diff --git a/.eslintignore b/.eslintignore index e1bf90151..1b84fb0bf 100644 --- a/.eslintignore +++ b/.eslintignore @@ -8,3 +8,12 @@ src/geom/polygon/Earcut.js src/utils/array/StableSort.js src/utils/object/Extend.js src/structs/RTree.js +src/dom/_ScaleManager.js +src/dom/VisualBounds.js +plugins/spine/src/spine-canvas.js +plugins/spine/src/spine-webgl.js +webpack.* +webpack.config.js +webpack.dist.config.js +webpack.fb.config.js +webpack.fb.dist.config.js diff --git a/.eslintrc.json b/.eslintrc.json index d0b2f6f52..f0680fd43 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,7 +16,8 @@ "CANVAS_RENDERER": true, "Phaser": true, "process": true, - "ActiveXObject": true + "ActiveXObject": true, + "FBInstant": true }, "rules": { @@ -71,7 +72,8 @@ "eol-last": [ "error" ], "func-call-spacing": [ "error", "never" ], "indent": [ "error", 4, { "SwitchCase": 1 } ], - "key-spacing": [ "error", { "beforeColon": false, "afterColon": true }], + "key-spacing": [ "error", { "beforeColon": false, "afterColon": true } ], + "keyword-spacing": [ "error", { "after": true } ], "linebreak-style": [ "off" ], "lines-around-comment": [ "error", { "beforeBlockComment": true, "afterBlockComment": false, "beforeLineComment": true, "afterLineComment": false, "allowBlockStart": true, "allowBlockEnd": false, "allowObjectStart": true, "allowArrayStart": true }], "new-parens": "error", diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index e49c20e2f..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,9 +0,0 @@ -This repo is for Phaser 3 related issues only. If you've found an issue with Phaser 2 please see the [Phaser CE (Community Edition)](https://github.com/photonstorm/phaser-ce) repo instead. - -This should not be used for technical support. If you're struggling trying to use Phaser then post your question to the [forum](http://www.html5gamedevs.com/forum/33-phaser-3/), [Slack](https://phaser.io/community/slack) or [Discord](https://phaser.io/community/discord) channels. GitHub Issues are for bugs and feature requests only. - -API errors must include example code showing what happens, and why you don't believe this is the expected behavior. Issues posted without code take _far_ longer to get resolved, _if ever_. Feel free to use a site such as jsBin or [CodePen](https://codepen.io/pen?template=YeEWom) to demo the problem. If we can run it, and see the error, we can usually fix it. - -If your Issue contains _any_ form of hostility it will be instantly closed and you will be blocked from access to all our repos. - -**Be nice. We do this for free.** diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..c49b33b07 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,59 @@ +--- +name: "\U0001F41B Bug Report" +about: Report a bug found while using Phaser 3 + +--- + + + + +## Version + +* Phaser Version: + +* Operating system: + +* Browser: + + +## Description + + + + +## Example Test Code + + + + +## Additional Information + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..1c8b87f18 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,15 @@ +--- +name: "\U0001F389 Feature Request" +about: Share an idea about a feature you'd like to see in Phaser + +--- + +**We're constantly trying to make Phaser 3 better** + +So we'd love to hear about feature requests for the v3 API. Screenshots, example code or links to blog posts / other APIs are encouraged. + +Please try and keep the requests sensible. We will only keep those we feel are within our abilities to add to Phaser, or that are a good fit for our API. + +**[Optional] Do you want to help provide this feature?** + +If you would like to get involved in helping build the feature, please let us know. We can then discuss implementation with you and the best way to approach it. Again, screenshots or mockups are really useful. diff --git a/.github/no-response.yml b/.github/no-response.yml new file mode 100644 index 000000000..cfbe92445 --- /dev/null +++ b/.github/no-response.yml @@ -0,0 +1,14 @@ +# Configuration for no-response - https://github.com/probot/no-response + +# Number of days of inactivity before an Issue is closed for lack of response +daysUntilClose: 30 +# Label requiring a response +# TODO: also close `needs-reproduction` issues (blocked by https://github.com/probot/no-response/issues/11) +responseRequiredLabel: 🤷‍♂️ More info needed +# Comment to post when closing an issue due to lack of response. +closeComment: > +Thank you for taking time to open this issue. + +We haven’t gotten a response to our questions above. With the details currently given in the issue we don’t have enough information to take action. + +So we’re going to close this issue. We can re-open it if you find the time to provide the information we need. diff --git a/CHANGELOG.md b/CHANGELOG.md index ea4dddb42..c31b8a6df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,842 @@ # Change Log -## Version 3.11.0 - Leafa - in development +## Version 3.16.0 - Ishikawa - in development + +### Facebook Instant Games Updates and Fixes + +* Added the `Leaderboard.getConnectedScores` method, to get a list of scores from player connected entries. +* The `loadPlayerPhoto` function in the Instant Games plugin now listens for the updated Loader event correctly, causing the `photocomplete` event to fire properly. +* `Leaderboard.setScore` now emits the LeaderboardScore object with the `setscore` event, as the documentation said it did. +* `Leaderboard.getPlayerScore` now only populates the `playerScore` property if the entry isn't `null`. +* If the `setScore` or `getPlayerScore` calls fail, it will return `null` as the score instance, instead of causing a run-time error. +* You can now pass an object or a string to `setScore` and objects will be automatically stringified. +* The `preloadAds` method will now only create an AdInstance object if the interstitial `loadSync` promise resolves. +* The `preloadVideoAds` method will now only create an AdInstance object if the interstitial `loadSync` promise resolves. +* The `preloadAds` method will now emit the `adsnofill` event, if there are no ads in the inventory to load. +* The `preloadVideoAds` method will now emit the `adsnofill` event, if there are no ads in the inventory to load. +* The `showAd` method will now emit the `adsnotloaded` event, if there are no ads loaded matching the given Placement ID. +* The `showVideo` method will now emit the `adsnotloaded` event, if there are no ads loaded matching the given Placement ID. +* Showing an ad will emit the `adfinished` event when the ad is closed, previously this event was called `showad` but the new name better reflects what has happened. +* The Facebook Plugin is now available in the `Phaser.Scene` class template under the `facebook` property (thanks @bryanwood) + +### Keyboard Input - New Features + +The specificity of the Keyboard events has been changed to allow you more control over event handling. Previously, the Keyboard Plugin would emit the global `keydown_CODE` event first (where CODE was a keycode string, like `keydown_A`), then it would emit the global `keydown` event. In previous versions, `Key` objects, created via `this.input.keyboard.addKey()`, didn't emit events. + +The `Key` class now extends EventEmitter and emits two new events directly: `down` and `up`. This means you can listen for an event from a Key you've created, i.e.: `yourKey.on('up', handler)`. + +The order has also now changed. If it exists, the Key object will dispatch its `down` event first. Then the Keyboard Plugin will dispatch `keydown_CODE` and finally the least specific of them all, `keydown` will be dispatched. + +You also now have the ability to cancel this at any stage either on a local or global level. All events handlers are sent an event object which you can call `event.stopImmediatePropagation()` on. This will immediately stop any further listeners from being invoked in the current Scene. Therefore, if you call `stopImmediatePropagation()` in the `Key.on` handler, then the Keyboard Plugin will not emit either the `keydown_CODE` or `keydown` global events. You can also call `stopImmediatePropagation()` during the `keydown_CODE` handler, to stop it reaching the global `keydown` handler. As `keydown` is last, calling it there has no effect. + +There is also the `stopPropagation()` function. This works in the same way as `stopImmediatePropagation` but instead of being local, it works across all of the Scenes in your game. For example, if you had 3 active Scenes (A, B and C, with A at the top of the Scene list), all listening for the same key, calling `stopPropagation()` in Scene A would stop the event from reaching any handlers in Scenes B or C. Remember that events flow down the Scene list from top to bottom. So, the top-most rendering Scene in the Scene list has priority over any Scene below it. + +All the above also works for `keyup` events. + +New in 3.16 is the ability to receive a global `keydown` or `keyup` event from any key on the keyboard. Previously, it would only emit the event if it came from one of the keys listed in the KeyCodes file. Now, those global events will fire for any key, regardless of location. + +#### Keyboard Captures + +Key capturing is the way in which you stop a keyboard DOM event from activating anything else in the browser by calling `preventDefault` on it. For example, in tall web pages, pressing the SPACE BAR causes the page to scroll down. Obviously, if this is also the fire or jump button in your game, you don't want this to happen. So the key needs to be 'captured' to prevent it. Equally, you may wish to also capture the arrow keys, for similar reasons. Key capturing is done on a global level. If you set-up the capture of a key in one Scene, it will be captured globally across the whole game. + +In 3.16 you now do this using the new `KeyboardPlugin.addCapture` method. This takes keycodes as its argument. You can either pass in a single key code (i.e. 32 for the Space Bar), an array of key codes, or a comma-delimited string - in which case the string is parsed and each code it can work out is captured. + +To remove a capture you can use the `KeyboardPlugin.removeCapture` method, which takes the same style arguments as adding captures. To clear all captures call `KeyboardPlugin.clearCaptures`. Again, remember that these actions are global. + +You can also temporarily enable and disable capturing using `KeyboardPlugin.enableGlobalCapture` and `KeyboardPlugin.disableGlobalCapture`. This means if you set-up a bunch of key captures, but then need to disable them all for a while (perhaps you swap focus to a DOM text field), you can call `disableGlobalCapture` to do this, and when finished in the DOM you can enable captures again with `enableGlobalCapture`, without having to clear and re-create them all. + +Default captures can be defined in the Game Config in the `input.keyboard.captures` object. The captures are actually stored in the `KeyboardManager` class. The `KeyboardPlugin` is just a proxy to methods in the Keyboard Manager, but is how you should interface with it. + +* `KeyboardPlugin.addCapture` is a new method that allows you to define a set of keycodes to have the default browser behaviors disabled on. +* `KeyboardPlugin.removeCapture` is a new method that removes specific previously set key captures. +* `KeyboardPlugin.clearCaptures` is a new method that removes all key captures. +* `KeyboardPlugin.getCaptures` is a new method that returns an array of all current key captures. +* `KeyboardPlugin.enableGlobalCapture` is a new method that enables any key captures that have been created. +* `KeyboardPlugin.disableGlobalCapture` is a new method that disables any key captures that have been created, without removing them from the captures list. +* `KeyboardPlugin.addKey` has a new boolean argument `enableCapture`, which is true by default, that will add a key capture for the Key being created. +* `KeyboardPlugin.addKeys` has a new boolean argument `enableCapture`, which is true by default, that will add a key capture for any Key created by the method. + +#### Other Keyboard Updates and Fixes + +* There is a new class called `KeyboardManager`. This class is created by the global Input Manager, if keyboard access has been enabled in the Game config. It's responsible for handling all browser keyboard events. Previously, the `KeyboardPlugin` did this. Which meant that every Scene that had its own Keyboard Plugin was binding more native keyboard events. This was causing problems with parallel Scenes when needing to capture keys. the `KeyboardPlugin` class still exists, and is still the main point of interface when you call `this.input.keyboard` in a Scene, but DOM event handling responsibility has been taken away from it. This means there's no only +one set of bindings ever created, which makes things a lot cleaner. +* There is a new Game and Scene Config setting `input.keyboard.capture` which is an array of KeyCodes that the Keyboard Plugin will capture all non-modified key events on. By default it is empty. You can populate it in the config, or use the new capture methods. +* The Keyboard Manager will now call `preventDefault` only on non-modified key presses, stopping the keyboard event from hitting the browser. Previously, capturing the R key, for example, would block a CTRL+R page reload, but it now ignores it because of the key modifier. +* `Key.emitOnRepeat` is a new boolean property that controls if the Key will continuously emit a `down` event while being held down (true), or emit the event just once, on first press, and then skip future events (false). +* `Key.setEmitOnRepeat` is a new chainable method for setting the `emitOnRepeat` property. +* The `KeyboardPlugin.addKeys` method has a new optional boolean `emitOnRepeat` which sets that property on all Key objects it creates as part of the call. It defaults to `false`. +* The `KeyboardPlugin.addKey` method has a new optional boolean `emitOnRepeat` which sets that property on the Key object it creates. It defaults to `false`. +* The `Key` class now extends EventEmitter and emits two events directly: `down` and `up`. This means you can listen for an event from a Key you've created, i.e.: `yourKey.on('up', handler)`. +* The following Key Codes have been added, which include some missing alphabet letters in Persian and Arabic: `SEMICOLON_FIREFOX`, `COLON`, `COMMA_FIREFOX_WINDOWS`, `COMMA_FIREFOX`, `BRACKET_RIGHT_FIREFOX` and `BRACKET_LEFT_FIREFOX` (thanks @wmateam) +* `Key.onDown` is a new method that handles the Key being pressed down, including down repeats. +* `Key.onUp` is a new method that handles the Key being released. +* `Key.destroy` is a new method that handles Key instance destruction. It is called automatically in `KeyboardPlugin.destroy`. +* The `Key.preventDefault` property has been removed. This is now handled by the global keyboard capture methods. +* `Key.metaKey` is a new boolean property which indicates if the Meta Key was held down when the Key was pressed. On a Mac the Meta Key is Command. On a Windows keyboard, it's the Windows key. +* `InputManager.keyboard` is a new property that instantiates the global Keyboard Manager, if enabled in the game config. +* The `KeyboardPlugin.addKey` method has a new boolean property `enableCapture` which automatically prevents default on the Key being created. +* The `KeyboardPlugin.addKeys` method has a new boolean property `enableCapture` which automatically prevents default on Keys being created. +* `Phaser.Input.Keyboard.ProcessKeyDown` has been removed as it's no longer required, `Key.onDown` handles it instead. +* `Phaser.Input.Keyboard.ProcessKeyUp` has been removed as it's no longer required, `Key.onUp` handles it instead. +* The Keyboard Manager has a property called `captures` which is an array of keycodes, as populated by the Game Config. Any key code in the array will have `preventDefault` called on it if pressed. +* `KeyboardPlugin.manager` is a new property that references the Keyboard Manager and is used internally. +* `KeyboardPlugin.target` has been removed as it's no longer used by the class. +* `KeyboardPlugin.queue` has been removed as it's no longer used by the class. +* `KeyboardPlugin.onKeyHandler` has been removed as it's no longer used by the class. + +### Mouse and Touch Input - New Features, Updates and Fixes + +* The Mouse Manager class has been updated to remove some commented out code and refine the `startListeners` method. +* When enabling a Game Object for input it will now use the `width` and `height` properties of the Game Object first, falling back to the frame size if not found. This stops a bug when enabling BitmapText objects for input and it using the font texture as the hit area size, rather than the text itself. +* `Pointer.smoothFactor` is a float-value that allows you to automatically apply smoothing to the Pointer position as it moves. This is ideal when you want something smoothly tracking a pointer in a game, or are need a smooth drawing motion for an art package. The default value is zero, meaning disabled. Set to a small number, such as 0.2, to enable. +* `Config.inputSmoothFactor` is a new property that allows you to set the smoothing factor for all Pointers the game creators. The default value is zero, which is disabled. Set in the game config as `input: { smoothFactor: value }`. +* `InputManager.transformPointer` has a new boolean argument `wasMove`, which controls if the pointer is being transformed after a move or up/down event. +* `Pointer.velocity` is a new Vector2 that contains the velocity of the Pointer, based on the current and previous positions. The velocity is smoothed out each frame, according to the `Pointer.motionFactor` property. This is done for more accurate gesture recognition. The velocity is updated based on Pointer movement, it doesn't require a button to be pressed first. +* `Pointer.angle` is a new property that contains the angle of the Pointer, in radians, based on the current and previous positions. The angle is smoothed out each frame, according to the `Pointer.motionFactor` property. This is done for more accurate gesture recognition. The angle is updated based on Pointer movement, it doesn't require a button to be pressed first. +* `Pointer.distance` is a new property that contains the distance of the Pointer, in radians, based on the current and previous positions. The distance is smoothed out each frame, according to the `Pointer.motionFactor` property. This is done for more accurate gesture recognition. The distance is updated based on Pointer movement, it doesn't require a button to be pressed first. +* `Pointer.motionFactor` is a new property that controls how much smoothing to apply to the Pointer positions each frame. This value is passed to the Smooth Step Interpolation that is used to calculate the velocity, angle and distance of the Pointer. It's applied every frame, until the midPoint reaches the current position of the Pointer. The default value is 0.2. +* The Input Plugin was emitting a `preUpdate` event, with the capital U, instead of `preupdate`. This has now been corrected. Fix #4185 (thanks @gadelan) +* `Pointer.updateMotion` is a new method that is called automatically, each step, by the Input Manager. It's responsible for calculating the Pointer velocity, angle and distance properties. +* `Pointer.time` is a new property that holds the time the Pointer was last updated by the Game step. +* `Pointer.getDistance` has been updated. If called while a button is being held down, it will return the distance between the Pointer's current position and it's down position. If called when a Pointer doesn't have a button down, it will return the historic distance between the up and down positions. +* `Pointer.getDistanceX` is a new method that will return the horizontal distance between the Pointer's previous and current coordinates. If called while a button is being held down, it will return the distance between the Pointer's current position and it's down position. If called when a Pointer doesn't have a button down, it will return the historic distance between the up and down positions. +* `Pointer.getDistanceY` is a new method that will return the horizontal distance between the Pointer's previous and current coordinates. If called while a button is being held down, it will return the distance between the Pointer's current position and it's down position. If called when a Pointer doesn't have a button down, it will return the historic distance between the up and down positions. +* `Pointer.getDuration` is a new method that will return the duration the Pointer was held down for. If the Pointer has a button pressed down at the time this method is called, it will return the duration since the Pointer's was pressed down. If no button is held down, it will return the last recorded duration, based on the time the Pointer button was released. +* `Pointer.getAngle` is a new method that will return the angle between the Pointer coordinates. If the Pointer has a button pressed down at the time this method is called, it will return the angle between the Pointer's `downX` and `downY` values and the current position. If no button is held down, it will return the last recorded angle, based on where the Pointer was when the button was released. +* In previous versions, the VisibilityHandler would create a `mousedown` listener for the game canvas and then call `window.focus` when detected (assuming the game config `autoFocus` property was `true`). Responsibility for this has now been handled to the Mouse Manager `onMouseDown` handler. +* In previous versions, the VisibilityHandler would create a `mouseout` listener for the game canvas and then set `game.isOver` when detected. Responsibility for this has now been handled to the Mouse Manager, which sets the new Input Manager `isOver` property directly. +* In previous versions, the VisibilityHandler would create a `mouseover` listener for the game canvas and then set `game.isOver` when detected. Responsibility for this has now been handled to the Mouse Manager, which sets the new Input Manager `isOver` property directly. +* The `Phaser.Game.isOver` property has been moved. You can now find it in the Input Manager and it's also accessible via the Input Plugin, which means you can do `this.input.isOver` from within a Scene. This makes more sense as it's input related and not a game level property. +* The Input Plugin has a new event you can listen to: `gameover`, which is triggered whenever the mouse or a pointer is moved over the Game canvas. Listen to it with `this.input.on('gameover')` from within a Scene. +* The Input Plugin has a new event you can listen to: `gameout`, which is triggered whenever the mouse or a pointer leaves the Game canvas. Listen to it with `this.input.on('gameout')` from within a Scene. +* The Game used to emit a `mouseover` event when the mouse entered the game canvas. This is no longer emitted by the Game itself and can instead be listened for using the new Input Plugin event `gameover`. +* The Game used to emit a `mouseout` event when the mouse left the game canvas. This is no longer emitted by the Game itself and can instead be listened for using the new Input Plugin event `gameout`. +* If the `window` object exists (which it will in normal browser environments) new `mouseup` and `touchend` event listeners are bound to it and trigger the normal `mouseup` or `touchend` events within the internal input system. This means if you will now get a `pointerup` event from the Input Plugin even if the pointer is released outside of the game canvas. Pointers will also no longer think they are still 'down' if released outside the canvas and then moved inside again in their new state. +* The window will now have focus called on it by the Touch Manager, as well as the Mouse Manager, is the `autoFocus` game config property is enabled. +* The Input Plugin has a new event you can listen to: `pointerdownoutside`, which is triggered whenever the mouse or a pointer is pressed down while outside of the Game canvas. Listen to it with `this.input.on('pointerdownoutside')` from within a Scene. +* The Input Plugin has a new event you can listen to: `pointerupoutside`, which is triggered whenever the mouse or a pointer is released while outside of the Game canvas. Listen to it with `this.input.on('pointerupoutside')` from within a Scene. +* `Pointer.downElement` is a new property that holds the target of the DOM Event that triggered when the Pointer was pressed down. If this is within the game, this will be the game canvas element. +* `Pointer.upElement` is a new property that holds the target of the DOM Event that triggered when the Pointer was released. If this is within the game, this will be the game canvas element. + +### New Features + +* You can now load external Scene files using the new `load.sceneFile` method. This allows you to dynamically load a Scene into the Scene Manager of your game, and swap to it at will. Please see the documentation and examples for further details. +* The data object being sent to the Dynamic Bitmap Text callback now has a new property `parent`, which is a reference to the Bitmap Text instance that owns the data object (thanks ornyth) +* The WebGL Renderer has a new method `clearPipeline`, which will clear down the current pipeline and reset the blend mode, ready for the context to be passed to a 3rd party library. +* The WebGL Renderer has a new method `rebindPipeline`, which will rebind the given pipeline instance, reset the blank texture and reset the blend mode. Which is useful for recovering from 3rd party libs that have modified the gl context. +* Game Objects have a new property called `state`. Use this to track the state of a Game Object during its lifetime. For example, it could move from a state of 'moving', to 'attacking', to 'dead'. Phaser itself will never set this property, although plugins are allowed to. +* Game Objects have a new method called `setState` which will set the state property in a chainable call. +* `BlendModes.ERASE` is a new blend mode that will erase the object being drawn. When used in conjunction with a Render Texture it allows for effects that let you erase parts of the texture, in either Canvas or WebGL. When used with a transparent game canvas, it allows you to erase parts of the canvas, showing the web page background through. +* `BlendModes.SOURCE_IN` is a new Canvas-only blend mode, that allows you to use the `source-in` composite operation when rendering Game Objects. +* `BlendModes.SOURCE_OUT` is a new Canvas-only blend mode, that allows you to use the `source-out` composite operation when rendering Game Objects. +* `BlendModes.SOURCE_ATOP` is a new Canvas-only blend mode, that allows you to use the `source-atop` composite operation when rendering Game Objects. +* `BlendModes.DESTINATION_OVER` is a new Canvas-only blend mode, that allows you to use the `destination-over` composite operation when rendering Game Objects. +* `BlendModes.DESTINATION_IN` is a new Canvas-only blend mode, that allows you to use the `destination-in` composite operation when rendering Game Objects. +* `BlendModes.DESTINATION_OUT` is a new Canvas-only blend mode, that allows you to use the `destination-out` composite operation when rendering Game Objects. +* `BlendModes.DESTINATION_ATOP` is a new Canvas-only blend mode, that allows you to use the `destination-atop` composite operation when rendering Game Objects. +* `BlendModes.LIGHTER` is a new Canvas-only blend mode, that allows you to use the `lighter` composite operation when rendering Game Objects. +* `BlendModes.COPY` is a new Canvas-only blend mode, that allows you to use the `copy` composite operation when rendering Game Objects. +* `BlendModes.XOR` is a new Canvas-only blend mode, that allows you to use the `xor` composite operation when rendering Game Objects. +* `RenderTexture.erase` is a new method that will take an object, or array of objects, and draw them to the Render Texture using an ERASE blend mode, resulting in them being removed from the Render Texture. This is really handy for making a bitmap masked texture in Canvas or WebGL (without using an actual mask), or for 'cutting away' part of a texture. +* There is a new boolean Game Config property called `customEnvironment`. If set to `true` it will skip the internal Feature checks when working out which type of renderer to create, allowing you to run Phaser under non-native web environments. If using this value, you _must_ set an explicit `renderType` of either CANVAS or WEBGL. It cannot be left as AUTO. Fix #4166 (thanks @jcyuan) +* `Animation.nextFrame` will advance an animation to the next frame in the sequence instantly, regardless of the animation time or state. You can call this on a Sprite: `sprite.anims.nextFrame()` (thanks rgk25) +* `Animation.previousFrame` will set an animation to the previous frame in the sequence instantly, regardless of the animation time or state. You can call this on a Sprite: `sprite.anims.previousFrame()` (thanks rgk25) +* `Geom.Intersects.PointToLine` has a new optional argument `lineThickness` (which defaults to 1). This allows you to determine if the point intersects a line of a given thickness, where the line-ends are circular (not square). +* `Geom.Line.GetNearestPoint` is a new static method that will return the nearest point on a line to the given point. +* `Geom.Line.GetShortestDistance` is a new static method that will return the shortest distance from a line to the given point. +* `Camera.getBounds` is a new method that will return a rectangle containing the bounds of the camera. +* `Camera.centerOnX` will move the camera horizontally to be centered on the given coordinate, without changing its vertical placement. +* `Camera.centerOnY` will move the camera vertically to be centered on the given coordinate, without changing its horizontally placement. +* `AnimationManager.exists` is a new method that will check to see if an Animation using the given key already exists or not and returns a boolean. +* `animationstart-key` is a new Animation key specific event emitted by a Game Object. For example, if you had an animation with a key of 'explode' you can now listen for `animationstart-explode`. +* `animationrestart-key` is a new Animation key specific event emitted by a Game Object. For example, if you had an animation with a key of 'explode' you can now listen for `animationrestart-explode`. +* `animationcomplete-key` is a new Animation key specific event emitted by a Game Object. For example, if you had an animation with a key of 'explode' you can now listen for `animationcomplete-explode`. +* `animationupdate-key` is a new Animation key specific event emitted by a Game Object. For example, if you had an animation with a key of 'explode' you can now listen for `animationupdate-explode`. +* The Animation class now extends the Event Emitter and dispatches events itself. This allows you to listen for events from a specific Animation, rather than via a Game Object. This is handy, for example, if you had an explosion animation that you wanted to trigger a sound effect when it started. You can now listen for the events from the Animation object directly. +* The Animation class now emits the `start` event when played (either forward, or in reverse) by any Game Object. +* The Animation class now emits the `restart` event when it restarts playing on any Game Object. +* The Animation class now emits the `complete` event when it finishes playing on any Game Object. +* The Animation Component has a new method called `chain` which allows you to line-up another animation to start playing as soon as the current one stops, no matter how it stops (either by reaching its natural end, or directly by having stop called on it). You can chain a new animation at any point, including before the current one starts playing, during it, or when it ends (via its `animationcomplete` callback). Chained animations are specific to a Game Object, meaning different Game Objects can have different chained animations without impacting the global animation they're playing. +* `CanvasTexture.drawFrame` is a new method that allows you to draw a texture frame to the CanvasTexture based on the texture key and frame given. +* `CanvasTexture.getIndex` is a new method that will take an x/y coordinate and return the Image Data index offset used to retrieve the pixel values. +* `CanvasTexture.getPixels` is a new method that will take a region as an x/y and width/height and return all of the pixels in that region from the CanvasTexture. +* `CanvasTexture.setPixel` is a new method that sets the given pixel in the CanvasTexture to the color and alpha values provided. +* `CanvasTexture.getData` is a new method that will extract an ImageData block from the CanvasTexture from the region given. +* `CanvasTexture.putData` is a new method that will put an ImageData block at the given coordinates in a CanvasTexture. + +### Updates + +* You can now modify `this.physics.world.debugGraphic.defaultStrokeWidth` to set the stroke width of any debug drawn body, previously it was always 1 (thanks @samme) +* `TextStyle.setFont` has a new optional argument `updateText` which will sets if the text should be automatically updated or not (thanks @DotTheGreat) +* `ProcessQueue.destroy` now sets the internal `toProcess` counter to zero. +* The `PathFollower.pathRotationVerticalAdjust` property has been removed. It was supposed to flipY a follower when it reversed path direction, but after some testing it appears it has never worked and it's easier to do this using events, so the property and associated config value are removed. The `verticalAdjust` argument from the `setRotateToPath` method has been removed as well. +* The config value `preserveDrawingBuffer` has been removed as it has never been used by the WebGL Renderer. +* `PluginManager.install` returns `null` if the plugin failed to install in all cases. +* `PluginFile` will now install the plugin into the _current_ Scene as long as the `start` or `mapping` arguments are provided. +* MATH_CONST no longer requires or sets the Random Data Generator, this is now done in the Game Config, allowing you to require the math constants without pulling in a whole copy of the RNG with it. +* The Dynamic Bitmap Text Canvas Renderer was creating a new data object every frame for the callback. It now uses the `callbackData` object instead, like the WebGL renderer does. +* `WebGLRenderer.setBlendMode` has a new optional argument `force`, which will force the given blend mode to be set, regardless of the current settings. +* The method `DisplayList.sortGameObjects` has been removed. It has thrown a runtime error since v3.3.0! which no-one even spotted, a good indication of how little the method is used. The display list is automatically sorted anyway, so if you need to sort a small section of it, just use the standard JavaScript Array sort method (thanks ornyth) +* The method `DisplayList.getTopGameObject` has been removed. It has thrown a runtime error since v3.3.0! which no-one even spotted, a good indication of how little the method is used (thanks ornyth) +* `WebGLRenderer.setFramebuffer` has a new optional boolean argument `updateScissor`, which will reset the scissor to match the framebuffer size, or clear it. +* `WebAudioSoundManager.onFocus` will not try to resume the Audio Context if it's still locked. +* `WebAudioSoundManager.onBlur` will not try to suspend the Audio Context if it's still locked. +* When using `ScenePlugin.add`, to add a new Scene to the Scene Manager, it didn't allow you to include the optional Scene data object. You can now pass this in the call (thanks @kainage) +* `Graphics.stroke` is a new alias for the `strokePath` method, to keep the calls consistent with the Canvas Rendering Context API. +* `Graphics.fill` is a new alias for the `fillPath` method, to keep the calls consistent with the Canvas Rendering Context API. +* `LoaderPlugin.sceneManager` is a new property that is a reference to the global Scene Manager, useful for Plugins. +* Whenever `Camera.roundPixels` was enabled it would use a bitwise operation to truncate the float (`x |= 0`) - this has been replaced across all files that used it, with a call to `Math.round` instead. This gives far better results when zooming cameras both in and out of a Scene, stopping thin gaps appearing between closely packed Game Objects. +* `AnimationManager.create` will now return a boolean `false` if the given key is invalid (i.e. undefined or falsey). +* `AnimationManager.create` will no longer raise a console warning if the animation key is already in use. Instead, it will return the animation belonging to that key. A brand new animation will only be created if the key isn't already in use. When this happens, the `add` event is emitted by the Animation Manager. If no event is emitted, the animation already existed. +* `ArcadePhysics.Body.destroy` will now only add itself to the World `pendingDestroy` list if the world property exists. This prevents `Cannot read property 'pendingDestroy' of undefined` errors if you try to delete a physics body in a callback and then immediately change Scene (which tells the physics work to also delete all bodies) +* The Animation Component `restart` method has had is sole `key` argument removed. Previously, you had to pass in the key of the animation you wished to reverse, but now you can just call the method directly, and as long as there is an animation playing, it will automatically start playing in reverse, without the nee for a key (the way it should have been originally) +* `Animation.play` and `playReverse` will now accept either a string-based key of the animation to play (like before), or you can pass in an Animation instance, and it will play that animation. +* `CanvasTexture.clear` now has 4 new optional arguments: `x, y, width, height` which allow you to define the region of the texture to be cleared. If not provided it will clear the whole texture, which is the same behavior as before. +* EarCut, the polygon triangulation library used by the Graphics and WebGL classes, has been upgraded from 2.1.1 to 2.1.4. 2.1.2 fixed a few race conditions where bad input would cause an error. 2.1.3 improved performance for bigger inputs (5-12%) and 2.1.4 fixed a race condition that could lead to a freeze on degenerate input. +* `TextureTintPipeline.batchQuad` and `batchTri` have two new optional arguments `texture` and `unit` which are used to re-set the batch texture should the method cause a batch flush. +* `TextureTintPipeline.requireTextureBatch` is a new internal method that helps speed-up the creation of texture batches. It is used in conjunction with `setTexture2D` and `pushBatch`. +* `TextureTintPipeline.flush` and `TextureTintPipeline.pushBatch` have been optimized to handle zero based texture units as priority. They've also been refactored to avoid creation of empty texture batches. +* The `WebGLRenderer.setTexture2D` method has a new optional argument `flush` which controls if the pipeline is flushed if the given texture is new, or not. This is used internally to skip flushing during an existing flush. +* The Tilemap Layer `width` and `height` properties are now based on the tilemap tile sizes multiplied by the layer dimensions. This corrects an issue with layer sizes being wrong if you called `setBaseTileSize` on a Map. +* The WebGLRenderer will now clear the framebuffer at the start of every render. +* `WebGLRenderer.setScissor` now has a new optional argument `drawingBufferHeight` which allows you to specify the drawing buffer height, rather than use the renderers default value. +* `WebGLRenderer.pushScissor` now has a new optional argument `drawingBufferHeight` which allows you to specify the drawing buffer height, rather than use the renderers default value. +* `WebGLRenderer.preRender` now calls `gl.clearColor` in order to restore the background clear color in case something, like a Render Texture, has changed it. + +### Bug Fixes + +* The Rectangle Shape object wouldn't render if it didn't have a stroke, or any other objects on the display list (thanks mliko) +* When using a font string instead of setting `fontFamily`, `fontSize` and `fontStyle` in either `Text.setStyle` or `setFont`, the style properties wouldn't get set. This isn't a problem while creating the text object, only if modifying it later (thanks @DotTheGreat) +* `Text.toJSON` wasn't saving the font style when using the "font" shorthand to create it. It now saves it correctly. Fix #4141 (thanks @divillysausages) +* Disabling camera bounds and then moving the camera to an area in a Tilemap that did not have any tile information would throw an `Uncaught Reference error` as it tried to access tiles that did not exist (thanks @Siyalatas) +* Fixed an issue where Sprite Sheets being extracted from a texture atlas would fail if the sheet was either just a single column or single row of sprites. Fix #4096 (thanks @Cirras) +* If you created an Arcade Physics Group without passing a configuration object, and passing an array of non-standard children, it would throw a classType runtime error. It now creates a default config object correctly (thanks @pierpo) +* The `Camera.cull` method has been restructured so it now calculates if a Game Object is correctly in view or not, before culling it. Although not used internally, if you need to cull objects for a camera, you can now safely use this method. Fix #4092 (thanks @Cirras) +* The Tiled Parser would ignore animated tile data if it was in the new Tiled 1.2 format. This is now accounted for, as well as 1.0 (thanks @nkholski) +* `Array.Matrix.ReverseRows` was actually reversing the columns, but now reverses the rows. +* `Array.Matrix.ReverseColumns` was actually reversing the rows, but now reverses the columns. +* UnityAtlas now sets the correct file type key if using a config file object. +* Starting with version 3.13 in the Canvas Renderer, it was possible for long-running scripts to start to get bogged-down in `fillRect` calls if the game had a background color set. The context is now saved properly to avoid this. Fix #4056 (thanks @Aveyder) +* Render Textures created larger than the size of the default canvas would be automatically clipped when drawn to in WebGL. They now reset the gl scissor and drawing height property in order to draw to their full size, regardless of the canvas size. Fix #4139 (thanks @chaoyang805 @iamchristopher) +* The `cameraFilter` property of a Game Object will now allow full bitmasks to be set (a value of -1), instead of just those > 0 (thanks @stuartkeith) +* The `PathFollower.startFollow` method now properly uses the `startAt` argument to the method, so you can start a follower off at any point along the path. Fix #3688 (thanks @DannyT @diteix) +* Static Circular Arcade Physics Bodies now render as circles in the debug display, instead of showing their rectangle bounds (thanks @maikthomas) +* Changing the mute flag on an `HTML5AudioSound` instance, via the `mute` setter, now works, as it does via the Sound Manager (thanks @Waclaw-I @neon-dev) +* Changing the volume on an `HTML5AudioSound` instance, via the `volume` setter, now works, as it does via the Sound Manager (thanks @Waclaw-I) +* The Dynamic Tilemap Layer WebGL renderer was drawing tiles at the incorrect position if the layer was scaled. Fix #4104 (thanks @the-realest-stu) +* `Tile.tileset` now returns the specific Tileset associated with the tile, rather than an array of them. Fix #4095 (thanks @quadrupleslap) +* `Tile.getCollisionGroup` wouldn't return the correct Group after the change to support multiple Tilesets. It now returns the group properly (thanks @jbpuryear) +* `Tile.getTileData` wouldn't return the correct data after the change to support multiple Tilesets. It now returns the tile data properly (thanks @jbpuryear) +* The `GetTileAt` and `RemoveTileAt` components would error with "Cannot read property 'index' of undefined" if the tile was undefined rather than null. It now handles both cases (thanks @WaSa42) +* Changing `TileSprite.width` or `TileSprite.height` will now flag the texture as dirty and call `updateDisplayOrigin`, allowing you to resize TileSprites dynamically in both Canvas and WebGL. +* `RandomDataGenerator.shuffle` has been fixed to use the proper modifier in the calculation, allowing for a more even distribution (thanks wayfinder) +* The Particle Emitter was not recycling dead particles correctly, so it was creating new objects every time it emitted (the old particles were then left to the browsers gc to clear up). This has now been recoded, so the emitter will properly keep track of dead particles and re-use them (thanks @Waclaw-I for the initial PR) +* `ParticleEmitter.indexSortCallback` has been removed as it's no longer required. +* `Particle.index` has been removed, as it's no longer required. Particles don't need to keep track of their index any more. +* The Particle Emitter no longer needs to call the StableSort.inplace during its preUpdate, saving cpu. +* `Particle.resetPosition` is a new method that is called when a particle dies, preparing it ready for firing again in the future. +* The Canvas `SetTransform` method would save the context state, but it wasn't restored at the end in the following Game Objects: Dynamic Bitmap Text, Graphics, Arc, Curve, Ellipse, Grid, IsoBox, IsoTriangle, Line, Polygon, Rectangle, Star and Triangle. These now all restore the context, meaning if you're using non-canvas sized cameras in Canvas mode, it will now render beyond just the first custom camera. +* `Utils.Array.MoveUp` wouldn't let you move an array element to the top-most index in the array. This also impacted `Container.moveUp`. +* The Texture Tint Pipeline had a logic error that would cause every 2001st quad to either be invisible, or pick-up the texture of the 2000th quad by mistake. The `batchQuad` and `batchTri` methods how handle re-assigning the batch texture if they cause a batch flush as part of their process. +* Rotating Sprites that used a Normal Map wouldn't rotate the normal map with it, causing the lighting effects to become irregular. The normal map vectors are now rotated correctly (thanks @sercant for the PR and @fazzamatazz and @ysraelJMM for the report) +* Changing `scaleX` or `scaleY` on a `MatterImage` or `MatterSprite` would cause the body scale to become distorted as the setters didn't use the correct factor when resetting the initial scale. Fix #4206 (thanks @YannCaron) +* `StaticBody.reset` in Arcade Physics would ignore the `x` and `y` values given to it. If given, they're now used to reset the parent Game Object before the body is updated. Fix #4224 (thanks @samme) +* Static Tilemap Layers wouldn't render correctly if the layer used a tileset with a different size to the base map data (set via `setBaseTileSize`). They now render correctly in WebGL and Canvas, regardless of the base tile size. +* When using `RenderTexture.fill`, the `alpha` argument would be ignored in Canvas mode. It's now used when filling the RenderTexture. +* Fixed an issue in `WebGLRenderer.setScissor` where it was possible to try and compare the scissor size to a non-current scissor, if called outside of the render loop (i.e. from `RenderTexture.fill`) (thanks @hackhat) +* `RenderTexture.fill` in WebGL would use `gl.clear` and a clear color to try and fill the Render Texture. This only worked for full-canvas sized RenderTextures that didn't have a camera zoom applied. It has now been swapped to use the `drawFillRect` method of the Texture Tint Pipeline, allowing it to work properly regardless of camera zoom or size. +* `Container.getFirst` was using an incorrect Array Utils function `GetFirstElement`, when it should have been using `GetFirst`. It now uses the correct function. Fix #4244 (thanks @miran248) +* `List.getFirst` was using an incorrect Array Utils function `GetFirstElement`, when it should have been using `GetFirst`. It now uses the correct function. Fix #4244 (thanks @miran248) +* Fixed an issue where changing the viewport or size of a Camera belonging to a RenderTexture, it wouldn't impact the rendering and objects will still render outside of the viewport range. It's now converted to a proper gl scissor rect by the renderer, meaning you can limit the area rendered to by adjusting the internal Render Texture cameras viewport. Fix #4243 (thanks @hackhat) +* `CanvasTexture.destroy` is a new method that specifically handles the destruction of the CanvasTexture and all of its associated typed arrays. This prevents a memory leak when creating and destroying lots of RenderTextures (which are CanvasTexture backed). Fix #4239 (thanks @sjb933) +* The Alpha, Flip and Origin components have been removed from the Mesh Game Object (and by extension, Quad as well) as they are not used in the renderer and should be manipulated via the Mesh properties. Fix #4188 (thanks @enriqueto) + +### Examples and TypeScript + +Thanks to the following for helping with the Phaser 3 Examples and TypeScript definitions, either by reporting errors, or even better, fixing them: + +@guilhermehto @samvieten @darkwebdev @RoryO @snowbillr @slothyrulez @jcyuan + +### Phaser Doc Jam + +The Phaser Doc Jam was a community-backed effort to try and get the Phaser 3 API documentation to 100% coverage. The Doc Jam is now over and I offer my thanks to the following who helped with docs in this release: + +16patsle - @gurungrahul2 - @icbat - @samme - @telinc1 - anandu pavanan - blackhawx - candelibas - Diego Romero - doronlinder - Elliott Wallace - eric - Georges Gabereau - Haobo Zhang - henriacle - jak6jak - Jake Jensen - James Van Roose - JamesSkemp - joelahoover - Joey - madclaws - marc136 - Mihail Ilinov - naum303 - NicolasRoehm - nuane - rejacobson - Robert Kowalski - rodri042 - rootasjey - sawamara - scottwestover - sir13tommy - stetso - therealsamf - Tigran - willblackmore - zenwaichi + +Also, the following helped with the docs outside of the Doc Jam: + +@bryanwood @jestarray @matosummer @tfelix @imilo + +## Version 3.15.1 - Batou - 16th October 2018 + +* Re-enabled Input Manager resizing, which had been left disabled by mistake. + +## Version 3.15.0 - Batou - 16th October 2018 + +Note: We are releasing this version ahead of schedule in order to make some very important iOS performance and input related fixes available. It does not contain the new Scale Manager or Spine support, both of which have been moved to 3.16 as they require a few more weeks of development. + +### New Features + +* You can now set the `maxLights` value in the Game Config, which controls the total number of lights the Light2D shader can render in a single pass. The default is 10. Be careful about pushing this too far. More lights = less performance. Close #4081 (thanks @FrancescoNegri) +* `Rectangle.SameDimensions` determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. +* An ArcadePhysics Group can now pass `{ enable: false }`` in its config to disable all the member bodies (thanks @samme) +* `Body.setEnable` is a new chainable method that allows you to toggle the enable state of an Arcade Physics Body (thanks @samme) +* `KeyboardPlugin.resetKeys` is a new method that will reset the state of any Key object created by a Scene's Keyboard Plugin. +* `Pointer.wasCanceled` is a new boolean property that allows you to tell if a Pointer was cleared due to a `touchcancel` event. This flag is reset during the next `touchstart` event for the Pointer. +* `Pointer.touchcancel` is a new internal method specifically for handling touch cancel events. It has the same result as `touchend` without setting any of the up properties, to avoid triggering up event handlers. It will also set the `wasCanceled` property to `true`. + +### Updates + +* `WebGLRenderer.deleteTexture` will check to see if the texture it is being asked to delete is the currently bound texture or not. If it is, it'll set the blank texture to be bound after deletion. This should stop `RENDER WARNING: there is no texture bound to the unit 0` errors if you destroy a Game Object, such as Text or TileSprite, from an async or timed process (thanks jamespierce) +* The `RequestAnimationFrame.step` and `stepTimeout` functions have been updated so that the new Frame is requested from raf before the main game step is called. This allows you to now stop the raf callback from within the game update or render loop. Fix #3952 (thanks @tolimeh) +* If you pass zero as the width or height when creating a TileSprite it will now use the dimensions of the texture frame as the size of the TileSprite. Fix #4073 (thanks @jcyuan) +* `TileSprite.setFrame` has had both the `updateSize` and `updateOrigin` arguments removed as they didn't do anything for TileSprites and were misleading. +* `CameraManager.remove` has a new argument `runDestroy` which, if set, will automatically call `Camera.destroy` on the Cameras removed from the Camera Manager. You should nearly always allow this to happen (thanks jamespierce) +* Device.OS has been restructured to allow fake UAs from Chrome dev tools to register iOS devices. +* Texture batching during the batch flush has been implemented in the TextureTintPipeline which resolves the issues of very low frame rates, especially on iOS devices, when using non-batched textures such as those used by Text or TileSprites. Fix #4110 #4086 (thanks @ivanpopelyshev @sachinhosmani @maximtsai @alexeymolchan) +* The WebGLRenderer method `canvasToTexture` has a new optional argument `noRepeat` which will stop it from using `gl.REPEAT` entirely. This is now used by the Text object to avoid it potentially switching between a REPEAT and CLAMP texture, causing texture black-outs (thanks @ivanpopelyshev) +* `KeyboardPlugin.resetKeys` is now called automatically as part of the Keyboard Plugin `shutdown` method. This means, when the plugin shuts down, such as when stopping a Scene, it will reset the state of any key held in the plugin. It will also clear the queue of any pending events. +* The `Touch Manager` has been rewritten to use declared functions for all touch event handlers, rather than bound functions. This means they will now clear properly when the TouchManager is shut down. +* There is a new Input constant `TOUCH_CANCEL` which represents canceled touch events. + +### Bug Fixes + +* Fixed a bug in the canvas rendering of both the Static and Dynamic Tilemap Layers where the camera matrix was being multiplied twice with the layer, causing the scale and placement to be off (thanks galerijanamar) +* If you set `pixelArt` to true in your game config (or `antialias` to false) then TileSprites will now respect this when using the Canvas Renderer and disable smoothing on the internal fill canvas. +* TileSprites that were set to be interactive before they had rendered once wouldn't receive a valid input hit area, causing input to fail. They now define their size immediately, allowing them to be made interactive without having rendered. Fix #4085 (thanks @DotTheGreat) +* The Particle Emitter Manager has been given a NOOP method called `setBlendMode` to stop warnings from being thrown if you added an emitter to a Container in the Canvas renderer. Fix #4083 (thanks @maximtsai) +* The `game.context` property would be incorrectly set to `null` after the WebGLRenderer instance was created (thanks @samme) +* The Touch Manager, Input Manager and Pointer classes all now handle the `touchcancel` event, such as triggered on iOS when activating an out of browser UI gesture, or in Facebook Instant Games when displaying an overlay ad. This should prevent issues with touch input becoming locked on iOS specifically. Fix #3756 (thanks @sftsk @sachinhosmani @kooappsdevs) + +## Version 3.14.0 - Tachikoma - 1st October 2018 + +### Tilemap New Features, Updates and Fixes + +* Both Static and Dynamic Tilemap layers now support rendering multiple tilesets per layer in both Canvas and WebGL. To use multiple tilesets pass in an array of Tileset objects, or strings, to the `createStaticLayer` and `createDynamicLayer` methods respectively. +* `Tilemap.createStaticLayer` now supports passing either a Tileset reference, or a string, or an array of them as the 2nd argument. If strings, the string should be the Tileset name (usually defined in Tiled). +* `Tilemap.createDynamicLayer` now supports passing either a Tileset reference, or a string, or an array of them as the 2nd argument. If strings, the string should be the Tileset name (usually defined in Tiled). +* `Tilemap.createBlankDynamicLayer` now supports passing either a Tileset reference, or a string, or an array of them as the 2nd argument. If strings, the string should be the Tileset name (usually defined in Tiled). +* Static Tilemap Layers now support tile rotation and flipping. Previously this was a feature only for Dynamic Tilemap Layers, but now both have it. Close #4037 (thanks @thisredone) +* `Tilemap.getTileset` is a new method that will return a Tileset based on its name. +* `ParseTilesets` has been rewritten so it will convert the new data structures of Tiled 1.2 into the format expected by Phaser, allowing you to use either Tiled 1.2.x or Tiled 1.1 JSON exports. Fix #3998 (thanks @martin-pabst @halgorithm) +* `Tilemap.setBaseTileSize` now sets the size into the LayerData `baseTileWidth` and `baseTileHeight` properties accordingly. Fix #4057 (thanks @imilo) +* Calling `Tilemap.renderDebug` ignored the layer world position when drawing to the Graphics object. It will now translate to the layer position before drawing. Fix #4061 (thanks @Zax37) +* Calling `Tilemap.renderDebug` ignored the layer scale when drawing to the Graphics object. It will now scale the layer before drawing. Fix #4026 (thanks @JasonHK) +* The Static Tilemap Layer would stop drawing all tiles from that point on, if it encountered a tile which had invalid texture coordinates (such as a tile from another tileset). It now skips invalid tiles properly again. Fix #4002 (thanks @jdotrjs) +* If you used a RenderTexture as a tileset then Dynamic Tilemap Layers would render the tiles inversed on the y-axis in WebGL. Fix #4017 (thanks @s-s) +* If you used a scaled Dynamic Tilemap Layer and rotated or flipped tiles, the tiles that were rotated or flipped would be positioned incorrectly in WebGL. Fix #3778 (thanks @nkholski) +* `StaticTilemapLayer.tileset` is now an array of Tileset objects, where-as before it was a single reference. +* `StaticTilemapLayer.vertexBuffer` is now an array of WebGLBuffer objects, where-as before it was a single instance. +* `StaticTilemapLayer.bufferData` is now an array of ArrayBuffer objects, where-as before it was a single instance. +* `StaticTilemapLayer.vertexViewF32` is now an array of Float3Array objects, where-as before it was a single instance. +* `StaticTilemapLayer.vertexViewU32` is now an array of Uint32Array objects, where-as before it was a single instance. +* `StaticTilemapLayer.dirty` is now an array of booleans, where-as before it was a single boolean. +* `StaticTilemapLayer.vertextCount` is now an array of integers, where-as before it was a single integer. +* `StaticTilemapLayer.updateVBOData()` is a new private method that creates the internal VBO data arrays for the WebGL renderer. +* The `StaticTilemapLayer.upload()` method has a new parameter `tilesetIndex` which controls which tileset to prepare the VBO data for. +* The `StaticTilemapLayer.batchTile()` method has a new parameter `tilesetIndex` which controls which tileset to batch the tile for. +* `StaticTilemapLayer.setTilesets()` is a new private method that creates the internal tileset references array. +* `DynamicTilemapLayer.tileset` is now an array of Tileset objects, where-as before it was a single reference. +* `DynamicTilemapLayer.setTilesets()` is a new private method that creates the internal tileset references array. + +### New Features + +* `bodyDebugFillColor` is a new Matter Physics debug option that allows you to set a color used when drawing filled bodies to the debug Graphic. +* `debugWireframes` is a new Matter Physics debug option that allows you to control if the wireframes of the bodies are used when drawing to the debug Graphic. The default is `true`. If enabled bodies are not filled. +* `debugShowInternalEdges` is a new Matter Physics debug option that allows you to set if the internal edges of a body are rendered to the debug Graphic. +* `debugShowConvexHulls` is a new Matter Physics debug option that allows you to control if the convex hull of a body is drawn to the debug Graphic. The default is `false`. +* `debugConvexHullColor` is a new Matter Physics debug option that lets you set the color of the convex hull, if being drawn to the debug Graphic. +* `debugShowSleeping` is a new Matter Physics debug option that lets you draw sleeping bodies at 50% opacity. +* `Curves.Ellipse.angle` is a new getter / setter that handles the rotation of the curve in degrees instead of radians. + +### Updates + +* The Loader has been updated to handle the impact of you destroying the game instance while still processing files. It will no longer throw cache and texture related errors. Fix #4049 (thanks @pantoninho) +* `Polygon.setTo` can now take a string of space separated numbers when creating the polygon data, i.e.: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'`. This update also impacts the Polygon Shape object, which can now also take this format as well. +* The `poly-decomp` library, as used by Matter.js, has been updated to 0.3.0. +* `Matter.verts`, available via `this.matter.verts` from within a Scene, is a quick way of accessing the Matter Vertices functions. +* You can now specify the vertices for a Matter `fromVerts` body as a string. +* `TextureTintPipeline.batchTexture` has a new optional argument `skipFlip` which allows you to control the internal render texture flip Y check. +* The Device.OS check for `node` will now do a `typeof` first to avoid issues with rollup packaged builds needing to shim the variable out. Fix #4058 (thanks @hollowdoor) +* Arcade Physics Bodies will now sync the display origin of the parent Game Object to the body properties as part of the `updateBounds` call. This means if you change the origin of an AP enabled Game Object, after creation of the body, it will be reflected in the body position. This may or may not be a breaking change for your game. Previously it was expected that the origin should always be 0.5 and you adjust the body using `setOffset`, but this change makes a bit more sense logically. If you find that your bodies are offset after upgrading to this version then this is likely why. Close #4052 (thanks @SolarOmni) +* The `Texture.getFramesFromTextureSource` method has a new boolean argument `includeBase`, which defaults to `false` and allows you to set if the base frame should be returned into the array or not. +* There is a new Animation Event that is dispatched when an animation restarts. Listen for it via `Sprite.on('animationrestart')`. +* All of the Animation Events now pass the Game Object as the final argument, this includes `animationstart`, `animationrestart`, `animationrepeat`, `animationupdate` and `animationcomplete`. +* `Curves.Ellipse.rotation` is a getter / setter that holds the rotation of the curve. Previously it expected the value in degrees and when getting it returned the value in radians. It now expects the value in radians and returns radians to keep it logical. +* `Set.size` will now only set the new size if the value is smaller than the current size, truncating the Set in the process. Values larger than the current size are ignored. +* Arcade Physics `shutdown` will check to see if the world instance still exists and only try removing it if so. This prevents errors when stopping a world and then destroying it at a later date. +* `Text.setFont`, `Text.setFontFamily`, `Text.setFontStyle` and `Text.setStroke` will no longer re-measure the parent Text object if their values have not changed. + +### Bug Fixes + +* GameObjects added to and removed from Containers no longer listen for the `shutdown` event at all (thanks Vitali) +* Sprites now have `preDestroy` method, which is called automatically by `destroy`. The method destroys the Animation component, unregistering the `remove` event in the process and freeing-up resources. Fix #4051 (thanks @Aveyder) +* `UpdateList.shutdown` wasn't correctly iterating over the pending lists (thanks @felipeprov) +* Input detection was known to be broken when the game resolution was !== 1 and the Camera zoom level was !== 1. Fix #4010 (thanks @s-s) +* The `Shape.Line` object was missing a `lineWidth` property unless you called the `setLineWidth` method, causing the line to not render in Canvas only. Fix #4068 (thanks @netgfx) +* All parts of Matter Body now have the `gameObject` property set correctly. Previously only the first part of the Body did. +* When using `MatterGameObject` and `fromVerts` as the shape type it wouldn't pass the values to `Bodies.fromVertices` because of a previous conditional. It now passes them over correctly and the body is only set if the result is valid. +* The `Texture.getFramesFromTextureSource` method was returning an array of Frame names by mistake, instead of Frame references. It now returns the Frames themselves. +* When using `CanvasTexture.refresh` or `Graphics.generateTexture` it would throw WebGL warnings like 'bindTexture: Attempt to bind a deleted texture'. This was due to the Frames losing sync with the glTexture reference used by their TextureSource. Fix #4050 (thanks @kanthi0802) +* Fixed an error in the `batchSprite` methods in the Canvas and WebGL Renderers that would incorrectly set the frame dimensions on Sprites with the crop component. This was particularly noticeable on Sprites with trimmed animation frames (thanks @sergeod9) +* Fixed a bug where the gl scissor wasn't being reset during a renderer resize, causing it to appear as if the canvas didn't resize properly when `autoResize` was set to `true` in the game config. Fix #4066 (thanks @Quinten @hsan999) +* If a Game instance is destroyed without using the `removeCanvas` argument, it would throw exceptions in the `MouseManager` after the destroy process has run, as the event listeners were not unbound. They're not unbound, regardless of if the parent canvas is removed or not. Fix #4015 (thanks @garethwhittaker) + +### Examples and TypeScript + +A huge thanks to @presidenten for his work on the Phaser 3 Examples. You'll notice they now have a lovely screen shots for every example and the scripts generate them automatically :) + +Also, thanks to the following for helping with the Phaser 3 Examples and TypeScript definitions, either by reporting errors, or even better, fixing them: + +@madanus @truncs @samme + +### Phaser Doc Jam + +The [Phaser Doc Jam](http://docjam.phaser.io) is an on-going effort to ensure that the Phaser 3 API has 100% documentation coverage. Thanks to the monumental effort of myself and the following people we're now really close to that goal! My thanks to: + +31826615 - @16patsle - @bobonthenet - @rgk - @samme - @shaneMLK - @wemyss - ajmetal - andiCR - Arian Fornaris - bsparks - Carl - cyantree - DannyT - Elliott Wallace - felixnemis - griga - Hardylr - henriacle - Hsaka - icbat - Kanthi - Kyle - Lee - Nathaniel Foldan - Peter Pedersen - rootasjey - Sam Frantz - SBCGames - snowbillr - Stephen Hamilton - STuFF - TadejZupancic - telinc1 + +If you'd like to help finish off the last parts of documentation then take a look at the [Doc Jam site](http://docjam.phaser.io). + +## Version 3.13.0 - Yuuki - 20th September 2018 + +### Facebook Instant Games Plugin + +Phaser 3.13 introduces the new Facebook Instant Games Plugin. The plugin provides a seamless bridge between Phaser and version 6.2 of the Facebook Instant Games SDK. Every single SDK function is available via the plugin and we will keep track of the official SDK to make sure they stay in sync. + +The plugin offers the following features: + +* Easy integration with the Phaser Loader so load events update the Facebook progress circle. +* Events for every plugin method, allowing the async calls of the SDK to be correctly inserted into the Phaser game flow. When SDK calls resolve they will surface naturally as a Phaser event and you'll know you can safely act upon them without potentially doing something mid-way through the game step. +* All Plugin methods check if the call is part of the supported APIs available in the SDK, without needing to launch an async request first. +* Instant access to platform, player and locale data. +* Easily load player photos directly into the Texture Manager, ready for use with a Game Object. +* Subscribe to game bots. +* The plugin has a built-in Data Manager which makes dealing with data stored on Facebook seamless. Just create whatever data properties you need and they are automatically synced. +* Support for FB stats, to retrieve, store and increment stats into cloud storage. +* Save Session data with built-in session length validation. +* Easy context switching, to swap between game instances and session data retrieval. +* Easily open a Facebook share, invite, request or game challenge window and populate the text and image content using any image stored in the Texture cache. +* Full Leaderboard support. Retrieve, scan and update leaderboard entries, as well as player matching. +* Support for in-app purchases, with product catalogs, the ability to handle purchases, get past purchases and consume previously unlocked purchases. +* Easily preload a set of interstitial ads, in both banner and video form, then display the ad at any point in your game, with in-built tracking of ads displayed and inventory available. +* Plus other features, such as logging to FB Analytics, creating short cuts, switching games, etc. + +The plugin is fully documented and official tutorials and project templates will follow shortly. + +### New Shape Game Objects + +Phaser 3.13 has a new Game Object called `Shape`, which by itself isn't much use because it's a base class. However, extending that class are 11 different types of Shape (with more to come) and you can use it to create your own custom Shapes as well. Shapes are added to the display list in the exact same way as any other Game Object. For example: + +``` +this.add.rectangle(400, 300, 500, 120, 0x00ff00); +``` + +Here we're creating a new Rectangle shape. It's positioned at 400 x 300 in the Scene and has a size of 500 x 120 pixels. The final value is the fill color. + +The thing to remember is that you can treat this Shape just like you'd treat any other Game Object. You can scale it, rotate it, alpha it, blend mode it, change its origin, give it a Camera scroll factor, put it inside a Container or Group, give it input abilities or even give it a physics body. It is, to all intents and purposes, a normal Game Object. The only difference is that when rendering it uses its own special bit of display code. + +The shapes available are as follows: + +* `GameObject.Arc` - The arc allows you to draw either a circle, or part of a circle. You can set the start and end angle, if the rotation is clockwise or not, and even set the number of iterations the arc will use during rendering. +* `GameObject.Curve` - The Curve Shape can take any Phaser Curve object, such as a Spline or Bezier Curve, and add it to the display list. +* `GameObject.Ellipse` - An ellipse shape, which is essentially a circle with a differing width and height. It can be filled or stroked (or both!) and as with the arc you can set the 'smoothness' of it, allowing you to decrease the number of points used when creating its polygon data. +* `GameObject.Grid` - The Grid Shape object allows you to generate them. You can set the width and height of the grid itself, as well as for the grid cells. The grid can either have a single color, or alternating cell colors and even have outline spacing between the cells, or not. +* `GameObject.Line` - Create a Line Shape drawn between any two points, with a color and thickness. In WebGL you can also specify a different thickness for the start and end of the line. +* `GameObject.Polygon` - A Polygon is effectively a list of points that is drawn between. The points can be provided in a number of different ways (as Vec2 objects, as an array, etc) and then you can either fill or stroke the resulting shape, or both. +* `GameObject.Rectangle` - Simple, but powerful and endlessly useful. Set a width and height and it'll display a Rectangle, with control over the size, fill color and stroke color. +* `GameObject.Star` - The Star shape does as its name suggests: it displays a star. You can control the number of points in the star as well as the inner and outer radius of it. +* `GameObject.Triangle` - A Triangular shape with full control over the points used to make it and its fill and stroke colors. Internally it uses the `batchFillTriangle` method in WebGL, making it actually faster to draw than a Quad! Use them happily for bullets or abstract space ships, or anything else you feel like. +* `GameObject.IsoTriangle` - This draws an isometric triangle, like a pyramid. You can control the colors of each face, if the pyramid is upside down or not and the width and height of it. +* `GameObject.IsoBox` - This draws an isometric box. You can set the colors for each face of the box, as well as the projection angle and also which of the 3 faces are drawn. + +All of the Shape objects render in both Canvas and WebGL and are available via the Game Object Factory. + +### Pointer and Input Event Updates + +The specificity if the input events has been changed to allow you more control over event handling. Previously, the InputPlugin would emit the global `pointerdown` event first, and then the Game Object itself would emit the `pointerdown` event and finally the InputPlugin would emit the `gameobjectdown` event. + +The order has now changed. The Game Object will dispatch its `pointerdown` event first. The InputPlugin will then dispatch `gameobjectdown` and finally the less specific of them all, `pointerdown` will be dispatched. + +New in 3.13 is the ability to cancel this at any stage. All events are now sent an event object which you can call `event.stopPropagation()` on. This will immediately stop any further listeners from being invoked. If you call `stopPropagation()` after the first Game Object `pointerdown` event, then no more Game Object's will receive their callbacks and the InputPlugin will not dispatch either of its events. + +This change has been introduced for `pointerdown`, `pointerup`, `pointermove`, `pointerover` and `pointerout`. No other data is included in the `event` object in this release. + +* The Game Object `pointerdown` callback signature has changed. It used to send `pointer, x, y, camera` to the listener. It now sends `pointer, x, y, event` to the listener. If you still need the `camera` property you can get it from `pointer.camera`. +* The Game Object `gameobjectdown` callback signature has a new argument. It now sends `event` as the 3rd argument. +* The `pointerdown` event, as dispatched by the InputPlugin, is now sent _after_ the Game Object specific events (`GameObject.pointerdown` and `gameobjectdown`). This gives you the chance to cancel the event before the global listener receives it. +* The Game Object `pointerup` callback signature has a new argument. It now sends the `event` as the 4th argument. +* The Game Object `gameobjectup` callback signature has a new argument. It now sends `event` as the 3rd argument. +* The `pointerup` event, as dispatched by the InputPlugin, is now sent _after_ the Game Object specific events (`GameObject.pointerup` and `gameobjectup`). This gives you the chance to cancel the event before the global listener receives it. +* The Game Object `pointermove` callback signature has a new argument. It now sends the `event` as the 4th argument. +* The Game Object `gameobjectmove` callback signature has a new argument. It now sends `event` as the 3rd argument. +* The `pointermove` event, as dispatched by the InputPlugin, is now sent _after_ the Game Object specific events (`GameObject.pointermove` and `gameobjectmove`). This gives you the chance to cancel the event before the global listener receives it. +* The Game Object `pointerover` callback signature has a new argument. It now sends the `event` as the 4th argument. +* The Game Object `gameobjectover` callback signature has a new argument. It now sends `event` as the 3rd argument. +* The `pointerover` event, as dispatched by the InputPlugin, is now sent _after_ the Game Object specific events (`GameObject.pointerover` and `gameobjectover`). This gives you the chance to cancel the event before the global listener receives it. +* The Game Object `pointerout` callback signature has a new argument. It now sends the `event` as the 2nd argument. +* The Game Object `gameobjectout` callback signature has a new argument. It now sends `event` as the 3rd argument. +* The `pointerout` event, as dispatched by the InputPlugin, is now sent _after_ the Game Object specific events (`GameObject.pointerout` and `gameobjectout`). This gives you the chance to cancel the event before the global listener receives it. + +### Game Object List Updates + +When Sprite's are created they are added to two lists within the Scene - the Display List and the Update List. Under 3.12 when a Scene was shut down it would emit a `shutdown` event, which Sprites listened out for. When they received it, they would destroy themselves. + +After [profiling and testing](https://github.com/photonstorm/phaser/issues/4028) this process has changed slightly. Game Object's no longer listen for the Scene `shutdown` event. Instead, the Display List and Update List will iterate their children and call `destroy` on them in turn. If being destroyed by a Scene in this way, the child will skip several expensive operations in its destroy function. More importantly, in busy Scenes you no longer need thousands of event listeners registered. The result is that changing Scene is now up to 100% faster than before. You need not change your code to benefit from this, however, if you were relying on custom Game Objects listening for the Scene `shutdown` event natively, then this is no longer the case and you'll have to manually add that listener to your classes. + +* The UpdateList will now clear out its internal `_list`, `_pendingRemoval` and `_pendingInsertion` lists on shutdown. Before, it would only clear `_list`. +* `GameObject.destroy` has a new optional boolean argument `fromScene`, which controls how the destroy process flows. + +### Camera Render to Texture + +In 3.12 a new Camera method called `setRenderToTexture` was introduced. However, it had known issues so was placed under the experimental flag and you were advised not to use it unless in testing. + +Thanks to several fixes in this release the experimental flag has been dropped and it's now safe to try using this new feature in production. + +The method sets the Camera to render to a texture instead of to the main canvas. The Camera will redirect all Game Objects it's asked to render to this texture. During the render sequence, the texture itself will then be rendered to the main canvas. + +Doing this gives you the ability to modify the texture before this happens, allowing for special effects such as Camera specific shaders, or post-processing on the texture. + +* `Camera.setRenderToTexture` is a new method that enables the Camera to render to a target texture instead of the main canvas, allowing for application of special effects at run-time. +* `Camera.clearRenderToTexture` is a new method that stops a Camera from rendering to a texture and frees-up all associated resources. +* `Camera.setPipeline` allows you to change the WebGL pipeline being used if the Camera is rendering to a texture, effectively swapping the active shader. Call with no arguments to clear the pipeline. +* `Camera.renderToTexture` is a boolean property that controls where the Camera renders. It can be toggled on the fly. +* `Camera.canvas` is a Canvas Element that the Camera will render to if running under the Canvas Renderer and rendering to a texture. +* `Camera.context` is a Rendering Context that the Camera will render to if running under the Canvas Renderer and rendering to a texture. +* `Camera.glTexture` is a WebGL Texture that the Camera will render to if running under the WebGL Renderer and rendering to a texture. +* `Camera.framebuffer` is a WebGL Frame Buffer that the Camera will render to if running under the WebGL Renderer and rendering to a texture. +* `Camera.pipeline` is the Pipeline that the Camera will render with if running under the WebGL Renderer and rendering to a texture with a pipeline set. +* If you set a Camera to render to a texture then it will emit 2 events during the render loop. First, it will emit the event `prerender`. This happens right before any Game Object's are drawn to the Camera texture. Then, it will emit the event `postrender`. This happens after all Game Object's have been drawn, but right before the Camera texture is rendered to the main game canvas. It's the final point at which you can manipulate the texture before it appears in-game. + +### New Features + +* The `Color` object has a new property `h` which represents the hue of the color. You can tween or adjust this property in real-time and it will automatically update the internal RGB values with it. +* The `Color` object has a new property `s` which represents the saturation of the color. You can tween or adjust this property in real-time and it will automatically update the internal RGB values with it. +* The `Color` object has a new property `v` which represents the lightness value of the color. You can tween or adjust this property in real-time and it will automatically update the internal RGB values with it. +* `Color.setFromHSV` is a new method that will set the color values based on the HSV values given. +* `Color.gray` is a new method that will set the color to be a shade of gray based on the amount given. +* `Color.random` is a new method that will set the color to be a random hue based on the min and max values given. +* `Color.randomGray` is a new method that will set the color to be a random grayscale based on the min and max values given. +* `Color.saturate` is a new method that will saturate the color based on the amount given. This is a chainable version of adjusting the saturation property directly. +* `Color.desaturate` is a new method that will desaturate the color based on the amount given. This is a chainable version of adjusting the saturation property directly. +* `Color.lighten` is a new method that will lighten the color based on the amount given. This is a chainable version of adjusting the value property directly. +* `Color.darken` is a new method that will darken the color based on the amount given. This is a chainable version of adjusting the value property directly. +* `Color.brighten` is a new method that will brighten the color based on the amount given. +* The `CanvasTexture` class has a new property `imageData` which contains the ImageData of the texture. +* The `CanvasTexture` class has a new property `data` which is a Uint8ClampedArray view into the `buffer`. +* The `CanvasTexture` class has a new property `pixels` which is a Uint32Array view into the `buffer`. +* The `CanvasTexture` class has a new property `buffer` which is an ArrayBuffer the same size as the context ImageData. +* The `CanvasTexture` class has a new method `update` which refreshes the ImageData and ArrayBuffer based on the texture contents. +* The `CanvasTexture` class has a new method `draw` which draws the given Image or Canvas element to the CanvasTexture, then updates the internal ImageData buffer and arrays. +* The `CanvasTexture` class has a new method `getPixel` which will get the color of a specific pixel from the Canvas Texture and store it in the returned Color object. It uses the ArrayBuffer to do this, which is extremely fast, allowing for quick iteration across the canvas data. +* The WebGLPipeline and WebGLRenderer have new a method `setFloat1v` which allows you to set a `uniform1fv` uniform value (thanks @Mattykins) +* The WebGLPipeline and WebGLRenderer have new a method `setFloat2v` which allows you to set a `uniform2fv` uniform value (thanks @Mattykins) +* The WebGLPipeline and WebGLRenderer have new a method `setFloat3v` which allows you to set a `uniform3fv` uniform value (thanks @Mattykins) +* The WebGLPipeline and WebGLRenderer have new a method `setFloat4v` which allows you to set a `uniform4fv` uniform value (thanks @Mattykins) +* `Text.setLineSpacing` is a new method that allows you to easily set the line spacing value of a Text object in a chainable call (thanks @RafelSanso) + +### Updates + +* The Graphics Canvas Renderer will now automatically call `beginPath` on the target context before processing the command stack. This has the effect of clearing off any sub-paths that may have persisted on the stack from previous Graphics objects or frames. This makes it more in-line with WebGL re: expectations when calling `Graphics.clear`. +* `initPipeline` now defaults to the Texture Tint Pipeline if nothing else is specified. This allowed me to remove explicit strings from 11 different Game Objects, saving some bytes in the process. +* The `RGBToHSV` function can now take an optional `out` argument, which is either a `HSVColorObject` or a `Color` object, and the results will be set into that object instead of creating a new one. +* The `HSVToRGB` function can now take an optional `out` argument, which is either a `HSVColorObject` or a `Color` object, and the results will be set into that object instead of creating a new one. +* `Color.setTo` has a new argument `updateHSV` which allows you to control if the internal HSV values are updated during the same call or not. +* The `Text._lineSpacing` property has been renamed to `lineSpacing` and made public, not private. You still set it in the same way, by passing a `lineSpacing` property to the Text configuration object, but internally it's now clearer. +* If a Scene is already active (i.e. running) and you call `start` on it (such as from another Scene) then it will shutdown the Scene first, before starting it again. + +### Bug Fixes + +* TileSprite.setTileScale would set the tile position by mistake, instead of the scale. Using the properties directly worked, but the method was incorrect (thanks @alexeymolchan) +* Calling `Text.setStyle` would make the Text vanish if you didn't provide a `resolution` property in the style configuration object. Calling `setStyle` now only changes the properties given in the object, leaving any previously changed properties as-is. Fix #4011 (thanks @okcompewter) +* In Matter.js if a body had its debug `render.visible` property set to `false` it wouldn't then render any other debug body beyond it. Now it will just skip bodies with hidden debug graphics (thanks @jf908) +* If you flagged a Tween as `paused` in its config, never started it, and then called `Tween.stop` it wouldn't ever be removed from the `_pending` array. It's now moved to the Tween Manager's destroy list, ready for removal on the next frame. Fix #4023 (thanks @goldfire) +* Game Objects would not remove themselves from the Scene's `shutdown` event handler when destroyed, leading to a build-up over time (thanks @goldfire) +* The WebGL Renderer will no longer try and just resize a canvas backed texture, instead it will properly delete it then re-create it. Fix #4016 (thanks @alexeymolchan) +* The Camera background for mini-Cameras (those positioned deep inside another Camera) would be offset incorrectly in WebGL, causing the background fills to be displaced (thanks @aaronfc) +* The WebGL Renderer now always enables the `SCISSOR_TEST`, this allows Game Objects that use the scissor (such as custom objects, or Bitmap Text) to render properly again. +* The Cameras `setScene` method, which is called automatically when a new Camera is created, will now call `updateSystem` which correctly increases the custom viewport counter. This fixes an issue with mini-cams inside of larger cameras not clipping their contents properly. If a Camera is moved to another Scene it also now correctly shrinks the total custom viewport counter. +* Due to the two fixes above another bug was fixed: The ability for you to swap between Cameras with and without `setRenderToTexture` enabled with custom shaders. Previously if you used this with a custom shader then only the first Camera using the shader would render, the rest would appear black. Now, all Cameras using the custom shader work correctly. As a result all of the 'experimental' Camera rendering properties from 3.12 have been moved to stable. +* If you destroyed a Game Object that had a custom cursor set during one of its input events the cursor didn't correctly reset. Fix #4033 (thanks @pantoninho) +* `RenderTexture.resize` wouldn't correctly resize the texture under WebGL. Fix #4034 (thanks @jbpuryear) +* Calling `setFrame` on a TileSprite wouldn't change the frame, it would just change the frame size. Fix #4039 (thanks @Jerenaux) +* `Zone.setRectangleDropZone` used the wrong `x` and `y` coordinates for the hit area, causing it to be offset from the zone itself after the changes made for issue #3865 in the 3.12 release. + +### 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: + +@johanlindfors @Arthur3DLHC @JamesSkemp + +## Version 3.12.0 - Silica - 4th September 2018 + +### FlatTintPipeline Updates + +In 3.11 I overhauled the TextureTintPipeline, the WebGL batch used to render all texture based Game Objects, such as Sprites. In this release I did the same to the FlatTintPipeline. This pipeline was used exclusively by the Graphics Game Object to draw filled and stroked primitives in WebGL. It was also used by classes such as the Camera in order to draw their colored backgrounds and flash / fade effects. + +When I looked closely at the shaders being used by the texture and graphics pipelines I noticed they were virtually identical. Yet if you were to mix Graphics objects and Sprites in your game, it would cause a complete batch flush as it switched between the them as it rebound the shaders, adding to both the draw calls and gl ops per frame. + +The more I looked through the graphics pipeline, the more I saw the same kind of things the texture one previously had: duplicate vars, in-line matrix operations and so on. So I worked through the process of refactoring it, boiling it down to just a handful of core methods and re-using methods the texture pipeline already had. The end result is that I've been able to remove the FlatTintPipeline entirely. This saves 42.3KB (unminifed) and removes 1000 lines of code from the build. Of course, lots of the methods were added to the texture pipeline, but that only increased from 730 sloc to 1087 sloc, a fraction of the amount before! And the benefits don't end there. + +If you had any custom pipelines that extended the FlatTintPipeline please update them to extend the TextureTintPipeline instead. You'll likely need to remap a few methods, but most of them remain the same. Double-check the method signatures though. + +The same pipeline can now draw both graphics and sprites, with the same shader and no texture swapping either. This means you can happily mix Graphics objects alongside Sprites and it won't cost any extra overhead at all. There are more benefits too, which are outlined in the list below. + +* The TextureTintPipeline now has 100% jsdoc coverage. +* The removal of the FlatTintPipeline shaves 42.3KB and 1000 sloc from the bundle size. +* The Graphics fill and line styles are now cached in the pipeline, rather than being re-calculated for every primitive drawn. +* The new `batchTri` method will add a triangle to the vertex batch, either textured or filled. +* `drawFillRect` is a new method that will add an untransformed rectangle to the batch. These are used by things like Cameras to fill in background colors. +* `batchFillRect` has been moved to the TextureTintPipeline and has a new much more concise method signature. +* `batchFillTriangle` has been moved to the TextureTintPipeline and has a new much more concise method signature. +* `batchFillPath` has been moved to the TextureTintPipeline and has a new much more concise method signature. +* `batchLine` has been moved to the TextureTintPipeline. +* When drawing Graphics paths with a line width of 1 it will no longer spend any time drawing the line joins, speeding-up the rendering of 1px lines. + +### WebGL Scissor Update + +The process of managing scissors in the WebGLRenderer has been completely rewritten. Previously, the gl scissor was being constantly enabled and disabled for every Camera in your game, leading to pointless gl operations. + +* Cameras have a new internal method `updateSystem` which is automatically called if you change any Camera viewport values. This in turn tells the Scene Manager if there are any cameras with custom viewports, in any Scene of your game. If there are not then the scissor is never even enabled or set, meaning zero gl ops! If your game uses full sized Cameras it now doesn't cost anything at all with regard to scissoring. +* If a new scissor is set it will now check to see if it's the same size and position as the current scissor, and if so, it'll skip setting it at all. + +### Render Texture New Features and Updates + +The Render Texture class has been rewritten from scratch and all Game Objects have been updated to support it. Previously it was very restricted in what you could do with it. It used to have a matrix stack for internal transforms, but this has been replaced with a Camera instead. This means you have the full power of a Camera system (scrolling, zooming, rotation) but it only impacts the contents of the Render Texture. + +* The biggest update is the change in what the `draw` method can accept. Previously you had to pass in a texture and frame reference. This has changed, as has the method signature. It can now accept any of the following: + + - Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + - Dynamic and Static Tilemap Layers. + - A Group. The contents of which will be iterated and drawn in turn. + - A Container. The contents of which will be iterated fully, and drawn in turn. + - A Scene. Pass in `Scene.children` to draw the whole display list. + - Another Render Texture. + - A Texture Frame instance. + - A string. This is used to look-up a texture from the Texture Manager. + +* There is a new method `drawFrame` which allows you to pass in a string-based texture and frame key and have it drawn to the Render Texture. +* The new method `saveTexture` allows you to save the Render Texture into the Texture Manager using your own key. You can then use the Render Texture for any Game Object that accepts textures as a source, such as Sprites or even Tilemap Layers. You can add frame data to a Render Texture using the `RenderTexture.texture.add` method. +* The new `camera` property is an instance of a complete 2D Camera. You can use it to change the view into your Render Texture. Scroll, rotate, zoom, just like you would with a normal Camera, except it will only influence the objects being drawn to the Render Texture. +* All of the matrix-style methods have been removed: `save`, `translate`, `restore`, `scale`, `rotate`. You can now achieve the same thing by either transforming the object you want to draw to the Render Texture, or using the built-in Camera. +* You can now crop a Render Texture. Use the `setCrop` method to define the crop region. + +See the fully complete documentation for more details and the extensive examples and tests created. + +### Text Game Object New Features and Updates + +The Text Game Object has been given an internal overhaul to make it more flexible. Some properties have been renamed or moved and new features added: + +* Text can now be cropped in WebGL and Canvas! Use the `setCrop` method to crop the text. +* Text now keeps a reference to the renderer in the `renderer` property. +* The `canvasTexture` property has been removed. +* Text now has internal `texture` and `frame` properties. These replace the old `canvasTexture` but perform the same task, while allowing for texture cropping and much smaller renderer code. +* Previously, changing a Text object by setting its `text` property directly wouldn't change the text being rendered as using `setText` was the expected way to change what was being displayed. Internally the `text` property has been renamed to `_text` and flagged as private, and a new getter / setter for `text` has been added, which hands over to the `setText` method, meaning you can now use both ways of setting the text. Fix #3919 (thanks @hackhat @samid737) + +### Tile Sprite Object New Features and Updates + +The Tile Sprite Game Object has been given an internal overhaul to make it more flexible. Some properties have been renamed or moved and new features added: + +* Tile Sprites can now be cropped in WebGL and Canvas! Use the `setCrop` method to crop the tile sprite. +* There is a new method `setTileScale` which will set the tile scale in a chainable call. +* There is a new internal `canvas` property. Tile Sprites work differently than before in Canvas mode: Previously they would use the `fillRect` command on the game canvas to draw themselves every frame, even if they hadn't changed. They now draw to an internal canvas only when their position or scale changes. This canvas is then drawn to the game canvas instead. It's faster, as it doesn't fillRect every frame and also allows you to draw them to other contexts, such as Render Textures. +* There are two new internal properties `_tilePosition` and `_tileScale` which are Vector 2s that hold the position and scale. Getters have been added, so use the same properties as before in your code. +* There are two new properties `displayTexture` and `displayFrame`. These replace the previous `texture` and `frame` properties and hold references to the source texture the Tile Sprite is using. +* The `canvasPattern` property has been renamed to `fillPattern`. +* The `oldFrame` property has been removed. +* The `canvasBuffer` property has been renamed to `fillCanvas`. +* The `canvasBufferCtx` property has been renamed to `fillContext`. + +### Tilemap New Features and Updates + +The Tilemap and Dynamic and Static Tilemap Layer classes now all support 4 different modes of render order for drawing the tiles. This allows you to control the z-order of the tiles during render. This feature was requested by @etienne (who provided the test maps too) - see the new examples in the Labs for better understand the impact this has. + +The default is 'right-down', meaning it will order the tiles starting from the top-left, drawing to the right and then moving down to the next row. + +The four draw orders are: + +0 = right-down +1 = left-down +2 = right-up +3 = left-up + +* Tilemap has a new property `renderOrder` which is a string based version of the render order, as used when new layers are created via the map. If the map is created from Tiled JSON data, it will use whatever render order has been specified in the map data. +* Tilemap has a new method `setRenderOrder`. This takes either an integer or a string-based version of the render order and stores it locally. It's then used during the creation of any layers from that point on. +* The DynamicTilemapLayer has a new method `setRenderOrder`. This takes either an integer or a string-based version of the render order and stores it locally. It's then used during rendering of the layer. You can change the value on the fly. +* The StaticTilemapLayer has a new method `setRenderOrder`. This takes either an integer or a string-based version of the render order and stores it locally. Under WebGL it will re-create the whole vertex buffer, using the new draw order. Under Canvas it uses it at run-time during rendering. You can change it on the fly. +* ParseJSONTiled now extracts the `renderorder` property from the Tiled JSON. +* MapData has a new `renderOrder` property, which is populated by the Tiled Parser. + +### Matter.js Updates + +The version of Matter.js used by Phaser has been updated from 0.13.1 to 0.14.2. To clarify why we don't include Matter via npm, it's because we use a customized version of Matter that includes extra features and optimizations not yet found in the official library. + +Most of the updates were about documentation and module namespacing, however those relevant to Phaser are listed below. You can also view the full [Matter Change Log](https://github.com/liabru/matter-js/blob/master/CHANGELOG.md). + +* fix Composite.bounds global issue, closes #627, closes #544 ([f7f77b4](https://github.com/liabru/matter-js/commit/f7f77b4)), closes [#627](https://github.com/liabru/matter-js/issues/627) [#544](https://github.com/liabru/matter-js/issues/544) +* updated pathseg library, closes #548, closes #602, closes #424 ([1e5758f](https://github.com/liabru/matter-js/commit/1e5758f)), closes [#548](https://github.com/liabru/matter-js/issues/548) [#602](https://github.com/liabru/matter-js/issues/602) [#424](https://github.com/liabru/matter-js/issues/424) +* fix Common.isElement on node, closes #535 ([ec38eeb](https://github.com/liabru/matter-js/commit/ec38eeb)), closes [#535](https://github.com/liabru/matter-js/issues/535) +* added Query.collides, closes #478 ([6593a72](https://github.com/liabru/matter-js/commit/6593a72)), closes [#478](https://github.com/liabru/matter-js/issues/478) +* fix `point` argument of Body.scale, closes #428 ([894c1ef](https://github.com/liabru/matter-js/commit/894c1ef)), closes [#428](https://github.com/liabru/matter-js/issues/428) +* fix Body.scale for compound bodies ([50a89d0](https://github.com/liabru/matter-js/commit/50a89d0)) +* fix centroid for static compound bodies, closes #483 ([ece66e6](https://github.com/liabru/matter-js/commit/ece66e6)), closes [#483](https://github.com/liabru/matter-js/issues/483) +* fix Common.isElement, closes #501, closes #507, closes #459, closes #468, closes #517 ([18a0845](https://github.com/liabru/matter-js/commit/18a0845)), closes [#501](https://github.com/liabru/matter-js/issues/501) [#507](https://github.com/liabru/matter-js/issues/507) [#459](https://github.com/liabru/matter-js/issues/459) [#468](https://github.com/liabru/matter-js/issues/468) [#517](https://github.com/liabru/matter-js/issues/517) +* fix inertia change in Body.setMass, closes #378 ([f7d1877](https://github.com/liabru/matter-js/commit/f7d1877)), closes [#378](https://github.com/liabru/matter-js/issues/378) +* fix Vertices.chamfer radius argument, closes #467 ([3bceef4](https://github.com/liabru/matter-js/commit/3bceef4)), closes [#467](https://github.com/liabru/matter-js/issues/467) + +### Camera 3D Plugin + +Support for Camera 3D and Sprite 3D Game Objects have been removed from the core Phaser bundle and moved to an optional plugin. + +You can find the source for Camera 3D in the new `plugins/camera3d` folder, along with a README file explaining how to now use the plugin in your games. + +* When a Sprite3D object is added to a Camera via `Camera.add` it is now added to the Display and Update Lists. Fix #3945 (thanks @vvega) + +### New Features + +* `Camera.resolution` is a new read-only property that holds the current game config resolution that the camera is using. This is used internally for viewport calculations. +* `Text.resolution` and the method `Text.setResolution` allows you to control the resolution of a Static Text Game Object. By default it will be set to match the resolution set in the Game Config, but you can override it yourself via the TextStyle. It allows for much clearer text on High DPI devices, at the cost of larger internal Canvas textures for the Text - so please use with caution, as the more high res Text you have, the more memory it uses up. Fix #3528 (thanks @kirillbunin) +* `TransformMatrix.getCSSMatrix` will return a CSS transform matrix formatted string from the current matrix values. +* `CacheManager` now creates a new cache called `html` which is used to store all loaded HTML snippets. +* `FileType.HTML` is a new file type loader that will load an HTML snippet and store it in the new `html` cache. Access it via `load.html` (this method was previously used to load html to textures, please see `load.htmlTexture` for this feature now) +* `TransformMatrix.getX` is a new method that return the x component from the given x and y values based on the current matrix. This is used heavily in the pipelines. +* `TransformMatrix.getY` is a new method that return the y component from the given x and y values based on the current matrix. This is used heavily in the pipelines. +* `TransformMatrix.copyToArray` is a new method that will copy the matrix values to the given array. It's the counter-part of `copyFromArray`. +* `Graphics.setTexture` is a new WebGL only method that allows you to set a texture to be used when drawing the shapes on the Graphics object. You can also specify how the texture should be blended with the current fill or gradient colors. Note that the texture is not tiled, it is stretched to fit the shape being drawn. +* `Graphics.fillGradientStyle` is a new WebGL only method that allows you to set a gradient for the shapes being filled. You can control the colors at the 4 corners of a rectangle. The colors are then blended automatically in the shader. Use of this feature is limited. For example, you cannot gradient fill a whole path or an arc, as it's made up of lots of triangles. But for quick gradient backgrounds or buttons it's perfect. +* `Graphics.lineGradientStyle` is a new WebGL only method that allows you to set a gradient for the shapes being stroked. You can control the colors at the 4 corners of a rectangle. The colors are then blended automatically in the shader. Use of this feature is limited. For example, you cannot gradient stroke a whole path or an arc, as it's made up of lots of triangles. But for quick gradient lines it's perfect. +* `TextureManager.getBase64` is a new method that will take a texture frame key and return a base64 encoded version of the frame. You can also provide the image type and encoder options. +* Global Plugins now have a new optional `data` object, the contents of which are passed to the plugins `init` method. This allows users to pass data directly into a plugin when added in the config: `{ key: 'BankPlugin', plugin: BankPluginV3, start: true, data: { gold: 5000 } }` or when adding a plugin via the `install` method (thanks @samme) +* You can now play animations in reverse! Use the new `Sprite.anims.playReverse` method to play a pre-defined animation in reverse from its starting frame. Or call `Sprite.anims.reverse` to immediately reverse the flow of an already running animation. Animations running in reverse still count towards the repeat total and respect the yoyo flag (thanks @khaleb85 @Ben-Millions) +* The `ParticleEmitterManager` now has the Transform component. This means you can now set the position, rotation or scale of the Emitter Manager, and it will influence every Emitter it is rendering. The Managers transform is mixed with that of the Camera. This works in both Canvas and WebGL. +* `TextureManager.addRenderTexture` is a new method that will add a Render Texture into the Texture Manager, allowing you to use it as the texture for Game Objects just by using the texture key. Modifying the source Render Texture will immediately modify any Game Objects using it. +* TextureSource has a new boolean property `isRenderTexture` which is set automatically when it's created. +* The Canvas Renderer has a new method `setContext` which allows it to swap the context being drawn to by all draw operations. Call the method with no arguments to reset it to the default game canvas. +* If you set `window.FORCE_WEBGL` or `window.FORCE_CANVAS` in the window in which the Phaser game is loaded it will over-ride the renderer type setting in your game config, and force either WebGL or Canvas. This is handy for quickly testing the differences between renderers without having to do a new build each time. +* `TextureSource.source` is a new property that contains the original source of the Texture image. It is cleared when the source is destroyed. +* `TransformMatrix.copyToContext` is a new method that will copy the values from the Matrix to the given Canvas Rendering Context. +* `Phaser.Utils.String.UUID` will return an RFC4122 complaint UUID as a string. This is used internally to avoid cache key conflicts, but is exposed for your own use as well. +* There is a new `Crop` Component which is used by non-texture based Game Objects, such as Text and TileSprite. You either use `TextureCrop` or `Crop`, not both together on the same object. +* `TransformMatrix.setToContext` is a new method that will set the values from the Matrix to the given Canvas Rendering Context using setTransform rather than transform. +* `SetTransform` is a new Canvas Renderer function that consolidates the process of preparing a Game Object for rendering, without actually rendering it. This is used internally by the Graphics and Bitmap Text classes. +* The Texture Manager has a new method called `renameTexture` which will let you rename a texture, changing the key to the new one given. All existing Game Objects will still maintain their reference, even after a rename. +* When loading an SVG file you can now change the size of the SVG during the load process, before it is rendered to a texture. This is really helpful if you wish to increase SVGs that have small viewBoxes set, or want to try and reduce memory consumption from SVGs with extra large dimensions. You can either pass in a fixed width and height: `this.load.svg('morty', 'file.svg', { width: 300, height: 600 })` or you can provide a scale factor instead: `this.load.svg('morty', 'file.svg', { scale: 4 })` (thanks @ysraelJMM) +* `Polygon.Perimeter` will return the perimeter for the given Polygon (thanks @iamchristopher) +* `Polygon.GetPoints` will return an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, based on the given quantity or stepRate values. This is available as a static function and as the `getPoints` method on a Polygon (thanks @iamchristopher) + +### Updates + +* The Camera class has been split into two: `BaseCamera` which contains all of the core Camera functions and properties, and would serve as a great base for you to extend for your own custom Cameras, and `Camera` which is the same class name as previously. `Camera` extends the Base Camera and adds in follower support and the Special Effects. You don't need to update your code, even if currently extending a Camera, as they work the same as before. +* `Camera.x` and `Camera.y` have been turned into getters / setters, mapped to the internal private values `_x` and `_y` respectively. This is so that setting the Camera viewport position directly will now update the new internal resolution calculation vars too. +* `Camera.setScene` will now set the Cameras `resolution` property at the same time and update the internal viewport vars. +* The `Cull Tiles` method used by the Dynamic Tilemap Layer has had a nice and significant optimization. It will now use the cull area dimensions to restrict the amount of tile iteration that takes place per layer, resulting in dramatic reductions in processing time on large layers, or multiple layers (thanks @tarsupin) +* `GameObject.willRender` now takes a Camera as its only argument and uses it within the check. This has allowed me to remove 23 duplicate checks spread across the various Game Objects, all of which did the same thing, saving both KB and CPU time as the flags were being checked twice in most cases. +* The file type loader `HTML` has been renamed to `HTMLTexture`. If you were using this then please change your calls from `load.html` to `load.htmlTexture`. The arguments remain the same. +* The `setBlendMode` method in the WebGL Renderer now returns a boolean. True if a new blend mode was set, otherwise false. Previously it returned a reference to the renderer instance. +* The method `batchVertices` in the TextureTintPipeline has been renamed to `batchQuad` which more accurately describes what it does. +* In ArcadePhysics `Body.setSize` you can now choose to not pass width and height values to the method. If you do this it will check to see if the parent Game Object has a texture frame, and if so, it will use the frame sizes for the Body dimensions (thanks @tarsupin) +* `PluginCache.destroyCorePlugins` will remove all core plugins from the cache. Be very careful calling this as Phaser cannot restart or create any new Scenes once this has been called. +* `PluginCache.destroyCustomPlugins` will remove all custom plugins from the cache. +* `PluginManager.destroy` will now clear all custom plugins from the Plugin Cache. This fixes an issue with not being able to destroy a Phaser game instance and restart it if it used a custom plugin (thanks jd.joshuadavison) +* `Game.destroy` has a new boolean argument `noReturn`. If set it will remove all Core plugins when the game instance is destroyed. You cannot restart Phaser on the same web page after doing this, so only set it if you know you're done and don't need to run Phaser again. +* The `MouseManager` will no longer process its native events if the manager reference has been removed (i.e. you move the pointer as the game is destroying itself) +* The `TouchManager` will no longer process its native events if the manager reference has been removed (i.e. you move the pointer as the game is destroying itself) +* `Particle.color` has been removed as it's now calculated during rendering to allow for Camera alpha support. +* The Game boot event flow has changed slightly. The Game will now listen for a `texturesready` event, which is dispatched by the Texture Manager when the default textures have finished processing. Upon receiving this, the Game will emit the `ready` event, which all the other systems listen for and respond to. The difference is that the Renderer uses the `texturesready` event to ensure that it is the first thing to be activated, before any other system. +* The WebGLRenderer has a new property `blankTexture` which is a reference to an empty 32x32 transparent WebGL Texture. This is used internally for things like rendering Graphics with no texture fills and where no other texture has been set. +* The WebGLRenderer has a new method `setBlankTexture` which forces it to set the blank texture as the current texture. This is used after drawing a Render Texture to ensure no other object tries to draw to itself. +* The StaticTilemapLayer has had the following properties and methods added to it: `skipCull`, `tilesDrawn`, `tilesTotal`, `cullPaddingX`, `cullPaddingY`, `cullCallback`, `setSkipCull` and `setCullPadding` as these are all used by the Canvas Static Layer renderer. Static Layers in 3.11 didn't render in Canvas because the cull values were missing, but now render correctly and can also be rendered to other targets, like a Render Texture. +* The Math.Snap methods `Snap.Floor`, `Snap.Ceil` and `Snap.To` have all gained a new optional boolean argument `divide`. If set the resulting snapped value will be divided by the gap amount before returning. This is handy if you're trying to quickly snap a value into a grid or array location. +* The `currentBlendMode` property has been removed from the Canvas Renderer and is no longer checked by any class. Blend modes are now set directly on the context to avoid state saving invalidation. +* The `currentAlpha` property has been removed from the Canvas Renderer and is no longer checked by any class. Alpha values are now set directly on the context to avoid state saving invalidation. +* `TextureCrop` and `Crop` have a new method `resetCropObject` which generates the crop data object required by Game Objects that support cropping. This allows us to remove duplicate code from a number of Game Objects and replace it with a single function call. +* The Canvas Renderer has a new `batchSprite` method that consolidates the process of drawing a texture-based Game Object to the canvas. It processes the alpha, blend mode and matrix calculations in a single function and now is used by nearly all Game Object canvas renderers. +* The `batchTexture` method in the Texture Tint Pipeline now supports cropped Game Objects and will adjust the drawn texture frame accordingly. +* The `Matrix Stack` Component has been removed. It's no longer used internally and was just wasting space. +* You can now specify the `lineHeight` of a Retro Font in the Retro Font Config object (thanks @FelixNemis) +* When a Static Tilemap Layer is generated in WebGL it will use the Cameras `roundPixels` value to clamp the tile coordinates. +* The `CanvasRenderer.DrawImage` function has been removed, as has the associated `drawImage` property from the Canvas Renderer as they're no longer used. +* The `CanvasRenderer.BlitImage` function has been removed, as has the associated `blitImage` property from the Canvas Renderer as they're no longer used. +* You can now access the Game instance directly from a Scene using `this.game` as long as it exists in the Scene's Injection Map, which it does by default. Be very careful what you do here: there's next to nothing you should actually use this for. +* `Camera.ignore` can now take nested-arrays of Game Objects and also supports both Groups and Containers. +* The `changedata` event dispatched by the Data Manager now includes the previous value as the 4th argument to the callback, so the event signature is now: `parent, key, value, previousValue` (thanks @iamchristopher) +* The call to `gl.clearColor` is now skipped when `clearBeforeRender` is set to `false` (thanks @goldfire) +* The calls to `DistanceBetween` have been replaced with `DistanceSquared` in the `closest` and `furthest` functions within Arcade Physics (thanks @Mursaat) +* The RandomDataGenerator will now create a default random seed if you instantiate your own version of the class (instead of using `Phaser.Math.RND`) and don't provide a seed for it (thanks michaeld) +* The Tilemap `createFromObjects` method will now add custom properties to the Game Objects. It works by checking if the property exists or not, and if not, it sets it in the Game Objects Data Manager (thanks @scalemailted @samme) +* In Matter.js if you scaled a Body it would only scale correctly once, due to the way Matter handles scaling internally. We now automatically reset the Matter scale before applying the new value, which allows you to keep the Phaser and Matter object scales in sync. Fix #3785 #3951 (thanks @bergben) +* The default Container Blend Mode is now `SKIP_TEST`. This allows you to either set a blend mode for a Container, in which case all children use that blend mode. Or, you can set a blend mode on the children and the children will render using their own blend modes, as the Container doesn't have one set. The WebGL and Canvas Renderer functions have also been updated to support this change. Fix #3684 (thanks @TadejZupancic) +* Previously the Input Manager would create a Touch handler unless the Game Config had `input.touch` set to `false` (the default was true). If no such property is set, it no longer defaults to `true` and instead is set to whatever `Device.input.touch` returns. On non-touchscreen desktops this means it will now only create one single Pointer, rather than two. +* The Arcade Physics Body `_tempMatrix` property has been removed. It was only used if the Body's Game Object had a parent. The matrix has been moved to the World instance instead, shared by all bodies. +* Arcade Physics World has gained two new private properties `_tempMatrix` and `_tempMatrix2`. These are used by all bodies in the simulation that need a temporal matrix for calculations, rather than having their own instances. +* The Input Manager has gained a new private property `_tempMatrix2`. This is used internally in the hitTest checks to avoid constant matrix creation. +* The Transform Matrix has a new method `applyInverse` which will take an x/y position and inverse translate it through the current matrix. +* Using `keyboard.addKeys("W, A, S, D")` would fail because of the spacing between the characters. `addKeys` will now trim the input allowing you to space characters out if you prefer (thanks @dhruvyad) +* Calling `setTimeScale` on the Sprite's Animation component will now set the time scale value and keep it set until you change it again. Previously it would be reset to 1 when a new animation was loaded into the component, but this no longer happens - once the time scale is set it remains in effect, regardless of which animations are played on the Sprite. + +### Game Config Resolution Specific Bug Fixes + +Setting the `resolution` property in the Game Config to a value other than 1 would cause various errors in the API. The following have been fixed: + +* The game canvas would be sized incorrectly, unless you had enabled auto resizing. It now scales the canvas to the size given, maintaining the resolution. Fix #3468 (thanks @Legomite) +* Cameras with background colors set would display the filled color area at the wrong size. Camera fills now respect the resolution. +* The Camera Fade Effect would display the fade fill rectangle at the wrong size. Camera fades now respect the resolution. +* The Camera Flash Effect would display the fade fill rectangle at the wrong size. Camera flashes now respect the resolution. +* The Camera Shake Effect would shake the Camera using the wrong width values. Camera Shakes now respect the resolution. +* Input calculations would not factor in the Game Resolution correctly. If a Camera viewport was not at 0x0 or not the full size, or the Camera was rotated or zoomed, the input areas would be wrong if `resolution` was > 1. These are now factored in correctly and changing the resolution no longer breaks input. Fix #3606 (thanks @Secretmapper @thanh-taro) + +### Bug Fixes + +* The `setCrop` method stored its crop object on the prototype chain by mistake, causing all Images or Sprites that were cropped to display the same frame. The crop data has been moved to the Game Object instance, where it should be, fixing this issue (thanks NoxBrutalis) +* If an AudioFile failed to load and throw an incomplete error, it would cause the console.log to crash JavaScript when trying to log the error. It now only logs the message if it exists. Fix #3830 (thanks @kelostrada) +* Particles using a blend mode wouldn't render correctly after the updates in 3.11. If the blend mode changes during the processing of an emitter manager it'll now correctly rebind the texture, stopping the particles from vanishing. Fix #3851 (thanks @maxailloud) +* Adding an array of children to a Group would cause it to mistakenly think you were passing a config object. Fix #3854 (thanks @pedro-w) +* Graphics paths in WebGL would not render the line join between the final and the first path if the path was closed, leaving a noticeable gap if you used particularly thick strokes. If the path is closed it will now render the final line join properly. +* If a Mesh caused a batch flush it would fail to render as its texture was lost. It's now rebound correctly after the flush. +* `ArcadePhysics.closest` and `ArcadePhysics.furthest` used the wrong tree reference, causing them to throw errors (thanks @samme) +* `BlitterCanvasRenderer` would fail to render a Bob in Canvas mode if it was flipped (thanks @SBCGames) +* `RenderTexture.draw` would fail to draw the frame in Canvas mode (thanks @SBCGames) +* `ParticleEmitter` would fail to draw a textured particle in Canvas mode (thanks @SBCGames) +* `RenderTexture.preDestroy` will now release the canvas back to the CanvasPool if running in canvas mode (thanks @SBCGames) +* The `alpha` value is now always set for Render Textures in canvas mode, regardless of the previous alpha value in the renderer (thanks @SBCGames) +* Zone now calls `updateDisplayOrigin` in its constructor, causing the `displayOriginX` and `displayOriginY` values to now be correct if you create a Zone and then don't resize it. Fix #3865 (thanks @rexrainbow) +* The `CameraManager` was accidentally adding extra destroy event calls when a Scene was restarted, causing an `Uncaught TypeError: Cannot read property 'events' of null` when trying to destroy a game instance having swapped from a Scene to another, and back again. Fix #3878 (thanks @mbunby) +* RenderTextures in WebGL will now set the viewport size, stopping the console warning in Firefox. Fix #3823 (thanks @SBCGames) +* Particles now take the Cameras alpha value into consideration when calculating their final alpha values in WebGL. They previously ignored it. If you now alpha a Camera out all particles will change accordingly. +* The `CullTiles` updates from 3.11 didn't factor in the position of the Tilemap Layer to its bounds calculations, causing Static layers displayed out of the Camera viewport to never render in Canvas mode. The method has also been optimized further, with less divisions and less checks if culling is disabled. +* The Particle Emitter when running in Canvas wouldn't allow more than 1 emitter to use a blend mode (as seen in the Electric examples). The blend mode is properly set for each emitter now. +* The Blend Mode is now set directly in all Canvas Renderers without comparing it to what's stored in the Canvas Renderer. This fixes problems where the blend mode would be lost between two different Game Objects because they restored the context, but didn't update the renderer flag. Game Objects in Canvas can now mix and match blend modes across the display list. +* Matter.js has received a tiny update that prevents `collisionEnd` from triggering many times when it should only trigger once (thanks @mikewesthad) +* Graphics objects couldn't be set to be ignored by Cameras. Now every renderable Game Object can be ignored by a Camera, either directly or via a Container. The exception are Groups because they don't render and are non-exclusive parents. +* The Tilemap Culling function now uses the Tilemap tile dimensions for its bounds calculations, instead of the layer tile sizes, as they two don't have to match and it's the underlying grid size that takes precedence when calculating visible tiles. Fix #3893 (thanks @Zax37) +* The Arcade Physics `Body.speed` property is now set whenever you set the velocity via `setVelocity` or `setVelocityX` or `setVelocityY` which stops the body velocity being reset to zero if `useDamping` is enabled. Fix #3888 (thanks @samme) +* The `getPixelAlpha` method in the Texture Manager wasn't using the correct frame name. This is now passed in correctly. Fix #3937 (thanks @goldfire) +* The `getPixelAlpha` and `getPixel` methods in the Texture Manager would allow x/y coordinates from outside the cut area of a frame. It now tests to ensure they're within the frame. Fix #3937 (thanks @goldfire) +* A Game Object couldn't have a blend mode of `SKIP_TEST` set by using the getter or the `setBlendMode` method. +* In Arcade Physics the `World.disable` call was passing the wrong argument, so never disabling the actual body (thanks @samme) +* There was a visual bug with Rounded Rectangles in Canvas mode, due to the addition of the `overshoot` argument in the Graphics arc call. This has been fixed, so arcs will now render correctly and consistently in WebGL and Canvas and Rounded Rectangles are back to normal again too. Fix #3912 (thanks @valse) +* The `InputManager.inputCandidate` method, which determines if a Game Object can be interacted with by a given Pointer and Camera combination, now takes the full camera status into consideration. This means if a Camera is set to ignore a Game Object you can now no longer interact with it, or if the Camera is ignoring a Container with an interactive Game Object inside it, you cannot interact with the Container children anymore. Previously they would interact regardless of the Camera state. Fix #3984 (thanks @NemoStein @samid737) +* `Transform.getWorldTransformMatrix` has been recoded to iterate the transform parents correctly, applying the matrix multiplications as it goes. This (along with some changes in the Input Manager) fix the issue with Game Objects inside of Containers failing hit tests between certain angles. Fix #3920 (thanks @chaping @hackhat) +* Calling Arcade Physics `collide` during an `update` method wouldn't inject the results back into the Body parent, causing the bodies to carry on moving. Using Colliders worked, but manually checking did not. Now, both methods work. Fix #3777 (thanks @samme) +* The `setTintFill` method would ignore the `alpha` value of the Game Object in the shader. The alpha value is now blended with the tint fill, allowing you to properly alpha out tint-filled Game Objects. Fix #3992 (thanks @trl-bsd) +* Arcade Physics World `collideSpriteVsTilemapLayer` now syncs the collision results back to the body, allowing you to call `collide` from within an update loop once again. Fix #3999 (thanks @nkholski @mikewesthad) +* Arcade Physics Body `deltaX` and `deltaY` methods will now return the previous steps delta values, rather than zero. Fix #3987 (thanks @HaoboZ) + +### 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: + +@SBCGames @rgk @rook2pawn @robbintt @bguyl @halilcakarr @PhaserEditor2D @Edwin222 @tfelix @Yudikubota @hexus @guzmonne @ampled @thanh-taro @dcbriccetti @Dreaded-Gnu @padme-amidala @rootasjey @ampled @thejonanshow @polarstoat @jdjoshuadavison @alexeymolchan @samme @PBird @spontoreau @hypertrifle @kid-wumeng + +Thanks to @khaleb85 for fixing the super-annoying lag on the API Docs pages when it hung the browser while indexing the search field. + + +## Version 3.11.0 - Leafa - 13th July 2018 ### Camera - New Features, Updates and Fixes * All of the 2D Camera classes are now 100% covered by JSDocs! +* All of the 3D Camera classes are now deprecated and will be removed in the next version. They will be moved to a stand-alone plugin. * `Camera.alpha` (and its related method `Camera.setAlpha`) allows you to set an alpha level for the entire camera. This impacts everything it is rendering, even if those objects also have their own alpha values too. You can tween the property to make the camera contents fade in / out, or otherwise set it as needed in your game. * `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game checks as needed. * `Camera.pan` is a new Camera Effect that allows you to control automatic camera pans between points in your game world. You can specify a duration and ease type for the pan, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the pan. See the examples and docs for more details. @@ -12,6 +844,8 @@ * `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. * `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level. * `Camera.displayHeight` is a new property that returns the display height of the camera, factoring in the current zoom level. +* `Camera.worldView` is a new property, an instance of a Rectangle, that contains the dimensions of the area of the world currently visible by the camera. You can use it for intersection or culling tests that don't need to factor in camera rotation. +* `Camera.dirty` is a new boolean property. A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. The flag is reset in the `postCameraRender` method, but until that point can be checked and used. * `Camera.centerOn` is a new method that will move the camera so its viewport is centered on the given coordinates. A handy way of jumping to different points around a map without needing to calculate the scroll offsets. * The Camera bounds didn't factor in the camera zoom properly, meaning you would often not be able to reach the corners of a camera bound world at a zoom level other than 1. The bounds are now calculated each frame to ensure they match the zoom level and it will no longer allow you to scroll off the edge of the bounds. Fix #3547 (thanks @nkholski) * `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) @@ -42,6 +876,80 @@ There is a third game config property called `pixelArt`. If set to `true` it's t * If in your game config you have enabled either pixel art mode or roundPixels, then all Cameras will have their `roundPixels` values set to `true` by default. You can toggle this by changing the `CameraManager.roundPixels` property, or change it on a camera-by-camera basis, as needed. * `Camera.roundPixels` is now used across all rendering code for both Canvas and WebGL. Previously, it would check the renderer config value, but now all renderer code uses the camera value to decide if it should floor the drawing position or not. +### Texture Tint Pipeline - New Features, Updates and Fixes + +The Texture Tint Pipeline has been rewritten to tidy up hundreds of lines of duplicate code and to move the responsibility of drawing to the Game Objects themselves. Previously, had you excluded say Tilemaps from your build of Phaser, the renderer would still include masses of code dealing with the drawing of them. This task has been moved to the Game Objects and the pipeline just provides a set of clean utility functions for batching, flushing and drawing. + +The decision to make this change was not taken lightly. However, I felt that none of the pipelines actually lived up to their name. You could never actually pass objects through one pipeline to another as they didn't have entry and exit points and were instead just glorified singular batches. Although you could change the pipeline being used on a Game Object this action meant that every pipeline had to be responsible for every single type of Game Object, both now and in the future, and they were full of redundant stub functions as a result. The payload size was also considerable. It has now gone from 1,961 lines of code at 76 KB down to 729 lines of code and 27 KB. It's not the only file to benefit either. The `ForwardDiffuseLightPipeline` also reduced from 402 lines (15.7 KB) down to 159 lines and 6 KB. Sizes include comments and are un-minified. In a production bundle the difference will be even greater. This is work we will continue in the next release as we do the same updates to the FlatTintPipeline, responsible for rendering Graphics objects, and look at consolidating the shaders allowing you to use Graphics and Sprites mixed in the display list with no shader swapping cost. + +* You can now set the WebGL batch size in the Game Config via the property `batchSize`. The default is 2000 before the batch will flush, which is a happy average between desktop and mobile. If targeting desktop specifically, you may wish to increase this value to reduce draw calls. +* There is a new method `batchVertices` which will add a vertices block to the current batch. This is now used internally by nearly all render functions. +* The shader has a new attribute: `tintEffect`. This is a single FLOAT. +* The vertex size has increased by 1 FLOAT to account for the extra shader attribute. +* All of the rendering functions now use the `TransformMatrix` class far more than before. This allows the matrix operations to be run-time compiled and cut down on masses of code. +* The `drawTexture` method has been removed. It has been replaced by `drawTextureFrame` which has a new and more concise signature. See the API docs for details. +* The `batchTileSprite` method has been removed. It is now handled in the TileSprite WebGL Render function. +* The `drawStaticTilemapLayer` method has been removed. It is now handled in the Static Tilemap Layer WebGL Render function. +* The `drawEmitterManager` method has been removed. It is now handled in the Particle Manager WebGL Render function. +* The `batchText` method has been removed. It is now handled in the Static Text WebGL Render function. +* The `batchDynamicTilemapLayer` method has been removed. It is now handled in the Dynamic Tilemap Layer WebGL Render function. +* The `batchMesh` method has been removed. It is now handled in the Mesh WebGL Render function. +* The `batchBitmapText` method has been removed. It is now handled in the BitmapText WebGL Render function. +* The `batchDynamicBitmapText` method has been removed. It is now handled in the DynamicBitmapText WebGL Render function. +* The `batchBlitter` method has been removed. It is now handled in the Blitter WebGL Render function. + +Due to the changes in the Texture Tint Pipeline the `Textures.Frame` class has also been updated. The following changes concern the Frame UV data: + +* Previously, the UV data spanned 8 properties: `x0`, `y0`, `x1`, `y1`, `x2`, `y2`, `x3` and `y3` and was stored in the `data.uvs` object. These have been replaced with directly accessible properties: `u0`, `v0`, `u1` and `v1`. These 4 properties are used directly in all renderer code now. Although it was clearer having 8 properties, 4 of them were just duplicates, so we've traded a little clarity for a smaller overall object and less dictionary look-ups. +* `Frame.uvs` (and the corresponding `Frame.data.uvs`) object has been removed. + +### New Tint Effects + +As well as tidying the Texture Tint Pipeline, I also updated the shader. It now has a new attribute 'tintEffect' which allows you to control how a tint is applied to a Game Object. The default way tinting worked was for the tint color values to be multiplied with the texture pixel values. This meant you were unable to do things like tint a Game Object white, because multiplying a color by white doesn't change it. The new tint mode allows you to literally replace the pixel color values. + +* `setTintFill` is a new method available to all Game Objects that have the Tint component. It differs from `setTint` in that the colors literally replace the pixel values from the texture (while still respecting the alpha). This means you can now create effects such as flashing a sprite white if it gets hit, or red for damage, etc. You can still use different colors per corner of the Game Object, allowing you to create nice seamless gradient effects. +* `tintFill` is a new boolean property that allows you to toggle between the two different tint types: multiply or replace. +* `isTinted` is a new read-only boolean indicating if a Game Object is tinted or not. Handy for knowing if you need to clear a tint after an effect. +* `Mesh.tintFill` allows you to control the tint effect applied to the Mesh vertices when color blending. + +The Tint component documentation has been overhauled to explain these differences in more detail, and you can find lots of new examples as well. + +### New Texture Crop Component + +There is a new Game Object Component called `TextureCrop`. It replaces the Texture Component (which still exists) and adds in the ability to crop the texture being used. This component is now being used by the `Sprite` and `Image` Game Objects. + +* You can crop the frame being used via the new `setCrop` method. The crop is a rectangle that limits the area of the texture frame that is visible during rendering. Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just changes what is shown when rendered. This is ideal for hiding part of a Sprite without using a mask, or for effects like displaying a progress or loading bar. Cropping works even when the Game Object is flipped, or is a trimmed frame from an atlas. +* You can toggle the crop on a Game Object by changing the `isCropped` boolean at any point. +* The crop is automatically re-applied when the texture or frame of a Game Object is changed. If you wish to disable this, turn off the crop before changing the frame. + +### BitmapText New Features, Updates and Bug Fixes + +* Multi-line BitmapText objects can now be aligned. The constructor has a new argument `align` which can accept either left-aligned (the default), center aligned, or right-aligned. Alignment works by calculating the longest line of text in the object and then offsetting the other lines to match it. +* `BitmapText.setCenterAlign` is a new chainable method to center-align the text. +* `BitmapText.setLeftAlign` is a new chainable method to left-align the text. +* `BitmapText.setRightAlign` is a new chainable method to right-align the text. +* `BitmapText.align` is a new property that holds the alignment of the text. +* `BitmapText.setFont` is a new method that allows you to change the font it is rendering with. +* Internally all of the BitmapText properties have been renamed with an underscore (i.e. `letterSpacing` is now `_letterSpacing`), so as to not change the API, getters and setters for them all have been added. +* Internally there is a new `dirty` flag that tracks if any part of the BitmapText has changed. This is used when getting the BitmapText's bounds object, as used in the renderer for line alignment, and in properties like `width` and `height`. The dirty flag ensures the bounds are only recalculated if something has changed, cutting down on un-necessary calculations. +* `GetBitmapTextSize`, which is used internally in the BitmapText Game Objects, will now produce different bounds from the previous version. Previously, the bounds were tight against the letters in the text. However, this meant the bounds were not properly aligned with the origin of the BitmapText, and consequently you'd get different bounds if the text consisted of different characters. The bounds are now calculated purely based on the glyph data and letter spacing values. This will give a far more consistent overall experience, but it does mean if you were using the bounds to position text previously, you'll need to revisit that code again. See issue #3799 for more details (and to discuss this further if you wish) (thanks @SBCGames) +* `GetBitmapTextSize` and its exposed method `BitmapText.getTextBounds` now factor in the display origin of the BitmapText into the `global` position returned. +* The `BitmapText` WebGL Renderer incorrectly calculated the font scale at very small sizes, causing characters to overlap when they shouldn't. Scale is now applied to the correct component parts in the render code. +* Under WebGL `BitmapText` would be cut off if you specified a resolution value > 1. Fix #3642 (thanks @kanthi0802) +* Under WebGL, `DynamicBitmapText` that had a crop set on it would fail to render if anything was above it on the display list. It now crops properly, no matter what is above or below it on the display list. +* The `DynamicBitmapText` class now extends the `BitmapText` class. This saves on lots of space in the bundle and consolidates functionality between the two. Please be aware of it if you have classes that extend either of them. +* If you were using the `displayCallback` in the `DynamicBitmapText` class it would generate a brand new object containing all the glyph data, every frame, for every glyph, and send it to the callback. This has been changed so it now uses a new cached local object: `callbackData`. This object is recycled for every glyph, stopping un-needed gc from building up. + +### Dynamic Tilemap Layer New Features, Updates and Bug Fixes + +* `DynamicTilemapLayer.tilesDrawn` is a read-only property that contains the number of tiles sent to the renderer in the previous frame. +* `DynamicTilemapLayer.tilesTotal` is a read-only property that contains the total number of tiles in the layer, updated every frame. +* `DynamicTilemapLayer.skipCull` and its associated chainable method `setSkipCull` allows you to control if the cameras should cull the layer tiles before rendering them or not. By default they will cull, to avoid over-rendering, but in some circumstances you may wish to disable this and can now do so by toggling this property. +* The `CullTiles` component, as used by the Dynamic Tilemap, has been recoded from scratch to take advantage of updates in the Camera system. It will now properly cull tiles, irrespective of the layer scale, or camera zoom. It also now supports the layers `skipCull` property, allowing you to override the culling. The Dungeon Generator labs demo now works again as a result of this fix, and has been updated with a debug mode and camera control UI. You can edit the example source to swap between 4 different dungeon layouts, from 2500 tiles up to 1 million tiles. There are limitations to the way the culling works though. If you rotate the camera you may find you see the cull edge. You can disable this using the new `skipCull` property. Fixing this also fixed #3818 (thanks @Mursaat) +* `DynamicTilemapLayer.cullPaddingX`, `cullPaddingY` and the associated chainable method `setCullPadding` allows you to control how many additional tiles are added into the cull rectangle when it is calculated. If you find that your camera size and zoom settings are causing tiles to get prematurely culled, resulting in clipping during scrolling, then set the `cullPadding` values to add extra layers of tiles to the calculations in both directions without needing to disable culling entirely. +* `DynamicTilemapLayer.cullCallback` allows you to change the function that is used to perform the tile culling. By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. It is sent 3 arguments: the layer data, the camera and the array to store the tiles in. Using this feature you can now create whatever culling system you require, should the default one prove to not be suitable for your game. Fix #3811 (thanks @georgzoeller) +* Dynamic Tilemap Layers now properly support the Lights2D Pipeline. This means you can provide a normal map for the layer tileset and it'll illuminate with the Lights shader properly. See the new `light map` example in the labs for a demonstration. Note that there are limits on the number of tiles that can be rendered with lighting enabled. Fix #3544 (thanks @FrancescoNegri) + ### New Features * `Graphics.fillRoundedRect` will draw a stroked rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) @@ -53,6 +961,14 @@ There is a third game config property called `pixelArt`. If set to `true` it's t * `ScenePlugin.wake` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'wake' event. * `ScenePlugin.setActive` now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'pause' or 'resume' events. * `TileSprite.tileScaleX` and `tileScaleY` are two new properties that allow you to control the scale of the texture within the Tile Sprite. This impacts the way the repeating texture is scaled, and is independent to scaling the Tile Sprite itself. It works in both Canvas and WebGL mode. +* `TransformMatrix.copyFrom` is a new method that will copy the given matrix into the values of the current one. +* `TransformMatrix.multiplyWithOffset` is a new method that will multiply the given matrix with the current one, factoring in an additional offset to the results. This is used internally by the renderer code in various places. +* `Rectangle.Intersection` will take two Rectangle objects and return the area of intersection between them. If there is no intersection, an empty Rectangle is returned. +* `Pointer.prevPosition` is a new Vector2 that stores the previous position of the Pointer, prior to the most recent DOM event. You can use this when performing calculations between the old and current positions, such as for tracking the pointer speed. +* `Pointer.getInterpolatedPosition` is a new method that will return an array of smoothly interpolated values between the old and previous position of the Pointer. You can configure how many interpolation steps should take place (the default is 10) and provide an output array to store them in. This method is handy if you've got an object tracking a pointer and you want to ensure it has smooth movement (as the DOM will often process pointer events at a faster rate than the game loop can update). +* `TransformMatrix.copyFromArray` will populate a matrix from the given array of values. Where 0, 1, 2, 3, 4 and 5 map to a, b, c, d, e and f. +* `WebGLPipeline` has a new over-rideable method called `boot` which is called when the renderer and all core game systems have finished being set-up. +* `KeyboardPlugin.checkDown` is a new method that allows you to check if a Key is being pressed down or not in an update loop. The difference between this method and checking the `Key.isDown` property directly is that you can provide a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it will only return `true` every 100ms. ### Updates @@ -60,10 +976,19 @@ There is a third game config property called `pixelArt`. If set to `true` it's t * The docs for the Loader `filecomplete` event said that you could listen for a specific file using its type and key, i.e.: `filecomplete-image-monster`, however, the code used an underscore instead of a hyphen. We feel the hyphen looks cleaner, so the Loader code has been updated, meaning you can now use the hyphen version of the event properly (thanks @NokFrt) * If a Game Object is already being dragged, it cannot be dragged by another pointer (in multi-touch mode) until the original pointer has released it (thanks @rexrainbow) * Calling `Tween.play` on a tween created via `TweenManager.create` wouldn't actually start playback until the tween was first added to the Tween Manager. Now, calling `play` will have it automatically add itself to the Tween Manager if it's not already in there. Fix #3763 (thanks @pantoninho) -* If the Blitter object has no Bob's to render it will now abort immediately, avoiding several context calls in Canvas mode. +* If the Blitter object has no Bobs to render it will now abort immediately, avoiding several context calls in Canvas mode. * `Scene.run` will now pass the optional `data` object in all cases, no matter if it's waking, resuming or starting a Scene (thanks @rook2pawn) * `ScenePlugin.start` and `ScenePlugin.restart` will now always queue the op with the Scene Manager, regardless of the state of the Scene, in order to avoid issues where plugins carry on running for a frame before closing down. Fix #3776 (thanks @jjalonso) -* The `batchTileSprite` method has been removed from the `TextureTintPipeline` class, because it is now handled internally by the Tile Sprite object itself. +* `Tileset.glTexture` is a new property that maps to the WebGL Texture for the Tileset image. It's used internally by the renderer to avoid expensive object look-ups and is set automatically in the `Tileset.setImage` method. +* `Frame.glTexture` is a new property that maps to the WebGL Texture for the Frames Texture Source image. It's used internally by the renderer to avoid expensive object look-ups and is set automatically in the `Frame` constructor. +* `TransformMatrix.e` and `TransformMatrix.f` are two new properties that are an alias for the `tx` and `ty` values. +* `Graphics.arc` has a new optional argument `overshoot`. This is a small value that is added onto the end of the `endAngle` and allows you to extend the arc further than the default 360 degrees. You may wish to do this if you're trying to draw an arc with an especially thick line stroke, to ensure there are no gaps. Fix #3798 (thanks @jjalonso) +* The TextureManager Sprite Sheet Parser will now throw a concise console warning if you specify invalid frame sizes that would result in no frames being generated (thanks @andygroff) +* The `Quad` Game Object now has a new `setFrame` method that allows you to change the frame being rendered by the Quad, including using frames that are part of a texture atlas. Fix #3161 (thanks @halgorithm) +* The `ScenePlugin` will now queue all of the following ops with the Scene Manager: `start`, `run`, `pause`, `resume`, `sleep`, `wake`, `switch` and `stop`. This means for all of these calls the Scene Manager will add the call into its queue and process it at the start of the next frame. This fixes #3812 and keeps things more predictable (thanks @Waclaw-I) +* `TransformMatrix.multiply` has a new optional argument `out` which is a matrix to store the multiplication results in. If not given it will act as before, multiplying the current matrix. +* `Zones` now have a NOOP `setAlpha` method, which allows them to be added into Containers (thanks @TadejZupancic) +* The `setPipeline` method now returns the instance of the Game Object on which it was called. It used to return the pipeline that was set, but this made it non-chainable which broke with the conventions set in all the other `set` methods. If you use `setPipeline` in your code anywhere to retrieve the pipeline reference, please use the `pipeline` property of the Game Object instead. ### Bug Fixes @@ -82,16 +1007,20 @@ There is a third game config property called `pixelArt`. If set to `true` it's t * `ArrayUtils.AddAt` didn't calculate the array offset correctly if you passed an array in to be merged with an existing array. This also caused Container.addAt to fail if an array was passed to it. Fix #3788 (thanks @jjalonso) * The `Pointer.camera` property would only be set if there was a viable Game Object in the camera view. Now it is set regardless, to always be the Camera the Pointer interacted with. * Added the Mask component to Container. It worked without it, but this brings it in-line with the documentation and other Game Objects. Fix #3797 (thanks @zilbuz) +* The DataManager couldn't redefine previously removed properties. Fix #3803 (thanks @AleBles @oo7ph) +* The Canvas DrawImage function has been recoded entirely so it now correctly supports parent matrix and camera matrix calculations. This fixes an issue where children inside Containers would lose their rotation, and other issues, when in the Canvas Renderer. Fix #3728 (thanks @samid737) +* `clearMask(true)` would throw an exception if the Game Object didn't have a mask. Now it checks first before destroying the mask. Fix #3809 (thanks @NokFrt) +* In the WebGL `GeometryMask` the stencil has been changed from `INVERT` to `KEEP` in order to fix issues when masking Graphics objects and other complex objects. Fix #3807. This also fixes the issue where children in Containers would display incorrectly outside of a Geometry mask. Fix #3746 (thanks @zilbuz @oklar) +* `BitmapMask.destroy` will now remove the textures and framebuffers that it created from the WebGL Renderer as part of the destroy process. Fix #3771 (thanks @nunof07) ### 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: -@DannyT @squilibob @dvdbrink @t1gu1 @cyantree @DrevanTonder @mikewesthad +@DannyT @squilibob @dvdbrink @t1gu1 @cyantree @DrevanTonder @mikewesthad @tarsupin @shadowofsoul Also, a special mention to @andygroff for his excellent work enhancing the search box on the examples site, and @hexus for his assistance completing the documentation for the Game Objects. - ## Version 3.10.1 - Hayashi - 13th June 2018 ### Bug Fixes diff --git a/README.md b/README.md index 0e206034e..ae2391003 100644 --- a/README.md +++ b/README.md @@ -24,25 +24,29 @@ Grab the source and join the fun!
-> 13th June 2018 +> 16th October 2018 -I'm pleased to announce that Phaser 3.10.0 is now available. This release represents just under a month's worth of work and is a huge version for us. It introduces a lot of significant new features into v3, including multi-touch support, custom cursors, pixel perfect detection, Scene isolated input events, new Input plugins, a brand new Gamepad system and plenty more. There are big changes in Arcade Physics too, with a new fixed timestep option, angular damping, speed improvements, support for time scaling across your whole physics simulation and, yes, even more. The Data Manager too has been given a real shot in the arm, and there are subtle but important changes to the Scene flow and Loader interactions. +Phaser 3.15 is now available. This is slightly ahead of schedule because we needed to get some important performance and iOS input related fixes released, without waiting for new features to be completed first. -There are, of course, plenty of bug fixes and updates too. I'd urge you to carefully read the Change Log, especially if upgrading from an earlier version in an existing project. Hundreds more areas have been covered with documentation too. An on-going battle which we're winning, albeit slowly. +This means that the new Scale Manager and Spine support have been moved to release 3.16 due towards the end of October. Please read the weekly Dev Logs for details about development. -3.10 is a huge release and represents tireless effort on my part to get it into this shape. My aim has always been to continue the mission of enhancing Phaser 3 as quickly as I can. It means releasing significant updates in relatively short periods of time. But it also means I'm jumping on bug reports as quickly as I can, keeping the issues list total nice and low (the vast majority of the items in there are feature requests now!) - a massive thank-you to all of you who support Phaser on Patreon and PayPal. It's your support that allows me to work on this full-time, to the benefit of everyone. +> 1st October 2018 + +I'm pleased to announce that Phaser 3.14 is now out. Hot on the heels of the massive 3.13 release, 3.14 brings some sought-after new features to the party, including support for the new Tiled Map Editor 1.2 file formats, as well as the long-requested feature allowing use of multiple tilesets per single tilemap layer. + +There are also new features to make Matter JS debugging easier and body creation when using lists of vertices is now much cleaner too. It's never just features though. There are lots of important fixes and updates in 3.14, including a fix causing gl canvas resizing to fail, better handling of the game shutdown process and fixes for an issue with Graphics.generateTexture. + +If you're building an active project on 3.13 then please upgrade to 3.14 and, as usual, report any issues you find on GitHub so we can look at them immediately. Also, in the 3.14 release we have completed over 1000 new areas of documentation. At the time of writing there are now just 1900 items in the API left to document, which may sound like a lot, but is a fraction of the tens of thousands already done! With our current progress we should have 100% documentation coverage within the next couple of months. + +In case you missed the notice, Phaser 3.13 introduced the Facebook Instant Games Plugin. The plugin provides a seamless bridge between Phaser and version 6.2 of the Facebook Instant Games SDK. Every single SDK function is available via the plugin and we will keep track of the official SDK to make sure they stay in sync. My thanks to Facebook for helping make this possible. + +Also new in 3.13 were the Shape Game Objects, which allows for quick addition of geometry onto the display list. Easily add rectangles, triangles, curves, stars and more into your game and treat them just like any other Game Object. Perfect for place-holder art, abstract style games or just really fast iterations game-jam style. + +3.14 continues to represent the tireless effort on my part to get it fully production ready. I'm seeing lots more games being released with Phaser 3 and stacks of tutorials and plugins are starting to surface. My aim has always been to continue the mission of enhancing Phaser 3 as quickly as I can. It means releasing significant updates in relatively short periods of time. But it also means I'm jumping on bug reports as quickly as I can, keeping the issues list total nice and low (the vast majority of the items in there are feature requests now!) - a massive thank-you to all of you who support Phaser on Patreon and PayPal. It's your support that allows me to work on this full-time, to the benefit of everyone. As always, please check out the [Change Log](#changelog) for comprehensive details about what recent versions contain. -**About Phaser 3** - -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! - -Please understand this is a bleeding-edge and brand new release. There are features we've had to leave out, areas of the documentation that need completing and so many cool new things we wanted to add. But we had to draw a line in the sand somewhere and 3.0.0 represents that. - -For us this is just the start of a new chapter in Phaser's life. We will be jumping on bug reports as quickly as we can and releasing new versions rapidly. We've structured v3 in such a way that we can push out point releases as fast as needed. - -We publish our [Developer Logs](https://phaser.io/phaser3/devlog) in the [Phaser World](https://phaser.io/community/newsletter) newsletter. Subscribe to stay in touch and get all the latest news from us and the wider Phaser community. +If you'd like to stay abreast of developments then I publish my [Developer Logs](https://phaser.io/phaser3/devlog) in the [Phaser World](https://phaser.io/community/newsletter) newsletter. Subscribe to stay in touch and get all the latest news from the core team and the wider community. You can also follow Phaser on [Twitter](https://twitter.com/phaser_) and chat with fellow Phaser devs in our [Slack](https://phaser.io/community/slack) and [Discord](https://phaser.io/community/discord) channels. @@ -104,19 +108,20 @@ 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 - + ``` or the minified version: ```html - + ``` ### API Documentation -1. Go to https://photonstorm.github.io/phaser3-docs/index.html to read the docs online. Use the drop-down menus at the top to navigate the name spaces, classes and Game Objects lists. If you wish to run the docs locally you can ... -2. Checkout the [phaser3-docs](https://github.com/photonstorm/phaser3-docs) repository and then read the documentation by pointing your browser to the local `docs/` folder, and again selecting from the Classes or Namespaces links at the top of the page. +Go to https://photonstorm.github.io/phaser3-docs/index.html to read the docs online. Use the drop-down menus at the top to navigate the name spaces, classes and Game Objects lists. + +Or, if you wish to run the docs locally you can checkout the [phaser3-docs](https://github.com/photonstorm/phaser3-docs) repository and then read the documentation by pointing your browser to the `docs/` folder. The documentation for Phaser 3 is an on-going project. Please help us by searching the Phaser code for any instance of the string `[description]` and then replacing it with some documentation. @@ -130,7 +135,7 @@ As soon as we're happy with the accuracy of the TS defs we'll merge them into th ### Webpack -We use Webpack to build Phaser and we take advantage of its conditional build flag feature to handle renderer swapping. If you wish to use Webpack with Phaser then please use our [Phaser 3 Project Template](https://github.com/photonstorm/phaser3-project-template) as it's already set-up to handle the build conditions Phaser needs. Recent changes to our build steps mean you should now be able to us any other packager, like Parcel, without any config changes. +We use Webpack to build Phaser and we take advantage of its conditional build flag feature to handle renderer swapping. If you wish to use Webpack with Phaser then please use our [Phaser 3 Project Template](https://github.com/photonstorm/phaser3-project-template) as it's already set-up to handle the build conditions Phaser needs. Recent changes to our build steps mean you should now be able to use any other packager, like Parcel, without any config changes. ### License @@ -141,17 +146,60 @@ Phaser is released under the [MIT License](https://opensource.org/licenses/MIT). -Phaser 3 is so new the "paint is still wet", but tutorials and guides are starting to come out! +Tutorials and guides on Phaser 3 development are being published every week. * [Getting Started with Phaser 3](https://phaser.io/tutorials/getting-started-phaser3) (useful if you are completely new to Phaser) * [Making your first Phaser 3 Game](https://phaser.io/tutorials/making-your-first-phaser-3-game) -* [Phaser 3 Bootstrap and Platformer Example](https://phaser.io/news/2018/02/phaser-3-bootstrap-platformer) +* The [Complete Phaser 3 Game Development course](https://academy.zenva.com/product/html5-game-phaser-mini-degree/?a=13) contains over 15 hours of videos covering all kinds of important topics. +* Plus, there are [over 700 Phaser tutorials](http://phaser.io/learn) listed on the official website. Also, please subscribe to the [Phaser World](https://phaser.io/community/newsletter) newsletter for details about new tutorials as they are published. +### Facebook Instant Games + +Phaser 3.13 introduced the new [Facebook Instant Games](http://phaser.io/news/2018/10/facebook-instant-games-phaser-tutorial) Plugin. The plugin provides a seamless bridge between Phaser and version 6.2 of the Facebook Instant Games SDK. Every single SDK function is available via the plugin and we will keep track of the official SDK to make sure they stay in sync. + +The plugin offers the following features: + +* Easy integration with the Phaser Loader so load events update the Facebook progress circle. +* Events for every plugin method, allowing the async calls of the SDK to be correctly inserted into the Phaser game flow. When SDK calls resolve they will surface naturally as a Phaser event and you'll know you can safely act upon them without potentially doing something mid-way through the game step. +* All Plugin methods check if the call is part of the supported APIs available in the SDK, without needing to launch an async request first. +* Instant access to platform, player and locale data. +* Easily load player photos directly into the Texture Manager, ready for use with a Game Object. +* Subscribe to game bots. +* The plugin has a built-in Data Manager which makes dealing with data stored on Facebook seamless. Just create whatever data properties you need and they are automatically synced. +* Support for FB stats, to retrieve, store and increment stats into cloud storage. +* Save Session data with built-in session length validation. +* Easy context switching, to swap between game instances and session data retrieval. +* Easily open a Facebook share, invite, request or game challenge window and populate the text and image content using any image stored in the Texture cache. +* Full Leaderboard support. Retrieve, scan and update leaderboard entries, as well as player matching. +* Support for in-app purchases, with product catalogs, the ability to handle purchases, get past purchases and consume previously unlocked purchases. +* Easily preload a set of interstitial ads, in both banner and video form, then display the ad at any point in your game, with in-built tracking of ads displayed and inventory available. +* Plus other features, such as logging to FB Analytics, creating short cuts, switching games, etc. + +We've 3 tutorials related to Facebook Instant Games and Phaser: + +* [Getting Started with Facebook Instant Games](http://phaser.io/news/2018/10/facebook-instant-games-phaser-tutorial) +* [Facebook Instant Games Leaderboards Tutorial](http://phaser.io/news/2018/11/facebook-instant-games-leaderboards-tutorial) +* [Displaying Ads in your Instant Games](http://phaser.io/news/2018/12/facebook-instant-games-ads-tutorial) + +A special build of Phaser with the Facebook Instant Games Plugin ready-enabled is [available on jsDelivr](https://www.jsdelivr.com/projects/phaser). Include the following in your html: + +```html + +``` + +or the minified version: + +```html + +``` + +The build files are in the git repository in the `dist` folder, and you can also include the plugin in custom builds. + ### Source Code Examples -During our development of Phaser 3, we created hundreds of examples with the full source code and assets. Until these examples are fully integrated into the Phaser website, you can browse them on [Phaser 3 Labs](https://labs.phaser.io), or clone the [examples repo][examples]. We are constantly adding to and refining these examples. +During our development of Phaser 3, we created hundreds of examples with the full source code and assets ready available. Until these examples are fully integrated into the Phaser website, you can browse them on [Phaser 3 Labs](https://labs.phaser.io), or clone the [examples repo][examples]. We are constantly adding to and refining these examples. ### Create Your First Phaser 3 Example @@ -257,11 +305,13 @@ There are both plain and minified compiled versions of Phaser in the `dist` fold ### Custom Builds -Phaser 3 is built using Webpack and we take advantage of the Webpack definePlugin feature to allow for conditional building of the Canvas and WebGL renderers. As of Phaser 3.7 we have updated our webpack config to make our source far easier to consume in other package managers like Parcel and Electron. Please look our webpack config files to get an idea of the settings we use. +Phaser 3 is built using Webpack and we take advantage of the Webpack definePlugin feature to allow for conditional building of the Canvas and WebGL renderers and extra plugins. You can custom the build process to only include the features you require. Doing so can cut the main build file size down to just 70KB. + +Read our [comprehensive guide](https://phaser.io/phaser3/devlog/127) on creating Custom Builds of Phaser 3 for full details. ### Building from Source -If you wish to build Phaser 3 from source, ensure you have the required packages by cloning the repository and then running `npm install`. +If you wish to build Phaser 3 from source, ensure you have the required packages by cloning the repository and then running `npm install` on your source directory. You can then run `webpack` to create a development build in the `build` folder which includes source maps for local testing. You can also `npm run dist` to create a minified packaged build in the `dist` folder. For a list of all commands available use `npm run help`. @@ -270,170 +320,42 @@ You can then run `webpack` to create a development build in the `build` folder w # Change Log -## Version 3.10.1 - Hayashi - 13th June 2018 +## Version 3.15.1 - Batou - 16th October 2018 -### Bug Fixes - -* The InputManager would only create 1 Pointer, even if Touch input was enabled in the config, which meant you couldn't use touch events unless you first called `addPointer` or specified one in the config. Now, it Touch is enabled in the config, it'll always create 2 pointers by default. - -## Version 3.10.0 - Hayashi - 13th June 2018 - -### Input System New Features + Updates - -* All Input classes are now covered 100% by JSDocs. -* The Input Manager and Input Plugin have been updated to support multiple simultaneous Pointers. Before, only one active pointer (mouse or touch) was supported. Now, you can have as many active pointers as you need, allowing for complex multi-touch games. These are stored in the Input Manager `pointers` array. -* `addPointer` allows you to add one, or more, new pointers to the Input Manager. There is no hard-coded limit to the amount you can have, although realistically you should never need more than 10. This method is available on both the Input Manager and Plugin, allowing you to use `this.input.addPointer` from within your game code. -* InputManager `pointersTotal` contains the total number of active pointers, which can be set in the Game Config using the `input.activePointers` property. Phaser will create 2 pointers on start unless a different value is given in the config, or you can add them at run-time. -* `mousePointer` is a new property that is specifically allocated for mouse use only. This is perfect for desktop only games but should be ignored if you're creating a mouse + touch game (use activePointer instead). -* `activePointer` will now reflect the most recently active pointer on the game, which is considered as being the pointer to have interacted with the game canvas most recently. -* The InputManager and InputPlugin have three new methods: `addUpCallback`, `addDownCallback` and `addMoveCallback`. These methods allow you to add callbacks to be invoked whenever native DOM mouse or touch events are received. Callbacks passed to this method are invoked _immediately_ when the DOM event happens, within the scope of the DOM event handler. Therefore, they are considered as 'native' from the perspective of the browser. This means they can be used for tasks such as opening new browser windows, or anything which explicitly requires user input to activate. However, as a result of this, they come with their own risks, and as such should not be used for general game input, but instead be reserved for special circumstances. The callbacks can be set as `isOnce` so you can control if the callback is called once then removed, or every time the DOM event occurs. -* Pointer has two new properties `worldX` and `worldY` which contain the position of the Pointer, translated into the coordinate space of the most recent Camera it interacted with. -* When checking to see if a Pointer has interacted with any objects it will now iterate through the Camera list. Previously, it would only check against the top-most Camera in the list, but now if the top-most camera doesn't return anything, it will move to the next camera and so on. This also addresses #3631 (thanks @samid737) -* `InputManager.dirty` is a new internal property that reflects if any of the Pointers have updated this frame. -* `InputManager.update` now uses constants internally for the event type checking, rather than string-based like before. -* `InputManager.startPointer` is a new internal method, called automatically by the update loop, that handles touch start events. -* `InputManager.updatePointer` is a new internal method, called automatically by the update loop, that handles touch move events. -* `InputManager.stopPointer` is a new internal method, called automatically by the update loop, that handles touch end events. -* `InputManager.hitTest` has had its arguments changed. It no longer takes x/y properties as the first two arguments, but instead takes a Pointer object (from which the x/y coordinates are extracted). -* `TouchManager.handler` has been removed as it's no longer used internally. -* `TouchManager.onTouchStart`, `onTouchMove` and `onTouchEnd` are the new DOM Touch Event handlers. They pass the events on to the InputManagers `queueTouchStart`, `queueTouchMove` and `queueTouchEnd` methods respectively. -* `MouseManager.handler` has been removed as it's no longer used internally. -* `MouseManager.onMouseDown`, `onMouseMove` and `onMouseUp` are the new DOM Mouse Event handlers. They pass the events on to the InputManagers `queueMouseDown`, `queueMouseMove` and `queueMouseUp` methods respectively. -* Setting `enabled` to false on either the TouchManager, MouseManager or KeyboardManager will prevent it from handling any native DOM events until you set it back again. -* InputPlugin has the following new read-only properties: `mousePointer`, `pointer1`, `pointer2`, `pointer3`, `pointer4`, `pointer5`, `pointer6`, `pointer7`, `pointer8`, `pointer9` and `pointer10`. Most of these will be undefined unless you call `addPointer` first, or set the active pointers quantity in your Game Config. -* InputManager has a new method `transformPointer` which will set the transformed x and y properties of a Pointer in one call, rather than the 2 calls it took before. This is now used by all Pointer event handlers. -* InputPlugin has a new method `makePixelPerfect` which allows you to specify a texture-based Game Object as being pixel perfect when performing all input checks against it. You use it like this: `this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect())`, or the easier: `setInteractive({ pixelPerfect: true })` - you can also pass or set an optional alpha tolerance level. See the method docs for full details and the new examples to see it in action. Note that as a pointer interacts with the Game Object it will constantly poll the texture, extracting a single pixel from the given coordinates and checking its color values. This is an expensive process, so should only be enabled on Game Objects that really need it. - -### Input - Custom Cursors - -* You can now set a custom cursor for your game via `this.input.setDefaultCursor()`. This will take any valid CSS cursor string, including URLs to cursor image files. -* You can now set a custom cursor for specific Game Objects. This will take any valid CSS cursor string, including URLs to cursor image files, and is used when-ever a pointer is over that Game Object. For example, to have a hand cursor appear when over a button Sprite, you can do: `button.input.cursor = 'pointer'`, or to have a help cursor appear: `button.input.cursor = 'help'`, or to have a custom image: `button.input.cursor = 'url(assets/cursors/sword.cur), pointer'`. -* You can also set a custom cursor in the new Input Configuration Object. To use the `pointer` (hand cursor) there is a new short-cut: `setInteractive({ useHandCursor: true })`. To use anything else: `setInteractive({ cursor: CSSString })` where `CSSString` is any valid CSS for setting a cursor. -* Please be aware of limitations when it comes to image based cursors between browsers. It's up to you to find a suitable format and size that fits the browsers you wish to support (note: virtually all modern browsers no longer support animated CSS cursors.) - -### Input - Configuration Objects - -* The `setInteractive` method can now take an Input Configuration object as its only argument. This allows you to set multiple input related properties in a single call, i.e.: `setInteractive({ draggable: true, pixelPerfect: true })`. The available properties are: -* `hitArea` - The object / shape to use as the Hit Area. If not given it will try to create a Rectangle based on the texture frame. -* `hitAreaCallback` - The callback that determines if the pointer is within the Hit Area shape or not. -* `draggable` - If `true` the Interactive Object will be set to be draggable and emit drag events. -* `dropZone` - If `true` the Interactive Object will be set to be a drop zone for draggable objects. -* `useHandCursor` - If `true` the Interactive Object will set the `pointer` hand cursor when a pointer is over it. This is a short-cut for setting `cursor: 'pointer'`. -* `cursor` - The CSS string to be used when the cursor is over this Interactive Object. -* `pixelPerfect` - If `true` the a pixel perfect function will be set for the hit area callback. Only works with texture based Game Objects. -* `alphaTolerance` - If `pixelPerfect` is set, this is the alpha tolerance threshold value used in the callback. - -### Input - Keyboard Manager Updates - -* The `KeyboardManager` class has been removed. It has been replaced with `KeyboardPlugin` which is now an Input level plugin, that registers itself with the new `InputPluginCache`. The Input Plugin class (which belongs to a Scene) will now automatically inject registered plugins into itself on boot. Every Scene has its own instance of the Input Plugin (if enabled in the scene plugins), which in turn has its own instance of the KeyboardPlugin. The `InputManager` no longer has any reference to the Keyboard class at all. The benefits of this are two-fold: First, it allows you to now entirely exclude all of the keyboard classes from a custom build, saving a lot of space if not required. Secondly, it means that the Scenes themselves are now responsible for keyboard events, where-as before they were entirely global. This means a Scene can be paused and stop processing keyboard events, and stop having its Key objects updated, while another Scene can still carry on doing this. It also prevents key related callbacks in sleeping Scenes from being fired (which resolves issue #3733, thanks @JoeMoov2) -* `KeyboardManager.handler` has been renamed to `onKeyHandler`. -* The `KeyboardManager.captures` property has been removed as it can be more effectively handled by polling the `keys` object instead. -* The Keyboard Manager will no longer process key down or up events if its `enabled` property is set to false, or if the Scene to which it belongs is not active. -* The Keyboard Manager will now call `event.preventDefault` on the native DOM event as long as the Key exists in the keys array and has its `preventDefault` property set to `true` (which is the default). This means you can now control specifically which key prevents default on the browser, where-as before every key added did so. -* KeyboardManager `addKeyCapture` and `removeKeyCapture` have been removed as you now control which keys prevent capture by using the `addKey` or `addKeys` methods (see entry above). The act of creating a Key is now enough to enable capture of it and can be toggled (at run-time) on a per-Key basis. -* `KeyboardManager.addKeys` can now take either an object, or key codes, or a comma-separated string as its input. This means you can now do: `keyboard.addKeys('W,S,A,D')` and get an object back with the properties WSAD mapped to the relevant Key objects. -* `KeyboardManager.addKey` can now take either a Key object, a string, such as `A` or `SPACE`, or a key code value. -* `KeyboardManager.removeKey` can now take either a Key object, a string, such as `A` or `SPACE`, or a key code value. - -### Input - Gamepad Manager Updates - -* The `GamepadManager` class has been removed. It has been replaced with `GamepadPlugin` which is now an Input level plugin, that registers itself with the new `InputPluginCache`. The Input Plugin class (which belongs to a Scene) will now automatically inject the registered plugins into itself on boot. Every Scene has its own instance of the Input Plugin (if enabled in the scene plugins), which in turn has its own instance of the GamepadPlugin. The `InputManager` no longer has any reference to the Gamepad class at all. The benefits of this are two-fold: First, it allows you to now entirely exclude all of the gamepad classes from a custom build, saving a lot of space if not required. Secondly, it means that the Scenes themselves are now responsible for gamepad events, where-as before they were entirely global. This means a Scene can be paused and stop processing gamepad events, and stop having its Gamepad objects updated, while another Scene can still carry on doing this. It also prevents gamepad related callbacks in sleeping Scenes from being fired. -* The Gamepad Plugin has been rewritten from scratch. It now offers a lot more features and far easier access to the Gamepads and their properties. You can now access the first 4 gamepads connected to the browser via the `pad1` to `pad4` properties, meaning you can do: `this.input.gamepad.pad1` for direct access to a pad once it's connected. -* The Gamepad class has also been rewritten from scratch. It will no longer create Buttons or Axes dynamically, instead doing so on instantiation. -* The Gamepad class now has a bunch of new properties for easy access to the various standard mapping buttons. These include `left`, `right`, `up`, `down` for directions, `A`, `Y`, `X` and `B` for buttons, `L1`, `L2`, `R1` and `R2` for shoulder buttons, and `leftStick` and `rightStick` for the axis sticks. You can still use `Gamepad.getButtonValue()` to get the value from a button and `Gamepad.getButtonTotal()` to get the total number of buttons available on the pad. -* `Gamepad.getAxisTotal` and `Gamepad.getAxisValue` will return the total number of axis, and an axis value, accordingly. -* `Gamepad.setAxisThreshold` will now let you set the threshold across all axis of a Gamepad in one call. -* The Gamepad `Button` objects will now emit 2 events, one from the button itself and another from the Gamepad. This means you can listen for button events in 3 ways: 1) By directly polling the button value in an update loop, 2) Listening for events on the Gamepad Plugin: `this.input.gamepad.on('down')`, or 3) By listening for events on the Gamepad itself: `gamepadReference.on('down')`. - -### Arcade Physics New Features + Updates - -* Arcade Physics now uses a fixed time-step for all internal calculations. There is a new `fps` config value and property (defaults to 60fps), which you can change at run-time using the `setFPS` method. The core update loop has been recoded so that it steps based entirely on the given frame rate, and not the wall-clock or game step delta. This fixed time step allows for a straightforward implementation of a deterministic game state. Meaning you can now set the fps rate to a high value such as 240, regardless of the browser update speed (it will simply perform more physics steps per game step). This is handy if you want to increase the accuracy of the simulation in certain cases. -* You can also optionally call the `step` function directly, to manually advance the simulation. -* There is a new property `timeScale` which will scale all time-step calculations at run-time, allowing you to speed-up or slow-down your simulation at will, without adjusting the frame rate. -* You can now disable the use of the RTree for dynamic bodies via the config property `useTree`. In certain situations, i.e. densely packed worlds, this may give better performance. Static bodies will always use an RTree. -* `collideSpriteVsGroup` has been rewritten. If you are using an RTree it now uses the results directly from the tree search, instead of iterating all children in the Group, which dramatically reduces the work it does. If you have disabled the RTree it performs a brute-force O(N2) Sprite vs. Group iteration sweep. We tested multiple axis sorting variants but the cost of the array allocation and/or sorting, with large amounts of bodies (10,000+), far outweighed the simple math involved in the separation logic. -* `Body.useDamping` is a new boolean property that allows you to use a damping effect for drag, rather than the default linear deceleration. This gives much better results if you need smooth deceleration across both axis, such as the way the ship slows down in the game Asteroids, without the tell-tale axis drift associated with linear drag. -* `GetOverlapX` and `GetOverlapY` now use the calculated delta values, not the deltaX/Y methods. -* `collideSpriteVsGroup` aborts early if the Sprite body has been disabled. -* `updateMotion` has a new argument `delta` which should typically be a fixed-time delta value. -* `intersects` has been restructured to prioritize rect vs. rect checks. -* Body `update` and `postUpdate` have been recoded to handle the new fixed time-step system in place. `update` now takes a new argument, delta, which is used internally for calculations. -* `Body.dirty` has been removed as a property as it's no longer used internally. -* `Body.deltaAbsX` and `deltaAbsY` now return the cached absolute delta value from the previous update, and no longer calculate it during the actual call. -* `World.enable` has been recoded to remove all the `hasOwnProperty` checks and streamline the internal flow. -* `World.disable` has been recoded to remove all the `hasOwnProperty` checks and streamline the internal flow. -* `World.add` is a new method that adds an existing body to the simulation and `enableBody` now passes its newly created bodies to this method. -* `World.disableGameObjectBody` has been removed as it duplicated what the `disable` method did. -* There is a new internal flow with regard to the creation and disabling of bodies. Calling `World.enable` will pass the objects to `enableBody`, which will create a new Body object, if required, and finally pass it to `add`. `World.disable` does the same, but removes the bodies from the simulation. It passes the bodies to `disableBody`, which in turn passes it to `remove`. Both of these work for single objects, an array of objects, Groups or even arrays of Groups. -* `World.computeAngularVelocity` is a new method that specifically calculates the angular velocity of a Body. -* `World.computeVelocity` has had its signature changed. Rather than taking a bunch of arguments all it now takes is a Body and a delta value. Internally it now calculates both the x and y velocity components together in the same single call, where-as before it was split into two calls and multiple assignments. -* `World.computeVelocity` no longer returns the new velocities, they are now set directly on the body within the method. -* `World.computeVelocity` has been recoded to use Fuzzy Greater Than and Less Than calls when applying drag to a previously accelerated body. Using a fuzzy epsilon allows us to mitigate the ping-pong issue, where a decelerating body would constantly flip between a small negative and positive velocity value and never come to an actual rest. -* `World.computeVelocity` now checks the `Body.useDamping` property to perform either linear deceleration or damping on the Body. -* `World.updateMotion` has changed to call the new `computeAngularVelocity` and `computeVelocity` methods. -* Bodies set to bounce would eventually run out of velocity and stop. This has been fixed as part of the refactoring of the time step and compute velocity updates. Fix #3593 (thanks @helmi77) -* If a Body collides with a Static Body it will now set the `blocked` properties accordingly (before it only set the `touching` properties.) This means you can now use checks like `Body.onFloor()` when traversing static bodies (thanks @fariazz) - -### Data Manager New Features and Updates - -* You can now access anything set in the DataManager using the new `values` property. For example, if you set a new value such as this: `data.set('gold', 50)` you can now access it via: `data.values.gold`, where it is treated as a normal property, allowing you to use it in conditional evaluations `if (data.values.level === 2)`, or modify it: `data.values.gold += 50`. -* Each time a value is updated it emits a `changedata` event, regardless if it is changed via the `set` method, or the new `values` approach. -* Each time a value is updated it emits a new event named after the value. For example, if the value was called `PlayerLives`, it will emit the event `changedata_PlayerLives`. This happens regardless if it is changed via the `set` method, or the new `values` approach. -* The `set` method can now take an object containing key value pairs as the first argument. This means you can now set a bunch of values all at once, i.e: `data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 })`. -* The `get` method can now take an array of keys, and will return an array of matching values. This is handy for array destructuring in ES6. -* The `remove` method can now take an array of keys, and will remove all matching values, emitting the `removedata` event for each. -* The order of events has been updated. When a value is first set, and doesn't already exist in the Data Manager, it will emit a `setdata` event. If a value is set that already exists, it instead emits a `changedata` and related `changedata_key` event. Setting a new value no longer emits both events. -* The `resetFunction` function has been removed from the `changedata` event arguments. Previously this was used to allow you to stop a value being updated by calling the reset function instead. However, it created brand new anonymous functions every single time a value was updated. As you can now access stored data via the `values` property you can use this for much easier conditional checks and sets. -* The `blockSet` property has been removed as it's no longer used internally. - -### Loader and Scene Updates - -* Internally, the Loader has changed slightly. Rather than have each file cause the new batch to load, an `update` method is polled every frame, which does the same job instead. This avoids load-time race conditions where pre-populated files would trigger loads part way during an existing load, fixing #3705 in the process (thanks @the-simian) -* The Scene Manager has been updated so that it will call Scene.Systems.step during the `init`, `preload` and `create` phase of your Scene. This means that any plugins, or custom code, written to use the Scene Systems `preupdate`, `update` or `postupdate` events will need to be aware that these are now fired from `init` onwards, not just once `create` has finished. -* As a result of these two changes, there is a new Systems property called `sceneUpdate`, which is a reference that maps to your `Scene.update` function. During `init`, `preload` and `create` this is always mapped to NOOP. Once `create` has finished it gets re-mapped to your Scene's update function. If your Scene doesn't have one, it remains mapped to NOOP. In practise, this means nothing has changed from before. `Scene.update` never ran until `create` was completed, and it still doesn't. However, because the internal Scene systems are now updating right from `init`, it means that things like the update list and physics systems are fully operational _during_ your Preloader. This allows you to create far more elaborate preloaders than ever before. Although, with great power comes great responsibility, as the onus is now on you to be careful which events you consume (especially input events) during your preloader. -* Another side-effect of these changes is that Scenes no longer need an 'update' function at all. Previously, if they were missing one, the Scene Manager would inject one into them automatically. It no longer does this. +Note: We are releasing this version ahead of schedule in order to make some very important iOS performance and input related fixes available. It does not contain the new Scale Manager or Spine support, both of which have been moved to 3.16 as they require a few more weeks of development. ### New Features -* `RenderTexture.resize` will allow you to resize the underlying Render Texture to the new dimensions given. Doing this also clears the Render Texture at the same time (thanks @saqsun). -* `Rectangle.RandomOutside` is a new function that takes two Rectangles, `outer` and `inner`, and returns a random point that falls within the outer rectangle but is always outside of the inner rectangle. -* The Update List has a new read-only property `length`, making it consistent with the Display List (thanks @samme) -* The 2D Camera class has two new read-only properties `centerX` and `centerY` which return the coordinates of the center of the viewport, relative to the canvas (thanks @samme) -* Camera has a new property `visible`. An invisible Camera will skip rendering and input tests of everything it can see. This allows you to create say a mini-cam and then toggle it on and off without needing to re-create it each time. -* Camera has a new method `setVisible` which toggles its visible property. -* `CameraManager.fromJSON` will now set the visible property is defined in the config. -* `ScenePlugin.run` is a new method that will run the given Scene and not change the state of the current Scene at all. If the scene is asleep, it will be woken. If it's paused, it will be resumed. If not running at all, it will be started. -* `TextureManager.getPixelAlpha` is a new method that will return the alpha value of a pixel from the given texture and frame. It will return `null` if the coordinates were out of bounds, otherwise a value between 0 and 255. -* `Game.isOver` is a new read-only boolean property that indicates if the mouse pointer is currently over the game canvas or not. It is set by the VisibilityHandler and is only reliable on desktop systems. -* A new event `Game.mouseout` is dispatched if the mouse leaves the game canvas. You can listen to it from `this.sys.game.events.on('mouseout')` from within a Scene. -* A new event `Game.mouseover` is dispatched if the mouse enters the game canvas, having previously been outside of it. You can listen to it from `this.sys.game.events.on('mouseover')` from within a Scene. -* You can now use PhysicsEditor (https://www.codeandweb.com/physicseditor) to create complex Matter.js bodies. Load them as normal JSON and then just pass it to the Matter Sprite as a shape property: `this.matter.add.sprite(x, y, texture, frame, { shape: shapes.banana })` (where `shapes.banana` is one of the exported PhysicsEditor shapes in the JSON you loaded). See the 'physics/matterjs/advanced shape creation.js' example for more details. +* You can now set the `maxLights` value in the Game Config, which controls the total number of lights the Light2D shader can render in a single pass. The default is 10. Be careful about pushing this too far. More lights = less performance. Close #4081 (thanks @FrancescoNegri) +* `Rectangle.SameDimensions` determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. +* An ArcadePhysics Group can now pass `{ enable: false }`` in its config to disable all the member bodies (thanks @samme) +* `Body.setEnable` is a new chainable method that allows you to toggle the enable state of an Arcade Physics Body (thanks @samme) +* `KeyboardPlugin.resetKeys` is a new method that will reset the state of any Key object created by a Scene's Keyboard Plugin. +* `Pointer.wasCanceled` is a new boolean property that allows you to tell if a Pointer was cleared due to a `touchcancel` event. This flag is reset during the next `touchstart` event for the Pointer. +* `Pointer.touchcancel` is a new internal method specifically for handling touch cancel events. It has the same result as `touchend` without setting any of the up properties, to avoid triggering up event handlers. It will also set the `wasCanceled` property to `true`. ### Updates -* The `ForwardDiffuseLightPipeline`, used by the Lights system, now sets a flag if the Scene doesn't contain any lights. All of the Game Objects now check this flag and don't even bother adding themselves to the batch if there are no lights in the Scene, as they'd never render anyway. This also avoids the ghost-image problem if you swap Scenes to a new Scene with the Light Manager enabled, but no actual lights defined. Fix #3707 (thanks @samvieten). -* `CameraManager.getCameraBelowPointer` has been renamed to `getCamerasBelowPointer` and it now returns an array of all the cameras below the given pointer, not just the top-most one. The array is sorted so that the top-most camera is at the start of the array. -* In `TimeStep.step` the `rawDelta` and `delta` values are checked to make sure they are non-negative, which can happen in Chrome when the delta is reset and out of sync with the value passed to Request Animation Frame. Fix #3088 (thanks @Antriel) -* `Cameras.Controls.Fixed` has been removed. It's was deprecated a few versions ago. Please use `FixedKeyControl` instead. -* `Cameras.Controls.Smoothed` has been removed. It's was deprecated a few versions ago. Please use `SmoothedKeyControl` instead. +* `WebGLRenderer.deleteTexture` will check to see if the texture it is being asked to delete is the currently bound texture or not. If it is, it'll set the blank texture to be bound after deletion. This should stop `RENDER WARNING: there is no texture bound to the unit 0` errors if you destroy a Game Object, such as Text or TileSprite, from an async or timed process (thanks jamespierce) +* The `RequestAnimationFrame.step` and `stepTimeout` functions have been updated so that the new Frame is requested from raf before the main game step is called. This allows you to now stop the raf callback from within the game update or render loop. Fix #3952 (thanks @tolimeh) +* If you pass zero as the width or height when creating a TileSprite it will now use the dimensions of the texture frame as the size of the TileSprite. Fix #4073 (thanks @jcyuan) +* `TileSprite.setFrame` has had both the `updateSize` and `updateOrigin` arguments removed as they didn't do anything for TileSprites and were misleading. +* `CameraManager.remove` has a new argument `runDestroy` which, if set, will automatically call `Camera.destroy` on the Cameras removed from the Camera Manager. You should nearly always allow this to happen (thanks jamespierce) +* Device.OS has been restructured to allow fake UAs from Chrome dev tools to register iOS devices. +* Texture batching during the batch flush has been implemented in the TextureTintPipeline which resolves the issues of very low frame rates, especially on iOS devices, when using non-batched textures such as those used by Text or TileSprites. Fix #4110 #4086 (thanks @ivanpopelyshev @sachinhosmani @maximtsai @alexeymolchan) +* The WebGLRenderer method `canvasToTexture` has a new optional argument `noRepeat` which will stop it from using `gl.REPEAT` entirely. This is now used by the Text object to avoid it potentially switching between a REPEAT and CLAMP texture, causing texture black-outs (thanks @ivanpopelyshev) +* `KeyboardPlugin.resetKeys` is now called automatically as part of the Keyboard Plugin `shutdown` method. This means, when the plugin shuts down, such as when stopping a Scene, it will reset the state of any key held in the plugin. It will also clear the queue of any pending events. +* The `Touch Manager` has been rewritten to use declared functions for all touch event handlers, rather than bound functions. This means they will now clear properly when the TouchManager is shut down. +* There is a new Input constant `TOUCH_CANCEL` which represents canceled touch events. ### Bug Fixes -* The Canvas `RenderTexture.drawImage` method incorrectly set the values of the frame, causing them to appear wrongly scaled in the canvas renderer. Fix #3710 (thanks @saqsun). -* Fixed `Math.Matrix4.makeRotationAxis()` (thanks @hexus) -* Fixed an incorrect usage of `Math.abs()` in `Math.Quaternion.calculateW()` (thanks @qxzkjp). -* Particle Emitter Managers can now be added to Containers (thanks @TadejZupancic) -* Fixed a method signature issue with the Animation component's `remove()` handler when `Animation`s are removed from the `AnimationManager`. This prevented removed animations from stopping correctly. -* If you set Phaser to use a pre-existing Canvas element it is no longer re-added to the DOM (thanks @NQNStudios) -* The `TweenManager.getTweensOf` method has been fixed to remove a potential endless loop should multiple targets be passed in to it (thanks @cyantree) -* Interactive Objects inside of Containers would still fire their input events even if the Container (or any ancestor) was set to be invisible. Objects now check their ancestor tree during the input cull and now properly skip input events if not visible. Fix #3620 (thanks @NemoStein) -* Fixed Device.os incorrectly reporting Linux as OS on Android devices (thanks @AleBles) - -### Examples, Documentation and TypeScript - -Thanks to the work of @hexus we have now documented all of the Math namespace and made good progress on the Game Objects. - -I personally have also documented the entire Input system, which was 328 classes, properties and methods to describe, as well as lots of other areas. +* Fixed a bug in the canvas rendering of both the Static and Dynamic Tilemap Layers where the camera matrix was being multiplied twice with the layer, causing the scale and placement to be off (thanks galerijanamar) +* If you set `pixelArt` to true in your game config (or `antialias` to false) then TileSprites will now respect this when using the Canvas Renderer and disable smoothing on the internal fill canvas. +* TileSprites that were set to be interactive before they had rendered once wouldn't receive a valid input hit area, causing input to fail. They now define their size immediately, allowing them to be made interactive without having rendered. Fix #4085 (thanks @DotTheGreat) +* The Particle Emitter Manager has been given a NOOP method called `setBlendMode` to stop warnings from being thrown if you added an emitter to a Container in the Canvas renderer. Fix #4083 (thanks @maximtsai) +* The `game.context` property would be incorrectly set to `null` after the WebGLRenderer instance was created (thanks @samme) +* The Touch Manager, Input Manager and Pointer classes all now handle the `touchcancel` event, such as triggered on iOS when activating an out of browser UI gesture, or in Facebook Instant Games when displaying an overlay ad. This should prevent issues with touch input becoming locked on iOS specifically. Fix #3756 (thanks @sftsk @sachinhosmani @kooappsdevs) Please see the complete [Change Log](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md) for previous releases. @@ -466,8 +388,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.10.1/phaser.js -[get-minjs]: https://github.com/photonstorm/phaser/releases/download/v3.10.1/phaser.min.js +[get-js]: https://github.com/photonstorm/phaser/releases/download/v3.15.1/phaser.js +[get-minjs]: https://github.com/photonstorm/phaser/releases/download/v3.15.1/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 @@ -476,4 +398,4 @@ All rights reserved. [issues]: https://github.com/photonstorm/phaser/issues [examples]: https://github.com/photonstorm/phaser3-examples [contribute]: https://github.com/photonstorm/phaser/blob/master/.github/CONTRIBUTING.md -[forum]: http://www.html5gamedevs.com/forum/33-phaser-3/ +[forum]: https://phaser.discourse.group/ diff --git a/dist/phaser-arcade-physics.js b/dist/phaser-arcade-physics.js index 0d5800d21..40e97dc8e 100644 --- a/dist/phaser-arcade-physics.js +++ b/dist/phaser-arcade-physics.js @@ -76,7 +76,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1027); +/******/ return __webpack_require__(__webpack_require__.s = 1078); /******/ }) /************************************************************************/ /******/ ([ @@ -321,6 +321,33 @@ module.exports = Class; /* 1 */ /***/ (function(module, exports) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A NOOP (No Operation) callback function. + * + * Used internally by Phaser when it's more expensive to determine if a callback exists + * than it is to just invoke an empty function. + * + * @function Phaser.Utils.NOOP + * @since 3.0.0 + */ +var NOOP = function () +{ + // NOOP +}; + +module.exports = NOOP; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -330,7 +357,7 @@ module.exports = Class; /** * Finds the key within the top level of the {@link source} object, or returns {@link defaultValue} * - * @function Phaser.Utils.Object.GetFastValue + * @function Phaser.Utils.Objects.GetFastValue * @since 3.0.0 * * @param {object} source - The object to search @@ -360,762 +387,8 @@ var GetFastValue = function (source, key, defaultValue) module.exports = GetFastValue; -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var DataManager = __webpack_require__(81); -var EventEmitter = __webpack_require__(9); - -/** - * @classdesc - * The base class that all Game Objects extend. - * You don't create GameObjects directly and they cannot be added to the display list. - * Instead, use them as the base for your own custom classes. - * - * @class GameObject - * @memberOf Phaser.GameObjects - * @extends Phaser.Events.EventEmitter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. - * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`. - */ -var GameObject = new Class({ - - Extends: EventEmitter, - - initialize: - - function GameObject (scene, type) - { - EventEmitter.call(this); - - /** - * The Scene to which this Game Object belongs. - * Game Objects can only belong to one Scene. - * - * @name Phaser.GameObjects.GameObject#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A textual representation of this Game Object, i.e. `sprite`. - * Used internally by Phaser but is available for your own custom classes to populate. - * - * @name Phaser.GameObjects.GameObject#type - * @type {string} - * @since 3.0.0 - */ - this.type = type; - - /** - * The parent Container of this Game Object, if it has one. - * - * @name Phaser.GameObjects.GameObject#parentContainer - * @type {Phaser.GameObjects.Container} - * @since 3.4.0 - */ - this.parentContainer = null; - - /** - * The name of this Game Object. - * Empty by default and never populated by Phaser, this is left for developers to use. - * - * @name Phaser.GameObjects.GameObject#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The active state of this Game Object. - * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. - * An active object is one which is having its logic and internal systems updated. - * - * @name Phaser.GameObjects.GameObject#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * The Tab Index of the Game Object. - * Reserved for future use by plugins and the Input Manager. - * - * @name Phaser.GameObjects.GameObject#tabIndex - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.tabIndex = -1; - - /** - * A Data Manager. - * It allows you to store, query and get key/value paired information specific to this Game Object. - * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. - * - * @name Phaser.GameObjects.GameObject#data - * @type {Phaser.Data.DataManager} - * @default null - * @since 3.0.0 - */ - this.data = null; - - /** - * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. - * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. - * If those components are not used by your custom class then you can use this bitmask as you wish. - * - * @name Phaser.GameObjects.GameObject#renderFlags - * @type {integer} - * @default 15 - * @since 3.0.0 - */ - this.renderFlags = 15; - - /** - * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly. Instead call `Camera.ignore`. - * - * @name Phaser.GameObjects.GameObject#cameraFilter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cameraFilter = 0; - - /** - * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. - * Not usually set directly. Instead call `GameObject.setInteractive()`. - * - * @name Phaser.GameObjects.GameObject#input - * @type {?Phaser.Input.InteractiveObject} - * @default null - * @since 3.0.0 - */ - this.input = null; - - /** - * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. - * - * @name Phaser.GameObjects.GameObject#body - * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} - * @default null - * @since 3.0.0 - */ - 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 - scene.sys.queueDepthSort(); - - scene.sys.events.once('shutdown', this.destroy, this); - }, - - /** - * Sets the `active` property of this Game Object and returns this Game Object for further chaining. - * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. - * - * @method Phaser.GameObjects.GameObject#setActive - * @since 3.0.0 - * - * @param {boolean} value - True if this Game Object should be set as active, false if not. - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setActive: function (value) - { - this.active = value; - - return this; - }, - - /** - * Sets the `name` property of this Game Object and returns this Game Object for further chaining. - * The `name` property is not populated by Phaser and is presented for your own use. - * - * @method Phaser.GameObjects.GameObject#setName - * @since 3.0.0 - * - * @param {string} value - The name to be given to this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setName: function (value) - { - this.name = value; - - return this; - }, - - /** - * Adds a Data Manager component to this Game Object. - * - * @method Phaser.GameObjects.GameObject#setDataEnabled - * @since 3.0.0 - * @see Phaser.Data.DataManager - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setDataEnabled: function () - { - if (!this.data) - { - this.data = new DataManager(this); - } - - return this; - }, - - /** - * Allows you to store a key value pair within this Game Objects Data Manager. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * sprite.setData('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `getData`: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or you can access the value directly via the `values` property, where it works like any other variable: - * - * ```javascript - * sprite.data.values.gold += 50; - * ``` - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * - * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. - * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. - * - * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * - * @method Phaser.GameObjects.GameObject#setData - * @since 3.0.0 - * - * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. - * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. - * - * @return {this} This GameObject. - */ - setData: function (key, value) - { - if (!this.data) - { - this.data = new DataManager(this); - } - - this.data.set(key, value); - - return this; - }, - - /** - * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. - * - * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * sprite.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: - * - * ```javascript - * sprite.getData([ 'gold', 'armor', 'health' ]); - * ``` - * - * This approach is useful for destructuring arrays in ES6. - * - * @method Phaser.GameObjects.GameObject#getData - * @since 3.0.0 - * - * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. - * - * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. - */ - getData: function (key) - { - if (!this.data) - { - this.data = new DataManager(this); - } - - return this.data.get(key); - }, - - /** - * Pass this Game Object to the Input Manager to enable it for Input. - * - * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area - * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced - * input detection. - * - * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If - * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific - * shape for it to use. - * - * You can also provide an Input Configuration Object as the only argument to this method. - * - * @method Phaser.GameObjects.GameObject#setInteractive - * @since 3.0.0 - * - * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. - * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setInteractive: function (shape, callback, dropZone) - { - this.scene.sys.input.enable(this, shape, callback, dropZone); - - return this; - }, - - /** - * If this Game Object has previously been enabled for input, this will disable it. - * - * An object that is disabled for input stops processing or being considered for - * input events, but can be turned back on again at any time by simply calling - * `setInteractive()` with no arguments provided. - * - * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. - * - * @method Phaser.GameObjects.GameObject#disableInteractive - * @since 3.7.0 - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - disableInteractive: function () - { - if (this.input) - { - this.input.enabled = (this.input.enabled) ? false : true; - } - - return this; - }, - - /** - * If this Game Object has previously been enabled for input, this will remove it. - * - * The Interactive Object that was assigned to this Game Object will be destroyed, - * removed from the Input Manager and cleared from this Game Object. - * - * If you wish to re-enable this Game Object at a later date you will need to - * re-create its InteractiveOobject by calling `setInteractive` again. - * - * If you wish to only temporarily stop an object from receiving input then use - * `disableInteractive` instead, as that toggles the interactive state, where-as - * this erases it completely. - * - * @method Phaser.GameObjects.GameObject#removeInteractive - * @since 3.7.0 - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - removeInteractive: function () - { - this.scene.sys.input.clear(this); - - this.input = undefined; - - return this; - }, - - /** - * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. - * - * @method Phaser.GameObjects.GameObject#update - * @since 3.0.0 - */ - update: function () - { - }, - - /** - * Returns a JSON representation of the Game Object. - * - * @method Phaser.GameObjects.GameObject#toJSON - * @since 3.0.0 - * - * @return {JSONGameObject} A JSON representation of the Game Object. - */ - toJSON: function () - { - return Components.ToJSON(this); - }, - - /** - * Compares the renderMask with the renderFlags to see if this Game Object will render or not. - * - * @method Phaser.GameObjects.GameObject#willRender - * @since 3.0.0 - * - * @return {boolean} True if the Game Object should be rendered, otherwise false. - */ - willRender: function () - { - return (GameObject.RENDER_MASK === this.renderFlags); - }, - - /** - * Returns an array containing the display list index of either this Game Object, or if it has one, - * its parent Container. It then iterates up through all of the parent containers until it hits the - * root of the display list (which is index 0 in the returned array). - * - * Used internally by the InputPlugin but also useful if you wish to find out the display depth of - * this Game Object and all of its ancestors. - * - * @method Phaser.GameObjects.GameObject#getIndexList - * @since 3.4.0 - * - * @return {integer[]} An array of display list position indexes. - */ - getIndexList: function () - { - // eslint-disable-next-line consistent-this - var child = this; - var parent = this.parentContainer; - - var indexes = []; - - while (parent) - { - // indexes.unshift([parent.getIndex(child), parent.name]); - indexes.unshift(parent.getIndex(child)); - - child = parent; - - if (!parent.parentContainer) - { - break; - } - else - { - parent = parent.parentContainer; - } - } - - // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']); - indexes.unshift(this.scene.sys.displayList.getIndex(child)); - - return indexes; - }, - - /** - * Destroys this Game Object removing it from the Display List and Update List and - * severing all ties to parent resources. - * - * Also removes itself from the Input Manager and Physics Manager if previously enabled. - * - * Use this to remove a Game Object from your game if you don't ever plan to use it again. - * As long as no reference to it exists within your own code it should become free for - * garbage collection by the browser. - * - * If you just want to temporarily disable an object then look at using the - * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. - * - * @method Phaser.GameObjects.GameObject#destroy - * @since 3.0.0 - */ - destroy: function () - { - // This Game Object had already been destroyed - if (!this.scene || this.ignoreDestroy) - { - return; - } - - if (this.preDestroy) - { - this.preDestroy.call(this); - } - - this.emit('destroy', this); - - var sys = this.scene.sys; - - sys.displayList.remove(this); - sys.updateList.remove(this); - - if (this.input) - { - sys.input.clear(this); - this.input = undefined; - } - - if (this.data) - { - this.data.destroy(); - - this.data = undefined; - } - - if (this.body) - { - this.body.destroy(); - this.body = undefined; - } - - // Tell the Scene to re-sort the children - sys.queueDepthSort(); - - this.active = false; - this.visible = false; - - this.scene = undefined; - - this.parentContainer = undefined; - - this.removeAllListeners(); - } - -}); - -/** - * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. - * - * @constant {integer} RENDER_MASK - * @memberOf Phaser.GameObjects.GameObject - * @default - */ -GameObject.RENDER_MASK = 15; - -module.exports = GameObject; - - /***/ }), /* 3 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A NOOP (No Operation) callback function. - * - * Used internally by Phaser when it's more expensive to determine if a callback exists - * than it is to just invoke an empty function. - * - * @function Phaser.Utils.NOOP - * @since 3.0.0 - */ -var NOOP = function () -{ - // NOOP -}; - -module.exports = NOOP; - - -/***/ }), -/* 4 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Source object -// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' -// The default value to use if the key doesn't exist - -/** - * [description] - * - * @function Phaser.Utils.Object.GetValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {*} [description] - */ -var GetValue = function (source, key, defaultValue) -{ - if (!source || typeof source === 'number') - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else if (key.indexOf('.')) - { - var keys = key.split('.'); - var parent = source; - var value = defaultValue; - - // Use for loop here so we can break early - for (var i = 0; i < keys.length; i++) - { - if (parent.hasOwnProperty(keys[i])) - { - // Yes it has a key property, let's carry on down - value = parent[keys[i]]; - - parent = parent[keys[i]]; - } - else - { - // Can't go any further, so reset to default - value = defaultValue; - break; - } - } - - return value; - } - else - { - return defaultValue; - } -}; - -module.exports = GetValue; - - -/***/ }), -/* 5 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * Defines a Point in 2D space, with an x and y component. - * - * @class Point - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - The x coordinate of this Point. - * @param {number} [y=x] - The y coordinate of this Point. - */ -var Point = new Class({ - - initialize: - - function Point (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - /** - * The x coordinate of this Point. - * - * @name Phaser.Geom.Point#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * The y coordinate of this Point. - * - * @name Phaser.Geom.Point#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - }, - - /** - * Set the x and y coordinates of the point to the given values. - * - * @method Phaser.Geom.Point#setTo - * @since 3.0.0 - * - * @param {number} [x=0] - The x coordinate of this Point. - * @param {number} [y=x] - The y coordinate of this Point. - * - * @return {Phaser.Geom.Point} This Point object. - */ - setTo: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - } - -}); - -module.exports = Point; - - -/***/ }), -/* 6 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -1143,11 +416,11 @@ var Class = __webpack_require__(0); * A two-component vector. * * @class Vector2 - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * - * @param {number} [x] - The x component. + * @param {number|Vector2Like} [x] - The x component, or an object with `x` and `y` properties. * @param {number} [y] - The y component. */ var Vector2 = new Class({ @@ -1282,8 +555,8 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#setToPolar * @since 3.0.0 * - * @param {float} azimuth - The angular coordinate, in radians. - * @param {float} [radius=1] - The radial coordinate (length). + * @param {number} azimuth - The angular coordinate, in radians. + * @param {number} [radius=1] - The radial coordinate (length). * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1473,7 +746,7 @@ var Vector2 = new Class({ }, /** - * Calculate the distance between this Vector, and the given Vector, squared. + * Calculate the distance between this Vector and the given Vector, squared. * * @method Phaser.Math.Vector2#distanceSq * @since 3.0.0 @@ -1688,7 +961,9 @@ var Vector2 = new Class({ /** * A static zero Vector2 for use by reference. * - * @method Phaser.Math.Vector2.ZERO + * @constant + * @name Phaser.Math.Vector2.ZERO + * @type {Vector2} * @since 3.1.0 */ Vector2.ZERO = new Vector2(); @@ -1696,6 +971,345 @@ Vector2.ZERO = new Vector2(); module.exports = Vector2; +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Source object +// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' +// The default value to use if the key doesn't exist + +/** + * Retrieves a value from an object. + * + * @function Phaser.Utils.Objects.GetValue + * @since 3.0.0 + * + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param {*} defaultValue - The value to return if the `key` isn't found in the `source` object. + * + * @return {*} The value of the requested key. + */ +var GetValue = function (source, key, defaultValue) +{ + if (!source || typeof source === 'number') + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else if (key.indexOf('.')) + { + var keys = key.split('.'); + var parent = source; + var value = defaultValue; + + // Use for loop here so we can break early + for (var i = 0; i < keys.length; i++) + { + if (parent.hasOwnProperty(keys[i])) + { + // Yes it has a key property, let's carry on down + value = parent[keys[i]]; + + parent = parent[keys[i]]; + } + else + { + // Can't go any further, so reset to default + value = defaultValue; + break; + } + } + + return value; + } + else + { + return defaultValue; + } +}; + +module.exports = GetValue; + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var PluginCache = __webpack_require__(15); + +/** + * @classdesc + * The Game Object Factory is a Scene plugin that allows you to quickly create many common + * types of Game Objects and have them automatically registered with the Scene. + * + * Game Objects directly register themselves with the Factory and inject their own creation + * methods into the class. + * + * @class GameObjectFactory + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. + */ +var GameObjectFactory = new Class({ + + initialize: + + function GameObjectFactory (scene) + { + /** + * The Scene to which this Game Object Factory belongs. + * + * @name Phaser.GameObjects.GameObjectFactory#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems. + * + * @name Phaser.GameObjects.GameObjectFactory#systems + * @type {Phaser.Scenes.Systems} + * @protected + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.GameObjectFactory#displayList + * @type {Phaser.GameObjects.DisplayList} + * @protected + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Update List. + * + * @name Phaser.GameObjects.GameObjectFactory#updateList; + * @type {Phaser.GameObjects.UpdateList} + * @protected + * @since 3.0.0 + */ + this.updateList; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.GameObjectFactory#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.displayList = this.systems.displayList; + this.updateList = this.systems.updateList; + + this.systems.events.once('destroy', this.destroy, 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.GameObjects.GameObjectFactory#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.systems.events.once('shutdown', this.shutdown, this); + }, + + /** + * Adds an existing Game Object to this Scene. + * + * If the Game Object renders, it will be added to the Display List. + * If it has a `preUpdate` method, it will be added to the Update List. + * + * @method Phaser.GameObjects.GameObjectFactory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The child to be added to this Scene. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was added. + */ + existing: function (child) + { + if (child.renderCanvas || child.renderWebGL) + { + this.displayList.add(child); + } + + if (child.preUpdate) + { + this.updateList.add(child); + } + + return child; + }, + + /** + * 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 () + { + this.systems.events.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.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; + } + +}); + +// Static method called directly by the Game Object factory functions + +GameObjectFactory.register = function (factoryType, factoryFunction) +{ + if (!GameObjectFactory.prototype.hasOwnProperty(factoryType)) + { + GameObjectFactory.prototype[factoryType] = factoryFunction; + } +}; + +PluginCache.register('GameObjectFactory', GameObjectFactory, 'add'); + +module.exports = GameObjectFactory; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * Defines a Point in 2D space, with an x and y component. + * + * @class Point + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of this Point. + * @param {number} [y=x] - The y coordinate of this Point. + */ +var Point = new Class({ + + initialize: + + function Point (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + /** + * The x coordinate of this Point. + * + * @name Phaser.Geom.Point#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y coordinate of this Point. + * + * @name Phaser.Geom.Point#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + }, + + /** + * Set the x and y coordinates of the point to the given values. + * + * @method Phaser.Geom.Point#setTo + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of this Point. + * @param {number} [y=x] - The y coordinate of this Point. + * + * @return {Phaser.Geom.Point} This Point object. + */ + setTo: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + } + +}); + +module.exports = Point; + + /***/ }), /* 7 */ /***/ (function(module, exports) { @@ -1775,7 +1389,7 @@ module.exports = FileTypesManager; * This is a slightly modified version of jQuery.isPlainObject. * A plain object is an object whose internal class property is [object Object]. * - * @function Phaser.Utils.Object.IsPlainObject + * @function Phaser.Utils.Objects.IsPlainObject * @since 3.0.0 * * @param {object} obj - The object to inspect. @@ -1821,6 +1435,640 @@ module.exports = IsPlainObject; /* 9 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(39); +var GetPoint = __webpack_require__(190); +var GetPoints = __webpack_require__(398); +var Line = __webpack_require__(54); +var Random = __webpack_require__(187); + +/** + * @classdesc + * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) + * + * @class Rectangle + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=0] - The Y coordinate of the top left corner of the Rectangle. + * @param {number} [width=0] - The width of the Rectangle. + * @param {number} [height=0] - The height of the Rectangle. + */ +var Rectangle = new Class({ + + initialize: + + function Rectangle (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * The X coordinate of the top left corner of the Rectangle. + * + * @name Phaser.Geom.Rectangle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The Y coordinate of the top left corner of the Rectangle. + * + * @name Phaser.Geom.Rectangle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. + * + * @name Phaser.Geom.Rectangle#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. + * + * @name Phaser.Geom.Rectangle#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * Checks if the given point is inside the Rectangle's bounds. + * + * @method Phaser.Geom.Rectangle#contains + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is within the Rectangle's bounds, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. + * + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. + * + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. + * + * @method Phaser.Geom.Rectangle#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {number} position - The normalized distance into the Rectangle's perimeter to return. + * @param {(Phaser.Geom.Point|object)} [output] - An object to update with the `x` and `y` coordinates of the point. + * + * @return {(Phaser.Geom.Point|object)} The updated `output` object, or a new Point if no `output` object was given. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. + * + * @method Phaser.Geom.Rectangle#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [output,$return] + * + * @param {integer} quantity - The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. + * @param {number} [stepRate] - If `quantity` is 0, determines the normalized distance between each returned point. + * @param {(array|Phaser.Geom.Point[])} [output] - An array to which to append the points. + * + * @return {(array|Phaser.Geom.Point[])} The modified `output` array, or a new array if none was provided. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a random point within the Rectangle's bounds. + * + * @method Phaser.Geom.Rectangle#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} [point] - The object in which to store the `x` and `y` coordinates of the point. + * + * @return {Phaser.Geom.Point} The updated `point`, or a new Point if none was provided. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets the position, width, and height of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setTo + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} y - The Y coordinate of the top left corner of the Rectangle. + * @param {number} width - The width of the Rectangle. + * @param {number} height - The height of the Rectangle. + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Resets the position, width, and height of the Rectangle to 0. + * + * @method Phaser.Geom.Rectangle#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setEmpty: function () + { + return this.setTo(0, 0, 0, 0); + }, + + /** + * Sets the position of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setPosition + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=x] - The Y coordinate of the top left corner of the Rectangle. + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Sets the width and height of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setSize + * @since 3.0.0 + * + * @param {number} width - The width to set the Rectangle to. + * @param {number} [height=width] - The height to set the Rectangle to. + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. + * + * @method Phaser.Geom.Rectangle#isEmpty + * @since 3.0.0 + * + * @return {boolean} `true` if the Rectangle is empty. A Rectangle object is empty if its width or height is less than or equal to 0. + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns a Line object that corresponds to the top of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineA + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.y, this.right, this.y); + + return line; + }, + + /** + * Returns a Line object that corresponds to the right of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.y, this.right, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the bottom of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineC + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.bottom, this.x, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the left of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineD + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. + */ + getLineD: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.bottom, this.x, this.y); + + return line; + }, + + /** + * The x coordinate of the left of the Rectangle. + * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. + * + * @name Phaser.Geom.Rectangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x; + }, + + set: function (value) + { + if (value >= this.right) + { + this.width = 0; + } + else + { + this.width = this.right - value; + } + + this.x = value; + } + + }, + + /** + * The sum of the x and width properties. + * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. + * + * @name Phaser.Geom.Rectangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this.width; + }, + + set: function (value) + { + if (value <= this.x) + { + this.width = 0; + } + else + { + this.width = value - this.x; + } + } + + }, + + /** + * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. + * However it does affect the height property, whereas changing the y value does not affect the height property. + * + * @name Phaser.Geom.Rectangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y; + }, + + set: function (value) + { + if (value >= this.bottom) + { + this.height = 0; + } + else + { + this.height = (this.bottom - value); + } + + this.y = value; + } + + }, + + /** + * The sum of the y and height properties. + * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. + * + * @name Phaser.Geom.Rectangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this.height; + }, + + set: function (value) + { + if (value <= this.y) + { + this.height = 0; + } + else + { + this.height = value - this.y; + } + } + + }, + + /** + * The x coordinate of the center of the Rectangle. + * + * @name Phaser.Geom.Rectangle#centerX + * @type {number} + * @since 3.0.0 + */ + centerX: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * The y coordinate of the center of the Rectangle. + * + * @name Phaser.Geom.Rectangle#centerY + * @type {number} + * @since 3.0.0 + */ + centerY: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + + } + +}); + +module.exports = Rectangle; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL.Utils + * @since 3.0.0 + */ +module.exports = { + + /** + * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 + * + * @function Phaser.Renderer.WebGL.Utils.getTintFromFloats + * @since 3.0.0 + * + * @param {number} r - Red component in a range from 0.0 to 1.0 + * @param {number} g - [description] + * @param {number} b - [description] + * @param {number} a - Alpha component in a range from 0.0 to 1.0 + * + * @return {number} [description] + */ + getTintFromFloats: function (r, g, b, a) + { + var ur = ((r * 255.0)|0) & 0xFF; + var ug = ((g * 255.0)|0) & 0xFF; + var ub = ((b * 255.0)|0) & 0xFF; + var ua = ((a * 255.0)|0) & 0xFF; + + return ((ua << 24) | (ur << 16) | (ug << 8) | ub) >>> 0; + }, + + /** + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 + * + * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha + * @since 3.0.0 + * + * @param {number} rgb - Uint24 representing RGB components + * @param {number} a - Float32 representing Alpha component + * + * @return {number} Packed RGBA as Uint32 + */ + getTintAppendFloatAlpha: function (rgb, a) + { + var ua = ((a * 255.0)|0) & 0xFF; + return ((ua << 24) | rgb) >>> 0; + }, + + /** + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a + * swizzled Uint32 + * + * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlphaAndSwap + * @since 3.0.0 + * + * @param {number} rgb - Uint24 representing RGB components + * @param {number} a - Float32 representing Alpha component + * + * @return {number} Packed RGBA as Uint32 + */ + getTintAppendFloatAlphaAndSwap: function (rgb, a) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + var ua = ((a * 255.0)|0) & 0xFF; + + return ((ua << 24) | (ub << 16) | (ug << 8) | ur) >>> 0; + }, + + /** + * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 + * + * @function Phaser.Renderer.WebGL.Utils.getFloatsFromUintRGB + * @since 3.0.0 + * + * @param {number} rgb - RGB packed as a Uint24 + * + * @return {array} Array of floats representing each component as a float + */ + getFloatsFromUintRGB: function (rgb) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + return [ ur / 255.0, ug / 255.0, ub / 255.0 ]; + }, + + /** + * Counts how many attributes of 32 bits a vertex has + * + * @function Phaser.Renderer.WebGL.Utils.getComponentCount + * @since 3.0.0 + * + * @param {array} attributes - Array of attributes + * @param {WebGLRenderingContext} glContext - WebGLContext used for check types + * + * @return {number} Count of 32 bit attributes in vertex + */ + getComponentCount: function (attributes, glContext) + { + var count = 0; + + for (var index = 0; index < attributes.length; ++index) + { + var element = attributes[index]; + + if (element.type === glContext.FLOAT) + { + count += element.size; + } + else + { + count += 1; // We'll force any other type to be 32 bit. for now + } + } + + return count; + } + +}; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + "use strict"; @@ -2161,7 +2409,7 @@ if (true) { /***/ }), -/* 10 */ +/* 12 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -2203,7 +2451,7 @@ var GetValue = __webpack_require__(4); /** * [description] * - * @function Phaser.Utils.Object.GetAdvancedValue + * @function Phaser.Utils.Objects.GetAdvancedValue * @since 3.0.0 * * @param {object} source - [description] @@ -2246,376 +2494,6 @@ var GetAdvancedValue = function (source, key, defaultValue) module.exports = GetAdvancedValue; -/***/ }), -/* 11 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * The Game Object Factory is a Scene plugin that allows you to quickly create many common - * types of Game Objects and have them automatically registered with the Scene. - * - * Game Objects directly register themselves with the Factory and inject their own creation - * methods into the class. - * - * @class GameObjectFactory - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. - */ -var GameObjectFactory = new Class({ - - initialize: - - function GameObjectFactory (scene) - { - /** - * The Scene to which this Game Object Factory belongs. - * - * @name Phaser.GameObjects.GameObjectFactory#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene.Systems. - * - * @name Phaser.GameObjects.GameObjectFactory#systems - * @type {Phaser.Scenes.Systems} - * @protected - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * A reference to the Scene Display List. - * - * @name Phaser.GameObjects.GameObjectFactory#displayList - * @type {Phaser.GameObjects.DisplayList} - * @protected - * @since 3.0.0 - */ - this.displayList; - - /** - * A reference to the Scene Update List. - * - * @name Phaser.GameObjects.GameObjectFactory#updateList; - * @type {Phaser.GameObjects.UpdateList} - * @protected - * @since 3.0.0 - */ - this.updateList; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.GameObjects.GameObjectFactory#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.displayList = this.systems.displayList; - this.updateList = this.systems.updateList; - - this.systems.events.once('destroy', this.destroy, 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.GameObjects.GameObjectFactory#start - * @private - * @since 3.5.0 - */ - start: function () - { - this.systems.events.once('shutdown', this.shutdown, this); - }, - - /** - * Adds an existing Game Object to this Scene. - * - * If the Game Object renders, it will be added to the Display List. - * If it has a `preUpdate` method, it will be added to the Update List. - * - * @method Phaser.GameObjects.GameObjectFactory#existing - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - The child to be added to this Scene. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was added. - */ - existing: function (child) - { - if (child.renderCanvas || child.renderWebGL) - { - this.displayList.add(child); - } - - if (child.preUpdate) - { - this.updateList.add(child); - } - - return child; - }, - - /** - * 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 () - { - this.systems.events.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.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; - } - -}); - -// Static method called directly by the Game Object factory functions - -GameObjectFactory.register = function (factoryType, factoryFunction) -{ - if (!GameObjectFactory.prototype.hasOwnProperty(factoryType)) - { - GameObjectFactory.prototype[factoryType] = factoryFunction; - } -}; - -PluginCache.register('GameObjectFactory', GameObjectFactory, 'add'); - -module.exports = GameObjectFactory; - - -/***/ }), -/* 12 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Contains the plugins that Phaser uses globally and locally. -// These are the source objects, not instantiated. -var corePlugins = {}; - -// Contains the plugins that the dev has loaded into their game -// These are the source objects, not instantiated. -var customPlugins = {}; - -/** - * @typedef {object} CorePluginContainer - * - * @property {string} key - The unique name of this plugin in the core plugin cache. - * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. - * @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used. - * @property {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? - */ - -/** - * @typedef {object} CustomPluginContainer - * - * @property {string} key - The unique name of this plugin in the custom plugin cache. - * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. - */ - -var PluginCache = {}; - -/** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * - * @method Phaser.Plugins.PluginCache.register - * @since 3.8.0 - * - * @param {string} key - A reference used to get this plugin from the plugin cache. - * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. - * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. - * @param {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? - */ -PluginCache.register = function (key, plugin, mapping, custom) -{ - if (custom === undefined) { custom = false; } - - corePlugins[key] = { plugin: plugin, mapping: mapping, custom: custom }; -}; - -/** - * Stores a custom plugin in the global plugin cache. - * The key must be unique, within the scope of the cache. - * - * @method Phaser.Plugins.PluginCache.registerCustom - * @since 3.8.0 - * - * @param {string} key - A reference used to get this plugin from the plugin cache. - * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. - * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. - */ -PluginCache.registerCustom = function (key, plugin, mapping) -{ - customPlugins[key] = { plugin: plugin, mapping: mapping }; -}; - -/** - * Checks if the given key is already being used in the core plugin cache. - * - * @method Phaser.Plugins.PluginCache.hasCore - * @since 3.8.0 - * - * @param {string} key - The key to check for. - * - * @return {boolean} `true` if the key is already in use in the core cache, otherwise `false`. - */ -PluginCache.hasCore = function (key) -{ - return corePlugins.hasOwnProperty(key); -}; - -/** - * Checks if the given key is already being used in the custom plugin cache. - * - * @method Phaser.Plugins.PluginCache.hasCustom - * @since 3.8.0 - * - * @param {string} key - The key to check for. - * - * @return {boolean} `true` if the key is already in use in the custom cache, otherwise `false`. - */ -PluginCache.hasCustom = function (key) -{ - return customPlugins.hasOwnProperty(key); -}; - -/** - * Returns the core plugin object from the cache based on the given key. - * - * @method Phaser.Plugins.PluginCache.getCore - * @since 3.8.0 - * - * @param {string} key - The key of the core plugin to get. - * - * @return {CorePluginContainer} The core plugin object. - */ -PluginCache.getCore = function (key) -{ - return corePlugins[key]; -}; - -/** - * Returns the custom plugin object from the cache based on the given key. - * - * @method Phaser.Plugins.PluginCache.getCustom - * @since 3.8.0 - * - * @param {string} key - The key of the custom plugin to get. - * - * @return {CustomPluginContainer} The custom plugin object. - */ -PluginCache.getCustom = function (key) -{ - return customPlugins[key]; -}; - -/** - * Returns an object from the custom cache based on the given key that can be instantiated. - * - * @method Phaser.Plugins.PluginCache.getCustomClass - * @since 3.8.0 - * - * @param {string} key - The key of the custom plugin to get. - * - * @return {function} The custom plugin object. - */ -PluginCache.getCustomClass = function (key) -{ - return (customPlugins.hasOwnProperty(key)) ? customPlugins[key].plugin : null; -}; - -/** - * Removes a core plugin based on the given key. - * - * @method Phaser.Plugins.PluginCache.remove - * @since 3.8.0 - * - * @param {string} key - The key of the core plugin to remove. - */ -PluginCache.remove = function (key) -{ - if (corePlugins.hasOwnProperty(key)) - { - delete corePlugins[key]; - } -}; - -/** - * Removes a custom plugin based on the given key. - * - * @method Phaser.Plugins.PluginCache.removeCustom - * @since 3.8.0 - * - * @param {string} key - The key of the custom plugin to remove. - */ -PluginCache.removeCustom = function (key) -{ - if (customPlugins.hasOwnProperty(key)) - { - delete customPlugins[key]; - } -}; - -module.exports = PluginCache; - - /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { @@ -2627,7 +2505,7 @@ module.exports = PluginCache; */ var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); +var PluginCache = __webpack_require__(15); /** * @classdesc @@ -2639,7 +2517,7 @@ var PluginCache = __webpack_require__(12); * methods into the class. * * @class GameObjectCreator - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -2785,490 +2663,40 @@ module.exports = GameObjectCreator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Contains = __webpack_require__(31); -var GetPoint = __webpack_require__(135); -var GetPoints = __webpack_require__(294); -var Line = __webpack_require__(96); -var Random = __webpack_require__(154); - /** - * @classdesc - * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) - * - * @class Rectangle - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width=0] - [description] - * @param {number} [height=0] - [description] + * @namespace Phaser.GameObjects.Components */ -var Rectangle = new Class({ - initialize: +module.exports = { - function Rectangle (x, y, width, height) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = 0; } - if (height === undefined) { height = 0; } + Alpha: __webpack_require__(401), + Animation: __webpack_require__(427), + BlendMode: __webpack_require__(400), + ComputedSize: __webpack_require__(1045), + Crop: __webpack_require__(1044), + Depth: __webpack_require__(399), + Flip: __webpack_require__(1043), + GetBounds: __webpack_require__(1042), + Mask: __webpack_require__(395), + Origin: __webpack_require__(1041), + Pipeline: __webpack_require__(186), + ScaleMode: __webpack_require__(1040), + ScrollFactor: __webpack_require__(392), + Size: __webpack_require__(1039), + Texture: __webpack_require__(1038), + TextureCrop: __webpack_require__(1037), + Tint: __webpack_require__(1036), + ToJSON: __webpack_require__(391), + Transform: __webpack_require__(390), + TransformMatrix: __webpack_require__(38), + Visible: __webpack_require__(389) - /** - * [description] - * - * @name Phaser.Geom.Rectangle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#width - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.width = width; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#height - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.height = height; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#contains - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [output,$return] - * - * @param {integer} quantity - [description] - * @param {number} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getRandomPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} [point] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setTo: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setEmpty: function () - { - return this.setTo(0, 0, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} [height=width] - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#isEmpty - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isEmpty: function () - { - return (this.width <= 0 || this.height <= 0); - }, - - /** - * Returns a Line object that corresponds to the top of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineA - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. - */ - getLineA: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.x, this.y, this.right, this.y); - - return line; - }, - - /** - * Returns a Line object that corresponds to the right of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineB - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. - */ - getLineB: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.right, this.y, this.right, this.bottom); - - return line; - }, - - /** - * Returns a Line object that corresponds to the bottom of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineC - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. - */ - getLineC: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.right, this.bottom, this.x, this.bottom); - - return line; - }, - - /** - * Returns a Line object that corresponds to the left of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineD - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. - */ - getLineD: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.x, this.bottom, this.x, this.y); - - return line; - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.x; - }, - - set: function (value) - { - if (value >= this.right) - { - this.width = 0; - } - else - { - this.width = this.right - value; - } - - this.x = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.x + this.width; - }, - - set: function (value) - { - if (value <= this.x) - { - this.width = 0; - } - else - { - this.width = value - this.x; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y; - }, - - set: function (value) - { - if (value >= this.bottom) - { - this.height = 0; - } - else - { - this.height = (this.bottom - value); - } - - this.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + this.height; - }, - - set: function (value) - { - if (value <= this.y) - { - this.height = 0; - } - else - { - this.height = value - this.y; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerX - * @type {number} - * @since 3.0.0 - */ - centerX: { - - get: function () - { - return this.x + (this.width / 2); - }, - - set: function (value) - { - this.x = value - (this.width / 2); - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerY - * @type {number} - * @since 3.0.0 - */ - centerY: { - - get: function () - { - return this.y + (this.height / 2); - }, - - set: function (value) - { - this.y = value - (this.height / 2); - } - - } - -}); - -module.exports = Rectangle; +}; /***/ }), /* 15 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -3276,35 +2704,216 @@ module.exports = Rectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Contains the plugins that Phaser uses globally and locally. +// These are the source objects, not instantiated. +var corePlugins = {}; + +// Contains the plugins that the dev has loaded into their game +// These are the source objects, not instantiated. +var customPlugins = {}; + /** - * @namespace Phaser.GameObjects.Components + * @typedef {object} CorePluginContainer + * + * @property {string} key - The unique name of this plugin in the core plugin cache. + * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. + * @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @property {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? */ -module.exports = { +/** + * @typedef {object} CustomPluginContainer + * + * @property {string} key - The unique name of this plugin in the custom plugin cache. + * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. + */ - Alpha: __webpack_require__(587), - Animation: __webpack_require__(302), - BlendMode: __webpack_require__(586), - ComputedSize: __webpack_require__(585), - Depth: __webpack_require__(584), - Flip: __webpack_require__(583), - GetBounds: __webpack_require__(582), - Mask: __webpack_require__(581), - MatrixStack: __webpack_require__(580), - Origin: __webpack_require__(579), - Pipeline: __webpack_require__(291), - ScaleMode: __webpack_require__(578), - ScrollFactor: __webpack_require__(577), - Size: __webpack_require__(576), - Texture: __webpack_require__(575), - Tint: __webpack_require__(574), - ToJSON: __webpack_require__(573), - Transform: __webpack_require__(572), - TransformMatrix: __webpack_require__(64), - Visible: __webpack_require__(571) +var PluginCache = {}; +/** + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + * + * @method Phaser.Plugins.PluginCache.register + * @since 3.8.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @param {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? + */ +PluginCache.register = function (key, plugin, mapping, custom) +{ + if (custom === undefined) { custom = false; } + + corePlugins[key] = { plugin: plugin, mapping: mapping, custom: custom }; }; +/** + * Stores a custom plugin in the global plugin cache. + * The key must be unique, within the scope of the cache. + * + * @method Phaser.Plugins.PluginCache.registerCustom + * @since 3.8.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @param {?any} data - A value to be passed to the plugin's `init` method. + */ +PluginCache.registerCustom = function (key, plugin, mapping, data) +{ + customPlugins[key] = { plugin: plugin, mapping: mapping, data: data }; +}; + +/** + * Checks if the given key is already being used in the core plugin cache. + * + * @method Phaser.Plugins.PluginCache.hasCore + * @since 3.8.0 + * + * @param {string} key - The key to check for. + * + * @return {boolean} `true` if the key is already in use in the core cache, otherwise `false`. + */ +PluginCache.hasCore = function (key) +{ + return corePlugins.hasOwnProperty(key); +}; + +/** + * Checks if the given key is already being used in the custom plugin cache. + * + * @method Phaser.Plugins.PluginCache.hasCustom + * @since 3.8.0 + * + * @param {string} key - The key to check for. + * + * @return {boolean} `true` if the key is already in use in the custom cache, otherwise `false`. + */ +PluginCache.hasCustom = function (key) +{ + return customPlugins.hasOwnProperty(key); +}; + +/** + * Returns the core plugin object from the cache based on the given key. + * + * @method Phaser.Plugins.PluginCache.getCore + * @since 3.8.0 + * + * @param {string} key - The key of the core plugin to get. + * + * @return {CorePluginContainer} The core plugin object. + */ +PluginCache.getCore = function (key) +{ + return corePlugins[key]; +}; + +/** + * Returns the custom plugin object from the cache based on the given key. + * + * @method Phaser.Plugins.PluginCache.getCustom + * @since 3.8.0 + * + * @param {string} key - The key of the custom plugin to get. + * + * @return {CustomPluginContainer} The custom plugin object. + */ +PluginCache.getCustom = function (key) +{ + return customPlugins[key]; +}; + +/** + * Returns an object from the custom cache based on the given key that can be instantiated. + * + * @method Phaser.Plugins.PluginCache.getCustomClass + * @since 3.8.0 + * + * @param {string} key - The key of the custom plugin to get. + * + * @return {function} The custom plugin object. + */ +PluginCache.getCustomClass = function (key) +{ + return (customPlugins.hasOwnProperty(key)) ? customPlugins[key].plugin : null; +}; + +/** + * Removes a core plugin based on the given key. + * + * @method Phaser.Plugins.PluginCache.remove + * @since 3.8.0 + * + * @param {string} key - The key of the core plugin to remove. + */ +PluginCache.remove = function (key) +{ + if (corePlugins.hasOwnProperty(key)) + { + delete corePlugins[key]; + } +}; + +/** + * Removes a custom plugin based on the given key. + * + * @method Phaser.Plugins.PluginCache.removeCustom + * @since 3.8.0 + * + * @param {string} key - The key of the custom plugin to remove. + */ +PluginCache.removeCustom = function (key) +{ + if (customPlugins.hasOwnProperty(key)) + { + delete customPlugins[key]; + } +}; + +/** + * Removes all Core Plugins. + * + * This includes all of the internal system plugins that Phaser needs, like the Input Plugin and Loader Plugin. + * So be sure you only call this if you do not wish to run Phaser again. + * + * @method Phaser.Plugins.PluginCache.destroyCorePlugins + * @since 3.12.0 + */ +PluginCache.destroyCorePlugins = function () +{ + for (var key in corePlugins) + { + if (corePlugins.hasOwnProperty(key)) + { + delete corePlugins[key]; + } + } +}; + +/** + * Removes all Custom Plugins. + * + * @method Phaser.Plugins.PluginCache.destroyCustomPlugins + * @since 3.12.0 + */ +PluginCache.destroyCustomPlugins = function () +{ + for (var key in customPlugins) + { + if (customPlugins.hasOwnProperty(key)) + { + delete customPlugins[key]; + } + } +}; + +module.exports = PluginCache; + /***/ }), /* 16 */ @@ -3316,7 +2925,7 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RND = __webpack_require__(297); +var RND = __webpack_require__(404); var MATH_CONST = { @@ -3389,93 +2998,86 @@ module.exports = MATH_CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var IsPlainObject = __webpack_require__(8); - -// @param {boolean} deep - Perform a deep copy? -// @param {object} target - The target object to copy to. -// @return {object} The extended object. +var GetFastValue = __webpack_require__(2); /** - * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * @typedef {object} GetTilesWithinFilteringOptions * - * @function Phaser.Utils.Object.Extend + * @property {boolean} [isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @property {boolean} [isColliding=false] - If true, only return tiles that collide on at least one side. + * @property {boolean} [hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + */ + +/** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithin + * @private * @since 3.0.0 * - * @return {object} [description] + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {object} GetTilesWithinFilteringOptions - Optional filters to apply when getting the tiles. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. */ -var Extend = function () +var GetTilesWithin = function (tileX, tileY, width, height, filteringOptions, layer) { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; + if (tileX === undefined) { tileX = 0; } + if (tileY === undefined) { tileY = 0; } + if (width === undefined) { width = layer.width; } + if (height === undefined) { height = layer.height; } - // Handle a deep copy situation - if (typeof target === 'boolean') + var isNotEmpty = GetFastValue(filteringOptions, 'isNotEmpty', false); + var isColliding = GetFastValue(filteringOptions, 'isColliding', false); + var hasInterestingFace = GetFastValue(filteringOptions, 'hasInterestingFace', false); + + // Clip x, y to top left of map, while shrinking width/height to match. + if (tileX < 0) { - deep = target; - target = arguments[1] || {}; - - // skip the boolean and the target - i = 2; + width += tileX; + tileX = 0; + } + if (tileY < 0) + { + height += tileY; + tileY = 0; } - // extend Phaser if only one argument is passed - if (length === i) + // Clip width and height to bottom right of map. + if (tileX + width > layer.width) { - target = this; - --i; + width = Math.max(layer.width - tileX, 0); + } + if (tileY + height > layer.height) + { + height = Math.max(layer.height - tileY, 0); } - for (; i < length; i++) + var results = []; + + for (var ty = tileY; ty < tileY + height; ty++) { - // Only deal with non-null/undefined values - if ((options = arguments[i]) != null) + for (var tx = tileX; tx < tileX + width; tx++) { - // Extend the base object - for (name in options) + var tile = layer.data[ty][tx]; + if (tile !== null) { - src = target[name]; - copy = options[name]; - - // Prevent never-ending loop - if (target === copy) - { - continue; - } - - // Recurse if we're merging plain objects or arrays - if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) - { - if (copyIsArray) - { - copyIsArray = false; - clone = src && Array.isArray(src) ? src : []; - } - else - { - clone = src && IsPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[name] = Extend(deep, clone, copy); - - // Don't bring in undefined values - } - else if (copy !== undefined) - { - target[name] = copy; - } + if (isNotEmpty && tile.index === -1) { continue; } + if (isColliding && !tile.collides) { continue; } + if (hasInterestingFace && !tile.hasInterestingFace) { continue; } + results.push(tile); } } } - // Return the modified object - return target; + return results; }; -module.exports = Extend; +module.exports = GetTilesWithin; /***/ }), @@ -3634,6 +3236,704 @@ module.exports = FILE_CONST; /* 19 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ComponentsToJSON = __webpack_require__(391); +var DataManager = __webpack_require__(123); +var EventEmitter = __webpack_require__(11); + +/** + * @classdesc + * The base class that all Game Objects extend. + * You don't create GameObjects directly and they cannot be added to the display list. + * Instead, use them as the base for your own custom classes. + * + * @class GameObject + * @memberof Phaser.GameObjects + * @extends Phaser.Events.EventEmitter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`. + */ +var GameObject = new Class({ + + Extends: EventEmitter, + + initialize: + + function GameObject (scene, type) + { + EventEmitter.call(this); + + /** + * The Scene to which this Game Object belongs. + * Game Objects can only belong to one Scene. + * + * @name Phaser.GameObjects.GameObject#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A textual representation of this Game Object, i.e. `sprite`. + * Used internally by Phaser but is available for your own custom classes to populate. + * + * @name Phaser.GameObjects.GameObject#type + * @type {string} + * @since 3.0.0 + */ + this.type = type; + + /** + * The parent Container of this Game Object, if it has one. + * + * @name Phaser.GameObjects.GameObject#parentContainer + * @type {Phaser.GameObjects.Container} + * @since 3.4.0 + */ + this.parentContainer = null; + + /** + * The name of this Game Object. + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.GameObject#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The active state of this Game Object. + * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. + * An active object is one which is having its logic and internal systems updated. + * + * @name Phaser.GameObjects.GameObject#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * The Tab Index of the Game Object. + * Reserved for future use by plugins and the Input Manager. + * + * @name Phaser.GameObjects.GameObject#tabIndex + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.tabIndex = -1; + + /** + * A Data Manager. + * It allows you to store, query and get key/value paired information specific to this Game Object. + * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. + * + * @name Phaser.GameObjects.GameObject#data + * @type {Phaser.Data.DataManager} + * @default null + * @since 3.0.0 + */ + this.data = null; + + /** + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. + * + * @name Phaser.GameObjects.GameObject#renderFlags + * @type {integer} + * @default 15 + * @since 3.0.0 + */ + this.renderFlags = 15; + + /** + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + * + * @example + * this.cameraFilter |= camera.id + * + * @name Phaser.GameObjects.GameObject#cameraFilter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cameraFilter = 0; + + /** + * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. + * Not usually set directly. Instead call `GameObject.setInteractive()`. + * + * @name Phaser.GameObjects.GameObject#input + * @type {?Phaser.Input.InteractiveObject} + * @default null + * @since 3.0.0 + */ + this.input = null; + + /** + * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. + * + * @name Phaser.GameObjects.GameObject#body + * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} + * @default null + * @since 3.0.0 + */ + 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 + scene.sys.queueDepthSort(); + }, + + /** + * Sets the `active` property of this Game Object and returns this Game Object for further chaining. + * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. + * + * @method Phaser.GameObjects.GameObject#setActive + * @since 3.0.0 + * + * @param {boolean} value - True if this Game Object should be set as active, false if not. + * + * @return {this} This GameObject. + */ + setActive: function (value) + { + this.active = value; + + return this; + }, + + /** + * Sets the `name` property of this Game Object and returns this Game Object for further chaining. + * The `name` property is not populated by Phaser and is presented for your own use. + * + * @method Phaser.GameObjects.GameObject#setName + * @since 3.0.0 + * + * @param {string} value - The name to be given to this Game Object. + * + * @return {this} This GameObject. + */ + setName: function (value) + { + this.name = value; + + return this; + }, + + /** + * Adds a Data Manager component to this Game Object. + * + * @method Phaser.GameObjects.GameObject#setDataEnabled + * @since 3.0.0 + * @see Phaser.Data.DataManager + * + * @return {this} This GameObject. + */ + setDataEnabled: function () + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this; + }, + + /** + * Allows you to store a key value pair within this Game Objects Data Manager. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * sprite.setData('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `getData`: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * sprite.data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.GameObjects.GameObject#setData + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {this} This GameObject. + */ + setData: function (key, value) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + this.data.set(key, value); + + return this; + }, + + /** + * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * sprite.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * sprite.getData([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.GameObjects.GameObject#getData + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + getData: function (key) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this.data.get(key); + }, + + /** + * Pass this Game Object to the Input Manager to enable it for Input. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * + * @method Phaser.GameObjects.GameObject#setInteractive + * @since 3.0.0 + * + * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? + * + * @return {this} This GameObject. + */ + setInteractive: function (shape, callback, dropZone) + { + this.scene.sys.input.enable(this, shape, callback, dropZone); + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will disable it. + * + * An object that is disabled for input stops processing or being considered for + * input events, but can be turned back on again at any time by simply calling + * `setInteractive()` with no arguments provided. + * + * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. + * + * @method Phaser.GameObjects.GameObject#disableInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + disableInteractive: function () + { + if (this.input) + { + this.input.enabled = false; + } + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. + * + * The Interactive Object that was assigned to this Game Object will be destroyed, + * removed from the Input Manager and cleared from this Game Object. + * + * If you wish to re-enable this Game Object at a later date you will need to + * re-create its InteractiveObject by calling `setInteractive` again. + * + * If you wish to only temporarily stop an object from receiving input then use + * `disableInteractive` instead, as that toggles the interactive state, where-as + * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) + * + * @method Phaser.GameObjects.GameObject#removeInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + removeInteractive: function () + { + this.scene.sys.input.clear(this); + + this.input = undefined; + + return this; + }, + + /** + * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. + * + * @method Phaser.GameObjects.GameObject#update + * @since 3.0.0 + * + * @param {...*} [args] - args + */ + update: function () + { + }, + + /** + * Returns a JSON representation of the Game Object. + * + * @method Phaser.GameObjects.GameObject#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + return ComponentsToJSON(this); + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * + * @method Phaser.GameObjects.GameObject#willRender + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * + * @return {boolean} True if the Game Object should be rendered, otherwise false. + */ + willRender: function (camera) + { + return !(GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter > 0 && (this.cameraFilter & camera.id))); + }, + + /** + * Returns an array containing the display list index of either this Game Object, or if it has one, + * its parent Container. It then iterates up through all of the parent containers until it hits the + * root of the display list (which is index 0 in the returned array). + * + * Used internally by the InputPlugin but also useful if you wish to find out the display depth of + * this Game Object and all of its ancestors. + * + * @method Phaser.GameObjects.GameObject#getIndexList + * @since 3.4.0 + * + * @return {integer[]} An array of display list position indexes. + */ + getIndexList: function () + { + // eslint-disable-next-line consistent-this + var child = this; + var parent = this.parentContainer; + + var indexes = []; + + while (parent) + { + // indexes.unshift([parent.getIndex(child), parent.name]); + indexes.unshift(parent.getIndex(child)); + + child = parent; + + if (!parent.parentContainer) + { + break; + } + else + { + parent = parent.parentContainer; + } + } + + // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']); + indexes.unshift(this.scene.sys.displayList.getIndex(child)); + + return indexes; + }, + + /** + * Destroys this Game Object removing it from the Display List and Update List and + * severing all ties to parent resources. + * + * Also removes itself from the Input Manager and Physics Manager if previously enabled. + * + * Use this to remove a Game Object from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * + * @method Phaser.GameObjects.GameObject#destroy + * @since 3.0.0 + * + * @param {boolean} [fromScene=false] - Is this Game Object being destroyed as the result of a Scene shutdown? + */ + destroy: function (fromScene) + { + if (fromScene === undefined) { fromScene = false; } + + // This Game Object has already been destroyed + if (!this.scene || this.ignoreDestroy) + { + return; + } + + if (this.preDestroy) + { + this.preDestroy.call(this); + } + + this.emit('destroy', this); + + var sys = this.scene.sys; + + if (!fromScene) + { + sys.displayList.remove(this); + sys.updateList.remove(this); + } + + if (this.input) + { + sys.input.clear(this); + this.input = undefined; + } + + if (this.data) + { + this.data.destroy(); + + this.data = undefined; + } + + if (this.body) + { + this.body.destroy(); + this.body = undefined; + } + + // Tell the Scene to re-sort the children + if (!fromScene) + { + sys.queueDepthSort(); + } + + this.active = false; + this.visible = false; + + this.scene = undefined; + + this.parentContainer = undefined; + + this.removeAllListeners(); + } + +}); + +/** + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + * + * @constant {integer} RENDER_MASK + * @memberof Phaser.GameObjects.GameObject + * @default + */ +GameObject.RENDER_MASK = 15; + +module.exports = GameObject; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsPlainObject = __webpack_require__(8); + +// @param {boolean} deep - Perform a deep copy? +// @param {object} target - The target object to copy to. +// @return {object} The extended object. + +/** + * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * + * @function Phaser.Utils.Objects.Extend + * @since 3.0.0 + * + * @return {object} [description] + */ +var Extend = function () +{ + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') + { + deep = target; + target = arguments[1] || {}; + + // skip the boolean and the target + i = 2; + } + + // extend Phaser if only one argument is passed + if (length === i) + { + target = this; + --i; + } + + for (; i < length; i++) + { + // Only deal with non-null/undefined values + if ((options = arguments[i]) != null) + { + // Extend the base object + for (name in options) + { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target === copy) + { + continue; + } + + // Recurse if we're merging plain objects or arrays + if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) + { + if (copyIsArray) + { + copyIsArray = false; + clone = src && Array.isArray(src) ? src : []; + } + else + { + clone = src && IsPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = Extend(deep, clone, copy); + + // Don't bring in undefined values + } + else if (copy !== undefined) + { + target[name] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +module.exports = Extend; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -3642,11 +3942,11 @@ module.exports = FILE_CONST; var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var GetFastValue = __webpack_require__(1); -var GetURL = __webpack_require__(108); -var MergeXHRSettings = __webpack_require__(107); -var XHRLoader = __webpack_require__(169); -var XHRSettings = __webpack_require__(75); +var GetFastValue = __webpack_require__(2); +var GetURL = __webpack_require__(141); +var MergeXHRSettings = __webpack_require__(140); +var XHRLoader = __webpack_require__(254); +var XHRSettings = __webpack_require__(105); /** * @typedef {object} FileConfig @@ -3667,7 +3967,7 @@ var XHRSettings = __webpack_require__(75); * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. * * @class File - * @memberOf Phaser.Loader + * @memberof Phaser.Loader * @constructor * @since 3.0.0 * @@ -3816,7 +4116,7 @@ var File = new Class({ * Only set if loading via XHR. * * @name Phaser.Loader.File#percentComplete - * @type {float} + * @type {number} * @default -1 * @since 3.0.0 */ @@ -4153,7 +4453,7 @@ var File = new Class({ var type = this.type; this.loader.emit('filecomplete', key, type, data); - this.loader.emit('filecomplete_' + type + '_' + key, key, type, data); + this.loader.emit('filecomplete-' + type + '-' + key, key, type, data); this.loader.flagForRemoval(this); }, @@ -4228,8 +4528,8 @@ module.exports = File; /***/ }), -/* 20 */ -/***/ (function(module, exports, __webpack_require__) { +/* 22 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -4238,136 +4538,83 @@ module.exports = File; */ /** - * Global consts. + * Takes a reference to the Canvas Renderer, a Canvas Rendering Context, a Game Object, a Camera and a parent matrix + * and then performs the following steps: * - * @ignore + * 1) Checks the alpha of the source combined with the Camera alpha. If 0 or less it aborts. + * 2) Takes the Camera and Game Object matrix and multiplies them, combined with the parent matrix if given. + * 3) Sets the blend mode of the context to be that used by the Game Object. + * 4) Sets the alpha value of the context to be that used by the Game Object combined with the Camera. + * 5) Saves the context state. + * 6) Sets the final matrix values into the context via setTransform. + * + * This function is only meant to be used internally. Most of the Canvas Renderer classes use it. + * + * @function Phaser.Renderer.Canvas.SetTransform + * @since 3.12.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {CanvasRenderingContext2D} ctx - The canvas context to set the transform on. + * @param {Phaser.GameObjects.GameObject} src - The Game Object being rendered. Can be any type that extends the base class. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A parent transform matrix to apply to the Game Object before rendering. + * + * @return {boolean} `true` if the Game Object context was set, otherwise `false`. */ +var SetTransform = function (renderer, ctx, src, camera, parentMatrix) +{ + var alpha = camera.alpha * src.alpha; -var CONST = { + if (alpha <= 0) + { + // Nothing to see, so don't waste time calculating stuff + return false; + } - /** - * Phaser Release Version - * - * @name Phaser.VERSION - * @readOnly - * @type {string} - * @since 3.0.0 - */ - VERSION: '3.10.1', + var camMatrix = renderer._tempMatrix1.copyFromArray(camera.matrix.matrix); + var gameObjectMatrix = renderer._tempMatrix2.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + var calcMatrix = renderer._tempMatrix3; - BlendModes: __webpack_require__(51), + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); - ScaleModes: __webpack_require__(59), + // Undo the camera scroll + gameObjectMatrix.e = src.x; + gameObjectMatrix.f = src.y; - /** - * AUTO Detect Renderer. - * - * @name Phaser.AUTO - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - AUTO: 0, + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(gameObjectMatrix, calcMatrix); + } + else + { + gameObjectMatrix.e -= camera.scrollX * src.scrollFactorX; + gameObjectMatrix.f -= camera.scrollY * src.scrollFactorY; - /** - * Canvas Renderer. - * - * @name Phaser.CANVAS - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - CANVAS: 1, + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(gameObjectMatrix, calcMatrix); + } - /** - * WebGL Renderer. - * - * @name Phaser.WEBGL - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - WEBGL: 2, + // Blend Mode + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - /** - * Headless Renderer. - * - * @name Phaser.HEADLESS - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - HEADLESS: 3, + // Alpha + ctx.globalAlpha = alpha; - /** - * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead - * to help you remember what the value is doing in your code. - * - * @name Phaser.FOREVER - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - FOREVER: -1, + ctx.save(); - /** - * Direction constant. - * - * @name Phaser.NONE - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - NONE: 4, - - /** - * Direction constant. - * - * @name Phaser.UP - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - UP: 5, - - /** - * Direction constant. - * - * @name Phaser.DOWN - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - DOWN: 6, - - /** - * Direction constant. - * - * @name Phaser.LEFT - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - LEFT: 7, - - /** - * Direction constant. - * - * @name Phaser.RIGHT - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - RIGHT: 8 + calcMatrix.setToContext(ctx); + return true; }; -module.exports = CONST; +module.exports = SetTransform; /***/ }), -/* 21 */ -/***/ (function(module, exports, __webpack_require__) { +/* 23 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -4375,90 +4622,28 @@ module.exports = CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); - /** - * @typedef {object} GetTilesWithinFilteringOptions + * Force a value within the boundaries by clamping it to the range `min`, `max`. * - * @property {boolean} [isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. - * @property {boolean} [isColliding=false] - If true, only return tiles that collide on at least one side. - * @property {boolean} [hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. - */ - -/** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @function Phaser.Tilemaps.Components.GetTilesWithin - * @private + * @function Phaser.Math.Clamp * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {object} GetTilesWithinFilteringOptions - Optional filters to apply when getting the tiles. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + * @param {number} value - The value to be clamped. + * @param {number} min - The minimum bounds. + * @param {number} max - The maximum bounds. + * + * @return {number} The clamped value. */ -var GetTilesWithin = function (tileX, tileY, width, height, filteringOptions, layer) +var Clamp = function (value, min, max) { - if (tileX === undefined) { tileX = 0; } - if (tileY === undefined) { tileY = 0; } - if (width === undefined) { width = layer.width; } - if (height === undefined) { height = layer.height; } - - var isNotEmpty = GetFastValue(filteringOptions, 'isNotEmpty', false); - var isColliding = GetFastValue(filteringOptions, 'isColliding', false); - var hasInterestingFace = GetFastValue(filteringOptions, 'hasInterestingFace', false); - - // Clip x, y to top left of map, while shrinking width/height to match. - if (tileX < 0) - { - width += tileX; - tileX = 0; - } - if (tileY < 0) - { - height += tileY; - tileY = 0; - } - - // Clip width and height to bottom right of map. - if (tileX + width > layer.width) - { - width = Math.max(layer.width - tileX, 0); - } - if (tileY + height > layer.height) - { - height = Math.max(layer.height - tileY, 0); - } - - var results = []; - - for (var ty = tileY; ty < tileY + height; ty++) - { - for (var tx = tileX; tx < tileX + width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile !== null) - { - if (isNotEmpty && tile.index === -1) { continue; } - if (isColliding && !tile.collides) { continue; } - if (hasInterestingFace && !tile.hasInterestingFace) { continue; } - results.push(tile); - } - } - } - - return results; + return Math.max(min, Math.min(max, value)); }; -module.exports = GetTilesWithin; +module.exports = Clamp; /***/ }), -/* 22 */ +/* 24 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -4467,8 +4652,8 @@ module.exports = GetTilesWithin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(20); -var Smoothing = __webpack_require__(131); +var CONST = __webpack_require__(26); +var Smoothing = __webpack_require__(120); // The pool into which the canvas elements are placed. var pool = []; @@ -4719,7 +4904,7 @@ module.exports = CanvasPool(); /***/ }), -/* 23 */ +/* 25 */ /***/ (function(module, exports) { /** @@ -4729,27 +4914,64 @@ module.exports = CanvasPool(); */ /** - * Force a value within the boundaries by clamping it to the range `min`, `max`. + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then sets it to the given value. * - * @function Phaser.Math.Clamp - * @since 3.0.0 + * The optional `step` property is applied incrementally, multiplied by each item in the array. * - * @param {number} value - The value to be clamped. - * @param {number} min - The minimum bounds. - * @param {number} max - The maximum bounds. + * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` * - * @return {number} The clamped value. + * @function Phaser.Actions.PropertyValueSet + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. */ -var Clamp = function (value, min, max) +var PropertyValueSet = function (items, key, value, step, index, direction) { - return Math.max(min, Math.min(max, value)); + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] = value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] = value + (t * step); + t++; + } + } + + return items; }; -module.exports = Clamp; +module.exports = PropertyValueSet; /***/ }), -/* 24 */ +/* 26 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -4758,9 +4980,448 @@ module.exports = Clamp; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(51); -var GetAdvancedValue = __webpack_require__(10); -var ScaleModes = __webpack_require__(59); +/** + * Global consts. + * + * @ignore + */ + +var CONST = { + + /** + * Phaser Release Version + * + * @name Phaser.VERSION + * @readonly + * @type {string} + * @since 3.0.0 + */ + VERSION: '3.15.1', + + BlendModes: __webpack_require__(66), + + ScaleModes: __webpack_require__(94), + + /** + * AUTO Detect Renderer. + * + * @name Phaser.AUTO + * @readonly + * @type {integer} + * @since 3.0.0 + */ + AUTO: 0, + + /** + * Canvas Renderer. + * + * @name Phaser.CANVAS + * @readonly + * @type {integer} + * @since 3.0.0 + */ + CANVAS: 1, + + /** + * WebGL Renderer. + * + * @name Phaser.WEBGL + * @readonly + * @type {integer} + * @since 3.0.0 + */ + WEBGL: 2, + + /** + * Headless Renderer. + * + * @name Phaser.HEADLESS + * @readonly + * @type {integer} + * @since 3.0.0 + */ + HEADLESS: 3, + + /** + * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead + * to help you remember what the value is doing in your code. + * + * @name Phaser.FOREVER + * @readonly + * @type {integer} + * @since 3.0.0 + */ + FOREVER: -1, + + /** + * Direction constant. + * + * @name Phaser.NONE + * @readonly + * @type {integer} + * @since 3.0.0 + */ + NONE: 4, + + /** + * Direction constant. + * + * @name Phaser.UP + * @readonly + * @type {integer} + * @since 3.0.0 + */ + UP: 5, + + /** + * Direction constant. + * + * @name Phaser.DOWN + * @readonly + * @type {integer} + * @since 3.0.0 + */ + DOWN: 6, + + /** + * Direction constant. + * + * @name Phaser.LEFT + * @readonly + * @type {integer} + * @since 3.0.0 + */ + LEFT: 7, + + /** + * Direction constant. + * + * @name Phaser.RIGHT + * @readonly + * @type {integer} + * @since 3.0.0 + */ + RIGHT: 8 + +}; + +module.exports = CONST; + + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var Line = __webpack_require__(54); + +/** + * @classdesc + * The Shape Game Object is a base class for the various different shapes, such as the Arc, Star or Polygon. + * You cannot add a Shape directly to your Scene, it is meant as a base for your own custom Shape classes. + * + * @class Shape + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {string} [type] - The internal type of the Shape. + * @param {any} [data] - The data of the source shape geometry, if any. + */ +var Shape = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Transform, + Components.Visible + ], + + initialize: + + function Shape (scene, type, data) + { + if (type === undefined) { type = 'Shape'; } + + GameObject.call(this, scene, type); + + /** + * The source Shape data. Typically a geometry object. + * You should not manipulate this directly. + * + * @name Phaser.GameObjects.Shape#data + * @type {any} + * @readonly + * @since 3.13.0 + */ + this.geom = data; + + /** + * Holds the polygon path data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathData + * @type {number[]} + * @readonly + * @since 3.13.0 + */ + this.pathData = []; + + /** + * Holds the earcut polygon path index data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathIndexes + * @type {integer[]} + * @readonly + * @since 3.13.0 + */ + this.pathIndexes = []; + + /** + * The fill color used by this Shape. + * + * @name Phaser.GameObjects.Shape#fillColor + * @type {number} + * @since 3.13.0 + */ + this.fillColor = 0xffffff; + + /** + * The fill alpha value used by this Shape. + * + * @name Phaser.GameObjects.Shape#fillAlpha + * @type {number} + * @since 3.13.0 + */ + this.fillAlpha = 1; + + /** + * The stroke color used by this Shape. + * + * @name Phaser.GameObjects.Shape#strokeColor + * @type {number} + * @since 3.13.0 + */ + this.strokeColor = 0xffffff; + + /** + * The stroke alpha value used by this Shape. + * + * @name Phaser.GameObjects.Shape#strokeAlpha + * @type {number} + * @since 3.13.0 + */ + this.strokeAlpha = 1; + + /** + * The stroke line width used by this Shape. + * + * @name Phaser.GameObjects.Shape#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Controls if this Shape is filled or not. + * Note that some Shapes do not support being filled (such as Line shapes) + * + * @name Phaser.GameObjects.Shape#isFilled + * @type {boolean} + * @since 3.13.0 + */ + this.isFilled = false; + + /** + * Controls if this Shape is stroked or not. + * Note that some Shapes do not support being stroked (such as Iso Box shapes) + * + * @name Phaser.GameObjects.Shape#isStroked + * @type {boolean} + * @since 3.13.0 + */ + this.isStroked = false; + + /** + * Controls if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * @name Phaser.GameObjects.Shape#closePath + * @type {boolean} + * @since 3.13.0 + */ + this.closePath = true; + + /** + * Private internal value. + * A Line used when parsing internal path data to avoid constant object re-creation. + * + * @name Phaser.GameObjects.Curve#_tempLine + * @type {Phaser.Geom.Line} + * @private + * @since 3.13.0 + */ + this._tempLine = new Line(); + + this.initPipeline(); + }, + + /** + * Sets the fill color and alpha for this Shape. + * + * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. + * + * Note that some Shapes do not support fill colors, such as the Line shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setFillStyle + * @since 3.13.0 + * + * @param {number} [color] - The color used to fill this shape. If not provided the Shape will not be filled. + * @param {number} [alpha=1] - The alpha value used when filling this shape, if a fill color is given. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (color === undefined) + { + this.isFilled = false; + } + else + { + this.fillColor = color; + this.fillAlpha = alpha; + this.isFilled = true; + } + + return this; + }, + + /** + * Sets the stroke color and alpha for this Shape. + * + * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. + * + * Note that some Shapes do not support being stroked, such as the Iso Box shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setStrokeStyle + * @since 3.13.0 + * + * @param {number} [color] - The color used to stroke this shape. If not provided the Shape will not be stroked. + * @param {number} [alpha=1] - The alpha value used when stroking this shape, if a stroke color is given. + * + * @return {this} This Game Object instance. + */ + setStrokeStyle: function (lineWidth, color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (lineWidth === undefined) + { + this.isStroked = false; + } + else + { + this.lineWidth = lineWidth; + this.strokeColor = color; + this.strokeAlpha = alpha; + this.isStroked = true; + } + + return this; + }, + + /** + * Sets if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setClosePath + * @since 3.13.0 + * + * @param {boolean} value - Set to `true` if the Shape should be closed when stroked, otherwise `false`. + * + * @return {this} This Game Object instance. + */ + setClosePath: function (value) + { + this.closePath = value; + + return this; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Shape#preDestroy + * @protected + * @since 3.13.0 + */ + preDestroy: function () + { + this.geom = null; + this._tempLine = null; + this.pathData = []; + this.pathIndexes = []; + } + +}); + +module.exports = Shape; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(66); +var GetAdvancedValue = __webpack_require__(12); +var ScaleModes = __webpack_require__(94); /** * @typedef {object} GameObjectConfig @@ -4902,74 +5563,7 @@ module.exports = BuildGameObject; /***/ }), -/* 25 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` - * - * @function Phaser.Actions.PropertyValueSet - * @since 3.3.0 - * - * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] - * - * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. - * @param {string} key - The property to be updated. - * @param {number} value - The amount to set the property to. - * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. - * @param {integer} [index=0] - An optional offset to start searching from within the items array. - * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. - * - * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. - */ -var PropertyValueSet = function (items, key, value, step, index, direction) -{ - if (step === undefined) { step = 0; } - if (index === undefined) { index = 0; } - if (direction === undefined) { direction = 1; } - - var i; - var t = 0; - var end = items.length; - - if (direction === 1) - { - // Start to End - for (i = index; i < end; i++) - { - items[i][key] = value + (t * step); - t++; - } - } - else - { - // End to Start - for (i = index; i >= 0; i--) - { - items[i][key] = value + (t * step); - t++; - } - } - - return items; -}; - -module.exports = PropertyValueSet; - - -/***/ }), -/* 26 */ +/* 29 */ /***/ (function(module, exports) { /** @@ -5024,142 +5618,2563 @@ module.exports = { /***/ }), -/* 27 */ +/* 30 */ /***/ (function(module, exports) { /** * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * @namespace Phaser.Renderer.WebGL.Utils - * @since 3.0.0 + * Sets the fillStyle on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#FillStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the fill style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the fill style from. */ -module.exports = { +var FillStyleCanvas = function (ctx, src, altColor) +{ + var fillColor = (altColor) ? altColor : src.fillColor; + var fillAlpha = src.fillAlpha; - /** - * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 - * - * @function Phaser.Renderer.WebGL.Utils.getTintFromFloats - * @since 3.0.0 - * - * @param {number} r - Red component in a range from 0.0 to 1.0 - * @param {number} g - [description] - * @param {number} b - [description] - * @param {number} a - Alpha component in a range from 0.0 to 1.0 - * - * @return {number} [description] - */ - getTintFromFloats: function (r, g, b, a) - { - var ur = ((r * 255.0)|0) & 0xFF; - var ug = ((g * 255.0)|0) & 0xFF; - var ub = ((b * 255.0)|0) & 0xFF; - var ua = ((a * 255.0)|0) & 0xFF; - - return ((ua << 24) | (ur << 16) | (ug << 8) | ub) >>> 0; - }, - - /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 - * - * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha - * @since 3.0.0 - * - * @param {number} rgb - Uint24 representing RGB components - * @param {number} a - Float32 representing Alpha component - * - * @return {number} Packed RGBA as Uint32 - */ - getTintAppendFloatAlpha: function (rgb, a) - { - var ua = ((a * 255.0)|0) & 0xFF; - return ((ua << 24) | rgb) >>> 0; - }, - - /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a - * swizzled Uint32 - * - * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlphaAndSwap - * @since 3.0.0 - * - * @param {number} rgb - Uint24 representing RGB components - * @param {number} a - Float32 representing Alpha component - * - * @return {number} Packed RGBA as Uint32 - */ - getTintAppendFloatAlphaAndSwap: function (rgb, a) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - var ua = ((a * 255.0)|0) & 0xFF; - - return ((ua << 24) | (ub << 16) | (ug << 8) | ur) >>> 0; - }, - - /** - * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 - * - * @function Phaser.Renderer.WebGL.Utils.getFloatsFromUintRGB - * @since 3.0.0 - * - * @param {number} rgb - RGB packed as a Uint24 - * - * @return {array} Array of floats representing each component as a float - */ - getFloatsFromUintRGB: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - return [ ur / 255.0, ug / 255.0, ub / 255.0 ]; - }, - - /** - * Counts how many attributes of 32 bits a vertex has - * - * @function Phaser.Renderer.WebGL.Utils.getComponentCount - * @since 3.0.0 - * - * @param {array} attributes - Array of attributes - * @param {WebGLRenderingContext} glContext - WebGLContext used for check types - * - * @return {number} Count of 32 bit attributes in vertex - */ - getComponentCount: function (attributes, glContext) - { - var count = 0; - - for (var index = 0; index < attributes.length; ++index) - { - var element = attributes[index]; - - if (element.type === glContext.FLOAT) - { - count += element.size; - } - else - { - count += 1; // We'll force any other type to be 32 bit. for now - } - } - - return count; - } + var red = ((fillColor & 0xFF0000) >>> 16); + var green = ((fillColor & 0xFF00) >>> 8); + var blue = (fillColor & 0xFF); + ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; }; +module.exports = FillStyleCanvas; + /***/ }), -/* 28 */ +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(16); + +/** + * Convert the given angle from degrees, to the equivalent angle in radians. + * + * @function Phaser.Math.DegToRad + * @since 3.0.0 + * + * @param {integer} degrees - The angle (in degrees) to convert to radians. + * + * @return {number} The given angle converted to radians. + */ +var DegToRad = function (degrees) +{ + return degrees * CONST.DEG_TO_RAD; +}; + +module.exports = DegToRad; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then adds the given value to it. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` + * + * @function Phaser.Actions.PropertyValueInc + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to be added to the property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var PropertyValueInc = function (items, key, value, step, index, direction) +{ + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] += value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] += value + (t * step); + t++; + } + } + + return items; +}; + +module.exports = PropertyValueInc; + + +/***/ }), +/* 33 */, +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(102); +var GetTilesWithin = __webpack_require__(17); + +/** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @function Phaser.Tilemaps.Components.CalculateFacesWithin + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var CalculateFacesWithin = function (tileX, tileY, width, height, layer) +{ + var above = null; + var below = null; + var left = null; + var right = null; + + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + if (tile) + { + if (tile.collides) + { + above = GetTileAt(tile.x, tile.y - 1, true, layer); + below = GetTileAt(tile.x, tile.y + 1, true, layer); + left = GetTileAt(tile.x - 1, tile.y, true, layer); + right = GetTileAt(tile.x + 1, tile.y, true, layer); + + tile.faceTop = (above && above.collides) ? false : true; + tile.faceBottom = (below && below.collides) ? false : true; + tile.faceLeft = (left && left.collides) ? false : true; + tile.faceRight = (right && right.collides) ? false : true; + } + else + { + tile.resetFaces(); + } + } + } +}; + +module.exports = CalculateFacesWithin; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Arcade Physics consts. + * + * @ignore + */ + +var CONST = { + + /** + * Dynamic Body. + * + * @name Phaser.Physics.Arcade.DYNAMIC_BODY + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#physicsType + * @see Phaser.Physics.Arcade.Group#physicsType + */ + DYNAMIC_BODY: 0, + + /** + * Static Body. + * + * @name Phaser.Physics.Arcade.STATIC_BODY + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#physicsType + * @see Phaser.Physics.Arcade.StaticBody#physicsType + */ + STATIC_BODY: 1, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.GROUP + * @readonly + * @type {number} + * @since 3.0.0 + */ + GROUP: 2, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.TILEMAPLAYER + * @readonly + * @type {number} + * @since 3.0.0 + */ + TILEMAPLAYER: 3, + + /** + * Facing no direction (initial value). + * + * @name Phaser.Physics.Arcade.FACING_NONE + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_NONE: 10, + + /** + * Facing up. + * + * @name Phaser.Physics.Arcade.FACING_UP + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_UP: 11, + + /** + * Facing down. + * + * @name Phaser.Physics.Arcade.FACING_DOWN + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_DOWN: 12, + + /** + * Facing left. + * + * @name Phaser.Physics.Arcade.FACING_LEFT + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_LEFT: 13, + + /** + * Facing right. + * + * @name Phaser.Physics.Arcade.FACING_RIGHT + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_RIGHT: 14 + +}; + +module.exports = CONST; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the strokeStyle and lineWidth on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#LineStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the stroke style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the stroke style from. + */ +var LineStyleCanvas = function (ctx, src) +{ + var strokeColor = src.strokeColor; + var strokeAlpha = src.strokeAlpha; + + var red = ((strokeColor & 0xFF0000) >>> 16); + var green = ((strokeColor & 0xFF00) >>> 8); + var blue = (strokeColor & 0xFF); + + ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + strokeAlpha + ')'; + ctx.lineWidth = src.lineWidth; +}; + +module.exports = LineStyleCanvas; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetColor = __webpack_require__(177); +var GetColor32 = __webpack_require__(376); +var HSVToRGB = __webpack_require__(176); +var RGBToHSV = __webpack_require__(375); + +/** + * @classdesc + * The Color class holds a single color value and allows for easy modification and reading of it. + * + * @class Color + * @memberof Phaser.Display + * @constructor + * @since 3.0.0 + * + * @param {integer} [red=0] - The red color value. A number between 0 and 255. + * @param {integer} [green=0] - The green color value. A number between 0 and 255. + * @param {integer} [blue=0] - The blue color value. A number between 0 and 255. + * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + */ +var Color = new Class({ + + initialize: + + function Color (red, green, blue, alpha) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + if (alpha === undefined) { alpha = 255; } + + /** + * The internal red color value. + * + * @name Phaser.Display.Color#r + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.r = 0; + + /** + * The internal green color value. + * + * @name Phaser.Display.Color#g + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.g = 0; + + /** + * The internal blue color value. + * + * @name Phaser.Display.Color#b + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.b = 0; + + /** + * The internal alpha color value. + * + * @name Phaser.Display.Color#a + * @type {number} + * @private + * @default 255 + * @since 3.0.0 + */ + this.a = 255; + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#_h + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._h = 0; + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#_s + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._s = 0; + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @name Phaser.Display.Color#_v + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._v = 0; + + /** + * Is this color update locked? + * + * @name Phaser.Display.Color#_locked + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._locked = false; + + /** + * An array containing the calculated color values for WebGL use. + * + * @name Phaser.Display.Color#gl + * @type {number[]} + * @since 3.0.0 + */ + this.gl = [ 0, 0, 0, 1 ]; + + /** + * Pre-calculated internal color value. + * + * @name Phaser.Display.Color#_color + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color = 0; + + /** + * Pre-calculated internal color32 value. + * + * @name Phaser.Display.Color#_color32 + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color32 = 0; + + /** + * Pre-calculated internal color rgb string value. + * + * @name Phaser.Display.Color#_rgba + * @type {string} + * @private + * @default '' + * @since 3.0.0 + */ + this._rgba = ''; + + this.setTo(red, green, blue, alpha); + }, + + /** + * Sets this color to be transparent. Sets all values to zero. + * + * @method Phaser.Display.Color#transparent + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + transparent: function () + { + this._locked = true; + + this.red = 0; + this.green = 0; + this.blue = 0; + this.alpha = 0; + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color of this Color component. + * + * @method Phaser.Display.Color#setTo + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + * @param {boolean} [updateHSV=true] - Update the HSV values after setting the RGB values? + * + * @return {Phaser.Display.Color} This Color object. + */ + setTo: function (red, green, blue, alpha, updateHSV) + { + if (alpha === undefined) { alpha = 255; } + if (updateHSV === undefined) { updateHSV = true; } + + this._locked = true; + + this.red = red; + this.green = green; + this.blue = blue; + this.alpha = alpha; + + this._locked = false; + + return this.update(updateHSV); + }, + + /** + * Sets the red, green, blue and alpha GL values of this Color component. + * + * @method Phaser.Display.Color#setGLTo + * @since 3.0.0 + * + * @param {number} red - The red color value. A number between 0 and 1. + * @param {number} green - The green color value. A number between 0 and 1. + * @param {number} blue - The blue color value. A number between 0 and 1. + * @param {number} [alpha=1] - The alpha value. A number between 0 and 1. + * + * @return {Phaser.Display.Color} This Color object. + */ + setGLTo: function (red, green, blue, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this._locked = true; + + this.redGL = red; + this.greenGL = green; + this.blueGL = blue; + this.alphaGL = alpha; + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color based on the color object given. + * + * @method Phaser.Display.Color#setFromRGB + * @since 3.0.0 + * + * @param {InputColorObject} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromRGB: function (color) + { + this._locked = true; + + this.red = color.r; + this.green = color.g; + this.blue = color.b; + + if (color.hasOwnProperty('a')) + { + this.alpha = color.a; + } + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color based on the hue, saturation and lightness values given. + * + * @method Phaser.Display.Color#setFromHSV + * @since 3.13.0 + * + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromHSV: function (h, s, v) + { + return HSVToRGB(h, s, v, this); + }, + + /** + * Updates the internal cache values. + * + * @method Phaser.Display.Color#update + * @private + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + update: function (updateHSV) + { + if (updateHSV === undefined) { updateHSV = false; } + + if (this._locked) + { + return this; + } + + var r = this.r; + var g = this.g; + var b = this.b; + var a = this.a; + + this._color = GetColor(r, g, b); + this._color32 = GetColor32(r, g, b, a); + this._rgba = 'rgba(' + r + ',' + g + ',' + b + ',' + (a / 255) + ')'; + + if (updateHSV) + { + RGBToHSV(r, g, b, this); + } + + return this; + }, + + /** + * Updates the internal hsv cache values. + * + * @method Phaser.Display.Color#updateHSV + * @private + * @since 3.13.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + updateHSV: function () + { + var r = this.r; + var g = this.g; + var b = this.b; + + RGBToHSV(r, g, b, this); + + return this; + }, + + /** + * Returns a new Color component using the values from this one. + * + * @method Phaser.Display.Color#clone + * @since 3.0.0 + * + * @return {Phaser.Display.Color} A new Color object. + */ + clone: function () + { + return new Color(this.r, this.g, this.b, this.a); + }, + + /** + * Sets this Color object to be grayscaled based on the shade value given. + * + * @method Phaser.Display.Color#gray + * @since 3.13.0 + * + * @param {integer} shade - A value between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + gray: function (shade) + { + return this.setTo(shade, shade, shade); + }, + + /** + * Sets this Color object to be a random color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#random + * @since 3.13.0 + * + * @param {integer} [min=0] - The minimum random color value. Between 0 and 255. + * @param {integer} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + random: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var r = Math.floor(min + Math.random() * (max - min)); + var g = Math.floor(min + Math.random() * (max - min)); + var b = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(r, g, b); + }, + + /** + * Sets this Color object to be a random grayscale color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#randomGray + * @since 3.13.0 + * + * @param {integer} [min=0] - The minimum random color value. Between 0 and 255. + * @param {integer} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + randomGray: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var s = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(s, s, s); + }, + + /** + * Increase the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#saturate + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + saturate: function (amount) + { + this.s += amount / 100; + + return this; + }, + + /** + * Decrease the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#desaturate + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + desaturate: function (amount) + { + this.s -= amount / 100; + + return this; + }, + + /** + * Increase the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#lighten + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + lighten: function (amount) + { + this.v += amount / 100; + + return this; + }, + + /** + * Decrease the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#darken + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + darken: function (amount) + { + this.v -= amount / 100; + + return this; + }, + + /** + * Brighten this Color by the percentage amount given. + * + * @method Phaser.Display.Color#brighten + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + brighten: function (amount) + { + var r = this.r; + var g = this.g; + var b = this.b; + + r = Math.max(0, Math.min(255, r - Math.round(255 * - (amount / 100)))); + g = Math.max(0, Math.min(255, g - Math.round(255 * - (amount / 100)))); + b = Math.max(0, Math.min(255, b - Math.round(255 * - (amount / 100)))); + + return this.setTo(r, g, b); + }, + + /** + * The color of this Color component, not including the alpha channel. + * + * @name Phaser.Display.Color#color + * @type {number} + * @readonly + * @since 3.0.0 + */ + color: { + + get: function () + { + return this._color; + } + + }, + + /** + * The color of this Color component, including the alpha channel. + * + * @name Phaser.Display.Color#color32 + * @type {number} + * @readonly + * @since 3.0.0 + */ + color32: { + + get: function () + { + return this._color32; + } + + }, + + /** + * The color of this Color component as a string which can be used in CSS color values. + * + * @name Phaser.Display.Color#rgba + * @type {string} + * @readonly + * @since 3.0.0 + */ + rgba: { + + get: function () + { + return this._rgba; + } + + }, + + /** + * The red color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#redGL + * @type {number} + * @since 3.0.0 + */ + redGL: { + + get: function () + { + return this.gl[0]; + }, + + set: function (value) + { + this.gl[0] = Math.min(Math.abs(value), 1); + + this.r = Math.floor(this.gl[0] * 255); + + this.update(true); + } + + }, + + /** + * The green color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#greenGL + * @type {number} + * @since 3.0.0 + */ + greenGL: { + + get: function () + { + return this.gl[1]; + }, + + set: function (value) + { + this.gl[1] = Math.min(Math.abs(value), 1); + + this.g = Math.floor(this.gl[1] * 255); + + this.update(true); + } + + }, + + /** + * The blue color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#blueGL + * @type {number} + * @since 3.0.0 + */ + blueGL: { + + get: function () + { + return this.gl[2]; + }, + + set: function (value) + { + this.gl[2] = Math.min(Math.abs(value), 1); + + this.b = Math.floor(this.gl[2] * 255); + + this.update(true); + } + + }, + + /** + * The alpha color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#alphaGL + * @type {number} + * @since 3.0.0 + */ + alphaGL: { + + get: function () + { + return this.gl[3]; + }, + + set: function (value) + { + this.gl[3] = Math.min(Math.abs(value), 1); + + this.a = Math.floor(this.gl[3] * 255); + + this.update(); + } + + }, + + /** + * The red color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#red + * @type {number} + * @since 3.0.0 + */ + red: { + + get: function () + { + return this.r; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.r = Math.min(value, 255); + + this.gl[0] = value / 255; + + this.update(true); + } + + }, + + /** + * The green color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#green + * @type {number} + * @since 3.0.0 + */ + green: { + + get: function () + { + return this.g; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.g = Math.min(value, 255); + + this.gl[1] = value / 255; + + this.update(true); + } + + }, + + /** + * The blue color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#blue + * @type {number} + * @since 3.0.0 + */ + blue: { + + get: function () + { + return this.b; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.b = Math.min(value, 255); + + this.gl[2] = value / 255; + + this.update(true); + } + + }, + + /** + * The alpha color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this.a; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.a = Math.min(value, 255); + + this.gl[3] = value / 255; + + this.update(); + } + + }, + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#h + * @type {number} + * @since 3.13.0 + */ + h: { + + get: function () + { + return this._h; + }, + + set: function (value) + { + this._h = value; + + HSVToRGB(value, this._s, this._v, this); + } + + }, + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#s + * @type {number} + * @since 3.13.0 + */ + s: { + + get: function () + { + return this._s; + }, + + set: function (value) + { + this._s = value; + + HSVToRGB(this._h, value, this._v, this); + } + + }, + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @name Phaser.Display.Color#v + * @type {number} + * @since 3.13.0 + */ + v: { + + get: function () + { + return this._v; + }, + + set: function (value) + { + this._v = value; + + HSVToRGB(this._h, this._s, value, this); + } + + } + +}); + +module.exports = Color; + + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Matrix used for display transformations for rendering. + * + * It is represented like so: + * + * ``` + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * ``` + * + * @class TransformMatrix + * @memberof Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {number} [a=1] - The Scale X value. + * @param {number} [b=0] - The Shear Y value. + * @param {number} [c=0] - The Shear X value. + * @param {number} [d=1] - The Scale Y value. + * @param {number} [tx=0] - The Translate X value. + * @param {number} [ty=0] - The Translate Y value. + */ +var TransformMatrix = new Class({ + + initialize: + + function TransformMatrix (a, b, c, d, tx, ty) + { + if (a === undefined) { a = 1; } + if (b === undefined) { b = 0; } + if (c === undefined) { c = 0; } + if (d === undefined) { d = 1; } + if (tx === undefined) { tx = 0; } + if (ty === undefined) { ty = 0; } + + /** + * The matrix values. + * + * @name Phaser.GameObjects.Components.TransformMatrix#matrix + * @type {Float32Array} + * @since 3.0.0 + */ + this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + + /** + * The decomposed matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * @type {object} + * @since 3.0.0 + */ + this.decomposedMatrix = { + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotation: 0 + }; + }, + + /** + * The Scale X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#a + * @type {number} + * @since 3.4.0 + */ + a: { + + get: function () + { + return this.matrix[0]; + }, + + set: function (value) + { + this.matrix[0] = value; + } + + }, + + /** + * The Shear Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#b + * @type {number} + * @since 3.4.0 + */ + b: { + + get: function () + { + return this.matrix[1]; + }, + + set: function (value) + { + this.matrix[1] = value; + } + + }, + + /** + * The Shear X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#c + * @type {number} + * @since 3.4.0 + */ + c: { + + get: function () + { + return this.matrix[2]; + }, + + set: function (value) + { + this.matrix[2] = value; + } + + }, + + /** + * The Scale Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#d + * @type {number} + * @since 3.4.0 + */ + d: { + + get: function () + { + return this.matrix[3]; + }, + + set: function (value) + { + this.matrix[3] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#e + * @type {number} + * @since 3.11.0 + */ + e: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#f + * @type {number} + * @since 3.11.0 + */ + f: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#tx + * @type {number} + * @since 3.4.0 + */ + tx: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#ty + * @type {number} + * @since 3.4.0 + */ + ty: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The rotation of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#rotation + * @type {number} + * @readonly + * @since 3.4.0 + */ + rotation: { + + get: function () + { + return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1); + } + + }, + + /** + * The horizontal scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleX + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleX: { + + get: function () + { + return Math.sqrt((this.a * this.a) + (this.c * this.c)); + } + + }, + + /** + * The vertical scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleY + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleY: { + + get: function () + { + return Math.sqrt((this.b * this.b) + (this.d * this.d)); + } + + }, + + /** + * Reset the Matrix to an identity matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + loadIdentity: function () + { + var matrix = this.matrix; + + matrix[0] = 1; + matrix[1] = 0; + matrix[2] = 0; + matrix[3] = 1; + matrix[4] = 0; + matrix[5] = 0; + + return this; + }, + + /** + * Translate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @since 3.0.0 + * + * @param {number} x - The horizontal translation value. + * @param {number} y - The vertical translation value. + * + * @return {this} This TransformMatrix. + */ + translate: function (x, y) + { + var matrix = this.matrix; + + matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; + matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; + + return this; + }, + + /** + * Scale the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#scale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale value. + * @param {number} y - The vertical scale value. + * + * @return {this} This TransformMatrix. + */ + scale: function (x, y) + { + var matrix = this.matrix; + + matrix[0] *= x; + matrix[1] *= x; + matrix[2] *= y; + matrix[3] *= y; + + return this; + }, + + /** + * Rotate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#rotate + * @since 3.0.0 + * + * @param {number} angle - The angle of rotation in radians. + * + * @return {this} This TransformMatrix. + */ + rotate: function (angle) + { + var sin = Math.sin(angle); + var cos = Math.cos(angle); + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + matrix[0] = a * cos + c * sin; + matrix[1] = b * cos + d * sin; + matrix[2] = a * -sin + c * cos; + matrix[3] = b * -sin + d * cos; + + return this; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiply + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - The Matrix to multiply by. + * @param {Phaser.GameObjects.Components.TransformMatrix} [out] - An optional Matrix to store the results in. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} Either this TransformMatrix, or the `out` Matrix, if given in the arguments. + */ + multiply: function (rhs, out) + { + var matrix = this.matrix; + var source = rhs.matrix; + + var localA = matrix[0]; + var localB = matrix[1]; + var localC = matrix[2]; + var localD = matrix[3]; + var localE = matrix[4]; + var localF = matrix[5]; + + var sourceA = source[0]; + var sourceB = source[1]; + var sourceC = source[2]; + var sourceD = source[3]; + var sourceE = source[4]; + var sourceF = source[5]; + + var destinationMatrix = (out === undefined) ? this : out; + + destinationMatrix.a = (sourceA * localA) + (sourceB * localC); + destinationMatrix.b = (sourceA * localB) + (sourceB * localD); + destinationMatrix.c = (sourceC * localA) + (sourceD * localC); + destinationMatrix.d = (sourceC * localB) + (sourceD * localD); + destinationMatrix.e = (sourceE * localA) + (sourceF * localC) + localE; + destinationMatrix.f = (sourceE * localB) + (sourceF * localD) + localF; + + return destinationMatrix; + }, + + /** + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiplyWithOffset + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * @param {number} offsetX - Horizontal offset to factor in to the multiplication. + * @param {number} offsetY - Vertical offset to factor in to the multiplication. + * + * @return {this} This TransformMatrix. + */ + multiplyWithOffset: function (src, offsetX, offsetY) + { + var matrix = this.matrix; + var otherMatrix = src.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + var pse = offsetX * a0 + offsetY * c0 + tx0; + var psf = offsetX * b0 + offsetY * d0 + ty0; + + var a1 = otherMatrix[0]; + var b1 = otherMatrix[1]; + var c1 = otherMatrix[2]; + var d1 = otherMatrix[3]; + var tx1 = otherMatrix[4]; + var ty1 = otherMatrix[5]; + + matrix[0] = a1 * a0 + b1 * c0; + matrix[1] = a1 * b0 + b1 * d0; + matrix[2] = c1 * a0 + d1 * c0; + matrix[3] = c1 * b0 + d1 * d0; + matrix[4] = tx1 * a0 + ty1 * c0 + pse; + matrix[5] = tx1 * b0 + ty1 * d0 + psf; + + return this; + }, + + /** + * Transform the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + transform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + matrix[0] = a * a0 + b * c0; + matrix[1] = a * b0 + b * d0; + matrix[2] = c * a0 + d * c0; + matrix[3] = c * b0 + d * d0; + matrix[4] = tx * a0 + ty * c0 + tx0; + matrix[5] = tx * b0 + ty * d0 + ty0; + + return this; + }, + + /** + * Transform a point using this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point to transform. + * @param {number} y - The y coordinate of the point to transform. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - The Point object to store the transformed coordinates. + * + * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} The Point containing the transformed coordinates. + */ + transformPoint: function (x, y, point) + { + if (point === undefined) { point = { x: 0, y: 0 }; } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + point.x = x * a + y * c + tx; + point.y = x * b + y * d + ty; + + return point; + }, + + /** + * Invert the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#invert + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + invert: function () + { + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var n = a * d - b * c; + + matrix[0] = d / n; + matrix[1] = -b / n; + matrix[2] = -c / n; + matrix[3] = a / n; + matrix[4] = (c * ty - d * tx) / n; + matrix[5] = -(a * ty - b * tx) / n; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the matrix given. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFrom + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * + * @return {this} This TransformMatrix. + */ + copyFrom: function (src) + { + var matrix = this.matrix; + + matrix[0] = src.a; + matrix[1] = src.b; + matrix[2] = src.c; + matrix[3] = src.d; + matrix[4] = src.e; + matrix[5] = src.f; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFromArray + * @since 3.11.0 + * + * @param {array} src - The array of values to set into this matrix. + * + * @return {this} This TransformMatrix. + */ + copyFromArray: function (src) + { + var matrix = this.matrix; + + matrix[0] = src[0]; + matrix[1] = src[1]; + matrix[2] = src[2]; + matrix[3] = src[3]; + matrix[4] = src[4]; + matrix[5] = src[5]; + + return this; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + copyToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + setToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToArray + * @since 3.12.0 + * + * @param {array} [out] - The array to copy the matrix values in to. + * + * @return {array} An array where elements 0 to 5 contain the values from this matrix. + */ + copyToArray: function (out) + { + var matrix = this.matrix; + + if (out === undefined) + { + out = [ matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] ]; + } + else + { + out[0] = matrix[0]; + out[1] = matrix[1]; + out[2] = matrix[2]; + out[3] = matrix[3]; + out[4] = matrix[4]; + out[5] = matrix[5]; + } + + return out; + }, + + /** + * Set the values of this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setTransform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + matrix[0] = a; + matrix[1] = b; + matrix[2] = c; + matrix[3] = d; + matrix[4] = tx; + matrix[5] = ty; + + return this; + }, + + /** + * Decompose this Matrix into its translation, scale and rotation values. + * + * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix + * @since 3.0.0 + * + * @return {object} The decomposed Matrix. + */ + decomposeMatrix: function () + { + var decomposedMatrix = this.decomposedMatrix; + + var matrix = this.matrix; + + // a = scale X (1) + // b = shear Y (0) + // c = shear X (0) + // d = scale Y (1) + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + var a2 = a * a; + var b2 = b * b; + var c2 = c * c; + var d2 = d * d; + + var sx = Math.sqrt(a2 + c2); + var sy = Math.sqrt(b2 + d2); + + decomposedMatrix.translateX = matrix[4]; + decomposedMatrix.translateY = matrix[5]; + + decomposedMatrix.scaleX = sx; + decomposedMatrix.scaleY = sy; + + decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); + + return decomposedMatrix; + }, + + /** + * Apply the identity, translate, rotate and scale operations on the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS + * @since 3.0.0 + * + * @param {number} x - The horizontal translation. + * @param {number} y - The vertical translation. + * @param {number} rotation - The angle of rotation in radians. + * @param {number} scaleX - The horizontal scale. + * @param {number} scaleY - The vertical scale. + * + * @return {this} This TransformMatrix. + */ + applyITRS: function (x, y, rotation, scaleX, scaleY) + { + var matrix = this.matrix; + + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); + + // Translate + matrix[4] = x; + matrix[5] = y; + + // Rotate and Scale + matrix[0] = radianCos * scaleX; + matrix[1] = radianSin * scaleX; + matrix[2] = -radianSin * scaleY; + matrix[3] = radianCos * scaleY; + + return this; + }, + + /** + * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of + * the current matrix with its transformation applied. + * + * Can be used to translate points from world to local space. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyInverse + * @since 3.12.0 + * + * @param {number} x - The x position to translate. + * @param {number} y - The y position to translate. + * @param {Phaser.Math.Vector2} [output] - A Vector2, or point-like object, to store the results in. + * + * @return {Phaser.Math.Vector2} The coordinates, inverse-transformed through this matrix. + */ + applyInverse: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var id = 1 / ((a * d) + (c * -b)); + + output.x = (d * id * x) + (-c * id * y) + (((ty * c) - (tx * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-ty * a) + (tx * b)) * id); + + return output; + }, + + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getX + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated x value. + */ + getX: function (x, y) + { + return x * this.a + y * this.c + this.e; + }, + + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getY + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated y value. + */ + getY: function (x, y) + { + return x * this.b + y * this.d + this.f; + }, + + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getCSSMatrix + * @since 3.12.0 + * + * @return {string} A string containing the CSS Transform matrix values. + */ + getCSSMatrix: function () + { + var m = this.matrix; + + return 'matrix(' + m[0] + ',' + m[1] + ',' + m[2] + ',' + m[3] + ',' + m[4] + ',' + m[5] + ')'; + }, + + /** + * Destroys this Transform Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#destroy + * @since 3.4.0 + */ + destroy: function () + { + this.matrix = null; + this.decomposedMatrix = null; + } + +}); + +module.exports = TransformMatrix; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ +var Contains = function (rect, x, y) +{ + if (rect.width <= 0 || rect.height <= 0) + { + return false; + } + + return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); +}; + +module.exports = Contains; + + +/***/ }), +/* 40 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check to see if the Circle contains the given x / y coordinates. + * + * @function Phaser.Geom.Circle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ +var Contains = function (circle, x, y) +{ + // Check if x/y are within the bounds first + if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) + { + var dx = (circle.x - x) * (circle.x - x); + var dy = (circle.y - y) * (circle.y - y); + + return (dx + dy) <= (circle.radius * circle.radius); + } + else + { + return false; + } +}; + +module.exports = Contains; + + +/***/ }), +/* 41 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetTop = function (gameObject, value) +{ + gameObject.y = value + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetTop; + + +/***/ }), +/* 42 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the top coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The top coordinate of the bounds of the Game Object. + */ +var GetTop = function (gameObject) +{ + return gameObject.y - (gameObject.height * gameObject.originY); +}; + +module.exports = GetTop; + + +/***/ }), +/* 43 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetRight = function (gameObject, value) +{ + gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetRight; + + +/***/ }), +/* 44 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the right coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The right coordinate of the bounds of the Game Object. + */ +var GetRight = function (gameObject) +{ + return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); +}; + +module.exports = GetRight; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetLeft = function (gameObject, value) +{ + gameObject.x = value + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetLeft; + + +/***/ }), +/* 46 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the left coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The left coordinate of the bounds of the Game Object. + */ +var GetLeft = function (gameObject) +{ + return gameObject.x - (gameObject.width * gameObject.originX); +}; + +module.exports = GetLeft; + + +/***/ }), +/* 47 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetBottom = function (gameObject, value) +{ + gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetBottom; + + +/***/ }), +/* 48 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the bottom coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The bottom coordinate of the bounds of the Game Object. + */ +var GetBottom = function (gameObject) +{ + return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); +}; + +module.exports = GetBottom; + + +/***/ }), +/* 49 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.WorldToTileY + * @private + * @since 3.0.0 + * + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The Y location in tile units. + */ +var WorldToTileY = function (worldY, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } + + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's vertical scroll + worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + + tileHeight *= tilemapLayer.scaleY; + } + + return snapToFloor + ? Math.floor(worldY / tileHeight) + : worldY / tileHeight; +}; + +module.exports = WorldToTileY; + + +/***/ }), +/* 50 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.WorldToTileX + * @private + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The X location in tile units. + */ +var WorldToTileX = function (worldX, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } + + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's horizontal scroll + worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX)); + + tileWidth *= tilemapLayer.scaleX; + } + + return snapToFloor + ? Math.floor(worldX / tileWidth) + : worldX / tileWidth; +}; + +module.exports = WorldToTileX; + + +/***/ }), +/* 51 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -5170,9 +8185,9 @@ module.exports = { var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var File = __webpack_require__(19); +var File = __webpack_require__(21); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); var IsPlainObject = __webpack_require__(8); @@ -5196,7 +8211,7 @@ var IsPlainObject = __webpack_require__(8); * * @class JSONFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -5398,2544 +8413,10 @@ FileTypesManager.register('json', function (key, url, dataKey, xhrSettings) module.exports = JSONFile; -/***/ }), -/* 29 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Tests if the start and end indexes are a safe range for the given array. - * - * @function Phaser.Utils.Array.SafeRange - * @since 3.4.0 - * - * @param {array} array - The array to check. - * @param {integer} startIndex - The start index. - * @param {integer} endIndex - The end index. - * @param {boolean} [throwError=true] - Throw an error if the range is out of bounds. - * - * @return {boolean} True if the range is safe, otherwise false. - */ -var SafeRange = function (array, startIndex, endIndex, throwError) -{ - var len = array.length; - - if (startIndex < 0 || - startIndex > len || - startIndex >= endIndex || - endIndex > len || - startIndex + endIndex > len) - { - if (throwError) - { - throw new Error('Range Error: Values outside acceptable range'); - } - - return false; - } - else - { - return true; - } -}; - -module.exports = SafeRange; - - -/***/ }), -/* 30 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetColor = __webpack_require__(152); -var GetColor32 = __webpack_require__(284); - -/** - * @classdesc - * The Color class holds a single color value and allows for easy modification and reading of it. - * - * @class Color - * @memberOf Phaser.Display - * @constructor - * @since 3.0.0 - * - * @param {integer} [red=0] - The red color value. A number between 0 and 255. - * @param {integer} [green=0] - The green color value. A number between 0 and 255. - * @param {integer} [blue=0] - The blue color value. A number between 0 and 255. - * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. - */ -var Color = new Class({ - - initialize: - - function Color (red, green, blue, alpha) - { - if (red === undefined) { red = 0; } - if (green === undefined) { green = 0; } - if (blue === undefined) { blue = 0; } - if (alpha === undefined) { alpha = 255; } - - /** - * The internal red color value. - * - * @name Phaser.Display.Color#r - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.r = 0; - - /** - * The internal green color value. - * - * @name Phaser.Display.Color#g - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.g = 0; - - /** - * The internal blue color value. - * - * @name Phaser.Display.Color#b - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.b = 0; - - /** - * The internal alpha color value. - * - * @name Phaser.Display.Color#a - * @type {number} - * @private - * @default 255 - * @since 3.0.0 - */ - this.a = 255; - - /** - * An array containing the calculated color values for WebGL use. - * - * @name Phaser.Display.Color#gl - * @type {number[]} - * @since 3.0.0 - */ - this.gl = [ 0, 0, 0, 1 ]; - - /** - * Pre-calculated internal color value. - * - * @name Phaser.Display.Color#_color - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._color = 0; - - /** - * Pre-calculated internal color32 value. - * - * @name Phaser.Display.Color#_color32 - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._color32 = 0; - - /** - * Pre-calculated internal color rgb string value. - * - * @name Phaser.Display.Color#_rgba - * @type {string} - * @private - * @default '' - * @since 3.0.0 - */ - this._rgba = ''; - - this.setTo(red, green, blue, alpha); - }, - - /** - * Sets this color to be transparent. Sets all values to zero. - * - * @method Phaser.Display.Color#transparent - * @since 3.0.0 - * - * @return {Phaser.Display.Color} This Color object. - */ - transparent: function () - { - this.red = 0; - this.green = 0; - this.blue = 0; - this.alpha = 0; - - return this.update(); - }, - - /** - * Sets the color of this Color component. - * - * @method Phaser.Display.Color#setTo - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. - * - * @return {Phaser.Display.Color} This Color object. - */ - setTo: function (red, green, blue, alpha) - { - if (alpha === undefined) { alpha = 255; } - - this.red = red; - this.green = green; - this.blue = blue; - this.alpha = alpha; - - return this.update(); - }, - - /** - * Sets the red, green, blue and alpha GL values of this Color component. - * - * @method Phaser.Display.Color#setGLTo - * @since 3.0.0 - * - * @param {float} red - The red color value. A number between 0 and 1. - * @param {float} green - The green color value. A number between 0 and 1. - * @param {float} blue - The blue color value. A number between 0 and 1. - * @param {float} [alpha=1] - The alpha value. A number between 0 and 1. - * - * @return {Phaser.Display.Color} This Color object. - */ - setGLTo: function (red, green, blue, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.redGL = red; - this.greenGL = green; - this.blueGL = blue; - this.alphaGL = alpha; - - return this.update(); - }, - - /** - * Sets the color based on the color object given. - * - * @method Phaser.Display.Color#setFromRGB - * @since 3.0.0 - * - * @param {InputColorObject} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. - * - * @return {Phaser.Display.Color} This Color object. - */ - setFromRGB: function (color) - { - this.red = color.r; - this.green = color.g; - this.blue = color.b; - - if (color.hasOwnProperty('a')) - { - this.alpha = color.a; - } - - return this.update(); - }, - - /** - * Updates the internal cache values. - * - * @method Phaser.Display.Color#update - * @since 3.0.0 - * - * @return {Phaser.Display.Color} This Color object. - */ - update: function () - { - this._color = GetColor(this.r, this.g, this.b); - this._color32 = GetColor32(this.r, this.g, this.b, this.a); - this._rgba = 'rgba(' + this.r + ',' + this.g + ',' + this.b + ',' + (this.a / 255) + ')'; - - return this; - }, - - /** - * Returns a new Color component using the values from this one. - * - * @method Phaser.Display.Color#clone - * @since 3.0.0 - * - * @return {Phaser.Display.Color} A new Color object. - */ - clone: function () - { - return new Color(this.r, this.g, this.b, this.a); - }, - - /** - * The color of this Color component, not including the alpha channel. - * - * @name Phaser.Display.Color#color - * @type {number} - * @readOnly - * @since 3.0.0 - */ - color: { - - get: function () - { - return this._color; - } - - }, - - /** - * The color of this Color component, including the alpha channel. - * - * @name Phaser.Display.Color#color32 - * @type {number} - * @readOnly - * @since 3.0.0 - */ - color32: { - - get: function () - { - return this._color32; - } - - }, - - /** - * The color of this Color component as a string which can be used in CSS color values. - * - * @name Phaser.Display.Color#rgba - * @type {string} - * @readOnly - * @since 3.0.0 - */ - rgba: { - - get: function () - { - return this._rgba; - } - - }, - - /** - * The red color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#redGL - * @type {float} - * @since 3.0.0 - */ - redGL: { - - get: function () - { - return this.gl[0]; - }, - - set: function (value) - { - this.gl[0] = Math.min(Math.abs(value), 1); - - this.r = Math.floor(this.gl[0] * 255); - - this.update(); - } - - }, - - /** - * The green color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#greenGL - * @type {float} - * @since 3.0.0 - */ - greenGL: { - - get: function () - { - return this.gl[1]; - }, - - set: function (value) - { - this.gl[1] = Math.min(Math.abs(value), 1); - - this.g = Math.floor(this.gl[1] * 255); - - this.update(); - } - - }, - - /** - * The blue color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#blueGL - * @type {float} - * @since 3.0.0 - */ - blueGL: { - - get: function () - { - return this.gl[2]; - }, - - set: function (value) - { - this.gl[2] = Math.min(Math.abs(value), 1); - - this.b = Math.floor(this.gl[2] * 255); - - this.update(); - } - - }, - - /** - * The alpha color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#alphaGL - * @type {float} - * @since 3.0.0 - */ - alphaGL: { - - get: function () - { - return this.gl[3]; - }, - - set: function (value) - { - this.gl[3] = Math.min(Math.abs(value), 1); - - this.a = Math.floor(this.gl[3] * 255); - - this.update(); - } - - }, - - /** - * The red color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#red - * @type {number} - * @since 3.0.0 - */ - red: { - - get: function () - { - return this.r; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.r = Math.min(value, 255); - - this.gl[0] = value / 255; - - this.update(); - } - - }, - - /** - * The green color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#green - * @type {number} - * @since 3.0.0 - */ - green: { - - get: function () - { - return this.g; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.g = Math.min(value, 255); - - this.gl[1] = value / 255; - - this.update(); - } - - }, - - /** - * The blue color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#blue - * @type {number} - * @since 3.0.0 - */ - blue: { - - get: function () - { - return this.b; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.b = Math.min(value, 255); - - this.gl[2] = value / 255; - - this.update(); - } - - }, - - /** - * The alpha color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#alpha - * @type {number} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this.a; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.a = Math.min(value, 255); - - this.gl[3] = value / 255; - - this.update(); - } - - } - -}); - -module.exports = Color; - - -/***/ }), -/* 31 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (rect, x, y) -{ - if (rect.width <= 0 || rect.height <= 0) - { - return false; - } - - return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); -}; - -module.exports = Contains; - - -/***/ }), -/* 32 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Circle contains the given x / y coordinates. - * - * @function Phaser.Geom.Circle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {number} x - The x coordinate to check within the circle. - * @param {number} y - The y coordinate to check within the circle. - * - * @return {boolean} True if the coordinates are within the circle, otherwise false. - */ -var Contains = function (circle, x, y) -{ - // Check if x/y are within the bounds first - if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) - { - var dx = (circle.x - x) * (circle.x - x); - var dy = (circle.y - y) * (circle.y - y); - - return (dx + dy) <= (circle.radius * circle.radius); - } - else - { - return false; - } -}; - -module.exports = Contains; - - -/***/ }), -/* 33 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Shallow Object Clone. Will not clone nested objects. - * - * @function Phaser.Utils.Object.Clone - * @since 3.0.0 - * - * @param {object} obj - the object from which to clone - * - * @return {object} a new object with the same properties as the input obj - */ -var Clone = function (obj) -{ - var clone = {}; - - for (var key in obj) - { - if (Array.isArray(obj[key])) - { - clone[key] = obj[key].slice(0); - } - else - { - clone[key] = obj[key]; - } - } - - return clone; -}; - -module.exports = Clone; - - -/***/ }), -/* 34 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var SpriteRender = __webpack_require__(556); - -/** - * @classdesc - * A Sprite Game Object. - * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - * - * @class Sprite - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Sprite = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - SpriteRender - ], - - initialize: - - function Sprite (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Sprite'); - - /** - * The Animation Controller of this Sprite. - * - * @name Phaser.GameObjects.Sprite#anims - * @type {Phaser.GameObjects.Components.Animation} - * @since 3.0.0 - */ - this.anims = new Components.Animation(this); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - }, - - /** - * Update this Sprite's animations. - * - * @method Phaser.GameObjects.Sprite#preUpdate - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp. - * @param {number} delta - The delta time, in ms, elapsed since the last frame. - */ - preUpdate: function (time, delta) - { - this.anims.update(time, delta); - }, - - /** - * Start playing the given animation. - * - * @method Phaser.GameObjects.Sprite#play - * @since 3.0.0 - * - * @param {string} key - The string-based key of the animation to play. - * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. - * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. - * - * @return {Phaser.GameObjects.Sprite} This Game Object. - */ - play: function (key, ignoreIfPlaying, startFrame) - { - this.anims.play(key, ignoreIfPlaying, startFrame); - - return this; - }, - - /** - * Build a JSON representation of this Sprite. - * - * @method Phaser.GameObjects.Sprite#toJSON - * @since 3.0.0 - * - * @return {JSONGameObject} A JSON representation of the Game Object. - */ - toJSON: function () - { - var data = Components.ToJSON(this); - - // Extra Sprite data is added here - - return data; - } - -}); - -module.exports = Sprite; - - -/***/ }), -/* 35 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, - * and then adds the given value to it. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` - * - * @function Phaser.Actions.PropertyValueInc - * @since 3.3.0 - * - * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] - * - * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. - * @param {string} key - The property to be updated. - * @param {number} value - The amount to be added to the property. - * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. - * @param {integer} [index=0] - An optional offset to start searching from within the items array. - * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. - * - * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. - */ -var PropertyValueInc = function (items, key, value, step, index, direction) -{ - if (step === undefined) { step = 0; } - if (index === undefined) { index = 0; } - if (direction === undefined) { direction = 1; } - - var i; - var t = 0; - var end = items.length; - - if (direction === 1) - { - // Start to End - for (i = index; i < end; i++) - { - items[i][key] += value + (t * step); - t++; - } - } - else - { - // End to Start - for (i = index; i >= 0; i--) - { - items[i][key] += value + (t * step); - t++; - } - } - - return items; -}; - -module.exports = PropertyValueInc; - - -/***/ }), -/* 36 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after - * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont. - * - * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. - * - * @class MultiFile - * @memberOf Phaser.Loader - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. - * @param {string} type - The file type string for sorting within the Loader. - * @param {string} key - The key of the file within the loader. - * @param {Phaser.Loader.File[]} files - An array of Files that make-up this MultiFile. - */ -var MultiFile = new Class({ - - initialize: - - function MultiFile (loader, type, key, files) - { - /** - * A reference to the Loader that is going to load this file. - * - * @name Phaser.Loader.MultiFile#loader - * @type {Phaser.Loader.LoaderPlugin} - * @since 3.7.0 - */ - this.loader = loader; - - /** - * The file type string for sorting within the Loader. - * - * @name Phaser.Loader.MultiFile#type - * @type {string} - * @since 3.7.0 - */ - this.type = type; - - /** - * Unique cache key (unique within its file type) - * - * @name Phaser.Loader.MultiFile#key - * @type {string} - * @since 3.7.0 - */ - this.key = key; - - /** - * Array of files that make up this MultiFile. - * - * @name Phaser.Loader.MultiFile#files - * @type {Phaser.Loader.File[]} - * @since 3.7.0 - */ - this.files = files; - - /** - * The completion status of this MultiFile. - * - * @name Phaser.Loader.MultiFile#complete - * @type {boolean} - * @default false - * @since 3.7.0 - */ - this.complete = false; - - /** - * The number of files to load. - * - * @name Phaser.Loader.MultiFile#pending - * @type {integer} - * @since 3.7.0 - */ - - this.pending = files.length; - - /** - * The number of files that failed to load. - * - * @name Phaser.Loader.MultiFile#failed - * @type {integer} - * @default 0 - * @since 3.7.0 - */ - this.failed = 0; - - /** - * A storage container for transient data that the loading files need. - * - * @name Phaser.Loader.MultiFile#config - * @type {any} - * @since 3.7.0 - */ - this.config = {}; - - // Link the files - for (var i = 0; i < files.length; i++) - { - files[i].multiFile = this; - } - }, - - /** - * Checks if this MultiFile is ready to process its children or not. - * - * @method Phaser.Loader.MultiFile#isReadyToProcess - * @since 3.7.0 - * - * @return {boolean} `true` if all children of this MultiFile have loaded, otherwise `false`. - */ - isReadyToProcess: function () - { - return (this.pending === 0 && this.failed === 0 && !this.complete); - }, - - /** - * Adds another child to this MultiFile, increases the pending count and resets the completion status. - * - * @method Phaser.Loader.MultiFile#addToMultiFile - * @since 3.7.0 - * - * @param {Phaser.Loader.File} files - The File to add to this MultiFile. - * - * @return {Phaser.Loader.MultiFile} This MultiFile instance. - */ - addToMultiFile: function (file) - { - this.files.push(file); - - file.multiFile = this; - - this.pending++; - - this.complete = false; - - return this; - }, - - /** - * Called by each File when it finishes loading. - * - * @method Phaser.Loader.MultiFile#onFileComplete - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The File that has completed processing. - */ - onFileComplete: function (file) - { - var index = this.files.indexOf(file); - - if (index !== -1) - { - this.pending--; - } - }, - - /** - * Called by each File that fails to load. - * - * @method Phaser.Loader.MultiFile#onFileFailed - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The File that has failed to load. - */ - onFileFailed: function (file) - { - var index = this.files.indexOf(file); - - if (index !== -1) - { - this.failed++; - } - } - -}); - -module.exports = MultiFile; - - -/***/ }), -/* 37 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.ImageFrameConfig - * - * @property {integer} frameWidth - The width of the frame in pixels. - * @property {integer} [frameHeight] - The height of the frame in pixels. Uses the `frameWidth` value if not provided. - * @property {integer} [startFrame=0] - The first frame to start parsing from. - * @property {integer} [endFrame] - The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions. - * @property {integer} [margin=0] - The margin in the image. This is the space around the edge of the frames. - * @property {integer} [spacing=0] - The spacing between each frame in the image. - */ - -/** - * @typedef {object} Phaser.Loader.FileTypes.ImageFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='png'] - The default file extension to use if no url is provided. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image. - * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Image File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. - * - * @class ImageFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. - */ -var ImageFile = new Class({ - - Extends: File, - - initialize: - - function ImageFile (loader, key, url, xhrSettings, frameConfig) - { - var extension = 'png'; - var normalMapURL; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - normalMapURL = GetFastValue(config, 'normalMap'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - frameConfig = GetFastValue(config, 'frameConfig'); - } - - if (Array.isArray(url)) - { - normalMapURL = url[1]; - url = url[0]; - } - - var fileConfig = { - type: 'image', - cache: loader.textureManager, - extension: extension, - responseType: 'blob', - key: key, - url: url, - xhrSettings: xhrSettings, - config: frameConfig - }; - - File.call(this, loader, fileConfig); - - // Do we have a normal map to load as well? - if (normalMapURL) - { - var normalMap = new ImageFile(loader, this.key, normalMapURL, xhrSettings, frameConfig); - - normalMap.type = 'normalMap'; - - this.setLink(normalMap); - - loader.addFile(normalMap); - } - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.ImageFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - var _this = this; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessComplete(); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessError(); - }; - - File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.ImageFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var texture; - var linkFile = this.linkFile; - - if (linkFile && linkFile.state === CONST.FILE_COMPLETE) - { - if (this.type === 'image') - { - texture = this.cache.addImage(this.key, this.data, linkFile.data); - } - else - { - texture = this.cache.addImage(linkFile.key, linkFile.data, this.data); - } - - this.pendingDestroy(texture); - - linkFile.pendingDestroy(texture); - } - else if (!linkFile) - { - texture = this.cache.addImage(this.key, this.data); - - this.pendingDestroy(texture); - } - } - -}); - -/** - * Adds an Image, or array of Images, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.image('logo', 'images/phaserLogo.png'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback - * of animated gifs to Canvas elements. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.image({ - * key: 'logo', - * url: 'images/AtariLogo.png' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.image('logo', 'images/AtariLogo.png'); - * // and later in your game ... - * this.add.image(x, y, 'logo'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.image({ - * key: 'logo', - * url: 'images/AtariLogo.png', - * normalMap: 'images/AtariLogo-n.png' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#image - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('image', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new ImageFile(this, key[i])); - } - } - else - { - this.addFile(new ImageFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = ImageFile; - - -/***/ }), -/* 38 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); - -/** - * Convert the given angle from degrees, to the equivalent angle in radians. - * - * @function Phaser.Math.DegToRad - * @since 3.0.0 - * - * @param {integer} degrees - The angle (in degrees) to convert to radians. - * - * @return {float} The given angle converted to radians. - */ -var DegToRad = function (degrees) -{ - return degrees * CONST.DEG_TO_RAD; -}; - -module.exports = DegToRad; - - -/***/ }), -/* 39 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Wrap the given `value` between `min` and `max. - * - * @function Phaser.Math.Wrap - * @since 3.0.0 - * - * @param {number} value - The value to wrap. - * @param {number} min - The minimum value. - * @param {number} max - The maximum value. - * - * @return {number} The wrapped value. - */ -var Wrap = function (value, min, max) -{ - var range = max - min; - - return (min + ((((value - min) % range) + range) % range)); -}; - -module.exports = Wrap; - - -/***/ }), -/* 40 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTileAt = __webpack_require__(140); -var GetTilesWithin = __webpack_require__(21); - -/** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @function Phaser.Tilemaps.Components.CalculateFacesWithin - * @private - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var CalculateFacesWithin = function (tileX, tileY, width, height, layer) -{ - var above = null; - var below = null; - var left = null; - var right = null; - - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - if (tile) - { - if (tile.collides) - { - above = GetTileAt(tile.x, tile.y - 1, true, layer); - below = GetTileAt(tile.x, tile.y + 1, true, layer); - left = GetTileAt(tile.x - 1, tile.y, true, layer); - right = GetTileAt(tile.x + 1, tile.y, true, layer); - - tile.faceTop = (above && above.collides) ? false : true; - tile.faceBottom = (below && below.collides) ? false : true; - tile.faceLeft = (left && left.collides) ? false : true; - tile.faceRight = (right && right.collides) ? false : true; - } - else - { - tile.resetFaces(); - } - } - } -}; - -module.exports = CalculateFacesWithin; - - -/***/ }), -/* 41 */, -/* 42 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Arcade Physics consts. - * - * @ignore - */ - -var CONST = { - - /** - * [description] - * - * @name Phaser.Physics.Arcade.DYNAMIC_BODY - * @readOnly - * @type {number} - * @since 3.0.0 - */ - DYNAMIC_BODY: 0, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.STATIC_BODY - * @readOnly - * @type {number} - * @since 3.0.0 - */ - STATIC_BODY: 1, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.GROUP - * @readOnly - * @type {number} - * @since 3.0.0 - */ - GROUP: 2, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.TILEMAPLAYER - * @readOnly - * @type {number} - * @since 3.0.0 - */ - TILEMAPLAYER: 3, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_NONE - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_NONE: 10, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_UP - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_UP: 11, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_DOWN - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_DOWN: 12, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_LEFT - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_LEFT: 13, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_RIGHT - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_RIGHT: 14 - -}; - -module.exports = CONST; - - -/***/ }), -/* 43 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the top of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetTop - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetTop = function (gameObject, value) -{ - gameObject.y = value + (gameObject.height * gameObject.originY); - - return gameObject; -}; - -module.exports = SetTop; - - -/***/ }), -/* 44 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the top coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The top coordinate of the bounds of the Game Object. - */ -var GetTop = function (gameObject) -{ - return gameObject.y - (gameObject.height * gameObject.originY); -}; - -module.exports = GetTop; - - -/***/ }), -/* 45 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetRight = function (gameObject, value) -{ - gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); - - return gameObject; -}; - -module.exports = SetRight; - - -/***/ }), -/* 46 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the right coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The right coordinate of the bounds of the Game Object. - */ -var GetRight = function (gameObject) -{ - return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); -}; - -module.exports = GetRight; - - -/***/ }), -/* 47 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetLeft = function (gameObject, value) -{ - gameObject.x = value + (gameObject.width * gameObject.originX); - - return gameObject; -}; - -module.exports = SetLeft; - - -/***/ }), -/* 48 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the left coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The left coordinate of the bounds of the Game Object. - */ -var GetLeft = function (gameObject) -{ - return gameObject.x - (gameObject.width * gameObject.originX); -}; - -module.exports = GetLeft; - - -/***/ }), -/* 49 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetBottom - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetBottom = function (gameObject, value) -{ - gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); - - return gameObject; -}; - -module.exports = SetBottom; - - -/***/ }), -/* 50 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the bottom coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetBottom - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The bottom coordinate of the bounds of the Game Object. - */ -var GetBottom = function (gameObject) -{ - return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); -}; - -module.exports = GetBottom; - - -/***/ }), -/* 51 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Phaser Blend Modes. - * - * @name Phaser.BlendModes - * @enum {integer} - * @memberOf Phaser - * @readOnly - * @since 3.0.0 - */ - -module.exports = { - - /** - * Skips the Blend Mode check in the renderer. - * - * @name Phaser.BlendModes.SKIP_CHECK - */ - SKIP_CHECK: -1, - - /** - * Normal blend mode. - * - * @name Phaser.BlendModes.NORMAL - */ - NORMAL: 0, - - /** - * Add blend mode. - * - * @name Phaser.BlendModes.ADD - */ - ADD: 1, - - /** - * Multiply blend mode. - * - * @name Phaser.BlendModes.MULTIPLY - */ - MULTIPLY: 2, - - /** - * Screen blend mode. - * - * @name Phaser.BlendModes.SCREEN - */ - SCREEN: 3, - - /** - * Overlay blend mode. - * - * @name Phaser.BlendModes.OVERLAY - */ - OVERLAY: 4, - - /** - * Darken blend mode. - * - * @name Phaser.BlendModes.DARKEN - */ - DARKEN: 5, - - /** - * Lighten blend mode. - * - * @name Phaser.BlendModes.LIGHTEN - */ - LIGHTEN: 6, - - /** - * Color Dodge blend mode. - * - * @name Phaser.BlendModes.COLOR_DODGE - */ - COLOR_DODGE: 7, - - /** - * Color Burn blend mode. - * - * @name Phaser.BlendModes.COLOR_BURN - */ - COLOR_BURN: 8, - - /** - * Hard Light blend mode. - * - * @name Phaser.BlendModes.HARD_LIGHT - */ - HARD_LIGHT: 9, - - /** - * Soft Light blend mode. - * - * @name Phaser.BlendModes.SOFT_LIGHT - */ - SOFT_LIGHT: 10, - - /** - * Difference blend mode. - * - * @name Phaser.BlendModes.DIFFERENCE - */ - DIFFERENCE: 11, - - /** - * Exclusion blend mode. - * - * @name Phaser.BlendModes.EXCLUSION - */ - EXCLUSION: 12, - - /** - * Hue blend mode. - * - * @name Phaser.BlendModes.HUE - */ - HUE: 13, - - /** - * Saturation blend mode. - * - * @name Phaser.BlendModes.SATURATION - */ - SATURATION: 14, - - /** - * Color blend mode. - * - * @name Phaser.BlendModes.COLOR - */ - COLOR: 15, - - /** - * Luminosity blend mode. - * - * @name Phaser.BlendModes.LUMINOSITY - */ - LUMINOSITY: 16 - -}; - - /***/ }), /* 52 */ /***/ (function(module, exports) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.WorldToTileY - * @private - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} The Y location in tile units. - */ -var WorldToTileY = function (worldY, snapToFloor, camera, layer) -{ - if (snapToFloor === undefined) { snapToFloor = true; } - - var tileHeight = layer.baseTileHeight; - var tilemapLayer = layer.tilemapLayer; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - // Find the world position relative to the static or dynamic layer's top left origin, - // factoring in the camera's vertical scroll - worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); - - tileHeight *= tilemapLayer.scaleY; - } - - return snapToFloor - ? Math.floor(worldY / tileHeight) - : worldY / tileHeight; -}; - -module.exports = WorldToTileY; - - -/***/ }), -/* 53 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.WorldToTileX - * @private - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} The X location in tile units. - */ -var WorldToTileX = function (worldX, snapToFloor, camera, layer) -{ - if (snapToFloor === undefined) { snapToFloor = true; } - - var tileWidth = layer.baseTileWidth; - var tilemapLayer = layer.tilemapLayer; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - // Find the world position relative to the static or dynamic layer's top left origin, - // factoring in the camera's horizontal scroll - worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX)); - - tileWidth *= tilemapLayer.scaleX; - } - - return snapToFloor - ? Math.floor(worldX / tileWidth) - : worldX / tileWidth; -}; - -module.exports = WorldToTileX; - - -/***/ }), -/* 54 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Ellipse contains the given x / y coordinates. - * - * @function Phaser.Geom.Ellipse.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {number} x - The x coordinate to check within the ellipse. - * @param {number} y - The y coordinate to check within the ellipse. - * - * @return {boolean} True if the coordinates are within the ellipse, otherwise false. - */ -var Contains = function (ellipse, x, y) -{ - if (ellipse.width <= 0 || ellipse.height <= 0) - { - return false; - } - - // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 - var normx = ((x - ellipse.x) / ellipse.width); - var normy = ((y - ellipse.y) / ellipse.height); - - normx *= normx; - normy *= normy; - - return (normx + normy < 0.25); -}; - -module.exports = Contains; - - -/***/ }), -/* 55 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Scene consts. - * - * @ignore - */ - -var CONST = { - - /** - * Scene state. - * - * @name Phaser.Scenes.PENDING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - PENDING: 0, - - /** - * Scene state. - * - * @name Phaser.Scenes.INIT - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - INIT: 1, - - /** - * Scene state. - * - * @name Phaser.Scenes.START - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - START: 2, - - /** - * Scene state. - * - * @name Phaser.Scenes.LOADING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - LOADING: 3, - - /** - * Scene state. - * - * @name Phaser.Scenes.CREATING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - CREATING: 4, - - /** - * Scene state. - * - * @name Phaser.Scenes.RUNNING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - RUNNING: 5, - - /** - * Scene state. - * - * @name Phaser.Scenes.PAUSED - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - PAUSED: 6, - - /** - * Scene state. - * - * @name Phaser.Scenes.SLEEPING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - SLEEPING: 7, - - /** - * Scene state. - * - * @name Phaser.Scenes.SHUTDOWN - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - SHUTDOWN: 8, - - /** - * Scene state. - * - * @name Phaser.Scenes.DESTROYED - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - DESTROYED: 9 - -}; - -module.exports = CONST; - - -/***/ }), -/* 56 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Removes a single item from an array and returns it without creating gc, like the native splice does. - * Based on code by Mike Reinstein. - * - * @function Phaser.Utils.Array.SpliceOne - * @since 3.0.0 - * - * @param {array} array - [description] - * @param {integer} index - [description] - * - * @return {*} [description] - */ -var SpliceOne = function (array, index) -{ - if (index >= array.length) - { - return; - } - - var len = array.length - 1; - - var item = array[index]; - - for (var i = index; i < len; i++) - { - array[i] = array[i + 1]; - } - - array.length = len; - - return item; -}; - -module.exports = SpliceOne; - - -/***/ }), -/* 57 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process) {/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the operating system of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.os` from within any Scene. - * - * @typedef {object} Phaser.Device.OS - * @since 3.0.0 - * - * @property {boolean} android - Is running on android? - * @property {boolean} chromeOS - Is running on chromeOS? - * @property {boolean} cocoonJS - Is the game running under CocoonJS? - * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? - * @property {boolean} cordova - Is the game running under Apache Cordova? - * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? - * @property {boolean} desktop - Is running on a desktop? - * @property {boolean} ejecta - Is the game running under Ejecta? - * @property {boolean} electron - Is the game running under GitHub Electron? - * @property {boolean} iOS - Is running on iOS? - * @property {boolean} iPad - Is running on iPad? - * @property {boolean} iPhone - Is running on iPhone? - * @property {boolean} kindle - Is running on an Amazon Kindle? - * @property {boolean} linux - Is running on linux? - * @property {boolean} macOS - Is running on macOS? - * @property {boolean} node - Is the game running under Node.js? - * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? - * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView - * @property {boolean} windows - Is running on windows? - * @property {boolean} windowsPhone - Is running on a Windows Phone? - * @property {number} iOSVersion - If running in iOS this will contain the major version number. - * @property {number} pixelRatio - PixelRatio of the host device? - */ -var OS = { - - android: false, - chromeOS: false, - cocoonJS: false, - cocoonJSApp: false, - cordova: false, - crosswalk: false, - desktop: false, - ejecta: false, - electron: false, - iOS: false, - iOSVersion: 0, - iPad: false, - iPhone: false, - kindle: false, - linux: false, - macOS: false, - node: false, - nodeWebkit: false, - pixelRatio: 1, - webApp: false, - windows: false, - windowsPhone: false - -}; - -function init () -{ - var ua = navigator.userAgent; - - if (/Windows/.test(ua)) - { - OS.windows = true; - } - else if (/Mac OS/.test(ua)) - { - OS.macOS = true; - } - else if (/Android/.test(ua)) - { - OS.android = true; - } - else if (/Linux/.test(ua)) - { - OS.linux = true; - } - else if (/iP[ao]d|iPhone/i.test(ua)) - { - OS.iOS = true; - (navigator.appVersion).match(/OS (\d+)/); - OS.iOSVersion = parseInt(RegExp.$1, 10); - } - else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) - { - OS.kindle = true; - - // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... - // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" - } - else if (/CrOS/.test(ua)) - { - OS.chromeOS = true; - } - - if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) - { - OS.android = false; - OS.iOS = false; - OS.macOS = false; - OS.windows = true; - OS.windowsPhone = true; - } - - var silk = (/Silk/).test(ua); - - if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) - { - OS.desktop = true; - } - - // Windows Phone / Table reset - if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) - { - OS.desktop = false; - } - - // WebApp mode in iOS - if (navigator.standalone) - { - OS.webApp = true; - } - - if (window.cordova !== undefined) - { - OS.cordova = true; - } - - if (process && process.versions && process.versions.node) - { - OS.node = true; - } - - if (OS.node && typeof process.versions === 'object') - { - OS.nodeWebkit = !!process.versions['node-webkit']; - - OS.electron = !!process.versions.electron; - } - - if (navigator.isCocoonJS) - { - OS.cocoonJS = true; - - try - { - OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); - } - catch (error) - { - OS.cocoonJSApp = false; - } - } - - if (window.ejecta !== undefined) - { - OS.ejecta = true; - } - - if ((/Crosswalk/).test(ua)) - { - OS.crosswalk = true; - } - - OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; - OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; - - OS.pixelRatio = window['devicePixelRatio'] || 1; - - return OS; -} - -module.exports = init(); - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(537))) - -/***/ }), -/* 58 */ -/***/ (function(module, exports) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -7967,7 +8448,7 @@ module.exports = DistanceBetween; /***/ }), -/* 59 */ +/* 53 */ /***/ (function(module, exports) { /** @@ -7977,371 +8458,29 @@ module.exports = DistanceBetween; */ /** - * Phaser Scale Modes. - * - * @name Phaser.ScaleModes - * @enum {integer} - * @memberOf Phaser - * @readOnly - * @since 3.0.0 - */ - -module.exports = { - - /** - * Default Scale Mode (Linear). - * - * @name Phaser.ScaleModes.DEFAULT - */ - DEFAULT: 0, - - /** - * Linear Scale Mode. - * - * @name Phaser.ScaleModes.LINEAR - */ - LINEAR: 0, - - /** - * Nearest Scale Mode. - * - * @name Phaser.ScaleModes.NEAREST - */ - NEAREST: 1 - -}; - - -/***/ }), -/* 60 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// http://www.blackpawn.com/texts/pointinpoly/ - -/** - * [description] + * Wrap the given `value` between `min` and `max. * - * @function Phaser.Geom.Triangle.Contains + * @function Phaser.Math.Wrap * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} value - The value to wrap. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. * - * @return {boolean} [description] + * @return {number} The wrapped value. */ -var Contains = function (triangle, x, y) +var Wrap = function (value, min, max) { - var v0x = triangle.x3 - triangle.x1; - var v0y = triangle.y3 - triangle.y1; + var range = max - min; - var v1x = triangle.x2 - triangle.x1; - var v1y = triangle.y2 - triangle.y1; - - var v2x = x - triangle.x1; - var v2y = y - triangle.y1; - - var dot00 = (v0x * v0x) + (v0y * v0y); - var dot01 = (v0x * v1x) + (v0y * v1y); - var dot02 = (v0x * v2x) + (v0y * v2y); - var dot11 = (v1x * v1x) + (v1y * v1y); - var dot12 = (v1x * v2x) + (v1y * v2y); - - // Compute barycentric coordinates - var b = ((dot00 * dot11) - (dot01 * dot01)); - var inv = (b === 0) ? 0 : (1 / b); - var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; - var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; - - return (u >= 0 && v >= 0 && (u + v < 1)); + return (min + ((((value - min) % range) + range) % range)); }; -module.exports = Contains; +module.exports = Wrap; /***/ }), -/* 61 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TWEEN_CONST = { - - /** - * TweenData state. - * - * @name Phaser.Tweens.CREATED - * @type {integer} - * @since 3.0.0 - */ - CREATED: 0, - - /** - * TweenData state. - * - * @name Phaser.Tweens.INIT - * @type {integer} - * @since 3.0.0 - */ - INIT: 1, - - /** - * TweenData state. - * - * @name Phaser.Tweens.DELAY - * @type {integer} - * @since 3.0.0 - */ - DELAY: 2, - - /** - * TweenData state. - * - * @name Phaser.Tweens.OFFSET_DELAY - * @type {integer} - * @since 3.0.0 - */ - OFFSET_DELAY: 3, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PENDING_RENDER - * @type {integer} - * @since 3.0.0 - */ - PENDING_RENDER: 4, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PLAYING_FORWARD - * @type {integer} - * @since 3.0.0 - */ - PLAYING_FORWARD: 5, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PLAYING_BACKWARD - * @type {integer} - * @since 3.0.0 - */ - PLAYING_BACKWARD: 6, - - /** - * TweenData state. - * - * @name Phaser.Tweens.HOLD_DELAY - * @type {integer} - * @since 3.0.0 - */ - HOLD_DELAY: 7, - - /** - * TweenData state. - * - * @name Phaser.Tweens.REPEAT_DELAY - * @type {integer} - * @since 3.0.0 - */ - REPEAT_DELAY: 8, - - /** - * TweenData state. - * - * @name Phaser.Tweens.COMPLETE - * @type {integer} - * @since 3.0.0 - */ - COMPLETE: 9, - - // Tween specific (starts from 20 to cleanly allow extra TweenData consts in the future) - - /** - * Tween state. - * - * @name Phaser.Tweens.PENDING_ADD - * @type {integer} - * @since 3.0.0 - */ - PENDING_ADD: 20, - - /** - * Tween state. - * - * @name Phaser.Tweens.PAUSED - * @type {integer} - * @since 3.0.0 - */ - PAUSED: 21, - - /** - * Tween state. - * - * @name Phaser.Tweens.LOOP_DELAY - * @type {integer} - * @since 3.0.0 - */ - LOOP_DELAY: 22, - - /** - * Tween state. - * - * @name Phaser.Tweens.ACTIVE - * @type {integer} - * @since 3.0.0 - */ - ACTIVE: 23, - - /** - * Tween state. - * - * @name Phaser.Tweens.COMPLETE_DELAY - * @type {integer} - * @since 3.0.0 - */ - COMPLETE_DELAY: 24, - - /** - * Tween state. - * - * @name Phaser.Tweens.PENDING_REMOVE - * @type {integer} - * @since 3.0.0 - */ - PENDING_REMOVE: 25, - - /** - * Tween state. - * - * @name Phaser.Tweens.REMOVED - * @type {integer} - * @since 3.0.0 - */ - REMOVED: 26 - -}; - -module.exports = TWEEN_CONST; - - -/***/ }), -/* 62 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetBoolean - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {*} [description] - */ -var GetBoolean = function (source, key, defaultValue) -{ - if (!source) - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else - { - return defaultValue; - } -}; - -module.exports = GetBoolean; - - -/***/ }), -/* 63 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var EaseMap = __webpack_require__(453); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetEaseFunction - * @since 3.0.0 - * - * @param {(string|function)} ease - [description] - * @param {array} easeParams - [description] - * - * @return {function} [description] - */ -var GetEaseFunction = function (ease, easeParams) -{ - if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) - { - if (easeParams) - { - var cloneParams = easeParams.slice(0); - - cloneParams.unshift(0); - - return function (v) - { - cloneParams[0] = v; - - return EaseMap[ease].apply(this, cloneParams); - }; - } - else - { - // String based look-up - return EaseMap[ease]; - } - } - else if (typeof ease === 'function') - { - // Custom function - return ease; - } - else if (Array.isArray(ease) && ease.length === 4) - { - // Bezier function (TODO) - } - - return EaseMap.Power0; -}; - -module.exports = GetEaseFunction; - - -/***/ }), -/* 64 */ +/* 54 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -8351,628 +8490,322 @@ module.exports = GetEaseFunction; */ var Class = __webpack_require__(0); +var GetPoint = __webpack_require__(397); +var GetPoints = __webpack_require__(189); +var Random = __webpack_require__(188); +var Vector2 = __webpack_require__(3); /** * @classdesc - * [description] + * Defines a Line segment, a part of a line between two endpoints. * - * @class TransformMatrix - * @memberOf Phaser.GameObjects.Components + * @class Line + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * - * @param {number} [a=1] - The Scale X value. - * @param {number} [b=0] - The Shear Y value. - * @param {number} [c=0] - The Shear X value. - * @param {number} [d=1] - The Scale Y value. - * @param {number} [tx=0] - The Translate X value. - * @param {number} [ty=0] - The Translate Y value. + * @param {number} [x1=0] - The x coordinate of the lines starting point. + * @param {number} [y1=0] - The y coordinate of the lines starting point. + * @param {number} [x2=0] - The x coordinate of the lines ending point. + * @param {number} [y2=0] - The y coordinate of the lines ending point. */ -var TransformMatrix = new Class({ +var Line = new Class({ initialize: - function TransformMatrix (a, b, c, d, tx, ty) + function Line (x1, y1, x2, y2) { - if (a === undefined) { a = 1; } - if (b === undefined) { b = 0; } - if (c === undefined) { c = 0; } - if (d === undefined) { d = 1; } - if (tx === undefined) { tx = 0; } - if (ty === undefined) { ty = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } /** - * [description] + * The x coordinate of the lines starting point. * - * @name Phaser.GameObjects.Components.TransformMatrix#matrix - * @type {Float32Array} + * @name Phaser.Geom.Line#x1 + * @type {number} * @since 3.0.0 */ - this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + this.x1 = x1; /** - * [description] + * The y coordinate of the lines starting point. * - * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix - * @type {object} + * @name Phaser.Geom.Line#y1 + * @type {number} * @since 3.0.0 */ - this.decomposedMatrix = { - translateX: 0, - translateY: 0, - scaleX: 1, - scaleY: 1, - rotation: 0 - }; + this.y1 = y1; + + /** + * The x coordinate of the lines ending point. + * + * @name Phaser.Geom.Line#x2 + * @type {number} + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * The y coordinate of the lines ending point. + * + * @name Phaser.Geom.Line#y2 + * @type {number} + * @since 3.0.0 + */ + this.y2 = y2; }, /** - * [description] + * Get a point on a line that's a given percentage along its length. * - * @name Phaser.GameObjects.Components.TransformMatrix#a - * @type {number} - * @since 3.4.0 + * @method Phaser.Geom.Line#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {(Phaser.Geom.Point|object)} [output] - An optional point, or point-like object, to store the coordinates of the point on the line. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point on the line. */ - a: { + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * @method Phaser.Geom.Line#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {integer} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {integer} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param {(array|Phaser.Geom.Point[])} [output] - An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * + * @return {(array|Phaser.Geom.Point[])} An array of Points, or point-like objects, containing the coordinates of the points on the line. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Get a random Point on the Line. + * + * @method Phaser.Geom.Line#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {(Phaser.Geom.Point|object)} [point] - An instance of a Point to be modified. + * + * @return {Phaser.Geom.Point} A random Point on the Line. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Set new coordinates for the line endpoints. + * + * @method Phaser.Geom.Line#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - The x coordinate of the lines starting point. + * @param {number} [y1=0] - The y coordinate of the lines starting point. + * @param {number} [x2=0] - The x coordinate of the lines ending point. + * @param {number} [y2=0] - The y coordinate of the lines ending point. + * + * @return {Phaser.Geom.Line} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + return this; + }, + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * + * @method Phaser.Geom.Line#getPointA + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + */ + getPointA: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x1, this.y1); + + return vec2; + }, + + /** + * Returns a Vector2 object that corresponds to the end of this Line. + * + * @method Phaser.Geom.Line#getPointB + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the end of this Line. + */ + getPointB: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x2, this.y2); + + return vec2; + }, + + /** + * The left position of the Line. + * + * @name Phaser.Geom.Line#left + * @type {number} + * @since 3.0.0 + */ + left: { get: function () { - return this.matrix[0]; + return Math.min(this.x1, this.x2); }, set: function (value) { - this.matrix[0] = value; + if (this.x1 <= this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } } }, /** - * [description] + * The right position of the Line. * - * @name Phaser.GameObjects.Components.TransformMatrix#b + * @name Phaser.Geom.Line#right * @type {number} - * @since 3.4.0 + * @since 3.0.0 */ - b: { + right: { get: function () { - return this.matrix[1]; + return Math.max(this.x1, this.x2); }, set: function (value) { - this.matrix[1] = value; + if (this.x1 > this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } } }, /** - * [description] + * The top position of the Line. * - * @name Phaser.GameObjects.Components.TransformMatrix#c + * @name Phaser.Geom.Line#top * @type {number} - * @since 3.4.0 + * @since 3.0.0 */ - c: { + top: { get: function () { - return this.matrix[2]; + return Math.min(this.y1, this.y2); }, set: function (value) { - this.matrix[2] = value; + if (this.y1 <= this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } } }, /** - * [description] + * The bottom position of the Line. * - * @name Phaser.GameObjects.Components.TransformMatrix#d + * @name Phaser.Geom.Line#bottom * @type {number} - * @since 3.4.0 + * @since 3.0.0 */ - d: { + bottom: { get: function () { - return this.matrix[3]; + return Math.max(this.y1, this.y2); }, set: function (value) { - this.matrix[3] = value; + if (this.y1 > this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } } - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#tx - * @type {number} - * @since 3.4.0 - */ - tx: { - - get: function () - { - return this.matrix[4]; - }, - - set: function (value) - { - this.matrix[4] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#ty - * @type {number} - * @since 3.4.0 - */ - ty: { - - get: function () - { - return this.matrix[5]; - }, - - set: function (value) - { - this.matrix[5] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#rotation - * @type {number} - * @readOnly - * @since 3.4.0 - */ - rotation: { - - get: function () - { - return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1); - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#scaleX - * @type {number} - * @readOnly - * @since 3.4.0 - */ - scaleX: { - - get: function () - { - return Math.sqrt((this.a * this.a) + (this.c * this.c)); - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#scaleY - * @type {number} - * @readOnly - * @since 3.4.0 - */ - scaleY: { - - get: function () - { - return Math.sqrt((this.b * this.b) + (this.d * this.d)); - } - - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity - * @since 3.0.0 - * - * @return {this} This TransformMatrix. - */ - loadIdentity: function () - { - var matrix = this.matrix; - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 1; - matrix[4] = 0; - matrix[5] = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#translate - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {this} This TransformMatrix. - */ - translate: function (x, y) - { - var matrix = this.matrix; - - matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; - matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#scale - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {this} This TransformMatrix. - */ - scale: function (x, y) - { - var matrix = this.matrix; - - matrix[0] *= x; - matrix[1] *= x; - matrix[2] *= y; - matrix[3] *= y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#rotate - * @since 3.0.0 - * - * @param {number} radian - [description] - * - * @return {this} This TransformMatrix. - */ - rotate: function (radian) - { - var radianSin = Math.sin(radian); - var radianCos = Math.cos(radian); - var matrix = this.matrix; - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - - matrix[0] = a * radianCos + c * radianSin; - matrix[1] = b * radianCos + d * radianSin; - matrix[2] = a * -radianSin + c * radianCos; - matrix[3] = b * -radianSin + d * radianCos; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#multiply - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - [description] - * - * @return {this} This TransformMatrix. - */ - multiply: function (rhs) - { - var matrix = this.matrix; - var otherMatrix = rhs.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - var a1 = otherMatrix[0]; - var b1 = otherMatrix[1]; - var c1 = otherMatrix[2]; - var d1 = otherMatrix[3]; - var tx1 = otherMatrix[4]; - var ty1 = otherMatrix[5]; - - matrix[0] = a1 * a0 + b1 * c0; - matrix[1] = a1 * b0 + b1 * d0; - matrix[2] = c1 * a0 + d1 * c0; - matrix[3] = c1 * b0 + d1 * d0; - matrix[4] = tx1 * a0 + ty1 * c0 + tx0; - matrix[5] = tx1 * b0 + ty1 * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transform - * @since 3.0.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This TransformMatrix. - */ - transform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - matrix[0] = a * a0 + b * c0; - matrix[1] = a * b0 + b * d0; - matrix[2] = c * a0 + d * c0; - matrix[3] = c * b0 + d * d0; - matrix[4] = tx * a0 + ty * c0 + tx0; - matrix[5] = tx * b0 + ty * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - [description] - * - * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} [description] - */ - transformPoint: function (x, y, point) - { - if (point === undefined) { point = { x: 0, y: 0 }; } - - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - point.x = x * a + y * c + tx; - point.y = x * b + y * d + ty; - - return point; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#invert - * @since 3.0.0 - * - * @return {this} This TransformMatrix. - */ - invert: function () - { - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - var n = a * d - b * c; - - matrix[0] = d / n; - matrix[1] = -b / n; - matrix[2] = -c / n; - matrix[3] = a / n; - matrix[4] = (c * ty - d * tx) / n; - matrix[5] = -(a * ty - b * tx) / n; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#setTransform - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {this} This TransformMatrix. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - matrix[0] = a; - matrix[1] = b; - matrix[2] = c; - matrix[3] = d; - matrix[4] = tx; - matrix[5] = ty; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix - * @since 3.0.0 - * - * @return {object} [description] - */ - decomposeMatrix: function () - { - var decomposedMatrix = this.decomposedMatrix; - - var matrix = this.matrix; - - // a = scale X (1) - // b = shear Y (0) - // c = shear X (0) - // d = scale Y (1) - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - - var a2 = a * a; - var b2 = b * b; - var c2 = c * c; - var d2 = d * d; - - var sx = Math.sqrt(a2 + c2); - var sy = Math.sqrt(b2 + d2); - - decomposedMatrix.translateX = matrix[4]; - decomposedMatrix.translateY = matrix[5]; - - decomposedMatrix.scaleX = sx; - decomposedMatrix.scaleY = sy; - - decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); - - return decomposedMatrix; - }, - - /** - * Identity + Translate + Rotate + Scale - * - * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} rotation - [description] - * @param {number} scaleX - [description] - * @param {number} scaleY - [description] - * - * @return {this} This TransformMatrix. - */ - applyITRS: function (x, y, rotation, scaleX, scaleY) - { - var matrix = this.matrix; - - var radianSin = Math.sin(rotation); - var radianCos = Math.cos(rotation); - - // Translate - matrix[4] = x; - matrix[5] = y; - - // Rotate and Scale - matrix[0] = radianCos * scaleX; - matrix[1] = radianSin * scaleX; - matrix[2] = -radianSin * scaleY; - matrix[3] = radianCos * scaleY; - - return this; - }, - - /** - * Destroys this Transform Matrix. - * - * @method Phaser.GameObjects.Components.TransformMatrix#destroy - * @since 3.4.0 - */ - destroy: function () - { - this.matrix = null; - this.decomposedMatrix = null; } }); -module.exports = TransformMatrix; +module.exports = Line; /***/ }), -/* 65 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); - -/** - * Return a value based on the range between `min` and `max` and the percentage given. - * - * @function Phaser.Math.FromPercent - * @since 3.0.0 - * - * @param {float} percent - A value between 0 and 1 representing the percentage. - * @param {number} min - The minimum value. - * @param {number} [max] - The maximum value. - * - * @return {number} The value that is `percent` percent between `min` and `max`. - */ -var FromPercent = function (percent, min, max) -{ - percent = Clamp(percent, 0, 1); - - return (max - min) * percent; -}; - -module.exports = FromPercent; - - -/***/ }), -/* 66 */ +/* 55 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -8982,8 +8815,8 @@ module.exports = FromPercent; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var Rectangle = __webpack_require__(389); +var Components = __webpack_require__(14); +var Rectangle = __webpack_require__(265); /** * @classdesc @@ -8992,7 +8825,7 @@ var Rectangle = __webpack_require__(389); * scale or layer position. * * @class Tile - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -9697,7 +9530,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#canCollide * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ canCollide: { @@ -9712,7 +9545,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#collides * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ collides: { @@ -9727,7 +9560,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#hasInterestingFace * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ hasInterestingFace: { @@ -9743,7 +9576,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#tileset * @type {?Phaser.Tilemaps.Tileset} - * @readOnly + * @readonly * @since 3.0.0 */ tileset: { @@ -9761,7 +9594,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#tilemapLayer * @type {?Phaser.Tilemaps.StaticTilemapLayer|Phaser.Tilemaps.DynamicTilemapLayer} - * @readOnly + * @readonly * @since 3.0.0 */ tilemapLayer: { @@ -9777,7 +9610,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#tilemap * @type {?Phaser.Tilemaps.Tilemap} - * @readOnly + * @readonly * @since 3.0.0 */ tilemap: { @@ -9794,7 +9627,7 @@ module.exports = Tile; /***/ }), -/* 67 */ +/* 56 */ /***/ (function(module, exports) { /** @@ -9811,8 +9644,8 @@ module.exports = Tile; * @private * @since 3.0.0 * - * @param {Phaser.Tilemaps.Tile} tile - [description] - * @param {boolean} [collides=true] - [description] + * @param {Phaser.Tilemaps.Tile} tile - The Tile to set the collision on. + * @param {boolean} [collides=true] - Should the tile index collide or not? */ var SetTileCollision = function (tile, collides) { @@ -9830,7 +9663,7 @@ module.exports = SetTileCollision; /***/ }), -/* 68 */ +/* 57 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -9840,11 +9673,501 @@ module.exports = SetTileCollision; */ var Class = __webpack_require__(0); -var Contains = __webpack_require__(60); -var GetPoint = __webpack_require__(227); -var GetPoints = __webpack_require__(226); -var Line = __webpack_require__(96); -var Random = __webpack_require__(153); + +/** + * @classdesc + * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after + * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont. + * + * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. + * + * @class MultiFile + * @memberof Phaser.Loader + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. + * @param {string} type - The file type string for sorting within the Loader. + * @param {string} key - The key of the file within the loader. + * @param {Phaser.Loader.File[]} files - An array of Files that make-up this MultiFile. + */ +var MultiFile = new Class({ + + initialize: + + function MultiFile (loader, type, key, files) + { + /** + * A reference to the Loader that is going to load this file. + * + * @name Phaser.Loader.MultiFile#loader + * @type {Phaser.Loader.LoaderPlugin} + * @since 3.7.0 + */ + this.loader = loader; + + /** + * The file type string for sorting within the Loader. + * + * @name Phaser.Loader.MultiFile#type + * @type {string} + * @since 3.7.0 + */ + this.type = type; + + /** + * Unique cache key (unique within its file type) + * + * @name Phaser.Loader.MultiFile#key + * @type {string} + * @since 3.7.0 + */ + this.key = key; + + /** + * Array of files that make up this MultiFile. + * + * @name Phaser.Loader.MultiFile#files + * @type {Phaser.Loader.File[]} + * @since 3.7.0 + */ + this.files = files; + + /** + * The completion status of this MultiFile. + * + * @name Phaser.Loader.MultiFile#complete + * @type {boolean} + * @default false + * @since 3.7.0 + */ + this.complete = false; + + /** + * The number of files to load. + * + * @name Phaser.Loader.MultiFile#pending + * @type {integer} + * @since 3.7.0 + */ + + this.pending = files.length; + + /** + * The number of files that failed to load. + * + * @name Phaser.Loader.MultiFile#failed + * @type {integer} + * @default 0 + * @since 3.7.0 + */ + this.failed = 0; + + /** + * A storage container for transient data that the loading files need. + * + * @name Phaser.Loader.MultiFile#config + * @type {any} + * @since 3.7.0 + */ + this.config = {}; + + // Link the files + for (var i = 0; i < files.length; i++) + { + files[i].multiFile = this; + } + }, + + /** + * Checks if this MultiFile is ready to process its children or not. + * + * @method Phaser.Loader.MultiFile#isReadyToProcess + * @since 3.7.0 + * + * @return {boolean} `true` if all children of this MultiFile have loaded, otherwise `false`. + */ + isReadyToProcess: function () + { + return (this.pending === 0 && this.failed === 0 && !this.complete); + }, + + /** + * Adds another child to this MultiFile, increases the pending count and resets the completion status. + * + * @method Phaser.Loader.MultiFile#addToMultiFile + * @since 3.7.0 + * + * @param {Phaser.Loader.File} files - The File to add to this MultiFile. + * + * @return {Phaser.Loader.MultiFile} This MultiFile instance. + */ + addToMultiFile: function (file) + { + this.files.push(file); + + file.multiFile = this; + + this.pending++; + + this.complete = false; + + return this; + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.MultiFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + } + }, + + /** + * Called by each File that fails to load. + * + * @method Phaser.Loader.MultiFile#onFileFailed + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has failed to load. + */ + onFileFailed: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.failed++; + } + } + +}); + +module.exports = MultiFile; + + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.ImageFrameConfig + * + * @property {integer} frameWidth - The width of the frame in pixels. + * @property {integer} [frameHeight] - The height of the frame in pixels. Uses the `frameWidth` value if not provided. + * @property {integer} [startFrame=0] - The first frame to start parsing from. + * @property {integer} [endFrame] - The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions. + * @property {integer} [margin=0] - The margin in the image. This is the space around the edge of the frames. + * @property {integer} [spacing=0] - The spacing between each frame in the image. + */ + +/** + * @typedef {object} Phaser.Loader.FileTypes.ImageFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='png'] - The default file extension to use if no url is provided. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image. + * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Image File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. + * + * @class ImageFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. + */ +var ImageFile = new Class({ + + Extends: File, + + initialize: + + function ImageFile (loader, key, url, xhrSettings, frameConfig) + { + var extension = 'png'; + var normalMapURL; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + normalMapURL = GetFastValue(config, 'normalMap'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + frameConfig = GetFastValue(config, 'frameConfig'); + } + + if (Array.isArray(url)) + { + normalMapURL = url[1]; + url = url[0]; + } + + var fileConfig = { + type: 'image', + cache: loader.textureManager, + extension: extension, + responseType: 'blob', + key: key, + url: url, + xhrSettings: xhrSettings, + config: frameConfig + }; + + File.call(this, loader, fileConfig); + + // Do we have a normal map to load as well? + if (normalMapURL) + { + var normalMap = new ImageFile(loader, this.key, normalMapURL, xhrSettings, frameConfig); + + normalMap.type = 'normalMap'; + + this.setLink(normalMap); + + loader.addFile(normalMap); + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.ImageFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var _this = this; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessError(); + }; + + File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.ImageFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture; + var linkFile = this.linkFile; + + if (linkFile && linkFile.state === CONST.FILE_COMPLETE) + { + if (this.type === 'image') + { + texture = this.cache.addImage(this.key, this.data, linkFile.data); + } + else + { + texture = this.cache.addImage(linkFile.key, linkFile.data, this.data); + } + + this.pendingDestroy(texture); + + linkFile.pendingDestroy(texture); + } + else if (!linkFile) + { + texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + } + +}); + +/** + * Adds an Image, or array of Images, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.image('logo', 'images/phaserLogo.png'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback + * of animated gifs to Canvas elements. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.image({ + * key: 'logo', + * url: 'images/AtariLogo.png' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.image('logo', 'images/AtariLogo.png'); + * // and later in your game ... + * this.add.image(x, y, 'logo'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.image({ + * key: 'logo', + * url: 'images/AtariLogo.png', + * normalMap: 'images/AtariLogo-n.png' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#image + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('image', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ImageFile(this, key[i])); + } + } + else + { + this.addFile(new ImageFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = ImageFile; + + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(69); +var GetPoint = __webpack_require__(278); +var GetPoints = __webpack_require__(277); +var Line = __webpack_require__(54); +var Random = __webpack_require__(184); /** * @classdesc @@ -9853,16 +10176,16 @@ var Random = __webpack_require__(153); * specify the second point, and the last two arguments specify the third point. * * @class Triangle - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. */ var Triangle = new Class({ @@ -9878,7 +10201,7 @@ var Triangle = new Class({ if (y3 === undefined) { y3 = 0; } /** - * [description] + * `x` coordinate of the first point. * * @name Phaser.Geom.Triangle#x1 * @type {number} @@ -9888,7 +10211,7 @@ var Triangle = new Class({ this.x1 = x1; /** - * [description] + * `y` coordinate of the first point. * * @name Phaser.Geom.Triangle#y1 * @type {number} @@ -9898,7 +10221,7 @@ var Triangle = new Class({ this.y1 = y1; /** - * [description] + * `x` coordinate of the second point. * * @name Phaser.Geom.Triangle#x2 * @type {number} @@ -9908,7 +10231,7 @@ var Triangle = new Class({ this.x2 = x2; /** - * [description] + * `y` coordinate of the second point. * * @name Phaser.Geom.Triangle#y2 * @type {number} @@ -9918,7 +10241,7 @@ var Triangle = new Class({ this.y2 = y2; /** - * [description] + * `x` coordinate of the third point. * * @name Phaser.Geom.Triangle#x3 * @type {number} @@ -9928,7 +10251,7 @@ var Triangle = new Class({ this.x3 = x3; /** - * [description] + * `y` coordinate of the third point. * * @name Phaser.Geom.Triangle#y3 * @type {number} @@ -9939,15 +10262,15 @@ var Triangle = new Class({ }, /** - * [description] + * Checks whether a given points lies within the triangle. * * @method Phaser.Geom.Triangle#contains * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The x coordinate of the point to check. + * @param {number} y - The y coordinate of the point to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the coordinate pair is within the triangle, otherwise `false`. */ contains: function (x, y) { @@ -9955,17 +10278,17 @@ var Triangle = new Class({ }, /** - * [description] + * Returns a specific point on the triangle. * * @method Phaser.Geom.Triangle#getPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [output,$return] * - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] + * @param {number} position - Position as float within `0` and `1`. `0` equals the first point. + * @param {(Phaser.Geom.Point|object)} [output] - Optional Point, or point-like object, that the calculated point will be written to. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} Calculated `Point` that represents the requested position. It is the same as `output` when this parameter has been given. */ getPoint: function (position, output) { @@ -9973,18 +10296,18 @@ var Triangle = new Class({ }, /** - * [description] + * Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (`quantity`) or the distance between two points (`stepRate`). * * @method Phaser.Geom.Triangle#getPoints * @since 3.0.0 * * @generic {Phaser.Geom.Point[]} O - [output,$return] * - * @param {integer} quantity - [description] - * @param {number} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * @param {integer} quantity - Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. + * @param {number} [stepRate] - Distance between two points. Will only be used when `quantity` is falsey. + * @param {(array|Phaser.Geom.Point[])} [output] - Optional Array for writing the calculated points into. Otherwise a new array will be created. * - * @return {(array|Phaser.Geom.Point[])} [description] + * @return {(array|Phaser.Geom.Point[])} Returns a list of calculated `Point` instances or the filled array passed as parameter `output`. */ getPoints: function (quantity, stepRate, output) { @@ -9992,16 +10315,16 @@ var Triangle = new Class({ }, /** - * [description] + * Returns a random point along the triangle. * * @method Phaser.Geom.Triangle#getRandomPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [point,$return] * - * @param {Phaser.Geom.Point} [point] - [description] + * @param {Phaser.Geom.Point} [point] - Optional `Point` that should be modified. Otherwise a new one will be created. * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Point} Random `Point`. When parameter `point` has been provided it will be returned. */ getRandomPoint: function (point) { @@ -10009,17 +10332,17 @@ var Triangle = new Class({ }, /** - * [description] + * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. * * @method Phaser.Geom.Triangle#setTo * @since 3.0.0 * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. * * @return {Phaser.Geom.Triangle} This Triangle object. */ @@ -10108,7 +10431,7 @@ var Triangle = new Class({ }, /** - * [description] + * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. * * @name Phaser.Geom.Triangle#left * @type {number} @@ -10146,7 +10469,7 @@ var Triangle = new Class({ }, /** - * [description] + * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. * * @name Phaser.Geom.Triangle#right * @type {number} @@ -10184,7 +10507,7 @@ var Triangle = new Class({ }, /** - * [description] + * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. * * @name Phaser.Geom.Triangle#top * @type {number} @@ -10222,7 +10545,7 @@ var Triangle = new Class({ }, /** - * [description] + * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. * * @name Phaser.Geom.Triangle#bottom * @type {number} @@ -10265,7 +10588,82 @@ module.exports = Triangle; /***/ }), -/* 69 */ +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders a stroke outline around the given Shape. + * + * @method Phaser.GameObjects.Shape#StrokePathWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The WebGL Pipeline used to render this Shape. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. + */ +var StrokePathWebGL = function (pipeline, src, alpha, dx, dy) +{ + var strokeTint = pipeline.strokeTint; + var strokeTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.strokeColor, src.strokeAlpha * alpha); + + strokeTint.TL = strokeTintColor; + strokeTint.TR = strokeTintColor; + strokeTint.BL = strokeTintColor; + strokeTint.BR = strokeTintColor; + + var path = src.pathData; + var pathLength = path.length - 1; + var lineWidth = src.lineWidth; + var halfLineWidth = lineWidth / 2; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + pipeline.setTexture2D(); + + pipeline.batchLine( + px1, + py1, + px2, + py2, + halfLineWidth, + halfLineWidth, + lineWidth, + i - 2, + (src.closePath) ? (i === pathLength - 1) : false + ); + + px1 = px2; + py1 = py2; + } +}; + +module.exports = StrokePathWebGL; + + +/***/ }), +/* 61 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -10275,22 +10673,25 @@ module.exports = Triangle; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var ImageRender = __webpack_require__(461); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var SpriteRender = __webpack_require__(829); /** * @classdesc - * An Image Game Object. + * A Sprite Game Object. * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. * - * @class Image + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -10305,7 +10706,7 @@ var ImageRender = __webpack_require__(461); * @extends Phaser.GameObjects.Components.ScaleMode * @extends Phaser.GameObjects.Components.ScrollFactor * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.TextureCrop * @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible @@ -10316,7 +10717,7 @@ var ImageRender = __webpack_require__(461); * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. */ -var Image = new Class({ +var Sprite = new Class({ Extends: GameObject, @@ -10332,29 +10733,1140 @@ var Image = new Class({ Components.ScaleMode, Components.ScrollFactor, Components.Size, - Components.Texture, + Components.TextureCrop, Components.Tint, Components.Transform, Components.Visible, - ImageRender + SpriteRender ], initialize: - function Image (scene, x, y, texture, frame) + function Sprite (scene, x, y, texture, frame) { - GameObject.call(this, scene, 'Image'); + GameObject.call(this, scene, 'Sprite'); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Sprite#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Animation Controller of this Sprite. + * + * @name Phaser.GameObjects.Sprite#anims + * @type {Phaser.GameObjects.Components.Animation} + * @since 3.0.0 + */ + this.anims = new Components.Animation(this); this.setTexture(texture, frame); this.setPosition(x, y); this.setSizeToFrame(); this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); + this.initPipeline(); + }, + + /** + * Update this Sprite's animations. + * + * @method Phaser.GameObjects.Sprite#preUpdate + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + }, + + /** + * Start playing the given animation. + * + * @method Phaser.GameObjects.Sprite#play + * @since 3.0.0 + * + * @param {string} key - The string-based key of the animation to play. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.Sprite} This Game Object. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + this.anims.play(key, ignoreIfPlaying, startFrame); + + return this; + }, + + /** + * Build a JSON representation of this Sprite. + * + * @method Phaser.GameObjects.Sprite#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + var data = Components.ToJSON(this); + + // Extra Sprite data is added here + + return data; + }, + + /** + * Handles the pre-destroy step for the Sprite, which removes the Animation component. + * + * @method Phaser.GameObjects.Sprite#preDestroy + * @private + * @since 3.14.0 + */ + preDestroy: function () + { + this.anims.destroy(); + + this.anims = undefined; } }); -module.exports = Image; +module.exports = Sprite; + + +/***/ }), +/* 62 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Tests if the start and end indexes are a safe range for the given array. + * + * @function Phaser.Utils.Array.SafeRange + * @since 3.4.0 + * + * @param {array} array - The array to check. + * @param {integer} startIndex - The start index. + * @param {integer} endIndex - The end index. + * @param {boolean} [throwError=true] - Throw an error if the range is out of bounds. + * + * @return {boolean} True if the range is safe, otherwise false. + */ +var SafeRange = function (array, startIndex, endIndex, throwError) +{ + var len = array.length; + + if (startIndex < 0 || + startIndex > len || + startIndex >= endIndex || + endIndex > len || + startIndex + endIndex > len) + { + if (throwError) + { + throw new Error('Range Error: Values outside acceptable range'); + } + + return false; + } + else + { + return true; + } +}; + +module.exports = SafeRange; + + +/***/ }), +/* 63 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Shallow Object Clone. Will not clone nested objects. + * + * @function Phaser.Utils.Objects.Clone + * @since 3.0.0 + * + * @param {object} obj - the object from which to clone + * + * @return {object} a new object with the same properties as the input obj + */ +var Clone = function (obj) +{ + var clone = {}; + + for (var key in obj) + { + if (Array.isArray(obj[key])) + { + clone[key] = obj[key].slice(0); + } + else + { + clone[key] = obj[key]; + } + } + + return clone; +}; + +module.exports = Clone; + + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// 2.1.1 (Mar 17, 2016) + +/* +ISC License + +Copyright (c) 2016, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + */ + + + +module.exports = earcut; + +/* +vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. +holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). +dimensions is the number of coordinates per vertice in the input array (2 by default). +Each group of three vertice indices in the resulting array forms a triangle. + */ + +function earcut(data, holeIndices, dim) { + + dim = dim || 2; + + var hasHoles = holeIndices && holeIndices.length, + outerLen = hasHoles ? holeIndices[0] * dim : data.length, + outerNode = linkedList(data, 0, outerLen, dim, true), + triangles = []; + + if (!outerNode) return triangles; + + var minX, minY, maxX, maxY, x, y, size; + + if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); + + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; + + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + } + + // minX, minY and size are later used to transform coords into integers for z-order calculation + size = Math.max(maxX - minX, maxY - minY); + } + + earcutLinked(outerNode, triangles, dim, minX, minY, size); + + return triangles; +} + +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList(data, start, end, dim, clockwise) { + var i, last; + + if (clockwise === (signedArea(data, start, end, dim) > 0)) { + for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); + } else { + for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); + } + + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + + return last; +} + +// eliminate colinear or duplicate points +function filterPoints(start, end) { + if (!start) return start; + if (!end) end = start; + + var p = start, + again; + do { + again = false; + + if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { + removeNode(p); + p = end = p.prev; + if (p === p.next) return null; + again = true; + + } else { + p = p.next; + } + } while (again || p !== end); + + return end; +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { + if (!ear) return; + + // interlink polygon nodes in z-order + if (!pass && size) indexCurve(ear, minX, minY, size); + + var stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { + // cut off the triangle + triangles.push(prev.i / dim); + triangles.push(ear.i / dim); + triangles.push(next.i / dim); + + removeNode(ear); + + // skipping the next vertice leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(ear, triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, size, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(ear, triangles, dim, minX, minY, size); + } + + break; + } + } +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar(ear) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + var p = ear.next.next; + + while (p !== ear.prev) { + if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.next; + } + + return true; +} + +function isEarHashed(ear, minX, minY, size) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // triangle bbox; min & max are calculated like this for speed + var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), + minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), + maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), + maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); + + // z-order range for the current triangle bbox; + var minZ = zOrder(minTX, minTY, minX, minY, size), + maxZ = zOrder(maxTX, maxTY, minX, minY, size); + + // first look for points inside the triangle in increasing z-order + var p = ear.nextZ; + + while (p && p.z <= maxZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.nextZ; + } + + // then look for points in decreasing z-order + p = ear.prevZ; + + while (p && p.z >= minZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + } + + return true; +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections(start, triangles, dim) { + var p = start; + do { + var a = p.prev, + b = p.next.next; + + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + + triangles.push(a.i / dim); + triangles.push(p.i / dim); + triangles.push(b.i / dim); + + // remove two nodes involved + removeNode(p); + removeNode(p.next); + + p = start = b; + } + p = p.next; + } while (p !== start); + + return p; +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut(start, triangles, dim, minX, minY, size) { + // look for a valid diagonal that divides the polygon into two + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + // split the polygon in two by the diagonal + var c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + + // run earcut on each half + earcutLinked(a, triangles, dim, minX, minY, size); + earcutLinked(c, triangles, dim, minX, minY, size); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], + i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) list.steiner = true; + queue.push(getLeftmost(list)); + } + + queue.sort(compareX); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + eliminateHole(queue[i], outerNode); + outerNode = filterPoints(outerNode, outerNode.next); + } + + return outerNode; +} + +function compareX(a, b) { + return a.x - b.x; +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole(hole, outerNode) { + outerNode = findHoleBridge(hole, outerNode); + if (outerNode) { + var b = splitPolygon(outerNode, hole); + filterPoints(b, b.next); + } +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge(hole, outerNode) { + var p = outerNode, + hx = hole.x, + hy = hole.y, + qx = -Infinity, + m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { + var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + if (x === hx) { + if (hy === p.y) return p; + if (hy === p.next.y) return p.next; + } + m = p.x < p.next.x ? p : p.next; + } + } + p = p.next; + } while (p !== outerNode); + + if (!m) return null; + + if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + var stop = m, + mx = m.x, + my = m.y, + tanMin = Infinity, + tan; + + p = m.next; + + while (p !== stop) { + if (hx >= p.x && p.x >= mx && hx !== p.x && + pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + + tan = Math.abs(hy - p.y) / (hx - p.x); // tangential + + if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { + m = p; + tanMin = tan; + } + } + + p = p.next; + } + + return m; +} + +// interlink polygon nodes in z-order +function indexCurve(start, minX, minY, size) { + var p = start; + do { + if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked(p); +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + + if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + + } while (numMerges > 1); + + return list; +} + +// z-order of a point given coords and size of the data bounding box +function zOrder(x, y, minX, minY, size) { + // coords are transformed into non-negative 15-bit integer range + x = 32767 * (x - minX) / size; + y = 32767 * (y - minY) / size; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); +} + +// find the leftmost node of a polygon ring +function getLeftmost(start) { + var p = start, + leftmost = start; + do { + if (p.x < leftmost.x) leftmost = p; + p = p.next; + } while (p !== start); + + return leftmost; +} + +// check if a point lies within a convex triangle +function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && + (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && + (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal(a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && + locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); +} + +// signed area of a triangle +function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); +} + +// check if two points are equal +function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; +} + +// check if two segments intersect +function intersects(p1, q1, p2, q2) { + if ((equals(p1, q1) && equals(p2, q2)) || + (equals(p1, q2) && equals(p2, q1))) return true; + return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && + area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon(a, b) { + var p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && + intersects(p, p.next, a, b)) return true; + p = p.next; + } while (p !== a); + + return false; +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? + area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : + area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside(a, b) { + var p = a, + inside = false, + px = (a.x + b.x) / 2, + py = (a.y + b.y) / 2; + do { + if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && + (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) + inside = !inside; + p = p.next; + } while (p !== a); + + return inside; +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon(a, b) { + var a2 = new Node(a.i, a.x, a.y), + b2 = new Node(b.i, b.x, b.y), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode(i, x, y, last) { + var p = new Node(i, x, y); + + if (!last) { + p.prev = p; + p.next = p; + + } else { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } + return p; +} + +function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + + if (p.prevZ) p.prevZ.nextZ = p.nextZ; + if (p.nextZ) p.nextZ.prevZ = p.prevZ; +} + +function Node(i, x, y) { + // vertice index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertice nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = null; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; +} + +// return a percentage difference between the polygon area and its triangulation area; +// used to verify correctness of triangulation +earcut.deviation = function (data, holeIndices, dim, triangles) { + var hasHoles = holeIndices && holeIndices.length; + var outerLen = hasHoles ? holeIndices[0] * dim : data.length; + + var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); + if (hasHoles) { + for (var i = 0, len = holeIndices.length; i < len; i++) { + var start = holeIndices[i] * dim; + var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + polygonArea -= Math.abs(signedArea(data, start, end, dim)); + } + } + + var trianglesArea = 0; + for (i = 0; i < triangles.length; i += 3) { + var a = triangles[i] * dim; + var b = triangles[i + 1] * dim; + var c = triangles[i + 2] * dim; + trianglesArea += Math.abs( + (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - + (data[a] - data[b]) * (data[c + 1] - data[a + 1])); + } + + return polygonArea === 0 && trianglesArea === 0 ? 0 : + Math.abs((trianglesArea - polygonArea) / polygonArea); +}; + +function signedArea(data, start, end, dim) { + var sum = 0; + for (var i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + return sum; +} + +// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts +earcut.flatten = function (data) { + var dim = data[0][0].length, + result = {vertices: [], holes: [], dimensions: dim}, + holeIndex = 0; + + for (var i = 0; i < data.length; i++) { + for (var j = 0; j < data[i].length; j++) { + for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); + } + if (i > 0) { + holeIndex += data[i - 1].length; + result.holes.push(holeIndex); + } + } + return result; +}; + +/***/ }), +/* 65 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the length of the given line. + * + * @function Phaser.Geom.Line.Length + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the length of. + * + * @return {number} The length of the line. + */ +var Length = function (line) +{ + return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); +}; + +module.exports = Length; + + +/***/ }), +/* 66 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser Blend Modes. + * + * @name Phaser.BlendModes + * @enum {integer} + * @memberof Phaser + * @readonly + * @since 3.0.0 + */ + +module.exports = { + + /** + * Skips the Blend Mode check in the renderer. + * + * @name Phaser.BlendModes.SKIP_CHECK + */ + SKIP_CHECK: -1, + + /** + * Normal blend mode. + * + * @name Phaser.BlendModes.NORMAL + */ + NORMAL: 0, + + /** + * Add blend mode. + * + * @name Phaser.BlendModes.ADD + */ + ADD: 1, + + /** + * Multiply blend mode. + * + * @name Phaser.BlendModes.MULTIPLY + */ + MULTIPLY: 2, + + /** + * Screen blend mode. + * + * @name Phaser.BlendModes.SCREEN + */ + SCREEN: 3, + + /** + * Overlay blend mode. + * + * @name Phaser.BlendModes.OVERLAY + */ + OVERLAY: 4, + + /** + * Darken blend mode. + * + * @name Phaser.BlendModes.DARKEN + */ + DARKEN: 5, + + /** + * Lighten blend mode. + * + * @name Phaser.BlendModes.LIGHTEN + */ + LIGHTEN: 6, + + /** + * Color Dodge blend mode. + * + * @name Phaser.BlendModes.COLOR_DODGE + */ + COLOR_DODGE: 7, + + /** + * Color Burn blend mode. + * + * @name Phaser.BlendModes.COLOR_BURN + */ + COLOR_BURN: 8, + + /** + * Hard Light blend mode. + * + * @name Phaser.BlendModes.HARD_LIGHT + */ + HARD_LIGHT: 9, + + /** + * Soft Light blend mode. + * + * @name Phaser.BlendModes.SOFT_LIGHT + */ + SOFT_LIGHT: 10, + + /** + * Difference blend mode. + * + * @name Phaser.BlendModes.DIFFERENCE + */ + DIFFERENCE: 11, + + /** + * Exclusion blend mode. + * + * @name Phaser.BlendModes.EXCLUSION + */ + EXCLUSION: 12, + + /** + * Hue blend mode. + * + * @name Phaser.BlendModes.HUE + */ + HUE: 13, + + /** + * Saturation blend mode. + * + * @name Phaser.BlendModes.SATURATION + */ + SATURATION: 14, + + /** + * Color blend mode. + * + * @name Phaser.BlendModes.COLOR + */ + COLOR: 15, + + /** + * Luminosity blend mode. + * + * @name Phaser.BlendModes.LUMINOSITY + */ + LUMINOSITY: 16 + +}; + + +/***/ }), +/* 67 */, +/* 68 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the angle of the line in radians. + * + * @function Phaser.Geom.Line.Angle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the angle of. + * + * @return {number} The angle of the line, in radians. + */ +var Angle = function (line) +{ + return Math.atan2(line.y2 - line.y1, line.x2 - line.x1); +}; + +module.exports = Angle; + + +/***/ }), +/* 69 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// http://www.blackpawn.com/texts/pointinpoly/ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ +var Contains = function (triangle, x, y) +{ + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var v2x = x - triangle.x1; + var v2y = y - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot02 = (v0x * v2x) + (v0y * v2y); + var dot11 = (v1x * v1x) + (v1y * v1y); + var dot12 = (v1x * v2x) + (v1y * v2y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + return (u >= 0 && v >= 0 && (u + v < 1)); +}; + +module.exports = Contains; /***/ }), @@ -10368,3668 +11880,9 @@ module.exports = Image; */ var Class = __webpack_require__(0); - -/** - * @callback EachSetCallback - * @generic E - [entry] - * - * @param {*} entry - [description] - * @param {number} index - [description] - * - * @return {?boolean} [description] - */ - -/** - * @classdesc - * A Set is a collection of unique elements. - * - * @class Set - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic T - * @genericUse {T[]} - [elements] - * - * @param {Array.<*>} [elements] - [description] - */ -var Set = new Class({ - - initialize: - - function Set (elements) - { - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.Set#entries - * @type {Array.<*>} - * @default [] - * @since 3.0.0 - */ - this.entries = []; - - if (Array.isArray(elements)) - { - for (var i = 0; i < elements.length; i++) - { - this.set(elements[i]); - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#set - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {*} value - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - set: function (value) - { - if (this.entries.indexOf(value) === -1) - { - this.entries.push(value); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#get - * @since 3.0.0 - * - * @genericUse {T} - [value,$return] - * - * @param {string} property - [description] - * @param {*} value - [description] - * - * @return {*} [description] - */ - get: function (property, value) - { - for (var i = 0; i < this.entries.length; i++) - { - var entry = this.entries[i]; - - if (entry[property] === value) - { - return entry; - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#getArray - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @return {Array.<*>} [description] - */ - getArray: function () - { - return this.entries.slice(0); - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#delete - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {*} value - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - delete: function (value) - { - var index = this.entries.indexOf(value); - - if (index > -1) - { - this.entries.splice(index, 1); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#dump - * @since 3.0.0 - */ - dump: function () - { - // eslint-disable-next-line no-console - console.group('Set'); - - for (var i = 0; i < this.entries.length; i++) - { - var entry = this.entries[i]; - console.log(entry); - } - - // eslint-disable-next-line no-console - console.groupEnd(); - }, - - /** - * For when you know this Set will be modified during the iteration. - * - * @method Phaser.Structs.Set#each - * @since 3.0.0 - * - * @genericUse {EachSetCallback.} - [callback] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {EachSetCallback} callback - [description] - * @param {*} callbackScope - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - each: function (callback, callbackScope) - { - var i; - var temp = this.entries.slice(); - var len = temp.length; - - if (callbackScope) - { - for (i = 0; i < len; i++) - { - if (callback.call(callbackScope, temp[i], i) === false) - { - break; - } - } - } - else - { - for (i = 0; i < len; i++) - { - if (callback(temp[i], i) === false) - { - break; - } - } - } - - return this; - }, - - /** - * For when you absolutely know this Set won't be modified during the iteration. - * - * @method Phaser.Structs.Set#iterate - * @since 3.0.0 - * - * @genericUse {EachSetCallback.} - [callback] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {EachSetCallback} callback - [description] - * @param {*} callbackScope - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - iterate: function (callback, callbackScope) - { - var i; - var len = this.entries.length; - - if (callbackScope) - { - for (i = 0; i < len; i++) - { - if (callback.call(callbackScope, this.entries[i], i) === false) - { - break; - } - } - } - else - { - for (i = 0; i < len; i++) - { - if (callback(this.entries[i], i) === false) - { - break; - } - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#iterateLocal - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {string} callbackKey - [description] - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - * - * @return {Phaser.Structs.Set} This Set object. - */ - iterateLocal: function (callbackKey) - { - var i; - var args = []; - - for (i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - var len = this.entries.length; - - for (i = 0; i < len; i++) - { - var entry = this.entries[i]; - - entry[callbackKey].apply(entry, args); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#clear - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @return {Phaser.Structs.Set} This Set object. - */ - clear: function () - { - this.entries.length = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#contains - * @since 3.0.0 - * - * @genericUse {T} - [value] - * - * @param {*} value - [description] - * - * @return {boolean} [description] - */ - contains: function (value) - { - return (this.entries.indexOf(value) > -1); - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#union - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [set,$return] - * - * @param {Phaser.Structs.Set} set - [description] - * - * @return {Phaser.Structs.Set} [description] - */ - union: function (set) - { - var newSet = new Set(); - - set.entries.forEach(function (value) - { - newSet.set(value); - }); - - this.entries.forEach(function (value) - { - newSet.set(value); - }); - - return newSet; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#intersect - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [set,$return] - * - * @param {Phaser.Structs.Set} set - [description] - * - * @return {Phaser.Structs.Set} [description] - */ - intersect: function (set) - { - var newSet = new Set(); - - this.entries.forEach(function (value) - { - if (set.contains(value)) - { - newSet.set(value); - } - }); - - return newSet; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#difference - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [set,$return] - * - * @param {Phaser.Structs.Set} set - [description] - * - * @return {Phaser.Structs.Set} [description] - */ - difference: function (set) - { - var newSet = new Set(); - - this.entries.forEach(function (value) - { - if (!set.contains(value)) - { - newSet.set(value); - } - }); - - return newSet; - }, - - /** - * [description] - * - * @name Phaser.Structs.Set#size - * @type {integer} - * @since 3.0.0 - */ - size: { - - get: function () - { - return this.entries.length; - }, - - set: function (value) - { - return this.entries.length = value; - } - - } - -}); - -module.exports = Set; - - -/***/ }), -/* 71 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Length - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Length = function (line) -{ - return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); -}; - -module.exports = Length; - - -/***/ }), -/* 72 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Defaults = __webpack_require__(100); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(62); -var GetEaseFunction = __webpack_require__(63); -var GetNewValue = __webpack_require__(73); -var GetProps = __webpack_require__(163); -var GetTargets = __webpack_require__(102); -var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(101); -var Tween = __webpack_require__(99); -var TweenData = __webpack_require__(98); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.TweenBuilder - * @since 3.0.0 - * - * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] - * @param {object} config - [description] - * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ -var TweenBuilder = function (parent, config, defaults) -{ - if (defaults === undefined) - { - defaults = Defaults; - } - - // Create arrays of the Targets and the Properties - var targets = (defaults.targets) ? defaults.targets : GetTargets(config); - - // var props = (defaults.props) ? defaults.props : GetProps(config); - var props = GetProps(config); - - // Default Tween values - var delay = GetNewValue(config, 'delay', defaults.delay); - var duration = GetNewValue(config, 'duration', defaults.duration); - var easeParams = GetValue(config, 'easeParams', defaults.easeParams); - var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); - var hold = GetNewValue(config, 'hold', defaults.hold); - var repeat = GetNewValue(config, 'repeat', defaults.repeat); - var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - var flipX = GetBoolean(config, 'flipX', defaults.flipX); - var flipY = GetBoolean(config, 'flipY', defaults.flipY); - - var data = []; - - // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } - for (var p = 0; p < props.length; p++) - { - var key = props[p].key; - var value = props[p].value; - - // Create 1 TweenData per target, per property - for (var t = 0; t < targets.length; t++) - { - var ops = GetValueOp(key, value); - - var tweenData = TweenData( - targets[t], - key, - ops.getEnd, - ops.getStart, - GetEaseFunction(GetValue(value, 'ease', ease), easeParams), - GetNewValue(value, 'delay', delay), - GetNewValue(value, 'duration', duration), - GetBoolean(value, 'yoyo', yoyo), - GetNewValue(value, 'hold', hold), - GetNewValue(value, 'repeat', repeat), - GetNewValue(value, 'repeatDelay', repeatDelay), - GetBoolean(value, 'flipX', flipX), - GetBoolean(value, 'flipY', flipY) - ); - - data.push(tweenData); - } - } - - var tween = new Tween(parent, data, targets); - - tween.offset = GetAdvancedValue(config, 'offset', null); - tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - tween.paused = GetBoolean(config, 'paused', false); - tween.useFrames = GetBoolean(config, 'useFrames', false); - - // Set the Callbacks - var scope = GetValue(config, 'callbackScope', tween); - - // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params - var tweenArray = [ tween, null ]; - - var callbacks = Tween.TYPES; - - for (var i = 0; i < callbacks.length; i++) - { - var type = callbacks[i]; - - var callback = GetValue(config, type, false); - - if (callback) - { - var callbackScope = GetValue(config, type + 'Scope', scope); - var callbackParams = GetValue(config, type + 'Params', []); - - // The null is reset to be the Tween target - tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); - } - } - - return tween; -}; - -module.exports = TweenBuilder; - - -/***/ }), -/* 73 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetNewValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {function} [description] - */ -var GetNewValue = function (source, key, defaultValue) -{ - var valueCallback; - - if (source.hasOwnProperty(key)) - { - var t = typeof(source[key]); - - if (t === 'function') - { - valueCallback = function (index, totalTargets, target) - { - return source[key](index, totalTargets, target); - }; - } - else - { - valueCallback = function () - { - return source[key]; - }; - } - } - else if (typeof defaultValue === 'function') - { - valueCallback = defaultValue; - } - else - { - valueCallback = function () - { - return defaultValue; - }; - } - - return valueCallback; -}; - -module.exports = GetNewValue; - - -/***/ }), -/* 74 */, -/* 75 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} XHRSettingsObject - * - * @property {XMLHttpRequestResponseType} responseType - The response type of the XHR request, i.e. `blob`, `text`, etc. - * @property {boolean} [async=true] - Should the XHR request use async or not? - * @property {string} [user=''] - Optional username for the XHR request. - * @property {string} [password=''] - Optional password for the XHR request. - * @property {integer} [timeout=0] - Optional XHR timeout value. - * @property {(string|undefined)} [header] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. - * @property {(string|undefined)} [headerValue] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. - * @property {(string|undefined)} [requestedWith] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. - * @property {(string|undefined)} [overrideMimeType] - Provide a custom mime-type to use instead of the default. - */ - -/** - * Creates an XHRSettings Object with default values. - * - * @function Phaser.Loader.XHRSettings - * @since 3.0.0 - * - * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. - * @param {boolean} [async=true] - Should the XHR request use async or not? - * @param {string} [user=''] - Optional username for the XHR request. - * @param {string} [password=''] - Optional password for the XHR request. - * @param {integer} [timeout=0] - Optional XHR timeout value. - * - * @return {XHRSettingsObject} The XHRSettings object as used by the Loader. - */ -var XHRSettings = function (responseType, async, user, password, timeout) -{ - if (responseType === undefined) { responseType = ''; } - if (async === undefined) { async = true; } - if (user === undefined) { user = ''; } - if (password === undefined) { password = ''; } - if (timeout === undefined) { timeout = 0; } - - // Before sending a request, set the xhr.responseType to "text", - // "arraybuffer", "blob", or "document", depending on your data needs. - // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". - - return { - - // Ignored by the Loader, only used by File. - responseType: responseType, - - async: async, - - // credentials - user: user, - password: password, - - // timeout in ms (0 = no timeout) - timeout: timeout, - - // setRequestHeader - header: undefined, - headerValue: undefined, - requestedWith: false, - - // overrideMimeType - overrideMimeType: undefined - - }; -}; - -module.exports = XHRSettings; - - -/***/ }), -/* 76 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -// Contains the plugins that Phaser uses globally and locally. -// These are the source objects, not instantiated. -var inputPlugins = {}; - -/** - * @typedef {object} InputPluginContainer - * - * @property {string} key - The unique name of this plugin in the input plugin cache. - * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. - * @property {string} [mapping] - If this plugin is to be injected into the Input Plugin, this is the property key map used. - */ - -var InputPluginCache = {}; - -/** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * - * @method Phaser.Input.InputPluginCache.register - * @since 3.10.0 - * - * @param {string} key - A reference used to get this plugin from the plugin cache. - * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. - * @param {string} mapping - If this plugin is to be injected into the Input Plugin, this is the property key used. - * @param {string} settingsKey - The key in the Scene Settings to check to see if this plugin should install or not. - * @param {string} configKey - The key in the Game Config to check to see if this plugin should install or not. - */ -InputPluginCache.register = function (key, plugin, mapping, settingsKey, configKey) -{ - inputPlugins[key] = { plugin: plugin, mapping: mapping, settingsKey: settingsKey, configKey: configKey }; -}; - -/** - * Returns the input plugin object from the cache based on the given key. - * - * @method Phaser.Input.InputPluginCache.getCore - * @since 3.10.0 - * - * @param {string} key - The key of the input plugin to get. - * - * @return {InputPluginContainer} The input plugin object. - */ -InputPluginCache.getPlugin = function (key) -{ - return inputPlugins[key]; -}; - -/** - * Installs all of the registered Input Plugins into the given target. - * - * @method Phaser.Input.InputPluginCache.install - * @since 3.10.0 - * - * @param {Phaser.Input.InputPlugin} target - The target InputPlugin to install the plugins into. - */ -InputPluginCache.install = function (target) -{ - var sys = target.scene.sys; - var settings = sys.settings.input; - var config = sys.game.config; - - for (var key in inputPlugins) - { - var source = inputPlugins[key].plugin; - var mapping = inputPlugins[key].mapping; - var settingsKey = inputPlugins[key].settingsKey; - var configKey = inputPlugins[key].configKey; - - if (GetValue(settings, settingsKey, config[configKey])) - { - target[mapping] = new source(target); - } - } -}; - -/** - * Removes an input plugin based on the given key. - * - * @method Phaser.Input.InputPluginCache.remove - * @since 3.10.0 - * - * @param {string} key - The key of the input plugin to remove. - */ -InputPluginCache.remove = function (key) -{ - if (inputPlugins.hasOwnProperty(key)) - { - delete inputPlugins[key]; - } -}; - -module.exports = InputPluginCache; - - -/***/ }), -/* 77 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. - -var CheckMatrix = __webpack_require__(116); -var TransposeMatrix = __webpack_require__(181); - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.RotateMatrix - * @since 3.0.0 - * - * @param {array} matrix - The array to rotate. - * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. - * - * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. - */ -var RotateMatrix = function (matrix, direction) -{ - if (direction === undefined) { direction = 90; } - - if (!CheckMatrix(matrix)) - { - return null; - } - - if (typeof direction !== 'string') - { - direction = ((direction % 360) + 360) % 360; - } - - if (direction === 90 || direction === -270 || direction === 'rotateLeft') - { - matrix = TransposeMatrix(matrix); - matrix.reverse(); - } - else if (direction === -90 || direction === 270 || direction === 'rotateRight') - { - matrix.reverse(); - matrix = TransposeMatrix(matrix); - } - else if (Math.abs(direction) === 180 || direction === 'rotate180') - { - for (var i = 0; i < matrix.length; i++) - { - matrix[i].reverse(); - } - - matrix.reverse(); - } - - return matrix; -}; - -module.exports = RotateMatrix; - - -/***/ }), -/* 78 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Extend = __webpack_require__(17); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * Class containing all the shared state and behavior of a sound object, independent of the implementation. - * - * @class BaseSound - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - */ -var BaseSound = new Class({ - - Extends: EventEmitter, - - initialize: - - function BaseSound (manager, key, config) - { - EventEmitter.call(this); - - /** - * Local reference to the sound manager. - * - * @name Phaser.Sound.BaseSound#manager - * @type {Phaser.Sound.BaseSoundManager} - * @private - * @since 3.0.0 - */ - this.manager = manager; - - /** - * Asset key for the sound. - * - * @name Phaser.Sound.BaseSound#key - * @type {string} - * @readOnly - * @since 3.0.0 - */ - this.key = key; - - /** - * Flag indicating if sound is currently playing. - * - * @name Phaser.Sound.BaseSound#isPlaying - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isPlaying = false; - - /** - * Flag indicating if sound is currently paused. - * - * @name Phaser.Sound.BaseSound#isPaused - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isPaused = false; - - /** - * A property that holds the value of sound's actual playback rate, - * after its rate and detune values has been combined with global - * rate and detune values. - * - * @name Phaser.Sound.BaseSound#totalRate - * @type {number} - * @default 1 - * @readOnly - * @since 3.0.0 - */ - this.totalRate = 1; - - /** - * A value representing the duration, in seconds. - * It could be total sound duration or a marker duration. - * - * @name Phaser.Sound.BaseSound#duration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.duration = this.duration || 0; - - /** - * The total duration of the sound in seconds. - * - * @name Phaser.Sound.BaseSound#totalDuration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.totalDuration = this.totalDuration || 0; - - /** - * A config object used to store default sound settings' values. - * Default values will be set by properties' setters. - * - * @name Phaser.Sound.BaseSound#config - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.config = { - - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - - }; - - /** - * Reference to the currently used config. - * It could be default config or marker config. - * - * @name Phaser.Sound.BaseSound#currentConfig - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.currentConfig = this.config; - - this.config = Extend(this.config, config); - - /** - * Object containing markers definitions. - * - * @name Phaser.Sound.BaseSound#markers - * @type {Object.} - * @default {} - * @readOnly - * @since 3.0.0 - */ - this.markers = {}; - - /** - * Currently playing marker. - * 'null' if whole sound is playing. - * - * @name Phaser.Sound.BaseSound#currentMarker - * @type {SoundMarker} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.currentMarker = null; - - /** - * Flag indicating if destroy method was called on this sound. - * - * @name Phaser.Sound.BaseSound#pendingRemove - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.pendingRemove = false; - }, - - /** - * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. - * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. - * - * @method Phaser.Sound.BaseSound#addMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object. - * - * @return {boolean} Whether the marker was added successfully. - */ - addMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - - if (this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.error('addMarker ' + marker.name + ' already exists in Sound'); - - return false; - } - - marker = Extend(true, { - name: '', - start: 0, - duration: this.totalDuration - (marker.start || 0), - config: { - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - } - }, marker); - - this.markers[marker.name] = marker; - - return true; - }, - - /** - * Updates previously added marker. - * - * @method Phaser.Sound.BaseSound#updateMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object with updated values. - * - * @return {boolean} Whether the marker was updated successfully. - */ - updateMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - - if (!this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.warn('Audio Marker: ' + marker.name + ' missing in Sound: ' + this.key); - - return false; - } - - this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); - - return true; - }, - - /** - * Removes a marker from the sound. - * - * @method Phaser.Sound.BaseSound#removeMarker - * @since 3.0.0 - * - * @param {string} markerName - The name of the marker to remove. - * - * @return {?SoundMarker} Removed marker object or 'null' if there was no marker with provided name. - */ - removeMarker: function (markerName) - { - var marker = this.markers[markerName]; - - if (!marker) - { - return null; - } - - this.markers[markerName] = null; - - return marker; - }, - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * - * @method Phaser.Sound.BaseSound#play - * @since 3.0.0 - * - * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (markerName, config) - { - if (markerName === undefined) { markerName = ''; } - - if (typeof markerName === 'object') - { - config = markerName; - markerName = ''; - } - - if (typeof markerName !== 'string') - { - return false; - } - - if (!markerName) - { - this.currentMarker = null; - this.currentConfig = this.config; - this.duration = this.totalDuration; - } - else - { - if (!this.markers[markerName]) - { - // eslint-disable-next-line no-console - console.warn('Marker: ' + markerName + ' missing in Sound: ' + this.key); - - return false; - } - - this.currentMarker = this.markers[markerName]; - this.currentConfig = this.currentMarker.config; - this.duration = this.currentMarker.duration; - } - - this.resetConfig(); - - this.currentConfig = Extend(this.currentConfig, config); - - this.isPlaying = true; - this.isPaused = false; - - return true; - }, - - /** - * Pauses the sound. - * - * @method Phaser.Sound.BaseSound#pause - * @since 3.0.0 - * - * @return {boolean} Whether the sound was paused successfully. - */ - pause: function () - { - if (this.isPaused || !this.isPlaying) - { - return false; - } - - this.isPlaying = false; - this.isPaused = true; - - return true; - }, - - /** - * Resumes the sound. - * - * @method Phaser.Sound.BaseSound#resume - * @since 3.0.0 - * - * @return {boolean} Whether the sound was resumed successfully. - */ - resume: function () - { - if (!this.isPaused || this.isPlaying) - { - return false; - } - - this.isPlaying = true; - this.isPaused = false; - - return true; - }, - - /** - * Stop playing this sound. - * - * @method Phaser.Sound.BaseSound#stop - * @since 3.0.0 - * - * @return {boolean} Whether the sound was stopped successfully. - */ - stop: function () - { - if (!this.isPaused && !this.isPlaying) - { - return false; - } - - this.isPlaying = false; - this.isPaused = false; - - this.resetConfig(); - - return true; - }, - - /** - * Method used internally for applying config values to some of the sound properties. - * - * @method Phaser.Sound.BaseSound#applyConfig - * @protected - * @since 3.0.0 - */ - applyConfig: function () - { - this.mute = this.currentConfig.mute; - this.volume = this.currentConfig.volume; - this.rate = this.currentConfig.rate; - this.detune = this.currentConfig.detune; - this.loop = this.currentConfig.loop; - }, - - /** - * Method used internally for resetting values of some of the config properties. - * - * @method Phaser.Sound.BaseSound#resetConfig - * @protected - * @since 3.0.0 - */ - resetConfig: function () - { - this.currentConfig.seek = 0; - this.currentConfig.delay = 0; - }, - - /** - * Update method called automatically by sound manager on every game step. - * - * @method Phaser.Sound.BaseSound#update - * @override - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: NOOP, - - /** - * Method used internally to calculate total playback rate of the sound. - * - * @method Phaser.Sound.BaseSound#calculateRate - * @protected - * @since 3.0.0 - */ - calculateRate: function () - { - var cent = 1.0005777895065548; // Math.pow(2, 1/1200); - var totalDetune = this.currentConfig.detune + this.manager.detune; - var detuneRate = Math.pow(cent, totalDetune); - - this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; - }, - - /** - * Destroys this sound and all associated events and marks it for removal from the sound manager. - * - * @method Phaser.Sound.BaseSound#destroy - * @since 3.0.0 - */ - destroy: function () - { - if (this.pendingRemove) - { - return; - } - - this.emit('destroy', this); - this.pendingRemove = true; - this.manager = null; - this.key = ''; - this.removeAllListeners(); - this.isPlaying = false; - this.isPaused = false; - this.config = null; - this.currentConfig = null; - this.markers = null; - this.currentMarker = null; - } - -}); - -module.exports = BaseSound; - - -/***/ }), -/* 79 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Clone = __webpack_require__(33); -var EventEmitter = __webpack_require__(9); -var NOOP = __webpack_require__(3); - -/** - * @callback EachActiveSoundCallback - * - * @param {Phaser.Sound.BaseSoundManager} manager - The SoundManager - * @param {Phaser.Sound.BaseSound} sound - The current active Sound - * @param {number} index - The index of the current active Sound - * @param {Phaser.Sound.BaseSound[]} sounds - All sounds - */ - -/** - * Audio sprite sound type. - * - * @typedef {Phaser.Sound.BaseSound} Phaser.Sound.BaseSound.AudioSpriteSound - * - * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. - */ - -/** - * @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 - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var BaseSoundManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function BaseSoundManager (game) - { - EventEmitter.call(this); - - /** - * Local reference to game. - * - * @name Phaser.Sound.BaseSoundManager#game - * @type {Phaser.Game} - * @readOnly - * @since 3.0.0 - */ - this.game = game; - - /** - * Local reference to the JSON Cache, as used by Audio Sprites. - * - * @name Phaser.Sound.BaseSoundManager#jsonCache - * @type {Phaser.Cache.BaseCache} - * @readOnly - * @since 3.7.0 - */ - this.jsonCache = game.cache.json; - - /** - * An array containing all added sounds. - * - * @name Phaser.Sound.BaseSoundManager#sounds - * @type {Phaser.Sound.BaseSound[]} - * @default [] - * @private - * @since 3.0.0 - */ - this.sounds = []; - - /** - * Global mute setting. - * - * @name Phaser.Sound.BaseSoundManager#mute - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.mute = false; - - /** - * Global volume setting. - * - * @name Phaser.Sound.BaseSoundManager#volume - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.volume = 1; - - /** - * Flag indicating if sounds should be paused when game looses focus, - * for instance when user switches to another tab/program/app. - * - * @name Phaser.Sound.BaseSoundManager#pauseOnBlur - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.pauseOnBlur = true; - - /** - * Property that actually holds the value of global playback rate. - * - * @name Phaser.Sound.BaseSoundManager#_rate - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._rate = 1; - - /** - * Property that actually holds the value of global detune. - * - * @name Phaser.Sound.BaseSoundManager#_detune - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._detune = 0; - - /** - * Mobile devices require sounds to be triggered from an explicit user action, - * such as a tap, before any sound can be loaded/played on a web page. - * Set to true if the audio system is currently locked awaiting user interaction. - * - * @name Phaser.Sound.BaseSoundManager#locked - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.locked = this.locked || false; - - /** - * Flag used internally for handling when the audio system - * has been unlocked, if there ever was a need for it. - * - * @name Phaser.Sound.BaseSoundManager#unlocked - * @type {boolean} - * @default false - * @private - * @since 3.0.0 - */ - this.unlocked = false; - - game.events.on('blur', function () - { - if (this.pauseOnBlur) - { - this.onBlur(); - } - }, this); - - game.events.on('focus', function () - { - if (this.pauseOnBlur) - { - this.onFocus(); - } - }, this); - - game.events.on('prestep', this.update, this); - game.events.once('destroy', this.destroy, this); - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.BaseSoundManager#add - * @override - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.BaseSound} The new sound instance. - */ - add: NOOP, - - /** - * Adds a new audio sprite sound into the sound manager. - * Audio Sprites are a combination of audio files and a JSON configuration. - * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite - * - * @method Phaser.Sound.BaseSoundManager#addAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.BaseSound.AudioSpriteSound} The new audio sprite sound instance. - */ - addAudioSprite: function (key, config) - { - if (config === undefined) { config = {}; } - - var sound = this.add(key, config); - - sound.spritemap = this.jsonCache.get(key).spritemap; - - for (var markerName in sound.spritemap) - { - if (!sound.spritemap.hasOwnProperty(markerName)) - { - continue; - } - - var markerConfig = Clone(config); - - var marker = sound.spritemap[markerName]; - - markerConfig.loop = (marker.hasOwnProperty('loop')) ? marker.loop : false; - - sound.addMarker({ - name: markerName, - start: marker.start, - duration: marker.end - marker.start, - config: markerConfig - }); - } - - return sound; - }, - - /** - * Enables playing sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#play - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {(SoundConfig|SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (key, extra) - { - var sound = this.add(key); - - sound.once('ended', sound.destroy, sound); - - if (extra) - { - if (extra.name) - { - sound.addMarker(extra); - - return sound.play(extra.name); - } - else - { - return sound.play(extra); - } - } - else - { - return sound.play(); - } - }, - - /** - * Enables playing audio sprite sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#playAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {string} spriteName - The name of the sound sprite to play. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {boolean} Whether the audio sprite sound started playing successfully. - */ - playAudioSprite: function (key, spriteName, config) - { - var sound = this.addAudioSprite(key); - - sound.once('ended', sound.destroy, sound); - - return sound.play(spriteName, config); - }, - - /** - * Removes a sound from the sound manager. - * The removed sound is destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#remove - * @since 3.0.0 - * - * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. - * - * @return {boolean} True if the sound was removed successfully, otherwise false. - */ - remove: function (sound) - { - var index = this.sounds.indexOf(sound); - - if (index !== -1) - { - sound.destroy(); - - this.sounds.splice(index, 1); - - return true; - } - - return false; - }, - - /** - * Removes all sounds from the sound manager that have an asset key matching the given value. - * The removed sounds are destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#removeByKey - * @since 3.0.0 - * - * @param {string} key - The key to match when removing sound objects. - * - * @return {number} The number of matching sound objects that were removed. - */ - removeByKey: function (key) - { - var removed = 0; - - for (var i = this.sounds.length - 1; i >= 0; i--) - { - var sound = this.sounds[i]; - - if (sound.key === key) - { - sound.destroy(); - - this.sounds.splice(i, 1); - - removed++; - } - } - - return removed; - }, - - /** - * @event Phaser.Sound.BaseSoundManager#pauseall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - - /** - * Pauses all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#pauseAll - * @fires Phaser.Sound.BaseSoundManager#pauseall - * @since 3.0.0 - */ - pauseAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.pause(); - }); - - this.emit('pauseall', this); - }, - - /** - * @event Phaser.Sound.BaseSoundManager#resumeall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - - /** - * Resumes all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#resumeAll - * @fires Phaser.Sound.BaseSoundManager#resumeall - * @since 3.0.0 - */ - resumeAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.resume(); - }); - - this.emit('resumeall', this); - }, - - /** - * @event Phaser.Sound.BaseSoundManager#stopall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - - /** - * Stops all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#stopAll - * @fires Phaser.Sound.BaseSoundManager#stopall - * @since 3.0.0 - */ - stopAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.stop(); - }); - - this.emit('stopall', this); - }, - - /** - * Method used internally for unlocking audio playback on devices that - * require user interaction before any sound can be played on a web page. - * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - * - * @method Phaser.Sound.BaseSoundManager#unlock - * @override - * @protected - * @since 3.0.0 - */ - unlock: NOOP, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onBlur - * @override - * @protected - * @since 3.0.0 - */ - onBlur: NOOP, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onFocus - * @override - * @protected - * @since 3.0.0 - */ - onFocus: NOOP, - - /** - * Update method called on every game step. - * Removes destroyed sounds and updates every active sound in the game. - * - * @method Phaser.Sound.BaseSoundManager#update - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: function (time, delta) - { - if (this.unlocked) - { - this.unlocked = false; - this.locked = false; - - /** - * @event Phaser.Sound.BaseSoundManager#unlocked - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - this.emit('unlocked', this); - } - - for (var i = this.sounds.length - 1; i >= 0; i--) - { - if (this.sounds[i].pendingRemove) - { - this.sounds.splice(i, 1); - } - } - - this.sounds.forEach(function (sound) - { - sound.update(time, delta); - }); - }, - - /** - * Destroys all the sounds in the game and all associated events. - * - * @method Phaser.Sound.BaseSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllListeners(); - - this.forEachActiveSound(function (sound) - { - sound.destroy(); - }); - - this.sounds.length = 0; - this.sounds = null; - - this.game = null; - }, - - /** - * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. - * - * @method Phaser.Sound.BaseSoundManager#forEachActiveSound - * @private - * @since 3.0.0 - * - * @param {EachActiveSoundCallback} callback - Callback function. (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Manager.BaseSound[]) => void - * @param {*} [scope] - Callback context. - */ - forEachActiveSound: function (callback, scope) - { - var _this = this; - - this.sounds.forEach(function (sound, index) - { - if (!sound.pendingRemove) - { - callback.call(scope || _this, sound, index, _this.sounds); - } - }); - }, - - /** - * @event Phaser.Sound.BaseSoundManager#rate - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. - */ - - /** - * 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. - * - * @method Phaser.Sound.BaseSoundManager#setRate - * @fires Phaser.Sound.BaseSoundManager#rate - * @since 3.3.0 - * - * @param {number} value - Global playback rate at which all the sounds will be played. - * - * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. - */ - setRate: function (value) - { - this.rate = value; - - return this; - }, - - /** - * Global playback rate at which all the sounds will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audio's playback speed. - * - * @name Phaser.Sound.BaseSoundManager#rate - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rate: { - - get: function () - { - return this._rate; - }, - - set: function (value) - { - this._rate = value; - - this.forEachActiveSound(function (sound) - { - sound.calculateRate(); - }); - - this.emit('rate', this, value); - } - - }, - - /** - * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @method Phaser.Sound.BaseSoundManager#setDetune - * @fires Phaser.Sound.BaseSoundManager#detune - * @since 3.3.0 - * - * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. - */ - setDetune: function (value) - { - this.detune = value; - - return this; - }, - - /** - * @event Phaser.Sound.BaseSoundManager#detune - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. - */ - - /** - * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @name Phaser.Sound.BaseSoundManager#detune - * @type {number} - * @default 0 - * @since 3.0.0 - */ - detune: { - - get: function () - { - return this._detune; - }, - - set: function (value) - { - this._detune = value; - - this.forEachActiveSound(function (sound) - { - sound.calculateRate(); - }); - - this.emit('detune', this, value); - } - - } - -}); - -module.exports = BaseSoundManager; - - -/***/ }), -/* 80 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(57); - -/** - * Determines the browser type and version running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.browser` from within any Scene. - * - * @typedef {object} Phaser.Device.Browser - * @since 3.0.0 - * - * @property {boolean} chrome - Set to true if running in Chrome. - * @property {boolean} edge - Set to true if running in Microsoft Edge browser. - * @property {boolean} firefox - Set to true if running in Firefox. - * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). - * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. - * @property {boolean} opera - Set to true if running in Opera. - * @property {boolean} safari - Set to true if running in Safari. - * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) - * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) - * @property {number} chromeVersion - If running in Chrome this will contain the major version number. - * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. - * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. - * @property {number} safariVersion - If running in Safari this will contain the major version number. - * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} - */ -var Browser = { - - chrome: false, - chromeVersion: 0, - edge: false, - firefox: false, - firefoxVersion: 0, - ie: false, - ieVersion: 0, - mobileSafari: false, - opera: false, - safari: false, - safariVersion: 0, - silk: false, - trident: false, - tridentVersion: 0 - -}; - -function init () -{ - var ua = navigator.userAgent; - - if (/Edge\/\d+/.test(ua)) - { - Browser.edge = true; - } - else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) - { - Browser.chrome = true; - Browser.chromeVersion = parseInt(RegExp.$1, 10); - } - else if ((/Firefox\D+(\d+)/).test(ua)) - { - Browser.firefox = true; - Browser.firefoxVersion = parseInt(RegExp.$1, 10); - } - else if ((/AppleWebKit/).test(ua) && OS.iOS) - { - Browser.mobileSafari = true; - } - else if ((/MSIE (\d+\.\d+);/).test(ua)) - { - Browser.ie = true; - Browser.ieVersion = parseInt(RegExp.$1, 10); - } - else if ((/Opera/).test(ua)) - { - Browser.opera = true; - } - else if ((/Safari/).test(ua) && !OS.windowsPhone) - { - Browser.safari = true; - } - else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) - { - Browser.ie = true; - Browser.trident = true; - Browser.tridentVersion = parseInt(RegExp.$1, 10); - Browser.ieVersion = parseInt(RegExp.$3, 10); - } - - // Silk gets its own if clause because its ua also contains 'Safari' - if ((/Silk/).test(ua)) - { - Browser.silk = true; - } - - return Browser; -} - -module.exports = init(); - - -/***/ }), -/* 81 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback DataEachCallback - * - * @param {*} parent - The parent object of the DataManager. - * @param {string} key - The key of the value. - * @param {*} value - The value. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. - */ - -/** - * @classdesc - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - * - * @class DataManager - * @memberOf Phaser.Data - * @constructor - * @since 3.0.0 - * - * @param {object} parent - The object that this DataManager belongs to. - * @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter. - */ -var DataManager = new Class({ - - initialize: - - function DataManager (parent, eventEmitter) - { - /** - * The object that this DataManager belongs to. - * - * @name Phaser.Data.DataManager#parent - * @type {*} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * The DataManager's event emitter. - * - * @name Phaser.Data.DataManager#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events = eventEmitter; - - if (!eventEmitter) - { - this.events = (parent.events) ? parent.events : parent; - } - - /** - * The data list. - * - * @name Phaser.Data.DataManager#list - * @type {Object.} - * @default {} - * @since 3.0.0 - */ - this.list = {}; - - /** - * The public values list. You can use this to access anything you have stored - * in this Data Manager. For example, if you set a value called `gold` you can - * access it via: - * - * ```javascript - * this.data.values.gold; - * ``` - * - * You can also modify it directly: - * - * ```javascript - * this.data.values.gold += 1000; - * ``` - * - * Doing so will emit a `setdata` event from the parent of this Data Manager. - * - * @name Phaser.Data.DataManager#values - * @type {Object.} - * @default {} - * @since 3.10.0 - */ - this.values = {}; - - /** - * Whether setting data is frozen for this DataManager. - * - * @name Phaser.Data.DataManager#_frozen - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._frozen = false; - - if (!parent.hasOwnProperty('sys') && this.events) - { - this.events.once('destroy', this.destroy, this); - } - }, - - /** - * Retrieves the value for the given key, or undefined if it doesn't exist. - * - * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * - * ```javascript - * this.data.get('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * this.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: - * - * ```javascript - * this.data.get([ 'gold', 'armor', 'health' ]); - * ``` - * - * This approach is useful for destructuring arrays in ES6. - * - * @method Phaser.Data.DataManager#get - * @since 3.0.0 - * - * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. - * - * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. - */ - get: function (key) - { - var list = this.list; - - if (Array.isArray(key)) - { - var output = []; - - for (var i = 0; i < key.length; i++) - { - output.push(list[key[i]]); - } - - return output; - } - else - { - return list[key]; - } - }, - - /** - * Retrieves all data values in a new object. - * - * @method Phaser.Data.DataManager#getAll - * @since 3.0.0 - * - * @return {Object.} All data values. - */ - getAll: function () - { - var results = {}; - - for (var key in this.list) - { - if (this.list.hasOwnProperty(key)) - { - results[key] = this.list[key]; - } - } - - return results; - }, - - /** - * Queries the DataManager for the values of keys matching the given regular expression. - * - * @method Phaser.Data.DataManager#query - * @since 3.0.0 - * - * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). - * - * @return {Object.} The values of the keys matching the search string. - */ - query: function (search) - { - var results = {}; - - for (var key in this.list) - { - if (this.list.hasOwnProperty(key) && key.match(search)) - { - results[key] = this.list[key]; - } - } - - return results; - }, - - /** - * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * data.set('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `get`: - * - * ```javascript - * data.get('gold'); - * ``` - * - * Or you can access the value directly via the `values` property, where it works like any other variable: - * - * ```javascript - * data.values.gold += 50; - * ``` - * - * When the value is first set, a `setdata` event is emitted. - * - * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. - * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. - * - * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * - * @method Phaser.Data.DataManager#set - * @since 3.0.0 - * - * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. - * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - set: function (key, data) - { - if (this._frozen) - { - return this; - } - - if (typeof key === 'string') - { - return this.setValue(key, data); - } - else - { - for (var entry in key) - { - this.setValue(entry, key[entry]); - } - } - - return this; - }, - - /** - * Internal value setter, called automatically by the `set` method. - * - * @method Phaser.Data.DataManager#setValue - * @private - * @since 3.10.0 - * - * @param {string} key - The key to set the value for. - * @param {*} data - The value to set. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - setValue: function (key, data) - { - if (this._frozen) - { - return this; - } - - if (this.has(key)) - { - // Hit the key getter, which will in turn emit the events. - this.values[key] = data; - } - else - { - var _this = this; - var list = this.list; - var events = this.events; - var parent = this.parent; - - Object.defineProperty(this.values, key, { - - enumerable: true, - - get: function () - { - return list[key]; - }, - - set: function (value) - { - if (!_this._frozen) - { - list[key] = value; - - events.emit('changedata', parent, key, data); - events.emit('changedata_' + key, parent, data); - } - } - - }); - - list[key] = data; - - events.emit('setdata', parent, key, data); - } - - return this; - }, - - /** - * Passes all data entries to the given callback. - * - * @method Phaser.Data.DataManager#each - * @since 3.0.0 - * - * @param {DataEachCallback} callback - The function to call. - * @param {*} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - each: function (callback, context) - { - var args = [ this.parent, null, undefined ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var key in this.list) - { - args[1] = key; - args[2] = this.list[key]; - - callback.apply(context, args); - } - - return this; - }, - - /** - * Merge the given object of key value pairs into this DataManager. - * - * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) - * will emit a `changedata` event. - * - * @method Phaser.Data.DataManager#merge - * @since 3.0.0 - * - * @param {Object.} data - The data to merge. - * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - merge: function (data, overwrite) - { - if (overwrite === undefined) { overwrite = true; } - - // Merge data from another component into this one - for (var key in data) - { - if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) - { - this.setValue(key, data[key]); - } - } - - return this; - }, - - /** - * Remove the value for the given key. - * - * If the key is found in this Data Manager it is removed from the internal lists and a - * `removedata` event is emitted. - * - * You can also pass in an array of keys, in which case all keys in the array will be removed: - * - * ```javascript - * this.data.remove([ 'gold', 'armor', 'health' ]); - * ``` - * - * @method Phaser.Data.DataManager#remove - * @since 3.0.0 - * - * @param {(string|string[])} key - The key to remove, or an array of keys to remove. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - remove: function (key) - { - if (this._frozen) - { - return this; - } - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - this.removeValue(key[i]); - } - } - else - { - return this.removeValue(key); - } - - return this; - }, - - /** - * Internal value remover, called automatically by the `remove` method. - * - * @method Phaser.Data.DataManager#removeValue - * @private - * @since 3.10.0 - * - * @param {string} key - The key to set the value for. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - removeValue: function (key) - { - if (this.has(key)) - { - var data = this.list[key]; - - delete this.list[key]; - delete this.values[key]; - - this.events.emit('removedata', this, key, data); - } - - return this; - }, - - /** - * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. - * - * @method Phaser.Data.DataManager#pop - * @since 3.0.0 - * - * @param {string} key - The key of the value to retrieve and delete. - * - * @return {*} The value of the given key. - */ - pop: function (key) - { - var data = undefined; - - if (!this._frozen && this.has(key)) - { - data = this.list[key]; - - delete this.list[key]; - delete this.values[key]; - - this.events.emit('removedata', this, key, data); - } - - return data; - }, - - /** - * Determines whether the given key is set in this Data Manager. - * - * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * - * @method Phaser.Data.DataManager#has - * @since 3.0.0 - * - * @param {string} key - The key to check. - * - * @return {boolean} Returns `true` if the key exists, otherwise `false`. - */ - has: function (key) - { - return this.list.hasOwnProperty(key); - }, - - /** - * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts - * to create new values or update existing ones. - * - * @method Phaser.Data.DataManager#setFreeze - * @since 3.0.0 - * - * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - setFreeze: function (value) - { - this._frozen = value; - - return this; - }, - - /** - * Delete all data in this Data Manager and unfreeze it. - * - * @method Phaser.Data.DataManager#reset - * @since 3.0.0 - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - reset: function () - { - for (var key in this.list) - { - delete this.list[key]; - delete this.values[key]; - } - - this._frozen = false; - - return this; - }, - - /** - * Destroy this data manager. - * - * @method Phaser.Data.DataManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.reset(); - - this.events.off('changedata'); - this.events.off('setdata'); - this.events.off('removedata'); - - this.parent = null; - }, - - /** - * Gets or sets the frozen state of this Data Manager. - * A frozen Data Manager will block all attempts to create new values or update existing ones. - * - * @name Phaser.Data.DataManager#freeze - * @type {boolean} - * @since 3.0.0 - */ - freeze: { - - get: function () - { - return this._frozen; - }, - - set: function (value) - { - this._frozen = (value) ? true : false; - } - - }, - - /** - * Return the total number of entries in this Data Manager. - * - * @name Phaser.Data.DataManager#count - * @type {integer} - * @since 3.0.0 - */ - count: { - - get: function () - { - var i = 0; - - for (var key in this.list) - { - if (this.list[key] !== undefined) - { - i++; - } - } - - return i; - } - - } - -}); - -module.exports = DataManager; - - -/***/ }), -/* 82 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Angle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Angle = function (line) -{ - return Math.atan2(line.y2 - line.y1, line.x2 - line.x1); -}; - -module.exports = Angle; - - -/***/ }), -/* 83 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -//! stable.js 0.1.6, https://github.com/Two-Screen/stable -//! © 2017 Angry Bytes and contributors. MIT licensed. - -(function() { - -// A stable array sort, because `Array#sort()` is not guaranteed stable. -// This is an implementation of merge sort, without recursion. - -var stable = function(arr, comp) { - return exec(arr.slice(), comp); -}; - -stable.inplace = function(arr, comp) { - var result = exec(arr, comp); - - // This simply copies back if the result isn't in the original array, - // which happens on an odd number of passes. - if (result !== arr) { - pass(result, null, arr.length, arr); - } - - return arr; -}; - -// Execute the sort using the input array and a second buffer as work space. -// Returns one of those two, containing the final result. -function exec(arr, comp) { - if (typeof(comp) !== 'function') { - comp = function(a, b) { - return String(a).localeCompare(b); - }; - } - - // Short-circuit when there's nothing to sort. - var len = arr.length; - if (len <= 1) { - return arr; - } - - // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. - // Chunks are the size of the left or right hand in merge sort. - // Stop when the left-hand covers all of the array. - var buffer = new Array(len); - for (var chk = 1; chk < len; chk *= 2) { - pass(arr, comp, chk, buffer); - - var tmp = arr; - arr = buffer; - buffer = tmp; - } - - return arr; -} - -// Run a single pass with the given chunk size. -var pass = function(arr, comp, chk, result) { - var len = arr.length; - var i = 0; - // Step size / double chunk size. - var dbl = chk * 2; - // Bounds of the left and right chunks. - var l, r, e; - // Iterators over the left and right chunk. - var li, ri; - - // Iterate over pairs of chunks. - for (l = 0; l < len; l += dbl) { - r = l + chk; - e = r + chk; - if (r > len) r = len; - if (e > len) e = len; - - // Iterate both chunks in parallel. - li = l; - ri = r; - while (true) { - // Compare the chunks. - if (li < r && ri < e) { - // This works for a regular `sort()` compatible comparator, - // but also for a simple comparator like: `a > b` - if (comp(arr[li], arr[ri]) <= 0) { - result[i++] = arr[li++]; - } - else { - result[i++] = arr[ri++]; - } - } - // Nothing to compare, just flush what's left. - else if (li < r) { - result[i++] = arr[li++]; - } - else if (ri < e) { - result[i++] = arr[ri++]; - } - // Both iterators are at the chunk ends. - else { - break; - } - } - } -}; - -// Export using CommonJS or to the window. -if (true) { - module.exports = stable; -} -else {} - -})(); - -/***/ }), -/* 84 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Utils = __webpack_require__(27); - -/** - * @classdesc - * WebGLPipeline is a class that describes the way elements will be rendererd - * in WebGL, specially focused on batching vertices (batching is not provided). - * Pipelines are mostly used for describing 2D rendering passes but it's - * flexible enough to be used for any type of rendering including 3D. - * Internally WebGLPipeline will handle things like compiling shaders, - * creating vertex buffers, assigning primitive topology and binding - * vertex attributes. - * - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - gl: Current WebGL context. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - vertices: An optional buffer of vertices - * - attributes: An array describing the vertex attributes - * - * The vertex attributes properties are: - * - name : String - Name of the attribute in the vertex shader - * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 - * - type : GLenum - WebGL type (gl.BYTE, gl.SHORT, gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.FLOAT) - * - normalized : boolean - Is the attribute normalized - * - offset : integer - The offset in bytes to the current attribute in the vertex. Equivalent to offsetof(vertex, attrib) in C - * Here you can find more information of how to describe an attribute: - * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer - * - * @class WebGLPipeline - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var WebGLPipeline = new Class({ - - initialize: - - function WebGLPipeline (config) - { - /** - * Name of the Pipeline. Used for identifying - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#name - * @type {string} - * @since 3.0.0 - */ - this.name = 'WebGLPipeline'; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = config.game; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#view - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.view = config.game.canvas; - - /** - * Used to store the current game resolution - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#resolution - * @type {number} - * @since 3.0.0 - */ - this.resolution = config.game.config.resolution; - - /** - * Width of the current viewport - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#width - * @type {number} - * @since 3.0.0 - */ - this.width = config.game.config.width * this.resolution; - - /** - * Height of the current viewport - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#height - * @type {number} - * @since 3.0.0 - */ - this.height = config.game.config.height * this.resolution; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#gl - * @type {WebGLRenderingContext} - * @since 3.0.0 - */ - this.gl = config.gl; - - /** - * How many vertices have been fed to the current pipeline. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.vertexCount = 0; - - /** - * The limit of vertices that the pipeline can hold - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity - * @type {integer} - * @since 3.0.0 - */ - this.vertexCapacity = config.vertexCapacity; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#renderer - * @type {Phaser.Renderer.WebGL.WebGLRenderer} - * @since 3.0.0 - */ - this.renderer = config.renderer; - - /** - * Raw byte buffer of vertices. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexData - * @type {ArrayBuffer} - * @since 3.0.0 - */ - this.vertexData = (config.vertices ? config.vertices : new ArrayBuffer(config.vertexCapacity * config.vertexSize)); - - /** - * The handle to a WebGL vertex buffer object. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer - * @type {WebGLBuffer} - * @since 3.0.0 - */ - this.vertexBuffer = this.renderer.createVertexBuffer((config.vertices ? config.vertices : this.vertexData.byteLength), this.gl.STREAM_DRAW); - - /** - * The handle to a WebGL program - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#program - * @type {WebGLProgram} - * @since 3.0.0 - */ - this.program = this.renderer.createProgram(config.vertShader, config.fragShader); - - /** - * Array of objects that describe the vertex attributes - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#attributes - * @type {object} - * @since 3.0.0 - */ - this.attributes = config.attributes; - - /** - * The size in bytes of the vertex - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexSize - * @type {integer} - * @since 3.0.0 - */ - this.vertexSize = config.vertexSize; - - /** - * The primitive topology which the pipeline will use to submit draw calls - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#topology - * @type {integer} - * @since 3.0.0 - */ - this.topology = config.topology; - - /** - * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources - * to the GPU. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#bytes - * @type {Uint8Array} - * @since 3.0.0 - */ - this.bytes = new Uint8Array(this.vertexData); - - /** - * This will store the amount of components of 32 bit length - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexComponentCount - * @type {integer} - * @since 3.0.0 - */ - this.vertexComponentCount = Utils.getComponentCount(config.attributes, this.gl); - - /** - * Indicates if the current pipeline is flushing the contents to the GPU. - * When the variable is set the flush function will be locked. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#flushLocked - * @type {boolean} - * @since 3.1.0 - */ - this.flushLocked = false; - - /** - * Indicates if the current pipeline is active or not for this frame only. - * Reset in the onRender method. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#active - * @type {boolean} - * @since 3.10.0 - */ - this.active = false; - }, - - /** - * Adds a description of vertex attribute to the pipeline - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#addAttribute - * @since 3.2.0 - * - * @param {string} name - Name of the vertex attribute - * @param {integer} size - Vertex component size - * @param {integer} type - Type of the attribute - * @param {boolean} normalized - Is the value normalized to a range - * @param {integer} offset - Byte offset to the beginning of the first element in the vertex - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - addAttribute: function (name, size, type, normalized, offset) - { - this.attributes.push({ - name: name, - size: size, - type: this.renderer.glFormats[type], - normalized: normalized, - offset: offset - }); - - return this; - }, - - /** - * Check if the current batch of vertices is full. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush - * @since 3.0.0 - * - * @return {boolean} [description] - */ - shouldFlush: function () - { - return (this.vertexCount >= this.vertexCapacity); - }, - - /** - * Resizes the properties used to describe the viewport - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - resize: function (width, height, resolution) - { - this.width = width * resolution; - this.height = height * resolution; - return this; - }, - - /** - * Binds the pipeline resources, including programs, vertex buffers and binds attributes - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#bind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - bind: function () - { - var gl = this.gl; - var vertexBuffer = this.vertexBuffer; - var attributes = this.attributes; - var program = this.program; - var renderer = this.renderer; - var vertexSize = this.vertexSize; - - renderer.setProgram(program); - renderer.setVertexBuffer(vertexBuffer); - - for (var index = 0; index < attributes.length; ++index) - { - var element = attributes[index]; - var location = gl.getAttribLocation(program, element.name); - - if (location >= 0) - { - gl.enableVertexAttribArray(location); - gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexSize, element.offset); - } - else - { - gl.disableVertexAttribArray(location); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onBind: function () - { - // This is for updating uniform data it's called on each bind attempt. - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onPreRender - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onPreRender: function () - { - // called once every frame - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onRender - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onRender: function () - { - // called for each camera - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onPostRender - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onPostRender: function () - { - // called once every frame - return this; - }, - - /** - * Uploads the vertex data and emits a draw call - * for the current batch of vertices. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#flush - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - flush: function () - { - if (this.flushLocked) { return this; } - - this.flushLocked = true; - - var gl = this.gl; - var vertexCount = this.vertexCount; - var topology = this.topology; - var vertexSize = this.vertexSize; - - if (vertexCount === 0) - { - this.flushLocked = false; - return; - } - - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); - gl.drawArrays(topology, 0, vertexCount); - - this.vertexCount = 0; - this.flushLocked = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#destroy - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - destroy: function () - { - var gl = this.gl; - - gl.deleteProgram(this.program); - gl.deleteBuffer(this.vertexBuffer); - - delete this.program; - delete this.vertexBuffer; - delete this.gl; - - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {float} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat1: function (name, x) - { - this.renderer.setFloat1(this.program, name, x); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat2: function (name, x, y) - { - - this.renderer.setFloat2(this.program, name, x, y); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat3: function (name, x, y, z) - { - - this.renderer.setFloat3(this.program, name, x, y, z); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4 - * @since 3.2.0 - * - * @param {string} name - Name of the uniform - * @param {float} x - X component of the uniform - * @param {float} y - Y component of the uniform - * @param {float} z - Z component of the uniform - * @param {float} w - W component of the uniform - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat4: function (name, x, y, z, w) - { - - this.renderer.setFloat4(this.program, name, x, y, z, w); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt1 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {integer} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt1: function (name, x) - { - this.renderer.setInt1(this.program, name, x); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt2 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt2: function (name, x, y) - { - this.renderer.setInt2(this.program, name, x, y); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt3 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt3: function (name, x, y, z) - { - this.renderer.setInt3(this.program, name, x, y, z); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt4 - * @since 3.2.0 - * - * @param {string} name - Name of the uniform - * @param {integer} x - X component of the uniform - * @param {integer} y - Y component of the uniform - * @param {integer} z - Z component of the uniform - * @param {integer} w - W component of the uniform - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt4: function (name, x, y, z, w) - { - this.renderer.setInt4(this.program, name, x, y, z, w); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setMatrix2: function (name, transpose, matrix) - { - this.renderer.setMatrix2(this.program, name, transpose, matrix); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * [description] - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setMatrix3: function (name, transpose, matrix) - { - this.renderer.setMatrix3(this.program, name, transpose, matrix); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4 - * @since 3.2.0 - * - * @param {string} name - Name of the uniform - * @param {boolean} transpose - Should the matrix be transpose - * @param {Float32Array} matrix - Matrix data - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setMatrix4: function (name, transpose, matrix) - { - this.renderer.setMatrix4(this.program, name, transpose, matrix); - return this; - } - -}); - -module.exports = WebGLPipeline; - - -/***/ }), -/* 85 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks if the given `width` and `height` are a power of two. - * Useful for checking texture dimensions. - * - * @function Phaser.Math.Pow2.IsSizePowerOfTwo - * @since 3.0.0 - * - * @param {number} width - The width. - * @param {number} height - The height. - * - * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. - */ -var IsSizePowerOfTwo = function (width, height) -{ - return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); -}; - -module.exports = IsSizePowerOfTwo; - - -/***/ }), -/* 86 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FromPoints = __webpack_require__(274); -var Rectangle = __webpack_require__(14); -var Vector2 = __webpack_require__(6); +var FromPoints = __webpack_require__(173); +var Rectangle = __webpack_require__(9); +var Vector2 = __webpack_require__(3); /** * @classdesc @@ -14038,7 +11891,7 @@ var Vector2 = __webpack_require__(6); * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) * * @class Curve - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * @@ -14153,7 +12006,7 @@ var Curve = new Class({ // So you can chain graphics calls return graphics.strokePoints(this.getPoints(pointsTotal)); }, - + /** * Returns a Rectangle where the position and dimensions match the bounds of this Curve. * @@ -14214,9 +12067,9 @@ var Curve = new Class({ * @method Phaser.Curves.Curve#getEndPoint * @since 3.0.0 * - * @param {Phaser.Math.Vector2} out - [description] + * @param {Phaser.Math.Vector2} [out] - Optional Vector object to store the result in. * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} Vector2 containing the coordinates of the curves end point. */ getEndPoint: function (out) { @@ -14300,7 +12153,7 @@ var Curve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -14420,7 +12273,7 @@ var Curve = new Class({ * @param {number} t - [description] * @param {Phaser.Math.Vector2} [out] - [description] * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001) */ getTangent: function (t, out) { @@ -14456,7 +12309,7 @@ var Curve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -14478,7 +12331,7 @@ var Curve = new Class({ * @param {integer} distance - [description] * @param {integer} [divisions] - [description] * - * @return {float} [description] + * @return {number} [description] */ getTFromDistance: function (distance, divisions) { @@ -14498,7 +12351,7 @@ var Curve = new Class({ * @method Phaser.Curves.Curve#getUtoTmapping * @since 3.0.0 * - * @param {float} u - [description] + * @param {number} u - [description] * @param {integer} distance - [description] * @param {integer} [divisions] - [description] * @@ -14592,793 +12445,7 @@ module.exports = Curve; /***/ }), -/* 87 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A representation of a vector in 3D space. - * - * A three-component vector. - * - * @class Vector3 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - The x component. - * @param {number} [y] - The y component. - * @param {number} [z] - The z component. - */ -var Vector3 = new Class({ - - initialize: - - function Vector3 (x, y, z) - { - /** - * The x component of this Vector. - * - * @name Phaser.Math.Vector3#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The y component of this Vector. - * - * @name Phaser.Math.Vector3#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The z component of this Vector. - * - * @name Phaser.Math.Vector3#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.z = 0; - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - }, - - /** - * Set this Vector to point up. - * - * Sets the y component of the vector to 1, and the others to 0. - * - * @method Phaser.Math.Vector3#up - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - up: function () - { - this.x = 0; - this.y = 1; - this.z = 0; - - return this; - }, - - /** - * Make a clone of this Vector3. - * - * @method Phaser.Math.Vector3#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} A new Vector3 object containing this Vectors values. - */ - clone: function () - { - return new Vector3(this.x, this.y, this.z); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#crossVectors - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} a - [description] - * @param {Phaser.Math.Vector3} b - [description] - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - crossVectors: function (a, b) - { - var ax = a.x; - var ay = a.y; - var az = a.z; - var bx = b.x; - var by = b.y; - var bz = b.z; - - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; - - return this; - }, - - /** - * Check whether this Vector is equal to a given Vector. - * - * Performs a strict equality check against each Vector's components. - * - * @method Phaser.Math.Vector3#equals - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} v - The Vector3 to compare against. - * - * @return {boolean} True if the two vectors strictly match, otherwise false. - */ - equals: function (v) - { - return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); - }, - - /** - * Copy the components of a given Vector into this Vector. - * - * @method Phaser.Math.Vector3#copy - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} src - The Vector to copy the components from. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z || 0; - - return this; - }, - - /** - * Set the `x`, `y`, and `z` components of this Vector to the given `x`, `y`, and `z` values. - * - * @method Phaser.Math.Vector3#set - * @since 3.0.0 - * - * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y and z components. - * @param {number} [y] - The y value to set for this Vector. - * @param {number} [z] - The z value to set for this Vector. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - set: function (x, y, z) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - - return this; - }, - - /** - * Add a given Vector to this Vector. Addition is component-wise. - * - * @method Phaser.Math.Vector3#add - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to add to this Vector. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z || 0; - - return this; - }, - - /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * - * @method Phaser.Math.Vector3#subtract - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to subtract from this Vector. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z || 0; - - return this; - }, - - /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * - * @method Phaser.Math.Vector3#multiply - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to multiply this Vector by. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - multiply: function (v) - { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z || 1; - - return this; - }, - - /** - * Scale this Vector by the given value. - * - * @method Phaser.Math.Vector3#scale - * @since 3.0.0 - * - * @param {number} scale - The value to scale this Vector by. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - scale: function (scale) - { - if (isFinite(scale)) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - } - else - { - this.x = 0; - this.y = 0; - this.z = 0; - } - - return this; - }, - - /** - * Perform a component-wise division between this Vector and the given Vector. - * - * Divides this Vector by the given Vector. - * - * @method Phaser.Math.Vector3#divide - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to divide this Vector by. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - divide: function (v) - { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z || 1; - - return this; - }, - - /** - * Negate the `x`, `y` and `z` components of this Vector. - * - * @method Phaser.Math.Vector3#negate - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - negate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - - return this; - }, - - /** - * Calculate the distance between this Vector and the given Vector. - * - * @method Phaser.Math.Vector3#distance - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. - * - * @return {number} The distance from this Vector to the given Vector. - */ - distance: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - - return Math.sqrt(dx * dx + dy * dy + dz * dz); - }, - - /** - * Calculate the distance between this Vector, and the given Vector, squared. - * - * @method Phaser.Math.Vector3#distanceSq - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. - * - * @return {number} The distance from this Vector to the given Vector, squared. - */ - distanceSq: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - - return dx * dx + dy * dy + dz * dz; - }, - - /** - * Calculate the length (or magnitude) of this Vector. - * - * @method Phaser.Math.Vector3#length - * @since 3.0.0 - * - * @return {number} The length of this Vector. - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - return Math.sqrt(x * x + y * y + z * z); - }, - - /** - * Calculate the length of this Vector squared. - * - * @method Phaser.Math.Vector3#lengthSq - * @since 3.0.0 - * - * @return {number} The length of this Vector, squared. - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - return x * x + y * y + z * z; - }, - - /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. - * - * @method Phaser.Math.Vector3#normalize - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var len = x * x + y * y + z * z; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - } - - return this; - }, - - /** - * Calculate the dot product of this Vector and the given Vector. - * - * @method Phaser.Math.Vector3#dot - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} v - The Vector3 to dot product with this Vector3. - * - * @return {number} [description] - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#cross - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} v - [description] - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - cross: function (v) - { - var ax = this.x; - var ay = this.y; - var az = this.z; - var bx = v.x; - var by = v.y; - var bz = v.z; - - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; - - return this; - }, - - /** - * Linearly interpolate between this Vector and the given Vector. - * - * Interpolates this Vector towards the given Vector. - * - * @method Phaser.Math.Vector3#lerp - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} v - The Vector3 to interpolate towards. - * @param {number} [t=0] - The interpolation percentage, between 0 and 1. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - - return this; - }, - - /** - * Transform this Vector with the given Matrix. - * - * @method Phaser.Math.Vector3#transformMat3 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector3 with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - transformMat3: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - this.x = x * m[0] + y * m[3] + z * m[6]; - this.y = x * m[1] + y * m[4] + z * m[7]; - this.z = x * m[2] + y * m[5] + z * m[8]; - - return this; - }, - - /** - * Transform this Vector with the given Matrix. - * - * @method Phaser.Math.Vector3#transformMat4 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - transformMat4: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; - this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; - this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformCoordinates - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - transformCoordinates: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; - var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; - var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; - var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; - - this.x = tx / tw; - this.y = ty / tw; - this.z = tz / tw; - - return this; - }, - - /** - * Transform this Vector with the given Quaternion. - * - * @method Phaser.Math.Vector3#transformQuat - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - transformQuat: function (q) - { - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations - var x = this.x; - var y = this.y; - var z = this.z; - var qx = q.x; - var qy = q.y; - var qz = q.z; - var qw = q.w; - - // calculate quat * vec - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; - - return this; - }, - - /** - * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, - * e.g. unprojecting a 2D point into 3D space. - * - * @method Phaser.Math.Vector3#project - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat - The Matrix4 to multiply this Vector3 with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - project: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - var a00 = m[0]; - var a01 = m[1]; - var a02 = m[2]; - var a03 = m[3]; - var a10 = m[4]; - var a11 = m[5]; - var a12 = m[6]; - var a13 = m[7]; - var a20 = m[8]; - var a21 = m[9]; - var a22 = m[10]; - var a23 = m[11]; - var a30 = m[12]; - var a31 = m[13]; - var a32 = m[14]; - var a33 = m[15]; - - var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); - - this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; - this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; - this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; - - return this; - }, - - /** - * Unproject this point from 2D space to 3D space. - * The point should have its x and y properties set to - * 2D screen space, and the z either at 0 (near plane) - * or 1 (far plane). The provided matrix is assumed to already - * be combined, i.e. projection * view * model. - * - * After this operation, this vector's (x, y, z) components will - * represent the unprojected 3D coordinate. - * - * @method Phaser.Math.Vector3#unproject - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} viewport - Screen x, y, width and height in pixels. - * @param {Phaser.Math.Matrix4} invProjectionView - Combined projection and view matrix. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - unproject: function (viewport, invProjectionView) - { - var viewX = viewport.x; - var viewY = viewport.y; - var viewWidth = viewport.z; - var viewHeight = viewport.w; - - var x = this.x - viewX; - var y = (viewHeight - this.y - 1) - viewY; - var z = this.z; - - this.x = (2 * x) / viewWidth - 1; - this.y = (2 * y) / viewHeight - 1; - this.z = 2 * z - 1; - - return this.project(invProjectionView); - }, - - /** - * Make this Vector the zero vector (0, 0, 0). - * - * @method Phaser.Math.Vector3#reset - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - reset: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - - return this; - } - -}); - -/* -Vector3.Zero = function () -{ - return new Vector3(0, 0, 0); -}; - -Vector3.Up = function () -{ - return new Vector3(0, 1.0, 0); -}; - -Vector3.Copy = function (source) -{ - return new Vector3(source.x, source.y, source.z); -}; - -Vector3.TransformCoordinates = function (vector, transformation) -{ - var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; - var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; - var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; - var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; - - return new Vector3(x / w, y / w, z / w); -}; - -Vector3.TransformNormal = function (vector, transformation) -{ - var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); - var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); - var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); - - return new Vector3(x, y, z); -}; - -Vector3.Dot = function (left, right) -{ - return (left.x * right.x + left.y * right.y + left.z * right.z); -}; - -Vector3.Cross = function (left, right) -{ - var x = left.y * right.z - left.z * right.y; - var y = left.z * right.x - left.x * right.z; - var z = left.x * right.y - left.y * right.x; - - return new Vector3(x, y, z); -}; - -Vector3.Normalize = function (vector) -{ - var newVector = Vector3.Copy(vector); - newVector.normalize(); - - return newVector; -}; - -Vector3.Distance = function (value1, value2) -{ - return Math.sqrt(Vector3.DistanceSquared(value1, value2)); -}; - -Vector3.DistanceSquared = function (value1, value2) -{ - var x = value1.x - value2.x; - var y = value1.y - value2.y; - var z = value1.z - value2.z; - - return (x * x) + (y * y) + (z * z); -}; -*/ - -module.exports = Vector3; - - -/***/ }), -/* 88 */ +/* 71 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -15388,10 +12455,10 @@ module.exports = Vector3; */ var Class = __webpack_require__(0); -var Contains = __webpack_require__(32); -var GetPoint = __webpack_require__(298); -var GetPoints = __webpack_require__(296); -var Random = __webpack_require__(157); +var Contains = __webpack_require__(40); +var GetPoint = __webpack_require__(405); +var GetPoints = __webpack_require__(403); +var Random = __webpack_require__(191); /** * @classdesc @@ -15402,7 +12469,7 @@ var Random = __webpack_require__(157); * To render a Circle you should look at the capabilities of the Graphics class. * * @class Circle - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * @@ -15487,7 +12554,7 @@ var Circle = new Class({ * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. @@ -15741,7 +12808,7 @@ module.exports = Circle; /***/ }), -/* 89 */ +/* 72 */ /***/ (function(module, exports) { /** @@ -15769,7 +12836,7 @@ module.exports = GetCenterY; /***/ }), -/* 90 */ +/* 73 */ /***/ (function(module, exports) { /** @@ -15804,7 +12871,7 @@ module.exports = SetCenterY; /***/ }), -/* 91 */ +/* 74 */ /***/ (function(module, exports) { /** @@ -15839,7 +12906,7 @@ module.exports = SetCenterX; /***/ }), -/* 92 */ +/* 75 */ /***/ (function(module, exports) { /** @@ -15867,906 +12934,8 @@ module.exports = GetCenterX; /***/ }), -/* 93 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArrayUtils = __webpack_require__(147); -var Class = __webpack_require__(0); -var NOOP = __webpack_require__(3); -var StableSort = __webpack_require__(83); - -/** - * @callback EachListCallback - * @generic I - [item] - * - * @param {*} item - [description] - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ - -/** - * @classdesc - * [description] - * - * @class List - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic T - * - * @param {*} parent - [description] - */ -var List = new Class({ - - initialize: - - function List (parent) - { - /** - * The parent of this list. - * - * @name Phaser.Structs.List#parent - * @type {*} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * The objects that belong to this collection. - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.List#list - * @type {Array.<*>} - * @default [] - * @since 3.0.0 - */ - this.list = []; - - /** - * [description] - * - * @name Phaser.Structs.List#position - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.position = 0; - - /** - * A callback that is invoked every time a child is added to this list. - * - * @name Phaser.Structs.List#addCallback - * @type {function} - * @since 3.4.0 - */ - this.addCallback = NOOP; - - /** - * A callback that is invoked every time a child is removed from this list. - * - * @name Phaser.Structs.List#removeCallback - * @type {function} - * @since 3.4.0 - */ - this.removeCallback = NOOP; - - /** - * The property key to sort by. - * - * @name Phaser.Structs.List#_sortKey - * @type {string} - * @since 3.4.0 - */ - this._sortKey = ''; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#add - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*|Array.<*>} child - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. - * - * @return {*} [description] - */ - add: function (child, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.Add(this.list, child); - } - else - { - return ArrayUtils.Add(this.list, child, 0, this.addCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#addAt - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * @param {integer} [index=0] - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. - * - * @return {*} [description] - */ - addAt: function (child, index, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.AddAt(this.list, child, index); - } - else - { - return ArrayUtils.AddAt(this.list, child, index, 0, this.addCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getAt - * @since 3.0.0 - * - * @genericUse {T} - [$return] - * - * @param {integer} index - [description] - * - * @return {*} [description] - */ - getAt: function (index) - { - return this.list[index]; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getIndex - * @since 3.0.0 - * - * @genericUse {T} - [child] - * - * @param {*} child - [description] - * - * @return {integer} [description] - */ - getIndex: function (child) - { - // Return -1 if given child isn't a child of this display list - return this.list.indexOf(child); - }, - - /** - * Sort the contents of this List so the items are in order based - * on the given property. For example, `sort('alpha')` would sort the List - * contents based on the value of their `alpha` property. - * - * @method Phaser.Structs.List#sort - * @since 3.0.0 - * - * @genericUse {T[]} - [children,$return] - * - * @param {string} property - The property to lexically sort by. - * - * @return {Array.<*>} [description] - */ - sort: function (property) - { - if (property) - { - this._sortKey = property; - - StableSort.inplace(this.list, this.sortHandler); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#sortHandler - * @private - * @since 3.4.0 - * - * @genericUse {T} - [childA,childB] - * - * @param {*} childA - [description] - * @param {*} childB - [description] - * - * @return {integer} [description] - */ - sortHandler: function (childA, childB) - { - return childA[this._sortKey] - childB[this._sortKey]; - }, - - /** - * Searches for the first instance of a child with its `name` - * property matching the given argument. Should more than one child have - * the same name only the first is returned. - * - * @method Phaser.Structs.List#getByName - * @since 3.0.0 - * - * @genericUse {T | null} - [$return] - * - * @param {string} name - The name to search for. - * - * @return {?*} The first child with a matching name, or null if none were found. - */ - getByName: function (name) - { - return ArrayUtils.GetFirst(this.list, 'name', name); - }, - - /** - * Returns a random child from the group. - * - * @method Phaser.Structs.List#getRandom - * @since 3.0.0 - * - * @genericUse {T | null} - [$return] - * - * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child). - * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from. - * - * @return {?*} A random child of this Group. - */ - getRandom: function (startIndex, length) - { - return ArrayUtils.GetRandom(this.list, startIndex, length); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getFirst - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {T | null} - [$return] - * - * @param {string} property - [description] - * @param {*} value - [description] - * @param {number} [startIndex=0] - [description] - * @param {number} [endIndex] - [description] - * - * @return {?*} [description] - */ - getFirst: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); - }, - - /** - * Returns all children in this List. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('parent')` would return only children that have a property called `parent`. - * - * You can also specify a value to compare the property to: - * - * `getAll('visible', true)` would return only children that have their visible property set to `true`. - * - * Optionally you can specify a start and end index. For example if this List had 100 children, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 children in the List. - * - * @method Phaser.Structs.List#getAll - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {T[]} - [$return] - * - * @param {string} [property] - An optional property to test against the value argument. - * @param {*} [value] - If property is set then Child.property must strictly equal this value to be included in the results. - * @param {integer} [startIndex] - The first child index to start the search from. - * @param {integer} [endIndex] - The last child index to search up until. - * - * @return {Array.<*>} [description] - */ - getAll: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#count - * @since 3.0.0 - * - * @genericUse {T} - [value] - * - * @param {string} property - [description] - * @param {*} value - [description] - * - * @return {integer} [description] - */ - count: function (property, value) - { - return ArrayUtils.CountAllMatching(this.list, property, value); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#swap - * @since 3.0.0 - * - * @genericUse {T} - [child1,child2] - * - * @param {*} child1 - [description] - * @param {*} child2 - [description] - */ - swap: function (child1, child2) - { - ArrayUtils.Swap(this.list, child1, child2); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#moveTo - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * @param {integer} index - [description] - * - * @return {*} [description] - */ - moveTo: function (child, index) - { - return ArrayUtils.MoveTo(this.list, child, index); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#remove - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {*} [description] - */ - remove: function (child, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.Remove(this.list, child); - } - else - { - return ArrayUtils.Remove(this.list, child, this.removeCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#removeAt - * @since 3.0.0 - * - * @genericUse {T} - [$return] - * - * @param {integer} index - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {*} [description] - */ - removeAt: function (index, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.RemoveAt(this.list, index); - } - else - { - return ArrayUtils.RemoveAt(this.list, index, this.removeCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#removeBetween - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @param {integer} [startIndex=0] - [description] - * @param {integer} [endIndex] - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {Array.<*>} [description] - */ - removeBetween: function (startIndex, endIndex, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex); - } - else - { - return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeCallback, this); - } - }, - - /** - * Removes all the items. - * - * @method Phaser.Structs.List#removeAll - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.List.} - [$return] - * - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {Phaser.Structs.List} This List object. - */ - removeAll: function (skipCallback) - { - var i = this.list.length; - - while (i--) - { - this.remove(this.list[i], skipCallback); - } - - return this; - }, - - /** - * Brings the given child to the top of this List. - * - * @method Phaser.Structs.List#bringToTop - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - bringToTop: function (child) - { - return ArrayUtils.BringToTop(this.list, child); - }, - - /** - * Sends the given child to the bottom of this List. - * - * @method Phaser.Structs.List#sendToBack - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - sendToBack: function (child) - { - return ArrayUtils.SendToBack(this.list, child); - }, - - /** - * Moves the given child up one place in this group unless it's already at the top. - * - * @method Phaser.Structs.List#moveUp - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - moveUp: function (child) - { - ArrayUtils.MoveUp(this.list, child); - - return child; - }, - - /** - * Moves the given child down one place in this group unless it's already at the bottom. - * - * @method Phaser.Structs.List#moveDown - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - moveDown: function (child) - { - ArrayUtils.MoveDown(this.list, child); - - return child; - }, - - /** - * Reverses the order of all children in this List. - * - * @method Phaser.Structs.List#reverse - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.List.} - [$return] - * - * @return {Phaser.Structs.List} This List object. - */ - reverse: function () - { - this.list.reverse(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#shuffle - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.List.} - [$return] - * - * @return {Phaser.Structs.List} This List object. - */ - shuffle: function () - { - ArrayUtils.Shuffle(this.list); - - return this; - }, - - /** - * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. - * - * @method Phaser.Structs.List#replace - * @since 3.0.0 - * - * @genericUse {T} - [oldChild,newChild,$return] - * - * @param {*} oldChild - The child in this List that will be replaced. - * @param {*} newChild - The child to be inserted into this List. - * - * @return {*} Returns the oldChild that was replaced within this group. - */ - replace: function (oldChild, newChild) - { - return ArrayUtils.Replace(this.list, oldChild, newChild); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#exists - * @since 3.0.0 - * - * @genericUse {T} - [child] - * - * @param {*} child - [description] - * - * @return {boolean} True if the item is found in the list, otherwise false. - */ - exists: function (child) - { - return (this.list.indexOf(child) > -1); - }, - - /** - * Sets the property `key` to the given value on all members of this List. - * - * @method Phaser.Structs.List#setAll - * @since 3.0.0 - * - * @genericUse {T} - [value] - * - * @param {string} property - [description] - * @param {*} value - [description] - * @param {integer} [startIndex] - The first child index to start the search from. - * @param {integer} [endIndex] - The last child index to search up until. - */ - setAll: function (property, value, startIndex, endIndex) - { - ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); - - return this; - }, - - /** - * Passes all children to the given callback. - * - * @method Phaser.Structs.List#each - * @since 3.0.0 - * - * @genericUse {EachListCallback.} - [callback] - * - * @param {EachListCallback} callback - The function to call. - * @param {*} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ - each: function (callback, context) - { - var args = [ null ]; - - for (var i = 2; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = 0; i < this.list.length; i++) - { - args[0] = this.list[i]; - - callback.apply(context, args); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAll(); - - this.list = []; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAll(); - - this.parent = null; - this.addCallback = null; - this.removeCallback = null; - }, - - /** - * [description] - * - * @name Phaser.Structs.List#length - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - length: { - - get: function () - { - return this.list.length; - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#first - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - first: { - - get: function () - { - this.position = 0; - - if (this.list.length > 0) - { - return this.list[0]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#last - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - last: { - - get: function () - { - if (this.list.length > 0) - { - this.position = this.list.length - 1; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#next - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - next: { - - get: function () - { - if (this.position < this.list.length) - { - this.position++; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#previous - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - previous: { - - get: function () - { - if (this.position > 0) - { - this.position--; - - return this.list[this.position]; - } - else - { - return null; - } - } - - } - -}); - -module.exports = List; - - -/***/ }), -/* 94 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(33); - -/** - * Creates a new Object using all values from obj1 and obj2. - * If a value exists in both obj1 and obj2, the value in obj1 is used. - * - * @function Phaser.Utils.Object.Merge - * @since 3.0.0 - * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] - * - * @return {object} [description] - */ -var Merge = function (obj1, obj2) -{ - var clone = Clone(obj1); - - for (var key in obj2) - { - if (!clone.hasOwnProperty(key)) - { - clone[key] = obj2[key]; - } - } - - return clone; -}; - -module.exports = Merge; - - -/***/ }), -/* 95 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Shuffles the contents of the given array using the Fisher-Yates implementation. - * - * The original array is modified directly and returned. - * - * @function Phaser.Utils.Array.Shuffle - * @since 3.0.0 - * - * @param {array} array - The array to shuffle. This array is modified in place. - * - * @return {array} The shuffled array. - */ -var Shuffle = function (array) -{ - for (var i = array.length - 1; i > 0; i--) - { - var j = Math.floor(Math.random() * (i + 1)); - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - - return array; -}; - -module.exports = Shuffle; - - -/***/ }), -/* 96 */ +/* 76 */, +/* 77 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -16776,2164 +12945,7 @@ module.exports = Shuffle; */ var Class = __webpack_require__(0); -var GetPoint = __webpack_require__(293); -var GetPoints = __webpack_require__(156); -var Random = __webpack_require__(155); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * Defines a Line segment, a part of a line between two endpoints. - * - * @class Line - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x1=0] - The x coordinate of the lines starting point. - * @param {number} [y1=0] - The y coordinate of the lines starting point. - * @param {number} [x2=0] - The x coordinate of the lines ending point. - * @param {number} [y2=0] - The y coordinate of the lines ending point. - */ -var Line = new Class({ - - initialize: - - function Line (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - - /** - * The x coordinate of the lines starting point. - * - * @name Phaser.Geom.Line#x1 - * @type {number} - * @since 3.0.0 - */ - this.x1 = x1; - - /** - * The y coordinate of the lines starting point. - * - * @name Phaser.Geom.Line#y1 - * @type {number} - * @since 3.0.0 - */ - this.y1 = y1; - - /** - * The x coordinate of the lines ending point. - * - * @name Phaser.Geom.Line#x2 - * @type {number} - * @since 3.0.0 - */ - this.x2 = x2; - - /** - * The y coordinate of the lines ending point. - * - * @name Phaser.Geom.Line#y2 - * @type {number} - * @since 3.0.0 - */ - this.y2 = y2; - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] - * - * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point on the line. - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * Get a random Point on the Line. - * - * @method Phaser.Geom.Line#getRandomPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {(Phaser.Geom.Point|object)} [point] - An instance of a Point to be modified. - * - * @return {Phaser.Geom.Point} A random Point on the Line. - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * Set new coordinates for the line endpoints. - * - * @method Phaser.Geom.Line#setTo - * @since 3.0.0 - * - * @param {number} [x1=0] - The x coordinate of the lines starting point. - * @param {number} [y1=0] - The y coordinate of the lines starting point. - * @param {number} [x2=0] - The x coordinate of the lines ending point. - * @param {number} [y2=0] - The y coordinate of the lines ending point. - * - * @return {Phaser.Geom.Line} This Line object. - */ - setTo: function (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - - this.x1 = x1; - this.y1 = y1; - - this.x2 = x2; - this.y2 = y2; - - return this; - }, - - /** - * Returns a Vector2 object that corresponds to the start of this Line. - * - * @method Phaser.Geom.Line#getPointA - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [vec2,$return] - * - * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. - */ - getPointA: function (vec2) - { - if (vec2 === undefined) { vec2 = new Vector2(); } - - vec2.set(this.x1, this.y1); - - return vec2; - }, - - /** - * Returns a Vector2 object that corresponds to the start of this Line. - * - * @method Phaser.Geom.Line#getPointB - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [vec2,$return] - * - * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. - */ - getPointB: function (vec2) - { - if (vec2 === undefined) { vec2 = new Vector2(); } - - vec2.set(this.x2, this.y2); - - return vec2; - }, - - /** - * The left position of the Line. - * - * @name Phaser.Geom.Line#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return Math.min(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 <= this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The right position of the Line. - * - * @name Phaser.Geom.Line#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return Math.max(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 > this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The top position of the Line. - * - * @name Phaser.Geom.Line#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return Math.min(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 <= this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } - } - - }, - - /** - * The bottom position of the Line. - * - * @name Phaser.Geom.Line#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return Math.max(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 > this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } - } - - } - -}); - -module.exports = Line; - - -/***/ }), -/* 97 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Perimeter - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {number} [description] - */ -var Perimeter = function (rect) -{ - return 2 * (rect.width + rect.height); -}; - -module.exports = Perimeter; - - -/***/ }), -/* 98 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} TweenDataGenConfig - * - * @property {function} delay - [description] - * @property {function} duration - [description] - * @property {function} hold - [description] - * @property {function} repeat - [description] - * @property {function} repeatDelay - [description] - */ - -/** - * @typedef {object} Phaser.Tweens.TweenDataConfig - * - * @property {object} target - The target to tween. - * @property {string} key - The property of the target being tweened. - * @property {function} getEndValue - The returned value sets what the property will be at the END of the Tween. - * @property {function} getStartValue - The returned value sets what the property will be at the START of the Tween. - * @property {function} ease - The ease function this tween uses. - * @property {number} [duration=0] - Duration of the tween in ms/frames, excludes time for yoyo or repeats. - * @property {number} [totalDuration=0] - The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) - * @property {number} [delay=0] - Time in ms/frames before tween will start. - * @property {boolean} [yoyo=false] - Cause the tween to return back to its start value after hold has expired. - * @property {number} [hold=0] - Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - * @property {integer} [repeat=0] - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - * @property {number} [repeatDelay=0] - Time in ms/frames before the repeat will start. - * @property {boolean} [flipX=false] - Automatically call toggleFlipX when the TweenData yoyos or repeats - * @property {boolean} [flipY=false] - Automatically call toggleFlipY when the TweenData yoyos or repeats - * @property {float} [progress=0] - Between 0 and 1 showing completion of this TweenData. - * @property {float} [elapsed=0] - Delta counter - * @property {integer} [repeatCounter=0] - How many repeats are left to run? - * @property {number} [start=0] - Ease value data. - * @property {number} [current=0] - Ease value data. - * @property {number} [end=0] - Ease value data. - * @property {number} [t1=0] - Time duration 1. - * @property {number} [t2=0] - Time duration 2. - * @property {TweenDataGenConfig} [gen] - LoadValue generation functions. - * @property {integer} [state=0] - TWEEN_CONST.CREATED - */ - -/** - * [description] - * - * @function Phaser.Tweens.TweenData - * @since 3.0.0 - * - * @param {object} target - [description] - * @param {string} key - [description] - * @param {function} getEnd - [description] - * @param {function} getStart - [description] - * @param {function} ease - [description] - * @param {number} delay - [description] - * @param {number} duration - [description] - * @param {boolean} yoyo - [description] - * @param {number} hold - [description] - * @param {number} repeat - [description] - * @param {number} repeatDelay - [description] - * @param {boolean} flipX - [description] - * @param {boolean} flipY - [description] - * - * @return {TweenDataConfig} [description] - */ -var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) -{ - return { - - // The target to tween - target: target, - - // The property of the target to tween - key: key, - - // The returned value sets what the property will be at the END of the Tween. - getEndValue: getEnd, - - // The returned value sets what the property will be at the START of the Tween. - getStartValue: getStart, - - // The ease function this tween uses. - ease: ease, - - // Duration of the tween in ms/frames, excludes time for yoyo or repeats. - duration: 0, - - // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) - totalDuration: 0, - - // Time in ms/frames before tween will start. - delay: 0, - - // Cause the tween to return back to its start value after hold has expired. - yoyo: yoyo, - - // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - hold: 0, - - // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - repeat: 0, - - // Time in ms/frames before the repeat will start. - repeatDelay: 0, - - // Automatically call toggleFlipX when the TweenData yoyos or repeats - flipX: flipX, - - // Automatically call toggleFlipY when the TweenData yoyos or repeats - flipY: flipY, - - // Between 0 and 1 showing completion of this TweenData. - progress: 0, - - // Delta counter. - elapsed: 0, - - // How many repeats are left to run? - repeatCounter: 0, - - // Ease Value Data: - - start: 0, - current: 0, - end: 0, - - // Time Durations - t1: 0, - t2: 0, - - // LoadValue generation functions - gen: { - delay: delay, - duration: duration, - hold: hold, - repeat: repeat, - repeatDelay: repeatDelay - }, - - // TWEEN_CONST.CREATED - state: 0 - }; -}; - -module.exports = TweenData; - - -/***/ }), -/* 99 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GameObjectCreator = __webpack_require__(13); -var GameObjectFactory = __webpack_require__(11); -var TWEEN_CONST = __webpack_require__(61); - -/** - * @classdesc - * [description] - * - * @class Tween - * @memberOf Phaser.Tweens - * @constructor - * @since 3.0.0 - * - * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] - * @param {Phaser.Tweens.TweenDataConfig[]} data - [description] - * @param {array} targets - [description] - */ -var Tween = new Class({ - - initialize: - - function Tween (parent, data, targets) - { - /** - * [description] - * - * @name Phaser.Tweens.Tween#parent - * @type {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * Is the parent of this Tween a Timeline? - * - * @name Phaser.Tweens.Tween#parentIsTimeline - * @type {boolean} - * @since 3.0.0 - */ - this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); - - /** - * An array of TweenData objects, each containing a unique property and target being tweened. - * - * @name Phaser.Tweens.Tween#data - * @type {Phaser.Tweens.TweenDataConfig[]} - * @since 3.0.0 - */ - this.data = data; - - /** - * data array doesn't change, so we can cache the length - * - * @name Phaser.Tweens.Tween#totalData - * @type {integer} - * @since 3.0.0 - */ - this.totalData = data.length; - - /** - * An array of references to the target/s this Tween is operating on - * - * @name Phaser.Tweens.Tween#targets - * @type {object[]} - * @since 3.0.0 - */ - this.targets = targets; - - /** - * Cached target total (not necessarily the same as the data total) - * - * @name Phaser.Tweens.Tween#totalTargets - * @type {integer} - * @since 3.0.0 - */ - this.totalTargets = targets.length; - - /** - * If true then duration, delay, etc values are all frame totals. - * - * @name Phaser.Tweens.Tween#useFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useFrames = false; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * - * @name Phaser.Tweens.Tween#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) - * - * @name Phaser.Tweens.Tween#loop - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loop = 0; - - /** - * Time in ms/frames before the tween loops. - * - * @name Phaser.Tweens.Tween#loopDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopDelay = 0; - - /** - * How many loops are left to run? - * - * @name Phaser.Tweens.Tween#loopCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopCounter = 0; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) - * - * @name Phaser.Tweens.Tween#completeDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.completeDelay = 0; - - /** - * Countdown timer (used by timeline offset, loopDelay and completeDelay) - * - * @name Phaser.Tweens.Tween#countdown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.countdown = 0; - - /** - * Set only if this Tween is part of a Timeline. - * - * @name Phaser.Tweens.Tween#offset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.offset = 0; - - /** - * Set only if this Tween is part of a Timeline. The calculated offset amount. - * - * @name Phaser.Tweens.Tween#calculatedOffset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.calculatedOffset = 0; - - /** - * The current state of the tween - * - * @name Phaser.Tweens.Tween#state - * @type {integer} - * @since 3.0.0 - */ - this.state = TWEEN_CONST.PENDING_ADD; - - /** - * The state of the tween when it was paused (used by Resume) - * - * @name Phaser.Tweens.Tween#_pausedState - * @type {integer} - * @private - * @since 3.0.0 - */ - this._pausedState = TWEEN_CONST.PENDING_ADD; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - * - * @name Phaser.Tweens.Tween#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * Elapsed time in ms/frames of this run through the Tween. - * - * @name Phaser.Tweens.Tween#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalElapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalElapsed = 0; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - * - * @name Phaser.Tweens.Tween#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - * - * @name Phaser.Tweens.Tween#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * Time in ms/frames for the Tween to complete (including looping) - * - * @name Phaser.Tweens.Tween#totalDuration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalDuration = 0; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalProgress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalProgress = 0; - - /** - * An object containing the various Tween callback references. - * - * @name Phaser.Tweens.Tween#callbacks - * @type {object} - * @default 0 - * @since 3.0.0 - */ - this.callbacks = { - onComplete: null, - onLoop: null, - onRepeat: null, - onStart: null, - onUpdate: null, - onYoyo: null - }; - - this.callbackScope; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#getValue - * @since 3.0.0 - * - * @return {number} [description] - */ - getValue: function () - { - return this.data[0].current; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setTimeScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - setTimeScale: function (value) - { - this.timeScale = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#getTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#isPlaying - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPlaying: function () - { - return (this.state === TWEEN_CONST.ACTIVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#isPaused - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPaused: function () - { - return (this.state === TWEEN_CONST.PAUSED); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#hasTarget - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - hasTarget: function (target) - { - return (this.targets.indexOf(target) !== -1); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTo - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {*} value - [description] - * @param {boolean} startToCurrent - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - updateTo: function (key, value, startToCurrent) - { - for (var i = 0; i < this.totalData; i++) - { - var tweenData = this.data[i]; - - if (tweenData.key === key) - { - tweenData.end = value; - - if (startToCurrent) - { - tweenData.start = tweenData.current; - } - - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#restart - * @since 3.0.0 - */ - restart: function () - { - if (this.state === TWEEN_CONST.REMOVED) - { - this.seek(0); - this.parent.makeActive(this); - } - else - { - this.stop(); - this.play(); - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#calcDuration - * @since 3.0.0 - */ - calcDuration: function () - { - var max = 0; - - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - // Set t1 (duration + hold + yoyo) - tweenData.t1 = tweenData.duration + tweenData.hold; - - if (tweenData.yoyo) - { - tweenData.t1 += tweenData.duration; - } - - // Set t2 (repeatDelay + duration + hold + yoyo) - tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; - - // Total Duration - tweenData.totalDuration = tweenData.delay + tweenData.t1; - - if (tweenData.repeat === -1) - { - tweenData.totalDuration += (tweenData.t2 * 999999999999); - } - else if (tweenData.repeat > 0) - { - tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); - } - - if (tweenData.totalDuration > max) - { - // Get the longest TweenData from the Tween, used to calculate the Tween TD - max = tweenData.totalDuration; - } - } - - // Excludes loop values - this.duration = max; - - this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; - - if (this.loopCounter > 0) - { - this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); - } - else - { - this.totalDuration = this.duration + this.completeDelay; - } - }, - - /** - * Called by TweenManager.preUpdate as part of its loop to check pending and active tweens. - * Should not be called directly. - * - * @method Phaser.Tweens.Tween#init - * @since 3.0.0 - * - * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. - */ - init: function () - { - var data = this.data; - var totalTargets = this.totalTargets; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - var target = tweenData.target; - var gen = tweenData.gen; - - tweenData.delay = gen.delay(i, totalTargets, target); - tweenData.duration = gen.duration(i, totalTargets, target); - tweenData.hold = gen.hold(i, totalTargets, target); - tweenData.repeat = gen.repeat(i, totalTargets, target); - tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); - } - - this.calcDuration(); - - this.progress = 0; - this.totalProgress = 0; - this.elapsed = 0; - this.totalElapsed = 0; - - // You can't have a paused Tween if it's part of a Timeline - if (this.paused && !this.parentIsTimeline) - { - this.state = TWEEN_CONST.PENDING_ADD; - this._pausedState = TWEEN_CONST.INIT; - - return false; - } - else - { - this.state = TWEEN_CONST.INIT; - - return true; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#nextState - * @since 3.0.0 - */ - nextState: function () - { - if (this.loopCounter > 0) - { - this.elapsed = 0; - this.progress = 0; - this.loopCounter--; - - var onLoop = this.callbacks.onLoop; - - if (onLoop) - { - onLoop.params[1] = this.targets; - - onLoop.func.apply(onLoop.scope, onLoop.params); - } - - this.resetTweenData(true); - - if (this.loopDelay > 0) - { - this.countdown = this.loopDelay; - this.state = TWEEN_CONST.LOOP_DELAY; - } - else - { - this.state = TWEEN_CONST.ACTIVE; - } - } - else if (this.completeDelay > 0) - { - this.countdown = this.completeDelay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#pause - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - pause: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - this.paused = true; - - this._pausedState = this.state; - - this.state = TWEEN_CONST.PAUSED; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#play - * @since 3.0.0 - * - * @param {boolean} resetFromTimeline - [description] - */ - play: function (resetFromTimeline) - { - if (this.state === TWEEN_CONST.ACTIVE) - { - return; - } - else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) - { - this.init(); - this.parent.makeActive(this); - resetFromTimeline = true; - } - - var onStart = this.callbacks.onStart; - - if (this.parentIsTimeline) - { - this.resetTweenData(resetFromTimeline); - - if (this.calculatedOffset === 0) - { - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - else - { - this.countdown = this.calculatedOffset; - - this.state = TWEEN_CONST.OFFSET_DELAY; - } - } - else if (this.paused) - { - this.paused = false; - - this.parent.makeActive(this); - } - else - { - this.resetTweenData(resetFromTimeline); - - this.state = TWEEN_CONST.ACTIVE; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resetTweenData - * @since 3.0.0 - * - * @param {boolean} resetFromLoop - [description] - */ - resetTweenData: function (resetFromLoop) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - tweenData.progress = 0; - tweenData.elapsed = 0; - - tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; - - if (resetFromLoop) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); - - tweenData.current = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else if (tweenData.delay > 0) - { - tweenData.elapsed = tweenData.delay; - tweenData.state = TWEEN_CONST.DELAY; - } - else - { - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resume - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - resume: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - this.paused = false; - - this.state = this._pausedState; - } - else - { - this.play(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#seek - * @since 3.0.0 - * - * @param {float} toPosition - A value between 0 and 1. - */ - seek: function (toPosition) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - // This won't work with loop > 0 yet - var ms = this.totalDuration * toPosition; - - var tweenData = data[i]; - var progress = 0; - var elapsed = 0; - - if (ms <= tweenData.delay) - { - progress = 0; - elapsed = 0; - } - else if (ms >= tweenData.totalDuration) - { - progress = 1; - elapsed = tweenData.duration; - } - else if (ms > tweenData.delay && ms <= tweenData.t1) - { - // Keep it zero bound - ms = Math.max(0, ms - tweenData.delay); - - // Somewhere in the first playthru range - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - else if (ms > tweenData.t1 && ms < tweenData.totalDuration) - { - // Somewhere in repeat land - ms -= tweenData.delay; - ms -= tweenData.t1; - - // var repeats = Math.floor(ms / tweenData.t2); - - // remainder - ms = ((ms / tweenData.t2) % 1) * tweenData.t2; - - if (ms > tweenData.repeatDelay) - { - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - } - - tweenData.progress = progress; - tweenData.elapsed = elapsed; - - var v = tweenData.ease(tweenData.progress); - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); - - // if (tweenData.current === 0) - // { - // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); - // } - - tweenData.target[tweenData.key] = tweenData.current; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setCallback - * @since 3.0.0 - * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] - * @param {object} [scope] - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - setCallback: function (type, callback, params, scope) - { - this.callbacks[type] = { func: callback, scope: scope, params: params }; - - return this; - }, - - /** - * Flags the Tween as being complete, whatever stage of progress it is at. - * - * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` - * argument is provided, in which case the Tween will delay for that period of time before calling the callback. - * - * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. - * - * @method Phaser.Tweens.Tween#complete - * @since 3.2.0 - * - * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. - */ - complete: function (delay) - { - if (delay === undefined) { delay = 0; } - - if (delay) - { - this.countdown = delay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - * - * @method Phaser.Tweens.Tween#stop - * @since 3.0.0 - * - * @param {float} [resetTo] - A value between 0 and 1. - */ - stop: function (resetTo) - { - if (this.state === TWEEN_CONST.ACTIVE) - { - if (resetTo !== undefined) - { - this.seek(resetTo); - } - } - - if (this.state !== TWEEN_CONST.REMOVED) - { - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - * - * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. - */ - update: function (timestamp, delta) - { - if (this.state === TWEEN_CONST.PAUSED) - { - return false; - } - - if (this.useFrames) - { - delta = 1 * this.parent.timeScale; - } - - delta *= this.timeScale; - - this.elapsed += delta; - this.progress = Math.min(this.elapsed / this.duration, 1); - - this.totalElapsed += delta; - this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); - - switch (this.state) - { - case TWEEN_CONST.ACTIVE: - - var stillRunning = false; - - for (var i = 0; i < this.totalData; i++) - { - if (this.updateTweenData(this, this.data[i], delta)) - { - stillRunning = true; - } - } - - // Anything still running? If not, we're done - if (!stillRunning) - { - this.nextState(); - } - - break; - - case TWEEN_CONST.LOOP_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.OFFSET_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onStart = this.callbacks.onStart; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.COMPLETE_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - - break; - } - - return (this.state === TWEEN_CONST.PENDING_REMOVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setStateFromEnd - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromEnd: function (tween, tweenData, diff) - { - if (tweenData.yoyo) - { - // We've hit the end of a Playing Forward TweenData and we have a yoyo - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. - // If you're tweening several properties it can fire for all of them, at once. - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onYoyo = tween.callbacks.onYoyo; - - if (onYoyo) - { - // Element 1 is reserved for the target of the yoyo (and needs setting here) - onYoyo.params[1] = tweenData.target; - - onYoyo.func.apply(onYoyo.scope, onYoyo.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - return TWEEN_CONST.PLAYING_BACKWARD; - } - else if (tweenData.repeatCounter > 0) - { - // We've hit the end of a Playing Forward TweenData and we have a Repeat. - // So we're going to go right back to the start to repeat it again. - - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - /** - * Was PLAYING_BACKWARD and has hit the start. - * - * @method Phaser.Tweens.Tween#setStateFromStart - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromStart: function (tween, tweenData, diff) - { - if (tweenData.repeatCounter > 0) - { - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - // - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTweenData - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] - * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true - * - * @return {boolean} [description] - */ - updateTweenData: function (tween, tweenData, delta) - { - switch (tweenData.state) - { - case TWEEN_CONST.PLAYING_FORWARD: - case TWEEN_CONST.PLAYING_BACKWARD: - - if (!tweenData.target) - { - tweenData.state = TWEEN_CONST.COMPLETE; - break; - } - - var elapsed = tweenData.elapsed; - var duration = tweenData.duration; - var diff = 0; - - elapsed += delta; - - if (elapsed > duration) - { - diff = elapsed - duration; - elapsed = duration; - } - - var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); - var progress = elapsed / duration; - - var v; - - if (forward) - { - v = tweenData.ease(progress); - } - else - { - v = tweenData.ease(1 - progress); - } - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - tweenData.target[tweenData.key] = tweenData.current; - - tweenData.elapsed = elapsed; - tweenData.progress = progress; - - var onUpdate = tween.callbacks.onUpdate; - - if (onUpdate) - { - onUpdate.params[1] = tweenData.target; - - onUpdate.func.apply(onUpdate.scope, onUpdate.params); - } - - if (progress === 1) - { - if (forward) - { - if (tweenData.hold > 0) - { - tweenData.elapsed = tweenData.hold - diff; - - tweenData.state = TWEEN_CONST.HOLD_DELAY; - } - else - { - tweenData.state = this.setStateFromEnd(tween, tweenData, diff); - } - } - else - { - tweenData.state = this.setStateFromStart(tween, tweenData, diff); - } - } - - break; - - case TWEEN_CONST.DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - - break; - - case TWEEN_CONST.REPEAT_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - - break; - - case TWEEN_CONST.HOLD_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); - } - - break; - - case TWEEN_CONST.PENDING_RENDER: - - if (tweenData.target) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else - { - tweenData.state = TWEEN_CONST.COMPLETE; - } - - break; - } - - // Return TRUE if this TweenData still playing, otherwise return FALSE - return (tweenData.state !== TWEEN_CONST.COMPLETE); - } - -}); - -Tween.TYPES = [ - 'onComplete', - 'onLoop', - 'onRepeat', - 'onStart', - 'onUpdate', - 'onYoyo' -]; - -/** - * Creates a new Tween object. - * - * Note: This method will only be available Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectFactory.register('tween', function (config) -{ - return this.scene.sys.tweens.add(config); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - -/** - * Creates a new Tween object and returns it. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectCreator.register('tween', function (config) -{ - return this.scene.sys.tweens.create(config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - -module.exports = Tween; - - -/***/ }), -/* 100 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} Phaser.Tweens.TweenConfigDefaults - * - * @property {(object|object[])} targets - [description] - * @property {number} [delay=0] - [description] - * @property {number} [duration=1000] - [description] - * @property {string} [ease='Power0'] - [description] - * @property {array} [easeParams] - [description] - * @property {number} [hold=0] - [description] - * @property {number} [repeat=0] - [description] - * @property {number} [repeatDelay=0] - [description] - * @property {boolean} [yoyo=false] - [description] - * @property {boolean} [flipX=false] - [description] - * @property {boolean} [flipY=false] - [description] - */ - -var TWEEN_DEFAULTS = { - targets: null, - delay: 0, - duration: 1000, - ease: 'Power0', - easeParams: null, - hold: 0, - repeat: 0, - repeatDelay: 0, - yoyo: false, - flipX: false, - flipY: false -}; - -module.exports = TWEEN_DEFAULTS; - - -/***/ }), -/* 101 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function hasGetStart (def) -{ - return (!!def.getStart && typeof def.getStart === 'function'); -} - -function hasGetEnd (def) -{ - return (!!def.getEnd && typeof def.getEnd === 'function'); -} - -function hasGetters (def) -{ - return hasGetStart(def) || hasGetEnd(def); -} - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetValueOp - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {*} propertyValue - [description] - * - * @return {function} [description] - */ -var GetValueOp = function (key, propertyValue) -{ - var callbacks; - - // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) - var getEnd = function (target, key, value) { return value; }; - - // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) - var getStart = function (target, key, value) { return value; }; - - var t = typeof(propertyValue); - - if (t === 'number') - { - // props: { - // x: 400, - // y: 300 - // } - - getEnd = function () - { - return propertyValue; - }; - } - else if (t === 'string') - { - // props: { - // x: '+=400', - // y: '-=300', - // z: '*=2', - // w: '/=2' - // } - - var op = propertyValue[0]; - var num = parseFloat(propertyValue.substr(2)); - - switch (op) - { - case '+': - getEnd = function (target, key, value) - { - return value + num; - }; - break; - - case '-': - getEnd = function (target, key, value) - { - return value - num; - }; - break; - - case '*': - getEnd = function (target, key, value) - { - return value * num; - }; - break; - - case '/': - getEnd = function (target, key, value) - { - return value / num; - }; - break; - - default: - getEnd = function () - { - return parseFloat(propertyValue); - }; - } - } - else if (t === 'function') - { - // The same as setting just the getEnd function and no getStart - - // props: { - // x: function (target, key, value) { return value + 50); }, - // } - - getEnd = propertyValue; - } - else if (t === 'object' && hasGetters(propertyValue)) - { - /* - x: { - // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. - getEnd: function (target, key, value) - { - return value; - }, - - // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. - getStart: function (target, key, value) - { - return value; - } - } - */ - - if (hasGetEnd(propertyValue)) - { - getEnd = propertyValue.getEnd; - } - - if (hasGetStart(propertyValue)) - { - getStart = propertyValue.getStart; - } - } - else if (propertyValue.hasOwnProperty('value')) - { - // Value may still be a string, function or a number - // props: { - // x: { value: 400, ... }, - // y: { value: 300, ... } - // } - - callbacks = GetValueOp(key, propertyValue.value); - } - - // If callback not set by the else if block above then set it here and return it - if (!callbacks) - { - callbacks = { - getEnd: getEnd, - getStart: getStart - }; - } - - return callbacks; -}; - -module.exports = GetValueOp; - - -/***/ }), -/* 102 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetTargets - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {array} [description] - */ -var GetTargets = function (config) -{ - var targets = GetValue(config, 'targets', null); - - if (targets === null) - { - return targets; - } - - if (typeof targets === 'function') - { - targets = targets.call(); - } - - if (!Array.isArray(targets)) - { - targets = [ targets ]; - } - - return targets; -}; - -module.exports = GetTargets; - - -/***/ }), -/* 103 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * @classdesc @@ -18942,7 +12954,7 @@ var GetFastValue = __webpack_require__(1); * itself. * * @class MapData - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -19037,6 +13049,15 @@ var MapData = new Class({ */ this.orientation = GetFastValue(config, 'orientation', 'orthogonal'); + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#renderOrder + * @type {string} + * @since 3.12.0 + */ + this.renderOrder = GetFastValue(config, 'renderOrder', 'right-down'); + /** * [description] * @@ -19125,7 +13146,7 @@ module.exports = MapData; /***/ }), -/* 104 */ +/* 78 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -19135,7 +13156,7 @@ module.exports = MapData; */ var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * @classdesc @@ -19144,7 +13165,7 @@ var GetFastValue = __webpack_require__(1); * to this data and use it to look up and perform operations on tiles. * * @class LayerData - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -19261,7 +13282,7 @@ var LayerData = new Class({ * [description] * * @name Phaser.Tilemaps.LayerData#alpha - * @type {float} + * @type {number} * @since 3.0.0 */ this.alpha = GetFastValue(config, 'alpha', 1); @@ -19345,7 +13366,7 @@ module.exports = LayerData; /***/ }), -/* 105 */ +/* 79 */ /***/ (function(module, exports) { /** @@ -19361,11 +13382,11 @@ module.exports = LayerData; * @private * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * - * @return {boolean} + * @return {boolean} `true` if the tile coordinates are within the bounds of the layer, otherwise `false`. */ var IsInLayerBounds = function (tileX, tileY, layer) { @@ -19376,8 +13397,9 @@ module.exports = IsInLayerBounds; /***/ }), -/* 106 */, -/* 107 */ +/* 80 */, +/* 81 */, +/* 82 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -19386,46 +13408,234 @@ module.exports = IsInLayerBounds; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Extend = __webpack_require__(17); -var XHRSettings = __webpack_require__(75); +var Utils = __webpack_require__(10); /** - * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * Renders a filled path for the given Shape. * - * The new object is seeded by the values given in the global settings, but any setting in - * the local object overrides the global ones. + * @method Phaser.GameObjects.Shape#FillPathWebGL + * @since 3.13.0 + * @private * - * @function Phaser.Loader.MergeXHRSettings - * @since 3.0.0 - * - * @param {XHRSettingsObject} global - The global XHRSettings object. - * @param {XHRSettingsObject} local - The local XHRSettings object. - * - * @return {XHRSettingsObject} A newly formed XHRSettings object. + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The WebGL Pipeline used to render this Shape. + * @param {Phaser.GameObjects.Components.TransformMatrix} calcMatrix - The transform matrix used to get the position values. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. */ -var MergeXHRSettings = function (global, local) +var FillPathWebGL = function (pipeline, calcMatrix, src, alpha, dx, dy) { - var output = (global === undefined) ? XHRSettings() : Extend({}, global); + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); - if (local) + var path = src.pathData; + var pathIndexes = src.pathIndexes; + + for (var i = 0; i < pathIndexes.length; i += 3) { - for (var setting in local) - { - if (local[setting] !== undefined) - { - output[setting] = local[setting]; - } - } - } + var p0 = pathIndexes[i] * 2; + var p1 = pathIndexes[i + 1] * 2; + var p2 = pathIndexes[i + 2] * 2; - return output; + var x0 = path[p0 + 0] - dx; + var y0 = path[p0 + 1] - dy; + var x1 = path[p1 + 0] - dx; + var y1 = path[p1 + 1] - dy; + var x2 = path[p2 + 0] - dx; + var y2 = path[p2 + 1] - dy; + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + pipeline.setTexture2D(); + + pipeline.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, 0, 0, 1, 1, fillTintColor, fillTintColor, fillTintColor, pipeline.tintEffect); + } }; -module.exports = MergeXHRSettings; +module.exports = FillPathWebGL; /***/ }), -/* 108 */ +/* 83 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TWEEN_CONST = { + + /** + * TweenData state. + * + * @name Phaser.Tweens.CREATED + * @type {integer} + * @since 3.0.0 + */ + CREATED: 0, + + /** + * TweenData state. + * + * @name Phaser.Tweens.INIT + * @type {integer} + * @since 3.0.0 + */ + INIT: 1, + + /** + * TweenData state. + * + * @name Phaser.Tweens.DELAY + * @type {integer} + * @since 3.0.0 + */ + DELAY: 2, + + /** + * TweenData state. + * + * @name Phaser.Tweens.OFFSET_DELAY + * @type {integer} + * @since 3.0.0 + */ + OFFSET_DELAY: 3, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PENDING_RENDER + * @type {integer} + * @since 3.0.0 + */ + PENDING_RENDER: 4, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PLAYING_FORWARD + * @type {integer} + * @since 3.0.0 + */ + PLAYING_FORWARD: 5, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PLAYING_BACKWARD + * @type {integer} + * @since 3.0.0 + */ + PLAYING_BACKWARD: 6, + + /** + * TweenData state. + * + * @name Phaser.Tweens.HOLD_DELAY + * @type {integer} + * @since 3.0.0 + */ + HOLD_DELAY: 7, + + /** + * TweenData state. + * + * @name Phaser.Tweens.REPEAT_DELAY + * @type {integer} + * @since 3.0.0 + */ + REPEAT_DELAY: 8, + + /** + * TweenData state. + * + * @name Phaser.Tweens.COMPLETE + * @type {integer} + * @since 3.0.0 + */ + COMPLETE: 9, + + // Tween specific (starts from 20 to cleanly allow extra TweenData consts in the future) + + /** + * Tween state. + * + * @name Phaser.Tweens.PENDING_ADD + * @type {integer} + * @since 3.0.0 + */ + PENDING_ADD: 20, + + /** + * Tween state. + * + * @name Phaser.Tweens.PAUSED + * @type {integer} + * @since 3.0.0 + */ + PAUSED: 21, + + /** + * Tween state. + * + * @name Phaser.Tweens.LOOP_DELAY + * @type {integer} + * @since 3.0.0 + */ + LOOP_DELAY: 22, + + /** + * Tween state. + * + * @name Phaser.Tweens.ACTIVE + * @type {integer} + * @since 3.0.0 + */ + ACTIVE: 23, + + /** + * Tween state. + * + * @name Phaser.Tweens.COMPLETE_DELAY + * @type {integer} + * @since 3.0.0 + */ + COMPLETE_DELAY: 24, + + /** + * Tween state. + * + * @name Phaser.Tweens.PENDING_REMOVE + * @type {integer} + * @since 3.0.0 + */ + PENDING_REMOVE: 25, + + /** + * Tween state. + * + * @name Phaser.Tweens.REMOVED + * @type {integer} + * @since 3.0.0 + */ + REMOVED: 26 + +}; + +module.exports = TWEEN_CONST; + + +/***/ }), +/* 84 */ /***/ (function(module, exports) { /** @@ -19435,1637 +13645,38 @@ module.exports = MergeXHRSettings; */ /** - * Given a File and a baseURL value this returns the URL the File will use to download from. + * Retrieves the value of the given key from an object. * - * @function Phaser.Loader.GetURL + * @function Phaser.Tweens.Builders.GetBoolean * @since 3.0.0 * - * @param {Phaser.Loader.File} file - The File object. - * @param {string} baseURL - A default base URL. + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The key to look for in the `source` object. + * @param {*} defaultValue - The default value to return if the `key` doesn't exist or if no `source` object is provided. * - * @return {string} The URL the File will use. + * @return {*} The retrieved value. */ -var GetURL = function (file, baseURL) +var GetBoolean = function (source, key, defaultValue) { - if (!file.url) + if (!source) { - return false; + return defaultValue; } - - if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) + else if (source.hasOwnProperty(key)) { - return file.url; + return source[key]; } else { - return baseURL + file.url; + return defaultValue; } }; -module.exports = GetURL; +module.exports = GetBoolean; /***/ }), -/* 109 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Keyboard Codes. - * - * @name Phaser.Input.Keyboard.KeyCodes - * @enum {integer} - * @memberOf Phaser.Input.Keyboard - * @readOnly - * @since 3.0.0 - */ - -var KeyCodes = { - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACKSPACE - */ - BACKSPACE: 8, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.TAB - */ - TAB: 9, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ENTER - */ - ENTER: 13, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SHIFT - */ - SHIFT: 16, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CTRL - */ - CTRL: 17, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ALT - */ - ALT: 18, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAUSE - */ - PAUSE: 19, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CAPS_LOCK - */ - CAPS_LOCK: 20, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ESC - */ - ESC: 27, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SPACE - */ - SPACE: 32, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAGE_UP - */ - PAGE_UP: 33, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAGE_DOWN - */ - PAGE_DOWN: 34, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.END - */ - END: 35, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.HOME - */ - HOME: 36, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.LEFT - */ - LEFT: 37, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.UP - */ - UP: 38, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.RIGHT - */ - RIGHT: 39, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.DOWN - */ - DOWN: 40, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PRINT_SCREEN - */ - PRINT_SCREEN: 42, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.INSERT - */ - INSERT: 45, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.DELETE - */ - DELETE: 46, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ZERO - */ - ZERO: 48, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ONE - */ - ONE: 49, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.TWO - */ - TWO: 50, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.THREE - */ - THREE: 51, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FOUR - */ - FOUR: 52, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FIVE - */ - FIVE: 53, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SIX - */ - SIX: 54, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SEVEN - */ - SEVEN: 55, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.EIGHT - */ - EIGHT: 56, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NINE - */ - NINE: 57, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ZERO - */ - NUMPAD_ZERO: 96, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ONE - */ - NUMPAD_ONE: 97, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_TWO - */ - NUMPAD_TWO: 98, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_THREE - */ - NUMPAD_THREE: 99, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FOUR - */ - NUMPAD_FOUR: 100, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FIVE - */ - NUMPAD_FIVE: 101, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SIX - */ - NUMPAD_SIX: 102, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SEVEN - */ - NUMPAD_SEVEN: 103, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_EIGHT - */ - NUMPAD_EIGHT: 104, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_NINE - */ - NUMPAD_NINE: 105, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.A - */ - A: 65, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.B - */ - B: 66, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.C - */ - C: 67, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.D - */ - D: 68, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.E - */ - E: 69, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F - */ - F: 70, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.G - */ - G: 71, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.H - */ - H: 72, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.I - */ - I: 73, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.J - */ - J: 74, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.K - */ - K: 75, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.L - */ - L: 76, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.M - */ - M: 77, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.N - */ - N: 78, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.O - */ - O: 79, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.P - */ - P: 80, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Q - */ - Q: 81, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.R - */ - R: 82, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.S - */ - S: 83, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.T - */ - T: 84, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.U - */ - U: 85, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.V - */ - V: 86, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.W - */ - W: 87, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.X - */ - X: 88, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Y - */ - Y: 89, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Z - */ - Z: 90, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F1 - */ - F1: 112, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F2 - */ - F2: 113, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F3 - */ - F3: 114, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F4 - */ - F4: 115, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F5 - */ - F5: 116, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F6 - */ - F6: 117, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F7 - */ - F7: 118, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F8 - */ - F8: 119, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F9 - */ - F9: 120, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F10 - */ - F10: 121, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F11 - */ - F11: 122, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F12 - */ - F12: 123, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON - */ - SEMICOLON: 186, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PLUS - */ - PLUS: 187, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.COMMA - */ - COMMA: 188, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.MINUS - */ - MINUS: 189, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PERIOD - */ - PERIOD: 190, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FORWARD_SLASH - */ - FORWARD_SLASH: 191, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACK_SLASH - */ - BACK_SLASH: 220, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.QUOTES - */ - QUOTES: 222, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACKTICK - */ - BACKTICK: 192, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.OPEN_BRACKET - */ - OPEN_BRACKET: 219, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET - */ - CLOSED_BRACKET: 221 - -}; - -module.exports = KeyCodes; - - -/***/ }), -/* 110 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AddToDOM = __webpack_require__(130); -var CanvasPool = __webpack_require__(22); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var CONST = __webpack_require__(20); -var GameObject = __webpack_require__(2); -var GetTextSize = __webpack_require__(417); -var GetValue = __webpack_require__(4); -var RemoveFromDOM = __webpack_require__(269); -var TextRender = __webpack_require__(416); -var TextStyle = __webpack_require__(413); - -/** - * @classdesc - * [description] - * - * @class Text - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {(string|string[])} text - The text this Text object will display. - * @param {object} style - The text style configuration object. - */ -var Text = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Tint, - Components.Transform, - Components.Visible, - TextRender - ], - - initialize: - - function Text (scene, x, y, text, style) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - GameObject.call(this, scene, 'Text'); - - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * The canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = CanvasPool.create(this); - - /** - * The context of the canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context = this.canvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#style - * @type {Phaser.GameObjects.Text.TextStyle} - * @since 3.0.0 - */ - this.style = new TextStyle(this, style); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#autoRound - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.autoRound = true; - - /** - * The Regular Expression that is used to split the text up into lines, in - * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. - * You can change this RegExp to be anything else that you may need. - * - * @name Phaser.GameObjects.Text#splitRegExp - * @type {object} - * @since 3.0.0 - */ - this.splitRegExp = /(?:\r\n|\r|\n)/; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#resolution - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.resolution = 1; - - /** - * Specify a padding value which is added to the line width and height when calculating the Text size. - * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. - * - * @name Phaser.GameObjects.Text#padding - * @type {{left:number,right:number,top:number,bottom:number}} - * @since 3.0.0 - */ - this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#width - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.width = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#height - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.height = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#canvasTexture - * @type {HTMLCanvasElement} - * @default null - * @since 3.0.0 - */ - this.canvasTexture = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#dirty - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.dirty = false; - - this.initRTL(); - - if (style && style.padding) - { - this.setPadding(style.padding); - } - - if (style && style.lineSpacing) - { - this._lineSpacing = style.lineSpacing; - } - - this.setText(text); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function () - { - this.canvasTexture = null; - this.dirty = true; - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#initRTL - * @since 3.0.0 - */ - initRTL: function () - { - if (!this.style.rtl) - { - return; - } - - // Here is where the crazy starts. - // - // Due to browser implementation issues, you cannot fillText BiDi text to a canvas - // that is not part of the DOM. It just completely ignores the direction property. - - this.canvas.dir = 'rtl'; - - // Experimental atm, but one day ... - this.context.direction = 'rtl'; - - // Add it to the DOM, but hidden within the parent canvas. - this.canvas.style.display = 'none'; - - AddToDOM(this.canvas, this.scene.sys.canvas); - - // And finally we set the x origin - this.originX = 1; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. - * - * @method Phaser.GameObjects.Text#runWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * - * @return {string} The text after wrapping has been applied. - */ - runWordWrap: function (text) - { - var style = this.style; - - if (style.wordWrapCallback) - { - var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); - - if (Array.isArray(wrappedLines)) - { - wrappedLines = wrappedLines.join('\n'); - } - - return wrappedLines; - } - else if (style.wordWrapWidth) - { - if (style.wordWrapUseAdvanced) - { - return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); - } - else - { - return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); - } - } - else - { - return text; - } - }, - - /** - * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be - * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a - * single character. - * - * @method Phaser.GameObjects.Text#advancedWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - advancedWordWrap: function (text, context, wordWrapWidth) - { - var output = ''; - - // Condense consecutive spaces and split into lines - var lines = text - .replace(/ +/gi, ' ') - .split(this.splitRegExp); - - var linesCount = lines.length; - - for (var i = 0; i < linesCount; i++) - { - var line = lines[i]; - var out = ''; - - // Trim whitespace - line = line.replace(/^ *|\s*$/gi, ''); - - // If entire line is less than wordWrapWidth append the entire line and exit early - var lineWidth = context.measureText(line).width; - - if (lineWidth < wordWrapWidth) - { - output += line + '\n'; - continue; - } - - // Otherwise, calculate new lines - var currentLineWidth = wordWrapWidth; - - // Split into words - var words = line.split(' '); - - for (var j = 0; j < words.length; j++) - { - var word = words[j]; - var wordWithSpace = word + ' '; - var wordWidth = context.measureText(wordWithSpace).width; - - if (wordWidth > currentLineWidth) - { - // Break word - if (j === 0) - { - // Shave off letters from word until it's small enough - var newWord = wordWithSpace; - - while (newWord.length) - { - newWord = newWord.slice(0, -1); - wordWidth = context.measureText(newWord).width; - - if (wordWidth <= currentLineWidth) - { - break; - } - } - - // If wordWrapWidth is too small for even a single letter, shame user - // failure with a fatal error - if (!newWord.length) - { - throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); - } - - // Replace current word in array with remainder - var secondPart = word.substr(newWord.length); - - words[j] = secondPart; - - // Append first piece to output - out += newWord; - } - - // If existing word length is 0, don't include it - var offset = (words[j].length) ? j : j + 1; - - // Collapse rest of sentence and remove any trailing white space - var remainder = words.slice(offset).join(' ') - .replace(/[ \n]*$/gi, ''); - - // Prepend remainder to next line - lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); - linesCount = lines.length; - - break; // Processing on this line - - // Append word with space to output - } - else - { - out += wordWithSpace; - currentLineWidth -= wordWidth; - } - } - - // Append processed line to output - output += out.replace(/[ \n]*$/gi, '') + '\n'; - } - - // Trim the end of the string - output = output.replace(/[\s|\n]*$/gi, ''); - - return output; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Spaces are not collapsed and whitespace is not trimmed. - * - * @method Phaser.GameObjects.Text#basicWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - basicWordWrap: function (text, context, wordWrapWidth) - { - var result = ''; - var lines = text.split(this.splitRegExp); - - for (var i = 0; i < lines.length; i++) - { - var spaceLeft = wordWrapWidth; - var words = lines[i].split(' '); - - for (var j = 0; j < words.length; j++) - { - var wordWidth = context.measureText(words[j]).width; - var wordWidthWithSpace = wordWidth + context.measureText(' ').width; - - if (wordWidthWithSpace > spaceLeft) - { - // Skip printing the newline if it's the first word of the line that is greater - // than the word wrap width. - if (j > 0) - { - result += '\n'; - } - - result += words[j] + ' '; - spaceLeft = wordWrapWidth - wordWidth; - } - else - { - spaceLeft -= wordWidthWithSpace; - result += words[j]; - - if (j < (words.length - 1)) - { - result += ' '; - } - } - } - - if (i < lines.length - 1) - { - result += '\n'; - } - } - - return result; - }, - - /** - * Runs the given text through this Text objects word wrapping and returns the results as an - * array, where each element of the array corresponds to a wrapped line of text. - * - * @method Phaser.GameObjects.Text#getWrappedText - * @since 3.0.0 - * - * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. - * - * @return {string[]} An array of strings with the pieces of wrapped text. - */ - getWrappedText: function (text) - { - if (text === undefined) { text = this.text; } - - this.style.syncFont(this.canvas, this.context); - - var wrappedLines = this.runWordWrap(text); - - return wrappedLines.split(this.splitRegExp); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setText - * @since 3.0.0 - * - * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this Text object. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateText(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStyle - * @since 3.0.0 - * - * @param {object} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStyle: function (style) - { - return this.style.setStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFont - * @since 3.0.0 - * - * @param {string} font - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFont: function (font) - { - return this.style.setFont(font); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontFamily - * @since 3.0.0 - * - * @param {string} family - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontFamily: function (family) - { - return this.style.setFontFamily(family); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontSize - * @since 3.0.0 - * - * @param {number} size - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontSize: function (size) - { - return this.style.setFontSize(size); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontStyle - * @since 3.0.0 - * - * @param {string} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontStyle: function (style) - { - return this.style.setFontStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFixedSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFixedSize: function (width, height) - { - return this.style.setFixedSize(width, height); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setBackgroundColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setBackgroundColor: function (color) - { - return this.style.setBackgroundColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFill - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFill: function (color) - { - return this.style.setFill(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setColor: function (color) - { - return this.style.setColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStroke - * @since 3.0.0 - * - * @param {string} color - [description] - * @param {number} thickness - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStroke: function (color, thickness) - { - return this.style.setStroke(color, thickness); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadow - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {string} color - [description] - * @param {number} blur - [description] - * @param {boolean} shadowStroke - [description] - * @param {boolean} shadowFill - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadow: function (x, y, color, blur, shadowStroke, shadowFill) - { - return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowOffset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowOffset: function (x, y) - { - return this.style.setShadowOffset(x, y); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowColor: function (color) - { - return this.style.setShadowColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowBlur - * @since 3.0.0 - * - * @param {number} blur - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowBlur: function (blur) - { - return this.style.setShadowBlur(blur); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowStroke - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowStroke: function (enabled) - { - return this.style.setShadowStroke(enabled); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowFill - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowFill: function (enabled) - { - return this.style.setShadowFill(enabled); - }, - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * - * @method Phaser.GameObjects.Text#setWordWrapWidth - * @since 3.0.0 - * - * @param {?number} width - The maximum width of a line in pixels. Set to null to remove wrapping. - * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapWidth: function (width, useAdvancedWrap) - { - return this.style.setWordWrapWidth(width, useAdvancedWrap); - }, - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * - * @method Phaser.GameObjects.Text#setWordWrapCallback - * @since 3.0.0 - * - * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapCallback: function (callback, scope) - { - return this.style.setWordWrapCallback(callback, scope); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setAlign - * @since 3.0.0 - * - * @param {string} align - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setAlign: function (align) - { - return this.style.setAlign(align); - }, - - /** - * 'left' can be an object. - * If only 'left' and 'top' are given they are treated as 'x' and 'y' - * - * @method Phaser.GameObjects.Text#setPadding - * @since 3.0.0 - * - * @param {(number|object)} left - [description] - * @param {number} top - [description] - * @param {number} right - [description] - * @param {number} bottom - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setPadding: function (left, top, right, bottom) - { - if (typeof left === 'object') - { - var config = left; - - // If they specify x and/or y this applies to all - var x = GetValue(config, 'x', null); - - if (x !== null) - { - left = x; - right = x; - } - else - { - left = GetValue(config, 'left', 0); - right = GetValue(config, 'right', left); - } - - var y = GetValue(config, 'y', null); - - if (y !== null) - { - top = y; - bottom = y; - } - else - { - top = GetValue(config, 'top', 0); - bottom = GetValue(config, 'bottom', top); - } - } - else - { - if (left === undefined) { left = 0; } - if (top === undefined) { top = left; } - if (right === undefined) { right = left; } - if (bottom === undefined) { bottom = top; } - } - - this.padding.left = left; - this.padding.top = top; - this.padding.right = right; - this.padding.bottom = bottom; - - return this.updateText(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setMaxLines - * @since 3.0.0 - * - * @param {integer} [max=0] - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setMaxLines: function (max) - { - return this.style.setMaxLines(max); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#updateText - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - updateText: function () - { - var canvas = this.canvas; - var context = this.context; - var style = this.style; - var resolution = this.resolution; - var size = style.metrics; - - style.syncFont(canvas, context); - - var outputText = this.text; - - if (style.wordWrapWidth || style.wordWrapCallback) - { - outputText = this.runWordWrap(this.text); - } - - // Split text into lines - var lines = outputText.split(this.splitRegExp); - - var textSize = GetTextSize(this, size, lines); - - var padding = this.padding; - - var w = textSize.width + padding.left + padding.right; - var h = textSize.height + padding.top + padding.bottom; - - if (style.fixedWidth === 0) - { - this.width = w; - } - - if (style.fixedHeight === 0) - { - this.height = h; - } - - this.updateDisplayOrigin(); - - w *= resolution; - h *= resolution; - - w = Math.max(w, 1); - h = Math.max(h, 1); - - if (canvas.width !== w || canvas.height !== h) - { - canvas.width = w; - canvas.height = h; - style.syncFont(canvas, context); // Resizing resets the context - } - else - { - context.clearRect(0, 0, w, h); - } - - context.save(); - - // context.scale(resolution, resolution); - - if (style.backgroundColor) - { - context.fillStyle = style.backgroundColor; - context.fillRect(0, 0, w, h); - } - - style.syncStyle(canvas, context); - - context.textBaseline = 'alphabetic'; - - // Apply padding - context.translate(padding.left, padding.top); - - var linePositionX; - var linePositionY; - - // Draw text line by line - for (var i = 0; i < textSize.lines; i++) - { - linePositionX = style.strokeThickness / 2; - linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; - - if (i > 0) - { - linePositionY += (textSize.lineSpacing * i); - } - - if (style.rtl) - { - linePositionX = w - linePositionX; - } - else if (style.align === 'right') - { - linePositionX += textSize.width - textSize.lineWidths[i]; - } - else if (style.align === 'center') - { - linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; - } - - if (this.autoRound) - { - linePositionX = Math.round(linePositionX); - linePositionY = Math.round(linePositionY); - } - - if (style.strokeThickness) - { - this.style.syncShadow(context, style.shadowStroke); - - context.strokeText(lines[i], linePositionX, linePositionY); - } - - if (style.color) - { - this.style.syncShadow(context, style.shadowFill); - - context.fillText(lines[i], linePositionX, linePositionY); - } - } - - context.restore(); - - this.dirty = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#getTextMetrics - * @since 3.0.0 - * - * @return {object} [description] - */ - getTextMetrics: function () - { - return this.style.getTextMetrics(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#toJSON - * @since 3.0.0 - * - * @return {JSONGameObject} A JSON representation of the Game Object. - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra Text data is added here - - var data = { - autoRound: this.autoRound, - text: this.text, - style: this.style.toJSON(), - resolution: this.resolution, - padding: { - left: this.padding.left, - right: this.padding.right, - top: this.padding.top, - bottom: this.padding.bottom - } - }; - - out.data = data; - - return out; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.Text#preDestroy - * @protected - * @since 3.0.0 - */ - preDestroy: function () - { - if (this.style.rtl) - { - RemoveFromDOM(this.canvas); - } - - CanvasPool.remove(this.canvas); - } - -}); - -module.exports = Text; - - -/***/ }), -/* 111 */ +/* 85 */ /***/ (function(module, exports) { /** @@ -21077,7 +13688,7 @@ module.exports = Text; /** * [description] * - * @function Phaser.Utils.Object.HasValue + * @function Phaser.Utils.Objects.HasValue * @since 3.0.0 * * @param {object} source - [description] @@ -21094,7 +13705,69 @@ module.exports = HasValue; /***/ }), -/* 112 */ +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var EaseMap = __webpack_require__(174); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetEaseFunction + * @since 3.0.0 + * + * @param {(string|function)} ease - [description] + * @param {array} easeParams - [description] + * + * @return {function} [description] + */ +var GetEaseFunction = function (ease, easeParams) +{ + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + if (easeParams) + { + var cloneParams = easeParams.slice(0); + + cloneParams.unshift(0); + + return function (v) + { + cloneParams[0] = v; + + return EaseMap[ease].apply(this, cloneParams); + }; + } + else + { + // String based look-up + return EaseMap[ease]; + } + } + else if (typeof ease === 'function') + { + // Custom function + return ease; + } + else if (Array.isArray(ease) && ease.length === 4) + { + // Bezier function (TODO) + } + + return EaseMap.Power0; +}; + +module.exports = GetEaseFunction; + + +/***/ }), +/* 87 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -21103,13 +13776,117 @@ module.exports = HasValue; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Actions = __webpack_require__(599); var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var ImageRender = __webpack_require__(826); + +/** + * @classdesc + * An Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Image = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.TextureCrop, + Components.Tint, + Components.Transform, + Components.Visible, + ImageRender + ], + + initialize: + + function Image (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Image'); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Image#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initPipeline(); + } + +}); + +module.exports = Image; + + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Actions = __webpack_require__(417); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); -var Range = __webpack_require__(254); -var Set = __webpack_require__(70); -var Sprite = __webpack_require__(34); +var IsPlainObject = __webpack_require__(8); +var Range = __webpack_require__(312); +var Set = __webpack_require__(95); +var Sprite = __webpack_require__(61); /** * @callback GroupCallback @@ -21199,11 +13976,11 @@ var Sprite = __webpack_require__(34); * Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden. * * @class Group - * @memberOf Phaser.GameObjects + * @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 {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [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. * * @see Phaser.Physics.Arcade.Group @@ -21215,8 +13992,38 @@ var Group = new Class({ function Group (scene, children, config) { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') + // They can pass in any of the following as the first argument: + + // 1) A single child + // 2) An array of children + // 3) A config object + // 4) An array of config objects + + // Or they can pass in a child, or array of children AND a config object + + if (config) { + // config has been set, are the children an array? + + if (children && !Array.isArray(children)) + { + children = [ children ]; + } + } + else if (Array.isArray(children)) + { + // No config, so let's check the children argument + + if (IsPlainObject(children[0])) + { + // It's an array of plain config objects + config = children; + children = null; + } + } + else if (IsPlainObject(children)) + { + // Children isn't an array. Is it a config object though? config = children; children = null; } @@ -21419,18 +14226,16 @@ var Group = new Class({ config = [ config ]; } - if (config[0].key === undefined) - { - return []; - } - var output = []; - for (var i = 0; i < config.length; i++) + if (config[0].key) { - var entries = this.createFromConfig(config[i]); - - output = output.concat(entries); + for (var i = 0; i < config.length; i++) + { + var entries = this.createFromConfig(config[i]); + + output = output.concat(entries); + } } return output; @@ -22287,8 +15092,8 @@ module.exports = Group; /***/ }), -/* 113 */ -/***/ (function(module, exports, __webpack_require__) { +/* 89 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -22296,40 +15101,40 @@ module.exports = Group; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * Check to see if the Ellipse contains the given x / y coordinates. * - * @function Phaser.Geom.Ellipse.CircumferencePoint + * @function Phaser.Geom.Ellipse.Contains * @since 3.0.0 * - * @generic {Phaser.Geom.Point} O - [out,$return] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. - * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. */ -var CircumferencePoint = function (ellipse, angle, out) +var Contains = function (ellipse, x, y) { - if (out === undefined) { out = new Point(); } + if (ellipse.width <= 0 || ellipse.height <= 0) + { + return false; + } - var halfWidth = ellipse.width / 2; - var halfHeight = ellipse.height / 2; + // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 + var normx = ((x - ellipse.x) / ellipse.width); + var normy = ((y - ellipse.y) / ellipse.height); - out.x = ellipse.x + halfWidth * Math.cos(angle); - out.y = ellipse.y + halfHeight * Math.sin(angle); + normx *= normx; + normy *= normy; - return out; + return (normx + normy < 0.25); }; -module.exports = CircumferencePoint; +module.exports = Contains; /***/ }), -/* 114 */ +/* 90 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -22339,10 +15144,10 @@ module.exports = CircumferencePoint; */ var Class = __webpack_require__(0); -var Contains = __webpack_require__(54); -var GetPoint = __webpack_require__(179); -var GetPoints = __webpack_require__(178); -var Random = __webpack_require__(134); +var Contains = __webpack_require__(89); +var GetPoint = __webpack_require__(308); +var GetPoints = __webpack_require__(307); +var Random = __webpack_require__(185); /** * @classdesc @@ -22353,7 +15158,7 @@ var Random = __webpack_require__(134); * To render an Ellipse you should look at the capabilities of the Graphics class. * * @class Ellipse - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * @@ -22440,7 +15245,7 @@ var Ellipse = new Class({ * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. @@ -22697,7 +15502,323 @@ module.exports = Ellipse; /***/ }), -/* 115 */ +/* 91 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Removes a single item from an array and returns it without creating gc, like the native splice does. + * Based on code by Mike Reinstein. + * + * @function Phaser.Utils.Array.SpliceOne + * @since 3.0.0 + * + * @param {array} array - [description] + * @param {integer} index - [description] + * + * @return {*} [description] + */ +var SpliceOne = function (array, index) +{ + if (index >= array.length) + { + return; + } + + var len = array.length - 1; + + var item = array[index]; + + for (var i = index; i < len; i++) + { + array[i] = array[i + 1]; + } + + array.length = len; + + return item; +}; + +module.exports = SpliceOne; + + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process) {/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the operating system of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.os` from within any Scene. + * + * @typedef {object} Phaser.Device.OS + * @since 3.0.0 + * + * @property {boolean} android - Is running on android? + * @property {boolean} chromeOS - Is running on chromeOS? + * @property {boolean} cocoonJS - Is the game running under CocoonJS? + * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? + * @property {boolean} cordova - Is the game running under Apache Cordova? + * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? + * @property {boolean} desktop - Is running on a desktop? + * @property {boolean} ejecta - Is the game running under Ejecta? + * @property {boolean} electron - Is the game running under GitHub Electron? + * @property {boolean} iOS - Is running on iOS? + * @property {boolean} iPad - Is running on iPad? + * @property {boolean} iPhone - Is running on iPhone? + * @property {boolean} kindle - Is running on an Amazon Kindle? + * @property {boolean} linux - Is running on linux? + * @property {boolean} macOS - Is running on macOS? + * @property {boolean} node - Is the game running under Node.js? + * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? + * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView + * @property {boolean} windows - Is running on windows? + * @property {boolean} windowsPhone - Is running on a Windows Phone? + * @property {number} iOSVersion - If running in iOS this will contain the major version number. + * @property {number} pixelRatio - PixelRatio of the host device? + */ +var OS = { + + android: false, + chromeOS: false, + cocoonJS: false, + cocoonJSApp: false, + cordova: false, + crosswalk: false, + desktop: false, + ejecta: false, + electron: false, + iOS: false, + iOSVersion: 0, + iPad: false, + iPhone: false, + kindle: false, + linux: false, + macOS: false, + node: false, + nodeWebkit: false, + pixelRatio: 1, + webApp: false, + windows: false, + windowsPhone: false + +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Windows/.test(ua)) + { + OS.windows = true; + } + else if (/Mac OS/.test(ua) && !(/like Mac OS/.test(ua))) + { + OS.macOS = true; + } + else if (/Android/.test(ua)) + { + OS.android = true; + } + else if (/Linux/.test(ua)) + { + OS.linux = true; + } + else if (/iP[ao]d|iPhone/i.test(ua)) + { + OS.iOS = true; + + (navigator.appVersion).match(/OS (\d+)/); + + OS.iOSVersion = parseInt(RegExp.$1, 10); + + OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; + OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; + } + else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) + { + OS.kindle = true; + + // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... + // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" + } + else if (/CrOS/.test(ua)) + { + OS.chromeOS = true; + } + + if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) + { + OS.android = false; + OS.iOS = false; + OS.macOS = false; + OS.windows = true; + OS.windowsPhone = true; + } + + var silk = (/Silk/).test(ua); + + if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) + { + OS.desktop = true; + } + + // Windows Phone / Table reset + if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) + { + OS.desktop = false; + } + + // WebApp mode in iOS + if (navigator.standalone) + { + OS.webApp = true; + } + + if (window.cordova !== undefined) + { + OS.cordova = true; + } + + if (typeof process !== 'undefined' && process.versions && process.versions.node) + { + OS.node = true; + } + + if (OS.node && typeof process.versions === 'object') + { + OS.nodeWebkit = !!process.versions['node-webkit']; + + OS.electron = !!process.versions.electron; + } + + if (navigator.isCocoonJS) + { + OS.cocoonJS = true; + + try + { + OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); + } + catch (error) + { + OS.cocoonJSApp = false; + } + } + + if (window.ejecta !== undefined) + { + OS.ejecta = true; + } + + if ((/Crosswalk/).test(ua)) + { + OS.crosswalk = true; + } + + OS.pixelRatio = window['devicePixelRatio'] || 1; + + return OS; +} + +module.exports = init(); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(907))) + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); + +/** + * Return a value based on the range between `min` and `max` and the percentage given. + * + * @function Phaser.Math.FromPercent + * @since 3.0.0 + * + * @param {number} percent - A value between 0 and 1 representing the percentage. + * @param {number} min - The minimum value. + * @param {number} [max] - The maximum value. + * + * @return {number} The value that is `percent` percent between `min` and `max`. + */ +var FromPercent = function (percent, min, max) +{ + percent = Clamp(percent, 0, 1); + + return (max - min) * percent; +}; + +module.exports = FromPercent; + + +/***/ }), +/* 94 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser Scale Modes. + * + * @name Phaser.ScaleModes + * @enum {integer} + * @memberof Phaser + * @readonly + * @since 3.0.0 + */ + +module.exports = { + + /** + * Default Scale Mode (Linear). + * + * @name Phaser.ScaleModes.DEFAULT + */ + DEFAULT: 0, + + /** + * Linear Scale Mode. + * + * @name Phaser.ScaleModes.LINEAR + */ + LINEAR: 0, + + /** + * Nearest Scale Mode. + * + * @name Phaser.ScaleModes.NEAREST + */ + NEAREST: 1 + +}; + + +/***/ }), +/* 95 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -22706,24 +15827,17031 @@ module.exports = Ellipse; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Camera = __webpack_require__(123); var Class = __webpack_require__(0); -var Commands = __webpack_require__(119); -var Components = __webpack_require__(15); -var Ellipse = __webpack_require__(249); -var GameObject = __webpack_require__(2); + +/** + * @callback EachSetCallback + * @generic E - [entry] + * + * @param {*} entry - [description] + * @param {number} index - [description] + * + * @return {?boolean} [description] + */ + +/** + * @classdesc + * A Set is a collection of unique elements. + * + * @class Set + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + * @genericUse {T[]} - [elements] + * + * @param {Array.<*>} [elements] - An optional array of elements to insert into this Set. + */ +var Set = new Class({ + + initialize: + + function Set (elements) + { + /** + * The entries of this Set. Stored internally as an array. + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.Set#entries + * @type {Array.<*>} + * @default [] + * @since 3.0.0 + */ + this.entries = []; + + if (Array.isArray(elements)) + { + for (var i = 0; i < elements.length; i++) + { + this.set(elements[i]); + } + } + }, + + /** + * Inserts the provided value into this Set. If the value is already contained in this Set this method will have no effect. + * + * @method Phaser.Structs.Set#set + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {*} value - The value to insert into this Set. + * + * @return {Phaser.Structs.Set} This Set object. + */ + set: function (value) + { + if (this.entries.indexOf(value) === -1) + { + this.entries.push(value); + } + + return this; + }, + + /** + * Get an element of this Set which has a property of the specified name, if that property is equal to the specified value. + * If no elements of this Set satisfy the condition then this method will return `null`. + * + * @method Phaser.Structs.Set#get + * @since 3.0.0 + * + * @genericUse {T} - [value,$return] + * + * @param {string} property - The property name to check on the elements of this Set. + * @param {*} value - The value to check for. + * + * @return {*} The first element of this Set that meets the required condition, or `null` if this Set contains no elements that meet the condition. + */ + get: function (property, value) + { + for (var i = 0; i < this.entries.length; i++) + { + var entry = this.entries[i]; + + if (entry[property] === value) + { + return entry; + } + } + }, + + /** + * Returns an array containing all the values in this Set. + * + * @method Phaser.Structs.Set#getArray + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} An array containing all the values in this Set. + */ + getArray: function () + { + return this.entries.slice(0); + }, + + /** + * Removes the given value from this Set if this Set contains that value. + * + * @method Phaser.Structs.Set#delete + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {*} value - The value to remove from the Set. + * + * @return {Phaser.Structs.Set} This Set object. + */ + delete: function (value) + { + var index = this.entries.indexOf(value); + + if (index > -1) + { + this.entries.splice(index, 1); + } + + return this; + }, + + /** + * Dumps the contents of this Set to the console via `console.group`. + * + * @method Phaser.Structs.Set#dump + * @since 3.0.0 + */ + dump: function () + { + // eslint-disable-next-line no-console + console.group('Set'); + + for (var i = 0; i < this.entries.length; i++) + { + var entry = this.entries[i]; + console.log(entry); + } + + // eslint-disable-next-line no-console + console.groupEnd(); + }, + + /** + * Passes each value in this Set to the given callback. + * Use this function when you know this Set will be modified during the iteration, otherwise use `iterate`. + * + * @method Phaser.Structs.Set#each + * @since 3.0.0 + * + * @genericUse {EachSetCallback.} - [callback] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {EachSetCallback} callback - The callback to be invoked and passed each value this Set contains. + * @param {*} callbackScope - The scope of the callback. + * + * @return {Phaser.Structs.Set} This Set object. + */ + each: function (callback, callbackScope) + { + var i; + var temp = this.entries.slice(); + var len = temp.length; + + if (callbackScope) + { + for (i = 0; i < len; i++) + { + if (callback.call(callbackScope, temp[i], i) === false) + { + break; + } + } + } + else + { + for (i = 0; i < len; i++) + { + if (callback(temp[i], i) === false) + { + break; + } + } + } + + return this; + }, + + /** + * Passes each value in this Set to the given callback. + * For when you absolutely know this Set won't be modified during the iteration. + * + * @method Phaser.Structs.Set#iterate + * @since 3.0.0 + * + * @genericUse {EachSetCallback.} - [callback] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {EachSetCallback} callback - The callback to be invoked and passed each value this Set contains. + * @param {*} callbackScope - The scope of the callback. + * + * @return {Phaser.Structs.Set} This Set object. + */ + iterate: function (callback, callbackScope) + { + var i; + var len = this.entries.length; + + if (callbackScope) + { + for (i = 0; i < len; i++) + { + if (callback.call(callbackScope, this.entries[i], i) === false) + { + break; + } + } + } + else + { + for (i = 0; i < len; i++) + { + if (callback(this.entries[i], i) === false) + { + break; + } + } + } + + return this; + }, + + /** + * Goes through each entry in this Set and invokes the given function on them, passing in the arguments. + * + * @method Phaser.Structs.Set#iterateLocal + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {string} callbackKey - The key of the function to be invoked on each Set entry. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.Structs.Set} This Set object. + */ + iterateLocal: function (callbackKey) + { + var i; + var args = []; + + for (i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + var len = this.entries.length; + + for (i = 0; i < len; i++) + { + var entry = this.entries[i]; + + entry[callbackKey].apply(entry, args); + } + + return this; + }, + + /** + * Clears this Set so that it no longer contains any values. + * + * @method Phaser.Structs.Set#clear + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @return {Phaser.Structs.Set} This Set object. + */ + clear: function () + { + this.entries.length = 0; + + return this; + }, + + /** + * Returns `true` if this Set contains the given value, otherwise returns `false`. + * + * @method Phaser.Structs.Set#contains + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {*} value - The value to check for in this Set. + * + * @return {boolean} `true` if the given value was found in this Set, otherwise `false`. + */ + contains: function (value) + { + return (this.entries.indexOf(value) > -1); + }, + + /** + * Returns a new Set containing all values that are either in this Set or in the Set provided as an argument. + * + * @method Phaser.Structs.Set#union + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - The Set to perform the union with. + * + * @return {Phaser.Structs.Set} A new Set containing all the values in this Set and the Set provided as an argument. + */ + union: function (set) + { + var newSet = new Set(); + + set.entries.forEach(function (value) + { + newSet.set(value); + }); + + this.entries.forEach(function (value) + { + newSet.set(value); + }); + + return newSet; + }, + + /** + * Returns a new Set that contains only the values which are in this Set and that are also in the given Set. + * + * @method Phaser.Structs.Set#intersect + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - The Set to intersect this set with. + * + * @return {Phaser.Structs.Set} The result of the intersection, as a new Set. + */ + intersect: function (set) + { + var newSet = new Set(); + + this.entries.forEach(function (value) + { + if (set.contains(value)) + { + newSet.set(value); + } + }); + + return newSet; + }, + + /** + * Returns a new Set containing all the values in this Set which are *not* also in the given Set. + * + * @method Phaser.Structs.Set#difference + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - The Set to perform the difference with. + * + * @return {Phaser.Structs.Set} A new Set containing all the values in this Set that are not also in the Set provided as an argument to this method. + */ + difference: function (set) + { + var newSet = new Set(); + + this.entries.forEach(function (value) + { + if (!set.contains(value)) + { + newSet.set(value); + } + }); + + return newSet; + }, + + /** + * The size of this Set. This is the number of entries within it. + * Changing the size will truncate the Set if the given value is smaller than the current size. + * Increasing the size larger than the current size has no effect. + * + * @name Phaser.Structs.Set#size + * @type {integer} + * @since 3.0.0 + */ + size: { + + get: function () + { + return this.entries.length; + }, + + set: function (value) + { + if (value < this.entries.length) + { + return this.entries.length = value; + } + else + { + return this.entries.length; + } + } + + } + +}); + +module.exports = Set; + + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(63); + +/** + * Creates a new Object using all values from obj1 and obj2. + * If a value exists in both obj1 and obj2, the value in obj1 is used. + * + * @function Phaser.Utils.Objects.Merge + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var Merge = function (obj1, obj2) +{ + var clone = Clone(obj1); + + for (var key in obj2) + { + if (!clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } + + return clone; +}; + +module.exports = Merge; + + +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Defaults = __webpack_require__(129); +var GetAdvancedValue = __webpack_require__(12); +var GetBoolean = __webpack_require__(84); +var GetEaseFunction = __webpack_require__(86); +var GetNewValue = __webpack_require__(98); +var GetProps = __webpack_require__(205); +var GetTargets = __webpack_require__(131); +var GetValue = __webpack_require__(4); +var GetValueOp = __webpack_require__(130); +var Tween = __webpack_require__(128); +var TweenData = __webpack_require__(127); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.TweenBuilder + * @since 3.0.0 + * + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {object} config - [description] + * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ +var TweenBuilder = function (parent, config, defaults) +{ + if (defaults === undefined) + { + defaults = Defaults; + } + + // Create arrays of the Targets and the Properties + var targets = (defaults.targets) ? defaults.targets : GetTargets(config); + + // var props = (defaults.props) ? defaults.props : GetProps(config); + var props = GetProps(config); + + // Default Tween values + var delay = GetNewValue(config, 'delay', defaults.delay); + var duration = GetNewValue(config, 'duration', defaults.duration); + var easeParams = GetValue(config, 'easeParams', defaults.easeParams); + var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); + var hold = GetNewValue(config, 'hold', defaults.hold); + var repeat = GetNewValue(config, 'repeat', defaults.repeat); + var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + var flipX = GetBoolean(config, 'flipX', defaults.flipX); + var flipY = GetBoolean(config, 'flipY', defaults.flipY); + + var data = []; + + // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } + for (var p = 0; p < props.length; p++) + { + var key = props[p].key; + var value = props[p].value; + + // Create 1 TweenData per target, per property + for (var t = 0; t < targets.length; t++) + { + var ops = GetValueOp(key, value); + + var tweenData = TweenData( + targets[t], + key, + ops.getEnd, + ops.getStart, + GetEaseFunction(GetValue(value, 'ease', ease), easeParams), + GetNewValue(value, 'delay', delay), + GetNewValue(value, 'duration', duration), + GetBoolean(value, 'yoyo', yoyo), + GetNewValue(value, 'hold', hold), + GetNewValue(value, 'repeat', repeat), + GetNewValue(value, 'repeatDelay', repeatDelay), + GetBoolean(value, 'flipX', flipX), + GetBoolean(value, 'flipY', flipY) + ); + + data.push(tweenData); + } + } + + var tween = new Tween(parent, data, targets); + + tween.offset = GetAdvancedValue(config, 'offset', null); + tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + tween.paused = GetBoolean(config, 'paused', false); + tween.useFrames = GetBoolean(config, 'useFrames', false); + + // Set the Callbacks + var scope = GetValue(config, 'callbackScope', tween); + + // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params + var tweenArray = [ tween, null ]; + + var callbacks = Tween.TYPES; + + for (var i = 0; i < callbacks.length; i++) + { + var type = callbacks[i]; + + var callback = GetValue(config, type, false); + + if (callback) + { + var callbackScope = GetValue(config, type + 'Scope', scope); + var callbackParams = GetValue(config, type + 'Params', []); + + // The null is reset to be the Tween target + tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); + } + } + + return tween; +}; + +module.exports = TweenBuilder; + + +/***/ }), +/* 98 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetNewValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {function} [description] + */ +var GetNewValue = function (source, key, defaultValue) +{ + var valueCallback; + + if (source.hasOwnProperty(key)) + { + var t = typeof(source[key]); + + if (t === 'function') + { + valueCallback = function (index, totalTargets, target) + { + return source[key](index, totalTargets, target); + }; + } + else + { + valueCallback = function () + { + return source[key]; + }; + } + } + else if (typeof defaultValue === 'function') + { + valueCallback = defaultValue; + } + else + { + valueCallback = function () + { + return defaultValue; + }; + } + + return valueCallback; +}; + +module.exports = GetNewValue; + + +/***/ }), +/* 99 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Tileset is a combination of an image containing the tiles and a container for data about + * each tile. + * + * @class Tileset + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {string} name - The name of the tileset in the map data. + * @param {integer} firstgid - The first tile index this tileset contains. + * @param {integer} [tileWidth=32] - Width of each tile (in pixels). + * @param {integer} [tileHeight=32] - Height of each tile (in pixels). + * @param {integer} [tileMargin=0] - The margin around all tiles in the sheet (in pixels). + * @param {integer} [tileSpacing=0] - The spacing between each tile in the sheet (in pixels). + * @param {object} [tileProperties={}] - Custom properties defined per tile in the Tileset. + * These typically are custom properties created in Tiled when editing a tileset. + * @param {object} [tileData={}] - Data stored per tile. These typically are created in Tiled + * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. + */ +var Tileset = new Class({ + + initialize: + + function Tileset (name, firstgid, tileWidth, tileHeight, tileMargin, tileSpacing, tileProperties, tileData) + { + if (tileWidth === undefined || tileWidth <= 0) { tileWidth = 32; } + if (tileHeight === undefined || tileHeight <= 0) { tileHeight = 32; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (tileProperties === undefined) { tileProperties = {}; } + if (tileData === undefined) { tileData = {}; } + + /** + * The name of the Tileset. + * + * @name Phaser.Tilemaps.Tileset#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The starting index of the first tile index this Tileset contains. + * + * @name Phaser.Tilemaps.Tileset#firstgid + * @type {integer} + * @since 3.0.0 + */ + this.firstgid = firstgid; + + /** + * The width of each tile (in pixels). Use setTileSize to change. + * + * @name Phaser.Tilemaps.Tileset#tileWidth + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileWidth = tileWidth; + + /** + * The height of each tile (in pixels). Use setTileSize to change. + * + * @name Phaser.Tilemaps.Tileset#tileHeight + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileHeight = tileHeight; + + /** + * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.Tileset#tileMargin + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileMargin = tileMargin; + + /** + * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.Tileset#tileSpacing + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileSpacing = tileSpacing; + + /** + * Tileset-specific properties per tile that are typically defined in the Tiled editor in the + * Tileset editor. + * + * @name Phaser.Tilemaps.Tileset#tileProperties + * @type {object} + * @since 3.0.0 + */ + this.tileProperties = tileProperties; + + /** + * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within + * the Tileset collision editor. This is where collision objects and terrain are stored. + * + * @name Phaser.Tilemaps.Tileset#tileData + * @type {object} + * @since 3.0.0 + */ + this.tileData = tileData; + + /** + * The cached image that contains the individual tiles. Use setImage to set. + * + * @name Phaser.Tilemaps.Tileset#image + * @type {?Phaser.Textures.Texture} + * @readonly + * @since 3.0.0 + */ + this.image = null; + + /** + * The gl texture used by the WebGL renderer. + * + * @name Phaser.Tilemaps.Tileset#glTexture + * @type {?WebGLTexture} + * @readonly + * @since 3.11.0 + */ + this.glTexture = null; + + /** + * The number of tile rows in the the tileset. + * + * @name Phaser.Tilemaps.Tileset#rows + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.rows = 0; + + /** + * The number of tile columns in the tileset. + * + * @name Phaser.Tilemaps.Tileset#columns + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.columns = 0; + + /** + * The total number of tiles in the tileset. + * + * @name Phaser.Tilemaps.Tileset#total + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.total = 0; + + /** + * The look-up table to specific tile image texture coordinates (UV in pixels). Each element + * contains the coordinates for a tile in an object of the form {x, y}. + * + * @name Phaser.Tilemaps.Tileset#texCoordinates + * @type {object[]} + * @readonly + * @since 3.0.0 + */ + this.texCoordinates = []; + }, + + /** + * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. + * + * @method Phaser.Tilemaps.Tileset#getTileProperties + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?(object|undefined)} + */ + getTileProperties: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.tileProperties[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained + * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision + * info and terrain mapping. + * + * @method Phaser.Tilemaps.Tileset#getTileData + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object|undefined} + */ + getTileData: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.tileData[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. + * + * @method Phaser.Tilemaps.Tileset#getTileCollisionGroup + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} + */ + getTileCollisionGroup: function (tileIndex) + { + var data = this.getTileData(tileIndex); + + return (data && data.objectgroup) ? data.objectgroup : null; + }, + + /** + * Returns true if and only if this Tileset contains the given tile index. + * + * @method Phaser.Tilemaps.Tileset#containsTileIndex + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {boolean} + */ + containsTileIndex: function (tileIndex) + { + return ( + tileIndex >= this.firstgid && + tileIndex < (this.firstgid + this.total) + ); + }, + + /** + * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. + * Returns null if tile index is not contained in this Tileset. + * + * @method Phaser.Tilemaps.Tileset#getTileTextureCoordinates + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} Object in the form { x, y } representing the top-left UV coordinate + * within the Tileset image. + */ + getTileTextureCoordinates: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.texCoordinates[tileIndex - this.firstgid]; + }, + + /** + * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setImage + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The image that contains the tiles. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setImage: function (texture) + { + this.image = texture; + + this.glTexture = texture.get().source.glTexture; + + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + + return this; + }, + + /** + * Sets the tile width & height and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setTileSize + * @since 3.0.0 + * + * @param {integer} [tileWidth] - The width of a tile in pixels. + * @param {integer} [tileHeight] - The height of a tile in pixels. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setTileSize: function (tileWidth, tileHeight) + { + if (tileWidth !== undefined) { this.tileWidth = tileWidth; } + if (tileHeight !== undefined) { this.tileHeight = tileHeight; } + + if (this.image) + { + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setSpacing + * @since 3.0.0 + * + * @param {integer} [margin] - The margin around the tiles in the sheet (in pixels). + * @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels). + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setSpacing: function (margin, spacing) + { + if (margin !== undefined) { this.tileMargin = margin; } + if (spacing !== undefined) { this.tileSpacing = spacing; } + + if (this.image) + { + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Updates tile texture coordinates and tileset data. + * + * @method Phaser.Tilemaps.Tileset#updateTileData + * @since 3.0.0 + * + * @param {integer} imageWidth - The (expected) width of the image to slice. + * @param {integer} imageHeight - The (expected) height of the image to slice. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + updateTileData: function (imageWidth, imageHeight) + { + var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); + var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); + + if (rowCount % 1 !== 0 || colCount % 1 !== 0) + { + console.warn('Image tile area not tile size multiple in: ' + this.name); + } + + // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated + // - hence the floor when calculating the rows/columns. + rowCount = Math.floor(rowCount); + colCount = Math.floor(colCount); + + this.rows = rowCount; + this.columns = colCount; + + // In Tiled, "empty" spaces in a tileset count as tiles and hence count towards the gid + this.total = rowCount * colCount; + + this.texCoordinates.length = 0; + + var tx = this.tileMargin; + var ty = this.tileMargin; + + for (var y = 0; y < this.rows; y++) + { + for (var x = 0; x < this.columns; x++) + { + this.texCoordinates.push({ x: tx, y: ty }); + tx += this.tileWidth + this.tileSpacing; + } + + tx = this.tileMargin; + ty += this.tileHeight + this.tileSpacing; + } + + return this; + } + +}); + +module.exports = Tileset; + + +/***/ }), +/* 100 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.TileToWorldY + * @private + * @since 3.0.0 + * + * @param {integer} tileY - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} + */ +var TileToWorldY = function (tileY, camera, layer) +{ + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; + var layerWorldY = 0; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + + tileHeight *= tilemapLayer.scaleY; + } + + return layerWorldY + tileY * tileHeight; +}; + +module.exports = TileToWorldY; + + +/***/ }), +/* 101 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.TileToWorldX + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} + */ +var TileToWorldX = function (tileX, camera, layer) +{ + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + var layerWorldX = 0; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX); + + tileWidth *= tilemapLayer.scaleX; + } + + return layerWorldX + tileX * tileWidth; +}; + +module.exports = TileToWorldX; + + +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsInLayerBounds = __webpack_require__(79); + +/** + * Gets a tile at the given tile coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAt = function (tileX, tileY, nonNull, layer) +{ + if (nonNull === undefined) { nonNull = false; } + + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else if (tile.index === -1) + { + return nonNull ? tile : null; + } + else + { + return tile; + } + } + else + { + return null; + } +}; + +module.exports = GetTileAt; + + +/***/ }), +/* 103 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Components + */ + +module.exports = { + + CalculateFacesAt: __webpack_require__(136), + CalculateFacesWithin: __webpack_require__(34), + Copy: __webpack_require__(489), + CreateFromTiles: __webpack_require__(488), + CullTiles: __webpack_require__(487), + Fill: __webpack_require__(486), + FilterTiles: __webpack_require__(485), + FindByIndex: __webpack_require__(484), + FindTile: __webpack_require__(483), + ForEachTile: __webpack_require__(482), + GetTileAt: __webpack_require__(102), + GetTileAtWorldXY: __webpack_require__(481), + GetTilesWithin: __webpack_require__(17), + GetTilesWithinShape: __webpack_require__(480), + GetTilesWithinWorldXY: __webpack_require__(479), + HasTileAt: __webpack_require__(219), + HasTileAtWorldXY: __webpack_require__(478), + IsInLayerBounds: __webpack_require__(79), + PutTileAt: __webpack_require__(135), + PutTileAtWorldXY: __webpack_require__(477), + PutTilesAt: __webpack_require__(476), + Randomize: __webpack_require__(475), + RemoveTileAt: __webpack_require__(218), + RemoveTileAtWorldXY: __webpack_require__(474), + RenderDebug: __webpack_require__(473), + ReplaceByIndex: __webpack_require__(220), + SetCollision: __webpack_require__(472), + SetCollisionBetween: __webpack_require__(471), + SetCollisionByExclusion: __webpack_require__(470), + SetCollisionByProperty: __webpack_require__(469), + SetCollisionFromCollisionGroup: __webpack_require__(468), + SetTileIndexCallback: __webpack_require__(467), + SetTileLocationCallback: __webpack_require__(466), + Shuffle: __webpack_require__(465), + SwapByIndex: __webpack_require__(464), + TileToWorldX: __webpack_require__(101), + TileToWorldXY: __webpack_require__(463), + TileToWorldY: __webpack_require__(100), + WeightedRandomize: __webpack_require__(462), + WorldToTileX: __webpack_require__(50), + WorldToTileXY: __webpack_require__(461), + WorldToTileY: __webpack_require__(49) + +}; + + +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(236); +var Sprite = __webpack_require__(61); + +/** + * @classdesc + * An Arcade Physics Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.Sprite + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeSprite = new Class({ + + Extends: Sprite, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeSprite (scene, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + + /** + * This Game Object's Physics Body. + * + * @name Phaser.Physics.Arcade.Sprite#body + * @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} + * @default null + * @since 3.0.0 + */ + this.body = null; + } + +}); + +module.exports = ArcadeSprite; + + +/***/ }), +/* 105 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} XHRSettingsObject + * + * @property {XMLHttpRequestResponseType} responseType - The response type of the XHR request, i.e. `blob`, `text`, etc. + * @property {boolean} [async=true] - Should the XHR request use async or not? + * @property {string} [user=''] - Optional username for the XHR request. + * @property {string} [password=''] - Optional password for the XHR request. + * @property {integer} [timeout=0] - Optional XHR timeout value. + * @property {(string|undefined)} [header] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [headerValue] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [requestedWith] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [overrideMimeType] - Provide a custom mime-type to use instead of the default. + */ + +/** + * Creates an XHRSettings Object with default values. + * + * @function Phaser.Loader.XHRSettings + * @since 3.0.0 + * + * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. + * @param {boolean} [async=true] - Should the XHR request use async or not? + * @param {string} [user=''] - Optional username for the XHR request. + * @param {string} [password=''] - Optional password for the XHR request. + * @param {integer} [timeout=0] - Optional XHR timeout value. + * + * @return {XHRSettingsObject} The XHRSettings object as used by the Loader. + */ +var XHRSettings = function (responseType, async, user, password, timeout) +{ + if (responseType === undefined) { responseType = ''; } + if (async === undefined) { async = true; } + if (user === undefined) { user = ''; } + if (password === undefined) { password = ''; } + if (timeout === undefined) { timeout = 0; } + + // Before sending a request, set the xhr.responseType to "text", + // "arraybuffer", "blob", or "document", depending on your data needs. + // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". + + return { + + // Ignored by the Loader, only used by File. + responseType: responseType, + + async: async, + + // credentials + user: user, + password: password, + + // timeout in ms (0 = no timeout) + timeout: timeout, + + // setRequestHeader + header: undefined, + headerValue: undefined, + requestedWith: false, + + // overrideMimeType + overrideMimeType: undefined + + }; +}; + +module.exports = XHRSettings; + + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); + +// Contains the plugins that Phaser uses globally and locally. +// These are the source objects, not instantiated. +var inputPlugins = {}; + +/** + * @typedef {object} InputPluginContainer + * + * @property {string} key - The unique name of this plugin in the input plugin cache. + * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. + * @property {string} [mapping] - If this plugin is to be injected into the Input Plugin, this is the property key map used. + */ + +var InputPluginCache = {}; + +/** + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + * + * @method Phaser.Input.InputPluginCache.register + * @since 3.10.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Input Plugin, this is the property key used. + * @param {string} settingsKey - The key in the Scene Settings to check to see if this plugin should install or not. + * @param {string} configKey - The key in the Game Config to check to see if this plugin should install or not. + */ +InputPluginCache.register = function (key, plugin, mapping, settingsKey, configKey) +{ + inputPlugins[key] = { plugin: plugin, mapping: mapping, settingsKey: settingsKey, configKey: configKey }; +}; + +/** + * Returns the input plugin object from the cache based on the given key. + * + * @method Phaser.Input.InputPluginCache.getCore + * @since 3.10.0 + * + * @param {string} key - The key of the input plugin to get. + * + * @return {InputPluginContainer} The input plugin object. + */ +InputPluginCache.getPlugin = function (key) +{ + return inputPlugins[key]; +}; + +/** + * Installs all of the registered Input Plugins into the given target. + * + * @method Phaser.Input.InputPluginCache.install + * @since 3.10.0 + * + * @param {Phaser.Input.InputPlugin} target - The target InputPlugin to install the plugins into. + */ +InputPluginCache.install = function (target) +{ + var sys = target.scene.sys; + var settings = sys.settings.input; + var config = sys.game.config; + + for (var key in inputPlugins) + { + var source = inputPlugins[key].plugin; + var mapping = inputPlugins[key].mapping; + var settingsKey = inputPlugins[key].settingsKey; + var configKey = inputPlugins[key].configKey; + + if (GetValue(settings, settingsKey, config[configKey])) + { + target[mapping] = new source(target); + } + } +}; + +/** + * Removes an input plugin based on the given key. + * + * @method Phaser.Input.InputPluginCache.remove + * @since 3.10.0 + * + * @param {string} key - The key of the input plugin to remove. + */ +InputPluginCache.remove = function (key) +{ + if (inputPlugins.hasOwnProperty(key)) + { + delete inputPlugins[key]; + } +}; + +module.exports = InputPluginCache; + + +/***/ }), +/* 107 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// This is based off an explanation and expanded math presented by Paul Bourke: +// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ + +/** + * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. + * + * @function Phaser.Geom.Intersects.LineToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line1 - The first Line to check. + * @param {Phaser.Geom.Line} line2 - The second Line to check. + * @param {Phaser.Geom.Point} [out] - A Point in which to optionally store the point of intersection. + * + * @return {boolean} `true` if the two Lines intersect, and the `out` object will be populated, if given. Otherwise, `false`. + */ +var LineToLine = function (line1, line2, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = line1.x1; + var y1 = line1.y1; + var x2 = line1.x2; + var y2 = line1.y2; + + var x3 = line2.x1; + var y3 = line2.y1; + var x4 = line2.x2; + var y4 = line2.y2; + + var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + var deNom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + + // Make sure there is not a division by zero - this also indicates that the lines are parallel. + // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). + // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). + + if (deNom === 0) + { + return false; + } + + // Calculate the intermediate fractional point that the lines potentially intersect. + + var uA = numA / deNom; + var uB = numB / deNom; + + // The fractional point will be between 0 and 1 inclusive if the lines intersect. + // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. + + if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) + { + out.x = x1 + (uA * (x2 - x1)); + out.y = y1 + (uA * (y2 - y1)); + + return true; + } + + return false; +}; + +module.exports = LineToLine; + + +/***/ }), +/* 108 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var MeshRender = __webpack_require__(731); + +/** + * @classdesc + * A Mesh Game Object. + * + * @class Mesh + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number[]} vertices - An array containing the vertices data for this Mesh. + * @param {number[]} uv - An array containing the uv data for this Mesh. + * @param {number[]} colors - An array containing the color data for this Mesh. + * @param {number[]} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Mesh = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + MeshRender + ], + + initialize: + + function Mesh (scene, x, y, vertices, uv, colors, alphas, texture, frame) + { + GameObject.call(this, scene, 'Mesh'); + + if (vertices.length !== uv.length) + { + throw new Error('Mesh Vertex count must match UV count'); + } + + var verticesUB = (vertices.length / 2) | 0; + + if (colors.length > 0 && colors.length < verticesUB) + { + throw new Error('Mesh Color count must match Vertex count'); + } + + if (alphas.length > 0 && alphas.length < verticesUB) + { + throw new Error('Mesh Alpha count must match Vertex count'); + } + + var i; + + if (colors.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + colors[i] = 0xFFFFFF; + } + } + + if (alphas.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + alphas[i] = 1.0; + } + } + + /** + * An array containing the vertices data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#vertices + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertices = new Float32Array(vertices); + + /** + * An array containing the uv data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#uv + * @type {Float32Array} + * @since 3.0.0 + */ + this.uv = new Float32Array(uv); + + /** + * An array containing the color data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#colors + * @type {Uint32Array} + * @since 3.0.0 + */ + this.colors = new Uint32Array(colors); + + /** + * An array containing the alpha data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#alphas + * @type {Float32Array} + * @since 3.0.0 + */ + this.alphas = new Float32Array(alphas); + + /** + * Fill or additive mode used when blending the color values? + * + * @name Phaser.GameObjects.Mesh#tintFill + * @type {boolean} + * @default false + * @since 3.11.0 + */ + this.tintFill = false; + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOrigin(); + this.initPipeline(); + } + +}); + +module.exports = Mesh; + + +/***/ }), +/* 109 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var GetBitmapTextSize = __webpack_require__(846); +var ParseFromAtlas = __webpack_require__(845); +var Render = __webpack_require__(844); + +/** + * The font data for an individual character of a Bitmap Font. + * + * Describes the character's position, size, offset and kerning. + * + * @typedef {object} BitmapFontCharacterData + * + * @property {number} x - The x position of the character. + * @property {number} y - The y position of the character. + * @property {number} width - The width of the character. + * @property {number} height - The height of the character. + * @property {number} centerX - The center x position of the character. + * @property {number} centerY - The center y position of the character. + * @property {number} xOffset - The x offset of the character. + * @property {number} yOffset - The y offset of the character. + * @property {object} data - Extra data for the character. + * @property {Object.} kerning - Kerning values, keyed by character code. + */ + +/** + * Bitmap Font data that can be used by a BitmapText Game Object. + * + * @typedef {object} BitmapFontData + * + * @property {string} font - The name of the font. + * @property {number} size - The size of the font. + * @property {number} lineHeight - The line height of the font. + * @property {boolean} retroFont - Whether this font is a retro font (monospace). + * @property {Object.} chars - The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more. + */ + +/** + * @typedef {object} JSONBitmapText + * @extends {JSONGameObject} + * + * @property {string} font - The name of the font. + * @property {string} text - The text that this Bitmap Text displays. + * @property {number} fontSize - The size of the font. + * @property {number} letterSpacing - Adds / Removes spacing between characters. + * @property {integer} align - The alignment of the text in a multi-line BitmapText object. + */ + +/** + * @classdesc + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * @class BitmapText + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} x - The x coordinate of this Game Object in world space. + * @param {number} y - The y coordinate of this Game Object in world space. + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size of this Bitmap Text. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. + */ +var BitmapText = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function BitmapText (scene, x, y, font, text, size, align) + { + if (text === undefined) { text = ''; } + if (align === undefined) { align = 0; } + + GameObject.call(this, scene, 'BitmapText'); + + /** + * The key of the Bitmap Font used by this Bitmap Text. + * To change the font after creation please use `setFont`. + * + * @name Phaser.GameObjects.BitmapText#font + * @type {string} + * @readonly + * @since 3.0.0 + */ + this.font = font; + + var entry = this.scene.sys.cache.bitmapFont.get(font); + + /** + * The data of the Bitmap Font used by this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#fontData + * @type {BitmapFontData} + * @readonly + * @since 3.0.0 + */ + this.fontData = entry.data; + + /** + * The text that this Bitmap Text object displays. + * + * @name Phaser.GameObjects.BitmapText#_text + * @type {string} + * @private + * @since 3.0.0 + */ + this._text = ''; + + /** + * The font size of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#_fontSize + * @type {number} + * @private + * @since 3.0.0 + */ + this._fontSize = size || this.fontData.size; + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * @name Phaser.GameObjects.BitmapText#_letterSpacing + * @type {number} + * @private + * @since 3.4.0 + */ + this._letterSpacing = 0; + + /** + * Controls the alignment of each line of text in this BitmapText object. + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#_align + * @type {integer} + * @private + * @since 3.11.0 + */ + this._align = align; + + /** + * An object that describes the size of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#_bounds + * @type {BitmapTextSize} + * @private + * @since 3.0.0 + */ + this._bounds = GetBitmapTextSize(this, false, this._bounds); + + /** + * An internal dirty flag for bounds calculation. + * + * @name Phaser.GameObjects.BitmapText#_dirty + * @type {boolean} + * @private + * @since 3.11.0 + */ + this._dirty = false; + + this.setTexture(entry.texture, entry.frame); + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline(); + + this.setText(text); + }, + + /** + * Set the lines of text in this BitmapText to be left-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setLeftAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setLeftAlign: function () + { + this._align = BitmapText.ALIGN_LEFT; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be center-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setCenterAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setCenterAlign: function () + { + this._align = BitmapText.ALIGN_CENTER; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be right-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setRightAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setRightAlign: function () + { + this._align = BitmapText.ALIGN_RIGHT; + + this._dirty = true; + + return this; + }, + + /** + * Set the font size of this Bitmap Text. + * + * @method Phaser.GameObjects.BitmapText#setFontSize + * @since 3.0.0 + * + * @param {number} size - The font size to set. + * + * @return {this} This BitmapText Object. + */ + setFontSize: function (size) + { + this._fontSize = size; + + this._dirty = true; + + return this; + }, + + /** + * Sets the letter spacing between each character of this Bitmap Text. + * Can be a positive value to increase the space, or negative to reduce it. + * Spacing is applied after the kerning values have been set. + * + * @method Phaser.GameObjects.BitmapText#setLetterSpacing + * @since 3.4.0 + * + * @param {number} [spacing=0] - The amount of horizontal space to add between each character. + * + * @return {this} This BitmapText Object. + */ + setLetterSpacing: function (spacing) + { + if (spacing === undefined) { spacing = 0; } + + this._letterSpacing = spacing; + + this._dirty = true; + + return this; + }, + + /** + * Set the textual content of this BitmapText. + * + * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. + * + * @method Phaser.GameObjects.BitmapText#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. + * + * @return {this} This BitmapText Object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this._text = value.toString(); + + this._dirty = true; + + this.updateDisplayOrigin(); + } + + return this; + }, + + /** + * Calculate the bounds of this Bitmap Text. + * + * An object is returned that contains the position, width and height of the Bitmap Text in local and global + * contexts. + * + * Local size is based on just the font size and a [0, 0] position. + * + * Global size takes into account the Game Object's scale, world position and display origin. + * + * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. + * + * @method Phaser.GameObjects.BitmapText#getTextBounds + * @since 3.0.0 + * + * @param {boolean} [round] - Whether to round the results to the nearest integer. + * + * @return {BitmapTextSize} An object that describes the size of this Bitmap Text. + */ + getTextBounds: function (round) + { + // local = The BitmapText based on fontSize and 0x0 coords + // global = The BitmapText, taking into account scale and world position + // lines = The BitmapText line data + + if (this._dirty) + { + GetBitmapTextSize(this, round, this._bounds); + } + + return this._bounds; + }, + + /** + * Changes the font this BitmapText is using to render. + * + * The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved, + * unless overridden via the arguments. + * + * @method Phaser.GameObjects.BitmapText#setFont + * @since 3.11.0 + * + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {number} [size] - The font size of this Bitmap Text. If not specified the current size will be used. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. + * + * @return {this} This BitmapText Object. + */ + setFont: function (key, size, align) + { + if (size === undefined) { size = this._fontSize; } + if (align === undefined) { align = this._align; } + + if (key !== this.font) + { + var entry = this.scene.sys.cache.bitmapFont.get(key); + + if (entry) + { + this.font = key; + this.fontData = entry.data; + this._fontSize = size; + this._align = align; + + this.setTexture(entry.texture, entry.frame); + + GetBitmapTextSize(this, false, this._bounds); + } + } + + return this; + }, + + /** + * Controls the alignment of each line of text in this BitmapText object. + * + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#align + * @type {integer} + * @since 3.11.0 + */ + align: { + + set: function (value) + { + this._align = value; + this._dirty = true; + }, + + get: function () + { + return this._align; + } + + }, + + /** + * The text that this Bitmap Text object displays. + * + * You can also use the method `setText` if you want a chainable way to change the text content. + * + * @name Phaser.GameObjects.BitmapText#text + * @type {string} + * @since 3.0.0 + */ + text: { + + set: function (value) + { + this.setText(value); + }, + + get: function () + { + return this._text; + } + + }, + + /** + * The font size of this Bitmap Text. + * + * You can also use the method `setFontSize` if you want a chainable way to change the font size. + * + * @name Phaser.GameObjects.BitmapText#fontSize + * @type {number} + * @since 3.0.0 + */ + fontSize: { + + set: function (value) + { + this._fontSize = value; + this._dirty = true; + }, + + get: function () + { + return this._fontSize; + } + + }, + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. + * + * @name Phaser.GameObjects.BitmapText#letterSpacing + * @type {number} + * @since 3.0.0 + */ + letterSpacing: { + + set: function (value) + { + this._letterSpacing = value; + this._dirty = true; + }, + + get: function () + { + return this._letterSpacing; + } + + }, + + /** + * The width of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#width + * @type {number} + * @readonly + * @since 3.0.0 + */ + width: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.width; + } + + }, + + /** + * The height of this bitmap text. + * + * @name Phaser.GameObjects.BitmapText#height + * @type {number} + * @readonly + * @since 3.0.0 + */ + height: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.height; + } + + }, + + /** + * Build a JSON representation of this Bitmap Text. + * + * @method Phaser.GameObjects.BitmapText#toJSON + * @since 3.0.0 + * + * @return {JSONBitmapText} A JSON representation of this Bitmap Text. + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra data is added here + + var data = { + font: this.font, + text: this.text, + fontSize: this.fontSize, + letterSpacing: this.letterSpacing, + align: this.align + }; + + out.data = data; + + return out; + } + +}); + +/** + * Left align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_LEFT + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_LEFT = 0; + +/** + * Center align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_CENTER + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_CENTER = 1; + +/** + * Right align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_RIGHT + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_RIGHT = 2; + +BitmapText.ParseFromAtlas = ParseFromAtlas; + +module.exports = BitmapText; + + +/***/ }), +/* 110 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +//! stable.js 0.1.6, https://github.com/Two-Screen/stable +//! © 2017 Angry Bytes and contributors. MIT licensed. + +(function() { + +// A stable array sort, because `Array#sort()` is not guaranteed stable. +// This is an implementation of merge sort, without recursion. + +var stable = function(arr, comp) { + return exec(arr.slice(), comp); +}; + +stable.inplace = function(arr, comp) { + var result = exec(arr, comp); + + // This simply copies back if the result isn't in the original array, + // which happens on an odd number of passes. + if (result !== arr) { + pass(result, null, arr.length, arr); + } + + return arr; +}; + +// Execute the sort using the input array and a second buffer as work space. +// Returns one of those two, containing the final result. +function exec(arr, comp) { + if (typeof(comp) !== 'function') { + comp = function(a, b) { + return String(a).localeCompare(b); + }; + } + + // Short-circuit when there's nothing to sort. + var len = arr.length; + if (len <= 1) { + return arr; + } + + // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. + // Chunks are the size of the left or right hand in merge sort. + // Stop when the left-hand covers all of the array. + var buffer = new Array(len); + for (var chk = 1; chk < len; chk *= 2) { + pass(arr, comp, chk, buffer); + + var tmp = arr; + arr = buffer; + buffer = tmp; + } + + return arr; +} + +// Run a single pass with the given chunk size. +var pass = function(arr, comp, chk, result) { + var len = arr.length; + var i = 0; + // Step size / double chunk size. + var dbl = chk * 2; + // Bounds of the left and right chunks. + var l, r, e; + // Iterators over the left and right chunk. + var li, ri; + + // Iterate over pairs of chunks. + for (l = 0; l < len; l += dbl) { + r = l + chk; + e = r + chk; + if (r > len) r = len; + if (e > len) e = len; + + // Iterate both chunks in parallel. + li = l; + ri = r; + while (true) { + // Compare the chunks. + if (li < r && ri < e) { + // This works for a regular `sort()` compatible comparator, + // but also for a simple comparator like: `a > b` + if (comp(arr[li], arr[ri]) <= 0) { + result[i++] = arr[li++]; + } + else { + result[i++] = arr[ri++]; + } + } + // Nothing to compare, just flush what's left. + else if (li < r) { + result[i++] = arr[li++]; + } + else if (ri < e) { + result[i++] = arr[ri++]; + } + // Both iterators are at the chunk ends. + else { + break; + } + } + } +}; + +// Export using CommonJS or to the window. +if (true) { + module.exports = stable; +} +else {} + +})(); + +/***/ }), +/* 111 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. + +var CheckMatrix = __webpack_require__(163); +var TransposeMatrix = __webpack_require__(315); + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateMatrix + * @since 3.0.0 + * + * @param {array} matrix - The array to rotate. + * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. + * + * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. + */ +var RotateMatrix = function (matrix, direction) +{ + if (direction === undefined) { direction = 90; } + + if (!CheckMatrix(matrix)) + { + return null; + } + + if (typeof direction !== 'string') + { + direction = ((direction % 360) + 360) % 360; + } + + if (direction === 90 || direction === -270 || direction === 'rotateLeft') + { + matrix = TransposeMatrix(matrix); + matrix.reverse(); + } + else if (direction === -90 || direction === 270 || direction === 'rotateRight') + { + matrix.reverse(); + matrix = TransposeMatrix(matrix); + } + else if (Math.abs(direction) === 180 || direction === 'rotate180') + { + for (var i = 0; i < matrix.length; i++) + { + matrix[i].reverse(); + } + + matrix.reverse(); + } + + return matrix; +}; + +module.exports = RotateMatrix; + + +/***/ }), +/* 112 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayUtils = __webpack_require__(164); +var Class = __webpack_require__(0); +var NOOP = __webpack_require__(1); +var StableSort = __webpack_require__(110); + +/** + * @callback EachListCallback + * @generic I - [item] + * + * @param {*} item - The item which is currently being processed. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + +/** + * @classdesc + * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. + * + * @class List + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + * + * @param {*} parent - The parent of this list. + */ +var List = new Class({ + + initialize: + + function List (parent) + { + /** + * The parent of this list. + * + * @name Phaser.Structs.List#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The objects that belong to this collection. + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.List#list + * @type {Array.<*>} + * @default [] + * @since 3.0.0 + */ + this.list = []; + + /** + * The index of the current element. + * + * This is used internally when iterating through the list with the {@link #first}, {@link #last}, {@link #get}, and {@link #previous} properties. + * + * @name Phaser.Structs.List#position + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.position = 0; + + /** + * A callback that is invoked every time a child is added to this list. + * + * @name Phaser.Structs.List#addCallback + * @type {function} + * @since 3.4.0 + */ + this.addCallback = NOOP; + + /** + * A callback that is invoked every time a child is removed from this list. + * + * @name Phaser.Structs.List#removeCallback + * @type {function} + * @since 3.4.0 + */ + this.removeCallback = NOOP; + + /** + * The property key to sort by. + * + * @name Phaser.Structs.List#_sortKey + * @type {string} + * @since 3.4.0 + */ + this._sortKey = ''; + }, + + /** + * Adds the given item to the end of the list. Each item must be unique. + * + * @method Phaser.Structs.List#add + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*|Array.<*>} child - The item, or array of items, to add to the list. + * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. + * + * @return {*} The list's underlying array. + */ + add: function (child, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.Add(this.list, child); + } + else + { + return ArrayUtils.Add(this.list, child, 0, this.addCallback, this); + } + }, + + /** + * Adds an item to list, starting at a specified index. Each item must be unique within the list. + * + * @method Phaser.Structs.List#addAt + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item, or array of items, to add to the list. + * @param {integer} [index=0] - The index in the list at which the element(s) will be inserted. + * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. + * + * @return {*} The List's underlying array. + */ + addAt: function (child, index, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.AddAt(this.list, child, index); + } + else + { + return ArrayUtils.AddAt(this.list, child, index, 0, this.addCallback, this); + } + }, + + /** + * Retrieves the item at a given position inside the List. + * + * @method Phaser.Structs.List#getAt + * @since 3.0.0 + * + * @genericUse {T} - [$return] + * + * @param {integer} index - The index of the item. + * + * @return {*} The retrieved item, or `undefined` if it's outside the List's bounds. + */ + getAt: function (index) + { + return this.list[index]; + }, + + /** + * Locates an item within the List and returns its index. + * + * @method Phaser.Structs.List#getIndex + * @since 3.0.0 + * + * @genericUse {T} - [child] + * + * @param {*} child - The item to locate. + * + * @return {integer} The index of the item within the List, or -1 if it's not in the List. + */ + getIndex: function (child) + { + // Return -1 if given child isn't a child of this display list + return this.list.indexOf(child); + }, + + /** + * Sort the contents of this List so the items are in order based + * on the given property. For example, `sort('alpha')` would sort the List + * contents based on the value of their `alpha` property. + * + * @method Phaser.Structs.List#sort + * @since 3.0.0 + * + * @genericUse {T[]} - [children,$return] + * + * @param {string} property - The property to lexically sort by. + * + * @return {Phaser.Structs.List} This List object. + */ + sort: function (property) + { + if (property) + { + this._sortKey = property; + + StableSort.inplace(this.list, this.sortHandler); + } + + return this; + }, + + /** + * Internal handler for the {@link #sort} method which compares two items. + * + * @method Phaser.Structs.List#sortHandler + * @private + * @since 3.4.0 + * + * @genericUse {T} - [childA,childB] + * + * @param {*} childA - The first item to compare. + * @param {*} childB - The second item to compare. + * + * @return {integer} The result of the comparison, which will be negative if the first item is smaller then second, positive if the first item is larger than the second, or 0 if they're equal. + */ + sortHandler: function (childA, childB) + { + return childA[this._sortKey] - childB[this._sortKey]; + }, + + /** + * Searches for the first instance of a child with its `name` + * property matching the given argument. Should more than one child have + * the same name only the first is returned. + * + * @method Phaser.Structs.List#getByName + * @since 3.0.0 + * + * @genericUse {T | null} - [$return] + * + * @param {string} name - The name to search for. + * + * @return {?*} The first child with a matching name, or null if none were found. + */ + getByName: function (name) + { + return ArrayUtils.GetFirst(this.list, 'name', name); + }, + + /** + * Returns a random child from the group. + * + * @method Phaser.Structs.List#getRandom + * @since 3.0.0 + * + * @genericUse {T | null} - [$return] + * + * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child). + * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from. + * + * @return {?*} A random child of this Group. + */ + getRandom: function (startIndex, length) + { + return ArrayUtils.GetRandom(this.list, startIndex, length); + }, + + /** + * Returns the first element in a given part of the List which matches a specific criterion. + * + * @method Phaser.Structs.List#getFirst + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {T | null} - [$return] + * + * @param {string} property - The name of the property to test or a falsey value to have no criterion. + * @param {*} value - The value to test the `property` against, or `undefined` to allow any value and only check for existence. + * @param {number} [startIndex=0] - The position in the List to start the search at. + * @param {number} [endIndex] - The position in the List to optionally stop the search at. It won't be checked. + * + * @return {?*} The first item which matches the given criterion, or `null` if no such item exists. + */ + getFirst: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns all children in this List. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('parent')` would return only children that have a property called `parent`. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only children that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this List had 100 children, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 children in the List. + * + * @method Phaser.Structs.List#getAll + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {T[]} - [$return] + * + * @param {string} [property] - An optional property to test against the value argument. + * @param {*} [value] - If property is set then Child.property must strictly equal this value to be included in the results. + * @param {integer} [startIndex] - The first child index to start the search from. + * @param {integer} [endIndex] - The last child index to search up until. + * + * @return {Array.<*>} All items of the List which match the given criterion, if any. + */ + getAll: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns the total number of items in the List which have a property matching the given value. + * + * @method Phaser.Structs.List#count + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {string} property - The property to test on each item. + * @param {*} value - The value to test the property against. + * + * @return {integer} The total number of matching elements. + */ + count: function (property, value) + { + return ArrayUtils.CountAllMatching(this.list, property, value); + }, + + /** + * Swaps the positions of two items in the list. + * + * @method Phaser.Structs.List#swap + * @since 3.0.0 + * + * @genericUse {T} - [child1,child2] + * + * @param {*} child1 - The first item to swap. + * @param {*} child2 - The second item to swap. + */ + swap: function (child1, child2) + { + ArrayUtils.Swap(this.list, child1, child2); + }, + + /** + * Moves an item in the List to a new position. + * + * @method Phaser.Structs.List#moveTo + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to move. + * @param {integer} index - Moves an item in the List to a new position. + * + * @return {*} The item that was moved. + */ + moveTo: function (child, index) + { + return ArrayUtils.MoveTo(this.list, child, index); + }, + + /** + * Removes one or many items from the List. + * + * @method Phaser.Structs.List#remove + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item, or array of items, to remove. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {*} The item, or array of items, which were successfully removed from the List. + */ + remove: function (child, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.Remove(this.list, child); + } + else + { + return ArrayUtils.Remove(this.list, child, this.removeCallback, this); + } + }, + + /** + * Removes the item at the given position in the List. + * + * @method Phaser.Structs.List#removeAt + * @since 3.0.0 + * + * @genericUse {T} - [$return] + * + * @param {integer} index - The position to remove the item from. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {*} The item that was removed. + */ + removeAt: function (index, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.RemoveAt(this.list, index); + } + else + { + return ArrayUtils.RemoveAt(this.list, index, this.removeCallback, this); + } + }, + + /** + * Removes the items within the given range in the List. + * + * @method Phaser.Structs.List#removeBetween + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @param {integer} [startIndex=0] - The index to start removing from. + * @param {integer} [endIndex] - The position to stop removing at. The item at this position won't be removed. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {Array.<*>} An array of the items which were removed.[description] + */ + removeBetween: function (startIndex, endIndex, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex); + } + else + { + return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeCallback, this); + } + }, + + /** + * Removes all the items. + * + * @method Phaser.Structs.List#removeAll + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.List.} - [$return] + * + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {Phaser.Structs.List} This List object. + */ + removeAll: function (skipCallback) + { + var i = this.list.length; + + while (i--) + { + this.remove(this.list[i], skipCallback); + } + + return this; + }, + + /** + * Brings the given child to the top of this List. + * + * @method Phaser.Structs.List#bringToTop + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to bring to the top of the List. + * + * @return {*} The item which was moved. + */ + bringToTop: function (child) + { + return ArrayUtils.BringToTop(this.list, child); + }, + + /** + * Sends the given child to the bottom of this List. + * + * @method Phaser.Structs.List#sendToBack + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to send to the back of the list. + * + * @return {*} The item which was moved. + */ + sendToBack: function (child) + { + return ArrayUtils.SendToBack(this.list, child); + }, + + /** + * Moves the given child up one place in this group unless it's already at the top. + * + * @method Phaser.Structs.List#moveUp + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to move up. + * + * @return {*} The item which was moved. + */ + moveUp: function (child) + { + ArrayUtils.MoveUp(this.list, child); + + return child; + }, + + /** + * Moves the given child down one place in this group unless it's already at the bottom. + * + * @method Phaser.Structs.List#moveDown + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to move down. + * + * @return {*} The item which was moved. + */ + moveDown: function (child) + { + ArrayUtils.MoveDown(this.list, child); + + return child; + }, + + /** + * Reverses the order of all children in this List. + * + * @method Phaser.Structs.List#reverse + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.List.} - [$return] + * + * @return {Phaser.Structs.List} This List object. + */ + reverse: function () + { + this.list.reverse(); + + return this; + }, + + /** + * Shuffles the items in the list. + * + * @method Phaser.Structs.List#shuffle + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.List.} - [$return] + * + * @return {Phaser.Structs.List} This List object. + */ + shuffle: function () + { + ArrayUtils.Shuffle(this.list); + + return this; + }, + + /** + * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. + * + * @method Phaser.Structs.List#replace + * @since 3.0.0 + * + * @genericUse {T} - [oldChild,newChild,$return] + * + * @param {*} oldChild - The child in this List that will be replaced. + * @param {*} newChild - The child to be inserted into this List. + * + * @return {*} Returns the oldChild that was replaced within this group. + */ + replace: function (oldChild, newChild) + { + return ArrayUtils.Replace(this.list, oldChild, newChild); + }, + + /** + * Checks if an item exists within the List. + * + * @method Phaser.Structs.List#exists + * @since 3.0.0 + * + * @genericUse {T} - [child] + * + * @param {*} child - The item to check for the existence of. + * + * @return {boolean} `true` if the item is found in the list, otherwise `false`. + */ + exists: function (child) + { + return (this.list.indexOf(child) > -1); + }, + + /** + * Sets the property `key` to the given value on all members of this List. + * + * @method Phaser.Structs.List#setAll + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {string} property - The name of the property to set. + * @param {*} value - The value to set the property to. + * @param {integer} [startIndex] - The first child index to start the search from. + * @param {integer} [endIndex] - The last child index to search up until. + */ + setAll: function (property, value, startIndex, endIndex) + { + ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); + + return this; + }, + + /** + * Passes all children to the given callback. + * + * @method Phaser.Structs.List#each + * @since 3.0.0 + * + * @genericUse {EachListCallback.} - [callback] + * + * @param {EachListCallback} callback - The function to call. + * @param {*} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + each: function (callback, context) + { + var args = [ null ]; + + for (var i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < this.list.length; i++) + { + args[0] = this.list[i]; + + callback.apply(context, args); + } + }, + + /** + * Clears the List and recreates its internal array. + * + * @method Phaser.Structs.List#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAll(); + + this.list = []; + }, + + /** + * Destroys this List. + * + * @method Phaser.Structs.List#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAll(); + + this.parent = null; + this.addCallback = null; + this.removeCallback = null; + }, + + /** + * The number of items inside the List. + * + * @name Phaser.Structs.List#length + * @type {integer} + * @readonly + * @since 3.0.0 + */ + length: { + + get: function () + { + return this.list.length; + } + + }, + + /** + * The first item in the List or `null` for an empty List. + * + * @name Phaser.Structs.List#first + * @type {integer} + * @readonly + * @since 3.0.0 + */ + first: { + + get: function () + { + this.position = 0; + + if (this.list.length > 0) + { + return this.list[0]; + } + else + { + return null; + } + } + + }, + + /** + * The last item in the List, or `null` for an empty List. + * + * @name Phaser.Structs.List#last + * @type {integer} + * @readonly + * @since 3.0.0 + */ + last: { + + get: function () + { + if (this.list.length > 0) + { + this.position = this.list.length - 1; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * The next item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #first} or manually setting the {@link #position} to iterate the List. + * + * @name Phaser.Structs.List#next + * @type {integer} + * @readonly + * @since 3.0.0 + */ + next: { + + get: function () + { + if (this.position < this.list.length) + { + this.position++; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * The previous item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #last} or manually setting the {@link #position} to iterate the List backwards. + * + * @name Phaser.Structs.List#previous + * @type {integer} + * @readonly + * @since 3.0.0 + */ + previous: { + + get: function () + { + if (this.position > 0) + { + this.position--; + + return this.list[this.position]; + } + else + { + return null; + } + } + + } + +}); + +module.exports = List; + + +/***/ }), +/* 113 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Clamp = __webpack_require__(23); +var Extend = __webpack_require__(20); + +/** + * @classdesc + * A Frame is a section of a Texture. + * + * @class Frame + * @memberof Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. + * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. + * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. + * @param {number} x - The x coordinate of the top-left of this Frame. + * @param {number} y - The y coordinate of the top-left of this Frame. + * @param {number} width - The width of this Frame. + * @param {number} height - The height of this Frame. + */ +var Frame = new Class({ + + initialize: + + function Frame (texture, name, sourceIndex, x, y, width, height) + { + /** + * The Texture this Frame is a part of. + * + * @name Phaser.Textures.Frame#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = texture; + + /** + * The name of this Frame. + * The name is unique within the Texture. + * + * @name Phaser.Textures.Frame#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The TextureSource this Frame is part of. + * + * @name Phaser.Textures.Frame#source + * @type {Phaser.Textures.TextureSource} + * @since 3.0.0 + */ + this.source = texture.source[sourceIndex]; + + /** + * The index of the TextureSource in the Texture sources array. + * + * @name Phaser.Textures.Frame#sourceIndex + * @type {integer} + * @since 3.0.0 + */ + this.sourceIndex = sourceIndex; + + /** + * A reference to the Texture Source WebGL Texture that this Frame is using. + * + * @name Phaser.Textures.Frame#glTexture + * @type {?WebGLTexture} + * @default null + * @since 3.11.0 + */ + this.glTexture = this.source.glTexture; + + /** + * X position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutX + * @type {integer} + * @since 3.0.0 + */ + this.cutX; + + /** + * Y position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutY + * @type {integer} + * @since 3.0.0 + */ + this.cutY; + + /** + * The width of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutWidth + * @type {integer} + * @since 3.0.0 + */ + this.cutWidth; + + /** + * The height of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutHeight + * @type {integer} + * @since 3.0.0 + */ + this.cutHeight; + + /** + * The X rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#x + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The Y rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#y + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The rendering width of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#width + * @type {integer} + * @since 3.0.0 + */ + this.width; + + /** + * The rendering height of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#height + * @type {integer} + * @since 3.0.0 + */ + this.height; + + /** + * Half the width, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfWidth + * @type {integer} + * @since 3.0.0 + */ + this.halfWidth; + + /** + * Half the height, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfHeight + * @type {integer} + * @since 3.0.0 + */ + this.halfHeight; + + /** + * The x center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerX + * @type {integer} + * @since 3.0.0 + */ + this.centerX; + + /** + * The y center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerY + * @type {integer} + * @since 3.0.0 + */ + this.centerY; + + /** + * The horizontal pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotX = 0; + + /** + * The vertical pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotY = 0; + + /** + * Does this Frame have a custom pivot point? + * + * @name Phaser.Textures.Frame#customPivot + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customPivot = false; + + /** + * **CURRENTLY UNSUPPORTED** + * + * Is this frame is rotated or not in the Texture? + * Rotation allows you to use rotated frames in texture atlas packing. + * It has nothing to do with Sprite rotation. + * + * @name Phaser.Textures.Frame#rotated + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotated = false; + + /** + * Over-rides the Renderer setting. + * -1 = use Renderer Setting + * 0 = No rounding + * 1 = Round + * + * @name Phaser.Textures.Frame#autoRound + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.autoRound = -1; + + /** + * Any Frame specific custom data can be stored here. + * + * @name Phaser.Textures.Frame#customData + * @type {object} + * @since 3.0.0 + */ + this.customData = {}; + + /** + * WebGL UV u0 value. + * + * @name Phaser.Textures.Frame#u0 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.u0 = 0; + + /** + * WebGL UV v0 value. + * + * @name Phaser.Textures.Frame#v0 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.v0 = 0; + + /** + * WebGL UV u1 value. + * + * @name Phaser.Textures.Frame#u1 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.u1 = 0; + + /** + * WebGL UV v1 value. + * + * @name Phaser.Textures.Frame#v1 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.v1 = 0; + + /** + * The un-modified source frame, trim and UV data. + * + * @name Phaser.Textures.Frame#data + * @type {object} + * @private + * @since 3.0.0 + */ + this.data = { + cut: { + x: 0, + y: 0, + w: 0, + h: 0, + r: 0, + b: 0 + }, + trim: false, + sourceSize: { + w: 0, + h: 0 + }, + spriteSourceSize: { + x: 0, + y: 0, + w: 0, + h: 0, + r: 0, + b: 0 + }, + radius: 0, + drawImage: { + x: 0, + y: 0, + width: 0, + height: 0 + } + }; + + this.setSize(width, height, x, y); + }, + + /** + * Sets the width, height, x and y of this Frame. + * + * This is called automatically by the constructor + * and should rarely be changed on-the-fly. + * + * @method Phaser.Textures.Frame#setSize + * @since 3.7.0 + * + * @param {integer} width - The width of the frame before being trimmed. + * @param {integer} height - The height of the frame before being trimmed. + * @param {integer} [x=0] - The x coordinate of the top-left of this Frame. + * @param {integer} [y=0] - The y coordinate of the top-left of this Frame. + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + setSize: function (width, height, x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + this.cutX = x; + this.cutY = y; + this.cutWidth = width; + this.cutHeight = height; + + this.width = width; + this.height = height; + + this.halfWidth = Math.floor(width * 0.5); + this.halfHeight = Math.floor(height * 0.5); + + this.centerX = Math.floor(width / 2); + this.centerY = Math.floor(height / 2); + + var data = this.data; + var cut = data.cut; + + cut.x = x; + cut.y = y; + cut.w = width; + cut.h = height; + cut.r = x + width; + cut.b = y + height; + + data.sourceSize.w = width; + data.sourceSize.h = height; + + data.spriteSourceSize.w = width; + data.spriteSourceSize.h = height; + + data.radius = 0.5 * Math.sqrt(width * width + height * height); + + var drawImage = data.drawImage; + + drawImage.x = x; + drawImage.y = y; + drawImage.width = width; + drawImage.height = height; + + return this.updateUVs(); + }, + + /** + * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. + * + * @method Phaser.Textures.Frame#setTrim + * @since 3.0.0 + * + * @param {number} actualWidth - The width of the frame before being trimmed. + * @param {number} actualHeight - The height of the frame before being trimmed. + * @param {number} destX - The destination X position of the trimmed frame for display. + * @param {number} destY - The destination Y position of the trimmed frame for display. + * @param {number} destWidth - The destination width of the trimmed frame for display. + * @param {number} destHeight - The destination height of the trimmed frame for display. + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) + { + var data = this.data; + var ss = data.spriteSourceSize; + + // Store actual values + + data.trim = true; + + data.sourceSize.w = actualWidth; + data.sourceSize.h = actualHeight; + + ss.x = destX; + ss.y = destY; + ss.w = destWidth; + ss.h = destHeight; + ss.r = destX + destWidth; + ss.b = destY + destHeight; + + // Adjust properties + this.x = destX; + this.y = destY; + + this.width = destWidth; + this.height = destHeight; + + this.halfWidth = destWidth * 0.5; + this.halfHeight = destHeight * 0.5; + + this.centerX = Math.floor(destWidth / 2); + this.centerY = Math.floor(destHeight / 2); + + return this.updateUVs(); + }, + + /** + * Takes a crop data object and, based on the rectangular region given, calculates the + * required UV coordinates in order to crop this Frame for WebGL and Canvas rendering. + * + * This is called directly by the Game Object Texture Components `setCrop` method. + * Please use that method to crop a Game Object. + * + * @method Phaser.Textures.Frame#setCropUVs + * @since 3.11.0 + * + * @param {object} crop - The crop data object. This is the `GameObject._crop` property. + * @param {number} x - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. + * @param {number} y - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param {number} width - The width of the crop rectangle. Cannot exceed the Frame width. + * @param {number} height - The height of the crop rectangle. Cannot exceed the Frame height. + * @param {boolean} flipX - Does the parent Game Object have flipX set? + * @param {boolean} flipY - Does the parent Game Object have flipY set? + * + * @return {object} The updated crop data object. + */ + setCropUVs: function (crop, x, y, width, height, flipX, flipY) + { + // Clamp the input values + + var cx = this.cutX; + var cy = this.cutY; + var cw = this.cutWidth; + var ch = this.cutHeight; + var rw = this.realWidth; + var rh = this.realHeight; + + x = Clamp(x, 0, rw); + y = Clamp(y, 0, rh); + + width = Clamp(width, 0, rw - x); + height = Clamp(height, 0, rh - y); + + var ox = cx + x; + var oy = cy + y; + var ow = width; + var oh = height; + + var data = this.data; + + if (data.trim) + { + var ss = data.spriteSourceSize; + + // Need to check for intersection between the cut area and the crop area + // If there is none, we set UV to be empty, otherwise set it to be the intersection area + + width = Clamp(width, 0, cw - x); + height = Clamp(height, 0, ch - y); + + var cropRight = x + width; + var cropBottom = y + height; + + var intersects = !(ss.r < x || ss.b < y || ss.x > cropRight || ss.y > cropBottom); + + if (intersects) + { + var ix = Math.max(ss.x, x); + var iy = Math.max(ss.y, y); + var iw = Math.min(ss.r, cropRight) - ix; + var ih = Math.min(ss.b, cropBottom) - iy; + + ow = iw; + oh = ih; + + if (flipX) + { + ox = cx + (cw - (ix - ss.x) - iw); + } + else + { + ox = cx + (ix - ss.x); + } + + if (flipY) + { + oy = cy + (ch - (iy - ss.y) - ih); + } + else + { + oy = cy + (iy - ss.y); + } + + x = ix; + y = iy; + + width = iw; + height = ih; + } + else + { + ox = 0; + oy = 0; + ow = 0; + oh = 0; + } + } + else + { + if (flipX) + { + ox = cx + (cw - x - width); + } + + if (flipY) + { + oy = cy + (ch - y - height); + } + } + + var tw = this.source.width; + var th = this.source.height; + + // Map the given coordinates into UV space, clamping to the 0-1 range. + + crop.u0 = Math.max(0, ox / tw); + crop.v0 = Math.max(0, oy / th); + crop.u1 = Math.min(1, (ox + ow) / tw); + crop.v1 = Math.min(1, (oy + oh) / th); + + crop.x = x; + crop.y = y; + + crop.cx = ox; + crop.cy = oy; + crop.cw = ow; + crop.ch = oh; + + crop.width = width; + crop.height = height; + + crop.flipX = flipX; + crop.flipY = flipY; + + return crop; + }, + + /** + * Takes a crop data object and recalculates the UVs based on the dimensions inside the crop object. + * Called automatically by `setFrame`. + * + * @method Phaser.Textures.Frame#updateCropUVs + * @since 3.11.0 + * + * @param {object} crop - The crop data object. This is the `GameObject._crop` property. + * @param {boolean} flipX - Does the parent Game Object have flipX set? + * @param {boolean} flipY - Does the parent Game Object have flipY set? + * + * @return {object} The updated crop data object. + */ + updateCropUVs: function (crop, flipX, flipY) + { + return this.setCropUVs(crop, crop.x, crop.y, crop.width, crop.height, flipX, flipY); + }, + + /** + * Updates the internal WebGL UV cache and the drawImage cache. + * + * @method Phaser.Textures.Frame#updateUVs + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVs: function () + { + var cx = this.cutX; + var cy = this.cutY; + var cw = this.cutWidth; + var ch = this.cutHeight; + + // Canvas data + + var cd = this.data.drawImage; + + cd.width = cw; + cd.height = ch; + + // WebGL data + + var tw = this.source.width; + var th = this.source.height; + + this.u0 = cx / tw; + this.v0 = cy / th; + + this.u1 = (cx + cw) / tw; + this.v1 = (cy + ch) / th; + + return this; + }, + + /** + * Updates the internal WebGL UV cache. + * + * @method Phaser.Textures.Frame#updateUVsInverted + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVsInverted: function () + { + var tw = this.source.width; + var th = this.source.height; + + this.u0 = (this.cutX + this.cutHeight) / tw; + this.v0 = this.cutY / th; + + this.u1 = this.cutX / tw; + this.v1 = (this.cutY + this.cutWidth) / th; + + return this; + }, + + /** + * Clones this Frame into a new Frame object. + * + * @method Phaser.Textures.Frame#clone + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} A clone of this Frame. + */ + clone: function () + { + var clone = new Frame(this.texture, this.name, this.sourceIndex); + + clone.cutX = this.cutX; + clone.cutY = this.cutY; + clone.cutWidth = this.cutWidth; + clone.cutHeight = this.cutHeight; + + clone.x = this.x; + clone.y = this.y; + + clone.width = this.width; + clone.height = this.height; + + clone.halfWidth = this.halfWidth; + clone.halfHeight = this.halfHeight; + + clone.centerX = this.centerX; + clone.centerY = this.centerY; + + clone.rotated = this.rotated; + + clone.data = Extend(true, clone.data, this.data); + + clone.updateUVs(); + + return clone; + }, + + /** + * Destroys this Frames references. + * + * @method Phaser.Textures.Frame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.texture = null; + + this.source = null; + }, + + /** + * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realWidth + * @type {number} + * @readonly + * @since 3.0.0 + */ + realWidth: { + + get: function () + { + return this.data.sourceSize.w; + } + + }, + + /** + * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realHeight + * @type {number} + * @readonly + * @since 3.0.0 + */ + realHeight: { + + get: function () + { + return this.data.sourceSize.h; + } + + }, + + /** + * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) + * + * @name Phaser.Textures.Frame#radius + * @type {number} + * @readonly + * @since 3.0.0 + */ + radius: { + + get: function () + { + return this.data.radius; + } + + }, + + /** + * Is the Frame trimmed or not? + * + * @name Phaser.Textures.Frame#trimmed + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + trimmed: { + + get: function () + { + return this.data.trim; + } + + }, + + /** + * The Canvas drawImage data object. + * + * @name Phaser.Textures.Frame#canvasData + * @type {object} + * @readonly + * @since 3.0.0 + */ + canvasData: { + + get: function () + { + return this.data.drawImage; + } + + } + +}); + +module.exports = Frame; + + +/***/ }), +/* 114 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var Extend = __webpack_require__(20); +var NOOP = __webpack_require__(1); + +/** + * @classdesc + * Class containing all the shared state and behavior of a sound object, independent of the implementation. + * + * @class BaseSound + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + */ +var BaseSound = new Class({ + + Extends: EventEmitter, + + initialize: + + function BaseSound (manager, key, config) + { + EventEmitter.call(this); + + /** + * Local reference to the sound manager. + * + * @name Phaser.Sound.BaseSound#manager + * @type {Phaser.Sound.BaseSoundManager} + * @private + * @since 3.0.0 + */ + this.manager = manager; + + /** + * Asset key for the sound. + * + * @name Phaser.Sound.BaseSound#key + * @type {string} + * @readonly + * @since 3.0.0 + */ + this.key = key; + + /** + * Flag indicating if sound is currently playing. + * + * @name Phaser.Sound.BaseSound#isPlaying + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isPlaying = false; + + /** + * Flag indicating if sound is currently paused. + * + * @name Phaser.Sound.BaseSound#isPaused + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isPaused = false; + + /** + * A property that holds the value of sound's actual playback rate, + * after its rate and detune values has been combined with global + * rate and detune values. + * + * @name Phaser.Sound.BaseSound#totalRate + * @type {number} + * @default 1 + * @readonly + * @since 3.0.0 + */ + this.totalRate = 1; + + /** + * A value representing the duration, in seconds. + * It could be total sound duration or a marker duration. + * + * @name Phaser.Sound.BaseSound#duration + * @type {number} + * @readonly + * @since 3.0.0 + */ + this.duration = this.duration || 0; + + /** + * The total duration of the sound in seconds. + * + * @name Phaser.Sound.BaseSound#totalDuration + * @type {number} + * @readonly + * @since 3.0.0 + */ + this.totalDuration = this.totalDuration || 0; + + /** + * A config object used to store default sound settings' values. + * Default values will be set by properties' setters. + * + * @name Phaser.Sound.BaseSound#config + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.config = { + + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + + }; + + /** + * Reference to the currently used config. + * It could be default config or marker config. + * + * @name Phaser.Sound.BaseSound#currentConfig + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.currentConfig = this.config; + + this.config = Extend(this.config, config); + + /** + * Object containing markers definitions. + * + * @name Phaser.Sound.BaseSound#markers + * @type {Object.} + * @default {} + * @readonly + * @since 3.0.0 + */ + this.markers = {}; + + /** + * Currently playing marker. + * 'null' if whole sound is playing. + * + * @name Phaser.Sound.BaseSound#currentMarker + * @type {SoundMarker} + * @default null + * @readonly + * @since 3.0.0 + */ + this.currentMarker = null; + + /** + * Flag indicating if destroy method was called on this sound. + * + * @name Phaser.Sound.BaseSound#pendingRemove + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.pendingRemove = false; + }, + + /** + * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. + * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. + * + * @method Phaser.Sound.BaseSound#addMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object. + * + * @return {boolean} Whether the marker was added successfully. + */ + addMarker: function (marker) + { + if (!marker || !marker.name || typeof marker.name !== 'string') + { + return false; + } + + if (this.markers[marker.name]) + { + // eslint-disable-next-line no-console + console.error('addMarker ' + marker.name + ' already exists in Sound'); + + return false; + } + + marker = Extend(true, { + name: '', + start: 0, + duration: this.totalDuration - (marker.start || 0), + config: { + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + } + }, marker); + + this.markers[marker.name] = marker; + + return true; + }, + + /** + * Updates previously added marker. + * + * @method Phaser.Sound.BaseSound#updateMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object with updated values. + * + * @return {boolean} Whether the marker was updated successfully. + */ + updateMarker: function (marker) + { + if (!marker || !marker.name || typeof marker.name !== 'string') + { + return false; + } + + if (!this.markers[marker.name]) + { + // eslint-disable-next-line no-console + console.warn('Audio Marker: ' + marker.name + ' missing in Sound: ' + this.key); + + return false; + } + + this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); + + return true; + }, + + /** + * Removes a marker from the sound. + * + * @method Phaser.Sound.BaseSound#removeMarker + * @since 3.0.0 + * + * @param {string} markerName - The name of the marker to remove. + * + * @return {?SoundMarker} Removed marker object or 'null' if there was no marker with provided name. + */ + removeMarker: function (markerName) + { + var marker = this.markers[markerName]; + + if (!marker) + { + return null; + } + + this.markers[markerName] = null; + + return marker; + }, + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * + * @method Phaser.Sound.BaseSound#play + * @since 3.0.0 + * + * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. + * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (markerName, config) + { + if (markerName === undefined) { markerName = ''; } + + if (typeof markerName === 'object') + { + config = markerName; + markerName = ''; + } + + if (typeof markerName !== 'string') + { + return false; + } + + if (!markerName) + { + this.currentMarker = null; + this.currentConfig = this.config; + this.duration = this.totalDuration; + } + else + { + if (!this.markers[markerName]) + { + // eslint-disable-next-line no-console + console.warn('Marker: ' + markerName + ' missing in Sound: ' + this.key); + + return false; + } + + this.currentMarker = this.markers[markerName]; + this.currentConfig = this.currentMarker.config; + this.duration = this.currentMarker.duration; + } + + this.resetConfig(); + + this.currentConfig = Extend(this.currentConfig, config); + + this.isPlaying = true; + this.isPaused = false; + + return true; + }, + + /** + * Pauses the sound. + * + * @method Phaser.Sound.BaseSound#pause + * @since 3.0.0 + * + * @return {boolean} Whether the sound was paused successfully. + */ + pause: function () + { + if (this.isPaused || !this.isPlaying) + { + return false; + } + + this.isPlaying = false; + this.isPaused = true; + + return true; + }, + + /** + * Resumes the sound. + * + * @method Phaser.Sound.BaseSound#resume + * @since 3.0.0 + * + * @return {boolean} Whether the sound was resumed successfully. + */ + resume: function () + { + if (!this.isPaused || this.isPlaying) + { + return false; + } + + this.isPlaying = true; + this.isPaused = false; + + return true; + }, + + /** + * Stop playing this sound. + * + * @method Phaser.Sound.BaseSound#stop + * @since 3.0.0 + * + * @return {boolean} Whether the sound was stopped successfully. + */ + stop: function () + { + if (!this.isPaused && !this.isPlaying) + { + return false; + } + + this.isPlaying = false; + this.isPaused = false; + + this.resetConfig(); + + return true; + }, + + /** + * Method used internally for applying config values to some of the sound properties. + * + * @method Phaser.Sound.BaseSound#applyConfig + * @protected + * @since 3.0.0 + */ + applyConfig: function () + { + this.mute = this.currentConfig.mute; + this.volume = this.currentConfig.volume; + this.rate = this.currentConfig.rate; + this.detune = this.currentConfig.detune; + this.loop = this.currentConfig.loop; + }, + + /** + * Method used internally for resetting values of some of the config properties. + * + * @method Phaser.Sound.BaseSound#resetConfig + * @protected + * @since 3.0.0 + */ + resetConfig: function () + { + this.currentConfig.seek = 0; + this.currentConfig.delay = 0; + }, + + /** + * Update method called automatically by sound manager on every game step. + * + * @method Phaser.Sound.BaseSound#update + * @override + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: NOOP, + + /** + * Method used internally to calculate total playback rate of the sound. + * + * @method Phaser.Sound.BaseSound#calculateRate + * @protected + * @since 3.0.0 + */ + calculateRate: function () + { + var cent = 1.0005777895065548; // Math.pow(2, 1/1200); + var totalDetune = this.currentConfig.detune + this.manager.detune; + var detuneRate = Math.pow(cent, totalDetune); + + this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; + }, + + /** + * Destroys this sound and all associated events and marks it for removal from the sound manager. + * + * @method Phaser.Sound.BaseSound#destroy + * @since 3.0.0 + */ + destroy: function () + { + if (this.pendingRemove) + { + return; + } + + this.emit('destroy', this); + this.pendingRemove = true; + this.manager = null; + this.key = ''; + this.removeAllListeners(); + this.isPlaying = false; + this.isPaused = false; + this.config = null; + this.currentConfig = null; + this.markers = null; + this.currentMarker = null; + } + +}); + +module.exports = BaseSound; + + +/***/ }), +/* 115 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Clone = __webpack_require__(63); +var EventEmitter = __webpack_require__(11); +var NOOP = __webpack_require__(1); + +/** + * @callback EachActiveSoundCallback + * + * @param {Phaser.Sound.BaseSoundManager} manager - The SoundManager + * @param {Phaser.Sound.BaseSound} sound - The current active Sound + * @param {number} index - The index of the current active Sound + * @param {Phaser.Sound.BaseSound[]} sounds - All sounds + */ + +/** + * Audio sprite sound type. + * + * @typedef {Phaser.Sound.BaseSound} Phaser.Sound.BaseSound.AudioSpriteSound + * + * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. + */ + +/** + * @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 + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var BaseSoundManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function BaseSoundManager (game) + { + EventEmitter.call(this); + + /** + * Local reference to game. + * + * @name Phaser.Sound.BaseSoundManager#game + * @type {Phaser.Game} + * @readonly + * @since 3.0.0 + */ + this.game = game; + + /** + * Local reference to the JSON Cache, as used by Audio Sprites. + * + * @name Phaser.Sound.BaseSoundManager#jsonCache + * @type {Phaser.Cache.BaseCache} + * @readonly + * @since 3.7.0 + */ + this.jsonCache = game.cache.json; + + /** + * An array containing all added sounds. + * + * @name Phaser.Sound.BaseSoundManager#sounds + * @type {Phaser.Sound.BaseSound[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.sounds = []; + + /** + * Global mute setting. + * + * @name Phaser.Sound.BaseSoundManager#mute + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.mute = false; + + /** + * Global volume setting. + * + * @name Phaser.Sound.BaseSoundManager#volume + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.volume = 1; + + /** + * Flag indicating if sounds should be paused when game looses focus, + * for instance when user switches to another tab/program/app. + * + * @name Phaser.Sound.BaseSoundManager#pauseOnBlur + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.pauseOnBlur = true; + + /** + * Property that actually holds the value of global playback rate. + * + * @name Phaser.Sound.BaseSoundManager#_rate + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._rate = 1; + + /** + * Property that actually holds the value of global detune. + * + * @name Phaser.Sound.BaseSoundManager#_detune + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._detune = 0; + + /** + * Mobile devices require sounds to be triggered from an explicit user action, + * such as a tap, before any sound can be loaded/played on a web page. + * Set to true if the audio system is currently locked awaiting user interaction. + * + * @name Phaser.Sound.BaseSoundManager#locked + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.locked = this.locked || false; + + /** + * Flag used internally for handling when the audio system + * has been unlocked, if there ever was a need for it. + * + * @name Phaser.Sound.BaseSoundManager#unlocked + * @type {boolean} + * @default false + * @private + * @since 3.0.0 + */ + this.unlocked = false; + + game.events.on('blur', function () + { + if (this.pauseOnBlur) + { + this.onBlur(); + } + }, this); + + game.events.on('focus', function () + { + if (this.pauseOnBlur) + { + this.onFocus(); + } + }, this); + + game.events.on('prestep', this.update, this); + game.events.once('destroy', this.destroy, this); + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.BaseSoundManager#add + * @override + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.BaseSound} The new sound instance. + */ + add: NOOP, + + /** + * Adds a new audio sprite sound into the sound manager. + * Audio Sprites are a combination of audio files and a JSON configuration. + * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite + * + * @method Phaser.Sound.BaseSoundManager#addAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.BaseSound.AudioSpriteSound} The new audio sprite sound instance. + */ + addAudioSprite: function (key, config) + { + if (config === undefined) { config = {}; } + + var sound = this.add(key, config); + + sound.spritemap = this.jsonCache.get(key).spritemap; + + for (var markerName in sound.spritemap) + { + if (!sound.spritemap.hasOwnProperty(markerName)) + { + continue; + } + + var markerConfig = Clone(config); + + var marker = sound.spritemap[markerName]; + + markerConfig.loop = (marker.hasOwnProperty('loop')) ? marker.loop : false; + + sound.addMarker({ + name: markerName, + start: marker.start, + duration: marker.end - marker.start, + config: markerConfig + }); + } + + return sound; + }, + + /** + * Enables playing sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#play + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {(SoundConfig|SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (key, extra) + { + var sound = this.add(key); + + sound.once('ended', sound.destroy, sound); + + if (extra) + { + if (extra.name) + { + sound.addMarker(extra); + + return sound.play(extra.name); + } + else + { + return sound.play(extra); + } + } + else + { + return sound.play(); + } + }, + + /** + * Enables playing audio sprite sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#playAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {string} spriteName - The name of the sound sprite to play. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {boolean} Whether the audio sprite sound started playing successfully. + */ + playAudioSprite: function (key, spriteName, config) + { + var sound = this.addAudioSprite(key); + + sound.once('ended', sound.destroy, sound); + + return sound.play(spriteName, config); + }, + + /** + * Removes a sound from the sound manager. + * The removed sound is destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#remove + * @since 3.0.0 + * + * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. + * + * @return {boolean} True if the sound was removed successfully, otherwise false. + */ + remove: function (sound) + { + var index = this.sounds.indexOf(sound); + + if (index !== -1) + { + sound.destroy(); + + this.sounds.splice(index, 1); + + return true; + } + + return false; + }, + + /** + * Removes all sounds from the sound manager that have an asset key matching the given value. + * The removed sounds are destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#removeByKey + * @since 3.0.0 + * + * @param {string} key - The key to match when removing sound objects. + * + * @return {number} The number of matching sound objects that were removed. + */ + removeByKey: function (key) + { + var removed = 0; + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + var sound = this.sounds[i]; + + if (sound.key === key) + { + sound.destroy(); + + this.sounds.splice(i, 1); + + removed++; + } + } + + return removed; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#pauseall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Pauses all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#pauseAll + * @fires Phaser.Sound.BaseSoundManager#pauseall + * @since 3.0.0 + */ + pauseAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.pause(); + }); + + this.emit('pauseall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#resumeall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Resumes all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#resumeAll + * @fires Phaser.Sound.BaseSoundManager#resumeall + * @since 3.0.0 + */ + resumeAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.resume(); + }); + + this.emit('resumeall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#stopall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Stops all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#stopAll + * @fires Phaser.Sound.BaseSoundManager#stopall + * @since 3.0.0 + */ + stopAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.stop(); + }); + + this.emit('stopall', this); + }, + + /** + * Method used internally for unlocking audio playback on devices that + * require user interaction before any sound can be played on a web page. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + * + * @method Phaser.Sound.BaseSoundManager#unlock + * @override + * @protected + * @since 3.0.0 + */ + unlock: NOOP, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onBlur + * @override + * @protected + * @since 3.0.0 + */ + onBlur: NOOP, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onFocus + * @override + * @protected + * @since 3.0.0 + */ + onFocus: NOOP, + + /** + * Update method called on every game step. + * Removes destroyed sounds and updates every active sound in the game. + * + * @method Phaser.Sound.BaseSoundManager#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: function (time, delta) + { + if (this.unlocked) + { + this.unlocked = false; + this.locked = false; + + /** + * @event Phaser.Sound.BaseSoundManager#unlocked + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + this.emit('unlocked', this); + } + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + if (this.sounds[i].pendingRemove) + { + this.sounds.splice(i, 1); + } + } + + this.sounds.forEach(function (sound) + { + sound.update(time, delta); + }); + }, + + /** + * Destroys all the sounds in the game and all associated events. + * + * @method Phaser.Sound.BaseSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.forEachActiveSound(function (sound) + { + sound.destroy(); + }); + + this.sounds.length = 0; + this.sounds = null; + + this.game = null; + }, + + /** + * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. + * + * @method Phaser.Sound.BaseSoundManager#forEachActiveSound + * @private + * @since 3.0.0 + * + * @param {EachActiveSoundCallback} callback - Callback function. (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Manager.BaseSound[]) => void + * @param {*} [scope] - Callback context. + */ + forEachActiveSound: function (callback, scope) + { + var _this = this; + + this.sounds.forEach(function (sound, index) + { + if (!sound.pendingRemove) + { + callback.call(scope || _this, sound, index, _this.sounds); + } + }); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#rate + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. + */ + + /** + * 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. + * + * @method Phaser.Sound.BaseSoundManager#setRate + * @fires Phaser.Sound.BaseSoundManager#rate + * @since 3.3.0 + * + * @param {number} value - Global playback rate at which all the sounds will be played. + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setRate: function (value) + { + this.rate = value; + + return this; + }, + + /** + * Global playback rate at which all the sounds will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audio's playback speed. + * + * @name Phaser.Sound.BaseSoundManager#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rate: { + + get: function () + { + return this._rate; + }, + + set: function (value) + { + this._rate = value; + + this.forEachActiveSound(function (sound) + { + sound.calculateRate(); + }); + + this.emit('rate', this, value); + } + + }, + + /** + * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @method Phaser.Sound.BaseSoundManager#setDetune + * @fires Phaser.Sound.BaseSoundManager#detune + * @since 3.3.0 + * + * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setDetune: function (value) + { + this.detune = value; + + return this; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#detune + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. + */ + + /** + * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.BaseSoundManager#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + detune: { + + get: function () + { + return this._detune; + }, + + set: function (value) + { + this._detune = value; + + this.forEachActiveSound(function (sound) + { + sound.calculateRate(); + }); + + this.emit('detune', this, value); + } + + } + +}); + +module.exports = BaseSoundManager; + + +/***/ }), +/* 116 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Scene consts. + * + * @ignore + */ + +var CONST = { + + /** + * Scene state. + * + * @name Phaser.Scenes.PENDING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + PENDING: 0, + + /** + * Scene state. + * + * @name Phaser.Scenes.INIT + * @readonly + * @type {integer} + * @since 3.0.0 + */ + INIT: 1, + + /** + * Scene state. + * + * @name Phaser.Scenes.START + * @readonly + * @type {integer} + * @since 3.0.0 + */ + START: 2, + + /** + * Scene state. + * + * @name Phaser.Scenes.LOADING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + LOADING: 3, + + /** + * Scene state. + * + * @name Phaser.Scenes.CREATING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + CREATING: 4, + + /** + * Scene state. + * + * @name Phaser.Scenes.RUNNING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + RUNNING: 5, + + /** + * Scene state. + * + * @name Phaser.Scenes.PAUSED + * @readonly + * @type {integer} + * @since 3.0.0 + */ + PAUSED: 6, + + /** + * Scene state. + * + * @name Phaser.Scenes.SLEEPING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + SLEEPING: 7, + + /** + * Scene state. + * + * @name Phaser.Scenes.SHUTDOWN + * @readonly + * @type {integer} + * @since 3.0.0 + */ + SHUTDOWN: 8, + + /** + * Scene state. + * + * @name Phaser.Scenes.DESTROYED + * @readonly + * @type {integer} + * @since 3.0.0 + */ + DESTROYED: 9 + +}; + +module.exports = CONST; + + +/***/ }), +/* 117 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks if the given `width` and `height` are a power of two. + * Useful for checking texture dimensions. + * + * @function Phaser.Math.Pow2.IsSizePowerOfTwo + * @since 3.0.0 + * + * @param {number} width - The width. + * @param {number} height - The height. + * + * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. + */ +var IsSizePowerOfTwo = function (width, height) +{ + return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); +}; + +module.exports = IsSizePowerOfTwo; + + +/***/ }), +/* 118 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(92); + +/** + * Determines the browser type and version running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.browser` from within any Scene. + * + * @typedef {object} Phaser.Device.Browser + * @since 3.0.0 + * + * @property {boolean} chrome - Set to true if running in Chrome. + * @property {boolean} edge - Set to true if running in Microsoft Edge browser. + * @property {boolean} firefox - Set to true if running in Firefox. + * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). + * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. + * @property {boolean} opera - Set to true if running in Opera. + * @property {boolean} safari - Set to true if running in Safari. + * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) + * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) + * @property {number} chromeVersion - If running in Chrome this will contain the major version number. + * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. + * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. + * @property {number} safariVersion - If running in Safari this will contain the major version number. + * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} + */ +var Browser = { + + chrome: false, + chromeVersion: 0, + edge: false, + firefox: false, + firefoxVersion: 0, + ie: false, + ieVersion: 0, + mobileSafari: false, + opera: false, + safari: false, + safariVersion: 0, + silk: false, + trident: false, + tridentVersion: 0 + +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Edge\/\d+/.test(ua)) + { + Browser.edge = true; + } + else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) + { + Browser.chrome = true; + Browser.chromeVersion = parseInt(RegExp.$1, 10); + } + else if ((/Firefox\D+(\d+)/).test(ua)) + { + Browser.firefox = true; + Browser.firefoxVersion = parseInt(RegExp.$1, 10); + } + else if ((/AppleWebKit/).test(ua) && OS.iOS) + { + Browser.mobileSafari = true; + } + else if ((/MSIE (\d+\.\d+);/).test(ua)) + { + Browser.ie = true; + Browser.ieVersion = parseInt(RegExp.$1, 10); + } + else if ((/Opera/).test(ua)) + { + Browser.opera = true; + } + else if ((/Safari/).test(ua) && !OS.windowsPhone) + { + Browser.safari = true; + } + else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) + { + Browser.ie = true; + Browser.trident = true; + Browser.tridentVersion = parseInt(RegExp.$1, 10); + Browser.ieVersion = parseInt(RegExp.$3, 10); + } + + // Silk gets its own if clause because its ua also contains 'Safari' + if ((/Silk/).test(ua)) + { + Browser.silk = true; + } + + return Browser; +} + +module.exports = init(); + + +/***/ }), +/* 119 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates a linear (interpolation) value over t. + * + * @function Phaser.Math.Linear + * @since 3.0.0 + * + * @param {number} p0 - The first point. + * @param {number} p1 - The second point. + * @param {number} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. + * + * @return {number} The step t% of the way between p0 and p1. + */ +var Linear = function (p0, p1, t) +{ + return (p1 - p0) * t + p0; +}; + +module.exports = Linear; + + +/***/ }), +/* 120 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Browser specific prefix, so not going to change between contexts, only between browsers +var prefix = ''; + +/** + * @namespace Phaser.Display.Canvas.Smoothing + * @since 3.0.0 + */ +var Smoothing = function () +{ + /** + * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. + * + * @function Phaser.Display.Canvas.Smoothing.getPrefix + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {string} [description] + */ + var getPrefix = function (context) + { + var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; + + for (var i = 0; i < vendors.length; i++) + { + var s = vendors[i] + 'mageSmoothingEnabled'; + + if (s in context) + { + return s; + } + } + + return null; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.enable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var enable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = true; + } + + return context; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.disable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var disable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = false; + } + + return context; + }; + + /** + * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. + * Returns null if no smoothing prefix is available. + * + * @function Phaser.Display.Canvas.Smoothing.isEnabled + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {?boolean} [description] + */ + var isEnabled = function (context) + { + return (prefix !== null) ? context[prefix] : null; + }; + + return { + disable: disable, + enable: enable, + getPrefix: getPrefix, + isEnabled: isEnabled + }; + +}; + +module.exports = Smoothing(); + + +/***/ }), +/* 121 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var DegToRad = __webpack_require__(31); +var EventEmitter = __webpack_require__(11); +var Rectangle = __webpack_require__(9); +var TransformMatrix = __webpack_require__(38); +var ValueToColor = __webpack_require__(178); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} JSONCameraBounds + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + */ + +/** + * @typedef {object} JSONCamera + * + * @property {string} name - The name of the camera + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + * @property {number} zoom - The zoom of camera + * @property {number} rotation - The rotation of camera + * @property {boolean} roundPixels - The round pixels st status of camera + * @property {number} scrollX - The horizontal scroll of camera + * @property {number} scrollY - The vertical scroll of camera + * @property {string} backgroundColor - The background color of camera + * @property {(JSONCameraBounds|undefined)} [bounds] - The bounds of camera + */ + +/** + * @classdesc + * A Base Camera class. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * The Base Camera is extended by the Camera class, which adds in special effects including Fade, + * Flash and Camera Shake, as well as the ability to follow Game Objects. + * + * The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow + * you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate + * to when they were added to the Camera class. + * + * @class BaseCamera + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.12.0 + * + * @extends Phaser.Events.EventEmitter + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.Visible + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var BaseCamera = new Class({ + + Extends: EventEmitter, + + Mixins: [ + Components.Alpha, + Components.Visible + ], + + initialize: + + function BaseCamera (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + EventEmitter.call(this); + + /** + * A reference to the Scene this camera belongs to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene; + + /** + * A reference to the Game Scene Manager. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#sceneManager + * @type {Phaser.Scenes.SceneManager} + * @since 3.12.0 + */ + this.sceneManager; + + /** + * A reference to the Game Config. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#config + * @type {object} + * @readonly + * @since 3.12.0 + */ + this.config; + + /** + * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * This value is a bitmask. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#id + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.id = 0; + + /** + * The name of the Camera. This is left empty for your own use. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The resolution of the Game, used in most Camera calculations. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#resolution + * @type {number} + * @readonly + * @since 3.12.0 + */ + this.resolution = 1; + + /** + * Should this camera round its pixel values to integers? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#roundPixels + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.roundPixels = false; + + /** + * Is this Camera visible or not? + * + * A visible camera will render and perform input tests. + * An invisible camera will not render anything and will skip input tests. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#visible + * @type {boolean} + * @default true + * @since 3.10.0 + */ + + /** + * Is this Camera using a bounds to restrict scrolling movement? + * + * Set this property along with the bounds via `Camera.setBounds`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#useBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useBounds = false; + + /** + * The World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. + * This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. + * If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. + * You can use it for culling or intersection checks. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#worldView + * @type {Phaser.Geom.Rectangle} + * @readonly + * @since 3.11.0 + */ + this.worldView = new Rectangle(); + + /** + * Is this Camera dirty? + * + * A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. + * + * This flag is cleared during the `postRenderCamera` method of the renderer. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#dirty + * @type {boolean} + * @default true + * @since 3.11.0 + */ + this.dirty = true; + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#x + * @type {number} + * @private + * @since 3.0.0 + */ + this._x = x; + + /** + * The y position of the Camera, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#y + * @type {number} + * @private + * @since 3.0.0 + */ + this._y = y; + + /** + * Internal Camera X value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cx + * @type {number} + * @private + * @since 3.12.0 + */ + this._cx = 0; + + /** + * Internal Camera Y value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cy + * @type {number} + * @private + * @since 3.12.0 + */ + this._cy = 0; + + /** + * Internal Camera Width value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cw + * @type {number} + * @private + * @since 3.12.0 + */ + this._cw = 0; + + /** + * Internal Camera Height value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_ch + * @type {number} + * @private + * @since 3.12.0 + */ + this._ch = 0; + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_width + * @type {number} + * @private + * @since 3.11.0 + */ + this._width = width; + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_height + * @type {number} + * @private + * @since 3.11.0 + */ + this._height = height; + + /** + * The bounds the camera is restrained to during scrolling. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollX + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollX = 0; + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollY + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollY = 0; + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_zoom + * @type {number} + * @private + * @default 1 + * @since 3.11.0 + */ + this._zoom = 1; + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._rotation = 0; + + /** + * A local transform matrix used for internal calculations. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#matrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.0.0 + */ + this.matrix = new TransformMatrix(); + + /** + * Does this Camera have a transparent background? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#transparent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.transparent = true; + + /** + * The background color of this Camera. Only used if `transparent` is `false`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#backgroundColor + * @type {Phaser.Display.Color} + * @since 3.0.0 + */ + this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); + + /** + * The Camera alpha value. Setting this property impacts every single object that this Camera + * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, + * or via the chainable `setAlpha` method instead. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#alpha + * @type {number} + * @default 1 + * @since 3.11.0 + */ + + /** + * Should the camera cull Game Objects before checking them for input hit tests? + * In some special cases it may be beneficial to disable this. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#disableCull + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.disableCull = false; + + /** + * A temporary array of culled objects. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#culledObjects + * @type {Phaser.GameObjects.GameObject[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.culledObjects = []; + + /** + * The mid-point of the Camera in 'world' coordinates. + * + * Use it to obtain exactly where in the world the center of the camera is currently looking. + * + * This value is updated in the preRender method, after the scroll values and follower + * have been processed. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#midPoint + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.11.0 + */ + this.midPoint = new Vector2(width / 2, height / 2); + + /** + * The horizontal origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originX + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originX = 0.5; + + /** + * The vertical origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originY + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originY = 0.5; + + /** + * Does this Camera have a custom viewport? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_customViewport + * @type {boolean} + * @private + * @default false + * @since 3.12.0 + */ + this._customViewport = false; + }, + + /** + * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAlpha + * @since 3.11.0 + * + * @param {number} [value=1] - The Camera alpha value. + * + * @return {this} This Camera instance. + */ + + /** + * Sets the rotation origin of this Camera. + * + * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setOrigin + * @since 3.11.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Camera instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this; + }, + + /** + * Calculates what the Camera.scrollX and scrollY values would need to be in order to move + * the Camera so it is centered on the given x and y coordinates, without actually moving + * the Camera there. The results are clamped based on the Camera bounds, if set. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getScroll + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {Phaser.Math.Vector2} [out] - A Vec2 to store the values in. If not given a new Vec2 is created. + * + * @return {Phaser.Math.Vector2} The scroll coordinates stored in the `x` abd `y` properties. + */ + getScroll: function (x, y, out) + { + if (out === undefined) { out = new Vector2(); } + + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + out.x = x - originX; + out.y = y - originY; + + if (this.useBounds) + { + out.x = this.clampX(out.x); + out.y = this.clampY(out.y); + } + + return out; + }, + + /** + * Moves the Camera so that it is centered on the given coordinates, bounds allowing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerOn + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerOn: function (x, y) + { + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + this.midPoint.set(x, y); + + this.scrollX = x - originX; + this.scrollY = y - originY; + + if (this.useBounds) + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerToBounds: function () + { + if (this.useBounds) + { + var bounds = this._bounds; + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + this.midPoint.set(bounds.centerX, bounds.centerY); + + this.scrollX = bounds.centerX - originX; + this.scrollY = bounds.centerY - originY; + } + + return this; + }, + + /** + * Moves the Camera so that it is re-centered based on its viewport size. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToSize + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerToSize: function () + { + this.scrollX = this.width * 0.5; + this.scrollY = this.height * 0.5; + + return this; + }, + + /** + * Takes an array of Game Objects and returns a new array featuring only those objects + * visible by this camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#cull + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] + * + * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. + * + * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. + */ + cull: function (renderableObjects) + { + if (this.disableCull) + { + return renderableObjects; + } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return renderableObjects; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var culledObjects = this.culledObjects; + var length = renderableObjects.length; + + determinant = 1 / determinant; + + culledObjects.length = 0; + + for (var index = 0; index < length; ++index) + { + var object = renderableObjects[index]; + + if (!object.hasOwnProperty('width') || object.parentContainer) + { + culledObjects.push(object); + continue; + } + + var objectW = object.width; + var objectH = object.height; + var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); + var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); + var tx = (objectX * mva + objectY * mvc + mve); + var ty = (objectX * mvb + objectY * mvd + mvf); + var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); + var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); + var cullW = cameraW + objectW; + var cullH = cameraH + objectH; + + if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH && + tw > -objectW && th > -objectH && tw < cullW && th < cullH) + { + culledObjects.push(object); + } + } + + return culledObjects; + }, + + /** + * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. + * You can optionally provide a Vector2, or similar object, to store the results in. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getWorldPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {number} x - The x position to convert to world space. + * @param {number} y - The y position to convert to world space. + * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. + */ + getWorldPoint: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + // Invert Matrix + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + output.x = x; + output.y = y; + + return output; + } + + determinant = 1 / determinant; + + var ima = mvd * determinant; + var imb = -mvb * determinant; + var imc = -mvc * determinant; + var imd = mva * determinant; + var ime = (mvc * mvf - mvd * mve) * determinant; + var imf = (mvb * mve - mva * mvf) * determinant; + + var c = Math.cos(this.rotation); + var s = Math.sin(this.rotation); + + var zoom = this.zoom; + var res = this.resolution; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + + // Works for zoom of 1 with any resolution, but resolution > 1 and zoom !== 1 breaks + var sx = x + ((scrollX * c - scrollY * s) * zoom); + var sy = y + ((scrollX * s + scrollY * c) * zoom); + + // Apply transform to point + output.x = (sx * ima + sy * imc) * res + ime; + output.y = (sx * imb + sy * imd) * res + imf; + + return output; + }, + + /** + * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings + * so that they are ignored by this Camera. This means they will not be rendered by this Camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#ignore + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group)} entries - The Game Object, or array of Game Objects, to be ignored by this Camera. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + ignore: function (entries) + { + var id = this.id; + + if (!Array.isArray(entries)) + { + entries = [ entries ]; + } + + for (var i = 0; i < entries.length; i++) + { + var entry = entries[i]; + + if (Array.isArray(entry)) + { + this.ignore(entry); + } + else if (entry.isParent) + { + this.ignore(entry.getChildren()); + } + else + { + entry.cameraFilter |= id; + } + } + + return this; + }, + + /** + * Internal preRender step. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#preRender + * @protected + * @since 3.0.0 + * + * @param {number} baseScale - The base scale, as set in the Camera Manager. + * @param {number} resolution - The game resolution. + */ + preRender: function (baseScale, resolution) + { + var width = this.width; + var height = this.height; + + var halfWidth = width * 0.5; + var halfHeight = height * 0.5; + + var zoom = this.zoom * baseScale; + var matrix = this.matrix; + + var originX = width * this.originX; + var originY = height * this.originY; + + var sx = this.scrollX; + var sy = this.scrollY; + + if (this.useBounds) + { + sx = this.clampX(sx); + sy = this.clampY(sy); + } + + if (this.roundPixels) + { + originX = Math.round(originX); + originY = Math.round(originY); + } + + // Values are in pixels and not impacted by zooming the Camera + this.scrollX = sx; + this.scrollY = sy; + + var midX = sx + halfWidth; + var midY = sy + halfHeight; + + // The center of the camera, in world space, so taking zoom into account + // Basically the pixel value of what it's looking at in the middle of the cam + this.midPoint.set(midX, midY); + + var displayWidth = width / zoom; + var displayHeight = height / zoom; + + this.worldView.setTo( + midX - (displayWidth / 2), + midY - (displayHeight / 2), + displayWidth, + displayHeight + ); + + matrix.loadIdentity(); + matrix.scale(resolution, resolution); + matrix.translate(this.x + originX, this.y + originY); + matrix.rotate(this.rotation); + matrix.scale(zoom, zoom); + matrix.translate(-originX, -originY); + }, + + /** + * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampX + * @since 3.11.0 + * + * @param {number} x - The value to horizontally scroll clamp. + * + * @return {number} The adjusted value to use as scrollX. + */ + clampX: function (x) + { + var bounds = this._bounds; + + var dw = this.displayWidth; + + var bx = bounds.x + ((dw - this.width) / 2); + var bw = Math.max(bx, bx + bounds.width - dw); + + if (x < bx) + { + x = bx; + } + else if (x > bw) + { + x = bw; + } + + return x; + }, + + /** + * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampY + * @since 3.11.0 + * + * @param {number} y - The value to vertically scroll clamp. + * + * @return {number} The adjusted value to use as scrollY. + */ + clampY: function (y) + { + var bounds = this._bounds; + + var dh = this.displayHeight; + + var by = bounds.y + ((dh - this.height) / 2); + var bh = Math.max(by, by + bounds.height - dh); + + if (y < by) + { + y = by; + } + else if (y > bh) + { + y = bh; + } + + return y; + }, + + /* + var gap = this._zoomInversed; + return gap * Math.round((src.x - this.scrollX * src.scrollFactorX) / gap); + */ + + /** + * If this Camera has previously had movement bounds set on it, this will remove them. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#removeBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + removeBounds: function () + { + this.useBounds = false; + + this.dirty = true; + + this._bounds.setEmpty(); + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAngle + * @since 3.0.0 + * + * @param {number} [value=0] - The cameras angle of rotation, given in degrees. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setAngle: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = DegToRad(value); + + return this; + }, + + /** + * Sets the background color for this Camera. + * + * By default a Camera has a transparent background but it can be given a solid color, with any level + * of transparency, via this method. + * + * The color value can be specified using CSS color notation, hex or numbers. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBackgroundColor + * @since 3.0.0 + * + * @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setBackgroundColor: function (color) + { + if (color === undefined) { color = 'rgba(0,0,0,0)'; } + + this.backgroundColor = ValueToColor(color); + + this.transparent = (this.backgroundColor.alpha === 0); + + return this; + }, + + /** + * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. + * + * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the + * edges and into blank space. It does not limit the placement of Game Objects, or where + * the Camera viewport can be positioned. + * + * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. + * + * Clear the bounds entirely by calling `Camera.removeBounds`. + * + * If you set bounds that are smaller than the viewport it will stop the Camera from being + * able to scroll. The bounds can be positioned where-ever you wish. By default they are from + * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of + * the Camera bounds. However, you can position them anywhere. So if you wanted a game world + * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y + * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find + * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBounds + * @since 3.0.0 + * + * @param {integer} x - The top-left x coordinate of the bounds. + * @param {integer} y - The top-left y coordinate of the bounds. + * @param {integer} width - The width of the bounds, in pixels. + * @param {integer} height - The height of the bounds, in pixels. + * @param {boolean} [centerOn] - If `true` the Camera will automatically be centered on the new bounds. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setBounds: function (x, y, width, height, centerOn) + { + this._bounds.setTo(x, y, width, height); + + this.dirty = true; + this.useBounds = true; + + if (centerOn) + { + this.centerToBounds(); + } + else + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Sets the name of this Camera. + * This value is for your own use and isn't used internally. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setName + * @since 3.0.0 + * + * @param {string} [value=''] - The name of the Camera. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setName: function (value) + { + if (value === undefined) { value = ''; } + + this.name = value; + + return this; + }, + + /** + * Set the position of the Camera viewport within the game. + * + * This does not change where the camera is 'looking'. See `setScroll` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setPosition + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRotation + * @since 3.0.0 + * + * @param {number} [value=0] - The rotation of the Camera, in radians. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setRotation: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = value; + + return this; + }, + + /** + * Should the Camera round pixel values to whole integers when rendering Game Objects? + * + * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRoundPixels + * @since 3.0.0 + * + * @param {boolean} value - `true` to round Camera pixels, `false` to not. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setRoundPixels: function (value) + { + this.roundPixels = value; + + return this; + }, + + /** + * Sets the Scene the Camera is bound to. + * + * Also populates the `resolution` property and updates the internal size values. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene the camera is bound to. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setScene: function (scene) + { + if (this.scene && this._customViewport) + { + this.sceneManager.customViewports--; + } + + this.scene = scene; + + this.config = scene.sys.game.config; + this.sceneManager = scene.sys.game.scene; + + var res = this.config.resolution; + + this.resolution = res; + + this._cx = this._x * res; + this._cy = this._y * res; + this._cw = this._width * res; + this._ch = this._height * res; + + this.updateSystem(); + + return this; + }, + + /** + * Set the position of where the Camera is looking within the game. + * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. + * Use this method, or the scroll properties, to move your camera around the game world. + * + * This does not change where the camera viewport is placed. See `setPosition` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScroll + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the Camera in the game world. + * @param {number} [y=x] - The y coordinate of the Camera in the game world. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setScroll: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollX = x; + this.scrollY = y; + + return this; + }, + + /** + * Set the size of the Camera viewport. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setSize + * @since 3.0.0 + * + * @param {integer} width - The width of the Camera viewport. + * @param {integer} [height=width] - The height of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * This method sets the position and size of the Camera viewport in a single call. + * + * If you're trying to change where the Camera is looking at in your game, then see + * the method `Camera.setScroll` instead. This method is for changing the viewport + * itself, not what the camera can see. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setViewport + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} y - The top-left y coordinate of the Camera viewport. + * @param {integer} width - The width of the Camera viewport. + * @param {integer} [height=width] - The height of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setViewport: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Set the zoom value of the Camera. + * + * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. + * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. + * + * A value of 1 means 'no zoom' and is the default. + * + * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setZoom + * @since 3.0.0 + * + * @param {number} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setZoom: function (value) + { + if (value === undefined) { value = 1; } + + if (value === 0) + { + value = 0.001; + } + + this.zoom = value; + + return this; + }, + + /** + * Sets the visibility of this Camera. + * + * An invisible Camera will skip rendering and input tests of everything it can see. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setVisible + * @since 3.10.0 + * + * @param {boolean} value - The visible state of the Camera. + * + * @return {this} This Camera instance. + */ + + /** + * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#toJSON + * @since 3.0.0 + * + * @return {JSONCamera} A well-formed object suitable for conversion to JSON. + */ + toJSON: function () + { + var output = { + name: this.name, + x: this.x, + y: this.y, + width: this.width, + height: this.height, + zoom: this.zoom, + rotation: this.rotation, + roundPixels: this.roundPixels, + scrollX: this.scrollX, + scrollY: this.scrollY, + backgroundColor: this.backgroundColor.rgba + }; + + if (this.useBounds) + { + output['bounds'] = { + x: this._bounds.x, + y: this._bounds.y, + width: this._bounds.width, + height: this._bounds.height + }; + } + + return output; + }, + + /** + * Internal method called automatically by the Camera Manager. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#update + * @protected + * @since 3.0.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 () + { + // NOOP + }, + + /** + * Internal method called automatically when the viewport changes. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#updateSystem + * @private + * @since 3.12.0 + */ + updateSystem: function () + { + if (!this.config) + { + return; + } + + var custom = (this._x !== 0 || this._y !== 0 || this.config.width !== this._width || this.config.height !== this._height); + + var sceneManager = this.sceneManager; + + if (custom && !this._customViewport) + { + // We need a custom viewport for this Camera + sceneManager.customViewports++; + } + else if (!custom && this._customViewport) + { + // We're turning off a custom viewport for this Camera + sceneManager.customViewports--; + } + + this.dirty = true; + this._customViewport = custom; + }, + + /** + * This event is fired when a camera is destroyed by the Camera Manager. + * + * @event CameraDestroyEvent + * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that was destroyed. + */ + + /** + * Destroys this Camera instance and its internal properties and references. + * Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager. + * + * This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default. + * + * Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction, + * rather than calling this method directly. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#destroy + * @fires CameraDestroyEvent + * @since 3.0.0 + */ + destroy: function () + { + this.emit('cameradestroy', this); + + this.removeAllListeners(); + + this.matrix.destroy(); + + this.culledObjects = []; + + if (this._customViewport) + { + // We're turning off a custom viewport for this Camera + this.sceneManager.customViewports--; + } + + this._bounds = null; + + this.scene = null; + this.config = null; + this.sceneManager = null; + }, + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this._x; + }, + + set: function (value) + { + this._x = value; + this._cx = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The y position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this._y; + }, + + set: function (value) + { + this._y = value; + this._cy = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#width + * @type {number} + * @since 3.0.0 + */ + width: { + + get: function () + { + return this._width; + }, + + set: function (value) + { + this._width = value; + this._cw = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#height + * @type {number} + * @since 3.0.0 + */ + height: { + + get: function () + { + return this._height; + }, + + set: function (value) + { + this._height = value; + this._ch = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollX: { + + get: function () + { + return this._scrollX; + }, + + set: function (value) + { + this._scrollX = value; + this.dirty = true; + } + + }, + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollY: { + + get: function () + { + return this._scrollY; + }, + + set: function (value) + { + this._scrollY = value; + this.dirty = true; + } + + }, + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#zoom + * @type {number} + * @default 1 + * @since 3.0.0 + */ + zoom: { + + get: function () + { + return this._zoom; + }, + + set: function (value) + { + this._zoom = value; + this.dirty = true; + } + + }, + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = value; + this.dirty = true; + } + + }, + + /** + * The x position of the center of the Camera's viewport, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerX + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerX: { + + get: function () + { + return this.x + (0.5 * this.width); + } + + }, + + /** + * The y position of the center of the Camera's viewport, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerY + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerY: { + + get: function () + { + return this.y + (0.5 * this.height); + } + + }, + + /** + * The displayed width of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width + * would be 1600, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a width of 800 and zoom of 2 would have a display width + * of 400 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayWidth + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayWidth: { + + get: function () + { + return this.width / this.zoom; + } + + }, + + /** + * The displayed height of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height + * would be 1200, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a height of 600 and zoom of 2 would have a display height + * of 300 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayHeight + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayHeight: { + + get: function () + { + return this.height / this.zoom; + } + + } + +}); + +module.exports = BaseCamera; + + +/***/ }), +/* 122 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Shuffles the contents of the given array using the Fisher-Yates implementation. + * + * The original array is modified directly and returned. + * + * @function Phaser.Utils.Array.Shuffle + * @since 3.0.0 + * + * @param {array} array - The array to shuffle. This array is modified in place. + * + * @return {array} The shuffled array. + */ +var Shuffle = function (array) +{ + for (var i = array.length - 1; i > 0; i--) + { + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + + return array; +}; + +module.exports = Shuffle; + + +/***/ }), +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback DataEachCallback + * + * @param {*} parent - The parent object of the DataManager. + * @param {string} key - The key of the value. + * @param {*} value - The value. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + */ + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManager + * @memberof Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {object} parent - The object that this DataManager belongs to. + * @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter. + */ +var DataManager = new Class({ + + initialize: + + function DataManager (parent, eventEmitter) + { + /** + * The object that this DataManager belongs to. + * + * @name Phaser.Data.DataManager#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The DataManager's event emitter. + * + * @name Phaser.Data.DataManager#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = eventEmitter; + + if (!eventEmitter) + { + this.events = (parent.events) ? parent.events : parent; + } + + /** + * The data list. + * + * @name Phaser.Data.DataManager#list + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * The public values list. You can use this to access anything you have stored + * in this Data Manager. For example, if you set a value called `gold` you can + * access it via: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also modify it directly: + * + * ```javascript + * this.data.values.gold += 1000; + * ``` + * + * Doing so will emit a `setdata` event from the parent of this Data Manager. + * + * Do not modify this object directly. Adding properties directly to this object will not + * emit any events. Always use `DataManager.set` to create new items the first time around. + * + * @name Phaser.Data.DataManager#values + * @type {Object.} + * @default {} + * @since 3.10.0 + */ + this.values = {}; + + /** + * Whether setting data is frozen for this DataManager. + * + * @name Phaser.Data.DataManager#_frozen + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._frozen = false; + + if (!parent.hasOwnProperty('sys') && this.events) + { + this.events.once('destroy', this.destroy, this); + } + }, + + /** + * Retrieves the value for the given key, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * this.data.get('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * this.data.get([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.Data.DataManager#get + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + get: function (key) + { + var list = this.list; + + if (Array.isArray(key)) + { + var output = []; + + for (var i = 0; i < key.length; i++) + { + output.push(list[key[i]]); + } + + return output; + } + else + { + return list[key]; + } + }, + + /** + * Retrieves all data values in a new object. + * + * @method Phaser.Data.DataManager#getAll + * @since 3.0.0 + * + * @return {Object.} All data values. + */ + getAll: function () + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Queries the DataManager for the values of keys matching the given regular expression. + * + * @method Phaser.Data.DataManager#query + * @since 3.0.0 + * + * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). + * + * @return {Object.} The values of the keys matching the search string. + */ + query: function (search) + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key) && key.match(search)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * data.set('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `get`: + * + * ```javascript + * data.get('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#set + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + set: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (typeof key === 'string') + { + return this.setValue(key, data); + } + else + { + for (var entry in key) + { + this.setValue(entry, key[entry]); + } + } + + return this; + }, + + /** + * Internal value setter, called automatically by the `set` method. + * + * @method Phaser.Data.DataManager#setValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * @param {*} data - The value to set. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setValue: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (this.has(key)) + { + // Hit the key getter, which will in turn emit the events. + this.values[key] = data; + } + else + { + var _this = this; + var list = this.list; + var events = this.events; + var parent = this.parent; + + Object.defineProperty(this.values, key, { + + enumerable: true, + + configurable: true, + + get: function () + { + return list[key]; + }, + + set: function (value) + { + if (!_this._frozen) + { + var previousValue = list[key]; + list[key] = value; + + events.emit('changedata', parent, key, value, previousValue); + events.emit('changedata_' + key, parent, value, previousValue); + } + } + + }); + + list[key] = data; + + events.emit('setdata', parent, key, data); + } + + return this; + }, + + /** + * Passes all data entries to the given callback. + * + * @method Phaser.Data.DataManager#each + * @since 3.0.0 + * + * @param {DataEachCallback} callback - The function to call. + * @param {*} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + each: function (callback, context) + { + var args = [ this.parent, null, undefined ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var key in this.list) + { + args[1] = key; + args[2] = this.list[key]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Merge the given object of key value pairs into this DataManager. + * + * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) + * will emit a `changedata` event. + * + * @method Phaser.Data.DataManager#merge + * @since 3.0.0 + * + * @param {Object.} data - The data to merge. + * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + merge: function (data, overwrite) + { + if (overwrite === undefined) { overwrite = true; } + + // Merge data from another component into this one + for (var key in data) + { + if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) + { + this.setValue(key, data[key]); + } + } + + return this; + }, + + /** + * Remove the value for the given key. + * + * If the key is found in this Data Manager it is removed from the internal lists and a + * `removedata` event is emitted. + * + * You can also pass in an array of keys, in which case all keys in the array will be removed: + * + * ```javascript + * this.data.remove([ 'gold', 'armor', 'health' ]); + * ``` + * + * @method Phaser.Data.DataManager#remove + * @since 3.0.0 + * + * @param {(string|string[])} key - The key to remove, or an array of keys to remove. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + remove: function (key) + { + if (this._frozen) + { + return this; + } + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.removeValue(key[i]); + } + } + else + { + return this.removeValue(key); + } + + return this; + }, + + /** + * Internal value remover, called automatically by the `remove` method. + * + * @method Phaser.Data.DataManager#removeValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + removeValue: function (key) + { + if (this.has(key)) + { + var data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this.parent, key, data); + } + + return this; + }, + + /** + * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. + * + * @method Phaser.Data.DataManager#pop + * @since 3.0.0 + * + * @param {string} key - The key of the value to retrieve and delete. + * + * @return {*} The value of the given key. + */ + pop: function (key) + { + var data = undefined; + + if (!this._frozen && this.has(key)) + { + data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this, key, data); + } + + return data; + }, + + /** + * Determines whether the given key is set in this Data Manager. + * + * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#has + * @since 3.0.0 + * + * @param {string} key - The key to check. + * + * @return {boolean} Returns `true` if the key exists, otherwise `false`. + */ + has: function (key) + { + return this.list.hasOwnProperty(key); + }, + + /** + * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts + * to create new values or update existing ones. + * + * @method Phaser.Data.DataManager#setFreeze + * @since 3.0.0 + * + * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setFreeze: function (value) + { + this._frozen = value; + + return this; + }, + + /** + * Delete all data in this Data Manager and unfreeze it. + * + * @method Phaser.Data.DataManager#reset + * @since 3.0.0 + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + reset: function () + { + for (var key in this.list) + { + delete this.list[key]; + delete this.values[key]; + } + + this._frozen = false; + + return this; + }, + + /** + * Destroy this data manager. + * + * @method Phaser.Data.DataManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + + this.events.off('changedata'); + this.events.off('setdata'); + this.events.off('removedata'); + + this.parent = null; + }, + + /** + * Gets or sets the frozen state of this Data Manager. + * A frozen Data Manager will block all attempts to create new values or update existing ones. + * + * @name Phaser.Data.DataManager#freeze + * @type {boolean} + * @since 3.0.0 + */ + freeze: { + + get: function () + { + return this._frozen; + }, + + set: function (value) + { + this._frozen = (value) ? true : false; + } + + }, + + /** + * Return the total number of entries in this Data Manager. + * + * @name Phaser.Data.DataManager#count + * @type {integer} + * @since 3.0.0 + */ + count: { + + get: function () + { + var i = 0; + + for (var key in this.list) + { + if (this.list[key] !== undefined) + { + i++; + } + } + + return i; + } + + } + +}); + +module.exports = DataManager; + + +/***/ }), +/* 124 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var Perimeter = function (rect) +{ + return 2 * (rect.width + rect.height); +}; + +module.exports = Perimeter; + + +/***/ }), +/* 125 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(66); +var Circle = __webpack_require__(71); +var CircleContains = __webpack_require__(40); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var Rectangle = __webpack_require__(9); +var RectangleContains = __webpack_require__(39); + +/** + * @classdesc + * A Zone Game Object. + * + * A Zone is a non-rendering rectangular Game Object that has a position and size. + * It has no texture and never displays, but does live on the display list and + * can be moved, scaled and rotated like any other Game Object. + * + * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods + * specifically for this. It is also useful for object overlap checks, or as a base for your own + * non-displaying Game Objects. + + * The default origin is 0.5, the center of the Zone, the same as with Game Objects. + * + * @class Zone + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @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 {number} [width=1] - The width of the Game Object. + * @param {number} [height=1] - The height of the Game Object. + */ +var Zone = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.GetBounds, + Components.Origin, + Components.ScaleMode, + Components.Transform, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function Zone (scene, x, y, width, height) + { + if (width === undefined) { width = 1; } + if (height === undefined) { height = width; } + + GameObject.call(this, scene, 'Zone'); + + this.setPosition(x, y); + + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Zone#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Zone#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * The Blend Mode of the Game Object. + * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into + * display lists without causing a batch flush. + * + * @name Phaser.GameObjects.Zone#blendMode + * @type {integer} + * @since 3.0.0 + */ + this.blendMode = BlendModes.NORMAL; + + this.updateDisplayOrigin(); + }, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Zone#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setSize: function (width, height, resizeInput) + { + if (resizeInput === undefined) { resizeInput = true; } + + this.width = width; + this.height = height; + + if (resizeInput && this.input && this.input.hitArea instanceof Rectangle) + { + this.input.hitArea.width = width; + this.input.hitArea.height = height; + } + + return this; + }, + + /** + * Sets the display size of this Game Object. + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Zone#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + }, + + /** + * Sets this Zone to be a Circular Drop Zone. + * The circle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setCircleDropZone + * @since 3.0.0 + * + * @param {number} radius - The radius of the Circle that will form the Drop Zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setCircleDropZone: function (radius) + { + return this.setDropZone(new Circle(0, 0, radius), CircleContains); + }, + + /** + * Sets this Zone to be a Rectangle Drop Zone. + * The rectangle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setRectangleDropZone + * @since 3.0.0 + * + * @param {number} width - The width of the rectangle drop zone. + * @param {number} height - The height of the rectangle drop zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setRectangleDropZone: function (width, height) + { + return this.setDropZone(new Rectangle(0, 0, width, height), RectangleContains); + }, + + /** + * Allows you to define your own Geometry shape to be used as a Drop Zone. + * + * @method Phaser.GameObjects.Zone#setDropZone + * @since 3.0.0 + * + * @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. + * @param {HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDropZone: function (shape, callback) + { + if (shape === undefined) + { + this.setRectangleDropZone(this.width, this.height); + } + else if (!this.input) + { + this.setInteractive(shape, callback, true); + } + + return this; + }, + + /** + * A NOOP method so you can pass a Zone to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Zone#setAlpha + * @private + * @since 3.11.0 + */ + setAlpha: function () + { + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderCanvas + * @private + * @since 3.0.0 + */ + renderCanvas: function () + { + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderWebGL + * @private + * @since 3.0.0 + */ + renderWebGL: function () + { + } + +}); + +module.exports = Zone; + + +/***/ }), +/* 126 */, +/* 127 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} TweenDataGenConfig + * + * @property {function} delay - [description] + * @property {function} duration - [description] + * @property {function} hold - [description] + * @property {function} repeat - [description] + * @property {function} repeatDelay - [description] + */ + +/** + * @typedef {object} Phaser.Tweens.TweenDataConfig + * + * @property {object} target - The target to tween. + * @property {string} key - The property of the target being tweened. + * @property {function} getEndValue - The returned value sets what the property will be at the END of the Tween. + * @property {function} getStartValue - The returned value sets what the property will be at the START of the Tween. + * @property {function} ease - The ease function this tween uses. + * @property {number} [duration=0] - Duration of the tween in ms/frames, excludes time for yoyo or repeats. + * @property {number} [totalDuration=0] - The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + * @property {number} [delay=0] - Time in ms/frames before tween will start. + * @property {boolean} [yoyo=false] - Cause the tween to return back to its start value after hold has expired. + * @property {number} [hold=0] - Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + * @property {integer} [repeat=0] - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + * @property {number} [repeatDelay=0] - Time in ms/frames before the repeat will start. + * @property {boolean} [flipX=false] - Automatically call toggleFlipX when the TweenData yoyos or repeats + * @property {boolean} [flipY=false] - Automatically call toggleFlipY when the TweenData yoyos or repeats + * @property {number} [progress=0] - Between 0 and 1 showing completion of this TweenData. + * @property {number} [elapsed=0] - Delta counter + * @property {integer} [repeatCounter=0] - How many repeats are left to run? + * @property {number} [start=0] - Ease value data. + * @property {number} [current=0] - Ease value data. + * @property {number} [end=0] - Ease value data. + * @property {number} [t1=0] - Time duration 1. + * @property {number} [t2=0] - Time duration 2. + * @property {TweenDataGenConfig} [gen] - LoadValue generation functions. + * @property {integer} [state=0] - TWEEN_CONST.CREATED + */ + +/** + * [description] + * + * @function Phaser.Tweens.TweenData + * @since 3.0.0 + * + * @param {object} target - [description] + * @param {string} key - [description] + * @param {function} getEnd - [description] + * @param {function} getStart - [description] + * @param {function} ease - [description] + * @param {number} delay - [description] + * @param {number} duration - [description] + * @param {boolean} yoyo - [description] + * @param {number} hold - [description] + * @param {number} repeat - [description] + * @param {number} repeatDelay - [description] + * @param {boolean} flipX - [description] + * @param {boolean} flipY - [description] + * + * @return {TweenDataConfig} [description] + */ +var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) +{ + return { + + // The target to tween + target: target, + + // The property of the target to tween + key: key, + + // The returned value sets what the property will be at the END of the Tween. + getEndValue: getEnd, + + // The returned value sets what the property will be at the START of the Tween. + getStartValue: getStart, + + // The ease function this tween uses. + ease: ease, + + // Duration of the tween in ms/frames, excludes time for yoyo or repeats. + duration: 0, + + // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + totalDuration: 0, + + // Time in ms/frames before tween will start. + delay: 0, + + // Cause the tween to return back to its start value after hold has expired. + yoyo: yoyo, + + // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + hold: 0, + + // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + repeat: 0, + + // Time in ms/frames before the repeat will start. + repeatDelay: 0, + + // Automatically call toggleFlipX when the TweenData yoyos or repeats + flipX: flipX, + + // Automatically call toggleFlipY when the TweenData yoyos or repeats + flipY: flipY, + + // Between 0 and 1 showing completion of this TweenData. + progress: 0, + + // Delta counter. + elapsed: 0, + + // How many repeats are left to run? + repeatCounter: 0, + + // Ease Value Data: + + start: 0, + current: 0, + end: 0, + + // Time Durations + t1: 0, + t2: 0, + + // LoadValue generation functions + gen: { + delay: delay, + duration: duration, + hold: hold, + repeat: repeat, + repeatDelay: repeatDelay + }, + + // TWEEN_CONST.CREATED + state: 0 + }; +}; + +module.exports = TweenData; + + +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GameObjectCreator = __webpack_require__(13); +var GameObjectFactory = __webpack_require__(5); +var TWEEN_CONST = __webpack_require__(83); + +/** + * @classdesc + * [description] + * + * @class Tween + * @memberof Phaser.Tweens + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {Phaser.Tweens.TweenDataConfig[]} data - [description] + * @param {array} targets - [description] + */ +var Tween = new Class({ + + initialize: + + function Tween (parent, data, targets) + { + /** + * [description] + * + * @name Phaser.Tweens.Tween#parent + * @type {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * Is the parent of this Tween a Timeline? + * + * @name Phaser.Tweens.Tween#parentIsTimeline + * @type {boolean} + * @since 3.0.0 + */ + this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); + + /** + * An array of TweenData objects, each containing a unique property and target being tweened. + * + * @name Phaser.Tweens.Tween#data + * @type {Phaser.Tweens.TweenDataConfig[]} + * @since 3.0.0 + */ + this.data = data; + + /** + * data array doesn't change, so we can cache the length + * + * @name Phaser.Tweens.Tween#totalData + * @type {integer} + * @since 3.0.0 + */ + this.totalData = data.length; + + /** + * An array of references to the target/s this Tween is operating on + * + * @name Phaser.Tweens.Tween#targets + * @type {object[]} + * @since 3.0.0 + */ + this.targets = targets; + + /** + * Cached target total (not necessarily the same as the data total) + * + * @name Phaser.Tweens.Tween#totalTargets + * @type {integer} + * @since 3.0.0 + */ + this.totalTargets = targets.length; + + /** + * If true then duration, delay, etc values are all frame totals. + * + * @name Phaser.Tweens.Tween#useFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useFrames = false; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * + * @name Phaser.Tweens.Tween#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + * + * @name Phaser.Tweens.Tween#loop + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loop = 0; + + /** + * Time in ms/frames before the tween loops. + * + * @name Phaser.Tweens.Tween#loopDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopDelay = 0; + + /** + * How many loops are left to run? + * + * @name Phaser.Tweens.Tween#loopCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopCounter = 0; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) + * + * @name Phaser.Tweens.Tween#completeDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.completeDelay = 0; + + /** + * Countdown timer (used by timeline offset, loopDelay and completeDelay) + * + * @name Phaser.Tweens.Tween#countdown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.countdown = 0; + + /** + * Set only if this Tween is part of a Timeline. + * + * @name Phaser.Tweens.Tween#offset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.offset = 0; + + /** + * Set only if this Tween is part of a Timeline. The calculated offset amount. + * + * @name Phaser.Tweens.Tween#calculatedOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.calculatedOffset = 0; + + /** + * The current state of the tween + * + * @name Phaser.Tweens.Tween#state + * @type {integer} + * @since 3.0.0 + */ + this.state = TWEEN_CONST.PENDING_ADD; + + /** + * The state of the tween when it was paused (used by Resume) + * + * @name Phaser.Tweens.Tween#_pausedState + * @type {integer} + * @private + * @since 3.0.0 + */ + this._pausedState = TWEEN_CONST.PENDING_ADD; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + * + * @name Phaser.Tweens.Tween#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * Elapsed time in ms/frames of this run through the Tween. + * + * @name Phaser.Tweens.Tween#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalElapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalElapsed = 0; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + * + * @name Phaser.Tweens.Tween#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + * + * @name Phaser.Tweens.Tween#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Time in ms/frames for the Tween to complete (including looping) + * + * @name Phaser.Tweens.Tween#totalDuration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalDuration = 0; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalProgress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalProgress = 0; + + /** + * An object containing the various Tween callback references. + * + * @name Phaser.Tweens.Tween#callbacks + * @type {object} + * @default 0 + * @since 3.0.0 + */ + this.callbacks = { + onComplete: null, + onLoop: null, + onRepeat: null, + onStart: null, + onUpdate: null, + onYoyo: null + }; + + this.callbackScope; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getValue + * @since 3.0.0 + * + * @return {number} [description] + */ + getValue: function () + { + return this.data[0].current; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setTimeScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getTimeScale: function () + { + return this.timeScale; + }, + + /** + * Checks if the Tween is currently active. + * + * @method Phaser.Tweens.Tween#isPlaying + * @since 3.0.0 + * + * @return {boolean} `true` if the Tween is active, otherwise `false`. + */ + isPlaying: function () + { + return (this.state === TWEEN_CONST.ACTIVE); + }, + + /** + * Checks if the Tween is currently paused. + * + * @method Phaser.Tweens.Tween#isPaused + * @since 3.0.0 + * + * @return {boolean} `true` if the Tween is paused, otherwise `false`. + */ + isPaused: function () + { + return (this.state === TWEEN_CONST.PAUSED); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#hasTarget + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + hasTarget: function (target) + { + return (this.targets.indexOf(target) !== -1); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTo + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} value - [description] + * @param {boolean} startToCurrent - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + updateTo: function (key, value, startToCurrent) + { + for (var i = 0; i < this.totalData; i++) + { + var tweenData = this.data[i]; + + if (tweenData.key === key) + { + tweenData.end = value; + + if (startToCurrent) + { + tweenData.start = tweenData.current; + } + + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#restart + * @since 3.0.0 + */ + restart: function () + { + if (this.state === TWEEN_CONST.REMOVED) + { + this.seek(0); + this.parent.makeActive(this); + } + else + { + this.stop(); + this.play(); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#calcDuration + * @since 3.0.0 + */ + calcDuration: function () + { + var max = 0; + + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + // Set t1 (duration + hold + yoyo) + tweenData.t1 = tweenData.duration + tweenData.hold; + + if (tweenData.yoyo) + { + tweenData.t1 += tweenData.duration; + } + + // Set t2 (repeatDelay + duration + hold + yoyo) + tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; + + // Total Duration + tweenData.totalDuration = tweenData.delay + tweenData.t1; + + if (tweenData.repeat === -1) + { + tweenData.totalDuration += (tweenData.t2 * 999999999999); + } + else if (tweenData.repeat > 0) + { + tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); + } + + if (tweenData.totalDuration > max) + { + // Get the longest TweenData from the Tween, used to calculate the Tween TD + max = tweenData.totalDuration; + } + } + + // Excludes loop values + this.duration = max; + + this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; + + if (this.loopCounter > 0) + { + this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); + } + else + { + this.totalDuration = this.duration + this.completeDelay; + } + }, + + /** + * Called by TweenManager.preUpdate as part of its loop to check pending and active tweens. + * Should not be called directly. + * + * @method Phaser.Tweens.Tween#init + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. + */ + init: function () + { + var data = this.data; + var totalTargets = this.totalTargets; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + var target = tweenData.target; + var gen = tweenData.gen; + + tweenData.delay = gen.delay(i, totalTargets, target); + tweenData.duration = gen.duration(i, totalTargets, target); + tweenData.hold = gen.hold(i, totalTargets, target); + tweenData.repeat = gen.repeat(i, totalTargets, target); + tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); + } + + this.calcDuration(); + + this.progress = 0; + this.totalProgress = 0; + this.elapsed = 0; + this.totalElapsed = 0; + + // You can't have a paused Tween if it's part of a Timeline + if (this.paused && !this.parentIsTimeline) + { + this.state = TWEEN_CONST.PENDING_ADD; + this._pausedState = TWEEN_CONST.INIT; + + return false; + } + else + { + this.state = TWEEN_CONST.INIT; + + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#nextState + * @since 3.0.0 + */ + nextState: function () + { + if (this.loopCounter > 0) + { + this.elapsed = 0; + this.progress = 0; + this.loopCounter--; + + var onLoop = this.callbacks.onLoop; + + if (onLoop) + { + onLoop.params[1] = this.targets; + + onLoop.func.apply(onLoop.scope, onLoop.params); + } + + this.resetTweenData(true); + + if (this.loopDelay > 0) + { + this.countdown = this.loopDelay; + this.state = TWEEN_CONST.LOOP_DELAY; + } + else + { + this.state = TWEEN_CONST.ACTIVE; + } + } + else if (this.completeDelay > 0) + { + this.countdown = this.completeDelay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#pause + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + pause: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + this.paused = true; + + this._pausedState = this.state; + + this.state = TWEEN_CONST.PAUSED; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#play + * @since 3.0.0 + * + * @param {boolean} resetFromTimeline - [description] + */ + play: function (resetFromTimeline) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + return; + } + else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) + { + this.init(); + this.parent.makeActive(this); + resetFromTimeline = true; + } + + var onStart = this.callbacks.onStart; + + if (this.parentIsTimeline) + { + this.resetTweenData(resetFromTimeline); + + if (this.calculatedOffset === 0) + { + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + else + { + this.countdown = this.calculatedOffset; + + this.state = TWEEN_CONST.OFFSET_DELAY; + } + } + else if (this.paused) + { + this.paused = false; + + this.parent.makeActive(this); + } + else + { + this.resetTweenData(resetFromTimeline); + + this.state = TWEEN_CONST.ACTIVE; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.parent.makeActive(this); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#resetTweenData + * @since 3.0.0 + * + * @param {boolean} resetFromLoop - [description] + */ + resetTweenData: function (resetFromLoop) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + tweenData.progress = 0; + tweenData.elapsed = 0; + + tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; + + if (resetFromLoop) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); + + tweenData.current = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else if (tweenData.delay > 0) + { + tweenData.elapsed = tweenData.delay; + tweenData.state = TWEEN_CONST.DELAY; + } + else + { + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + } + }, + + /** + * Resumes the playback of a previously paused Tween. + * + * @method Phaser.Tweens.Tween#resume + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + resume: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + this.paused = false; + + this.state = this._pausedState; + } + else + { + this.play(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#seek + * @since 3.0.0 + * + * @param {number} toPosition - A value between 0 and 1. + */ + seek: function (toPosition) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + // This won't work with loop > 0 yet + var ms = this.totalDuration * toPosition; + + var tweenData = data[i]; + var progress = 0; + var elapsed = 0; + + if (ms <= tweenData.delay) + { + progress = 0; + elapsed = 0; + } + else if (ms >= tweenData.totalDuration) + { + progress = 1; + elapsed = tweenData.duration; + } + else if (ms > tweenData.delay && ms <= tweenData.t1) + { + // Keep it zero bound + ms = Math.max(0, ms - tweenData.delay); + + // Somewhere in the first playthru range + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + else if (ms > tweenData.t1 && ms < tweenData.totalDuration) + { + // Somewhere in repeat land + ms -= tweenData.delay; + ms -= tweenData.t1; + + // var repeats = Math.floor(ms / tweenData.t2); + + // remainder + ms = ((ms / tweenData.t2) % 1) * tweenData.t2; + + if (ms > tweenData.repeatDelay) + { + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + } + + tweenData.progress = progress; + tweenData.elapsed = elapsed; + + var v = tweenData.ease(tweenData.progress); + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); + + // if (tweenData.current === 0) + // { + // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); + // } + + tweenData.target[tweenData.key] = tweenData.current; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setCallback + * @since 3.0.0 + * + * @param {string} type - [description] + * @param {function} callback - [description] + * @param {array} [params] - [description] + * @param {object} [scope] - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setCallback: function (type, callback, params, scope) + { + this.callbacks[type] = { func: callback, scope: scope, params: params }; + + return this; + }, + + /** + * Flags the Tween as being complete, whatever stage of progress it is at. + * + * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` + * argument is provided, in which case the Tween will delay for that period of time before calling the callback. + * + * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. + * + * @method Phaser.Tweens.Tween#complete + * @since 3.2.0 + * + * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. + */ + complete: function (delay) + { + if (delay === undefined) { delay = 0; } + + if (delay) + { + this.countdown = delay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + * + * @method Phaser.Tweens.Tween#stop + * @since 3.0.0 + * + * @param {number} [resetTo] - A value between 0 and 1. + */ + stop: function (resetTo) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + if (resetTo !== undefined) + { + this.seek(resetTo); + } + } + + if (this.state !== TWEEN_CONST.REMOVED) + { + if (this.state === TWEEN_CONST.PAUSED || this.state === TWEEN_CONST.PENDING_ADD) + { + this.parent._destroy.push(this); + this.parent._toProcess++; + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + * + * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. + */ + update: function (timestamp, delta) + { + if (this.state === TWEEN_CONST.PAUSED) + { + return false; + } + + if (this.useFrames) + { + delta = 1 * this.parent.timeScale; + } + + delta *= this.timeScale; + + this.elapsed += delta; + this.progress = Math.min(this.elapsed / this.duration, 1); + + this.totalElapsed += delta; + this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); + + switch (this.state) + { + case TWEEN_CONST.ACTIVE: + + var stillRunning = false; + + for (var i = 0; i < this.totalData; i++) + { + if (this.updateTweenData(this, this.data[i], delta)) + { + stillRunning = true; + } + } + + // Anything still running? If not, we're done + if (!stillRunning) + { + this.nextState(); + } + + break; + + case TWEEN_CONST.LOOP_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.OFFSET_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onStart = this.callbacks.onStart; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.COMPLETE_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + + break; + } + + return (this.state === TWEEN_CONST.PENDING_REMOVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setStateFromEnd + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromEnd: function (tween, tweenData, diff) + { + if (tweenData.yoyo) + { + // We've hit the end of a Playing Forward TweenData and we have a yoyo + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. + // If you're tweening several properties it can fire for all of them, at once. + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onYoyo = tween.callbacks.onYoyo; + + if (onYoyo) + { + // Element 1 is reserved for the target of the yoyo (and needs setting here) + onYoyo.params[1] = tweenData.target; + + onYoyo.func.apply(onYoyo.scope, onYoyo.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + return TWEEN_CONST.PLAYING_BACKWARD; + } + else if (tweenData.repeatCounter > 0) + { + // We've hit the end of a Playing Forward TweenData and we have a Repeat. + // So we're going to go right back to the start to repeat it again. + + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + /** + * Was PLAYING_BACKWARD and has hit the start. + * + * @method Phaser.Tweens.Tween#setStateFromStart + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromStart: function (tween, tweenData, diff) + { + if (tweenData.repeatCounter > 0) + { + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + // + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTweenData + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true + * + * @return {boolean} [description] + */ + updateTweenData: function (tween, tweenData, delta) + { + switch (tweenData.state) + { + case TWEEN_CONST.PLAYING_FORWARD: + case TWEEN_CONST.PLAYING_BACKWARD: + + if (!tweenData.target) + { + tweenData.state = TWEEN_CONST.COMPLETE; + break; + } + + var elapsed = tweenData.elapsed; + var duration = tweenData.duration; + var diff = 0; + + elapsed += delta; + + if (elapsed > duration) + { + diff = elapsed - duration; + elapsed = duration; + } + + var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); + var progress = elapsed / duration; + + var v; + + if (forward) + { + v = tweenData.ease(progress); + } + else + { + v = tweenData.ease(1 - progress); + } + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + tweenData.target[tweenData.key] = tweenData.current; + + tweenData.elapsed = elapsed; + tweenData.progress = progress; + + var onUpdate = tween.callbacks.onUpdate; + + if (onUpdate) + { + onUpdate.params[1] = tweenData.target; + + onUpdate.func.apply(onUpdate.scope, onUpdate.params); + } + + if (progress === 1) + { + if (forward) + { + if (tweenData.hold > 0) + { + tweenData.elapsed = tweenData.hold - diff; + + tweenData.state = TWEEN_CONST.HOLD_DELAY; + } + else + { + tweenData.state = this.setStateFromEnd(tween, tweenData, diff); + } + } + else + { + tweenData.state = this.setStateFromStart(tween, tweenData, diff); + } + } + + break; + + case TWEEN_CONST.DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + + break; + + case TWEEN_CONST.REPEAT_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + + break; + + case TWEEN_CONST.HOLD_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); + } + + break; + + case TWEEN_CONST.PENDING_RENDER: + + if (tweenData.target) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else + { + tweenData.state = TWEEN_CONST.COMPLETE; + } + + break; + } + + // Return TRUE if this TweenData still playing, otherwise return FALSE + return (tweenData.state !== TWEEN_CONST.COMPLETE); + } + +}); + +Tween.TYPES = [ + 'onComplete', + 'onLoop', + 'onRepeat', + 'onStart', + 'onUpdate', + 'onYoyo' +]; + +/** + * Creates a new Tween object. + * + * Note: This method will only be available Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectFactory.register('tween', function (config) +{ + return this.scene.sys.tweens.add(config); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +/** + * Creates a new Tween object and returns it. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectCreator.register('tween', function (config) +{ + return this.scene.sys.tweens.create(config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + +module.exports = Tween; + + +/***/ }), +/* 129 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} Phaser.Tweens.TweenConfigDefaults + * + * @property {(object|object[])} targets - The object, or an array of objects, to run the tween on. + * @property {number} [delay=0] - The number of milliseconds to delay before the tween will start. + * @property {number} [duration=1000] - The duration of the tween in milliseconds. + * @property {string} [ease='Power0'] - The easing equation to use for the tween. + * @property {array} [easeParams] - Optional easing parameters. + * @property {number} [hold=0] - The number of milliseconds to hold the tween for before yoyo'ing. + * @property {number} [repeat=0] - The number of times to repeat the tween. + * @property {number} [repeatDelay=0] - The number of milliseconds to pause before a tween will repeat. + * @property {boolean} [yoyo=false] - Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete. + * @property {boolean} [flipX=false] - Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property. + * @property {boolean} [flipY=false] - Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property. + */ + +var TWEEN_DEFAULTS = { + targets: null, + delay: 0, + duration: 1000, + ease: 'Power0', + easeParams: null, + hold: 0, + repeat: 0, + repeatDelay: 0, + yoyo: false, + flipX: false, + flipY: false +}; + +module.exports = TWEEN_DEFAULTS; + + +/***/ }), +/* 130 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function hasGetStart (def) +{ + return (!!def.getStart && typeof def.getStart === 'function'); +} + +function hasGetEnd (def) +{ + return (!!def.getEnd && typeof def.getEnd === 'function'); +} + +function hasGetters (def) +{ + return hasGetStart(def) || hasGetEnd(def); +} + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetValueOp + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} propertyValue - [description] + * + * @return {function} [description] + */ +var GetValueOp = function (key, propertyValue) +{ + var callbacks; + + // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) + var getEnd = function (target, key, value) { return value; }; + + // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) + var getStart = function (target, key, value) { return value; }; + + var t = typeof(propertyValue); + + if (t === 'number') + { + // props: { + // x: 400, + // y: 300 + // } + + getEnd = function () + { + return propertyValue; + }; + } + else if (t === 'string') + { + // props: { + // x: '+=400', + // y: '-=300', + // z: '*=2', + // w: '/=2' + // } + + var op = propertyValue[0]; + var num = parseFloat(propertyValue.substr(2)); + + switch (op) + { + case '+': + getEnd = function (target, key, value) + { + return value + num; + }; + break; + + case '-': + getEnd = function (target, key, value) + { + return value - num; + }; + break; + + case '*': + getEnd = function (target, key, value) + { + return value * num; + }; + break; + + case '/': + getEnd = function (target, key, value) + { + return value / num; + }; + break; + + default: + getEnd = function () + { + return parseFloat(propertyValue); + }; + } + } + else if (t === 'function') + { + // The same as setting just the getEnd function and no getStart + + // props: { + // x: function (target, key, value) { return value + 50); }, + // } + + getEnd = propertyValue; + } + else if (t === 'object' && hasGetters(propertyValue)) + { + /* + x: { + // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. + getEnd: function (target, key, value) + { + return value; + }, + + // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. + getStart: function (target, key, value) + { + return value; + } + } + */ + + if (hasGetEnd(propertyValue)) + { + getEnd = propertyValue.getEnd; + } + + if (hasGetStart(propertyValue)) + { + getStart = propertyValue.getStart; + } + } + else if (propertyValue.hasOwnProperty('value')) + { + // Value may still be a string, function or a number + // props: { + // x: { value: 400, ... }, + // y: { value: 300, ... } + // } + + callbacks = GetValueOp(key, propertyValue.value); + } + + // If callback not set by the else if block above then set it here and return it + if (!callbacks) + { + callbacks = { + getEnd: getEnd, + getStart: getStart + }; + } + + return callbacks; +}; + +module.exports = GetValueOp; + + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetTargets + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {array} [description] + */ +var GetTargets = function (config) +{ + var targets = GetValue(config, 'targets', null); + + if (targets === null) + { + return targets; + } + + if (typeof targets === 'function') + { + targets = targets.call(); + } + + if (!Array.isArray(targets)) + { + targets = [ targets ]; + } + + return targets; +}; + +module.exports = GetTargets; + + +/***/ }), +/* 132 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var MapData = __webpack_require__(77); +var Parse = __webpack_require__(217); +var Tilemap = __webpack_require__(209); + +/** + * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When + * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from + * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For + * an empty map, you should specify tileWidth, tileHeight, width & height. + * + * @function Phaser.Tilemaps.ParseToTilemap + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. + * @param {integer} [width=10] - The width of the map in tiles. + * @param {integer} [height=10] - The height of the map in tiles. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} + */ +var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull) +{ + if (tileWidth === undefined) { tileWidth = 32; } + if (tileHeight === undefined) { tileHeight = 32; } + if (width === undefined) { width = 10; } + if (height === undefined) { height = 10; } + if (insertNull === undefined) { insertNull = false; } + + var mapData = null; + + if (Array.isArray(data)) + { + var name = key !== undefined ? key : 'map'; + mapData = Parse(name, Formats.ARRAY_2D, data, tileWidth, tileHeight, insertNull); + } + else if (key !== undefined) + { + var tilemapData = scene.cache.tilemap.get(key); + + if (!tilemapData) + { + console.warn('No map data found for key ' + key); + } + else + { + mapData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull); + } + } + + if (mapData === null) + { + mapData = new MapData({ + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + } + + return new Tilemap(scene, mapData); +}; + +module.exports = ParseToTilemap; + + +/***/ }), +/* 133 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var LayerData = __webpack_require__(78); +var MapData = __webpack_require__(77); +var Tile = __webpack_require__(55); + +/** + * Parses a 2D array of tile indexes into a new MapData object with a single layer. + * + * @function Phaser.Tilemaps.Parsers.Parse2DArray + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer[][]} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.MapData} [description] + */ +var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull) +{ + var layerData = new LayerData({ + tileWidth: tileWidth, + tileHeight: tileHeight + }); + + var mapData = new MapData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + format: Formats.ARRAY_2D, + layers: [ layerData ] + }); + + var tiles = []; + var height = data.length; + var width = 0; + + for (var y = 0; y < data.length; y++) + { + tiles[y] = []; + var row = data[y]; + + for (var x = 0; x < row.length; x++) + { + var tileIndex = parseInt(row[x], 10); + + if (isNaN(tileIndex) || tileIndex === -1) + { + tiles[y][x] = insertNull + ? null + : new Tile(layerData, -1, x, y, tileWidth, tileHeight); + } + else + { + tiles[y][x] = new Tile(layerData, tileIndex, x, y, tileWidth, tileHeight); + } + } + + if (width === 0) + { + width = row.length; + } + } + + mapData.width = layerData.width = width; + mapData.height = layerData.height = height; + mapData.widthInPixels = layerData.widthInPixels = width * tileWidth; + mapData.heightInPixels = layerData.heightInPixels = height * tileHeight; + layerData.data = tiles; + + return mapData; +}; + +module.exports = Parse2DArray; + + +/***/ }), +/* 134 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internally used method to keep track of the tile indexes that collide within a layer. This + * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. + * + * @function Phaser.Tilemaps.Components.SetLayerCollisionIndex + * @private + * @since 3.0.0 + * + * @param {integer} tileIndex - The tile index to set the collision boolean for. + * @param {boolean} [collides=true] - Should the tile index collide or not? + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetLayerCollisionIndex = function (tileIndex, collides, layer) +{ + var loc = layer.collideIndexes.indexOf(tileIndex); + + if (collides && loc === -1) + { + layer.collideIndexes.push(tileIndex); + } + else if (!collides && loc !== -1) + { + layer.collideIndexes.splice(loc, 1); + } +}; + +module.exports = SetLayerCollisionIndex; + + +/***/ }), +/* 135 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tile = __webpack_require__(55); +var IsInLayerBounds = __webpack_require__(79); +var CalculateFacesAt = __webpack_require__(136); +var SetTileCollision = __webpack_require__(56); + +/** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * @function Phaser.Tilemaps.Components.PutTileAt + * @private + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + */ +var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) +{ + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var oldTile = layer.data[tileY][tileX]; + var oldTileCollides = oldTile && oldTile.collides; + + if (tile instanceof Tile) + { + if (layer.data[tileY][tileX] === null) + { + layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); + } + layer.data[tileY][tileX].copy(tile); + } + else + { + var index = tile; + if (layer.data[tileY][tileX] === null) + { + layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight); + } + else + { + layer.data[tileY][tileX].index = index; + } + } + + // Updating colliding flag on the new tile + var newTile = layer.data[tileY][tileX]; + var collides = layer.collideIndexes.indexOf(newTile.index) !== -1; + SetTileCollision(newTile, collides); + + // Recalculate faces only if the colliding flag at (tileX, tileY) has changed + if (recalculateFaces && (oldTileCollides !== newTile.collides)) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return newTile; +}; + +module.exports = PutTileAt; + + + +/***/ }), +/* 136 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(102); + +/** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @function Phaser.Tilemaps.Components.CalculateFacesAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var CalculateFacesAt = function (tileX, tileY, layer) +{ + var tile = GetTileAt(tileX, tileY, true, layer); + var above = GetTileAt(tileX, tileY - 1, true, layer); + var below = GetTileAt(tileX, tileY + 1, true, layer); + var left = GetTileAt(tileX - 1, tileY, true, layer); + var right = GetTileAt(tileX + 1, tileY, true, layer); + var tileCollides = tile && tile.collides; + + // Assume the changed tile has all interesting edges + if (tileCollides) + { + tile.faceTop = true; + tile.faceBottom = true; + tile.faceLeft = true; + tile.faceRight = true; + } + + // Reset edges that are shared between tile and its neighbors + if (above && above.collides) + { + if (tileCollides) { tile.faceTop = false; } + above.faceBottom = !tileCollides; + } + + if (below && below.collides) + { + if (tileCollides) { tile.faceBottom = false; } + below.faceTop = !tileCollides; + } + + if (left && left.collides) + { + if (tileCollides) { tile.faceLeft = false; } + left.faceRight = !tileCollides; + } + + if (right && right.collides) + { + if (tileCollides) { tile.faceRight = false; } + right.faceLeft = !tileCollides; + } + + if (tile && !tile.collides) { tile.resetFaces(); } + + return tile; +}; + +module.exports = CalculateFacesAt; + + +/***/ }), +/* 137 */, +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A representation of a vector in 3D space. + * + * A three-component vector. + * + * @class Vector3 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + */ +var Vector3 = new Class({ + + initialize: + + function Vector3 (x, y, z) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector3#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector3#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector3#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.z = 0; + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + }, + + /** + * Set this Vector to point up. + * + * Sets the y component of the vector to 1, and the others to 0. + * + * @method Phaser.Math.Vector3#up + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + up: function () + { + this.x = 0; + this.y = 1; + this.z = 0; + + return this; + }, + + /** + * Make a clone of this Vector3. + * + * @method Phaser.Math.Vector3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} A new Vector3 object containing this Vectors values. + */ + clone: function () + { + return new Vector3(this.x, this.y, this.z); + }, + + /** + * Calculate the cross (vector) product of two given Vectors. + * + * @method Phaser.Math.Vector3#crossVectors + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - The first Vector to multiply. + * @param {Phaser.Math.Vector3} b - The second Vector to multiply. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + crossVectors: function (a, b) + { + var ax = a.x; + var ay = a.y; + var az = a.z; + var bx = b.x; + var by = b.y; + var bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict equality check against each Vector's components. + * + * @method Phaser.Math.Vector3#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to compare against. + * + * @return {boolean} True if the two vectors strictly match, otherwise false. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); + }, + + /** + * Copy the components of a given Vector into this Vector. + * + * @method Phaser.Math.Vector3#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + + return this; + }, + + /** + * Set the `x`, `y`, and `z` components of this Vector to the given `x`, `y`, and `z` values. + * + * @method Phaser.Math.Vector3#set + * @since 3.0.0 + * + * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y and z components. + * @param {number} [y] - The y value to set for this Vector. + * @param {number} [z] - The z value to set for this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + set: function (x, y, z) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + + return this; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector3#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector3#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector3#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector3#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + scale: function (scale) + { + if (isFinite(scale)) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + } + else + { + this.x = 0; + this.y = 0; + this.z = 0; + } + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector3#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + + return this; + }, + + /** + * Negate the `x`, `y` and `z` components of this Vector. + * + * @method Phaser.Math.Vector3#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector3#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector3#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return dx * dx + dy * dy + dz * dz; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector3#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return Math.sqrt(x * x + y * y + z * z); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector3#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return x * x + y * y + z * z; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector3#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var len = x * x + y * y + z * z; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector3#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to dot product with this Vector3. + * + * @return {number} The dot product of this Vector and `v`. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z; + }, + + /** + * Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector. + * + * @method Phaser.Math.Vector3#cross + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector to cross product with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + cross: function (v) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var bx = v.x; + var by = v.y; + var bz = v.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector3#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector3#transformMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformMat3: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = x * m[0] + y * m[3] + z * m[6]; + this.y = x * m[1] + y * m[4] + z * m[7]; + this.z = x * m[2] + y * m[5] + z * m[8]; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector3#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformCoordinates + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformCoordinates: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; + var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; + var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; + var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; + + this.x = tx / tw; + this.y = ty / tw; + this.z = tz / tw; + + return this; + }, + + /** + * Transform this Vector with the given Quaternion. + * + * @method Phaser.Math.Vector3#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformQuat: function (q) + { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, + * e.g. unprojecting a 2D point into 3D space. + * + * @method Phaser.Math.Vector3#project + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to multiply this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + project: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var a00 = m[0]; + var a01 = m[1]; + var a02 = m[2]; + var a03 = m[3]; + var a10 = m[4]; + var a11 = m[5]; + var a12 = m[6]; + var a13 = m[7]; + var a20 = m[8]; + var a21 = m[9]; + var a22 = m[10]; + var a23 = m[11]; + var a30 = m[12]; + var a31 = m[13]; + var a32 = m[14]; + var a33 = m[15]; + + var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); + + this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; + this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; + this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; + + return this; + }, + + /** + * Unproject this point from 2D space to 3D space. + * The point should have its x and y properties set to + * 2D screen space, and the z either at 0 (near plane) + * or 1 (far plane). The provided matrix is assumed to already + * be combined, i.e. projection * view * model. + * + * After this operation, this vector's (x, y, z) components will + * represent the unprojected 3D coordinate. + * + * @method Phaser.Math.Vector3#unproject + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} viewport - Screen x, y, width and height in pixels. + * @param {Phaser.Math.Matrix4} invProjectionView - Combined projection and view matrix. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + unproject: function (viewport, invProjectionView) + { + var viewX = viewport.x; + var viewY = viewport.y; + var viewWidth = viewport.z; + var viewHeight = viewport.w; + + var x = this.x - viewX; + var y = (viewHeight - this.y - 1) - viewY; + var z = this.z; + + this.x = (2 * x) / viewWidth - 1; + this.y = (2 * y) / viewHeight - 1; + this.z = 2 * z - 1; + + return this.project(invProjectionView); + }, + + /** + * Make this Vector the zero vector (0, 0, 0). + * + * @method Phaser.Math.Vector3#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + + return this; + } + +}); + +/* +Vector3.Zero = function () +{ + return new Vector3(0, 0, 0); +}; + +Vector3.Up = function () +{ + return new Vector3(0, 1.0, 0); +}; + +Vector3.Copy = function (source) +{ + return new Vector3(source.x, source.y, source.z); +}; + +Vector3.TransformCoordinates = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; + var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; + + return new Vector3(x / w, y / w, z / w); +}; + +Vector3.TransformNormal = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); + + return new Vector3(x, y, z); +}; + +Vector3.Dot = function (left, right) +{ + return (left.x * right.x + left.y * right.y + left.z * right.z); +}; + +Vector3.Cross = function (left, right) +{ + var x = left.y * right.z - left.z * right.y; + var y = left.z * right.x - left.x * right.z; + var z = left.x * right.y - left.y * right.x; + + return new Vector3(x, y, z); +}; + +Vector3.Normalize = function (vector) +{ + var newVector = Vector3.Copy(vector); + newVector.normalize(); + + return newVector; +}; + +Vector3.Distance = function (value1, value2) +{ + return Math.sqrt(Vector3.DistanceSquared(value1, value2)); +}; + +Vector3.DistanceSquared = function (value1, value2) +{ + var x = value1.x - value2.x; + var y = value1.y - value2.y; + var z = value1.z - value2.z; + + return (x * x) + (y * y) + (z * z); +}; +*/ + +module.exports = Vector3; + + +/***/ }), +/* 139 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); +var ParseXML = __webpack_require__(343); + +/** + * @typedef {object} Phaser.Loader.FileTypes.XMLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='xml'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single XML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. + * + * @class XMLFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var XMLFile = new Class({ + + Extends: File, + + initialize: + + function XMLFile (loader, key, url, xhrSettings) + { + var extension = 'xml'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'xml', + cache: loader.cacheManager.xml, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.XMLFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = ParseXML(this.xhrLoader.responseText); + + if (this.data) + { + this.onProcessComplete(); + } + else + { + console.warn('Invalid XMLFile: ' + this.key); + + this.onProcessError(); + } + } + +}); + +/** + * Adds an XML file, or array of XML files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.xml('wavedata', 'files/AlienWaveData.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global XML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the XML Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the XML Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.xml({ + * key: 'wavedata', + * url: 'files/AlienWaveData.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.XMLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.xml('wavedata', 'files/AlienWaveData.xml'); + * // and later in your game ... + * var data = this.cache.xml.get('wavedata'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the XML Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the XML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#xml + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig|Phaser.Loader.FileTypes.XMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('xml', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new XMLFile(this, key[i])); + } + } + else + { + this.addFile(new XMLFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = XMLFile; + + +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(20); +var XHRSettings = __webpack_require__(105); + +/** + * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * + * The new object is seeded by the values given in the global settings, but any setting in + * the local object overrides the global ones. + * + * @function Phaser.Loader.MergeXHRSettings + * @since 3.0.0 + * + * @param {XHRSettingsObject} global - The global XHRSettings object. + * @param {XHRSettingsObject} local - The local XHRSettings object. + * + * @return {XHRSettingsObject} A newly formed XHRSettings object. + */ +var MergeXHRSettings = function (global, local) +{ + var output = (global === undefined) ? XHRSettings() : Extend({}, global); + + if (local) + { + for (var setting in local) + { + if (local[setting] !== undefined) + { + output[setting] = local[setting]; + } + } + } + + return output; +}; + +module.exports = MergeXHRSettings; + + +/***/ }), +/* 141 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given a File and a baseURL value this returns the URL the File will use to download from. + * + * @function Phaser.Loader.GetURL + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File object. + * @param {string} baseURL - A default base URL. + * + * @return {string} The URL the File will use. + */ +var GetURL = function (file, baseURL) +{ + if (!file.url) + { + return false; + } + + if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) + { + return file.url; + } + else + { + return baseURL + file.url; + } +}; + +module.exports = GetURL; + + +/***/ }), +/* 142 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Snap a value to nearest grid slice, using floor. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10`. + * As will `14` snap to `10`... but `16` will snap to `15`. + * + * @function Phaser.Math.Snap.Floor + * @since 3.0.0 + * + * @param {number} value - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. + * + * @return {number} The snapped value. + */ +var SnapFloor = function (value, gap, start, divide) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.floor(value / gap); + + return (divide) ? (start + value) / gap : start + value; +}; + +module.exports = SnapFloor; + + +/***/ }), +/* 143 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Keyboard Codes. + * + * @name Phaser.Input.Keyboard.KeyCodes + * @enum {integer} + * @memberof Phaser.Input.Keyboard + * @readonly + * @since 3.0.0 + */ + +var KeyCodes = { + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACKSPACE + */ + BACKSPACE: 8, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.TAB + */ + TAB: 9, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ENTER + */ + ENTER: 13, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SHIFT + */ + SHIFT: 16, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CTRL + */ + CTRL: 17, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ALT + */ + ALT: 18, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAUSE + */ + PAUSE: 19, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CAPS_LOCK + */ + CAPS_LOCK: 20, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ESC + */ + ESC: 27, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SPACE + */ + SPACE: 32, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_UP + */ + PAGE_UP: 33, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_DOWN + */ + PAGE_DOWN: 34, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.END + */ + END: 35, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.HOME + */ + HOME: 36, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.LEFT + */ + LEFT: 37, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.UP + */ + UP: 38, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.RIGHT + */ + RIGHT: 39, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.DOWN + */ + DOWN: 40, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PRINT_SCREEN + */ + PRINT_SCREEN: 42, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.INSERT + */ + INSERT: 45, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.DELETE + */ + DELETE: 46, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ZERO + */ + ZERO: 48, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ONE + */ + ONE: 49, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.TWO + */ + TWO: 50, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.THREE + */ + THREE: 51, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FOUR + */ + FOUR: 52, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FIVE + */ + FIVE: 53, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SIX + */ + SIX: 54, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SEVEN + */ + SEVEN: 55, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.EIGHT + */ + EIGHT: 56, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NINE + */ + NINE: 57, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ZERO + */ + NUMPAD_ZERO: 96, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ONE + */ + NUMPAD_ONE: 97, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_TWO + */ + NUMPAD_TWO: 98, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_THREE + */ + NUMPAD_THREE: 99, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FOUR + */ + NUMPAD_FOUR: 100, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FIVE + */ + NUMPAD_FIVE: 101, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SIX + */ + NUMPAD_SIX: 102, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SEVEN + */ + NUMPAD_SEVEN: 103, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_EIGHT + */ + NUMPAD_EIGHT: 104, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_NINE + */ + NUMPAD_NINE: 105, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.A + */ + A: 65, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.B + */ + B: 66, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.C + */ + C: 67, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.D + */ + D: 68, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.E + */ + E: 69, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F + */ + F: 70, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.G + */ + G: 71, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.H + */ + H: 72, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.I + */ + I: 73, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.J + */ + J: 74, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.K + */ + K: 75, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.L + */ + L: 76, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.M + */ + M: 77, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.N + */ + N: 78, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.O + */ + O: 79, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.P + */ + P: 80, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Q + */ + Q: 81, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.R + */ + R: 82, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.S + */ + S: 83, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.T + */ + T: 84, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.U + */ + U: 85, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.V + */ + V: 86, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.W + */ + W: 87, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.X + */ + X: 88, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Y + */ + Y: 89, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Z + */ + Z: 90, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F1 + */ + F1: 112, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F2 + */ + F2: 113, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F3 + */ + F3: 114, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F4 + */ + F4: 115, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F5 + */ + F5: 116, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F6 + */ + F6: 117, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F7 + */ + F7: 118, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F8 + */ + F8: 119, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F9 + */ + F9: 120, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F10 + */ + F10: 121, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F11 + */ + F11: 122, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F12 + */ + F12: 123, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON + */ + SEMICOLON: 186, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PLUS + */ + PLUS: 187, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.COMMA + */ + COMMA: 188, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.MINUS + */ + MINUS: 189, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PERIOD + */ + PERIOD: 190, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FORWARD_SLASH + */ + FORWARD_SLASH: 191, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACK_SLASH + */ + BACK_SLASH: 220, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.QUOTES + */ + QUOTES: 222, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACKTICK + */ + BACKTICK: 192, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.OPEN_BRACKET + */ + OPEN_BRACKET: 219, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET + */ + CLOSED_BRACKET: 221 + +}; + +module.exports = KeyCodes; + + +/***/ }), +/* 144 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.RotateAroundXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var RotateAroundXY = function (triangle, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = triangle.x1 - x; + var ty = triangle.y1 - y; + + triangle.x1 = tx * c - ty * s + x; + triangle.y1 = tx * s + ty * c + y; + + tx = triangle.x2 - x; + ty = triangle.y2 - y; + + triangle.x2 = tx * c - ty * s + x; + triangle.y2 = tx * s + ty * c + y; + + tx = triangle.x3 - x; + ty = triangle.y3 - y; + + triangle.x3 = tx * c - ty * s + x; + triangle.y3 = tx * s + ty * c + y; + + return triangle; +}; + +module.exports = RotateAroundXY; + + +/***/ }), +/* 145 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.GetAspectRatio + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var GetAspectRatio = function (rect) +{ + return (rect.height === 0) ? NaN : rect.width / rect.height; +}; + +module.exports = GetAspectRatio; + + +/***/ }), +/* 146 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rotate a line around the given coordinates by the given angle in radians. + * + * @function Phaser.Geom.Line.RotateAroundXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {number} x - The horizontal coordinate to rotate the line around. + * @param {number} y - The vertical coordinate to rotate the line around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var RotateAroundXY = function (line, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = line.x1 - x; + var ty = line.y1 - y; + + line.x1 = tx * c - ty * s + x; + line.y1 = tx * s + ty * c + y; + + tx = line.x2 - x; + ty = line.y2 - y; + + line.x2 = tx * c - ty * s + x; + line.y2 = tx * s + ty * c + y; + + return line; +}; + +module.exports = RotateAroundXY; + + +/***/ }), +/* 147 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// http://www.blackpawn.com/texts/pointinpoly/ + +// points is an array of Point-like objects with public x/y properties +// returns an array containing all points that are within the triangle, or an empty array if none +// if 'returnFirst' is true it will return after the first point within the triangle is found + +/** + * Filters an array of point-like objects to only those contained within a triangle. + * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). + * + * @function Phaser.Geom.Triangle.ContainsArray + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The triangle that the points are being checked in. + * @param {Phaser.Geom.Point[]} points - An array of point-like objects (objects that have an `x` and `y` property) + * @param {boolean} [returnFirst=false] - If `true`, return an array containing only the first point found that is within the triangle. + * @param {array} [out] - If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. + * + * @return {Phaser.Geom.Point[]} An array containing all the points from `points` that are within the triangle, if an array was provided as `out`, points will be appended to that array and it will also be returned here. + */ +var ContainsArray = function (triangle, points, returnFirst, out) +{ + if (returnFirst === undefined) { returnFirst = false; } + if (out === undefined) { out = []; } + + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot11 = (v1x * v1x) + (v1y * v1y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + + var u; + var v; + var v2x; + var v2y; + var dot02; + var dot12; + + var x1 = triangle.x1; + var y1 = triangle.y1; + + for (var i = 0; i < points.length; i++) + { + v2x = points[i].x - x1; + v2y = points[i].y - y1; + + dot02 = (v0x * v2x) + (v0y * v2y); + dot12 = (v1x * v2x) + (v1y * v2y); + + u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + if (u >= 0 && v >= 0 && (u + v < 1)) + { + out.push({ x: points[i].x, y: points[i].y }); + + if (returnFirst) + { + break; + } + } + } + + return out; +}; + +module.exports = ContainsArray; + + +/***/ }), +/* 148 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var RectangleToRectangle = function (rectA, rectB) +{ + if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) + { + return false; + } + + return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); +}; + +module.exports = RectangleToRectangle; + + +/***/ }), +/* 149 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Mesh = __webpack_require__(108); + +/** + * @classdesc + * A Quad Game Object. + * + * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single + * texture spread across them. + * + * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also + * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. + * + * @class Quad + * @extends Phaser.GameObjects.Mesh + * @memberof Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Quad belongs. + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Quad = new Class({ + + Extends: Mesh, + + initialize: + + function Quad (scene, x, y, texture, frame) + { + // 0----3 + // |\ B| + // | \ | + // | \ | + // | A \| + // | \ + // 1----2 + + var vertices = [ + 0, 0, // tl + 0, 0, // bl + 0, 0, // br + 0, 0, // tl + 0, 0, // br + 0, 0 // tr + ]; + + var uv = [ + 0, 0, // tl + 0, 1, // bl + 1, 1, // br + 0, 0, // tl + 1, 1, // br + 1, 0 // tr + ]; + + var colors = [ + 0xffffff, // tl + 0xffffff, // bl + 0xffffff, // br + 0xffffff, // tl + 0xffffff, // br + 0xffffff // tr + ]; + + var alphas = [ + 1, // tl + 1, // bl + 1, // br + 1, // tl + 1, // br + 1 // tr + ]; + + Mesh.call(this, scene, x, y, vertices, uv, colors, alphas, texture, frame); + + this.resetPosition(); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Quad#setFrame + * @since 3.11.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame) + { + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~8; + } + else + { + this.renderFlags |= 8; + } + + frame = this.frame; + + // TL + this.uv[0] = frame.u0; + this.uv[1] = frame.v0; + + // BL + this.uv[2] = frame.u0; + this.uv[3] = frame.v1; + + // BR + this.uv[4] = frame.u1; + this.uv[5] = frame.v1; + + // TL + this.uv[6] = frame.u0; + this.uv[7] = frame.v0; + + // BR + this.uv[8] = frame.u1; + this.uv[9] = frame.v1; + + // TR + this.uv[10] = frame.u1; + this.uv[11] = frame.v0; + + return this; + }, + + /** + * The top-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftX + * @type {number} + * @since 3.0.0 + */ + topLeftX: { + + get: function () + { + return this.x + this.vertices[0]; + }, + + set: function (value) + { + this.vertices[0] = value - this.x; + this.vertices[6] = value - this.x; + } + + }, + + /** + * The top-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftY + * @type {number} + * @since 3.0.0 + */ + topLeftY: { + + get: function () + { + return this.y + this.vertices[1]; + }, + + set: function (value) + { + this.vertices[1] = value - this.y; + this.vertices[7] = value - this.y; + } + + }, + + /** + * The top-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightX + * @type {number} + * @since 3.0.0 + */ + topRightX: { + + get: function () + { + return this.x + this.vertices[10]; + }, + + set: function (value) + { + this.vertices[10] = value - this.x; + } + + }, + + /** + * The top-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightY + * @type {number} + * @since 3.0.0 + */ + topRightY: { + + get: function () + { + return this.y + this.vertices[11]; + }, + + set: function (value) + { + this.vertices[11] = value - this.y; + } + + }, + + /** + * The bottom-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftX + * @type {number} + * @since 3.0.0 + */ + bottomLeftX: { + + get: function () + { + return this.x + this.vertices[2]; + }, + + set: function (value) + { + this.vertices[2] = value - this.x; + } + + }, + + /** + * The bottom-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftY + * @type {number} + * @since 3.0.0 + */ + bottomLeftY: { + + get: function () + { + return this.y + this.vertices[3]; + }, + + set: function (value) + { + this.vertices[3] = value - this.y; + } + + }, + + /** + * The bottom-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightX + * @type {number} + * @since 3.0.0 + */ + bottomRightX: { + + get: function () + { + return this.x + this.vertices[4]; + }, + + set: function (value) + { + this.vertices[4] = value - this.x; + this.vertices[8] = value - this.x; + } + + }, + + /** + * The bottom-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightY + * @type {number} + * @since 3.0.0 + */ + bottomRightY: { + + get: function () + { + return this.y + this.vertices[5]; + }, + + set: function (value) + { + this.vertices[5] = value - this.y; + this.vertices[9] = value - this.y; + } + + }, + + /** + * The top-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftAlpha + * @type {number} + * @since 3.0.0 + */ + topLeftAlpha: { + + get: function () + { + return this.alphas[0]; + }, + + set: function (value) + { + this.alphas[0] = value; + this.alphas[3] = value; + } + + }, + + /** + * The top-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightAlpha + * @type {number} + * @since 3.0.0 + */ + topRightAlpha: { + + get: function () + { + return this.alphas[5]; + }, + + set: function (value) + { + this.alphas[5] = value; + } + + }, + + /** + * The bottom-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftAlpha + * @type {number} + * @since 3.0.0 + */ + bottomLeftAlpha: { + + get: function () + { + return this.alphas[1]; + }, + + set: function (value) + { + this.alphas[1] = value; + } + + }, + + /** + * The bottom-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightAlpha + * @type {number} + * @since 3.0.0 + */ + bottomRightAlpha: { + + get: function () + { + return this.alphas[2]; + }, + + set: function (value) + { + this.alphas[2] = value; + this.alphas[4] = value; + } + + }, + + /** + * The top-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftColor + * @type {number} + * @since 3.0.0 + */ + topLeftColor: { + + get: function () + { + return this.colors[0]; + }, + + set: function (value) + { + this.colors[0] = value; + this.colors[3] = value; + } + + }, + + /** + * The top-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightColor + * @type {number} + * @since 3.0.0 + */ + topRightColor: { + + get: function () + { + return this.colors[5]; + }, + + set: function (value) + { + this.colors[5] = value; + } + + }, + + /** + * The bottom-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftColor + * @type {number} + * @since 3.0.0 + */ + bottomLeftColor: { + + get: function () + { + return this.colors[1]; + }, + + set: function (value) + { + this.colors[1] = value; + } + + }, + + /** + * The bottom-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightColor + * @type {number} + * @since 3.0.0 + */ + bottomRightColor: { + + get: function () + { + return this.colors[2]; + }, + + set: function (value) + { + this.colors[2] = value; + this.colors[4] = value; + } + + }, + + /** + * Sets the top-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopLeft: function (x, y) + { + this.topLeftX = x; + this.topLeftY = y; + + return this; + }, + + /** + * Sets the top-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopRight: function (x, y) + { + this.topRightX = x; + this.topRightY = y; + + return this; + }, + + /** + * Sets the bottom-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomLeft: function (x, y) + { + this.bottomLeftX = x; + this.bottomLeftY = y; + + return this; + }, + + /** + * Sets the bottom-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomRight: function (x, y) + { + this.bottomRightX = x; + this.bottomRightY = y; + + return this; + }, + + /** + * Resets the positions of the four corner vertices of this Quad. + * + * @method Phaser.GameObjects.Quad#resetPosition + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetPosition: function () + { + var x = this.x; + var y = this.y; + var halfWidth = Math.floor(this.width / 2); + var halfHeight = Math.floor(this.height / 2); + + this.setTopLeft(x - halfWidth, y - halfHeight); + this.setTopRight(x + halfWidth, y - halfHeight); + this.setBottomLeft(x - halfWidth, y + halfHeight); + this.setBottomRight(x + halfWidth, y + halfHeight); + + return this; + }, + + /** + * Resets the alpha values used by this Quad back to 1. + * + * @method Phaser.GameObjects.Quad#resetAlpha + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetAlpha: function () + { + var alphas = this.alphas; + + alphas[0] = 1; + alphas[1] = 1; + alphas[2] = 1; + alphas[3] = 1; + alphas[4] = 1; + alphas[5] = 1; + + return this; + }, + + /** + * Resets the color values used by this Quad back to 0xffffff. + * + * @method Phaser.GameObjects.Quad#resetColors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetColors: function () + { + var colors = this.colors; + + colors[0] = 0xffffff; + colors[1] = 0xffffff; + colors[2] = 0xffffff; + colors[3] = 0xffffff; + colors[4] = 0xffffff; + colors[5] = 0xffffff; + + return this; + }, + + /** + * Resets the position, alpha and color values used by this Quad. + * + * @method Phaser.GameObjects.Quad#reset + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + reset: function () + { + this.resetPosition(); + + this.resetAlpha(); + + return this.resetColors(); + } + +}); + +module.exports = Quad; + + +/***/ }), +/* 150 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Checks whether the x and y coordinates are contained within this polygon. +// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva + +/** + * Checks if a point is within the bounds of a Polygon. + * + * @function Phaser.Geom.Polygon.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to check against. + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is within the bounds of the Polygon, otherwise `false`. + */ +var Contains = function (polygon, x, y) +{ + var inside = false; + + for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) + { + var ix = polygon.points[i].x; + var iy = polygon.points[i].y; + + var jx = polygon.points[j].x; + var jy = polygon.points[j].y; + + if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) + { + inside = !inside; + } + } + + return inside; +}; + +module.exports = Contains; + + +/***/ }), +/* 151 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(150); +var GetPoints = __webpack_require__(284); + +/** + * @classdesc + * [description] + * + * @class Polygon + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Geom.Point[]} [points] - [description] + */ +var Polygon = new Class({ + + initialize: + + function Polygon (points) + { + /** + * The area of this Polygon. + * + * @name Phaser.Geom.Polygon#area + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.area = 0; + + /** + * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] + * + * @name Phaser.Geom.Polygon#points + * @type {Phaser.Geom.Point[]} + * @since 3.0.0 + */ + this.points = []; + + if (points) + { + this.setTo(points); + } + }, + + /** + * Check to see if the Polygon contains the given x / y coordinates. + * + * @method Phaser.Geom.Polygon#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the polygon. + * @param {number} y - The y coordinate to check within the polygon. + * + * @return {boolean} `true` if the coordinates are within the polygon, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * `setTo` may also be called without any arguments to remove all points. + * + * @method Phaser.Geom.Polygon#setTo + * @since 3.0.0 + * + * @param {array} points - [description] + * + * @return {Phaser.Geom.Polygon} This Polygon object. + */ + setTo: function (points) + { + this.area = 0; + this.points = []; + + if (typeof points === 'string') + { + points = points.split(' '); + } + + if (!Array.isArray(points)) + { + return this; + } + + var p; + var y0 = Number.MAX_VALUE; + + // The points argument is an array, so iterate through it + for (var i = 0; i < points.length; i++) + { + p = { x: 0, y: 0 }; + + if (typeof points[i] === 'number' || typeof points[i] === 'string') + { + p.x = parseFloat(points[i]); + p.y = parseFloat(points[i + 1]); + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + + // Lowest boundary + if (p.y < y0) + { + y0 = p.y; + } + } + + this.calculateArea(y0); + + return this; + }, + + /** + * Calculates the area of the Polygon. This is available in the property Polygon.area + * + * @method Phaser.Geom.Polygon#calculateArea + * @since 3.0.0 + * + * @return {number} The area of the polygon. + */ + calculateArea: function () + { + if (this.points.length < 3) + { + this.area = 0; + + return this.area; + } + + var sum = 0; + var p1; + var p2; + + for (var i = 0; i < this.points.length - 1; i++) + { + p1 = this.points[i]; + p2 = this.points[i + 1]; + + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + + p1 = this.points[0]; + p2 = this.points[this.points.length - 1]; + + sum += (p1.x - p2.x) * (p2.y + p1.y); + + this.area = -sum * 0.5; + + return this.area; + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Polygon#getPoints + * @since 3.12.0 + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the perimeter of the Polygon. + */ + getPoints: function (quantity, step, output) + { + return GetPoints(this, quantity, step, output); + } + +}); + +module.exports = Polygon; + + +/***/ }), +/* 152 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(24); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var CONST = __webpack_require__(26); +var GameObject = __webpack_require__(19); +var GetPowerOfTwo = __webpack_require__(294); +var Smoothing = __webpack_require__(120); +var TileSpriteRender = __webpack_require__(805); +var Vector2 = __webpack_require__(3); + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * @classdesc + * A TileSprite is a Sprite that has a repeating texture. + * + * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and + * are designed so that you can create game backdrops using seamless textures as a source. + * + * You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide + * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means + * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a + * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then + * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use + * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, + * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in + * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you + * provide POT textures for Tile Sprites. + * + * @class TileSprite + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Crop + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {integer} height - The height of the Game Object. If zero it will use the size of the texture frame. + * @param {string} textureKey - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frameKey] - An optional frame from the Texture this Game Object is rendering with. + */ +var TileSprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + TileSpriteRender + ], + + initialize: + + function TileSprite (scene, x, y, width, height, textureKey, frameKey) + { + var renderer = scene.sys.game.renderer; + + GameObject.call(this, scene, 'TileSprite'); + + var displayTexture = scene.sys.textures.get(textureKey); + var displayFrame = displayTexture.get(frameKey); + + if (!width || !height) + { + width = displayFrame.width; + height = displayFrame.height; + } + else + { + width = Math.floor(width); + height = Math.floor(height); + } + + /** + * Internal tile position vector. + * + * @name Phaser.GameObjects.TileSprite#_tilePosition + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 + */ + this._tilePosition = new Vector2(); + + /** + * Internal tile scale vector. + * + * @name Phaser.GameObjects.TileSprite#_tileScale + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 + */ + this._tileScale = new Vector2(1, 1); + + /** + * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. + * + * Such changes include the texture frame and scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + /** + * The renderer in use by this Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = renderer; + + /** + * The Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#canvas + * @type {?HTMLCanvasElement} + * @since 3.12.0 + */ + this.canvas = CanvasPool.create(this, width, height); + + /** + * The Context of the Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#context + * @type {CanvasRenderingContext2D} + * @since 3.12.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * The Texture the TileSprite is using as its fill pattern. + * + * @name Phaser.GameObjects.TileSprite#displayTexture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @private + * @since 3.12.0 + */ + this.displayTexture = displayTexture; + + /** + * The Frame the TileSprite is using as its fill pattern. + * + * @name Phaser.GameObjects.TileSprite#displayFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.12.0 + */ + this.displayFrame = displayFrame; + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.TileSprite#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.TileSprite#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.TileSprite#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.frame = this.texture.get(); + + /** + * The next power of two value from the width of the Fill Pattern frame. + * + * @name Phaser.GameObjects.TileSprite#potWidth + * @type {integer} + * @since 3.0.0 + */ + this.potWidth = GetPowerOfTwo(displayFrame.width); + + /** + * The next power of two value from the height of the Fill Pattern frame. + * + * @name Phaser.GameObjects.TileSprite#potHeight + * @type {integer} + * @since 3.0.0 + */ + this.potHeight = GetPowerOfTwo(displayFrame.height); + + /** + * The Canvas that the TileSprites texture is rendered to. + * This is used to create a WebGL texture from. + * + * @name Phaser.GameObjects.TileSprite#fillCanvas + * @type {HTMLCanvasElement} + * @since 3.12.0 + */ + this.fillCanvas = CanvasPool.create2D(this, this.potWidth, this.potHeight); + + /** + * The Canvas Context used to render the TileSprites texture. + * + * @name Phaser.GameObjects.TileSprite#fillContext + * @type {CanvasRenderingContext2D} + * @since 3.12.0 + */ + this.fillContext = this.fillCanvas.getContext('2d'); + + /** + * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. + * + * @name Phaser.GameObjects.TileSprite#fillPattern + * @type {?(WebGLTexture|CanvasPattern)} + * @since 3.12.0 + */ + this.fillPattern = null; + + this.setPosition(x, y); + this.setSize(width, height); + this.setFrame(frameKey); + this.setOriginFromFrame(); + this.initPipeline(); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function (renderer) + { + var gl = renderer.gl; + + this.dirty = true; + this.fillPattern = null; + this.fillPattern = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.fillCanvas, this.potWidth, this.potHeight); + }, this); + } + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.TileSprite#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.displayTexture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.TileSprite#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame) + { + this.displayFrame = this.displayTexture.get(frame); + + if (!this.displayFrame.cutWidth || !this.displayFrame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + this.dirty = true; + + this.updateTileTexture(); + + return this; + }, + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. + * + * @method Phaser.GameObjects.TileSprite#setTilePosition + * @since 3.3.0 + * + * @param {number} [x] - The x position of this sprite's tiling texture. + * @param {number} [y] - The y position of this sprite's tiling texture. + * + * @return {this} This Tile Sprite instance. + */ + setTilePosition: function (x, y) + { + if (x !== undefined) + { + this.tilePositionX = x; + } + + if (y !== undefined) + { + this.tilePositionY = y; + } + + return this; + }, + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. + * + * @method Phaser.GameObjects.TileSprite#setTileScale + * @since 3.12.0 + * + * @param {number} [x] - The horizontal scale of the tiling texture. + * @param {number} [y] - The vertical scale of the tiling texture. + * + * @return {this} This Tile Sprite instance. + */ + setTileScale: function (x, y) + { + if (x !== undefined) + { + this.tileScaleX = x; + } + + if (y !== undefined) + { + this.tileScaleY = y; + } + + return this; + }, + + /** + * Render the tile texture if it is dirty, or if the frame has changed. + * + * @method Phaser.GameObjects.TileSprite#updateTileTexture + * @private + * @since 3.0.0 + */ + updateTileTexture: function () + { + if (!this.dirty) + { + return; + } + + // Draw the displayTexture to our fillCanvas + + var frame = this.displayFrame; + + var ctx = this.fillContext; + var canvas = this.fillCanvas; + + var fw = this.potWidth; + var fh = this.potHeight; + + if (!this.renderer.gl) + { + fw = frame.cutWidth; + fh = frame.cutHeight; + } + + ctx.clearRect(0, 0, fw, fh); + + canvas.width = fw; + canvas.height = fh; + + ctx.drawImage( + frame.source.image, + frame.cutX, frame.cutY, + frame.cutWidth, frame.cutHeight, + 0, 0, + fw, fh + ); + + if (this.renderer.gl) + { + this.fillPattern = this.renderer.canvasToTexture(canvas, this.fillPattern); + } + else + { + this.fillPattern = ctx.createPattern(canvas, 'repeat'); + } + + this.updateCanvas(); + + this.dirty = false; + }, + + /** + * Draw the fill pattern to the internal canvas. + * + * @method Phaser.GameObjects.TileSprite#updateCanvas + * @private + * @since 3.12.0 + */ + updateCanvas: function () + { + var canvas = this.canvas; + + if (canvas.width !== this.width || canvas.height !== this.height) + { + canvas.width = this.width; + canvas.height = this.height; + + this.frame.setSize(this.width, this.height); + } + + if (!this.dirty || this.renderer && this.renderer.gl) + { + this.dirty = false; + return; + } + + var ctx = this.context; + + if (!this.scene.sys.game.config.antialias) + { + Smoothing.disable(ctx); + } + + var scaleX = this._tileScale.x; + var scaleY = this._tileScale.y; + + var positionX = this._tilePosition.x; + var positionY = this._tilePosition.y; + + ctx.clearRect(0, 0, this.width, this.height); + + ctx.save(); + + ctx.scale(scaleX, scaleY); + + ctx.translate(-positionX, -positionY); + + ctx.fillStyle = this.fillPattern; + + ctx.fillRect(positionX, positionY, this.width / scaleX, this.height / scaleY); + + ctx.restore(); + + this.dirty = false; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.TileSprite#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + if (this.renderer && this.renderer.gl) + { + this.renderer.deleteTexture(this.fillPattern); + } + + CanvasPool.remove(this.canvas); + CanvasPool.remove(this.fillCanvas); + + this.fillPattern = null; + this.fillContext = null; + this.fillCanvas = null; + + this.displayTexture = null; + this.displayFrame = null; + + this.texture.destroy(); + + this.renderer = null; + }, + + /** + * The horizontal scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionX: { + + get: function () + { + return this._tilePosition.x; + }, + + set: function (value) + { + this._tilePosition.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionY: { + + get: function () + { + return this._tilePosition.y; + }, + + set: function (value) + { + this._tilePosition.y = value; + this.dirty = true; + } + + }, + + /** + * The horizontal scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleX + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleX: { + + get: function () + { + return this._tileScale.x; + }, + + set: function (value) + { + this._tileScale.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleY + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleY: { + + get: function () + { + return this._tileScale.y; + }, + + set: function (value) + { + this._tileScale.y = value; + this.dirty = true; + } + + } + +}); + +module.exports = TileSprite; + + +/***/ }), +/* 153 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AddToDOM = __webpack_require__(169); +var CanvasPool = __webpack_require__(24); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var CONST = __webpack_require__(26); +var GameObject = __webpack_require__(19); +var GetTextSize = __webpack_require__(811); +var GetValue = __webpack_require__(4); +var RemoveFromDOM = __webpack_require__(342); +var TextRender = __webpack_require__(810); +var TextStyle = __webpack_require__(807); + +/** + * @classdesc + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + * + * @class Text + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Crop + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {object} style - The text style configuration object. + */ +var Text = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + TextRender + ], + + initialize: + + function Text (scene, x, y, text, style) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + GameObject.call(this, scene, 'Text'); + + /** + * The renderer in use by this Text object. + * + * @name Phaser.GameObjects.Text#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.12.0 + */ + this.renderer = scene.sys.game.renderer; + + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline(); + + /** + * The canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = CanvasPool.create(this); + + /** + * The context of the canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * The Text Style object. + * + * Manages the style of this Text object. + * + * @name Phaser.GameObjects.Text#style + * @type {Phaser.GameObjects.Text.TextStyle} + * @since 3.0.0 + */ + this.style = new TextStyle(this, style); + + /** + * Whether to automatically round line positions. + * + * @name Phaser.GameObjects.Text#autoRound + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.autoRound = true; + + /** + * The Regular Expression that is used to split the text up into lines, in + * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. + * You can change this RegExp to be anything else that you may need. + * + * @name Phaser.GameObjects.Text#splitRegExp + * @type {object} + * @since 3.0.0 + */ + this.splitRegExp = /(?:\r\n|\r|\n)/; + + /** + * The text to display. + * + * @name Phaser.GameObjects.Text#_text + * @type {string} + * @private + * @since 3.12.0 + */ + this._text = ''; + + /** + * Specify a padding value which is added to the line width and height when calculating the Text size. + * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. + * + * @name Phaser.GameObjects.Text#padding + * @type {{left:number,right:number,top:number,bottom:number}} + * @since 3.0.0 + */ + this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; + + /** + * The width of this Text object. + * + * @name Phaser.GameObjects.Text#width + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.width = 1; + + /** + * The height of this Text object. + * + * @name Phaser.GameObjects.Text#height + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.height = 1; + + /** + * The line spacing value. + * This value is added to the font height to calculate the overall line height. + * Only has an effect if this Text object contains multiple lines of text. + * + * If you update this property directly, instead of using the `setLineSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. + * + * @name Phaser.GameObjects.Text#lineSpacing + * @type {number} + * @since 3.13.0 + */ + this.lineSpacing = 0; + + /** + * Whether the text or its settings have changed and need updating. + * + * @name Phaser.GameObjects.Text#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + // If resolution wasn't set, then we get it from the game config + if (this.style.resolution === 0) + { + this.style.resolution = scene.sys.game.config.resolution; + } + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Text#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + // Create a Texture for this Text object + this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + + // Get the frame + this.frame = this.texture.get(); + + // Set the resolution + this.frame.source.resolution = this.style.resolution; + + if (this.renderer && this.renderer.gl) + { + // Clear the default 1x1 glTexture, as we override it later + this.renderer.deleteTexture(this.frame.source.glTexture); + + this.frame.source.glTexture = null; + } + + this.initRTL(); + + if (style && style.padding) + { + this.setPadding(style.padding); + } + + if (style && style.lineSpacing) + { + this.lineSpacing = style.lineSpacing; + } + + this.setText(text); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.dirty = true; + }, this); + } + }, + + /** + * Initialize right to left text. + * + * @method Phaser.GameObjects.Text#initRTL + * @since 3.0.0 + */ + initRTL: function () + { + if (!this.style.rtl) + { + return; + } + + // Here is where the crazy starts. + // + // Due to browser implementation issues, you cannot fillText BiDi text to a canvas + // that is not part of the DOM. It just completely ignores the direction property. + + this.canvas.dir = 'rtl'; + + // Experimental atm, but one day ... + this.context.direction = 'rtl'; + + // Add it to the DOM, but hidden within the parent canvas. + this.canvas.style.display = 'none'; + + AddToDOM(this.canvas, this.scene.sys.canvas); + + // And finally we set the x origin + this.originX = 1; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. + * + * @method Phaser.GameObjects.Text#runWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * + * @return {string} The text after wrapping has been applied. + */ + runWordWrap: function (text) + { + var style = this.style; + + if (style.wordWrapCallback) + { + var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); + + if (Array.isArray(wrappedLines)) + { + wrappedLines = wrappedLines.join('\n'); + } + + return wrappedLines; + } + else if (style.wordWrapWidth) + { + if (style.wordWrapUseAdvanced) + { + return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); + } + else + { + return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); + } + } + else + { + return text; + } + }, + + /** + * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be + * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a + * single character. + * + * @method Phaser.GameObjects.Text#advancedWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {number} wordWrapWidth - The word wrap width. + * + * @return {string} The wrapped text. + */ + advancedWordWrap: function (text, context, wordWrapWidth) + { + var output = ''; + + // Condense consecutive spaces and split into lines + var lines = text + .replace(/ +/gi, ' ') + .split(this.splitRegExp); + + var linesCount = lines.length; + + for (var i = 0; i < linesCount; i++) + { + var line = lines[i]; + var out = ''; + + // Trim whitespace + line = line.replace(/^ *|\s*$/gi, ''); + + // If entire line is less than wordWrapWidth append the entire line and exit early + var lineWidth = context.measureText(line).width; + + if (lineWidth < wordWrapWidth) + { + output += line + '\n'; + continue; + } + + // Otherwise, calculate new lines + var currentLineWidth = wordWrapWidth; + + // Split into words + var words = line.split(' '); + + for (var j = 0; j < words.length; j++) + { + var word = words[j]; + var wordWithSpace = word + ' '; + var wordWidth = context.measureText(wordWithSpace).width; + + if (wordWidth > currentLineWidth) + { + // Break word + if (j === 0) + { + // Shave off letters from word until it's small enough + var newWord = wordWithSpace; + + while (newWord.length) + { + newWord = newWord.slice(0, -1); + wordWidth = context.measureText(newWord).width; + + if (wordWidth <= currentLineWidth) + { + break; + } + } + + // If wordWrapWidth is too small for even a single letter, shame user + // failure with a fatal error + if (!newWord.length) + { + throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); + } + + // Replace current word in array with remainder + var secondPart = word.substr(newWord.length); + + words[j] = secondPart; + + // Append first piece to output + out += newWord; + } + + // If existing word length is 0, don't include it + var offset = (words[j].length) ? j : j + 1; + + // Collapse rest of sentence and remove any trailing white space + var remainder = words.slice(offset).join(' ') + .replace(/[ \n]*$/gi, ''); + + // Prepend remainder to next line + lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); + linesCount = lines.length; + + break; // Processing on this line + + // Append word with space to output + } + else + { + out += wordWithSpace; + currentLineWidth -= wordWidth; + } + } + + // Append processed line to output + output += out.replace(/[ \n]*$/gi, '') + '\n'; + } + + // Trim the end of the string + output = output.replace(/[\s|\n]*$/gi, ''); + + return output; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Spaces are not collapsed and whitespace is not trimmed. + * + * @method Phaser.GameObjects.Text#basicWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {number} wordWrapWidth - The word wrap width. + * + * @return {string} The wrapped text. + */ + basicWordWrap: function (text, context, wordWrapWidth) + { + var result = ''; + var lines = text.split(this.splitRegExp); + + for (var i = 0; i < lines.length; i++) + { + var spaceLeft = wordWrapWidth; + var words = lines[i].split(' '); + + for (var j = 0; j < words.length; j++) + { + var wordWidth = context.measureText(words[j]).width; + var wordWidthWithSpace = wordWidth + context.measureText(' ').width; + + if (wordWidthWithSpace > spaceLeft) + { + // Skip printing the newline if it's the first word of the line that is greater + // than the word wrap width. + if (j > 0) + { + result += '\n'; + } + + result += words[j] + ' '; + spaceLeft = wordWrapWidth - wordWidth; + } + else + { + spaceLeft -= wordWidthWithSpace; + result += words[j]; + + if (j < (words.length - 1)) + { + result += ' '; + } + } + } + + if (i < lines.length - 1) + { + result += '\n'; + } + } + + return result; + }, + + /** + * Runs the given text through this Text objects word wrapping and returns the results as an + * array, where each element of the array corresponds to a wrapped line of text. + * + * @method Phaser.GameObjects.Text#getWrappedText + * @since 3.0.0 + * + * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. + * + * @return {string[]} An array of strings with the pieces of wrapped text. + */ + getWrappedText: function (text) + { + if (text === undefined) { text = this._text; } + + this.style.syncFont(this.canvas, this.context); + + var wrappedLines = this.runWordWrap(text); + + return wrappedLines.split(this.splitRegExp); + }, + + /** + * Set the text to display. + * + * An array of strings will be joined with `\n` line breaks. + * + * @method Phaser.GameObjects.Text#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this Text object. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this._text) + { + this._text = value.toString(); + + this.updateText(); + } + + return this; + }, + + /** + * Set the text style. + * + * @example + * text.setStyle({ + * fontSize: '64px', + * fontFamily: 'Arial', + * color: '#ffffff', + * align: 'center', + * backgroundColor: '#ff00ff' + * }); + * + * @method Phaser.GameObjects.Text#setStyle + * @since 3.0.0 + * + * @param {object} style - The style settings to set. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStyle: function (style) + { + return this.style.setStyle(style); + }, + + /** + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * + * @method Phaser.GameObjects.Text#setFont + * @since 3.0.0 + * + * @param {string} font - The font family or font settings to set. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFont: function (font) + { + return this.style.setFont(font); + }, + + /** + * Set the font family. + * + * @method Phaser.GameObjects.Text#setFontFamily + * @since 3.0.0 + * + * @param {string} family - The font family. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontFamily: function (family) + { + return this.style.setFontFamily(family); + }, + + /** + * Set the font size. + * + * @method Phaser.GameObjects.Text#setFontSize + * @since 3.0.0 + * + * @param {number} size - The font size. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontSize: function (size) + { + return this.style.setFontSize(size); + }, + + /** + * Set the font style. + * + * @method Phaser.GameObjects.Text#setFontStyle + * @since 3.0.0 + * + * @param {string} style - The font style. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontStyle: function (style) + { + return this.style.setFontStyle(style); + }, + + /** + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * + * @method Phaser.GameObjects.Text#setFixedSize + * @since 3.0.0 + * + * @param {number} width - The fixed width to set. `0` disables fixed width. + * @param {number} height - The fixed height to set. `0` disables fixed height. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFixedSize: function (width, height) + { + return this.style.setFixedSize(width, height); + }, + + /** + * Set the background color. + * + * @method Phaser.GameObjects.Text#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - The background color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setBackgroundColor: function (color) + { + return this.style.setBackgroundColor(color); + }, + + /** + * Set the text fill color. + * + * @method Phaser.GameObjects.Text#setFill + * @since 3.0.0 + * + * @param {string} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFill: function (color) + { + return this.style.setFill(color); + }, + + /** + * Set the text fill color. + * + * @method Phaser.GameObjects.Text#setColor + * @since 3.0.0 + * + * @param {string} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setColor: function (color) + { + return this.style.setColor(color); + }, + + /** + * Set the stroke settings. + * + * @method Phaser.GameObjects.Text#setStroke + * @since 3.0.0 + * + * @param {string} color - The stroke color. + * @param {number} thickness - The stroke thickness. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStroke: function (color, thickness) + { + return this.style.setStroke(color, thickness); + }, + + /** + * Set the shadow settings. + * + * @method Phaser.GameObjects.Text#setShadow + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * @param {string} [color='#000'] - The shadow color. + * @param {number} [blur=0] - The shadow blur radius. + * @param {boolean} [shadowStroke=false] - Whether to stroke the shadow. + * @param {boolean} [shadowFill=true] - Whether to fill the shadow. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); + }, + + /** + * Set the shadow offset. + * + * @method Phaser.GameObjects.Text#setShadowOffset + * @since 3.0.0 + * + * @param {number} x - The horizontal shadow offset. + * @param {number} y - The vertical shadow offset. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowOffset: function (x, y) + { + return this.style.setShadowOffset(x, y); + }, + + /** + * Set the shadow color. + * + * @method Phaser.GameObjects.Text#setShadowColor + * @since 3.0.0 + * + * @param {string} color - The shadow color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowColor: function (color) + { + return this.style.setShadowColor(color); + }, + + /** + * Set the shadow blur radius. + * + * @method Phaser.GameObjects.Text#setShadowBlur + * @since 3.0.0 + * + * @param {number} blur - The shadow blur radius. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowBlur: function (blur) + { + return this.style.setShadowBlur(blur); + }, + + /** + * Enable or disable shadow stroke. + * + * @method Phaser.GameObjects.Text#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow stroke is enabled or not. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowStroke: function (enabled) + { + return this.style.setShadowStroke(enabled); + }, + + /** + * Enable or disable shadow fill. + * + * @method Phaser.GameObjects.Text#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow fill is enabled or not. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowFill: function (enabled) + { + return this.style.setShadowFill(enabled); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.Text#setWordWrapWidth + * @since 3.0.0 + * + * @param {?number} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + return this.style.setWordWrapWidth(width, useAdvancedWrap); + }, + + /** + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.Text#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapCallback: function (callback, scope) + { + return this.style.setWordWrapCallback(callback, scope); + }, + + /** + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. + * + * @method Phaser.GameObjects.Text#setAlign + * @since 3.0.0 + * + * @param {string} align - The text alignment. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setAlign: function (align) + { + return this.style.setAlign(align); + }, + + /** + * Set the resolution used by this Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method, or by specifying it in the Text style configuration object. + * + * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger + * internal Canvas textures for the Text. + * + * Therefore, please use with caution, as the more high res Text you have, the more memory it uses. + * + * @method Phaser.GameObjects.Text#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setResolution: function (value) + { + return this.style.setResolution(value); + }, + + /** + * Sets the line spacing value. + * + * This value is _added_ to the height of the font when calculating the overall line height. + * This only has an effect if this Text object consists of multiple lines of text. + * + * @method Phaser.GameObjects.Text#setLineSpacing + * @since 3.13.0 + * + * @param {number} value - The amount to add to the font height to achieve the overall line height. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setLineSpacing: function (value) + { + this.lineSpacing = value; + + return this.updateText(); + }, + + /** + * Set the text padding. + * + * 'left' can be an object. + * + * If only 'left' and 'top' are given they are treated as 'x' and 'y'. + * + * @method Phaser.GameObjects.Text#setPadding + * @since 3.0.0 + * + * @param {(number|object)} left - The left padding value, or a padding config object. + * @param {number} top - The top padding value. + * @param {number} right - The right padding value. + * @param {number} bottom - The bottom padding value. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setPadding: function (left, top, right, bottom) + { + if (typeof left === 'object') + { + var config = left; + + // If they specify x and/or y this applies to all + var x = GetValue(config, 'x', null); + + if (x !== null) + { + left = x; + right = x; + } + else + { + left = GetValue(config, 'left', 0); + right = GetValue(config, 'right', left); + } + + var y = GetValue(config, 'y', null); + + if (y !== null) + { + top = y; + bottom = y; + } + else + { + top = GetValue(config, 'top', 0); + bottom = GetValue(config, 'bottom', top); + } + } + else + { + if (left === undefined) { left = 0; } + if (top === undefined) { top = left; } + if (right === undefined) { right = left; } + if (bottom === undefined) { bottom = top; } + } + + this.padding.left = left; + this.padding.top = top; + this.padding.right = right; + this.padding.bottom = bottom; + + return this.updateText(); + }, + + /** + * Set the maximum number of lines to draw. + * + * @method Phaser.GameObjects.Text#setMaxLines + * @since 3.0.0 + * + * @param {integer} [max=0] - The maximum number of lines to draw. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setMaxLines: function (max) + { + return this.style.setMaxLines(max); + }, + + /** + * Update the displayed text. + * + * @method Phaser.GameObjects.Text#updateText + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + updateText: function () + { + var canvas = this.canvas; + var context = this.context; + var style = this.style; + var resolution = style.resolution; + var size = style.metrics; + + style.syncFont(canvas, context); + + var outputText = this._text; + + if (style.wordWrapWidth || style.wordWrapCallback) + { + outputText = this.runWordWrap(this._text); + } + + // Split text into lines + var lines = outputText.split(this.splitRegExp); + + var textSize = GetTextSize(this, size, lines); + + var padding = this.padding; + + var w = textSize.width + padding.left + padding.right; + var h = textSize.height + padding.top + padding.bottom; + + if (style.fixedWidth === 0) + { + this.width = w; + } + + if (style.fixedHeight === 0) + { + this.height = h; + } + + this.updateDisplayOrigin(); + + w *= resolution; + h *= resolution; + + w = Math.max(w, 1); + h = Math.max(h, 1); + + if (canvas.width !== w || canvas.height !== h) + { + canvas.width = w; + canvas.height = h; + + this.frame.setSize(w, h); + + style.syncFont(canvas, context); // Resizing resets the context + } + else + { + context.clearRect(0, 0, w, h); + } + + context.save(); + + context.scale(resolution, resolution); + + if (style.backgroundColor) + { + context.fillStyle = style.backgroundColor; + context.fillRect(0, 0, w, h); + } + + style.syncStyle(canvas, context); + + context.textBaseline = 'alphabetic'; + + // Apply padding + context.translate(padding.left, padding.top); + + var linePositionX; + var linePositionY; + + // Draw text line by line + for (var i = 0; i < textSize.lines; i++) + { + linePositionX = style.strokeThickness / 2; + linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; + + if (i > 0) + { + linePositionY += (textSize.lineSpacing * i); + } + + if (style.rtl) + { + linePositionX = w - linePositionX; + } + else if (style.align === 'right') + { + linePositionX += textSize.width - textSize.lineWidths[i]; + } + else if (style.align === 'center') + { + linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; + } + + if (this.autoRound) + { + linePositionX = Math.round(linePositionX); + linePositionY = Math.round(linePositionY); + } + + if (style.strokeThickness) + { + this.style.syncShadow(context, style.shadowStroke); + + context.strokeText(lines[i], linePositionX, linePositionY); + } + + if (style.color) + { + this.style.syncShadow(context, style.shadowFill); + + context.fillText(lines[i], linePositionX, linePositionY); + } + } + + context.restore(); + + if (this.renderer.gl) + { + this.frame.source.glTexture = this.renderer.canvasToTexture(canvas, this.frame.source.glTexture, true); + + this.frame.glTexture = this.frame.source.glTexture; + } + + this.dirty = true; + + return this; + }, + + /** + * Get the current text metrics. + * + * @method Phaser.GameObjects.Text#getTextMetrics + * @since 3.0.0 + * + * @return {object} The text metrics. + */ + getTextMetrics: function () + { + return this.style.getTextMetrics(); + }, + + /** + * The text string being rendered by this Text Game Object. + * + * @name Phaser.GameObjects.Text#text + * @type {string} + * @since 3.0.0 + */ + text: { + + get: function () + { + return this._text; + }, + + set: function (value) + { + this.setText(value); + } + + }, + + /** + * Build a JSON representation of the Text object. + * + * @method Phaser.GameObjects.Text#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Text object. + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra Text data is added here + + var data = { + autoRound: this.autoRound, + text: this._text, + style: this.style.toJSON(), + padding: { + left: this.padding.left, + right: this.padding.right, + top: this.padding.top, + bottom: this.padding.bottom + } + }; + + out.data = data; + + return out; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Text#preDestroy + * @protected + * @since 3.0.0 + */ + preDestroy: function () + { + if (this.style.rtl) + { + RemoveFromDOM(this.canvas); + } + + CanvasPool.remove(this.canvas); + + this.texture.destroy(); + } + +}); + +module.exports = Text; + + +/***/ }), +/* 154 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(121); +var CanvasPool = __webpack_require__(24); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var CONST = __webpack_require__(26); +var Frame = __webpack_require__(113); +var GameObject = __webpack_require__(19); +var Render = __webpack_require__(817); +var UUID = __webpack_require__(295); + +/** + * @classdesc + * A Render Texture. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. + * + * @class RenderTexture + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.2.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + */ +var RenderTexture = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function RenderTexture (scene, x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 32; } + if (height === undefined) { height = 32; } + + GameObject.call(this, scene, 'RenderTexture'); + + /** + * A reference to either the Canvas or WebGL Renderer that the Game instance is using. + * + * @name Phaser.GameObjects.RenderTexture#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.2.0 + */ + this.renderer = scene.sys.game.renderer; + + /** + * A reference to the Texture Manager. + * + * @name Phaser.GameObjects.RenderTexture#textureManager + * @type {Phaser.Textures.TextureManager} + * @since 3.12.0 + */ + this.textureManager = scene.sys.textures; + + /** + * The tint of the Render Texture when rendered. + * + * @name Phaser.GameObjects.RenderTexture#globalTint + * @type {number} + * @default 0xffffff + * @since 3.2.0 + */ + this.globalTint = 0xffffff; + + /** + * The alpha of the Render Texture when rendered. + * + * @name Phaser.GameObjects.RenderTexture#globalAlpha + * @type {number} + * @default 1 + * @since 3.2.0 + */ + this.globalAlpha = 1; + + /** + * The HTML Canvas Element that the Render Texture is drawing to. + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.GameObjects.RenderTexture#canvas + * @type {HTMLCanvasElement} + * @since 3.2.0 + */ + this.canvas = CanvasPool.create2D(this, width, height); + + /** + * A reference to the Rendering Context belonging to the Canvas Element this Render Texture is drawing to. + * + * @name Phaser.GameObjects.RenderTexture#context + * @type {CanvasRenderingContext2D} + * @since 3.2.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * A reference to the GL Frame Buffer this Render Texture is drawing to. + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.GameObjects.RenderTexture#framebuffer + * @type {?WebGLFramebuffer} + * @since 3.2.0 + */ + this.framebuffer = null; + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.RenderTexture#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Texture corresponding to this Render Texture. + * + * @name Phaser.GameObjects.RenderTexture#texture + * @type {Phaser.Textures.Texture} + * @since 3.12.0 + */ + this.texture = scene.sys.textures.addCanvas(UUID(), this.canvas); + + /** + * The Frame corresponding to this Render Texture. + * + * @name Phaser.GameObjects.RenderTexture#frame + * @type {Phaser.Textures.Frame} + * @since 3.12.0 + */ + this.frame = this.texture.get(); + + /** + * Internal saved texture flag. + * + * @name Phaser.GameObjects.RenderTexture#_saved + * @type {boolean} + * @private + * @since 3.12.0 + */ + this._saved = false; + + /** + * An internal Camera that can be used to move around the Render Texture. + * Control it just like you would any Scene Camera. The difference is that it only impacts the placement of what + * is drawn to the Render Texture. You can scroll, zoom and rotate this Camera. + * + * @name Phaser.GameObjects.RenderTexture#camera + * @type {Phaser.Cameras.Scene2D.BaseCamera} + * @since 3.12.0 + */ + this.camera = new Camera(0, 0, width, height); + + /** + * Is this Render Texture dirty or not? If not it won't spend time clearing or filling itself. + * + * @name Phaser.GameObjects.RenderTexture#dirty + * @type {boolean} + * @since 3.12.0 + */ + this.dirty = false; + + /** + * A reference to the WebGL Rendering Context. + * + * @name Phaser.GameObjects.RenderTexture#gl + * @type {WebGLRenderingContext} + * @default null + * @since 3.0.0 + */ + this.gl = null; + + var renderer = this.renderer; + + if (renderer.type === CONST.WEBGL) + { + var gl = renderer.gl; + + this.gl = gl; + this.drawGameObject = this.batchGameObjectWebGL; + this.framebuffer = renderer.createFramebuffer(width, height, this.frame.source.glTexture, false); + } + else if (renderer.type === CONST.CANVAS) + { + this.drawGameObject = this.batchGameObjectCanvas; + } + + this.camera.setScene(scene); + + this.setPosition(x, y); + this.setSize(width, height); + this.setOrigin(0, 0); + this.initPipeline(); + }, + + /** + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + return this.resize(width, height); + }, + + /** + * Resizes the Render Texture to the new dimensions given. + * + * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. + * In Canvas it will resize the underlying canvas element. + * Both approaches will erase everything currently drawn to the Render Texture. + * + * If the dimensions given are the same as those already being used, calling this method will do nothing. + * + * @method Phaser.GameObjects.RenderTexture#resize + * @since 3.10.0 + * + * @param {number} width - The new width of the Render Texture. + * @param {number} [height] - The new height of the Render Texture. If not specified, will be set the same as the `width`. + * + * @return {this} This Render Texture. + */ + resize: function (width, height) + { + if (height === undefined) { height = width; } + + if (width !== this.width || height !== this.height) + { + this.canvas.width = width; + this.canvas.height = height; + + if (this.gl) + { + var gl = this.gl; + + this.renderer.deleteTexture(this.frame.source.glTexture); + this.renderer.deleteFramebuffer(this.framebuffer); + + this.frame.source.glTexture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); + this.framebuffer = this.renderer.createFramebuffer(width, height, this.frame.source.glTexture, false); + + this.frame.glTexture = this.frame.source.glTexture; + } + + this.frame.source.width = width; + this.frame.source.height = height; + + this.camera.setSize(width, height); + + this.frame.setSize(width, height); + + this.width = width; + this.height = height; + } + + return this; + }, + + /** + * Set the tint to use when rendering this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#setGlobalTint + * @since 3.2.0 + * + * @param {integer} tint - The tint value. + * + * @return {this} This Render Texture. + */ + setGlobalTint: function (tint) + { + this.globalTint = tint; + + return this; + }, + + /** + * Set the alpha to use when rendering this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#setGlobalAlpha + * @since 3.2.0 + * + * @param {number} alpha - The alpha value. + * + * @return {this} This Render Texture. + */ + setGlobalAlpha: function (alpha) + { + this.globalAlpha = alpha; + + return this; + }, + + /** + * Stores a copy of this Render Texture in the Texture Manager using the given key. + * + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this + * Render Texture by using the texture key: + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 128, 128); + * + * // Draw something to the Render Texture + * + * rt.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Updating the contents of this Render Texture will automatically update _any_ Game Object + * that is using it as a texture. Calling `saveTexture` again will not save another copy + * of the same texture, it will just rename the key of the existing copy. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#saveTexture + * @since 3.12.0 + * + * @param {string} key - The unique key to store the texture as within the global Texture Manager. + * + * @return {Phaser.Textures.Texture} The Texture that was saved. + */ + saveTexture: function (key) + { + this.textureManager.renameTexture(this.texture.key, key); + + this._saved = true; + + return this.texture; + }, + + /** + * Fills the Render Texture with the given color. + * + * @method Phaser.GameObjects.RenderTexture#fill + * @since 3.2.0 + * + * @param {number} rgb - The color to fill the Render Texture with. + * @param {number} [alpha=1] - The alpha value used by the fill. + * + * @return {this} This Render Texture instance. + */ + fill: function (rgb, alpha) + { + if (alpha === undefined) { alpha = 1; } + + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + if (this.gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var gl = this.gl; + + gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, alpha); + + gl.clear(gl.COLOR_BUFFER_BIT); + + this.renderer.setFramebuffer(null); + } + else + { + this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; + this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); + } + + return this; + }, + + /** + * Clears the Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#clear + * @since 3.2.0 + * + * @return {this} This Render Texture instance. + */ + clear: function () + { + if (this.dirty) + { + if (this.gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var gl = this.gl; + + gl.clearColor(0, 0, 0, 0); + + gl.clear(gl.COLOR_BUFFER_BIT); + + this.renderer.setFramebuffer(null); + } + else + { + var ctx = this.context; + + ctx.save(); + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + ctx.restore(); + } + + this.dirty = false; + } + + return this; + }, + + /** + * Draws the given object, or an array of objects, to this Render Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Dynamic and Static Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. + * * Another Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot draw a Render Texture to itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * + * @method Phaser.GameObjects.RenderTexture#draw + * @since 3.2.0 + * + * @param {any} entries - Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param {number} [x] - The x position to draw the Frame at, or the offset applied to the object. + * @param {number} [y] - The y position to draw the Frame at, or the offset applied to the object. + * @param {number} [alpha] - The alpha value. Only used for Texture Frames and if not specified defaults to the `globalAlpha` property. Game Objects use their own current alpha value. + * @param {number} [tint] - WebGL only. The tint color value. Only used for Texture Frames and if not specified defaults to the `globalTint` property. Game Objects use their own current tint value. + * + * @return {this} This Render Texture instance. + */ + draw: function (entries, x, y, alpha, tint) + { + if (alpha === undefined) { alpha = this.globalAlpha; } + + if (tint === undefined) + { + tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + } + else + { + tint = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16); + } + + if (!Array.isArray(entries)) + { + entries = [ entries ]; + } + + var gl = this.gl; + + this.camera.preRender(1, 1, 1); + + if (gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var pipeline = this.pipeline; + + pipeline.projOrtho(0, this.width, 0, this.height, -1000.0, 1000.0); + + this.batchList(entries, x, y, alpha, tint); + + pipeline.flush(); + + this.renderer.setFramebuffer(null); + + pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000.0, 1000.0); + } + else + { + this.renderer.setContext(this.context); + + this.batchList(entries, x, y, alpha, tint); + + this.renderer.setContext(); + } + + this.dirty = true; + + return this; + }, + + /** + * Draws the Texture Frame to the Render Texture at the given position. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 800, 600); + * rt.drawFrame(key, frame); + * ``` + * + * You can optionally provide a position, alpha and tint value to apply to the frame + * before it is drawn. + * + * Calling this method will cause a batch flush, so if you've got a stack of things to draw + * in a tight loop, try using the `draw` method instead. + * + * If you need to draw a Sprite to this Render Texture, use the `draw` method instead. + * + * @method Phaser.GameObjects.RenderTexture#drawFrame + * @since 3.12.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} [x=0] - The x position to draw the frame at. + * @param {number} [y=0] - The y position to draw the frame at. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - WebGL only. The tint color to use. If not specified it uses the `globalTint` property. + * + * @return {this} This Render Texture instance. + */ + drawFrame: function (key, frame, x, y, alpha, tint) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (alpha === undefined) { alpha = this.globalAlpha; } + + if (tint === undefined) + { + tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + } + else + { + tint = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16); + } + + var gl = this.gl; + var textureFrame = this.textureManager.getFrame(key, frame); + + if (textureFrame) + { + this.camera.preRender(1, 1, 1); + + if (gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var pipeline = this.pipeline; + + pipeline.projOrtho(0, this.width, 0, this.height, -1000.0, 1000.0); + + pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null); + + pipeline.flush(); + + this.renderer.setFramebuffer(null); + + pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000.0, 1000.0); + } + else + { + this.batchTextureFrame(textureFrame, x, y, alpha, tint); + } + + this.dirty = true; + } + + return this; + }, + + /** + * Internal method that handles the drawing of an array of children. + * + * @method Phaser.GameObjects.RenderTexture#batchList + * @private + * @since 3.12.0 + * + * @param {array} children - The array of Game Objects to draw. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - The tint color to use. If not specified it uses the `globalTint` property. + */ + batchList: function (children, x, y, alpha, tint) + { + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (!entry || entry === this) + { + continue; + } + + if (entry.renderWebGL || entry.renderCanvas) + { + // Game Objects + this.drawGameObject(entry, x, y); + } + else if (entry.isParent || entry.list) + { + // Groups / Display Lists + this.batchGroup(entry.getChildren(), x, y); + } + else if (typeof entry === 'string') + { + // Texture key + this.batchTextureFrameKey(entry, null, x, y, alpha, tint); + } + else if (entry instanceof Frame) + { + // Texture Frame instance + this.batchTextureFrame(entry, x, y, alpha, tint); + } + else if (Array.isArray(entry)) + { + // Another Array + this.batchList(entry, x, y, alpha, tint); + } + } + }, + + /** + * Internal method that handles the drawing a Phaser Group contents. + * + * @method Phaser.GameObjects.RenderTexture#batchGroup + * @private + * @since 3.12.0 + * + * @param {array} children - The array of Game Objects to draw. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + */ + batchGroup: function (children, x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (entry.willRender()) + { + var tx = entry.x + x; + var ty = entry.y + y; + + this.drawGameObject(entry, tx, ty); + } + } + }, + + /** + * Internal method that handles drawing a single Phaser Game Object to this Render Texture using WebGL. + * + * @method Phaser.GameObjects.RenderTexture#batchGameObjectWebGL + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to draw. + * @param {number} x - The x position to draw the Game Object at. + * @param {number} y - The y position to draw the Game Object at. + */ + batchGameObjectWebGL: function (gameObject, x, y) + { + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + var prevX = gameObject.x; + var prevY = gameObject.y; + + this.renderer.setBlendMode(gameObject.blendMode); + + gameObject.setPosition(x, y); + + gameObject.renderWebGL(this.renderer, gameObject, 0, this.camera, null); + + gameObject.setPosition(prevX, prevY); + }, + + /** + * Internal method that handles drawing a single Phaser Game Object to this Render Texture using Canvas. + * + * @method Phaser.GameObjects.RenderTexture#batchGameObjectCanvas + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to draw. + * @param {number} x - The x position to draw the Game Object at. + * @param {number} y - The y position to draw the Game Object at. + */ + batchGameObjectCanvas: function (gameObject, x, y) + { + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + var prevX = gameObject.x; + var prevY = gameObject.y; + + gameObject.setPosition(x, y); + + gameObject.renderCanvas(this.renderer, gameObject, 0, this.camera, null); + + gameObject.setPosition(prevX, prevY); + }, + + /** + * Internal method that handles the drawing of an array of children. + * + * @method Phaser.GameObjects.RenderTexture#batchTextureFrameKey + * @private + * @since 3.12.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - The tint color to use. If not specified it uses the `globalTint` property. + * + * @return {boolean} `true` if the frame was found and drawn, otherwise `false`. + */ + batchTextureFrameKey: function (key, frame, x, y, alpha, tint) + { + var textureFrame = this.textureManager.getFrame(key, frame); + + if (textureFrame) + { + this.batchTextureFrame(textureFrame, x, y, alpha, tint); + } + }, + + /** + * Internal method that handles the drawing of a Texture Frame to this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#batchTextureFrame + * @private + * @since 3.12.0 + * + * @param {Phaser.Textures.Frame} textureFrame - The Texture Frame to draw. + * @param {number} x - The x position to draw the Frame at. + * @param {number} y - The y position to draw the Frame at. + * @param {number} [tint] - A tint color to be applied to the frame drawn to the Render Texture. + */ + batchTextureFrame: function (textureFrame, x, y, alpha, tint) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + if (this.gl) + { + this.pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null); + } + else + { + var ctx = this.context; + var cd = textureFrame.canvasData; + var source = textureFrame.source.image; + + var matrix = this.camera.matrix; + + ctx.globalAlpha = this.globalAlpha; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + ctx.drawImage(source, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height); + } + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.RenderTexture#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + if (!this._saved) + { + CanvasPool.remove(this.canvas); + + if (this.gl) + { + this.renderer.deleteFramebuffer(this.framebuffer); + } + + this.texture.destroy(); + } + } + +}); + +module.exports = RenderTexture; + + +/***/ }), +/* 155 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var GravityWell = __webpack_require__(304); +var List = __webpack_require__(112); +var ParticleEmitter = __webpack_require__(302); +var Render = __webpack_require__(821); + +/** + * @classdesc + * A Particle Emitter Manager creates and controls {@link Phaser.GameObjects.Particles.ParticleEmitter Particle Emitters} and {@link Phaser.GameObjects.Particles.GravityWell Gravity Wells}. + * + * @class ParticleEmitterManager + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Emitter Manager belongs. + * @param {string} texture - The key of the Texture this Emitter Manager will use to render particles, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Emitter Manager will use to render particles. + * @param {ParticleEmitterConfig|ParticleEmitterConfig[]} [emitters] - Configuration settings for one or more emitters to create. + */ +var ParticleEmitterManager = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.Pipeline, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + // frame is optional and can contain the emitters array or object if skipped + function ParticleEmitterManager (scene, texture, frame, emitters) + { + GameObject.call(this, scene, 'ParticleEmitterManager'); + + /** + * The blend mode applied to all emitters and particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode + * @type {integer} + * @default -1 + * @private + * @since 3.0.0 + */ + this.blendMode = -1; + + /** + * The time scale applied to all emitters and particles, affecting flow rate, lifespan, and movement. + * Values larger than 1 are faster than normal. + * This is multiplied with any timeScale set on each individual emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * The texture used to render this Emitter Manager's particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture + * @type {Phaser.Textures.Texture} + * @default null + * @since 3.0.0 + */ + this.texture = null; + + /** + * The texture frame used to render this Emitter Manager's particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame + * @type {Phaser.Textures.Frame} + * @default null + * @since 3.0.0 + */ + this.frame = null; + + /** + * Names of this Emitter Manager's texture frames. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames + * @type {string[]} + * @since 3.0.0 + */ + this.frameNames = []; + + // frame is optional and can contain the emitters array or object if skipped + if (frame !== null && (typeof frame === 'object' || Array.isArray(frame))) + { + emitters = frame; + frame = null; + } + + this.setTexture(texture, frame); + + this.initPipeline(); + + /** + * A list of Emitters being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.emitters = new List(this); + + /** + * A list of Gravity Wells being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.wells = new List(this); + + if (emitters) + { + // An array of emitter configs? + if (!Array.isArray(emitters)) + { + emitters = [ emitters ]; + } + + for (var i = 0; i < emitters.length; i++) + { + this.createEmitter(emitters[i]); + } + } + }, + + /** + * Sets the texture and frame this Emitter Manager will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Emitter Manager will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + setFrame: function (frame) + { + this.frame = this.texture.get(frame); + + var frames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); + + var names = []; + + frames.forEach(function (sourceFrame) + { + names.push(sourceFrame.name); + }); + + this.frameNames = names; + + this.defaultFrame = this.frame; + + return this; + }, + + /** + * Assigns texture frames to an emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames + * @since 3.0.0 + * + * @param {(Phaser.Textures.Frame|Phaser.Textures.Frame[])} frames - The texture frames. + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The particle emitter to modify. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + setEmitterFrames: function (frames, emitter) + { + if (!Array.isArray(frames)) + { + frames = [ frames ]; + } + + var out = emitter.frames; + + out.length = 0; + + for (var i = 0; i < frames.length; i++) + { + var frame = frames[i]; + + if (this.frameNames.indexOf(frame) !== -1) + { + out.push(this.texture.get(frame)); + } + } + + if (out.length > 0) + { + emitter.defaultFrame = out[0]; + } + else + { + emitter.defaultFrame = this.defaultFrame; + } + + return this; + }, + + /** + * Adds an existing Particle Emitter to this Emitter Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager. + */ + addEmitter: function (emitter) + { + return this.emitters.add(emitter); + }, + + /** + * Creates a new Particle Emitter object, adds it to this Emitter Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter + * @since 3.0.0 + * + * @param {ParticleEmitterConfig} config - Configuration settings for the Particle Emitter to create. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created. + */ + createEmitter: function (config) + { + return this.addEmitter(new ParticleEmitter(this, config)); + }, + + /** + * Adds an existing Gravity Well object to this Emitter Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager. + */ + addGravityWell: function (well) + { + return this.wells.add(well); + }, + + /** + * Creates a new Gravity Well, adds it to this Emitter Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell + * @since 3.0.0 + * + * @param {GravityWellConfig} config - Configuration settings for the Gravity Well to create. + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. + */ + createGravityWell: function (config) + { + return this.addGravityWell(new GravityWell(config)); + }, + + /** + * Emits particles from each active emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle + * @since 3.0.0 + * + * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * @param {number} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. + * @param {number} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + emitParticle: function (count, x, y) + { + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.emitParticle(count, x, y); + } + } + + return this; + }, + + /** + * Emits particles from each active emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt + * @since 3.0.0 + * + * @param {number} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. + * @param {number} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. + * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * Pauses this Emitter Manager. + * + * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. + * + * The particles will still render, but they will not have any of their logic updated. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * Resumes this Emitter Manager, should it have been previously paused. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * Gets all active particle processors (gravity wells). + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.GravityWell[]} - The active gravity wells. + */ + getProcessors: function () + { + return this.wells.getAll('active', true); + }, + + /** + * Updates all active emitters. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate + * @since 3.0.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. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.preUpdate(time, delta); + } + } + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setAlpha + * @private + * @since 3.10.0 + */ + setAlpha: function () + { + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setScrollFactor + * @private + * @since 3.10.0 + */ + setScrollFactor: function () + { + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setBlendMode + * @private + * @since 3.15.0 + */ + setBlendMode: function () + { + } + +}); + +module.exports = ParticleEmitterManager; + + +/***/ }), +/* 156 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * + * @function Phaser.Geom.Ellipse.CircumferencePoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (ellipse, angle, out) +{ + if (out === undefined) { out = new Point(); } + + var halfWidth = ellipse.width / 2; + var halfHeight = ellipse.height / 2; + + out.x = ellipse.x + halfWidth * Math.cos(angle); + out.y = ellipse.y + halfHeight * Math.sin(angle); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 157 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Graphics.Commands + */ + +module.exports = { + + ARC: 0, + BEGIN_PATH: 1, + CLOSE_PATH: 2, + FILL_RECT: 3, + LINE_TO: 4, + MOVE_TO: 5, + LINE_STYLE: 6, + FILL_STYLE: 7, + FILL_PATH: 8, + STROKE_PATH: 9, + FILL_TRIANGLE: 10, + STROKE_TRIANGLE: 11, + LINE_FX_TO: 12, + MOVE_FX_TO: 13, + SAVE: 14, + RESTORE: 15, + TRANSLATE: 16, + SCALE: 17, + ROTATE: 18, + SET_TEXTURE: 19, + CLEAR_TEXTURE: 20, + GRADIENT_FILL_STYLE: 21, + GRADIENT_LINE_STYLE: 22 + +}; + + +/***/ }), +/* 158 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCamera = __webpack_require__(121); +var Class = __webpack_require__(0); +var Commands = __webpack_require__(157); +var ComponentsAlpha = __webpack_require__(401); +var ComponentsBlendMode = __webpack_require__(400); +var ComponentsDepth = __webpack_require__(399); +var ComponentsMask = __webpack_require__(395); +var ComponentsPipeline = __webpack_require__(186); +var ComponentsTransform = __webpack_require__(390); +var ComponentsVisible = __webpack_require__(389); +var ComponentsScrollFactor = __webpack_require__(392); + +var Ellipse = __webpack_require__(90); +var GameObject = __webpack_require__(19); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); var MATH_CONST = __webpack_require__(16); -var Render = __webpack_require__(463); +var Render = __webpack_require__(831); /** * Graphics line style (or stroke style) settings. * * @typedef {object} GraphicsLineStyle * - * @property {number} width - The stroke width. - * @property {number} color - The stroke color. - * @property {number} alpha - The stroke alpha. + * @property {number} [width] - The stroke width. + * @property {number} [color] - The stroke color. + * @property {number} [alpha] - The stroke alpha. */ /** @@ -22731,8 +32859,8 @@ var Render = __webpack_require__(463); * * @typedef {object} GraphicsFillStyle * - * @property {number} color - The fill color. - * @property {number} alpha - The fill alpha. + * @property {number} [color] - The fill color. + * @property {number} [alpha] - The fill alpha. */ /** @@ -22740,8 +32868,8 @@ var Render = __webpack_require__(463); * * @typedef {object} GraphicsStyles * - * @property {GraphicsLineStyle} lineStyle - The style applied to shape outlines. - * @property {GraphicsFillStyle} fillStyle - The style applied to shape areas. + * @property {GraphicsLineStyle} [lineStyle] - The style applied to shape outlines. + * @property {GraphicsFillStyle} [fillStyle] - The style applied to shape areas. */ /** @@ -22750,13 +32878,13 @@ var Render = __webpack_require__(463); * @typedef {object} GraphicsOptions * @extends GraphicsStyles * - * @property {number} x - The x coordinate of the Graphics. - * @property {number} y - The y coordinate of the Graphics. + * @property {number} [x] - The x coordinate of the Graphics. + * @property {number} [y] - The y coordinate of the Graphics. */ /** * @classdesc - * A Graphics object is a way to draw primitive shapes to you game. Primitives include forms of geometry, such as + * A Graphics object is a way to draw primitive shapes to your game. Primitives include forms of geometry, such as * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics * object it will be empty. * @@ -22797,7 +32925,7 @@ var Render = __webpack_require__(463); * * @class Graphics * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -22811,21 +32939,21 @@ var Render = __webpack_require__(463); * @extends Phaser.GameObjects.Components.ScrollFactor * * @param {Phaser.Scene} scene - The Scene to which this Graphics object belongs. - * @param {GraphicsOptions} options - Options that set the position and default style of this Graphics object. + * @param {GraphicsOptions} [options] - Options that set the position and default style of this Graphics object. */ var Graphics = new Class({ Extends: GameObject, Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Pipeline, - Components.Transform, - Components.Visible, - Components.ScrollFactor, + ComponentsAlpha, + ComponentsBlendMode, + ComponentsDepth, + ComponentsMask, + ComponentsPipeline, + ComponentsTransform, + ComponentsVisible, + ComponentsScrollFactor, Render ], @@ -22839,7 +32967,7 @@ var Graphics = new Class({ GameObject.call(this, scene, 'Graphics'); this.setPosition(x, y); - this.initPipeline('FlatTintPipeline'); + this.initPipeline(); /** * The horizontal display origin of the Graphics. @@ -23015,6 +33143,139 @@ var Graphics = new Class({ return this; }, + /** + * Sets a gradient fill style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all filled shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. + * + * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. + * + * This feature is best used only on rectangles and triangles. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#fillGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {integer} topLeft - The tint being applied to the top-left of the Game Object. + * @param {integer} topRight - The tint being applied to the top-right of the Game Object. + * @param {integer} bottomLeft - The tint being applied to the bottom-left of the Game Object. + * @param {integer} bottomRight - The tint being applied to the bottom-right of the Game Object. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillGradientStyle: function (topLeft, topRight, bottomLeft, bottomRight, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.GRADIENT_FILL_STYLE, + alpha, topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Sets a gradient line style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all stroked shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. + * + * This feature is best used only on single lines. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#lineGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {number} lineWidth - The stroke width. + * @param {integer} topLeft - The tint being applied to the top-left of the Game Object. + * @param {integer} topRight - The tint being applied to the top-right of the Game Object. + * @param {integer} bottomLeft - The tint being applied to the bottom-left of the Game Object. + * @param {integer} bottomRight - The tint being applied to the bottom-right of the Game Object. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineGradientStyle: function (lineWidth, topLeft, topRight, bottomLeft, bottomRight, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.GRADIENT_LINE_STYLE, + lineWidth, alpha, topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Sets the texture frame this Graphics Object will use when drawing all shapes defined after calling this. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Once set, all shapes will use this texture. Call this method with no arguments to clear it. + * + * The textures are not tiled. They are stretched to the dimensions of the shapes being rendered. For this reason, + * it works best with seamless / tileable textures. + * + * The mode argument controls how the textures are combined with the fill colors. The default value (0) will + * multiply the texture by the fill color. A value of 1 will use just the fill color, but the alpha data from the texture, + * and a value of 2 will use just the texture and no fill color at all. + * + * @method Phaser.GameObjects.Graphics#setTexture + * @since 3.12.0 + * @webglOnly + * + * @param {string} [key] - The key of the texture to be used, as stored in the Texture Manager. Leave blank to clear a previously set texture. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} [mode=0] - The texture tint mode. 0 is multiply, 1 is alpha only and 2 is texture only. + * + * @return {this} This Game Object. + */ + setTexture: function (key, frame, mode) + { + if (mode === undefined) { mode = 0; } + + if (key === undefined) + { + this.commandBuffer.push( + Commands.CLEAR_TEXTURE + ); + } + else + { + var textureFrame = this.scene.sys.textures.getFrame(key, frame); + + if (textureFrame) + { + if (mode === 2) + { + mode = 3; + } + + this.commandBuffer.push( + Commands.SET_TEXTURE, + textureFrame, + mode + ); + } + } + + return this; + }, + /** * Start a new shape path. * @@ -23250,6 +33511,106 @@ var Graphics = new Class({ return this; }, + /** + * Fill a rounded rectangle with the given position, size and radius. + * + * @method Phaser.GameObjects.Graphics#fillRoundedRect + * @since 3.11.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {number} [radius = 20] - The corner radius; It can also be an object to specify different radii for corners + * @param {number} [radius.tl = 20] Top left + * @param {number} [radius.tr = 20] Top right + * @param {number} [radius.br = 20] Bottom right + * @param {number} [radius.bl = 20] Bottom left + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillRoundedRect: function (x, y, width, height, radius) + { + if (radius === undefined) { radius = 20; } + + var tl = radius; + var tr = radius; + var bl = radius; + var br = radius; + + if (typeof radius !== 'number') + { + tl = GetFastValue(radius, 'tl', 20); + tr = GetFastValue(radius, 'tr', 20); + bl = GetFastValue(radius, 'bl', 20); + br = GetFastValue(radius, 'br', 20); + } + + this.beginPath(); + this.moveTo(x + tl, y); + this.lineTo(x + width - tr, y); + this.arc(x + width - tr, y + tr, tr, -MATH_CONST.TAU, 0); + this.lineTo(x + width, y + height - br); + this.arc(x + width - br, y + height - br, br, 0, MATH_CONST.TAU); + this.lineTo(x + bl, y + height); + this.arc(x + bl, y + height - bl, bl, MATH_CONST.TAU, Math.PI); + this.lineTo(x, y + tl); + this.arc(x + tl, y + tl, tl, -Math.PI, -MATH_CONST.TAU); + this.fillPath(); + + return this; + }, + + /** + * Stroke a rounded rectangle with the given position, size and radius. + * + * @method Phaser.GameObjects.Graphics#strokeRoundedRect + * @since 3.11.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {number} [radius = 20] - The corner radius; It can also be an object to specify different radii for corners + * @param {number} [radius.tl = 20] Top left + * @param {number} [radius.tr = 20] Top right + * @param {number} [radius.br = 20] Bottom right + * @param {number} [radius.bl = 20] Bottom left + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeRoundedRect: function (x, y, width, height, radius) + { + if (radius === undefined) { radius = 20; } + + var tl = radius; + var tr = radius; + var bl = radius; + var br = radius; + + if (typeof radius !== 'number') + { + tl = GetFastValue(radius, 'tl', 20); + tr = GetFastValue(radius, 'tr', 20); + bl = GetFastValue(radius, 'bl', 20); + br = GetFastValue(radius, 'br', 20); + } + + this.beginPath(); + this.moveTo(x + tl, y); + this.lineTo(x + width - tr, y); + this.arc(x + width - tr, y + tr, tr, -MATH_CONST.TAU, 0); + this.lineTo(x + width, y + height - br); + this.arc(x + width - br, y + height - br, br, 0, MATH_CONST.TAU); + this.lineTo(x + bl, y + height); + this.arc(x + bl, y + height - bl, bl, MATH_CONST.TAU, Math.PI); + this.lineTo(x, y + tl); + this.arc(x + tl, y + tl, tl, -Math.PI, -MATH_CONST.TAU); + this.strokePath(); + + return this; + }, + /** * Fill the given point. * @@ -23680,6 +34041,13 @@ var Graphics = new Class({ * Draw an arc. * * This method can be used to create circles, or parts of circles. + * + * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically + * close when filled or stroked. + * + * Use the optional `overshoot` argument increase the number of iterations that take place when + * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, + * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. * * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling * this method to draw the arc. @@ -23693,14 +34061,18 @@ var Graphics = new Class({ * @param {number} startAngle - The starting angle, in radians. * @param {number} endAngle - The ending angle, in radians. * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. * * @return {Phaser.GameObjects.Graphics} This Game Object. */ - arc: function (x, y, radius, startAngle, endAngle, anticlockwise) + arc: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) { + if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } + this.commandBuffer.push( Commands.ARC, - x, y, radius, startAngle, endAngle, anticlockwise + x, y, radius, startAngle, endAngle, anticlockwise, overshoot ); return this; @@ -23724,19 +34096,21 @@ var Graphics = new Class({ * @param {number} radius - The radius of the slice. * @param {number} startAngle - The start angle of the slice, given in radians. * @param {number} endAngle - The end angle of the slice, given in radians. - * @param {boolean} [anticlockwise=false] - Draw the slice piece anticlockwise or clockwise? + * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. * * @return {Phaser.GameObjects.Graphics} This Game Object. */ - slice: function (x, y, radius, startAngle, endAngle, anticlockwise) + slice: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) { if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } this.commandBuffer.push(Commands.BEGIN_PATH); this.commandBuffer.push(Commands.MOVE_TO, x, y); - this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise); + this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise, overshoot); this.commandBuffer.push(Commands.CLOSE_PATH); @@ -23744,7 +34118,9 @@ var Graphics = new Class({ }, /** - * [description] + * Saves the state of the Graphics by pushing the current state onto a stack. + * + * The most recently saved state can then be restored with {@link Phaser.GameObjects.Graphics#restore}. * * @method Phaser.GameObjects.Graphics#save * @since 3.0.0 @@ -23761,7 +34137,11 @@ var Graphics = new Class({ }, /** - * [description] + * Restores the most recently saved state of the Graphics by popping from the state stack. + * + * Use {@link Phaser.GameObjects.Graphics#save} to save the current state, and call this afterwards to restore that state. + * + * If there is no saved state, this command does nothing. * * @method Phaser.GameObjects.Graphics#restore * @since 3.0.0 @@ -23885,10 +34265,12 @@ var Graphics = new Class({ generateTexture: function (key, width, height) { var sys = this.scene.sys; + var renderer = sys.game.renderer; if (width === undefined) { width = sys.game.config.width; } if (height === undefined) { height = sys.game.config.height; } + Graphics.TargetCamera.setScene(this.scene); Graphics.TargetCamera.setViewport(0, 0, width, height); Graphics.TargetCamera.scrollX = this.x; Graphics.TargetCamera.scrollY = this.y; @@ -23929,11 +34311,12 @@ var Graphics = new Class({ if (ctx) { - this.renderCanvas(sys.game.renderer, this, 0.0, Graphics.TargetCamera, null, ctx); + // var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) + this.renderCanvas(renderer, this, 0, Graphics.TargetCamera, null, ctx, false); - if (sys.game.renderer.gl && texture) + if (texture) { - texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture); + texture.refresh(); } } @@ -23961,13 +34344,1839 @@ var Graphics = new Class({ * @type {Phaser.Cameras.Scene2D.Camera} * @since 3.1.0 */ -Graphics.TargetCamera = new Camera(0, 0, 0, 0); +Graphics.TargetCamera = new BaseCamera(); module.exports = Graphics; /***/ }), -/* 116 */ +/* 159 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(109); +var Class = __webpack_require__(0); +var Render = __webpack_require__(834); + +/** + * @typedef {object} DisplayCallbackConfig + * + * @property {{topLeft:number, topRight:number, bottomLeft:number, bottomRight:number}} tint - The tint of the character being rendered. + * @property {number} index - The index of the character being rendered. + * @property {number} charCode - The character code of the character being rendered. + * @property {number} x - The x position of the character being rendered. + * @property {number} y - The y position of the character being rendered. + * @property {number} scale - The scale of the character being rendered. + * @property {number} rotation - The rotation of the character being rendered. + * @property {any} data - Custom data stored with the character being rendered. + */ + +/** + * @callback DisplayCallback + * + * @param {DisplayCallbackConfig} display - Settings of the character that is about to be rendered. + * + * @return {{x:number, y:number, scale:number, rotation:number}} Altered position, scale and rotation values for the character that is about to be rendered. + */ + +/** + * @classdesc + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * @class DynamicBitmapText + * @extends Phaser.GameObjects.BitmapText + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} x - The x coordinate of this Game Object in world space. + * @param {number} y - The y coordinate of this Game Object in world space. + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size of this Bitmap Text. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. + */ +var DynamicBitmapText = new Class({ + + Extends: BitmapText, + + Mixins: [ + Render + ], + + initialize: + + function DynamicBitmapText (scene, x, y, font, text, size, align) + { + BitmapText.call(this, scene, x, y, font, text, size, align); + + this.type = 'DynamicBitmapText'; + + /** + * The horizontal scroll position of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollX = 0; + + /** + * The vertical scroll position of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollY = 0; + + /** + * The crop width of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#cropWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropWidth = 0; + + /** + * The crop height of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#cropHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropHeight = 0; + + /** + * A callback that alters how each character of the Bitmap Text is rendered. + * + * @name Phaser.GameObjects.DynamicBitmapText#displayCallback + * @type {DisplayCallback} + * @since 3.0.0 + */ + this.displayCallback; + + /** + * The data object that is populated during rendering, then passed to the displayCallback. + * You should modify this object then return it back from the callback. It's updated values + * will be used to render the specific glyph. + * + * Please note that if you need a reference to this object locally in your game code then you + * should shallow copy it, as it's updated and re-used for every glyph in the text. + * + * @name Phaser.GameObjects.DynamicBitmapText#callbackData + * @type {DisplayCallbackConfig} + * @since 3.11.0 + */ + this.callbackData = { + color: 0, + tint: { + topLeft: 0, + topRight: 0, + bottomLeft: 0, + bottomRight: 0 + }, + index: 0, + charCode: 0, + x: 0, + y: 0, + scale: 0, + rotation: 0, + data: 0 + }; + }, + + /** + * Set the crop size of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setSize + * @since 3.0.0 + * + * @param {number} width - The width of the crop. + * @param {number} height - The height of the crop. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setSize: function (width, height) + { + this.cropWidth = width; + this.cropHeight = height; + + return this; + }, + + /** + * Set a callback that alters how each character of the Bitmap Text is rendered. + * + * The callback receives a {@link DisplayCallbackConfig} object that contains information about the character that's + * about to be rendered. + * + * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the + * usual values when rendering. + * + * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback + * @since 3.0.0 + * + * @param {DisplayCallback} callback - The display callback to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setDisplayCallback: function (callback) + { + this.displayCallback = callback; + + return this; + }, + + /** + * Set the horizontal scroll position of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollX + * @since 3.0.0 + * + * @param {number} value - The horizontal scroll position to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollX: function (value) + { + this.scrollX = value; + + return this; + }, + + /** + * Set the vertical scroll position of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollY + * @since 3.0.0 + * + * @param {number} value - The vertical scroll position to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollY: function (value) + { + this.scrollY = value; + + return this; + } + +}); + +module.exports = DynamicBitmapText; + + +/***/ }), +/* 160 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayUtils = __webpack_require__(164); +var BlendModes = __webpack_require__(66); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var Rectangle = __webpack_require__(9); +var Render = __webpack_require__(837); +var Union = __webpack_require__(309); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Container Game Object. + * + * 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. + * + * The position of the Game Object automatically becomes relative to the position of the Container. + * + * When the Container is rendered, all of its children are rendered as well, in the order in which they exist + * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. + * + * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will + * automatically influence all children as well. + * + * Containers can include other Containers for deeply nested transforms. + * + * Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked. + * The masks do not 'stack up'. Only a Container on the root of the display list will use its mask. + * + * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them + * to use as their hit area. Container children can also be enabled for input, independent of the Container. + * + * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, + * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, + * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children + * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure + * your game to work around this. + * + * It's important to understand the impact of using Containers. They add additional processing overhead into + * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true + * for input events. You also loose the ability to set the display depth of Container children in the same + * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost + * every time you create one, try to structure your game around avoiding that where possible. + * + * @class Container + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.4.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. + */ +var Container = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Mask, + Components.ScrollFactor, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function Container (scene, x, y, children) + { + GameObject.call(this, scene, 'Container'); + + /** + * An array holding the children of this Container. + * + * @name Phaser.GameObjects.Container#list + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.4.0 + */ + this.list = []; + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * + * @name Phaser.GameObjects.Container#exclusive + * @type {boolean} + * @default true + * @since 3.4.0 + */ + this.exclusive = true; + + /** + * Containers can have an optional maximum size. If set to anything above 0 it + * will constrict the addition of new Game Objects into the Container, capping off + * the maximum limit the Container can grow in size to. + * + * @name Phaser.GameObjects.Container#maxSize + * @type {integer} + * @default -1 + * @since 3.4.0 + */ + this.maxSize = -1; + + /** + * The cursor position. + * + * @name Phaser.GameObjects.Container#position + * @type {integer} + * @since 3.4.0 + */ + this.position = 0; + + /** + * Internal Transform Matrix used for local space conversion. + * + * @name Phaser.GameObjects.Container#localTransform + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.4.0 + */ + this.localTransform = new Components.TransformMatrix(); + + /** + * Internal temporary Transform Matrix used to avoid object creation. + * + * @name Phaser.GameObjects.Container#tempTransformMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.4.0 + */ + this.tempTransformMatrix = new Components.TransformMatrix(); + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.Container#_displayList + * @type {Phaser.GameObjects.DisplayList} + * @private + * @since 3.4.0 + */ + this._displayList = scene.sys.displayList; + + /** + * The property key to sort by. + * + * @name Phaser.GameObjects.Container#_sortKey + * @type {string} + * @private + * @since 3.4.0 + */ + this._sortKey = ''; + + /** + * A reference to the Scene Systems Event Emitter. + * + * @name Phaser.GameObjects.Container#_sysEvents + * @type {Phaser.Events.EventEmitter} + * @private + * @since 3.9.0 + */ + this._sysEvents = scene.sys.events; + + this.setPosition(x, y); + + this.clearAlpha(); + + this.setBlendMode(BlendModes.SKIP_CHECK); + + if (children) + { + this.add(children); + } + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#originX + * @type {number} + * @readonly + * @since 3.4.0 + */ + originX: { + + get: function () + { + return 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#originY + * @type {number} + * @readonly + * @since 3.4.0 + */ + originY: { + + get: function () + { + return 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#displayOriginX + * @type {number} + * @readonly + * @since 3.4.0 + */ + displayOriginX: { + + get: function () + { + return this.width * 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#displayOriginY + * @type {number} + * @readonly + * @since 3.4.0 + */ + displayOriginY: { + + get: function () + { + return this.height * 0.5; + } + + }, + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * + * @method Phaser.GameObjects.Container#setExclusive + * @since 3.4.0 + * + * @param {boolean} [value=true] - The exclusive state of this Container. + * + * @return {Phaser.GameObjects.Container} This Container. + */ + setExclusive: function (value) + { + if (value === undefined) { value = true; } + + this.exclusive = value; + + return this; + }, + + /** + * Gets the bounds of this Container. It works by iterating all children of the Container, + * getting their respective bounds, and then working out a min-max rectangle from that. + * It does not factor in if the children render or not, all are included. + * + * Some children are unable to return their bounds, such as Graphics objects, in which case + * they are skipped. + * + * Depending on the quantity of children in this Container it could be a really expensive call, + * so cache it and only poll it as needed. + * + * The values are stored and returned in a Rectangle object. + * + * @method Phaser.GameObjects.Container#getBounds + * @since 3.4.0 + * + * @param {Phaser.Geom.Rectangle} [output] - A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + output.setTo(this.x, this.y, 0, 0); + + if (this.list.length > 0) + { + var children = this.list; + var tempRect = new Rectangle(); + + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (entry.getBounds) + { + entry.getBounds(tempRect); + + Union(tempRect, output, output); + } + } + } + + return output; + }, + + /** + * Internal add handler. + * + * @method Phaser.GameObjects.Container#addHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just added to this Container. + */ + addHandler: function (gameObject) + { + gameObject.once('destroy', this.remove, this); + + if (this.exclusive) + { + this._displayList.remove(gameObject); + + if (gameObject.parentContainer) + { + gameObject.parentContainer.remove(gameObject); + } + + gameObject.parentContainer = this; + } + }, + + /** + * Internal remove handler. + * + * @method Phaser.GameObjects.Container#removeHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just removed from this Container. + */ + removeHandler: function (gameObject) + { + gameObject.off('destroy', this.remove); + + if (this.exclusive) + { + gameObject.parentContainer = null; + } + }, + + /** + * Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties, + * and transforms it into the space of this Container, then returns it in the output object. + * + * @method Phaser.GameObjects.Container#pointToContainer + * @since 3.4.0 + * + * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} source - The Source Point to be transformed. + * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} [output] - A destination object to store the transformed point in. If none given a Vector2 will be created and returned. + * + * @return {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} The transformed point. + */ + pointToContainer: function (source, output) + { + if (output === undefined) { output = new Vector2(); } + + if (this.parentContainer) + { + return this.parentContainer.pointToContainer(source, output); + } + + var tempMatrix = this.tempTransformMatrix; + + // No need to loadIdentity because applyITRS overwrites every value anyway + tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY); + + tempMatrix.invert(); + + tempMatrix.transformPoint(source.x, source.y, output); + + return output; + }, + + /** + * Returns the world transform matrix as used for Bounds checks. + * + * The returned matrix is temporal and shouldn't be stored. + * + * @method Phaser.GameObjects.Container#getBoundsTransformMatrix + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The world transform matrix. + */ + getBoundsTransformMatrix: function () + { + return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform); + }, + + /** + * Adds the given Game Object, or array of Game Objects, to this Container. + * + * Each Game Object must be unique within the Container. + * + * @method Phaser.GameObjects.Container#add + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + add: function (child) + { + ArrayUtils.Add(this.list, child, this.maxSize, this.addHandler, this); + + return this; + }, + + /** + * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. + * + * Existing Game Objects in the Container are shifted up. + * + * Each Game Object must be unique within the Container. + * + * @method Phaser.GameObjects.Container#addAt + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. + * @param {integer} [index=0] - The position to insert the Game Object/s at. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + addAt: function (child, index) + { + ArrayUtils.AddAt(this.list, child, index, this.maxSize, this.addHandler, this); + + return this; + }, + + /** + * Returns the Game Object at the given position in this Container. + * + * @method Phaser.GameObjects.Container#getAt + * @since 3.4.0 + * + * @param {integer} index - The position to get the Game Object from. + * + * @return {?Phaser.GameObjects.GameObject} The Game Object at the specified index, or `null` if none found. + */ + getAt: function (index) + { + return this.list[index]; + }, + + /** + * Returns the index of the given Game Object in this Container. + * + * @method Phaser.GameObjects.Container#getIndex + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to search for in this Container. + * + * @return {integer} The index of the Game Object in this Container, or -1 if not found. + */ + getIndex: function (child) + { + return this.list.indexOf(child); + }, + + /** + * Sort the contents of this Container so the items are in order based on the given property. + * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. + * + * @method Phaser.GameObjects.Container#sort + * @since 3.4.0 + * + * @param {string} property - The property to lexically sort by. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + sort: function (property) + { + if (property) + { + this._sortKey = property; + + ArrayUtils.StableSort.inplace(this.list, this.sortHandler); + } + + return this; + }, + + /** + * Internal sort handler method. + * + * @method Phaser.GameObjects.Container#sortHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} childA - The first child to sort. + * @param {Phaser.GameObjects.GameObject} childB - The second child to sort. + * + * @return {integer} The sort results. + */ + sortHandler: function (childA, childB) + { + return childA[this._sortKey] - childB[this._sortKey]; + }, + + /** + * Searches for the first instance of a child with its `name` property matching the given argument. + * Should more than one child have the same name only the first is returned. + * + * @method Phaser.GameObjects.Container#getByName + * @since 3.4.0 + * + * @param {string} name - The name to search for. + * + * @return {?Phaser.GameObjects.GameObject} The first child with a matching name, or `null` if none were found. + */ + getByName: function (name) + { + return ArrayUtils.GetFirst(this.list, 'name', name); + }, + + /** + * Returns a random Game Object from this Container. + * + * @method Phaser.GameObjects.Container#getRandom + * @since 3.4.0 + * + * @param {integer} [startIndex=0] - An optional start index. + * @param {integer} [length] - An optional length, the total number of elements (from the startIndex) to choose from. + * + * @return {?Phaser.GameObjects.GameObject} A random child from the Container, or `null` if the Container is empty. + */ + getRandom: function (startIndex, length) + { + return ArrayUtils.GetRandom(this.list, startIndex, length); + }, + + /** + * Gets the first Game Object in this Container. + * + * You can also specify a property and value to search for, in which case it will return the first + * Game Object in this Container with a matching property and / or value. + * + * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. + * + * You can limit the search to the `startIndex` - `endIndex` range. + * + * @method Phaser.GameObjects.Container#getFirst + * @since 3.4.0 + * + * @param {string} [property] - The property to test on each Game Object in the Container. + * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {?Phaser.GameObjects.GameObject} The first matching Game Object, or `null` if none was found. + */ + getFirst: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns all Game Objects in this Container. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('body')` would return only Game Objects that have a body property. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * + * @method Phaser.GameObjects.Container#getAll + * @since 3.4.0 + * + * @param {string} [property] - The property to test on each Game Object in the Container. + * @param {any} [value] - If property is set then the `property` must strictly equal this value to be included in the results. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {Phaser.GameObjects.GameObject[]} An array of matching Game Objects from this Container. + */ + getAll: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns the total number of Game Objects in this Container that have a property + * matching the given value. + * + * For example: `count('visible', true)` would count all the elements that have their visible property set. + * + * You can optionally limit the operation to the `startIndex` - `endIndex` range. + * + * @method Phaser.GameObjects.Container#count + * @since 3.4.0 + * + * @param {string} property - The property to check. + * @param {any} value - The value to check. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {integer} The total number of Game Objects in this Container with a property matching the given value. + */ + count: function (property, value, startIndex, endIndex) + { + return ArrayUtils.CountAllMatching(this.list, property, value, startIndex, endIndex); + }, + + /** + * Swaps the position of two Game Objects in this Container. + * Both Game Objects must belong to this Container. + * + * @method Phaser.GameObjects.Container#swap + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child1 - The first Game Object to swap. + * @param {Phaser.GameObjects.GameObject} child2 - The second Game Object to swap. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + swap: function (child1, child2) + { + ArrayUtils.Swap(this.list, child1, child2); + + return this; + }, + + /** + * Moves a Game Object to a new position within this Container. + * + * The Game Object must already be a child of this Container. + * + * The Game Object is removed from its old position and inserted into the new one. + * Therefore the Container size does not change. Other children will change position accordingly. + * + * @method Phaser.GameObjects.Container#moveTo + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to move. + * @param {integer} index - The new position of the Game Object in this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + moveTo: function (child, index) + { + ArrayUtils.MoveTo(this.list, child, index); + + return this; + }, + + /** + * Removes the given Game Object, or array of Game Objects, from this Container. + * + * The Game Objects must already be children of this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#remove + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to be removed from the Container. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each child successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + remove: function (child, destroyChild) + { + var removed = ArrayUtils.Remove(this.list, child, this.removeHandler, this); + + if (destroyChild && removed) + { + if (!Array.isArray(removed)) + { + removed = [ removed ]; + } + + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Removes the Game Object at the given position in this Container. + * + * You can also optionally call `destroy` on the Game Object, if one is found. + * + * @method Phaser.GameObjects.Container#removeAt + * @since 3.4.0 + * + * @param {integer} index - The index of the Game Object to be removed. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + removeAt: function (index, destroyChild) + { + var removed = ArrayUtils.RemoveAt(this.list, index, this.removeHandler, this); + + if (destroyChild && removed) + { + removed.destroy(); + } + + return this; + }, + + /** + * Removes the Game Objects between the given positions in this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#removeBetween + * @since 3.4.0 + * + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + removeBetween: function (startIndex, endIndex, destroyChild) + { + var removed = ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeHandler, this); + + if (destroyChild) + { + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Removes all Game Objects from this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#removeAll + * @since 3.4.0 + * + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + removeAll: function (destroyChild) + { + var removed = ArrayUtils.RemoveBetween(this.list, 0, this.list.length, this.removeHandler, this); + + if (destroyChild) + { + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Brings the given Game Object to the top of this Container. + * This will cause it to render on-top of any other objects in the Container. + * + * @method Phaser.GameObjects.Container#bringToTop + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to bring to the top of the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + bringToTop: function (child) + { + ArrayUtils.BringToTop(this.list, child); + + return this; + }, + + /** + * Sends the given Game Object to the bottom of this Container. + * This will cause it to render below any other objects in the Container. + * + * @method Phaser.GameObjects.Container#sendToBack + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to send to the bottom of the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + sendToBack: function (child) + { + ArrayUtils.SendToBack(this.list, child); + + return this; + }, + + /** + * Moves the given Game Object up one place in this Container, unless it's already at the top. + * + * @method Phaser.GameObjects.Container#moveUp + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + moveUp: function (child) + { + ArrayUtils.MoveUp(this.list, child); + + return this; + }, + + /** + * Moves the given Game Object down one place in this Container, unless it's already at the bottom. + * + * @method Phaser.GameObjects.Container#moveDown + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + moveDown: function (child) + { + ArrayUtils.MoveDown(this.list, child); + + return this; + }, + + /** + * Reverses the order of all Game Objects in this Container. + * + * @method Phaser.GameObjects.Container#reverse + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + reverse: function () + { + this.list.reverse(); + + return this; + }, + + /** + * Shuffles the all Game Objects in this Container using the Fisher-Yates implementation. + * + * @method Phaser.GameObjects.Container#shuffle + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + shuffle: function () + { + ArrayUtils.Shuffle(this.list); + + return this; + }, + + /** + * Replaces a Game Object in this Container with the new Game Object. + * The new Game Object cannot already be a child of this Container. + * + * @method Phaser.GameObjects.Container#replace + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} oldChild - The Game Object in this Container that will be replaced. + * @param {Phaser.GameObjects.GameObject} newChild - The Game Object to be added to this Container. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + replace: function (oldChild, newChild, destroyChild) + { + var moved = ArrayUtils.Replace(this.list, oldChild, newChild); + + if (moved) + { + this.addHandler(newChild); + this.removeHandler(oldChild); + + if (destroyChild) + { + oldChild.destroy(); + } + } + + return this; + }, + + /** + * Returns `true` if the given Game Object is a direct child of this Container. + * + * This check does not scan nested Containers. + * + * @method Phaser.GameObjects.Container#exists + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to check for within this Container. + * + * @return {boolean} True if the Game Object is an immediate child of this Container, otherwise false. + */ + exists: function (child) + { + return (this.list.indexOf(child) > -1); + }, + + /** + * Sets the property to the given value on all Game Objects in this Container. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * + * @method Phaser.GameObjects.Container#setAll + * @since 3.4.0 + * + * @param {string} property - The property that must exist on the Game Object. + * @param {any} value - The value to get the property to. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + setAll: function (property, value, startIndex, endIndex) + { + ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); + + return this; + }, + + /** + * @callback EachContainerCallback + * @generic I - [item] + * + * @param {*} item - The child Game Object of the Container. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + + /** + * Passes all Game Objects in this Container to the given callback. + * + * A copy of the Container is made before passing each entry to your callback. + * This protects against the callback itself modifying the Container. + * + * If you know for sure that the callback will not change the size of this Container + * then you can use the more performant `Container.iterate` method instead. + * + * @method Phaser.GameObjects.Container#each + * @since 3.4.0 + * + * @param {function} callback - The function to call. + * @param {object} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + each: function (callback, context) + { + var args = [ null ]; + var i; + var temp = this.list.slice(); + var len = temp.length; + + for (i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < len; i++) + { + args[0] = temp[i]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Passes all Game Objects in this Container to the given callback. + * + * Only use this method when you absolutely know that the Container will not be modified during + * the iteration, i.e. by removing or adding to its contents. + * + * @method Phaser.GameObjects.Container#iterate + * @since 3.4.0 + * + * @param {function} callback - The function to call. + * @param {object} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + iterate: function (callback, context) + { + var args = [ null ]; + var i; + + for (i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < this.list.length; i++) + { + args[0] = this.list[i]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * The number of Game Objects inside this Container. + * + * @name Phaser.GameObjects.Container#length + * @type {integer} + * @readonly + * @since 3.4.0 + */ + length: { + + get: function () + { + return this.list.length; + } + + }, + + /** + * Returns the first Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#first + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + first: { + + get: function () + { + this.position = 0; + + if (this.list.length > 0) + { + return this.list[0]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the last Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#last + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + last: { + + get: function () + { + if (this.list.length > 0) + { + this.position = this.list.length - 1; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the next Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#next + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + next: { + + get: function () + { + if (this.position < this.list.length) + { + this.position++; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the previous Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#previous + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + previous: { + + get: function () + { + if (this.position > 0) + { + this.position--; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Container#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.removeAll(!!this.exclusive); + + this.localTransform.destroy(); + this.tempTransformMatrix.destroy(); + + this.list = []; + this._displayList = null; + } + +}); + +module.exports = Container; + + +/***/ }), +/* 161 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlitterRender = __webpack_require__(841); +var Bob = __webpack_require__(838); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var Frame = __webpack_require__(113); +var GameObject = __webpack_require__(19); +var List = __webpack_require__(112); + +/** + * @callback Phaser.GameObjects.Blitter.CreateCallback + * + * @param {Phaser.GameObjects.Blitter.Bob} bob - The Bob that was created by the Blitter. + * @param {integer} index - The position of the Bob within the Blitter display list. + */ + +/** + * @classdesc + * A Blitter Game Object. + * + * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. + * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, + * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed + * during rendering. + * + * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this + * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows + * them their speed. + * + * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth + * investigating. They are especially useful for using as a base for your own special effects systems. + * + * @class Blitter + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. + * @param {(string|integer)} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. + */ +var Blitter = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Mask, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + BlitterRender + ], + + initialize: + + function Blitter (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Blitter'); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.initPipeline(); + + /** + * The children of this Blitter. + * This List contains all of the Bob objects created by the Blitter. + * + * @name Phaser.GameObjects.Blitter#children + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.children = new List(); + + /** + * A transient array that holds all of the Bobs that will be rendered this frame. + * The array is re-populated whenever the dirty flag is set. + * + * @name Phaser.GameObjects.Blitter#renderList + * @type {Phaser.GameObjects.Blitter.Bob[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.renderList = []; + + /** + * Is the Blitter considered dirty? + * A 'dirty' Blitter has had its child count changed since the last frame. + * + * @name Phaser.GameObjects.Blitter#dirty + * @type {boolean} + * @since 3.0.0 + */ + this.dirty = false; + }, + + /** + * Creates a new Bob in this Blitter. + * + * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. + * A Bob can use any frame belonging to the texture bound to the Blitter. + * + * @method Phaser.GameObjects.Blitter#create + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. + * + * @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object. + */ + create: function (x, y, frame, visible, index) + { + if (visible === undefined) { visible = true; } + if (index === undefined) { index = this.children.length; } + + if (frame === undefined) + { + frame = this.frame; + } + else if (!(frame instanceof Frame)) + { + frame = this.texture.get(frame); + } + + var bob = new Bob(this, x, y, frame, visible); + + this.children.addAt(bob, index, false); + + this.dirty = true; + + return bob; + }, + + /** + * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. + * + * @method Phaser.GameObjects.Blitter#createFromCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter.CreateCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createFromCallback: function (callback, quantity, frame, visible) + { + var bobs = this.createMultiple(quantity, frame, visible); + + for (var i = 0; i < bobs.length; i++) + { + var bob = bobs[i]; + + callback.call(this, bob, i); + } + + return bobs; + }, + + /** + * Creates multiple Bobs in one call. + * + * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. + * + * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first + * frame and 10 with the second. + * + * @method Phaser.GameObjects.Blitter#createMultiple + * @since 3.0.0 + * + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createMultiple: function (quantity, frame, visible) + { + if (frame === undefined) { frame = this.frame.name; } + if (visible === undefined) { visible = true; } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + + var bobs = []; + var _this = this; + + frame.forEach(function (singleFrame) + { + for (var i = 0; i < quantity; i++) + { + bobs.push(_this.create(0, 0, singleFrame, visible)); + } + }); + + return bobs; + }, + + /** + * Checks if the given child can render or not, by checking its `visible` and `alpha` values. + * + * @method Phaser.GameObjects.Blitter#childCanRender + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter.Bob} child - The Bob to check for rendering. + * + * @return {boolean} Returns `true` if the given child can render, otherwise `false`. + */ + childCanRender: function (child) + { + return (child.visible && child.alpha > 0); + }, + + /** + * Returns an array of Bobs to be rendered. + * If the Blitter is dirty then a new list is generated and stored in `renderList`. + * + * @method Phaser.GameObjects.Blitter#getRenderList + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that will be rendered this frame. + */ + getRenderList: function () + { + if (this.dirty) + { + this.renderList = this.children.list.filter(this.childCanRender, this); + this.dirty = false; + } + + return this.renderList; + }, + + /** + * Removes all Bobs from the children List and clears the dirty flag. + * + * @method Phaser.GameObjects.Blitter#clear + * @since 3.0.0 + */ + clear: function () + { + this.children.removeAll(); + this.dirty = true; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Blitter#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.children.destroy(); + + this.renderList = []; + } + +}); + +module.exports = Blitter; + + +/***/ }), +/* 162 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns a Random element from the array. + * + * @function Phaser.Utils.Array.GetRandom + * @since 3.0.0 + * + * @param {array} array - The array to select the random entry from. + * @param {integer} [startIndex=0] - An optional start index. + * @param {integer} [length=array.length] - An optional length, the total number of elements (from the startIndex) to choose from. + * + * @return {*} A random element from the array, or `null` if no element could be found in the range given. + */ +var GetRandom = function (array, startIndex, length) +{ + if (startIndex === undefined) { startIndex = 0; } + if (length === undefined) { length = array.length; } + + var randomIndex = startIndex + Math.floor(Math.random() * length); + + return (array[randomIndex] === undefined) ? null : array[randomIndex]; +}; + +module.exports = GetRandom; + + +/***/ }), +/* 163 */ /***/ (function(module, exports) { /** @@ -24025,7 +36234,60 @@ module.exports = CheckMatrix; /***/ }), -/* 117 */ +/* 164 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.Array + */ + +module.exports = { + + Matrix: __webpack_require__(874), + + Add: __webpack_require__(867), + AddAt: __webpack_require__(866), + BringToTop: __webpack_require__(865), + CountAllMatching: __webpack_require__(864), + Each: __webpack_require__(863), + EachInRange: __webpack_require__(862), + FindClosestInSorted: __webpack_require__(383), + GetAll: __webpack_require__(861), + GetFirst: __webpack_require__(860), + GetRandom: __webpack_require__(162), + MoveDown: __webpack_require__(859), + MoveTo: __webpack_require__(858), + MoveUp: __webpack_require__(857), + NumberArray: __webpack_require__(856), + NumberArrayStep: __webpack_require__(855), + QuickSelect: __webpack_require__(313), + Range: __webpack_require__(312), + Remove: __webpack_require__(330), + RemoveAt: __webpack_require__(854), + RemoveBetween: __webpack_require__(853), + RemoveRandomElement: __webpack_require__(852), + Replace: __webpack_require__(851), + RotateLeft: __webpack_require__(387), + RotateRight: __webpack_require__(386), + SafeRange: __webpack_require__(62), + SendToBack: __webpack_require__(850), + SetAll: __webpack_require__(849), + Shuffle: __webpack_require__(122), + SpliceOne: __webpack_require__(91), + StableSort: __webpack_require__(110), + Swap: __webpack_require__(848) + +}; + + +/***/ }), +/* 165 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -24035,8 +36297,10 @@ module.exports = CheckMatrix; */ var Class = __webpack_require__(0); -var Frame = __webpack_require__(128); -var TextureSource = __webpack_require__(183); +var Frame = __webpack_require__(113); +var TextureSource = __webpack_require__(317); + +var TEXTURE_MISSING_ERROR = 'Texture.frame missing: '; /** * @classdesc @@ -24051,7 +36315,7 @@ var TextureSource = __webpack_require__(183); * Sprites and other Game Objects get the texture data they need from the TextureManager. * * @class Texture - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * @@ -24233,7 +36497,7 @@ var Texture = new Class({ if (!frame) { - console.warn('No Texture.frame found with name ' + name); + console.warn(TEXTURE_MISSING_ERROR + name); frame = this.frames[this.firstFrame]; } @@ -24274,16 +36538,19 @@ var Texture = new Class({ * @since 3.0.0 * * @param {integer} sourceIndex - The index of the TextureSource to get the Frames from. + * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? * * @return {Phaser.Textures.Frame[]} An array of Texture Frames. */ - getFramesFromTextureSource: function (sourceIndex) + getFramesFromTextureSource: function (sourceIndex, includeBase) { + if (includeBase === undefined) { includeBase = false; } + var out = []; for (var frameName in this.frames) { - if (frameName === '__BASE') + if (frameName === '__BASE' && !includeBase) { continue; } @@ -24292,7 +36559,7 @@ var Texture = new Class({ if (frame.sourceIndex === sourceIndex) { - out.push(frame.name); + out.push(frame); } } @@ -24341,7 +36608,7 @@ var Texture = new Class({ * * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. * - * @return {(HTMLImageElement|HTMLCanvasElement)} The DOM Image or Canvas Element. + * @return {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)} The DOM Image, Canvas Element or Render Texture. */ getSourceImage: function (name) { @@ -24352,15 +36619,15 @@ var Texture = new Class({ var frame = this.frames[name]; - if (!frame) + if (frame) { - console.warn('No Texture.frame found with name ' + name); - - return this.frames['__BASE'].source.image; + return frame.source.image; } else { - return frame.source.image; + console.warn(TEXTURE_MISSING_ERROR + name); + + return this.frames['__BASE'].source.image; } }, @@ -24389,7 +36656,7 @@ var Texture = new Class({ if (!frame) { - console.warn('No Texture.frame found with name ' + name); + console.warn(TEXTURE_MISSING_ERROR + name); idx = this.frames['__BASE'].sourceIndex; } @@ -24418,7 +36685,7 @@ var Texture = new Class({ { data = [ data ]; } - + for (var i = 0; i < data.length; i++) { var source = this.source[i]; @@ -24495,7 +36762,7 @@ module.exports = Texture; /***/ }), -/* 118 */ +/* 166 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -24505,12 +36772,12 @@ module.exports = Texture; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(55); -var DefaultPlugins = __webpack_require__(121); -var GetPhysicsPlugins = __webpack_require__(518); -var GetScenePlugins = __webpack_require__(517); -var NOOP = __webpack_require__(3); -var Settings = __webpack_require__(192); +var CONST = __webpack_require__(116); +var DefaultPlugins = __webpack_require__(167); +var GetPhysicsPlugins = __webpack_require__(890); +var GetScenePlugins = __webpack_require__(889); +var NOOP = __webpack_require__(1); +var Settings = __webpack_require__(326); /** * @classdesc @@ -24521,7 +36788,7 @@ var Settings = __webpack_require__(192); * handling the update step and renderer. It also contains references to global systems belonging to Game. * * @class Systems - * @memberOf Phaser.Scenes + * @memberof Phaser.Scenes * @constructor * @since 3.0.0 * @@ -24535,7 +36802,7 @@ var Systems = new Class({ function Systems (scene, config) { /** - * [description] + * A reference to the Scene that these Systems belong to. * * @name Phaser.Scenes.Systems#scene * @type {Phaser.Scene} @@ -24544,7 +36811,7 @@ var Systems = new Class({ this.scene = scene; /** - * [description] + * A reference to the Phaser Game instance. * * @name Phaser.Scenes.Systems#game * @type {Phaser.Game} @@ -24552,8 +36819,11 @@ var Systems = new Class({ */ this.game; + if (false) + {} + /** - * [description] + * The Scene Configuration object, as passed in when creating the Scene. * * @name Phaser.Scenes.Systems#config * @type {(string|Phaser.Scenes.Settings.Config)} @@ -24562,7 +36832,7 @@ var Systems = new Class({ this.config = config; /** - * [description] + * The Scene Settings. This is the parsed output based on the Scene configuration. * * @name Phaser.Scenes.Systems#settings * @type {Phaser.Scenes.Settings.Object} @@ -24580,7 +36850,7 @@ var Systems = new Class({ this.canvas; /** - * [description] + * A reference to the Canvas Rendering Context being used by the renderer. * * @name Phaser.Scenes.Systems#context * @type {CanvasRenderingContext2D} @@ -24591,7 +36861,9 @@ var Systems = new Class({ // Global Systems - these are single-instance global managers that belong to Game /** - * [description] + * A reference to the global Animations Manager. + * + * In the default set-up you can access this from within a Scene via the `this.anims` property. * * @name Phaser.Scenes.Systems#anims * @type {Phaser.Animations.AnimationManager} @@ -24600,7 +36872,10 @@ var Systems = new Class({ this.anims; /** - * [description] + * A reference to the global Cache. The Cache stores all files bought in to Phaser via + * the Loader, with the exception of images. Images are stored in the Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.cache` property. * * @name Phaser.Scenes.Systems#cache * @type {Phaser.Cache.CacheManager} @@ -24609,7 +36884,9 @@ var Systems = new Class({ this.cache; /** - * [description] + * A reference to the global Plugins Manager. + * + * In the default set-up you can access this from within a Scene via the `this.plugins` property. * * @name Phaser.Scenes.Systems#plugins * @type {Phaser.Plugins.PluginManager} @@ -24618,7 +36895,10 @@ var Systems = new Class({ this.plugins; /** - * [description] + * A reference to the global registry. This is a game-wide instance of the Data Manager, allowing + * you to exchange data between Scenes via a universal and shared point. + * + * In the default set-up you can access this from within a Scene via the `this.registry` property. * * @name Phaser.Scenes.Systems#registry * @type {Phaser.Data.DataManager} @@ -24627,7 +36907,9 @@ var Systems = new Class({ this.registry; /** - * [description] + * A reference to the global Sound Manager. + * + * In the default set-up you can access this from within a Scene via the `this.sound` property. * * @name Phaser.Scenes.Systems#sound * @type {Phaser.Sound.BaseSoundManager} @@ -24636,7 +36918,9 @@ var Systems = new Class({ this.sound; /** - * [description] + * A reference to the global Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.textures` property. * * @name Phaser.Scenes.Systems#textures * @type {Phaser.Textures.TextureManager} @@ -24647,7 +36931,11 @@ var Systems = new Class({ // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems /** - * [description] + * A reference to the Scene's Game Object Factory. + * + * Use this to quickly and easily create new Game Object's. + * + * In the default set-up you can access this from within a Scene via the `this.add` property. * * @name Phaser.Scenes.Systems#add * @type {Phaser.GameObjects.GameObjectFactory} @@ -24656,7 +36944,11 @@ var Systems = new Class({ this.add; /** - * [description] + * A reference to the Scene's Camera Manager. + * + * Use this to manipulate and create Cameras for this specific Scene. + * + * In the default set-up you can access this from within a Scene via the `this.cameras` property. * * @name Phaser.Scenes.Systems#cameras * @type {Phaser.Cameras.Scene2D.CameraManager} @@ -24665,7 +36957,11 @@ var Systems = new Class({ this.cameras; /** - * [description] + * A reference to the Scene's Display List. + * + * Use this to organize the children contained in the display list. + * + * In the default set-up you can access this from within a Scene via the `this.children` property. * * @name Phaser.Scenes.Systems#displayList * @type {Phaser.GameObjects.DisplayList} @@ -24674,7 +36970,11 @@ var Systems = new Class({ this.displayList; /** - * [description] + * A reference to the Scene's Event Manager. + * + * Use this to listen for Scene specific events, such as `pause` and `shutdown`. + * + * In the default set-up you can access this from within a Scene via the `this.events` property. * * @name Phaser.Scenes.Systems#events * @type {Phaser.Events.EventEmitter} @@ -24683,7 +36983,13 @@ var Systems = new Class({ this.events; /** - * [description] + * A reference to the Scene's Game Object Creator. + * + * Use this to quickly and easily create new Game Object's. The difference between this and the + * Game Object Factory, is that the Creator just creates and returns Game Object instances, it + * doesn't then add them to the Display List or Update List. + * + * In the default set-up you can access this from within a Scene via the `this.make` property. * * @name Phaser.Scenes.Systems#make * @type {Phaser.GameObjects.GameObjectCreator} @@ -24692,7 +36998,12 @@ var Systems = new Class({ this.make; /** - * [description] + * A reference to the Scene Manager Plugin. + * + * Use this to manipulate both this and other Scene's in your game, for example to launch a parallel Scene, + * or pause or resume a Scene, or switch from this Scene to another. + * + * In the default set-up you can access this from within a Scene via the `this.scene` property. * * @name Phaser.Scenes.Systems#scenePlugin * @type {Phaser.Scenes.ScenePlugin} @@ -24701,7 +37012,14 @@ var Systems = new Class({ this.scenePlugin; /** - * [description] + * A reference to the Scene's Update List. + * + * Use this to organize the children contained in the update list. + * + * The Update List is responsible for managing children that need their `preUpdate` methods called, + * in order to process so internal components, such as Sprites with Animations. + * + * In the default set-up there is no reference to this from within the Scene itself. * * @name Phaser.Scenes.Systems#updateList * @type {Phaser.GameObjects.UpdateList} @@ -24711,7 +37029,7 @@ var Systems = new Class({ /** * The Scene Update function. - * + * * This starts out as NOOP during init, preload and create, and at the end of create * it swaps to be whatever the Scene.update function is. * @@ -24798,13 +37116,13 @@ var Systems = new Class({ }, /** - * Called automatically by the Scene Manager. Instructs the Scene to render itself via - * its Camera Manager to the renderer given. + * 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 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The renderer that invoked the render call. */ render: function (renderer) { @@ -24845,10 +37163,12 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#pause * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'pause' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ - pause: function () + pause: function (data) { if (this.settings.active) { @@ -24856,7 +37176,7 @@ var Systems = new Class({ this.settings.active = false; - this.events.emit('pause', this); + this.events.emit('pause', this, data); } return this; @@ -24868,9 +37188,11 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#resume * @since 3.0.0 * + * @param {object} [data] - A data object that will be passed in the 'resume' event. + * * @return {Phaser.Scenes.Systems} This Systems object. */ - resume: function () + resume: function (data) { if (!this.settings.active) { @@ -24878,7 +37200,7 @@ var Systems = new Class({ this.settings.active = true; - this.events.emit('resume', this); + this.events.emit('resume', this, data); } return this; @@ -24894,17 +37216,19 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#sleep * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'sleep' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ - sleep: function () + sleep: function (data) { this.settings.status = CONST.SLEEPING; this.settings.active = false; this.settings.visible = false; - this.events.emit('sleep', this); + this.events.emit('sleep', this, data); return this; }, @@ -24915,9 +37239,11 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#wake * @since 3.0.0 * + * @param {object} [data] - A data object that will be passed in the 'wake' event. + * * @return {Phaser.Scenes.Systems} This Systems object. */ - wake: function () + wake: function (data) { var settings = this.settings; @@ -24926,7 +37252,7 @@ var Systems = new Class({ settings.active = true; settings.visible = true; - this.events.emit('wake', this); + this.events.emit('wake', this, data); if (settings.isTransition) { @@ -24942,7 +37268,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#isSleeping * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Scene is asleep, otherwise `false`. */ isSleeping: function () { @@ -24955,13 +37281,26 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#isActive * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Scene is active, otherwise `false`. */ isActive: function () { return (this.settings.status === CONST.RUNNING); }, + /** + * Is this Scene paused? + * + * @method Phaser.Scenes.Systems#isPaused + * @since 3.13.0 + * + * @return {boolean} `true` if this Scene is paused, otherwise `false`. + */ + isPaused: function () + { + return (this.settings.status === CONST.PAUSED); + }, + /** * Is this Scene currently transitioning out to, or in from another Scene? * @@ -25007,7 +37346,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#isVisible * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Scene is visible, otherwise `false`. */ isVisible: function () { @@ -25021,7 +37360,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#setVisible * @since 3.0.0 * - * @param {boolean} value - [description] + * @param {boolean} value - `true` to render this Scene, otherwise `false`. * * @return {Phaser.Scenes.Systems} This Systems object. */ @@ -25034,24 +37373,26 @@ var Systems = new Class({ /** * 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 - If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. + * @param {object} [data] - A data object that will be passed in the 'resume' or 'pause' events. * * @return {Phaser.Scenes.Systems} This Systems object. */ - setActive: function (value) + setActive: function (value, data) { if (value) { - return this.resume(); + return this.resume(data); } else { - return this.pause(); + return this.pause(data); } }, @@ -25080,7 +37421,7 @@ var Systems = new Class({ this.events.emit('start', this); // For user-land code to listen out for - this.events.emit('ready', this); + this.events.emit('ready', this, data); }, /** @@ -25107,8 +37448,10 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#shutdown * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'shutdown' event. */ - shutdown: function () + shutdown: function (data) { this.events.off('transitioninit'); this.events.off('transitionstart'); @@ -25120,7 +37463,7 @@ var Systems = new Class({ this.settings.active = false; this.settings.visible = false; - this.events.emit('shutdown', this); + this.events.emit('shutdown', this, data); }, /** @@ -25157,46 +37500,7 @@ module.exports = Systems; /***/ }), -/* 119 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects.Graphics.Commands - */ - -module.exports = { - - ARC: 0, - BEGIN_PATH: 1, - CLOSE_PATH: 2, - FILL_RECT: 3, - LINE_TO: 4, - MOVE_TO: 5, - LINE_STYLE: 6, - FILL_STYLE: 7, - FILL_PATH: 8, - STROKE_PATH: 9, - FILL_TRIANGLE: 10, - STROKE_TRIANGLE: 11, - LINE_FX_TO: 12, - MOVE_FX_TO: 13, - SAVE: 14, - RESTORE: 15, - TRANSLATE: 16, - SCALE: 17, - ROTATE: 18 - -}; - - -/***/ }), -/* 120 */ +/* 167 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -25205,9 +37509,110 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var OS = __webpack_require__(57); -var Browser = __webpack_require__(80); -var CanvasPool = __webpack_require__(22); +/** + * @typedef {object} Phaser.Plugins.DefaultPlugins + * + * @property {array} Global - These are the Global Managers that are created by the Phaser.Game instance. + * @property {array} CoreScene - These are the core plugins that are installed into every Scene.Systems instance, no matter what. + * @property {array} DefaultScene - These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + */ + +var DefaultPlugins = { + + /** + * These are the Global Managers that are created by the Phaser.Game instance. + * They are referenced from Scene.Systems so that plugins can use them. + * + * @name Phaser.Plugins.Global + * @type {array} + * @since 3.0.0 + */ + Global: [ + + 'game', + 'anims', + 'cache', + 'plugins', + 'registry', + 'scale', + 'sound', + 'textures' + + ], + + /** + * These are the core plugins that are installed into every Scene.Systems instance, no matter what. + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are created in the order in which they appear in this array and EventEmitter is always first. + * + * @name Phaser.Plugins.CoreScene + * @type {array} + * @since 3.0.0 + */ + CoreScene: [ + + 'EventEmitter', + + 'CameraManager', + 'GameObjectCreator', + 'GameObjectFactory', + 'ScenePlugin', + 'DisplayList', + 'UpdateList' + + ], + + /** + * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + * + * You can elect not to have these plugins by either creating a DefaultPlugins object as part + * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array + * and building your own bundle. + * + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are always created in the order in which they appear in the array. + * + * @name Phaser.Plugins.DefaultScene + * @type {array} + * @since 3.0.0 + */ + DefaultScene: [ + + 'Clock', + 'DataManagerPlugin', + 'InputPlugin', + 'Loader', + 'TweenManager', + 'LightsPlugin' + + ] + +}; + +if (false) +{} + +if (false) +{} + +module.exports = DefaultPlugins; + + +/***/ }), +/* 168 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(92); +var Browser = __webpack_require__(118); +var CanvasPool = __webpack_require__(24); /** * Determines the features of the browser running this Phaser Game instance. @@ -25393,4811 +37798,7 @@ module.exports = init(); /***/ }), -/* 121 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} Phaser.Plugins.DefaultPlugins - * - * @property {array} Global - These are the Global Managers that are created by the Phaser.Game instance. - * @property {array} CoreScene - These are the core plugins that are installed into every Scene.Systems instance, no matter what. - * @property {array} DefaultScene - These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - */ - -var DefaultPlugins = { - - /** - * These are the Global Managers that are created by the Phaser.Game instance. - * They are referenced from Scene.Systems so that plugins can use them. - * - * @name Phaser.Plugins.Global - * @type {array} - * @since 3.0.0 - */ - Global: [ - - 'anims', - 'cache', - 'plugins', - 'registry', - 'sound', - 'textures' - - ], - - /** - * These are the core plugins that are installed into every Scene.Systems instance, no matter what. - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are created in the order in which they appear in this array and EventEmitter is always first. - * - * @name Phaser.Plugins.CoreScene - * @type {array} - * @since 3.0.0 - */ - CoreScene: [ - - 'EventEmitter', - - 'CameraManager', - 'GameObjectCreator', - 'GameObjectFactory', - 'ScenePlugin', - 'DisplayList', - 'UpdateList' - - ], - - /** - * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - * - * You can elect not to have these plugins by either creating a DefaultPlugins object as part - * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array - * and building your own bundle. - * - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are always created in the order in which they appear in the array. - * - * @name Phaser.Plugins.DefaultScene - * @type {array} - * @since 3.0.0 - */ - DefaultScene: [ - - 'CameraManager3D', - 'Clock', - 'DataManagerPlugin', - 'InputPlugin', - 'Loader', - 'TweenManager', - 'LightsPlugin' - - ] - -}; - -module.exports = DefaultPlugins; - - -/***/ }), -/* 122 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates a linear (interpolation) value over t. - * - * @function Phaser.Math.Linear - * @since 3.0.0 - * - * @param {number} p0 - The first point. - * @param {number} p1 - The second point. - * @param {float} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. - * - * @return {number} The step t% of the way between p0 and p1. - */ -var Linear = function (p0, p1, t) -{ - return (p1 - p0) * t + p0; -}; - -module.exports = Linear; - - -/***/ }), -/* 123 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var Effects = __webpack_require__(204); -var EventEmitter = __webpack_require__(9); -var Linear = __webpack_require__(122); -var Rectangle = __webpack_require__(14); -var TransformMatrix = __webpack_require__(64); -var ValueToColor = __webpack_require__(132); -var Vector2 = __webpack_require__(6); - -/** - * @typedef {object} JSONCameraBounds - * @property {number} x - The horizontal position of camera - * @property {number} y - The vertical position of camera - * @property {number} width - The width size of camera - * @property {number} height - The height size of camera - */ - -/** - * @typedef {object} JSONCamera - * - * @property {string} name - The name of the camera - * @property {number} x - The horizontal position of camera - * @property {number} y - The vertical position of camera - * @property {number} width - The width size of camera - * @property {number} height - The height size of camera - * @property {number} zoom - The zoom of camera - * @property {number} rotation - The rotation of camera - * @property {boolean} roundPixels - The round pixels st status of camera - * @property {number} scrollX - The horizontal scroll of camera - * @property {number} scrollY - The vertical scroll of camera - * @property {string} backgroundColor - The background color of camera - * @property {(JSONCameraBounds|undefined)} [bounds] - The bounds of camera - */ - -/** - * @classdesc - * A Camera. - * - * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, - * and can be positioned, rotated, zoomed and scrolled accordingly. - * - * A Camera consists of two elements: The viewport and the scroll values. - * - * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are - * created the same size as your game, but their position and size can be set to anything. This means if you - * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, - * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). - * - * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this - * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the - * viewport, and changing the viewport has no impact on the scrolling. - * - * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, - * allowing you to filter Game Objects out on a per-Camera basis. - * - * A Camera also has built-in special effects including Fade, Flash and Camera Shake. - * - * @class Camera - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Cameras.Scene2D - * @constructor - * @since 3.0.0 - * - * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. - * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. - * @param {number} width - The width of the Camera, in pixels. - * @param {number} height - The height of the Camera, in pixels. - */ -var Camera = new Class({ - - Extends: EventEmitter, - - initialize: - - function Camera (x, y, width, height) - { - EventEmitter.call(this); - - /** - * A reference to the Scene this camera belongs to. - * - * @name Phaser.Cameras.Scene2D.Camera#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene; - - /** - * The name of the Camera. This is left empty for your own use. - * - * @name Phaser.Cameras.Scene2D.Camera#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The x position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The width of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#width - * @type {number} - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#height - * @type {number} - * @since 3.0.0 - */ - this.height = height; - - /** - * Should this camera round its pixel values to integers? - * - * @name Phaser.Cameras.Scene2D.Camera#roundPixels - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.roundPixels = false; - - /** - * Is this Camera visible or not? - * - * A visible camera will render and perform input tests. - * An invisible camera will not render anything and will skip input tests. - * - * @name Phaser.Cameras.Scene2D.Camera#visible - * @type {boolean} - * @default true - * @since 3.10.0 - */ - this.visible = true; - - /** - * Is this Camera using a bounds to restrict scrolling movement? - * Set this property along with the bounds via `Camera.setBounds`. - * - * @name Phaser.Cameras.Scene2D.Camera#useBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useBounds = false; - - /** - * The bounds the camera is restrained to during scrolling. - * - * @name Phaser.Cameras.Scene2D.Camera#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); - - /** - * Does this Camera allow the Game Objects it renders to receive input events? - * - * @name Phaser.Cameras.Scene2D.Camera#inputEnabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.inputEnabled = true; - - /** - * The horizontal scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * The vertical scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * The Camera zoom value. Change this value to zoom in, or out of, a Scene. - * Set to 1 to return to the default zoom level. - * - * @name Phaser.Cameras.Scene2D.Camera#zoom - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.zoom = 1; - - /** - * The rotation of the Camera. This influences the rendering of all Game Objects visible by this camera. - * - * @name Phaser.Cameras.Scene2D.Camera#rotation - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotation = 0; - - /** - * A local transform matrix used for internal calculations. - * - * @name Phaser.Cameras.Scene2D.Camera#matrix - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @since 3.0.0 - */ - this.matrix = new TransformMatrix(1, 0, 0, 1, 0, 0); - - /** - * Does this Camera have a transparent background? - * - * @name Phaser.Cameras.Scene2D.Camera#transparent - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.transparent = true; - - /** - * The background color of this Camera. Only used if `transparent` is `false`. - * - * @name Phaser.Cameras.Scene2D.Camera#backgroundColor - * @type {Phaser.Display.Color} - * @since 3.0.0 - */ - this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); - - /** - * The Camera Fade effect handler. - * To fade this camera see the `Camera.fade` methods. - * - * @name Phaser.Cameras.Scene2D.Camera#fadeEffect - * @type {Phaser.Cameras.Scene2D.Effects.Fade} - * @since 3.5.0 - */ - this.fadeEffect = new Effects.Fade(this); - - /** - * The Camera Flash effect handler. - * To flash this camera see the `Camera.flash` method. - * - * @name Phaser.Cameras.Scene2D.Camera#flashEffect - * @type {Phaser.Cameras.Scene2D.Effects.Flash} - * @since 3.5.0 - */ - this.flashEffect = new Effects.Flash(this); - - /** - * The Camera Shake effect handler. - * To shake this camera see the `Camera.shake` method. - * - * @name Phaser.Cameras.Scene2D.Camera#shakeEffect - * @type {Phaser.Cameras.Scene2D.Effects.Shake} - * @since 3.5.0 - */ - this.shakeEffect = new Effects.Shake(this); - - /** - * Should the camera cull Game Objects before checking them for input hit tests? - * In some special cases it may be beneficial to disable this. - * - * @name Phaser.Cameras.Scene2D.Camera#disableCull - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.disableCull = false; - - /** - * A temporary array of culled objects. - * - * @name Phaser.Cameras.Scene2D.Camera#culledObjects - * @type {Phaser.GameObjects.GameObject[]} - * @default [] - * @since 3.0.0 - */ - this.culledObjects = []; - - /** - * The linear interpolation value to use when following a target. - * - * Can also be set via `setLerp` or as part of the `startFollow` call. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - * - * @name Phaser.Cameras.Scene2D.Camera#lerp - * @type {Phaser.Math.Vector2} - * @since 3.9.0 - */ - this.lerp = new Vector2(1, 1); - - /** - * The values stored in this property are subtracted from the Camera targets position, allowing you to - * offset the camera from the actual target x/y coordinates by this amount. - * Can also be set via `setFollowOffset` or as part of the `startFollow` call. - * - * @name Phaser.Cameras.Scene2D.Camera#followOffset - * @type {Phaser.Math.Vector2} - * @since 3.9.0 - */ - this.followOffset = new Vector2(); - - /** - * Internal follow target reference. - * - * @name Phaser.Cameras.Scene2D.Camera#_follow - * @type {?any} - * @private - * @default null - * @since 3.0.0 - */ - this._follow = null; - - /** - * Internal camera ID. Assigned by the Camera Manager and used in the camera pool. - * - * @name Phaser.Cameras.Scene2D.Camera#_id - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._id = 0; - }, - - /** - * Scrolls the Camera so that it is looking at the center of the Camera Bounds (if previously enabled) - * - * @method Phaser.Cameras.Scene2D.Camera#centerToBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToBounds: function () - { - if (this.useBounds) - { - this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5); - this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5); - } - - return this; - }, - - /** - * Scrolls the Camera so that it is re-centered based on its viewport size. - * - * @method Phaser.Cameras.Scene2D.Camera#centerToSize - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToSize: function () - { - this.scrollX = this.width * 0.5; - this.scrollY = this.height * 0.5; - - return this; - }, - - /** - * Takes an array of Game Objects and returns a new array featuring only those objects - * visible by this camera. - * - * @method Phaser.Cameras.Scene2D.Camera#cull - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] - * - * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. - * - * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. - */ - cull: function (renderableObjects) - { - if (this.disableCull) - { - return renderableObjects; - } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return renderableObjects; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var culledObjects = this.culledObjects; - var length = renderableObjects.length; - - determinant = 1 / determinant; - - culledObjects.length = 0; - - for (var index = 0; index < length; ++index) - { - var object = renderableObjects[index]; - - if (!object.hasOwnProperty('width') || object.parentContainer) - { - culledObjects.push(object); - continue; - } - - var objectW = object.width; - var objectH = object.height; - var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); - var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); - var tx = (objectX * mva + objectY * mvc + mve); - var ty = (objectX * mvb + objectY * mvd + mvf); - var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); - var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); - var cullW = cameraW + objectW; - var cullH = cameraH + objectH; - - if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH && - tw > -objectW && th > -objectH && tw < cullW && th < cullH) - { - culledObjects.push(object); - } - } - - return culledObjects; - }, - - /** - * Fades the Camera in from the given color over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#fadeIn - * @since 3.3.0 - * - * @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 {function} [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} This Camera instance. - */ - fadeIn: function (duration, red, green, blue, callback, context) - { - return this.fadeEffect.start(false, duration, red, green, blue, true, callback, context); - }, - - /** - * Fades the Camera out to the given color over the duration specified. - * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. - * - * @method Phaser.Cameras.Scene2D.Camera#fadeOut - * @since 3.3.0 - * - * @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 {function} [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} This Camera instance. - */ - fadeOut: function (duration, red, green, blue, callback, context) - { - return this.fadeEffect.start(true, duration, red, green, blue, true, callback, context); - }, - - /** - * Fades the Camera from the given color to transparent over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#fadeFrom - * @since 3.5.0 - * - * @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 {function} [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} This Camera instance. - */ - fadeFrom: function (duration, red, green, blue, force, callback, context) - { - return this.fadeEffect.start(false, duration, red, green, blue, force, callback, context); - }, - - /** - * Fades the Camera from transparent to the given color over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#fade - * @since 3.0.0 - * - * @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 {function} [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} This Camera instance. - */ - fade: function (duration, red, green, blue, force, callback, context) - { - return this.fadeEffect.start(true, duration, red, green, blue, force, callback, context); - }, - - /** - * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#flash - * @since 3.0.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 {function} [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} This Camera instance. - */ - flash: function (duration, red, green, blue, force, callback, context) - { - return this.flashEffect.start(duration, red, green, blue, force, callback, context); - }, - - /** - * Shakes the Camera by the given intensity over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#shake - * @since 3.0.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 {function} [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} This Camera instance. - */ - shake: function (duration, intensity, force, callback, context) - { - return this.shakeEffect.start(duration, intensity, force, callback, context); - }, - - /** - * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. - * You can optionally provide a Vector2, or similar object, to store the results in. - * - * @method Phaser.Cameras.Scene2D.Camera#getWorldPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [output,$return] - * - * @param {number} x - The x position to convert to world space. - * @param {number} y - The y position to convert to world space. - * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. - */ - getWorldPoint: function (x, y, output) - { - if (output === undefined) { output = new Vector2(); } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - output.x = x; - output.y = y; - - return output; - } - - determinant = 1 / determinant; - - var ima = mvd * determinant; - var imb = -mvb * determinant; - var imc = -mvc * determinant; - var imd = mva * determinant; - var ime = (mvc * mvf - mvd * mve) * determinant; - var imf = (mvb * mve - mva * mvf) * determinant; - - var c = Math.cos(this.rotation); - var s = Math.sin(this.rotation); - - var zoom = this.zoom; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - - var sx = x + ((scrollX * c - scrollY * s) * zoom); - var sy = y + ((scrollX * s + scrollY * c) * zoom); - - /* Apply transform to point */ - output.x = (sx * ima + sy * imc + ime); - output.y = (sx * imb + sy * imd + imf); - - return output; - }, - - /** - * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings - * so that they are ignored by this Camera. This means they will not be rendered by this Camera. - * - * @method Phaser.Cameras.Scene2D.Camera#ignore - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObject - The Game Object, or array of Game Objects, to be ignored by this Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - ignore: function (gameObject) - { - var id = this._id; - - if (Array.isArray(gameObject)) - { - for (var i = 0; i < gameObject.length; i++) - { - gameObject[i].cameraFilter |= id; - } - } - else - { - gameObject.cameraFilter |= id; - } - - return this; - }, - - /** - * Internal preRender step. - * - * @method Phaser.Cameras.Scene2D.Camera#preRender - * @protected - * @since 3.0.0 - * - * @param {number} baseScale - The base scale, as set in the Camera Manager. - * @param {number} resolution - The game resolution. - */ - preRender: function (baseScale, resolution) - { - var width = this.width; - var height = this.height; - var zoom = this.zoom * baseScale; - var matrix = this.matrix; - var originX = width / 2; - var originY = height / 2; - var follow = this._follow; - - if (follow) - { - this.scrollX = Linear(this.scrollX, (follow.x - this.followOffset.x) - originX, this.lerp.x) / zoom; - this.scrollY = Linear(this.scrollY, (follow.y - this.followOffset.y) - originY, this.lerp.y) / zoom; - } - - if (this.useBounds) - { - var bounds = this._bounds; - - var bw = Math.max(0, bounds.right - width); - var bh = Math.max(0, bounds.bottom - height); - - if (this.scrollX < bounds.x) - { - this.scrollX = bounds.x; - } - else if (this.scrollX > bw) - { - this.scrollX = bw; - } - - if (this.scrollY < bounds.y) - { - this.scrollY = bounds.y; - } - else if (this.scrollY > bh) - { - this.scrollY = bh; - } - } - - if (this.roundPixels) - { - this.scrollX = Math.round(this.scrollX); - this.scrollY = Math.round(this.scrollY); - } - - matrix.loadIdentity(); - matrix.scale(resolution, resolution); - matrix.translate(this.x + originX, this.y + originY); - matrix.rotate(this.rotation); - matrix.scale(zoom, zoom); - matrix.translate(-originX, -originY); - - this.shakeEffect.preRender(); - }, - - /** - * If this Camera has previously had movement bounds set on it, this will remove them. - * - * @method Phaser.Cameras.Scene2D.Camera#removeBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - removeBounds: function () - { - this.useBounds = false; - - this._bounds.setEmpty(); - - return this; - }, - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setAngle - * @since 3.0.0 - * - * @param {number} [value=0] - The cameras angle of rotation, given in degrees. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setAngle: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = DegToRad(value); - - return this; - }, - - /** - * Sets the linear interpolation value to use when following a target. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - * - * @method Phaser.Cameras.Scene2D.Camera#setLerp - * @since 3.9.0 - * - * @param {number} [x=1] - The amount added to the horizontal linear interpolation of the follow target. - * @param {number} [y=1] - The amount added to the vertical linear interpolation of the follow target. - * - * @return {this} This Camera instance. - */ - setLerp: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.lerp.set(x, y); - - return this; - }, - - /** - * Sets the horizontal and vertical offset of the camera from its follow target. - * The values are subtracted from the targets position during the Cameras update step. - * - * @method Phaser.Cameras.Scene2D.Camera#setFollowOffset - * @since 3.9.0 - * - * @param {number} [x=0] - The horizontal offset from the camera follow target.x position. - * @param {number} [y=0] - The vertical offset from the camera follow target.y position. - * - * @return {this} This Camera instance. - */ - setFollowOffset: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - this.followOffset.set(x, y); - - return this; - }, - - /** - * Sets the background color for this Camera. - * - * By default a Camera has a transparent background but it can be given a solid color, with any level - * of transparency, via this method. - * - * The color value can be specified using CSS color notation, hex or numbers. - * - * @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor - * @since 3.0.0 - * - * @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBackgroundColor: function (color) - { - if (color === undefined) { color = 'rgba(0,0,0,0)'; } - - this.backgroundColor = ValueToColor(color); - - this.transparent = (this.backgroundColor.alpha === 0); - - return this; - }, - - /** - * Set the world bounds for this Camera. - * - * A Camera bounds controls where the camera can scroll to within the world. It does not limit - * rendering of the camera, or placement of the viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setBounds - * @since 3.0.0 - * - * @param {integer} x - The top-left x coordinate of the bounds. - * @param {integer} y - The top-left y coordinate of the bounds. - * @param {integer} width - The width of the bounds, in pixels. - * @param {integer} height - The height of the bounds, in pixels. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBounds: function (x, y, width, height) - { - this._bounds.setTo(x, y, width, height); - - this.useBounds = true; - - return this; - }, - - /** - * Sets the name of this Camera. - * This value is for your own use and isn't used internally. - * - * @method Phaser.Cameras.Scene2D.Camera#setName - * @since 3.0.0 - * - * @param {string} [value=''] - The name of the Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setName: function (value) - { - if (value === undefined) { value = ''; } - - this.name = value; - - return this; - }, - - /** - * Set the position of the Camera viewport within the game. - * - * This does not change where the camera is 'looking'. See `setScroll` to control that. - * - * @method Phaser.Cameras.Scene2D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the Camera viewport. - * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setRotation - * @since 3.0.0 - * - * @param {number} [value=0] - The rotation of the Camera, in radians. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRotation: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = value; - - return this; - }, - - /** - * Should the Camera round pixel values to whole integers when scrolling? - * In some types of game this is required to prevent sub-pixel aliasing. - * - * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels - * @since 3.0.0 - * - * @param {boolean} value - `true` to round Camera pixels, `false` to not. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRoundPixels: function (value) - { - this.roundPixels = value; - - return this; - }, - - /** - * Sets the Scene the Camera is bound to. - * - * @method Phaser.Cameras.Scene2D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene the camera is bound to. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * Set the position of where the Camera is looking within the game. - * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. - * Use this method, or the scroll properties, to move your camera around the game world. - * - * This does not change where the camera viewport is placed. See `setPosition` to control that. - * - * @method Phaser.Cameras.Scene2D.Camera#setScroll - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the Camera in the game world. - * @param {number} [y=x] - The y coordinate of the Camera in the game world. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScroll: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollX = x; - this.scrollY = y; - - return this; - }, - - /** - * Set the size of the Camera viewport. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setSize - * @since 3.0.0 - * - * @param {integer} width - The width of the Camera viewport. - * @param {integer} [height=width] - The height of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * This method sets the position and size of the Camera viewport in a single call. - * - * If you're trying to change where the Camera is looking at in your game, then see - * the method `Camera.setScroll` instead. This method is for changing the viewport - * itself, not what the camera can see. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the Camera viewport. - * @param {number} y - The top-left y coordinate of the Camera viewport. - * @param {integer} width - The width of the Camera viewport. - * @param {integer} [height=width] - The height of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setViewport: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * Set the zoom value of the Camera. - * - * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. - * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. - * - * A value of 1 means 'no zoom' and is the default. - * - * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setZoom - * @since 3.0.0 - * - * @param {float} [value=1] - The zoom value of the Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setZoom: function (value) - { - if (value === undefined) { value = 1; } - - this.zoom = value; - - return this; - }, - - /** - * Sets the visibility of this Camera. - * - * An invisible Camera will skip rendering and input tests of everything it can see. - * - * @method Phaser.Cameras.Scene2D.Camera#setVisible - * @since 3.10.0 - * - * @param {boolean} value - The visible state of the Camera. - * - * @return {this} This Camera instance. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * Sets the Camera to follow a Game Object. - * - * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object - * in its center. - * - * You can set the linear interpolation value used in the follow code. - * Use low lerp values (such as 0.1) to automatically smooth the camera motion. - * - * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel - * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to - * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom - * value on the camera. So be sure to keep the camera zoom to integers. - * - * @method Phaser.Cameras.Scene2D.Camera#startFollow - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. - * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? - * @param {float} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. - * @param {float} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. - * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. - * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. - * - * @return {this} This Camera instance. - */ - startFollow: function (target, roundPixels, lerpX, lerpY, offsetX, offsetY) - { - if (roundPixels === undefined) { roundPixels = false; } - if (lerpX === undefined) { lerpX = 1; } - if (lerpY === undefined) { lerpY = lerpX; } - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = offsetX; } - - this._follow = target; - - this.roundPixels = roundPixels; - - lerpX = Clamp(lerpX, 0, 1); - lerpY = Clamp(lerpY, 0, 1); - - this.lerp.set(lerpX, lerpY); - - this.followOffset.set(offsetX, offsetY); - - // Move the camera there immediately, to avoid a large lerp during preUpdate - var zoom = this.zoom; - var originX = this.width / 2; - var originY = this.height / 2; - - this.scrollX = (target.x - offsetX - originX) / zoom; - this.scrollY = (target.y - offsetY - originY) / zoom; - - return this; - }, - - /** - * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. - * - * @method Phaser.Cameras.Scene2D.Camera#stopFollow - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - stopFollow: function () - { - this._follow = null; - - return this; - }, - - /** - * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. - * - * @method Phaser.Cameras.Scene2D.Camera#toJSON - * @since 3.0.0 - * - * @return {JSONCamera} A well-formed object suitable for conversion to JSON. - */ - toJSON: function () - { - var output = { - name: this.name, - x: this.x, - y: this.y, - width: this.width, - height: this.height, - zoom: this.zoom, - rotation: this.rotation, - roundPixels: this.roundPixels, - scrollX: this.scrollX, - scrollY: this.scrollY, - backgroundColor: this.backgroundColor.rgba - }; - - if (this.useBounds) - { - output['bounds'] = { - x: this._bounds.x, - y: this._bounds.y, - width: this._bounds.width, - height: this._bounds.height - }; - } - - return output; - }, - - /** - * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to - * remove the fade. - * - * @method Phaser.Cameras.Scene2D.Camera#resetFX - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - resetFX: function () - { - this.shakeEffect.reset(); - this.flashEffect.reset(); - this.fadeEffect.reset(); - - return this; - }, - - /** - * Internal method called automatically by the Camera Manager. - * - * @method Phaser.Cameras.Scene2D.Camera#update - * @protected - * @since 3.0.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.visible) - { - this.shakeEffect.update(time, delta); - this.flashEffect.update(time, delta); - this.fadeEffect.update(time, delta); - } - }, - - /** - * This event is fired when a camera is destroyed by the Camera Manager. - * - * @event CameraDestroyEvent - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that was destroyed. - */ - - /** - * Destroys this Camera instance. You rarely need to call this directly. - * - * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as - * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. - * - * @method Phaser.Cameras.Scene2D.Camera#destroy - * @fires CameraDestroyEvent - * @since 3.0.0 - */ - destroy: function () - { - this.emit('cameradestroy', this); - - this.removeAllListeners(); - - this.resetFX(); - - this.matrix.destroy(); - - this.culledObjects = []; - - this._follow = null; - - this._bounds = null; - - this.scene = null; - }, - - /** - * The x position of the center of the Camera's viewport, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#centerX - * @type {number} - * @readOnly - * @since 3.10.0 - */ - centerX: { - - get: function () - { - return this.x + (0.5 * this.width); - } - - }, - - /** - * The y position of the center of the Camera's viewport, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#centerY - * @type {number} - * @readOnly - * @since 3.10.0 - */ - centerY: { - - get: function () - { - return this.y + (0.5 * this.height); - } - - } - -}); - -module.exports = Camera; - - -/***/ }), -/* 124 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback EachMapCallback - * @generic E - [entry] - * - * @param {string} key - [description] - * @param {*} entry - [description] - * - * @return {?boolean} [description] - */ - -/** - * @classdesc - * The keys of a Map can be arbitrary values. - * var map = new Map([ - * [ 1, 'one' ], - * [ 2, 'two' ], - * [ 3, 'three' ] - * ]); - * - * @class Map - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic K - * @generic V - * @genericUse {V[]} - [elements] - * - * @param {Array.<*>} elements - [description] - */ -var Map = new Class({ - - initialize: - - function Map (elements) - { - /** - * [description] - * - * @genericUse {Object.} - [$type] - * - * @name Phaser.Structs.Map#entries - * @type {Object.} - * @default {} - * @since 3.0.0 - */ - this.entries = {}; - - /** - * [description] - * - * @name Phaser.Structs.Map#size - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.size = 0; - - if (Array.isArray(elements)) - { - for (var i = 0; i < elements.length; i++) - { - this.set(elements[i][0], elements[i][1]); - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#set - * @since 3.0.0 - * - * @genericUse {K} - [key] - * @genericUse {V} - [value] - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @param {string} key - [description] - * @param {*} value - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - set: function (key, value) - { - if (!this.has(key)) - { - this.entries[key] = value; - this.size++; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#get - * @since 3.0.0 - * - * @genericUse {K} - [key] - * @genericUse {V} - [$return] - * - * @param {string} key - [description] - * - * @return {*} [description] - */ - get: function (key) - { - if (this.has(key)) - { - return this.entries[key]; - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#getArray - * @since 3.0.0 - * - * @genericUse {V[]} - [$return] - * - * @return {Array.<*>} [description] - */ - getArray: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#has - * @since 3.0.0 - * - * @genericUse {K} - [key] - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (key) - { - return (this.entries.hasOwnProperty(key)); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#delete - * @since 3.0.0 - * - * @genericUse {K} - [key] - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @param {string} key - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - delete: function (key) - { - if (this.has(key)) - { - delete this.entries[key]; - this.size--; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#clear - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @return {Phaser.Structs.Map} This Map object. - */ - clear: function () - { - Object.keys(this.entries).forEach(function (prop) - { - delete this.entries[prop]; - - }, this); - - this.size = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#keys - * @since 3.0.0 - * - * @genericUse {K[]} - [$return] - * - * @return {string[]} [description] - */ - keys: function () - { - return Object.keys(this.entries); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#values - * @since 3.0.0 - * - * @genericUse {V[]} - [$return] - * - * @return {Array.<*>} [description] - */ - values: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#dump - * @since 3.0.0 - */ - dump: function () - { - var entries = this.entries; - - // eslint-disable-next-line no-console - console.group('Map'); - - for (var key in entries) - { - console.log(key, entries[key]); - } - - // eslint-disable-next-line no-console - console.groupEnd(); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#each - * @since 3.0.0 - * - * @genericUse {EachMapCallback.} - [callback] - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @param {EachMapCallback} callback - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - each: function (callback) - { - var entries = this.entries; - - for (var key in entries) - { - if (callback(key, entries[key]) === false) - { - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#contains - * @since 3.0.0 - * - * @genericUse {V} - [value] - * - * @param {*} value - [description] - * - * @return {boolean} [description] - */ - contains: function (value) - { - var entries = this.entries; - - for (var key in entries) - { - if (entries[key] === value) - { - return true; - } - } - - return false; - }, - - /** - * Merges all new keys from the given Map into this one - * If it encounters a key that already exists it will be skipped - * unless override = true. - * - * @method Phaser.Structs.Map#merge - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Map.} - [map,$return] - * - * @param {Phaser.Structs.Map} map - [description] - * @param {boolean} [override=false] - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - merge: function (map, override) - { - if (override === undefined) { override = false; } - - var local = this.entries; - var source = map.entries; - - for (var key in source) - { - if (local.hasOwnProperty(key) && override) - { - local[key] = source[key]; - } - else - { - this.set(key, source[key]); - } - } - - return this; - } - -}); - -module.exports = Map; - - -/***/ }), -/* 125 */, -/* 126 */, -/* 127 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetAdvancedValue = __webpack_require__(10); - -/** - * Adds an Animation component to a Sprite and populates it based on the given config. - * - * @function Phaser.GameObjects.BuildGameObjectAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - The sprite to add an Animation component to. - * @param {object} config - The animation config. - * - * @return {Phaser.GameObjects.Sprite} The updated Sprite. - */ -var BuildGameObjectAnimation = function (sprite, config) -{ - var animConfig = GetAdvancedValue(config, 'anims', null); - - if (animConfig === null) - { - return sprite; - } - - if (typeof animConfig === 'string') - { - // { anims: 'key' } - sprite.anims.play(animConfig); - } - else if (typeof animConfig === 'object') - { - // { anims: { - // key: string - // startFrame: [string|integer] - // delay: [float] - // repeat: [integer] - // repeatDelay: [float] - // yoyo: [boolean] - // play: [boolean] - // delayedPlay: [boolean] - // } - // } - - var anims = sprite.anims; - - var key = GetAdvancedValue(animConfig, 'key', undefined); - var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); - - var delay = GetAdvancedValue(animConfig, 'delay', 0); - var repeat = GetAdvancedValue(animConfig, 'repeat', 0); - var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); - var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); - - var play = GetAdvancedValue(animConfig, 'play', false); - var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); - - anims.delay(delay); - anims.repeat(repeat); - anims.repeatDelay(repeatDelay); - anims.yoyo(yoyo); - - if (play) - { - anims.play(key, startFrame); - } - else if (delayedPlay > 0) - { - anims.delayedPlay(delayedPlay, key, startFrame); - } - else - { - anims.load(key); - } - } - - return sprite; -}; - -module.exports = BuildGameObjectAnimation; - - -/***/ }), -/* 128 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Extend = __webpack_require__(17); - -/** - * @classdesc - * A Frame is a section of a Texture. - * - * @class Frame - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. - * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. - * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. - * @param {number} x - The x coordinate of the top-left of this Frame. - * @param {number} y - The y coordinate of the top-left of this Frame. - * @param {number} width - The width of this Frame. - * @param {number} height - The height of this Frame. - */ -var Frame = new Class({ - - initialize: - - function Frame (texture, name, sourceIndex, x, y, width, height) - { - /** - * The Texture this Frame is a part of. - * - * @name Phaser.Textures.Frame#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - this.texture = texture; - - /** - * The name of this Frame. - * The name is unique within the Texture. - * - * @name Phaser.Textures.Frame#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The TextureSource this Frame is part of. - * - * @name Phaser.Textures.Frame#source - * @type {Phaser.Textures.TextureSource} - * @since 3.0.0 - */ - this.source = texture.source[sourceIndex]; - - /** - * The index of the TextureSource in the Texture sources array. - * - * @name Phaser.Textures.Frame#sourceIndex - * @type {integer} - * @since 3.0.0 - */ - this.sourceIndex = sourceIndex; - - /** - * X position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutX - * @type {integer} - * @since 3.0.0 - */ - this.cutX; - - /** - * Y position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutY - * @type {integer} - * @since 3.0.0 - */ - this.cutY; - - /** - * The width of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutWidth - * @type {integer} - * @since 3.0.0 - */ - this.cutWidth; - - /** - * The height of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutHeight - * @type {integer} - * @since 3.0.0 - */ - this.cutHeight; - - /** - * The X rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#x - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The Y rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#y - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The rendering width of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#width - * @type {integer} - * @since 3.0.0 - */ - this.width; - - /** - * The rendering height of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#height - * @type {integer} - * @since 3.0.0 - */ - this.height; - - /** - * Half the width, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfWidth - * @type {integer} - * @since 3.0.0 - */ - this.halfWidth; - - /** - * Half the height, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfHeight - * @type {integer} - * @since 3.0.0 - */ - this.halfHeight; - - /** - * The x center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerX - * @type {integer} - * @since 3.0.0 - */ - this.centerX; - - /** - * The y center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerY - * @type {integer} - * @since 3.0.0 - */ - this.centerY; - - /** - * The horizontal pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotX = 0; - - /** - * The vertical pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotY = 0; - - /** - * Does this Frame have a custom pivot point? - * - * @name Phaser.Textures.Frame#customPivot - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customPivot = false; - - /** - * **CURRENTLY UNSUPPORTED** - * - * Is this frame is rotated or not in the Texture? - * Rotation allows you to use rotated frames in texture atlas packing. - * It has nothing to do with Sprite rotation. - * - * @name Phaser.Textures.Frame#rotated - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rotated = false; - - /** - * Over-rides the Renderer setting. - * -1 = use Renderer Setting - * 0 = No rounding - * 1 = Round - * - * @name Phaser.Textures.Frame#autoRound - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.autoRound = -1; - - /** - * Any Frame specific custom data can be stored here. - * - * @name Phaser.Textures.Frame#customData - * @type {object} - * @since 3.0.0 - */ - this.customData = {}; - - /** - * The un-modified source frame, trim and UV data. - * - * @name Phaser.Textures.Frame#data - * @type {object} - * @private - * @since 3.0.0 - */ - this.data = { - cut: { - x: 0, - y: 0, - w: 0, - h: 0, - r: 0, - b: 0 - }, - trim: false, - sourceSize: { - w: 0, - h: 0 - }, - spriteSourceSize: { - x: 0, - y: 0, - w: 0, - h: 0 - }, - uvs: { - x0: 0, - y0: 0, - x1: 0, - y1: 0, - x2: 0, - y2: 0, - x3: 0, - y3: 0 - }, - radius: 0, - drawImage: { - sx: 0, - sy: 0, - sWidth: 0, - sHeight: 0, - dWidth: 0, - dHeight: 0 - } - }; - - this.setSize(width, height, x, y); - }, - - /** - * Sets the width, height, x and y of this Frame. - * - * This is called automatically by the constructor - * and should rarely be changed on-the-fly. - * - * @method Phaser.Textures.Frame#setSize - * @since 3.7.0 - * - * @param {integer} width - The width of the frame before being trimmed. - * @param {integer} height - The height of the frame before being trimmed. - * @param {integer} [x=0] - The x coordinate of the top-left of this Frame. - * @param {integer} [y=0] - The y coordinate of the top-left of this Frame. - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - setSize: function (width, height, x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - this.cutX = x; - this.cutY = y; - this.cutWidth = width; - this.cutHeight = height; - - this.width = width; - this.height = height; - - this.halfWidth = Math.floor(width * 0.5); - this.halfHeight = Math.floor(height * 0.5); - - this.centerX = Math.floor(width / 2); - this.centerY = Math.floor(height / 2); - - var data = this.data; - var cut = data.cut; - - cut.x = x; - cut.y = y; - cut.w = width; - cut.h = height; - cut.r = x + width; - cut.b = y + height; - - data.sourceSize.w = width; - data.sourceSize.h = height; - - data.spriteSourceSize.w = width; - data.spriteSourceSize.h = height; - - data.radius = 0.5 * Math.sqrt(width * width + height * height); - - var drawImage = data.drawImage; - - drawImage.sx = x; - drawImage.sy = y; - drawImage.sWidth = width; - drawImage.sHeight = height; - drawImage.dWidth = width; - drawImage.dHeight = height; - - return this.updateUVs(); - }, - - /** - * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. - * - * @method Phaser.Textures.Frame#setTrim - * @since 3.0.0 - * - * @param {number} actualWidth - The width of the frame before being trimmed. - * @param {number} actualHeight - The height of the frame before being trimmed. - * @param {number} destX - The destination X position of the trimmed frame for display. - * @param {number} destY - The destination Y position of the trimmed frame for display. - * @param {number} destWidth - The destination width of the trimmed frame for display. - * @param {number} destHeight - The destination height of the trimmed frame for display. - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) - { - var data = this.data; - var ss = data.spriteSourceSize; - - // Store actual values - - data.trim = true; - - data.sourceSize.w = actualWidth; - data.sourceSize.h = actualHeight; - - ss.x = destX; - ss.y = destY; - ss.w = destWidth; - ss.h = destHeight; - - // Adjust properties - this.x = destX; - this.y = destY; - - this.width = destWidth; - this.height = destHeight; - - this.halfWidth = destWidth * 0.5; - this.halfHeight = destHeight * 0.5; - - this.centerX = Math.floor(destWidth / 2); - this.centerY = Math.floor(destHeight / 2); - - return this.updateUVs(); - }, - - /** - * Updates the internal WebGL UV cache and the drawImage cache. - * - * @method Phaser.Textures.Frame#updateUVs - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVs: function () - { - var cx = this.cutX; - var cy = this.cutY; - var cw = this.cutWidth; - var ch = this.cutHeight; - - // Canvas data - - var cd = this.data.drawImage; - - cd.sWidth = cw; - cd.sHeight = ch; - cd.dWidth = cw; - cd.dHeight = ch; - - // WebGL data - - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x0 = cx / tw; - uvs.y0 = cy / th; - - uvs.x1 = cx / tw; - uvs.y1 = (cy + ch) / th; - - uvs.x2 = (cx + cw) / tw; - uvs.y2 = (cy + ch) / th; - - uvs.x3 = (cx + cw) / tw; - uvs.y3 = cy / th; - - return this; - }, - - /** - * Updates the internal WebGL UV cache. - * - * @method Phaser.Textures.Frame#updateUVsInverted - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVsInverted: function () - { - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x3 = (this.cutX + this.cutHeight) / tw; - uvs.y3 = (this.cutY + this.cutWidth) / th; - - uvs.x2 = this.cutX / tw; - uvs.y2 = (this.cutY + this.cutWidth) / th; - - uvs.x1 = this.cutX / tw; - uvs.y1 = this.cutY / th; - - uvs.x0 = (this.cutX + this.cutHeight) / tw; - uvs.y0 = this.cutY / th; - - return this; - }, - - /** - * Clones this Frame into a new Frame object. - * - * @method Phaser.Textures.Frame#clone - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} A clone of this Frame. - */ - clone: function () - { - var clone = new Frame(this.texture, this.name, this.sourceIndex); - - clone.cutX = this.cutX; - clone.cutY = this.cutY; - clone.cutWidth = this.cutWidth; - clone.cutHeight = this.cutHeight; - - clone.x = this.x; - clone.y = this.y; - - clone.width = this.width; - clone.height = this.height; - - clone.halfWidth = this.halfWidth; - clone.halfHeight = this.halfHeight; - - clone.centerX = this.centerX; - clone.centerY = this.centerY; - - clone.rotated = this.rotated; - - clone.data = Extend(true, clone.data, this.data); - - clone.updateUVs(); - - return clone; - }, - - /** - * Destroys this Frames references. - * - * @method Phaser.Textures.Frame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.texture = null; - - this.source = null; - }, - - /** - * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realWidth - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realWidth: { - - get: function () - { - return this.data.sourceSize.w; - } - - }, - - /** - * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realHeight - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realHeight: { - - get: function () - { - return this.data.sourceSize.h; - } - - }, - - /** - * The UV data for this Frame. - * - * @name Phaser.Textures.Frame#uvs - * @type {object} - * @readOnly - * @since 3.0.0 - */ - uvs: { - - get: function () - { - return this.data.uvs; - } - - }, - - /** - * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) - * - * @name Phaser.Textures.Frame#radius - * @type {number} - * @readOnly - * @since 3.0.0 - */ - radius: { - - get: function () - { - return this.data.radius; - } - - }, - - /** - * Is the Frame trimmed or not? - * - * @name Phaser.Textures.Frame#trimmed - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - trimmed: { - - get: function () - { - return this.data.trim; - } - - }, - - /** - * The Canvas drawImage data object. - * - * @name Phaser.Textures.Frame#canvasData - * @type {object} - * @readOnly - * @since 3.0.0 - */ - canvasData: { - - get: function () - { - return this.data.drawImage; - } - - } - -}); - -module.exports = Frame; - - -/***/ }), -/* 129 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var ModelViewProjection = __webpack_require__(202); -var ShaderSourceFS = __webpack_require__(526); -var ShaderSourceVS = __webpack_require__(525); -var Utils = __webpack_require__(27); -var WebGLPipeline = __webpack_require__(84); - -/** - * @classdesc - * TextureTintPipeline implements the rendering infrastructure - * for displaying textured objects - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class TextureTintPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var TextureTintPipeline = new Class({ - - Extends: WebGLPipeline, - - Mixins: [ - ModelViewProjection - ], - - initialize: - - function TextureTintPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 6 * 2000), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2 + - Float32Array.BYTES_PER_ELEMENT * 2 + - Uint8Array.BYTES_PER_ELEMENT * 4), - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - }, - { - name: 'inTexCoord', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: Float32Array.BYTES_PER_ELEMENT * 2 - }, - { - name: 'inTint', - size: 4, - type: config.renderer.gl.UNSIGNED_BYTE, - normalized: true, - offset: Float32Array.BYTES_PER_ELEMENT * 4 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewU32 - * @type {Uint32Array} - * @since 3.0.0 - */ - this.vertexViewU32 = new Uint32Array(this.vertexData); - - /** - * Size of the batch. - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#maxQuads - * @type {integer} - * @default 2000 - * @since 3.0.0 - */ - this.maxQuads = 2000; - - /** - * Collection of batch information - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batches - * @type {array} - * @since 3.1.0 - */ - this.batches = []; - - this.mvpInit(); - }, - - /** - * Assigns a texture to the current batch. If a texture is already set it creates - * a new batch object. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#setTexture2D - * @since 3.1.0 - * - * @param {WebGLTexture} texture - WebGLTexture that will be assigned to the current batch. - * @param {integer} textureUnit - Texture unit to which the texture needs to be bound. - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - setTexture2D: function (texture, unit) - { - if (!texture) - { - return this; - } - - var batches = this.batches; - - if (batches.length === 0) - { - this.pushBatch(); - } - - var batch = batches[batches.length - 1]; - - if (unit > 0) - { - if (batch.textures[unit - 1] && - batch.textures[unit - 1] !== texture) - { - this.pushBatch(); - } - - batches[batches.length - 1].textures[unit - 1] = texture; - } - else - { - if (batch.texture !== null && - batch.texture !== texture) - { - this.pushBatch(); - } - - batches[batches.length - 1].texture = texture; - } - - return this; - }, - - /** - * Creates a new batch object and pushes it to a batch array. - * The batch object contains information relevant to the current - * vertex batch like the offset in the vertex buffer, vertex count and - * the textures used by that batch. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#pushBatch - * @since 3.1.0 - */ - pushBatch: function () - { - var batch = { - first: this.vertexCount, - texture: null, - textures: [] - }; - - this.batches.push(batch); - }, - - /** - * Binds, uploads resources and processes all batches generating draw calls. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#flush - * @since 3.1.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This Pipeline. - */ - flush: function () - { - if (this.flushLocked) - { - return this; - } - - this.flushLocked = true; - - var gl = this.gl; - var renderer = this.renderer; - var vertexCount = this.vertexCount; - var topology = this.topology; - var vertexSize = this.vertexSize; - var batches = this.batches; - var batchCount = batches.length; - var batchVertexCount = 0; - var batch = null; - var batchNext; - var textureIndex; - var nTexture; - - if (batchCount === 0 || vertexCount === 0) - { - this.flushLocked = false; - return this; - } - - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); - - for (var index = 0; index < batches.length - 1; ++index) - { - batch = batches[index]; - batchNext = batches[index + 1]; - - if (batch.textures.length > 0) - { - for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) - { - nTexture = batch.textures[textureIndex]; - - if (nTexture) - { - renderer.setTexture2D(nTexture, 1 + textureIndex); - } - } - - gl.activeTexture(gl.TEXTURE0); - } - - batchVertexCount = batchNext.first - batch.first; - - if (batch.texture === null || batchVertexCount <= 0) { continue; } - - renderer.setTexture2D(batch.texture, 0); - gl.drawArrays(topology, batch.first, batchVertexCount); - } - - // Left over data - batch = batches[batches.length - 1]; - - if (batch.textures.length > 0) - { - for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) - { - nTexture = batch.textures[textureIndex]; - - if (nTexture) - { - renderer.setTexture2D(nTexture, 1 + textureIndex); - } - } - - gl.activeTexture(gl.TEXTURE0); - } - - batchVertexCount = vertexCount - batch.first; - - if (batch.texture && batchVertexCount > 0) - { - renderer.setTexture2D(batch.texture, 0); - gl.drawArrays(topology, batch.first, batchVertexCount); - } - - this.vertexCount = 0; - batches.length = 0; - this.pushBatch(); - this.flushLocked = false; - - return this; - }, - - /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - - this.mvpUpdate(); - - if (this.batches.length === 0) - { - this.pushBatch(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); - return this; - }, - - /** - * Renders immediately a static tilemap. This function won't use - * the batching functionality of the pipeline. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawStaticTilemapLayer: function (tilemap) - { - if (tilemap.vertexCount > 0) - { - var pipelineVertexBuffer = this.vertexBuffer; - var gl = this.gl; - var renderer = this.renderer; - var frame = tilemap.tileset.image.get(); - - if (renderer.currentPipeline && - renderer.currentPipeline.vertexCount > 0) - { - renderer.flush(); - } - - this.vertexBuffer = tilemap.vertexBuffer; - renderer.setPipeline(this); - renderer.setTexture2D(frame.source.glTexture, 0); - gl.drawArrays(this.topology, 0, tilemap.vertexCount); - this.vertexBuffer = pipelineVertexBuffer; - } - - this.viewIdentity(); - this.modelIdentity(); - }, - - /** - * Renders contents of a ParticleEmitterManager. It'll batch all particles if possible. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawEmitterManager: function (emitterManager, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var roundPixels = this.renderer.config.roundPixels; - var emitters = emitterManager.emitters.list; - var emitterCount = emitters.length; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var renderer = this.renderer; - var maxQuads = this.maxQuads; - var cameraScrollX = camera.scrollX; - var cameraScrollY = camera.scrollY; - var cameraMatrix = camera.matrix.matrix; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var sin = Math.sin; - var cos = Math.cos; - var vertexComponentCount = this.vertexComponentCount; - var vertexCapacity = this.vertexCapacity; - var texture = emitterManager.defaultFrame.source.glTexture; - var pca, pcb, pcc, pcd, pce, pcf; - var pma, pmb, pmc, pmd, pme, pmf; - - if (parentMatrix) - { - pma = parentMatrix[0]; - pmb = parentMatrix[1]; - pmc = parentMatrix[2]; - pmd = parentMatrix[3]; - pme = parentMatrix[4]; - pmf = parentMatrix[5]; - } - - this.setTexture2D(texture, 0); - - for (var emitterIndex = 0; emitterIndex < emitterCount; ++emitterIndex) - { - var emitter = emitters[emitterIndex]; - var particles = emitter.alive; - var aliveLength = particles.length; - var batchCount = Math.ceil(aliveLength / maxQuads); - var particleOffset = 0; - var scrollX = cameraScrollX * emitter.scrollFactorX; - var scrollY = cameraScrollY * emitter.scrollFactorY; - - if (parentMatrix) - { - var cse = -scrollX; - var csf = -scrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - pca = pma * cma + pmb * cmc; - pcb = pma * cmb + pmb * cmd; - pcc = pmc * cma + pmd * cmc; - pcd = pmc * cmb + pmd * cmd; - pce = pme * cma + pmf * cmc + pse; - pcf = pme * cmb + pmf * cmd + psf; - - cma = pca; - cmb = pcb; - cmc = pcc; - cmd = pcd; - cme = pce; - cmf = pcf; - - scrollX = 0.0; - scrollY = 0.0; - } - - if (!emitter.visible || aliveLength === 0) - { - continue; - } - - renderer.setBlendMode(emitter.blendMode); - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - - for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) - { - var batchSize = Math.min(aliveLength, maxQuads); - - for (var index = 0; index < batchSize; ++index) - { - var particle = particles[particleOffset + index]; - - if (particle.alpha <= 0) - { - continue; - } - - var frame = particle.frame; - var uvs = frame.uvs; - var x = -(frame.halfWidth); - var y = -(frame.halfHeight); - var color = particle.color; - var xw = x + frame.width; - var yh = y + frame.height; - var sr = sin(particle.rotation); - var cr = cos(particle.rotation); - var sra = cr * particle.scaleX; - var srb = sr * particle.scaleX; - var src = -sr * particle.scaleY; - var srd = cr * particle.scaleY; - var sre = particle.x - scrollX; - var srf = particle.y - scrollY; - var mva = sra * cma + srb * cmc; - var mvb = sra * cmb + srb * cmd; - var mvc = src * cma + srd * cmc; - var mvd = src * cmb + srd * cmd; - var mve = sre * cma + srf * cmc + cme; - var mvf = sre * cmb + srf * cmd + cmf; - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = this.vertexCount * vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = color; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = color; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = color; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = color; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = color; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = color; - - this.vertexCount += 6; - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - - } - - particleOffset += batchSize; - aliveLength -= batchSize; - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - } - } - - this.setTexture2D(texture, 0); - }, - - /** - * Batches blitter game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawBlitter: function (blitter, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var list = blitter.getRenderList(); - var length = list.length; - var cameraMatrix = camera.matrix.matrix; - var a = cameraMatrix[0]; - var b = cameraMatrix[1]; - var c = cameraMatrix[2]; - var d = cameraMatrix[3]; - var e = cameraMatrix[4]; - var f = cameraMatrix[5]; - var cameraScrollX = camera.scrollX * blitter.scrollFactorX; - var cameraScrollY = camera.scrollY * blitter.scrollFactorY; - var batchCount = Math.ceil(length / this.maxQuads); - var batchOffset = 0; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * a + csf * c + e; - var psf = cse * b + csf * d + f; - var pca = pma * a + pmb * c; - var pcb = pma * b + pmb * d; - var pcc = pmc * a + pmd * c; - var pcd = pmc * b + pmd * d; - var pce = pme * a + pmf * c + pse; - var pcf = pme * b + pmf * d + psf; - - a = pca; - b = pcb; - c = pcc; - d = pcd; - e = pce; - f = pcf; - - cameraScrollX = 0.0; - cameraScrollY = 0.0; - } - - var blitterX = blitter.x - cameraScrollX; - var blitterY = blitter.y - cameraScrollY; - - var prevTextureSourceIndex; - - for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) - { - var batchSize = Math.min(length, this.maxQuads); - - for (var index = 0; index < batchSize; ++index) - { - var bob = list[batchOffset + index]; - var frame = bob.frame; - var alpha = bob.alpha; - - if (alpha === 0) - { - // Nothing to see here, moving on ... - continue; - } - - var tint = getTint(0xffffff, alpha); - var uvs = frame.uvs; - var flipX = bob.flipX; - var flipY = bob.flipY; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = blitterX + bob.x + frame.x + (frame.width * ((flipX) ? 1.0 : 0.0)); - var y = blitterY + bob.y + frame.y + (frame.height * ((flipY) ? 1.0 : 0.0)); - var xw = x + width; - var yh = y + height; - var tx0 = x * a + y * c + e; - var ty0 = x * b + y * d + f; - var tx1 = xw * a + yh * c + e; - var ty1 = xw * b + yh * d + f; - - // Bind texture only if the Texture Source is different from before - if (frame.sourceIndex !== prevTextureSourceIndex) - { - this.setTexture2D(frame.texture.source[frame.sourceIndex].glTexture, 0); - - prevTextureSourceIndex = frame.sourceIndex; - } - - var vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = tint; - vertexViewF32[vertexOffset + 5] = tx0; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = tint; - vertexViewF32[vertexOffset + 10] = tx1; - vertexViewF32[vertexOffset + 11] = ty1; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = tint; - vertexViewF32[vertexOffset + 20] = tx1; - vertexViewF32[vertexOffset + 21] = ty1; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = tint; - vertexViewF32[vertexOffset + 25] = tx1; - vertexViewF32[vertexOffset + 26] = ty0; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = tint; - - this.vertexCount += 6; - - if (this.vertexCount >= this.vertexCapacity) - { - this.flush(); - - prevTextureSourceIndex = -1; - } - } - - batchOffset += batchSize; - length -= batchSize; - - if (this.vertexCount >= this.vertexCapacity) - { - this.flush(); - } - } - }, - - /** - * Batches Sprite game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchSprite: function (sprite, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var frame = sprite.frame; - var texture = frame.texture.source[frame.sourceIndex].glTexture; - var forceFlipY = (texture.isRenderTexture ? true : false); - var flipX = sprite.flipX; - var flipY = sprite.flipY ^ forceFlipY; - var uvs = frame.uvs; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = -sprite.displayOriginX + frame.x + ((frame.width) * (flipX ? 1.0 : 0.0)); - var y = -sprite.displayOriginY + frame.y + ((frame.height) * (flipY ? 1.0 : 0.0)); - var xw = (roundPixels ? (x|0) : x) + width; - var yh = (roundPixels ? (y|0) : y) + height; - var scaleX = sprite.scaleX; - var scaleY = sprite.scaleY; - var rotation = sprite.rotation; - var alphaTL = sprite._alphaTL; - var alphaTR = sprite._alphaTR; - var alphaBL = sprite._alphaBL; - var alphaBR = sprite._alphaBR; - var tintTL = sprite._tintTL; - var tintTR = sprite._tintTR; - var tintBL = sprite._tintBL; - var tintBR = sprite._tintBR; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = sprite.x; - var srf = sprite.y; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * sprite.scrollFactorX; - var csf = -camera.scrollY * sprite.scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * sprite.scrollFactorX; - srf -= camera.scrollY * sprite.scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vTintTL = getTint(tintTL, alphaTL); - var vTintTR = getTint(tintTR, alphaTR); - var vTintBL = getTint(tintBL, alphaBL); - var vTintBR = getTint(tintBR, alphaBR); - var vertexOffset = 0; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - }, - - /** - * Batches Mesh game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchMesh: function (mesh, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - var vertices = mesh.vertices; - var length = vertices.length; - var vertexCount = (length / 2)|0; - - this.renderer.setPipeline(this); - - if (this.vertexCount + vertexCount > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var uvs = mesh.uv; - var colors = mesh.colors; - var alphas = mesh.alphas; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var frame = mesh.frame; - var texture = mesh.texture.source[frame.sourceIndex].glTexture; - var translateX = mesh.x; - var translateY = mesh.y; - var scaleX = mesh.scaleX; - var scaleY = mesh.scaleY; - var rotation = mesh.rotation; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * mesh.scrollFactorX; - var csf = -camera.scrollY * mesh.scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * mesh.scrollFactorX; - srf -= camera.scrollY * mesh.scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - for (var index = 0, index0 = 0; index < length; index += 2) - { - var x = vertices[index + 0]; - var y = vertices[index + 1]; - var tx = x * mva + y * mvc + mve; - var ty = x * mvb + y * mvd + mvf; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx; - vertexViewF32[vertexOffset + 1] = ty; - vertexViewF32[vertexOffset + 2] = uvs[index + 0]; - vertexViewF32[vertexOffset + 3] = uvs[index + 1]; - vertexViewU32[vertexOffset + 4] = getTint(colors[index0], alphas[index0]); - - vertexOffset += 5; - index0 += 1; - } - - this.vertexCount += vertexCount; - }, - - /** - * Batches BitmapText game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var text = bitmapText.text; - var textLength = text.length; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var cameraWidth = camera.width + 50; - var cameraHeight = camera.height + 50; - var cameraX = -50; - var cameraY = -50; - var frame = bitmapText.frame; - var textureSource = bitmapText.texture.source[frame.sourceIndex]; - var cameraScrollX = camera.scrollX * bitmapText.scrollFactorX; - var cameraScrollY = camera.scrollY * bitmapText.scrollFactorY; - var fontData = bitmapText.fontData; - var lineHeight = fontData.lineHeight; - var scale = (bitmapText.fontSize / fontData.size); - var chars = fontData.chars; - var alpha = bitmapText.alpha; - var vTintTL = getTint(bitmapText._tintTL, alpha); - var vTintTR = getTint(bitmapText._tintTR, alpha); - var vTintBL = getTint(bitmapText._tintBL, alpha); - var vTintBR = getTint(bitmapText._tintBR, alpha); - var srcX = bitmapText.x; - var srcY = bitmapText.y; - var textureX = frame.cutX; - var textureY = frame.cutY; - var textureWidth = textureSource.width; - var textureHeight = textureSource.height; - var texture = textureSource.glTexture; - var xAdvance = 0; - var yAdvance = 0; - var indexCount = 0; - var charCode = 0; - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - var x = 0; - var y = 0; - var xw = 0; - var yh = 0; - - var tx0; - var ty0; - var tx1; - var ty1; - var tx2; - var ty2; - var tx3; - var ty3; - - var umin = 0; - var umax = 0; - var vmin = 0; - var vmax = 0; - var lastGlyph = null; - var lastCharCode = 0; - var translateX = srcX + frame.x; - var translateY = srcY + frame.y; - var rotation = bitmapText.rotation; - var scaleX = bitmapText.scaleX; - var scaleY = bitmapText.scaleY; - var letterSpacing = bitmapText.letterSpacing; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) * scale; - y = (glyph.yOffset + yAdvance) * scale; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - x -= bitmapText.displayOriginX; - y -= bitmapText.displayOriginY; - - xw = x + glyphW * scale; - yh = y + glyphH * scale; - tx0 = x * mva + y * mvc + mve; - ty0 = x * mvb + y * mvd + mvf; - tx1 = x * mva + yh * mvc + mve; - ty1 = x * mvb + yh * mvd + mvf; - tx2 = xw * mva + yh * mvc + mve; - ty2 = xw * mvb + yh * mvd + mvf; - tx3 = xw * mva + y * mvc + mve; - ty3 = xw * mvb + y * mvd + mvf; - - umin = glyphX / textureWidth; - umax = (glyphX + glyphW) / textureWidth; - vmin = glyphY / textureHeight; - vmax = (glyphY + glyphH) / textureHeight; - - if ((tx0 < cameraX || tx0 > cameraWidth || ty0 < cameraY || ty0 > cameraHeight) && - (tx1 < cameraX || tx1 > cameraWidth || ty1 < cameraY || ty1 > cameraHeight) && - (tx2 < cameraX || tx2 > cameraWidth || ty2 < cameraY || ty2 > cameraHeight) && - (tx3 < cameraX || tx3 > cameraWidth || ty3 < cameraY || ty3 > cameraHeight)) - { - continue; - } - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = umin; - vertexViewF32[vertexOffset + 3] = vmin; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = umin; - vertexViewF32[vertexOffset + 8] = vmax; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = umax; - vertexViewF32[vertexOffset + 13] = vmax; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = umin; - vertexViewF32[vertexOffset + 18] = vmin; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = umax; - vertexViewF32[vertexOffset + 23] = vmax; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = umax; - vertexViewF32[vertexOffset + 28] = vmin; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - } - }, - - /** - * Batches DynamicBitmapText game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var displayCallback = bitmapText.displayCallback; - var text = bitmapText.text; - var textLength = text.length; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var renderer = this.renderer; - var cameraMatrix = camera.matrix.matrix; - var frame = bitmapText.frame; - var textureSource = bitmapText.texture.source[frame.sourceIndex]; - var cameraScrollX = camera.scrollX * bitmapText.scrollFactorX; - var cameraScrollY = camera.scrollY * bitmapText.scrollFactorY; - var scrollX = bitmapText.scrollX; - var scrollY = bitmapText.scrollY; - var fontData = bitmapText.fontData; - var lineHeight = fontData.lineHeight; - var scale = (bitmapText.fontSize / fontData.size); - var chars = fontData.chars; - var alpha = bitmapText.alpha; - var vTintTL = getTint(bitmapText._tintTL, alpha); - var vTintTR = getTint(bitmapText._tintTR, alpha); - var vTintBL = getTint(bitmapText._tintBL, alpha); - var vTintBR = getTint(bitmapText._tintBR, alpha); - var srcX = bitmapText.x; - var srcY = bitmapText.y; - var textureX = frame.cutX; - var textureY = frame.cutY; - var textureWidth = textureSource.width; - var textureHeight = textureSource.height; - var texture = textureSource.glTexture; - var xAdvance = 0; - var yAdvance = 0; - var indexCount = 0; - var charCode = 0; - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - var x = 0; - var y = 0; - var xw = 0; - var tx0; - var ty0; - var tx1; - var ty1; - var tx2; - var ty2; - var tx3; - var ty3; - var yh = 0; - var umin = 0; - var umax = 0; - var vmin = 0; - var vmax = 0; - var lastGlyph = null; - var lastCharCode = 0; - var translateX = srcX + frame.x; - var translateY = srcY + frame.y; - var rotation = bitmapText.rotation; - var scaleX = bitmapText.scaleX; - var scaleY = bitmapText.scaleY; - var letterSpacing = bitmapText.letterSpacing; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var crop = (bitmapText.cropWidth > 0 || bitmapText.cropHeight > 0); - var uta, utb, utc, utd, ute, utf; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - if (crop) - { - renderer.pushScissor( - bitmapText.x, - bitmapText.y, - bitmapText.cropWidth * bitmapText.scaleX, - bitmapText.cropHeight * bitmapText.scaleY - ); - } - - for (var index = 0; index < textLength; ++index) - { - scale = (bitmapText.fontSize / bitmapText.fontData.size); - rotation = 0; - - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) - scrollX; - y = (glyph.yOffset + yAdvance) - scrollY; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - if (displayCallback) - { - var output = displayCallback({ - color: 0, - tint: { - topLeft: vTintTL, - topRight: vTintTR, - bottomLeft: vTintBL, - bottomRight: vTintBR - }, - index: index, - charCode: charCode, - x: x, - y: y, - scale: scale, - rotation: 0, - data: glyph.data - }); - - x = output.x; - y = output.y; - scale = output.scale; - rotation = output.rotation; - - if (output.color) - { - vTintTL = output.color; - vTintTR = output.color; - vTintBL = output.color; - vTintBR = output.color; - } - else - { - vTintTL = output.tint.topLeft; - vTintTR = output.tint.topRight; - vTintBL = output.tint.bottomLeft; - vTintBR = output.tint.bottomRight; - } - - vTintTL = getTint(vTintTL, alpha); - vTintTR = getTint(vTintTR, alpha); - vTintBL = getTint(vTintBL, alpha); - vTintBR = getTint(vTintBR, alpha); - } - - x -= bitmapText.displayOriginX; - y -= bitmapText.displayOriginY; - x *= scale; - y *= scale; - - sr = Math.sin(rotation); - cr = Math.cos(rotation); - uta = cr * scale; - utb = sr * scale; - utc = -sr * scale; - utd = cr * scale; - ute = x; - utf = y; - - sra = uta * mva + utb * mvc; - srb = uta * mvb + utb * mvd; - src = utc * mva + utd * mvc; - srd = utc * mvb + utd * mvd; - sre = ute * mva + utf * mvc + mve; - srf = ute * mvb + utf * mvd + mvf; - - xw = glyphW; - yh = glyphH; - tx0 = sre; - ty0 = srf; - tx1 = yh * src + sre; - ty1 = yh * srd + srf; - tx2 = xw * sra + yh * src + sre; - ty2 = xw * srb + yh * srd + srf; - tx3 = xw * sra + sre; - ty3 = xw * srb + srf; - - umin = glyphX / textureWidth; - umax = (glyphX + glyphW) / textureWidth; - vmin = glyphY / textureHeight; - vmax = (glyphY + glyphH) / textureHeight; - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = umin; - vertexViewF32[vertexOffset + 3] = vmin; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = umin; - vertexViewF32[vertexOffset + 8] = vmax; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = umax; - vertexViewF32[vertexOffset + 13] = vmax; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = umin; - vertexViewF32[vertexOffset + 18] = vmin; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = umax; - vertexViewF32[vertexOffset + 23] = vmax; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = umax; - vertexViewF32[vertexOffset + 28] = vmin; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - } - - if (crop) - { - renderer.popScissor(); - } - }, - - /** - * Batches Text game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchText: function (text, camera, parentTransformMatrix) - { - var getTint = Utils.getTintAppendFloatAlpha; - - this.batchTexture( - text, - text.canvasTexture, - text.canvasTexture.width, text.canvasTexture.height, - text.x, text.y, - text.canvasTexture.width, text.canvasTexture.height, - text.scaleX, text.scaleY, - text.rotation, - text.flipX, text.flipY, - text.scrollFactorX, text.scrollFactorY, - text.displayOriginX, text.displayOriginY, - 0, 0, text.canvasTexture.width, text.canvasTexture.height, - getTint(text._tintTL, text._alphaTL), - getTint(text._tintTR, text._alphaTR), - getTint(text._tintBL, text._alphaBL), - getTint(text._tintBR, text._alphaBR), - 0, 0, - camera, - parentTransformMatrix - ); - }, - - /** - * Batches DynamicTilemapLayer game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix) - { - var renderTiles = tilemapLayer.culledTiles; - var length = renderTiles.length; - var texture = tilemapLayer.tileset.image.get().source.glTexture; - var tileset = tilemapLayer.tileset; - var scrollFactorX = tilemapLayer.scrollFactorX; - var scrollFactorY = tilemapLayer.scrollFactorY; - var alpha = tilemapLayer.alpha; - var x = tilemapLayer.x; - var y = tilemapLayer.y; - var sx = tilemapLayer.scaleX; - var sy = tilemapLayer.scaleY; - var getTint = Utils.getTintAppendFloatAlpha; - - for (var index = 0; index < length; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } - - var frameWidth = tile.width; - var frameHeight = tile.height; - var frameX = tileTexCoords.x; - var frameY = tileTexCoords.y; - var tint = getTint(tile.tint, alpha * tile.alpha); - - this.batchTexture( - tilemapLayer, - texture, - texture.width, texture.height, - (tile.width / 2) + x + tile.pixelX * sx, (tile.height / 2) + y + tile.pixelY * sy, - tile.width * sx, tile.height * sy, - 1, 1, - tile.rotation, - tile.flipX, tile.flipY, - scrollFactorX, scrollFactorY, - (tile.width / 2), (tile.height / 2), - frameX, frameY, frameWidth, frameHeight, - tint, tint, tint, tint, - 0, 0, - camera, - parentTransformMatrix - ); - } - }, - - /** - * Batches TileSprite game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchTileSprite: function (tileSprite, camera, parentTransformMatrix) - { - var getTint = Utils.getTintAppendFloatAlpha; - - this.batchTexture( - tileSprite, - tileSprite.tileTexture, - tileSprite.frame.width, tileSprite.frame.height, - tileSprite.x, tileSprite.y, - tileSprite.width, tileSprite.height, - tileSprite.scaleX, tileSprite.scaleY, - tileSprite.rotation, - tileSprite.flipX, tileSprite.flipY, - tileSprite.scrollFactorX, tileSprite.scrollFactorY, - tileSprite.originX * tileSprite.width, tileSprite.originY * tileSprite.height, - 0, 0, tileSprite.width, tileSprite.height, - getTint(tileSprite._tintTL, tileSprite._alphaTL), - getTint(tileSprite._tintTR, tileSprite._alphaTR), - getTint(tileSprite._tintBL, tileSprite._alphaBL), - getTint(tileSprite._tintBR, tileSprite._alphaBR), - (tileSprite.tilePositionX % tileSprite.frame.width) / tileSprite.frame.width, - (tileSprite.tilePositionY % tileSprite.frame.height) / tileSprite.frame.height, - camera, - parentTransformMatrix - ); - }, - - /** - * Generic function for batching a textured quad - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject - * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad - * @param {integer} textureWidth - Real texture width - * @param {integer} textureHeight - Real texture height - * @param {float} srcX - X coordinate of the quad - * @param {float} srcY - Y coordinate of the quad - * @param {float} srcWidth - Width of the quad - * @param {float} srcHeight - Height of the quad - * @param {float} scaleX - X component of scale - * @param {float} scaleY - Y component of scale - * @param {float} rotation - Rotation of the quad - * @param {boolean} flipX - Indicates if the quad is horizontally flipped - * @param {boolean} flipY - Indicates if the quad is vertically flipped - * @param {float} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll - * @param {float} scrollFactorY - By which factor is the quad effected by the camera vertical scroll - * @param {float} displayOriginX - Horizontal origin in pixels - * @param {float} displayOriginY - Vertical origin in pixels - * @param {float} frameX - X coordinate of the texture frame - * @param {float} frameY - Y coordinate of the texture frame - * @param {float} frameWidth - Width of the texture frame - * @param {float} frameHeight - Height of the texture frame - * @param {integer} tintTL - Tint for top left - * @param {integer} tintTR - Tint for top right - * @param {integer} tintBL - Tint for bottom left - * @param {integer} tintBR - Tint for bottom right - * @param {float} uOffset - Horizontal offset on texture coordinate - * @param {float} vOffset - Vertical offset on texture coordinate - * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container - */ - batchTexture: function ( - gameObject, - texture, - textureWidth, textureHeight, - srcX, srcY, - srcWidth, srcHeight, - scaleX, scaleY, - rotation, - flipX, flipY, - scrollFactorX, scrollFactorY, - displayOriginX, displayOriginY, - frameX, frameY, frameWidth, frameHeight, - tintTL, tintTR, tintBL, tintBR, - uOffset, vOffset, - camera, - parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); - - var roundPixels = this.renderer.config.roundPixels; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var width = srcWidth * (flipX ? -1.0 : 1.0); - var height = srcHeight * (flipY ? -1.0 : 1.0); - var x = -displayOriginX + ((srcWidth) * (flipX ? 1.0 : 0.0)); - var y = -displayOriginY + ((srcHeight) * (flipY ? 1.0 : 0.0)); - var xw = x + width; - var yh = y + height; - var translateX = srcX; - var translateY = srcY; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * scrollFactorX; - var csf = -camera.scrollY * scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * scrollFactorX; - srf -= camera.scrollY * scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = 0; - var u0 = (frameX / textureWidth) + uOffset; - var v0 = (frameY / textureHeight) + vOffset; - var u1 = (frameX + frameWidth) / textureWidth + uOffset; - var v1 = (frameY + frameHeight) / textureHeight + vOffset; - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = u0; - vertexViewF32[vertexOffset + 3] = v0; - vertexViewU32[vertexOffset + 4] = tintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = u0; - vertexViewF32[vertexOffset + 8] = v1; - vertexViewU32[vertexOffset + 9] = tintTR; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = u1; - vertexViewF32[vertexOffset + 13] = v1; - vertexViewU32[vertexOffset + 14] = tintBL; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = u0; - vertexViewF32[vertexOffset + 18] = v0; - vertexViewU32[vertexOffset + 19] = tintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = u1; - vertexViewF32[vertexOffset + 23] = v1; - vertexViewU32[vertexOffset + 24] = tintBL; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = u1; - vertexViewF32[vertexOffset + 28] = v0; - vertexViewU32[vertexOffset + 29] = tintBR; - - this.vertexCount += 6; - }, - - /** - * Immediately draws a texture with no batching. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawTexture - * @since 3.2.0 - * - * @param {WebGLTexture} texture [description] - * @param {number} srcX - [description] - * @param {number} srcY - [description] - * @param {number} tint - [description] - * @param {number} alpha - [description] - * @param {number} frameX - [description] - * @param {number} frameY - [description] - * @param {number} frameWidth - [description] - * @param {number} frameHeight - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} transformMatrix - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This Pipeline. - */ - drawTexture: function ( - texture, - srcX, srcY, - tint, alpha, - frameX, frameY, frameWidth, frameHeight, - transformMatrix, - parentTransformMatrix - ) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var width = frameWidth; - var height = frameHeight; - var x = srcX; - var y = srcY; - var xw = x + width; - var yh = y + height; - var mva = transformMatrix[0]; - var mvb = transformMatrix[1]; - var mvc = transformMatrix[2]; - var mvd = transformMatrix[3]; - var mve = transformMatrix[4]; - var mvf = transformMatrix[5]; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var pca = mva * pma + mvb * pmc; - var pcb = mva * pmb + mvb * pmd; - var pcc = mvc * pma + mvd * pmc; - var pcd = mvc * pmb + mvd * pmd; - var pce = mve * pma + mvf * pmc + pme; - var pcf = mve * pmb + mvf * pmd + pmf; - mva = pca; - mvb = pcb; - mvc = pcc; - mvd = pcd; - mve = pce; - mvf = pcf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = 0; - var textureWidth = texture.width; - var textureHeight = texture.height; - var u0 = (frameX / textureWidth); - var v0 = (frameY / textureHeight); - var u1 = (frameX + frameWidth) / textureWidth; - var v1 = (frameY + frameHeight) / textureHeight; - tint = Utils.getTintAppendFloatAlpha(tint, alpha); - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = u0; - vertexViewF32[vertexOffset + 3] = v0; - vertexViewU32[vertexOffset + 4] = tint; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = u0; - vertexViewF32[vertexOffset + 8] = v1; - vertexViewU32[vertexOffset + 9] = tint; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = u1; - vertexViewF32[vertexOffset + 13] = v1; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = u0; - vertexViewF32[vertexOffset + 18] = v0; - vertexViewU32[vertexOffset + 19] = tint; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = u1; - vertexViewF32[vertexOffset + 23] = v1; - vertexViewU32[vertexOffset + 24] = tint; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = u1; - vertexViewF32[vertexOffset + 28] = v0; - vertexViewU32[vertexOffset + 29] = tint; - - this.vertexCount += 6; - - // Force an immediate draw - this.flush(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchGraphics - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchGraphics: function () - { - // Stub - } - -}); - -module.exports = TextureTintPipeline; - - -/***/ }), -/* 130 */ +/* 169 */ /***/ (function(module, exports) { /** @@ -30208,7 +37809,7 @@ module.exports = TextureTintPipeline; /** * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. - * If no parent was given or falls back to using `document.body`. + * If no parent was given it falls back to using `document.body`. * * @function Phaser.DOM.AddToDOM * @since 3.0.0 @@ -30234,7 +37835,7 @@ var AddToDOM = function (element, parent, overflowHidden) } else if (typeof parent === 'object' && parent.nodeType === 1) { - // Quick test for a HTMLelement + // Quick test for a HTMLElement target = parent; } } @@ -30243,7 +37844,7 @@ var AddToDOM = function (element, parent, overflowHidden) return element; } - // Fallback, covers an invalid ID and a non HTMLelement object + // Fallback, covers an invalid ID and a non HTMLElement object if (!target) { target = document.body; @@ -30263,7 +37864,7 @@ module.exports = AddToDOM; /***/ }), -/* 131 */ +/* 170 */ /***/ (function(module, exports) { /** @@ -30272,130 +37873,64 @@ module.exports = AddToDOM; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Browser specific prefix, so not going to change between contexts, only between browsers -var prefix = ''; - /** - * @namespace Phaser.Display.Canvas.Smoothing + * Compute a random integer between the `min` and `max` values, inclusive. + * + * @function Phaser.Math.Between * @since 3.0.0 + * + * @param {integer} min - The minimum value. + * @param {integer} max - The maximum value. + * + * @return {integer} The random integer. */ -var Smoothing = function () +var Between = function (min, max) { - /** - * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. - * - * @function Phaser.Display.Canvas.Smoothing.getPrefix - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {string} [description] - */ - var getPrefix = function (context) - { - var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; - - for (var i = 0; i < vendors.length; i++) - { - var s = vendors[i] + 'mageSmoothingEnabled'; - - if (s in context) - { - return s; - } - } - - return null; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.enable - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] - */ - var enable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = true; - } - - return context; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.disable - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] - */ - var disable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = false; - } - - return context; - }; - - /** - * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. - * Returns null if no smoothing prefix is available. - * - * @function Phaser.Display.Canvas.Smoothing.isEnabled - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {?boolean} [description] - */ - var isEnabled = function (context) - { - return (prefix !== null) ? context[prefix] : null; - }; - - return { - disable: disable, - enable: enable, - getPrefix: getPrefix, - isEnabled: isEnabled - }; - + return Math.floor(Math.random() * (max - min + 1) + min); }; -module.exports = Smoothing(); +module.exports = Between; /***/ }), -/* 132 */ +/* 171 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates a Catmull-Rom value. + * + * @function Phaser.Math.CatmullRom + * @since 3.0.0 + * + * @param {number} t - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {number} p2 - [description] + * @param {number} p3 - [description] + * + * @return {number} The Catmull-Rom value. + */ +var CatmullRom = function (t, p0, p1, p2, p3) +{ + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + var t2 = t * t; + var t3 = t * t2; + + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; +}; + +module.exports = CatmullRom; + + +/***/ }), +/* 172 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -30404,10 +37939,374 @@ module.exports = Smoothing(); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var HexStringToColor = __webpack_require__(285); -var IntegerToColor = __webpack_require__(283); -var ObjectToColor = __webpack_require__(281); -var RGBStringToColor = __webpack_require__(280); +var CONST = __webpack_require__(16); + +/** + * Convert the given angle in radians, to the equivalent angle in degrees. + * + * @function Phaser.Math.RadToDeg + * @since 3.0.0 + * + * @param {number} radians - The angle in radians to convert ot degrees. + * + * @return {integer} The given angle converted to degrees. + */ +var RadToDeg = function (radians) +{ + return radians * CONST.RAD_TO_DEG; +}; + +module.exports = RadToDeg; + + +/***/ }), +/* 173 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +// points is an array of Point-like objects, +// either 2 dimensional arrays, or objects with public x/y properties: +// var points = [ +// [100, 200], +// [200, 400], +// { x: 30, y: 60 } +// ] + +/** + * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. + * + * @function Phaser.Geom.Rectangle.FromPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {array} points - An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. + * @param {Phaser.Geom.Rectangle} [out] - Optional Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted `out` Rectangle, or a new Rectangle if none was provided. + */ +var FromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (points.length === 0) + { + return out; + } + + var minX = Number.MAX_VALUE; + var minY = Number.MAX_VALUE; + + var maxX = Number.MIN_SAFE_INTEGER; + var maxY = Number.MIN_SAFE_INTEGER; + + var p; + var px; + var py; + + for (var i = 0; i < points.length; i++) + { + p = points[i]; + + if (Array.isArray(p)) + { + px = p[0]; + py = p[1]; + } + else + { + px = p.x; + py = p.y; + } + + minX = Math.min(minX, px); + minY = Math.min(minY, py); + + maxX = Math.max(maxX, px); + maxY = Math.max(maxY, py); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; +}; + +module.exports = FromPoints; + + +/***/ }), +/* 174 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Back = __webpack_require__(369); +var Bounce = __webpack_require__(368); +var Circular = __webpack_require__(367); +var Cubic = __webpack_require__(366); +var Elastic = __webpack_require__(365); +var Expo = __webpack_require__(364); +var Linear = __webpack_require__(363); +var Quadratic = __webpack_require__(362); +var Quartic = __webpack_require__(361); +var Quintic = __webpack_require__(360); +var Sine = __webpack_require__(359); +var Stepped = __webpack_require__(358); + +// EaseMap +module.exports = { + + Power0: Linear, + Power1: Quadratic.Out, + Power2: Cubic.Out, + Power3: Quartic.Out, + Power4: Quintic.Out, + + Linear: Linear, + Quad: Quadratic.Out, + Cubic: Cubic.Out, + Quart: Quartic.Out, + Quint: Quintic.Out, + Sine: Sine.Out, + Expo: Expo.Out, + Circ: Circular.Out, + Elastic: Elastic.Out, + Back: Back.Out, + Bounce: Bounce.Out, + Stepped: Stepped, + + 'Quad.easeIn': Quadratic.In, + 'Cubic.easeIn': Cubic.In, + 'Quart.easeIn': Quartic.In, + 'Quint.easeIn': Quintic.In, + 'Sine.easeIn': Sine.In, + 'Expo.easeIn': Expo.In, + 'Circ.easeIn': Circular.In, + 'Elastic.easeIn': Elastic.In, + 'Back.easeIn': Back.In, + 'Bounce.easeIn': Bounce.In, + + 'Quad.easeOut': Quadratic.Out, + 'Cubic.easeOut': Cubic.Out, + 'Quart.easeOut': Quartic.Out, + 'Quint.easeOut': Quintic.Out, + 'Sine.easeOut': Sine.Out, + 'Expo.easeOut': Expo.Out, + 'Circ.easeOut': Circular.Out, + 'Elastic.easeOut': Elastic.Out, + 'Back.easeOut': Back.Out, + 'Bounce.easeOut': Bounce.Out, + + 'Quad.easeInOut': Quadratic.InOut, + 'Cubic.easeInOut': Cubic.InOut, + 'Quart.easeInOut': Quartic.InOut, + 'Quint.easeInOut': Quintic.InOut, + 'Sine.easeInOut': Sine.InOut, + 'Expo.easeInOut': Expo.InOut, + 'Circ.easeInOut': Circular.InOut, + 'Elastic.easeInOut': Elastic.InOut, + 'Back.easeInOut': Back.InOut, + 'Bounce.easeInOut': Bounce.InOut + +}; + + +/***/ }), +/* 175 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Centers this Rectangle so that the center coordinates match the given x and y values. + +/** + * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. + * + * @function Phaser.Geom.Rectangle.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to be centered. + * @param {number} x - The X coordinate of the Rectangle's center. + * @param {number} y - The Y coordinate of the Rectangle's center. + * + * @return {Phaser.Geom.Rectangle} The centered rectangle. + */ +var CenterOn = function (rect, x, y) +{ + rect.x = x - (rect.width / 2); + rect.y = y - (rect.height / 2); + + return rect; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 176 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetColor = __webpack_require__(177); + +/** + * Converts an HSV (hue, saturation and value) color value to RGB. + * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes HSV values are contained in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HSVToRGB + * @since 3.0.0 + * + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * @param {(ColorObject|Phaser.Display.Color)} [out] - A Color object to store the results in. If not given a new ColorObject will be created. + * + * @return {(ColorObject|Phaser.Display.Color)} An object with the red, green and blue values set in the r, g and b properties. + */ +var HSVToRGB = function (h, s, v, out) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var i = Math.floor(h * 6); + var f = h * 6 - i; + + var p = Math.floor((v * (1 - s)) * 255); + var q = Math.floor((v * (1 - f * s)) * 255); + var t = Math.floor((v * (1 - (1 - f) * s)) * 255); + + v = Math.floor(v *= 255); + + var r = v; + var g = v; + var b = v; + + var c = i % 6; + + if (c === 0) + { + g = t; + b = p; + } + else if (c === 1) + { + r = q; + b = p; + } + else if (c === 2) + { + r = p; + b = t; + } + else if (c === 3) + { + r = p; + g = q; + } + else if (c === 4) + { + r = t; + g = p; + } + else if (c === 5) + { + g = p; + b = q; + } + + if (!out) + { + return { r: r, g: g, b: b, color: GetColor(r, g, b) }; + } + else if (out.setTo) + { + return out.setTo(r, g, b, out.alpha, false); + } + else + { + out.r = r; + out.g = g; + out.b = b; + out.color = GetColor(r, g, b); + + return out; + } +}; + +module.exports = HSVToRGB; + + +/***/ }), +/* 177 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given 3 separate color values this will return an integer representation of it. + * + * @function Phaser.Display.Color.GetColor + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * + * @return {number} The combined color value. + */ +var GetColor = function (red, green, blue) +{ + return red << 16 | green << 8 | blue; +}; + +module.exports = GetColor; + + +/***/ }), +/* 178 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HexStringToColor = __webpack_require__(377); +var IntegerToColor = __webpack_require__(374); +var ObjectToColor = __webpack_require__(372); +var RGBStringToColor = __webpack_require__(371); /** * Converts the given source color value into an instance of a Color class. @@ -30451,7 +38350,7 @@ module.exports = ValueToColor; /***/ }), -/* 133 */ +/* 179 */ /***/ (function(module, exports) { /** @@ -30527,7 +38426,7 @@ module.exports = Pad; /***/ }), -/* 134 */ +/* 180 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -30536,7 +38435,558 @@ module.exports = Pad; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +var Class = __webpack_require__(0); + +/** + * @callback EachMapCallback + * @generic E - [entry] + * + * @param {string} key - [description] + * @param {*} entry - [description] + * + * @return {?boolean} [description] + */ + +/** + * @classdesc + * The keys of a Map can be arbitrary values. + * + * ```javascript + * var map = new Map([ + * [ 1, 'one' ], + * [ 2, 'two' ], + * [ 3, 'three' ] + * ]); + * ``` + * + * @class Map + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic K + * @generic V + * @genericUse {V[]} - [elements] + * + * @param {Array.<*>} elements - An optional array of key-value pairs to populate this Map with. + */ +var Map = new Class({ + + initialize: + + function Map (elements) + { + /** + * The entries in this Map. + * + * @genericUse {Object.} - [$type] + * + * @name Phaser.Structs.Map#entries + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.entries = {}; + + /** + * The number of key / value pairs in this Map. + * + * @name Phaser.Structs.Map#size + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.size = 0; + + if (Array.isArray(elements)) + { + for (var i = 0; i < elements.length; i++) + { + this.set(elements[i][0], elements[i][1]); + } + } + }, + + /** + * Adds an element with a specified `key` and `value` to this Map. + * + * @method Phaser.Structs.Map#set + * @since 3.0.0 + * + * @genericUse {K} - [key] + * @genericUse {V} - [value] + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @param {string} key - The key of the element to be added to this Map. + * @param {*} value - The value of the element to be added to this Map. + * + * @return {Phaser.Structs.Map} This Map object. + */ + set: function (key, value) + { + if (!this.has(key)) + { + this.entries[key] = value; + this.size++; + } + + return this; + }, + + /** + * Returns the value associated to the `key`, or `undefined` if there is none. + * + * @method Phaser.Structs.Map#get + * @since 3.0.0 + * + * @genericUse {K} - [key] + * @genericUse {V} - [$return] + * + * @param {string} key - The key of the element to return from the `Map` object. + * + * @return {*} The element associated with the specified key or `undefined` if the key can't be found in this Map object. + */ + get: function (key) + { + if (this.has(key)) + { + return this.entries[key]; + } + }, + + /** + * Returns an `Array` of all the values stored in this Map. + * + * @method Phaser.Structs.Map#getArray + * @since 3.0.0 + * + * @genericUse {V[]} - [$return] + * + * @return {Array.<*>} An array of the values stored in this Map. + */ + getArray: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * Returns a boolean indicating whether an element with the specified key exists or not. + * + * @method Phaser.Structs.Map#has + * @since 3.0.0 + * + * @genericUse {K} - [key] + * + * @param {string} key - The key of the element to test for presence of in this Map. + * + * @return {boolean} Returns `true` if an element with the specified key exists in this Map, otherwise `false`. + */ + has: function (key) + { + return (this.entries.hasOwnProperty(key)); + }, + + /** + * Delete the specified element from this Map. + * + * @method Phaser.Structs.Map#delete + * @since 3.0.0 + * + * @genericUse {K} - [key] + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @param {string} key - The key of the element to delete from this Map. + * + * @return {Phaser.Structs.Map} This Map object. + */ + delete: function (key) + { + if (this.has(key)) + { + delete this.entries[key]; + this.size--; + } + + return this; + }, + + /** + * Delete all entries from this Map. + * + * @method Phaser.Structs.Map#clear + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @return {Phaser.Structs.Map} This Map object. + */ + clear: function () + { + Object.keys(this.entries).forEach(function (prop) + { + delete this.entries[prop]; + + }, this); + + this.size = 0; + + return this; + }, + + /** + * Returns all entries keys in this Map. + * + * @method Phaser.Structs.Map#keys + * @since 3.0.0 + * + * @genericUse {K[]} - [$return] + * + * @return {string[]} Array containing entries' keys. + */ + keys: function () + { + return Object.keys(this.entries); + }, + + /** + * Returns an `Array` of all entries. + * + * @method Phaser.Structs.Map#values + * @since 3.0.0 + * + * @genericUse {V[]} - [$return] + * + * @return {Array.<*>} An `Array` of entries. + */ + values: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * Dumps the contents of this Map to the console via `console.group`. + * + * @method Phaser.Structs.Map#dump + * @since 3.0.0 + */ + dump: function () + { + var entries = this.entries; + + // eslint-disable-next-line no-console + console.group('Map'); + + for (var key in entries) + { + console.log(key, entries[key]); + } + + // eslint-disable-next-line no-console + console.groupEnd(); + }, + + /** + * Passes all entries in this Map to the given callback. + * + * @method Phaser.Structs.Map#each + * @since 3.0.0 + * + * @genericUse {EachMapCallback.} - [callback] + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @param {EachMapCallback} callback - The callback which will receive the keys and entries held in this Map. + * + * @return {Phaser.Structs.Map} This Map object. + */ + each: function (callback) + { + var entries = this.entries; + + for (var key in entries) + { + if (callback(key, entries[key]) === false) + { + break; + } + } + + return this; + }, + + /** + * Returns `true` if the value exists within this Map. Otherwise, returns `false`. + * + * @method Phaser.Structs.Map#contains + * @since 3.0.0 + * + * @genericUse {V} - [value] + * + * @param {*} value - The value to search for. + * + * @return {boolean} `true` if the value is found, otherwise `false`. + */ + contains: function (value) + { + var entries = this.entries; + + for (var key in entries) + { + if (entries[key] === value) + { + return true; + } + } + + return false; + }, + + /** + * Merges all new keys from the given Map into this one. + * If it encounters a key that already exists it will be skipped unless override is set to `true`. + * + * @method Phaser.Structs.Map#merge + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Map.} - [map,$return] + * + * @param {Phaser.Structs.Map} map - The Map to merge in to this Map. + * @param {boolean} [override=false] - Set to `true` to replace values in this Map with those from the source map, or `false` to skip them. + * + * @return {Phaser.Structs.Map} This Map object. + */ + merge: function (map, override) + { + if (override === undefined) { override = false; } + + var local = this.entries; + var source = map.entries; + + for (var key in source) + { + if (local.hasOwnProperty(key) && override) + { + local[key] = source[key]; + } + else + { + this.set(key, source[key]); + } + } + + return this; + } + +}); + +module.exports = Map; + + +/***/ }), +/* 181 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate a smooth interpolation percentage of `x` between `min` and `max`. + * + * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, + * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, + * between 0 and 1 otherwise. + * + * @function Phaser.Math.SmoothStep + * @since 3.0.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep} + * + * @param {number} x - The input value. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The percentage of interpolation, between 0 and 1. + */ +var SmoothStep = function (x, min, max) +{ + if (x <= min) + { + return 0; + } + + if (x >= max) + { + return 1; + } + + x = (x - min) / (max - min); + + return x * x * (3 - 2 * x); +}; + +module.exports = SmoothStep; + + +/***/ }), +/* 182 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate a smoother interpolation percentage of `x` between `min` and `max`. + * + * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, + * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, + * between 0 and 1 otherwise. + * + * Produces an even smoother interpolation than {@link Phaser.Math.SmoothStep}. + * + * @function Phaser.Math.SmootherStep + * @since 3.0.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} + * + * @param {number} x - The input value. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The percentage of interpolation, between 0 and 1. + */ +var SmootherStep = function (x, min, max) +{ + x = Math.max(0, Math.min(1, (x - min) / (max - min))); + + return x * x * x * (x * (x * 6 - 15) + 10); +}; + +module.exports = SmootherStep; + + +/***/ }), +/* 183 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RotateAroundDistance + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. + * @param {number} x - The horizontal coordinate to rotate around. + * @param {number} y - The vertical coordinate to rotate around. + * @param {number} angle - The angle of rotation in radians. + * @param {number} distance - [description] + * + * @return {Phaser.Geom.Point} The given point. + */ +var RotateAroundDistance = function (point, x, y, angle, distance) +{ + var t = angle + Math.atan2(point.y - y, point.x - x); + + point.x = x + (distance * Math.cos(t)); + point.y = y + (distance * Math.sin(t)); + + return point; +}; + +module.exports = RotateAroundDistance; + + +/***/ }), +/* 184 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Random = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + // Basis vectors + var ux = triangle.x2 - triangle.x1; + var uy = triangle.y2 - triangle.y1; + + var vx = triangle.x3 - triangle.x1; + var vy = triangle.y3 - triangle.y1; + + // Random point within the unit square + var r = Math.random(); + var s = Math.random(); + + // Point outside the triangle? Remap it. + if (r + s >= 1) + { + r = 1 - r; + s = 1 - s; + } + + out.x = triangle.x1 + ((ux * r) + (vx * s)); + out.y = triangle.y1 + ((uy * r) + (vy * s)); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 185 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); /** * Returns a uniformly distributed random point from anywhere within the given Ellipse. @@ -30568,7 +39018,136 @@ module.exports = Random; /***/ }), -/* 135 */ +/* 186 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the WebGL rendering pipeline of a Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline + * @webglOnly + * @since 3.0.0 + */ + +var Pipeline = { + + /** + * The initial WebGL pipeline of this Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + defaultPipeline: null, + + /** + * The current WebGL pipeline of this Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline#pipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + pipeline: null, + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#initPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} [pipelineName=TextureTintPipeline] - The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + initPipeline: function (pipelineName) + { + if (pipelineName === undefined) { pipelineName = 'TextureTintPipeline'; } + + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.defaultPipeline = renderer.getPipeline(pipelineName); + this.pipeline = this.defaultPipeline; + + return true; + } + + return false; + }, + + /** + * Sets the active WebGL Pipeline of this Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#setPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * + * @return {this} This Game Object instance. + */ + setPipeline: function (pipelineName) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.pipeline = renderer.getPipeline(pipelineName); + } + + return this; + }, + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * + * @method Phaser.GameObjects.Components.Pipeline#resetPipeline + * @webglOnly + * @since 3.0.0 + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + resetPipeline: function () + { + this.pipeline = this.defaultPipeline; + + return (this.pipeline !== null); + }, + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + * + * @method Phaser.GameObjects.Components.Pipeline#getPipelineName + * @webglOnly + * @since 3.0.0 + * + * @return {string} The string-based name of the pipeline being used by this Game Object. + */ + getPipelineName: function () + { + return this.pipeline.name; + } + +}; + +module.exports = Pipeline; + + +/***/ }), +/* 187 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -30577,8 +39156,151 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Perimeter = __webpack_require__(97); -var Point = __webpack_require__(5); +var Point = __webpack_require__(6); + +/** + * Returns a random point within a Rectangle. + * + * @function Phaser.Geom.Rectangle.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to return a point from. + * @param {Phaser.Geom.Point} out - The object to update with the point's coordinates. + * + * @return {Phaser.Geom.Point} The modified `out` object, or a new Point if none was provided. + */ +var Random = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.x + (Math.random() * rect.width); + out.y = rect.y + (Math.random() * rect.height); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 188 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a random point on a given Line. + * + * @function Phaser.Geom.Line.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The Line to calculate the random Point on. + * @param {(Phaser.Geom.Point|object)} [out] - An instance of a Point to be modified. + * + * @return {(Phaser.Geom.Point|object)} A random Point on the Line. + */ +var Random = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + var t = Math.random(); + + out.x = line.x1 + t * (line.x2 - line.x1); + out.y = line.y1 + t * (line.y2 - line.y1); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 189 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); +var Point = __webpack_require__(6); + +/** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * @function Phaser.Geom.Line.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line. + * @param {integer} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {number} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param {(array|Phaser.Geom.Point[])} [out] - An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * + * @return {(array|Phaser.Geom.Point[])} An array of Points, or point-like objects, containing the coordinates of the points on the line. + */ +var GetPoints = function (line, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Length(line) / stepRate; + } + + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + var x = x1 + (x2 - x1) * position; + var y = y1 + (y2 - y1) * position; + + out.push(new Point(x, y)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 190 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Perimeter = __webpack_require__(124); +var Point = __webpack_require__(6); /** * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. @@ -30589,7 +39311,7 @@ var Point = __webpack_require__(5); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [out] - [description] * * @return {Phaser.Geom.Point} [description] @@ -30645,7 +39367,7 @@ module.exports = GetPoint; /***/ }), -/* 136 */ +/* 191 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -30654,2288 +39376,7 @@ module.exports = GetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * - * @function Phaser.Geom.Circle.CircumferencePoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. - * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. - */ -var CircumferencePoint = function (circle, angle, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = circle.x + (circle.radius * Math.cos(angle)); - out.y = circle.y + (circle.radius * Math.sin(angle)); - - return out; -}; - -module.exports = CircumferencePoint; - - -/***/ }), -/* 137 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A Tileset is a combination of an image containing the tiles and a container for data about - * each tile. - * - * @class Tileset - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {string} name - The name of the tileset in the map data. - * @param {integer} firstgid - The first tile index this tileset contains. - * @param {integer} [tileWidth=32] - Width of each tile (in pixels). - * @param {integer} [tileHeight=32] - Height of each tile (in pixels). - * @param {integer} [tileMargin=0] - The margin around all tiles in the sheet (in pixels). - * @param {integer} [tileSpacing=0] - The spacing between each tile in the sheet (in pixels). - * @param {object} [tileProperties={}] - Custom properties defined per tile in the Tileset. - * These typically are custom properties created in Tiled when editing a tileset. - * @param {object} [tileData={}] - Data stored per tile. These typically are created in Tiled - * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. - */ -var Tileset = new Class({ - - initialize: - - function Tileset (name, firstgid, tileWidth, tileHeight, tileMargin, tileSpacing, tileProperties, tileData) - { - if (tileWidth === undefined || tileWidth <= 0) { tileWidth = 32; } - if (tileHeight === undefined || tileHeight <= 0) { tileHeight = 32; } - if (tileMargin === undefined) { tileMargin = 0; } - if (tileSpacing === undefined) { tileSpacing = 0; } - if (tileProperties === undefined) { tileProperties = {}; } - if (tileData === undefined) { tileData = {}; } - - /** - * The name of the Tileset. - * - * @name Phaser.Tilemaps.Tileset#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The starting index of the first tile index this Tileset contains. - * - * @name Phaser.Tilemaps.Tileset#firstgid - * @type {integer} - * @since 3.0.0 - */ - this.firstgid = firstgid; - - /** - * The width of each tile (in pixels). Use setTileSize to change. - * - * @name Phaser.Tilemaps.Tileset#tileWidth - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileWidth = tileWidth; - - /** - * The height of each tile (in pixels). Use setTileSize to change. - * - * @name Phaser.Tilemaps.Tileset#tileHeight - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileHeight = tileHeight; - - /** - * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.Tileset#tileMargin - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileMargin = tileMargin; - - /** - * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.Tileset#tileSpacing - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileSpacing = tileSpacing; - - /** - * Tileset-specific properties per tile that are typically defined in the Tiled editor in the - * Tileset editor. - * - * @name Phaser.Tilemaps.Tileset#tileProperties - * @type {object} - * @since 3.0.0 - */ - this.tileProperties = tileProperties; - - /** - * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within - * the Tileset collision editor. This is where collision objects and terrain are stored. - * - * @name Phaser.Tilemaps.Tileset#tileData - * @type {object} - * @since 3.0.0 - */ - this.tileData = tileData; - - /** - * The cached image that contains the individual tiles. Use setImage to set. - * - * @name Phaser.Tilemaps.Tileset#image - * @type {?Phaser.Textures.Texture} - * @readOnly - * @since 3.0.0 - */ - this.image = null; - - /** - * The number of tile rows in the the tileset. - * - * @name Phaser.Tilemaps.Tileset#rows - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.rows = 0; - - /** - * The number of tile columns in the tileset. - * - * @name Phaser.Tilemaps.Tileset#columns - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.columns = 0; - - /** - * The total number of tiles in the tileset. - * - * @name Phaser.Tilemaps.Tileset#total - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.total = 0; - - /** - * The look-up table to specific tile image texture coordinates (UV in pixels). Each element - * contains the coordinates for a tile in an object of the form {x, y}. - * - * @name Phaser.Tilemaps.Tileset#texCoordinates - * @type {object[]} - * @readOnly - * @since 3.0.0 - */ - this.texCoordinates = []; - }, - - /** - * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. - * - * @method Phaser.Tilemaps.Tileset#getTileProperties - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {?(object|undefined)} - */ - getTileProperties: function (tileIndex) - { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.tileProperties[tileIndex - this.firstgid]; - }, - - /** - * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained - * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision - * info and terrain mapping. - * - * @method Phaser.Tilemaps.Tileset#getTileData - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {?object|undefined} - */ - getTileData: function (tileIndex) - { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.tileData[tileIndex - this.firstgid]; - }, - - /** - * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. - * - * @method Phaser.Tilemaps.Tileset#getTileCollisionGroup - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {?object} - */ - getTileCollisionGroup: function (tileIndex) - { - var data = this.getTileData(tileIndex); - - return (data && data.objectgroup) ? data.objectgroup : null; - }, - - /** - * Returns true if and only if this Tileset contains the given tile index. - * - * @method Phaser.Tilemaps.Tileset#containsTileIndex - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {boolean} - */ - containsTileIndex: function (tileIndex) - { - return ( - tileIndex >= this.firstgid && - tileIndex < (this.firstgid + this.total) - ); - }, - - /** - * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. - * Returns null if tile index is not contained in this Tileset. - * - * @method Phaser.Tilemaps.Tileset#getTileTextureCoordinates - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {?object} Object in the form { x, y } representing the top-left UV coordinate - * within the Tileset image. - */ - getTileTextureCoordinates: function (tileIndex) - { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.texCoordinates[tileIndex - this.firstgid]; - }, - - /** - * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setImage - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The image that contains the tiles. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setImage: function (texture) - { - this.image = texture; - - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - - return this; - }, - - /** - * Sets the tile width & height and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setTileSize - * @since 3.0.0 - * - * @param {integer} [tileWidth] - The width of a tile in pixels. - * @param {integer} [tileHeight] - The height of a tile in pixels. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setTileSize: function (tileWidth, tileHeight) - { - if (tileWidth !== undefined) { this.tileWidth = tileWidth; } - if (tileHeight !== undefined) { this.tileHeight = tileHeight; } - - if (this.image) - { - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - } - - return this; - }, - - /** - * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setSpacing - * @since 3.0.0 - * - * @param {integer} [margin] - The margin around the tiles in the sheet (in pixels). - * @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels). - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setSpacing: function (margin, spacing) - { - if (margin !== undefined) { this.tileMargin = margin; } - if (spacing !== undefined) { this.tileSpacing = spacing; } - - if (this.image) - { - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - } - - return this; - }, - - /** - * Updates tile texture coordinates and tileset data. - * - * @method Phaser.Tilemaps.Tileset#updateTileData - * @since 3.0.0 - * - * @param {integer} imageWidth - The (expected) width of the image to slice. - * @param {integer} imageHeight - The (expected) height of the image to slice. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - updateTileData: function (imageWidth, imageHeight) - { - var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); - var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); - - if (rowCount % 1 !== 0 || colCount % 1 !== 0) - { - console.warn('Tileset ' + this.name + ' image tile area is not an even multiple of tile size'); - } - - // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated - // - hence the floor when calculating the rows/columns. - rowCount = Math.floor(rowCount); - colCount = Math.floor(colCount); - - this.rows = rowCount; - this.columns = colCount; - - // In Tiled, "empty" spaces in a tileset count as tiles and hence count towards the gid - this.total = rowCount * colCount; - - this.texCoordinates.length = 0; - - var tx = this.tileMargin; - var ty = this.tileMargin; - - for (var y = 0; y < this.rows; y++) - { - for (var x = 0; x < this.columns; x++) - { - this.texCoordinates.push({ x: tx, y: ty }); - tx += this.tileWidth + this.tileSpacing; - } - - tx = this.tileMargin; - ty += this.tileHeight + this.tileSpacing; - } - - return this; - } - -}); - -module.exports = Tileset; - - -/***/ }), -/* 138 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.TileToWorldY - * @private - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} - */ -var TileToWorldY = function (tileY, camera, layer) -{ - var tileHeight = layer.baseTileHeight; - var tilemapLayer = layer.tilemapLayer; - var layerWorldY = 0; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); - - tileHeight *= tilemapLayer.scaleY; - } - - return layerWorldY + tileY * tileHeight; -}; - -module.exports = TileToWorldY; - - -/***/ }), -/* 139 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.TileToWorldX - * @private - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} - */ -var TileToWorldX = function (tileX, camera, layer) -{ - var tileWidth = layer.baseTileWidth; - var tilemapLayer = layer.tilemapLayer; - var layerWorldX = 0; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX); - - tileWidth *= tilemapLayer.scaleX; - } - - return layerWorldX + tileX * tileWidth; -}; - -module.exports = TileToWorldX; - - -/***/ }), -/* 140 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsInLayerBounds = __webpack_require__(105); - -/** - * Gets a tile at the given tile coordinates from the given layer. - * - * @function Phaser.Tilemaps.Components.GetTileAt - * @private - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ -var GetTileAt = function (tileX, tileY, nonNull, layer) -{ - if (nonNull === undefined) { nonNull = false; } - - if (IsInLayerBounds(tileX, tileY, layer)) - { - var tile = layer.data[tileY][tileX]; - if (tile === null) - { - return null; - } - else if (tile.index === -1) - { - return nonNull ? tile : null; - } - else - { - return tile; - } - } - else - { - return null; - } -}; - -module.exports = GetTileAt; - - -/***/ }), -/* 141 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps.Components - */ - -module.exports = { - - CalculateFacesAt: __webpack_require__(220), - CalculateFacesWithin: __webpack_require__(40), - Copy: __webpack_require__(667), - CreateFromTiles: __webpack_require__(666), - CullTiles: __webpack_require__(665), - Fill: __webpack_require__(664), - FilterTiles: __webpack_require__(663), - FindByIndex: __webpack_require__(662), - FindTile: __webpack_require__(661), - ForEachTile: __webpack_require__(660), - GetTileAt: __webpack_require__(140), - GetTileAtWorldXY: __webpack_require__(659), - GetTilesWithin: __webpack_require__(21), - GetTilesWithinShape: __webpack_require__(658), - GetTilesWithinWorldXY: __webpack_require__(657), - HasTileAt: __webpack_require__(321), - HasTileAtWorldXY: __webpack_require__(656), - IsInLayerBounds: __webpack_require__(105), - PutTileAt: __webpack_require__(219), - PutTileAtWorldXY: __webpack_require__(655), - PutTilesAt: __webpack_require__(654), - Randomize: __webpack_require__(653), - RemoveTileAt: __webpack_require__(320), - RemoveTileAtWorldXY: __webpack_require__(652), - RenderDebug: __webpack_require__(651), - ReplaceByIndex: __webpack_require__(322), - SetCollision: __webpack_require__(650), - SetCollisionBetween: __webpack_require__(649), - SetCollisionByExclusion: __webpack_require__(648), - SetCollisionByProperty: __webpack_require__(647), - SetCollisionFromCollisionGroup: __webpack_require__(646), - SetTileIndexCallback: __webpack_require__(645), - SetTileLocationCallback: __webpack_require__(644), - Shuffle: __webpack_require__(643), - SwapByIndex: __webpack_require__(642), - TileToWorldX: __webpack_require__(139), - TileToWorldXY: __webpack_require__(641), - TileToWorldY: __webpack_require__(138), - WeightedRandomize: __webpack_require__(640), - WorldToTileX: __webpack_require__(53), - WorldToTileXY: __webpack_require__(639), - WorldToTileY: __webpack_require__(52) - -}; - - -/***/ }), -/* 142 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(343); -var Sprite = __webpack_require__(34); - -/** - * @classdesc - * An Arcade Physics Sprite Game Object. - * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - * - * @class Sprite - * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Arcade.Components.Acceleration - * @extends Phaser.Physics.Arcade.Components.Angular - * @extends Phaser.Physics.Arcade.Components.Bounce - * @extends Phaser.Physics.Arcade.Components.Debug - * @extends Phaser.Physics.Arcade.Components.Drag - * @extends Phaser.Physics.Arcade.Components.Enable - * @extends Phaser.Physics.Arcade.Components.Friction - * @extends Phaser.Physics.Arcade.Components.Gravity - * @extends Phaser.Physics.Arcade.Components.Immovable - * @extends Phaser.Physics.Arcade.Components.Mass - * @extends Phaser.Physics.Arcade.Components.Size - * @extends Phaser.Physics.Arcade.Components.Velocity - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var ArcadeSprite = new Class({ - - Extends: Sprite, - - Mixins: [ - Components.Acceleration, - Components.Angular, - Components.Bounce, - Components.Debug, - Components.Drag, - Components.Enable, - Components.Friction, - Components.Gravity, - Components.Immovable, - Components.Mass, - Components.Size, - Components.Velocity - ], - - initialize: - - function ArcadeSprite (scene, x, y, texture, frame) - { - Sprite.call(this, scene, x, y, texture, frame); - - /** - * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. - * - * @name Phaser.Physics.Arcade.Sprite#body - * @type {?Phaser.Physics.Arcade.Body} - * @default null - * @since 3.0.0 - */ - this.body = null; - } - -}); - -module.exports = ArcadeSprite; - - -/***/ }), -/* 143 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); -var ParseXML = __webpack_require__(270); - -/** - * @typedef {object} Phaser.Loader.FileTypes.XMLFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='xml'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single XML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. - * - * @class XMLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var XMLFile = new Class({ - - Extends: File, - - initialize: - - function XMLFile (loader, key, url, xhrSettings) - { - var extension = 'xml'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'xml', - cache: loader.cacheManager.xml, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.XMLFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = ParseXML(this.xhrLoader.responseText); - - if (this.data) - { - this.onProcessComplete(); - } - else - { - console.warn('Invalid XMLFile: ' + this.key); - - this.onProcessError(); - } - } - -}); - -/** - * Adds an XML file, or array of XML files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.xml('wavedata', 'files/AlienWaveData.xml'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global XML Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the XML Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the XML Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.xml({ - * key: 'wavedata', - * url: 'files/AlienWaveData.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.XMLFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.xml('wavedata', 'files/AlienWaveData.xml'); - * // and later in your game ... - * var data = this.cache.xml.get('wavedata'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the XML Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" - * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the XML File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#xml - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig|Phaser.Loader.FileTypes.XMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('xml', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new XMLFile(this, key[i])); - } - } - else - { - this.addFile(new XMLFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = XMLFile; - - -/***/ }), -/* 144 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// This is based off an explanation and expanded math presented by Paul Bourke: -// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.LineToLine - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line1 - [description] - * @param {Phaser.Geom.Line} line2 - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {boolean} [description] - */ -var LineToLine = function (line1, line2, out) -{ - if (out === undefined) { out = new Point(); } - - var x1 = line1.x1; - var y1 = line1.y1; - var x2 = line1.x2; - var y2 = line1.y2; - - var x3 = line2.x1; - var y3 = line2.y1; - var x4 = line2.x2; - var y4 = line2.y2; - - var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); - var deNom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - - // Make sure there is not a division by zero - this also indicates that the lines are parallel. - // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). - // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). - - if (deNom === 0) - { - return false; - } - - // Calculate the intermediate fractional point that the lines potentially intersect. - - var uA = numA / deNom; - var uB = numB / deNom; - - // The fractional point will be between 0 and 1 inclusive if the lines intersect. - // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. - - if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) - { - out.x = x1 + (uA * (x2 - x1)); - out.y = y1 + (uA * (y2 - y1)); - - return true; - } - - return false; -}; - -module.exports = LineToLine; - - -/***/ }), -/* 145 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var MeshRender = __webpack_require__(862); - -/** - * @classdesc - * A Mesh Game Object. - * - * @class Mesh - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @webglOnly - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number[]} vertices - An array containing the vertices data for this Mesh. - * @param {number[]} uv - An array containing the uv data for this Mesh. - * @param {number[]} colors - An array containing the color data for this Mesh. - * @param {number[]} alphas - An array containing the alpha data for this Mesh. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Mesh = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Size, - Components.Texture, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - MeshRender - ], - - initialize: - - function Mesh (scene, x, y, vertices, uv, colors, alphas, texture, frame) - { - GameObject.call(this, scene, 'Mesh'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOrigin(); - this.initPipeline('TextureTintPipeline'); - - if (vertices.length !== uv.length) - { - throw new Error('Mesh Vertex count must match UV count'); - } - - var verticesUB = (vertices.length / 2) | 0; - - if (colors.length > 0 && colors.length < verticesUB) - { - throw new Error('Mesh Color count must match Vertex count'); - } - - if (alphas.length > 0 && alphas.length < verticesUB) - { - throw new Error('Mesh Alpha count must match Vertex count'); - } - - var i; - - if (colors.length === 0) - { - for (i = 0; i < verticesUB; ++i) - { - colors[i] = 0xFFFFFF; - } - } - - if (alphas.length === 0) - { - for (i = 0; i < verticesUB; ++i) - { - alphas[i] = 1.0; - } - } - - /** - * An array containing the vertices data for this Mesh. - * - * @name Phaser.GameObjects.Mesh#vertices - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertices = new Float32Array(vertices); - - /** - * An array containing the uv data for this Mesh. - * - * @name Phaser.GameObjects.Mesh#uv - * @type {Float32Array} - * @since 3.0.0 - */ - this.uv = new Float32Array(uv); - - /** - * An array containing the color data for this Mesh. - * - * @name Phaser.GameObjects.Mesh#colors - * @type {Uint32Array} - * @since 3.0.0 - */ - this.colors = new Uint32Array(colors); - - /** - * An array containing the alpha data for this Mesh. - * - * @name Phaser.GameObjects.Mesh#alphas - * @type {Float32Array} - * @since 3.0.0 - */ - this.alphas = new Float32Array(alphas); - } - -}); - -module.exports = Mesh; - - -/***/ }), -/* 146 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns a Random element from the array. - * - * @function Phaser.Utils.Array.GetRandom - * @since 3.0.0 - * - * @param {array} array - The array to select the random entry from. - * @param {integer} [startIndex=0] - An optional start index. - * @param {integer} [length=array.length] - An optional length, the total number of elements (from the startIndex) to choose from. - * - * @return {object} A random element from the array, or `null` if no element could be found in the range given. - */ -var GetRandom = function (array, startIndex, length) -{ - if (startIndex === undefined) { startIndex = 0; } - if (length === undefined) { length = array.length; } - - var randomIndex = startIndex + Math.floor(Math.random() * length); - - return (array[randomIndex] === undefined) ? null : array[randomIndex]; -}; - -module.exports = GetRandom; - - -/***/ }), -/* 147 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils.Array - */ - -module.exports = { - - Matrix: __webpack_require__(503), - - Add: __webpack_require__(496), - AddAt: __webpack_require__(495), - BringToTop: __webpack_require__(494), - CountAllMatching: __webpack_require__(493), - Each: __webpack_require__(492), - EachInRange: __webpack_require__(491), - FindClosestInSorted: __webpack_require__(209), - GetAll: __webpack_require__(490), - GetFirst: __webpack_require__(489), - GetRandom: __webpack_require__(146), - MoveDown: __webpack_require__(488), - MoveTo: __webpack_require__(487), - MoveUp: __webpack_require__(486), - NumberArray: __webpack_require__(485), - NumberArrayStep: __webpack_require__(484), - QuickSelect: __webpack_require__(180), - Range: __webpack_require__(254), - Remove: __webpack_require__(195), - RemoveAt: __webpack_require__(483), - RemoveBetween: __webpack_require__(482), - RemoveRandomElement: __webpack_require__(481), - Replace: __webpack_require__(480), - RotateLeft: __webpack_require__(290), - RotateRight: __webpack_require__(289), - SafeRange: __webpack_require__(29), - SendToBack: __webpack_require__(479), - SetAll: __webpack_require__(478), - Shuffle: __webpack_require__(95), - SpliceOne: __webpack_require__(56), - StableSort: __webpack_require__(83), - Swap: __webpack_require__(477) - -}; - - -/***/ }), -/* 148 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(527); -var TextureTintPipeline = __webpack_require__(129); - -var LIGHT_COUNT = 10; - -/** - * @classdesc - * ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights. - * This pipeline extends TextureTintPipeline so it implements all it's rendering functions - * and batching system. - * - * @class ForwardDiffuseLightPipeline - * @extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var ForwardDiffuseLightPipeline = new Class({ - - Extends: TextureTintPipeline, - - initialize: - - function ForwardDiffuseLightPipeline (config) - { - config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); - - TextureTintPipeline.call(this, config); - }, - - /** - * This function binds it's base class resources and this lights 2D resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onBind - * @override - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline} [description] - */ - onBind: function () - { - TextureTintPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - this.mvpUpdate(); - - renderer.setInt1(program, 'uNormSampler', 1); - renderer.setFloat2(program, 'uResolution', this.width, this.height); - - return this; - }, - - /** - * This function sets all the needed resources for each camera pass. - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onRender - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline} [description] - */ - onRender: function (scene, camera) - { - this.active = false; - - var lightManager = scene.sys.lights; - - if (!lightManager || lightManager.lights.length <= 0 || !lightManager.active) - { - // Passthru - return this; - } - - var lights = lightManager.cull(camera); - var lightCount = Math.min(lights.length, LIGHT_COUNT); - - if (lightCount === 0) - { - return this; - } - - this.active = true; - - var renderer = this.renderer; - var program = this.program; - var cameraMatrix = camera.matrix; - var point = {x: 0, y: 0}; - var height = renderer.height; - var index; - - for (index = 0; index < LIGHT_COUNT; ++index) - { - // Reset lights - renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); - } - - renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); - renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); - - for (index = 0; index < lightCount; ++index) - { - var light = lights[index]; - var lightName = 'uLights[' + index + '].'; - - cameraMatrix.transformPoint(light.x, light.y, point); - - renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); - renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); - renderer.setFloat1(program, lightName + 'intensity', light.intensity); - renderer.setFloat1(program, lightName + 'radius', light.radius); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawStaticTilemapLayer - * @override - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawStaticTilemapLayer: function (tilemap, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tilemap.tileset.image.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. StaticTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - drawEmitterManager: function (emitterManager, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = emitterManager.texture.dataSource[emitterManager.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. EmitterManager rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - drawBlitter: function (blitter, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = blitter.texture.dataSource[blitter.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Blitter rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchSprite: function (sprite, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = sprite.texture.dataSource[sprite.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Sprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchMesh: function (mesh, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = mesh.texture.dataSource[mesh.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Mesh rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera, parentTransformMatrix); - - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = bitmapText.texture.dataSource[bitmapText.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. BitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var normalTexture = bitmapText.texture.dataSource[bitmapText.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicBitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchText: function (text, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = text.texture.dataSource[text.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchText.call(this, text, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Text rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchText(text, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tilemapLayer.tileset.image.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchTileSprite: function (tileSprite, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tileSprite.texture.dataSource[tileSprite.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. TileSprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera, parentTransformMatrix); - } - } - -}); - -ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; - -module.exports = ForwardDiffuseLightPipeline; - - -/***/ }), -/* 149 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compute a random integer between the `min` and `max` values, inclusive. - * - * @function Phaser.Math.Between - * @since 3.0.0 - * - * @param {integer} min - The minimum value. - * @param {integer} max - The maximum value. - * - * @return {integer} The random integer. - */ -var Between = function (min, max) -{ - return Math.floor(Math.random() * (max - min + 1) + min); -}; - -module.exports = Between; - - -/***/ }), -/* 150 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); - -/** - * Convert the given angle in radians, to the equivalent angle in degrees. - * - * @function Phaser.Math.RadToDeg - * @since 3.0.0 - * - * @param {float} radians - The angle in radians to convert ot degrees. - * - * @return {integer} The given angle converted to degrees. - */ -var RadToDeg = function (radians) -{ - return radians * CONST.RAD_TO_DEG; -}; - -module.exports = RadToDeg; - - -/***/ }), -/* 151 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GameObject = __webpack_require__(2); -var Sprite = __webpack_require__(34); -var Vector2 = __webpack_require__(6); -var Vector4 = __webpack_require__(277); - -/** - * @classdesc - * A Sprite 3D Game Object. - * - * The Sprite 3D object is an encapsulation of a standard Sprite object, with additional methods to allow - * it to be rendered by a 3D Camera. The Sprite can be positioned anywhere within 3D space. - * - * @class Sprite3D - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The x position of this Game Object. - * @param {number} y - The y position of this Game Object. - * @param {number} z - The z position of this Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Sprite3D = new Class({ - - Extends: GameObject, - - initialize: - - function Sprite3D (scene, x, y, z, texture, frame) - { - GameObject.call(this, scene, 'Sprite3D'); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = new Sprite(scene, 0, 0, texture, frame); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#position - * @type {Phaser.Math.Vector4} - * @since 3.0.0 - */ - this.position = new Vector4(x, y, z); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#size - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.size = new Vector2(this.gameObject.width, this.gameObject.height); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#scale - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.scale = new Vector2(1, 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#adjustScaleX - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.adjustScaleX = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#adjustScaleY - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.adjustScaleY = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#_visible - * @type {boolean} - * @default true - * @private - * @since 3.0.0 - */ - this._visible = true; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite3D#project - * @since 3.0.0 - * - * @param {Phaser.Cameras.Sprite3D.Camera} camera - The 3D Camera onto which to project this Sprite. - */ - project: function (camera) - { - var pos = this.position; - - var gameObject = this.gameObject; - - camera.project(pos, gameObject); - - camera.getPointSize(pos, this.size, this.scale); - - if (this.scale.x <= 0 || this.scale.y <= 0) - { - gameObject.setVisible(false); - } - else - { - if (!gameObject.visible) - { - gameObject.setVisible(true); - } - - if (this.adjustScaleX) - { - gameObject.scaleX = this.scale.x; - } - - if (this.adjustScaleY) - { - gameObject.scaleY = this.scale.y; - } - - gameObject.setDepth(gameObject.z * -1); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite3D#setVisible - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.GameObjects.Sprite3D} This Sprite3D Object. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @name Phaser.GameObjects.Sprite3D#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - this._visible = value; - this.gameObject.visible = value; - } - - }, - - /** - * The x position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - } - - }, - - /** - * The y position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - } - - }, - - /** - * The z position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#z - * @type {number} - * @since 3.0.0 - */ - z: { - - get: function () - { - return this.position.z; - }, - - set: function (value) - { - this.position.z = value; - } - - } - -}); - -module.exports = Sprite3D; - - -/***/ }), -/* 152 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Given 3 separate color values this will return an integer representation of it. - * - * @function Phaser.Display.Color.GetColor - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * - * @return {number} The combined color value. - */ -var GetColor = function (red, green, blue) -{ - return red << 16 | green << 8 | blue; -}; - -module.exports = GetColor; - - -/***/ }), -/* 153 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Random = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - - // Basis vectors - var ux = triangle.x2 - triangle.x1; - var uy = triangle.y2 - triangle.y1; - - var vx = triangle.x3 - triangle.x1; - var vy = triangle.y3 - triangle.y1; - - // Random point within the unit square - var r = Math.random(); - var s = Math.random(); - - // Point outside the triangle? Remap it. - if (r + s >= 1) - { - r = 1 - r; - s = 1 - s; - } - - out.x = triangle.x1 + ((ux * r) + (vx * s)); - out.y = triangle.y1 + ((uy * r) + (vy * s)); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 154 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} out - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Random = function (rect, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = rect.x + (Math.random() * rect.width); - out.y = rect.y + (Math.random() * rect.height); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 155 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a random point on a given Line. - * - * @function Phaser.Geom.Line.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - The Line to calculate the random Point on. - * @param {(Phaser.Geom.Point|object)} [out] - An instance of a Point to be modified. - * - * @return {(Phaser.Geom.Point|object)} A random Point on the Line. - */ -var Random = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - var t = Math.random(); - - out.x = line.x1 + t * (line.x2 - line.x1); - out.y = line.y1 + t * (line.y2 - line.y1); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 156 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(71); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ -var GetPoints = function (line, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = Length(line) / stepRate; - } - - var x1 = line.x1; - var y1 = line.y1; - - var x2 = line.x2; - var y2 = line.y2; - - for (var i = 0; i < quantity; i++) - { - var position = i / quantity; - - var x = x1 + (x2 - x1) * position; - var y = y1 + (y2 - y1) * position; - - out.push(new Point(x, y)); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 157 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); +var Point = __webpack_require__(6); /** * Returns a uniformly distributed random point from anywhere within the given Circle. @@ -32970,7 +39411,7 @@ module.exports = Random; /***/ }), -/* 158 */ +/* 192 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -32979,287 +39420,2493 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(51); -var Circle = __webpack_require__(88); -var CircleContains = __webpack_require__(32); +var Point = __webpack_require__(6); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * + * @function Phaser.Geom.Circle.CircumferencePoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (circle, angle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = circle.x + (circle.radius * Math.cos(angle)); + out.y = circle.y + (circle.radius * Math.sin(angle)); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 193 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ALIGN_CONST = { + + /** + * A constant representing a top-left alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_LEFT + * @since 3.0.0 + * @type {integer} + */ + TOP_LEFT: 0, + + /** + * A constant representing a top-center alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_CENTER + * @since 3.0.0 + * @type {integer} + */ + TOP_CENTER: 1, + + /** + * A constant representing a top-right alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_RIGHT + * @since 3.0.0 + * @type {integer} + */ + TOP_RIGHT: 2, + + /** + * A constant representing a left-top alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_TOP + * @since 3.0.0 + * @type {integer} + */ + LEFT_TOP: 3, + + /** + * A constant representing a left-center alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_CENTER + * @since 3.0.0 + * @type {integer} + */ + LEFT_CENTER: 4, + + /** + * A constant representing a left-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + LEFT_BOTTOM: 5, + + /** + * A constant representing a center alignment or position. + * @constant + * @name Phaser.Display.Align.CENTER + * @since 3.0.0 + * @type {integer} + */ + CENTER: 6, + + /** + * A constant representing a right-top alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_TOP + * @since 3.0.0 + * @type {integer} + */ + RIGHT_TOP: 7, + + /** + * A constant representing a right-center alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_CENTER + * @since 3.0.0 + * @type {integer} + */ + RIGHT_CENTER: 8, + + /** + * A constant representing a right-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + RIGHT_BOTTOM: 9, + + /** + * A constant representing a bottom-left alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_LEFT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_LEFT: 10, + + /** + * A constant representing a bottom-center alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_CENTER + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_CENTER: 11, + + /** + * A constant representing a bottom-right alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_RIGHT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_RIGHT: 12 + +}; + +module.exports = ALIGN_CONST; + + +/***/ }), +/* 194 */, +/* 195 */, +/* 196 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var Rectangle = __webpack_require__(14); -var RectangleContains = __webpack_require__(31); +var Earcut = __webpack_require__(64); +var GetFastValue = __webpack_require__(2); +var ModelViewProjection = __webpack_require__(894); +var ShaderSourceFS = __webpack_require__(893); +var ShaderSourceVS = __webpack_require__(892); +var TransformMatrix = __webpack_require__(38); +var Utils = __webpack_require__(10); +var WebGLPipeline = __webpack_require__(197); /** * @classdesc - * A Zone Game Object. + * TextureTintPipeline implements the rendering infrastructure + * for displaying textured objects + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. * - * A Zone is a non-rendering rectangular Game Object that has a position and size. - * It has no texture and never displays, but does live on the display list and - * can be moved, scaled and rotated like any other Game Object. - * - * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods - * specifically for this. It is also useful for object overlap checks, or as a base for your own - * non-displaying Game Objects. - - * The default origin is 0.5, the center of the Zone, the same as with Game Objects. - * - * @class Zone - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @class TextureTintPipeline + * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @memberof Phaser.Renderer.WebGL.Pipelines * @constructor * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - [description] - * @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 {number} [width=1] - The width of the Game Object. - * @param {number} [height=1] - The height of the Game Object. + * @param {object} config - [description] */ -var Zone = new Class({ +var TextureTintPipeline = new Class({ - Extends: GameObject, + Extends: WebGLPipeline, Mixins: [ - Components.Depth, - Components.GetBounds, - Components.Origin, - Components.ScaleMode, - Components.Transform, - Components.ScrollFactor, - Components.Visible + ModelViewProjection ], initialize: - function Zone (scene, x, y, width, height) + function TextureTintPipeline (config) { - if (width === undefined) { width = 1; } - if (height === undefined) { height = width; } + var rendererConfig = config.renderer.config; - GameObject.call(this, scene, 'Zone'); + // Vertex Size = attribute size added together (2 + 2 + 1 + 4) - this.setPosition(x, y); + WebGLPipeline.call(this, { + game: config.game, + renderer: config.renderer, + gl: config.renderer.gl, + topology: GetFastValue(config, 'topology', config.renderer.gl.TRIANGLES), + vertShader: GetFastValue(config, 'vertShader', ShaderSourceVS), + fragShader: GetFastValue(config, 'fragShader', ShaderSourceFS), + vertexCapacity: GetFastValue(config, 'vertexCapacity', 6 * rendererConfig.batchSize), + vertexSize: GetFastValue(config, 'vertexSize', Float32Array.BYTES_PER_ELEMENT * 5 + Uint8Array.BYTES_PER_ELEMENT * 4), + attributes: [ + { + name: 'inPosition', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: 0 + }, + { + name: 'inTexCoord', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: Float32Array.BYTES_PER_ELEMENT * 2 + }, + { + name: 'inTintEffect', + size: 1, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: Float32Array.BYTES_PER_ELEMENT * 4 + }, + { + name: 'inTint', + size: 4, + type: config.renderer.gl.UNSIGNED_BYTE, + normalized: true, + offset: Float32Array.BYTES_PER_ELEMENT * 5 + } + ] + }); /** - * The native (un-scaled) width of this Game Object. + * Float32 view of the array buffer containing the pipeline's vertices. * - * @name Phaser.GameObjects.Zone#width - * @type {number} + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewF32 + * @type {Float32Array} * @since 3.0.0 */ - this.width = width; + this.vertexViewF32 = new Float32Array(this.vertexData); /** - * The native (un-scaled) height of this Game Object. + * Uint32 view of the array buffer containing the pipeline's vertices. * - * @name Phaser.GameObjects.Zone#height - * @type {number} + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewU32 + * @type {Uint32Array} * @since 3.0.0 */ - this.height = height; + this.vertexViewU32 = new Uint32Array(this.vertexData); /** - * The Blend Mode of the Game Object. - * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into - * display lists without causing a batch flush. + * Size of the batch. * - * @name Phaser.GameObjects.Zone#blendMode + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#maxQuads * @type {integer} * @since 3.0.0 */ - this.blendMode = BlendModes.NORMAL; + this.maxQuads = rendererConfig.batchSize; + + /** + * Collection of batch information + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batches + * @type {array} + * @since 3.1.0 + */ + this.batches = []; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + /** + * Used internally to draw stroked triangles. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tempTriangle + * @type {array} + * @private + * @since 3.12.0 + */ + this.tempTriangle = [ + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 } + ]; + + /** + * The tint effect to be applied by the shader in the next geometry draw: + * + * 0 = texture multiplied by color + * 1 = solid color + texture alpha + * 2 = solid color, no texture + * 3 = solid texture, no color + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tintEffect + * @type {number} + * @private + * @since 3.12.0 + */ + this.tintEffect = 2; + + /** + * Cached stroke tint. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#strokeTint + * @type {object} + * @private + * @since 3.12.0 + */ + this.strokeTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; + + /** + * Cached fill tint. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#fillTint + * @type {object} + * @private + * @since 3.12.0 + */ + this.fillTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; + + /** + * Internal texture frame reference. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#currentFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.12.0 + */ + this.currentFrame = { u0: 0, v0: 0, u1: 1, v1: 1 }; + + /** + * Internal path quad cache. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#firstQuad + * @type {array} + * @private + * @since 3.12.0 + */ + this.firstQuad = [ 0, 0, 0, 0, 0 ]; + + /** + * Internal path quad cache. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#prevQuad + * @type {array} + * @private + * @since 3.12.0 + */ + this.prevQuad = [ 0, 0, 0, 0, 0 ]; + + /** + * Used internally for triangulating a polygon. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#polygonCache + * @type {array} + * @private + * @since 3.12.0 + */ + this.polygonCache = []; + + this.mvpInit(); }, /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. + * Called every time the pipeline needs to be used. + * It binds all necessary resources. * - * @name Phaser.GameObjects.Zone#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.width; - }, - - set: function (value) - { - this.scaleX = value / this.width; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Zone#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.height; - }, - - set: function (value) - { - this.scaleY = value / this.height; - } - - }, - - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Zone#setSize + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#onBind * @since 3.0.0 * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. - * - * @return {Phaser.GameObjects.Zone} This Game Object. + * @return {this} This WebGLPipeline instance. */ - setSize: function (width, height, resizeInput) + onBind: function () { - if (resizeInput === undefined) { resizeInput = true; } + WebGLPipeline.prototype.onBind.call(this); - this.width = width; - this.height = height; + this.mvpUpdate(); - if (resizeInput && this.input && this.input.hitArea instanceof Rectangle) + if (this.batches.length === 0) { - this.input.hitArea.width = width; - this.input.hitArea.height = height; + this.pushBatch(); } return this; }, /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. + * Resizes this pipeline and updates the projection. * - * @method Phaser.GameObjects.Zone#setDisplaySize + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#resize * @since 3.0.0 * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. + * @param {number} width - The new width. + * @param {number} height - The new height. + * @param {number} resolution - The resolution. * - * @return {Phaser.GameObjects.Zone} This Game Object. + * @return {this} This WebGLPipeline instance. */ - setDisplaySize: function (width, height) + resize: function (width, height, resolution) { - this.displayWidth = width; - this.displayHeight = height; + WebGLPipeline.prototype.resize.call(this, width, height, resolution); + + this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); return this; }, /** - * Sets this Zone to be a Circular Drop Zone. - * The circle is centered on this Zones `x` and `y` coordinates. + * Assigns a texture to the current batch. If a texture is already set it creates + * a new batch object. * - * @method Phaser.GameObjects.Zone#setCircleDropZone - * @since 3.0.0 + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#setTexture2D + * @since 3.1.0 * - * @param {number} radius - The radius of the Circle that will form the Drop Zone. + * @param {WebGLTexture} texture - WebGLTexture that will be assigned to the current batch. + * @param {integer} textureUnit - Texture unit to which the texture needs to be bound. * - * @return {Phaser.GameObjects.Zone} This Game Object. + * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This pipeline instance. */ - setCircleDropZone: function (radius) + setTexture2D: function (texture, unit) { - return this.setDropZone(new Circle(0, 0, radius), CircleContains); - }, - - /** - * Sets this Zone to be a Rectangle Drop Zone. - * The rectangle is centered on this Zones `x` and `y` coordinates. - * - * @method Phaser.GameObjects.Zone#setRectangleDropZone - * @since 3.0.0 - * - * @param {number} width - The width of the rectangle drop zone. - * @param {number} height - The height of the rectangle drop zone. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setRectangleDropZone: function (width, height) - { - var x = -(width / 2); - var y = -(height / 2); - - return this.setDropZone(new Rectangle(x, y, width, height), RectangleContains); - }, - - /** - * Allows you to define your own Geometry shape to be used as a Drop Zone. - * - * @method Phaser.GameObjects.Zone#setDropZone - * @since 3.0.0 - * - * @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. - * @param {HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setDropZone: function (shape, callback) - { - if (shape === undefined) + if (!texture) { - this.setRectangleDropZone(this.width, this.height); + texture = this.renderer.blankTexture.glTexture; + unit = 0; + } + + var batches = this.batches; + + if (batches.length === 0) + { + this.pushBatch(); + } + + var batch = batches[batches.length - 1]; + + if (unit > 0) + { + if (batch.textures[unit - 1] && + batch.textures[unit - 1] !== texture) + { + this.pushBatch(); + } + + batches[batches.length - 1].textures[unit - 1] = texture; } else - if (!this.input) { - this.setInteractive(shape, callback, true); + if (batch.texture !== null && + batch.texture !== texture) + { + this.pushBatch(); + } + + batches[batches.length - 1].texture = texture; } return this; }, /** - * A Zone does not render. + * Creates a new batch object and pushes it to a batch array. + * The batch object contains information relevant to the current + * vertex batch like the offset in the vertex buffer, vertex count and + * the textures used by that batch. * - * @method Phaser.GameObjects.Zone#renderCanvas - * @private - * @since 3.0.0 + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#pushBatch + * @since 3.1.0 */ - renderCanvas: function () + pushBatch: function () { + var batch = { + first: this.vertexCount, + texture: null, + textures: [] + }; + + this.batches.push(batch); }, /** - * A Zone does not render. + * Uploads the vertex data and emits a draw call for the current batch of vertices. * - * @method Phaser.GameObjects.Zone#renderWebGL - * @private + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#flush * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. */ - renderWebGL: function () + flush: function () { + if (this.flushLocked) + { + return this; + } + + this.flushLocked = true; + + var gl = this.gl; + var vertexCount = this.vertexCount; + var topology = this.topology; + var vertexSize = this.vertexSize; + var renderer = this.renderer; + + var batches = this.batches; + var batchCount = batches.length; + var batchVertexCount = 0; + var batch = null; + var batchNext; + var textureIndex; + var nTexture; + + if (batchCount === 0 || vertexCount === 0) + { + this.flushLocked = false; + + return this; + } + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); + + for (var index = 0; index < batches.length - 1; index++) + { + batch = batches[index]; + batchNext = batches[index + 1]; + + if (batch.textures.length > 0) + { + for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) + { + nTexture = batch.textures[textureIndex]; + + if (nTexture) + { + renderer.setTexture2D(nTexture, 1 + textureIndex); + } + } + + gl.activeTexture(gl.TEXTURE0); + } + + batchVertexCount = batchNext.first - batch.first; + + if (batch.texture === null || batchVertexCount <= 0) + { + continue; + } + + renderer.setTexture2D(batch.texture, 0); + + gl.drawArrays(topology, batch.first, batchVertexCount); + } + + // Left over data + batch = batches[batches.length - 1]; + + if (batch.textures.length > 0) + { + for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) + { + nTexture = batch.textures[textureIndex]; + + if (nTexture) + { + renderer.setTexture2D(nTexture, 1 + textureIndex); + } + } + + gl.activeTexture(gl.TEXTURE0); + } + + batchVertexCount = vertexCount - batch.first; + + if (batch.texture && batchVertexCount > 0) + { + renderer.setTexture2D(batch.texture, 0); + + gl.drawArrays(topology, batch.first, batchVertexCount); + } + + this.vertexCount = 0; + + batches.length = 0; + + this.pushBatch(); + + this.flushLocked = false; + + return this; + }, + + /** + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchSprite + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.Image|Phaser.GameObjects.Sprite)} sprite - The texture based Game Object to add to the batch. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the rendering transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - The transform matrix of the parent container, if set. + */ + batchSprite: function (sprite, camera, parentTransformMatrix) + { + this.renderer.setPipeline(this); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var frame = sprite.frame; + var texture = frame.glTexture; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + var frameX = frame.x; + var frameY = frame.y; + var frameWidth = frame.cutWidth; + var frameHeight = frame.cutHeight; + + var x = -sprite.displayOriginX + frameX; + var y = -sprite.displayOriginY + frameY; + + if (sprite.isCropped) + { + var crop = sprite._crop; + + if (crop.flipX !== sprite.flipX || crop.flipY !== sprite.flipY) + { + frame.updateCropUVs(crop, sprite.flipX, sprite.flipY); + } + + u0 = crop.u0; + v0 = crop.v0; + u1 = crop.u1; + v1 = crop.v1; + + frameWidth = crop.width; + frameHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + x = -sprite.displayOriginX + frameX; + y = -sprite.displayOriginY + frameY; + } + + if (sprite.flipX) + { + x += frameWidth; + frameWidth *= -1; + } + + if (sprite.flipY) + { + y += frameHeight; + frameHeight *= -1; + } + + var xw = x + frameWidth; + var yh = y + frameHeight; + + spriteMatrix.applyITRS(sprite.x, sprite.y, sprite.rotation, sprite.scaleX, sprite.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * sprite.scrollFactorX, -camera.scrollY * sprite.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = sprite.x; + spriteMatrix.f = sprite.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * sprite.scrollFactorX; + spriteMatrix.f -= camera.scrollY * sprite.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + var tintTL = Utils.getTintAppendFloatAlpha(sprite._tintTL, camera.alpha * sprite._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(sprite._tintTR, camera.alpha * sprite._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(sprite._tintBL, camera.alpha * sprite._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(sprite._tintBR, camera.alpha * sprite._alphaBR); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + this.setTexture2D(texture, 0); + + var tintEffect = (sprite._isTinted && sprite.tintFill); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + }, + + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 6 vertices in the following arrangement: + * + * ``` + * 0----3 + * |\ B| + * | \ | + * | \ | + * | A \| + * | \ + * 1----2 + * ``` + * + * Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3 + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchQuad + * @since 3.12.0 + * + * @param {number} x0 - The top-left x position. + * @param {number} y0 - The top-left y position. + * @param {number} x1 - The bottom-left x position. + * @param {number} y1 - The bottom-left y position. + * @param {number} x2 - The bottom-right x position. + * @param {number} y2 - The bottom-right y position. + * @param {number} x3 - The top-right x position. + * @param {number} y3 - The top-right y position. + * @param {number} u0 - UV u0 value. + * @param {number} v0 - UV v0 value. + * @param {number} u1 - UV u1 value. + * @param {number} v1 - UV v1 value. + * @param {number} tintTL - The top-left tint color value. + * @param {number} tintTR - The top-right tint color value. + * @param {number} tintBL - The bottom-left tint color value. + * @param {number} tintBR - The bottom-right tint color value. + * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. + * + * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. + */ + batchQuad: function (x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect) + { + var hasFlushed = false; + + if (this.vertexCount + 6 > this.vertexCapacity) + { + this.flush(); + + hasFlushed = true; + } + + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + + var vertexOffset = (this.vertexCount * this.vertexComponentCount) - 1; + + vertexViewF32[++vertexOffset] = x0; + vertexViewF32[++vertexOffset] = y0; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x1; + vertexViewF32[++vertexOffset] = y1; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBR; + + vertexViewF32[++vertexOffset] = x0; + vertexViewF32[++vertexOffset] = y0; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBR; + + vertexViewF32[++vertexOffset] = x3; + vertexViewF32[++vertexOffset] = y3; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTR; + + this.vertexCount += 6; + + return hasFlushed; + }, + + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 3 vertices in the following arrangement: + * + * ``` + * 0 + * |\ + * | \ + * | \ + * | \ + * | \ + * 1-----2 + * ``` + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTri + * @since 3.12.0 + * + * @param {number} x1 - The bottom-left x position. + * @param {number} y1 - The bottom-left y position. + * @param {number} x2 - The bottom-right x position. + * @param {number} y2 - The bottom-right y position. + * @param {number} x3 - The top-right x position. + * @param {number} y3 - The top-right y position. + * @param {number} u0 - UV u0 value. + * @param {number} v0 - UV v0 value. + * @param {number} u1 - UV u1 value. + * @param {number} v1 - UV v1 value. + * @param {number} tintTL - The top-left tint color value. + * @param {number} tintTR - The top-right tint color value. + * @param {number} tintBL - The bottom-left tint color value. + * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. + * + * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. + */ + batchTri: function (x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect) + { + var hasFlushed = false; + + if (this.vertexCount + 3 > this.vertexCapacity) + { + this.flush(); + + hasFlushed = true; + } + + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + + var vertexOffset = (this.vertexCount * this.vertexComponentCount) - 1; + + vertexViewF32[++vertexOffset] = x1; + vertexViewF32[++vertexOffset] = y1; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTR; + + vertexViewF32[++vertexOffset] = x3; + vertexViewF32[++vertexOffset] = y3; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBL; + + this.vertexCount += 3; + + return hasFlushed; + }, + + /** + * Generic function for batching a textured quad using argument values instead of a Game Object. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject. + * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad. + * @param {integer} textureWidth - Real texture width. + * @param {integer} textureHeight - Real texture height. + * @param {number} srcX - X coordinate of the quad. + * @param {number} srcY - Y coordinate of the quad. + * @param {number} srcWidth - Width of the quad. + * @param {number} srcHeight - Height of the quad. + * @param {number} scaleX - X component of scale. + * @param {number} scaleY - Y component of scale. + * @param {number} rotation - Rotation of the quad. + * @param {boolean} flipX - Indicates if the quad is horizontally flipped. + * @param {boolean} flipY - Indicates if the quad is vertically flipped. + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll. + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll. + * @param {number} displayOriginX - Horizontal origin in pixels. + * @param {number} displayOriginY - Vertical origin in pixels. + * @param {number} frameX - X coordinate of the texture frame. + * @param {number} frameY - Y coordinate of the texture frame. + * @param {number} frameWidth - Width of the texture frame. + * @param {number} frameHeight - Height of the texture frame. + * @param {integer} tintTL - Tint for top left. + * @param {integer} tintTR - Tint for top right. + * @param {integer} tintBL - Tint for bottom left. + * @param {integer} tintBR - Tint for bottom right. + * @param {number} tintEffect - The tint effect. + * @param {number} uOffset - Horizontal offset on texture coordinate. + * @param {number} vOffset - Vertical offset on texture coordinate. + * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container. + * @param {boolean} [skipFlip=false] - Skip the renderTexture check. + */ + batchTexture: function ( + gameObject, + texture, + textureWidth, textureHeight, + srcX, srcY, + srcWidth, srcHeight, + scaleX, scaleY, + rotation, + flipX, flipY, + scrollFactorX, scrollFactorY, + displayOriginX, displayOriginY, + frameX, frameY, frameWidth, frameHeight, + tintTL, tintTR, tintBL, tintBR, tintEffect, + uOffset, vOffset, + camera, + parentTransformMatrix, + skipFlip) + { + this.renderer.setPipeline(this, gameObject); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var u0 = (frameX / textureWidth) + uOffset; + var v0 = (frameY / textureHeight) + vOffset; + var u1 = (frameX + frameWidth) / textureWidth + uOffset; + var v1 = (frameY + frameHeight) / textureHeight + vOffset; + + var width = srcWidth; + var height = srcHeight; + + var x = -displayOriginX; + var y = -displayOriginY; + + if (gameObject.isCropped) + { + var crop = gameObject._crop; + + width = crop.width; + height = crop.height; + + srcWidth = crop.width; + srcHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + var ox = frameX; + var oy = frameY; + + if (flipX) + { + ox = (frameWidth - crop.x - crop.width); + } + + if (flipY && !texture.isRenderTexture) + { + oy = (frameHeight - crop.y - crop.height); + } + + u0 = (ox / textureWidth) + uOffset; + v0 = (oy / textureHeight) + vOffset; + u1 = (ox + crop.width) / textureWidth + uOffset; + v1 = (oy + crop.height) / textureHeight + vOffset; + + x = -displayOriginX + frameX; + y = -displayOriginY + frameY; + } + + // Invert the flipY if this is a RenderTexture + flipY = flipY ^ (!skipFlip && texture.isRenderTexture ? 1 : 0); + + if (flipX) + { + width *= -1; + x += srcWidth; + } + + if (flipY) + { + height *= -1; + y += srcHeight; + } + + var xw = x + width; + var yh = y + height; + + spriteMatrix.applyITRS(srcX, srcY, rotation, scaleX, scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * scrollFactorX, -camera.scrollY * scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = srcX; + spriteMatrix.f = srcY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * scrollFactorX; + spriteMatrix.f -= camera.scrollY * scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + this.setTexture2D(texture, 0); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + }, + + /** + * Adds a Texture Frame into the batch for rendering. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTextureFrame + * @since 3.12.0 + * + * @param {Phaser.Textures.Frame} frame - The Texture Frame to be rendered. + * @param {number} x - The horizontal position to render the texture at. + * @param {number} y - The vertical position to render the texture at. + * @param {number} tint - The tint color. + * @param {number} alpha - The alpha value. + * @param {Phaser.GameObjects.Components.TransformMatrix} transformMatrix - The Transform Matrix to use for the texture. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - A parent Transform Matrix. + */ + batchTextureFrame: function ( + frame, + x, y, + tint, alpha, + transformMatrix, + parentTransformMatrix + ) + { + this.renderer.setPipeline(this); + + var spriteMatrix = this._tempMatrix1.copyFrom(transformMatrix); + var calcMatrix = this._tempMatrix2; + + var xw = x + frame.width; + var yh = y + frame.height; + + if (parentTransformMatrix) + { + spriteMatrix.multiply(parentTransformMatrix, calcMatrix); + } + else + { + calcMatrix = spriteMatrix; + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + this.setTexture2D(frame.glTexture, 0); + + tint = Utils.getTintAppendFloatAlpha(tint, alpha); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, 0); + }, + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle has no transform values and isn't transformed into the local space. + * Used for directly batching untransformed rectangles, such as Camera background colors. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawFillRect + * @since 3.12.0 + * + * @param {number} x - Horizontal top left coordinate of the rectangle. + * @param {number} y - Vertical top left coordinate of the rectangle. + * @param {number} width - Width of the rectangle. + * @param {number} height - Height of the rectangle. + * @param {number} color - Color of the rectangle to draw. + * @param {number} alpha - Alpha value of the rectangle to draw. + */ + drawFillRect: function (x, y, width, height, color, alpha) + { + var xw = x + width; + var yh = y + height; + + var tint = Utils.getTintAppendFloatAlphaAndSwap(color, alpha); + + this.batchQuad(x, y, x, yh, xw, yh, xw, y, 0, 0, 1, 1, tint, tint, tint, tint, 2); + }, + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle factors in the given transform matrices before adding to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillRect + * @since 3.12.0 + * + * @param {number} x - Horizontal top left coordinate of the rectangle. + * @param {number} y - Vertical top left coordinate of the rectangle. + * @param {number} width - Width of the rectangle. + * @param {number} height - Height of the rectangle. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillRect: function (x, y, width, height, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var xw = x + width; + var yh = y + height; + + var x0 = calcMatrix.getX(x, y); + var y0 = calcMatrix.getY(x, y); + + var x1 = calcMatrix.getX(x, yh); + var y1 = calcMatrix.getY(x, yh); + + var x2 = calcMatrix.getX(xw, yh); + var y2 = calcMatrix.getY(xw, yh); + + var x3 = calcMatrix.getX(xw, y); + var y3 = calcMatrix.getY(xw, y); + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.fillTint.BR, this.tintEffect); + }, + + /** + * Pushes a filled triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillTriangle + * @since 3.12.0 + * + * @param {number} x0 - Point 0 x coordinate. + * @param {number} y0 - Point 0 y coordinate. + * @param {number} x1 - Point 1 x coordinate. + * @param {number} y1 - Point 1 y coordinate. + * @param {number} x2 - Point 2 x coordinate. + * @param {number} y2 - Point 2 y coordinate. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillTriangle: function (x0, y0, x1, y1, x2, y2, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.tintEffect); + }, + + /** + * Pushes a stroked triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * The triangle is created from 3 lines and drawn using the `batchStrokePath` method. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokeTriangle + * @since 3.12.0 + * + * @param {number} x0 - Point 0 x coordinate. + * @param {number} y0 - Point 0 y coordinate. + * @param {number} x1 - Point 1 x coordinate. + * @param {number} y1 - Point 1 y coordinate. + * @param {number} x2 - Point 2 x coordinate. + * @param {number} y2 - Point 2 y coordinate. + * @param {number} lineWidth - The width of the line in pixels. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchStrokeTriangle: function (x0, y0, x1, y1, x2, y2, lineWidth, currentMatrix, parentMatrix) + { + var tempTriangle = this.tempTriangle; + + tempTriangle[0].x = x0; + tempTriangle[0].y = y0; + tempTriangle[0].width = lineWidth; + + tempTriangle[1].x = x1; + tempTriangle[1].y = y1; + tempTriangle[1].width = lineWidth; + + tempTriangle[2].x = x2; + tempTriangle[2].y = y2; + tempTriangle[2].width = lineWidth; + + tempTriangle[3].x = x0; + tempTriangle[3].y = y0; + tempTriangle[3].width = lineWidth; + + this.batchStrokePath(tempTriangle, lineWidth, false, currentMatrix, parentMatrix); + }, + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and then passing it through Earcut, which + * creates a list of polygons. Each polygon is then added to the batch. + * + * The path is always automatically closed because it's filled. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillPath + * @since 3.12.0 + * + * @param {array} path - Collection of points that represent the path. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillPath: function (path, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var length = path.length; + var polygonCache = this.polygonCache; + var polygonIndexArray; + var point; + + var tintTL = this.fillTint.TL; + var tintTR = this.fillTint.TR; + var tintBL = this.fillTint.BL; + var tintEffect = this.tintEffect; + + for (var pathIndex = 0; pathIndex < length; ++pathIndex) + { + point = path[pathIndex]; + polygonCache.push(point.x, point.y); + } + + polygonIndexArray = Earcut(polygonCache); + length = polygonIndexArray.length; + + var frame = this.currentFrame; + + for (var index = 0; index < length; index += 3) + { + var p0 = polygonIndexArray[index + 0] * 2; + var p1 = polygonIndexArray[index + 1] * 2; + var p2 = polygonIndexArray[index + 2] * 2; + + var x0 = polygonCache[p0 + 0]; + var y0 = polygonCache[p0 + 1]; + var x1 = polygonCache[p1 + 0]; + var y1 = polygonCache[p1 + 1]; + var x2 = polygonCache[p2 + 0]; + var y2 = polygonCache[p2 + 1]; + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect); + } + + polygonCache.length = 0; + }, + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and calling `batchLine` for each section + * of the path. + * + * The path is optionally closed at the end. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokePath + * @since 3.12.0 + * + * @param {array} path - Collection of points that represent the path. + * @param {number} lineWidth - The width of the line segments in pixels. + * @param {boolean} pathOpen - Indicates if the path should be closed or left open. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchStrokePath: function (path, lineWidth, pathOpen, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + // Reset the closePath booleans + this.prevQuad[4] = 0; + this.firstQuad[4] = 0; + + var pathLength = path.length - 1; + + for (var pathIndex = 0; pathIndex < pathLength; pathIndex++) + { + var point0 = path[pathIndex]; + var point1 = path[pathIndex + 1]; + + this.batchLine( + point0.x, + point0.y, + point1.x, + point1.y, + point0.width / 2, + point1.width / 2, + lineWidth, + pathIndex, + !pathOpen && (pathIndex === pathLength - 1), + currentMatrix, + parentMatrix + ); + } + }, + + /** + * Creates a quad and adds it to the vertex batch based on the given line values. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchLine + * @since 3.12.0 + * + * @param {number} ax - X coordinate to the start of the line + * @param {number} ay - Y coordinate to the start of the line + * @param {number} bx - X coordinate to the end of the line + * @param {number} by - Y coordinate to the end of the line + * @param {number} aLineWidth - Width of the start of the line + * @param {number} bLineWidth - Width of the end of the line + * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers + */ + batchLine: function (ax, ay, bx, by, aLineWidth, bLineWidth, lineWidth, index, closePath, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var dx = bx - ax; + var dy = by - ay; + + var len = Math.sqrt(dx * dx + dy * dy); + var al0 = aLineWidth * (by - ay) / len; + var al1 = aLineWidth * (ax - bx) / len; + var bl0 = bLineWidth * (by - ay) / len; + var bl1 = bLineWidth * (ax - bx) / len; + + var lx0 = bx - bl0; + var ly0 = by - bl1; + var lx1 = ax - al0; + var ly1 = ay - al1; + var lx2 = bx + bl0; + var ly2 = by + bl1; + var lx3 = ax + al0; + var ly3 = ay + al1; + + // tx0 = bottom right + var brX = calcMatrix.getX(lx0, ly0); + var brY = calcMatrix.getY(lx0, ly0); + + // tx1 = bottom left + var blX = calcMatrix.getX(lx1, ly1); + var blY = calcMatrix.getY(lx1, ly1); + + // tx2 = top right + var trX = calcMatrix.getX(lx2, ly2); + var trY = calcMatrix.getY(lx2, ly2); + + // tx3 = top left + var tlX = calcMatrix.getX(lx3, ly3); + var tlY = calcMatrix.getY(lx3, ly3); + + var tint = this.strokeTint; + var tintEffect = this.tintEffect; + + var tintTL = tint.TL; + var tintTR = tint.TR; + var tintBL = tint.BL; + var tintBR = tint.BR; + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + // TL, BL, BR, TR + this.batchQuad(tlX, tlY, blX, blY, brX, brY, trX, trY, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + + if (lineWidth <= 2) + { + // No point doing a linejoin if the line isn't thick enough + return; + } + + var prev = this.prevQuad; + var first = this.firstQuad; + + if (index > 0 && prev[4]) + { + this.batchQuad(tlX, tlY, blX, blY, prev[0], prev[1], prev[2], prev[3], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + else + { + first[0] = tlX; + first[1] = tlY; + first[2] = blX; + first[3] = blY; + first[4] = 1; + } + + if (closePath && first[4]) + { + // Add a join for the final path segment + this.batchQuad(brX, brY, trX, trY, first[0], first[1], first[2], first[3], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + else + { + // Store it + + prev[0] = brX; + prev[1] = brY; + prev[2] = trX; + prev[3] = trY; + prev[4] = 1; + } } }); -module.exports = Zone; +module.exports = TextureTintPipeline; /***/ }), -/* 159 */ +/* 197 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(10); + +/** + * @classdesc + * WebGLPipeline is a class that describes the way elements will be rendererd + * in WebGL, specially focused on batching vertices (batching is not provided). + * Pipelines are mostly used for describing 2D rendering passes but it's + * flexible enough to be used for any type of rendering including 3D. + * Internally WebGLPipeline will handle things like compiling shaders, + * creating vertex buffers, assigning primitive topology and binding + * vertex attributes. + * + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - gl: Current WebGL context. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + * - vertices: An optional buffer of vertices + * - attributes: An array describing the vertex attributes + * + * The vertex attributes properties are: + * - name : String - Name of the attribute in the vertex shader + * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 + * - type : GLenum - WebGL type (gl.BYTE, gl.SHORT, gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.FLOAT) + * - normalized : boolean - Is the attribute normalized + * - offset : integer - The offset in bytes to the current attribute in the vertex. Equivalent to offsetof(vertex, attrib) in C + * Here you can find more information of how to describe an attribute: + * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer + * + * @class WebGLPipeline + * @memberof Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var WebGLPipeline = new Class({ + + initialize: + + function WebGLPipeline (config) + { + /** + * Name of the Pipeline. Used for identifying + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'WebGLPipeline'; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = config.game; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#view + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.view = config.game.canvas; + + /** + * Used to store the current game resolution + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#resolution + * @type {number} + * @since 3.0.0 + */ + this.resolution = config.game.config.resolution; + + /** + * Width of the current viewport + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#width + * @type {number} + * @since 3.0.0 + */ + this.width = config.game.config.width * this.resolution; + + /** + * Height of the current viewport + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#height + * @type {number} + * @since 3.0.0 + */ + this.height = config.game.config.height * this.resolution; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#gl + * @type {WebGLRenderingContext} + * @since 3.0.0 + */ + this.gl = config.gl; + + /** + * How many vertices have been fed to the current pipeline. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.vertexCount = 0; + + /** + * The limit of vertices that the pipeline can hold + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity + * @type {integer} + * @since 3.0.0 + */ + this.vertexCapacity = config.vertexCapacity; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#renderer + * @type {Phaser.Renderer.WebGL.WebGLRenderer} + * @since 3.0.0 + */ + this.renderer = config.renderer; + + /** + * Raw byte buffer of vertices. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexData + * @type {ArrayBuffer} + * @since 3.0.0 + */ + this.vertexData = (config.vertices ? config.vertices : new ArrayBuffer(config.vertexCapacity * config.vertexSize)); + + /** + * The handle to a WebGL vertex buffer object. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer + * @type {WebGLBuffer} + * @since 3.0.0 + */ + this.vertexBuffer = this.renderer.createVertexBuffer((config.vertices ? config.vertices : this.vertexData.byteLength), this.gl.STREAM_DRAW); + + /** + * The handle to a WebGL program + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#program + * @type {WebGLProgram} + * @since 3.0.0 + */ + this.program = this.renderer.createProgram(config.vertShader, config.fragShader); + + /** + * Array of objects that describe the vertex attributes + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#attributes + * @type {object} + * @since 3.0.0 + */ + this.attributes = config.attributes; + + /** + * The size in bytes of the vertex + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexSize + * @type {integer} + * @since 3.0.0 + */ + this.vertexSize = config.vertexSize; + + /** + * The primitive topology which the pipeline will use to submit draw calls + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#topology + * @type {integer} + * @since 3.0.0 + */ + this.topology = config.topology; + + /** + * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources + * to the GPU. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#bytes + * @type {Uint8Array} + * @since 3.0.0 + */ + this.bytes = new Uint8Array(this.vertexData); + + /** + * This will store the amount of components of 32 bit length + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexComponentCount + * @type {integer} + * @since 3.0.0 + */ + this.vertexComponentCount = Utils.getComponentCount(config.attributes, this.gl); + + /** + * Indicates if the current pipeline is flushing the contents to the GPU. + * When the variable is set the flush function will be locked. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#flushLocked + * @type {boolean} + * @since 3.1.0 + */ + this.flushLocked = false; + + /** + * Indicates if the current pipeline is active or not for this frame only. + * Reset in the onRender method. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#active + * @type {boolean} + * @since 3.10.0 + */ + this.active = false; + }, + + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#boot + * @since 3.11.0 + */ + boot: function () + { + }, + + /** + * Adds a description of vertex attribute to the pipeline + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#addAttribute + * @since 3.2.0 + * + * @param {string} name - Name of the vertex attribute + * @param {integer} size - Vertex component size + * @param {integer} type - Type of the attribute + * @param {boolean} normalized - Is the value normalized to a range + * @param {integer} offset - Byte offset to the beginning of the first element in the vertex + * + * @return {this} This WebGLPipeline instance. + */ + addAttribute: function (name, size, type, normalized, offset) + { + this.attributes.push({ + name: name, + size: size, + type: this.renderer.glFormats[type], + normalized: normalized, + offset: offset + }); + + return this; + }, + + /** + * Check if the current batch of vertices is full. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush + * @since 3.0.0 + * + * @return {boolean} [description] + */ + shouldFlush: function () + { + return (this.vertexCount >= this.vertexCapacity); + }, + + /** + * Resizes the properties used to describe the viewport + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} resolution - [description] + * + * @return {this} This WebGLPipeline instance. + */ + resize: function (width, height, resolution) + { + this.width = width * resolution; + this.height = height * resolution; + + return this; + }, + + /** + * Binds the pipeline resources, including programs, vertex buffers and binds attributes + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#bind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + bind: function () + { + var gl = this.gl; + var vertexBuffer = this.vertexBuffer; + var attributes = this.attributes; + var program = this.program; + var renderer = this.renderer; + var vertexSize = this.vertexSize; + + renderer.setProgram(program); + renderer.setVertexBuffer(vertexBuffer); + + for (var index = 0; index < attributes.length; ++index) + { + var element = attributes[index]; + var location = gl.getAttribLocation(program, element.name); + + if (location >= 0) + { + gl.enableVertexAttribArray(location); + gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexSize, element.offset); + } + else + { + gl.disableVertexAttribArray(location); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onBind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function () + { + // This is for updating uniform data it's called on each bind attempt. + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onPreRender + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onPreRender: function () + { + // called once every frame + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onRender + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {this} This WebGLPipeline instance. + */ + onRender: function () + { + // called for each camera + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onPostRender + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onPostRender: function () + { + // called once every frame + return this; + }, + + /** + * Uploads the vertex data and emits a draw call + * for the current batch of vertices. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#flush + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + flush: function () + { + if (this.flushLocked) { return this; } + + this.flushLocked = true; + + var gl = this.gl; + var vertexCount = this.vertexCount; + var topology = this.topology; + var vertexSize = this.vertexSize; + + if (vertexCount === 0) + { + this.flushLocked = false; + return; + } + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); + gl.drawArrays(topology, 0, vertexCount); + + this.vertexCount = 0; + this.flushLocked = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#destroy + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + destroy: function () + { + var gl = this.gl; + + gl.deleteProgram(this.program); + gl.deleteBuffer(this.vertexBuffer); + + delete this.program; + delete this.vertexBuffer; + delete this.gl; + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setFloat1: function (name, x) + { + this.renderer.setFloat1(this.program, name, x); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setFloat2: function (name, x, y) + { + this.renderer.setFloat2(this.program, name, x, y); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setFloat3: function (name, x, y, z) + { + this.renderer.setFloat3(this.program, name, x, y, z); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - X component of the uniform + * @param {number} y - Y component of the uniform + * @param {number} z - Z component of the uniform + * @param {number} w - W component of the uniform + * + * @return {this} This WebGLPipeline instance. + */ + setFloat4: function (name, x, y, z, w) + { + this.renderer.setFloat4(this.program, name, x, y, z, w); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat1v: function (name, arr) + { + this.renderer.setFloat1v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat2v: function (name, arr) + { + this.renderer.setFloat2v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat3v: function (name, arr) + { + this.renderer.setFloat3v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat4v: function (name, arr) + { + this.renderer.setFloat4v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt1 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setInt1: function (name, x) + { + this.renderer.setInt1(this.program, name, x); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt2 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setInt2: function (name, x, y) + { + this.renderer.setInt2(this.program, name, x, y); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt3 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setInt3: function (name, x, y, z) + { + this.renderer.setInt3(this.program, name, x, y, z); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt4 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - X component of the uniform + * @param {integer} y - Y component of the uniform + * @param {integer} z - Z component of the uniform + * @param {integer} w - W component of the uniform + * + * @return {this} This WebGLPipeline instance. + */ + setInt4: function (name, x, y, z, w) + { + this.renderer.setInt4(this.program, name, x, y, z, w); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setMatrix2: function (name, transpose, matrix) + { + this.renderer.setMatrix2(this.program, name, transpose, matrix); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setMatrix3: function (name, transpose, matrix) + { + this.renderer.setMatrix3(this.program, name, transpose, matrix); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - Should the matrix be transpose + * @param {Float32Array} matrix - Matrix data + * + * @return {this} This WebGLPipeline instance. + */ + setMatrix4: function (name, transpose, matrix) + { + this.renderer.setMatrix4(this.program, name, transpose, matrix); + + return this; + } + +}); + +module.exports = WebGLPipeline; + + +/***/ }), +/* 198 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Wrap = __webpack_require__(53); + +/** + * Wrap an angle in degrees. + * + * Wraps the angle to a value in the range of -180 to 180. + * + * @function Phaser.Math.Angle.WrapDegrees + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in degrees. + * + * @return {number} The wrapped angle, in degrees. + */ +var WrapDegrees = function (angle) +{ + return Wrap(angle, -180, 180); +}; + +module.exports = WrapDegrees; + + +/***/ }), +/* 199 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathWrap = __webpack_require__(53); + +/** + * Wrap an angle. + * + * Wraps the angle to a value in the range of -PI to PI. + * + * @function Phaser.Math.Angle.Wrap + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in radians. + * + * @return {number} The wrapped angle, in radians. + */ +var Wrap = function (angle) +{ + return MathWrap(angle, -Math.PI, Math.PI); +}; + +module.exports = Wrap; + + +/***/ }), +/* 200 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1, eval)("this"); +} catch (e) { + // This works if the window reference is available + if (typeof window === "object") g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 201 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -33269,16 +41916,16 @@ module.exports = Zone; */ var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var TweenBuilder = __webpack_require__(72); -var TWEEN_CONST = __webpack_require__(61); +var EventEmitter = __webpack_require__(11); +var TweenBuilder = __webpack_require__(97); +var TWEEN_CONST = __webpack_require__(83); /** * @classdesc * [description] * * @class Timeline - * @memberOf Phaser.Tweens + * @memberof Phaser.Tweens * @extends Phaser.Events.EventEmitter * @constructor * @since 3.0.0 @@ -33507,12 +42154,13 @@ var Timeline = new Class({ }, /** - * [description] + * Sets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. * * @method Phaser.Tweens.Timeline#setTimeScale * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The time scale value to set. * * @return {Phaser.Tweens.Timeline} This Timeline object. */ @@ -33524,12 +42172,12 @@ var Timeline = new Class({ }, /** - * [description] + * Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. * * @method Phaser.Tweens.Timeline#getTimeScale * @since 3.0.0 * - * @return {number} [description] + * @return {number} The value of the time scale applied to this Tween. */ getTimeScale: function () { @@ -33537,12 +42185,12 @@ var Timeline = new Class({ }, /** - * [description] + * Check whether or not the Timeline is playing. * * @method Phaser.Tweens.Timeline#isPlaying * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Timeline is active, otherwise `false`. */ isPlaying: function () { @@ -33787,7 +42435,7 @@ var Timeline = new Class({ }, /** - * [description] + * Sets a callback for the Tween Manager. * * @method Phaser.Tweens.Timeline#setCallback * @since 3.0.0 @@ -33930,7 +42578,7 @@ var Timeline = new Class({ * @since 3.0.0 * * @param {number} timestamp - [description] - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. * * @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager. */ @@ -34107,7 +42755,7 @@ var Timeline = new Class({ }, /** - * [description] + * Stops all the Tweens in the Timeline immediately, whatever stage of progress they are at and flags them for removal by the TweenManager. * * @method Phaser.Tweens.Timeline#destroy * @since 3.0.0 @@ -34128,7 +42776,7 @@ module.exports = Timeline; /***/ }), -/* 160 */ +/* 202 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -34137,17 +42785,17 @@ module.exports = Timeline; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(33); -var Defaults = __webpack_require__(100); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(62); -var GetEaseFunction = __webpack_require__(63); -var GetNewValue = __webpack_require__(73); -var GetTargets = __webpack_require__(102); -var GetTweens = __webpack_require__(162); +var Clone = __webpack_require__(63); +var Defaults = __webpack_require__(129); +var GetAdvancedValue = __webpack_require__(12); +var GetBoolean = __webpack_require__(84); +var GetEaseFunction = __webpack_require__(86); +var GetNewValue = __webpack_require__(98); +var GetTargets = __webpack_require__(131); +var GetTweens = __webpack_require__(204); var GetValue = __webpack_require__(4); -var Timeline = __webpack_require__(159); -var TweenBuilder = __webpack_require__(72); +var Timeline = __webpack_require__(201); +var TweenBuilder = __webpack_require__(97); /** * [description] @@ -34280,7 +42928,7 @@ module.exports = TimelineBuilder; /***/ }), -/* 161 */ +/* 203 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -34289,15 +42937,15 @@ module.exports = TimelineBuilder; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Defaults = __webpack_require__(100); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(62); -var GetEaseFunction = __webpack_require__(63); -var GetNewValue = __webpack_require__(73); +var Defaults = __webpack_require__(129); +var GetAdvancedValue = __webpack_require__(12); +var GetBoolean = __webpack_require__(84); +var GetEaseFunction = __webpack_require__(86); +var GetNewValue = __webpack_require__(98); var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(101); -var Tween = __webpack_require__(99); -var TweenData = __webpack_require__(98); +var GetValueOp = __webpack_require__(130); +var Tween = __webpack_require__(128); +var TweenData = __webpack_require__(127); /** * [description] @@ -34408,7 +43056,7 @@ module.exports = NumberTweenBuilder; /***/ }), -/* 162 */ +/* 204 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -34454,7 +43102,7 @@ module.exports = GetTweens; /***/ }), -/* 163 */ +/* 205 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -34463,7 +43111,7 @@ module.exports = GetTweens; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RESERVED = __webpack_require__(304); +var RESERVED = __webpack_require__(437); /** * [description] @@ -34471,9 +43119,9 @@ var RESERVED = __webpack_require__(304); * @function Phaser.Tweens.Builders.GetProps * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object of the tween to get the target(s) from. * - * @return {array} [description] + * @return {array} An array of all the targets the tween is operating on. */ var GetProps = function (config) { @@ -34512,7 +43160,7 @@ module.exports = GetProps; /***/ }), -/* 164 */ +/* 206 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -34522,7 +43170,7 @@ module.exports = GetProps; */ var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * @typedef {object} TimerEventConfig @@ -34543,7 +43191,7 @@ var GetFastValue = __webpack_require__(1); * [description] * * @class TimerEvent - * @memberOf Phaser.Time + * @memberof Phaser.Time * @constructor * @since 3.0.0 * @@ -34561,7 +43209,7 @@ var TimerEvent = new Class({ * @name Phaser.Time.TimerEvent#delay * @type {number} * @default 0 - * @readOnly + * @readonly * @since 3.0.0 */ this.delay = 0; @@ -34572,7 +43220,7 @@ var TimerEvent = new Class({ * @name Phaser.Time.TimerEvent#repeat * @type {number} * @default 0 - * @readOnly + * @readonly * @since 3.0.0 */ this.repeat = 0; @@ -34593,7 +43241,7 @@ var TimerEvent = new Class({ * @name Phaser.Time.TimerEvent#loop * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.loop = false; @@ -34829,7 +43477,6067 @@ module.exports = TimerEvent; /***/ }), -/* 165 */ +/* 207 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var CONST = __webpack_require__(26); +var GameObject = __webpack_require__(19); +var StaticTilemapLayerRender = __webpack_require__(446); +var TilemapComponents = __webpack_require__(103); +var TransformMatrix = __webpack_require__(38); +var Utils = __webpack_require__(10); + +/** + * @classdesc + * A Static Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. + * + * A Static Tilemap Layer is optimized for rendering speed over flexibility. You cannot apply per-tile + * effects like tint or alpha, or change the tiles or tilesets the layer uses. + * + * Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features. + * + * @class StaticTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + */ +var StaticTilemapLayer = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + StaticTilemapLayerRender + ], + + initialize: + + function StaticTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) + { + GameObject.call(this, scene, 'StaticTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + // Link the LayerData with this static tilemap layer + this.layer.tilemapLayer = this; + + /** + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tileset = []; + + /** + * Used internally by the Canvas renderer. + * This holds the tiles that are visible within the camera in the last frame. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + /** + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#skipCull + * @type {boolean} + * @since 3.12.0 + */ + this.skipCull = false; + + /** + * Canvas only. + * + * The total number of tiles drawn by the renderer in the last frame. + * + * This only works when rending with Canvas. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilesDrawn + * @type {integer} + * @readonly + * @since 3.12.0 + */ + this.tilesDrawn = 0; + + /** + * Canvas only. + * + * The total number of tiles in this layer. Updated every frame. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilesTotal + * @type {integer} + * @readonly + * @since 3.12.0 + */ + this.tilesTotal = this.layer.width * this.layer.height; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullPaddingX + * @type {integer} + * @default 1 + * @since 3.12.0 + */ + this.cullPaddingX = 1; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullPaddingY + * @type {integer} + * @default 1 + * @since 3.12.0 + */ + this.cullPaddingY = 1; + + /** + * Canvas only. + * + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1) The Phaser.Tilemaps.LayerData object for this Layer + * 2) The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3) A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullCallback + * @type {function} + * @since 3.12.0 + */ + this.cullCallback = TilemapComponents.CullTiles; + + /** + * A reference to the renderer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @private + * @since 3.0.0 + */ + this.renderer = scene.sys.game.renderer; + + /** + * An array of vertex buffer objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer + * @type {WebGLBuffer[]} + * @private + * @since 3.0.0 + */ + this.vertexBuffer = []; + + /** + * An array of ArrayBuffer objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData + * @type {ArrayBuffer[]} + * @private + * @since 3.0.0 + */ + this.bufferData = []; + + /** + * An array of Float32 Array objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 + * @type {Float32Array[]} + * @private + * @since 3.0.0 + */ + this.vertexViewF32 = []; + + /** + * An array of Uint32 Array objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 + * @type {Uint32Array[]} + * @private + * @since 3.0.0 + */ + this.vertexViewU32 = []; + + /** + * An array of booleans, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single boolean. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#dirty + * @type {boolean[]} + * @private + * @since 3.0.0 + */ + this.dirty = []; + + /** + * An array of integers, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single integer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount + * @type {integer[]} + * @private + * @since 3.0.0 + */ + this.vertexCount = []; + + /** + * The rendering (draw) order of the tiles in this layer. + * + * The default is 0 which is 'right-down', meaning it will draw the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#_renderOrder + * @type {integer} + * @default 0 + * @private + * @since 3.12.0 + */ + this._renderOrder = 0; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#_tempMatrix + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.14.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#gidMap + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.14.0 + */ + this.gidMap = []; + + this.setTilesets(tileset); + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.updateVBOData(); + + this.initPipeline('TextureTintPipeline'); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.updateVBOData(); + }, this); + } + }, + + /** + * Populates the internal `tileset` array with the Tileset references this Layer requires for rendering. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTilesets + * @private + * @since 3.14.0 + * + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + */ + setTilesets: function (tilesets) + { + var gidMap = []; + var setList = []; + var map = this.tilemap; + + if (!Array.isArray(tilesets)) + { + tilesets = [ tilesets ]; + } + + for (var i = 0; i < tilesets.length; i++) + { + var tileset = tilesets[i]; + + if (typeof tileset === 'string') + { + tileset = map.getTileset(tileset); + } + + if (tileset) + { + setList.push(tileset); + + var s = tileset.firstgid; + + for (var t = 0; t < tileset.total; t++) + { + gidMap[s + t] = tileset; + } + } + } + + this.gidMap = gidMap; + this.tileset = setList; + }, + + /** + * Prepares the VBO data arrays for population by the `upload` method. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#updateVBOData + * @private + * @since 3.14.0 + * + * @return {this} This Tilemap Layer object. + */ + updateVBOData: function () + { + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + this.vertexCount[i] = 0; + this.vertexBuffer[i] = null; + this.bufferData[i] = null; + this.vertexViewF32[i] = null; + this.vertexViewU32[i] = null; + } + + return this; + }, + + /** + * Upload the tile data to a VBO. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#upload + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. + * @param {integer} tilesetIndex - The tileset index. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + upload: function (camera, tilesetIndex) + { + var renderer = this.renderer; + var gl = renderer.gl; + + var pipeline = renderer.pipelines.TextureTintPipeline; + + if (this.dirty[tilesetIndex]) + { + var tileset = this.tileset[tilesetIndex]; + var mapWidth = this.layer.width; + var mapHeight = this.layer.height; + var width = tileset.image.source[0].width; + var height = tileset.image.source[0].height; + var mapData = this.layer.data; + var tile; + var row; + var col; + var renderOrder = this._renderOrder; + var minTileIndex = tileset.firstgid; + var maxTileIndex = tileset.firstgid + tileset.total; + + var vertexBuffer = this.vertexBuffer[tilesetIndex]; + var bufferData = this.bufferData[tilesetIndex]; + var vOffset = -1; + var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; + + this.vertexCount[tilesetIndex] = 0; + + if (bufferData === null) + { + bufferData = new ArrayBuffer(bufferSize); + + this.bufferData[tilesetIndex] = bufferData; + + this.vertexViewF32[tilesetIndex] = new Float32Array(bufferData); + this.vertexViewU32[tilesetIndex] = new Uint32Array(bufferData); + } + + if (renderOrder === 0) + { + // right-down + + for (row = 0; row < mapHeight; row++) + { + for (col = 0; col < mapWidth; col++) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 1) + { + // left-down + + for (row = 0; row < mapHeight; row++) + { + for (col = mapWidth - 1; col >= 0; col--) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 2) + { + // right-up + + for (row = mapHeight - 1; row >= 0; row--) + { + for (col = 0; col < mapWidth; col++) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 3) + { + // left-up + + for (row = mapHeight - 1; row >= 0; row--) + { + for (col = mapWidth - 1; col >= 0; col--) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + + this.dirty[tilesetIndex] = false; + + if (vertexBuffer === null) + { + vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); + + this.vertexBuffer[tilesetIndex] = vertexBuffer; + } + else + { + renderer.setVertexBuffer(vertexBuffer); + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); + } + } + + return this; + }, + + /** + * Add a single tile into the batch. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#batchTile + * @private + * @since 3.12.0 + * + * @param {integer} vOffset - The vertex offset. + * @param {any} tile - The tile being rendered. + * @param {any} tileset - The tileset being used for rendering. + * @param {integer} width - The width of the layer. + * @param {integer} height - The height of the layer. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the layer is being rendered with. + * @param {integer} tilesetIndex - The tileset index. + * + * @return {integer} The new vOffset value. + */ + batchTile: function (vOffset, tile, tileset, width, height, camera, tilesetIndex) + { + var texCoords = tileset.getTileTextureCoordinates(tile.index); + + if (!texCoords) + { + return vOffset; + } + + var u0 = texCoords.x / width; + var v0 = texCoords.y / height; + var u1 = (texCoords.x + tile.width) / width; + var v1 = (texCoords.y + tile.height) / height; + + var matrix = this._tempMatrix; + + var tileWidth = tile.width; + var tileHeight = tile.height; + + var halfTileWidth = tileWidth / 2; + var halfTileHeight = tileHeight / 2; + + var x = -halfTileWidth; + var y = -halfTileHeight; + + if (tile.flipX) + { + tileWidth *= -1; + x += tile.width; + } + + if (tile.flipY) + { + tileHeight *= -1; + y += tile.height; + } + + var xw = x + tileWidth; + var yh = y + tileHeight; + + matrix.applyITRS(halfTileWidth + tile.pixelX, halfTileHeight + tile.pixelY, tile.rotation, 1, 1); + + var tint = Utils.getTintAppendFloatAlpha(0xffffff, camera.alpha * this.alpha * tile.alpha); + + var tx0 = matrix.getX(x, y); + var ty0 = matrix.getY(x, y); + + var tx1 = matrix.getX(x, yh); + var ty1 = matrix.getY(x, yh); + + var tx2 = matrix.getX(xw, yh); + var ty2 = matrix.getY(xw, yh); + + var tx3 = matrix.getX(xw, y); + var ty3 = matrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + var vertexViewF32 = this.vertexViewF32[tilesetIndex]; + var vertexViewU32 = this.vertexViewU32[tilesetIndex]; + + vertexViewF32[++vOffset] = tx0; + vertexViewF32[++vOffset] = ty0; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx1; + vertexViewF32[++vOffset] = ty1; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx2; + vertexViewF32[++vOffset] = ty2; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx0; + vertexViewF32[++vOffset] = ty0; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx2; + vertexViewF32[++vOffset] = ty2; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx3; + vertexViewF32[++vOffset] = ty3; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + this.vertexCount[tilesetIndex] += 6; + + return vOffset; + }, + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap Layer object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'string') + { + renderOrder = orders.indexOf(renderOrder); + } + + if (renderOrder >= 0 && renderOrder < 4) + { + this._renderOrder = renderOrder; + + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + } + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return this.cullCallback(this.layer, camera, this.culledTiles); + }, + + /** + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setSkipCull + * @since 3.12.0 + * + * @param {boolean} [value=true] - Set to `true` to stop culling tiles. Set to `false` to enable culling again. + * + * @return {this} This Tilemap Layer object. + */ + setSkipCull: function (value) + { + if (value === undefined) { value = true; } + + this.skipCull = value; + + return this; + }, + + /** + * Canvas only. + * + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCullPadding + * @since 3.12.0 + * + * @param {integer} [paddingX=1] - The amount of extra horizontal tiles to add to the cull check padding. + * @param {integer} [paddingY=1] - The amount of extra vertical tiles to add to the cull check padding. + * + * @return {this} This Tilemap Layer object. + */ + setCullPadding: function (paddingX, paddingY) + { + if (paddingX === undefined) { paddingX = 1; } + if (paddingY === undefined) { paddingY = 1; } + + this.cullPaddingX = paddingX; + this.cullPaddingY = paddingY; + + return this; + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * + * @return {boolean} + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {boolean} + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} [callbackContext] - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); + }, + + /** + * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.culledTiles.length = 0; + this.cullCallback = null; + + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + this.vertexCount[i] = 0; + this.vertexBuffer[i] = null; + this.bufferData[i] = null; + this.vertexViewF32[i] = null; + this.vertexViewU32[i] = null; + } + + this.gidMap = []; + this.tileset = []; + + GameObject.prototype.destroy.call(this); + } + +}); + +module.exports = StaticTilemapLayer; + + +/***/ }), +/* 208 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var DynamicTilemapLayerRender = __webpack_require__(449); +var GameObject = __webpack_require__(19); +var TilemapComponents = __webpack_require__(103); + +/** + * @classdesc + * A Dynamic Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. + * + * A Dynamic Tilemap Layer trades some speed for being able to apply powerful effects. Unlike a + * Static Tilemap Layer, you can apply per-tile effects like tint or alpha, and you can change the + * tiles in a DynamicTilemapLayer. + * + * Use this over a Static Tilemap Layer when you need those features. + * + * @class DynamicTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + */ +var DynamicTilemapLayer = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + DynamicTilemapLayerRender + ], + + initialize: + + function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) + { + GameObject.call(this, scene, 'DynamicTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + // Link the LayerData with this static tilemap layer + this.layer.tilemapLayer = this; + + /** + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tileset = []; + + /** + * Used internally with the canvas render. This holds the tiles that are visible within the + * camera. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#skipCull + * @type {boolean} + * @since 3.11.0 + */ + this.skipCull = false; + + /** + * The total number of tiles drawn by the renderer in the last frame. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilesDrawn + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.tilesDrawn = 0; + + /** + * The total number of tiles in this layer. Updated every frame. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilesTotal + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.tilesTotal = this.layer.width * this.layer.height; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingX + * @type {integer} + * @default 1 + * @since 3.11.0 + */ + this.cullPaddingX = 1; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingY + * @type {integer} + * @default 1 + * @since 3.11.0 + */ + this.cullPaddingY = 1; + + /** + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1) The Phaser.Tilemaps.LayerData object for this Layer + * 2) The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3) A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullCallback + * @type {function} + * @since 3.11.0 + */ + this.cullCallback = TilemapComponents.CullTiles; + + /** + * The rendering (draw) order of the tiles in this layer. + * + * The default is 0 which is 'right-down', meaning it will draw the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#_renderOrder + * @type {integer} + * @default 0 + * @private + * @since 3.12.0 + */ + this._renderOrder = 0; + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#gidMap + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.14.0 + */ + this.gidMap = []; + + this.setTilesets(tileset); + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.initPipeline('TextureTintPipeline'); + }, + + /** + * Populates the internal `tileset` array with the Tileset references this Layer requires for rendering. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTilesets + * @private + * @since 3.14.0 + * + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + */ + setTilesets: function (tilesets) + { + var gidMap = []; + var setList = []; + var map = this.tilemap; + + if (!Array.isArray(tilesets)) + { + tilesets = [ tilesets ]; + } + + for (var i = 0; i < tilesets.length; i++) + { + var tileset = tilesets[i]; + + if (typeof tileset === 'string') + { + tileset = map.getTileset(tileset); + } + + if (tileset) + { + setList.push(tileset); + + var s = tileset.firstgid; + + for (var t = 0; t < tileset.total; t++) + { + gidMap[s + t] = tileset; + } + } + } + + this.gidMap = gidMap; + this.tileset = setList; + }, + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap Layer object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'string') + { + renderOrder = orders.indexOf(renderOrder); + } + + if (renderOrder >= 0 && renderOrder < 4) + { + this._renderOrder = renderOrder; + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return this.cullCallback(this.layer, camera, this.culledTiles, this._renderOrder); + }, + + /** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#copy + * @since 3.0.0 + * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces) + { + TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.culledTiles.length = 0; + this.cullCallback = null; + + this.gidMap = []; + this.tileset = []; + + GameObject.prototype.destroy.call(this); + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#fill + * @since 3.0.0 + * + * @param {integer} index - The tile index to fill the area with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer); + + return this; + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * + * @return {boolean} `true` if a tile was found at the given location, otherwise `false`. + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * + * @return {boolean} `true` if a tile was found at the given location, otherwise `false`. + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces) + { + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera) + { + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + randomize: function (tileX, tileY, width, height, indexes) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer); + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces) + { + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera) + { + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setSkipCull + * @since 3.11.0 + * + * @param {boolean} [value=true] - Set to `true` to stop culling tiles. Set to `false` to enable culling again. + * + * @return {this} This Tilemap Layer object. + */ + setSkipCull: function (value) + { + if (value === undefined) { value = true; } + + this.skipCull = value; + + return this; + }, + + /** + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCullPadding + * @since 3.11.0 + * + * @param {integer} [paddingX=1] - The amount of extra horizontal tiles to add to the cull check padding. + * @param {integer} [paddingY=1] - The amount of extra vertical tiles to add to the cull check padding. + * + * @return {this} This Tilemap Layer object. + */ + setCullPadding: function (paddingX, paddingY) + { + if (paddingX === undefined) { paddingX = 1; } + if (paddingY === undefined) { paddingY = 1; } + + this.cullPaddingX = paddingX; + this.cullPaddingY = paddingY; + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} [callbackContext] - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + shuffle: function (tileX, tileY, width, height) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer); + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); + } + +}); + +module.exports = DynamicTilemapLayer; + + +/***/ }), +/* 209 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(31); +var DynamicTilemapLayer = __webpack_require__(208); +var Extend = __webpack_require__(20); +var Formats = __webpack_require__(29); +var LayerData = __webpack_require__(78); +var Rotate = __webpack_require__(242); +var StaticTilemapLayer = __webpack_require__(207); +var Tile = __webpack_require__(55); +var TilemapComponents = __webpack_require__(103); +var Tileset = __webpack_require__(99); + +/** + * @callback TilemapFilterCallback + * + * @param {Phaser.GameObjects.GameObject} value - An object found in the filtered area. + * @param {number} index - The index of the object within the array. + * @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found. + * + * @return {Phaser.GameObjects.GameObject} The object. + */ + +/** + * @callback TilemapFindCallback + * + * @param {Phaser.GameObjects.GameObject} value - An object found. + * @param {number} index - The index of the object within the array. + * @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found. + * + * @return {boolean} `true` if the callback should be invoked, otherwise `false`. + */ + +/** + * @classdesc + * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data + * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or + * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display + * objects that actually render tiles. + * + * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free + * software package specifically for creating tile maps, and is available from: + * http://www.mapeditor.org + * + * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only + * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. + * + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a + * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides + * it. + * + * @class Tilemap + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {Phaser.Tilemaps.MapData} mapData - A MapData instance containing Tilemap data. + */ +var Tilemap = new Class({ + + initialize: + + function Tilemap (scene, mapData) + { + /** + * @name Phaser.Tilemaps.Tilemap#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The base width of a tile in pixels. Note that individual layers may have a different tile + * width. + * + * @name Phaser.Tilemaps.Tilemap#tileWidth + * @type {integer} + * @since 3.0.0 + */ + this.tileWidth = mapData.tileWidth; + + /** + * The base height of a tile in pixels. Note that individual layers may have a different + * tile height. + * + * @name Phaser.Tilemaps.Tilemap#tileHeight + * @type {integer} + * @since 3.0.0 + */ + this.tileHeight = mapData.tileHeight; + + /** + * The width of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#width + * @type {number} + * @since 3.0.0 + */ + this.width = mapData.width; + + /** + * The height of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#height + * @type {number} + * @since 3.0.0 + */ + this.height = mapData.height; + + /** + * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. + * + * @name Phaser.Tilemaps.Tilemap#orientation + * @type {string} + * @since 3.0.0 + */ + this.orientation = mapData.orientation; + + /** + * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. + * + * The draw orders are: + * + * right-down + * left-down + * right-up + * left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.Tilemap#renderOrder + * @type {string} + * @since 3.12.0 + */ + this.renderOrder = mapData.renderOrder; + + /** + * The format of the map data. + * + * @name Phaser.Tilemaps.Tilemap#format + * @type {number} + * @since 3.0.0 + */ + this.format = mapData.format; + + /** + * The version of the map data (as specified in Tiled, usually 1). + * + * @name Phaser.Tilemaps.Tilemap#version + * @type {number} + * @since 3.0.0 + */ + this.version = mapData.version; + + /** + * Map specific properties as specified in Tiled. + * + * @name Phaser.Tilemaps.Tilemap#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = mapData.properties; + + /** + * The width of the map in pixels based on width * tileWidth. + * + * @name Phaser.Tilemaps.Tilemap#widthInPixels + * @type {number} + * @since 3.0.0 + */ + this.widthInPixels = mapData.widthInPixels; + + /** + * The height of the map in pixels based on height * tileHeight. + * + * @name Phaser.Tilemaps.Tilemap#heightInPixels + * @type {number} + * @since 3.0.0 + */ + this.heightInPixels = mapData.heightInPixels; + + /** + * + * @name Phaser.Tilemaps.Tilemap#imageCollections + * @type {Phaser.Tilemaps.ImageCollection[]} + * @since 3.0.0 + */ + this.imageCollections = mapData.imageCollections; + + /** + * An array of Tiled Image Layers. + * + * @name Phaser.Tilemaps.Tilemap#images + * @type {array} + * @since 3.0.0 + */ + this.images = mapData.images; + + /** + * An array of Tilemap layer data. + * + * @name Phaser.Tilemaps.Tilemap#layers + * @type {Phaser.Tilemaps.LayerData[]} + * @since 3.0.0 + */ + this.layers = mapData.layers; + + /** + * An array of Tilesets used in the map. + * + * @name Phaser.Tilemaps.Tilemap#tilesets + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tilesets = mapData.tilesets; + + /** + * An array of ObjectLayer instances parsed from Tiled object layers. + * + * @name Phaser.Tilemaps.Tilemap#objects + * @type {Phaser.Tilemaps.ObjectLayer[]} + * @since 3.0.0 + */ + this.objects = mapData.objects; + + /** + * The index of the currently selected LayerData object. + * + * @name Phaser.Tilemaps.Tilemap#currentLayerIndex + * @type {integer} + * @since 3.0.0 + */ + this.currentLayerIndex = 0; + }, + + /** + * Sets the rendering (draw) order of the tiles in this map. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * Calling this method _after_ creating Static or Dynamic Tilemap Layers will **not** automatically + * update them to use the new render order. If you call this method after creating layers, use their + * own `setRenderOrder` methods to change them as needed. + * + * @method Phaser.Tilemaps.Tilemap#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'number') + { + renderOrder = orders[renderOrder]; + } + + if (orders.indexOf(renderOrder) > -1) + { + this.renderOrder = renderOrder; + } + + return this; + }, + + /** + * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. + * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled + * editor. + * + * @method Phaser.Tilemaps.Tilemap#addTilesetImage + * @since 3.0.0 + * + * @param {string} tilesetName - The name of the tileset as specified in the map data. + * @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If + * `undefined` or `null` it will look for an image with a key matching the tilesetName parameter. + * @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not + * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled + * JSON file. + * @param {integer} [tileHeight] - The height of the tiles (in pixels) in the Tileset Image. If + * not given it will default to the map's tileHeight value, or the tileHeight specified in the + * Tiled JSON file. + * @param {integer} [tileMargin] - The margin around the tiles in the sheet (in pixels). If not + * specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [tileSpacing] - The spacing between each the tile in the sheet (in pixels). + * If not specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [gid=0] - If adding multiple tilesets to a blank map, specify the starting + * GID this set will use here. + * + * @return {?Phaser.Tilemaps.Tileset} Returns the Tileset object that was created or updated, or null if it + * failed. + */ + addTilesetImage: function (tilesetName, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) + { + if (tilesetName === undefined) { return null; } + if (key === undefined || key === null) { key = tilesetName; } + + if (!this.scene.sys.textures.exists(key)) + { + console.warn('Invalid Tileset Image: ' + key); + return null; + } + + var texture = this.scene.sys.textures.get(key); + + var index = this.getTilesetIndex(tilesetName); + + if (index === null && this.format === Formats.TILED_JSON) + { + console.warn('No data found for Tileset: ' + tilesetName); + return null; + } + + var tileset = this.tilesets[index]; + + if (tileset) + { + tileset.setTileSize(tileWidth, tileHeight); + tileset.setSpacing(tileMargin, tileSpacing); + tileset.setImage(texture); + + return tileset; + } + + if (tileWidth === undefined) { tileWidth = this.tileWidth; } + if (tileHeight === undefined) { tileHeight = this.tileHeight; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (gid === undefined) { gid = 0; } + + tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); + + tileset.setImage(texture); + + this.tilesets.push(tileset); + + return tileset; + }, + + /** + * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If + * no layer specified, the map's current layer is used. This is useful if you want to manipulate + * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. + * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value + * returned from this method if you want to manipulate the new StaticTilemapLayer. + * + * @method Phaser.Tilemaps.Tilemap#convertLayerToStatic + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer)} [layer] - The name of the layer from Tiled, the + * index of the layer in the map, or a DynamicTilemapLayer. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer that was created, or null if it + * failed. + */ + convertLayerToStatic: function (layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + var dynamicLayer = layer.tilemapLayer; + + if (!dynamicLayer || !(dynamicLayer instanceof DynamicTilemapLayer)) + { + return null; + } + + var staticLayer = new StaticTilemapLayer( + dynamicLayer.scene, + dynamicLayer.tilemap, + dynamicLayer.layerIndex, + dynamicLayer.tileset, + dynamicLayer.x, + dynamicLayer.y + ); + + this.scene.sys.displayList.add(staticLayer); + + dynamicLayer.destroy(); + + return staticLayer; + }, + + /** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#copy + * @since 3.0.0 + * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'copy')) { return this; } + + if (layer !== null) + { + TilemapComponents.Copy( + srcTileX, srcTileY, + width, height, + destTileX, destTileY, + recalculateFaces, layer + ); + } + + return this; + }, + + /** + * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set to this new layer. + * + * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer + * @since 3.0.0 + * + * @param {string} name - The name of this layer. Must be unique within the map. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + * @param {integer} [width] - The width of the layer in tiles. If not specified, it will default to the map's width. + * @param {integer} [height] - The height of the layer in tiles. If not specified, it will default to the map's height. + * @param {integer} [tileWidth] - The width of the tiles the layer uses for calculations. If not specified, it will default to the map's tileWidth. + * @param {integer} [tileHeight] - The height of the tiles the layer uses for calculations. If not specified, it will default to the map's tileHeight. + * + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) + { + if (tileWidth === undefined) { tileWidth = tileset.tileWidth; } + if (tileHeight === undefined) { tileHeight = tileset.tileHeight; } + if (width === undefined) { width = this.width; } + if (height === undefined) { height = this.height; } + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + var index = this.getLayerIndex(name); + + if (index !== null) + { + console.warn('Invalid Tilemap Layer ID: ' + name); + return null; + } + + var layerData = new LayerData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + + var row; + + for (var tileY = 0; tileY < height; tileY++) + { + row = []; + + for (var tileX = 0; tileX < width; tileX++) + { + row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight)); + } + + layerData.data.push(row); + } + + this.layers.push(layerData); + + this.currentLayerIndex = this.layers.length - 1; + + var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); + + dynamicLayer.setRenderOrder(this.renderOrder); + + this.scene.sys.displayList.add(dynamicLayer); + + return dynamicLayer; + }, + + /** + * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more + * information. + * + * @method Phaser.Tilemaps.Tilemap#createDynamicLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createDynamicLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Invalid Tilemap Layer ID: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Tilemap Layer ID already exists:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); + + layer.setRenderOrder(this.renderOrder); + + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Creates a Sprite for every object matching the given gid in the map data. All properties from + * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy + * way to configure Sprite properties from within the map editor. For example giving an object a + * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. + * + * Custom object properties not sharing names with the Sprite's own properties are copied to the + * Sprite's {@link Phaser.GameObjects.Sprite#data data store}. + * + * @method Phaser.Tilemaps.Tilemap#createFromObjects + * @since 3.0.0 + * + * @param {string} name - The name of the object layer (from Tiled) to create Sprites from. + * @param {(integer|string)} id - Either the id (object), gid (tile object) or name (object or + * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects + * with the same graphic. The same name can be used on multiple objects. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromObjects: function (name, id, spriteConfig, scene) + { + if (spriteConfig === undefined) { spriteConfig = {}; } + if (scene === undefined) { scene = this.scene; } + + var objectLayer = this.getObjectLayer(name); + if (!objectLayer) + { + console.warn('Cannot create from object. Invalid objectgroup name given: ' + name); + return; + } + + var objects = objectLayer.objects; + var sprites = []; + + for (var i = 0; i < objects.length; i++) + { + var found = false; + var obj = objects[i]; + + if (obj.gid !== undefined && typeof id === 'number' && obj.gid === id || + obj.id !== undefined && typeof id === 'number' && obj.id === id || + obj.name !== undefined && typeof id === 'string' && obj.name === id) + { + found = true; + } + + if (found) + { + var config = Extend({}, spriteConfig, obj.properties); + + config.x = obj.x; + config.y = obj.y; + + var sprite = this.scene.make.sprite(config); + + sprite.name = obj.name; + + if (obj.width) { sprite.displayWidth = obj.width; } + if (obj.height) { sprite.displayHeight = obj.height; } + + // Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin. + var offset = { + x: sprite.originX * sprite.displayWidth, + y: (sprite.originY - 1) * sprite.displayHeight + }; + + // If the object is rotated, then the origin offset also needs to be rotated. + if (obj.rotation) + { + var angle = DegToRad(obj.rotation); + Rotate(offset, angle); + sprite.rotation = angle; + } + + sprite.x += offset.x; + sprite.y += offset.y; + + if (obj.flippedHorizontal !== undefined || obj.flippedVertical !== undefined) + { + sprite.setFlip(obj.flippedHorizontal, obj.flippedVertical); + } + + if (!obj.visible) { sprite.visible = false; } + + for (var key in obj.properties) + { + if (sprite.hasOwnProperty(key)) + { + continue; + } + + sprite.setData(key, obj.properties[key]); + } + + sprites.push(sprite); + } + } + + return sprites; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.Tilemap#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.GameObjects.Sprite[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, layer); + }, + + /** + * Creates a new StaticTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for + * more information. + * + * @method Phaser.Tilemaps.Tilemap#createStaticLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createStaticLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Invalid Tilemap Layer ID: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Tilemap Layer ID already exists:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); + + layer.setRenderOrder(this.renderOrder); + + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any + * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. + * + * @method Phaser.Tilemaps.Tilemap#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllLayers(); + this.tilesets.length = 0; + this.objects.length = 0; + this.scene = undefined; + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * If no layer specified, the map's current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#fill + * @since 3.0.0 + * + * @param {integer} index - The tile index to fill the area with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'fill')) { return this; } + + if (layer !== null) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, layer); + } + + return this; + }, + + /** + * For each object in the given object layer, run the given filter callback function. Any + * objects that pass the filter test (i.e. where the callback returns true) will returned as a + * new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#filterObjects + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param {TilemapFilterCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject[]} An array of object that match the search, or null if the objectLayer given was invalid. + */ + filterObjects: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.filter(callback, context); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to apply the filter on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to run the search on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findByIndex: function (findIndex, skip, reverse, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindByIndex(findIndex, skip, reverse, layer); + }, + + /** + * Find the first object in the given object layer that satisfies the provided testing function. + * I.e. finds the first object for which `callback` returns true. Similar to + * Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#findObject + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param {TilemapFindCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject} An object that matches the search, or null if no object found. + */ + findObject: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.find(callback, context) || null; + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to run the search on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#forEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to run the search on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer !== null) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + } + + return this; + }, + + /** + * Gets the image layer index based on its name. + * + * @method Phaser.Tilemaps.Tilemap#getImageIndex + * @since 3.0.0 + * + * @param {string} name - The name of the image to get. + * + * @return {integer} The index of the image in this tilemap, or null if not found. + */ + getImageIndex: function (name) + { + return this.getIndex(this.images, name); + }, + + /** + * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name + * property matches the given `name`. + * + * @method Phaser.Tilemaps.Tilemap#getIndex + * @since 3.0.0 + * + * @param {array} location - The Tilemap array to search. + * @param {string} name - The name of the array element to get. + * + * @return {number} The index of the element in the array, or null if not found. + */ + getIndex: function (location, name) + { + for (var i = 0; i < location.length; i++) + { + if (location[i].name === name) + { + return i; + } + } + + return null; + }, + + /** + * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the maps current layer index. + * + * @return {Phaser.Tilemaps.LayerData} The corresponding LayerData within this.layers. + */ + getLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + return index !== null ? this.layers[index] : null; + }, + + /** + * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer + * is found with that name. + * + * @method Phaser.Tilemaps.Tilemap#getObjectLayer + * @since 3.0.0 + * + * @param {string} [name] - The name of the object layer from Tiled. + * + * @return {?Phaser.Tilemaps.ObjectLayer} The corresponding ObjectLayer within this.objects or null. + */ + getObjectLayer: function (name) + { + var index = this.getIndex(this.objects, name); + + return index !== null ? this.objects[index] : null; + }, + + /** + * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndex + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndex: function (layer) + { + if (layer === undefined) + { + return this.currentLayerIndex; + } + else if (typeof layer === 'string') + { + return this.getLayerIndexByName(layer); + } + else if (typeof layer === 'number' && layer < this.layers.length) + { + return layer; + } + else if (layer instanceof StaticTilemapLayer || layer instanceof DynamicTilemapLayer) + { + return layer.layerIndex; + } + else + { + return null; + } + }, + + /** + * Gets the index of the LayerData within this.layers that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndexByName + * @since 3.0.0 + * + * @param {string} name - The name of the layer to get. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndexByName: function (name) + { + return this.getIndex(this.layers, name); + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAt: function (tileX, tileY, nonNull, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) + { + return null; + } + else + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, layer); + } + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinShape: function (shape, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); + }, + + /** + * Gets the Tileset that has the given `name`, or null if an invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getTileset + * @since 3.14.0 + * + * @param {string} name - The name of the Tileset to get. + * + * @return {?Phaser.Tilemaps.Tileset} The Tileset, or `null` if no matching named tileset was found. + */ + getTileset: function (name) + { + var index = this.getIndex(this.tilesets, name); + + return (index !== null) ? this.tilesets[index] : null; + }, + + /** + * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getTilesetIndex + * @since 3.0.0 + * + * @param {string} name - The name of the Tileset to get. + * + * @return {integer} The Tileset index within this.tilesets. + */ + getTilesetIndex: function (name) + { + return this.getIndex(this.tilesets, name); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAt(tileX, tileY, layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAtWorldXY: function (worldX, worldY, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, layer); + }, + + /** + * The LayerData object that is currently selected in the map. You can set this property using + * any type supported by setLayer. + * + * @name Phaser.Tilemaps.Tilemap#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + layer: { + get: function () + { + return this.layers[this.currentLayerIndex]; + }, + + set: function (layer) + { + this.setLayer(layer); + } + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. + * + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid or the coordinates were out of bounds. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTilesAt')) { return this; } + + if (layer !== null) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, layer); + } + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + randomize: function (tileX, tileY, width, height, indexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'randomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, layer); + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesAt(tileX, tileY, layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesWithin: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, layer); + + return this; + }, + + /** + * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or + * DynamicTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeAllLayers + * @since 3.0.0 + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + removeAllLayers: function () + { + // Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData + for (var i = 0; i < this.layers.length; i++) + { + if (this.layers[i].tilemapLayer) + { + this.layers[i].tilemapLayer.destroy(); + } + } + + this.layers.length = 0; + this.currentLayerIndex = 0; + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + renderDebug: function (graphics, styleConfig, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.RenderDebug(graphics, styleConfig, layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'replaceByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollision: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileIndexCallback: function (indexes, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} [callbackContext] - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets the current layer to the LayerData associated with `layer`. + * + * @method Phaser.Tilemaps.Tilemap#setLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + if (index !== null) + { + this.currentLayerIndex = index; + } + + return this; + }, + + /** + * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and + * tileHeight for all layers. This also updates the base size on all tiles across all layers. + * + * @method Phaser.Tilemaps.Tilemap#setBaseTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles the map uses for calculations. + * @param {integer} tileHeight - The height of the tiles the map uses for calculations. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setBaseTileSize: function (tileWidth, tileHeight) + { + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.widthInPixels = this.width * tileWidth; + this.heightInPixels = this.height * tileHeight; + + // Update the base tile size on all layers & tiles + for (var i = 0; i < this.layers.length; i++) + { + this.layers[i].baseTileWidth = tileWidth; + this.layers[i].baseTileHeight = tileHeight; + + var mapData = this.layers[i].data; + var mapWidth = this.layers[i].width; + var mapHeight = this.layers[i].height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) + { + tile.setSize(undefined, undefined, tileWidth, tileHeight); + } + } + } + } + + return this; + }, + + /** + * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's + * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any + * tiles the layer has. + * + * @method Phaser.Tilemaps.Tilemap#setLayerTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles (in pixels) in the layer. + * @param {integer} tileHeight - The height of the tiles (in pixels) in the layer. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayerTileSize: function (tileWidth, tileHeight, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + layer.tileWidth = tileWidth; + layer.tileHeight = tileHeight; + + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) { tile.setSize(tileWidth, tileHeight); } + } + } + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + shuffle: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'shuffle')) { return this; } + + if (layer !== null) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'swapByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldX: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldX(tileX, camera, layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldY: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldY(tileX, camera, layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + tileToWorldXY: function (tileX, tileY, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the map's current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'weightedRandomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, layer); + } + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileX: function (worldX, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileY: function (worldY, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer); + }, + + /** + * Used internally to check if a layer is static and prints out a warning. + * + * @method Phaser.Tilemaps.Tilemap#_isStaticCall + * @private + * @since 3.0.0 + * + * @return {boolean} + */ + _isStaticCall: function (layer, functionName) + { + if (layer.tilemapLayer instanceof StaticTilemapLayer) + { + console.warn(functionName + ': You cannot change the tiles in a static tilemap layer'); + return true; + } + else + { + return false; + } + } + +}); + +module.exports = Tilemap; + + +/***/ }), +/* 210 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var MapData = __webpack_require__(77); +var ParseTileLayers = __webpack_require__(451); +var ParseTilesets = __webpack_require__(450); + +/** + * @namespace Phaser.Tilemaps.Parsers.Impact + */ + +/** + * Parses a Weltmeister JSON object into a new MapData object. + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Weltmeister JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {?object} [description] + */ +var ParseWeltmeister = function (name, json, insertNull) +{ + if (json.layer.length === 0) + { + console.warn('No layers found in the Weltmeister map: ' + name); + return null; + } + + var width = 0; + var height = 0; + + for (var i = 0; i < json.layer.length; i++) + { + if (json.layer[i].width > width) { width = json.layer[i].width; } + if (json.layer[i].height > height) { height = json.layer[i].height; } + } + + var mapData = new MapData({ + width: width, + height: height, + name: name, + tileWidth: json.layer[0].tilesize, + tileHeight: json.layer[0].tilesize, + format: Formats.WELTMEISTER + }); + + mapData.layers = ParseTileLayers(json, insertNull); + mapData.tilesets = ParseTilesets(json); + + return mapData; +}; + +module.exports = ParseWeltmeister; + + +/***/ }), +/* 211 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled + * object layer, except: + * - "x" & "y" properties are ignored since these cannot be changed in Tiled. + * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they + * are ignored as well. + * - "draworder" is ignored. + * + * @class ObjectLayer + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {object} [config] - [description] + */ +var ObjectLayer = new Class({ + + initialize: + + function ObjectLayer (config) + { + if (config === undefined) { config = {}; } + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#name + * @type {string} + * @since 3.0.0 + */ + this.name = GetFastValue(config, 'name', 'object layer'); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#opacity + * @type {number} + * @since 3.0.0 + */ + this.opacity = GetFastValue(config, 'opacity', 1); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = GetFastValue(config, 'properties', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#propertyTypes + * @type {object} + * @since 3.0.0 + */ + this.propertyTypes = GetFastValue(config, 'propertytypes', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#type + * @type {string} + * @since 3.0.0 + */ + this.type = GetFastValue(config, 'type', 'objectgroup'); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#visible + * @type {boolean} + * @since 3.0.0 + */ + this.visible = GetFastValue(config, 'visible', true); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#objects + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.0.0 + */ + this.objects = GetFastValue(config, 'objects', []); + } + +}); + +module.exports = ObjectLayer; + + +/***/ }), +/* 212 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Pick = __webpack_require__(455); +var ParseGID = __webpack_require__(214); + +var copyPoints = function (p) { return { x: p.x, y: p.y }; }; + +var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject + * @since 3.0.0 + * + * @param {object} tiledObject - [description] + * @param {number} [offsetX=0] - [description] + * @param {number} [offsetY=0] - [description] + * + * @return {object} [description] + */ +var ParseObject = function (tiledObject, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + var parsedObject = Pick(tiledObject, commonObjectProps); + + parsedObject.x += offsetX; + parsedObject.y += offsetY; + + if (tiledObject.gid) + { + // Object tiles + var gidInfo = ParseGID(tiledObject.gid); + parsedObject.gid = gidInfo.gid; + parsedObject.flippedHorizontal = gidInfo.flippedHorizontal; + parsedObject.flippedVertical = gidInfo.flippedVertical; + parsedObject.flippedAntiDiagonal = gidInfo.flippedAntiDiagonal; + } + else if (tiledObject.polyline) + { + parsedObject.polyline = tiledObject.polyline.map(copyPoints); + } + else if (tiledObject.polygon) + { + parsedObject.polygon = tiledObject.polygon.map(copyPoints); + } + else if (tiledObject.ellipse) + { + parsedObject.ellipse = tiledObject.ellipse; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + } + else if (tiledObject.text) + { + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + parsedObject.text = tiledObject.text; + } + else + { + // Otherwise, assume it is a rectangle + parsedObject.rectangle = true; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + } + + return parsedObject; +}; + +module.exports = ParseObject; + + +/***/ }), +/* 213 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. + * + * Image Collections are normally created automatically when Tiled data is loaded. + * + * @class ImageCollection + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {string} name - The name of the image collection in the map data. + * @param {integer} firstgid - The first image index this image collection contains. + * @param {integer} [width=32] - Width of widest image (in pixels). + * @param {integer} [height=32] - Height of tallest image (in pixels). + * @param {integer} [margin=0] - The margin around all images in the collection (in pixels). + * @param {integer} [spacing=0] - The spacing between each image in the collection (in pixels). + * @param {object} [properties={}] - Custom Image Collection properties. + */ +var ImageCollection = new Class({ + + initialize: + + function ImageCollection (name, firstgid, width, height, margin, spacing, properties) + { + if (width === undefined || width <= 0) { width = 32; } + if (height === undefined || height <= 0) { height = 32; } + if (margin === undefined) { margin = 0; } + if (spacing === undefined) { spacing = 0; } + + /** + * The name of the Image Collection. + * + * @name Phaser.Tilemaps.ImageCollection#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The Tiled firstgid value. + * This is the starting index of the first image index this Image Collection contains. + * + * @name Phaser.Tilemaps.ImageCollection#firstgid + * @type {integer} + * @since 3.0.0 + */ + this.firstgid = firstgid | 0; + + /** + * The width of the widest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageWidth + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageWidth = width | 0; + + /** + * The height of the tallest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageHeight + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageHeight = height | 0; + + /** + * The margin around the images in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageMarge + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageMargin = margin | 0; + + /** + * The spacing between each image in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageSpacing + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageSpacing = spacing | 0; + + /** + * Image Collection-specific properties that are typically defined in the Tiled editor. + * + * @name Phaser.Tilemaps.ImageCollection#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = properties || {}; + + /** + * The cached images that are a part of this collection. + * + * @name Phaser.Tilemaps.ImageCollection#images + * @type {array} + * @readonly + * @since 3.0.0 + */ + this.images = []; + + /** + * The total number of images in the image collection. + * + * @name Phaser.Tilemaps.ImageCollection#total + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.total = 0; + }, + + /** + * Returns true if and only if this image collection contains the given image index. + * + * @method Phaser.Tilemaps.ImageCollection#containsImageIndex + * @since 3.0.0 + * + * @param {integer} imageIndex - The image index to search for. + * + * @return {boolean} True if this Image Collection contains the given index. + */ + containsImageIndex: function (imageIndex) + { + return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)); + }, + + /** + * Add an image to this Image Collection. + * + * @method Phaser.Tilemaps.ImageCollection#addImage + * @since 3.0.0 + * + * @param {integer} gid - The gid of the image in the Image Collection. + * @param {string} image - The the key of the image in the Image Collection and in the cache. + * + * @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object. + */ + addImage: function (gid, image) + { + this.images.push({ gid: gid, image: image }); + this.total++; + + return this; + } + +}); + +module.exports = ImageCollection; + + +/***/ }), +/* 214 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FLIPPED_HORIZONTAL = 0x80000000; +var FLIPPED_VERTICAL = 0x40000000; +var FLIPPED_ANTI_DIAGONAL = 0x20000000; // Top-right is swapped with bottom-left corners + +/** + * See Tiled documentation on tile flipping: + * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseGID + * @since 3.0.0 + * + * @param {number} gid - [description] + * + * @return {object} [description] + */ +var ParseGID = function (gid) +{ + var flippedHorizontal = Boolean(gid & FLIPPED_HORIZONTAL); + var flippedVertical = Boolean(gid & FLIPPED_VERTICAL); + var flippedAntiDiagonal = Boolean(gid & FLIPPED_ANTI_DIAGONAL); + gid = gid & ~(FLIPPED_HORIZONTAL | FLIPPED_VERTICAL | FLIPPED_ANTI_DIAGONAL); + + // Parse the flip flags into something Phaser can use + var rotation = 0; + var flipped = false; + + if (flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = true; + } + else if (flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = true; + } + else if (!flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = false; + } + else if (!flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = false; + } + + return { + gid: gid, + flippedHorizontal: flippedHorizontal, + flippedVertical: flippedVertical, + flippedAntiDiagonal: flippedAntiDiagonal, + rotation: rotation, + flipped: flipped + }; +}; + +module.exports = ParseGID; + + +/***/ }), +/* 215 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var MapData = __webpack_require__(77); +var ParseTileLayers = __webpack_require__(459); +var ParseImageLayers = __webpack_require__(457); +var ParseTilesets = __webpack_require__(456); +var ParseObjectLayers = __webpack_require__(454); +var BuildTilesetIndex = __webpack_require__(453); +var AssignTileProperties = __webpack_require__(452); + +/** + * @namespace Phaser.Tilemaps.Parsers.Tiled + */ + +/** + * Parses a Tiled JSON object into a new MapData object. + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Tiled JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {?Phaser.Tilemaps.MapData} The created MapData object, or `null` if the data can't be parsed. + */ +var ParseJSONTiled = function (name, json, insertNull) +{ + if (json.orientation !== 'orthogonal') + { + console.warn('Only orthogonal map types are supported in this version of Phaser'); + return null; + } + + // Map data will consist of: layers, objects, images, tilesets, sizes + var mapData = new MapData({ + width: json.width, + height: json.height, + name: name, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + orientation: json.orientation, + format: Formats.TILED_JSON, + version: json.version, + properties: json.properties, + renderOrder: json.renderorder + }); + + mapData.layers = ParseTileLayers(json, insertNull); + mapData.images = ParseImageLayers(json); + + var sets = ParseTilesets(json); + mapData.tilesets = sets.tilesets; + mapData.imageCollections = sets.imageCollections; + + mapData.objects = ParseObjectLayers(json); + + mapData.tiles = BuildTilesetIndex(mapData); + + AssignTileProperties(mapData); + + return mapData; +}; + +module.exports = ParseJSONTiled; + + +/***/ }), +/* 216 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var Parse2DArray = __webpack_require__(133); + +/** + * Parses a CSV string of tile indexes into a new MapData object with a single layer. + * + * @function Phaser.Tilemaps.Parsers.ParseCSV + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {string} data - CSV string of tile indexes. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.MapData} The resulting MapData object. + */ +var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) +{ + var array2D = data + .trim() + .split('\n') + .map(function (row) { return row.split(','); }); + + var map = Parse2DArray(name, array2D, tileWidth, tileHeight, insertNull); + map.format = Formats.CSV; + + return map; +}; + +module.exports = ParseCSV; + + +/***/ }), +/* 217 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var Parse2DArray = __webpack_require__(133); +var ParseCSV = __webpack_require__(216); +var ParseJSONTiled = __webpack_require__(215); +var ParseWeltmeister = __webpack_require__(210); + +/** + * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format + * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & + * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from + * the map data. + * + * @function Phaser.Tilemaps.Parsers.Parse + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer} mapFormat - See ../Formats.js. + * @param {(integer[][]|string|object)} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {integer} tileHeight - The height of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.MapData} The created `MapData` object. + */ +var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) +{ + var newMap; + + switch (mapFormat) + { + case (Formats.ARRAY_2D): + newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.CSV): + newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.TILED_JSON): + newMap = ParseJSONTiled(name, data, insertNull); + break; + case (Formats.WELTMEISTER): + newMap = ParseWeltmeister(name, data, insertNull); + break; + default: + console.warn('Unrecognized tilemap data format: ' + mapFormat); + newMap = null; + } + + return newMap; +}; + +module.exports = Parse; + + +/***/ }), +/* 218 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tile = __webpack_require__(55); +var IsInLayerBounds = __webpack_require__(79); +var CalculateFacesAt = __webpack_require__(136); + +/** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * @function Phaser.Tilemaps.Components.RemoveTileAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + */ +var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer) +{ + if (replaceWithNull === undefined) { replaceWithNull = false; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else + { + layer.data[tileY][tileX] = replaceWithNull + ? null + : new Tile(layer, -1, tileX, tileY, tile.width, tile.height); + } + + // Recalculate faces only if the removed tile was a colliding tile + if (recalculateFaces && tile && tile.collides) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return tile; +}; + +module.exports = RemoveTileAt; + + +/***/ }), +/* 219 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsInLayerBounds = __webpack_require__(79); + +/** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @function Phaser.Tilemaps.Components.HasTileAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ +var HasTileAt = function (tileX, tileY, layer) +{ + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + return (tile !== null && tile.index > -1); + } + else + { + return false; + } + +}; + +module.exports = HasTileAt; + + +/***/ }), +/* 220 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * @function Phaser.Tilemaps.Components.ReplaceByIndex + * @private + * @since 3.0.0 + * + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + if (tiles[i] && tiles[i].index === findIndex) + { + tiles[i].index = newIndex; + } + } +}; + +module.exports = ReplaceByIndex; + + +/***/ }), +/* 221 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -34846,7 +49554,7 @@ var Class = __webpack_require__(0); * It can listen for Game events and respond to them. * * @class BasePlugin - * @memberOf Phaser.Plugins + * @memberof Phaser.Plugins * @constructor * @since 3.8.0 * @@ -34914,6 +49622,8 @@ var BasePlugin = new Class({ * * @method Phaser.Plugins.BasePlugin#init * @since 3.8.0 + * + * @param {?any} [data] - A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually). */ init: function () { @@ -35008,8 +49718,1607 @@ module.exports = BasePlugin; /***/ }), -/* 166 */, -/* 167 */ +/* 222 */, +/* 223 */, +/* 224 */, +/* 225 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircleContains = __webpack_require__(40); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var RectangleContains = __webpack_require__(39); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Static Arcade Physics Body. + * + * A Static Body never moves, and isn't automatically synchronized with its parent Game Object. + * That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually. + * + * A Static Body can collide with other Bodies, but is never moved by collisions. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Body}. + * + * @class StaticBody + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ +var StaticBody = new Class({ + + initialize: + + function StaticBody (world, gameObject) + { + var width = (gameObject.width) ? gameObject.width : 64; + var height = (gameObject.height) ? gameObject.height : 64; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#gameObject + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.gameObject = gameObject; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowStaticBody; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.staticBodyDebugColor; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#enable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enable = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#isCircle + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isCircle = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#radius + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.radius = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#offset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.offset = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(this.width / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(this.height / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#velocity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.velocity = Vector2.ZERO; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#allowGravity + * @type {boolean} + * @readonly + * @default false + * @since 3.0.0 + */ + this.allowGravity = false; + + /** + * Gravitational force applied specifically to this Body. Values are in pixels per second squared. Always zero for a Static Body. + * + * @name Phaser.Physics.Arcade.StaticBody#gravity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.gravity = Vector2.ZERO; + + /** + * Rebound, or restitution, following a collision, relative to 1. Always zero for a Static Body. + * + * @name Phaser.Physics.Arcade.StaticBody#bounce + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.bounce = Vector2.ZERO; + + // If true this Body will dispatch events + + /** + * Whether the simulation emits a `worldbounds` event when this StaticBody collides with the world boundary (and `collideWorldBounds` is also true). + * + * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onWorldBounds = false; + + /** + * Whether the simulation emits a `collide` event when this StaticBody collides with another. + * + * @name Phaser.Physics.Arcade.StaticBody#onCollide + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onCollide = false; + + /** + * Whether the simulation emits an `overlap` event when this StaticBody overlaps with another. + * + * @name Phaser.Physics.Arcade.StaticBody#onOverlap + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onOverlap = false; + + /** + * The StaticBody's inertia, relative to a default unit (1). With `bounce`, this affects the exchange of momentum (velocities) during collisions. + * + * @name Phaser.Physics.Arcade.StaticBody#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * Whether this object can be moved by collisions with another body. + * + * @name Phaser.Physics.Arcade.StaticBody#immovable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.immovable = true; + + /** + * A flag disabling the default horizontal separation of colliding bodies. Pass your own `processHandler` to the collider. + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * A flag disabling the default vertical separation of colliding bodies. Pass your own `processHandler` to the collider. + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * The amount of horizontal overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.StaticBody#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * The amount of vertical overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.StaticBody#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * The amount of overlap (before separation), if this StaticBody is circular and colliding with another circular body. + * + * @name Phaser.Physics.Arcade.StaticBody#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * Whether this StaticBody is overlapped with another and both have zero velocity. + * + * @name Phaser.Physics.Arcade.StaticBody#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * Whether this StaticBody interacts with the world boundary. + * + * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * Whether this StaticBody is checked for collisions and for which directions. You can set `checkCollision.none = false` to disable collision checks. + * + * @name Phaser.Physics.Arcade.StaticBody#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * Whether this StaticBody is colliding with another and in which direction. + * + * @name Phaser.Physics.Arcade.StaticBody#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this StaticBody was colliding with another during the last step, and in which direction. + * + * @name Phaser.Physics.Arcade.StaticBody#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this StaticBody is colliding with a tile or the world boundary. + * + * @name Phaser.Physics.Arcade.StaticBody#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * The StaticBody's physics type (static by default). + * + * @name Phaser.Physics.Arcade.StaticBody#physicsType + * @type {integer} + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; + + /** + * The calculated change in the Body's horizontal position during the current step. + * For a static body this is always zero. + * + * @name Phaser.Physics.Arcade.StaticBody#_dx + * @type {number} + * @private + * @default 0 + * @since 3.10.0 + */ + this._dx = 0; + + /** + * The calculated change in the Body's vertical position during the current step. + * For a static body this is always zero. + * + * @name Phaser.Physics.Arcade.StaticBody#_dy + * @type {number} + * @private + * @default 0 + * @since 3.10.0 + */ + this._dy = 0; + }, + + /** + * Changes the Game Object this Body is bound to. + * First it removes its reference from the old Game Object, then sets the new one. + * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. + * + * @method Phaser.Physics.Arcade.StaticBody#setGameObject + * @since 3.1.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The new Game Object that will own this Body. + * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + * + * @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject + */ + setGameObject: function (gameObject, update) + { + if (gameObject && gameObject !== this.gameObject) + { + // Remove this body from the old game object + this.gameObject.body = null; + + gameObject.body = this; + + // Update our reference + this.gameObject = gameObject; + } + + if (update) + { + this.updateFromGameObject(); + } + + return this; + }, + + /** + * Updates this Static Body so that its position and dimensions are updated + * based on the current Game Object it is bound to. + * + * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject + * @since 3.1.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + updateFromGameObject: function () + { + this.world.staticTree.remove(this); + + var gameObject = this.gameObject; + + gameObject.getTopLeft(this.position); + + this.width = gameObject.displayWidth; + this.height = gameObject.displayHeight; + + this.halfWidth = Math.abs(this.width / 2); + this.halfHeight = Math.abs(this.height / 2); + + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * Sets the offset of the body. + * + * @method Phaser.Physics.Arcade.StaticBody#setOffset + * @since 3.4.0 + * + * @param {number} x - The horizontal offset of the Body from the Game Object's center. + * @param {number} y - The vertical offset of the Body from the Game Object's center. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setOffset: function (x, y) + { + if (y === undefined) { y = x; } + + this.world.staticTree.remove(this); + + this.position.x -= this.offset.x; + this.position.y -= this.offset.y; + + this.offset.set(x, y); + + this.position.x += this.offset.x; + this.position.y += this.offset.y; + + this.updateCenter(); + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * Sets the size of the body. + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * + * @method Phaser.Physics.Arcade.StaticBody#setSize + * @since 3.0.0 + * + * @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param {number} [offsetX] - The horizontal offset of the Body from the Game Object's center. + * @param {number} [offsetY] - The vertical offset of the Body from the Game Object's center. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setSize: function (width, height, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + var gameObject = this.gameObject; + + if (!width && gameObject.frame) + { + width = gameObject.frame.realWidth; + } + + if (!height && gameObject.frame) + { + height = gameObject.frame.realHeight; + } + + this.world.staticTree.remove(this); + + this.width = width; + this.height = height; + + this.halfWidth = Math.floor(width / 2); + this.halfHeight = Math.floor(height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.isCircle = false; + this.radius = 0; + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * Sets this Static Body to have a circular body and sets its sizes and position. + * + * @method Phaser.Physics.Arcade.StaticBody#setCircle + * @since 3.0.0 + * + * @param {number} radius - The radius of the StaticBody, in pixels. + * @param {number} [offsetX] - The horizontal offset of the StaticBody from its Game Object, in pixels. + * @param {number} [offsetY] - The vertical offset of the StaticBody from its Game Object, in pixels. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.world.staticTree.remove(this); + + this.isCircle = true; + + this.radius = radius; + + this.width = radius * 2; + this.height = radius * 2; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.world.staticTree.insert(this); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * Updates the StaticBody's `center` from its `position` and dimensions. + * + * @method Phaser.Physics.Arcade.StaticBody#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * Updates this Static Body's position based on the current Game Object it is bound to. + * Similar to `updateFromGameObject`, but doesn't modify the Body's dimensions. + * + * @method Phaser.Physics.Arcade.StaticBody#reset + * @since 3.0.0 + * + * @param {number} x - The x coordinate to reset the body to. + * @param {number} y - The y coordinate to reset the body to. + */ + reset: function (x, y) + { + var gameObject = this.gameObject; + + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + this.world.staticTree.remove(this); + + gameObject.getTopLeft(this.position); + + this.updateCenter(); + + this.world.staticTree.insert(this); + }, + + /** + * NOOP function. A Static Body cannot be stopped. + * + * @method Phaser.Physics.Arcade.StaticBody#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + stop: function () + { + return this; + }, + + /** + * Returns the x and y coordinates of the top left and bottom right points of the StaticBody. + * + * @method Phaser.Physics.Arcade.StaticBody#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - The object which will hold the coordinates of the bounds. + * + * @return {ArcadeBodyBounds} The same object that was passed with `x`, `y`, `right` and `bottom` values matching the respective values of the StaticBody. + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * Checks to see if a given x,y coordinate is colliding with this Static Body. + * + * @method Phaser.Physics.Arcade.StaticBody#hitTest + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check against this body. + * @param {number} y - The y coordinate to check against this body. + * + * @return {boolean} `true` if the given coordinate lies within this body, otherwise `false`. + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * NOOP + * + * @method Phaser.Physics.Arcade.StaticBody#postUpdate + * @since 3.12.0 + */ + postUpdate: function () + { + }, + + /** + * The absolute (non-negative) change in this StaticBody's horizontal position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX + * @since 3.0.0 + * + * @return {number} Always zero for a Static Body. + */ + deltaAbsX: function () + { + return 0; + }, + + /** + * The absolute (non-negative) change in this StaticBody's vertical position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY + * @since 3.0.0 + * + * @return {number} Always zero for a Static Body. + */ + deltaAbsY: function () + { + return 0; + }, + + /** + * The change in this StaticBody's horizontal position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaX + * @since 3.0.0 + * + * @return {number} Always zero for a Static Body. + */ + deltaX: function () + { + return 0; + }, + + /** + * The change in this StaticBody's vertical position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaY + * @since 3.0.0 + * + * @return {number} 0 + */ + deltaY: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaZ + * @since 3.0.0 + * + * @return {number} 0 + */ + deltaZ: function () + { + return 0; + }, + + /** + * Disables this Body and marks it for destruction during the next step. + * + * @method Phaser.Physics.Arcade.StaticBody#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * Draws a graphical representation of the StaticBody for visual debugging purposes. + * + * @method Phaser.Physics.Arcade.StaticBody#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - The Graphics object to use for the debug drawing of the StaticBody. + */ + drawDebug: function (graphic) + { + var pos = this.position; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor, 1); + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + }, + + /** + * Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate. + * + * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} Whether or not the StaticBody is going to show the debug visualization during postUpdate. + */ + willDrawDebug: function () + { + return this.debugShowBody; + }, + + /** + * Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero. + * + * @method Phaser.Physics.Arcade.StaticBody#setMass + * @since 3.0.0 + * + * @param {number} value - The value to set the Mass to. Values of zero or less are changed to 0.1. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setMass: function (value) + { + if (value <= 0) + { + // Causes havoc otherwise + value = 0.1; + } + + this.mass = value; + + return this; + }, + + /** + * The x coordinate of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.x = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * The y coordinate of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.y = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * Returns the left-most x coordinate of the area of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#left + * @type {number} + * @readonly + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.position.x; + } + + }, + + /** + * The right-most x coordinate of the area of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#right + * @type {number} + * @readonly + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.position.x + this.width; + } + + }, + + /** + * The highest y coordinate of the area of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#top + * @type {number} + * @readonly + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.position.y; + } + + }, + + /** + * The lowest y coordinate of the area of the StaticBody. (y + height) + * + * @name Phaser.Physics.Arcade.StaticBody#bottom + * @type {number} + * @readonly + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.position.y + this.height; + } + + } + +}); + +module.exports = StaticBody; + + +/***/ }), +/* 226 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody + * @since 3.0.0 + * + * @param {{ left: number, right: number, top: number, bottom: number }} tileWorldRect - [description] + * @param {Phaser.Physics.Arcade.Body} body - [description] + * + * @return {boolean} [description] + */ +var TileIntersectsBody = function (tileWorldRect, body) +{ + // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this + // should support circle bodies when those are less buggy in v3. + + return !( + body.right <= tileWorldRect.left || + body.bottom <= tileWorldRect.top || + body.position.x >= tileWorldRect.right || + body.position.y >= tileWorldRect.bottom + ); +}; + +module.exports = TileIntersectsBody; + + +/***/ }), +/* 227 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var quickselect = __webpack_require__(313); + +/** + * @classdesc + * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. + * It's based on an optimized R-tree data structure with bulk insertion support. + * + * Spatial index is a special data structure for points and rectangles that allows you to perform queries like + * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). + * + * This version of RBush uses a fixed min/max accessor structure of `[ '.left', '.top', '.right', '.bottom' ]`. + * This is to avoid the eval like function creation that the original library used, which caused CSP policy violations. + * + * @class RTree + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + */ + +function rbush (maxEntries) +{ + var format = [ '.left', '.top', '.right', '.bottom' ]; + + if (!(this instanceof rbush)) return new rbush(maxEntries, format); + + // max entries in a node is 9 by default; min node fill is 40% for best performance + this._maxEntries = Math.max(4, maxEntries || 9); + this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); + + this.clear(); +} + +rbush.prototype = { + + all: function () + { + return this._all(this.data, []); + }, + + search: function (bbox) + { + var node = this.data, + result = [], + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return result; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf) result.push(child); + else if (contains(bbox, childBBox)) this._all(child, result); + else nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return result; + }, + + collides: function (bbox) + { + var node = this.data, + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return false; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf || contains(bbox, childBBox)) return true; + nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return false; + }, + + load: function (data) + { + if (!(data && data.length)) return this; + + if (data.length < this._minEntries) { + for (var i = 0, len = data.length; i < len; i++) { + this.insert(data[i]); + } + return this; + } + + // recursively build the tree with the given data from scratch using OMT algorithm + var node = this._build(data.slice(), 0, data.length - 1, 0); + + if (!this.data.children.length) { + // save as is if tree is empty + this.data = node; + + } else if (this.data.height === node.height) { + // split root if trees have the same height + this._splitRoot(this.data, node); + + } else { + if (this.data.height < node.height) { + // swap trees if inserted one is bigger + var tmpNode = this.data; + this.data = node; + node = tmpNode; + } + + // insert the small tree into the large tree at appropriate level + this._insert(node, this.data.height - node.height - 1, true); + } + + return this; + }, + + insert: function (item) + { + if (item) this._insert(item, this.data.height - 1); + return this; + }, + + clear: function () + { + this.data = createNode([]); + return this; + }, + + remove: function (item, equalsFn) + { + if (!item) return this; + + var node = this.data, + bbox = this.toBBox(item), + path = [], + indexes = [], + i, parent, index, goingUp; + + // depth-first iterative tree traversal + while (node || path.length) { + + if (!node) { // go up + node = path.pop(); + parent = path[path.length - 1]; + i = indexes.pop(); + goingUp = true; + } + + if (node.leaf) { // check current node + index = findItem(item, node.children, equalsFn); + + if (index !== -1) { + // item found, remove the item and condense tree upwards + node.children.splice(index, 1); + path.push(node); + this._condense(path); + return this; + } + } + + if (!goingUp && !node.leaf && contains(node, bbox)) { // go down + path.push(node); + indexes.push(i); + i = 0; + parent = node; + node = node.children[0]; + + } else if (parent) { // go right + i++; + node = parent.children[i]; + goingUp = false; + + } else node = null; // nothing found + } + + return this; + }, + + toBBox: function (item) { return item; }, + + compareMinX: compareNodeMinX, + compareMinY: compareNodeMinY, + + toJSON: function () { return this.data; }, + + fromJSON: function (data) + { + this.data = data; + return this; + }, + + _all: function (node, result) + { + var nodesToSearch = []; + while (node) { + if (node.leaf) result.push.apply(result, node.children); + else nodesToSearch.push.apply(nodesToSearch, node.children); + + node = nodesToSearch.pop(); + } + return result; + }, + + _build: function (items, left, right, height) + { + var N = right - left + 1, + M = this._maxEntries, + node; + + if (N <= M) { + // reached leaf level; return leaf + node = createNode(items.slice(left, right + 1)); + calcBBox(node, this.toBBox); + return node; + } + + if (!height) { + // target height of the bulk-loaded tree + height = Math.ceil(Math.log(N) / Math.log(M)); + + // target number of root entries to maximize storage utilization + M = Math.ceil(N / Math.pow(M, height - 1)); + } + + node = createNode([]); + node.leaf = false; + node.height = height; + + // split the items into M mostly square tiles + + var N2 = Math.ceil(N / M), + N1 = N2 * Math.ceil(Math.sqrt(M)), + i, j, right2, right3; + + multiSelect(items, left, right, N1, this.compareMinX); + + for (i = left; i <= right; i += N1) { + + right2 = Math.min(i + N1 - 1, right); + + multiSelect(items, i, right2, N2, this.compareMinY); + + for (j = i; j <= right2; j += N2) { + + right3 = Math.min(j + N2 - 1, right2); + + // pack each entry recursively + node.children.push(this._build(items, j, right3, height - 1)); + } + } + + calcBBox(node, this.toBBox); + + return node; + }, + + _chooseSubtree: function (bbox, node, level, path) + { + var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; + + while (true) { + path.push(node); + + if (node.leaf || path.length - 1 === level) break; + + minArea = minEnlargement = Infinity; + + for (i = 0, len = node.children.length; i < len; i++) { + child = node.children[i]; + area = bboxArea(child); + enlargement = enlargedArea(bbox, child) - area; + + // choose entry with the least area enlargement + if (enlargement < minEnlargement) { + minEnlargement = enlargement; + minArea = area < minArea ? area : minArea; + targetNode = child; + + } else if (enlargement === minEnlargement) { + // otherwise choose one with the smallest area + if (area < minArea) { + minArea = area; + targetNode = child; + } + } + } + + node = targetNode || node.children[0]; + } + + return node; + }, + + _insert: function (item, level, isNode) + { + var toBBox = this.toBBox, + bbox = isNode ? item : toBBox(item), + insertPath = []; + + // find the best node for accommodating the item, saving all nodes along the path too + var node = this._chooseSubtree(bbox, this.data, level, insertPath); + + // put the item into the node + node.children.push(item); + extend(node, bbox); + + // split on node overflow; propagate upwards if necessary + while (level >= 0) { + if (insertPath[level].children.length > this._maxEntries) { + this._split(insertPath, level); + level--; + } else break; + } + + // adjust bboxes along the insertion path + this._adjustParentBBoxes(bbox, insertPath, level); + }, + + // split overflowed node into two + _split: function (insertPath, level) + { + var node = insertPath[level], + M = node.children.length, + m = this._minEntries; + + this._chooseSplitAxis(node, m, M); + + var splitIndex = this._chooseSplitIndex(node, m, M); + + var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); + newNode.height = node.height; + newNode.leaf = node.leaf; + + calcBBox(node, this.toBBox); + calcBBox(newNode, this.toBBox); + + if (level) insertPath[level - 1].children.push(newNode); + else this._splitRoot(node, newNode); + }, + + _splitRoot: function (node, newNode) + { + // split root node + this.data = createNode([node, newNode]); + this.data.height = node.height + 1; + this.data.leaf = false; + calcBBox(this.data, this.toBBox); + }, + + _chooseSplitIndex: function (node, m, M) + { + var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; + + minOverlap = minArea = Infinity; + + for (i = m; i <= M - m; i++) { + bbox1 = distBBox(node, 0, i, this.toBBox); + bbox2 = distBBox(node, i, M, this.toBBox); + + overlap = intersectionArea(bbox1, bbox2); + area = bboxArea(bbox1) + bboxArea(bbox2); + + // choose distribution with minimum overlap + if (overlap < minOverlap) { + minOverlap = overlap; + index = i; + + minArea = area < minArea ? area : minArea; + + } else if (overlap === minOverlap) { + // otherwise choose distribution with minimum area + if (area < minArea) { + minArea = area; + index = i; + } + } + } + + return index; + }, + + // sorts node children by the best axis for split + _chooseSplitAxis: function (node, m, M) + { + var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, + compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, + xMargin = this._allDistMargin(node, m, M, compareMinX), + yMargin = this._allDistMargin(node, m, M, compareMinY); + + // if total distributions margin value is minimal for x, sort by minX, + // otherwise it's already sorted by minY + if (xMargin < yMargin) node.children.sort(compareMinX); + }, + + // total margin of all possible split distributions where each node is at least m full + _allDistMargin: function (node, m, M, compare) + { + node.children.sort(compare); + + var toBBox = this.toBBox, + leftBBox = distBBox(node, 0, m, toBBox), + rightBBox = distBBox(node, M - m, M, toBBox), + margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), + i, child; + + for (i = m; i < M - m; i++) { + child = node.children[i]; + extend(leftBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(leftBBox); + } + + for (i = M - m - 1; i >= m; i--) { + child = node.children[i]; + extend(rightBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(rightBBox); + } + + return margin; + }, + + _adjustParentBBoxes: function (bbox, path, level) + { + // adjust bboxes along the given tree path + for (var i = level; i >= 0; i--) { + extend(path[i], bbox); + } + }, + + _condense: function (path) + { + // go through the path, removing empty nodes and updating bboxes + for (var i = path.length - 1, siblings; i >= 0; i--) { + if (path[i].children.length === 0) { + if (i > 0) { + siblings = path[i - 1].children; + siblings.splice(siblings.indexOf(path[i]), 1); + + } else this.clear(); + + } else calcBBox(path[i], this.toBBox); + } + }, + + compareMinX: function (a, b) + { + return a.left - b.left; + }, + + compareMinY: function (a, b) + { + return a.top - b.top; + }, + + toBBox: function (a) + { + return { + minX: a.left, + minY: a.top, + maxX: a.right, + maxY: a.bottom + }; + } +}; + +function findItem (item, items, equalsFn) +{ + if (!equalsFn) return items.indexOf(item); + + for (var i = 0; i < items.length; i++) { + if (equalsFn(item, items[i])) return i; + } + return -1; +} + +// calculate node's bbox from bboxes of its children +function calcBBox (node, toBBox) +{ + distBBox(node, 0, node.children.length, toBBox, node); +} + +// min bounding rectangle of node children from k to p-1 +function distBBox (node, k, p, toBBox, destNode) +{ + if (!destNode) destNode = createNode(null); + destNode.minX = Infinity; + destNode.minY = Infinity; + destNode.maxX = -Infinity; + destNode.maxY = -Infinity; + + for (var i = k, child; i < p; i++) { + child = node.children[i]; + extend(destNode, node.leaf ? toBBox(child) : child); + } + + return destNode; +} + +function extend (a, b) +{ + a.minX = Math.min(a.minX, b.minX); + a.minY = Math.min(a.minY, b.minY); + a.maxX = Math.max(a.maxX, b.maxX); + a.maxY = Math.max(a.maxY, b.maxY); + return a; +} + +function compareNodeMinX (a, b) { return a.minX - b.minX; } +function compareNodeMinY (a, b) { return a.minY - b.minY; } + +function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } +function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } + +function enlargedArea (a, b) +{ + return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * + (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); +} + +function intersectionArea (a, b) +{ + var minX = Math.max(a.minX, b.minX), + minY = Math.max(a.minY, b.minY), + maxX = Math.min(a.maxX, b.maxX), + maxY = Math.min(a.maxY, b.maxY); + + return Math.max(0, maxX - minX) * + Math.max(0, maxY - minY); +} + +function contains (a, b) +{ + return a.minX <= b.minX && + a.minY <= b.minY && + b.maxX <= a.maxX && + b.maxY <= a.maxY; +} + +function intersects (a, b) +{ + return b.minX <= a.maxX && + b.minY <= a.maxY && + b.maxX >= a.minX && + b.maxY >= a.minY; +} + +function createNode (children) +{ + return { + children: children, + height: 1, + leaf: true, + minX: Infinity, + minY: Infinity, + maxX: -Infinity, + maxY: -Infinity + }; +} + +// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; +// combines selection algorithm with binary divide & conquer approach + +function multiSelect (arr, left, right, n, compare) +{ + var stack = [left, right], + mid; + + while (stack.length) + { + right = stack.pop(); + left = stack.pop(); + + if (right - left <= n) continue; + + mid = left + Math.ceil((right - left) / n / 2) * n; + quickselect(arr, mid, left, right, compare); + + stack.push(left, mid, mid, right); + } +} + +module.exports = rbush; + +/***/ }), +/* 228 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -35019,9 +51328,9247 @@ module.exports = BasePlugin; */ var Class = __webpack_require__(0); -var File = __webpack_require__(19); -var GetFastValue = __webpack_require__(1); -var GetURL = __webpack_require__(108); + +/** + * @classdesc + * [description] + * + * @class ProcessQueue + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + */ +var ProcessQueue = new Class({ + + initialize: + + function ProcessQueue () + { + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.ProcessQueue#_pending + * @type {Array.<*>} + * @private + * @default [] + * @since 3.0.0 + */ + this._pending = []; + + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.ProcessQueue#_active + * @type {Array.<*>} + * @private + * @default [] + * @since 3.0.0 + */ + this._active = []; + + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.ProcessQueue#_destroy + * @type {Array.<*>} + * @private + * @default [] + * @since 3.0.0 + */ + this._destroy = []; + + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_toProcess + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#add + * @since 3.0.0 + * + * @genericUse {T} - [item] + * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + add: function (item) + { + this._pending.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#remove + * @since 3.0.0 + * + * @genericUse {T} - [item] + * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + remove: function (item) + { + this._destroy.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#update + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} [description] + */ + update: function () + { + if (this._toProcess === 0) + { + // Quick bail + return this._active; + } + + var list = this._destroy; + var active = this._active; + var i; + var item; + + // Clear the 'destroy' list + for (i = 0; i < list.length; i++) + { + item = list[i]; + + // Remove from the 'active' array + var idx = active.indexOf(item); + + if (idx !== -1) + { + active.splice(idx, 1); + } + } + + list.length = 0; + + // Process the pending addition list + // This stops callbacks and out of sync events from populating the active array mid-way during an update + + list = this._pending; + + for (i = 0; i < list.length; i++) + { + item = list[i]; + + this._active.push(item); + } + + list.length = 0; + + this._toProcess = 0; + + // The owner of this queue can now safely do whatever it needs to with the active list + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#getActive + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} [description] + */ + getActive: function () + { + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#destroy + * @since 3.0.0 + */ + destroy: function () + { + this._pending = []; + this._active = []; + this._destroy = []; + } + +}); + +module.exports = ProcessQueue; + + +/***/ }), +/* 229 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(35); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.GetOverlapY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {number} [description] + */ +var GetOverlapY = function (body1, body2, overlapOnly, bias) +{ + var overlap = 0; + var maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + bias; + + if (body1._dy === 0 && body2._dy === 0) + { + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1._dy > body2._dy) + { + // Body1 is moving down and/or Body2 is moving up + overlap = body1.bottom - body2.y; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.down === false || body2.checkCollision.up === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.down = true; + + body2.touching.none = false; + body2.touching.up = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.down = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.up = true; + } + } + } + else if (body1._dy < body2._dy) + { + // Body1 is moving up and/or Body2 is moving down + overlap = body1.y - body2.bottom; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.up === false || body2.checkCollision.down === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.up = true; + + body2.touching.none = false; + body2.touching.down = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.up = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.down = true; + } + } + } + + // Resets the overlapY to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapY = overlap; + body2.overlapY = overlap; + + return overlap; +}; + +module.exports = GetOverlapY; + + +/***/ }), +/* 230 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(35); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.GetOverlapX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {number} [description] + */ +var GetOverlapX = function (body1, body2, overlapOnly, bias) +{ + var overlap = 0; + var maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + bias; + + if (body1._dx === 0 && body2._dx === 0) + { + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1._dx > body2._dx) + { + // Body1 is moving right and / or Body2 is moving left + overlap = body1.right - body2.x; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.right === false || body2.checkCollision.left === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.right = true; + + body2.touching.none = false; + body2.touching.left = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.right = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.left = true; + } + } + } + else if (body1._dx < body2._dx) + { + // Body1 is moving left and/or Body2 is moving right + overlap = body1.x - body2.width - body2.x; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.left === false || body2.checkCollision.right === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.left = true; + + body2.touching.none = false; + body2.touching.right = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.left = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.right = true; + } + } + } + + // Resets the overlapX to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapX = overlap; + body2.overlapX = overlap; + + return overlap; +}; + +module.exports = GetOverlapX; + + +/***/ }), +/* 231 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class Collider + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {boolean} overlapOnly - [description] + * @param {ArcadeColliderType} object1 - The first object to check for collision. + * @param {ArcadeColliderType} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {any} callbackContext - The scope in which to call the callbacks. + */ +var Collider = new Class({ + + initialize: + + function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) + { + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#name + * @type {string} + * @since 3.1.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#overlapOnly + * @type {boolean} + * @since 3.0.0 + */ + this.overlapOnly = overlapOnly; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object1 + * @type {ArcadeColliderType} + * @since 3.0.0 + */ + this.object1 = object1; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object2 + * @type {ArcadeColliderType} + * @since 3.0.0 + */ + this.object2 = object2; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#collideCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.collideCallback = collideCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#processCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.processCallback = processCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#callbackContext + * @type {object} + * @since 3.0.0 + */ + this.callbackContext = callbackContext; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#setName + * @since 3.1.0 + * + * @param {string} name - [description] + * + * @return {Phaser.Physics.Arcade.Collider} [description] + */ + setName: function (name) + { + this.name = name; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#update + * @since 3.0.0 + */ + update: function () + { + this.world.collideObjects( + this.object1, + this.object2, + this.collideCallback, + this.processCallback, + this.callbackContext, + this.overlapOnly + ); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.removeCollider(this); + + this.active = false; + + this.world = null; + + this.object1 = null; + this.object2 = null; + + this.collideCallback = null; + this.processCallback = null; + this.callbackContext = null; + } + +}); + +module.exports = Collider; + + +/***/ }), +/* 232 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircleContains = __webpack_require__(40); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var RadToDeg = __webpack_require__(172); +var Rectangle = __webpack_require__(9); +var RectangleContains = __webpack_require__(39); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} ArcadeBodyBounds + * + * @property {number} x - The left edge. + * @property {number} y - The upper edge. + * @property {number} right - The right edge. + * @property {number} bottom - The lower edge. + */ + +/** + * @typedef {object} ArcadeBodyCollision + * + * @property {boolean} none - True if the Body is not colliding. + * @property {boolean} up - True if the Body is colliding on its upper edge. + * @property {boolean} down - True if the Body is colliding on its lower edge. + * @property {boolean} left - True if the Body is colliding on its left edge. + * @property {boolean} right - True if the Body is colliding on its right edge. + */ + +/** + * @classdesc + * A Dynamic Arcade Body. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticBody}. + * + * @class Body + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics simulation this Body belongs to. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object this Body belongs to. + */ +var Body = new Class({ + + initialize: + + function Body (world, gameObject) + { + var width = (gameObject.width) ? gameObject.width : 64; + var height = (gameObject.height) ? gameObject.height : 64; + + /** + * The Arcade Physics simulation this Body belongs to. + * + * @name Phaser.Physics.Arcade.Body#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * The Game Object this Body belongs to. + * + * @name Phaser.Physics.Arcade.Body#gameObject + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.gameObject = gameObject; + + /** + * Transformations applied to this Body. + * + * @name Phaser.Physics.Arcade.Body#transform + * @type {object} + * @since 3.4.0 + */ + this.transform = { + x: gameObject.x, + y: gameObject.y, + rotation: gameObject.angle, + scaleX: gameObject.scaleX, + scaleY: gameObject.scaleY, + displayOriginX: gameObject.displayOriginX, + displayOriginY: gameObject.displayOriginY + }; + + /** + * Whether the Body's boundary is drawn to the debug display. + * + * @name Phaser.Physics.Arcade.Body#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowBody; + + /** + * Whether the Body's velocity is drawn to the debug display. + * + * @name Phaser.Physics.Arcade.Body#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowVelocity = world.defaults.debugShowVelocity; + + /** + * The color of this Body on the debug display. + * + * @name Phaser.Physics.Arcade.Body#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.bodyDebugColor; + + /** + * Whether this Body is updated by the physics simulation. + * + * @name Phaser.Physics.Arcade.Body#enable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enable = true; + + /** + * Whether this Body's boundary is circular (true) or rectangular (false). + * + * @name Phaser.Physics.Arcade.Body#isCircle + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setCircle + */ + this.isCircle = false; + + /** + * If this Body is circular, this is the unscaled radius of the Body's boundary, as set by setCircle(), in source pixels. + * The true radius is equal to `halfWidth`. + * + * @name Phaser.Physics.Arcade.Body#radius + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setCircle + */ + this.radius = 0; + + /** + * The offset of this Body's position from its Game Object's position, in source pixels. + * + * @name Phaser.Physics.Arcade.Body#offset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setOffset + */ + this.offset = new Vector2(); + + /** + * The position of this Body within the simulation. + * + * @name Phaser.Physics.Arcade.Body#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x, gameObject.y); + + /** + * The position of this Body during the previous step. + * + * @name Phaser.Physics.Arcade.Body#prev + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.prev = new Vector2(gameObject.x, gameObject.y); + + /** + * Whether this Body's `rotation` is affected by its angular acceleration and angular velocity. + * + * @name Phaser.Physics.Arcade.Body#allowRotation + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowRotation = true; + + /** + * This body's rotation, in degrees, based on its angular acceleration and angular velocity. + * The Body's rotation controls the `angle` of its Game Object. + * It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle. + * + * @name Phaser.Physics.Arcade.Body#rotation + * @type {number} + * @since 3.0.0 + */ + this.rotation = gameObject.angle; + + /** + * The Body's rotation, in degrees, during the previous step. + * + * @name Phaser.Physics.Arcade.Body#preRotation + * @type {number} + * @since 3.0.0 + */ + this.preRotation = gameObject.angle; + + /** + * The width of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. + * + * @name Phaser.Physics.Arcade.Body#width + * @type {number} + * @default 64 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. + * + * @name Phaser.Physics.Arcade.Body#height + * @type {number} + * @default 64 + * @since 3.0.0 + */ + this.height = height; + + /** + * The unscaled width of the Body, in source pixels, as set by setSize(). + * The default is the width of the Body's Game Object's texture frame. + * + * @name Phaser.Physics.Arcade.Body#sourceWidth + * @type {number} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setSize + */ + this.sourceWidth = width; + + /** + * The unscaled height of the Body, in source pixels, as set by setSize(). + * The default is the height of the Body's Game Object's texture frame. + * + * @name Phaser.Physics.Arcade.Body#sourceHeight + * @type {number} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setSize + */ + this.sourceHeight = height; + + if (gameObject.frame) + { + this.sourceWidth = gameObject.frame.realWidth; + this.sourceHeight = gameObject.frame.realHeight; + } + + /** + * Half the Body's width, in pixels. + * + * @name Phaser.Physics.Arcade.Body#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(width / 2); + + /** + * Half the Body's height, in pixels. + * + * @name Phaser.Physics.Arcade.Body#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(height / 2); + + /** + * The center of the Body's boundary. + * The midpoint of its `position` (top-left corner) and its bottom-right corner. + * + * @name Phaser.Physics.Arcade.Body#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * The Body's velocity, in pixels per second. + * + * @name Phaser.Physics.Arcade.Body#velocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.velocity = new Vector2(); + + /** + * The Body's calculated velocity, in pixels per second, at the last step. + * + * @name Phaser.Physics.Arcade.Body#newVelocity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.newVelocity = new Vector2(); + + /** + * The Body's absolute maximum change in position, in pixels per step. + * + * @name Phaser.Physics.Arcade.Body#deltaMax + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.deltaMax = new Vector2(); + + /** + * The Body's change in velocity, in pixels per second squared. + * + * @name Phaser.Physics.Arcade.Body#acceleration + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.acceleration = new Vector2(); + + /** + * Whether this Body's velocity is affected by its `drag`. + * + * @name Phaser.Physics.Arcade.Body#allowDrag + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowDrag = true; + + /** + * Absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * + * @name Phaser.Physics.Arcade.Body#drag + * @type {(Phaser.Math.Vector2|number)} + * @since 3.0.0 + */ + this.drag = new Vector2(); + + /** + * Whether this Body's position is affected by gravity (local or world). + * + * @name Phaser.Physics.Arcade.Body#allowGravity + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#gravity + * @see Phaser.Physics.Arcade.World#gravity + */ + this.allowGravity = true; + + /** + * Acceleration due to gravity (specific to this Body), in pixels per second squared. + * Total gravity is the sum of this vector and the simulation's `gravity`. + * + * @name Phaser.Physics.Arcade.Body#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#gravity + */ + this.gravity = new Vector2(); + + /** + * Rebound following a collision, relative to 1. + * + * @name Phaser.Physics.Arcade.Body#bounce + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.bounce = new Vector2(); + + /** + * Rebound following a collision with the world boundary, relative to 1. + * If null, `bounce` is used instead. + * + * @name Phaser.Physics.Arcade.Body#worldBounce + * @type {?Phaser.Math.Vector2} + * @default null + * @since 3.0.0 + */ + this.worldBounce = null; + + // If true this Body will dispatch events + + /** + * Whether the simulation emits a `worldbounds` event when this Body collides with the world boundary (and `collideWorldBounds` is also true). + * + * @name Phaser.Physics.Arcade.Body#onWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#event:worldbounds + */ + this.onWorldBounds = false; + + /** + * Whether the simulation emits a `collide` event when this Body collides with another. + * + * @name Phaser.Physics.Arcade.Body#onCollide + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#event:collide + */ + this.onCollide = false; + + /** + * Whether the simulation emits an `overlap` event when this Body overlaps with another. + * + * @name Phaser.Physics.Arcade.Body#onOverlap + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#event:overlap + */ + this.onOverlap = false; + + /** + * The Body's absolute maximum velocity, in pixels per second. + * The horizontal and vertical components are applied separately. + * + * @name Phaser.Physics.Arcade.Body#maxVelocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.maxVelocity = new Vector2(10000, 10000); + + /** + * If this Body is `immovable` and in motion, `friction` is the proportion of this Body's motion received by the riding Body on each axis, relative to 1. + * The default value (1, 0) moves the riding Body horizontally in equal proportion to this Body and vertically not at all. + * The horizontal component (x) is applied only when two colliding Bodies are separated vertically. + * The vertical component (y) is applied only when two colliding Bodies are separated horizontally. + * + * @name Phaser.Physics.Arcade.Body#friction + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.friction = new Vector2(1, 0); + + /** + * If this Body is using `drag` for deceleration this property controls how the drag is applied. + * If set to `true` drag will use a damping effect rather than a linear approach. If you are + * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in + * the game Asteroids) then you will get a far smoother and more visually correct deceleration + * by using damping, avoiding the axis-drift that is prone with linear deceleration. + * + * If you enable this property then you should use far smaller `drag` values than with linear, as + * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow + * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. + * + * @name Phaser.Physics.Arcade.Body#useDamping + * @type {boolean} + * @default false + * @since 3.10.0 + */ + this.useDamping = false; + + /** + * The rate of change of this Body's `rotation`, in degrees per second. + * + * @name Phaser.Physics.Arcade.Body#angularVelocity + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularVelocity = 0; + + /** + * The Body's angular acceleration (change in angular velocity), in degrees per second squared. + * + * @name Phaser.Physics.Arcade.Body#angularAcceleration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularAcceleration = 0; + + /** + * Loss of angular velocity due to angular movement, in degrees per second. + * + * Angular drag is applied only when angular acceleration is zero. + * + * @name Phaser.Physics.Arcade.Body#angularDrag + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularDrag = 0; + + /** + * The Body's maximum angular velocity, in degrees per second. + * + * @name Phaser.Physics.Arcade.Body#maxAngular + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.maxAngular = 1000; + + /** + * The Body's inertia, relative to a default unit (1). + * With `bounce`, this affects the exchange of momentum (velocities) during collisions. + * + * @name Phaser.Physics.Arcade.Body#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * The calculated angle of this Body's velocity vector, in degrees, during the last step. + * + * @name Phaser.Physics.Arcade.Body#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angle = 0; + + /** + * The calculated magnitude of the Body's velocity, in pixels per second, during the last step. + * + * @name Phaser.Physics.Arcade.Body#speed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speed = 0; + + /** + * The direction of the Body's velocity, as calculated during the last step. + * If the Body is moving on both axes (diagonally), this describes motion on the vertical axis only. + * + * @name Phaser.Physics.Arcade.Body#facing + * @type {integer} + * @since 3.0.0 + */ + this.facing = CONST.FACING_NONE; + + /** + * Whether this Body can be moved by collisions with another Body. + * + * @name Phaser.Physics.Arcade.Body#immovable + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.immovable = false; + + /** + * Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity. + * + * @name Phaser.Physics.Arcade.Body#moves + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.moves = true; + + /** + * A flag disabling the default horizontal separation of colliding bodies. + * Pass your own `collideCallback` to the collider. + * + * @name Phaser.Physics.Arcade.Body#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * A flag disabling the default vertical separation of colliding bodies. + * Pass your own `collideCallback` to the collider. + * + * @name Phaser.Physics.Arcade.Body#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * The amount of horizontal overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.Body#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * The amount of vertical overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.Body#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * The amount of overlap (before separation), if this Body is circular and colliding with another circular body. + * + * @name Phaser.Physics.Arcade.Body#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * Whether this Body is overlapped with another and both have zero velocity. + * + * @name Phaser.Physics.Arcade.Body#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * Whether this Body interacts with the world boundary. + * + * @name Phaser.Physics.Arcade.Body#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * Whether this Body is checked for collisions and for which directions. + * You can set `checkCollision.none = false` to disable collision checks. + * + * @name Phaser.Physics.Arcade.Body#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * Whether this Body is colliding with another and in which direction. + * + * @name Phaser.Physics.Arcade.Body#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this Body was colliding with another during the last step, and in which direction. + * + * @name Phaser.Physics.Arcade.Body#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this Body is colliding with a tile or the world boundary. + * + * @name Phaser.Physics.Arcade.Body#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether to automatically synchronize this Body's dimensions to the dimensions of its Game Object's visual bounds. + * + * @name Phaser.Physics.Arcade.Body#syncBounds + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.GameObjects.Components.GetBounds#getBounds + */ + this.syncBounds = false; + + /** + * Whether this Body is being moved by the `moveTo` or `moveFrom` methods. + * + * @name Phaser.Physics.Arcade.Body#isMoving + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isMoving = false; + + /** + * Whether this Body's movement by `moveTo` or `moveFrom` will be stopped by collisions with other bodies. + * + * @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.stopVelocityOnCollide = true; + + // read-only + + /** + * The Body's physics type (dynamic or static). + * + * @name Phaser.Physics.Arcade.Body#physicsType + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.physicsType = CONST.DYNAMIC_BODY; + + /** + * Whether the Body's position needs updating from its Game Object. + * + * @name Phaser.Physics.Arcade.Body#_reset + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + this._reset = true; + + /** + * Cached horizontal scale of the Body's Game Object. + * + * @name Phaser.Physics.Arcade.Body#_sx + * @type {number} + * @private + * @since 3.0.0 + */ + this._sx = gameObject.scaleX; + + /** + * Cached vertical scale of the Body's Game Object. + * + * @name Phaser.Physics.Arcade.Body#_sy + * @type {number} + * @private + * @since 3.0.0 + */ + this._sy = gameObject.scaleY; + + /** + * The calculated change in the Body's horizontal position during the last step. + * + * @name Phaser.Physics.Arcade.Body#_dx + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._dx = 0; + + /** + * The calculated change in the Body's vertical position during the last step. + * + * @name Phaser.Physics.Arcade.Body#_dy + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._dy = 0; + + /** + * Stores the Game Object's bounds. + * + * @name Phaser.Physics.Arcade.Body#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + }, + + /** + * Updates this Body's transform, dimensions, and position from its Game Object. + * + * @method Phaser.Physics.Arcade.Body#updateBounds + * @since 3.0.0 + */ + updateBounds: function () + { + var sprite = this.gameObject; + + // Container? + + var transform = this.transform; + + if (sprite.parentContainer) + { + var matrix = sprite.getWorldTransformMatrix(this.world._tempMatrix, this.world._tempMatrix2); + + transform.x = matrix.tx; + transform.y = matrix.ty; + transform.rotation = RadToDeg(matrix.rotation); + transform.scaleX = matrix.scaleX; + transform.scaleY = matrix.scaleY; + transform.displayOriginX = sprite.displayOriginX; + transform.displayOriginY = sprite.displayOriginY; + } + else + { + transform.x = sprite.x; + transform.y = sprite.y; + transform.rotation = sprite.angle; + transform.scaleX = sprite.scaleX; + transform.scaleY = sprite.scaleY; + transform.displayOriginX = sprite.displayOriginX; + transform.displayOriginY = sprite.displayOriginY; + } + + var recalc = false; + + if (this.syncBounds) + { + var b = sprite.getBounds(this._bounds); + + this.width = b.width; + this.height = b.height; + recalc = true; + } + else + { + var asx = Math.abs(transform.scaleX); + var asy = Math.abs(transform.scaleY); + + if (this._sx !== asx || this._sy !== asy) + { + this.width = this.sourceWidth * asx; + this.height = this.sourceHeight * asy; + this._sx = asx; + this._sy = asy; + recalc = true; + } + } + + if (recalc) + { + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + this.updateCenter(); + } + }, + + /** + * Updates the Body's `center` from its `position`, `width`, and `height`. + * + * @method Phaser.Physics.Arcade.Body#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * Updates the Body. + * + * @method Phaser.Physics.Arcade.Body#update + * @fires Phaser.Physics.Arcade.World#worldbounds + * @since 3.0.0 + * + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (delta) + { + // Store and reset collision flags + this.wasTouching.none = this.touching.none; + this.wasTouching.up = this.touching.up; + this.wasTouching.down = this.touching.down; + this.wasTouching.left = this.touching.left; + this.wasTouching.right = this.touching.right; + + this.touching.none = true; + this.touching.up = false; + this.touching.down = false; + this.touching.left = false; + this.touching.right = false; + + this.blocked.none = true; + this.blocked.up = false; + this.blocked.down = false; + this.blocked.left = false; + this.blocked.right = false; + + this.overlapR = 0; + this.overlapX = 0; + this.overlapY = 0; + + this.embedded = false; + + // Updates the transform values + this.updateBounds(); + + var sprite = this.transform; + + this.position.x = sprite.x + sprite.scaleX * (this.offset.x - sprite.displayOriginX); + this.position.y = sprite.y + sprite.scaleY * (this.offset.y - sprite.displayOriginY); + + this.updateCenter(); + + this.rotation = sprite.rotation; + + this.preRotation = this.rotation; + + if (this._reset) + { + this.prev.x = this.position.x; + this.prev.y = this.position.y; + } + + if (this.moves) + { + this.world.updateMotion(this, delta); + + var vx = this.velocity.x; + var vy = this.velocity.y; + + this.newVelocity.set(vx * delta, vy * delta); + + this.position.add(this.newVelocity); + + this.updateCenter(); + + this.angle = Math.atan2(vy, vx); + this.speed = Math.sqrt(vx * vx + vy * vy); + + // Now the State update will throw collision checks at the Body + // And finally we'll integrate the new position back to the Sprite in postUpdate + + if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) + { + this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); + } + } + + this._dx = this.position.x - this.prev.x; + this._dy = this.position.y - this.prev.y; + }, + + /** + * Feeds the Body results back into the parent Game Object. + * + * @method Phaser.Physics.Arcade.Body#postUpdate + * @since 3.0.0 + * + * @param {boolean} resetDelta - Reset the delta properties? + */ + postUpdate: function () + { + this._dx = this.position.x - this.prev.x; + this._dy = this.position.y - this.prev.y; + + if (this.moves) + { + if (this.deltaMax.x !== 0 && this._dx !== 0) + { + if (this._dx < 0 && this._dx < -this.deltaMax.x) + { + this._dx = -this.deltaMax.x; + } + else if (this._dx > 0 && this._dx > this.deltaMax.x) + { + this._dx = this.deltaMax.x; + } + } + + if (this.deltaMax.y !== 0 && this._dy !== 0) + { + if (this._dy < 0 && this._dy < -this.deltaMax.y) + { + this._dy = -this.deltaMax.y; + } + else if (this._dy > 0 && this._dy > this.deltaMax.y) + { + this._dy = this.deltaMax.y; + } + } + + this.gameObject.x += this._dx; + this.gameObject.y += this._dy; + + this._reset = true; + } + + if (this._dx < 0) + { + this.facing = CONST.FACING_LEFT; + } + else if (this._dx > 0) + { + this.facing = CONST.FACING_RIGHT; + } + + if (this._dy < 0) + { + this.facing = CONST.FACING_UP; + } + else if (this._dy > 0) + { + this.facing = CONST.FACING_DOWN; + } + + if (this.allowRotation) + { + this.gameObject.angle += this.deltaZ(); + } + + this.prev.x = this.position.x; + this.prev.y = this.position.y; + }, + + /** + * Checks for collisions between this Body and the world boundary and separates them. + * + * @method Phaser.Physics.Arcade.Body#checkWorldBounds + * @since 3.0.0 + * + * @return {boolean} True if this Body is colliding with the world boundary. + */ + checkWorldBounds: function () + { + var pos = this.position; + var bounds = this.world.bounds; + var check = this.world.checkCollision; + + var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x; + var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y; + + if (pos.x < bounds.x && check.left) + { + pos.x = bounds.x; + this.velocity.x *= bx; + this.blocked.left = true; + this.blocked.none = false; + } + else if (this.right > bounds.right && check.right) + { + pos.x = bounds.right - this.width; + this.velocity.x *= bx; + this.blocked.right = true; + this.blocked.none = false; + } + + if (pos.y < bounds.y && check.up) + { + pos.y = bounds.y; + this.velocity.y *= by; + this.blocked.up = true; + this.blocked.none = false; + } + else if (this.bottom > bounds.bottom && check.down) + { + pos.y = bounds.bottom - this.height; + this.velocity.y *= by; + this.blocked.down = true; + this.blocked.none = false; + } + + return !this.blocked.none; + }, + + /** + * Sets the offset of the Body's position from its Game Object's position. + * + * @method Phaser.Physics.Arcade.Body#setOffset + * @since 3.0.0 + * + * @param {number} x - The horizontal offset, in source pixels. + * @param {number} [y=x] - The vertical offset, in source pixels. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setOffset: function (x, y) + { + if (y === undefined) { y = x; } + + this.offset.set(x, y); + + return this; + }, + + /** + * Sizes and positions this Body's boundary, as a rectangle. + * Modifies the Body `offset` if `center` is true (the default). + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * + * @method Phaser.Physics.Arcade.Body#setSize + * @since 3.0.0 + * + * @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param {boolean} [center=true] - Modify the Body's `offset`, placing the Body's center on its Game Object's center. Only works if the Game Object has the `getCenter` method. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setSize: function (width, height, center) + { + if (center === undefined) { center = true; } + + var gameObject = this.gameObject; + + if (!width && gameObject.frame) + { + width = gameObject.frame.realWidth; + } + + if (!height && gameObject.frame) + { + height = gameObject.frame.realHeight; + } + + this.sourceWidth = width; + this.sourceHeight = height; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.updateCenter(); + + if (center && gameObject.getCenter) + { + var ox = gameObject.displayWidth / 2; + var oy = gameObject.displayHeight / 2; + + this.offset.set(ox - this.halfWidth, oy - this.halfHeight); + } + + this.isCircle = false; + this.radius = 0; + + return this; + }, + + /** + * Sizes and positions this Body's boundary, as a circle. + * + * @method Phaser.Physics.Arcade.Body#setCircle + * @since 3.0.0 + * + * @param {number} radius - The radius of the Body, in source pixels. + * @param {number} [offsetX] - The horizontal offset of the Body from its Game Object, in source pixels. + * @param {number} [offsetY] - The vertical offset of the Body from its Game Object, in source pixels. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.isCircle = true; + this.radius = radius; + + this.sourceWidth = radius * 2; + this.sourceHeight = radius * 2; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * If the Body had any velocity or acceleration it is lost as a result of calling this. + * + * @method Phaser.Physics.Arcade.Body#reset + * @since 3.0.0 + * + * @param {number} x - The horizontal position to place the Game Object and Body. + * @param {number} y - The vertical position to place the Game Object and Body. + */ + reset: function (x, y) + { + this.stop(); + + var gameObject = this.gameObject; + + gameObject.setPosition(x, y); + + gameObject.getTopLeft(this.position); + + this.prev.copy(this.position); + + this.rotation = gameObject.angle; + this.preRotation = gameObject.angle; + + this.updateBounds(); + this.updateCenter(); + }, + + /** + * Sets acceleration, velocity, and speed to zero. + * + * @method Phaser.Physics.Arcade.Body#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + stop: function () + { + this.velocity.set(0); + this.acceleration.set(0); + this.speed = 0; + this.angularVelocity = 0; + this.angularAcceleration = 0; + + return this; + }, + + /** + * Copies the coordinates of this Body's edges into an object. + * + * @method Phaser.Physics.Arcade.Body#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - An object to copy the values into. + * + * @return {ArcadeBodyBounds} - An object with {x, y, right, bottom}. + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * Tests if the coordinates are within this Body's boundary. + * + * @method Phaser.Physics.Arcade.Body#hitTest + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate. + * @param {number} y - The vertical coordinate. + * + * @return {boolean} True if (x, y) is within this Body. + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * Whether this Body is touching a tile or the world boundary while moving down. + * + * @method Phaser.Physics.Arcade.Body#onFloor + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#blocked + * + * @return {boolean} True if touching. + */ + onFloor: function () + { + return this.blocked.down; + }, + + /** + * Whether this Body is touching a tile or the world boundary while moving up. + * + * @method Phaser.Physics.Arcade.Body#onCeiling + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#blocked + * + * @return {boolean} True if touching. + */ + onCeiling: function () + { + return this.blocked.up; + }, + + /** + * Whether this Body is touching a tile or the world boundary while moving left or right. + * + * @method Phaser.Physics.Arcade.Body#onWall + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#blocked + * + * @return {boolean} True if touching. + */ + onWall: function () + { + return (this.blocked.left || this.blocked.right); + }, + + /** + * The absolute (non-negative) change in this Body's horizontal position from the previous step. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsX + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaAbsX: function () + { + return (this._dx > 0) ? this._dx : -this._dx; + }, + + /** + * The absolute (non-negative) change in this Body's vertical position from the previous step. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsY + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaAbsY: function () + { + return (this._dy > 0) ? this._dy : -this._dy; + }, + + /** + * The change in this Body's horizontal position from the previous step. + * This value is set during the Body's update phase. + * + * @method Phaser.Physics.Arcade.Body#deltaX + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaX: function () + { + return this._dx; + }, + + /** + * The change in this Body's vertical position from the previous step. + * This value is set during the Body's update phase. + * + * @method Phaser.Physics.Arcade.Body#deltaY + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaY: function () + { + return this._dy; + }, + + /** + * The change in this Body's rotation from the previous step, in degrees. + * + * @method Phaser.Physics.Arcade.Body#deltaZ + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaZ: function () + { + return this.rotation - this.preRotation; + }, + + /** + * Disables this Body and marks it for deletion by the simulation. + * + * @method Phaser.Physics.Arcade.Body#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * Draws this Body's boundary and velocity, if enabled. + * + * @method Phaser.Physics.Arcade.Body#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - The Graphics object to draw on. + */ + drawDebug: function (graphic) + { + var pos = this.position; + + var x = pos.x + this.halfWidth; + var y = pos.y + this.halfHeight; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor); + + if (this.isCircle) + { + graphic.strokeCircle(x, y, this.width / 2); + } + else + { + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + } + + if (this.debugShowVelocity) + { + graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); + graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); + } + }, + + /** + * Whether this Body will be drawn to the debug display. + * + * @method Phaser.Physics.Arcade.Body#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} True if either `debugShowBody` or `debugShowVelocity` are enabled. + */ + willDrawDebug: function () + { + return (this.debugShowBody || this.debugShowVelocity); + }, + + /** + * Sets whether this Body collides with the world boundary. + * + * @method Phaser.Physics.Arcade.Body#setCollideWorldBounds + * @since 3.0.0 + * + * @param {boolean} [value=true] - True (collisions) or false (no collisions). + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCollideWorldBounds: function (value) + { + if (value === undefined) { value = true; } + + this.collideWorldBounds = value; + + return this; + }, + + /** + * Sets the Body's velocity. + * + * @method Phaser.Physics.Arcade.Body#setVelocity + * @since 3.0.0 + * + * @param {number} x - The horizontal velocity, in pixels per second. + * @param {number} [y=x] - The vertical velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocity: function (x, y) + { + this.velocity.set(x, y); + + this.speed = Math.sqrt(x * x + y * y); + + return this; + }, + + /** + * Sets the Body's horizontal velocity. + * + * @method Phaser.Physics.Arcade.Body#setVelocityX + * @since 3.0.0 + * + * @param {number} value - The velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityX: function (value) + { + this.velocity.x = value; + + var vx = value; + var vy = this.velocity.y; + + this.speed = Math.sqrt(vx * vx + vy * vy); + + return this; + }, + + /** + * Sets the Body's vertical velocity. + * + * @method Phaser.Physics.Arcade.Body#setVelocityY + * @since 3.0.0 + * + * @param {number} value - The velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityY: function (value) + { + this.velocity.y = value; + + var vx = this.velocity.x; + var vy = value; + + this.speed = Math.sqrt(vx * vx + vy * vy); + + return this; + }, + + /** + * Sets the Body's maximum velocity. + * + * @method Phaser.Physics.Arcade.Body#setMaxVelocity + * @since 3.10.0 + * + * @param {number} x - The horizontal velocity, in pixels per second. + * @param {number} [y=x] - The vertical velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setMaxVelocity: function (x, y) + { + this.maxVelocity.set(x, y); + + return this; + }, + + /** + * Sets the Body's bounce. + * + * @method Phaser.Physics.Arcade.Body#setBounce + * @since 3.0.0 + * + * @param {number} x - The horizontal bounce, relative to 1. + * @param {number} y - The vertical bounce, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounce: function (x, y) + { + this.bounce.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal bounce. + * + * @method Phaser.Physics.Arcade.Body#setBounceX + * @since 3.0.0 + * + * @param {number} value - The bounce, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceX: function (value) + { + this.bounce.x = value; + + return this; + }, + + /** + * Sets the Body's vertical bounce. + * + * @method Phaser.Physics.Arcade.Body#setBounceY + * @since 3.0.0 + * + * @param {number} value - The bounce, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceY: function (value) + { + this.bounce.y = value; + + return this; + }, + + /** + * Sets the Body's acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAcceleration + * @since 3.0.0 + * + * @param {number} x - The horizontal component, in pixels per second squared. + * @param {number} y - The vertical component, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAcceleration: function (x, y) + { + this.acceleration.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - The acceleration, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationX: function (value) + { + this.acceleration.x = value; + + return this; + }, + + /** + * Sets the Body's vertical acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - The acceleration, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationY: function (value) + { + this.acceleration.y = value; + + return this; + }, + + /** + * Enables or disables drag. + * + * @method Phaser.Physics.Arcade.Body#setAllowDrag + * @since 3.9.0 + * @see Phaser.Physics.Arcade.Body#allowDrag + * + * @param {boolean} [value=true] - `true` to allow drag on this body, or `false` to disable it. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAllowDrag: function (value) + { + if (value === undefined) { value = true; } + + this.allowDrag = value; + + return this; + }, + + /** + * Enables or disables gravity's effect on this Body. + * + * @method Phaser.Physics.Arcade.Body#setAllowGravity + * @since 3.9.0 + * @see Phaser.Physics.Arcade.Body#allowGravity + * + * @param {boolean} [value=true] - `true` to allow gravity on this body, or `false` to disable it. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAllowGravity: function (value) + { + if (value === undefined) { value = true; } + + this.allowGravity = value; + + return this; + }, + + /** + * Enables or disables rotation. + * + * @method Phaser.Physics.Arcade.Body#setAllowRotation + * @since 3.9.0 + * @see Phaser.Physics.Arcade.Body#allowRotation + * + * @param {boolean} [value=true] - `true` to allow rotation on this body, or `false` to disable it. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAllowRotation: function (value) + { + if (value === undefined) { value = true; } + + this.allowRotation = value; + + return this; + }, + + /** + * Sets the Body's drag. + * + * @method Phaser.Physics.Arcade.Body#setDrag + * @since 3.0.0 + * + * @param {number} x - The horizontal component, in pixels per second squared. + * @param {number} y - The vertical component, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDrag: function (x, y) + { + this.drag.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal drag. + * + * @method Phaser.Physics.Arcade.Body#setDragX + * @since 3.0.0 + * + * @param {number} value - The drag, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragX: function (value) + { + this.drag.x = value; + + return this; + }, + + /** + * Sets the Body's vertical drag. + * + * @method Phaser.Physics.Arcade.Body#setDragY + * @since 3.0.0 + * + * @param {number} value - The drag, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragY: function (value) + { + this.drag.y = value; + + return this; + }, + + /** + * Sets the Body's gravity. + * + * @method Phaser.Physics.Arcade.Body#setGravity + * @since 3.0.0 + * + * @param {number} x - The horizontal component, in pixels per second squared. + * @param {number} y - The vertical component, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravity: function (x, y) + { + this.gravity.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal gravity. + * + * @method Phaser.Physics.Arcade.Body#setGravityX + * @since 3.0.0 + * + * @param {number} value - The gravity, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityX: function (value) + { + this.gravity.x = value; + + return this; + }, + + /** + * Sets the Body's vertical gravity. + * + * @method Phaser.Physics.Arcade.Body#setGravityY + * @since 3.0.0 + * + * @param {number} value - The gravity, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityY: function (value) + { + this.gravity.y = value; + + return this; + }, + + /** + * Sets the Body's friction. + * + * @method Phaser.Physics.Arcade.Body#setFriction + * @since 3.0.0 + * + * @param {number} x - The horizontal component, relative to 1. + * @param {number} y - The vertical component, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFriction: function (x, y) + { + this.friction.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal friction. + * + * @method Phaser.Physics.Arcade.Body#setFrictionX + * @since 3.0.0 + * + * @param {number} value - The friction value, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionX: function (value) + { + this.friction.x = value; + + return this; + }, + + /** + * Sets the Body's vertical friction. + * + * @method Phaser.Physics.Arcade.Body#setFrictionY + * @since 3.0.0 + * + * @param {number} value - The friction value, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionY: function (value) + { + this.friction.y = value; + + return this; + }, + + /** + * Sets the Body's angular velocity. + * + * @method Phaser.Physics.Arcade.Body#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - The velocity, in degrees per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularVelocity: function (value) + { + this.angularVelocity = value; + + return this; + }, + + /** + * Sets the Body's angular acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - The acceleration, in degrees per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularAcceleration: function (value) + { + this.angularAcceleration = value; + + return this; + }, + + /** + * Sets the Body's angular drag. + * + * @method Phaser.Physics.Arcade.Body#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - The drag, in degrees per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularDrag: function (value) + { + this.angularDrag = value; + + return this; + }, + + /** + * Sets the Body's mass. + * + * @method Phaser.Physics.Arcade.Body#setMass + * @since 3.0.0 + * + * @param {number} value - The mass value, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setMass: function (value) + { + this.mass = value; + + return this; + }, + + /** + * Sets the Body's `immovable` property. + * + * @method Phaser.Physics.Arcade.Body#setImmovable + * @since 3.0.0 + * + * @param {boolean} [value=true] - The value to assign to `immovable`. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setImmovable: function (value) + { + if (value === undefined) { value = true; } + + this.immovable = value; + + return this; + }, + + /** + * Sets the Body's `enable` property. + * + * @method Phaser.Physics.Arcade.Body#setEnable + * @since 3.15.0 + * + * @param {boolean} [value=true] - The value to assign to `enable`. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setEnable: function (value) + { + if (value === undefined) { value = true; } + + this.enable = value; + + return this; + }, + + /** + * The Body's horizontal position (left edge). + * + * @name Phaser.Physics.Arcade.Body#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + } + + }, + + /** + * The Body's vertical position (top edge). + * + * @name Phaser.Physics.Arcade.Body#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } + + }, + + /** + * The left edge of the Body's boundary. Identical to x. + * + * @name Phaser.Physics.Arcade.Body#left + * @type {number} + * @readonly + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.position.x; + } + + }, + + /** + * The right edge of the Body's boundary. + * + * @name Phaser.Physics.Arcade.Body#right + * @type {number} + * @readonly + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.position.x + this.width; + } + + }, + + /** + * The top edge of the Body's boundary. Identical to y. + * + * @name Phaser.Physics.Arcade.Body#top + * @type {number} + * @readonly + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.position.y; + } + + }, + + /** + * The bottom edge of this Body's boundary. + * + * @name Phaser.Physics.Arcade.Body#bottom + * @type {number} + * @readonly + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.position.y + this.height; + } + + } + +}); + +module.exports = Body; + + +/***/ }), +/* 233 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(232); +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var Collider = __webpack_require__(231); +var CONST = __webpack_require__(35); +var DistanceBetween = __webpack_require__(52); +var EventEmitter = __webpack_require__(11); +var FuzzyEqual = __webpack_require__(248); +var FuzzyGreaterThan = __webpack_require__(247); +var FuzzyLessThan = __webpack_require__(246); +var GetOverlapX = __webpack_require__(230); +var GetOverlapY = __webpack_require__(229); +var GetValue = __webpack_require__(4); +var ProcessQueue = __webpack_require__(228); +var ProcessTileCallbacks = __webpack_require__(514); +var Rectangle = __webpack_require__(9); +var RTree = __webpack_require__(227); +var SeparateTile = __webpack_require__(513); +var SeparateX = __webpack_require__(508); +var SeparateY = __webpack_require__(507); +var Set = __webpack_require__(95); +var StaticBody = __webpack_require__(225); +var TileIntersectsBody = __webpack_require__(226); +var TransformMatrix = __webpack_require__(38); +var Vector2 = __webpack_require__(3); +var Wrap = __webpack_require__(53); + +/** + * @event Phaser.Physics.Arcade.World#pause + */ + +/** + * @event Phaser.Physics.Arcade.World#resume + */ + +/** + * @event Phaser.Physics.Arcade.World#collide + * @param {Phaser.GameObjects.GameObject} gameObject1 + * @param {Phaser.GameObjects.GameObject} gameObject2 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 + */ + +/** + * @event Phaser.Physics.Arcade.World#overlap + * @param {Phaser.GameObjects.GameObject} gameObject1 + * @param {Phaser.GameObjects.GameObject} gameObject2 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 + */ + +/** + * @event Phaser.Physics.Arcade.World#worldbounds + * @param {Phaser.Physics.Arcade.Body} body + * @param {boolean} up + * @param {boolean} down + * @param {boolean} left + * @param {boolean} right + */ + +/** + * @typedef {object} ArcadeWorldConfig + * + * @property {number} [fps=60] - Sets {@link Phaser.Physics.Arcade.World#fps}. + * @property {number} [timeScale=1] - Sets {@link Phaser.Physics.Arcade.World#timeScale}. + * @property {object} [gravity] - Sets {@link Phaser.Physics.Arcade.World#gravity}. + * @property {number} [gravity.x=0] - The horizontal world gravity value. + * @property {number} [gravity.y=0] - The vertical world gravity value. + * @property {number} [x=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.x}. + * @property {number} [y=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.y}. + * @property {number} [width=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.width}. + * @property {number} [height=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.height}. + * @property {object} [checkCollision] - Sets {@link Phaser.Physics.Arcade.World#checkCollision}. + * @property {boolean} [checkCollision.up=true] - Should bodies collide with the top of the world bounds? + * @property {boolean} [checkCollision.down=true] - Should bodies collide with the bottom of the world bounds? + * @property {boolean} [checkCollision.left=true] - Should bodies collide with the left of the world bounds? + * @property {boolean} [checkCollision.right=true] - Should bodies collide with the right of the world bounds? + * @property {number} [overlapBias=4] - Sets {@link Phaser.Physics.Arcade.World#OVERLAP_BIAS}. + * @property {number} [tileBias=16] - Sets {@link Phaser.Physics.Arcade.World#TILE_BIAS}. + * @property {boolean} [forceX=false] - Sets {@link Phaser.Physics.Arcade.World#forceX}. + * @property {boolean} [isPaused=false] - Sets {@link Phaser.Physics.Arcade.World#isPaused}. + * @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Arcade.World#debug}. + * @property {boolean} [debugShowBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowBody}. + * @property {boolean} [debugShowStaticBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. + * @property {boolean} [debugShowVelocity=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. + * @property {number} [debugBodyColor=0xff00ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugBodyColor}. + * @property {number} [debugStaticBodyColor=0x0000ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugStaticBodyColor}. + * @property {number} [debugVelocityColor=0x00ff00] - Sets {@link Phaser.Physics.Arcade.World#defaults debugVelocityColor}. + * @property {number} [maxEntries=16] - Sets {@link Phaser.Physics.Arcade.World#maxEntries}. + * @property {boolean} [useTree=true] - Sets {@link Phaser.Physics.Arcade.World#useTree}. + */ + +/** + * @typedef {object} CheckCollisionObject + * + * @property {boolean} up - [description] + * @property {boolean} down - [description] + * @property {boolean} left - [description] + * @property {boolean} right - [description] + */ + +/** + * @typedef {object} ArcadeWorldDefaults + * + * @property {boolean} debugShowBody - [description] + * @property {boolean} debugShowStaticBody - [description] + * @property {boolean} debugShowVelocity - [description] + * @property {number} bodyDebugColor - [description] + * @property {number} staticBodyDebugColor - [description] + * @property {number} velocityDebugColor - [description] + */ + +/** + * @typedef {object} ArcadeWorldTreeMinMax + * + * @property {number} minX - [description] + * @property {number} minY - [description] + * @property {number} maxX - [description] + * @property {number} maxY - [description] + */ + +/** + * An Arcade Physics Collider Type. + * + * @typedef {( + * Phaser.GameObjects.GameObject| + * Phaser.GameObjects.Group| + * Phaser.Physics.Arcade.Sprite| + * Phaser.Physics.Arcade.Image| + * Phaser.Physics.Arcade.StaticGroup| + * Phaser.Physics.Arcade.Group| + * Phaser.Tilemaps.DynamicTilemapLayer| + * Phaser.Tilemaps.StaticTilemapLayer| + * Phaser.GameObjects.GameObject[]| + * Phaser.Physics.Arcade.Sprite[]| + * Phaser.Physics.Arcade.Image[]| + * Phaser.Physics.Arcade.StaticGroup[]| + * Phaser.Physics.Arcade.Group[]| + * Phaser.Tilemaps.DynamicTilemapLayer[]| + * Phaser.Tilemaps.StaticTilemapLayer[] + * )} ArcadeColliderType + */ + +/** + * @classdesc + * The Arcade Physics World. + * + * The World is responsible for creating, managing, colliding and updating all of the bodies within it. + * + * An instance of the World belongs to a Phaser.Scene and is accessed via the property `physics.world`. + * + * @class World + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this World instance belongs. + * @param {ArcadeWorldConfig} config - An Arcade Physics Configuration object. + */ +var World = new Class({ + + Extends: EventEmitter, + + initialize: + + function World (scene, config) + { + EventEmitter.call(this); + + /** + * The Scene this simulation belongs to. + * + * @name Phaser.Physics.Arcade.World#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * Dynamic Bodies in this simulation. + * + * @name Phaser.Physics.Arcade.World#bodies + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.bodies = new Set(); + + /** + * Static Bodies in this simulation. + * + * @name Phaser.Physics.Arcade.World#staticBodies + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.staticBodies = new Set(); + + /** + * Static Bodies marked for deletion. + * + * @name Phaser.Physics.Arcade.World#pendingDestroy + * @type {Phaser.Structs.Set.<(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)>} + * @since 3.1.0 + */ + this.pendingDestroy = new Set(); + + /** + * This simulation's collision processors. + * + * @name Phaser.Physics.Arcade.World#colliders + * @type {Phaser.Structs.ProcessQueue.} + * @since 3.0.0 + */ + this.colliders = new ProcessQueue(); + + /** + * Acceleration of Bodies due to gravity, in pixels per second. + * + * @name Phaser.Physics.Arcade.World#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.gravity = new Vector2(GetValue(config, 'gravity.x', 0), GetValue(config, 'gravity.y', 0)); + + /** + * A boundary constraining Bodies. + * + * @name Phaser.Physics.Arcade.World#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.0.0 + */ + this.bounds = new Rectangle( + GetValue(config, 'x', 0), + GetValue(config, 'y', 0), + GetValue(config, 'width', scene.sys.game.config.width), + GetValue(config, 'height', scene.sys.game.config.height) + ); + + /** + * The boundary edges that Bodies can collide with. + * + * @name Phaser.Physics.Arcade.World#checkCollision + * @type {CheckCollisionObject} + * @since 3.0.0 + */ + this.checkCollision = { + up: GetValue(config, 'checkCollision.up', true), + down: GetValue(config, 'checkCollision.down', true), + left: GetValue(config, 'checkCollision.left', true), + right: GetValue(config, 'checkCollision.right', true) + }; + + /** + * The number of physics steps to be taken per second. + * + * This property is read-only. Use the `setFPS` method to modify it at run-time. + * + * @name Phaser.Physics.Arcade.World#fps + * @readonly + * @type {number} + * @default 60 + * @since 3.10.0 + */ + this.fps = GetValue(config, 'fps', 60); + + /** + * The amount of elapsed ms since the last frame. + * + * @name Phaser.Physics.Arcade.World#_elapsed + * @private + * @type {number} + * @since 3.10.0 + */ + this._elapsed = 0; + + /** + * Internal frame time value. + * + * @name Phaser.Physics.Arcade.World#_frameTime + * @private + * @type {number} + * @since 3.10.0 + */ + this._frameTime = 1 / this.fps; + + /** + * Internal frame time ms value. + * + * @name Phaser.Physics.Arcade.World#_frameTimeMS + * @private + * @type {number} + * @since 3.10.0 + */ + this._frameTimeMS = 1000 * this._frameTime; + + /** + * The number of steps that took place in the last frame. + * + * @name Phaser.Physics.Arcade.World#stepsLastFrame + * @readonly + * @type {number} + * @since 3.10.0 + */ + this.stepsLastFrame = 0; + + /** + * Scaling factor applied to the frame rate. + * + * - 1.0 = normal speed + * - 2.0 = half speed + * - 0.5 = double speed + * + * @name Phaser.Physics.Arcade.World#timeScale + * @property {number} + * @default 1 + * @since 3.10.0 + */ + this.timeScale = GetValue(config, 'timeScale', 1); + + /** + * The maximum absolute difference of a Body's per-step velocity and its overlap with another Body that will result in separation on *each axis*. + * Larger values favor separation. + * Smaller values favor no separation. + * + * @name Phaser.Physics.Arcade.World#OVERLAP_BIAS + * @type {number} + * @default 4 + * @since 3.0.0 + */ + this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4); + + /** + * The maximum absolute value of a Body's overlap with a tile that will result in separation on *each axis*. + * Larger values favor separation. + * Smaller values favor no separation. + * The optimum value may be similar to the tile size. + * + * @name Phaser.Physics.Arcade.World#TILE_BIAS + * @type {number} + * @default 16 + * @since 3.0.0 + */ + this.TILE_BIAS = GetValue(config, 'tileBias', 16); + + /** + * Always separate overlapping Bodies horizontally before vertically. + * False (the default) means Bodies are first separated on the axis of greater gravity, or the vertical axis if neither is greater. + * + * @name Phaser.Physics.Arcade.World#forceX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.forceX = GetValue(config, 'forceX', false); + + /** + * Whether the simulation advances with the game loop. + * + * @name Phaser.Physics.Arcade.World#isPaused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPaused = GetValue(config, 'isPaused', false); + + /** + * Temporary total of colliding Bodies. + * + * @name Phaser.Physics.Arcade.World#_total + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._total = 0; + + /** + * Enables the debug display. + * + * @name Phaser.Physics.Arcade.World#drawDebug + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.drawDebug = GetValue(config, 'debug', false); + + /** + * The graphics object drawing the debug display. + * + * @name Phaser.Physics.Arcade.World#debugGraphic + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.debugGraphic; + + /** + * Default debug display settings for new Bodies. + * + * @name Phaser.Physics.Arcade.World#defaults + * @type {ArcadeWorldDefaults} + * @since 3.0.0 + */ + this.defaults = { + debugShowBody: GetValue(config, 'debugShowBody', true), + debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), + debugShowVelocity: GetValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), + staticBodyDebugColor: GetValue(config, 'debugStaticBodyColor', 0x0000ff), + velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) + }; + + /** + * The maximum number of items per node on the RTree. + * + * This is ignored if `useTree` is `false`. If you have a large number of bodies in + * your world then you may find search performance improves by increasing this value, + * to allow more items per node and less node division. + * + * @name Phaser.Physics.Arcade.World#maxEntries + * @type {integer} + * @default 16 + * @since 3.0.0 + */ + this.maxEntries = GetValue(config, 'maxEntries', 16); + + /** + * Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not? + * + * An RTree is a fast way of spatially sorting of all the moving bodies in the world. + * However, at certain limits, the cost of clearing and inserting the bodies into the + * tree every frame becomes more expensive than the search speed gains it provides. + * + * If you have a large number of dynamic bodies in your world then it may be best to + * disable the use of the RTree by setting this property to `true`. + * The number it can cope with depends on browser and device, but a conservative estimate + * of around 5,000 bodies should be considered the max before disabling it. + * + * Note this only applies to dynamic bodies. Static bodies are always kept in an RTree, + * because they don't have to be cleared every frame, so you benefit from the + * massive search speeds all the time. + * + * @name Phaser.Physics.Arcade.World#useTree + * @type {boolean} + * @default true + * @since 3.10.0 + */ + this.useTree = GetValue(config, 'useTree', true); + + /** + * The spatial index of Dynamic Bodies. + * + * @name Phaser.Physics.Arcade.World#tree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.tree = new RTree(this.maxEntries); + + /** + * The spatial index of Static Bodies. + * + * @name Phaser.Physics.Arcade.World#staticTree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.staticTree = new RTree(this.maxEntries); + + /** + * Recycled input for tree searches. + * + * @name Phaser.Physics.Arcade.World#treeMinMax + * @type {ArcadeWorldTreeMinMax} + * @since 3.0.0 + */ + this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; + + /** + * A temporary Transform Matrix used by bodies for calculations without them needing their own local copy. + * + * @name Phaser.Physics.Arcade.World#_tempMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * A temporary Transform Matrix used by bodies for calculations without them needing their own local copy. + * + * @name Phaser.Physics.Arcade.World#_tempMatrix2 + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + if (this.drawDebug) + { + this.createDebugGraphic(); + } + }, + + /** + * Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group. + * + * The difference between this and the `enableBody` method is that you can pass arrays or Groups + * to this method. + * + * You can specify if the bodies are to be Dynamic or Static. A dynamic body can move via velocity and + * acceleration. A static body remains fixed in place and as such is able to use an optimized search + * tree, making it ideal for static elements such as level objects. You can still collide and overlap + * with static bodies. + * + * Normally, rather than calling this method directly, you'd use the helper methods available in the + * Arcade Physics Factory, such as: + * + * ```javascript + * this.physics.add.image(x, y, textureKey); + * this.physics.add.sprite(x, y, textureKey); + * ``` + * + * Calling factory methods encapsulates the creation of a Game Object and the creation of its + * body at the same time. If you are creating custom classes then you can pass them to this + * method to have their bodies created. + * + * @method Phaser.Physics.Arcade.World#enable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to create the bodies. + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + */ + enable: function (object, bodyType) + { + if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } + + if (!Array.isArray(object)) + { + object = [ object ]; + } + + for (var i = 0; i < object.length; i++) + { + var entry = object[i]; + + if (entry.isParent) + { + var children = entry.getChildren(); + + for (var c = 0; c < children.length; c++) + { + var child = children[c]; + + if (child.isParent) + { + // Handle Groups nested inside of Groups + this.enable(child, bodyType); + } + else + { + this.enableBody(child, bodyType); + } + } + } + else + { + this.enableBody(entry, bodyType); + } + } + }, + + /** + * Creates an Arcade Physics Body on a single Game Object. + * + * If the Game Object already has a body, this method will simply add it back into the simulation. + * + * You can specify if the body is Dynamic or Static. A dynamic body can move via velocity and + * acceleration. A static body remains fixed in place and as such is able to use an optimized search + * tree, making it ideal for static elements such as level objects. You can still collide and overlap + * with static bodies. + * + * Normally, rather than calling this method directly, you'd use the helper methods available in the + * Arcade Physics Factory, such as: + * + * ```javascript + * this.physics.add.image(x, y, textureKey); + * this.physics.add.sprite(x, y, textureKey); + * ``` + * + * Calling factory methods encapsulates the creation of a Game Object and the creation of its + * body at the same time. If you are creating custom classes then you can pass them to this + * method to have their bodies created. + * + * @method Phaser.Physics.Arcade.World#enableBody + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object - The Game Object on which to create the body. + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + * + * @return {Phaser.GameObjects.GameObject} The Game Object on which the body was created. + */ + enableBody: function (object, bodyType) + { + if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } + + if (!object.body) + { + if (bodyType === CONST.DYNAMIC_BODY) + { + object.body = new Body(this, object); + } + else if (bodyType === CONST.STATIC_BODY) + { + object.body = new StaticBody(this, object); + } + } + + this.add(object.body); + + return object; + }, + + /** + * Adds an existing Arcade Physics Body or StaticBody to the simulation. + * + * The body is enabled and added to the local search trees. + * + * @method Phaser.Physics.Arcade.World#add + * @since 3.10.0 + * + * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be added to the simulation. + * + * @return {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} The Body that was added to the simulation. + */ + add: function (body) + { + if (body.physicsType === CONST.DYNAMIC_BODY) + { + this.bodies.set(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.set(body); + + this.staticTree.insert(body); + } + + body.enable = true; + + return body; + }, + + /** + * Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group. + * + * The difference between this and the `disableBody` method is that you can pass arrays or Groups + * to this method. + * + * The body itself is not deleted, it just has its `enable` property set to false, which + * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. + * + * @method Phaser.Physics.Arcade.World#disable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to disable the bodies. + */ + disable: function (object) + { + if (!Array.isArray(object)) + { + object = [ object ]; + } + + for (var i = 0; i < object.length; i++) + { + var entry = object[i]; + + if (entry.isParent) + { + var children = entry.getChildren(); + + for (var c = 0; c < children.length; c++) + { + var child = children[c]; + + if (child.isParent) + { + // Handle Groups nested inside of Groups + this.disable(child); + } + else + { + this.disableBody(child.body); + } + } + } + else + { + this.disableBody(entry.body); + } + } + }, + + /** + * Disables an existing Arcade Physics Body or StaticBody and removes it from the simulation. + * + * The body is disabled and removed from the local search trees. + * + * The body itself is not deleted, it just has its `enable` property set to false, which + * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. + * + * @method Phaser.Physics.Arcade.World#disableBody + * @since 3.0.0 + * + * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be disabled. + */ + disableBody: function (body) + { + this.remove(body); + + body.enable = false; + }, + + /** + * Removes an existing Arcade Physics Body or StaticBody from the simulation. + * + * The body is disabled and removed from the local search trees. + * + * The body itself is not deleted, it just has its `enabled` property set to false, which + * means you can re-enable it again at any point by passing it to enable `enable` or `add`. + * + * @method Phaser.Physics.Arcade.World#remove + * @since 3.0.0 + * + * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The body to be removed from the simulation. + */ + remove: function (body) + { + if (body.physicsType === CONST.DYNAMIC_BODY) + { + this.tree.remove(body); + this.bodies.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.delete(body); + this.staticTree.remove(body); + } + }, + + /** + * Creates a Graphics Game Object that the world will use to render the debug display to. + * + * This is called automatically when the World is instantiated if the `debug` config property + * was set to `true`. However, you can call it at any point should you need to display the + * debug Graphic from a fixed point. + * + * You can control which objects are drawn to the Graphics object, and the colors they use, + * by setting the debug properties in the physics config. + * + * You should not typically use this in a production game. Use it to aid during debugging. + * + * @method Phaser.Physics.Arcade.World#createDebugGraphic + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} The Graphics object that was created for use by the World. + */ + createDebugGraphic: function () + { + var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); + + graphic.setDepth(Number.MAX_VALUE); + + this.debugGraphic = graphic; + + this.drawDebug = true; + + return graphic; + }, + + /** + * Sets the position, size and properties of the World boundary. + * + * The World boundary is an invisible rectangle that defines the edges of the World. + * If a Body is set to collide with the world bounds then it will automatically stop + * when it reaches any of the edges. You can optionally set which edges of the boundary + * should be checked against. + * + * @method Phaser.Physics.Arcade.World#setBounds + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the boundary. + * @param {number} y - The top-left y coordinate of the boundary. + * @param {number} width - The width of the boundary. + * @param {number} height - The height of the boundary. + * @param {boolean} [checkLeft] - Should bodies check against the left edge of the boundary? + * @param {boolean} [checkRight] - Should bodies check against the right edge of the boundary? + * @param {boolean} [checkUp] - Should bodies check against the top edge of the boundary? + * @param {boolean} [checkDown] - Should bodies check against the bottom edge of the boundary? + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBounds: function (x, y, width, height, checkLeft, checkRight, checkUp, checkDown) + { + this.bounds.setTo(x, y, width, height); + + if (checkLeft !== undefined) + { + this.setBoundsCollision(checkLeft, checkRight, checkUp, checkDown); + } + + return this; + }, + + /** + * Enables or disables collisions on each edge of the World boundary. + * + * @method Phaser.Physics.Arcade.World#setBoundsCollision + * @since 3.0.0 + * + * @param {boolean} [left=true] - Should bodies check against the left edge of the boundary? + * @param {boolean} [right=true] - Should bodies check against the right edge of the boundary? + * @param {boolean} [up=true] - Should bodies check against the top edge of the boundary? + * @param {boolean} [down=true] - Should bodies check against the bottom edge of the boundary? + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBoundsCollision: function (left, right, up, down) + { + if (left === undefined) { left = true; } + if (right === undefined) { right = true; } + if (up === undefined) { up = true; } + if (down === undefined) { down = true; } + + this.checkCollision.left = left; + this.checkCollision.right = right; + this.checkCollision.up = up; + this.checkCollision.down = down; + + return this; + }, + + /** + * Pauses the simulation. + * + * A paused simulation does not update any existing bodies, or run any Colliders. + * + * However, you can still enable and disable bodies within it, or manually run collide or overlap + * checks. + * + * @method Phaser.Physics.Arcade.World#pause + * @fires Phaser.Physics.Arcade.World#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + pause: function () + { + this.isPaused = true; + + this.emit('pause'); + + return this; + }, + + /** + * Resumes the simulation, if paused. + * + * @method Phaser.Physics.Arcade.World#resume + * @fires Phaser.Physics.Arcade.World#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + resume: function () + { + this.isPaused = false; + + this.emit('resume'); + + return this; + }, + + /** + * Creates a new Collider object and adds it to the simulation. + * + * A Collider is a way to automatically perform collision checks between two objects, + * calling the collide and process callbacks if they occur. + * + * Colliders are run as part of the World update, after all of the Bodies have updated. + * + * By creating a Collider you don't need then call `World.collide` in your `update` loop, + * as it will be handled for you automatically. + * + * @method Phaser.Physics.Arcade.World#addCollider + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#collide + * + * @param {ArcadeColliderType} object1 - The first object to check for collision. + * @param {ArcadeColliderType} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addCollider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, false, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * Creates a new Overlap Collider object and adds it to the simulation. + * + * A Collider is a way to automatically perform overlap checks between two objects, + * calling the collide and process callbacks if they occur. + * + * Colliders are run as part of the World update, after all of the Bodies have updated. + * + * By creating a Collider you don't need then call `World.overlap` in your `update` loop, + * as it will be handled for you automatically. + * + * @method Phaser.Physics.Arcade.World#addOverlap + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object to check for overlap. + * @param {ArcadeColliderType} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects overlap. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects overlap. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addOverlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, true, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * Removes a Collider from the simulation so it is no longer processed. + * + * This method does not destroy the Collider. If you wish to add it back at a later stage you can call + * `World.colliders.add(Collider)`. + * + * If you no longer need the Collider you can call the `Collider.destroy` method instead, which will + * automatically clear all of its references and then remove it from the World. If you call destroy on + * a Collider you _don't_ need to pass it to this method too. + * + * @method Phaser.Physics.Arcade.World#removeCollider + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Collider} collider - The Collider to remove from the simulation. + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + removeCollider: function (collider) + { + this.colliders.remove(collider); + + return this; + }, + + /** + * Sets the frame rate to run the simulation at. + * + * The frame rate value is used to simulate a fixed update time step. This fixed + * time step allows for a straightforward implementation of a deterministic game state. + * + * This frame rate is independent of the frequency at which the game is rendering. The + * higher you set the fps, the more physics simulation steps will occur per game step. + * Conversely, the lower you set it, the less will take place. + * + * You can optionally advance the simulation directly yourself by calling the `step` method. + * + * @method Phaser.Physics.Arcade.World#setFPS + * @since 3.10.0 + * + * @param {integer} framerate - The frame rate to advance the simulation at. + * + * @return {this} This World object. + */ + setFPS: function (framerate) + { + this.fps = framerate; + this._frameTime = 1 / this.fps; + this._frameTimeMS = 1000 * this._frameTime; + + return this; + }, + + /** + * Advances the simulation based on the elapsed time and fps rate. + * + * This is called automatically by your Scene and does not need to be invoked directly. + * + * @method Phaser.Physics.Arcade.World#update + * @protected + * @since 3.0.0 + * + * @param {number} 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.isPaused || this.bodies.size === 0) + { + return; + } + + var stepsThisFrame = 0; + var fixedDelta = this._frameTime; + var msPerFrame = this._frameTimeMS * this.timeScale; + + this._elapsed += delta; + + while (this._elapsed >= msPerFrame) + { + this._elapsed -= msPerFrame; + + stepsThisFrame++; + + this.step(fixedDelta); + } + + this.stepsLastFrame = stepsThisFrame; + }, + + /** + * Advances the simulation by one step. + * + * @method Phaser.Physics.Arcade.World#step + * @since 3.10.0 + * + * @param {number} delta - The delta time amount, in ms, by which to advance the simulation. + */ + step: function (delta) + { + // Update all active bodies + var i; + var body; + var bodies = this.bodies.entries; + var len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.update(delta); + } + } + + // Optionally populate our dynamic collision tree + if (this.useTree) + { + this.tree.clear(); + this.tree.load(bodies); + } + + // Process any colliders + var colliders = this.colliders.update(); + + for (i = 0; i < colliders.length; i++) + { + var collider = colliders[i]; + + if (collider.active) + { + collider.update(); + } + } + + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.postUpdate(); + } + } + }, + + /** + * Updates bodies, draws the debug display, and handles pending queue operations. + * + * @method Phaser.Physics.Arcade.World#postUpdate + * @since 3.0.0 + */ + postUpdate: function () + { + var i; + var body; + + var dynamic = this.bodies; + var staticBodies = this.staticBodies; + var pending = this.pendingDestroy; + + var bodies = dynamic.entries; + var len = bodies.length; + + if (this.drawDebug) + { + var graphics = this.debugGraphic; + + graphics.clear(); + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + + bodies = staticBodies.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + } + + if (pending.size > 0) + { + var dynamicTree = this.tree; + var staticTree = this.staticTree; + + bodies = pending.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.physicsType === CONST.DYNAMIC_BODY) + { + dynamicTree.remove(body); + dynamic.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + staticTree.remove(body); + staticBodies.delete(body); + } + + body.world = undefined; + body.gameObject = undefined; + } + + pending.clear(); + } + }, + + /** + * Calculates a Body's velocity and updates its position. + * + * @method Phaser.Physics.Arcade.World#updateMotion + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body to be updated. + * @param {number} delta - The delta value to be used in the motion calculations. + */ + updateMotion: function (body, delta) + { + if (body.allowRotation) + { + this.computeAngularVelocity(body, delta); + } + + this.computeVelocity(body, delta); + }, + + /** + * Calculates a Body's angular velocity. + * + * @method Phaser.Physics.Arcade.World#computeAngularVelocity + * @since 3.10.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. + * @param {number} delta - The delta value to be used in the calculation. + */ + computeAngularVelocity: function (body, delta) + { + var velocity = body.angularVelocity; + var acceleration = body.angularAcceleration; + var drag = body.angularDrag; + var max = body.maxAngular; + + if (acceleration) + { + velocity += acceleration * delta; + } + else if (body.allowDrag && drag) + { + drag *= delta; + + if (FuzzyGreaterThan(velocity - drag, 0, 0.1)) + { + velocity -= drag; + } + else if (FuzzyLessThan(velocity + drag, 0, 0.1)) + { + velocity += drag; + } + else + { + velocity = 0; + } + } + + velocity = Clamp(velocity, -max, max); + + var velocityDelta = velocity - body.angularVelocity; + + body.angularVelocity += velocityDelta; + body.rotation += (body.angularVelocity * delta); + }, + + /** + * Calculates a Body's per-axis velocity. + * + * @method Phaser.Physics.Arcade.World#computeVelocity + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. + * @param {number} delta - The delta value to be used in the calculation. + */ + computeVelocity: function (body, delta) + { + var velocityX = body.velocity.x; + var accelerationX = body.acceleration.x; + var dragX = body.drag.x; + var maxX = body.maxVelocity.x; + + var velocityY = body.velocity.y; + var accelerationY = body.acceleration.y; + var dragY = body.drag.y; + var maxY = body.maxVelocity.y; + + var speed = body.speed; + var allowDrag = body.allowDrag; + var useDamping = body.useDamping; + + if (body.allowGravity) + { + velocityX += (this.gravity.x + body.gravity.x) * delta; + velocityY += (this.gravity.y + body.gravity.y) * delta; + } + + if (accelerationX) + { + velocityX += accelerationX * delta; + } + else if (allowDrag && dragX) + { + if (useDamping) + { + // Damping based deceleration + velocityX *= dragX; + + if (FuzzyEqual(speed, 0, 0.001)) + { + velocityX = 0; + } + } + else + { + // Linear deceleration + dragX *= delta; + + if (FuzzyGreaterThan(velocityX - dragX, 0, 0.01)) + { + velocityX -= dragX; + } + else if (FuzzyLessThan(velocityX + dragX, 0, 0.01)) + { + velocityX += dragX; + } + else + { + velocityX = 0; + } + } + } + + if (accelerationY) + { + velocityY += accelerationY * delta; + } + else if (allowDrag && dragY) + { + if (useDamping) + { + // Damping based deceleration + velocityY *= dragY; + + if (FuzzyEqual(speed, 0, 0.001)) + { + velocityY = 0; + } + } + else + { + // Linear deceleration + dragY *= delta; + + if (FuzzyGreaterThan(velocityY - dragY, 0, 0.01)) + { + velocityY -= dragY; + } + else if (FuzzyLessThan(velocityY + dragY, 0, 0.01)) + { + velocityY += dragY; + } + else + { + velocityY = 0; + } + } + } + + velocityX = Clamp(velocityX, -maxX, maxX); + velocityY = Clamp(velocityY, -maxY, maxY); + + body.velocity.set(velocityX, velocityY); + }, + + /** + * Separates two Bodies. + * + * @method Phaser.Physics.Arcade.World#separate + * @fires Phaser.Physics.Arcade.World#collide + * @fires Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. + * @param {ArcadePhysicsCallback} [processCallback] - The process callback. + * @param {*} [callbackContext] - The context in which to invoke the callback. + * @param {boolean} [overlapOnly] - If this a collide or overlap check? + * + * @return {boolean} True if separation occurred, otherwise false. + */ + separate: function (body1, body2, processCallback, callbackContext, overlapOnly) + { + if ( + !body1.enable || + !body2.enable || + body1.checkCollision.none || + body2.checkCollision.none || + !this.intersects(body1, body2)) + { + return false; + } + + // They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort. + if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false) + { + return false; + } + + // Circle vs. Circle quick bail out + if (body1.isCircle && body2.isCircle) + { + return this.separateCircle(body1, body2, overlapOnly); + } + + // We define the behavior of bodies in a collision circle and rectangle + // If a collision occurs in the corner points of the rectangle, the body behave like circles + + // Either body1 or body2 is a circle + if (body1.isCircle !== body2.isCircle) + { + var bodyRect = (body1.isCircle) ? body2 : body1; + var bodyCircle = (body1.isCircle) ? body1 : body2; + + var rect = { + x: bodyRect.x, + y: bodyRect.y, + right: bodyRect.right, + bottom: bodyRect.bottom + }; + + var circle = bodyCircle.center; + + if (circle.y < rect.y || circle.y > rect.bottom) + { + if (circle.x < rect.x || circle.x > rect.right) + { + return this.separateCircle(body1, body2, overlapOnly); + } + } + } + + var resultX = false; + var resultY = false; + + // Do we separate on x or y first? + if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + else + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + + var result = (resultX || resultY); + + if (result) + { + if (overlapOnly && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + else + { + body1.postUpdate(); + body2.postUpdate(); + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + } + } + + return result; + }, + + /** + * Separates two Bodies, when both are circular. + * + * @method Phaser.Physics.Arcade.World#separateCircle + * @fires Phaser.Physics.Arcade.World#collide + * @fires Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. + * @param {boolean} [overlapOnly] - If this a collide or overlap check? + * @param {number} bias - A small value added to the calculations. + * + * @return {boolean} True if separation occurred, otherwise false. + */ + separateCircle: function (body1, body2, overlapOnly, bias) + { + // Set the bounding box overlap values into the bodies themselves (hence we don't use the return values here) + GetOverlapX(body1, body2, false, bias); + GetOverlapY(body1, body2, false, bias); + + var dx = body2.center.x - body1.center.x; + var dy = body2.center.y - body1.center.y; + + var angleCollision = Math.atan2(dy, dx); + + var overlap = 0; + + if (body1.isCircle !== body2.isCircle) + { + var rect = { + x: (body2.isCircle) ? body1.position.x : body2.position.x, + y: (body2.isCircle) ? body1.position.y : body2.position.y, + right: (body2.isCircle) ? body1.right : body2.right, + bottom: (body2.isCircle) ? body1.bottom : body2.bottom + }; + + var circle = { + x: (body1.isCircle) ? body1.center.x : body2.center.x, + y: (body1.isCircle) ? body1.center.y : body2.center.y, + radius: (body1.isCircle) ? body1.halfWidth : body2.halfWidth + }; + + if (circle.y < rect.y) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.y) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.y) - circle.radius; + } + } + else if (circle.y > rect.bottom) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.bottom) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.bottom) - circle.radius; + } + } + + overlap *= -1; + } + else + { + overlap = (body1.halfWidth + body2.halfWidth) - DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y); + } + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) + { + if (overlap !== 0 && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + + // return true if there was some overlap, otherwise false + return (overlap !== 0); + } + + // Transform the velocity vector to the coordinate system oriented along the direction of impact. + // This is done to eliminate the vertical component of the velocity + + var b1vx = body1.velocity.x; + var b1vy = body1.velocity.y; + var b1mass = body1.mass; + + var b2vx = body2.velocity.x; + var b2vy = body2.velocity.y; + var b2mass = body2.mass; + + var v1 = { + x: b1vx * Math.cos(angleCollision) + b1vy * Math.sin(angleCollision), + y: b1vx * Math.sin(angleCollision) - b1vy * Math.cos(angleCollision) + }; + + var v2 = { + x: b2vx * Math.cos(angleCollision) + b2vy * Math.sin(angleCollision), + y: b2vx * Math.sin(angleCollision) - b2vy * Math.cos(angleCollision) + }; + + // We expect the new velocity after impact + var tempVel1 = ((b1mass - b2mass) * v1.x + 2 * b2mass * v2.x) / (b1mass + b2mass); + var tempVel2 = (2 * b1mass * v1.x + (b2mass - b1mass) * v2.x) / (b1mass + b2mass); + + // We convert the vector to the original coordinate system and multiplied by factor of rebound + if (!body1.immovable) + { + body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x; + body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y; + + // Reset local var + b1vx = body1.velocity.x; + b1vy = body1.velocity.y; + } + + if (!body2.immovable) + { + body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x; + body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y; + + // Reset local var + b2vx = body2.velocity.x; + b2vy = body2.velocity.y; + } + + // When the collision angle is almost perpendicular to the total initial velocity vector + // (collision on a tangent) vector direction can be determined incorrectly. + // This code fixes the problem + + if (Math.abs(angleCollision) < Math.PI / 2) + { + if ((b1vx > 0) && !body1.immovable && (b2vx > b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx < 0) && !body2.immovable && (b1vx < b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy > 0) && !body1.immovable && (b2vy > b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy < 0) && !body2.immovable && (b1vy < b2vy)) + { + body2.velocity.y *= -1; + } + } + else if (Math.abs(angleCollision) > Math.PI / 2) + { + if ((b1vx < 0) && !body1.immovable && (b2vx < b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx > 0) && !body2.immovable && (b1vx > b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy < 0) && !body1.immovable && (b2vy < b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy > 0) && !body2.immovable && (b1vx > b2vy)) + { + body2.velocity.y *= -1; + } + } + + var delta = this._frameTime; + + if (!body1.immovable) + { + body1.x += (body1.velocity.x * delta) - overlap * Math.cos(angleCollision); + body1.y += (body1.velocity.y * delta) - overlap * Math.sin(angleCollision); + } + + if (!body2.immovable) + { + body2.x += (body2.velocity.x * delta) + overlap * Math.cos(angleCollision); + body2.y += (body2.velocity.y * delta) + overlap * Math.sin(angleCollision); + } + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + + // sync changes back to the bodies + body1.postUpdate(); + body2.postUpdate(); + + return true; + }, + + /** + * Checks to see if two Bodies intersect at all. + * + * @method Phaser.Physics.Arcade.World#intersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - The first body to check. + * @param {Phaser.Physics.Arcade.Body} body2 - The second body to check. + * + * @return {boolean} True if the two bodies intersect, otherwise false. + */ + intersects: function (body1, body2) + { + if (body1 === body2) + { + return false; + } + + if (!body1.isCircle && !body2.isCircle) + { + // Rect vs. Rect + return !( + body1.right <= body2.position.x || + body1.bottom <= body2.position.y || + body1.position.x >= body2.right || + body1.position.y >= body2.bottom + ); + } + else if (body1.isCircle) + { + if (body2.isCircle) + { + // Circle vs. Circle + return DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.halfWidth + body2.halfWidth); + } + else + { + // Circle vs. Rect + return this.circleBodyIntersects(body1, body2); + } + } + else + { + // Rect vs. Circle + return this.circleBodyIntersects(body2, body1); + } + }, + + /** + * Tests if a circular Body intersects with another Body. + * + * @method Phaser.Physics.Arcade.World#circleBodyIntersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} circle - The circular body to test. + * @param {Phaser.Physics.Arcade.Body} body - The rectangular body to test. + * + * @return {boolean} True if the two bodies intersect, otherwise false. + */ + circleBodyIntersects: function (circle, body) + { + var x = Clamp(circle.center.x, body.left, body.right); + var y = Clamp(circle.center.y, body.top, body.bottom); + + var dx = (circle.center.x - x) * (circle.center.x - x); + var dy = (circle.center.y - y) * (circle.center.y - y); + + return (dx + dy) <= (circle.halfWidth * circle.halfWidth); + }, + + /** + * Tests if Game Objects overlap. + * + * @method Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [overlapCallback] - An optional callback function that is called if the objects overlap. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if at least one Game Object overlaps another. + */ + overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) + { + if (overlapCallback === undefined) { overlapCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = overlapCallback; } + + return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + }, + + /** + * Performs a collision check and separation between the two physics enabled objects given, which can be single + * Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups. + * + * If you don't require separation then use {@link #overlap} instead. + * + * If two Groups or arrays are passed, each member of one will be tested against each member of the other. + * + * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. + * + * Two callbacks can be provided. The `collideCallback` is invoked if a collision occurs and the two colliding + * objects are passed to it. + * + * Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable + * for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other. + * The separation that stops two objects penetrating may create a new penetration against a different object. If you + * require a high level of stability please consider using an alternative physics system, such as Matter.js. + * + * @method Phaser.Physics.Arcade.World#collide + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if any overlapping Game Objects were separated, otherwise false. + */ + collide: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + }, + + /** + * Helper for Phaser.Physics.Arcade.World#collide. + * + * @method Phaser.Physics.Arcade.World#collideObjects + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - [description] + * @param {ArcadeColliderType} [object2] - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. + */ + collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + var i; + + if (object1.isParent && object1.physicsType === undefined) + { + object1 = object1.children.entries; + } + + if (object2 && object2.isParent && object2.physicsType === undefined) + { + object2 = object2.children.entries; + } + + var object1isArray = Array.isArray(object1); + var object2isArray = Array.isArray(object2); + + this._total = 0; + + if (!object1isArray && !object2isArray) + { + // Neither of them are arrays - do this first as it's the most common use-case + this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (!object1isArray && object2isArray) + { + // Object 2 is an Array + for (i = 0; i < object2.length; i++) + { + this.collideHandler(object1, object2[i], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else if (object1isArray && !object2isArray) + { + // Object 1 is an Array + for (i = 0; i < object1.length; i++) + { + this.collideHandler(object1[i], object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else + { + // They're both arrays + for (i = 0; i < object1.length; i++) + { + for (var j = 0; j < object2.length; j++) + { + this.collideHandler(object1[i], object2[j], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + } + + return (this._total > 0); + }, + + /** + * Helper for Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap. + * + * @method Phaser.Physics.Arcade.World#collideHandler + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - [description] + * @param {ArcadeColliderType} [object2] - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. + */ + collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + // Collide Group with Self + // Only collide valid objects + if (object2 === undefined && object1.isParent) + { + return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + + // If neither of the objects are set then bail out + if (!object1 || !object2) + { + return false; + } + + // A Body + if (object1.body) + { + if (object2.body) + { + return this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // GROUPS + else if (object1.isParent) + { + if (object2.body) + { + return this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // TILEMAP LAYERS + else if (object1.isTilemap) + { + if (object2.body) + { + return this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + }, + + /** + * Handler for Sprite vs. Sprite collisions. + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite1 - [description] + * @param {Phaser.GameObjects.GameObject} sprite2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (!sprite1.body || !sprite2.body) + { + return false; + } + + if (this.separate(sprite1.body, sprite2.body, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, sprite1, sprite2); + } + + this._total++; + } + + return true; + }, + + /** + * Handler for Sprite vs. Group collisions. + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {Phaser.GameObjects.Group} group - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) + { + var bodyA = sprite.body; + + if (group.length === 0 || !bodyA || !bodyA.enable) + { + return; + } + + // Does sprite collide with anything? + + var i; + var len; + var bodyB; + + if (this.useTree) + { + var minMax = this.treeMinMax; + + minMax.minX = bodyA.left; + minMax.minY = bodyA.top; + minMax.maxX = bodyA.right; + minMax.maxY = bodyA.bottom; + + var results = (group.physicsType === CONST.DYNAMIC_BODY) ? this.tree.search(minMax) : this.staticTree.search(minMax); + + len = results.length; + + for (i = 0; i < len; i++) + { + bodyB = results[i]; + + if (bodyA === bodyB || !group.contains(bodyB.gameObject)) + { + // Skip if comparing against itself, or if bodyB isn't actually part of the Group + continue; + } + + if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); + } + + this._total++; + } + } + } + else + { + var children = group.getChildren(); + var skipIndex = group.children.entries.indexOf(sprite); + + len = children.length; + + for (i = 0; i < len; i++) + { + bodyB = children[i].body; + + if (!bodyB || i === skipIndex || !bodyB.enable) + { + continue; + } + + if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); + } + + this._total++; + } + } + } + }, + + /** + * Helper for Group vs. Tilemap collisions. + * + * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var children = group.getChildren(); + + if (children.length === 0) + { + return false; + } + + var didCollide = false; + + for (var i = 0; i < children.length; i++) + { + if (children[i].body) + { + if (this.collideSpriteVsTilemapLayer(children[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)) + { + didCollide = true; + } + } + } + + return didCollide; + }, + + /** + * Helper for Sprite vs. Tilemap collisions. + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer + * @fires Phaser.Physics.Arcade.World#collide + * @fires Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var body = sprite.body; + + if (!body.enable) + { + return false; + } + + var x = body.position.x; + var y = body.position.y; + var w = body.width; + var h = body.height; + + // TODO: this logic should be encapsulated within the Tilemap API at some point. + // If the maps base tile size differs from the layer's tile size, we need to adjust the + // selection area by the difference between the two. + var layerData = tilemapLayer.layer; + + if (layerData.tileWidth > layerData.baseTileWidth) + { + // The x origin of a tile is the left side, so x and width need to be adjusted. + var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; + x -= xDiff; + w += xDiff; + } + + if (layerData.tileHeight > layerData.baseTileHeight) + { + // The y origin of a tile is the bottom side, so just the height needs to be adjusted. + var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; + h += yDiff; + } + + var mapData = tilemapLayer.getTilesWithinWorldXY(x, y, w, h); + + if (mapData.length === 0) + { + return false; + } + + var tile; + var tileWorldRect = { left: 0, right: 0, top: 0, bottom: 0 }; + + for (var i = 0; i < mapData.length; i++) + { + tile = mapData[i]; + tileWorldRect.left = tilemapLayer.tileToWorldX(tile.x); + tileWorldRect.top = tilemapLayer.tileToWorldY(tile.y); + + // If the map's base tile size differs from the layer's tile size, only the top of the rect + // needs to be adjusted since its origin is (0, 1). + if (tile.baseHeight !== tile.height) + { + tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; + } + + tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; + tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; + + if (TileIntersectsBody(tileWorldRect, body) + && (!processCallback || processCallback.call(callbackContext, sprite, tile)) + && ProcessTileCallbacks(tile, sprite) + && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) + { + this._total++; + + if (collideCallback) + { + collideCallback.call(callbackContext, sprite, tile); + } + + if (overlapOnly && body.onOverlap) + { + sprite.emit('overlap', body.gameObject, tile, body, null); + } + else if (body.onCollide) + { + sprite.emit('collide', body.gameObject, tile, body, null); + } + + // sync changes back to the body + body.postUpdate(); + } + } + }, + + /** + * Helper for Group vs. Group collisions. + * + * @method Phaser.Physics.Arcade.World#collideGroupVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group1 - [description] + * @param {Phaser.GameObjects.Group} group2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (group1.length === 0 || group2.length === 0) + { + return; + } + + var children = group1.getChildren(); + + for (var i = 0; i < children.length; i++) + { + this.collideSpriteVsGroup(children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly); + } + }, + + /** + * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. + * + * If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior). + * + * @method Phaser.Physics.Arcade.World#wrap + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects. + * @param {number} [padding=0] - An amount added to each boundary edge during the operation. + */ + wrap: function (object, padding) + { + if (object.body) + { + this.wrapObject(object, padding); + } + else if (object.getChildren) + { + this.wrapArray(object.getChildren(), padding); + } + else if (Array.isArray(object)) + { + this.wrapArray(object, padding); + } + else + { + this.wrapObject(object, padding); + } + }, + + + /** + * Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapArray + * @since 3.3.0 + * + * @param {Array.<*>} objects - An array of objects to be wrapped. + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapArray: function (objects, padding) + { + for (var i = 0; i < objects.length; i++) + { + this.wrapObject(objects[i], padding); + } + }, + + /** + * Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapObject + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Physics Body, or any object with `x` and `y` coordinates + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapObject: function (object, padding) + { + if (padding === undefined) { padding = 0; } + + object.x = Wrap(object.x, this.bounds.left - padding, this.bounds.right + padding); + object.y = Wrap(object.y, this.bounds.top - padding, this.bounds.bottom + padding); + }, + + /** + * Shuts down the simulation, clearing physics data and removing listeners. + * + * @method Phaser.Physics.Arcade.World#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.tree.clear(); + this.staticTree.clear(); + this.bodies.clear(); + this.staticBodies.clear(); + this.colliders.destroy(); + + this.removeAllListeners(); + }, + + /** + * Shuts down the simulation and disconnects it from the current scene. + * + * @method Phaser.Physics.Arcade.World#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.scene = null; + } + +}); + +module.exports = World; + + +/***/ }), +/* 234 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeSprite = __webpack_require__(104); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var Group = __webpack_require__(88); +var IsPlainObject = __webpack_require__(8); + +/** + * @classdesc + * An Arcade Physics Static Group object. + * + * All Game Objects created by this Group will automatically be given static Arcade Physics bodies. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Group}. + * + * @class StaticGroup + * @extends Phaser.GameObjects.Group + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The physics simulation. + * @param {Phaser.Scene} scene - The scene this group belongs to. + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. + */ +var StaticPhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function StaticPhysicsGroup (world, scene, children, config) + { + if (!children && !config) + { + config = { + createCallback: this.createCallbackHandler, + removeCallback: this.removeCallbackHandler, + createMultipleCallback: this.createMultipleCallbackHandler, + classType: ArcadeSprite + }; + } + else if (IsPlainObject(children)) + { + // children is a plain object, so swizzle them: + config = children; + children = null; + + config.createCallback = this.createCallbackHandler; + config.removeCallback = this.removeCallbackHandler; + config.createMultipleCallback = this.createMultipleCallbackHandler; + config.classType = ArcadeSprite; + } + else if (Array.isArray(children) && IsPlainObject(children[0])) + { + // children is an array of plain objects + config = children; + children = null; + + config.forEach(function (singleConfig) + { + singleConfig.createCallback = this.createCallbackHandler; + singleConfig.removeCallback = this.removeCallbackHandler; + singleConfig.createMultipleCallback = this.createMultipleCallbackHandler; + singleConfig.classType = ArcadeSprite; + }); + } + + /** + * The physics simulation. + * + * @name Phaser.Physics.Arcade.StaticGroup#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * The scene this group belongs to. + * + * @name Phaser.Physics.Arcade.StaticGroup#physicsType + * @type {integer} + * @default STATIC_BODY + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; + + Group.call(this, scene, children, config); + }, + + /** + * Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation. + * + * @method Phaser.Physics.Arcade.StaticGroup#createCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The new group member. + * + * @see Phaser.Physics.Arcade.World#enableBody + */ + createCallbackHandler: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.STATIC_BODY); + } + }, + + /** + * Disables the group member's physics body, removing it from the simulation. + * + * @method Phaser.Physics.Arcade.StaticGroup#removeCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The group member being removed. + * + * @see Phaser.Physics.Arcade.World#disableBody + */ + removeCallbackHandler: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * Refreshes the group. + * + * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} entries - The newly created group members. + * + * @see Phaser.Physics.Arcade.StaticGroup#refresh + */ + createMultipleCallbackHandler: function () + { + this.refresh(); + }, + + /** + * Resets each Body to the position of its parent Game Object. + * Body sizes aren't changed (use {@link Phaser.Physics.Arcade.Components.Enable#refreshBody} for that). + * + * @method Phaser.Physics.Arcade.StaticGroup#refresh + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticGroup} This group. + * + * @see Phaser.Physics.Arcade.StaticBody#reset + */ + refresh: function () + { + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + children[i].body.reset(); + } + + return this; + } + +}); + +module.exports = StaticPhysicsGroup; + + +/***/ }), +/* 235 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeSprite = __webpack_require__(104); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var GetFastValue = __webpack_require__(2); +var Group = __webpack_require__(88); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} PhysicsGroupConfig + * @extends GroupConfig + * + * @property {boolean} [collideWorldBounds=false] - Sets {@link Phaser.Physics.Arcade.Body#collideWorldBounds}. + * @property {number} [accelerationX=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.x}. + * @property {number} [accelerationY=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.y}. + * @property {boolean} [allowDrag=true] - Sets {@link Phaser.Physics.Arcade.Body#allowDrag}. + * @property {boolean} [allowGravity=true] - Sets {@link Phaser.Physics.Arcade.Body#allowGravity}. + * @property {boolean} [allowRotation=true] - Sets {@link Phaser.Physics.Arcade.Body#allowRotation}. + * @property {number} [bounceX=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.x}. + * @property {number} [bounceY=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.y}. + * @property {number} [dragX=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.x}. + * @property {number} [dragY=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.y}. + * @property {boolean} [enable=true] - Sets {@link Phaser.Physics.Arcade.Body#enable enable}. + * @property {number} [gravityX=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.x}. + * @property {number} [gravityY=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.y}. + * @property {number} [frictionX=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.x}. + * @property {number} [frictionY=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.y}. + * @property {number} [velocityX=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.x}. + * @property {number} [velocityY=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.y}. + * @property {number} [angularVelocity=0] - Sets {@link Phaser.Physics.Arcade.Body#angularVelocity}. + * @property {number} [angularAcceleration=0] - Sets {@link Phaser.Physics.Arcade.Body#angularAcceleration}. + * @property {number} [angularDrag=0] - Sets {@link Phaser.Physics.Arcade.Body#angularDrag}. + * @property {number} [mass=0] - Sets {@link Phaser.Physics.Arcade.Body#mass}. + * @property {boolean} [immovable=false] - Sets {@link Phaser.Physics.Arcade.Body#immovable}. + */ + +/** + * @typedef {object} PhysicsGroupDefaults + * + * @property {boolean} setCollideWorldBounds - As {@link Phaser.Physics.Arcade.Body#setCollideWorldBounds}. + * @property {number} setAccelerationX - As {@link Phaser.Physics.Arcade.Body#setAccelerationX}. + * @property {number} setAccelerationY - As {@link Phaser.Physics.Arcade.Body#setAccelerationY}. + * @property {boolean} setAllowDrag - As {@link Phaser.Physics.Arcade.Body#setAllowDrag}. + * @property {boolean} setAllowGravity - As {@link Phaser.Physics.Arcade.Body#setAllowGravity}. + * @property {boolean} setAllowRotation - As {@link Phaser.Physics.Arcade.Body#setAllowRotation}. + * @property {number} setBounceX - As {@link Phaser.Physics.Arcade.Body#setBounceX}. + * @property {number} setBounceY - As {@link Phaser.Physics.Arcade.Body#setBounceY}. + * @property {number} setDragX - As {@link Phaser.Physics.Arcade.Body#setDragX}. + * @property {number} setDragY - As {@link Phaser.Physics.Arcade.Body#setDragY}. + * @property {boolean} setEnable - As {@link Phaser.Physics.Arcade.Body#setEnable}. + * @property {number} setGravityX - As {@link Phaser.Physics.Arcade.Body#setGravityX}. + * @property {number} setGravityY - As {@link Phaser.Physics.Arcade.Body#setGravityY}. + * @property {number} setFrictionX - As {@link Phaser.Physics.Arcade.Body#setFrictionX}. + * @property {number} setFrictionY - As {@link Phaser.Physics.Arcade.Body#setFrictionY}. + * @property {number} setVelocityX - As {@link Phaser.Physics.Arcade.Body#setVelocityX}. + * @property {number} setVelocityY - As {@link Phaser.Physics.Arcade.Body#setVelocityY}. + * @property {number} setAngularVelocity - As {@link Phaser.Physics.Arcade.Body#setAngularVelocity}. + * @property {number} setAngularAcceleration - As {@link Phaser.Physics.Arcade.Body#setAngularAcceleration}. + * @property {number} setAngularDrag - As {@link Phaser.Physics.Arcade.Body#setAngularDrag}. + * @property {number} setMass - As {@link Phaser.Physics.Arcade.Body#setMass}. + * @property {boolean} setImmovable - As {@link Phaser.Physics.Arcade.Body#setImmovable}. + */ + +/** + * @classdesc + * An Arcade Physics Group object. + * + * All Game Objects created by this Group will automatically be given dynamic Arcade Physics bodies. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticGroup}. + * + * @class Group + * @extends Phaser.GameObjects.Group + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The physics simulation. + * @param {Phaser.Scene} scene - The scene this group belongs to. + * @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group. + */ +var PhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function PhysicsGroup (world, scene, children, config) + { + if (!children && !config) + { + config = { + createCallback: this.createCallbackHandler, + removeCallback: this.removeCallbackHandler + }; + } + else if (IsPlainObject(children)) + { + // children is a plain object, so swizzle them: + config = children; + children = null; + + config.createCallback = this.createCallbackHandler; + config.removeCallback = this.removeCallbackHandler; + } + else if (Array.isArray(children) && IsPlainObject(children[0])) + { + // children is an array of plain objects + config = children; + children = null; + + config.forEach(function (singleConfig) + { + singleConfig.createCallback = this.createCallbackHandler; + singleConfig.removeCallback = this.removeCallbackHandler; + }); + } + + /** + * The physics simulation. + * + * @name Phaser.Physics.Arcade.Group#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * The class to create new group members from. + * This should be ArcadeImage, ArcadeSprite, or a class extending one of those. + * + * @name Phaser.Physics.Arcade.Group#classType + * @type {(Phaser.Physics.Arcade.Image|Phaser.Physics.Arcade.Sprite)} + * @default ArcadeSprite + */ + config.classType = GetFastValue(config, 'classType', ArcadeSprite); + + /** + * The physics type of the Group's members. + * + * @name Phaser.Physics.Arcade.Group#physicsType + * @type {integer} + * @default DYNAMIC_BODY + * @since 3.0.0 + */ + this.physicsType = CONST.DYNAMIC_BODY; + + /** + * Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument. + * + * @name Phaser.Physics.Arcade.Group#defaults + * @type {PhysicsGroupDefaults} + * @since 3.0.0 + */ + this.defaults = { + setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false), + setAccelerationX: GetFastValue(config, 'accelerationX', 0), + setAccelerationY: GetFastValue(config, 'accelerationY', 0), + setAllowDrag: GetFastValue(config, 'allowDrag', true), + setAllowGravity: GetFastValue(config, 'allowGravity', true), + setAllowRotation: GetFastValue(config, 'allowRotation', true), + setBounceX: GetFastValue(config, 'bounceX', 0), + setBounceY: GetFastValue(config, 'bounceY', 0), + setDragX: GetFastValue(config, 'dragX', 0), + setDragY: GetFastValue(config, 'dragY', 0), + setEnable: GetFastValue(config, 'enable', true), + setGravityX: GetFastValue(config, 'gravityX', 0), + setGravityY: GetFastValue(config, 'gravityY', 0), + setFrictionX: GetFastValue(config, 'frictionX', 0), + setFrictionY: GetFastValue(config, 'frictionY', 0), + setVelocityX: GetFastValue(config, 'velocityX', 0), + setVelocityY: GetFastValue(config, 'velocityY', 0), + setAngularVelocity: GetFastValue(config, 'angularVelocity', 0), + setAngularAcceleration: GetFastValue(config, 'angularAcceleration', 0), + setAngularDrag: GetFastValue(config, 'angularDrag', 0), + setMass: GetFastValue(config, 'mass', 1), + setImmovable: GetFastValue(config, 'immovable', false) + }; + + Group.call(this, scene, children, config); + }, + + /** + * Enables a Game Object's Body and assigns `defaults`. Called when a Group member is added or created. + * + * @method Phaser.Physics.Arcade.Group#createCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object being added. + */ + createCallbackHandler: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.DYNAMIC_BODY); + } + + var body = child.body; + + for (var key in this.defaults) + { + body[key](this.defaults[key]); + } + }, + + /** + * Disables a Game Object's Body. Called when a Group member is removed. + * + * @method Phaser.Physics.Arcade.Group#removeCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object being removed. + */ + removeCallbackHandler: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * Sets the velocity of each Group member. + * + * @method Phaser.Physics.Arcade.Group#setVelocity + * @since 3.0.0 + * + * @param {number} x - The horizontal velocity. + * @param {number} y - The vertical velocity. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x, y), the second (x + step, y + step), and so on. + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocity: function (x, y, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.set(x + (i * step), y + (i * step)); + } + + return this; + }, + + /** + * Sets the horizontal velocity of each Group member. + * + * @method Phaser.Physics.Arcade.Group#setVelocityX + * @since 3.0.0 + * + * @param {number} value - The velocity value. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x), the second (x + step), and so on. + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityX: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.x = value + (i * step); + } + + return this; + }, + + /** + * Sets the vertical velocity of each Group member. + * + * @method Phaser.Physics.Arcade.Group#setVelocityY + * @since 3.0.0 + * + * @param {number} value - The velocity value. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (y), the second (y + step), and so on. + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityY: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.y = value + (i * step); + } + + return this; + } + +}); + +module.exports = PhysicsGroup; + + +/***/ }), +/* 236 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Arcade.Components + */ + +module.exports = { + + Acceleration: __webpack_require__(526), + Angular: __webpack_require__(525), + Bounce: __webpack_require__(524), + Debug: __webpack_require__(523), + Drag: __webpack_require__(522), + Enable: __webpack_require__(521), + Friction: __webpack_require__(520), + Gravity: __webpack_require__(519), + Immovable: __webpack_require__(518), + Mass: __webpack_require__(517), + Size: __webpack_require__(516), + Velocity: __webpack_require__(515) + +}; + + +/***/ }), +/* 237 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(236); +var Image = __webpack_require__(87); + +/** + * @classdesc + * An Arcade Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.Image + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeImage = new Class({ + + Extends: Image, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeImage (scene, x, y, texture, frame) + { + Image.call(this, scene, x, y, texture, frame); + + /** + * This Game Object's Physics Body. + * + * @name Phaser.Physics.Arcade.Image#body + * @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} + * @default null + * @since 3.0.0 + */ + this.body = null; + } + +}); + +module.exports = ArcadeImage; + + +/***/ }), +/* 238 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeImage = __webpack_require__(237); +var ArcadeSprite = __webpack_require__(104); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var PhysicsGroup = __webpack_require__(235); +var StaticPhysicsGroup = __webpack_require__(234); + +/** + * @classdesc + * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. + * Objects that are created by this Factory are automatically added to the physics world. + * + * @class Factory + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics World instance. + */ +var Factory = new Class({ + + initialize: + + function Factory (world) + { + /** + * A reference to the Arcade Physics World. + * + * @name Phaser.Physics.Arcade.Factory#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * A reference to the Scene this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = world.scene; + + /** + * A reference to the Scene.Systems this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = world.scene.sys; + }, + + /** + * Create a new Arcade Physics Collider object. + * + * @method Phaser.Physics.Arcade.Factory#collider + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for collision. + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + collider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addCollider(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Create a new Arcade Physics Collider Overlap object. + * + * @method Phaser.Physics.Arcade.Factory#overlap + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for overlap. + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + overlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addOverlap(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Adds an Arcade Physics Body to the given Game Object. + * + * @method Phaser.Physics.Arcade.Factory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - A Game Object. + * @param {boolean} [isStatic=false] - Create a Static body (true) or Dynamic body (false). + * + * @return {Phaser.GameObjects.GameObject} The Game Object. + */ + existing: function (gameObject, isStatic) + { + var type = (isStatic) ? CONST.STATIC_BODY : CONST.DYNAMIC_BODY; + + this.world.enableBody(gameObject, type); + + return gameObject; + }, + + /** + * Creates a new Arcade Image object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticImage + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + staticImage: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.STATIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Image object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + image: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.DYNAMIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Sprite object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + staticSprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.STATIC_BODY); + + return sprite; + }, + + /** + * Creates a new Arcade Sprite object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + sprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.DYNAMIC_BODY); + + return sprite; + }, + + /** + * Creates a Static Physics Group object. + * All Game Objects created by this Group will automatically be static Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#staticGroup + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. + * + * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. + */ + staticGroup: function (children, config) + { + return this.sys.updateList.add(new StaticPhysicsGroup(this.world, this.world.scene, children, config)); + }, + + /** + * Creates a Physics Group object. + * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#group + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group. + * + * @return {Phaser.Physics.Arcade.Group} The Group object that was created. + */ + 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; + } + +}); + +module.exports = Factory; + + +/***/ }), +/* 239 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(138); +var Matrix3 = __webpack_require__(241); + +var EPSILON = 0.000001; + +// Some shared 'private' arrays +var siNext = new Int8Array([ 1, 2, 0 ]); +var tmp = new Float32Array([ 0, 0, 0 ]); + +var xUnitVec3 = new Vector3(1, 0, 0); +var yUnitVec3 = new Vector3(0, 1, 0); + +var tmpvec = new Vector3(); +var tmpMat3 = new Matrix3(); + +/** + * @classdesc + * A quaternion. + * + * @class Quaternion + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + * @param {number} [w] - The w component. + */ +var Quaternion = new Class({ + + initialize: + + function Quaternion (x, y, z, w) + { + /** + * The x component of this Quaternion. + * + * @name Phaser.Math.Quaternion#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The y component of this Quaternion. + * + * @name Phaser.Math.Quaternion#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The z component of this Quaternion. + * + * @name Phaser.Math.Quaternion#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The w component of this Quaternion. + * + * @name Phaser.Math.Quaternion#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * Copy the components of a given Quaternion or Vector into this Quaternion. + * + * @method Phaser.Math.Quaternion#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} src - The Quaternion or Vector to copy the components from. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z; + this.w = src.w; + + return this; + }, + + /** + * Set the components of this Quaternion. + * + * @method Phaser.Math.Quaternion#set + * @since 3.0.0 + * + * @param {(number|object)} [x=0] - The x component, or an object containing x, y, z, and w components. + * @param {number} [y=0] - The y component. + * @param {number} [z=0] - The z component. + * @param {number} [w=0] - The w component. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * Add a given Quaternion or Vector to this Quaternion. Addition is component-wise. + * + * @method Phaser.Math.Quaternion#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to add to this Quaternion. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z; + this.w += v.w; + + return this; + }, + + /** + * Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise. + * + * @method Phaser.Math.Quaternion#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to subtract from this Quaternion. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + this.w -= v.w; + + return this; + }, + + /** + * Scale this Quaternion by the given value. + * + * @method Phaser.Math.Quaternion#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Quaternion by. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * Calculate the length of this Quaternion. + * + * @method Phaser.Math.Quaternion#length + * @since 3.0.0 + * + * @return {number} The length of this Quaternion. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * Calculate the length of this Quaternion squared. + * + * @method Phaser.Math.Quaternion#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Quaternion, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * Normalize this Quaternion. + * + * @method Phaser.Math.Quaternion#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Quaternion and the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#dot + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to dot product with this Quaternion. + * + * @return {number} The dot product of this Quaternion and the given Quaternion or Vector. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * Linearly interpolate this Quaternion towards the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#lerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to interpolate towards. + * @param {number} [t=0] - The percentage of interpolation. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotationTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - [description] + * @param {Phaser.Math.Vector3} b - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotationTo: function (a, b) + { + var dot = a.x * b.x + a.y * b.y + a.z * b.z; + + if (dot < -0.999999) + { + if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) + { + tmpvec.copy(yUnitVec3).cross(a); + } + + tmpvec.normalize(); + + return this.setAxisAngle(tmpvec, Math.PI); + + } + else if (dot > 0.999999) + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + } + else + { + tmpvec.copy(a).cross(b); + + this.x = tmpvec.x; + this.y = tmpvec.y; + this.z = tmpvec.z; + this.w = 1 + dot; + + return this.normalize(); + } + }, + + /** + * Set the axes of this Quaternion. + * + * @method Phaser.Math.Quaternion#setAxes + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} view - The view axis. + * @param {Phaser.Math.Vector3} right - The right axis. + * @param {Phaser.Math.Vector3} up - The upwards axis. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + setAxes: function (view, right, up) + { + var m = tmpMat3.val; + + m[0] = right.x; + m[3] = right.y; + m[6] = right.z; + + m[1] = up.x; + m[4] = up.y; + m[7] = up.z; + + m[2] = -view.x; + m[5] = -view.y; + m[8] = -view.z; + + return this.fromMat3(tmpMat3).normalize(); + }, + + /** + * Reset this Matrix to an identity (default) Quaternion. + * + * @method Phaser.Math.Quaternion#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + identity: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + }, + + /** + * Set the axis angle of this Quaternion. + * + * @method Phaser.Math.Quaternion#setAxisAngle + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} axis - The axis. + * @param {number} rad - The angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + setAxisAngle: function (axis, rad) + { + rad = rad * 0.5; + + var s = Math.sin(rad); + + this.x = s * axis.x; + this.y = s * axis.y; + this.z = s * axis.z; + this.w = Math.cos(rad); + + return this; + }, + + /** + * Multiply this Quaternion by the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to multiply this Quaternion by. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + multiply: function (b) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + this.x = ax * bw + aw * bx + ay * bz - az * by; + this.y = ay * bw + aw * by + az * bx - ax * bz; + this.z = az * bw + aw * bz + ax * by - ay * bx; + this.w = aw * bw - ax * bx - ay * by - az * bz; + + return this; + }, + + /** + * Smoothly linearly interpolate this Quaternion towards the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#slerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to interpolate towards. + * @param {number} t - The percentage of interpolation. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + slerp: function (b, t) + { + // benchmarks: http://jsperf.com/quaternion-slerp-implementations + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + // calc cosine + var cosom = ax * bx + ay * by + az * bz + aw * bw; + + // adjust signs (if necessary) + if (cosom < 0) + { + cosom = -cosom; + bx = - bx; + by = - by; + bz = - bz; + bw = - bw; + } + + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + var scale0 = 1 - t; + var scale1 = t; + + // calculate coefficients + if ((1 - cosom) > EPSILON) + { + // standard case (slerp) + var omega = Math.acos(cosom); + var sinom = Math.sin(omega); + + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } + + // calculate final values + this.x = scale0 * ax + scale1 * bx; + this.y = scale0 * ay + scale1 * by; + this.z = scale0 * az + scale1 * bz; + this.w = scale0 * aw + scale1 * bw; + + return this; + }, + + /** + * Invert this Quaternion. + * + * @method Phaser.Math.Quaternion#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + invert: function () + { + var a0 = this.x; + var a1 = this.y; + var a2 = this.z; + var a3 = this.w; + + var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + var invDot = (dot) ? 1 / dot : 0; + + // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + + this.x = -a0 * invDot; + this.y = -a1 * invDot; + this.z = -a2 * invDot; + this.w = a3 * invDot; + + return this; + }, + + /** + * Convert this Quaternion into its conjugate. + * + * Sets the x, y and z components. + * + * @method Phaser.Math.Quaternion#conjugate + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + conjugate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * Rotate this Quaternion on the X axis. + * + * @method Phaser.Math.Quaternion#rotateX + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateX: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + aw * bx; + this.y = ay * bw + az * bx; + this.z = az * bw - ay * bx; + this.w = aw * bw - ax * bx; + + return this; + }, + + /** + * Rotate this Quaternion on the Y axis. + * + * @method Phaser.Math.Quaternion#rotateY + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateY: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var by = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw - az * by; + this.y = ay * bw + aw * by; + this.z = az * bw + ax * by; + this.w = aw * bw - ay * by; + + return this; + }, + + /** + * Rotate this Quaternion on the Z axis. + * + * @method Phaser.Math.Quaternion#rotateZ + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateZ: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bz = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + ay * bz; + this.y = ay * bw - ax * bz; + this.z = az * bw + aw * bz; + this.w = aw * bw - az * bz; + + return this; + }, + + /** + * Create a unit (or rotation) Quaternion from its x, y, and z components. + * + * Sets the w component. + * + * @method Phaser.Math.Quaternion#calculateW + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + calculateW: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + this.w = -Math.sqrt(1.0 - x * x - y * y - z * z); + + return this; + }, + + /** + * Convert the given Matrix into this Quaternion. + * + * @method Phaser.Math.Quaternion#fromMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix to convert from. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + fromMat3: function (mat) + { + // benchmarks: + // http://jsperf.com/typed-array-access-speed + // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion + + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + var m = mat.val; + var fTrace = m[0] + m[4] + m[8]; + var fRoot; + + if (fTrace > 0) + { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + + this.w = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; // 1/(4w) + + this.x = (m[7] - m[5]) * fRoot; + this.y = (m[2] - m[6]) * fRoot; + this.z = (m[3] - m[1]) * fRoot; + } + else + { + // |w| <= 1/2 + var i = 0; + + if (m[4] > m[0]) + { + i = 1; + } + + if (m[8] > m[i * 3 + i]) + { + i = 2; + } + + var j = siNext[i]; + var k = siNext[j]; + + // This isn't quite as clean without array access + fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); + tmp[i] = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; + + tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; + tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; + + this.x = tmp[0]; + this.y = tmp[1]; + this.z = tmp[2]; + this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; + } + + return this; + } + +}); + +module.exports = Quaternion; + + +/***/ }), +/* 240 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +var EPSILON = 0.000001; + +/** + * @classdesc + * A four-dimensional matrix. + * + * @class Matrix4 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} [m] - Optional Matrix4 to copy values from. + */ +var Matrix4 = new Class({ + + initialize: + + function Matrix4 (m) + { + /** + * The matrix values. + * + * @name Phaser.Math.Matrix4#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(16); + + if (m) + { + // Assume Matrix4 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * Make a clone of this Matrix4. + * + * @method Phaser.Math.Matrix4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} A clone of this Matrix4. + */ + clone: function () + { + return new Matrix4(this); + }, + + // TODO - Should work with basic values + + /** + * This method is an alias for `Matrix4.copy`. + * + * @method Phaser.Math.Matrix4#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to set the values of this Matrix's from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * Copy the values of a given Matrix into this Matrix. + * + * @method Phaser.Math.Matrix4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Set the values of this Matrix from the given array. + * + * @method Phaser.Math.Matrix4#fromArray + * @since 3.0.0 + * + * @param {array} a - The array to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Reset this Matrix. + * + * Sets all values to `0`. + * + * @method Phaser.Math.Matrix4#zero + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + zero: function () + { + var out = this.val; + + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 0; + + return this; + }, + + /** + * Set the `x`, `y` and `z` values of this Matrix. + * + * @method Phaser.Math.Matrix4#xyz + * @since 3.0.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * @param {number} z - The z value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + xyz: function (x, y, z) + { + this.identity(); + + var out = this.val; + + out[12] = x; + out[13] = y; + out[14] = z; + + return this; + }, + + /** + * Set the scaling values of this Matrix. + * + * @method Phaser.Math.Matrix4#scaling + * @since 3.0.0 + * + * @param {number} x - The x scaling value. + * @param {number} y - The y scaling value. + * @param {number} z - The z scaling value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scaling: function (x, y, z) + { + this.zero(); + + var out = this.val; + + out[0] = x; + out[5] = y; + out[10] = z; + out[15] = 1; + + return this; + }, + + /** + * Reset this Matrix to an identity (default) matrix. + * + * @method Phaser.Math.Matrix4#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Transpose this Matrix. + * + * @method Phaser.Math.Matrix4#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + transpose: function () + { + var a = this.val; + + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a12 = a[6]; + var a13 = a[7]; + var a23 = a[11]; + + a[1] = a[4]; + a[2] = a[8]; + a[3] = a[12]; + a[4] = a01; + a[6] = a[9]; + a[7] = a[13]; + a[8] = a02; + a[9] = a12; + a[11] = a[14]; + a[12] = a03; + a[13] = a13; + a[14] = a23; + + return this; + }, + + /** + * Invert this Matrix. + * + * @method Phaser.Math.Matrix4#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return this; + }, + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + * + * @method Phaser.Math.Matrix4#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); + a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); + a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); + a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); + a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); + a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); + a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); + a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); + + return this; + }, + + /** + * Calculate the determinant of this Matrix. + * + * @method Phaser.Math.Matrix4#determinant + * @since 3.0.0 + * + * @return {number} The determinant of this Matrix. + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * @method Phaser.Math.Matrix4#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to multiply this Matrix by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b = src.val; + + // Cache only the current line of the second matrix + var b0 = b[0]; + var b1 = b[1]; + var b2 = b[2]; + var b3 = b[3]; + + a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + + a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + + a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + + a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#multiplyLocal + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiplyLocal: function (src) + { + var a = []; + var m1 = this.val; + var m2 = src.val; + + a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; + a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; + a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; + a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; + + a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; + a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; + a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; + a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; + + a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; + a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; + a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; + a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; + + a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; + a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; + a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; + a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; + + return this.fromArray(a); + }, + + /** + * Translate this Matrix using the given Vector. + * + * @method Phaser.Math.Matrix4#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + translate: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix. + * + * @method Phaser.Math.Matrix4#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scale: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[0] = a[0] * x; + a[1] = a[1] * x; + a[2] = a[2] * x; + a[3] = a[3] * x; + + a[4] = a[4] * y; + a[5] = a[5] * y; + a[6] = a[6] * y; + a[7] = a[7] * y; + + a[8] = a[8] * z; + a[9] = a[9] * z; + a[10] = a[10] * z; + a[11] = a[11] * z; + + return this; + }, + + /** + * Derive a rotation matrix around the given axis. + * + * @method Phaser.Math.Matrix4#makeRotationAxis + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis. + * @param {number} angle - The rotation angle in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + makeRotationAxis: function (axis, angle) + { + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + var c = Math.cos(angle); + var s = Math.sin(angle); + var t = 1 - c; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var tx = t * x; + var ty = t * y; + + this.fromArray([ + tx * x + c, tx * y - s * z, tx * z + s * y, 0, + tx * y + s * z, ty * y + c, ty * z - s * x, 0, + tx * z - s * y, ty * z + s * x, t * z * z + c, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + /** + * Apply a rotation transformation to this Matrix. + * + * @method Phaser.Math.Matrix4#rotate + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * @param {Phaser.Math.Vector3} axis - The axis to rotate upon. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotate: function (rad, axis) + { + var a = this.val; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var len = Math.sqrt(x * x + y * y + z * z); + + if (Math.abs(len) < EPSILON) + { + return null; + } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + var s = Math.sin(rad); + var c = Math.cos(rad); + var t = 1 - c; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Construct the elements of the rotation matrix + var b00 = x * x * t + c; + var b01 = y * x * t + z * s; + var b02 = z * x * t - y * s; + + var b10 = x * y * t - z * s; + var b11 = y * y * t + c; + var b12 = z * y * t + x * s; + + var b20 = x * z * t + y * s; + var b21 = y * z * t - x * s; + var b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + a[0] = a00 * b00 + a10 * b01 + a20 * b02; + a[1] = a01 * b00 + a11 * b01 + a21 * b02; + a[2] = a02 * b00 + a12 * b01 + a22 * b02; + a[3] = a03 * b00 + a13 * b01 + a23 * b02; + a[4] = a00 * b10 + a10 * b11 + a20 * b12; + a[5] = a01 * b10 + a11 * b11 + a21 * b12; + a[6] = a02 * b10 + a12 * b11 + a22 * b12; + a[7] = a03 * b10 + a13 * b11 + a23 * b12; + a[8] = a00 * b20 + a10 * b21 + a20 * b22; + a[9] = a01 * b20 + a11 * b21 + a21 * b22; + a[10] = a02 * b20 + a12 * b21 + a22 * b22; + a[11] = a03 * b20 + a13 * b21 + a23 * b22; + + return this; + }, + + /** + * Rotate this matrix on its X axis. + * + * @method Phaser.Math.Matrix4#rotateX + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateX: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[4] = a10 * c + a20 * s; + a[5] = a11 * c + a21 * s; + a[6] = a12 * c + a22 * s; + a[7] = a13 * c + a23 * s; + a[8] = a20 * c - a10 * s; + a[9] = a21 * c - a11 * s; + a[10] = a22 * c - a12 * s; + a[11] = a23 * c - a13 * s; + + return this; + }, + + /** + * Rotate this matrix on its Y axis. + * + * @method Phaser.Math.Matrix4#rotateY + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateY: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c - a20 * s; + a[1] = a01 * c - a21 * s; + a[2] = a02 * c - a22 * s; + a[3] = a03 * c - a23 * s; + a[8] = a00 * s + a20 * c; + a[9] = a01 * s + a21 * c; + a[10] = a02 * s + a22 * c; + a[11] = a03 * s + a23 * c; + + return this; + }, + + /** + * Rotate this matrix on its Z axis. + * + * @method Phaser.Math.Matrix4#rotateZ + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateZ: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c + a10 * s; + a[1] = a01 * c + a11 * s; + a[2] = a02 * c + a12 * s; + a[3] = a03 * c + a13 * s; + a[4] = a10 * c - a00 * s; + a[5] = a11 * c - a01 * s; + a[6] = a12 * c - a02 * s; + a[7] = a13 * c - a03 * s; + + return this; + }, + + /** + * Set the values of this Matrix from the given rotation Quaternion and translation Vector. + * + * @method Phaser.Math.Matrix4#fromRotationTranslation + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set rotation from. + * @param {Phaser.Math.Vector3} v - The Vector to set translation from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromRotationTranslation: function (q, v) + { + // Quaternion math + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = v.x; + out[13] = v.y; + out[14] = v.z; + out[15] = 1; + + return this; + }, + + /** + * Set the values of this Matrix from the given Quaternion. + * + * @method Phaser.Math.Matrix4#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromQuat: function (q) + { + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Generate a frustum matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#frustum + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + frustum: function (left, right, bottom, top, near, far) + { + var out = this.val; + + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + + out[0] = (near * 2) * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (near * 2) * tb; + out[6] = 0; + out[7] = 0; + + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (far * near * 2) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspective + * @since 3.0.0 + * + * @param {number} fovy - Vertical field of view in radians + * @param {number} aspect - Aspect ratio. Typically viewport width /height. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspective: function (fovy, aspect, near, far) + { + var out = this.val; + var f = 1.0 / Math.tan(fovy / 2); + var nf = 1 / (near - far); + + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspectiveLH + * @since 3.0.0 + * + * @param {number} width - The width of the frustum. + * @param {number} height - The height of the frustum. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspectiveLH: function (width, height, near, far) + { + var out = this.val; + + out[0] = (2 * near) / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (2 * near) / height; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = -far / (near - far); + out[11] = 1; + + out[12] = 0; + out[13] = 0; + out[14] = (near * far) / (near - far); + out[15] = 0; + + return this; + }, + + /** + * Generate an orthogonal projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#ortho + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + ortho: function (left, right, bottom, top, near, far) + { + var out = this.val; + var lr = left - right; + var bt = bottom - top; + var nf = near - far; + + // Avoid division by zero + lr = (lr === 0) ? lr : 1 / lr; + bt = (bt === 0) ? bt : 1 / bt; + nf = (nf === 0) ? nf : 1 / nf; + + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; + + return this; + }, + + /** + * Generate a look-at matrix with the given eye position, focal point, and up axis. + * + * @method Phaser.Math.Matrix4#lookAt + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} eye - Position of the viewer + * @param {Phaser.Math.Vector3} center - Point the viewer is looking at + * @param {Phaser.Math.Vector3} up - vec3 pointing up. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + lookAt: function (eye, center, up) + { + var out = this.val; + + var eyex = eye.x; + var eyey = eye.y; + var eyez = eye.z; + + var upx = up.x; + var upy = up.y; + var upz = up.z; + + var centerx = center.x; + var centery = center.y; + var centerz = center.z; + + if (Math.abs(eyex - centerx) < EPSILON && + Math.abs(eyey - centery) < EPSILON && + Math.abs(eyez - centerz) < EPSILON) + { + return this.identity(); + } + + var z0 = eyex - centerx; + var z1 = eyey - centery; + var z2 = eyez - centerz; + + var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + + z0 *= len; + z1 *= len; + z2 *= len; + + var x0 = upy * z2 - upz * z1; + var x1 = upz * z0 - upx * z2; + var x2 = upx * z1 - upy * z0; + + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + + if (!len) + { + x0 = 0; + x1 = 0; + x2 = 0; + } + else + { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + var y0 = z1 * x2 - z2 * x1; + var y1 = z2 * x0 - z0 * x2; + var y2 = z0 * x1 - z1 * x0; + + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + + if (!len) + { + y0 = 0; + y1 = 0; + y2 = 0; + } + else + { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + + return this; + }, + + /** + * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values. + * + * @method Phaser.Math.Matrix4#yawPitchRoll + * @since 3.0.0 + * + * @param {number} yaw - [description] + * @param {number} pitch - [description] + * @param {number} roll - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + yawPitchRoll: function (yaw, pitch, roll) + { + this.zero(); + _tempMat1.zero(); + _tempMat2.zero(); + + var m0 = this.val; + var m1 = _tempMat1.val; + var m2 = _tempMat2.val; + + // Rotate Z + var s = Math.sin(roll); + var c = Math.cos(roll); + + m0[10] = 1; + m0[15] = 1; + m0[0] = c; + m0[1] = s; + m0[4] = -s; + m0[5] = c; + + // Rotate X + s = Math.sin(pitch); + c = Math.cos(pitch); + + m1[0] = 1; + m1[15] = 1; + m1[5] = c; + m1[10] = c; + m1[9] = -s; + m1[6] = s; + + // Rotate Y + s = Math.sin(yaw); + c = Math.cos(yaw); + + m2[5] = 1; + m2[15] = 1; + m2[0] = c; + m2[2] = -s; + m2[8] = s; + m2[10] = c; + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + return this; + }, + + /** + * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix. + * + * @method Phaser.Math.Matrix4#setWorldMatrix + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} rotation - The rotation of the world matrix. + * @param {Phaser.Math.Vector3} position - The position of the world matrix. + * @param {Phaser.Math.Vector3} scale - The scale of the world matrix. + * @param {Phaser.Math.Matrix4} [viewMatrix] - The view matrix. + * @param {Phaser.Math.Matrix4} [projectionMatrix] - The projection matrix. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) + { + this.yawPitchRoll(rotation.y, rotation.x, rotation.z); + + _tempMat1.scaling(scale.x, scale.y, scale.z); + _tempMat2.xyz(position.x, position.y, position.z); + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + if (viewMatrix !== undefined) + { + this.multiplyLocal(viewMatrix); + } + + if (projectionMatrix !== undefined) + { + this.multiplyLocal(projectionMatrix); + } + + return this; + } + +}); + +var _tempMat1 = new Matrix4(); +var _tempMat2 = new Matrix4(); + +module.exports = Matrix4; + + +/***/ }), +/* 241 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A three-dimensional matrix. + * + * Defaults to the identity matrix when instantiated. + * + * @class Matrix3 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} [m] - Optional Matrix3 to copy values from. + */ +var Matrix3 = new Class({ + + initialize: + + function Matrix3 (m) + { + /** + * The matrix values. + * + * @name Phaser.Math.Matrix3#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(9); + + if (m) + { + // Assume Matrix3 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * Make a clone of this Matrix3. + * + * @method Phaser.Math.Matrix3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} A clone of this Matrix3. + */ + clone: function () + { + return new Matrix3(this); + }, + + /** + * This method is an alias for `Matrix3.copy`. + * + * @method Phaser.Math.Matrix3#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to set the values of this Matrix's from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * Copy the values of a given Matrix into this Matrix. + * + * @method Phaser.Math.Matrix3#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * Copy the values of a given Matrix4 into this Matrix3. + * + * @method Phaser.Math.Matrix3#fromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - The Matrix4 to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromMat4: function (m) + { + var a = m.val; + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; + + return this; + }, + + /** + * Set the values of this Matrix from the given array. + * + * @method Phaser.Math.Matrix3#fromArray + * @since 3.0.0 + * + * @param {array} a - The array to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * Reset this Matrix to an identity (default) matrix. + * + * @method Phaser.Math.Matrix3#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + + return this; + }, + + /** + * Transpose this Matrix. + * + * @method Phaser.Math.Matrix3#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + transpose: function () + { + var a = this.val; + var a01 = a[1]; + var a02 = a[2]; + var a12 = a[5]; + + a[1] = a[3]; + a[2] = a[6]; + a[3] = a01; + a[5] = a[7]; + a[6] = a02; + a[7] = a12; + + return this; + }, + + /** + * Invert this Matrix. + * + * @method Phaser.Math.Matrix3#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b01 = a22 * a11 - a12 * a21; + var b11 = -a22 * a10 + a12 * a20; + var b21 = a21 * a10 - a11 * a20; + + // Calculate the determinant + var det = a00 * b01 + a01 * b11 + a02 * b21; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = b01 * det; + a[1] = (-a22 * a01 + a02 * a21) * det; + a[2] = (a12 * a01 - a02 * a11) * det; + a[3] = b11 * det; + a[4] = (a22 * a00 - a02 * a20) * det; + a[5] = (-a12 * a00 + a02 * a10) * det; + a[6] = b21 * det; + a[7] = (-a21 * a00 + a01 * a20) * det; + a[8] = (a11 * a00 - a01 * a10) * det; + + return this; + }, + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + * + * @method Phaser.Math.Matrix3#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + a[0] = (a11 * a22 - a12 * a21); + a[1] = (a02 * a21 - a01 * a22); + a[2] = (a01 * a12 - a02 * a11); + a[3] = (a12 * a20 - a10 * a22); + a[4] = (a00 * a22 - a02 * a20); + a[5] = (a02 * a10 - a00 * a12); + a[6] = (a10 * a21 - a11 * a20); + a[7] = (a01 * a20 - a00 * a21); + a[8] = (a00 * a11 - a01 * a10); + + return this; + }, + + /** + * Calculate the determinant of this Matrix. + * + * @method Phaser.Math.Matrix3#determinant + * @since 3.0.0 + * + * @return {number} The determinant of this Matrix. + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * @method Phaser.Math.Matrix3#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to multiply this Matrix by. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b = src.val; + + var b00 = b[0]; + var b01 = b[1]; + var b02 = b[2]; + var b10 = b[3]; + var b11 = b[4]; + var b12 = b[5]; + var b20 = b[6]; + var b21 = b[7]; + var b22 = b[8]; + + a[0] = b00 * a00 + b01 * a10 + b02 * a20; + a[1] = b00 * a01 + b01 * a11 + b02 * a21; + a[2] = b00 * a02 + b01 * a12 + b02 * a22; + + a[3] = b10 * a00 + b11 * a10 + b12 * a20; + a[4] = b10 * a01 + b11 * a11 + b12 * a21; + a[5] = b10 * a02 + b11 * a12 + b12 * a22; + + a[6] = b20 * a00 + b21 * a10 + b22 * a20; + a[7] = b20 * a01 + b21 * a11 + b22 * a21; + a[8] = b20 * a02 + b21 * a12 + b22 * a22; + + return this; + }, + + /** + * Translate this Matrix using the given Vector. + * + * @method Phaser.Math.Matrix3#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + translate: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[6] = x * a[0] + y * a[3] + a[6]; + a[7] = x * a[1] + y * a[4] + a[7]; + a[8] = x * a[2] + y * a[5] + a[8]; + + return this; + }, + + /** + * Apply a rotation transformation to this Matrix. + * + * @method Phaser.Math.Matrix3#rotate + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + rotate: function (rad) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + + var s = Math.sin(rad); + var c = Math.cos(rad); + + a[0] = c * a00 + s * a10; + a[1] = c * a01 + s * a11; + a[2] = c * a02 + s * a12; + + a[3] = c * a10 - s * a00; + a[4] = c * a11 - s * a01; + a[5] = c * a12 - s * a02; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x` and `y` components of the given Vector to scale the Matrix. + * + * @method Phaser.Math.Matrix3#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + scale: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[0] = x * a[0]; + a[1] = x * a[1]; + a[2] = x * a[2]; + + a[3] = y * a[3]; + a[4] = y * a[4]; + a[5] = y * a[5]; + + return this; + }, + + /** + * Set the values of this Matrix from the given Quaternion. + * + * @method Phaser.Math.Matrix3#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromQuat: function (q) + { + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + var out = this.val; + + out[0] = 1 - (yy + zz); + out[3] = xy + wz; + out[6] = xz - wy; + + out[1] = xy - wz; + out[4] = 1 - (xx + zz); + out[7] = yz + wx; + + out[2] = xz + wy; + out[5] = yz - wx; + out[8] = 1 - (xx + yy); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#normalFromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + normalFromMat4: function (m) + { + var a = m.val; + var out = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + + return this; + } + +}); + +module.exports = Matrix3; + + +/***/ }), +/* 242 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rotate a given point by a given angle around the origin (0, 0), in an anti-clockwise direction. + * + * @function Phaser.Math.Rotate + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. + * @param {number} angle - The angle to be rotated by in an anticlockwise direction. + * + * @return {Phaser.Geom.Point} The given point, rotated by the given angle in an anticlockwise direction. + */ +var Rotate = function (point, angle) +{ + var x = point.x; + var y = point.y; + + point.x = (x * Math.cos(angle)) - (y * Math.sin(angle)); + point.y = (x * Math.sin(angle)) + (y * Math.cos(angle)); + + return point; +}; + +module.exports = Rotate; + + +/***/ }), +/* 243 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Snap a value to nearest grid slice, using ceil. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `15`. + * As will `14` snap to `15`... but `16` will snap to `20`. + * + * @function Phaser.Math.Snap.Ceil + * @since 3.0.0 + * + * @param {number} value - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. + * + * @return {number} The snapped value. + */ +var SnapCeil = function (value, gap, start, divide) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.ceil(value / gap); + + return (divide) ? (start + value) / gap : start + value; +}; + +module.exports = SnapCeil; + + +/***/ }), +/* 244 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the factorial of a given number for integer values greater than 0. + * + * @function Phaser.Math.Factorial + * @since 3.0.0 + * + * @param {number} value - A positive integer to calculate the factorial of. + * + * @return {number} The factorial of the given number. + */ +var Factorial = function (value) +{ + if (value === 0) + { + return 1; + } + + var res = value; + + while (--value) + { + res *= value; + } + + return res; +}; + +module.exports = Factorial; + + +/***/ }), +/* 245 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Factorial = __webpack_require__(244); + +/** + * [description] + * + * @function Phaser.Math.Bernstein + * @since 3.0.0 + * + * @param {number} n - [description] + * @param {number} i - [description] + * + * @return {number} [description] + */ +var Bernstein = function (n, i) +{ + return Factorial(n) / Factorial(i) / Factorial(n - i); +}; + +module.exports = Bernstein; + + +/***/ }), +/* 246 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check whether `a` is fuzzily less than `b`. + * + * `a` is fuzzily less than `b` if it is less than `b + epsilon`. + * + * @function Phaser.Math.Fuzzy.LessThan + * @since 3.0.0 + * + * @param {number} a - The first value. + * @param {number} b - The second value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {boolean} `true` if `a` is fuzzily less than `b`, otherwise `false`. + */ +var LessThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a < b + epsilon; +}; + +module.exports = LessThan; + + +/***/ }), +/* 247 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check whether `a` is fuzzily greater than `b`. + * + * `a` is fuzzily greater than `b` if it is more than `b - epsilon`. + * + * @function Phaser.Math.Fuzzy.GreaterThan + * @since 3.0.0 + * + * @param {number} a - The first value. + * @param {number} b - The second value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {boolean} `true` if `a` is fuzzily greater than than `b`, otherwise `false`. + */ +var GreaterThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a > b - epsilon; +}; + +module.exports = GreaterThan; + + +/***/ }), +/* 248 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check whether the given values are fuzzily equal. + * + * Two numbers are fuzzily equal if their difference is less than `epsilon`. + * + * @function Phaser.Math.Fuzzy.Equal + * @since 3.0.0 + * + * @param {number} a - The first value. + * @param {number} b - The second value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {boolean} `true` if the values are fuzzily equal, otherwise `false`. + */ +var Equal = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.abs(a - b) < epsilon; +}; + +module.exports = Equal; + + +/***/ }), +/* 249 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the distance between two sets of coordinates (points), squared. + * + * @function Phaser.Math.Distance.Squared + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The distance between each point, squared. + */ +var DistanceSquared = function (x1, y1, x2, y2) +{ + var dx = x1 - x2; + var dy = y1 - y2; + + return dx * dx + dy * dy; +}; + +module.exports = DistanceSquared; + + +/***/ }), +/* 250 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Normalize an angle to the [0, 2pi] range. + * + * @function Phaser.Math.Angle.Normalize + * @since 3.0.0 + * + * @param {number} angle - The angle to normalize, in radians. + * + * @return {number} The normalized angle, in radians. + */ +var Normalize = function (angle) +{ + angle = angle % (2 * Math.PI); + + if (angle >= 0) + { + return angle; + } + else + { + return angle + 2 * Math.PI; + } +}; + +module.exports = Normalize; + + +/***/ }), +/* 251 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TextFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='txt'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Text File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. + * + * @class TextFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TextFile = new Class({ + + Extends: File, + + initialize: + + function TextFile (loader, key, url, xhrSettings) + { + var extension = 'txt'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'text', + cache: loader.cacheManager.text, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.TextFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Text file, or array of Text files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.text('story', 'files/IntroStory.txt'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Text Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Text Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.text({ + * key: 'story', + * url: 'files/IntroStory.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.text('story', 'files/IntroStory.txt'); + * // and later in your game ... + * var data = this.cache.text.get('story'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Text Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.txt". It will always add `.txt` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Text File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#text + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig|Phaser.Loader.FileTypes.TextFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('text', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TextFile(this, key[i])); + } + } + else + { + this.addFile(new TextFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TextFile; + + +/***/ }), +/* 252 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var File = __webpack_require__(21); +var GetFastValue = __webpack_require__(2); +var GetURL = __webpack_require__(141); var IsPlainObject = __webpack_require__(8); /** @@ -35034,7 +60581,7 @@ var IsPlainObject = __webpack_require__(8); * * @class HTML5AudioFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -35205,7 +60752,7 @@ module.exports = HTML5AudioFile; /***/ }), -/* 168 */ +/* 253 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -35215,11 +60762,11 @@ module.exports = HTML5AudioFile; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var File = __webpack_require__(19); +var CONST = __webpack_require__(26); +var File = __webpack_require__(21); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var HTML5AudioFile = __webpack_require__(167); +var GetFastValue = __webpack_require__(2); +var HTML5AudioFile = __webpack_require__(252); var IsPlainObject = __webpack_require__(8); /** @@ -35241,7 +60788,7 @@ var IsPlainObject = __webpack_require__(8); * * @class AudioFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -35307,7 +60854,7 @@ var AudioFile = new Class({ function (e) { // eslint-disable-next-line no-console - console.error('Error decoding audio: ' + this.key + ' - ', e.message); + console.error('Error decoding audio: ' + this.key + ' - ', e ? e.message : null); _this.onProcessError(); } @@ -35485,7 +61032,7 @@ module.exports = AudioFile; /***/ }), -/* 169 */ +/* 254 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -35494,7 +61041,7 @@ module.exports = AudioFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MergeXHRSettings = __webpack_require__(107); +var MergeXHRSettings = __webpack_require__(140); /** * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings @@ -35553,7 +61100,7 @@ module.exports = XHRLoader; /***/ }), -/* 170 */ +/* 255 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -35563,9 +61110,9 @@ module.exports = XHRLoader; */ var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); -var ProcessKeyCombo = __webpack_require__(372); -var ResetKeyCombo = __webpack_require__(370); +var GetFastValue = __webpack_require__(2); +var ProcessKeyCombo = __webpack_require__(605); +var ResetKeyCombo = __webpack_require__(603); /** * @callback KeyboardKeydownCallback @@ -35593,11 +61140,11 @@ var ResetKeyCombo = __webpack_require__(370); * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); @@ -35611,7 +61158,7 @@ var ResetKeyCombo = __webpack_require__(370); * ``` * * @class KeyCombo - * @memberOf Phaser.Input.Keyboard + * @memberof Phaser.Input.Keyboard * @constructor * @since 3.0.0 * @@ -35824,7 +61371,7 @@ var KeyCombo = new Class({ * * @name Phaser.Input.Keyboard.KeyCombo#progress * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ progress: { @@ -35858,7 +61405,7 @@ module.exports = KeyCombo; /***/ }), -/* 171 */ +/* 256 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -35875,7 +61422,7 @@ var Class = __webpack_require__(0); * keycode must be an integer * * @class Key - * @memberOf Phaser.Input.Keyboard + * @memberof Phaser.Input.Keyboard * @constructor * @since 3.0.0 * @@ -35996,9 +61543,7 @@ var Key = new Class({ this.timeDown = 0; /** - * The number of milliseconds this key has been held down for. - * If the key is down this value holds the duration of that key press and is constantly updated. - * If the key is up it holds the duration of the previous down session. + * The number of milliseconds this key was held down for in the previous down - up sequence. * * @name Phaser.Input.Keyboard.Key#duration * @type {number} @@ -36048,6 +61593,16 @@ var Key = new Class({ * @since 3.0.0 */ this._justUp = false; + + /** + * Internal tick counter. + * + * @name Phaser.Input.Keyboard.Key#_tick + * @type {number} + * @private + * @since 3.11.0 + */ + this._tick = -1; }, /** @@ -36073,6 +61628,7 @@ var Key = new Class({ this.repeats = 0; this._justDown = false; this._justUp = false; + this._tick = -1; return this; } @@ -36083,7 +61639,7 @@ module.exports = Key; /***/ }), -/* 172 */ +/* 257 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -36092,11 +61648,11 @@ module.exports = Key; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Axis = __webpack_require__(174); -var Button = __webpack_require__(173); +var Axis = __webpack_require__(259); +var Button = __webpack_require__(258); var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Vector2 = __webpack_require__(6); +var EventEmitter = __webpack_require__(11); +var Vector2 = __webpack_require__(3); /** * @classdesc @@ -36106,7 +61662,7 @@ var Vector2 = __webpack_require__(6); * * @class Gamepad * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.0.0 * @@ -36841,7 +62397,7 @@ module.exports = Gamepad; /***/ }), -/* 173 */ +/* 258 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -36858,7 +62414,7 @@ var Class = __webpack_require__(0); * Button objects are created automatically by the Gamepad as they are needed. * * @class Button - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.0.0 * @@ -36902,7 +62458,7 @@ var Button = new Class({ * Between 0 and 1. * * @name Phaser.Input.Gamepad.Button#value - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -36913,7 +62469,7 @@ var Button = new Class({ * before a button is considered as being 'pressed'. * * @name Phaser.Input.Gamepad.Button#threshold - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -36982,7 +62538,7 @@ module.exports = Button; /***/ }), -/* 174 */ +/* 259 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -36999,7 +62555,7 @@ var Class = __webpack_require__(0); * Axis objects are created automatically by the Gamepad as they are needed. * * @class Axis - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.0.0 * @@ -37044,7 +62600,7 @@ var Axis = new Class({ * Use the method `getValue` to get a normalized value with the threshold applied. * * @name Phaser.Input.Gamepad.Axis#value - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -37054,7 +62610,7 @@ var Axis = new Class({ * Movement tolerance threshold below which axis values are ignored in `getValue`. * * @name Phaser.Input.Gamepad.Axis#threshold - * @type {float} + * @type {number} * @default 0.1 * @since 3.0.0 */ @@ -37069,7 +62625,7 @@ var Axis = new Class({ * @private * @since 3.0.0 * - * @param {float} value - The value of the axis movement. + * @param {number} value - The value of the axis movement. */ update: function (value) { @@ -37082,7 +62638,7 @@ var Axis = new Class({ * @method Phaser.Input.Gamepad.Axis#getValue * @since 3.0.0 * - * @return {float} The axis value, adjusted for the movement threshold. + * @return {number} The axis value, adjusted for the movement threshold. */ getValue: function () { @@ -37107,7 +62663,7 @@ module.exports = Axis; /***/ }), -/* 175 */ +/* 260 */ /***/ (function(module, exports) { /** @@ -37203,7 +62759,7 @@ module.exports = CreateInteractiveObject; /***/ }), -/* 176 */ +/* 261 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37212,8 +62768,8019 @@ module.exports = CreateInteractiveObject; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Commands = __webpack_require__(119); -var GameObject = __webpack_require__(2); +var Point = __webpack_require__(6); + +// The three angle bisectors of a triangle meet in one point called the incenter. +// It is the center of the incircle, the circle inscribed in the triangle. + +function getLength (x1, y1, x2, y2) +{ + var x = x1 - x2; + var y = y1 - y2; + var magnitude = (x * x) + (y * y); + + return Math.sqrt(magnitude); +} + +/** + * [description] + * + * @function Phaser.Geom.Triangle.InCenter + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var InCenter = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = triangle.x1; + var y1 = triangle.y1; + + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + var d1 = getLength(x3, y3, x2, y2); + var d2 = getLength(x1, y1, x3, y3); + var d3 = getLength(x2, y2, x1, y1); + + var p = d1 + d2 + d3; + + out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; + out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; + + return out; +}; + +module.exports = InCenter; + + +/***/ }), +/* 262 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Offset = function (triangle, x, y) +{ + triangle.x1 += x; + triangle.y1 += y; + + triangle.x2 += x; + triangle.y2 += y; + + triangle.x3 += x; + triangle.y3 += y; + + return triangle; +}; + +module.exports = Offset; + + +/***/ }), +/* 263 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) +// meet in the centroid or center of mass (center of gravity). +// The centroid divides each median in a ratio of 2:1 + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Centroid + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Centroid = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; + out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; + + return out; +}; + +module.exports = Centroid; + + +/***/ }), +/* 264 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Checks if rectB is fully contained within rectA + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var ContainsRect = function (rectA, rectB) +{ + // Volume check (if rectB volume > rectA then rectA cannot contain it) + if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) + { + return false; + } + + return ( + (rectB.x > rectA.x && rectB.x < rectA.right) && + (rectB.right > rectA.x && rectB.right < rectA.right) && + (rectB.y > rectA.y && rectB.y < rectA.bottom) && + (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 265 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +Rectangle.Area = __webpack_require__(656); +Rectangle.Ceil = __webpack_require__(655); +Rectangle.CeilAll = __webpack_require__(654); +Rectangle.CenterOn = __webpack_require__(175); +Rectangle.Clone = __webpack_require__(653); +Rectangle.Contains = __webpack_require__(39); +Rectangle.ContainsPoint = __webpack_require__(652); +Rectangle.ContainsRect = __webpack_require__(264); +Rectangle.CopyFrom = __webpack_require__(651); +Rectangle.Decompose = __webpack_require__(270); +Rectangle.Equals = __webpack_require__(650); +Rectangle.FitInside = __webpack_require__(649); +Rectangle.FitOutside = __webpack_require__(648); +Rectangle.Floor = __webpack_require__(647); +Rectangle.FloorAll = __webpack_require__(646); +Rectangle.FromPoints = __webpack_require__(173); +Rectangle.GetAspectRatio = __webpack_require__(145); +Rectangle.GetCenter = __webpack_require__(645); +Rectangle.GetPoint = __webpack_require__(190); +Rectangle.GetPoints = __webpack_require__(398); +Rectangle.GetSize = __webpack_require__(644); +Rectangle.Inflate = __webpack_require__(643); +Rectangle.Intersection = __webpack_require__(642); +Rectangle.MarchingAnts = __webpack_require__(388); +Rectangle.MergePoints = __webpack_require__(641); +Rectangle.MergeRect = __webpack_require__(640); +Rectangle.MergeXY = __webpack_require__(639); +Rectangle.Offset = __webpack_require__(638); +Rectangle.OffsetPoint = __webpack_require__(637); +Rectangle.Overlaps = __webpack_require__(636); +Rectangle.Perimeter = __webpack_require__(124); +Rectangle.PerimeterPoint = __webpack_require__(635); +Rectangle.Random = __webpack_require__(187); +Rectangle.RandomOutside = __webpack_require__(634); +Rectangle.SameDimensions = __webpack_require__(633); +Rectangle.Scale = __webpack_require__(632); +Rectangle.Union = __webpack_require__(309); + +module.exports = Rectangle; + + +/***/ }), +/* 266 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitudeSq + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitudeSq = function (point) +{ + return (point.x * point.x) + (point.y * point.y); +}; + +module.exports = GetMagnitudeSq; + + +/***/ }), +/* 267 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitude + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitude = function (point) +{ + return Math.sqrt((point.x * point.x) + (point.y * point.y)); +}; + +module.exports = GetMagnitude; + + +/***/ }), +/* 268 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Wrap = __webpack_require__(53); +var Angle = __webpack_require__(68); + +/** + * Get the angle of the normal of the given line in radians. + * + * @function Phaser.Geom.Line.NormalAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the angle of the normal of. + * + * @return {number} The angle of the normal of the line in radians. + */ +var NormalAngle = function (line) +{ + var angle = Angle(line) - MATH_CONST.TAU; + + return Wrap(angle, -Math.PI, Math.PI); +}; + +module.exports = NormalAngle; + + +/***/ }), +/* 269 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {array} [out] - [description] + * + * @return {array} [description] + */ +var Decompose = function (triangle, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: triangle.x1, y: triangle.y1 }); + out.push({ x: triangle.x2, y: triangle.y2 }); + out.push({ x: triangle.x3, y: triangle.y3 }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 270 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Create an array of points for each corner of a Rectangle + * If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created. + * + * @function Phaser.Geom.Rectangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object to be decomposed. + * @param {array} [out] - If provided, each point will be added to this array. + * + * @return {array} Will return the array you specified or a new array containing the points of the Rectangle. + */ +var Decompose = function (rect, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: rect.x, y: rect.y }); + out.push({ x: rect.right, y: rect.y }); + out.push({ x: rect.right, y: rect.bottom }); + out.push({ x: rect.x, y: rect.bottom }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 271 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.PointToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var PointToLine = function (point, line) +{ + return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); +}; + +module.exports = PointToLine; + + +/***/ }), +/* 272 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on code by Matt DesLauriers +// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md + +var Contains = __webpack_require__(40); +var Point = __webpack_require__(6); + +var tmp = new Point(); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.LineToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Point} [nearest] - [description] + * + * @return {boolean} [description] + */ +var LineToCircle = function (line, circle, nearest) +{ + if (nearest === undefined) { nearest = tmp; } + + if (Contains(circle, line.x1, line.y1)) + { + nearest.x = line.x1; + nearest.y = line.y1; + + return true; + } + + if (Contains(circle, line.x2, line.y2)) + { + nearest.x = line.x2; + nearest.y = line.y2; + + return true; + } + + var dx = line.x2 - line.x1; + var dy = line.y2 - line.y1; + + var lcx = circle.x - line.x1; + var lcy = circle.y - line.y1; + + // project lc onto d, resulting in vector p + var dLen2 = (dx * dx) + (dy * dy); + var px = dx; + var py = dy; + + if (dLen2 > 0) + { + var dp = ((lcx * dx) + (lcy * dy)) / dLen2; + + px *= dp; + py *= dp; + } + + nearest.x = line.x1 + px; + nearest.y = line.y1 + py; + + // len2 of p + var pLen2 = (px * px) + (py * py); + + return ( + pLen2 <= dLen2 && + ((px * dx) + (py * dy)) >= 0 && + Contains(circle, nearest.x, nearest.y) + ); +}; + +module.exports = LineToCircle; + + +/***/ }), +/* 273 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom.Intersects + */ + +module.exports = { + + CircleToCircle: __webpack_require__(703), + CircleToRectangle: __webpack_require__(702), + GetRectangleIntersection: __webpack_require__(701), + LineToCircle: __webpack_require__(272), + LineToLine: __webpack_require__(107), + LineToRectangle: __webpack_require__(700), + PointToLine: __webpack_require__(271), + PointToLineSegment: __webpack_require__(699), + RectangleToRectangle: __webpack_require__(148), + RectangleToTriangle: __webpack_require__(698), + RectangleToValues: __webpack_require__(697), + TriangleToCircle: __webpack_require__(696), + TriangleToLine: __webpack_require__(695), + TriangleToTriangle: __webpack_require__(694) + +}; + + +/***/ }), +/* 274 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom + */ + +module.exports = { + + Circle: __webpack_require__(723), + Ellipse: __webpack_require__(713), + Intersects: __webpack_require__(273), + Line: __webpack_require__(693), + Point: __webpack_require__(675), + Polygon: __webpack_require__(661), + Rectangle: __webpack_require__(265), + Triangle: __webpack_require__(631) + +}; + + +/***/ }), +/* 275 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Light = __webpack_require__(276); +var Utils = __webpack_require__(10); + +/** + * @callback LightForEach + * + * @param {Phaser.GameObjects.Light} light - The Light. + */ + +/** + * @classdesc + * Manages Lights for a Scene. + * + * Affects the rendering of Game Objects using the `Light2D` pipeline. + * + * @class LightsManager + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + */ +var LightsManager = new Class({ + + initialize: + + function LightsManager () + { + /** + * The pool of Lights. + * + * Used to recycle removed Lights for a more efficient use of memory. + * + * @name Phaser.GameObjects.LightsManager#lightPool + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lightPool = []; + + /** + * The Lights in the Scene. + * + * @name Phaser.GameObjects.LightsManager#lights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lights = []; + + /** + * Lights that have been culled from a Camera's viewport. + * + * Lights in this list will not be rendered. + * + * @name Phaser.GameObjects.LightsManager#culledLights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.culledLights = []; + + /** + * The ambient color. + * + * @name Phaser.GameObjects.LightsManager#ambientColor + * @type {{ r: number, g: number, b: number }} + * @since 3.0.0 + */ + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + + /** + * Whether the Lights Manager is enabled. + * + * @name Phaser.GameObjects.LightsManager#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + + /** + * The maximum number of lights that a single Camera and the lights shader can process. + * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. + * + * @name Phaser.GameObjects.LightsManager#maxLights + * @type {integer} + * @readonly + * @since 3.15.0 + */ + this.maxLights = -1; + }, + + /** + * Enable the Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#enable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + enable: function () + { + if (this.maxLights === -1) + { + this.maxLights = this.scene.sys.game.renderer.config.maxLights; + } + + this.active = true; + + return this; + }, + + /** + * Disable the Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#disable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + disable: function () + { + this.active = false; + + return this; + }, + + /** + * Cull any Lights that aren't visible to the given Camera. + * + * Culling Lights improves performance by ensuring that only Lights within a Camera's viewport are rendered. + * + * @method Phaser.GameObjects.LightsManager#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to cull Lights for. + * + * @return {Phaser.GameObjects.Light[]} The culled Lights. + */ + cull: function (camera) + { + var lights = this.lights; + var culledLights = this.culledLights; + var length = lights.length; + var cameraCenterX = camera.x + camera.width / 2.0; + var cameraCenterY = camera.y + camera.height / 2.0; + var cameraRadius = (camera.width + camera.height) / 2.0; + var point = { x: 0, y: 0 }; + var cameraMatrix = camera.matrix; + var viewportHeight = this.systems.game.config.height; + + culledLights.length = 0; + + for (var index = 0; index < length && culledLights.length < this.maxLights; index++) + { + var light = lights[index]; + + cameraMatrix.transformPoint(light.x, light.y, point); + + // We'll just use bounding spheres to test if lights should be rendered + var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); + var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + var distance = Math.sqrt(dx * dx + dy * dy); + + if (distance < light.radius + cameraRadius) + { + culledLights.push(lights[index]); + } + } + + return culledLights; + }, + + /** + * Iterate over each Light with a callback. + * + * @method Phaser.GameObjects.LightsManager#forEachLight + * @since 3.0.0 + * + * @param {LightForEach} callback - The callback that is called with each Light. + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + forEachLight: function (callback) + { + if (!callback) + { + return; + } + + var lights = this.lights; + var length = lights.length; + + for (var index = 0; index < length; ++index) + { + callback(lights[index]); + } + + return this; + }, + + /** + * Set the ambient light color. + * + * @method Phaser.GameObjects.LightsManager#setAmbientColor + * @since 3.0.0 + * + * @param {number} rgb - The integer RGB color of the ambient light. + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + setAmbientColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.ambientColor.r = color[0]; + this.ambientColor.g = color[1]; + this.ambientColor.b = color[2]; + + return this; + }, + + /** + * Returns the maximum number of Lights allowed to appear at once. + * + * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights + * @since 3.0.0 + * + * @return {integer} The maximum number of Lights allowed to appear at once. + */ + getMaxVisibleLights: function () + { + return 10; + }, + + /** + * Get the number of Lights managed by this Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#getLightCount + * @since 3.0.0 + * + * @return {integer} The number of Lights managed by this Lights Manager. + */ + getLightCount: function () + { + return this.lights.length; + }, + + /** + * Add a Light. + * + * @method Phaser.GameObjects.LightsManager#addLight + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal position of the Light. + * @param {number} [y=0] - The vertical position of the Light. + * @param {number} [radius=100] - The radius of the Light. + * @param {number} [rgb=0xffffff] - The integer RGB color of the light. + * @param {number} [intensity=1] - The intensity of the Light. + * + * @return {Phaser.GameObjects.Light} The Light that was added. + */ + addLight: function (x, y, radius, rgb, intensity) + { + var color = null; + var light = null; + + x = (x === undefined) ? 0.0 : x; + y = (y === undefined) ? 0.0 : y; + rgb = (rgb === undefined) ? 0xffffff : rgb; + radius = (radius === undefined) ? 100.0 : radius; + intensity = (intensity === undefined) ? 1.0 : intensity; + + color = Utils.getFloatsFromUintRGB(rgb); + light = null; + + if (this.lightPool.length > 0) + { + light = this.lightPool.pop(); + light.set(x, y, radius, color[0], color[1], color[2], intensity); + } + else + { + light = new Light(x, y, radius, color[0], color[1], color[2], intensity); + } + + this.lights.push(light); + + return light; + }, + + /** + * Remove a Light. + * + * @method Phaser.GameObjects.LightsManager#removeLight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Light} light - The Light to remove. + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + removeLight: function (light) + { + var index = this.lights.indexOf(light); + + if (index >= 0) + { + this.lightPool.push(light); + this.lights.splice(index, 1); + } + + return this; + }, + + /** + * Shut down the Lights Manager. + * + * Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and + * culled Lights. + * + * @method Phaser.GameObjects.LightsManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + while (this.lights.length > 0) + { + this.lightPool.push(this.lights.pop()); + } + + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + this.culledLights.length = 0; + this.lights.length = 0; + }, + + /** + * Destroy the Lights Manager. + * + * Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}. + * + * @method Phaser.GameObjects.LightsManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + } + +}); + +module.exports = LightsManager; + + +/***/ }), +/* 276 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(10); + +/** + * @classdesc + * A 2D point light. + * + * These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`. + * + * Any Game Objects using the Light2D pipeline will then be affected by these Lights. + * + * They can also simply be used to represent a point light for your own purposes. + * + * @class Light + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color of the light. A value between 0 and 1. + * @param {number} g - The green color of the light. A value between 0 and 1. + * @param {number} b - The blue color of the light. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + */ +var Light = new Class({ + + initialize: + + function Light (x, y, radius, r, g, b, intensity) + { + /** + * The horizontal position of the light. + * + * @name Phaser.GameObjects.Light#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The vertical position of the light. + * + * @name Phaser.GameObjects.Light#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The radius of the light. + * + * @name Phaser.GameObjects.Light#radius + * @type {number} + * @since 3.0.0 + */ + this.radius = radius; + + /** + * The red color of the light. A value between 0 and 1. + * + * @name Phaser.GameObjects.Light#r + * @type {number} + * @since 3.0.0 + */ + this.r = r; + + /** + * The green color of the light. A value between 0 and 1. + * + * @name Phaser.GameObjects.Light#g + * @type {number} + * @since 3.0.0 + */ + this.g = g; + + /** + * The blue color of the light. A value between 0 and 1. + * + * @name Phaser.GameObjects.Light#b + * @type {number} + * @since 3.0.0 + */ + this.b = b; + + /** + * The intensity of the light. + * + * @name Phaser.GameObjects.Light#intensity + * @type {number} + * @since 3.0.0 + */ + this.intensity = intensity; + + /** + * The horizontal scroll factor of the light. + * + * @name Phaser.GameObjects.Light#scrollFactorX + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorX = 1.0; + + /** + * The vertical scroll factor of the light. + * + * @name Phaser.GameObjects.Light#scrollFactorY + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorY = 1.0; + }, + + /** + * Set the properties of the light. + * + * Sets both horizontal and vertical scroll factor to 1. Use {@link Phaser.GameObjects.Light#setScrollFactor} to set + * the scroll factor. + * + * @method Phaser.GameObjects.Light#set + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color. A value between 0 and 1. + * @param {number} g - The green color. A value between 0 and 1. + * @param {number} b - The blue color. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + set: function (x, y, radius, r, g, b, intensity) + { + this.x = x; + this.y = y; + + this.radius = radius; + + this.r = r; + this.g = g; + this.b = b; + + this.intensity = intensity; + + this.scrollFactorX = 1; + this.scrollFactorY = 1; + + return this; + }, + + /** + * Set the scroll factor of the light. + * + * @method Phaser.GameObjects.Light#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of the light. + * @param {number} y - The vertical scroll factor of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setScrollFactor: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + }, + + /** + * Set the color of the light from a single integer RGB value. + * + * @method Phaser.GameObjects.Light#setColor + * @since 3.0.0 + * + * @param {number} rgb - The integer RGB color of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.r = color[0]; + this.g = color[1]; + this.b = color[2]; + + return this; + }, + + /** + * Set the intensity of the light. + * + * @method Phaser.GameObjects.Light#setIntensity + * @since 3.0.0 + * + * @param {number} intensity - The intensity of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setIntensity: function (intensity) + { + this.intensity = intensity; + + return this; + }, + + /** + * Set the position of the light. + * + * @method Phaser.GameObjects.Light#setPosition + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setPosition: function (x, y) + { + this.x = x; + this.y = y; + + return this; + }, + + /** + * Set the radius of the light. + * + * @method Phaser.GameObjects.Light#setRadius + * @since 3.0.0 + * + * @param {number} radius - The radius of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setRadius: function (radius) + { + this.radius = radius; + + return this; + } + +}); + +module.exports = Light; + + +/***/ }), +/* 277 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); +var Point = __webpack_require__(6); + +/** + * Returns an array of evenly spaced points on the perimeter of a Triangle. + * + * @function Phaser.Geom.Triangle.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the points from. + * @param {integer} quantity - The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. + * @param {number} stepRate - If `quantity` is 0, the distance between each returned point. + * @param {(array|Phaser.Geom.Point[])} [out] - An array to which the points should be appended. + * + * @return {(array|Phaser.Geom.Point[])} The modified `out` array, or a new array if none was provided. + */ +var GetPoints = function (triangle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var p = perimeter * (i / quantity); + var localPosition = 0; + + var point = new Point(); + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + out.push(point); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 278 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); +var Length = __webpack_require__(65); + +// Position is a value between 0 and 1 +/** + * [description] + * + * @function Phaser.Geom.Triangle.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} position - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetPoint = function (triangle, position, out) +{ + if (out === undefined) { out = new Point(); } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + if (position <= 0 || position >= 1) + { + out.x = line1.x1; + out.y = line1.y1; + + return out; + } + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + var p = perimeter * position; + var localPosition = 0; + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 279 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Shape = __webpack_require__(27); +var GeomTriangle = __webpack_require__(59); +var TriangleRender = __webpack_require__(772); + +/** + * @classdesc + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @class Triangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Triangle = new Class({ + + Extends: Shape, + + Mixins: [ + TriangleRender + ], + + initialize: + + function Triangle (scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 128; } + if (x2 === undefined) { x2 = 64; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 128; } + if (y3 === undefined) { y3 = 128; } + + Shape.call(this, scene, 'Triangle', new GeomTriangle(x1, y1, x2, y2, x3, y3)); + + var width = this.geom.right - this.geom.left; + var height = this.geom.bottom - this.geom.top; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the data for the lines that make up this Triangle shape. + * + * @method Phaser.GameObjects.Triangle#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=0] - The vertical position of the first point in the triangle. + * @param {number} [x2=0] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=0] - The horizontal position of the third point in the triangle. + * @param {number} [y3=0] - The vertical position of the third point in the triangle. + * + * @return {this} This Game Object instance. + */ + setTo: function (x1, y1, x2, y2, x3, y3) + { + this.geom.setTo(x1, y1, x2, y2, x3, y3); + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Triangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var rect = this.geom; + var line = this._tempLine; + + rect.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + rect.getLineB(line); + + path.push(line.x2, line.y2); + + rect.getLineC(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + } + +}); + +module.exports = Triangle; + + +/***/ }), +/* 280 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StarRender = __webpack_require__(775); +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(64); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @class Star + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star. + * @param {number} [outerRadius=64] - The outer radius of the star. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Star = new Class({ + + Extends: Shape, + + Mixins: [ + StarRender + ], + + initialize: + + function Star (scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (points === undefined) { points = 5; } + if (innerRadius === undefined) { innerRadius = 32; } + if (outerRadius === undefined) { outerRadius = 64; } + + Shape.call(this, scene, 'Star', null); + + /** + * Private internal value. + * The number of points in the star. + * + * @name Phaser.GameObjects.Star#_points + * @type {integer} + * @private + * @since 3.13.0 + */ + this._points = points; + + /** + * Private internal value. + * The inner radius of the star. + * + * @name Phaser.GameObjects.Star#_innerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._innerRadius = innerRadius; + + /** + * Private internal value. + * The outer radius of the star. + * + * @name Phaser.GameObjects.Star#_outerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._outerRadius = outerRadius; + + this.setPosition(x, y); + this.setSize(outerRadius * 2, outerRadius * 2); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the number of points that make up the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setPoints + * @since 3.13.0 + * + * @param {integer} value - The amount of points the Star will have. + * + * @return {this} This Game Object instance. + */ + setPoints: function (value) + { + this._points = value; + + return this.updateData(); + }, + + /** + * Sets the inner radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setInnerRadius + * @since 3.13.0 + * + * @param {number} value - The amount to set the inner radius to. + * + * @return {this} This Game Object instance. + */ + setInnerRadius: function (value) + { + this._innerRadius = value; + + return this.updateData(); + }, + + /** + * Sets the outer radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setOuterRadius + * @since 3.13.0 + * + * @param {number} value - The amount to set the outer radius to. + * + * @return {this} This Game Object instance. + */ + setOuterRadius: function (value) + { + this._outerRadius = value; + + return this.updateData(); + }, + + /** + * The number of points that make up the Star shape. + * + * @name Phaser.GameObjects.Star#points + * @type {integer} + * @default 5 + * @since 3.13.0 + */ + points: { + + get: function () + { + return this._points; + }, + + set: function (value) + { + this._points = value; + + this.updateData(); + } + + }, + + /** + * The inner radius of the Star shape. + * + * @name Phaser.GameObjects.Star#innerRadius + * @type {number} + * @default 32 + * @since 3.13.0 + */ + innerRadius: { + + get: function () + { + return this._innerRadius; + }, + + set: function (value) + { + this._innerRadius = value; + + this.updateData(); + } + + }, + + /** + * The outer radius of the Star shape. + * + * @name Phaser.GameObjects.Star#outerRadius + * @type {number} + * @default 64 + * @since 3.13.0 + */ + outerRadius: { + + get: function () + { + return this._outerRadius; + }, + + set: function (value) + { + this._outerRadius = value; + + this.updateData(); + } + + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Star#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + + var points = this._points; + var innerRadius = this._innerRadius; + var outerRadius = this._outerRadius; + + var rot = Math.PI / 2 * 3; + var step = Math.PI / points; + + // So origin 0.5 = the center of the star + var x = outerRadius; + var y = outerRadius; + + path.push(x, y + -outerRadius); + + for (var i = 0; i < points; i++) + { + path.push(x + Math.cos(rot) * outerRadius, y + Math.sin(rot) * outerRadius); + + rot += step; + + path.push(x + Math.cos(rot) * innerRadius, y + Math.sin(rot) * innerRadius); + + rot += step; + } + + path.push(x, y + -outerRadius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Star; + + +/***/ }), +/* 281 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GeomRectangle = __webpack_require__(9); +var Shape = __webpack_require__(27); +var RectangleRender = __webpack_require__(778); + +/** + * @classdesc + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @class Rectangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Rectangle = new Class({ + + Extends: Shape, + + Mixins: [ + RectangleRender + ], + + initialize: + + function Rectangle (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Rectangle', new GeomRectangle(0, 0, width, height)); + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Rectangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var rect = this.geom; + var line = this._tempLine; + + rect.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + rect.getLineB(line); + + path.push(line.x2, line.y2); + + rect.getLineC(line); + + path.push(line.x2, line.y2); + + rect.getLineD(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + } + +}); + +module.exports = Rectangle; + + +/***/ }), +/* 282 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Igor Ognichenko + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var copy = function (out, a) +{ + out[0] = a[0]; + out[1] = a[1]; + + return out; +}; + +/** + * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. + * + * @function Phaser.Geom.Polygon.Smooth + * @since 3.13.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The polygon to be smoothed. The polygon will be modified in-place and returned. + * + * @return {Phaser.Geom.Polygon} The input polygon. + */ +var Smooth = function (polygon) +{ + var i; + var points = []; + var data = polygon.points; + + for (i = 0; i < data.length; i++) + { + points.push([ data[i].x, data[i].y ]); + } + + var output = []; + + if (points.length > 0) + { + output.push(copy([ 0, 0 ], points[0])); + } + + for (i = 0; i < points.length - 1; i++) + { + var p0 = points[i]; + var p1 = points[i + 1]; + var p0x = p0[0]; + var p0y = p0[1]; + var p1x = p1[0]; + var p1y = p1[1]; + + output.push([ 0.85 * p0x + 0.15 * p1x, 0.85 * p0y + 0.15 * p1y ]); + output.push([ 0.15 * p0x + 0.85 * p1x, 0.15 * p0y + 0.85 * p1y ]); + } + + if (points.length > 1) + { + output.push(copy([ 0, 0 ], points[points.length - 1])); + } + + return polygon.setTo(output); +}; + +module.exports = Smooth; + + +/***/ }), +/* 283 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); +var Line = __webpack_require__(54); + +/** + * Returns the perimeter of the given Polygon. + * + * @function Phaser.Geom.Polygon.Perimeter + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the perimeter of. + * + * @return {number} The perimeter of the Polygon. + */ +var Perimeter = function (polygon) +{ + var points = polygon.points; + var perimeter = 0; + + for (var i = 0; i < points.length; i++) + { + var pointA = points[i]; + var pointB = points[(i + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + + perimeter += Length(line); + } + + return perimeter; +}; + +module.exports = Perimeter; + + +/***/ }), +/* 284 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); +var Line = __webpack_require__(54); +var Perimeter = __webpack_require__(283); + +/** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Polygon.GetPoints + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the perimeter of the Polygon. + */ +var GetPoints = function (polygon, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var points = polygon.points; + var perimeter = Perimeter(polygon); + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var position = perimeter * (i / quantity); + var accumulatedPerimeter = 0; + + for (var j = 0; j < points.length; j++) + { + var pointA = points[j]; + var pointB = points[(j + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + var length = Length(line); + + if (position < accumulatedPerimeter || position > accumulatedPerimeter + length) + { + accumulatedPerimeter += length; + continue; + } + + var point = line.getPoint((position - accumulatedPerimeter) / length); + out.push(point); + + break; + } + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 285 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * [description] + * + * @function Phaser.Geom.Polygon.GetAABB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {(Phaser.Geom.Rectangle|object)} [out] - [description] + * + * @return {(Phaser.Geom.Rectangle|object)} [description] + */ +var GetAABB = function (polygon, out) +{ + if (out === undefined) { out = new Rectangle(); } + + var minX = Infinity; + var minY = Infinity; + var maxX = -minX; + var maxY = -minY; + var p; + + for (var i = 0; i < polygon.points.length; i++) + { + p = polygon.points[i]; + + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; +}; + +module.exports = GetAABB; + + +/***/ }), +/* 286 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PolygonRender = __webpack_require__(781); +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(64); +var GetAABB = __webpack_require__(285); +var GeomPolygon = __webpack_require__(151); +var Shape = __webpack_require__(27); +var Smooth = __webpack_require__(282); + +/** + * @classdesc + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * @class Polygon + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Polygon = new Class({ + + Extends: Shape, + + Mixins: [ + PolygonRender + ], + + initialize: + + function Polygon (scene, x, y, points, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Polygon', new GeomPolygon(points)); + + var bounds = GetAABB(this.geom); + + this.setPosition(x, y); + this.setSize(bounds.width, bounds.height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Smooths the polygon over the number of iterations specified. + * The base polygon data will be updated and replaced with the smoothed values. + * This call can be chained. + * + * @method Phaser.GameObjects.Polygon#smooth + * @since 3.13.0 + * + * @param {integer} [iterations=1] - The number of times to apply the polygon smoothing. + * + * @return {this} This Game Object instance. + */ + smooth: function (iterations) + { + if (iterations === undefined) { iterations = 1; } + + for (var i = 0; i < iterations; i++) + { + Smooth(this.geom); + } + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Polygon#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.points; + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Polygon; + + +/***/ }), +/* 287 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Shape = __webpack_require__(27); +var GeomLine = __webpack_require__(54); +var LineRender = __webpack_require__(784); + +/** + * @classdesc + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * @class Line + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Line = new Class({ + + Extends: Shape, + + Mixins: [ + LineRender + ], + + initialize: + + function Line (scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 128; } + if (y2 === undefined) { y2 = 0; } + + Shape.call(this, scene, 'Line', new GeomLine(x1, y1, x2, y2)); + + var width = this.geom.right - this.geom.left; + var height = this.geom.bottom - this.geom.top; + + /** + * The width (or thickness) of the line. + * See the setLineWidth method for extra details on changing this on WebGL. + * + * @name Phaser.GameObjects.Line#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Private internal value. Holds the start width of the line. + * + * @name Phaser.GameObjects.Line#_startWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._startWidth = 1; + + /** + * Private internal value. Holds the end width of the line. + * + * @name Phaser.GameObjects.Line#_endWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._endWidth = 1; + + this.setPosition(x, y); + this.setSize(width, height); + + if (strokeColor !== undefined) + { + this.setStrokeStyle(1, strokeColor, strokeAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the width of the line. + * + * When using the WebGL renderer you can have different start and end widths. + * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Line#setLineWidth + * @since 3.13.0 + * + * @param {number} startWidth - The start width of the line. + * @param {number} [endWidth] - The end width of the line. Only used in WebGL. + * + * @return {this} This Game Object instance. + */ + setLineWidth: function (startWidth, endWidth) + { + if (endWidth === undefined) { endWidth = startWidth; } + + this._startWidth = startWidth; + this._endWidth = endWidth; + + this.lineWidth = startWidth; + + return this; + }, + + /** + * Sets the start and end coordinates of this Line. + * + * @method Phaser.GameObjects.Line#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=0] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * + * @return {this} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + this.geom.setTo(x1, y1, x2, y2); + + return this; + } + +}); + +module.exports = Line; + + +/***/ }), +/* 288 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var IsoTriangleRender = __webpack_require__(787); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @class IsoTriangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + */ +var IsoTriangle = new Class({ + + Extends: Shape, + + Mixins: [ + IsoTriangleRender + ], + + initialize: + + function IsoTriangle (scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (reversed === undefined) { reversed = false; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoTriangle', null); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * + * @name Phaser.GameObjects.IsoTriangle#projection + * @type {integer} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. + * + * @name Phaser.GameObjects.IsoTriangle#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls if the top-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls if the left-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls if the right-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + /** + * Sets if the iso triangle will be rendered upside down or not. + * + * @name Phaser.GameObjects.IsoTriangle#isReversed + * @type {boolean} + * @default false + * @since 3.13.0 + */ + this.isReversed = reversed; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setProjection + * @since 3.13.0 + * + * @param {integer} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets if the iso triangle will be rendered upside down or not. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setReversed + * @since 3.13.0 + * + * @param {boolean} reversed - Sets if the iso triangle will be rendered upside down or not. + * + * @return {this} This Game Object instance. + */ + setReversed: function (reversed) + { + this.isReversed = reversed; + + return this; + }, + + /** + * Sets which faces of the iso triangle will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso triangle (only if `reversed` is true) + * @param {boolean} [showLeft=true] - Show the left-face of the iso triangle. + * @param {boolean} [showRight=true] - Show the right-face of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso triangle. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso triangle. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso triangle. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoTriangle; + + +/***/ }), +/* 289 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsoBoxRender = __webpack_require__(790); +var Class = __webpack_require__(0); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * + * @class IsoBox + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + */ +var IsoBox = new Class({ + + Extends: Shape, + + Mixins: [ + IsoBoxRender + ], + + initialize: + + function IsoBox (scene, x, y, size, height, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoBox', null); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * + * @name Phaser.GameObjects.IsoBox#projection + * @type {integer} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls if the top-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls if the left-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls if the right-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setProjection + * @since 3.13.0 + * + * @param {integer} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets which faces of the iso box will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso box. + * @param {boolean} [showLeft=true] - Show the left-face of the iso box. + * @param {boolean} [showRight=true] - Show the right-face of the iso box. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso box. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso box. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso box. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoBox; + + +/***/ }), +/* 290 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Shape = __webpack_require__(27); +var GridRender = __webpack_require__(793); + +/** + * @classdesc + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @class Grid + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [outlineFillColor] - The color of the lines between the grid cells. See the `setOutline` method. + * @param {number} [outlineFillAlpha] - The alpha of the lines between the grid cells. + */ +var Grid = new Class({ + + Extends: Shape, + + Mixins: [ + GridRender + ], + + initialize: + + function Grid (scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + if (cellWidth === undefined) { cellWidth = 32; } + if (cellHeight === undefined) { cellHeight = 32; } + + Shape.call(this, scene, 'Grid', null); + + /** + * The width of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellWidth + * @type {number} + * @since 3.13.0 + */ + this.cellWidth = cellWidth; + + /** + * The height of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellHeight + * @type {number} + * @since 3.13.0 + */ + this.cellHeight = cellHeight; + + /** + * Will the grid render its cells in the `fillColor`? + * + * @name Phaser.GameObjects.Grid#showCells + * @type {boolean} + * @since 3.13.0 + */ + this.showCells = true; + + /** + * The color of the lines between each grid cell. + * + * @name Phaser.GameObjects.Grid#outlineFillColor + * @type {number} + * @since 3.13.0 + */ + this.outlineFillColor = 0; + + /** + * The alpha value for the color of the lines between each grid cell. + * + * @name Phaser.GameObjects.Grid#outlineFillAlpha + * @type {number} + * @since 3.13.0 + */ + this.outlineFillAlpha = 0; + + /** + * Will the grid display the lines between each cell when it renders? + * + * @name Phaser.GameObjects.Grid#showOutline + * @type {boolean} + * @since 3.13.0 + */ + this.showOutline = true; + + /** + * Will the grid render the alternating cells in the `altFillColor`? + * + * @name Phaser.GameObjects.Grid#showAltCells + * @type {boolean} + * @since 3.13.0 + */ + this.showAltCells = false; + + /** + * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * + * @name Phaser.GameObjects.Grid#altFillColor + * @type {number} + * @since 3.13.0 + */ + this.altFillColor; + + /** + * The alpha the alternating grid cells will be filled with. + * You can also set the alpha of the overall Shape using its `alpha` property. + * + * @name Phaser.GameObjects.Grid#altFillAlpha + * @type {number} + * @since 3.13.0 + */ + this.altFillAlpha; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + if (outlineFillColor !== undefined) + { + this.setOutlineStyle(outlineFillColor, outlineFillAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the fill color and alpha level the grid cells will use when rendering. + * + * If this method is called with no values then the grid cells will not be rendered, + * however the grid lines and alternating cells may still be. + * + * Also see the `setOutlineStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showCells = false; + } + else + { + this.fillColor = fillColor; + this.fillAlpha = fillAlpha; + this.showCells = true; + } + + return this; + }, + + /** + * Sets the fill color and alpha level that the alternating grid cells will use. + * + * If this method is called with no values then alternating grid cells will not be rendered in a different color. + * + * Also see the `setOutlineStyle` and `setFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setAltFillStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setAltFillStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showAltCells = false; + } + else + { + this.altFillColor = fillColor; + this.altFillAlpha = fillAlpha; + this.showAltCells = true; + } + + return this; + }, + + /** + * Sets the fill color and alpha level that the lines between each grid cell will use. + * + * If this method is called with no values then the grid lines will not be rendered at all, however + * the cells themselves may still be if they have colors set. + * + * Also see the `setFillStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setOutlineStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setOutlineStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showOutline = false; + } + else + { + this.outlineFillColor = fillColor; + this.outlineFillAlpha = fillAlpha; + this.showOutline = true; + } + + return this; + } + +}); + +module.exports = Grid; + + +/***/ }), +/* 291 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(64); +var EllipseRender = __webpack_require__(796); +var GeomEllipse = __webpack_require__(90); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @class Ellipse + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Ellipse = new Class({ + + Extends: Shape, + + Mixins: [ + EllipseRender + ], + + initialize: + + function Ellipse (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Ellipse', new GeomEllipse(width / 2, height / 2, width, height)); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Ellipse#_smoothness + * @type {integer} + * @private + * @since 3.13.0 + */ + this._smoothness = 64; + + this.setPosition(x, y); + + this.width = width; + this.height = height; + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Ellipse#smoothness + * @type {integer} + * @default 64 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSize + * @since 3.13.0 + * + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.geom.setSize(width, height); + + return this.updateData(); + }, + + /** + * Sets the smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSmoothness + * @since 3.13.0 + * + * @param {integer} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Ellipse#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.getPoints(this._smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Ellipse; + + +/***/ }), +/* 292 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CurveRender = __webpack_require__(799); +var Earcut = __webpack_require__(64); +var Rectangle = __webpack_require__(9); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @class Curve + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Curve = new Class({ + + Extends: Shape, + + Mixins: [ + CurveRender + ], + + initialize: + + function Curve (scene, x, y, curve, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Curve', curve); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Curve#_smoothness + * @type {integer} + * @private + * @since 3.13.0 + */ + this._smoothness = 32; + + /** + * Private internal value. + * The Curve bounds rectangle. + * + * @name Phaser.GameObjects.Curve#_curveBounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.13.0 + */ + this._curveBounds = new Rectangle(); + + this.closePath = false; + + this.setPosition(x, y); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateData(); + }, + + /** + * The smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Curve#smoothness + * @type {integer} + * @default 32 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Curve#setSmoothness + * @since 3.13.0 + * + * @param {integer} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Curve#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var bounds = this._curveBounds; + var smoothness = this._smoothness; + + // Update the bounds in case the underlying data has changed + this.geom.getBounds(bounds, smoothness); + + this.setSize(bounds.width, bounds.height); + this.updateDisplayOrigin(); + + var path = []; + var points = this.geom.getPoints(smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Curve; + + +/***/ }), +/* 293 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcRender = __webpack_require__(802); +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(31); +var Earcut = __webpack_require__(64); +var GeomCircle = __webpack_require__(71); +var MATH_CONST = __webpack_require__(16); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows + * you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. + * + * @class Arc + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [radius=128] - The radius of the arc. + * @param {integer} [startAngle=0] - The start angle of the arc, in degrees. + * @param {integer} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - The winding order of the start and end angles. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Arc = new Class({ + + Extends: Shape, + + Mixins: [ + ArcRender + ], + + initialize: + + function Arc (scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 128; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (anticlockwise === undefined) { anticlockwise = false; } + + Shape.call(this, scene, 'Arc', new GeomCircle(0, 0, radius)); + + /** + * Private internal value. Holds the start angle in degrees. + * + * @name Phaser.GameObjects.Arc#_startAngle + * @type {integer} + * @private + * @since 3.13.0 + */ + this._startAngle = startAngle; + + /** + * Private internal value. Holds the end angle in degrees. + * + * @name Phaser.GameObjects.Arc#_endAngle + * @type {integer} + * @private + * @since 3.13.0 + */ + this._endAngle = endAngle; + + /** + * Private internal value. Holds the winding order of the start and end angles. + * + * @name Phaser.GameObjects.Arc#_anticlockwise + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._anticlockwise = anticlockwise; + + /** + * Private internal value. Holds the number of iterations used when drawing the arc. + * + * @name Phaser.GameObjects.Arc#_iterations + * @type {number} + * @default 0.01 + * @private + * @since 3.13.0 + */ + this._iterations = 0.01; + + this.setPosition(x, y); + this.setSize(this.geom.radius, this.geom.radius); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * + * @name Phaser.GameObjects.Arc#iterations + * @type {number} + * @default 0.01 + * @since 3.13.0 + */ + iterations: { + + get: function () + { + return this._iterations; + }, + + set: function (value) + { + this._iterations = value; + + this.updateData(); + } + + }, + + /** + * The radius of the arc. + * + * @name Phaser.GameObjects.Arc#radius + * @type {number} + * @since 3.13.0 + */ + radius: { + + get: function () + { + return this.geom.radius; + }, + + set: function (value) + { + this.geom.radius = value; + + this.updateData(); + } + + }, + + /** + * The start angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#startAngle + * @type {integer} + * @since 3.13.0 + */ + startAngle: { + + get: function () + { + return this._startAngle; + }, + + set: function (value) + { + this._startAngle = value; + + this.updateData(); + } + + }, + + /** + * The end angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#endAngle + * @type {integer} + * @since 3.13.0 + */ + endAngle: { + + get: function () + { + return this._endAngle; + }, + + set: function (value) + { + this._endAngle = value; + + this.updateData(); + } + + }, + + /** + * The winding order of the start and end angles. + * + * @name Phaser.GameObjects.Arc#anticlockwise + * @type {boolean} + * @since 3.13.0 + */ + anticlockwise: { + + get: function () + { + return this._anticlockwise; + }, + + set: function (value) + { + this._anticlockwise = value; + + this.updateData(); + } + + }, + + /** + * Sets the radius of the arc. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setRadius + * @since 3.13.0 + * + * @param {number} value - The value to set the radius to. + * + * @return {this} This Game Object instance. + */ + setRadius: function (value) + { + this.radius = value; + + return this; + }, + + /** + * Sets the number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setIterations + * @since 3.13.0 + * + * @param {number} value - The value to set the iterations to. + * + * @return {this} This Game Object instance. + */ + setIterations: function (value) + { + if (value === undefined) { value = 0.01; } + + this.iterations = value; + + return this; + }, + + /** + * Sets the starting angle of the arc, in degrees. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setStartAngle + * @since 3.13.0 + * + * @param {integer} value - The value to set the starting angle to. + * + * @return {this} This Game Object instance. + */ + setStartAngle: function (angle, anticlockwise) + { + this._startAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Sets the ending angle of the arc, in degrees. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setEndAngle + * @since 3.13.0 + * + * @param {integer} value - The value to set the ending angle to. + * + * @return {this} This Game Object instance. + */ + setEndAngle: function (angle, anticlockwise) + { + this._endAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Arc#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var step = this._iterations; + var iteration = step; + + var radius = this.geom.radius; + var startAngle = DegToRad(this._startAngle); + var endAngle = DegToRad(this._endAngle); + var anticlockwise = this._anticlockwise; + + var x = radius / 2; + var y = radius / 2; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -MATH_CONST.PI2) + { + endAngle = -MATH_CONST.PI2; + } + else if (endAngle > 0) + { + endAngle = -MATH_CONST.PI2 + endAngle % MATH_CONST.PI2; + } + } + else if (endAngle > MATH_CONST.PI2) + { + endAngle = MATH_CONST.PI2; + } + else if (endAngle < 0) + { + endAngle = MATH_CONST.PI2 + endAngle % MATH_CONST.PI2; + } + + var path = [ x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius ]; + + var ta; + + while (iteration < 1) + { + ta = endAngle * iteration + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + iteration += step; + } + + ta = endAngle + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + path.push(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Arc; + + +/***/ }), +/* 294 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the nearest power of 2 to the given `value`. + * + * @function Phaser.Math.Pow2.GetPowerOfTwo + * @since 3.0.0 + * + * @param {number} value - The value. + * + * @return {integer} The nearest power of 2 to `value`. + */ +var GetPowerOfTwo = function (value) +{ + var index = Math.log(value) / 0.6931471805599453; + + return (1 << Math.ceil(index)); +}; + +module.exports = GetPowerOfTwo; + + +/***/ }), +/* 295 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Creates and returns an RFC4122 version 4 compliant UUID. + * + * The string is in the form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` where each `x` is replaced with a random + * hexadecimal digit from 0 to f, and `y` is replaced with a random hexadecimal digit from 8 to b. + * + * @function Phaser.Utils.String.UUID + * @since 3.12.0 + * + * @return {string} The UUID string. + */ +var UUID = function () +{ + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) + { + var r = Math.random() * 16 | 0; + var v = (c === 'x') ? r : (r & 0x3 | 0x8); + + return v.toString(16); + }); +}; + +module.exports = UUID; + + +/***/ }), +/* 296 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(31); +var GetBoolean = __webpack_require__(84); +var GetValue = __webpack_require__(4); +var Sprite = __webpack_require__(61); +var TWEEN_CONST = __webpack_require__(83); +var Vector2 = __webpack_require__(3); + +/** + * Settings for a PathFollower. + * + * @typedef {object} PathConfig + * + * @property {number} duration - The duration of the path follow. + * @property {number} from - The start position of the path follow, between 0 and 1. + * @property {number} to - The end position of the path follow, between 0 and 1. + * @property {boolean} [positionOnPath=false] - Whether to position the PathFollower on the Path using its path offset. + * @property {boolean} [rotateToPath=false] - Should the PathFollower automatically rotate to point in the direction of the Path? + * @property {number} [rotationOffset=0] - If the PathFollower is rotating to match the Path, this value is added to the rotation value. This allows you to rotate objects to a path but control the angle of the rotation as well. + * @property {boolean} [verticalAdjust=false] - [description] + */ + +/** + * @classdesc + * A PathFollower Game Object. + * + * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. + * + * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, + * scale it and so on. + * + * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start + * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate + * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. + * + * @class PathFollower + * @extends Phaser.GameObjects.Sprite + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this PathFollower belongs. + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var PathFollower = new Class({ + + Extends: Sprite, + + initialize: + + function PathFollower (scene, path, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + + /** + * The Path this PathFollower is following. It can only follow one Path at a time. + * + * @name Phaser.GameObjects.PathFollower#path + * @type {Phaser.Curves.Path} + * @since 3.0.0 + */ + this.path = path; + + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + * + * @name Phaser.GameObjects.PathFollower#rotateToPath + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotateToPath = false; + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pathRotationVerticalAdjust = false; + + /** + * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) + * this value is added to the rotation value. This allows you to rotate objects to a path but control + * the angle of the rotation as well. + * + * @name Phaser.GameObjects.PathFollower#pathRotationOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pathRotationOffset = 0; + + /** + * An additional vector to add to the PathFollowers position, allowing you to offset it from the + * Path coordinates. + * + * @name Phaser.GameObjects.PathFollower#pathOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathOffset = new Vector2(x, y); + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathVector + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathVector = new Vector2(); + + /** + * The Tween used for following the Path. + * + * @name Phaser.GameObjects.PathFollower#pathTween + * @type {Phaser.Tweens.Tween} + * @since 3.0.0 + */ + this.pathTween; + + /** + * Settings for the PathFollower. + * + * @name Phaser.GameObjects.PathFollower#pathConfig + * @type {?PathConfig} + * @default null + * @since 3.0.0 + */ + this.pathConfig = null; + + /** + * Records the direction of the follower so it can change direction. + * + * @name Phaser.GameObjects.PathFollower#_prevDirection + * @type {integer} + * @private + * @since 3.0.0 + */ + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + }, + + /** + * Set the Path that this PathFollower should follow. + * + * Optionally accepts {@link PathConfig} settings. + * + * @method Phaser.GameObjects.PathFollower#setPath + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @param {PathConfig} [config] - Settings for the PathFollower. + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setPath: function (path, config) + { + if (config === undefined) { config = this.pathConfig; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + this.path = path; + + if (config) + { + this.startFollow(config); + } + + return this; + }, + + /** + * Set whether the PathFollower should automatically rotate to point in the direction of the Path. + * + * @method Phaser.GameObjects.PathFollower#setRotateToPath + * @since 3.0.0 + * + * @param {boolean} value - Whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param {number} [offset=0] - Rotation offset in degrees. + * @param {boolean} [verticalAdjust=false] - [description] + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setRotateToPath: function (value, offset, verticalAdjust) + { + if (offset === undefined) { offset = 0; } + if (verticalAdjust === undefined) { verticalAdjust = false; } + + this.rotateToPath = value; + + this.pathRotationOffset = offset; + this.pathRotationVerticalAdjust = verticalAdjust; + + return this; + }, + + /** + * Is this PathFollower actively following a Path or not? + * + * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + * + * @method Phaser.GameObjects.PathFollower#isFollowing + * @since 3.0.0 + * + * @return {boolean} `true` is this PathFollower is actively following a Path, otherwise `false`. + */ + isFollowing: function () + { + var tween = this.pathTween; + + return (tween && tween.isPlaying()); + }, + + /** + * Starts this PathFollower following its given Path. + * + * @method Phaser.GameObjects.PathFollower#startFollow + * @since 3.3.0 + * + * @param {(number|PathConfig)} [config={}] - The duration of the follow, or a PathFollower config object. + * @param {number} [startAt=0] - Optional start position of the follow, between 0 and 1. + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + startFollow: function (config, startAt) + { + if (config === undefined) { config = {}; } + if (startAt === undefined) { startAt = 0; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + if (typeof config === 'number') + { + config = { duration: config }; + } + + // Override in case they've been specified in the config + config.from = 0; + config.to = 1; + + // Can also read extra values out of the config: + + var positionOnPath = GetBoolean(config, 'positionOnPath', false); + + this.rotateToPath = GetBoolean(config, 'rotateToPath', false); + this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); + this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); + + this.pathTween = this.scene.sys.tweens.addCounter(config); + + // The starting point of the path, relative to this follower + this.path.getStartPoint(this.pathOffset); + + if (positionOnPath) + { + this.x = this.pathOffset.x; + this.y = this.pathOffset.y; + } + + this.pathOffset.x = this.x - this.pathOffset.x; + this.pathOffset.y = this.y - this.pathOffset.y; + + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + + if (this.rotateToPath) + { + // Set the rotation now (in case the tween has a delay on it, etc) + var nextPoint = this.path.getPoint(0.1); + + this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); + } + + this.pathConfig = config; + + return this; + }, + + /** + * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the + * point on the Path at which you paused it. + * + * @method Phaser.GameObjects.PathFollower#pauseFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + pauseFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.pause(); + } + + return this; + }, + + /** + * Resumes a previously paused PathFollower. + * + * If the PathFollower was not paused this has no effect. + * + * @method Phaser.GameObjects.PathFollower#resumeFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + resumeFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPaused()) + { + tween.resume(); + } + + return this; + }, + + /** + * Stops this PathFollower from following the path any longer. + * + * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + * + * @method Phaser.GameObjects.PathFollower#stopFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + stopFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + return this; + }, + + /** + * Internal update handler that advances this PathFollower along the path. + * + * Called automatically by the Scene step, should not typically be called directly. + * + * @method Phaser.GameObjects.PathFollower#preUpdate + * @protected + * @since 3.0.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. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + + var tween = this.pathTween; + + if (tween) + { + var tweenData = tween.data[0]; + + if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) + { + // If delayed, etc then bail out + return; + } + + var pathVector = this.pathVector; + + this.path.getPoint(tween.getValue(), pathVector); + + pathVector.add(this.pathOffset); + + var oldX = this.x; + var oldY = this.y; + + this.setPosition(pathVector.x, pathVector.y); + + var speedX = this.x - oldX; + var speedY = this.y - oldY; + + if (speedX === 0 && speedY === 0) + { + // Bail out early + return; + } + + if (tweenData.state !== this._prevDirection) + { + // We've changed direction, so don't do a rotate this frame + this._prevDirection = tweenData.state; + + return; + } + + if (this.rotateToPath) + { + this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); + + if (this.pathRotationVerticalAdjust) + { + this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); + } + } + } + } + +}); + +module.exports = PathFollower; + + +/***/ }), +/* 297 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @callback RandomZoneSourceCallback + * + * @param {Phaser.Math.Vector2} point - A point to modify. + */ + +/** + * @typedef {object} RandomZoneSource + * + * @property {RandomZoneSourceCallback} getRandomPoint - A function modifying its point argument. + * + * @see Phaser.Geom.Circle + * @see Phaser.Geom.Ellipse + * @see Phaser.Geom.Line + * @see Phaser.Geom.Polygon + * @see Phaser.Geom.Rectangle + * @see Phaser.Geom.Triangle + */ + +/** + * @classdesc + * A zone that places particles randomly within a shape's area. + * + * @class RandomZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {RandomZoneSource} source - An object instance with a `getRandomPoint(point)` method. + */ +var RandomZone = new Class({ + + initialize: + + function RandomZone (source) + { + /** + * An object instance with a `getRandomPoint(point)` method. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#source + * @type {RandomZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * Internal calculation vector. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tempVec = new Vector2(); + }, + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * + * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle. + */ + getPoint: function (particle) + { + var vec = this._tempVec; + + this.source.getRandomPoint(vec); + + particle.x = vec.x; + particle.y = vec.y; + } + +}); + +module.exports = RandomZone; + + +/***/ }), +/* 298 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Verifies that an object contains at least one of the requested keys + * + * @function Phaser.Utils.Objects.HasAny + * @since 3.0.0 + * + * @param {object} source - an object on which to check for key existence + * @param {string[]} keys - an array of keys to search the object for + * + * @return {boolean} true if the source object contains at least one of the keys, false otherwise + */ +var HasAny = function (source, keys) +{ + for (var i = 0; i < keys.length; i++) + { + if (source.hasOwnProperty(keys[i])) + { + return true; + } + } + + return false; +}; + +module.exports = HasAny; + + +/***/ }), +/* 299 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Generate a random floating point number between the two given bounds, minimum inclusive, maximum exclusive. + * + * @function Phaser.Math.FloatBetween + * @since 3.0.0 + * + * @param {number} min - The lower bound for the float, inclusive. + * @param {number} max - The upper bound for the float exclusive. + * + * @return {number} A random float within the given range. + */ +var FloatBetween = function (min, max) +{ + return Math.random() * (max - min) + min; +}; + +module.exports = FloatBetween; + + +/***/ }), +/* 300 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback EdgeZoneSourceCallback + * + * @param {integer} quantity - The number of particles to place on the source edge. If 0, `stepRate` should be used instead. + * @param {number} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to `0`. + * + * @return {Phaser.Geom.Point[]} - The points placed on the source edge. + */ + +/** + * @typedef {object} EdgeZoneSource + * + * @property {EdgeZoneSourceCallback} getPoints - A function placing points on the source's edge or edges. + * + * @see Phaser.Curves.Curve + * @see Phaser.Curves.Path + * @see Phaser.Geom.Circle + * @see Phaser.Geom.Ellipse + * @see Phaser.Geom.Line + * @see Phaser.Geom.Polygon + * @see Phaser.Geom.Rectangle + * @see Phaser.Geom.Triangle + */ + +/** + * @classdesc + * A zone that places particles on a shape's edges. + * + * @class EdgeZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * @param {integer} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @param {number} stepRate - The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @param {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. + * @param {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. + */ +var EdgeZone = new Class({ + + initialize: + + function EdgeZone (source, quantity, stepRate, yoyo, seamless) + { + if (yoyo === undefined) { yoyo = false; } + if (seamless === undefined) { seamless = true; } + + /** + * An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source + * @type {EdgeZoneSource|RandomZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * The points placed on the source edge. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points + * @type {Phaser.Geom.Point[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + /** + * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity + * @type {integer} + * @since 3.0.0 + */ + this.quantity = quantity; + + /** + * The distance between each particle. When set, `quantity` is implied and should be set to 0. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate + * @type {number} + * @since 3.0.0 + */ + this.stepRate = stepRate; + + /** + * Whether particles are placed from start to end and then end to start. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo + * @type {boolean} + * @since 3.0.0 + */ + this.yoyo = yoyo; + + /** + * The counter used for iterating the EdgeZone's points. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.counter = -1; + + /** + * Whether one endpoint will be removed if it's identical to the other. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless + * @type {boolean} + * @since 3.0.0 + */ + this.seamless = seamless; + + /** + * An internal count of the points belonging to this EdgeZone. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._length = 0; + + /** + * An internal value used to keep track of the current iteration direction for the EdgeZone's points. + * + * 0 = forwards, 1 = backwards + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._direction = 0; + + this.updateSource(); + }, + + /** + * Update the {@link Phaser.GameObjects.Particles.Zones.EdgeZone#points} from the EdgeZone's + * {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * + * Also updates internal properties. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + updateSource: function () + { + this.points = this.source.getPoints(this.quantity, this.stepRate); + + // Remove ends? + if (this.seamless) + { + var a = this.points[0]; + var b = this.points[this.points.length - 1]; + + if (a.x === b.x && a.y === b.y) + { + this.points.pop(); + } + } + + var oldLength = this._length; + + this._length = this.points.length; + + // Adjust counter if we now have less points than before + if (this._length < oldLength && this.counter > this._length) + { + this.counter = this._length - 1; + } + + return this; + }, + + /** + * Change the EdgeZone's source. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource + * @since 3.0.0 + * + * @param {EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + changeSource: function (source) + { + this.source = source; + + return this.updateSource(); + }, + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle. + */ + getPoint: function (particle) + { + if (this._direction === 0) + { + this.counter++; + + if (this.counter >= this._length) + { + if (this.yoyo) + { + this._direction = 1; + this.counter = this._length - 1; + } + else + { + this.counter = 0; + } + } + } + else + { + this.counter--; + + if (this.counter === -1) + { + if (this.yoyo) + { + this._direction = 0; + this.counter = 0; + } + else + { + this.counter = this._length - 1; + } + } + } + + var point = this.points[this.counter]; + + if (point) + { + particle.x = point.x; + particle.y = point.y; + } + } + +}); + +module.exports = EdgeZone; + + +/***/ }), +/* 301 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback DeathZoneSourceCallback + * + * @param {number} x - The x coordinate of the particle to check against this source area. + * @param {number} y - The y coordinate of the particle to check against this source area. + * + * @return {boolean} - True if the coordinates are within the source area. + */ + +/** + * @typedef {object} DeathZoneSource + * + * @property {DeathZoneSourceCallback} contains + * + * @see Phaser.Geom.Circle + * @see Phaser.Geom.Ellipse + * @see Phaser.Geom.Polygon + * @see Phaser.Geom.Rectangle + * @see Phaser.Geom.Triangle + */ + +/** + * @classdesc + * A Death Zone. + * + * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. + * + * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own + * object as long as it includes a `contains` method for which the Particles can be tested against. + * + * @class DeathZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {DeathZoneSource} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` + */ +var DeathZone = new Class({ + + initialize: + + function DeathZone (source, killOnEnter) + { + /** + * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#source + * @type {DeathZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * Set to `true` if the Particle should be killed if it enters this zone. + * Set to `false` to kill the Particle if it leaves this zone. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter + * @type {boolean} + * @since 3.0.0 + */ + this.killOnEnter = killOnEnter; + }, + + /** + * Checks if the given Particle will be killed or not by this zone. + * + * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to be checked against this zone. + * + * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. + */ + willKill: function (particle) + { + var withinZone = this.source.contains(particle.x, particle.y); + + return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); + } + +}); + +module.exports = DeathZone; + + +/***/ }), +/* 302 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(66); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var DeathZone = __webpack_require__(301); +var EdgeZone = __webpack_require__(300); +var EmitterOp = __webpack_require__(822); +var GetFastValue = __webpack_require__(2); +var GetRandom = __webpack_require__(162); +var HasAny = __webpack_require__(298); +var HasValue = __webpack_require__(85); +var Particle = __webpack_require__(303); +var RandomZone = __webpack_require__(297); +var Rectangle = __webpack_require__(9); +var StableSort = __webpack_require__(110); +var Vector2 = __webpack_require__(3); +var Wrap = __webpack_require__(53); + +/** + * @callback ParticleEmitterCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle associated with the call. + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - This particle emitter associated with the call. + */ + +/** + * @callback ParticleDeathCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle that died. +*/ + +/** + * @typedef {object} ParticleEmitterBounds + * + * @property {number} x - The left edge of the rectangle. + * @property {number} y - The top edge of the rectangle. + * @property {number} width - The width of the rectangle. + * @property {number} height - The height of the rectangle. + * + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + */ + +/** + * @typedef {object} ParticleEmitterBoundsAlt + * + * @property {number} x - The left edge of the rectangle. + * @property {number} y - The top edge of the rectangle. + * @property {number} w - The width of the rectangle. + * @property {number} h - The height of the rectangle. + * + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + */ + +/** + * @typedef {object} ParticleEmitterDeathZoneConfig + * + * @property {DeathZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.DeathZone#source}. + * @property {string} [type='onEnter'] - 'onEnter' or 'onLeave'. + */ + +/** + * @typedef {object} ParticleEmitterEdgeZoneConfig + * + * @property {EdgeZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * @property {string} type - 'edge'. + * @property {integer} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @property {number} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @property {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. + * @property {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. + */ + +/** + * @typedef {object} ParticleEmitterRandomZoneConfig + * + * @property {RandomZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.RandomZone#source}. + * @property {string} [type] - 'random'. + */ + +/** + * @typedef {object} ParticleEmitterConfig + * + * @property {boolean} [active] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#active}. + * @property {integer} [blendMode] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#blendMode}. + * @property {*} [callbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope} and {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. + * @property {boolean} [collideBottom] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideBottom}. + * @property {boolean} [collideLeft] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideLeft}. + * @property {boolean} [collideRight] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideRight}. + * @property {boolean} [collideTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideTop}. + * @property {boolean} [deathCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + * @property {*} [deathCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope}. + * @property {function} [emitCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + * @property {*} [emitCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. + * @property {Phaser.GameObjects.GameObject} [follow] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#follow}. + * @property {number} [frequency] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency}. + * @property {number} [gravityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityX}. + * @property {number} [gravityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityY}. + * @property {integer} [maxParticles] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxParticles}. + * @property {string} [name] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#name}. + * @property {boolean} [on] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#on}. + * @property {boolean} [particleBringToTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop}. + * @property {Phaser.GameObjects.Particles.Particle} [particleClass] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleClass}. + * @property {boolean} [radial] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#radial}. + * @property {number} [timeScale] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#timeScale}. + * @property {boolean} [trackVisible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#trackVisible}. + * @property {boolean} [visible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#visible}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [accelerationX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [accelerationY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationY} (emit only). + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [alpha] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#alpha}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [angle] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#angle} (emit only) + * @property {number|number[]|EmitterOpOnEmitCallback|object} [bounce] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#bounce} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [delay] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#delay} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [lifespan] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#lifespan} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [maxVelocityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [maxVelocityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [moveToX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [moveToY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToY} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [quantity] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity} (emit only). + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [rotate] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#rotate}. + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [scale] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setScale}. + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [scaleX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleX}. + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [scaleY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleY}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [speed] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setSpeed} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [speedX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [speedY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedY} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [tint] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#tint}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [x] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#x} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [y] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#y} (emit only). + * @property {object} [emitZone] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone}. + * @property {ParticleEmitterBounds|ParticleEmitterBoundsAlt} [bounds] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setBounds}. + * @property {object} [followOffset] - Assigns to {@link Phaser.GameObjects.Particles.ParticleEmitter#followOffset}. + * @property {number} [followOffset.x] - x-coordinate of the offset. + * @property {number} [followOffset.y] - y-coordinate of the offset. + * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]|ParticleEmitterFrameConfig} [frames] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + */ + +/** + * @typedef {object} ParticleEmitterFrameConfig + * + * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]} [frames] - One or more texture frames. + * @property {boolean} [cycle] - Whether texture frames will be assigned consecutively (true) or at random (false). + * @property {integer} [quantity] - The number of consecutive particles receiving each texture frame, when `cycle` is true. + */ + +/** + * @classdesc + * A particle emitter represents a single particle stream. + * It controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles} and is controlled by a {@link Phaser.GameObjects.Particles.ParticleEmitterManager Particle Emitter Manager}. + * + * @class ParticleEmitter + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} manager - The Emitter Manager this Emitter belongs to. + * @param {ParticleEmitterConfig} config - Settings for this emitter. + */ +var ParticleEmitter = new Class({ + + Mixins: [ + Components.BlendMode, + Components.Mask, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function ParticleEmitter (manager, config) + { + /** + * The Emitter Manager this Emitter belongs to. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#manager + * @type {Phaser.GameObjects.Particles.ParticleEmitterManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The texture assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = manager.texture; + + /** + * The texture frames assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frames + * @type {Phaser.Textures.Frame[]} + * @since 3.0.0 + */ + this.frames = [ manager.defaultFrame ]; + + /** + * The default texture frame assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#defaultFrame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.defaultFrame = manager.defaultFrame; + + /** + * Names of simple configuration properties. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configFastMap + * @type {object} + * @since 3.0.0 + */ + this.configFastMap = [ + 'active', + 'blendMode', + 'collideBottom', + 'collideLeft', + 'collideRight', + 'collideTop', + 'deathCallback', + 'deathCallbackScope', + 'emitCallback', + 'emitCallbackScope', + 'follow', + 'frequency', + 'gravityX', + 'gravityY', + 'maxParticles', + 'name', + 'on', + 'particleBringToTop', + 'particleClass', + 'radial', + 'timeScale', + 'trackVisible', + 'visible' + ]; + + /** + * Names of complex configuration properties. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configOpMap + * @type {object} + * @since 3.0.0 + */ + this.configOpMap = [ + 'accelerationX', + 'accelerationY', + 'angle', + 'alpha', + 'bounce', + 'delay', + 'lifespan', + 'maxVelocityX', + 'maxVelocityY', + 'moveToX', + 'moveToY', + 'quantity', + 'rotate', + 'scaleX', + 'scaleY', + 'speedX', + 'speedY', + 'tint', + 'x', + 'y' + ]; + + /** + * The name of this Particle Emitter. + * + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The Particle Class which will be emitted by this Emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass + * @type {Phaser.GameObjects.Particles.Particle} + * @default Phaser.GameObjects.Particles.Particle + * @since 3.0.0 + */ + this.particleClass = Particle; + + /** + * The x-coordinate of the particle origin (where particles will be emitted). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#x + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition + */ + this.x = new EmitterOp(config, 'x', 0); + + /** + * The y-coordinate of the particle origin (where particles will be emitted). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#y + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition + */ + this.y = new EmitterOp(config, 'y', 0); + + /** + * A radial emitter will emit particles in all directions between angle min and max, + * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. + * A point emitter will emit particles only in the direction derived from the speedX and speedY values. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#radial + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setRadial + */ + this.radial = true; + + /** + * Horizontal acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity + */ + this.gravityX = 0; + + /** + * Vertical acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity + */ + this.gravityY = 0; + + /** + * Whether accelerationX and accelerationY are non-zero. Set automatically during configuration. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.acceleration = false; + + /** + * Horizontal acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.accelerationX = new EmitterOp(config, 'accelerationX', 0, true); + + /** + * Vertical acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.accelerationY = new EmitterOp(config, 'accelerationY', 0, true); + + /** + * The maximum horizontal velocity of emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityX = new EmitterOp(config, 'maxVelocityX', 10000, true); + + /** + * The maximum vertical velocity of emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityY = new EmitterOp(config, 'maxVelocityY', 10000, true); + + /** + * The initial horizontal speed of emitted particles, in pixels per second. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX + */ + this.speedX = new EmitterOp(config, 'speedX', 0, true); + + /** + * The initial vertical speed of emitted particles, in pixels per second. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY + */ + this.speedY = new EmitterOp(config, 'speedY', 0, true); + + /** + * Whether moveToX and moveToY are nonzero. Set automatically during configuration. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.moveTo = false; + + /** + * The x-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.moveToX = new EmitterOp(config, 'moveToX', 0, true); + + /** + * The y-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.moveToY = new EmitterOp(config, 'moveToY', 0, true); + + /** + * Whether particles will rebound when they meet the emitter bounds. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.bounce = new EmitterOp(config, 'bounce', 0, true); + + /** + * The horizontal scale of emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleX + */ + this.scaleX = new EmitterOp(config, 'scaleX', 1); + + /** + * The vertical scale of emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleY + */ + this.scaleY = new EmitterOp(config, 'scaleY', 1); + + /** + * Color tint applied to emitted particles. Any alpha component (0xAA000000) is ignored. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#tint + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0xffffffff + * @since 3.0.0 + */ + this.tint = new EmitterOp(config, 'tint', 0xffffffff); + + /** + * The alpha (transparency) of emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alpha + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setAlpha + */ + this.alpha = new EmitterOp(config, 'alpha', 1); + + /** + * The lifespan of emitted particles, in ms. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1000 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setLifespan + */ + this.lifespan = new EmitterOp(config, 'lifespan', 1000); + + /** + * The angle of the initial velocity of emitted particles, in degrees. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#angle + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default { min: 0, max: 360 } + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setAngle + */ + this.angle = new EmitterOp(config, 'angle', { min: 0, max: 360 }); + + /** + * The rotation of emitted particles, in degrees. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#rotate + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.rotate = new EmitterOp(config, 'rotate', 0); + + /** + * A function to call when a particle is emitted. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback + * @type {?ParticleEmitterCallback} + * @default null + * @since 3.0.0 + */ + this.emitCallback = null; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.emitCallbackScope = null; + + /** + * A function to call when a particle dies. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback + * @type {?ParticleDeathCallback} + * @default null + * @since 3.0.0 + */ + this.deathCallback = null; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.deathCallbackScope = null; + + /** + * Set to hard limit the amount of particle objects this emitter is allowed to create. + * 0 means unlimited. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.maxParticles = 0; + + /** + * How many particles are emitted each time particles are emitted (one explosion or one flow cycle). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @see Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + */ + this.quantity = new EmitterOp(config, 'quantity', 1, true); + + /** + * How many ms to wait after emission before the particles start updating. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#delay + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.delay = new EmitterOp(config, 'delay', 0, true); + + /** + * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. + * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. + * For an exploding emitter, this value will be -1. + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + */ + this.frequency = 0; + + /** + * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). + * Already alive particles will continue to update until they expire. + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#on + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.on = true; + + /** + * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. + * Set to false to send them to the back. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.particleBringToTop = true; + + /** + * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * An object describing a shape to emit particles from. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZone + * @type {?Phaser.GameObjects.Particles.Zones.EdgeZone|Phaser.GameObjects.Particles.Zones.RandomZone} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + */ + this.emitZone = null; + + /** + * An object describing a shape that deactivates particles when they interact with it. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZone + * @type {?Phaser.GameObjects.Particles.Zones.DeathZone} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone + */ + this.deathZone = null; + + /** + * A rectangular boundary constraining particle movement. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounds + * @type {?Phaser.Geom.Rectangle} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + */ + this.bounds = null; + + /** + * Whether particles interact with the left edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideLeft + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideLeft = true; + + /** + * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideRight + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideRight = true; + + /** + * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideTop = true; + + /** + * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideBottom + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideBottom = true; + + /** + * Whether this emitter updates itself and its particles. + * + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#pause} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#resume}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * Set this to false to hide any active particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#visible + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setVisible + */ + this.visible = true; + + /** + * The blend mode of this emitter's particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#blendMode + * @type {integer} + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBlendMode + */ + this.blendMode = BlendModes.NORMAL; + + /** + * A Game Object whose position is used as the particle origin. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#follow + * @type {?Phaser.GameObjects.GameObject} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @see Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + */ + this.follow = null; + + /** + * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + */ + this.followOffset = new Vector2(); + + /** + * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track + * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + */ + this.trackVisible = false; + + /** + * The current texture frame, as an index of {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame + * @type {integer} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame + */ + this.currentFrame = 0; + + /** + * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame + */ + this.randomFrame = true; + + /** + * The number of consecutive particles that receive a single texture frame (per frame cycle). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity + * @type {integer} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame + */ + this.frameQuantity = 1; + + /** + * Inactive particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#dead + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.dead = []; + + /** + * Active particles + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alive + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.alive = []; + + /** + * The time until the next flow cycle. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_counter + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._counter = 0; + + /** + * Counts up to {@link Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_frameCounter + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._frameCounter = 0; + + if (config) + { + this.fromJSON(config); + } + }, + + /** + * Merges configuration settings into the emitter's current settings. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#fromJSON + * @since 3.0.0 + * + * @param {ParticleEmitterConfig} config - Settings for this emitter. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + fromJSON: function (config) + { + if (!config) + { + return this; + } + + // Only update properties from their current state if they exist in the given config + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + if (HasValue(config, key)) + { + this[key] = GetFastValue(config, key); + } + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (HasValue(config, key)) + { + this[key].loadConfig(config); + } + } + + this.acceleration = (this.accelerationX.propertyValue !== 0 || this.accelerationY.propertyValue !== 0); + + this.moveTo = (this.moveToX.propertyValue !== 0 || this.moveToY.propertyValue !== 0); + + // Special 'speed' override + + if (HasValue(config, 'speed')) + { + this.speedX.loadConfig(config, 'speed'); + this.speedY = null; + } + + // If you specify speedX, speedY or moveTo then it changes the emitter from radial to a point emitter + if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) + { + this.radial = false; + } + + // Special 'scale' override + + if (HasValue(config, 'scale')) + { + this.scaleX.loadConfig(config, 'scale'); + this.scaleY = null; + } + + if (HasValue(config, 'callbackScope')) + { + var callbackScope = GetFastValue(config, 'callbackScope', null); + + this.emitCallbackScope = callbackScope; + this.deathCallbackScope = callbackScope; + } + + if (HasValue(config, 'emitZone')) + { + this.setEmitZone(config.emitZone); + } + + if (HasValue(config, 'deathZone')) + { + this.setDeathZone(config.deathZone); + } + + if (HasValue(config, 'bounds')) + { + this.setBounds(config.bounds); + } + + if (HasValue(config, 'followOffset')) + { + this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); + } + + if (HasValue(config, 'frame')) + { + this.setFrame(config.frame); + } + + return this; + }, + + /** + * Creates a description of this emitter suitable for JSON serialization. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON + * @since 3.0.0 + * + * @param {object} [output] - An object to copy output into. + * + * @return {object} - The output object. + */ + toJSON: function (output) + { + if (output === undefined) { output = {}; } + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + output[key] = this[key]; + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (this[key]) + { + output[key] = this[key].toJSON(); + } + } + + // special handlers + if (!this.speedY) + { + delete output.speedX; + output.speed = this.speedX.toJSON(); + } + + if (!this.scaleY) + { + delete output.scaleX; + output.scale = this.scaleX.toJSON(); + } + + return output; + }, + + /** + * Continuously moves the particle origin to follow a Game Object's position. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} target - The Game Object to follow. + * @param {number} [offsetX=0] - Horizontal offset of the particle origin from the Game Object. + * @param {number} [offsetY=0] - Vertical offset of the particle origin from the Game Object. + * @param {boolean} [trackVisible=false] - Whether the emitter's visible state will track the target's visible state. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + startFollow: function (target, offsetX, offsetY, trackVisible) + { + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + if (trackVisible === undefined) { trackVisible = false; } + + this.follow = target; + this.followOffset.set(offsetX, offsetY); + this.trackVisible = trackVisible; + + return this; + }, + + /** + * Stops following a Game Object. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stopFollow: function () + { + this.follow = null; + this.followOffset.set(0, 0); + this.trackVisible = false; + + return this; + }, + + /** + * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} The texture frame. + */ + getFrame: function () + { + if (this.frames.length === 1) + { + return this.defaultFrame; + } + else if (this.randomFrame) + { + return GetRandom(this.frames); + } + else + { + var frame = this.frames[this.currentFrame]; + + this._frameCounter++; + + if (this._frameCounter === this.frameQuantity) + { + this._frameCounter = 0; + this.currentFrame = Wrap(this.currentFrame + 1, 0, this._frameLength); + } + + return frame; + } + }, + + // frame: 0 + // frame: 'red' + // frame: [ 0, 1, 2, 3 ] + // frame: [ 'red', 'green', 'blue', 'pink', 'white' ] + // frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } + + /** + * Sets a pattern for assigning texture frames to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrame + * @since 3.0.0 + * + * @param {(array|string|integer|ParticleEmitterFrameConfig)} frames - One or more texture frames, or a configuration object. + * @param {boolean} [pickRandom=true] - Whether frames should be assigned at random from `frames`. + * @param {integer} [quantity=1] - The number of consecutive particles that will receive each frame. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrame: function (frames, pickRandom, quantity) + { + if (pickRandom === undefined) { pickRandom = true; } + if (quantity === undefined) { quantity = 1; } + + this.randomFrame = pickRandom; + this.frameQuantity = quantity; + this.currentFrame = 0; + this._frameCounter = 0; + + var t = typeof (frames); + + if (Array.isArray(frames) || t === 'string' || t === 'number') + { + this.manager.setEmitterFrames(frames, this); + } + else if (t === 'object') + { + var frameConfig = frames; + + frames = GetFastValue(frameConfig, 'frames', null); + + if (frames) + { + this.manager.setEmitterFrames(frames, this); + } + + var isCycle = GetFastValue(frameConfig, 'cycle', false); + + this.randomFrame = (isCycle) ? false : true; + + this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); + } + + this._frameLength = this.frames.length; + + if (this._frameLength === 1) + { + this.frameQuantity = 1; + this.randomFrame = false; + } + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial + * @since 3.0.0 + * + * @param {boolean} [value=true] - Radial mode (true) or point mode (true). + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setRadial: function (value) + { + if (value === undefined) { value = true; } + + this.radial = value; + + return this; + }, + + /** + * Sets the position of the emitter's particle origin. + * New particles will be emitted here. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} x - The x-coordinate of the particle origin. + * @param {number|float[]|EmitterOpOnEmitCallback|object} y - The y-coordinate of the particle origin. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setPosition: function (x, y) + { + this.x.onChange(x); + this.y.onChange(y); + + return this; + }, + + /** + * Sets or modifies a rectangular boundary constraining the particles. + * + * To remove the boundary, set {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds} to null. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setBounds + * @since 3.0.0 + * + * @param {(number|ParticleEmitterBounds|ParticleEmitterBoundsAlt)} x - The x-coordinate of the left edge of the boundary, or an object representing a rectangle. + * @param {number} y - The y-coordinate of the top edge of the boundary. + * @param {number} width - The width of the boundary. + * @param {number} height - The height of the boundary. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setBounds: function (x, y, width, height) + { + if (typeof x === 'object') + { + var obj = x; + + x = obj.x; + y = obj.y; + width = (HasValue(obj, 'w')) ? obj.w : obj.width; + height = (HasValue(obj, 'h')) ? obj.h : obj.height; + } + + if (this.bounds) + { + this.bounds.setTo(x, y, width, height); + } + else + { + this.bounds = new Rectangle(x, y, width, height); + } + + return this; + }, + + /** + * Sets the initial horizontal speed of emitted particles. + * Changes the emitter to point mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedX: function (value) + { + this.speedX.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + + return this; + }, + + /** + * Sets the initial vertical speed of emitted particles. + * Changes the emitter to point mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedY: function (value) + { + if (this.speedY) + { + this.speedY.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + } + + return this; + }, + + /** + * Sets the initial radial speed of emitted particles. + * Changes the emitter to radial mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeed: function (value) + { + this.speedX.onChange(value); + this.speedY = null; + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = true; + + return this; + }, + + /** + * Sets the horizontal scale of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleX: function (value) + { + this.scaleX.onChange(value); + + return this; + }, + + /** + * Sets the vertical scale of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleY: function (value) + { + this.scaleY.onChange(value); + + return this; + }, + + /** + * Sets the scale of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScale: function (value) + { + this.scaleX.onChange(value); + this.scaleY = null; + + return this; + }, + + /** + * Sets the horizontal gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX + * @since 3.0.0 + * + * @param {number} value - Acceleration due to gravity, in pixels per second squared. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityX: function (value) + { + this.gravityX = value; + + return this; + }, + + /** + * Sets the vertical gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY + * @since 3.0.0 + * + * @param {number} value - Acceleration due to gravity, in pixels per second squared. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityY: function (value) + { + this.gravityY = value; + + return this; + }, + + /** + * Sets the gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity + * @since 3.0.0 + * + * @param {number} x - Horizontal acceleration due to gravity, in pixels per second squared. + * @param {number} y - Vertical acceleration due to gravity, in pixels per second squared. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravity: function (x, y) + { + this.gravityX = x; + this.gravityY = y; + + return this; + }, + + /** + * Sets the opacity of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - A value between 0 (transparent) and 1 (opaque). + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAlpha: function (value) + { + this.alpha.onChange(value); + + return this; + }, + + /** + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitterAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * Sets the lifespan of newly emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The particle lifespan, in ms. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setLifespan: function (value) + { + this.lifespan.onChange(value); + + return this; + }, + + /** + * Sets the number of particles released at each flow cycle or explosion. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} quantity - The number of particles to release at each flow cycle or explosion. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setQuantity: function (quantity) + { + this.quantity.onChange(quantity); + + return this; + }, + + /** + * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @since 3.0.0 + * + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [quantity] - The number of particles to release at each flow cycle or explosion. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrequency: function (frequency, quantity) + { + this.frequency = frequency; + + this._counter = 0; + + if (quantity) + { + this.quantity.onChange(quantity); + } + + return this; + }, + + /** + * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#emitZone}. + * + * An {@link ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. Its {@link EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link EdgeZoneSourceCallback getPoints} method. + * + * A {@link ParticleEmitterRandomZoneConfig RandomZone} places randomly within its interior. Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link RandomZoneSourceCallback getRandomPoint} method. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + * @since 3.0.0 + * + * @param {ParticleEmitterEdgeZoneConfig|ParticleEmitterRandomZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current emit zone. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.emitZone = null; + } + else + { + // Where source = Geom like Circle, or a Path or Curve + // emitZone: { type: 'random', source: X } + // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] } + + var type = GetFastValue(zoneConfig, 'type', 'random'); + var source = GetFastValue(zoneConfig, 'source', null); + + switch (type) + { + case 'random': + + this.emitZone = new RandomZone(source); + + break; + + case 'edge': + + var quantity = GetFastValue(zoneConfig, 'quantity', 1); + var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); + var yoyo = GetFastValue(zoneConfig, 'yoyo', false); + var seamless = GetFastValue(zoneConfig, 'seamless', true); + + this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); + + break; + } + } + + return this; + }, + + /** + * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#deathZone}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone + * @since 3.0.0 + * + * @param {ParticleEmitterDeathZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current death zone. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setDeathZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.deathZone = null; + } + else + { + // Where source = Geom like Circle or Rect that supports a 'contains' function + // deathZone: { type: 'onEnter', source: X } + // deathZone: { type: 'onLeave', source: X } + + var type = GetFastValue(zoneConfig, 'type', 'onEnter'); + var source = GetFastValue(zoneConfig, 'source', null); + + if (source && typeof source.contains === 'function') + { + var killOnEnter = (type === 'onEnter') ? true : false; + + this.deathZone = new DeathZone(source, killOnEnter); + } + } + + return this; + }, + + /** + * Creates inactive particles and adds them to this emitter's pool. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve + * @since 3.0.0 + * + * @param {integer} particleCount - The number of particles to create. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + reserve: function (particleCount) + { + var dead = this.dead; + + for (var i = 0; i < particleCount; i++) + { + dead.push(new this.particleClass(this)); + } + + return this; + }, + + /** + * Gets the number of active (in-use) particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount + * @since 3.0.0 + * + * @return {integer} The number of particles with `active=true`. + */ + getAliveParticleCount: function () + { + return this.alive.length; + }, + + /** + * Gets the number of inactive (available) particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount + * @since 3.0.0 + * + * @return {integer} The number of particles with `active=false`. + */ + getDeadParticleCount: function () + { + return this.dead.length; + }, + + /** + * Gets the total number of particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount + * @since 3.0.0 + * + * @return {integer} The number of particles, including both alive and dead. + */ + getParticleCount: function () + { + return this.getAliveParticleCount() + this.getDeadParticleCount(); + }, + + /** + * Whether this emitter is at its limit (if set). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. + */ + atLimit: function () + { + return (this.maxParticles > 0 && this.getParticleCount() === this.maxParticles); + }, + + /** + * Sets a function to call for each newly emitted particle. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - The function. + * @param {*} [context] - The calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleEmit: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.emitCallback = null; + this.emitCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.emitCallback = callback; + + if (context) + { + this.emitCallbackScope = context; + } + } + + return this; + }, + + /** + * Sets a function to call for each particle death. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath + * @since 3.0.0 + * + * @param {ParticleDeathCallback} callback - The function. + * @param {*} [context] - The function's calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleDeath: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.deathCallback = null; + this.deathCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.deathCallback = callback; + + if (context) + { + this.deathCallbackScope = context; + } + } + + return this; + }, + + /** + * Deactivates every particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + killAll: function () + { + var dead = this.dead; + var alive = this.alive; + + while (alive.length > 0) + { + dead.push(alive.pop()); + } + + return this; + }, + + /** + * Calls a function for each active particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - The function. + * @param {*} context - The function's calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachAlive: function (callback, context) + { + var alive = this.alive; + var length = alive.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(context, alive[index], this); + } + + return this; + }, + + /** + * Calls a function for each inactive particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - The function. + * @param {*} context - The function's calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachDead: function (callback, context) + { + var dead = this.dead; + var length = dead.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(context, dead[index], this); + } + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. + * + * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). + * + * If this emitter is in explode mode (frequency = -1), nothing will happen. + * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#start + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + start: function () + { + this.on = true; + + this._counter = 0; + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on off} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stop + * @since 3.11.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stop: function () + { + this.on = false; + + return this; + }, + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + depthSort: function () + { + StableSort.inplace(this.alive, this.depthSortCallback); + + return this; + }, + + /** + * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. + * + * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#flow + * @since 3.0.0 + * + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [count=1] - The number of particles to emit at each flow cycle. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + flow: function (frequency, count) + { + if (count === undefined) { count = 1; } + + this.frequency = frequency; + + this.quantity.onChange(count); + + return this.start(); + }, + + /** + * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#explode + * @since 3.0.0 + * + * @param {integer} count - The amount of Particles to emit. + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + explode: function (count, x, y) + { + this.frequency = -1; + + return this.emitParticle(count, x, y); + }, + + /** + * Emits particles at a given position (or the emitter's current position). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt + * @since 3.0.0 + * + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. + * @param {integer} [count=this.quantity] - The number of Particles to emit. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * Emits particles at a given position (or the emitter's current position). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle + * @since 3.0.0 + * + * @param {integer} [count=this.quantity] - The number of Particles to emit. + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + * + * @see Phaser.GameObjects.Particles.Particle#fire + */ + emitParticle: function (count, x, y) + { + if (this.atLimit()) + { + return; + } + + if (count === undefined) + { + count = this.quantity.onEmit(); + } + + var dead = this.dead; + + for (var i = 0; i < count; i++) + { + var particle; + + if (dead.length > 0) + { + particle = dead.pop(); + } + else + { + particle = new this.particleClass(this); + } + + particle.fire(x, y); + + if (this.particleBringToTop) + { + this.alive.push(particle); + } + else + { + this.alive.unshift(particle); + } + + if (this.emitCallback) + { + this.emitCallback.call(this.emitCallbackScope, particle, this); + } + + if (this.atLimit()) + { + break; + } + } + + return particle; + }, + + /** + * Updates this emitter and its particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate + * @since 3.0.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. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var step = (delta / 1000); + + if (this.trackVisible) + { + this.visible = this.follow.visible; + } + + // Any particle processors? + var processors = this.manager.getProcessors(); + + var particles = this.alive; + var length = particles.length; + + for (var index = 0; index < length; index++) + { + var particle = particles[index]; + + // update returns `true` if the particle is now dead (lifeStep < 0) + if (particle.update(delta, step, processors)) + { + // Moves the dead particle to the end of the particles array (ready for splicing out later) + var last = particles[length - 1]; + + particles[length - 1] = particle; + particles[index] = last; + + index -= 1; + length -= 1; + } + } + + // Move dead particles to the dead array + var deadLength = particles.length - length; + + if (deadLength > 0) + { + var rip = particles.splice(particles.length - deadLength, deadLength); + + var deathCallback = this.deathCallback; + var deathCallbackScope = this.deathCallbackScope; + + if (deathCallback) + { + for (var i = 0; i < rip.length; i++) + { + deathCallback.call(deathCallbackScope, rip[i]); + } + } + + this.dead.concat(rip); + + StableSort.inplace(particles, this.indexSortCallback); + } + + if (!this.on) + { + return; + } + + if (this.frequency === 0) + { + this.emitParticle(); + } + else if (this.frequency > 0) + { + this._counter -= delta; + + if (this._counter <= 0) + { + this.emitParticle(); + + // counter = frequency - remained from previous delta + this._counter = (this.frequency - Math.abs(this._counter)); + } + } + }, + + /** + * Calculates the difference of two particles, for sorting them by depth. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback + * @since 3.0.0 + * + * @param {object} a - The first particle. + * @param {object} b - The second particle. + * + * @return {integer} The difference of a and b's y coordinates. + */ + depthSortCallback: function (a, b) + { + return a.y - b.y; + }, + + /** + * Calculates the difference of two particles, for sorting them by index. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback + * @since 3.0.0 + * + * @param {object} a - The first particle. + * @param {object} b - The second particle. + * + * @return {integer} The difference of a and b's `index` properties. + */ + indexSortCallback: function (a, b) + { + return a.index - b.index; + } + +}); + +module.exports = ParticleEmitter; + + +/***/ }), +/* 303 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(31); +var DistanceBetween = __webpack_require__(52); + +/** + * @classdesc + * A Particle is a simple Game Object controlled by a Particle Emitter and Manager, and rendered by the Manager. + * It uses its own lightweight physics system, and can interact only with its Emitter's bounds and zones. + * + * @class Particle + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to which this Particle belongs. + */ +var Particle = new Class({ + + initialize: + + function Particle (emitter) + { + /** + * The Emitter to which this Particle belongs. + * + * A Particle can only belong to a single Emitter and is created, updated and destroyed via it. + * + * @name Phaser.GameObjects.Particles.Particle#emitter + * @type {Phaser.GameObjects.Particles.ParticleEmitter} + * @since 3.0.0 + */ + this.emitter = emitter; + + /** + * The texture frame used to render this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#frame + * @type {Phaser.Textures.Frame} + * @default null + * @since 3.0.0 + */ + this.frame = null; + + /** + * The position of this Particle within its Emitter's particle pool. + * + * @name Phaser.GameObjects.Particles.Particle#index + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.index = 0; + + /** + * The x coordinate of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y coordinate of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The x velocity of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#velocityX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.velocityX = 0; + + /** + * The y velocity of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#velocityY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.velocityY = 0; + + /** + * The x acceleration of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#accelerationX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationX = 0; + + /** + * The y acceleration of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#accelerationY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationY = 0; + + /** + * The maximum horizontal velocity this Particle can travel at. + * + * @name Phaser.GameObjects.Particles.Particle#maxVelocityX + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityX = 10000; + + /** + * The maximum vertical velocity this Particle can travel at. + * + * @name Phaser.GameObjects.Particles.Particle#maxVelocityY + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityY = 10000; + + /** + * The bounciness, or restitution, of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#bounce + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.bounce = 0; + + /** + * The horizontal scale of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.scaleX = 1; + + /** + * The vertical scale of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.scaleY = 1; + + /** + * The alpha value of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#alpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.alpha = 1; + + /** + * The angle of this Particle in degrees. + * + * @name Phaser.GameObjects.Particles.Particle#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angle = 0; + + /** + * The angle of this Particle in radians. + * + * @name Phaser.GameObjects.Particles.Particle#rotation + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rotation = 0; + + /** + * The tint applied to this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#tint + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + this.tint = 0xffffff; + + /** + * The lifespan of this Particle in ms. + * + * @name Phaser.GameObjects.Particles.Particle#life + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.life = 1000; + + /** + * The current life of this Particle in ms. + * + * @name Phaser.GameObjects.Particles.Particle#lifeCurrent + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.lifeCurrent = 1000; + + /** + * The delay applied to this Particle upon emission, in ms. + * + * @name Phaser.GameObjects.Particles.Particle#delayCurrent + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.delayCurrent = 0; + + /** + * The normalized lifespan T value, where 0 is the start and 1 is the end. + * + * @name Phaser.GameObjects.Particles.Particle#lifeT + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lifeT = 0; + + /** + * The data used by the ease equation. + * + * @name Phaser.GameObjects.Particles.Particle#data + * @type {object} + * @since 3.0.0 + */ + this.data = { + tint: { min: 0xffffff, max: 0xffffff, current: 0xffffff }, + alpha: { min: 1, max: 1 }, + rotate: { min: 0, max: 0 }, + scaleX: { min: 1, max: 1 }, + scaleY: { min: 1, max: 1 } + }; + }, + + /** + * Checks to see if this Particle is alive and updating. + * + * @method Phaser.GameObjects.Particles.Particle#isAlive + * @since 3.0.0 + * + * @return {boolean} `true` if this Particle is alive and updating, otherwise `false`. + */ + isAlive: function () + { + return (this.lifeCurrent > 0); + }, + + /** + * Starts this Particle from the given coordinates. + * + * @method Phaser.GameObjects.Particles.Particle#fire + * @since 3.0.0 + * + * @param {number} x - The x coordinate to launch this Particle from. + * @param {number} y - The y coordinate to launch this Particle from. + */ + fire: function (x, y) + { + var emitter = this.emitter; + + this.frame = emitter.getFrame(); + + if (emitter.emitZone) + { + // Updates particle.x and particle.y during this call + emitter.emitZone.getPoint(this); + } + + if (x === undefined) + { + if (emitter.follow) + { + this.x += emitter.follow.x + emitter.followOffset.x; + } + + this.x += emitter.x.onEmit(this, 'x'); + } + else + { + this.x += x; + } + + if (y === undefined) + { + if (emitter.follow) + { + this.y += emitter.follow.y + emitter.followOffset.y; + } + + this.y += emitter.y.onEmit(this, 'y'); + } + else + { + this.y += y; + } + + this.life = emitter.lifespan.onEmit(this, 'lifespan'); + this.lifeCurrent = this.life; + this.lifeT = 0; + + var sx = emitter.speedX.onEmit(this, 'speedX'); + var sy = (emitter.speedY) ? emitter.speedY.onEmit(this, 'speedY') : sx; + + if (emitter.radial) + { + var rad = DegToRad(emitter.angle.onEmit(this, 'angle')); + + this.velocityX = Math.cos(rad) * Math.abs(sx); + this.velocityY = Math.sin(rad) * Math.abs(sy); + } + else if (emitter.moveTo) + { + var mx = emitter.moveToX.onEmit(this, 'moveToX'); + var my = (emitter.moveToY) ? emitter.moveToY.onEmit(this, 'moveToY') : mx; + + var angle = Math.atan2(my - this.y, mx - this.x); + + var speed = DistanceBetween(this.x, this.y, mx, my) / (this.life / 1000); + + // We know how many pixels we need to move, but how fast? + // var speed = this.distanceToXY(displayObject, x, y) / (maxTime / 1000); + + this.velocityX = Math.cos(angle) * speed; + this.velocityY = Math.sin(angle) * speed; + } + else + { + this.velocityX = sx; + this.velocityY = sy; + } + + if (emitter.acceleration) + { + this.accelerationX = emitter.accelerationX.onEmit(this, 'accelerationX'); + this.accelerationY = emitter.accelerationY.onEmit(this, 'accelerationY'); + } + + this.maxVelocityX = emitter.maxVelocityX.onEmit(this, 'maxVelocityX'); + this.maxVelocityY = emitter.maxVelocityY.onEmit(this, 'maxVelocityY'); + + this.delayCurrent = emitter.delay.onEmit(this, 'delay'); + + this.scaleX = emitter.scaleX.onEmit(this, 'scaleX'); + this.scaleY = (emitter.scaleY) ? emitter.scaleY.onEmit(this, 'scaleY') : this.scaleX; + + this.angle = emitter.rotate.onEmit(this, 'rotate'); + this.rotation = DegToRad(this.angle); + + this.bounce = emitter.bounce.onEmit(this, 'bounce'); + + this.alpha = emitter.alpha.onEmit(this, 'alpha'); + + this.tint = emitter.tint.onEmit(this, 'tint'); + + this.index = emitter.alive.length; + }, + + /** + * An internal method that calculates the velocity of the Particle. + * + * @method Phaser.GameObjects.Particles.Particle#computeVelocity + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter that is updating this Particle. + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + * @param {array} processors - Particle processors (gravity wells). + */ + computeVelocity: function (emitter, delta, step, processors) + { + var vx = this.velocityX; + var vy = this.velocityY; + + var ax = this.accelerationX; + var ay = this.accelerationY; + + var mx = this.maxVelocityX; + var my = this.maxVelocityY; + + vx += (emitter.gravityX * step); + vy += (emitter.gravityY * step); + + if (ax) + { + vx += (ax * step); + } + + if (ay) + { + vy += (ay * step); + } + + if (vx > mx) + { + vx = mx; + } + else if (vx < -mx) + { + vx = -mx; + } + + if (vy > my) + { + vy = my; + } + else if (vy < -my) + { + vy = -my; + } + + this.velocityX = vx; + this.velocityY = vy; + + // Apply any additional processors + for (var i = 0; i < processors.length; i++) + { + processors[i].update(this, delta, step); + } + }, + + /** + * Checks if this Particle is still within the bounds defined by the given Emitter. + * + * If not, and depending on the Emitter collision flags, the Particle may either stop or rebound. + * + * @method Phaser.GameObjects.Particles.Particle#checkBounds + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to check the bounds against. + */ + checkBounds: function (emitter) + { + var bounds = emitter.bounds; + var bounce = -this.bounce; + + if (this.x < bounds.x && emitter.collideLeft) + { + this.x = bounds.x; + this.velocityX *= bounce; + } + else if (this.x > bounds.right && emitter.collideRight) + { + this.x = bounds.right; + this.velocityX *= bounce; + } + + if (this.y < bounds.y && emitter.collideTop) + { + this.y = bounds.y; + this.velocityY *= bounce; + } + else if (this.y > bounds.bottom && emitter.collideBottom) + { + this.y = bounds.bottom; + this.velocityY *= bounce; + } + }, + + /** + * The main update method for this Particle. + * + * Updates its life values, computes the velocity and repositions the Particle. + * + * @method Phaser.GameObjects.Particles.Particle#update + * @since 3.0.0 + * + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + * @param {array} processors - An optional array of update processors. + * + * @return {boolean} Returns `true` if this Particle has now expired and should be removed, otherwise `false` if still active. + */ + update: function (delta, step, processors) + { + if (this.delayCurrent > 0) + { + this.delayCurrent -= delta; + + return false; + } + + var emitter = this.emitter; + + // How far along in life is this particle? (t = 0 to 1) + var t = 1 - (this.lifeCurrent / this.life); + + this.lifeT = t; + + this.computeVelocity(emitter, delta, step, processors); + + this.x += this.velocityX * step; + this.y += this.velocityY * step; + + if (emitter.bounds) + { + this.checkBounds(emitter); + } + + if (emitter.deathZone && emitter.deathZone.willKill(this)) + { + this.lifeCurrent = 0; + + // No need to go any further, particle has been killed + return true; + } + + this.scaleX = emitter.scaleX.onUpdate(this, 'scaleX', t, this.scaleX); + + if (emitter.scaleY) + { + this.scaleY = emitter.scaleY.onUpdate(this, 'scaleY', t, this.scaleY); + } + else + { + this.scaleY = this.scaleX; + } + + this.angle = emitter.rotate.onUpdate(this, 'rotate', t, this.angle); + this.rotation = DegToRad(this.angle); + + this.alpha = emitter.alpha.onUpdate(this, 'alpha', t, this.alpha); + + this.tint = emitter.tint.onUpdate(this, 'tint', t, this.tint); + + this.lifeCurrent -= delta; + + return (this.lifeCurrent <= 0); + } + +}); + +module.exports = Particle; + + +/***/ }), +/* 304 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); + +/** + * @typedef {object} GravityWellConfig + * + * @property {number} [x=0] - The x coordinate of the Gravity Well, in world space. + * @property {number} [y=0] - The y coordinate of the Gravity Well, in world space. + * @property {number} [power=0] - The power of the Gravity Well. + * @property {number} [epsilon=100] - [description] + * @property {number} [gravity=50] - The gravitational force of this Gravity Well. + */ + +/** + * @classdesc + * [description] + * + * @class GravityWell + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {(number|GravityWellConfig)} [x=0] - The x coordinate of the Gravity Well, in world space. + * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. + * @param {number} [power=0] - The power of the Gravity Well. + * @param {number} [epsilon=100] - [description] + * @param {number} [gravity=50] - The gravitational force of this Gravity Well. + */ +var GravityWell = new Class({ + + initialize: + + function GravityWell (x, y, power, epsilon, gravity) + { + if (typeof x === 'object') + { + var config = x; + + x = GetFastValue(config, 'x', 0); + y = GetFastValue(config, 'y', 0); + power = GetFastValue(config, 'power', 0); + epsilon = GetFastValue(config, 'epsilon', 100); + gravity = GetFastValue(config, 'gravity', 50); + } + else + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (power === undefined) { power = 0; } + if (epsilon === undefined) { epsilon = 100; } + if (gravity === undefined) { gravity = 50; } + } + + /** + * The x coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. + * + * @name Phaser.GameObjects.Particles.GravityWell#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * Internal gravity value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_gravity + * @type {number} + * @private + * @since 3.0.0 + */ + this._gravity = gravity; + + /** + * Internal power value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_power + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._power = 0; + + /** + * Internal epsilon value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_epsilon + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._epsilon = 0; + + /** + * The power of the Gravity Well. + * + * @name Phaser.GameObjects.Particles.GravityWell#power + * @type {number} + * @since 3.0.0 + */ + this.power = power; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.GravityWell#epsilon + * @type {number} + * @since 3.0.0 + */ + this.epsilon = epsilon; + }, + + /** + * Takes a Particle and updates it based on the properties of this Gravity Well. + * + * @method Phaser.GameObjects.Particles.GravityWell#update + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + */ + update: function (particle, delta) + { + var x = this.x - particle.x; + var y = this.y - particle.y; + var dSq = x * x + y * y; + + if (dSq === 0) + { + return; + } + + var d = Math.sqrt(dSq); + + if (dSq < this._epsilon) + { + dSq = this._epsilon; + } + + var factor = ((this._power * delta) / (dSq * d)) * 100; + + particle.velocityX += x * factor; + particle.velocityY += y * factor; + }, + + epsilon: { + + get: function () + { + return Math.sqrt(this._epsilon); + }, + + set: function (value) + { + this._epsilon = value * value; + } + + }, + + power: { + + get: function () + { + return this._power / this._gravity; + }, + + set: function (value) + { + this._power = value * this._gravity; + } + + }, + + gravity: { + + get: function () + { + return this._gravity; + }, + + set: function (value) + { + var pwr = this.power; + this._gravity = value; + this.power = pwr; + } + + } + +}); + +module.exports = GravityWell; + + +/***/ }), +/* 305 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Commands = __webpack_require__(157); +var SetTransform = __webpack_require__(22); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -37230,66 +70797,35 @@ var GameObject = __webpack_require__(2); * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested * @param {CanvasRenderingContext2D} [renderTargetCtx] - The target rendering context. - * @param {boolean} allowClip - [description] + * @param {boolean} allowClip - If `true` then path operations will be used instead of fill operations. */ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + var commandBuffer = src.commandBuffer; + var commandBufferLength = commandBuffer.length; + + var ctx = renderTargetCtx || renderer.currentContext; + + if (commandBufferLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) { return; } - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - var srcX = src.x; - var srcY = src.y; - var srcScaleX = src.scaleX; - var srcScaleY = src.scaleY; - var srcRotation = src.rotation; - var commandBuffer = src.commandBuffer; - var ctx = renderTargetCtx || renderer.currentContext; - var lineAlpha = 1.0; - var fillAlpha = 1.0; + var lineAlpha = 1; + var fillAlpha = 1; var lineColor = 0; var fillColor = 0; - var lineWidth = 1.0; + var lineWidth = 1; var red = 0; var green = 0; var blue = 0; - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - ctx.save(); - if (parentMatrix) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); - ctx.rotate(srcRotation); - ctx.scale(srcScaleX, srcScaleY); - ctx.fillStyle = '#fff'; - ctx.globalAlpha = src.alpha; - for (var index = 0, length = commandBuffer.length; index < length; ++index) + // Reset any currently active paths + ctx.beginPath(); + + for (var index = 0; index < commandBufferLength; ++index) { var commandID = commandBuffer[index]; @@ -37304,7 +70840,9 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c commandBuffer[index + 5], commandBuffer[index + 6] ); - index += 6; + + // +7 because overshoot is the 7th value, not used in Canvas + index += 7; break; case Commands.LINE_STYLE: @@ -37462,8 +71000,16 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c index += 1; break; - default: - // console.error('Phaser: Invalid Graphics Command ID ' + commandID); + case Commands.GRADIENT_FILL_STYLE: + index += 5; + break; + + case Commands.GRADIENT_LINE_STYLE: + index += 6; + break; + + case Commands.SET_TEXTURE: + index += 2; break; } } @@ -37475,7 +71021,7 @@ module.exports = GraphicsCanvasRenderer; /***/ }), -/* 177 */ +/* 306 */ /***/ (function(module, exports) { /** @@ -37507,7 +71053,7 @@ module.exports = Circumference; /***/ }), -/* 178 */ +/* 307 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37516,9 +71062,9 @@ module.exports = Circumference; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circumference = __webpack_require__(177); -var CircumferencePoint = __webpack_require__(113); -var FromPercent = __webpack_require__(65); +var Circumference = __webpack_require__(306); +var CircumferencePoint = __webpack_require__(156); +var FromPercent = __webpack_require__(93); var MATH_CONST = __webpack_require__(16); /** @@ -37561,7 +71107,7 @@ module.exports = GetPoints; /***/ }), -/* 179 */ +/* 308 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37570,10 +71116,10 @@ module.exports = GetPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CircumferencePoint = __webpack_require__(113); -var FromPercent = __webpack_require__(65); +var CircumferencePoint = __webpack_require__(156); +var FromPercent = __webpack_require__(93); var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); +var Point = __webpack_require__(6); /** * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse @@ -37586,7 +71132,7 @@ var Point = __webpack_require__(5); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. @@ -37604,7 +71150,419 @@ module.exports = GetPoint; /***/ }), -/* 180 */ +/* 309 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. + * + * @function Phaser.Geom.Rectangle.Union + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to use. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to use. + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the union in. + * + * @return {Phaser.Geom.Rectangle} The modified `out` Rectangle, or a new Rectangle if none was provided. + */ +var Union = function (rectA, rectB, out) +{ + if (out === undefined) { out = new Rectangle(); } + + // Cache vars so we can use one of the input rects as the output rect + var x = Math.min(rectA.x, rectB.x); + var y = Math.min(rectA.y, rectB.y); + var w = Math.max(rectA.right, rectB.right) - x; + var h = Math.max(rectA.bottom, rectB.bottom) - y; + + return out.setTo(x, y, w, h); +}; + +module.exports = Union; + + +/***/ }), +/* 310 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Read an integer value from an XML Node. + * + * @function getValue + * @since 3.0.0 + * @private + * + * @param {Node} node - The XML Node. + * @param {string} attribute - The attribute to read. + * + * @return {integer} The parsed value. + */ +function getValue (node, attribute) +{ + return parseInt(node.getAttribute(attribute), 10); +} + +/** + * Parse an XML font to Bitmap Font data for the Bitmap Font cache. + * + * @function ParseXMLBitmapFont + * @since 3.0.0 + * @private + * + * @param {XMLDocument} xml - The XML Document to parse the font from. + * @param {integer} [xSpacing=0] - The x-axis spacing to add between each letter. + * @param {integer} [ySpacing=0] - The y-axis spacing to add to the line height. + * @param {Phaser.Textures.Frame} [frame] - The texture frame to take into account while parsing. + * + * @return {BitmapFontData} The parsed Bitmap Font data. + */ +var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame) +{ + if (xSpacing === undefined) { xSpacing = 0; } + if (ySpacing === undefined) { ySpacing = 0; } + + var data = {}; + var info = xml.getElementsByTagName('info')[0]; + var common = xml.getElementsByTagName('common')[0]; + + data.font = info.getAttribute('face'); + data.size = getValue(info, 'size'); + data.lineHeight = getValue(common, 'lineHeight') + ySpacing; + data.chars = {}; + + var letters = xml.getElementsByTagName('char'); + + var adjustForTrim = (frame !== undefined && frame.trimmed); + + if (adjustForTrim) + { + var top = frame.height; + var left = frame.width; + } + + for (var i = 0; i < letters.length; i++) + { + var node = letters[i]; + + var charCode = getValue(node, 'id'); + var gx = getValue(node, 'x'); + var gy = getValue(node, 'y'); + var gw = getValue(node, 'width'); + var gh = getValue(node, 'height'); + + // Handle frame trim issues + + if (adjustForTrim) + { + if (gx < left) + { + left = gx; + } + + if (gy < top) + { + top = gy; + } + } + + data.chars[charCode] = + { + x: gx, + y: gy, + width: gw, + height: gh, + centerX: Math.floor(gw / 2), + centerY: Math.floor(gh / 2), + xOffset: getValue(node, 'xoffset'), + yOffset: getValue(node, 'yoffset'), + xAdvance: getValue(node, 'xadvance') + xSpacing, + data: {}, + kerning: {} + }; + } + + if (adjustForTrim && top !== 0 && left !== 0) + { + // console.log('top and left', top, left, frame.x, frame.y); + + // Now we know the top and left coordinates of the glyphs in the original data + // so we can work out how much to adjust the glyphs by + + for (var code in data.chars) + { + var glyph = data.chars[code]; + + glyph.x -= frame.x; + glyph.y -= frame.y; + } + } + + var kernings = xml.getElementsByTagName('kerning'); + + for (i = 0; i < kernings.length; i++) + { + var kern = kernings[i]; + + var first = getValue(kern, 'first'); + var second = getValue(kern, 'second'); + var amount = getValue(kern, 'amount'); + + data.chars[second].kerning[first] = amount; + } + + return data; +}; + +module.exports = ParseXMLBitmapFont; + + +/***/ }), +/* 311 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAdvancedValue = __webpack_require__(12); + +/** + * Adds an Animation component to a Sprite and populates it based on the given config. + * + * @function Phaser.GameObjects.BuildGameObjectAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - The sprite to add an Animation component to. + * @param {object} config - The animation config. + * + * @return {Phaser.GameObjects.Sprite} The updated Sprite. + */ +var BuildGameObjectAnimation = function (sprite, config) +{ + var animConfig = GetAdvancedValue(config, 'anims', null); + + if (animConfig === null) + { + return sprite; + } + + if (typeof animConfig === 'string') + { + // { anims: 'key' } + sprite.anims.play(animConfig); + } + else if (typeof animConfig === 'object') + { + // { anims: { + // key: string + // startFrame: [string|integer] + // delay: [float] + // repeat: [integer] + // repeatDelay: [float] + // yoyo: [boolean] + // play: [boolean] + // delayedPlay: [boolean] + // } + // } + + var anims = sprite.anims; + + var key = GetAdvancedValue(animConfig, 'key', undefined); + var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); + + var delay = GetAdvancedValue(animConfig, 'delay', 0); + var repeat = GetAdvancedValue(animConfig, 'repeat', 0); + var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); + var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); + + var play = GetAdvancedValue(animConfig, 'play', false); + var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); + + anims.setDelay(delay); + anims.setRepeat(repeat); + anims.setRepeatDelay(repeatDelay); + anims.setYoyo(yoyo); + + if (play) + { + anims.play(key, startFrame); + } + else if (delayedPlay > 0) + { + anims.delayedPlay(delayedPlay, key, startFrame); + } + else + { + anims.load(key); + } + } + + return sprite; +}; + +module.exports = BuildGameObjectAnimation; + + +/***/ }), +/* 312 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); +var Shuffle = __webpack_require__(122); + +var BuildChunk = function (a, b, qty) +{ + var out = []; + + for (var aIndex = 0; aIndex < a.length; aIndex++) + { + for (var bIndex = 0; bIndex < b.length; bIndex++) + { + for (var i = 0; i < qty; i++) + { + out.push({ a: a[aIndex], b: b[bIndex] }); + } + } + } + + return out; +}; + +// options = repeat, random, randomB, yoyo, max, qty + +// Range ([a,b,c], [1,2,3]) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2,3], qty = 3) = +// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 + +// Range ([a,b,c], [1,2,3], repeat x1) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = +// Maybe if max is set then repeat goes to -1 automatically? +// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) + +// Range ([a], [1,2,3,4,5], random = true) = +// a4, a1, a5, a2, a3 + +// Range ([a, b], [1,2,3], random = true) = +// b3, a2, a1, b1, a3, b2 + +// Range ([a, b, c], [1,2,3], randomB = true) = +// a3, a1, a2, b2, b3, b1, c1, c3, c2 + +// Range ([a], [1,2,3,4,5], yoyo = true) = +// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 + +// Range ([a, b], [1,2,3], yoyo = true) = +// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 + +/** + * [description] + * + * @function Phaser.Utils.Array.Range + * @since 3.0.0 + * + * @param {array} a - [description] + * @param {array} b - [description] + * @param {object} options - [description] + * + * @return {array} [description] + */ +var Range = function (a, b, options) +{ + var max = GetValue(options, 'max', 0); + var qty = GetValue(options, 'qty', 1); + var random = GetValue(options, 'random', false); + var randomB = GetValue(options, 'randomB', false); + var repeat = GetValue(options, 'repeat', 0); + var yoyo = GetValue(options, 'yoyo', false); + + var out = []; + + if (randomB) + { + Shuffle(b); + } + + // Endless repeat, so limit by max + if (repeat === -1) + { + if (max === 0) + { + repeat = 0; + } + else + { + // Work out how many repeats we need + var total = (a.length * b.length) * qty; + + if (yoyo) + { + total *= 2; + } + + repeat = Math.ceil(max / total); + } + } + + for (var i = 0; i <= repeat; i++) + { + var chunk = BuildChunk(a, b, qty); + + if (random) + { + Shuffle(chunk); + } + + out = out.concat(chunk); + + if (yoyo) + { + chunk.reverse(); + + out = out.concat(chunk); + } + } + + if (max) + { + out.splice(max); + } + + return out; +}; + +module.exports = Range; + + +/***/ }), +/* 313 */ /***/ (function(module, exports) { /** @@ -37722,7 +71680,36 @@ module.exports = QuickSelect; /***/ }), -/* 181 */ +/* 314 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Round a given number so it is further away from zero. That is, positive numbers are rounded up, and negative numbers are rounded down. + * + * @function Phaser.Math.RoundAwayFromZero + * @since 3.0.0 + * + * @param {number} value - The number to round. + * + * @return {number} The rounded number, rounded away from zero. + */ +var RoundAwayFromZero = function (value) +{ + // "Opposite" of truncate. + return (value > 0) ? Math.ceil(value) : Math.floor(value); +}; + +module.exports = RoundAwayFromZero; + + +/***/ }), +/* 315 */ /***/ (function(module, exports) { /** @@ -37768,7 +71755,7 @@ module.exports = TransposeMatrix; /***/ }), -/* 182 */ +/* 316 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37783,20 +71770,20 @@ module.exports = TransposeMatrix; module.exports = { - AtlasXML: __webpack_require__(514), - Canvas: __webpack_require__(513), - Image: __webpack_require__(512), - JSONArray: __webpack_require__(511), - JSONHash: __webpack_require__(510), - SpriteSheet: __webpack_require__(509), - SpriteSheetFromAtlas: __webpack_require__(508), - UnityYAML: __webpack_require__(507) + AtlasXML: __webpack_require__(886), + Canvas: __webpack_require__(885), + Image: __webpack_require__(884), + JSONArray: __webpack_require__(883), + JSONHash: __webpack_require__(882), + SpriteSheet: __webpack_require__(881), + SpriteSheetFromAtlas: __webpack_require__(880), + UnityYAML: __webpack_require__(879) }; /***/ }), -/* 183 */ +/* 317 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37805,10 +71792,10 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CanvasPool = __webpack_require__(22); +var CanvasPool = __webpack_require__(24); var Class = __webpack_require__(0); -var IsSizePowerOfTwo = __webpack_require__(85); -var ScaleModes = __webpack_require__(59); +var IsSizePowerOfTwo = __webpack_require__(117); +var ScaleModes = __webpack_require__(94); /** * @classdesc @@ -37818,7 +71805,7 @@ var ScaleModes = __webpack_require__(59); * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. * * @class TextureSource - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * @@ -37848,13 +71835,24 @@ var TextureSource = new Class({ * The Texture this TextureSource belongs to. * * @name Phaser.Textures.TextureSource#texture - * @type {string} + * @type {Phaser.Textures.Texture} * @since 3.0.0 */ this.texture = texture; /** - * The source image data. This is either an Image Element, or a Canvas Element. + * The source of the image data. + * This is either an Image Element, a Canvas Element or a RenderTexture. + * + * @name Phaser.Textures.TextureSource#source + * @type {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)} + * @since 3.12.0 + */ + this.source = source; + + /** + * The image data. + * This is either an Image element or a Canvas element. * * @name Phaser.Textures.TextureSource#image * @type {(HTMLImageElement|HTMLCanvasElement)} @@ -37921,6 +71919,15 @@ var TextureSource = new Class({ */ this.isCanvas = (source instanceof HTMLCanvasElement); + /** + * Is the source image a Render Texture? + * + * @name Phaser.Textures.TextureSource#isRenderTexture + * @type {boolean} + * @since 3.12.0 + */ + this.isRenderTexture = (source.type === 'RenderTexture'); + /** * Are the source image dimensions a power of two? * @@ -37953,19 +71960,32 @@ var TextureSource = new Class({ */ init: function (game) { - if (this.renderer && this.renderer.gl) + if (this.renderer) { - if (this.isCanvas) + if (this.renderer.gl) { - this.glTexture = this.renderer.canvasToTexture(this.image); + if (this.isCanvas) + { + this.glTexture = this.renderer.canvasToTexture(this.image); + } + else if (this.isRenderTexture) + { + this.image = this.source.canvas; + + this.glTexture = this.renderer.createTextureFromSource(null, this.width, this.height, this.scaleMode); + } + else + { + this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + } } - else + else if (this.isRenderTexture) { - this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + this.image = this.source.canvas; } } - if (game.config.pixelArt) + if (!game.config.antialias) { this.setFilter(1); } @@ -38002,7 +72022,20 @@ var TextureSource = new Class({ { if (this.renderer.gl && this.isCanvas) { - this.renderer.canvasToTexture(this.image, this.glTexture); + this.glTexture = this.renderer.canvasToTexture(this.image, this.glTexture); + + // Update all the Frames using this TextureSource + + /* + var index = this.texture.getTextureSourceIndex(this); + + var frames = this.texture.getFramesFromTextureSource(index, true); + + for (var i = 0; i < frames.length; i++) + { + frames[i].glTexture = this.glTexture; + } + */ } }, @@ -38026,7 +72059,9 @@ var TextureSource = new Class({ this.renderer = null; this.texture = null; + this.source = null; this.image = null; + this.glTexture = null; } }); @@ -38035,7 +72070,7 @@ module.exports = TextureSource; /***/ }), -/* 184 */ +/* 318 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -38044,21 +72079,21 @@ module.exports = TextureSource; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CanvasPool = __webpack_require__(22); -var CanvasTexture = __webpack_require__(515); +var CanvasPool = __webpack_require__(24); +var CanvasTexture = __webpack_require__(887); var Class = __webpack_require__(0); -var Color = __webpack_require__(30); -var CONST = __webpack_require__(20); -var EventEmitter = __webpack_require__(9); -var GenerateTexture = __webpack_require__(276); +var Color = __webpack_require__(37); +var CONST = __webpack_require__(26); +var EventEmitter = __webpack_require__(11); +var GenerateTexture = __webpack_require__(357); var GetValue = __webpack_require__(4); -var Parser = __webpack_require__(182); -var Texture = __webpack_require__(117); +var Parser = __webpack_require__(316); +var Texture = __webpack_require__(165); /** * @callback EachTextureCallback * - * @param {Phaser.Textures.Texture} texture - [description] + * @param {Phaser.Textures.Texture} texture - Each texture in Texture Manager. * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. */ @@ -38073,11 +72108,11 @@ var Texture = __webpack_require__(117); * * @class TextureManager * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - The Phaser.Game instance this Texture Manager belongs to. */ var TextureManager = new Class({ @@ -38090,7 +72125,7 @@ var TextureManager = new Class({ EventEmitter.call(this); /** - * [description] + * The Game that this TextureManager belongs to. * * @name Phaser.Textures.TextureManager#game * @type {Phaser.Game} @@ -38099,7 +72134,7 @@ var TextureManager = new Class({ this.game = game; /** - * [description] + * The name of this manager. * * @name Phaser.Textures.TextureManager#name * @type {string} @@ -38108,7 +72143,8 @@ var TextureManager = new Class({ this.name = 'TextureManager'; /** - * [description] + * An object that has all of textures that Texture Manager creates. + * Textures are assigned to keys so we can access to any texture that this object has directly by key value without iteration. * * @name Phaser.Textures.TextureManager#list * @type {object} @@ -38118,7 +72154,7 @@ var TextureManager = new Class({ this.list = {}; /** - * [description] + * The temporary canvas element to save an pixel data of an arbitrary texture in getPixel() and getPixelAlpha() method. * * @name Phaser.Textures.TextureManager#_tempCanvas * @type {HTMLCanvasElement} @@ -38128,7 +72164,7 @@ var TextureManager = new Class({ this._tempCanvas = CanvasPool.create2D(this, 1, 1); /** - * [description] + * The context of the temporary canvas element made to save an pixel data in getPixel() and getPixelAlpha() method. * * @name Phaser.Textures.TextureManager#_tempContext * @type {CanvasRenderingContext2D} @@ -38138,7 +72174,7 @@ var TextureManager = new Class({ this._tempContext = this._tempCanvas.getContext('2d'); /** - * [description] + * An counting value used for emitting 'ready' event after all of managers in game is loaded. * * @name Phaser.Textures.TextureManager#_pending * @type {integer} @@ -38152,9 +72188,10 @@ var TextureManager = new Class({ }, /** - * [description] + * The Boot Handler called by Phaser.Game when it first starts up. * * @method Phaser.Textures.TextureManager#boot + * @private * @since 3.0.0 */ boot: function () @@ -38171,9 +72208,10 @@ var TextureManager = new Class({ }, /** - * [description] + * After 'onload' or 'onerror' invoked twice, emit 'ready' event. * * @method Phaser.Textures.TextureManager#updatePending + * @private * @since 3.0.0 */ updatePending: function () @@ -38185,7 +72223,7 @@ var TextureManager = new Class({ this.off('onload'); this.off('onerror'); - this.game.events.emit('ready'); + this.game.events.emit('texturesready'); } }, @@ -38265,6 +72303,8 @@ var TextureManager = new Class({ * * @param {string} key - The unique string-based key of the Texture. * @param {*} data - The Base64 encoded data. + * + * @return {this} This Texture Manager instance. */ addBase64: function (key, data) { @@ -38292,6 +72332,59 @@ var TextureManager = new Class({ image.src = data; } + + return this; + }, + + /** + * Gets an existing texture frame and converts it into a base64 encoded image and returns the base64 data. + * + * You can also provide the image type and encoder options. + * + * @method Phaser.Textures.TextureManager#getBase64 + * @since 3.12.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. + * @param {string} [type='image/png'] - [description] + * @param {number} [encoderOptions=0.92] - [description] + * + * @return {string} The base64 encoded data, or an empty string if the texture frame could not be found. + */ + getBase64: function (key, frame, type, encoderOptions) + { + if (type === undefined) { type = 'image/png'; } + if (encoderOptions === undefined) { encoderOptions = 0.92; } + + var data = ''; + + var textureFrame = this.getFrame(key, frame); + + if (textureFrame) + { + var cd = textureFrame.canvasData; + + var canvas = CanvasPool.create2D(this, cd.width, cd.height); + var ctx = canvas.getContext('2d'); + + ctx.drawImage( + textureFrame.source.image, + cd.x, + cd.y, + cd.width, + cd.height, + 0, + 0, + cd.width, + cd.height + ); + + data = canvas.toDataURL(type, encoderOptions); + + CanvasPool.remove(canvas); + } + + return data; }, /** @@ -38327,6 +72420,34 @@ var TextureManager = new Class({ return texture; }, + /** + * Adds a Render Texture to the Texture Manager using the given key. + * This allows you to then use the Render Texture as a normal texture for texture based Game Objects like Sprites. + * + * @method Phaser.Textures.TextureManager#addRenderTexture + * @since 3.12.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {Phaser.GameObjects.RenderTexture} renderTexture - The source Render Texture. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addRenderTexture: function (key, renderTexture) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, renderTexture); + + texture.add('__BASE', 0, 0, 0, renderTexture.width, renderTexture.height); + + this.emit('addtexture', key, texture); + } + + return texture; + }, + /** * Creates a new Texture using the given config values. * Generated textures consist of a Canvas element to which the texture data is drawn. @@ -38336,7 +72457,7 @@ var TextureManager = new Class({ * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. - * @param {object} config - [description] + * @param {object} config - The configuration object needed to generate the texture. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -38389,22 +72510,29 @@ var TextureManager = new Class({ }, /** - * Creates a new Canvas Texture object from an existing Canvas element and adds - * it to this Texture Manager. + * Creates a new Canvas Texture object from an existing Canvas element + * and adds it to this Texture Manager, unless `skipCache` is true. * * @method Phaser.Textures.TextureManager#addCanvas * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. * @param {HTMLCanvasElement} source - The Canvas element to form the base of the new Texture. + * @param {boolean} [skipCache=false] - Skip adding this Texture into the Cache? * * @return {?Phaser.Textures.CanvasTexture} The Canvas Texture that was created, or `null` if the key is already in use. */ - addCanvas: function (key, source) + addCanvas: function (key, source, skipCache) { + if (skipCache === undefined) { skipCache = false; } + var texture = null; - if (this.checkKey(key)) + if (skipCache) + { + texture = new CanvasTexture(this, key, source, source.width, source.height); + } + else if (this.checkKey(key)) { texture = new CanvasTexture(this, key, source, source.width, source.height); @@ -38815,7 +72943,7 @@ var TextureManager = new Class({ * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. - * @param {(string|integer)} frame - The string or index of the Frame. + * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. * * @return {Phaser.Textures.Frame} A Texture Frame object. */ @@ -38873,25 +73001,23 @@ var TextureManager = new Class({ if (textureFrame) { - var source = textureFrame.source.image; + // Adjust for trim (if not trimmed x and y are just zero) + x -= textureFrame.x; + y -= textureFrame.y; - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) + var data = textureFrame.data.cut; + + x += data.x; + y += data.y; + + if (x >= data.x && x < data.r && y >= data.y && y < data.b) { - x += textureFrame.cutX; - y += textureFrame.cutY; + var ctx = this._tempContext; - // if (textureFrame.trimmed) - // { - // x -= this.sprite.texture.trim.x; - // y -= this.sprite.texture.trim.y; - // } + ctx.clearRect(0, 0, 1, 1); + ctx.drawImage(textureFrame.source.image, x, y, 1, 1, 0, 0, 1, 1); - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); + var rgb = ctx.getImageData(0, 0, 1, 1); return new Color(rgb.data[0], rgb.data[1], rgb.data[2], rgb.data[3]); } @@ -38921,20 +73047,24 @@ var TextureManager = new Class({ if (textureFrame) { - var source = textureFrame.source.image; + // Adjust for trim (if not trimmed x and y are just zero) + x -= textureFrame.x; + y -= textureFrame.y; - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) + var data = textureFrame.data.cut; + + x += data.x; + y += data.y; + + if (x >= data.x && x < data.r && y >= data.y && y < data.b) { - x += textureFrame.cutX; - y += textureFrame.cutY; - - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); + var ctx = this._tempContext; + ctx.clearRect(0, 0, 1, 1); + ctx.drawImage(textureFrame.source.image, x, y, 1, 1, 0, 0, 1, 1); + + var rgb = ctx.getImageData(0, 0, 1, 1); + return rgb.data[3]; } } @@ -38949,7 +73079,7 @@ var TextureManager = new Class({ * @method Phaser.Textures.TextureManager#setTexture * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the texture would be set on. * @param {string} key - The unique string-based key of the Texture. * @param {(string|integer)} frame - The string or index of the Frame. * @@ -38966,6 +73096,40 @@ var TextureManager = new Class({ return gameObject; }, + /** + * Changes the key being used by a Texture to the new key provided. + * + * The old key is removed, allowing it to be re-used. + * + * Game Objects are linked to Textures by a reference to the Texture object, so + * all existing references will be retained. + * + * @method Phaser.Textures.TextureManager#renameTexture + * @since 3.12.0 + * + * @param {string} currentKey - The current string-based key of the Texture you wish to rename. + * @param {string} newKey - The new unique string-based key to use for the Texture. + * + * @return {boolean} `true` if the Texture key was successfully renamed, otherwise `false`. + */ + renameTexture: function (currentKey, newKey) + { + var texture = this.get(currentKey); + + if (texture && currentKey !== newKey) + { + texture.key = newKey; + + this.list[newKey] = texture; + + delete this.list[currentKey]; + + return true; + } + + return false; + }, + /** * Passes all Textures to the given callback. * @@ -39019,7 +73183,7 @@ module.exports = TextureManager; /***/ }), -/* 185 */ +/* 319 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -39029,7 +73193,7 @@ module.exports = TextureManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSound = __webpack_require__(78); +var BaseSound = __webpack_require__(114); var Class = __webpack_require__(0); /** @@ -39038,7 +73202,7 @@ var Class = __webpack_require__(0); * * @class WebAudioSound * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -39986,7 +74150,7 @@ module.exports = WebAudioSound; /***/ }), -/* 186 */ +/* 320 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -39996,9 +74160,9 @@ module.exports = WebAudioSound; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSoundManager = __webpack_require__(79); +var BaseSoundManager = __webpack_require__(115); var Class = __webpack_require__(0); -var WebAudioSound = __webpack_require__(185); +var WebAudioSound = __webpack_require__(319); /** * @classdesc @@ -40006,7 +74170,7 @@ var WebAudioSound = __webpack_require__(185); * * @class WebAudioSoundManager * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -40313,7 +74477,7 @@ module.exports = WebAudioSoundManager; /***/ }), -/* 187 */ +/* 321 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40323,10 +74487,10 @@ module.exports = WebAudioSoundManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSound = __webpack_require__(78); +var BaseSound = __webpack_require__(114); var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Extend = __webpack_require__(17); +var EventEmitter = __webpack_require__(11); +var Extend = __webpack_require__(20); /** * @classdesc @@ -40339,7 +74503,7 @@ var Extend = __webpack_require__(17); * * @class NoAudioSound * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -40440,7 +74604,7 @@ module.exports = NoAudioSound; /***/ }), -/* 188 */ +/* 322 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40450,11 +74614,11 @@ module.exports = NoAudioSound; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSoundManager = __webpack_require__(79); +var BaseSoundManager = __webpack_require__(115); var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var NoAudioSound = __webpack_require__(187); -var NOOP = __webpack_require__(3); +var EventEmitter = __webpack_require__(11); +var NoAudioSound = __webpack_require__(321); +var NOOP = __webpack_require__(1); /** * @classdesc @@ -40467,7 +74631,7 @@ var NOOP = __webpack_require__(3); * * @class NoAudioSoundManager * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -40558,7 +74722,7 @@ module.exports = NoAudioSoundManager; /***/ }), -/* 189 */ +/* 323 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40568,7 +74732,7 @@ module.exports = NoAudioSoundManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSound = __webpack_require__(78); +var BaseSound = __webpack_require__(114); var Class = __webpack_require__(0); /** @@ -40577,7 +74741,7 @@ var Class = __webpack_require__(0); * * @class HTML5AudioSound * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -41540,7 +75704,7 @@ module.exports = HTML5AudioSound; /***/ }), -/* 190 */ +/* 324 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -41550,16 +75714,16 @@ module.exports = HTML5AudioSound; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSoundManager = __webpack_require__(79); +var BaseSoundManager = __webpack_require__(115); var Class = __webpack_require__(0); -var HTML5AudioSound = __webpack_require__(189); +var HTML5AudioSound = __webpack_require__(323); /** * HTML5 Audio implementation of the Sound Manager. * * @class HTML5AudioSoundManager * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -42007,7 +76171,7 @@ module.exports = HTML5AudioSoundManager; /***/ }), -/* 191 */ +/* 325 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -42017,9 +76181,9 @@ module.exports = HTML5AudioSoundManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var HTML5AudioSoundManager = __webpack_require__(190); -var NoAudioSoundManager = __webpack_require__(188); -var WebAudioSoundManager = __webpack_require__(186); +var HTML5AudioSoundManager = __webpack_require__(324); +var NoAudioSoundManager = __webpack_require__(322); +var WebAudioSoundManager = __webpack_require__(320); /** * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. @@ -42057,7 +76221,7 @@ module.exports = SoundManagerCreator; /***/ }), -/* 192 */ +/* 326 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -42066,10 +76230,10 @@ module.exports = SoundManagerCreator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(55); +var CONST = __webpack_require__(116); var GetValue = __webpack_require__(4); -var Merge = __webpack_require__(94); -var InjectionMap = __webpack_require__(516); +var Merge = __webpack_require__(96); +var InjectionMap = __webpack_require__(888); /** * @namespace Phaser.Scenes.Settings @@ -42189,7 +76353,44 @@ module.exports = Settings; /***/ }), -/* 193 */ +/* 327 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Capitalizes the first letter of a string if there is one. + * @example + * UppercaseFirst('abc'); + * // returns 'Abc' + * @example + * UppercaseFirst('the happy family'); + * // returns 'The happy family' + * @example + * UppercaseFirst(''); + * // returns '' + * + * @function Phaser.Utils.String.UppercaseFirst + * @since 3.0.0 + * + * @param {string} str - The string to capitalize. + * + * @return {string} A new string, same as the first, but with the first letter capitalized. + */ +var UppercaseFirst = function (str) +{ + return str && str[0].toUpperCase() + str.slice(1); +}; + +module.exports = UppercaseFirst; + + +/***/ }), +/* 328 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -42199,14 +76400,14 @@ module.exports = Settings; */ var Class = __webpack_require__(0); -var Systems = __webpack_require__(118); +var Systems = __webpack_require__(166); /** * @classdesc * [description] * * @class Scene - * @memberOf Phaser + * @memberof Phaser * @constructor * @since 3.0.0 * @@ -42307,16 +76508,6 @@ var Scene = new Class({ */ this.cameras; - /** - * A scene level 3D Camera System. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#cameras3d - * @type {Phaser.Cameras.Sprite3D.CameraManager} - * @since 3.0.0 - */ - this.cameras3d; - /** * A scene level Game Object Factory. * This property will only be available if defined in the Scene Injection Map. @@ -42455,8 +76646,8 @@ var Scene = new Class({ * @override * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function () { @@ -42468,7 +76659,7 @@ module.exports = Scene; /***/ }), -/* 194 */ +/* 329 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -42478,11 +76669,11 @@ module.exports = Scene; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(55); +var CONST = __webpack_require__(116); var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var Scene = __webpack_require__(193); -var Systems = __webpack_require__(118); +var NOOP = __webpack_require__(1); +var Scene = __webpack_require__(328); +var Systems = __webpack_require__(166); /** * @classdesc @@ -42493,7 +76684,7 @@ var Systems = __webpack_require__(118); * * * @class SceneManager - * @memberOf Phaser.Scenes + * @memberof Phaser.Scenes * @constructor * @since 3.0.0 * @@ -42579,7 +76770,7 @@ var SceneManager = new Class({ * @name Phaser.Scenes.SceneManager#isProcessing * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isProcessing = false; @@ -42590,11 +76781,22 @@ var SceneManager = new Class({ * @name Phaser.Scenes.SceneManager#isBooted * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.4.0 */ this.isBooted = false; + /** + * Do any of the Cameras in any of the Scenes require a custom viewport? + * If not we can skip scissor tests. + * + * @name Phaser.Scenes.SceneManager#customViewports + * @type {number} + * @default 0 + * @since 3.12.0 + */ + this.customViewports = 0; + if (sceneConfig) { if (!Array.isArray(sceneConfig)) @@ -42613,7 +76815,7 @@ var SceneManager = new Class({ }); } } - + game.events.once('ready', this.bootQueue, this); }, @@ -42850,7 +77052,7 @@ var SceneManager = new Class({ * The Scene is removed from the local scenes array, it's key is cleared from the keys * cache and Scene.Systems.destroy is then called on it. * - * If the SceneManager is processing the Scenes when this method is called it wil + * If the SceneManager is processing the Scenes when this method is called it will * queue the operation for the next update sequence. * * @method Phaser.Scenes.SceneManager#remove @@ -42914,6 +77116,8 @@ var SceneManager = new Class({ { scene.init.call(scene, settings.data); + settings.status = CONST.INIT; + if (settings.isTransition) { sys.events.emit('transitioninit', settings.transitionFrom, settings.transitionDuration); @@ -43080,9 +77284,9 @@ var SceneManager = new Class({ if (scene.create) { - scene.sys.settings.status = CONST.CREATING; + settings.status = CONST.CREATING; - scene.create.call(scene, scene.sys.settings.data); + scene.create.call(scene, settings.data); if (settings.isTransition) { @@ -43398,16 +77602,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its pause event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - pause: function (key) + pause: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.pause(); + scene.sys.pause(data); } return this; @@ -43420,16 +77625,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its resume event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - resume: function (key) + resume: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.resume(); + scene.sys.resume(data); } return this; @@ -43442,16 +77648,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its sleep event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - sleep: function (key) + sleep: function (key, data) { var scene = this.getScene(key); if (scene && !scene.sys.isTransitioning()) { - scene.sys.sleep(); + scene.sys.sleep(data); } return this; @@ -43464,16 +77671,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its wake event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - wake: function (key) + wake: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.wake(); + scene.sys.wake(data); } return this; @@ -43481,7 +77689,7 @@ var SceneManager = new Class({ /** * Runs the given Scene, but does not change the state of this Scene. - * + * * If the given Scene is paused, it will resume it. If sleeping, it will wake it. * If not running at all, it will be started. * @@ -43492,7 +77700,7 @@ var SceneManager = new Class({ * @since 3.10.0 * * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param {object} [data] - A data object that will be passed to the Scene on start, wake, or resume. * * @return {Phaser.Scenes.SceneManager} This Scene Manager. */ @@ -43502,18 +77710,26 @@ var SceneManager = new Class({ if (!scene) { + for (var i = 0; i < this._pending.length; i++) + { + if (this._pending[i].key === key) + { + this.queueOp('start', key, data); + break; + } + } return this; } if (scene.sys.isSleeping()) { // Sleeping? - scene.sys.wake(); + scene.sys.wake(data); } else if (scene.sys.isBooted && !scene.sys.isActive()) { // Paused? - scene.sys.resume(); + scene.sys.resume(data); } else { @@ -43550,29 +77766,40 @@ var SceneManager = new Class({ if (scene) { - scene.sys.start(data); - - var loader; - - if (scene.sys.load) + // If the Scene is already running (perhaps they called start from a launched sub-Scene?) + // then we close it down before starting it again. + if (scene.sys.isActive() || scene.sys.isPaused()) { - loader = scene.sys.load; + scene.sys.shutdown(); + + scene.sys.start(data); } - - // Files payload? - if (loader && scene.sys.settings.hasOwnProperty('pack')) + else { - loader.reset(); + scene.sys.start(data); - if (loader.addPack({ payload: scene.sys.settings.pack })) + var loader; + + if (scene.sys.load) { - scene.sys.settings.status = CONST.LOADING; - - loader.once('complete', this.payloadComplete, this); - - loader.start(); - - return this; + loader = scene.sys.load; + } + + // Files payload? + if (loader && scene.sys.settings.hasOwnProperty('pack')) + { + loader.reset(); + + if (loader.addPack({ payload: scene.sys.settings.pack })) + { + scene.sys.settings.status = CONST.LOADING; + + loader.once('complete', this.payloadComplete, this); + + loader.start(); + + return this; + } } } @@ -43991,7 +78218,7 @@ var SceneManager = new Class({ */ destroy: function () { - for (var i = this.scenes.length - 1; i >= 0; i--) + for (var i = 0; i < this.scenes.length; i++) { var sys = this.scenes[i].sys; @@ -44015,7 +78242,7 @@ module.exports = SceneManager; /***/ }), -/* 195 */ +/* 330 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -44024,7 +78251,7 @@ module.exports = SceneManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SpliceOne = __webpack_require__(56); +var SpliceOne = __webpack_require__(91); /** * Removes the given item, or array of items, from the array. @@ -44106,7 +78333,7 @@ module.exports = Remove; /***/ }), -/* 196 */ +/* 331 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -44116,13 +78343,13 @@ module.exports = Remove; */ var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); +var EventEmitter = __webpack_require__(11); var FileTypesManager = __webpack_require__(7); var GameObjectCreator = __webpack_require__(13); -var GameObjectFactory = __webpack_require__(11); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); -var Remove = __webpack_require__(195); +var GameObjectFactory = __webpack_require__(5); +var GetFastValue = __webpack_require__(2); +var PluginCache = __webpack_require__(15); +var Remove = __webpack_require__(330); /** * @typedef {object} GlobalPlugin @@ -44168,7 +78395,7 @@ var Remove = __webpack_require__(195); * For information on creating your own plugin please see the Phaser 3 Plugin Template. * * @class PluginManager - * @memberOf Phaser.Plugins + * @memberof Phaser.Plugins * @constructor * @since 3.0.0 * @@ -44257,6 +78484,7 @@ var PluginManager = new Class({ var plugin; var start; var mapping; + var data; var config = this.game.config; // Any plugins to install? @@ -44269,16 +78497,17 @@ var PluginManager = new Class({ { entry = list[i]; - // { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test' } + // { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test', data: { msg: 'The plugin is alive' } } key = GetFastValue(entry, 'key', null); plugin = GetFastValue(entry, 'plugin', null); start = GetFastValue(entry, 'start', false); mapping = GetFastValue(entry, 'mapping', null); + data = GetFastValue(entry, 'data', null); if (key && plugin) { - this.install(key, plugin, start, mapping); + this.install(key, plugin, start, mapping, data); } } @@ -44350,6 +78579,10 @@ var PluginManager = new Class({ scene[map[pluginKey]] = sys[pluginKey]; } } + else if (pluginKey === 'game' && map.hasOwnProperty(pluginKey)) + { + scene[map[pluginKey]] = game; + } } for (var s = 0; s < scenePlugins.length; s++) @@ -44510,11 +78743,13 @@ var PluginManager = new Class({ * @param {function} plugin - The plugin code. This should be the non-instantiated version. * @param {boolean} [start=false] - Automatically start the plugin running? This is always `true` if you provide a mapping value. * @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use. + * @param {any} [data] - A value passed to the plugin's `init` method. */ - install: function (key, plugin, start, mapping) + install: function (key, plugin, start, mapping, data) { if (start === undefined) { start = false; } if (mapping === undefined) { mapping = null; } + if (data === undefined) { data = null; } if (typeof plugin !== 'function') { @@ -44535,12 +78770,12 @@ var PluginManager = new Class({ if (!this.game.isBooted) { - this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping }); + this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping, data: data }); } else { // Add it to the plugin store - PluginCache.registerCustom(key, plugin, mapping); + PluginCache.registerCustom(key, plugin, mapping, data); if (start) { @@ -44679,12 +78914,13 @@ var PluginManager = new Class({ key: runAs, plugin: instance, active: true, - mapping: entry.mapping + mapping: entry.mapping, + data: entry.data }; this.plugins.push(entry); - instance.init(); + instance.init(entry.data); instance.start(); } @@ -44915,7 +79151,8 @@ var PluginManager = new Class({ /** * Destroys this Plugin Manager and all associated plugins. * It will iterate all plugins found and call their `destroy` methods. - * Note that the PluginCache is NOT cleared by this as it doesn't hold any plugin instances. + * + * The PluginCache will remove all custom plugins. * * @method Phaser.Plugins.PluginManager#destroy * @since 3.8.0 @@ -44927,6 +79164,13 @@ var PluginManager = new Class({ this.plugins[i].plugin.destroy(); } + PluginCache.destroyCustomPlugins(); + + if (this.game.noReturn) + { + PluginCache.destroyCorePlugins(); + } + this.game = null; this.plugins = []; this.scenePlugins = []; @@ -44944,7 +79188,62 @@ module.exports = PluginManager; /***/ }), -/* 197 */ +/* 332 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector2 = __webpack_require__(3); + +/** + * Takes the `x` and `y` coordinates and transforms them into the same space as + * defined by the position, rotation and scale values. + * + * @function Phaser.Math.TransformXY + * @since 3.0.0 + * + * @param {number} x - The x coordinate to be transformed. + * @param {number} y - The y coordinate to be transformed. + * @param {number} positionX - Horizontal position of the transform point. + * @param {number} positionY - Vertical position of the transform point. + * @param {number} rotation - Rotation of the transform point, in radians. + * @param {number} scaleX - Horizontal scale of the transform point. + * @param {number} scaleY - Vertical scale of the transform point. + * @param {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} [output] - The output vector, point or object for the translated coordinates. + * + * @return {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} The translated point. + */ +var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) +{ + if (output === undefined) { output = new Vector2(); } + + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); + + // Rotate and Scale + var a = radianCos * scaleX; + var b = radianSin * scaleX; + var c = -radianSin * scaleY; + var d = radianCos * scaleY; + + // Invert + var id = 1 / ((a * d) + (c * -b)); + + output.x = (d * id * x) + (-c * id * y) + (((positionY * c) - (positionX * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-positionY * a) + (positionX * b)) * id); + + return output; +}; + +module.exports = TransformXY; + + +/***/ }), +/* 333 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -44954,6 +79253,7 @@ module.exports = PluginManager; */ var Class = __webpack_require__(0); +var NOOP = __webpack_require__(1); // https://developer.mozilla.org/en-US/docs/Web/API/Touch_events // https://patrickhlauke.github.io/touch/tests/results/ @@ -44968,7 +79268,7 @@ var Class = __webpack_require__(0); * You do not need to create this class directly, the Input Manager will create an instance of it automatically. * * @class TouchManager - * @memberOf Phaser.Input.Touch + * @memberof Phaser.Input.Touch * @constructor * @since 3.0.0 * @@ -45020,6 +79320,46 @@ var TouchManager = new Class({ */ this.target; + /** + * The Touch Start event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchStart + * @type {function} + * @since 3.0.0 + */ + this.onTouchStart = NOOP; + + /** + * The Touch Move event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchMove + * @type {function} + * @since 3.0.0 + */ + this.onTouchMove = NOOP; + + /** + * The Touch End event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchEnd + * @type {function} + * @since 3.0.0 + */ + this.onTouchEnd = NOOP; + + /** + * The Touch Cancel event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchCancel + * @type {function} + * @since 3.15.0 + */ + this.onTouchCancel = NOOP; + inputManager.events.once('boot', this.boot, this); }, @@ -45043,110 +79383,115 @@ var TouchManager = new Class({ this.target = this.manager.game.canvas; } - if (this.enabled) + if (this.enabled && this.target) { this.startListeners(); } }, /** - * The Touch Start Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchStart - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch Start Event. - */ - onTouchStart: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchStart(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Touch Move Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchMove - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch Move Event. - */ - onTouchMove: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchMove(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Touch End Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchEnd - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch End Event. - */ - onTouchEnd: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchEnd(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * Starts the Touch Event listeners running. - * This is called automatically and does not need to be manually invoked. + * Starts the Touch Event listeners running as long as an input target is set. + * + * This method is called automatically if Touch Input is enabled in the game config, + * which it is by default. However, you can call it manually should you need to + * delay input capturing until later in the game. * * @method Phaser.Input.Touch.TouchManager#startListeners * @since 3.0.0 */ startListeners: function () { + var _this = this; + + this.onTouchStart = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchStart(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchMove = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchMove(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchEnd = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchEnd(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchCancel = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchCancel(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + var target = this.target; + if (!target) + { + return; + } + var passive = { passive: true }; var nonPassive = { passive: false }; if (this.capture) { - target.addEventListener('touchstart', this.onTouchStart.bind(this), nonPassive); - target.addEventListener('touchmove', this.onTouchMove.bind(this), nonPassive); - target.addEventListener('touchend', this.onTouchEnd.bind(this), nonPassive); + target.addEventListener('touchstart', this.onTouchStart, nonPassive); + target.addEventListener('touchmove', this.onTouchMove, nonPassive); + target.addEventListener('touchend', this.onTouchEnd, nonPassive); + target.addEventListener('touchcancel', this.onTouchCancel, nonPassive); } else { - target.addEventListener('touchstart', this.onTouchStart.bind(this), passive); - target.addEventListener('touchmove', this.onTouchMove.bind(this), passive); - target.addEventListener('touchend', this.onTouchEnd.bind(this), passive); + target.addEventListener('touchstart', this.onTouchStart, passive); + target.addEventListener('touchmove', this.onTouchMove, passive); + target.addEventListener('touchend', this.onTouchEnd, passive); } + + this.enabled = true; }, /** @@ -45163,6 +79508,7 @@ var TouchManager = new Class({ target.removeEventListener('touchstart', this.onTouchStart); target.removeEventListener('touchmove', this.onTouchMove); target.removeEventListener('touchend', this.onTouchEnd); + target.removeEventListener('touchcancel', this.onTouchCancel); }, /** @@ -45176,6 +79522,7 @@ var TouchManager = new Class({ this.stopListeners(); this.target = null; + this.enabled = false; this.manager = null; } @@ -45185,7 +79532,40 @@ module.exports = TouchManager; /***/ }), -/* 198 */ +/* 334 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SmoothStep = __webpack_require__(181); + +/** + * A Smooth Step interpolation method. + * + * @function Phaser.Math.Interpolation.SmoothStep + * @since 3.9.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep} + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The interpolated value. + */ +var SmoothStepInterpolation = function (t, min, max) +{ + return min + (max - min) * SmoothStep(t, 0, 1); +}; + +module.exports = SmoothStepInterpolation; + + +/***/ }), +/* 335 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -45195,7 +79575,9 @@ module.exports = TouchManager; */ var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); +var Distance = __webpack_require__(52); +var SmoothStepInterpolation = __webpack_require__(334); +var Vector2 = __webpack_require__(3); /** * @classdesc @@ -45213,7 +79595,7 @@ var Vector2 = __webpack_require__(6); * callbacks. * * @class Pointer - * @memberOf Phaser.Input + * @memberof Phaser.Input * @constructor * @since 3.0.0 * @@ -45240,7 +79622,7 @@ var Pointer = new Class({ * * @name Phaser.Input.Pointer#id * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.id = id; @@ -45294,6 +79676,20 @@ var Pointer = new Class({ */ this.position = new Vector2(); + /** + * The previous position of the Pointer in screen space. + * + * The old x and y values are stored in here during the InputManager.transformPointer call. + * + * You can use it to track how fast the pointer is moving, or to smoothly interpolate between the old and current position. + * See the `Pointer.getInterpolatedPosition` method to assist in this. + * + * @name Phaser.Input.Pointer#prevPosition + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.prevPosition = new Vector2(); + /** * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. * @@ -45458,6 +79854,18 @@ var Pointer = new Class({ */ this.wasTouch = false; + /** + * Did this Pointer get canceled by a touchcancel event? + * + * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! + * + * @name Phaser.Input.Pointer#wasCanceled + * @type {boolean} + * @default false + * @since 3.15.0 + */ + this.wasCanceled = false; + /** * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. * @@ -45698,6 +80106,7 @@ var Pointer = new Class({ this.dirty = true; this.wasTouch = true; + this.wasCanceled = false; }, /** @@ -45754,6 +80163,35 @@ var Pointer = new Class({ this.dirty = true; this.wasTouch = true; + this.wasCanceled = false; + + this.active = false; + }, + + /** + * Internal method to handle a Touch Cancel Event. + * + * @method Phaser.Input.Pointer#touchcancel + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The Touch Event to process. + */ + touchcancel: function (event) + { + this.buttons = 0; + + this.event = event; + + this.primaryDown = false; + + this.justUp = false; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = true; + this.wasCanceled = true; this.active = false; }, @@ -45836,6 +80274,71 @@ var Pointer = new Class({ return (this.buttons & 16); }, + /** + * Returns the distance between the Pointer's current position and where it was + * first pressed down (the `downX` and `downY` properties) + * + * @method Phaser.Input.Pointer#getDistance + * @since 3.13.0 + * + * @return {number} The distance the Pointer has moved since being pressed down. + */ + getDistance: function () + { + return Distance(this.downX, this.downY, this.x, this.y); + }, + + /** + * Takes the previous and current Pointer positions and then generates an array of interpolated values between + * the two. The array will be populated up to the size of the `steps` argument. + * + * ```javaScript + * var points = pointer.getInterpolatedPosition(4); + * + * // points[0] = { x: 0, y: 0 } + * // points[1] = { x: 2, y: 1 } + * // points[2] = { x: 3, y: 2 } + * // points[3] = { x: 6, y: 3 } + * ``` + * + * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer + * events can often fire faster than the main browser loop, and this will help you avoid janky movement + * especially if you have an object following a Pointer. + * + * Note that if you provide an output array it will only be populated up to the number of steps provided. + * It will not clear any previous data that may have existed beyond the range of the steps count. + * + * Internally it uses the Smooth Step interpolation calculation. + * + * @method Phaser.Input.Pointer#getInterpolatedPosition + * @since 3.11.0 + * + * @param {integer} [steps=10] - The number of interpolation steps to use. + * @param {array} [out] - An array to store the results in. If not provided a new one will be created. + * + * @return {array} An array of interpolated values. + */ + getInterpolatedPosition: function (steps, out) + { + if (steps === undefined) { steps = 10; } + if (out === undefined) { out = []; } + + var prevX = this.prevPosition.x; + var prevY = this.prevPosition.y; + + var curX = this.position.x; + var curY = this.position.y; + + for (var i = 0; i < steps; i++) + { + var t = (1 / steps) * i; + + out[i] = { x: SmoothStepInterpolation(t, prevX, curX), y: SmoothStepInterpolation(t, prevY, curY) }; + } + + return out; + }, + /** * Destroys this Pointer instance and resets its external references. * @@ -45901,7 +80404,7 @@ module.exports = Pointer; /***/ }), -/* 199 */ +/* 336 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -45911,7 +80414,7 @@ module.exports = Pointer; */ var Class = __webpack_require__(0); -var Features = __webpack_require__(120); +var Features = __webpack_require__(168); // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md @@ -45925,7 +80428,7 @@ var Features = __webpack_require__(120); * You do not need to create this class directly, the Input Manager will create an instance of it automatically. * * @class MouseManager - * @memberOf Phaser.Input.Mouse + * @memberof Phaser.Input.Mouse * @constructor * @since 3.0.0 * @@ -46078,6 +80581,8 @@ var MouseManager = new Class({ * * @param {MouseEvent} event - The native event from the browser. */ + + /* pointerLockChange: function (event) { var element = this.target; @@ -46086,6 +80591,7 @@ var MouseManager = new Class({ this.manager.queue.push(event); }, + */ /** * If the browser supports pointer lock, this will request that the pointer lock is released. If @@ -46112,9 +80618,11 @@ var MouseManager = new Class({ * * @param {MouseEvent} event - The native DOM Mouse Move Event. */ + + /* onMouseMove: function (event) { - if (event.defaultPrevented || !this.enabled) + if (event.defaultPrevented || !this.enabled || !this.manager) { // Do nothing if event already handled return; @@ -46127,6 +80635,7 @@ var MouseManager = new Class({ event.preventDefault(); } }, + */ /** * The Mouse Down Event Handler. @@ -46136,6 +80645,8 @@ var MouseManager = new Class({ * * @param {MouseEvent} event - The native DOM Mouse Down Event. */ + + /* onMouseDown: function (event) { if (event.defaultPrevented || !this.enabled) @@ -46151,6 +80662,7 @@ var MouseManager = new Class({ event.preventDefault(); } }, + */ /** * The Mouse Up Event Handler. @@ -46160,6 +80672,8 @@ var MouseManager = new Class({ * * @param {MouseEvent} event - The native DOM Mouse Up Event. */ + + /* onMouseUp: function (event) { if (event.defaultPrevented || !this.enabled) @@ -46175,6 +80689,7 @@ var MouseManager = new Class({ event.preventDefault(); } }, + */ /** * Starts the Mouse Event listeners running. @@ -46185,31 +80700,84 @@ var MouseManager = new Class({ */ startListeners: function () { - var target = this.target; + var _this = this; + var onMouseMove = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseMove(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + var onMouseDown = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseDown(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + var onMouseUp = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseUp(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onMouseMove = onMouseMove; + this.onMouseDown = onMouseDown; + this.onMouseUp = onMouseUp; + + var target = this.target; var passive = { passive: true }; var nonPassive = { passive: false }; - if (this.capture) - { - target.addEventListener('mousemove', this.onMouseMove.bind(this), nonPassive); - target.addEventListener('mousedown', this.onMouseDown.bind(this), nonPassive); - target.addEventListener('mouseup', this.onMouseUp.bind(this), nonPassive); - } - else - { - target.addEventListener('mousemove', this.onMouseMove.bind(this), passive); - target.addEventListener('mousedown', this.onMouseDown.bind(this), passive); - target.addEventListener('mouseup', this.onMouseUp.bind(this), passive); - } + target.addEventListener('mousemove', onMouseMove, (this.capture) ? nonPassive : passive); + target.addEventListener('mousedown', onMouseDown, (this.capture) ? nonPassive : passive); + target.addEventListener('mouseup', onMouseUp, (this.capture) ? nonPassive : passive); if (Features.pointerLock) { - this.pointerLockChange = this.pointerLockChange.bind(this); + var onPointerLockChange = function (event) + { + var element = _this.target; - document.addEventListener('pointerlockchange', this.pointerLockChange, true); - document.addEventListener('mozpointerlockchange', this.pointerLockChange, true); - document.addEventListener('webkitpointerlockchange', this.pointerLockChange, true); + _this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; + + _this.manager.queue.push(event); + }; + + this.pointerLockChange = onPointerLockChange; + + document.addEventListener('pointerlockchange', onPointerLockChange, true); + document.addEventListener('mozpointerlockchange', onPointerLockChange, true); + document.addEventListener('webkitpointerlockchange', onPointerLockChange, true); } }, @@ -46256,7 +80824,7 @@ module.exports = MouseManager; /***/ }), -/* 200 */ +/* 337 */ /***/ (function(module, exports) { /** @@ -46321,6 +80889,15 @@ var INPUT_CONST = { */ TOUCH_END: 5, + /** + * A touch pointer has been been cancelled by the browser. + * + * @name Phaser.Input.TOUCH_CANCEL + * @type {integer} + * @since 3.15.0 + */ + TOUCH_CANCEL: 7, + /** * The pointer lock has changed. * @@ -46336,7 +80913,7 @@ module.exports = INPUT_CONST; /***/ }), -/* 201 */ +/* 338 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -46346,14 +80923,14 @@ module.exports = INPUT_CONST; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(200); -var EventEmitter = __webpack_require__(9); -var Mouse = __webpack_require__(199); -var Pointer = __webpack_require__(198); -var Rectangle = __webpack_require__(14); -var Touch = __webpack_require__(197); -var TransformMatrix = __webpack_require__(64); -var TransformXY = __webpack_require__(257); +var CONST = __webpack_require__(337); +var EventEmitter = __webpack_require__(11); +var Mouse = __webpack_require__(336); +var Pointer = __webpack_require__(335); +var Rectangle = __webpack_require__(9); +var Touch = __webpack_require__(333); +var TransformMatrix = __webpack_require__(38); +var TransformXY = __webpack_require__(332); /** * @classdesc @@ -46370,7 +80947,7 @@ var TransformXY = __webpack_require__(257); * for dealing with all input events for a Scene. * * @class InputManager - * @memberOf Phaser.Input + * @memberof Phaser.Input * @constructor * @since 3.0.0 * @@ -46389,7 +80966,7 @@ var InputManager = new Class({ * * @name Phaser.Input.InputManager#game * @type {Phaser.Game} - * @readOnly + * @readonly * @since 3.0.0 */ this.game = game; @@ -46555,7 +81132,7 @@ var InputManager = new Class({ * * @name Phaser.Input.InputManager#pointersTotal * @type {integer} - * @readOnly + * @readonly * @since 3.10.0 */ this.pointersTotal = config.inputActivePointers; @@ -46677,6 +81254,16 @@ var InputManager = new Class({ */ this._tempMatrix = new TransformMatrix(); + /** + * A re-cycled matrix used in hit test calculations. + * + * @name Phaser.Input.InputManager#_tempMatrix2 + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + game.events.once('boot', this.boot, this); }, @@ -46822,6 +81409,10 @@ var InputManager = new Class({ this.stopPointer(event, time); break; + case CONST.TOUCH_CANCEL: + this.cancelPointer(event, time); + break; + case CONST.POINTER_LOCK_CHANGE: this.events.emit('pointerlockchange', event, this.mouse.locked); break; @@ -47027,6 +81618,37 @@ var InputManager = new Class({ } }, + /** + * Called by the main update loop when a Touch Cancel Event is received. + * + * @method Phaser.Input.InputManager#cancelPointer + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The native DOM event to be processed. + * @param {number} time - The time stamp value of this game step. + */ + cancelPointer: function (event, time) + { + var pointers = this.pointers; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < this.pointersTotal; i++) + { + var pointer = pointers[i]; + + if (pointer.active && pointer.identifier === changedTouch.identifier) + { + pointer.touchend(changedTouch, time); + break; + } + } + } + }, + /** * Adds new Pointer objects to the Input Manager. * @@ -47170,6 +81792,21 @@ var InputManager = new Class({ } }, + /** + * Queues a touch cancel event, as passed in by the TouchManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueTouchCancel + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + queueTouchCancel: function (event) + { + this.queue.push(CONST.TOUCH_CANCEL, event); + }, + /** * Queues a mouse down event, as passed in by the MouseManager. * Also dispatches any DOM callbacks for this event. @@ -47391,14 +82028,15 @@ var InputManager = new Class({ * @since 3.10.0 * * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to test. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against. * * @return {boolean} `true` if the Game Object should be considered for input, otherwise `false`. */ - inputCandidate: function (gameObject) + inputCandidate: function (gameObject, camera) { var input = gameObject.input; - if (!input || !input.enabled || !gameObject.willRender()) + if (!input || !input.enabled || !gameObject.willRender(camera)) { return false; } @@ -47410,7 +82048,7 @@ var InputManager = new Class({ { do { - if (!parent.visible) + if (!parent.willRender(camera)) { visible = false; break; @@ -47449,17 +82087,19 @@ var InputManager = new Class({ if (output === undefined) { output = this._tempHitTest; } var tempPoint = this._tempPoint; - var cameraW = camera.width; - var cameraH = camera.height; + + var csx = camera.scrollX; + var csy = camera.scrollY; output.length = 0; var x = pointer.x; var y = pointer.y; - if (!(x >= camera.x && y >= camera.y && x <= camera.x + cameraW && y <= camera.y + cameraH)) + if (camera.resolution !== 1) { - return output; + x += camera._x; + y += camera._y; } // Stores the world point inside of tempPoint @@ -47468,38 +82108,36 @@ var InputManager = new Class({ pointer.worldX = tempPoint.x; pointer.worldY = tempPoint.y; - // Disable until fixed. - // var culledGameObjects = camera.cull(gameObjects); - var point = { x: 0, y: 0 }; - var res = this.game.config.resolution; - var matrix = this._tempMatrix; + var parentMatrix = this._tempMatrix2; for (var i = 0; i < gameObjects.length; i++) { var gameObject = gameObjects[i]; - if (!this.inputCandidate(gameObject)) + // Checks if the Game Object can receive input (isn't being ignored by the camera, invisible, etc) + // and also checks all of its parents, if any + if (!this.inputCandidate(gameObject, camera)) { continue; } - var px = tempPoint.x * res + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX; - var py = tempPoint.y * res + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY; + var px = tempPoint.x + (csx * gameObject.scrollFactorX) - csx; + var py = tempPoint.y + (csy * gameObject.scrollFactorY) - csy; if (gameObject.parentContainer) { - gameObject.getWorldTransformMatrix(matrix); + gameObject.getWorldTransformMatrix(matrix, parentMatrix); - TransformXY(px, py, matrix.tx, matrix.ty, matrix.rotation, matrix.scaleX, matrix.scaleY, point); + matrix.applyInverse(px, py, point); } else { TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); } - + if (this.pointWithinHitArea(gameObject, point.x, point.y)) { output.push(gameObject); @@ -47586,11 +82224,15 @@ var InputManager = new Class({ * @since 3.10.0 * * @param {Phaser.Input.Pointer} pointer - The Pointer to transform the values for. - * - * @return {number} The translated value. + * @param {number} pageX - The Page X value. + * @param {number} pageY - The Page Y value. */ transformPointer: function (pointer, pageX, pageY) { + // Store the previous position + pointer.prevPosition.x = pointer.x; + pointer.prevPosition.y = pointer.y; + pointer.x = (pageX - this.bounds.left) * this.scale.x; pointer.y = (pageY - this.bounds.top) * this.scale.y; }, @@ -47719,598 +82361,7 @@ module.exports = InputManager; /***/ }), -/* 202 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -/** - * Implements a model view projection matrices. - * Pipelines can implement this for doing 2D and 3D rendering. - */ - -var ModelViewProjection = { - - /** - * Dirty flag for checking if model matrix needs to be updated on GPU. - */ - modelMatrixDirty: false, - - /** - * Dirty flag for checking if view matrix needs to be updated on GPU. - */ - viewMatrixDirty: false, - - /** - * Dirty flag for checking if projection matrix needs to be updated on GPU. - */ - projectionMatrixDirty: false, - - /** - * Model matrix - */ - modelMatrix: null, - - /** - * View matrix - */ - viewMatrix: null, - - /** - * Projection matrix - */ - projectionMatrix: null, - - /** - * Initializes MVP matrices with an identity matrix - */ - mvpInit: function () - { - this.modelMatrixDirty = true; - this.viewMatrixDirty = true; - this.projectionMatrixDirty = true; - - this.modelMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.viewMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.projectionMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - return this; - }, - - /** - * If dirty flags are set then the matrices are uploaded to the GPU. - */ - mvpUpdate: function () - { - var program = this.program; - - if (this.modelMatrixDirty) - { - this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); - this.modelMatrixDirty = false; - } - - if (this.viewMatrixDirty) - { - this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); - this.viewMatrixDirty = false; - } - - if (this.projectionMatrixDirty) - { - this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); - this.projectionMatrixDirty = false; - } - - return this; - }, - - /** - * Loads an identity matrix to the model matrix - */ - modelIdentity: function () - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = 1; - modelMatrix[1] = 0; - modelMatrix[2] = 0; - modelMatrix[3] = 0; - modelMatrix[4] = 0; - modelMatrix[5] = 1; - modelMatrix[6] = 0; - modelMatrix[7] = 0; - modelMatrix[8] = 0; - modelMatrix[9] = 0; - modelMatrix[10] = 1; - modelMatrix[11] = 0; - modelMatrix[12] = 0; - modelMatrix[13] = 0; - modelMatrix[14] = 0; - modelMatrix[15] = 1; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Scale model matrix - */ - modelScale: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = modelMatrix[0] * x; - modelMatrix[1] = modelMatrix[1] * x; - modelMatrix[2] = modelMatrix[2] * x; - modelMatrix[3] = modelMatrix[3] * x; - modelMatrix[4] = modelMatrix[4] * y; - modelMatrix[5] = modelMatrix[5] * y; - modelMatrix[6] = modelMatrix[6] * y; - modelMatrix[7] = modelMatrix[7] * y; - modelMatrix[8] = modelMatrix[8] * z; - modelMatrix[9] = modelMatrix[9] * z; - modelMatrix[10] = modelMatrix[10] * z; - modelMatrix[11] = modelMatrix[11] * z; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Translate model matrix - */ - modelTranslate: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; - modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; - modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; - modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; - - this.modelMatrixDirty = true; - - return this; - }, - - - /** - * Rotates the model matrix in the X axis. - */ - modelRotateX: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[4] = a10 * c + a20 * s; - modelMatrix[5] = a11 * c + a21 * s; - modelMatrix[6] = a12 * c + a22 * s; - modelMatrix[7] = a13 * c + a23 * s; - modelMatrix[8] = a20 * c - a10 * s; - modelMatrix[9] = a21 * c - a11 * s; - modelMatrix[10] = a22 * c - a12 * s; - modelMatrix[11] = a23 * c - a13 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Rotates the model matrix in the Y axis. - */ - modelRotateY: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[0] = a00 * c - a20 * s; - modelMatrix[1] = a01 * c - a21 * s; - modelMatrix[2] = a02 * c - a22 * s; - modelMatrix[3] = a03 * c - a23 * s; - modelMatrix[8] = a00 * s + a20 * c; - modelMatrix[9] = a01 * s + a21 * c; - modelMatrix[10] = a02 * s + a22 * c; - modelMatrix[11] = a03 * s + a23 * c; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Rotates the model matrix in the Z axis. - */ - modelRotateZ: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - - modelMatrix[0] = a00 * c + a10 * s; - modelMatrix[1] = a01 * c + a11 * s; - modelMatrix[2] = a02 * c + a12 * s; - modelMatrix[3] = a03 * c + a13 * s; - modelMatrix[4] = a10 * c - a00 * s; - modelMatrix[5] = a11 * c - a01 * s; - modelMatrix[6] = a12 * c - a02 * s; - modelMatrix[7] = a13 * c - a03 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Loads identity matrix into the view matrix - */ - viewIdentity: function () - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = 1; - viewMatrix[1] = 0; - viewMatrix[2] = 0; - viewMatrix[3] = 0; - viewMatrix[4] = 0; - viewMatrix[5] = 1; - viewMatrix[6] = 0; - viewMatrix[7] = 0; - viewMatrix[8] = 0; - viewMatrix[9] = 0; - viewMatrix[10] = 1; - viewMatrix[11] = 0; - viewMatrix[12] = 0; - viewMatrix[13] = 0; - viewMatrix[14] = 0; - viewMatrix[15] = 1; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Scales view matrix - */ - viewScale: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = viewMatrix[0] * x; - viewMatrix[1] = viewMatrix[1] * x; - viewMatrix[2] = viewMatrix[2] * x; - viewMatrix[3] = viewMatrix[3] * x; - viewMatrix[4] = viewMatrix[4] * y; - viewMatrix[5] = viewMatrix[5] * y; - viewMatrix[6] = viewMatrix[6] * y; - viewMatrix[7] = viewMatrix[7] * y; - viewMatrix[8] = viewMatrix[8] * z; - viewMatrix[9] = viewMatrix[9] * z; - viewMatrix[10] = viewMatrix[10] * z; - viewMatrix[11] = viewMatrix[11] * z; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Translates view matrix - */ - viewTranslate: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; - viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; - viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; - viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Rotates view matrix in the X axis. - */ - viewRotateX: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[4] = a10 * c + a20 * s; - viewMatrix[5] = a11 * c + a21 * s; - viewMatrix[6] = a12 * c + a22 * s; - viewMatrix[7] = a13 * c + a23 * s; - viewMatrix[8] = a20 * c - a10 * s; - viewMatrix[9] = a21 * c - a11 * s; - viewMatrix[10] = a22 * c - a12 * s; - viewMatrix[11] = a23 * c - a13 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Rotates view matrix in the Y axis. - */ - viewRotateY: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[0] = a00 * c - a20 * s; - viewMatrix[1] = a01 * c - a21 * s; - viewMatrix[2] = a02 * c - a22 * s; - viewMatrix[3] = a03 * c - a23 * s; - viewMatrix[8] = a00 * s + a20 * c; - viewMatrix[9] = a01 * s + a21 * c; - viewMatrix[10] = a02 * s + a22 * c; - viewMatrix[11] = a03 * s + a23 * c; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Rotates view matrix in the Z axis. - */ - viewRotateZ: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - - viewMatrix[0] = a00 * c + a10 * s; - viewMatrix[1] = a01 * c + a11 * s; - viewMatrix[2] = a02 * c + a12 * s; - viewMatrix[3] = a03 * c + a13 * s; - viewMatrix[4] = a10 * c - a00 * s; - viewMatrix[5] = a11 * c - a01 * s; - viewMatrix[6] = a12 * c - a02 * s; - viewMatrix[7] = a13 * c - a03 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Loads a 2D view matrix (3x2 matrix) into a 4x4 view matrix - */ - viewLoad2D: function (matrix2D) - { - var vm = this.viewMatrix; - - vm[0] = matrix2D[0]; - vm[1] = matrix2D[1]; - vm[2] = 0.0; - vm[3] = 0.0; - vm[4] = matrix2D[2]; - vm[5] = matrix2D[3]; - vm[6] = 0.0; - vm[7] = 0.0; - vm[8] = matrix2D[4]; - vm[9] = matrix2D[5]; - vm[10] = 1.0; - vm[11] = 0.0; - vm[12] = 0.0; - vm[13] = 0.0; - vm[14] = 0.0; - vm[15] = 1.0; - - this.viewMatrixDirty = true; - - return this; - }, - - - /** - * Copies a 4x4 matrix into the view matrix - */ - viewLoad: function (matrix) - { - var vm = this.viewMatrix; - - vm[0] = matrix[0]; - vm[1] = matrix[1]; - vm[2] = matrix[2]; - vm[3] = matrix[3]; - vm[4] = matrix[4]; - vm[5] = matrix[5]; - vm[6] = matrix[6]; - vm[7] = matrix[7]; - vm[8] = matrix[8]; - vm[9] = matrix[9]; - vm[10] = matrix[10]; - vm[11] = matrix[11]; - vm[12] = matrix[12]; - vm[13] = matrix[13]; - vm[14] = matrix[14]; - vm[15] = matrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Loads identity matrix into the projection matrix. - */ - projIdentity: function () - { - var projectionMatrix = this.projectionMatrix; - - projectionMatrix[0] = 1; - projectionMatrix[1] = 0; - projectionMatrix[2] = 0; - projectionMatrix[3] = 0; - projectionMatrix[4] = 0; - projectionMatrix[5] = 1; - projectionMatrix[6] = 0; - projectionMatrix[7] = 0; - projectionMatrix[8] = 0; - projectionMatrix[9] = 0; - projectionMatrix[10] = 1; - projectionMatrix[11] = 0; - projectionMatrix[12] = 0; - projectionMatrix[13] = 0; - projectionMatrix[14] = 0; - projectionMatrix[15] = 1; - - this.projectionMatrixDirty = true; - - return this; - }, - - /** - * Sets up an orthographics projection matrix - */ - projOrtho: function (left, right, bottom, top, near, far) - { - var projectionMatrix = this.projectionMatrix; - var leftRight = 1.0 / (left - right); - var bottomTop = 1.0 / (bottom - top); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = -2.0 * leftRight; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = -2.0 * bottomTop; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = 2.0 * nearFar; - projectionMatrix[11] = 0.0; - projectionMatrix[12] = (left + right) * leftRight; - projectionMatrix[13] = (top + bottom) * bottomTop; - projectionMatrix[14] = (far + near) * nearFar; - projectionMatrix[15] = 1.0; - - this.projectionMatrixDirty = true; - return this; - }, - - /** - * Sets up a perspective projection matrix - */ - projPersp: function (fovy, aspectRatio, near, far) - { - var projectionMatrix = this.projectionMatrix; - var fov = 1.0 / Math.tan(fovy / 2.0); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = fov / aspectRatio; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = fov; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = (far + near) * nearFar; - projectionMatrix[11] = -1.0; - projectionMatrix[12] = 0.0; - projectionMatrix[13] = 0.0; - projectionMatrix[14] = (2.0 * far * near) * nearFar; - projectionMatrix[15] = 0.0; - - this.projectionMatrixDirty = true; - return this; - } -}; - -module.exports = ModelViewProjection; - - -/***/ }), -/* 203 */ +/* 339 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -48319,7 +82370,7 @@ module.exports = ModelViewProjection; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CanvasPool = __webpack_require__(22); +var CanvasPool = __webpack_require__(24); /** * Determines the canvas features of the browser running this Phaser Game instance. @@ -48424,7 +82475,2708 @@ module.exports = init(); /***/ }), -/* 204 */ +/* 340 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// This singleton is instantiated as soon as Phaser loads, +// before a Phaser.Game instance has even been created. +// Which means all instances of Phaser Games can share it, +// without having to re-poll the device all over again + +/** + * @namespace Phaser.Device + * @since 3.0.0 + */ + +/** + * @typedef {object} Phaser.DeviceConf + * + * @property {Phaser.Device.OS} os - The OS Device functions. + * @property {Phaser.Device.Browser} browser - The Browser Device functions. + * @property {Phaser.Device.Features} features - The Features Device functions. + * @property {Phaser.Device.Input} input - The Input Device functions. + * @property {Phaser.Device.Audio} audio - The Audio Device functions. + * @property {Phaser.Device.Video} video - The Video Device functions. + * @property {Phaser.Device.Fullscreen} fullscreen - The Fullscreen Device functions. + * @property {Phaser.Device.CanvasFeatures} canvasFeatures - The Canvas Device functions. + */ + +module.exports = { + + os: __webpack_require__(92), + browser: __webpack_require__(118), + features: __webpack_require__(168), + input: __webpack_require__(902), + audio: __webpack_require__(901), + video: __webpack_require__(900), + fullscreen: __webpack_require__(899), + canvasFeatures: __webpack_require__(339) + +}; + + +/***/ }), +/* 341 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var NOOP = __webpack_require__(1); + +/** + * @classdesc + * Abstracts away the use of RAF or setTimeOut for the core game update loop. + * This is invoked automatically by the Phaser.Game instance. + * + * @class RequestAnimationFrame + * @memberof Phaser.DOM + * @constructor + * @since 3.0.0 + */ +var RequestAnimationFrame = new Class({ + + initialize: + + function RequestAnimationFrame () + { + /** + * True if RequestAnimationFrame is running, otherwise false. + * + * @name Phaser.DOM.RequestAnimationFrame#isRunning + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * The callback to be invoked each step. + * + * @name Phaser.DOM.RequestAnimationFrame#callback + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#tick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.tick = 0; + + /** + * True if the step is using setTimeout instead of RAF. + * + * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isSetTimeOut = false; + + /** + * The setTimeout or RAF callback ID used when canceling them. + * + * @name Phaser.DOM.RequestAnimationFrame#timeOutID + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.timeOutID = null; + + /** + * The previous time the step was called. + * + * @name Phaser.DOM.RequestAnimationFrame#lastTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lastTime = 0; + + var _this = this; + + /** + * The RAF step function. + * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. + * + * @name Phaser.DOM.RequestAnimationFrame#step + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.step = function step (timestamp) + { + // DOMHighResTimeStamp + _this.lastTime = _this.tick; + + _this.tick = timestamp; + + _this.timeOutID = window.requestAnimationFrame(step); + + _this.callback(timestamp); + }; + + /** + * The SetTimeout step function. + * Updates the local tick value, invokes the callback and schedules another call to setTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#stepTimeout + * @type {function} + * @since 3.0.0 + */ + this.stepTimeout = function stepTimeout () + { + var d = Date.now(); + + var delay = Math.max(16 + _this.lastTime - d, 0); + + _this.lastTime = _this.tick; + + _this.tick = d; + + _this.timeOutID = window.setTimeout(stepTimeout, delay); + + _this.callback(d); + }; + }, + + /** + * Starts the requestAnimationFrame or setTimeout process running. + * + * @method Phaser.DOM.RequestAnimationFrame#start + * @since 3.0.0 + * + * @param {FrameRequestCallback} callback - The callback to invoke each step. + * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? + */ + start: function (callback, forceSetTimeOut) + { + if (this.isRunning) + { + return; + } + + this.callback = callback; + + this.isSetTimeOut = forceSetTimeOut; + + this.isRunning = true; + + this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); + }, + + /** + * Stops the requestAnimationFrame or setTimeout from running. + * + * @method Phaser.DOM.RequestAnimationFrame#stop + * @since 3.0.0 + */ + stop: function () + { + this.isRunning = false; + + if (this.isSetTimeOut) + { + clearTimeout(this.timeOutID); + } + else + { + window.cancelAnimationFrame(this.timeOutID); + } + }, + + /** + * Stops the step from running and clears the callback reference. + * + * @method Phaser.DOM.RequestAnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.callback = NOOP; + } + +}); + +module.exports = RequestAnimationFrame; + + +/***/ }), +/* 342 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Attempts to remove the element from its parentNode in the DOM. + * + * @function Phaser.DOM.RemoveFromDOM + * @since 3.0.0 + * + * @param {HTMLElement} element - The DOM element to remove from its parent node. + */ +var RemoveFromDOM = function (element) +{ + if (element.parentNode) + { + element.parentNode.removeChild(element); + } +}; + +module.exports = RemoveFromDOM; + + +/***/ }), +/* 343 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given data string and parses it as XML. + * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. + * The parsed XML object is returned, or `null` if there was an error while parsing the data. + * + * @function Phaser.DOM.ParseXML + * @since 3.0.0 + * + * @param {string} data - The XML source stored in a string. + * + * @return {?(DOMParser|ActiveXObject)} The parsed XML data, or `null` if the data could not be parsed. + */ +var ParseXML = function (data) +{ + var xml = ''; + + try + { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(data, 'text/xml'); + } + else + { + xml = new ActiveXObject('Microsoft.XMLDOM'); + xml.loadXML(data); + } + } + catch (e) + { + xml = null; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) + { + return null; + } + else + { + return xml; + } +}; + +module.exports = ParseXML; + + +/***/ }), +/* 344 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(92); + +/** + * @callback ContentLoadedCallback + */ + +/** + * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. + * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. + * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. + * + * @function Phaser.DOM.DOMContentLoaded + * @since 3.0.0 + * + * @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded. + */ +var DOMContentLoaded = function (callback) +{ + if (document.readyState === 'complete' || document.readyState === 'interactive') + { + callback(); + + return; + } + + var check = function () + { + document.removeEventListener('deviceready', check, true); + document.removeEventListener('DOMContentLoaded', check, true); + window.removeEventListener('load', check, true); + + callback(); + }; + + if (!document.body) + { + window.setTimeout(check, 20); + } + else if (OS.cordova && !OS.cocoonJS) + { + // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready + document.addEventListener('deviceready', check, false); + } + else + { + document.addEventListener('DOMContentLoaded', check, true); + window.addEventListener('load', check, true); + } +}; + +module.exports = DOMContentLoaded; + + +/***/ }), +/* 345 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts a hue to an RGB color. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HueToComponent + * @since 3.0.0 + * + * @param {number} p + * @param {number} q + * @param {number} t + * + * @return {number} The combined color value. + */ +var HueToComponent = function (p, q, t) +{ + if (t < 0) + { + t += 1; + } + + if (t > 1) + { + t -= 1; + } + + if (t < 1 / 6) + { + return p + (q - p) * 6 * t; + } + + if (t < 1 / 2) + { + return q; + } + + if (t < 2 / 3) + { + return p + (q - p) * (2 / 3 - t) * 6; + } + + return p; +}; + +module.exports = HueToComponent; + + +/***/ }), +/* 346 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns a string containing a hex representation of the given color component. + * + * @function Phaser.Display.Color.ComponentToHex + * @since 3.0.0 + * + * @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255. + * + * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. + */ +var ComponentToHex = function (color) +{ + var hex = color.toString(16); + + return (hex.length === 1) ? '0' + hex : hex; +}; + +module.exports = ComponentToHex; + + +/***/ }), +/* 347 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} InputColorObject + * + * @property {number} [r] - The red color value in the range 0 to 255. + * @property {number} [g] - The green color value in the range 0 to 255. + * @property {number} [b] - The blue color value in the range 0 to 255. + * @property {number} [a] - The alpha color value in the range 0 to 255. + */ + +/** + * @typedef {Object} ColorObject + * @property {number} r - The red color value in the range 0 to 255. + * @property {number} g - The green color value in the range 0 to 255. + * @property {number} b - The blue color value in the range 0 to 255. + * @property {number} a - The alpha color value in the range 0 to 255. + */ + +var Color = __webpack_require__(37); + +Color.ColorToRGBA = __webpack_require__(915); +Color.ComponentToHex = __webpack_require__(346); +Color.GetColor = __webpack_require__(177); +Color.GetColor32 = __webpack_require__(376); +Color.HexStringToColor = __webpack_require__(377); +Color.HSLToColor = __webpack_require__(914); +Color.HSVColorWheel = __webpack_require__(913); +Color.HSVToRGB = __webpack_require__(176); +Color.HueToComponent = __webpack_require__(345); +Color.IntegerToColor = __webpack_require__(374); +Color.IntegerToRGB = __webpack_require__(373); +Color.Interpolate = __webpack_require__(912); +Color.ObjectToColor = __webpack_require__(372); +Color.RandomRGB = __webpack_require__(911); +Color.RGBStringToColor = __webpack_require__(371); +Color.RGBToHSV = __webpack_require__(375); +Color.RGBToString = __webpack_require__(910); +Color.ValueToColor = __webpack_require__(178); + +module.exports = Color; + + +/***/ }), +/* 348 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Canvas.CanvasInterpolation + * @since 3.0.0 + */ +var CanvasInterpolation = { + + /** + * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setCrisp: function (canvas) + { + var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; + + types.forEach(function (type) + { + canvas.style['image-rendering'] = type; + }); + + canvas.style.msInterpolationMode = 'nearest-neighbor'; + + return canvas; + }, + + /** + * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setBicubic: function (canvas) + { + canvas.style['image-rendering'] = 'auto'; + canvas.style.msInterpolationMode = 'bicubic'; + + return canvas; + } + +}; + +module.exports = CanvasInterpolation; + + +/***/ }), +/* 349 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var CatmullRom = __webpack_require__(171); +var Class = __webpack_require__(0); +var Curve = __webpack_require__(70); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * [description] + * + * @class Spline + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} [points] - [description] + */ +var SplineCurve = new Class({ + + Extends: Curve, + + initialize: + + function SplineCurve (points) + { + if (points === undefined) { points = []; } + + Curve.call(this, 'SplineCurve'); + + /** + * [description] + * + * @name Phaser.Curves.Spline#points + * @type {Phaser.Math.Vector2[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + this.addPoints(points); + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#addPoints + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - [description] + * + * @return {Phaser.Curves.Spline} This curve object. + */ + addPoints: function (points) + { + for (var i = 0; i < points.length; i++) + { + var p = new Vector2(); + + if (typeof points[i] === 'number') + { + p.x = points[i]; + p.y = points[i + 1]; + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#addPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + addPoint: function (x, y) + { + var vec = new Vector2(x, y); + + this.points.push(vec); + + return vec; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Spline#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.points[0]); + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * this.points.length; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Spline#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var points = this.points; + + var point = (points.length - 1) * t; + + var intPoint = Math.floor(point); + + var weight = point - intPoint; + + var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; + var p1 = points[intPoint]; + var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; + var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; + + return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + var points = []; + + for (var i = 0; i < this.points.length; i++) + { + points.push(this.points[i].x); + points.push(this.points[i].y); + } + + return { + type: this.type, + points: points + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.Spline.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Spline} [description] + */ +SplineCurve.fromJSON = function (data) +{ + return new SplineCurve(data.points); +}; + +module.exports = SplineCurve; + + +/***/ }), +/* 350 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * p; +} + +function P1 (t, p) +{ + return 2 * (1 - t) * t * p; +} + +function P2 (t, p) +{ + return t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = end point + +// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js + +/** + * A quadratic bezier interpolation method. + * + * @function Phaser.Math.Interpolation.QuadraticBezier + * @since 3.2.0 + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} p0 - The start point. + * @param {number} p1 - The control point. + * @param {number} p2 - The end point. + * + * @return {number} The interpolated value. + */ +var QuadraticBezierInterpolation = function (t, p0, p1, p2) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2); +}; + +module.exports = QuadraticBezierInterpolation; + + +/***/ }), +/* 351 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(70); +var QuadraticBezierInterpolation = __webpack_require__(350); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * [description] + * + * @class QuadraticBezier + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.2.0 + * + * @param {(Phaser.Math.Vector2|number[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + */ +var QuadraticBezier = new Class({ + + Extends: Curve, + + initialize: + + function QuadraticBezier (p0, p1, p2) + { + Curve.call(this, 'QuadraticBezier'); + + if (Array.isArray(p0)) + { + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p1 = p1; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p2 = p2; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.QuadraticBezier#getStartPoint + * @since 3.2.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#getResolution + * @since 3.2.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.QuadraticBezier#getPoint + * @since 3.2.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + + return out.set( + QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), + QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) + ); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#draw + * @since 3.2.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - `Graphics` object to draw onto. + * @param {integer} [pointsTotal=32] - Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. + * + * @return {Phaser.GameObjects.Graphics} `Graphics` object that was drawn to. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * Converts the curve into a JSON compatible object. + * + * @method Phaser.Curves.QuadraticBezier#toJSON + * @since 3.2.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y + ] + }; + } + +}); + +/** + * Creates a curve from a JSON object, e. g. created by `toJSON`. + * + * @function Phaser.Curves.QuadraticBezier.fromJSON + * @since 3.2.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.QuadraticBezier} The created curve instance. + */ +QuadraticBezier.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + + return new QuadraticBezier(p0, p1, p2); +}; + +module.exports = QuadraticBezier; + + +/***/ }), +/* 352 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(70); +var FromPoints = __webpack_require__(173); +var Rectangle = __webpack_require__(9); +var Vector2 = __webpack_require__(3); + +var tmpVec2 = new Vector2(); + +/** + * @classdesc + * [description] + * + * @class Line + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|number[])} p0 - [description] + * @param {Phaser.Math.Vector2} [p1] - [description] + */ +var LineCurve = new Class({ + + Extends: Curve, + + initialize: + + // vec2s or array + function LineCurve (p0, p1) + { + Curve.call(this, 'LineCurve'); + + if (Array.isArray(p0)) + { + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.Line#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.Line#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + }, + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * @method Phaser.Curves.Line#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the bounds in. If not given a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. + */ + getBounds: function (out) + { + if (out === undefined) { out = new Rectangle(); } + + return FromPoints([ this.p0, this.p1 ], out); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Line#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.Line#getResolution + * @since 3.0.0 + * + * @param {number} [divisions=1] - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + if (divisions === undefined) { divisions = 1; } + + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Line#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + if (t === 1) + { + return out.copy(this.p1); + } + + out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); + + return out; + }, + + // Line curve is linear, so we can overwrite default getPointAt + + /** + * [description] + * + * @method Phaser.Curves.Line#getPointAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.Line#getTangent + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @return {Phaser.Math.Vector2} [description] + */ + getTangent: function () + { + var tangent = tmpVec2.copy(this.p1).subtract(this.p0); + + return tangent.normalize(); + }, + + // Override default Curve.draw because this is better than calling getPoints on a line! + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.Line#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. + */ + draw: function (graphics) + { + graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); + + // So you can chain graphics calls + return graphics; + }, + + /** + * [description] + * + * @method Phaser.Curves.Line#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y + ] + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.Line.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Line} [description] + */ +LineCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + + return new LineCurve(p0, p1); +}; + +module.exports = LineCurve; + + +/***/ }), +/* 353 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(70); +var DegToRad = __webpack_require__(31); +var GetValue = __webpack_require__(4); +var RadToDeg = __webpack_require__(172); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} JSONEllipseCurve + * + * @property {string} type - The of the curve. + * @property {number} x - The x coordinate of the ellipse. + * @property {number} y - The y coordinate of the ellipse. + * @property {number} xRadius - The horizontal radius of ellipse. + * @property {number} yRadius - The vertical radius of ellipse. + * @property {integer} startAngle - The start angle of the ellipse, in degrees. + * @property {integer} endAngle - The end angle of the ellipse, in degrees. + * @property {boolean} clockwise - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @property {integer} rotation - The rotation of ellipse, in degrees. + */ + +/** + * @typedef {object} EllipseCurveConfig + * + * @property {number} [x=0] - The x coordinate of the ellipse. + * @property {number} [y=0] - The y coordinate of the ellipse. + * @property {number} [xRadius=0] - The horizontal radius of the ellipse. + * @property {number} [yRadius=0] - The vertical radius of the ellipse. + * @property {integer} [startAngle=0] - The start angle of the ellipse, in degrees. + * @property {integer} [endAngle=360] - The end angle of the ellipse, in degrees. + * @property {boolean} [clockwise=false] - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @property {integer} [rotation=0] - The rotation of the ellipse, in degrees. + */ + +/** + * @classdesc + * An Elliptical Curve derived from the Base Curve class. + * + * See https://en.wikipedia.org/wiki/Elliptic_curve for more details. + * + * @class Ellipse + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(number|EllipseCurveConfig)} [x=0] - The x coordinate of the ellipse, or an Ellipse Curve configuration object. + * @param {number} [y=0] - The y coordinate of the ellipse. + * @param {number} [xRadius=0] - The horizontal radius of ellipse. + * @param {number} [yRadius=0] - The vertical radius of ellipse. + * @param {integer} [startAngle=0] - The start angle of the ellipse, in degrees. + * @param {integer} [endAngle=360] - The end angle of the ellipse, in degrees. + * @param {boolean} [clockwise=false] - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @param {integer} [rotation=0] - The rotation of the ellipse, in degrees. + */ +var EllipseCurve = new Class({ + + Extends: Curve, + + initialize: + + function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + if (typeof x === 'object') + { + var config = x; + + x = GetValue(config, 'x', 0); + y = GetValue(config, 'y', 0); + xRadius = GetValue(config, 'xRadius', 0); + yRadius = GetValue(config, 'yRadius', xRadius); + startAngle = GetValue(config, 'startAngle', 0); + endAngle = GetValue(config, 'endAngle', 360); + clockwise = GetValue(config, 'clockwise', false); + rotation = GetValue(config, 'rotation', 0); + } + else + { + if (yRadius === undefined) { yRadius = xRadius; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (clockwise === undefined) { clockwise = false; } + if (rotation === undefined) { rotation = 0; } + } + + Curve.call(this, 'EllipseCurve'); + + // Center point + + /** + * The center point of the ellipse. Used for calculating rotation. + * + * @name Phaser.Curves.Ellipse#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + + /** + * The horizontal radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#_xRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._xRadius = xRadius; + + /** + * The vertical radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#_yRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._yRadius = yRadius; + + // Radians + + /** + * The starting angle of the ellipse in radians. + * + * @name Phaser.Curves.Ellipse#_startAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._startAngle = DegToRad(startAngle); + + /** + * The end angle of the ellipse in radians. + * + * @name Phaser.Curves.Ellipse#_endAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._endAngle = DegToRad(endAngle); + + /** + * Anti-clockwise direction. + * + * @name Phaser.Curves.Ellipse#_clockwise + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._clockwise = clockwise; + + /** + * The rotation of the arc. + * + * @name Phaser.Curves.Ellipse#_rotation + * @type {number} + * @private + * @since 3.0.0 + */ + this._rotation = DegToRad(rotation); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Ellipse#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(0, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.Ellipse#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * 2; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Ellipse#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var twoPi = Math.PI * 2; + var deltaAngle = this._endAngle - this._startAngle; + var samePoints = Math.abs(deltaAngle) < Number.EPSILON; + + // ensures that deltaAngle is 0 .. 2 PI + while (deltaAngle < 0) + { + deltaAngle += twoPi; + } + + while (deltaAngle > twoPi) + { + deltaAngle -= twoPi; + } + + if (deltaAngle < Number.EPSILON) + { + if (samePoints) + { + deltaAngle = 0; + } + else + { + deltaAngle = twoPi; + } + } + + if (this._clockwise && !samePoints) + { + if (deltaAngle === twoPi) + { + deltaAngle = - twoPi; + } + else + { + deltaAngle = deltaAngle - twoPi; + } + } + + var angle = this._startAngle + t * deltaAngle; + var x = this.p0.x + this._xRadius * Math.cos(angle); + var y = this.p0.y + this._yRadius * Math.sin(angle); + + if (this._rotation !== 0) + { + var cos = Math.cos(this._rotation); + var sin = Math.sin(this._rotation); + + var tx = x - this.p0.x; + var ty = y - this.p0.y; + + // Rotate the point about the center of the ellipse. + x = tx * cos - ty * sin + this.p0.x; + y = tx * sin + ty * cos + this.p0.y; + } + + return out.set(x, y); + }, + + /** + * Sets the horizontal radius of this curve. + * + * @method Phaser.Curves.Ellipse#setXRadius + * @since 3.0.0 + * + * @param {number} value - The horizontal radius of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setXRadius: function (value) + { + this.xRadius = value; + + return this; + }, + + /** + * Sets the vertical radius of this curve. + * + * @method Phaser.Curves.Ellipse#setYRadius + * @since 3.0.0 + * + * @param {number} value - The vertical radius of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setYRadius: function (value) + { + this.yRadius = value; + + return this; + }, + + /** + * Sets the width of this curve. + * + * @method Phaser.Curves.Ellipse#setWidth + * @since 3.0.0 + * + * @param {number} value - The width of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setWidth: function (value) + { + this.xRadius = value * 2; + + return this; + }, + + /** + * Sets the height of this curve. + * + * @method Phaser.Curves.Ellipse#setHeight + * @since 3.0.0 + * + * @param {number} value - The height of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setHeight: function (value) + { + this.yRadius = value * 2; + + return this; + }, + + /** + * Sets the start angle of this curve. + * + * @method Phaser.Curves.Ellipse#setStartAngle + * @since 3.0.0 + * + * @param {number} value - The start angle of this curve, in radians. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setStartAngle: function (value) + { + this.startAngle = value; + + return this; + }, + + /** + * Sets the end angle of this curve. + * + * @method Phaser.Curves.Ellipse#setEndAngle + * @since 3.0.0 + * + * @param {number} value - The end angle of this curve, in radians. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setEndAngle: function (value) + { + this.endAngle = value; + + return this; + }, + + /** + * Sets if this curve extends clockwise or anti-clockwise. + * + * @method Phaser.Curves.Ellipse#setClockwise + * @since 3.0.0 + * + * @param {boolean} value - The clockwise state of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setClockwise: function (value) + { + this.clockwise = value; + + return this; + }, + + /** + * Sets the rotation of this curve. + * + * @method Phaser.Curves.Ellipse#setRotation + * @since 3.0.0 + * + * @param {number} value - The rotation of this curve, in radians. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setRotation: function (value) + { + this.rotation = value; + + return this; + }, + + /** + * The x coordinate of the center of the ellipse. + * + * @name Phaser.Curves.Ellipse#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.p0.x; + }, + + set: function (value) + { + this.p0.x = value; + } + + }, + + /** + * The y coordinate of the center of the ellipse. + * + * @name Phaser.Curves.Ellipse#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.p0.y; + }, + + set: function (value) + { + this.p0.y = value; + } + + }, + + /** + * The horizontal radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#xRadius + * @type {number} + * @since 3.0.0 + */ + xRadius: { + + get: function () + { + return this._xRadius; + }, + + set: function (value) + { + this._xRadius = value; + } + + }, + + /** + * The vertical radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#yRadius + * @type {number} + * @since 3.0.0 + */ + yRadius: { + + get: function () + { + return this._yRadius; + }, + + set: function (value) + { + this._yRadius = value; + } + + }, + + /** + * The start angle of the ellipse in degrees. + * + * @name Phaser.Curves.Ellipse#startAngle + * @type {number} + * @since 3.0.0 + */ + startAngle: { + + get: function () + { + return RadToDeg(this._startAngle); + }, + + set: function (value) + { + this._startAngle = DegToRad(value); + } + + }, + + /** + * The end angle of the ellipse in degrees. + * + * @name Phaser.Curves.Ellipse#endAngle + * @type {number} + * @since 3.0.0 + */ + endAngle: { + + get: function () + { + return RadToDeg(this._endAngle); + }, + + set: function (value) + { + this._endAngle = DegToRad(value); + } + + }, + + /** + * `true` if the ellipse rotation is clockwise or `false` if anti-clockwise. + * + * @name Phaser.Curves.Ellipse#clockwise + * @type {boolean} + * @since 3.0.0 + */ + clockwise: { + + get: function () + { + return this._clockwise; + }, + + set: function (value) + { + this._clockwise = value; + } + + }, + + /** + * The rotation of the ellipse, relative to the center, in degrees. + * + * @name Phaser.Curves.Ellipse#angle + * @type {number} + * @since 3.14.0 + */ + angle: { + + get: function () + { + return RadToDeg(this._rotation); + }, + + set: function (value) + { + this._rotation = DegToRad(value); + } + + }, + + /** + * The rotation of the ellipse, relative to the center, in radians. + * + * @name Phaser.Curves.Ellipse#rotation + * @type {number} + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = value; + } + + }, + + /** + * JSON serialization of the curve. + * + * @method Phaser.Curves.Ellipse#toJSON + * @since 3.0.0 + * + * @return {JSONEllipseCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + x: this.p0.x, + y: this.p0.y, + xRadius: this._xRadius, + yRadius: this._yRadius, + startAngle: RadToDeg(this._startAngle), + endAngle: RadToDeg(this._endAngle), + clockwise: this._clockwise, + rotation: RadToDeg(this._rotation) + }; + } + +}); + +/** + * Creates a curve from the provided Ellipse Curve Configuration object. + * + * @function Phaser.Curves.Ellipse.fromJSON + * @since 3.0.0 + * + * @param {JSONEllipseCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Ellipse} The ellipse curve constructed from the configuration object. + */ +EllipseCurve.fromJSON = function (data) +{ + return new EllipseCurve(data); +}; + +module.exports = EllipseCurve; + + +/***/ }), +/* 354 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * k * p; +} + +function P1 (t, p) +{ + var k = 1 - t; + + return 3 * k * k * t * p; +} + +function P2 (t, p) +{ + return 3 * (1 - t) * t * t * p; +} + +function P3 (t, p) +{ + return t * t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = control point 2 +// p3 = end point + +// https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a + +/** + * A cubic bezier interpolation method. + * + * @function Phaser.Math.Interpolation.CubicBezier + * @since 3.0.0 + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} p0 - The start point. + * @param {number} p1 - The first control point. + * @param {number} p2 - The second control point. + * @param {number} p3 - The end point. + * + * @return {number} The interpolated value. + */ +var CubicBezierInterpolation = function (t, p0, p1, p2, p3) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2) + P3(t, p3); +}; + +module.exports = CubicBezierInterpolation; + + +/***/ }), +/* 355 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var CubicBezier = __webpack_require__(354); +var Curve = __webpack_require__(70); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A higher-order Bézier curve constructed of four points. + * + * @class CubicBezier + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + * @param {Phaser.Math.Vector2} p3 - End Point. + */ +var CubicBezierCurve = new Class({ + + Extends: Curve, + + initialize: + + function CubicBezierCurve (p0, p1, p2, p3) + { + Curve.call(this, 'CubicBezierCurve'); + + if (Array.isArray(p0)) + { + p3 = new Vector2(p0[6], p0[7]); + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * The start point of this curve. + * + * @name Phaser.Curves.CubicBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * The first control point of this curve. + * + * @name Phaser.Curves.CubicBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + + /** + * The second control point of this curve. + * + * @name Phaser.Curves.CubicBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p2 = p2; + + /** + * The end point of this curve. + * + * @name Phaser.Curves.CubicBezier#p3 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p3 = p3; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.CubicBezier#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * Returns the resolution of this curve. + * + * @method Phaser.Curves.CubicBezier#getResolution + * @since 3.0.0 + * + * @param {number} divisions - The amount of divisions used by this curve. + * + * @return {number} The resolution of the curve. + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.CubicBezier#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + var p3 = this.p3; + + return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * Draws this curve to the specified graphics object. + * + * @method Phaser.Curves.CubicBezier#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The graphics object this curve should be drawn to. + * @param {integer} [pointsTotal=32] - The number of intermediary points that make up this curve. A higher number of points will result in a smoother curve. + * + * @return {Phaser.GameObjects.Graphics} The graphics object this curve was drawn to. Useful for method chaining. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * Returns a JSON object that describes this curve. + * + * @method Phaser.Curves.CubicBezier#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y, + this.p3.x, this.p3.y + ] + }; + } + +}); + +/** + * Generates a curve from a JSON object. + * + * @function Phaser.Curves.CubicBezier.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.CubicBezier} The curve generated from the JSON object. + */ +CubicBezierCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + var p3 = new Vector2(points[6], points[7]); + + return new CubicBezierCurve(p0, p1, p2, p3); +}; + +module.exports = CubicBezierCurve; + + +/***/ }), +/* 356 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.ARNE16 + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#9D9D9D', + 2: '#FFF', + 3: '#BE2633', + 4: '#E06F8B', + 5: '#493C2B', + 6: '#A46422', + 7: '#EB8931', + 8: '#F7E26B', + 9: '#2F484E', + A: '#44891A', + B: '#A3CE27', + C: '#1B2632', + D: '#005784', + E: '#31A2F2', + F: '#B2DCEF' +}; + + +/***/ }), +/* 357 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Arne16 = __webpack_require__(356); +var CanvasPool = __webpack_require__(24); +var GetValue = __webpack_require__(4); + +/** + * @callback GenerateTextureRendererCallback + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {CanvasRenderingContext2D} context - [description] + */ + +/** + * @typedef {object} GenerateTextureConfig + * + * @property {array} [data=[]] - [description] + * @property {HTMLCanvasElement} [canvas=null] - [description] + * @property {Palette} [palette=Arne16] - [description] + * @property {number} [pixelWidth=1] - The width of each 'pixel' in the generated texture. + * @property {number} [pixelHeight=1] - The height of each 'pixel' in the generated texture. + * @property {boolean} [resizeCanvas=true] - [description] + * @property {boolean} [clearCanvas=true] - [description] + * @property {GenerateTextureRendererCallback} [preRender] - [description] + * @property {GenerateTextureRendererCallback} [postRender] - [description] + */ + +/** + * [description] + * + * @function Phaser.Create.GenerateTexture + * @since 3.0.0 + * + * @param {GenerateTextureConfig} config - [description] + * + * @return {HTMLCanvasElement} [description] + */ +var GenerateTexture = function (config) +{ + var data = GetValue(config, 'data', []); + var canvas = GetValue(config, 'canvas', null); + var palette = GetValue(config, 'palette', Arne16); + var pixelWidth = GetValue(config, 'pixelWidth', 1); + var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); + var resizeCanvas = GetValue(config, 'resizeCanvas', true); + var clearCanvas = GetValue(config, 'clearCanvas', true); + var preRender = GetValue(config, 'preRender', null); + var postRender = GetValue(config, 'postRender', null); + + var width = Math.floor(Math.abs(data[0].length * pixelWidth)); + var height = Math.floor(Math.abs(data.length * pixelHeight)); + + if (!canvas) + { + canvas = CanvasPool.create2D(this, width, height); + resizeCanvas = false; + clearCanvas = false; + } + + if (resizeCanvas) + { + canvas.width = width; + canvas.height = height; + } + + var ctx = canvas.getContext('2d'); + + if (clearCanvas) + { + ctx.clearRect(0, 0, width, height); + } + + // preRender Callback? + if (preRender) + { + preRender(canvas, ctx); + } + + // Draw it + for (var y = 0; y < data.length; y++) + { + var row = data[y]; + + for (var x = 0; x < row.length; x++) + { + var d = row[x]; + + if (d !== '.' && d !== ' ') + { + ctx.fillStyle = palette[d]; + ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); + } + } + } + + // postRender Callback? + if (postRender) + { + postRender(canvas, ctx); + } + + return canvas; +}; + +module.exports = GenerateTexture; + + +/***/ }), +/* 358 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Stepped + */ + +module.exports = __webpack_require__(952); + + +/***/ }), +/* 359 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Sine + */ + +module.exports = { + + In: __webpack_require__(955), + Out: __webpack_require__(954), + InOut: __webpack_require__(953) + +}; + + +/***/ }), +/* 360 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Quintic + */ + +module.exports = { + + In: __webpack_require__(958), + Out: __webpack_require__(957), + InOut: __webpack_require__(956) + +}; + + +/***/ }), +/* 361 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Quartic + */ + +module.exports = { + + In: __webpack_require__(961), + Out: __webpack_require__(960), + InOut: __webpack_require__(959) + +}; + + +/***/ }), +/* 362 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Quadratic + */ + +module.exports = { + + In: __webpack_require__(964), + Out: __webpack_require__(963), + InOut: __webpack_require__(962) + +}; + + +/***/ }), +/* 363 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Linear + */ + +module.exports = __webpack_require__(965); + + +/***/ }), +/* 364 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Expo + */ + +module.exports = { + + In: __webpack_require__(968), + Out: __webpack_require__(967), + InOut: __webpack_require__(966) + +}; + + +/***/ }), +/* 365 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Elastic + */ + +module.exports = { + + In: __webpack_require__(971), + Out: __webpack_require__(970), + InOut: __webpack_require__(969) + +}; + + +/***/ }), +/* 366 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Cubic + */ + +module.exports = { + + In: __webpack_require__(974), + Out: __webpack_require__(973), + InOut: __webpack_require__(972) + +}; + + +/***/ }), +/* 367 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Circular + */ + +module.exports = { + + In: __webpack_require__(977), + Out: __webpack_require__(976), + InOut: __webpack_require__(975) + +}; + + +/***/ }), +/* 368 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Bounce + */ + +module.exports = { + + In: __webpack_require__(980), + Out: __webpack_require__(979), + InOut: __webpack_require__(978) + +}; + + +/***/ }), +/* 369 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Back + */ + +module.exports = { + + In: __webpack_require__(983), + Out: __webpack_require__(982), + InOut: __webpack_require__(981) + +}; + + +/***/ }), +/* 370 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -48439,15 +85191,17 @@ module.exports = init(); module.exports = { - Fade: __webpack_require__(565), - Flash: __webpack_require__(564), - Shake: __webpack_require__(563) + Fade: __webpack_require__(986), + Flash: __webpack_require__(985), + Pan: __webpack_require__(984), + Shake: __webpack_require__(951), + Zoom: __webpack_require__(950) }; /***/ }), -/* 205 */ +/* 371 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -48456,7 +85210,1302 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseCache = __webpack_require__(206); +var Color = __webpack_require__(37); + +/** + * Converts a CSS 'web' string into a Phaser Color object. + * + * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * + * @function Phaser.Display.Color.RGBStringToColor + * @since 3.0.0 + * + * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. + * + * @return {Phaser.Display.Color} A Color object. + */ +var RGBStringToColor = function (rgb) +{ + var color = new Color(); + + var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); + + if (result) + { + var r = parseInt(result[1], 10); + var g = parseInt(result[2], 10); + var b = parseInt(result[3], 10); + var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; + + color.setTo(r, g, b, a * 255); + } + + return color; +}; + +module.exports = RGBStringToColor; + + +/***/ }), +/* 372 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(37); + +/** + * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. + * + * @function Phaser.Display.Color.ObjectToColor + * @since 3.0.0 + * + * @param {InputColorObject} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. + * + * @return {Phaser.Display.Color} A Color object. + */ +var ObjectToColor = function (input) +{ + return new Color(input.r, input.g, input.b, input.a); +}; + +module.exports = ObjectToColor; + + +/***/ }), +/* 373 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * + * Alpha will only be set if it exists in the given color (0xAARRGGBB) + * + * @function Phaser.Display.Color.IntegerToRGB + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + */ +var IntegerToRGB = function (color) +{ + if (color > 16777215) + { + // The color value has an alpha component + return { + a: color >>> 24, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } + else + { + return { + a: 255, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } +}; + +module.exports = IntegerToRGB; + + +/***/ }), +/* 374 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(37); +var IntegerToRGB = __webpack_require__(373); + +/** + * Converts the given color value into an instance of a Color object. + * + * @function Phaser.Display.Color.IntegerToColor + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {Phaser.Display.Color} A Color object. + */ +var IntegerToColor = function (input) +{ + var rgb = IntegerToRGB(input); + + return new Color(rgb.r, rgb.g, rgb.b, rgb.a); +}; + +module.exports = IntegerToColor; + + +/***/ }), +/* 375 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} HSVColorObject + * + * @property {number} h - The hue color value. A number between 0 and 1 + * @property {number} s - The saturation color value. A number between 0 and 1 + * @property {number} v - The lightness color value. A number between 0 and 1 + */ + +/** + * Converts an RGB color value to HSV (hue, saturation and value). + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.RGBToHSV + * @since 3.0.0 + * + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * @param {(HSVColorObject|Phaser.Display.Color)} [out] - An object to store the color values in. If not given an HSV Color Object will be created. + * + * @return {(HSVColorObject|Phaser.Display.Color)} An object with the properties `h`, `s` and `v` set. + */ +var RGBToHSV = function (r, g, b, out) +{ + if (out === undefined) { out = { h: 0, s: 0, v: 0 }; } + + r /= 255; + g /= 255; + b /= 255; + + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var d = max - min; + + // achromatic by default + var h = 0; + var s = (max === 0) ? 0 : d / max; + var v = max; + + if (max !== min) + { + if (max === r) + { + h = (g - b) / d + ((g < b) ? 6 : 0); + } + else if (max === g) + { + h = (b - r) / d + 2; + } + else if (max === b) + { + h = (r - g) / d + 4; + } + + h /= 6; + } + + if (out.hasOwnProperty('_h')) + { + out._h = h; + out._s = s; + out._v = v; + } + else + { + out.h = h; + out.s = s; + out.v = v; + } + + return out; +}; + +module.exports = RGBToHSV; + + +/***/ }), +/* 376 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given an alpha and 3 color values this will return an integer representation of it. + * + * @function Phaser.Display.Color.GetColor32 + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} alpha - The alpha color value. A number between 0 and 255. + * + * @return {number} The combined color value. + */ +var GetColor32 = function (red, green, blue, alpha) +{ + return alpha << 24 | red << 16 | green << 8 | blue; +}; + +module.exports = GetColor32; + + +/***/ }), +/* 377 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(37); + +/** + * Converts a hex string into a Phaser Color object. + * + * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. + * + * An alpha channel is _not_ supported. + * + * @function Phaser.Display.Color.HexStringToColor + * @since 3.0.0 + * + * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. + * + * @return {Phaser.Display.Color} A Color object populated by the values of the given string. + */ +var HexStringToColor = function (hex) +{ + var color = new Color(); + + // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") + hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) + { + return r + r + g + g + b + b; + }); + + var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); + + if (result) + { + var r = parseInt(result[1], 16); + var g = parseInt(result[2], 16); + var b = parseInt(result[3], 16); + + color.setTo(r, g, b); + } + + return color; +}; + +module.exports = HexStringToColor; + + +/***/ }), +/* 378 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCamera = __webpack_require__(121); +var CanvasPool = __webpack_require__(24); +var CenterOn = __webpack_require__(175); +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var Effects = __webpack_require__(370); +var Linear = __webpack_require__(119); +var Rectangle = __webpack_require__(9); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Camera. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * A Camera also has built-in special effects including Fade, Flash and Camera Shake. + * + * @class Camera + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Cameras.Scene2D.BaseCamera + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.Tint + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var Camera = new Class({ + + Extends: BaseCamera, + + Mixins: [ + Components.Flip, + Components.Tint + ], + + initialize: + + function Camera (x, y, width, height) + { + BaseCamera.call(this, x, y, width, height); + + /** + * Does this Camera allow the Game Objects it renders to receive input events? + * + * @name Phaser.Cameras.Scene2D.Camera#inputEnabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.inputEnabled = true; + + /** + * The Camera Fade effect handler. + * To fade this camera see the `Camera.fade` methods. + * + * @name Phaser.Cameras.Scene2D.Camera#fadeEffect + * @type {Phaser.Cameras.Scene2D.Effects.Fade} + * @since 3.5.0 + */ + this.fadeEffect = new Effects.Fade(this); + + /** + * The Camera Flash effect handler. + * To flash this camera see the `Camera.flash` method. + * + * @name Phaser.Cameras.Scene2D.Camera#flashEffect + * @type {Phaser.Cameras.Scene2D.Effects.Flash} + * @since 3.5.0 + */ + this.flashEffect = new Effects.Flash(this); + + /** + * The Camera Shake effect handler. + * To shake this camera see the `Camera.shake` method. + * + * @name Phaser.Cameras.Scene2D.Camera#shakeEffect + * @type {Phaser.Cameras.Scene2D.Effects.Shake} + * @since 3.5.0 + */ + this.shakeEffect = new Effects.Shake(this); + + /** + * The Camera Pan effect handler. + * To pan this camera see the `Camera.pan` method. + * + * @name Phaser.Cameras.Scene2D.Camera#panEffect + * @type {Phaser.Cameras.Scene2D.Effects.Pan} + * @since 3.11.0 + */ + this.panEffect = new Effects.Pan(this); + + /** + * The Camera Zoom effect handler. + * To zoom this camera see the `Camera.zoom` method. + * + * @name Phaser.Cameras.Scene2D.Camera#zoomEffect + * @type {Phaser.Cameras.Scene2D.Effects.Zoom} + * @since 3.11.0 + */ + this.zoomEffect = new Effects.Zoom(this); + + /** + * The linear interpolation value to use when following a target. + * + * Can also be set via `setLerp` or as part of the `startFollow` call. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * + * @name Phaser.Cameras.Scene2D.Camera#lerp + * @type {Phaser.Math.Vector2} + * @since 3.9.0 + */ + this.lerp = new Vector2(1, 1); + + /** + * The values stored in this property are subtracted from the Camera targets position, allowing you to + * offset the camera from the actual target x/y coordinates by this amount. + * Can also be set via `setFollowOffset` or as part of the `startFollow` call. + * + * @name Phaser.Cameras.Scene2D.Camera#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.9.0 + */ + this.followOffset = new Vector2(); + + /** + * The Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * You can directly set this property to be an instance of a Rectangle. Or, you can use the + * `setDeadzone` method for a chainable approach. + * + * The rectangle you provide can have its dimensions adjusted dynamically, however, please + * note that its position is updated every frame, as it is constantly re-centered on the cameras mid point. + * + * Calling `setDeadzone` with no arguments will reset an active deadzone, as will setting this property + * to `null`. + * + * @name Phaser.Cameras.Scene2D.Camera#deadzone + * @type {?Phaser.Geom.Rectangle} + * @since 3.11.0 + */ + this.deadzone = null; + + /** + * Internal follow target reference. + * + * @name Phaser.Cameras.Scene2D.Camera#_follow + * @type {?any} + * @private + * @default null + * @since 3.0.0 + */ + this._follow = null; + + /** + * Is this Camera rendering directly to the canvas or to a texture? + * + * Enable rendering to texture with the method `setRenderToTexture` (just enabling this boolean won't be enough) + * + * Once enabled you can toggle it by switching this property. + * + * To properly remove a render texture you should call the `clearRenderToTexture()` method. + * + * @name Phaser.Cameras.Scene2D.Camera#renderToTexture + * @type {boolean} + * @default false + * @since 3.13.0 + */ + this.renderToTexture = false; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the HTML Canvas Element that the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#canvas + * @type {HTMLCanvasElement} + * @since 3.13.0 + */ + this.canvas = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the Rendering Context belonging to the Canvas element the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#context + * @type {CanvasRenderingContext2D} + * @since 3.13.0 + */ + this.context = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Texture belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#framebuffer + * @type {?WebGLTexture} + * @since 3.13.0 + */ + this.glTexture = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Frame Buffer belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#framebuffer + * @type {?WebGLFramebuffer} + * @since 3.13.0 + */ + this.framebuffer = null; + + /** + * If this Camera has been set to render to a texture and to use a custom pipeline, + * then this holds a reference to the pipeline the Camera is drawing with. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#pipeline + * @type {any} + * @since 3.13.0 + */ + this.pipeline = null; + }, + + /** + * Sets the Camera to render to a texture instead of to the main canvas. + * + * The Camera will redirect all Game Objects it's asked to render to this texture. + * + * During the render sequence, the texture itself will then be rendered to the main canvas. + * + * Doing this gives you the ability to modify the texture before this happens, + * allowing for special effects such as Camera specific shaders, or post-processing + * on the texture. + * + * If running under Canvas the Camera will render to its `canvas` property. + * + * If running under WebGL the Camera will create a frame buffer, which is stored in its `framebuffer` and `glTexture` properties. + * + * If you set a camera to render to a texture then it will emit 2 events during the render loop: + * + * First, it will emit the event `prerender`. This happens right before any Game Object's are drawn to the Camera texture. + * + * Then, it will emit the event `postrender`. This happens after all Game Object's have been drawn, but right before the + * Camera texture is rendered to the main game canvas. It's the final point at which you can manipulate the texture before + * it appears in-game. + * + * You should not enable this unless you plan on actually using the texture it creates + * somehow, otherwise you're just doubling the work required to render your game. + * + * To temporarily disable rendering to a texture, toggle the `renderToTexture` boolean. + * + * If you no longer require the Camera to render to a texture, call the `clearRenderToTexture` method, + * which will delete the respective textures and free-up resources. + * + * @method Phaser.Cameras.Scene2D.Camera#setRenderToTexture + * @since 3.13.0 + * + * @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} [pipeline] - An optional WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setRenderToTexture: function (pipeline) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl) + { + this.glTexture = renderer.createTextureFromSource(null, this.width, this.height, 0); + this.framebuffer = renderer.createFramebuffer(this.width, this.height, this.glTexture, false); + } + else + { + this.canvas = CanvasPool.create2D(this, this.width, this.height); + this.context = this.canvas.getContext('2d'); + } + + this.renderToTexture = true; + + if (pipeline) + { + this.setPipeline(pipeline); + } + + return this; + }, + + /** + * Sets the WebGL pipeline this Camera is using when rendering to a texture. + * + * You can pass either the string-based name of the pipeline, or a reference to the pipeline itself. + * + * Call this method with no arguments to clear any previously set pipeline. + * + * @method Phaser.Cameras.Scene2D.Camera#setPipeline + * @since 3.13.0 + * + * @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} [pipeline] - The WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. Or if left empty it will clear the pipeline. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setPipeline: function (pipeline) + { + if (typeof pipeline === 'string') + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl && renderer.hasPipeline(pipeline)) + { + this.pipeline = renderer.getPipeline(pipeline); + } + } + else + { + this.pipeline = pipeline; + } + + return this; + }, + + /** + * If this Camera was set to render to a texture, this will clear the resources it was using and + * redirect it to render back to the primary Canvas again. + * + * If you only wish to temporarily disable rendering to a texture then you can toggle the + * property `renderToTexture` instead. + * + * @method Phaser.Cameras.Scene2D.Camera#clearRenderToTexture + * @since 3.13.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + clearRenderToTexture: function () + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl) + { + if (this.framebuffer) + { + renderer.deleteFramebuffer(this.framebuffer); + } + + if (this.glTexture) + { + renderer.deleteTexture(this.glTexture); + } + + this.framebuffer = null; + this.glTexture = null; + this.pipeline = null; + } + else + { + CanvasPool.remove(this); + + this.canvas = null; + this.context = null; + } + + this.renderToTexture = false; + + return this; + }, + + /** + * Sets the Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point + * of the camera. This allows you to use the object for additional game related checks, such as + * testing if an object is within it or not via a Rectangle.contains call. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * Calling this method with no arguments will reset an active deadzone. + * + * @method Phaser.Cameras.Scene2D.Camera#setDeadzone + * @since 3.11.0 + * + * @param {number} [width] - The width of the deadzone rectangle in pixels. If not specified the deadzone is removed. + * @param {number} [height] - The height of the deadzone rectangle in pixels. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setDeadzone: function (width, height) + { + if (width === undefined) + { + this.deadzone = null; + } + else + { + if (this.deadzone) + { + this.deadzone.width = width; + this.deadzone.height = height; + } + else + { + this.deadzone = new Rectangle(0, 0, width, height); + } + + if (this._follow) + { + var originX = this.width / 2; + var originY = this.height / 2; + + var fx = this._follow.x - this.followOffset.x; + var fy = this._follow.y - this.followOffset.y; + + this.midPoint.set(fx, fy); + + this.scrollX = fx - originX; + this.scrollY = fy - originY; + } + + CenterOn(this.deadzone, this.midPoint.x, this.midPoint.y); + } + + return this; + }, + + /** + * Fades the Camera in from the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeIn + * @since 3.3.0 + * + * @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 {function} [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} This Camera instance. + */ + fadeIn: function (duration, red, green, blue, callback, context) + { + return this.fadeEffect.start(false, duration, red, green, blue, true, callback, context); + }, + + /** + * Fades the Camera out to the given color over the duration specified. + * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeOut + * @since 3.3.0 + * + * @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 {function} [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} This Camera instance. + */ + fadeOut: function (duration, red, green, blue, callback, context) + { + return this.fadeEffect.start(true, duration, red, green, blue, true, callback, context); + }, + + /** + * Fades the Camera from the given color to transparent over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeFrom + * @since 3.5.0 + * + * @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 {function} [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} This Camera instance. + */ + fadeFrom: function (duration, red, green, blue, force, callback, context) + { + return this.fadeEffect.start(false, duration, red, green, blue, force, callback, context); + }, + + /** + * Fades the Camera from transparent to the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fade + * @since 3.0.0 + * + * @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 {function} [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} This Camera instance. + */ + fade: function (duration, red, green, blue, force, callback, context) + { + return this.fadeEffect.start(true, duration, red, green, blue, force, callback, context); + }, + + /** + * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#flash + * @since 3.0.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 {function} [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} This Camera instance. + */ + flash: function (duration, red, green, blue, force, callback, context) + { + return this.flashEffect.start(duration, red, green, blue, force, callback, context); + }, + + /** + * Shakes the Camera by the given intensity over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#shake + * @since 3.0.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 {function} [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} This Camera instance. + */ + shake: function (duration, intensity, force, callback, context) + { + return this.shakeEffect.start(duration, intensity, force, callback, context); + }, + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Camera#pan + * @since 3.11.0 + * + * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. + * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @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} This Camera instance. + */ + pan: function (x, y, duration, ease, force, callback, context) + { + return this.panEffect.start(x, y, duration, ease, force, callback, context); + }, + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Camera#zoomTo + * @since 3.11.0 + * + * @param {number} zoom - The target Camera zoom value. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @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} This Camera instance. + */ + zoomTo: function (zoom, duration, ease, force, callback, context) + { + return this.zoomEffect.start(zoom, duration, ease, force, callback, context); + }, + + /** + * Internal preRender step. + * + * @method Phaser.Cameras.Scene2D.Camera#preRender + * @protected + * @since 3.0.0 + * + * @param {number} baseScale - The base scale, as set in the Camera Manager. + * @param {number} resolution - The game resolution. + */ + preRender: function (baseScale, resolution) + { + var width = this.width; + var height = this.height; + + var halfWidth = width * 0.5; + var halfHeight = height * 0.5; + + var zoom = this.zoom * baseScale; + var matrix = this.matrix; + + var originX = width * this.originX; + var originY = height * this.originY; + + var follow = this._follow; + var deadzone = this.deadzone; + + var sx = this.scrollX; + var sy = this.scrollY; + + if (deadzone) + { + CenterOn(deadzone, this.midPoint.x, this.midPoint.y); + } + + if (follow) + { + var fx = (follow.x - this.followOffset.x); + var fy = (follow.y - this.followOffset.y); + + if (deadzone) + { + if (fx < deadzone.x) + { + sx = Linear(sx, sx - (deadzone.x - fx), this.lerp.x); + } + else if (fx > deadzone.right) + { + sx = Linear(sx, sx + (fx - deadzone.right), this.lerp.x); + } + + if (fy < deadzone.y) + { + sy = Linear(sy, sy - (deadzone.y - fy), this.lerp.y); + } + else if (fy > deadzone.bottom) + { + sy = Linear(sy, sy + (fy - deadzone.bottom), this.lerp.y); + } + } + else + { + sx = Linear(sx, fx - originX, this.lerp.x); + sy = Linear(sy, fy - originY, this.lerp.y); + } + } + + if (this.useBounds) + { + sx = this.clampX(sx); + sy = this.clampY(sy); + } + + if (this.roundPixels) + { + originX = Math.round(originX); + originY = Math.round(originY); + } + + // Values are in pixels and not impacted by zooming the Camera + this.scrollX = sx; + this.scrollY = sy; + + var midX = sx + halfWidth; + var midY = sy + halfHeight; + + // The center of the camera, in world space, so taking zoom into account + // Basically the pixel value of what it's looking at in the middle of the cam + this.midPoint.set(midX, midY); + + var displayWidth = width / zoom; + var displayHeight = height / zoom; + + this.worldView.setTo( + midX - (displayWidth / 2), + midY - (displayHeight / 2), + displayWidth, + displayHeight + ); + + matrix.loadIdentity(); + matrix.scale(resolution, resolution); + matrix.translate(this.x + originX, this.y + originY); + matrix.rotate(this.rotation); + matrix.scale(zoom, zoom); + matrix.translate(-originX, -originY); + + this.shakeEffect.preRender(); + }, + + /** + * Sets the linear interpolation value to use when following a target. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * + * @method Phaser.Cameras.Scene2D.Camera#setLerp + * @since 3.9.0 + * + * @param {number} [x=1] - The amount added to the horizontal linear interpolation of the follow target. + * @param {number} [y=1] - The amount added to the vertical linear interpolation of the follow target. + * + * @return {this} This Camera instance. + */ + setLerp: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.lerp.set(x, y); + + return this; + }, + + /** + * Sets the horizontal and vertical offset of the camera from its follow target. + * The values are subtracted from the targets position during the Cameras update step. + * + * @method Phaser.Cameras.Scene2D.Camera#setFollowOffset + * @since 3.9.0 + * + * @param {number} [x=0] - The horizontal offset from the camera follow target.x position. + * @param {number} [y=0] - The vertical offset from the camera follow target.y position. + * + * @return {this} This Camera instance. + */ + setFollowOffset: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + this.followOffset.set(x, y); + + return this; + }, + + /** + * Sets the Camera to follow a Game Object. + * + * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object + * in its center. + * + * You can set the linear interpolation value used in the follow code. + * Use low lerp values (such as 0.1) to automatically smooth the camera motion. + * + * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel + * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to + * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom + * value on the camera. So be sure to keep the camera zoom to integers. + * + * @method Phaser.Cameras.Scene2D.Camera#startFollow + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. + * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? + * @param {number} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. + * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. + * + * @return {this} This Camera instance. + */ + startFollow: function (target, roundPixels, lerpX, lerpY, offsetX, offsetY) + { + if (roundPixels === undefined) { roundPixels = false; } + if (lerpX === undefined) { lerpX = 1; } + if (lerpY === undefined) { lerpY = lerpX; } + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = offsetX; } + + this._follow = target; + + this.roundPixels = roundPixels; + + lerpX = Clamp(lerpX, 0, 1); + lerpY = Clamp(lerpY, 0, 1); + + this.lerp.set(lerpX, lerpY); + + this.followOffset.set(offsetX, offsetY); + + var originX = this.width / 2; + var originY = this.height / 2; + + var fx = target.x - offsetX; + var fy = target.y - offsetY; + + this.midPoint.set(fx, fy); + + this.scrollX = fx - originX; + this.scrollY = fy - originY; + + return this; + }, + + /** + * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. + * + * @method Phaser.Cameras.Scene2D.Camera#stopFollow + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + stopFollow: function () + { + this._follow = null; + + return this; + }, + + /** + * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to + * remove the fade. + * + * @method Phaser.Cameras.Scene2D.Camera#resetFX + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + resetFX: function () + { + this.panEffect.reset(); + this.shakeEffect.reset(); + this.flashEffect.reset(); + this.fadeEffect.reset(); + + return this; + }, + + /** + * Internal method called automatically by the Camera Manager. + * + * @method Phaser.Cameras.Scene2D.Camera#update + * @protected + * @since 3.0.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.visible) + { + this.panEffect.update(time, delta); + this.zoomEffect.update(time, delta); + this.shakeEffect.update(time, delta); + this.flashEffect.update(time, delta); + this.fadeEffect.update(time, delta); + } + }, + + /** + * Destroys this Camera instance. You rarely need to call this directly. + * + * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as + * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. + * + * @method Phaser.Cameras.Scene2D.Camera#destroy + * @fires CameraDestroyEvent + * @since 3.0.0 + */ + destroy: function () + { + this.clearRenderToTexture(); + + this.resetFX(); + + BaseCamera.prototype.destroy.call(this); + + this._follow = null; + + this.deadzone = null; + } + +}); + +module.exports = Camera; + + +/***/ }), +/* 379 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCache = __webpack_require__(380); var Class = __webpack_require__(0); /** @@ -48468,7 +86517,7 @@ var Class = __webpack_require__(0); * instances, one per type of file. You can also add your own custom caches. * * @class CacheManager - * @memberOf Phaser.Cache + * @memberof Phaser.Cache * @constructor * @since 3.0.0 * @@ -48554,6 +86603,15 @@ var CacheManager = new Class({ */ this.text = new BaseCache(); + /** + * A Cache storing all html files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#html + * @type {Phaser.Cache.BaseCache} + * @since 3.12.0 + */ + this.html = new BaseCache(); + /** * A Cache storing all WaveFront OBJ files, typically added via the Loader. * @@ -48633,6 +86691,7 @@ var CacheManager = new Class({ 'shader', 'audio', 'text', + 'html', 'obj', 'tilemap', 'xml' @@ -48660,7 +86719,7 @@ module.exports = CacheManager; /***/ }), -/* 206 */ +/* 380 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -48670,8 +86729,8 @@ module.exports = CacheManager; */ var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(124); -var EventEmitter = __webpack_require__(9); +var CustomMap = __webpack_require__(180); +var EventEmitter = __webpack_require__(11); /** * @classdesc @@ -48682,7 +86741,7 @@ var EventEmitter = __webpack_require__(9); * Keys are string-based. * * @class BaseCache - * @memberOf Phaser.Cache + * @memberof Phaser.Cache * @constructor * @since 3.0.0 */ @@ -48854,7 +86913,7 @@ module.exports = BaseCache; /***/ }), -/* 207 */ +/* 381 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -48863,12 +86922,12 @@ module.exports = BaseCache; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Animation = __webpack_require__(210); +var Animation = __webpack_require__(384); var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(124); -var EventEmitter = __webpack_require__(9); +var CustomMap = __webpack_require__(180); +var EventEmitter = __webpack_require__(11); var GetValue = __webpack_require__(4); -var Pad = __webpack_require__(133); +var Pad = __webpack_require__(179); /** * @typedef {object} JSONAnimationManager @@ -48889,11 +86948,11 @@ var Pad = __webpack_require__(133); * * @class AnimationManager * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Animations + * @memberof Phaser.Animations * @constructor * @since 3.0.0 * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - A reference to the Phaser.Game instance. */ var AnimationManager = new Class({ @@ -48906,7 +86965,7 @@ var AnimationManager = new Class({ EventEmitter.call(this); /** - * [description] + * A reference to the Phaser.Game instance. * * @name Phaser.Animations.AnimationManager#game * @type {Phaser.Game} @@ -48916,7 +86975,7 @@ var AnimationManager = new Class({ this.game = game; /** - * [description] + * A reference to the Texture Manager. * * @name Phaser.Animations.AnimationManager#textureManager * @type {Phaser.Textures.TextureManager} @@ -49046,7 +87105,7 @@ var AnimationManager = new Class({ * @since 3.0.0 * * @param {(string|JSONAnimationManager|JSONAnimation)} data - [description] - * @param {boolean} [clearCurrentAnimations=false] - [description] + * @param {boolean} [clearCurrentAnimations=false] - If set to `true`, the current animations will be removed (`anims.clear()`). If set to `false` (default), the animations in `data` will be added. * * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. */ @@ -49101,15 +87160,17 @@ var AnimationManager = new Class({ */ /** - * [description] + * Generate an array of {@link AnimationFrameConfig} objects from a texture key and configuration object. + * + * Generates objects with string frame names, as configured by the given {@link AnimationFrameConfig}. * * @method Phaser.Animations.AnimationManager#generateFrameNames * @since 3.0.0 * - * @param {string} key - [description] - * @param {GenerateFrameNamesConfig} [config] - [description] + * @param {string} key - The key for the texture containing the animation frames. + * @param {GenerateFrameNamesConfig} [config] - The configuration object for the animation frame names. * - * @return {AnimationFrameConfig[]} [description] + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects. */ generateFrameNames: function (key, config) { @@ -49178,23 +87239,25 @@ var AnimationManager = new Class({ /** * @typedef {object} GenerateFrameNumbersConfig * - * @property {integer} [start=0] - [description] - * @property {integer} [end=-1] - [description] - * @property {boolean} [first=false] - [description] - * @property {AnimationFrameConfig[]} [outputArray=[]] - [description] - * @property {boolean} [frames=false] - [description] + * @property {integer} [start=0] - The starting frame of the animation. + * @property {integer} [end=-1] - The ending frame of the animation. + * @property {(boolean|integer)} [first=false] - A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. + * @property {AnimationFrameConfig[]} [outputArray=[]] - An array to concatenate the output onto. + * @property {(boolean|integer[])} [frames=false] - A custom sequence of frames. */ /** - * [description] + * Generate an array of {@link AnimationFrameConfig} objects from a texture key and configuration object. + * + * Generates objects with numbered frame names, as configured by the given {@link GenerateFrameNumbersConfig}. * * @method Phaser.Animations.AnimationManager#generateFrameNumbers * @since 3.0.0 * - * @param {string} key - [description] - * @param {GenerateFrameNumbersConfig} config - [description] + * @param {string} key - The key for the texture containing the animation frames. + * @param {GenerateFrameNumbersConfig} config - The configuration object for the animation frames. * - * @return {AnimationFrameConfig[]} [description] + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects. */ generateFrameNumbers: function (key, config) { @@ -49250,14 +87313,14 @@ var AnimationManager = new Class({ }, /** - * [description] + * Get an Animation. * * @method Phaser.Animations.AnimationManager#get * @since 3.0.0 * - * @param {string} key - [description] + * @param {string} key - The key of the Animation to retrieve. * - * @return {Phaser.Animations.Animation} [description] + * @return {Phaser.Animations.Animation} The Animation. */ get: function (key) { @@ -49265,14 +87328,14 @@ var AnimationManager = new Class({ }, /** - * Load an Animation into a Game Objects Animation Component. + * Load an Animation into a Game Object's Animation Component. * * @method Phaser.Animations.AnimationManager#load * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {string} key - [description] - * @param {(string|integer)} [startFrame] - [description] + * @param {Phaser.GameObjects.GameObject} child - The Game Object to load the animation into. + * @param {string} key - The key of the animation to load. + * @param {(string|integer)} [startFrame] - The name of a start frame to set on the loaded animation. * * @return {Phaser.GameObjects.GameObject} [description] */ @@ -49289,7 +87352,7 @@ var AnimationManager = new Class({ }, /** - * [description] + * Pause all animations. * * @method Phaser.Animations.AnimationManager#pauseAll * @fires PauseAllAnimationEvent @@ -49310,13 +87373,13 @@ var AnimationManager = new Class({ }, /** - * [description] + * Play an animation on the given Game Objects that have an Animation Component. * * @method Phaser.Animations.AnimationManager#play * @since 3.0.0 * - * @param {string} key - [description] - * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {string} key - The key of the animation to play on the Game Object. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Objects to play the animation on. * * @return {Phaser.Animations.AnimationManager} This Animation Manager. */ @@ -49343,13 +87406,13 @@ var AnimationManager = new Class({ }, /** - * [description] + * Remove an animation. * * @method Phaser.Animations.AnimationManager#remove * @fires RemoveAnimationEvent * @since 3.0.0 * - * @param {string} key - [description] + * @param {string} key - The key of the animation to remove. * * @return {Phaser.Animations.Animation} [description] */ @@ -49368,7 +87431,7 @@ var AnimationManager = new Class({ }, /** - * [description] + * Resume all paused animations. * * @method Phaser.Animations.AnimationManager#resumeAll * @fires ResumeAllAnimationEvent @@ -49389,17 +87452,17 @@ var AnimationManager = new Class({ }, /** - * Takes an array of Game Objects that have the Animation Component and then + * Takes an array of Game Objects that have an Animation Component and then * starts the given animation playing on them, each one offset by the * `stagger` amount given to this method. * * @method Phaser.Animations.AnimationManager#staggerPlay * @since 3.0.0 - * + * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {string} key - The key of the animation to play on the Game Objects. - * @param {Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have the Animation Component. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have an Animation Component. * @param {number} [stagger=0] - The amount of time, in milliseconds, to offset each play time by. * * @return {Phaser.Animations.AnimationManager} This Animation Manager. @@ -49481,7 +87544,7 @@ module.exports = AnimationManager; /***/ }), -/* 208 */ +/* 382 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -49511,7 +87574,7 @@ var Class = __webpack_require__(0); * AnimationFrames are generated automatically by the Animation class. * * @class AnimationFrame - * @memberOf Phaser.Animations + * @memberof Phaser.Animations * @constructor * @since 3.0.0 * @@ -49568,7 +87631,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#isFirst * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isFirst = false; @@ -49579,7 +87642,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#isLast * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isLast = false; @@ -49590,7 +87653,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#prevFrame * @type {?Phaser.Animations.AnimationFrame} * @default null - * @readOnly + * @readonly * @since 3.0.0 */ this.prevFrame = null; @@ -49601,7 +87664,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#nextFrame * @type {?Phaser.Animations.AnimationFrame} * @default null - * @readOnly + * @readonly * @since 3.0.0 */ this.nextFrame = null; @@ -49624,7 +87687,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#progress * @type {number} * @default 0 - * @readOnly + * @readonly * @since 3.0.0 */ this.progress = 0; @@ -49664,7 +87727,7 @@ module.exports = AnimationFrame; /***/ }), -/* 209 */ +/* 383 */ /***/ (function(module, exports) { /** @@ -49745,7 +87808,7 @@ module.exports = FindClosestInSorted; /***/ }), -/* 210 */ +/* 384 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -49756,8 +87819,8 @@ module.exports = FindClosestInSorted; var Clamp = __webpack_require__(23); var Class = __webpack_require__(0); -var FindClosestInSorted = __webpack_require__(209); -var Frame = __webpack_require__(208); +var FindClosestInSorted = __webpack_require__(383); +var Frame = __webpack_require__(382); var GetValue = __webpack_require__(4); /** @@ -49782,7 +87845,7 @@ var GetValue = __webpack_require__(4); * * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) * @property {(string|number)} frame - [description] - * @property {float} [duration=0] - [description] + * @property {number} [duration=0] - [description] * @property {boolean} [visible] - [description] */ @@ -49814,7 +87877,7 @@ var GetValue = __webpack_require__(4); * So multiple Game Objects can have playheads all pointing to this one Animation instance. * * @class Animation - * @memberOf Phaser.Animations + * @memberof Phaser.Animations * @constructor * @since 3.0.0 * @@ -50279,14 +88342,20 @@ var Animation = new Class({ component.msPerFrame = this.msPerFrame; component.skipMissedFrames = this.skipMissedFrames; - component._timeScale = 1; component._delay = this.delay; component._repeat = this.repeat; component._repeatDelay = this.repeatDelay; component._yoyo = this.yoyo; } - component.updateFrame(this.frames[startFrame]); + var frame = this.frames[startFrame]; + + if (startFrame === 0 && !component.forward) + { + frame = this.getLastFrame(); + } + + component.updateFrame(frame); }, /** @@ -50295,7 +88364,7 @@ var Animation = new Class({ * @method Phaser.Animations.Animation#getFrameByProgress * @since 3.4.0 * - * @param {float} value - A value between 0 and 1. + * @param {number} value - A value between 0 and 1. * * @return {Phaser.Animations.AnimationFrame} The frame closest to the given progress value. */ @@ -50327,17 +88396,20 @@ var Animation = new Class({ // Yoyo? (happens before repeat) if (component._yoyo) { - component.forward = false; - - component.updateFrame(frame.prevFrame); - - // Delay for the current frame - this.getNextTick(component); + this.handleYoyoFrame(component, false); } else if (component.repeatCounter > 0) { // Repeat (happens before complete) - this.repeatAnimation(component); + + if (component._reverse && component.forward) + { + component.forward = false; + } + else + { + this.repeatAnimation(component); + } } else { @@ -50346,12 +88418,60 @@ var Animation = new Class({ } else { - component.updateFrame(frame.nextFrame); - - this.getNextTick(component); + this.updateAndGetNextTick(component, frame.nextFrame); } }, + /** + * Handle the yoyo functionality in nextFrame and previousFrame methods. + * + * @method Phaser.Animations.Animation#handleYoyoFrame + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component to advance. + * @param {boolean} isReverse - Is animation in reverse mode? (Default: false) + */ + handleYoyoFrame: function (component, isReverse) + { + if (!isReverse) { isReverse = false; } + + if (component._reverse === !isReverse && component.repeatCounter > 0) + { + component.forward = isReverse; + + this.repeatAnimation(component); + + return; + } + + if (component._reverse !== isReverse && component.repeatCounter === 0) + { + this.completeAnimation(component); + + return; + } + + component.forward = isReverse; + + var frame = (isReverse) ? component.currentFrame.nextFrame : component.currentFrame.prevFrame; + + this.updateAndGetNextTick(component, frame); + }, + + /** + * Returns the animation last frame. + * + * @method Phaser.Animations.Animation#getLastFrame + * @since 3.12.0 + * + * @return {Phaser.Animations.AnimationFrame} component - The Animation Last Frame. + */ + getLastFrame: function () + { + return this.frames[this.frames.length - 1]; + }, + /** * [description] * @@ -50370,10 +88490,23 @@ var Animation = new Class({ { // We're at the start of the animation - if (component.repeatCounter > 0) + if (component._yoyo) { - // Repeat (happens before complete) - this.repeatAnimation(component); + this.handleYoyoFrame(component, true); + } + else if (component.repeatCounter > 0) + { + if (component._reverse && !component.forward) + { + component.currentFrame = this.getLastFrame(); + this.repeatAnimation(component); + } + else + { + // Repeat (happens before complete) + component.forward = true; + this.repeatAnimation(component); + } } else { @@ -50382,12 +88515,26 @@ var Animation = new Class({ } else { - component.updateFrame(frame.prevFrame); - - this.getNextTick(component); + this.updateAndGetNextTick(component, frame.prevFrame); } }, + /** + * Update Frame and Wait next tick. + * + * @method Phaser.Animations.Animation#updateAndGetNextTick + * @private + * @since 3.12.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - An Animation frame. + */ + updateAndGetNextTick: function (component, frame) + { + component.updateFrame(frame); + + this.getNextTick(component); + }, + /** * [description] * @@ -50455,9 +88602,7 @@ var Animation = new Class({ { component.repeatCounter--; - component.forward = true; - - component.updateFrame(component.currentFrame.nextFrame); + component.updateFrame(component.currentFrame[(component.forward) ? 'nextFrame' : 'prevFrame']); if (component.isPlaying) { @@ -50465,7 +88610,7 @@ var Animation = new Class({ component.pendingRepeat = false; - component.parent.emit('animationrepeat', this, component.currentFrame, component.repeatCounter); + component.parent.emit('animationrepeat', this, component.currentFrame, component.repeatCounter, component.parent); } } }, @@ -50628,7 +88773,161 @@ module.exports = Animation; /***/ }), -/* 211 */ +/* 385 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Using Bresenham's line algorithm this will return an array of all coordinates on this line. + * + * The `start` and `end` points are rounded before this runs as the algorithm works on integers. + * + * @function Phaser.Geom.Line.BresenhamPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line. + * @param {integer} [stepRate=1] - The optional step rate for the points on the line. + * @param {array} [results] - An optional array to push the resulting coordinates into. + * + * @return {object[]} The array of coordinates on the line. + */ +var BresenhamPoints = function (line, stepRate, results) +{ + if (stepRate === undefined) { stepRate = 1; } + if (results === undefined) { results = []; } + + var x1 = Math.round(line.x1); + var y1 = Math.round(line.y1); + var x2 = Math.round(line.x2); + var y2 = Math.round(line.y2); + + var dx = Math.abs(x2 - x1); + var dy = Math.abs(y2 - y1); + var sx = (x1 < x2) ? 1 : -1; + var sy = (y1 < y2) ? 1 : -1; + var err = dx - dy; + + results.push({ x: x1, y: y1 }); + + var i = 1; + + while (!((x1 === x2) && (y1 === y2))) + { + var e2 = err << 1; + + if (e2 > -dy) + { + err -= dy; + x1 += sx; + } + + if (e2 < dx) + { + err += dx; + y1 += sy; + } + + if (i % stepRate === 0) + { + results.push({ x: x1, y: y1 }); + } + + i++; + } + + return results; +}; + +module.exports = BresenhamPoints; + + +/***/ }), +/* 386 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the end of the array to the start, shifting all items in the process. + * The "rotation" happens to the right. + * + * @function Phaser.Utils.Array.RotateRight + * @since 3.0.0 + * + * @param {array} array - The array to shift to the right. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateRight = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.pop(); + array.unshift(element); + } + + return element; +}; + +module.exports = RotateRight; + + +/***/ }), +/* 387 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the start of the array to the end, shifting all items in the process. + * The "rotation" happens to the left. + * + * @function Phaser.Utils.Array.RotateLeft + * @since 3.0.0 + * + * @param {array} array - The array to shift to the left. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateLeft = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.shift(); + array.push(element); + } + + return element; +}; + +module.exports = RotateLeft; + + +/***/ }), +/* 388 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -50637,30 +88936,207 @@ module.exports = Animation; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Wrap = __webpack_require__(39); +var Perimeter = __webpack_require__(124); +var Point = __webpack_require__(6); + +// Return an array of points from the perimeter of the rectangle +// each spaced out based on the quantity or step required /** - * Wrap an angle in degrees. + * [description] * - * Wraps the angle to a value in the range of -180 to 180. - * - * @function Phaser.Math.Angle.WrapDegrees + * @function Phaser.Geom.Rectangle.MarchingAnts * @since 3.0.0 * - * @param {number} angle - The angle to wrap, in degrees. + * @generic {Phaser.Geom.Point[]} O - [out,$return] * - * @return {number} The wrapped angle, in degrees. + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} step - [description] + * @param {integer} quantity - [description] + * @param {(array|Phaser.Geom.Point[])} [out] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] */ -var WrapDegrees = function (angle) +var MarchingAnts = function (rect, step, quantity, out) { - return Wrap(angle, -180, 180); + if (out === undefined) { out = []; } + + if (!step && !quantity) + { + // Bail out + return out; + } + + // If step is a falsey value (false, null, 0, undefined, etc) then we calculate + // it based on the quantity instead, otherwise we always use the step value + if (!step) + { + step = Perimeter(rect) / quantity; + } + else + { + quantity = Math.round(Perimeter(rect) / step); + } + + var x = rect.x; + var y = rect.y; + var face = 0; + + // Loop across each face of the rectangle + + for (var i = 0; i < quantity; i++) + { + out.push(new Point(x, y)); + + switch (face) + { + + // Top face + case 0: + x += step; + + if (x >= rect.right) + { + face = 1; + y += (x - rect.right); + x = rect.right; + } + break; + + // Right face + case 1: + y += step; + + if (y >= rect.bottom) + { + face = 2; + x -= (y - rect.bottom); + y = rect.bottom; + } + break; + + // Bottom face + case 2: + x -= step; + + if (x <= rect.left) + { + face = 3; + y -= (rect.left - x); + x = rect.left; + } + break; + + // Left face + case 3: + y -= step; + + if (y <= rect.top) + { + face = 0; + y = rect.top; + } + break; + } + } + + return out; }; -module.exports = WrapDegrees; +module.exports = MarchingAnts; /***/ }), -/* 212 */ +/* 389 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 1; // 0001 + +/** + * Provides methods used for setting the visibility of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Visible + * @since 3.0.0 + */ + +var Visible = { + + /** + * Private internal value. Holds the visible value. + * + * @name Phaser.GameObjects.Components.Visible#_visible + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + _visible: true, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Components.Visible#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + if (value) + { + this._visible = true; + this.renderFlags |= _FLAG; + } + else + { + this._visible = false; + this.renderFlags &= ~_FLAG; + } + } + + }, + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @method Phaser.GameObjects.Components.Visible#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {this} This Game Object instance. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + } +}; + +module.exports = Visible; + + +/***/ }), +/* 390 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -50669,30 +89145,660 @@ module.exports = WrapDegrees; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathWrap = __webpack_require__(39); +var MATH_CONST = __webpack_require__(16); +var TransformMatrix = __webpack_require__(38); +var WrapAngle = __webpack_require__(199); +var WrapAngleDegrees = __webpack_require__(198); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 /** - * Wrap an angle. + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. * - * Wraps the angle to a value in the range of -PI to PI. - * - * @function Phaser.Math.Angle.Wrap + * @name Phaser.GameObjects.Components.Transform * @since 3.0.0 - * - * @param {number} angle - The angle to wrap, in radians. - * - * @return {number} The wrapped angle, in radians. */ -var Wrap = function (angle) -{ - return MathWrap(angle, -Math.PI, Math.PI); + +var Transform = { + + /** + * Private internal value. Holds the horizontal scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleX + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleX: 1, + + /** + * Private internal value. Holds the vertical scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleY + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleY: 1, + + /** + * Private internal value. Holds the rotation value in radians. + * + * @name Phaser.GameObjects.Components.Transform#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + _rotation: 0, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + x: 0, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + y: 0, + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + * + * @name Phaser.GameObjects.Components.Transform#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + z: 0, + + /** + * The w position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + w: 0, + + /** + * The horizontal scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + this._scaleX = value; + + if (this._scaleX === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The vertical scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + this._scaleY = value; + + if (this._scaleY === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + * + * @name Phaser.GameObjects.Components.Transform#angle + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + * + * @name Phaser.GameObjects.Components.Transform#rotation + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + } + }, + + /** + * Sets the position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of this Game Object. + * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value. + * @param {number} [z=0] - The z position of this Game Object. + * @param {number} [w=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setPosition: function (x, y, z, w) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + if (z === undefined) { z = 0; } + if (w === undefined) { w = 0; } + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + }, + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * + * @method Phaser.GameObjects.Components.Transform#setRandomPosition + * @since 3.8.0 + * + * @param {number} [x=0] - The x position of the top-left of the random area. + * @param {number} [y=0] - The y position of the top-left of the random area. + * @param {number} [width] - The width of the random area. + * @param {number} [height] - The height of the random area. + * + * @return {this} This Game Object instance. + */ + setRandomPosition: function (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + + this.x = x + (Math.random() * width); + this.y = y + (Math.random() * height); + + return this; + }, + + /** + * Sets the rotation of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - The rotation of this Game Object, in radians. + * + * @return {this} This Game Object instance. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this.rotation = radians; + + return this; + }, + + /** + * Sets the angle of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. + * + * @return {this} This Game Object instance. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + return this; + }, + + /** + * Sets the scale of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScale: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scaleX = x; + this.scaleY = y; + + return this; + }, + + /** + * Sets the x position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setX + * @since 3.0.0 + * + * @param {number} [value=0] - The x position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setX: function (value) + { + if (value === undefined) { value = 0; } + + this.x = value; + + return this; + }, + + /** + * Sets the y position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setY + * @since 3.0.0 + * + * @param {number} [value=0] - The y position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setY: function (value) + { + if (value === undefined) { value = 0; } + + this.y = value; + + return this; + }, + + /** + * Sets the z position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setZ + * @since 3.0.0 + * + * @param {number} [value=0] - The z position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setZ: function (value) + { + if (value === undefined) { value = 0; } + + this.z = value; + + return this; + }, + + /** + * Sets the w position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setW + * @since 3.0.0 + * + * @param {number} [value=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setW: function (value) + { + if (value === undefined) { value = 0; } + + this.w = value; + + return this; + }, + + /** + * Gets the local transform matrix for this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getLocalTransformMatrix: function (tempMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + + return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + }, + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * + * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A temporary matrix to hold parent values during the calculations. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getWorldTransformMatrix: function (tempMatrix, parentMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + if (parentMatrix === undefined) { parentMatrix = new TransformMatrix(); } + + var parent = this.parentContainer; + + if (!parent) + { + return this.getLocalTransformMatrix(tempMatrix); + } + + tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + + while (parent) + { + parentMatrix.applyITRS(parent.x, parent.y, parent._rotation, parent._scaleX, parent._scaleY); + + parentMatrix.multiply(tempMatrix, tempMatrix); + + parent = parent.parentContainer; + } + + return tempMatrix; + } + }; -module.exports = Wrap; +module.exports = Transform; /***/ }), -/* 213 */ +/* 391 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} JSONGameObject + * + * @property {string} name - The name of this Game Object. + * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. + * @property {number} x - The x position of this Game Object. + * @property {number} y - The y position of this Game Object. + * @property {object} scale - The scale of this Game Object + * @property {number} scale.x - The horizontal scale of this Game Object. + * @property {number} scale.y - The vertical scale of this Game Object. + * @property {object} origin - The origin of this Game Object. + * @property {number} origin.x - The horizontal origin of this Game Object. + * @property {number} origin.y - The vertical origin of this Game Object. + * @property {boolean} flipX - The horizontally flipped state of the Game Object. + * @property {boolean} flipY - The vertically flipped state of the Game Object. + * @property {number} rotation - The angle of this Game Object in radians. + * @property {number} alpha - The alpha value of the Game Object. + * @property {boolean} visible - The visible state of the Game Object. + * @property {integer} scaleMode - The Scale Mode being used by this Game Object. + * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. + * @property {string} textureKey - The texture key of this Game Object. + * @property {string} frameKey - The frame key of this Game Object. + * @property {object} data - The data of this Game Object. + */ + +/** + * Build a JSON representation of the given Game Object. + * + * This is typically extended further by Game Object specific implementations. + * + * @method Phaser.GameObjects.Components.ToJSON + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON. + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ +var ToJSON = function (gameObject) +{ + var out = { + name: gameObject.name, + type: gameObject.type, + x: gameObject.x, + y: gameObject.y, + depth: gameObject.depth, + scale: { + x: gameObject.scaleX, + y: gameObject.scaleY + }, + origin: { + x: gameObject.originX, + y: gameObject.originY + }, + flipX: gameObject.flipX, + flipY: gameObject.flipY, + rotation: gameObject.rotation, + alpha: gameObject.alpha, + visible: gameObject.visible, + scaleMode: gameObject.scaleMode, + blendMode: gameObject.blendMode, + textureKey: '', + frameKey: '', + data: {} + }; + + if (gameObject.texture) + { + out.textureKey = gameObject.texture.key; + out.frameKey = gameObject.frame.name; + } + + return out; +}; + +module.exports = ToJSON; + + +/***/ }), +/* 392 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the Scroll Factor of a Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor + * @since 3.0.0 + */ + +var ScrollFactor = { + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorX: 1, + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorY: 1, + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of this Game Object. + * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScrollFactor: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + } + +}; + +module.exports = ScrollFactor; + + +/***/ }), +/* 393 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -50705,15 +89811,19 @@ var Class = __webpack_require__(0); /** * @classdesc - * [description] + * A Geometry Mask can be applied to a Game Object to hide any pixels of it which don't intersect a visible pixel from the geometry mask. The mask is essentially a clipping path which can only make a masked pixel fully visible or fully invisible without changing its alpha (opacity). + * + * A Geometry Mask uses a Graphics Game Object to determine which pixels of the masked Game Object(s) should be clipped. For any given point of a masked Game Object's texture, the pixel will only be displayed if the Graphics Game Object of the Geometry Mask has a visible pixel at the same position. The color and alpha of the pixel from the Geometry Mask do not matter. + * + * The Geometry Mask's location matches the location of its Graphics object, not the location of the masked objects. Moving or transforming the underlying Graphics object will change the mask (and affect the visibility of any masked objects), whereas moving or transforming a masked object will not affect the mask. You can think of the Geometry Mask (or rather, of the its Graphics object) as an invisible curtain placed in front of all masked objects which has its own visual properties and, naturally, respects the camera's visual properties, but isn't affected by and doesn't follow the masked objects by itself. * * @class GeometryMask - * @memberOf Phaser.Display.Masks + * @memberof Phaser.Display.Masks * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + * @param {Phaser.Scene} scene - This parameter is not used. + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics Game Object to use for the Geometry Mask. Doesn't have to be in the Display List. */ var GeometryMask = new Class({ @@ -50722,7 +89832,7 @@ var GeometryMask = new Class({ function GeometryMask (scene, graphicsGeometry) { /** - * [description] + * The Graphics object which describes the Geometry Mask. * * @name Phaser.Display.Masks.GeometryMask#geometryMask * @type {Phaser.GameObjects.Graphics} @@ -50732,12 +89842,12 @@ var GeometryMask = new Class({ }, /** - * [description] + * Sets a new Graphics object for the Geometry Mask. * * @method Phaser.Display.Masks.GeometryMask#setShape * @since 3.0.0 * - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics object which will be used for the Geometry Mask. */ setShape: function (graphicsGeometry) { @@ -50745,14 +89855,14 @@ var GeometryMask = new Class({ }, /** - * [description] + * Renders the Geometry Mask's underlying Graphics object to the OpenGL stencil buffer and enables the stencil test, which clips rendered pixels according to the mask. * * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to draw to. + * @param {Phaser.GameObjects.GameObject} mask - The Game Object being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the Game Object is being rendered through. */ preRenderWebGL: function (renderer, mask, camera) { @@ -50776,16 +89886,16 @@ var GeometryMask = new Class({ // Use stencil buffer to affect next rendering object gl.colorMask(true, true, true, true); gl.stencilFunc(gl.EQUAL, 1, 1); - gl.stencilOp(gl.INVERT, gl.INVERT, gl.INVERT); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); }, /** - * [description] + * Flushes all rendered pixels and disables the stencil test of a WebGL context, thus disabling the mask for it. * * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to draw flush. */ postRenderWebGL: function (renderer) { @@ -50793,18 +89903,19 @@ var GeometryMask = new Class({ // Force flush before disabling stencil test renderer.flush(); + gl.disable(gl.STENCIL_TEST); }, /** - * [description] + * Sets the clipping path of a 2D canvas context to the Geometry Mask's underlying Graphics object. * * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance to set the clipping path on. + * @param {Phaser.GameObjects.GameObject} mask - The Game Object being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the Game Object is being rendered through. */ preRenderCanvas: function (renderer, mask, camera) { @@ -50812,18 +89923,18 @@ var GeometryMask = new Class({ renderer.currentContext.save(); - geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, undefined, null, true); + geometryMask.renderCanvas(renderer, geometryMask, 0, camera, null, null, true); renderer.currentContext.clip(); }, /** - * [description] + * Restore the canvas context's previous clipping path, thus turning off the mask for it. * * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance being restored. */ postRenderCanvas: function (renderer) { @@ -50850,7 +89961,7 @@ module.exports = GeometryMask; /***/ }), -/* 214 */ +/* 394 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -50866,7 +89977,7 @@ var Class = __webpack_require__(0); * [description] * * @class BitmapMask - * @memberOf Phaser.Display.Masks + * @memberof Phaser.Display.Masks * @constructor * @since 3.0.0 * @@ -50881,6 +89992,15 @@ var BitmapMask = new Class({ { var renderer = scene.sys.game.renderer; + /** + * A reference to either the Canvas or WebGL Renderer that this Mask is using. + * + * @name Phaser.Display.Masks.BitmapMask#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.11.0 + */ + this.renderer = renderer; + /** * A renderable Game Object that uses a texture, such as a Sprite. * @@ -51060,10 +90180,22 @@ var BitmapMask = new Class({ destroy: function () { this.bitmapMask = null; + + var renderer = this.renderer; + + if (renderer && renderer.gl) + { + renderer.deleteTexture(this.mainTexture); + renderer.deleteTexture(this.maskTexture); + renderer.deleteFramebuffer(this.mainFramebuffer); + renderer.deleteFramebuffer(this.maskFramebuffer); + } + this.mainTexture = null; this.maskTexture = null; this.mainFramebuffer = null; this.maskFramebuffer = null; + this.renderer = null; } }); @@ -51072,33 +90204,7 @@ module.exports = BitmapMask; /***/ }), -/* 215 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1, eval)("this"); -} catch (e) { - // This works if the window reference is available - if (typeof window === "object") g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }), -/* 216 */ +/* 395 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -51107,15721 +90213,145 @@ module.exports = g; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Formats = __webpack_require__(26); -var MapData = __webpack_require__(103); -var Parse = __webpack_require__(319); -var Tilemap = __webpack_require__(311); +var BitmapMask = __webpack_require__(394); +var GeometryMask = __webpack_require__(393); /** - * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When - * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from - * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For - * an empty map, you should specify tileWidth, tileHeight, width & height. + * Provides methods used for getting and setting the mask of a Game Object. * - * @function Phaser.Tilemaps.ParseToTilemap - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. - * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param {integer} [tileWidth=32] - The width of a tile in pixels. - * @param {integer} [tileHeight=32] - The height of a tile in pixels. - * @param {integer} [width=10] - The width of the map in tiles. - * @param {integer} [height=10] - The height of the map in tiles. - * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. - * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull) -{ - if (tileWidth === undefined) { tileWidth = 32; } - if (tileHeight === undefined) { tileHeight = 32; } - if (width === undefined) { width = 10; } - if (height === undefined) { height = 10; } - if (insertNull === undefined) { insertNull = false; } - - var mapData = null; - - if (Array.isArray(data)) - { - var name = key !== undefined ? key : 'map'; - mapData = Parse(name, Formats.ARRAY_2D, data, tileWidth, tileHeight, insertNull); - } - else if (key !== undefined) - { - var tilemapData = scene.cache.tilemap.get(key); - - if (!tilemapData) - { - console.warn('No map data found for key ' + key); - } - else - { - mapData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull); - } - } - - if (mapData === null) - { - mapData = new MapData({ - tileWidth: tileWidth, - tileHeight: tileHeight, - width: width, - height: height - }); - } - - return new Tilemap(scene, mapData); -}; - -module.exports = ParseToTilemap; - - -/***/ }), -/* 217 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var LayerData = __webpack_require__(104); -var MapData = __webpack_require__(103); -var Tile = __webpack_require__(66); - -/** - * Parses a 2D array of tile indexes into a new MapData object with a single layer. - * - * @function Phaser.Tilemaps.Parsers.Parse2DArray - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {integer[][]} data - 2D array, CSV string or Tiled JSON object. - * @param {integer} tileWidth - The width of a tile in pixels. - * @param {integer} tileHeight - The height of a tile in pixels. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.MapData} [description] - */ -var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull) -{ - var layerData = new LayerData({ - tileWidth: tileWidth, - tileHeight: tileHeight - }); - - var mapData = new MapData({ - name: name, - tileWidth: tileWidth, - tileHeight: tileHeight, - format: Formats.ARRAY_2D, - layers: [ layerData ] - }); - - var tiles = []; - var height = data.length; - var width = 0; - - for (var y = 0; y < data.length; y++) - { - tiles[y] = []; - var row = data[y]; - - for (var x = 0; x < row.length; x++) - { - var tileIndex = parseInt(row[x], 10); - - if (isNaN(tileIndex) || tileIndex === -1) - { - tiles[y][x] = insertNull - ? null - : new Tile(layerData, -1, x, y, tileWidth, tileHeight); - } - else - { - tiles[y][x] = new Tile(layerData, tileIndex, x, y, tileWidth, tileHeight); - } - } - - if (width === 0) - { - width = row.length; - } - } - - mapData.width = layerData.width = width; - mapData.height = layerData.height = height; - mapData.widthInPixels = layerData.widthInPixels = width * tileWidth; - mapData.heightInPixels = layerData.heightInPixels = height * tileHeight; - layerData.data = tiles; - - return mapData; -}; - -module.exports = Parse2DArray; - - -/***/ }), -/* 218 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internally used method to keep track of the tile indexes that collide within a layer. This - * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. - * - * @function Phaser.Tilemaps.Components.SetLayerCollisionIndex - * @private - * @since 3.0.0 - * - * @param {integer} tileIndex - [description] - * @param {boolean} [collides=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetLayerCollisionIndex = function (tileIndex, collides, layer) -{ - var loc = layer.collideIndexes.indexOf(tileIndex); - - if (collides && loc === -1) - { - layer.collideIndexes.push(tileIndex); - } - else if (!collides && loc !== -1) - { - layer.collideIndexes.splice(loc, 1); - } -}; - -module.exports = SetLayerCollisionIndex; - - -/***/ }), -/* 219 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tile = __webpack_require__(66); -var IsInLayerBounds = __webpack_require__(105); -var CalculateFacesAt = __webpack_require__(220); -var SetTileCollision = __webpack_require__(67); - -/** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * @function Phaser.Tilemaps.Components.PutTileAt - * @private - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. - */ -var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) -{ - if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var oldTile = layer.data[tileY][tileX]; - var oldTileCollides = oldTile && oldTile.collides; - - if (tile instanceof Tile) - { - if (layer.data[tileY][tileX] === null) - { - layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); - } - layer.data[tileY][tileX].copy(tile); - } - else - { - var index = tile; - if (layer.data[tileY][tileX] === null) - { - layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight); - } - else - { - layer.data[tileY][tileX].index = index; - } - } - - // Updating colliding flag on the new tile - var newTile = layer.data[tileY][tileX]; - var collides = layer.collideIndexes.indexOf(newTile.index) !== -1; - SetTileCollision(newTile, collides); - - // Recalculate faces only if the colliding flag at (tileX, tileY) has changed - if (recalculateFaces && (oldTileCollides !== newTile.collides)) - { - CalculateFacesAt(tileX, tileY, layer); - } - - return newTile; -}; - -module.exports = PutTileAt; - - - -/***/ }), -/* 220 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTileAt = __webpack_require__(140); - -/** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @function Phaser.Tilemaps.Components.CalculateFacesAt - * @private - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var CalculateFacesAt = function (tileX, tileY, layer) -{ - var tile = GetTileAt(tileX, tileY, true, layer); - var above = GetTileAt(tileX, tileY - 1, true, layer); - var below = GetTileAt(tileX, tileY + 1, true, layer); - var left = GetTileAt(tileX - 1, tileY, true, layer); - var right = GetTileAt(tileX + 1, tileY, true, layer); - var tileCollides = tile && tile.collides; - - // Assume the changed tile has all interesting edges - if (tileCollides) - { - tile.faceTop = true; - tile.faceBottom = true; - tile.faceLeft = true; - tile.faceRight = true; - } - - // Reset edges that are shared between tile and its neighbors - if (above && above.collides) - { - if (tileCollides) { tile.faceTop = false; } - above.faceBottom = !tileCollides; - } - - if (below && below.collides) - { - if (tileCollides) { tile.faceBottom = false; } - below.faceTop = !tileCollides; - } - - if (left && left.collides) - { - if (tileCollides) { tile.faceLeft = false; } - left.faceRight = !tileCollides; - } - - if (right && right.collides) - { - if (tileCollides) { tile.faceRight = false; } - right.faceLeft = !tileCollides; - } - - if (tile && !tile.collides) { tile.resetFaces(); } - - return tile; -}; - -module.exports = CalculateFacesAt; - - -/***/ }), -/* 221 */, -/* 222 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var quickselect = __webpack_require__(180); - -/** - * @classdesc - * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. - * It's based on an optimized R-tree data structure with bulk insertion support. - * - * Spatial index is a special data structure for points and rectangles that allows you to perform queries like - * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). - * - * This version of RBush uses a fixed min/max accessor structure of `[ '.left', '.top', '.right', '.bottom' ]`. - * This is to avoid the eval like function creation that the original library used, which caused CSP policy violations. - * - * @class RTree - * @memberOf Phaser.Structs - * @constructor + * @name Phaser.GameObjects.Components.Mask * @since 3.0.0 */ -function rbush (maxEntries) -{ - var format = [ '.left', '.top', '.right', '.bottom' ]; - - if (!(this instanceof rbush)) return new rbush(maxEntries, format); - - // max entries in a node is 9 by default; min node fill is 40% for best performance - this._maxEntries = Math.max(4, maxEntries || 9); - this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); - - this.clear(); -} - -rbush.prototype = { - - all: function () - { - return this._all(this.data, []); - }, - - search: function (bbox) - { - var node = this.data, - result = [], - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return result; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf) result.push(child); - else if (contains(bbox, childBBox)) this._all(child, result); - else nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return result; - }, - - collides: function (bbox) - { - var node = this.data, - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return false; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf || contains(bbox, childBBox)) return true; - nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return false; - }, - - load: function (data) - { - if (!(data && data.length)) return this; - - if (data.length < this._minEntries) { - for (var i = 0, len = data.length; i < len; i++) { - this.insert(data[i]); - } - return this; - } - - // recursively build the tree with the given data from scratch using OMT algorithm - var node = this._build(data.slice(), 0, data.length - 1, 0); - - if (!this.data.children.length) { - // save as is if tree is empty - this.data = node; - - } else if (this.data.height === node.height) { - // split root if trees have the same height - this._splitRoot(this.data, node); - - } else { - if (this.data.height < node.height) { - // swap trees if inserted one is bigger - var tmpNode = this.data; - this.data = node; - node = tmpNode; - } - - // insert the small tree into the large tree at appropriate level - this._insert(node, this.data.height - node.height - 1, true); - } - - return this; - }, - - insert: function (item) - { - if (item) this._insert(item, this.data.height - 1); - return this; - }, - - clear: function () - { - this.data = createNode([]); - return this; - }, - - remove: function (item, equalsFn) - { - if (!item) return this; - - var node = this.data, - bbox = this.toBBox(item), - path = [], - indexes = [], - i, parent, index, goingUp; - - // depth-first iterative tree traversal - while (node || path.length) { - - if (!node) { // go up - node = path.pop(); - parent = path[path.length - 1]; - i = indexes.pop(); - goingUp = true; - } - - if (node.leaf) { // check current node - index = findItem(item, node.children, equalsFn); - - if (index !== -1) { - // item found, remove the item and condense tree upwards - node.children.splice(index, 1); - path.push(node); - this._condense(path); - return this; - } - } - - if (!goingUp && !node.leaf && contains(node, bbox)) { // go down - path.push(node); - indexes.push(i); - i = 0; - parent = node; - node = node.children[0]; - - } else if (parent) { // go right - i++; - node = parent.children[i]; - goingUp = false; - - } else node = null; // nothing found - } - - return this; - }, - - toBBox: function (item) { return item; }, - - compareMinX: compareNodeMinX, - compareMinY: compareNodeMinY, - - toJSON: function () { return this.data; }, - - fromJSON: function (data) - { - this.data = data; - return this; - }, - - _all: function (node, result) - { - var nodesToSearch = []; - while (node) { - if (node.leaf) result.push.apply(result, node.children); - else nodesToSearch.push.apply(nodesToSearch, node.children); - - node = nodesToSearch.pop(); - } - return result; - }, - - _build: function (items, left, right, height) - { - var N = right - left + 1, - M = this._maxEntries, - node; - - if (N <= M) { - // reached leaf level; return leaf - node = createNode(items.slice(left, right + 1)); - calcBBox(node, this.toBBox); - return node; - } - - if (!height) { - // target height of the bulk-loaded tree - height = Math.ceil(Math.log(N) / Math.log(M)); - - // target number of root entries to maximize storage utilization - M = Math.ceil(N / Math.pow(M, height - 1)); - } - - node = createNode([]); - node.leaf = false; - node.height = height; - - // split the items into M mostly square tiles - - var N2 = Math.ceil(N / M), - N1 = N2 * Math.ceil(Math.sqrt(M)), - i, j, right2, right3; - - multiSelect(items, left, right, N1, this.compareMinX); - - for (i = left; i <= right; i += N1) { - - right2 = Math.min(i + N1 - 1, right); - - multiSelect(items, i, right2, N2, this.compareMinY); - - for (j = i; j <= right2; j += N2) { - - right3 = Math.min(j + N2 - 1, right2); - - // pack each entry recursively - node.children.push(this._build(items, j, right3, height - 1)); - } - } - - calcBBox(node, this.toBBox); - - return node; - }, - - _chooseSubtree: function (bbox, node, level, path) - { - var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; - - while (true) { - path.push(node); - - if (node.leaf || path.length - 1 === level) break; - - minArea = minEnlargement = Infinity; - - for (i = 0, len = node.children.length; i < len; i++) { - child = node.children[i]; - area = bboxArea(child); - enlargement = enlargedArea(bbox, child) - area; - - // choose entry with the least area enlargement - if (enlargement < minEnlargement) { - minEnlargement = enlargement; - minArea = area < minArea ? area : minArea; - targetNode = child; - - } else if (enlargement === minEnlargement) { - // otherwise choose one with the smallest area - if (area < minArea) { - minArea = area; - targetNode = child; - } - } - } - - node = targetNode || node.children[0]; - } - - return node; - }, - - _insert: function (item, level, isNode) - { - var toBBox = this.toBBox, - bbox = isNode ? item : toBBox(item), - insertPath = []; - - // find the best node for accommodating the item, saving all nodes along the path too - var node = this._chooseSubtree(bbox, this.data, level, insertPath); - - // put the item into the node - node.children.push(item); - extend(node, bbox); - - // split on node overflow; propagate upwards if necessary - while (level >= 0) { - if (insertPath[level].children.length > this._maxEntries) { - this._split(insertPath, level); - level--; - } else break; - } - - // adjust bboxes along the insertion path - this._adjustParentBBoxes(bbox, insertPath, level); - }, - - // split overflowed node into two - _split: function (insertPath, level) - { - var node = insertPath[level], - M = node.children.length, - m = this._minEntries; - - this._chooseSplitAxis(node, m, M); - - var splitIndex = this._chooseSplitIndex(node, m, M); - - var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); - newNode.height = node.height; - newNode.leaf = node.leaf; - - calcBBox(node, this.toBBox); - calcBBox(newNode, this.toBBox); - - if (level) insertPath[level - 1].children.push(newNode); - else this._splitRoot(node, newNode); - }, - - _splitRoot: function (node, newNode) - { - // split root node - this.data = createNode([node, newNode]); - this.data.height = node.height + 1; - this.data.leaf = false; - calcBBox(this.data, this.toBBox); - }, - - _chooseSplitIndex: function (node, m, M) - { - var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; - - minOverlap = minArea = Infinity; - - for (i = m; i <= M - m; i++) { - bbox1 = distBBox(node, 0, i, this.toBBox); - bbox2 = distBBox(node, i, M, this.toBBox); - - overlap = intersectionArea(bbox1, bbox2); - area = bboxArea(bbox1) + bboxArea(bbox2); - - // choose distribution with minimum overlap - if (overlap < minOverlap) { - minOverlap = overlap; - index = i; - - minArea = area < minArea ? area : minArea; - - } else if (overlap === minOverlap) { - // otherwise choose distribution with minimum area - if (area < minArea) { - minArea = area; - index = i; - } - } - } - - return index; - }, - - // sorts node children by the best axis for split - _chooseSplitAxis: function (node, m, M) - { - var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, - compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, - xMargin = this._allDistMargin(node, m, M, compareMinX), - yMargin = this._allDistMargin(node, m, M, compareMinY); - - // if total distributions margin value is minimal for x, sort by minX, - // otherwise it's already sorted by minY - if (xMargin < yMargin) node.children.sort(compareMinX); - }, - - // total margin of all possible split distributions where each node is at least m full - _allDistMargin: function (node, m, M, compare) - { - node.children.sort(compare); - - var toBBox = this.toBBox, - leftBBox = distBBox(node, 0, m, toBBox), - rightBBox = distBBox(node, M - m, M, toBBox), - margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), - i, child; - - for (i = m; i < M - m; i++) { - child = node.children[i]; - extend(leftBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(leftBBox); - } - - for (i = M - m - 1; i >= m; i--) { - child = node.children[i]; - extend(rightBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(rightBBox); - } - - return margin; - }, - - _adjustParentBBoxes: function (bbox, path, level) - { - // adjust bboxes along the given tree path - for (var i = level; i >= 0; i--) { - extend(path[i], bbox); - } - }, - - _condense: function (path) - { - // go through the path, removing empty nodes and updating bboxes - for (var i = path.length - 1, siblings; i >= 0; i--) { - if (path[i].children.length === 0) { - if (i > 0) { - siblings = path[i - 1].children; - siblings.splice(siblings.indexOf(path[i]), 1); - - } else this.clear(); - - } else calcBBox(path[i], this.toBBox); - } - }, - - compareMinX: function (a, b) - { - return a.left - b.left; - }, - - compareMinY: function (a, b) - { - return a.top - b.top; - }, - - toBBox: function (a) - { - return { - minX: a.left, - minY: a.top, - maxX: a.right, - maxY: a.bottom - }; - } -}; - -function findItem (item, items, equalsFn) -{ - if (!equalsFn) return items.indexOf(item); - - for (var i = 0; i < items.length; i++) { - if (equalsFn(item, items[i])) return i; - } - return -1; -} - -// calculate node's bbox from bboxes of its children -function calcBBox (node, toBBox) -{ - distBBox(node, 0, node.children.length, toBBox, node); -} - -// min bounding rectangle of node children from k to p-1 -function distBBox (node, k, p, toBBox, destNode) -{ - if (!destNode) destNode = createNode(null); - destNode.minX = Infinity; - destNode.minY = Infinity; - destNode.maxX = -Infinity; - destNode.maxY = -Infinity; - - for (var i = k, child; i < p; i++) { - child = node.children[i]; - extend(destNode, node.leaf ? toBBox(child) : child); - } - - return destNode; -} - -function extend (a, b) -{ - a.minX = Math.min(a.minX, b.minX); - a.minY = Math.min(a.minY, b.minY); - a.maxX = Math.max(a.maxX, b.maxX); - a.maxY = Math.max(a.maxY, b.maxY); - return a; -} - -function compareNodeMinX (a, b) { return a.minX - b.minX; } -function compareNodeMinY (a, b) { return a.minY - b.minY; } - -function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } -function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } - -function enlargedArea (a, b) -{ - return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * - (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); -} - -function intersectionArea (a, b) -{ - var minX = Math.max(a.minX, b.minX), - minY = Math.max(a.minY, b.minY), - maxX = Math.min(a.maxX, b.maxX), - maxY = Math.min(a.maxY, b.maxY); - - return Math.max(0, maxX - minX) * - Math.max(0, maxY - minY); -} - -function contains (a, b) -{ - return a.minX <= b.minX && - a.minY <= b.minY && - b.maxX <= a.maxX && - b.maxY <= a.maxY; -} - -function intersects (a, b) -{ - return b.minX <= a.maxX && - b.minY <= a.maxY && - b.maxX >= a.minX && - b.maxY >= a.minY; -} - -function createNode (children) -{ - return { - children: children, - height: 1, - leaf: true, - minX: Infinity, - minY: Infinity, - maxX: -Infinity, - maxY: -Infinity - }; -} - -// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; -// combines selection algorithm with binary divide & conquer approach - -function multiSelect (arr, left, right, n, compare) -{ - var stack = [left, right], - mid; - - while (stack.length) - { - right = stack.pop(); - left = stack.pop(); - - if (right - left <= n) continue; - - mid = left + Math.ceil((right - left) / n / 2) * n; - quickselect(arr, mid, left, right, compare); - - stack.push(left, mid, mid, right); - } -} - -module.exports = rbush; - -/***/ }), -/* 223 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class ProcessQueue - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic T - */ -var ProcessQueue = new Class({ - - initialize: - - function ProcessQueue () - { - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.ProcessQueue#_pending - * @type {Array.<*>} - * @private - * @default [] - * @since 3.0.0 - */ - this._pending = []; - - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.ProcessQueue#_active - * @type {Array.<*>} - * @private - * @default [] - * @since 3.0.0 - */ - this._active = []; - - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.ProcessQueue#_destroy - * @type {Array.<*>} - * @private - * @default [] - * @since 3.0.0 - */ - this._destroy = []; - - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_toProcess - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#add - * @since 3.0.0 - * - * @genericUse {T} - [item] - * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] - * - * @param {*} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - add: function (item) - { - this._pending.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#remove - * @since 3.0.0 - * - * @genericUse {T} - [item] - * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] - * - * @param {*} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - remove: function (item) - { - this._destroy.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#update - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @return {Array.<*>} [description] - */ - update: function () - { - if (this._toProcess === 0) - { - // Quick bail - return this._active; - } - - var list = this._destroy; - var active = this._active; - var i; - var item; - - // Clear the 'destroy' list - for (i = 0; i < list.length; i++) - { - item = list[i]; - - // Remove from the 'active' array - var idx = active.indexOf(item); - - if (idx !== -1) - { - active.splice(idx, 1); - } - } - - list.length = 0; - - // Process the pending addition list - // This stops callbacks and out of sync events from populating the active array mid-way during an update - - list = this._pending; - - for (i = 0; i < list.length; i++) - { - item = list[i]; - - this._active.push(item); - } - - list.length = 0; - - this._toProcess = 0; - - // The owner of this queue can now safely do whatever it needs to with the active list - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#getActive - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @return {Array.<*>} [description] - */ - getActive: function () - { - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#destroy - * @since 3.0.0 - */ - destroy: function () - { - this._pending = []; - this._active = []; - this._destroy = []; - } - -}); - -module.exports = ProcessQueue; - - -/***/ }), -/* 224 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.TextFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='txt'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Text File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. - * - * @class TextFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var TextFile = new Class({ - - Extends: File, - - initialize: - - function TextFile (loader, key, url, xhrSettings) - { - var extension = 'txt'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'text', - cache: loader.cacheManager.text, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.TextFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onProcessComplete(); - } - -}); - -/** - * Adds a Text file, or array of Text files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.text('story', files/IntroStory.txt'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Text Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Text Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.text({ - * key: 'story', - * url: 'files/IntroStory.txt' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.image('story', 'files/IntroStory.txt'); - * // and later in your game ... - * var data = this.cache.text.get('story'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Text Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" - * and no URL is given then the Loader will set the URL to be "story.txt". It will always add `.txt` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Text File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#text - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.TextFileConfig|Phaser.Loader.FileTypes.TextFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('text', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TextFile(this, key[i])); - } - } - else - { - this.addFile(new TextFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = TextFile; - - -/***/ }), -/* 225 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.RotateAroundXY - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var RotateAroundXY = function (triangle, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); - - var tx = triangle.x1 - x; - var ty = triangle.y1 - y; - - triangle.x1 = tx * c - ty * s + x; - triangle.y1 = tx * s + ty * c + y; - - tx = triangle.x2 - x; - ty = triangle.y2 - y; - - triangle.x2 = tx * c - ty * s + x; - triangle.y2 = tx * s + ty * c + y; - - tx = triangle.x3 - x; - ty = triangle.y3 - y; - - triangle.x3 = tx * c - ty * s + x; - triangle.y3 = tx * s + ty * c + y; - - return triangle; -}; - -module.exports = RotateAroundXY; - - -/***/ }), -/* 226 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(71); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {integer} quantity - [description] - * @param {number} stepRate - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ -var GetPoints = function (triangle, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = perimeter / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var p = perimeter * (i / quantity); - var localPosition = 0; - - var point = new Point(); - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - out.push(point); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 227 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var Length = __webpack_require__(71); - -// Position is a value between 0 and 1 -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetPoint = function (triangle, position, out) -{ - if (out === undefined) { out = new Point(); } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - if (position <= 0 || position >= 1) - { - out.x = line1.x1; - out.y = line1.y1; - - return out; - } - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - var p = perimeter * position; - var localPosition = 0; - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - return out; -}; - -module.exports = GetPoint; - - -/***/ }), -/* 228 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.GetAspectRatio - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {number} [description] - */ -var GetAspectRatio = function (rect) -{ - return (rect.height === 0) ? NaN : rect.width / rect.height; -}; - -module.exports = GetAspectRatio; - - -/***/ }), -/* 229 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Checks whether the x and y coordinates are contained within this polygon. -// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva - -/** - * [description] - * - * @function Phaser.Geom.Polygon.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (polygon, x, y) -{ - var inside = false; - - for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) - { - var ix = polygon.points[i].x; - var iy = polygon.points[i].y; - - var jx = polygon.points[j].x; - var jy = polygon.points[j].y; - - if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) - { - inside = !inside; - } - } - - return inside; -}; - -module.exports = Contains; - - -/***/ }), -/* 230 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.RotateAroundXY - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var RotateAroundXY = function (line, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); - - var tx = line.x1 - x; - var ty = line.y1 - y; - - line.x1 = tx * c - ty * s + x; - line.y1 = tx * s + ty * c + y; - - tx = line.x2 - x; - ty = line.y2 - y; - - line.x2 = tx * c - ty * s + x; - line.y2 = tx * s + ty * c + y; - - return line; -}; - -module.exports = RotateAroundXY; - - -/***/ }), -/* 231 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// http://www.blackpawn.com/texts/pointinpoly/ - -// points is an array of Point-like objects with public x/y properties -// returns an array containing all points that are within the triangle, or an empty array if none -// if 'returnFirst' is true it will return after the first point within the triangle is found - -/** - * [description] - * - * @function Phaser.Geom.Triangle.ContainsArray - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point[]} points - [description] - * @param {boolean} [returnFirst] - [description] - * @param {array} [out] - [description] - * - * @return {Phaser.Geom.Point[]} [description] - */ -var ContainsArray = function (triangle, points, returnFirst, out) -{ - if (returnFirst === undefined) { returnFirst = false; } - if (out === undefined) { out = []; } - - var v0x = triangle.x3 - triangle.x1; - var v0y = triangle.y3 - triangle.y1; - - var v1x = triangle.x2 - triangle.x1; - var v1y = triangle.y2 - triangle.y1; - - var dot00 = (v0x * v0x) + (v0y * v0y); - var dot01 = (v0x * v1x) + (v0y * v1y); - var dot11 = (v1x * v1x) + (v1y * v1y); - - // Compute barycentric coordinates - var b = ((dot00 * dot11) - (dot01 * dot01)); - var inv = (b === 0) ? 0 : (1 / b); - - var u; - var v; - var v2x; - var v2y; - var dot02; - var dot12; - - var x1 = triangle.x1; - var y1 = triangle.y1; - - for (var i = 0; i < points.length; i++) - { - v2x = points[i].x - x1; - v2y = points[i].y - y1; - - dot02 = (v0x * v2x) + (v0y * v2y); - dot12 = (v1x * v2x) + (v1y * v2y); - - u = ((dot11 * dot02) - (dot01 * dot12)) * inv; - v = ((dot00 * dot12) - (dot01 * dot02)) * inv; - - if (u >= 0 && v >= 0 && (u + v < 1)) - { - out.push({ x: points[i].x, y: points[i].y }); - - if (returnFirst) - { - break; - } - } - } - - return out; -}; - -module.exports = ContainsArray; - - -/***/ }), -/* 232 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Mesh = __webpack_require__(145); - -/** - * @classdesc - * A Quad Game Object. - * - * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single - * texture spread across them. - * - * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also - * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. - * - * @class Quad - * @extends Phaser.GameObjects.Mesh - * @memberOf Phaser.GameObjects - * @constructor - * @webglOnly - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Quad belongs. - * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Quad = new Class({ - - Extends: Mesh, - - initialize: - - function Quad (scene, x, y, texture, frame) - { - // 0----3 - // |\ B| - // | \ | - // | \ | - // | A \| - // | \ - // 1----2 - - var vertices = [ - 0, 0, // tl - 0, 0, // bl - 0, 0, // br - 0, 0, // tl - 0, 0, // br - 0, 0 // tr - ]; - var uv = [ - 0, 0, // tl - 0, 1, // bl - 1, 1, // br - 0, 0, // tl - 1, 1, // br - 1, 0 // tr - ]; - var colors = [ - 0xffffff, // tl - 0xffffff, // bl - 0xffffff, // br - 0xffffff, // tl - 0xffffff, // br - 0xffffff // tr - ]; - var alphas = [ - 1, // tl - 1, // bl - 1, // br - 1, // tl - 1, // br - 1 // tr - ]; - - Mesh.call(this, scene, x, y, vertices, uv, colors, alphas, texture, frame); - - this.resetPosition(); - }, - - /** - * The top-left x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftX - * @type {number} - * @since 3.0.0 - */ - topLeftX: { - - get: function () - { - return this.x + this.vertices[0]; - }, - - set: function (value) - { - this.vertices[0] = value - this.x; - this.vertices[6] = value - this.x; - } - - }, - - /** - * The top-left y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftY - * @type {number} - * @since 3.0.0 - */ - topLeftY: { - - get: function () - { - return this.y + this.vertices[1]; - }, - - set: function (value) - { - this.vertices[1] = value - this.y; - this.vertices[7] = value - this.y; - } - - }, - - /** - * The top-right x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightX - * @type {number} - * @since 3.0.0 - */ - topRightX: { - - get: function () - { - return this.x + this.vertices[10]; - }, - - set: function (value) - { - this.vertices[10] = value - this.x; - } - - }, - - /** - * The top-right y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightY - * @type {number} - * @since 3.0.0 - */ - topRightY: { - - get: function () - { - return this.y + this.vertices[11]; - }, - - set: function (value) - { - this.vertices[11] = value - this.y; - } - - }, - - /** - * The bottom-left x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftX - * @type {number} - * @since 3.0.0 - */ - bottomLeftX: { - - get: function () - { - return this.x + this.vertices[2]; - }, - - set: function (value) - { - this.vertices[2] = value - this.x; - } - - }, - - /** - * The bottom-left y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftY - * @type {number} - * @since 3.0.0 - */ - bottomLeftY: { - - get: function () - { - return this.y + this.vertices[3]; - }, - - set: function (value) - { - this.vertices[3] = value - this.y; - } - - }, - - /** - * The bottom-right x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightX - * @type {number} - * @since 3.0.0 - */ - bottomRightX: { - - get: function () - { - return this.x + this.vertices[4]; - }, - - set: function (value) - { - this.vertices[4] = value - this.x; - this.vertices[8] = value - this.x; - } - - }, - - /** - * The bottom-right y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightY - * @type {number} - * @since 3.0.0 - */ - bottomRightY: { - - get: function () - { - return this.y + this.vertices[5]; - }, - - set: function (value) - { - this.vertices[5] = value - this.y; - this.vertices[9] = value - this.y; - } - - }, - - /** - * The top-left alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftAlpha - * @type {float} - * @since 3.0.0 - */ - topLeftAlpha: { - - get: function () - { - return this.alphas[0]; - }, - - set: function (value) - { - this.alphas[0] = value; - this.alphas[3] = value; - } - - }, - - /** - * The top-right alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightAlpha - * @type {float} - * @since 3.0.0 - */ - topRightAlpha: { - - get: function () - { - return this.alphas[5]; - }, - - set: function (value) - { - this.alphas[5] = value; - } - - }, - - /** - * The bottom-left alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftAlpha - * @type {float} - * @since 3.0.0 - */ - bottomLeftAlpha: { - - get: function () - { - return this.alphas[1]; - }, - - set: function (value) - { - this.alphas[1] = value; - } - - }, - - /** - * The bottom-right alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightAlpha - * @type {float} - * @since 3.0.0 - */ - bottomRightAlpha: { - - get: function () - { - return this.alphas[2]; - }, - - set: function (value) - { - this.alphas[2] = value; - this.alphas[4] = value; - } - - }, - - /** - * The top-left color value of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftColor - * @type {number} - * @since 3.0.0 - */ - topLeftColor: { - - get: function () - { - return this.colors[0]; - }, - - set: function (value) - { - this.colors[0] = value; - this.colors[3] = value; - } - - }, - - /** - * The top-right color value of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightColor - * @type {number} - * @since 3.0.0 - */ - topRightColor: { - - get: function () - { - return this.colors[5]; - }, - - set: function (value) - { - this.colors[5] = value; - } - - }, - - /** - * The bottom-left color value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftColor - * @type {number} - * @since 3.0.0 - */ - bottomLeftColor: { - - get: function () - { - return this.colors[1]; - }, - - set: function (value) - { - this.colors[1] = value; - } - - }, - - /** - * The bottom-right color value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightColor - * @type {number} - * @since 3.0.0 - */ - bottomRightColor: { - - get: function () - { - return this.colors[2]; - }, - - set: function (value) - { - this.colors[2] = value; - this.colors[4] = value; - } - - }, - - /** - * Sets the top-left vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setTopLeft - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setTopLeft: function (x, y) - { - this.topLeftX = x; - this.topLeftY = y; - - return this; - }, - - /** - * Sets the top-right vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setTopRight - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setTopRight: function (x, y) - { - this.topRightX = x; - this.topRightY = y; - - return this; - }, - - /** - * Sets the bottom-left vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setBottomLeft - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setBottomLeft: function (x, y) - { - this.bottomLeftX = x; - this.bottomLeftY = y; - - return this; - }, - - /** - * Sets the bottom-right vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setBottomRight - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setBottomRight: function (x, y) - { - this.bottomRightX = x; - this.bottomRightY = y; - - return this; - }, - - /** - * Resets the positions of the four corner vertices of this Quad. - * - * @method Phaser.GameObjects.Quad#resetPosition - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetPosition: function () - { - var x = this.x; - var y = this.y; - var halfWidth = Math.floor(this.width / 2); - var halfHeight = Math.floor(this.height / 2); - - this.setTopLeft(x - halfWidth, y - halfHeight); - this.setTopRight(x + halfWidth, y - halfHeight); - this.setBottomLeft(x - halfWidth, y + halfHeight); - this.setBottomRight(x + halfWidth, y + halfHeight); - - return this; - }, - - /** - * Resets the alpha values used by this Quad back to 1. - * - * @method Phaser.GameObjects.Quad#resetAlpha - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetAlpha: function () - { - var alphas = this.alphas; - - alphas[0] = 1; - alphas[1] = 1; - alphas[2] = 1; - alphas[3] = 1; - alphas[4] = 1; - alphas[5] = 1; - - return this; - }, - - /** - * Resets the color values used by this Quad back to 0xffffff. - * - * @method Phaser.GameObjects.Quad#resetColors - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetColors: function () - { - var colors = this.colors; - - colors[0] = 0xffffff; - colors[1] = 0xffffff; - colors[2] = 0xffffff; - colors[3] = 0xffffff; - colors[4] = 0xffffff; - colors[5] = 0xffffff; - - return this; - }, - - /** - * Resets the position, alpha and color values used by this Quad. - * - * @method Phaser.GameObjects.Quad#reset - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - reset: function () - { - this.resetPosition(); - - this.resetAlpha(); - - return this.resetColors(); - } - -}); - -module.exports = Quad; - - -/***/ }), -/* 233 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(22); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var CONST = __webpack_require__(20); -var GameObject = __webpack_require__(2); -var GetPowerOfTwo = __webpack_require__(411); -var TileSpriteRender = __webpack_require__(886); - -/** - * @classdesc - * [description] - * - * @class TileSprite - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var TileSprite = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - TileSpriteRender - ], - - initialize: - - function TileSprite (scene, x, y, width, height, texture, frame) - { - var renderer = scene.sys.game.renderer; - - GameObject.call(this, scene, 'TileSprite'); - - /** - * The horizontal scroll position of the Tile Sprite. - * - * @name Phaser.GameObjects.TileSprite#tilePositionX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tilePositionX = 0; - - /** - * The vertical scroll position of the Tile Sprite. - * - * @name Phaser.GameObjects.TileSprite#tilePositionY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tilePositionY = 0; - - /** - * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. - * - * Such changes include the texture frame and scroll position of the Tile Sprite. - * - * @name Phaser.GameObjects.TileSprite#dirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.dirty = true; - - /** - * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. - * - * @name Phaser.GameObjects.TileSprite#tileTexture - * @type {?WebGLTexture} - * @default null - * @since 3.0.0 - */ - this.tileTexture = null; - - /** - * The renderer in use by this Tile Sprite. - * - * @name Phaser.GameObjects.TileSprite#renderer - * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} - * @since 3.0.0 - */ - this.renderer = renderer; - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSize(width, height); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - - /** - * The next power of two value from the width of the Frame. - * - * @name Phaser.GameObjects.TileSprite#potWidth - * @type {integer} - * @since 3.0.0 - */ - this.potWidth = GetPowerOfTwo(this.frame.width); - - /** - * The next power of two value from the height of the Frame. - * - * @name Phaser.GameObjects.TileSprite#potHeight - * @type {integer} - * @since 3.0.0 - */ - this.potHeight = GetPowerOfTwo(this.frame.height); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasPattern - * @type {?CanvasPattern} - * @default null - * @since 3.0.0 - */ - this.canvasPattern = null; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasBuffer - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvasBuffer = CanvasPool.create2D(this, this.potWidth, this.potHeight); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasBufferCtx - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.canvasBufferCtx = this.canvasBuffer.getContext('2d'); - - this.oldFrame = null; - - this.updateTileTexture(); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function (renderer) - { - var gl = renderer.gl; - - this.tileTexture = null; - this.dirty = true; - this.tileTexture = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.canvasBuffer, this.potWidth, this.potHeight); - }, this); - } - }, - - /** - * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. - * - * @method Phaser.GameObjects.TileSprite#setTilePosition - * @since 3.3.0 - * - * @param {number} [x] - The x position of this sprite's tiling texture. - * @param {number} [y] - The y position of this sprite's tiling texture. - * - * @return {Phaser.GameObjects.TileSprite} This Tile Sprite instance. - */ - setTilePosition: function (x, y) - { - if (x !== undefined) - { - this.tilePositionX = x; - } - - if (y !== undefined) - { - this.tilePositionY = y; - } - - return this; - }, - - /** - * Render the tile texture if it is dirty, or if the frame has changed. - * - * @method Phaser.GameObjects.TileSprite#updateTileTexture - * @since 3.0.0 - */ - updateTileTexture: function () - { - if (!this.dirty && this.oldFrame === this.frame) - { - return; - } - - this.oldFrame = this.frame; - - this.canvasBufferCtx.clearRect(0, 0, this.canvasBuffer.width, this.canvasBuffer.height); - - if (this.renderer.gl) - { - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.potWidth, this.potHeight - ); - - this.tileTexture = this.renderer.canvasToTexture(this.canvasBuffer, this.tileTexture); - } - else - { - this.canvasBuffer.width = this.frame.cutWidth; - this.canvasBuffer.height = this.frame.cutHeight; - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.frame.cutWidth, this.frame.cutHeight - ); - - this.canvasPattern = this.canvasBufferCtx.createPattern(this.canvasBuffer, 'repeat'); - } - - this.dirty = false; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.TileSprite#preDestroy - * @protected - * @since 3.9.0 - */ - preDestroy: function () - { - if (this.renderer && this.renderer.gl) - { - this.renderer.deleteTexture(this.tileTexture); - } - - CanvasPool.remove(this.canvasBuffer); - - this.canvasPattern = null; - this.canvasBufferCtx = null; - this.canvasBuffer = null; - - this.renderer = null; - } - -}); - -module.exports = TileSprite; - - -/***/ }), -/* 234 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(22); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var CONST = __webpack_require__(20); -var GameObject = __webpack_require__(2); -var Render = __webpack_require__(894); -var RenderTextureCanvas = __webpack_require__(891); -var RenderTextureWebGL = __webpack_require__(890); - -/** - * @classdesc - * A Render Texture. - * - * @class RenderTexture - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.2.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.MatrixStack - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {integer} [width=32] - The width of the Render Texture. - * @param {integer} [height=32] - The height of the Render Texture. - */ -var RenderTexture = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.MatrixStack, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Tint, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function RenderTexture (scene, x, y, width, height) - { - if (width === undefined) { width = 32; } - if (height === undefined) { height = 32; } - - GameObject.call(this, scene, 'RenderTexture'); - - this.initMatrixStack(); - - /** - * A reference to either the Canvas or WebGL Renderer that the Game instance is using. - * - * @name Phaser.GameObjects.RenderTexture#renderer - * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} - * @since 3.2.0 - */ - this.renderer = scene.sys.game.renderer; - - /** - * The tint of the Render Texture when rendered. - * - * @name Phaser.GameObjects.RenderTexture#globalTint - * @type {number} - * @default 0xffffff - * @since 3.2.0 - */ - this.globalTint = 0xffffff; - - /** - * The alpha of the Render Texture when rendered. - * - * @name Phaser.GameObjects.RenderTexture#globalAlpha - * @type {number} - * @default 1 - * @since 3.2.0 - */ - this.globalAlpha = 1; - - /** - * The HTML Canvas Element that the Render Texture is drawing to. - * This is only set if Phaser is running with the Canvas Renderer. - * - * @name Phaser.GameObjects.RenderTexture#canvas - * @type {?HTMLCanvasElement} - * @since 3.2.0 - */ - this.canvas = null; - - /** - * A reference to the Rendering Context belonging to the Canvas Element this Render Texture is drawing to. - * This is only set if Phaser is running with the Canvas Renderer. - * - * @name Phaser.GameObjects.RenderTexture#context - * @type {?CanvasRenderingContext2D} - * @since 3.2.0 - */ - this.context = null; - - /** - * A reference to the GL Frame Buffer this Render Texture is drawing to. - * This is only set if Phaser is running with the WebGL Renderer. - * - * @name Phaser.GameObjects.RenderTexture#framebuffer - * @type {?WebGLFramebuffer} - * @since 3.2.0 - */ - this.framebuffer = null; - - if (this.renderer.type === CONST.WEBGL) - { - var gl = this.renderer.gl; - - this.gl = gl; - this.fill = RenderTextureWebGL.fill; - this.clear = RenderTextureWebGL.clear; - this.draw = RenderTextureWebGL.draw; - this.drawFrame = RenderTextureWebGL.drawFrame; - this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); - this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); - } - else if (this.renderer.type === CONST.CANVAS) - { - this.fill = RenderTextureCanvas.fill; - this.clear = RenderTextureCanvas.clear; - this.draw = RenderTextureCanvas.draw; - this.drawFrame = RenderTextureCanvas.drawFrame; - this.canvas = CanvasPool.create2D(this, width, height); - this.context = this.canvas.getContext('2d'); - } - - this.setPosition(x, y); - this.setSize(width, height); - this.initPipeline('TextureTintPipeline'); - }, - - /** - * Resizes the Render Texture to the new dimensions given. - * - * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. - * In Canvas it will resize the underlying canvas element. - * Both approaches will erase everything currently drawn to the Render Texture. - * - * If the dimensions given are the same as those already being used, calling this method will do nothing. - * - * @method Phaser.GameObjects.RenderTexture#resize - * @since 3.10.0 - * - * @param {number} width - The new width of the Render Texture. - * @param {number} [height] - The new height of the Render Texture. If not specified, will be set the same as the `width`. - * - * @return {this} This Render Texture. - */ - resize: function (width, height) - { - if (height === undefined) { height = width; } - - if (width !== this.width || height !== this.height) - { - if (this.canvas) - { - this.canvas.width = width; - this.canvas.height = height; - } - else - { - this.renderer.deleteTexture(this.texture); - this.renderer.deleteFramebuffer(this.framebuffer); - - var gl = this.renderer.gl; - - this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); - this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); - } - - this.setSize(width, height); - } - - return this; - }, - - /** - * Set the tint to use when rendering this Render Texture. - * - * @method Phaser.GameObjects.RenderTexture#setGlobalTint - * @since 3.2.0 - * - * @param {integer} tint - The tint value. - * - * @return {this} This Render Texture. - */ - setGlobalTint: function (tint) - { - this.globalTint = tint; - - return this; - }, - - /** - * Set the alpha to use when rendering this Render Texture. - * - * @method Phaser.GameObjects.RenderTexture#setGlobalAlpha - * @since 3.2.0 - * - * @param {number} alpha - The alpha value. - * - * @return {this} This Render Texture. - */ - setGlobalAlpha: function (alpha) - { - this.globalAlpha = alpha; - - return this; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.RenderTexture#preDestroy - * @protected - * @since 3.9.0 - */ - preDestroy: function () - { - if (this.renderer && this.renderer.gl) - { - this.renderer.deleteTexture(this.texture); - this.renderer.deleteFramebuffer(this.framebuffer); - } - } - - /** - * Fills the Render Texture with the given color. - * - * @method Phaser.GameObjects.RenderTexture#fill - * @since 3.2.0 - * - * @param {number} rgb - The color to fill the Render Texture with. - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - - /** - * Clears the Render Texture. - * - * @method Phaser.GameObjects.RenderTexture#clear - * @since 3.2.0 - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - - /** - * Draws a texture frame to the Render Texture at the given position. - * - * @method Phaser.GameObjects.RenderTexture#draw - * @since 3.2.0 - * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {number} x - The x position to draw the frame at. - * @param {number} y - The y position to draw the frame at. - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - -}); - -module.exports = RenderTexture; - - -/***/ }), -/* 235 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var GravityWell = __webpack_require__(458); -var List = __webpack_require__(93); -var ParticleEmitter = __webpack_require__(456); -var Render = __webpack_require__(898); - -/** - * @classdesc - * A Particle Emitter Manager creates and controls {@link Phaser.GameObjects.Particles.ParticleEmitter Particle Emitters} and {@link Phaser.GameObjects.Particles.GravityWell Gravity Wells}. - * - * @class ParticleEmitterManager - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects.Particles - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Particles.Components.Depth - * @extends Phaser.GameObjects.Particles.Components.Pipeline - * @extends Phaser.GameObjects.Particles.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Emitter Manager belongs. - * @param {string} texture - The key of the Texture this Emitter Manager will use to render particles, as stored in the Texture Manager. - * @param {(string|integer)} frame - An optional frame from the Texture this Emitter Manager will use to render particles. - * @param {ParticleEmitterConfig|ParticleEmitterConfig[]} emitters - Configuration settings for one or more emitters to create. - */ -var ParticleEmitterManager = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Depth, - Components.Pipeline, - Components.Visible, - Render - ], - - initialize: - - // frame is optional and can contain the emitters array or object if skipped - function ParticleEmitterManager (scene, texture, frame, emitters) - { - GameObject.call(this, scene, 'ParticleEmitterManager'); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode - * @type {integer} - * @default -1 - * @private - * @since 3.0.0 - */ - this.blendMode = -1; - - /** - * The time scale applied to all emitters and particles, affecting flow rate, lifespan, and movement. - * Values larger than 1 are faster than normal. - * This is multiplied with any timeScale set on each individual emitter. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * The texture used to render this Emitter Manager's particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture - * @type {Phaser.Textures.Texture} - * @default null - * @since 3.0.0 - */ - this.texture = null; - - /** - * The texture frame used to render this Emitter Manager's particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame - * @type {Phaser.Textures.Frame} - * @default null - * @since 3.0.0 - */ - this.frame = null; - - /** - * Names of this Emitter Manager's texture frames. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames - * @type {string[]} - * @since 3.0.0 - */ - this.frameNames = []; - - // frame is optional and can contain the emitters array or object if skipped - if (frame !== null && (typeof frame === 'object' || Array.isArray(frame))) - { - emitters = frame; - frame = null; - } - - this.setTexture(texture, frame); - - this.initPipeline('TextureTintPipeline'); - - /** - * A list of Emitters being managed by this Emitter Manager. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters - * @type {Phaser.Structs.List.} - * @since 3.0.0 - */ - this.emitters = new List(this); - - /** - * A list of Gravity Wells being managed by this Emitter Manager. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells - * @type {Phaser.Structs.List.} - * @since 3.0.0 - */ - this.wells = new List(this); - - if (emitters) - { - // An array of emitter configs? - if (!Array.isArray(emitters)) - { - emitters = [ emitters ]; - } - - for (var i = 0; i < emitters.length; i++) - { - this.createEmitter(emitters[i]); - } - } - }, - - /** - * Sets the texture and frame this Emitter Manager will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture - * @since 3.0.0 - * - * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - setTexture: function (key, frame) - { - this.texture = this.scene.sys.textures.get(key); - - return this.setFrame(frame); - }, - - /** - * Sets the frame this Emitter Manager will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame - * @since 3.0.0 - * - * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - setFrame: function (frame) - { - this.frame = this.texture.get(frame); - - this.frameNames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); - - this.defaultFrame = this.frame; - - return this; - }, - - /** - * Assigns texture frames to an emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames - * @since 3.0.0 - * - * @param {(Phaser.Textures.Frame|Phaser.Textures.Frame[])} frames - The texture frames. - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The particle emitter to modify. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - setEmitterFrames: function (frames, emitter) - { - if (!Array.isArray(frames)) - { - frames = [ frames ]; - } - - var out = emitter.frames; - - out.length = 0; - - for (var i = 0; i < frames.length; i++) - { - var frame = frames[i]; - - if (this.frameNames.indexOf(frame) !== -1) - { - out.push(this.texture.get(frame)); - } - } - - if (out.length > 0) - { - emitter.defaultFrame = out[0]; - } - else - { - emitter.defaultFrame = this.defaultFrame; - } - - return this; - }, - - /** - * Adds an existing Particle Emitter to this Emitter Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager. - */ - addEmitter: function (emitter) - { - return this.emitters.add(emitter); - }, - - /** - * Creates a new Particle Emitter object, adds it to this Emitter Manager and returns a reference to it. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created. - */ - createEmitter: function (config) - { - return this.addEmitter(new ParticleEmitter(this, config)); - }, - - /** - * Adds an existing Gravity Well object to this Emitter Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager. - * - * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager. - */ - addGravityWell: function (well) - { - return this.wells.add(well); - }, - - /** - * Creates a new Gravity Well, adds it to this Emitter Manager and returns a reference to it. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. - */ - createGravityWell: function (config) - { - return this.addGravityWell(new GravityWell(config)); - }, - - /** - * Emits particles from each active emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle - * @since 3.0.0 - * - * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - * @param {float} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. - * @param {float} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - emitParticle: function (count, x, y) - { - var emitters = this.emitters.list; - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - if (emitter.active) - { - emitter.emitParticle(count, x, y); - } - } - - return this; - }, - - /** - * Emits particles from each active emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt - * @since 3.0.0 - * - * @param {float} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. - * @param {float} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. - * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - emitParticleAt: function (x, y, count) - { - return this.emitParticle(count, x, y); - }, - - /** - * Pauses this Emitter Manager. - * - * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. - * - * The particles will still render, but they will not have any of their logic updated. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - pause: function () - { - this.active = false; - - return this; - }, - - /** - * Resumes this Emitter Manager, should it have been previously paused. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - resume: function () - { - this.active = true; - - return this; - }, - - /** - * Gets all active particle processors (gravity wells). - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.GravityWell[]} - The active gravity wells. - */ - getProcessors: function () - { - return this.wells.getAll('active', true); - }, - - /** - * Updates all active emitters. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate - * @since 3.0.0 - * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {float} delta - The delta time, in ms, elapsed since the last frame. - */ - preUpdate: function (time, delta) - { - // Scale the delta - delta *= this.timeScale; - - var emitters = this.emitters.list; - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - if (emitter.active) - { - emitter.preUpdate(time, delta); - } - } - }, - - /** - * A NOOP method so you can pass an EmitterManager to a Container. - * Calling this method will do nothing. It is intentionally empty. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setAlpha - * @private - * @since 3.10.0 - */ - setAlpha: function () - { - }, - - /** - * A NOOP method so you can pass an EmitterManager to a Container. - * Calling this method will do nothing. It is intentionally empty. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setScrollFactor - * @private - * @since 3.10.0 - */ - setScrollFactor: function () - { - } - -}); - -module.exports = ParticleEmitterManager; - - -/***/ }), -/* 236 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Stepped - */ - -module.exports = __webpack_require__(421); - - -/***/ }), -/* 237 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Sine - */ - -module.exports = { - - In: __webpack_require__(424), - Out: __webpack_require__(423), - InOut: __webpack_require__(422) - -}; - - -/***/ }), -/* 238 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Quintic - */ - -module.exports = { - - In: __webpack_require__(427), - Out: __webpack_require__(426), - InOut: __webpack_require__(425) - -}; - - -/***/ }), -/* 239 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Quartic - */ - -module.exports = { - - In: __webpack_require__(430), - Out: __webpack_require__(429), - InOut: __webpack_require__(428) - -}; - - -/***/ }), -/* 240 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Quadratic - */ - -module.exports = { - - In: __webpack_require__(433), - Out: __webpack_require__(432), - InOut: __webpack_require__(431) - -}; - - -/***/ }), -/* 241 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Linear - */ - -module.exports = __webpack_require__(434); - - -/***/ }), -/* 242 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Expo - */ - -module.exports = { - - In: __webpack_require__(437), - Out: __webpack_require__(436), - InOut: __webpack_require__(435) - -}; - - -/***/ }), -/* 243 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Elastic - */ - -module.exports = { - - In: __webpack_require__(440), - Out: __webpack_require__(439), - InOut: __webpack_require__(438) - -}; - - -/***/ }), -/* 244 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Cubic - */ - -module.exports = { - - In: __webpack_require__(443), - Out: __webpack_require__(442), - InOut: __webpack_require__(441) - -}; - - -/***/ }), -/* 245 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Circular - */ - -module.exports = { - - In: __webpack_require__(446), - Out: __webpack_require__(445), - InOut: __webpack_require__(444) - -}; - - -/***/ }), -/* 246 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Bounce - */ - -module.exports = { - - In: __webpack_require__(449), - Out: __webpack_require__(448), - InOut: __webpack_require__(447) - -}; - - -/***/ }), -/* 247 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Back - */ - -module.exports = { - - In: __webpack_require__(452), - Out: __webpack_require__(451), - InOut: __webpack_require__(450) - -}; - - -/***/ }), -/* 248 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Generate a random floating point number between the two given bounds, minimum inclusive, maximum exclusive. - * - * @function Phaser.Math.FloatBetween - * @since 3.0.0 - * - * @param {float} min - The lower bound for the float, inclusive. - * @param {float} max - The upper bound for the float exclusive. - * - * @return {float} A random float within the given range. - */ -var FloatBetween = function (min, max) -{ - return Math.random() * (max - min) + min; -}; - -module.exports = FloatBetween; - - -/***/ }), -/* 249 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Ellipse = __webpack_require__(114); - -Ellipse.Area = __webpack_require__(472); -Ellipse.Circumference = __webpack_require__(177); -Ellipse.CircumferencePoint = __webpack_require__(113); -Ellipse.Clone = __webpack_require__(471); -Ellipse.Contains = __webpack_require__(54); -Ellipse.ContainsPoint = __webpack_require__(470); -Ellipse.ContainsRect = __webpack_require__(469); -Ellipse.CopyFrom = __webpack_require__(468); -Ellipse.Equals = __webpack_require__(467); -Ellipse.GetBounds = __webpack_require__(466); -Ellipse.GetPoint = __webpack_require__(179); -Ellipse.GetPoints = __webpack_require__(178); -Ellipse.Offset = __webpack_require__(465); -Ellipse.OffsetPoint = __webpack_require__(464); -Ellipse.Random = __webpack_require__(134); - -module.exports = Ellipse; - - -/***/ }), -/* 250 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var GetBitmapTextSize = __webpack_require__(475); -var Render = __webpack_require__(903); - -/** - * @typedef {object} DisplayCallbackConfig - * @property {{topLeft:number,topRight:number,bottomLeft:number,bottomRight:number}} tint - The tint of the character being rendered. - * @property {number} index - The index of the character being rendered. - * @property {number} charCode - The character code of the character being rendered. - * @property {number} x - The x position of the character being rendered. - * @property {number} y - The y position of the character being rendered. - * @property {number} scale - The scale of the character being rendered. - * @property {number} rotation - The rotation of the character being rendered. - * @property {any} data - Custom data stored with the character being rendered. - */ - -/** - * @callback DisplayCallback - * - * @param {DisplayCallbackConfig} display - Settings of the character that is about to be rendered. - * - * @return {{x:number, y:number, scale:number, rotation:number}} Altered position, scale and rotation values for the character that is about to be rendered. - */ - -/** - * @classdesc - * [description] - * - * @class DynamicBitmapText - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} x - The x coordinate of this Game Object in world space. - * @param {number} y - The y coordinate of this Game Object in world space. - * @param {string} font - The key of the font to use from the Bitmap Font cache. - * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @param {number} [size] - The font size of this Bitmap Text. - */ -var DynamicBitmapText = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScrollFactor, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function DynamicBitmapText (scene, x, y, font, text, size) - { - if (text === undefined) { text = ''; } - - GameObject.call(this, scene, 'DynamicBitmapText'); - - /** - * The key of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#font - * @type {string} - * @since 3.0.0 - */ - this.font = font; - - var entry = this.scene.sys.cache.bitmapFont.get(font); - - /** - * The data of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#fontData - * @type {BitmapFontData} - * @since 3.0.0 - */ - this.fontData = entry.data; - - /** - * The text that this Bitmap Text object displays. - * - * @name Phaser.GameObjects.DynamicBitmapText#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * The font size of this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#fontSize - * @type {number} - * @since 3.0.0 - */ - 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.setText(text); - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * An object that describes the size of this BitmapText. - * - * @name Phaser.GameObjects.DynamicBitmapText#_bounds - * @type {BitmapTextSize} - * @private - * @since 3.0.0 - */ - this._bounds = this.getTextBounds(); - - /** - * The horizontal scroll position of the Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * The vertical scroll position of the Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * The crop width of the Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#cropWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cropWidth = 0; - - /** - * The crop height of the Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#cropHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cropHeight = 0; - - /** - * A callback that alters how each character of the Bitmap Text is rendered. - * - * @name Phaser.GameObjects.DynamicBitmapText#displayCallback; - * @type {DisplayCallback} - * @since 3.0.0 - */ - this.displayCallback; - }, - - /** - * Set the crop size of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setSize - * @since 3.0.0 - * - * @param {number} width - The width of the crop. - * @param {number} height - The height of the crop. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setSize: function (width, height) - { - this.cropWidth = width; - this.cropHeight = height; - - return this; - }, - - /** - * Set a callback that alters how each character of the Bitmap Text is rendered. - * - * The callback receives a {@link DisplayCallbackConfig} object that contains information about the character that's - * about to be rendered. - * - * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the - * usual values when rendering. - * - * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback - * @since 3.0.0 - * - * @param {DisplayCallback} callback - The display callback to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setDisplayCallback: function (callback) - { - this.displayCallback = callback; - - return this; - }, - - /** - * Set the font size of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setFontSize - * @since 3.0.0 - * - * @param {number} size - The font size to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setFontSize: function (size) - { - this.fontSize = size; - - return this; - }, - - /** - * Set the content of this BitmapText. - * - * An array of strings will be converted multi-line text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setText - * @since 3.0.0 - * - * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateDisplayOrigin(); - } - - return this; - }, - - /** - * Set the horizontal scroll position of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setScrollX - * @since 3.0.0 - * - * @param {number} value - The horizontal scroll position to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setScrollX: function (value) - { - this.scrollX = value; - - return this; - }, - - /** - * Set the vertical scroll position of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setScrollY - * @since 3.0.0 - * - * @param {number} value - The vertical scroll position to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setScrollY: function (value) - { - this.scrollY = value; - - return this; - }, - - /** - * Calculate the bounds of this Bitmap Text. - * - * An object is returned that contains the position, width and height of the Bitmap Text in local and global - * contexts. - * - * Local size is based on just the font size and a [0, 0] position. - * - * Global size takes into account the Game Object's scale and world position. - * - * @method Phaser.GameObjects.DynamicBitmapText#getTextBounds - * @since 3.0.0 - * - * @param {boolean} [round] - Whether to round the results to the nearest integer. - * - * @return {BitmapTextSize} An object that describes the size of this Bitmap Text. - */ - getTextBounds: function (round) - { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position - - this._bounds = GetBitmapTextSize(this, round); - - return this._bounds; - }, - - /** - * The width of this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#width - * @type {number} - * @readOnly - * @since 3.0.0 - */ - width: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.width; - } - - }, - - /** - * The height of this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#height - * @type {number} - * @readOnly - * @since 3.0.0 - */ - height: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.height; - } - - }, - - /** - * Build a JSON representation of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#toJSON - * @since 3.0.0 - * - * @return {JSONBitmapText} The JSON representation of this Bitmap Text. - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra data is added here - - var data = { - font: this.font, - text: this.text, - fontSize: this.fontSize - }; - - out.data = data; - - return out; - } - -}); - -module.exports = DynamicBitmapText; - - -/***/ }), -/* 251 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArrayUtils = __webpack_require__(147); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var Rectangle = __webpack_require__(14); -var Render = __webpack_require__(906); -var Union = __webpack_require__(473); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * A Container Game Object. - * - * 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. - * - * The position of the Game Object automatically becomes relative to the position of the Container. - * - * When the Container is rendered, all of its children are rendered as well, in the order in which they exist - * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. - * - * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will - * automatically influence all children as well. - * - * Containers can include other Containers for deeply nested transforms. - * - * Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked. - * The masks do not 'stack up'. Only a Container on the root of the display list will use its mask. - * - * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them - * to use as their hit area. Container children can also be enabled for input, independent of the Container. - * - * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, - * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, - * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children - * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure - * your game to work around this. - * - * It's important to understand the impact of using Containers. They add additional processing overhead into - * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true - * for input events. You also loose the ability to set the display depth of Container children in the same - * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost - * every time you create one, try to structure your game around avoiding that where possible. - * - * @class Container - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.4.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} [x=0] - The horizontal position of this Game Object in the world. - * @param {number} [y=0] - The vertical position of this Game Object in the world. - * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. - */ -var Container = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.ScrollFactor, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function Container (scene, x, y, children) - { - GameObject.call(this, scene, 'Container'); - - /** - * An array holding the children of this Container. - * - * @name Phaser.GameObjects.Container#list - * @type {Phaser.GameObjects.GameObject[]} - * @since 3.4.0 - */ - this.list = []; - - /** - * Does this Container exclusively manage its children? - * - * The default is `true` which means a child added to this Container cannot - * belong in another Container, which includes the Scene display list. - * - * If you disable this then this Container will no longer exclusively manage its children. - * This allows you to create all kinds of interesting graphical effects, such as replicating - * Game Objects without reparenting them all over the Scene. - * However, doing so will prevent children from receiving any kind of input event or have - * their physics bodies work by default, as they're no longer a single entity on the - * display list, but are being replicated where-ever this Container is. - * - * @name Phaser.GameObjects.Container#exclusive - * @type {boolean} - * @default true - * @since 3.4.0 - */ - this.exclusive = true; - - /** - * Containers can have an optional maximum size. If set to anything above 0 it - * will constrict the addition of new Game Objects into the Container, capping off - * the maximum limit the Container can grow in size to. - * - * @name Phaser.GameObjects.Container#maxSize - * @type {integer} - * @default -1 - * @since 3.4.0 - */ - this.maxSize = -1; - - /** - * The cursor position. - * - * @name Phaser.GameObjects.Container#position - * @type {integer} - * @since 3.4.0 - */ - this.position = 0; - - /** - * Internal Transform Matrix used for local space conversion. - * - * @name Phaser.GameObjects.Container#localTransform - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @since 3.4.0 - */ - this.localTransform = new Components.TransformMatrix(); - - /** - * Internal temporary Transform Matrix used to avoid object creation. - * - * @name Phaser.GameObjects.Container#tempTransformMatrix - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @private - * @since 3.4.0 - */ - this.tempTransformMatrix = new Components.TransformMatrix(); - - /** - * A reference to the Scene Display List. - * - * @name Phaser.GameObjects.Container#_displayList - * @type {Phaser.GameObjects.DisplayList} - * @private - * @since 3.4.0 - */ - this._displayList = scene.sys.displayList; - - /** - * The property key to sort by. - * - * @name Phaser.GameObjects.Container#_sortKey - * @type {string} - * @private - * @since 3.4.0 - */ - this._sortKey = ''; - - /** - * A reference to the Scene Systems Event Emitter. - * - * @name Phaser.GameObjects.Container#_sysEvents - * @type {Phaser.Events.EventEmitter} - * @private - * @since 3.9.0 - */ - this._sysEvents = scene.sys.events; - - this.setPosition(x, y); - - this.clearAlpha(); - - if (children) - { - this.add(children); - } - }, - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - * - * @name Phaser.GameObjects.Container#originX - * @type {number} - * @readOnly - * @since 3.4.0 - */ - originX: { - - get: function () - { - return 0.5; - } - - }, - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - * - * @name Phaser.GameObjects.Container#originY - * @type {number} - * @readOnly - * @since 3.4.0 - */ - originY: { - - get: function () - { - return 0.5; - } - - }, - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - * - * @name Phaser.GameObjects.Container#displayOriginX - * @type {number} - * @readOnly - * @since 3.4.0 - */ - displayOriginX: { - - get: function () - { - return this.width * 0.5; - } - - }, - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - * - * @name Phaser.GameObjects.Container#displayOriginY - * @type {number} - * @readOnly - * @since 3.4.0 - */ - displayOriginY: { - - get: function () - { - return this.height * 0.5; - } - - }, - - /** - * Does this Container exclusively manage its children? - * - * The default is `true` which means a child added to this Container cannot - * belong in another Container, which includes the Scene display list. - * - * If you disable this then this Container will no longer exclusively manage its children. - * This allows you to create all kinds of interesting graphical effects, such as replicating - * Game Objects without reparenting them all over the Scene. - * However, doing so will prevent children from receiving any kind of input event or have - * their physics bodies work by default, as they're no longer a single entity on the - * display list, but are being replicated where-ever this Container is. - * - * @method Phaser.GameObjects.Container#setExclusive - * @since 3.4.0 - * - * @param {boolean} [value=true] - The exclusive state of this Container. - * - * @return {Phaser.GameObjects.Container} This Container. - */ - setExclusive: function (value) - { - if (value === undefined) { value = true; } - - this.exclusive = value; - - return this; - }, - - /** - * Gets the bounds of this Container. It works by iterating all children of the Container, - * getting their respective bounds, and then working out a min-max rectangle from that. - * It does not factor in if the children render or not, all are included. - * - * Some children are unable to return their bounds, such as Graphics objects, in which case - * they are skipped. - * - * Depending on the quantity of children in this Container it could be a really expensive call, - * so cache it and only poll it as needed. - * - * The values are stored and returned in a Rectangle object. - * - * @method Phaser.GameObjects.Container#getBounds - * @since 3.4.0 - * - * @param {Phaser.Geom.Rectangle} [output] - A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle} The values stored in the output object. - */ - getBounds: function (output) - { - if (output === undefined) { output = new Rectangle(); } - - output.setTo(this.x, this.y, 0, 0); - - if (this.list.length > 0) - { - var children = this.list; - var tempRect = new Rectangle(); - - for (var i = 0; i < children.length; i++) - { - var entry = children[i]; - - if (entry.getBounds) - { - entry.getBounds(tempRect); - - Union(tempRect, output, output); - } - } - } - - return output; - }, - - /** - * Internal add handler. - * - * @method Phaser.GameObjects.Container#addHandler - * @private - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just added to this Container. - */ - addHandler: function (gameObject) - { - gameObject.once('destroy', this.remove, this); - - if (this.exclusive) - { - this._displayList.remove(gameObject); - - if (gameObject.parentContainer) - { - gameObject.parentContainer.remove(gameObject); - } - - gameObject.parentContainer = this; - } - - // Game Objects automatically listen to the Scene shutdown event, but - // we don't need this if they're in a Container - this._sysEvents.off('shutdown', gameObject.destroy, gameObject); - }, - - /** - * Internal remove handler. - * - * @method Phaser.GameObjects.Container#removeHandler - * @private - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just removed from this Container. - */ - removeHandler: function (gameObject) - { - gameObject.off('destroy', this.remove); - - if (this.exclusive) - { - gameObject.parentContainer = null; - - this._sysEvents.once('shutdown', gameObject.destroy, gameObject); - } - }, - - /** - * Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties, - * and transforms it into the space of this Container, then returns it in the output object. - * - * @method Phaser.GameObjects.Container#pointToContainer - * @since 3.4.0 - * - * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} source - The Source Point to be transformed. - * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} [output] - A destination object to store the transformed point in. If none given a Vector2 will be created and returned. - * - * @return {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} The transformed point. - */ - pointToContainer: function (source, output) - { - if (output === undefined) { output = new Vector2(); } - - if (this.parentContainer) - { - return this.parentContainer.pointToContainer(source, output); - } - - var tempMatrix = this.tempTransformMatrix; - - // No need to loadIdentity because applyITRS overwrites every value anyway - tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY); - - tempMatrix.invert(); - - tempMatrix.transformPoint(source.x, source.y, output); - - return output; - }, - - /** - * Returns the world transform matrix as used for Bounds checks. - * The returned matrix is temporal and shouldn't be stored. - * - * @method Phaser.GameObjects.Container#getBoundsTransformMatrix - * @since 3.4.0 - * - * @return {Phaser.GameObjects.Components.TransformMatrix} The world transform matrix. - */ - getBoundsTransformMatrix: function () - { - return this.getWorldTransformMatrix(this.tempTransformMatrix); - }, - - /** - * Adds the given Game Object, or array of Game Objects, to this Container. - * - * Each Game Object must be unique within the Container. - * - * @method Phaser.GameObjects.Container#add - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - add: function (child) - { - ArrayUtils.Add(this.list, child, this.maxSize, this.addHandler, this); - - return this; - }, - - /** - * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. - * - * Existing Game Objects in the Container are shifted up. - * - * Each Game Object must be unique within the Container. - * - * @method Phaser.GameObjects.Container#addAt - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. - * @param {integer} [index=0] - The position to insert the Game Object/s at. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - addAt: function (child, index) - { - ArrayUtils.AddAt(this.list, child, index, this.maxSize, this.addHandler, this); - - return this; - }, - - /** - * Returns the Game Object at the given position in this Container. - * - * @method Phaser.GameObjects.Container#getAt - * @since 3.4.0 - * - * @param {integer} index - The position to get the Game Object from. - * - * @return {?Phaser.GameObjects.GameObject} The Game Object at the specified index, or `null` if none found. - */ - getAt: function (index) - { - return this.list[index]; - }, - - /** - * Returns the index of the given Game Object in this Container. - * - * @method Phaser.GameObjects.Container#getIndex - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to search for in this Container. - * - * @return {integer} The index of the Game Object in this Container, or -1 if not found. - */ - getIndex: function (child) - { - return this.list.indexOf(child); - }, - - /** - * Sort the contents of this Container so the items are in order based on the given property. - * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. - * - * @method Phaser.GameObjects.Container#sort - * @since 3.4.0 - * - * @param {string} property - The property to lexically sort by. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - sort: function (property) - { - if (property) - { - this._sortKey = property; - - ArrayUtils.StableSort.inplace(this.list, this.sortHandler); - } - - return this; - }, - - /** - * Internal sort handler method. - * - * @method Phaser.GameObjects.Container#sortHandler - * @private - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} childA - The first child to sort. - * @param {Phaser.GameObjects.GameObject} childB - The second child to sort. - * - * @return {integer} The sort results. - */ - sortHandler: function (childA, childB) - { - return childA[this._sortKey] - childB[this._sortKey]; - }, - - /** - * Searches for the first instance of a child with its `name` property matching the given argument. - * Should more than one child have the same name only the first is returned. - * - * @method Phaser.GameObjects.Container#getByName - * @since 3.4.0 - * - * @param {string} name - The name to search for. - * - * @return {?Phaser.GameObjects.GameObject} The first child with a matching name, or `null` if none were found. - */ - getByName: function (name) - { - return ArrayUtils.GetFirst(this.list, 'name', name); - }, - - /** - * Returns a random Game Object from this Container. - * - * @method Phaser.GameObjects.Container#getRandom - * @since 3.4.0 - * - * @param {integer} [startIndex=0] - An optional start index. - * @param {integer} [length] - An optional length, the total number of elements (from the startIndex) to choose from. - * - * @return {?Phaser.GameObjects.GameObject} A random child from the Container, or `null` if the Container is empty. - */ - getRandom: function (startIndex, length) - { - return ArrayUtils.GetRandom(this.list, startIndex, length); - }, - - /** - * Gets the first Game Object in this Container. - * - * You can also specify a property and value to search for, in which case it will return the first - * Game Object in this Container with a matching property and / or value. - * - * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. - * - * You can limit the search to the `startIndex` - `endIndex` range. - * - * @method Phaser.GameObjects.Container#getFirst - * @since 3.4.0 - * - * @param {string} [property] - The property to test on each Game Object in the Container. - * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * - * @return {?Phaser.GameObjects.GameObject} The first matching Game Object, or `null` if none was found. - */ - getFirst: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); - }, - - /** - * Returns all Game Objects in this Container. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('body')` would return only Game Objects that have a body property. - * - * You can also specify a value to compare the property to: - * - * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. - * - * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 Game Objects. - * - * @method Phaser.GameObjects.Container#getAll - * @since 3.4.0 - * - * @param {string} [property] - The property to test on each Game Object in the Container. - * @param {any} [value] - If property is set then the `property` must strictly equal this value to be included in the results. - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * - * @return {Phaser.GameObjects.GameObject[]} An array of matching Game Objects from this Container. - */ - getAll: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); - }, - - /** - * Returns the total number of Game Objects in this Container that have a property - * matching the given value. - * - * For example: `count('visible', true)` would count all the elements that have their visible property set. - * - * You can optionally limit the operation to the `startIndex` - `endIndex` range. - * - * @method Phaser.GameObjects.Container#count - * @since 3.4.0 - * - * @param {string} property - The property to check. - * @param {any} value - The value to check. - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * - * @return {integer} The total number of Game Objects in this Container with a property matching the given value. - */ - count: function (property, value, startIndex, endIndex) - { - return ArrayUtils.CountAllMatching(this.list, property, value, startIndex, endIndex); - }, - - /** - * Swaps the position of two Game Objects in this Container. - * Both Game Objects must belong to this Container. - * - * @method Phaser.GameObjects.Container#swap - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child1 - The first Game Object to swap. - * @param {Phaser.GameObjects.GameObject} child2 - The second Game Object to swap. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - swap: function (child1, child2) - { - ArrayUtils.Swap(this.list, child1, child2); - - return this; - }, - - /** - * Moves a Game Object to a new position within this Container. - * - * The Game Object must already be a child of this Container. - * - * The Game Object is removed from its old position and inserted into the new one. - * Therefore the Container size does not change. Other children will change position accordingly. - * - * @method Phaser.GameObjects.Container#moveTo - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to move. - * @param {integer} index - The new position of the Game Object in this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - moveTo: function (child, index) - { - ArrayUtils.MoveTo(this.list, child, index); - - return this; - }, - - /** - * Removes the given Game Object, or array of Game Objects, from this Container. - * - * The Game Objects must already be children of this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * - * @method Phaser.GameObjects.Container#remove - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to be removed from the Container. - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each child successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - remove: function (child, destroyChild) - { - var removed = ArrayUtils.Remove(this.list, child, this.removeHandler, this); - - if (destroyChild && removed) - { - if (!Array.isArray(removed)) - { - removed = [ removed ]; - } - - for (var i = 0; i < removed.length; i++) - { - removed[i].destroy(); - } - } - - return this; - }, - - /** - * Removes the Game Object at the given position in this Container. - * - * You can also optionally call `destroy` on the Game Object, if one is found. - * - * @method Phaser.GameObjects.Container#removeAt - * @since 3.4.0 - * - * @param {integer} index - The index of the Game Object to be removed. - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - removeAt: function (index, destroyChild) - { - var removed = ArrayUtils.RemoveAt(this.list, index, this.removeHandler, this); - - if (destroyChild && removed) - { - removed.destroy(); - } - - return this; - }, - - /** - * Removes the Game Objects between the given positions in this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * - * @method Phaser.GameObjects.Container#removeBetween - * @since 3.4.0 - * - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - removeBetween: function (startIndex, endIndex, destroyChild) - { - var removed = ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeHandler, this); - - if (destroyChild) - { - for (var i = 0; i < removed.length; i++) - { - removed[i].destroy(); - } - } - - return this; - }, - - /** - * Removes all Game Objects from this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * - * @method Phaser.GameObjects.Container#removeAll - * @since 3.4.0 - * - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - removeAll: function (destroyChild) - { - var removed = ArrayUtils.RemoveBetween(this.list, 0, this.list.length, this.removeHandler, this); - - if (destroyChild) - { - for (var i = 0; i < removed.length; i++) - { - removed[i].destroy(); - } - } - - return this; - }, - - /** - * Brings the given Game Object to the top of this Container. - * This will cause it to render on-top of any other objects in the Container. - * - * @method Phaser.GameObjects.Container#bringToTop - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to bring to the top of the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - bringToTop: function (child) - { - ArrayUtils.BringToTop(this.list, child); - - return this; - }, - - /** - * Sends the given Game Object to the bottom of this Container. - * This will cause it to render below any other objects in the Container. - * - * @method Phaser.GameObjects.Container#sendToBack - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to send to the bottom of the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - sendToBack: function (child) - { - ArrayUtils.SendToBack(this.list, child); - - return this; - }, - - /** - * Moves the given Game Object up one place in this Container, unless it's already at the top. - * - * @method Phaser.GameObjects.Container#moveUp - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - moveUp: function (child) - { - ArrayUtils.MoveUp(this.list, child); - - return this; - }, - - /** - * Moves the given Game Object down one place in this Container, unless it's already at the bottom. - * - * @method Phaser.GameObjects.Container#moveDown - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - moveDown: function (child) - { - ArrayUtils.MoveDown(this.list, child); - - return this; - }, - - /** - * Reverses the order of all Game Objects in this Container. - * - * @method Phaser.GameObjects.Container#reverse - * @since 3.4.0 - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - reverse: function () - { - this.list.reverse(); - - return this; - }, - - /** - * Shuffles the all Game Objects in this Container using the Fisher-Yates implementation. - * - * @method Phaser.GameObjects.Container#shuffle - * @since 3.4.0 - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - shuffle: function () - { - ArrayUtils.Shuffle(this.list); - - return this; - }, - - /** - * Replaces a Game Object in this Container with the new Game Object. - * The new Game Object cannot already be a child of this Container. - * - * @method Phaser.GameObjects.Container#replace - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} oldChild - The Game Object in this Container that will be replaced. - * @param {Phaser.GameObjects.GameObject} newChild - The Game Object to be added to this Container. - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - replace: function (oldChild, newChild, destroyChild) - { - var moved = ArrayUtils.Replace(this.list, oldChild, newChild); - - if (moved) - { - this.addHandler(newChild); - this.removeHandler(oldChild); - - if (destroyChild) - { - oldChild.destroy(); - } - } - - return this; - }, - - /** - * Returns `true` if the given Game Object is a direct child of this Container. - * - * This check does not scan nested Containers. - * - * @method Phaser.GameObjects.Container#exists - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to check for within this Container. - * - * @return {boolean} True if the Game Object is an immediate child of this Container, otherwise false. - */ - exists: function (child) - { - return (this.list.indexOf(child) > -1); - }, - - /** - * Sets the property to the given value on all Game Objects in this Container. - * - * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 Game Objects. - * - * @method Phaser.GameObjects.Container#setAll - * @since 3.4.0 - * - * @param {string} property - The property that must exist on the Game Object. - * @param {any} value - The value to get the property to. - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - setAll: function (property, value, startIndex, endIndex) - { - ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); - - return this; - }, - - /** - * @callback EachContainerCallback - * @generic I - [item] - * - * @param {*} item - [description] - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ - - /** - * Passes all Game Objects in this Container to the given callback. - * - * A copy of the Container is made before passing each entry to your callback. - * This protects against the callback itself modifying the Container. - * - * If you know for sure that the callback will not change the size of this Container - * then you can use the more performant `Container.iterate` method instead. - * - * @method Phaser.GameObjects.Container#each - * @since 3.4.0 - * - * @param {function} callback - The function to call. - * @param {object} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - each: function (callback, context) - { - var args = [ null ]; - var i; - var temp = this.list.slice(); - var len = temp.length; - - for (i = 2; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = 0; i < len; i++) - { - args[0] = temp[i]; - - callback.apply(context, args); - } - - return this; - }, - - /** - * Passes all Game Objects in this Container to the given callback. - * - * Only use this method when you absolutely know that the Container will not be modified during - * the iteration, i.e. by removing or adding to its contents. - * - * @method Phaser.GameObjects.Container#iterate - * @since 3.4.0 - * - * @param {function} callback - The function to call. - * @param {object} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - iterate: function (callback, context) - { - var args = [ null ]; - var i; - - for (i = 2; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = 0; i < this.list.length; i++) - { - args[0] = this.list[i]; - - callback.apply(context, args); - } - - return this; - }, - - /** - * The number of Game Objects inside this Container. - * - * @name Phaser.GameObjects.Container#length - * @type {integer} - * @readOnly - * @since 3.4.0 - */ - length: { - - get: function () - { - return this.list.length; - } - - }, - - /** - * Returns the first Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - * - * @name Phaser.GameObjects.Container#first - * @type {?Phaser.GameObjects.GameObject} - * @readOnly - * @since 3.4.0 - */ - first: { - - get: function () - { - this.position = 0; - - if (this.list.length > 0) - { - return this.list[0]; - } - else - { - return null; - } - } - - }, - - /** - * Returns the last Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - * - * @name Phaser.GameObjects.Container#last - * @type {?Phaser.GameObjects.GameObject} - * @readOnly - * @since 3.4.0 - */ - last: { - - get: function () - { - if (this.list.length > 0) - { - this.position = this.list.length - 1; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * Returns the next Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - * - * @name Phaser.GameObjects.Container#next - * @type {?Phaser.GameObjects.GameObject} - * @readOnly - * @since 3.4.0 - */ - next: { - - get: function () - { - if (this.position < this.list.length) - { - this.position++; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * Returns the previous Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - * - * @name Phaser.GameObjects.Container#previous - * @type {?Phaser.GameObjects.GameObject} - * @readOnly - * @since 3.4.0 - */ - previous: { - - get: function () - { - if (this.position > 0) - { - this.position--; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.Container#preDestroy - * @protected - * @since 3.9.0 - */ - preDestroy: function () - { - this.removeAll(!!this.exclusive); - - this.localTransform.destroy(); - this.tempTransformMatrix.destroy(); - - this.list = []; - this._displayList = null; - } - -}); - -module.exports = Container; - - -/***/ }), -/* 252 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlitterRender = __webpack_require__(910); -var Bob = __webpack_require__(907); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var Frame = __webpack_require__(128); -var GameObject = __webpack_require__(2); -var List = __webpack_require__(93); - -/** - * @callback Phaser.GameObjects.Blitter.CreateCallback - * - * @param {Phaser.GameObjects.Blitter.Bob} bob - The Bob that was created by the Blitter. - * @param {integer} index - The position of the Bob within the Blitter display list. - */ - -/** - * @classdesc - * A Blitter Game Object. - * - * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. - * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, - * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed - * during rendering. - * - * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this - * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows - * them their speed. - * - * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth - * investigating. They are especially useful for using as a base for your own special effects systems. - * - * @class Blitter - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} [x=0] - The x coordinate of this Game Object in world space. - * @param {number} [y=0] - The y coordinate of this Game Object in world space. - * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. - * @param {(string|integer)} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. - */ -var Blitter = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Transform, - Components.Visible, - BlitterRender - ], - - initialize: - - function Blitter (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Blitter'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.initPipeline('TextureTintPipeline'); - - /** - * The children of this Blitter. - * This List contains all of the Bob objects created by the Blitter. - * - * @name Phaser.GameObjects.Blitter#children - * @type {Phaser.Structs.List.} - * @since 3.0.0 - */ - this.children = new List(); - - /** - * A transient array that holds all of the Bobs that will be rendered this frame. - * The array is re-populated whenever the dirty flag is set. - * - * @name Phaser.GameObjects.Blitter#renderList - * @type {Phaser.GameObjects.Blitter.Bob[]} - * @default [] - * @private - * @since 3.0.0 - */ - this.renderList = []; - - /** - * Is the Blitter considered dirty? - * A 'dirty' Blitter has had its child count changed since the last frame. - * - * @name Phaser.GameObjects.Blitter#dirty - * @type {boolean} - * @since 3.0.0 - */ - this.dirty = false; - }, - - /** - * Creates a new Bob in this Blitter. - * - * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. - * A Bob can use any frame belonging to the texture bound to the Blitter. - * - * @method Phaser.GameObjects.Blitter#create - * @since 3.0.0 - * - * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - * @param {boolean} [visible=true] - Should the created Bob render or not? - * @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. - * - * @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object. - */ - create: function (x, y, frame, visible, index) - { - if (visible === undefined) { visible = true; } - if (index === undefined) { index = this.children.length; } - - if (frame === undefined) - { - frame = this.frame; - } - else if (!(frame instanceof Frame)) - { - frame = this.texture.get(frame); - } - - var bob = new Bob(this, x, y, frame, visible); - - this.children.addAt(bob, index, false); - - this.dirty = true; - - return bob; - }, - - /** - * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. - * - * @method Phaser.GameObjects.Blitter#createFromCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter.CreateCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. - * @param {integer} quantity - The quantity of Bob objects to create. - * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param {boolean} [visible=true] - Should the created Bob render or not? - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. - */ - createFromCallback: function (callback, quantity, frame, visible) - { - var bobs = this.createMultiple(quantity, frame, visible); - - for (var i = 0; i < bobs.length; i++) - { - var bob = bobs[i]; - - callback.call(this, bob, i); - } - - return bobs; - }, - - /** - * Creates multiple Bobs in one call. - * - * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. - * - * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first - * frame and 10 with the second. - * - * @method Phaser.GameObjects.Blitter#createMultiple - * @since 3.0.0 - * - * @param {integer} quantity - The quantity of Bob objects to create. - * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param {boolean} [visible=true] - Should the created Bob render or not? - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. - */ - createMultiple: function (quantity, frame, visible) - { - if (frame === undefined) { frame = this.frame.name; } - if (visible === undefined) { visible = true; } - - if (!Array.isArray(frame)) - { - frame = [ frame ]; - } - - var bobs = []; - var _this = this; - - frame.forEach(function (singleFrame) - { - for (var i = 0; i < quantity; i++) - { - bobs.push(_this.create(0, 0, singleFrame, visible)); - } - }); - - return bobs; - }, - - /** - * Checks if the given child can render or not, by checking its `visible` and `alpha` values. - * - * @method Phaser.GameObjects.Blitter#childCanRender - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter.Bob} child - The Bob to check for rendering. - * - * @return {boolean} Returns `true` if the given child can render, otherwise `false`. - */ - childCanRender: function (child) - { - return (child.visible && child.alpha > 0); - }, - - /** - * Returns an array of Bobs to be rendered. - * If the Blitter is dirty then a new list is generated and stored in `renderList`. - * - * @method Phaser.GameObjects.Blitter#getRenderList - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that will be rendered this frame. - */ - getRenderList: function () - { - if (this.dirty) - { - this.renderList = this.children.list.filter(this.childCanRender, this); - this.dirty = false; - } - - return this.renderList; - }, - - /** - * Removes all Bobs from the children List and clears the dirty flag. - * - * @method Phaser.GameObjects.Blitter#clear - * @since 3.0.0 - */ - clear: function () - { - this.children.removeAll(); - this.dirty = true; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.Blitter#preDestroy - * @protected - * @since 3.9.0 - */ - preDestroy: function () - { - this.children.destroy(); - - this.renderList = []; - } - -}); - -module.exports = Blitter; - - -/***/ }), -/* 253 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var GetBitmapTextSize = __webpack_require__(475); -var ParseFromAtlas = __webpack_require__(914); -var Render = __webpack_require__(913); - -/** - * The font data for an individual character of a Bitmap Font. - * - * Describes the character's position, size, offset and kerning. - * - * @typedef {object} BitmapFontCharacterData - * - * @property {number} x - The x position of the character. - * @property {number} y - The y position of the character. - * @property {number} width - The width of the character. - * @property {number} height - The height of the character. - * @property {number} centerX - The center x position of the character. - * @property {number} centerY - The center y position of the character. - * @property {number} xOffset - The x offset of the character. - * @property {number} yOffset - The y offset of the character. - * @property {object} data - Extra data for the character. - * @property {Object.} kerning - Kerning values, keyed by character code. - */ - -/** - * Bitmap Font data that can be used by a BitmapText Game Object. - * - * @typedef {object} BitmapFontData - * - * @property {string} font - The name of the font. - * @property {number} size - The size of the font. - * @property {number} lineHeight - The line height of the font. - * @property {boolean} retroFont - Whether this font is a retro font (monospace). - * @property {Object.} chars - The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more. - */ - -/** - * @typedef {object} JSONBitmapText - * @extends {JSONGameObject} - * - * @property {string} font - The name of the font. - * @property {string} text - The text that this Bitmap Text displays. - * @property {number} fontSize - The size of the font. - * @property {number} letterSpacing - Adds/Removes spacing between characters - */ - -/** - * @classdesc - * [description] - * - * @class BitmapText - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} x - The x coordinate of this Game Object in world space. - * @param {number} y - The y coordinate of this Game Object in world space. - * @param {string} font - The key of the font to use from the Bitmap Font cache. - * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @param {number} [size] - The font size of this Bitmap Text. - */ -var BitmapText = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function BitmapText (scene, x, y, font, text, size) - { - if (text === undefined) { text = ''; } - - GameObject.call(this, scene, 'BitmapText'); - - /** - * The key of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#font - * @type {string} - * @since 3.0.0 - */ - this.font = font; - - var entry = this.scene.sys.cache.bitmapFont.get(font); - - /** - * The data of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#fontData - * @type {BitmapFontData} - * @since 3.0.0 - */ - this.fontData = entry.data; - - /** - * The text that this Bitmap Text object displays. - * - * @name Phaser.GameObjects.BitmapText#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * The font size of this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#fontSize - * @type {number} - * @since 3.0.0 - */ - this.fontSize = size || this.fontData.size; - - /** - * Adds/Removes spacing between characters. - * - * Can be a negative or positive number. - * - * @name Phaser.GameObjects.BitmapText#letterSpacing - * @type {number} - * @since 3.4.0 - */ - this.letterSpacing = 0; - - this.setText(text); - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * An object that describes the size of this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#_bounds - * @type {BitmapTextSize} - * @private - * @since 3.0.0 - */ - this._bounds = this.getTextBounds(); - }, - - /** - * Set the font size of this Bitmap Text. - * - * @method Phaser.GameObjects.BitmapText#setFontSize - * @since 3.0.0 - * - * @param {number} size - The font size to set. - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setFontSize: function (size) - { - this.fontSize = size; - - return this; - }, - - /** - * Sets the letter spacing between each character of this Bitmap Text. - * Can be a positive value to increase the space, or negative to reduce it. - * Spacing is applied after the kerning values have been set. - * - * @method Phaser.GameObjects.BitmapText#setLetterSpacing - * @since 3.4.0 - * - * @param {number} [spacing=0] - The amount of horizontal space to add between each character. - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setLetterSpacing: function (spacing) - { - if (spacing === undefined) { spacing = 0; } - - this.letterSpacing = spacing; - - return this; - }, - - /** - * Set the content of this BitmapText. - * - * An array of strings will be converted multi-line text. - * - * @method Phaser.GameObjects.BitmapText#setText - * @since 3.0.0 - * - * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateDisplayOrigin(); - } - - return this; - }, - - /** - * Calculate the bounds of this Bitmap Text. - * - * An object is returned that contains the position, width and height of the Bitmap Text in local and global - * contexts. - * - * Local size is based on just the font size and a [0, 0] position. - * - * Global size takes into account the Game Object's scale and world position. - * - * @method Phaser.GameObjects.BitmapText#getTextBounds - * @since 3.0.0 - * - * @param {boolean} [round] - Whether to round the results to the nearest integer. - * - * @return {BitmapTextSize} An object that describes the size of this Bitmap Text. - */ - getTextBounds: function (round) - { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position - - this._bounds = GetBitmapTextSize(this, round); - - return this._bounds; - }, - - /** - * The width of this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#width - * @type {number} - * @readOnly - * @since 3.0.0 - */ - width: { - - get: function () - { - this.getTextBounds(false); - - return this._bounds.global.width; - } - - }, - - /** - * The height of this bitmap text. - * - * @name Phaser.GameObjects.BitmapText#height - * @type {number} - * @readOnly - * @since 3.0.0 - */ - height: { - - get: function () - { - this.getTextBounds(false); - - return this._bounds.global.height; - } - - }, - - /** - * Build a JSON representation of this Bitmap Text. - * - * @method Phaser.GameObjects.BitmapText#toJSON - * @since 3.0.0 - * - * @return {JSONBitmapText} The JSON representation of this Bitmap Text. - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra data is added here - - var data = { - font: this.font, - text: this.text, - fontSize: this.fontSize, - letterSpacing: this.letterSpacing - }; - - out.data = data; - - return out; - } - -}); - -BitmapText.ParseFromAtlas = ParseFromAtlas; - -module.exports = BitmapText; - - -/***/ }), -/* 254 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); -var Shuffle = __webpack_require__(95); - -var BuildChunk = function (a, b, qty) -{ - var out = []; - - for (var aIndex = 0; aIndex < a.length; aIndex++) - { - for (var bIndex = 0; bIndex < b.length; bIndex++) - { - for (var i = 0; i < qty; i++) - { - out.push({ a: a[aIndex], b: b[bIndex] }); - } - } - } - - return out; -}; - -// options = repeat, random, randomB, yoyo, max, qty - -// Range ([a,b,c], [1,2,3]) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2,3], qty = 3) = -// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 - -// Range ([a,b,c], [1,2,3], repeat x1) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = -// Maybe if max is set then repeat goes to -1 automatically? -// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) - -// Range ([a], [1,2,3,4,5], random = true) = -// a4, a1, a5, a2, a3 - -// Range ([a, b], [1,2,3], random = true) = -// b3, a2, a1, b1, a3, b2 - -// Range ([a, b, c], [1,2,3], randomB = true) = -// a3, a1, a2, b2, b3, b1, c1, c3, c2 - -// Range ([a], [1,2,3,4,5], yoyo = true) = -// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 - -// Range ([a, b], [1,2,3], yoyo = true) = -// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 - -/** - * [description] - * - * @function Phaser.Utils.Array.Range - * @since 3.0.0 - * - * @param {array} a - [description] - * @param {array} b - [description] - * @param {object} options - [description] - * - * @return {array} [description] - */ -var Range = function (a, b, options) -{ - var max = GetValue(options, 'max', 0); - var qty = GetValue(options, 'qty', 1); - var random = GetValue(options, 'random', false); - var randomB = GetValue(options, 'randomB', false); - var repeat = GetValue(options, 'repeat', 0); - var yoyo = GetValue(options, 'yoyo', false); - - var out = []; - - if (randomB) - { - Shuffle(b); - } - - // Endless repeat, so limit by max - if (repeat === -1) - { - if (max === 0) - { - repeat = 0; - } - else - { - // Work out how many repeats we need - var total = (a.length * b.length) * qty; - - if (yoyo) - { - total *= 2; - } - - repeat = Math.ceil(max / total); - } - } - - for (var i = 0; i <= repeat; i++) - { - var chunk = BuildChunk(a, b, qty); - - if (random) - { - Shuffle(chunk); - } - - out = out.concat(chunk); - - if (yoyo) - { - chunk.reverse(); - - out = out.concat(chunk); - } - } - - if (max) - { - out.splice(max); - } - - return out; -}; - -module.exports = Range; - - -/***/ }), -/* 255 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Round a given number so it is further away from zero. That is, positive numbers are rounded up, and negative numbers are rounded down. - * - * @function Phaser.Math.RoundAwayFromZero - * @since 3.0.0 - * - * @param {number} value - The number to round. - * - * @return {number} The rounded number, rounded away from zero. - */ -var RoundAwayFromZero = function (value) -{ - // "Opposite" of truncate. - return (value > 0) ? Math.ceil(value) : Math.floor(value); -}; - -module.exports = RoundAwayFromZero; - - -/***/ }), -/* 256 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Capitalizes the first letter of a string if there is one. - * @example - * UppercaseFirst('abc'); - * // returns 'Abc' - * @example - * UppercaseFirst('the happy family'); - * // returns 'The happy family' - * @example - * UppercaseFirst(''); - * // returns '' - * - * @function Phaser.Utils.String.UppercaseFirst - * @since 3.0.0 - * - * @param {string} str - The string to capitalize. - * - * @return {string} A new string, same as the first, but with the first letter capitalized. - */ -var UppercaseFirst = function (str) -{ - return str && str[0].toUpperCase() + str.slice(1); -}; - -module.exports = UppercaseFirst; - - -/***/ }), -/* 257 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Vector2 = __webpack_require__(6); - -/** - * Takes the `x` and `y` coordinates and transforms them into the same space as - * defined by the position, rotation and scale values. - * - * @function Phaser.Math.TransformXY - * @since 3.0.0 - * - * @param {number} x - The x coordinate to be transformed. - * @param {number} y - The y coordinate to be transformed. - * @param {number} positionX - Horizontal position of the transform point. - * @param {number} positionY - Vertical position of the transform point. - * @param {number} rotation - Rotation of the transform point, in radians. - * @param {number} scaleX - Horizontal scale of the transform point. - * @param {number} scaleY - Vertical scale of the transform point. - * @param {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} [output] - The output vector, point or object for the translated coordinates. - * - * @return {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} The translated point. - */ -var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) -{ - if (output === undefined) { output = new Vector2(); } - - // ITRS - - var sr = Math.sin(-rotation); - var cr = Math.cos(-rotation); - - var a = cr * scaleX; - var b = -sr * scaleX; - var c = sr * scaleY; - var d = cr * scaleY; - - // Invert - - var n = a * d - b * c; - - var m0 = d / n; - var m1 = -b / n; - var m2 = -c / n; - var m3 = a / n; - var m4 = (c * positionY - d * positionX) / n; - var m5 = -(a * positionY - b * positionX) / n; - - // Transform - - output.x = x * m0 + y * m2 + m4; - output.y = x * m1 + y * m3 + m5; - - return output; -}; - -module.exports = TransformXY; - - -/***/ }), -/* 258 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// 2.1.1 (Mar 17, 2016) - -/* -ISC License - -Copyright (c) 2016, Mapbox - -Permission to use, copy, modify, and/or distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright notice -and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - */ - - - -module.exports = earcut; - -/* -vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. -holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). -dimensions is the number of coordinates per vertice in the input array (2 by default). -Each group of three vertice indices in the resulting array forms a triangle. - */ - -function earcut(data, holeIndices, dim) { - - dim = dim || 2; - - var hasHoles = holeIndices && holeIndices.length, - outerLen = hasHoles ? holeIndices[0] * dim : data.length, - outerNode = linkedList(data, 0, outerLen, dim, true), - triangles = []; - - if (!outerNode) return triangles; - - var minX, minY, maxX, maxY, x, y, size; - - if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); - - // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox - if (data.length > 80 * dim) { - minX = maxX = data[0]; - minY = maxY = data[1]; - - for (var i = dim; i < outerLen; i += dim) { - x = data[i]; - y = data[i + 1]; - if (x < minX) minX = x; - if (y < minY) minY = y; - if (x > maxX) maxX = x; - if (y > maxY) maxY = y; - } - - // minX, minY and size are later used to transform coords into integers for z-order calculation - size = Math.max(maxX - minX, maxY - minY); - } - - earcutLinked(outerNode, triangles, dim, minX, minY, size); - - return triangles; -} - -// create a circular doubly linked list from polygon points in the specified winding order -function linkedList(data, start, end, dim, clockwise) { - var i, last; - - if (clockwise === (signedArea(data, start, end, dim) > 0)) { - for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); - } else { - for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); - } - - if (last && equals(last, last.next)) { - removeNode(last); - last = last.next; - } - - return last; -} - -// eliminate colinear or duplicate points -function filterPoints(start, end) { - if (!start) return start; - if (!end) end = start; - - var p = start, - again; - do { - again = false; - - if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { - removeNode(p); - p = end = p.prev; - if (p === p.next) return null; - again = true; - - } else { - p = p.next; - } - } while (again || p !== end); - - return end; -} - -// main ear slicing loop which triangulates a polygon (given as a linked list) -function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { - if (!ear) return; - - // interlink polygon nodes in z-order - if (!pass && size) indexCurve(ear, minX, minY, size); - - var stop = ear, - prev, next; - - // iterate through ears, slicing them one by one - while (ear.prev !== ear.next) { - prev = ear.prev; - next = ear.next; - - if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { - // cut off the triangle - triangles.push(prev.i / dim); - triangles.push(ear.i / dim); - triangles.push(next.i / dim); - - removeNode(ear); - - // skipping the next vertice leads to less sliver triangles - ear = next.next; - stop = next.next; - - continue; - } - - ear = next; - - // if we looped through the whole remaining polygon and can't find any more ears - if (ear === stop) { - // try filtering points and slicing again - if (!pass) { - earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); - - // if this didn't work, try curing all small self-intersections locally - } else if (pass === 1) { - ear = cureLocalIntersections(ear, triangles, dim); - earcutLinked(ear, triangles, dim, minX, minY, size, 2); - - // as a last resort, try splitting the remaining polygon into two - } else if (pass === 2) { - splitEarcut(ear, triangles, dim, minX, minY, size); - } - - break; - } - } -} - -// check whether a polygon node forms a valid ear with adjacent nodes -function isEar(ear) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // now make sure we don't have other points inside the potential ear - var p = ear.next.next; - - while (p !== ear.prev) { - if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.next; - } - - return true; -} - -function isEarHashed(ear, minX, minY, size) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // triangle bbox; min & max are calculated like this for speed - var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), - minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), - maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), - maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); - - // z-order range for the current triangle bbox; - var minZ = zOrder(minTX, minTY, minX, minY, size), - maxZ = zOrder(maxTX, maxTY, minX, minY, size); - - // first look for points inside the triangle in increasing z-order - var p = ear.nextZ; - - while (p && p.z <= maxZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.nextZ; - } - - // then look for points in decreasing z-order - p = ear.prevZ; - - while (p && p.z >= minZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.prevZ; - } - - return true; -} - -// go through all polygon nodes and cure small local self-intersections -function cureLocalIntersections(start, triangles, dim) { - var p = start; - do { - var a = p.prev, - b = p.next.next; - - if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { - - triangles.push(a.i / dim); - triangles.push(p.i / dim); - triangles.push(b.i / dim); - - // remove two nodes involved - removeNode(p); - removeNode(p.next); - - p = start = b; - } - p = p.next; - } while (p !== start); - - return p; -} - -// try splitting polygon into two and triangulate them independently -function splitEarcut(start, triangles, dim, minX, minY, size) { - // look for a valid diagonal that divides the polygon into two - var a = start; - do { - var b = a.next.next; - while (b !== a.prev) { - if (a.i !== b.i && isValidDiagonal(a, b)) { - // split the polygon in two by the diagonal - var c = splitPolygon(a, b); - - // filter colinear points around the cuts - a = filterPoints(a, a.next); - c = filterPoints(c, c.next); - - // run earcut on each half - earcutLinked(a, triangles, dim, minX, minY, size); - earcutLinked(c, triangles, dim, minX, minY, size); - return; - } - b = b.next; - } - a = a.next; - } while (a !== start); -} - -// link every hole into the outer loop, producing a single-ring polygon without holes -function eliminateHoles(data, holeIndices, outerNode, dim) { - var queue = [], - i, len, start, end, list; - - for (i = 0, len = holeIndices.length; i < len; i++) { - start = holeIndices[i] * dim; - end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - list = linkedList(data, start, end, dim, false); - if (list === list.next) list.steiner = true; - queue.push(getLeftmost(list)); - } - - queue.sort(compareX); - - // process holes from left to right - for (i = 0; i < queue.length; i++) { - eliminateHole(queue[i], outerNode); - outerNode = filterPoints(outerNode, outerNode.next); - } - - return outerNode; -} - -function compareX(a, b) { - return a.x - b.x; -} - -// find a bridge between vertices that connects hole with an outer ring and and link it -function eliminateHole(hole, outerNode) { - outerNode = findHoleBridge(hole, outerNode); - if (outerNode) { - var b = splitPolygon(outerNode, hole); - filterPoints(b, b.next); - } -} - -// David Eberly's algorithm for finding a bridge between hole and outer polygon -function findHoleBridge(hole, outerNode) { - var p = outerNode, - hx = hole.x, - hy = hole.y, - qx = -Infinity, - m; - - // find a segment intersected by a ray from the hole's leftmost point to the left; - // segment's endpoint with lesser x will be potential connection point - do { - if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { - var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); - if (x <= hx && x > qx) { - qx = x; - if (x === hx) { - if (hy === p.y) return p; - if (hy === p.next.y) return p.next; - } - m = p.x < p.next.x ? p : p.next; - } - } - p = p.next; - } while (p !== outerNode); - - if (!m) return null; - - if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint - - // look for points inside the triangle of hole point, segment intersection and endpoint; - // if there are no points found, we have a valid connection; - // otherwise choose the point of the minimum angle with the ray as connection point - - var stop = m, - mx = m.x, - my = m.y, - tanMin = Infinity, - tan; - - p = m.next; - - while (p !== stop) { - if (hx >= p.x && p.x >= mx && hx !== p.x && - pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { - - tan = Math.abs(hy - p.y) / (hx - p.x); // tangential - - if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { - m = p; - tanMin = tan; - } - } - - p = p.next; - } - - return m; -} - -// interlink polygon nodes in z-order -function indexCurve(start, minX, minY, size) { - var p = start; - do { - if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); - p.prevZ = p.prev; - p.nextZ = p.next; - p = p.next; - } while (p !== start); - - p.prevZ.nextZ = null; - p.prevZ = null; - - sortLinked(p); -} - -// Simon Tatham's linked list merge sort algorithm -// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html -function sortLinked(list) { - var i, p, q, e, tail, numMerges, pSize, qSize, - inSize = 1; - - do { - p = list; - list = null; - tail = null; - numMerges = 0; - - while (p) { - numMerges++; - q = p; - pSize = 0; - for (i = 0; i < inSize; i++) { - pSize++; - q = q.nextZ; - if (!q) break; - } - qSize = inSize; - - while (pSize > 0 || (qSize > 0 && q)) { - - if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { - e = p; - p = p.nextZ; - pSize--; - } else { - e = q; - q = q.nextZ; - qSize--; - } - - if (tail) tail.nextZ = e; - else list = e; - - e.prevZ = tail; - tail = e; - } - - p = q; - } - - tail.nextZ = null; - inSize *= 2; - - } while (numMerges > 1); - - return list; -} - -// z-order of a point given coords and size of the data bounding box -function zOrder(x, y, minX, minY, size) { - // coords are transformed into non-negative 15-bit integer range - x = 32767 * (x - minX) / size; - y = 32767 * (y - minY) / size; - - x = (x | (x << 8)) & 0x00FF00FF; - x = (x | (x << 4)) & 0x0F0F0F0F; - x = (x | (x << 2)) & 0x33333333; - x = (x | (x << 1)) & 0x55555555; - - y = (y | (y << 8)) & 0x00FF00FF; - y = (y | (y << 4)) & 0x0F0F0F0F; - y = (y | (y << 2)) & 0x33333333; - y = (y | (y << 1)) & 0x55555555; - - return x | (y << 1); -} - -// find the leftmost node of a polygon ring -function getLeftmost(start) { - var p = start, - leftmost = start; - do { - if (p.x < leftmost.x) leftmost = p; - p = p.next; - } while (p !== start); - - return leftmost; -} - -// check if a point lies within a convex triangle -function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { - return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && - (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && - (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; -} - -// check if a diagonal between two polygon nodes is valid (lies in polygon interior) -function isValidDiagonal(a, b) { - return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && - locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); -} - -// signed area of a triangle -function area(p, q, r) { - return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); -} - -// check if two points are equal -function equals(p1, p2) { - return p1.x === p2.x && p1.y === p2.y; -} - -// check if two segments intersect -function intersects(p1, q1, p2, q2) { - if ((equals(p1, q1) && equals(p2, q2)) || - (equals(p1, q2) && equals(p2, q1))) return true; - return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && - area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; -} - -// check if a polygon diagonal intersects any polygon segments -function intersectsPolygon(a, b) { - var p = a; - do { - if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && - intersects(p, p.next, a, b)) return true; - p = p.next; - } while (p !== a); - - return false; -} - -// check if a polygon diagonal is locally inside the polygon -function locallyInside(a, b) { - return area(a.prev, a, a.next) < 0 ? - area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : - area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; -} - -// check if the middle point of a polygon diagonal is inside the polygon -function middleInside(a, b) { - var p = a, - inside = false, - px = (a.x + b.x) / 2, - py = (a.y + b.y) / 2; - do { - if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && - (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) - inside = !inside; - p = p.next; - } while (p !== a); - - return inside; -} - -// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; -// if one belongs to the outer ring and another to a hole, it merges it into a single ring -function splitPolygon(a, b) { - var a2 = new Node(a.i, a.x, a.y), - b2 = new Node(b.i, b.x, b.y), - an = a.next, - bp = b.prev; - - a.next = b; - b.prev = a; - - a2.next = an; - an.prev = a2; - - b2.next = a2; - a2.prev = b2; - - bp.next = b2; - b2.prev = bp; - - return b2; -} - -// create a node and optionally link it with previous one (in a circular doubly linked list) -function insertNode(i, x, y, last) { - var p = new Node(i, x, y); - - if (!last) { - p.prev = p; - p.next = p; - - } else { - p.next = last.next; - p.prev = last; - last.next.prev = p; - last.next = p; - } - return p; -} - -function removeNode(p) { - p.next.prev = p.prev; - p.prev.next = p.next; - - if (p.prevZ) p.prevZ.nextZ = p.nextZ; - if (p.nextZ) p.nextZ.prevZ = p.prevZ; -} - -function Node(i, x, y) { - // vertice index in coordinates array - this.i = i; - - // vertex coordinates - this.x = x; - this.y = y; - - // previous and next vertice nodes in a polygon ring - this.prev = null; - this.next = null; - - // z-order curve value - this.z = null; - - // previous and next nodes in z-order - this.prevZ = null; - this.nextZ = null; - - // indicates whether this is a steiner point - this.steiner = false; -} - -// return a percentage difference between the polygon area and its triangulation area; -// used to verify correctness of triangulation -earcut.deviation = function (data, holeIndices, dim, triangles) { - var hasHoles = holeIndices && holeIndices.length; - var outerLen = hasHoles ? holeIndices[0] * dim : data.length; - - var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); - if (hasHoles) { - for (var i = 0, len = holeIndices.length; i < len; i++) { - var start = holeIndices[i] * dim; - var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - polygonArea -= Math.abs(signedArea(data, start, end, dim)); - } - } - - var trianglesArea = 0; - for (i = 0; i < triangles.length; i += 3) { - var a = triangles[i] * dim; - var b = triangles[i + 1] * dim; - var c = triangles[i + 2] * dim; - trianglesArea += Math.abs( - (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - - (data[a] - data[b]) * (data[c + 1] - data[a + 1])); - } - - return polygonArea === 0 && trianglesArea === 0 ? 0 : - Math.abs((trianglesArea - polygonArea) / polygonArea); -}; - -function signedArea(data, start, end, dim) { - var sum = 0; - for (var i = start, j = end - dim; i < end; i += dim) { - sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); - j = i; - } - return sum; -} - -// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts -earcut.flatten = function (data) { - var dim = data[0][0].length, - result = {vertices: [], holes: [], dimensions: dim}, - holeIndex = 0; - - for (var i = 0; i < data.length; i++) { - for (var j = 0; j < data[i].length; j++) { - for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); - } - if (i > 0) { - holeIndex += data[i - 1].length; - result.holes.push(holeIndex); - } - } - return result; -}; - -/***/ }), -/* 259 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Commands = __webpack_require__(119); -var Earcut = __webpack_require__(258); -var ModelViewProjection = __webpack_require__(202); -var ShaderSourceFS = __webpack_require__(529); -var ShaderSourceVS = __webpack_require__(528); -var Utils = __webpack_require__(27); -var WebGLPipeline = __webpack_require__(84); - -var Point = function (x, y, width, rgb, alpha) -{ - this.x = x; - this.y = y; - this.width = width; - this.rgb = rgb; - this.alpha = alpha; -}; - -var Path = function (x, y, width, rgb, alpha) -{ - this.points = []; - this.pointsLength = 1; - this.points[0] = new Point(x, y, width, rgb, alpha); -}; - -var currentMatrix = new Float32Array([ 1, 0, 0, 1, 0, 0 ]); -var matrixStack = new Float32Array(6 * 1000); -var matrixStackLength = 0; -var pathArray = []; - -/** - * @classdesc - * The FlatTintPipeline is used for rendering flat colored shapes. - * Mostly used by the Graphics game object. - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class FlatTintPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. - */ -var FlatTintPipeline = new Class({ - - Extends: WebGLPipeline, - - Mixins: [ - ModelViewProjection - ], - - initialize: - - function FlatTintPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapcity ? config.vertexCapacity : 12000), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2 + - Uint8Array.BYTES_PER_ELEMENT * 4), - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - }, - { - name: 'inTint', - size: 4, - type: config.renderer.gl.UNSIGNED_BYTE, - normalized: true, - offset: Float32Array.BYTES_PER_ELEMENT * 2 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#vertexViewU32 - * @type {Uint32Array} - * @since 3.0.0 - */ - this.vertexViewU32 = new Uint32Array(this.vertexData); - - /** - * Used internally to draw triangles - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#tempTriangle - * @type {array} - * @since 3.0.0 - */ - this.tempTriangle = [ - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0} - ]; - - /** - * Used internally by for triangulating a polyong - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#polygonCache - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.polygonCache = []; - - this.mvpInit(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - this.mvpUpdate(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); - - return this; - }, - - /** - * Pushes a rectangle into the vertex batch - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillRect - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x - Horiztonal top left coordinate of the rectangle - * @param {float} y - Vertical top left coordinate of the rectangle - * @param {float} width - Width of the rectangle - * @param {float} height - Height of the rectangle - * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillRect: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x, y, width, height, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = this.vertexCount * this.vertexComponentCount; - var xw = x + width; - var yh = y + height; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tx0 = x * a + y * c + e; - var ty0 = x * b + y * d + f; - var tx1 = x * a + yh * c + e; - var ty1 = x * b + yh * d + f; - var tx2 = xw * a + yh * c + e; - var ty2 = xw * b + yh * d + f; - var tx3 = xw * a + y * c + e; - var ty3 = xw * b + y * d + f; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - vertexViewF32[vertexOffset + 9] = tx0; - vertexViewF32[vertexOffset + 10] = ty0; - vertexViewU32[vertexOffset + 11] = tint; - vertexViewF32[vertexOffset + 12] = tx2; - vertexViewF32[vertexOffset + 13] = ty2; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx3; - vertexViewF32[vertexOffset + 16] = ty3; - vertexViewU32[vertexOffset + 17] = tint; - - this.vertexCount += 6; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillTriangle - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - Point 0 x coordinate - * @param {float} y0 - Point 0 y coordinate - * @param {float} x1 - Point 1 x coordinate - * @param {float} y1 - Point 1 y coordinate - * @param {float} x2 - Point 2 x coordinate - * @param {float} y2 - Point 2 y coordinate - * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 3 > this.vertexCapacity) - { - this.flush(); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = this.vertexCount * this.vertexComponentCount; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tx0 = x0 * a + y0 * c + e; - var ty0 = x0 * b + y0 * d + f; - var tx1 = x1 * a + y1 * c + e; - var ty1 = x1 * b + y1 * d + f; - var tx2 = x2 * a + y2 * c + e; - var ty2 = x2 * b + y2 * d + f; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - - this.vertexCount += 3; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokeTriangle - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - [description] - * @param {float} y0 - [description] - * @param {float} x1 - [description] - * @param {float} y1 - [description] - * @param {float} x2 - [description] - * @param {float} y2 - [description] - * @param {float} lineWidth - Size of the line as a float value - * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchStrokeTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, currentMatrix) - { - var tempTriangle = this.tempTriangle; - - tempTriangle[0].x = x0; - tempTriangle[0].y = y0; - tempTriangle[0].width = lineWidth; - tempTriangle[0].rgb = lineColor; - tempTriangle[0].alpha = lineAlpha; - tempTriangle[1].x = x1; - tempTriangle[1].y = y1; - tempTriangle[1].width = lineWidth; - tempTriangle[1].rgb = lineColor; - tempTriangle[1].alpha = lineAlpha; - tempTriangle[2].x = x2; - tempTriangle[2].y = y2; - tempTriangle[2].width = lineWidth; - tempTriangle[2].rgb = lineColor; - tempTriangle[2].alpha = lineAlpha; - tempTriangle[3].x = x0; - tempTriangle[3].y = y0; - tempTriangle[3].width = lineWidth; - tempTriangle[3].rgb = lineColor; - tempTriangle[3].alpha = lineAlpha; - - this.batchStrokePath( - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - tempTriangle, lineWidth, lineColor, lineAlpha, - a, b, c, d, e, f, - false, - currentMatrix - ); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillPath - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} path - Collection of points that represent the path - * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillPath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - var length = path.length; - var polygonCache = this.polygonCache; - var polygonIndexArray; - var point; - var v0, v1, v2; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = 0; - var x0, y0, x1, y1, x2, y2; - var tx0, ty0, tx1, ty1, tx2, ty2; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - for (var pathIndex = 0; pathIndex < length; ++pathIndex) - { - point = path[pathIndex]; - polygonCache.push(point.x, point.y); - } - - polygonIndexArray = Earcut(polygonCache); - length = polygonIndexArray.length; - - for (var index = 0; index < length; index += 3) - { - v0 = polygonIndexArray[index + 0] * 2; - v1 = polygonIndexArray[index + 1] * 2; - v2 = polygonIndexArray[index + 2] * 2; - - if (this.vertexCount + 3 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - x0 = polygonCache[v0 + 0]; - y0 = polygonCache[v0 + 1]; - x1 = polygonCache[v1 + 0]; - y1 = polygonCache[v1 + 1]; - x2 = polygonCache[v2 + 0]; - y2 = polygonCache[v2 + 1]; - - tx0 = x0 * a + y0 * c + e; - ty0 = x0 * b + y0 * d + f; - tx1 = x1 * a + y1 * c + e; - ty1 = x1 * b + y1 * d + f; - tx2 = x2 * a + y2 * c + e; - ty2 = x2 * b + y2 * d + f; - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - - this.vertexCount += 3; - } - - polygonCache.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokePath - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {array} path - [description] - * @param {float} lineWidth - [description] - * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component - * @param {boolean} isLastPath - Indicates if the path should be closed - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchStrokePath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, isLastPath, currentMatrix) - { - this.renderer.setPipeline(this); - - var point0, point1; - var pathLength = path.length; - var polylines = this.polygonCache; - var last, curr; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset; - var line; - var getTint = Utils.getTintAppendFloatAlphaAndSwap; - - for (var pathIndex = 0; pathIndex + 1 < pathLength; pathIndex += 1) - { - point0 = path[pathIndex]; - point1 = path[pathIndex + 1]; - - line = this.batchLine( - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - point0.x, point0.y, - point1.x, point1.y, - point0.width / 2, point1.width / 2, - point0.rgb, point1.rgb, lineAlpha, - a, b, c, d, e, f, - currentMatrix - ); - - polylines.push(line); - } - - /* Render joints */ - for (var index = 1, polylinesLength = polylines.length; index < polylinesLength; ++index) - { - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - last = polylines[index - 1] || polylines[polylinesLength - 1]; - curr = polylines[index]; - vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = last[3 * 2 + 0]; - vertexViewF32[vertexOffset + 1] = last[3 * 2 + 1]; - vertexViewU32[vertexOffset + 2] = getTint(last[3 * 2 + 2], lineAlpha); - vertexViewF32[vertexOffset + 3] = last[3 * 0 + 0]; - vertexViewF32[vertexOffset + 4] = last[3 * 0 + 1]; - vertexViewU32[vertexOffset + 5] = getTint(last[3 * 0 + 2], lineAlpha); - vertexViewF32[vertexOffset + 6] = curr[3 * 3 + 0]; - vertexViewF32[vertexOffset + 7] = curr[3 * 3 + 1]; - vertexViewU32[vertexOffset + 8] = getTint(curr[3 * 3 + 2], lineAlpha); - vertexViewF32[vertexOffset + 9] = last[3 * 0 + 0]; - vertexViewF32[vertexOffset + 10] = last[3 * 0 + 1]; - vertexViewU32[vertexOffset + 11] = getTint(last[3 * 0 + 2], lineAlpha); - vertexViewF32[vertexOffset + 12] = last[3 * 2 + 0]; - vertexViewF32[vertexOffset + 13] = last[3 * 2 + 1]; - vertexViewU32[vertexOffset + 14] = getTint(last[3 * 2 + 2], lineAlpha); - vertexViewF32[vertexOffset + 15] = curr[3 * 1 + 0]; - vertexViewF32[vertexOffset + 16] = curr[3 * 1 + 1]; - vertexViewU32[vertexOffset + 17] = getTint(curr[3 * 1 + 2], lineAlpha); - - this.vertexCount += 6; - } - - polylines.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchLine - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} ax - X coordinate to the start of the line - * @param {float} ay - Y coordinate to the start of the line - * @param {float} bx - X coordinate to the end of the line - * @param {float} by - Y coordinate to the end of the line - * @param {float} aLineWidth - Width of the start of the line - * @param {float} bLineWidth - Width of the end of the line - * @param {integer} aLineColor - RGB color packed as a uint - * @param {integer} bLineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchLine: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, ax, ay, bx, by, aLineWidth, bLineWidth, aLineColor, bLineColor, lineAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var dx = bx - ax; - var dy = by - ay; - var len = Math.sqrt(dx * dx + dy * dy); - var al0 = aLineWidth * (by - ay) / len; - var al1 = aLineWidth * (ax - bx) / len; - var bl0 = bLineWidth * (by - ay) / len; - var bl1 = bLineWidth * (ax - bx) / len; - var lx0 = bx - bl0; - var ly0 = by - bl1; - var lx1 = ax - al0; - var ly1 = ay - al1; - var lx2 = bx + bl0; - var ly2 = by + bl1; - var lx3 = ax + al0; - var ly3 = ay + al1; - var x0 = lx0 * a + ly0 * c + e; - var y0 = lx0 * b + ly0 * d + f; - var x1 = lx1 * a + ly1 * c + e; - var y1 = lx1 * b + ly1 * d + f; - var x2 = lx2 * a + ly2 * c + e; - var y2 = lx2 * b + ly2 * d + f; - var x3 = lx3 * a + ly3 * c + e; - var y3 = lx3 * b + ly3 * d + f; - var getTint = Utils.getTintAppendFloatAlphaAndSwap; - var aTint = getTint(aLineColor, lineAlpha); - var bTint = getTint(bLineColor, lineAlpha); - var vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = x0; - vertexViewF32[vertexOffset + 1] = y0; - vertexViewU32[vertexOffset + 2] = bTint; - vertexViewF32[vertexOffset + 3] = x1; - vertexViewF32[vertexOffset + 4] = y1; - vertexViewU32[vertexOffset + 5] = aTint; - vertexViewF32[vertexOffset + 6] = x2; - vertexViewF32[vertexOffset + 7] = y2; - vertexViewU32[vertexOffset + 8] = bTint; - vertexViewF32[vertexOffset + 9] = x1; - vertexViewF32[vertexOffset + 10] = y1; - vertexViewU32[vertexOffset + 11] = aTint; - vertexViewF32[vertexOffset + 12] = x3; - vertexViewF32[vertexOffset + 13] = y3; - vertexViewU32[vertexOffset + 14] = aTint; - vertexViewF32[vertexOffset + 15] = x2; - vertexViewF32[vertexOffset + 16] = y2; - vertexViewU32[vertexOffset + 17] = bTint; - - this.vertexCount += 6; - - return [ - x0, y0, bLineColor, - x1, y1, aLineColor, - x2, y2, bLineColor, - x3, y3, aLineColor - ]; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchGraphics - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchGraphics: function (graphics, camera, parentTransformMatrix) - { - if (graphics.commandBuffer.length <= 0) { return; } - - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var cameraScrollX = camera.scrollX * graphics.scrollFactorX; - var cameraScrollY = camera.scrollY * graphics.scrollFactorY; - var srcX = graphics.x; - var srcY = graphics.y; - var srcScaleX = graphics.scaleX; - var srcScaleY = graphics.scaleY; - var srcRotation = graphics.rotation; - var commands = graphics.commandBuffer; - var alpha = graphics.alpha; - var lineAlpha = 1.0; - var fillAlpha = 1.0; - var lineColor = 0; - var fillColor = 0; - var lineWidth = 1.0; - var cameraMatrix = camera.matrix.matrix; - var lastPath = null; - var iteration = 0; - var iterStep = 0.01; - var tx = 0; - var ty = 0; - var ta = 0; - var x = 0; - var y = 0; - var radius = 0; - var startAngle = 0; - var endAngle = 0; - var anticlockwise = 0; - var path = null; - var sin = Math.sin; - var cos = Math.cos; - var PI2 = Math.PI * 2; - var sr = sin(srcRotation); - var cr = cos(srcRotation); - var sra = cr * srcScaleX; - var srb = sr * srcScaleX; - var src = -sr * srcScaleY; - var srd = cr * srcScaleY; - var sre = srcX; - var srf = srcY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var pathArrayIndex; - var pathArrayLength; - - pathArray.length = 0; - - for (var cmdIndex = 0, cmdLength = commands.length; cmdIndex < cmdLength; ++cmdIndex) - { - cmd = commands[cmdIndex]; - - switch (cmd) - { - case Commands.ARC: - iteration = 0; - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - radius = commands[cmdIndex + 3]; - startAngle = commands[cmdIndex + 4]; - endAngle = commands[cmdIndex + 5]; - anticlockwise = commands[cmdIndex + 6]; - - if (lastPath === null) - { - lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - iteration += iterStep; - } - - endAngle -= startAngle; - - if (anticlockwise) - { - if (endAngle < -PI2) - { - endAngle = -PI2; - } - else if (endAngle > 0) - { - endAngle = -PI2 + endAngle % PI2; - } - } - else if (endAngle > PI2) - { - endAngle = PI2; - } - else if (endAngle < 0) - { - endAngle = PI2 + endAngle % PI2; - } - - while (iteration < 1) - { - ta = endAngle * iteration + startAngle; - tx = x + cos(ta) * radius; - ty = y + sin(ta) * radius; - - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); - - iteration += iterStep; - } - - ta = endAngle + startAngle; - tx = x + cos(ta) * radius; - ty = y + sin(ta) * radius; - - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); - - cmdIndex += 6; - break; - - case Commands.LINE_STYLE: - lineWidth = commands[cmdIndex + 1]; - lineColor = commands[cmdIndex + 2]; - lineAlpha = commands[cmdIndex + 3]; - cmdIndex += 3; - break; - - case Commands.FILL_STYLE: - fillColor = commands[cmdIndex + 1]; - fillAlpha = commands[cmdIndex + 2]; - cmdIndex += 2; - break; - - case Commands.BEGIN_PATH: - pathArray.length = 0; - lastPath = null; - break; - - case Commands.CLOSE_PATH: - if (lastPath && lastPath.points.length) - { - lastPath.points.push(lastPath.points[0]); - } - break; - - case Commands.FILL_PATH: - for (pathArrayIndex = 0, pathArrayLength = pathArray.length; - pathArrayIndex < pathArrayLength; - ++pathArrayIndex) - { - this.batchFillPath( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - pathArray[pathArrayIndex].points, - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - } - break; - - case Commands.STROKE_PATH: - for (pathArrayIndex = 0, pathArrayLength = pathArray.length; - pathArrayIndex < pathArrayLength; - ++pathArrayIndex) - { - path = pathArray[pathArrayIndex]; - this.batchStrokePath( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - path.points, - lineWidth, - lineColor, - lineAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - path === this._lastPath, - currentMatrix - ); - } - break; - - case Commands.FILL_RECT: - this.batchFillRect( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 4; - break; - - case Commands.FILL_TRIANGLE: - this.batchFillTriangle( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Triangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5], - commands[cmdIndex + 6], - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 6; - break; - - case Commands.STROKE_TRIANGLE: - this.batchStrokeTriangle( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Triangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5], - commands[cmdIndex + 6], - lineWidth, - lineColor, - lineAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 6; - break; - - case Commands.LINE_TO: - if (lastPath !== null) - { - lastPath.points.push(new Point(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha)); - } - else - { - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - } - cmdIndex += 2; - break; - - case Commands.MOVE_TO: - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - cmdIndex += 2; - break; - - case Commands.LINE_FX_TO: - if (lastPath !== null) - { - lastPath.points.push(new Point( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - )); - } - else - { - lastPath = new Path( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - ); - pathArray.push(lastPath); - } - cmdIndex += 5; - break; - - case Commands.MOVE_FX_TO: - lastPath = new Path( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - ); - pathArray.push(lastPath); - cmdIndex += 5; - break; - - case Commands.SAVE: - matrixStack[matrixStackLength + 0] = currentMatrix[0]; - matrixStack[matrixStackLength + 1] = currentMatrix[1]; - matrixStack[matrixStackLength + 2] = currentMatrix[2]; - matrixStack[matrixStackLength + 3] = currentMatrix[3]; - matrixStack[matrixStackLength + 4] = currentMatrix[4]; - matrixStack[matrixStackLength + 5] = currentMatrix[5]; - matrixStackLength += 6; - break; - - case Commands.RESTORE: - matrixStackLength -= 6; - currentMatrix[0] = matrixStack[matrixStackLength + 0]; - currentMatrix[1] = matrixStack[matrixStackLength + 1]; - currentMatrix[2] = matrixStack[matrixStackLength + 2]; - currentMatrix[3] = matrixStack[matrixStackLength + 3]; - currentMatrix[4] = matrixStack[matrixStackLength + 4]; - currentMatrix[5] = matrixStack[matrixStackLength + 5]; - break; - - case Commands.TRANSLATE: - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - currentMatrix[4] = currentMatrix[0] * x + currentMatrix[2] * y + currentMatrix[4]; - currentMatrix[5] = currentMatrix[1] * x + currentMatrix[3] * y + currentMatrix[5]; - cmdIndex += 2; - break; - - case Commands.SCALE: - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - currentMatrix[0] *= x; - currentMatrix[1] *= x; - currentMatrix[2] *= y; - currentMatrix[3] *= y; - cmdIndex += 2; - break; - - case Commands.ROTATE: - y = commands[cmdIndex + 1]; - x = sin(y); - y = cos(y); - sra = currentMatrix[0]; - srb = currentMatrix[1]; - src = currentMatrix[2]; - srd = currentMatrix[3]; - currentMatrix[0] = y * sra + x * src; - currentMatrix[1] = y * srb + x * srd; - currentMatrix[2] = -x * sra + y * src; - currentMatrix[3] = -x * srb + y * srd; - cmdIndex += 1; - break; - - default: - // eslint-disable-next-line no-console - console.error('Phaser: Invalid Graphics Command ID ' + cmd); - break; - } - } - }, - - // Stubs - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawStaticTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawEmitterManager: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawBlitter: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchSprite: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchMesh: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchTileSprite: function () - { - } - -}); - -module.exports = FlatTintPipeline; - - -/***/ }), -/* 260 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(531); -var ShaderSourceVS = __webpack_require__(530); -var WebGLPipeline = __webpack_require__(84); - -/** - * @classdesc - * BitmapMaskPipeline handles all bitmap masking rendering in WebGL. It works by using - * sampling two texture on the fragment shader and using the fragment's alpha to clip the region. - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class BitmapMaskPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. - */ -var BitmapMaskPipeline = new Class({ - - Extends: WebGLPipeline, - - initialize: - - function BitmapMaskPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2), - - vertices: new Float32Array([ - -1, +1, -1, -7, +7, +1 - ]).buffer, - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Size of the batch. - * - * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#maxQuads - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.maxQuads = 1; - - /** - * Dirty flag to check if resolution properties need to be updated on the - * masking shader. - * - * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resolutionDirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.resolutionDirty = true; - }, - - /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - if (this.resolutionDirty) - { - renderer.setFloat2(program, 'uResolution', this.width, this.height); - renderer.setInt1(program, 'uMainSampler', 0); - renderer.setInt1(program, 'uMaskSampler', 1); - this.resolutionDirty = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.resolutionDirty = true; - return this; - }, - - /** - * Binds necessary resources and renders the mask to a separated framebuffer. - * The framebuffer for the masked object is also bound for further use. - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#beginMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - GameObject used as mask. - * @param {Phaser.GameObjects.GameObject} maskedObject - GameObject masked by the mask GameObject. - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - beginMask: function (mask, maskedObject, camera) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - var visible = bitmapMask.visible; - - if (bitmapMask && gl) - { - // First we clear the mask framebuffer - renderer.setFramebuffer(mask.maskFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - - // We render out mask source - bitmapMask.visible = true; - bitmapMask.renderWebGL(renderer, bitmapMask, 0.0, camera); - bitmapMask.visible = visible; - renderer.flush(); - - // Bind and clear our main source (masked object) - renderer.setFramebuffer(mask.mainFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - } - }, - - /** - * The masked game object's framebuffer is unbound and it's texture - * is bound together with the mask texture and the mask shader and - * a draw call with a single quad is processed. Here is where the - * masking effect is applied. - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#endMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - GameObject used as a mask. - */ - endMask: function (mask) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - - if (bitmapMask) - { - // Return to default framebuffer - renderer.setFramebuffer(null); - - // Bind bitmap mask pipeline and draw - renderer.setPipeline(this); - - renderer.setTexture2D(mask.maskTexture, 1); - renderer.setTexture2D(mask.mainTexture, 0); - renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); - - // Finally draw a triangle filling the whole screen - gl.drawArrays(this.topology, 0, 3); - } - } - -}); - -module.exports = BitmapMaskPipeline; - - -/***/ }), -/* 261 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Renderer.Snapshot.WebGL - * @since 3.0.0 - * - * @param {HTMLCanvasElement} sourceCanvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] - * - * @return {HTMLImageElement} [description] - */ -var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) -{ - if (!type) { type = 'image/png'; } - if (!encoderOptions) { encoderOptions = 0.92; } - - var gl = sourceCanvas.getContext('experimental-webgl'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); - - // CanvasPool? - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - var imageData; - - canvas.width = gl.drawingBufferWidth; - canvas.height = gl.drawingBufferHeight; - - imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - - var data = imageData.data; - - for (var y = 0; y < canvas.height; y += 1) - { - for (var x = 0; x < canvas.width; x += 1) - { - var si = ((canvas.height - y) * canvas.width + x) * 4; - var di = (y * canvas.width + x) * 4; - data[di + 0] = pixels[si + 0]; - data[di + 1] = pixels[si + 1]; - data[di + 2] = pixels[si + 2]; - data[di + 3] = pixels[si + 3]; - } - } - - ctx.putImageData(imageData, 0, 0); - - var src = canvas.toDataURL(type, encoderOptions); - var image = new Image(); - - image.src = src; - - return image; -}; - -module.exports = WebGLSnapshot; - - -/***/ }), -/* 262 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var IsSizePowerOfTwo = __webpack_require__(85); -var SpliceOne = __webpack_require__(56); -var Utils = __webpack_require__(27); -var WebGLSnapshot = __webpack_require__(261); - -// Default Pipelines -var BitmapMaskPipeline = __webpack_require__(260); -var FlatTintPipeline = __webpack_require__(259); -var ForwardDiffuseLightPipeline = __webpack_require__(148); -var TextureTintPipeline = __webpack_require__(129); - -/** - * @callback WebGLContextCallback - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] - */ - -/** - * @typedef {object} SnapshotState - * - * @property {SnapshotCallback} callback - [description] - * @property {string} type - [description] - * @property {float} encoder - [description] - */ - -/** - * @classdesc - * WebGLRenderer is a class that contains the needed functionality to keep the - * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of - * any context change that happens for WebGL rendering inside of Phaser. This means - * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL - * rendering ecosystem they might pollute the current WebGLRenderingContext state producing - * unexpected behaviour. It's recommended that WebGL interaction is done through - * WebGLRenderer and/or WebGLPipeline. - * - * @class WebGLRenderer - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - */ -var WebGLRenderer = new Class({ - - initialize: - - function WebGLRenderer (game) - { - // eslint-disable-next-line consistent-this - var renderer = this; - - var gameConfig = game.config; - - var contextCreationConfig = { - alpha: gameConfig.transparent, - depth: false, // enable when 3D is added in the future - antialias: gameConfig.antialias, - premultipliedAlpha: gameConfig.premultipliedAlpha, - stencil: true, - preserveDrawingBuffer: gameConfig.preserveDrawingBuffer, - failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat, - powerPreference: gameConfig.powerPreference - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#config - * @type {RendererConfig} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: gameConfig.clearBeforeRender, - pixelArt: gameConfig.pixelArt, - backgroundColor: gameConfig.backgroundColor, - contextCreation: contextCreationConfig, - resolution: gameConfig.resolution, - autoResize: gameConfig.autoResize, - roundPixels: gameConfig.roundPixels, - maxTextures: gameConfig.maxTextures, - maxTextureSize: gameConfig.maxTextureSize - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.WEBGL; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks - * @type {WebGLContextCallback[]} - * @since 3.0.0 - */ - this.lostContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks - * @type {WebGLContextCallback[]} - * @since 3.0.0 - */ - this.restoredContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.blendModes = []; - - /** - * Keeps track of any WebGLTexture created with the current WebGLRenderingContext - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.nativeTextures = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.contextLost = false; - - /** - * This object will store all pipelines created through addPipeline - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines - * @type {object} - * @default null - * @since 3.0.0 - */ - this.pipelines = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState - * @type {SnapshotState} - * @since 3.0.0 - */ - this.snapshotState = { - callback: null, - type: null, - encoder: null - }; - - // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) - - /** - * Cached value for the last texture unit that was used - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit - * @type {integer} - * @since 3.1.0 - */ - this.currentActiveTextureUnit = 0; - - /** - * An array of the last texture handles that were bound to the WebGLRenderingContext - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures - * @type {array} - * @since 3.0.0 - */ - this.currentTextures = new Array(16); - - /** - * Current framebuffer in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer - * @type {WebGLFramebuffer} - * @default null - * @since 3.0.0 - */ - this.currentFramebuffer = null; - - /** - * Current WebGLPipeline in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @since 3.0.0 - */ - this.currentPipeline = null; - - /** - * Current WebGLProgram in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram - * @type {WebGLProgram} - * @default null - * @since 3.0.0 - */ - this.currentProgram = null; - - /** - * Current WebGLBuffer (Vertex buffer) in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentVertexBuffer = null; - - /** - * Current WebGLBuffer (Index buffer) in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentIndexBuffer = null; - - /** - * Current blend mode in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode - * @type {integer} - * @since 3.0.0 - */ - this.currentBlendMode = Infinity; - - /** - * Indicates if the the scissor state is enabled in WebGLRenderingContext - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.currentScissorEnabled = false; - - /** - * Stores the current scissor data - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor - * @type {Uint32Array} - * @since 3.0.0 - */ - this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); - - /** - * Index to the scissor stack top - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorIdx - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScissorIdx = 0; - - /** - * Stack of scissor data - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack - * @type {Uint32Array} - * @since 3.0.0 - */ - this.scissorStack = new Uint32Array(4 * 1000); - - // Setup context lost and restore event listeners - - this.canvas.addEventListener('webglcontextlost', function (event) - { - renderer.contextLost = true; - event.preventDefault(); - - for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) - { - var callback = renderer.lostContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - this.canvas.addEventListener('webglcontextrestored', function () - { - renderer.contextLost = false; - renderer.init(renderer.config); - for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) - { - var callback = renderer.restoredContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - // These are initialized post context creation - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#gl - * @type {WebGLRenderingContext} - * @default null - * @since 3.0.0 - */ - this.gl = null; - - /** - * Array of strings that indicate which WebGL extensions are supported by the browser - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions - * @type {object} - * @default null - * @since 3.0.0 - */ - this.supportedExtensions = null; - - /** - * Extensions loaded into the current context - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.extensions = {}; - - /** - * Stores the current WebGL component formats for further use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats - * @type {array} - * @default [] - * @since 3.2.0 - */ - this.glFormats = []; - - /** - * Stores the supported WebGL texture compression formats. - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#compression - * @type {array} - * @since 3.8.0 - */ - this.compression = { - ETC1: false, - PVRTC: false, - S3TC: false - }; - - this.init(this.config); - }, - - /** - * Creates a new WebGLRenderingContext and initializes all internal - * state. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#init - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - init: function (config) - { - var gl; - var canvas = this.canvas; - var clearColor = config.backgroundColor; - - // Did they provide their own context? - if (this.game.config.context) - { - gl = this.game.config.context; - } - else - { - gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); - } - - if (!gl || gl.isContextLost()) - { - this.contextLost = true; - - throw new Error('This browser does not support WebGL. Try using the Canvas pipeline.'); - } - - this.gl = gl; - - // Set it back into the Game, so devs can access it from there too - this.game.context = gl; - - for (var i = 0; i <= 16; i++) - { - this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); - } - - this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; - this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; - this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; - - this.glFormats[0] = gl.BYTE; - this.glFormats[1] = gl.SHORT; - this.glFormats[2] = gl.UNSIGNED_BYTE; - this.glFormats[3] = gl.UNSIGNED_SHORT; - this.glFormats[4] = gl.FLOAT; - - // Load supported extensions - var exts = gl.getSupportedExtensions(); - - if (!config.maxTextures) - { - config.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); - } - - if (!config.maxTextureSize) - { - config.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); - } - - var extString = 'WEBGL_compressed_texture_'; - var wkExtString = 'WEBKIT_' + extString; - - this.compression.ETC1 = gl.getExtension(extString + 'etc1') || gl.getExtension(wkExtString + 'etc1'); - this.compression.PVRTC = gl.getExtension(extString + 'pvrtc') || gl.getExtension(wkExtString + 'pvrtc'); - this.compression.S3TC = gl.getExtension(extString + 's3tc') || gl.getExtension(wkExtString + 's3tc'); - - this.supportedExtensions = exts; - - // Setup initial WebGL state - gl.disable(gl.DEPTH_TEST); - gl.disable(gl.CULL_FACE); - gl.disable(gl.SCISSOR_TEST); - gl.enable(gl.BLEND); - gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); - - // Initialize all textures to null - for (var index = 0; index < this.currentTextures.length; ++index) - { - this.currentTextures[index] = null; - } - - // Clear previous pipelines and reload default ones - this.pipelines = {}; - - this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('FlatTintPipeline', new FlatTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); - this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this })); - - this.setBlendMode(CONST.BlendModes.NORMAL); - this.resize(this.width, this.height); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - resize: function (width, height) - { - var gl = this.gl; - var pipelines = this.pipelines; - var resolution = this.config.resolution; - - this.width = Math.floor(width * resolution); - this.height = Math.floor(height * resolution); - - this.canvas.width = this.width; - this.canvas.height = this.height; - - if (this.config.autoResize) - { - this.canvas.style.width = (this.width / resolution) + 'px'; - this.canvas.style.height = (this.height / resolution) + 'px'; - } - - gl.viewport(0, 0, this.width, this.height); - - // Update all registered pipelines - for (var pipelineName in pipelines) - { - pipelines[pipelineName].resize(width, height, resolution); - } - - this.currentScissor.set([ 0, 0, this.width, this.height ]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored - * @since 3.0.0 - * - * @param {WebGLContextCallback} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextRestored: function (callback, target) - { - this.restoredContextCallbacks.push([ callback, target ]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost - * @since 3.0.0 - * - * @param {WebGLContextCallback} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextLost: function (callback, target) - { - this.lostContextCallbacks.push([ callback, target ]); - - return this; - }, - - /** - * Checks if a WebGL extension is supported - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension - * @since 3.0.0 - * - * @param {string} extensionName - Name of the WebGL extension - * - * @return {boolean} [description] - */ - hasExtension: function (extensionName) - { - return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; - }, - - /** - * Loads a WebGL extension - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension - * @since 3.0.0 - * - * @param {string} extensionName - [description] - * - * @return {object} WebGL extension if the extension is supported - */ - getExtension: function (extensionName) - { - if (!this.hasExtension(extensionName)) { return null; } - - if (!(extensionName in this.extensions)) - { - this.extensions[extensionName] = this.gl.getExtension(extensionName); - } - - return this.extensions[extensionName]; - }, - - /** - * Flushes the current pipeline if the pipeline is bound - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#flush - * @since 3.0.0 - */ - flush: function () - { - if (this.currentPipeline) - { - this.currentPipeline.flush(); - } - }, - - /* Renderer State Manipulation Functions */ - - /** - * Checks if a pipeline is present in the current WebGLRenderer - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - Name of the pipeline - * - * @return {boolean} [description] - */ - hasPipeline: function (pipelineName) - { - return (pipelineName in this.pipelines); - }, - - /** - * Returns the pipeline by name if the pipeline exists - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - getPipeline: function (pipelineName) - { - return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; - }, - - /** - * Removes a pipeline by name - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - removePipeline: function (pipelineName) - { - delete this.pipelines[pipelineName]; - - return this; - }, - - /** - * Adds a pipeline instance into the collection of pipelines - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - Pipeline instance must extend WebGLPipeline - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} The instance that was passed. - */ - addPipeline: function (pipelineName, pipelineInstance) - { - if (!this.hasPipeline(pipelineName)) - { - this.pipelines[pipelineName] = pipelineInstance; - } - else - { - console.warn('Pipeline', pipelineName, ' already exists.'); - } - - pipelineInstance.name = pipelineName; - - this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); - - return pipelineInstance; - }, - - /** - * Sets the current scissor state - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setScissor: function (x, y, w, h) - { - var gl = this.gl; - var currentScissor = this.currentScissor; - var enabled = (x === 0 && y === 0 && w === gl.canvas.width && h === gl.canvas.height && w >= 0 && h >= 0); - - if (currentScissor[0] !== x || - currentScissor[1] !== y || - currentScissor[2] !== w || - currentScissor[3] !== h) - { - this.flush(); - } - - currentScissor[0] = x; - currentScissor[1] = y; - currentScissor[2] = w; - currentScissor[3] = h; - - this.currentScissorEnabled = enabled; - - if (enabled) - { - gl.disable(gl.SCISSOR_TEST); - - return this; - } - - gl.enable(gl.SCISSOR_TEST); - gl.scissor(x, (gl.drawingBufferHeight - y - h), w, h); - - return this; - }, - - /** - * Pushes a new scissor state. This is used to set nested scissor states. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - pushScissor: function (x, y, w, h) - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx; - var currentScissor = this.currentScissor; - - scissorStack[stackIndex + 0] = currentScissor[0]; - scissorStack[stackIndex + 1] = currentScissor[1]; - scissorStack[stackIndex + 2] = currentScissor[2]; - scissorStack[stackIndex + 3] = currentScissor[3]; - - this.currentScissorIdx += 4; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * Pops the last scissor state and sets it. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - popScissor: function () - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx - 4; - - var x = scissorStack[stackIndex + 0]; - var y = scissorStack[stackIndex + 1]; - var w = scissorStack[stackIndex + 2]; - var h = scissorStack[stackIndex + 3]; - - this.currentScissorIdx = stackIndex; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * Binds a WebGLPipeline and sets it as the current pipeline to be used. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline - * @since 3.0.0 - * - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setPipeline: function (pipelineInstance) - { - if (this.currentPipeline !== pipelineInstance || - this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || - this.currentPipeline.program !== this.currentProgram) - { - this.flush(); - this.currentPipeline = pipelineInstance; - this.currentPipeline.bind(); - } - - this.currentPipeline.onBind(); - - return this.currentPipeline; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode - * @since 3.0.0 - * - * @param {integer} blendModeId - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setBlendMode: function (blendModeId) - { - var gl = this.gl; - var blendMode = this.blendModes[blendModeId]; - - if (blendModeId !== CONST.BlendModes.SKIP_CHECK && - this.currentBlendMode !== blendModeId) - { - this.flush(); - - gl.enable(gl.BLEND); - gl.blendEquation(blendMode.equation); - - if (blendMode.func.length > 2) - { - gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); - } - else - { - gl.blendFunc(blendMode.func[0], blendMode.func[1]); - } - - this.currentBlendMode = blendModeId; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#addBlendMode - * @since 3.0.0 - * - * @param {function} func - [description] - * @param {function} equation - [description] - * - * @return {integer} [description] - */ - addBlendMode: function (func, equation) - { - var index = this.blendModes.push({ func: func, equation: equation }); - - return index - 1; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#updateBlendMode - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {function} func - [description] - * @param {function} equation - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - updateBlendMode: function (index, func, equation) - { - if (this.blendModes[index]) - { - this.blendModes[index].func = func; - - if (equation) - { - this.blendModes[index].equation = equation; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#removeBlendMode - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - removeBlendMode: function (index) - { - if (index > 16 && this.blendModes[index]) - { - this.blendModes.splice(index, 1); - } - - return this; - }, - - /** - * Binds a texture at a texture unit. If a texture is already - * bound to that unit it will force a flush on the current pipeline. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D - * @since 3.0.0 - * - * @param {WebGLTexture} texture - The WebGL texture that needs to be bound - * @param {integer} textureUnit - The texture unit to which the texture will be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setTexture2D: function (texture, textureUnit) - { - var gl = this.gl; - - if (texture !== this.currentTextures[textureUnit]) - { - this.flush(); - - if (this.currentActiveTextureUnit !== textureUnit) - { - gl.activeTexture(gl.TEXTURE0 + textureUnit); - - this.currentActiveTextureUnit = textureUnit; - } - - gl.bindTexture(gl.TEXTURE_2D, texture); - - this.currentTextures[textureUnit] = texture; - } - - return this; - }, - - /** - * Binds a framebuffer. If there was another framebuffer already bound - * it will force a pipeline flush. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setFramebuffer: function (framebuffer) - { - var gl = this.gl; - - if (framebuffer !== this.currentFramebuffer) - { - this.flush(); - - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - - this.currentFramebuffer = framebuffer; - } - - return this; - }, - - /** - * Binds a program. If there was another program already bound - * it will force a pipeline flush - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - The program that needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setProgram: function (program) - { - var gl = this.gl; - - if (program !== this.currentProgram) - { - this.flush(); - - gl.useProgram(program); - - this.currentProgram = program; - } - - return this; - }, - - /** - * Bounds a vertex buffer. If there is a vertex buffer already bound - * it'll force a pipeline flush. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - The buffer that needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setVertexBuffer: function (vertexBuffer) - { - var gl = this.gl; - - if (vertexBuffer !== this.currentVertexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - - this.currentVertexBuffer = vertexBuffer; - } - - return this; - }, - - /** - * Bounds a index buffer. If there is a index buffer already bound - * it'll force a pipeline flush. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} indexBuffer - The buffer the needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setIndexBuffer: function (indexBuffer) - { - var gl = this.gl; - - if (indexBuffer !== this.currentIndexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); - - this.currentIndexBuffer = indexBuffer; - } - - return this; - }, - - /* Renderer Resource Creation Functions */ - - /** - * Creates a texture from an image source. If the source is not valid - * it creates an empty texture - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} scaleMode - [description] - * - * @return {WebGLTexture} [description] - */ - createTextureFromSource: function (source, width, height, scaleMode) - { - var gl = this.gl; - var filter = gl.NEAREST; - var wrap = gl.CLAMP_TO_EDGE; - var texture = null; - - width = source ? source.width : width; - height = source ? source.height : height; - - if (IsSizePowerOfTwo(width, height)) - { - wrap = gl.REPEAT; - } - - if (scaleMode === CONST.ScaleModes.LINEAR) - { - filter = gl.LINEAR; - } - else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt) - { - filter = gl.NEAREST; - } - - if (!source && typeof width === 'number' && typeof height === 'number') - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - } - else - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); - } - - return texture; - }, - - /** - * A wrapper for creating a WebGLTexture. If not pixel data is passed - * it will create an empty texture. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D - * @since 3.0.0 - * - * @param {integer} mipLevel - Mip level of the texture - * @param {integer} minFilter - Filtering of the texture - * @param {integer} magFilter - Filtering of the texture - * @param {integer} wrapT - Wrapping mode of the texture - * @param {integer} wrapS - Wrapping mode of the texture - * @param {integer} format - Which format does the texture use - * @param {object} pixels - pixel data - * @param {integer} width - Width of the texture in pixels - * @param {integer} height - Height of the texture in pixels - * @param {boolean} pma - Does the texture hace premultiplied alpha. - * - * @return {WebGLTexture} Raw WebGLTexture - */ - createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) - { - var gl = this.gl; - var texture = gl.createTexture(); - - pma = (pma === undefined || pma === null) ? true : pma; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); - - if (pixels === null || pixels === undefined) - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); - } - else - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); - width = pixels.width; - height = pixels.height; - } - - this.setTexture2D(null, 0); - - texture.isAlphaPremultiplied = pma; - texture.isRenderTexture = false; - texture.width = width; - texture.height = height; - - this.nativeTextures.push(texture); - - return texture; - }, - - /** - * Wrapper for creating WebGLFramebuffer. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer - * @since 3.0.0 - * - * @param {integer} width - Width in pixels of the framebuffer - * @param {integer} height - Height in pixels of the framebuffer - * @param {WebGLTexture} renderTexture - The color texture to where the color pixels are written - * @param {boolean} addDepthStencilBuffer - Indicates if the current framebuffer support depth and stencil buffers - * - * @return {WebGLFramebuffer} Raw WebGLFramebuffer - */ - createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) - { - var gl = this.gl; - var framebuffer = gl.createFramebuffer(); - var complete = 0; - - this.setFramebuffer(framebuffer); - - if (addDepthStencilBuffer) - { - var depthStencilBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); - } - - renderTexture.isRenderTexture = true; - renderTexture.isAlphaPremultiplied = false; - - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); - - complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); - - if (complete !== gl.FRAMEBUFFER_COMPLETE) - { - var errors = { - 36054: 'Incomplete Attachment', - 36055: 'Missing Attachment', - 36057: 'Incomplete Dimensions', - 36061: 'Framebuffer Unsupported' - }; - - throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); - } - - framebuffer.renderTexture = renderTexture; - - this.setFramebuffer(null); - - return framebuffer; - }, - - /** - * Wrapper for creating a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram - * @since 3.0.0 - * - * @param {string} vertexShader - Source to the vertex shader - * @param {string} fragmentShader - Source to the fragment shader - * - * @return {WebGLProgram} Raw WebGLProgram - */ - createProgram: function (vertexShader, fragmentShader) - { - var gl = this.gl; - var program = gl.createProgram(); - var vs = gl.createShader(gl.VERTEX_SHADER); - var fs = gl.createShader(gl.FRAGMENT_SHADER); - - gl.shaderSource(vs, vertexShader); - gl.shaderSource(fs, fragmentShader); - gl.compileShader(vs); - gl.compileShader(fs); - - if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); - } - if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); - } - - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.linkProgram(program); - - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) - { - throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); - } - - return program; - }, - - /** - * Wrapper for creating a vertex buffer. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo - * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW - * - * @return {WebGLBuffer} Raw vertex buffer - */ - createVertexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var vertexBuffer = gl.createBuffer(); - - this.setVertexBuffer(vertexBuffer); - - gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); - - this.setVertexBuffer(null); - - return vertexBuffer; - }, - - /** - * Wrapper for creating a vertex buffer. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo - * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW - * - * @return {WebGLBuffer} Raw index buffer - */ - createIndexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var indexBuffer = gl.createBuffer(); - - this.setIndexBuffer(indexBuffer); - - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); - - this.setIndexBuffer(null); - - return indexBuffer; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture - * @since 3.0.0 - * - * @param {WebGLTexture} texture - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteTexture: function (texture) - { - var index = this.nativeTextures.indexOf(texture); - - if (index !== -1) - { - SpliceOne(this.nativeTextures, index); - } - - this.gl.deleteTexture(texture); - - return this; - }, - - /** - * Wrapper for deleting a raw WebGLFramebuffer - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteFramebuffer: function (framebuffer) - { - this.gl.deleteFramebuffer(framebuffer); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteProgram: function (program) - { - this.gl.deleteProgram(program); - - return this; - }, - - /** - * Wrapper for deleting a vertex or index buffer - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteBuffer: function (buffer) - { - this.gl.deleteBuffer(buffer); - - return this; - }, - - /* Rendering Functions */ - - /** - * Handles any clipping needed by the camera and renders the background - * color if a color is visible. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderCamera: function (camera) - { - var resolution = this.config.resolution; - - var cx = Math.floor(camera.x * resolution); - var cy = Math.floor(camera.y * resolution); - var cw = Math.floor(camera.width * resolution); - var ch = Math.floor(camera.height * resolution); - - this.pushScissor(cx, cy, cw, ch); - - if (camera.backgroundColor.alphaGL > 0) - { - var color = camera.backgroundColor; - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1.0), - color.alphaGL, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); - - FlatTintPipeline.flush(); - } - }, - - /** - * Renders the foreground camera effects like flash and fading. - * It resets the current scissor state. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - postRenderCamera: function (camera) - { - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - var isFlashing = camera.flashEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); - var isFading = camera.fadeEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); - - if (isFading || isFlashing) - { - FlatTintPipeline.flush(); - } - - this.popScissor(); - }, - - /** - * Clears the current vertex buffer and updates pipelines. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - if (this.contextLost) { return; } - - var gl = this.gl; - var color = this.config.backgroundColor; - var pipelines = this.pipelines; - - // Bind custom framebuffer here - gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); - - if (this.config.clearBeforeRender) - { - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); - } - - for (var key in pipelines) - { - pipelines[key].onPreRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.GameObject} children - [description] - * @param {number} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - if (this.contextLost) { return; } - - var list = children.list; - var childCount = list.length; - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onRender(scene, camera); - } - - this.preRenderCamera(camera); - - for (var index = 0; index < childCount; ++index) - { - var child = list[index]; - - if (!child.willRender()) - { - continue; - } - - if (child.blendMode !== this.currentBlendMode) - { - this.setBlendMode(child.blendMode); - } - - if (child.mask) - { - child.mask.preRenderWebGL(this, child, camera); - } - - child.renderWebGL(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderWebGL(this, child); - } - } - - this.flush(); - this.setBlendMode(CONST.BlendModes.NORMAL); - this.postRenderCamera(camera); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - if (this.contextLost) { return; } - - // Unbind custom framebuffer here - - if (this.snapshotState.callback) - { - this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); - this.snapshotState.callback = null; - } - - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onPostRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot - * @since 3.0.0 - * - * @param {SnapshotCallback} callback - [description] - * @param {string} type - [description] - * @param {float} encoderOptions - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotState.callback = callback; - this.snapshotState.type = type; - this.snapshotState.encoder = encoderOptions; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture - * @since 3.0.0 - * - * @param {HTMLCanvasElement} srcCanvas - [description] - * @param {WebGLTexture} [dstTexture] - [description] - * - * @return {WebGLTexture} [description] - */ - canvasToTexture: function (srcCanvas, dstTexture) - { - var gl = this.gl; - - if (!dstTexture) - { - var wrapping = gl.CLAMP_TO_EDGE; - - if (IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) - { - wrapping = gl.REPEAT; - } - - dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); - } - else - { - this.setTexture2D(dstTexture, 0); - - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); - - dstTexture.width = srcCanvas.width; - dstTexture.height = srcCanvas.height; - - this.setTexture2D(null, 0); - } - - return dstTexture; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter - * @since 3.0.0 - * - * @param {integer} texture - [description] - * @param {integer} filter - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setTextureFilter: function (texture, filter) - { - var gl = this.gl; - var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); - - this.setTexture2D(null, 0); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat1: function (program, name, x) - { - this.setProgram(program); - - this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat2: function (program, name, x, y) - { - this.setProgram(program); - - this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat3: function (program, name, x, y, z) - { - this.setProgram(program); - - this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); - - return this; - }, - - /** - * Sets uniform of a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - Target program - * @param {string} name - Name of the uniform - * @param {float} x - X component - * @param {float} y - Y component - * @param {float} z - Z component - * @param {float} w - W component - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat4: function (program, name, x, y, z, w) - { - this.setProgram(program); - - this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt1: function (program, name, x) - { - this.setProgram(program); - - this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt2: function (program, name, x, y) - { - this.setProgram(program); - - this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt3: function (program, name, x, y, z) - { - this.setProgram(program); - - this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); - - return this; - }, - - /** - * Sets uniform of a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - Target Program - * @param {string} name - Name of the uniform - * @param {integer} x - X component - * @param {integer} y - Y component - * @param {integer} z - Z component - * @param {integer} w - W component - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt4: function (program, name, x, y, z, w) - { - this.setProgram(program); - - this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix2: function (program, name, transpose, matrix) - { - this.setProgram(program); - - this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix3: function (program, name, transpose, matrix) - { - this.setProgram(program); - - this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); - - return this; - }, - - /** - * Sets uniform of a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - Target program - * @param {string} name - Name of the uniform - * @param {boolean} transpose - Is the matrix transposed - * @param {Float32Array} matrix - Matrix data - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix4: function (program, name, transpose, matrix) - { - this.setProgram(program); - - this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); - - return this; - }, - - /** - * Returns the maximum number of texture units that can be used in a fragment shader. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextures - * @since 3.8.0 - * - * @return {integer} The maximum number of textures WebGL supports. - */ - getMaxTextures: function () - { - return this.config.maxTextures; - }, - - /** - * Returns the largest texture size (either width or height) that can be created. - * Note that VRAM may not allow a texture of any given size, it just expresses - * hardware / driver support for a given size. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextureSize - * @since 3.8.0 - * - * @return {integer} ... - */ - getMaxTextureSize: function () - { - return this.config.maxTextureSize; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Clear-up anything that should be cleared :) - for (var key in this.pipelines) - { - this.pipelines[key].destroy(); - - delete this.pipelines[key]; - } - - for (var index = 0; index < this.nativeTextures.length; ++index) - { - this.deleteTexture(this.nativeTextures[index]); - - delete this.nativeTextures[index]; - } - - delete this.gl; - delete this.game; - - this.contextLost = true; - this.extensions = {}; - this.nativeTextures.length = 0; - } - -}); - -module.exports = WebGLRenderer; - - -/***/ }), -/* 263 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var modes = __webpack_require__(51); -var CanvasFeatures = __webpack_require__(203); - -/** - * [description] - * - * @function Phaser.Renderer.Canvas.GetBlendModes - * @since 3.0.0 - * - * @return {array} [description] - */ -var GetBlendModes = function () -{ - var output = []; - var useNew = CanvasFeatures.supportNewBlendModes; - - output[modes.NORMAL] = 'source-over'; - output[modes.ADD] = 'lighter'; - output[modes.MULTIPLY] = (useNew) ? 'multiply' : 'source-over'; - output[modes.SCREEN] = (useNew) ? 'screen' : 'source-over'; - output[modes.OVERLAY] = (useNew) ? 'overlay' : 'source-over'; - output[modes.DARKEN] = (useNew) ? 'darken' : 'source-over'; - output[modes.LIGHTEN] = (useNew) ? 'lighten' : 'source-over'; - output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : 'source-over'; - output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : 'source-over'; - output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : 'source-over'; - output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : 'source-over'; - output[modes.DIFFERENCE] = (useNew) ? 'difference' : 'source-over'; - output[modes.EXCLUSION] = (useNew) ? 'exclusion' : 'source-over'; - output[modes.HUE] = (useNew) ? 'hue' : 'source-over'; - output[modes.SATURATION] = (useNew) ? 'saturation' : 'source-over'; - output[modes.COLOR] = (useNew) ? 'color' : 'source-over'; - output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : 'source-over'; - - return output; -}; - -module.exports = GetBlendModes; - - -/***/ }), -/* 264 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var roundPixels = false; - -/** - * [description] - * - * @function Phaser.Renderer.Canvas.DrawImage - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} src - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - [description] - */ -var DrawImage = function (src, camera, parentMatrix) -{ - var ctx = this.currentContext; - var frame = src.frame; - var cd = frame.canvasData; - - // Blend Mode - - if (this.currentBlendMode !== src.blendMode) - { - this.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = this.blendModes[src.blendMode]; - } - - // Alpha - - if (this.currentAlpha !== src.alpha) - { - this.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - - if (this.currentScaleMode !== src.scaleMode) - { - this.currentScaleMode = src.scaleMode; - - // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); - } - - var dx = frame.x; - var dy = frame.y; - - var fx = 1; - var fy = 1; - - if (src.flipX) - { - fx = -1; - dx -= cd.dWidth - src.displayOriginX; - } - else - { - dx -= src.displayOriginX; - } - - if (src.flipY) - { - fy = -1; - dy -= cd.dHeight - src.displayOriginY; - } - else - { - dy -= src.displayOriginY; - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - dx |= 0; - dy |= 0; - } - - // Perform Matrix ITRS - - ctx.save(); - - if (parentMatrix) - { - var matrix = parentMatrix.matrix; - - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(fx, fy); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - - ctx.restore(); -}; - -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return DrawImage; -}; - - -/***/ }), -/* 265 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Renderer.Snapshot.Canvas - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] - * - * @return {HTMLImageElement} [description] - */ -var CanvasSnapshot = function (canvas, type, encoderOptions) -{ - if (type === undefined) { type = 'image/png'; } - if (encoderOptions === undefined) { encoderOptions = 0.92; } - - var src = canvas.toDataURL(type, encoderOptions); - - var image = new Image(); - - image.src = src; - - return image; -}; - -module.exports = CanvasSnapshot; - - -/***/ }), -/* 266 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var roundPixels = false; - -/** - * No scaling, anchor, rotation or effects, literally draws the frame directly to the canvas. - * - * @function Phaser.Renderer.Canvas.BlitImage - * @since 3.0.0 - * - * @param {number} dx - The x coordinate to render the Frame to. - * @param {number} dy - The y coordinate to render the Frame to. - * @param {Phaser.Textures.Frame} frame - The Frame to render. - */ -var BlitImage = function (dx, dy, frame) -{ - var ctx = this.currentContext; - var cd = frame.canvasData; - - if (roundPixels) - { - dx |= 0; - dy |= 0; - } - - ctx.drawImage( - frame.source.image, - cd.sx, - cd.sy, - cd.sWidth, - cd.sHeight, - dx, - dy, - cd.dWidth, - cd.dHeight - ); -}; - -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return BlitImage; -}; - - -/***/ }), -/* 267 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlitImage = __webpack_require__(266); -var CanvasSnapshot = __webpack_require__(265); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var DrawImage = __webpack_require__(264); -var GetBlendModes = __webpack_require__(263); -var ScaleModes = __webpack_require__(59); -var Smoothing = __webpack_require__(131); - -/** - * @classdesc - * [description] - * - * @class CanvasRenderer - * @memberOf Phaser.Renderer.Canvas - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. - */ -var CanvasRenderer = new Class({ - - initialize: - - function CanvasRenderer (game) - { - /** - * The Phaser Game instance that owns this renderer. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.CANVAS; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.drawCount = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#config - * @type {RendererConfig} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: game.config.clearBeforeRender, - pixelArt: game.config.pixelArt, - backgroundColor: game.config.backgroundColor, - resolution: game.config.resolution, - autoResize: game.config.autoResize, - roundPixels: game.config.roundPixels - }; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode - * @type {integer} - * @since 3.0.0 - */ - this.scaleMode = (game.config.pixelArt) ? ScaleModes.NEAREST : ScaleModes.LINEAR; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.gameCanvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.gameContext = (this.game.config.context) ? this.game.config.context : this.gameCanvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.currentContext = this.gameContext; - - /** - * Map to the required function. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawImage - * @type {function} - * @since 3.0.0 - */ - this.drawImage = DrawImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blitImage - * @type {function} - * @since 3.0.0 - */ - this.blitImage = BlitImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes - * @type {array} - * @since 3.0.0 - */ - this.blendModes = GetBlendModes(); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.currentAlpha = 1; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentBlendMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentBlendMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScaleMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback - * @type {?SnapshotCallback} - * @default null - * @since 3.0.0 - */ - this.snapshotCallback = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType - * @type {?string} - * @default null - * @since 3.0.0 - */ - this.snapshotType = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder - * @type {?number} - * @default null - * @since 3.0.0 - */ - this.snapshotEncoder = null; - - this.init(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#init - * @since 3.0.0 - */ - init: function () - { - this.resize(this.width, this.height); - }, - - /** - * Resize the main game canvas. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resize - * @since 3.0.0 - * - * @param {integer} width - [description] - * @param {integer} height - [description] - */ - resize: function (width, height) - { - var resolution = this.config.resolution; - - this.width = width * resolution; - this.height = height * resolution; - - this.gameCanvas.width = this.width; - this.gameCanvas.height = this.height; - - if (this.config.autoResize) - { - this.gameCanvas.style.width = (this.width / resolution) + 'px'; - this.gameCanvas.style.height = (this.height / resolution) + 'px'; - } - - // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) - if (this.scaleMode === ScaleModes.NEAREST) - { - Smoothing.disable(this.gameContext); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextLost: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextRestored: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform - * @since 3.0.0 - */ - resetTransform: function () - { - this.currentContext.setTransform(1, 0, 0, 1, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode - * @since 3.0.0 - * - * @param {number} blendMode - [description] - * - * @return {number} [description] - */ - setBlendMode: function (blendMode) - { - if (this.currentBlendMode !== blendMode) - { - this.currentContext.globalCompositeOperation = blendMode; - this.currentBlendMode = blendMode; - } - - return this.currentBlendMode; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha - * @since 3.0.0 - * - * @param {float} alpha - [description] - * - * @return {float} [description] - */ - setAlpha: function (alpha) - { - if (this.currentAlpha !== alpha) - { - this.currentContext.globalAlpha = alpha; - this.currentAlpha = alpha; - } - - return this.currentAlpha; - }, - - /** - * Called at the start of the render loop. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - var ctx = this.gameContext; - var config = this.config; - - var width = this.width; - var height = this.height; - - if (config.clearBeforeRender) - { - ctx.clearRect(0, 0, width, height); - } - - if (!config.transparent) - { - ctx.fillStyle = config.backgroundColor.rgba; - ctx.fillRect(0, 0, width, height); - } - - this.drawCount = 0; - }, - - /** - * Renders the Scene to the given Camera. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.DisplayList} children - [description] - * @param {float} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - var ctx = scene.sys.context; - var scissor = (camera.x !== 0 || camera.y !== 0 || camera.width !== ctx.canvas.width || camera.height !== ctx.canvas.height); - var list = children.list; - var resolution = this.config.resolution; - - this.currentContext = ctx; - - // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) - - if (!camera.transparent) - { - ctx.fillStyle = camera.backgroundColor.rgba; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); - } - - if (this.currentAlpha !== 1) - { - ctx.globalAlpha = 1; - this.currentAlpha = 1; - } - - if (this.currentBlendMode !== 0) - { - ctx.globalCompositeOperation = 'source-over'; - this.currentBlendMode = 0; - } - - this.currentScaleMode = 0; - - this.drawCount += list.length; - - if (scissor) - { - ctx.save(); - ctx.beginPath(); - ctx.rect(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); - ctx.clip(); - } - - var matrix = camera.matrix.matrix; - - ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - - for (var c = 0; c < list.length; c++) - { - var child = list[c]; - - if (child.mask) - { - child.mask.preRenderCanvas(this, child, camera); - } - - child.renderCanvas(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderCanvas(this, child, camera); - } - } - - ctx.setTransform(1, 0, 0, 1, 0, 0); - ctx.globalCompositeOperation = 'source-over'; - - camera.flashEffect.postRenderCanvas(ctx); - camera.fadeEffect.postRenderCanvas(ctx); - - // Reset the camera scissor - if (scissor) - { - ctx.restore(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - var ctx = this.gameContext; - - ctx.globalAlpha = 1; - ctx.globalCompositeOperation = 'source-over'; - - this.currentAlpha = 1; - this.currentBlendMode = 0; - - if (this.snapshotCallback) - { - this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); - this.snapshotCallback = null; - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot - * @since 3.0.0 - * - * @param {SnapshotCallback} callback - [description] - * @param {string} type - [description] - * @param {number} encoderOptions - [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotCallback = callback; - this.snapshotType = type; - this.snapshotEncoder = encoderOptions; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.gameCanvas = null; - this.gameContext = null; - - this.game = null; - } - -}); - -module.exports = CanvasRenderer; - - -/***/ }), -/* 268 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * Abstracts away the use of RAF or setTimeOut for the core game update loop. - * This is invoked automatically by the Phaser.Game instance. - * - * @class RequestAnimationFrame - * @memberOf Phaser.DOM - * @constructor - * @since 3.0.0 - */ -var RequestAnimationFrame = new Class({ - - initialize: - - function RequestAnimationFrame () - { - /** - * True if RequestAnimationFrame is running, otherwise false. - * - * @name Phaser.DOM.RequestAnimationFrame#isRunning - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isRunning = false; - - /** - * The callback to be invoked each step. - * - * @name Phaser.DOM.RequestAnimationFrame#callback - * @type {FrameRequestCallback} - * @since 3.0.0 - */ - this.callback = NOOP; - - /** - * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#tick - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tick = 0; - - /** - * True if the step is using setTimeout instead of RAF. - * - * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isSetTimeOut = false; - - /** - * The setTimeout or RAF callback ID used when canceling them. - * - * @name Phaser.DOM.RequestAnimationFrame#timeOutID - * @type {?number} - * @default null - * @since 3.0.0 - */ - this.timeOutID = null; - - /** - * The previous time the step was called. - * - * @name Phaser.DOM.RequestAnimationFrame#lastTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.lastTime = 0; - - var _this = this; - - /** - * The RAF step function. - * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. - * - * @name Phaser.DOM.RequestAnimationFrame#step - * @type {FrameRequestCallback} - * @since 3.0.0 - */ - this.step = function step (timestamp) - { - // DOMHighResTimeStamp - _this.lastTime = _this.tick; - - _this.tick = timestamp; - - _this.callback(timestamp); - - _this.timeOutID = window.requestAnimationFrame(step); - }; - - /** - * The SetTimeout step function. - * Updates the local tick value, invokes the callback and schedules another call to setTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#stepTimeout - * @type {function} - * @since 3.0.0 - */ - this.stepTimeout = function stepTimeout () - { - var d = Date.now(); - - var delay = Math.max(16 + _this.lastTime - d, 0); - - _this.lastTime = _this.tick; - - _this.tick = d; - - _this.callback(d); - - _this.timeOutID = window.setTimeout(stepTimeout, delay); - }; - }, - - /** - * Starts the requestAnimationFrame or setTimeout process running. - * - * @method Phaser.DOM.RequestAnimationFrame#start - * @since 3.0.0 - * - * @param {FrameRequestCallback} callback - The callback to invoke each step. - * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? - */ - start: function (callback, forceSetTimeOut) - { - if (this.isRunning) - { - return; - } - - this.callback = callback; - - this.isSetTimeOut = forceSetTimeOut; - - this.isRunning = true; - - this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); - }, +var Mask = { /** - * Stops the requestAnimationFrame or setTimeout from running. + * The Mask this Game Object is using during render. * - * @method Phaser.DOM.RequestAnimationFrame#stop + * @name Phaser.GameObjects.Components.Mask#mask + * @type {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} * @since 3.0.0 */ - stop: function () - { - this.isRunning = false; - - if (this.isSetTimeOut) - { - clearTimeout(this.timeOutID); - } - else - { - window.cancelAnimationFrame(this.timeOutID); - } - }, + mask: null, /** - * Stops the step from running and clears the callback reference. + * Sets the mask that this Game Object will use to render with. * - * @method Phaser.DOM.RequestAnimationFrame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stop(); - - this.callback = NOOP; - } - -}); - -module.exports = RequestAnimationFrame; - - -/***/ }), -/* 269 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Attempts to remove the element from its parentNode in the DOM. - * - * @function Phaser.DOM.RemoveFromDOM - * @since 3.0.0 - * - * @param {HTMLElement} element - The DOM element to remove from its parent node. - */ -var RemoveFromDOM = function (element) -{ - if (element.parentNode) - { - element.parentNode.removeChild(element); - } -}; - -module.exports = RemoveFromDOM; - - -/***/ }), -/* 270 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes the given data string and parses it as XML. - * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. - * The parsed XML object is returned, or `null` if there was an error while parsing the data. - * - * @function Phaser.DOM.ParseXML - * @since 3.0.0 - * - * @param {string} data - The XML source stored in a string. - * - * @return {?(DOMParser|ActiveXObject)} The parsed XML data, or `null` if the data could not be parsed. - */ -var ParseXML = function (data) -{ - var xml = ''; - - try - { - if (window['DOMParser']) - { - var domparser = new DOMParser(); - xml = domparser.parseFromString(data, 'text/xml'); - } - else - { - xml = new ActiveXObject('Microsoft.XMLDOM'); - xml.loadXML(data); - } - } - catch (e) - { - xml = null; - } - - if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) - { - return null; - } - else - { - return xml; - } -}; - -module.exports = ParseXML; - - -/***/ }), -/* 271 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(57); - -/** - * @callback ContentLoadedCallback - */ - -/** - * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. - * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. - * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. - * - * @function Phaser.DOM.DOMContentLoaded - * @since 3.0.0 - * - * @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded. - */ -var DOMContentLoaded = function (callback) -{ - if (document.readyState === 'complete' || document.readyState === 'interactive') - { - callback(); - - return; - } - - var check = function () - { - document.removeEventListener('deviceready', check, true); - document.removeEventListener('DOMContentLoaded', check, true); - window.removeEventListener('load', check, true); - - callback(); - }; - - if (!document.body) - { - window.setTimeout(check, 20); - } - else if (OS.cordova && !OS.cocoonJS) - { - // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready - document.addEventListener('deviceready', check, false); - } - else - { - document.addEventListener('DOMContentLoaded', check, true); - window.addEventListener('load', check, true); - } -}; - -module.exports = DOMContentLoaded; - - -/***/ }), -/* 272 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Canvas.CanvasInterpolation - * @since 3.0.0 - */ -var CanvasInterpolation = { - - /** - * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * - * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp - * @since 3.0.0 + * If a mask is already set on this Game Object it will be immediately replaced. * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. * - * @return {HTMLCanvasElement} The canvas. + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * + * @method Phaser.GameObjects.Components.Mask#setMask + * @since 3.6.2 + * + * @param {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} mask - The mask this Game Object will use when rendering. + * + * @return {this} This Game Object instance. */ - setCrisp: function (canvas) + setMask: function (mask) { - var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; + this.mask = mask; - types.forEach(function (type) - { - canvas.style['image-rendering'] = type; - }); - - canvas.style.msInterpolationMode = 'nearest-neighbor'; - - return canvas; + return this; }, /** - * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). + * Clears the mask that this Game Object was using. * - * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic - * @since 3.0.0 + * @method Phaser.GameObjects.Components.Mask#clearMask + * @since 3.6.2 + * + * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? + * + * @return {this} This Game Object instance. + */ + clearMask: function (destroyMask) + { + if (destroyMask === undefined) { destroyMask = false; } + + if (destroyMask && this.mask) + { + this.mask.destroy(); + } + + this.mask = null; + + return this; + }, + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * + * @method Phaser.GameObjects.Components.Mask#createBitmapMask + * @since 3.6.2 * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * @param {Phaser.GameObjects.GameObject} [renderable] - A renderable Game Object that uses a texture, such as a Sprite. + * + * @return {Phaser.Display.Masks.BitmapMask} This Bitmap Mask that was created. + */ + createBitmapMask: function (renderable) + { + if (renderable === undefined && this.texture) + { + // eslint-disable-next-line consistent-this + renderable = this; + } + + return new BitmapMask(this.scene, renderable); + }, + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. * - * @return {HTMLCanvasElement} The canvas. + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * + * @method Phaser.GameObjects.Components.Mask#createGeometryMask + * @since 3.6.2 + * + * @param {Phaser.GameObjects.Graphics} [graphics] - A Graphics Game Object. The geometry within it will be used as the mask. + * + * @return {Phaser.Display.Masks.GeometryMask} This Geometry Mask that was created. */ - setBicubic: function (canvas) + createGeometryMask: function (graphics) { - canvas.style['image-rendering'] = 'auto'; - canvas.style.msInterpolationMode = 'bicubic'; + if (graphics === undefined && this.type === 'Graphics') + { + // eslint-disable-next-line consistent-this + graphics = this; + } - return canvas; + return new GeometryMask(this.scene, graphics); } }; -module.exports = CanvasInterpolation; +module.exports = Mask; /***/ }), -/* 273 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates a Catmull-Rom value. - * - * @function Phaser.Math.CatmullRom - * @since 3.0.0 - * - * @param {number} t - [description] - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {number} p2 - [description] - * @param {number} p3 - [description] - * - * @return {number} The Catmull-Rom value. - */ -var CatmullRom = function (t, p0, p1, p2, p3) -{ - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - var t2 = t * t; - var t3 = t * t2; - - return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; -}; - -module.exports = CatmullRom; - - -/***/ }), -/* 274 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -// points is an array of Point-like objects, -// either 2 dimensional arrays, or objects with public x/y properties: -// var points = [ -// [100, 200], -// [200, 400], -// { x: 30, y: 60 } -// ] - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.FromPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {array} points - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var FromPoints = function (points, out) -{ - if (out === undefined) { out = new Rectangle(); } - - if (points.length === 0) - { - return out; - } - - var minX = Number.MAX_VALUE; - var minY = Number.MAX_VALUE; - - var maxX = Number.MIN_SAFE_INTEGER; - var maxY = Number.MIN_SAFE_INTEGER; - - var p; - var px; - var py; - - for (var i = 0; i < points.length; i++) - { - p = points[i]; - - if (Array.isArray(p)) - { - px = p[0]; - py = p[1]; - } - else - { - px = p.x; - py = p.y; - } - - minX = Math.min(minX, px); - minY = Math.min(minY, py); - - maxX = Math.max(maxX, px); - maxY = Math.max(maxY, py); - } - - out.x = minX; - out.y = minY; - out.width = maxX - minX; - out.height = maxY - minY; - - return out; -}; - -module.exports = FromPoints; - - -/***/ }), -/* 275 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.ARNE16 - * @since 3.0.0 - * - * @type {Palette} - */ -module.exports = { - 0: '#000', - 1: '#9D9D9D', - 2: '#FFF', - 3: '#BE2633', - 4: '#E06F8B', - 5: '#493C2B', - 6: '#A46422', - 7: '#EB8931', - 8: '#F7E26B', - 9: '#2F484E', - A: '#44891A', - B: '#A3CE27', - C: '#1B2632', - D: '#005784', - E: '#31A2F2', - F: '#B2DCEF' -}; - - -/***/ }), -/* 276 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Arne16 = __webpack_require__(275); -var CanvasPool = __webpack_require__(22); -var GetValue = __webpack_require__(4); - -/** - * @callback GenerateTextureRendererCallback - * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] - */ - -/** - * @typedef {object} GenerateTextureConfig - * - * @property {array} [data=[]] - [description] - * @property {HTMLCanvasElement} [canvas=null] - [description] - * @property {Palette} [palette=Arne16] - [description] - * @property {number} [pixelWidth=1] - [description] - * @property {number} [pixelHeight=1] - [description] - * @property {boolean} [resizeCanvas=true] - [description] - * @property {boolean} [clearCanvas=true] - [description] - * @property {GenerateTextureRendererCallback} [preRender] - [description] - * @property {GenerateTextureRendererCallback} [postRender] - [description] - */ - -/** - * [description] - * - * @function Phaser.Create.GenerateTexture - * @since 3.0.0 - * - * @param {GenerateTextureConfig} config - [description] - * - * @return {HTMLCanvasElement} [description] - */ -var GenerateTexture = function (config) -{ - var data = GetValue(config, 'data', []); - var canvas = GetValue(config, 'canvas', null); - var palette = GetValue(config, 'palette', Arne16); - var pixelWidth = GetValue(config, 'pixelWidth', 1); - var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); - var resizeCanvas = GetValue(config, 'resizeCanvas', true); - var clearCanvas = GetValue(config, 'clearCanvas', true); - var preRender = GetValue(config, 'preRender', null); - var postRender = GetValue(config, 'postRender', null); - - var width = Math.floor(Math.abs(data[0].length * pixelWidth)); - var height = Math.floor(Math.abs(data.length * pixelHeight)); - - if (!canvas) - { - canvas = CanvasPool.create2D(this, width, height); - resizeCanvas = false; - clearCanvas = false; - } - - if (resizeCanvas) - { - canvas.width = width; - canvas.height = height; - } - - var ctx = canvas.getContext('2d'); - - if (clearCanvas) - { - ctx.clearRect(0, 0, width, height); - } - - // preRender Callback? - if (preRender) - { - preRender(canvas, ctx); - } - - // Draw it - for (var y = 0; y < data.length; y++) - { - var row = data[y]; - - for (var x = 0; x < row.length; x++) - { - var d = row[x]; - - if (d !== '.' && d !== ' ') - { - ctx.fillStyle = palette[d]; - ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); - } - } - } - - // postRender Callback? - if (postRender) - { - postRender(canvas, ctx); - } - - return canvas; -}; - -module.exports = GenerateTexture; - - -/***/ }), -/* 277 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A representation of a vector in 4D space. - * - * A four-component vector. - * - * @class Vector4 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - The x component. - * @param {number} [y] - The y component. - * @param {number} [z] - The z component. - * @param {number} [w] - The w component. - */ -var Vector4 = new Class({ - - initialize: - - function Vector4 (x, y, z, w) - { - /** - * The x component of this Vector. - * - * @name Phaser.Math.Vector4#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The y component of this Vector. - * - * @name Phaser.Math.Vector4#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The z component of this Vector. - * - * @name Phaser.Math.Vector4#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.z = 0; - - /** - * The w component of this Vector. - * - * @name Phaser.Math.Vector4#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.w = 0; - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - }, - - /** - * Make a clone of this Vector4. - * - * @method Phaser.Math.Vector4#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} A clone of this Vector4. - */ - clone: function () - { - return new Vector4(this.x, this.y, this.z, this.w); - }, - - /** - * Copy the components of a given Vector into this Vector. - * - * @method Phaser.Math.Vector4#copy - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} src - The Vector to copy the components from. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z || 0; - this.w = src.w || 0; - - return this; - }, - - /** - * Check whether this Vector is equal to a given Vector. - * - * Performs a strict quality check against each Vector's components. - * - * @method Phaser.Math.Vector4#equals - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} v - [description] - * - * @return {boolean} [description] - */ - equals: function (v) - { - return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); - }, - - /** - * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. - * - * @method Phaser.Math.Vector4#set - * @since 3.0.0 - * - * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y, z and w components. - * @param {number} y - The y value to set for this Vector. - * @param {number} z - The z value to set for this Vector. - * @param {number} w - The z value to set for this Vector. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - set: function (x, y, z, w) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - - return this; - }, - - /** - * Add a given Vector to this Vector. Addition is component-wise. - * - * @method Phaser.Math.Vector4#add - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to add to this Vector. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z || 0; - this.w += v.w || 0; - - return this; - }, - - /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * - * @method Phaser.Math.Vector4#subtract - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to subtract from this Vector. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z || 0; - this.w -= v.w || 0; - - return this; - }, - - /** - * Scale this Vector by the given value. - * - * @method Phaser.Math.Vector4#scale - * @since 3.0.0 - * - * @param {number} scale - The value to scale this Vector by. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - scale: function (scale) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - this.w *= scale; - - return this; - }, - - /** - * Calculate the length (or magnitude) of this Vector. - * - * @method Phaser.Math.Vector4#length - * @since 3.0.0 - * - * @return {number} The length of this Vector. - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return Math.sqrt(x * x + y * y + z * z + w * w); - }, - - /** - * Calculate the length of this Vector squared. - * - * @method Phaser.Math.Vector4#lengthSq - * @since 3.0.0 - * - * @return {number} The length of this Vector, squared. - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return x * x + y * y + z * z + w * w; - }, - - /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. - * - * @method Phaser.Math.Vector4#normalize - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var len = x * x + y * y + z * z + w * w; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - this.w = w * len; - } - - return this; - }, - - /** - * Calculate the dot product of this Vector and the given Vector. - * - * @method Phaser.Math.Vector4#dot - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} v - The Vector4 to dot product with this Vector4. - * - * @return {number} The dot product of this Vector and the given Vector. - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; - }, - - /** - * Linearly interpolate between this Vector and the given Vector. - * - * Interpolates this Vector towards the given Vector. - * - * @method Phaser.Math.Vector4#lerp - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} v - The Vector4 to interpolate towards. - * @param {number} [t=0] - The interpolation percentage, between 0 and 1. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - this.w = aw + t * (v.w - aw); - - return this; - }, - - /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * - * @method Phaser.Math.Vector4#multiply - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to multiply this Vector by. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - multiply: function (v) - { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z || 1; - this.w *= v.w || 1; - - return this; - }, - - /** - * Perform a component-wise division between this Vector and the given Vector. - * - * Divides this Vector by the given Vector. - * - * @method Phaser.Math.Vector4#divide - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to divide this Vector by. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - divide: function (v) - { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z || 1; - this.w /= v.w || 1; - - return this; - }, - - /** - * Calculate the distance between this Vector and the given Vector. - * - * @method Phaser.Math.Vector4#distance - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] - * - * @return {number} The distance from this Vector to the given Vector. - */ - distance: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - var dw = v.w - this.w || 0; - - return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); - }, - - /** - * Calculate the distance between this Vector, and the given Vector, squared. - * - * @method Phaser.Math.Vector4#distanceSq - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. - * - * @return {number} The distance from this Vector to the given Vector, squared. - */ - distanceSq: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - var dw = v.w - this.w || 0; - - return dx * dx + dy * dy + dz * dz + dw * dw; - }, - - /** - * Negate the `x`, `y`, `z` and `w` components of this Vector. - * - * @method Phaser.Math.Vector4#negate - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - negate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - this.w = -this.w; - - return this; - }, - - /** - * Transform this Vector with the given Matrix. - * - * @method Phaser.Math.Vector4#transformMat4 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector4 with. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - transformMat4: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var m = mat.val; - - this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; - this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; - this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; - this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; - - return this; - }, - - /** - * Transform this Vector with the given Quaternion. - * - * @method Phaser.Math.Vector4#transformQuat - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - transformQuat: function (q) - { - // TODO: is this really the same as Vector3? - // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations - var x = this.x; - var y = this.y; - var z = this.z; - var qx = q.x; - var qy = q.y; - var qz = q.z; - var qw = q.w; - - // calculate quat * vec - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; - - return this; - }, - - /** - * Make this Vector the zero vector (0, 0, 0, 0). - * - * @method Phaser.Math.Vector4#reset - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - reset: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 0; - - return this; - } - -}); - -// TODO: Check if these are required internally, if not, remove. -Vector4.prototype.sub = Vector4.prototype.subtract; -Vector4.prototype.mul = Vector4.prototype.multiply; -Vector4.prototype.div = Vector4.prototype.divide; -Vector4.prototype.dist = Vector4.prototype.distance; -Vector4.prototype.distSq = Vector4.prototype.distanceSq; -Vector4.prototype.len = Vector4.prototype.length; -Vector4.prototype.lenSq = Vector4.prototype.lengthSq; - -module.exports = Vector4; - - -/***/ }), -/* 278 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -var EPSILON = 0.000001; - -/** - * @classdesc - * A four-dimensional matrix. - * - * @class Matrix4 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} [m] - Optional Matrix4 to copy values from. - */ -var Matrix4 = new Class({ - - initialize: - - function Matrix4 (m) - { - /** - * The matrix values. - * - * @name Phaser.Math.Matrix4#val - * @type {Float32Array} - * @since 3.0.0 - */ - this.val = new Float32Array(16); - - if (m) - { - // Assume Matrix4 with val: - this.copy(m); - } - else - { - // Default to identity - this.identity(); - } - }, - - /** - * Make a clone of this Matrix4. - * - * @method Phaser.Math.Matrix4#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} A clone of this Matrix4. - */ - clone: function () - { - return new Matrix4(this); - }, - - // TODO - Should work with basic values - - /** - * This method is an alias for `Matrix4.copy`. - * - * @method Phaser.Math.Matrix4#set - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} src - The Matrix to set the values of this Matrix's from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - set: function (src) - { - return this.copy(src); - }, - - /** - * Copy the values of a given Matrix into this Matrix. - * - * @method Phaser.Math.Matrix4#copy - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} src - The Matrix to copy the values from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - copy: function (src) - { - var out = this.val; - var a = src.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - - return this; - }, - - /** - * Set the values of this Matrix from the given array. - * - * @method Phaser.Math.Matrix4#fromArray - * @since 3.0.0 - * - * @param {array} a - The array to copy the values from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - fromArray: function (a) - { - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - - return this; - }, - - /** - * Reset this Matrix. - * - * Sets all values to `0`. - * - * @method Phaser.Math.Matrix4#zero - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - zero: function () - { - var out = this.val; - - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 0; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 0; - - return this; - }, - - /** - * Set the `x`, `y` and `z` values of this Matrix. - * - * @method Phaser.Math.Matrix4#xyz - * @since 3.0.0 - * - * @param {number} x - The x value. - * @param {number} y - The y value. - * @param {number} z - The z value. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - xyz: function (x, y, z) - { - this.identity(); - - var out = this.val; - - out[12] = x; - out[13] = y; - out[14] = z; - - return this; - }, - - /** - * Set the scaling values of this Matrix. - * - * @method Phaser.Math.Matrix4#scaling - * @since 3.0.0 - * - * @param {number} x - The x scaling value. - * @param {number} y - The y scaling value. - * @param {number} z - The z scaling value. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - scaling: function (x, y, z) - { - this.zero(); - - var out = this.val; - - out[0] = x; - out[5] = y; - out[10] = z; - out[15] = 1; - - return this; - }, - - /** - * Reset this Matrix to an identity (default) matrix. - * - * @method Phaser.Math.Matrix4#identity - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - identity: function () - { - var out = this.val; - - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - return this; - }, - - /** - * Transpose this Matrix. - * - * @method Phaser.Math.Matrix4#transpose - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - transpose: function () - { - var a = this.val; - - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - var a12 = a[6]; - var a13 = a[7]; - var a23 = a[11]; - - a[1] = a[4]; - a[2] = a[8]; - a[3] = a[12]; - a[4] = a01; - a[6] = a[9]; - a[7] = a[13]; - a[8] = a02; - a[9] = a12; - a[11] = a[14]; - a[12] = a03; - a[13] = a13; - a[14] = a23; - - return this; - }, - - /** - * Invert this Matrix. - * - * @method Phaser.Math.Matrix4#invert - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - invert: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) - { - return null; - } - - det = 1 / det; - - a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; - - return this; - }, - - /** - * Calculate the adjoint, or adjugate, of this Matrix. - * - * @method Phaser.Math.Matrix4#adjoint - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - adjoint: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); - a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); - a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); - a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); - a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); - a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); - a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); - a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); - a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); - a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); - a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); - a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); - a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); - a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); - a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); - a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); - - return this; - }, - - /** - * Calculate the determinant of this Matrix. - * - * @method Phaser.Math.Matrix4#determinant - * @since 3.0.0 - * - * @return {number} The determinant of this Matrix. - */ - determinant: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - }, - - /** - * Multiply this Matrix by the given Matrix. - * - * @method Phaser.Math.Matrix4#multiply - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} src - The Matrix to multiply this Matrix by. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - multiply: function (src) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b = src.val; - - // Cache only the current line of the second matrix - var b0 = b[0]; - var b1 = b[1]; - var b2 = b[2]; - var b3 = b[3]; - - a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[4]; - b1 = b[5]; - b2 = b[6]; - b3 = b[7]; - - a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[8]; - b1 = b[9]; - b2 = b[10]; - b3 = b[11]; - - a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[12]; - b1 = b[13]; - b2 = b[14]; - b3 = b[15]; - - a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#multiplyLocal - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} src - [description] - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - multiplyLocal: function (src) - { - var a = []; - var m1 = this.val; - var m2 = src.val; - - a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; - a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; - a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; - a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; - - a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; - a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; - a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; - a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; - - a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; - a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; - a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; - a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; - - a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; - a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; - a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; - a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; - - return this.fromArray(a); - }, - - /** - * Translate this Matrix using the given Vector. - * - * @method Phaser.Math.Matrix4#translate - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - translate: function (v) - { - var x = v.x; - var y = v.y; - var z = v.z; - var a = this.val; - - a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; - a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; - a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; - a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; - - return this; - }, - - /** - * Apply a scale transformation to this Matrix. - * - * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix. - * - * @method Phaser.Math.Matrix4#scale - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - scale: function (v) - { - var x = v.x; - var y = v.y; - var z = v.z; - var a = this.val; - - a[0] = a[0] * x; - a[1] = a[1] * x; - a[2] = a[2] * x; - a[3] = a[3] * x; - - a[4] = a[4] * y; - a[5] = a[5] * y; - a[6] = a[6] * y; - a[7] = a[7] * y; - - a[8] = a[8] * z; - a[9] = a[9] * z; - a[10] = a[10] * z; - a[11] = a[11] * z; - - return this; - }, - - /** - * Derive a rotation matrix around the given axis. - * - * @method Phaser.Math.Matrix4#makeRotationAxis - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis. - * @param {float} angle - The rotation angle in radians. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - makeRotationAxis: function (axis, angle) - { - // Based on http://www.gamedev.net/reference/articles/article1199.asp - - var c = Math.cos(angle); - var s = Math.sin(angle); - var t = 1 - c; - var x = axis.x; - var y = axis.y; - var z = axis.z; - var tx = t * x; - var ty = t * y; - - this.fromArray([ - tx * x + c, tx * y - s * z, tx * z + s * y, 0, - tx * y + s * z, ty * y + c, ty * z - s * x, 0, - tx * z - s * y, ty * z + s * x, t * z * z + c, 0, - 0, 0, 0, 1 - ]); - - return this; - }, - - /** - * Apply a rotation transformation to this Matrix. - * - * @method Phaser.Math.Matrix4#rotate - * @since 3.0.0 - * - * @param {float} rad - The angle in radians to rotate by. - * @param {Phaser.Math.Vector3} axis - The axis to rotate upon. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - rotate: function (rad, axis) - { - var a = this.val; - var x = axis.x; - var y = axis.y; - var z = axis.z; - var len = Math.sqrt(x * x + y * y + z * z); - - if (Math.abs(len) < EPSILON) - { - return null; - } - - len = 1 / len; - x *= len; - y *= len; - z *= len; - - var s = Math.sin(rad); - var c = Math.cos(rad); - var t = 1 - c; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Construct the elements of the rotation matrix - var b00 = x * x * t + c; - var b01 = y * x * t + z * s; - var b02 = z * x * t - y * s; - - var b10 = x * y * t - z * s; - var b11 = y * y * t + c; - var b12 = z * y * t + x * s; - - var b20 = x * z * t + y * s; - var b21 = y * z * t - x * s; - var b22 = z * z * t + c; - - // Perform rotation-specific matrix multiplication - a[0] = a00 * b00 + a10 * b01 + a20 * b02; - a[1] = a01 * b00 + a11 * b01 + a21 * b02; - a[2] = a02 * b00 + a12 * b01 + a22 * b02; - a[3] = a03 * b00 + a13 * b01 + a23 * b02; - a[4] = a00 * b10 + a10 * b11 + a20 * b12; - a[5] = a01 * b10 + a11 * b11 + a21 * b12; - a[6] = a02 * b10 + a12 * b11 + a22 * b12; - a[7] = a03 * b10 + a13 * b11 + a23 * b12; - a[8] = a00 * b20 + a10 * b21 + a20 * b22; - a[9] = a01 * b20 + a11 * b21 + a21 * b22; - a[10] = a02 * b20 + a12 * b21 + a22 * b22; - a[11] = a03 * b20 + a13 * b21 + a23 * b22; - - return this; - }, - - /** - * Rotate this matrix on its X axis. - * - * @method Phaser.Math.Matrix4#rotateX - * @since 3.0.0 - * - * @param {float} rad - The angle in radians to rotate by. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - rotateX: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Perform axis-specific matrix multiplication - a[4] = a10 * c + a20 * s; - a[5] = a11 * c + a21 * s; - a[6] = a12 * c + a22 * s; - a[7] = a13 * c + a23 * s; - a[8] = a20 * c - a10 * s; - a[9] = a21 * c - a11 * s; - a[10] = a22 * c - a12 * s; - a[11] = a23 * c - a13 * s; - - return this; - }, - - /** - * Rotate this matrix on its Y axis. - * - * @method Phaser.Math.Matrix4#rotateY - * @since 3.0.0 - * - * @param {float} rad - The angle to rotate by, in radians. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - rotateY: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Perform axis-specific matrix multiplication - a[0] = a00 * c - a20 * s; - a[1] = a01 * c - a21 * s; - a[2] = a02 * c - a22 * s; - a[3] = a03 * c - a23 * s; - a[8] = a00 * s + a20 * c; - a[9] = a01 * s + a21 * c; - a[10] = a02 * s + a22 * c; - a[11] = a03 * s + a23 * c; - - return this; - }, - - /** - * Rotate this matrix on its Z axis. - * - * @method Phaser.Math.Matrix4#rotateZ - * @since 3.0.0 - * - * @param {float} rad - The angle to rotate by, in radians. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - rotateZ: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - // Perform axis-specific matrix multiplication - a[0] = a00 * c + a10 * s; - a[1] = a01 * c + a11 * s; - a[2] = a02 * c + a12 * s; - a[3] = a03 * c + a13 * s; - a[4] = a10 * c - a00 * s; - a[5] = a11 * c - a01 * s; - a[6] = a12 * c - a02 * s; - a[7] = a13 * c - a03 * s; - - return this; - }, - - /** - * Set the values of this Matrix from the given rotation Quaternion and translation Vector. - * - * @method Phaser.Math.Matrix4#fromRotationTranslation - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to set rotation from. - * @param {Phaser.Math.Vector3} v - The Vector to set translation from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - fromRotationTranslation: function (q, v) - { - // Quaternion math - var out = this.val; - - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - - out[12] = v.x; - out[13] = v.y; - out[14] = v.z; - out[15] = 1; - - return this; - }, - - /** - * Set the values of this Matrix from the given Quaternion. - * - * @method Phaser.Math.Matrix4#fromQuat - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - fromQuat: function (q) - { - var out = this.val; - - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - return this; - }, - - /** - * Generate a frustum matrix with the given bounds. - * - * @method Phaser.Math.Matrix4#frustum - * @since 3.0.0 - * - * @param {number} left - The left bound of the frustum. - * @param {number} right - The right bound of the frustum. - * @param {number} bottom - The bottom bound of the frustum. - * @param {number} top - The top bound of the frustum. - * @param {number} near - The near bound of the frustum. - * @param {number} far - The far bound of the frustum. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - frustum: function (left, right, bottom, top, near, far) - { - var out = this.val; - - var rl = 1 / (right - left); - var tb = 1 / (top - bottom); - var nf = 1 / (near - far); - - out[0] = (near * 2) * rl; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = (near * 2) * tb; - out[6] = 0; - out[7] = 0; - - out[8] = (right + left) * rl; - out[9] = (top + bottom) * tb; - out[10] = (far + near) * nf; - out[11] = -1; - - out[12] = 0; - out[13] = 0; - out[14] = (far * near * 2) * nf; - out[15] = 0; - - return this; - }, - - /** - * Generate a perspective projection matrix with the given bounds. - * - * @method Phaser.Math.Matrix4#perspective - * @since 3.0.0 - * - * @param {number} fovy - Vertical field of view in radians - * @param {number} aspect - Aspect ratio. Typically viewport width /height. - * @param {number} near - Near bound of the frustum. - * @param {number} far - Far bound of the frustum. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - perspective: function (fovy, aspect, near, far) - { - var out = this.val; - var f = 1.0 / Math.tan(fovy / 2); - var nf = 1 / (near - far); - - out[0] = f / aspect; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = f; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = (far + near) * nf; - out[11] = -1; - - out[12] = 0; - out[13] = 0; - out[14] = (2 * far * near) * nf; - out[15] = 0; - - return this; - }, - - /** - * Generate a perspective projection matrix with the given bounds. - * - * @method Phaser.Math.Matrix4#perspectiveLH - * @since 3.0.0 - * - * @param {number} width - The width of the frustum. - * @param {number} height - The height of the frustum. - * @param {number} near - Near bound of the frustum. - * @param {number} far - Far bound of the frustum. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - perspectiveLH: function (width, height, near, far) - { - var out = this.val; - - out[0] = (2 * near) / width; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = (2 * near) / height; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = -far / (near - far); - out[11] = 1; - - out[12] = 0; - out[13] = 0; - out[14] = (near * far) / (near - far); - out[15] = 0; - - return this; - }, - - /** - * Generate an orthogonal projection matrix with the given bounds. - * - * @method Phaser.Math.Matrix4#ortho - * @since 3.0.0 - * - * @param {number} left - The left bound of the frustum. - * @param {number} right - The right bound of the frustum. - * @param {number} bottom - The bottom bound of the frustum. - * @param {number} top - The top bound of the frustum. - * @param {number} near - The near bound of the frustum. - * @param {number} far - The far bound of the frustum. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - ortho: function (left, right, bottom, top, near, far) - { - var out = this.val; - var lr = left - right; - var bt = bottom - top; - var nf = near - far; - - // Avoid division by zero - lr = (lr === 0) ? lr : 1 / lr; - bt = (bt === 0) ? bt : 1 / bt; - nf = (nf === 0) ? nf : 1 / nf; - - out[0] = -2 * lr; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = -2 * bt; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = 2 * nf; - out[11] = 0; - - out[12] = (left + right) * lr; - out[13] = (top + bottom) * bt; - out[14] = (far + near) * nf; - out[15] = 1; - - return this; - }, - - /** - * Generate a look-at matrix with the given eye position, focal point, and up axis. - * - * @method Phaser.Math.Matrix4#lookAt - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} eye - Position of the viewer - * @param {Phaser.Math.Vector3} center - Point the viewer is looking at - * @param {Phaser.Math.Vector3} up - vec3 pointing up. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - lookAt: function (eye, center, up) - { - var out = this.val; - - var eyex = eye.x; - var eyey = eye.y; - var eyez = eye.z; - - var upx = up.x; - var upy = up.y; - var upz = up.z; - - var centerx = center.x; - var centery = center.y; - var centerz = center.z; - - if (Math.abs(eyex - centerx) < EPSILON && - Math.abs(eyey - centery) < EPSILON && - Math.abs(eyez - centerz) < EPSILON) - { - return this.identity(); - } - - var z0 = eyex - centerx; - var z1 = eyey - centery; - var z2 = eyez - centerz; - - var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); - - z0 *= len; - z1 *= len; - z2 *= len; - - var x0 = upy * z2 - upz * z1; - var x1 = upz * z0 - upx * z2; - var x2 = upx * z1 - upy * z0; - - len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); - - if (!len) - { - x0 = 0; - x1 = 0; - x2 = 0; - } - else - { - len = 1 / len; - x0 *= len; - x1 *= len; - x2 *= len; - } - - var y0 = z1 * x2 - z2 * x1; - var y1 = z2 * x0 - z0 * x2; - var y2 = z0 * x1 - z1 * x0; - - len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); - - if (!len) - { - y0 = 0; - y1 = 0; - y2 = 0; - } - else - { - len = 1 / len; - y0 *= len; - y1 *= len; - y2 *= len; - } - - out[0] = x0; - out[1] = y0; - out[2] = z0; - out[3] = 0; - - out[4] = x1; - out[5] = y1; - out[6] = z1; - out[7] = 0; - - out[8] = x2; - out[9] = y2; - out[10] = z2; - out[11] = 0; - - out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); - out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); - out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); - out[15] = 1; - - return this; - }, - - /** - * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values. - * - * @method Phaser.Math.Matrix4#yawPitchRoll - * @since 3.0.0 - * - * @param {number} yaw - [description] - * @param {number} pitch - [description] - * @param {number} roll - [description] - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - yawPitchRoll: function (yaw, pitch, roll) - { - this.zero(); - _tempMat1.zero(); - _tempMat2.zero(); - - var m0 = this.val; - var m1 = _tempMat1.val; - var m2 = _tempMat2.val; - - // Rotate Z - var s = Math.sin(roll); - var c = Math.cos(roll); - - m0[10] = 1; - m0[15] = 1; - m0[0] = c; - m0[1] = s; - m0[4] = -s; - m0[5] = c; - - // Rotate X - s = Math.sin(pitch); - c = Math.cos(pitch); - - m1[0] = 1; - m1[15] = 1; - m1[5] = c; - m1[10] = c; - m1[9] = -s; - m1[6] = s; - - // Rotate Y - s = Math.sin(yaw); - c = Math.cos(yaw); - - m2[5] = 1; - m2[15] = 1; - m2[0] = c; - m2[2] = -s; - m2[8] = s; - m2[10] = c; - - this.multiplyLocal(_tempMat1); - this.multiplyLocal(_tempMat2); - - return this; - }, - - /** - * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix. - * - * @method Phaser.Math.Matrix4#setWorldMatrix - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} rotation - The rotation of the world matrix. - * @param {Phaser.Math.Vector3} position - The position of the world matrix. - * @param {Phaser.Math.Vector3} scale - The scale of the world matrix. - * @param {Phaser.Math.Matrix4} [viewMatrix] - The view matrix. - * @param {Phaser.Math.Matrix4} [projectionMatrix] - The projection matrix. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) - { - this.yawPitchRoll(rotation.y, rotation.x, rotation.z); - - _tempMat1.scaling(scale.x, scale.y, scale.z); - _tempMat2.xyz(position.x, position.y, position.z); - - this.multiplyLocal(_tempMat1); - this.multiplyLocal(_tempMat2); - - if (viewMatrix !== undefined) - { - this.multiplyLocal(viewMatrix); - } - - if (projectionMatrix !== undefined) - { - this.multiplyLocal(projectionMatrix); - } - - return this; - } - -}); - -var _tempMat1 = new Matrix4(); -var _tempMat2 = new Matrix4(); - -module.exports = Matrix4; - - -/***/ }), -/* 279 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Matrix4 = __webpack_require__(278); -var RandomXYZ = __webpack_require__(561); -var RandomXYZW = __webpack_require__(560); -var RotateVec3 = __webpack_require__(559); -var Set = __webpack_require__(70); -var Sprite3D = __webpack_require__(151); -var Vector2 = __webpack_require__(6); -var Vector3 = __webpack_require__(87); -var Vector4 = __webpack_require__(277); - -// Local cache vars -var tmpVec3 = new Vector3(); -var tmpVec4 = new Vector4(); -var dirvec = new Vector3(); -var rightvec = new Vector3(); -var billboardMatrix = new Matrix4(); - -// @author attribute https://github.com/mattdesl/cam3d/wiki - -/** - * @typedef {object} RayDef - * - * @property {Phaser.Math.Vector3} origin - [description] - * @property {Phaser.Math.Vector3} direction - [description] - */ - -/** - * @classdesc - * [description] - * - * @class Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var Camera = new Class({ - - initialize: - - function Camera (scene) - { - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#displayList - * @type {Phaser.GameObjects.DisplayList} - * @since 3.0.0 - */ - this.displayList = scene.sys.displayList; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#updateList - * @type {Phaser.GameObjects.UpdateList} - * @since 3.0.0 - */ - this.updateList = scene.sys.updateList; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#direction - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.direction = new Vector3(0, 0, -1); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#up - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.up = new Vector3(0, 1, 0); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#position - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.position = new Vector3(); - - // The mapping from 3D size units to pixels. - // In the default case 1 3D unit = 128 pixels. So a sprite that is - // 256 x 128 px in size will be 2 x 1 units. - // Change to whatever best fits your game assets. - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#pixelScale - * @type {number} - * @since 3.0.0 - */ - this.pixelScale = 128; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#projection - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.projection = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#view - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.view = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#combined - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.combined = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#invProjectionView - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.invProjectionView = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#near - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.near = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#far - * @type {number} - * @since 3.0.0 - */ - this.far = 100; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#ray - * @type {RayDef} - * @since 3.0.0 - */ - this.ray = { - origin: new Vector3(), - direction: new Vector3() - }; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#viewportWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.viewportWidth = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#viewportHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.viewportHeight = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#billboardMatrixDirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.billboardMatrixDirty = true; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#children - * @type {Phaser.Structs.Set.} - * @since 3.0.0 - */ - this.children = new Set(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setPosition: function (x, y, z) - { - this.position.set(x, y, z); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setPixelScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setPixelScale: function (value) - { - this.pixelScale = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#add - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite3D} sprite3D - [description] - * - * @return {Phaser.GameObjects.Sprite3D} [description] - */ - add: function (sprite3D) - { - this.children.set(sprite3D); - - this.updateChildren(); - - return sprite3D; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#remove - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - remove: function (child) - { - this.displayList.remove(child.gameObject); - this.updateList.remove(child.gameObject); - - this.children.delete(child); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#clear - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - clear: function () - { - var children = this.getChildren(); - - for (var i = 0; i < children.length; i++) - { - this.remove(children[i]); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#getChildren - * @since 3.0.0 - * - * @return {array} [description] - */ - getChildren: function () - { - return this.children.entries; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#create - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] - * @param {string} key - [description] - * @param {(string|number)} frame - [description] - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.Sprite3D} [description] - */ - create: function (x, y, z, key, frame, visible) - { - if (visible === undefined) { visible = true; } - - var child = new Sprite3D(this.scene, x, y, z, key, frame); - - this.displayList.add(child.gameObject); - this.updateList.add(child.gameObject); - - child.visible = visible; - - this.children.set(child); - - this.updateChildren(); - - return child; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#createMultiple - * @since 3.0.0 - * - * @param {number} quantity - [description] - * @param {string} key - [description] - * @param {(string|number)} frame - [description] - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.Sprite3D[]} [description] - */ - createMultiple: function (quantity, key, frame, visible) - { - if (visible === undefined) { visible = true; } - - var output = []; - - for (var i = 0; i < quantity; i++) - { - var child = new Sprite3D(this.scene, 0, 0, 0, key, frame); - - this.displayList.add(child.gameObject); - this.updateList.add(child.gameObject); - - child.visible = visible; - - this.children.set(child); - - output.push(child); - } - - return output; - }, - - // Create a bunch of Sprite3D objects in a rectangle - // size and spacing are Vec3s (or if integers are converted to vec3s) - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#createRect - * @since 3.0.0 - * - * @param {(number|{x:number,y:number})} size - [description] - * @param {(number|{x:number,y:number,z:number})} spacing - [description] - * @param {string} key - [description] - * @param {(string|number)} [frame] - [description] - * - * @return {Phaser.GameObjects.Sprite3D[]} [description] - */ - createRect: function (size, spacing, key, frame) - { - if (typeof size === 'number') { size = { x: size, y: size, z: size }; } - if (typeof spacing === 'number') { spacing = { x: spacing, y: spacing, z: spacing }; } - - var quantity = size.x * size.y * size.z; - - var sprites = this.createMultiple(quantity, key, frame); - - var i = 0; - - for (var z = 0.5 - (size.z / 2); z < (size.z / 2); z++) - { - for (var y = 0.5 - (size.y / 2); y < (size.y / 2); y++) - { - for (var x = 0.5 - (size.x / 2); x < (size.x / 2); x++) - { - var bx = (x * spacing.x); - var by = (y * spacing.y); - var bz = (z * spacing.z); - - sprites[i].position.set(bx, by, bz); - - i++; - } - } - } - - this.update(); - - return sprites; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#randomSphere - * @since 3.0.0 - * - * @param {number} [radius=1] - [description] - * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - randomSphere: function (radius, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - RandomXYZ(sprites[i].position, radius); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#randomCube - * @since 3.0.0 - * - * @param {float} [scale=1] - [description] - * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - randomCube: function (scale, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - RandomXYZW(sprites[i].position, scale); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#translateChildren - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec3 - [description] - * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - translateChildren: function (vec3, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - sprites[i].position.add(vec3); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#transformChildren - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat4 - [description] - * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - transformChildren: function (mat4, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - sprites[i].position.transformMat4(mat4); - } - - return this.update(); - }, - - /** - * Sets the width and height of the viewport. Does not update any matrices. - * - * @method Phaser.Cameras.Sprite3D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setViewport: function (width, height) - { - this.viewportWidth = width; - this.viewportHeight = height; - - return this.update(); - }, - - /** - * Translates this camera by a specified Vector3 object - * or x, y, z parameters. Any undefined x y z values will - * default to zero, leaving that component unaffected. - * If you wish to set the camera position directly call setPosition instead. - * - * @method Phaser.Cameras.Sprite3D.Camera#translate - * @since 3.0.0 - * - * @param {(number|object)} x - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - translate: function (x, y, z) - { - if (typeof x === 'object') - { - this.position.x += x.x || 0; - this.position.y += x.y || 0; - this.position.z += x.z || 0; - } - else - { - this.position.x += x || 0; - this.position.y += y || 0; - this.position.z += z || 0; - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#lookAt - * @since 3.0.0 - * - * @param {(number|object)} x - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - lookAt: function (x, y, z) - { - var dir = this.direction; - var up = this.up; - - if (typeof x === 'object') - { - dir.copy(x); - } - else - { - dir.set(x, y, z); - } - - dir.subtract(this.position).normalize(); - - // Calculate right vector - tmpVec3.copy(dir).cross(up).normalize(); - - // Calculate up vector - up.copy(tmpVec3).cross(dir).normalize(); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#rotate - * @since 3.0.0 - * - * @param {float} radians - [description] - * @param {Phaser.Math.Vector3} axis - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - rotate: function (radians, axis) - { - RotateVec3(this.direction, axis, radians); - RotateVec3(this.up, axis, radians); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#rotateAround - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} point - [description] - * @param {float} radians - [description] - * @param {Phaser.Math.Vector3} axis - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - rotateAround: function (point, radians, axis) - { - tmpVec3.copy(point).subtract(this.position); - - this.translate(tmpVec3); - this.rotate(radians, axis); - this.translate(tmpVec3.negate()); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#project - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec - [description] - * @param {Phaser.Math.Vector4} out - [description] - * - * @return {Phaser.Math.Vector4} [description] - */ - project: function (vec, out) - { - if (out === undefined) { out = new Vector4(); } - - // TODO: support viewport XY - var viewportWidth = this.viewportWidth; - var viewportHeight = this.viewportHeight; - var n = Camera.NEAR_RANGE; - var f = Camera.FAR_RANGE; - - // For useful Z and W values we should do the usual steps: clip space -> NDC -> window coords - - // Implicit 1.0 for w component - tmpVec4.set(vec.x, vec.y, vec.z, 1.0); - - // Transform into clip space - tmpVec4.transformMat4(this.combined); - - // Avoid divide by zero when 0x0x0 camera projects to a 0x0x0 vec3 - if (tmpVec4.w === 0) - { - tmpVec4.w = 1; - } - - // Now into NDC - tmpVec4.x = tmpVec4.x / tmpVec4.w; - tmpVec4.y = tmpVec4.y / tmpVec4.w; - tmpVec4.z = tmpVec4.z / tmpVec4.w; - - // And finally into window coordinates - out.x = viewportWidth / 2 * tmpVec4.x + (0 + viewportWidth / 2); - out.y = viewportHeight / 2 * tmpVec4.y + (0 + viewportHeight / 2); - out.z = (f - n) / 2 * tmpVec4.z + (f + n) / 2; - - // If the out vector has a fourth component, we also store (1/clip.w), same idea as gl_FragCoord.w - if (out.w === 0 || out.w) - { - out.w = 1 / tmpVec4.w; - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#unproject - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} vec - [description] - * @param {Phaser.Math.Vector3} out - [description] - * - * @return {Phaser.Math.Vector3} [description] - */ - unproject: function (vec, out) - { - if (out === undefined) { out = new Vector3(); } - - var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); - - return out.copy(vec).unproject(viewport, this.invProjectionView); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#getPickRay - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y] - [description] - * - * @return {RayDef} [description] - */ - getPickRay: function (x, y) - { - var origin = this.ray.origin.set(x, y, 0); - var direction = this.ray.direction.set(x, y, 1); - var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); - var mtx = this.invProjectionView; - - origin.unproject(viewport, mtx); - - direction.unproject(viewport, mtx); - - direction.subtract(origin).normalize(); - - return this.ray; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#updateChildren - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - updateChildren: function () - { - var children = this.children.entries; - - for (var i = 0; i < children.length; i++) - { - children[i].project(this); - } - - return this; - }, - - // Overriden by subclasses - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#update - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - update: function () - { - return this.updateChildren(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#updateBillboardMatrix - * @since 3.0.0 - */ - updateBillboardMatrix: function () - { - var dir = dirvec.set(this.direction).negate(); - - // Better view-aligned billboards might use this: - // var dir = tmp.set(camera.position).subtract(p).normalize(); - - var right = rightvec.set(this.up).cross(dir).normalize(); - var up = tmpVec3.set(dir).cross(right).normalize(); - - var out = billboardMatrix.val; - - out[0] = right.x; - out[1] = right.y; - out[2] = right.z; - out[3] = 0; - - out[4] = up.x; - out[5] = up.y; - out[6] = up.z; - out[7] = 0; - - out[8] = dir.x; - out[9] = dir.y; - out[10] = dir.z; - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - this.billboardMatrixDirty = false; - }, - - /** - * This is a utility function for canvas 3D rendering, - * which determines the "point size" of a camera-facing - * sprite billboard given its 3D world position - * (origin at center of sprite) and its world width - * and height in x/y. - * - * We place into the output Vector2 the scaled width - * and height. If no `out` is specified, a new Vector2 - * will be created for convenience (this should be avoided - * in tight loops). - * - * @method Phaser.Cameras.Sprite3D.Camera#getPointSize - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} vec - The position of the 3D Sprite. - * @param {Phaser.Math.Vector2} size - The x and y dimensions. - * @param {Phaser.Math.Vector2} out - The result, scaled x and y dimensions. - * - * @return {Phaser.Math.Vector2} [description] - */ - getPointSize: function (vec, size, out) - { - if (out === undefined) { out = new Vector2(); } - - // TODO: optimize this with a simple distance calculation: - // https://developer.valvesoftware.com/wiki/Field_of_View - - if (this.billboardMatrixDirty) - { - this.updateBillboardMatrix(); - } - - var tmp = tmpVec3; - - var dx = (size.x / this.pixelScale) / 2; - var dy = (size.y / this.pixelScale) / 2; - - tmp.set(-dx, -dy, 0).transformMat4(billboardMatrix).add(vec); - - this.project(tmp, tmp); - - var tlx = tmp.x; - var tly = tmp.y; - - tmp.set(dx, dy, 0).transformMat4(billboardMatrix).add(vec); - - this.project(tmp, tmp); - - var brx = tmp.x; - var bry = tmp.y; - - // var w = Math.abs(brx - tlx); - // var h = Math.abs(bry - tly); - - // Allow the projection to get negative ... - var w = brx - tlx; - var h = bry - tly; - - return out.set(w, h); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.children.clear(); - - this.scene = undefined; - this.children = undefined; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setX: function (value) - { - this.position.x = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setY: function (value) - { - this.position.y = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setZ - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setZ: function (value) - { - this.position.z = value; - - return this.update(); - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#x - * @type {number} - * @since 3.0.0 - */ - x: { - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - this.update(); - } - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#y - * @type {number} - * @since 3.0.0 - */ - y: { - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - this.update(); - } - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#z - * @type {number} - * @since 3.0.0 - */ - z: { - get: function () - { - return this.position.z; - }, - - set: function (value) - { - this.position.z = value; - this.update(); - } - } - -}); - -Camera.FAR_RANGE = 1.0; -Camera.NEAR_RANGE = 0.0; - -module.exports = Camera; - - -/***/ }), -/* 280 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); - -/** - * Converts a CSS 'web' string into a Phaser Color object. - * - * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. - * - * @function Phaser.Display.Color.RGBStringToColor - * @since 3.0.0 - * - * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. - * - * @return {Phaser.Display.Color} A Color object. - */ -var RGBStringToColor = function (rgb) -{ - var color = new Color(); - - var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); - - if (result) - { - var r = parseInt(result[1], 10); - var g = parseInt(result[2], 10); - var b = parseInt(result[3], 10); - var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; - - color.setTo(r, g, b, a * 255); - } - - return color; -}; - -module.exports = RGBStringToColor; - - -/***/ }), -/* 281 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); - -/** - * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. - * - * @function Phaser.Display.Color.ObjectToColor - * @since 3.0.0 - * - * @param {InputColorObject} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. - * - * @return {Phaser.Display.Color} A Color object. - */ -var ObjectToColor = function (input) -{ - return new Color(input.r, input.g, input.b, input.a); -}; - -module.exports = ObjectToColor; - - -/***/ }), -/* 282 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Return the component parts of a color as an Object with the properties alpha, red, green, blue. - * - * Alpha will only be set if it exists in the given color (0xAARRGGBB) - * - * @function Phaser.Display.Color.IntegerToRGB - * @since 3.0.0 - * - * @param {integer} input - The color value to convert into a Color object. - * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. - */ -var IntegerToRGB = function (color) -{ - if (color > 16777215) - { - // The color value has an alpha component - return { - a: color >>> 24, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; - } - else - { - return { - a: 255, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; - } -}; - -module.exports = IntegerToRGB; - - -/***/ }), -/* 283 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); -var IntegerToRGB = __webpack_require__(282); - -/** - * Converts the given color value into an instance of a Color object. - * - * @function Phaser.Display.Color.IntegerToColor - * @since 3.0.0 - * - * @param {integer} input - The color value to convert into a Color object. - * - * @return {Phaser.Display.Color} A Color object. - */ -var IntegerToColor = function (input) -{ - var rgb = IntegerToRGB(input); - - return new Color(rgb.r, rgb.g, rgb.b, rgb.a); -}; - -module.exports = IntegerToColor; - - -/***/ }), -/* 284 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Given an alpha and 3 color values this will return an integer representation of it. - * - * @function Phaser.Display.Color.GetColor32 - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * @param {integer} alpha - The alpha color value. A number between 0 and 255. - * - * @return {number} The combined color value. - */ -var GetColor32 = function (red, green, blue, alpha) -{ - return alpha << 24 | red << 16 | green << 8 | blue; -}; - -module.exports = GetColor32; - - -/***/ }), -/* 285 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); - -/** - * Converts a hex string into a Phaser Color object. - * - * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. - * - * An alpha channel is _not_ supported. - * - * @function Phaser.Display.Color.HexStringToColor - * @since 3.0.0 - * - * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. - * - * @return {Phaser.Display.Color} A Color object populated by the values of the given string. - */ -var HexStringToColor = function (hex) -{ - var color = new Color(); - - // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") - hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) - { - return r + r + g + g + b + b; - }); - - var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); - - if (result) - { - var r = parseInt(result[1], 16); - var g = parseInt(result[2], 16); - var b = parseInt(result[3], 16); - - color.setTo(r, g, b); - } - - return color; -}; - -module.exports = HexStringToColor; - - -/***/ }), -/* 286 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate a smooth interpolation percentage of `x` between `min` and `max`. - * - * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, - * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, - * between 0 and 1 otherwise. - * - * @function Phaser.Math.SmoothStep - * @since 3.0.0 - * @see {@link https://en.wikipedia.org/wiki/Smoothstep} - * - * @param {number} x - The input value. - * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - * - * @return {number} The percentage of interpolation, between 0 and 1. - */ -var SmoothStep = function (x, min, max) -{ - if (x <= min) - { - return 0; - } - - if (x >= max) - { - return 1; - } - - x = (x - min) / (max - min); - - return x * x * (3 - 2 * x); -}; - -module.exports = SmoothStep; - - -/***/ }), -/* 287 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate a smoother interpolation percentage of `x` between `min` and `max`. - * - * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, - * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, - * between 0 and 1 otherwise. - * - * Produces an even smoother interpolation than {@link Phaser.Math.SmoothStep}. - * - * @function Phaser.Math.SmootherStep - * @since 3.0.0 - * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} - * - * @param {number} x - The input value. - * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - * - * @return {number} The percentage of interpolation, between 0 and 1. - */ -var SmootherStep = function (x, min, max) -{ - x = Math.max(0, Math.min(1, (x - min) / (max - min))); - - return x * x * x * (x * (x * 6 - 15) + 10); -}; - -module.exports = SmootherStep; - - -/***/ }), -/* 288 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RotateAroundDistance - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. - * @param {number} x - The horizontal coordinate to rotate around. - * @param {number} y - The vertical coordinate to rotate around. - * @param {number} angle - The angle of rotation in radians. - * @param {number} distance - [description] - * - * @return {Phaser.Geom.Point} The given point. - */ -var RotateAroundDistance = function (point, x, y, angle, distance) -{ - var t = angle + Math.atan2(point.y - y, point.x - x); - - point.x = x + (distance * Math.cos(t)); - point.y = y + (distance * Math.sin(t)); - - return point; -}; - -module.exports = RotateAroundDistance; - - -/***/ }), -/* 289 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the element at the end of the array to the start, shifting all items in the process. - * The "rotation" happens to the right. - * - * @function Phaser.Utils.Array.RotateRight - * @since 3.0.0 - * - * @param {array} array - The array to shift to the right. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. - * - * @return {*} The most recently shifted element. - */ -var RotateRight = function (array, total) -{ - if (total === undefined) { total = 1; } - - var element = null; - - for (var i = 0; i < total; i++) - { - element = array.pop(); - array.unshift(element); - } - - return element; -}; - -module.exports = RotateRight; - - -/***/ }), -/* 290 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the element at the start of the array to the end, shifting all items in the process. - * The "rotation" happens to the left. - * - * @function Phaser.Utils.Array.RotateLeft - * @since 3.0.0 - * - * @param {array} array - The array to shift to the left. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. - * - * @return {*} The most recently shifted element. - */ -var RotateLeft = function (array, total) -{ - if (total === undefined) { total = 1; } - - var element = null; - - for (var i = 0; i < total; i++) - { - element = array.shift(); - array.push(element); - } - - return element; -}; - -module.exports = RotateLeft; - - -/***/ }), -/* 291 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for setting the WebGL rendering pipeline of a Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline - * @webglOnly - * @since 3.0.0 - */ - -var Pipeline = { - - /** - * The initial WebGL pipeline of this Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - defaultPipeline: null, - - /** - * The current WebGL pipeline of this Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline#pipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - pipeline: null, - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#initPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - initPipeline: function (pipelineName) - { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.defaultPipeline = renderer.getPipeline(pipelineName); - this.pipeline = this.defaultPipeline; - - return true; - } - - return false; - }, - - /** - * Sets the active WebGL Pipeline of this Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#setPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - setPipeline: function (pipelineName) - { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.pipeline = renderer.getPipeline(pipelineName); - - return true; - } - - return false; - }, - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * - * @method Phaser.GameObjects.Components.Pipeline#resetPipeline - * @webglOnly - * @since 3.0.0 - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - resetPipeline: function () - { - this.pipeline = this.defaultPipeline; - - return (this.pipeline !== null); - }, - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - * - * @method Phaser.GameObjects.Components.Pipeline#getPipelineName - * @webglOnly - * @since 3.0.0 - * - * @return {string} The string-based name of the pipeline being used by this Game Object. - */ - getPipelineName: function () - { - return this.pipeline.name; - } - -}; - -module.exports = Pipeline; - - -/***/ }), -/* 292 */ +/* 396 */ /***/ (function(module, exports) { /** @@ -66861,7 +90391,7 @@ module.exports = RotateAround; /***/ }), -/* 293 */ +/* 397 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -66870,24 +90400,21 @@ module.exports = RotateAround; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -// Get a point on the given line 'progress' percentage along its length. -// progress is a value between 0 and 1. +var Point = __webpack_require__(6); /** - * [description] + * Get a point on a line that's a given percentage along its length. * * @function Phaser.Geom.Line.GetPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Line} line - [description] - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {(Phaser.Geom.Point|object)} [out] - [description] + * @param {Phaser.Geom.Line} line - The line. + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point, or point-like object, to store the coordinates of the point on the line. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} The point on the line. */ var GetPoint = function (line, position, out) { @@ -66903,7 +90430,7 @@ module.exports = GetPoint; /***/ }), -/* 294 */ +/* 398 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -66912,26 +90439,26 @@ module.exports = GetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetPoint = __webpack_require__(135); -var Perimeter = __webpack_require__(97); +var GetPoint = __webpack_require__(190); +var Perimeter = __webpack_require__(124); // Return an array of points from the perimeter of the rectangle // each spaced out based on the quantity or step required /** - * [description] + * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. * * @function Phaser.Geom.Rectangle.GetPoints * @since 3.0.0 * * @generic {Phaser.Geom.Point[]} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle object to get the points from. * @param {number} step - [description] * @param {integer} quantity - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] + * @param {(array|Phaser.Geom.Point[])} [out] - An optional array to store the points in. * - * @return {(array|Phaser.Geom.Point[])} [description] + * @return {(array|Phaser.Geom.Point[])} An array of Points from the perimeter of the rectangle. */ var GetPoints = function (rectangle, quantity, stepRate, out) { @@ -66957,7 +90484,515 @@ module.exports = GetPoints; /***/ }), -/* 295 */ +/* 399 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Depth + * @since 3.0.0 + */ + +var Depth = { + + /** + * Private internal value. Holds the depth of the Game Object. + * + * @name Phaser.GameObjects.Components.Depth#_depth + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _depth: 0, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @name Phaser.GameObjects.Components.Depth#depth + * @type {number} + * @since 3.0.0 + */ + depth: { + + get: function () + { + return this._depth; + }, + + set: function (value) + { + this.scene.sys.queueDepthSort(); + this._depth = value; + } + + }, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @method Phaser.GameObjects.Components.Depth#setDepth + * @since 3.0.0 + * + * @param {integer} value - The depth of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDepth: function (value) + { + if (value === undefined) { value = 0; } + + this.depth = value; + + return this; + } + +}; + +module.exports = Depth; + + +/***/ }), +/* 400 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(66); + +/** + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.BlendMode + * @since 3.0.0 + */ + +var BlendMode = { + + /** + * Private internal value. Holds the current blend mode. + * + * @name Phaser.GameObjects.Components.BlendMode#_blendMode + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _blendMode: BlendModes.NORMAL, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @name Phaser.GameObjects.Components.BlendMode#blendMode + * @type {(Phaser.BlendModes|string)} + * @since 3.0.0 + */ + blendMode: { + + get: function () + { + return this._blendMode; + }, + + set: function (value) + { + if (typeof value === 'string') + { + value = BlendModes[value]; + } + + value |= 0; + + if (value >= -1) + { + this._blendMode = value; + } + } + + }, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @method Phaser.GameObjects.Components.BlendMode#setBlendMode + * @since 3.0.0 + * + * @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST. + * + * @return {this} This Game Object instance. + */ + setBlendMode: function (value) + { + this.blendMode = value; + + return this; + } + +}; + +module.exports = BlendMode; + + +/***/ }), +/* 401 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); + +// bitmask flag for GameObject.renderMask +var _FLAG = 2; // 0010 + +/** + * Provides methods used for setting the alpha properties of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Alpha + * @since 3.0.0 + */ + +var Alpha = { + + /** + * Private internal value. Holds the global alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alpha: 1, + + /** + * Private internal value. Holds the top-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTL: 1, + + /** + * Private internal value. Holds the top-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTR: 1, + + /** + * Private internal value. Holds the bottom-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBL: 1, + + /** + * Private internal value. Holds the bottom-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBR: 1, + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + * + * @method Phaser.GameObjects.Components.Alpha#clearAlpha + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearAlpha: function () + { + return this.setAlpha(1); + }, + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * + * @method Phaser.GameObjects.Components.Alpha#setAlpha + * @since 3.0.0 + * + * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * + * @return {this} This Game Object instance. + */ + setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 1; } + + // Treat as if there is only one alpha value for the whole Game Object + if (topRight === undefined) + { + this.alpha = topLeft; + } + else + { + this._alphaTL = Clamp(topLeft, 0, 1); + this._alphaTR = Clamp(topRight, 0, 1); + this._alphaBL = Clamp(bottomLeft, 0, 1); + this._alphaBR = Clamp(bottomRight, 0, 1); + } + + return this; + }, + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + * + * @name Phaser.GameObjects.Components.Alpha#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alpha = v; + this._alphaTL = v; + this._alphaTR = v; + this._alphaBL = v; + this._alphaBR = v; + + if (v === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopLeft: { + + get: function () + { + return this._alphaTL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopRight: { + + get: function () + { + return this._alphaTR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomLeft: { + + get: function () + { + return this._alphaBL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomRight: { + + get: function () + { + return this._alphaBR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + } + +}; + +module.exports = Alpha; + + +/***/ }), +/* 402 */ /***/ (function(module, exports) { /** @@ -66985,7 +91020,7 @@ module.exports = Circumference; /***/ }), -/* 296 */ +/* 403 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -66994,9 +91029,9 @@ module.exports = Circumference; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circumference = __webpack_require__(295); -var CircumferencePoint = __webpack_require__(136); -var FromPercent = __webpack_require__(65); +var Circumference = __webpack_require__(402); +var CircumferencePoint = __webpack_require__(192); +var FromPercent = __webpack_require__(93); var MATH_CONST = __webpack_require__(16); /** @@ -67037,7 +91072,7 @@ module.exports = GetPoints; /***/ }), -/* 297 */ +/* 404 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -67050,14 +91085,23 @@ var Class = __webpack_require__(0); /** * @classdesc - * A seeded random data generator. + * A seeded Random Data Generator. + * + * Access via `Phaser.Math.RND` which is an instance of this class pre-defined + * by Phaser. Or, create your own instance to use as you require. + * + * The `Math.RND` generator is seeded by the Game Config property value `seed`. + * If no such config property exists, a random number is used. + * + * If you create your own instance of this class you should provide a seed for it. + * If no seed is given it will use a 'random' one based on Date.now. * * @class RandomDataGenerator - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * - * @param {string[]} [seeds] - The seeds. + * @param {(string|string[])} [seeds] - The seeds to use for the random number generator. */ var RandomDataGenerator = new Class({ @@ -67065,6 +91109,8 @@ var RandomDataGenerator = new Class({ function RandomDataGenerator (seeds) { + if (seeds === undefined) { seeds = [ (Date.now() * Math.random()).toString() ]; } + /** * Internal var. * @@ -67525,7 +91571,7 @@ module.exports = RandomDataGenerator; /***/ }), -/* 298 */ +/* 405 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -67534,10 +91580,10 @@ module.exports = RandomDataGenerator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CircumferencePoint = __webpack_require__(136); -var FromPercent = __webpack_require__(65); +var CircumferencePoint = __webpack_require__(192); +var FromPercent = __webpack_require__(93); var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); +var Point = __webpack_require__(6); /** * Returns a Point object containing the coordinates of a point on the circumference of the Circle @@ -67550,7 +91596,7 @@ var Point = __webpack_require__(5); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. @@ -67568,7 +91614,1244 @@ module.exports = GetPoint; /***/ }), -/* 299 */ +/* 406 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(44); +var GetTop = __webpack_require__(42); +var SetRight = __webpack_require__(43); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned in the top right of the other. + * + * @function Phaser.Display.Align.In.TopRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }), +/* 407 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(46); +var GetTop = __webpack_require__(42); +var SetLeft = __webpack_require__(45); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned in the top left of the other. + * + * @function Phaser.Display.Align.In.TopLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }), +/* 408 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterX = __webpack_require__(75); +var GetTop = __webpack_require__(42); +var SetCenterX = __webpack_require__(74); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned in the top center of the other. + * + * @function Phaser.Display.Align.In.TopCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }), +/* 409 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(72); +var GetRight = __webpack_require__(44); +var SetCenterY = __webpack_require__(73); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned in the right center of the other. + * + * @function Phaser.Display.Align.In.RightCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }), +/* 410 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(72); +var GetLeft = __webpack_require__(46); +var SetCenterY = __webpack_require__(73); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned in the left center of the other. + * + * @function Phaser.Display.Align.In.LeftCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }), +/* 411 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetCenterX = __webpack_require__(74); +var SetCenterY = __webpack_require__(73); + +/** + * Positions the Game Object so that it is centered on the given coordinates. + * + * @function Phaser.Display.Bounds.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The horizontal coordinate to position the Game Object on. + * @param {number} y - The vertical coordinate to position the Game Object on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var CenterOn = function (gameObject, x, y) +{ + SetCenterX(gameObject, x); + + return SetCenterY(gameObject, y); +}; + +module.exports = CenterOn; + + +/***/ }), +/* 412 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CenterOn = __webpack_require__(411); +var GetCenterX = __webpack_require__(75); +var GetCenterY = __webpack_require__(72); + +/** + * Takes given Game Object and aligns it so that it is positioned in the center of the other. + * + * @function Phaser.Display.Align.In.Center + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var Center = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = Center; + + +/***/ }), +/* 413 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetRight = __webpack_require__(44); +var SetBottom = __webpack_require__(47); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. + * + * @function Phaser.Display.Align.In.BottomRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }), +/* 414 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetLeft = __webpack_require__(46); +var SetBottom = __webpack_require__(47); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. + * + * @function Phaser.Display.Align.In.BottomLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }), +/* 415 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetCenterX = __webpack_require__(75); +var SetBottom = __webpack_require__(47); +var SetCenterX = __webpack_require__(74); + +/** + * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. + * + * @function Phaser.Display.Align.In.BottomCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }), +/* 416 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ALIGN_CONST = __webpack_require__(193); + +var AlignInMap = []; + +AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(415); +AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(414); +AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(413); +AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(412); +AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(410); +AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(409); +AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(408); +AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(407); +AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(406); + +/** + * Takes given Game Object and aligns it so that it is positioned relative to the other. + * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. + * + * @function Phaser.Display.Align.In.QuickSet + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [child,$return] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var QuickSet = function (child, alignIn, position, offsetX, offsetY) +{ + return AlignInMap[position](child, alignIn, offsetX, offsetY); +}; + +module.exports = QuickSet; + + +/***/ }), +/* 417 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Actions + */ + +module.exports = { + + Angle: __webpack_require__(1050), + Call: __webpack_require__(1049), + GetFirst: __webpack_require__(1048), + GetLast: __webpack_require__(1047), + GridAlign: __webpack_require__(1046), + IncAlpha: __webpack_require__(1035), + IncX: __webpack_require__(1034), + IncXY: __webpack_require__(1033), + IncY: __webpack_require__(1032), + PlaceOnCircle: __webpack_require__(1031), + PlaceOnEllipse: __webpack_require__(1030), + PlaceOnLine: __webpack_require__(1029), + PlaceOnRectangle: __webpack_require__(1028), + PlaceOnTriangle: __webpack_require__(1027), + PlayAnimation: __webpack_require__(1026), + PropertyValueInc: __webpack_require__(32), + PropertyValueSet: __webpack_require__(25), + RandomCircle: __webpack_require__(1025), + RandomEllipse: __webpack_require__(1024), + RandomLine: __webpack_require__(1023), + RandomRectangle: __webpack_require__(1022), + RandomTriangle: __webpack_require__(1021), + Rotate: __webpack_require__(1020), + RotateAround: __webpack_require__(1019), + RotateAroundDistance: __webpack_require__(1018), + ScaleX: __webpack_require__(1017), + ScaleXY: __webpack_require__(1016), + ScaleY: __webpack_require__(1015), + SetAlpha: __webpack_require__(1014), + SetBlendMode: __webpack_require__(1013), + SetDepth: __webpack_require__(1012), + SetHitArea: __webpack_require__(1011), + SetOrigin: __webpack_require__(1010), + SetRotation: __webpack_require__(1009), + SetScale: __webpack_require__(1008), + SetScaleX: __webpack_require__(1007), + SetScaleY: __webpack_require__(1006), + SetTint: __webpack_require__(1005), + SetVisible: __webpack_require__(1004), + SetX: __webpack_require__(1003), + SetXY: __webpack_require__(1002), + SetY: __webpack_require__(1001), + ShiftPosition: __webpack_require__(1000), + Shuffle: __webpack_require__(999), + SmootherStep: __webpack_require__(998), + SmoothStep: __webpack_require__(997), + Spread: __webpack_require__(996), + ToggleVisible: __webpack_require__(995), + WrapInRectangle: __webpack_require__(994) + +}; + + +/***/ }), +/* 418 */, +/* 419 */, +/* 420 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(895); +var TextureTintPipeline = __webpack_require__(196); + +var LIGHT_COUNT = 10; + +/** + * @classdesc + * ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights. + * This pipeline extends TextureTintPipeline so it implements all it's rendering functions + * and batching system. + * + * @class ForwardDiffuseLightPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline + * @memberof Phaser.Renderer.WebGL.Pipelines + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var ForwardDiffuseLightPipeline = new Class({ + + Extends: TextureTintPipeline, + + initialize: + + function ForwardDiffuseLightPipeline (config) + { + LIGHT_COUNT = config.maxLights; + + config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); + + TextureTintPipeline.call(this, config); + + /** + * Default normal map texture to use. + * + * @name Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#defaultNormalMap + * @type {Phaser.Texture.Frame} + * @private + * @since 3.11.0 + */ + this.defaultNormalMap; + }, + + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#boot + * @override + * @since 3.11.0 + */ + boot: function () + { + this.defaultNormalMap = this.game.textures.getFrame('__DEFAULT'); + }, + + /** + * This function binds its base class resources and this lights 2D resources. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onBind + * @override + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any. + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function (gameObject) + { + TextureTintPipeline.prototype.onBind.call(this); + + var renderer = this.renderer; + var program = this.program; + + this.mvpUpdate(); + + renderer.setInt1(program, 'uNormSampler', 1); + renderer.setFloat2(program, 'uResolution', this.width, this.height); + + if (gameObject) + { + this.setNormalMap(gameObject); + } + + return this; + }, + + /** + * This function sets all the needed resources for each camera pass. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onRender + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {this} This WebGLPipeline instance. + */ + onRender: function (scene, camera) + { + this.active = false; + + var lightManager = scene.sys.lights; + + if (!lightManager || lightManager.lights.length <= 0 || !lightManager.active) + { + // Passthru + return this; + } + + var lights = lightManager.cull(camera); + var lightCount = Math.min(lights.length, LIGHT_COUNT); + + if (lightCount === 0) + { + return this; + } + + this.active = true; + + var renderer = this.renderer; + var program = this.program; + var cameraMatrix = camera.matrix; + var point = {x: 0, y: 0}; + var height = renderer.height; + var index; + + for (index = 0; index < LIGHT_COUNT; ++index) + { + // Reset lights + renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); + } + + renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); + renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); + + for (index = 0; index < lightCount; ++index) + { + var light = lights[index]; + var lightName = 'uLights[' + index + '].'; + + cameraMatrix.transformPoint(light.x, light.y, point); + + renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); + renderer.setFloat1(program, lightName + 'intensity', light.intensity); + renderer.setFloat1(program, lightName + 'radius', light.radius); + } + + return this; + }, + + /** + * Generic function for batching a textured quad + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject + * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad + * @param {integer} textureWidth - Real texture width + * @param {integer} textureHeight - Real texture height + * @param {number} srcX - X coordinate of the quad + * @param {number} srcY - Y coordinate of the quad + * @param {number} srcWidth - Width of the quad + * @param {number} srcHeight - Height of the quad + * @param {number} scaleX - X component of scale + * @param {number} scaleY - Y component of scale + * @param {number} rotation - Rotation of the quad + * @param {boolean} flipX - Indicates if the quad is horizontally flipped + * @param {boolean} flipY - Indicates if the quad is vertically flipped + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll + * @param {number} displayOriginX - Horizontal origin in pixels + * @param {number} displayOriginY - Vertical origin in pixels + * @param {number} frameX - X coordinate of the texture frame + * @param {number} frameY - Y coordinate of the texture frame + * @param {number} frameWidth - Width of the texture frame + * @param {number} frameHeight - Height of the texture frame + * @param {integer} tintTL - Tint for top left + * @param {integer} tintTR - Tint for top right + * @param {integer} tintBL - Tint for bottom left + * @param {integer} tintBR - Tint for bottom right + * @param {number} tintEffect - The tint effect (0 for additive, 1 for replacement) + * @param {number} uOffset - Horizontal offset on texture coordinate + * @param {number} vOffset - Vertical offset on texture coordinate + * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container + */ + batchTexture: function ( + gameObject, + texture, + textureWidth, textureHeight, + srcX, srcY, + srcWidth, srcHeight, + scaleX, scaleY, + rotation, + flipX, flipY, + scrollFactorX, scrollFactorY, + displayOriginX, displayOriginY, + frameX, frameY, frameWidth, frameHeight, + tintTL, tintTR, tintBL, tintBR, tintEffect, + uOffset, vOffset, + camera, + parentTransformMatrix) + { + if (!this.active) + { + return; + } + + this.renderer.setPipeline(this); + + var normalTexture; + + if (gameObject.displayTexture) + { + normalTexture = gameObject.displayTexture.dataSource[gameObject.displayFrame.sourceIndex]; + } + else if (gameObject.texture) + { + normalTexture = gameObject.texture.dataSource[gameObject.frame.sourceIndex]; + } + else if (gameObject.tileset) + { + normalTexture = gameObject.tileset.image.dataSource[0]; + } + + if (!normalTexture) + { + console.warn('Normal map missing or invalid'); + return; + } + + this.setTexture2D(normalTexture.glTexture, 1); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var u0 = (frameX / textureWidth) + uOffset; + var v0 = (frameY / textureHeight) + vOffset; + var u1 = (frameX + frameWidth) / textureWidth + uOffset; + var v1 = (frameY + frameHeight) / textureHeight + vOffset; + + var width = srcWidth; + var height = srcHeight; + + // var x = -displayOriginX + frameX; + // var y = -displayOriginY + frameY; + + var x = -displayOriginX; + var y = -displayOriginY; + + if (gameObject.isCropped) + { + var crop = gameObject._crop; + + width = crop.width; + height = crop.height; + + srcWidth = crop.width; + srcHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + var ox = frameX; + var oy = frameY; + + if (flipX) + { + ox = (frameWidth - crop.x - crop.width); + } + + if (flipY && !texture.isRenderTexture) + { + oy = (frameHeight - crop.y - crop.height); + } + + u0 = (ox / textureWidth) + uOffset; + v0 = (oy / textureHeight) + vOffset; + u1 = (ox + crop.width) / textureWidth + uOffset; + v1 = (oy + crop.height) / textureHeight + vOffset; + + x = -displayOriginX + frameX; + y = -displayOriginY + frameY; + } + + // Invert the flipY if this is a RenderTexture + flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); + + if (flipX) + { + width *= -1; + x += srcWidth; + } + + if (flipY) + { + height *= -1; + y += srcHeight; + } + + // Do we need this? (doubt it) + // if (camera.roundPixels) + // { + // x |= 0; + // y |= 0; + // } + + var xw = x + width; + var yh = y + height; + + spriteMatrix.applyITRS(srcX, srcY, rotation, scaleX, scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * scrollFactorX, -camera.scrollY * scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = srcX; + spriteMatrix.f = srcY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * scrollFactorX; + spriteMatrix.f -= camera.scrollY * scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + this.setTexture2D(texture, 0); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + }, + + /** + * Sets the Game Objects normal map as the active texture. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#setNormalMap + * @since 3.11.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ + setNormalMap: function (gameObject) + { + if (!this.active || !gameObject) + { + return; + } + + var normalTexture; + + if (gameObject.texture) + { + normalTexture = gameObject.texture.dataSource[gameObject.frame.sourceIndex]; + } + + if (!normalTexture) + { + normalTexture = this.defaultNormalMap; + } + + this.setTexture2D(normalTexture.glTexture, 1); + + this.renderer.setPipeline(gameObject.defaultPipeline); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] + * + */ + batchSprite: function (sprite, camera, parentTransformMatrix) + { + if (!this.active) + { + return; + } + + var normalTexture = sprite.texture.dataSource[sprite.frame.sourceIndex]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + + this.setTexture2D(normalTexture.glTexture, 1); + + TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera, parentTransformMatrix); + } + } + +}); + +ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; + +module.exports = ForwardDiffuseLightPipeline; + + +/***/ }), +/* 421 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(897); +var ShaderSourceVS = __webpack_require__(896); +var WebGLPipeline = __webpack_require__(197); + +/** + * @classdesc + * BitmapMaskPipeline handles all bitmap masking rendering in WebGL. It works by using + * sampling two texture on the fragment shader and using the fragment's alpha to clip the region. + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + * + * @class BitmapMaskPipeline + * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @memberof Phaser.Renderer.WebGL.Pipelines + * @constructor + * @since 3.0.0 + * + * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. + */ +var BitmapMaskPipeline = new Class({ + + Extends: WebGLPipeline, + + initialize: + + function BitmapMaskPipeline (config) + { + WebGLPipeline.call(this, { + game: config.game, + renderer: config.renderer, + gl: config.renderer.gl, + topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), + vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), + fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), + vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), + + vertexSize: (config.vertexSize ? config.vertexSize : + Float32Array.BYTES_PER_ELEMENT * 2), + + vertices: new Float32Array([ + -1, +1, -1, -7, +7, +1 + ]).buffer, + + attributes: [ + { + name: 'inPosition', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: 0 + } + ] + }); + + /** + * Float32 view of the array buffer containing the pipeline's vertices. + * + * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#vertexViewF32 + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertexViewF32 = new Float32Array(this.vertexData); + + /** + * Size of the batch. + * + * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#maxQuads + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.maxQuads = 1; + + /** + * Dirty flag to check if resolution properties need to be updated on the + * masking shader. + * + * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resolutionDirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.resolutionDirty = true; + }, + + /** + * Called every time the pipeline needs to be used. + * It binds all necessary resources. + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#onBind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function () + { + WebGLPipeline.prototype.onBind.call(this); + + var renderer = this.renderer; + var program = this.program; + + if (this.resolutionDirty) + { + renderer.setFloat2(program, 'uResolution', this.width, this.height); + renderer.setInt1(program, 'uMainSampler', 0); + renderer.setInt1(program, 'uMaskSampler', 1); + this.resolutionDirty = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} resolution - [description] + * + * @return {this} This WebGLPipeline instance. + */ + resize: function (width, height, resolution) + { + WebGLPipeline.prototype.resize.call(this, width, height, resolution); + this.resolutionDirty = true; + return this; + }, + + /** + * Binds necessary resources and renders the mask to a separated framebuffer. + * The framebuffer for the masked object is also bound for further use. + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#beginMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - GameObject used as mask. + * @param {Phaser.GameObjects.GameObject} maskedObject - GameObject masked by the mask GameObject. + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + beginMask: function (mask, maskedObject, camera) + { + var renderer = this.renderer; + var gl = this.gl; + + // The renderable Game Object that is being used for the bitmap mask + var bitmapMask = mask.bitmapMask; + + if (bitmapMask && gl) + { + renderer.flush(); + + // First we clear the mask framebuffer + renderer.setFramebuffer(mask.maskFramebuffer); + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // We render our mask source + bitmapMask.renderWebGL(renderer, bitmapMask, 0, camera); + renderer.flush(); + + // Bind and clear our main source (masked object) + renderer.setFramebuffer(mask.mainFramebuffer); + + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + } + }, + + /** + * The masked game object's framebuffer is unbound and it's texture + * is bound together with the mask texture and the mask shader and + * a draw call with a single quad is processed. Here is where the + * masking effect is applied. + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#endMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - GameObject used as a mask. + */ + endMask: function (mask) + { + var renderer = this.renderer; + var gl = this.gl; + + // The renderable Game Object that is being used for the bitmap mask + var bitmapMask = mask.bitmapMask; + + if (bitmapMask && gl) + { + // Return to default framebuffer + renderer.setFramebuffer(null); + + // Bind bitmap mask pipeline and draw + renderer.setPipeline(this); + + renderer.setTexture2D(mask.maskTexture, 1); + renderer.setTexture2D(mask.mainTexture, 0); + renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); + + // Finally draw a triangle filling the whole screen + gl.drawArrays(this.topology, 0, 3); + } + } + +}); + +module.exports = BitmapMaskPipeline; + + +/***/ }), +/* 422 */ /***/ (function(module, exports) { /** @@ -67577,134 +92860,3103 @@ module.exports = GetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ALIGN_CONST = { +/** + * Takes a snapshot of the current frame displayed by a WebGL canvas. + * + * @function Phaser.Renderer.Snapshot.WebGL + * @since 3.0.0 + * + * @param {HTMLCanvasElement} sourceCanvas - The canvas to take a snapshot of. + * @param {string} [type='image/png'] - The format of the returned image. + * @param {number} [encoderOptions=0.92] - The image quality, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). + * + * @return {HTMLImageElement} A new image which contains a snapshot of the canvas's contents. + */ +var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) +{ + if (!type) { type = 'image/png'; } + if (!encoderOptions) { encoderOptions = 0.92; } - /** - * A constant representing a top-left alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_LEFT - * @since 3.0.0 - * @type {integer} - */ - TOP_LEFT: 0, + var gl = sourceCanvas.getContext('experimental-webgl'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); - /** - * A constant representing a top-center alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_CENTER - * @since 3.0.0 - * @type {integer} - */ - TOP_CENTER: 1, + // CanvasPool? + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + var imageData; - /** - * A constant representing a top-right alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_RIGHT - * @since 3.0.0 - * @type {integer} - */ - TOP_RIGHT: 2, + canvas.width = gl.drawingBufferWidth; + canvas.height = gl.drawingBufferHeight; - /** - * A constant representing a left-top alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_TOP - * @since 3.0.0 - * @type {integer} - */ - LEFT_TOP: 3, + imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - /** - * A constant representing a left-center alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_CENTER - * @since 3.0.0 - * @type {integer} - */ - LEFT_CENTER: 4, + var data = imageData.data; - /** - * A constant representing a left-bottom alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_BOTTOM - * @since 3.0.0 - * @type {integer} - */ - LEFT_BOTTOM: 5, + for (var y = 0; y < canvas.height; y += 1) + { + for (var x = 0; x < canvas.width; x += 1) + { + var si = ((canvas.height - y) * canvas.width + x) * 4; + var di = (y * canvas.width + x) * 4; + data[di + 0] = pixels[si + 0]; + data[di + 1] = pixels[si + 1]; + data[di + 2] = pixels[si + 2]; + data[di + 3] = pixels[si + 3]; + } + } - /** - * A constant representing a center alignment or position. - * @constant - * @name Phaser.Display.Align.CENTER - * @since 3.0.0 - * @type {integer} - */ - CENTER: 6, + ctx.putImageData(imageData, 0, 0); - /** - * A constant representing a right-top alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_TOP - * @since 3.0.0 - * @type {integer} - */ - RIGHT_TOP: 7, + var src = canvas.toDataURL(type, encoderOptions); + var image = new Image(); - /** - * A constant representing a right-center alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_CENTER - * @since 3.0.0 - * @type {integer} - */ - RIGHT_CENTER: 8, - - /** - * A constant representing a right-bottom alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_BOTTOM - * @since 3.0.0 - * @type {integer} - */ - RIGHT_BOTTOM: 9, - - /** - * A constant representing a bottom-left alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_LEFT - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_LEFT: 10, - - /** - * A constant representing a bottom-center alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_CENTER - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_CENTER: 11, - - /** - * A constant representing a bottom-right alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_RIGHT - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_RIGHT: 12 + image.src = src; + return image; }; -module.exports = ALIGN_CONST; +module.exports = WebGLSnapshot; /***/ }), -/* 300 */, -/* 301 */, -/* 302 */ +/* 423 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCamera = __webpack_require__(121); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(26); +var IsSizePowerOfTwo = __webpack_require__(117); +var SpliceOne = __webpack_require__(91); +var TransformMatrix = __webpack_require__(38); +var Utils = __webpack_require__(10); +var WebGLSnapshot = __webpack_require__(422); + +// Default Pipelines +var BitmapMaskPipeline = __webpack_require__(421); +var ForwardDiffuseLightPipeline = __webpack_require__(420); +var TextureTintPipeline = __webpack_require__(196); + +/** + * @callback WebGLContextCallback + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer which owns the context. + */ + +/** + * @typedef {object} SnapshotState + * + * @property {SnapshotCallback} callback - The function to call after the snapshot is taken. + * @property {string} type - The type of the image to create. + * @property {number} encoder - The image quality, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). + */ + +/** + * @classdesc + * WebGLRenderer is a class that contains the needed functionality to keep the + * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of + * any context change that happens for WebGL rendering inside of Phaser. This means + * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL + * rendering ecosystem they might pollute the current WebGLRenderingContext state producing + * unexpected behavior. It's recommended that WebGL interaction is done through + * WebGLRenderer and/or WebGLPipeline. + * + * @class WebGLRenderer + * @memberof Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Game instance which owns this WebGL Renderer. + */ +var WebGLRenderer = new Class({ + + initialize: + + function WebGLRenderer (game) + { + // eslint-disable-next-line consistent-this + var renderer = this; + + var gameConfig = game.config; + + var contextCreationConfig = { + alpha: gameConfig.transparent, + depth: false, // enable when 3D is added in the future + antialias: gameConfig.antialias, + premultipliedAlpha: gameConfig.premultipliedAlpha, + stencil: true, + preserveDrawingBuffer: gameConfig.preserveDrawingBuffer, + failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat, + powerPreference: gameConfig.powerPreference + }; + + /** + * The local configuration settings of this WebGL Renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: gameConfig.clearBeforeRender, + antialias: gameConfig.antialias, + backgroundColor: gameConfig.backgroundColor, + contextCreation: contextCreationConfig, + resolution: gameConfig.resolution, + autoResize: gameConfig.autoResize, + roundPixels: gameConfig.roundPixels, + maxTextures: gameConfig.maxTextures, + maxTextureSize: gameConfig.maxTextureSize, + batchSize: gameConfig.batchSize, + maxLights: gameConfig.maxLights + }; + + /** + * The Game instance which owns this WebGL Renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * A constant which allows the renderer to be easily identified as a WebGL Renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.WEBGL; + + /** + * The width of the canvas being rendered to. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#width + * @type {integer} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * The height of the canvas being rendered to. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#height + * @type {integer} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * The canvas which this WebGL Renderer draws to. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = game.canvas; + + /** + * An array of functions to invoke if the WebGL context is lost. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.lostContextCallbacks = []; + + /** + * An array of functions to invoke if the WebGL context is restored. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.restoredContextCallbacks = []; + + /** + * An array of blend modes supported by the WebGL Renderer. + * + * This array includes the default blend modes as well as any custom blend modes added through {@link #addBlendMode}. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.blendModes = []; + + /** + * Keeps track of any WebGLTexture created with the current WebGLRenderingContext + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.nativeTextures = []; + + /** + * Set to `true` if the WebGL context of the renderer is lost. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.contextLost = false; + + /** + * This object will store all pipelines created through addPipeline + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines + * @type {object} + * @default null + * @since 3.0.0 + */ + this.pipelines = null; + + /** + * Details about the currently scheduled snapshot. + * + * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState + * @type {SnapshotState} + * @since 3.0.0 + */ + this.snapshotState = { + callback: null, + type: null, + encoder: null + }; + + // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) + + /** + * Cached value for the last texture unit that was used + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit + * @type {integer} + * @since 3.1.0 + */ + this.currentActiveTextureUnit = 0; + + /** + * An array of the last texture handles that were bound to the WebGLRenderingContext + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures + * @type {array} + * @since 3.0.0 + */ + this.currentTextures = new Array(16); + + /** + * Current framebuffer in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer + * @type {WebGLFramebuffer} + * @default null + * @since 3.0.0 + */ + this.currentFramebuffer = null; + + /** + * Current WebGLPipeline in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @since 3.0.0 + */ + this.currentPipeline = null; + + /** + * Current WebGLProgram in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram + * @type {WebGLProgram} + * @default null + * @since 3.0.0 + */ + this.currentProgram = null; + + /** + * Current WebGLBuffer (Vertex buffer) in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentVertexBuffer = null; + + /** + * Current WebGLBuffer (Index buffer) in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentIndexBuffer = null; + + /** + * Current blend mode in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode + * @type {integer} + * @since 3.0.0 + */ + this.currentBlendMode = Infinity; + + /** + * Indicates if the the scissor state is enabled in WebGLRenderingContext + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.currentScissorEnabled = false; + + /** + * Stores the current scissor data + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor + * @type {Uint32Array} + * @since 3.0.0 + */ + // this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); + this.currentScissor = null; + + /** + * Stack of scissor data + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack + * @type {Uint32Array} + * @since 3.0.0 + */ + this.scissorStack = []; + + // Setup context lost and restore event listeners + + this.canvas.addEventListener('webglcontextlost', function (event) + { + renderer.contextLost = true; + event.preventDefault(); + + for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) + { + var callback = renderer.lostContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + this.canvas.addEventListener('webglcontextrestored', function () + { + renderer.contextLost = false; + renderer.init(renderer.config); + for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) + { + var callback = renderer.restoredContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + // These are initialized post context creation + + /** + * The underlying WebGL context of the renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#gl + * @type {WebGLRenderingContext} + * @default null + * @since 3.0.0 + */ + this.gl = null; + + /** + * Array of strings that indicate which WebGL extensions are supported by the browser + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions + * @type {object} + * @default null + * @since 3.0.0 + */ + this.supportedExtensions = null; + + /** + * Extensions loaded into the current context + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.extensions = {}; + + /** + * Stores the current WebGL component formats for further use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats + * @type {array} + * @default [] + * @since 3.2.0 + */ + this.glFormats = []; + + /** + * Stores the supported WebGL texture compression formats. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#compression + * @type {array} + * @since 3.8.0 + */ + this.compression = { + ETC1: false, + PVRTC: false, + S3TC: false + }; + + /** + * Cached drawing buffer height to reduce gl calls. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#drawingBufferHeight + * @type {number} + * @readonly + * @since 3.11.0 + */ + this.drawingBufferHeight = 0; + + /** + * A blank 32x32 transparent texture, as used by the Graphics system where needed. + * This is set in the `boot` method. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#blankTexture + * @type {WebGLTexture} + * @readonly + * @since 3.12.0 + */ + this.blankTexture = null; + + this.defaultCamera = new BaseCamera(0, 0, 0, 0); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + this.init(this.config); + }, + + /** + * Creates a new WebGLRenderingContext and initializes all internal + * state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#init + * @since 3.0.0 + * + * @param {object} config - The configuration object for the renderer. + * + * @return {this} This WebGLRenderer instance. + */ + init: function (config) + { + var gl; + var canvas = this.canvas; + var clearColor = config.backgroundColor; + + // Did they provide their own context? + if (this.game.config.context) + { + gl = this.game.config.context; + } + else + { + gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); + } + + if (!gl || gl.isContextLost()) + { + this.contextLost = true; + + throw new Error('WebGL unsupported'); + } + + this.gl = gl; + + // Set it back into the Game, so developers can access it from there too + this.game.context = gl; + + for (var i = 0; i <= 16; i++) + { + this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); + } + + this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; + this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; + this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; + + this.glFormats[0] = gl.BYTE; + this.glFormats[1] = gl.SHORT; + this.glFormats[2] = gl.UNSIGNED_BYTE; + this.glFormats[3] = gl.UNSIGNED_SHORT; + this.glFormats[4] = gl.FLOAT; + + // Load supported extensions + var exts = gl.getSupportedExtensions(); + + if (!config.maxTextures) + { + config.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); + } + + if (!config.maxTextureSize) + { + config.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); + } + + var extString = 'WEBGL_compressed_texture_'; + var wkExtString = 'WEBKIT_' + extString; + + this.compression.ETC1 = gl.getExtension(extString + 'etc1') || gl.getExtension(wkExtString + 'etc1'); + this.compression.PVRTC = gl.getExtension(extString + 'pvrtc') || gl.getExtension(wkExtString + 'pvrtc'); + this.compression.S3TC = gl.getExtension(extString + 's3tc') || gl.getExtension(wkExtString + 's3tc'); + + this.supportedExtensions = exts; + + // Setup initial WebGL state + gl.disable(gl.DEPTH_TEST); + gl.disable(gl.CULL_FACE); + + // gl.disable(gl.SCISSOR_TEST); + + gl.enable(gl.BLEND); + gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); + + // Initialize all textures to null + for (var index = 0; index < this.currentTextures.length; ++index) + { + this.currentTextures[index] = null; + } + + // Clear previous pipelines and reload default ones + this.pipelines = {}; + + this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); + this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); + this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this, maxLights: config.maxLights })); + + this.setBlendMode(CONST.BlendModes.NORMAL); + + this.resize(this.width, this.height); + + this.game.events.once('texturesready', this.boot, this); + + return this; + }, + + /** + * Internal boot handler. Calls 'boot' on each pipeline. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#boot + * @private + * @since 3.11.0 + */ + boot: function () + { + for (var pipelineName in this.pipelines) + { + this.pipelines[pipelineName].boot(); + } + + var blank = this.game.textures.getFrame('__DEFAULT'); + + this.pipelines.TextureTintPipeline.currentFrame = blank; + + this.blankTexture = blank; + }, + + /** + * Resizes the drawing buffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#resize + * @since 3.0.0 + * + * @param {number} width - The width of the renderer. + * @param {number} height - The height of the renderer. + * + * @return {this} This WebGLRenderer instance. + */ + resize: function (width, height) + { + var gl = this.gl; + var pipelines = this.pipelines; + var resolution = this.config.resolution; + + this.width = Math.floor(width * resolution); + this.height = Math.floor(height * resolution); + + this.canvas.width = this.width; + this.canvas.height = this.height; + + if (this.config.autoResize) + { + this.canvas.style.width = (this.width / resolution) + 'px'; + this.canvas.style.height = (this.height / resolution) + 'px'; + } + + gl.viewport(0, 0, this.width, this.height); + + // Update all registered pipelines + for (var pipelineName in pipelines) + { + pipelines[pipelineName].resize(width, height, resolution); + } + + this.drawingBufferHeight = gl.drawingBufferHeight; + + this.defaultCamera.setSize(width, height); + + gl.scissor(0, (this.drawingBufferHeight - this.height), this.width, this.height); + + return this; + }, + + /** + * Adds a callback to be invoked when the WebGL context has been restored by the browser. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - The callback to be invoked on context restoration. + * @param {object} target - The context of the callback. + * + * @return {this} This WebGLRenderer instance. + */ + onContextRestored: function (callback, target) + { + this.restoredContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * Adds a callback to be invoked when the WebGL context has been lost by the browser. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - The callback to be invoked on context loss. + * @param {object} target - The context of the callback. + * + * @return {this} This WebGLRenderer instance. + */ + onContextLost: function (callback, target) + { + this.lostContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * Checks if a WebGL extension is supported + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension + * @since 3.0.0 + * + * @param {string} extensionName - Name of the WebGL extension + * + * @return {boolean} `true` if the extension is supported, otherwise `false`. + */ + hasExtension: function (extensionName) + { + return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; + }, + + /** + * Loads a WebGL extension + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension + * @since 3.0.0 + * + * @param {string} extensionName - The name of the extension to load. + * + * @return {object} WebGL extension if the extension is supported + */ + getExtension: function (extensionName) + { + if (!this.hasExtension(extensionName)) { return null; } + + if (!(extensionName in this.extensions)) + { + this.extensions[extensionName] = this.gl.getExtension(extensionName); + } + + return this.extensions[extensionName]; + }, + + /** + * Flushes the current pipeline if the pipeline is bound + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#flush + * @since 3.0.0 + */ + flush: function () + { + if (this.currentPipeline) + { + this.currentPipeline.flush(); + } + }, + + /** + * Checks if a pipeline is present in the current WebGLRenderer + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline. + * + * @return {boolean} `true` if the given pipeline is loaded, otherwise `false`. + */ + hasPipeline: function (pipelineName) + { + return (pipelineName in this.pipelines); + }, + + /** + * Returns the pipeline by name if the pipeline exists + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline. + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline instance, or `null` if not found. + */ + getPipeline: function (pipelineName) + { + return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; + }, + + /** + * Removes a pipeline by name. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to be removed. + * + * @return {this} This WebGLRenderer instance. + */ + removePipeline: function (pipelineName) + { + delete this.pipelines[pipelineName]; + + return this; + }, + + /** + * Adds a pipeline instance into the collection of pipelines + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - A unique string-based key for the pipeline. + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - A pipeline instance which must extend WebGLPipeline. + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipline instance that was passed. + */ + addPipeline: function (pipelineName, pipelineInstance) + { + if (!this.hasPipeline(pipelineName)) + { + this.pipelines[pipelineName] = pipelineInstance; + } + else + { + console.warn('Pipeline exists: ' + pipelineName); + } + + pipelineInstance.name = pipelineName; + + this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); + + return pipelineInstance; + }, + + /** + * Pushes a new scissor state. This is used to set nested scissor states. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor + * @since 3.0.0 + * + * @param {integer} x - The x position of the scissor. + * @param {integer} y - The y position of the scissor. + * @param {integer} width - The width of the scissor. + * @param {integer} height - The height of the scissor. + * + * @return {integer[]} An array containing the scissor values. + */ + pushScissor: function (x, y, width, height) + { + var scissorStack = this.scissorStack; + + var scissor = [ x, y, width, height ]; + + scissorStack.push(scissor); + + this.setScissor(x, y, width, height); + + this.currentScissor = scissor; + + return scissor; + }, + + /** + * Sets the current scissor state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor + * @since 3.0.0 + * + * @param {integer} x - The x position of the scissor. + * @param {integer} y - The y position of the scissor. + * @param {integer} width - The width of the scissor. + * @param {integer} height - The height of the scissor. + */ + setScissor: function (x, y, width, height) + { + var gl = this.gl; + + var current = this.currentScissor; + + var cx = current[0]; + var cy = current[1]; + var cw = current[2]; + var ch = current[3]; + + if (cx !== x || cy !== y || cw !== width || ch !== height) + { + this.flush(); + + // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/scissor + + if (width > 0 && height > 0) + { + gl.scissor(x, (this.drawingBufferHeight - y - height), width, height); + + } + } + }, + + /** + * Pops the last scissor state and sets it. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor + * @since 3.0.0 + */ + popScissor: function () + { + var scissorStack = this.scissorStack; + + // Remove the current scissor + scissorStack.pop(); + + // Reset the previous scissor + var scissor = scissorStack[scissorStack.length - 1]; + + if (scissor) + { + this.setScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + } + + this.currentScissor = scissor; + }, + + /** + * Binds a WebGLPipeline and sets it as the current pipeline to be used. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline + * @since 3.0.0 + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - The pipeline instance to be activated. + * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any. + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline that was activated. + */ + setPipeline: function (pipelineInstance, gameObject) + { + if (this.currentPipeline !== pipelineInstance || + this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || + this.currentPipeline.program !== this.currentProgram) + { + this.flush(); + this.currentPipeline = pipelineInstance; + this.currentPipeline.bind(); + } + + this.currentPipeline.onBind(gameObject); + + return this.currentPipeline; + }, + + /** + * Sets the blend mode to the value given. + * + * If the current blend mode is different from the one given, the pipeline is flushed and the new + * blend mode is enabled. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode + * @since 3.0.0 + * + * @param {integer} blendModeId - The blend mode to be set. Can be a `BlendModes` const or an integer value. + * + * @return {boolean} `true` if the blend mode was changed as a result of this call, forcing a flush, otherwise `false`. + */ + setBlendMode: function (blendModeId) + { + var gl = this.gl; + var blendMode = this.blendModes[blendModeId]; + + if (blendModeId !== CONST.BlendModes.SKIP_CHECK && this.currentBlendMode !== blendModeId) + { + this.flush(); + + gl.enable(gl.BLEND); + gl.blendEquation(blendMode.equation); + + if (blendMode.func.length > 2) + { + gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); + } + else + { + gl.blendFunc(blendMode.func[0], blendMode.func[1]); + } + + this.currentBlendMode = blendModeId; + + return true; + } + + return false; + }, + + /** + * Creates a new custom blend mode for the renderer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addBlendMode + * @since 3.0.0 + * + * @param {function} func - An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for {@link WebGLRenderingContext#blendFunc()}. + * @param {function} equation - The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for {@link WebGLRenderingContext#blendEquation()}. + * + * @return {integer} The index of the new blend mode, used for referencing it in the future. + */ + addBlendMode: function (func, equation) + { + var index = this.blendModes.push({ func: func, equation: equation }); + + return index - 1; + }, + + /** + * Updates the function bound to a given custom blend mode. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#updateBlendMode + * @since 3.0.0 + * + * @param {integer} index - The index of the custom blend mode. + * @param {function} func - The function to use for the blend mode. + * @param {function} equation - The equation to use for the blend mode. + * + * @return {this} This WebGLRenderer instance. + */ + updateBlendMode: function (index, func, equation) + { + if (this.blendModes[index]) + { + this.blendModes[index].func = func; + + if (equation) + { + this.blendModes[index].equation = equation; + } + } + + return this; + }, + + /** + * Removes a custom blend mode from the renderer. + * Any Game Objects still using this blend mode will error, so be sure to clear them first. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removeBlendMode + * @since 3.0.0 + * + * @param {integer} index - The index of the custom blend mode to be removed. + * + * @return {this} This WebGLRenderer instance. + */ + removeBlendMode: function (index) + { + if (index > 16 && this.blendModes[index]) + { + this.blendModes.splice(index, 1); + } + + return this; + }, + + /** + * Sets the current active texture for texture unit zero to be a blank texture. + * This only happens if there isn't a texture already in use by texture unit zero. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlankTexture + * @private + * @since 3.12.0 + * + * @param {boolean} [force=false] - Force a blank texture set, regardless of what's already bound? + */ + setBlankTexture: function (force) + { + if (force === undefined) { force = false; } + + if (force || this.currentActiveTextureUnit !== 0 || !this.currentTextures[0]) + { + this.setTexture2D(this.blankTexture.glTexture, 0); + } + }, + + /** + * Binds a texture at a texture unit. If a texture is already + * bound to that unit it will force a flush on the current pipeline. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D + * @since 3.0.0 + * + * @param {WebGLTexture} texture - The WebGL texture that needs to be bound. + * @param {integer} textureUnit - The texture unit to which the texture will be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setTexture2D: function (texture, textureUnit) + { + var gl = this.gl; + + if (texture !== this.currentTextures[textureUnit]) + { + this.flush(); + + if (this.currentActiveTextureUnit !== textureUnit) + { + gl.activeTexture(gl.TEXTURE0 + textureUnit); + + this.currentActiveTextureUnit = textureUnit; + } + + gl.bindTexture(gl.TEXTURE_2D, texture); + + this.currentTextures[textureUnit] = texture; + } + + return this; + }, + + /** + * Binds a framebuffer. If there was another framebuffer already bound it will force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setFramebuffer: function (framebuffer) + { + var gl = this.gl; + + var width = this.width; + var height = this.height; + + if (framebuffer !== this.currentFramebuffer) + { + if (framebuffer && framebuffer.renderTexture) + { + width = framebuffer.renderTexture.width; + height = framebuffer.renderTexture.height; + } + else + { + this.flush(); + } + + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + + gl.viewport(0, 0, width, height); + + this.currentFramebuffer = framebuffer; + } + + return this; + }, + + /** + * Binds a program. If there was another program already bound it will force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - The program that needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setProgram: function (program) + { + var gl = this.gl; + + if (program !== this.currentProgram) + { + this.flush(); + + gl.useProgram(program); + + this.currentProgram = program; + } + + return this; + }, + + /** + * Bounds a vertex buffer. If there is a vertex buffer already bound it'll force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - The buffer that needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setVertexBuffer: function (vertexBuffer) + { + var gl = this.gl; + + if (vertexBuffer !== this.currentVertexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + + this.currentVertexBuffer = vertexBuffer; + } + + return this; + }, + + /** + * Bounds a index buffer. If there is a index buffer already bound it'll force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} indexBuffer - The buffer the needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setIndexBuffer: function (indexBuffer) + { + var gl = this.gl; + + if (indexBuffer !== this.currentIndexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + + this.currentIndexBuffer = indexBuffer; + } + + return this; + }, + + /** + * Creates a texture from an image source. If the source is not valid it creates an empty texture. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource + * @since 3.0.0 + * + * @param {object} source - The source of the texture. + * @param {integer} width - The width of the texture. + * @param {integer} height - The height of the texture. + * @param {integer} scaleMode - The scale mode to be used by the texture. + * + * @return {?WebGLTexture} The WebGL Texture that was created, or `null` if it couldn't be created. + */ + createTextureFromSource: function (source, width, height, scaleMode) + { + var gl = this.gl; + var filter = gl.NEAREST; + var wrap = gl.CLAMP_TO_EDGE; + var texture = null; + + width = source ? source.width : width; + height = source ? source.height : height; + + if (IsSizePowerOfTwo(width, height)) + { + wrap = gl.REPEAT; + } + + if (scaleMode === CONST.ScaleModes.LINEAR && this.config.antialias) + { + filter = gl.LINEAR; + } + + if (!source && typeof width === 'number' && typeof height === 'number') + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + } + else + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); + } + + return texture; + }, + + /** + * A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D + * @since 3.0.0 + * + * @param {integer} mipLevel - Mip level of the texture. + * @param {integer} minFilter - Filtering of the texture. + * @param {integer} magFilter - Filtering of the texture. + * @param {integer} wrapT - Wrapping mode of the texture. + * @param {integer} wrapS - Wrapping mode of the texture. + * @param {integer} format - Which format does the texture use. + * @param {object} pixels - pixel data. + * @param {integer} width - Width of the texture in pixels. + * @param {integer} height - Height of the texture in pixels. + * @param {boolean} pma - Does the texture have premultiplied alpha? + * + * @return {WebGLTexture} The WebGLTexture that was created. + */ + createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) + { + pma = (pma === undefined || pma === null) ? true : pma; + + var gl = this.gl; + var texture = gl.createTexture(); + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); + + if (pixels === null || pixels === undefined) + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); + } + else + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); + width = pixels.width; + height = pixels.height; + } + + this.setTexture2D(null, 0); + + texture.isAlphaPremultiplied = pma; + texture.isRenderTexture = false; + texture.width = width; + texture.height = height; + + this.nativeTextures.push(texture); + + return texture; + }, + + /** + * Wrapper for creating WebGLFramebuffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer + * @since 3.0.0 + * + * @param {integer} width - Width in pixels of the framebuffer + * @param {integer} height - Height in pixels of the framebuffer + * @param {WebGLTexture} renderTexture - The color texture to where the color pixels are written + * @param {boolean} addDepthStencilBuffer - Indicates if the current framebuffer support depth and stencil buffers + * + * @return {WebGLFramebuffer} Raw WebGLFramebuffer + */ + createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) + { + var gl = this.gl; + var framebuffer = gl.createFramebuffer(); + var complete = 0; + + this.setFramebuffer(framebuffer); + + if (addDepthStencilBuffer) + { + var depthStencilBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); + } + + renderTexture.isRenderTexture = true; + renderTexture.isAlphaPremultiplied = false; + + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); + + complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); + + if (complete !== gl.FRAMEBUFFER_COMPLETE) + { + var errors = { + 36054: 'Incomplete Attachment', + 36055: 'Missing Attachment', + 36057: 'Incomplete Dimensions', + 36061: 'Framebuffer Unsupported' + }; + + throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); + } + + framebuffer.renderTexture = renderTexture; + + this.setFramebuffer(null); + + return framebuffer; + }, + + /** + * Wrapper for creating a WebGLProgram + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram + * @since 3.0.0 + * + * @param {string} vertexShader - Source to the vertex shader + * @param {string} fragmentShader - Source to the fragment shader + * + * @return {WebGLProgram} Raw WebGLProgram + */ + createProgram: function (vertexShader, fragmentShader) + { + var gl = this.gl; + var program = gl.createProgram(); + var vs = gl.createShader(gl.VERTEX_SHADER); + var fs = gl.createShader(gl.FRAGMENT_SHADER); + + gl.shaderSource(vs, vertexShader); + gl.shaderSource(fs, fragmentShader); + gl.compileShader(vs); + gl.compileShader(fs); + + if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); + } + if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); + } + + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.linkProgram(program); + + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) + { + throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); + } + + return program; + }, + + /** + * Wrapper for creating a vertex buffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo + * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW + * + * @return {WebGLBuffer} Raw vertex buffer + */ + createVertexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var vertexBuffer = gl.createBuffer(); + + this.setVertexBuffer(vertexBuffer); + + gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setVertexBuffer(null); + + return vertexBuffer; + }, + + /** + * Wrapper for creating a vertex buffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - Either ArrayBuffer or an integer indicating the size of the vbo. + * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. + * + * @return {WebGLBuffer} Raw index buffer + */ + createIndexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var indexBuffer = gl.createBuffer(); + + this.setIndexBuffer(indexBuffer); + + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setIndexBuffer(null); + + return indexBuffer; + }, + + /** + * Removes the given texture from the nativeTextures array and then deletes it from the GPU. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture + * @since 3.0.0 + * + * @param {WebGLTexture} texture - The WebGL Texture to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteTexture: function (texture) + { + var index = this.nativeTextures.indexOf(texture); + + if (index !== -1) + { + SpliceOne(this.nativeTextures, index); + } + + this.gl.deleteTexture(texture); + + if (this.currentTextures[0] === texture) + { + // texture we just deleted is in use, so bind a blank texture + this.setBlankTexture(true); + } + + return this; + }, + + /** + * Deletes a WebGLFramebuffer from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - The Framebuffer to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteFramebuffer: function (framebuffer) + { + this.gl.deleteFramebuffer(framebuffer); + + return this; + }, + + /** + * Deletes a WebGLProgram from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - The shader program to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteProgram: function (program) + { + this.gl.deleteProgram(program); + + return this; + }, + + /** + * Deletes a WebGLBuffer from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - The WebGLBuffer to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteBuffer: function (buffer) + { + this.gl.deleteBuffer(buffer); + + return this; + }, + + /** + * Controls the pre-render operations for the given camera. + * Handles any clipping needed by the camera and renders the background color if a color is visible. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to pre-render. + */ + preRenderCamera: function (camera) + { + var cx = camera._cx; + var cy = camera._cy; + var cw = camera._cw; + var ch = camera._ch; + + var TextureTintPipeline = this.pipelines.TextureTintPipeline; + + var color = camera.backgroundColor; + + if (camera.renderToTexture) + { + this.flush(); + + this.pushScissor(cx, cy, cw, -ch); + + this.setFramebuffer(camera.framebuffer); + + var gl = this.gl; + + gl.clearColor(0, 0, 0, 0); + + gl.clear(gl.COLOR_BUFFER_BIT); + + TextureTintPipeline.projOrtho(cx, cw + cx, cy, ch + cy, -1000, 1000); + + if (color.alphaGL > 0) + { + TextureTintPipeline.drawFillRect( + cx, cy, cw + cx, ch + cy, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1), + color.alphaGL + ); + } + + camera.emit('prerender', camera); + } + else + { + this.pushScissor(cx, cy, cw, ch); + + if (color.alphaGL > 0) + { + TextureTintPipeline.drawFillRect( + cx, cy, cw , ch, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1), + color.alphaGL + ); + } + } + }, + + /** + * Controls the post-render operations for the given camera. + * Renders the foreground camera effects like flash and fading. It resets the current scissor state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to post-render. + */ + postRenderCamera: function (camera) + { + var TextureTintPipeline = this.pipelines.TextureTintPipeline; + + camera.flashEffect.postRenderWebGL(TextureTintPipeline, Utils.getTintFromFloats); + camera.fadeEffect.postRenderWebGL(TextureTintPipeline, Utils.getTintFromFloats); + + camera.dirty = false; + + this.popScissor(); + + if (camera.renderToTexture) + { + TextureTintPipeline.flush(); + + this.setFramebuffer(null); + + camera.emit('postrender', camera); + + TextureTintPipeline.projOrtho(0, TextureTintPipeline.width, TextureTintPipeline.height, 0, -1000.0, 1000.0); + + var getTint = Utils.getTintAppendFloatAlpha; + + var pipeline = (camera.pipeline) ? camera.pipeline : TextureTintPipeline; + + pipeline.batchTexture( + camera, + camera.glTexture, + camera.width, camera.height, + camera.x, camera.y, + camera.width, camera.height, + camera.zoom, camera.zoom, + camera.rotation, + camera.flipX, !camera.flipY, + 1, 1, + 0, 0, + 0, 0, camera.width, camera.height, + getTint(camera._tintTL, camera._alphaTL), + getTint(camera._tintTR, camera._alphaTR), + getTint(camera._tintBL, camera._alphaBL), + getTint(camera._tintBR, camera._alphaBR), + (camera._isTinted && camera.tintFill), + 0, 0, + this.defaultCamera, + null + ); + + // Force clear the current texture so that items next in the batch (like Graphics) don't try and use it + this.setBlankTexture(true); + } + }, + + /** + * Clears the current vertex buffer and updates pipelines. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender + * @since 3.0.0 + */ + preRender: function () + { + if (this.contextLost) { return; } + + var gl = this.gl; + var color = this.config.backgroundColor; + var pipelines = this.pipelines; + + if (this.config.clearBeforeRender) + { + gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + } + + gl.enable(gl.SCISSOR_TEST); + + for (var key in pipelines) + { + pipelines[key].onPreRender(); + } + + // TODO - Find a way to stop needing to create these arrays every frame + // and equally not need a huge array buffer created to hold them + + this.currentScissor = [ 0, 0, this.width, this.height ]; + this.scissorStack = [ this.currentScissor ]; + + if (this.game.scene.customViewports) + { + gl.scissor(0, (this.drawingBufferHeight - this.height), this.width, this.height); + } + + this.setPipeline(this.pipelines.TextureTintPipeline); + }, + + /** + * The core render step for a Scene. + * Iterates through the given Game Object's array and renders them with the given Camera. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to render. + * @param {Phaser.GameObjects.GameObject} children - The Game Object's within the Scene to be rendered. + * @param {number} interpolationPercentage - The interpolation percentage to apply. Currently un-used. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Scene Camera to render with. + */ + render: function (scene, children, interpolationPercentage, camera) + { + if (this.contextLost) { return; } + + var list = children.list; + var childCount = list.length; + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onRender(scene, camera); + } + + // Apply scissor for cam region + render background color, if not transparent + this.preRenderCamera(camera); + + for (var i = 0; i < childCount; i++) + { + var child = list[i]; + + if (!child.willRender(camera)) + { + continue; + } + + if (child.blendMode !== this.currentBlendMode) + { + this.setBlendMode(child.blendMode); + } + + var mask = child.mask; + + if (mask) + { + mask.preRenderWebGL(this, child, camera); + + child.renderWebGL(this, child, interpolationPercentage, camera); + + mask.postRenderWebGL(this, child); + } + else + { + child.renderWebGL(this, child, interpolationPercentage, camera); + } + } + + this.setBlendMode(CONST.BlendModes.NORMAL); + + // Applies camera effects and pops the scissor, if set + this.postRenderCamera(camera); + }, + + /** + * The post-render step happens after all Cameras in all Scenes have been rendered. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender + * @since 3.0.0 + */ + postRender: function () + { + if (this.contextLost) { return; } + + this.flush(); + + // Unbind custom framebuffer here + + if (this.snapshotState.callback) + { + this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); + this.snapshotState.callback = null; + } + + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onPostRender(); + } + }, + + /** + * Schedules a snapshot to be taken after the current frame is rendered. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - Function to invoke after the snapshot is created. + * @param {string} type - The format of the image to create, usually `image/png`. + * @param {number} encoderOptions - The image quality, between 0 and 1, to use for image formats with lossy compression (such as `image/jpeg`). + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotState.callback = callback; + this.snapshotState.type = type; + this.snapshotState.encoder = encoderOptions; + + return this; + }, + + /** + * Creates a WebGL Texture based on the given canvas element. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture + * @since 3.0.0 + * + * @param {HTMLCanvasElement} srcCanvas - The Canvas element that will be used to populate the texture. + * @param {WebGLTexture} [dstTexture] - Is this going to replace an existing texture? If so, pass it here. + * @param {boolean} [noRepeat=false] - Should this canvas never be allowed to set REPEAT? (such as for Text objects) + * + * @return {WebGLTexture} The newly created WebGL Texture. + */ + canvasToTexture: function (srcCanvas, dstTexture, noRepeat) + { + if (noRepeat === undefined) { noRepeat = false; } + + var gl = this.gl; + + if (!dstTexture) + { + var wrapping = gl.CLAMP_TO_EDGE; + + if (!noRepeat && IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) + { + wrapping = gl.REPEAT; + } + + dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); + } + else + { + this.setTexture2D(dstTexture, 0); + + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); + + dstTexture.width = srcCanvas.width; + dstTexture.height = srcCanvas.height; + + this.setTexture2D(null, 0); + } + + return dstTexture; + }, + + /** + * Sets the minification and magnification filter for a texture. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter + * @since 3.0.0 + * + * @param {integer} texture - The texture to set the filter for. + * @param {integer} filter - The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. + * + * @return {this} This WebGL Renderer instance. + */ + setTextureFilter: function (texture, filter) + { + var gl = this.gl; + var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); + + this.setTexture2D(null, 0); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setFloat1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setFloat2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setFloat3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, + + /** + * Sets uniform of a WebGLProgram + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - X component + * @param {number} y - Y component + * @param {number} z - Z component + * @param {number} w - W component + * + * @return {this} This WebGL Renderer instance. + */ + setFloat4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + setFloat1v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform1fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + setFloat2v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform2fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + setFloat3v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform3fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + + setFloat4v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform4fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setInt1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setInt2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setInt3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - X component + * @param {integer} y - Y component + * @param {integer} z - Z component + * @param {integer} w - W component + * + * @return {this} This WebGL Renderer instance. + */ + setInt4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setMatrix2: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setMatrix3: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * Sets uniform of a WebGLProgram + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - Is the matrix transposed + * @param {Float32Array} matrix - Matrix data + * + * @return {this} This WebGL Renderer instance. + */ + setMatrix4: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * Returns the maximum number of texture units that can be used in a fragment shader. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextures + * @since 3.8.0 + * + * @return {integer} The maximum number of textures WebGL supports. + */ + getMaxTextures: function () + { + return this.config.maxTextures; + }, + + /** + * Returns the largest texture size (either width or height) that can be created. + * Note that VRAM may not allow a texture of any given size, it just expresses + * hardware / driver support for a given size. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextureSize + * @since 3.8.0 + * + * @return {integer} The maximum supported texture size. + */ + getMaxTextureSize: function () + { + return this.config.maxTextureSize; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Clear-up anything that should be cleared :) + for (var key in this.pipelines) + { + this.pipelines[key].destroy(); + + delete this.pipelines[key]; + } + + for (var index = 0; index < this.nativeTextures.length; ++index) + { + this.deleteTexture(this.nativeTextures[index]); + + delete this.nativeTextures[index]; + } + + delete this.gl; + delete this.game; + + this.contextLost = true; + this.extensions = {}; + this.nativeTextures.length = 0; + } + +}); + +module.exports = WebGLRenderer; + + +/***/ }), +/* 424 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var modes = __webpack_require__(66); +var CanvasFeatures = __webpack_require__(339); + +/** + * [description] + * + * @function Phaser.Renderer.Canvas.GetBlendModes + * @since 3.0.0 + * + * @return {array} [description] + */ +var GetBlendModes = function () +{ + var output = []; + var useNew = CanvasFeatures.supportNewBlendModes; + var so = 'source-over'; + + output[modes.NORMAL] = so; + output[modes.ADD] = 'lighter'; + output[modes.MULTIPLY] = (useNew) ? 'multiply' : so; + output[modes.SCREEN] = (useNew) ? 'screen' : so; + output[modes.OVERLAY] = (useNew) ? 'overlay' : so; + output[modes.DARKEN] = (useNew) ? 'darken' : so; + output[modes.LIGHTEN] = (useNew) ? 'lighten' : so; + output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : so; + output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : so; + output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : so; + output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : so; + output[modes.DIFFERENCE] = (useNew) ? 'difference' : so; + output[modes.EXCLUSION] = (useNew) ? 'exclusion' : so; + output[modes.HUE] = (useNew) ? 'hue' : so; + output[modes.SATURATION] = (useNew) ? 'saturation' : so; + output[modes.COLOR] = (useNew) ? 'color' : so; + output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : so; + + return output; +}; + +module.exports = GetBlendModes; + + +/***/ }), +/* 425 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Renderer.Snapshot.Canvas + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {string} [type='image/png'] - [description] + * @param {number} [encoderOptions=0.92] - [description] + * + * @return {HTMLImageElement} [description] + */ +var CanvasSnapshot = function (canvas, type, encoderOptions) +{ + if (type === undefined) { type = 'image/png'; } + if (encoderOptions === undefined) { encoderOptions = 0.92; } + + var src = canvas.toDataURL(type, encoderOptions); + + var image = new Image(); + + image.src = src; + + return image; +}; + +module.exports = CanvasSnapshot; + + +/***/ }), +/* 426 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasSnapshot = __webpack_require__(425); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(26); +var GetBlendModes = __webpack_require__(424); +var ScaleModes = __webpack_require__(94); +var Smoothing = __webpack_require__(120); +var TransformMatrix = __webpack_require__(38); + +/** + * @classdesc + * [description] + * + * @class CanvasRenderer + * @memberof Phaser.Renderer.Canvas + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. + */ +var CanvasRenderer = new Class({ + + initialize: + + function CanvasRenderer (game) + { + /** + * The Phaser Game instance that owns this renderer. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.CANVAS; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.drawCount = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#width + * @type {number} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#height + * @type {number} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: game.config.clearBeforeRender, + backgroundColor: game.config.backgroundColor, + resolution: game.config.resolution, + autoResize: game.config.autoResize, + antialias: game.config.antialias, + roundPixels: game.config.roundPixels + }; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode + * @type {integer} + * @since 3.0.0 + */ + this.scaleMode = (game.config.antialias) ? ScaleModes.LINEAR : ScaleModes.NEAREST; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.gameCanvas = game.canvas; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.gameContext = (this.game.config.context) ? this.game.config.context : this.gameCanvas.getContext('2d'); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.currentContext = this.gameContext; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes + * @type {array} + * @since 3.0.0 + */ + this.blendModes = GetBlendModes(); + + // image-rendering: optimizeSpeed; + // image-rendering: pixelated; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentScaleMode = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback + * @type {?SnapshotCallback} + * @default null + * @since 3.0.0 + */ + this.snapshotCallback = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType + * @type {?string} + * @default null + * @since 3.0.0 + */ + this.snapshotType = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.snapshotEncoder = null; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + this.init(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#init + * @since 3.0.0 + */ + init: function () + { + this.resize(this.width, this.height); + }, + + /** + * Resize the main game canvas. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resize + * @since 3.0.0 + * + * @param {integer} width - [description] + * @param {integer} height - [description] + */ + resize: function (width, height) + { + var resolution = this.config.resolution; + + this.width = width * resolution; + this.height = height * resolution; + + this.gameCanvas.width = this.width; + this.gameCanvas.height = this.height; + + if (this.config.autoResize) + { + this.gameCanvas.style.width = (this.width / resolution) + 'px'; + this.gameCanvas.style.height = (this.height / resolution) + 'px'; + } + + // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) + if (this.scaleMode === ScaleModes.NEAREST) + { + Smoothing.disable(this.gameContext); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextLost: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextRestored: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform + * @since 3.0.0 + */ + resetTransform: function () + { + this.currentContext.setTransform(1, 0, 0, 1, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode + * @since 3.0.0 + * + * @param {number} blendMode - [description] + * + * @return {this} [description] + */ + setBlendMode: function (blendMode) + { + this.currentContext.globalCompositeOperation = blendMode; + + return this; + }, + + /** + * Changes the Canvas Rendering Context that all draw operations are performed against. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setContext + * @since 3.12.0 + * + * @param {?CanvasRenderingContext2D} [ctx] - The new Canvas Rendering Context to draw everything to. Leave empty to reset to the Game Canvas. + * + * @return {this} The Canvas Renderer instance. + */ + setContext: function (ctx) + { + this.currentContext = (ctx) ? ctx : this.gameContext; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha + * @since 3.0.0 + * + * @param {number} alpha - [description] + * + * @return {this} [description] + */ + setAlpha: function (alpha) + { + this.currentContext.globalAlpha = alpha; + + return this; + }, + + /** + * Called at the start of the render loop. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender + * @since 3.0.0 + */ + preRender: function () + { + var ctx = this.gameContext; + var config = this.config; + + var width = this.width; + var height = this.height; + + if (config.clearBeforeRender) + { + ctx.clearRect(0, 0, width, height); + } + + if (!config.transparent) + { + ctx.fillStyle = config.backgroundColor.rgba; + ctx.fillRect(0, 0, width, height); + } + + this.drawCount = 0; + }, + + /** + * Renders the Scene to the given Camera. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.DisplayList} children - [description] + * @param {number} interpolationPercentage - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + render: function (scene, children, interpolationPercentage, camera) + { + var list = children.list; + var childCount = list.length; + + var cx = camera._cx; + var cy = camera._cy; + var cw = camera._cw; + var ch = camera._ch; + + var ctx = (camera.renderToTexture) ? camera.context : scene.sys.context; + + var scissor = (cx !== 0 || cy !== 0 || cw !== ctx.canvas.width || ch !== ctx.canvas.height); + + this.currentContext = ctx; + + // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) + + if (!camera.transparent) + { + ctx.fillStyle = camera.backgroundColor.rgba; + ctx.fillRect(cx, cy, cw, ch); + } + + ctx.globalAlpha = camera.alpha; + + ctx.globalCompositeOperation = 'source-over'; + + this.drawCount += list.length; + + if (scissor) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(cx, cy, cw, ch); + ctx.clip(); + } + + if (camera.renderToTexture) + { + camera.emit('prerender', camera); + } + + camera.matrix.copyToContext(ctx); + + for (var i = 0; i < childCount; i++) + { + var child = list[i]; + + if (!child.willRender(camera)) + { + continue; + } + + if (child.mask) + { + child.mask.preRenderCanvas(this, child, camera); + } + + child.renderCanvas(this, child, interpolationPercentage, camera); + + if (child.mask) + { + child.mask.postRenderCanvas(this, child, camera); + } + } + + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + + camera.flashEffect.postRenderCanvas(ctx); + camera.fadeEffect.postRenderCanvas(ctx); + + camera.dirty = false; + + // Reset the camera scissor + if (scissor) + { + ctx.restore(); + } + + if (camera.renderToTexture) + { + camera.emit('postrender', camera); + + scene.sys.context.drawImage(camera.canvas, cx, cy); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender + * @since 3.0.0 + */ + postRender: function () + { + var ctx = this.gameContext; + + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + + if (this.snapshotCallback) + { + this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); + this.snapshotCallback = null; + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - [description] + * @param {string} type - [description] + * @param {number} encoderOptions - [description] + */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotCallback = callback; + this.snapshotType = type; + this.snapshotEncoder = encoderOptions; + }, + + /** + * Takes a Sprite Game Object, or any object that extends it, and draws it to the current context. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#batchSprite + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - The texture based Game Object to draw. + * @param {Phaser.Textures.Frame} frame - The frame to draw, doesn't have to be that owned by the Game Object. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the rendering transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - The transform matrix of the parent container, if set. + */ + batchSprite: function (sprite, frame, camera, parentTransformMatrix) + { + var alpha = camera.alpha * sprite.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + + var ctx = this.currentContext; + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var cd = frame.canvasData; + + var frameX = cd.x; + var frameY = cd.y; + var frameWidth = frame.cutWidth; + var frameHeight = frame.cutHeight; + var res = frame.source.resolution; + + var x = -sprite.displayOriginX + frame.x; + var y = -sprite.displayOriginY + frame.y; + + var fx = (sprite.flipX) ? -1 : 1; + var fy = (sprite.flipY) ? -1 : 1; + + if (sprite.isCropped) + { + var crop = sprite._crop; + + if (crop.flipX !== sprite.flipX || crop.flipY !== sprite.flipY) + { + frame.updateCropUVs(crop, sprite.flipX, sprite.flipY); + } + + frameWidth = crop.cw; + frameHeight = crop.ch; + + frameX = crop.cx; + frameY = crop.cy; + + x = -sprite.displayOriginX + crop.x; + y = -sprite.displayOriginY + crop.y; + + if (fx === -1) + { + if (x >= 0) + { + x = -(x + frameWidth); + } + else if (x < 0) + { + x = (Math.abs(x) - frameWidth); + } + } + + if (fy === -1) + { + if (y >= 0) + { + y = -(y + frameHeight); + } + else if (y < 0) + { + y = (Math.abs(y) - frameHeight); + } + } + } + + spriteMatrix.applyITRS(sprite.x, sprite.y, sprite.rotation, sprite.scaleX, sprite.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * sprite.scrollFactorX, -camera.scrollY * sprite.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = sprite.x; + spriteMatrix.f = sprite.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * sprite.scrollFactorX; + spriteMatrix.f -= camera.scrollY * sprite.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + ctx.save(); + + calcMatrix.setToContext(ctx); + + ctx.scale(fx, fy); + + ctx.globalCompositeOperation = this.blendModes[sprite.blendMode]; + + ctx.globalAlpha = alpha; + + ctx.drawImage(frame.source.image, frameX, frameY, frameWidth, frameHeight, x, y, frameWidth / res, frameHeight / res); + + ctx.restore(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.gameCanvas = null; + this.gameContext = null; + + this.game = null; + } + +}); + +module.exports = CanvasRenderer; + + +/***/ }), +/* 427 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -67717,36 +95969,59 @@ var Class = __webpack_require__(0); /** * This event is dispatched when an animation starts playing. + * + * Listen for it on the Game Object: `sprite.on('animationstart', listener)` * * @event Phaser.GameObjects.Components.Animation#onStartEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. + */ + +/** + * This event is dispatched when an animation restarts. + * + * Listen for it on the Game Object: `sprite.on('animationrestart', listener)` + * + * @event Phaser.GameObjects.Components.Animation#onRestartEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** * This event is dispatched when an animation repeats. + * + * Listen for it on the Game Object: `sprite.on('animationrepeat', listener)` * * @event Phaser.GameObjects.Components.Animation#onRepeatEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. * @param {integer} repeatCount - The number of times this animation has repeated. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** * This event is dispatched when an animation updates. This happens when the animation frame changes, * based on the animation frame rate and other factors like timeScale and delay. + * + * Listen for it on the Game Object: `sprite.on('animationupdate', listener)` * * @event Phaser.GameObjects.Components.Animation#onUpdateEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** * This event is dispatched when an animation completes playing, either naturally or via Animation.stop. + * + * Listen for it on the Game Object: `sprite.on('animationcomplete', listener)` * * @event Phaser.GameObjects.Components.Animation#onCompleteEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** @@ -67756,7 +96031,7 @@ var Class = __webpack_require__(0); * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. * * @class Animation - * @memberOf Phaser.GameObjects.Components + * @memberof Phaser.GameObjects.Components * @constructor * @since 3.0.0 * @@ -67917,7 +96192,7 @@ var Animation = new Class({ this._yoyo = false; /** - * Will the playhead move forwards (`true`) or in reverse (`false`) + * Will the playhead move forwards (`true`) or in reverse (`false`). * * @name Phaser.GameObjects.Components.Animation#forward * @type {boolean} @@ -67926,6 +96201,17 @@ var Animation = new Class({ */ this.forward = true; + /** + * An Internal trigger that's play the animation in reverse mode ('true') or not ('false'), + * needed because forward can be changed by yoyo feature. + * + * @name Phaser.GameObjects.Components.Animation#forward + * @type {boolean} + * @default false + * @since 3.12.0 + */ + this._reverse = false; + /** * Internal time overflow accumulator. * @@ -68169,7 +96455,7 @@ var Animation = new Class({ * `true` if the current animation is paused, otherwise `false`. * * @name Phaser.GameObjects.Components.Animation#isPaused - * @readOnly + * @readonly * @type {boolean} * @since 3.4.0 */ @@ -68205,6 +96491,56 @@ var Animation = new Class({ return this.parent; } + this.forward = true; + this._reverse = false; + + return this._startAnimation(key, startFrame); + }, + + /** + * Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component. + * + * @method Phaser.GameObjects.Components.Animation#playReverse + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + playReverse: function (key, ignoreIfPlaying, startFrame) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + if (startFrame === undefined) { startFrame = 0; } + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) + { + return this.parent; + } + + this.forward = false; + this._reverse = true; + + return this._startAnimation(key, startFrame); + }, + + /** + * Load an Animation and fires 'onStartEvent' event, + * extracted from 'play' method + * + * @method Phaser.GameObjects.Components.Animation#_startAnimation + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + _startAnimation: function (key, startFrame) + { this.load(key, startFrame); var anim = this.currentAnim; @@ -68215,7 +96551,6 @@ var Animation = new Class({ anim.getFirstTick(this); - this.forward = true; this.isPlaying = true; this.pendingRepeat = false; @@ -68224,11 +96559,30 @@ var Animation = new Class({ gameObject.visible = true; } - gameObject.emit('animationstart', this.currentAnim, this.currentFrame); + gameObject.emit('animationstart', this.currentAnim, this.currentFrame, gameObject); return gameObject; }, + /** + * Reverse an Animation that is already playing on the Game Object. + * + * @method Phaser.GameObjects.Components.Animation#reverse + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + reverse: function (key) + { + if (!this.isPlaying || this.currentAnim.key !== key) { return this.parent; } + this._reverse = !this._reverse; + this.forward = !this.forward; + + return this.parent; + }, + /** * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. * If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different @@ -68237,7 +96591,7 @@ var Animation = new Class({ * @method Phaser.GameObjects.Components.Animation#getProgress * @since 3.4.0 * - * @return {float} The progress of the current animation, between 0 and 1. + * @return {number} The progress of the current animation, between 0 and 1. */ getProgress: function () { @@ -68258,7 +96612,7 @@ var Animation = new Class({ * @method Phaser.GameObjects.Components.Animation#setProgress * @since 3.4.0 * - * @param {float} [value=0] - The progress value, between 0 and 1. + * @param {number} [value=0] - The progress value, between 0 and 1. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ @@ -68370,6 +96724,7 @@ var Animation = new Class({ * Restarts the current animation from its beginning, optionally including its delay value. * * @method Phaser.GameObjects.Components.Animation#restart + * @fires Phaser.GameObjects.Components.Animation#onRestartEvent * @since 3.0.0 * * @param {boolean} [includeDelay=false] - Whether to include the delay value of the animation when restarting. @@ -68390,6 +96745,10 @@ var Animation = new Class({ // Set frame this.updateFrame(this.currentAnim.frames[0]); + var gameObject = this.parent; + + gameObject.emit('animationrestart', this.currentAnim, this.currentFrame, gameObject); + return this.parent; }, @@ -68410,7 +96769,7 @@ var Animation = new Class({ var gameObject = this.parent; - gameObject.emit('animationcomplete', this.currentAnim, this.currentFrame); + gameObject.emit('animationcomplete', this.currentAnim, this.currentFrame, gameObject); return gameObject; }, @@ -68570,6 +96929,11 @@ var Animation = new Class({ gameObject.texture = animationFrame.frame.texture; gameObject.frame = animationFrame.frame; + if (gameObject.isCropped) + { + gameObject.frame.updateCropUVs(gameObject._crop, gameObject.flipX, gameObject.flipY); + } + gameObject.setSizeToFrame(); if (animationFrame.frame.customPivot) @@ -68607,7 +96971,7 @@ var Animation = new Class({ var anim = this.currentAnim; - gameObject.emit('animationupdate', anim, animationFrame); + gameObject.emit('animationupdate', anim, animationFrame, gameObject); if (this._pendingStop === 3 && this._pendingStopValue === animationFrame) { @@ -68675,7 +97039,270 @@ module.exports = Animation; /***/ }), -/* 303 */ +/* 428 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given string and reverses it, returning the reversed string. + * For example if given the string `Atari 520ST` it would return `TS025 iratA`. + * + * @function Phaser.Utils.String.ReverseString + * @since 3.0.0 + * + * @param {string} string - The string to be reversed. + * + * @return {string} The reversed string. + */ +var ReverseString = function (string) +{ + return string.split('').reverse().join(''); +}; + +module.exports = ReverseString; + + +/***/ }), +/* 429 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes a string and replaces instances of markers with values in the given array. + * The markers take the form of `%1`, `%2`, etc. I.e.: + * + * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` + * + * @function Phaser.Utils.String.Format + * @since 3.0.0 + * + * @param {string} string - The string containing the replacement markers. + * @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead. + * + * @return {string} The string containing replaced values. + */ +var Format = function (string, values) +{ + return string.replace(/%([0-9]+)/g, function (s, n) + { + return values[Number(n) - 1]; + }); +}; + +module.exports = Format; + + +/***/ }), +/* 430 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.String + */ + +module.exports = { + + Format: __webpack_require__(429), + Pad: __webpack_require__(179), + Reverse: __webpack_require__(428), + UppercaseFirst: __webpack_require__(327), + UUID: __webpack_require__(295) + +}; + + +/***/ }), +/* 431 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(63); + +/** + * Creates a new Object using all values from obj1. + * + * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. + * + * @function Phaser.Utils.Objects.MergeRight + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var MergeRight = function (obj1, obj2) +{ + var clone = Clone(obj1); + + for (var key in obj2) + { + if (clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } + + return clone; +}; + +module.exports = MergeRight; + + +/***/ }), +/* 432 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Verifies that an object contains all requested keys + * + * @function Phaser.Utils.Objects.HasAll + * @since 3.0.0 + * + * @param {object} source - an object on which to check for key existence + * @param {string[]} keys - an array of keys to ensure the source object contains + * + * @return {boolean} true if the source object contains all keys, false otherwise. + */ +var HasAll = function (source, keys) +{ + for (var i = 0; i < keys.length; i++) + { + if (!source.hasOwnProperty(keys[i])) + { + return false; + } + } + + return true; +}; + +module.exports = HasAll; + + +/***/ }), +/* 433 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); +var Clamp = __webpack_require__(23); + +/** + * Retrieves and clamps a numerical value from an object. + * + * @function Phaser.Utils.Objects.GetMinMaxValue + * @since 3.0.0 + * + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`). + * @param {number} min - The minimum value which can be returned. + * @param {number} max - The maximum value which can be returned. + * @param {number} defaultValue - The value to return if the property doesn't exist. It's also constrained to the given bounds. + * + * @return {number} The clamped value from the `source` object. + */ +var GetMinMaxValue = function (source, key, min, max, defaultValue) +{ + if (defaultValue === undefined) { defaultValue = min; } + + var value = GetValue(source, key, defaultValue); + + return Clamp(value, min, max); +}; + +module.exports = GetMinMaxValue; + + +/***/ }), +/* 434 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.Object + */ + +module.exports = { + + Clone: __webpack_require__(63), + Extend: __webpack_require__(20), + GetAdvancedValue: __webpack_require__(12), + GetFastValue: __webpack_require__(2), + GetMinMaxValue: __webpack_require__(433), + GetValue: __webpack_require__(4), + HasAll: __webpack_require__(432), + HasAny: __webpack_require__(298), + HasValue: __webpack_require__(85), + IsPlainObject: __webpack_require__(8), + Merge: __webpack_require__(96), + MergeRight: __webpack_require__(431) + +}; + + +/***/ }), +/* 435 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils + */ + +module.exports = { + + Array: __webpack_require__(164), + Objects: __webpack_require__(434), + String: __webpack_require__(430) + +}; + + +/***/ }), +/* 436 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -68685,18 +97312,18 @@ module.exports = Animation; */ var Class = __webpack_require__(0); -var NumberTweenBuilder = __webpack_require__(161); -var PluginCache = __webpack_require__(12); -var TimelineBuilder = __webpack_require__(160); -var TWEEN_CONST = __webpack_require__(61); -var TweenBuilder = __webpack_require__(72); +var NumberTweenBuilder = __webpack_require__(203); +var PluginCache = __webpack_require__(15); +var TimelineBuilder = __webpack_require__(202); +var TWEEN_CONST = __webpack_require__(83); +var TweenBuilder = __webpack_require__(97); /** * @classdesc * [description] * * @class TweenManager - * @memberOf Phaser.Tweens + * @memberof Phaser.Tweens * @constructor * @since 3.0.0 * @@ -68955,6 +97582,7 @@ var TweenManager = new Class({ var list = this._destroy; var active = this._active; + var pending = this._pending; var i; var tween; @@ -68966,7 +97594,18 @@ var TweenManager = new Class({ // Remove from the 'active' array var idx = active.indexOf(tween); - if (idx !== -1) + if (idx === -1) + { + // Not in the active array, is it in pending instead? + idx = pending.indexOf(tween); + + if (idx > -1) + { + tween.state = TWEEN_CONST.REMOVED; + pending.splice(idx, 1); + } + } + else { tween.state = TWEEN_CONST.REMOVED; active.splice(idx, 1); @@ -69012,7 +97651,7 @@ var TweenManager = new Class({ * @since 3.0.0 * * @param {number} timestamp - [description] - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (timestamp, delta) { @@ -69295,7 +97934,7 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#setGlobalTimeScale * @since 3.0.0 * - * @param {float} value - [description] + * @param {number} value - [description] * * @return {Phaser.Tweens.TweenManager} [description] */ @@ -69356,7 +97995,7 @@ module.exports = TweenManager; /***/ }), -/* 304 */ +/* 437 */ /***/ (function(module, exports) { /** @@ -69428,7 +98067,7 @@ module.exports = [ /***/ }), -/* 305 */ +/* 438 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -69443,22 +98082,22 @@ module.exports = [ module.exports = { - GetBoolean: __webpack_require__(62), - GetEaseFunction: __webpack_require__(63), - GetNewValue: __webpack_require__(73), - GetProps: __webpack_require__(163), - GetTargets: __webpack_require__(102), - GetTweens: __webpack_require__(162), - GetValueOp: __webpack_require__(101), - NumberTweenBuilder: __webpack_require__(161), - TimelineBuilder: __webpack_require__(160), - TweenBuilder: __webpack_require__(72) + GetBoolean: __webpack_require__(84), + GetEaseFunction: __webpack_require__(86), + GetNewValue: __webpack_require__(98), + GetProps: __webpack_require__(205), + GetTargets: __webpack_require__(131), + GetTweens: __webpack_require__(204), + GetValueOp: __webpack_require__(130), + NumberTweenBuilder: __webpack_require__(203), + TimelineBuilder: __webpack_require__(202), + TweenBuilder: __webpack_require__(97) }; /***/ }), -/* 306 */ +/* 439 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -69467,8 +98106,8 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(61); -var Extend = __webpack_require__(17); +var CONST = __webpack_require__(83); +var Extend = __webpack_require__(20); /** * @namespace Phaser.Tweens @@ -69476,12 +98115,12 @@ var Extend = __webpack_require__(17); var Tweens = { - Builders: __webpack_require__(305), + Builders: __webpack_require__(438), - TweenManager: __webpack_require__(303), - Tween: __webpack_require__(99), - TweenData: __webpack_require__(98), - Timeline: __webpack_require__(159) + TweenManager: __webpack_require__(436), + Tween: __webpack_require__(128), + TweenData: __webpack_require__(127), + Timeline: __webpack_require__(201) }; @@ -69492,7 +98131,7 @@ module.exports = Tweens; /***/ }), -/* 307 */ +/* 440 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -69502,15 +98141,15 @@ module.exports = Tweens; */ var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); -var TimerEvent = __webpack_require__(164); +var PluginCache = __webpack_require__(15); +var TimerEvent = __webpack_require__(206); /** * @classdesc * [description] * * @class Clock - * @memberOf Phaser.Time + * @memberof Phaser.Time * @constructor * @since 3.0.0 * @@ -69556,7 +98195,7 @@ var Clock = new Class({ * [description] * * @name Phaser.Time.Clock#timeScale - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -69713,8 +98352,8 @@ var Clock = new Class({ * @method Phaser.Time.Clock#preUpdate * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ preUpdate: function () { @@ -69764,8 +98403,8 @@ var Clock = new Class({ * @method Phaser.Time.Clock#update * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (time, delta) { @@ -69886,7 +98525,7 @@ module.exports = Clock; /***/ }), -/* 308 */ +/* 441 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -69901,14 +98540,14 @@ module.exports = Clock; module.exports = { - Clock: __webpack_require__(307), - TimerEvent: __webpack_require__(164) + Clock: __webpack_require__(440), + TimerEvent: __webpack_require__(206) }; /***/ }), -/* 309 */ +/* 442 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -69917,4600 +98556,64 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var CONST = __webpack_require__(20); -var GameObject = __webpack_require__(2); -var StaticTilemapLayerRender = __webpack_require__(624); -var TilemapComponents = __webpack_require__(141); -var Utils = __webpack_require__(27); +var GameObjectFactory = __webpack_require__(5); +var ParseToTilemap = __webpack_require__(132); /** - * @classdesc - * A StaticTilemapLayer is a game object that renders LayerData from a Tilemap. A - * StaticTilemapLayer can only render tiles from a single tileset. + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. * - * A StaticTilemapLayer is optimized for speed over flexibility. You cannot apply per-tile - * effects like tint or alpha. You cannot change the tiles in a StaticTilemapLayer. Use this - * over a DynamicTilemapLayer when you don't need either of those features. - * - * @class StaticTilemapLayer - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps - * @constructor + * @method Phaser.GameObjects.GameObjectFactory#tilemap * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. - * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. - * @param {number} [x=0] - The world x position where the top left of this layer will be placed. - * @param {number} [y=0] - The world y position where the top left of this layer will be placed. - */ -var StaticTilemapLayer = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - StaticTilemapLayerRender - ], - - initialize: - - function StaticTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) - { - GameObject.call(this, scene, 'StaticTilemapLayer'); - - /** - * Used internally by physics system to perform fast type checks. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isTilemap = true; - - /** - * The Tilemap that this layer is a part of. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#tilemap - * @type {Phaser.Tilemaps.Tilemap} - * @since 3.0.0 - */ - this.tilemap = tilemap; - - /** - * The index of the LayerData associated with this layer. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#layerIndex - * @type {integer} - * @since 3.0.0 - */ - this.layerIndex = layerIndex; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - this.layer = tilemap.layers[layerIndex]; - - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer - - /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} - * @since 3.0.0 - */ - this.tileset = tileset; - - /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles - * @type {array} - * @since 3.0.0 - */ - this.culledTiles = []; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer - * @type {array} - * @private - * @since 3.0.0 - */ - this.vertexBuffer = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#renderer - * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} - * @private - * @since 3.0.0 - */ - this.renderer = scene.sys.game.renderer; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData - * @type {ArrayBuffer} - * @private - * @since 3.0.0 - */ - this.bufferData = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 - * @type {Float32Array} - * @private - * @since 3.0.0 - */ - this.vertexViewF32 = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 - * @type {Uint32Array} - * @private - * @since 3.0.0 - */ - this.vertexViewU32 = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#dirty - * @type {boolean} - * @private - * @since 3.0.0 - */ - this.dirty = true; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount - * @type {integer} - * @private - * @since 3.0.0 - */ - this.vertexCount = 0; - - this.setAlpha(this.layer.alpha); - this.setPosition(x, y); - this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); - - this.initPipeline('TextureTintPipeline'); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function () - { - this.dirty = true; - this.vertexBuffer = null; - }, this); - } - }, - - /** - * Upload the tile data to a VBO. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#upload - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - upload: function (camera) - { - var tileset = this.tileset; - var mapWidth = this.layer.width; - var mapHeight = this.layer.height; - var width = tileset.image.source[0].width; - var height = tileset.image.source[0].height; - var mapData = this.layer.data; - var renderer = this.renderer; - var tile; - var row; - var col; - var texCoords; - - if (renderer.gl) - { - var pipeline = renderer.pipelines.TextureTintPipeline; - - if (this.dirty) - { - var gl = renderer.gl; - var vertexBuffer = this.vertexBuffer; - var bufferData = this.bufferData; - var voffset = 0; - var vertexCount = 0; - var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; - - if (bufferData === null) - { - bufferData = new ArrayBuffer(bufferSize); - this.bufferData = bufferData; - this.vertexViewF32 = new Float32Array(bufferData); - this.vertexViewU32 = new Uint32Array(bufferData); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - - for (row = 0; row < mapHeight; ++row) - { - for (col = 0; col < mapWidth; ++col) - { - tile = mapData[row][col]; - if (tile === null || tile.index === -1) { continue; } - - var tx = tile.pixelX; - var ty = tile.pixelY; - var txw = tx + tile.width; - var tyh = ty + tile.height; - - texCoords = tileset.getTileTextureCoordinates(tile.index); - if (texCoords === null) { continue; } - - var u0 = texCoords.x / width; - var v0 = texCoords.y / height; - var u1 = (texCoords.x + tile.width) / width; - var v1 = (texCoords.y + tile.height) / height; - - var tx0 = tx; - var ty0 = ty; - var tx1 = tx; - var ty1 = tyh; - var tx2 = txw; - var ty2 = tyh; - var tx3 = txw; - var ty3 = ty; - var tint = Utils.getTintAppendFloatAlpha(0xffffff, this.alpha * tile.alpha); - - vertexViewF32[voffset + 0] = tx0; - vertexViewF32[voffset + 1] = ty0; - vertexViewF32[voffset + 2] = u0; - vertexViewF32[voffset + 3] = v0; - vertexViewU32[voffset + 4] = tint; - vertexViewF32[voffset + 5] = tx1; - vertexViewF32[voffset + 6] = ty1; - vertexViewF32[voffset + 7] = u0; - vertexViewF32[voffset + 8] = v1; - vertexViewU32[voffset + 9] = tint; - vertexViewF32[voffset + 10] = tx2; - vertexViewF32[voffset + 11] = ty2; - vertexViewF32[voffset + 12] = u1; - vertexViewF32[voffset + 13] = v1; - vertexViewU32[voffset + 14] = tint; - vertexViewF32[voffset + 15] = tx0; - vertexViewF32[voffset + 16] = ty0; - vertexViewF32[voffset + 17] = u0; - vertexViewF32[voffset + 18] = v0; - vertexViewU32[voffset + 19] = tint; - vertexViewF32[voffset + 20] = tx2; - vertexViewF32[voffset + 21] = ty2; - vertexViewF32[voffset + 22] = u1; - vertexViewF32[voffset + 23] = v1; - vertexViewU32[voffset + 24] = tint; - vertexViewF32[voffset + 25] = tx3; - vertexViewF32[voffset + 26] = ty3; - vertexViewF32[voffset + 27] = u1; - vertexViewF32[voffset + 28] = v0; - vertexViewU32[voffset + 29] = tint; - - voffset += 30; - vertexCount += 6; - } - } - - this.vertexCount = vertexCount; - this.dirty = false; - if (vertexBuffer === null) - { - vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); - this.vertexBuffer = vertexBuffer; - } - else - { - renderer.setVertexBuffer(vertexBuffer); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); - } - } - - pipeline.modelIdentity(); - pipeline.modelTranslate(this.x - (camera.scrollX * this.scrollFactorX), this.y - (camera.scrollY * this.scrollFactorY), 0.0); - pipeline.modelScale(this.scaleX, this.scaleY, 1.0); - pipeline.viewLoad2D(camera.matrix.matrix); - } - - return this; - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - calculateFacesAt: function (tileX, tileY) - { - TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - calculateFacesWithin: function (tileX, tileY, width, height) - { - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#createFromTiles - * @since 3.0.0 - * - * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) - { - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); - }, - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - cull: function (camera) - { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); - }, - - /** - * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Uninstall this layer only if it is still installed on the LayerData object - if (this.layer.tilemapLayer === this) - { - this.layer.tilemapLayer = undefined; - } - - this.tilemap = undefined; - this.layer = undefined; - this.tileset = undefined; - - GameObject.prototype.destroy.call(this); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - findByIndex: function (findIndex, skip, reverse) - { - return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {?Phaser.Tilemaps.Tile} - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - - return this; - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. - */ - getTileAt: function (tileX, tileY, nonNull) - { - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera) - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinShape - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinShape: function (shape, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * - * @return {boolean} - */ - hasTileAt: function (tileX, tileY) - { - return TilemapComponents.HasTileAt(tileX, tileY, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {boolean} - */ - hasTileAtWorldXY: function (worldX, worldY, camera) - { - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - renderDebug: function (graphics, styleConfig) - { - TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollision - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollision: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces) - { - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setTileIndexCallback - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setTileIndexCallback: function (indexes, callback, callbackContext) - { - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces) - { - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} [callbackContext] - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) - { - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldX: function (tileX, camera) - { - return TilemapComponents.TileToWorldX(tileX, camera, this.layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldY: function (tileY, camera) - { - return TilemapComponents.TileToWorldY(tileY, camera, this.layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - tileToWorldXY: function (tileX, tileY, point, camera) - { - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileX: function (worldX, snapToFloor, camera) - { - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileY: function (worldY, snapToFloor, camera) - { - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) - { - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); - } - -}); - -module.exports = StaticTilemapLayer; - - -/***/ }), -/* 310 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var DynamicTilemapLayerRender = __webpack_require__(627); -var GameObject = __webpack_require__(2); -var TilemapComponents = __webpack_require__(141); - -/** - * @classdesc - * A DynamicTilemapLayer is a game object that renders LayerData from a Tilemap. A - * DynamicTilemapLayer can only render tiles from a single tileset. - * - * A DynamicTilemapLayer trades some speed for being able to apply powerful effects. Unlike a - * StaticTilemapLayer, you can apply per-tile effects like tint or alpha, and you can change the - * tiles in a DynamicTilemapLayer. Use this over a StaticTilemapLayer when you need those - * features. - * - * @class DynamicTilemapLayer - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. - * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. - * @param {number} [x=0] - The world x position where the top left of this layer will be placed. - * @param {number} [y=0] - The world y position where the top left of this layer will be placed. - */ -var DynamicTilemapLayer = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - DynamicTilemapLayerRender - ], - - initialize: - - function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) - { - GameObject.call(this, scene, 'DynamicTilemapLayer'); - - /** - * Used internally by physics system to perform fast type checks. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isTilemap = true; - - /** - * The Tilemap that this layer is a part of. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#tilemap - * @type {Phaser.Tilemaps.Tilemap} - * @since 3.0.0 - */ - this.tilemap = tilemap; - - /** - * The index of the LayerData associated with this layer. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#layerIndex - * @type {integer} - * @since 3.0.0 - */ - this.layerIndex = layerIndex; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - this.layer = tilemap.layers[layerIndex]; - - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer - - /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} - * @since 3.0.0 - */ - this.tileset = tileset; - - /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#culledTiles - * @type {array} - * @since 3.0.0 - */ - this.culledTiles = []; - - this.setAlpha(this.layer.alpha); - this.setPosition(x, y); - this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); - - this.initPipeline('TextureTintPipeline'); - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - calculateFacesAt: function (tileX, tileY) - { - TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - calculateFacesWithin: function (tileX, tileY, width, height) - { - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#createFromTiles - * @since 3.0.0 - * - * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) - { - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); - }, - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - cull: function (camera) - { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); - }, - - /** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#copy - * @since 3.0.0 - * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces) - { - TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer); - - return this; - }, - - /** - * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Uninstall this layer only if it is still installed on the LayerData object - if (this.layer.tilemapLayer === this) - { - this.layer.tilemapLayer = undefined; - } - - this.tilemap = undefined; - this.layer = undefined; - this.tileset = undefined; - this.culledTiles.length = 0; - - GameObject.prototype.destroy.call(this); - }, - - /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - fill: function (index, tileX, tileY, width, height, recalculateFaces) - { - TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer); - - return this; - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - findByIndex: function (findIndex, skip, reverse) - { - return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {?Phaser.Tilemaps.Tile} - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - - return this; - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. - */ - getTileAt: function (tileX, tileY, nonNull) - { - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera) - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinShape - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinShape: function (shape, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * - * @return {boolean} - */ - hasTileAt: function (tileX, tileY) - { - return TilemapComponents.HasTileAt(tileX, tileY, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {boolean} - */ - hasTileAtWorldXY: function (worldX, worldY, camera) - { - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); - }, - - /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAt - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - putTileAt: function (tile, tileX, tileY, recalculateFaces) - { - return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); - }, - - /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAtWorldXY - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera) - { - return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer); - }, - - /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt - * @since 3.0.0 - * - * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) - { - TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); - - return this; - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - randomize: function (tileX, tileY, width, height, indexes) - { - TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer); - - return this; - }, - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces) - { - return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer); - }, - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera) - { - return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - renderDebug: function (graphics, styleConfig) - { - TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height) - { - TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollision - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollision: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces) - { - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces) - { - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setTileIndexCallback: function (indexes, callback, callbackContext) - { - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} [callbackContext] - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) - { - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - shuffle: function (tileX, tileY, width, height) - { - TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#swapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - swapByIndex: function (indexA, indexB, tileX, tileY, width, height) - { - TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldX: function (tileX, camera) - { - return TilemapComponents.TileToWorldX(tileX, camera, this.layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldY: function (tileY, camera) - { - return TilemapComponents.TileToWorldY(tileY, camera, this.layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - tileToWorldXY: function (tileX, tileY, point, camera) - { - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - weightedRandomize: function (tileX, tileY, width, height, weightedIndexes) - { - TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer); - - return this; - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileX: function (worldX, snapToFloor, camera) - { - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileY: function (worldY, snapToFloor, camera) - { - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) - { - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); - } - -}); - -module.exports = DynamicTilemapLayer; - - -/***/ }), -/* 311 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var DynamicTilemapLayer = __webpack_require__(310); -var Extend = __webpack_require__(17); -var Formats = __webpack_require__(26); -var LayerData = __webpack_require__(104); -var Rotate = __webpack_require__(346); -var StaticTilemapLayer = __webpack_require__(309); -var Tile = __webpack_require__(66); -var TilemapComponents = __webpack_require__(141); -var Tileset = __webpack_require__(137); - -/** - * @callback TilemapFilterCallback - * - * @param {Phaser.GameObjects.GameObject} value - [description] - * @param {number} index - [description] - * @param {Phaser.GameObjects.GameObject[]} array - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - -/** - * @callback TilemapFindCallback - * - * @param {Phaser.GameObjects.GameObject} value - [description] - * @param {number} index - [description] - * @param {Phaser.GameObjects.GameObject[]} array - [description] - * - * @return {boolean} [description] - */ - -/** - * @classdesc - * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data - * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or - * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display - * objects that actually render tiles. - * - * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free - * software package specifically for creating tile maps, and is available from: - * http://www.mapeditor.org - * - * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only - * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. - * - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a - * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides - * it. - * - * @class Tilemap - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. - * @param {Phaser.Tilemaps.MapData} mapData - A MapData instance containing Tilemap data. - */ -var Tilemap = new Class({ - - initialize: - - function Tilemap (scene, mapData) - { - /** - * @name Phaser.Tilemaps.Tilemap#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * The base width of a tile in pixels. Note that individual layers may have a different tile - * width. - * - * @name Phaser.Tilemaps.Tilemap#tileWidth - * @type {integer} - * @since 3.0.0 - */ - this.tileWidth = mapData.tileWidth; - - /** - * The base height of a tile in pixels. Note that individual layers may have a different - * tile height. - * - * @name Phaser.Tilemaps.Tilemap#tileHeight - * @type {integer} - * @since 3.0.0 - */ - this.tileHeight = mapData.tileHeight; - - /** - * The width of the map (in tiles). - * - * @name Phaser.Tilemaps.Tilemap#width - * @type {number} - * @since 3.0.0 - */ - this.width = mapData.width; - - /** - * The height of the map (in tiles). - * - * @name Phaser.Tilemaps.Tilemap#height - * @type {number} - * @since 3.0.0 - */ - this.height = mapData.height; - - /** - * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. - * - * @name Phaser.Tilemaps.Tilemap#orientation - * @type {string} - * @since 3.0.0 - */ - this.orientation = mapData.orientation; - - /** - * The format of the map data. - * - * @name Phaser.Tilemaps.Tilemap#format - * @type {number} - * @since 3.0.0 - */ - this.format = mapData.format; - - /** - * The version of the map data (as specified in Tiled, usually 1). - * - * @name Phaser.Tilemaps.Tilemap#version - * @type {number} - * @since 3.0.0 - */ - this.version = mapData.version; - - /** - * Map specific properties as specified in Tiled. - * - * @name Phaser.Tilemaps.Tilemap#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = mapData.properties; - - /** - * The width of the map in pixels based on width * tileWidth. - * - * @name Phaser.Tilemaps.Tilemap#widthInPixels - * @type {number} - * @since 3.0.0 - */ - this.widthInPixels = mapData.widthInPixels; - - /** - * The height of the map in pixels based on height * tileHeight. - * - * @name Phaser.Tilemaps.Tilemap#heightInPixels - * @type {number} - * @since 3.0.0 - */ - this.heightInPixels = mapData.heightInPixels; - - /** - * - * @name Phaser.Tilemaps.Tilemap#imageCollections - * @type {Phaser.Tilemaps.ImageCollection[]} - * @since 3.0.0 - */ - this.imageCollections = mapData.imageCollections; - - /** - * An array of Tiled Image Layers. - * - * @name Phaser.Tilemaps.Tilemap#images - * @type {array} - * @since 3.0.0 - */ - this.images = mapData.images; - - /** - * An array of Tilemap layer data. - * - * @name Phaser.Tilemaps.Tilemap#layers - * @type {Phaser.Tilemaps.LayerData[]} - * @since 3.0.0 - */ - this.layers = mapData.layers; - - /** - * An array of Tilesets used in the map. - * - * @name Phaser.Tilemaps.Tilemap#tilesets - * @type {Phaser.Tilemaps.Tileset[]} - * @since 3.0.0 - */ - this.tilesets = mapData.tilesets; - - /** - * An array of ObjectLayer instances parsed from Tiled object layers. - * - * @name Phaser.Tilemaps.Tilemap#objects - * @type {Phaser.Tilemaps.ObjectLayer[]} - * @since 3.0.0 - */ - this.objects = mapData.objects; - - /** - * The index of the currently selected LayerData object. - * - * @name Phaser.Tilemaps.Tilemap#currentLayerIndex - * @type {integer} - * @since 3.0.0 - */ - this.currentLayerIndex = 0; - }, - - /** - * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. - * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled - * editor. - * - * @method Phaser.Tilemaps.Tilemap#addTilesetImage - * @since 3.0.0 - * - * @param {string} tilesetName - The name of the tileset as specified in the map data. - * @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If - * `undefined` or `null` it will look for an image with a key matching the tilesetName parameter. - * @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not - * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled - * JSON file. - * @param {integer} [tileHeight] - The height of the tiles (in pixels) in the Tileset Image. If - * not given it will default to the map's tileHeight value, or the tileHeight specified in the - * Tiled JSON file. - * @param {integer} [tileMargin] - The margin around the tiles in the sheet (in pixels). If not - * specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param {integer} [tileSpacing] - The spacing between each the tile in the sheet (in pixels). - * If not specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param {integer} [gid=0] - If adding multiple tilesets to a blank map, specify the starting - * GID this set will use here. - * - * @return {?Phaser.Tilemaps.Tileset} Returns the Tileset object that was created or updated, or null if it - * failed. - */ - addTilesetImage: function (tilesetName, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) - { - if (tilesetName === undefined) { return null; } - if (key === undefined || key === null) { key = tilesetName; } - - if (!this.scene.sys.textures.exists(key)) - { - console.warn('Invalid image key given for tileset: "' + key + '"'); - return null; - } - - var texture = this.scene.sys.textures.get(key); - - var index = this.getTilesetIndex(tilesetName); - - if (index === null && this.format === Formats.TILED_JSON) - { - console.warn('No data found in the JSON tilemap from Tiled matching the tileset name: "' + tilesetName + '"'); - return null; - } - - if (this.tilesets[index]) - { - this.tilesets[index].setTileSize(tileWidth, tileHeight); - this.tilesets[index].setSpacing(tileMargin, tileSpacing); - this.tilesets[index].setImage(texture); - return this.tilesets[index]; - } - - if (tileWidth === undefined) { tileWidth = this.tileWidth; } - if (tileHeight === undefined) { tileHeight = this.tileHeight; } - if (tileMargin === undefined) { tileMargin = 0; } - if (tileSpacing === undefined) { tileSpacing = 0; } - if (gid === undefined) { gid = 0; } - - var tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); - tileset.setImage(texture); - this.tilesets.push(tileset); - - return tileset; - }, - - /** - * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If - * no layer specified, the map's current layer is used. This is useful if you want to manipulate - * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. - * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value - * returned from this method if you want to manipulate the new StaticTilemapLayer. - * - * @method Phaser.Tilemaps.Tilemap#convertLayerToStatic - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer)} [layer] - The name of the layer from Tiled, the - * index of the layer in the map, or a DynamicTilemapLayer. - * - * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer that was created, or null if it - * failed. - */ - convertLayerToStatic: function (layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - var dynamicLayer = layer.tilemapLayer; - - if (!dynamicLayer || !(dynamicLayer instanceof DynamicTilemapLayer)) - { - return null; - } - - var staticLayer = new StaticTilemapLayer( - dynamicLayer.scene, - dynamicLayer.tilemap, - dynamicLayer.layerIndex, - dynamicLayer.tileset, - dynamicLayer.x, - dynamicLayer.y - ); - - this.scene.sys.displayList.add(staticLayer); - - dynamicLayer.destroy(); - - return staticLayer; - }, - - /** - * See component documentation. If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#copy - * @since 3.0.0 - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'copy')) { return this; } - - if (layer !== null) - { - TilemapComponents.Copy( - srcTileX, srcTileY, - width, height, - destTileX, destTileY, - recalculateFaces, layer - ); - } - - return this; - }, - - /** - * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set - * to this new layer. - * - * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer - * @since 3.0.0 - * - * @param {string} name - The name of this layer. Must be unique within the map. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {integer} width - The width of the layer in tiles. If not specified, it will default - * to the map's width. - * @param {integer} height - The height of the layer in tiles. If not specified, it will default - * to the map's height. - * @param {integer} tileWidth - The width of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileWidth. - * @param {integer} tileHeight - The height of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileHeight. - * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. - */ - createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) - { - if (tileWidth === undefined) { tileWidth = tileset.tileWidth; } - if (tileHeight === undefined) { tileHeight = tileset.tileHeight; } - if (width === undefined) { width = this.width; } - if (height === undefined) { height = this.height; } - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - var index = this.getLayerIndex(name); - - if (index !== null) - { - console.warn('Cannot create blank layer: layer with matching name already exists ' + name); - return null; - } - - var layerData = new LayerData({ - name: name, - tileWidth: tileWidth, - tileHeight: tileHeight, - width: width, - height: height - }); - - var row; - - for (var tileY = 0; tileY < height; tileY++) - { - row = []; - - for (var tileX = 0; tileX < width; tileX++) - { - row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight)); - } - - layerData.data.push(row); - } - - this.layers.push(layerData); - this.currentLayerIndex = this.layers.length - 1; - - var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); - this.scene.sys.displayList.add(dynamicLayer); - - return dynamicLayer; - }, - - /** - * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more - * information. - * - * @method Phaser.Tilemaps.Tilemap#createDynamicLayer - * @since 3.0.0 - * - * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * - * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. - */ - createDynamicLayer: function (layerID, tileset, x, y) - { - var index = this.getLayerIndex(layerID); - - if (index === null) - { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); - return null; - } - - var layerData = this.layers[index]; - - // Check for an associated static or dynamic tilemap layer - if (layerData.tilemapLayer) - { - console.warn('Cannot create dynamic tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); - return null; - } - - this.currentLayerIndex = index; - - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. - if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } - if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } - - var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); - this.scene.sys.displayList.add(layer); - - return layer; - }, - - /** - * Creates a Sprite for every object matching the given gid in the map data. All properties from - * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy - * way to configure Sprite properties from within the map editor. For example giving an object a - * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. - * - * @method Phaser.Tilemaps.Tilemap#createFromObjects - * @since 3.0.0 - * - * @param {string} name - The name of the object layer (from Tiled) to create Sprites from. - * @param {(integer|string)} id - Either the id (object), gid (tile object) or name (object or - * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects - * with the same graphic. The same name can be used on multiple objects. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromObjects: function (name, id, spriteConfig, scene) - { - if (spriteConfig === undefined) { spriteConfig = {}; } - if (scene === undefined) { scene = this.scene; } - - var objectLayer = this.getObjectLayer(name); - if (!objectLayer) - { - console.warn('Cannot create from object. Invalid objectgroup name given: ' + name); - return; - } - - var objects = objectLayer.objects; - var sprites = []; - - for (var i = 0; i < objects.length; i++) - { - var found = false; - var obj = objects[i]; - - if (obj.gid !== undefined && typeof id === 'number' && obj.gid === id || - obj.id !== undefined && typeof id === 'number' && obj.id === id || - obj.name !== undefined && typeof id === 'string' && obj.name === id) - { - found = true; - } - - if (found) - { - var config = Extend({}, spriteConfig, obj.properties); - - config.x = obj.x; - config.y = obj.y; - - var sprite = this.scene.make.sprite(config); - - sprite.name = obj.name; - - if (obj.width) { sprite.displayWidth = obj.width; } - if (obj.height) { sprite.displayHeight = obj.height; } - - // Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin. - var offset = { - x: sprite.originX * sprite.displayWidth, - y: (sprite.originY - 1) * sprite.displayHeight - }; - - // If the object is rotated, then the origin offset also needs to be rotated. - if (obj.rotation) - { - var angle = DegToRad(obj.rotation); - Rotate(offset, angle); - sprite.rotation = angle; - } - - sprite.x += offset.x; - sprite.y += offset.y; - - if (obj.flippedHorizontal !== undefined || obj.flippedVertical !== undefined) - { - sprite.setFlip(obj.flippedHorizontal, obj.flippedVertical); - } - - if (!obj.visible) { sprite.visible = false; } - - sprites.push(sprite); - } - } - - return sprites; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.Tilemap#createFromTiles - * @since 3.0.0 - * - * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.GameObjects.Sprite[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, layer); - }, - - /** - * Creates a new StaticTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for - * more information. - * - * @method Phaser.Tilemaps.Tilemap#createStaticLayer - * @since 3.0.0 - * - * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * - * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed. - */ - createStaticLayer: function (layerID, tileset, x, y) - { - var index = this.getLayerIndex(layerID); - - if (index === null) - { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); - return null; - } - - var layerData = this.layers[index]; - - // Check for an associated static or dynamic tilemap layer - if (layerData.tilemapLayer) - { - console.warn('Cannot create static tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); - return null; - } - - this.currentLayerIndex = index; - - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. - if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } - if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } - - var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); - this.scene.sys.displayList.add(layer); - - return layer; - }, - - /** - * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any - * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. - * - * @method Phaser.Tilemaps.Tilemap#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllLayers(); - this.tilesets.length = 0; - this.objects.length = 0; - this.scene = undefined; - }, - - /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * If no layer specified, the map's current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - fill: function (index, tileX, tileY, width, height, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'fill')) { return this; } - - if (layer !== null) - { - TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, layer); - } - - return this; - }, - - /** - * For each object in the given object layer, run the given filter callback function. Any - * objects that pass the filter test (i.e. where the callback returns true) will returned as a - * new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.Tilemap#filterObjects - * @since 3.0.0 - * - * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. - * @param {TilemapFilterCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * - * @return {?Phaser.GameObjects.GameObject[]} An array of object that match the search, or null if the objectLayer given was invalid. - */ - filterObjects: function (objectLayer, callback, context) - { - if (typeof objectLayer === 'string') - { - var name = objectLayer; - - objectLayer = this.getObjectLayer(objectLayer); - - if (!objectLayer) - { - console.warn('No object layer found with the name: ' + name); - return null; - } - } - - return objectLayer.objects.filter(callback, context); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. - */ - findByIndex: function (findIndex, skip, reverse, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FindByIndex(findIndex, skip, reverse, layer); - }, - - /** - * Find the first object in the given object layer that satisfies the provided testing function. - * I.e. finds the first object for which `callback` returns true. Similar to - * Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.Tilemap#findObject - * @since 3.0.0 - * - * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. - * @param {TilemapFindCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * - * @return {?Phaser.GameObjects.GameObject} An object that matches the search, or null if no object found. - */ - findObject: function (objectLayer, callback, context) - { - if (typeof objectLayer === 'string') - { - var name = objectLayer; - - objectLayer = this.getObjectLayer(objectLayer); - - if (!objectLayer) - { - console.warn('No object layer found with the name: ' + name); - return null; - } - } - - return objectLayer.objects.find(callback, context) || null; - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#findTile - * @since 3.0.0 - * - * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#forEachTile - * @since 3.0.0 - * - * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer !== null) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); - } - - return this; - }, - - /** - * Gets the image layer index based on its name. - * - * @method Phaser.Tilemaps.Tilemap#getImageIndex - * @since 3.0.0 - * - * @param {string} name - The name of the image to get. - * - * @return {integer} The index of the image in this tilemap, or null if not found. - */ - getImageIndex: function (name) - { - return this.getIndex(this.images, name); - }, - - /** - * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name - * property matches the given `name`. - * - * @method Phaser.Tilemaps.Tilemap#getIndex - * @since 3.0.0 - * - * @param {array} location - The Tilemap array to search. - * @param {string} name - The name of the array element to get. - * - * @return {number} The index of the element in the array, or null if not found. - */ - getIndex: function (location, name) - { - for (var i = 0; i < location.length; i++) - { - if (location[i].name === name) - { - return i; - } - } - - return null; - }, - - /** - * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid - * `layer` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayer - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the maps current layer index. - * - * @return {Phaser.Tilemaps.LayerData} The corresponding LayerData within this.layers. - */ - getLayer: function (layer) - { - var index = this.getLayerIndex(layer); - - return index !== null ? this.layers[index] : null; - }, - - /** - * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer - * is found with that name. - * - * @method Phaser.Tilemaps.Tilemap#getObjectLayer - * @since 3.0.0 - * - * @param {string} [name] - The name of the object layer from Tiled. - * - * @return {?Phaser.Tilemaps.ObjectLayer} The corresponding ObjectLayer within this.objects or null. - */ - getObjectLayer: function (name) - { - var index = this.getIndex(this.objects, name); - - return index !== null ? this.objects[index] : null; - }, - - /** - * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid - * `layer` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayerIndex - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {integer} The LayerData index within this.layers. - */ - getLayerIndex: function (layer) - { - if (layer === undefined) - { - return this.currentLayerIndex; - } - else if (typeof layer === 'string') - { - return this.getLayerIndexByName(layer); - } - else if (typeof layer === 'number' && layer < this.layers.length) - { - return layer; - } - else if (layer instanceof StaticTilemapLayer || layer instanceof DynamicTilemapLayer) - { - return layer.layerIndex; - } - else - { - return null; - } - }, - - /** - * Gets the index of the LayerData within this.layers that has the given `name`, or null if an - * invalid `name` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayerIndexByName - * @since 3.0.0 - * - * @param {string} name - The name of the layer to get. - * - * @return {integer} The LayerData index within this.layers. - */ - getLayerIndexByName: function (name) - { - return this.getIndex(this.layers, name); - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - getTileAt: function (tileX, tileY, nonNull, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) - { - return null; - } - else - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, layer); - } - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithinShape - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithinShape: function (shape, filteringOptions, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); - }, - - /** - * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an - * invalid `name` is given. - * - * @method Phaser.Tilemaps.Tilemap#getTilesetIndex - * @since 3.0.0 - * - * @param {string} name - The name of the Tileset to get. - * - * @return {integer} The Tileset index within this.tilesets. - */ - getTilesetIndex: function (name) - { - return this.getIndex(this.tilesets, name); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?boolean} Returns a boolean, or null if the layer given was invalid. - */ - hasTileAt: function (tileX, tileY, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.HasTileAt(tileX, tileY, layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?boolean} Returns a boolean, or null if the layer given was invalid. - */ - hasTileAtWorldXY: function (worldX, worldY, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, layer); - }, - - /** - * The LayerData object that is currently selected in the map. You can set this property using - * any type supported by setLayer. - * - * @name Phaser.Tilemaps.Tilemap#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - layer: { - get: function () - { - return this.layers[this.currentLayerIndex]; - }, - - set: function (layer) - { - this.setLayer(layer); - } - }, - - /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * If no layer specified, the maps current layer is used. - * - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTileAt - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTileAt')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, layer); - }, - - /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * If no layer specified, the maps current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTileAtWorldXY - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTileAtWorldXY')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, layer); - }, - - /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTilesAt - * @since 3.0.0 - * - * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTilesAt')) { return this; } - - if (layer !== null) - { - TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, layer); - } - - return this; - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - randomize: function (tileX, tileY, width, height, indexes, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'randomize')) { return this; } - - if (layer !== null) - { - TilemapComponents.Randomize(tileX, tileY, width, height, indexes, layer); - } - - return this; - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - calculateFacesAt: function (tileX, tileY, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.CalculateFacesAt(tileX, tileY, layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - calculateFacesWithin: function (tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, layer); - - return this; - }, - - /** - * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or - * DynamicTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeAllLayers - * @since 3.0.0 - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - removeAllLayers: function () - { - // Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData - for (var i = 0; i < this.layers.length; i++) - { - if (this.layers[i].tilemapLayer) - { - this.layers[i].tilemapLayer.destroy(); - } - } - - this.layers.length = 0; - this.currentLayerIndex = 0; - - return this; - }, - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeTileAt - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'removeTileAt')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); - }, - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'removeTileAtWorldXY')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - renderDebug: function (graphics, styleConfig, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.RenderDebug(graphics, styleConfig, layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#replaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'replaceByIndex')) { return this; } - - if (layer !== null) - { - TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollision - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollision: function (indexes, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setTileIndexCallback: function (indexes, callback, callbackContext, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} [callbackContext] - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, layer); - - return this; - }, - - /** - * Sets the current layer to the LayerData associated with `layer`. - * - * @method Phaser.Tilemaps.Tilemap#setLayer - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setLayer: function (layer) - { - var index = this.getLayerIndex(layer); - - if (index !== null) - { - this.currentLayerIndex = index; - } - - return this; - }, - - /** - * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and - * tileHeight for all layers. This also updates the base size on all tiles across all layers. - * - * @method Phaser.Tilemaps.Tilemap#setBaseTileSize - * @since 3.0.0 - * - * @param {integer} tileWidth - The width of the tiles the map uses for calculations. - * @param {integer} tileHeight - The height of the tiles the map uses for calculations. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setBaseTileSize: function (tileWidth, tileHeight) - { - this.tileWidth = tileWidth; - this.tileHeight = tileHeight; - this.widthInPixels = this.width * tileWidth; - this.heightInPixels = this.height * tileHeight; - - // Update the base tile size on all layers & tiles - for (var i = 0; i < this.layers.length; i++) - { - this.layers[i].baseWidth = tileWidth; - this.layers[i].baseHeight = tileHeight; - - var mapData = this.layers[i].data; - var mapWidth = this.layers[i].width; - var mapHeight = this.layers[i].height; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile !== null) - { - tile.setSize(undefined, undefined, tileWidth, tileHeight); - } - } - } - } - - return this; - }, - - /** - * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's - * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any - * tiles the layer has. - * - * @method Phaser.Tilemaps.Tilemap#setLayerTileSize - * @since 3.0.0 - * - * @param {integer} tileWidth - The width of the tiles (in pixels) in the layer. - * @param {integer} tileHeight - The height of the tiles (in pixels) in the layer. - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setLayerTileSize: function (tileWidth, tileHeight, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - layer.tileWidth = tileWidth; - layer.tileHeight = tileHeight; - - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile !== null) { tile.setSize(tileWidth, tileHeight); } - } - } - - return this; - }, - - /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - shuffle: function (tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'shuffle')) { return this; } - - if (layer !== null) - { - TilemapComponents.Shuffle(tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#swapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - swapByIndex: function (indexA, indexB, tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'swapByIndex')) { return this; } - - if (layer !== null) - { - TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?number} Returns a number, or null if the layer given was invalid. - */ - tileToWorldX: function (tileX, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldX(tileX, camera, layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?number} Returns a number, or null if the layer given was invalid. - */ - tileToWorldY: function (tileX, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldY(tileX, camera, layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. - */ - tileToWorldXY: function (tileX, tileY, point, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer); - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#weightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - weightedRandomize: function (tileX, tileY, width, height, weightedIndexes, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'weightedRandomize')) { return this; } - - if (layer !== null) - { - TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, layer); - } - - return this; - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?number} Returns a number, or null if the layer given was invalid. - */ - worldToTileX: function (worldX, snapToFloor, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?number} Returns a number, or null if the layer given was invalid. - */ - worldToTileY: function (worldY, snapToFloor, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer); - }, - - /** - * Used internally to check if a layer is static and prints out a warning. - * - * @method Phaser.Tilemaps.Tilemap#_isStaticCall - * @private - * @since 3.0.0 - * - * @return {boolean} - */ - _isStaticCall: function (layer, functionName) - { - if (layer.tilemapLayer instanceof StaticTilemapLayer) - { - console.warn(functionName + ': You cannot change the tiles in a static tilemap layer'); - return true; - } - else - { - return false; - } - } - -}); - -module.exports = Tilemap; - - -/***/ }), -/* 312 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var MapData = __webpack_require__(103); -var ParseTileLayers = __webpack_require__(629); -var ParseTilesets = __webpack_require__(628); - -/** - * @namespace Phaser.Tilemaps.Parsers.Impact - */ - -/** - * Parses a Weltmeister JSON object into a new MapData object. - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {object} json - The Weltmeister JSON object. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [width=10] - The width of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer} [height=10] - The height of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. Pass in `null` for no data. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty * location will get a Tile object with an index of -1. If you've a large sparsely populated map and * the tile data doesn't need to change then setting this value to `true` will help with memory * consumption. However if your map is small or you need to update the tiles dynamically, then leave * the default value set. - * - * @return {?object} [description] + * + * @return {Phaser.Tilemaps.Tilemap} */ -var ParseWeltmeister = function (name, json, insertNull) +GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, width, height, data, insertNull) { - if (json.layer.length === 0) - { - console.warn('No layers found in the Weltmeister map: ' + name); - return null; - } + // Allow users to specify null to indicate that they want the default value, since null is + // shorter & more legible than undefined. Convert null to undefined to allow ParseToTilemap + // defaults to take effect. - var width = 0; - var height = 0; - - for (var i = 0; i < json.layer.length; i++) - { - if (json.layer[i].width > width) { width = json.layer[i].width; } - if (json.layer[i].height > height) { height = json.layer[i].height; } - } - - var mapData = new MapData({ - width: width, - height: height, - name: name, - tileWidth: json.layer[0].tilesize, - tileHeight: json.layer[0].tilesize, - format: Formats.WELTMEISTER - }); - - mapData.layers = ParseTileLayers(json, insertNull); - mapData.tilesets = ParseTilesets(json); - - return mapData; -}; - -module.exports = ParseWeltmeister; - - -/***/ }), -/* 313 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); - -/** - * @classdesc - * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled - * object layer, except: - * - "x" & "y" properties are ignored since these cannot be changed in Tiled. - * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they - * are ignored as well. - * - "draworder" is ignored. - * - * @class ObjectLayer - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {object} [config] - [description] - */ -var ObjectLayer = new Class({ - - initialize: - - function ObjectLayer (config) - { - if (config === undefined) { config = {}; } - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#name - * @type {string} - * @since 3.0.0 - */ - this.name = GetFastValue(config, 'name', 'object layer'); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#opacity - * @type {number} - * @since 3.0.0 - */ - this.opacity = GetFastValue(config, 'opacity', 1); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = GetFastValue(config, 'properties', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#propertyTypes - * @type {object} - * @since 3.0.0 - */ - this.propertyTypes = GetFastValue(config, 'propertytypes', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#type - * @type {string} - * @since 3.0.0 - */ - this.type = GetFastValue(config, 'type', 'objectgroup'); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#visible - * @type {boolean} - * @since 3.0.0 - */ - this.visible = GetFastValue(config, 'visible', true); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#objects - * @type {Phaser.GameObjects.GameObject[]} - * @since 3.0.0 - */ - this.objects = GetFastValue(config, 'objects', []); - } + if (key === null) { key = undefined; } + if (tileWidth === null) { tileWidth = undefined; } + if (tileHeight === null) { tileHeight = undefined; } + if (width === null) { width = undefined; } + if (height === null) { height = undefined; } + return ParseToTilemap(this.scene, key, tileWidth, tileHeight, width, height, data, insertNull); }); -module.exports = ObjectLayer; +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns /***/ }), -/* 314 */ +/* 443 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -74519,252 +98622,59 @@ module.exports = ObjectLayer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Pick = __webpack_require__(633); -var ParseGID = __webpack_require__(316); - -var copyPoints = function (p) { return { x: p.x, y: p.y }; }; - -var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; +var GameObjectCreator = __webpack_require__(13); +var ParseToTilemap = __webpack_require__(132); /** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject - * @since 3.0.0 - * - * @param {object} tiledObject - [description] - * @param {number} [offsetX=0] - [description] - * @param {number} [offsetY=0] - [description] - * - * @return {object} [description] - */ -var ParseObject = function (tiledObject, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - var parsedObject = Pick(tiledObject, commonObjectProps); - - parsedObject.x += offsetX; - parsedObject.y += offsetY; - - if (tiledObject.gid) - { - // Object tiles - var gidInfo = ParseGID(tiledObject.gid); - parsedObject.gid = gidInfo.gid; - parsedObject.flippedHorizontal = gidInfo.flippedHorizontal; - parsedObject.flippedVertical = gidInfo.flippedVertical; - parsedObject.flippedAntiDiagonal = gidInfo.flippedAntiDiagonal; - } - else if (tiledObject.polyline) - { - parsedObject.polyline = tiledObject.polyline.map(copyPoints); - } - else if (tiledObject.polygon) - { - parsedObject.polygon = tiledObject.polygon.map(copyPoints); - } - else if (tiledObject.ellipse) - { - parsedObject.ellipse = tiledObject.ellipse; - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - } - else if (tiledObject.text) - { - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - parsedObject.text = tiledObject.text; - } - else - { - // Otherwise, assume it is a rectangle - parsedObject.rectangle = true; - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - } - - return parsedObject; -}; - -module.exports = ParseObject; - - -/***/ }), -/* 315 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + * @typedef {object} TilemapConfig + * + * @property {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @property {integer[][]} [data] - Instead of loading from the cache, you can also load directly from a 2D array of tile indexes. + * @property {integer} [tileWidth=32] - The width of a tile in pixels. + * @property {integer} [tileHeight=32] - The height of a tile in pixels. + * @property {integer} [width=10] - The width of the map in tiles. + * @property {integer} [height=10] - The height of the map in tiles. + * @property {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, + * in the map data are handled. If `true`, empty locations will get a value of `null`. If `false`, + * empty location will get a Tile object with an index of -1. If you've a large sparsely populated + * map and the tile data doesn't need to change then setting this value to `true` will help with + * memory consumption. However if your map is small or you need to update the tiles dynamically, + * then leave the default value set. */ -var Class = __webpack_require__(0); - /** - * @classdesc - * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. * - * Image Collections are normally created automatically when Tiled data is loaded. - * - * @class ImageCollection - * @memberOf Phaser.Tilemaps - * @constructor + * @method Phaser.GameObjects.GameObjectCreator#tilemap * @since 3.0.0 * - * @param {string} name - The name of the image collection in the map data. - * @param {integer} firstgid - The first image index this image collection contains. - * @param {integer} [width=32] - Width of widest image (in pixels). - * @param {integer} [height=32] - Height of tallest image (in pixels). - * @param {integer} [margin=0] - The margin around all images in the collection (in pixels). - * @param {integer} [spacing=0] - The spacing between each image in the collection (in pixels). - * @param {object} [properties={}] - Custom Image Collection properties. + * @param {TilemapConfig} [config] - The config options for the Tilemap. + * + * @return {Phaser.Tilemaps.Tilemap} */ -var ImageCollection = new Class({ - - initialize: - - function ImageCollection (name, firstgid, width, height, margin, spacing, properties) - { - if (width === undefined || width <= 0) { width = 32; } - if (height === undefined || height <= 0) { height = 32; } - if (margin === undefined) { margin = 0; } - if (spacing === undefined) { spacing = 0; } - - /** - * The name of the Image Collection. - * - * @name Phaser.Tilemaps.ImageCollection#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The Tiled firstgid value. - * This is the starting index of the first image index this Image Collection contains. - * - * @name Phaser.Tilemaps.ImageCollection#firstgid - * @type {integer} - * @since 3.0.0 - */ - this.firstgid = firstgid | 0; - - /** - * The width of the widest image (in pixels). - * - * @name Phaser.Tilemaps.ImageCollection#imageWidth - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageWidth = width | 0; - - /** - * The height of the tallest image (in pixels). - * - * @name Phaser.Tilemaps.ImageCollection#imageHeight - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageHeight = height | 0; - - /** - * The margin around the images in the collection (in pixels). - * Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.ImageCollection#imageMarge - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageMargin = margin | 0; - - /** - * The spacing between each image in the collection (in pixels). - * Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.ImageCollection#imageSpacing - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageSpacing = spacing | 0; - - /** - * Image Collection-specific properties that are typically defined in the Tiled editor. - * - * @name Phaser.Tilemaps.ImageCollection#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = properties || {}; - - /** - * The cached images that are a part of this collection. - * - * @name Phaser.Tilemaps.ImageCollection#images - * @type {array} - * @readOnly - * @since 3.0.0 - */ - this.images = []; - - /** - * The total number of images in the image collection. - * - * @name Phaser.Tilemaps.ImageCollection#total - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.total = 0; - }, - - /** - * Returns true if and only if this image collection contains the given image index. - * - * @method Phaser.Tilemaps.ImageCollection#containsImageIndex - * @since 3.0.0 - * - * @param {integer} imageIndex - The image index to search for. - * - * @return {boolean} True if this Image Collection contains the given index. - */ - containsImageIndex: function (imageIndex) - { - return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)); - }, - - /** - * Add an image to this Image Collection. - * - * @method Phaser.Tilemaps.ImageCollection#addImage - * @since 3.0.0 - * - * @param {integer} gid - The gid of the image in the Image Collection. - * @param {string} image - The the key of the image in the Image Collection and in the cache. - * - * @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object. - */ - addImage: function (gid, image) - { - this.images.push({ gid: gid, image: image }); - this.total++; - - return this; - } +GameObjectCreator.register('tilemap', function (config) +{ + // Defaults are applied in ParseToTilemap + var c = (config !== undefined) ? config : {}; + return ParseToTilemap( + this.scene, + c.key, + c.tileWidth, + c.tileHeight, + c.width, + c.height, + c.data, + c.insertNull + ); }); -module.exports = ImageCollection; - /***/ }), -/* 316 */ +/* 444 */ /***/ (function(module, exports) { /** @@ -74773,435 +98683,3131 @@ module.exports = ImageCollection; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var FLIPPED_HORIZONTAL = 0x80000000; -var FLIPPED_VERTICAL = 0x40000000; -var FLIPPED_ANTI_DIAGONAL = 0x20000000; // Top-right is swapped with bottom-left corners - /** - * See Tiled documentation on tile flipping: - * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseGID + * @method Phaser.Tilemaps.StaticTilemapLayer#renderCanvas * @since 3.0.0 - * - * @param {number} gid - [description] - * - * @return {object} [description] - */ -var ParseGID = function (gid) -{ - var flippedHorizontal = Boolean(gid & FLIPPED_HORIZONTAL); - var flippedVertical = Boolean(gid & FLIPPED_VERTICAL); - var flippedAntiDiagonal = Boolean(gid & FLIPPED_ANTI_DIAGONAL); - gid = gid & ~(FLIPPED_HORIZONTAL | FLIPPED_VERTICAL | FLIPPED_ANTI_DIAGONAL); - - // Parse the flip flags into something Phaser can use - var rotation = 0; - var flipped = false; - - if (flippedHorizontal && flippedVertical && flippedAntiDiagonal) - { - rotation = Math.PI / 2; - flipped = true; - } - else if (flippedHorizontal && flippedVertical && !flippedAntiDiagonal) - { - rotation = Math.PI; - flipped = false; - } - else if (flippedHorizontal && !flippedVertical && flippedAntiDiagonal) - { - rotation = Math.PI / 2; - flipped = false; - } - else if (flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) - { - rotation = 0; - flipped = true; - } - else if (!flippedHorizontal && flippedVertical && flippedAntiDiagonal) - { - rotation = 3 * Math.PI / 2; - flipped = false; - } - else if (!flippedHorizontal && flippedVertical && !flippedAntiDiagonal) - { - rotation = Math.PI; - flipped = true; - } - else if (!flippedHorizontal && !flippedVertical && flippedAntiDiagonal) - { - rotation = 3 * Math.PI / 2; - flipped = true; - } - else if (!flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) - { - rotation = 0; - flipped = false; - } - - return { - gid: gid, - flippedHorizontal: flippedHorizontal, - flippedVertical: flippedVertical, - flippedAntiDiagonal: flippedAntiDiagonal, - rotation: rotation, - flipped: flipped - }; -}; - -module.exports = ParseGID; - - -/***/ }), -/* 317 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var MapData = __webpack_require__(103); -var ParseTileLayers = __webpack_require__(637); -var ParseImageLayers = __webpack_require__(635); -var ParseTilesets = __webpack_require__(634); -var ParseObjectLayers = __webpack_require__(632); -var BuildTilesetIndex = __webpack_require__(631); -var AssignTileProperties = __webpack_require__(630); - -/** - * @namespace Phaser.Tilemaps.Parsers.Tiled - */ - -/** - * Parses a Tiled JSON object into a new MapData object. - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {object} json - The Tiled JSON object. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {?Phaser.Tilemaps.MapData} [description] - */ -var ParseJSONTiled = function (name, json, insertNull) -{ - if (json.orientation !== 'orthogonal') - { - console.warn('Only orthogonal map types are supported in this version of Phaser'); - return null; - } - - // Map data will consist of: layers, objects, images, tilesets, sizes - var mapData = new MapData({ - width: json.width, - height: json.height, - name: name, - tileWidth: json.tilewidth, - tileHeight: json.tileheight, - orientation: json.orientation, - format: Formats.TILED_JSON, - version: json.version, - properties: json.properties - }); - - mapData.layers = ParseTileLayers(json, insertNull); - mapData.images = ParseImageLayers(json); - - var sets = ParseTilesets(json); - mapData.tilesets = sets.tilesets; - mapData.imageCollections = sets.imageCollections; - - mapData.objects = ParseObjectLayers(json); - - mapData.tiles = BuildTilesetIndex(mapData); - - AssignTileProperties(mapData); - - return mapData; -}; - -module.exports = ParseJSONTiled; - - -/***/ }), -/* 318 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var Parse2DArray = __webpack_require__(217); - -/** - * Parses a CSV string of tile indexes into a new MapData object with a single layer. - * - * @function Phaser.Tilemaps.Parsers.ParseCSV - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {string} data - CSV string of tile indexes. - * @param {integer} tileWidth - The width of a tile in pixels. - * @param {integer} tileHeight - The height of a tile in pixels. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.MapData} [description] - */ -var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) -{ - var array2D = data - .trim() - .split('\n') - .map(function (row) { return row.split(','); }); - - var map = Parse2DArray(name, array2D, tileWidth, tileHeight, insertNull); - map.format = Formats.CSV; - - return map; -}; - -module.exports = ParseCSV; - - -/***/ }), -/* 319 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var Parse2DArray = __webpack_require__(217); -var ParseCSV = __webpack_require__(318); -var ParseJSONTiled = __webpack_require__(317); -var ParseWeltmeister = __webpack_require__(312); - -/** - * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format - * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & - * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from - * the map data. - * - * @function Phaser.Tilemaps.Parsers.Parse - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {integer} mapFormat - See ../Formats.js. - * @param {(integer[][]|string|object)} data - 2D array, CSV string or Tiled JSON object. - * @param {integer} tileWidth - The width of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param {integer} tileHeight - The height of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.MapData} [description] - */ -var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) -{ - var newMap; - - switch (mapFormat) - { - case (Formats.ARRAY_2D): - newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull); - break; - case (Formats.CSV): - newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull); - break; - case (Formats.TILED_JSON): - newMap = ParseJSONTiled(name, data, insertNull); - break; - case (Formats.WELTMEISTER): - newMap = ParseWeltmeister(name, data, insertNull); - break; - default: - console.warn('Unrecognized tilemap data format: ' + mapFormat); - newMap = null; - } - - return newMap; -}; - -module.exports = Parse; - - -/***/ }), -/* 320 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tile = __webpack_require__(66); -var IsInLayerBounds = __webpack_require__(105); -var CalculateFacesAt = __webpack_require__(220); - -/** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * @function Phaser.Tilemaps.Components.RemoveTileAt * @private - * @since 3.0.0 * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer) +var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (replaceWithNull === undefined) { replaceWithNull = false; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + src.cull(camera); - var tile = layer.data[tileY][tileX]; - if (tile === null) + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + + if (tileCount === 0) { - return null; + return; + } + + var camMatrix = renderer._tempMatrix1; + var layerMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + var ctx = renderer.currentContext; + var gidMap = src.gidMap; + + ctx.save(); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + layerMatrix.e = src.x; + layerMatrix.f = src.y; + + camMatrix.multiply(layerMatrix, calcMatrix); + + calcMatrix.copyToContext(ctx); } else { - layer.data[tileY][tileX] = replaceWithNull - ? null - : new Tile(layer, -1, tileX, tileY, tile.width, tile.height); + // Undo the camera scroll + layerMatrix.e -= camera.scrollX * src.scrollFactorX; + layerMatrix.f -= camera.scrollY * src.scrollFactorY; + + layerMatrix.copyToContext(ctx); } - // Recalculate faces only if the removed tile was a colliding tile - if (recalculateFaces && tile && tile.collides) + var alpha = camera.alpha * src.alpha; + + ctx.globalAlpha = camera.alpha * src.alpha; + + for (var i = 0; i < tileCount; i++) { - CalculateFacesAt(tileX, tileY, layer); - } + var tile = renderTiles[i]; - return tile; -}; + var tileset = gidMap[tile.index]; -module.exports = RemoveTileAt; - - -/***/ }), -/* 321 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsInLayerBounds = __webpack_require__(105); - -/** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @function Phaser.Tilemaps.Components.HasTileAt - * @private - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var HasTileAt = function (tileX, tileY, layer) -{ - if (IsInLayerBounds(tileX, tileY, layer)) - { - var tile = layer.data[tileY][tileX]; - return (tile !== null && tile.index > -1); - } - else - { - return false; - } - -}; - -module.exports = HasTileAt; - - -/***/ }), -/* 322 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * @function Phaser.Tilemaps.Components.ReplaceByIndex - * @private - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - if (tiles[i] && tiles[i].index === findIndex) + if (!tileset) { - tiles[i].index = newIndex; + continue; + } + + var image = tileset.image.getSourceImage(); + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords) + { + var halfWidth = tile.width / 2; + var halfHeight = tile.height / 2; + + ctx.save(); + + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale((tile.flipX) ? -1 : 1, (tile.flipY) ? -1 : 1); + } + + ctx.globalAlpha = alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + -halfWidth, -halfHeight, + tile.width, tile.height + ); + + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = StaticTilemapLayerCanvasRenderer; + + +/***/ }), +/* 445 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * A Static Tilemap Layer renders immediately and does not use any batching. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + var tilesets = src.tileset; + + var pipeline = src.pipeline; + var pipelineVertexBuffer = pipeline.vertexBuffer; + + renderer.setPipeline(pipeline); + + pipeline.modelIdentity(); + pipeline.modelTranslate(src.x - (camera.scrollX * src.scrollFactorX), src.y - (camera.scrollY * src.scrollFactorY), 0); + pipeline.modelScale(src.scaleX, src.scaleY, 1); + pipeline.viewLoad2D(camera.matrix.matrix); + + for (var i = 0; i < tilesets.length; i++) + { + src.upload(camera, i); + + if (src.vertexCount[i] > 0) + { + if (renderer.currentPipeline && renderer.currentPipeline.vertexCount > 0) + { + renderer.flush(); + } + + pipeline.vertexBuffer = src.vertexBuffer[i]; + + renderer.setPipeline(pipeline); + + renderer.setTexture2D(tilesets[i].glTexture, 0); + + renderer.gl.drawArrays(pipeline.topology, 0, src.vertexCount[i]); + } + } + + // Restore the pipeline + pipeline.vertexBuffer = pipelineVertexBuffer; + + pipeline.viewIdentity(); + pipeline.modelIdentity(); +}; + +module.exports = StaticTilemapLayerWebGLRenderer; + + +/***/ }), +/* 446 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(445); +} + +if (true) +{ + renderCanvas = __webpack_require__(444); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 447 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + + if (tileCount === 0) + { + return; + } + + var camMatrix = renderer._tempMatrix1; + var layerMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + var ctx = renderer.currentContext; + var gidMap = src.gidMap; + + ctx.save(); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + layerMatrix.e = src.x; + layerMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(layerMatrix, calcMatrix); + + calcMatrix.copyToContext(ctx); + } + else + { + layerMatrix.e -= camera.scrollX * src.scrollFactorX; + layerMatrix.f -= camera.scrollY * src.scrollFactorY; + + layerMatrix.copyToContext(ctx); + } + + var alpha = camera.alpha * src.alpha; + + for (var i = 0; i < tileCount; i++) + { + var tile = renderTiles[i]; + + var tileset = gidMap[tile.index]; + + if (!tileset) + { + continue; + } + + var image = tileset.image.getSourceImage(); + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords) + { + var halfWidth = tile.width / 2; + var halfHeight = tile.height / 2; + + ctx.save(); + + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale((tile.flipX) ? -1 : 1, (tile.flipY) ? -1 : 1); + } + + ctx.globalAlpha = alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + -halfWidth, -halfHeight, + tile.width, tile.height + ); + + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = DynamicTilemapLayerCanvasRenderer; + + +/***/ }), +/* 448 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + var alpha = camera.alpha * src.alpha; + + if (tileCount === 0 || alpha <= 0) + { + return; + } + + var gidMap = src.gidMap; + var pipeline = src.pipeline; + + var getTint = Utils.getTintAppendFloatAlpha; + + var scrollFactorX = src.scrollFactorX; + var scrollFactorY = src.scrollFactorY; + + var x = src.x; + var y = src.y; + + var sx = src.scaleX; + var sy = src.scaleY; + + var tilesets = src.tileset; + + // Loop through each tileset in this layer, drawing just the tiles that are in that set each time + // Doing it this way around allows us to batch tiles using the same tileset + for (var c = 0; c < tilesets.length; c++) + { + var currentSet = tilesets[c]; + var texture = currentSet.glTexture; + + for (var i = 0; i < tileCount; i++) + { + var tile = renderTiles[i]; + + var tileset = gidMap[tile.index]; + + if (tileset !== currentSet) + { + // Skip tiles that aren't in this set + continue; + } + + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords === null) + { + continue; + } + + var frameWidth = tile.width; + var frameHeight = tile.height; + + var frameX = tileTexCoords.x; + var frameY = tileTexCoords.y; + + var tw = tile.width * 0.5; + var th = tile.height * 0.5; + + var tint = getTint(tile.tint, alpha * tile.alpha); + + pipeline.batchTexture( + src, + texture, + texture.width, texture.height, + (tw + x + tile.pixelX) * sx, (th + y + tile.pixelY) * sy, + tile.width, tile.height, + sx, sy, + tile.rotation, + tile.flipX, tile.flipY, + scrollFactorX, scrollFactorY, + tw, th, + frameX, frameY, frameWidth, frameHeight, + tint, tint, tint, tint, false, + 0, 0, + camera, + null, + true + ); } } }; -module.exports = ReplaceByIndex; +module.exports = DynamicTilemapLayerWebGLRenderer; /***/ }), -/* 323 */ +/* 449 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(448); +} + +if (true) +{ + renderCanvas = __webpack_require__(447); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 450 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(99); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var tilesetsNames = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + // A relative filepath to the source image (within Weltmeister) is used for the name + var tilesetName = layer.tilesetName; + + // Only add unique tilesets that have a valid name. Collision layers will have a blank name. + if (tilesetName !== '' && tilesetsNames.indexOf(tilesetName) === -1) + { + tilesetsNames.push(tilesetName); + + // Tiles are stored with an ID relative to the tileset, rather than a globally unique ID + // across all tilesets. Also, tilesets in Weltmeister have no margin or padding. + tilesets.push(new Tileset(tilesetName, 0, layer.tilesize, layer.tilesize, 0, 0)); + } + } + + return tilesets; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 451 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LayerData = __webpack_require__(78); +var Tile = __webpack_require__(55); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + var layerData = new LayerData({ + name: layer.name, + width: layer.width, + height: layer.height, + tileWidth: layer.tilesize, + tileHeight: layer.tilesize, + visible: layer.visible === 1 + }); + + var row = []; + var tileGrid = []; + + // Loop through the data field in the JSON. This is a 2D array containing the tile indexes, + // one after the other. The indexes are relative to the tileset that contains the tile. + for (var y = 0; y < layer.data.length; y++) + { + for (var x = 0; x < layer.data[y].length; x++) + { + // In Weltmeister, 0 = no tile, but the Tilemap API expects -1 = no tile. + var index = layer.data[y][x] - 1; + + var tile; + + if (index > -1) + { + tile = new Tile(layerData, index, x, y, layer.tilesize, layer.tilesize); + } + else + { + tile = insertNull + ? null + : new Tile(layerData, -1, x, y, layer.tilesize, layer.tilesize); + } + + row.push(tile); + } + + tileGrid.push(row); + row = []; + } + + layerData.data = tileGrid; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 452 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(20); + +/** + * Copy properties from tileset to tiles. + * + * @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + */ +var AssignTileProperties = function (mapData) +{ + var layerData; + var tile; + var sid; + var set; + var row; + + // go through each of the map data layers + for (var i = 0; i < mapData.layers.length; i++) + { + layerData = mapData.layers[i]; + + set = null; + + // rows of tiles + for (var j = 0; j < layerData.data.length; j++) + { + row = layerData.data[j]; + + // individual tiles + for (var k = 0; k < row.length; k++) + { + tile = row[k]; + + if (tile === null || tile.index < 0) + { + continue; + } + + // find the relevant tileset + sid = mapData.tiles[tile.index][2]; + set = mapData.tilesets[sid]; + + // Ensure that a tile's size matches its tileset + tile.width = set.tileWidth; + tile.height = set.tileHeight; + + // if that tile type has any properties, add them to the tile object + if (set.tileProperties && set.tileProperties[tile.index - set.firstgid]) + { + tile.properties = Extend( + tile.properties, set.tileProperties[tile.index - set.firstgid] + ); + } + } + } + } +}; + +module.exports = AssignTileProperties; + + +/***/ }), +/* 453 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Master list of tiles -> x, y, index in tileset. + * + * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + * + * @return {array} [description] + */ +var BuildTilesetIndex = function (mapData) +{ + var tiles = []; + + for (var i = 0; i < mapData.tilesets.length; i++) + { + var set = mapData.tilesets[i]; + + var x = set.tileMargin; + var y = set.tileMargin; + + var count = 0; + var countX = 0; + var countY = 0; + + for (var t = set.firstgid; t < set.firstgid + set.total; t++) + { + // Can add extra properties here as needed + tiles[t] = [ x, y, i ]; + + x += set.tileWidth + set.tileSpacing; + + count++; + + if (count === set.total) + { + break; + } + + countX++; + + if (countX === set.columns) + { + x = set.tileMargin; + y += set.tileHeight + set.tileSpacing; + + countX = 0; + countY++; + + if (countY === set.rows) + { + break; + } + } + } + } + + return tiles; +}; + +module.exports = BuildTilesetIndex; + + +/***/ }), +/* 454 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); +var ParseObject = __webpack_require__(212); +var ObjectLayer = __webpack_require__(211); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseObjectLayers = function (json) +{ + var objectLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'objectgroup') + { + continue; + } + + var curo = json.layers[i]; + var offsetX = GetFastValue(curo, 'offsetx', 0); + var offsetY = GetFastValue(curo, 'offsety', 0); + var objects = []; + + for (var j = 0; j < curo.objects.length; j++) + { + var parsedObject = ParseObject(curo.objects[j], offsetX, offsetY); + + objects.push(parsedObject); + } + + var objectLayer = new ObjectLayer(curo); + objectLayer.objects = objects; + + objectLayers.push(objectLayer); + } + + return objectLayers; +}; + +module.exports = ParseObjectLayers; + + +/***/ }), +/* 455 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasValue = __webpack_require__(85); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.Pick + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {array} keys - [description] + * + * @return {object} [description] + */ +var Pick = function (object, keys) +{ + var obj = {}; + + for (var i = 0; i < keys.length; i++) + { + var key = keys[i]; + + if (HasValue(object, key)) + { + obj[key] = object[key]; + } + } + + return obj; +}; + +module.exports = Pick; + + +/***/ }), +/* 456 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(99); +var ImageCollection = __webpack_require__(213); +var ParseObject = __webpack_require__(212); + +/** + * Tilesets & Image Collections + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {object} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var imageCollections = []; + var lastSet = null; + var stringID; + + for (var i = 0; i < json.tilesets.length; i++) + { + // name, firstgid, width, height, margin, spacing, properties + var set = json.tilesets[i]; + + if (set.source) + { + console.warn('Phaser can\'t load external tilesets. Use the Embed Tileset button and then export the map again.'); + } + else if (set.image) + { + var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); + + if (json.version > 1) + { + // Tiled 1.2+ + + if (Array.isArray(set.tiles)) + { + var tiles = {}; + var props = {}; + + for (var t = 0; t < set.tiles.length; t++) + { + var tile = set.tiles[t]; + + // Convert tileproperties + if (tile.properties) + { + var newPropData = {}; + + tile.properties.forEach(function (propData) + { + newPropData[propData['name']] = propData['value']; + }); + + props[tile.id] = newPropData; + } + + // Convert objectgroup + if (tile.objectgroup) + { + tiles[tile.id] = { objectgroup: tile.objectgroup }; + + if (tile.objectgroup.objects) + { + var parsedObjects2 = tile.objectgroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + + tiles[tile.id].objectgroup.objects = parsedObjects2; + } + } + } + + newSet.tileData = tiles; + newSet.tileProperties = props; + } + } + else + { + // Tiled 1 + + // Properties stored per-tile in object with string indexes starting at "0" + if (set.tileproperties) + { + newSet.tileProperties = set.tileproperties; + } + + // Object & terrain shapes stored per-tile in object with string indexes starting at "0" + if (set.tiles) + { + newSet.tileData = set.tiles; + + // Parse the objects into Phaser format to match handling of other Tiled objects + for (stringID in newSet.tileData) + { + var objectGroup = newSet.tileData[stringID].objectgroup; + if (objectGroup && objectGroup.objects) + { + var parsedObjects1 = objectGroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + newSet.tileData[stringID].objectgroup.objects = parsedObjects1; + } + } + } + } + + // For a normal sliced tileset the row/count/size information is computed when updated. + // This is done (again) after the image is set. + newSet.updateTileData(set.imagewidth, set.imageheight); + + tilesets.push(newSet); + } + else + { + var newCollection = new ImageCollection(set.name, set.firstgid, set.tilewidth, + set.tileheight, set.margin, set.spacing, set.properties); + + for (stringID in set.tiles) + { + var image = set.tiles[stringID].image; + var gid = set.firstgid + parseInt(stringID, 10); + newCollection.addImage(gid, image); + } + + imageCollections.push(newCollection); + } + + // We've got a new Tileset, so set the lastgid into the previous one + if (lastSet) + { + lastSet.lastgid = set.firstgid - 1; + } + + lastSet = set; + } + + return { tilesets: tilesets, imageCollections: imageCollections }; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 457 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseImageLayers = function (json) +{ + var images = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'imagelayer') + { + continue; + } + + var curi = json.layers[i]; + + images.push({ + name: curi.name, + image: curi.image, + x: GetFastValue(curi, 'offsetx', 0) + curi.x, + y: GetFastValue(curi, 'offsety', 0) + curi.y, + alpha: curi.opacity, + visible: curi.visible, + properties: GetFastValue(curi, 'properties', {}) + }); + } + + return images; +}; + +module.exports = ParseImageLayers; + + +/***/ }), +/* 458 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Decode base-64 encoded data, for example as exported by Tiled. + * + * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode + * @since 3.0.0 + * + * @param {object} data - Base-64 encoded data to decode. + * + * @return {array} Array containing the decoded bytes. + */ +var Base64Decode = function (data) +{ + var binaryString = window.atob(data); + var len = binaryString.length; + var bytes = new Array(len / 4); + + // Interpret binaryString as an array of bytes representing little-endian encoded uint32 values. + for (var i = 0; i < len; i += 4) + { + bytes[i / 4] = ( + binaryString.charCodeAt(i) | + binaryString.charCodeAt(i + 1) << 8 | + binaryString.charCodeAt(i + 2) << 16 | + binaryString.charCodeAt(i + 3) << 24 + ) >>> 0; + } + + return bytes; +}; + +module.exports = Base64Decode; + + +/***/ }), +/* 459 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Base64Decode = __webpack_require__(458); +var GetFastValue = __webpack_require__(2); +var LayerData = __webpack_require__(78); +var ParseGID = __webpack_require__(214); +var Tile = __webpack_require__(55); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'tilelayer') + { + continue; + } + + var curl = json.layers[i]; + + // Base64 decode data if necessary. NOTE: uncompressed base64 only. + if (curl.compression) + { + console.warn( + 'TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' + + curl.name + '\'' + ); + continue; + } + else if (curl.encoding && curl.encoding === 'base64') + { + curl.data = Base64Decode(curl.data); + delete curl.encoding; // Allow the same map to be parsed multiple times + } + + var layerData = new LayerData({ + name: curl.name, + x: GetFastValue(curl, 'offsetx', 0) + curl.x, + y: GetFastValue(curl, 'offsety', 0) + curl.y, + width: curl.width, + height: curl.height, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + alpha: curl.opacity, + visible: curl.visible, + properties: GetFastValue(curl, 'properties', {}) + }); + + var x = 0; + var row = []; + var output = []; + + // Loop through the data field in the JSON. + + // This is an array containing the tile indexes, one after the other. -1 = no tile, + // everything else = the tile index (starting at 1 for Tiled, 0 for CSV) If the map + // contains multiple tilesets then the indexes are relative to that which the set starts + // from. Need to set which tileset in the cache = which tileset in the JSON, if you do this + // manually it means you can use the same map data but a new tileset. + + for (var t = 0, len = curl.data.length; t < len; t++) + { + var gidInfo = ParseGID(curl.data[t]); + + // index, x, y, width, height + if (gidInfo.gid > 0) + { + var tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, + json.tileheight); + + // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal + // propeties into flipX, flipY and rotation + tile.rotation = gidInfo.rotation; + tile.flipX = gidInfo.flipped; + + row.push(tile); + } + else + { + var blankTile = insertNull + ? null + : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); + row.push(blankTile); + } + + x++; + + if (x === curl.width) + { + output.push(row); + x = 0; + row = []; + } + } + + layerData.data = output; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 460 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Parsers + */ + +module.exports = { + + Parse: __webpack_require__(217), + Parse2DArray: __webpack_require__(133), + ParseCSV: __webpack_require__(216), + + Impact: __webpack_require__(210), + Tiled: __webpack_require__(215) + +}; + + +/***/ }), +/* 461 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); +var Vector2 = __webpack_require__(3); + +/** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.WorldToTileXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in tile units. + */ +var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = WorldToTileX(worldX, snapToFloor, camera, layer); + point.y = WorldToTileY(worldY, snapToFloor, camera, layer); + + return point; +}; + +module.exports = WorldToTileXY; + + +/***/ }), +/* 462 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.WeightedRandomize + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) +{ + if (weightedIndexes === undefined) { return; } + + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var weightTotal = 0; + for (i = 0; i < weightedIndexes.length; i++) + { + weightTotal += weightedIndexes[i].weight; + } + + if (weightTotal <= 0) { return; } + + for (i = 0; i < tiles.length; i++) + { + var rand = Math.random() * weightTotal; + var sum = 0; + var randomIndex = -1; + for (var j = 0; j < weightedIndexes.length; j++) + { + sum += weightedIndexes[j].weight; + if (rand <= sum) + { + var chosen = weightedIndexes[j].index; + randomIndex = Array.isArray(chosen) + ? chosen[Math.floor(Math.random() * chosen.length)] + : chosen; + break; + } + } + + tiles[i].index = randomIndex; + } +}; + +module.exports = WeightedRandomize; + + +/***/ }), +/* 463 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(101); +var TileToWorldY = __webpack_require__(100); +var Vector2 = __webpack_require__(3); + +/** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.TileToWorldXY + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in world coordinates. + */ +var TileToWorldXY = function (tileX, tileY, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = TileToWorldX(tileX, camera, layer); + point.y = TileToWorldY(tileY, camera, layer); + + return point; +}; + +module.exports = TileToWorldXY; + + +/***/ }), +/* 464 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.SwapByIndex + * @private + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) + { + if (tiles[i]) + { + if (tiles[i].index === indexA) + { + tiles[i].index = indexB; + } + else if (tiles[i].index === indexB) + { + tiles[i].index = indexA; + } + } + } +}; + +module.exports = SwapByIndex; + + +/***/ }), +/* 465 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var ShuffleArray = __webpack_require__(122); + +/** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.Shuffle + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Shuffle = function (tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var indexes = tiles.map(function (tile) { return tile.index; }); + ShuffleArray(indexes); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = indexes[i]; + } +}; + +module.exports = Shuffle; + + +/***/ }), +/* 466 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @function Phaser.Tilemaps.Components.SetTileLocationCallback + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].setCollisionCallback(callback, callbackContext); + } + +}; + +module.exports = SetTileLocationCallback; + + +/***/ }), +/* 467 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @function Phaser.Tilemaps.Components.SetTileIndexCallback + * @private + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileIndexCallback = function (indexes, callback, callbackContext, layer) +{ + if (typeof indexes === 'number') + { + layer.callbacks[indexes] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + else + { + for (var i = 0, len = indexes.length; i < len; i++) + { + layer.callbacks[indexes[i]] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + } +}; + +module.exports = SetTileIndexCallback; + + +/***/ }), +/* 468 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); + +/** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup + * @private + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + var collisionGroup = tile.getCollisionGroup(); + + // It's possible in Tiled to have a collision group without any shapes, e.g. create a + // shape and then delete the shape. + if (collisionGroup && collisionGroup.objects && collisionGroup.objects.length > 0) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionFromCollisionGroup; + + +/***/ }), +/* 469 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); +var HasValue = __webpack_require__(85); + +/** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @function Phaser.Tilemaps.Components.SetCollisionByProperty + * @private + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + for (var property in properties) + { + if (!HasValue(tile.properties, property)) { continue; } + + var values = properties[property]; + if (!Array.isArray(values)) + { + values = [ values ]; + } + + for (var i = 0; i < values.length; i++) + { + if (tile.properties[property] === values[i]) + { + SetTileCollision(tile, collides); + } + } + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionByProperty; + + +/***/ }), +/* 470 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); +var SetLayerCollisionIndex = __webpack_require__(134); + +/** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionByExclusion + * @private + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Note: this only updates layer.collideIndexes for tile indexes found currently in the layer + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile && indexes.indexOf(tile.index) === -1) + { + SetTileCollision(tile, collides); + SetLayerCollisionIndex(tile.index, collides, layer); + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionByExclusion; + + +/***/ }), +/* 471 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); +var SetLayerCollisionIndex = __webpack_require__(134); + +/** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionBetween + * @private + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + if (start > stop) { return; } + + // Update the array of colliding indexes + for (var index = start; index <= stop; index++) + { + SetLayerCollisionIndex(index, collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile) + { + if (tile.index >= start && tile.index <= stop) + { + SetTileCollision(tile, collides); + } + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionBetween; + + +/***/ }), +/* 472 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); +var SetLayerCollisionIndex = __webpack_require__(134); + +/** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollision + * @private + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollision = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Update the array of colliding indexes + for (var i = 0; i < indexes.length; i++) + { + SetLayerCollisionIndex(indexes[i], collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (tile && indexes.indexOf(tile.index) !== -1) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollision; + + +/***/ }), +/* 473 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var Color = __webpack_require__(347); + +var defaultTileColor = new Color(105, 210, 231, 150); +var defaultCollidingTileColor = new Color(243, 134, 48, 200); +var defaultFaceColor = new Color(40, 39, 37, 150); + +/** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @function Phaser.Tilemaps.Components.RenderDebug + * @private + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Phaser.Display.Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var RenderDebug = function (graphics, styleConfig, layer) +{ + if (styleConfig === undefined) { styleConfig = {}; } + + // Default colors without needlessly creating Color objects + var tileColor = (styleConfig.tileColor !== undefined) ? styleConfig.tileColor : defaultTileColor; + var collidingTileColor = (styleConfig.collidingTileColor !== undefined) ? styleConfig.collidingTileColor : defaultCollidingTileColor; + var faceColor = (styleConfig.faceColor !== undefined) ? styleConfig.faceColor : defaultFaceColor; + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + + graphics.translate(layer.tilemapLayer.x, layer.tilemapLayer.y); + graphics.scale(layer.tilemapLayer.scaleX, layer.tilemapLayer.scaleY); + + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + var tw = tile.width; + var th = tile.height; + var x = tile.pixelX; + var y = tile.pixelY; + + var color = tile.collides ? collidingTileColor : tileColor; + + if (color !== null) + { + graphics.fillStyle(color.color, color.alpha / 255); + graphics.fillRect(x, y, tw, th); + } + + // Inset the face line to prevent neighboring tile's lines from overlapping + x += 1; + y += 1; + tw -= 2; + th -= 2; + + if (faceColor !== null) + { + graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); + + if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } + if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } + if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } + if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } + } + } +}; + +module.exports = RenderDebug; + + +/***/ }), +/* 474 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RemoveTileAt = __webpack_require__(218); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @function Phaser.Tilemaps.Components.RemoveTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + */ +var RemoveTileAtWorldXY = function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); +}; + +module.exports = RemoveTileAtWorldXY; + + +/***/ }), +/* 475 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var GetRandom = __webpack_require__(162); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.Randomize + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Randomize = function (tileX, tileY, width, height, indexes, layer) +{ + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + // If no indicies are given, then find all the unique indexes within the specified region + if (indexes === undefined) + { + indexes = []; + for (i = 0; i < tiles.length; i++) + { + if (indexes.indexOf(tiles[i].index) === -1) + { + indexes.push(tiles[i].index); + } + } + } + + for (i = 0; i < tiles.length; i++) + { + tiles[i].index = GetRandom(indexes); + } +}; + +module.exports = Randomize; + + +/***/ }), +/* 476 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CalculateFacesWithin = __webpack_require__(34); +var PutTileAt = __webpack_require__(135); + +/** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @function Phaser.Tilemaps.Components.PutTilesAt + * @private + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) +{ + if (!Array.isArray(tilesArray)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + // Force the input array to be a 2D array + if (!Array.isArray(tilesArray[0])) + { + tilesArray = [ tilesArray ]; + } + + var height = tilesArray.length; + var width = tilesArray[0].length; + + for (var ty = 0; ty < height; ty++) + { + for (var tx = 0; tx < width; tx++) + { + var tile = tilesArray[ty][tx]; + PutTileAt(tile, tileX + tx, tileY + ty, false, layer); + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = PutTilesAt; + + + +/***/ }), +/* 477 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PutTileAt = __webpack_require__(135); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @function Phaser.Tilemaps.Components.PutTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + */ +var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return PutTileAt(tile, tileX, tileY, recalculateFaces, layer); +}; + +module.exports = PutTileAtWorldXY; + + +/***/ }), +/* 478 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasTileAt = __webpack_require__(219); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @function Phaser.Tilemaps.Components.HasTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The X coordinate of the world position. + * @param {number} worldY - The Y coordinate of the world position. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ +var HasTileAtWorldXY = function (worldX, worldY, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return HasTileAt(tileX, tileY, layer); +}; + +module.exports = HasTileAtWorldXY; + + +/***/ }), +/* 479 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer) +{ + // Top left corner of the rect, rounded down to include partial tiles + var xStart = WorldToTileX(worldX, true, camera, layer); + var yStart = WorldToTileY(worldY, true, camera, layer); + + // Bottom right corner of the rect, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer)); + + return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer); +}; + +module.exports = GetTilesWithinWorldXY; + + +/***/ }), +/* 480 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Geom = __webpack_require__(274); +var GetTilesWithin = __webpack_require__(17); +var Intersects = __webpack_require__(273); +var NOOP = __webpack_require__(1); +var TileToWorldX = __webpack_require__(101); +var TileToWorldY = __webpack_require__(100); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +var TriangleToRectangle = function (triangle, rect) +{ + return Intersects.RectangleToTriangle(rect, triangle); +}; + +// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer +// coordinates instead of shifting the tiles. + +/** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinShape + * @private + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) +{ + if (shape === undefined) { return []; } + + // intersectTest is a function with parameters: shape, rect + var intersectTest = NOOP; + if (shape instanceof Geom.Circle) { intersectTest = Intersects.CircleToRectangle; } + else if (shape instanceof Geom.Rectangle) { intersectTest = Intersects.RectangleToRectangle; } + else if (shape instanceof Geom.Triangle) { intersectTest = TriangleToRectangle; } + else if (shape instanceof Geom.Line) { intersectTest = Intersects.LineToRectangle; } + + // Top left corner of the shapes's bounding box, rounded down to include partial tiles + var xStart = WorldToTileX(shape.left, true, camera, layer); + var yStart = WorldToTileY(shape.top, true, camera, layer); + + // Bottom right corner of the shapes's bounding box, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(shape.right, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(shape.bottom, false, camera, layer)); + + // Tiles within bounding rectangle of shape. Bounds are forced to be at least 1 x 1 tile in size + // to grab tiles for shapes that don't have a height or width (e.g. a horizontal line). + var width = Math.max(xEnd - xStart, 1); + var height = Math.max(yEnd - yStart, 1); + var tiles = GetTilesWithin(xStart, yStart, width, height, filteringOptions, layer); + + var tileWidth = layer.tileWidth; + var tileHeight = layer.tileHeight; + if (layer.tilemapLayer) + { + tileWidth *= layer.tilemapLayer.scaleX; + tileHeight *= layer.tilemapLayer.scaleY; + } + + var results = []; + var tileRect = new Geom.Rectangle(0, 0, tileWidth, tileHeight); + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + tileRect.x = TileToWorldX(tile.x, camera, layer); + tileRect.y = TileToWorldY(tile.y, camera, layer); + if (intersectTest(shape, tileRect)) + { + results.push(tile); + } + } + + return results; +}; + +module.exports = GetTilesWithinShape; + + +/***/ }), +/* 481 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(102); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Gets a tile at the given world coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return GetTileAt(tileX, tileY, nonNull, layer); +}; + +module.exports = GetTileAtWorldXY; + + +/***/ }), +/* 482 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * @callback EachTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - The Tile. + * @param {integer} index - The index of the tile. + * @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects. + */ + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @function Phaser.Tilemaps.Components.ForEachTile + * @private + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + + tiles.forEach(callback, context); +}; + +module.exports = ForEachTile; + + +/***/ }), +/* 483 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * @callback FindTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - The Tile. + * @param {integer} index - The index of the tile. + * @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects. + * + * @return {boolean} Return `true` if the callback should run, otherwise `false`. + */ + +/** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FindTile + * @private + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found + */ +var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + return tiles.find(callback, context) || null; +}; + +module.exports = FindTile; + + +/***/ }), +/* 484 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @function Phaser.Tilemaps.Components.FindByIndex + * @private + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} The first (or n skipped) tile with the matching index. + */ +var FindByIndex = function (findIndex, skip, reverse, layer) +{ + if (skip === undefined) { skip = 0; } + if (reverse === undefined) { reverse = false; } + + var count = 0; + var tx; + var ty; + var tile; + + if (reverse) + { + for (ty = layer.height - 1; ty >= 0; ty--) + { + for (tx = layer.width - 1; tx >= 0; tx--) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + else + { + for (ty = 0; ty < layer.height; ty++) + { + for (tx = 0; tx < layer.width; tx++) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + + return null; +}; + +module.exports = FindByIndex; + + +/***/ }), +/* 485 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FilterTiles + * @private + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. + */ +var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + + return tiles.filter(callback, context); +}; + +module.exports = FilterTiles; + + + +/***/ }), +/* 486 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var CalculateFacesWithin = __webpack_require__(34); +var SetTileCollision = __webpack_require__(56); + +/** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @function Phaser.Tilemaps.Components.Fill + * @private + * @since 3.0.0 + * + * @param {integer} index - The tile index to fill the area with. + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} recalculateFaces - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The tile layer to use. If not given the current layer is used. + */ +var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) +{ + var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); + + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = index; + + SetTileCollision(tiles[i], doesIndexCollide); + } + + if (recalculateFaces) + { + // Recalculate the faces within the area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Fill; + + +/***/ }), +/* 487 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SnapFloor = __webpack_require__(142); +var SnapCeil = __webpack_require__(243); + +/** + * Returns the tiles in the given layer that are within the camera's viewport. This is used internally. + * + * @function Phaser.Tilemaps.Components.CullTiles + * @private + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * @param {array} [outputArray] - An optional array to store the Tile objects within. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ +var CullTiles = function (layer, camera, outputArray, renderOrder) +{ + if (outputArray === undefined) { outputArray = []; } + if (renderOrder === undefined) { renderOrder = 0; } + + outputArray.length = 0; + + var tilemap = layer.tilemapLayer.tilemap; + var tilemapLayer = layer.tilemapLayer; + + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + + // We need to use the tile sizes defined for the map as a whole, not the layer, + // in order to calculate the bounds correctly. As different sized tiles may be + // placed on the grid and we cannot trust layer.baseTileWidth to give us the true size. + var tileW = Math.floor(tilemap.tileWidth * tilemapLayer.scaleX); + var tileH = Math.floor(tilemap.tileHeight * tilemapLayer.scaleY); + + var drawLeft = 0; + var drawRight = mapWidth; + var drawTop = 0; + var drawBottom = mapHeight; + + if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1) + { + // Camera world view bounds, snapped for scaled tile size + // Cull Padding values are given in tiles, not pixels + + var boundsLeft = SnapFloor(camera.worldView.x - tilemapLayer.x, tileW, 0, true) - tilemapLayer.cullPaddingX; + var boundsRight = SnapCeil(camera.worldView.right - tilemapLayer.x, tileW, 0, true) + tilemapLayer.cullPaddingX; + var boundsTop = SnapFloor(camera.worldView.y - tilemapLayer.y, tileH, 0, true) - tilemapLayer.cullPaddingY; + var boundsBottom = SnapCeil(camera.worldView.bottom - tilemapLayer.y, tileH, 0, true) + tilemapLayer.cullPaddingY; + + drawLeft = Math.max(0, boundsLeft); + drawRight = Math.min(mapWidth, boundsRight); + drawTop = Math.max(0, boundsTop); + drawBottom = Math.min(mapHeight, boundsBottom); + } + + var x; + var y; + var tile; + + if (renderOrder === 0) + { + // right-down + + for (y = drawTop; y < drawBottom; y++) + { + for (x = drawLeft; x < drawRight; x++) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 1) + { + // left-down + + for (y = drawTop; y < drawBottom; y++) + { + for (x = drawRight; x >= drawLeft; x--) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 2) + { + // right-up + + for (y = drawBottom; y >= drawTop; y--) + { + for (x = drawLeft; x < drawRight; x++) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 3) + { + // left-up + + for (y = drawBottom; y >= drawTop; y--) + { + for (x = drawRight; x >= drawLeft; x--) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + + tilemapLayer.tilesDrawn = outputArray.length; + tilemapLayer.tilesTotal = mapWidth * mapHeight; + + return outputArray; +}; + +module.exports = CullTiles; + + +/***/ }), +/* 488 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(101); +var TileToWorldY = __webpack_require__(100); +var GetTilesWithin = __webpack_require__(17); +var ReplaceByIndex = __webpack_require__(220); + +/** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @function Phaser.Tilemaps.Components.CreateFromTiles + * @private + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ +var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, camera, layer) +{ + if (spriteConfig === undefined) { spriteConfig = {}; } + + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + var tilemapLayer = layer.tilemapLayer; + if (scene === undefined) { scene = tilemapLayer.scene; } + if (camera === undefined) { camera = scene.cameras.main; } + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + var sprites = []; + var i; + + for (i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + if (indexes.indexOf(tile.index) !== -1) + { + spriteConfig.x = TileToWorldX(tile.x, camera, layer); + spriteConfig.y = TileToWorldY(tile.y, camera, layer); + + var sprite = scene.make.sprite(spriteConfig); + sprites.push(sprite); + } + } + + if (typeof replacements === 'number') + { + // Assume 1 replacement for all types of tile given + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); + } + } + else if (Array.isArray(replacements)) + { + // Assume 1 to 1 mapping with indexes array + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); + } + } + + return sprites; +}; + +module.exports = CreateFromTiles; + + +/***/ }), +/* 489 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var CalculateFacesWithin = __webpack_require__(34); + +/** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @function Phaser.Tilemaps.Components.Copy + * @private + * @since 3.0.0 + * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) +{ + if (srcTileX < 0) { srcTileX = 0; } + if (srcTileY < 0) { srcTileY = 0; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer); + + var offsetX = destTileX - srcTileX; + var offsetY = destTileY - srcTileY; + + for (var i = 0; i < srcTiles.length; i++) + { + var tileX = srcTiles[i].x + offsetX; + var tileY = srcTiles[i].y + offsetY; + if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height) + { + if (layer.data[tileY][tileX]) + { + layer.data[tileY][tileX].copy(srcTiles[i]); + } + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Copy; + + +/***/ }), +/* 490 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps + */ + +module.exports = { + + Components: __webpack_require__(103), + Parsers: __webpack_require__(460), + + Formats: __webpack_require__(29), + ImageCollection: __webpack_require__(213), + ParseToTilemap: __webpack_require__(132), + Tile: __webpack_require__(55), + Tilemap: __webpack_require__(209), + TilemapCreator: __webpack_require__(443), + TilemapFactory: __webpack_require__(442), + Tileset: __webpack_require__(99), + + LayerData: __webpack_require__(78), + MapData: __webpack_require__(77), + ObjectLayer: __webpack_require__(211), + + DynamicTilemapLayer: __webpack_require__(208), + StaticTilemapLayer: __webpack_require__(207) + +}; + + +/***/ }), +/* 491 */ /***/ (function(module, exports) { /** @@ -75215,8 +101821,8 @@ module.exports = ReplaceByIndex; * * @name Phaser.Textures.FilterMode * @enum {integer} - * @memberOf Phaser.Textures - * @readOnly + * @memberof Phaser.Textures + * @readonly * @since 3.0.0 */ var CONST = { @@ -75241,7 +101847,7 @@ module.exports = CONST; /***/ }), -/* 324 */ +/* 492 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -75250,8 +101856,8 @@ module.exports = CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Extend = __webpack_require__(17); -var FilterMode = __webpack_require__(323); +var Extend = __webpack_require__(20); +var FilterMode = __webpack_require__(491); /** * @namespace Phaser.Textures @@ -75274,11 +101880,11 @@ var FilterMode = __webpack_require__(323); var Textures = { FilterMode: FilterMode, - Frame: __webpack_require__(128), - Parsers: __webpack_require__(182), - Texture: __webpack_require__(117), - TextureManager: __webpack_require__(184), - TextureSource: __webpack_require__(183) + Frame: __webpack_require__(113), + Parsers: __webpack_require__(316), + Texture: __webpack_require__(165), + TextureManager: __webpack_require__(318), + TextureSource: __webpack_require__(317) }; @@ -75288,7 +101894,7 @@ module.exports = Textures; /***/ }), -/* 325 */ +/* 493 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -75303,17 +101909,17 @@ module.exports = Textures; module.exports = { - List: __webpack_require__(93), - Map: __webpack_require__(124), - ProcessQueue: __webpack_require__(223), - RTree: __webpack_require__(222), - Set: __webpack_require__(70) + List: __webpack_require__(112), + Map: __webpack_require__(180), + ProcessQueue: __webpack_require__(228), + RTree: __webpack_require__(227), + Set: __webpack_require__(95) }; /***/ }), -/* 326 */ +/* 494 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -75354,25 +101960,25 @@ module.exports = { module.exports = { - SoundManagerCreator: __webpack_require__(191), + SoundManagerCreator: __webpack_require__(325), - BaseSound: __webpack_require__(78), - BaseSoundManager: __webpack_require__(79), + BaseSound: __webpack_require__(114), + BaseSoundManager: __webpack_require__(115), - WebAudioSound: __webpack_require__(185), - WebAudioSoundManager: __webpack_require__(186), + WebAudioSound: __webpack_require__(319), + WebAudioSoundManager: __webpack_require__(320), - HTML5AudioSound: __webpack_require__(189), - HTML5AudioSoundManager: __webpack_require__(190), + HTML5AudioSound: __webpack_require__(323), + HTML5AudioSoundManager: __webpack_require__(324), - NoAudioSound: __webpack_require__(187), - NoAudioSoundManager: __webpack_require__(188) + NoAudioSound: __webpack_require__(321), + NoAudioSoundManager: __webpack_require__(322) }; /***/ }), -/* 327 */ +/* 495 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -75383,16 +101989,15 @@ module.exports = { var Clamp = __webpack_require__(23); var Class = __webpack_require__(0); -var CONST = __webpack_require__(55); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); +var GetFastValue = __webpack_require__(2); +var PluginCache = __webpack_require__(15); /** * @classdesc * A proxy class to the Global Scene Manager. * * @class ScenePlugin - * @memberOf Phaser.Scenes + * @memberof Phaser.Scenes * @constructor * @since 3.0.0 * @@ -75454,7 +102059,7 @@ var ScenePlugin = new Class({ * the current percentage of the transition progress, between 0 and 1. * * @name Phaser.Scenes.ScenePlugin#transitionProgress - * @type {float} + * @type {number} * @since 3.5.0 */ this.transitionProgress = 0; @@ -75568,7 +102173,7 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#start * @since 3.0.0 * - * @param {string} key - The Scene to start. + * @param {string} [key] - The Scene to start. * @param {object} [data] - The Scene data. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. @@ -75577,16 +102182,8 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', this.key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(this.key); - this.manager.start(key, data); - } + this.manager.queueOp('stop', this.key); + this.manager.queueOp('start', key, data); return this; }, @@ -75605,16 +102202,8 @@ var ScenePlugin = new Class({ { var key = this.key; - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(key); - this.manager.start(key, data); - } + this.manager.queueOp('stop', key); + this.manager.queueOp('start', key, data); return this; }, @@ -75651,10 +102240,10 @@ var ScenePlugin = new Class({ * 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. + * as the Scenes `init` and `create` methods are not invoked when a Scene 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. + * These events are cleared of all 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 @@ -75765,8 +102354,8 @@ var ScenePlugin = new Class({ * @private * @since 3.5.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ step: function (time, delta) { @@ -75862,14 +102451,7 @@ var ScenePlugin = new Class({ { if (key && key !== this.key) { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('start', key, data); - } - else - { - this.manager.start(key, data); - } + this.manager.queueOp('start', key, data); } return this; @@ -75888,20 +102470,16 @@ var ScenePlugin = new Class({ * @since 3.10.0 * * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param {object} [data] - A data object that will be passed to the Scene and emitted in its ready, wake, or resume events. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ run: function (key, data) { - if (this.settings.status !== CONST.RUNNING) + if (key && key !== this.key) { this.manager.queueOp('run', key, data); } - else - { - this.manager.run(key, data); - } return this; }, @@ -75912,15 +102490,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#pause * @since 3.0.0 * - * @param {string} key - The Scene to pause. + * @param {string} [key] - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its pause event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - pause: function (key) + pause: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.pause(key); + this.manager.queueOp('pause', key, data); return this; }, @@ -75931,15 +102510,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#resume * @since 3.0.0 * - * @param {string} key - The Scene to resume. + * @param {string} [key] - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its resume event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - resume: function (key) + resume: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.resume(key); + this.manager.queueOp('resume', key, data); return this; }, @@ -75950,15 +102530,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#sleep * @since 3.0.0 * - * @param {string} key - The Scene to put to sleep. + * @param {string} [key] - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its sleep event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - sleep: function (key) + sleep: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.sleep(key); + this.manager.queueOp('sleep', key, data); return this; }, @@ -75969,15 +102550,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#wake * @since 3.0.0 * - * @param {string} key - The Scene to wake up. + * @param {string} [key] - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its wake event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - wake: function (key) + wake: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.wake(key); + this.manager.queueOp('wake', key, data); return this; }, @@ -75996,14 +102578,7 @@ var ScenePlugin = new Class({ { if (key !== this.key) { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('switch', this.key, key); - } - else - { - this.manager.switch(this.key, key); - } + this.manager.queueOp('switch', this.key, key); } return this; @@ -76023,7 +102598,7 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - this.manager.stop(key); + this.manager.queueOp('stop', key); return this; }, @@ -76034,12 +102609,13 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#setActive * @since 3.0.0 * - * @param {boolean} value - The active value. - * @param {string} [key] - The Scene to set the active state for. + * @param {boolean} value - If `true` the Scene will be resumed. If `false` it will be paused. + * @param {string} [key] - The Scene to set the active state of. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted with its events. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - setActive: function (value, key) + setActive: function (value, key, data) { if (key === undefined) { key = this.key; } @@ -76047,7 +102623,7 @@ var ScenePlugin = new Class({ if (scene) { - scene.sys.setActive(value); + scene.sys.setActive(value, data); } return this; @@ -76386,7 +102962,7 @@ module.exports = ScenePlugin; /***/ }), -/* 328 */ +/* 496 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -76395,8 +102971,8 @@ module.exports = ScenePlugin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(55); -var Extend = __webpack_require__(17); +var CONST = __webpack_require__(116); +var Extend = __webpack_require__(20); /** * @namespace Phaser.Scenes @@ -76404,10 +102980,10 @@ var Extend = __webpack_require__(17); var Scene = { - SceneManager: __webpack_require__(194), - ScenePlugin: __webpack_require__(327), - Settings: __webpack_require__(192), - Systems: __webpack_require__(118) + SceneManager: __webpack_require__(329), + ScenePlugin: __webpack_require__(495), + Settings: __webpack_require__(326), + Systems: __webpack_require__(166) }; @@ -76418,7 +102994,7 @@ module.exports = Scene; /***/ }), -/* 329 */ +/* 497 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -76427,7 +103003,7 @@ module.exports = Scene; * @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} */ -var BasePlugin = __webpack_require__(165); +var BasePlugin = __webpack_require__(221); var Class = __webpack_require__(0); /** @@ -76437,7 +103013,7 @@ var Class = __webpack_require__(0); * It can map itself to a Scene property, or into the Scene Systems, or both. * * @class ScenePlugin - * @memberOf Phaser.Plugins + * @memberof Phaser.Plugins * @extends Phaser.Plugins.BasePlugin * @constructor * @since 3.8.0 @@ -76455,26 +103031,7 @@ var ScenePlugin = new Class({ { BasePlugin.call(this, pluginManager); - /** - * A reference to the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * - * @name Phaser.Plugins.ScenePlugin#scene - * @type {?Phaser.Scene} - * @protected - * @since 3.8.0 - */ this.scene = scene; - - /** - * A reference to the Scene Systems of the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * - * @name Phaser.Plugins.ScenePlugin#systems - * @type {?Phaser.Scenes.Systems} - * @protected - * @since 3.8.0 - */ this.systems = scene.sys; scene.sys.events.once('boot', this.boot, this); @@ -76525,7 +103082,7 @@ module.exports = ScenePlugin; /***/ }), -/* 330 */ +/* 498 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -76540,20 +103097,25 @@ module.exports = ScenePlugin; module.exports = { - BasePlugin: __webpack_require__(165), - DefaultPlugins: __webpack_require__(121), - PluginCache: __webpack_require__(12), - PluginManager: __webpack_require__(196), - ScenePlugin: __webpack_require__(329) + BasePlugin: __webpack_require__(221), + DefaultPlugins: __webpack_require__(167), + PluginCache: __webpack_require__(15), + PluginManager: __webpack_require__(331), + ScenePlugin: __webpack_require__(497) }; /***/ }), -/* 331 */, -/* 332 */, -/* 333 */, -/* 334 */ +/* 499 */, +/* 500 */, +/* 501 */, +/* 502 */, +/* 503 */, +/* 504 */, +/* 505 */, +/* 506 */, +/* 507 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -76562,913 +103124,529 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var RectangleContains = __webpack_require__(31); -var Vector2 = __webpack_require__(6); +var GetOverlapY = __webpack_require__(229); /** - * @classdesc * [description] * - * @class StaticBody - * @memberOf Phaser.Physics.Arcade - * @constructor + * @function Phaser.Physics.Arcade.SeparateY * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] */ -var StaticBody = new Class({ +var SeparateY = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapY(body1, body2, overlapOnly, bias); - initialize: - - function StaticBody (world, gameObject) + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateY || body2.customSeparateY) { - var width = (gameObject.width) ? gameObject.width : 64; - var height = (gameObject.height) ? gameObject.height : 64; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = gameObject; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowBody = world.defaults.debugShowStaticBody; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor - * @type {integer} - * @since 3.0.0 - */ - this.debugBodyColor = world.defaults.staticBodyDebugColor; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#enable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#isCircle - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isCircle = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#radius - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.radius = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#offset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.offset = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#width - * @type {number} - * @since 3.0.0 - */ - this.width = width; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#height - * @type {number} - * @since 3.0.0 - */ - this.height = height; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#halfWidth - * @type {number} - * @since 3.0.0 - */ - this.halfWidth = Math.abs(this.width / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#halfHeight - * @type {number} - * @since 3.0.0 - */ - this.halfHeight = Math.abs(this.height / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#center - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#velocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.velocity = Vector2.ZERO; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#allowGravity - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.allowGravity = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = Vector2.ZERO; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#bounce - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.bounce = Vector2.ZERO; - - // If true this Body will dispatch events - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onCollide - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onCollide = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onOverlap - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onOverlap = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#mass - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.mass = 1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#immovable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.immovable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#customSeparateX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateX = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#customSeparateY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateY = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapX = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapY = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapR - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapR = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#embedded - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.embedded = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.collideWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#checkCollision - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#touching - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#wasTouching - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#blocked - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.STATIC_BODY; - - /** - * The calculated change in the Body's horizontal position during the current step. - * For a static body this is always zero. - * - * @name Phaser.Physics.Arcade.StaticBody#_dx - * @type {number} - * @private - * @default 0 - * @since 3.10.0 - */ - this._dx = 0; - - /** - * The calculated change in the Body's vertical position during the current step. - * For a static body this is always zero. - * - * @name Phaser.Physics.Arcade.StaticBody#_dy - * @type {number} - * @private - * @default 0 - * @since 3.10.0 - */ - this._dy = 0; - }, - - /** - * Changes the Game Object this Body is bound to. - * First it removes its reference from the old Game Object, then sets the new one. - * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. - * - * @method Phaser.Physics.Arcade.StaticBody#setGameObject - * @since 3.1.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The new Game Object that will own this Body. - * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setGameObject: function (gameObject, update) - { - if (gameObject && gameObject !== this.gameObject) - { - // Remove this body from the old game object - this.gameObject.body = null; - - gameObject.body = this; - - // Update our reference - this.gameObject = gameObject; - } - - if (update) - { - this.updateFromGameObject(); - } - - return this; - }, - - /** - * Updates this Static Body so that its position and dimensions are updated - * based on the current Game Object it is bound to. - * - * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject - * @since 3.1.0 - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - updateFromGameObject: function () - { - this.world.staticTree.remove(this); - - var gameObject = this.gameObject; - - gameObject.getTopLeft(this.position); - - this.width = gameObject.displayWidth; - this.height = gameObject.displayHeight; - - this.halfWidth = Math.abs(this.width / 2); - this.halfHeight = Math.abs(this.height / 2); - - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setOffset - * @since 3.4.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setOffset: function (x, y) - { - if (y === undefined) { y = x; } - - this.world.staticTree.remove(this); - - this.position.x -= this.offset.x; - this.position.y -= this.offset.y; - - this.offset.set(x, y); - - this.position.x += this.offset.x; - this.position.y += this.offset.y; - - this.updateCenter(); - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setSize: function (width, height, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - this.world.staticTree.remove(this); - - this.width = width; - this.height = height; - - this.halfWidth = Math.floor(width / 2); - this.halfHeight = Math.floor(height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - - this.isCircle = false; - this.radius = 0; - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setCircle - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setCircle: function (radius, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - if (radius > 0) - { - this.world.staticTree.remove(this); - - this.isCircle = true; - - this.radius = radius; - - this.width = radius * 2; - this.height = radius * 2; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - - this.world.staticTree.insert(this); - } - else - { - this.isCircle = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#updateCenter - * @since 3.0.0 - */ - updateCenter: function () - { - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#reset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - */ - reset: function (x, y) - { - var gameObject = this.gameObject; - - if (x === undefined) { x = gameObject.x; } - if (y === undefined) { y = gameObject.y; } - - this.world.staticTree.remove(this); - - gameObject.getTopLeft(this.position); - - this.updateCenter(); - - this.world.staticTree.insert(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#stop - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - stop: function () - { - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#getBounds - * @since 3.0.0 - * - * @param {ArcadeBodyBounds} obj - [description] - * - * @return {ArcadeBodyBounds} [description] - */ - getBounds: function (obj) - { - obj.x = this.x; - obj.y = this.y; - obj.right = this.right; - obj.bottom = this.bottom; - - return obj; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#hitTest - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - hitTest: function (x, y) - { - return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsX: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsY: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaX: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaY: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaZ - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaZ: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enable = false; - - this.world.pendingDestroy.set(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#drawDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphic - [description] - */ - drawDebug: function (graphic) - { - var pos = this.position; - - if (this.debugShowBody) - { - graphic.lineStyle(1, this.debugBodyColor, 1); - graphic.strokeRect(pos.x, pos.y, this.width, this.height); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug - * @since 3.0.0 - * - * @return {boolean} [description] - */ - willDrawDebug: function () - { - return this.debugShowBody; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setMass - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setMass: function (value) - { - if (value <= 0) - { - // Causes havoc otherwise - value = 0.1; - } - - this.mass = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.world.staticTree.remove(this); - - this.position.x = value; - - this.world.staticTree.insert(this); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.world.staticTree.remove(this); - - this.position.y = value; - - this.world.staticTree.insert(this); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#left - * @type {number} - * @readOnly - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.position.x; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#right - * @type {number} - * @readOnly - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.position.x + this.width; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#top - * @type {number} - * @readOnly - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.position.y; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#bottom - * @type {number} - * @readOnly - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.position.y + this.height; - } - + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); } -}); + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.y; + var v2 = body2.velocity.y; -module.exports = StaticBody; + if (!body1.immovable && !body2.immovable) + { + overlap *= 0.5; + + body1.y -= overlap; + body2.y += overlap; + + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; + + nv1 -= avg; + nv2 -= avg; + + body1.velocity.y = avg + nv1 * body1.bounce.y; + body2.velocity.y = avg + nv2 * body2.bounce.y; + } + else if (!body1.immovable) + { + body1.y -= overlap; + body1.velocity.y = v2 - v1 * body1.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body2.moves) + { + body1.x += (body2.x - body2.prev.x) * body2.friction.x; + } + } + else + { + body2.y += overlap; + body2.velocity.y = v1 - v2 * body2.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body1.moves) + { + body2.x += (body1.x - body1.prev.x) * body1.friction.x; + } + } + + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; + +module.exports = SeparateY; /***/ }), -/* 335 */ +/* 508 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetOverlapX = __webpack_require__(230); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.SeparateX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ +var SeparateX = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapX(body1, body2, overlapOnly, bias); + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) + { + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); + } + + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.x; + var v2 = body2.velocity.x; + + if (!body1.immovable && !body2.immovable) + { + overlap *= 0.5; + + body1.x -= overlap; + body2.x += overlap; + + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; + + nv1 -= avg; + nv2 -= avg; + + body1.velocity.x = avg + nv1 * body1.bounce.x; + body2.velocity.x = avg + nv2 * body2.bounce.x; + } + else if (!body1.immovable) + { + body1.x -= overlap; + body1.velocity.x = v2 - v1 * body1.bounce.x; + + // This is special case code that handles things like vertically moving platforms you can ride + if (body2.moves) + { + body1.y += (body2.y - body2.prev.y) * body2.friction.y; + } + } + else + { + body2.x += overlap; + body2.velocity.x = v1 - v2 * body2.bounce.x; + + // This is special case code that handles things like vertically moving platforms you can ride + if (body1.moves) + { + body2.y += (body1.y - body1.prev.y) * body1.friction.y; + } + } + + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; + +module.exports = SeparateX; + + +/***/ }), +/* 509 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} y - The y separation amount. + */ +var ProcessTileSeparationY = function (body, y) +{ + if (y < 0) + { + body.blocked.none = false; + body.blocked.up = true; + } + else if (y > 0) + { + body.blocked.none = false; + body.blocked.down = true; + } + + body.position.y -= y; + + if (body.bounce.y === 0) + { + body.velocity.y = 0; + } + else + { + body.velocity.y = -body.velocity.y * body.bounce.y; + } +}; + +module.exports = ProcessTileSeparationY; + + +/***/ }), +/* 510 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationY = __webpack_require__(509); + +/** + * Check the body against the given tile on the Y axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileTop - [description] + * @param {number} tileBottom - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) +{ + var oy = 0; + + if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) + { + // Body is moving UP + if (tile.faceBottom && body.y < tileBottom) + { + oy = body.y - tileBottom; + + if (oy < -tileBias) + { + oy = 0; + } + } + } + else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) + { + // Body is moving DOWN + if (tile.faceTop && body.bottom > tileTop) + { + oy = body.bottom - tileTop; + + if (oy > tileBias) + { + oy = 0; + } + } + } + + if (oy !== 0) + { + if (body.customSeparateY) + { + body.overlapY = oy; + } + else + { + ProcessTileSeparationY(body, oy); + } + } + + return oy; +}; + +module.exports = TileCheckY; + + +/***/ }), +/* 511 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} x - The x separation amount. + */ +var ProcessTileSeparationX = function (body, x) +{ + if (x < 0) + { + body.blocked.none = false; + body.blocked.left = true; + } + else if (x > 0) + { + body.blocked.none = false; + body.blocked.right = true; + } + + body.position.x -= x; + + if (body.bounce.x === 0) + { + body.velocity.x = 0; + } + else + { + body.velocity.x = -body.velocity.x * body.bounce.x; + } +}; + +module.exports = ProcessTileSeparationX; + + +/***/ }), +/* 512 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationX = __webpack_require__(511); + +/** + * Check the body against the given tile on the X axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileLeft - [description] + * @param {number} tileRight - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) +{ + var ox = 0; + + if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) + { + // Body is moving LEFT + if (tile.faceRight && body.x < tileRight) + { + ox = body.x - tileRight; + + if (ox < -tileBias) + { + ox = 0; + } + } + } + else if (body.deltaX() > 0 && !body.blocked.right && tile.collideLeft && body.checkCollision.right) + { + // Body is moving RIGHT + if (tile.faceLeft && body.right > tileLeft) + { + ox = body.right - tileLeft; + + if (ox > tileBias) + { + ox = 0; + } + } + } + + if (ox !== 0) + { + if (body.customSeparateX) + { + body.overlapX = ox; + } + else + { + ProcessTileSeparationX(body, ox); + } + } + + return ox; +}; + +module.exports = TileCheckX; + + +/***/ }), +/* 513 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileCheckX = __webpack_require__(512); +var TileCheckY = __webpack_require__(510); +var TileIntersectsBody = __webpack_require__(226); + +/** + * The core separation function to separate a physics body and a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.SeparateTile + * @since 3.0.0 + * + * @param {number} i - [description] + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. + * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemapLayer to collide against. + * @param {number} tileBias - [description] + * + * @return {boolean} Returns true if the body was separated, otherwise false. + */ +var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) +{ + var tileLeft = tileWorldRect.left; + var tileTop = tileWorldRect.top; + var tileRight = tileWorldRect.right; + var tileBottom = tileWorldRect.bottom; + var faceHorizontal = tile.faceLeft || tile.faceRight; + var faceVertical = tile.faceTop || tile.faceBottom; + + // We don't need to go any further if this tile doesn't actually have any colliding faces. This + // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't + // needed for separation. + if (!faceHorizontal && !faceVertical) + { + return false; + } + + var ox = 0; + var oy = 0; + var minX = 0; + var minY = 1; + + if (body.deltaAbsX() > body.deltaAbsY()) + { + // Moving faster horizontally, check X axis first + minX = -1; + } + else if (body.deltaAbsX() < body.deltaAbsY()) + { + // Moving faster vertically, check Y axis first + minY = -1; + } + + if (body.deltaX() !== 0 && body.deltaY() !== 0 && faceHorizontal && faceVertical) + { + // We only need do this if both axes have colliding faces AND we're moving in both + // directions + minX = Math.min(Math.abs(body.position.x - tileRight), Math.abs(body.right - tileLeft)); + minY = Math.min(Math.abs(body.position.y - tileBottom), Math.abs(body.bottom - tileTop)); + } + + if (minX < minY) + { + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + + // That's horizontal done, check if we still intersects? If not then we can return now + if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + } + } + else + { + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + + // That's vertical done, check if we still intersects? If not then we can return now + if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + } + } + + return (ox !== 0 || oy !== 0); +}; + +module.exports = SeparateTile; + + +/***/ }), +/* 514 */ /***/ (function(module, exports) { /** @@ -77480,419 +103658,37 @@ module.exports = StaticBody; /** * [description] * - * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks * @since 3.0.0 * - * @param {{ left: number, right: number, top: number, bottom: number }} tileWorldRect - [description] - * @param {Phaser.Physics.Arcade.Body} body - [description] + * @param {Phaser.Tilemaps.Tilemap} tile - [description] + * @param {Phaser.GameObjects.Sprite} sprite - [description] * * @return {boolean} [description] */ -var TileIntersectsBody = function (tileWorldRect, body) +var ProcessTileCallbacks = function (tile, sprite) { - // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this - // should support circle bodies when those are less buggy in v3. - - return !( - body.right <= tileWorldRect.left || - body.bottom <= tileWorldRect.top || - body.position.x >= tileWorldRect.right || - body.position.y >= tileWorldRect.bottom - ); -}; - -module.exports = TileIntersectsBody; - - -/***/ }), -/* 336 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(42); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.GetOverlapY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {number} [description] - */ -var GetOverlapY = function (body1, body2, overlapOnly, bias) -{ - var overlap = 0; - var maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + bias; - - if (body1._dy === 0 && body2._dy === 0) + // Tile callbacks take priority over layer level callbacks + if (tile.collisionCallback) { - // They overlap but neither of them are moving - body1.embedded = true; - body2.embedded = true; + return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); } - else if (body1._dy > body2._dy) + else if (tile.layer.callbacks[tile.index]) { - // Body1 is moving down and/or Body2 is moving up - overlap = body1.bottom - body2.y; - - if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.down === false || body2.checkCollision.up === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.down = true; - - body2.touching.none = false; - body2.touching.up = true; - - if (body2.physicsType === CONST.STATIC_BODY) - { - body1.blocked.down = true; - } - - if (body1.physicsType === CONST.STATIC_BODY) - { - body2.blocked.up = true; - } - } - } - else if (body1._dy < body2._dy) - { - // Body1 is moving up and/or Body2 is moving down - overlap = body1.y - body2.bottom; - - if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.up === false || body2.checkCollision.down === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.up = true; - - body2.touching.none = false; - body2.touching.down = true; - - if (body2.physicsType === CONST.STATIC_BODY) - { - body1.blocked.up = true; - } - - if (body1.physicsType === CONST.STATIC_BODY) - { - body2.blocked.down = true; - } - } - } - - // Resets the overlapY to zero if there is no overlap, or to the actual pixel value if there is - body1.overlapY = overlap; - body2.overlapY = overlap; - - return overlap; -}; - -module.exports = GetOverlapY; - - -/***/ }), -/* 337 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(42); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.GetOverlapX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {number} [description] - */ -var GetOverlapX = function (body1, body2, overlapOnly, bias) -{ - var overlap = 0; - var maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + bias; - - if (body1._dx === 0 && body2._dx === 0) - { - // They overlap but neither of them are moving - body1.embedded = true; - body2.embedded = true; - } - else if (body1._dx > body2._dx) - { - // Body1 is moving right and / or Body2 is moving left - overlap = body1.right - body2.x; - - if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.right === false || body2.checkCollision.left === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.right = true; - - body2.touching.none = false; - body2.touching.left = true; - - if (body2.physicsType === CONST.STATIC_BODY) - { - body1.blocked.right = true; - } - - if (body1.physicsType === CONST.STATIC_BODY) - { - body2.blocked.left = true; - } - } - } - else if (body1._dx < body2._dx) - { - // Body1 is moving left and/or Body2 is moving right - overlap = body1.x - body2.width - body2.x; - - if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.left === false || body2.checkCollision.right === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.left = true; - - body2.touching.none = false; - body2.touching.right = true; - - if (body2.physicsType === CONST.STATIC_BODY) - { - body1.blocked.left = true; - } - - if (body1.physicsType === CONST.STATIC_BODY) - { - body2.blocked.right = true; - } - } - } - - // Resets the overlapX to zero if there is no overlap, or to the actual pixel value if there is - body1.overlapX = overlap; - body2.overlapX = overlap; - - return overlap; -}; - -module.exports = GetOverlapX; - - -/***/ }), -/* 338 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Collider - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {boolean} overlapOnly - [description] - * @param {ArcadeColliderType} object1 - The first object to check for collision. - * @param {ArcadeColliderType} object2 - The second object to check for collision. - * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. - * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {any} callbackContext - The scope in which to call the callbacks. - */ -var Collider = new Class({ - - initialize: - - function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#name - * @type {string} - * @since 3.1.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#overlapOnly - * @type {boolean} - * @since 3.0.0 - */ - this.overlapOnly = overlapOnly; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#object1 - * @type {ArcadeColliderType} - * @since 3.0.0 - */ - this.object1 = object1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#object2 - * @type {ArcadeColliderType} - * @since 3.0.0 - */ - this.object2 = object2; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#collideCallback - * @type {ArcadePhysicsCallback} - * @since 3.0.0 - */ - this.collideCallback = collideCallback; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#processCallback - * @type {ArcadePhysicsCallback} - * @since 3.0.0 - */ - this.processCallback = processCallback; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#callbackContext - * @type {object} - * @since 3.0.0 - */ - this.callbackContext = callbackContext; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#setName - * @since 3.1.0 - * - * @param {string} name - [description] - * - * @return {Phaser.Physics.Arcade.Collider} [description] - */ - setName: function (name) - { - this.name = name; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#update - * @since 3.0.0 - */ - update: function () - { - this.world.collideObjects( - this.object1, - this.object2, - this.collideCallback, - this.processCallback, - this.callbackContext, - this.overlapOnly + return !tile.layer.callbacks[tile.index].callback.call( + tile.layer.callbacks[tile.index].callbackContext, sprite, tile ); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.world.removeCollider(this); - - this.active = false; - - this.world = null; - - this.object1 = null; - this.object2 = null; - - this.collideCallback = null; - this.processCallback = null; - this.callbackContext = null; } -}); + return true; +}; -module.exports = Collider; +module.exports = ProcessTileCallbacks; /***/ }), -/* 339 */ -/***/ (function(module, exports, __webpack_require__) { +/* 515 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -77900,2025 +103696,992 @@ module.exports = Collider; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var RadToDeg = __webpack_require__(150); -var Rectangle = __webpack_require__(14); -var RectangleContains = __webpack_require__(31); -var TransformMatrix = __webpack_require__(64); -var Vector2 = __webpack_require__(6); - /** - * @typedef {object} ArcadeBodyBounds + * [description] * - * @property {number} x - The left edge. - * @property {number} y - The upper edge. - * @property {number} right - The right edge. - * @property {number} bottom - The lower edge. - */ - -/** - * @typedef {object} ArcadeBodyCollision - * - * @property {boolean} none - True if the Body is not colliding. - * @property {boolean} up - True if the Body is colliding on its upper edge. - * @property {boolean} down - True if the Body is colliding on its lower edge. - * @property {boolean} left - True if the Body is colliding on its left edge. - * @property {boolean} right - True if the Body is colliding on its right edge. - */ - -/** - * @classdesc - * A Dynamic Arcade Body. - * - * @class Body - * @memberOf Phaser.Physics.Arcade - * @constructor + * @name Phaser.Physics.Arcade.Components.Velocity * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics simulation this Body belongs to. - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object this Body belongs to. */ -var Body = new Class({ - - initialize: - - function Body (world, gameObject) - { - var width = (gameObject.width) ? gameObject.width : 64; - var height = (gameObject.height) ? gameObject.height : 64; - - /** - * The Arcade Physics simulation this Body belongs to. - * - * @name Phaser.Physics.Arcade.Body#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * The Game Object this Body belongs to. - * - * @name Phaser.Physics.Arcade.Body#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = gameObject; - - /** - * Transformations applied to this Body. - * - * @name Phaser.Physics.Arcade.Body#transform - * @type {object} - * @since 3.4.0 - */ - this.transform = { - x: gameObject.x, - y: gameObject.y, - rotation: gameObject.angle, - scaleX: gameObject.scaleX, - scaleY: gameObject.scaleY, - displayOriginX: gameObject.displayOriginX, - displayOriginY: gameObject.displayOriginY - }; - - /** - * Whether the Body's boundary is drawn to the debug display. - * - * @name Phaser.Physics.Arcade.Body#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowBody = world.defaults.debugShowBody; - - /** - * Whether the Body's velocity is drawn to the debug display. - * - * @name Phaser.Physics.Arcade.Body#debugShowVelocity - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowVelocity = world.defaults.debugShowVelocity; - - /** - * The color of this Body on the debug display. - * - * @name Phaser.Physics.Arcade.Body#debugBodyColor - * @type {integer} - * @since 3.0.0 - */ - this.debugBodyColor = world.defaults.bodyDebugColor; - - /** - * Whether this Body is updated by the physics simulation. - * - * @name Phaser.Physics.Arcade.Body#enable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enable = true; - - /** - * Whether this Body's boundary is circular (true) or rectangular (false). - * - * @name Phaser.Physics.Arcade.Body#isCircle - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setCircle - */ - this.isCircle = false; - - /** - * The unscaled radius of this Body's boundary (if circular), as set by setCircle, in source pixels. - * The true radius (if circular) is equal to halfWidth. - * - * @name Phaser.Physics.Arcade.Body#radius - * @type {number} - * @default 0 - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setCircle - */ - this.radius = 0; - - /** - * The offset of this Body's position from its Game Object's position, in source pixels. - * - * @name Phaser.Physics.Arcade.Body#offset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setOffset - */ - this.offset = new Vector2(); - - /** - * The position of this Body within the simulation. - * - * @name Phaser.Physics.Arcade.Body#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(gameObject.x, gameObject.y); - - /** - * The position of this Body during the previous step. - * - * @name Phaser.Physics.Arcade.Body#prev - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.prev = new Vector2(gameObject.x, gameObject.y); - - /** - * Whether this Body's rotation is affected by its angular acceleration and velocity. - * - * @name Phaser.Physics.Arcade.Body#allowRotation - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowRotation = true; - - /** - * This body's rotation, in degrees, based on its angular acceleration and velocity. - * The Body's rotation controls the `angle` of its Game Object. - * It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle. - * - * @name Phaser.Physics.Arcade.Body#rotation - * @type {number} - * @since 3.0.0 - */ - this.rotation = gameObject.angle; - - /** - * The Body's rotation, in degrees, during the previous step. - * - * @name Phaser.Physics.Arcade.Body#preRotation - * @type {number} - * @since 3.0.0 - */ - this.preRotation = gameObject.angle; - - /** - * The width of the Body's boundary. If circular, this is also the Body's diameter. - * - * @name Phaser.Physics.Arcade.Body#width - * @type {number} - * @default 64 - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the Body's boundary. If circular, this is also the Body's diameter. - * - * @name Phaser.Physics.Arcade.Body#height - * @type {number} - * @default 64 - * @since 3.0.0 - */ - this.height = height; - - /** - * The unscaled width of the Body, in source pixels. The default is the width of the Body's Game Object's texture frame. - * - * @name Phaser.Physics.Arcade.Body#sourceWidth - * @type {number} - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setSize - */ - this.sourceWidth = width; - - /** - * The unscaled height of the Body, in source pixels. The default is the height of the Body's Game Object's texture frame. - * - * @name Phaser.Physics.Arcade.Body#sourceHeight - * @type {number} - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setSize - */ - this.sourceHeight = height; - - if (gameObject.frame) - { - this.sourceWidth = gameObject.frame.realWidth; - this.sourceHeight = gameObject.frame.realHeight; - } - - /** - * Half the Body's width. - * - * @name Phaser.Physics.Arcade.Body#halfWidth - * @type {number} - * @since 3.0.0 - */ - this.halfWidth = Math.abs(width / 2); - - /** - * Half the Body's height. - * - * @name Phaser.Physics.Arcade.Body#halfHeight - * @type {number} - * @since 3.0.0 - */ - this.halfHeight = Math.abs(height / 2); - - /** - * The center of the Body's boundary. The midpoint of its `position` (top-left corner) and its bottom-right corner. - * - * @name Phaser.Physics.Arcade.Body#center - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); - - /** - * The Body's change in position, in pixels per second. - * - * @name Phaser.Physics.Arcade.Body#velocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.velocity = new Vector2(); - - /** - * The Body's calculated change in position, in pixels, at the last step. - * - * @name Phaser.Physics.Arcade.Body#newVelocity - * @type {Phaser.Math.Vector2} - * @readOnly - * @since 3.0.0 - */ - this.newVelocity = new Vector2(); - - /** - * The Body's absolute maximum change in position, in pixels per step. - * - * @name Phaser.Physics.Arcade.Body#deltaMax - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.deltaMax = new Vector2(); - - /** - * The Body's change in velocity, in pixels per second squared. - * - * @name Phaser.Physics.Arcade.Body#acceleration - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.acceleration = new Vector2(); - - /** - * Whether this Body's velocity is affected by its drag vector. - * - * @name Phaser.Physics.Arcade.Body#allowDrag - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowDrag = true; - - /** - * Absolute loss of velocity due to movement, in pixels per second squared. - * - * @name Phaser.Physics.Arcade.Body#drag - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.drag = new Vector2(); - - /** - * Whether this Body's position is affected by its gravity vector. - * - * @name Phaser.Physics.Arcade.Body#allowGravity - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowGravity = true; - - /** - * Acceleration due to gravity (specific to this Body), in pixels per second squared. - * Total gravity is the sum of this vector and the simulation's `gravity`. - * - * @name Phaser.Physics.Arcade.Body#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = new Vector2(); - - /** - * Rebound following a collision, relative to 1. - * - * @name Phaser.Physics.Arcade.Body#bounce - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.bounce = new Vector2(); - - /** - * Rebound following a collision with the world boundary, relative to 1. - * If empty, `bounce` is used instead. - * - * @name Phaser.Physics.Arcade.Body#worldBounce - * @type {?Phaser.Math.Vector2} - * @default null - * @since 3.0.0 - */ - this.worldBounce = null; - - // If true this Body will dispatch events - - /** - * Whether the simulation emits a `worldbounds` event when this Body collides with the world boundary (and `collideWorldBounds` is also true). - * - * @name Phaser.Physics.Arcade.Body#onWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#event:worldbounds - */ - this.onWorldBounds = false; - - /** - * Whether the simulation emits a `collide` event when this Body collides with another. - * - * @name Phaser.Physics.Arcade.Body#onCollide - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#event:collide - */ - this.onCollide = false; - - /** - * Whether the simulation emits an `overlap` event when this Body overlaps with another. - * - * @name Phaser.Physics.Arcade.Body#onOverlap - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#event:overlap - */ - this.onOverlap = false; - - /** - * The Body's absolute maximum velocity. - * - * This limits the Body's rate of movement but not its `velocity` values (which can still exceed `maxVelocity`). - * - * @name Phaser.Physics.Arcade.Body#maxVelocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.maxVelocity = new Vector2(10000, 10000); - - /** - * If this Body is `immovable` and in motion, this the proportion of this Body's movement received by the riding body on each axis, relative to 1. - * The default value (1, 0) moves the riding body horizontally in equal proportion and vertically not at all. - * - * @name Phaser.Physics.Arcade.Body#friction - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.friction = new Vector2(1, 0); - - /** - * If this Body is using `drag` for deceleration this property controls how the drag is applied. - * If set to `true` drag will use a damping effect rather than a linear approach. If you are - * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in - * the game Asteroids) then you will get a far smoother and more visually correct deceleration - * by using damping, avoiding the axis-drift that is prone with linear deceleration. - * - * If you enable this property then you should use far smaller `drag` values than with linear, as - * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow - * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. - * - * @name Phaser.Physics.Arcade.Body#useDamping - * @type {boolean} - * @default false - * @since 3.10.0 - */ - this.useDamping = false; - - /** - * The rate of change of this Body's rotation, in degrees per second. - * - * @name Phaser.Physics.Arcade.Body#angularVelocity - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularVelocity = 0; - - /** - * The rate of change of this Body's angular velocity, in degrees per second squared. - * - * @name Phaser.Physics.Arcade.Body#angularAcceleration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularAcceleration = 0; - - /** - * Loss of angular velocity due to angular movement, in degrees per second. - * - * @name Phaser.Physics.Arcade.Body#angularDrag - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularDrag = 0; - - /** - * The Body's maximum angular velocity, in degrees per second. - * - * @name Phaser.Physics.Arcade.Body#maxAngular - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.maxAngular = 1000; - - /** - * The Body's inertia, relative to a default unit (1). - * With `bounce`, this affects the exchange of momentum (velocities) during collisions. - * - * @name Phaser.Physics.Arcade.Body#mass - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.mass = 1; - - /** - * The angle of this Body's velocity vector, in degrees. - * - * @name Phaser.Physics.Arcade.Body#angle - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angle = 0; - - /** - * The magnitude of the Body's velocity, as calculated during the last update. - * - * @name Phaser.Physics.Arcade.Body#speed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.speed = 0; - - /** - * The calculated direction of the Body's velocity. - * - * @name Phaser.Physics.Arcade.Body#facing - * @type {integer} - * @since 3.0.0 - */ - this.facing = CONST.FACING_NONE; - - /** - * Whether this object can be moved by collisions with another body. - * - * @name Phaser.Physics.Arcade.Body#immovable - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.immovable = false; - - /** - * Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity. - * - * @name Phaser.Physics.Arcade.Body#moves - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.moves = true; - - /** - * A flag disabling the default horizontal separation of colliding bodies. Pass your own `processHandler` to the collider. - * - * @name Phaser.Physics.Arcade.Body#customSeparateX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateX = false; - - /** - * A flag disabling the default vertical separation of colliding bodies. Pass your own `processHandler` to the collider. - * - * @name Phaser.Physics.Arcade.Body#customSeparateY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateY = false; - - /** - * The amount of horizontal overlap (before separation), if this Body is colliding with another. - * - * @name Phaser.Physics.Arcade.Body#overlapX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapX = 0; - - /** - * The amount of vertical overlap (before separation), if this Body is colliding with another. - * - * @name Phaser.Physics.Arcade.Body#overlapY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapY = 0; - - /** - * The amount of overlap (before separation), if this Body is circular and colliding with another circular body. - * - * @name Phaser.Physics.Arcade.Body#overlapR - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapR = 0; - - /** - * Whether this Body is overlapped with another and both have zero velocity. - * - * @name Phaser.Physics.Arcade.Body#embedded - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.embedded = false; - - /** - * Whether this Body interacts with the world boundary. - * - * @name Phaser.Physics.Arcade.Body#collideWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.collideWorldBounds = false; - - /** - * Whether this Body is checked for collisions and for which directions. - * You can set `checkCollision.none = false` to disable collision checks. - * - * @name Phaser.Physics.Arcade.Body#checkCollision - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; - - /** - * Whether this Body is colliding with another and in which direction. - * - * @name Phaser.Physics.Arcade.Body#touching - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * Whether this Body was colliding with another during the last step, and in which direction. - * - * @name Phaser.Physics.Arcade.Body#wasTouching - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * Whether this Body is colliding with a tile or the world boundary. - * - * @name Phaser.Physics.Arcade.Body#blocked - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; - - /** - * Whether to automatically synchronize this Body's dimensions to the dimensions of its Game Object's visual bounds. - * - * @name Phaser.Physics.Arcade.Body#syncBounds - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.GameObjects.Components.GetBounds#getBounds - */ - this.syncBounds = false; - - /** - * Whether this Body is being moved by the `moveTo` or `moveFrom` methods. - * - * @name Phaser.Physics.Arcade.Body#isMoving - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isMoving = false; - - /** - * Whether this Body's movement by `moveTo` or `moveFrom` will be stopped by collisions with other bodies. - * - * @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.stopVelocityOnCollide = true; - - // read-only - - /** - * The Body's physics type (dynamic or static). - * - * @name Phaser.Physics.Arcade.Body#physicsType - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.physicsType = CONST.DYNAMIC_BODY; - - /** - * Whether the Body's position needs updating from its Game Object. - * - * @name Phaser.Physics.Arcade.Body#_reset - * @type {boolean} - * @private - * @default true - * @since 3.0.0 - */ - this._reset = true; - - /** - * Cached horizontal scale of the Body's Game Object. - * - * @name Phaser.Physics.Arcade.Body#_sx - * @type {number} - * @private - * @since 3.0.0 - */ - this._sx = gameObject.scaleX; - - /** - * Cached vertical scale of the Body's Game Object. - * - * @name Phaser.Physics.Arcade.Body#_sy - * @type {number} - * @private - * @since 3.0.0 - */ - this._sy = gameObject.scaleY; - - /** - * The calculated change in the Body's horizontal position during the current step. - * - * @name Phaser.Physics.Arcade.Body#_dx - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._dx = 0; - - /** - * The calculated change in the Body's vertical position during the current step. - * - * @name Phaser.Physics.Arcade.Body#_dy - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._dy = 0; - - /** - * Stores the Game Object's bounds. - * - * @name Phaser.Physics.Arcade.Body#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); - - this._tempMatrix = new TransformMatrix(); - }, +var Velocity = { /** - * Updates this Body's transform, dimensions, and position from its Game Object. + * [description] * - * @method Phaser.Physics.Arcade.Body#updateBounds - * @since 3.0.0 - */ - updateBounds: function () - { - var sprite = this.gameObject; - - // Container? - - var transform = this.transform; - - if (sprite.parentContainer) - { - var matrix = sprite.getWorldTransformMatrix(this._tempMatrix); - - transform.x = matrix.tx; - transform.y = matrix.ty; - transform.rotation = RadToDeg(matrix.rotation); - transform.scaleX = matrix.scaleX; - transform.scaleY = matrix.scaleY; - } - else - { - transform.x = sprite.x; - transform.y = sprite.y; - transform.rotation = sprite.angle; - transform.scaleX = sprite.scaleX; - transform.scaleY = sprite.scaleY; - } - - var recalc = false; - - if (this.syncBounds) - { - var b = sprite.getBounds(this._bounds); - - this.width = b.width; - this.height = b.height; - recalc = true; - } - else - { - var asx = Math.abs(transform.scaleX); - var asy = Math.abs(transform.scaleY); - - if (this._sx !== asx || this._sy !== asy) - { - this.width = this.sourceWidth * asx; - this.height = this.sourceHeight * asy; - this._sx = asx; - this._sy = asy; - recalc = true; - } - } - - if (recalc) - { - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - this.updateCenter(); - } - }, - - /** - * Updates the Body's `center` from its `position` and dimensions. - * - * @method Phaser.Physics.Arcade.Body#updateCenter - * @since 3.0.0 - */ - updateCenter: function () - { - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - }, - - /** - * Updates the Body. - * - * @method Phaser.Physics.Arcade.Body#update - * @fires Phaser.Physics.Arcade.World#worldbounds + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity * @since 3.0.0 * - * @param {number} delta - The delta time, in ms, elapsed since the last frame. - */ - update: function (delta) - { - // Store and reset collision flags - this.wasTouching.none = this.touching.none; - this.wasTouching.up = this.touching.up; - this.wasTouching.down = this.touching.down; - this.wasTouching.left = this.touching.left; - this.wasTouching.right = this.touching.right; - - this.touching.none = true; - this.touching.up = false; - this.touching.down = false; - this.touching.left = false; - this.touching.right = false; - - this.blocked.none = true; - this.blocked.up = false; - this.blocked.down = false; - this.blocked.left = false; - this.blocked.right = false; - - this.overlapR = 0; - this.overlapX = 0; - this.overlapY = 0; - - this.embedded = false; - - // Updates the transform values - this.updateBounds(); - - var sprite = this.transform; - - this.position.x = sprite.x + sprite.scaleX * (this.offset.x - sprite.displayOriginX); - this.position.y = sprite.y + sprite.scaleY * (this.offset.y - sprite.displayOriginY); - - this.updateCenter(); - - this.rotation = sprite.rotation; - - this.preRotation = this.rotation; - - if (this._reset) - { - this.prev.x = this.position.x; - this.prev.y = this.position.y; - } - - if (this.moves) - { - this.world.updateMotion(this, delta); - - var vx = this.velocity.x; - var vy = this.velocity.y; - - this.newVelocity.set(vx * delta, vy * delta); - - this.position.add(this.newVelocity); - - this.updateCenter(); - - this.angle = Math.atan2(vy, vx); - this.speed = Math.sqrt(vx * vx + vy * vy); - - // Now the State update will throw collision checks at the Body - // And finally we'll integrate the new position back to the Sprite in postUpdate - - if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) - { - this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); - } - } - - this._dx = this.deltaX(); - this._dy = this.deltaY(); - }, - - /** - * Feeds the Body results back into the parent Game Object. + * @param {number} x - [description] + * @param {number} [y=x] - [description] * - * @method Phaser.Physics.Arcade.Body#postUpdate - * @since 3.0.0 - * - * @param {boolean} resetDelta - Reset the delta properties? - */ - postUpdate: function () - { - this._dx = this.deltaX(); - this._dy = this.deltaY(); - - if (this.moves) - { - if (this.deltaMax.x !== 0 && this._dx !== 0) - { - if (this._dx < 0 && this._dx < -this.deltaMax.x) - { - this._dx = -this.deltaMax.x; - } - else if (this._dx > 0 && this._dx > this.deltaMax.x) - { - this._dx = this.deltaMax.x; - } - } - - if (this.deltaMax.y !== 0 && this._dy !== 0) - { - if (this._dy < 0 && this._dy < -this.deltaMax.y) - { - this._dy = -this.deltaMax.y; - } - else if (this._dy > 0 && this._dy > this.deltaMax.y) - { - this._dy = this.deltaMax.y; - } - } - - this.gameObject.x += this._dx; - this.gameObject.y += this._dy; - - this._reset = true; - } - - if (this._dx < 0) - { - this.facing = CONST.FACING_LEFT; - } - else if (this._dx > 0) - { - this.facing = CONST.FACING_RIGHT; - } - - if (this._dy < 0) - { - this.facing = CONST.FACING_UP; - } - else if (this._dy > 0) - { - this.facing = CONST.FACING_DOWN; - } - - if (this.allowRotation) - { - this.gameObject.angle += this.deltaZ(); - } - - this.prev.x = this.position.x; - this.prev.y = this.position.y; - }, - - /** - * Checks for collisions between this Body and the world boundary and separates them. - * - * @method Phaser.Physics.Arcade.Body#checkWorldBounds - * @since 3.0.0 - * - * @return {boolean} True if this Body is colliding with the world boundary. - */ - checkWorldBounds: function () - { - var pos = this.position; - var bounds = this.world.bounds; - var check = this.world.checkCollision; - - var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x; - var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y; - - if (pos.x < bounds.x && check.left) - { - pos.x = bounds.x; - this.velocity.x *= bx; - this.blocked.left = true; - this.blocked.none = false; - } - else if (this.right > bounds.right && check.right) - { - pos.x = bounds.right - this.width; - this.velocity.x *= bx; - this.blocked.right = true; - this.blocked.none = false; - } - - if (pos.y < bounds.y && check.up) - { - pos.y = bounds.y; - this.velocity.y *= by; - this.blocked.up = true; - this.blocked.none = false; - } - else if (this.bottom > bounds.bottom && check.down) - { - pos.y = bounds.bottom - this.height; - this.velocity.y *= by; - this.blocked.down = true; - this.blocked.none = false; - } - - return !this.blocked.none; - }, - - /** - * Sets the offset of the Body's position from its Game Object's position. - * - * @method Phaser.Physics.Arcade.Body#setOffset - * @since 3.0.0 - * - * @param {number} x - The horizontal offset, in source pixels. - * @param {number} [y=x] - The vertical offset, in source pixels. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setOffset: function (x, y) - { - if (y === undefined) { y = x; } - - this.offset.set(x, y); - - return this; - }, - - /** - * Sizes and positions this Body's boundary, as a rectangle. - * Modifies the Body's `offset` if `center` is true (the default). - * - * @method Phaser.Physics.Arcade.Body#setSize - * @since 3.0.0 - * - * @param {number} width - The width of the Body, in source pixels. - * @param {number} height - The height of the Body, in source pixels. - * @param {boolean} [center=true] - Modify the Body's `offset`, placing the Body's center on its Game Object's center. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setSize: function (width, height, center) - { - if (center === undefined) { center = true; } - - var gameObject = this.gameObject; - - this.sourceWidth = width; - this.sourceHeight = height; - - this.width = this.sourceWidth * this._sx; - this.height = this.sourceHeight * this._sy; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.updateCenter(); - - if (center && gameObject.getCenter) - { - var ox = gameObject.displayWidth / 2; - var oy = gameObject.displayHeight / 2; - - this.offset.set(ox - this.halfWidth, oy - this.halfHeight); - } - - this.isCircle = false; - this.radius = 0; - - return this; - }, - - /** - * Sizes and positions this Body's boundary, as a circle. - * - * @method Phaser.Physics.Arcade.Body#setCircle - * @since 3.0.0 - * - * @param {number} radius - The radius of the Body, in source pixels. - * @param {number} [offsetX] - The horizontal offset of the Body from its Game Object, in source pixels. - * @param {number} [offsetY] - The vertical offset of the Body from its Game Object, in source pixels. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setCircle: function (radius, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - if (radius > 0) - { - this.isCircle = true; - this.radius = radius; - - this.sourceWidth = radius * 2; - this.sourceHeight = radius * 2; - - this.width = this.sourceWidth * this._sx; - this.height = this.sourceHeight * this._sy; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - } - else - { - this.isCircle = false; - } - - return this; - }, - - /** - * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. - * If the Body had any velocity or acceleration it is lost as a result of calling this. - * - * @method Phaser.Physics.Arcade.Body#reset - * @since 3.0.0 - * - * @param {number} x - The horizontal position to place the Game Object and Body. - * @param {number} y - The vertical position to place the Game Object and Body. - */ - reset: function (x, y) - { - this.stop(); - - var gameObject = this.gameObject; - - gameObject.setPosition(x, y); - - gameObject.getTopLeft(this.position); - - this.prev.copy(this.position); - - this.rotation = gameObject.angle; - this.preRotation = gameObject.angle; - - this.updateBounds(); - this.updateCenter(); - }, - - /** - * Sets acceleration, velocity, and speed to zero. - * - * @method Phaser.Physics.Arcade.Body#stop - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - stop: function () - { - this.velocity.set(0); - this.acceleration.set(0); - this.speed = 0; - this.angularVelocity = 0; - this.angularAcceleration = 0; - - return this; - }, - - /** - * Copies the coordinates of this Body's edges into an object. - * - * @method Phaser.Physics.Arcade.Body#getBounds - * @since 3.0.0 - * - * @param {ArcadeBodyBounds} obj - An object to copy the values into. - * - * @return {ArcadeBodyBounds} - An object with {x, y, right, bottom}. - */ - getBounds: function (obj) - { - obj.x = this.x; - obj.y = this.y; - obj.right = this.right; - obj.bottom = this.bottom; - - return obj; - }, - - /** - * Tests if the coordinates are within this Body's boundary. - * - * @method Phaser.Physics.Arcade.Body#hitTest - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate. - * @param {number} y - The vertical coordinate. - * - * @return {boolean} True if (x, y) is within this Body. - */ - hitTest: function (x, y) - { - return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); - }, - - /** - * Whether this Body is touching a tile or the world boundary while moving down. - * - * @method Phaser.Physics.Arcade.Body#onFloor - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#blocked - * - * @return {boolean} True if touching. - */ - onFloor: function () - { - return this.blocked.down; - }, - - /** - * Whether this Body is touching a tile or the world boundary while moving up. - * - * @method Phaser.Physics.Arcade.Body#onCeiling - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#blocked - * - * @return {boolean} True if touching. - */ - onCeiling: function () - { - return this.blocked.up; - }, - - /** - * Whether this Body is touching a tile or the world boundary while moving left or right. - * - * @method Phaser.Physics.Arcade.Body#onWall - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#blocked - * - * @return {boolean} True if touching. - */ - onWall: function () - { - return (this.blocked.left || this.blocked.right); - }, - - /** - * The absolute (non-negative) change in this Body's horizontal position from the previous step. - * - * @method Phaser.Physics.Arcade.Body#deltaAbsX - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaAbsX: function () - { - return (this._dx > 0) ? this._dx : -this._dx; - }, - - /** - * The absolute (non-negative) change in this Body's vertical position from the previous step. - * - * @method Phaser.Physics.Arcade.Body#deltaAbsY - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaAbsY: function () - { - return (this._dy > 0) ? this._dy : -this._dy; - }, - - /** - * The change in this Body's horizontal position from the previous step. - * This value is set during the Body's update phase. - * - * @method Phaser.Physics.Arcade.Body#deltaX - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaX: function () - { - return this.position.x - this.prev.x; - }, - - /** - * The change in this Body's vertical position from the previous step. - * This value is set during the Body's update phase. - * - * @method Phaser.Physics.Arcade.Body#deltaY - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaY: function () - { - return this.position.y - this.prev.y; - }, - - /** - * The change in this Body's rotation from the previous step, in degrees. - * - * @method Phaser.Physics.Arcade.Body#deltaZ - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaZ: function () - { - return this.rotation - this.preRotation; - }, - - /** - * Disables this Body and marks it for deletion by the simulation. - * - * @method Phaser.Physics.Arcade.Body#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enable = false; - - this.world.pendingDestroy.set(this); - }, - - /** - * Draws this Body's boundary and velocity, if enabled. - * - * @method Phaser.Physics.Arcade.Body#drawDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphic - The Graphics object to draw on. - */ - drawDebug: function (graphic) - { - var pos = this.position; - var x = pos.x + this.halfWidth; - var y = pos.y + this.halfHeight; - - if (this.debugShowBody) - { - graphic.lineStyle(1, this.debugBodyColor); - - if (this.isCircle) - { - graphic.strokeCircle(x, y, this.width / 2); - } - else - { - graphic.strokeRect(pos.x, pos.y, this.width, this.height); - } - } - - if (this.debugShowVelocity) - { - graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); - graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); - } - }, - - /** - * Whether this Body will be drawn to the debug display. - * - * @method Phaser.Physics.Arcade.Body#willDrawDebug - * @since 3.0.0 - * - * @return {boolean} True if either `debugShowBody` or `debugShowVelocity` are enabled. - */ - willDrawDebug: function () - { - return (this.debugShowBody || this.debugShowVelocity); - }, - - /** - * Sets whether this Body collides with the world boundary. - * - * @method Phaser.Physics.Arcade.Body#setCollideWorldBounds - * @since 3.0.0 - * - * @param {boolean} [value=true] - True (collisions) or false (no collisions). - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setCollideWorldBounds: function (value) - { - if (value === undefined) { value = true; } - - this.collideWorldBounds = value; - - return this; - }, - - /** - * Sets the Body's velocity. - * - * @method Phaser.Physics.Arcade.Body#setVelocity - * @since 3.0.0 - * - * @param {number} x - The horizontal velocity, in pixels per second. - * @param {number} [y=x] - The vertical velocity, in pixels per second. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ setVelocity: function (x, y) { - this.velocity.set(x, y); + this.body.setVelocity(x, y); return this; }, /** - * Sets the Body's horizontal velocity. + * [description] * - * @method Phaser.Physics.Arcade.Body#setVelocityX + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX * @since 3.0.0 * - * @param {number} value - The velocity, in pixels per second. + * @param {number} x - [description] * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ - setVelocityX: function (value) + setVelocityX: function (x) { - this.velocity.x = value; + this.body.setVelocityX(x); return this; }, /** - * Sets the Body's vertical velocity. + * [description] * - * @method Phaser.Physics.Arcade.Body#setVelocityY + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY * @since 3.0.0 * - * @param {number} value - The velocity, in pixels per second. + * @param {number} y - [description] * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ - setVelocityY: function (value) + setVelocityY: function (y) { - this.velocity.y = value; + this.body.setVelocityY(y); return this; }, /** - * Sets the Body's maximum velocity. + * [description] * - * @method Phaser.Physics.Arcade.Body#setMaxVelocity - * @since 3.10.0 + * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity + * @since 3.0.0 * - * @param {number} x - The horizontal velocity, in pixels per second. - * @param {number} [y=x] - The vertical velocity, in pixels per second. + * @param {number} x - [description] + * @param {number} [y=x] - [description] * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ setMaxVelocity: function (x, y) { - this.maxVelocity.set(x, y); + this.body.maxVelocity.set(x, y); return this; - }, + } + +}; + +module.exports = Velocity; + + +/***/ }), +/* 516 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods for setting the size of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.Physics.Arcade.Components.Size + * @since 3.0.0 + */ +var Size = { /** - * Sets the Body's bounce. + * Sets the body offset. This allows you to adjust the difference between the center of the body + * and the x and y coordinates of the parent Game Object. * - * @method Phaser.Physics.Arcade.Body#setBounce + * @method Phaser.Physics.Arcade.Components.Size#setOffset * @since 3.0.0 * - * @param {number} x - The horizontal bounce, relative to 1. - * @param {number} y - The vertical bounce, relative to 1. + * @param {number} x - The amount to offset the body from the parent Game Object along the x-axis. + * @param {number} [y=x] - The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ - setBounce: function (x, y) + setOffset: function (x, y) { - this.bounce.set(x, y); + this.body.setOffset(x, y); return this; }, /** - * Sets the Body's horizontal bounce. + * Sets the size of this physics body. Setting the size does not adjust the dimensions + * of the parent Game Object. * - * @method Phaser.Physics.Arcade.Body#setBounceX + * @method Phaser.Physics.Arcade.Components.Size#setSize * @since 3.0.0 * - * @param {number} value - The bounce, relative to 1. + * @param {number} width - The new width of the physics body, in pixels. + * @param {number} height - The new height of the physics body, in pixels. + * @param {boolean} [center=true] - Should the body be re-positioned so its center aligns with the parent Game Object? * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ - setBounceX: function (value) + setSize: function (width, height, center) { - this.bounce.x = value; + this.body.setSize(width, height, center); return this; }, /** - * Sets the Body's vertical bounce. + * Sets this physics body to use a circle for collision instead of a rectangle. * - * @method Phaser.Physics.Arcade.Body#setBounceY + * @method Phaser.Physics.Arcade.Components.Size#setCircle * @since 3.0.0 * - * @param {number} value - The bounce, relative to 1. + * @param {number} radius - The radius of the physics body, in pixels. + * @param {number} [offsetX] - The amount to offset the body from the parent Game Object along the x-axis. + * @param {number} [offsetY] - The amount to offset the body from the parent Game Object along the y-axis. * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ - setBounceY: function (value) + setCircle: function (radius, offsetX, offsetY) { - this.bounce.y = value; + this.body.setCircle(radius, offsetX, offsetY); return this; - }, + } + +}; + +module.exports = Size; + + +/***/ }), +/* 517 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Mass + * @since 3.0.0 + */ +var Mass = { /** - * Sets the Body's acceleration. + * [description] * - * @method Phaser.Physics.Arcade.Body#setAcceleration + * @method Phaser.Physics.Arcade.Components.Mass#setMass * @since 3.0.0 * - * @param {number} x - The horizontal component, in pixels per second squared. - * @param {number} y - The vertical component, in pixels per second squared. + * @param {number} value - [description] * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAcceleration: function (x, y) - { - this.acceleration.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal acceleration. - * - * @method Phaser.Physics.Arcade.Body#setAccelerationX - * @since 3.0.0 - * - * @param {number} value - The acceleration, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAccelerationX: function (value) - { - this.acceleration.x = value; - - return this; - }, - - /** - * Sets the Body's vertical acceleration. - * - * @method Phaser.Physics.Arcade.Body#setAccelerationY - * @since 3.0.0 - * - * @param {number} value - The acceleration, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAccelerationY: function (value) - { - this.acceleration.y = value; - - return this; - }, - - /** - * Enables or disables drag. - * - * @method Phaser.Physics.Arcade.Body#setAllowDrag - * @since 3.9.0 - * @see Phaser.Physics.Arcade.Body#allowDrag - * - * @param {boolean} [value=true] - `true` to allow drag on this body, or `false` to disable it. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAllowDrag: function (value) - { - if (value === undefined) { value = true; } - - this.allowDrag = value; - - return this; - }, - - /** - * Enables or disables gravity's effect on this Body. - * - * @method Phaser.Physics.Arcade.Body#setAllowGravity - * @since 3.9.0 - * @see Phaser.Physics.Arcade.Body#allowGravity - * - * @param {boolean} [value=true] - `true` to allow gravity on this body, or `false` to disable it. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAllowGravity: function (value) - { - if (value === undefined) { value = true; } - - this.allowGravity = value; - - return this; - }, - - /** - * Enables or disables rotation. - * - * @method Phaser.Physics.Arcade.Body#setAllowRotation - * @since 3.9.0 - * @see Phaser.Physics.Arcade.Body#allowRotation - * - * @param {boolean} [value=true] - `true` to allow rotation on this body, or `false` to disable it. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAllowRotation: function (value) - { - if (value === undefined) { value = true; } - - this.allowRotation = value; - - return this; - }, - - /** - * Sets the Body's drag. - * - * @method Phaser.Physics.Arcade.Body#setDrag - * @since 3.0.0 - * - * @param {number} x - The horizontal component, in pixels per second squared. - * @param {number} y - The vertical component, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDrag: function (x, y) - { - this.drag.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal drag. - * - * @method Phaser.Physics.Arcade.Body#setDragX - * @since 3.0.0 - * - * @param {number} value - The drag, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDragX: function (value) - { - this.drag.x = value; - - return this; - }, - - /** - * Sets the Body's vertical drag. - * - * @method Phaser.Physics.Arcade.Body#setDragY - * @since 3.0.0 - * - * @param {number} value - The drag, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDragY: function (value) - { - this.drag.y = value; - - return this; - }, - - /** - * Sets the Body's gravity. - * - * @method Phaser.Physics.Arcade.Body#setGravity - * @since 3.0.0 - * - * @param {number} x - The horizontal component, in pixels per second squared. - * @param {number} y - The vertical component, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravity: function (x, y) - { - this.gravity.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal gravity. - * - * @method Phaser.Physics.Arcade.Body#setGravityX - * @since 3.0.0 - * - * @param {number} value - The gravity, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravityX: function (value) - { - this.gravity.x = value; - - return this; - }, - - /** - * Sets the Body's vertical gravity. - * - * @method Phaser.Physics.Arcade.Body#setGravityY - * @since 3.0.0 - * - * @param {number} value - The gravity, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravityY: function (value) - { - this.gravity.y = value; - - return this; - }, - - /** - * Sets the Body's friction. - * - * @method Phaser.Physics.Arcade.Body#setFriction - * @since 3.0.0 - * - * @param {number} x - The horizontal component, relative to 1. - * @param {number} y - The vertical component, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFriction: function (x, y) - { - this.friction.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal friction. - * - * @method Phaser.Physics.Arcade.Body#setFrictionX - * @since 3.0.0 - * - * @param {number} value - The friction value, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFrictionX: function (value) - { - this.friction.x = value; - - return this; - }, - - /** - * Sets the Body's vertical friction. - * - * @method Phaser.Physics.Arcade.Body#setFrictionY - * @since 3.0.0 - * - * @param {number} value - The friction value, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFrictionY: function (value) - { - this.friction.y = value; - - return this; - }, - - /** - * Sets the Body's angular velocity. - * - * @method Phaser.Physics.Arcade.Body#setAngularVelocity - * @since 3.0.0 - * - * @param {number} value - The velocity, in degrees per second. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularVelocity: function (value) - { - this.angularVelocity = value; - - return this; - }, - - /** - * Sets the Body's angular acceleration. - * - * @method Phaser.Physics.Arcade.Body#setAngularAcceleration - * @since 3.0.0 - * - * @param {number} value - The acceleration, in degrees per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularAcceleration: function (value) - { - this.angularAcceleration = value; - - return this; - }, - - /** - * Sets the Body's angular drag. - * - * @method Phaser.Physics.Arcade.Body#setAngularDrag - * @since 3.0.0 - * - * @param {number} value - The drag, in degrees per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularDrag: function (value) - { - this.angularDrag = value; - - return this; - }, - - /** - * Sets the Body's mass. - * - * @method Phaser.Physics.Arcade.Body#setMass - * @since 3.0.0 - * - * @param {number} value - The mass value, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ setMass: function (value) { - this.mass = value; + this.body.mass = value; return this; - }, + } + +}; + +module.exports = Mass; + + +/***/ }), +/* 518 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Immovable + * @since 3.0.0 + */ +var Immovable = { /** - * Sets the Body's `immovable` property. + * [description] * - * @method Phaser.Physics.Arcade.Body#setImmovable + * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable * @since 3.0.0 * - * @param {boolean} [value=true] - The value to assign to `immovable`. + * @param {boolean} [value=true] - [description] * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ setImmovable: function (value) { if (value === undefined) { value = true; } - this.immovable = value; + this.body.immovable = value; + + return this; + } + +}; + +module.exports = Immovable; + + +/***/ }), +/* 519 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods for setting the gravity properties of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.Physics.Arcade.Components.Gravity + * @since 3.0.0 + */ +var Gravity = { + + /** + * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. + * + * If only one value is provided, this value will be used for both the X and Y axis. + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravity + * @since 3.0.0 + * + * @param {number} x - The gravitational force to be applied to the X-axis. + * @param {number} [y=x] - The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. + * + * @return {this} This Game Object. + */ + setGravity: function (x, y) + { + this.body.gravity.set(x, y); return this; }, /** - * The Body's horizontal position (left edge). + * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. * - * @name Phaser.Physics.Arcade.Body#x - * @type {number} + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX + * @since 3.0.0 + * + * @param {number} x - The gravitational force to be applied to the X-axis. + * + * @return {this} This Game Object. + */ + setGravityX: function (x) + { + this.body.gravity.x = x; + + return this; + }, + + /** + * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY + * @since 3.0.0 + * + * @param {number} y - The gravitational force to be applied to the Y-axis. + * + * @return {this} This Game Object. + */ + setGravityY: function (y) + { + this.body.gravity.y = y; + + return this; + } + +}; + +module.exports = Gravity; + + +/***/ }), +/* 520 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @name Phaser.Physics.Arcade.Components.Friction + * @since 3.0.0 + */ +var Friction = { + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @method Phaser.Physics.Arcade.Components.Friction#setFriction + * @since 3.0.0 + * + * @param {number} x - The amount of horizontal friction to apply. + * @param {number} [y=x] - The amount of vertical friction to apply. + * + * @return {this} This Game Object. + */ + setFriction: function (x, y) + { + this.body.friction.set(x, y); + + return this; + }, + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX + * @since 3.0.0 + * + * @param {number} x - The amount of friction to apply. + * + * @return {this} This Game Object. + */ + setFrictionX: function (x) + { + this.body.friction.x = x; + + return this; + }, + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY + * @since 3.0.0 + * + * @param {number} x - The amount of friction to apply. + * + * @return {this} This Game Object. + */ + setFrictionY: function (y) + { + this.body.friction.y = y; + + return this; + } + +}; + +module.exports = Friction; + + +/***/ }), +/* 521 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Enable + * @since 3.0.0 + */ +var Enable = { + + /** + * Enables this Game Object's Body. + * + * @method Phaser.Physics.Arcade.Components.Enable#enableBody + * @since 3.0.0 + * + * @param {boolean} reset - Also reset the Body and place it at (x, y). + * @param {number} x - The horizontal position to place the Game Object and Body. + * @param {number} y - The horizontal position to place the Game Object and Body. + * @param {boolean} enableGameObject - Also activate this Game Object. + * @param {boolean} showGameObject - Also show this Game Object. + * + * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.Body#enable + * @see Phaser.Physics.Arcade.StaticBody#enable + * @see Phaser.Physics.Arcade.Body#reset + * @see Phaser.Physics.Arcade.StaticBody#reset + * @see Phaser.GameObjects.GameObject#active + * @see Phaser.GameObjects.GameObject#visible + */ + enableBody: function (reset, x, y, enableGameObject, showGameObject) + { + if (reset) + { + this.body.reset(x, y); + } + + if (enableGameObject) + { + this.body.gameObject.active = true; + } + + if (showGameObject) + { + this.body.gameObject.visible = true; + } + + this.body.enable = true; + + return this; + }, + + /** + * Stops and disables this Game Object's Body. + * + * @method Phaser.Physics.Arcade.Components.Enable#disableBody + * @since 3.0.0 + * + * @param {boolean} [disableGameObject=false] - Also deactivate this Game Object. + * @param {boolean} [hideGameObject=false] - Also hide this Game Object. + * + * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.Body#enable + * @see Phaser.Physics.Arcade.StaticBody#enable + * @see Phaser.GameObjects.GameObject#active + * @see Phaser.GameObjects.GameObject#visible + */ + disableBody: function (disableGameObject, hideGameObject) + { + if (disableGameObject === undefined) { disableGameObject = false; } + if (hideGameObject === undefined) { hideGameObject = false; } + + this.body.stop(); + + this.body.enable = false; + + if (disableGameObject) + { + this.body.gameObject.active = false; + } + + if (hideGameObject) + { + this.body.gameObject.visible = false; + } + + return this; + }, + + /** + * Syncs the Body's position and size with its parent Game Object. + * You don't need to call this for Dynamic Bodies, as it happens automatically. + * But for Static bodies it's a useful way of modifying the position of a Static Body + * in the Physics World, based on its Game Object. + * + * @method Phaser.Physics.Arcade.Components.Enable#refreshBody + * @since 3.1.0 + * + * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject + */ + refreshBody: function () + { + this.body.updateFromGameObject(); + + return this; + } + +}; + +module.exports = Enable; + + +/***/ }), +/* 522 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Drag + * @since 3.0.0 + */ +var Drag = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDrag + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. + */ + setDrag: function (x, y) + { + this.body.drag.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setDragX: function (value) + { + this.body.drag.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setDragY: function (value) + { + this.body.drag.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDamping + * @since 3.10.0 + * + * @param {boolean} value - `true` to use damping for deceleration, or `false` to use linear deceleration. + * + * @return {this} This Game Object. + */ + setDamping: function (value) + { + this.body.useDamping = value; + + return this; + } + +}; + +module.exports = Drag; + + +/***/ }), +/* 523 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug + * @since 3.0.0 + */ +var Debug = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebug + * @since 3.0.0 + * + * @param {boolean} showBody - [description] + * @param {boolean} showVelocity - [description] + * @param {number} bodyColor - [description] + * + * @return {this} This Game Object. + */ + setDebug: function (showBody, showVelocity, bodyColor) + { + this.debugShowBody = showBody; + this.debugShowVelocity = showVelocity; + this.debugBodyColor = bodyColor; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setDebugBodyColor: function (value) + { + this.body.debugBodyColor = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody + * @type {boolean} * @since 3.0.0 */ - x: { + debugShowBody: { get: function () { - return this.position.x; + return this.body.debugShowBody; }, set: function (value) { - this.position.x = value; + this.body.debugShowBody = value; } }, /** - * The Body's vertical position (top edge). + * [description] * - * @name Phaser.Physics.Arcade.Body#y - * @type {number} + * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity + * @type {boolean} * @since 3.0.0 */ - y: { + debugShowVelocity: { get: function () { - return this.position.y; + return this.body.debugShowVelocity; }, set: function (value) { - this.position.y = value; + this.body.debugShowVelocity = value; } }, /** - * The left edge of the Body's boundary. Identical to x. + * [description] * - * @name Phaser.Physics.Arcade.Body#left + * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor * @type {number} - * @readOnly * @since 3.0.0 */ - left: { + debugBodyColor: { get: function () { - return this.position.x; - } + return this.body.debugBodyColor; + }, - }, - - /** - * The right edge of the Body's boundary. - * - * @name Phaser.Physics.Arcade.Body#right - * @type {number} - * @readOnly - * @since 3.0.0 - */ - right: { - - get: function () + set: function (value) { - return this.position.x + this.width; - } - - }, - - /** - * The top edge of the Body's boundary. Identical to y. - * - * @name Phaser.Physics.Arcade.Body#top - * @type {number} - * @readOnly - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.position.y; - } - - }, - - /** - * The bottom edge of this Body's boundary. - * - * @name Phaser.Physics.Arcade.Body#bottom - * @type {number} - * @readOnly - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.position.y + this.height; + this.body.debugBodyColor = value; } } -}); +}; -module.exports = Body; +module.exports = Debug; /***/ }), -/* 340 */ +/* 524 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Bounce + * @since 3.0.0 + */ +var Bounce = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounce + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. + */ + setBounce: function (x, y) + { + this.body.bounce.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setBounceX: function (value) + { + this.body.bounce.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setBounceY: function (value) + { + this.body.bounce.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {this} This Game Object. + */ + setCollideWorldBounds: function (value) + { + this.body.collideWorldBounds = value; + + return this; + } + +}; + +module.exports = Bounce; + + +/***/ }), +/* 525 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Angular + * @since 3.0.0 + */ +var Angular = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setAngularVelocity: function (value) + { + this.body.angularVelocity = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setAngularAcceleration: function (value) + { + this.body.angularAcceleration = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setAngularDrag: function (value) + { + this.body.angularDrag = value; + + return this; + } + +}; + +module.exports = Angular; + + +/***/ }), +/* 526 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the acceleration properties of an Arcade Body. + * + * @name Phaser.Physics.Arcade.Components.Acceleration + * @since 3.0.0 + */ +var Acceleration = { + + /** + * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration + * @since 3.0.0 + * + * @param {number} x - The horizontal acceleration + * @param {number} [y=x] - The vertical acceleration + * + * @return {this} This Game Object. + */ + setAcceleration: function (x, y) + { + this.body.acceleration.set(x, y); + + return this; + }, + + /** + * Sets the body's horizontal acceleration. + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - The horizontal acceleration + * + * @return {this} This Game Object. + */ + setAccelerationX: function (value) + { + this.body.acceleration.x = value; + + return this; + }, + + /** + * Sets the body's vertical acceleration. + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - The vertical acceleration + * + * @return {this} This Game Object. + */ + setAccelerationY: function (value) + { + this.body.acceleration.y = value; + + return this; + } + +}; + +module.exports = Acceleration; + + +/***/ }), +/* 527 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -79927,1726 +104690,162 @@ module.exports = Body; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Body = __webpack_require__(339); -var Clamp = __webpack_require__(23); var Class = __webpack_require__(0); -var Collider = __webpack_require__(338); -var CONST = __webpack_require__(42); -var DistanceBetween = __webpack_require__(58); -var EventEmitter = __webpack_require__(9); -var FuzzyEqual = __webpack_require__(351); -var FuzzyGreaterThan = __webpack_require__(350); -var FuzzyLessThan = __webpack_require__(349); -var GetOverlapX = __webpack_require__(337); -var GetOverlapY = __webpack_require__(336); -var GetValue = __webpack_require__(4); -var ProcessQueue = __webpack_require__(223); -var ProcessTileCallbacks = __webpack_require__(689); -var Rectangle = __webpack_require__(14); -var RTree = __webpack_require__(222); -var SeparateTile = __webpack_require__(688); -var SeparateX = __webpack_require__(683); -var SeparateY = __webpack_require__(682); -var Set = __webpack_require__(70); -var StaticBody = __webpack_require__(334); -var TileIntersectsBody = __webpack_require__(335); -var Vector2 = __webpack_require__(6); -var Wrap = __webpack_require__(39); - -/** - * @event Phaser.Physics.Arcade.World#pause - */ - -/** - * @event Phaser.Physics.Arcade.World#resume - */ - -/** - * @event Phaser.Physics.Arcade.World#collide - * @param {Phaser.GameObjects.GameObject} gameObject1 - * @param {Phaser.GameObjects.GameObject} gameObject2 - * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 - * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 - */ - -/** - * @event Phaser.Physics.Arcade.World#overlap - * @param {Phaser.GameObjects.GameObject} gameObject1 - * @param {Phaser.GameObjects.GameObject} gameObject2 - * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 - * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 - */ - -/** - * @event Phaser.Physics.Arcade.World#worldbounds - * @param {Phaser.Physics.Arcade.Body} body - * @param {boolean} up - * @param {boolean} down - * @param {boolean} left - * @param {boolean} right - */ - -/** - * @typedef {object} ArcadeWorldConfig - * - * @property {number} [fps=60] - Sets {@link Phaser.Physics.Arcade.World#fps}. - * @property {number} [timeScale=1] - Sets {@link Phaser.Physics.Arcade.World#timeScale}. - * @property {object} [gravity] - Sets {@link Phaser.Physics.Arcade.World#gravity}. - * @property {number} [gravity.x=0] - The horizontal world gravity value. - * @property {number} [gravity.y=0] - The vertical world gravity value. - * @property {number} [x=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.x}. - * @property {number} [y=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.y}. - * @property {number} [width=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.width}. - * @property {number} [height=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.height}. - * @property {object} [checkCollision] - Sets {@link Phaser.Physics.Arcade.World#checkCollision}. - * @property {boolean} [checkCollision.up=true] - Should bodies collide with the top of the world bounds? - * @property {boolean} [checkCollision.down=true] - Should bodies collide with the bottom of the world bounds? - * @property {boolean} [checkCollision.left=true] - Should bodies collide with the left of the world bounds? - * @property {boolean} [checkCollision.right=true] - Should bodies collide with the right of the world bounds? - * @property {number} [overlapBias=4] - Sets {@link Phaser.Physics.Arcade.World#OVERLAP_BIAS}. - * @property {number} [tileBias=16] - Sets {@link Phaser.Physics.Arcade.World#TILE_BIAS}. - * @property {boolean} [forceX=false] - Sets {@link Phaser.Physics.Arcade.World#forceX}. - * @property {boolean} [isPaused=false] - Sets {@link Phaser.Physics.Arcade.World#isPaused}. - * @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Arcade.World#debug}. - * @property {boolean} [debugShowBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowBody}. - * @property {boolean} [debugShowStaticBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. - * @property {boolean} [debugShowVelocity=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. - * @property {number} [debugBodyColor=0xff00ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugBodyColor}. - * @property {number} [debugStaticBodyColor=0x0000ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugStaticBodyColor}. - * @property {number} [debugVelocityColor=0x00ff00] - Sets {@link Phaser.Physics.Arcade.World#defaults debugVelocityColor}. - * @property {number} [maxEntries=16] - Sets {@link Phaser.Physics.Arcade.World#maxEntries}. - * @property {boolean} [useTree=true] - Sets {@link Phaser.Physics.Arcade.World#useTree}. - */ - -/** - * @typedef {object} CheckCollisionObject - * - * @property {boolean} up - [description] - * @property {boolean} down - [description] - * @property {boolean} left - [description] - * @property {boolean} right - [description] - */ - -/** - * @typedef {object} ArcadeWorldDefaults - * - * @property {boolean} debugShowBody - [description] - * @property {boolean} debugShowStaticBody - [description] - * @property {boolean} debugShowVelocity - [description] - * @property {number} bodyDebugColor - [description] - * @property {number} staticBodyDebugColor - [description] - * @property {number} velocityDebugColor - [description] - */ - -/** - * @typedef {object} ArcadeWorldTreeMinMax - * - * @property {number} minX - [description] - * @property {number} minY - [description] - * @property {number} maxX - [description] - * @property {number} maxY - [description] - */ - -/** - * An Arcade Physics Collider Type. - * - * @typedef {( - * Phaser.GameObjects.GameObject| - * Phaser.GameObjects.Group| - * Phaser.Physics.Arcade.Sprite| - * Phaser.Physics.Arcade.Image| - * Phaser.Physics.Arcade.StaticGroup| - * Phaser.Physics.Arcade.Group| - * Phaser.Tilemaps.DynamicTilemapLayer| - * Phaser.Tilemaps.StaticTilemapLayer| - * Phaser.GameObjects.GameObject[]| - * Phaser.Physics.Arcade.Sprite[]| - * Phaser.Physics.Arcade.Image[]| - * Phaser.Physics.Arcade.StaticGroup[]| - * Phaser.Physics.Arcade.Group[]| - * Phaser.Tilemaps.DynamicTilemapLayer[]| - * Phaser.Tilemaps.StaticTilemapLayer[] - * )} ArcadeColliderType - */ +var DegToRad = __webpack_require__(31); +var DistanceBetween = __webpack_require__(52); +var DistanceSquared = __webpack_require__(249); +var Factory = __webpack_require__(238); +var GetFastValue = __webpack_require__(2); +var Merge = __webpack_require__(96); +var PluginCache = __webpack_require__(15); +var Vector2 = __webpack_require__(3); +var World = __webpack_require__(233); /** * @classdesc - * The Arcade Physics World. + * The Arcade Physics Plugin belongs to a Scene and sets up and manages the Scene's physics simulation. + * It also holds some useful methods for moving and rotating Arcade Physics Bodies. * - * The World is responsible for creating, managing, colliding and updating all of the bodies within it. + * You can access it from within a Scene using `this.physics`. * - * An instance of the World belongs to a Phaser.Scene and is accessed via the property `physics.world`. - * - * @class World - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Physics.Arcade + * @class ArcadePhysics + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - The Scene to which this World instance belongs. - * @param {ArcadeWorldConfig} config - An Arcade Physics Configuration object. + * @param {Phaser.Scene} scene - The Scene that this Plugin belongs to. */ -var World = new Class({ - - Extends: EventEmitter, +var ArcadePhysics = new Class({ initialize: - function World (scene, config) + function ArcadePhysics (scene) { - EventEmitter.call(this); - /** - * The Scene this simulation belongs to. + * The Scene that this Plugin belongs to. * - * @name Phaser.Physics.Arcade.World#scene + * @name Phaser.Physics.Arcade.ArcadePhysics#scene * @type {Phaser.Scene} * @since 3.0.0 */ this.scene = scene; /** - * Dynamic Bodies in this simulation. + * The Scene's Systems. * - * @name Phaser.Physics.Arcade.World#bodies - * @type {Phaser.Structs.Set.} + * @name Phaser.Physics.Arcade.ArcadePhysics#systems + * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ - this.bodies = new Set(); + this.systems = scene.sys; /** - * Static Bodies in this simulation. + * A configuration object. Union of the `physics.arcade.*` properties of the GameConfig and SceneConfig objects. * - * @name Phaser.Physics.Arcade.World#staticBodies - * @type {Phaser.Structs.Set.} + * @name Phaser.Physics.Arcade.ArcadePhysics#config + * @type {object} * @since 3.0.0 */ - this.staticBodies = new Set(); + this.config = this.getConfig(); /** - * Static Bodies marked for deletion. + * The physics simulation. * - * @name Phaser.Physics.Arcade.World#pendingDestroy - * @type {Phaser.Structs.Set.<(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)>} - * @since 3.1.0 - */ - this.pendingDestroy = new Set(); - - /** - * This simulation's collision processors. - * - * @name Phaser.Physics.Arcade.World#colliders - * @type {Phaser.Structs.ProcessQueue.} + * @name Phaser.Physics.Arcade.ArcadePhysics#world + * @type {Phaser.Physics.Arcade.World} * @since 3.0.0 */ - this.colliders = new ProcessQueue(); + this.world; /** - * Acceleration of Bodies due to gravity, in pixels per second. + * An object holding the Arcade Physics factory methods. * - * @name Phaser.Physics.Arcade.World#gravity - * @type {Phaser.Math.Vector2} + * @name Phaser.Physics.Arcade.ArcadePhysics#add + * @type {Phaser.Physics.Arcade.Factory} * @since 3.0.0 */ - this.gravity = new Vector2(GetValue(config, 'gravity.x', 0), GetValue(config, 'gravity.y', 0)); + this.add; - /** - * A boundary constraining Bodies. - * - * @name Phaser.Physics.Arcade.World#bounds - * @type {Phaser.Geom.Rectangle} - * @since 3.0.0 - */ - this.bounds = new Rectangle( - GetValue(config, 'x', 0), - GetValue(config, 'y', 0), - GetValue(config, 'width', scene.sys.game.config.width), - GetValue(config, 'height', scene.sys.game.config.height) + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.world = new World(this.scene, this.config); + this.add = new Factory(this.world); + + this.systems.events.once('destroy', this.destroy, 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 () + { + if (!this.world) + { + 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); + }, + + /** + * Creates the physics configuration for the current Scene. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig + * @since 3.0.0 + * + * @return {object} The physics configuration. + */ + getConfig: function () + { + var gameConfig = this.systems.game.config.physics; + var sceneConfig = this.systems.settings.physics; + + var config = Merge( + GetFastValue(sceneConfig, 'arcade', {}), + GetFastValue(gameConfig, 'arcade', {}) ); - /** - * The boundary edges that Bodies can collide with. - * - * @name Phaser.Physics.Arcade.World#checkCollision - * @type {CheckCollisionObject} - * @since 3.0.0 - */ - this.checkCollision = { - up: GetValue(config, 'checkCollision.up', true), - down: GetValue(config, 'checkCollision.down', true), - left: GetValue(config, 'checkCollision.left', true), - right: GetValue(config, 'checkCollision.right', true) - }; - - /** - * The number of physics steps to be taken per second. - * - * This property is read-only. Use the `setFPS` method to modify it at run-time. - * - * @name Phaser.Physics.Arcade.World#fps - * @readOnly - * @type {number} - * @default 60 - * @since 3.10.0 - */ - this.fps = GetValue(config, 'fps', 60); - - /** - * The amount of elapsed ms since the last frame. - * - * @name Phaser.Physics.Arcade.World#_elapsed - * @private - * @type {number} - * @since 3.10.0 - */ - this._elapsed = 0; - - /** - * Internal frame time value. - * - * @name Phaser.Physics.Arcade.World#_frameTime - * @private - * @type {number} - * @since 3.10.0 - */ - this._frameTime = 1 / this.fps; - - /** - * Internal frame time ms value. - * - * @name Phaser.Physics.Arcade.World#_frameTimeMS - * @private - * @type {number} - * @since 3.10.0 - */ - this._frameTimeMS = 1000 * this._frameTime; - - /** - * The number of steps that took place in the last frame. - * - * @name Phaser.Physics.Arcade.World#stepsLastFrame - * @readOnly - * @type {number} - * @since 3.10.0 - */ - this.stepsLastFrame = 0; - - /** - * Scaling factor applied to the frame rate. - * - * - 1.0 = normal speed - * - 2.0 = half speed - * - 0.5 = double speed - * - * @name Phaser.Physics.Arcade.World#timeScale - * @property {number} - * @default 1 - * @since 3.10.0 - */ - this.timeScale = GetValue(config, 'timeScale', 1); - - /** - * The maximum absolute difference of a Body's per-step velocity and its overlap with another Body that will result in separation on *each axis*. - * Larger values favor separation. - * Smaller values favor no separation. - * - * @name Phaser.Physics.Arcade.World#OVERLAP_BIAS - * @type {number} - * @default 4 - * @since 3.0.0 - */ - this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4); - - /** - * The maximum absolute value of a Body's overlap with a tile that will result in separation on *each axis*. - * Larger values favor separation. - * Smaller values favor no separation. - * The optimum value may be similar to the tile size. - * - * @name Phaser.Physics.Arcade.World#TILE_BIAS - * @type {number} - * @default 16 - * @since 3.0.0 - */ - this.TILE_BIAS = GetValue(config, 'tileBias', 16); - - /** - * Always separate overlapping Bodies horizontally before vertically. - * False (the default) means Bodies are first separated on the axis of greater gravity, or the vertical axis if neither is greater. - * - * @name Phaser.Physics.Arcade.World#forceX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.forceX = GetValue(config, 'forceX', false); - - /** - * Whether the simulation advances with the game loop. - * - * @name Phaser.Physics.Arcade.World#isPaused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isPaused = GetValue(config, 'isPaused', false); - - /** - * Temporary total of colliding Bodies. - * - * @name Phaser.Physics.Arcade.World#_total - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._total = 0; - - /** - * Enables the debug display. - * - * @name Phaser.Physics.Arcade.World#drawDebug - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.drawDebug = GetValue(config, 'debug', false); - - /** - * The graphics object drawing the debug display. - * - * @name Phaser.Physics.Arcade.World#debugGraphic - * @type {Phaser.GameObjects.Graphics} - * @since 3.0.0 - */ - this.debugGraphic; - - /** - * Default debug display settings for new Bodies. - * - * @name Phaser.Physics.Arcade.World#defaults - * @type {ArcadeWorldDefaults} - * @since 3.0.0 - */ - this.defaults = { - debugShowBody: GetValue(config, 'debugShowBody', true), - debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), - debugShowVelocity: GetValue(config, 'debugShowVelocity', true), - bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), - staticBodyDebugColor: GetValue(config, 'debugStaticBodyColor', 0x0000ff), - velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) - }; - - /** - * The maximum number of items per node on the RTree. - * - * This is ignored if `useTree` is `false`. If you have a large number of bodies in - * your world then you may find search performance improves by increasing this value, - * to allow more items per node and less node division. - * - * @name Phaser.Physics.Arcade.World#maxEntries - * @type {integer} - * @default 16 - * @since 3.0.0 - */ - this.maxEntries = GetValue(config, 'maxEntries', 16); - - /** - * Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not? - * - * An RTree is a fast way of spatially sorting of all the moving bodies in the world. - * However, at certain limits, the cost of clearing and inserting the bodies into the - * tree every frame becomes more expensive than the search speed gains it provides. - * - * If you have a large number of dynamic bodies in your world then it may be best to - * disable the use of the RTree by setting this property to `true`. - * The number it can cope with depends on browser and device, but a conservative estimate - * of around 5,000 bodies should be considered the max before disabling it. - * - * Note this only applies to dynamic bodies. Static bodies are always kept in an RTree, - * because they don't have to be cleared every frame, so you benefit from the - * massive search speeds all the time. - * - * @name Phaser.Physics.Arcade.World#useTree - * @type {boolean} - * @default true - * @since 3.10.0 - */ - this.useTree = GetValue(config, 'useTree', true); - - /** - * The spatial index of Dynamic Bodies. - * - * @name Phaser.Physics.Arcade.World#tree - * @type {Phaser.Structs.RTree} - * @since 3.0.0 - */ - this.tree = new RTree(this.maxEntries); - - /** - * The spatial index of Static Bodies. - * - * @name Phaser.Physics.Arcade.World#staticTree - * @type {Phaser.Structs.RTree} - * @since 3.0.0 - */ - this.staticTree = new RTree(this.maxEntries); - - /** - * Recycled input for tree searches. - * - * @name Phaser.Physics.Arcade.World#treeMinMax - * @type {ArcadeWorldTreeMinMax} - * @since 3.0.0 - */ - this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; - - if (this.drawDebug) - { - this.createDebugGraphic(); - } + return config; }, /** - * Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group. - * - * The difference between this and the `enableBody` method is that you can pass arrays or Groups - * to this method. + * Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap} * - * You can specify if the bodies are to be Dynamic or Static. A dynamic body can move via velocity and - * acceleration. A static body remains fixed in place and as such is able to use an optimized search - * tree, making it ideal for static elements such as level objects. You can still collide and overlap - * with static bodies. - * - * Normally, rather than calling this method directly, you'd use the helper methods available in the - * Arcade Physics Factory, such as: - * - * ```javascript - * this.physics.add.image(x, y, textureKey); - * this.physics.add.sprite(x, y, textureKey); - * ``` - * - * Calling factory methods encapsulates the creation of a Game Object and the creation of its - * body at the same time. If you are creating custom classes then you can pass them to this - * method to have their bodies created. - * - * @method Phaser.Physics.Arcade.World#enable + * @method Phaser.Physics.Arcade.ArcadePhysics#overlap * @since 3.0.0 * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to create the bodies. - * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. - */ - enable: function (object, bodyType) - { - if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } - - if (!Array.isArray(object)) - { - object = [ object ]; - } - - for (var i = 0; i < object.length; i++) - { - var entry = object[i]; - - if (entry.isParent) - { - var children = entry.getChildren(); - - for (var c = 0; c < children.length; c++) - { - var child = children[c]; - - if (child.isParent) - { - // Handle Groups nested inside of Groups - this.enable(child, bodyType); - } - else - { - this.enableBody(child, bodyType); - } - } - } - else - { - this.enableBody(entry, bodyType); - } - } - }, - - /** - * Creates an Arcade Physics Body on a single Game Object. - * - * If the Game Object already has a body, this method will simply add it back into the simulation. - * - * You can specify if the body is Dynamic or Static. A dynamic body can move via velocity and - * acceleration. A static body remains fixed in place and as such is able to use an optimized search - * tree, making it ideal for static elements such as level objects. You can still collide and overlap - * with static bodies. - * - * Normally, rather than calling this method directly, you'd use the helper methods available in the - * Arcade Physics Factory, such as: - * - * ```javascript - * this.physics.add.image(x, y, textureKey); - * this.physics.add.sprite(x, y, textureKey); - * ``` - * - * Calling factory methods encapsulates the creation of a Game Object and the creation of its - * body at the same time. If you are creating custom classes then you can pass them to this - * method to have their bodies created. - * - * @method Phaser.Physics.Arcade.World#enableBody - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object - The Game Object on which to create the body. - * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. - * - * @return {Phaser.GameObjects.GameObject} The Game Object on which the body was created. - */ - enableBody: function (object, bodyType) - { - if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } - - if (!object.body) - { - if (bodyType === CONST.DYNAMIC_BODY) - { - object.body = new Body(this, object); - } - else if (bodyType === CONST.STATIC_BODY) - { - object.body = new StaticBody(this, object); - } - } - - this.add(object.body); - - return object; - }, - - /** - * Adds an existing Arcade Physics Body or StaticBody to the simulation. - * - * The body is enabled and added to the local search trees. - * - * @method Phaser.Physics.Arcade.World#add - * @since 3.10.0 - * - * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be added to the simulation. - * - * @return {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} The Body that was added to the simulation. - */ - add: function (body) - { - if (body.physicsType === CONST.DYNAMIC_BODY) - { - this.bodies.set(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - this.staticBodies.set(body); - - this.staticTree.insert(body); - } - - body.enable = true; - - return body; - }, - - /** - * Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group. - * - * The difference between this and the `disableBody` method is that you can pass arrays or Groups - * to this method. - * - * The body itself is not deleted, it just has its `enable` property set to false, which - * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. - * - * @method Phaser.Physics.Arcade.World#disable - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to disable the bodies. - */ - disable: function (object) - { - if (!Array.isArray(object)) - { - object = [ object ]; - } - - for (var i = 0; i < object.length; i++) - { - var entry = object[i]; - - if (entry.isParent) - { - var children = entry.getChildren(); - - for (var c = 0; c < children.length; c++) - { - var child = children[c]; - - if (child.isParent) - { - // Handle Groups nested inside of Groups - this.disable(child); - } - else - { - this.disableBody(child); - } - } - } - else - { - this.disableBody(entry); - } - } - }, - - /** - * Disables an existing Arcade Physics Body or StaticBody and removes it from the simulation. - * - * The body is disabled and removed from the local search trees. - * - * The body itself is not deleted, it just has its `enable` property set to false, which - * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. - * - * @method Phaser.Physics.Arcade.World#disableBody - * @since 3.0.0 - * - * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be disabled. - */ - disableBody: function (body) - { - this.remove(body); - - body.enable = false; - }, - - /** - * Removes an existing Arcade Physics Body or StaticBody from the simulation. - * - * The body is disabled and removed from the local search trees. - * - * The body itself is not deleted, it just has its `enabled` property set to false, which - * means you can re-enable it again at any point by passing it to enable `enable` or `add`. - * - * @method Phaser.Physics.Arcade.World#remove - * @since 3.0.0 - * - * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The body to be removed from the simulation. - */ - remove: function (body) - { - if (body.physicsType === CONST.DYNAMIC_BODY) - { - this.tree.remove(body); - this.bodies.delete(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - this.staticBodies.delete(body); - this.staticTree.remove(body); - } - }, - - /** - * Creates a Graphics Game Object that the world will use to render the debug display to. - * - * This is called automatically when the World is instantiated if the `debug` config property - * was set to `true`. However, you can call it at any point should you need to display the - * debug Graphic from a fixed point. - * - * You can control which objects are drawn to the Graphics object, and the colors they use, - * by setting the debug properties in the physics config. - * - * You should not typically use this in a production game. Use it to aid during debugging. - * - * @method Phaser.Physics.Arcade.World#createDebugGraphic - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} The Graphics object that was created for use by the World. - */ - createDebugGraphic: function () - { - var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); - - graphic.setDepth(Number.MAX_VALUE); - - this.debugGraphic = graphic; - - this.drawDebug = true; - - return graphic; - }, - - /** - * Sets the position, size and properties of the World boundary. - * - * The World boundary is an invisible rectangle that defines the edges of the World. - * If a Body is set to collide with the world bounds then it will automatically stop - * when it reaches any of the edges. You can optionally set which edges of the boundary - * should be checked against. - * - * @method Phaser.Physics.Arcade.World#setBounds - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the boundary. - * @param {number} y - The top-left y coordinate of the boundary. - * @param {number} width - The width of the boundary. - * @param {number} height - The height of the boundary. - * @param {boolean} [checkLeft] - Should bodies check against the left edge of the boundary? - * @param {boolean} [checkRight] - Should bodies check against the right edge of the boundary? - * @param {boolean} [checkUp] - Should bodies check against the top edge of the boundary? - * @param {boolean} [checkDown] - Should bodies check against the bottom edge of the boundary? - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - setBounds: function (x, y, width, height, checkLeft, checkRight, checkUp, checkDown) - { - this.bounds.setTo(x, y, width, height); - - if (checkLeft !== undefined) - { - this.setBoundsCollision(checkLeft, checkRight, checkUp, checkDown); - } - - return this; - }, - - /** - * Enables or disables collisions on each edge of the World boundary. - * - * @method Phaser.Physics.Arcade.World#setBoundsCollision - * @since 3.0.0 - * - * @param {boolean} [left=true] - Should bodies check against the left edge of the boundary? - * @param {boolean} [right=true] - Should bodies check against the right edge of the boundary? - * @param {boolean} [up=true] - Should bodies check against the top edge of the boundary? - * @param {boolean} [down=true] - Should bodies check against the bottom edge of the boundary? - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - setBoundsCollision: function (left, right, up, down) - { - if (left === undefined) { left = true; } - if (right === undefined) { right = true; } - if (up === undefined) { up = true; } - if (down === undefined) { down = true; } - - this.checkCollision.left = left; - this.checkCollision.right = right; - this.checkCollision.up = up; - this.checkCollision.down = down; - - return this; - }, - - /** - * Pauses the simulation. - * - * A paused simulation does not update any existing bodies, or run any Colliders. - * - * However, you can still enable and disable bodies within it, or manually run collide or overlap - * checks. - * - * @method Phaser.Physics.Arcade.World#pause - * @fires Phaser.Physics.Arcade.World#pause - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - pause: function () - { - this.isPaused = true; - - this.emit('pause'); - - return this; - }, - - /** - * Resumes the simulation, if paused. - * - * @method Phaser.Physics.Arcade.World#resume - * @fires Phaser.Physics.Arcade.World#resume - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - resume: function () - { - this.isPaused = false; - - this.emit('resume'); - - return this; - }, - - /** - * Creates a new Collider object and adds it to the simulation. - * - * A Collider is a way to automatically perform collision checks between two objects, - * calling the collide and process callbacks if they occur. - * - * Colliders are run as part of the World update, after all of the Bodies have updated. - * - * By creating a Collider you don't need then call `World.collide` in your `update` loop, - * as it will be handled for you automatically. - * - * @method Phaser.Physics.Arcade.World#addCollider - * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#collide - * - * @param {ArcadeColliderType} object1 - The first object to check for collision. - * @param {ArcadeColliderType} object2 - The second object to check for collision. - * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. - * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. - * @param {*} [callbackContext] - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - addCollider: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - var collider = new Collider(this, false, object1, object2, collideCallback, processCallback, callbackContext); - - this.colliders.add(collider); - - return collider; - }, - - /** - * Creates a new Overlap Collider object and adds it to the simulation. - * - * A Collider is a way to automatically perform overlap checks between two objects, - * calling the collide and process callbacks if they occur. - * - * Colliders are run as part of the World update, after all of the Bodies have updated. - * - * By creating a Collider you don't need then call `World.overlap` in your `update` loop, - * as it will be handled for you automatically. - * - * @method Phaser.Physics.Arcade.World#addOverlap - * @since 3.0.0 - * - * @param {ArcadeColliderType} object1 - The first object to check for overlap. - * @param {ArcadeColliderType} object2 - The second object to check for overlap. - * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects overlap. - * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects overlap. Must return a boolean. - * @param {*} [callbackContext] - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - addOverlap: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - var collider = new Collider(this, true, object1, object2, collideCallback, processCallback, callbackContext); - - this.colliders.add(collider); - - return collider; - }, - - /** - * Removes a Collider from the simulation so it is no longer processed. - * - * This method does not destroy the Collider. If you wish to add it back at a later stage you can call - * `World.colliders.add(Collider)`. - * - * If you no longer need the Collider you can call the `Collider.destroy` method instead, which will - * automatically clear all of its references and then remove it from the World. If you call destroy on - * a Collider you _don't_ need to pass it to this method too. - * - * @method Phaser.Physics.Arcade.World#removeCollider - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Collider} collider - The Collider to remove from the simulation. - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - removeCollider: function (collider) - { - this.colliders.remove(collider); - - return this; - }, - - /** - * Sets the frame rate to run the simulation at. - * - * The frame rate value is used to simulate a fixed update time step. This fixed - * time step allows for a straightforward implementation of a deterministic game state. - * - * This frame rate is independent of the frequency at which the game is rendering. The - * higher you set the fps, the more physics simulation steps will occur per game step. - * Conversely, the lower you set it, the less will take place. - * - * You can optionally advance the simulation directly yourself by calling the `step` method. - * - * @method Phaser.Physics.Arcade.World#setFPS - * @since 3.10.0 - * - * @param {integer} framerate - The frame rate to advance the simulation at. - * - * @return {this} This World object. - */ - setFPS: function (framerate) - { - this.fps = framerate; - this._frameTime = 1 / this.fps; - this._frameTimeMS = 1000 * this._frameTime; - - return this; - }, - - /** - * Advances the simulation based on the elapsed time and fps rate. - * - * This is called automatically by your Scene and does not need to be invoked directly. - * - * @method Phaser.Physics.Arcade.World#update - * @protected - * @since 3.0.0 - * - * @param {number} 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.isPaused || this.bodies.size === 0) - { - return; - } - - var stepsThisFrame = 0; - var fixedDelta = this._frameTime; - var msPerFrame = this._frameTimeMS * this.timeScale; - - this._elapsed += delta; - - while (this._elapsed >= msPerFrame) - { - this._elapsed -= msPerFrame; - - stepsThisFrame++; - - this.step(fixedDelta); - } - - this.stepsLastFrame = stepsThisFrame; - }, - - /** - * Advances the simulation by one step. - * - * @method Phaser.Physics.Arcade.World#step - * @since 3.10.0 - * - * @param {number} delta - The delta time amount, in ms, by which to advance the simulation. - */ - step: function (delta) - { - // Update all active bodies - var i; - var body; - var bodies = this.bodies.entries; - var len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.enable) - { - body.update(delta); - } - } - - // Optionally populate our dynamic collision tree - if (this.useTree) - { - this.tree.clear(); - this.tree.load(bodies); - } - - // Process any colliders - var colliders = this.colliders.update(); - - for (i = 0; i < colliders.length; i++) - { - var collider = colliders[i]; - - if (collider.active) - { - collider.update(); - } - } - - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.enable) - { - body.postUpdate(); - } - } - }, - - /** - * Updates bodies, draws the debug display, and handles pending queue operations. - * - * @method Phaser.Physics.Arcade.World#postUpdate - * @since 3.0.0 - */ - postUpdate: function () - { - var i; - var body; - - var dynamic = this.bodies; - var staticBodies = this.staticBodies; - var pending = this.pendingDestroy; - - var bodies = dynamic.entries; - var len = bodies.length; - - if (this.drawDebug) - { - var graphics = this.debugGraphic; - - graphics.clear(); - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.willDrawDebug()) - { - body.drawDebug(graphics); - } - } - - bodies = staticBodies.entries; - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.willDrawDebug()) - { - body.drawDebug(graphics); - } - } - } - - if (pending.size > 0) - { - var dynamicTree = this.tree; - var staticTree = this.staticTree; - - bodies = pending.entries; - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.physicsType === CONST.DYNAMIC_BODY) - { - dynamicTree.remove(body); - dynamic.delete(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - staticTree.remove(body); - staticBodies.delete(body); - } - - body.world = undefined; - body.gameObject = undefined; - } - - pending.clear(); - } - }, - - /** - * Calculates a Body's velocity and updates its position. - * - * @method Phaser.Physics.Arcade.World#updateMotion - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body to be updated. - * @param {number} delta - The delta value to be used in the motion calculations. - */ - updateMotion: function (body, delta) - { - if (body.allowRotation) - { - this.computeAngularVelocity(body, delta); - } - - this.computeVelocity(body, delta); - }, - - /** - * Calculates a Body's angular velocity. - * - * @method Phaser.Physics.Arcade.World#computeAngularVelocity - * @since 3.10.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. - * @param {number} delta - The delta value to be used in the calculation. - */ - computeAngularVelocity: function (body, delta) - { - var velocity = body.angularVelocity; - var acceleration = body.angularAcceleration; - var drag = body.angularDrag; - var max = body.maxAngular; - - if (acceleration) - { - velocity += acceleration * delta; - } - else if (body.allowDrag && drag) - { - drag *= delta; - - if (FuzzyGreaterThan(velocity - drag, 0, 0.1)) - { - velocity -= drag; - } - else if (FuzzyLessThan(velocity + drag, 0, 0.1)) - { - velocity += drag; - } - else - { - velocity = 0; - } - } - - velocity = Clamp(velocity, -max, max); - - var velocityDelta = velocity - body.angularVelocity; - - body.angularVelocity += velocityDelta; - body.rotation += (body.angularVelocity * delta); - }, - - /** - * Calculates a Body's per-axis velocity. - * - * @method Phaser.Physics.Arcade.World#computeVelocity - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. - * @param {number} delta - The delta value to be used in the calculation. - */ - computeVelocity: function (body, delta) - { - var velocityX = body.velocity.x; - var accelerationX = body.acceleration.x; - var dragX = body.drag.x; - var maxX = body.maxVelocity.x; - - var velocityY = body.velocity.y; - var accelerationY = body.acceleration.y; - var dragY = body.drag.y; - var maxY = body.maxVelocity.y; - - var speed = body.speed; - var allowDrag = body.allowDrag; - var useDamping = body.useDamping; - - if (body.allowGravity) - { - velocityX += (this.gravity.x + body.gravity.x) * delta; - velocityY += (this.gravity.y + body.gravity.y) * delta; - } - - if (accelerationX) - { - velocityX += accelerationX * delta; - } - else if (allowDrag && dragX) - { - if (useDamping) - { - // Damping based deceleration - velocityX *= dragX; - - if (FuzzyEqual(speed, 0, 0.001)) - { - velocityX = 0; - } - } - else - { - // Linear deceleration - dragX *= delta; - - if (FuzzyGreaterThan(velocityX - dragX, 0, 0.01)) - { - velocityX -= dragX; - } - else if (FuzzyLessThan(velocityX + dragX, 0, 0.01)) - { - velocityX += dragX; - } - else - { - velocityX = 0; - } - } - } - - if (accelerationY) - { - velocityY += accelerationY * delta; - } - else if (allowDrag && dragY) - { - if (useDamping) - { - // Damping based deceleration - velocityY *= dragY; - - if (FuzzyEqual(speed, 0, 0.001)) - { - velocityY = 0; - } - } - else - { - // Linear deceleration - dragY *= delta; - - if (FuzzyGreaterThan(velocityY - dragY, 0, 0.01)) - { - velocityY -= dragY; - } - else if (FuzzyLessThan(velocityY + dragY, 0, 0.01)) - { - velocityY += dragY; - } - else - { - velocityY = 0; - } - } - } - - velocityX = Clamp(velocityX, -maxX, maxX); - velocityY = Clamp(velocityY, -maxY, maxY); - - body.velocity.set(velocityX, velocityY); - }, - - /** - * Separates two Bodies. - * - * @method Phaser.Physics.Arcade.World#separate - * @fires Phaser.Physics.Arcade.World#collide - * @fires Phaser.Physics.Arcade.World#overlap - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. - * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. - * @param {ArcadePhysicsCallback} [processCallback] - The process callback. - * @param {*} [callbackContext] - The context in which to invoke the callback. - * @param {boolean} [overlapOnly] - If this a collide or overlap check? - * - * @return {boolean} True if separation occurred, otherwise false. - */ - separate: function (body1, body2, processCallback, callbackContext, overlapOnly) - { - if ( - !body1.enable || - !body2.enable || - body1.checkCollision.none || - body2.checkCollision.none || - !this.intersects(body1, body2)) - { - return false; - } - - // They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort. - if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false) - { - return false; - } - - // Circle vs. Circle quick bail out - if (body1.isCircle && body2.isCircle) - { - return this.separateCircle(body1, body2, overlapOnly); - } - - // We define the behavior of bodies in a collision circle and rectangle - // If a collision occurs in the corner points of the rectangle, the body behave like circles - - // Either body1 or body2 is a circle - if (body1.isCircle !== body2.isCircle) - { - var bodyRect = (body1.isCircle) ? body2 : body1; - var bodyCircle = (body1.isCircle) ? body1 : body2; - - var rect = { - x: bodyRect.x, - y: bodyRect.y, - right: bodyRect.right, - bottom: bodyRect.bottom - }; - - var circle = bodyCircle.center; - - if (circle.y < rect.y || circle.y > rect.bottom) - { - if (circle.x < rect.x || circle.x > rect.right) - { - return this.separateCircle(body1, body2, overlapOnly); - } - } - } - - var resultX = false; - var resultY = false; - - // Do we separate on x or y first? - if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x)) - { - resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); - - // Are they still intersecting? Let's do the other axis then - if (this.intersects(body1, body2)) - { - resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); - } - } - else - { - resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); - - // Are they still intersecting? Let's do the other axis then - if (this.intersects(body1, body2)) - { - resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); - } - } - - var result = (resultX || resultY); - - if (result) - { - if (overlapOnly && (body1.onOverlap || body2.onOverlap)) - { - this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); - } - else if (body1.onCollide || body2.onCollide) - { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); - } - } - - return result; - }, - - /** - * Separates two Bodies, when both are circular. - * - * @method Phaser.Physics.Arcade.World#separateCircle - * @fires Phaser.Physics.Arcade.World#collide - * @fires Phaser.Physics.Arcade.World#overlap - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. - * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. - * @param {boolean} [overlapOnly] - If this a collide or overlap check? - * @param {number} bias - A small value added to the calculations. - * - * @return {boolean} True if separation occurred, otherwise false. - */ - separateCircle: function (body1, body2, overlapOnly, bias) - { - // Set the bounding box overlap values into the bodies themselves (hence we don't use the return values here) - GetOverlapX(body1, body2, false, bias); - GetOverlapY(body1, body2, false, bias); - - var dx = body2.center.x - body1.center.x; - var dy = body2.center.y - body1.center.y; - - var angleCollision = Math.atan2(dy, dx); - - var overlap = 0; - - if (body1.isCircle !== body2.isCircle) - { - var rect = { - x: (body2.isCircle) ? body1.position.x : body2.position.x, - y: (body2.isCircle) ? body1.position.y : body2.position.y, - right: (body2.isCircle) ? body1.right : body2.right, - bottom: (body2.isCircle) ? body1.bottom : body2.bottom - }; - - var circle = { - x: (body1.isCircle) ? body1.center.x : body2.center.x, - y: (body1.isCircle) ? body1.center.y : body2.center.y, - radius: (body1.isCircle) ? body1.halfWidth : body2.halfWidth - }; - - if (circle.y < rect.y) - { - if (circle.x < rect.x) - { - overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.y) - circle.radius; - } - else if (circle.x > rect.right) - { - overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.y) - circle.radius; - } - } - else if (circle.y > rect.bottom) - { - if (circle.x < rect.x) - { - overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.bottom) - circle.radius; - } - else if (circle.x > rect.right) - { - overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.bottom) - circle.radius; - } - } - - overlap *= -1; - } - else - { - overlap = (body1.halfWidth + body2.halfWidth) - DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y); - } - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) - { - if (overlap !== 0 && (body1.onOverlap || body2.onOverlap)) - { - this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); - } - - // return true if there was some overlap, otherwise false - return (overlap !== 0); - } - - // Transform the velocity vector to the coordinate system oriented along the direction of impact. - // This is done to eliminate the vertical component of the velocity - - var b1vx = body1.velocity.x; - var b1vy = body1.velocity.y; - var b1mass = body1.mass; - - var b2vx = body2.velocity.x; - var b2vy = body2.velocity.y; - var b2mass = body2.mass; - - var v1 = { - x: b1vx * Math.cos(angleCollision) + b1vy * Math.sin(angleCollision), - y: b1vx * Math.sin(angleCollision) - b1vy * Math.cos(angleCollision) - }; - - var v2 = { - x: b2vx * Math.cos(angleCollision) + b2vy * Math.sin(angleCollision), - y: b2vx * Math.sin(angleCollision) - b2vy * Math.cos(angleCollision) - }; - - // We expect the new velocity after impact - var tempVel1 = ((b1mass - b2mass) * v1.x + 2 * b2mass * v2.x) / (b1mass + b2mass); - var tempVel2 = (2 * b1mass * v1.x + (b2mass - b1mass) * v2.x) / (b1mass + b2mass); - - // We convert the vector to the original coordinate system and multiplied by factor of rebound - if (!body1.immovable) - { - body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x; - body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y; - - // Reset local var - b1vx = body1.velocity.x; - b1vy = body1.velocity.y; - } - - if (!body2.immovable) - { - body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x; - body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y; - - // Reset local var - b2vx = body2.velocity.x; - b2vy = body2.velocity.y; - } - - // When the collision angle is almost perpendicular to the total initial velocity vector - // (collision on a tangent) vector direction can be determined incorrectly. - // This code fixes the problem - - if (Math.abs(angleCollision) < Math.PI / 2) - { - if ((b1vx > 0) && !body1.immovable && (b2vx > b1vx)) - { - body1.velocity.x *= -1; - } - else if ((b2vx < 0) && !body2.immovable && (b1vx < b2vx)) - { - body2.velocity.x *= -1; - } - else if ((b1vy > 0) && !body1.immovable && (b2vy > b1vy)) - { - body1.velocity.y *= -1; - } - else if ((b2vy < 0) && !body2.immovable && (b1vy < b2vy)) - { - body2.velocity.y *= -1; - } - } - else if (Math.abs(angleCollision) > Math.PI / 2) - { - if ((b1vx < 0) && !body1.immovable && (b2vx < b1vx)) - { - body1.velocity.x *= -1; - } - else if ((b2vx > 0) && !body2.immovable && (b1vx > b2vx)) - { - body2.velocity.x *= -1; - } - else if ((b1vy < 0) && !body1.immovable && (b2vy < b1vy)) - { - body1.velocity.y *= -1; - } - else if ((b2vy > 0) && !body2.immovable && (b1vx > b2vy)) - { - body2.velocity.y *= -1; - } - } - - var delta = this._frameTime; - - if (!body1.immovable) - { - body1.x += (body1.velocity.x * delta) - overlap * Math.cos(angleCollision); - body1.y += (body1.velocity.y * delta) - overlap * Math.sin(angleCollision); - } - - if (!body2.immovable) - { - body2.x += (body2.velocity.x * delta) + overlap * Math.cos(angleCollision); - body2.y += (body2.velocity.y * delta) + overlap * Math.sin(angleCollision); - } - - if (body1.onCollide || body2.onCollide) - { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); - } - - return true; - }, - - /** - * Checks to see if two Bodies intersect at all. - * - * @method Phaser.Physics.Arcade.World#intersects - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - The first body to check. - * @param {Phaser.Physics.Arcade.Body} body2 - The second body to check. - * - * @return {boolean} True if the two bodies intersect, otherwise false. - */ - intersects: function (body1, body2) - { - if (body1 === body2) - { - return false; - } - - if (!body1.isCircle && !body2.isCircle) - { - // Rect vs. Rect - return !( - body1.right <= body2.position.x || - body1.bottom <= body2.position.y || - body1.position.x >= body2.right || - body1.position.y >= body2.bottom - ); - } - else if (body1.isCircle) - { - if (body2.isCircle) - { - // Circle vs. Circle - return DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.halfWidth + body2.halfWidth); - } - else - { - // Circle vs. Rect - return this.circleBodyIntersects(body1, body2); - } - } - else - { - // Rect vs. Circle - return this.circleBodyIntersects(body2, body1); - } - }, - - /** - * Tests if a circular Body intersects with another Body. - * - * @method Phaser.Physics.Arcade.World#circleBodyIntersects - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} circle - The circular body to test. - * @param {Phaser.Physics.Arcade.Body} body - The rectangular body to test. - * - * @return {boolean} True if the two bodies intersect, otherwise false. - */ - circleBodyIntersects: function (circle, body) - { - var x = Clamp(circle.center.x, body.left, body.right); - var y = Clamp(circle.center.y, body.top, body.bottom); - - var dx = (circle.center.x - x) * (circle.center.x - x); - var dy = (circle.center.y - y) * (circle.center.y - y); - - return (dx + dy) <= (circle.halfWidth * circle.halfWidth); - }, - - /** - * Tests if Game Objects overlap. - * - * @method Phaser.Physics.Arcade.World#overlap - * @since 3.0.0 - * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} [overlapCallback] - [description] - * @param {ArcadePhysicsCallback} [processCallback] - [description] - * @param {*} [callbackContext] - [description] + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. * * @return {boolean} True if at least one Game Object overlaps another. + * + * @see Phaser.Physics.Arcade.World#overlap */ overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) { @@ -81654,37 +104853,24 @@ var World = new Class({ if (processCallback === undefined) { processCallback = null; } if (callbackContext === undefined) { callbackContext = overlapCallback; } - return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + return this.world.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); }, /** - * Performs a collision check and separation between the two physics enabled objects given, which can be single - * Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups. + * Tests if Game Objects overlap and separates them (if possible). See {@link Phaser.Physics.Arcade.World#collide}. * - * If you don't require separation then use {@link #overlap} instead. - * - * If two Groups or arrays are passed, each member of one will be tested against each member of the other. - * - * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. - * - * Two callbacks can be provided. The `collideCallback` is invoked if a collision occurs and the two colliding - * objects are passed to it. - * - * Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable - * for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other. - * The separation that stops two objects penetrating may create a new penetration against a different object. If you - * require a high level of stability please consider using an alternative physics system, such as Matter.js. - * - * @method Phaser.Physics.Arcade.World#collide + * @method Phaser.Physics.Arcade.ArcadePhysics#collide * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} [collideCallback] - [description] - * @param {ArcadePhysicsCallback} [processCallback] - [description] - * @param {*} [callbackContext] - [description] + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. * - * @return {boolean} True if any overlapping Game Objects were separated. + * @return {boolean} True if any overlapping Game Objects were separated, otherwise false. + * + * @see Phaser.Physics.Arcade.World#collide */ collide: function (object1, object2, collideCallback, processCallback, callbackContext) { @@ -81692,559 +104878,319 @@ var World = new Class({ if (processCallback === undefined) { processCallback = null; } if (callbackContext === undefined) { callbackContext = collideCallback; } - return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + return this.world.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); }, /** - * Helper for Phaser.Physics.Arcade.World#collide. + * Pauses the simulation. * - * @method Phaser.Physics.Arcade.World#collideObjects + * @method Phaser.Physics.Arcade.ArcadePhysics#pause * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} True if any overlapping objects were separated. + * @return {Phaser.Physics.Arcade.World} The simulation. */ - collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + pause: function () { - var i; - - if (object1.isParent && object1.physicsType === undefined) - { - object1 = object1.children.entries; - } - - if (object2 && object2.isParent && object2.physicsType === undefined) - { - object2 = object2.children.entries; - } - - var object1isArray = Array.isArray(object1); - var object2isArray = Array.isArray(object2); - - this._total = 0; - - if (!object1isArray && !object2isArray) - { - // Neither of them are arrays - do this first as it's the most common use-case - this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (!object1isArray && object2isArray) - { - // Object 2 is an Array - for (i = 0; i < object2.length; i++) - { - this.collideHandler(object1, object2[i], collideCallback, processCallback, callbackContext, overlapOnly); - } - } - else if (object1isArray && !object2isArray) - { - // Object 1 is an Array - for (i = 0; i < object1.length; i++) - { - this.collideHandler(object1[i], object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - else - { - // They're both arrays - for (i = 0; i < object1.length; i++) - { - for (var j = 0; j < object2.length; j++) - { - this.collideHandler(object1[i], object2[j], collideCallback, processCallback, callbackContext, overlapOnly); - } - } - } - - return (this._total > 0); + return this.world.pause(); }, /** - * Helper for Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap. + * Resumes the simulation (if paused). * - * @method Phaser.Physics.Arcade.World#collideHandler + * @method Phaser.Physics.Arcade.ArcadePhysics#resume * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] + * @return {Phaser.Physics.Arcade.World} The simulation. */ - collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + resume: function () { - // Collide Group with Self - // Only collide valid objects - if (object2 === undefined && object1.isParent) - { - return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - - // If neither of the objects are set then bail out - if (!object1 || !object2) - { - return false; - } - - // A Body - if (object1.body) - { - if (object2.body) - { - return this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isTilemap) - { - return this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - - // GROUPS - else if (object1.isParent) - { - if (object2.body) - { - return this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isTilemap) - { - return this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - - // TILEMAP LAYERS - else if (object1.isTilemap) - { - if (object2.body) - { - return this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - } + return this.world.resume(); }, /** - * Handler for Sprite vs. Sprite collisions. + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) * - * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateTo * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} sprite1 - [description] - * @param {Phaser.GameObjects.GameObject} sprite2 - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to accelerate towards. + * @param {number} y - The y coordinate to accelerate towards. + * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. * - * @return {boolean} [description] + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. */ - collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) + accelerateTo: function (gameObject, x, y, speed, xSpeedMax, ySpeedMax) { - if (!sprite1.body || !sprite2.body) + if (speed === undefined) { speed = 60; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + gameObject.body.acceleration.setToPolar(angle, speed); + + if (xSpeedMax !== undefined && ySpeedMax !== undefined) { - return false; + gameObject.body.maxVelocity.set(xSpeedMax, ySpeedMax); } - if (this.separate(sprite1.body, sprite2.body, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, sprite1, sprite2); - } - - this._total++; - } - - return true; + return angle; }, /** - * Handler for Sprite vs. Group collisions. + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) * - * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateToObject * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {Phaser.GameObjects.Group} group - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {Phaser.GameObjects.GameObject} destination - The Game Object to move towards. Can be any object but must have visible x/y properties. + * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. * - * @return {boolean} [description] + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. */ - collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) + accelerateToObject: function (gameObject, destination, speed, xSpeedMax, ySpeedMax) { - var bodyA = sprite.body; - - if (group.length === 0 || !bodyA || !bodyA.enable) - { - return; - } - - // Does sprite collide with anything? - - var i; - var len; - var bodyB; - - if (this.useTree) - { - var minMax = this.treeMinMax; - - minMax.minX = bodyA.left; - minMax.minY = bodyA.top; - minMax.maxX = bodyA.right; - minMax.maxY = bodyA.bottom; - - var results = (group.physicsType === CONST.DYNAMIC_BODY) ? this.tree.search(minMax) : this.staticTree.search(minMax); - - len = results.length; - - for (i = 0; i < len; i++) - { - bodyB = results[i]; - - if (bodyA === bodyB || !group.contains(bodyB.gameObject)) - { - // Skip if comparing against itself, or if bodyB isn't actually part of the Group - continue; - } - - if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); - } - - this._total++; - } - } - } - else - { - var children = group.getChildren(); - var skipIndex = group.children.entries.indexOf(sprite); - - len = children.length; - - for (i = 0; i < len; i++) - { - bodyB = children[i].body; - - if (!bodyB || i === skipIndex || !bodyB.enable) - { - continue; - } - - if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); - } - - this._total++; - } - } - } + return this.accelerateTo(gameObject, destination.x, destination.y, speed, xSpeedMax, ySpeedMax); }, /** - * Helper for Group vs. Tilemap collisions. + * Finds the Body closest to a source point or object. * - * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer + * @method Phaser.Physics.Arcade.ArcadePhysics#closest * @since 3.0.0 * - * @param {Phaser.GameObjects.Group} group - [description] - * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. * - * @return {boolean} [description] + * @return {Phaser.Physics.Arcade.Body} The closest Body to the given source point. */ - collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + closest: function (source) { - var children = group.getChildren(); + var bodies = this.world.tree.all(); - if (children.length === 0) + var min = Number.MAX_VALUE; + var closest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) { - return false; - } + var target = bodies[i]; + var distance = DistanceSquared(x, y, target.x, target.y); - var didCollide = false; - - for (var i = 0; i < children.length; i++) - { - if (children[i].body) + if (distance < min) { - if (this.collideSpriteVsTilemapLayer(children[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)) - { - didCollide = true; - } + closest = target; + min = distance; } } - return didCollide; + return closest; }, /** - * Helper for Sprite vs. Tilemap collisions. + * Finds the Body farthest from a source point or object. * - * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer - * @fires Phaser.Physics.Arcade.World#collide - * @fires Phaser.Physics.Arcade.World#overlap + * @method Phaser.Physics.Arcade.ArcadePhysics#furthest * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. * - * @return {boolean} [description] + * @return {Phaser.Physics.Arcade.Body} The Body furthest from the given source point. */ - collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + furthest: function (source) { - var body = sprite.body; + var bodies = this.world.tree.all(); - if (!body.enable) + var max = -1; + var farthest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) { - return false; - } + var target = bodies[i]; + var distance = DistanceSquared(x, y, target.x, target.y); - var x = body.position.x; - var y = body.position.y; - var w = body.width; - var h = body.height; - - // TODO: this logic should be encapsulated within the Tilemap API at some point. - // If the maps base tile size differs from the layer's tile size, we need to adjust the - // selection area by the difference between the two. - var layerData = tilemapLayer.layer; - - if (layerData.tileWidth > layerData.baseTileWidth) - { - // The x origin of a tile is the left side, so x and width need to be adjusted. - var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; - x -= xDiff; - w += xDiff; - } - - if (layerData.tileHeight > layerData.baseTileHeight) - { - // The y origin of a tile is the bottom side, so just the height needs to be adjusted. - var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; - h += yDiff; - } - - var mapData = tilemapLayer.getTilesWithinWorldXY(x, y, w, h); - - if (mapData.length === 0) - { - return false; - } - - var tile; - var tileWorldRect = { left: 0, right: 0, top: 0, bottom: 0 }; - - for (var i = 0; i < mapData.length; i++) - { - tile = mapData[i]; - tileWorldRect.left = tilemapLayer.tileToWorldX(tile.x); - tileWorldRect.top = tilemapLayer.tileToWorldY(tile.y); - - // If the map's base tile size differs from the layer's tile size, only the top of the rect - // needs to be adjusted since its origin is (0, 1). - if (tile.baseHeight !== tile.height) + if (distance > max) { - tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; - } - - tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; - tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; - - if (TileIntersectsBody(tileWorldRect, body) - && (!processCallback || processCallback.call(callbackContext, sprite, tile)) - && ProcessTileCallbacks(tile, sprite) - && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) - { - this._total++; - - if (collideCallback) - { - collideCallback.call(callbackContext, sprite, tile); - } - - if (overlapOnly && body.onOverlap) - { - sprite.emit('overlap', body.gameObject, tile, body, null); - } - else if (body.onCollide) - { - sprite.emit('collide', body.gameObject, tile, body, null); - } + farthest = target; + max = distance; } } + + return farthest; }, /** - * Helper for Group vs. Group collisions. + * Move the given display object towards the x/y coordinates at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) * - * @method Phaser.Physics.Arcade.World#collideGroupVsGroup + * @method Phaser.Physics.Arcade.ArcadePhysics#moveTo * @since 3.0.0 * - * @param {Phaser.GameObjects.Group} group1 - [description] - * @param {Phaser.GameObjects.Group} group2 - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to move towards. + * @param {number} y - The y coordinate to move towards. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. * - * @return {boolean} [description] + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. */ - collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) + moveTo: function (gameObject, x, y, speed, maxTime) { - if (group1.length === 0 || group2.length === 0) + if (speed === undefined) { speed = 60; } + if (maxTime === undefined) { maxTime = 0; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + if (maxTime > 0) { - return; + // We know how many pixels we need to move, but how fast? + speed = DistanceBetween(gameObject.x, gameObject.y, x, y) / (maxTime / 1000); } - var children = group1.getChildren(); + gameObject.body.velocity.setToPolar(angle, speed); - for (var i = 0; i < children.length; i++) - { - this.collideSpriteVsGroup(children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly); - } + return angle; }, /** - * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. + * Move the given display object towards the destination object at a steady velocity. + * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) * - * If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior). + * @method Phaser.Physics.Arcade.ArcadePhysics#moveToObject + * @since 3.0.0 * - * @method Phaser.Physics.Arcade.World#wrap - * @since 3.3.0 + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {object} destination - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. * - * @param {*} object - A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects. - * @param {number} [padding=0] - An amount added to each boundary edge during the operation. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. */ - wrap: function (object, padding) + moveToObject: function (gameObject, destination, speed, maxTime) { - if (object.body) - { - this.wrapObject(object, padding); - } - else if (object.getChildren) - { - this.wrapArray(object.getChildren(), padding); - } - else if (Array.isArray(object)) - { - this.wrapArray(object, padding); - } - else - { - this.wrapObject(object, padding); - } - }, - - - /** - * Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. - * - * @method Phaser.Physics.Arcade.World#wrapArray - * @since 3.3.0 - * - * @param {Array.<*>} objects - An array of objects to be wrapped. - * @param {number} [padding=0] - An amount added to the boundary. - */ - wrapArray: function (objects, padding) - { - for (var i = 0; i < objects.length; i++) - { - this.wrapObject(objects[i], padding); - } + return this.moveTo(gameObject, destination.x, destination.y, speed, maxTime); }, /** - * Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * Given the angle (in degrees) and speed calculate the velocity and return it as a vector, or set it to the given vector object. + * One way to use this is: velocityFromAngle(angle, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. * - * @method Phaser.Physics.Arcade.World#wrapObject - * @since 3.3.0 + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromAngle + * @since 3.0.0 * - * @param {*} object - A Game Object, a Physics Body, or any object with `x` and `y` coordinates - * @param {number} [padding=0] - An amount added to the boundary. + * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param {number} [speed=60] - The speed it will move, in pixels per second squared. + * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. */ - wrapObject: function (object, padding) + velocityFromAngle: function (angle, speed, vec2) { - if (padding === undefined) { padding = 0; } + if (speed === undefined) { speed = 60; } + if (vec2 === undefined) { vec2 = new Vector2(); } - object.x = Wrap(object.x, this.bounds.left - padding, this.bounds.right + padding); - object.y = Wrap(object.y, this.bounds.top - padding, this.bounds.bottom + padding); + return vec2.setToPolar(DegToRad(angle), speed); }, /** - * Shuts down the simulation, clearing physics data and removing listeners. + * Given the rotation (in radians) and speed calculate the velocity and return it as a vector, or set it to the given vector object. + * One way to use this is: velocityFromRotation(rotation, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. * - * @method Phaser.Physics.Arcade.World#shutdown + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromRotation + * @since 3.0.0 + * + * @param {number} rotation - The angle in radians. + * @param {number} [speed=60] - The speed it will move, in pixels per second squared + * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. + */ + velocityFromRotation: function (rotation, speed, vec2) + { + if (speed === undefined) { speed = 60; } + if (vec2 === undefined) { vec2 = new Vector2(); } + + return vec2.setToPolar(rotation, speed); + }, + + /** + * 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 () { - this.tree.clear(); - this.staticTree.clear(); - this.bodies.clear(); - this.staticBodies.clear(); - this.colliders.destroy(); + if (!this.world) + { + // Already destroyed + return; + } - this.removeAllListeners(); + 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.add.destroy(); + this.world.destroy(); + + this.add = null; + this.world = null; }, /** - * Shuts down the simulation and disconnects it from the current scene. + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. * - * @method Phaser.Physics.Arcade.World#destroy + * @method Phaser.Physics.Arcade.ArcadePhysics#destroy * @since 3.0.0 */ destroy: function () { this.shutdown(); + this.scene.sys.events.off('start', this.start, this); + this.scene = null; + this.systems = null; } }); -module.exports = World; +PluginCache.register('ArcadePhysics', ArcadePhysics, 'arcadePhysics'); + +module.exports = ArcadePhysics; /***/ }), -/* 341 */ +/* 528 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -82253,146 +105199,637 @@ module.exports = World; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Physics.Arcade.StaticGroup +var CONST = __webpack_require__(35); +var Extend = __webpack_require__(20); + +/** + * @callback ArcadePhysicsCallback + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + */ + +/** + * @namespace Phaser.Physics.Arcade + */ + +var Arcade = { + + ArcadePhysics: __webpack_require__(527), + Body: __webpack_require__(232), + Collider: __webpack_require__(231), + Factory: __webpack_require__(238), + Group: __webpack_require__(235), + Image: __webpack_require__(237), + Sprite: __webpack_require__(104), + StaticBody: __webpack_require__(225), + StaticGroup: __webpack_require__(234), + World: __webpack_require__(233) + +}; + +// Merge in the consts +Arcade = Extend(false, Arcade, CONST); + +module.exports = Arcade; + + +/***/ }), +/* 529 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector3 = __webpack_require__(138); +var Matrix4 = __webpack_require__(240); +var Quaternion = __webpack_require__(239); + +var tmpMat4 = new Matrix4(); +var tmpQuat = new Quaternion(); +var tmpVec3 = new Vector3(); + +/** + * Rotates a vector in place by axis angle. + * + * This is the same as transforming a point by an + * axis-angle quaternion, but it has higher precision. + * + * @function Phaser.Math.RotateVec3 + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec - The vector to be rotated. + * @param {Phaser.Math.Vector3} axis - The axis to rotate around. + * @param {number} radians - The angle of rotation in radians. + * + * @return {Phaser.Math.Vector3} The given vector. + */ +var RotateVec3 = function (vec, axis, radians) +{ + // Set the quaternion to our axis angle + tmpQuat.setAxisAngle(axis, radians); + + // Create a rotation matrix from the axis angle + tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); + + // Multiply our vector by the rotation matrix + return vec.transformMat4(tmpMat4); +}; + +module.exports = RotateVec3; + + +/***/ }), +/* 530 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl -var ArcadeSprite = __webpack_require__(142); var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var Group = __webpack_require__(112); /** * @classdesc - * [description] + * A representation of a vector in 4D space. * - * @class StaticGroup - * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade + * A four-component vector. + * + * @class Vector4 + * @memberof Phaser.Math * @constructor * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {GroupConfig} config - [description] + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + * @param {number} [w] - The w component. */ -var StaticPhysicsGroup = new Class({ - - Extends: Group, +var Vector4 = new Class({ initialize: - function StaticPhysicsGroup (world, scene, children, config) + function Vector4 (x, y, z, w) { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - else if (config === undefined) - { - config = {}; - } - /** - * [description] + * The x component of this Vector. * - * @name Phaser.Physics.Arcade.StaticGroup#world - * @type {Phaser.Physics.Arcade.World} + * @name Phaser.Math.Vector4#x + * @type {number} + * @default 0 * @since 3.0.0 */ - this.world = world; - - config.createCallback = this.createCallbackHandler; - config.removeCallback = this.removeCallbackHandler; - config.createMultipleCallback = this.createMultipleCallbackHandler; - - config.classType = ArcadeSprite; + this.x = 0; /** - * [description] + * The y component of this Vector. * - * @name Phaser.Physics.Arcade.StaticGroup#physicsType - * @type {integer} + * @name Phaser.Math.Vector4#y + * @type {number} + * @default 0 * @since 3.0.0 */ - this.physicsType = CONST.STATIC_BODY; + this.y = 0; - Group.call(this, scene, children, config); - }, + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector4#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.z = 0; - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#createCallbackHandler - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - createCallbackHandler: function (child) - { - if (!child.body) + /** + * The w component of this Vector. + * + * @name Phaser.Math.Vector4#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.w = 0; + + if (typeof x === 'object') { - this.world.enableBody(child, CONST.STATIC_BODY); + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; } }, /** - * [description] + * Make a clone of this Vector4. * - * @method Phaser.Physics.Arcade.StaticGroup#removeCallbackHandler + * @method Phaser.Math.Vector4#clone * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] + * @return {Phaser.Math.Vector4} A clone of this Vector4. */ - removeCallbackHandler: function (child) + clone: function () { - if (child.body) - { - this.world.disableBody(child); - } + return new Vector4(this.x, this.y, this.z, this.w); }, /** - * [description] + * Copy the components of a given Vector into this Vector. * - * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallbackHandler + * @method Phaser.Math.Vector4#copy * @since 3.0.0 * - * @param {object} entries - [description] + * @param {Phaser.Math.Vector4} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector4} This Vector4. */ - createMultipleCallbackHandler: function () + copy: function (src) { - this.refresh(); + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + this.w = src.w || 0; + + return this; }, /** - * [description] + * Check whether this Vector is equal to a given Vector. * - * @method Phaser.Physics.Arcade.StaticGroup#refresh + * Performs a strict quality check against each Vector's components. + * + * @method Phaser.Math.Vector4#equals * @since 3.0.0 * - * @return {Phaser.Physics.Arcade.StaticGroup} [description] + * @param {Phaser.Math.Vector4} v - The vector to check equality with. + * + * @return {boolean} A boolean indicating whether the two Vectors are equal or not. */ - refresh: function () + equals: function (v) { - var children = this.children.entries; + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); + }, - for (var i = 0; i < children.length; i++) + /** + * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. + * + * @method Phaser.Math.Vector4#set + * @since 3.0.0 + * + * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y, z and w components. + * @param {number} y - The y value to set for this Vector. + * @param {number} z - The z value to set for this Vector. + * @param {number} w - The z value to set for this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') { - children[i].body.reset(); + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector4#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + this.w += v.w || 0; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector4#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + this.w -= v.w || 0; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector4#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector4#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector4#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector4#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector4#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - The Vector4 to dot product with this Vector4. + * + * @return {number} The dot product of this Vector and the given Vector. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector4#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - The Vector4 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector4#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + this.w *= v.w || 1; + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector4#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + this.w /= v.w || 1; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector4#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector4#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return dx * dx + dy * dy + dz * dz + dw * dw; + }, + + /** + * Negate the `x`, `y`, `z` and `w` components of this Vector. + * + * @method Phaser.Math.Vector4#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector4#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector4 with. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + + return this; + }, + + /** + * Transform this Vector with the given Quaternion. + * + * @method Phaser.Math.Vector4#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + transformQuat: function (q) + { + // TODO: is this really the same as Vector3? + // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Make this Vector the zero vector (0, 0, 0, 0). + * + * @method Phaser.Math.Vector4#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 0; return this; } }); -module.exports = StaticPhysicsGroup; +// TODO: Check if these are required internally, if not, remove. +Vector4.prototype.sub = Vector4.prototype.subtract; +Vector4.prototype.mul = Vector4.prototype.multiply; +Vector4.prototype.div = Vector4.prototype.divide; +Vector4.prototype.dist = Vector4.prototype.distance; +Vector4.prototype.distSq = Vector4.prototype.distanceSq; +Vector4.prototype.len = Vector4.prototype.length; +Vector4.prototype.lenSq = Vector4.prototype.lengthSq; + +module.exports = Vector4; /***/ }), -/* 342 */ -/***/ (function(module, exports, __webpack_require__) { +/* 531 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -82400,286 +105837,629 @@ module.exports = StaticPhysicsGroup; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ArcadeSprite = __webpack_require__(142); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var GetFastValue = __webpack_require__(1); -var Group = __webpack_require__(112); - /** - * @typedef {object} PhysicsGroupConfig - * @extends GroupConfig + * Checks if the two values are within the given `tolerance` of each other. * - * @property {boolean} [collideWorldBounds=false] - Sets {@link Phaser.Physics.Arcade.Body#collideWorldBounds}. - * @property {number} [accelerationX=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.x}. - * @property {number} [accelerationY=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.y}. - * @property {boolean} [allowDrag=true] - Sets {@link Phaser.Physics.Arcade.Body#allowDrag}. - * @property {boolean} [allowGravity=true] - Sets {@link Phaser.Physics.Arcade.Body#allowGravity}. - * @property {boolean} [allowRotation=true] - Sets {@link Phaser.Physics.Arcade.Body#allowRotation}. - * @property {number} [bounceX=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.x}. - * @property {number} [bounceY=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.y}. - * @property {number} [dragX=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.x}. - * @property {number} [dragY=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.y}. - * @property {number} [gravityX=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.x}. - * @property {number} [gravityY=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.y}. - * @property {number} [frictionX=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.x}. - * @property {number} [frictionY=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.y}. - * @property {number} [velocityX=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.x}. - * @property {number} [velocityY=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.y}. - * @property {number} [angularVelocity=0] - Sets {@link Phaser.Physics.Arcade.Body#angularVelocity}. - * @property {number} [angularAcceleration=0] - Sets {@link Phaser.Physics.Arcade.Body#angularAcceleration}. - * @property {number} [angularDrag=0] - Sets {@link Phaser.Physics.Arcade.Body#angularDrag}. - * @property {number} [mass=0] - Sets {@link Phaser.Physics.Arcade.Body#mass}. - * @property {boolean} [immovable=false] - Sets {@link Phaser.Physics.Arcade.Body#immovable}. - */ - -/** - * @typedef {object} PhysicsGroupDefaults - * - * @property {boolean} setCollideWorldBounds - [description] - * @property {number} setAccelerationX - [description] - * @property {number} setAccelerationY - [description] - * @property {boolean} setAllowDrag - [description] - * @property {boolean} setAllowGravity - [description] - * @property {boolean} setAllowRotation - [description] - * @property {number} setBounceX - [description] - * @property {number} setBounceY - [description] - * @property {number} setDragX - [description] - * @property {number} setDragY - [description] - * @property {number} setGravityX - [description] - * @property {number} setGravityY - [description] - * @property {number} setFrictionX - [description] - * @property {number} setFrictionY - [description] - * @property {number} setVelocityX - [description] - * @property {number} setVelocityY - [description] - * @property {number} setAngularVelocity - [description] - * @property {number} setAngularAcceleration - [description] - * @property {number} setAngularDrag - [description] - * @property {number} setMass - [description] - * @property {boolean} setImmovable - [description] - */ - -/** - * @classdesc - * An Arcade Physics Group object. - * - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * - * @class Group - * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade - * @constructor + * @function Phaser.Math.Within * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {PhysicsGroupConfig} [config] - [description] + * @param {number} a - The first value to use in the calculation. + * @param {number} b - The second value to use in the calculation. + * @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range. + * + * @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`. */ -var PhysicsGroup = new Class({ +var Within = function (a, b, tolerance) +{ + return (Math.abs(a - b) <= tolerance); +}; - Extends: Group, - - initialize: - - function PhysicsGroup (world, scene, children, config) - { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - else if (config === undefined) - { - config = {}; - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - config.createCallback = this.createCallbackHandler; - config.removeCallback = this.removeCallbackHandler; - - /** - * The class to create new group members from. - * - * @name Phaser.Physics.Arcade.Group#classType - * @type {Phaser.Physics.Arcade.Sprite} - * @default ArcadeSprite - */ - config.classType = GetFastValue(config, 'classType', ArcadeSprite); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.DYNAMIC_BODY; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#defaults - * @type {PhysicsGroupDefaults} - * @since 3.0.0 - */ - this.defaults = { - setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false), - setAccelerationX: GetFastValue(config, 'accelerationX', 0), - setAccelerationY: GetFastValue(config, 'accelerationY', 0), - setAllowDrag: GetFastValue(config, 'allowDrag', true), - setAllowGravity: GetFastValue(config, 'allowGravity', true), - setAllowRotation: GetFastValue(config, 'allowRotation', true), - setBounceX: GetFastValue(config, 'bounceX', 0), - setBounceY: GetFastValue(config, 'bounceY', 0), - setDragX: GetFastValue(config, 'dragX', 0), - setDragY: GetFastValue(config, 'dragY', 0), - setGravityX: GetFastValue(config, 'gravityX', 0), - setGravityY: GetFastValue(config, 'gravityY', 0), - setFrictionX: GetFastValue(config, 'frictionX', 0), - setFrictionY: GetFastValue(config, 'frictionY', 0), - setVelocityX: GetFastValue(config, 'velocityX', 0), - setVelocityY: GetFastValue(config, 'velocityY', 0), - setAngularVelocity: GetFastValue(config, 'angularVelocity', 0), - setAngularAcceleration: GetFastValue(config, 'angularAcceleration', 0), - setAngularDrag: GetFastValue(config, 'angularDrag', 0), - setMass: GetFastValue(config, 'mass', 1), - setImmovable: GetFastValue(config, 'immovable', false) - }; - - Group.call(this, scene, children, config); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#createCallbackHandler - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - createCallbackHandler: function (child) - { - if (!child.body) - { - this.world.enableBody(child, CONST.DYNAMIC_BODY); - } - - var body = child.body; - - for (var key in this.defaults) - { - body[key](this.defaults[key]); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#removeCallbackHandler - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - removeCallbackHandler: function (child) - { - if (child.body) - { - this.world.disableBody(child); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocity: function (x, y, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.set(x + (i * step), y + (i * step)); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocityX - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocityX: function (value, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.x = value + (i * step); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocityY - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocityY: function (value, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.y = value + (i * step); - } - - return this; - } - -}); - -module.exports = PhysicsGroup; +module.exports = Within; /***/ }), -/* 343 */ +/* 532 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} SinCosTable + * + * @property {number} sin - The sine value. + * @property {number} cos - The cosine value. + * @property {number} length - The length. + */ + +/** + * Generate a series of sine and cosine values. + * + * @function Phaser.Math.SinCosTableGenerator + * @since 3.0.0 + * + * @param {number} length - The number of values to generate. + * @param {number} [sinAmp=1] - The sine value amplitude. + * @param {number} [cosAmp=1] - The cosine value amplitude. + * @param {number} [frequency=1] - The frequency of the values. + * + * @return {SinCosTable} The generated values. + */ +var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency) +{ + if (sinAmp === undefined) { sinAmp = 1; } + if (cosAmp === undefined) { cosAmp = 1; } + if (frequency === undefined) { frequency = 1; } + + frequency *= Math.PI / length; + + var cos = []; + var sin = []; + + for (var c = 0; c < length; c++) + { + cosAmp -= sinAmp * frequency; + sinAmp += cosAmp * frequency; + + cos[c] = cosAmp; + sin[c] = sinAmp; + } + + return { + sin: sin, + cos: cos, + length: length + }; +}; + +module.exports = SinCosTableGenerator; + + +/***/ }), +/* 533 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Round a value to a given decimal place. + * + * @function Phaser.Math.RoundTo + * @since 3.0.0 + * + * @param {number} value - The value to round. + * @param {integer} [place=0] - The place to round to. + * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. + * + * @return {number} The rounded value. + */ +var RoundTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.round(value * p) / p; +}; + +module.exports = RoundTo; + + +/***/ }), +/* 534 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random four-dimensional vector. + * + * @function Phaser.Math.RandomXYZW + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} vec4 - The Vector to compute random values for. + * @param {number} [scale=1] - The scale of the random values. + * + * @return {Phaser.Math.Vector4} The given Vector. + */ +var RandomXYZW = function (vec4, scale) +{ + if (scale === undefined) { scale = 1; } + + // TODO: Not spherical; should fix this for more uniform distribution + vec4.x = (Math.random() * 2 - 1) * scale; + vec4.y = (Math.random() * 2 - 1) * scale; + vec4.z = (Math.random() * 2 - 1) * scale; + vec4.w = (Math.random() * 2 - 1) * scale; + + return vec4; +}; + +module.exports = RandomXYZW; + + +/***/ }), +/* 535 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random position vector in a spherical area, optionally defined by the given radius. + * + * @function Phaser.Math.RandomXYZ + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec3 - The Vector to compute random values for. + * @param {number} [radius=1] - The radius. + * + * @return {Phaser.Math.Vector3} The given Vector. + */ +var RandomXYZ = function (vec3, radius) +{ + if (radius === undefined) { radius = 1; } + + var r = Math.random() * 2 * Math.PI; + var z = (Math.random() * 2) - 1; + var zScale = Math.sqrt(1 - z * z) * radius; + + vec3.x = Math.cos(r) * zScale; + vec3.y = Math.sin(r) * zScale; + vec3.z = z * radius; + + return vec3; +}; + +module.exports = RandomXYZ; + + +/***/ }), +/* 536 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random unit vector. + * + * Computes random values for the given vector between -1 and 1 that can be used to represent a direction. + * + * Optionally accepts a scale value to scale the resulting vector by. + * + * @function Phaser.Math.RandomXY + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} vector - The Vector to compute random values for. + * @param {number} [scale=1] - The scale of the random values. + * + * @return {Phaser.Math.Vector2} The given Vector. + */ +var RandomXY = function (vector, scale) +{ + if (scale === undefined) { scale = 1; } + + var r = Math.random() * 2 * Math.PI; + + vector.x = Math.cos(r) * scale; + vector.y = Math.sin(r) * scale; + + return vector; +}; + +module.exports = RandomXY; + + +/***/ }), +/* 537 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Work out what percentage `value` is of the range between `min` and `max`. + * If `max` isn't given then it will return the percentage of `value` to `min`. + * + * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. + * + * @function Phaser.Math.Percent + * @since 3.0.0 + * + * @param {number} value - The value to determine the percentage of. + * @param {number} min - The minimum value. + * @param {number} [max] - The maximum value. + * @param {number} [upperMax] - The mid-way point in the range that represents 100%. + * + * @return {number} A value between 0 and 1 representing the percentage. + */ +var Percent = function (value, min, max, upperMax) +{ + if (max === undefined) { max = min + 1; } + + var percentage = (value - min) / (max - min); + + if (percentage > 1) + { + if (upperMax !== undefined) + { + percentage = ((upperMax - value)) / (upperMax - max); + + if (percentage < 0) + { + percentage = 0; + } + } + else + { + percentage = 1; + } + } + else if (percentage < 0) + { + percentage = 0; + } + + return percentage; +}; + +module.exports = Percent; + + +/***/ }), +/* 538 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Subtract an `amount` from `value`, limiting the minimum result to `min`. + * + * @function Phaser.Math.MinSub + * @since 3.0.0 + * + * @param {number} value - The value to subtract from. + * @param {number} amount - The amount to subtract. + * @param {number} min - The minimum value to return. + * + * @return {number} The resulting value. + */ +var MinSub = function (value, amount, min) +{ + return Math.max(value - amount, min); +}; + +module.exports = MinSub; + + +/***/ }), +/* 539 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Add an `amount` to a `value`, limiting the maximum result to `max`. + * + * @function Phaser.Math.MaxAdd + * @since 3.0.0 + * + * @param {number} value - The value to add to. + * @param {number} amount - The amount to add. + * @param {number} max - The maximum value to return. + * + * @return {number} The resulting value. + */ +var MaxAdd = function (value, amount, max) +{ + return Math.min(value + amount, max); +}; + +module.exports = MaxAdd; + + +/***/ }), +/* 540 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check if a given value is an even number using a strict type check. + * + * @function Phaser.Math.IsEvenStrict + * @since 3.0.0 + * + * @param {number} value - The number to perform the check with. + * + * @return {boolean} Whether the number is even or not. + */ +var IsEvenStrict = function (value) +{ + // Use strict equality === for "is number" test + return (value === parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEvenStrict; + + +/***/ }), +/* 541 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check if a given value is an even number. + * + * @function Phaser.Math.IsEven + * @since 3.0.0 + * + * @param {number} value - The number to perform the check with. + * + * @return {boolean} Whether the number is even or not. + */ +var IsEven = function (value) +{ + // Use abstract equality == for "is number" test + + // eslint-disable-next-line eqeqeq + return (value == parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEven; + + +/***/ }), +/* 542 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the speed required to cover a distance in the time given. + * + * @function Phaser.Math.GetSpeed + * @since 3.0.0 + * + * @param {number} distance - The distance to travel in pixels. + * @param {integer} time - The time, in ms, to cover the distance in. + * + * @return {number} The amount you will need to increment the position by each step in order to cover the distance in the time given. + */ +var GetSpeed = function (distance, time) +{ + return (distance / time) / 1000; +}; + +module.exports = GetSpeed; + + +/***/ }), +/* 543 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Floors to some place comparative to a `base`, default is 10 for decimal place. + * + * The `place` is represented by the power applied to `base` to get that place. + * + * @function Phaser.Math.FloorTo + * @since 3.0.0 + * + * @param {number} value - The value to round. + * @param {integer} [place=0] - The place to round to. + * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. + * + * @return {number} The rounded value. + */ +var FloorTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.floor(value * p) / p; +}; + +module.exports = FloorTo; + + +/***/ }), +/* 544 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the positive difference of two given numbers. + * + * @function Phaser.Math.Difference + * @since 3.0.0 + * + * @param {number} a - The first number in the calculation. + * @param {number} b - The second number in the calculation. + * + * @return {number} The positive difference of the two given numbers. + */ +var Difference = function (a, b) +{ + return Math.abs(a - b); +}; + +module.exports = Difference; + + +/***/ }), +/* 545 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Ceils to some place comparative to a `base`, default is 10 for decimal place. + * + * The `place` is represented by the power applied to `base` to get that place. + * + * @function Phaser.Math.CeilTo + * @since 3.0.0 + * + * @param {number} value - The value to round. + * @param {number} [place=0] - The place to round to. + * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. + * + * @return {number} The rounded value. + */ +var CeilTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.ceil(value * p) / p; +}; + +module.exports = CeilTo; + + +/***/ }), +/* 546 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the mean average of the given values. + * + * @function Phaser.Math.Average + * @since 3.0.0 + * + * @param {number[]} values - The values to average. + * + * @return {number} The average value. + */ +var Average = function (values) +{ + var sum = 0; + + for (var i = 0; i < values.length; i++) + { + sum += (+values[i]); + } + + return sum / values.length; +}; + +module.exports = Average; + + +/***/ }), +/* 547 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Snap a value to nearest grid slice, using rounding. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10` whereas `14` will snap to `15`. + * + * @function Phaser.Math.Snap.To + * @since 3.0.0 + * + * @param {number} value - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. + * + * @return {number} The snapped value. + */ +var SnapTo = function (value, gap, start, divide) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.round(value / gap); + + return (divide) ? (start + value) / gap : start + value; +}; + +module.exports = SnapTo; + + +/***/ }), +/* 548 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -82689,29 +106469,48 @@ module.exports = PhysicsGroup; */ /** - * @namespace Phaser.Physics.Arcade.Components + * @namespace Phaser.Math.Snap */ module.exports = { - Acceleration: __webpack_require__(701), - Angular: __webpack_require__(700), - Bounce: __webpack_require__(699), - Debug: __webpack_require__(698), - Drag: __webpack_require__(697), - Enable: __webpack_require__(696), - Friction: __webpack_require__(695), - Gravity: __webpack_require__(694), - Immovable: __webpack_require__(693), - Mass: __webpack_require__(692), - Size: __webpack_require__(691), - Velocity: __webpack_require__(690) + Ceil: __webpack_require__(243), + Floor: __webpack_require__(142), + To: __webpack_require__(547) }; /***/ }), -/* 344 */ +/* 549 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Tests the value and returns `true` if it is a power of two. + * + * @function Phaser.Math.Pow2.IsValuePowerOfTwo + * @since 3.0.0 + * + * @param {number} value - The value to check if it's a power of two. + * + * @return {boolean} Returns `true` if `value` is a power of two, otherwise `false`. + */ +var IsValuePowerOfTwo = function (value) +{ + return (value > 0 && (value & (value - 1)) === 0); +}; + +module.exports = IsValuePowerOfTwo; + + +/***/ }), +/* 550 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -82720,91 +106519,21 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(343); -var Image = __webpack_require__(69); - /** - * @classdesc - * An Arcade Physics Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - * - * @class Image - * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Arcade.Components.Acceleration - * @extends Phaser.Physics.Arcade.Components.Angular - * @extends Phaser.Physics.Arcade.Components.Bounce - * @extends Phaser.Physics.Arcade.Components.Debug - * @extends Phaser.Physics.Arcade.Components.Drag - * @extends Phaser.Physics.Arcade.Components.Enable - * @extends Phaser.Physics.Arcade.Components.Friction - * @extends Phaser.Physics.Arcade.Components.Gravity - * @extends Phaser.Physics.Arcade.Components.Immovable - * @extends Phaser.Physics.Arcade.Components.Mass - * @extends Phaser.Physics.Arcade.Components.Size - * @extends Phaser.Physics.Arcade.Components.Velocity - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @namespace Phaser.Math.Pow2 */ -var ArcadeImage = new Class({ - Extends: Image, +module.exports = { - Mixins: [ - Components.Acceleration, - Components.Angular, - Components.Bounce, - Components.Debug, - Components.Drag, - Components.Enable, - Components.Friction, - Components.Gravity, - Components.Immovable, - Components.Mass, - Components.Size, - Components.Velocity - ], + GetNext: __webpack_require__(294), + IsSize: __webpack_require__(117), + IsValue: __webpack_require__(549) - initialize: - - function ArcadeImage (scene, x, y, texture, frame) - { - Image.call(this, scene, x, y, texture, frame); - } - -}); - -module.exports = ArcadeImage; +}; /***/ }), -/* 345 */ +/* 551 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -82813,344 +106542,31 @@ module.exports = ArcadeImage; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ArcadeImage = __webpack_require__(344); -var ArcadeSprite = __webpack_require__(142); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var PhysicsGroup = __webpack_require__(342); -var StaticPhysicsGroup = __webpack_require__(341); +var SmootherStep = __webpack_require__(182); /** - * @classdesc - * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. - * Objects that are created by this Factory are automatically added to the physics world. + * A Smoother Step interpolation method. * - * @class Factory - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 + * @function Phaser.Math.Interpolation.SmootherStep + * @since 3.9.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} * - * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics World instance. + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The interpolated value. */ -var Factory = new Class({ - - initialize: - - function Factory (world) - { - /** - * A reference to the Arcade Physics World. - * - * @name Phaser.Physics.Arcade.Factory#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * A reference to the Scene this Arcade Physics instance belongs to. - * - * @name Phaser.Physics.Arcade.Factory#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = world.scene; - - /** - * A reference to the Scene.Systems this Arcade Physics instance belongs to. - * - * @name Phaser.Physics.Arcade.Factory#sys - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.sys = world.scene.sys; - }, - - /** - * Create a new Arcade Physics Collider object. - * - * @method Phaser.Physics.Arcade.Factory#collider - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for collision. - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for collision. - * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. - * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. - * @param {*} [callbackContext] - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - collider: function (object1, object2, collideCallback, processCallback, callbackContext) - { - return this.world.addCollider(object1, object2, collideCallback, processCallback, callbackContext); - }, - - /** - * Create a new Arcade Physics Collider Overlap object. - * - * @method Phaser.Physics.Arcade.Factory#overlap - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for overlap. - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for overlap. - * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. - * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. - * @param {*} [callbackContext] - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - overlap: function (object1, object2, collideCallback, processCallback, callbackContext) - { - return this.world.addOverlap(object1, object2, collideCallback, processCallback, callbackContext); - }, - - /** - * Adds an Arcade Physics Body to the given Game Object. - * - * @method Phaser.Physics.Arcade.Factory#existing - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {boolean} [isStatic=false] - Set to true to create a Static body, otherwise it will create a Dynamic body. - * - * @return {Phaser.GameObjects.GameObject} The Game Object. - */ - existing: function (gameObject, isStatic) - { - var type = (isStatic) ? CONST.STATIC_BODY : CONST.DYNAMIC_BODY; - - this.world.enableBody(gameObject, type); - - return gameObject; - }, - - /** - * Creates a new Arcade Image object with a Static body. - * - * @method Phaser.Physics.Arcade.Factory#staticImage - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Image} The Image object that was created. - */ - staticImage: function (x, y, key, frame) - { - var image = new ArcadeImage(this.scene, x, y, key, frame); - - this.sys.displayList.add(image); - - this.world.enableBody(image, CONST.STATIC_BODY); - - return image; - }, - - /** - * Creates a new Arcade Image object with a Dynamic body. - * - * @method Phaser.Physics.Arcade.Factory#image - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Image} The Image object that was created. - */ - image: function (x, y, key, frame) - { - var image = new ArcadeImage(this.scene, x, y, key, frame); - - this.sys.displayList.add(image); - - this.world.enableBody(image, CONST.DYNAMIC_BODY); - - return image; - }, - - /** - * Creates a new Arcade Sprite object with a Static body. - * - * @method Phaser.Physics.Arcade.Factory#staticSprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. - */ - staticSprite: function (x, y, key, frame) - { - var sprite = new ArcadeSprite(this.scene, x, y, key, frame); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - this.world.enableBody(sprite, CONST.STATIC_BODY); - - return sprite; - }, - - /** - * Creates a new Arcade Sprite object with a Dynamic body. - * - * @method Phaser.Physics.Arcade.Factory#sprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. - */ - sprite: function (x, y, key, frame) - { - var sprite = new ArcadeSprite(this.scene, x, y, key, frame); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - this.world.enableBody(sprite, CONST.DYNAMIC_BODY); - - return sprite; - }, - - /** - * Creates a Static Physics Group object. - * All Game Objects created by this Group will automatically be static Arcade Physics objects. - * - * @method Phaser.Physics.Arcade.Factory#staticGroup - * @since 3.0.0 - * - * @param {object|object[]} [children] - [description] - * @param {GroupConfig} [config] - [description] - * - * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. - */ - staticGroup: function (children, config) - { - return this.sys.updateList.add(new StaticPhysicsGroup(this.world, this.world.scene, children, config)); - }, - - /** - * Creates a Physics Group object. - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * - * @method Phaser.Physics.Arcade.Factory#group - * @since 3.0.0 - * - * @param {object|object[]} [children] - [description] - * @param {PhysicsGroupConfig} [config] - [description] - * - * @return {Phaser.Physics.Arcade.Group} The Group object that was created. - */ - 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; - } - -}); - -module.exports = Factory; - - -/***/ }), -/* 346 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Rotate a given point by a given angle around the origin (0, 0), in an anti-clockwise direction. - * - * @function Phaser.Math.Rotate - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. - * @param {number} angle - The angle to be rotated by in an anticlockwise direction. - * - * @return {Phaser.Geom.Point} The given point, rotated by the given angle in an anticlockwise direction. - */ -var Rotate = function (point, angle) +var SmootherStepInterpolation = function (t, min, max) { - var x = point.x; - var y = point.y; - - point.x = (x * Math.cos(angle)) - (y * Math.sin(angle)); - point.y = (x * Math.sin(angle)) + (y * Math.cos(angle)); - - return point; + return min + (max - min) * SmootherStep(t, 0, 1); }; -module.exports = Rotate; +module.exports = SmootherStepInterpolation; /***/ }), -/* 347 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the factorial of a given number for integer values greater than 0. - * - * @function Phaser.Math.Factorial - * @since 3.0.0 - * - * @param {number} value - A positive integer to calculate the factorial of. - * - * @return {number} The factorial of the given number. - */ -var Factorial = function (value) -{ - if (value === 0) - { - return 1; - } - - var res = value; - - while (--value) - { - res *= value; - } - - return res; -}; - -module.exports = Factorial; - - -/***/ }), -/* 348 */ +/* 552 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -83159,168 +106575,734 @@ module.exports = Factorial; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Factorial = __webpack_require__(347); +var Linear = __webpack_require__(119); /** - * [description] + * A linear interpolation method. * - * @function Phaser.Math.Bernstein + * @function Phaser.Math.Interpolation.Linear * @since 3.0.0 + * @see {@link https://en.wikipedia.org/wiki/Linear_interpolation} * - * @param {number} n - [description] - * @param {number} i - [description] + * @param {number[]} v - The input array of values to interpolate between. + * @param {!number} k - The percentage of interpolation, between 0 and 1. * - * @return {number} [description] + * @return {!number} The interpolated value. */ -var Bernstein = function (n, i) +var LinearInterpolation = function (v, k) { - return Factorial(n) / Factorial(i) / Factorial(n - i); -}; + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); -module.exports = Bernstein; - - -/***/ }), -/* 349 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check whether `a` is fuzzily less than `b`. - * - * `a` is fuzzily less than `b` if it is less than `b + epsilon`. - * - * @function Phaser.Math.Fuzzy.LessThan - * @since 3.0.0 - * - * @param {number} a - The first value. - * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {boolean} `true` if `a` is fuzzily less than `b`, otherwise `false`. - */ -var LessThan = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return a < b + epsilon; -}; - -module.exports = LessThan; - - -/***/ }), -/* 350 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check whether `a` is fuzzily greater than `b`. - * - * `a` is fuzzily greater than `b` if it is more than `b - epsilon`. - * - * @function Phaser.Math.Fuzzy.GreaterThan - * @since 3.0.0 - * - * @param {number} a - The first value. - * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {boolean} `true` if `a` is fuzzily greater than than `b`, otherwise `false`. - */ -var GreaterThan = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return a > b - epsilon; -}; - -module.exports = GreaterThan; - - -/***/ }), -/* 351 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check whether the given values are fuzzily equal. - * - * Two numbers are fuzzily equal if their difference is less than `epsilon`. - * - * @function Phaser.Math.Fuzzy.Equal - * @since 3.0.0 - * - * @param {number} a - The first value. - * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {boolean} `true` if the values are fuzzily equal, otherwise `false`. - */ -var Equal = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.abs(a - b) < epsilon; -}; - -module.exports = Equal; - - -/***/ }), -/* 352 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Normalize an angle to the [0, 2pi] range. - * - * @function Phaser.Math.Angle.Normalize - * @since 3.0.0 - * - * @param {number} angle - The angle to normalize, in radians. - * - * @return {number} The normalized angle, in radians. - */ -var Normalize = function (angle) -{ - angle = angle % (2 * Math.PI); - - if (angle >= 0) + if (k < 0) { - return angle; + return Linear(v[0], v[1], f); + } + + if (k > 1) + { + return Linear(v[m], v[m - 1], m - f); + } + + return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); +}; + +module.exports = LinearInterpolation; + + +/***/ }), +/* 553 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CatmullRom = __webpack_require__(171); + +/** + * A Catmull-Rom interpolation method. + * + * @function Phaser.Math.Interpolation.CatmullRom + * @since 3.0.0 + * + * @param {number[]} v - The input array of values to interpolate between. + * @param {number} k - The percentage of interpolation, between 0 and 1. + * + * @return {number} The interpolated value. + */ +var CatmullRomInterpolation = function (v, k) +{ + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + + if (v[0] === v[m]) + { + if (k < 0) + { + i = Math.floor(f = m * (1 + k)); + } + + return CatmullRom(f - i, v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m]); } else { - return angle + 2 * Math.PI; + if (k < 0) + { + return v[0] - (CatmullRom(-f, v[0], v[0], v[1], v[1]) - v[0]); + } + + if (k > 1) + { + return v[m] - (CatmullRom(f - m, v[m], v[m], v[m - 1], v[m - 1]) - v[m]); + } + + return CatmullRom(f - i, v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2]); } }; -module.exports = Normalize; +module.exports = CatmullRomInterpolation; /***/ }), -/* 353 */ +/* 554 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bernstein = __webpack_require__(245); + +/** + * A bezier interpolation method. + * + * @function Phaser.Math.Interpolation.Bezier + * @since 3.0.0 + * + * @param {number[]} v - The input array of values to interpolate between. + * @param {number} k - The percentage of interpolation, between 0 and 1. + * + * @return {number} The interpolated value. + */ +var BezierInterpolation = function (v, k) +{ + var b = 0; + var n = v.length - 1; + + for (var i = 0; i <= n; i++) + { + b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * Bernstein(n, i); + } + + return b; +}; + +module.exports = BezierInterpolation; + + +/***/ }), +/* 555 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Interpolation + */ + +module.exports = { + + Bezier: __webpack_require__(554), + CatmullRom: __webpack_require__(553), + CubicBezier: __webpack_require__(354), + Linear: __webpack_require__(552), + QuadraticBezier: __webpack_require__(350), + SmoothStep: __webpack_require__(334), + SmootherStep: __webpack_require__(551) + +}; + + +/***/ }), +/* 556 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the fuzzy floor of the given value. + * + * @function Phaser.Math.Fuzzy.Floor + * @since 3.0.0 + * + * @param {number} value - The value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {number} The floor of the value. + */ +var Floor = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.floor(value + epsilon); +}; + +module.exports = Floor; + + +/***/ }), +/* 557 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the fuzzy ceiling of the given value. + * + * @function Phaser.Math.Fuzzy.Ceil + * @since 3.0.0 + * + * @param {number} value - The value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {number} The fuzzy ceiling of the value. + */ +var Ceil = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.ceil(value - epsilon); +}; + +module.exports = Ceil; + + +/***/ }), +/* 558 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Fuzzy + */ + +module.exports = { + + Ceil: __webpack_require__(557), + Equal: __webpack_require__(248), + Floor: __webpack_require__(556), + GreaterThan: __webpack_require__(247), + LessThan: __webpack_require__(246) + +}; + + +/***/ }), +/* 559 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing + */ + +module.exports = { + + Back: __webpack_require__(369), + Bounce: __webpack_require__(368), + Circular: __webpack_require__(367), + Cubic: __webpack_require__(366), + Elastic: __webpack_require__(365), + Expo: __webpack_require__(364), + Linear: __webpack_require__(363), + Quadratic: __webpack_require__(362), + Quartic: __webpack_require__(361), + Quintic: __webpack_require__(360), + Sine: __webpack_require__(359), + Stepped: __webpack_require__(358) + +}; + + +/***/ }), +/* 560 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the distance between two sets of coordinates (points) to the power of `pow`. + * + * @function Phaser.Math.Distance.Power + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * @param {number} pow - The exponent. + * + * @return {number} The distance between each point. + */ +var DistancePower = function (x1, y1, x2, y2, pow) +{ + if (pow === undefined) { pow = 2; } + + return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow)); +}; + +module.exports = DistancePower; + + +/***/ }), +/* 561 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Distance + */ + +module.exports = { + + Between: __webpack_require__(52), + Power: __webpack_require__(560), + Squared: __webpack_require__(249) + +}; + + +/***/ }), +/* 562 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Gets the shortest angle between `angle1` and `angle2`. + * + * Both angles must be in the range -180 to 180, which is the same clamped + * range that `sprite.angle` uses, so you can pass in two sprite angles to + * this method and get the shortest angle back between the two of them. + * + * The angle returned will be in the same range. If the returned angle is + * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's + * a clockwise rotation. + * + * TODO: Wrap the angles in this function? + * + * @function Phaser.Math.Angle.ShortestBetween + * @since 3.0.0 + * + * @param {number} angle1 - The first angle in the range -180 to 180. + * @param {number} angle2 - The second angle in the range -180 to 180. + * + * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. + */ +var ShortestBetween = function (angle1, angle2) +{ + var difference = angle2 - angle1; + + if (difference === 0) + { + return 0; + } + + var times = Math.floor((difference - (-180)) / 360); + + return difference - (times * 360); + +}; + +module.exports = ShortestBetween; + + +/***/ }), +/* 563 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); + +/** + * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. + * + * @function Phaser.Math.Angle.RotateTo + * @since 3.0.0 + * + * @param {number} currentAngle - The current angle, in radians. + * @param {number} targetAngle - The target angle to rotate to, in radians. + * @param {number} [lerp=0.05] - The lerp value to add to the current angle. + * + * @return {number} The adjusted angle. + */ +var RotateTo = function (currentAngle, targetAngle, lerp) +{ + if (lerp === undefined) { lerp = 0.05; } + + if (currentAngle === targetAngle) + { + return currentAngle; + } + + if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp)) + { + currentAngle = targetAngle; + } + else + { + if (Math.abs(targetAngle - currentAngle) > Math.PI) + { + if (targetAngle < currentAngle) + { + targetAngle += MATH_CONST.PI2; + } + else + { + targetAngle -= MATH_CONST.PI2; + } + } + + if (targetAngle > currentAngle) + { + currentAngle += lerp; + } + else if (targetAngle < currentAngle) + { + currentAngle -= lerp; + } + } + + return currentAngle; +}; + +module.exports = RotateTo; + + +/***/ }), +/* 564 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Normalize = __webpack_require__(250); + +/** + * Reverse the given angle. + * + * @function Phaser.Math.Angle.Reverse + * @since 3.0.0 + * + * @param {number} angle - The angle to reverse, in radians. + * + * @return {number} The reversed angle, in radians. + */ +var Reverse = function (angle) +{ + return Normalize(angle + Math.PI); +}; + +module.exports = Reverse; + + +/***/ }), +/* 565 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * The difference between this method and {@link Phaser.Math.Angle.BetweenPoints} is that this assumes the y coordinate + * travels down the screen. + * + * @function Phaser.Math.Angle.BetweenPointsY + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - The first point. + * @param {(Phaser.Geom.Point|object)} point2 - The second point. + * + * @return {number} The angle in radians. + */ +var BetweenPointsY = function (point1, point2) +{ + return Math.atan2(point2.x - point1.x, point2.y - point1.y); +}; + +module.exports = BetweenPointsY; + + +/***/ }), +/* 566 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * Calculates the angle of the vector from the first point to the second point. + * + * @function Phaser.Math.Angle.BetweenPoints + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - The first point. + * @param {(Phaser.Geom.Point|object)} point2 - The second point. + * + * @return {number} The angle in radians. + */ +var BetweenPoints = function (point1, point2) +{ + return Math.atan2(point2.y - point1.y, point2.x - point1.x); +}; + +module.exports = BetweenPoints; + + +/***/ }), +/* 567 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * + * The difference between this method and {@link Phaser.Math.Angle.Between} is that this assumes the y coordinate + * travels down the screen. + * + * @function Phaser.Math.Angle.BetweenY + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The angle in radians. + */ +var BetweenY = function (x1, y1, x2, y2) +{ + return Math.atan2(x2 - x1, y2 - y1); +}; + +module.exports = BetweenY; + + +/***/ }), +/* 568 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * + * @function Phaser.Math.Angle.Between + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The angle in radians. + */ +var Between = function (x1, y1, x2, y2) +{ + return Math.atan2(y2 - y1, x2 - x1); +}; + +module.exports = Between; + + +/***/ }), +/* 569 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Angle + */ + +module.exports = { + + Between: __webpack_require__(568), + BetweenY: __webpack_require__(567), + BetweenPoints: __webpack_require__(566), + BetweenPointsY: __webpack_require__(565), + Reverse: __webpack_require__(564), + RotateTo: __webpack_require__(563), + ShortestBetween: __webpack_require__(562), + Normalize: __webpack_require__(250), + Wrap: __webpack_require__(199), + WrapDegrees: __webpack_require__(198) + +}; + + +/***/ }), +/* 570 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(16); +var Extend = __webpack_require__(20); + +/** + * @namespace Phaser.Math + */ + +var PhaserMath = { + + // Collections of functions + Angle: __webpack_require__(569), + Distance: __webpack_require__(561), + Easing: __webpack_require__(559), + Fuzzy: __webpack_require__(558), + Interpolation: __webpack_require__(555), + Pow2: __webpack_require__(550), + Snap: __webpack_require__(548), + + // Expose the RNG Class + RandomDataGenerator: __webpack_require__(404), + + // Single functions + Average: __webpack_require__(546), + Bernstein: __webpack_require__(245), + Between: __webpack_require__(170), + CatmullRom: __webpack_require__(171), + CeilTo: __webpack_require__(545), + Clamp: __webpack_require__(23), + DegToRad: __webpack_require__(31), + Difference: __webpack_require__(544), + Factorial: __webpack_require__(244), + FloatBetween: __webpack_require__(299), + FloorTo: __webpack_require__(543), + FromPercent: __webpack_require__(93), + GetSpeed: __webpack_require__(542), + IsEven: __webpack_require__(541), + IsEvenStrict: __webpack_require__(540), + Linear: __webpack_require__(119), + MaxAdd: __webpack_require__(539), + MinSub: __webpack_require__(538), + Percent: __webpack_require__(537), + RadToDeg: __webpack_require__(172), + RandomXY: __webpack_require__(536), + RandomXYZ: __webpack_require__(535), + RandomXYZW: __webpack_require__(534), + Rotate: __webpack_require__(242), + RotateAround: __webpack_require__(396), + RotateAroundDistance: __webpack_require__(183), + RoundAwayFromZero: __webpack_require__(314), + RoundTo: __webpack_require__(533), + SinCosTableGenerator: __webpack_require__(532), + SmootherStep: __webpack_require__(182), + SmoothStep: __webpack_require__(181), + TransformXY: __webpack_require__(332), + Within: __webpack_require__(531), + Wrap: __webpack_require__(53), + + // Vector classes + Vector2: __webpack_require__(3), + Vector3: __webpack_require__(138), + Vector4: __webpack_require__(530), + Matrix3: __webpack_require__(241), + Matrix4: __webpack_require__(240), + Quaternion: __webpack_require__(239), + RotateVec3: __webpack_require__(529) + +}; + +// Merge in the consts + +PhaserMath = Extend(false, PhaserMath, CONST); + +// Export it + +module.exports = PhaserMath; + + +/***/ }), +/* 571 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -83331,12 +107313,12 @@ module.exports = Normalize; var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var CustomSet = __webpack_require__(70); -var EventEmitter = __webpack_require__(9); +var CustomSet = __webpack_require__(95); +var EventEmitter = __webpack_require__(11); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); -var XHRSettings = __webpack_require__(75); +var GetFastValue = __webpack_require__(2); +var PluginCache = __webpack_require__(15); +var XHRSettings = __webpack_require__(105); /** * @classdesc @@ -83366,7 +107348,7 @@ var XHRSettings = __webpack_require__(75); * * @class LoaderPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Loader + * @memberof Phaser.Loader * @constructor * @since 3.0.0 * @@ -83540,7 +107522,7 @@ var LoaderPlugin = new Class({ * Note that it is possible for this value to go down again if you add content to the current load queue during a load. * * @name Phaser.Loader.LoaderPlugin#progress - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -83625,7 +107607,7 @@ var LoaderPlugin = new Class({ * * @name Phaser.Loader.LoaderPlugin#state * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.state = CONST.LOADER_IDLE; @@ -84049,7 +108031,7 @@ var LoaderPlugin = new Class({ * a file having completed loading. * * @event Phaser.Loader.LoaderPlugin#progressEvent - * @param {float} progress - The current progress of the load. A value between 0 and 1. + * @param {number} progress - The current progress of the load. A value between 0 and 1. */ /** @@ -84152,6 +108134,12 @@ var LoaderPlugin = new Class({ */ nextFile: function (file, success) { + // Has the game been destroyed during load? If so, bail out now. + if (!this.inflight) + { + return; + } + this.inflight.delete(file); this.updateProgress(); @@ -84173,6 +108161,8 @@ var LoaderPlugin = new Class({ this._deleteQueue.set(file); this.emit('loaderror', file); + + this.fileProcessComplete(file); } }, @@ -84190,6 +108180,12 @@ var LoaderPlugin = new Class({ */ fileProcessComplete: function (file) { + // Has the game been destroyed during load? If so, bail out now. + if (!this.scene || !this.systems || !this.systems.game || this.systems.game.pendingDestroy) + { + return; + } + // This file has failed, so move it to the failed Set if (file.state === CONST.FILE_ERRORED) { @@ -84219,6 +108215,7 @@ var LoaderPlugin = new Class({ this.queue.delete(file); // Nothing left to do? + if (this.list.size === 0 && this.inflight.size === 0 && this.queue.size === 0) { this.loadComplete(); @@ -84409,7 +108406,7 @@ module.exports = LoaderPlugin; /***/ }), -/* 354 */ +/* 572 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -84420,7 +108417,1150 @@ module.exports = LoaderPlugin; var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(37); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); +var IsPlainObject = __webpack_require__(8); +var MultiFile = __webpack_require__(57); +var TextFile = __webpack_require__(251); + +/** + * @typedef {object} Phaser.Loader.FileTypes.UnityAtlasFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [atlasURL] - The absolute or relative URL to load the atlas data file from. + * @property {string} [atlasExtension='txt'] - The default file extension to use for the atlas data if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas data file. + */ + +/** + * @classdesc + * A single text file based Unity Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#unityAtlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#unityAtlas. + * + * @class UnityAtlasFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + */ +var UnityAtlasFile = new Class({ + + Extends: MultiFile, + + initialize: + + function UnityAtlasFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new TextFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'txt'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new TextFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'unityatlas', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'unityatlas', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.UnityAtlasFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.failed === 0 && !this.complete) + { + var image = this.files[0]; + var text = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addUnityAtlas(image.key, image.data, text.data, normalMap); + + text.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Adds a Unity YAML based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.UnityAtlasFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Unity Atlas File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#unityAtlas + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig|Phaser.Loader.FileTypes.UnityAtlasFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new UnityAtlasFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new UnityAtlasFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = UnityAtlasFile; + + +/***/ }), +/* 573 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); +var TILEMAP_FORMATS = __webpack_require__(29); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TilemapJSONFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Tiled Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. + * + * @class TilemapJSONFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TilemapJSONFile = new Class({ + + Extends: JSONFile, + + initialize: + + function TilemapJSONFile (loader, key, url, xhrSettings) + { + JSONFile.call(this, loader, key, url, xhrSettings); + + this.type = 'tilemapJSON'; + + this.cache = loader.cacheManager.tilemap; + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.TilemapJSONFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var tiledata = { format: TILEMAP_FORMATS.TILED_JSON, data: this.data }; + + this.cache.add(this.key, tiledata); + + this.pendingDestroy(tiledata); + } + +}); + +/** + * Adds a Tiled JSON Tilemap file, or array of map files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); + * } + * ``` + * + * The Tilemap data is created using the Tiled Map Editor and selecting JSON as the export format. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapTiledJSON({ + * key: 'level1', + * url: 'maps/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapJSONFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" + * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Tilemap JSON File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig|Phaser.Loader.FileTypes.TilemapJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapJSONFile(this, key[i])); + } + } + else + { + this.addFile(new TilemapJSONFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TilemapJSONFile; + + +/***/ }), +/* 574 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); +var TILEMAP_FORMATS = __webpack_require__(29); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TilemapImpactFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Impact.js Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. + * + * @class TilemapImpactFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TilemapImpactFile = new Class({ + + Extends: JSONFile, + + initialize: + + function TilemapImpactFile (loader, key, url, xhrSettings) + { + JSONFile.call(this, loader, key, url, xhrSettings); + + this.type = 'tilemapJSON'; + + this.cache = loader.cacheManager.tilemap; + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.TilemapImpactFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var tiledata = { format: TILEMAP_FORMATS.WELTMEISTER, data: this.data }; + + this.cache.add(this.key, tiledata); + + this.pendingDestroy(tiledata); + } + +}); + +/** + * Adds an Impact.js Tilemap file, or array of map files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.tilemapImpact('level1', 'maps/Level1.json'); + * } + * ``` + * + * Impact Tilemap data is created the Impact.js Map Editor called Weltmeister. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapImpact({ + * key: 'level1', + * url: 'maps/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapImpactFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapImpact('level1', 'maps/Level1.json'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" + * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Tilemap Impact File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#tilemapImpact + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig|Phaser.Loader.FileTypes.TilemapImpactFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('tilemapImpact', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapImpactFile(this, key[i])); + } + } + else + { + this.addFile(new TilemapImpactFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TilemapImpactFile; + + +/***/ }), +/* 575 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); +var TILEMAP_FORMATS = __webpack_require__(29); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TilemapCSVFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='csv'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Tilemap CSV File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. + * + * @class TilemapCSVFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TilemapCSVFile = new Class({ + + Extends: File, + + initialize: + + function TilemapCSVFile (loader, key, url, xhrSettings) + { + var extension = 'csv'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'tilemapCSV', + cache: loader.cacheManager.tilemap, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + + this.tilemapFormat = TILEMAP_FORMATS.CSV; + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.TilemapCSVFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.TilemapCSVFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var tiledata = { format: this.tilemapFormat, data: this.data }; + + this.cache.add(this.key, tiledata); + + this.pendingDestroy(tiledata); + } + +}); + +/** + * Adds a CSV Tilemap file, or array of CSV files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.tilemapCSV('level1', 'maps/Level1.csv'); + * } + * ``` + * + * Tilemap CSV data can be created in a text editor, or a 3rd party app that exports as CSV. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapCSV({ + * key: 'level1', + * url: 'maps/Level1.csv' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapCSVFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapCSV('level1', 'maps/Level1.csv'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" + * and no URL is given then the Loader will set the URL to be "level.csv". It will always add `.csv` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Tilemap CSV File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#tilemapCSV + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig|Phaser.Loader.FileTypes.TilemapCSVFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapCSVFile(this, key[i])); + } + } + else + { + this.addFile(new TilemapCSVFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TilemapCSVFile; + + +/***/ }), +/* 576 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.SVGSizeConfig + * + * @property {integer} [width] - An optional width. The SVG will be resized to this size before being rendered to a texture. + * @property {integer} [height] - An optional height. The SVG will be resized to this size before being rendered to a texture. + * @property {number} [scale] - An optional scale. If given it overrides the width / height properties. The SVG is scaled by the scale factor before being rendered to a texture. + */ + +/** + * @typedef {object} Phaser.Loader.FileTypes.SVGFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='svg'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. + */ + +/** + * @classdesc + * A single SVG File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. + * + * @class SVGFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var SVGFile = new Class({ + + Extends: File, + + initialize: + + function SVGFile (loader, key, url, svgConfig, xhrSettings) + { + var extension = 'svg'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + svgConfig = GetFastValue(config, 'svgConfig', {}); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'svg', + cache: loader.textureManager, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + width: GetFastValue(svgConfig, 'width'), + height: GetFastValue(svgConfig, 'height'), + scale: GetFastValue(svgConfig, 'scale') + } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.SVGFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var text = this.xhrLoader.responseText; + var svg = [ text ]; + var width = this.config.width; + var height = this.config.height; + var scale = this.config.scale; + + resize: if (width && height || scale) + { + var xml = null; + var parser = new DOMParser(); + xml = parser.parseFromString(text, 'text/xml'); + var svgXML = xml.getElementsByTagName('svg')[0]; + + var hasViewBox = svgXML.hasAttribute('viewBox'); + var svgWidth = parseFloat(svgXML.getAttribute('width')); + var svgHeight = parseFloat(svgXML.getAttribute('height')); + + if (!hasViewBox && svgWidth && svgHeight) + { + // If there's no viewBox attribute, set one + svgXML.setAttribute('viewBox', '0 0 ' + svgWidth + ' ' + svgHeight); + } + else if (hasViewBox && !svgWidth && !svgHeight) + { + // Get the w/h from the viewbox + var viewBox = svgXML.getAttribute('viewBox').split(/\s+|,/); + + svgWidth = viewBox[2]; + svgHeight = viewBox[3]; + } + + if (scale) + { + if (svgWidth && svgHeight) + { + width = svgWidth * scale; + height = svgHeight * scale; + } + else + { + break resize; + } + } + + svgXML.setAttribute('width', width.toString() + 'px'); + svgXML.setAttribute('height', height.toString() + 'px'); + + svg = [ (new XMLSerializer()).serializeToString(svgXML) ]; + } + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + this.onProcessError(); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var _this = this; + var retry = false; + + this.data.onload = function () + { + if (!retry) + { + File.revokeObjectURL(_this.data); + } + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + // Safari 8 re-try + if (!retry) + { + retry = true; + + File.revokeObjectURL(_this.data); + + _this.data.src = 'data:image/svg+xml,' + encodeURIComponent(svg.join('')); + } + else + { + _this.onProcessError(); + } + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.SVGFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + +}); + +/** + * Adds an SVG File, or array of SVG Files, to the current load queue. When the files are loaded they + * will be rendered to bitmap textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SVGFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.svg('morty', 'images/Morty.svg'); + * // and later in your game ... + * this.add.image(x, y, 'morty'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can optionally pass an SVG Resize Configuration object when you load an SVG file. By default the SVG will be rendered to a texture + * at the same size defined in the SVG file attributes. However, this isn't always desirable. You may wish to resize the SVG (either down + * or up) to improve texture clarity, or reduce texture memory consumption. You can either specify an exact width and height to resize + * the SVG to: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { width: 300, height: 600 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * width: 300, + * height: 600 + * } + * }); + * ``` + * + * Alternatively, you can just provide a scale factor instead: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { scale: 2.5 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * scale: 2.5 + * } + * }); + * ``` + * + * If scale, width and height values are all given, the scale has priority and the width and height values are ignored. + * + * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#svg + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig|Phaser.Loader.FileTypes.SVGFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('svg', function (key, url, svgConfig, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new SVGFile(this, key[i])); + } + } + else + { + this.addFile(new SVGFile(this, key, url, svgConfig, xhrSettings)); + } + + return this; +}); + +module.exports = SVGFile; + + + +/***/ }), +/* 577 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(58); /** * @typedef {object} Phaser.Loader.FileTypes.SpriteSheetFileConfig @@ -84443,7 +109583,7 @@ var ImageFile = __webpack_require__(37); * * @class SpriteSheetFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -84611,7 +109751,7 @@ module.exports = SpriteSheetFile; /***/ }), -/* 355 */ +/* 578 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -84622,9 +109762,9 @@ module.exports = SpriteSheetFile; var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var File = __webpack_require__(19); +var File = __webpack_require__(21); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); var IsPlainObject = __webpack_require__(8); /** @@ -84646,7 +109786,7 @@ var IsPlainObject = __webpack_require__(8); * * @class ScriptFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -84791,7 +109931,7 @@ module.exports = ScriptFile; /***/ }), -/* 356 */ +/* 579 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -84802,9 +109942,226 @@ module.exports = ScriptFile; var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var File = __webpack_require__(19); +var File = __webpack_require__(21); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.ScenePluginFileConfig + * + * @property {string} key - The key of the file. Must be unique within the Loader. + * @property {(string|function)} [url] - The absolute or relative URL to load the file from. Or, a Scene Plugin. + * @property {string} [extension='js'] - The default file extension to use if no url is provided. + * @property {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. + * @property {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Scene Plugin Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#scenePlugin method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scenePlugin. + * + * @class ScenePluginFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.8.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. + * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var ScenePluginFile = new Class({ + + Extends: File, + + initialize: + + function ScenePluginFile (loader, key, url, systemKey, sceneKey, xhrSettings) + { + var extension = 'js'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + systemKey = GetFastValue(config, 'systemKey'); + sceneKey = GetFastValue(config, 'sceneKey'); + } + + var fileConfig = { + type: 'scenePlugin', + cache: false, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + systemKey: systemKey, + sceneKey: sceneKey + } + }; + + File.call(this, loader, fileConfig); + + // If the url variable refers to a class, add the plugin directly + if (typeof url === 'function') + { + this.data = url; + + this.state = CONST.FILE_POPULATED; + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.ScenePluginFile#onProcess + * @since 3.8.0 + */ + onProcess: function () + { + var pluginManager = this.loader.systems.plugins; + var config = this.config; + + var key = this.key; + var systemKey = GetFastValue(config, 'systemKey', key); + var sceneKey = GetFastValue(config, 'sceneKey', key); + + if (this.state === CONST.FILE_POPULATED) + { + pluginManager.installScenePlugin(systemKey, this.data, sceneKey, this.loader.scene); + } + else + { + // Plugin added via a js file + this.state = CONST.FILE_PROCESSING; + + this.data = document.createElement('script'); + this.data.language = 'javascript'; + this.data.type = 'text/javascript'; + this.data.defer = false; + this.data.text = this.xhrLoader.responseText; + + document.head.appendChild(this.data); + + pluginManager.installScenePlugin(systemKey, window[this.key], sceneKey, this.loader.scene); + } + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Scene Plugin Script file, or array of plugin files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.scenePlugin('ModPlayer', 'plugins/ModPlayer.js', 'modPlayer', 'mods'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String and not already in-use by another file in the Loader. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.scenePlugin({ + * key: 'modplayer', + * url: 'plugins/ModPlayer.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ScenePluginFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a script element + * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to + * false and then the resulting element will be appended to `document.head`. Any code then in the + * script will be executed. It will then be passed to the Phaser PluginCache.register method. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Script File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#scenePlugin + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.8.0 + * + * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig|Phaser.Loader.FileTypes.ScenePluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {(string|function)} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, set to a plugin function. + * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. + * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('scenePlugin', function (key, url, systemKey, sceneKey, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ScenePluginFile(this, key[i])); + } + } + else + { + this.addFile(new ScenePluginFile(this, key, url, systemKey, sceneKey, xhrSettings)); + } + + return this; +}); + +module.exports = ScenePluginFile; + + +/***/ }), +/* 580 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); var IsPlainObject = __webpack_require__(8); /** @@ -84828,7 +110185,7 @@ var IsPlainObject = __webpack_require__(8); * * @class PluginFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -85007,7 +110364,235 @@ module.exports = PluginFile; /***/ }), -/* 357 */ +/* 581 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); + +/** + * @typedef {object} Phaser.Loader.FileTypes.PackFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the JSON Cache. + * @property {string|any} [url] - The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly processed. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {string} [dataKey] - If specified instead of the whole JSON file being parsed, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single JSON Pack File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#pack method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#pack. + * + * @class PackFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + */ +var PackFile = new Class({ + + Extends: JSONFile, + + initialize: + + // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object + // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing + + function PackFile (loader, key, url, xhrSettings, dataKey) + { + JSONFile.call(this, loader, key, url, xhrSettings, dataKey); + + this.type = 'packfile'; + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.PackFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + if (this.state !== CONST.FILE_POPULATED) + { + this.state = CONST.FILE_PROCESSING; + + this.data = JSON.parse(this.xhrLoader.responseText); + } + + // Let's pass the pack file data over to the Loader ... + this.loader.addPack(this.data, this.config); + + this.onProcessComplete(); + } + +}); + +/** + * Adds a JSON File Pack, or array of packs, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.pack('level1', 'data/Level1Files.json'); + * } + * ``` + * + * A File Pack is a JSON file (or object) that contains details about other files that should be added into the Loader. + * Here is a small example: + * + * ```json + * { + * "test1": { + * "files": [ + * { + * "type": "image", + * "key": "taikodrummaster", + * "url": "assets/pics/taikodrummaster.jpg" + * }, + * { + * "type": "image", + * "key": "sukasuka-chtholly", + * "url": "assets/pics/sukasuka-chtholly.png" + * } + * ] + * }, + * "meta": { + * "generated": "1401380327373", + * "app": "Phaser 3 Asset Packer", + * "url": "https://phaser.io", + * "version": "1.0", + * "copyright": "Photon Storm Ltd. 2018" + * } + * } + * ``` + * + * The pack can be split into sections. In the example above you'll see a section called `test1. You can tell + * the `load.pack` method to parse only a particular section of a pack. The pack is stored in the JSON Cache, + * so you can pass it to the Loader to process additional sections as needed in your game, or you can just load + * them all at once without specifying anything. + * + * The pack file can contain an entry for any type of file that Phaser can load. The object structures exactly + * match that of the file type configs, and all properties available within the file type configs can be used + * in the pack file too. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.pack({ + * key: 'level1', + * url: 'data/Level1Files.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.PackFileConfig` for more details. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the Pack File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#pack + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.PackFileConfig|Phaser.Loader.FileTypes.PackFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('pack', function (key, url, packKey, xhrSettings) +{ + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.addFile(new PackFile(this, key[i])); + } + } + else + { + this.addFile(new PackFile(this, key, url, xhrSettings, packKey)); + } + + return this; +}); + +module.exports = PackFile; + + +/***/ }), +/* 582 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -85018,11 +110603,11 @@ module.exports = PluginFile; var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); var IsPlainObject = __webpack_require__(8); -var JSONFile = __webpack_require__(28); -var MultiFile = __webpack_require__(36); +var JSONFile = __webpack_require__(51); +var MultiFile = __webpack_require__(57); /** * @typedef {object} Phaser.Loader.FileTypes.MultiAtlasFileConfig @@ -85046,7 +110631,7 @@ var MultiFile = __webpack_require__(36); * * @class MultiAtlasFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.7.0 * @@ -85343,7 +110928,645 @@ module.exports = MultiAtlasFile; /***/ }), -/* 358 */ +/* 583 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.HTMLTextureFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='html'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {integer} [width=512] - The width of the texture the HTML will be rendered to. + * @property {integer} [height=512] - The height of the texture the HTML will be rendered to. + */ + +/** + * @classdesc + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#htmlTexture method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#htmlTexture. + * + * @class HTMLTextureFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.12.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.HTMLTextureFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {integer} [width] - The width of the texture the HTML will be rendered to. + * @param {integer} [height] - The height of the texture the HTML will be rendered to. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var HTMLTextureFile = new Class({ + + Extends: File, + + initialize: + + function HTMLTextureFile (loader, key, url, width, height, xhrSettings) + { + if (width === undefined) { width = 512; } + if (height === undefined) { height = 512; } + + var extension = 'html'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + width = GetFastValue(config, 'width', width); + height = GetFastValue(config, 'height', height); + } + + var fileConfig = { + type: 'html', + cache: loader.textureManager, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + width: width, + height: height + } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.HTMLTextureFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var w = this.config.width; + var h = this.config.height; + + var data = []; + + data.push(''); + data.push(''); + data.push(''); + data.push(this.xhrLoader.responseText); + data.push(''); + data.push(''); + data.push(''); + + var svg = [ data.join('\n') ]; + var _this = this; + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + _this.state = CONST.FILE_ERRORED; + + _this.onProcessComplete(); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessError(); + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.HTMLTextureFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + +}); + +/** + * Adds an HTML File, or array of HTML Files, to the current load queue. When the files are loaded they + * will be rendered to textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.htmlTexture({ + * key: 'instructions', + * url: 'content/intro.html', + * width: 256, + * height: 512 + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLTextureFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); + * // and later in your game ... + * this.add.image(x, y, 'instructions'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * The width and height are the size of the texture to which the HTML will be rendered. It's not possible to determine these + * automatically, so you will need to provide them, either as arguments or in the file config object. + * When the HTML file has loaded a new SVG element is created with a size and viewbox set to the width and height given. + * The SVG file has a body tag added to it, with the HTML file contents included. It then calls `window.Blob` on the SVG, + * and if successful is added to the Texture Manager, otherwise it fails processing. The overall quality of the rendered + * HTML depends on your browser, and some of them may not even support the svg / blob process used. Be aware that there are + * limitations on what HTML can be inside an SVG. You can find out more details in this + * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). + * + * Note: The ability to load this type of file will only be available if the HTMLTextureFile File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#htmlTexture + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.12.0 + * + * @param {(string|Phaser.Loader.FileTypes.HTMLTextureFileConfig|Phaser.Loader.FileTypes.HTMLTextureFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {integer} [width=512] - The width of the texture the HTML will be rendered to. + * @param {integer} [height=512] - The height of the texture the HTML will be rendered to. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('htmlTexture', function (key, url, width, height, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new HTMLTextureFile(this, key[i])); + } + } + else + { + this.addFile(new HTMLTextureFile(this, key, url, width, height, xhrSettings)); + } + + return this; +}); + +module.exports = HTMLTextureFile; + + +/***/ }), +/* 584 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.HTMLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='html'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. + * + * @class HTMLFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.12.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var HTMLFile = new Class({ + + Extends: File, + + initialize: + + function HTMLFile (loader, key, url, xhrSettings) + { + var extension = 'html'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'text', + cache: loader.cacheManager.html, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.HTMLFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds an HTML file, or array of HTML files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.html('story', 'files/LoginForm.html'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global HTML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the HTML Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the HTML Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.html({ + * key: 'login', + * url: 'files/LoginForm.html' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.html('login', 'files/LoginForm.html'); + * // and later in your game ... + * var data = this.cache.html.get('login'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the html from the HTML Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the HTML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#html + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.12.0 + * + * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig|Phaser.Loader.FileTypes.HTMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('html', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new HTMLFile(this, key[i])); + } + } + else + { + this.addFile(new HTMLFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = HTMLFile; + + +/***/ }), +/* 585 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.GLSLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='glsl'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single GLSL File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl. + * + * @class GLSLFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var GLSLFile = new Class({ + + Extends: File, + + initialize: + + function GLSLFile (loader, key, url, xhrSettings) + { + var extension = 'glsl'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'glsl', + cache: loader.cacheManager.shader, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.GLSLFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a GLSL file, or array of GLSL files, to the current load queue. + * In Phaser 3 GLSL files are just plain Text files at the current moment in time. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.glsl('plasma', 'shaders/Plasma.glsl'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Shader Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Shader Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Shader Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.glsl({ + * key: 'plasma', + * url: 'shaders/Plasma.glsl' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.GLSLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.glsl('plasma', 'shaders/Plasma.glsl'); + * // and later in your game ... + * var data = this.cache.shader.get('plasma'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `FX.` and the key was `Plasma` the final key will be `FX.Plasma` and + * this is what you would use to retrieve the text from the Shader Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "plasma" + * and no URL is given then the Loader will set the URL to be "plasma.glsl". It will always add `.glsl` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the GLSL File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#glsl + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.GLSLFileConfig|Phaser.Loader.FileTypes.GLSLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.glsl`, i.e. if `key` was "alien" then the URL will be "alien.glsl". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('glsl', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new GLSLFile(this, key[i])); + } + } + else + { + this.addFile(new GLSLFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = GLSLFile; + + +/***/ }), +/* 586 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -85352,13 +111575,461 @@ module.exports = MultiAtlasFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AudioFile = __webpack_require__(168); var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); var IsPlainObject = __webpack_require__(8); -var JSONFile = __webpack_require__(28); -var MultiFile = __webpack_require__(36); +var MultiFile = __webpack_require__(57); +var ParseXMLBitmapFont = __webpack_require__(310); +var XMLFile = __webpack_require__(139); + +/** + * @typedef {object} Phaser.Loader.FileTypes.BitmapFontFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [fontDataURL] - The absolute or relative URL to load the font data xml file from. + * @property {string} [fontDataExtension='xml'] - The default file extension to use for the font data xml if no url is provided. + * @property {XHRSettingsObject} [fontDataXhrSettings] - Extra XHR Settings specifically for the font data xml file. + */ + +/** + * @classdesc + * A single Bitmap Font based File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. + * + * @class BitmapFontFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + */ +var BitmapFontFile = new Class({ + + Extends: MultiFile, + + initialize: + + function BitmapFontFile (loader, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new XMLFile(loader, { + key: key, + url: GetFastValue(config, 'fontDataURL'), + extension: GetFastValue(config, 'fontDataExtension', 'xml'), + xhrSettings: GetFastValue(config, 'fontDataXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new XMLFile(loader, key, fontDataURL, fontDataXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'bitmapfont', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'bitmapfont', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.BitmapFontFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var xml = this.files[1]; + + image.addToCache(); + xml.addToCache(); + + this.loader.cacheManager.bitmapFont.add(image.key, { data: ParseXMLBitmapFont(xml.data), texture: image.key, frame: null }); + + this.complete = true; + } + } + +}); + +/** + * Adds an XML based Bitmap Font, or array of fonts, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + + * ```javascript + * function preload () + * { + * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the font data to be provided in an XML file format. + * These files are created by software such as the [Angelcode Bitmap Font Generator](http://www.angelcode.com/products/bmfont/), + * [Littera](http://kvazars.com/littera/) or [Glyph Designer](https://71squared.com/glyphdesigner) + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.BitmapFontFileConfig` for more details. + * + * Once the atlas has finished loading you can use key of it when creating a Bitmap Text Game Object: + * + * ```javascript + * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * // and later in your game ... + * this.add.bitmapText(x, y, 'goldenFont', 'Hello World'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use when creating a Bitmap Text object. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.bitmapFont('goldenFont', [ 'images/GoldFont.png', 'images/GoldFont-n.png' ], 'images/GoldFont.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * normalMap: 'images/GoldFont-n.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Bitmap Font File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#bitmapFont + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig|Phaser.Loader.FileTypes.BitmapFontFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('bitmapFont', function (key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new BitmapFontFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new BitmapFontFile(this, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = BitmapFontFile; + + +/***/ }), +/* 587 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.BinaryFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Binary Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='bin'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ + +/** + * @classdesc + * A single Binary File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. + * + * @class BinaryFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ +var BinaryFile = new Class({ + + Extends: File, + + initialize: + + function BinaryFile (loader, key, url, xhrSettings, dataType) + { + var extension = 'bin'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + dataType = GetFastValue(config, 'dataType', dataType); + } + + var fileConfig = { + type: 'binary', + cache: loader.cacheManager.binary, + extension: extension, + responseType: 'arraybuffer', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { dataType: dataType } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.BinaryFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var ctor = this.config.dataType; + + this.data = (ctor) ? new ctor(this.xhrLoader.response) : this.xhrLoader.response; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Binary file, or array of Binary files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.binary('doom', 'files/Doom.wad'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Binary Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Binary Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Binary Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.binary({ + * key: 'doom', + * url: 'files/Doom.wad', + * dataType: Uint8Array + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.BinaryFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.binary('doom', 'files/Doom.wad'); + * // and later in your game ... + * var data = this.cache.binary.get('doom'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Data` the final key will be `LEVEL1.Data` and + * this is what you would use to retrieve the text from the Binary Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "doom" + * and no URL is given then the Loader will set the URL to be "doom.bin". It will always add `.bin` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Binary File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#binary + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig|Phaser.Loader.FileTypes.BinaryFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('binary', function (key, url, dataType, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new BinaryFile(this, key[i])); + } + } + else + { + this.addFile(new BinaryFile(this, key, url, xhrSettings, dataType)); + } + + return this; +}); + +module.exports = BinaryFile; + + +/***/ }), +/* 588 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AudioFile = __webpack_require__(253); +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); +var JSONFile = __webpack_require__(51); +var MultiFile = __webpack_require__(57); /** * @typedef {object} Phaser.Loader.FileTypes.AudioSpriteFileConfig @@ -85366,7 +112037,7 @@ var MultiFile = __webpack_require__(36); * @property {string} key - The key of the file. Must be unique within both the Loader and the Audio Cache. * @property {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. * @property {XHRSettingsObject} [jsonXhrSettings] - Extra XHR Settings specifically for the json file. - * @property {string} [audioURL] - The absolute or relative URL to load the audio file from. + * @property {{(string|string[])}} [audioURL] - The absolute or relative URL to load the audio file from. * @property {any} [audioConfig] - The audio configuration options. * @property {XHRSettingsObject} [audioXhrSettings] - Extra XHR Settings specifically for the audio file. */ @@ -85381,14 +112052,14 @@ var MultiFile = __webpack_require__(36); * * @class AudioSpriteFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.7.0 * * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig)} key - The key to use for this file, or a file configuration object. * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param {string} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {{(string|string[])}} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. * @param {any} [audioConfig] - The audio configuration options. * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. @@ -85592,7 +112263,7 @@ var AudioSpriteFile = new Class({ * * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig|Phaser.Loader.FileTypes.AudioSpriteFileConfig[])} key - The key to use for this file, or a file configuration object, or an array of objects. * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param {string} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {(string|string[])} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. * @param {any} [audioConfig] - The audio configuration options. * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. @@ -85644,7 +112315,7 @@ FileTypesManager.register('audioSprite', function (key, jsonURL, audioURL, audio /***/ }), -/* 359 */ +/* 589 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -85655,11 +112326,266 @@ FileTypesManager.register('audioSprite', function (key, jsonURL, audioURL, audio var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); var IsPlainObject = __webpack_require__(8); -var JSONFile = __webpack_require__(28); -var MultiFile = __webpack_require__(36); +var MultiFile = __webpack_require__(57); +var XMLFile = __webpack_require__(139); + +/** + * @typedef {object} Phaser.Loader.FileTypes.AtlasXMLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [atlasURL] - The absolute or relative URL to load the atlas xml file from. + * @property {string} [atlasExtension='xml'] - The default file extension to use for the atlas xml if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas xml file. + */ + +/** + * @classdesc + * A single XML based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. + * + * @class AtlasXMLFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + */ +var AtlasXMLFile = new Class({ + + Extends: MultiFile, + + initialize: + + function AtlasXMLFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new XMLFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'xml'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new XMLFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'atlasxml', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'atlasxml', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.AtlasXMLFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var xml = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addAtlasXML(image.key, image.data, xml.data, normalMap); + + xml.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Adds an XML based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in an XML file format. + * These files are created by software such as Shoebox and Adobe Flash / Animate. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AtlasXMLFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.atlasXML('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Atlas XML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#atlasXML + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig|Phaser.Loader.FileTypes.AtlasXMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('atlasXML', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new AtlasXMLFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new AtlasXMLFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = AtlasXMLFile; + + +/***/ }), +/* 590 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); +var IsPlainObject = __webpack_require__(8); +var JSONFile = __webpack_require__(51); +var MultiFile = __webpack_require__(57); /** * @typedef {object} Phaser.Loader.FileTypes.AtlasJSONFileConfig @@ -85686,7 +112612,7 @@ var MultiFile = __webpack_require__(36); * * @class AtlasJSONFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -85906,7 +112832,7 @@ module.exports = AtlasJSONFile; /***/ }), -/* 360 */ +/* 591 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -85917,7 +112843,7 @@ module.exports = AtlasJSONFile; var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(28); +var JSONFile = __webpack_require__(51); /** * @classdesc @@ -85929,7 +112855,7 @@ var JSONFile = __webpack_require__(28); * * @class AnimationJSONFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -86108,7 +113034,91 @@ module.exports = AnimationJSONFile; /***/ }), -/* 361 */ +/* 592 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Loader.FileTypes + */ + +module.exports = { + + AnimationJSONFile: __webpack_require__(591), + AtlasJSONFile: __webpack_require__(590), + AtlasXMLFile: __webpack_require__(589), + AudioFile: __webpack_require__(253), + AudioSpriteFile: __webpack_require__(588), + BinaryFile: __webpack_require__(587), + BitmapFontFile: __webpack_require__(586), + GLSLFile: __webpack_require__(585), + HTML5AudioFile: __webpack_require__(252), + HTMLFile: __webpack_require__(584), + HTMLTextureFile: __webpack_require__(583), + ImageFile: __webpack_require__(58), + JSONFile: __webpack_require__(51), + MultiAtlasFile: __webpack_require__(582), + PackFile: __webpack_require__(581), + PluginFile: __webpack_require__(580), + ScenePluginFile: __webpack_require__(579), + ScriptFile: __webpack_require__(578), + SpriteSheetFile: __webpack_require__(577), + SVGFile: __webpack_require__(576), + TextFile: __webpack_require__(251), + TilemapCSVFile: __webpack_require__(575), + TilemapImpactFile: __webpack_require__(574), + TilemapJSONFile: __webpack_require__(573), + UnityAtlasFile: __webpack_require__(572), + XMLFile: __webpack_require__(139) + +}; + + +/***/ }), +/* 593 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(18); +var Extend = __webpack_require__(20); + +/** + * @namespace Phaser.Loader + */ + +var Loader = { + + FileTypes: __webpack_require__(592), + + File: __webpack_require__(21), + FileTypesManager: __webpack_require__(7), + GetURL: __webpack_require__(141), + LoaderPlugin: __webpack_require__(571), + MergeXHRSettings: __webpack_require__(140), + MultiFile: __webpack_require__(57), + XHRLoader: __webpack_require__(254), + XHRSettings: __webpack_require__(105) + +}; + +// Merge in the consts +Loader = Extend(false, Loader, CONST); + +module.exports = Loader; + + +/***/ }), +/* 594 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -86124,14 +113134,14 @@ module.exports = AnimationJSONFile; /* eslint-disable */ module.exports = { - TouchManager: __webpack_require__(197) + TouchManager: __webpack_require__(333) }; /* eslint-enable */ /***/ }), -/* 362 */ +/* 595 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -86147,14 +113157,14 @@ module.exports = { /* eslint-disable */ module.exports = { - MouseManager: __webpack_require__(199) + MouseManager: __webpack_require__(336) }; /* eslint-enable */ /***/ }), -/* 363 */ +/* 596 */ /***/ (function(module, exports) { /** @@ -86186,7 +113196,7 @@ module.exports = UpDuration; /***/ }), -/* 364 */ +/* 597 */ /***/ (function(module, exports) { /** @@ -86218,7 +113228,7 @@ module.exports = DownDuration; /***/ }), -/* 365 */ +/* 598 */ /***/ (function(module, exports) { /** @@ -86260,7 +113270,7 @@ module.exports = JustUp; /***/ }), -/* 366 */ +/* 599 */ /***/ (function(module, exports) { /** @@ -86302,7 +113312,7 @@ module.exports = JustDown; /***/ }), -/* 367 */ +/* 600 */ /***/ (function(module, exports) { /** @@ -86345,6 +113355,7 @@ var ProcessKeyUp = function (key, event) key._justDown = false; key._justUp = true; + key._tick = -1; return key; }; @@ -86353,7 +113364,7 @@ module.exports = ProcessKeyUp; /***/ }), -/* 368 */ +/* 601 */ /***/ (function(module, exports) { /** @@ -86412,7 +113423,7 @@ module.exports = ProcessKeyDown; /***/ }), -/* 369 */ +/* 602 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -86421,7 +113432,7 @@ module.exports = ProcessKeyDown; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var KeyCodes = __webpack_require__(109); +var KeyCodes = __webpack_require__(143); var KeyMap = {}; @@ -86434,7 +113445,7 @@ module.exports = KeyMap; /***/ }), -/* 370 */ +/* 603 */ /***/ (function(module, exports) { /** @@ -86469,7 +113480,7 @@ module.exports = ResetKeyCombo; /***/ }), -/* 371 */ +/* 604 */ /***/ (function(module, exports) { /** @@ -86511,7 +113522,7 @@ module.exports = AdvanceKeyCombo; /***/ }), -/* 372 */ +/* 605 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -86520,7 +113531,7 @@ module.exports = AdvanceKeyCombo; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AdvanceKeyCombo = __webpack_require__(371); +var AdvanceKeyCombo = __webpack_require__(604); /** * Used internally by the KeyCombo class. @@ -86592,7 +113603,7 @@ module.exports = ProcessKeyCombo; /***/ }), -/* 373 */ +/* 606 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -86602,15 +113613,16 @@ module.exports = ProcessKeyCombo; */ var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); +var EventEmitter = __webpack_require__(11); var GetValue = __webpack_require__(4); -var InputPluginCache = __webpack_require__(76); -var Key = __webpack_require__(171); -var KeyCodes = __webpack_require__(109); -var KeyCombo = __webpack_require__(170); -var KeyMap = __webpack_require__(369); -var ProcessKeyDown = __webpack_require__(368); -var ProcessKeyUp = __webpack_require__(367); +var InputPluginCache = __webpack_require__(106); +var Key = __webpack_require__(256); +var KeyCodes = __webpack_require__(143); +var KeyCombo = __webpack_require__(255); +var KeyMap = __webpack_require__(602); +var ProcessKeyDown = __webpack_require__(601); +var ProcessKeyUp = __webpack_require__(600); +var SnapFloor = __webpack_require__(142); /** * @classdesc @@ -86647,7 +113659,7 @@ var ProcessKeyUp = __webpack_require__(367); * * @class KeyboardPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Keyboard + * @memberof Phaser.Input.Keyboard * @constructor * @since 3.10.0 * @@ -86749,6 +113761,16 @@ var KeyboardPlugin = new Class({ */ this.onKeyHandler; + /** + * Internal time value. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#time + * @type {number} + * @private + * @since 3.11.0 + */ + this.time = 0; + sceneInputPlugin.pluginEvents.once('boot', this.boot, this); sceneInputPlugin.pluginEvents.on('start', this.start, this); }, @@ -86862,7 +113884,8 @@ var KeyboardPlugin = new Class({ /** * @typedef {object} CursorKeys - * + * @memberof Phaser.Input.Keyboard + * * @property {Phaser.Input.Keyboard.Key} [up] - A Key object mapping to the UP arrow key. * @property {Phaser.Input.Keyboard.Key} [down] - A Key object mapping to the DOWN arrow key. * @property {Phaser.Input.Keyboard.Key} [left] - A Key object mapping to the LEFT arrow key. @@ -86929,7 +113952,12 @@ var KeyboardPlugin = new Class({ for (var i = 0; i < keys.length; i++) { - output[keys[i]] = this.addKey(keys[i]); + var currentKey = keys[i].trim(); + + if (currentKey) + { + output[currentKey] = this.addKey(currentKey); + } } } else @@ -87036,11 +114064,11 @@ var KeyboardPlugin = new Class({ * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); @@ -87066,15 +114094,54 @@ var KeyboardPlugin = new Class({ return new KeyCombo(this, keys, config); }, + /** + * Checks if the given Key object is currently being held down. + * + * The difference between this method and checking the `Key.isDown` property directly is that you can provide + * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted + * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it + * will only return `true` every 100ms. + * + * If the Keyboard Plugin has been disabled, this method will always return `false`. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#checkDown + * @since 3.11.0 + * + * @param {Phaser.Input.Keyboard.Key} key - A Key object. + * @param {number} [duration=0] - The duration which must have elapsed before this Key is considered as being down. + * + * @return {boolean} `True` if the Key is down within the duration specified, otherwise `false`. + */ + checkDown: function (key, duration) + { + if (this.enabled && key.isDown) + { + var t = SnapFloor(this.time - key.timeDown, duration); + + if (t > key._tick) + { + key._tick = t; + + return true; + } + } + + return false; + }, + /** * Internal update handler called by the Input Manager, which is in turn invoked by the Game step. * * @method Phaser.Input.Keyboard.KeyboardPlugin#update * @private * @since 3.10.0 + * + * @param {number} time - The game loop time value. */ - update: function () + update: function (time) { + this.time = time; + var len = this.queue.length; if (!this.enabled || len === 0) @@ -87125,8 +114192,38 @@ var KeyboardPlugin = new Class({ }, /** - * Shuts the Keyboard Plugin down. - * All this does is remove any listeners bound to it. + * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. + * This can only reset keys created via the `addKey`, `addKeys` or `createCursors` methods. + * If you have created a Key object directly you'll need to reset it yourself. + * + * This method is called automatically when the Keyboard Plugin shuts down, but can be + * invoked directly at any time you require. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#resetKeys + * @since 3.15.0 + */ + resetKeys: function () + { + var keys = this.keys; + + for (var i = 0; i < keys.length; i++) + { + // Because it's a sparsely populated array + if (keys[i]) + { + keys[i].reset(); + } + } + + return this; + }, + + /** + * Shuts this Keyboard Plugin down. This performs the following tasks: + * + * 1 - Resets all keys created by this Keyboard plugin. + * 2 - Stops and removes the keyboard event listeners. + * 3 - Clears out any pending requests in the queue, without processing them. * * @method Phaser.Input.Keyboard.KeyboardPlugin#shutdown * @private @@ -87134,9 +114231,13 @@ var KeyboardPlugin = new Class({ */ shutdown: function () { + this.resetKeys(); + this.stopListeners(); this.removeAllListeners(); + + this.queue = []; }, /** @@ -87176,7 +114277,7 @@ module.exports = KeyboardPlugin; /***/ }), -/* 374 */ +/* 607 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -87191,23 +114292,23 @@ module.exports = KeyboardPlugin; module.exports = { - KeyboardPlugin: __webpack_require__(373), + KeyboardPlugin: __webpack_require__(606), - Key: __webpack_require__(171), - KeyCodes: __webpack_require__(109), + Key: __webpack_require__(256), + KeyCodes: __webpack_require__(143), - KeyCombo: __webpack_require__(170), + KeyCombo: __webpack_require__(255), - JustDown: __webpack_require__(366), - JustUp: __webpack_require__(365), - DownDuration: __webpack_require__(364), - UpDuration: __webpack_require__(363) + JustDown: __webpack_require__(599), + JustUp: __webpack_require__(598), + DownDuration: __webpack_require__(597), + UpDuration: __webpack_require__(596) }; /***/ }), -/* 375 */ +/* 608 */ /***/ (function(module, exports) { /** @@ -87233,7 +114334,7 @@ var CreatePixelPerfectHandler = function (textureManager, alphaTolerance) { return function (hitArea, x, y, gameObject) { - var alpha = textureManager.getPixelAlpha(x, y, gameObject.texture.key, gameObject.frame.key); + var alpha = textureManager.getPixelAlpha(x, y, gameObject.texture.key, gameObject.frame.name); return (alpha && alpha >= alphaTolerance); }; @@ -87243,7 +114344,7 @@ module.exports = CreatePixelPerfectHandler; /***/ }), -/* 376 */ +/* 609 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -87252,23 +114353,23 @@ module.exports = CreatePixelPerfectHandler; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circle = __webpack_require__(88); -var CircleContains = __webpack_require__(32); +var Circle = __webpack_require__(71); +var CircleContains = __webpack_require__(40); var Class = __webpack_require__(0); -var CreateInteractiveObject = __webpack_require__(175); -var CreatePixelPerfectHandler = __webpack_require__(375); -var DistanceBetween = __webpack_require__(58); -var Ellipse = __webpack_require__(114); -var EllipseContains = __webpack_require__(54); -var EventEmitter = __webpack_require__(9); -var GetFastValue = __webpack_require__(1); -var InputPluginCache = __webpack_require__(76); +var CreateInteractiveObject = __webpack_require__(260); +var CreatePixelPerfectHandler = __webpack_require__(608); +var DistanceBetween = __webpack_require__(52); +var Ellipse = __webpack_require__(90); +var EllipseContains = __webpack_require__(89); +var EventEmitter = __webpack_require__(11); +var GetFastValue = __webpack_require__(2); +var InputPluginCache = __webpack_require__(106); var IsPlainObject = __webpack_require__(8); -var PluginCache = __webpack_require__(12); -var Rectangle = __webpack_require__(14); -var RectangleContains = __webpack_require__(31); -var Triangle = __webpack_require__(68); -var TriangleContains = __webpack_require__(60); +var PluginCache = __webpack_require__(15); +var Rectangle = __webpack_require__(9); +var RectangleContains = __webpack_require__(39); +var Triangle = __webpack_require__(59); +var TriangleContains = __webpack_require__(69); /** * @classdesc @@ -87297,7 +114398,7 @@ var TriangleContains = __webpack_require__(60); * * @class InputPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input + * @memberof Phaser.Input * @constructor * @since 3.0.0 * @@ -87449,6 +114550,33 @@ var InputPlugin = new Class({ */ this._pollTimer = 0; + var _eventData = { cancelled: false }; + + /** + * Internal event propagation callback container. + * + * @name Phaser.Input.InputPlugin#_eventContainer + * @type {object} + * @private + * @since 3.13.0 + */ + this._eventContainer = { + stopPropagation: function () + { + _eventData.cancelled = true; + } + }; + + /** + * Internal event propagation data object. + * + * @name Phaser.Input.InputPlugin#_eventData + * @type {object} + * @private + * @since 3.13.0 + */ + this._eventData = _eventData; + /** * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. * @@ -87816,6 +114944,8 @@ var InputPlugin = new Class({ input.hitAreaCallback = undefined; input.callbackContext = undefined; + this.manager.resetCursor(input); + gameObject.input = null; // Clear from _draggable, _drag and _over @@ -87931,7 +115061,7 @@ var InputPlugin = new Class({ { var camera = cameras[c]; - // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array. + // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'over' array. // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. var over = this.manager.hitTest(pointer, this._list, camera); @@ -87954,6 +115084,11 @@ var InputPlugin = new Class({ } } + // If we got this far then there were no Game Objects below the pointer, but it was still over + // a camera, so set that the top-most one into the pointer + + pointer.camera = cameras[0]; + return []; }, @@ -87970,12 +115105,15 @@ var InputPlugin = new Class({ */ processDownEvents: function (pointer) { + var total = 0; var currentlyOver = this._temp; - // Contains ALL Game Objects currently over in the array - this.emit('pointerdown', pointer, currentlyOver); + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; - var total = 0; + _eventData.cancelled = false; + + var aborted = false; // Go through all objects the pointer was over and fire their events / callbacks for (var i = 0; i < currentlyOver.length; i++) @@ -87989,9 +115127,27 @@ var InputPlugin = new Class({ total++; - gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, pointer.camera); + gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); - this.emit('gameobjectdown', pointer, gameObject); + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectdown', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + // Contains ALL Game Objects currently over in the array + if (!aborted) + { + this.emit('pointerdown', pointer, currentlyOver); } return total; @@ -88051,7 +115207,7 @@ var InputPlugin = new Class({ { gameObject = currentlyOver[i]; - if (gameObject.input.draggable) + if (gameObject.input.draggable && (gameObject.input.dragState === 0)) { draglist.push(gameObject); } @@ -88278,11 +115434,15 @@ var InputPlugin = new Class({ */ processMoveEvents: function (pointer) { + var total = 0; var currentlyOver = this._temp; - this.emit('pointermove', pointer, currentlyOver); + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; - var total = 0; + _eventData.cancelled = false; + + var aborted = false; // Go through all objects the pointer was over and fire their events / callbacks for (var i = 0; i < currentlyOver.length; i++) @@ -88296,9 +115456,21 @@ var InputPlugin = new Class({ total++; - gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY); + gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); - this.emit('gameobjectmove', pointer, gameObject); + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectmove', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } if (this.topOnly) { @@ -88306,6 +115478,11 @@ var InputPlugin = new Class({ } } + if (!aborted) + { + this.emit('pointermove', pointer, currentlyOver); + } + return total; }, @@ -88374,12 +115551,17 @@ var InputPlugin = new Class({ var totalInteracted = 0; + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; + if (total > 0) { this.sortGameObjects(justOut); - this.emit('pointerout', pointer, justOut); - // Call onOut for everything in the justOut array for (i = 0; i < total; i++) { @@ -88390,25 +115572,44 @@ var InputPlugin = new Class({ continue; } - this.emit('gameobjectout', pointer, gameObject); - - gameObject.emit('pointerout', pointer); + gameObject.emit('pointerout', pointer, _eventContainer); manager.resetCursor(gameObject.input); totalInteracted++; + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectout', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + this.emit('pointerout', pointer, justOut); } } // Process the Just Over objects total = justOver.length; + _eventData.cancelled = false; + + aborted = false; + if (total > 0) { this.sortGameObjects(justOver); - this.emit('pointerover', pointer, justOver); - // Call onOver for everything in the justOver array for (i = 0; i < total; i++) { @@ -88419,13 +115620,30 @@ var InputPlugin = new Class({ continue; } - this.emit('gameobjectover', pointer, gameObject); - - gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY); + gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); manager.setCursor(gameObject.input); totalInteracted++; + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectover', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + this.emit('pointerover', pointer, justOver); } } @@ -88453,8 +115671,12 @@ var InputPlugin = new Class({ { var currentlyOver = this._temp; - // Contains ALL Game Objects currently up in the array - this.emit('pointerup', pointer, currentlyOver); + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; // Go through all objects the pointer was over and fire their events / callbacks for (var i = 0; i < currentlyOver.length; i++) @@ -88468,9 +115690,27 @@ var InputPlugin = new Class({ // pointerupoutside - gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY); + gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); - this.emit('gameobjectup', pointer, gameObject); + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectup', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + // Contains ALL Game Objects currently up in the array + this.emit('pointerup', pointer, currentlyOver); } return currentlyOver.length; @@ -89351,7 +116591,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#x * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ x: { @@ -89369,7 +116609,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#y * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ y: { @@ -89388,7 +116628,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#mousePointer * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ mousePointer: { @@ -89405,7 +116645,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#activePointer * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.0.0 */ activePointer: { @@ -89423,7 +116663,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer1 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer1: { @@ -89441,7 +116681,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer2 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer2: { @@ -89459,7 +116699,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer3 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer3: { @@ -89477,7 +116717,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer4 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer4: { @@ -89495,7 +116735,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer5 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer5: { @@ -89513,7 +116753,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer6 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer6: { @@ -89531,7 +116771,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer7 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer7: { @@ -89549,7 +116789,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer8 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer8: { @@ -89567,7 +116807,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer9 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer9: { @@ -89585,7 +116825,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer10 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer10: { @@ -89605,7 +116845,7 @@ module.exports = InputPlugin; /***/ }), -/* 377 */ +/* 610 */ /***/ (function(module, exports) { /** @@ -89656,7 +116896,7 @@ module.exports = { /***/ }), -/* 378 */ +/* 611 */ /***/ (function(module, exports) { /** @@ -89695,7 +116935,7 @@ module.exports = { /***/ }), -/* 379 */ +/* 612 */ /***/ (function(module, exports) { /** @@ -89745,7 +116985,7 @@ module.exports = { /***/ }), -/* 380 */ +/* 613 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -89760,15 +117000,15 @@ module.exports = { module.exports = { - DUALSHOCK_4: __webpack_require__(379), - SNES_USB: __webpack_require__(378), - XBOX_360: __webpack_require__(377) + DUALSHOCK_4: __webpack_require__(612), + SNES_USB: __webpack_require__(611), + XBOX_360: __webpack_require__(610) }; /***/ }), -/* 381 */ +/* 614 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -89778,10 +117018,10 @@ module.exports = { */ var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Gamepad = __webpack_require__(172); +var EventEmitter = __webpack_require__(11); +var Gamepad = __webpack_require__(257); var GetValue = __webpack_require__(4); -var InputPluginCache = __webpack_require__(76); +var InputPluginCache = __webpack_require__(106); /** * @typedef {object} Pad @@ -89827,7 +117067,7 @@ var InputPluginCache = __webpack_require__(76); * * @class GamepadPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.10.0 * @@ -90411,7 +117651,7 @@ module.exports = GamepadPlugin; /***/ }), -/* 382 */ +/* 615 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90426,17 +117666,17 @@ module.exports = GamepadPlugin; module.exports = { - Axis: __webpack_require__(174), - Button: __webpack_require__(173), - Gamepad: __webpack_require__(172), - GamepadPlugin: __webpack_require__(381), + Axis: __webpack_require__(259), + Button: __webpack_require__(258), + Gamepad: __webpack_require__(257), + GamepadPlugin: __webpack_require__(614), - Configs: __webpack_require__(380) + Configs: __webpack_require__(613) }; /***/ }), -/* 383 */ +/* 616 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90445,8 +117685,8 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(200); -var Extend = __webpack_require__(17); +var CONST = __webpack_require__(337); +var Extend = __webpack_require__(20); /** * @namespace Phaser.Input @@ -90454,15 +117694,15 @@ var Extend = __webpack_require__(17); var Input = { - CreateInteractiveObject: __webpack_require__(175), - Gamepad: __webpack_require__(382), - InputManager: __webpack_require__(201), - InputPlugin: __webpack_require__(376), - InputPluginCache: __webpack_require__(76), - Keyboard: __webpack_require__(374), - Mouse: __webpack_require__(362), - Pointer: __webpack_require__(198), - Touch: __webpack_require__(361) + CreateInteractiveObject: __webpack_require__(260), + Gamepad: __webpack_require__(615), + InputManager: __webpack_require__(338), + InputPlugin: __webpack_require__(609), + InputPluginCache: __webpack_require__(106), + Keyboard: __webpack_require__(607), + Mouse: __webpack_require__(595), + Pointer: __webpack_require__(335), + Touch: __webpack_require__(594) }; @@ -90473,7 +117713,7 @@ module.exports = Input; /***/ }), -/* 384 */ +/* 617 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90482,37 +117722,634 @@ module.exports = Input; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -// The three angle bisectors of a triangle meet in one point called the incenter. -// It is the center of the incircle, the circle inscribed in the triangle. - -function getLength (x1, y1, x2, y2) -{ - var x = x1 - x2; - var y = y1 - y2; - var magnitude = (x * x) + (y * y); - - return Math.sqrt(magnitude); -} +var RotateAroundXY = __webpack_require__(144); /** * [description] * - * @function Phaser.Geom.Triangle.InCenter + * @function Phaser.Geom.Triangle.RotateAroundPoint * @since 3.0.0 * - * @generic {Phaser.Geom.Point} O - [out,$return] + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] * * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {Phaser.Geom.Point} point - [description] + * @param {number} angle - [description] * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Triangle} [description] */ -var InCenter = function (triangle, out) +var RotateAroundPoint = function (triangle, point, angle) { - if (out === undefined) { out = new Point(); } + return RotateAroundXY(triangle, point.x, point.y, angle); +}; +module.exports = RotateAroundPoint; + + +/***/ }), +/* 618 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(144); +var InCenter = __webpack_require__(261); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Rotate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Rotate = function (triangle, angle) +{ + var point = InCenter(triangle); + + return RotateAroundXY(triangle, point.x, point.y, angle); +}; + +module.exports = Rotate; + + +/***/ }), +/* 619 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); + +// The 2D area of a triangle. The area value is always non-negative. + +/** + * Gets the length of the perimeter of the given triangle. + * + * @function Phaser.Geom.Triangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {number} [description] + */ +var Perimeter = function (triangle) +{ + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + return (Length(line1) + Length(line2) + Length(line3)); +}; + +module.exports = Perimeter; + + +/***/ }), +/* 620 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns true if two triangles have the same coordinates. + * + * @function Phaser.Geom.Triangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The first triangle to check. + * @param {Phaser.Geom.Triangle} toCompare - The second triangle to check. + * + * @return {boolean} `true` if the two given triangles have the exact same coordinates, otherwise `false`. + */ +var Equals = function (triangle, toCompare) +{ + return ( + triangle.x1 === toCompare.x1 && + triangle.y1 === toCompare.y1 && + triangle.x2 === toCompare.x2 && + triangle.y2 === toCompare.y2 && + triangle.x3 === toCompare.x3 && + triangle.y3 === toCompare.y3 + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 621 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one Triangle to a destination Triangle. + * + * @function Phaser.Geom.Triangle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [dest,$return] + * + * @param {Phaser.Geom.Triangle} source - The source Triangle to copy the values from. + * @param {Phaser.Geom.Triangle} dest - The destination Triangle to copy the values to. + * + * @return {Phaser.Geom.Triangle} The destination Triangle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 622 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(69); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} point - [description] + * + * @return {boolean} [description] + */ +var ContainsPoint = function (triangle, point) +{ + return Contains(triangle, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 623 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(59); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} source - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Clone = function (source) +{ + return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; + +module.exports = Clone; + + +/***/ }), +/* 624 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(71); + +// Adapted from https://gist.github.com/mutoo/5617691 + +/** + * [description] + * + * @function Phaser.Geom.Triangle.CircumCircle + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Circle} [out] - [description] + * + * @return {Phaser.Geom.Circle} [description] + */ +var CircumCircle = function (triangle, out) +{ + if (out === undefined) { out = new Circle(); } + + // A + var x1 = triangle.x1; + var y1 = triangle.y1; + + // B + var x2 = triangle.x2; + var y2 = triangle.y2; + + // C + var x3 = triangle.x3; + var y3 = triangle.y3; + + var A = x2 - x1; + var B = y2 - y1; + var C = x3 - x1; + var D = y3 - y1; + var E = A * (x1 + x2) + B * (y1 + y2); + var F = C * (x1 + x3) + D * (y1 + y3); + var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); + + var dx; + var dy; + + // If the points of the triangle are collinear, then just find the + // extremes and use the midpoint as the center of the circumcircle. + + if (Math.abs(G) < 0.000001) + { + var minX = Math.min(x1, x2, x3); + var minY = Math.min(y1, y2, y3); + dx = (Math.max(x1, x2, x3) - minX) * 0.5; + dy = (Math.max(y1, y2, y3) - minY) * 0.5; + + out.x = minX + dx; + out.y = minY + dy; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + else + { + out.x = (D * E - B * F) / G; + out.y = (A * F - C * E) / G; + dx = out.x - x1; + dy = out.y - y1; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + + return out; +}; + +module.exports = CircumCircle; + + +/***/ }), +/* 625 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector2 = __webpack_require__(3); + +// Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html + +/** + * Computes the determinant of a 2x2 matrix. Uses standard double-precision arithmetic, so is susceptible to round-off error. + * + * @function det + * @private + * @since 3.0.0 + * + * @param {number} m00 - The [0,0] entry of the matrix. + * @param {number} m01 - The [0,1] entry of the matrix. + * @param {number} m10 - The [1,0] entry of the matrix. + * @param {number} m11 - The [1,1] entry of the matrix. + * + * @return {number} the determinant. + */ +function det (m00, m01, m10, m11) +{ + return (m00 * m11) - (m01 * m10); +} + +/** + * Computes the circumcentre of a triangle. The circumcentre is the centre of + * the circumcircle, the smallest circle which encloses the triangle. It is also + * the common intersection point of the perpendicular bisectors of the sides of + * the triangle, and is the only point which has equal distance to all three + * vertices of the triangle. + * + * @function Phaser.Geom.Triangle.CircumCenter + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ +var CircumCenter = function (triangle, out) +{ + if (out === undefined) { out = new Vector2(); } + + var cx = triangle.x3; + var cy = triangle.y3; + + var ax = triangle.x1 - cx; + var ay = triangle.y1 - cy; + + var bx = triangle.x2 - cx; + var by = triangle.y2 - cy; + + var denom = 2 * det(ax, ay, bx, by); + var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); + var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); + + out.x = cx - numx / denom; + out.y = cy + numy / denom; + + return out; +}; + +module.exports = CircumCenter; + + +/***/ }), +/* 626 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Centroid = __webpack_require__(263); +var Offset = __webpack_require__(262); + +/** + * @callback CenterFunction + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + +/** + * Positions the Triangle so that it is centered on the given coordinates. + * + * @function Phaser.Geom.Triangle.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The triangle to be positioned. + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {CenterFunction} [centerFunc] - The function used to center the triangle. Defaults to Centroid centering. + * + * @return {Phaser.Geom.Triangle} The Triangle that was centered. + */ +var CenterOn = function (triangle, x, y, centerFunc) +{ + if (centerFunc === undefined) { centerFunc = Centroid; } + + // Get the center of the triangle + var center = centerFunc(triangle); + + // Difference + var diffX = x - center.x; + var diffY = y - center.y; + + return Offset(triangle, diffX, diffY); +}; + +module.exports = CenterOn; + + +/***/ }), +/* 627 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(59); + +// Builds a right triangle, with one 90 degree angle and two acute angles +// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) +// w/h can be positive or negative and represent the length of each side + +/** + * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. + * + * @function Phaser.Geom.Triangle.BuildRight + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. + * @param {number} y - The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. + * @param {number} width - The length of the side which is to the left or to the right of the right angle. + * @param {number} height - The length of the side which is above or below the right angle. + * + * @return {Phaser.Geom.Triangle} The constructed right Triangle. + */ +var BuildRight = function (x, y, width, height) +{ + if (height === undefined) { height = width; } + + // 90 degree angle + var x1 = x; + var y1 = y; + + var x2 = x; + var y2 = y - height; + + var x3 = x + width; + var y3 = y; + + return new Triangle(x1, y1, x2, y2, x3, y3); +}; + +module.exports = BuildRight; + + +/***/ }), +/* 628 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var EarCut = __webpack_require__(64); +var Triangle = __webpack_require__(59); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.BuildFromPolygon + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle[]} O - [out,$return] + * + * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] + * @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). + * @param {number} [scaleX=1] - [description] + * @param {number} [scaleY=1] - [description] + * @param {(array|Phaser.Geom.Triangle[])} [out] - [description] + * + * @return {(array|Phaser.Geom.Triangle[])} [description] + */ +var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) +{ + if (holes === undefined) { holes = null; } + if (scaleX === undefined) { scaleX = 1; } + if (scaleY === undefined) { scaleY = 1; } + if (out === undefined) { out = []; } + + var tris = EarCut(data, holes); + + var a; + var b; + var c; + + var x1; + var y1; + + var x2; + var y2; + + var x3; + var y3; + + for (var i = 0; i < tris.length; i += 3) + { + a = tris[i]; + b = tris[i + 1]; + c = tris[i + 2]; + + x1 = data[a * 2] * scaleX; + y1 = data[(a * 2) + 1] * scaleY; + + x2 = data[b * 2] * scaleX; + y2 = data[(b * 2) + 1] * scaleY; + + x3 = data[c * 2] * scaleX; + y3 = data[(c * 2) + 1] * scaleY; + + out.push(new Triangle(x1, y1, x2, y2, x3, y3)); + } + + return out; +}; + +module.exports = BuildFromPolygon; + + +/***/ }), +/* 629 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(59); + +/** + * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). + * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. + * + * @function Phaser.Geom.Triangle.BuildEquilateral + * @since 3.0.0 + * + * @param {number} x - x coordinate of the top point of the triangle. + * @param {number} y - y coordinate of the top point of the triangle. + * @param {number} length - Length of each side of the triangle. + * + * @return {Phaser.Geom.Triangle} The Triangle object of the given size. + */ +var BuildEquilateral = function (x, y, length) +{ + var height = length * (Math.sqrt(3) / 2); + + var x1 = x; + var y1 = y; + + var x2 = x + (length / 2); + var y2 = y + height; + + var x3 = x - (length / 2); + var y3 = y + height; + + return new Triangle(x1, y1, x2, y2, x3, y3); +}; + +module.exports = BuildEquilateral; + + +/***/ }), +/* 630 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// The 2D area of a triangle. The area value is always non-negative. + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {number} [description] + */ +var Area = function (triangle) +{ var x1 = triangle.x1; var y1 = triangle.y1; @@ -90522,64 +118359,14 @@ var InCenter = function (triangle, out) var x3 = triangle.x3; var y3 = triangle.y3; - var d1 = getLength(x3, y3, x2, y2); - var d2 = getLength(x1, y1, x3, y3); - var d3 = getLength(x2, y2, x1, y1); - - var p = d1 + d2 + d3; - - out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; - out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; - - return out; + return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); }; -module.exports = InCenter; +module.exports = Area; /***/ }), -/* 385 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Offset = function (triangle, x, y) -{ - triangle.x1 += x; - triangle.y1 += y; - - triangle.x2 += x; - triangle.y2 += y; - - triangle.x3 += x; - triangle.y3 += y; - - return triangle; -}; - -module.exports = Offset; - - -/***/ }), -/* 386 */ +/* 631 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90588,40 +118375,38 @@ module.exports = Offset; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +var Triangle = __webpack_require__(59); -// The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) -// meet in the centroid or center of mass (center of gravity). -// The centroid divides each median in a ratio of 2:1 +Triangle.Area = __webpack_require__(630); +Triangle.BuildEquilateral = __webpack_require__(629); +Triangle.BuildFromPolygon = __webpack_require__(628); +Triangle.BuildRight = __webpack_require__(627); +Triangle.CenterOn = __webpack_require__(626); +Triangle.Centroid = __webpack_require__(263); +Triangle.CircumCenter = __webpack_require__(625); +Triangle.CircumCircle = __webpack_require__(624); +Triangle.Clone = __webpack_require__(623); +Triangle.Contains = __webpack_require__(69); +Triangle.ContainsArray = __webpack_require__(147); +Triangle.ContainsPoint = __webpack_require__(622); +Triangle.CopyFrom = __webpack_require__(621); +Triangle.Decompose = __webpack_require__(269); +Triangle.Equals = __webpack_require__(620); +Triangle.GetPoint = __webpack_require__(278); +Triangle.GetPoints = __webpack_require__(277); +Triangle.InCenter = __webpack_require__(261); +Triangle.Perimeter = __webpack_require__(619); +Triangle.Offset = __webpack_require__(262); +Triangle.Random = __webpack_require__(184); +Triangle.Rotate = __webpack_require__(618); +Triangle.RotateAroundPoint = __webpack_require__(617); +Triangle.RotateAroundXY = __webpack_require__(144); -/** - * [description] - * - * @function Phaser.Geom.Triangle.Centroid - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var Centroid = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; - out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; - - return out; -}; - -module.exports = Centroid; +module.exports = Triangle; /***/ }), -/* 387 */ +/* 632 */ /***/ (function(module, exports) { /** @@ -90630,54 +118415,12 @@ module.exports = Centroid; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Checks if rectB is fully contained within rectA +// Scales the width and height of this Rectangle by the given amounts. /** * [description] * - * @function Phaser.Geom.Rectangle.ContainsRect - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * - * @return {boolean} [description] - */ -var ContainsRect = function (rectA, rectB) -{ - // Volume check (if rectB volume > rectA then rectA cannot contain it) - if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) - { - return false; - } - - return ( - (rectB.x > rectA.x && rectB.x < rectA.right) && - (rectB.right > rectA.x && rectB.right < rectA.right) && - (rectB.y > rectA.y && rectB.y < rectA.bottom) && - (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) - ); -}; - -module.exports = ContainsRect; - - -/***/ }), -/* 388 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Centers this Rectangle so that the center coordinates match the given x and y values. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.CenterOn + * @function Phaser.Geom.Rectangle.Scale * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] @@ -90688,19 +118431,50 @@ module.exports = ContainsRect; * * @return {Phaser.Geom.Rectangle} [description] */ -var CenterOn = function (rect, x, y) +var Scale = function (rect, x, y) { - rect.x = x - (rect.width / 2); - rect.y = y - (rect.height / 2); + if (y === undefined) { y = x; } + + rect.width *= x; + rect.height *= y; return rect; }; -module.exports = CenterOn; +module.exports = Scale; /***/ }), -/* 389 */ +/* 633 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. + * + * @function Phaser.Geom.Rectangle.SameDimensions + * @since 3.15.0 + * + * @param {Phaser.Geom.Rectangle} rect - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} toCompare - The second Rectangle object. + * + * @return {boolean} `true` if the objects have equivalent values for the `width` and `height` properties, otherwise `false`. + */ +var SameDimensions = function (rect, toCompare) +{ + return (rect.width === toCompare.width && rect.height === toCompare.height); +}; + +module.exports = SameDimensions; + + +/***/ }), +/* 634 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90709,233 +118483,1268 @@ module.exports = CenterOn; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(14); - -Rectangle.Area = __webpack_require__(797); -Rectangle.Ceil = __webpack_require__(796); -Rectangle.CeilAll = __webpack_require__(795); -Rectangle.CenterOn = __webpack_require__(388); -Rectangle.Clone = __webpack_require__(794); -Rectangle.Contains = __webpack_require__(31); -Rectangle.ContainsPoint = __webpack_require__(793); -Rectangle.ContainsRect = __webpack_require__(387); -Rectangle.CopyFrom = __webpack_require__(792); -Rectangle.Decompose = __webpack_require__(395); -Rectangle.Equals = __webpack_require__(791); -Rectangle.FitInside = __webpack_require__(790); -Rectangle.FitOutside = __webpack_require__(789); -Rectangle.Floor = __webpack_require__(788); -Rectangle.FloorAll = __webpack_require__(787); -Rectangle.FromPoints = __webpack_require__(274); -Rectangle.GetAspectRatio = __webpack_require__(228); -Rectangle.GetCenter = __webpack_require__(786); -Rectangle.GetPoint = __webpack_require__(135); -Rectangle.GetPoints = __webpack_require__(294); -Rectangle.GetSize = __webpack_require__(785); -Rectangle.Inflate = __webpack_require__(784); -Rectangle.MarchingAnts = __webpack_require__(570); -Rectangle.MergePoints = __webpack_require__(783); -Rectangle.MergeRect = __webpack_require__(782); -Rectangle.MergeXY = __webpack_require__(781); -Rectangle.Offset = __webpack_require__(780); -Rectangle.OffsetPoint = __webpack_require__(779); -Rectangle.Overlaps = __webpack_require__(778); -Rectangle.Perimeter = __webpack_require__(97); -Rectangle.PerimeterPoint = __webpack_require__(777); -Rectangle.Random = __webpack_require__(154); -Rectangle.RandomOutside = __webpack_require__(776); -Rectangle.Scale = __webpack_require__(775); -Rectangle.Union = __webpack_require__(473); - -module.exports = Rectangle; - - -/***/ }), -/* 390 */ -/***/ (function(module, exports, __webpack_require__) { +var Between = __webpack_require__(170); +var ContainsRect = __webpack_require__(264); +var Point = __webpack_require__(6); /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(229); - -/** - * @classdesc - * [description] + * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. + * The inner Rectangle must be fully contained within the outer rectangle. * - * @class Polygon - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 + * @function Phaser.Geom.Rectangle.RandomOutside + * @since 3.10.0 * - * @param {Phaser.Geom.Point[]} [points] - [description] + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} outer - The outer Rectangle to get the random point within. + * @param {Phaser.Geom.Rectangle} inner - The inner Rectangle to exclude from the returned point. + * @param {Phaser.Geom.Point} [out] - A Point, or Point-like object to store the result in. If not specified, a new Point will be created. + * + * @return {Phaser.Geom.Point} A Point object containing the random values in its `x` and `y` properties. */ -var Polygon = new Class({ +var RandomOutside = function (outer, inner, out) +{ + if (out === undefined) { out = new Point(); } - initialize: - - function Polygon (points) + if (ContainsRect(outer, inner)) { - /** - * The area of this Polygon. - * - * @name Phaser.Geom.Polygon#area - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.area = 0; + // Pick a random quadrant + // + // The quadrants don't extend the full widths / heights of the outer rect to give + // us a better uniformed distribution, otherwise you get clumping in the corners where + // the 4 quads would overlap - /** - * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] - * - * @name Phaser.Geom.Polygon#points - * @type {Phaser.Geom.Point[]} - * @since 3.0.0 - */ - this.points = []; - - if (points) + switch (Between(0, 3)) { - this.setTo(points); + case 0: // Top + out.x = outer.x + (Math.random() * (inner.right - outer.x)); + out.y = outer.y + (Math.random() * (inner.top - outer.y)); + break; + + case 1: // Bottom + out.x = inner.x + (Math.random() * (outer.right - inner.x)); + out.y = inner.bottom + (Math.random() * (outer.bottom - inner.bottom)); + break; + + case 2: // Left + out.x = outer.x + (Math.random() * (inner.x - outer.x)); + out.y = inner.y + (Math.random() * (outer.bottom - inner.y)); + break; + + case 3: // Right + out.x = inner.right + (Math.random() * (outer.right - inner.right)); + out.y = outer.y + (Math.random() * (inner.bottom - outer.y)); + break; } - }, - - /** - * [description] - * - * @method Phaser.Geom.Polygon#contains - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` - * - An array of objects with public x/y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` - * - * `setTo` may also be called without any arguments to remove all points. - * - * @method Phaser.Geom.Polygon#setTo - * @since 3.0.0 - * - * @param {array} points - [description] - * - * @return {Phaser.Geom.Polygon} This Polygon object. - */ - setTo: function (points) - { - this.area = 0; - this.points = []; - - if (!Array.isArray(points)) - { - return this; - } - - var p; - var y0 = Number.MAX_VALUE; - - // The points argument is an array, so iterate through it - for (var i = 0; i < points.length; i++) - { - p = { x: 0, y: 0 }; - - if (typeof points[i] === 'number') - { - p.x = points[i]; - p.y = points[i + 1]; - i++; - } - else if (Array.isArray(points[i])) - { - // An array of arrays? - p.x = points[i][0]; - p.y = points[i][1]; - } - else - { - p.x = points[i].x; - p.y = points[i].y; - } - - this.points.push(p); - - // Lowest boundary - if (p.y < y0) - { - y0 = p.y; - } - } - - this.calculateArea(y0); - - return this; - }, - - /** - * Calculates the area of the Polygon. This is available in the property Polygon.area - * - * @method Phaser.Geom.Polygon#calculateArea - * @since 3.0.0 - * - * @return {number} [description] - */ - calculateArea: function () - { - if (this.points.length < 3) - { - this.area = 0; - - return this.area; - } - - var sum = 0; - var p1; - var p2; - - for (var i = 0; i < this.points.length - 1; i++) - { - p1 = this.points[i]; - p2 = this.points[i + 1]; - - sum += (p2.x - p1.x) * (p1.y + p2.y); - } - - p1 = this.points[0]; - p2 = this.points[this.points.length - 1]; - - sum += (p1.x - p2.x) * (p2.y + p1.y); - - this.area = -sum * 0.5; - - return this.area; } -}); + return out; +}; + +module.exports = RandomOutside; + + +/***/ }), +/* 635 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); +var DegToRad = __webpack_require__(31); + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.PerimeterPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {integer} angle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var PerimeterPoint = function (rectangle, angle, out) +{ + if (out === undefined) { out = new Point(); } + + angle = DegToRad(angle); + + var s = Math.sin(angle); + var c = Math.cos(angle); + + var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; + var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; + + if (Math.abs(dx * s) < Math.abs(dy * c)) + { + dy = (dx * s) / c; + } + else + { + dx = (dy * c) / s; + } + + out.x = dx + rectangle.centerX; + out.y = dy + rectangle.centerY; + + return out; +}; + +module.exports = PerimeterPoint; + + +/***/ }), +/* 636 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Overlaps + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var Overlaps = function (rectA, rectB) +{ + return ( + rectA.x < rectB.right && + rectA.right > rectB.x && + rectA.y < rectB.bottom && + rectA.bottom > rectB.y + ); +}; + +module.exports = Overlaps; + + +/***/ }), +/* 637 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector). + * + * @function Phaser.Geom.Rectangle.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2)} point - The point whose coordinates should be used as an offset. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var OffsetPoint = function (rect, point) +{ + rect.x += point.x; + rect.y += point.y; + + return rect; +}; + +module.exports = OffsetPoint; + + +/***/ }), +/* 638 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Nudges (translates) the top left corner of a Rectangle by a given offset. + * + * @function Phaser.Geom.Rectangle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {number} x - The distance to move the Rectangle horizontally. + * @param {number} y - The distance to move the Rectangle vertically. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var Offset = function (rect, x, y) +{ + rect.x += x; + rect.y += y; + + return rect; +}; + +module.exports = Offset; + + +/***/ }), +/* 639 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. + * + * @function Phaser.Geom.Rectangle.MergeXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged and modified. + * @param {number} x - The X coordinate of the point which should be merged. + * @param {number} y - The Y coordinate of the point which should be merged. + * + * @return {Phaser.Geom.Rectangle} The modified `target` Rectangle. + */ +var MergeXY = function (target, x, y) +{ + var minX = Math.min(target.x, x); + var maxX = Math.max(target.right, x); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, y); + var maxY = Math.max(target.bottom, y); + + target.y = minY; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergeXY; + + +/***/ }), +/* 640 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Merges source rectangle into target rectangle and returns target +// Neither rect should have negative widths or heights + +/** + * Merges the source rectangle into the target rectangle and returns the target. + * Neither rectangle should have a negative width or height. + * + * @function Phaser.Geom.Rectangle.MergeRect + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - Target rectangle. Will be modified to include source rectangle. + * @param {Phaser.Geom.Rectangle} source - Rectangle that will be merged into target rectangle. + * + * @return {Phaser.Geom.Rectangle} Modified target rectangle that contains source rectangle. + */ +var MergeRect = function (target, source) +{ + var minX = Math.min(target.x, source.x); + var maxX = Math.max(target.right, source.right); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, source.y); + var maxY = Math.max(target.bottom, source.bottom); + + target.y = minY; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergeRect; + + +/***/ }), +/* 641 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. + * + * @function Phaser.Geom.Rectangle.MergePoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged. + * @param {Phaser.Geom.Point[]} points - An array of Points (or any object with public `x` and `y` properties) which should be merged with the Rectangle. + * + * @return {Phaser.Geom.Rectangle} The modified Rectangle. + */ +var MergePoints = function (target, points) +{ + var minX = target.x; + var maxX = target.right; + var minY = target.y; + var maxY = target.bottom; + + for (var i = 0; i < points.length; i++) + { + minX = Math.min(minX, points[i].x); + maxX = Math.max(maxX, points[i].x); + minY = Math.min(minY, points[i].y); + maxY = Math.max(maxY, points[i].y); + } + + target.x = minX; + target.y = minY; + target.width = maxX - minX; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergePoints; + + +/***/ }), +/* 642 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); +var Intersects = __webpack_require__(148); + +/** + * Takes two Rectangles and first checks to see if they intersect. + * If they intersect it will return the area of intersection in the `out` Rectangle. + * If they do not intersect, the `out` Rectangle will have a width and height of zero. + * + * @function Phaser.Geom.Rectangle.Intersection + * @since 3.11.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle to store the intersection results in. + * + * @return {Phaser.Geom.Rectangle} The intersection result. If the width and height are zero, no intersection occurred. + */ +var Intersection = function (rectA, rectB, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (Intersects(rectA, rectB)) + { + out.x = Math.max(rectA.x, rectB.x); + out.y = Math.max(rectA.y, rectB.y); + out.width = Math.min(rectA.right, rectB.right) - out.x; + out.height = Math.min(rectA.bottom, rectB.bottom) - out.y; + } + else + { + out.setEmpty(); + } + + return out; +}; + +module.exports = Intersection; + + +/***/ }), +/* 643 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CenterOn = __webpack_require__(175); + +// Increases the size of the Rectangle object by the specified amounts. +// The center point of the Rectangle object stays the same, and its size increases +// to the left and right by the x value, and to the top and the bottom by the y value. + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Inflate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var Inflate = function (rect, x, y) +{ + var cx = rect.centerX; + var cy = rect.centerY; + + rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); + + return CenterOn(rect, cx, cy); +}; + +module.exports = Inflate; + + +/***/ }), +/* 644 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// The size of the Rectangle object, expressed as a Point object +// with the values of the width and height properties. + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.GetSize + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetSize = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.width; + out.y = rect.height; + + return out; +}; + +module.exports = GetSize; + + +/***/ }), +/* 645 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns the center of a Rectangle as a Point. + * + * @function Phaser.Geom.Rectangle.GetCenter + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the center of. + * @param {(Phaser.Geom.Point|object)} [out] - Optional point-like object to update with the center coordinates. + * + * @return {(Phaser.Geom.Point|object)} The modified `out` object, or a new Point if none was provided. + */ +var GetCenter = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.centerX; + out.y = rect.centerY; + + return out; +}; + +module.exports = GetCenter; + + +/***/ }), +/* 646 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. + * + * @function Phaser.Geom.Rectangle.FloorAll + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var FloorAll = function (rect) +{ + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + rect.width = Math.floor(rect.width); + rect.height = Math.floor(rect.height); + + return rect; +}; + +module.exports = FloorAll; + + +/***/ }), +/* 647 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Floor + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var Floor = function (rect) +{ + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + + return rect; +}; + +module.exports = Floor; + + +/***/ }), +/* 648 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAspectRatio = __webpack_require__(145); + +// Fits the target rectangle around the source rectangle. +// Preserves aspect ration. +// Scales and centers the target rectangle to the source rectangle + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.FitOutside + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var FitOutside = function (target, source) +{ + var ratio = GetAspectRatio(target); + + if (ratio > GetAspectRatio(source)) + { + // Wider than Tall + target.setSize(source.height * ratio, source.height); + } + else + { + // Taller than Wide + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - target.width / 2, + source.centerY - target.height / 2 + ); +}; + +module.exports = FitOutside; + + +/***/ }), +/* 649 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAspectRatio = __webpack_require__(145); + +// Fits the target rectangle into the source rectangle. +// Preserves aspect ratio. +// Scales and centers the target rectangle to the source rectangle + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.FitInside + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var FitInside = function (target, source) +{ + var ratio = GetAspectRatio(target); + + if (ratio < GetAspectRatio(source)) + { + // Taller than Wide + target.setSize(source.height * ratio, source.height); + } + else + { + // Wider than Tall + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - (target.width / 2), + source.centerY - (target.height / 2) + ); +}; + +module.exports = FitInside; + + +/***/ }), +/* 650 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} toCompare - [description] + * + * @return {boolean} [description] + */ +var Equals = function (rect, toCompare) +{ + return ( + rect.x === toCompare.x && + rect.y === toCompare.y && + rect.width === toCompare.width && + rect.height === toCompare.height + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 651 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one Rectangle to a destination Rectangle. + * + * @function Phaser.Geom.Rectangle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [dest,$return] + * + * @param {Phaser.Geom.Rectangle} source - The source Rectangle to copy the values from. + * @param {Phaser.Geom.Rectangle} dest - The destination Rectangle to copy the values to. + * + * @return {Phaser.Geom.Rectangle} The destination Rectangle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 652 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(39); + +/** + * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. + * + * @function Phaser.Geom.Rectangle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object. + * @param {Phaser.Geom.Point} point - The point object to be checked. Can be a Phaser Point object or any object with x and y values. + * + * @return {boolean} A value of true if the Rectangle object contains the specified point, otherwise false. + */ +var ContainsPoint = function (rect, point) +{ + return Contains(rect, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 653 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Creates a new Rectangle which is identical to the given one. + * + * @function Phaser.Geom.Rectangle.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} source - The Rectangle to clone. + * + * @return {Phaser.Geom.Rectangle} The newly created Rectangle, which is separate from the given one. + */ +var Clone = function (source) +{ + return new Rectangle(source.x, source.y, source.width, source.height); +}; + +module.exports = Clone; + + +/***/ }), +/* 654 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.CeilAll + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var CeilAll = function (rect) +{ + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + rect.width = Math.ceil(rect.width); + rect.height = Math.ceil(rect.height); + + return rect; +}; + +module.exports = CeilAll; + + +/***/ }), +/* 655 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. + * + * @function Phaser.Geom.Rectangle.Ceil + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var Ceil = function (rect) +{ + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + + return rect; +}; + +module.exports = Ceil; + + +/***/ }), +/* 656 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var Area = function (rect) +{ + return rect.width * rect.height; +}; + +module.exports = Area; + + +/***/ }), +/* 657 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Polygon.Reverse + * @since 3.0.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * + * @return {Phaser.Geom.Polygon} [description] + */ +var Reverse = function (polygon) +{ + polygon.points.reverse(); + + return polygon; +}; + +module.exports = Reverse; + + +/***/ }), +/* 658 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] + +/** + * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], + * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant + * array for the point's X and Y coordinate. + * + * @function Phaser.Geom.Polygon.GetNumberArray + * @since 3.0.0 + * + * @generic {number[]} O - [output,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon whose points to export. + * @param {(array|number[])} [output] - An array to which the points' coordinates should be appended. + * + * @return {(array|number[])} The modified `output` array, or a new array if none was given. + */ +var GetNumberArray = function (polygon, output) +{ + if (output === undefined) { output = []; } + + for (var i = 0; i < polygon.points.length; i++) + { + output.push(polygon.points[i].x); + output.push(polygon.points[i].y); + } + + return output; +}; + +module.exports = GetNumberArray; + + +/***/ }), +/* 659 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(150); + +/** + * [description] + * + * @function Phaser.Geom.Polygon.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {Phaser.Geom.Point} point - [description] + * + * @return {boolean} [description] + */ +var ContainsPoint = function (polygon, point) +{ + return Contains(polygon, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 660 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Polygon = __webpack_require__(151); + +/** + * [description] + * + * @function Phaser.Geom.Polygon.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * + * @return {Phaser.Geom.Polygon} [description] + */ +var Clone = function (polygon) +{ + return new Polygon(polygon.points); +}; + +module.exports = Clone; + + +/***/ }), +/* 661 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Polygon = __webpack_require__(151); + +Polygon.Clone = __webpack_require__(660); +Polygon.Contains = __webpack_require__(150); +Polygon.ContainsPoint = __webpack_require__(659); +Polygon.GetAABB = __webpack_require__(285); +Polygon.GetNumberArray = __webpack_require__(658); +Polygon.GetPoints = __webpack_require__(284); +Polygon.Perimeter = __webpack_require__(283); +Polygon.Reverse = __webpack_require__(657); +Polygon.Smooth = __webpack_require__(282); module.exports = Polygon; /***/ }), -/* 391 */ +/* 662 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetMagnitude = __webpack_require__(267); + +/** + * [description] + * + * @function Phaser.Geom.Point.SetMagnitude + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} point - [description] + * @param {number} magnitude - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var SetMagnitude = function (point, magnitude) +{ + if (point.x !== 0 || point.y !== 0) + { + var m = GetMagnitude(point); + + point.x /= m; + point.y /= m; + } + + point.x *= magnitude; + point.y *= magnitude; + + return point; +}; + +module.exports = SetMagnitude; + + +/***/ }), +/* 663 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Point.ProjectUnit + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var ProjectUnit = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var amt = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = ProjectUnit; + + +/***/ }), +/* 664 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); +var GetMagnitudeSq = __webpack_require__(266); + +/** + * [description] + * + * @function Phaser.Geom.Point.Project + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Project = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var dot = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + var amt = dot / GetMagnitudeSq(pointB); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = Project; + + +/***/ }), +/* 665 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Point.Negative + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Negative = function (point, out) +{ + if (out === undefined) { out = new Point(); } + + return out.setTo(-point.x, -point.y); +}; + +module.exports = Negative; + + +/***/ }), +/* 666 */ /***/ (function(module, exports) { /** @@ -90945,25 +119754,201 @@ module.exports = Polygon; */ /** - * [description] + * Swaps the X and the Y coordinate of a point. * - * @function Phaser.Geom.Point.GetMagnitudeSq + * @function Phaser.Geom.Point.Invert * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] + * @generic {Phaser.Geom.Point} O - [point,$return] * - * @return {number} [description] + * @param {Phaser.Geom.Point} point - The Point to modify. + * + * @return {Phaser.Geom.Point} The modified `point`. */ -var GetMagnitudeSq = function (point) +var Invert = function (point) { - return (point.x * point.x) + (point.y * point.y); + return point.setTo(point.y, point.x); }; -module.exports = GetMagnitudeSq; +module.exports = Invert; /***/ }), -/* 392 */ +/* 667 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Interpolate two given Point objects, based on `t` value. Return result either as new Point if `out` parameter is omitted or load result into Point passed as `out` parameter and return it. For `out` parameter you can also use any object with public x/y properties. + * + * @function Phaser.Geom.Point.Interpolate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {number} [t=0] - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Interpolate = function (pointA, pointB, t, out) +{ + if (t === undefined) { t = 0; } + if (out === undefined) { out = new Point(); } + + out.x = pointA.x + ((pointB.x - pointA.x) * t); + out.y = pointA.y + ((pointB.y - pointA.y) * t); + + return out; +}; + +module.exports = Interpolate; + + +/***/ }), +/* 668 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. + * + * @function Phaser.Geom.Point.GetRectangleFromPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Rectangle} [out] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var GetRectangleFromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + var xMax = Number.NEGATIVE_INFINITY; + var xMin = Number.POSITIVE_INFINITY; + var yMax = Number.NEGATIVE_INFINITY; + var yMin = Number.POSITIVE_INFINITY; + + for (var i = 0; i < points.length; i++) + { + var point = points[i]; + + if (point.x > xMax) + { + xMax = point.x; + } + + if (point.x < xMin) + { + xMin = point.x; + } + + if (point.y > yMax) + { + yMax = point.y; + } + + if (point.y < yMin) + { + yMin = point.y; + } + } + + out.x = xMin; + out.y = yMin; + out.width = xMax - xMin; + out.height = yMax - yMin; + + return out; +}; + +module.exports = GetRectangleFromPoints; + + +/***/ }), +/* 669 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Point.GetCentroid + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var GetCentroid = function (points, out) +{ + if (out === undefined) { out = new Point(); } + + if (!Array.isArray(points)) + { + throw new Error('GetCentroid points argument must be an array'); + } + + var len = points.length; + + if (len < 1) + { + throw new Error('GetCentroid points array must not be empty'); + } + else if (len === 1) + { + out.x = points[0].x; + out.y = points[0].y; + } + else + { + for (var i = 0; i < len; i++) + { + out.x += points[i].x; + out.y += points[i].y; + } + + out.x /= len; + out.y /= len; + } + + return out; +}; + +module.exports = GetCentroid; + + +/***/ }), +/* 670 */ /***/ (function(module, exports) { /** @@ -90973,25 +119958,444 @@ module.exports = GetMagnitudeSq; */ /** - * [description] + * Apply `Math.ceil()` to each coordinate of the given Point. * - * @function Phaser.Geom.Point.GetMagnitude + * @function Phaser.Geom.Point.Floor * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] + * @generic {Phaser.Geom.Point} O - [point,$return] * - * @return {number} [description] + * @param {Phaser.Geom.Point} point - The Point to floor. + * + * @return {Phaser.Geom.Point} The Point with `Math.floor()` applied to its coordinates. */ -var GetMagnitude = function (point) +var Floor = function (point) { - return Math.sqrt((point.x * point.x) + (point.y * point.y)); + return point.setTo(Math.floor(point.x), Math.floor(point.y)); }; -module.exports = GetMagnitude; +module.exports = Floor; /***/ }), -/* 393 */ +/* 671 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A comparison of two `Point` objects to see if they are equal. + * + * @function Phaser.Geom.Point.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - The original `Point` to compare against. + * @param {Phaser.Geom.Point} toCompare - The second `Point` to compare. + * + * @return {boolean} Returns true if the both `Point` objects are equal. + */ +var Equals = function (point, toCompare) +{ + return (point.x === toCompare.x && point.y === toCompare.y); +}; + +module.exports = Equals; + + +/***/ }), +/* 672 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one Point to a destination Point. + * + * @function Phaser.Geom.Point.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [dest,$return] + * + * @param {Phaser.Geom.Point} source - The source Point to copy the values from. + * @param {Phaser.Geom.Point} dest - The destination Point to copy the values to. + * + * @return {Phaser.Geom.Point} The destination Point. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 673 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Clone the given Point. + * + * @function Phaser.Geom.Point.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} source - The source Point to clone. + * + * @return {Phaser.Geom.Point} The cloned Point. + */ +var Clone = function (source) +{ + return new Point(source.x, source.y); +}; + +module.exports = Clone; + + +/***/ }), +/* 674 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Apply `Math.ceil()` to each coordinate of the given Point. + * + * @function Phaser.Geom.Point.Ceil + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} point - The Point to ceil. + * + * @return {Phaser.Geom.Point} The Point with `Math.ceil()` applied to its coordinates. + */ +var Ceil = function (point) +{ + return point.setTo(Math.ceil(point.x), Math.ceil(point.y)); +}; + +module.exports = Ceil; + + +/***/ }), +/* 675 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +Point.Ceil = __webpack_require__(674); +Point.Clone = __webpack_require__(673); +Point.CopyFrom = __webpack_require__(672); +Point.Equals = __webpack_require__(671); +Point.Floor = __webpack_require__(670); +Point.GetCentroid = __webpack_require__(669); +Point.GetMagnitude = __webpack_require__(267); +Point.GetMagnitudeSq = __webpack_require__(266); +Point.GetRectangleFromPoints = __webpack_require__(668); +Point.Interpolate = __webpack_require__(667); +Point.Invert = __webpack_require__(666); +Point.Negative = __webpack_require__(665); +Point.Project = __webpack_require__(664); +Point.ProjectUnit = __webpack_require__(663); +Point.SetMagnitude = __webpack_require__(662); + +module.exports = Point; + + +/***/ }), +/* 676 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the width of the given line. + * + * @function Phaser.Geom.Line.Width + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the width of. + * + * @return {number} The width of the line. + */ +var Width = function (line) +{ + return Math.abs(line.x1 - line.x2); +}; + +module.exports = Width; + + +/***/ }), +/* 677 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the slope of the given line. + * + * @function Phaser.Geom.Line.Slope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the slope of. + * + * @return {number} The slope of the line. + */ +var Slope = function (line) +{ + return (line.y2 - line.y1) / (line.x2 - line.x1); +}; + +module.exports = Slope; + + +/***/ }), +/* 678 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Set a line to a given position, angle and length. + * + * @function Phaser.Geom.Line.SetToAngle + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to set. + * @param {number} x - The horizontal start position of the line. + * @param {number} y - The vertical start position of the line. + * @param {number} angle - The angle of the line in radians. + * @param {number} length - The length of the line. + * + * @return {Phaser.Geom.Line} The updated line. + */ +var SetToAngle = function (line, x, y, angle, length) +{ + line.x1 = x; + line.y1 = y; + + line.x2 = x + (Math.cos(angle) * length); + line.y2 = y + (Math.sin(angle) * length); + + return line; +}; + +module.exports = SetToAngle; + + +/***/ }), +/* 679 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(146); + +/** + * Rotate a line around a point by the given angle in radians. + * + * @function Phaser.Geom.Line.RotateAroundPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {(Phaser.Geom.Point|object)} point - The point to rotate the line around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var RotateAroundPoint = function (line, point, angle) +{ + return RotateAroundXY(line, point.x, point.y, angle); +}; + +module.exports = RotateAroundPoint; + + +/***/ }), +/* 680 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(146); + +/** + * Rotate a line around its midpoint by the given angle in radians. + * + * @function Phaser.Geom.Line.Rotate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var Rotate = function (line, angle) +{ + var x = (line.x1 + line.x2) / 2; + var y = (line.y1 + line.y2) / 2; + + return RotateAroundXY(line, x, y, angle); +}; + +module.exports = Rotate; + + +/***/ }), +/* 681 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Angle = __webpack_require__(68); +var NormalAngle = __webpack_require__(268); + +/** + * Calculate the reflected angle between two lines. + * + * This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. + * + * @function Phaser.Geom.Line.ReflectAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} lineA - The first line. + * @param {Phaser.Geom.Line} lineB - The second line. + * + * @return {number} The reflected angle between each line. + */ +var ReflectAngle = function (lineA, lineB) +{ + return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); +}; + +module.exports = ReflectAngle; + + +/***/ }), +/* 682 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the perpendicular slope of the given line. + * + * @function Phaser.Geom.Line.PerpSlope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the perpendicular slope of. + * + * @return {number} The perpendicular slope of the line. + */ +var PerpSlope = function (line) +{ + return -((line.x2 - line.x1) / (line.y2 - line.y1)); +}; + +module.exports = PerpSlope; + + +/***/ }), +/* 683 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offset a line by the given amount. + * + * @function Phaser.Geom.Line.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to offset. + * @param {number} x - The horizontal offset to add to the line. + * @param {number} y - The vertical offset to add to the line. + * + * @return {Phaser.Geom.Line} The offset line. + */ +var Offset = function (line, x, y) +{ + line.x1 += x; + line.y1 += y; + + line.x2 += x; + line.y2 += y; + + return line; +}; + +module.exports = Offset; + + +/***/ }), +/* 684 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91001,31 +120405,59 @@ module.exports = GetMagnitude; */ var MATH_CONST = __webpack_require__(16); -var Wrap = __webpack_require__(39); -var Angle = __webpack_require__(82); +var Angle = __webpack_require__(68); /** * [description] * - * @function Phaser.Geom.Line.NormalAngle + * @function Phaser.Geom.Line.NormalY * @since 3.0.0 * * @param {Phaser.Geom.Line} line - [description] * * @return {number} [description] */ -var NormalAngle = function (line) +var NormalY = function (line) { - var angle = Angle(line) - MATH_CONST.TAU; - - return Wrap(angle, -Math.PI, Math.PI); + return Math.sin(Angle(line) - MATH_CONST.TAU); }; -module.exports = NormalAngle; +module.exports = NormalY; /***/ }), -/* 394 */ +/* 685 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(68); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalX + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The Line object to get the normal value from. + * + * @return {number} [description] + */ +var NormalX = function (line) +{ + return Math.cos(Angle(line) - MATH_CONST.TAU); +}; + +module.exports = NormalX; + + +/***/ }), +/* 686 */ /***/ (function(module, exports) { /** @@ -91034,33 +120466,491 @@ module.exports = NormalAngle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** + * Calculate the height of the given line. + * + * @function Phaser.Geom.Line.Height + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the height of. + * + * @return {number} The height of the line. + */ +var Height = function (line) +{ + return Math.abs(line.y1 - line.y2); +}; + +module.exports = Height; + + +/***/ }), +/* 687 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(68); +var Point = __webpack_require__(6); + +/** + * Calculate the normal of the given line. + * + * The normal of a line is a vector that points perpendicular from it. + * + * @function Phaser.Geom.Line.GetNormal + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to calculate the normal of. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point object to store the normal in. + * + * @return {(Phaser.Geom.Point|object)} The normal of the Line. + */ +var GetNormal = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + var a = Angle(line) - MATH_CONST.TAU; + + out.x = Math.cos(a); + out.y = Math.sin(a); + + return out; +}; + +module.exports = GetNormal; + + +/***/ }), +/* 688 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Get the midpoint of the given line. + * + * @function Phaser.Geom.Line.GetMidPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to get the midpoint of. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point object to store the midpoint in. + * + * @return {(Phaser.Geom.Point|object)} The midpoint of the Line. + */ +var GetMidPoint = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (line.x1 + line.x2) / 2; + out.y = (line.y1 + line.y2) / 2; + + return out; +}; + +module.exports = GetMidPoint; + + +/***/ }), +/* 689 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compare two lines for strict equality. + * + * @function Phaser.Geom.Line.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The first line to compare. + * @param {Phaser.Geom.Line} toCompare - The second line to compare. + * + * @return {boolean} Whether the two lines are equal. + */ +var Equals = function (line, toCompare) +{ + return ( + line.x1 === toCompare.x1 && + line.y1 === toCompare.y1 && + line.x2 === toCompare.x2 && + line.y2 === toCompare.y2 + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 690 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one line to a destination line. + * + * @function Phaser.Geom.Line.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [dest,$return] + * + * @param {Phaser.Geom.Line} source - The source line to copy the values from. + * @param {Phaser.Geom.Line} dest - The destination line to copy the values to. + * + * @return {Phaser.Geom.Line} The destination line. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 691 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(54); + +/** + * Clone the given line. + * + * @function Phaser.Geom.Line.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} source - The source line to clone. + * + * @return {Phaser.Geom.Line} The cloned line. + */ +var Clone = function (source) +{ + return new Line(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = Clone; + + +/***/ }), +/* 692 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + + +/** + * Center a line on the given coordinates. + * + * @function Phaser.Geom.Line.CenterOn + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to center. + * @param {number} x - The horizontal coordinate to center the line on. + * @param {number} y - The vertical coordinate to center the line on. + * + * @return {Phaser.Geom.Line} The centered line. + */ +var CenterOn = function (line, x, y) +{ + var tx = x - ((line.x1 + line.x2) / 2); + var ty = y - ((line.y1 + line.y2) / 2); + + line.x1 += tx; + line.y1 += ty; + + line.x2 += tx; + line.y2 += ty; + + return line; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 693 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(54); + +Line.Angle = __webpack_require__(68); +Line.BresenhamPoints = __webpack_require__(385); +Line.CenterOn = __webpack_require__(692); +Line.Clone = __webpack_require__(691); +Line.CopyFrom = __webpack_require__(690); +Line.Equals = __webpack_require__(689); +Line.GetMidPoint = __webpack_require__(688); +Line.GetNormal = __webpack_require__(687); +Line.GetPoint = __webpack_require__(397); +Line.GetPoints = __webpack_require__(189); +Line.Height = __webpack_require__(686); +Line.Length = __webpack_require__(65); +Line.NormalAngle = __webpack_require__(268); +Line.NormalX = __webpack_require__(685); +Line.NormalY = __webpack_require__(684); +Line.Offset = __webpack_require__(683); +Line.PerpSlope = __webpack_require__(682); +Line.Random = __webpack_require__(188); +Line.ReflectAngle = __webpack_require__(681); +Line.Rotate = __webpack_require__(680); +Line.RotateAroundPoint = __webpack_require__(679); +Line.RotateAroundXY = __webpack_require__(146); +Line.SetToAngle = __webpack_require__(678); +Line.Slope = __webpack_require__(677); +Line.Width = __webpack_require__(676); + +module.exports = Line; + + +/***/ }), +/* 694 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ContainsArray = __webpack_require__(147); +var Decompose = __webpack_require__(269); +var LineToLine = __webpack_require__(107); + /** * [description] * - * @function Phaser.Geom.Triangle.Decompose + * @function Phaser.Geom.Intersects.TriangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangleA - [description] + * @param {Phaser.Geom.Triangle} triangleB - [description] + * + * @return {boolean} [description] + */ +var TriangleToTriangle = function (triangleA, triangleB) +{ + // First the cheapest ones: + + if ( + triangleA.left > triangleB.right || + triangleA.right < triangleB.left || + triangleA.top > triangleB.bottom || + triangleA.bottom < triangleB.top) + { + return false; + } + + var lineAA = triangleA.getLineA(); + var lineAB = triangleA.getLineB(); + var lineAC = triangleA.getLineC(); + + var lineBA = triangleB.getLineA(); + var lineBB = triangleB.getLineB(); + var lineBC = triangleB.getLineC(); + + // Now check the lines against each line of TriangleB + if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) + { + return true; + } + + if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) + { + return true; + } + + if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) + { + return true; + } + + // Nope, so check to see if any of the points of triangleA are within triangleB + + var points = Decompose(triangleA); + var within = ContainsArray(triangleB, points, true); + + if (within.length > 0) + { + return true; + } + + // Finally check to see if any of the points of triangleB are within triangleA + + points = Decompose(triangleB); + within = ContainsArray(triangleA, points, true); + + if (within.length > 0) + { + return true; + } + + return false; +}; + +module.exports = TriangleToTriangle; + + +/***/ }), +/* 695 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(69); +var LineToLine = __webpack_require__(107); + +/** + * Checks if a Triangle and a Line intersect. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". + * + * @function Phaser.Geom.Intersects.TriangleToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check with. + * @param {Phaser.Geom.Line} line - The Line to check with. + * + * @return {boolean} `true` if the Triangle and the Line intersect, otherwise `false`. + */ +var TriangleToLine = function (triangle, line) +{ + // If the Triangle contains either the start or end point of the line, it intersects + if (Contains(triangle, line.getPointA()) || Contains(triangle, line.getPointB())) + { + return true; + } + + // Now check the line against each line of the Triangle + if (LineToLine(triangle.getLineA(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineB(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineC(), line)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToLine; + + +/***/ }), +/* 696 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineToCircle = __webpack_require__(272); +var Contains = __webpack_require__(69); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToCircle * @since 3.0.0 * * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {array} [out] - [description] + * @param {Phaser.Geom.Circle} circle - [description] * - * @return {array} [description] + * @return {boolean} [description] */ -var Decompose = function (triangle, out) +var TriangleToCircle = function (triangle, circle) { - if (out === undefined) { out = []; } + // First the cheapest ones: - out.push({ x: triangle.x1, y: triangle.y1 }); - out.push({ x: triangle.x2, y: triangle.y2 }); - out.push({ x: triangle.x3, y: triangle.y3 }); + if ( + triangle.left > circle.right || + triangle.right < circle.left || + triangle.top > circle.bottom || + triangle.bottom < circle.top) + { + return false; + } - return out; + if (Contains(triangle, circle.x, circle.y)) + { + return true; + } + + if (LineToCircle(triangle.getLineA(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineB(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineC(), circle)) + { + return true; + } + + return false; }; -module.exports = Decompose; +module.exports = TriangleToCircle; /***/ }), -/* 395 */ +/* 697 */ /***/ (function(module, exports) { /** @@ -91072,32 +120962,36 @@ module.exports = Decompose; /** * [description] * - * @function Phaser.Geom.Rectangle.Decompose + * @function Phaser.Geom.Intersects.RectangleToValues * @since 3.0.0 * * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {array} [out] - [description] + * @param {number} left - [description] + * @param {number} right - [description] + * @param {number} top - [description] + * @param {number} bottom - [description] + * @param {number} [tolerance=0] - [description] * - * @return {array} [description] + * @return {boolean} [description] */ -var Decompose = function (rect, out) +var RectangleToValues = function (rect, left, right, top, bottom, tolerance) { - if (out === undefined) { out = []; } + if (tolerance === undefined) { tolerance = 0; } - out.push({ x: rect.x, y: rect.y }); - out.push({ x: rect.right, y: rect.y }); - out.push({ x: rect.right, y: rect.bottom }); - out.push({ x: rect.x, y: rect.bottom }); - - return out; + return !( + left > rect.right + tolerance || + right < rect.left - tolerance || + top > rect.bottom + tolerance || + bottom < rect.top - tolerance + ); }; -module.exports = Decompose; +module.exports = RectangleToValues; /***/ }), -/* 396 */ -/***/ (function(module, exports) { +/* 698 */ +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -91105,10 +120999,105 @@ module.exports = Decompose; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var LineToLine = __webpack_require__(107); +var Contains = __webpack_require__(39); +var ContainsArray = __webpack_require__(147); +var Decompose = __webpack_require__(270); + +/** + * Checks for intersection between Rectangle shape and Triangle shape. + * + * @function Phaser.Geom.Intersects.RectangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - Rectangle object to test. + * @param {Phaser.Geom.Triangle} triangle - Triangle object to test. + * + * @return {boolean} A value of `true` if objects intersect; otherwise `false`. + */ +var RectangleToTriangle = function (rect, triangle) +{ + // First the cheapest ones: + + if ( + triangle.left > rect.right || + triangle.right < rect.left || + triangle.top > rect.bottom || + triangle.bottom < rect.top) + { + return false; + } + + var triA = triangle.getLineA(); + var triB = triangle.getLineB(); + var triC = triangle.getLineC(); + + // Are any of the triangle points within the rectangle? + + if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) + { + return true; + } + + if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) + { + return true; + } + + if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) + { + return true; + } + + // Cheap tests over, now to see if any of the lines intersect ... + + var rectA = rect.getLineA(); + var rectB = rect.getLineB(); + var rectC = rect.getLineC(); + var rectD = rect.getLineD(); + + if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) + { + return true; + } + + if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) + { + return true; + } + + if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) + { + return true; + } + + // None of the lines intersect, so are any rectangle points within the triangle? + + var points = Decompose(rect); + var within = ContainsArray(triangle, points, true); + + return (within.length > 0); +}; + +module.exports = RectangleToTriangle; + + +/***/ }), +/* 699 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PointToLine = __webpack_require__(271); + /** * [description] * - * @function Phaser.Geom.Intersects.PointToLine + * @function Phaser.Geom.Intersects.PointToLineSegment * @since 3.0.0 * * @param {Phaser.Geom.Point} point - [description] @@ -91116,16 +121105,127 @@ module.exports = Decompose; * * @return {boolean} [description] */ -var PointToLine = function (point, line) +var PointToLineSegment = function (point, line) { - return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); + if (!PointToLine(point, line)) + { + return false; + } + + var xMin = Math.min(line.x1, line.x2); + var xMax = Math.max(line.x1, line.x2); + var yMin = Math.min(line.y1, line.y2); + var yMax = Math.max(line.y1, line.y2); + + return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); }; -module.exports = PointToLine; +module.exports = PointToLineSegment; /***/ }), -/* 397 */ +/* 700 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like + * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. + * + * An intersection is considered valid if: + * + * The line starts within, or ends within, the Rectangle. + * The line segment intersects one of the 4 rectangle edges. + * + * The for the purposes of this function rectangles are considered 'solid'. + * + * @function Phaser.Geom.Intersects.LineToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Rectangle|object)} rect - [description] + * + * @return {boolean} [description] + */ +var LineToRectangle = function (line, rect) +{ + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var bx1 = rect.x; + var by1 = rect.y; + var bx2 = rect.right; + var by2 = rect.bottom; + + var t = 0; + + // If the start or end of the line is inside the rect then we assume + // collision, as rects are solid for our use-case. + + if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || + (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) + { + return true; + } + + if (x1 < bx1 && x2 >= bx1) + { + // Left edge + t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); + + if (t > by1 && t <= by2) + { + return true; + } + } + else if (x1 > bx2 && x2 <= bx2) + { + // Right edge + t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); + + if (t >= by1 && t <= by2) + { + return true; + } + } + + if (y1 < by1 && y2 >= by1) + { + // Top edge + t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + else if (y1 > by2 && y2 <= by2) + { + // Bottom edge + t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + + return false; +}; + +module.exports = LineToRectangle; + + +/***/ }), +/* 701 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91134,83 +121234,47 @@ module.exports = PointToLine; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Based on code by Matt DesLauriers -// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md - -var Contains = __webpack_require__(32); -var Point = __webpack_require__(5); - -var tmp = new Point(); +var Rectangle = __webpack_require__(9); +var RectangleToRectangle = __webpack_require__(148); /** - * [description] + * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. + * + * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it wil be empty Rectangle (all values set to zero). + * + * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersetion, it will be returned without any change. * - * @function Phaser.Geom.Intersects.LineToCircle + * @function Phaser.Geom.Intersects.GetRectangleIntersection * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Point} [nearest] - [description] + * @generic {Phaser.Geom.Rectangle} O - [output,$return] * - * @return {boolean} [description] + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle object. + * @param {Phaser.Geom.Rectangle} [output] - Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. + * + * @return {Phaser.Geom.Rectangle} A rectangle object with intersection data. */ -var LineToCircle = function (line, circle, nearest) +var GetRectangleIntersection = function (rectA, rectB, output) { - if (nearest === undefined) { nearest = tmp; } + if (output === undefined) { output = new Rectangle(); } - if (Contains(circle, line.x1, line.y1)) + if (RectangleToRectangle(rectA, rectB)) { - nearest.x = line.x1; - nearest.y = line.y1; - - return true; + output.x = Math.max(rectA.x, rectB.x); + output.y = Math.max(rectA.y, rectB.y); + output.width = Math.min(rectA.right, rectB.right) - output.x; + output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; } - if (Contains(circle, line.x2, line.y2)) - { - nearest.x = line.x2; - nearest.y = line.y2; - - return true; - } - - var dx = line.x2 - line.x1; - var dy = line.y2 - line.y1; - - var lcx = circle.x - line.x1; - var lcy = circle.y - line.y1; - - // project lc onto d, resulting in vector p - var dLen2 = (dx * dx) + (dy * dy); - var px = dx; - var py = dy; - - if (dLen2 > 0) - { - var dp = ((lcx * dx) + (lcy * dy)) / dLen2; - - px *= dp; - py *= dp; - } - - nearest.x = line.x1 + px; - nearest.y = line.y1 + py; - - // len2 of p - var pLen2 = (px * px) + (py * py); - - return ( - pLen2 <= dLen2 && - ((px * dx) + (py * dy)) >= 0 && - Contains(circle, nearest.x, nearest.y) - ); + return output; }; -module.exports = LineToCircle; +module.exports = GetRectangleIntersection; /***/ }), -/* 398 */ +/* 702 */ /***/ (function(module, exports) { /** @@ -91222,29 +121286,49 @@ module.exports = LineToCircle; /** * [description] * - * @function Phaser.Geom.Intersects.RectangleToRectangle + * @function Phaser.Geom.Intersects.CircleToRectangle * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * * @return {boolean} [description] */ -var RectangleToRectangle = function (rectA, rectB) +var CircleToRectangle = function (circle, rect) { - if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) + var halfWidth = rect.width / 2; + var halfHeight = rect.height / 2; + + var cx = Math.abs(circle.x - rect.x - halfWidth); + var cy = Math.abs(circle.y - rect.y - halfHeight); + var xDist = halfWidth + circle.radius; + var yDist = halfHeight + circle.radius; + + if (cx > xDist || cy > yDist) { return false; } + else if (cx <= halfWidth || cy <= halfHeight) + { + return true; + } + else + { + var xCornerDist = cx - halfWidth; + var yCornerDist = cy - halfHeight; + var xCornerDistSq = xCornerDist * xCornerDist; + var yCornerDistSq = yCornerDist * yCornerDist; + var maxCornerDistSq = circle.radius * circle.radius; - return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); + return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); + } }; -module.exports = RectangleToRectangle; +module.exports = CircleToRectangle; /***/ }), -/* 399 */ +/* 703 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91253,33 +121337,30 @@ module.exports = RectangleToRectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var DistanceBetween = __webpack_require__(52); + /** - * @namespace Phaser.Geom.Intersects + * Checks if two Circles intersect. + * + * @function Phaser.Geom.Intersects.CircleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circleA - The first Circle to check for intersection. + * @param {Phaser.Geom.Circle} circleB - The second Circle to check for intersection. + * + * @return {boolean} `true` if the two Circles intersect, otherwise `false`. */ - -module.exports = { - - CircleToCircle: __webpack_require__(844), - CircleToRectangle: __webpack_require__(843), - GetRectangleIntersection: __webpack_require__(842), - LineToCircle: __webpack_require__(397), - LineToLine: __webpack_require__(144), - LineToRectangle: __webpack_require__(841), - PointToLine: __webpack_require__(396), - PointToLineSegment: __webpack_require__(840), - RectangleToRectangle: __webpack_require__(398), - RectangleToTriangle: __webpack_require__(839), - RectangleToValues: __webpack_require__(838), - TriangleToCircle: __webpack_require__(837), - TriangleToLine: __webpack_require__(836), - TriangleToTriangle: __webpack_require__(835) - +var CircleToCircle = function (circleA, circleB) +{ + return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); }; +module.exports = CircleToCircle; + /***/ }), -/* 400 */ -/***/ (function(module, exports, __webpack_require__) { +/* 704 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -91288,25 +121369,666 @@ module.exports = { */ /** - * @namespace Phaser.Geom + * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. + * + * @function Phaser.Geom.Ellipse.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. */ +var OffsetPoint = function (ellipse, point) +{ + ellipse.x += point.x; + ellipse.y += point.y; -module.exports = { - - Circle: __webpack_require__(854), - Ellipse: __webpack_require__(249), - Intersects: __webpack_require__(399), - Line: __webpack_require__(834), - Point: __webpack_require__(816), - Polygon: __webpack_require__(802), - Rectangle: __webpack_require__(389), - Triangle: __webpack_require__(774) - + return ellipse; }; +module.exports = OffsetPoint; + /***/ }), -/* 401 */ +/* 705 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Ellipse by the values given. + * + * @function Phaser.Geom.Ellipse.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Ellipse by. + * @param {number} y - The amount to vertically offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + */ +var Offset = function (ellipse, x, y) +{ + ellipse.x += x; + ellipse.y += y; + + return ellipse; +}; + +module.exports = Offset; + + +/***/ }), +/* 706 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Returns the bounds of the Ellipse object. + * + * @function Phaser.Geom.Ellipse.GetBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Ellipse bounds. + */ +var GetBounds = function (ellipse, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = ellipse.left; + out.y = ellipse.top; + out.width = ellipse.width; + out.height = ellipse.height; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }), +/* 707 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Ellipse.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. + * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. + * + * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. + */ +var Equals = function (ellipse, toCompare) +{ + return ( + ellipse.x === toCompare.x && + ellipse.y === toCompare.y && + ellipse.width === toCompare.width && + ellipse.height === toCompare.height + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 708 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse + * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * + * @function Phaser.Geom.Ellipse.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [dest,$return] + * + * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. + * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. + * + * @return {Phaser.Geom.Ellipse} The destination Ellipse. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 709 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(89); + +/** + * Check to see if the Ellipse contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Ellipse.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. + */ +var ContainsRect = function (ellipse, rect) +{ + return ( + Contains(ellipse, rect.x, rect.y) && + Contains(ellipse, rect.right, rect.y) && + Contains(ellipse, rect.x, rect.bottom) && + Contains(ellipse, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 710 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(89); + +/** + * Check to see if the Ellipse contains the given Point object. + * + * @function Phaser.Geom.Ellipse.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. + */ +var ContainsPoint = function (ellipse, point) +{ + return Contains(ellipse, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 711 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(90); + +/** + * Creates a new Ellipse instance based on the values contained in the given source. + * + * @function Phaser.Geom.Ellipse.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. + * + * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. + */ +var Clone = function (source) +{ + return new Ellipse(source.x, source.y, source.width, source.height); +}; + +module.exports = Clone; + + +/***/ }), +/* 712 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the Ellipse. + * + * @function Phaser.Geom.Ellipse.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. + * + * @return {number} The area of the Ellipse. + */ +var Area = function (ellipse) +{ + if (ellipse.isEmpty()) + { + return 0; + } + + // units squared + return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); +}; + +module.exports = Area; + + +/***/ }), +/* 713 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(90); + +Ellipse.Area = __webpack_require__(712); +Ellipse.Circumference = __webpack_require__(306); +Ellipse.CircumferencePoint = __webpack_require__(156); +Ellipse.Clone = __webpack_require__(711); +Ellipse.Contains = __webpack_require__(89); +Ellipse.ContainsPoint = __webpack_require__(710); +Ellipse.ContainsRect = __webpack_require__(709); +Ellipse.CopyFrom = __webpack_require__(708); +Ellipse.Equals = __webpack_require__(707); +Ellipse.GetBounds = __webpack_require__(706); +Ellipse.GetPoint = __webpack_require__(308); +Ellipse.GetPoints = __webpack_require__(307); +Ellipse.Offset = __webpack_require__(705); +Ellipse.OffsetPoint = __webpack_require__(704); +Ellipse.Random = __webpack_require__(185); + +module.exports = Ellipse; + + +/***/ }), +/* 714 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. + * + * @function Phaser.Geom.Circle.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [circle,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var OffsetPoint = function (circle, point) +{ + circle.x += point.x; + circle.y += point.y; + + return circle; +}; + +module.exports = OffsetPoint; + + +/***/ }), +/* 715 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given. + * + * @function Phaser.Geom.Circle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [circle,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Circle by. + * @param {number} y - The amount to vertically offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var Offset = function (circle, x, y) +{ + circle.x += x; + circle.y += y; + + return circle; +}; + +module.exports = Offset; + + +/***/ }), +/* 716 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Returns the bounds of the Circle object. + * + * @function Phaser.Geom.Circle.GetBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Circles bounds. + */ +var GetBounds = function (circle, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = circle.left; + out.y = circle.top; + out.width = circle.diameter; + out.height = circle.diameter; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }), +/* 717 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compares the `x`, `y` and `radius` properties of the two given Circles. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Circle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The first Circle to compare. + * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. + * + * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. + */ +var Equals = function (circle, toCompare) +{ + return ( + circle.x === toCompare.x && + circle.y === toCompare.y && + circle.radius === toCompare.radius + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 718 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copies the `x`, `y` and `radius` properties from the `source` Circle + * into the given `dest` Circle, then returns the `dest` Circle. + * + * @function Phaser.Geom.Circle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [dest,$return] + * + * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. + * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. + * + * @return {Phaser.Geom.Circle} The destination Circle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.radius); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 719 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(40); + +/** + * Check to see if the Circle contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Circle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Circle or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. + */ +var ContainsRect = function (circle, rect) +{ + return ( + Contains(circle, rect.x, rect.y) && + Contains(circle, rect.right, rect.y) && + Contains(circle, rect.x, rect.bottom) && + Contains(circle, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 720 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(40); + +/** + * Check to see if the Circle contains the given Point object. + * + * @function Phaser.Geom.Circle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. + */ +var ContainsPoint = function (circle, point) +{ + return Contains(circle, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 721 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(71); + +/** + * Creates a new Circle instance based on the values contained in the given source. + * + * @function Phaser.Geom.Circle.Clone + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|object)} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. + * + * @return {Phaser.Geom.Circle} A clone of the source Circle. + */ +var Clone = function (source) +{ + return new Circle(source.x, source.y, source.radius); +}; + +module.exports = Clone; + + +/***/ }), +/* 722 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the circle. + * + * @function Phaser.Geom.Circle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. + * + * @return {number} The area of the Circle. + */ +var Area = function (circle) +{ + return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; +}; + +module.exports = Area; + + +/***/ }), +/* 723 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(71); + +Circle.Area = __webpack_require__(722); +Circle.Circumference = __webpack_require__(402); +Circle.CircumferencePoint = __webpack_require__(192); +Circle.Clone = __webpack_require__(721); +Circle.Contains = __webpack_require__(40); +Circle.ContainsPoint = __webpack_require__(720); +Circle.ContainsRect = __webpack_require__(719); +Circle.CopyFrom = __webpack_require__(718); +Circle.Equals = __webpack_require__(717); +Circle.GetBounds = __webpack_require__(716); +Circle.GetPoint = __webpack_require__(405); +Circle.GetPoints = __webpack_require__(403); +Circle.Offset = __webpack_require__(715); +Circle.OffsetPoint = __webpack_require__(714); +Circle.Random = __webpack_require__(191); + +module.exports = Circle; + + +/***/ }), +/* 724 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91316,333 +122038,112 @@ module.exports = { */ var Class = __webpack_require__(0); -var Light = __webpack_require__(402); -var LightPipeline = __webpack_require__(148); -var Utils = __webpack_require__(27); - -/** - * @callback LightForEach - * - * @param {Phaser.GameObjects.Light} light - [description] - */ +var LightsManager = __webpack_require__(275); +var PluginCache = __webpack_require__(15); /** * @classdesc - * [description] + * A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for the Light2D pipeline. * - * @class LightsManager - * @memberOf Phaser.GameObjects + * Available from within a Scene via `this.lights`. + * + * Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method: + * + * ```javascript + * // Enable the Lights Manager because it is disabled by default + * this.lights.enable(); + * + * // Create a Light at [400, 300] with a radius of 200 + * this.lights.addLight(400, 300, 200); + * ``` + * + * For Game Objects to be affected by the Lights when rendered, you will need to set them to use the `Light2D` pipeline like so: + * + * ```javascript + * sprite.setPipeline('Light2D'); + * ``` + * + * @class LightsPlugin + * @extends Phaser.GameObjects.LightsManager + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that this Lights Plugin belongs to. */ -var LightsManager = new Class({ +var LightsPlugin = new Class({ + + Extends: LightsManager, initialize: - function LightsManager () + function LightsPlugin (scene) { /** - * [description] + * A reference to the Scene that this Lights Plugin belongs to. * - * @name Phaser.GameObjects.LightsManager#lightPool - * @type {Phaser.GameObjects.Light[]} - * @default [] + * @name Phaser.GameObjects.LightsPlugin#scene + * @type {Phaser.Scene} * @since 3.0.0 */ - this.lightPool = []; + this.scene = scene; /** - * [description] + * A reference to the Scene's systems. * - * @name Phaser.GameObjects.LightsManager#lights - * @type {Phaser.GameObjects.Light[]} - * @default [] + * @name Phaser.GameObjects.LightsPlugin#systems + * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ - this.lights = []; + this.systems = scene.sys; - /** - * [description] - * - * @name Phaser.GameObjects.LightsManager#culledLights - * @type {Phaser.GameObjects.Light[]} - * @default [] - * @since 3.0.0 - */ - this.culledLights = []; - - /** - * [description] - * - * @name Phaser.GameObjects.LightsManager#ambientColor - * @type {{ r: float, g: float, b: float }} - * @since 3.0.0 - */ - this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; - - /** - * [description] - * - * @name Phaser.GameObjects.LightsManager#active - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.active = false; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#enable - * @since 3.0.0 - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - enable: function () - { - this.active = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#disable - * @since 3.0.0 - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - disable: function () - { - this.active = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.GameObjects.Light[]} [description] - */ - cull: function (camera) - { - var lights = this.lights; - var culledLights = this.culledLights; - var length = lights.length; - var cameraCenterX = camera.x + camera.width / 2.0; - var cameraCenterY = camera.y + camera.height / 2.0; - var cameraRadius = (camera.width + camera.height) / 2.0; - var point = { x: 0, y: 0 }; - var cameraMatrix = camera.matrix; - var viewportHeight = this.systems.game.config.height; - - culledLights.length = 0; - - for (var index = 0; index < length && culledLights.length < LightPipeline.LIGHT_COUNT; ++index) + if (!scene.sys.settings.isBooted) { - var light = lights[index]; - - cameraMatrix.transformPoint(light.x, light.y, point); - - // We'll just use bounding spheres to test - // if lights should be rendered - var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); - var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); - var distance = Math.sqrt(dx * dx + dy * dy); - - if (distance < light.radius + cameraRadius) - { - culledLights.push(lights[index]); - } + scene.sys.events.once('boot', this.boot, this); } - return culledLights; + LightsManager.call(this); }, /** - * [description] + * Boot the Lights Plugin. * - * @method Phaser.GameObjects.LightsManager#forEachLight - * @since 3.0.0 - * - * @param {LightForEach} callback - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - forEachLight: function (callback) - { - if (!callback) - { - return; - } - - var lights = this.lights; - var length = lights.length; - - for (var index = 0; index < length; ++index) - { - callback(lights[index]); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#setAmbientColor - * @since 3.0.0 - * - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - setAmbientColor: function (rgb) - { - var color = Utils.getFloatsFromUintRGB(rgb); - - this.ambientColor.r = color[0]; - this.ambientColor.g = color[1]; - this.ambientColor.b = color[2]; - - return this; - }, - - /** - * Returns the maximum number of Lights allowed to appear at once. - * - * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights - * @since 3.0.0 - * - * @return {integer} [description] - */ - getMaxVisibleLights: function () - { - return 10; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#getLightCount - * @since 3.0.0 - * - * @return {integer} [description] - */ - getLightCount: function () - { - return this.lights.length; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#addLight - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * @param {number} rgb - [description] - * @param {number} intensity - [description] - * - * @return {Phaser.GameObjects.Light} [description] - */ - addLight: function (x, y, radius, rgb, intensity) - { - var color = null; - var light = null; - - x = (x === undefined) ? 0.0 : x; - y = (y === undefined) ? 0.0 : y; - rgb = (rgb === undefined) ? 0xffffff : rgb; - radius = (radius === undefined) ? 100.0 : radius; - intensity = (intensity === undefined) ? 1.0 : intensity; - - color = Utils.getFloatsFromUintRGB(rgb); - light = null; - - if (this.lightPool.length > 0) - { - light = this.lightPool.pop(); - light.set(x, y, radius, color[0], color[1], color[2], intensity); - } - else - { - light = new Light(x, y, radius, color[0], color[1], color[2], intensity); - } - - this.lights.push(light); - - return light; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#removeLight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Light} light - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - removeLight: function (light) - { - var index = this.lights.indexOf(light); - - if (index >= 0) - { - this.lightPool.push(light); - this.lights.splice(index, 1); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#shutdown + * @method Phaser.GameObjects.LightsPlugin#boot * @since 3.0.0 */ - shutdown: function () + boot: function () { - while (this.lights.length > 0) - { - this.lightPool.push(this.lights.pop()); - } + var eventEmitter = this.systems.events; - this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; - this.culledLights.length = 0; - this.lights.length = 0; + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); }, /** - * [description] + * Destroy the Lights Plugin. * - * @method Phaser.GameObjects.LightsManager#destroy + * Cleans up all references. + * + * @method Phaser.GameObjects.LightsPlugin#destroy * @since 3.0.0 */ destroy: function () { this.shutdown(); + + this.scene = undefined; + this.systems = undefined; } }); -module.exports = LightsManager; +PluginCache.register('LightsPlugin', LightsPlugin, 'lights'); + +module.exports = LightsPlugin; /***/ }), -/* 402 */ +/* 725 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91651,257 +122152,48 @@ module.exports = LightsManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Utils = __webpack_require__(27); +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Quad = __webpack_require__(149); /** - * @classdesc - * A 2D point light. + * Creates a new Quad Game Object and returns it. * - * Add these to a scene using the ForwardDiffuseLightPipeline for lighting effects, or just to represent a point light. + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. * - * @class Light - * @memberOf Phaser.GameObjects - * @constructor + * @method Phaser.GameObjects.GameObjectCreator#quad * @since 3.0.0 * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * @param {number} radius - The radius of the light. - * @param {number} r - The red color of the light. A value between 0 and 1. - * @param {number} g - The green color of the light. A value between 0 and 1. - * @param {number} b - The blue color of the light. A value between 0 and 1. - * @param {number} intensity - The intensity of the light. + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. */ -var Light = new Class({ +GameObjectCreator.register('quad', function (config, addToScene) +{ + if (config === undefined) { config = {}; } - initialize: + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); - function Light (x, y, radius, r, g, b, intensity) + var quad = new Quad(this.scene, x, y, key, frame); + + if (addToScene !== undefined) { - /** - * The horizontal position of the light. - * - * @name Phaser.GameObjects.Light#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The vertical position of the light. - * - * @name Phaser.GameObjects.Light#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The radius of the light. - * - * @name Phaser.GameObjects.Light#radius - * @type {number} - * @since 3.0.0 - */ - this.radius = radius; - - /** - * The red color of the light. A value between 0 and 1. - * - * @name Phaser.GameObjects.Light#r - * @type {number} - * @since 3.0.0 - */ - this.r = r; - - /** - * The green color of the light. A value between 0 and 1. - * - * @name Phaser.GameObjects.Light#g - * @type {number} - * @since 3.0.0 - */ - this.g = g; - - /** - * The blue color of the light. A value between 0 and 1. - * - * @name Phaser.GameObjects.Light#b - * @type {number} - * @since 3.0.0 - */ - this.b = b; - - /** - * The intensity of the light. - * - * @name Phaser.GameObjects.Light#intensity - * @type {number} - * @since 3.0.0 - */ - this.intensity = intensity; - - /** - * The horizontal scroll factor of the light. - * - * @name Phaser.GameObjects.Light#scrollFactorX - * @type {number} - * @since 3.0.0 - */ - this.scrollFactorX = 1.0; - - /** - * The vertical scroll factor of the light. - * - * @name Phaser.GameObjects.Light#scrollFactorY - * @type {number} - * @since 3.0.0 - */ - this.scrollFactorY = 1.0; - }, - - /** - * Set the properties of the light. - * - * Sets both horizontal and vertical scroll factor to 1. Use {@link Phaser.GameObjects.Light#setScrollFactor} to set - * the scroll factor. - * - * @method Phaser.GameObjects.Light#set - * @since 3.0.0 - * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * @param {number} radius - The radius of the light. - * @param {number} r - The red color. A value between 0 and 1. - * @param {number} g - The green color. A value between 0 and 1. - * @param {number} b - The blue color. A value between 0 and 1. - * @param {number} intensity - The intensity of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - set: function (x, y, radius, r, g, b, intensity) - { - this.x = x; - this.y = y; - - this.radius = radius; - - this.r = r; - this.g = g; - this.b = b; - - this.intensity = intensity; - - this.scrollFactorX = 1; - this.scrollFactorY = 1; - - return this; - }, - - /** - * Set the scroll factor of the light. - * - * @method Phaser.GameObjects.Light#setScrollFactor - * @since 3.0.0 - * - * @param {number} x - The horizontal scroll factor of the light. - * @param {number} y - The vertical scroll factor of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setScrollFactor: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.scrollFactorX = x; - this.scrollFactorY = y; - - return this; - }, - - /** - * Set the color of the light from a single integer RGB value. - * - * @method Phaser.GameObjects.Light#setColor - * @since 3.0.0 - * - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setColor: function (rgb) - { - var color = Utils.getFloatsFromUintRGB(rgb); - - this.r = color[0]; - this.g = color[1]; - this.b = color[2]; - - return this; - }, - - /** - * Set the intensity of the light. - * - * @method Phaser.GameObjects.Light#setIntensity - * @since 3.0.0 - * - * @param {number} intensity - The intensity of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setIntensity: function (intensity) - { - this.intensity = intensity; - - return this; - }, - - /** - * Set the position of the light. - * - * @method Phaser.GameObjects.Light#setPosition - * @since 3.0.0 - * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setPosition: function (x, y) - { - this.x = x; - this.y = y; - - return this; - }, - - /** - * Set the radius of the light. - * - * @method Phaser.GameObjects.Light#setRadius - * @since 3.0.0 - * - * @param {number} radius - The radius of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setRadius: function (radius) - { - this.radius = radius; - - return this; + config.add = addToScene; } -}); + BuildGameObject(this.scene, quad, config); -module.exports = Light; + return quad; +}); /***/ }), -/* 403 */ +/* 726 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91910,10 +122202,444 @@ module.exports = Light; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BuildGameObject = __webpack_require__(24); +var BuildGameObject = __webpack_require__(28); var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Text = __webpack_require__(110); +var GetAdvancedValue = __webpack_require__(12); +var GetValue = __webpack_require__(4); +var Mesh = __webpack_require__(108); + +/** + * Creates a new Mesh Game Object and returns it. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#mesh + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +GameObjectCreator.register('mesh', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var vertices = GetValue(config, 'vertices', []); + var colors = GetValue(config, 'colors', []); + var alphas = GetValue(config, 'alphas', []); + var uv = GetValue(config, 'uv', []); + + var mesh = new Mesh(this.scene, 0, 0, vertices, uv, colors, alphas, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, mesh, config); + + return mesh; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 727 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Quad = __webpack_require__(149); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Quad Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#quad + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('quad', function (x, y, key, frame) + { + return this.displayList.add(new Quad(this.scene, x, y, key, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 728 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Mesh = __webpack_require__(108); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Mesh Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#mesh + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number[]} vertices - An array containing the vertices data for this Mesh. + * @param {number[]} uv - An array containing the uv data for this Mesh. + * @param {number[]} colors - An array containing the color data for this Mesh. + * @param {number[]} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame) + { + return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, colors, alphas, texture, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 729 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects. + * + * @method Phaser.GameObjects.Mesh#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var MeshCanvasRenderer = function () +{ +}; + +module.exports = MeshCanvasRenderer; + + +/***/ }), +/* 730 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Mesh#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + + var vertices = src.vertices; + var uvs = src.uv; + var colors = src.colors; + var alphas = src.alphas; + + var meshVerticesLength = vertices.length; + var vertexCount = Math.floor(meshVerticesLength * 0.5); + + if (pipeline.vertexCount + vertexCount >= pipeline.vertexCapacity) + { + pipeline.flush(); + } + + pipeline.setTexture2D(texture, 0); + + var vertexViewF32 = pipeline.vertexViewF32; + var vertexViewU32 = pipeline.vertexViewU32; + + var vertexOffset = (pipeline.vertexCount * pipeline.vertexComponentCount) - 1; + + var colorIndex = 0; + var tintEffect = src.tintFill; + + for (var i = 0; i < meshVerticesLength; i += 2) + { + var x = vertices[i + 0]; + var y = vertices[i + 1]; + + var tx = x * calcMatrix.a + y * calcMatrix.c + calcMatrix.e; + var ty = x * calcMatrix.b + y * calcMatrix.d + calcMatrix.f; + + if (camera.roundPixels) + { + tx |= 0; + ty |= 0; + } + + vertexViewF32[++vertexOffset] = tx; + vertexViewF32[++vertexOffset] = ty; + vertexViewF32[++vertexOffset] = uvs[i + 0]; + vertexViewF32[++vertexOffset] = uvs[i + 1]; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = Utils.getTintAppendFloatAlpha(colors[colorIndex], camera.alpha * alphas[colorIndex]); + + colorIndex++; + } + + pipeline.vertexCount += vertexCount; +}; + +module.exports = MeshWebGLRenderer; + + +/***/ }), +/* 731 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(730); +} + +if (true) +{ + renderCanvas = __webpack_require__(729); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 732 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Zone = __webpack_require__(125); + +/** + * Creates a new Zone Game Object and returns it. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#zone + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectCreator.register('zone', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 1); + var height = GetAdvancedValue(config, 'height', width); + + return new Zone(this.scene, x, y, width, height); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 733 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var TileSprite = __webpack_require__(152); + +/** + * @typedef {object} TileSprite + * @extends GameObjectConfig + * + * @property {number} [x=0] - The x coordinate of the Tile Sprite. + * @property {number} [y=0] - The y coordinate of the Tile Sprite. + * @property {integer} [width=512] - The width of the Tile Sprite. If zero it will use the size of the texture frame. + * @property {integer} [height=512] - The height of the Tile Sprite. If zero it will use the size of the texture frame. + * @property {string} [key=''] - The key of the Texture this Tile Sprite will use to render with, as stored in the Texture Manager. + * @property {string} [frame=''] - An optional frame from the Texture this Tile Sprite is rendering with. + */ + +/** + * Creates a new TileSprite Game Object and returns it. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tileSprite + * @since 3.0.0 + * + * @param {TileSprite} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectCreator.register('tileSprite', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 512); + var height = GetAdvancedValue(config, 'height', 512); + var key = GetAdvancedValue(config, 'key', ''); + var frame = GetAdvancedValue(config, 'frame', ''); + + var tile = new TileSprite(this.scene, x, y, width, height, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, tile, config); + + return tile; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 734 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Text = __webpack_require__(153); /** * Creates a new Text Game Object and returns it. @@ -91988,7 +122714,7 @@ GameObjectCreator.register('text', function (config, addToScene) /***/ }), -/* 404 */ +/* 735 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91997,11 +122723,72 @@ GameObjectCreator.register('text', function (config, addToScene) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BuildGameObject = __webpack_require__(24); -var BuildGameObjectAnimation = __webpack_require__(127); +var BitmapText = __webpack_require__(109); +var BuildGameObject = __webpack_require__(28); var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Sprite = __webpack_require__(34); +var GetAdvancedValue = __webpack_require__(12); +var GetValue = __webpack_require__(4); + +/** + * Creates a new Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#bitmapText + * @since 3.0.0 + * + * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectCreator.register('bitmapText', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var font = GetValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + var align = GetValue(config, 'align', 0); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 736 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var BuildGameObjectAnimation = __webpack_require__(311); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Sprite = __webpack_require__(61); + +/** + * @typedef {object} SpriteConfig + * @extends GameObjectConfig + * + * @property {string} [key] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @property {(number|string)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ /** * Creates a new Sprite Game Object and returns it. @@ -92011,7 +122798,7 @@ var Sprite = __webpack_require__(34); * @method Phaser.GameObjects.GameObjectCreator#sprite * @since 3.0.0 * - * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {SpriteConfig} config - The configuration object this Game Object will use to create itself. * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. * * @return {Phaser.GameObjects.Sprite} The Game Object that was created. @@ -92041,7 +122828,7 @@ GameObjectCreator.register('sprite', function (config, addToScene) /***/ }), -/* 405 */ +/* 737 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -92050,10 +122837,126 @@ GameObjectCreator.register('sprite', function (config, addToScene) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BuildGameObject = __webpack_require__(24); +var BuildGameObject = __webpack_require__(28); var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Image = __webpack_require__(69); +var GetAdvancedValue = __webpack_require__(12); +var RenderTexture = __webpack_require__(154); + +/** + * @typedef {object} RenderTextureConfig + * + * @property {number} [x=0] - The x coordinate of the RenderTexture's position. + * @property {number} [y=0] - The y coordinate of the RenderTexture's position. + * @property {number} [width=32] - The width of the RenderTexture. + * @property {number} [height=32] - The height of the RenderTexture. + */ + +/** + * Creates a new Render Texture Game Object and returns it. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#renderTexture + * @since 3.2.0 + * + * @param {RenderTextureConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectCreator.register('renderTexture', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 32); + var height = GetAdvancedValue(config, 'height', 32); + + var renderTexture = new RenderTexture(this.scene, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, renderTexture, config); + + return renderTexture; +}); + + +/***/ }), +/* 738 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var GetFastValue = __webpack_require__(2); +var ParticleEmitterManager = __webpack_require__(155); + +/** + * Creates a new Particle Emitter Manager Game Object and returns it. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#particles + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectCreator.register('particles', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var emitters = GetFastValue(config, 'emitters', null); + + // frame is optional and can contain the emitters array or object if skipped + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + var add = GetFastValue(config, 'add', false); + + if (add) + { + this.displayList.add(manager); + } + + this.updateList.add(manager); + + return manager; +}); + + +/***/ }), +/* 739 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Image = __webpack_require__(87); /** * Creates a new Image Game Object and returns it. @@ -92091,7 +122994,7 @@ GameObjectCreator.register('image', function (config, addToScene) /***/ }), -/* 406 */ +/* 740 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -92101,7 +123004,40 @@ GameObjectCreator.register('image', function (config, addToScene) */ var GameObjectCreator = __webpack_require__(13); -var Graphics = __webpack_require__(115); +var Group = __webpack_require__(88); + +/** + * Creates a new Group Game Object and returns it. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#group + * @since 3.0.0 + * + * @param {GroupConfig} config - The configuration object this Game Object will use to create itself. + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectCreator.register('group', function (config) +{ + return new Group(this.scene, null, config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 741 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(13); +var Graphics = __webpack_require__(158); /** * Creates a new Graphics Game Object and returns it. @@ -92139,7 +123075,7 @@ GameObjectCreator.register('graphics', function (config, addToScene) /***/ }), -/* 407 */ +/* 742 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -92148,11 +123084,865 @@ GameObjectCreator.register('graphics', function (config, addToScene) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Text = __webpack_require__(110); -var GameObjectFactory = __webpack_require__(11); +var BitmapText = __webpack_require__(159); +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); + +/** + * @typedef {object} BitmapTextConfig + * @extends GameObjectConfig + * + * @property {string} [font=''] - The key of the font to use from the BitmapFont cache. + * @property {string} [text=''] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @property {(number|false)} [size=false] - The font size to set. + */ + +/** + * Creates a new Dynamic Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText + * @since 3.0.0 + *² + * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectCreator.register('dynamicBitmapText', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var font = GetAdvancedValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 743 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var Container = __webpack_require__(160); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); + +/** + * Creates a new Container Game Object and returns it. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#container + * @since 3.4.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Container} The Game Object that was created. + */ +GameObjectCreator.register('container', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + + var container = new Container(this.scene, x, y); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, container, config); + + return container; +}); + + +/***/ }), +/* 744 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(161); +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); + +/** + * Creates a new Blitter Game Object and returns it. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#blitter + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectCreator.register('blitter', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var blitter = new Blitter(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, blitter, config); + + return blitter; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 745 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Triangle = __webpack_require__(279); + +/** + * Creates a new Triangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Triangle Game Object has been built into Phaser. + * + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @method Phaser.GameObjects.GameObjectFactory#triangle + * @since 3.13.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 {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Triangle} The Game Object that was created. + */ +GameObjectFactory.register('triangle', function (x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) +{ + return this.displayList.add(new Triangle(this.scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 746 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Star = __webpack_require__(280); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Star Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Star Game Object has been built into Phaser. + * + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#star + * @since 3.13.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 {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star. + * @param {number} [outerRadius=64] - The outer radius of the star. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Star} The Game Object that was created. + */ +GameObjectFactory.register('star', function (x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) +{ + return this.displayList.add(new Star(this.scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 747 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Rectangle = __webpack_require__(281); + +/** + * Creates a new Rectangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. + * + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @method Phaser.GameObjects.GameObjectFactory#rectangle + * @since 3.13.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 {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Rectangle} The Game Object that was created. + */ +GameObjectFactory.register('rectangle', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Rectangle(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 748 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Polygon = __webpack_require__(286); + +/** + * Creates a new Polygon Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Polygon Game Object has been built into Phaser. + * + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * @method Phaser.GameObjects.GameObjectFactory#polygon + * @since 3.13.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 {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Polygon} The Game Object that was created. + */ +GameObjectFactory.register('polygon', function (x, y, points, fillColor, fillAlpha) +{ + return this.displayList.add(new Polygon(this.scene, x, y, points, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 749 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Line = __webpack_require__(287); + +/** + * Creates a new Line Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Line Game Object has been built into Phaser. + * + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * @method Phaser.GameObjects.GameObjectFactory#line + * @since 3.13.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 {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Line} The Game Object that was created. + */ +GameObjectFactory.register('line', function (x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) +{ + return this.displayList.add(new Line(this.scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha)); +}); + + +/***/ }), +/* 750 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var IsoTriangle = __webpack_require__(288); + +/** + * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. + * + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @method Phaser.GameObjects.GameObjectFactory#isotriangle + * @since 3.13.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 {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + * + * @return {Phaser.GameObjects.IsoTriangle} The Game Object that was created. + */ +GameObjectFactory.register('isotriangle', function (x, y, size, height, reversed, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoTriangle(this.scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight)); +}); + + +/***/ }), +/* 751 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var IsoBox = __webpack_require__(289); + +/** + * Creates a new IsoBox Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. + * + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * + * @method Phaser.GameObjects.GameObjectFactory#isobox + * @since 3.13.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 {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + * + * @return {Phaser.GameObjects.IsoBox} The Game Object that was created. + */ +GameObjectFactory.register('isobox', function (x, y, size, height, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoBox(this.scene, x, y, size, height, fillTop, fillLeft, fillRight)); +}); + + +/***/ }), +/* 752 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Grid = __webpack_require__(290); + +/** + * Creates a new Grid Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Grid Game Object has been built into Phaser. + * + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @method Phaser.GameObjects.GameObjectFactory#grid + * @since 3.13.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 {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [outlineFillColor] - The color of the lines between the grid cells. + * @param {number} [outlineFillAlpha] - The alpha of the lines between the grid cells. + * + * @return {Phaser.GameObjects.Grid} The Game Object that was created. + */ +GameObjectFactory.register('grid', function (x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha) +{ + return this.displayList.add(new Grid(this.scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha)); +}); + + +/***/ }), +/* 753 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(291); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Ellipse Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. + * + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#ellipse + * @since 3.13.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 {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Ellipse} The Game Object that was created. + */ +GameObjectFactory.register('ellipse', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Ellipse(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 754 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Curve = __webpack_require__(292); + +/** + * Creates a new Curve Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Curve Game Object has been built into Phaser. + * + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#curve + * @since 3.13.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 {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Curve} The Game Object that was created. + */ +GameObjectFactory.register('curve', function (x, y, curve, fillColor, fillAlpha) +{ + return this.displayList.add(new Curve(this.scene, x, y, curve, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 755 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Arc = __webpack_require__(293); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Arc Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * @method Phaser.GameObjects.GameObjectFactory#arc + * @since 3.13.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 {number} [radius=128] - The radius of the arc. + * @param {integer} [startAngle=0] - The start angle of the arc, in degrees. + * @param {integer} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - The winding order of the start and end angles. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('arc', function (x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha)); +}); + +/** + * Creates a new Circle Shape Game Object and adds it to the Scene. + * + * A Circle is an Arc with no defined start and end angle, making it render as a complete circle. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#circle + * @since 3.13.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 {number} [radius=128] - The radius of the circle. + * @param {number} [fillColor] - The color the circle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('circle', function (x, y, radius, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, 0, 360, false, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 756 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Zone = __webpack_require__(125); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Zone Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#zone + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectFactory.register('zone', function (x, y, width, height) +{ + return this.displayList.add(new Zone(this.scene, x, y, width, height)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 757 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileSprite = __webpack_require__(152); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new TileSprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tileSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {integer} height - The height of the Game Object. If zero it will use the size of the texture frame. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) +{ + return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 758 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Text = __webpack_require__(153); +var GameObjectFactory = __webpack_require__(5); /** * Creates a new Text Game Object and adds it to the Scene. + * + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. * * Note: This method will only be available if the Text Game Object has been built into Phaser. * @@ -92181,7 +123971,7 @@ GameObjectFactory.register('text', function (x, y, text, style) /***/ }), -/* 408 */ +/* 759 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -92190,8 +123980,72 @@ GameObjectFactory.register('text', function (x, y, text, style) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObjectFactory = __webpack_require__(11); -var Sprite = __webpack_require__(34); +var BitmapText = __webpack_require__(109); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#bitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectFactory.register('bitmapText', function (x, y, font, text, size, align) +{ + return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size, align)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 760 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Sprite = __webpack_require__(61); /** * Creates a new Sprite Game Object and adds it to the Scene. @@ -92228,7 +124082,7 @@ GameObjectFactory.register('sprite', function (x, y, key, frame) /***/ }), -/* 409 */ +/* 761 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -92237,8 +124091,140 @@ GameObjectFactory.register('sprite', function (x, y, key, frame) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Image = __webpack_require__(69); -var GameObjectFactory = __webpack_require__(11); +var GameObjectFactory = __webpack_require__(5); +var RenderTexture = __webpack_require__(154); + +/** + * Creates a new Render Texture Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. + * + * @method Phaser.GameObjects.GameObjectFactory#renderTexture + * @since 3.2.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectFactory.register('renderTexture', function (x, y, width, height) +{ + return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); +}); + + +/***/ }), +/* 762 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var PathFollower = __webpack_require__(296); + +/** + * Creates a new PathFollower Game Object and adds it to the Scene. + * + * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#follower + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. + */ +GameObjectFactory.register('follower', function (path, x, y, key, frame) +{ + var sprite = new PathFollower(this.scene, path, x, y, key, frame); + + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 763 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var ParticleEmitterManager = __webpack_require__(155); + +/** + * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#particles + * @since 3.0.0 + * + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer|object)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {ParticleEmitterConfig|ParticleEmitterConfig[]} [emitters] - Configuration settings for one or more emitters to create. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectFactory.register('particles', function (key, frame, emitters) +{ + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + this.displayList.add(manager); + this.updateList.add(manager); + + return manager; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 764 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Image = __webpack_require__(87); +var GameObjectFactory = __webpack_require__(5); /** * Creates a new Image Game Object and adds it to the Scene. @@ -92270,7 +124256,7 @@ GameObjectFactory.register('image', function (x, y, key, frame) /***/ }), -/* 410 */ +/* 765 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -92279,8 +124265,40 @@ GameObjectFactory.register('image', function (x, y, key, frame) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Graphics = __webpack_require__(115); -var GameObjectFactory = __webpack_require__(11); +var Group = __webpack_require__(88); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Group Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#group + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupConfig[])} [children] - Game Objects to add to this Group; or the `config` argument. + * @param {GroupConfig} [config] - A Group Configuration object. + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectFactory.register('group', function (children, config) +{ + return this.updateList.add(new Group(this.scene, children, config)); +}); + + +/***/ }), +/* 766 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Graphics = __webpack_require__(158); +var GameObjectFactory = __webpack_require__(5); /** * Creates a new Graphics Game Object and adds it to the Scene. @@ -92309,7 +124327,2611 @@ GameObjectFactory.register('graphics', function (config) /***/ }), -/* 411 */ +/* 767 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DynamicBitmapText = __webpack_require__(159); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) +{ + return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 768 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Container = __webpack_require__(160); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Container Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#container + * @since 3.4.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. + * + * @return {Phaser.GameObjects.Container} The Game Object that was created. + */ +GameObjectFactory.register('container', function (x, y, children) +{ + return this.displayList.add(new Container(this.scene, x, y, children)); +}); + + +/***/ }), +/* 769 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(161); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Blitter Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#blitter + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} key - The key of the Texture the Blitter object will use. + * @param {(string|integer)} [frame] - The default Frame children of the Blitter will use. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectFactory.register('blitter', function (x, y, key, frame) +{ + return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 770 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + ctx.beginPath(); + + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.lineTo(x3, y3); + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = TriangleCanvasRenderer; + + +/***/ }), +/* 771 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StrokePathWebGL = __webpack_require__(60); +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + var fillTint = pipeline.fillTint; + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + pipeline.setTexture2D(); + + pipeline.batchFillTriangle( + x1, + y1, + x2, + y2, + x3, + y3, + shapeMatrix, + camMatrix + ); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = TriangleWebGLRenderer; + + +/***/ }), +/* 772 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(771); +} + +if (true) +{ + renderCanvas = __webpack_require__(770); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 773 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = StarCanvasRenderer; + + +/***/ }), +/* 774 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = StarWebGLRenderer; + + +/***/ }), +/* 775 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(774); +} + +if (true) +{ + renderCanvas = __webpack_require__(773); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 776 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.rect( + -dx, + -dy, + src.width, + src.height + ); + + ctx.stroke(); + } + } +}; + +module.exports = RectangleCanvasRenderer; + + +/***/ }), +/* 777 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StrokePathWebGL = __webpack_require__(60); +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + var fillTint = pipeline.fillTint; + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + pipeline.batchFillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = RectangleWebGLRenderer; + + +/***/ }), +/* 778 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(777); +} + +if (true) +{ + renderCanvas = __webpack_require__(776); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 779 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = PolygonCanvasRenderer; + + +/***/ }), +/* 780 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = PolygonWebGLRenderer; + + +/***/ }), +/* 781 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(780); +} + +if (true) +{ + renderCanvas = __webpack_require__(779); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 782 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.moveTo(src.geom.x1 - dx, src.geom.y1 - dy); + ctx.lineTo(src.geom.x2 - dx, src.geom.y2 - dy); + + ctx.stroke(); + } + } +}; + +module.exports = LineCanvasRenderer; + + +/***/ }), +/* 783 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isStroked) + { + var strokeTint = pipeline.strokeTint; + var color = Utils.getTintAppendFloatAlphaAndSwap(src.strokeColor, src.strokeAlpha * alpha); + + strokeTint.TL = color; + strokeTint.TR = color; + strokeTint.BL = color; + strokeTint.BR = color; + + var startWidth = src._startWidth; + var endWidth = src._endWidth; + + pipeline.setTexture2D(); + + pipeline.batchLine( + src.geom.x1 - dx, + src.geom.y1 - dy, + src.geom.x2 - dx, + src.geom.y2 - dy, + startWidth, + endWidth, + 1, + 0, + false, + shapeMatrix, + camMatrix + ); + } +}; + +module.exports = LineWebGLRenderer; + + +/***/ }), +/* 784 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(783); +} + +if (true) +{ + renderCanvas = __webpack_require__(782); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 785 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + // Top Face + + if (src.showTop && reversed) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(0, sizeB - height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + } +}; + +module.exports = IsoTriangleCanvasRenderer; + + +/***/ }), +/* 786 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + var alpha = camera.alpha * src.alpha; + + if (!src.isFilled) + { + return; + } + + var tint; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + // Top Face + + if (src.showTop && reversed) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillTop, alpha); + + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, -sizeB - height); + y1 = calcMatrix.getY(0, -sizeB - height); + + x2 = calcMatrix.getX(sizeA, -height); + y2 = calcMatrix.getY(sizeA, -height); + + var x3 = calcMatrix.getX(0, sizeB - height); + var y3 = calcMatrix.getY(0, sizeB - height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillLeft, alpha); + + if (reversed) + { + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + else + { + x0 = calcMatrix.getX(-sizeA, 0); + y0 = calcMatrix.getY(-sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + + pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillRight, alpha); + + if (reversed) + { + x0 = calcMatrix.getX(sizeA, -height); + y0 = calcMatrix.getY(sizeA, -height); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + else + { + x0 = calcMatrix.getX(sizeA, 0); + y0 = calcMatrix.getY(sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + + pipeline.setTexture2D(); + + pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2); + } +}; + +module.exports = IsoTriangleWebGLRenderer; + + +/***/ }), +/* 787 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(786); +} + +if (true) +{ + renderCanvas = __webpack_require__(785); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 788 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + // Top Face + + if (src.showTop) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, -1); + ctx.lineTo(0, sizeB - 1); + ctx.lineTo(-sizeA, -1); + ctx.lineTo(-sizeA, -height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(-sizeA, -height); + ctx.lineTo(-sizeA, 0); + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, 0); + + ctx.fill(); + } + } +}; + +module.exports = IsoBoxCanvasRenderer; + + +/***/ }), +/* 789 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var alpha = camera.alpha * src.alpha; + + if (!src.isFilled) + { + return; + } + + var tint; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + var x3; + var y3; + + // Top Face + + if (src.showTop) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillTop, alpha); + + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, -sizeB - height); + y1 = calcMatrix.getY(0, -sizeB - height); + + x2 = calcMatrix.getX(sizeA, -height); + y2 = calcMatrix.getY(sizeA, -height); + + x3 = calcMatrix.getX(0, sizeB - height); + y3 = calcMatrix.getY(0, sizeB - height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillLeft, alpha); + + x0 = calcMatrix.getX(-sizeA, 0); + y0 = calcMatrix.getY(-sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + + x3 = calcMatrix.getX(-sizeA, -height); + y3 = calcMatrix.getY(-sizeA, -height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillRight, alpha); + + x0 = calcMatrix.getX(sizeA, 0); + y0 = calcMatrix.getY(sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + + x3 = calcMatrix.getX(sizeA, -height); + y3 = calcMatrix.getY(sizeA, -height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } +}; + +module.exports = IsoBoxWebGLRenderer; + + +/***/ }), +/* 790 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(789); +} + +if (true) +{ + renderCanvas = __webpack_require__(788); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 791 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.rect( + -dx, + -dy, + src.width, + src.height + ); + + ctx.stroke(); + } + } +}; + +module.exports = RectangleCanvasRenderer; + + +/***/ }), +/* 792 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Grid#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Grid} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + calcMatrix.translate(-src._displayOriginX, -src._displayOriginY); + + var alpha = camera.alpha * src.alpha; + + // Work out the grid size + + var width = src.width; + var height = src.height; + + var cellWidth = src.cellWidth; + var cellHeight = src.cellHeight; + + var gridWidth = Math.ceil(width / cellWidth); + var gridHeight = Math.ceil(height / cellHeight); + + var cellWidthA = cellWidth; + var cellHeightA = cellHeight; + + var cellWidthB = cellWidth - ((gridWidth * cellWidth) - width); + var cellHeightB = cellHeight - ((gridHeight * cellHeight) - height); + + var fillTint; + var fillTintColor; + + var showCells = src.showCells; + var showAltCells = src.showAltCells; + var showOutline = src.showOutline; + + var x = 0; + var y = 0; + var r = 0; + var cw = 0; + var ch = 0; + + if (showOutline) + { + // To make room for the grid lines (in case alpha < 1) + cellWidthA--; + cellHeightA--; + + if (cellWidthB === cellWidth) + { + cellWidthB--; + } + + if (cellHeightB === cellHeight) + { + cellHeightB--; + } + } + + if (showCells && src.fillAlpha > 0) + { + fillTint = pipeline.fillTint; + fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && r) + { + r = 0; + continue; + } + + r++; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + pipeline.setTexture2D(); + + pipeline.batchFillRect( + x * cellWidth, + y * cellHeight, + cw, + ch + ); + } + } + } + + if (showAltCells && src.altFillAlpha > 0) + { + fillTint = pipeline.fillTint; + fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.altFillColor, src.altFillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && !r) + { + r = 1; + continue; + } + + r = 0; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + pipeline.setTexture2D(); + + pipeline.batchFillRect( + x * cellWidth, + y * cellHeight, + cw, + ch + ); + } + } + } + + if (showOutline && src.outlineFillAlpha > 0) + { + var strokeTint = pipeline.strokeTint; + var color = Utils.getTintAppendFloatAlphaAndSwap(src.outlineFillColor, src.outlineFillAlpha * alpha); + + strokeTint.TL = color; + strokeTint.TR = color; + strokeTint.BL = color; + strokeTint.BR = color; + + for (x = 1; x < gridWidth; x++) + { + var x1 = x * cellWidth; + + pipeline.setTexture2D(); + + pipeline.batchLine(x1, 0, x1, height, 1, 1, 1, 0, false); + } + + for (y = 1; y < gridHeight; y++) + { + var y1 = y * cellHeight; + + pipeline.setTexture2D(); + + pipeline.batchLine(0, y1, width, y1, 1, 1, 1, 0, false); + } + } +}; + +module.exports = GridWebGLRenderer; + + +/***/ }), +/* 793 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(792); +} + +if (true) +{ + renderCanvas = __webpack_require__(791); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 794 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = EllipseCanvasRenderer; + + +/***/ }), +/* 795 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = EllipseWebGLRenderer; + + +/***/ }), +/* 796 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(795); +} + +if (true) +{ + renderCanvas = __webpack_require__(794); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 797 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = CurveCanvasRenderer; + + +/***/ }), +/* 798 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = CurveWebGLRenderer; + + +/***/ }), +/* 799 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(798); +} + +if (true) +{ + renderCanvas = __webpack_require__(797); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 800 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DegToRad = __webpack_require__(31); +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var radius = src.radius; + + ctx.beginPath(); + + ctx.arc( + (radius) - src.originX * (radius * 2), + (radius) - src.originY * (radius * 2), + radius, + DegToRad(src._startAngle), + DegToRad(src._endAngle), + src.anticlockwise + ); + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = ArcCanvasRenderer; + + +/***/ }), +/* 801 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = ArcWebGLRenderer; + + +/***/ }), +/* 802 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(801); +} + +if (true) +{ + renderCanvas = __webpack_require__(800); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 803 */ /***/ (function(module, exports) { /** @@ -92319,27 +126941,32 @@ GameObjectFactory.register('graphics', function (config) */ /** - * Returns the nearest power of 2 to the given `value`. + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Math.Pow2.GetPowerOfTwo + * @method Phaser.GameObjects.TileSprite#renderCanvas * @since 3.0.0 + * @private * - * @param {number} value - The value. - * - * @return {integer} The nearest power of 2 to `value`. + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var GetPowerOfTwo = function (value) +var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - var index = Math.log(value) / 0.6931471805599453; + src.updateCanvas(); - return (1 << Math.ceil(index)); + renderer.batchSprite(src, src.frame, camera, parentMatrix); }; -module.exports = GetPowerOfTwo; +module.exports = TileSpriteCanvasRenderer; /***/ }), -/* 412 */ +/* 804 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -92348,7 +126975,98 @@ module.exports = GetPowerOfTwo; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CanvasPool = __webpack_require__(22); +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + src.updateCanvas(); + + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + src.fillPattern, + src.displayFrame.width * src.tileScaleX, src.displayFrame.height * src.tileScaleY, + src.x, src.y, + src.width, src.height, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.originX * src.width, src.originY * src.height, + 0, 0, src.width, src.height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + (src.tilePositionX % src.displayFrame.width) / src.displayFrame.width, + (src.tilePositionY % src.displayFrame.height) / src.displayFrame.height, + camera, + parentMatrix + ); +}; + +module.exports = TileSpriteWebGLRenderer; + + +/***/ }), +/* 805 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(804); +} + +if (true) +{ + renderCanvas = __webpack_require__(803); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 806 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(24); /** * Calculates the ascent, descent and fontSize of a given font style. @@ -92474,7 +127192,7 @@ module.exports = MeasureText; /***/ }), -/* 413 */ +/* 807 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -92484,9 +127202,9 @@ module.exports = MeasureText; */ var Class = __webpack_require__(0); -var GetAdvancedValue = __webpack_require__(10); +var GetAdvancedValue = __webpack_require__(12); var GetValue = __webpack_require__(4); -var MeasureText = __webpack_require__(412); +var MeasureText = __webpack_require__(806); // Key: [ Object Key, Default Value ] @@ -92519,6 +127237,7 @@ var propertyMap = { maxLines: [ 'maxLines', 0 ], fixedWidth: [ 'fixedWidth', 0 ], fixedHeight: [ 'fixedHeight', 0 ], + resolution: [ 'resolution', 0 ], rtl: [ 'rtl', false ], testString: [ 'testString', '|MÉqgy' ], baselineX: [ 'baselineX', 1.2 ], @@ -92529,17 +127248,27 @@ var propertyMap = { wordWrapUseAdvanced: [ 'wordWrap.useAdvancedWrap', false ] }; +/** + * Font metrics for a Text Style object. + * + * @typedef {object} BitmapTextMetrics + * + * @property {number} ascent - The ascent of the font. + * @property {number} descent - The descent of the font. + * @property {number} fontSize - The size of the font. + */ + /** * @classdesc - * [description] + * Style settings for a Text object. * * @class TextStyle - * @memberOf Phaser.GameObjects.Text + * @memberof Phaser.GameObjects.Text * @constructor * @since 3.0.0 * * @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling. - * @param {object} style - [description] + * @param {object} style - The style settings to set. */ var TextStyle = new Class({ @@ -92557,7 +127286,7 @@ var TextStyle = new Class({ this.parent = text; /** - * [description] + * The font family. * * @name Phaser.GameObjects.Text.TextStyle#fontFamily * @type {string} @@ -92567,7 +127296,7 @@ var TextStyle = new Class({ this.fontFamily; /** - * [description] + * The font size. * * @name Phaser.GameObjects.Text.TextStyle#fontSize * @type {string} @@ -92577,7 +127306,7 @@ var TextStyle = new Class({ this.fontSize; /** - * [description] + * The font style. * * @name Phaser.GameObjects.Text.TextStyle#fontStyle * @type {string} @@ -92586,7 +127315,7 @@ var TextStyle = new Class({ this.fontStyle; /** - * [description] + * The background color. * * @name Phaser.GameObjects.Text.TextStyle#backgroundColor * @type {string} @@ -92595,7 +127324,7 @@ var TextStyle = new Class({ this.backgroundColor; /** - * [description] + * The text fill color. * * @name Phaser.GameObjects.Text.TextStyle#color * @type {string} @@ -92605,7 +127334,7 @@ var TextStyle = new Class({ this.color; /** - * [description] + * The text stroke color. * * @name Phaser.GameObjects.Text.TextStyle#stroke * @type {string} @@ -92615,7 +127344,7 @@ var TextStyle = new Class({ this.stroke; /** - * [description] + * The text stroke thickness. * * @name Phaser.GameObjects.Text.TextStyle#strokeThickness * @type {number} @@ -92625,7 +127354,7 @@ var TextStyle = new Class({ this.strokeThickness; /** - * [description] + * The horizontal shadow offset. * * @name Phaser.GameObjects.Text.TextStyle#shadowOffsetX * @type {number} @@ -92635,7 +127364,7 @@ var TextStyle = new Class({ this.shadowOffsetX; /** - * [description] + * The vertical shadow offset. * * @name Phaser.GameObjects.Text.TextStyle#shadowOffsetY * @type {number} @@ -92645,7 +127374,7 @@ var TextStyle = new Class({ this.shadowOffsetY; /** - * [description] + * The shadow color. * * @name Phaser.GameObjects.Text.TextStyle#shadowColor * @type {string} @@ -92655,7 +127384,7 @@ var TextStyle = new Class({ this.shadowColor; /** - * [description] + * The shadow blur radius. * * @name Phaser.GameObjects.Text.TextStyle#shadowBlur * @type {number} @@ -92665,7 +127394,7 @@ var TextStyle = new Class({ this.shadowBlur; /** - * [description] + * Whether shadow stroke is enabled or not. * * @name Phaser.GameObjects.Text.TextStyle#shadowStroke * @type {boolean} @@ -92675,7 +127404,7 @@ var TextStyle = new Class({ this.shadowStroke; /** - * [description] + * Whether shadow fill is enabled or not. * * @name Phaser.GameObjects.Text.TextStyle#shadowFill * @type {boolean} @@ -92685,7 +127414,7 @@ var TextStyle = new Class({ this.shadowFill; /** - * [description] + * The text alignment. * * @name Phaser.GameObjects.Text.TextStyle#align * @type {string} @@ -92695,7 +127424,7 @@ var TextStyle = new Class({ this.align; /** - * [description] + * The maximum number of lines to draw. * * @name Phaser.GameObjects.Text.TextStyle#maxLines * @type {integer} @@ -92705,7 +127434,9 @@ var TextStyle = new Class({ this.maxLines; /** - * [description] + * The fixed width of the text. + * + * `0` means no fixed with. * * @name Phaser.GameObjects.Text.TextStyle#fixedWidth * @type {number} @@ -92715,7 +127446,9 @@ var TextStyle = new Class({ this.fixedWidth; /** - * [description] + * The fixed height of the text. + * + * `0` means no fixed height. * * @name Phaser.GameObjects.Text.TextStyle#fixedHeight * @type {number} @@ -92725,7 +127458,18 @@ var TextStyle = new Class({ this.fixedHeight; /** - * [description] + * The resolution the text is rendered to its internal canvas at. + * The default is 0, which means it will use the resolution set in the Game Config. + * + * @name Phaser.GameObjects.Text.TextStyle#resolution + * @type {number} + * @default 0 + * @since 3.12.0 + */ + this.resolution; + + /** + * Whether the text should render right to left. * * @name Phaser.GameObjects.Text.TextStyle#rtl * @type {boolean} @@ -92735,7 +127479,7 @@ var TextStyle = new Class({ this.rtl; /** - * [description] + * The test string to use when measuring the font. * * @name Phaser.GameObjects.Text.TextStyle#testString * @type {string} @@ -92765,7 +127509,7 @@ var TextStyle = new Class({ this.baselineY; /** - * [description] + * The font style, size and family. * * @name Phaser.GameObjects.Text.TextStyle#_font * @type {string} @@ -92775,7 +127519,7 @@ var TextStyle = new Class({ this._font; // Set to defaults + user style - this.setStyle(style, false); + this.setStyle(style, false, true); var metrics = GetValue(style, 'metrics', false); @@ -92796,19 +127540,30 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the text style. + * + * @example + * text.setStyle({ + * fontSize: '64px', + * fontFamily: 'Arial', + * color: '#ffffff', + * align: 'center', + * backgroundColor: '#ff00ff' + * }); * * @method Phaser.GameObjects.Text.TextStyle#setStyle * @since 3.0.0 * - * @param {CSSStyleRule} style - [description] - * @param {boolean} [updateText=true] - [description] + * @param {object} style - The style settings to set. + * @param {boolean} [updateText=true] - Whether to update the text immediately. + * @param {boolean} [setDefaults=false] - Use the default values is not set, or the local values. * * @return {Phaser.GameObjects.Text} The parent Text object. */ - setStyle: function (style, updateText) + setStyle: function (style, updateText, setDefaults) { if (updateText === undefined) { updateText = true; } + if (setDefaults === undefined) { setDefaults = false; } // Avoid type mutation if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number') @@ -92818,14 +127573,16 @@ var TextStyle = new Class({ for (var key in propertyMap) { + var value = (setDefaults) ? propertyMap[key][1] : this[key]; + if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') { // Callback & scope should be set without processing the values - this[key] = GetValue(style, propertyMap[key][0], propertyMap[key][1]); + this[key] = GetValue(style, propertyMap[key][0], value); } else { - this[key] = GetAdvancedValue(style, propertyMap[key][0], propertyMap[key][1]); + this[key] = GetAdvancedValue(style, propertyMap[key][0], value); } } @@ -92834,7 +127591,7 @@ var TextStyle = new Class({ if (font === null) { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); } else { @@ -92860,13 +127617,13 @@ var TextStyle = new Class({ }, /** - * [description] + * Synchronize the font settings to the given Canvas Rendering Context. * * @method Phaser.GameObjects.Text.TextStyle#syncFont * @since 3.0.0 * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] + * @param {HTMLCanvasElement} canvas - The Canvas Element. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. */ syncFont: function (canvas, context) { @@ -92874,13 +127631,13 @@ var TextStyle = new Class({ }, /** - * [description] + * Synchronize the text style settings to the given Canvas Rendering Context. * * @method Phaser.GameObjects.Text.TextStyle#syncStyle * @since 3.0.0 * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] + * @param {HTMLCanvasElement} canvas - The Canvas Element. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. */ syncStyle: function (canvas, context) { @@ -92895,13 +127652,13 @@ var TextStyle = new Class({ }, /** - * [description] + * Synchronize the shadow settings to the given Canvas Rendering Context. * * @method Phaser.GameObjects.Text.TextStyle#syncShadow * @since 3.0.0 * - * @param {CanvasRenderingContext2D} context - [description] - * @param {boolean} enabled - [description] + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {boolean} enabled - Whether shadows are enabled or not. */ syncShadow: function (context, enabled) { @@ -92922,12 +127679,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Update the style settings for the parent Text object. * * @method Phaser.GameObjects.Text.TextStyle#update * @since 3.0.0 * - * @param {boolean} recalculateMetrics - [description] + * @param {boolean} recalculateMetrics - Whether to recalculate font and text metrics. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -92935,7 +127692,7 @@ var TextStyle = new Class({ { if (recalculateMetrics) { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); this.metrics = MeasureText(this); } @@ -92944,74 +127701,96 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. * * @method Phaser.GameObjects.Text.TextStyle#setFont * @since 3.0.0 * - * @param {(string|object)} font - [description] + * @param {(string|object)} font - The font family or font settings to set. * * @return {Phaser.GameObjects.Text} The parent Text object. */ setFont: function (font) { - if (typeof font === 'string') + var fontFamily = font; + var fontSize = ''; + var fontStyle = ''; + + if (typeof font !== 'string') { - this.fontFamily = font; - this.fontSize = ''; - this.fontStyle = ''; - } - else - { - this.fontFamily = GetValue(font, 'fontFamily', 'Courier'); - this.fontSize = GetValue(font, 'fontSize', '16px'); - this.fontStyle = GetValue(font, 'fontStyle', ''); + fontFamily = GetValue(font, 'fontFamily', 'Courier'); + fontSize = GetValue(font, 'fontSize', '16px'); + fontStyle = GetValue(font, 'fontStyle', ''); } - return this.update(true); + if (fontFamily !== this.fontFamily || fontSize !== this.fontSize || fontStyle !== this.fontStyle) + { + this.fontFamily = fontFamily; + this.fontSize = fontSize; + this.fontStyle = fontStyle; + + this.update(true); + } + + return this.parent; }, /** - * [description] + * Set the font family. * * @method Phaser.GameObjects.Text.TextStyle#setFontFamily * @since 3.0.0 * - * @param {string} family - [description] + * @param {string} family - The font family. * * @return {Phaser.GameObjects.Text} The parent Text object. */ setFontFamily: function (family) { - this.fontFamily = family; + if (this.fontFamily !== family) + { + this.fontFamily = family; - return this.update(true); + this.update(true); + } + + return this.parent; }, /** - * [description] + * Set the font style. * * @method Phaser.GameObjects.Text.TextStyle#setFontStyle * @since 3.0.0 * - * @param {string} style - [description] + * @param {string} style - The font style. * * @return {Phaser.GameObjects.Text} The parent Text object. */ setFontStyle: function (style) { - this.fontStyle = style; + if (this.fontStyle !== style) + { + this.fontStyle = style; - return this.update(true); + this.update(true); + } + + return this.parent; }, /** - * [description] + * Set the font size. * * @method Phaser.GameObjects.Text.TextStyle#setFontSize * @since 3.0.0 * - * @param {(number|string)} size - [description] + * @param {(number|string)} size - The font size. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93022,18 +127801,23 @@ var TextStyle = new Class({ size = size.toString() + 'px'; } - this.fontSize = size; + if (this.fontSize !== size) + { + this.fontSize = size; - return this.update(true); + this.update(true); + } + + return this.parent; }, /** - * [description] + * Set the test string to use when measuring the font. * * @method Phaser.GameObjects.Text.TextStyle#setTestString * @since 3.0.0 * - * @param {string} string - [description] + * @param {string} string - The test string to use when measuring the font. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93045,13 +127829,15 @@ var TextStyle = new Class({ }, /** - * [description] + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. * * @method Phaser.GameObjects.Text.TextStyle#setFixedSize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} width - The fixed width to set. + * @param {number} height - The fixed height to set. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93074,12 +127860,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the background color. * * @method Phaser.GameObjects.Text.TextStyle#setBackgroundColor * @since 3.0.0 * - * @param {string} color - [description] + * @param {string} color - The background color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93091,12 +127877,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the text fill color. * * @method Phaser.GameObjects.Text.TextStyle#setFill * @since 3.0.0 * - * @param {string} color - [description] + * @param {string} color - The text fill color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93108,12 +127894,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the text fill color. * * @method Phaser.GameObjects.Text.TextStyle#setColor * @since 3.0.0 * - * @param {string} color - [description] + * @param {string} color - The text fill color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93125,46 +127911,76 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the resolution used by the Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method. It allows for much clearer text on High DPI devices, + * at the cost of memory because it uses larger internal Canvas textures for the Text. + * + * Please use with caution, as the more high res Text you have, the more memory it uses up. + * + * @method Phaser.GameObjects.Text.TextStyle#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setResolution: function (value) + { + this.resolution = value; + + return this.update(false); + }, + + /** + * Set the stroke settings. * * @method Phaser.GameObjects.Text.TextStyle#setStroke * @since 3.0.0 * - * @param {string} color - [description] - * @param {number} thickness - [description] + * @param {string} color - The stroke color. + * @param {number} thickness - The stroke thickness. * * @return {Phaser.GameObjects.Text} The parent Text object. */ setStroke: function (color, thickness) { - if (color === undefined) + if (thickness === undefined) { thickness = this.strokeThickness; } + + if (color === undefined && this.strokeThickness !== 0) { // Reset the stroke to zero (disabling it) this.strokeThickness = 0; - } - else - { - if (thickness === undefined) { thickness = this.strokeThickness; } + this.update(true); + } + else if (this.stroke !== color || this.strokeThickness !== thickness) + { this.stroke = color; this.strokeThickness = thickness; + + this.update(true); } - return this.update(true); + return this.parent; }, /** - * [description] + * Set the shadow settings. + * + * Calling this method always re-measures the parent Text object, + * so only call it when you actually change the shadow settings. * * @method Phaser.GameObjects.Text.TextStyle#setShadow * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {string} [color='#000'] - [description] - * @param {number} [blur=0] - [description] - * @param {boolean} [shadowStroke=false] - [description] - * @param {boolean} [shadowFill=true] - [description] + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * @param {string} [color='#000'] - The shadow color. + * @param {number} [blur=0] - The shadow blur radius. + * @param {boolean} [shadowStroke=false] - Whether to stroke the shadow. + * @param {boolean} [shadowFill=true] - Whether to fill the shadow. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93188,13 +128004,13 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the shadow offset. * * @method Phaser.GameObjects.Text.TextStyle#setShadowOffset * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93210,12 +128026,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the shadow color. * * @method Phaser.GameObjects.Text.TextStyle#setShadowColor * @since 3.0.0 * - * @param {string} [color='#000'] - [description] + * @param {string} [color='#000'] - The shadow color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93229,12 +128045,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the shadow blur radius. * * @method Phaser.GameObjects.Text.TextStyle#setShadowBlur * @since 3.0.0 * - * @param {number} [blur=0] - [description] + * @param {number} [blur=0] - The shadow blur radius. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93248,12 +128064,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Enable or disable shadow stroke. * * @method Phaser.GameObjects.Text.TextStyle#setShadowStroke * @since 3.0.0 * - * @param {boolean} enabled - [description] + * @param {boolean} enabled - Whether shadow stroke is enabled or not. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93265,12 +128081,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Enable or disable shadow fill. * * @method Phaser.GameObjects.Text.TextStyle#setShadowFill * @since 3.0.0 * - * @param {boolean} enabled - [description] + * @param {boolean} enabled - Whether shadow fill is enabled or not. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93282,7 +128098,9 @@ var TextStyle = new Class({ }, /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * Set the width (in pixels) to use for wrapping lines. + * + * Pass in null to remove wrapping by width. * * @method Phaser.GameObjects.Text.TextStyle#setWordWrapWidth * @since 3.0.0 @@ -93305,7 +128123,9 @@ var TextStyle = new Class({ }, /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * Set a custom callback for wrapping lines. + * + * Pass in null to remove wrapping by callback. * * @method Phaser.GameObjects.Text.TextStyle#setWordWrapCallback * @since 3.0.0 @@ -93329,12 +128149,14 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. * * @method Phaser.GameObjects.Text.TextStyle#setAlign * @since 3.0.0 * - * @param {string} align - [description] + * @param {string} align - The text alignment. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93348,12 +128170,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the maximum number of lines to draw. * * @method Phaser.GameObjects.Text.TextStyle#setMaxLines * @since 3.0.0 * - * @param {integer} [max=0] - [description] + * @param {integer} [max=0] - The maximum number of lines to draw. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -93367,12 +128189,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Get the current text metrics. * * @method Phaser.GameObjects.Text.TextStyle#getTextMetrics * @since 3.0.0 * - * @return {object} [description] + * @return {BitmapTextMetrics} The text metrics. */ getTextMetrics: function () { @@ -93386,12 +128208,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Build a JSON representation of this Text Style. * * @method Phaser.GameObjects.Text.TextStyle#toJSON * @since 3.0.0 * - * @return {object} [description] + * @return {object} A JSON representation of this Text Style. */ toJSON: function () { @@ -93408,7 +128230,7 @@ var TextStyle = new Class({ }, /** - * [description] + * Destroy this Text Style. * * @method Phaser.GameObjects.Text.TextStyle#destroy * @since 3.0.0 @@ -93424,8 +128246,8 @@ module.exports = TextStyle; /***/ }), -/* 414 */ -/***/ (function(module, exports, __webpack_require__) { +/* 808 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -93433,8 +128255,6 @@ module.exports = TextStyle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -93452,74 +128272,17 @@ var GameObject = __webpack_require__(2); */ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + if (src.text !== '') { - return; + renderer.batchSprite(src, src.frame, camera, parentMatrix); } - - var ctx = renderer.currentContext; - - // var resolution = src.resolution; - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var canvas = src.canvas; - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (renderer.config.roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - - ctx.translate(canvas.width * (src.flipX ? 1 : 0), canvas.height * (src.flipY ? 1 : 0)); - - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, -src.displayOriginX, -src.displayOriginY, canvas.width, canvas.height); - - ctx.restore(); }; module.exports = TextCanvasRenderer; /***/ }), -/* 415 */ +/* 809 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -93528,7 +128291,7 @@ module.exports = TextCanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); +var Utils = __webpack_require__(10); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -93547,25 +128310,44 @@ var GameObject = __webpack_require__(2); */ var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + if (src.text === '') { return; } - - if (src.dirty) - { - src.canvasTexture = renderer.canvasToTexture(src.canvas, src.canvasTexture); - src.dirty = false; - } - this.pipeline.batchText(this, camera, parentMatrix); + var frame = src.frame; + var width = frame.width; + var height = frame.height; + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + frame.glTexture, + width, height, + src.x, src.y, + width / src.style.resolution, height / src.style.resolution, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.displayOriginX, src.displayOriginY, + 0, 0, width, height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + 0, 0, + camera, + parentMatrix + ); }; module.exports = TextWebGLRenderer; /***/ }), -/* 416 */ +/* 810 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -93574,17 +128356,17 @@ module.exports = TextWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); if (true) { - renderWebGL = __webpack_require__(415); + renderWebGL = __webpack_require__(809); } if (true) { - renderCanvas = __webpack_require__(414); + renderCanvas = __webpack_require__(808); } module.exports = { @@ -93596,7 +128378,7 @@ module.exports = { /***/ }), -/* 417 */ +/* 811 */ /***/ (function(module, exports) { /** @@ -93611,9 +128393,9 @@ module.exports = { * @function Phaser.GameObjects.Text.GetTextSize * @since 3.0.0 * - * @param {Phaser.GameObjects.Text} text - The Text object to get the size from. - * @param {number} size - [description] - * @param {array} lines - [description] + * @param {Phaser.GameObjects.Text} text - The Text object to calculate the size from. + * @param {BitmapTextMetrics} size - The Text metrics to use when calculating the size. + * @param {array} lines - The lines of text to calculate the size from. * * @return {object} An object containing dimensions of the Text object. */ @@ -93626,7 +128408,7 @@ var GetTextSize = function (text, size, lines) var lineWidths = []; var maxLineWidth = 0; var drawnLines = lines.length; - + if (style.maxLines > 0 && style.maxLines < lines.length) { drawnLines = style.maxLines; @@ -93656,17 +128438,12 @@ var GetTextSize = function (text, size, lines) var lineHeight = size.fontSize + style.strokeThickness; var height = lineHeight * drawnLines; - var lineSpacing = text._lineSpacing || 0; - - if (lineSpacing < 0 && Math.abs(lineSpacing) > lineHeight) - { - lineSpacing = -lineHeight; - } + var lineSpacing = text.lineSpacing; // Adjust for line spacing - if (lineSpacing !== 0) + if (lines.length > 1) { - height += (lineSpacing > 0) ? lineSpacing * lines.length : lineSpacing * (lines.length - 1); + height += lineSpacing * (lines.length - 1); } return { @@ -93683,7 +128460,7 @@ module.exports = GetTextSize; /***/ }), -/* 418 */ +/* 812 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -93692,431 +128469,230 @@ module.exports = GetTextSize; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var GetBoolean = __webpack_require__(62); var GetValue = __webpack_require__(4); -var Sprite = __webpack_require__(34); -var TWEEN_CONST = __webpack_require__(61); -var Vector2 = __webpack_require__(6); /** - * @typedef {object} PathConfig + * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor + * and create a BitmapText object using a fixed-width retro font. * - * @property {number} duration - [description] - * @property {number} from - [description] - * @property {number} to - [description] - * @property {boolean} [positionOnPath=false] - [description] - * @property {boolean} [rotateToPath=false] - [description] - * @property {number} [rotationOffset=0] - [description] - * @property {boolean} [verticalAdjust=false] - [description] - */ - -/** - * @classdesc - * A PathFollower Game Object. - * - * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. - * - * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, - * scale it and so on. - * - * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start - * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate - * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. - * - * @class PathFollower - * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.GameObjects - * @constructor + * @function Phaser.GameObjects.RetroFont.Parse * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. - * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {Phaser.Scene} scene - A reference to the Phaser Scene. + * @param {Phaser.GameObjects.RetroFont.Config} config - The font configuration object. + * + * @return {object} A parsed Bitmap Font data entry for the Bitmap Font cache. */ -var PathFollower = new Class({ +var ParseRetroFont = function (scene, config) +{ + var w = config.width; + var h = config.height; + var cx = Math.floor(w / 2); + var cy = Math.floor(h / 2); + var letters = GetValue(config, 'chars', ''); - Extends: Sprite, - - initialize: - - function PathFollower (scene, path, x, y, texture, frame) + if (letters === '') { - Sprite.call(this, scene, x, y, texture, frame); + return; + } - /** - * The Path this PathFollower is following. It can only follow one Path at a time. - * - * @name Phaser.GameObjects.PathFollower#path - * @type {Phaser.Curves.Path} - * @since 3.0.0 - */ - this.path = path; + var key = GetValue(config, 'image', ''); + var offsetX = GetValue(config, 'offset.x', 0); + var offsetY = GetValue(config, 'offset.y', 0); + var spacingX = GetValue(config, 'spacing.x', 0); + var spacingY = GetValue(config, 'spacing.y', 0); + var lineSpacing = GetValue(config, 'lineSpacing', 0); - /** - * Should the PathFollower automatically rotate to point in the direction of the Path? - * - * @name Phaser.GameObjects.PathFollower#rotateToPath - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rotateToPath = false; + var charsPerRow = GetValue(config, 'charsPerRow', null); - /** - * [description] - * - * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.pathRotationVerticalAdjust = false; - - /** - * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) - * this value is added to the rotation value. This allows you to rotate objects to a path but control - * the angle of the rotation as well. - * - * @name Phaser.GameObjects.PathFollower#pathRotationOffset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pathRotationOffset = 0; - - /** - * An additional vector to add to the PathFollowers position, allowing you to offset it from the - * Path coordinates. - * - * @name Phaser.GameObjects.PathFollower#pathOffset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.pathOffset = new Vector2(x, y); - - /** - * [description] - * - * @name Phaser.GameObjects.PathFollower#pathVector - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.pathVector = new Vector2(); - - /** - * [description] - * - * @name Phaser.GameObjects.PathFollower#pathTween - * @type {Phaser.Tweens.Tween} - * @since 3.0.0 - */ - this.pathTween; - - /** - * [description] - * - * @name Phaser.GameObjects.PathFollower#pathConfig - * @type {?PathConfig} - * @default null - * @since 3.0.0 - */ - this.pathConfig = null; - - /** - * Records the direction of the follower so it can change direction. - * - * @name Phaser.GameObjects.PathFollower#_prevDirection - * @type {integer} - * @private - * @since 3.0.0 - */ - this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.PathFollower#setPath - * @since 3.0.0 - * - * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. - * @param {PathConfig} [config] - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - setPath: function (path, config) + if (charsPerRow === null) { - if (config === undefined) { config = this.pathConfig; } + charsPerRow = scene.sys.textures.getFrame(key).width / w; - var tween = this.pathTween; - - if (tween && tween.isPlaying()) + if (charsPerRow > letters.length) { - tween.stop(); - } - - this.path = path; - - if (config) - { - this.startFollow(config); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.PathFollower#setRotateToPath - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} [offset=0] - Rotation offset in degrees. - * @param {boolean} [verticalAdjust=false] - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - setRotateToPath: function (value, offset, verticalAdjust) - { - if (offset === undefined) { offset = 0; } - if (verticalAdjust === undefined) { verticalAdjust = false; } - - this.rotateToPath = value; - - this.pathRotationOffset = offset; - this.pathRotationVerticalAdjust = verticalAdjust; - - return this; - }, - - /** - * Is this PathFollower actively following a Path or not? - * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. - * - * @method Phaser.GameObjects.PathFollower#isFollowing - * @since 3.0.0 - * - * @return {boolean} `true` is this PathFollower is actively following a Path, otherwise `false`. - */ - isFollowing: function () - { - var tween = this.pathTween; - - return (tween && tween.isPlaying()); - }, - - /** - * Starts this PathFollower following its given Path. - * - * @method Phaser.GameObjects.PathFollower#startFollow - * @since 3.3.0 - * - * @param {(number|PathConfig)} [config={}] - [description] - * @param {number} [startAt=0] - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - startFollow: function (config, startAt) - { - if (config === undefined) { config = {}; } - if (startAt === undefined) { startAt = 0; } - - var tween = this.pathTween; - - if (tween && tween.isPlaying()) - { - tween.stop(); - } - - if (typeof config === 'number') - { - config = { duration: config }; - } - - // Override in case they've been specified in the config - config.from = 0; - config.to = 1; - - // Can also read extra values out of the config: - - var positionOnPath = GetBoolean(config, 'positionOnPath', false); - - this.rotateToPath = GetBoolean(config, 'rotateToPath', false); - this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); - this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); - - this.pathTween = this.scene.sys.tweens.addCounter(config); - - // The starting point of the path, relative to this follower - this.path.getStartPoint(this.pathOffset); - - if (positionOnPath) - { - this.x = this.pathOffset.x; - this.y = this.pathOffset.y; - } - - this.pathOffset.x = this.x - this.pathOffset.x; - this.pathOffset.y = this.y - this.pathOffset.y; - - this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; - - if (this.rotateToPath) - { - // Set the rotation now (in case the tween has a delay on it, etc) - var nextPoint = this.path.getPoint(0.1); - - this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); - } - - this.pathConfig = config; - - return this; - }, - - /** - * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the - * point on the Path at which you paused it. - * - * @method Phaser.GameObjects.PathFollower#pauseFollow - * @since 3.3.0 - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - pauseFollow: function () - { - var tween = this.pathTween; - - if (tween && tween.isPlaying()) - { - tween.pause(); - } - - return this; - }, - - /** - * Resumes a previously paused PathFollower. - * If the PathFollower was not paused this has no effect. - * - * @method Phaser.GameObjects.PathFollower#resumeFollow - * @since 3.3.0 - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - resumeFollow: function () - { - var tween = this.pathTween; - - if (tween && tween.isPaused()) - { - tween.resume(); - } - - return this; - }, - - /** - * Stops this PathFollower from following the path any longer. - * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. - * - * @method Phaser.GameObjects.PathFollower#stopFollow - * @since 3.3.0 - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - stopFollow: function () - { - var tween = this.pathTween; - - if (tween && tween.isPlaying()) - { - tween.stop(); - } - - return this; - }, - - /** - * Internal update handler that advances this PathFollower along the path. - * Called automatically by the Scene step, should not typically be called directly. - * - * @method Phaser.GameObjects.PathFollower#preUpdate - * @protected - * @since 3.0.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. - */ - preUpdate: function (time, delta) - { - this.anims.update(time, delta); - - var tween = this.pathTween; - - if (tween) - { - var tweenData = tween.data[0]; - - if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) - { - // If delayed, etc then bail out - return; - } - - var pathVector = this.pathVector; - - this.path.getPoint(tween.getValue(), pathVector); - - pathVector.add(this.pathOffset); - - var oldX = this.x; - var oldY = this.y; - - this.setPosition(pathVector.x, pathVector.y); - - var speedX = this.x - oldX; - var speedY = this.y - oldY; - - if (speedX === 0 && speedY === 0) - { - // Bail out early - return; - } - - if (tweenData.state !== this._prevDirection) - { - // We've changed direction, so don't do a rotate this frame - this._prevDirection = tweenData.state; - - return; - } - - if (this.rotateToPath) - { - this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); - - if (this.pathRotationVerticalAdjust) - { - this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); - } - } + charsPerRow = letters.length; } } -}); + var x = offsetX; + var y = offsetY; -module.exports = PathFollower; + var data = { + retroFont: true, + font: key, + size: w, + lineHeight: h + lineSpacing, + chars: {} + }; + + var r = 0; + + for (var i = 0; i < letters.length; i++) + { + // var node = letters[i]; + + var charCode = letters.charCodeAt(i); + + data.chars[charCode] = + { + x: x, + y: y, + width: w, + height: h, + centerX: cx, + centerY: cy, + xOffset: 0, + yOffset: 0, + xAdvance: w, + data: {}, + kerning: {} + }; + + r++; + + if (r === charsPerRow) + { + r = 0; + x = offsetX; + y += h + spacingY; + } + else + { + x += w + spacingX; + } + } + + var entry = { + data: data, + frame: null, + texture: key + }; + + return entry; +}; + +module.exports = ParseRetroFont; /***/ }), -/* 419 */ +/* 813 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RETRO_FONT_CONST = { + + /** + * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET1 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET1: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', + + /** + * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET2 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET2: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET3 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET3: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ', + + /** + * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET4 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET4: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789', + + /** + * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET5 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET5: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789', + + /** + * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET6 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET6: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' ', + + /** + * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET7 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET7: 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39', + + /** + * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET8 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET8: '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET9 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET9: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!', + + /** + * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET10 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET10: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET11 + * @since 3.6.0 + * @type {string} + */ + TEXT_SET11: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789' + +}; + +module.exports = RETRO_FONT_CONST; + + +/***/ }), +/* 814 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -94125,4487 +128701,491 @@ module.exports = PathFollower; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @callback RandomZoneSourceCallback - * - * @param {Phaser.Math.Vector2} point - A point to modify. - */ - -/** - * @typedef {object} RandomZoneSource - * - * @property {RandomZoneSourceCallback} getRandomPoint - A function modifying its point argument. - * - * @see Phaser.Geom.Circle - * @see Phaser.Geom.Ellipse - * @see Phaser.Geom.Line - * @see Phaser.Geom.Polygon - * @see Phaser.Geom.Rectangle - * @see Phaser.Geom.Triangle - */ - -/** - * @classdesc - * A zone that places particles randomly within a shape's area. - * - * @class RandomZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor - * @since 3.0.0 - * - * @param {RandomZoneSource} source - An object instance with a `getRandomPoint(point)` method. - */ -var RandomZone = new Class({ - - initialize: - - function RandomZone (source) - { - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.RandomZone#source - * @type {RandomZoneSource} - * @since 3.0.0 - */ - this.source = source; - - /** - * Internal calculation vector. - * - * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tempVec = new Vector2(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - */ - getPoint: function (particle) - { - var vec = this._tempVec; - - this.source.getRandomPoint(vec); - - particle.x = vec.x; - particle.y = vec.y; - } - -}); - -module.exports = RandomZone; - - -/***/ }), -/* 420 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Verifies that an object contains at least one of the requested keys - * - * @function Phaser.Utils.Object.HasAny - * @since 3.0.0 - * - * @param {object} source - an object on which to check for key existence - * @param {string[]} keys - an array of keys to search the object for - * - * @return {boolean} true if the source object contains at least one of the keys, false otherwise - */ -var HasAny = function (source, keys) -{ - for (var i = 0; i < keys.length; i++) - { - if (source.hasOwnProperty(keys[i])) - { - return true; - } - } - - return false; -}; - -module.exports = HasAny; - - -/***/ }), -/* 421 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Stepped easing. - * - * @function Phaser.Math.Easing.Stepped.Stepped - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [steps=1] - The number of steps in the ease. - * - * @return {number} The tweened value. - */ -var Stepped = function (v, steps) -{ - if (steps === undefined) { steps = 1; } - - if (v <= 0) - { - return 0; - } - else if (v >= 1) - { - return 1; - } - else - { - return (((steps * v) | 0) + 1) * (1 / steps); - } -}; - -module.exports = Stepped; - - -/***/ }), -/* 422 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sinusoidal ease-in/out. - * - * @function Phaser.Math.Easing.Sine.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 0.5 * (1 - Math.cos(Math.PI * v)); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 423 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sinusoidal ease-out. - * - * @function Phaser.Math.Easing.Sine.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return Math.sin(v * Math.PI / 2); - } -}; - -module.exports = Out; - - -/***/ }), -/* 424 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sinusoidal ease-in. - * - * @function Phaser.Math.Easing.Sine.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 1 - Math.cos(v * Math.PI / 2); - } -}; - -module.exports = In; - - -/***/ }), -/* 425 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quintic ease-in/out. - * - * @function Phaser.Math.Easing.Quintic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v * v * v + 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 426 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quintic ease-out. - * - * @function Phaser.Math.Easing.Quintic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return --v * v * v * v * v + 1; -}; - -module.exports = Out; - - -/***/ }), -/* 427 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quintic ease-in. - * - * @function Phaser.Math.Easing.Quintic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v * v * v * v; -}; - -module.exports = In; - - -/***/ }), -/* 428 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quartic ease-in/out. - * - * @function Phaser.Math.Easing.Quartic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v * v * v; - } - else - { - return -0.5 * ((v -= 2) * v * v * v - 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 429 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quartic ease-out. - * - * @function Phaser.Math.Easing.Quartic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return 1 - (--v * v * v * v); -}; - -module.exports = Out; - - -/***/ }), -/* 430 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quartic ease-in. - * - * @function Phaser.Math.Easing.Quartic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v * v * v; -}; - -module.exports = In; - - -/***/ }), -/* 431 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quadratic ease-in/out. - * - * @function Phaser.Math.Easing.Quadratic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v; - } - else - { - return -0.5 * (--v * (v - 2) - 1); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 432 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quadratic ease-out. - * - * @function Phaser.Math.Easing.Quadratic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return v * (2 - v); -}; - -module.exports = Out; - - -/***/ }), -/* 433 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quadratic ease-in. - * - * @function Phaser.Math.Easing.Quadratic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v; -}; - -module.exports = In; - - -/***/ }), -/* 434 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Linear easing (no variation). - * - * @function Phaser.Math.Easing.Linear.Linear - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Linear = function (v) -{ - return v; -}; - -module.exports = Linear; - - -/***/ }), -/* 435 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Exponential ease-in/out. - * - * @function Phaser.Math.Easing.Expo.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * Math.pow(2, 10 * (v - 1)); - } - else - { - return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 436 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Exponential ease-out. - * - * @function Phaser.Math.Easing.Expo.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return 1 - Math.pow(2, -10 * v); -}; - -module.exports = Out; - - -/***/ }), -/* 437 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Exponential ease-in. - * - * @function Phaser.Math.Easing.Expo.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return Math.pow(2, 10 * (v - 1)) - 0.001; -}; - -module.exports = In; - - -/***/ }), -/* 438 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Elastic ease-in/out. - * - * @function Phaser.Math.Easing.Elastic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] - * - * @return {number} The tweened value. - */ -var InOut = function (v, amplitude, period) -{ - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } - - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; - - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - if ((v *= 2) < 1) - { - return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } - else - { - return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; - } - } -}; - -module.exports = InOut; - - -/***/ }), -/* 439 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Elastic ease-out. - * - * @function Phaser.Math.Easing.Elastic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] - * - * @return {number} The tweened value. - */ -var Out = function (v, amplitude, period) -{ - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } - - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; - - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); - } -}; - -module.exports = Out; - - -/***/ }), -/* 440 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Elastic ease-in. - * - * @function Phaser.Math.Easing.Elastic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] - * - * @return {number} The tweened value. - */ -var In = function (v, amplitude, period) -{ - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } - - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; - - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } -}; - -module.exports = In; - - -/***/ }), -/* 441 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Cubic ease-in/out. - * - * @function Phaser.Math.Easing.Cubic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v + 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 442 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Cubic ease-out. - * - * @function Phaser.Math.Easing.Cubic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return --v * v * v + 1; -}; - -module.exports = Out; - - -/***/ }), -/* 443 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Cubic ease-in. - * - * @function Phaser.Math.Easing.Cubic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v * v; -}; - -module.exports = In; - - -/***/ }), -/* 444 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Circular ease-in/out. - * - * @function Phaser.Math.Easing.Circular.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return -0.5 * (Math.sqrt(1 - v * v) - 1); - } - else - { - return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 445 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Circular ease-out. - * - * @function Phaser.Math.Easing.Circular.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return Math.sqrt(1 - (--v * v)); -}; - -module.exports = Out; - - -/***/ }), -/* 446 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Circular ease-in. - * - * @function Phaser.Math.Easing.Circular.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return 1 - Math.sqrt(1 - v * v); -}; - -module.exports = In; - - -/***/ }), -/* 447 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Bounce ease-in/out. - * - * @function Phaser.Math.Easing.Bounce.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - var reverse = false; - - if (v < 0.5) - { - v = 1 - (v * 2); - reverse = true; - } - else - { - v = (v * 2) - 1; - } - - if (v < 1 / 2.75) - { - v = 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } - - if (reverse) - { - return (1 - v) * 0.5; - } - else - { - return v * 0.5 + 0.5; - } -}; - -module.exports = InOut; - - -/***/ }), -/* 448 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Bounce ease-out. - * - * @function Phaser.Math.Easing.Bounce.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - if (v < 1 / 2.75) - { - return 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } -}; - -module.exports = Out; - - -/***/ }), -/* 449 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Bounce ease-in. - * - * @function Phaser.Math.Easing.Bounce.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - v = 1 - v; - - if (v < 1 / 2.75) - { - return 1 - (7.5625 * v * v); - } - else if (v < 2 / 2.75) - { - return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); - } - else if (v < 2.5 / 2.75) - { - return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); - } - else - { - return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); - } -}; - -module.exports = In; - - -/***/ }), -/* 450 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Back ease-in/out. - * - * @function Phaser.Math.Easing.Back.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [overshoot=1.70158] - The overshoot amount. - * - * @return {number} The tweened value. - */ -var InOut = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } - - var s = overshoot * 1.525; - - if ((v *= 2) < 1) - { - return 0.5 * (v * v * ((s + 1) * v - s)); - } - else - { - return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 451 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Back ease-out. - * - * @function Phaser.Math.Easing.Back.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [overshoot=1.70158] - The overshoot amount. - * - * @return {number} The tweened value. - */ -var Out = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } - - return --v * v * ((overshoot + 1) * v + overshoot) + 1; -}; - -module.exports = Out; - - -/***/ }), -/* 452 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Back ease-in. - * - * @function Phaser.Math.Easing.Back.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [overshoot=1.70158] - The overshoot amount. - * - * @return {number} The tweened value. - */ -var In = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } - - return v * v * ((overshoot + 1) * v - overshoot); -}; - -module.exports = In; - - -/***/ }), -/* 453 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Back = __webpack_require__(247); -var Bounce = __webpack_require__(246); -var Circular = __webpack_require__(245); -var Cubic = __webpack_require__(244); -var Elastic = __webpack_require__(243); -var Expo = __webpack_require__(242); -var Linear = __webpack_require__(241); -var Quadratic = __webpack_require__(240); -var Quartic = __webpack_require__(239); -var Quintic = __webpack_require__(238); -var Sine = __webpack_require__(237); -var Stepped = __webpack_require__(236); - -// EaseMap -module.exports = { - - Power0: Linear, - Power1: Quadratic.Out, - Power2: Cubic.Out, - Power3: Quartic.Out, - Power4: Quintic.Out, - - Linear: Linear, - Quad: Quadratic.Out, - Cubic: Cubic.Out, - Quart: Quartic.Out, - Quint: Quintic.Out, - Sine: Sine.Out, - Expo: Expo.Out, - Circ: Circular.Out, - Elastic: Elastic.Out, - Back: Back.Out, - Bounce: Bounce.Out, - Stepped: Stepped, - - 'Quad.easeIn': Quadratic.In, - 'Cubic.easeIn': Cubic.In, - 'Quart.easeIn': Quartic.In, - 'Quint.easeIn': Quintic.In, - 'Sine.easeIn': Sine.In, - 'Expo.easeIn': Expo.In, - 'Circ.easeIn': Circular.In, - 'Elastic.easeIn': Elastic.In, - 'Back.easeIn': Back.In, - 'Bounce.easeIn': Bounce.In, - - 'Quad.easeOut': Quadratic.Out, - 'Cubic.easeOut': Cubic.Out, - 'Quart.easeOut': Quartic.Out, - 'Quint.easeOut': Quintic.Out, - 'Sine.easeOut': Sine.Out, - 'Expo.easeOut': Expo.Out, - 'Circ.easeOut': Circular.Out, - 'Elastic.easeOut': Elastic.Out, - 'Back.easeOut': Back.Out, - 'Bounce.easeOut': Bounce.Out, - - 'Quad.easeInOut': Quadratic.InOut, - 'Cubic.easeInOut': Cubic.InOut, - 'Quart.easeInOut': Quartic.InOut, - 'Quint.easeInOut': Quintic.InOut, - 'Sine.easeInOut': Sine.InOut, - 'Expo.easeInOut': Expo.InOut, - 'Circ.easeInOut': Circular.InOut, - 'Elastic.easeInOut': Elastic.InOut, - 'Back.easeInOut': Back.InOut, - 'Bounce.easeInOut': Bounce.InOut - -}; - - -/***/ }), -/* 454 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback EdgeZoneSourceCallback - * - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * - * @return {Phaser.Geom.Point[]} - [description] - */ - -/** - * @typedef {object} EdgeZoneSource - * - * @property {EdgeZoneSourceCallback} getPoints - A function placing points on the source's edge or edges. - * - * @see Phaser.Curves.Curve - * @see Phaser.Curves.Path - * @see Phaser.Geom.Circle - * @see Phaser.Geom.Ellipse - * @see Phaser.Geom.Line - * @see Phaser.Geom.Polygon - * @see Phaser.Geom.Rectangle - * @see Phaser.Geom.Triangle - */ - -/** - * @classdesc - * A zone that places particles on a shape's edges. - * - * @class EdgeZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor - * @since 3.0.0 - * - * @param {EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. - * @param {number} quantity - [description] - * @param {number} stepRate - [description] - * @param {boolean} [yoyo=false] - [description] - * @param {boolean} [seamless=true] - [description] - */ -var EdgeZone = new Class({ - - initialize: - - function EdgeZone (source, quantity, stepRate, yoyo, seamless) - { - if (yoyo === undefined) { yoyo = false; } - if (seamless === undefined) { seamless = true; } - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source - * @type {EdgeZoneSource|RandomZoneSource} - * @since 3.0.0 - */ - this.source = source; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points - * @type {Phaser.Geom.Point[]} - * @default [] - * @since 3.0.0 - */ - this.points = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity - * @type {number} - * @since 3.0.0 - */ - this.quantity = quantity; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate - * @type {number} - * @since 3.0.0 - */ - this.stepRate = stepRate; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo - * @type {boolean} - * @since 3.0.0 - */ - this.yoyo = yoyo; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.counter = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless - * @type {boolean} - * @since 3.0.0 - */ - this.seamless = seamless; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._length = 0; - - /** - * 0 = forwards, 1 = backwards - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._direction = 0; - - this.updateSource(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. - */ - updateSource: function () - { - this.points = this.source.getPoints(this.quantity, this.stepRate); - - // Remove ends? - if (this.seamless) - { - var a = this.points[0]; - var b = this.points[this.points.length - 1]; - - if (a.x === b.x && a.y === b.y) - { - this.points.pop(); - } - } - - var oldLength = this._length; - - this._length = this.points.length; - - // Adjust counter if we now have less points than before - if (this._length < oldLength && this.counter > this._length) - { - this.counter = this._length - 1; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource - * @since 3.0.0 - * - * @param {object} source - [description] - * - * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. - */ - changeSource: function (source) - { - this.source = source; - - return this.updateSource(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - */ - getPoint: function (particle) - { - if (this._direction === 0) - { - this.counter++; - - if (this.counter >= this._length) - { - if (this.yoyo) - { - this._direction = 1; - this.counter = this._length - 1; - } - else - { - this.counter = 0; - } - } - } - else - { - this.counter--; - - if (this.counter === -1) - { - if (this.yoyo) - { - this._direction = 0; - this.counter = 0; - } - else - { - this.counter = this._length - 1; - } - } - } - - var point = this.points[this.counter]; - - if (point) - { - particle.x = point.x; - particle.y = point.y; - } - } - -}); - -module.exports = EdgeZone; - - -/***/ }), -/* 455 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback DeathZoneSourceCallback - * - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {boolean} - True if the coordinates are within the source area. - */ - -/** - * @typedef {object} DeathZoneSource - * - * @property {DeathZoneSourceCallback} contains - * - * @see Phaser.Geom.Circle - * @see Phaser.Geom.Ellipse - * @see Phaser.Geom.Polygon - * @see Phaser.Geom.Rectangle - * @see Phaser.Geom.Triangle - */ - -/** - * @classdesc - * A Death Zone. - * - * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. - * - * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own - * object as long as it includes a `contains` method for which the Particles can be tested against. - * - * @class DeathZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor - * @since 3.0.0 - * - * @param {DeathZoneSource} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` - */ -var DeathZone = new Class({ - - initialize: - - function DeathZone (source, killOnEnter) - { - /** - * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. - * - * @name Phaser.GameObjects.Particles.Zones.DeathZone#source - * @type {DeathZoneSource} - * @since 3.0.0 - */ - this.source = source; - - /** - * Set to `true` if the Particle should be killed if it enters this zone. - * Set to `false` to kill the Particle if it leaves this zone. - * - * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter - * @type {boolean} - * @since 3.0.0 - */ - this.killOnEnter = killOnEnter; - }, - - /** - * Checks if the given Particle will be killed or not by this zone. - * - * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to be checked against this zone. - * - * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. - */ - willKill: function (particle) - { - var withinZone = this.source.contains(particle.x, particle.y); - - return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); - } - -}); - -module.exports = DeathZone; - - -/***/ }), -/* 456 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlendModes = __webpack_require__(51); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var DeathZone = __webpack_require__(455); -var EdgeZone = __webpack_require__(454); -var EmitterOp = __webpack_require__(899); -var GetFastValue = __webpack_require__(1); -var GetRandom = __webpack_require__(146); -var HasAny = __webpack_require__(420); -var HasValue = __webpack_require__(111); -var Particle = __webpack_require__(457); -var RandomZone = __webpack_require__(419); -var Rectangle = __webpack_require__(14); -var StableSort = __webpack_require__(83); -var Vector2 = __webpack_require__(6); -var Wrap = __webpack_require__(39); - -/** - * @callback ParticleEmitterCallback - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The particle associated with the call. - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - This particle emitter associated with the call. - */ - -/** - * @callback ParticleDeathCallback - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The particle that died. +var RETRO_FONT_CONST = __webpack_require__(813); +var Extend = __webpack_require__(20); + +/** + * @typedef {object} Phaser.GameObjects.RetroFont.Config + * + * @property {string} image - The key of the image containing the font. + * @property {number} offset.x - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. + * @property {number} offset.y - If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. + * @property {number} width - The width of each character in the font set. + * @property {number} height - The height of each character in the font set. + * @property {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. + * @property {number} charsPerRow - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. + * @property {number} spacing.x - If the characters in the font set have horizontal spacing between them set the required amount here. + * @property {number} spacing.y - If the characters in the font set have vertical spacing between them set the required amount here. + * @property {number} lineSpacing - The amount of vertical space to add to the line height of the font. */ /** - * @typedef {object} ParticleEmitterBounds - * - * @property {float} x - The left edge of the rectangle. - * @property {float} y - The top edge of the rectangle. - * @property {float} width - The width of the rectangle. - * @property {float} height - The height of the rectangle. - * - * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + * @namespace Phaser.GameObjects.RetroFont + * @since 3.6.0 + */ + +var RetroFont = { Parse: __webpack_require__(812) }; + +// Merge in the consts +RetroFont = Extend(false, RetroFont, RETRO_FONT_CONST); + +module.exports = RetroFont; + + +/***/ }), +/* 815 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * @typedef {object} ParticleEmitterBoundsAlt + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @property {float} x - The left edge of the rectangle. - * @property {float} y - The top edge of the rectangle. - * @property {float} w - The width of the rectangle. - * @property {float} h - The height of the rectangle. + * @method Phaser.GameObjects.RenderTexture#renderCanvas + * @since 3.2.0 + * @private * - * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RenderTextureCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = RenderTextureCanvasRenderer; + + +/***/ }), +/* 816 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderWebGL + * @since 3.2.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RenderTextureWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var frame = src.frame; + var width = frame.width; + var height = frame.height; + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + frame.glTexture, + width, height, + src.x, src.y, + width, height, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, !src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.displayOriginX, src.displayOriginY, + 0, 0, width, height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + 0, 0, + camera, + parentMatrix + ); + + // Force clear the current texture so that items next in the batch (like Graphics) don't try and use it + renderer.setBlankTexture(true); +}; + +module.exports = RenderTextureWebGLRenderer; + + +/***/ }), +/* 817 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(816); +} + +if (true) +{ + renderCanvas = __webpack_require__(815); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 818 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * @typedef {object} ParticleEmitterDeathZoneConfig - * - * @property {DeathZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.DeathZone#source}. - * @property {string} [type='onEnter'] - 'onEnter' or 'onLeave'. + * @namespace Phaser.GameObjects.Particles.Zones + */ + +module.exports = { + + DeathZone: __webpack_require__(301), + EdgeZone: __webpack_require__(300), + RandomZone: __webpack_require__(297) + +}; + + +/***/ }), +/* 819 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * @typedef {object} ParticleEmitterEdgeZoneConfig + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @property {EdgeZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. - * @property {string} type - 'edge'. - * @property {integer} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. - * @property {float} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to 0. - * @property {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. - * @property {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. - */ - -/** - * @typedef {object} ParticleEmitterRandomZoneConfig - * - * @property {RandomZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.RandomZone#source}. - * @property {string} [type] - 'random'. - */ - -/** - * @typedef {object} ParticleEmitterConfig - * - * @property {boolean} [active] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#active}. - * @property {integer} [blendMode] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#blendMode}. - * @property {*} [callbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope} and {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. - * @property {boolean} [collideBottom] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideBottom}. - * @property {boolean} [collideLeft] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideLeft}. - * @property {boolean} [collideRight] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideRight}. - * @property {boolean} [collideTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideTop}. - * @property {boolean} [deathCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. - * @property {*} [deathCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope}. - * @property {function} [emitCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. - * @property {*} [emitCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. - * @property {Phaser.GameObjects.GameObject} [follow] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#follow}. - * @property {float} [frequency] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency}. - * @property {float} [gravityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityX}. - * @property {float} [gravityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityY}. - * @property {integer} [maxParticles] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxParticles}. - * @property {string} [name] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#name}. - * @property {boolean} [on] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#on}. - * @property {boolean} [particleBringToTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop}. - * @property {Phaser.GameObjects.Particles.Particle} [particleClass] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleClass}. - * @property {boolean} [radial] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#radial}. - * @property {float} [timeScale] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#timeScale}. - * @property {boolean} [trackVisible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#trackVisible}. - * @property {boolean} [visible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#visible}. - * @property {float|float[]|EmitterOpOnEmitCallback|object} [accelerationX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationX} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [accelerationY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationY} (emit only). - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [alpha] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#alpha}. - * @property {float|float[]|EmitterOpOnEmitCallback|object} [angle] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#angle} (emit only) - * @property {float|float[]|EmitterOpOnEmitCallback|object} [bounce] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#bounce} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [delay] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#delay} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [lifespan] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#lifespan} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [maxVelocityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [maxVelocityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [moveToX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToX} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [moveToY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToY} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [quantity] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity} (emit only). - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [rotate] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#rotate}. - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [scale] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setScale}. - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [scaleX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleX}. - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [scaleY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleY}. - * @property {float|float[]|EmitterOpOnEmitCallback|object} [speed] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setSpeed} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [speedX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedX} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [speedY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedY} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [tint] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#tint}. - * @property {float|float[]|EmitterOpOnEmitCallback|object} [x] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#x} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [y] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#y} (emit only). - * @property {object} [emitZone] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone}. - * @property {ParticleEmitterBounds|ParticleEmitterBoundsAlt} [bounds] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setBounds}. - * @property {object} [followOffset] - Assigns to {@link Phaser.GameObjects.Particles.ParticleEmitter#followOffset}. - * @property {float} [followOffset.x] - x-coordinate of the offset. - * @property {float} [followOffset.y] - y-coordinate of the offset. - * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]|ParticleEmitterFrameConfig} [frames] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. - */ - -/** - * @typedef {object} ParticleEmitterFrameConfig - * - * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]} [frames] - One or more texture frames. - * @property {boolean} [cycle] - Whether texture frames will be assigned consecutively (true) or at random (false). - * @property {integer} [quantity] - The number of consecutive particles receiving each texture frame, when `cycle` is true. - */ - -/** - * @classdesc - * A particle emitter represents a single particle stream. - * It controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles} and is controlled by a {@link Phaser.GameObjects.Particles.ParticleEmitterManager Particle Emitter Manager}. - * - * @class ParticleEmitter - * @memberOf Phaser.GameObjects.Particles - * @constructor + * @method Phaser.GameObjects.Particles.EmitterManager#renderCanvas * @since 3.0.0 + * @private * - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} manager - The Emitter Manager this Emitter belongs to. - * @param {ParticleEmitterConfig} config - Settings for this emitter. + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var ParticleEmitter = new Class({ +var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) +{ + var emitters = emitterManager.emitters.list; + var emittersLength = emitters.length; - Mixins: [ - Components.BlendMode, - Components.Mask, - Components.ScrollFactor, - Components.Visible - ], - - initialize: - - function ParticleEmitter (manager, config) + if (emittersLength === 0) { - /** - * The Emitter Manager this Emitter belongs to. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#manager - * @type {Phaser.GameObjects.Particles.ParticleEmitterManager} - * @since 3.0.0 - */ - this.manager = manager; + return; + } - /** - * The texture assigned to particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - this.texture = manager.texture; + var camMatrix = renderer._tempMatrix1.copyFrom(camera.matrix); + var calcMatrix = renderer._tempMatrix2; + var particleMatrix = renderer._tempMatrix3; + var managerMatrix = renderer._tempMatrix4.applyITRS(emitterManager.x, emitterManager.y, emitterManager.rotation, emitterManager.scaleX, emitterManager.scaleY); - /** - * The texture frames assigned to particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frames - * @type {Phaser.Textures.Frame[]} - * @since 3.0.0 - */ - this.frames = [ manager.defaultFrame ]; + camMatrix.multiply(managerMatrix); - /** - * The default texture frame assigned to particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#defaultFrame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - this.defaultFrame = manager.defaultFrame; + var roundPixels = camera.roundPixels; - /** - * Names of simple configuration properties. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#configFastMap - * @type {object} - * @since 3.0.0 - */ - this.configFastMap = [ - 'active', - 'blendMode', - 'collideBottom', - 'collideLeft', - 'collideRight', - 'collideTop', - 'deathCallback', - 'deathCallbackScope', - 'emitCallback', - 'emitCallbackScope', - 'follow', - 'frequency', - 'gravityX', - 'gravityY', - 'maxParticles', - 'name', - 'on', - 'particleBringToTop', - 'particleClass', - 'radial', - 'timeScale', - 'trackVisible', - 'visible' - ]; + var ctx = renderer.currentContext; - /** - * Names of complex configuration properties. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#configOpMap - * @type {object} - * @since 3.0.0 - */ - this.configOpMap = [ - 'accelerationX', - 'accelerationY', - 'angle', - 'alpha', - 'bounce', - 'delay', - 'lifespan', - 'maxVelocityX', - 'maxVelocityY', - 'moveToX', - 'moveToY', - 'quantity', - 'rotate', - 'scaleX', - 'scaleY', - 'speedX', - 'speedY', - 'tint', - 'x', - 'y' - ]; + ctx.save(); - /** - * The name of this Particle Emitter. - * - * Empty by default and never populated by Phaser, this is left for developers to use. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The Particle Class which will be emitted by this Emitter. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass - * @type {Phaser.GameObjects.Particles.Particle} - * @default Phaser.GameObjects.Particles.Particle - * @since 3.0.0 - */ - this.particleClass = Particle; - - /** - * The x-coordinate of the particle origin (where particles will be emitted). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#x - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition - */ - this.x = new EmitterOp(config, 'x', 0); - - /** - * The y-coordinate of the particle origin (where particles will be emitted). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#y - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition - */ - this.y = new EmitterOp(config, 'y', 0); - - /** - * A radial emitter will emit particles in all directions between angle min and max, - * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. - * A point emitter will emit particles only in the direction derived from the speedX and speedY values. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#radial - * @type {boolean} - * @default true - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setRadial - */ - this.radial = true; - - /** - * Horizontal acceleration applied to emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX - * @type {float} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity - */ - this.gravityX = 0; - - /** - * Vertical acceleration applied to emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY - * @type {float} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity - */ - this.gravityY = 0; - - /** - * Whether accelerationX and accelerationY are nonzero. Set automatically during configuration. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.acceleration = false; - - /** - * Horizontal acceleration applied to emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.accelerationX = new EmitterOp(config, 'accelerationX', 0, true); - - /** - * Vertical acceleration applied to emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.accelerationY = new EmitterOp(config, 'accelerationY', 0, true); - - /** - * The maximum horizontal velocity of emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityX = new EmitterOp(config, 'maxVelocityX', 10000, true); - - /** - * The maximum vertical velocity of emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityY = new EmitterOp(config, 'maxVelocityY', 10000, true); - - /** - * The initial horizontal speed of emitted particles, in pixels per second. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX - */ - this.speedX = new EmitterOp(config, 'speedX', 0, true); - - /** - * The initial vertical speed of emitted particles, in pixels per second. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY - */ - this.speedY = new EmitterOp(config, 'speedY', 0, true); - - /** - * Whether moveToX and moveToY are nonzero. Set automatically during configuration. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.moveTo = false; - - /** - * The x-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.moveToX = new EmitterOp(config, 'moveToX', 0, true); - - /** - * The y-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.moveToY = new EmitterOp(config, 'moveToY', 0, true); - - /** - * Whether particles will rebound when they meet the emitter bounds. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.bounce = new EmitterOp(config, 'bounce', 0, true); - - /** - * The horizontal scale of emitted particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale - * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleX - */ - this.scaleX = new EmitterOp(config, 'scaleX', 1); - - /** - * The vertical scale of emitted particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale - * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleY - */ - this.scaleY = new EmitterOp(config, 'scaleY', 1); - - /** - * Color tint applied to emitted particles. Any alpha component (0xAA000000) is ignored. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#tint - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0xffffffff - * @since 3.0.0 - */ - this.tint = new EmitterOp(config, 'tint', 0xffffffff); - - /** - * The alpha (transparency) of emitted particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#alpha - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setAlpha - */ - this.alpha = new EmitterOp(config, 'alpha', 1); - - /** - * The lifespan of emitted particles, in ms. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1000 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setLifespan - */ - this.lifespan = new EmitterOp(config, 'lifespan', 1000); - - /** - * The angle of the initial velocity of emitted particles, in degrees. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#angle - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default { min: 0, max: 360 } - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setAngle - */ - this.angle = new EmitterOp(config, 'angle', { min: 0, max: 360 }); - - /** - * The rotation of emitted particles, in degrees. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#rotate - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.rotate = new EmitterOp(config, 'rotate', 0); - - /** - * A function to call when a particle is emitted. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback - * @type {?ParticleEmitterCallback} - * @default null - * @since 3.0.0 - */ - this.emitCallback = null; - - /** - * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope - * @type {?*} - * @default null - * @since 3.0.0 - */ - this.emitCallbackScope = null; - - /** - * A function to call when a particle dies. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback - * @type {?ParticleDeathCallback} - * @default null - * @since 3.0.0 - */ - this.deathCallback = null; - - /** - * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope - * @type {?*} - * @default null - * @since 3.0.0 - */ - this.deathCallbackScope = null; - - /** - * Set to hard limit the amount of particle objects this emitter is allowed to create. - * 0 means unlimited. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.maxParticles = 0; - - /** - * How many particles are emitted each time particles are emitted (one explosion or one flow cycle). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency - * @see Phaser.GameObjects.Particles.ParticleEmitter#setQuantity - */ - this.quantity = new EmitterOp(config, 'quantity', 1, true); - - /** - * How many ms to wait after emission before the particles start updating. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#delay - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.delay = new EmitterOp(config, 'delay', 0, true); - - /** - * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. - * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. - * For an exploding emitter, this value will be -1. - * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). - * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency - * @type {float} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency - */ - this.frequency = 0; - - /** - * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). - * Already alive particles will continue to update until they expire. - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#on - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.on = true; - - /** - * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. - * Set to false to send them to the back. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.particleBringToTop = true; - - /** - * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * An object describing a shape to emit particles from. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZone - * @type {?Phaser.GameObjects.Particles.Zones.EdgeZone|Phaser.GameObjects.Particles.Zones.RandomZone} - * @default null - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone - */ - this.emitZone = null; - - /** - * An object describing a shape that deactivates particles when they interact with it. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZone - * @type {?Phaser.GameObjects.Particles.Zones.DeathZone} - * @default null - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone - */ - this.deathZone = null; - - /** - * A rectangular boundary constraining particle movement. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#bounds - * @type {?Phaser.Geom.Rectangle} - * @default null - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds - */ - this.bounds = null; - - /** - * Whether particles interact with the left edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideLeft - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideLeft = true; - - /** - * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideRight - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideRight = true; - - /** - * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideTop - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideTop = true; - - /** - * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideBottom - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideBottom = true; - - /** - * Whether this emitter updates itself and its particles. - * - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#pause} - * and {@link Phaser.GameObjects.Particles.ParticleEmitter#resume}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * Set this to false to hide any active particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#visible - * @type {boolean} - * @default true - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setVisible - */ - this.visible = true; - - /** - * The blend mode of this emitter's particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#blendMode - * @type {integer} - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setBlendMode - */ - this.blendMode = BlendModes.NORMAL; - - /** - * A Game Object whose position is used as the particle origin. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#follow - * @type {?Phaser.GameObjects.GameObject} - * @default null - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow - * @see Phaser.GameObjects.Particles.ParticleEmitter#stopFollow - */ - this.follow = null; - - /** - * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow - */ - this.followOffset = new Vector2(); - - /** - * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track - * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow - */ - this.trackVisible = false; - - /** - * The current texture frame, as an index of {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame - * @type {integer} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame - */ - this.currentFrame = 0; - - /** - * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame - * @type {boolean} - * @default true - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame - */ - this.randomFrame = true; - - /** - * The number of consecutive particles that receive a single texture frame (per frame cycle). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity - * @type {integer} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame - */ - this.frameQuantity = 1; - - /** - * Inactive particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#dead - * @type {Phaser.GameObjects.Particles.Particle[]} - * @private - * @since 3.0.0 - */ - this.dead = []; - - /** - * Active particles - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#alive - * @type {Phaser.GameObjects.Particles.Particle[]} - * @private - * @since 3.0.0 - */ - this.alive = []; - - /** - * The time until the next flow cycle. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#_counter - * @type {float} - * @private - * @default 0 - * @since 3.0.0 - */ - this._counter = 0; - - /** - * Counts up to {@link Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#_frameCounter - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._frameCounter = 0; - - if (config) - { - this.fromJSON(config); - } - }, - - /** - * Merges configuration settings into the emitter's current settings. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#fromJSON - * @since 3.0.0 - * - * @param {ParticleEmitterConfig} config - Settings for this emitter. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - fromJSON: function (config) + for (var e = 0; e < emittersLength; e++) { - if (!config) + var emitter = emitters[e]; + var particles = emitter.alive; + var particleCount = particles.length; + + if (!emitter.visible || particleCount === 0) { - return this; + continue; } - // Only update properties from their current state if they exist in the given config + var scrollX = camera.scrollX * emitter.scrollFactorX; + var scrollY = camera.scrollY * emitter.scrollFactorY; - var i = 0; - var key = ''; - - for (i = 0; i < this.configFastMap.length; i++) + if (parentMatrix) { - key = this.configFastMap[i]; + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -scrollX, -scrollY); - if (HasValue(config, key)) - { - this[key] = GetFastValue(config, key); - } + scrollX = 0; + scrollY = 0; } - for (i = 0; i < this.configOpMap.length; i++) - { - key = this.configOpMap[i]; - - if (HasValue(config, key)) - { - this[key].loadConfig(config); - } - } - - this.acceleration = (this.accelerationX.propertyValue !== 0 || this.accelerationY.propertyValue !== 0); - - this.moveTo = (this.moveToX.propertyValue !== 0 || this.moveToY.propertyValue !== 0); - - // Special 'speed' override - - if (HasValue(config, 'speed')) - { - this.speedX.loadConfig(config, 'speed'); - this.speedY = null; - } - - // If you specify speedX, speedY or moveTo then it changes the emitter from radial to a point emitter - if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) - { - this.radial = false; - } - - // Special 'scale' override - - if (HasValue(config, 'scale')) - { - this.scaleX.loadConfig(config, 'scale'); - this.scaleY = null; - } - - if (HasValue(config, 'callbackScope')) - { - var callbackScope = GetFastValue(config, 'callbackScope', null); - - this.emitCallbackScope = callbackScope; - this.deathCallbackScope = callbackScope; - } - - if (HasValue(config, 'emitZone')) - { - this.setEmitZone(config.emitZone); - } - - if (HasValue(config, 'deathZone')) - { - this.setDeathZone(config.deathZone); - } - - if (HasValue(config, 'bounds')) - { - this.setBounds(config.bounds); - } - - if (HasValue(config, 'followOffset')) - { - this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); - } - - if (HasValue(config, 'frame')) - { - this.setFrame(config.frame); - } - - return this; - }, - - /** - * Creates a description of this emitter suitable for JSON serialization. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON - * @since 3.0.0 - * - * @param {object} [output] - An object to copy output into. - * - * @return {object} - The output object. - */ - toJSON: function (output) - { - if (output === undefined) { output = {}; } - - var i = 0; - var key = ''; - - for (i = 0; i < this.configFastMap.length; i++) - { - key = this.configFastMap[i]; - - output[key] = this[key]; - } - - for (i = 0; i < this.configOpMap.length; i++) - { - key = this.configOpMap[i]; - - if (this[key]) - { - output[key] = this[key].toJSON(); - } - } - - // special handlers - if (!this.speedY) - { - delete output.speedX; - output.speed = this.speedX.toJSON(); - } - - if (!this.scaleY) - { - delete output.scaleX; - output.scale = this.scaleX.toJSON(); - } - - return output; - }, - - /** - * Continuously moves the particle origin to follow a Game Object's position. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} target - The Game Object to follow. - * @param {float} [offsetX=0] - Horizontal offset of the particle origin from the Game Object. - * @param {float} [offsetY=0] - Vertical offset of the particle origin from the Game Object. - * @param {boolean} [trackVisible=false] - Whether the emitter's visible state will track the target's visible state. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - startFollow: function (target, offsetX, offsetY, trackVisible) - { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - if (trackVisible === undefined) { trackVisible = false; } - - this.follow = target; - this.followOffset.set(offsetX, offsetY); - this.trackVisible = trackVisible; - - return this; - }, - - /** - * Stops following a Game Object. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - stopFollow: function () - { - this.follow = null; - this.followOffset.set(0, 0); - this.trackVisible = false; - - return this; - }, - - /** - * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} The texture frame. - */ - getFrame: function () - { - if (this.frames.length === 1) - { - return this.defaultFrame; - } - else if (this.randomFrame) - { - return GetRandom(this.frames); - } - else - { - var frame = this.frames[this.currentFrame]; - - this._frameCounter++; - - if (this._frameCounter === this.frameQuantity) - { - this._frameCounter = 0; - this.currentFrame = Wrap(this.currentFrame + 1, 0, this._frameLength); - } - - return frame; - } - }, - - // frame: 0 - // frame: 'red' - // frame: [ 0, 1, 2, 3 ] - // frame: [ 'red', 'green', 'blue', 'pink', 'white' ] - // frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } - - /** - * Sets a pattern for assigning texture frames to emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrame - * @since 3.0.0 - * - * @param {(array|string|integer|ParticleEmitterFrameConfig)} frames - One or more texture frames, or a configuration object. - * @param {boolean} [pickRandom=true] - Whether frames should be assigned at random from `frames`. - * @param {integer} [quantity=1] - The number of consecutive particles that will receive each frame. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setFrame: function (frames, pickRandom, quantity) - { - if (pickRandom === undefined) { pickRandom = true; } - if (quantity === undefined) { quantity = 1; } - - this.randomFrame = pickRandom; - this.frameQuantity = quantity; - this.currentFrame = 0; - this._frameCounter = 0; - - var t = typeof (frames); - - if (Array.isArray(frames) || t === 'string' || t === 'number') - { - this.manager.setEmitterFrames(frames, this); - } - else if (t === 'object') - { - var frameConfig = frames; - - frames = GetFastValue(frameConfig, 'frames', null); - - if (frames) - { - this.manager.setEmitterFrames(frames, this); - } - - var isCycle = GetFastValue(frameConfig, 'cycle', false); - - this.randomFrame = (isCycle) ? false : true; - - this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); - } - - this._frameLength = this.frames.length; - - if (this._frameLength === 1) - { - this.frameQuantity = 1; - this.randomFrame = false; - } - - return this; - }, - - /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial - * @since 3.0.0 - * - * @param {boolean} [value=true] - Radial mode (true) or point mode (true). - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setRadial: function (value) - { - if (value === undefined) { value = true; } - - this.radial = value; - - return this; - }, - - /** - * Sets the position of the emitter's particle origin. - * New particles will be emitted here. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} x - The x-coordinate of the particle origin. - * @param {float|float[]|EmitterOpOnEmitCallback|object} y - The y-coordinate of the particle origin. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setPosition: function (x, y) - { - this.x.onChange(x); - this.y.onChange(y); - - return this; - }, - - /** - * Sets or modifies a rectangular boundary constraining the particles. - * - * To remove the boundary, set {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds} to null. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setBounds - * @since 3.0.0 - * - * @param {(number|ParticleEmitterBounds|ParticleEmitterBoundsAlt)} x - The x-coordinate of the left edge of the boundary, or an object representing a rectangle. - * @param {float} y - The y-coordinate of the top edge of the boundary. - * @param {float} width - The width of the boundary. - * @param {float} height - The height of the boundary. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setBounds: function (x, y, width, height) - { - if (typeof x === 'object') - { - var obj = x; - - x = obj.x; - y = obj.y; - width = (HasValue(obj, 'w')) ? obj.w : obj.width; - height = (HasValue(obj, 'h')) ? obj.h : obj.height; - } - - if (this.bounds) - { - this.bounds.setTo(x, y, width, height); - } - else - { - this.bounds = new Rectangle(x, y, width, height); - } - - return this; - }, - - /** - * Sets the initial horizontal speed of emitted particles. - * Changes the emitter to point mode. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeedX: function (value) - { - this.speedX.onChange(value); - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = false; - - return this; - }, - - /** - * Sets the initial vertical speed of emitted particles. - * Changes the emitter to point mode. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeedY: function (value) - { - if (this.speedY) - { - this.speedY.onChange(value); - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = false; - } - - return this; - }, - - /** - * Sets the initial radial speed of emitted particles. - * Changes the emitter to radial mode. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeed: function (value) - { - this.speedX.onChange(value); - this.speedY = null; - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = true; - - return this; - }, - - /** - * Sets the horizontal scale of emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScaleX: function (value) - { - this.scaleX.onChange(value); - - return this; - }, - - /** - * Sets the vertical scale of emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScaleY: function (value) - { - this.scaleY.onChange(value); - - return this; - }, - - /** - * Sets the scale of emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScale: function (value) - { - this.scaleX.onChange(value); - this.scaleY = null; - - return this; - }, - - /** - * Sets the horizontal gravity applied to emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX - * @since 3.0.0 - * - * @param {float} value - Acceleration due to gravity, in pixels per second squared. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravityX: function (value) - { - this.gravityX = value; - - return this; - }, - - /** - * Sets the vertical gravity applied to emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY - * @since 3.0.0 - * - * @param {float} value - Acceleration due to gravity, in pixels per second squared. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravityY: function (value) - { - this.gravityY = value; - - return this; - }, - - /** - * Sets the gravity applied to emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity - * @since 3.0.0 - * - * @param {float} x - Horizontal acceleration due to gravity, in pixels per second squared. - * @param {float} y - Vertical acceleration due to gravity, in pixels per second squared. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravity: function (x, y) - { - this.gravityX = x; - this.gravityY = y; - - return this; - }, - - /** - * Sets the opacity of emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - A value between 0 (transparent) and 1 (opaque). - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setAlpha: function (value) - { - this.alpha.onChange(value); - - return this; - }, - - /** - * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setEmitterAngle: function (value) - { - this.angle.onChange(value); - - return this; - }, - - /** - * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setAngle: function (value) - { - this.angle.onChange(value); - - return this; - }, - - /** - * Sets the lifespan of newly emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The particle lifespan, in ms. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setLifespan: function (value) - { - this.lifespan.onChange(value); - - return this; - }, - - /** - * Sets the number of particles released at each flow cycle or explosion. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} quantity - The number of particles to release at each flow cycle or explosion. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setQuantity: function (quantity) - { - this.quantity.onChange(quantity); - - return this; - }, - - /** - * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} - * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency - * @since 3.0.0 - * - * @param {float} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. - * @param {float|float[]|EmitterOpOnEmitCallback|object} [quantity] - The number of particles to release at each flow cycle or explosion. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setFrequency: function (frequency, quantity) - { - this.frequency = frequency; - - this._counter = 0; - - if (quantity) - { - this.quantity.onChange(quantity); - } - - return this; - }, - - /** - * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#emitZone}. - * - * An {@link ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. Its {@link EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link EdgeZoneSourceCallback getPoints} method. - * - * A {@link ParticleEmitterRandomZoneConfig RandomZone} places randomly within its interior. Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link RandomZoneSourceCallback getRandomPoint} method. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone - * @since 3.0.0 - * - * @param {ParticleEmitterEdgeZoneConfig|ParticleEmitterRandomZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current emit zone. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setEmitZone: function (zoneConfig) - { - if (zoneConfig === undefined) - { - this.emitZone = null; - } - else - { - // Where source = Geom like Circle, or a Path or Curve - // emitZone: { type: 'random', source: X } - // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] } - - var type = GetFastValue(zoneConfig, 'type', 'random'); - var source = GetFastValue(zoneConfig, 'source', null); - - switch (type) - { - case 'random': - - this.emitZone = new RandomZone(source); - - break; - - case 'edge': - - var quantity = GetFastValue(zoneConfig, 'quantity', 1); - var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); - var yoyo = GetFastValue(zoneConfig, 'yoyo', false); - var seamless = GetFastValue(zoneConfig, 'seamless', true); - - this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); - - break; - } - } - - return this; - }, - - /** - * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#deathZone}. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone - * @since 3.0.0 - * - * @param {ParticleEmitterDeathZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current death zone. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setDeathZone: function (zoneConfig) - { - if (zoneConfig === undefined) - { - this.deathZone = null; - } - else - { - // Where source = Geom like Circle or Rect that supports a 'contains' function - // deathZone: { type: 'onEnter', source: X } - // deathZone: { type: 'onLeave', source: X } - - var type = GetFastValue(zoneConfig, 'type', 'onEnter'); - var source = GetFastValue(zoneConfig, 'source', null); - - if (source && typeof source.contains === 'function') - { - var killOnEnter = (type === 'onEnter') ? true : false; - - this.deathZone = new DeathZone(source, killOnEnter); - } - } - - return this; - }, - - /** - * Creates inactive particles and adds them to this emitter's pool. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve - * @since 3.0.0 - * - * @param {integer} particleCount - The number of particles to create. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - reserve: function (particleCount) - { - var dead = this.dead; + ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; for (var i = 0; i < particleCount; i++) { - dead.push(new this.particleClass(this)); - } + var particle = particles[i]; - return this; - }, + var alpha = particle.alpha * camera.alpha; - /** - * Gets the number of active (in-use) particles in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount - * @since 3.0.0 - * - * @return {integer} The number of particles with `active=true`. - */ - getAliveParticleCount: function () - { - return this.alive.length; - }, - - /** - * Gets the number of inactive (available) particles in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount - * @since 3.0.0 - * - * @return {integer} The number of particles with `active=false`. - */ - getDeadParticleCount: function () - { - return this.dead.length; - }, - - /** - * Gets the total number of particles in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount - * @since 3.0.0 - * - * @return {integer} The number of particles, including both alive and dead. - */ - getParticleCount: function () - { - return this.getAliveParticleCount() + this.getDeadParticleCount(); - }, - - /** - * Whether this emitter is at its limit (if set). - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit - * @since 3.0.0 - * - * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. - */ - atLimit: function () - { - return (this.maxParticles > 0 && this.getParticleCount() === this.maxParticles); - }, - - /** - * Sets a function to call for each newly emitted particle. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit - * @since 3.0.0 - * - * @param {ParticleEmitterCallback} callback - The function. - * @param {*} [context] - The calling context. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - onParticleEmit: function (callback, context) - { - if (callback === undefined) - { - // Clear any previously set callback - this.emitCallback = null; - this.emitCallbackScope = null; - } - else if (typeof callback === 'function') - { - this.emitCallback = callback; - - if (context) + if (alpha <= 0) { - this.emitCallbackScope = context; - } - } - - return this; - }, - - /** - * Sets a function to call for each particle death. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath - * @since 3.0.0 - * - * @param {ParticleDeathCallback} callback - The function. - * @param {*} [context] - The function's calling context. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - onParticleDeath: function (callback, context) - { - if (callback === undefined) - { - // Clear any previously set callback - this.deathCallback = null; - this.deathCallbackScope = null; - } - else if (typeof callback === 'function') - { - this.deathCallback = callback; - - if (context) - { - this.deathCallbackScope = context; - } - } - - return this; - }, - - /** - * Deactivates every particle in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - killAll: function () - { - var dead = this.dead; - var alive = this.alive; - - while (alive.length > 0) - { - dead.push(alive.pop()); - } - - return this; - }, - - /** - * Calls a function for each active particle in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive - * @since 3.0.0 - * - * @param {ParticleEmitterCallback} callback - The function. - * @param {*} context - The function's calling context. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - forEachAlive: function (callback, context) - { - var alive = this.alive; - var length = alive.length; - - for (var index = 0; index < length; ++index) - { - // Sends the Particle and the Emitter - callback.call(context, alive[index], this); - } - - return this; - }, - - /** - * Calls a function for each inactive particle in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead - * @since 3.0.0 - * - * @param {ParticleEmitterCallback} callback - The function. - * @param {*} context - The function's calling context. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - forEachDead: function (callback, context) - { - var dead = this.dead; - var length = dead.length; - - for (var index = 0; index < length; ++index) - { - // Sends the Particle and the Emitter - callback.call(context, dead[index], this); - } - - return this; - }, - - /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. - * - * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). - * - * If this emitter is in explode mode (frequency = -1), nothing will happen. - * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#start - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - start: function () - { - this.on = true; - - this._counter = 0; - - return this; - }, - - /** - * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#pause - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - pause: function () - { - this.active = false; - - return this; - }, - - /** - * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#resume - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - resume: function () - { - this.active = true; - - return this; - }, - - /** - * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - depthSort: function () - { - StableSort.inplace(this.alive, this.depthSortCallback); - - return this; - }, - - /** - * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. - * - * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#flow - * @since 3.0.0 - * - * @param {float} frequency - The time interval (>= 0) of each flow cycle, in ms. - * @param {float|float[]|EmitterOpOnEmitCallback|object} [count=1] - The number of particles to emit at each flow cycle. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - flow: function (frequency, count) - { - if (count === undefined) { count = 1; } - - this.frequency = frequency; - - this.quantity.onChange(count); - - return this.start(); - }, - - /** - * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#explode - * @since 3.0.0 - * - * @param {integer} count - The amount of Particles to emit. - * @param {float} x - The x coordinate to emit the Particles from. - * @param {float} y - The y coordinate to emit the Particles from. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - explode: function (count, x, y) - { - this.frequency = -1; - - return this.emitParticle(count, x, y); - }, - - /** - * Emits particles at a given position (or the emitter's current position). - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt - * @since 3.0.0 - * - * @param {float} [x=this.x] - The x coordinate to emit the Particles from. - * @param {float} [y=this.x] - The y coordinate to emit the Particles from. - * @param {integer} [count=this.quantity] - The number of Particles to emit. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - emitParticleAt: function (x, y, count) - { - return this.emitParticle(count, x, y); - }, - - /** - * Emits particles at a given position (or the emitter's current position). - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle - * @since 3.0.0 - * - * @param {integer} [count=this.quantity] - The number of Particles to emit. - * @param {float} [x=this.x] - The x coordinate to emit the Particles from. - * @param {float} [y=this.x] - The y coordinate to emit the Particles from. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - * - * @see Phaser.GameObjects.Particles.Particle#fire - */ - emitParticle: function (count, x, y) - { - if (this.atLimit()) - { - return; - } - - if (count === undefined) - { - count = this.quantity.onEmit(); - } - - var dead = this.dead; - - for (var i = 0; i < count; i++) - { - var particle; - - if (dead.length > 0) - { - particle = dead.pop(); - } - else - { - particle = new this.particleClass(this); + continue; } - particle.fire(x, y); + var frame = particle.frame; + var cd = frame.canvasData; - if (this.particleBringToTop) + var x = -(frame.halfWidth); + var y = -(frame.halfHeight); + + particleMatrix.applyITRS(0, 0, particle.rotation, particle.scaleX, particle.scaleY); + + particleMatrix.e = particle.x - scrollX; + particleMatrix.f = particle.y - scrollY; + + camMatrix.multiply(particleMatrix, calcMatrix); + + ctx.globalAlpha = alpha; + + ctx.save(); + + calcMatrix.copyToContext(ctx); + + if (roundPixels) { - this.alive.push(particle); - } - else - { - this.alive.unshift(particle); + x |= 0; + y |= 0; } - if (this.emitCallback) - { - this.emitCallback.call(this.emitCallbackScope, particle, this); - } + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height); - if (this.atLimit()) - { - break; - } + ctx.restore(); } - - return particle; - }, - - /** - * Updates this emitter and its particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate - * @since 3.0.0 - * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {float} delta - The delta time, in ms, elapsed since the last frame. - */ - preUpdate: function (time, delta) - { - // Scale the delta - delta *= this.timeScale; - - var step = (delta / 1000); - - if (this.trackVisible) - { - this.visible = this.follow.visible; - } - - // Any particle processors? - var processors = this.manager.getProcessors(); - - var particles = this.alive; - var length = particles.length; - - for (var index = 0; index < length; index++) - { - var particle = particles[index]; - - // update returns `true` if the particle is now dead (lifeStep < 0) - if (particle.update(delta, step, processors)) - { - // Moves the dead particle to the end of the particles array (ready for splicing out later) - var last = particles[length - 1]; - - particles[length - 1] = particle; - particles[index] = last; - - index -= 1; - length -= 1; - } - } - - // Move dead particles to the dead array - var deadLength = particles.length - length; - - if (deadLength > 0) - { - var rip = particles.splice(particles.length - deadLength, deadLength); - - var deathCallback = this.deathCallback; - var deathCallbackScope = this.deathCallbackScope; - - if (deathCallback) - { - for (var i = 0; i < rip.length; i++) - { - deathCallback.call(deathCallbackScope, rip[i]); - } - } - - this.dead.concat(rip); - - StableSort.inplace(particles, this.indexSortCallback); - } - - if (!this.on) - { - return; - } - - if (this.frequency === 0) - { - this.emitParticle(); - } - else if (this.frequency > 0) - { - this._counter -= delta; - - if (this._counter <= 0) - { - this.emitParticle(); - - // counter = frequency - remained from previous delta - this._counter = (this.frequency - Math.abs(this._counter)); - } - } - }, - - /** - * Calculates the difference of two particles, for sorting them by depth. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback - * @since 3.0.0 - * - * @param {object} a - The first particle. - * @param {object} b - The second particle. - * - * @return {integer} The difference of a and b's y coordinates. - */ - depthSortCallback: function (a, b) - { - return a.y - b.y; - }, - - /** - * Calculates the difference of two particles, for sorting them by index. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback - * @since 3.0.0 - * - * @param {object} a - The first particle. - * @param {object} b - The second particle. - * - * @return {integer} The difference of a and b's `index` properties. - */ - indexSortCallback: function (a, b) - { - return a.index - b.index; } -}); - -module.exports = ParticleEmitter; - - -/***/ }), -/* 457 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var DistanceBetween = __webpack_require__(58); - -var GetColor = function (value) -{ - return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); + ctx.restore(); }; -/** - * @classdesc - * A Particle is a simple Game Object controlled by a Particle Emitter and Manager, and rendered by the Manager. - * It uses its own lightweight physics system, and can interact only with its Emitter's bounds and zones. - * - * @class Particle - * @memberOf Phaser.GameObjects.Particles - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to which this Particle belongs. - */ -var Particle = new Class({ - - initialize: - - function Particle (emitter) - { - /** - * The Emitter to which this Particle belongs. - * - * A Particle can only belong to a single Emitter and is created, updated and destroyed via it. - * - * @name Phaser.GameObjects.Particles.Particle#emitter - * @type {Phaser.GameObjects.Particles.ParticleEmitter} - * @since 3.0.0 - */ - this.emitter = emitter; - - /** - * The texture frame used to render this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#frame - * @type {Phaser.Textures.Frame} - * @default null - * @since 3.0.0 - */ - this.frame = null; - - /** - * The position of this Particle within its Emitter's particle pool. - * - * @name Phaser.GameObjects.Particles.Particle#index - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.index = 0; - - /** - * The x coordinate of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The y coordinate of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The x velocity of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#velocityX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.velocityX = 0; - - /** - * The y velocity of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#velocityY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.velocityY = 0; - - /** - * The x acceleration of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#accelerationX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelerationX = 0; - - /** - * The y acceleration of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#accelerationY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelerationY = 0; - - /** - * The maximum horizontal velocity this Particle can travel at. - * - * @name Phaser.GameObjects.Particles.Particle#maxVelocityX - * @type {number} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityX = 10000; - - /** - * The maximum vertical velocity this Particle can travel at. - * - * @name Phaser.GameObjects.Particles.Particle#maxVelocityY - * @type {number} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityY = 10000; - - /** - * The bounciness, or restitution, of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#bounce - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.bounce = 0; - - /** - * The horizontal scale of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#scaleX - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.scaleX = 1; - - /** - * The vertical scale of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#scaleY - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.scaleY = 1; - - /** - * The alpha value of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#alpha - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.alpha = 1; - - /** - * The angle of this Particle in degrees. - * - * @name Phaser.GameObjects.Particles.Particle#angle - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angle = 0; - - /** - * The angle of this Particle in radians. - * - * @name Phaser.GameObjects.Particles.Particle#rotation - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotation = 0; - - /** - * The tint applied to this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#tint - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - this.tint = 0xffffff; - - /** - * The full color of this Particle, computed from its alpha and tint. - * - * @name Phaser.GameObjects.Particles.Particle#color - * @type {integer} - * @since 3.0.0 - */ - this.color = 16777215; - - /** - * The lifespan of this Particle in ms. - * - * @name Phaser.GameObjects.Particles.Particle#life - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.life = 1000; - - /** - * The current life of this Particle in ms. - * - * @name Phaser.GameObjects.Particles.Particle#lifeCurrent - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.lifeCurrent = 1000; - - /** - * The delay applied to this Particle upon emission, in ms. - * - * @name Phaser.GameObjects.Particles.Particle#delayCurrent - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.delayCurrent = 0; - - /** - * The normalized lifespan T value, where 0 is the start and 1 is the end. - * - * @name Phaser.GameObjects.Particles.Particle#lifeT - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.lifeT = 0; - - /** - * The data used by the ease equation. - * - * @name Phaser.GameObjects.Particles.Particle#data - * @type {object} - * @since 3.0.0 - */ - this.data = { - tint: { min: 0xffffff, max: 0xffffff, current: 0xffffff }, - alpha: { min: 1, max: 1 }, - rotate: { min: 0, max: 0 }, - scaleX: { min: 1, max: 1 }, - scaleY: { min: 1, max: 1 } - }; - }, - - /** - * Checks to see if this Particle is alive and updating. - * - * @method Phaser.GameObjects.Particles.Particle#isAlive - * @since 3.0.0 - * - * @return {boolean} `true` if this Particle is alive and updating, otherwise `false`. - */ - isAlive: function () - { - return (this.lifeCurrent > 0); - }, - - /** - * Starts this Particle from the given coordinates. - * - * @method Phaser.GameObjects.Particles.Particle#fire - * @since 3.0.0 - * - * @param {number} x - The x coordinate to launch this Particle from. - * @param {number} y - The y coordinate to launch this Particle from. - */ - fire: function (x, y) - { - var emitter = this.emitter; - - this.frame = emitter.getFrame(); - - if (emitter.emitZone) - { - // Updates particle.x and particle.y during this call - emitter.emitZone.getPoint(this); - } - - if (x === undefined) - { - if (emitter.follow) - { - this.x += emitter.follow.x + emitter.followOffset.x; - } - - this.x += emitter.x.onEmit(this, 'x'); - } - else - { - this.x += x; - } - - if (y === undefined) - { - if (emitter.follow) - { - this.y += emitter.follow.y + emitter.followOffset.y; - } - - this.y += emitter.y.onEmit(this, 'y'); - } - else - { - this.y += y; - } - - this.life = emitter.lifespan.onEmit(this, 'lifespan'); - this.lifeCurrent = this.life; - this.lifeT = 0; - - var sx = emitter.speedX.onEmit(this, 'speedX'); - var sy = (emitter.speedY) ? emitter.speedY.onEmit(this, 'speedY') : sx; - - if (emitter.radial) - { - var rad = DegToRad(emitter.angle.onEmit(this, 'angle')); - - this.velocityX = Math.cos(rad) * Math.abs(sx); - this.velocityY = Math.sin(rad) * Math.abs(sy); - } - else if (emitter.moveTo) - { - var mx = emitter.moveToX.onEmit(this, 'moveToX'); - var my = (emitter.moveToY) ? emitter.moveToY.onEmit(this, 'moveToY') : mx; - - var angle = Math.atan2(my - this.y, mx - this.x); - - var speed = DistanceBetween(this.x, this.y, mx, my) / (this.life / 1000); - - // We know how many pixels we need to move, but how fast? - // var speed = this.distanceToXY(displayObject, x, y) / (maxTime / 1000); - - this.velocityX = Math.cos(angle) * speed; - this.velocityY = Math.sin(angle) * speed; - } - else - { - this.velocityX = sx; - this.velocityY = sy; - } - - if (emitter.acceleration) - { - this.accelerationX = emitter.accelerationX.onEmit(this, 'accelerationX'); - this.accelerationY = emitter.accelerationY.onEmit(this, 'accelerationY'); - } - - this.maxVelocityX = emitter.maxVelocityX.onEmit(this, 'maxVelocityX'); - this.maxVelocityY = emitter.maxVelocityY.onEmit(this, 'maxVelocityY'); - - this.delayCurrent = emitter.delay.onEmit(this, 'delay'); - - this.scaleX = emitter.scaleX.onEmit(this, 'scaleX'); - this.scaleY = (emitter.scaleY) ? emitter.scaleY.onEmit(this, 'scaleY') : this.scaleX; - - this.angle = emitter.rotate.onEmit(this, 'rotate'); - this.rotation = DegToRad(this.angle); - - this.bounce = emitter.bounce.onEmit(this, 'bounce'); - - this.alpha = emitter.alpha.onEmit(this, 'alpha'); - - this.tint = emitter.tint.onEmit(this, 'tint'); - - var ua = ((this.alpha * 255) | 0) & 0xFF; - - this.color = ((ua << 24) | GetColor(this.tint)) >>> 0; - - this.index = emitter.alive.length; - }, - - /** - * An internal method that calculates the velocity of the Particle. - * - * @method Phaser.GameObjects.Particles.Particle#computeVelocity - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter that is updating this Particle. - * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. - * @param {array} processors - Particle processors (gravity wells). - */ - computeVelocity: function (emitter, delta, step, processors) - { - var vx = this.velocityX; - var vy = this.velocityY; - - var ax = this.accelerationX; - var ay = this.accelerationY; - - var mx = this.maxVelocityX; - var my = this.maxVelocityY; - - vx += (emitter.gravityX * step); - vy += (emitter.gravityY * step); - - if (ax) - { - vx += (ax * step); - } - - if (ay) - { - vy += (ay * step); - } - - if (vx > mx) - { - vx = mx; - } - else if (vx < -mx) - { - vx = -mx; - } - - if (vy > my) - { - vy = my; - } - else if (vy < -my) - { - vy = -my; - } - - this.velocityX = vx; - this.velocityY = vy; - - // Apply any additional processors - for (var i = 0; i < processors.length; i++) - { - processors[i].update(this, delta, step); - } - }, - - /** - * Checks if this Particle is still within the bounds defined by the given Emitter. - * - * If not, and depending on the Emitter collision flags, the Particle may either stop or rebound. - * - * @method Phaser.GameObjects.Particles.Particle#checkBounds - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to check the bounds against. - */ - checkBounds: function (emitter) - { - var bounds = emitter.bounds; - var bounce = -this.bounce; - - if (this.x < bounds.x && emitter.collideLeft) - { - this.x = bounds.x; - this.velocityX *= bounce; - } - else if (this.x > bounds.right && emitter.collideRight) - { - this.x = bounds.right; - this.velocityX *= bounce; - } - - if (this.y < bounds.y && emitter.collideTop) - { - this.y = bounds.y; - this.velocityY *= bounce; - } - else if (this.y > bounds.bottom && emitter.collideBottom) - { - this.y = bounds.bottom; - this.velocityY *= bounce; - } - }, - - /** - * The main update method for this Particle. - * - * Updates its life values, computes the velocity and repositions the Particle. - * - * @method Phaser.GameObjects.Particles.Particle#update - * @since 3.0.0 - * - * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. - * @param {array} processors - An optional array of update processors. - * - * @return {boolean} Returns `true` if this Particle has now expired and should be removed, otherwise `false` if still active. - */ - update: function (delta, step, processors) - { - if (this.delayCurrent > 0) - { - this.delayCurrent -= delta; - - return false; - } - - var emitter = this.emitter; - - // How far along in life is this particle? (t = 0 to 1) - var t = 1 - (this.lifeCurrent / this.life); - - this.lifeT = t; - - this.computeVelocity(emitter, delta, step, processors); - - this.x += this.velocityX * step; - this.y += this.velocityY * step; - - if (emitter.bounds) - { - this.checkBounds(emitter); - } - - if (emitter.deathZone && emitter.deathZone.willKill(this)) - { - this.lifeCurrent = 0; - - // No need to go any further, particle has been killed - return true; - } - - this.scaleX = emitter.scaleX.onUpdate(this, 'scaleX', t, this.scaleX); - - if (emitter.scaleY) - { - this.scaleY = emitter.scaleY.onUpdate(this, 'scaleY', t, this.scaleY); - } - else - { - this.scaleY = this.scaleX; - } - - this.angle = emitter.rotate.onUpdate(this, 'rotate', t, this.angle); - this.rotation = DegToRad(this.angle); - - this.alpha = emitter.alpha.onUpdate(this, 'alpha', t, this.alpha); - - this.tint = emitter.tint.onUpdate(this, 'tint', t, this.tint); - - var ua = ((this.alpha * 255) | 0) & 0xFF; - - this.color = ((ua << 24) | GetColor(this.tint)) >>> 0; - - this.lifeCurrent -= delta; - - return (this.lifeCurrent <= 0); - } - -}); - -module.exports = Particle; +module.exports = ParticleManagerCanvasRenderer; /***/ }), -/* 458 */ +/* 820 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.EmitterManager#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) +{ + var emitters = emitterManager.emitters.list; + var emittersLength = emitters.length; + + if (emittersLength === 0) + { + return; + } + + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1.copyFrom(camera.matrix); + var calcMatrix = pipeline._tempMatrix2; + var particleMatrix = pipeline._tempMatrix3; + var managerMatrix = pipeline._tempMatrix4.applyITRS(emitterManager.x, emitterManager.y, emitterManager.rotation, emitterManager.scaleX, emitterManager.scaleY); + + camMatrix.multiply(managerMatrix); + + renderer.setPipeline(pipeline); + + var roundPixels = camera.roundPixels; + var texture = emitterManager.defaultFrame.glTexture; + var getTint = Utils.getTintAppendFloatAlphaAndSwap; + + pipeline.setTexture2D(texture, 0); + + for (var e = 0; e < emittersLength; e++) + { + var emitter = emitters[e]; + var particles = emitter.alive; + var particleCount = particles.length; + + if (!emitter.visible || particleCount === 0) + { + continue; + } + + var scrollX = camera.scrollX * emitter.scrollFactorX; + var scrollY = camera.scrollY * emitter.scrollFactorY; + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -scrollX, -scrollY); + + scrollX = 0; + scrollY = 0; + } + + if (renderer.setBlendMode(emitter.blendMode)) + { + // Rebind the texture if we've flushed + pipeline.setTexture2D(texture, 0); + } + + var tintEffect = 0; + + for (var i = 0; i < particleCount; i++) + { + var particle = particles[i]; + + var alpha = particle.alpha * camera.alpha; + + if (alpha <= 0) + { + continue; + } + + var frame = particle.frame; + + var x = -(frame.halfWidth); + var y = -(frame.halfHeight); + var xw = x + frame.width; + var yh = y + frame.height; + + particleMatrix.applyITRS(0, 0, particle.rotation, particle.scaleX, particle.scaleY); + + particleMatrix.e = particle.x - scrollX; + particleMatrix.f = particle.y - scrollY; + + camMatrix.multiply(particleMatrix, calcMatrix); + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + var tint = getTint(particle.tint, alpha); + + if (pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect)) + { + pipeline.setTexture2D(texture, 0); + } + } + } +}; + +module.exports = ParticleManagerWebGLRenderer; + + +/***/ }), +/* 821 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(820); +} + +if (true) +{ + renderCanvas = __webpack_require__(819); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 822 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -98615,222 +129195,666 @@ module.exports = Particle; */ var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var FloatBetween = __webpack_require__(299); +var GetEaseFunction = __webpack_require__(86); +var GetFastValue = __webpack_require__(2); +var Wrap = __webpack_require__(53); /** - * @typedef {object} GravityWellConfig + * The returned value sets what the property will be at the START of the particle's life, on emit. + * @callback EmitterOpOnEmitCallback * - * @property {number} [x=0] - The x coordinate of the Gravity Well, in world space. - * @property {number} [y=0] - The y coordinate of the Gravity Well, in world space. - * @property {number} [power=0] - The power of the Gravity Well. - * @property {number} [epsilon=100] - [description] - * @property {number} [gravity=50] - The gravitational force of this Gravity Well. + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + +/** + * The returned value updates the property for the duration of the particle's life. + * @callback EmitterOpOnUpdateCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The normalized lifetime of the particle, between 0 (start) and 1 (end). + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + +/** + * Defines an operation yielding a random value within a range. + * @typedef {object} EmitterOpRandomConfig + * + * @property {number[]} random - The minimum and maximum values, as [min, max]. + */ + +/** + * Defines an operation yielding a random value within a range. + * @typedef {object} EmitterOpRandomMinMaxConfig + * + * @property {number} min - The minimum value. + * @property {number} max - The maximum value. + */ + +/** + * Defines an operation yielding a random value within a range. + * @typedef {object} EmitterOpRandomStartEndConfig + * + * @property {number} start - The starting value. + * @property {number} end - The ending value. + * @property {boolean} random - If false, this becomes {@link EmitterOpEaseConfig}. + */ + +/** + * Defines an operation yielding a value incremented continuously across a range. + * @typedef {object} EmitterOpEaseConfig + * + * @property {number} start - The starting value. + * @property {number} end - The ending value. + * @property {string} [ease='Linear'] - The name of the easing function. + */ + +/** + * Defines an operation yielding a value incremented by steps across a range. + * @typedef {object} EmitterOpSteppedConfig + * + * @property {number} start - The starting value. + * @property {number} end - The ending value. + * @property {number} steps - The number of steps between start and end. + */ + +/** + * @typedef {object} EmitterOpCustomEmitConfig + * + * @property {EmitterOpOnEmitCallback} onEmit - [description] + */ + +/** + * @typedef {object} EmitterOpCustomUpdateConfig + * + * @property {EmitterOpOnEmitCallback} [onEmit] - [description] + * @property {EmitterOpOnUpdateCallback} onUpdate - [description] */ /** * @classdesc - * [description] + * A Particle Emitter property. * - * @class GravityWell - * @memberOf Phaser.GameObjects.Particles + * Facilitates changing Particle properties as they are emitted and throughout their lifetime. + * + * @class EmitterOp + * @memberof Phaser.GameObjects.Particles * @constructor * @since 3.0.0 * - * @param {(number|GravityWellConfig)} [x=0] - The x coordinate of the Gravity Well, in world space. - * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. - * @param {number} [power=0] - The power of the Gravity Well. - * @param {number} [epsilon=100] - [description] - * @param {number} [gravity=50] - The gravitational force of this Gravity Well. + * @param {ParticleEmitterConfig} config - Settings for the Particle Emitter that owns this property. + * @param {string} key - The name of the property. + * @param {number} defaultValue - The default value of the property. + * @param {boolean} [emitOnly=false] - Whether the property can only be modified when a Particle is emitted. */ -var GravityWell = new Class({ +var EmitterOp = new Class({ initialize: - function GravityWell (x, y, power, epsilon, gravity) + function EmitterOp (config, key, defaultValue, emitOnly) { - if (typeof x === 'object') + if (emitOnly === undefined) { - var config = x; - - x = GetFastValue(config, 'x', 0); - y = GetFastValue(config, 'y', 0); - power = GetFastValue(config, 'power', 0); - epsilon = GetFastValue(config, 'epsilon', 100); - gravity = GetFastValue(config, 'gravity', 50); - } - else - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (power === undefined) { power = 0; } - if (epsilon === undefined) { epsilon = 100; } - if (gravity === undefined) { gravity = 50; } + emitOnly = false; } /** - * The x coordinate of the Gravity Well, in world space. + * The name of this property. * - * @name Phaser.GameObjects.Particles.GravityWell#x + * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey + * @type {string} + * @since 3.0.0 + */ + this.propertyKey = key; + + /** + * The value of this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue * @type {number} * @since 3.0.0 */ - this.x = x; + this.propertyValue = defaultValue; /** - * The y coordinate of the Gravity Well, in world space. + * The default value of this property. * - * @name Phaser.GameObjects.Particles.GravityWell#y + * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue * @type {number} * @since 3.0.0 */ - this.y = y; + this.defaultValue = defaultValue; /** - * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. + * The number of steps for stepped easing between {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} values, per emit. * - * @name Phaser.GameObjects.Particles.GravityWell#active + * @name Phaser.GameObjects.Particles.EmitterOp#steps + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.steps = 0; + + /** + * The step counter for stepped easing, per emit. + * + * @name Phaser.GameObjects.Particles.EmitterOp#counter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.counter = 0; + + /** + * The start value for this property to ease between. + * + * @name Phaser.GameObjects.Particles.EmitterOp#start + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.start = 0; + + /** + * The end value for this property to ease between. + * + * @name Phaser.GameObjects.Particles.EmitterOp#end + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.end = 0; + + /** + * The easing function to use for updating this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#ease + * @type {?function} + * @since 3.0.0 + */ + this.ease; + + /** + * Whether this property can only be modified when a Particle is emitted. + * + * Set to `true` to allow only {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} callbacks to be set and + * affect this property. + * + * Set to `false` to allow both {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks to be set and affect this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly * @type {boolean} - * @default true * @since 3.0.0 */ - this.active = true; + this.emitOnly = emitOnly; /** - * Internal gravity value. + * The callback to run for Particles when they are emitted from the Particle Emitter. * - * @name Phaser.GameObjects.Particles.GravityWell#_gravity - * @type {number} - * @private + * @name Phaser.GameObjects.Particles.EmitterOp#onEmit + * @type {EmitterOpOnEmitCallback} * @since 3.0.0 */ - this._gravity = gravity; + this.onEmit = this.defaultEmit; /** - * Internal power value. + * The callback to run for Particles when they are updated. * - * @name Phaser.GameObjects.Particles.GravityWell#_power - * @type {number} - * @private - * @default 0 + * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate + * @type {EmitterOpOnUpdateCallback} * @since 3.0.0 */ - this._power = 0; + this.onUpdate = this.defaultUpdate; - /** - * Internal epsilon value. - * - * @name Phaser.GameObjects.Particles.GravityWell#_epsilon - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._epsilon = 0; - - /** - * The power of the Gravity Well. - * - * @name Phaser.GameObjects.Particles.GravityWell#power - * @type {number} - * @since 3.0.0 - */ - this.power = power; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.GravityWell#epsilon - * @type {number} - * @since 3.0.0 - */ - this.epsilon = epsilon; + this.loadConfig(config); }, /** - * Takes a Particle and updates it based on the properties of this Gravity Well. + * Load the property from a Particle Emitter configuration object. * - * @method Phaser.GameObjects.Particles.GravityWell#update + * Optionally accepts a new property key to use, replacing the current one. + * + * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig * @since 3.0.0 * - * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. - * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. + * @param {ParticleEmitterConfig} [config] - Settings for the Particle Emitter that owns this property. + * @param {string} [newKey] - The new key to use for this property, if any. */ - update: function (particle, delta) + loadConfig: function (config, newKey) { - var x = this.x - particle.x; - var y = this.y - particle.y; - var dSq = x * x + y * y; - - if (dSq === 0) + if (config === undefined) { - return; + config = {}; } - var d = Math.sqrt(dSq); - - if (dSq < this._epsilon) + if (newKey) { - dSq = this._epsilon; + this.propertyKey = newKey; } - var factor = ((this._power * delta) / (dSq * d)) * 100; + this.propertyValue = GetFastValue( + config, + this.propertyKey, + this.defaultValue + ); - particle.velocityX += x * factor; - particle.velocityY += y * factor; + this.setMethods(); + + if (this.emitOnly) + { + // Reset it back again + this.onUpdate = this.defaultUpdate; + } }, - epsilon: { - - get: function () - { - return Math.sqrt(this._epsilon); - }, - - set: function (value) - { - this._epsilon = value * value; - } - + /** + * Build a JSON representation of this Particle Emitter property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#toJSON + * @since 3.0.0 + * + * @return {object} A JSON representation of this Particle Emitter property. + */ + toJSON: function () + { + return this.propertyValue; }, - power: { - - get: function () - { - return this._power / this._gravity; - }, - - set: function (value) - { - this._power = value * this._gravity; - } + /** + * Change the current value of the property and update its callback methods. + * + * @method Phaser.GameObjects.Particles.EmitterOp#onChange + * @since 3.0.0 + * + * @param {number} value - The value of the property. + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + onChange: function (value) + { + this.propertyValue = value; + return this.setMethods(); }, - gravity: { + /** + * Update the {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks based on the type of the current + * {@link Phaser.GameObjects.Particles.EmitterOp#propertyValue}. + * + * @method Phaser.GameObjects.Particles.EmitterOp#setMethods + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + setMethods: function () + { + var value = this.propertyValue; - get: function () - { - return this._gravity; - }, + var t = typeof value; - set: function (value) + if (t === 'number') { - var pwr = this.power; - this._gravity = value; - this.power = pwr; + // Explicit static value: + // x: 400 + + this.onEmit = this.staticValueEmit; + this.onUpdate = this.staticValueUpdate; // How? + } + else if (Array.isArray(value)) + { + // Picks a random element from the array: + // x: [ 100, 200, 300, 400 ] + + this.onEmit = this.randomStaticValueEmit; + } + else if (t === 'function') + { + // The same as setting just the onUpdate function and no onEmit (unless this op is an emitOnly one) + // Custom callback, must return a value: + + /* + x: function (particle, key, t, value) + { + return value + 50; + } + */ + + if (this.emitOnly) + { + this.onEmit = value; + } + else + { + this.onUpdate = value; + } + } + else if (t === 'object' && (this.has(value, 'random') || this.hasBoth(value, 'start', 'end') || this.hasBoth(value, 'min', 'max'))) + { + this.start = this.has(value, 'start') ? value.start : value.min; + this.end = this.has(value, 'end') ? value.end : value.max; + + var isRandom = (this.hasBoth(value, 'min', 'max') || this.has(value, 'random')); + + // A random starting value (using 'min | max' instead of 'start | end' automatically implies a random value) + + // x: { start: 100, end: 400, random: true } OR { min: 100, max: 400 } OR { random: [ 100, 400 ] } + + if (isRandom) + { + var rnd = value.random; + + // x: { random: [ 100, 400 ] } = the same as doing: x: { start: 100, end: 400, random: true } + if (Array.isArray(rnd)) + { + this.start = rnd[0]; + this.end = rnd[1]; + } + + this.onEmit = this.randomRangedValueEmit; + } + + if (this.has(value, 'steps')) + { + // A stepped (per emit) range + + // x: { start: 100, end: 400, steps: 64 } + + // Increments a value stored in the emitter + + this.steps = value.steps; + this.counter = this.start; + + this.onEmit = this.steppedEmit; + } + else + { + // An eased range (defaults to Linear if not specified) + + // x: { start: 100, end: 400, [ ease: 'Linear' ] } + + var easeType = this.has(value, 'ease') ? value.ease : 'Linear'; + + this.ease = GetEaseFunction(easeType); + + if (!isRandom) + { + this.onEmit = this.easedValueEmit; + } + + // BUG: alpha, rotate, scaleX, scaleY, or tint are eased here if {min, max} is given. + // Probably this branch should exclude isRandom entirely. + + this.onUpdate = this.easeValueUpdate; + } + } + else if (t === 'object' && this.hasEither(value, 'onEmit', 'onUpdate')) + { + // Custom onEmit and onUpdate callbacks + + /* + x: { + // Called at the start of the particles life, when it is being created + onEmit: function (particle, key, t, value) + { + return value; + }, + + // Called during the particles life on each update + onUpdate: function (particle, key, t, value) + { + return value; + } + } + */ + + if (this.has(value, 'onEmit')) + { + this.onEmit = value.onEmit; + } + + if (this.has(value, 'onUpdate')) + { + this.onUpdate = value.onUpdate; + } } + return this; + }, + + /** + * Check whether an object has the given property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#has + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key - The key of the property to look for in the object. + * + * @return {boolean} `true` if the property exists in the object, `false` otherwise. + */ + has: function (object, key) + { + return object.hasOwnProperty(key); + }, + + /** + * Check whether an object has both of the given properties. + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key1 - The key of the first property to check the object for. + * @param {string} key2 - The key of the second property to check the object for. + * + * @return {boolean} `true` if both properties exist in the object, `false` otherwise. + */ + hasBoth: function (object, key1, key2) + { + return object.hasOwnProperty(key1) && object.hasOwnProperty(key2); + }, + + /** + * Check whether an object has at least one of the given properties. + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasEither + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key1 - The key of the first property to check the object for. + * @param {string} key2 - The key of the second property to check the object for. + * + * @return {boolean} `true` if at least one of the properties exists in the object, `false` if neither exist. + */ + hasEither: function (object, key1, key2) + { + return object.hasOwnProperty(key1) || object.hasOwnProperty(key2); + }, + + /** + * The returned value sets what the property will be at the START of the particles life, on emit. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} [value] - The current value of the property. + * + * @return {number} The new value of hte property. + */ + defaultEmit: function (particle, key, value) + { + return value; + }, + + /** + * The returned value updates the property for the duration of the particles life. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The T value (between 0 and 1) + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + defaultUpdate: function (particle, key, t, value) + { + return value; + }, + + /** + * An `onEmit` callback that returns the current value of the property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit + * @since 3.0.0 + * + * @return {number} The current value of the property. + */ + staticValueEmit: function () + { + return this.propertyValue; + }, + + /** + * An `onUpdate` callback that returns the current value of the property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate + * @since 3.0.0 + * + * @return {number} The current value of the property. + */ + staticValueUpdate: function () + { + return this.propertyValue; + }, + + /** + * An `onEmit` callback that returns a random value from the current value array. + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit + * @since 3.0.0 + * + * @return {number} The new value of the property. + */ + randomStaticValueEmit: function () + { + var randomIndex = Math.floor(Math.random() * this.propertyValue.length); + + return this.propertyValue[randomIndex]; + }, + + /** + * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The key of the property. + * + * @return {number} The new value of the property. + */ + randomRangedValueEmit: function (particle, key) + { + var value = FloatBetween(this.start, this.end); + + if (particle && particle.data[key]) + { + particle.data[key].min = value; + } + + return value; + }, + + /** + * An `onEmit` callback that returns a stepped value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit + * @since 3.0.0 + * + * @return {number} The new value of the property. + */ + steppedEmit: function () + { + var current = this.counter; + + var next = this.counter + (this.end - this.start) / this.steps; + + this.counter = Wrap(next, this.start, this.end); + + return current; + }, + + /** + * An `onEmit` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * + * @return {number} The new value of the property. + */ + easedValueEmit: function (particle, key) + { + if (particle && particle.data[key]) + { + var data = particle.data[key]; + + data.min = this.start; + data.max = this.end; + } + + return this.start; + }, + + /** + * An `onUpdate` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The T value (between 0 and 1) + * + * @return {number} The new value of the property. + */ + easeValueUpdate: function (particle, key, t) + { + var data = particle.data[key]; + + return (data.max - data.min) * this.ease(t) + data.min; } - }); -module.exports = GravityWell; +module.exports = EmitterOp; /***/ }), -/* 459 */ +/* 823 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -98839,7 +129863,30 @@ module.exports = GravityWell; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); +/** + * @namespace Phaser.GameObjects.Particles + */ + +module.exports = { + + GravityWell: __webpack_require__(304), + Particle: __webpack_require__(303), + ParticleEmitter: __webpack_require__(302), + ParticleEmitterManager: __webpack_require__(155), + Zones: __webpack_require__(818) + +}; + + +/***/ }), +/* 824 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -98858,20 +129905,15 @@ var GameObject = __webpack_require__(2); */ var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera, parentMatrix); + renderer.batchSprite(src, src.frame, camera, parentMatrix); }; module.exports = ImageCanvasRenderer; /***/ }), -/* 460 */ -/***/ (function(module, exports, __webpack_require__) { +/* 825 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -98879,8 +129921,6 @@ module.exports = ImageCanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); - /** * Renders this Game Object with the WebGL Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -98898,11 +129938,6 @@ var GameObject = __webpack_require__(2); */ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - this.pipeline.batchSprite(src, camera, parentMatrix); }; @@ -98910,7 +129945,7 @@ module.exports = ImageWebGLRenderer; /***/ }), -/* 461 */ +/* 826 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -98919,17 +129954,17 @@ module.exports = ImageWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); if (true) { - renderWebGL = __webpack_require__(460); + renderWebGL = __webpack_require__(825); } if (true) { - renderCanvas = __webpack_require__(459); + renderCanvas = __webpack_require__(824); } module.exports = { @@ -98941,7 +129976,73 @@ module.exports = { /***/ }), -/* 462 */ +/* 827 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = SpriteCanvasRenderer; + + +/***/ }), +/* 828 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + this.pipeline.batchSprite(src, camera, parentMatrix); +}; + +module.exports = SpriteWebGLRenderer; + + +/***/ }), +/* 829 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -98950,7 +130051,57 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(828); +} + +if (true) +{ + renderCanvas = __webpack_require__(827); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 830 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Commands = __webpack_require__(157); +var Utils = __webpack_require__(10); + +// TODO: Remove the use of this +var Point = function (x, y, width) +{ + this.x = x; + this.y = y; + this.width = width; +}; + +// TODO: Remove the use of this +var Path = function (x, y, width) +{ + this.points = []; + this.pointsLength = 1; + this.points[0] = new Point(x, y, width); +}; + +var matrixStack = []; /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -98962,26 +130113,332 @@ var GameObject = __webpack_require__(2); * @private * * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Graphics} graphics - The Game Object being rendered in this call. + * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera, parentMatrix) +var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== graphics.renderFlags || (graphics.cameraFilter > 0 && (graphics.cameraFilter & camera._id))) + if (src.commandBuffer.length === 0) { return; } - this.pipeline.batchGraphics(this, camera, parentMatrix); + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var graphicsMatrix = pipeline._tempMatrix2; + var currentMatrix = pipeline._tempMatrix4; + + renderer.setPipeline(pipeline); + + currentMatrix.loadIdentity(); + + graphicsMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + graphicsMatrix.e = src.x; + graphicsMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(graphicsMatrix); + } + else + { + graphicsMatrix.e -= camera.scrollX * src.scrollFactorX; + graphicsMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(graphicsMatrix); + } + + var commands = src.commandBuffer; + var alpha = camera.alpha * src.alpha; + + var lineWidth = 1; + var fillTint = pipeline.fillTint; + var strokeTint = pipeline.strokeTint; + + var tx = 0; + var ty = 0; + var ta = 0; + var iterStep = 0.01; + var PI2 = Math.PI * 2; + + var cmd; + + var path = []; + var pathIndex = 0; + var pathOpen = false; + var lastPath = null; + + var getTint = Utils.getTintAppendFloatAlphaAndSwap; + + var currentTexture = renderer.blankTexture.glTexture; + + for (var cmdIndex = 0; cmdIndex < commands.length; cmdIndex++) + { + cmd = commands[cmdIndex]; + + switch (cmd) + { + case Commands.BEGIN_PATH: + + path.length = 0; + lastPath = null; + pathOpen = true; + break; + + case Commands.CLOSE_PATH: + + pathOpen = false; + + if (lastPath && lastPath.points.length) + { + lastPath.points.push(lastPath.points[0]); + } + break; + + case Commands.FILL_PATH: + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + pipeline.setTexture2D(currentTexture); + + pipeline.batchFillPath( + path[pathIndex].points, + currentMatrix, + camMatrix + ); + } + break; + + case Commands.STROKE_PATH: + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + pipeline.setTexture2D(currentTexture); + + pipeline.batchStrokePath( + path[pathIndex].points, + lineWidth, + pathOpen, + currentMatrix, + camMatrix + ); + } + break; + + case Commands.LINE_STYLE: + lineWidth = commands[++cmdIndex]; + var strokeColor = commands[++cmdIndex]; + var strokeAlpha = commands[++cmdIndex] * alpha; + var strokeTintColor = getTint(strokeColor, strokeAlpha); + strokeTint.TL = strokeTintColor; + strokeTint.TR = strokeTintColor; + strokeTint.BL = strokeTintColor; + strokeTint.BR = strokeTintColor; + break; + + case Commands.FILL_STYLE: + var fillColor = commands[++cmdIndex]; + var fillAlpha = commands[++cmdIndex] * alpha; + var fillTintColor = getTint(fillColor, fillAlpha); + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + break; + + case Commands.GRADIENT_FILL_STYLE: + var gradientFillAlpha = commands[++cmdIndex] * alpha; + fillTint.TL = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.TR = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.BL = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.BR = getTint(commands[++cmdIndex], gradientFillAlpha); + break; + + case Commands.GRADIENT_LINE_STYLE: + lineWidth = commands[++cmdIndex]; + var gradientLineAlpha = commands[++cmdIndex] * alpha; + strokeTint.TL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.TR = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BR = getTint(commands[++cmdIndex], gradientLineAlpha); + break; + + case Commands.ARC: + var iteration = 0; + var x = commands[++cmdIndex]; + var y = commands[++cmdIndex]; + var radius = commands[++cmdIndex]; + var startAngle = commands[++cmdIndex]; + var endAngle = commands[++cmdIndex]; + var anticlockwise = commands[++cmdIndex]; + var overshoot = commands[++cmdIndex]; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -PI2) + { + endAngle = -PI2; + } + else if (endAngle > 0) + { + endAngle = -PI2 + endAngle % PI2; + } + } + else if (endAngle > PI2) + { + endAngle = PI2; + } + else if (endAngle < 0) + { + endAngle = PI2 + endAngle % PI2; + } + + if (lastPath === null) + { + lastPath = new Path(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius, lineWidth); + path.push(lastPath); + iteration += iterStep; + } + + while (iteration < 1 + overshoot) + { + ta = endAngle * iteration + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.points.push(new Point(tx, ty, lineWidth)); + + iteration += iterStep; + } + + ta = endAngle + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.points.push(new Point(tx, ty, lineWidth)); + + break; + + case Commands.FILL_RECT: + pipeline.setTexture2D(currentTexture); + pipeline.batchFillRect( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + currentMatrix, + camMatrix + ); + break; + + case Commands.FILL_TRIANGLE: + pipeline.setTexture2D(currentTexture); + pipeline.batchFillTriangle( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + currentMatrix, + camMatrix + ); + break; + + case Commands.STROKE_TRIANGLE: + pipeline.setTexture2D(currentTexture); + pipeline.batchStrokeTriangle( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + lineWidth, + currentMatrix, + camMatrix + ); + break; + + case Commands.LINE_TO: + if (lastPath !== null) + { + lastPath.points.push(new Point(commands[++cmdIndex], commands[++cmdIndex], lineWidth)); + } + else + { + lastPath = new Path(commands[++cmdIndex], commands[++cmdIndex], lineWidth); + path.push(lastPath); + } + break; + + case Commands.MOVE_TO: + lastPath = new Path(commands[++cmdIndex], commands[++cmdIndex], lineWidth); + path.push(lastPath); + break; + + case Commands.SAVE: + matrixStack.push(currentMatrix.copyToArray()); + break; + + case Commands.RESTORE: + currentMatrix.copyFromArray(matrixStack.pop()); + break; + + case Commands.TRANSLATE: + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.translate(x, y); + break; + + case Commands.SCALE: + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.scale(x, y); + break; + + case Commands.ROTATE: + currentMatrix.rotate(commands[++cmdIndex]); + break; + + case Commands.SET_TEXTURE: + var frame = commands[++cmdIndex]; + var mode = commands[++cmdIndex]; + + pipeline.currentFrame = frame; + pipeline.setTexture2D(frame.glTexture, 0); + pipeline.tintEffect = mode; + + currentTexture = frame.glTexture; + + break; + + case Commands.CLEAR_TEXTURE: + pipeline.currentFrame = renderer.blankTexture; + pipeline.tintEffect = 2; + currentTexture = renderer.blankTexture.glTexture; + break; + } + } }; module.exports = GraphicsWebGLRenderer; /***/ }), -/* 463 */ +/* 831 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -98990,20 +130447,20 @@ module.exports = GraphicsWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); if (true) { - renderWebGL = __webpack_require__(462); + renderWebGL = __webpack_require__(830); // Needed for Graphics.generateTexture - renderCanvas = __webpack_require__(176); + renderCanvas = __webpack_require__(305); } if (true) { - renderCanvas = __webpack_require__(176); + renderCanvas = __webpack_require__(305); } module.exports = { @@ -99015,76 +130472,7 @@ module.exports = { /***/ }), -/* 464 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. - * - * @function Phaser.Geom.Ellipse.OffsetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Ellipse by. - * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. - */ -var OffsetPoint = function (ellipse, point) -{ - ellipse.x += point.x; - ellipse.y += point.y; - - return ellipse; -}; - -module.exports = OffsetPoint; - - -/***/ }), -/* 465 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Ellipse by the values given. - * - * @function Phaser.Geom.Ellipse.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {number} x - The amount to horizontally offset the Ellipse by. - * @param {number} y - The amount to vertically offset the Ellipse by. - * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. - */ -var Offset = function (ellipse, x, y) -{ - ellipse.x += x; - ellipse.y += y; - - return ellipse; -}; - -module.exports = Offset; - - -/***/ }), -/* 466 */ +/* 832 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -99093,419 +130481,1894 @@ module.exports = Offset; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(14); +var SetTransform = __webpack_require__(22); /** - * Returns the bounds of the Ellipse object. + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Geom.Ellipse.GetBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. - * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. - * - * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Ellipse bounds. - */ -var GetBounds = function (ellipse, out) -{ - if (out === undefined) { out = new Rectangle(); } - - out.x = ellipse.left; - out.y = ellipse.top; - out.width = ellipse.width; - out.height = ellipse.height; - - return out; -}; - -module.exports = GetBounds; - - -/***/ }), -/* 467 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. - * Returns `true` if they all match, otherwise returns `false`. - * - * @function Phaser.Geom.Ellipse.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. - * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. - * - * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. - */ -var Equals = function (ellipse, toCompare) -{ - return ( - ellipse.x === toCompare.x && - ellipse.y === toCompare.y && - ellipse.width === toCompare.width && - ellipse.height === toCompare.height - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 468 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse - * into the given `dest` Ellipse, then returns the `dest` Ellipse. - * - * @function Phaser.Geom.Ellipse.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Ellipse} O - [dest,$return] - * - * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. - * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. - * - * @return {Phaser.Geom.Ellipse} The dest Ellipse. - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.width, source.height); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 469 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(54); - -/** - * Check to see if the Ellipse contains all four points of the given Rectangle object. - * - * @function Phaser.Geom.Ellipse.ContainsRect - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not. - * - * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. - */ -var ContainsRect = function (ellipse, rect) -{ - return ( - Contains(ellipse, rect.x, rect.y) && - Contains(ellipse, rect.right, rect.y) && - Contains(ellipse, rect.x, rect.bottom) && - Contains(ellipse, rect.right, rect.bottom) - ); -}; - -module.exports = ContainsRect; - - -/***/ }), -/* 470 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(54); - -/** - * Check to see if the Ellipse contains the given Point object. - * - * @function Phaser.Geom.Ellipse.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. - * - * @return {boolean} True if the Point coordinates are within the circle, otherwise false. - */ -var ContainsPoint = function (ellipse, point) -{ - return Contains(ellipse, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 471 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Ellipse = __webpack_require__(114); - -/** - * Creates a new Ellipse instance based on the values contained in the given source. - * - * @function Phaser.Geom.Ellipse.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. - * - * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. - */ -var Clone = function (source) -{ - return new Ellipse(source.x, source.y, source.width, source.height); -}; - -module.exports = Clone; - - -/***/ }), -/* 472 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the area of the Ellipse. - * - * @function Phaser.Geom.Ellipse.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. - * - * @return {number} The area of the Ellipse. - */ -var Area = function (ellipse) -{ - if (ellipse.isEmpty()) - { - return 0; - } - - // units squared - return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); -}; - -module.exports = Area; - - -/***/ }), -/* 473 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Union - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Union = function (rectA, rectB, out) -{ - if (out === undefined) { out = new Rectangle(); } - - // Cache vars so we can use one of the input rects as the output rect - var x = Math.min(rectA.x, rectB.x); - var y = Math.min(rectA.y, rectB.y); - var w = Math.max(rectA.right, rectB.right) - x; - var h = Math.max(rectA.bottom, rectB.bottom) - y; - - return out.setTo(x, y, w, h); -}; - -module.exports = Union; - - -/***/ }), -/* 474 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Read an integer value from an XML Node. - * - * @function getValue + * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas * @since 3.0.0 * @private * - * @param {Node} node - The XML Node. - * @param {string} attribute - The attribute to read. - * - * @return {integer} The parsed value. + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -function getValue (node, attribute) +var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - return parseInt(node.getAttribute(attribute), 10); + var text = src.text; + var textLength = text.length; + + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + var textureFrame = src.frame; + + var displayCallback = src.displayCallback; + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + + var xAdvance = 0; + var yAdvance = 0; + + var indexCount = 0; + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + // var ctx = renderer.currentContext; + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var rotation = 0; + var scale = (src.fontSize / src.fontData.size); + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(0, 0, src.cropWidth, src.cropHeight); + ctx.clip(); + } + + for (var index = 0; index < textLength; ++index) + { + // Reset the scale (in case the callback changed it) + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + charCode = text.charCodeAt(index); + + if (charCode === 10) + { + xAdvance = 0; + indexCount = 0; + yAdvance += lineHeight; + lastGlyph = null; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = (indexCount + glyph.xOffset + xAdvance) - src.scrollX; + y = (glyph.yOffset + yAdvance) - src.scrollY; + + // This could be optimized so that it doesn't even bother drawing it if the x/y is out of range + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (displayCallback) + { + var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + } + + x *= scale; + y *= scale; + + x -= cameraScrollX; + y -= cameraScrollY; + + if (camera.roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.rotate(rotation); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + + xAdvance += glyph.xAdvance; + indexCount += 1; + lastGlyph = glyph; + lastCharCode = charCode; + } + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = DynamicBitmapTextCanvasRenderer; + + +/***/ }), +/* 833 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DynamicBitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src.text; + var textLength = text.length; + + if (textLength === 0) + { + return; + } + + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var crop = (src.cropWidth > 0 || src.cropHeight > 0); + + if (crop) + { + pipeline.flush(); + + renderer.pushScissor( + src.x, + src.y, + src.cropWidth * src.scaleX, + src.cropHeight * src.scaleY + ); + } + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + var fontMatrix = pipeline._tempMatrix4; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = texture.width; + var textureHeight = texture.height; + + var tintEffect = (src._isTinted && src.tintFill); + var tintTL = Utils.getTintAppendFloatAlpha(src._tintTL, camera.alpha * src._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(src._tintTR, camera.alpha * src._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, camera.alpha * src._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, camera.alpha * src._alphaBR); + + pipeline.setTexture2D(texture, 0); + + var xAdvance = 0; + var yAdvance = 0; + var charCode = 0; + var lastCharCode = 0; + var letterSpacing = src.letterSpacing; + var glyph; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + var lastGlyph; + var scrollX = src.scrollX; + var scrollY = src.scrollY; + + var fontData = src.fontData; + var chars = fontData.chars; + var lineHeight = fontData.lineHeight; + var scale = (src.fontSize / fontData.size); + var rotation = 0; + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + var roundPixels = camera.roundPixels; + var displayCallback = src.displayCallback; + var callbackData = src.callbackData; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + // Carriage-return + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + var x = (glyph.xOffset + xAdvance) - scrollX; + var y = (glyph.yOffset + yAdvance) - scrollY; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + if (displayCallback) + { + callbackData.color = 0; + callbackData.tint.topLeft = tintTL; + callbackData.tint.topRight = tintTR; + callbackData.tint.bottomLeft = tintBL; + callbackData.tint.bottomRight = tintBR; + callbackData.index = i; + callbackData.charCode = charCode; + callbackData.x = x; + callbackData.y = y; + callbackData.scale = scale; + callbackData.rotation = rotation; + callbackData.data = glyph.data; + + var output = displayCallback(callbackData); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + + if (output.color) + { + tintTL = output.color; + tintTR = output.color; + tintBL = output.color; + tintBR = output.color; + } + else + { + tintTL = output.tint.topLeft; + tintTR = output.tint.topRight; + tintBL = output.tint.bottomLeft; + tintBR = output.tint.bottomRight; + } + + tintTL = Utils.getTintAppendFloatAlpha(tintTL, camera.alpha * src._alphaTL); + tintTR = Utils.getTintAppendFloatAlpha(tintTR, camera.alpha * src._alphaTR); + tintBL = Utils.getTintAppendFloatAlpha(tintBL, camera.alpha * src._alphaBL); + tintBR = Utils.getTintAppendFloatAlpha(tintBR, camera.alpha * src._alphaBR); + } + + x *= scale; + y *= scale; + + x -= src.displayOriginX; + y -= src.displayOriginY; + + x += lineOffsetX; + + fontMatrix.applyITRS(x, y, rotation, scale, scale); + + calcMatrix.multiply(fontMatrix, spriteMatrix); + + var u0 = glyphX / textureWidth; + var v0 = glyphY / textureHeight; + var u1 = (glyphX + glyphW) / textureWidth; + var v1 = (glyphY + glyphH) / textureHeight; + + var xw = glyphW; + var yh = glyphH; + + var tx0 = spriteMatrix.e; + var ty0 = spriteMatrix.f; + + var tx1 = yh * spriteMatrix.c + spriteMatrix.e; + var ty1 = yh * spriteMatrix.d + spriteMatrix.f; + + var tx2 = xw * spriteMatrix.a + yh * spriteMatrix.c + spriteMatrix.e; + var ty2 = xw * spriteMatrix.b + yh * spriteMatrix.d + spriteMatrix.f; + + var tx3 = xw * spriteMatrix.a + spriteMatrix.e; + var ty3 = xw * spriteMatrix.b + spriteMatrix.f; + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + + if (crop) + { + pipeline.flush(); + + renderer.popScissor(); + } +}; + +module.exports = DynamicBitmapTextWebGLRenderer; + + +/***/ }), +/* 834 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(833); } -/** - * Parse an XML font to Bitmap Font data for the Bitmap Font cache. - * - * @function ParseXMLBitmapFont - * @since 3.0.0 - * @private - * - * @param {XMLDocument} xml - The XML Document to parse the font from. - * @param {integer} [xSpacing=0] - The x-axis spacing to add between each letter. - * @param {integer} [ySpacing=0] - The y-axis spacing to add to the line height. - * @param {Phaser.Textures.Frame} [frame] - The texture frame to take into account while parsing. - * - * @return {BitmapFontData} The parsed Bitmap Font data. - */ -var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame) +if (true) { - if (xSpacing === undefined) { xSpacing = 0; } - if (ySpacing === undefined) { ySpacing = 0; } + renderCanvas = __webpack_require__(832); +} - var data = {}; - var info = xml.getElementsByTagName('info')[0]; - var common = xml.getElementsByTagName('common')[0]; +module.exports = { - data.font = info.getAttribute('face'); - data.size = getValue(info, 'size'); - data.lineHeight = getValue(common, 'lineHeight') + ySpacing; - data.chars = {}; + renderWebGL: renderWebGL, + renderCanvas: renderCanvas - var letters = xml.getElementsByTagName('char'); - - var adjustForTrim = (frame !== undefined && frame.trimmed); - - if (adjustForTrim) - { - var top = frame.height; - var left = frame.width; - } - - for (var i = 0; i < letters.length; i++) - { - var node = letters[i]; - - var charCode = getValue(node, 'id'); - var gx = getValue(node, 'x'); - var gy = getValue(node, 'y'); - var gw = getValue(node, 'width'); - var gh = getValue(node, 'height'); - - // Handle frame trim issues - - if (adjustForTrim) - { - if (gx < left) - { - left = gx; - } - - if (gy < top) - { - top = gy; - } - } - - data.chars[charCode] = - { - x: gx, - y: gy, - width: gw, - height: gh, - centerX: Math.floor(gw / 2), - centerY: Math.floor(gh / 2), - xOffset: getValue(node, 'xoffset'), - yOffset: getValue(node, 'yoffset'), - xAdvance: getValue(node, 'xadvance') + xSpacing, - data: {}, - kerning: {} - }; - } - - if (adjustForTrim && top !== 0 && left !== 0) - { - // console.log('top and left', top, left, frame.x, frame.y); - - // Now we know the top and left coordinates of the glyphs in the original data - // so we can work out how much to adjust the glyphs by - - for (var code in data.chars) - { - var glyph = data.chars[code]; - - glyph.x -= frame.x; - glyph.y -= frame.y; - } - } - - var kernings = xml.getElementsByTagName('kerning'); - - for (i = 0; i < kernings.length; i++) - { - var kern = kernings[i]; - - var first = getValue(kern, 'first'); - var second = getValue(kern, 'second'); - var amount = getValue(kern, 'amount'); - - data.chars[second].kerning[first] = amount; - } - - return data; }; -module.exports = ParseXMLBitmapFont; - /***/ }), -/* 475 */ +/* 835 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Container#renderCanvas + * @since 3.4.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ContainerCanvasRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) +{ + var children = container.list; + + if (children.length === 0) + { + return; + } + + var transformMatrix = container.localTransform; + + if (parentMatrix) + { + transformMatrix.loadIdentity(); + transformMatrix.multiply(parentMatrix); + transformMatrix.translate(container.x, container.y); + transformMatrix.rotate(container.rotation); + transformMatrix.scale(container.scaleX, container.scaleY); + } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode) + { + // If Container is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } + + var alpha = container._alpha; + var scrollFactorX = container.scrollFactorX; + var scrollFactorY = container.scrollFactorY; + + for (var i = 0; i < children.length; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlpha = child._alpha; + var childBlendMode = child._blendMode; + var childScrollFactorX = child.scrollFactorX; + var childScrollFactorY = child.scrollFactorY; + + // Set parent values + child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); + child.setAlpha(childAlpha * alpha); + + if (containerHasBlendMode) + { + child.setBlendMode(container._blendMode); + } + + // Render + child.renderCanvas(renderer, child, interpolationPercentage, camera, transformMatrix); + + // Restore original values + child.setAlpha(childAlpha); + child.setScrollFactor(childScrollFactorX, childScrollFactorY); + child.setBlendMode(childBlendMode); + } +}; + +module.exports = ContainerCanvasRenderer; + + +/***/ }), +/* 836 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Container#renderWebGL + * @since 3.4.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ContainerWebGLRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) +{ + var children = container.list; + + if (children.length === 0) + { + return; + } + + var transformMatrix = container.localTransform; + + if (parentMatrix) + { + transformMatrix.loadIdentity(); + transformMatrix.multiply(parentMatrix); + transformMatrix.translate(container.x, container.y); + transformMatrix.rotate(container.rotation); + transformMatrix.scale(container.scaleX, container.scaleY); + } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode) + { + // If Container is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } + + var alpha = container._alpha; + var scrollFactorX = container.scrollFactorX; + var scrollFactorY = container.scrollFactorY; + + for (var i = 0; i < children.length; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlpha = child._alpha; + var childScrollFactorX = child.scrollFactorX; + var childScrollFactorY = child.scrollFactorY; + + if (!containerHasBlendMode && child.blendMode !== renderer.currentBlendMode) + { + // If Container doesn't have its own blend mode, then a child can have one + renderer.setBlendMode(child.blendMode); + } + + // Set parent values + child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); + child.setAlpha(childAlpha * alpha); + + // Render + child.renderWebGL(renderer, child, interpolationPercentage, camera, transformMatrix); + + // Restore original values + child.setAlpha(childAlpha); + child.setScrollFactor(childScrollFactorX, childScrollFactorY); + } +}; + +module.exports = ContainerWebGLRenderer; + + +/***/ }), +/* 837 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(836); +} + +if (true) +{ + renderCanvas = __webpack_require__(835); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 838 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Bob Game Object. + * + * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * + * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle + * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it + * must be a Frame within the Texture used by the parent Blitter. + * + * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will + * have their positions impacted by this change as well. + * + * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be + * handled via the Blitter parent. + * + * @class Bob + * @memberof Phaser.GameObjects.Blitter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. + * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. + * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. + * @param {(string|integer)} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. + * @param {boolean} visible - Should the Bob render visible or not to start with? + */ +var Bob = new Class({ + + initialize: + + function Bob (blitter, x, y, frame, visible) + { + /** + * The Blitter object that this Bob belongs to. + * + * @name Phaser.GameObjects.Blitter.Bob#parent + * @type {Phaser.GameObjects.Blitter} + * @since 3.0.0 + */ + this.parent = blitter; + + /** + * The x position of this Bob, relative to the x position of the Blitter. + * + * @name Phaser.GameObjects.Blitter.Bob#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of this Bob, relative to the y position of the Blitter. + * + * @name Phaser.GameObjects.Blitter.Bob#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The frame that the Bob uses to render with. + * To change the frame use the `Bob.setFrame` method. + * + * @name Phaser.GameObjects.Blitter.Bob#frame + * @type {Phaser.Textures.Frame} + * @protected + * @since 3.0.0 + */ + this.frame = frame; + + /** + * A blank object which can be used to store data related to this Bob in. + * + * @name Phaser.GameObjects.Blitter.Bob#data + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.data = {}; + + /** + * The visible state of this Bob. + * + * @name Phaser.GameObjects.Blitter.Bob#_visible + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._visible = visible; + + /** + * The alpha value of this Bob. + * + * @name Phaser.GameObjects.Blitter.Bob#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._alpha = 1; + + /** + * The horizontally flipped state of the Bob. + * A Bob that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture. + * + * @name Phaser.GameObjects.Blitter.Bob#flipX + * @type {boolean} + * @since 3.0.0 + */ + this.flipX = false; + + /** + * The vertically flipped state of the Bob. + * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture. + * + * @name Phaser.GameObjects.Blitter.Bob#flipY + * @type {boolean} + * @since 3.0.0 + */ + this.flipY = false; + }, + + /** + * Changes the Texture Frame being used by this Bob. + * The frame must be part of the Texture the parent Blitter is using. + * If no value is given it will use the default frame of the Blitter parent. + * + * @method Phaser.GameObjects.Blitter.Bob#setFrame + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The frame to be used during rendering. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFrame: function (frame) + { + if (frame === undefined) + { + this.frame = this.parent.frame; + } + else + { + this.frame = this.parent.texture.get(frame); + } + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. + * + * @method Phaser.GameObjects.Blitter.Bob#resetFlip + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + }, + + /** + * Resets this Bob. + * + * Changes the position to the values given, and optionally changes the frame. + * + * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. + * + * @method Phaser.GameObjects.Blitter.Bob#reset + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + reset: function (x, y, frame) + { + this.x = x; + this.y = y; + + this.flipX = false; + this.flipY = false; + + this._alpha = 1; + this._visible = true; + + this.parent.dirty = true; + + if (frame) + { + this.setFrame(frame); + } + + return this; + }, + + /** + * Sets the horizontal flipped state of this Bob. + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Bob. + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Bob. + * + * @method Phaser.GameObjects.Blitter.Bob#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Sets the visibility of this Bob. + * + * An invisible Bob will skip rendering. + * + * @method Phaser.GameObjects.Blitter.Bob#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + }, + + /** + * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * A Bob with alpha 0 will skip rendering. + * + * @method Phaser.GameObjects.Blitter.Bob#setAlpha + * @since 3.0.0 + * + * @param {number} value - The alpha value used for this Bob. Between 0 and 1. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setAlpha: function (value) + { + this.alpha = value; + + return this; + }, + + /** + * Destroys this Bob instance. + * Removes itself from the Blitter and clears the parent, frame and data properties. + * + * @method Phaser.GameObjects.Blitter.Bob#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent.dirty = true; + + this.parent.children.remove(this); + + this.parent = undefined; + this.frame = undefined; + this.data = undefined; + }, + + /** + * The visible state of the Bob. + * + * An invisible Bob will skip rendering. + * + * @name Phaser.GameObjects.Blitter.Bob#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + this._visible = value; + this.parent.dirty = true; + } + + }, + + /** + * The alpha value of the Bob, between 0 and 1. + * + * A Bob with alpha 0 will skip rendering. + * + * @name Phaser.GameObjects.Blitter.Bob#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + this._alpha = value; + this.parent.dirty = true; + } + + } + +}); + +module.exports = Bob; + + +/***/ }), +/* 839 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var list = src.getRenderList(); + + if (list.length === 0) + { + return; + } + + var ctx = renderer.currentContext; + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + + // Blend Mode + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + + var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; + var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; + + ctx.save(); + + if (parentMatrix) + { + parentMatrix.copyToContext(ctx); + } + + var roundPixels = camera.roundPixels; + + // Render bobs + for (var i = 0; i < list.length; i++) + { + var bob = list[i]; + var flip = (bob.flipX || bob.flipY); + var frame = bob.frame; + var cd = frame.canvasData; + var dx = frame.x; + var dy = frame.y; + var fx = 1; + var fy = 1; + + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + + ctx.globalAlpha = bobAlpha; + + if (!flip) + { + if (roundPixels) + { + dx |= 0; + dy |= 0; + } + + ctx.drawImage( + frame.source.image, + cd.x, + cd.y, + cd.width, + cd.height, + dx + bob.x + cameraScrollX, + dy + bob.y + cameraScrollY, + cd.width, + cd.height + ); + } + else + { + if (bob.flipX) + { + fx = -1; + dx -= cd.width; + } + + if (bob.flipY) + { + fy = -1; + dy -= cd.height; + } + + ctx.save(); + ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); + ctx.scale(fx, fy); + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, dx, dy, cd.width, cd.height); + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = BlitterCanvasRenderer; + + +/***/ }), +/* 840 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var list = src.getRenderList(); + + if (list.length === 0) + { + return; + } + + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + + var calcMatrix = pipeline._tempMatrix1; + + calcMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + calcMatrix.multiplyWithOffset(parentMatrix, -cameraScrollX, -cameraScrollY); + + cameraScrollX = 0; + cameraScrollY = 0; + } + + var blitterX = src.x - cameraScrollX; + var blitterY = src.y - cameraScrollY; + var prevTextureSourceIndex = -1; + var tintEffect = false; + var alpha = camera.alpha * src.alpha; + var roundPixels = camera.roundPixels; + + for (var index = 0; index < list.length; index++) + { + var bob = list[index]; + var frame = bob.frame; + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + + var width = frame.width; + var height = frame.height; + + var x = blitterX + bob.x + frame.x; + var y = blitterY + bob.y + frame.y; + + if (bob.flipX) + { + width *= -1; + x += frame.width; + } + + if (bob.flipY) + { + height *= -1; + y += frame.height; + } + + var xw = x + width; + var yh = y + height; + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(xw, yh); + var ty1 = calcMatrix.getY(xw, yh); + + var tint = Utils.getTintAppendFloatAlpha(0xffffff, bobAlpha); + + // Bind texture only if the Texture Source is different from before + if (frame.sourceIndex !== prevTextureSourceIndex) + { + pipeline.setTexture2D(frame.glTexture, 0); + + prevTextureSourceIndex = frame.sourceIndex; + } + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + } + + // TL x/y, BL x/y, BR x/y, TR x/y + if (pipeline.batchQuad(tx0, ty0, tx0, ty1, tx1, ty1, tx1, ty0, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect)) + { + prevTextureSourceIndex = -1; + } + } +}; + +module.exports = BlitterWebGLRenderer; + + +/***/ }), +/* 841 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(840); +} + +if (true) +{ + renderCanvas = __webpack_require__(839); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 842 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.BitmapText#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src._text; + var textLength = text.length; + + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + var textureFrame = src.frame; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + var letterSpacing = src._letterSpacing; + + var xAdvance = 0; + var yAdvance = 0; + + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var scale = (src._fontSize / src.fontData.size); + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + ctx.translate(-src.displayOriginX, -src.displayOriginY); + + var roundPixels = camera.roundPixels; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = glyph.xOffset + xAdvance; + y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + x *= scale; + y *= scale; + + x += lineOffsetX; + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + if (roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = BitmapTextCanvasRenderer; + + +/***/ }), +/* 843 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.BitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src._text; + var textLength = text.length; + + if (textLength === 0) + { + return; + } + + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = texture.width; + var textureHeight = texture.height; + + var tintEffect = (src._isTinted && src.tintFill); + var tintTL = Utils.getTintAppendFloatAlpha(src._tintTL, camera.alpha * src._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(src._tintTR, camera.alpha * src._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, camera.alpha * src._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, camera.alpha * src._alphaBR); + + pipeline.setTexture2D(texture, 0); + + var xAdvance = 0; + var yAdvance = 0; + var charCode = 0; + var lastCharCode = 0; + var letterSpacing = src._letterSpacing; + var glyph; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + var lastGlyph; + + var fontData = src.fontData; + var chars = fontData.chars; + var lineHeight = fontData.lineHeight; + var scale = (src._fontSize / fontData.size); + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + var roundPixels = camera.roundPixels; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + // Carriage-return + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + var x = glyph.xOffset + xAdvance; + var y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + x *= scale; + y *= scale; + + x -= src.displayOriginX; + y -= src.displayOriginY; + + x += lineOffsetX; + + var u0 = glyphX / textureWidth; + var v0 = glyphY / textureHeight; + var u1 = (glyphX + glyphW) / textureWidth; + var v1 = (glyphY + glyphH) / textureHeight; + + var xw = x + (glyphW * scale); + var yh = y + (glyphH * scale); + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } +}; + +module.exports = BitmapTextWebGLRenderer; + + +/***/ }), +/* 844 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(843); +} + +if (true) +{ + renderCanvas = __webpack_require__(842); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 845 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ParseXMLBitmapFont = __webpack_require__(310); + +/** + * Parse an XML Bitmap Font from an Atlas. + * + * Adds the parsed Bitmap Font data to the cache with the `fontName` key. + * + * @function ParseFromAtlas + * @since 3.0.0 + * @private + * + * @param {Phaser.Scene} scene - The Scene to parse the Bitmap Font for. + * @param {string} fontName - The key of the font to add to the Bitmap Font cache. + * @param {string} textureKey - The key of the BitmapFont's texture. + * @param {string} frameKey - The key of the BitmapFont texture's frame. + * @param {string} xmlKey - The key of the XML data of the font to parse. + * @param {integer} xSpacing - The x-axis spacing to add between each letter. + * @param {integer} ySpacing - The y-axis spacing to add to the line height. + * + * @return {boolean} Whether the parsing was successful or not. + */ +var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) +{ + var frame = scene.sys.textures.getFrame(textureKey, frameKey); + var xml = scene.sys.cache.xml.get(xmlKey); + + if (frame && xml) + { + var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame); + + scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey }); + + return true; + } + else + { + return false; + } +}; + +module.exports = ParseFromAtlas; + + +/***/ }), +/* 846 */ /***/ (function(module, exports) { /** @@ -99559,11 +132422,35 @@ module.exports = ParseXMLBitmapFont; * * @param {(Phaser.GameObjects.DynamicBitmapText|Phaser.GameObjects.BitmapText)} src - The BitmapText to calculate the position, width and height of. * @param {boolean} [round] - Whether to round the results to the nearest integer. + * @param {object} [out] - Optional object to store the results in, to save constant object creation. * * @return {BitmapTextSize} The calculated position, width and height of the BitmapText. */ -var GetBitmapTextSize = function (src, round) +var GetBitmapTextSize = function (src, round, out) { + if (out === undefined) + { + out = { + local: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + global: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + lines: { + shortest: 0, + longest: 0, + lengths: null + } + }; + } + var text = src.text; var textLength = text.length; @@ -99579,29 +132466,49 @@ var GetBitmapTextSize = function (src, round) var xAdvance = 0; var yAdvance = 0; - var indexCount = 0; var charCode = 0; var glyph = null; - var glyphW = 0; - var glyphH = 0; var x = 0; var y = 0; + var scale = (src.fontSize / src.fontData.size); + var sx = scale * src.scaleX; + var sy = scale * src.scaleY; + var lastGlyph = null; var lastCharCode = 0; + var lineWidths = []; + var shortestLine = Number.MAX_VALUE; + var longestLine = 0; + var currentLine = 0; + var currentLineWidth = 0; - for (var index = 0; index < textLength; ++index) + for (var i = 0; i < textLength; i++) { - charCode = text.charCodeAt(index); + charCode = text.charCodeAt(i); if (charCode === 10) { xAdvance = 0; - indexCount = 0; yAdvance += lineHeight; lastGlyph = null; + + lineWidths[currentLine] = currentLineWidth; + + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + currentLine++; + currentLineWidth = 0; continue; } @@ -99612,11 +132519,8 @@ var GetBitmapTextSize = function (src, round) continue; } - glyphW = glyph.width; - glyphH = glyph.height; - - x = indexCount + glyph.xOffset + xAdvance; - y = glyph.yOffset + yAdvance; + x = xAdvance; + y = yAdvance; if (lastGlyph !== null) { @@ -99634,8 +132538,8 @@ var GetBitmapTextSize = function (src, round) by = y; } - var gw = x + glyphW - bx; - var gh = y + glyphH - by; + var gw = x + glyph.xAdvance; + var gh = y + lineHeight; if (bw < gw) { @@ -99648,41 +132552,55 @@ var GetBitmapTextSize = function (src, round) } xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; lastGlyph = glyph; lastCharCode = charCode; + currentLineWidth = gw * scale; } - var scale = (src.fontSize / src.fontData.size); - var sx = scale * src.scaleX; - var sy = scale * src.scaleY; + lineWidths[currentLine] = currentLineWidth; - var out = { - local: { - x: bx * scale, - y: by * scale, - width: bw * scale, - height: bh * scale - }, - global: { - x: src.x + (bx * sx), - y: src.y + (by * sy), - width: bw * sx, - height: bh * sy - } - }; + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + var local = out.local; + var global = out.global; + var lines = out.lines; + + local.x = bx * scale; + local.y = by * scale; + local.width = bw * scale; + local.height = bh * scale; + + global.x = (src.x - src.displayOriginX) + (bx * sx); + global.y = (src.y - src.displayOriginY) + (by * sy); + global.width = bw * sx; + global.height = bh * sy; + + lines.shortest = shortestLine; + lines.longest = longestLine; + lines.lengths = lineWidths; if (round) { - out.local.x = Math.round(out.local.x); - out.local.y = Math.round(out.local.y); - out.local.width = Math.round(out.local.width); - out.local.height = Math.round(out.local.height); + local.x = Math.round(local.x); + local.y = Math.round(local.y); + local.width = Math.round(local.width); + local.height = Math.round(local.height); - out.global.x = Math.round(out.global.x); - out.global.y = Math.round(out.global.y); - out.global.width = Math.round(out.global.width); - out.global.height = Math.round(out.global.height); + global.x = Math.round(global.x); + global.y = Math.round(global.y); + global.width = Math.round(global.width); + global.height = Math.round(global.height); + + lines.shortest = Math.round(shortestLine); + lines.longest = Math.round(longestLine); } return out; @@ -99692,7 +132610,7 @@ module.exports = GetBitmapTextSize; /***/ }), -/* 476 */ +/* 847 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -99702,7 +132620,7 @@ module.exports = GetBitmapTextSize; */ var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); +var PluginCache = __webpack_require__(15); /** * @classdesc @@ -99713,7 +132631,7 @@ var PluginCache = __webpack_require__(12); * Some or all of these Game Objects may also be part of the Scene's [Display List]{@link Phaser.GameObjects.DisplayList}, for Rendering. * * @class UpdateList - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -99951,7 +132869,26 @@ var UpdateList = new Class({ */ shutdown: function () { - this.removeAll(); + var i = this._list.length; + + while (i--) + { + this._list[i].destroy(true); + } + + i = this._pendingRemoval.length; + + while (i--) + { + this._pendingRemoval[i].destroy(true); + } + + i = this._pendingInsertion.length; + + while (i--) + { + this._pendingInsertion[i].destroy(true); + } this._list.length = 0; this._pendingRemoval.length = 0; @@ -99986,7 +132923,7 @@ var UpdateList = new Class({ * * @name Phaser.GameObjects.UpdateList#length * @type {integer} - * @readOnly + * @readonly * @since 3.10.0 */ length: { @@ -100006,7 +132943,7 @@ module.exports = UpdateList; /***/ }), -/* 477 */ +/* 848 */ /***/ (function(module, exports) { /** @@ -100054,7 +132991,7 @@ module.exports = Swap; /***/ }), -/* 478 */ +/* 849 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100063,7 +133000,7 @@ module.exports = Swap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Scans the array for elements with the given property. If found, the property is set to the `value`. @@ -100109,7 +133046,7 @@ module.exports = SetAll; /***/ }), -/* 479 */ +/* 850 */ /***/ (function(module, exports) { /** @@ -100147,7 +133084,7 @@ module.exports = SendToBack; /***/ }), -/* 480 */ +/* 851 */ /***/ (function(module, exports) { /** @@ -100190,7 +133127,7 @@ module.exports = Replace; /***/ }), -/* 481 */ +/* 852 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100199,7 +133136,7 @@ module.exports = Replace; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SpliceOne = __webpack_require__(56); +var SpliceOne = __webpack_require__(91); /** * Removes a random object from the given array and returns it. @@ -100228,7 +133165,7 @@ module.exports = RemoveRandomElement; /***/ }), -/* 482 */ +/* 853 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100237,7 +133174,7 @@ module.exports = RemoveRandomElement; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Removes the item within the given range in the array. @@ -100291,7 +133228,7 @@ module.exports = RemoveBetween; /***/ }), -/* 483 */ +/* 854 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100300,7 +133237,7 @@ module.exports = RemoveBetween; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SpliceOne = __webpack_require__(56); +var SpliceOne = __webpack_require__(91); /** * Removes the item from the given position in the array. @@ -100342,7 +133279,7 @@ module.exports = RemoveAt; /***/ }), -/* 484 */ +/* 855 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100351,7 +133288,7 @@ module.exports = RemoveAt; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RoundAwayFromZero = __webpack_require__(255); +var RoundAwayFromZero = __webpack_require__(314); /** * Create an array of numbers (positive and/or negative) progressing from `start` @@ -100419,7 +133356,7 @@ module.exports = NumberArrayStep; /***/ }), -/* 485 */ +/* 856 */ /***/ (function(module, exports) { /** @@ -100483,7 +133420,7 @@ module.exports = NumberArray; /***/ }), -/* 486 */ +/* 857 */ /***/ (function(module, exports) { /** @@ -100525,7 +133462,7 @@ module.exports = MoveUp; /***/ }), -/* 487 */ +/* 858 */ /***/ (function(module, exports) { /** @@ -100572,7 +133509,7 @@ module.exports = MoveTo; /***/ }), -/* 488 */ +/* 859 */ /***/ (function(module, exports) { /** @@ -100614,7 +133551,7 @@ module.exports = MoveDown; /***/ }), -/* 489 */ +/* 860 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100623,7 +133560,7 @@ module.exports = MoveDown; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Returns the first element in the array. @@ -100673,7 +133610,7 @@ module.exports = GetFirst; /***/ }), -/* 490 */ +/* 861 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100682,7 +133619,7 @@ module.exports = GetFirst; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Returns all elements in the array. @@ -100735,7 +133672,7 @@ module.exports = GetAll; /***/ }), -/* 491 */ +/* 862 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100744,7 +133681,7 @@ module.exports = GetAll; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Passes each element in the array, between the start and end indexes, to the given callback. @@ -100791,7 +133728,7 @@ module.exports = EachInRange; /***/ }), -/* 492 */ +/* 863 */ /***/ (function(module, exports) { /** @@ -100809,7 +133746,7 @@ module.exports = EachInRange; * @param {array} array - The array to search. * @param {function} callback - A callback to be invoked for each item in the array. * @param {object} context - The context in which the callback is invoked. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the current array item. * * @return {array} The input array. */ @@ -100818,7 +133755,7 @@ var Each = function (array, callback, context) var i; var args = [ null ]; - for (i = 2; i < arguments.length; i++) + for (i = 3; i < arguments.length; i++) { args.push(arguments[i]); } @@ -100837,7 +133774,7 @@ module.exports = Each; /***/ }), -/* 493 */ +/* 864 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -100846,7 +133783,7 @@ module.exports = Each; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Returns the total number of elements in the array which have a property matching the given value. @@ -100889,7 +133826,7 @@ module.exports = CountAllMatching; /***/ }), -/* 494 */ +/* 865 */ /***/ (function(module, exports) { /** @@ -100927,7 +133864,7 @@ module.exports = BringToTop; /***/ }), -/* 495 */ +/* 866 */ /***/ (function(module, exports) { /** @@ -101030,7 +133967,7 @@ var AddAt = function (array, item, index, limit, callback, context) itemLength = remaining; } - for (var i = itemLength; i > 0; i--) + for (var i = itemLength - 1; i >= 0; i--) { var entry = item[i]; @@ -101049,7 +133986,7 @@ module.exports = AddAt; /***/ }), -/* 496 */ +/* 867 */ /***/ (function(module, exports) { /** @@ -101166,7 +134103,7 @@ module.exports = Add; /***/ }), -/* 497 */ +/* 868 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -101175,7 +134112,7 @@ module.exports = Add; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateMatrix = __webpack_require__(77); +var RotateMatrix = __webpack_require__(111); /** * [description] @@ -101196,7 +134133,7 @@ module.exports = RotateRight; /***/ }), -/* 498 */ +/* 869 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -101205,7 +134142,7 @@ module.exports = RotateRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateMatrix = __webpack_require__(77); +var RotateMatrix = __webpack_require__(111); /** * [description] @@ -101226,7 +134163,7 @@ module.exports = RotateLeft; /***/ }), -/* 499 */ +/* 870 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -101235,7 +134172,7 @@ module.exports = RotateLeft; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateMatrix = __webpack_require__(77); +var RotateMatrix = __webpack_require__(111); /** * [description] @@ -101256,7 +134193,7 @@ module.exports = Rotate180; /***/ }), -/* 500 */ +/* 871 */ /***/ (function(module, exports) { /** @@ -101284,7 +134221,7 @@ module.exports = ReverseRows; /***/ }), -/* 501 */ +/* 872 */ /***/ (function(module, exports) { /** @@ -101294,14 +134231,14 @@ module.exports = ReverseRows; */ /** - * [description] + * Reverses the columns in the given Array Matrix. * * @function Phaser.Utils.Array.Matrix.ReverseColumns * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - The array matrix to reverse the columns for. * - * @return {array} [description] + * @return {array} The column reversed matrix. */ var ReverseColumns = function (matrix) { @@ -101317,7 +134254,7 @@ module.exports = ReverseColumns; /***/ }), -/* 502 */ +/* 873 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -101326,21 +134263,21 @@ module.exports = ReverseColumns; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Pad = __webpack_require__(133); -var CheckMatrix = __webpack_require__(116); +var Pad = __webpack_require__(179); +var CheckMatrix = __webpack_require__(163); // Generates a string (which you can pass to console.log) from the given // Array Matrix. /** - * [description] + * Generates a string (which you can pass to console.log) from the given Array Matrix. * * @function Phaser.Utils.Array.Matrix.MatrixToString * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - A 2-dimensional array. * - * @return {string} [description] + * @return {string} A string representing the matrix. */ var MatrixToString = function (matrix) { @@ -101398,7 +134335,7 @@ module.exports = MatrixToString; /***/ }), -/* 503 */ +/* 874 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -101413,21 +134350,21 @@ module.exports = MatrixToString; module.exports = { - CheckMatrix: __webpack_require__(116), - MatrixToString: __webpack_require__(502), - ReverseColumns: __webpack_require__(501), - ReverseRows: __webpack_require__(500), - Rotate180: __webpack_require__(499), - RotateLeft: __webpack_require__(498), - RotateMatrix: __webpack_require__(77), - RotateRight: __webpack_require__(497), - TransposeMatrix: __webpack_require__(181) + CheckMatrix: __webpack_require__(163), + MatrixToString: __webpack_require__(873), + ReverseColumns: __webpack_require__(872), + ReverseRows: __webpack_require__(871), + Rotate180: __webpack_require__(870), + RotateLeft: __webpack_require__(869), + RotateMatrix: __webpack_require__(111), + RotateRight: __webpack_require__(868), + TransposeMatrix: __webpack_require__(315) }; /***/ }), -/* 504 */ +/* 875 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -101437,9 +134374,9 @@ module.exports = { */ var Class = __webpack_require__(0); -var List = __webpack_require__(93); -var PluginCache = __webpack_require__(12); -var StableSort = __webpack_require__(83); +var List = __webpack_require__(112); +var PluginCache = __webpack_require__(15); +var StableSort = __webpack_require__(110); /** * @classdesc @@ -101451,7 +134388,7 @@ var StableSort = __webpack_require__(83); * * @class DisplayList * @extends Phaser.Structs.List. - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -101608,6 +134545,19 @@ var DisplayList = new Class({ return gameObjects[gameObjects.length - 1]; }, + /** + * All members of the group. + * + * @method Phaser.GameObjects.DisplayList#getChildren + * @since 3.12.0 + * + * @return {Phaser.GameObjects.GameObject[]} The group members. + */ + getChildren: function () + { + return this.list; + }, + /** * 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. @@ -101618,7 +134568,14 @@ var DisplayList = new Class({ */ shutdown: function () { - this.removeAll(); + var i = this.list.length; + + while (i--) + { + this.list[i].destroy(true); + } + + this.list.length = 0; this.systems.events.off('shutdown', this.shutdown, this); }, @@ -101649,7 +134606,138 @@ module.exports = DisplayList; /***/ }), -/* 505 */ +/* 876 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects + */ + +var GameObjects = { + + DisplayList: __webpack_require__(875), + GameObjectCreator: __webpack_require__(13), + GameObjectFactory: __webpack_require__(5), + UpdateList: __webpack_require__(847), + + Components: __webpack_require__(14), + + BuildGameObject: __webpack_require__(28), + BuildGameObjectAnimation: __webpack_require__(311), + GameObject: __webpack_require__(19), + BitmapText: __webpack_require__(109), + Blitter: __webpack_require__(161), + Container: __webpack_require__(160), + DynamicBitmapText: __webpack_require__(159), + Graphics: __webpack_require__(158), + Group: __webpack_require__(88), + Image: __webpack_require__(87), + Particles: __webpack_require__(823), + PathFollower: __webpack_require__(296), + RenderTexture: __webpack_require__(154), + RetroFont: __webpack_require__(814), + Sprite: __webpack_require__(61), + Text: __webpack_require__(153), + TileSprite: __webpack_require__(152), + Zone: __webpack_require__(125), + + // Shapes + + Shape: __webpack_require__(27), + Arc: __webpack_require__(293), + Curve: __webpack_require__(292), + Ellipse: __webpack_require__(291), + Grid: __webpack_require__(290), + IsoBox: __webpack_require__(289), + IsoTriangle: __webpack_require__(288), + Line: __webpack_require__(287), + Polygon: __webpack_require__(286), + Rectangle: __webpack_require__(281), + Star: __webpack_require__(280), + Triangle: __webpack_require__(279), + + // Game Object Factories + + Factories: { + Blitter: __webpack_require__(769), + Container: __webpack_require__(768), + DynamicBitmapText: __webpack_require__(767), + Graphics: __webpack_require__(766), + Group: __webpack_require__(765), + Image: __webpack_require__(764), + Particles: __webpack_require__(763), + PathFollower: __webpack_require__(762), + RenderTexture: __webpack_require__(761), + Sprite: __webpack_require__(760), + StaticBitmapText: __webpack_require__(759), + Text: __webpack_require__(758), + TileSprite: __webpack_require__(757), + Zone: __webpack_require__(756), + + // Shapes + Arc: __webpack_require__(755), + Curve: __webpack_require__(754), + Ellipse: __webpack_require__(753), + Grid: __webpack_require__(752), + IsoBox: __webpack_require__(751), + IsoTriangle: __webpack_require__(750), + Line: __webpack_require__(749), + Polygon: __webpack_require__(748), + Rectangle: __webpack_require__(747), + Star: __webpack_require__(746), + Triangle: __webpack_require__(745) + }, + + Creators: { + Blitter: __webpack_require__(744), + Container: __webpack_require__(743), + DynamicBitmapText: __webpack_require__(742), + Graphics: __webpack_require__(741), + Group: __webpack_require__(740), + Image: __webpack_require__(739), + Particles: __webpack_require__(738), + RenderTexture: __webpack_require__(737), + Sprite: __webpack_require__(736), + StaticBitmapText: __webpack_require__(735), + Text: __webpack_require__(734), + TileSprite: __webpack_require__(733), + Zone: __webpack_require__(732) + } + +}; + +if (false) +{} + +if (true) +{ + // WebGL only Game Objects + GameObjects.Mesh = __webpack_require__(108); + GameObjects.Quad = __webpack_require__(149); + + GameObjects.Factories.Mesh = __webpack_require__(728); + GameObjects.Factories.Quad = __webpack_require__(727); + + GameObjects.Creators.Mesh = __webpack_require__(726); + GameObjects.Creators.Quad = __webpack_require__(725); + + GameObjects.Light = __webpack_require__(276); + + __webpack_require__(275); + __webpack_require__(724); +} + +module.exports = GameObjects; + + +/***/ }), +/* 877 */ /***/ (function(module, exports) { /** @@ -101790,7 +134878,7 @@ module.exports = VisibilityHandler; /***/ }), -/* 506 */ +/* 878 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -101801,8 +134889,8 @@ module.exports = VisibilityHandler; var Class = __webpack_require__(0); var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var RequestAnimationFrame = __webpack_require__(268); +var NOOP = __webpack_require__(1); +var RequestAnimationFrame = __webpack_require__(341); // Frame Rate config // fps: { @@ -101828,7 +134916,7 @@ var RequestAnimationFrame = __webpack_require__(268); * [description] * * @class TimeStep - * @memberOf Phaser.Boot + * @memberof Phaser.Boot * @constructor * @since 3.0.0 * @@ -101846,7 +134934,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#game * @type {Phaser.Game} - * @readOnly + * @readonly * @since 3.0.0 */ this.game = game; @@ -101856,7 +134944,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#raf * @type {Phaser.DOM.RequestAnimationFrame} - * @readOnly + * @readonly * @since 3.0.0 */ this.raf = new RequestAnimationFrame(); @@ -101866,7 +134954,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#started * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.0.0 */ @@ -101880,7 +134968,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#running * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.0.0 */ @@ -101937,7 +135025,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#actualFps * @type {integer} - * @readOnly + * @readonly * @default 60 * @since 3.0.0 */ @@ -101948,7 +135036,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#nextFpsUpdate * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.0.0 */ @@ -101959,7 +135047,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#framesThisSecond * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.0.0 */ @@ -101981,7 +135069,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#forceSetTimeOut * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.0.0 */ @@ -102022,7 +135110,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#frame * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.0.0 */ @@ -102033,7 +135121,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#inFocus * @type {boolean} - * @readOnly + * @readonly * @default true * @since 3.0.0 */ @@ -102453,7 +135541,7 @@ module.exports = TimeStep; /***/ }), -/* 507 */ +/* 879 */ /***/ (function(module, exports) { /** @@ -102498,7 +135586,7 @@ var addFrame = function (texture, sourceIndex, name, frame) * For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html * * @function Phaser.Textures.Parsers.UnityYAML - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -102623,7 +135711,7 @@ TextureImporter: /***/ }), -/* 508 */ +/* 880 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -102632,7 +135720,7 @@ TextureImporter: * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas. @@ -102641,7 +135729,7 @@ var GetFastValue = __webpack_require__(1); * same size and cannot be trimmed or rotated. * * @function Phaser.Textures.Parsers.SpriteSheetFromAtlas - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -102814,7 +135902,7 @@ module.exports = SpriteSheetFromAtlas; /***/ }), -/* 509 */ +/* 881 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -102823,7 +135911,7 @@ module.exports = SpriteSheetFromAtlas; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * Parses a Sprite Sheet and adds the Frames to the Texture. @@ -102832,7 +135920,7 @@ var GetFastValue = __webpack_require__(1); * same size and cannot be trimmed or rotated. * * @function Phaser.Textures.Parsers.SpriteSheet - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -102877,6 +135965,11 @@ var SpriteSheet = function (texture, sourceIndex, x, y, width, height, config) var column = Math.floor((height - margin + spacing) / (frameHeight + spacing)); var total = row * column; + if (total === 0) + { + console.warn('SpriteSheet frame dimensions will result in zero frames.'); + } + if (startFrame > total || startFrame < -total) { startFrame = 0; @@ -102934,7 +136027,7 @@ module.exports = SpriteSheet; /***/ }), -/* 510 */ +/* 882 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -102943,14 +136036,14 @@ module.exports = SpriteSheet; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(33); +var Clone = __webpack_require__(63); /** * Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. * JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames. * * @function Phaser.Textures.Parsers.JSONHash - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -103033,7 +136126,7 @@ module.exports = JSONHash; /***/ }), -/* 511 */ +/* 883 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103042,14 +136135,14 @@ module.exports = JSONHash; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(33); +var Clone = __webpack_require__(63); /** * Parses a Texture Atlas JSON Array and adds the Frames to the Texture. * JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames. * * @function Phaser.Textures.Parsers.JSONArray - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -103140,7 +136233,7 @@ module.exports = JSONArray; /***/ }), -/* 512 */ +/* 884 */ /***/ (function(module, exports) { /** @@ -103153,7 +136246,7 @@ module.exports = JSONArray; * Adds an Image Element to a Texture. * * @function Phaser.Textures.Parsers.Image - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -103175,7 +136268,7 @@ module.exports = Image; /***/ }), -/* 513 */ +/* 885 */ /***/ (function(module, exports) { /** @@ -103188,7 +136281,7 @@ module.exports = Image; * Adds a Canvas Element to a Texture. * * @function Phaser.Textures.Parsers.Canvas - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -103210,7 +136303,7 @@ module.exports = Canvas; /***/ }), -/* 514 */ +/* 886 */ /***/ (function(module, exports) { /** @@ -103223,7 +136316,7 @@ module.exports = Canvas; * Parses an XML Texture Atlas object and adds all the Frames into a Texture. * * @function Phaser.Textures.Parsers.AtlasXML - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.7.0 * @@ -103291,7 +136384,7 @@ module.exports = AtlasXML; /***/ }), -/* 515 */ +/* 887 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103301,8 +136394,9 @@ module.exports = AtlasXML; */ var Class = __webpack_require__(0); -var IsSizePowerOfTwo = __webpack_require__(85); -var Texture = __webpack_require__(117); +var Color = __webpack_require__(37); +var IsSizePowerOfTwo = __webpack_require__(117); +var Texture = __webpack_require__(165); /** * @classdesc @@ -103326,11 +136420,11 @@ var Texture = __webpack_require__(117); * * @class CanvasTexture * @extends Phaser.Textures.Texture - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.7.0 * - * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. + * @param {Phaser.Textures.CanvasTexture} manager - A reference to the Texture Manager this Texture belongs to. * @param {string} key - The unique string-based key of this Texture. * @param {HTMLCanvasElement} source - The canvas element that is used as the base of this texture. * @param {integer} width - The width of the canvas. @@ -103351,7 +136445,7 @@ var CanvasTexture = new Class({ /** * A reference to the Texture Source of this Canvas. * - * @name Phaser.Textures.TextureManager#_source + * @name Phaser.Textures.CanvasTexture#_source * @type {Phaser.Textures.TextureSource} * @private * @since 3.7.0 @@ -103361,8 +136455,8 @@ var CanvasTexture = new Class({ /** * The source Canvas Element. * - * @name Phaser.Textures.TextureManager#canvas - * @readOnly + * @name Phaser.Textures.CanvasTexture#canvas + * @readonly * @type {HTMLCanvasElement} * @since 3.7.0 */ @@ -103371,8 +136465,8 @@ var CanvasTexture = new Class({ /** * The 2D Canvas Rendering Context. * - * @name Phaser.Textures.TextureManager#canvas - * @readOnly + * @name Phaser.Textures.CanvasTexture#context + * @readonly * @type {CanvasRenderingContext2D} * @since 3.7.0 */ @@ -103380,10 +136474,10 @@ var CanvasTexture = new Class({ /** * The width of the Canvas. - * This property is read-only, if you wish to change use `setSize`. + * This property is read-only, if you wish to change it use the `setSize` method. * - * @name Phaser.Textures.TextureManager#width - * @readOnly + * @name Phaser.Textures.CanvasTexture#width + * @readonly * @type {integer} * @since 3.7.0 */ @@ -103391,14 +136485,165 @@ var CanvasTexture = new Class({ /** * The height of the Canvas. - * This property is read-only, if you wish to change use `setSize`. + * This property is read-only, if you wish to change it use the `setSize` method. * - * @name Phaser.Textures.TextureManager#height - * @readOnly + * @name Phaser.Textures.CanvasTexture#height + * @readonly * @type {integer} * @since 3.7.0 */ this.height = height; + + /** + * The context image data. + * Use the `update` method to populate this when the canvas changes. + * + * @name Phaser.Textures.CanvasTexture#imageData + * @type {ImageData} + * @since 3.13.0 + */ + this.imageData = this.context.getImageData(0, 0, width, height); + + /** + * A Uint8ClampedArray view into the `buffer`. + * Use the `update` method to populate this when the canvas changes. + * Note that this is unavailable in some browsers, such as Epic Browser, due to their security restrictions. + * + * @name Phaser.Textures.CanvasTexture#data + * @type {Uint8ClampedArray} + * @since 3.13.0 + */ + this.data = null; + + if (this.imageData) + { + this.data = this.imageData.data; + } + + /** + * An Uint32Array view into the `buffer`. + * + * @name Phaser.Textures.CanvasTexture#pixels + * @type {Uint32Array} + * @since 3.13.0 + */ + this.pixels = null; + + /** + * An ArrayBuffer the same size as the context ImageData. + * + * @name Phaser.Textures.CanvasTexture#buffer + * @type {ArrayBuffer} + * @since 3.13.0 + */ + this.buffer; + + if (this.data) + { + if (this.imageData.data.buffer) + { + this.buffer = this.imageData.data.buffer; + this.pixels = new Uint32Array(this.buffer); + } + else if (window.ArrayBuffer) + { + this.buffer = new ArrayBuffer(this.imageData.data.length); + this.pixels = new Uint32Array(this.buffer); + } + else + { + this.pixels = this.imageData.data; + } + } + }, + + /** + * This re-creates the `imageData` from the current context. + * It then re-builds the ArrayBuffer, the `data` Uint8ClampedArray reference and the `pixels` Int32Array. + * + * Warning: This is a very expensive operation, so use it sparingly. + * + * @method Phaser.Textures.CanvasTexture#update + * @since 3.13.0 + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + update: function () + { + this.imageData = this.context.getImageData(0, 0, this.width, this.height); + + this.data = this.imageData.data; + + if (this.imageData.data.buffer) + { + this.buffer = this.imageData.data.buffer; + this.pixels = new Uint32Array(this.buffer); + } + else if (window.ArrayBuffer) + { + this.buffer = new ArrayBuffer(this.imageData.data.length); + this.pixels = new Uint32Array(this.buffer); + } + else + { + this.pixels = this.imageData.data; + } + + return this; + }, + + /** + * Draws the given Image or Canvas element to this CanvasTexture, then updates the internal + * ImageData buffer and arrays. + * + * @method Phaser.Textures.CanvasTexture#draw + * @since 3.13.0 + * + * @param {integer} x - The x coordinate to draw the source at. + * @param {integer} y - The y coordinate to draw the source at. + * @param {(HTMLImageElement|HTMLCanvasElement)} source - The element to draw to this canvas. + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + draw: function (x, y, source) + { + this.context.drawImage(source, x, y); + + return this.update(); + }, + + /** + * Get the color of a specific pixel from this texture and store it in a Color object. + * + * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * + * @method Phaser.Textures.CanvasTexture#getPixel + * @since 3.13.0 + * + * @param {integer} x - The x coordinate of the pixel to be set. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} y - The y coordinate of the pixel to be set. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {Phaser.Display.Color} [out] - An object into which 4 properties will be set: r, g, b and a. If not provided a Color object will be created. + * + * @return {Phaser.Display.Color} An object with the red, green, blue and alpha values set in the r, g, b and a properties. + */ + getPixel: function (x, y, out) + { + if (!out) + { + out = new Color(); + } + + var index = ~~(x + (y * this.width)); + + index *= 4; + + var r = this.data[index]; + var g = this.data[++index]; + var b = this.data[++index]; + var a = this.data[++index]; + + return out.setTo(r, g, b, a); }, /** @@ -103456,7 +136701,7 @@ var CanvasTexture = new Class({ { this.context.clearRect(0, 0, this.width, this.height); - return this; + return this.update(); }, /** @@ -103500,8 +136745,8 @@ module.exports = CanvasTexture; /***/ }), -/* 516 */ -/***/ (function(module, exports) { +/* 888 */ +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -103532,7 +136777,6 @@ var InjectionMap = { events: 'events', cameras: 'cameras', - cameras3d: 'cameras3d', add: 'add', make: 'make', scenePlugin: 'scene', @@ -103551,11 +136795,17 @@ var InjectionMap = { }; +if (false) +{} + +if (false) +{} + module.exports = InjectionMap; /***/ }), -/* 517 */ +/* 889 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103564,7 +136814,7 @@ module.exports = InjectionMap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. @@ -103602,7 +136852,7 @@ module.exports = GetScenePlugins; /***/ }), -/* 518 */ +/* 890 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103611,8 +136861,8 @@ module.exports = GetScenePlugins; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); -var UppercaseFirst = __webpack_require__(256); +var GetFastValue = __webpack_require__(2); +var UppercaseFirst = __webpack_require__(327); /** * Builds an array of which physics plugins should be activated for the given Scene. @@ -103664,7 +136914,1044 @@ module.exports = GetPhysicsPlugins; /***/ }), -/* 519 */ +/* 891 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(26); + +/** + * Called automatically by Phaser.Game and responsible for creating the console.log debug header. + * + * You can customize or disable the header via the Game Config object. + * + * @function Phaser.Boot.DebugHeader + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. + */ +var DebugHeader = function (game) +{ + var config = game.config; + + if (config.hideBanner) + { + return; + } + + var renderType = 'WebGL'; + + if (config.renderType === CONST.CANVAS) + { + renderType = 'Canvas'; + } + else if (config.renderType === CONST.HEADLESS) + { + renderType = 'Headless'; + } + + var audioConfig = config.audio; + var deviceAudio = game.device.audio; + + var audioType; + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + audioType = 'Web Audio'; + } + else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + audioType = 'No Audio'; + } + else + { + audioType = 'HTML5 Audio'; + } + + if (!game.device.browser.ie) + { + var c = ''; + var args = [ c ]; + + if (Array.isArray(config.bannerBackgroundColor)) + { + var lastColor; + + config.bannerBackgroundColor.forEach(function (color) + { + c = c.concat('%c '); + + args.push('background: ' + color); + + lastColor = color; + + }); + + // inject the text color + args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; + } + else + { + c = c.concat('%c '); + + args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); + } + + // URL link background color (always white) + args.push('background: #fff'); + + if (config.gameTitle) + { + c = c.concat(config.gameTitle); + + if (config.gameVersion) + { + c = c.concat(' v' + config.gameVersion); + } + + if (!config.hidePhaser) + { + c = c.concat(' / '); + } + } + + var fb = ( false) ? undefined : ''; + + if (!config.hidePhaser) + { + c = c.concat('Phaser v' + CONST.VERSION + fb + ' (' + renderType + ' | ' + audioType + ')'); + } + + c = c.concat(' %c ' + config.gameURL); + + // Inject the new string back into the args array + args[0] = c; + + console.log.apply(console, args); + } + else if (window['console']) + { + console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); + } +}; + +module.exports = DebugHeader; + + +/***/ }), +/* 892 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_TEXTURE_TINT_VS', + '', + 'precision mediump float;', + '', + 'uniform mat4 uProjectionMatrix;', + 'uniform mat4 uViewMatrix;', + 'uniform mat4 uModelMatrix;', + '', + 'attribute vec2 inPosition;', + 'attribute vec2 inTexCoord;', + 'attribute float inTintEffect;', + 'attribute vec4 inTint;', + '', + 'varying vec2 outTexCoord;', + 'varying float outTintEffect;', + 'varying vec4 outTint;', + '', + 'void main ()', + '{', + ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', + '', + ' outTexCoord = inTexCoord;', + ' outTint = inTint;', + ' outTintEffect = inTintEffect;', + '}', + '', + '' +].join('\n'); + + +/***/ }), +/* 893 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_TEXTURE_TINT_FS', + '', + 'precision mediump float;', + '', + 'uniform sampler2D uMainSampler;', + '', + 'varying vec2 outTexCoord;', + 'varying float outTintEffect;', + 'varying vec4 outTint;', + '', + 'void main()', + '{', + ' vec4 texture = texture2D(uMainSampler, outTexCoord);', + ' vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);', + ' vec4 color = texture;', + '', + ' if (outTintEffect == 0.0)', + ' {', + ' // Multiply texture tint', + ' color = texture * texel;', + ' }', + ' else if (outTintEffect == 1.0)', + ' {', + ' // Solid color + texture alpha', + ' color.rgb = mix(texture.rgb, outTint.rgb * outTint.a, texture.a);', + ' color.a = texture.a * texel.a;', + ' }', + ' else if (outTintEffect == 2.0)', + ' {', + ' // Solid color, no texture', + ' color = texel;', + ' }', + '', + ' gl_FragColor = color;', + '}', + '' +].join('\n'); + + +/***/ }), +/* 894 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + + +/** + * Implements a model view projection matrices. + * Pipelines can implement this for doing 2D and 3D rendering. + */ + +var ModelViewProjection = { + + /** + * Dirty flag for checking if model matrix needs to be updated on GPU. + */ + modelMatrixDirty: false, + + /** + * Dirty flag for checking if view matrix needs to be updated on GPU. + */ + viewMatrixDirty: false, + + /** + * Dirty flag for checking if projection matrix needs to be updated on GPU. + */ + projectionMatrixDirty: false, + + /** + * Model matrix + */ + modelMatrix: null, + + /** + * View matrix + */ + viewMatrix: null, + + /** + * Projection matrix + */ + projectionMatrix: null, + + /** + * Initializes MVP matrices with an identity matrix + */ + mvpInit: function () + { + this.modelMatrixDirty = true; + this.viewMatrixDirty = true; + this.projectionMatrixDirty = true; + + this.modelMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.viewMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.projectionMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + /** + * If dirty flags are set then the matrices are uploaded to the GPU. + */ + mvpUpdate: function () + { + var program = this.program; + + if (this.modelMatrixDirty) + { + this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); + this.modelMatrixDirty = false; + } + + if (this.viewMatrixDirty) + { + this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); + this.viewMatrixDirty = false; + } + + if (this.projectionMatrixDirty) + { + this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); + this.projectionMatrixDirty = false; + } + + return this; + }, + + /** + * Loads an identity matrix to the model matrix + */ + modelIdentity: function () + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = 1; + modelMatrix[1] = 0; + modelMatrix[2] = 0; + modelMatrix[3] = 0; + modelMatrix[4] = 0; + modelMatrix[5] = 1; + modelMatrix[6] = 0; + modelMatrix[7] = 0; + modelMatrix[8] = 0; + modelMatrix[9] = 0; + modelMatrix[10] = 1; + modelMatrix[11] = 0; + modelMatrix[12] = 0; + modelMatrix[13] = 0; + modelMatrix[14] = 0; + modelMatrix[15] = 1; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Scale model matrix + */ + modelScale: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = modelMatrix[0] * x; + modelMatrix[1] = modelMatrix[1] * x; + modelMatrix[2] = modelMatrix[2] * x; + modelMatrix[3] = modelMatrix[3] * x; + modelMatrix[4] = modelMatrix[4] * y; + modelMatrix[5] = modelMatrix[5] * y; + modelMatrix[6] = modelMatrix[6] * y; + modelMatrix[7] = modelMatrix[7] * y; + modelMatrix[8] = modelMatrix[8] * z; + modelMatrix[9] = modelMatrix[9] * z; + modelMatrix[10] = modelMatrix[10] * z; + modelMatrix[11] = modelMatrix[11] * z; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Translate model matrix + */ + modelTranslate: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; + modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; + modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; + modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; + + this.modelMatrixDirty = true; + + return this; + }, + + + /** + * Rotates the model matrix in the X axis. + */ + modelRotateX: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[4] = a10 * c + a20 * s; + modelMatrix[5] = a11 * c + a21 * s; + modelMatrix[6] = a12 * c + a22 * s; + modelMatrix[7] = a13 * c + a23 * s; + modelMatrix[8] = a20 * c - a10 * s; + modelMatrix[9] = a21 * c - a11 * s; + modelMatrix[10] = a22 * c - a12 * s; + modelMatrix[11] = a23 * c - a13 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Rotates the model matrix in the Y axis. + */ + modelRotateY: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[0] = a00 * c - a20 * s; + modelMatrix[1] = a01 * c - a21 * s; + modelMatrix[2] = a02 * c - a22 * s; + modelMatrix[3] = a03 * c - a23 * s; + modelMatrix[8] = a00 * s + a20 * c; + modelMatrix[9] = a01 * s + a21 * c; + modelMatrix[10] = a02 * s + a22 * c; + modelMatrix[11] = a03 * s + a23 * c; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Rotates the model matrix in the Z axis. + */ + modelRotateZ: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + + modelMatrix[0] = a00 * c + a10 * s; + modelMatrix[1] = a01 * c + a11 * s; + modelMatrix[2] = a02 * c + a12 * s; + modelMatrix[3] = a03 * c + a13 * s; + modelMatrix[4] = a10 * c - a00 * s; + modelMatrix[5] = a11 * c - a01 * s; + modelMatrix[6] = a12 * c - a02 * s; + modelMatrix[7] = a13 * c - a03 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Loads identity matrix into the view matrix + */ + viewIdentity: function () + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = 1; + viewMatrix[1] = 0; + viewMatrix[2] = 0; + viewMatrix[3] = 0; + viewMatrix[4] = 0; + viewMatrix[5] = 1; + viewMatrix[6] = 0; + viewMatrix[7] = 0; + viewMatrix[8] = 0; + viewMatrix[9] = 0; + viewMatrix[10] = 1; + viewMatrix[11] = 0; + viewMatrix[12] = 0; + viewMatrix[13] = 0; + viewMatrix[14] = 0; + viewMatrix[15] = 1; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Scales view matrix + */ + viewScale: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = viewMatrix[0] * x; + viewMatrix[1] = viewMatrix[1] * x; + viewMatrix[2] = viewMatrix[2] * x; + viewMatrix[3] = viewMatrix[3] * x; + viewMatrix[4] = viewMatrix[4] * y; + viewMatrix[5] = viewMatrix[5] * y; + viewMatrix[6] = viewMatrix[6] * y; + viewMatrix[7] = viewMatrix[7] * y; + viewMatrix[8] = viewMatrix[8] * z; + viewMatrix[9] = viewMatrix[9] * z; + viewMatrix[10] = viewMatrix[10] * z; + viewMatrix[11] = viewMatrix[11] * z; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Translates view matrix + */ + viewTranslate: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; + viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; + viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; + viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Rotates view matrix in the X axis. + */ + viewRotateX: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[4] = a10 * c + a20 * s; + viewMatrix[5] = a11 * c + a21 * s; + viewMatrix[6] = a12 * c + a22 * s; + viewMatrix[7] = a13 * c + a23 * s; + viewMatrix[8] = a20 * c - a10 * s; + viewMatrix[9] = a21 * c - a11 * s; + viewMatrix[10] = a22 * c - a12 * s; + viewMatrix[11] = a23 * c - a13 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Rotates view matrix in the Y axis. + */ + viewRotateY: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[0] = a00 * c - a20 * s; + viewMatrix[1] = a01 * c - a21 * s; + viewMatrix[2] = a02 * c - a22 * s; + viewMatrix[3] = a03 * c - a23 * s; + viewMatrix[8] = a00 * s + a20 * c; + viewMatrix[9] = a01 * s + a21 * c; + viewMatrix[10] = a02 * s + a22 * c; + viewMatrix[11] = a03 * s + a23 * c; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Rotates view matrix in the Z axis. + */ + viewRotateZ: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + + viewMatrix[0] = a00 * c + a10 * s; + viewMatrix[1] = a01 * c + a11 * s; + viewMatrix[2] = a02 * c + a12 * s; + viewMatrix[3] = a03 * c + a13 * s; + viewMatrix[4] = a10 * c - a00 * s; + viewMatrix[5] = a11 * c - a01 * s; + viewMatrix[6] = a12 * c - a02 * s; + viewMatrix[7] = a13 * c - a03 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Loads a 2D view matrix (3x2 matrix) into a 4x4 view matrix + */ + viewLoad2D: function (matrix2D) + { + var vm = this.viewMatrix; + + vm[0] = matrix2D[0]; + vm[1] = matrix2D[1]; + vm[2] = 0.0; + vm[3] = 0.0; + vm[4] = matrix2D[2]; + vm[5] = matrix2D[3]; + vm[6] = 0.0; + vm[7] = 0.0; + vm[8] = matrix2D[4]; + vm[9] = matrix2D[5]; + vm[10] = 1.0; + vm[11] = 0.0; + vm[12] = 0.0; + vm[13] = 0.0; + vm[14] = 0.0; + vm[15] = 1.0; + + this.viewMatrixDirty = true; + + return this; + }, + + + /** + * Copies a 4x4 matrix into the view matrix + */ + viewLoad: function (matrix) + { + var vm = this.viewMatrix; + + vm[0] = matrix[0]; + vm[1] = matrix[1]; + vm[2] = matrix[2]; + vm[3] = matrix[3]; + vm[4] = matrix[4]; + vm[5] = matrix[5]; + vm[6] = matrix[6]; + vm[7] = matrix[7]; + vm[8] = matrix[8]; + vm[9] = matrix[9]; + vm[10] = matrix[10]; + vm[11] = matrix[11]; + vm[12] = matrix[12]; + vm[13] = matrix[13]; + vm[14] = matrix[14]; + vm[15] = matrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Loads identity matrix into the projection matrix. + */ + projIdentity: function () + { + var projectionMatrix = this.projectionMatrix; + + projectionMatrix[0] = 1; + projectionMatrix[1] = 0; + projectionMatrix[2] = 0; + projectionMatrix[3] = 0; + projectionMatrix[4] = 0; + projectionMatrix[5] = 1; + projectionMatrix[6] = 0; + projectionMatrix[7] = 0; + projectionMatrix[8] = 0; + projectionMatrix[9] = 0; + projectionMatrix[10] = 1; + projectionMatrix[11] = 0; + projectionMatrix[12] = 0; + projectionMatrix[13] = 0; + projectionMatrix[14] = 0; + projectionMatrix[15] = 1; + + this.projectionMatrixDirty = true; + + return this; + }, + + /** + * Sets up an orthographics projection matrix + */ + projOrtho: function (left, right, bottom, top, near, far) + { + var projectionMatrix = this.projectionMatrix; + var leftRight = 1.0 / (left - right); + var bottomTop = 1.0 / (bottom - top); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = -2.0 * leftRight; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = -2.0 * bottomTop; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = 2.0 * nearFar; + projectionMatrix[11] = 0.0; + projectionMatrix[12] = (left + right) * leftRight; + projectionMatrix[13] = (top + bottom) * bottomTop; + projectionMatrix[14] = (far + near) * nearFar; + projectionMatrix[15] = 1.0; + + this.projectionMatrixDirty = true; + return this; + }, + + /** + * Sets up a perspective projection matrix + */ + projPersp: function (fovy, aspectRatio, near, far) + { + var projectionMatrix = this.projectionMatrix; + var fov = 1.0 / Math.tan(fovy / 2.0); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = fov / aspectRatio; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = fov; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = (far + near) * nearFar; + projectionMatrix[11] = -1.0; + projectionMatrix[12] = 0.0; + projectionMatrix[13] = 0.0; + projectionMatrix[14] = (2.0 * far * near) * nearFar; + projectionMatrix[15] = 0.0; + + this.projectionMatrixDirty = true; + return this; + } +}; + +module.exports = ModelViewProjection; + + +/***/ }), +/* 895 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS', + '', + 'precision mediump float;', + '', + 'struct Light', + '{', + ' vec2 position;', + ' vec3 color;', + ' float intensity;', + ' float radius;', + '};', + '', + 'const int kMaxLights = %LIGHT_COUNT%;', + '', + 'uniform vec4 uCamera; /* x, y, rotation, zoom */', + 'uniform vec2 uResolution;', + 'uniform sampler2D uMainSampler;', + 'uniform sampler2D uNormSampler;', + 'uniform vec3 uAmbientLightColor;', + 'uniform Light uLights[kMaxLights];', + '', + 'varying vec2 outTexCoord;', + 'varying vec4 outTint;', + '', + 'void main()', + '{', + ' vec3 finalColor = vec3(0.0, 0.0, 0.0);', + ' vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);', + ' vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;', + ' vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));', + ' vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;', + '', + ' for (int index = 0; index < kMaxLights; ++index)', + ' {', + ' Light light = uLights[index];', + ' vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);', + ' vec3 lightNormal = normalize(lightDir);', + ' float distToSurf = length(lightDir) * uCamera.w;', + ' float diffuseFactor = max(dot(normal, lightNormal), 0.0);', + ' float radius = (light.radius / res.x * uCamera.w) * uCamera.w;', + ' float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);', + ' vec3 diffuse = light.color * diffuseFactor;', + ' finalColor += (attenuation * diffuse) * light.intensity;', + ' }', + '', + ' vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);', + ' gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);', + '', + '}', + '' +].join('\n'); + + +/***/ }), +/* 896 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_BITMAP_MASK_VS', + '', + 'precision mediump float;', + '', + 'attribute vec2 inPosition;', + '', + 'void main()', + '{', + ' gl_Position = vec4(inPosition, 0.0, 1.0);', + '}', + '' +].join('\n'); + + +/***/ }), +/* 897 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_BITMAP_MASK_FS', + '', + 'precision mediump float;', + '', + 'uniform vec2 uResolution;', + 'uniform sampler2D uMainSampler;', + 'uniform sampler2D uMaskSampler;', + 'uniform bool uInvertMaskAlpha;', + '', + 'void main()', + '{', + ' vec2 uv = gl_FragCoord.xy / uResolution;', + ' vec4 mainColor = texture2D(uMainSampler, uv);', + ' vec4 maskColor = texture2D(uMaskSampler, uv);', + ' float alpha = mainColor.a;', + '', + ' if (!uInvertMaskAlpha)', + ' {', + ' alpha *= (maskColor.a);', + ' }', + ' else', + ' {', + ' alpha *= (1.0 - maskColor.a);', + ' }', + '', + ' gl_FragColor = vec4(mainColor.rgb * alpha, alpha);', + '}', + '' +].join('\n'); + + +/***/ }), +/* 898 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasInterpolation = __webpack_require__(348); +var CanvasPool = __webpack_require__(24); +var CONST = __webpack_require__(26); +var Features = __webpack_require__(168); + +/** + * Called automatically by Phaser.Game and responsible for creating the renderer it will use. + * + * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. + * + * @function Phaser.Boot.CreateRenderer + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. + */ +var CreateRenderer = function (game) +{ + var config = game.config; + + // Game either requested Canvas, + // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas + + if (config.renderType !== CONST.HEADLESS) + { + if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) + { + if (Features.canvas) + { + // They requested Canvas and their browser supports it + config.renderType = CONST.CANVAS; + } + else + { + throw new Error('Cannot create Canvas or WebGL context, aborting.'); + } + } + else + { + // Game requested WebGL and browser says it supports it + config.renderType = CONST.WEBGL; + } + } + + // Pixel Art mode? + if (!config.antialias) + { + CanvasPool.disableSmoothing(); + } + + // Does the game config provide its own canvas element to use? + if (config.canvas) + { + game.canvas = config.canvas; + + game.canvas.width = game.config.width; + game.canvas.height = game.config.height; + } + else + { + game.canvas = CanvasPool.create(game, config.width * config.resolution, config.height * config.resolution, config.renderType); + } + + // Does the game config provide some canvas css styles to use? + if (config.canvasStyle) + { + game.canvas.style = config.canvasStyle; + } + + // Pixel Art mode? + if (!config.antialias) + { + CanvasInterpolation.setCrisp(game.canvas); + } + + // Zoomed? + game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; + game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; + + if (config.renderType === CONST.HEADLESS) + { + // Nothing more to do here + return; + } + + var CanvasRenderer; + var WebGLRenderer; + + if (true) + { + CanvasRenderer = __webpack_require__(426); + WebGLRenderer = __webpack_require__(423); + + // Let the config pick the renderer type, as both are included + if (config.renderType === CONST.WEBGL) + { + game.renderer = new WebGLRenderer(game); + } + else + { + game.renderer = new CanvasRenderer(game); + game.context = game.renderer.gameContext; + } + } + + if (false) + {} + + if (false) + {} +}; + +module.exports = CreateRenderer; + + +/***/ }), +/* 899 */ /***/ (function(module, exports) { /** @@ -103762,7 +138049,7 @@ module.exports = init(); /***/ }), -/* 520 */ +/* 900 */ /***/ (function(module, exports) { /** @@ -103847,7 +138134,7 @@ module.exports = init(); /***/ }), -/* 521 */ +/* 901 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103856,7 +138143,7 @@ module.exports = init(); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Browser = __webpack_require__(80); +var Browser = __webpack_require__(118); /** * Determines the audio playback capabilities of the device running this Phaser Game instance. @@ -103972,7 +138259,7 @@ module.exports = init(); /***/ }), -/* 522 */ +/* 902 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103981,8 +138268,8 @@ module.exports = init(); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var OS = __webpack_require__(57); -var Browser = __webpack_require__(80); +var OS = __webpack_require__(92); +var Browser = __webpack_require__(118); /** * Determines the input support of the browser running this Phaser Game instance. @@ -104051,521 +138338,7 @@ module.exports = init(); /***/ }), -/* 523 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// This singleton is instantiated as soon as Phaser loads, -// before a Phaser.Game instance has even been created. -// Which means all instances of Phaser Games can share it, -// without having to re-poll the device all over again - -/** - * @namespace Phaser.Device - * @since 3.0.0 - */ - -/** - * @typedef {object} Phaser.DeviceConf - * - * @property {Phaser.Device.OS} os - The OS Device functions. - * @property {Phaser.Device.Browser} browser - The Browser Device functions. - * @property {Phaser.Device.Features} features - The Features Device functions. - * @property {Phaser.Device.Input} input - The Input Device functions. - * @property {Phaser.Device.Audio} audio - The Audio Device functions. - * @property {Phaser.Device.Video} video - The Video Device functions. - * @property {Phaser.Device.Fullscreen} fullscreen - The Fullscreen Device functions. - * @property {Phaser.Device.CanvasFeatures} canvasFeatures - The Canvas Device functions. - */ - -module.exports = { - - os: __webpack_require__(57), - browser: __webpack_require__(80), - features: __webpack_require__(120), - input: __webpack_require__(522), - audio: __webpack_require__(521), - video: __webpack_require__(520), - fullscreen: __webpack_require__(519), - canvasFeatures: __webpack_require__(203) - -}; - - -/***/ }), -/* 524 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(20); - -/** - * Called automatically by Phaser.Game and responsible for creating the console.log debug header. - * - * You can customize or disable the header via the Game Config object. - * - * @function Phaser.Boot.DebugHeader - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. - */ -var DebugHeader = function (game) -{ - var config = game.config; - - if (config.hideBanner) - { - return; - } - - var renderType = 'WebGL'; - - if (config.renderType === CONST.CANVAS) - { - renderType = 'Canvas'; - } - else if (config.renderType === CONST.HEADLESS) - { - renderType = 'Headless'; - } - - var audioConfig = config.audio; - var deviceAudio = game.device.audio; - - var audioType; - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - audioType = 'Web Audio'; - } - else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - audioType = 'No Audio'; - } - else - { - audioType = 'HTML5 Audio'; - } - - if (!game.device.browser.ie) - { - var c = ''; - var args = [ c ]; - - if (Array.isArray(config.bannerBackgroundColor)) - { - var lastColor; - - config.bannerBackgroundColor.forEach(function (color) - { - c = c.concat('%c '); - - args.push('background: ' + color); - - lastColor = color; - - }); - - // inject the text color - args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; - } - else - { - c = c.concat('%c '); - - args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); - } - - // URL link background color (always white) - args.push('background: #fff'); - - if (config.gameTitle) - { - c = c.concat(config.gameTitle); - - if (config.gameVersion) - { - c = c.concat(' v' + config.gameVersion); - } - - if (!config.hidePhaser) - { - c = c.concat(' / '); - } - } - - if (!config.hidePhaser) - { - c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); - } - - c = c.concat(' %c ' + config.gameURL); - - // Inject the new string back into the args array - args[0] = c; - - console.log.apply(console, args); - } - else if (window['console']) - { - console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); - } -}; - -module.exports = DebugHeader; - - -/***/ }), -/* 525 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_TEXTURE_TINT_VS', - '', - 'precision mediump float;', - '', - 'uniform mat4 uProjectionMatrix;', - 'uniform mat4 uViewMatrix;', - 'uniform mat4 uModelMatrix;', - '', - 'attribute vec2 inPosition;', - 'attribute vec2 inTexCoord;', - 'attribute vec4 inTint;', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main ()', - '{', - ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', - ' outTexCoord = inTexCoord;', - ' outTint = inTint;', - '}', - '', - '' -].join('\n'); - - -/***/ }), -/* 526 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_TEXTURE_TINT_FS', - '', - 'precision mediump float;', - '', - 'uniform sampler2D uMainSampler;', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main()', - '{', - ' vec4 texel = texture2D(uMainSampler, outTexCoord);', - ' texel *= vec4(outTint.rgb * outTint.a, outTint.a);', - ' gl_FragColor = texel;', - '}', - '' -].join('\n'); - - -/***/ }), -/* 527 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS', - '', - 'precision mediump float;', - '', - 'struct Light', - '{', - ' vec2 position;', - ' vec3 color;', - ' float intensity;', - ' float radius;', - '};', - '', - 'const int kMaxLights = %LIGHT_COUNT%;', - '', - 'uniform vec4 uCamera; /* x, y, rotation, zoom */', - 'uniform vec2 uResolution;', - 'uniform sampler2D uMainSampler;', - 'uniform sampler2D uNormSampler;', - 'uniform vec3 uAmbientLightColor;', - 'uniform Light uLights[kMaxLights];', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main()', - '{', - ' vec3 finalColor = vec3(0.0, 0.0, 0.0);', - ' vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);', - ' vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;', - ' vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));', - ' vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;', - '', - ' for (int index = 0; index < kMaxLights; ++index)', - ' {', - ' Light light = uLights[index];', - ' vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);', - ' vec3 lightNormal = normalize(lightDir);', - ' float distToSurf = length(lightDir) * uCamera.w;', - ' float diffuseFactor = max(dot(normal, lightNormal), 0.0);', - ' float radius = (light.radius / res.x * uCamera.w) * uCamera.w;', - ' float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);', - ' vec3 diffuse = light.color * diffuseFactor;', - ' finalColor += (attenuation * diffuse) * light.intensity;', - ' }', - '', - ' vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);', - ' gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);', - '', - '}', - '' -].join('\n'); - - -/***/ }), -/* 528 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_FLAT_TINT_VS', - '', - 'precision mediump float;', - '', - 'uniform mat4 uProjectionMatrix;', - 'uniform mat4 uViewMatrix;', - 'uniform mat4 uModelMatrix;', - '', - 'attribute vec2 inPosition;', - 'attribute vec4 inTint;', - '', - 'varying vec4 outTint;', - '', - 'void main () {', - ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', - ' outTint = inTint;', - '}', - '' -].join('\n'); - - -/***/ }), -/* 529 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_FLAT_TINT_FS', - '', - 'precision mediump float;', - '', - 'varying vec4 outTint;', - '', - 'void main() {', - ' gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);', - '}', - '' -].join('\n'); - - -/***/ }), -/* 530 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_BITMAP_MASK_VS', - '', - 'precision mediump float;', - '', - 'attribute vec2 inPosition;', - '', - 'void main()', - '{', - ' gl_Position = vec4(inPosition, 0.0, 1.0);', - '}', - '' -].join('\n'); - - -/***/ }), -/* 531 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_BITMAP_MASK_FS', - '', - 'precision mediump float;', - '', - 'uniform vec2 uResolution;', - 'uniform sampler2D uMainSampler;', - 'uniform sampler2D uMaskSampler;', - 'uniform bool uInvertMaskAlpha;', - '', - 'void main()', - '{', - ' vec2 uv = gl_FragCoord.xy / uResolution;', - ' vec4 mainColor = texture2D(uMainSampler, uv);', - ' vec4 maskColor = texture2D(uMaskSampler, uv);', - ' float alpha = mainColor.a;', - '', - ' if (!uInvertMaskAlpha)', - ' {', - ' alpha *= (maskColor.a);', - ' }', - ' else', - ' {', - ' alpha *= (1.0 - maskColor.a);', - ' }', - '', - ' gl_FragColor = vec4(mainColor.rgb * alpha, alpha);', - '}', - '' -].join('\n'); - - -/***/ }), -/* 532 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasInterpolation = __webpack_require__(272); -var CanvasPool = __webpack_require__(22); -var CONST = __webpack_require__(20); -var Features = __webpack_require__(120); - -/** - * Called automatically by Phaser.Game and responsible for creating the renderer it will use. - * - * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. - * - * @function Phaser.Boot.CreateRenderer - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. - */ -var CreateRenderer = function (game) -{ - var config = game.config; - - // Game either requested Canvas, - // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas - - if (config.renderType !== CONST.HEADLESS) - { - if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) - { - if (Features.canvas) - { - // They requested Canvas and their browser supports it - config.renderType = CONST.CANVAS; - } - else - { - throw new Error('Cannot create Canvas or WebGL context, aborting.'); - } - } - else - { - // Game requested WebGL and browser says it supports it - config.renderType = CONST.WEBGL; - } - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasPool.disableSmoothing(); - } - - // Does the game config provide its own canvas element to use? - if (config.canvas) - { - game.canvas = config.canvas; - } - else - { - game.canvas = CanvasPool.create(game, config.width, config.height, config.renderType); - } - - // Does the game config provide some canvas css styles to use? - if (config.canvasStyle) - { - game.canvas.style = config.canvasStyle; - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasInterpolation.setCrisp(game.canvas); - } - - // Zoomed? - if (config.zoom !== 1) - { - game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; - game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; - } - - if (config.renderType === CONST.HEADLESS) - { - // Nothing more to do here - return; - } - - var CanvasRenderer; - var WebGLRenderer; - - if (true) - { - CanvasRenderer = __webpack_require__(267); - WebGLRenderer = __webpack_require__(262); - - // Let the config pick the renderer type, as both are included - if (config.renderType === CONST.WEBGL) - { - game.renderer = new WebGLRenderer(game); - - // The WebGL Renderer sets this value during its init, not on construction - game.context = null; - } - else - { - game.renderer = new CanvasRenderer(game); - game.context = game.renderer.gameContext; - } - } - - if (false) - {} - - if (false) - {} -}; - -module.exports = CreateRenderer; - - -/***/ }), -/* 533 */ +/* 903 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -104575,14 +138348,15 @@ module.exports = CreateRenderer; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var GetFastValue = __webpack_require__(1); +var CONST = __webpack_require__(26); +var Device = __webpack_require__(340); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); var IsPlainObject = __webpack_require__(8); var MATH = __webpack_require__(16); -var NOOP = __webpack_require__(3); -var DefaultPlugins = __webpack_require__(121); -var ValueToColor = __webpack_require__(132); +var NOOP = __webpack_require__(1); +var DefaultPlugins = __webpack_require__(167); +var ValueToColor = __webpack_require__(178); /** * This callback type is completely empty, a no-operation. @@ -104593,98 +138367,210 @@ var ValueToColor = __webpack_require__(132); /** * @callback BootCallback * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - The game. + */ + +/** + * @typedef {object} InputConfig + * + * @property {(boolean|KeyboardInputConfig)} [keyboard=true] - Keyboard input configuration. `true` uses the default configuration and `false` disables keyboard input. + * @property {(boolean|MouseInputConfig)} [mouse=true] - Mouse input configuration. `true` uses the default configuration and `false` disables mouse input. + * @property {(boolean|TouchInputConfig)} [touch=true] - Touch input configuration. `true` uses the default configuration and `false` disables touch input. + * @property {(boolean|GamepadInputConfig)} [gamepad=false] - Gamepad input configuration. `true` enables gamepad input. + * @property {integer} [activePointers=1] - The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}. + */ + +/** + * @typedef {object} MouseInputConfig + * + * @property {*} [target=null] - Where the Mouse Manager listens for mouse input events. The default is the game canvas. + * @property {boolean} [capture=true] - Whether mouse input events have preventDefault() called on them. + */ + +/** + * @typedef {object} KeyboardInputConfig + * + * @property {*} [target=window] - Where the Keyboard Manager listens for keyboard input events. + */ + +/** + * @typedef {object} TouchInputConfig + * + * @property {*} [target=null] - Where the Touch Manager listens for touch input events. The default is the game canvas. + * @property {boolean} [capture=true] - Whether touch input events have preventDefault() called on them. + */ + +/** + * @typedef {object} GamepadInputConfig + * + * @property {*} [target=window] - Where the Gamepad Manager listens for gamepad input events. + */ + +/** + * @typedef {object} BannerConfig + * + * @property {boolean} [hidePhaser=false] - Omit Phaser's name and version from the banner. + * @property {string} [text='#ffffff'] - The color of the banner text. + * @property {string[]} [background] - The background colors of the banner. */ /** * @typedef {object} FPSConfig * - * @property {integer} [min=10] - [description] - * @property {integer} [target=60] - [description] - * @property {boolean} [forceSetTimeOut=false] - [description] - * @property {integer} [deltaHistory=10] - [description] + * @property {integer} [min=10] - The minimum acceptable rendering rate, in frames per second. + * @property {integer} [target=60] - The optimum rendering rate, in frames per second. + * @property {boolean} [forceSetTimeOut=false] - Use setTimeout instead of requestAnimationFrame to run the game loop. + * @property {integer} [deltaHistory=10] - Calculate the average frame delta from this many consecutive frame intervals. * @property {integer} [panicMax=120] - [description] */ +/** + * @typedef {object} RenderConfig + * + * @property {boolean} [antialias=true] - When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. + * @property {boolean} [pixelArt=false] - Sets `antialias` and `roundPixels` to true. This is the best setting for pixel-art games. + * @property {boolean} [autoResize=true] - Automatically resize the Game Canvas if you resize the renderer. + * @property {boolean} [roundPixels=false] - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. + * @property {boolean} [transparent=false] - Whether the game canvas will be transparent. + * @property {boolean} [clearBeforeRender=true] - Whether the game canvas will be cleared between each rendering frame. + * @property {boolean} [premultipliedAlpha=true] - In WebGL mode, the drawing buffer contains colors with pre-multiplied alpha. + * @property {boolean} [preserveDrawingBuffer=false] - In WebGL mode, the drawing buffer won't be cleared automatically each frame. + * @property {boolean} [failIfMajorPerformanceCaveat=false] - Let the browser abort creating a WebGL context if it judges performance would be unacceptable. + * @property {string} [powerPreference='default'] - "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. + * @property {integer} [batchSize=2000] - The default WebGL batch size. + * @property {integer} [maxLights=10] - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + +/** + * @typedef {object} ScaleConfig + * + * @property {(integer|string)} [width=1024] - The base width of your game. + * @property {(integer|string)} [height=768] - The base height of your game. + * @property {integer} [zoom=1] - The zoom value of the game canvas. + * @property {number} [resolution=1] - The rendering resolution of the canvas. + * @property {(HTMLElement|string)} [parent] - The DOM element that will contain the game canvas, or its `id`. If null (the default) or if the named element doesn't exist, the game canvas is inserted directly into the document body. + * @property {integer} [mode=0] - The scale mode to apply to the canvas. SHOW_ALL, EXACT_FIT, USER_SCALE, or RESIZE. + * @property {integer} [minWidth] - The minimum width the canvas can be scaled down to. + * @property {integer} [minHeight] - The minimum height the canvas can be scaled down to. + * @property {integer} [maxWidth] - The maximum width the canvas can be scaled up to. + * @property {integer} [maxHeight] - The maximum height the canvas can be scaled up to. + */ + +/** + * @typedef {object} CallbacksConfig + * + * @property {BootCallback} [preBoot=NOOP] - A function to run at the start of the boot sequence. + * @property {BootCallback} [postBoot=NOOP] - A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. + */ + /** * @typedef {object} LoaderConfig * - * @property {string} [baseURL] - [description] - * @property {string} [path] - [description] - * @property {integer} [maxParallelDownloads=32] - [description] - * @property {(string|undefined)} [crossOrigin=undefined] - [description] - * @property {string} [responseType] - [description] - * @property {boolean} [async=true] - [description] - * @property {string} [user] - [description] - * @property {string} [password] - [description] - * @property {integer} [timeout=0] - [description] + * @property {string} [baseURL] - An URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. + * @property {string} [path] - An URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. + * @property {integer} [maxParallelDownloads=32] - The maximum number of resources the loader will start loading at once. + * @property {(string|undefined)} [crossOrigin=undefined] - 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. + * @property {string} [responseType] - The response type of the XHR request, e.g. `blob`, `text`, etc. + * @property {boolean} [async=true] - Should the XHR request use async or not? + * @property {string} [user] - Optional username for the XHR request. + * @property {string} [password] - Optional password for the XHR request. + * @property {integer} [timeout=0] - Optional XHR timeout value, in ms. + */ + +/** + * @typedef {object} DOMContainerConfig + * + * @property {boolean} [createContainer=false] - Create a div element in which DOM Elements will be contained. You must also provide a parent. + * @property {boolean} [behindCanvas=false] - Place the DOM Container behind the Phaser Canvas. The default is to place it over the Canvas. + */ + +/** + * @typedef {object} ImagesConfig + * + * @property {string} [default] - URL to use for the 'default' texture. + * @property {string} [missing] - URL to use for the 'missing' texture. + */ + +/** + * @typedef {object} PhysicsConfig + * + * @property {string} [default] - The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'. + * @property {ArcadeWorldConfig} [arcade] - Arcade Physics configuration. + * @property {Phaser.Physics.Impact.WorldConfig} [impact] - Impact Physics configuration. + * @property {object} [matter] - Matter Physics configuration. + */ + +/** + * @typedef {object} PluginObjectItem + * + * @property {string} [key] - A key to identify the plugin in the Plugin Manager. + * @property {*} [plugin] - The plugin itself. Usually a class/constructor. + * @property {boolean} [start] - Whether the plugin should be started automatically. + * @property {string} [systemKey] - For a scene plugin, add the plugin to the scene's systems object under this key (`this.sys.KEY`, from the scene). + * @property {string} [sceneKey] - For a scene plugin, add the plugin to the scene object under this key (`this.KEY`, from the scene). + * @property {*} [data] - Arbitrary data passed to the plugin's init() method. + * + * @example + * // Global plugin + * { key: 'BankPlugin', plugin: BankPluginV3, start: true, data: { gold: 5000 } } + * @example + * // Scene plugin + * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } + */ + +/** + * @typedef {object} PluginObject + * + * @property {?PluginObjectItem[]} [global] - Global plugins to install. + * @property {?PluginObjectItem[]} [scene] - Scene plugins to install. + * @property {string[]} [default] - The default set of scene plugins (names). + * @property {string[]} [defaultMerge] - Plugins to *add* to the default set of scene plugins. */ /** * @typedef {object} GameConfig * - * @property {(integer|string)} [width=1024] - [description] - * @property {(integer|string)} [height=768] - [description] - * @property {number} [zoom=1] - [description] - * @property {number} [resolution=1] - [description] - * @property {number} [type=CONST.AUTO] - [description] - * @property {*} [parent=null] - [description] + * @property {(integer|string)} [width=1024] - The width of the game, in game pixels. + * @property {(integer|string)} [height=768] - The height of the game, in game pixels. + * @property {number} [zoom=1] - Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc. + * @property {number} [resolution=1] - The size of each game pixel, in canvas pixels. Values larger than 1 are "high" resolution. + * @property {number} [type=CONST.AUTO] - Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS. + * @property {(HTMLElement|string)} [parent=null] - The DOM element that will contain the game canvas, or its `id`. If null (the default) or if the named element doesn't exist, the game canvas is inserted directly into the document body. * @property {HTMLCanvasElement} [canvas=null] - Provide your own Canvas element for Phaser to use instead of creating one. - * @property {string} [canvasStyle=null] - [description] + * @property {string} [canvasStyle=null] - CSS styles to apply to the game canvas instead of Phaser's default styles. * @property {CanvasRenderingContext2D} [context] - Provide your own Canvas Context for Phaser to use, instead of creating one. - * @property {object} [scene=null] - [description] - * @property {string[]} [seed] - [description] - * @property {string} [title=''] - [description] - * @property {string} [url='http://phaser.io'] - [description] - * @property {string} [version=''] - [description] - * @property {boolean} [autoFocus=true] - Automatically call window.focus() when the game boots. - * @property {(boolean|object)} [input] - [description] - * @property {boolean} [input.keyboard=true] - [description] - * @property {*} [input.keyboard.target=window] - [description] - * @property {(boolean|object)} [input.mouse=true] - [description] - * @property {*} [input.mouse.target=null] - [description] - * @property {boolean} [input.touch=true] - [description] - * @property {integer} [input.activePointers=1] - [description] - * @property {*} [input.touch.target=null] - [description] - * @property {boolean} [input.touch.capture=true] - [description] - * @property {(boolean|object)} [input.gamepad=false] - [description] - * @property {boolean} [disableContextMenu=false] - [description] - * @property {(boolean|object)} [banner=false] - [description] - * @property {boolean} [banner.hidePhaser=false] - [description] - * @property {string} [banner.text='#ffffff'] - [description] - * @property {string[]} [banner.background] - [description] - * @property {FPSConfig} [fps] - [description] - * @property {boolean} [render.antialias=true] - [description] - * @property {boolean} [render.pixelArt=false] - [description] - * @property {boolean} [render.autoResize=false] - [description] - * @property {boolean} [render.roundPixels=false] - [description] - * @property {boolean} [render.transparent=false] - [description] - * @property {boolean} [render.clearBeforeRender=true] - [description] - * @property {boolean} [render.premultipliedAlpha=true] - [description] - * @property {boolean} [render.preserveDrawingBuffer=false] - [description] - * @property {boolean} [render.failIfMajorPerformanceCaveat=false] - [description] - * @property {string} [render.powerPreference='default'] - "high-performance", "low-power" or "default" - * @property {(string|number)} [backgroundColor=0x000000] - [description] - * @property {object} [callbacks] - [description] - * @property {BootCallback} [callbacks.preBoot=NOOP] - [description] - * @property {BootCallback} [callbacks.postBoot=NOOP] - [description] - * @property {LoaderConfig} [loader] - [description] - * @property {object} [images] - [description] - * @property {string} [images.default] - [description] - * @property {string} [images.missing] - [description] - * @property {object} [physics] - [description] + * @property {object} [scene=null] - A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have { active: true }. + * @property {string[]} [seed] - Seed for the random number generator. + * @property {string} [title=''] - The title of the game. Shown in the browser console. + * @property {string} [url='http://phaser.io'] - The URL of the game. Shown in the browser console. + * @property {string} [version=''] - The version of the game. Shown in the browser console. + * @property {boolean} [autoFocus=true] - Automatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame. + * @property {(boolean|InputConfig)} [input] - Input configuration, or `false` to disable all game input. + * @property {boolean} [disableContextMenu=false] - Disable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click). + * @property {(boolean|BannerConfig)} [banner=false] - Configuration for the banner printed in the browser console when the game starts. + * @property {DOMContainerConfig} [dom] - The DOM Container configuration object. + * @property {FPSConfig} [fps] - Game loop configuration. + * @property {RenderConfig} [render] - Game renderer configuration. + * @property {(string|number)} [backgroundColor=0x000000] - The background color of the game canvas. The default is black. + * @property {CallbacksConfig} [callbacks] - Optional callbacks to run before or after game boot. + * @property {LoaderConfig} [loader] - Loader configuration. + * @property {ImagesConfig} [images] - Images configuration. + * @property {object} [physics] - Physics configuration. + * @property {PluginObject|PluginObjectItem[]} [plugins] - Plugins to install. */ /** * @classdesc - * [description] + * The active game configuration settings, parsed from a {@link GameConfig} object. * * @class Config - * @memberOf Phaser.Boot + * @memberof Phaser.Boot * @constructor * @since 3.0.0 * * @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. + * + * @see Phaser.Game#config */ var Config = new Class({ @@ -104724,16 +138610,65 @@ var Config = new Class({ */ this.resolution = GetValue(config, 'resolution', 1); - /** - * @const {number} Phaser.Boot.Config#renderType - [description] - */ - this.renderType = GetValue(config, 'type', CONST.AUTO); - /** * @const {?*} Phaser.Boot.Config#parent - [description] */ this.parent = GetValue(config, 'parent', null); + /** + * @const {integer} Phaser.Boot.Config#scaleMode - [description] + */ + this.scaleMode = GetValue(config, 'scaleMode', 0); + + /** + * @const {boolean} Phaser.Boot.Config#expandParent - [description] + */ + this.expandParent = GetValue(config, 'expandParent', false); + + /** + * @const {integer} Phaser.Boot.Config#minWidth - [description] + */ + this.minWidth = GetValue(config, 'minWidth', 0); + + /** + * @const {integer} Phaser.Boot.Config#maxWidth - [description] + */ + this.maxWidth = GetValue(config, 'maxWidth', 0); + + /** + * @const {integer} Phaser.Boot.Config#minHeight - [description] + */ + this.minHeight = GetValue(config, 'minHeight', 0); + + /** + * @const {integer} Phaser.Boot.Config#maxHeight - [description] + */ + this.maxHeight = GetValue(config, 'maxHeight', 0); + + // Scale Manager - Anything set in here over-rides anything set above + + var scaleConfig = GetValue(config, 'scale', null); + + if (scaleConfig) + { + this.width = GetValue(scaleConfig, 'width', this.width); + this.height = GetValue(scaleConfig, 'height', this.height); + this.zoom = GetValue(scaleConfig, 'zoom', this.zoom); + this.resolution = GetValue(scaleConfig, 'resolution', this.resolution); + this.parent = GetValue(scaleConfig, 'parent', this.parent); + this.scaleMode = GetValue(scaleConfig, 'mode', this.scaleMode); + this.expandParent = GetValue(scaleConfig, 'mode', this.expandParent); + this.minWidth = GetValue(scaleConfig, 'min.width', this.minWidth); + this.maxWidth = GetValue(scaleConfig, 'max.width', this.maxWidth); + this.minHeight = GetValue(scaleConfig, 'min.height', this.minHeight); + this.maxHeight = GetValue(scaleConfig, 'max.height', this.maxHeight); + } + + /** + * @const {number} Phaser.Boot.Config#renderType - Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) + */ + this.renderType = GetValue(config, 'type', CONST.AUTO); + /** * @const {?HTMLCanvasElement} Phaser.Boot.Config#canvas - Force Phaser to use your own Canvas element instead of creating one. */ @@ -104762,17 +138697,17 @@ var Config = new Class({ MATH.RND.init(this.seed); /** - * @const {string} Phaser.Boot.Config#gameTitle - [description] + * @const {string} Phaser.Boot.Config#gameTitle - The title of the game. */ this.gameTitle = GetValue(config, 'title', ''); /** - * @const {string} Phaser.Boot.Config#gameURL - [description] + * @const {string} Phaser.Boot.Config#gameURL - The URL of the game. */ this.gameURL = GetValue(config, 'url', 'https://phaser.io'); /** - * @const {string} Phaser.Boot.Config#gameVersion - [description] + * @const {string} Phaser.Boot.Config#gameVersion - The version of the game. */ this.gameVersion = GetValue(config, 'version', ''); @@ -104781,6 +138716,18 @@ var Config = new Class({ */ this.autoFocus = GetValue(config, 'autoFocus', true); + // DOM Element Container + + /** + * @const {?boolean} Phaser.Boot.Config#domCreateContainer - [description] + */ + this.domCreateContainer = GetValue(config, 'dom.createContainer', false); + + /** + * @const {?boolean} Phaser.Boot.Config#domBehindCanvas - [description] + */ + this.domBehindCanvas = GetValue(config, 'dom.behindCanvas', false); + // Input /** @@ -104811,7 +138758,7 @@ var Config = new Class({ /** * @const {boolean} Phaser.Boot.Config#inputTouch - [description] */ - this.inputTouch = GetValue(config, 'input.touch', true); + this.inputTouch = GetValue(config, 'input.touch', Device.input.touch); /** * @const {?*} Phaser.Boot.Config#inputTouchEventTarget - [description] @@ -104839,7 +138786,7 @@ var Config = new Class({ this.inputGamepadEventTarget = GetValue(config, 'input.gamepad.target', window); /** - * @const {boolean} Phaser.Boot.Config#disableContextMenu - [description] + * @const {boolean} Phaser.Boot.Config#disableContextMenu - Set to `true` to disable context menu. Default value is `false`. */ this.disableContextMenu = GetValue(config, 'disableContextMenu', false); @@ -104893,33 +138840,39 @@ var Config = new Class({ var renderConfig = GetValue(config, 'render', config); + /** + * @const {boolean} Phaser.Boot.Config#autoResize - Automatically resize the Game Canvas if you resize the renderer. + */ + this.autoResize = GetValue(renderConfig, 'autoResize', true); + /** * @const {boolean} Phaser.Boot.Config#antialias - [description] */ this.antialias = GetValue(renderConfig, 'antialias', true); - /** - * @const {boolean} Phaser.Boot.Config#pixelArt - [description] - */ - this.pixelArt = GetValue(renderConfig, 'pixelArt', false); - - /** - * @const {boolean} Phaser.Boot.Config#autoResize - [description] - */ - this.autoResize = GetValue(renderConfig, 'autoResize', false); - /** * @const {boolean} Phaser.Boot.Config#roundPixels - [description] */ this.roundPixels = GetValue(renderConfig, 'roundPixels', false); + /** + * @const {boolean} Phaser.Boot.Config#pixelArt - Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode). + */ + this.pixelArt = GetValue(renderConfig, 'pixelArt', false); + + if (this.pixelArt) + { + this.antialias = false; + this.roundPixels = true; + } + /** * @const {boolean} Phaser.Boot.Config#transparent - [description] */ this.transparent = GetValue(renderConfig, 'transparent', false); /** - * @const {boolean} Phaser.Boot.Config#zoclearBeforeRenderom - [description] + * @const {boolean} Phaser.Boot.Config#clearBeforeRender - [description] */ this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true); @@ -104943,6 +138896,16 @@ var Config = new Class({ */ this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default'); + /** + * @const {integer} Phaser.Boot.Config#batchSize - The default WebGL Batch size. + */ + this.batchSize = GetValue(renderConfig, 'batchSize', 2000); + + /** + * @const {integer} Phaser.Boot.Config#maxLights - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + this.maxLights = GetValue(renderConfig, 'maxLights', 10); + var bgc = GetValue(config, 'backgroundColor', 0); /** @@ -104998,7 +138961,7 @@ var Config = new Class({ this.loaderPath = GetValue(config, 'loader.path', ''); /** - * @const {integer} Phaser.Boot.Config#loaderMaxParallelDownloads - [description] + * @const {integer} Phaser.Boot.Config#loaderMaxParallelDownloads - Maximum parallel downloads allowed for resources (Default to 32). */ this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 32); @@ -105040,15 +139003,15 @@ var Config = new Class({ * * plugins: { * global: [ - * { key: 'TestPlugin', plugin: TestPlugin, start: true }, + * { key: 'TestPlugin', plugin: TestPlugin, start: true, data: { msg: 'The plugin is alive' } }, * ], * scene: [ * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } * ], * default: [], OR - * defaultMerge: { + * defaultMerge: [ * 'ModPlayer' - * } + * ] * } */ @@ -105100,11 +139063,23 @@ var Config = new Class({ * @const {string} Phaser.Boot.Config#defaultImage - [description] */ this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); - + /** * @const {string} Phaser.Boot.Config#missingImage - [description] */ this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); + + if (window) + { + if (window.FORCE_WEBGL) + { + this.renderType = CONST.WEBGL; + } + else if (window.FORCE_CANVAS) + { + this.renderType = CONST.CANVAS; + } + } } }); @@ -105113,7 +139088,7 @@ module.exports = Config; /***/ }), -/* 534 */ +/* 904 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105122,25 +139097,32 @@ module.exports = Config; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AddToDOM = __webpack_require__(130); -var AnimationManager = __webpack_require__(207); -var CacheManager = __webpack_require__(205); -var CanvasPool = __webpack_require__(22); +var AddToDOM = __webpack_require__(169); +var AnimationManager = __webpack_require__(381); +var CacheManager = __webpack_require__(379); +var CanvasPool = __webpack_require__(24); var Class = __webpack_require__(0); -var Config = __webpack_require__(533); -var CreateRenderer = __webpack_require__(532); -var DataManager = __webpack_require__(81); -var DebugHeader = __webpack_require__(524); -var Device = __webpack_require__(523); -var DOMContentLoaded = __webpack_require__(271); -var EventEmitter = __webpack_require__(9); -var InputManager = __webpack_require__(201); -var PluginManager = __webpack_require__(196); -var SceneManager = __webpack_require__(194); -var SoundManagerCreator = __webpack_require__(191); -var TextureManager = __webpack_require__(184); -var TimeStep = __webpack_require__(506); -var VisibilityHandler = __webpack_require__(505); +var Config = __webpack_require__(903); +var CreateRenderer = __webpack_require__(898); +var DataManager = __webpack_require__(123); +var DebugHeader = __webpack_require__(891); +var Device = __webpack_require__(340); +var DOMContentLoaded = __webpack_require__(344); +var EventEmitter = __webpack_require__(11); +var InputManager = __webpack_require__(338); +var PluginCache = __webpack_require__(15); +var PluginManager = __webpack_require__(331); +var SceneManager = __webpack_require__(329); +var SoundManagerCreator = __webpack_require__(325); +var TextureManager = __webpack_require__(318); +var TimeStep = __webpack_require__(878); +var VisibilityHandler = __webpack_require__(877); + +if (false) +{ var CreateDOMContainer; } + +if (false) +{ var FacebookInstantGamesPlugin; } /** * @classdesc @@ -105153,7 +139135,7 @@ var VisibilityHandler = __webpack_require__(505); * made available to you via the Phaser.Scene Systems class instead. * * @class Game - * @memberOf Phaser + * @memberof Phaser * @constructor * @since 3.0.0 * @@ -105172,7 +139154,7 @@ var Game = new Class({ * * @name Phaser.Game#config * @type {Phaser.Boot.Config} - * @readOnly + * @readonly * @since 3.0.0 */ this.config = new Config(config); @@ -105186,6 +139168,9 @@ var Game = new Class({ */ this.renderer = null; + if (false) + {} + /** * A reference to the HTML Canvas Element that Phaser uses to render the game. * This is created automatically by Phaser unless you provide a `canvas` property @@ -105215,7 +139200,7 @@ var Game = new Class({ * * @name Phaser.Game#isBooted * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ this.isBooted = false; @@ -105225,7 +139210,7 @@ var Game = new Class({ * * @name Phaser.Game#isRunning * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ this.isRunning = false; @@ -105350,6 +139335,9 @@ var Game = new Class({ */ this.plugins = new PluginManager(this, this.config); + if (false) + {} + /** * Is this Game pending destruction at the start of the next frame? * @@ -105370,13 +139358,24 @@ var Game = new Class({ */ this.removeCanvas = false; + /** + * Remove everything when the game is destroyed. + * You cannot create a new Phaser instance on the same web page after doing this. + * + * @name Phaser.Game#noReturn + * @type {boolean} + * @private + * @since 3.12.0 + */ + this.noReturn = false; + /** * Does the window the game is running in currently have focus or not? * This is modified by the VisibilityHandler. * * @name Phaser.Game#hasFocus * @type {boolean} - * @readOnly + * @readonly * @since 3.9.0 */ this.hasFocus = false; @@ -105387,7 +139386,7 @@ var Game = new Class({ * * @name Phaser.Game#isOver * @type {boolean} - * @readOnly + * @readonly * @since 3.10.0 */ this.isOver = true; @@ -105417,20 +139416,47 @@ var Game = new Class({ */ boot: function () { + if (!PluginCache.hasCore('EventEmitter')) + { + console.warn('Aborting. Core Plugins missing.'); + return; + } + this.isBooted = true; this.config.preBoot(this); CreateRenderer(this); + if (false) + {} + DebugHeader(this); AddToDOM(this.canvas, this.config.parent); this.events.emit('boot'); - // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event - this.events.once('ready', this.start, this); + // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready. + // So it will emit this internal event when done: + this.events.once('texturesready', this.texturesReady, this); + }, + + /** + * Called automatically when the Texture Manager has finished setting up and preparing the + * default textures. + * + * @method Phaser.Game#texturesReady + * @private + * @fires Phaser.Game#ready + * @since 3.12.0 + */ + texturesReady: function () + { + // Start all the other systems + this.events.emit('ready'); + + this.start(); }, /** @@ -105469,40 +139495,48 @@ var Game = new Class({ /** * Game Pre-Step event. + * + * Listen for it using the event type `prestep`. * * This event is dispatched before the main Step starts. * By this point none of the Scene updates have happened. * Hook into it from plugins or systems that need to update before the Scene Manager does. * * @event Phaser.Game#prestepEvent - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ /** * Game Step event. + * + * Listen for it using the event type `step`. * * This event is dispatched after Pre-Step and before the Scene Manager steps. * Hook into it from plugins or systems that need to update before the Scene Manager does, but after core Systems. * * @event Phaser.Game#stepEvent - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ /** * Game Post-Step event. + * + * Listen for it using the event type `poststep`. * * This event is dispatched after the Scene Manager has updated. * Hook into it from plugins or systems that need to do things before the render starts. * * @event Phaser.Game#poststepEvent - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ /** * Game Pre-Render event. + * + * Listen for it using the event type `prerender`. * * This event is dispatched immediately before any of the Scenes have started to render. * The renderer will already have been initialized this frame, clearing itself and preparing to receive @@ -105514,6 +139548,8 @@ var Game = new Class({ /** * Game Post-Render event. + * + * Listen for it using the event type `postrender`. * * This event is dispatched right at the end of the render process. * Every Scene will have rendered and drawn to the canvas. @@ -105538,8 +139574,8 @@ var Game = new Class({ * @fires Phaser.Game#postrenderEvent * @since 3.0.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. + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ step: function (time, delta) { @@ -105602,8 +139638,8 @@ var Game = new Class({ * @fires Phaser.Game#postrenderEvent * @since 3.2.0 * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ headlessStep: function (time, delta) { @@ -105630,6 +139666,8 @@ var Game = new Class({ /** * Game Pause event. + * + * Listen for it using the event type `pause`. * * This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler. * @@ -105654,6 +139692,8 @@ var Game = new Class({ /** * Game Resume event. + * + * Listen for it using the event type `resume`. * * This event is dispatched when the game loop leaves a paused state and resumes running. * @@ -105708,6 +139748,8 @@ var Game = new Class({ /** * Game Resize event. + * + * Listen for it using the event type `resize`. * * @event Phaser.Game#resizeEvent * @param {number} width - The new width of the Game. @@ -105719,6 +139761,7 @@ var Game = new Class({ * Then resizes the Renderer and Input Manager scale. * * @method Phaser.Game#resize + * @fires Phaser.Game#resizeEvent * @since 3.2.0 * * @param {number} width - The new width of the game. @@ -105729,6 +139772,9 @@ var Game = new Class({ this.config.width = width; this.config.height = height; + if (false) + {} + this.renderer.resize(width, height); this.input.resize(); @@ -105738,20 +139784,36 @@ var Game = new Class({ this.events.emit('resize', width, height); }, + /** + * Game Destroy event. + * + * Listen for it using the event type `destroy`. + * + * @event Phaser.Game#destroyEvent + */ + /** * Flags this Game instance as needing to be destroyed on the next frame. * It will wait until the current frame has completed and then call `runDestroy` internally. + * + * If you **do not** need to run Phaser again on the same web page you can set the `noReturn` argument to `true` and it will free-up + * memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as `false`. * * @method Phaser.Game#destroy + * @fires Phaser.Game#destroyEvent * @since 3.0.0 * * @param {boolean} removeCanvas - Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. + * @param {boolean} [noReturn=false] - If `true` all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this. */ - destroy: function (removeCanvas) + destroy: function (removeCanvas, noReturn) { + if (noReturn === undefined) { noReturn = false; } + this.pendingDestroy = true; this.removeCanvas = removeCanvas; + this.noReturn = noReturn; }, /** @@ -105784,8 +139846,11 @@ var Game = new Class({ } } - this.loop.destroy(); + if (false) + {} + this.loop.destroy(); + this.pendingDestroy = false; } @@ -105795,7 +139860,7 @@ module.exports = Game; /***/ }), -/* 535 */ +/* 905 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105805,15 +139870,15 @@ module.exports = Game; */ var Class = __webpack_require__(0); -var EE = __webpack_require__(9); -var PluginCache = __webpack_require__(12); +var EE = __webpack_require__(11); +var PluginCache = __webpack_require__(15); /** * @classdesc * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. * * @class EventEmitter - * @memberOf Phaser.Events + * @memberof Phaser.Events * @constructor * @since 3.0.0 */ @@ -105979,7 +140044,7 @@ module.exports = EventEmitter; /***/ }), -/* 536 */ +/* 906 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105992,11 +140057,11 @@ module.exports = EventEmitter; * @namespace Phaser.Events */ -module.exports = { EventEmitter: __webpack_require__(535) }; +module.exports = { EventEmitter: __webpack_require__(905) }; /***/ }), -/* 537 */ +/* 907 */ /***/ (function(module, exports) { // shim for using process in browser @@ -106186,7 +140251,34 @@ process.umask = function() { return 0; }; /***/ }), -/* 538 */ +/* 908 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.DOM + */ + +var Dom = { + + AddToDOM: __webpack_require__(169), + DOMContentLoaded: __webpack_require__(344), + ParseXML: __webpack_require__(343), + RemoveFromDOM: __webpack_require__(342), + RequestAnimationFrame: __webpack_require__(341) + +}; + +module.exports = Dom; + + +/***/ }), +/* 909 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -106201,14 +140293,14 @@ process.umask = function() { return 0; }; module.exports = { - BitmapMask: __webpack_require__(214), - GeometryMask: __webpack_require__(213) + BitmapMask: __webpack_require__(394), + GeometryMask: __webpack_require__(393) }; /***/ }), -/* 539 */ +/* 910 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -106217,82 +140309,312 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetColor = __webpack_require__(152); +var ComponentToHex = __webpack_require__(346); /** - * Converts an HSV (hue, saturation and value) color value to RGB. - * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes HSV values are contained in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) + * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. * - * @function Phaser.Display.Color.HSVToRGB + * @function Phaser.Display.Color.RGBToString * @since 3.0.0 * - * @param {number} h - The hue, in the range 0 - 1. - * @param {number} s - The saturation, in the range 0 - 1. - * @param {number} v - The value, in the range 0 - 1. + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * @param {integer} [a=255] - The alpha value. A number between 0 and 255. + * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + * @return {string} A string-based representation of the color values. */ -var HSVToRGB = function (h, s, v) +var RGBToString = function (r, g, b, a, prefix) +{ + if (a === undefined) { a = 255; } + if (prefix === undefined) { prefix = '#'; } + + if (prefix === '#') + { + return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); + } + else + { + return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); + } +}; + +module.exports = RGBToString; + + +/***/ }), +/* 911 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Between = __webpack_require__(170); +var Color = __webpack_require__(37); + +/** + * Creates a new Color object where the r, g, and b values have been set to random values + * based on the given min max values. + * + * @function Phaser.Display.Color.RandomRGB + * @since 3.0.0 + * + * @param {integer} [min=0] - The minimum value to set the random range from (between 0 and 255) + * @param {integer} [max=255] - The maximum value to set the random range from (between 0 and 255) + * + * @return {Phaser.Display.Color} A Color object. + */ +var RandomRGB = function (min, max) +{ + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + return new Color(Between(min, max), Between(min, max), Between(min, max)); +}; + +module.exports = RandomRGB; + + +/***/ }), +/* 912 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Linear = __webpack_require__(119); + +/** + * Interpolates color values + * + * @namespace Phaser.Display.Color.Interpolate + * @since 3.0.0 + */ + +/** + * Interpolates between the two given color ranges over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.RGBWithRGB + * @since 3.0.0 + * + * @param {number} r1 - Red value. + * @param {number} g1 - Blue value. + * @param {number} b1 - Green value. + * @param {number} r2 - Red value. + * @param {number} g2 - Blue value. + * @param {number} b2 - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + var t = index / length; + + return { + r: Linear(r1, r2, t), + g: Linear(g1, g2, t), + b: Linear(b1, b2, t) + }; +}; + +/** + * Interpolates between the two given color objects over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithColor + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {Phaser.Display.Color} color2 - The second Color object. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithColor = function (color1, color2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); +}; + +/** + * Interpolates between the Color object and color values over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithRGB + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {number} r - Red value. + * @param {number} g - Blue value. + * @param {number} b - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithRGB = function (color, r, g, b, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); +}; + +module.exports = { + + RGBWithRGB: RGBWithRGB, + ColorWithRGB: ColorWithRGB, + ColorWithColor: ColorWithColor + +}; + + +/***/ }), +/* 913 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HSVToRGB = __webpack_require__(176); + +/** + * Get HSV color wheel values in an array which will be 360 elements in size. + * + * @function Phaser.Display.Color.HSVColorWheel + * @since 3.0.0 + * + * @param {number} [s=1] - The saturation, in the range 0 - 1. + * @param {number} [v=1] - The value, in the range 0 - 1. + * + * @return {ColorObject[]} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel. + */ +var HSVColorWheel = function (s, v) { if (s === undefined) { s = 1; } if (v === undefined) { v = 1; } - var i = Math.floor(h * 6); - var f = h * 6 - i; + var colors = []; - var p = Math.floor((v * (1 - s)) * 255); - var q = Math.floor((v * (1 - f * s)) * 255); - var t = Math.floor((v * (1 - (1 - f) * s)) * 255); - - v = Math.floor(v *= 255); - - var output = { r: v, g: v, b: v, color: 0 }; - - var r = i % 6; - - if (r === 0) + for (var c = 0; c <= 359; c++) { - output.g = t; - output.b = p; - } - else if (r === 1) - { - output.r = q; - output.b = p; - } - else if (r === 2) - { - output.r = p; - output.b = t; - } - else if (r === 3) - { - output.r = p; - output.g = q; - } - else if (r === 4) - { - output.r = t; - output.g = p; - } - else if (r === 5) - { - output.g = p; - output.b = q; + colors.push(HSVToRGB(c / 359, s, v)); } - output.color = GetColor(output.r, output.g, output.b); + return colors; +}; + +module.exports = HSVColorWheel; + + +/***/ }), +/* 914 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(37); +var HueToComponent = __webpack_require__(345); + +/** + * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. + * + * @function Phaser.Display.Color.HSLToColor + * @since 3.0.0 + * + * @param {number} h - The hue value in the range 0 to 1. + * @param {number} s - The saturation value in the range 0 to 1. + * @param {number} l - The lightness value in the range 0 to 1. + * + * @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values. + */ +var HSLToColor = function (h, s, l) +{ + // achromatic by default + var r = l; + var g = l; + var b = l; + + if (s !== 0) + { + var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + + r = HueToComponent(p, q, h + 1 / 3); + g = HueToComponent(p, q, h); + b = HueToComponent(p, q, h - 1 / 3); + } + + var color = new Color(); + + return color.setGLTo(r, g, b, 1); +}; + +module.exports = HSLToColor; + + +/***/ }), +/* 915 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts the given color value into an Object containing r,g,b and a properties. + * + * @function Phaser.Display.Color.ColorToRGBA + * @since 3.0.0 + * + * @param {number} color - A color value, optionally including the alpha value. + * + * @return {ColorObject} An object containing the parsed color values. + */ +var ColorToRGBA = function (color) +{ + var output = { + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF, + a: 255 + }; + + if (color > 16777215) + { + output.a = color >>> 24; + } return output; }; -module.exports = HSVToRGB; +module.exports = ColorToRGBA; /***/ }), -/* 540 */ +/* 916 */ /***/ (function(module, exports) { /** @@ -106302,53 +140624,44 @@ module.exports = HSVToRGB; */ /** - * Converts a hue to an RGB color. - * Based on code by Michael Jackson (https://github.com/mjijackson) + * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. * - * @function Phaser.Display.Color.HueToComponent + * @function Phaser.Display.Canvas.UserSelect * @since 3.0.0 * - * @param {number} p - * @param {number} q - * @param {number} t + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts. * - * @return {number} The combined color value. + * @return {HTMLCanvasElement} The canvas element. */ -var HueToComponent = function (p, q, t) +var UserSelect = function (canvas, value) { - if (t < 0) - { - t += 1; - } + if (value === undefined) { value = 'none'; } - if (t > 1) - { - t -= 1; - } + var vendors = [ + '-webkit-', + '-khtml-', + '-moz-', + '-ms-', + '' + ]; - if (t < 1 / 6) + vendors.forEach(function (vendor) { - return p + (q - p) * 6 * t; - } + canvas.style[vendor + 'user-select'] = value; + }); - if (t < 1 / 2) - { - return q; - } + canvas.style['-webkit-touch-callout'] = value; + canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; - if (t < 2 / 3) - { - return p + (q - p) * (2 / 3 - t) * 6; - } - - return p; + return canvas; }; -module.exports = HueToComponent; +module.exports = UserSelect; /***/ }), -/* 541 */ +/* 917 */ /***/ (function(module, exports) { /** @@ -106358,27 +140671,32 @@ module.exports = HueToComponent; */ /** - * Returns a string containing a hex representation of the given color component. + * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. * - * @function Phaser.Display.Color.ComponentToHex + * @function Phaser.Display.Canvas.TouchAction * @since 3.0.0 * - * @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255. + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. * - * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. + * @return {HTMLCanvasElement} The canvas element. */ -var ComponentToHex = function (color) +var TouchAction = function (canvas, value) { - var hex = color.toString(16); + if (value === undefined) { value = 'none'; } - return (hex.length === 1) ? '0' + hex : hex; + canvas.style['msTouchAction'] = value; + canvas.style['ms-touch-action'] = value; + canvas.style['touch-action'] = value; + + return canvas; }; -module.exports = ComponentToHex; +module.exports = TouchAction; /***/ }), -/* 542 */ +/* 918 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -106388,48 +140706,762 @@ module.exports = ComponentToHex; */ /** - * @typedef {object} InputColorObject - * - * @property {number} [r] - The red color value in the range 0 to 255. - * @property {number} [g] - The green color value in the range 0 to 255. - * @property {number} [b] - The blue color value in the range 0 to 255. - * @property {number} [a] - The alpha color value in the range 0 to 255. + * @namespace Phaser.Display.Canvas */ -/** - * @typedef {Object} ColorObject - * @property {number} r - The red color value in the range 0 to 255. - * @property {number} g - The green color value in the range 0 to 255. - * @property {number} b - The blue color value in the range 0 to 255. - * @property {number} a - The alpha color value in the range 0 to 255. - */ +module.exports = { -var Color = __webpack_require__(30); - -Color.ColorToRGBA = __webpack_require__(923); -Color.ComponentToHex = __webpack_require__(541); -Color.GetColor = __webpack_require__(152); -Color.GetColor32 = __webpack_require__(284); -Color.HexStringToColor = __webpack_require__(285); -Color.HSLToColor = __webpack_require__(922); -Color.HSVColorWheel = __webpack_require__(921); -Color.HSVToRGB = __webpack_require__(539); -Color.HueToComponent = __webpack_require__(540); -Color.IntegerToColor = __webpack_require__(283); -Color.IntegerToRGB = __webpack_require__(282); -Color.Interpolate = __webpack_require__(920); -Color.ObjectToColor = __webpack_require__(281); -Color.RandomRGB = __webpack_require__(919); -Color.RGBStringToColor = __webpack_require__(280); -Color.RGBToHSV = __webpack_require__(918); -Color.RGBToString = __webpack_require__(917); -Color.ValueToColor = __webpack_require__(132); - -module.exports = Color; + CanvasInterpolation: __webpack_require__(348), + CanvasPool: __webpack_require__(24), + Smoothing: __webpack_require__(120), + TouchAction: __webpack_require__(917), + UserSelect: __webpack_require__(916) + +}; /***/ }), -/* 543 */ +/* 919 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its y coordinate. + * This is the same as `width * origin.y`. + * This value will only be > 0 if `origin.y` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The vertical offset of the Game Object. + */ +var GetOffsetY = function (gameObject) +{ + return gameObject.height * gameObject.originY; +}; + +module.exports = GetOffsetY; + + +/***/ }), +/* 920 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * origin.x`. + * This value will only be > 0 if `origin.x` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The horizontal offset of the Game Object. + */ +var GetOffsetX = function (gameObject) +{ + return gameObject.width * gameObject.originX; +}; + +module.exports = GetOffsetX; + + +/***/ }), +/* 921 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Bounds + */ + +module.exports = { + + CenterOn: __webpack_require__(411), + GetBottom: __webpack_require__(48), + GetCenterX: __webpack_require__(75), + GetCenterY: __webpack_require__(72), + GetLeft: __webpack_require__(46), + GetOffsetX: __webpack_require__(920), + GetOffsetY: __webpack_require__(919), + GetRight: __webpack_require__(44), + GetTop: __webpack_require__(42), + SetBottom: __webpack_require__(47), + SetCenterX: __webpack_require__(74), + SetCenterY: __webpack_require__(73), + SetLeft: __webpack_require__(45), + SetRight: __webpack_require__(43), + SetTop: __webpack_require__(41) + +}; + + +/***/ }), +/* 922 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(44); +var GetTop = __webpack_require__(42); +var SetBottom = __webpack_require__(47); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. + * + * @function Phaser.Display.Align.To.TopRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }), +/* 923 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(46); +var GetTop = __webpack_require__(42); +var SetBottom = __webpack_require__(47); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. + * + * @function Phaser.Display.Align.To.TopLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }), +/* 924 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterX = __webpack_require__(75); +var GetTop = __webpack_require__(42); +var SetBottom = __webpack_require__(47); +var SetCenterX = __webpack_require__(74); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. + * + * @function Phaser.Display.Align.To.TopCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }), +/* 925 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(44); +var GetTop = __webpack_require__(42); +var SetLeft = __webpack_require__(45); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. + * + * @function Phaser.Display.Align.To.RightTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = RightTop; + + +/***/ }), +/* 926 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(72); +var GetRight = __webpack_require__(44); +var SetCenterY = __webpack_require__(73); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. + * + * @function Phaser.Display.Align.To.RightCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }), +/* 927 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetRight = __webpack_require__(44); +var SetBottom = __webpack_require__(47); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. + * + * @function Phaser.Display.Align.To.RightBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightBottom; + + +/***/ }), +/* 928 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(46); +var GetTop = __webpack_require__(42); +var SetRight = __webpack_require__(43); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. + * + * @function Phaser.Display.Align.To.LeftTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = LeftTop; + + +/***/ }), +/* 929 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(72); +var GetLeft = __webpack_require__(46); +var SetCenterY = __webpack_require__(73); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. + * + * @function Phaser.Display.Align.To.LeftCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }), +/* 930 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetLeft = __webpack_require__(46); +var SetBottom = __webpack_require__(47); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. + * + * @function Phaser.Display.Align.To.LeftBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftBottom; + + +/***/ }), +/* 931 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetRight = __webpack_require__(44); +var SetRight = __webpack_require__(43); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. + * + * @function Phaser.Display.Align.To.BottomRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }), +/* 932 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetLeft = __webpack_require__(46); +var SetLeft = __webpack_require__(45); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. + * + * @function Phaser.Display.Align.To.BottomLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }), +/* 933 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetCenterX = __webpack_require__(75); +var SetCenterX = __webpack_require__(74); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. + * + * @function Phaser.Display.Align.To.BottomCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }), +/* 934 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.To + */ + +module.exports = { + + BottomCenter: __webpack_require__(933), + BottomLeft: __webpack_require__(932), + BottomRight: __webpack_require__(931), + LeftBottom: __webpack_require__(930), + LeftCenter: __webpack_require__(929), + LeftTop: __webpack_require__(928), + RightBottom: __webpack_require__(927), + RightCenter: __webpack_require__(926), + RightTop: __webpack_require__(925), + TopCenter: __webpack_require__(924), + TopLeft: __webpack_require__(923), + TopRight: __webpack_require__(922) + +}; + + +/***/ }), +/* 935 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.In + */ + +module.exports = { + + BottomCenter: __webpack_require__(415), + BottomLeft: __webpack_require__(414), + BottomRight: __webpack_require__(413), + Center: __webpack_require__(412), + LeftCenter: __webpack_require__(410), + QuickSet: __webpack_require__(416), + RightCenter: __webpack_require__(409), + TopCenter: __webpack_require__(408), + TopLeft: __webpack_require__(407), + TopRight: __webpack_require__(406) + +}; + + +/***/ }), +/* 936 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(193); +var Extend = __webpack_require__(20); + +/** + * @namespace Phaser.Display.Align + */ + +var Align = { + + In: __webpack_require__(935), + To: __webpack_require__(934) + +}; + +// Merge in the consts +Align = Extend(false, Align, CONST); + +module.exports = Align; + + +/***/ }), +/* 937 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display + */ + +module.exports = { + + Align: __webpack_require__(936), + Bounds: __webpack_require__(921), + Canvas: __webpack_require__(918), + Color: __webpack_require__(347), + Masks: __webpack_require__(909) + +}; + + +/***/ }), +/* 938 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -106439,8 +141471,8 @@ module.exports = Color; */ var Class = __webpack_require__(0); -var DataManager = __webpack_require__(81); -var PluginCache = __webpack_require__(12); +var DataManager = __webpack_require__(123); +var PluginCache = __webpack_require__(15); /** * @classdesc @@ -106450,7 +141482,7 @@ var PluginCache = __webpack_require__(12); * * @class DataManagerPlugin * @extends Phaser.Data.DataManager - * @memberOf Phaser.Data + * @memberof Phaser.Data * @constructor * @since 3.0.0 * @@ -106555,7 +141587,7 @@ module.exports = DataManagerPlugin; /***/ }), -/* 544 */ +/* 939 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -106570,28904 +141602,16 @@ module.exports = DataManagerPlugin; module.exports = { - DataManager: __webpack_require__(81), - DataManagerPlugin: __webpack_require__(543) + DataManager: __webpack_require__(123), + DataManagerPlugin: __webpack_require__(938) }; -/***/ }), -/* 545 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var CatmullRom = __webpack_require__(273); -var Class = __webpack_require__(0); -var Curve = __webpack_require__(86); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class Spline - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2[]} [points] - [description] - */ -var SplineCurve = new Class({ - - Extends: Curve, - - initialize: - - function SplineCurve (points) - { - if (points === undefined) { points = []; } - - Curve.call(this, 'SplineCurve'); - - /** - * [description] - * - * @name Phaser.Curves.Spline#points - * @type {Phaser.Math.Vector2[]} - * @default [] - * @since 3.0.0 - */ - this.points = []; - - this.addPoints(points); - }, - - /** - * [description] - * - * @method Phaser.Curves.Spline#addPoints - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - [description] - * - * @return {Phaser.Curves.Spline} This curve object. - */ - addPoints: function (points) - { - for (var i = 0; i < points.length; i++) - { - var p = new Vector2(); - - if (typeof points[i] === 'number') - { - p.x = points[i]; - p.y = points[i + 1]; - i++; - } - else if (Array.isArray(points[i])) - { - // An array of arrays? - p.x = points[i][0]; - p.y = points[i][1]; - } - else - { - p.x = points[i].x; - p.y = points[i].y; - } - - this.points.push(p); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.Spline#addPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - addPoint: function (x, y) - { - var vec = new Vector2(x, y); - - this.points.push(vec); - - return vec; - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.Spline#getStartPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.points[0]); - }, - - /** - * [description] - * - * @method Phaser.Curves.Spline#getResolution - * @since 3.0.0 - * - * @param {number} divisions - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - return divisions * this.points.length; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.Spline#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var points = this.points; - - var point = (points.length - 1) * t; - - var intPoint = Math.floor(point); - - var weight = point - intPoint; - - var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; - var p1 = points[intPoint]; - var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; - var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; - - return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.Spline#toJSON - * @since 3.0.0 - * - * @return {JSONCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - var points = []; - - for (var i = 0; i < this.points.length; i++) - { - points.push(this.points[i].x); - points.push(this.points[i].y); - } - - return { - type: this.type, - points: points - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.Spline.fromJSON - * @since 3.0.0 - * - * @param {JSONCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.Spline} [description] - */ -SplineCurve.fromJSON = function (data) -{ - return new SplineCurve(data.points); -}; - -module.exports = SplineCurve; - - -/***/ }), -/* 546 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function P0 (t, p) -{ - var k = 1 - t; - - return k * k * p; -} - -function P1 (t, p) -{ - return 2 * (1 - t) * t * p; -} - -function P2 (t, p) -{ - return t * t * p; -} - -// p0 = start point -// p1 = control point 1 -// p2 = end point - -// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js - -/** - * A quadratic bezier interpolation method. - * - * @function Phaser.Math.Interpolation.QuadraticBezier - * @since 3.2.0 - * - * @param {float} t - The percentage of interpolation, between 0 and 1. - * @param {number} p0 - The start point. - * @param {number} p1 - The control point. - * @param {number} p2 - The end point. - * - * @return {number} The interpolated value. - */ -var QuadraticBezierInterpolation = function (t, p0, p1, p2) -{ - return P0(t, p0) + P1(t, p1) + P2(t, p2); -}; - -module.exports = QuadraticBezierInterpolation; - - -/***/ }), -/* 547 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(86); -var QuadraticBezierInterpolation = __webpack_require__(546); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class QuadraticBezier - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.2.0 - * - * @param {(Phaser.Math.Vector2|number[])} p0 - Start point, or an array of point pairs. - * @param {Phaser.Math.Vector2} p1 - Control Point 1. - * @param {Phaser.Math.Vector2} p2 - Control Point 2. - */ -var QuadraticBezier = new Class({ - - Extends: Curve, - - initialize: - - function QuadraticBezier (p0, p1, p2) - { - Curve.call(this, 'QuadraticBezier'); - - if (Array.isArray(p0)) - { - p2 = new Vector2(p0[4], p0[5]); - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p0 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p1 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p1 = p1; - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p2 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p2 = p2; - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.QuadraticBezier#getStartPoint - * @since 3.2.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#getResolution - * @since 3.2.0 - * - * @param {number} divisions - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - return divisions; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.QuadraticBezier#getPoint - * @since 3.2.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var p0 = this.p0; - var p1 = this.p1; - var p2 = this.p2; - - return out.set( - QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), - QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) - ); - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#draw - * @since 3.2.0 - * - * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - if (pointsTotal === undefined) { pointsTotal = 32; } - - var points = this.getPoints(pointsTotal); - - graphics.beginPath(); - graphics.moveTo(this.p0.x, this.p0.y); - - for (var i = 1; i < points.length; i++) - { - graphics.lineTo(points[i].x, points[i].y); - } - - graphics.strokePath(); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#toJSON - * @since 3.2.0 - * - * @return {JSONCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y, - this.p2.x, this.p2.y - ] - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.QuadraticBezier.fromJSON - * @since 3.2.0 - * - * @param {JSONCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.QuadraticBezier} [description] - */ -QuadraticBezier.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - var p2 = new Vector2(points[4], points[5]); - - return new QuadraticBezier(p0, p1, p2); -}; - -module.exports = QuadraticBezier; - - -/***/ }), -/* 548 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(86); -var FromPoints = __webpack_require__(274); -var Rectangle = __webpack_require__(14); -var Vector2 = __webpack_require__(6); - -var tmpVec2 = new Vector2(); - -/** - * @classdesc - * [description] - * - * @class Line - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|number[])} p0 - [description] - * @param {Phaser.Math.Vector2} [p1] - [description] - */ -var LineCurve = new Class({ - - Extends: Curve, - - initialize: - - // vec2s or array - function LineCurve (p0, p1) - { - Curve.call(this, 'LineCurve'); - - if (Array.isArray(p0)) - { - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } - - /** - * [description] - * - * @name Phaser.Curves.Line#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.Line#p1 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p1 = p1; - }, - - /** - * Returns a Rectangle where the position and dimensions match the bounds of this Curve. - * - * @method Phaser.Curves.Line#getBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the bounds in. If not given a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. - */ - getBounds: function (out) - { - if (out === undefined) { out = new Rectangle(); } - - return FromPoints([ this.p0, this.p1 ], out); - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.Line#getStartPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.Line#getResolution - * @since 3.0.0 - * - * @param {number} [divisions=1] - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - if (divisions === undefined) { divisions = 1; } - - return divisions; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.Line#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - if (t === 1) - { - return out.copy(this.p1); - } - - out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); - - return out; - }, - - // Line curve is linear, so we can overwrite default getPointAt - - /** - * [description] - * - * @method Phaser.Curves.Line#getPointAt - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} u - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPointAt: function (u, out) - { - return this.getPoint(u, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.Line#getTangent - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @return {Phaser.Math.Vector2} [description] - */ - getTangent: function () - { - var tangent = tmpVec2.copy(this.p1).subtract(this.p0); - - return tangent.normalize(); - }, - - // Override default Curve.draw because this is better than calling getPoints on a line! - - /** - * Draws this curve on the given Graphics object. - * - * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line color is. - * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. - * - * @method Phaser.Curves.Line#draw - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] - * - * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. - * - * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. - */ - draw: function (graphics) - { - graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.Line#toJSON - * @since 3.0.0 - * - * @return {JSONCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y - ] - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.Line.fromJSON - * @since 3.0.0 - * - * @param {JSONCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.Line} [description] - */ -LineCurve.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - - return new LineCurve(p0, p1); -}; - -module.exports = LineCurve; - - -/***/ }), -/* 549 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(86); -var DegToRad = __webpack_require__(38); -var GetValue = __webpack_require__(4); -var RadToDeg = __webpack_require__(150); -var Vector2 = __webpack_require__(6); - -/** - * @typedef {object} JSONEllipseCurve - * - * @property {string} type - The of the curve. - * @property {number} x - [description] - * @property {number} y - [description] - * @property {number} xRadius - The horizontal radius of ellipse. - * @property {number} yRadius - The vertical radius of ellipse. - * @property {integer} startAngle - The start angle of ellipse. - * @property {integer} endAngle - The end angle of ellipse. - * @property {boolean} clockwise - The clockwise of ellipse. - * @property {integer} rotation - The rotation of ellipse. - */ - -/** - * @typedef {object} EllipseCurveConfig - * - * @property {number} [x=0] - [description] - * @property {number} [y=0] - [description] - * @property {number} [xRadius=0] - [description] - * @property {number} [yRadius=0] - [description] - * @property {integer} [startAngle=0] - [description] - * @property {integer} [endAngle=360] - [description] - * @property {boolean} [clockwise=false] - [description] - * @property {integer} [rotation=0] - [description] - */ - -/** - * @classdesc - * [description] - * - * @class Ellipse - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {(number|EllipseCurveConfig)} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [xRadius=0] - [description] - * @param {number} [yRadius=0] - [description] - * @param {integer} [startAngle=0] - [description] - * @param {integer} [endAngle=360] - [description] - * @param {boolean} [clockwise=false] - [description] - * @param {integer} [rotation=0] - [description] - */ -var EllipseCurve = new Class({ - - Extends: Curve, - - initialize: - - function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) - { - if (typeof x === 'object') - { - var config = x; - - x = GetValue(config, 'x', 0); - y = GetValue(config, 'y', 0); - xRadius = GetValue(config, 'xRadius', 0); - yRadius = GetValue(config, 'yRadius', xRadius); - startAngle = GetValue(config, 'startAngle', 0); - endAngle = GetValue(config, 'endAngle', 360); - clockwise = GetValue(config, 'clockwise', false); - rotation = GetValue(config, 'rotation', 0); - } - else - { - if (yRadius === undefined) { yRadius = xRadius; } - if (startAngle === undefined) { startAngle = 0; } - if (endAngle === undefined) { endAngle = 360; } - if (clockwise === undefined) { clockwise = false; } - if (rotation === undefined) { rotation = 0; } - } - - Curve.call(this, 'EllipseCurve'); - - // Center point - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = new Vector2(x, y); - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#_xRadius - * @type {number} - * @private - * @since 3.0.0 - */ - this._xRadius = xRadius; - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#_yRadius - * @type {number} - * @private - * @since 3.0.0 - */ - this._yRadius = yRadius; - - // Radians - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#_startAngle - * @type {number} - * @private - * @since 3.0.0 - */ - this._startAngle = DegToRad(startAngle); - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#_endAngle - * @type {number} - * @private - * @since 3.0.0 - */ - this._endAngle = DegToRad(endAngle); - - /** - * Anti-clockwise direction. - * - * @name Phaser.Curves.Ellipse#_clockwise - * @type {boolean} - * @private - * @since 3.0.0 - */ - this._clockwise = clockwise; - - /** - * The rotation of the arc. - * - * @name Phaser.Curves.Ellipse#_rotation - * @type {number} - * @private - * @since 3.0.0 - */ - this._rotation = DegToRad(rotation); - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.Ellipse#getStartPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return this.getPoint(0, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.Ellipse#getResolution - * @since 3.0.0 - * - * @param {number} divisions - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - return divisions * 2; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.Ellipse#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var twoPi = Math.PI * 2; - var deltaAngle = this._endAngle - this._startAngle; - var samePoints = Math.abs(deltaAngle) < Number.EPSILON; - - // ensures that deltaAngle is 0 .. 2 PI - while (deltaAngle < 0) - { - deltaAngle += twoPi; - } - - while (deltaAngle > twoPi) - { - deltaAngle -= twoPi; - } - - if (deltaAngle < Number.EPSILON) - { - if (samePoints) - { - deltaAngle = 0; - } - else - { - deltaAngle = twoPi; - } - } - - if (this._clockwise && !samePoints) - { - if (deltaAngle === twoPi) - { - deltaAngle = - twoPi; - } - else - { - deltaAngle = deltaAngle - twoPi; - } - } - - var angle = this._startAngle + t * deltaAngle; - var x = this.p0.x + this._xRadius * Math.cos(angle); - var y = this.p0.y + this._yRadius * Math.sin(angle); - - if (this._rotation !== 0) - { - var cos = Math.cos(this._rotation); - var sin = Math.sin(this._rotation); - - var tx = x - this.p0.x; - var ty = y - this.p0.y; - - // Rotate the point about the center of the ellipse. - x = tx * cos - ty * sin + this.p0.x; - y = tx * sin + ty * cos + this.p0.y; - } - - return out.set(x, y); - }, - - /** - * Sets the horizontal radius of this curve. - * - * @method Phaser.Curves.Ellipse#setXRadius - * @since 3.0.0 - * - * @param {number} value - The horizontal radius of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setXRadius: function (value) - { - this.xRadius = value; - - return this; - }, - - /** - * Sets the vertical radius of this curve. - * - * @method Phaser.Curves.Ellipse#setYRadius - * @since 3.0.0 - * - * @param {number} value - The vertical radius of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setYRadius: function (value) - { - this.yRadius = value; - - return this; - }, - - /** - * Sets the width of this curve. - * - * @method Phaser.Curves.Ellipse#setWidth - * @since 3.0.0 - * - * @param {number} value - The width of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setWidth: function (value) - { - this.xRadius = value * 2; - - return this; - }, - - /** - * Sets the height of this curve. - * - * @method Phaser.Curves.Ellipse#setHeight - * @since 3.0.0 - * - * @param {number} value - The height of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setHeight: function (value) - { - this.yRadius = value * 2; - - return this; - }, - - /** - * Sets the start angle of this curve. - * - * @method Phaser.Curves.Ellipse#setStartAngle - * @since 3.0.0 - * - * @param {number} value - The start angle of this curve, in radians. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setStartAngle: function (value) - { - this.startAngle = value; - - return this; - }, - - /** - * Sets the end angle of this curve. - * - * @method Phaser.Curves.Ellipse#setEndAngle - * @since 3.0.0 - * - * @param {number} value - The end angle of this curve, in radians. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setEndAngle: function (value) - { - this.endAngle = value; - - return this; - }, - - /** - * Sets if this curve extends clockwise or anti-clockwise. - * - * @method Phaser.Curves.Ellipse#setClockwise - * @since 3.0.0 - * - * @param {boolean} value - The clockwise state of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setClockwise: function (value) - { - this.clockwise = value; - - return this; - }, - - /** - * Sets the rotation of this curve. - * - * @method Phaser.Curves.Ellipse#setRotation - * @since 3.0.0 - * - * @param {number} value - The rotation of this curve, in radians. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setRotation: function (value) - { - this.rotation = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.p0.x; - }, - - set: function (value) - { - this.p0.x = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.p0.y; - }, - - set: function (value) - { - this.p0.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#xRadius - * @type {number} - * @since 3.0.0 - */ - xRadius: { - - get: function () - { - return this._xRadius; - }, - - set: function (value) - { - this._xRadius = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#yRadius - * @type {number} - * @since 3.0.0 - */ - yRadius: { - - get: function () - { - return this._yRadius; - }, - - set: function (value) - { - this._yRadius = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#startAngle - * @type {number} - * @since 3.0.0 - */ - startAngle: { - - get: function () - { - return RadToDeg(this._startAngle); - }, - - set: function (value) - { - this._startAngle = DegToRad(value); - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#endAngle - * @type {number} - * @since 3.0.0 - */ - endAngle: { - - get: function () - { - return RadToDeg(this._endAngle); - }, - - set: function (value) - { - this._endAngle = DegToRad(value); - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#clockwise - * @type {boolean} - * @since 3.0.0 - */ - clockwise: { - - get: function () - { - return this._clockwise; - }, - - set: function (value) - { - this._clockwise = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#rotation - * @type {number} - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this._rotation; - }, - - set: function (value) - { - this._rotation = DegToRad(value); - } - - }, - - /** - * [description] - * - * @method Phaser.Curves.Ellipse#toJSON - * @since 3.0.0 - * - * @return {JSONEllipseCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - return { - type: this.type, - x: this.p0.x, - y: this.p0.y, - xRadius: this._xRadius, - yRadius: this._yRadius, - startAngle: RadToDeg(this._startAngle), - endAngle: RadToDeg(this._endAngle), - clockwise: this._clockwise, - rotation: RadToDeg(this._rotation) - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.Ellipse.fromJSON - * @since 3.0.0 - * - * @param {JSONEllipseCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.Ellipse} [description] - */ -EllipseCurve.fromJSON = function (data) -{ - return new EllipseCurve(data); -}; - -module.exports = EllipseCurve; - - -/***/ }), -/* 550 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function P0 (t, p) -{ - var k = 1 - t; - - return k * k * k * p; -} - -function P1 (t, p) -{ - var k = 1 - t; - - return 3 * k * k * t * p; -} - -function P2 (t, p) -{ - return 3 * (1 - t) * t * t * p; -} - -function P3 (t, p) -{ - return t * t * t * p; -} - -// p0 = start point -// p1 = control point 1 -// p2 = control point 2 -// p3 = end point - -// https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a - -/** - * A cubic bezier interpolation method. - * - * @function Phaser.Math.Interpolation.CubicBezier - * @since 3.0.0 - * - * @param {float} t - The percentage of interpolation, between 0 and 1. - * @param {number} p0 - The start point. - * @param {number} p1 - The first control point. - * @param {number} p2 - The second control point. - * @param {number} p3 - The end point. - * - * @return {number} The interpolated value. - */ -var CubicBezierInterpolation = function (t, p0, p1, p2, p3) -{ - return P0(t, p0) + P1(t, p1) + P2(t, p2) + P3(t, p3); -}; - -module.exports = CubicBezierInterpolation; - - -/***/ }), -/* 551 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var CubicBezier = __webpack_require__(550); -var Curve = __webpack_require__(86); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class CubicBezier - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. - * @param {Phaser.Math.Vector2} p1 - Control Point 1. - * @param {Phaser.Math.Vector2} p2 - Control Point 2. - * @param {Phaser.Math.Vector2} p3 - End Point. - */ -var CubicBezierCurve = new Class({ - - Extends: Curve, - - initialize: - - function CubicBezierCurve (p0, p1, p2, p3) - { - Curve.call(this, 'CubicBezierCurve'); - - if (Array.isArray(p0)) - { - p3 = new Vector2(p0[6], p0[7]); - p2 = new Vector2(p0[4], p0[5]); - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } - - /** - * [description] - * - * @name Phaser.Curves.CubicBezier#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezier#p1 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p1 = p1; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezier#p2 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p2 = p2; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezier#p3 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p3 = p3; - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.CubicBezier#getStartPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezier#getResolution - * @since 3.0.0 - * - * @param {number} divisions - The amount of divisions used by this curve. - * - * @return {number} The resolution of the curve. - */ - getResolution: function (divisions) - { - return divisions; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.CubicBezier#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var p0 = this.p0; - var p1 = this.p1; - var p2 = this.p2; - var p3 = this.p3; - - return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezier#draw - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - if (pointsTotal === undefined) { pointsTotal = 32; } - - var points = this.getPoints(pointsTotal); - - graphics.beginPath(); - graphics.moveTo(this.p0.x, this.p0.y); - - for (var i = 1; i < points.length; i++) - { - graphics.lineTo(points[i].x, points[i].y); - } - - graphics.strokePath(); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezier#toJSON - * @since 3.0.0 - * - * @return {JSONCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y, - this.p2.x, this.p2.y, - this.p3.x, this.p3.y - ] - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.CubicBezier.fromJSON - * @since 3.0.0 - * - * @param {JSONCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.CubicBezier} [description] - */ -CubicBezierCurve.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - var p2 = new Vector2(points[4], points[5]); - var p3 = new Vector2(points[6], points[7]); - - return new CubicBezierCurve(p0, p1, p2, p3); -}; - -module.exports = CubicBezierCurve; - - -/***/ }), -/* 552 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(279); -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(87); - -// Local cache vars -var tmpVec3 = new Vector3(); - -/** - * @classdesc - * [description] - * - * @class PerspectiveCamera - * @extends Phaser.Cameras.Sprite3D.Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {integer} [fieldOfView=80] - [description] - * @param {integer} [viewportWidth=0] - [description] - * @param {integer} [viewportHeight=0] - [description] - */ -var PerspectiveCamera = new Class({ - - Extends: Camera, - - // FOV is converted to radians automatically - initialize: - - function PerspectiveCamera (scene, fieldOfView, viewportWidth, viewportHeight) - { - if (fieldOfView === undefined) { fieldOfView = 80; } - if (viewportWidth === undefined) { viewportWidth = 0; } - if (viewportHeight === undefined) { viewportHeight = 0; } - - Camera.call(this, scene); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportWidth - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.viewportWidth = viewportWidth; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportHeight - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.viewportHeight = viewportHeight; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#fieldOfView - * @type {integer} - * @default 80 - * @since 3.0.0 - */ - this.fieldOfView = fieldOfView * Math.PI / 180; - - this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#setFOV - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] - */ - setFOV: function (value) - { - this.fieldOfView = value * Math.PI / 180; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#update - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] - */ - update: function () - { - var aspect = this.viewportWidth / this.viewportHeight; - - // Create a perspective matrix for our camera - this.projection.perspective( - this.fieldOfView, - aspect, - Math.abs(this.near), - Math.abs(this.far) - ); - - // Build the view matrix - tmpVec3.copy(this.position).add(this.direction); - - this.view.lookAt(this.position, tmpVec3, this.up); - - // Projection * view matrix - this.combined.copy(this.projection).multiply(this.view); - - // Invert combined matrix, used for unproject - this.invProjectionView.copy(this.combined).invert(); - - this.billboardMatrixDirty = true; - - this.updateChildren(); - - return this; - } - -}); - -module.exports = PerspectiveCamera; - - -/***/ }), -/* 553 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(279); -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(87); - -// Local cache vars -var tmpVec3 = new Vector3(); - -/** - * @classdesc - * [description] - * - * @class OrthographicCamera - * @extends Phaser.Cameras.Sprite3D.Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {integer} [viewportWidth=0] - [description] - * @param {integer} [viewportHeight=0] - [description] - */ -var OrthographicCamera = new Class({ - - Extends: Camera, - - initialize: - - function OrthographicCamera (scene, viewportWidth, viewportHeight) - { - if (viewportWidth === undefined) { viewportWidth = 0; } - if (viewportHeight === undefined) { viewportHeight = 0; } - - Camera.call(this, scene); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportWidth - * @type {integer} - * @since 3.0.0 - */ - this.viewportWidth = viewportWidth; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportHeight - * @type {integer} - * @since 3.0.0 - */ - this.viewportHeight = viewportHeight; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom - * @type {float} - * @private - * @since 3.0.0 - */ - this._zoom = 1.0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#near - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.near = 0; - - this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.OrthographicCamera#setToOrtho - * @since 3.0.0 - * - * @param {number} yDown - [description] - * @param {number} [viewportWidth] - [description] - * @param {number} [viewportHeight] - [description] - * - * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] - */ - setToOrtho: function (yDown, viewportWidth, viewportHeight) - { - if (viewportWidth === undefined) { viewportWidth = this.viewportWidth; } - if (viewportHeight === undefined) { viewportHeight = this.viewportHeight; } - - var zoom = this.zoom; - - this.up.set(0, (yDown) ? -1 : 1, 0); - this.direction.set(0, 0, (yDown) ? 1 : -1); - this.position.set(zoom * viewportWidth / 2, zoom * viewportHeight / 2, 0); - - this.viewportWidth = viewportWidth; - this.viewportHeight = viewportHeight; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.OrthographicCamera#update - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] - */ - update: function () - { - var w = this.viewportWidth; - var h = this.viewportHeight; - var near = Math.abs(this.near); - var far = Math.abs(this.far); - var zoom = this.zoom; - - if (w === 0 || h === 0) - { - // What to do here... hmm? - return this; - } - - this.projection.ortho( - zoom * -w / 2, zoom * w / 2, - zoom * -h / 2, zoom * h / 2, - near, - far - ); - - // Build the view matrix - tmpVec3.copy(this.position).add(this.direction); - - this.view.lookAt(this.position, tmpVec3, this.up); - - // Projection * view matrix - this.combined.copy(this.projection).multiply(this.view); - - // Invert combined matrix, used for unproject - this.invProjectionView.copy(this.combined).invert(); - - this.billboardMatrixDirty = true; - - this.updateChildren(); - - return this; - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#zoom - * @type {number} - * @since 3.0.0 - */ - zoom: { - - get: function () - { - return this._zoom; - }, - - set: function (value) - { - this._zoom = value; - this.update(); - } - } - -}); - -module.exports = OrthographicCamera; - - -/***/ }), -/* 554 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera, parentMatrix); -}; - -module.exports = SpriteCanvasRenderer; - - -/***/ }), -/* 555 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchSprite(src, camera, parentMatrix); -}; - -module.exports = SpriteWebGLRenderer; - - -/***/ }), -/* 556 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(555); -} - -if (true) -{ - renderCanvas = __webpack_require__(554); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 557 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A three-dimensional matrix. - * - * Defaults to the identity matrix when instantiated. - * - * @class Matrix3 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} [m] - Optional Matrix3 to copy values from. - */ -var Matrix3 = new Class({ - - initialize: - - function Matrix3 (m) - { - /** - * The matrix values. - * - * @name Phaser.Math.Matrix3#val - * @type {Float32Array} - * @since 3.0.0 - */ - this.val = new Float32Array(9); - - if (m) - { - // Assume Matrix3 with val: - this.copy(m); - } - else - { - // Default to identity - this.identity(); - } - }, - - /** - * Make a clone of this Matrix3. - * - * @method Phaser.Math.Matrix3#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} A clone of this Matrix3. - */ - clone: function () - { - return new Matrix3(this); - }, - - /** - * This method is an alias for `Matrix3.copy`. - * - * @method Phaser.Math.Matrix3#set - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} src - The Matrix to set the values of this Matrix's from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - set: function (src) - { - return this.copy(src); - }, - - /** - * Copy the values of a given Matrix into this Matrix. - * - * @method Phaser.Math.Matrix3#copy - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} src - The Matrix to copy the values from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - copy: function (src) - { - var out = this.val; - var a = src.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - - return this; - }, - - /** - * Copy the values of a given Matrix4 into this Matrix3. - * - * @method Phaser.Math.Matrix3#fromMat4 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} m - The Matrix4 to copy the values from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - fromMat4: function (m) - { - var a = m.val; - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[4]; - out[4] = a[5]; - out[5] = a[6]; - out[6] = a[8]; - out[7] = a[9]; - out[8] = a[10]; - - return this; - }, - - /** - * Set the values of this Matrix from the given array. - * - * @method Phaser.Math.Matrix3#fromArray - * @since 3.0.0 - * - * @param {array} a - The array to copy the values from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - fromArray: function (a) - { - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - - return this; - }, - - /** - * Reset this Matrix to an identity (default) matrix. - * - * @method Phaser.Math.Matrix3#identity - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - identity: function () - { - var out = this.val; - - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 1; - - return this; - }, - - /** - * Transpose this Matrix. - * - * @method Phaser.Math.Matrix3#transpose - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - transpose: function () - { - var a = this.val; - var a01 = a[1]; - var a02 = a[2]; - var a12 = a[5]; - - a[1] = a[3]; - a[2] = a[6]; - a[3] = a01; - a[5] = a[7]; - a[6] = a02; - a[7] = a12; - - return this; - }, - - /** - * Invert this Matrix. - * - * @method Phaser.Math.Matrix3#invert - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - invert: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - var b01 = a22 * a11 - a12 * a21; - var b11 = -a22 * a10 + a12 * a20; - var b21 = a21 * a10 - a11 * a20; - - // Calculate the determinant - var det = a00 * b01 + a01 * b11 + a02 * b21; - - if (!det) - { - return null; - } - - det = 1 / det; - - a[0] = b01 * det; - a[1] = (-a22 * a01 + a02 * a21) * det; - a[2] = (a12 * a01 - a02 * a11) * det; - a[3] = b11 * det; - a[4] = (a22 * a00 - a02 * a20) * det; - a[5] = (-a12 * a00 + a02 * a10) * det; - a[6] = b21 * det; - a[7] = (-a21 * a00 + a01 * a20) * det; - a[8] = (a11 * a00 - a01 * a10) * det; - - return this; - }, - - /** - * Calculate the adjoint, or adjugate, of this Matrix. - * - * @method Phaser.Math.Matrix3#adjoint - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - adjoint: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - a[0] = (a11 * a22 - a12 * a21); - a[1] = (a02 * a21 - a01 * a22); - a[2] = (a01 * a12 - a02 * a11); - a[3] = (a12 * a20 - a10 * a22); - a[4] = (a00 * a22 - a02 * a20); - a[5] = (a02 * a10 - a00 * a12); - a[6] = (a10 * a21 - a11 * a20); - a[7] = (a01 * a20 - a00 * a21); - a[8] = (a00 * a11 - a01 * a10); - - return this; - }, - - /** - * Calculate the determinant of this Matrix. - * - * @method Phaser.Math.Matrix3#determinant - * @since 3.0.0 - * - * @return {number} The determinant of this Matrix. - */ - determinant: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); - }, - - /** - * Multiply this Matrix by the given Matrix. - * - * @method Phaser.Math.Matrix3#multiply - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} src - The Matrix to multiply this Matrix by. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - multiply: function (src) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - var b = src.val; - - var b00 = b[0]; - var b01 = b[1]; - var b02 = b[2]; - var b10 = b[3]; - var b11 = b[4]; - var b12 = b[5]; - var b20 = b[6]; - var b21 = b[7]; - var b22 = b[8]; - - a[0] = b00 * a00 + b01 * a10 + b02 * a20; - a[1] = b00 * a01 + b01 * a11 + b02 * a21; - a[2] = b00 * a02 + b01 * a12 + b02 * a22; - - a[3] = b10 * a00 + b11 * a10 + b12 * a20; - a[4] = b10 * a01 + b11 * a11 + b12 * a21; - a[5] = b10 * a02 + b11 * a12 + b12 * a22; - - a[6] = b20 * a00 + b21 * a10 + b22 * a20; - a[7] = b20 * a01 + b21 * a11 + b22 * a21; - a[8] = b20 * a02 + b21 * a12 + b22 * a22; - - return this; - }, - - /** - * Translate this Matrix using the given Vector. - * - * @method Phaser.Math.Matrix3#translate - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - translate: function (v) - { - var a = this.val; - var x = v.x; - var y = v.y; - - a[6] = x * a[0] + y * a[3] + a[6]; - a[7] = x * a[1] + y * a[4] + a[7]; - a[8] = x * a[2] + y * a[5] + a[8]; - - return this; - }, - - /** - * Apply a rotation transformation to this Matrix. - * - * @method Phaser.Math.Matrix3#rotate - * @since 3.0.0 - * - * @param {number} rad - The angle in radians to rotate by. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - rotate: function (rad) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - - var s = Math.sin(rad); - var c = Math.cos(rad); - - a[0] = c * a00 + s * a10; - a[1] = c * a01 + s * a11; - a[2] = c * a02 + s * a12; - - a[3] = c * a10 - s * a00; - a[4] = c * a11 - s * a01; - a[5] = c * a12 - s * a02; - - return this; - }, - - /** - * Apply a scale transformation to this Matrix. - * - * Uses the `x` and `y` components of the given Vector to scale the Matrix. - * - * @method Phaser.Math.Matrix3#scale - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - scale: function (v) - { - var a = this.val; - var x = v.x; - var y = v.y; - - a[0] = x * a[0]; - a[1] = x * a[1]; - a[2] = x * a[2]; - - a[3] = y * a[3]; - a[4] = y * a[4]; - a[5] = y * a[5]; - - return this; - }, - - /** - * Set the values of this Matrix from the given Quaternion. - * - * @method Phaser.Math.Matrix3#fromQuat - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - fromQuat: function (q) - { - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - var out = this.val; - - out[0] = 1 - (yy + zz); - out[3] = xy + wz; - out[6] = xz - wy; - - out[1] = xy - wz; - out[4] = 1 - (xx + zz); - out[7] = yz + wx; - - out[2] = xz + wy; - out[5] = yz - wx; - out[8] = 1 - (xx + yy); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#normalFromMat4 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} m - [description] - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - normalFromMat4: function (m) - { - var a = m.val; - var out = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) - { - return null; - } - - det = 1 / det; - - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - - out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - - out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - - return this; - } - -}); - -module.exports = Matrix3; - - -/***/ }), -/* 558 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(87); -var Matrix3 = __webpack_require__(557); - -var EPSILON = 0.000001; - -// Some shared 'private' arrays -var siNext = new Int8Array([ 1, 2, 0 ]); -var tmp = new Float32Array([ 0, 0, 0 ]); - -var xUnitVec3 = new Vector3(1, 0, 0); -var yUnitVec3 = new Vector3(0, 1, 0); - -var tmpvec = new Vector3(); -var tmpMat3 = new Matrix3(); - -/** - * @classdesc - * A quaternion. - * - * @class Quaternion - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - The x component. - * @param {number} [y] - The y component. - * @param {number} [z] - The z component. - * @param {number} [w] - The w component. - */ -var Quaternion = new Class({ - - initialize: - - function Quaternion (x, y, z, w) - { - /** - * The x component of this Quaternion. - * - * @name Phaser.Math.Quaternion#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The y component of this Quaternion. - * - * @name Phaser.Math.Quaternion#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The z component of this Quaternion. - * - * @name Phaser.Math.Quaternion#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The w component of this Quaternion. - * - * @name Phaser.Math.Quaternion#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - }, - - /** - * Copy the components of a given Quaternion or Vector into this Quaternion. - * - * @method Phaser.Math.Quaternion#copy - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} src - The Quaternion or Vector to copy the components from. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z; - this.w = src.w; - - return this; - }, - - /** - * Set the components of this Quaternion. - * - * @method Phaser.Math.Quaternion#set - * @since 3.0.0 - * - * @param {(number|object)} [x=0] - The x component, or an object containing x, y, z, and w components. - * @param {number} [y=0] - The y component. - * @param {number} [z=0] - The z component. - * @param {number} [w=0] - The w component. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - set: function (x, y, z, w) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - - return this; - }, - - /** - * Add a given Quaternion or Vector to this Quaternion. Addition is component-wise. - * - * @method Phaser.Math.Quaternion#add - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to add to this Quaternion. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z; - this.w += v.w; - - return this; - }, - - /** - * Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise. - * - * @method Phaser.Math.Quaternion#subtract - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to subtract from this Quaternion. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - this.w -= v.w; - - return this; - }, - - /** - * Scale this Quaternion by the given value. - * - * @method Phaser.Math.Quaternion#scale - * @since 3.0.0 - * - * @param {number} scale - The value to scale this Quaternion by. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - scale: function (scale) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - this.w *= scale; - - return this; - }, - - /** - * Calculate the length of this Quaternion. - * - * @method Phaser.Math.Quaternion#length - * @since 3.0.0 - * - * @return {number} The length of this Quaternion. - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return Math.sqrt(x * x + y * y + z * z + w * w); - }, - - /** - * Calculate the length of this Quaternion squared. - * - * @method Phaser.Math.Quaternion#lengthSq - * @since 3.0.0 - * - * @return {number} The length of this Quaternion, squared. - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return x * x + y * y + z * z + w * w; - }, - - /** - * Normalize this Quaternion. - * - * @method Phaser.Math.Quaternion#normalize - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var len = x * x + y * y + z * z + w * w; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - this.w = w * len; - } - - return this; - }, - - /** - * Calculate the dot product of this Quaternion and the given Quaternion or Vector. - * - * @method Phaser.Math.Quaternion#dot - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to dot product with this Quaternion. - * - * @return {number} The dot product of this Quaternion and the given Quaternion or Vector. - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; - }, - - /** - * Linearly interpolate this Quaternion towards the given Quaternion or Vector. - * - * @method Phaser.Math.Quaternion#lerp - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to interpolate towards. - * @param {number} [t=0] - The percentage of interpolation. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - this.w = aw + t * (v.w - aw); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotationTo - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} a - [description] - * @param {Phaser.Math.Vector3} b - [description] - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - rotationTo: function (a, b) - { - var dot = a.x * b.x + a.y * b.y + a.z * b.z; - - if (dot < -0.999999) - { - if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) - { - tmpvec.copy(yUnitVec3).cross(a); - } - - tmpvec.normalize(); - - return this.setAxisAngle(tmpvec, Math.PI); - - } - else if (dot > 0.999999) - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 1; - - return this; - } - else - { - tmpvec.copy(a).cross(b); - - this.x = tmpvec.x; - this.y = tmpvec.y; - this.z = tmpvec.z; - this.w = 1 + dot; - - return this.normalize(); - } - }, - - /** - * Set the axes of this Quaternion. - * - * @method Phaser.Math.Quaternion#setAxes - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} view - The view axis. - * @param {Phaser.Math.Vector3} right - The right axis. - * @param {Phaser.Math.Vector3} up - The upwards axis. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - setAxes: function (view, right, up) - { - var m = tmpMat3.val; - - m[0] = right.x; - m[3] = right.y; - m[6] = right.z; - - m[1] = up.x; - m[4] = up.y; - m[7] = up.z; - - m[2] = -view.x; - m[5] = -view.y; - m[8] = -view.z; - - return this.fromMat3(tmpMat3).normalize(); - }, - - /** - * Reset this Matrix to an identity (default) Quaternion. - * - * @method Phaser.Math.Quaternion#identity - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - identity: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 1; - - return this; - }, - - /** - * Set the axis angle of this Quaternion. - * - * @method Phaser.Math.Quaternion#setAxisAngle - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} axis - The axis. - * @param {number} rad - The angle in radians. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - setAxisAngle: function (axis, rad) - { - rad = rad * 0.5; - - var s = Math.sin(rad); - - this.x = s * axis.x; - this.y = s * axis.y; - this.z = s * axis.z; - this.w = Math.cos(rad); - - return this; - }, - - /** - * Multiply this Quaternion by the given Quaternion or Vector. - * - * @method Phaser.Math.Quaternion#multiply - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to multiply this Quaternion by. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - multiply: function (b) - { - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = b.x; - var by = b.y; - var bz = b.z; - var bw = b.w; - - this.x = ax * bw + aw * bx + ay * bz - az * by; - this.y = ay * bw + aw * by + az * bx - ax * bz; - this.z = az * bw + aw * bz + ax * by - ay * bx; - this.w = aw * bw - ax * bx - ay * by - az * bz; - - return this; - }, - - /** - * Smoothly linearly interpolate this Quaternion towards the given Quaternion or Vector. - * - * @method Phaser.Math.Quaternion#slerp - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to interpolate towards. - * @param {number} t - The percentage of interpolation. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - slerp: function (b, t) - { - // benchmarks: http://jsperf.com/quaternion-slerp-implementations - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = b.x; - var by = b.y; - var bz = b.z; - var bw = b.w; - - // calc cosine - var cosom = ax * bx + ay * by + az * bz + aw * bw; - - // adjust signs (if necessary) - if (cosom < 0) - { - cosom = -cosom; - bx = - bx; - by = - by; - bz = - bz; - bw = - bw; - } - - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - var scale0 = 1 - t; - var scale1 = t; - - // calculate coefficients - if ((1 - cosom) > EPSILON) - { - // standard case (slerp) - var omega = Math.acos(cosom); - var sinom = Math.sin(omega); - - scale0 = Math.sin((1.0 - t) * omega) / sinom; - scale1 = Math.sin(t * omega) / sinom; - } - - // calculate final values - this.x = scale0 * ax + scale1 * bx; - this.y = scale0 * ay + scale1 * by; - this.z = scale0 * az + scale1 * bz; - this.w = scale0 * aw + scale1 * bw; - - return this; - }, - - /** - * Invert this Quaternion. - * - * @method Phaser.Math.Quaternion#invert - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - invert: function () - { - var a0 = this.x; - var a1 = this.y; - var a2 = this.z; - var a3 = this.w; - - var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; - var invDot = (dot) ? 1 / dot : 0; - - // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 - - this.x = -a0 * invDot; - this.y = -a1 * invDot; - this.z = -a2 * invDot; - this.w = a3 * invDot; - - return this; - }, - - /** - * Convert this Quaternion into its conjugate. - * - * Sets the x, y and z components. - * - * @method Phaser.Math.Quaternion#conjugate - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - conjugate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - - return this; - }, - - /** - * Rotate this Quaternion on the X axis. - * - * @method Phaser.Math.Quaternion#rotateX - * @since 3.0.0 - * - * @param {number} rad - The rotation angle in radians. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - rotateX: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw + aw * bx; - this.y = ay * bw + az * bx; - this.z = az * bw - ay * bx; - this.w = aw * bw - ax * bx; - - return this; - }, - - /** - * Rotate this Quaternion on the Y axis. - * - * @method Phaser.Math.Quaternion#rotateY - * @since 3.0.0 - * - * @param {number} rad - The rotation angle in radians. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - rotateY: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var by = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw - az * by; - this.y = ay * bw + aw * by; - this.z = az * bw + ax * by; - this.w = aw * bw - ay * by; - - return this; - }, - - /** - * Rotate this Quaternion on the Z axis. - * - * @method Phaser.Math.Quaternion#rotateZ - * @since 3.0.0 - * - * @param {number} rad - The rotation angle in radians. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - rotateZ: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bz = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw + ay * bz; - this.y = ay * bw - ax * bz; - this.z = az * bw + aw * bz; - this.w = aw * bw - az * bz; - - return this; - }, - - /** - * Create a unit (or rotation) Quaternion from its x, y, and z components. - * - * Sets the w component. - * - * @method Phaser.Math.Quaternion#calculateW - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - calculateW: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - this.w = -Math.sqrt(1.0 - x * x - y * y - z * z); - - return this; - }, - - /** - * Convert the given Matrix into this Quaternion. - * - * @method Phaser.Math.Quaternion#fromMat3 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} mat - The Matrix to convert from. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - fromMat3: function (mat) - { - // benchmarks: - // http://jsperf.com/typed-array-access-speed - // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion - - // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes - // article "Quaternion Calculus and Fast Animation". - var m = mat.val; - var fTrace = m[0] + m[4] + m[8]; - var fRoot; - - if (fTrace > 0) - { - // |w| > 1/2, may as well choose w > 1/2 - fRoot = Math.sqrt(fTrace + 1.0); // 2w - - this.w = 0.5 * fRoot; - - fRoot = 0.5 / fRoot; // 1/(4w) - - this.x = (m[7] - m[5]) * fRoot; - this.y = (m[2] - m[6]) * fRoot; - this.z = (m[3] - m[1]) * fRoot; - } - else - { - // |w| <= 1/2 - var i = 0; - - if (m[4] > m[0]) - { - i = 1; - } - - if (m[8] > m[i * 3 + i]) - { - i = 2; - } - - var j = siNext[i]; - var k = siNext[j]; - - // This isn't quite as clean without array access - fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); - tmp[i] = 0.5 * fRoot; - - fRoot = 0.5 / fRoot; - - tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; - tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; - - this.x = tmp[0]; - this.y = tmp[1]; - this.z = tmp[2]; - this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; - } - - return this; - } - -}); - -module.exports = Quaternion; - - -/***/ }), -/* 559 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Vector3 = __webpack_require__(87); -var Matrix4 = __webpack_require__(278); -var Quaternion = __webpack_require__(558); - -var tmpMat4 = new Matrix4(); -var tmpQuat = new Quaternion(); -var tmpVec3 = new Vector3(); - -/** - * Rotates a vector in place by axis angle. - * - * This is the same as transforming a point by an - * axis-angle quaternion, but it has higher precision. - * - * @function Phaser.Math.RotateVec3 - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec - The vector to be rotated. - * @param {Phaser.Math.Vector3} axis - The axis to rotate around. - * @param {float} radians - The angle of rotation in radians. - * - * @return {Phaser.Math.Vector3} The given vector. - */ -var RotateVec3 = function (vec, axis, radians) -{ - // Set the quaternion to our axis angle - tmpQuat.setAxisAngle(axis, radians); - - // Create a rotation matrix from the axis angle - tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); - - // Multiply our vector by the rotation matrix - return vec.transformMat4(tmpMat4); -}; - -module.exports = RotateVec3; - - -/***/ }), -/* 560 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compute a random four-dimensional vector. - * - * @function Phaser.Math.RandomXYZW - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} vec4 - The Vector to compute random values for. - * @param {float} [scale=1] - The scale of the random values. - * - * @return {Phaser.Math.Vector4} The given Vector. - */ -var RandomXYZW = function (vec4, scale) -{ - if (scale === undefined) { scale = 1; } - - // TODO: Not spherical; should fix this for more uniform distribution - vec4.x = (Math.random() * 2 - 1) * scale; - vec4.y = (Math.random() * 2 - 1) * scale; - vec4.z = (Math.random() * 2 - 1) * scale; - vec4.w = (Math.random() * 2 - 1) * scale; - - return vec4; -}; - -module.exports = RandomXYZW; - - -/***/ }), -/* 561 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compute a random position vector in a spherical area, optionally defined by the given radius. - * - * @function Phaser.Math.RandomXYZ - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec3 - The Vector to compute random values for. - * @param {number} [radius=1] - The radius. - * - * @return {Phaser.Math.Vector3} The given Vector. - */ -var RandomXYZ = function (vec3, radius) -{ - if (radius === undefined) { radius = 1; } - - var r = Math.random() * 2 * Math.PI; - var z = (Math.random() * 2) - 1; - var zScale = Math.sqrt(1 - z * z) * radius; - - vec3.x = Math.cos(r) * zScale; - vec3.y = Math.sin(r) * zScale; - vec3.z = z * radius; - - return vec3; -}; - -module.exports = RandomXYZ; - - -/***/ }), -/* 562 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(123); -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); -var RectangleContains = __webpack_require__(31); - -/** - * @typedef {object} InputJSONCameraObject - * - * @property {string} [name=''] - [description] - * @property {integer} [x=0] - [description] - * @property {integer} [y=0] - [description] - * @property {integer} [width] - [description] - * @property {integer} [height] - [description] - * @property {float} [zoom=1] - [description] - * @property {float} [rotation=0] - [description] - * @property {boolean} [roundPixels=false] - [description] - * @property {float} [scrollX=0] - [description] - * @property {float} [scrollY=0] - [description] - * @property {(false|string)} [backgroundColor=false] - [description] - * @property {?object} [bounds] - [description] - * @property {number} [bounds.x=0] - [description] - * @property {number} [bounds.y=0] - [description] - * @property {number} [bounds.width] - [description] - * @property {number} [bounds.height] - [description] - */ - -/** - * @classdesc - * [description] - * - * @class CameraManager - * @memberOf Phaser.Cameras.Scene2D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. - */ -var CameraManager = new Class({ - - initialize: - - function CameraManager (scene) - { - /** - * The Scene that owns the Camera Manager plugin. - * - * @name Phaser.Cameras.Scene2D.CameraManager#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * The current Camera ID. - * - * @name Phaser.Cameras.Scene2D.CameraManager#currentCameraId - * @type {number} - * @default 1 - * @readOnly - * @since 3.0.0 - */ - this.currentCameraId = 1; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameras - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameras = []; - - /** - * A pool of Camera objects available to be used by the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameraPool - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameraPool = []; - - /** - * The default Camera in the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#main - * @type {Phaser.Cameras.Scene2D.Camera} - * @since 3.0.0 - */ - this.main; - - /** - * This scale affects all cameras. It's used by Scale Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#baseScale - * @type {number} - * @since 3.0.0 - */ - this.baseScale = 1; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Cameras.Scene2D.CameraManager#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - 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]; - - this.systems.events.once('destroy', this.destroy, 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.Cameras.Scene2D.CameraManager#start - * @private - * @since 3.5.0 - */ - start: function () - { - if (!this.main) - { - this.boot(); - } - - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#add - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] - * @param {boolean} [makeMain=false] - [description] - * @param {string} [name=''] - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - add: function (x, y, width, height, makeMain, name) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = this.scene.sys.game.config.width; } - if (height === undefined) { height = this.scene.sys.game.config.height; } - if (makeMain === undefined) { makeMain = false; } - if (name === undefined) { name = ''; } - - var camera = null; - - if (this.cameraPool.length > 0) - { - camera = this.cameraPool.pop(); - - camera.setViewport(x, y, width, height); - } - else - { - camera = new Camera(x, y, width, height); - } - - camera.setName(name); - camera.setScene(this.scene); - - this.cameras.push(camera); - - if (makeMain) - { - this.main = camera; - } - - camera._id = this.currentCameraId; - - this.currentCameraId = this.currentCameraId << 1; - - return camera; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#addExisting - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - addExisting: function (camera) - { - var index = this.cameras.indexOf(camera); - var poolIndex = this.cameraPool.indexOf(camera); - - if (index < 0 && poolIndex >= 0) - { - this.cameras.push(camera); - this.cameraPool.slice(poolIndex, 1); - - return camera; - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON - * @since 3.0.0 - * - * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - [description] - * - * @return {Phaser.Cameras.Scene2D.CameraManager} [description] - */ - fromJSON: function (config) - { - if (!Array.isArray(config)) - { - config = [ config ]; - } - - var gameWidth = this.scene.sys.game.config.width; - var gameHeight = this.scene.sys.game.config.height; - - for (var i = 0; i < config.length; i++) - { - var cameraConfig = config[i]; - - var x = GetFastValue(cameraConfig, 'x', 0); - var y = GetFastValue(cameraConfig, 'y', 0); - var width = GetFastValue(cameraConfig, 'width', gameWidth); - var height = GetFastValue(cameraConfig, 'height', gameHeight); - - var camera = this.add(x, y, width, height); - - // Direct properties - camera.name = GetFastValue(cameraConfig, 'name', ''); - camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); - camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); - camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); - camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); - camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); - camera.visible = GetFastValue(cameraConfig, 'visible', true); - - // Background Color - - var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); - - if (backgroundColor) - { - camera.setBackgroundColor(backgroundColor); - } - - // Bounds - - var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); - - if (boundsConfig) - { - var bx = GetFastValue(boundsConfig, 'x', 0); - var by = GetFastValue(boundsConfig, 'y', 0); - var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); - var bheight = GetFastValue(boundsConfig, 'height', gameHeight); - - camera.setBounds(bx, by, bwidth, bheight); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCamera - * @since 3.0.0 - * - * @param {string} name - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - getCamera: function (name) - { - for (var i = 0; i < this.cameras.length; i++) - { - if (this.cameras[i].name === name) - { - return this.cameras[i]; - } - } - - return null; - }, - - /** - * Returns an array of all cameras below the given Pointer. - * - * The first camera in the array is the top-most camera in the camera list. - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCamerasBelowPointer - * @since 3.10.0 - * - * @param {Phaser.Input.Pointer} pointer - The Pointer to check against. - * - * @return {Phaser.Cameras.Scene2D.Camera[]} An array of cameras below the Pointer. - */ - getCamerasBelowPointer: function (pointer) - { - var cameras = this.cameras; - - var x = pointer.x; - var y = pointer.y; - - var output = []; - - for (var i = 0; i < cameras.length; i++) - { - var camera = cameras[i]; - - if (camera.visible && camera.inputEnabled && RectangleContains(camera, x, y)) - { - // So the top-most camera is at the top of the search array - output.unshift(camera); - } - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#remove - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - remove: function (camera) - { - var cameraIndex = this.cameras.indexOf(camera); - - if (cameraIndex >= 0 && this.cameras.length > 1) - { - this.cameraPool.push(this.cameras[cameraIndex]); - this.cameras.splice(cameraIndex, 1); - - if (this.main === camera) - { - this.main = this.cameras[0]; - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#render - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. - * @param {Phaser.GameObjects.GameObject[]} children - An array of renderable Game Objects. - * @param {number} interpolation - Interpolation value. Reserved for future use. - */ - render: function (renderer, children, interpolation) - { - var cameras = this.cameras; - var baseScale = this.baseScale; - - for (var i = 0, l = cameras.length; i < l; ++i) - { - var camera = cameras[i]; - - if (camera.visible) - { - camera.preRender(baseScale, renderer.config.resolution); - - renderer.render(this.scene, children, interpolation, camera); - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#resetAll - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - resetAll: function () - { - while (this.cameras.length > 0) - { - this.cameraPool.push(this.cameras.pop()); - } - - this.main = this.add(); - - return this.main; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#update - * @since 3.0.0 - * - * @param {number} timestep - [description] - * @param {number} delta - [description] - */ - update: function (timestep, delta) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].update(timestep, delta); - } - }, - - /** - * Resizes all cameras to the given dimensions. - * - * @method Phaser.Cameras.Scene2D.CameraManager#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the camera. - * @param {number} height - The new height of the camera. - */ - resize: function (width, height) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].setSize(width, height); - } - }, - - /** - * 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 () - { - this.main = undefined; - - for (var i = 0; i < this.cameras.length; i++) - { - this.cameras[i].destroy(); - } - - for (i = 0; i < this.cameraPool.length; i++) - { - this.cameraPool[i].destroy(); - } - - this.cameras = []; - this.cameraPool = []; - - 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; - } - -}); - -PluginCache.register('CameraManager', CameraManager, 'cameras'); - -module.exports = CameraManager; - - -/***/ }), -/* 563 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @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; - - -/***/ }), -/* 564 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); - -/** - * @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.Pipelines.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; - - -/***/ }), -/* 565 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); - -/** - * @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.Pipelines.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; - - -/***/ }), -/* 566 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras.Scene2D - */ - -module.exports = { - - Camera: __webpack_require__(123), - CameraManager: __webpack_require__(562), - Effects: __webpack_require__(204) - -}; - - -/***/ }), -/* 567 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cache - */ - -module.exports = { - - BaseCache: __webpack_require__(206), - CacheManager: __webpack_require__(205) - -}; - - -/***/ }), -/* 568 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Animations - */ - -module.exports = { - - Animation: __webpack_require__(210), - AnimationFrame: __webpack_require__(208), - AnimationManager: __webpack_require__(207) - -}; - - -/***/ }), -/* 569 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Using Bresenham's line algorithm this will return an array of all coordinates on this line. - * The start and end points are rounded before this runs as the algorithm works on integers. - * - * @function Phaser.Geom.Line.BresenhamPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {integer} [stepRate=1] - [description] - * @param {array} [results] - [description] - * - * @return {array} [description] - */ -var BresenhamPoints = function (line, stepRate, results) -{ - if (stepRate === undefined) { stepRate = 1; } - if (results === undefined) { results = []; } - - var x1 = Math.round(line.x1); - var y1 = Math.round(line.y1); - var x2 = Math.round(line.x2); - var y2 = Math.round(line.y2); - - var dx = Math.abs(x2 - x1); - var dy = Math.abs(y2 - y1); - var sx = (x1 < x2) ? 1 : -1; - var sy = (y1 < y2) ? 1 : -1; - var err = dx - dy; - - results.push({ x: x1, y: y1 }); - - var i = 1; - - while (!((x1 === x2) && (y1 === y2))) - { - var e2 = err << 1; - - if (e2 > -dy) - { - err -= dy; - x1 += sx; - } - - if (e2 < dx) - { - err += dx; - y1 += sy; - } - - if (i % stepRate === 0) - { - results.push({ x: x1, y: y1 }); - } - - i++; - } - - return results; -}; - -module.exports = BresenhamPoints; - - -/***/ }), -/* 570 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Perimeter = __webpack_require__(97); -var Point = __webpack_require__(5); - -// Return an array of points from the perimeter of the rectangle -// each spaced out based on the quantity or step required - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.MarchingAnts - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} step - [description] - * @param {integer} quantity - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ -var MarchingAnts = function (rect, step, quantity, out) -{ - if (out === undefined) { out = []; } - - if (!step && !quantity) - { - // Bail out - return out; - } - - // If step is a falsey value (false, null, 0, undefined, etc) then we calculate - // it based on the quantity instead, otherwise we always use the step value - if (!step) - { - step = Perimeter(rect) / quantity; - } - else - { - quantity = Math.round(Perimeter(rect) / step); - } - - var x = rect.x; - var y = rect.y; - var face = 0; - - // Loop across each face of the rectangle - - for (var i = 0; i < quantity; i++) - { - out.push(new Point(x, y)); - - switch (face) - { - - // Top face - case 0: - x += step; - - if (x >= rect.right) - { - face = 1; - y += (x - rect.right); - x = rect.right; - } - break; - - // Right face - case 1: - y += step; - - if (y >= rect.bottom) - { - face = 2; - x -= (y - rect.bottom); - y = rect.bottom; - } - break; - - // Bottom face - case 2: - x -= step; - - if (x <= rect.left) - { - face = 3; - y -= (rect.left - x); - x = rect.left; - } - break; - - // Left face - case 3: - y -= step; - - if (y <= rect.top) - { - face = 0; - y = rect.top; - } - break; - } - } - - return out; -}; - -module.exports = MarchingAnts; - - -/***/ }), -/* 571 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// bitmask flag for GameObject.renderMask -var _FLAG = 1; // 0001 - -/** - * Provides methods used for setting the visibility of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Visible - * @since 3.0.0 - */ - -var Visible = { - - /** - * Private internal value. Holds the visible value. - * - * @name Phaser.GameObjects.Components.Visible#_visible - * @type {boolean} - * @private - * @default true - * @since 3.0.0 - */ - _visible: true, - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @name Phaser.GameObjects.Components.Visible#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - if (value) - { - this._visible = true; - this.renderFlags |= _FLAG; - } - else - { - this._visible = false; - this.renderFlags &= ~_FLAG; - } - } - - }, - - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @method Phaser.GameObjects.Components.Visible#setVisible - * @since 3.0.0 - * - * @param {boolean} value - The visible state of the Game Object. - * - * @return {this} This Game Object instance. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - } -}; - -module.exports = Visible; - - -/***/ }), -/* 572 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var TransformMatrix = __webpack_require__(64); -var WrapAngle = __webpack_require__(212); -var WrapAngleDegrees = __webpack_require__(211); - -// global bitmask flag for GameObject.renderMask (used by Scale) -var _FLAG = 4; // 0100 - -/** - * Provides methods used for getting and setting the position, scale and rotation of a Game Object. - * - * @name Phaser.GameObjects.Components.Transform - * @since 3.0.0 - */ - -var Transform = { - - /** - * Private internal value. Holds the horizontal scale value. - * - * @name Phaser.GameObjects.Components.Transform#_scaleX - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _scaleX: 1, - - /** - * Private internal value. Holds the vertical scale value. - * - * @name Phaser.GameObjects.Components.Transform#_scaleY - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _scaleY: 1, - - /** - * Private internal value. Holds the rotation value in radians. - * - * @name Phaser.GameObjects.Components.Transform#_rotation - * @type {float} - * @private - * @default 0 - * @since 3.0.0 - */ - _rotation: 0, - - /** - * The x position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - x: 0, - - /** - * The y position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - y: 0, - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - * - * @name Phaser.GameObjects.Components.Transform#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - z: 0, - - /** - * The w position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - w: 0, - - /** - * The horizontal scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleX: { - - get: function () - { - return this._scaleX; - }, - - set: function (value) - { - this._scaleX = value; - - if (this._scaleX === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The vertical scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleY: { - - get: function () - { - return this._scaleY; - }, - - set: function (value) - { - this._scaleY = value; - - if (this._scaleY === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The angle of this Game Object as expressed in degrees. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - * - * @name Phaser.GameObjects.Components.Transform#angle - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - angle: { - - get: function () - { - return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); - }, - - set: function (value) - { - // value is in degrees - this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; - } - }, - - /** - * The angle of this Game Object in radians. - * - * If you prefer to work in degrees, see the `angle` property instead. - * - * @name Phaser.GameObjects.Components.Transform#rotation - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this._rotation; - }, - - set: function (value) - { - // value is in radians - this._rotation = WrapAngle(value); - } - }, - - /** - * Sets the position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setPosition - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of this Game Object. - * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value. - * @param {number} [z=0] - The z position of this Game Object. - * @param {number} [w=0] - The w position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setPosition: function (x, y, z, w) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - if (z === undefined) { z = 0; } - if (w === undefined) { w = 0; } - - this.x = x; - this.y = y; - this.z = z; - this.w = w; - - return this; - }, - - /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. - * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * - * @method Phaser.GameObjects.Components.Transform#setRandomPosition - * @since 3.8.0 - * - * @param {number} [x=0] - The x position of the top-left of the random area. - * @param {number} [y=0] - The y position of the top-left of the random area. - * @param {number} [width] - The width of the random area. - * @param {number} [height] - The height of the random area. - * - * @return {this} This Game Object instance. - */ - setRandomPosition: function (x, y, width, height) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = this.scene.sys.game.config.width; } - if (height === undefined) { height = this.scene.sys.game.config.height; } - - this.x = x + (Math.random() * width); - this.y = y + (Math.random() * height); - - return this; - }, - - /** - * Sets the rotation of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setRotation - * @since 3.0.0 - * - * @param {number} [radians=0] - The rotation of this Game Object, in radians. - * - * @return {this} This Game Object instance. - */ - setRotation: function (radians) - { - if (radians === undefined) { radians = 0; } - - this.rotation = radians; - - return this; - }, - - /** - * Sets the angle of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setAngle - * @since 3.0.0 - * - * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. - * - * @return {this} This Game Object instance. - */ - setAngle: function (degrees) - { - if (degrees === undefined) { degrees = 0; } - - this.angle = degrees; - - return this; - }, - - /** - * Sets the scale of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setScale - * @since 3.0.0 - * - * @param {number} x - The horizontal scale of this Game Object. - * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. - * - * @return {this} This Game Object instance. - */ - setScale: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.scaleX = x; - this.scaleY = y; - - return this; - }, - - /** - * Sets the x position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setX - * @since 3.0.0 - * - * @param {number} [value=0] - The x position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setX: function (value) - { - if (value === undefined) { value = 0; } - - this.x = value; - - return this; - }, - - /** - * Sets the y position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setY - * @since 3.0.0 - * - * @param {number} [value=0] - The y position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setY: function (value) - { - if (value === undefined) { value = 0; } - - this.y = value; - - return this; - }, - - /** - * Sets the z position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setZ - * @since 3.0.0 - * - * @param {number} [value=0] - The z position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setZ: function (value) - { - if (value === undefined) { value = 0; } - - this.z = value; - - return this; - }, - - /** - * Sets the w position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setW - * @since 3.0.0 - * - * @param {number} [value=0] - The w position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setW: function (value) - { - if (value === undefined) { value = 0; } - - this.w = value; - - return this; - }, - - /** - * Gets the local transform matrix for this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix - * @since 3.4.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. - * - * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. - */ - getLocalTransformMatrix: function (tempMatrix) - { - if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } - - return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); - }, - - /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * - * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix - * @since 3.4.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. - * - * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. - */ - getWorldTransformMatrix: function (tempMatrix) - { - if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } - - var parent = this.parentContainer; - - if (!parent) - { - return this.getLocalTransformMatrix(tempMatrix); - } - - var parents = []; - - while (parent) - { - parents.unshift(parent); - parent = parent.parentContainer; - } - - tempMatrix.loadIdentity(); - - var length = parents.length; - - for (var i = 0; i < length; ++i) - { - parent = parents[i]; - - tempMatrix.translate(parent.x, parent.y); - tempMatrix.rotate(parent.rotation); - tempMatrix.scale(parent.scaleX, parent.scaleY); - } - - tempMatrix.translate(this.x, this.y); - tempMatrix.rotate(this._rotation); - tempMatrix.scale(this._scaleX, this._scaleY); - - return tempMatrix; - } - -}; - -module.exports = Transform; - - -/***/ }), -/* 573 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} JSONGameObject - * - * @property {string} name - The name of this Game Object. - * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. - * @property {number} x - The x position of this Game Object. - * @property {number} y - The y position of this Game Object. - * @property {object} scale - The scale of this Game Object - * @property {number} scale.x - The horizontal scale of this Game Object. - * @property {number} scale.y - The vertical scale of this Game Object. - * @property {object} origin - The origin of this Game Object. - * @property {float} origin.x - The horizontal origin of this Game Object. - * @property {float} origin.y - The vertical origin of this Game Object. - * @property {boolean} flipX - The horizontally flipped state of the Game Object. - * @property {boolean} flipY - The vertically flipped state of the Game Object. - * @property {number} rotation - The angle of this Game Object in radians. - * @property {float} alpha - The alpha value of the Game Object. - * @property {boolean} visible - The visible state of the Game Object. - * @property {integer} scaleMode - The Scale Mode being used by this Game Object. - * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. - * @property {string} textureKey - The texture key of this Game Object. - * @property {string} frameKey - The frame key of this Game Object. - * @property {object} data - The data of this Game Object. - */ - -/** - * Build a JSON representation of the given Game Object. - * - * This is typically extended further by Game Object specific implementations. - * - * @method Phaser.GameObjects.Components.ToJSON - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON. - * - * @return {JSONGameObject} The JSON representation of the Game Object. - */ -var ToJSON = function (gameObject) -{ - var out = { - name: gameObject.name, - type: gameObject.type, - x: gameObject.x, - y: gameObject.y, - depth: gameObject.depth, - scale: { - x: gameObject.scaleX, - y: gameObject.scaleY - }, - origin: { - x: gameObject.originX, - y: gameObject.originY - }, - flipX: gameObject.flipX, - flipY: gameObject.flipY, - rotation: gameObject.rotation, - alpha: gameObject.alpha, - visible: gameObject.visible, - scaleMode: gameObject.scaleMode, - blendMode: gameObject.blendMode, - textureKey: '', - frameKey: '', - data: {} - }; - - if (gameObject.texture) - { - out.textureKey = gameObject.texture.key; - out.frameKey = gameObject.frame.name; - } - - return out; -}; - -module.exports = ToJSON; - - -/***/ }), -/* 574 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @function GetColor - * @since 3.0.0 - * @private - */ -var GetColor = function (value) -{ - return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); -}; - -/** - * Provides methods used for setting the tint of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Tint - * @webglOnly - * @since 3.0.0 - */ - -var Tint = { - - /** - * Private internal value. Holds the top-left tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintTL - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintTL: 16777215, - - /** - * Private internal value. Holds the top-right tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintTR - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintTR: 16777215, - - /** - * Private internal value. Holds the bottom-left tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintBL - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintBL: 16777215, - - /** - * Private internal value. Holds the bottom-right tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintBR - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintBR: 16777215, - - /** - * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) - * - * @method Phaser.GameObjects.Components.Tint#clearTint - * @webglOnly - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - clearTint: function () - { - this.setTint(0xffffff); - - return this; - }, - - /** - * Sets the tint values for this Game Object. - * - * @method Phaser.GameObjects.Components.Tint#setTint - * @webglOnly - * @since 3.0.0 - * - * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. - * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. - * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. - * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. - * - * @return {this} This Game Object instance. - */ - setTint: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 0xffffff; } - - if (topRight === undefined) - { - topRight = topLeft; - bottomLeft = topLeft; - bottomRight = topLeft; - } - - this._tintTL = GetColor(topLeft); - this._tintTR = GetColor(topRight); - this._tintBL = GetColor(bottomLeft); - this._tintBR = GetColor(bottomRight); - - return this; - }, - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopLeft: { - - get: function () - { - return this._tintTL; - }, - - set: function (value) - { - this._tintTL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopRight: { - - get: function () - { - return this._tintTR; - }, - - set: function (value) - { - this._tintTR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomLeft: { - - get: function () - { - return this._tintBL; - }, - - set: function (value) - { - this._tintBL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomRight: { - - get: function () - { - return this._tintBR; - }, - - set: function (value) - { - this._tintBR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the whole of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tint - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tint: { - - set: function (value) - { - this.setTint(value, value, value, value); - } - } - -}; - -module.exports = Tint; - - -/***/ }), -/* 575 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// bitmask flag for GameObject.renderMask -var _FLAG = 8; // 1000 - -/** - * Provides methods used for getting and setting the texture of a Game Object. - * - * @name Phaser.GameObjects.Components.Texture - * @since 3.0.0 - */ - -var Texture = { - - /** - * The Texture this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#texture - * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} - * @since 3.0.0 - */ - texture: null, - - /** - * The Texture Frame this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#frame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - frame: null, - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * @method Phaser.GameObjects.Components.Texture#setTexture - * @since 3.0.0 - * - * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. - * - * @return {this} This Game Object instance. - */ - setTexture: function (key, frame) - { - this.texture = this.scene.sys.textures.get(key); - - return this.setFrame(frame); - }, - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * - * @method Phaser.GameObjects.Components.Texture#setFrame - * @since 3.0.0 - * - * @param {(string|integer)} frame - The name or index of the frame within the Texture. - * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? - * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? - * - * @return {this} This Game Object instance. - */ - setFrame: function (frame, updateSize, updateOrigin) - { - if (updateSize === undefined) { updateSize = true; } - if (updateOrigin === undefined) { updateOrigin = true; } - - this.frame = this.texture.get(frame); - - if (!this.frame.cutWidth || !this.frame.cutHeight) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - - if (this._sizeComponent && updateSize) - { - this.setSizeToFrame(); - } - - if (this._originComponent && updateOrigin) - { - if (this.frame.customPivot) - { - this.setOrigin(this.frame.pivotX, this.frame.pivotY); - } - else - { - this.updateDisplayOrigin(); - } - } - - return this; - } - -}; - -module.exports = Texture; - - -/***/ }), -/* 576 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the size of a Game Object. - * - * @name Phaser.GameObjects.Components.Size - * @since 3.0.0 - */ - -var Size = { - - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Size#_sizeComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _sizeComponent: true, - - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#width - * @type {number} - * @since 3.0.0 - */ - width: 0, - - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.frame.realWidth; - }, - - set: function (value) - { - this.scaleX = value / this.frame.realWidth; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.frame.realHeight; - }, - - set: function (value) - { - this.scaleY = value / this.frame.realHeight; - } - - }, - - /** - * Sets the size of this Game Object to be that of the given Frame. - * - * @method Phaser.GameObjects.Components.Size#setSizeToFrame - * @since 3.0.0 - * - * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. - * - * @return {this} This Game Object instance. - */ - setSizeToFrame: function (frame) - { - if (frame === undefined) { frame = this.frame; } - - this.width = frame.realWidth; - this.height = frame.realHeight; - - return this; - }, - - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Components.Size#setSize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setSize: function (width, height) - { - this.width = width; - this.height = height; - - return this; - }, - - /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Components.Size#setDisplaySize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setDisplaySize: function (width, height) - { - this.displayWidth = width; - this.displayHeight = height; - - return this; - } - -}; - -module.exports = Size; - - -/***/ }), -/* 577 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the Scroll Factor of a Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor - * @since 3.0.0 - */ - -var ScrollFactor = { - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorX: 1, - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorY: 1, - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor - * @since 3.0.0 - * - * @param {number} x - The horizontal scroll factor of this Game Object. - * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. - * - * @return {this} This Game Object instance. - */ - setScrollFactor: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollFactorX = x; - this.scrollFactorY = y; - - return this; - } - -}; - -module.exports = ScrollFactor; - - -/***/ }), -/* 578 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ScaleModes = __webpack_require__(59); - -/** - * Provides methods used for getting and setting the scale of a Game Object. - * - * @name Phaser.GameObjects.Components.ScaleMode - * @since 3.0.0 - */ - -var ScaleMode = { - - _scaleMode: ScaleModes.DEFAULT, - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @name Phaser.GameObjects.Components.ScaleMode#scaleMode - * @type {Phaser.ScaleModes} - * @since 3.0.0 - */ - scaleMode: { - - get: function () - { - return this._scaleMode; - }, - - set: function (value) - { - if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) - { - this._scaleMode = value; - } - } - - }, - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode - * @since 3.0.0 - * - * @param {Phaser.ScaleModes} value - The Scale Mode to be used by this Game Object. - * - * @return {this} This Game Object instance. - */ - setScaleMode: function (value) - { - this.scaleMode = value; - - return this; - } - -}; - -module.exports = ScaleMode; - - -/***/ }), -/* 579 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the origin of a Game Object. - * Values are normalized, given in the range 0 to 1. - * Display values contain the calculated pixel values. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Origin - * @since 3.0.0 - */ - -var Origin = { - - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Origin#_originComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _originComponent: true, - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originX - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originX: 0.5, - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originY - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originY: 0.5, - - // private + read only - _displayOriginX: 0, - _displayOriginY: 0, - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginX - * @type {float} - * @since 3.0.0 - */ - displayOriginX: { - - get: function () - { - return this._displayOriginX; - }, - - set: function (value) - { - this._displayOriginX = value; - this.originX = value / this.width; - } - - }, - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginY - * @type {float} - * @since 3.0.0 - */ - displayOriginY: { - - get: function () - { - return this._displayOriginY; - }, - - set: function (value) - { - this._displayOriginY = value; - this.originY = value / this.height; - } - - }, - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * - * @method Phaser.GameObjects.Components.Origin#setOrigin - * @since 3.0.0 - * - * @param {number} [x=0.5] - The horizontal origin value. - * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. - * - * @return {this} This Game Object instance. - */ - setOrigin: function (x, y) - { - if (x === undefined) { x = 0.5; } - if (y === undefined) { y = x; } - - this.originX = x; - this.originY = y; - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - * - * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - setOriginFromFrame: function () - { - if (!this.frame || !this.frame.customPivot) - { - return this.setOrigin(); - } - else - { - this.originX = this.frame.pivotX; - this.originY = this.frame.pivotY; - } - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * - * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin - * @since 3.0.0 - * - * @param {number} [x=0] - The horizontal display origin value. - * @param {number} [y=x] - The vertical display origin value. If not defined it will be set to the value of `x`. - * - * @return {this} This Game Object instance. - */ - setDisplayOrigin: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.displayOriginX = x; - this.displayOriginY = y; - - return this; - }, - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - * - * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - updateDisplayOrigin: function () - { - this._displayOriginX = Math.round(this.originX * this.width); - this._displayOriginY = Math.round(this.originY * this.height); - - return this; - } - -}; - -module.exports = Origin; - - -/***/ }), -/* 580 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the transform values of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.MatrixStack - * @since 3.2.0 - */ - -var MatrixStack = { - - /** - * The matrix stack. - * - * @name Phaser.GameObjects.Components.MatrixStack#matrixStack - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - matrixStack: null, - - /** - * The current matrix. - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrix - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - currentMatrix: null, - - /** - * The current index of the top of the matrix stack. - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex - * @type {integer} - * @private - * @since 3.2.0 - */ - currentMatrixIndex: 0, - - /** - * Initialize the matrix stack. - * - * @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - initMatrixStack: function () - { - this.matrixStack = new Float32Array(6000); // up to 1000 matrices - this.currentMatrix = new Float32Array([ 1, 0, 0, 1, 0, 0 ]); - this.currentMatrixIndex = 0; - - return this; - }, - - /** - * Push the current matrix onto the matrix stack. - * - * @method Phaser.GameObjects.Components.MatrixStack#save - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - save: function () - { - if (this.currentMatrixIndex >= this.matrixStack.length) { return this; } - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - this.currentMatrixIndex += 6; - - matrixStack[currentMatrixIndex + 0] = currentMatrix[0]; - matrixStack[currentMatrixIndex + 1] = currentMatrix[1]; - matrixStack[currentMatrixIndex + 2] = currentMatrix[2]; - matrixStack[currentMatrixIndex + 3] = currentMatrix[3]; - matrixStack[currentMatrixIndex + 4] = currentMatrix[4]; - matrixStack[currentMatrixIndex + 5] = currentMatrix[5]; - - return this; - }, - - /** - * Pop the top of the matrix stack into the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#restore - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - restore: function () - { - if (this.currentMatrixIndex <= 0) { return this; } - - this.currentMatrixIndex -= 6; - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - - currentMatrix[0] = matrixStack[currentMatrixIndex + 0]; - currentMatrix[1] = matrixStack[currentMatrixIndex + 1]; - currentMatrix[2] = matrixStack[currentMatrixIndex + 2]; - currentMatrix[3] = matrixStack[currentMatrixIndex + 3]; - currentMatrix[4] = matrixStack[currentMatrixIndex + 4]; - currentMatrix[5] = matrixStack[currentMatrixIndex + 5]; - - return this; - }, - - /** - * Resets the current matrix to the identity matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#loadIdentity - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - loadIdentity: function () - { - this.setTransform(1, 0, 0, 1, 0, 0); - - return this; - }, - - /** - * Transform the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#transform - * @since 3.2.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This Game Object instance. - */ - transform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[0] = m0 * a + m2 * b; - currentMatrix[1] = m1 * a + m3 * b; - currentMatrix[2] = m0 * c + m2 * d; - currentMatrix[3] = m1 * c + m3 * d; - currentMatrix[4] = m0 * tx + m2 * ty + m4; - currentMatrix[5] = m1 * tx + m3 * ty + m5; - - return this; - }, - - /** - * Set a transform matrix as the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#setTransform - * @since 3.2.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This Game Object instance. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - - currentMatrix[0] = a; - currentMatrix[1] = b; - currentMatrix[2] = c; - currentMatrix[3] = d; - currentMatrix[4] = tx; - currentMatrix[5] = ty; - - return this; - }, - - /** - * Translate the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#translate - * @since 3.2.0 - * - * @param {number} x - The horizontal translation value. - * @param {number} y - The vertical translation value. - * - * @return {this} This Game Object instance. - */ - translate: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[4] = m0 * x + m2 * y + m4; - currentMatrix[5] = m1 * x + m3 * y + m5; - - return this; - }, - - /** - * Scale the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#scale - * @since 3.2.0 - * - * @param {number} x - The horizontal scale value. - * @param {number} y - The vertical scale value. - * - * @return {this} This Game Object instance. - */ - scale: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - - currentMatrix[0] = m0 * x; - currentMatrix[1] = m1 * x; - currentMatrix[2] = m2 * y; - currentMatrix[3] = m3 * y; - - return this; - }, - - /** - * Rotate the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#rotate - * @since 3.2.0 - * - * @param {number} t - The angle of rotation, in radians. - * - * @return {this} This Game Object instance. - */ - rotate: function (t) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var st = Math.sin(t); - var ct = Math.cos(t); - - currentMatrix[0] = m0 * ct + m2 * st; - currentMatrix[1] = m1 * ct + m3 * st; - currentMatrix[2] = m0 * -st + m2 * ct; - currentMatrix[3] = m1 * -st + m3 * ct; - - return this; - } - -}; - -module.exports = MatrixStack; - - -/***/ }), -/* 581 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapMask = __webpack_require__(214); -var GeometryMask = __webpack_require__(213); - -/** - * Provides methods used for getting and setting the mask of a Game Object. - * - * @name Phaser.GameObjects.Components.Mask - * @since 3.0.0 - */ - -var Mask = { - - /** - * The Mask this Game Object is using during render. - * - * @name Phaser.GameObjects.Components.Mask#mask - * @type {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} - * @since 3.0.0 - */ - mask: null, - - /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * @method Phaser.GameObjects.Components.Mask#setMask - * @since 3.6.2 - * - * @param {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} mask - The mask this Game Object will use when rendering. - * - * @return {this} This Game Object instance. - */ - setMask: function (mask) - { - this.mask = mask; - - return this; - }, - - /** - * Clears the mask that this Game Object was using. - * - * @method Phaser.GameObjects.Components.Mask#clearMask - * @since 3.6.2 - * - * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? - * - * @return {this} This Game Object instance. - */ - clearMask: function (destroyMask) - { - if (destroyMask === undefined) { destroyMask = false; } - - if (destroyMask) - { - this.mask.destroy(); - } - - this.mask = null; - - return this; - }, - - /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * - * @method Phaser.GameObjects.Components.Mask#createBitmapMask - * @since 3.6.2 - * - * @param {Phaser.GameObjects.GameObject} [renderable] - A renderable Game Object that uses a texture, such as a Sprite. - * - * @return {Phaser.Display.Masks.BitmapMask} This Bitmap Mask that was created. - */ - createBitmapMask: function (renderable) - { - if (renderable === undefined && this.texture) - { - // eslint-disable-next-line consistent-this - renderable = this; - } - - return new BitmapMask(this.scene, renderable); - }, - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * - * @method Phaser.GameObjects.Components.Mask#createGeometryMask - * @since 3.6.2 - * - * @param {Phaser.GameObjects.Graphics} [graphics] - A Graphics Game Object. The geometry within it will be used as the mask. - * - * @return {Phaser.Display.Masks.GeometryMask} This Geometry Mask that was created. - */ - createGeometryMask: function (graphics) - { - if (graphics === undefined && this.type === 'Graphics') - { - // eslint-disable-next-line consistent-this - graphics = this; - } - - return new GeometryMask(this.scene, graphics); - } - -}; - -module.exports = Mask; - - -/***/ }), -/* 582 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); -var RotateAround = __webpack_require__(292); -var Vector2 = __webpack_require__(6); - -/** - * Provides methods used for obtaining the bounds of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.GetBounds - * @since 3.0.0 - */ - -var GetBounds = { - - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getCenter - * @since 3.0.0 - * - * @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. - * - * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. - */ - getCenter: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); - output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); - - return output; - }, - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getTopLeft - * @since 3.0.0 - * - * @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, includeParent) - { - 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); - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getTopRight - * @since 3.0.0 - * - * @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, includeParent) - { - 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); - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft - * @since 3.0.0 - * - * @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, includeParent) - { - 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; - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomRight - * @since 3.0.0 - * - * @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, includeParent) - { - 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; - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the bounds of this Game Object, regardless of origin. - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * - * @method Phaser.GameObjects.Components.GetBounds#getBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [output,$return] - * - * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. - * - * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. - */ - getBounds: function (output) - { - if (output === undefined) { output = new Rectangle(); } - - // We can use the output object to temporarily store the x/y coords in: - - var TLx, TLy, TRx, TRy, BLx, BLy, BRx, BRy; - - // Instead of doing a check if parent container is - // defined per corner we only do it once. - if (this.parentContainer) - { - var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); - - this.getTopLeft(output); - parentMatrix.transformPoint(output.x, output.y, output); - - TLx = output.x; - TLy = output.y; - - this.getTopRight(output); - parentMatrix.transformPoint(output.x, output.y, output); - - TRx = output.x; - TRy = output.y; - - this.getBottomLeft(output); - parentMatrix.transformPoint(output.x, output.y, output); - - BLx = output.x; - BLy = output.y; - - this.getBottomRight(output); - parentMatrix.transformPoint(output.x, output.y, output); - - BRx = output.x; - BRy = output.y; - } - else - { - this.getTopLeft(output); - - TLx = output.x; - TLy = output.y; - - this.getTopRight(output); - - TRx = output.x; - TRy = output.y; - - this.getBottomLeft(output); - - BLx = output.x; - BLy = output.y; - - this.getBottomRight(output); - - BRx = output.x; - BRy = output.y; - } - - output.x = Math.min(TLx, TRx, BLx, BRx); - output.y = Math.min(TLy, TRy, BLy, BRy); - output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; - output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; - - return output; - } - -}; - -module.exports = GetBounds; - - -/***/ }), -/* 583 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for visually flipping a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Flip - * @since 3.0.0 - */ - -var Flip = { - - /** - * The horizontally flipped state of the Game Object. - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipX: false, - - /** - * The vertically flipped state of the Game Object. - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipY: false, - - /** - * Toggles the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipX - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - toggleFlipX: function () - { - this.flipX = !this.flipX; - - return this; - }, - - /** - * Toggles the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipY - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - toggleFlipY: function () - { - this.flipY = !this.flipY; - - return this; - }, - - /** - * Sets the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipX - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {this} This Game Object instance. - */ - setFlipX: function (value) - { - this.flipX = value; - - return this; - }, - - /** - * Sets the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipY - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {this} This Game Object instance. - */ - setFlipY: function (value) - { - this.flipY = value; - - return this; - }, - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlip - * @since 3.0.0 - * - * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {this} This Game Object instance. - */ - setFlip: function (x, y) - { - this.flipX = x; - this.flipY = y; - - return this; - }, - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - * - * @method Phaser.GameObjects.Components.Flip#resetFlip - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - resetFlip: function () - { - this.flipX = false; - this.flipY = false; - - return this; - } - -}; - -module.exports = Flip; - - -/***/ }), -/* 584 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for setting the depth of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Depth - * @since 3.0.0 - */ - -var Depth = { - - /** - * Private internal value. Holds the depth of the Game Object. - * - * @name Phaser.GameObjects.Components.Depth#_depth - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - _depth: 0, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @name Phaser.GameObjects.Components.Depth#depth - * @type {number} - * @since 3.0.0 - */ - depth: { - - get: function () - { - return this._depth; - }, - - set: function (value) - { - this.scene.sys.queueDepthSort(); - this._depth = value; - } - - }, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @method Phaser.GameObjects.Components.Depth#setDepth - * @since 3.0.0 - * - * @param {integer} value - The depth of this Game Object. - * - * @return {this} This Game Object instance. - */ - setDepth: function (value) - { - if (value === undefined) { value = 0; } - - this.depth = value; - - return this; - } - -}; - -module.exports = Depth; - - -/***/ }), -/* 585 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for calculating and setting the size of a non-Frame based Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.ComputedSize - * @since 3.0.0 - */ - -var ComputedSize = { - - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#width - * @type {number} - * @since 3.0.0 - */ - width: 0, - - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.width; - }, - - set: function (value) - { - this.scaleX = value / this.width; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.height; - }, - - set: function (value) - { - this.scaleY = value / this.height; - } - - }, - - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Components.ComputedSize#setSize - * @since 3.4.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setSize: function (width, height) - { - this.width = width; - this.height = height; - - return this; - }, - - /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize - * @since 3.4.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setDisplaySize: function (width, height) - { - this.displayWidth = width; - this.displayHeight = height; - - return this; - } - -}; - -module.exports = ComputedSize; - - -/***/ }), -/* 586 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlendModes = __webpack_require__(51); - -/** - * Provides methods used for setting the blend mode of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.BlendMode - * @since 3.0.0 - */ - -var BlendMode = { - - /** - * Private internal value. Holds the current blend mode. - * - * @name Phaser.GameObjects.Components.BlendMode#_blendMode - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - _blendMode: BlendModes.NORMAL, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @name Phaser.GameObjects.Components.BlendMode#blendMode - * @type {(Phaser.BlendModes|string)} - * @since 3.0.0 - */ - blendMode: { - - get: function () - { - return this._blendMode; - }, - - set: function (value) - { - if (typeof value === 'string') - { - value = BlendModes[value]; - } - - value |= 0; - - if (value >= 0) - { - this._blendMode = value; - } - } - - }, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @method Phaser.GameObjects.Components.BlendMode#setBlendMode - * @since 3.0.0 - * - * @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST. - * - * @return {this} This Game Object instance. - */ - setBlendMode: function (value) - { - this.blendMode = value; - - return this; - } - -}; - -module.exports = BlendMode; - - -/***/ }), -/* 587 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); - -// bitmask flag for GameObject.renderMask -var _FLAG = 2; // 0010 - -/** - * Provides methods used for setting the alpha properties of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Alpha - * @since 3.0.0 - */ - -var Alpha = { - - /** - * Private internal value. Holds the global alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alpha - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alpha: 1, - - /** - * Private internal value. Holds the top-left alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaTL - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaTL: 1, - - /** - * Private internal value. Holds the top-right alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaTR - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaTR: 1, - - /** - * Private internal value. Holds the bottom-left alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaBL - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaBL: 1, - - /** - * Private internal value. Holds the bottom-right alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaBR - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaBR: 1, - - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - * - * @method Phaser.GameObjects.Components.Alpha#clearAlpha - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - clearAlpha: function () - { - return this.setAlpha(1); - }, - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * - * @method Phaser.GameObjects.Components.Alpha#setAlpha - * @since 3.0.0 - * - * @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. - * @param {float} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. - * @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. - * - * @return {this} This Game Object instance. - */ - setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 1; } - - // Treat as if there is only one alpha value for the whole Game Object - if (topRight === undefined) - { - this.alpha = topLeft; - } - else - { - this._alphaTL = Clamp(topLeft, 0, 1); - this._alphaTR = Clamp(topRight, 0, 1); - this._alphaBL = Clamp(bottomLeft, 0, 1); - this._alphaBR = Clamp(bottomRight, 0, 1); - } - - return this; - }, - - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - * - * @name Phaser.GameObjects.Components.Alpha#alpha - * @type {float} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this._alpha; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alpha = v; - this._alphaTL = v; - this._alphaTR = v; - this._alphaBL = v; - this._alphaBR = v; - - if (v === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopLeft: { - - get: function () - { - return this._alphaTL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopRight: { - - get: function () - { - return this._alphaTR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomLeft: { - - get: function () - { - return this._alphaBL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomRight: { - - get: function () - { - return this._alphaBR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - } - -}; - -module.exports = Alpha; - - -/***/ }), -/* 588 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(46); -var GetTop = __webpack_require__(44); -var SetRight = __webpack_require__(45); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned in the top right of the other. - * - * @function Phaser.Display.Align.In.TopRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopRight = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); - - return gameObject; -}; - -module.exports = TopRight; - - -/***/ }), -/* 589 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(48); -var GetTop = __webpack_require__(44); -var SetLeft = __webpack_require__(47); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned in the top left of the other. - * - * @function Phaser.Display.Align.In.TopLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopLeft = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); - - return gameObject; -}; - -module.exports = TopLeft; - - -/***/ }), -/* 590 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterX = __webpack_require__(92); -var GetTop = __webpack_require__(44); -var SetCenterX = __webpack_require__(91); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned in the top center of the other. - * - * @function Phaser.Display.Align.In.TopCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopCenter = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); - - return gameObject; -}; - -module.exports = TopCenter; - - -/***/ }), -/* 591 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(89); -var GetRight = __webpack_require__(46); -var SetCenterY = __webpack_require__(90); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned in the right center of the other. - * - * @function Phaser.Display.Align.In.RightCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightCenter = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = RightCenter; - - -/***/ }), -/* 592 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(89); -var GetLeft = __webpack_require__(48); -var SetCenterY = __webpack_require__(90); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned in the left center of the other. - * - * @function Phaser.Display.Align.In.LeftCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = LeftCenter; - - -/***/ }), -/* 593 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetCenterX = __webpack_require__(91); -var SetCenterY = __webpack_require__(90); - -/** - * Positions the Game Object so that it is centered on the given coordinates. - * - * @function Phaser.Display.Bounds.CenterOn - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} x - The horizontal coordinate to position the Game Object on. - * @param {number} y - The vertical coordinate to position the Game Object on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var CenterOn = function (gameObject, x, y) -{ - SetCenterX(gameObject, x); - - return SetCenterY(gameObject, y); -}; - -module.exports = CenterOn; - - -/***/ }), -/* 594 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CenterOn = __webpack_require__(593); -var GetCenterX = __webpack_require__(92); -var GetCenterY = __webpack_require__(89); - -/** - * Takes given Game Object and aligns it so that it is positioned in the center of the other. - * - * @function Phaser.Display.Align.In.Center - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var Center = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = Center; - - -/***/ }), -/* 595 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetRight = __webpack_require__(46); -var SetBottom = __webpack_require__(49); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. - * - * @function Phaser.Display.Align.In.BottomRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomRight = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = BottomRight; - - -/***/ }), -/* 596 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetLeft = __webpack_require__(48); -var SetBottom = __webpack_require__(49); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. - * - * @function Phaser.Display.Align.In.BottomLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = BottomLeft; - - -/***/ }), -/* 597 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetCenterX = __webpack_require__(92); -var SetBottom = __webpack_require__(49); -var SetCenterX = __webpack_require__(91); - -/** - * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. - * - * @function Phaser.Display.Align.In.BottomCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = BottomCenter; - - -/***/ }), -/* 598 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ALIGN_CONST = __webpack_require__(299); - -var AlignInMap = []; - -AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(597); -AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(596); -AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(595); -AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(594); -AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(592); -AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(591); -AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(590); -AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(589); -AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(588); - -/** - * Takes given Game Object and aligns it so that it is positioned relative to the other. - * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. - * - * @function Phaser.Display.Align.In.QuickSet - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [child,$return] - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var QuickSet = function (child, alignIn, position, offsetX, offsetY) -{ - return AlignInMap[position](child, alignIn, offsetX, offsetY); -}; - -module.exports = QuickSet; - - -/***/ }), -/* 599 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Actions - */ - -module.exports = { - - Angle: __webpack_require__(1007), - Call: __webpack_require__(1006), - GetFirst: __webpack_require__(1005), - GetLast: __webpack_require__(1004), - GridAlign: __webpack_require__(1003), - IncAlpha: __webpack_require__(1002), - IncX: __webpack_require__(1001), - IncXY: __webpack_require__(1000), - IncY: __webpack_require__(999), - PlaceOnCircle: __webpack_require__(998), - PlaceOnEllipse: __webpack_require__(997), - PlaceOnLine: __webpack_require__(996), - PlaceOnRectangle: __webpack_require__(995), - PlaceOnTriangle: __webpack_require__(994), - PlayAnimation: __webpack_require__(993), - PropertyValueInc: __webpack_require__(35), - PropertyValueSet: __webpack_require__(25), - RandomCircle: __webpack_require__(992), - RandomEllipse: __webpack_require__(991), - RandomLine: __webpack_require__(990), - RandomRectangle: __webpack_require__(989), - RandomTriangle: __webpack_require__(988), - Rotate: __webpack_require__(987), - RotateAround: __webpack_require__(986), - RotateAroundDistance: __webpack_require__(985), - ScaleX: __webpack_require__(984), - ScaleXY: __webpack_require__(983), - ScaleY: __webpack_require__(982), - SetAlpha: __webpack_require__(981), - SetBlendMode: __webpack_require__(980), - SetDepth: __webpack_require__(979), - SetHitArea: __webpack_require__(978), - SetOrigin: __webpack_require__(977), - SetRotation: __webpack_require__(976), - SetScale: __webpack_require__(975), - SetScaleX: __webpack_require__(974), - SetScaleY: __webpack_require__(973), - SetTint: __webpack_require__(972), - SetVisible: __webpack_require__(971), - SetX: __webpack_require__(970), - SetXY: __webpack_require__(969), - SetY: __webpack_require__(968), - ShiftPosition: __webpack_require__(967), - Shuffle: __webpack_require__(966), - SmootherStep: __webpack_require__(965), - SmoothStep: __webpack_require__(964), - Spread: __webpack_require__(963), - ToggleVisible: __webpack_require__(962), - WrapInRectangle: __webpack_require__(961) - -}; - - -/***/ }), -/* 600 */ -/***/ (function(module, exports) { - -/** -* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 -* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ -* Cameron Foale (http://www.kibibu.com) -*/ -if (typeof window.Uint32Array !== 'function' && typeof window.Uint32Array !== 'object') -{ - var CheapArray = function (fakeType) - { - var proto = new Array(); // jshint ignore:line - - window[fakeType] = function(arg) { - - if (typeof(arg) === 'number') - { - Array.call(this, arg); - - this.length = arg; - - for (var i = 0; i < this.length; i++) - { - this[i] = 0; - } - } - else - { - Array.call(this, arg.length); - - this.length = arg.length; - - for (var i = 0; i < this.length; i++) - { - this[i] = arg[i]; - } - } - }; - - window[fakeType].prototype = proto; - window[fakeType].constructor = window[fakeType]; - }; - - CheapArray('Float32Array'); // jshint ignore:line - CheapArray('Uint32Array'); // jshint ignore:line - CheapArray('Uint16Array'); // jshint ignore:line - CheapArray('Int16Array'); // jshint ignore:line - CheapArray('ArrayBuffer'); // jshint ignore:line -} - - -/***/ }), -/* 601 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global) {// References: -// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ -// https://gist.github.com/1579671 -// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision -// https://gist.github.com/timhall/4078614 -// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame - -// Expected to be used with Browserfiy -// Browserify automatically detects the use of `global` and passes the -// correct reference of `global`, `self`, and finally `window` - -// Date.now -if (!(Date.now && Date.prototype.getTime)) { - Date.now = function now() { - return new Date().getTime(); - }; -} - -// performance.now -if (!(global.performance && global.performance.now)) { - var startTime = Date.now(); - if (!global.performance) { - global.performance = {}; - } - global.performance.now = function () { - return Date.now() - startTime; - }; -} - -// requestAnimationFrame -var lastTime = Date.now(); -var vendors = ['ms', 'moz', 'webkit', 'o']; - -for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { - global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; - global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || - global[vendors[x] + 'CancelRequestAnimationFrame']; -} - -if (!global.requestAnimationFrame) { - global.requestAnimationFrame = function (callback) { - if (typeof callback !== 'function') { - throw new TypeError(callback + 'is not a function'); - } - - var currentTime = Date.now(), - delay = 16 + lastTime - currentTime; - - if (delay < 0) { - delay = 0; - } - - lastTime = currentTime; - - return setTimeout(function () { - lastTime = Date.now(); - callback(performance.now()); - }, delay); - }; -} - -if (!global.cancelAnimationFrame) { - global.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; -} - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(215))) - -/***/ }), -/* 602 */ -/***/ (function(module, exports) { - -/** - * performance.now - */ -(function () { - - if ('performance' in window === false) - { - window.performance = {}; - } - - // Thanks IE8 - Date.now = (Date.now || function () { - return new Date().getTime(); - }); - - if ('now' in window.performance === false) - { - var nowOffset = Date.now(); - - if (performance.timing && performance.timing.navigationStart) - { - nowOffset = performance.timing.navigationStart; - } - - window.performance.now = function now () - { - return Date.now() - nowOffset; - } - } - -})(); - - -/***/ }), -/* 603 */ -/***/ (function(module, exports) { - -// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc -if (!Math.trunc) { - Math.trunc = function trunc(x) { - return x < 0 ? Math.ceil(x) : Math.floor(x); - }; -} - - -/***/ }), -/* 604 */ -/***/ (function(module, exports) { - -/** -* A polyfill for Function.prototype.bind -*/ -if (!Function.prototype.bind) { - - /* jshint freeze: false */ - Function.prototype.bind = (function () { - - var slice = Array.prototype.slice; - - return function (thisArg) { - - var target = this, boundArgs = slice.call(arguments, 1); - - if (typeof target !== 'function') - { - throw new TypeError(); - } - - function bound() { - var args = boundArgs.concat(slice.call(arguments)); - target.apply(this instanceof bound ? this : thisArg, args); - } - - bound.prototype = (function F(proto) { - if (proto) - { - F.prototype = proto; - } - - if (!(this instanceof F)) - { - /* jshint supernew: true */ - return new F; - } - })(target.prototype); - - return bound; - }; - })(); -} - - - -/***/ }), -/* 605 */ -/***/ (function(module, exports) { - -/** - * Also fix for the absent console in IE9 - */ -if (!window.console) -{ - window.console = {}; - window.console.log = window.console.assert = function(){}; - window.console.warn = window.console.assert = function(){}; -} - - -/***/ }), -/* 606 */ -/***/ (function(module, exports) { - -/* Copyright 2013 Chris Wilson - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - -This monkeypatch library is intended to be included in projects that are -written to the proper AudioContext spec (instead of webkitAudioContext), -and that use the new naming and proper bits of the Web Audio API (e.g. -using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may -have to run on systems that only support the deprecated bits. - -This library should be harmless to include if the browser supports -unprefixed "AudioContext", and/or if it supports the new names. - -The patches this library handles: -if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). -if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or -noteGrainOn(), depending on parameters. - -The following aliases only take effect if the new names are not already in place: - -AudioBufferSourceNode.stop() is aliased to noteOff() -AudioContext.createGain() is aliased to createGainNode() -AudioContext.createDelay() is aliased to createDelayNode() -AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() -AudioContext.createPeriodicWave() is aliased to createWaveTable() -OscillatorNode.start() is aliased to noteOn() -OscillatorNode.stop() is aliased to noteOff() -OscillatorNode.setPeriodicWave() is aliased to setWaveTable() -AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() - -This library does NOT patch the enumerated type changes, as it is -recommended in the specification that implementations support both integer -and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel -BiquadFilterNode.type and OscillatorNode.type. - -*/ - -(function () { - - function fixSetTarget(param) { - if (!param) // if NYI, just return - return; - if (!param.setTargetAtTime) - param.setTargetAtTime = param.setTargetValueAtTime; - } - - if (window.hasOwnProperty('webkitAudioContext') && - !window.hasOwnProperty('AudioContext')) { - window.AudioContext = webkitAudioContext; - - if (!AudioContext.prototype.hasOwnProperty('createGain')) - AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; - if (!AudioContext.prototype.hasOwnProperty('createDelay')) - AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; - if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) - AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; - if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) - AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; - - - AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; - AudioContext.prototype.createGain = function() { - var node = this.internal_createGain(); - fixSetTarget(node.gain); - return node; - }; - - AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; - AudioContext.prototype.createDelay = function(maxDelayTime) { - var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); - fixSetTarget(node.delayTime); - return node; - }; - - AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; - AudioContext.prototype.createBufferSource = function() { - var node = this.internal_createBufferSource(); - if (!node.start) { - node.start = function ( when, offset, duration ) { - if ( offset || duration ) - this.noteGrainOn( when || 0, offset, duration ); - else - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function( when, offset, duration ) { - if( typeof duration !== 'undefined' ) - node.internal_start( when || 0, offset, duration ); - else - node.internal_start( when || 0, offset || 0 ); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - fixSetTarget(node.playbackRate); - return node; - }; - - AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; - AudioContext.prototype.createDynamicsCompressor = function() { - var node = this.internal_createDynamicsCompressor(); - fixSetTarget(node.threshold); - fixSetTarget(node.knee); - fixSetTarget(node.ratio); - fixSetTarget(node.reduction); - fixSetTarget(node.attack); - fixSetTarget(node.release); - return node; - }; - - AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; - AudioContext.prototype.createBiquadFilter = function() { - var node = this.internal_createBiquadFilter(); - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - fixSetTarget(node.Q); - fixSetTarget(node.gain); - return node; - }; - - if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { - AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; - AudioContext.prototype.createOscillator = function() { - var node = this.internal_createOscillator(); - if (!node.start) { - node.start = function ( when ) { - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function ( when ) { - node.internal_start( when || 0); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - if (!node.setPeriodicWave) - node.setPeriodicWave = node.setWaveTable; - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - return node; - }; - } - } - - if (window.hasOwnProperty('webkitOfflineAudioContext') && - !window.hasOwnProperty('OfflineAudioContext')) { - window.OfflineAudioContext = webkitOfflineAudioContext; - } - -})(); - - -/***/ }), -/* 607 */ -/***/ (function(module, exports) { - -/** -* A polyfill for Array.isArray -*/ -if (!Array.isArray) -{ - Array.isArray = function (arg) - { - return Object.prototype.toString.call(arg) === '[object Array]'; - }; -} - - -/***/ }), -/* 608 */ -/***/ (function(module, exports) { - -/** -* A polyfill for Array.forEach -* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach -*/ -if (!Array.prototype.forEach) -{ - Array.prototype.forEach = function (fun /*, thisArg */) - { - 'use strict'; - - if (this === void 0 || this === null) - { - throw new TypeError(); - } - - var t = Object(this); - var len = t.length >>> 0; - - if (typeof fun !== 'function') - { - throw new TypeError(); - } - - var thisArg = arguments.length >= 2 ? arguments[1] : void 0; - - for (var i = 0; i < len; i++) - { - if (i in t) - { - fun.call(thisArg, t[i], i, t); - } - } - }; -} - - -/***/ }), -/* 609 */ -/***/ (function(module, exports, __webpack_require__) { - -__webpack_require__(608); -__webpack_require__(607); -__webpack_require__(606); -__webpack_require__(605); -__webpack_require__(604); -__webpack_require__(603); -__webpack_require__(602); -__webpack_require__(601); -__webpack_require__(600); - - -/***/ }), -/* 610 */, -/* 611 */, -/* 612 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes the given string and reverses it, returning the reversed string. - * For example if given the string `Atari 520ST` it would return `TS025 iratA`. - * - * @function Phaser.Utils.String.ReverseString - * @since 3.0.0 - * - * @param {string} string - The string to be reversed. - * - * @return {string} The reversed string. - */ -var ReverseString = function (string) -{ - return string.split('').reverse().join(''); -}; - -module.exports = ReverseString; - - -/***/ }), -/* 613 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes a string and replaces instances of markers with values in the given array. - * The markers take the form of `%1`, `%2`, etc. I.e.: - * - * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` - * - * @function Phaser.Utils.String.Format - * @since 3.0.0 - * - * @param {string} string - The string containing the replacement markers. - * @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead. - * - * @return {string} The string containing replaced values. - */ -var Format = function (string, values) -{ - return string.replace(/%([0-9]+)/g, function (s, n) - { - return values[Number(n) - 1]; - }); -}; - -module.exports = Format; - - -/***/ }), -/* 614 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils.String - */ - -module.exports = { - - Format: __webpack_require__(613), - Pad: __webpack_require__(133), - Reverse: __webpack_require__(612), - UppercaseFirst: __webpack_require__(256) - -}; - - -/***/ }), -/* 615 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(33); - -/** - * Creates a new Object using all values from obj1. - * - * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. - * - * @function Phaser.Utils.Object.MergeRight - * @since 3.0.0 - * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] - * - * @return {object} [description] - */ -var MergeRight = function (obj1, obj2) -{ - var clone = Clone(obj1); - - for (var key in obj2) - { - if (clone.hasOwnProperty(key)) - { - clone[key] = obj2[key]; - } - } - - return clone; -}; - -module.exports = MergeRight; - - -/***/ }), -/* 616 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Verifies that an object contains all requested keys - * - * @function Phaser.Utils.Object.HasAll - * @since 3.0.0 - * - * @param {object} source - an object on which to check for key existence - * @param {string[]} keys - an array of keys to ensure the source object contains - * - * @return {boolean} true if the source object contains all keys, false otherwise. - */ -var HasAll = function (source, keys) -{ - for (var i = 0; i < keys.length; i++) - { - if (!source.hasOwnProperty(keys[i])) - { - return false; - } - } - - return true; -}; - -module.exports = HasAll; - - -/***/ }), -/* 617 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); -var Clamp = __webpack_require__(23); - -/** - * [description] - * - * @function Phaser.Utils.Object.GetMinMaxValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} defaultValue - [description] - * - * @return {number} [description] - */ -var GetMinMaxValue = function (source, key, min, max, defaultValue) -{ - if (defaultValue === undefined) { defaultValue = min; } - - var value = GetValue(source, key, defaultValue); - - return Clamp(value, min, max); -}; - -module.exports = GetMinMaxValue; - - -/***/ }), -/* 618 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils.Object - */ - -module.exports = { - - Clone: __webpack_require__(33), - Extend: __webpack_require__(17), - GetAdvancedValue: __webpack_require__(10), - GetFastValue: __webpack_require__(1), - GetMinMaxValue: __webpack_require__(617), - GetValue: __webpack_require__(4), - HasAll: __webpack_require__(616), - HasAny: __webpack_require__(420), - HasValue: __webpack_require__(111), - IsPlainObject: __webpack_require__(8), - Merge: __webpack_require__(94), - MergeRight: __webpack_require__(615) - -}; - - -/***/ }), -/* 619 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils - */ - -module.exports = { - - Array: __webpack_require__(147), - Objects: __webpack_require__(618), - String: __webpack_require__(614) - -}; - - -/***/ }), -/* 620 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(11); -var ParseToTilemap = __webpack_require__(216); - -/** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * - * @method Phaser.GameObjects.GameObjectFactory#tilemap - * @since 3.0.0 - * - * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param {integer} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the - * default. - * @param {integer} [tileHeight=32] - The height of a tile in pixels. Pass in `null` to leave as the - * default. - * @param {integer} [width=10] - The width of the map in tiles. Pass in `null` to leave as the - * default. - * @param {integer} [height=10] - The height of the map in tiles. Pass in `null` to leave as the - * default. - * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. Pass in `null` for no data. - * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, width, height, data, insertNull) -{ - // Allow users to specify null to indicate that they want the default value, since null is - // shorter & more legible than undefined. Convert null to undefined to allow ParseToTilemap - // defaults to take effect. - - if (key === null) { key = undefined; } - if (tileWidth === null) { tileWidth = undefined; } - if (tileHeight === null) { tileHeight = undefined; } - if (width === null) { width = undefined; } - if (height === null) { height = undefined; } - - return ParseToTilemap(this.scene, key, tileWidth, tileHeight, width, height, data, insertNull); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 621 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var ParseToTilemap = __webpack_require__(216); - -/** - * @typedef {object} TilemapConfig - * - * @property {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @property {integer[][]} [data] - Instead of loading from the cache, you can also load directly from a 2D array of tile indexes. - * @property {integer} [tileWidth=32] - The width of a tile in pixels. - * @property {integer} [tileHeight=32] - The height of a tile in pixels. - * @property {integer} [width=10] - The width of the map in tiles. - * @property {integer} [height=10] - The height of the map in tiles. - * @property {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, - * in the map data are handled. If `true`, empty locations will get a value of `null`. If `false`, - * empty location will get a Tile object with an index of -1. If you've a large sparsely populated - * map and the tile data doesn't need to change then setting this value to `true` will help with - * memory consumption. However if your map is small or you need to update the tiles dynamically, - * then leave the default value set. - */ - -/** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * - * @method Phaser.GameObjects.GameObjectCreator#tilemap - * @since 3.0.0 - * - * @param {TilemapConfig} [config] - The config options for the Tilemap. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -GameObjectCreator.register('tilemap', function (config) -{ - // Defaults are applied in ParseToTilemap - var c = (config !== undefined) ? config : {}; - - return ParseToTilemap( - this.scene, - c.key, - c.tileWidth, - c.tileHeight, - c.width, - c.height, - c.data, - c.insertNull - ); -}); - - -/***/ }), -/* 622 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - var renderTiles = src.culledTiles; - var tileset = this.tileset; - var ctx = renderer.gameContext; - var tileCount = renderTiles.length; - var image = tileset.image.getSourceImage(); - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - ctx.globalAlpha = src.alpha; - - for (var index = 0; index < tileCount; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - - if (tileTexCoords === null) { continue; } - - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - tile.pixelX, tile.pixelY, - tile.width, tile.height - ); - } - - ctx.restore(); -}; - -module.exports = StaticTilemapLayerCanvasRenderer; - - -/***/ }), -/* 623 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.upload(camera); - - this.pipeline.drawStaticTilemapLayer(src, camera); -}; - -module.exports = StaticTilemapLayerWebGLRenderer; - - -/***/ }), -/* 624 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(623); -} - -if (true) -{ - renderCanvas = __webpack_require__(622); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 625 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - var renderTiles = src.culledTiles; - var length = renderTiles.length; - var image = src.tileset.image.getSourceImage(); - var tileset = this.tileset; - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - var ctx = renderer.gameContext; - - ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - for (var index = 0; index < length; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } - - var halfWidth = tile.width / 2; - var halfHeight = tile.height / 2; - - ctx.save(); - ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); - - if (tile.rotation !== 0) - { - ctx.rotate(tile.rotation); - } - - if (tile.flipX || tile.flipY) - { - ctx.scale(tile.flipX ? -1 : 1, tile.flipY ? -1 : 1); - } - - ctx.globalAlpha = src.alpha * tile.alpha; - - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - -halfWidth, -halfHeight, - tile.width, tile.height - ); - - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = DynamicTilemapLayerCanvasRenderer; - - -/***/ }), -/* 626 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - this.pipeline.batchDynamicTilemapLayer(src, camera); -}; - -module.exports = DynamicTilemapLayerWebGLRenderer; - - -/***/ }), -/* 627 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(626); -} - -if (true) -{ - renderCanvas = __webpack_require__(625); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 628 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tileset = __webpack_require__(137); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseTilesets = function (json) -{ - var tilesets = []; - var tilesetsNames = []; - - for (var i = 0; i < json.layer.length; i++) - { - var layer = json.layer[i]; - - // A relative filepath to the source image (within Weltmeister) is used for the name - var tilesetName = layer.tilesetName; - - // Only add unique tilesets that have a valid name. Collision layers will have a blank name. - if (tilesetName !== '' && tilesetsNames.indexOf(tilesetName) === -1) - { - tilesetsNames.push(tilesetName); - - // Tiles are stored with an ID relative to the tileset, rather than a globally unique ID - // across all tilesets. Also, tilesets in Weltmeister have no margin or padding. - tilesets.push(new Tileset(tilesetName, 0, layer.tilesize, layer.tilesize, 0, 0)); - } - } - - return tilesets; -}; - -module.exports = ParseTilesets; - - -/***/ }), -/* 629 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LayerData = __webpack_require__(104); -var Tile = __webpack_require__(66); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * @param {boolean} insertNull - [description] - * - * @return {array} [description] - */ -var ParseTileLayers = function (json, insertNull) -{ - var tileLayers = []; - - for (var i = 0; i < json.layer.length; i++) - { - var layer = json.layer[i]; - - var layerData = new LayerData({ - name: layer.name, - width: layer.width, - height: layer.height, - tileWidth: layer.tilesize, - tileHeight: layer.tilesize, - visible: layer.visible === 1 - }); - - var row = []; - var tileGrid = []; - - // Loop through the data field in the JSON. This is a 2D array containing the tile indexes, - // one after the other. The indexes are relative to the tileset that contains the tile. - for (var y = 0; y < layer.data.length; y++) - { - for (var x = 0; x < layer.data[y].length; x++) - { - // In Weltmeister, 0 = no tile, but the Tilemap API expects -1 = no tile. - var index = layer.data[y][x] - 1; - - var tile; - - if (index > -1) - { - tile = new Tile(layerData, index, x, y, layer.tilesize, layer.tilesize); - } - else - { - tile = insertNull - ? null - : new Tile(layerData, -1, x, y, layer.tilesize, layer.tilesize); - } - - row.push(tile); - } - - tileGrid.push(row); - row = []; - } - - layerData.data = tileGrid; - - tileLayers.push(layerData); - } - - return tileLayers; -}; - -module.exports = ParseTileLayers; - - -/***/ }), -/* 630 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Extend = __webpack_require__(17); - -/** - * Copy properties from tileset to tiles. - * - * @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.MapData} mapData - [description] - */ -var AssignTileProperties = function (mapData) -{ - var layerData; - var tile; - var sid; - var set; - var row; - - // go through each of the map data layers - for (var i = 0; i < mapData.layers.length; i++) - { - layerData = mapData.layers[i]; - - set = null; - - // rows of tiles - for (var j = 0; j < layerData.data.length; j++) - { - row = layerData.data[j]; - - // individual tiles - for (var k = 0; k < row.length; k++) - { - tile = row[k]; - - if (tile === null || tile.index < 0) - { - continue; - } - - // find the relevant tileset - sid = mapData.tiles[tile.index][2]; - set = mapData.tilesets[sid]; - - // Ensure that a tile's size matches its tileset - tile.width = set.tileWidth; - tile.height = set.tileHeight; - - // if that tile type has any properties, add them to the tile object - if (set.tileProperties && set.tileProperties[tile.index - set.firstgid]) - { - tile.properties = Extend( - tile.properties, set.tileProperties[tile.index - set.firstgid] - ); - } - } - } - } -}; - -module.exports = AssignTileProperties; - - -/***/ }), -/* 631 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Master list of tiles -> x, y, index in tileset. - * - * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.MapData} mapData - [description] - * - * @return {array} [description] - */ -var BuildTilesetIndex = function (mapData) -{ - var tiles = []; - - for (var i = 0; i < mapData.tilesets.length; i++) - { - var set = mapData.tilesets[i]; - - var x = set.tileMargin; - var y = set.tileMargin; - - var count = 0; - var countX = 0; - var countY = 0; - - for (var t = set.firstgid; t < set.firstgid + set.total; t++) - { - // Can add extra properties here as needed - tiles[t] = [ x, y, i ]; - - x += set.tileWidth + set.tileSpacing; - - count++; - - if (count === set.total) - { - break; - } - - countX++; - - if (countX === set.columns) - { - x = set.tileMargin; - y += set.tileHeight + set.tileSpacing; - - countX = 0; - countY++; - - if (countY === set.rows) - { - break; - } - } - } - } - - return tiles; -}; - -module.exports = BuildTilesetIndex; - - -/***/ }), -/* 632 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(1); -var ParseObject = __webpack_require__(314); -var ObjectLayer = __webpack_require__(313); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseObjectLayers = function (json) -{ - var objectLayers = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'objectgroup') - { - continue; - } - - var curo = json.layers[i]; - var offsetX = GetFastValue(curo, 'offsetx', 0); - var offsetY = GetFastValue(curo, 'offsety', 0); - var objects = []; - - for (var j = 0; j < curo.objects.length; j++) - { - var parsedObject = ParseObject(curo.objects[j], offsetX, offsetY); - - objects.push(parsedObject); - } - - var objectLayer = new ObjectLayer(curo); - objectLayer.objects = objects; - - objectLayers.push(objectLayer); - } - - return objectLayers; -}; - -module.exports = ParseObjectLayers; - - -/***/ }), -/* 633 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HasValue = __webpack_require__(111); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.Pick - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {array} keys - [description] - * - * @return {object} [description] - */ -var Pick = function (object, keys) -{ - var obj = {}; - - for (var i = 0; i < keys.length; i++) - { - var key = keys[i]; - - if (HasValue(object, key)) - { - obj[key] = object[key]; - } - } - - return obj; -}; - -module.exports = Pick; - - -/***/ }), -/* 634 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tileset = __webpack_require__(137); -var ImageCollection = __webpack_require__(315); -var ParseObject = __webpack_require__(314); - -/** - * Tilesets & Image Collections - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {object} [description] - */ -var ParseTilesets = function (json) -{ - var tilesets = []; - var imageCollections = []; - var lastSet = null; - var stringID; - - for (var i = 0; i < json.tilesets.length; i++) - { - // name, firstgid, width, height, margin, spacing, properties - var set = json.tilesets[i]; - - if (set.source) - { - console.warn('Phaser can\'t load external tilesets. Use the Embed Tileset button and then export the map again.'); - } - else if (set.image) - { - var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); - - // Properties stored per-tile in object with string indexes starting at "0" - if (set.tileproperties) - { - newSet.tileProperties = set.tileproperties; - } - - // Object & terrain shapes stored per-tile in object with string indexes starting at "0" - if (set.tiles) - { - newSet.tileData = set.tiles; - - // Parse the objects into Phaser format to match handling of other Tiled objects - for (stringID in newSet.tileData) - { - var objectGroup = newSet.tileData[stringID].objectgroup; - if (objectGroup && objectGroup.objects) - { - var parsedObjects = objectGroup.objects.map( - function (obj) { return ParseObject(obj); } - ); - newSet.tileData[stringID].objectgroup.objects = parsedObjects; - } - } - } - - // For a normal sliced tileset the row/count/size information is computed when updated. - // This is done (again) after the image is set. - newSet.updateTileData(set.imagewidth, set.imageheight); - - tilesets.push(newSet); - } - else - { - var newCollection = new ImageCollection(set.name, set.firstgid, set.tilewidth, - set.tileheight, set.margin, set.spacing, set.properties); - - for (stringID in set.tiles) - { - var image = set.tiles[stringID].image; - var gid = set.firstgid + parseInt(stringID, 10); - newCollection.addImage(gid, image); - } - - imageCollections.push(newCollection); - } - - // We've got a new Tileset, so set the lastgid into the previous one - if (lastSet) - { - lastSet.lastgid = set.firstgid - 1; - } - - lastSet = set; - } - - return { tilesets: tilesets, imageCollections: imageCollections }; -}; - -module.exports = ParseTilesets; - - -/***/ }), -/* 635 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(1); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseImageLayers = function (json) -{ - var images = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'imagelayer') - { - continue; - } - - var curi = json.layers[i]; - - images.push({ - name: curi.name, - image: curi.image, - x: GetFastValue(curi, 'offsetx', 0) + curi.x, - y: GetFastValue(curi, 'offsety', 0) + curi.y, - alpha: curi.opacity, - visible: curi.visible, - properties: GetFastValue(curi, 'properties', {}) - }); - } - - return images; -}; - -module.exports = ParseImageLayers; - - -/***/ }), -/* 636 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode - * @since 3.0.0 - * - * @param {object} data - [description] - * - * @return {array} [description] - */ -var Base64Decode = function (data) -{ - var binaryString = window.atob(data); - var len = binaryString.length; - var bytes = new Array(len / 4); - - // Interpret binaryString as an array of bytes representing little-endian encoded uint32 values. - for (var i = 0; i < len; i += 4) - { - bytes[i / 4] = ( - binaryString.charCodeAt(i) | - binaryString.charCodeAt(i + 1) << 8 | - binaryString.charCodeAt(i + 2) << 16 | - binaryString.charCodeAt(i + 3) << 24 - ) >>> 0; - } - - return bytes; -}; - -module.exports = Base64Decode; - - -/***/ }), -/* 637 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Base64Decode = __webpack_require__(636); -var GetFastValue = __webpack_require__(1); -var LayerData = __webpack_require__(104); -var ParseGID = __webpack_require__(316); -var Tile = __webpack_require__(66); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * @param {boolean} insertNull - [description] - * - * @return {array} [description] - */ -var ParseTileLayers = function (json, insertNull) -{ - var tileLayers = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'tilelayer') - { - continue; - } - - var curl = json.layers[i]; - - // Base64 decode data if necessary. NOTE: uncompressed base64 only. - if (curl.compression) - { - console.warn( - 'TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' - + curl.name + '\'' - ); - continue; - } - else if (curl.encoding && curl.encoding === 'base64') - { - curl.data = Base64Decode(curl.data); - delete curl.encoding; // Allow the same map to be parsed multiple times - } - - var layerData = new LayerData({ - name: curl.name, - x: GetFastValue(curl, 'offsetx', 0) + curl.x, - y: GetFastValue(curl, 'offsety', 0) + curl.y, - width: curl.width, - height: curl.height, - tileWidth: json.tilewidth, - tileHeight: json.tileheight, - alpha: curl.opacity, - visible: curl.visible, - properties: GetFastValue(curl, 'properties', {}) - }); - - var x = 0; - var row = []; - var output = []; - - // Loop through the data field in the JSON. - - // This is an array containing the tile indexes, one after the other. -1 = no tile, - // everything else = the tile index (starting at 1 for Tiled, 0 for CSV) If the map - // contains multiple tilesets then the indexes are relative to that which the set starts - // from. Need to set which tileset in the cache = which tileset in the JSON, if you do this - // manually it means you can use the same map data but a new tileset. - - for (var t = 0, len = curl.data.length; t < len; t++) - { - var gidInfo = ParseGID(curl.data[t]); - - // index, x, y, width, height - if (gidInfo.gid > 0) - { - var tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, - json.tileheight); - - // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal - // propeties into flipX, flipY and rotation - tile.rotation = gidInfo.rotation; - tile.flipX = gidInfo.flipped; - - row.push(tile); - } - else - { - var blankTile = insertNull - ? null - : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); - row.push(blankTile); - } - - x++; - - if (x === curl.width) - { - output.push(row); - x = 0; - row = []; - } - } - - layerData.data = output; - - tileLayers.push(layerData); - } - - return tileLayers; -}; - -module.exports = ParseTileLayers; - - -/***/ }), -/* 638 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps.Parsers - */ - -module.exports = { - - Parse: __webpack_require__(319), - Parse2DArray: __webpack_require__(217), - ParseCSV: __webpack_require__(318), - - Impact: __webpack_require__(312), - Tiled: __webpack_require__(317) - -}; - - -/***/ }), -/* 639 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); -var Vector2 = __webpack_require__(6); - -/** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @function Phaser.Tilemaps.Components.WorldToTileXY - * @private - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Math.Vector2} The XY location in tile units. - */ -var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer) -{ - if (point === undefined) { point = new Vector2(0, 0); } - - point.x = WorldToTileX(worldX, snapToFloor, camera, layer); - point.y = WorldToTileY(worldY, snapToFloor, camera, layer); - - return point; -}; - -module.exports = WorldToTileXY; - - -/***/ }), -/* 640 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * @function Phaser.Tilemaps.Components.WeightedRandomize - * @private - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) -{ - if (weightedIndexes === undefined) { return; } - - var i; - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - var weightTotal = 0; - for (i = 0; i < weightedIndexes.length; i++) - { - weightTotal += weightedIndexes[i].weight; - } - - if (weightTotal <= 0) { return; } - - for (i = 0; i < tiles.length; i++) - { - var rand = Math.random() * weightTotal; - var sum = 0; - var randomIndex = -1; - for (var j = 0; j < weightedIndexes.length; j++) - { - sum += weightedIndexes[j].weight; - if (rand <= sum) - { - var chosen = weightedIndexes[j].index; - randomIndex = Array.isArray(chosen) - ? chosen[Math.floor(Math.random() * chosen.length)] - : chosen; - break; - } - } - - tiles[i].index = randomIndex; - } -}; - -module.exports = WeightedRandomize; - - -/***/ }), -/* 641 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileToWorldX = __webpack_require__(139); -var TileToWorldY = __webpack_require__(138); -var Vector2 = __webpack_require__(6); - -/** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @function Phaser.Tilemaps.Components.TileToWorldXY - * @private - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Math.Vector2} The XY location in world coordinates. - */ -var TileToWorldXY = function (tileX, tileY, point, camera, layer) -{ - if (point === undefined) { point = new Vector2(0, 0); } - - point.x = TileToWorldX(tileX, camera, layer); - point.y = TileToWorldY(tileY, camera, layer); - - return point; -}; - -module.exports = TileToWorldXY; - - -/***/ }), -/* 642 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * @function Phaser.Tilemaps.Components.SwapByIndex - * @private - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - if (tiles[i]) - { - if (tiles[i].index === indexA) - { - tiles[i].index = indexB; - } - else if (tiles[i].index === indexB) - { - tiles[i].index = indexA; - } - } - } -}; - -module.exports = SwapByIndex; - - -/***/ }), -/* 643 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var ShuffleArray = __webpack_require__(95); - -/** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * @function Phaser.Tilemaps.Components.Shuffle - * @private - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Shuffle = function (tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - var indexes = tiles.map(function (tile) { return tile.index; }); - ShuffleArray(indexes); - - for (var i = 0; i < tiles.length; i++) - { - tiles[i].index = indexes[i]; - } -}; - -module.exports = Shuffle; - - -/***/ }), -/* 644 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @function Phaser.Tilemaps.Components.SetTileLocationCallback - * @private - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - tiles[i].setCollisionCallback(callback, callbackContext); - } - -}; - -module.exports = SetTileLocationCallback; - - -/***/ }), -/* 645 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @function Phaser.Tilemaps.Components.SetTileIndexCallback - * @private - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetTileIndexCallback = function (indexes, callback, callbackContext, layer) -{ - if (typeof indexes === 'number') - { - layer.callbacks[indexes] = (callback !== null) - ? { callback: callback, callbackContext: callbackContext } - : undefined; - } - else - { - for (var i = 0, len = indexes.length; i < len; i++) - { - layer.callbacks[indexes[i]] = (callback !== null) - ? { callback: callback, callbackContext: callbackContext } - : undefined; - } - } -}; - -module.exports = SetTileIndexCallback; - - -/***/ }), -/* 646 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); - -/** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup - * @private - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (!tile) { continue; } - - var collisionGroup = tile.getCollisionGroup(); - - // It's possible in Tiled to have a collision group without any shapes, e.g. create a - // shape and then delete the shape. - if (collisionGroup && collisionGroup.objects && collisionGroup.objects.length > 0) - { - SetTileCollision(tile, collides); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionFromCollisionGroup; - - -/***/ }), -/* 647 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); -var HasValue = __webpack_require__(111); - -/** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @function Phaser.Tilemaps.Components.SetCollisionByProperty - * @private - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (!tile) { continue; } - - for (var property in properties) - { - if (!HasValue(tile.properties, property)) { continue; } - - var values = properties[property]; - if (!Array.isArray(values)) - { - values = [ values ]; - } - - for (var i = 0; i < values.length; i++) - { - if (tile.properties[property] === values[i]) - { - SetTileCollision(tile, collides); - } - } - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionByProperty; - - -/***/ }), -/* 648 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); -var SetLayerCollisionIndex = __webpack_require__(218); - -/** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionByExclusion - * @private - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - // Note: this only updates layer.collideIndexes for tile indexes found currently in the layer - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile && indexes.indexOf(tile.index) === -1) - { - SetTileCollision(tile, collides); - SetLayerCollisionIndex(tile.index, collides, layer); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionByExclusion; - - -/***/ }), -/* 649 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); -var SetLayerCollisionIndex = __webpack_require__(218); - -/** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionBetween - * @private - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - if (start > stop) { return; } - - // Update the array of colliding indexes - for (var index = start; index <= stop; index++) - { - SetLayerCollisionIndex(index, collides, layer); - } - - // Update the tiles - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile) - { - if (tile.index >= start && tile.index <= stop) - { - SetTileCollision(tile, collides); - } - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionBetween; - - -/***/ }), -/* 650 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); -var SetLayerCollisionIndex = __webpack_require__(218); - -/** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollision - * @private - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollision = function (indexes, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - // Update the array of colliding indexes - for (var i = 0; i < indexes.length; i++) - { - SetLayerCollisionIndex(indexes[i], collides, layer); - } - - // Update the tiles - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (tile && indexes.indexOf(tile.index) !== -1) - { - SetTileCollision(tile, collides); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollision; - - -/***/ }), -/* 651 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var Color = __webpack_require__(542); - -/** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @function Phaser.Tilemaps.Components.RenderDebug - * @private - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {?Phaser.Display.Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {?Phaser.Display.Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {?Phaser.Display.Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var RenderDebug = function (graphics, styleConfig, layer) -{ - if (styleConfig === undefined) { styleConfig = {}; } - - // Default colors without needlessly creating Color objects - var tileColor = styleConfig.tileColor !== undefined - ? styleConfig.tileColor - : new Color(105, 210, 231, 150); - var collidingTileColor = styleConfig.collidingTileColor !== undefined - ? styleConfig.collidingTileColor - : new Color(243, 134, 48, 200); - var faceColor = styleConfig.faceColor !== undefined - ? styleConfig.faceColor - : new Color(40, 39, 37, 150); - - var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - var tw = tile.width; - var th = tile.height; - var x = tile.pixelX; - var y = tile.pixelY; - - var color = tile.collides ? collidingTileColor : tileColor; - if (color !== null) - { - graphics.fillStyle(color.color, color.alpha / 255); - graphics.fillRect(x, y, tw, th); - } - - // Inset the face line to prevent neighboring tile's lines from overlapping - x += 1; - y += 1; - tw -= 2; - th -= 2; - - if (faceColor !== null) - { - graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); - if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } - if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } - if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } - if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } - } - } -}; - -module.exports = RenderDebug; - - -/***/ }), -/* 652 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RemoveTileAt = __webpack_require__(320); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * @function Phaser.Tilemaps.Components.RemoveTileAtWorldXY - * @private - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. - */ -var RemoveTileAtWorldXY = function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - return RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); -}; - -module.exports = RemoveTileAtWorldXY; - - -/***/ }), -/* 653 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var GetRandom = __webpack_require__(146); - -/** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * @function Phaser.Tilemaps.Components.Randomize - * @private - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Randomize = function (tileX, tileY, width, height, indexes, layer) -{ - var i; - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - // If no indicies are given, then find all the unique indexes within the specified region - if (indexes === undefined) - { - indexes = []; - for (i = 0; i < tiles.length; i++) - { - if (indexes.indexOf(tiles[i].index) === -1) - { - indexes.push(tiles[i].index); - } - } - } - - for (i = 0; i < tiles.length; i++) - { - tiles[i].index = GetRandom(indexes); - } -}; - -module.exports = Randomize; - - -/***/ }), -/* 654 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CalculateFacesWithin = __webpack_require__(40); -var PutTileAt = __webpack_require__(219); - -/** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * @function Phaser.Tilemaps.Components.PutTilesAt - * @private - * @since 3.0.0 - * - * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) -{ - if (!Array.isArray(tilesArray)) { return null; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - // Force the input array to be a 2D array - if (!Array.isArray(tilesArray[0])) - { - tilesArray = [ tilesArray ]; - } - - var height = tilesArray.length; - var width = tilesArray[0].length; - - for (var ty = 0; ty < height; ty++) - { - for (var tx = 0; tx < width; tx++) - { - var tile = tilesArray[ty][tx]; - PutTileAt(tile, tileX + tx, tileY + ty, false, layer); - } - } - - if (recalculateFaces) - { - // Recalculate the faces within the destination area and neighboring tiles - CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = PutTilesAt; - - - -/***/ }), -/* 655 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var PutTileAt = __webpack_require__(219); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * @function Phaser.Tilemaps.Components.PutTileAtWorldXY - * @private - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. - */ -var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - return PutTileAt(tile, tileX, tileY, recalculateFaces, layer); -}; - -module.exports = PutTileAtWorldXY; - - -/***/ }), -/* 656 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HasTileAt = __webpack_require__(321); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @function Phaser.Tilemaps.Components.HasTileAtWorldXY - * @private - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var HasTileAtWorldXY = function (worldX, worldY, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - - return HasTileAt(tileX, tileY, layer); -}; - -module.exports = HasTileAtWorldXY; - - -/***/ }), -/* 657 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @function Phaser.Tilemaps.Components.GetTilesWithinWorldXY - * @private - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer) -{ - // Top left corner of the rect, rounded down to include partial tiles - var xStart = WorldToTileX(worldX, true, camera, layer); - var yStart = WorldToTileY(worldY, true, camera, layer); - - // Bottom right corner of the rect, rounded up to include partial tiles - var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer)); - var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer)); - - return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer); -}; - -module.exports = GetTilesWithinWorldXY; - - -/***/ }), -/* 658 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Geom = __webpack_require__(400); -var GetTilesWithin = __webpack_require__(21); -var Intersects = __webpack_require__(399); -var NOOP = __webpack_require__(3); -var TileToWorldX = __webpack_require__(139); -var TileToWorldY = __webpack_require__(138); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -var TriangleToRectangle = function (triangle, rect) -{ - return Intersects.RectangleToTriangle(rect, triangle); -}; - -// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer -// coordinates instead of shifting the tiles. - -/** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @function Phaser.Tilemaps.Components.GetTilesWithinShape - * @private - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) -{ - if (shape === undefined) { return []; } - - // intersectTest is a function with parameters: shape, rect - var intersectTest = NOOP; - if (shape instanceof Geom.Circle) { intersectTest = Intersects.CircleToRectangle; } - else if (shape instanceof Geom.Rectangle) { intersectTest = Intersects.RectangleToRectangle; } - else if (shape instanceof Geom.Triangle) { intersectTest = TriangleToRectangle; } - else if (shape instanceof Geom.Line) { intersectTest = Intersects.LineToRectangle; } - - // Top left corner of the shapes's bounding box, rounded down to include partial tiles - var xStart = WorldToTileX(shape.left, true, camera, layer); - var yStart = WorldToTileY(shape.top, true, camera, layer); - - // Bottom right corner of the shapes's bounding box, rounded up to include partial tiles - var xEnd = Math.ceil(WorldToTileX(shape.right, false, camera, layer)); - var yEnd = Math.ceil(WorldToTileY(shape.bottom, false, camera, layer)); - - // Tiles within bounding rectangle of shape. Bounds are forced to be at least 1 x 1 tile in size - // to grab tiles for shapes that don't have a height or width (e.g. a horizontal line). - var width = Math.max(xEnd - xStart, 1); - var height = Math.max(yEnd - yStart, 1); - var tiles = GetTilesWithin(xStart, yStart, width, height, filteringOptions, layer); - - var tileWidth = layer.tileWidth; - var tileHeight = layer.tileHeight; - if (layer.tilemapLayer) - { - tileWidth *= layer.tilemapLayer.scaleX; - tileHeight *= layer.tilemapLayer.scaleY; - } - - var results = []; - var tileRect = new Geom.Rectangle(0, 0, tileWidth, tileHeight); - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - tileRect.x = TileToWorldX(tile.x, camera, layer); - tileRect.y = TileToWorldY(tile.y, camera, layer); - if (intersectTest(shape, tileRect)) - { - results.push(tile); - } - } - - return results; -}; - -module.exports = GetTilesWithinShape; - - -/***/ }), -/* 659 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTileAt = __webpack_require__(140); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Gets a tile at the given world coordinates from the given layer. - * - * @function Phaser.Tilemaps.Components.GetTileAtWorldXY - * @private - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ -var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - - return GetTileAt(tileX, tileY, nonNull, layer); -}; - -module.exports = GetTileAtWorldXY; - - -/***/ }), -/* 660 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * @callback EachTileCallback - * - * @param {Phaser.Tilemaps.Tile} value - [description] - * @param {number} index - [description] - * @param {Phaser.Tilemaps.Tile[]} array - [description] - */ - -/** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @function Phaser.Tilemaps.Components.ForEachTile - * @private - * @since 3.0.0 - * - * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - tiles.forEach(callback, context); -}; - -module.exports = ForEachTile; - - -/***/ }), -/* 661 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * @callback FindTileCallback - * - * @param {Phaser.Tilemaps.Tile} value - [description] - * @param {number} index - [description] - * @param {Phaser.Tilemaps.Tile[]} array - [description] - * - * @return {boolean} [description] - */ - -/** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @function Phaser.Tilemaps.Components.FindTile - * @private - * @since 3.0.0 - * - * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found - */ -var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - return tiles.find(callback, context) || null; -}; - -module.exports = FindTile; - - -/***/ }), -/* 662 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @function Phaser.Tilemaps.Components.FindByIndex - * @private - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {?Phaser.Tilemaps.Tile} The first (or n skipped) tile with the matching index. - */ -var FindByIndex = function (findIndex, skip, reverse, layer) -{ - if (skip === undefined) { skip = 0; } - if (reverse === undefined) { reverse = false; } - - var count = 0; - var tx; - var ty; - var tile; - - if (reverse) - { - for (ty = layer.height - 1; ty >= 0; ty--) - { - for (tx = layer.width - 1; tx >= 0; tx--) - { - tile = layer.data[ty][tx]; - if (tile && tile.index === findIndex) - { - if (count === skip) - { - return tile; - } - else - { - count += 1; - } - } - } - } - } - else - { - for (ty = 0; ty < layer.height; ty++) - { - for (tx = 0; tx < layer.width; tx++) - { - tile = layer.data[ty][tx]; - if (tile && tile.index === findIndex) - { - if (count === skip) - { - return tile; - } - else - { - count += 1; - } - } - } - } - } - - return null; -}; - -module.exports = FindByIndex; - - -/***/ }), -/* 663 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @function Phaser.Tilemaps.Components.FilterTiles - * @private - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. - */ -var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - return tiles.filter(callback, context); -}; - -module.exports = FilterTiles; - - - -/***/ }), -/* 664 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var CalculateFacesWithin = __webpack_require__(40); -var SetTileCollision = __webpack_require__(67); - -/** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * @function Phaser.Tilemaps.Components.Fill - * @private - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) -{ - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); - - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - tiles[i].index = index; - - SetTileCollision(tiles[i], doesIndexCollide); - } - - if (recalculateFaces) - { - // Recalculate the faces within the area and neighboring tiles - CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = Fill; - - -/***/ }), -/* 665 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the tiles in the given layer that are within the camera's viewport. This is used - * internally. - * - * @function Phaser.Tilemaps.Components.CullTiles - * @private - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * @param {array} [outputArray] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ -var CullTiles = function (layer, camera, outputArray) -{ - if (outputArray === undefined) { outputArray = []; } - - outputArray.length = 0; - - var zoom = camera.zoom; - var originX = camera.width / 2; - var originY = camera.height / 2; - - camera.matrix.loadIdentity(); - camera.matrix.translate(camera.x + originX, camera.y + originY); - camera.matrix.rotate(camera.rotation); - camera.matrix.scale(zoom, zoom); - camera.matrix.translate(-originX, -originY); - camera.matrix.invert(); - - camera.shakeEffect.preRender(); - - var tilemapLayer = layer.tilemapLayer; - var tileW = layer.tileWidth; - var tileH = layer.tileHeight; - var cullX = ((camera.scrollX * tilemapLayer.scrollFactorX) - tileW); - var cullY = ((camera.scrollY * tilemapLayer.scrollFactorY) - tileH); - var cullW = (cullX + (camera.width + tileW * 2)); - var cullH = (cullY + (camera.height + tileH * 2)); - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - var cameraMatrix = camera.matrix.matrix; - var a = cameraMatrix[0]; - var b = cameraMatrix[1]; - var c = cameraMatrix[2]; - var d = cameraMatrix[3]; - var e = cameraMatrix[4]; - var f = cameraMatrix[5]; - var tCullX = cullX * a + cullY * c + e; - var tCullY = cullX * b + cullY * d + f; - var tCullW = cullW * a + cullH * c + e; - var tCullH = cullW * b + cullH * d + f; - - for (var y = 0; y < mapHeight; ++y) - { - for (var x = 0; x < mapWidth; ++x) - { - var tile = mapData[y][x]; - - if (tile === null || tile.index === -1) - { - continue; - } - - var tileX = tile.pixelX * a + tile.pixelY * c + e; - var tileY = tile.pixelX * b + tile.pixelY * d + f; - - if (tile.visible && - tileX >= tCullX && - tileY >= tCullY && - tileX + tileW <= tCullW && - tileY + tileH <= tCullH - ) - { - outputArray.push(tile); - } - } - } - - /* var tilemapLayer = layer.tilemapLayer; - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - var left = (camera.scrollX * camera.zoom * tilemapLayer.scrollFactorX) - tilemapLayer.x; - var top = (camera.scrollY * camera.zoom * tilemapLayer.scrollFactorY) - tilemapLayer.y; - var sx = tilemapLayer.scaleX; - var sy = tilemapLayer.scaleY; - var tileWidth = layer.tileWidth * sx; - var tileHeight = layer.tileHeight * sy; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile === null || tile.index === -1) { continue; } - - var tileX = tile.pixelX * sx - left; - var tileY = tile.pixelY * sy - top; - var cullW = camera.width + tileWidth; - var cullH = camera.height + tileHeight; - - if (tile.visible && - tileX > -tileWidth && tileY > -tileHeight && - tileX < cullW && tileY < cullH) - { - outputArray.push(tile); - } - } - } */ - - return outputArray; -}; - -module.exports = CullTiles; - - -/***/ }), -/* 666 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileToWorldX = __webpack_require__(139); -var TileToWorldY = __webpack_require__(138); -var GetTilesWithin = __webpack_require__(21); -var ReplaceByIndex = __webpack_require__(322); - -/** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @function Phaser.Tilemaps.Components.CreateFromTiles - * @private - * @since 3.0.0 - * - * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ -var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, camera, layer) -{ - if (spriteConfig === undefined) { spriteConfig = {}; } - - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - var tilemapLayer = layer.tilemapLayer; - if (scene === undefined) { scene = tilemapLayer.scene; } - if (camera === undefined) { camera = scene.cameras.main; } - - var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); - var sprites = []; - var i; - - for (i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - if (indexes.indexOf(tile.index) !== -1) - { - spriteConfig.x = TileToWorldX(tile.x, camera, layer); - spriteConfig.y = TileToWorldY(tile.y, camera, layer); - - var sprite = scene.make.sprite(spriteConfig); - sprites.push(sprite); - } - } - - if (typeof replacements === 'number') - { - // Assume 1 replacement for all types of tile given - for (i = 0; i < indexes.length; i++) - { - ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); - } - } - else if (Array.isArray(replacements)) - { - // Assume 1 to 1 mapping with indexes array - for (i = 0; i < indexes.length; i++) - { - ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); - } - } - - return sprites; -}; - -module.exports = CreateFromTiles; - - -/***/ }), -/* 667 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var CalculateFacesWithin = __webpack_require__(40); - -/** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * - * @function Phaser.Tilemaps.Components.Copy - * @private - * @since 3.0.0 - * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) -{ - if (srcTileX < 0) { srcTileX = 0; } - if (srcTileY < 0) { srcTileY = 0; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer); - - var offsetX = destTileX - srcTileX; - var offsetY = destTileY - srcTileY; - - for (var i = 0; i < srcTiles.length; i++) - { - var tileX = srcTiles[i].x + offsetX; - var tileY = srcTiles[i].y + offsetY; - if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height) - { - if (layer.data[tileY][tileX]) - { - layer.data[tileY][tileX].copy(srcTiles[i]); - } - } - } - - if (recalculateFaces) - { - // Recalculate the faces within the destination area and neighboring tiles - CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = Copy; - - -/***/ }), -/* 668 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps - */ - -module.exports = { - - Components: __webpack_require__(141), - Parsers: __webpack_require__(638), - - Formats: __webpack_require__(26), - ImageCollection: __webpack_require__(315), - ParseToTilemap: __webpack_require__(216), - Tile: __webpack_require__(66), - Tilemap: __webpack_require__(311), - TilemapCreator: __webpack_require__(621), - TilemapFactory: __webpack_require__(620), - Tileset: __webpack_require__(137), - - LayerData: __webpack_require__(104), - MapData: __webpack_require__(103), - ObjectLayer: __webpack_require__(313), - - DynamicTilemapLayer: __webpack_require__(310), - StaticTilemapLayer: __webpack_require__(309) - -}; - - -/***/ }), -/* 669 */, -/* 670 */, -/* 671 */, -/* 672 */, -/* 673 */, -/* 674 */, -/* 675 */, -/* 676 */, -/* 677 */, -/* 678 */, -/* 679 */, -/* 680 */, -/* 681 */, -/* 682 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetOverlapY = __webpack_require__(336); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.SeparateY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ -var SeparateY = function (body1, body2, overlapOnly, bias) -{ - var overlap = GetOverlapY(body1, body2, overlapOnly, bias); - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateY || body2.customSeparateY) - { - // return true if there was some overlap, otherwise false - return (overlap !== 0) || (body1.embedded && body2.embedded); - } - - // Adjust their positions and velocities accordingly (if there was any overlap) - var v1 = body1.velocity.y; - var v2 = body2.velocity.y; - - if (!body1.immovable && !body2.immovable) - { - overlap *= 0.5; - - body1.y -= overlap; - body2.y += overlap; - - var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); - var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); - var avg = (nv1 + nv2) * 0.5; - - nv1 -= avg; - nv2 -= avg; - - body1.velocity.y = avg + nv1 * body1.bounce.y; - body2.velocity.y = avg + nv2 * body2.bounce.y; - } - else if (!body1.immovable) - { - body1.y -= overlap; - body1.velocity.y = v2 - v1 * body1.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body2.moves) - { - body1.x += (body2.x - body2.prev.x) * body2.friction.x; - } - } - else - { - body2.y += overlap; - body2.velocity.y = v1 - v2 * body2.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body1.moves) - { - body2.x += (body1.x - body1.prev.x) * body1.friction.x; - } - } - - // If we got this far then there WAS overlap, and separation is complete, so return true - return true; -}; - -module.exports = SeparateY; - - -/***/ }), -/* 683 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetOverlapX = __webpack_require__(337); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.SeparateX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ -var SeparateX = function (body1, body2, overlapOnly, bias) -{ - var overlap = GetOverlapX(body1, body2, overlapOnly, bias); - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) - { - // return true if there was some overlap, otherwise false - return (overlap !== 0) || (body1.embedded && body2.embedded); - } - - // Adjust their positions and velocities accordingly (if there was any overlap) - var v1 = body1.velocity.x; - var v2 = body2.velocity.x; - - if (!body1.immovable && !body2.immovable) - { - overlap *= 0.5; - - body1.x -= overlap; - body2.x += overlap; - - var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); - var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); - var avg = (nv1 + nv2) * 0.5; - - nv1 -= avg; - nv2 -= avg; - - body1.velocity.x = avg + nv1 * body1.bounce.x; - body2.velocity.x = avg + nv2 * body2.bounce.x; - } - else if (!body1.immovable) - { - body1.x -= overlap; - body1.velocity.x = v2 - v1 * body1.bounce.x; - - // This is special case code that handles things like vertically moving platforms you can ride - if (body2.moves) - { - body1.y += (body2.y - body2.prev.y) * body2.friction.y; - } - } - else - { - body2.x += overlap; - body2.velocity.x = v1 - v2 * body2.bounce.x; - - // This is special case code that handles things like vertically moving platforms you can ride - if (body1.moves) - { - body2.y += (body1.y - body1.prev.y) * body1.friction.y; - } - } - - // If we got this far then there WAS overlap, and separation is complete, so return true - return true; -}; - -module.exports = SeparateX; - - -/***/ }), -/* 684 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internal function to process the separation of a physics body from a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {number} y - The y separation amount. - */ -var ProcessTileSeparationY = function (body, y) -{ - if (y < 0) - { - body.blocked.up = true; - } - else if (y > 0) - { - body.blocked.down = true; - } - - body.position.y -= y; - - if (body.bounce.y === 0) - { - body.velocity.y = 0; - } - else - { - body.velocity.y = -body.velocity.y * body.bounce.y; - } -}; - -module.exports = ProcessTileSeparationY; - - -/***/ }), -/* 685 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ProcessTileSeparationY = __webpack_require__(684); - -/** - * Check the body against the given tile on the Y axis. - * - * @function Phaser.Physics.Arcade.Tilemap.TileCheckY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileTop - [description] - * @param {number} tileBottom - [description] - * @param {number} tileBias - [description] - * - * @return {number} The amount of separation that occurred. - */ -var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) -{ - var oy = 0; - - if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) - { - // Body is moving UP - if (tile.faceBottom && body.y < tileBottom) - { - oy = body.y - tileBottom; - - if (oy < -tileBias) - { - oy = 0; - } - } - } - else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) - { - // Body is moving DOWN - if (tile.faceTop && body.bottom > tileTop) - { - oy = body.bottom - tileTop; - - if (oy > tileBias) - { - oy = 0; - } - } - } - - if (oy !== 0) - { - if (body.customSeparateY) - { - body.overlapY = oy; - } - else - { - ProcessTileSeparationY(body, oy); - } - } - - return oy; -}; - -module.exports = TileCheckY; - - -/***/ }), -/* 686 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internal function to process the separation of a physics body from a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {number} x - The x separation amount. - */ -var ProcessTileSeparationX = function (body, x) -{ - if (x < 0) - { - body.blocked.left = true; - } - else if (x > 0) - { - body.blocked.right = true; - } - - body.position.x -= x; - - if (body.bounce.x === 0) - { - body.velocity.x = 0; - } - else - { - body.velocity.x = -body.velocity.x * body.bounce.x; - } -}; - -module.exports = ProcessTileSeparationX; - - -/***/ }), -/* 687 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ProcessTileSeparationX = __webpack_require__(686); - -/** - * Check the body against the given tile on the X axis. - * - * @function Phaser.Physics.Arcade.Tilemap.TileCheckX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileLeft - [description] - * @param {number} tileRight - [description] - * @param {number} tileBias - [description] - * - * @return {number} The amount of separation that occurred. - */ -var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) -{ - var ox = 0; - - if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) - { - // Body is moving LEFT - if (tile.faceRight && body.x < tileRight) - { - ox = body.x - tileRight; - - if (ox < -tileBias) - { - ox = 0; - } - } - } - else if (body.deltaX() > 0 && !body.blocked.right && tile.collideLeft && body.checkCollision.right) - { - // Body is moving RIGHT - if (tile.faceLeft && body.right > tileLeft) - { - ox = body.right - tileLeft; - - if (ox > tileBias) - { - ox = 0; - } - } - } - - if (ox !== 0) - { - if (body.customSeparateX) - { - body.overlapX = ox; - } - else - { - ProcessTileSeparationX(body, ox); - } - } - - return ox; -}; - -module.exports = TileCheckX; - - -/***/ }), -/* 688 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileCheckX = __webpack_require__(687); -var TileCheckY = __webpack_require__(685); -var TileIntersectsBody = __webpack_require__(335); - -/** - * The core separation function to separate a physics body and a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.SeparateTile - * @since 3.0.0 - * - * @param {number} i - [description] - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. - * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] - * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemapLayer to collide against. - * @param {number} tileBias - [description] - * - * @return {boolean} Returns true if the body was separated, otherwise false. - */ -var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) -{ - var tileLeft = tileWorldRect.left; - var tileTop = tileWorldRect.top; - var tileRight = tileWorldRect.right; - var tileBottom = tileWorldRect.bottom; - var faceHorizontal = tile.faceLeft || tile.faceRight; - var faceVertical = tile.faceTop || tile.faceBottom; - - // We don't need to go any further if this tile doesn't actually have any colliding faces. This - // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't - // needed for separation. - if (!faceHorizontal && !faceVertical) - { - return false; - } - - var ox = 0; - var oy = 0; - var minX = 0; - var minY = 1; - - if (body.deltaAbsX() > body.deltaAbsY()) - { - // Moving faster horizontally, check X axis first - minX = -1; - } - else if (body.deltaAbsX() < body.deltaAbsY()) - { - // Moving faster vertically, check Y axis first - minY = -1; - } - - if (body.deltaX() !== 0 && body.deltaY() !== 0 && faceHorizontal && faceVertical) - { - // We only need do this if both axes have colliding faces AND we're moving in both - // directions - minX = Math.min(Math.abs(body.position.x - tileRight), Math.abs(body.right - tileLeft)); - minY = Math.min(Math.abs(body.position.y - tileBottom), Math.abs(body.bottom - tileTop)); - } - - if (minX < minY) - { - if (faceHorizontal) - { - ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); - - // That's horizontal done, check if we still intersects? If not then we can return now - if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) - { - return true; - } - } - - if (faceVertical) - { - oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); - } - } - else - { - if (faceVertical) - { - oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); - - // That's vertical done, check if we still intersects? If not then we can return now - if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) - { - return true; - } - } - - if (faceHorizontal) - { - ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); - } - } - - return (ox !== 0 || oy !== 0); -}; - -module.exports = SeparateTile; - - -/***/ }), -/* 689 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.Tilemap} tile - [description] - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * - * @return {boolean} [description] - */ -var ProcessTileCallbacks = function (tile, sprite) -{ - // Tile callbacks take priority over layer level callbacks - if (tile.collisionCallback) - { - return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); - } - else if (tile.layer.callbacks[tile.index]) - { - return !tile.layer.callbacks[tile.index].callback.call( - tile.layer.callbacks[tile.index].callbackContext, sprite, tile - ); - } - - return true; -}; - -module.exports = ProcessTileCallbacks; - - -/***/ }), -/* 690 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Velocity - * @since 3.0.0 - */ -var Velocity = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setVelocity: function (x, y) - { - this.body.velocity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX - * @since 3.0.0 - * - * @param {number} x - [description] - * - * @return {this} This Game Object. - */ - setVelocityX: function (x) - { - this.body.velocity.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY - * @since 3.0.0 - * - * @param {number} y - [description] - * - * @return {this} This Game Object. - */ - setVelocityY: function (y) - { - this.body.velocity.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setMaxVelocity: function (x, y) - { - this.body.maxVelocity.set(x, y); - - return this; - } - -}; - -module.exports = Velocity; - - -/***/ }), -/* 691 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Size - * @since 3.0.0 - */ -var Size = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setOffset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setOffset: function (x, y) - { - this.body.setOffset(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {boolean} [center=true] - [description] - * - * @return {this} This Game Object. - */ - setSize: function (width, height, center) - { - this.body.setSize(width, height, center); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setCircle - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {this} This Game Object. - */ - setCircle: function (radius, offsetX, offsetY) - { - this.body.setCircle(radius, offsetX, offsetY); - - return this; - } - -}; - -module.exports = Size; - - -/***/ }), -/* 692 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Mass - * @since 3.0.0 - */ -var Mass = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Mass#setMass - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setMass: function (value) - { - this.body.mass = value; - - return this; - } - -}; - -module.exports = Mass; - - -/***/ }), -/* 693 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Immovable - * @since 3.0.0 - */ -var Immovable = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable - * @since 3.0.0 - * - * @param {boolean} [value=true] - [description] - * - * @return {this} This Game Object. - */ - setImmovable: function (value) - { - if (value === undefined) { value = true; } - - this.body.immovable = value; - - return this; - } - -}; - -module.exports = Immovable; - - -/***/ }), -/* 694 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Gravity - * @since 3.0.0 - */ -var Gravity = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setGravity: function (x, y) - { - this.body.gravity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX - * @since 3.0.0 - * - * @param {number} x - [description] - * - * @return {this} This Game Object. - */ - setGravityX: function (x) - { - this.body.gravity.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY - * @since 3.0.0 - * - * @param {number} y - [description] - * - * @return {this} This Game Object. - */ - setGravityY: function (y) - { - this.body.gravity.y = y; - - return this; - } - -}; - -module.exports = Gravity; - - -/***/ }), -/* 695 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Friction - * @since 3.0.0 - */ -var Friction = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFriction - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setFriction: function (x, y) - { - this.body.friction.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX - * @since 3.0.0 - * - * @param {number} x - [description] - * - * @return {this} This Game Object. - */ - setFrictionX: function (x) - { - this.body.friction.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY - * @since 3.0.0 - * - * @param {number} y - [description] - * - * @return {this} This Game Object. - */ - setFrictionY: function (y) - { - this.body.friction.y = y; - - return this; - } - -}; - -module.exports = Friction; - - -/***/ }), -/* 696 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Enable - * @since 3.0.0 - */ -var Enable = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Enable#enableBody - * @since 3.0.0 - * - * @param {boolean} reset - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {boolean} enableGameObject - [description] - * @param {boolean} showGameObject - [description] - * - * @return {this} This Game Object. - */ - enableBody: function (reset, x, y, enableGameObject, showGameObject) - { - if (reset) - { - this.body.reset(x, y); - } - - if (enableGameObject) - { - this.body.gameObject.active = true; - } - - if (showGameObject) - { - this.body.gameObject.visible = true; - } - - this.body.enable = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Enable#disableBody - * @since 3.0.0 - * - * @param {boolean} [disableGameObject=false] - [description] - * @param {boolean} [hideGameObject=false] - [description] - * - * @return {this} This Game Object. - */ - disableBody: function (disableGameObject, hideGameObject) - { - if (disableGameObject === undefined) { disableGameObject = false; } - if (hideGameObject === undefined) { hideGameObject = false; } - - this.body.stop(); - - this.body.enable = false; - - if (disableGameObject) - { - this.body.gameObject.active = false; - } - - if (hideGameObject) - { - this.body.gameObject.visible = false; - } - - return this; - }, - - /** - * Syncs the Bodies position and size with its parent Game Object. - * You don't need to call this for Dynamic Bodies, as it happens automatically. - * But for Static bodies it's a useful way of modifying the position of a Static Body - * in the Physics World, based on its Game Object. - * - * @method Phaser.Physics.Arcade.Components.Enable#refreshBody - * @since 3.1.0 - * - * @return {this} This Game Object. - */ - refreshBody: function () - { - this.body.updateFromGameObject(); - - return this; - } - -}; - -module.exports = Enable; - - -/***/ }), -/* 697 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Drag - * @since 3.0.0 - */ -var Drag = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDrag - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setDrag: function (x, y) - { - this.body.drag.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDragX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setDragX: function (value) - { - this.body.drag.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDragY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setDragY: function (value) - { - this.body.drag.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDamping - * @since 3.10.0 - * - * @param {boolean} value - `true` to use damping for deceleration, or `false` to use linear deceleration. - * - * @return {this} This Game Object. - */ - setDamping: function (value) - { - this.body.useDamping = value; - - return this; - } - -}; - -module.exports = Drag; - - -/***/ }), -/* 698 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug - * @since 3.0.0 - */ -var Debug = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Debug#setDebug - * @since 3.0.0 - * - * @param {boolean} showBody - [description] - * @param {boolean} showVelocity - [description] - * @param {number} bodyColor - [description] - * - * @return {this} This Game Object. - */ - setDebug: function (showBody, showVelocity, bodyColor) - { - this.debugShowBody = showBody; - this.debugShowVelocity = showVelocity; - this.debugBodyColor = bodyColor; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setDebugBodyColor: function (value) - { - this.body.debugBodyColor = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - debugShowBody: { - - get: function () - { - return this.body.debugShowBody; - }, - - set: function (value) - { - this.body.debugShowBody = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity - * @type {boolean} - * @since 3.0.0 - */ - debugShowVelocity: { - - get: function () - { - return this.body.debugShowVelocity; - }, - - set: function (value) - { - this.body.debugShowVelocity = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor - * @type {number} - * @since 3.0.0 - */ - debugBodyColor: { - - get: function () - { - return this.body.debugBodyColor; - }, - - set: function (value) - { - this.body.debugBodyColor = value; - } - - } - -}; - -module.exports = Debug; - - -/***/ }), -/* 699 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Bounce - * @since 3.0.0 - */ -var Bounce = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounce - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setBounce: function (x, y) - { - this.body.bounce.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setBounceX: function (value) - { - this.body.bounce.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setBounceY: function (value) - { - this.body.bounce.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {this} This Game Object. - */ - setCollideWorldBounds: function (value) - { - this.body.collideWorldBounds = value; - - return this; - } - -}; - -module.exports = Bounce; - - -/***/ }), -/* 700 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Angular - * @since 3.0.0 - */ -var Angular = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setAngularVelocity: function (value) - { - this.body.angularVelocity = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setAngularAcceleration: function (value) - { - this.body.angularAcceleration = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setAngularDrag: function (value) - { - this.body.angularDrag = value; - - return this; - } - -}; - -module.exports = Angular; - - -/***/ }), -/* 701 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Acceleration - * @since 3.0.0 - */ -var Acceleration = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration - * @since 3.0.0 - * - * @param {number} x - The horizontal acceleration - * @param {number} [y=x] - The vertical acceleration - * - * @return {this} This Game Object. - */ - setAcceleration: function (x, y) - { - this.body.acceleration.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX - * @since 3.0.0 - * - * @param {number} value - The horizontal acceleration - * - * @return {this} This Game Object. - */ - setAccelerationX: function (value) - { - this.body.acceleration.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY - * @since 3.0.0 - * - * @param {number} value - The vertical acceleration - * - * @return {this} This Game Object. - */ - setAccelerationY: function (value) - { - this.body.acceleration.y = value; - - return this; - } - -}; - -module.exports = Acceleration; - - -/***/ }), -/* 702 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var DistanceBetween = __webpack_require__(58); -var Factory = __webpack_require__(345); -var GetFastValue = __webpack_require__(1); -var Merge = __webpack_require__(94); -var PluginCache = __webpack_require__(12); -var Vector2 = __webpack_require__(6); -var World = __webpack_require__(340); - -// All methods in this class are available under `this.physics` in a Scene. - -/** - * @classdesc - * [description] - * - * @class ArcadePhysics - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var ArcadePhysics = new Class({ - - initialize: - - function ArcadePhysics (scene) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#config - * @type {object} - * @since 3.0.0 - */ - this.config = this.getConfig(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#add - * @type {Phaser.Physics.Arcade.Factory} - * @since 3.0.0 - */ - this.add; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.world = new World(this.scene, this.config); - this.add = new Factory(this.world); - - this.systems.events.once('destroy', this.destroy, 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 () - { - if (!this.world) - { - 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); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig - * @since 3.0.0 - * - * @return {object} [description] - */ - getConfig: function () - { - var gameConfig = this.systems.game.config.physics; - var sceneConfig = this.systems.settings.physics; - - var config = Merge( - GetFastValue(sceneConfig, 'arcade', {}), - GetFastValue(gameConfig, 'arcade', {}) - ); - - return config; - }, - - /** - * Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body. - * - * Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. - * - * Both the first and second parameter can be arrays of objects, of differing types. - * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. - * - * ##### Tilemaps - * - * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. - * - * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). - * - * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#overlap - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {ArcadePhysicsCallback} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. - * @param {*} [callbackContext] - The context in which to run the callbacks. - * - * @return {boolean} True if an overlap occurred otherwise false. - */ - overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) - { - if (overlapCallback === undefined) { overlapCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = overlapCallback; } - - return this.world.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#collide - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {ArcadePhysicsCallback} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. - * @param {*} [callbackContext] - The context in which to run the callbacks. - * - * @return {boolean} True if a collision occurred otherwise false. - */ - collide: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - return this.world.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#pause - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} [description] - */ - pause: function () - { - return this.world.pause(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#resume - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} [description] - */ - resume: function () - { - return this.world.resume(); - }, - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateTo - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {number} x - The x coordinate to accelerate towards. - * @param {number} y - The y coordinate to accelerate towards. - * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. - * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. - * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - accelerateTo: function (gameObject, x, y, speed, xSpeedMax, ySpeedMax) - { - if (speed === undefined) { speed = 60; } - - var angle = Math.atan2(y - gameObject.y, x - gameObject.x); - - gameObject.body.acceleration.setToPolar(angle, speed); - - if (xSpeedMax !== undefined && ySpeedMax !== undefined) - { - gameObject.body.maxVelocity.set(xSpeedMax, ySpeedMax); - } - - return angle; - }, - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateToObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {Phaser.GameObjects.GameObject} destination - The Game Object to move towards. Can be any object but must have visible x/y properties. - * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. - * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. - * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - accelerateToObject: function (gameObject, destination, speed, xSpeedMax, ySpeedMax) - { - return this.accelerateTo(gameObject, destination.x, destination.y, speed, xSpeedMax, ySpeedMax); - }, - - /** - * Finds the Body closest to a source point or object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#closest - * @since 3.0.0 - * - * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * - * @return {Phaser.Physics.Arcade.Body} The closest Body to the given source point. - */ - closest: function (source) - { - var bodies = this.tree.all(); - - var min = Number.MAX_VALUE; - var closest = null; - var x = source.x; - var y = source.y; - - for (var i = bodies.length - 1; i >= 0; i--) - { - var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); - - if (distance < min) - { - closest = target; - min = distance; - } - } - - return closest; - }, - - /** - * Finds the Body farthest from a source point or object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#furthest - * @since 3.0.0 - * - * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * - * @return {Phaser.Physics.Arcade.Body} The Body furthest from the given source point. - */ - furthest: function (source) - { - var bodies = this.tree.all(); - - var max = -1; - var farthest = null; - var x = source.x; - var y = source.y; - - for (var i = bodies.length - 1; i >= 0; i--) - { - var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); - - if (distance > max) - { - farthest = target; - max = distance; - } - } - - return farthest; - }, - - /** - * Move the given display object towards the x/y coordinates at a steady velocity. - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @method Phaser.Physics.Arcade.ArcadePhysics#moveTo - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {number} x - The x coordinate to move towards. - * @param {number} y - The y coordinate to move towards. - * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - moveTo: function (gameObject, x, y, speed, maxTime) - { - if (speed === undefined) { speed = 60; } - if (maxTime === undefined) { maxTime = 0; } - - var angle = Math.atan2(y - gameObject.y, x - gameObject.x); - - if (maxTime > 0) - { - // We know how many pixels we need to move, but how fast? - speed = DistanceBetween(gameObject.x, gameObject.y, x, y) / (maxTime / 1000); - } - - gameObject.body.velocity.setToPolar(angle, speed); - - return angle; - }, - - /** - * Move the given display object towards the destination object at a steady velocity. - * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @method Phaser.Physics.Arcade.ArcadePhysics#moveToObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {object} destination - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - moveToObject: function (gameObject, destination, speed, maxTime) - { - return this.moveTo(gameObject, destination.x, destination.y, speed, maxTime); - }, - - /** - * Given the angle (in degrees) and speed calculate the velocity and return it as a vector, or set it to the given vector object. - * One way to use this is: velocityFromAngle(angle, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromAngle - * @since 3.0.0 - * - * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * @param {number} [speed=60] - The speed it will move, in pixels per second squared. - * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. - * - * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. - */ - velocityFromAngle: function (angle, speed, vec2) - { - if (speed === undefined) { speed = 60; } - if (vec2 === undefined) { vec2 = new Vector2(); } - - return vec2.setToPolar(DegToRad(angle), speed); - }, - - /** - * Given the rotation (in radians) and speed calculate the velocity and return it as a vector, or set it to the given vector object. - * One way to use this is: velocityFromRotation(rotation, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromRotation - * @since 3.0.0 - * - * @param {number} rotation - The angle in radians. - * @param {number} [speed=60] - The speed it will move, in pixels per second squared - * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. - * - * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. - */ - velocityFromRotation: function (rotation, speed, vec2) - { - if (speed === undefined) { speed = 60; } - if (vec2 === undefined) { vec2 = new Vector2(); } - - return vec2.setToPolar(rotation, speed); - }, - - /** - * 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.add.destroy(); - this.world.destroy(); - - this.add = null; - this.world = null; - }, - - /** - * 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.scene.sys.events.off('start', this.start, this); - - this.scene = null; - this.systems = null; - } - -}); - -PluginCache.register('ArcadePhysics', ArcadePhysics, 'arcadePhysics'); - -module.exports = ArcadePhysics; - - -/***/ }), -/* 703 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(42); -var Extend = __webpack_require__(17); - -/** - * @callback ArcadePhysicsCallback - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - */ - -/** - * @namespace Phaser.Physics.Arcade - */ - -var Arcade = { - - ArcadePhysics: __webpack_require__(702), - Body: __webpack_require__(339), - Collider: __webpack_require__(338), - Factory: __webpack_require__(345), - Group: __webpack_require__(342), - Image: __webpack_require__(344), - Sprite: __webpack_require__(142), - StaticBody: __webpack_require__(334), - StaticGroup: __webpack_require__(341), - World: __webpack_require__(340) - -}; - -// Merge in the consts -Arcade = Extend(false, Arcade, CONST); - -module.exports = Arcade; - - -/***/ }), -/* 704 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks if the two values are within the given `tolerance` of each other. - * - * @function Phaser.Math.Within - * @since 3.0.0 - * - * @param {number} a - The first value to use in the calculation. - * @param {number} b - The second value to use in the calculation. - * @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range. - * - * @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`. - */ -var Within = function (a, b, tolerance) -{ - return (Math.abs(a - b) <= tolerance); -}; - -module.exports = Within; - - -/***/ }), -/* 705 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} SinCosTable - * - * @property {number} sin - The sine value. - * @property {number} cos - The cosine value. - * @property {number} length - The length. - */ - -/** - * Generate a series of sine and cosine values. - * - * @function Phaser.Math.SinCosTableGenerator - * @since 3.0.0 - * - * @param {number} length - The number of values to generate. - * @param {number} [sinAmp=1] - The sine value amplitude. - * @param {number} [cosAmp=1] - The cosine value amplitude. - * @param {number} [frequency=1] - The frequency of the values. - * - * @return {SinCosTable} The generated values. - */ -var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency) -{ - if (sinAmp === undefined) { sinAmp = 1; } - if (cosAmp === undefined) { cosAmp = 1; } - if (frequency === undefined) { frequency = 1; } - - frequency *= Math.PI / length; - - var cos = []; - var sin = []; - - for (var c = 0; c < length; c++) - { - cosAmp -= sinAmp * frequency; - sinAmp += cosAmp * frequency; - - cos[c] = cosAmp; - sin[c] = sinAmp; - } - - return { - sin: sin, - cos: cos, - length: length - }; -}; - -module.exports = SinCosTableGenerator; - - -/***/ }), -/* 706 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Round a value to a given decimal place. - * - * @function Phaser.Math.RoundTo - * @since 3.0.0 - * - * @param {number} value - The value to round. - * @param {integer} [place=0] - The place to round to. - * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. - * - * @return {number} The rounded value. - */ -var RoundTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.round(value * p) / p; -}; - -module.exports = RoundTo; - - -/***/ }), -/* 707 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compute a random unit vector. - * - * Computes random values for the given vector between -1 and 1 that can be used to represent a direction. - * - * Optionally accepts a scale value to scale the resulting vector by. - * - * @function Phaser.Math.RandomXY - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} vector - The Vector to compute random values for. - * @param {float} [scale=1] - The scale of the random values. - * - * @return {Phaser.Math.Vector2} The given Vector. - */ -var RandomXY = function (vector, scale) -{ - if (scale === undefined) { scale = 1; } - - var r = Math.random() * 2 * Math.PI; - - vector.x = Math.cos(r) * scale; - vector.y = Math.sin(r) * scale; - - return vector; -}; - -module.exports = RandomXY; - - -/***/ }), -/* 708 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Work out what percentage `value` is of the range between `min` and `max`. - * If `max` isn't given then it will return the percentage of `value` to `min`. - * - * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. - * - * @function Phaser.Math.Percent - * @since 3.0.0 - * - * @param {number} value - The value to determine the percentage of. - * @param {number} min - The minimum value. - * @param {number} [max] - The maximum value. - * @param {number} [upperMax] - The mid-way point in the range that represents 100%. - * - * @return {float} A value between 0 and 1 representing the percentage. - */ -var Percent = function (value, min, max, upperMax) -{ - if (max === undefined) { max = min + 1; } - - var percentage = (value - min) / (max - min); - - if (percentage > 1) - { - if (upperMax !== undefined) - { - percentage = ((upperMax - value)) / (upperMax - max); - - if (percentage < 0) - { - percentage = 0; - } - } - else - { - percentage = 1; - } - } - else if (percentage < 0) - { - percentage = 0; - } - - return percentage; -}; - -module.exports = Percent; - - -/***/ }), -/* 709 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Subtract an `amount` from `value`, limiting the minimum result to `min`. - * - * @function Phaser.Math.MinSub - * @since 3.0.0 - * - * @param {number} value - The value to subtract from. - * @param {number} amount - The amount to subtract. - * @param {number} min - The minimum value to return. - * - * @return {number} The resulting value. - */ -var MinSub = function (value, amount, min) -{ - return Math.max(value - amount, min); -}; - -module.exports = MinSub; - - -/***/ }), -/* 710 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Add an `amount` to a `value`, limiting the maximum result to `max`. - * - * @function Phaser.Math.MaxAdd - * @since 3.0.0 - * - * @param {number} value - The value to add to. - * @param {number} amount - The amount to add. - * @param {number} max - The maximum value to return. - * - * @return {number} The resulting value. - */ -var MaxAdd = function (value, amount, max) -{ - return Math.min(value + amount, max); -}; - -module.exports = MaxAdd; - - -/***/ }), -/* 711 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check if a given value is an even number using a strict type check. - * - * @function Phaser.Math.IsEvenStrict - * @since 3.0.0 - * - * @param {number} value - The number to perform the check with. - * - * @return {boolean} Whether the number is even or not. - */ -var IsEvenStrict = function (value) -{ - // Use strict equality === for "is number" test - return (value === parseFloat(value)) ? !(value % 2) : void 0; -}; - -module.exports = IsEvenStrict; - - -/***/ }), -/* 712 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check if a given value is an even number. - * - * @function Phaser.Math.IsEven - * @since 3.0.0 - * - * @param {number} value - The number to perform the check with. - * - * @return {boolean} Whether the number is even or not. - */ -var IsEven = function (value) -{ - // Use abstract equality == for "is number" test - - // eslint-disable-next-line eqeqeq - return (value == parseFloat(value)) ? !(value % 2) : void 0; -}; - -module.exports = IsEven; - - -/***/ }), -/* 713 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the speed required to cover a distance in the time given. - * - * @function Phaser.Math.GetSpeed - * @since 3.0.0 - * - * @param {number} distance - The distance to travel in pixels. - * @param {integer} time - The time, in ms, to cover the distance in. - * - * @return {number} The amount you will need to increment the position by each step in order to cover the distance in the time given. - */ -var GetSpeed = function (distance, time) -{ - return (distance / time) / 1000; -}; - -module.exports = GetSpeed; - - -/***/ }), -/* 714 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Floors to some place comparative to a `base`, default is 10 for decimal place. - * - * The `place` is represented by the power applied to `base` to get that place. - * - * @function Phaser.Math.FloorTo - * @since 3.0.0 - * - * @param {number} value - The value to round. - * @param {integer} [place=0] - The place to round to. - * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. - * - * @return {number} The rounded value. - */ -var FloorTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.floor(value * p) / p; -}; - -module.exports = FloorTo; - - -/***/ }), -/* 715 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the positive difference of two given numbers. - * - * @function Phaser.Math.Difference - * @since 3.0.0 - * - * @param {number} a - The first number in the calculation. - * @param {number} b - The second number in the calculation. - * - * @return {number} The positive difference of the two given numbers. - */ -var Difference = function (a, b) -{ - return Math.abs(a - b); -}; - -module.exports = Difference; - - -/***/ }), -/* 716 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Ceils to some place comparative to a `base`, default is 10 for decimal place. - * - * The `place` is represented by the power applied to `base` to get that place. - * - * @function Phaser.Math.CeilTo - * @since 3.0.0 - * - * @param {number} value - The value to round. - * @param {number} [place=0] - The place to round to. - * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. - * - * @return {number} The rounded value. - */ -var CeilTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.ceil(value * p) / p; -}; - -module.exports = CeilTo; - - -/***/ }), -/* 717 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the mean average of the given values. - * - * @function Phaser.Math.Average - * @since 3.0.0 - * - * @param {number[]} values - The values to average. - * - * @return {number} The average value. - */ -var Average = function (values) -{ - var sum = 0; - - for (var i = 0; i < values.length; i++) - { - sum += (+values[i]); - } - - return sum / values.length; -}; - -module.exports = Average; - - -/***/ }), -/* 718 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Snap a value to nearest grid slice, using rounding. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10` whereas `14` will snap to `15`. - * - * @function Phaser.Math.Snap.To - * @since 3.0.0 - * - * @param {number} value - The value to snap. - * @param {number} gap - The interval gap of the grid. - * @param {number} [start=0] - Optional starting offset for gap. - * - * @return {number} The snapped value. - */ -var SnapTo = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.round(value / gap); - - return start + value; -}; - -module.exports = SnapTo; - - -/***/ }), -/* 719 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Snap a value to nearest grid slice, using floor. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10`. - * As will `14` snap to `10`... but `16` will snap to `15`. - * - * @function Phaser.Math.Snap.Floor - * @since 3.0.0 - * - * @param {number} value - The value to snap. - * @param {number} gap - The interval gap of the grid. - * @param {number} [start=0] - Optional starting offset for gap. - * - * @return {number} The snapped value. - */ -var SnapFloor = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.floor(value / gap); - - return start + value; -}; - -module.exports = SnapFloor; - - -/***/ }), -/* 720 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Snap a value to nearest grid slice, using ceil. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `15`. - * As will `14` snap to `15`... but `16` will snap to `20`. - * - * @function Phaser.Math.Snap.Ceil - * @since 3.0.0 - * - * @param {number} value - The value to snap. - * @param {number} gap - The interval gap of the grid. - * @param {number} [start=0] - Optional starting offset for gap. - * - * @return {number} The snapped value. - */ -var SnapCeil = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.ceil(value / gap); - - return start + value; -}; - -module.exports = SnapCeil; - - -/***/ }), -/* 721 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Snap - */ - -module.exports = { - - Ceil: __webpack_require__(720), - Floor: __webpack_require__(719), - To: __webpack_require__(718) - -}; - - -/***/ }), -/* 722 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Tests the value and returns `true` if it is a power of two. - * - * @function Phaser.Math.Pow2.IsValuePowerOfTwo - * @since 3.0.0 - * - * @param {number} value - The value to check if it's a power of two. - * - * @return {boolean} Returns `true` if `value` is a power of two, otherwise `false`. - */ -var IsValuePowerOfTwo = function (value) -{ - return (value > 0 && (value & (value - 1)) === 0); -}; - -module.exports = IsValuePowerOfTwo; - - -/***/ }), -/* 723 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Pow2 - */ - -module.exports = { - - GetNext: __webpack_require__(411), - IsSize: __webpack_require__(85), - IsValue: __webpack_require__(722) - -}; - - -/***/ }), -/* 724 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SmootherStep = __webpack_require__(287); - -/** - * A Smoother Step interpolation method. - * - * @function Phaser.Math.Interpolation.SmootherStep - * @since 3.9.0 - * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} - * - * @param {number} t - The percentage of interpolation, between 0 and 1. - * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - * - * @return {number} The interpolated value. - */ -var SmootherStepInterpolation = function (t, min, max) -{ - return min + (max - min) * SmootherStep(t, 0, 1); -}; - -module.exports = SmootherStepInterpolation; - - -/***/ }), -/* 725 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SmoothStep = __webpack_require__(286); - -/** - * A Smooth Step interpolation method. - * - * @function Phaser.Math.Interpolation.SmoothStep - * @since 3.9.0 - * @see {@link https://en.wikipedia.org/wiki/Smoothstep} - * - * @param {number} t - The percentage of interpolation, between 0 and 1. - * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - * - * @return {number} The interpolated value. - */ -var SmoothStepInterpolation = function (t, min, max) -{ - return min + (max - min) * SmoothStep(t, 0, 1); -}; - -module.exports = SmoothStepInterpolation; - - -/***/ }), -/* 726 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Linear = __webpack_require__(122); - -/** - * A linear interpolation method. - * - * @function Phaser.Math.Interpolation.Linear - * @since 3.0.0 - * @see {@link https://en.wikipedia.org/wiki/Linear_interpolation} - * - * @param {number[]} v - The input array of values to interpolate between. - * @param {!number} k - The percentage of interpolation, between 0 and 1. - * - * @return {!number} The interpolated value. - */ -var LinearInterpolation = function (v, k) -{ - var m = v.length - 1; - var f = m * k; - var i = Math.floor(f); - - if (k < 0) - { - return Linear(v[0], v[1], f); - } - - if (k > 1) - { - return Linear(v[m], v[m - 1], m - f); - } - - return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); -}; - -module.exports = LinearInterpolation; - - -/***/ }), -/* 727 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CatmullRom = __webpack_require__(273); - -/** - * A Catmull-Rom interpolation method. - * - * @function Phaser.Math.Interpolation.CatmullRom - * @since 3.0.0 - * - * @param {number[]} v - The input array of values to interpolate between. - * @param {number} k - The percentage of interpolation, between 0 and 1. - * - * @return {number} The interpolated value. - */ -var CatmullRomInterpolation = function (v, k) -{ - var m = v.length - 1; - var f = m * k; - var i = Math.floor(f); - - if (v[0] === v[m]) - { - if (k < 0) - { - i = Math.floor(f = m * (1 + k)); - } - - return CatmullRom(f - i, v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m]); - } - else - { - if (k < 0) - { - return v[0] - (CatmullRom(-f, v[0], v[0], v[1], v[1]) - v[0]); - } - - if (k > 1) - { - return v[m] - (CatmullRom(f - m, v[m], v[m], v[m - 1], v[m - 1]) - v[m]); - } - - return CatmullRom(f - i, v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2]); - } -}; - -module.exports = CatmullRomInterpolation; - - -/***/ }), -/* 728 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Bernstein = __webpack_require__(348); - -/** - * A bezier interpolation method. - * - * @function Phaser.Math.Interpolation.Bezier - * @since 3.0.0 - * - * @param {number[]} v - The input array of values to interpolate between. - * @param {number} k - The percentage of interpolation, between 0 and 1. - * - * @return {number} The interpolated value. - */ -var BezierInterpolation = function (v, k) -{ - var b = 0; - var n = v.length - 1; - - for (var i = 0; i <= n; i++) - { - b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * Bernstein(n, i); - } - - return b; -}; - -module.exports = BezierInterpolation; - - -/***/ }), -/* 729 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Interpolation - */ - -module.exports = { - - Bezier: __webpack_require__(728), - CatmullRom: __webpack_require__(727), - CubicBezier: __webpack_require__(550), - Linear: __webpack_require__(726), - QuadraticBezier: __webpack_require__(546), - SmoothStep: __webpack_require__(725), - SmootherStep: __webpack_require__(724) - -}; - - -/***/ }), -/* 730 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the fuzzy floor of the given value. - * - * @function Phaser.Math.Fuzzy.Floor - * @since 3.0.0 - * - * @param {number} value - The value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {number} The floor of the value. - */ -var Floor = function (value, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.floor(value + epsilon); -}; - -module.exports = Floor; - - -/***/ }), -/* 731 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the fuzzy ceiling of the given value. - * - * @function Phaser.Math.Fuzzy.Ceil - * @since 3.0.0 - * - * @param {number} value - The value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {number} The fuzzy ceiling of the value. - */ -var Ceil = function (value, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.ceil(value - epsilon); -}; - -module.exports = Ceil; - - -/***/ }), -/* 732 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Fuzzy - */ - -module.exports = { - - Ceil: __webpack_require__(731), - Equal: __webpack_require__(351), - Floor: __webpack_require__(730), - GreaterThan: __webpack_require__(350), - LessThan: __webpack_require__(349) - -}; - - -/***/ }), -/* 733 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing - */ - -module.exports = { - - Back: __webpack_require__(247), - Bounce: __webpack_require__(246), - Circular: __webpack_require__(245), - Cubic: __webpack_require__(244), - Elastic: __webpack_require__(243), - Expo: __webpack_require__(242), - Linear: __webpack_require__(241), - Quadratic: __webpack_require__(240), - Quartic: __webpack_require__(239), - Quintic: __webpack_require__(238), - Sine: __webpack_require__(237), - Stepped: __webpack_require__(236) - -}; - - -/***/ }), -/* 734 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the distance between two sets of coordinates (points), squared. - * - * @function Phaser.Math.Distance.Squared - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the first point. - * @param {number} y1 - The y coordinate of the first point. - * @param {number} x2 - The x coordinate of the second point. - * @param {number} y2 - The y coordinate of the second point. - * - * @return {number} The distance between each point, squared. - */ -var DistanceSquared = function (x1, y1, x2, y2) -{ - var dx = x1 - x2; - var dy = y1 - y2; - - return dx * dx + dy * dy; -}; - -module.exports = DistanceSquared; - - -/***/ }), -/* 735 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the distance between two sets of coordinates (points) to the power of `pow`. - * - * @function Phaser.Math.Distance.Power - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the first point. - * @param {number} y1 - The y coordinate of the first point. - * @param {number} x2 - The x coordinate of the second point. - * @param {number} y2 - The y coordinate of the second point. - * @param {number} pow - The exponent. - * - * @return {number} The distance between each point. - */ -var DistancePower = function (x1, y1, x2, y2, pow) -{ - if (pow === undefined) { pow = 2; } - - return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow)); -}; - -module.exports = DistancePower; - - -/***/ }), -/* 736 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Distance - */ - -module.exports = { - - Between: __webpack_require__(58), - Power: __webpack_require__(735), - Squared: __webpack_require__(734) - -}; - - -/***/ }), -/* 737 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Gets the shortest angle between `angle1` and `angle2`. - * - * Both angles must be in the range -180 to 180, which is the same clamped - * range that `sprite.angle` uses, so you can pass in two sprite angles to - * this method and get the shortest angle back between the two of them. - * - * The angle returned will be in the same range. If the returned angle is - * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's - * a clockwise rotation. - * - * TODO: Wrap the angles in this function? - * - * @function Phaser.Math.Angle.ShortestBetween - * @since 3.0.0 - * - * @param {number} angle1 - The first angle in the range -180 to 180. - * @param {number} angle2 - The second angle in the range -180 to 180. - * - * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. - */ -var ShortestBetween = function (angle1, angle2) -{ - var difference = angle2 - angle1; - - if (difference === 0) - { - return 0; - } - - var times = Math.floor((difference - (-180)) / 360); - - return difference - (times * 360); - -}; - -module.exports = ShortestBetween; - - -/***/ }), -/* 738 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); - -/** - * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. - * - * @function Phaser.Math.Angle.RotateTo - * @since 3.0.0 - * - * @param {number} currentAngle - The current angle, in radians. - * @param {number} targetAngle - The target angle to rotate to, in radians. - * @param {number} [lerp=0.05] - The lerp value to add to the current angle. - * - * @return {number} The adjusted angle. - */ -var RotateTo = function (currentAngle, targetAngle, lerp) -{ - if (lerp === undefined) { lerp = 0.05; } - - if (currentAngle === targetAngle) - { - return currentAngle; - } - - if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp)) - { - currentAngle = targetAngle; - } - else - { - if (Math.abs(targetAngle - currentAngle) > Math.PI) - { - if (targetAngle < currentAngle) - { - targetAngle += MATH_CONST.PI2; - } - else - { - targetAngle -= MATH_CONST.PI2; - } - } - - if (targetAngle > currentAngle) - { - currentAngle += lerp; - } - else if (targetAngle < currentAngle) - { - currentAngle -= lerp; - } - } - - return currentAngle; -}; - -module.exports = RotateTo; - - -/***/ }), -/* 739 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Normalize = __webpack_require__(352); - -/** - * Reverse the given angle. - * - * @function Phaser.Math.Angle.Reverse - * @since 3.0.0 - * - * @param {number} angle - The angle to reverse, in radians. - * - * @return {number} The reversed angle, in radians. - */ -var Reverse = function (angle) -{ - return Normalize(angle + Math.PI); -}; - -module.exports = Reverse; - - -/***/ }), -/* 740 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). - * - * The difference between this method and {@link Phaser.Math.Angle.BetweenPoints} is that this assumes the y coordinate - * travels down the screen. - * - * @function Phaser.Math.Angle.BetweenPointsY - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|object)} point1 - The first point. - * @param {(Phaser.Geom.Point|object)} point2 - The second point. - * - * @return {number} The angle in radians. - */ -var BetweenPointsY = function (point1, point2) -{ - return Math.atan2(point2.x - point1.x, point2.y - point1.y); -}; - -module.exports = BetweenPointsY; - - -/***/ }), -/* 741 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). - * - * Calculates the angle of the vector from the first point to the second point. - * - * @function Phaser.Math.Angle.BetweenPoints - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|object)} point1 - The first point. - * @param {(Phaser.Geom.Point|object)} point2 - The second point. - * - * @return {number} The angle in radians. - */ -var BetweenPoints = function (point1, point2) -{ - return Math.atan2(point2.y - point1.y, point2.x - point1.x); -}; - -module.exports = BetweenPoints; - - -/***/ }), -/* 742 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Find the angle of a segment from (x1, y1) -> (x2, y2). - * - * The difference between this method and {@link Phaser.Math.Angle.Between} is that this assumes the y coordinate - * travels down the screen. - * - * @function Phaser.Math.Angle.BetweenY - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the first point. - * @param {number} y1 - The y coordinate of the first point. - * @param {number} x2 - The x coordinate of the second point. - * @param {number} y2 - The y coordinate of the second point. - * - * @return {number} The angle in radians. - */ -var BetweenY = function (x1, y1, x2, y2) -{ - return Math.atan2(x2 - x1, y2 - y1); -}; - -module.exports = BetweenY; - - -/***/ }), -/* 743 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Find the angle of a segment from (x1, y1) -> (x2, y2). - * - * @function Phaser.Math.Angle.Between - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the first point. - * @param {number} y1 - The y coordinate of the first point. - * @param {number} x2 - The x coordinate of the second point. - * @param {number} y2 - The y coordinate of the second point. - * - * @return {number} The angle in radians. - */ -var Between = function (x1, y1, x2, y2) -{ - return Math.atan2(y2 - y1, x2 - x1); -}; - -module.exports = Between; - - -/***/ }), -/* 744 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Angle - */ - -module.exports = { - - Between: __webpack_require__(743), - BetweenY: __webpack_require__(742), - BetweenPoints: __webpack_require__(741), - BetweenPointsY: __webpack_require__(740), - Reverse: __webpack_require__(739), - RotateTo: __webpack_require__(738), - ShortestBetween: __webpack_require__(737), - Normalize: __webpack_require__(352), - Wrap: __webpack_require__(212), - WrapDegrees: __webpack_require__(211) - -}; - - -/***/ }), -/* 745 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser.Math - */ - -var PhaserMath = { - - // Collections of functions - Angle: __webpack_require__(744), - Distance: __webpack_require__(736), - Easing: __webpack_require__(733), - Fuzzy: __webpack_require__(732), - Interpolation: __webpack_require__(729), - Pow2: __webpack_require__(723), - Snap: __webpack_require__(721), - - // Expose the RNG Class - RandomDataGenerator: __webpack_require__(297), - - // Single functions - Average: __webpack_require__(717), - Bernstein: __webpack_require__(348), - Between: __webpack_require__(149), - CatmullRom: __webpack_require__(273), - CeilTo: __webpack_require__(716), - Clamp: __webpack_require__(23), - DegToRad: __webpack_require__(38), - Difference: __webpack_require__(715), - Factorial: __webpack_require__(347), - FloatBetween: __webpack_require__(248), - FloorTo: __webpack_require__(714), - FromPercent: __webpack_require__(65), - GetSpeed: __webpack_require__(713), - IsEven: __webpack_require__(712), - IsEvenStrict: __webpack_require__(711), - Linear: __webpack_require__(122), - MaxAdd: __webpack_require__(710), - MinSub: __webpack_require__(709), - Percent: __webpack_require__(708), - RadToDeg: __webpack_require__(150), - RandomXY: __webpack_require__(707), - RandomXYZ: __webpack_require__(561), - RandomXYZW: __webpack_require__(560), - Rotate: __webpack_require__(346), - RotateAround: __webpack_require__(292), - RotateAroundDistance: __webpack_require__(288), - RoundAwayFromZero: __webpack_require__(255), - RoundTo: __webpack_require__(706), - SinCosTableGenerator: __webpack_require__(705), - SmootherStep: __webpack_require__(287), - SmoothStep: __webpack_require__(286), - TransformXY: __webpack_require__(257), - Within: __webpack_require__(704), - Wrap: __webpack_require__(39), - - // Vector classes - Vector2: __webpack_require__(6), - Vector3: __webpack_require__(87), - Vector4: __webpack_require__(277), - Matrix3: __webpack_require__(557), - Matrix4: __webpack_require__(278), - Quaternion: __webpack_require__(558), - RotateVec3: __webpack_require__(559) - -}; - -// Merge in the consts - -PhaserMath = Extend(false, PhaserMath, CONST); - -// Export it - -module.exports = PhaserMath; - - -/***/ }), -/* 746 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); -var IsPlainObject = __webpack_require__(8); -var MultiFile = __webpack_require__(36); -var TextFile = __webpack_require__(224); - -/** - * @typedef {object} Phaser.Loader.FileTypes.UnityAtlasFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. - * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. - * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. - * @property {string} [atlasURL] - The absolute or relative URL to load the atlas data file from. - * @property {string} [atlasExtension='txt'] - The default file extension to use for the atlas data if no url is provided. - * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas data file. - */ - -/** - * @classdesc - * A single text file based Unity Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#unityAtlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#unityAtlas. - * - * @class UnityAtlasFile - * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes - * @constructor - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. - */ -var UnityAtlasFile = new Class({ - - Extends: MultiFile, - - initialize: - - function UnityAtlasFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) - { - var image; - var data; - - if (IsPlainObject(key)) - { - var config = key; - - image = new ImageFile(loader, { - key: key, - url: GetFastValue(config, 'textureURL'), - extension: GetFastValue(config, 'textureExtension', 'png'), - normalMap: GetFastValue(config, 'normalMap'), - xhrSettings: GetFastValue(config, 'textureXhrSettings') - }); - - data = new TextFile(loader, { - key: key, - url: GetFastValue(config, 'atlasURL'), - extension: GetFastValue(config, 'atlasExtension', 'txt'), - xhrSettings: GetFastValue(config, 'atlasXhrSettings') - }); - } - else - { - image = new ImageFile(loader, key, textureURL, textureXhrSettings); - data = new TextFile(loader, key, atlasURL, atlasXhrSettings); - } - - if (image.linkFile) - { - // Image has a normal map - MultiFile.call(this, loader, 'unityatlas', key, [ image, data, image.linkFile ]); - } - else - { - MultiFile.call(this, loader, 'unityatlas', key, [ image, data ]); - } - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.UnityAtlasFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.failed === 0 && !this.complete) - { - var image = this.files[0]; - var text = this.files[1]; - var normalMap = (this.files[2]) ? this.files[2].data : null; - - this.loader.textureManager.addUnityAtlas(image.key, image.data, text.data, normalMap); - - text.addToCache(); - - this.complete = true; - } - } - -}); - -/** - * Adds a Unity YAML based Texture Atlas, or array of atlases, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.unityAtlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * atlasURL: 'images/MainMenu.txt' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.UnityAtlasFileConfig` for more details. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); - * // and later in your game ... - * this.add.image(x, y, 'mainmenu', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.unityAtlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * normalMap: 'images/MainMenu-n.png', - * atlasURL: 'images/MainMenu.txt' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Unity Atlas File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#unityAtlas - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig|Phaser.Loader.FileTypes.UnityAtlasFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) -{ - var multifile; - - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - multifile = new UnityAtlasFile(this, key[i]); - - this.addFile(multifile.files); - } - } - else - { - multifile = new UnityAtlasFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); - - this.addFile(multifile.files); - } - - return this; -}); - -module.exports = UnityAtlasFile; - - -/***/ }), -/* 747 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(28); -var TILEMAP_FORMATS = __webpack_require__(26); - -/** - * @typedef {object} Phaser.Loader.FileTypes.TilemapJSONFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='json'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Tiled Tilemap JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. - * - * @class TilemapJSONFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var TilemapJSONFile = new Class({ - - Extends: JSONFile, - - initialize: - - function TilemapJSONFile (loader, key, url, xhrSettings) - { - JSONFile.call(this, loader, key, url, xhrSettings); - - this.type = 'tilemapJSON'; - - this.cache = loader.cacheManager.tilemap; - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.TilemapJSONFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var tiledata = { format: TILEMAP_FORMATS.TILED_JSON, data: this.data }; - - this.cache.add(this.key, tiledata); - - this.pendingDestroy(tiledata); - } - -}); - -/** - * Adds a Tiled JSON Tilemap file, or array of map files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.tilemapTiledJSON('level1', maps/Level1.json'); - * } - * ``` - * - * The Tilemap data is created using the Tiled Map Editor and selecting JSON as the export format. - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.tilemapTiledJSON({ - * key: 'level1', - * url: 'maps/Level1.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TilemapJSONFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); - * // and later in your game ... - * var map = this.make.tilemap({ key: 'level1' }); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Tilemap Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" - * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Tilemap JSON File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig|Phaser.Loader.FileTypes.TilemapJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TilemapJSONFile(this, key[i])); - } - } - else - { - this.addFile(new TilemapJSONFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = TilemapJSONFile; - - -/***/ }), -/* 748 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(28); -var TILEMAP_FORMATS = __webpack_require__(26); - -/** - * @typedef {object} Phaser.Loader.FileTypes.TilemapImpactFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='json'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Impact.js Tilemap JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. - * - * @class TilemapImpactFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var TilemapImpactFile = new Class({ - - Extends: JSONFile, - - initialize: - - function TilemapImpactFile (loader, key, url, xhrSettings) - { - JSONFile.call(this, loader, key, url, xhrSettings); - - this.type = 'tilemapJSON'; - - this.cache = loader.cacheManager.tilemap; - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.TilemapImpactFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var tiledata = { format: TILEMAP_FORMATS.WELTMEISTER, data: this.data }; - - this.cache.add(this.key, tiledata); - - this.pendingDestroy(tiledata); - } - -}); - -/** - * Adds an Impact.js Tilemap file, or array of map files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.tilemapImpact('level1', maps/Level1.json'); - * } - * ``` - * - * Impact Tilemap data is created the Impact.js Map Editor called Weltmeister. - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.tilemapImpact({ - * key: 'level1', - * url: 'maps/Level1.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TilemapImpactFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.tilemapImpact('level1', 'maps/Level1.json'); - * // and later in your game ... - * var map = this.make.tilemap({ key: 'level1' }); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Tilemap Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" - * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Tilemap Impact File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#tilemapImpact - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.7.0 - * - * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig|Phaser.Loader.FileTypes.TilemapImpactFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('tilemapImpact', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TilemapImpactFile(this, key[i])); - } - } - else - { - this.addFile(new TilemapImpactFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = TilemapImpactFile; - - -/***/ }), -/* 749 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); -var TILEMAP_FORMATS = __webpack_require__(26); - -/** - * @typedef {object} Phaser.Loader.FileTypes.TilemapCSVFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='csv'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Tilemap CSV File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. - * - * @class TilemapCSVFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var TilemapCSVFile = new Class({ - - Extends: File, - - initialize: - - function TilemapCSVFile (loader, key, url, xhrSettings) - { - var extension = 'csv'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'tilemapCSV', - cache: loader.cacheManager.tilemap, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - - this.tilemapFormat = TILEMAP_FORMATS.CSV; - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.TilemapCSVFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onProcessComplete(); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.TilemapCSVFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var tiledata = { format: this.tilemapFormat, data: this.data }; - - this.cache.add(this.key, tiledata); - - this.pendingDestroy(tiledata); - } - -}); - -/** - * Adds a CSV Tilemap file, or array of CSV files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.tilemapCSV('level1', maps/Level1.csv'); - * } - * ``` - * - * Tilemap CSV data can be created in a text editor, or a 3rd party app that exports as CSV. - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.tilemapCSV({ - * key: 'level1', - * url: 'maps/Level1.csv' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TilemapCSVFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.tilemapCSV('level1', 'maps/Level1.csv'); - * // and later in your game ... - * var map = this.make.tilemap({ key: 'level1' }); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Tilemap Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" - * and no URL is given then the Loader will set the URL to be "level.csv". It will always add `.csv` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Tilemap CSV File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#tilemapCSV - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig|Phaser.Loader.FileTypes.TilemapCSVFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TilemapCSVFile(this, key[i])); - } - } - else - { - this.addFile(new TilemapCSVFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = TilemapCSVFile; - - -/***/ }), -/* 750 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.SVGFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='svg'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single SVG File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. - * - * @class SVGFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var SVGFile = new Class({ - - Extends: File, - - initialize: - - function SVGFile (loader, key, url, xhrSettings) - { - var extension = 'svg'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'svg', - cache: loader.textureManager, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.SVGFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - var svg = [ this.xhrLoader.responseText ]; - - try - { - var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); - } - catch (e) - { - this.onProcessError(); - - return; - } - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - var _this = this; - var retry = false; - - this.data.onload = function () - { - if (!retry) - { - File.revokeObjectURL(_this.data); - } - - _this.onProcessComplete(); - }; - - this.data.onerror = function () - { - // Safari 8 re-try - if (!retry) - { - retry = true; - - File.revokeObjectURL(_this.data); - - _this.data.src = 'data:image/svg+xml,' + encodeURIComponent(svg.join('')); - } - else - { - _this.onProcessError(); - } - }; - - File.createObjectURL(this.data, blob, 'image/svg+xml'); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.SVGFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var texture = this.cache.addImage(this.key, this.data); - - this.pendingDestroy(texture); - } - -}); - -/** - * Adds an SVG File, or array of SVG Files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.svg('morty', 'images/Morty.svg'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.svg({ - * key: 'morty', - * url: 'images/Morty.svg' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.SVGFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.svg('morty', 'images/Morty.svg'); - * // and later in your game ... - * this.add.image(x, y, 'morty'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#svg - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig|Phaser.Loader.FileTypes.SVGFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('svg', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new SVGFile(this, key[i])); - } - } - else - { - this.addFile(new SVGFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = SVGFile; - - -/***/ }), -/* 751 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.ScenePluginFileConfig - * - * @property {string} key - The key of the file. Must be unique within the Loader. - * @property {(string|function)} [url] - The absolute or relative URL to load the file from. Or, a Scene Plugin. - * @property {string} [extension='js'] - The default file extension to use if no url is provided. - * @property {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. - * @property {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Scene Plugin Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#scenePlugin method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scenePlugin. - * - * @class ScenePluginFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.8.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. - * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var ScenePluginFile = new Class({ - - Extends: File, - - initialize: - - function ScenePluginFile (loader, key, url, systemKey, sceneKey, xhrSettings) - { - var extension = 'js'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - systemKey = GetFastValue(config, 'systemKey'); - sceneKey = GetFastValue(config, 'sceneKey'); - } - - var fileConfig = { - type: 'scenePlugin', - cache: false, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings, - config: { - systemKey: systemKey, - sceneKey: sceneKey - } - }; - - File.call(this, loader, fileConfig); - - // If the url variable refers to a class, add the plugin directly - if (typeof url === 'function') - { - this.data = url; - - this.state = CONST.FILE_POPULATED; - } - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.ScenePluginFile#onProcess - * @since 3.8.0 - */ - onProcess: function () - { - var pluginManager = this.loader.systems.plugins; - var config = this.config; - - var key = this.key; - var systemKey = GetFastValue(config, 'systemKey', key); - var sceneKey = GetFastValue(config, 'sceneKey', key); - - if (this.state === CONST.FILE_POPULATED) - { - pluginManager.installScenePlugin(systemKey, this.data, sceneKey, this.loader.scene); - } - else - { - // Plugin added via a js file - this.state = CONST.FILE_PROCESSING; - - this.data = document.createElement('script'); - this.data.language = 'javascript'; - this.data.type = 'text/javascript'; - this.data.defer = false; - this.data.text = this.xhrLoader.responseText; - - document.head.appendChild(this.data); - - pluginManager.installScenePlugin(systemKey, window[this.key], sceneKey, this.loader.scene); - } - - this.onProcessComplete(); - } - -}); - -/** - * Adds a Scene Plugin Script file, or array of plugin files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.scenePlugin('ModPlayer', 'plugins/ModPlayer.js', 'modPlayer', 'mods'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String and not already in-use by another file in the Loader. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.scenePlugin({ - * key: 'modplayer', - * url: 'plugins/ModPlayer.js' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.ScenePluginFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a script element - * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to - * false and then the resulting element will be appended to `document.head`. Any code then in the - * script will be executed. It will then be passed to the Phaser PluginCache.register method. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Script File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#scenePlugin - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.8.0 - * - * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig|Phaser.Loader.FileTypes.ScenePluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {(string|function)} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, set to a plugin function. - * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. - * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('scenePlugin', function (key, url, systemKey, sceneKey, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new ScenePluginFile(this, key[i])); - } - } - else - { - this.addFile(new ScenePluginFile(this, key, url, systemKey, sceneKey, xhrSettings)); - } - - return this; -}); - -module.exports = ScenePluginFile; - - -/***/ }), -/* 752 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(28); - -/** - * @typedef {object} Phaser.Loader.FileTypes.PackFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the JSON Cache. - * @property {string|any} [url] - The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly processed. - * @property {string} [extension='json'] - The default file extension to use if no url is provided. - * @property {string} [dataKey] - If specified instead of the whole JSON file being parsed, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single JSON Pack File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#pack method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#pack. - * - * @class PackFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. - */ -var PackFile = new Class({ - - Extends: JSONFile, - - initialize: - - // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object - // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing - - function PackFile (loader, key, url, xhrSettings, dataKey) - { - JSONFile.call(this, loader, key, url, xhrSettings, dataKey); - - this.type = 'packfile'; - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.PackFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - if (this.state !== CONST.FILE_POPULATED) - { - this.state = CONST.FILE_PROCESSING; - - this.data = JSON.parse(this.xhrLoader.responseText); - } - - // Let's pass the pack file data over to the Loader ... - this.loader.addPack(this.data, this.config); - - this.onProcessComplete(); - } - -}); - -/** - * Adds a JSON File Pack, or array of packs, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.pack('level1', 'data/Level1Files.json'); - * } - * ``` - * - * A File Pack is a JSON file (or object) that contains details about other files that should be added into the Loader. - * Here is a small example: - * - * ```json - * { - * "test1": { - * "files": [ - * { - * "type": "image", - * "key": "taikodrummaster", - * "url": "assets/pics/taikodrummaster.jpg" - * }, - * { - * "type": "image", - * "key": "sukasuka-chtholly", - * "url": "assets/pics/sukasuka-chtholly.png" - * } - * ] - * }, - * "meta": { - * "generated": "1401380327373", - * "app": "Phaser 3 Asset Packer", - * "url": "https://phaser.io", - * "version": "1.0", - * "copyright": "Photon Storm Ltd. 2018" - * } - * } - * ``` - * - * The pack can be split into sections. In the example above you'll see a section called `test1. You can tell - * the `load.pack` method to parse only a particular section of a pack. The pack is stored in the JSON Cache, - * so you can pass it to the Loader to process additional sections as needed in your game, or you can just load - * them all at once without specifying anything. - * - * The pack file can contain an entry for any type of file that Phaser can load. The object structures exactly - * match that of the file type configs, and all properties available within the file type configs can be used - * in the pack file too. - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the JSON Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.pack({ - * key: 'level1', - * url: 'data/Level1Files.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.PackFileConfig` for more details. - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the JSON Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" - * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, - * rather than the whole file. For example, if your JSON data had a structure like this: - * - * ```json - * { - * "level1": { - * "baddies": { - * "aliens": {}, - * "boss": {} - * } - * }, - * "level2": {}, - * "level3": {} - * } - * ``` - * - * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. - * - * Note: The ability to load this type of file will only be available if the Pack File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#pack - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.7.0 - * - * @param {(string|Phaser.Loader.FileTypes.PackFileConfig|Phaser.Loader.FileTypes.PackFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('pack', function (key, url, packKey, xhrSettings) -{ - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - this.addFile(new PackFile(this, key[i])); - } - } - else - { - this.addFile(new PackFile(this, key, url, xhrSettings, packKey)); - } - - return this; -}); - -module.exports = PackFile; - - -/***/ }), -/* 753 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.HTMLFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='html'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @property {integer} [width=512] - The width of the texture the HTML will be rendered to. - * @property {integer} [height=512] - The height of the texture the HTML will be rendered to. - */ - -/** - * @classdesc - * A single HTML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. - * - * @class HTMLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {integer} [width] - The width of the texture the HTML will be rendered to. - * @param {integer} [height] - The height of the texture the HTML will be rendered to. - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var HTMLFile = new Class({ - - Extends: File, - - initialize: - - function HTMLFile (loader, key, url, width, height, xhrSettings) - { - if (width === undefined) { width = 512; } - if (height === undefined) { height = 512; } - - var extension = 'html'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - width = GetFastValue(config, 'width', width); - height = GetFastValue(config, 'height', height); - } - - var fileConfig = { - type: 'html', - cache: loader.textureManager, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings, - config: { - width: width, - height: height - } - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.HTMLFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - var w = this.config.width; - var h = this.config.height; - - var data = []; - - data.push(''); - data.push(''); - data.push(''); - data.push(this.xhrLoader.responseText); - data.push(''); - data.push(''); - data.push(''); - - var svg = [ data.join('\n') ]; - var _this = this; - - try - { - var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); - } - catch (e) - { - _this.state = CONST.FILE_ERRORED; - - _this.onProcessComplete(); - - return; - } - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessComplete(); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessError(); - }; - - File.createObjectURL(this.data, blob, 'image/svg+xml'); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.HTMLFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var texture = this.cache.addImage(this.key, this.data); - - this.pendingDestroy(texture); - } - -}); - -/** - * Adds an HTML File, or array of HTML Files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.html('instructions', 'content/intro.html', 256, 512); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.html({ - * key: 'instructions', - * url: 'content/intro.html', - * width: 256, - * height: 512 - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.html('instructions', 'content/intro.html', 256, 512); - * // and later in your game ... - * this.add.image(x, y, 'instructions'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * The width and height are the size of the texture to which the HTML will be rendered. It's not possible to determine these - * automatically, so you will need to provide them, either as arguments or in the file config object. - * When the HTML file has loaded a new SVG element is created with a size and viewbox set to the width and height given. - * The SVG file has a body tag added to it, with the HTML file contents included. It then calls `window.Blob` on the SVG, - * and if successful is added to the Texture Manager, otherwise it fails processing. The overall quality of the rendered - * HTML depends on your browser, and some of them may not even support the svg / blob process used. Be aware that there are - * limitations on what HTML can be inside an SVG. You can find out more details in this - * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). - * - * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#html - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {integer} [width=512] - The width of the texture the HTML will be rendered to. - * @param {integer} [height=512] - The height of the texture the HTML will be rendered to. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('html', function (key, url, width, height, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new HTMLFile(this, key[i])); - } - } - else - { - this.addFile(new HTMLFile(this, key, url, width, height, xhrSettings)); - } - - return this; -}); - -module.exports = HTMLFile; - - -/***/ }), -/* 754 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.GLSLFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='glsl'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single GLSL File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl. - * - * @class GLSLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var GLSLFile = new Class({ - - Extends: File, - - initialize: - - function GLSLFile (loader, key, url, xhrSettings) - { - var extension = 'glsl'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'glsl', - cache: loader.cacheManager.shader, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.GLSLFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onProcessComplete(); - } - -}); - -/** - * Adds a GLSL file, or array of GLSL files, to the current load queue. - * In Phaser 3 GLSL files are just plain Text files at the current moment in time. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.glsl('plasma', 'shaders/Plasma.glsl'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Shader Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Shader Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Shader Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.glsl({ - * key: 'plasma', - * url: 'shaders/Plasma.glsl' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.GLSLFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.glsl('plasma', 'shaders/Plasma.glsl'); - * // and later in your game ... - * var data = this.cache.shader.get('plasma'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `FX.` and the key was `Plasma` the final key will be `FX.Plasma` and - * this is what you would use to retrieve the text from the Shader Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "plasma" - * and no URL is given then the Loader will set the URL to be "plasma.glsl". It will always add `.glsl` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the GLSL File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#glsl - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.GLSLFileConfig|Phaser.Loader.FileTypes.GLSLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.glsl`, i.e. if `key` was "alien" then the URL will be "alien.glsl". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('glsl', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new GLSLFile(this, key[i])); - } - } - else - { - this.addFile(new GLSLFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = GLSLFile; - - -/***/ }), -/* 755 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); -var IsPlainObject = __webpack_require__(8); -var MultiFile = __webpack_require__(36); -var ParseXMLBitmapFont = __webpack_require__(474); -var XMLFile = __webpack_require__(143); - -/** - * @typedef {object} Phaser.Loader.FileTypes.BitmapFontFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. - * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. - * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. - * @property {string} [fontDataURL] - The absolute or relative URL to load the font data xml file from. - * @property {string} [fontDataExtension='xml'] - The default file extension to use for the font data xml if no url is provided. - * @property {XHRSettingsObject} [fontDataXhrSettings] - Extra XHR Settings specifically for the font data xml file. - */ - -/** - * @classdesc - * A single Bitmap Font based File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. - * - * @class BitmapFontFile - * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. - */ -var BitmapFontFile = new Class({ - - Extends: MultiFile, - - initialize: - - function BitmapFontFile (loader, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) - { - var image; - var data; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - - image = new ImageFile(loader, { - key: key, - url: GetFastValue(config, 'textureURL'), - extension: GetFastValue(config, 'textureExtension', 'png'), - normalMap: GetFastValue(config, 'normalMap'), - xhrSettings: GetFastValue(config, 'textureXhrSettings') - }); - - data = new XMLFile(loader, { - key: key, - url: GetFastValue(config, 'fontDataURL'), - extension: GetFastValue(config, 'fontDataExtension', 'xml'), - xhrSettings: GetFastValue(config, 'fontDataXhrSettings') - }); - } - else - { - image = new ImageFile(loader, key, textureURL, textureXhrSettings); - data = new XMLFile(loader, key, fontDataURL, fontDataXhrSettings); - } - - if (image.linkFile) - { - // Image has a normal map - MultiFile.call(this, loader, 'bitmapfont', key, [ image, data, image.linkFile ]); - } - else - { - MultiFile.call(this, loader, 'bitmapfont', key, [ image, data ]); - } - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.BitmapFontFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.isReadyToProcess()) - { - var image = this.files[0]; - var xml = this.files[1]; - - image.addToCache(); - xml.addToCache(); - - this.loader.cacheManager.bitmapFont.add(image.key, { data: ParseXMLBitmapFont(xml.data), texture: image.key, frame: null }); - - this.complete = true; - } - } - -}); - -/** - * Adds an XML based Bitmap Font, or array of fonts, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - - * ```javascript - * function preload () - * { - * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the font data to be provided in an XML file format. - * These files are created by software such as the [Angelcode Bitmap Font Generator](http://www.angelcode.com/products/bmfont/), - * [Littera](http://kvazars.com/littera/) or [Glyph Designer](https://71squared.com/glyphdesigner) - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.bitmapFont({ - * key: 'goldenFont', - * textureURL: 'images/GoldFont.png', - * fontDataURL: 'images/GoldFont.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.BitmapFontFileConfig` for more details. - * - * Once the atlas has finished loading you can use key of it when creating a Bitmap Text Game Object: - * - * ```javascript - * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); - * // and later in your game ... - * this.add.bitmapText(x, y, 'goldenFont', 'Hello World'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use when creating a Bitmap Text object. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.bitmapFont('goldenFont', [ 'images/GoldFont.png', 'images/GoldFont-n.png' ], 'images/GoldFont.xml'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.bitmapFont({ - * key: 'goldenFont', - * textureURL: 'images/GoldFont.png', - * normalMap: 'images/GoldFont-n.png', - * fontDataURL: 'images/GoldFont.xml' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Bitmap Font File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#bitmapFont - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig|Phaser.Loader.FileTypes.BitmapFontFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('bitmapFont', function (key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) -{ - var multifile; - - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - multifile = new BitmapFontFile(this, key[i]); - - this.addFile(multifile.files); - } - } - else - { - multifile = new BitmapFontFile(this, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings); - - this.addFile(multifile.files); - } - - return this; -}); - -module.exports = BitmapFontFile; - - -/***/ }), -/* 756 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.BinaryFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Binary Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='bin'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @property {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. - */ - -/** - * @classdesc - * A single Binary File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. - * - * @class BinaryFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. - */ -var BinaryFile = new Class({ - - Extends: File, - - initialize: - - function BinaryFile (loader, key, url, xhrSettings, dataType) - { - var extension = 'bin'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - dataType = GetFastValue(config, 'dataType', dataType); - } - - var fileConfig = { - type: 'binary', - cache: loader.cacheManager.binary, - extension: extension, - responseType: 'arraybuffer', - key: key, - url: url, - xhrSettings: xhrSettings, - config: { dataType: dataType } - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.BinaryFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - var ctor = this.config.dataType; - - this.data = (ctor) ? new ctor(this.xhrLoader.response) : this.xhrLoader.response; - - this.onProcessComplete(); - } - -}); - -/** - * Adds a Binary file, or array of Binary files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.binary('doom', 'files/Doom.wad'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Binary Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Binary Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Binary Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.binary({ - * key: 'doom', - * url: 'files/Doom.wad', - * dataType: Uint8Array - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.BinaryFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.binary('doom', 'files/Doom.wad'); - * // and later in your game ... - * var data = this.cache.binary.get('doom'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Data` the final key will be `LEVEL1.Data` and - * this is what you would use to retrieve the text from the Binary Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "doom" - * and no URL is given then the Loader will set the URL to be "doom.bin". It will always add `.bin` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Binary File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#binary - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig|Phaser.Loader.FileTypes.BinaryFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". - * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('binary', function (key, url, dataType, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new BinaryFile(this, key[i])); - } - } - else - { - this.addFile(new BinaryFile(this, key, url, xhrSettings, dataType)); - } - - return this; -}); - -module.exports = BinaryFile; - - -/***/ }), -/* 757 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); -var IsPlainObject = __webpack_require__(8); -var MultiFile = __webpack_require__(36); -var XMLFile = __webpack_require__(143); - -/** - * @typedef {object} Phaser.Loader.FileTypes.AtlasXMLFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. - * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. - * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. - * @property {string} [atlasURL] - The absolute or relative URL to load the atlas xml file from. - * @property {string} [atlasExtension='xml'] - The default file extension to use for the atlas xml if no url is provided. - * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas xml file. - */ - -/** - * @classdesc - * A single XML based Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. - * - * @class AtlasXMLFile - * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes - * @constructor - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. - */ -var AtlasXMLFile = new Class({ - - Extends: MultiFile, - - initialize: - - function AtlasXMLFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) - { - var image; - var data; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - - image = new ImageFile(loader, { - key: key, - url: GetFastValue(config, 'textureURL'), - extension: GetFastValue(config, 'textureExtension', 'png'), - normalMap: GetFastValue(config, 'normalMap'), - xhrSettings: GetFastValue(config, 'textureXhrSettings') - }); - - data = new XMLFile(loader, { - key: key, - url: GetFastValue(config, 'atlasURL'), - extension: GetFastValue(config, 'atlasExtension', 'xml'), - xhrSettings: GetFastValue(config, 'atlasXhrSettings') - }); - } - else - { - image = new ImageFile(loader, key, textureURL, textureXhrSettings); - data = new XMLFile(loader, key, atlasURL, atlasXhrSettings); - } - - if (image.linkFile) - { - // Image has a normal map - MultiFile.call(this, loader, 'atlasxml', key, [ image, data, image.linkFile ]); - } - else - { - MultiFile.call(this, loader, 'atlasxml', key, [ image, data ]); - } - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.AtlasXMLFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.isReadyToProcess()) - { - var image = this.files[0]; - var xml = this.files[1]; - var normalMap = (this.files[2]) ? this.files[2].data : null; - - this.loader.textureManager.addAtlasXML(image.key, image.data, xml.data, normalMap); - - xml.addToCache(); - - this.complete = true; - } - } - -}); - -/** - * Adds an XML based Texture Atlas, or array of atlases, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in an XML file format. - * These files are created by software such as Shoebox and Adobe Flash / Animate. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.atlasXML({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * atlasURL: 'images/MainMenu.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.AtlasXMLFileConfig` for more details. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); - * // and later in your game ... - * this.add.image(x, y, 'mainmenu', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.atlasXML('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.xml'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.atlasXML({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * normalMap: 'images/MainMenu-n.png', - * atlasURL: 'images/MainMenu.xml' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Atlas XML File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#atlasXML - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.7.0 - * - * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig|Phaser.Loader.FileTypes.AtlasXMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('atlasXML', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) -{ - var multifile; - - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - multifile = new AtlasXMLFile(this, key[i]); - - this.addFile(multifile.files); - } - } - else - { - multifile = new AtlasXMLFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); - - this.addFile(multifile.files); - } - - return this; -}); - -module.exports = AtlasXMLFile; - - -/***/ }), -/* 758 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Loader.FileTypes - */ - -module.exports = { - - AnimationJSONFile: __webpack_require__(360), - AtlasJSONFile: __webpack_require__(359), - AtlasXMLFile: __webpack_require__(757), - AudioFile: __webpack_require__(168), - AudioSpriteFile: __webpack_require__(358), - BinaryFile: __webpack_require__(756), - BitmapFontFile: __webpack_require__(755), - GLSLFile: __webpack_require__(754), - HTML5AudioFile: __webpack_require__(167), - HTMLFile: __webpack_require__(753), - ImageFile: __webpack_require__(37), - JSONFile: __webpack_require__(28), - MultiAtlasFile: __webpack_require__(357), - PackFile: __webpack_require__(752), - PluginFile: __webpack_require__(356), - ScenePluginFile: __webpack_require__(751), - ScriptFile: __webpack_require__(355), - SpriteSheetFile: __webpack_require__(354), - SVGFile: __webpack_require__(750), - TextFile: __webpack_require__(224), - TilemapCSVFile: __webpack_require__(749), - TilemapImpactFile: __webpack_require__(748), - TilemapJSONFile: __webpack_require__(747), - UnityAtlasFile: __webpack_require__(746), - XMLFile: __webpack_require__(143) - -}; - - -/***/ }), -/* 759 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(18); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser.Loader - */ - -var Loader = { - - FileTypes: __webpack_require__(758), - - File: __webpack_require__(19), - FileTypesManager: __webpack_require__(7), - GetURL: __webpack_require__(108), - LoaderPlugin: __webpack_require__(353), - MergeXHRSettings: __webpack_require__(107), - MultiFile: __webpack_require__(36), - XHRLoader: __webpack_require__(169), - XHRSettings: __webpack_require__(75) - -}; - -// Merge in the consts -Loader = Extend(false, Loader, CONST); - -module.exports = Loader; - - -/***/ }), -/* 760 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(225); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.RotateAroundPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var RotateAroundPoint = function (triangle, point, angle) -{ - return RotateAroundXY(triangle, point.x, point.y, angle); -}; - -module.exports = RotateAroundPoint; - - -/***/ }), -/* 761 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(225); -var InCenter = __webpack_require__(384); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Rotate - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Rotate = function (triangle, angle) -{ - var point = InCenter(triangle); - - return RotateAroundXY(triangle, point.x, point.y, angle); -}; - -module.exports = Rotate; - - -/***/ }), -/* 762 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(71); - -// The 2D area of a triangle. The area value is always non-negative. - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Perimeter - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {number} [description] - */ -var Perimeter = function (triangle) -{ - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - return (Length(line1) + Length(line2) + Length(line3)); -}; - -module.exports = Perimeter; - - -/***/ }), -/* 763 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Triangle} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (triangle, toCompare) -{ - return ( - triangle.x1 === toCompare.x1 && - triangle.y1 === toCompare.y1 && - triangle.x2 === toCompare.x2 && - triangle.y2 === toCompare.y2 && - triangle.x3 === toCompare.x3 && - triangle.y3 === toCompare.y3 - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 764 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [dest,$return] - * - * @param {Phaser.Geom.Triangle} source - [description] - * @param {Phaser.Geom.Triangle} dest - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 765 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(60); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {boolean} [description] - */ -var ContainsPoint = function (triangle, point) -{ - return Contains(triangle, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 766 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Triangle = __webpack_require__(68); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} source - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Clone = function (source) -{ - return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); -}; - -module.exports = Clone; - - -/***/ }), -/* 767 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(88); - -// Adapted from https://gist.github.com/mutoo/5617691 - -/** - * [description] - * - * @function Phaser.Geom.Triangle.CircumCircle - * @since 3.0.0 - * - * @generic {Phaser.Geom.Circle} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} [out] - [description] - * - * @return {Phaser.Geom.Circle} [description] - */ -var CircumCircle = function (triangle, out) -{ - if (out === undefined) { out = new Circle(); } - - // A - var x1 = triangle.x1; - var y1 = triangle.y1; - - // B - var x2 = triangle.x2; - var y2 = triangle.y2; - - // C - var x3 = triangle.x3; - var y3 = triangle.y3; - - var A = x2 - x1; - var B = y2 - y1; - var C = x3 - x1; - var D = y3 - y1; - var E = A * (x1 + x2) + B * (y1 + y2); - var F = C * (x1 + x3) + D * (y1 + y3); - var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); - - var dx; - var dy; - - // If the points of the triangle are collinear, then just find the - // extremes and use the midpoint as the center of the circumcircle. - - if (Math.abs(G) < 0.000001) - { - var minX = Math.min(x1, x2, x3); - var minY = Math.min(y1, y2, y3); - dx = (Math.max(x1, x2, x3) - minX) * 0.5; - dy = (Math.max(y1, y2, y3) - minY) * 0.5; - - out.x = minX + dx; - out.y = minY + dy; - out.radius = Math.sqrt(dx * dx + dy * dy); - } - else - { - out.x = (D * E - B * F) / G; - out.y = (A * F - C * E) / G; - dx = out.x - x1; - dy = out.y - y1; - out.radius = Math.sqrt(dx * dx + dy * dy); - } - - return out; -}; - -module.exports = CircumCircle; - - -/***/ }), -/* 768 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Vector2 = __webpack_require__(6); - -// Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html - -/** - * Computes the determinant of a 2x2 matrix. Uses standard double-precision arithmetic, so is susceptible to round-off error. - * - * @function det - * @private - * @since 3.0.0 - * - * @param {number} m00 - The [0,0] entry of the matrix. - * @param {number} m01 - The [0,1] entry of the matrix. - * @param {number} m10 - The [1,0] entry of the matrix. - * @param {number} m11 - The [1,1] entry of the matrix. - * - * @return {number} the determinant. - */ -function det (m00, m01, m10, m11) -{ - return (m00 * m11) - (m01 * m10); -} - -/** - * Computes the circumcentre of a triangle. The circumcentre is the centre of - * the circumcircle, the smallest circle which encloses the triangle. It is also - * the common intersection point of the perpendicular bisectors of the sides of - * the triangle, and is the only point which has equal distance to all three - * vertices of the triangle. - * - * @function Phaser.Geom.Triangle.CircumCenter - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ -var CircumCenter = function (triangle, out) -{ - if (out === undefined) { out = new Vector2(); } - - var cx = triangle.x3; - var cy = triangle.y3; - - var ax = triangle.x1 - cx; - var ay = triangle.y1 - cy; - - var bx = triangle.x2 - cx; - var by = triangle.y2 - cy; - - var denom = 2 * det(ax, ay, bx, by); - var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); - var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); - - out.x = cx - numx / denom; - out.y = cy + numy / denom; - - return out; -}; - -module.exports = CircumCenter; - - -/***/ }), -/* 769 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Centroid = __webpack_require__(386); -var Offset = __webpack_require__(385); - -/** - * @callback CenterFunction - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.CenterOn - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {CenterFunction} [centerFunc] - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var CenterOn = function (triangle, x, y, centerFunc) -{ - if (centerFunc === undefined) { centerFunc = Centroid; } - - // Get the center of the triangle - var center = centerFunc(triangle); - - // Difference - var diffX = x - center.x; - var diffY = y - center.y; - - return Offset(triangle, diffX, diffY); -}; - -module.exports = CenterOn; - - -/***/ }), -/* 770 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Triangle = __webpack_require__(68); - -// Builds a right triangle, with one 90 degree angle and two acute angles -// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) -// w/h can be positive or negative and represent the length of each side - -/** - * [description] - * - * @function Phaser.Geom.Triangle.BuildRight - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var BuildRight = function (x, y, width, height) -{ - if (height === undefined) { height = width; } - - // 90 degree angle - var x1 = x; - var y1 = y; - - var x2 = x; - var y2 = y - height; - - var x3 = x + width; - var y3 = y; - - return new Triangle(x1, y1, x2, y2, x3, y3); -}; - -module.exports = BuildRight; - - -/***/ }), -/* 771 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var EarCut = __webpack_require__(258); -var Triangle = __webpack_require__(68); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.BuildFromPolygon - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle[]} O - [out,$return] - * - * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] - * @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). - * @param {float} [scaleX=1] - [description] - * @param {float} [scaleY=1] - [description] - * @param {(array|Phaser.Geom.Triangle[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Triangle[])} [description] - */ -var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) -{ - if (holes === undefined) { holes = null; } - if (scaleX === undefined) { scaleX = 1; } - if (scaleY === undefined) { scaleY = 1; } - if (out === undefined) { out = []; } - - var tris = EarCut(data, holes); - - var a; - var b; - var c; - - var x1; - var y1; - - var x2; - var y2; - - var x3; - var y3; - - for (var i = 0; i < tris.length; i += 3) - { - a = tris[i]; - b = tris[i + 1]; - c = tris[i + 2]; - - x1 = data[a * 2] * scaleX; - y1 = data[(a * 2) + 1] * scaleY; - - x2 = data[b * 2] * scaleX; - y2 = data[(b * 2) + 1] * scaleY; - - x3 = data[c * 2] * scaleX; - y3 = data[(c * 2) + 1] * scaleY; - - out.push(new Triangle(x1, y1, x2, y2, x3, y3)); - } - - return out; -}; - -module.exports = BuildFromPolygon; - - -/***/ }), -/* 772 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Triangle = __webpack_require__(68); - -// Builds an equilateral triangle. -// In the equilateral triangle, all the sides are the same length (congruent) -// and all the angles are the same size (congruent). - -// The x/y specifies the top-middle of the triangle (x1/y1) and length -// is the length of each side - -/** - * [description] - * - * @function Phaser.Geom.Triangle.BuildEquilateral - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} length - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var BuildEquilateral = function (x, y, length) -{ - var height = length * (Math.sqrt(3) / 2); - - var x1 = x; - var y1 = y; - - var x2 = x + (length / 2); - var y2 = y + height; - - var x3 = x - (length / 2); - var y3 = y + height; - - return new Triangle(x1, y1, x2, y2, x3, y3); -}; - -module.exports = BuildEquilateral; - - -/***/ }), -/* 773 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// The 2D area of a triangle. The area value is always non-negative. - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {number} [description] - */ -var Area = function (triangle) -{ - var x1 = triangle.x1; - var y1 = triangle.y1; - - var x2 = triangle.x2; - var y2 = triangle.y2; - - var x3 = triangle.x3; - var y3 = triangle.y3; - - return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); -}; - -module.exports = Area; - - -/***/ }), -/* 774 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Triangle = __webpack_require__(68); - -Triangle.Area = __webpack_require__(773); -Triangle.BuildEquilateral = __webpack_require__(772); -Triangle.BuildFromPolygon = __webpack_require__(771); -Triangle.BuildRight = __webpack_require__(770); -Triangle.CenterOn = __webpack_require__(769); -Triangle.Centroid = __webpack_require__(386); -Triangle.CircumCenter = __webpack_require__(768); -Triangle.CircumCircle = __webpack_require__(767); -Triangle.Clone = __webpack_require__(766); -Triangle.Contains = __webpack_require__(60); -Triangle.ContainsArray = __webpack_require__(231); -Triangle.ContainsPoint = __webpack_require__(765); -Triangle.CopyFrom = __webpack_require__(764); -Triangle.Decompose = __webpack_require__(394); -Triangle.Equals = __webpack_require__(763); -Triangle.GetPoint = __webpack_require__(227); -Triangle.GetPoints = __webpack_require__(226); -Triangle.InCenter = __webpack_require__(384); -Triangle.Perimeter = __webpack_require__(762); -Triangle.Offset = __webpack_require__(385); -Triangle.Random = __webpack_require__(153); -Triangle.Rotate = __webpack_require__(761); -Triangle.RotateAroundPoint = __webpack_require__(760); -Triangle.RotateAroundXY = __webpack_require__(225); - -module.exports = Triangle; - - -/***/ }), -/* 775 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Scales the width and height of this Rectangle by the given amounts. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Scale - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Scale = function (rect, x, y) -{ - if (y === undefined) { y = x; } - - rect.width *= x; - rect.height *= y; - - return rect; -}; - -module.exports = Scale; - - -/***/ }), -/* 776 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Between = __webpack_require__(149); -var ContainsRect = __webpack_require__(387); -var Point = __webpack_require__(5); - -/** - * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. - * The inner Rectangle must be fully contained within the outer rectangle. - * - * @function Phaser.Geom.Rectangle.RandomOutside - * @since 3.10.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} outer - The outer Rectangle to get the random point within. - * @param {Phaser.Geom.Rectangle} inner - The inner Rectangle to exclude from the returned point. - * @param {Phaser.Geom.Point} [out] - A Point, or Point-like object to store the result in. If not specified, a new Point will be created. - * - * @return {Phaser.Geom.Point} A Point object containing the random values in its `x` and `y` properties. - */ -var RandomOutside = function (outer, inner, out) -{ - if (out === undefined) { out = new Point(); } - - if (ContainsRect(outer, inner)) - { - // Pick a random quadrant - // - // The quadrants don't extend the full widths / heights of the outer rect to give - // us a better uniformed distribution, otherwise you get clumping in the corners where - // the 4 quads would overlap - - switch (Between(0, 3)) - { - case 0: // Top - out.x = outer.x + (Math.random() * (inner.right - outer.x)); - out.y = outer.y + (Math.random() * (inner.top - outer.y)); - break; - - case 1: // Bottom - out.x = inner.x + (Math.random() * (outer.right - inner.x)); - out.y = inner.bottom + (Math.random() * (outer.bottom - inner.bottom)); - break; - - case 2: // Left - out.x = outer.x + (Math.random() * (inner.x - outer.x)); - out.y = inner.y + (Math.random() * (outer.bottom - inner.y)); - break; - - case 3: // Right - out.x = inner.right + (Math.random() * (outer.right - inner.right)); - out.y = outer.y + (Math.random() * (inner.bottom - outer.y)); - break; - } - } - - return out; -}; - -module.exports = RandomOutside; - - -/***/ }), -/* 777 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var DegToRad = __webpack_require__(38); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.PerimeterPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {integer} angle - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var PerimeterPoint = function (rectangle, angle, out) -{ - if (out === undefined) { out = new Point(); } - - angle = DegToRad(angle); - - var s = Math.sin(angle); - var c = Math.cos(angle); - - var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; - var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; - - if (Math.abs(dx * s) < Math.abs(dy * c)) - { - dy = (dx * s) / c; - } - else - { - dx = (dy * c) / s; - } - - out.x = dx + rectangle.centerX; - out.y = dy + rectangle.centerY; - - return out; -}; - -module.exports = PerimeterPoint; - - -/***/ }), -/* 778 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Overlaps - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * - * @return {boolean} [description] - */ -var Overlaps = function (rectA, rectB) -{ - return ( - rectA.x < rectB.right && - rectA.right > rectB.x && - rectA.y < rectB.bottom && - rectA.bottom > rectB.y - ); -}; - -module.exports = Overlaps; - - -/***/ }), -/* 779 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.OffsetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var OffsetPoint = function (rect, point) -{ - rect.x += point.x; - rect.y += point.y; - - return rect; -}; - -module.exports = OffsetPoint; - - -/***/ }), -/* 780 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Offset = function (rect, x, y) -{ - rect.x += x; - rect.y += y; - - return rect; -}; - -module.exports = Offset; - - -/***/ }), -/* 781 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.MergeXY - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var MergeXY = function (target, x, y) -{ - var minX = Math.min(target.x, x); - var maxX = Math.max(target.right, x); - - target.x = minX; - target.width = maxX - minX; - - var minY = Math.min(target.y, y); - var maxY = Math.max(target.bottom, y); - - target.y = minY; - target.height = maxY - minY; - - return target; -}; - -module.exports = MergeXY; - - -/***/ }), -/* 782 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Merges source rectangle into target rectangle and returns target -// Neither rect should have negative widths or heights - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.MergeRect - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var MergeRect = function (target, source) -{ - var minX = Math.min(target.x, source.x); - var maxX = Math.max(target.right, source.right); - - target.x = minX; - target.width = maxX - minX; - - var minY = Math.min(target.y, source.y); - var maxY = Math.max(target.bottom, source.bottom); - - target.y = minY; - target.height = maxY - minY; - - return target; -}; - -module.exports = MergeRect; - - -/***/ }), -/* 783 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Merges the target Rectangle with a list of points. -// The points is an array of objects with public x/y properties. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.MergePoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Point[]} points - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var MergePoints = function (target, points) -{ - var minX = target.x; - var maxX = target.right; - var minY = target.y; - var maxY = target.bottom; - - for (var i = 0; i < points.length; i++) - { - minX = Math.min(minX, points[i].x); - maxX = Math.max(maxX, points[i].x); - minY = Math.min(minY, points[i].y); - maxY = Math.max(maxY, points[i].y); - } - - target.x = minX; - target.y = minY; - target.width = maxX - minX; - target.height = maxY - minY; - - return target; -}; - -module.exports = MergePoints; - - -/***/ }), -/* 784 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CenterOn = __webpack_require__(388); - -// Increases the size of the Rectangle object by the specified amounts. -// The center point of the Rectangle object stays the same, and its size increases -// to the left and right by the x value, and to the top and the bottom by the y value. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Inflate - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Inflate = function (rect, x, y) -{ - var cx = rect.centerX; - var cy = rect.centerY; - - rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); - - return CenterOn(rect, cx, cy); -}; - -module.exports = Inflate; - - -/***/ }), -/* 785 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// The size of the Rectangle object, expressed as a Point object -// with the values of the width and height properties. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.GetSize - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetSize = function (rect, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = rect.width; - out.y = rect.height; - - return out; -}; - -module.exports = GetSize; - - -/***/ }), -/* 786 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// The center of the Rectangle object, expressed as a Point object - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.GetCenter - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetCenter = function (rect, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = rect.centerX; - out.y = rect.centerY; - - return out; -}; - -module.exports = GetCenter; - - -/***/ }), -/* 787 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.FloorAll - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var FloorAll = function (rect) -{ - rect.x = Math.floor(rect.x); - rect.y = Math.floor(rect.y); - rect.width = Math.floor(rect.width); - rect.height = Math.floor(rect.height); - - return rect; -}; - -module.exports = FloorAll; - - -/***/ }), -/* 788 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Floor - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Floor = function (rect) -{ - rect.x = Math.floor(rect.x); - rect.y = Math.floor(rect.y); - - return rect; -}; - -module.exports = Floor; - - -/***/ }), -/* 789 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetAspectRatio = __webpack_require__(228); - -// Fits the target rectangle around the source rectangle. -// Preserves aspect ration. -// Scales and centers the target rectangle to the source rectangle - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.FitOutside - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var FitOutside = function (target, source) -{ - var ratio = GetAspectRatio(target); - - if (ratio > GetAspectRatio(source)) - { - // Wider than Tall - target.setSize(source.height * ratio, source.height); - } - else - { - // Taller than Wide - target.setSize(source.width, source.width / ratio); - } - - return target.setPosition( - source.centerX - target.width / 2, - source.centerY - target.height / 2 - ); -}; - -module.exports = FitOutside; - - -/***/ }), -/* 790 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetAspectRatio = __webpack_require__(228); - -// Fits the target rectangle into the source rectangle. -// Preserves aspect ratio. -// Scales and centers the target rectangle to the source rectangle - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.FitInside - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var FitInside = function (target, source) -{ - var ratio = GetAspectRatio(target); - - if (ratio < GetAspectRatio(source)) - { - // Taller than Wide - target.setSize(source.height * ratio, source.height); - } - else - { - // Wider than Tall - target.setSize(source.width, source.width / ratio); - } - - return target.setPosition( - source.centerX - (target.width / 2), - source.centerY - (target.height / 2) - ); -}; - -module.exports = FitInside; - - -/***/ }), -/* 791 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Rectangle} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (rect, toCompare) -{ - return ( - rect.x === toCompare.x && - rect.y === toCompare.y && - rect.width === toCompare.width && - rect.height === toCompare.height - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 792 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [dest,$return] - * - * @param {Phaser.Geom.Rectangle} source - [description] - * @param {Phaser.Geom.Rectangle} dest - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.width, source.height); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 793 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(31); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {boolean} [description] - */ -var ContainsPoint = function (rect, point) -{ - return Contains(rect, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 794 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} source - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Clone = function (source) -{ - return new Rectangle(source.x, source.y, source.width, source.height); -}; - -module.exports = Clone; - - -/***/ }), -/* 795 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.CeilAll - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var CeilAll = function (rect) -{ - rect.x = Math.ceil(rect.x); - rect.y = Math.ceil(rect.y); - rect.width = Math.ceil(rect.width); - rect.height = Math.ceil(rect.height); - - return rect; -}; - -module.exports = CeilAll; - - -/***/ }), -/* 796 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Ceil - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Ceil = function (rect) -{ - rect.x = Math.ceil(rect.x); - rect.y = Math.ceil(rect.y); - - return rect; -}; - -module.exports = Ceil; - - -/***/ }), -/* 797 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {number} [description] - */ -var Area = function (rect) -{ - return rect.width * rect.height; -}; - -module.exports = Area; - - -/***/ }), -/* 798 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] - -/** - * [description] - * - * @function Phaser.Geom.Polygon.GetNumberArray - * @since 3.0.0 - * - * @generic {number[]} O - [output,$return] - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {(array|number[])} [output] - [description] - * - * @return {(array|number[])} [description] - */ -var GetNumberArray = function (polygon, output) -{ - if (output === undefined) { output = []; } - - for (var i = 0; i < polygon.points.length; i++) - { - output.push(polygon.points[i].x); - output.push(polygon.points[i].y); - } - - return output; -}; - -module.exports = GetNumberArray; - - -/***/ }), -/* 799 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * [description] - * - * @function Phaser.Geom.Polygon.GetAABB - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {(Phaser.Geom.Rectangle|object)} [out] - [description] - * - * @return {(Phaser.Geom.Rectangle|object)} [description] - */ -var GetAABB = function (polygon, out) -{ - if (out === undefined) { out = new Rectangle(); } - - var minX = Infinity; - var minY = Infinity; - var maxX = -minX; - var maxY = -minY; - var p; - - for (var i = 0; i < polygon.points.length; i++) - { - p = polygon.points[i]; - - minX = Math.min(minX, p.x); - minY = Math.min(minY, p.y); - maxX = Math.max(maxX, p.x); - maxY = Math.max(maxY, p.y); - } - - out.x = minX; - out.y = minY; - out.width = maxX - minX; - out.height = maxY - minY; - - return out; -}; - -module.exports = GetAABB; - - -/***/ }), -/* 800 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(229); - -/** - * [description] - * - * @function Phaser.Geom.Polygon.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {boolean} [description] - */ -var ContainsPoint = function (polygon, point) -{ - return Contains(polygon, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 801 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Polygon = __webpack_require__(390); - -/** - * [description] - * - * @function Phaser.Geom.Polygon.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * - * @return {Phaser.Geom.Polygon} [description] - */ -var Clone = function (polygon) -{ - return new Polygon(polygon.points); -}; - -module.exports = Clone; - - -/***/ }), -/* 802 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Polygon = __webpack_require__(390); - -Polygon.Clone = __webpack_require__(801); -Polygon.Contains = __webpack_require__(229); -Polygon.ContainsPoint = __webpack_require__(800); -Polygon.GetAABB = __webpack_require__(799); -Polygon.GetNumberArray = __webpack_require__(798); - -module.exports = Polygon; - - -/***/ }), -/* 803 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetMagnitude = __webpack_require__(392); - -/** - * [description] - * - * @function Phaser.Geom.Point.SetMagnitude - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * @param {number} magnitude - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var SetMagnitude = function (point, magnitude) -{ - if (point.x !== 0 || point.y !== 0) - { - var m = GetMagnitude(point); - - point.x /= m; - point.y /= m; - } - - point.x *= magnitude; - point.y *= magnitude; - - return point; -}; - -module.exports = SetMagnitude; - - -/***/ }), -/* 804 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.ProjectUnit - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var ProjectUnit = function (pointA, pointB, out) -{ - if (out === undefined) { out = new Point(); } - - var amt = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); - - if (amt !== 0) - { - out.x = amt * pointB.x; - out.y = amt * pointB.y; - } - - return out; -}; - -module.exports = ProjectUnit; - - -/***/ }), -/* 805 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var GetMagnitudeSq = __webpack_require__(391); - -/** - * [description] - * - * @function Phaser.Geom.Point.Project - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Project = function (pointA, pointB, out) -{ - if (out === undefined) { out = new Point(); } - - var dot = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); - var amt = dot / GetMagnitudeSq(pointB); - - if (amt !== 0) - { - out.x = amt * pointB.x; - out.y = amt * pointB.y; - } - - return out; -}; - -module.exports = Project; - - -/***/ }), -/* 806 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Negative - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Negative = function (point, out) -{ - if (out === undefined) { out = new Point(); } - - return out.setTo(-point.x, -point.y); -}; - -module.exports = Negative; - - -/***/ }), -/* 807 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Invert - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Invert = function (point) -{ - return point.setTo(point.y, point.x); -}; - -module.exports = Invert; - - -/***/ }), -/* 808 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Interpolate - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {float} [t=0] - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var Interpolate = function (pointA, pointB, t, out) -{ - if (t === undefined) { t = 0; } - if (out === undefined) { out = new Point(); } - - out.x = pointA.x + ((pointB.x - pointA.x) * t); - out.y = pointA.y + ((pointB.y - pointA.y) * t); - - return out; -}; - -module.exports = Interpolate; - - -/***/ }), -/* 809 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. - * - * @function Phaser.Geom.Point.GetRectangleFromPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var GetRectangleFromPoints = function (points, out) -{ - if (out === undefined) { out = new Rectangle(); } - - var xMax = Number.NEGATIVE_INFINITY; - var xMin = Number.POSITIVE_INFINITY; - var yMax = Number.NEGATIVE_INFINITY; - var yMin = Number.POSITIVE_INFINITY; - - for (var i = 0; i < points.length; i++) - { - var point = points[i]; - - if (point.x > xMax) - { - xMax = point.x; - } - - if (point.x < xMin) - { - xMin = point.x; - } - - if (point.y > yMax) - { - yMax = point.y; - } - - if (point.y < yMin) - { - yMin = point.y; - } - } - - out.x = xMin; - out.y = yMin; - out.width = xMax - xMin; - out.height = yMax - yMin; - - return out; -}; - -module.exports = GetRectangleFromPoints; - - -/***/ }), -/* 810 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.GetCentroid - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var GetCentroid = function (points, out) -{ - if (out === undefined) { out = new Point(); } - - if (!Array.isArray(points)) - { - throw new Error('GetCentroid points argument must be an array'); - } - - var len = points.length; - - if (len < 1) - { - throw new Error('GetCentroid points array must not be empty'); - } - else if (len === 1) - { - out.x = points[0].x; - out.y = points[0].y; - } - else - { - for (var i = 0; i < len; i++) - { - out.x += points[i].x; - out.y += points[i].y; - } - - out.x /= len; - out.y /= len; - } - - return out; -}; - -module.exports = GetCentroid; - - -/***/ }), -/* 811 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Floor - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Floor = function (point) -{ - return point.setTo(Math.floor(point.x), Math.floor(point.y)); -}; - -module.exports = Floor; - - -/***/ }), -/* 812 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (point, toCompare) -{ - return (point.x === toCompare.x && point.y === toCompare.y); -}; - -module.exports = Equals; - - -/***/ }), -/* 813 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [dest,$return] - * - * @param {Phaser.Geom.Point} source - [description] - * @param {Phaser.Geom.Point} dest - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 814 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} source - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Clone = function (source) -{ - return new Point(source.x, source.y); -}; - -module.exports = Clone; - - -/***/ }), -/* 815 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Ceil - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Ceil = function (point) -{ - return point.setTo(Math.ceil(point.x), Math.ceil(point.y)); -}; - -module.exports = Ceil; - - -/***/ }), -/* 816 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -Point.Ceil = __webpack_require__(815); -Point.Clone = __webpack_require__(814); -Point.CopyFrom = __webpack_require__(813); -Point.Equals = __webpack_require__(812); -Point.Floor = __webpack_require__(811); -Point.GetCentroid = __webpack_require__(810); -Point.GetMagnitude = __webpack_require__(392); -Point.GetMagnitudeSq = __webpack_require__(391); -Point.GetRectangleFromPoints = __webpack_require__(809); -Point.Interpolate = __webpack_require__(808); -Point.Invert = __webpack_require__(807); -Point.Negative = __webpack_require__(806); -Point.Project = __webpack_require__(805); -Point.ProjectUnit = __webpack_require__(804); -Point.SetMagnitude = __webpack_require__(803); - -module.exports = Point; - - -/***/ }), -/* 817 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Width - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Width = function (line) -{ - return Math.abs(line.x1 - line.x2); -}; - -module.exports = Width; - - -/***/ }), -/* 818 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Slope - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Slope = function (line) -{ - return (line.y2 - line.y1) / (line.x2 - line.x1); -}; - -module.exports = Slope; - - -/***/ }), -/* 819 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.SetToAngle - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * @param {number} length - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var SetToAngle = function (line, x, y, angle, length) -{ - line.x1 = x; - line.y1 = y; - - line.x2 = x + (Math.cos(angle) * length); - line.y2 = y + (Math.sin(angle) * length); - - return line; -}; - -module.exports = SetToAngle; - - -/***/ }), -/* 820 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(230); - -/** - * [description] - * - * @function Phaser.Geom.Line.RotateAroundPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {(Phaser.Geom.Point|object)} point - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var RotateAroundPoint = function (line, point, angle) -{ - return RotateAroundXY(line, point.x, point.y, angle); -}; - -module.exports = RotateAroundPoint; - - -/***/ }), -/* 821 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(230); - -/** - * [description] - * - * @function Phaser.Geom.Line.Rotate - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Rotate = function (line, angle) -{ - var x = (line.x1 + line.x2) / 2; - var y = (line.y1 + line.y2) / 2; - - return RotateAroundXY(line, x, y, angle); -}; - -module.exports = Rotate; - - -/***/ }), -/* 822 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Angle = __webpack_require__(82); -var NormalAngle = __webpack_require__(393); - -/** -* Returns the reflected angle between two lines. -* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. -*/ -/** - * [description] - * - * @function Phaser.Geom.Line.ReflectAngle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} lineA - [description] - * @param {Phaser.Geom.Line} lineB - [description] - * - * @return {number} [description] - */ -var ReflectAngle = function (lineA, lineB) -{ - return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); -}; - -module.exports = ReflectAngle; - - -/***/ }), -/* 823 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.PerpSlope - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var PerpSlope = function (line) -{ - return -((line.x2 - line.x1) / (line.y2 - line.y1)); -}; - -module.exports = PerpSlope; - - -/***/ }), -/* 824 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Offset = function (line, x, y) -{ - line.x1 += x; - line.y1 += y; - - line.x2 += x; - line.y2 += y; - - return line; -}; - -module.exports = Offset; - - -/***/ }), -/* 825 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(82); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalY - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalY = function (line) -{ - return Math.sin(Angle(line) - MATH_CONST.TAU); -}; - -module.exports = NormalY; - - -/***/ }), -/* 826 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(82); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalX - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalX = function (line) -{ - return Math.cos(Angle(line) - MATH_CONST.TAU); -}; - -module.exports = NormalX; - - -/***/ }), -/* 827 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Height - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Height = function (line) -{ - return Math.abs(line.y1 - line.y2); -}; - -module.exports = Height; - - -/***/ }), -/* 828 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(82); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetNormal - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetNormal = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - var a = Angle(line) - MATH_CONST.TAU; - - out.x = Math.cos(a); - out.y = Math.sin(a); - - return out; -}; - -module.exports = GetNormal; - - -/***/ }), -/* 829 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetMidPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetMidPoint = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = (line.x1 + line.x2) / 2; - out.y = (line.y1 + line.y2) / 2; - - return out; -}; - -module.exports = GetMidPoint; - - -/***/ }), -/* 830 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Line} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (line, toCompare) -{ - return ( - line.x1 === toCompare.x1 && - line.y1 === toCompare.y1 && - line.x2 === toCompare.x2 && - line.y2 === toCompare.y2 - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 831 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [dest,$return] - * - * @param {Phaser.Geom.Line} source - [description] - * @param {Phaser.Geom.Line} dest - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x1, source.y1, source.x2, source.y2); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 832 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Line = __webpack_require__(96); - -/** - * [description] - * - * @function Phaser.Geom.Line.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} source - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Clone = function (source) -{ - return new Line(source.x1, source.y1, source.x2, source.y2); -}; - -module.exports = Clone; - - -/***/ }), -/* 833 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -/** - * [description] - * - * @function Phaser.Geom.Line.CenterOn - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var CenterOn = function (line, x, y) -{ - var tx = x - ((line.x1 + line.x2) / 2); - var ty = y - ((line.y1 + line.y2) / 2); - - line.x1 += tx; - line.y1 += ty; - - line.x2 += tx; - line.y2 += ty; - - return line; -}; - -module.exports = CenterOn; - - -/***/ }), -/* 834 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Line = __webpack_require__(96); - -Line.Angle = __webpack_require__(82); -Line.BresenhamPoints = __webpack_require__(569); -Line.CenterOn = __webpack_require__(833); -Line.Clone = __webpack_require__(832); -Line.CopyFrom = __webpack_require__(831); -Line.Equals = __webpack_require__(830); -Line.GetMidPoint = __webpack_require__(829); -Line.GetNormal = __webpack_require__(828); -Line.GetPoint = __webpack_require__(293); -Line.GetPoints = __webpack_require__(156); -Line.Height = __webpack_require__(827); -Line.Length = __webpack_require__(71); -Line.NormalAngle = __webpack_require__(393); -Line.NormalX = __webpack_require__(826); -Line.NormalY = __webpack_require__(825); -Line.Offset = __webpack_require__(824); -Line.PerpSlope = __webpack_require__(823); -Line.Random = __webpack_require__(155); -Line.ReflectAngle = __webpack_require__(822); -Line.Rotate = __webpack_require__(821); -Line.RotateAroundPoint = __webpack_require__(820); -Line.RotateAroundXY = __webpack_require__(230); -Line.SetToAngle = __webpack_require__(819); -Line.Slope = __webpack_require__(818); -Line.Width = __webpack_require__(817); - -module.exports = Line; - - -/***/ }), -/* 835 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ContainsArray = __webpack_require__(231); -var Decompose = __webpack_require__(394); -var LineToLine = __webpack_require__(144); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToTriangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangleA - [description] - * @param {Phaser.Geom.Triangle} triangleB - [description] - * - * @return {boolean} [description] - */ -var TriangleToTriangle = function (triangleA, triangleB) -{ - // First the cheapest ones: - - if ( - triangleA.left > triangleB.right || - triangleA.right < triangleB.left || - triangleA.top > triangleB.bottom || - triangleA.bottom < triangleB.top) - { - return false; - } - - var lineAA = triangleA.getLineA(); - var lineAB = triangleA.getLineB(); - var lineAC = triangleA.getLineC(); - - var lineBA = triangleB.getLineA(); - var lineBB = triangleB.getLineB(); - var lineBC = triangleB.getLineC(); - - // Now check the lines against each line of TriangleB - if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) - { - return true; - } - - if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) - { - return true; - } - - if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) - { - return true; - } - - // Nope, so check to see if any of the points of triangleA are within triangleB - - var points = Decompose(triangleA); - var within = ContainsArray(triangleB, points, true); - - if (within.length > 0) - { - return true; - } - - // Finally check to see if any of the points of triangleB are within triangleA - - points = Decompose(triangleB); - within = ContainsArray(triangleA, points, true); - - if (within.length > 0) - { - return true; - } - - return false; -}; - -module.exports = TriangleToTriangle; - - -/***/ }), -/* 836 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(60); -var LineToLine = __webpack_require__(144); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToLine - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] - */ -var TriangleToLine = function (triangle, line) -{ - // If the Triangle contains either the start or end point of the line, it intersects - if (Contains(triangle, line.getPointA()) || Contains(triangle, line.getPointB())) - { - return true; - } - - // Now check the line against each line of the Triangle - if (LineToLine(triangle.getLineA(), line)) - { - return true; - } - - if (LineToLine(triangle.getLineB(), line)) - { - return true; - } - - if (LineToLine(triangle.getLineC(), line)) - { - return true; - } - - return false; -}; - -module.exports = TriangleToLine; - - -/***/ }), -/* 837 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LineToCircle = __webpack_require__(397); -var Contains = __webpack_require__(60); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToCircle - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {boolean} [description] - */ -var TriangleToCircle = function (triangle, circle) -{ - // First the cheapest ones: - - if ( - triangle.left > circle.right || - triangle.right < circle.left || - triangle.top > circle.bottom || - triangle.bottom < circle.top) - { - return false; - } - - if (Contains(triangle, circle.x, circle.y)) - { - return true; - } - - if (LineToCircle(triangle.getLineA(), circle)) - { - return true; - } - - if (LineToCircle(triangle.getLineB(), circle)) - { - return true; - } - - if (LineToCircle(triangle.getLineC(), circle)) - { - return true; - } - - return false; -}; - -module.exports = TriangleToCircle; - - -/***/ }), -/* 838 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.RectangleToValues - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} left - [description] - * @param {number} right - [description] - * @param {number} top - [description] - * @param {number} bottom - [description] - * @param {float} [tolerance=0] - [description] - * - * @return {boolean} [description] - */ -var RectangleToValues = function (rect, left, right, top, bottom, tolerance) -{ - if (tolerance === undefined) { tolerance = 0; } - - return !( - left > rect.right + tolerance || - right < rect.left - tolerance || - top > rect.bottom + tolerance || - bottom < rect.top - tolerance - ); -}; - -module.exports = RectangleToValues; - - -/***/ }), -/* 839 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LineToLine = __webpack_require__(144); -var Contains = __webpack_require__(31); -var ContainsArray = __webpack_require__(231); -var Decompose = __webpack_require__(395); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.RectangleToTriangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {boolean} [description] - */ -var RectangleToTriangle = function (rect, triangle) -{ - // First the cheapest ones: - - if ( - triangle.left > rect.right || - triangle.right < rect.left || - triangle.top > rect.bottom || - triangle.bottom < rect.top) - { - return false; - } - - var triA = triangle.getLineA(); - var triB = triangle.getLineB(); - var triC = triangle.getLineC(); - - // Are any of the triangle points within the rectangle? - - if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) - { - return true; - } - - if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) - { - return true; - } - - if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) - { - return true; - } - - // Cheap tests over, now to see if any of the lines intersect ... - - var rectA = rect.getLineA(); - var rectB = rect.getLineB(); - var rectC = rect.getLineC(); - var rectD = rect.getLineD(); - - if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) - { - return true; - } - - if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) - { - return true; - } - - if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) - { - return true; - } - - // None of the lines intersect, so are any rectangle points within the triangle? - - var points = Decompose(rect); - var within = ContainsArray(triangle, points, true); - - return (within.length > 0); -}; - -module.exports = RectangleToTriangle; - - -/***/ }), -/* 840 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var PointToLine = __webpack_require__(396); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.PointToLineSegment - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] - */ -var PointToLineSegment = function (point, line) -{ - if (!PointToLine(point, line)) - { - return false; - } - - var xMin = Math.min(line.x1, line.x2); - var xMax = Math.max(line.x1, line.x2); - var yMin = Math.min(line.y1, line.y2); - var yMax = Math.max(line.y1, line.y2); - - return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); -}; - -module.exports = PointToLineSegment; - - -/***/ }), -/* 841 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like - * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. - * - * An intersection is considered valid if: - * - * The line starts within, or ends within, the Rectangle. - * The line segment intersects one of the 4 rectangle edges. - * - * The for the purposes of this function rectangles are considered 'solid'. - * - * @function Phaser.Geom.Intersects.LineToRectangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {(Phaser.Geom.Rectangle|object)} rect - [description] - * - * @return {boolean} [description] - */ -var LineToRectangle = function (line, rect) -{ - var x1 = line.x1; - var y1 = line.y1; - - var x2 = line.x2; - var y2 = line.y2; - - var bx1 = rect.x; - var by1 = rect.y; - var bx2 = rect.right; - var by2 = rect.bottom; - - var t = 0; - - // If the start or end of the line is inside the rect then we assume - // collision, as rects are solid for our use-case. - - if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || - (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) - { - return true; - } - - if (x1 < bx1 && x2 >= bx1) - { - // Left edge - t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); - - if (t > by1 && t <= by2) - { - return true; - } - } - else if (x1 > bx2 && x2 <= bx2) - { - // Right edge - t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); - - if (t >= by1 && t <= by2) - { - return true; - } - } - - if (y1 < by1 && y2 >= by1) - { - // Top edge - t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); - - if (t >= bx1 && t <= bx2) - { - return true; - } - } - else if (y1 > by2 && y2 <= by2) - { - // Bottom edge - t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); - - if (t >= bx1 && t <= bx2) - { - return true; - } - } - - return false; -}; - -module.exports = LineToRectangle; - - -/***/ }), -/* 842 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); -var RectangleToRectangle = __webpack_require__(398); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.GetRectangleIntersection - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [output,$return] - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [output] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var GetRectangleIntersection = function (rectA, rectB, output) -{ - if (output === undefined) { output = new Rectangle(); } - - if (RectangleToRectangle(rectA, rectB)) - { - output.x = Math.max(rectA.x, rectB.x); - output.y = Math.max(rectA.y, rectB.y); - output.width = Math.min(rectA.right, rectB.right) - output.x; - output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; - } - - return output; -}; - -module.exports = GetRectangleIntersection; - - -/***/ }), -/* 843 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.CircleToRectangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {boolean} [description] - */ -var CircleToRectangle = function (circle, rect) -{ - var halfWidth = rect.width / 2; - var halfHeight = rect.height / 2; - - var cx = Math.abs(circle.x - rect.x - halfWidth); - var cy = Math.abs(circle.y - rect.y - halfHeight); - var xDist = halfWidth + circle.radius; - var yDist = halfHeight + circle.radius; - - if (cx > xDist || cy > yDist) - { - return false; - } - else if (cx <= halfWidth || cy <= halfHeight) - { - return true; - } - else - { - var xCornerDist = cx - halfWidth; - var yCornerDist = cy - halfHeight; - var xCornerDistSq = xCornerDist * xCornerDist; - var yCornerDistSq = yCornerDist * yCornerDist; - var maxCornerDistSq = circle.radius * circle.radius; - - return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); - } -}; - -module.exports = CircleToRectangle; - - -/***/ }), -/* 844 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var DistanceBetween = __webpack_require__(58); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.CircleToCircle - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circleA - [description] - * @param {Phaser.Geom.Circle} circleB - [description] - * - * @return {boolean} [description] - */ -var CircleToCircle = function (circleA, circleB) -{ - return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); -}; - -module.exports = CircleToCircle; - - -/***/ }), -/* 845 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. - * - * @function Phaser.Geom.Circle.OffsetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Circle} O - [circle,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) - * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Circle by. - * - * @return {Phaser.Geom.Circle} The Circle that was offset. - */ -var OffsetPoint = function (circle, point) -{ - circle.x += point.x; - circle.y += point.y; - - return circle; -}; - -module.exports = OffsetPoint; - - -/***/ }), -/* 846 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Circle by the values given. - * - * @function Phaser.Geom.Circle.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Circle} O - [circle,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) - * @param {number} x - The amount to horizontally offset the Circle by. - * @param {number} y - The amount to vertically offset the Circle by. - * - * @return {Phaser.Geom.Circle} The Circle that was offset. - */ -var Offset = function (circle, x, y) -{ - circle.x += x; - circle.y += y; - - return circle; -}; - -module.exports = Offset; - - -/***/ }), -/* 847 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * Returns the bounds of the Circle object. - * - * @function Phaser.Geom.Circle.GetBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. - * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. - * - * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Circles bounds. - */ -var GetBounds = function (circle, out) -{ - if (out === undefined) { out = new Rectangle(); } - - out.x = circle.left; - out.y = circle.top; - out.width = circle.diameter; - out.height = circle.diameter; - - return out; -}; - -module.exports = GetBounds; - - -/***/ }), -/* 848 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compares the `x`, `y` and `radius` properties of the two given Circles. - * Returns `true` if they all match, otherwise returns `false`. - * - * @function Phaser.Geom.Circle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The first Circle to compare. - * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. - * - * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. - */ -var Equals = function (circle, toCompare) -{ - return ( - circle.x === toCompare.x && - circle.y === toCompare.y && - circle.radius === toCompare.radius - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 849 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Copies the `x`, `y` and `radius` properties from the `source` Circle - * into the given `dest` Circle, then returns the `dest` Circle. - * - * @function Phaser.Geom.Circle.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Circle} O - [dest,$return] - * - * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. - * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. - * - * @return {Phaser.Geom.Circle} The dest Circle. - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.radius); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 850 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(32); - -/** - * Check to see if the Circle contains all four points of the given Rectangle object. - * - * @function Phaser.Geom.Circle.ContainsRect - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Circle or not. - * - * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. - */ -var ContainsRect = function (circle, rect) -{ - return ( - Contains(circle, rect.x, rect.y) && - Contains(circle, rect.right, rect.y) && - Contains(circle, rect.x, rect.bottom) && - Contains(circle, rect.right, rect.bottom) - ); -}; - -module.exports = ContainsRect; - - -/***/ }), -/* 851 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(32); - -/** - * Check to see if the Circle contains the given Point object. - * - * @function Phaser.Geom.Circle.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. - * - * @return {boolean} True if the Point coordinates are within the circle, otherwise false. - */ -var ContainsPoint = function (circle, point) -{ - return Contains(circle, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 852 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(88); - -/** - * Creates a new Circle instance based on the values contained in the given source. - * - * @function Phaser.Geom.Circle.Clone - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|object)} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. - * - * @return {Phaser.Geom.Circle} A clone of the source Circle. - */ -var Clone = function (source) -{ - return new Circle(source.x, source.y, source.radius); -}; - -module.exports = Clone; - - -/***/ }), -/* 853 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the area of the circle. - * - * @function Phaser.Geom.Circle.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. - * - * @return {number} The area of the Circle. - */ -var Area = function (circle) -{ - return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; -}; - -module.exports = Area; - - -/***/ }), -/* 854 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(88); - -Circle.Area = __webpack_require__(853); -Circle.Circumference = __webpack_require__(295); -Circle.CircumferencePoint = __webpack_require__(136); -Circle.Clone = __webpack_require__(852); -Circle.Contains = __webpack_require__(32); -Circle.ContainsPoint = __webpack_require__(851); -Circle.ContainsRect = __webpack_require__(850); -Circle.CopyFrom = __webpack_require__(849); -Circle.Equals = __webpack_require__(848); -Circle.GetBounds = __webpack_require__(847); -Circle.GetPoint = __webpack_require__(298); -Circle.GetPoints = __webpack_require__(296); -Circle.Offset = __webpack_require__(846); -Circle.OffsetPoint = __webpack_require__(845); -Circle.Random = __webpack_require__(157); - -module.exports = Circle; - - -/***/ }), -/* 855 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var LightsManager = __webpack_require__(401); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * [description] - * - * @class LightsPlugin - * @extends Phaser.GameObjects.LightsManager - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var LightsPlugin = new Class({ - - Extends: LightsManager, - - initialize: - - function LightsPlugin (scene) - { - /** - * [description] - * - * @name Phaser.GameObjects.LightsPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.LightsPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - LightsManager.call(this); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsPlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); - - this.scene = undefined; - this.systems = undefined; - } - -}); - -PluginCache.register('LightsPlugin', LightsPlugin, 'lights'); - -module.exports = LightsPlugin; - - -/***/ }), -/* 856 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Quad = __webpack_require__(232); - -/** - * Creates a new Quad Game Object and returns it. - * - * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#quad - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Quad} The Game Object that was created. - */ -GameObjectCreator.register('quad', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var quad = new Quad(this.scene, x, y, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, quad, config); - - return quad; -}); - - -/***/ }), -/* 857 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); -var Mesh = __webpack_require__(145); - -/** - * Creates a new Mesh Game Object and returns it. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#mesh - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Mesh} The Game Object that was created. - */ -GameObjectCreator.register('mesh', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - var vertices = GetValue(config, 'vertices', []); - var colors = GetValue(config, 'colors', []); - var alphas = GetValue(config, 'alphas', []); - var uv = GetValue(config, 'uv', []); - - var mesh = new Mesh(this.scene, 0, 0, vertices, uv, colors, alphas, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, mesh, config); - - return mesh; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 858 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Quad = __webpack_require__(232); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Quad Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#quad - * @webglOnly - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Quad} The Game Object that was created. - */ -if (true) -{ - GameObjectFactory.register('quad', function (x, y, key, frame) - { - return this.displayList.add(new Quad(this.scene, x, y, key, frame)); - }); -} - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 859 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Mesh = __webpack_require__(145); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Mesh Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#mesh - * @webglOnly - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {float[]} vertices - An array containing the vertices data for this Mesh. - * @param {float[]} uv - An array containing the uv data for this Mesh. - * @param {float[]} colors - An array containing the color data for this Mesh. - * @param {float[]} alphas - An array containing the alpha data for this Mesh. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Mesh} The Game Object that was created. - */ -if (true) -{ - GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame) - { - return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, colors, alphas, texture, frame)); - }); -} - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 860 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects. - * - * @method Phaser.GameObjects.Mesh#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var MeshCanvasRenderer = function () -{ -}; - -module.exports = MeshCanvasRenderer; - - -/***/ }), -/* 861 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Mesh#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchMesh(src, camera, parentMatrix); -}; - -module.exports = MeshWebGLRenderer; - - -/***/ }), -/* 862 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(861); -} - -if (true) -{ - renderCanvas = __webpack_require__(860); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 863 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Zone = __webpack_require__(158); - -/** - * Creates a new Zone Game Object and returns it. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#zone - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Zone} The Game Object that was created. - */ -GameObjectCreator.register('zone', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 1); - var height = GetAdvancedValue(config, 'height', width); - - return new Zone(this.scene, x, y, width, height); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 864 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var TileSprite = __webpack_require__(233); - -/** - * @typedef {object} TileSprite - * @extends GameObjectConfig - * - * @property {number} [x=0] - The x coordinate of the Tile Sprite. - * @property {number} [y=0] - The y coordinate of the Tile Sprite. - * @property {number} [width=512] - The width of the Tile Sprite. - * @property {number} [height=512] - The height of the Tile Sprite. - * @property {string} [key=''] - The key of the Texture this Tile Sprite will use to render with, as stored in the Texture Manager. - * @property {string} [frame=''] - An optional frame from the Texture this Tile Sprite is rendering with. - */ - -/** - * Creates a new TileSprite Game Object and returns it. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#tileSprite - * @since 3.0.0 - * - * @param {TileSprite} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. - */ -GameObjectCreator.register('tileSprite', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 512); - var height = GetAdvancedValue(config, 'height', 512); - var key = GetAdvancedValue(config, 'key', ''); - var frame = GetAdvancedValue(config, 'frame', ''); - - var tile = new TileSprite(this.scene, x, y, width, height, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, tile, config); - - return tile; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 865 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(253); -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); - -/** - * Creates a new Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#bitmapText - * @since 3.0.0 - * - * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. - */ -GameObjectCreator.register('bitmapText', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var font = GetValue(config, 'font', ''); - var text = GetAdvancedValue(config, 'text', ''); - var size = GetAdvancedValue(config, 'size', false); - - // var align = GetValue(config, 'align', 'left'); - - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, bitmapText, config); - - return bitmapText; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 866 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var BuildGameObjectAnimation = __webpack_require__(127); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Sprite3D = __webpack_require__(151); - -/** - * Creates a new Sprite3D Game Object and returns it. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#sprite3D - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. - */ -GameObjectCreator.register('sprite3D', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var sprite = new Sprite3D(this.scene, 0, 0, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, sprite, config); - - // Sprite specific config options: - - BuildGameObjectAnimation(sprite, config); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 867 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var RenderTexture = __webpack_require__(234); - -/** - * @typedef {object} RenderTextureConfig - * - * @property {number} [x=0] - The x coordinate of the RenderTexture's position. - * @property {number} [y=0] - The y coordinate of the RenderTexture's position. - * @property {number} [width=32] - The width of the RenderTexture. - * @property {number} [height=32] - The height of the RenderTexture. - */ - -/** - * Creates a new Render Texture Game Object and returns it. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#renderTexture - * @since 3.2.0 - * - * @param {RenderTextureConfig} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. - */ -GameObjectCreator.register('renderTexture', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 32); - var height = GetAdvancedValue(config, 'height', 32); - - var renderTexture = new RenderTexture(this.scene, x, y, width, height); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, renderTexture, config); - - return renderTexture; -}); - - -/***/ }), -/* 868 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetFastValue = __webpack_require__(1); -var ParticleEmitterManager = __webpack_require__(235); - -/** - * Creates a new Particle Emitter Manager Game Object and returns it. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#particles - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. - */ -GameObjectCreator.register('particles', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - var emitters = GetFastValue(config, 'emitters', null); - - // frame is optional and can contain the emitters array or object if skipped - var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - var add = GetFastValue(config, 'add', false); - - if (add) - { - this.displayList.add(manager); - } - - this.updateList.add(manager); - - return manager; -}); - - -/***/ }), -/* 869 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var Group = __webpack_require__(112); - -/** - * Creates a new Group Game Object and returns it. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#group - * @since 3.0.0 - * - * @param {GroupConfig} config - [description] - * - * @return {Phaser.GameObjects.Group} The Game Object that was created. - */ -GameObjectCreator.register('group', function (config) -{ - return new Group(this.scene, null, config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 870 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(250); -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * @typedef {object} BitmapTextConfig - * @extends GameObjectConfig - * - * @property {string} [font=''] - The key of the font to use from the BitmapFont cache. - * @property {string} [text=''] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @property {(number|false)} [size=false] - The font size to set. - */ - -/** - * Creates a new Dynamic Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText - * @since 3.0.0 - *² - * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. - */ -GameObjectCreator.register('dynamicBitmapText', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var font = GetAdvancedValue(config, 'font', ''); - var text = GetAdvancedValue(config, 'text', ''); - var size = GetAdvancedValue(config, 'size', false); - - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, bitmapText, config); - - return bitmapText; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 871 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var Container = __webpack_require__(251); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * Creates a new Container Game Object and returns it. - * - * Note: This method will only be available if the Container Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#container - * @since 3.4.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Container} The Game Object that was created. - */ -GameObjectCreator.register('container', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - - var container = new Container(this.scene, x, y); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, container, config); - - return container; -}); - - -/***/ }), -/* 872 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Blitter = __webpack_require__(252); -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * Creates a new Blitter Game Object and returns it. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#blitter - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Blitter} The Game Object that was created. - */ -GameObjectCreator.register('blitter', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var blitter = new Blitter(this.scene, 0, 0, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, blitter, config); - - return blitter; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 873 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Zone = __webpack_require__(158); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Zone Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#zone - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * - * @return {Phaser.GameObjects.Zone} The Game Object that was created. - */ -GameObjectFactory.register('zone', function (x, y, width, height) -{ - return this.displayList.add(new Zone(this.scene, x, y, width, height)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 874 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileSprite = __webpack_require__(233); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new TileSprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#tileSprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. - */ -GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) -{ - return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 875 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(253); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Bitmap Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#bitmapText - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} font - The key of the font to use from the BitmapFont cache. - * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @param {number} [size] - The font size to set. - * - * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. - */ -GameObjectFactory.register('bitmapText', function (x, y, font, text, size) -{ - return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 876 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Sprite3D = __webpack_require__(151); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Sprite3D Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#sprite3D - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object. - * @param {number} y - The vertical position of this Game Object. - * @param {number} z - The z position of this Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. - */ -GameObjectFactory.register('sprite3D', function (x, y, z, key, frame) -{ - var sprite = new Sprite3D(this.scene, x, y, z, key, frame); - - this.displayList.add(sprite.gameObject); - this.updateList.add(sprite.gameObject); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 877 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(11); -var RenderTexture = __webpack_require__(234); - -/** - * Creates a new Render Texture Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#renderTexture - * @since 3.2.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {integer} [width=32] - The width of the Render Texture. - * @param {integer} [height=32] - The height of the Render Texture. - * - * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. - */ -GameObjectFactory.register('renderTexture', function (x, y, width, height) -{ - return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); -}); - - -/***/ }), -/* 878 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(11); -var PathFollower = __webpack_require__(418); - -/** - * Creates a new PathFollower Game Object and adds it to the Scene. - * - * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#follower - * @since 3.0.0 - * - * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. - * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. - */ -GameObjectFactory.register('follower', function (path, x, y, key, frame) -{ - var sprite = new PathFollower(this.scene, path, x, y, key, frame); - - this.displayList.add(sprite); - this.updateList.add(sprite); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 879 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(11); -var ParticleEmitterManager = __webpack_require__(235); - -/** - * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#particles - * @since 3.0.0 - * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer|object)} [frame] - [description] - * @param {object} [emitters] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. - */ -GameObjectFactory.register('particles', function (key, frame, emitters) -{ - var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); - - this.displayList.add(manager); - this.updateList.add(manager); - - return manager; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 880 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Group = __webpack_require__(112); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Group Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#group - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject[]|GroupConfig)} [children] - Game Objects to add to this Group; or the `config` argument. - * @param {GroupConfig} [config] - A Group Configuration object. - * - * @return {Phaser.GameObjects.Group} The Game Object that was created. - */ -GameObjectFactory.register('group', function (children, config) -{ - if (typeof children === 'object' && config === undefined) - { - config = children; - children = []; - } - - return this.updateList.add(new Group(this.scene, children, config)); -}); - - -/***/ }), -/* 881 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var DynamicBitmapText = __webpack_require__(250); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} font - The key of the font to use from the BitmapFont cache. - * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @param {number} [size] - The font size to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. - */ -GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) -{ - return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 882 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Container = __webpack_require__(251); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Container Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Container Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#container - * @since 3.4.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. - * - * @return {Phaser.GameObjects.Container} The Game Object that was created. - */ -GameObjectFactory.register('container', function (x, y, children) -{ - return this.displayList.add(new Container(this.scene, x, y, children)); -}); - - -/***/ }), -/* 883 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Blitter = __webpack_require__(252); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Blitter Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#blitter - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} key - The key of the Texture the Blitter object will use. - * @param {(string|integer)} [frame] - The default Frame children of the Blitter will use. - * - * @return {Phaser.GameObjects.Blitter} The Game Object that was created. - */ -GameObjectFactory.register('blitter', function (x, y, key, frame) -{ - return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 884 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.TileSprite#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - var frame = src.frame; - - src.updateTileTexture(); - - // Blend Mode - - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var dx = frame.x - (src.originX * src.width); - var dy = frame.y - (src.originY * src.height); - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - var fx = 1; - var fy = 1; - - // Flipping - - if (src.flipX) - { - fx = -1; - dx += src.width; - } - - if (src.flipY) - { - fy = -1; - dy += src.height; - } - - if (renderer.config.roundPixels) - { - dx |= 0; - dy |= 0; - tx |= 0; - ty |= 0; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(dx, dy); - - ctx.translate(tx, ty); - - // Flip - ctx.scale(fx, fy); - - // Rotate and scale around center - ctx.translate((src.originX * src.width), (src.originY * src.height)); - ctx.rotate(fx * fy * src.rotation); - ctx.scale(this.scaleX, this.scaleY); - ctx.translate(-(src.originX * src.width), -(src.originY * src.height)); - - // Draw - ctx.translate(-this.tilePositionX, -this.tilePositionY); - ctx.fillStyle = src.canvasPattern; - ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width, src.height); - - ctx.restore(); -}; - -module.exports = TileSpriteCanvasRenderer; - - -/***/ }), -/* 885 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.TileSprite#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.updateTileTexture(); - - this.pipeline.batchTileSprite(this, camera, parentMatrix); -}; - -module.exports = TileSpriteWebGLRenderer; - - -/***/ }), -/* 886 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(885); -} - -if (true) -{ - renderCanvas = __webpack_require__(884); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 887 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -/** - * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor - * and create a BitmapText object using a fixed-width retro font. - * - * @function Phaser.GameObjects.RetroFont.Parse - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - A reference to the Phaser Scene. - * @param {Phaser.GameObjects.RetroFont.Config} config - The font configuration object. - * - * @return {object} A parsed Bitmap Font data entry for the Bitmap Font cache. - */ -var ParseRetroFont = function (scene, config) -{ - var w = config.width; - var h = config.height; - var cx = Math.floor(w / 2); - var cy = Math.floor(h / 2); - var letters = GetValue(config, 'chars', ''); - - if (letters === '') - { - return; - } - - var key = GetValue(config, 'image', ''); - var offsetX = GetValue(config, 'offset.x', 0); - var offsetY = GetValue(config, 'offset.y', 0); - var spacingX = GetValue(config, 'spacing.x', 0); - var spacingY = GetValue(config, 'spacing.y', 0); - - var charsPerRow = GetValue(config, 'charsPerRow', null); - - if (charsPerRow === null) - { - charsPerRow = scene.sys.textures.getFrame(key).width / w; - - if (charsPerRow > letters.length) - { - charsPerRow = letters.length; - } - } - - var x = offsetX; - var y = offsetY; - - var data = { - retroFont: true, - font: key, - size: w, - lineHeight: h, - chars: {} - }; - - var r = 0; - - for (var i = 0; i < letters.length; i++) - { - // var node = letters[i]; - - var charCode = letters.charCodeAt(i); - - data.chars[charCode] = - { - x: x, - y: y, - width: w, - height: h, - centerX: cx, - centerY: cy, - xOffset: 0, - yOffset: 0, - xAdvance: w, - data: {}, - kerning: {} - }; - - r++; - - if (r === charsPerRow) - { - r = 0; - x = offsetX; - y += h + spacingY; - } - else - { - x += w + spacingX; - } - } - - var entry = { - data: data, - frame: null, - texture: key - }; - - return entry; -}; - -module.exports = ParseRetroFont; - - -/***/ }), -/* 888 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RETRO_FONT_CONST = { - - /** - * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET1 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET1: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', - - /** - * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET2 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET2: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ', - - /** - * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET3 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET3: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ', - - /** - * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET4 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET4: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789', - - /** - * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET5 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET5: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789', - - /** - * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET6 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET6: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' ', - - /** - * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET7 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET7: 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39', - - /** - * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET8 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET8: '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ', - - /** - * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET9 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET9: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!', - - /** - * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET10 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET10: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', - - /** - * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET11 - * @since 3.6.0 - * @type {string} - */ - TEXT_SET11: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789' - -}; - -module.exports = RETRO_FONT_CONST; - - -/***/ }), -/* 889 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RETRO_FONT_CONST = __webpack_require__(888); -var Extend = __webpack_require__(17); - -/** - * @typedef {object} Phaser.GameObjects.RetroFont.Config - * - * @property {string} image - The key of the image containing the font. - * @property {number} offset.x - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. - * @property {number} offset.y - If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. - * @property {number} width - The width of each character in the font set. - * @property {number} height - The height of each character in the font set. - * @property {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. - * @property {number} charsPerRow - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. - * @property {number} spacing.x - If the characters in the font set have horizontal spacing between them set the required amount here. - * @property {number} spacing.y - If the characters in the font set have vertical spacing between them set the required amount here. -*/ - -/** - * @namespace Phaser.GameObjects.RetroFont - * @since 3.6.0 - */ - -var RetroFont = { Parse: __webpack_require__(887) }; - -// Merge in the consts -RetroFont = Extend(false, RetroFont, RETRO_FONT_CONST); - -module.exports = RetroFont; - - -/***/ }), -/* 890 */ -/***/ (function(module, exports) { - -var RenderTextureWebGL = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, 1); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - clear: function () - { - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - draw: function (texture, frame, x, y) - { - 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.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; - } - -}; - -module.exports = RenderTextureWebGL; - - -/***/ }), -/* 891 */ -/***/ (function(module, exports) { - -var RenderTextureCanvas = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; - this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); - - return this; - }, - - clear: function () - { - this.context.save(); - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); - this.context.restore(); - - return this; - }, - - draw: function (texture, frame, x, y) - { - var cd = frame.canvasData; - var source = frame.source.image; - - var matrix = this.currentMatrix; - - this.context.globalAlpha = this.globalAlpha; - this.context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - this.context.drawImage(source, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); - - return this; - } - -}; - -module.exports = RenderTextureCanvas; - - -/***/ }), -/* 892 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.RenderTexture#renderCanvas - * @since 3.2.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - - if (renderer.currentBlendMode !== renderTexture.blendMode) - { - renderer.currentBlendMode = renderTexture.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; - } - - if (renderer.currentAlpha !== renderTexture.alpha) - { - renderer.currentAlpha = renderTexture.alpha; - ctx.globalAlpha = renderTexture.alpha; - } - - if (renderer.currentScaleMode !== renderTexture.scaleMode) - { - renderer.currentScaleMode = renderTexture.scaleMode; - } - - var dx = 0; - var dy = 0; - - var fx = 1; - var fy = 1; - - if (renderTexture.flipX) - { - fx = -1; - dx -= renderTexture.canvas.width - renderTexture.displayOriginX; - } - else - { - dx -= renderTexture.displayOriginX; - } - - if (renderTexture.flipY) - { - fy = -1; - dy -= renderTexture.canvas.height - renderTexture.displayOriginY; - } - else - { - dy -= renderTexture.displayOriginY; - } - - ctx.save(); - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY); - ctx.rotate(renderTexture.rotation); - ctx.scale(renderTexture.scaleX, renderTexture.scaleY); - ctx.scale(fx, fy); - ctx.drawImage(renderTexture.canvas, dx, dy); - ctx.restore(); -}; - -module.exports = RenderTextureCanvasRenderer; - - -/***/ }), -/* 893 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); -var Utils = __webpack_require__(27); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.RenderTexture#renderWebgl - * @since 3.2.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchTexture( - renderTexture, - renderTexture.texture, - renderTexture.texture.width, renderTexture.texture.height, - renderTexture.x, renderTexture.y, - renderTexture.width, renderTexture.height, - renderTexture.scaleX, renderTexture.scaleY, - renderTexture.rotation, - renderTexture.flipX, !renderTexture.flipY, - renderTexture.scrollFactorX, renderTexture.scrollFactorY, - renderTexture.displayOriginX, renderTexture.displayOriginY, - 0, 0, renderTexture.texture.width, renderTexture.texture.height, - Utils.getTintAppendFloatAlpha(renderTexture.tintTopLeft, renderTexture.alphaTopLeft), Utils.getTintAppendFloatAlpha(renderTexture.tintTopRight, renderTexture.alphaTopRight), Utils.getTintAppendFloatAlpha(renderTexture.tintBottomLeft, renderTexture.alphaBottomLeft), Utils.getTintAppendFloatAlpha(renderTexture.tintBottomRight, renderTexture.alphaBottomRight), - 0, 0, - camera, - parentMatrix - ); -}; - -module.exports = RenderTextureWebGLRenderer; - - -/***/ }), -/* 894 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(893); -} - -if (true) -{ - renderCanvas = __webpack_require__(892); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 895 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects.Particles.Zones - */ - -module.exports = { - - DeathZone: __webpack_require__(455), - EdgeZone: __webpack_require__(454), - RandomZone: __webpack_require__(419) - -}; - - -/***/ }), -/* 896 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Particles.EmitterManager#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) -{ - var emitters = emitterManager.emitters.list; - - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - - ctx.save(); - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - var particles = emitter.alive; - var length = particles.length; - - if (!emitter.visible || length === 0) - { - continue; - } - - - var lastAlpha = ctx.globalAlpha; - var cameraScrollX = camera.scrollX * emitter.scrollFactorX; - var cameraScrollY = camera.scrollY * emitter.scrollFactorY; - - if (renderer.currentBlendMode !== emitter.blendMode) - { - renderer.currentBlendMode = emitter.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; - } - - var roundPixels = renderer.config.roundPixels; - - for (var index = 0; index < length; ++index) - { - var particle = particles[index]; - - var alpha = ((particle.color >> 24) & 0xFF) / 255.0; - - if (alpha <= 0) - { - continue; - } - - var frame = particle.frame; - var width = frame.width; - var height = frame.height; - var ox = width * 0.5; - var oy = height * 0.5; - var cd = frame.canvasData; - - var x = -ox; - var y = -oy; - - var tx = particle.x - cameraScrollX; - var ty = particle.y - cameraScrollY; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.globalAlpha = alpha; - - ctx.save(); - - ctx.translate(tx, ty); - - ctx.rotate(particle.rotation); - - ctx.scale(particle.scaleX, particle.scaleY); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); - - ctx.restore(); - } - - ctx.globalAlpha = lastAlpha; - } - - ctx.restore(); -}; - -module.exports = ParticleManagerCanvasRenderer; - - -/***/ }), -/* 897 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Particles.EmitterManager#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) -{ - var emitters = emitterManager.emitters; - - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.drawEmitterManager(emitterManager, camera, parentMatrix); -}; - -module.exports = ParticleManagerWebGLRenderer; - - -/***/ }), -/* 898 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(897); -} - -if (true) -{ - renderCanvas = __webpack_require__(896); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 899 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FloatBetween = __webpack_require__(248); -var GetEaseFunction = __webpack_require__(63); -var GetFastValue = __webpack_require__(1); -var Wrap = __webpack_require__(39); - -/** - * The returned value sets what the property will be at the START of the particle's life, on emit. - * @callback EmitterOpOnEmitCallback - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. - * @param {string} key - The name of the property. - * @param {number} value - The current value of the property. - * - * @return {number} The new value of the property. - */ - -/** - * The returned value updates the property for the duration of the particle's life. - * @callback EmitterOpOnUpdateCallback - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. - * @param {string} key - The name of the property. - * @param {float} t - The normalized lifetime of the particle, between 0 (start) and 1 (end). - * @param {number} value - The current value of the property. - * - * @return {number} The new value of the property. - */ - -/** - * Defines an operation yielding a random value within a range. - * @typedef {object} EmitterOpRandomConfig - * - * @property {float[]} random - The minimum and maximum values, as [min, max]. - */ - -/** - * Defines an operation yielding a random value within a range. - * @typedef {object} EmitterOpRandomMinMaxConfig - * - * @property {float} min - The minimum value. - * @property {float} max - The maximum value. - */ - -/** - * Defines an operation yielding a random value within a range. - * @typedef {object} EmitterOpRandomStartEndConfig - * - * @property {float} start - The starting value. - * @property {float} end - The ending value. - * @property {boolean} random - If false, this becomes {@link EmitterOpEaseConfig}. - */ - -/** - * Defines an operation yielding a value incremented continuously across a range. - * @typedef {object} EmitterOpEaseConfig - * - * @property {float} start - The starting value. - * @property {float} end - The ending value. - * @property {string} [ease='Linear'] - The name of the easing function. - */ - -/** - * Defines an operation yielding a value incremented by steps across a range. - * @typedef {object} EmitterOpSteppedConfig - * - * @property {number} start - The starting value. - * @property {number} end - The ending value. - * @property {number} steps - The number of steps between start and end. - */ - -/** - * @typedef {object} EmitterOpCustomEmitConfig - * - * @property {EmitterOpOnEmitCallback} onEmit - [description] - */ - -/** - * @typedef {object} EmitterOpCustomUpdateConfig - * - * @property {EmitterOpOnEmitCallback} [onEmit] - [description] - * @property {EmitterOpOnUpdateCallback} onUpdate - [description] - */ - -/** - * @classdesc - * [description] - * - * @class EmitterOp - * @memberOf Phaser.GameObjects.Particles - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - * @param {string} key - [description] - * @param {number} defaultValue - [description] - * @param {boolean} [emitOnly=false] - [description] - */ -var EmitterOp = new Class({ - - initialize: - - function EmitterOp (config, key, defaultValue, emitOnly) - { - if (emitOnly === undefined) - { - emitOnly = false; - } - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey - * @type {string} - * @since 3.0.0 - */ - this.propertyKey = key; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue - * @type {number} - * @since 3.0.0 - */ - this.propertyValue = defaultValue; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue - * @type {number} - * @since 3.0.0 - */ - this.defaultValue = defaultValue; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#steps - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.steps = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#counter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.counter = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#start - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.start = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#end - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.end = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#ease - * @type {?function} - * @since 3.0.0 - */ - this.ease; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly - * @type {boolean} - * @since 3.0.0 - */ - this.emitOnly = emitOnly; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#onEmit - * @type {EmitterOpOnEmitCallback} - * @since 3.0.0 - */ - this.onEmit = this.defaultEmit; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate - * @type {EmitterOpOnUpdateCallback} - * @since 3.0.0 - */ - this.onUpdate = this.defaultUpdate; - - this.loadConfig(config); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig - * @since 3.0.0 - * - * @param {object} [config] - [description] - * @param {string} [newKey] - [description] - */ - loadConfig: function (config, newKey) - { - if (config === undefined) - { - config = {}; - } - - if (newKey) - { - this.propertyKey = newKey; - } - - this.propertyValue = GetFastValue( - config, - this.propertyKey, - this.defaultValue - ); - - this.setMethods(); - - if (this.emitOnly) - { - // Reset it back again - this.onUpdate = this.defaultUpdate; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#onChange - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. - */ - onChange: function (value) - { - this.propertyValue = value; - - return this.setMethods(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#setMethods - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. - */ - setMethods: function () - { - var value = this.propertyValue; - - var t = typeof value; - - if (t === 'number') - { - // Explicit static value: - // x: 400 - - this.onEmit = this.staticValueEmit; - this.onUpdate = this.staticValueUpdate; // How? - } - else if (Array.isArray(value)) - { - // Picks a random element from the array: - // x: [ 100, 200, 300, 400 ] - - this.onEmit = this.randomStaticValueEmit; - } - else if (t === 'function') - { - // The same as setting just the onUpdate function and no onEmit (unless this op is an emitOnly one) - // Custom callback, must return a value: - - /* - x: function (particle, key, t, value) - { - return value + 50; - } - */ - - if (this.emitOnly) - { - this.onEmit = value; - } - else - { - this.onUpdate = value; - } - } - else if (t === 'object' && (this.has(value, 'random') || this.hasBoth(value, 'start', 'end') || this.hasBoth(value, 'min', 'max'))) - { - this.start = this.has(value, 'start') ? value.start : value.min; - this.end = this.has(value, 'end') ? value.end : value.max; - - var isRandom = (this.hasBoth(value, 'min', 'max') || this.has(value, 'random')); - - // A random starting value (using 'min | max' instead of 'start | end' automatically implies a random value) - - // x: { start: 100, end: 400, random: true } OR { min: 100, max: 400 } OR { random: [ 100, 400 ] } - - if (isRandom) - { - var rnd = value.random; - - // x: { random: [ 100, 400 ] } = the same as doing: x: { start: 100, end: 400, random: true } - if (Array.isArray(rnd)) - { - this.start = rnd[0]; - this.end = rnd[1]; - } - - this.onEmit = this.randomRangedValueEmit; - } - - if (this.has(value, 'steps')) - { - // A stepped (per emit) range - - // x: { start: 100, end: 400, steps: 64 } - - // Increments a value stored in the emitter - - this.steps = value.steps; - this.counter = this.start; - - this.onEmit = this.steppedEmit; - } - else - { - // An eased range (defaults to Linear if not specified) - - // x: { start: 100, end: 400, [ ease: 'Linear' ] } - - var easeType = this.has(value, 'ease') ? value.ease : 'Linear'; - - this.ease = GetEaseFunction(easeType); - - if (!isRandom) - { - this.onEmit = this.easedValueEmit; - } - - // BUG: alpha, rotate, scaleX, scaleY, or tint are eased here if {min, max} is given. - // Probably this branch should exclude isRandom entirely. - - this.onUpdate = this.easeValueUpdate; - } - } - else if (t === 'object' && this.hasEither(value, 'onEmit', 'onUpdate')) - { - // Custom onEmit and onUpdate callbacks - - /* - x: { - // Called at the start of the particles life, when it is being created - onEmit: function (particle, key, t, value) - { - return value; - }, - - // Called during the particles life on each update - onUpdate: function (particle, key, t, value) - { - return value; - } - } - */ - - if (this.has(value, 'onEmit')) - { - this.onEmit = value.onEmit; - } - - if (this.has(value, 'onUpdate')) - { - this.onUpdate = value.onUpdate; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#has - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (object, key) - { - return object.hasOwnProperty(key); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key1 - [description] - * @param {string} key2 - [description] - * - * @return {boolean} [description] - */ - hasBoth: function (object, key1, key2) - { - return object.hasOwnProperty(key1) && object.hasOwnProperty(key2); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#hasEither - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key1 - [description] - * @param {string} key2 - [description] - * - * @return {boolean} [description] - */ - hasEither: function (object, key1, key2) - { - return object.hasOwnProperty(key1) || object.hasOwnProperty(key2); - }, - - /** - * The returned value sets what the property will be at the START of the particles life, on emit. - * - * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {number} value - [description] - * - * @return {number} [description] - */ - defaultEmit: function (particle, key, value) - { - return value; - }, - - /** - * The returned value updates the property for the duration of the particles life. - * - * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {float} t - The T value (between 0 and 1) - * @param {number} value - [description] - * - * @return {number} [description] - */ - defaultUpdate: function (particle, key, t, value) - { - return value; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - staticValueEmit: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate - * @since 3.0.0 - * - * @return {number} [description] - */ - staticValueUpdate: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - randomStaticValueEmit: function () - { - var randomIndex = Math.floor(Math.random() * this.propertyValue.length); - - return this.propertyValue[randomIndex]; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * - * @return {number} [description] - */ - randomRangedValueEmit: function (particle, key) - { - var value = FloatBetween(this.start, this.end); - - if (particle && particle.data[key]) - { - particle.data[key].min = value; - } - - return value; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - steppedEmit: function () - { - var current = this.counter; - - var next = this.counter + (this.end - this.start) / this.steps; - - this.counter = Wrap(next, this.start, this.end); - - return current; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * - * @return {number} [description] - */ - easedValueEmit: function (particle, key) - { - if (particle && particle.data[key]) - { - var data = particle.data[key]; - - data.min = this.start; - data.max = this.end; - } - - return this.start; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {float} t - The T value (between 0 and 1) - * - * @return {number} [description] - */ - easeValueUpdate: function (particle, key, t) - { - var data = particle.data[key]; - - return (data.max - data.min) * this.ease(t) + data.min; - } -}); - -module.exports = EmitterOp; - - -/***/ }), -/* 900 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects.Particles - */ - -module.exports = { - - GravityWell: __webpack_require__(458), - Particle: __webpack_require__(457), - ParticleEmitter: __webpack_require__(456), - ParticleEmitterManager: __webpack_require__(235), - Zones: __webpack_require__(895) - -}; - - -/***/ }), -/* 901 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - var text = src.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var textureFrame = src.frame; - - var displayCallback = src.displayCallback; - - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; - - var xAdvance = 0; - var yAdvance = 0; - - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - var ctx = renderer.currentContext; - var image = src.frame.source.image; - - var textureX = textureFrame.cutX; - var textureY = textureFrame.cutY; - - var rotation = 0; - var scale = (src.fontSize / src.fontData.size); - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(src.x, src.y); - - ctx.rotate(src.rotation); - - ctx.translate(-src.displayOriginX, -src.displayOriginY); - - ctx.scale(src.scaleX, src.scaleY); - - if (src.cropWidth > 0 && src.cropHeight > 0) - { - ctx.save(); - ctx.beginPath(); - ctx.rect(0, 0, src.cropWidth, src.cropHeight); - ctx.clip(); - } - - var roundPixels = renderer.config.roundPixels; - - for (var index = 0; index < textLength; ++index) - { - // Reset the scale (in case the callback changed it) - scale = (src.fontSize / src.fontData.size); - rotation = 0; - - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) - src.scrollX; - y = (glyph.yOffset + yAdvance) - src.scrollY; - - // This could be optimized so that it doesn't even bother drawing it if the x/y is out of range - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - if (displayCallback) - { - var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); - - x = output.x; - y = output.y; - scale = output.scale; - rotation = output.rotation; - } - - x *= scale; - y *= scale; - - x -= cameraScrollX; - y -= cameraScrollY; - - if (roundPixels) - { - x |= 0; - y |= 0; - } - - ctx.save(); - - ctx.translate(x, y); - - ctx.rotate(rotation); - - ctx.scale(scale, scale); - - ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); - - ctx.restore(); - - xAdvance += glyph.xAdvance; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - } - - if (src.cropWidth > 0 && src.cropHeight > 0) - { - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = DynamicBitmapTextCanvasRenderer; - - -/***/ }), -/* 902 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.DynamicBitmapText} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolationPercentage, camera, parentMatrix) -{ - var text = bitmapText.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== bitmapText.renderFlags || textLength === 0 || (bitmapText.cameraFilter > 0 && (bitmapText.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchDynamicBitmapText(bitmapText, camera, parentMatrix); -}; - -module.exports = DynamicBitmapTextWebGLRenderer; - - -/***/ }), -/* 903 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(902); -} - -if (true) -{ - renderCanvas = __webpack_require__(901); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 904 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Container#renderCanvas - * @since 3.4.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ContainerCanvasRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== container.renderFlags || (container.cameraFilter > 0 && (container.cameraFilter & camera._id))) - { - return; - } - - var children = container.list; - var transformMatrix = container.localTransform; - - if (parentMatrix === undefined) - { - transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); - } - else - { - transformMatrix.loadIdentity(); - transformMatrix.multiply(parentMatrix); - transformMatrix.translate(container.x, container.y); - transformMatrix.rotate(container.rotation); - transformMatrix.scale(container.scaleX, container.scaleY); - } - - var alpha = container._alpha; - var scrollFactorX = container.scrollFactorX; - var scrollFactorY = container.scrollFactorY; - - for (var index = 0; index < children.length; ++index) - { - var child = children[index]; - var childAlpha = child._alpha; - var childScrollFactorX = child.scrollFactorX; - var childScrollFactorY = child.scrollFactorY; - - child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); - child.setAlpha(childAlpha * alpha); - child.renderCanvas(renderer, child, interpolationPercentage, camera, transformMatrix); - child.setAlpha(childAlpha); - child.setScrollFactor(childScrollFactorX, childScrollFactorY); - } -}; - -module.exports = ContainerCanvasRenderer; - - -/***/ }), -/* 905 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Container#renderWebGL - * @since 3.4.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ContainerWebGLRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== container.renderFlags || (container.cameraFilter > 0 && (container.cameraFilter & camera._id))) - { - return; - } - - var children = container.list; - var transformMatrix = container.localTransform; - - if (parentMatrix === undefined) - { - transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); - } - else - { - transformMatrix.loadIdentity(); - transformMatrix.multiply(parentMatrix); - transformMatrix.translate(container.x, container.y); - transformMatrix.rotate(container.rotation); - transformMatrix.scale(container.scaleX, container.scaleY); - } - - var alpha = container._alpha; - var scrollFactorX = container.scrollFactorX; - var scrollFactorY = container.scrollFactorY; - - for (var index = 0; index < children.length; ++index) - { - var child = children[index]; - var childAlpha = child._alpha; - var childScrollFactorX = child.scrollFactorX; - var childScrollFactorY = child.scrollFactorY; - - child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); - child.setAlpha(childAlpha * alpha); - child.renderWebGL(renderer, child, interpolationPercentage, camera, transformMatrix); - child.setAlpha(childAlpha); - child.setScrollFactor(childScrollFactorX, childScrollFactorY); - } -}; - -module.exports = ContainerWebGLRenderer; - - -/***/ }), -/* 906 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(905); -} - -if (true) -{ - renderCanvas = __webpack_require__(904); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 907 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A Bob Game Object. - * - * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. - * - * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle - * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it - * must be a Frame within the Texture used by the parent Blitter. - * - * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will - * have their positions impacted by this change as well. - * - * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be - * handled via the Blitter parent. - * - * @class Bob - * @memberOf Phaser.GameObjects.Blitter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. - * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. - * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. - * @param {(string|integer)} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. - * @param {boolean} visible - Should the Bob render visible or not to start with? - */ -var Bob = new Class({ - - initialize: - - function Bob (blitter, x, y, frame, visible) - { - /** - * The Blitter object that this Bob belongs to. - * - * @name Phaser.GameObjects.Blitter.Bob#parent - * @type {Phaser.GameObjects.Blitter} - * @since 3.0.0 - */ - this.parent = blitter; - - /** - * The x position of this Bob, relative to the x position of the Blitter. - * - * @name Phaser.GameObjects.Blitter.Bob#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of this Bob, relative to the y position of the Blitter. - * - * @name Phaser.GameObjects.Blitter.Bob#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The frame that the Bob uses to render with. - * To change the frame use the `Bob.setFrame` method. - * - * @name Phaser.GameObjects.Blitter.Bob#frame - * @type {Phaser.Textures.Frame} - * @protected - * @since 3.0.0 - */ - this.frame = frame; - - /** - * A blank object which can be used to store data related to this Bob in. - * - * @name Phaser.GameObjects.Blitter.Bob#data - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.data = {}; - - /** - * The visible state of this Bob. - * - * @name Phaser.GameObjects.Blitter.Bob#_visible - * @type {boolean} - * @private - * @since 3.0.0 - */ - this._visible = visible; - - /** - * The alpha value of this Bob. - * - * @name Phaser.GameObjects.Blitter.Bob#_alpha - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._alpha = 1; - - /** - * The horizontally flipped state of the Bob. - * A Bob that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture. - * - * @name Phaser.GameObjects.Blitter.Bob#flipX - * @type {boolean} - * @since 3.0.0 - */ - this.flipX = false; - - /** - * The vertically flipped state of the Bob. - * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture. - * - * @name Phaser.GameObjects.Blitter.Bob#flipY - * @type {boolean} - * @since 3.0.0 - */ - this.flipY = false; - }, - - /** - * Changes the Texture Frame being used by this Bob. - * The frame must be part of the Texture the parent Blitter is using. - * If no value is given it will use the default frame of the Blitter parent. - * - * @method Phaser.GameObjects.Blitter.Bob#setFrame - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The frame to be used during rendering. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFrame: function (frame) - { - if (frame === undefined) - { - frame = this.parent.frame; - } - else - { - frame = this.parent.texture.get(frame); - } - - return this; - }, - - /** - * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. - * - * @method Phaser.GameObjects.Blitter.Bob#resetFlip - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - resetFlip: function () - { - this.flipX = false; - this.flipY = false; - - return this; - }, - - /** - * Resets this Bob. - * - * Changes the position to the values given, and optionally changes the frame. - * - * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. - * - * @method Phaser.GameObjects.Blitter.Bob#reset - * @since 3.0.0 - * - * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - reset: function (x, y, frame) - { - this.x = x; - this.y = y; - - this.flipX = false; - this.flipY = false; - - this._alpha = 1; - this._visible = true; - - this.parent.dirty = true; - - if (frame) - { - this.setFrame(frame); - } - - return this; - }, - - /** - * Sets the horizontal flipped state of this Bob. - * - * @method Phaser.GameObjects.Blitter.Bob#setFlipX - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlipX: function (value) - { - this.flipX = value; - - return this; - }, - - /** - * Sets the vertical flipped state of this Bob. - * - * @method Phaser.GameObjects.Blitter.Bob#setFlipY - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlipY: function (value) - { - this.flipY = value; - - return this; - }, - - /** - * Sets the horizontal and vertical flipped state of this Bob. - * - * @method Phaser.GameObjects.Blitter.Bob#setFlip - * @since 3.0.0 - * - * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlip: function (x, y) - { - this.flipX = x; - this.flipY = y; - - return this; - }, - - /** - * Sets the visibility of this Bob. - * - * An invisible Bob will skip rendering. - * - * @method Phaser.GameObjects.Blitter.Bob#setVisible - * @since 3.0.0 - * - * @param {boolean} value - The visible state of the Game Object. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * A Bob with alpha 0 will skip rendering. - * - * @method Phaser.GameObjects.Blitter.Bob#setAlpha - * @since 3.0.0 - * - * @param {float} value - The alpha value used for this Bob. Between 0 and 1. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setAlpha: function (value) - { - this.alpha = value; - - return this; - }, - - /** - * Destroys this Bob instance. - * Removes itself from the Blitter and clears the parent, frame and data properties. - * - * @method Phaser.GameObjects.Blitter.Bob#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.parent.dirty = true; - - this.parent.children.remove(this); - - this.parent = undefined; - this.frame = undefined; - this.data = undefined; - }, - - /** - * The visible state of the Bob. - * - * An invisible Bob will skip rendering. - * - * @name Phaser.GameObjects.Blitter.Bob#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - this._visible = value; - this.parent.dirty = true; - } - - }, - - /** - * The alpha value of the Bob, between 0 and 1. - * - * A Bob with alpha 0 will skip rendering. - * - * @name Phaser.GameObjects.Blitter.Bob#alpha - * @type {number} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this._alpha; - }, - - set: function (value) - { - this._alpha = value; - this.parent.dirty = true; - } - - } - -}); - -module.exports = Bob; - - -/***/ }), -/* 908 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Blitter#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var list = src.getRenderList(); - - renderer.setBlendMode(src.blendMode); - - var ctx = renderer.gameContext; - var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; - var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - // Render bobs - for (var i = 0; i < list.length; i++) - { - var bob = list[i]; - var flip = (bob.flipX || bob.flipY); - var frame = bob.frame; - var cd = frame.canvasData; - var dx = frame.x; - var dy = frame.y; - var fx = 1; - var fy = 1; - - if (!flip) - { - renderer.blitImage(dx + bob.x + cameraScrollX, dy + bob.y + cameraScrollY, bob.frame); - } - else - { - if (bob.flipX) - { - fx = -1; - dx -= cd.dWidth; - } - - if (bob.flipY) - { - fy = -1; - dy -= cd.dHeight; - } - - ctx.save(); - ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); - ctx.scale(fx, fy); - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - ctx.restore(); - } - } - - ctx.restore(); -}; - -module.exports = BlitterCanvasRenderer; - - -/***/ }), -/* 909 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Blitter#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Blitter} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var BlitterWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== gameObject.renderFlags || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.drawBlitter(gameObject, camera, parentMatrix); -}; - -module.exports = BlitterWebGLRenderer; - - -/***/ }), -/* 910 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(909); -} - -if (true) -{ - renderCanvas = __webpack_require__(908); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 911 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.BitmapText#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - var text = src.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var textureFrame = src.frame; - - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; - var letterSpacing = src.letterSpacing; - - var xAdvance = 0; - var yAdvance = 0; - - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - var ctx = renderer.currentContext; - var image = src.frame.source.image; - - var textureX = textureFrame.cutX; - var textureY = textureFrame.cutY; - - var scale = (src.fontSize / src.fontData.size); - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var roundPixels = renderer.config.roundPixels; - - var tx = (src.x - camera.scrollX * src.scrollFactorX) + src.frame.x; - var ty = (src.y - camera.scrollY * src.scrollFactorY) + src.frame.y; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.translate(-src.displayOriginX, -src.displayOriginY); - - ctx.scale(src.scaleX, src.scaleY); - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = indexCount + glyph.xOffset + xAdvance; - y = glyph.yOffset + yAdvance; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - x *= scale; - y *= scale; - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - if (roundPixels) - { - x |= 0; - y |= 0; - } - - ctx.save(); - - ctx.translate(x, y); - - ctx.scale(scale, scale); - - ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); - - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = BitmapTextCanvasRenderer; - - -/***/ }), -/* 912 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.BitmapText#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.BitmapText} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera, parentMatrix) -{ - var text = gameObject.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== gameObject.renderFlags || textLength === 0 || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchBitmapText(this, camera, parentMatrix); -}; - -module.exports = BitmapTextWebGLRenderer; - - -/***/ }), -/* 913 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(912); -} - -if (true) -{ - renderCanvas = __webpack_require__(911); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 914 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ParseXMLBitmapFont = __webpack_require__(474); - -/** - * Parse an XML Bitmap Font from an Atlas. - * - * Adds the parsed Bitmap Font data to the cache with the `fontName` key. - * - * @function ParseFromAtlas - * @since 3.0.0 - * @private - * - * @param {Phaser.Scene} scene - The Scene to parse the Bitmap Font for. - * @param {string} fontName - The key of the font to add to the Bitmap Font cache. - * @param {string} textureKey - The key of the BitmapFont's texture. - * @param {string} frameKey - The key of the BitmapFont texture's frame. - * @param {string} xmlKey - The key of the XML data of the font to parse. - * @param {integer} xSpacing - The x-axis spacing to add between each letter. - * @param {integer} ySpacing - The y-axis spacing to add to the line height. - * - * @return {boolean} Whether the parsing was successful or not. - */ -var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) -{ - var frame = scene.sys.textures.getFrame(textureKey, frameKey); - var xml = scene.sys.cache.xml.get(xmlKey); - - if (frame && xml) - { - var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame); - - scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey }); - - return true; - } - else - { - return false; - } -}; - -module.exports = ParseFromAtlas; - - -/***/ }), -/* 915 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects - */ - -var GameObjects = { - - DisplayList: __webpack_require__(504), - GameObjectCreator: __webpack_require__(13), - GameObjectFactory: __webpack_require__(11), - UpdateList: __webpack_require__(476), - - Components: __webpack_require__(15), - - BuildGameObject: __webpack_require__(24), - BuildGameObjectAnimation: __webpack_require__(127), - GameObject: __webpack_require__(2), - BitmapText: __webpack_require__(253), - Blitter: __webpack_require__(252), - Container: __webpack_require__(251), - DynamicBitmapText: __webpack_require__(250), - Graphics: __webpack_require__(115), - Group: __webpack_require__(112), - Image: __webpack_require__(69), - Particles: __webpack_require__(900), - PathFollower: __webpack_require__(418), - RenderTexture: __webpack_require__(234), - RetroFont: __webpack_require__(889), - Sprite3D: __webpack_require__(151), - Sprite: __webpack_require__(34), - Text: __webpack_require__(110), - TileSprite: __webpack_require__(233), - Zone: __webpack_require__(158), - - // Game Object Factories - - Factories: { - Blitter: __webpack_require__(883), - Container: __webpack_require__(882), - DynamicBitmapText: __webpack_require__(881), - Graphics: __webpack_require__(410), - Group: __webpack_require__(880), - Image: __webpack_require__(409), - Particles: __webpack_require__(879), - PathFollower: __webpack_require__(878), - RenderTexture: __webpack_require__(877), - Sprite3D: __webpack_require__(876), - Sprite: __webpack_require__(408), - StaticBitmapText: __webpack_require__(875), - Text: __webpack_require__(407), - TileSprite: __webpack_require__(874), - Zone: __webpack_require__(873) - }, - - Creators: { - Blitter: __webpack_require__(872), - Container: __webpack_require__(871), - DynamicBitmapText: __webpack_require__(870), - Graphics: __webpack_require__(406), - Group: __webpack_require__(869), - Image: __webpack_require__(405), - Particles: __webpack_require__(868), - RenderTexture: __webpack_require__(867), - Sprite3D: __webpack_require__(866), - Sprite: __webpack_require__(404), - StaticBitmapText: __webpack_require__(865), - Text: __webpack_require__(403), - TileSprite: __webpack_require__(864), - Zone: __webpack_require__(863) - } - -}; - -if (true) -{ - // WebGL only Game Objects - GameObjects.Mesh = __webpack_require__(145); - GameObjects.Quad = __webpack_require__(232); - - GameObjects.Factories.Mesh = __webpack_require__(859); - GameObjects.Factories.Quad = __webpack_require__(858); - - GameObjects.Creators.Mesh = __webpack_require__(857); - GameObjects.Creators.Quad = __webpack_require__(856); - - GameObjects.Light = __webpack_require__(402); - - __webpack_require__(401); - __webpack_require__(855); -} - -module.exports = GameObjects; - - -/***/ }), -/* 916 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.DOM - */ - -module.exports = { - - AddToDOM: __webpack_require__(130), - DOMContentLoaded: __webpack_require__(271), - ParseXML: __webpack_require__(270), - RemoveFromDOM: __webpack_require__(269), - RequestAnimationFrame: __webpack_require__(268) - -}; - - -/***/ }), -/* 917 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ComponentToHex = __webpack_require__(541); - -/** - * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. - * - * @function Phaser.Display.Color.RGBToString - * @since 3.0.0 - * - * @param {integer} r - The red color value. A number between 0 and 255. - * @param {integer} g - The green color value. A number between 0 and 255. - * @param {integer} b - The blue color value. A number between 0 and 255. - * @param {integer} [a=255] - The alpha value. A number between 0 and 255. - * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. - * - * @return {string} A string-based representation of the color values. - */ -var RGBToString = function (r, g, b, a, prefix) -{ - if (a === undefined) { a = 255; } - if (prefix === undefined) { prefix = '#'; } - - if (prefix === '#') - { - return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); - } - else - { - return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); - } -}; - -module.exports = RGBToString; - - -/***/ }), -/* 918 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} HSLColorObject - * - * @property {number} h - The hue color value. A number between 0 and 1 - * @property {number} s - The saturation color value. A number between 0 and 1 - * @property {number} l - The lightness color value. A number between 0 and 1 - */ - -/** - * Converts an RGB color value to HSV (hue, saturation and value). - * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @function Phaser.Display.Color.RGBToHSV - * @since 3.0.0 - * - * @param {integer} r - The red color value. A number between 0 and 255. - * @param {integer} g - The green color value. A number between 0 and 255. - * @param {integer} b - The blue color value. A number between 0 and 255. - * - * @return {HSLColorObject} An object with the properties `h`, `s` and `v`. - */ -var RGBToHSV = function (r, g, b) -{ - r /= 255; - g /= 255; - b /= 255; - - var min = Math.min(r, g, b); - var max = Math.max(r, g, b); - var d = max - min; - - // achromatic by default - var h = 0; - var s = (max === 0) ? 0 : d / max; - var v = max; - - if (max !== min) - { - if (max === r) - { - h = (g - b) / d + ((g < b) ? 6 : 0); - } - else if (max === g) - { - h = (b - r) / d + 2; - } - else if (max === b) - { - h = (r - g) / d + 4; - } - - h /= 6; - } - - return { h: h, s: s, v: v }; -}; - -module.exports = RGBToHSV; - - -/***/ }), -/* 919 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Between = __webpack_require__(149); -var Color = __webpack_require__(30); - -/** - * Creates a new Color object where the r, g, and b values have been set to random values - * based on the given min max values. - * - * @function Phaser.Display.Color.RandomRGB - * @since 3.0.0 - * - * @param {integer} [min=0] - The minimum value to set the random range from (between 0 and 255) - * @param {integer} [max=255] - The maximum value to set the random range from (between 0 and 255) - * - * @return {Phaser.Display.Color} A Color object. - */ -var RandomRGB = function (min, max) -{ - if (min === undefined) { min = 0; } - if (max === undefined) { max = 255; } - - return new Color(Between(min, max), Between(min, max), Between(min, max)); -}; - -module.exports = RandomRGB; - - -/***/ }), -/* 920 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Linear = __webpack_require__(122); - -/** - * Interpolates color values - * - * @namespace Phaser.Display.Color.Interpolate - * @since 3.0.0 - */ - -/** - * Interpolates between the two given color ranges over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.RGBWithRGB - * @since 3.0.0 - * - * @param {number} r1 - Red value. - * @param {number} g1 - Blue value. - * @param {number} b1 - Green value. - * @param {number} r2 - Red value. - * @param {number} g2 - Blue value. - * @param {number} b2 - Green value. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - var t = index / length; - - return { - r: Linear(r1, r2, t), - g: Linear(g1, g2, t), - b: Linear(b1, b2, t) - }; -}; - -/** - * Interpolates between the two given color objects over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.ColorWithColor - * @since 3.0.0 - * - * @param {Phaser.Display.Color} color1 - The first Color object. - * @param {Phaser.Display.Color} color2 - The second Color object. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var ColorWithColor = function (color1, color2, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); -}; - -/** - * Interpolates between the Color object and color values over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.ColorWithRGB - * @since 3.0.0 - * - * @param {Phaser.Display.Color} color1 - The first Color object. - * @param {number} r - Red value. - * @param {number} g - Blue value. - * @param {number} b - Green value. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var ColorWithRGB = function (color, r, g, b, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); -}; - -module.exports = { - - RGBWithRGB: RGBWithRGB, - ColorWithRGB: ColorWithRGB, - ColorWithColor: ColorWithColor - -}; - - -/***/ }), -/* 921 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HSVToRGB = __webpack_require__(539); - -/** - * Get HSV color wheel values in an array which will be 360 elements in size. - * - * @function Phaser.Display.Color.HSVColorWheel - * @since 3.0.0 - * - * @param {number} [s=1] - The saturation, in the range 0 - 1. - * @param {number} [v=1] - The value, in the range 0 - 1. - * - * @return {ColorObject[]} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel. - */ -var HSVColorWheel = function (s, v) -{ - if (s === undefined) { s = 1; } - if (v === undefined) { v = 1; } - - var colors = []; - - for (var c = 0; c <= 359; c++) - { - colors.push(HSVToRGB(c / 359, s, v)); - } - - return colors; -}; - -module.exports = HSVColorWheel; - - -/***/ }), -/* 922 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); -var HueToComponent = __webpack_require__(540); - -/** - * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. - * - * @function Phaser.Display.Color.HSLToColor - * @since 3.0.0 - * - * @param {number} h - The hue value in the range 0 to 1. - * @param {number} s - The saturation value in the range 0 to 1. - * @param {number} l - The lightness value in the range 0 to 1. - * - * @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values. - */ -var HSLToColor = function (h, s, l) -{ - // achromatic by default - var r = l; - var g = l; - var b = l; - - if (s !== 0) - { - var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; - var p = 2 * l - q; - - r = HueToComponent(p, q, h + 1 / 3); - g = HueToComponent(p, q, h); - b = HueToComponent(p, q, h - 1 / 3); - } - - var color = new Color(); - - return color.setGLTo(r, g, b, 1); -}; - -module.exports = HSLToColor; - - -/***/ }), -/* 923 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts the given color value into an Object containing r,g,b and a properties. - * - * @function Phaser.Display.Color.ColorToRGBA - * @since 3.0.0 - * - * @param {number} color - A color value, optionally including the alpha value. - * - * @return {ColorObject} An object containing the parsed color values. - */ -var ColorToRGBA = function (color) -{ - var output = { - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF, - a: 255 - }; - - if (color > 16777215) - { - output.a = color >>> 24; - } - - return output; -}; - -module.exports = ColorToRGBA; - - -/***/ }), -/* 924 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. - * - * @function Phaser.Display.Canvas.UserSelect - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. - * @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts. - * - * @return {HTMLCanvasElement} The canvas element. - */ -var UserSelect = function (canvas, value) -{ - if (value === undefined) { value = 'none'; } - - var vendors = [ - '-webkit-', - '-khtml-', - '-moz-', - '-ms-', - '' - ]; - - vendors.forEach(function (vendor) - { - canvas.style[vendor + 'user-select'] = value; - }); - - canvas.style['-webkit-touch-callout'] = value; - canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; - - return canvas; -}; - -module.exports = UserSelect; - - -/***/ }), -/* 925 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. - * - * @function Phaser.Display.Canvas.TouchAction - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. - * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. - * - * @return {HTMLCanvasElement} The canvas element. - */ -var TouchAction = function (canvas, value) -{ - if (value === undefined) { value = 'none'; } - - canvas.style['msTouchAction'] = value; - canvas.style['ms-touch-action'] = value; - canvas.style['touch-action'] = value; - - return canvas; -}; - -module.exports = TouchAction; - - -/***/ }), -/* 926 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Canvas - */ - -module.exports = { - - Interpolation: __webpack_require__(272), - Pool: __webpack_require__(22), - Smoothing: __webpack_require__(131), - TouchAction: __webpack_require__(925), - UserSelect: __webpack_require__(924) - -}; - - -/***/ }), -/* 927 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the amount the Game Object is visually offset from its y coordinate. - * This is the same as `width * origin.y`. - * This value will only be > 0 if `origin.y` is not equal to zero. - * - * @function Phaser.Display.Bounds.GetOffsetY - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The vertical offset of the Game Object. - */ -var GetOffsetY = function (gameObject) -{ - return gameObject.height * gameObject.originY; -}; - -module.exports = GetOffsetY; - - -/***/ }), -/* 928 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * origin.x`. - * This value will only be > 0 if `origin.x` is not equal to zero. - * - * @function Phaser.Display.Bounds.GetOffsetX - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The horizontal offset of the Game Object. - */ -var GetOffsetX = function (gameObject) -{ - return gameObject.width * gameObject.originX; -}; - -module.exports = GetOffsetX; - - -/***/ }), -/* 929 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Bounds - */ - -module.exports = { - - CenterOn: __webpack_require__(593), - GetBottom: __webpack_require__(50), - GetCenterX: __webpack_require__(92), - GetCenterY: __webpack_require__(89), - GetLeft: __webpack_require__(48), - GetOffsetX: __webpack_require__(928), - GetOffsetY: __webpack_require__(927), - GetRight: __webpack_require__(46), - GetTop: __webpack_require__(44), - SetBottom: __webpack_require__(49), - SetCenterX: __webpack_require__(91), - SetCenterY: __webpack_require__(90), - SetLeft: __webpack_require__(47), - SetRight: __webpack_require__(45), - SetTop: __webpack_require__(43) - -}; - - -/***/ }), -/* 930 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(46); -var GetTop = __webpack_require__(44); -var SetBottom = __webpack_require__(49); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. - * - * @function Phaser.Display.Align.To.TopRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopRight = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignTo) + offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopRight; - - -/***/ }), -/* 931 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(48); -var GetTop = __webpack_require__(44); -var SetBottom = __webpack_require__(49); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. - * - * @function Phaser.Display.Align.To.TopLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopLeft = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignTo) - offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopLeft; - - -/***/ }), -/* 932 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterX = __webpack_require__(92); -var GetTop = __webpack_require__(44); -var SetBottom = __webpack_require__(49); -var SetCenterX = __webpack_require__(91); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. - * - * @function Phaser.Display.Align.To.TopCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopCenter; - - -/***/ }), -/* 933 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(46); -var GetTop = __webpack_require__(44); -var SetLeft = __webpack_require__(47); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. - * - * @function Phaser.Display.Align.To.RightTop - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightTop = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetTop(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = RightTop; - - -/***/ }), -/* 934 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(89); -var GetRight = __webpack_require__(46); -var SetCenterY = __webpack_require__(90); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. - * - * @function Phaser.Display.Align.To.RightCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = RightCenter; - - -/***/ }), -/* 935 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetRight = __webpack_require__(46); -var SetBottom = __webpack_require__(49); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. - * - * @function Phaser.Display.Align.To.RightBottom - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightBottom = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetBottom(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = RightBottom; - - -/***/ }), -/* 936 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(48); -var GetTop = __webpack_require__(44); -var SetRight = __webpack_require__(45); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. - * - * @function Phaser.Display.Align.To.LeftTop - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftTop = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetTop(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = LeftTop; - - -/***/ }), -/* 937 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(89); -var GetLeft = __webpack_require__(48); -var SetCenterY = __webpack_require__(90); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. - * - * @function Phaser.Display.Align.To.LeftCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = LeftCenter; - - -/***/ }), -/* 938 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetLeft = __webpack_require__(48); -var SetBottom = __webpack_require__(49); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. - * - * @function Phaser.Display.Align.To.LeftBottom - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetBottom(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = LeftBottom; - - -/***/ }), -/* 939 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetRight = __webpack_require__(46); -var SetRight = __webpack_require__(45); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. - * - * @function Phaser.Display.Align.To.BottomRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomRight = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignTo) + offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomRight; - - /***/ }), /* 940 */ /***/ (function(module, exports, __webpack_require__) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetLeft = __webpack_require__(48); -var SetLeft = __webpack_require__(47); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. - * - * @function Phaser.Display.Align.To.BottomLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignTo) - offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomLeft; - - -/***/ }), -/* 941 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetCenterX = __webpack_require__(92); -var SetCenterX = __webpack_require__(91); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. - * - * @function Phaser.Display.Align.To.BottomCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomCenter; - - -/***/ }), -/* 942 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align.To - */ - -module.exports = { - - BottomCenter: __webpack_require__(941), - BottomLeft: __webpack_require__(940), - BottomRight: __webpack_require__(939), - LeftBottom: __webpack_require__(938), - LeftCenter: __webpack_require__(937), - LeftTop: __webpack_require__(936), - RightBottom: __webpack_require__(935), - RightCenter: __webpack_require__(934), - RightTop: __webpack_require__(933), - TopCenter: __webpack_require__(932), - TopLeft: __webpack_require__(931), - TopRight: __webpack_require__(930) - -}; - - -/***/ }), -/* 943 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align.In - */ - -module.exports = { - - BottomCenter: __webpack_require__(597), - BottomLeft: __webpack_require__(596), - BottomRight: __webpack_require__(595), - Center: __webpack_require__(594), - LeftCenter: __webpack_require__(592), - QuickSet: __webpack_require__(598), - RightCenter: __webpack_require__(591), - TopCenter: __webpack_require__(590), - TopLeft: __webpack_require__(589), - TopRight: __webpack_require__(588) - -}; - - -/***/ }), -/* 944 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(299); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser.Display.Align - */ - -var Align = { - - In: __webpack_require__(943), - To: __webpack_require__(942) - -}; - -// Merge in the consts -Align = Extend(false, Align, CONST); - -module.exports = Align; - - -/***/ }), -/* 945 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display - */ - -module.exports = { - - Align: __webpack_require__(944), - Bounds: __webpack_require__(929), - Canvas: __webpack_require__(926), - Color: __webpack_require__(542), - Masks: __webpack_require__(538) - -}; - - -/***/ }), -/* 946 */ -/***/ (function(module, exports, __webpack_require__) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -135475,14 +141619,14 @@ module.exports = { */ var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); +var Vector2 = __webpack_require__(3); /** * @classdesc * [description] * * @class MoveTo - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * @@ -135525,7 +141669,7 @@ var MoveTo = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. @@ -135545,7 +141689,7 @@ var MoveTo = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -135605,7 +141749,7 @@ module.exports = MoveTo; /***/ }), -/* 947 */ +/* 941 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -135617,15 +141761,15 @@ module.exports = MoveTo; // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) var Class = __webpack_require__(0); -var CubicBezierCurve = __webpack_require__(551); -var EllipseCurve = __webpack_require__(549); -var GameObjectFactory = __webpack_require__(11); -var LineCurve = __webpack_require__(548); -var MovePathTo = __webpack_require__(946); -var QuadraticBezierCurve = __webpack_require__(547); -var Rectangle = __webpack_require__(14); -var SplineCurve = __webpack_require__(545); -var Vector2 = __webpack_require__(6); +var CubicBezierCurve = __webpack_require__(355); +var EllipseCurve = __webpack_require__(353); +var GameObjectFactory = __webpack_require__(5); +var LineCurve = __webpack_require__(352); +var MovePathTo = __webpack_require__(940); +var QuadraticBezierCurve = __webpack_require__(351); +var Rectangle = __webpack_require__(9); +var SplineCurve = __webpack_require__(349); +var Vector2 = __webpack_require__(3); /** * @typedef {object} JSONPath @@ -135642,7 +141786,7 @@ var Vector2 = __webpack_require__(6); * [description] * * @class Path - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * @@ -136168,9 +142312,9 @@ var Path = new Class({ * @method Phaser.Curves.Path#getPoints * @since 3.0.0 * - * @param {integer} [divisions=12] - [description] + * @param {integer} [divisions=12] - The number of points to divide the path in to. * - * @return {Phaser.Math.Vector2[]} [description] + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects that containing the points along the Path. */ getPoints: function (divisions) { @@ -136224,7 +142368,7 @@ var Path = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {Phaser.Math.Vector2} [out] - [description] + * @param {Phaser.Math.Vector2} [out] - `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. * * @return {Phaser.Math.Vector2} [description] */ @@ -136431,7 +142575,7 @@ module.exports = Path; /***/ }), -/* 948 */ +/* 942 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -136452,19 +142596,19 @@ module.exports = Path; */ module.exports = { - Path: __webpack_require__(947), + Path: __webpack_require__(941), - CubicBezier: __webpack_require__(551), - Curve: __webpack_require__(86), - Ellipse: __webpack_require__(549), - Line: __webpack_require__(548), - QuadraticBezier: __webpack_require__(547), - Spline: __webpack_require__(545) + CubicBezier: __webpack_require__(355), + Curve: __webpack_require__(70), + Ellipse: __webpack_require__(353), + Line: __webpack_require__(352), + QuadraticBezier: __webpack_require__(351), + Spline: __webpack_require__(349) }; /***/ }), -/* 949 */ +/* 943 */ /***/ (function(module, exports) { /** @@ -136502,7 +142646,7 @@ module.exports = { /***/ }), -/* 950 */ +/* 944 */ /***/ (function(module, exports) { /** @@ -136540,7 +142684,7 @@ module.exports = { /***/ }), -/* 951 */ +/* 945 */ /***/ (function(module, exports) { /** @@ -136578,7 +142722,7 @@ module.exports = { /***/ }), -/* 952 */ +/* 946 */ /***/ (function(module, exports) { /** @@ -136616,7 +142760,7 @@ module.exports = { /***/ }), -/* 953 */ +/* 947 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -136652,17 +142796,17 @@ module.exports = { module.exports = { - ARNE16: __webpack_require__(275), - C64: __webpack_require__(952), - CGA: __webpack_require__(951), - JMP: __webpack_require__(950), - MSX: __webpack_require__(949) + ARNE16: __webpack_require__(356), + C64: __webpack_require__(946), + CGA: __webpack_require__(945), + JMP: __webpack_require__(944), + MSX: __webpack_require__(943) }; /***/ }), -/* 954 */ +/* 948 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -136677,14 +142821,14 @@ module.exports = { module.exports = { - GenerateTexture: __webpack_require__(276), - Palettes: __webpack_require__(953) + GenerateTexture: __webpack_require__(357), + Palettes: __webpack_require__(947) }; /***/ }), -/* 955 */ +/* 949 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -136693,21 +142837,70 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Camera = __webpack_require__(378); var Class = __webpack_require__(0); -var OrthographicCamera = __webpack_require__(553); -var PerspectiveCamera = __webpack_require__(552); -var PluginCache = __webpack_require__(12); +var GetFastValue = __webpack_require__(2); +var PluginCache = __webpack_require__(15); +var RectangleContains = __webpack_require__(39); + +/** + * @typedef {object} InputJSONCameraObject + * + * @property {string} [name=''] - The name of the Camera. + * @property {integer} [x=0] - The horizontal position of the Camera viewport. + * @property {integer} [y=0] - The vertical position of the Camera viewport. + * @property {integer} [width] - The width of the Camera viewport. + * @property {integer} [height] - The height of the Camera viewport. + * @property {number} [zoom=1] - The default zoom level of the Camera. + * @property {number} [rotation=0] - The rotation of the Camera, in radians. + * @property {boolean} [roundPixels=false] - Should the Camera round pixels before rendering? + * @property {number} [scrollX=0] - The horizontal scroll position of the Camera. + * @property {number} [scrollY=0] - The vertical scroll position of the Camera. + * @property {(false|string)} [backgroundColor=false] - A CSS color string controlling the Camera background color. + * @property {?object} [bounds] - Defines the Camera bounds. + * @property {number} [bounds.x=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.y=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.width] - The width of the Camera bounds. + * @property {number} [bounds.height] - The height of the Camera bounds. + */ /** * @classdesc - * [description] + * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. + * + * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed + * in your game config. + * + * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add + * the new Camera in using the `addExisting` method. + * + * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique + * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of + * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore + * Game Objects, make sure it's one of the first 31 created. + * + * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. * * @class CameraManager - * @memberOf Phaser.Cameras.Sprite3D + * @memberof Phaser.Cameras.Scene2D * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. */ var CameraManager = new Class({ @@ -136716,47 +142909,102 @@ var CameraManager = new Class({ function CameraManager (scene) { /** - * [description] + * The Scene that owns the Camera Manager plugin. * - * @name Phaser.Cameras.Sprite3D.CameraManager#scene + * @name Phaser.Cameras.Scene2D.CameraManager#scene * @type {Phaser.Scene} * @since 3.0.0 */ this.scene = scene; /** - * [description] + * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. * - * @name Phaser.Cameras.Sprite3D.CameraManager#systems + * @name Phaser.Cameras.Scene2D.CameraManager#systems * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ this.systems = scene.sys; /** - * An Array of the Camera objects being managed by this Camera Manager. + * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` + * property set to match this value. By default it is set to match the value set in the + * game configuration, but can be changed at any point. Equally, individual cameras can + * also be changed as needed. * - * @name Phaser.Cameras.Sprite3D.CameraManager#cameras - * @type {Phaser.Cameras.Sprite3D.Camera[]} + * @name Phaser.Cameras.Scene2D.CameraManager#roundPixels + * @type {boolean} + * @since 3.11.0 + */ + this.roundPixels = scene.sys.game.config.roundPixels; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * The Cameras are updated and rendered in the same order in which they appear in this array. + * Do not directly add or remove entries to this array. However, you can move the contents + * around the array should you wish to adjust the display order. + * + * @name Phaser.Cameras.Scene2D.CameraManager#cameras + * @type {Phaser.Cameras.Scene2D.Camera[]} * @since 3.0.0 */ this.cameras = []; + /** + * A handy reference to the 'main' camera. By default this is the first Camera the + * Camera Manager creates. You can also set it directly, or use the `makeMain` argument + * in the `add` and `addExisting` methods. It allows you to access it from your game: + * + * ```javascript + * var cam = this.cameras.main; + * ``` + * + * Also see the properties `camera1`, `camera2` and so on. + * + * @name Phaser.Cameras.Scene2D.CameraManager#main + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.0.0 + */ + this.main; + + /** + * This scale affects all cameras. It's used by the Scale Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#baseScale + * @type {number} + * @since 3.0.0 + */ + this.baseScale = 1; + scene.sys.events.once('boot', this.boot, this); scene.sys.events.on('start', this.start, this); }, - /** * This method is called automatically, only once, when the Scene is first created. * Do not invoke it directly. * - * @method Phaser.Cameras.Scene3D.CameraManager#boot + * @method Phaser.Cameras.Scene2D.CameraManager#boot * @private * @since 3.5.1 */ boot: function () { + 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]; + this.systems.events.once('destroy', this.destroy, this); }, @@ -136765,12 +143013,30 @@ var CameraManager = new Class({ * It is responsible for creating local systems, properties and listening for Scene events. * Do not invoke it directly. * - * @method Phaser.Cameras.Sprite3D.CameraManager#start + * @method Phaser.Cameras.Scene2D.CameraManager#start * @private * @since 3.5.0 */ start: function () { + if (!this.main) + { + 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 = this.systems.events; eventEmitter.on('update', this.update, this); @@ -136778,91 +143044,279 @@ var CameraManager = new Class({ }, /** - * [description] + * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. + * + * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. + * + * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the + * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, + * pan and zoom. + * + * By default Cameras are transparent and will render anything that they can see based on their `scrollX` + * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. + * + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after creation if required. + * + * See the Camera class documentation for more details. * - * @method Phaser.Cameras.Sprite3D.CameraManager#add + * @method Phaser.Cameras.Scene2D.CameraManager#add * @since 3.0.0 * - * @param {number} [fieldOfView=80] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] + * @param {integer} [x=0] - The horizontal position of the Camera viewport. + * @param {integer} [y=0] - The vertical position of the Camera viewport. + * @param {integer} [width] - The width of the Camera viewport. If not given it'll be the game config size. + * @param {integer} [height] - The height of the Camera viewport. If not given it'll be the game config size. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. + * @param {string} [name=''] - The name of the Camera. * - * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + * @return {Phaser.Cameras.Scene2D.Camera} The newly created Camera. */ - add: function (fieldOfView, width, height) + add: function (x, y, width, height, makeMain, name) { - return this.addPerspectiveCamera(fieldOfView, width, height); - }, + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + if (makeMain === undefined) { makeMain = false; } + if (name === undefined) { name = ''; } - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#addOrthographicCamera - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] - */ - addOrthographicCamera: function (width, height) - { - var config = this.scene.sys.game.config; + var camera = new Camera(x, y, width, height); - if (width === undefined) { width = config.width; } - if (height === undefined) { height = config.height; } + camera.setName(name); + camera.setScene(this.scene); + camera.setRoundPixels(this.roundPixels); - var camera = new OrthographicCamera(this.scene, width, height); + camera.id = this.getNextID(); this.cameras.push(camera); + if (makeMain) + { + this.main = camera; + } + return camera; }, /** - * [description] + * Adds an existing Camera into the Camera Manager. + * + * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after addition if required. + * + * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the + * manager. As long as it doesn't already exist in the manager it will be added then returned. + * + * If this method returns `null` then the Camera already exists in this Camera Manager. * - * @method Phaser.Cameras.Sprite3D.CameraManager#addPerspectiveCamera + * @method Phaser.Cameras.Scene2D.CameraManager#addExisting * @since 3.0.0 * - * @param {number} [fieldOfView=80] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be added to the Camera Manager. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. * - * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + * @return {?Phaser.Cameras.Scene2D.Camera} The Camera that was added to the Camera Manager, or `null` if it couldn't be added. */ - addPerspectiveCamera: function (fieldOfView, width, height) + addExisting: function (camera, makeMain) { - var config = this.scene.sys.game.config; + if (makeMain === undefined) { makeMain = false; } - if (fieldOfView === undefined) { fieldOfView = 80; } - if (width === undefined) { width = config.width; } - if (height === undefined) { height = config.height; } + var index = this.cameras.indexOf(camera); - var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height); + if (index === -1) + { + camera.id = this.getNextID(); - this.cameras.push(camera); + camera.setRoundPixels(this.roundPixels); - return camera; + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + + return camera; + } + + return null; }, /** - * [description] + * Gets the next available Camera ID number. + * + * The Camera Manager supports up to 31 unique cameras, after which the ID returned will always be zero. + * You can create additional cameras beyond 31, but they cannot be used for Game Object exclusion. * - * @method Phaser.Cameras.Sprite3D.CameraManager#getCamera + * @method Phaser.Cameras.Scene2D.CameraManager#getNextID + * @private + * @since 3.11.0 + * + * @return {number} The next available Camera ID, or 0 if they're all already in use. + */ + getNextID: function () + { + var cameras = this.cameras; + + var testID = 1; + + // Find the first free camera ID we can use + + for (var t = 0; t < 32; t++) + { + var found = false; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera && camera.id === testID) + { + found = true; + continue; + } + } + + if (found) + { + testID = testID << 1; + } + else + { + return testID; + } + } + + return 0; + }, + + /** + * Gets the total number of Cameras in this Camera Manager. + * + * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getTotal + * @since 3.11.0 + * + * @param {boolean} [isVisible=false] - Set the `true` to only include visible Cameras in the total. + * + * @return {integer} The total number of Cameras in this Camera Manager. + */ + getTotal: function (isVisible) + { + if (isVisible === undefined) { isVisible = false; } + + var total = 0; + + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (!isVisible || (isVisible && camera.visible)) + { + total++; + } + } + + return total; + }, + + /** + * Populates this Camera Manager based on the given configuration object, or an array of config objects. + * + * See the `InputJSONCameraObject` documentation for details of the object structure. + * + * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON * @since 3.0.0 * - * @param {string} name - [description] + * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - A Camera configuration object, or an array of them, to be added to this Camera Manager. * - * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + * @return {Phaser.Cameras.Scene2D.CameraManager} This Camera Manager instance. + */ + fromJSON: function (config) + { + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var gameWidth = this.scene.sys.game.config.width; + var gameHeight = this.scene.sys.game.config.height; + + for (var i = 0; i < config.length; i++) + { + var cameraConfig = config[i]; + + var x = GetFastValue(cameraConfig, 'x', 0); + var y = GetFastValue(cameraConfig, 'y', 0); + var width = GetFastValue(cameraConfig, 'width', gameWidth); + var height = GetFastValue(cameraConfig, 'height', gameHeight); + + var camera = this.add(x, y, width, height); + + // Direct properties + camera.name = GetFastValue(cameraConfig, 'name', ''); + camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); + camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); + camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); + camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); + camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); + camera.visible = GetFastValue(cameraConfig, 'visible', true); + + // Background Color + + var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); + + if (backgroundColor) + { + camera.setBackgroundColor(backgroundColor); + } + + // Bounds + + var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); + + if (boundsConfig) + { + var bx = GetFastValue(boundsConfig, 'x', 0); + var by = GetFastValue(boundsConfig, 'y', 0); + var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); + var bheight = GetFastValue(boundsConfig, 'height', gameHeight); + + camera.setBounds(bx, by, bwidth, bheight); + } + } + + return this; + }, + + /** + * Gets a Camera based on its name. + * + * Camera names are optional and don't have to be set, so this method is only of any use if you + * have given your Cameras unique names. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCamera + * @since 3.0.0 + * + * @param {string} name - The name of the Camera. + * + * @return {?Phaser.Cameras.Scene2D.Camera} The first Camera with a name matching the given string, otherwise `null`. */ getCamera: function (name) { - for (var i = 0; i < this.cameras.length; i++) + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) { - if (this.cameras[i].name === name) + if (cameras[i].name === name) { - return this.cameras[i]; + return cameras[i]; } } @@ -136870,83 +143324,219 @@ var CameraManager = new Class({ }, /** - * [description] + * Returns an array of all cameras below the given Pointer. + * + * The first camera in the array is the top-most camera in the camera list. * - * @method Phaser.Cameras.Sprite3D.CameraManager#removeCamera + * @method Phaser.Cameras.Scene2D.CameraManager#getCamerasBelowPointer + * @since 3.10.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check against. + * + * @return {Phaser.Cameras.Scene2D.Camera[]} An array of cameras below the Pointer. + */ + getCamerasBelowPointer: function (pointer) + { + var cameras = this.cameras; + + var x = pointer.x; + var y = pointer.y; + + var output = []; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera.visible && camera.inputEnabled && RectangleContains(camera, x, y)) + { + // So the top-most camera is at the top of the search array + output.unshift(camera); + } + } + + return output; + }, + + /** + * Removes the given Camera, or an array of Cameras, from this Camera Manager. + * + * If found in the Camera Manager it will be immediately removed from the local cameras array. + * If also currently the 'main' camera, 'main' will be reset to be camera 0. + * + * The removed Cameras are automatically destroyed if the `runDestroy` argument is `true`, which is the default. + * If you wish to re-use the cameras then set this to `false`, but know that they will retain their references + * and internal data until destroyed or re-added to a Camera Manager. + * + * @method Phaser.Cameras.Scene2D.CameraManager#remove * @since 3.0.0 * - * @param {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} camera - [description] + * @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager. + * @param {boolean} [runDestroy=true] - Automatically call `Camera.destroy` on each Camera removed from this Camera Manager. + * + * @return {integer} The total number of Cameras removed. */ - removeCamera: function (camera) + remove: function (camera, runDestroy) { - var cameraIndex = this.cameras.indexOf(camera); + if (runDestroy === undefined) { runDestroy = true; } - if (cameraIndex !== -1) + if (!Array.isArray(camera)) { - this.cameras.splice(cameraIndex, 1); + camera = [ camera ]; + } + + var total = 0; + var cameras = this.cameras; + + for (var i = 0; i < camera.length; i++) + { + var index = cameras.indexOf(camera[i]); + + if (index !== -1) + { + if (runDestroy) + { + cameras[index].destroy(); + } + + cameras.splice(index, 1); + + total++; + } + } + + if (!this.main && cameras[0]) + { + this.main = cameras[0]; + } + + return total; + }, + + /** + * The internal render method. This is called automatically by the Scene and should not be invoked directly. + * + * It will iterate through all local cameras and render them in turn, as long as they're visible and have + * an alpha level > 0. + * + * @method Phaser.Cameras.Scene2D.CameraManager#render + * @protected + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. + * @param {Phaser.GameObjects.GameObject[]} children - An array of renderable Game Objects. + * @param {number} interpolation - Interpolation value. Reserved for future use. + */ + render: function (renderer, children, interpolation) + { + var scene = this.scene; + var cameras = this.cameras; + var baseScale = this.baseScale; + var resolution = renderer.config.resolution; + + for (var i = 0; i < this.cameras.length; i++) + { + var camera = cameras[i]; + + if (camera.visible && camera.alpha > 0) + { + camera.preRender(baseScale, resolution); + + renderer.render(scene, children, interpolation, camera); + } } }, /** - * [description] + * Resets this Camera Manager. + * + * This will iterate through all current Cameras, destroying them all, then it will reset the + * cameras array, reset the ID counter and create 1 new single camera using the default values. * - * @method Phaser.Cameras.Sprite3D.CameraManager#removeAll + * @method Phaser.Cameras.Scene2D.CameraManager#resetAll * @since 3.0.0 * - * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + * @return {Phaser.Cameras.Scene2D.Camera} The freshly created main Camera. */ - removeAll: function () + resetAll: function () { - while (this.cameras.length > 0) + for (var i = 0; i < this.cameras.length; i++) { - var camera = this.cameras.pop(); - - camera.destroy(); + this.cameras[i].destroy(); } + this.cameras = []; + + this.main = this.add(); + return this.main; }, /** - * [description] + * The main update loop. Called automatically when the Scene steps. * - * @method Phaser.Cameras.Sprite3D.CameraManager#update + * @method Phaser.Cameras.Scene2D.CameraManager#update + * @protected * @since 3.0.0 * - * @param {number} timestep - [description] - * @param {number} delta - [description] + * @param {number} timestep - The timestep value. + * @param {number} delta - The delta value since the last frame. */ update: function (timestep, delta) { - for (var i = 0, l = this.cameras.length; i < l; ++i) + for (var i = 0; i < this.cameras.length; i++) { this.cameras[i].update(timestep, delta); } }, + /** + * Resizes all cameras to the given dimensions. + * + * @method Phaser.Cameras.Scene2D.CameraManager#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the camera. + * @param {number} height - The new height of the camera. + */ + resize: function (width, height) + { + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].setSize(width, height); + } + }, + /** * 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 + * @method Phaser.Cameras.Scene2D.CameraManager#shutdown * @private * @since 3.0.0 */ shutdown: function () { + this.main = undefined; + + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].destroy(); + } + + this.cameras = []; + var eventEmitter = this.systems.events; eventEmitter.off('update', this.update, this); eventEmitter.off('shutdown', this.shutdown, this); - - this.removeAll(); }, /** * 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 + * @method Phaser.Cameras.Scene2D.CameraManager#destroy * @private * @since 3.0.0 */ @@ -136962,13 +143552,2991 @@ var CameraManager = new Class({ }); -PluginCache.register('CameraManager3D', CameraManager, 'cameras3d'); +PluginCache.register('CameraManager', CameraManager, 'cameras'); module.exports = CameraManager; +/***/ }), +/* 950 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var EaseMap = __webpack_require__(174); + +/** + * @classdesc + * A Camera Zoom effect. + * + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * 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 Zoom + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.11.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Zoom = new Class({ + + initialize: + + function Zoom (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.11.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.11.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#duration + * @type {integer} + * @readonly + * @default 0 + * @since 3.11.0 + */ + this.duration = 0; + + /** + * The starting zoom value; + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#source + * @type {number} + * @since 3.11.0 + */ + this.source = 1; + + /** + * The destination zoom value. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#destination + * @type {number} + * @since 3.11.0 + */ + this.destination = 1; + + /** + * The ease function to use during the zoom. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#ease + * @type {function} + * @since 3.11.0 + */ + this.ease; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#progress + * @type {number} + * @since 3.11.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_elapsed + * @type {number} + * @private + * @since 3.11.0 + */ + this._elapsed = 0; + + /** + * @callback CameraZoomCallback + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. + * @param {number} progress - The progress of the effect. A value between 0 and 1. + * @param {number} zoom - The Camera's new zoom value. + */ + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdate + * @type {?CameraZoomCallback} + * @private + * @default null + * @since 3.11.0 + */ + this._onUpdate; + + /** + * On Complete callback scope. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdateScope + * @type {any} + * @private + * @since 3.11.0 + */ + this._onUpdateScope; + }, + + /** + * This event is fired when the Zoom effect begins to run on a camera. + * + * @event CameraZoomStartEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. + * @param {integer} duration - The duration of the effect. + * @param {number} zoom - The destination zoom value. + */ + + /** + * This event is fired when the Zoom effect completes. + * + * @event CameraZoomCompleteEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. + */ + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#start + * @fires CameraZoomStartEvent + * @fires CameraZoomCompleteEvent + * @since 3.11.0 + * + * @param {number} zoom - The target Camera zoom value. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the Zoom. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraZoomCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * and the current camera zoom value. + * @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 (zoom, duration, ease, force, callback, context) + { + if (duration === undefined) { duration = 1000; } + if (ease === undefined) { ease = EaseMap.Linear; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + var cam = this.camera; + + if (!force && this.isRunning) + { + return cam; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + // Starting from + this.source = cam.zoom; + + // Zooming to + this.destination = zoom; + + // Using this ease + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + this.ease = EaseMap[ease]; + } + else if (typeof ease === 'function') + { + this.ease = ease; + } + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit('camerazoomstart', this.camera, this, duration, zoom); + + return cam; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#update + * @since 3.11.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._elapsed < this.duration) + { + this.camera.zoom = this.source + ((this.destination - this.source) * this.ease(this.progress)); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.camera.zoom); + } + } + else + { + this.camera.zoom = this.destination; + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.destination); + } + + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#effectComplete + * @since 3.11.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit('camerazoomcomplete', 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.Zoom#reset + * @since 3.11.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.Zoom#destroy + * @since 3.11.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + } + +}); + +module.exports = Zoom; + + +/***/ }), +/* 951 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @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 {number} + * @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 {number} 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 {number} 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._cw; + var height = this.camera._ch; + 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; + + +/***/ }), +/* 952 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Stepped easing. + * + * @function Phaser.Math.Easing.Stepped.Stepped + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [steps=1] - The number of steps in the ease. + * + * @return {number} The tweened value. + */ +var Stepped = function (v, steps) +{ + if (steps === undefined) { steps = 1; } + + if (v <= 0) + { + return 0; + } + else if (v >= 1) + { + return 1; + } + else + { + return (((steps * v) | 0) + 1) * (1 / steps); + } +}; + +module.exports = Stepped; + + +/***/ }), +/* 953 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sinusoidal ease-in/out. + * + * @function Phaser.Math.Easing.Sine.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 0.5 * (1 - Math.cos(Math.PI * v)); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 954 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sinusoidal ease-out. + * + * @function Phaser.Math.Easing.Sine.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return Math.sin(v * Math.PI / 2); + } +}; + +module.exports = Out; + + +/***/ }), +/* 955 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sinusoidal ease-in. + * + * @function Phaser.Math.Easing.Sine.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 1 - Math.cos(v * Math.PI / 2); + } +}; + +module.exports = In; + + /***/ }), /* 956 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quintic ease-in/out. + * + * @function Phaser.Math.Easing.Quintic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v * v * v + 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 957 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quintic ease-out. + * + * @function Phaser.Math.Easing.Quintic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return --v * v * v * v * v + 1; +}; + +module.exports = Out; + + +/***/ }), +/* 958 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quintic ease-in. + * + * @function Phaser.Math.Easing.Quintic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v * v * v * v; +}; + +module.exports = In; + + +/***/ }), +/* 959 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quartic ease-in/out. + * + * @function Phaser.Math.Easing.Quartic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v * v * v; + } + else + { + return -0.5 * ((v -= 2) * v * v * v - 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 960 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quartic ease-out. + * + * @function Phaser.Math.Easing.Quartic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return 1 - (--v * v * v * v); +}; + +module.exports = Out; + + +/***/ }), +/* 961 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quartic ease-in. + * + * @function Phaser.Math.Easing.Quartic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v * v * v; +}; + +module.exports = In; + + +/***/ }), +/* 962 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quadratic ease-in/out. + * + * @function Phaser.Math.Easing.Quadratic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v; + } + else + { + return -0.5 * (--v * (v - 2) - 1); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 963 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quadratic ease-out. + * + * @function Phaser.Math.Easing.Quadratic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return v * (2 - v); +}; + +module.exports = Out; + + +/***/ }), +/* 964 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quadratic ease-in. + * + * @function Phaser.Math.Easing.Quadratic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v; +}; + +module.exports = In; + + +/***/ }), +/* 965 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Linear easing (no variation). + * + * @function Phaser.Math.Easing.Linear.Linear + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Linear = function (v) +{ + return v; +}; + +module.exports = Linear; + + +/***/ }), +/* 966 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Exponential ease-in/out. + * + * @function Phaser.Math.Easing.Expo.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * Math.pow(2, 10 * (v - 1)); + } + else + { + return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 967 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Exponential ease-out. + * + * @function Phaser.Math.Easing.Expo.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return 1 - Math.pow(2, -10 * v); +}; + +module.exports = Out; + + +/***/ }), +/* 968 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Exponential ease-in. + * + * @function Phaser.Math.Easing.Expo.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return Math.pow(2, 10 * (v - 1)) - 0.001; +}; + +module.exports = In; + + +/***/ }), +/* 969 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Elastic ease-in/out. + * + * @function Phaser.Math.Easing.Elastic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] + * + * @return {number} The tweened value. + */ +var InOut = function (v, amplitude, period) +{ + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } + + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; + + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + if ((v *= 2) < 1) + { + return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } + else + { + return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; + } + } +}; + +module.exports = InOut; + + +/***/ }), +/* 970 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Elastic ease-out. + * + * @function Phaser.Math.Easing.Elastic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] + * + * @return {number} The tweened value. + */ +var Out = function (v, amplitude, period) +{ + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } + + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; + + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); + } +}; + +module.exports = Out; + + +/***/ }), +/* 971 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Elastic ease-in. + * + * @function Phaser.Math.Easing.Elastic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] + * + * @return {number} The tweened value. + */ +var In = function (v, amplitude, period) +{ + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } + + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; + + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } +}; + +module.exports = In; + + +/***/ }), +/* 972 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Cubic ease-in/out. + * + * @function Phaser.Math.Easing.Cubic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v + 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 973 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Cubic ease-out. + * + * @function Phaser.Math.Easing.Cubic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return --v * v * v + 1; +}; + +module.exports = Out; + + +/***/ }), +/* 974 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Cubic ease-in. + * + * @function Phaser.Math.Easing.Cubic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v * v; +}; + +module.exports = In; + + +/***/ }), +/* 975 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Circular ease-in/out. + * + * @function Phaser.Math.Easing.Circular.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return -0.5 * (Math.sqrt(1 - v * v) - 1); + } + else + { + return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 976 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Circular ease-out. + * + * @function Phaser.Math.Easing.Circular.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return Math.sqrt(1 - (--v * v)); +}; + +module.exports = Out; + + +/***/ }), +/* 977 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Circular ease-in. + * + * @function Phaser.Math.Easing.Circular.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return 1 - Math.sqrt(1 - v * v); +}; + +module.exports = In; + + +/***/ }), +/* 978 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Bounce ease-in/out. + * + * @function Phaser.Math.Easing.Bounce.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + var reverse = false; + + if (v < 0.5) + { + v = 1 - (v * 2); + reverse = true; + } + else + { + v = (v * 2) - 1; + } + + if (v < 1 / 2.75) + { + v = 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } + + if (reverse) + { + return (1 - v) * 0.5; + } + else + { + return v * 0.5 + 0.5; + } +}; + +module.exports = InOut; + + +/***/ }), +/* 979 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Bounce ease-out. + * + * @function Phaser.Math.Easing.Bounce.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + if (v < 1 / 2.75) + { + return 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } +}; + +module.exports = Out; + + +/***/ }), +/* 980 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Bounce ease-in. + * + * @function Phaser.Math.Easing.Bounce.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + v = 1 - v; + + if (v < 1 / 2.75) + { + return 1 - (7.5625 * v * v); + } + else if (v < 2 / 2.75) + { + return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); + } + else if (v < 2.5 / 2.75) + { + return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); + } + else + { + return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); + } +}; + +module.exports = In; + + +/***/ }), +/* 981 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Back ease-in/out. + * + * @function Phaser.Math.Easing.Back.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [overshoot=1.70158] - The overshoot amount. + * + * @return {number} The tweened value. + */ +var InOut = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } + + var s = overshoot * 1.525; + + if ((v *= 2) < 1) + { + return 0.5 * (v * v * ((s + 1) * v - s)); + } + else + { + return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 982 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Back ease-out. + * + * @function Phaser.Math.Easing.Back.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [overshoot=1.70158] - The overshoot amount. + * + * @return {number} The tweened value. + */ +var Out = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } + + return --v * v * ((overshoot + 1) * v + overshoot) + 1; +}; + +module.exports = Out; + + +/***/ }), +/* 983 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Back ease-in. + * + * @function Phaser.Math.Easing.Back.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [overshoot=1.70158] - The overshoot amount. + * + * @return {number} The tweened value. + */ +var In = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } + + return v * v * ((overshoot + 1) * v - overshoot); +}; + +module.exports = In; + + +/***/ }), +/* 984 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); +var EaseMap = __webpack_require__(174); + +/** + * @classdesc + * A Camera Pan effect. + * + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * Only the camera scroll 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 Pan + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.11.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Pan = new Class({ + + initialize: + + function Pan (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.11.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.11.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#duration + * @type {integer} + * @readonly + * @default 0 + * @since 3.11.0 + */ + this.duration = 0; + + /** + * The starting scroll coordinates to pan the camera from. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#source + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.source = new Vector2(); + + /** + * The constantly updated value based on zoom. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#current + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.current = new Vector2(); + + /** + * The destination scroll coordinates to pan the camera to. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#destination + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.destination = new Vector2(); + + /** + * The ease function to use during the pan. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#ease + * @type {function} + * @since 3.11.0 + */ + this.ease; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#progress + * @type {number} + * @since 3.11.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_elapsed + * @type {number} + * @private + * @since 3.11.0 + */ + this._elapsed = 0; + + /** + * @callback CameraPanCallback + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. + * @param {number} progress - The progress of the effect. A value between 0 and 1. + * @param {number} x - The Camera's new scrollX coordinate. + * @param {number} y - The Camera's new scrollY coordinate. + */ + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdate + * @type {?CameraPanCallback} + * @private + * @default null + * @since 3.11.0 + */ + this._onUpdate; + + /** + * On Complete callback scope. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdateScope + * @type {any} + * @private + * @since 3.11.0 + */ + this._onUpdateScope; + }, + + /** + * This event is fired when the pan effect begins to run on a camera. + * + * @event CameraPanStartEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. + * @param {integer} duration - The duration of the effect. + * @param {number} x - The destination scroll x coordinate. + * @param {number} y - The destination scroll y coordinate. + */ + + /** + * This event is fired when the pan effect completes. + * + * @event CameraPanCompleteEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. + */ + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#start + * @fires CameraPanStartEvent + * @fires CameraPanCompleteEvent + * @since 3.11.0 + * + * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. + * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @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 (x, y, duration, ease, force, callback, context) + { + if (duration === undefined) { duration = 1000; } + if (ease === undefined) { ease = EaseMap.Linear; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + var cam = this.camera; + + if (!force && this.isRunning) + { + return cam; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + // Starting from + this.source.set(cam.scrollX, cam.scrollY); + + // Destination + this.destination.set(x, y); + + // Zoom factored version + cam.getScroll(x, y, this.current); + + // Using this ease + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + this.ease = EaseMap[ease]; + } + else if (typeof ease === 'function') + { + this.ease = ease; + } + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit('camerapanstart', this.camera, this, duration, x, y); + + return cam; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#update + * @since 3.11.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; + + var progress = Clamp(this._elapsed / this.duration, 0, 1); + + this.progress = progress; + + var cam = this.camera; + + if (this._elapsed < this.duration) + { + var v = this.ease(progress); + + cam.getScroll(this.destination.x, this.destination.y, this.current); + + var x = this.source.x + ((this.current.x - this.source.x) * v); + var y = this.source.y + ((this.current.y - this.source.y) * v); + + cam.setScroll(x, y); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, x, y); + } + } + else + { + cam.centerOn(this.destination.x, this.destination.y); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, cam.scrollX, cam.scrollY); + } + + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#effectComplete + * @since 3.11.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit('camerapancomplete', 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.Pan#reset + * @since 3.11.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.Pan#destroy + * @since 3.11.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + this.source = null; + this.destination = null; + } + +}); + +module.exports = Pan; + + +/***/ }), +/* 985 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); + +/** + * @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 {number} + * @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 {number} + * @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 {number} 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._cx, camera._cy, camera._cw, camera._ch); + + return true; + }, + + /** + * Called internally by the WebGL Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderWebGL + * @since 3.5.0 + * + * @param {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} 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.drawFillRect( + camera._cx, camera._cy, camera._cw, camera._ch, + getTintFunction(red, green, blue, 1), + this.alpha + ); + + 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; + + +/***/ }), +/* 986 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); + +/** + * @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 {number} + * @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 {number} + * @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 {number} 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._cx, camera._cy, camera._cw, camera._ch); + + return true; + }, + + /** + * Called internally by the WebGL Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderWebGL + * @since 3.5.0 + * + * @param {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} 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.drawFillRect( + camera._cx, camera._cy, camera._cw, camera._ch, + getTintFunction(red, green, blue, 1), + this.alpha + ); + + 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; + + +/***/ }), +/* 987 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -136978,21 +146546,20 @@ module.exports = CameraManager; */ /** - * @namespace Phaser.Cameras.Sprite3D + * @namespace Phaser.Cameras.Scene2D */ module.exports = { - Camera: __webpack_require__(279), - CameraManager: __webpack_require__(955), - OrthographicCamera: __webpack_require__(553), - PerspectiveCamera: __webpack_require__(552) + Camera: __webpack_require__(378), + CameraManager: __webpack_require__(949), + Effects: __webpack_require__(370) }; /***/ }), -/* 957 */ +/* 988 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -137027,10 +146594,10 @@ var GetValue = __webpack_require__(4); * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. - * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * @property {(float|{x:float,y:float})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. - * @property {(float|{x:float,y:float})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. - * @property {(float|{x:float,y:float})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. + * @property {(number|{x:number,y:number})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. + * @property {(number|{x:number,y:number})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. */ /** @@ -137038,7 +146605,7 @@ var GetValue = __webpack_require__(4); * [description] * * @class SmoothedKeyControl - * @memberOf Phaser.Cameras.Controls + * @memberof Phaser.Cameras.Controls * @constructor * @since 3.0.0 * @@ -137124,7 +146691,7 @@ var SmoothedKeyControl = new Class({ * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed - * @type {float} + * @type {number} * @default 0.01 * @since 3.0.0 */ @@ -137134,7 +146701,7 @@ var SmoothedKeyControl = new Class({ * The horizontal acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -137144,7 +146711,7 @@ var SmoothedKeyControl = new Class({ * The vertical acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -137167,7 +146734,7 @@ var SmoothedKeyControl = new Class({ * The horizontal drag applied to the camera when it is moving. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -137177,7 +146744,7 @@ var SmoothedKeyControl = new Class({ * The vertical drag applied to the camera when it is moving. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -137200,7 +146767,7 @@ var SmoothedKeyControl = new Class({ * The maximum horizontal speed the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -137210,7 +146777,7 @@ var SmoothedKeyControl = new Class({ * The maximum vertical speed the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -137481,7 +147048,7 @@ module.exports = SmoothedKeyControl; /***/ }), -/* 958 */ +/* 989 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -137507,10 +147074,11 @@ var GetValue = __webpack_require__(4); * @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left. * @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right. * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. + * @property {Phaser.Input.Keyboard.Key} [down] - The Key to be pressed that will move the Camera down. * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. - * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * @property {(float|{x:float,y:float})} [speed=0] - The horizontal and vertical speed the camera will move. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [speed=0] - The horizontal and vertical speed the camera will move. */ /** @@ -137518,7 +147086,7 @@ var GetValue = __webpack_require__(4); * [description] * * @class FixedKeyControl - * @memberOf Phaser.Cameras.Controls + * @memberof Phaser.Cameras.Controls * @constructor * @since 3.0.0 * @@ -137604,7 +147172,7 @@ var FixedKeyControl = new Class({ * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. * * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed - * @type {float} + * @type {number} * @default 0.01 * @since 3.0.0 */ @@ -137614,7 +147182,7 @@ var FixedKeyControl = new Class({ * The horizontal speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -137624,7 +147192,7 @@ var FixedKeyControl = new Class({ * The vertical speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -137717,7 +147285,7 @@ var FixedKeyControl = new Class({ * @method Phaser.Cameras.Controls.FixedKeyControl#update * @since 3.0.0 * - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (delta) { @@ -137790,7 +147358,7 @@ module.exports = FixedKeyControl; /***/ }), -/* 959 */ +/* 990 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -137805,14 +147373,14 @@ module.exports = FixedKeyControl; module.exports = { - FixedKeyControl: __webpack_require__(958), - SmoothedKeyControl: __webpack_require__(957) + FixedKeyControl: __webpack_require__(989), + SmoothedKeyControl: __webpack_require__(988) }; /***/ }), -/* 960 */ +/* 991 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -137827,15 +147395,59 @@ module.exports = { module.exports = { - Controls: __webpack_require__(959), - Scene2D: __webpack_require__(566), - Sprite3D: __webpack_require__(956) + Controls: __webpack_require__(990), + Scene2D: __webpack_require__(987) }; /***/ }), -/* 961 */ +/* 992 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cache + */ + +module.exports = { + + BaseCache: __webpack_require__(380), + CacheManager: __webpack_require__(379) + +}; + + +/***/ }), +/* 993 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Animations + */ + +module.exports = { + + Animation: __webpack_require__(384), + AnimationFrame: __webpack_require__(382), + AnimationManager: __webpack_require__(381) + +}; + + +/***/ }), +/* 994 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -137845,7 +147457,7 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Wrap = __webpack_require__(39); +var Wrap = __webpack_require__(53); /** * Wrap each item's coordinates within a rectangle's area. @@ -137884,7 +147496,7 @@ module.exports = WrapInRectangle; /***/ }), -/* 962 */ +/* 995 */ /***/ (function(module, exports) { /** @@ -137894,7 +147506,8 @@ module.exports = WrapInRectangle; */ /** - * [description] + * Takes an array of Game Objects and toggles the visibility of each one. + * Those previously `visible = false` will become `visible = true`, and vice versa. * * @function Phaser.Actions.ToggleVisible * @since 3.0.0 @@ -137919,7 +147532,7 @@ module.exports = ToggleVisible; /***/ }), -/* 963 */ +/* 996 */ /***/ (function(module, exports) { /** @@ -137929,7 +147542,16 @@ module.exports = ToggleVisible; */ /** - * [description] + * Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, the + * calculated spread value. + * + * The spread value is derived from the given `min` and `max` values and the total number of items in the array.//#endregion + * + * For example, to cause an array of Sprites to change in alpha from 0 to 1 you could call: + * + * ```javascript + * Phaser.Actions.Spread(itemsArray, 'alpha', 0, 1); + * ``` * * @function Phaser.Actions.Spread * @since 3.0.0 @@ -137937,12 +147559,12 @@ module.exports = ToggleVisible; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} [inc=false] - [description] + * @param {string} property - The property of the Game Object to spread. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * - * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that were passed to this Action. */ var Spread = function (items, property, min, max, inc) { @@ -137973,7 +147595,7 @@ module.exports = Spread; /***/ }), -/* 964 */ +/* 997 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -137982,10 +147604,12 @@ module.exports = Spread; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathSmoothStep = __webpack_require__(286); +var MathSmoothStep = __webpack_require__(181); /** - * [description] + * Smoothstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * * @function Phaser.Actions.SmoothStep * @since 3.0.0 @@ -137993,10 +147617,10 @@ var MathSmoothStep = __webpack_require__(286); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The minimum interpolation value. + * @param {number} max - The maximum interpolation value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -138029,7 +147653,7 @@ module.exports = SmoothStep; /***/ }), -/* 965 */ +/* 998 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138038,10 +147662,12 @@ module.exports = SmoothStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathSmootherStep = __webpack_require__(287); +var MathSmootherStep = __webpack_require__(182); /** - * [description] + * Smootherstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * * @function Phaser.Actions.SmootherStep * @since 3.0.0 @@ -138049,10 +147675,10 @@ var MathSmootherStep = __webpack_require__(287); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The minimum interpolation value. + * @param {number} max - The maximum interpolation value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -138085,7 +147711,7 @@ module.exports = SmootherStep; /***/ }), -/* 966 */ +/* 999 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138094,7 +147720,7 @@ module.exports = SmootherStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ArrayShuffle = __webpack_require__(95); +var ArrayShuffle = __webpack_require__(122); /** * Shuffles the array in place. The shuffled array is both modified and returned. @@ -138118,7 +147744,7 @@ module.exports = Shuffle; /***/ }), -/* 967 */ +/* 1000 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138127,12 +147753,14 @@ module.exports = Shuffle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Vector2 = __webpack_require__(6); +var Vector2 = __webpack_require__(3); /** - * Iterate through items changing the position of each element to - * be that of the element that came before it in the array (or after it if direction = 1) + * Iterate through the items array changing the position of each element to be that of the element that came before + * it in the array (or after it if direction = 1) + * * The first items position is set to x/y. + * * The final x/y coords are returned * * @function Phaser.Actions.ShiftPosition @@ -138142,10 +147770,10 @@ var Vector2 = __webpack_require__(6); * @generic {Phaser.Math.Vector2} O - [output,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * @param {integer} [direction=0] - [description] - * @param {(Phaser.Math.Vector2|object)} [output] - [description] + * @param {number} x - The x coordinate to place the first item in the array at. + * @param {number} y - The y coordinate to place the first item in the array at. + * @param {integer} [direction=0] - The iteration direction. 0 = first to last and 1 = last to first. + * @param {(Phaser.Math.Vector2|object)} [output] - An optional objec to store the final objects position in. * * @return {Phaser.Math.Vector2} The output vector. */ @@ -138246,7 +147874,7 @@ module.exports = ShiftPosition; /***/ }), -/* 968 */ +/* 1001 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138287,7 +147915,7 @@ module.exports = SetY; /***/ }), -/* 969 */ +/* 1002 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138334,7 +147962,7 @@ module.exports = SetXY; /***/ }), -/* 970 */ +/* 1003 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138375,7 +148003,7 @@ module.exports = SetX; /***/ }), -/* 971 */ +/* 1004 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138413,7 +148041,7 @@ module.exports = SetVisible; /***/ }), -/* 972 */ +/* 1005 */ /***/ (function(module, exports) { /** @@ -138423,7 +148051,7 @@ module.exports = SetVisible; */ /** - * [description] + * Takes an array of Game Objects, or any objects that have the public method setTint() and then updates it to the given value(s). You can specify tint color per corner or provide only one color value for `topLeft` parameter, in which case whole item will be tinted with that color. * * @function Phaser.Actions.SetTint * @since 3.0.0 @@ -138431,10 +148059,10 @@ module.exports = SetVisible; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} topLeft - [description] - * @param {number} [topRight] - [description] - * @param {number} [bottomLeft] - [description] - * @param {number} [bottomRight] - [description] + * @param {number} topLeft - The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. + * @param {number} [topRight] - The tint to be applied to top-right corner of item. + * @param {number} [bottomLeft] - The tint to be applied to the bottom-left corner of item. + * @param {number} [bottomRight] - The tint to be applied to the bottom-right corner of item. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -138452,7 +148080,7 @@ module.exports = SetTint; /***/ }), -/* 973 */ +/* 1006 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138493,7 +148121,7 @@ module.exports = SetScaleY; /***/ }), -/* 974 */ +/* 1007 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138534,7 +148162,7 @@ module.exports = SetScaleX; /***/ }), -/* 975 */ +/* 1008 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138581,7 +148209,7 @@ module.exports = SetScale; /***/ }), -/* 976 */ +/* 1009 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138622,7 +148250,7 @@ module.exports = SetRotation; /***/ }), -/* 977 */ +/* 1010 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138669,7 +148297,7 @@ module.exports = SetOrigin; /***/ }), -/* 978 */ +/* 1011 */ /***/ (function(module, exports) { /** @@ -138679,7 +148307,9 @@ module.exports = SetOrigin; */ /** - * [description] + * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. + * + * @see {@link Phaser.GameObjects.GameObject#setInteractive} * * @function Phaser.Actions.SetHitArea * @since 3.0.0 @@ -138687,8 +148317,8 @@ module.exports = SetOrigin; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {*} hitArea - [description] - * @param {HitAreaCallback} hitAreaCallback - [description] + * @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -138706,7 +148336,7 @@ module.exports = SetHitArea; /***/ }), -/* 979 */ +/* 1012 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138747,7 +148377,7 @@ module.exports = SetDepth; /***/ }), -/* 980 */ +/* 1013 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138787,7 +148417,7 @@ module.exports = SetBlendMode; /***/ }), -/* 981 */ +/* 1014 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138828,7 +148458,7 @@ module.exports = SetAlpha; /***/ }), -/* 982 */ +/* 1015 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138837,7 +148467,7 @@ module.exports = SetAlpha; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `scaleY` property, @@ -138869,7 +148499,7 @@ module.exports = ScaleY; /***/ }), -/* 983 */ +/* 1016 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138878,7 +148508,7 @@ module.exports = ScaleY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, @@ -138916,7 +148546,7 @@ module.exports = ScaleXY; /***/ }), -/* 984 */ +/* 1017 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138925,7 +148555,7 @@ module.exports = ScaleXY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `scaleX` property, @@ -138957,7 +148587,7 @@ module.exports = ScaleX; /***/ }), -/* 985 */ +/* 1018 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -138966,10 +148596,10 @@ module.exports = ScaleX; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathRotateAroundDistance = __webpack_require__(288); +var MathRotateAroundDistance = __webpack_require__(183); /** - * [description] + * Rotates an array of Game Objects around a point by the given angle and distance. * * @function Phaser.Actions.RotateAroundDistance * @since 3.0.0 @@ -139006,7 +148636,7 @@ module.exports = RotateAroundDistance; /***/ }), -/* 986 */ +/* 1019 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139015,8 +148645,8 @@ module.exports = RotateAroundDistance; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateAroundDistance = __webpack_require__(288); -var DistanceBetween = __webpack_require__(58); +var RotateAroundDistance = __webpack_require__(183); +var DistanceBetween = __webpack_require__(52); /** * Rotates each item around the given point by the given angle. @@ -139052,7 +148682,7 @@ module.exports = RotateAround; /***/ }), -/* 987 */ +/* 1020 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139061,7 +148691,7 @@ module.exports = RotateAround; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `rotation` property, @@ -139093,7 +148723,7 @@ module.exports = Rotate; /***/ }), -/* 988 */ +/* 1021 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139102,10 +148732,12 @@ module.exports = Rotate; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(153); +var Random = __webpack_require__(184); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomTriangle * @since 3.0.0 @@ -139113,7 +148745,7 @@ var Random = __webpack_require__(153); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139131,7 +148763,7 @@ module.exports = RandomTriangle; /***/ }), -/* 989 */ +/* 1022 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139140,10 +148772,10 @@ module.exports = RandomTriangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(154); +var Random = __webpack_require__(187); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Ellipse. * * @function Phaser.Actions.RandomRectangle * @since 3.0.0 @@ -139151,7 +148783,7 @@ var Random = __webpack_require__(154); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139169,7 +148801,7 @@ module.exports = RandomRectangle; /***/ }), -/* 990 */ +/* 1023 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139178,10 +148810,12 @@ module.exports = RandomRectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(155); +var Random = __webpack_require__(188); /** - * [description] + * Takes an array of Game Objects and positions them at random locations on the Line. + * + * If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomLine * @since 3.0.0 @@ -139189,7 +148823,7 @@ var Random = __webpack_require__(155); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects randomly on. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139207,7 +148841,7 @@ module.exports = RandomLine; /***/ }), -/* 991 */ +/* 1024 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139216,10 +148850,12 @@ module.exports = RandomLine; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(134); +var Random = __webpack_require__(185); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomEllipse * @since 3.0.0 @@ -139227,7 +148863,7 @@ var Random = __webpack_require__(134); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139245,7 +148881,7 @@ module.exports = RandomEllipse; /***/ }), -/* 992 */ +/* 1025 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139254,10 +148890,12 @@ module.exports = RandomEllipse; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(157); +var Random = __webpack_require__(191); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomCircle * @since 3.0.0 @@ -139265,7 +148903,7 @@ var Random = __webpack_require__(157); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139283,7 +148921,7 @@ module.exports = RandomCircle; /***/ }), -/* 993 */ +/* 1026 */ /***/ (function(module, exports) { /** @@ -139320,7 +148958,7 @@ module.exports = PlayAnimation; /***/ }), -/* 994 */ +/* 1027 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139329,11 +148967,12 @@ module.exports = PlayAnimation; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// var GetPointsOnLine = require('../geom/line/GetPointsOnLine'); -var BresenhamPoints = __webpack_require__(569); +var BresenhamPoints = __webpack_require__(385); /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnTriangle * @since 3.0.0 @@ -139341,8 +148980,8 @@ var BresenhamPoints = __webpack_require__(569); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} [stepRate=1] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects on. + * @param {number} [stepRate=1] - An optional step rate, to increase or decrease the packing of the Game Objects on the lines. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139380,7 +149019,7 @@ module.exports = PlaceOnTriangle; /***/ }), -/* 995 */ +/* 1028 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139389,18 +149028,15 @@ module.exports = PlaceOnTriangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MarchingAnts = __webpack_require__(570); -var RotateLeft = __webpack_require__(290); -var RotateRight = __webpack_require__(289); - -// Place the items in the array around the perimeter of the given rectangle. - -// Placement starts from the top-left of the rectangle, and proceeds in a -// clockwise direction. If the shift parameter is given you can offset where -// placement begins. +var MarchingAnts = __webpack_require__(388); +var RotateLeft = __webpack_require__(387); +var RotateRight = __webpack_require__(386); /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. + * + * Placement starts from the top-left of the rectangle, and proceeds in a clockwise direction. + * If the `shift` parameter is given you can offset where placement begins. * * @function Phaser.Actions.PlaceOnRectangle * @since 3.0.0 @@ -139408,8 +149044,8 @@ var RotateRight = __webpack_require__(289); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {integer} [shift=1] - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects on. + * @param {integer} [shift=1] - An optional positional offset. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139441,7 +149077,7 @@ module.exports = PlaceOnRectangle; /***/ }), -/* 996 */ +/* 1029 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139450,10 +149086,10 @@ module.exports = PlaceOnRectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetPoints = __webpack_require__(156); +var GetPoints = __webpack_require__(189); /** - * [description] + * Positions an array of Game Objects on evenly spaced points of a Line. * * @function Phaser.Actions.PlaceOnLine * @since 3.0.0 @@ -139461,7 +149097,7 @@ var GetPoints = __webpack_require__(156); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects on. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139485,7 +149121,7 @@ module.exports = PlaceOnLine; /***/ }), -/* 997 */ +/* 1030 */ /***/ (function(module, exports) { /** @@ -139495,7 +149131,9 @@ module.exports = PlaceOnLine; */ /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnEllipse * @since 3.0.0 @@ -139503,9 +149141,9 @@ module.exports = PlaceOnLine; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139535,7 +149173,7 @@ module.exports = PlaceOnEllipse; /***/ }), -/* 998 */ +/* 1031 */ /***/ (function(module, exports) { /** @@ -139545,7 +149183,9 @@ module.exports = PlaceOnEllipse; */ /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnCircle * @since 3.0.0 @@ -139553,9 +149193,9 @@ module.exports = PlaceOnEllipse; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -139582,7 +149222,7 @@ module.exports = PlaceOnCircle; /***/ }), -/* 999 */ +/* 1032 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139591,7 +149231,7 @@ module.exports = PlaceOnCircle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `y` property, @@ -139623,7 +149263,7 @@ module.exports = IncY; /***/ }), -/* 1000 */ +/* 1033 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139632,7 +149272,7 @@ module.exports = IncY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, @@ -139670,7 +149310,7 @@ module.exports = IncXY; /***/ }), -/* 1001 */ +/* 1034 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139679,7 +149319,7 @@ module.exports = IncXY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `x` property, @@ -139711,7 +149351,7 @@ module.exports = IncX; /***/ }), -/* 1002 */ +/* 1035 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139720,7 +149360,7 @@ module.exports = IncX; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `alpha` property, @@ -139752,7 +149392,871 @@ module.exports = IncAlpha; /***/ }), -/* 1003 */ +/* 1036 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @function GetColor + * @since 3.0.0 + * @private + */ +var GetColor = function (value) +{ + return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); +}; + +/** + * Provides methods used for setting the tint of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Tint + * @webglOnly + * @since 3.0.0 + */ + +var Tint = { + + /** + * Private internal value. Holds the top-left tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintTL + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintTL: 16777215, + + /** + * Private internal value. Holds the top-right tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintTR + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintTR: 16777215, + + /** + * Private internal value. Holds the bottom-left tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintBL + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintBL: 16777215, + + /** + * Private internal value. Holds the bottom-right tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintBR + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintBR: 16777215, + + /** + * Private internal value. Holds if the Game Object is tinted or not. + * + * @name Phaser.GameObjects.Components.Tint#_isTinted + * @type {boolean} + * @private + * @default false + * @since 3.11.0 + */ + _isTinted: false, + + /** + * Fill or additive? + * + * @name Phaser.GameObjects.Components.Tint#tintFill + * @type {boolean} + * @default false + * @since 3.11.0 + */ + tintFill: false, + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + * + * @method Phaser.GameObjects.Components.Tint#clearTint + * @webglOnly + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearTint: function () + { + this.setTint(0xffffff); + + this._isTinted = false; + + return this; + }, + + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * + * @method Phaser.GameObjects.Components.Tint#setTint + * @webglOnly + * @since 3.0.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTint: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 0xffffff; } + + if (topRight === undefined) + { + topRight = topLeft; + bottomLeft = topLeft; + bottomRight = topLeft; + } + + this._tintTL = GetColor(topLeft); + this._tintTR = GetColor(topRight); + this._tintBL = GetColor(bottomLeft); + this._tintBR = GetColor(bottomRight); + + this._isTinted = true; + + this.tintFill = false; + + return this; + }, + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * + * @method Phaser.GameObjects.Components.Tint#setTintFill + * @webglOnly + * @since 3.11.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTintFill: function (topLeft, topRight, bottomLeft, bottomRight) + { + this.setTint(topLeft, topRight, bottomLeft, bottomRight); + + this.tintFill = true; + + return this; + }, + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopLeft: { + + get: function () + { + return this._tintTL; + }, + + set: function (value) + { + this._tintTL = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopRight: { + + get: function () + { + return this._tintTR; + }, + + set: function (value) + { + this._tintTR = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomLeft: { + + get: function () + { + return this._tintBL; + }, + + set: function (value) + { + this._tintBL = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomRight: { + + get: function () + { + return this._tintBR; + }, + + set: function (value) + { + this._tintBR = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the whole of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tint + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tint: { + + set: function (value) + { + this.setTint(value, value, value, value); + } + }, + + /** + * Does this Game Object have a tint applied to it or not? + * + * @name Phaser.GameObjects.Components.Tint#isTinted + * @type {boolean} + * @webglOnly + * @readonly + * @since 3.11.0 + */ + isTinted: { + + get: function () + { + return this._isTinted; + } + + } + +}; + +module.exports = Tint; + + +/***/ }), +/* 1037 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.TextureCrop + * @since 3.0.0 + */ + +var TextureCrop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.TextureCrop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.TextureCrop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.TextureCrop#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.TextureCrop#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + if (this.isCropped) + { + this.frame.updateCropUVs(this._crop, this.flipX, this.flipY); + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.TextureCrop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = TextureCrop; + + +/***/ }), +/* 1038 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Texture + * @since 3.0.0 + */ + +var Texture = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * Internal flag. Not to be set by this Game Object. + * + * @name Phaser.GameObjects.Components.Texture#isCropped + * @type {boolean} + * @private + * @since 3.11.0 + */ + isCropped: false, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.Texture#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.Texture#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + return this; + } + +}; + +module.exports = Texture; + + +/***/ }), +/* 1039 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the size of a Game Object. + * + * @name Phaser.GameObjects.Components.Size + * @since 3.0.0 + */ + +var Size = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Size#_sizeComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _sizeComponent: true, + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.Size#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.Size#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.frame.realWidth; + }, + + set: function (value) + { + this.scaleX = value / this.frame.realWidth; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.frame.realHeight; + }, + + set: function (value) + { + this.scaleY = value / this.frame.realHeight; + } + + }, + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.Size#setSizeToFrame + * @since 3.0.0 + * + * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. + * + * @return {this} This Game Object instance. + */ + setSizeToFrame: function (frame) + { + if (frame === undefined) { frame = this.frame; } + + this.width = frame.realWidth; + this.height = frame.realHeight; + + return this; + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.Size#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = Size; + + +/***/ }), +/* 1040 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -139761,11 +150265,989 @@ module.exports = IncAlpha; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AlignIn = __webpack_require__(598); -var CONST = __webpack_require__(299); -var GetFastValue = __webpack_require__(1); -var NOOP = __webpack_require__(3); -var Zone = __webpack_require__(158); +var ScaleModes = __webpack_require__(94); + +/** + * Provides methods used for getting and setting the scale of a Game Object. + * + * @name Phaser.GameObjects.Components.ScaleMode + * @since 3.0.0 + */ + +var ScaleMode = { + + _scaleMode: ScaleModes.DEFAULT, + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @name Phaser.GameObjects.Components.ScaleMode#scaleMode + * @type {Phaser.ScaleModes} + * @since 3.0.0 + */ + scaleMode: { + + get: function () + { + return this._scaleMode; + }, + + set: function (value) + { + if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) + { + this._scaleMode = value; + } + } + + }, + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode + * @since 3.0.0 + * + * @param {Phaser.ScaleModes} value - The Scale Mode to be used by this Game Object. + * + * @return {this} This Game Object instance. + */ + setScaleMode: function (value) + { + this.scaleMode = value; + + return this; + } + +}; + +module.exports = ScaleMode; + + +/***/ }), +/* 1041 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the origin of a Game Object. + * Values are normalized, given in the range 0 to 1. + * Display values contain the calculated pixel values. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Origin + * @since 3.0.0 + */ + +var Origin = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Origin#_originComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _originComponent: true, + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originX + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originX: 0.5, + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originY + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originY: 0.5, + + // private + read only + _displayOriginX: 0, + _displayOriginY: 0, + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginX + * @type {number} + * @since 3.0.0 + */ + displayOriginX: { + + get: function () + { + return this._displayOriginX; + }, + + set: function (value) + { + this._displayOriginX = value; + this.originX = value / this.width; + } + + }, + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginY + * @type {number} + * @since 3.0.0 + */ + displayOriginY: { + + get: function () + { + return this._displayOriginY; + }, + + set: function (value) + { + this._displayOriginY = value; + this.originY = value / this.height; + } + + }, + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * + * @method Phaser.GameObjects.Components.Origin#setOrigin + * @since 3.0.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + * + * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + setOriginFromFrame: function () + { + if (!this.frame || !this.frame.customPivot) + { + return this.setOrigin(); + } + else + { + this.originX = this.frame.pivotX; + this.originY = this.frame.pivotY; + } + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * + * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal display origin value. + * @param {number} [y=x] - The vertical display origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setDisplayOrigin: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.displayOriginX = x; + this.displayOriginY = y; + + return this; + }, + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + * + * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + updateDisplayOrigin: function () + { + this._displayOriginX = Math.round(this.originX * this.width); + this._displayOriginY = Math.round(this.originY * this.height); + + return this; + } + +}; + +module.exports = Origin; + + +/***/ }), +/* 1042 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); +var RotateAround = __webpack_require__(396); +var Vector2 = __webpack_require__(3); + +/** + * Provides methods used for obtaining the bounds of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.GetBounds + * @since 3.0.0 + */ + +var GetBounds = { + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getCenter + * @since 3.0.0 + * + * @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. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getCenter: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); + output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); + + return output; + }, + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getTopLeft + * @since 3.0.0 + * + * @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, includeParent) + { + 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); + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getTopRight + * @since 3.0.0 + * + * @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, includeParent) + { + 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); + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft + * @since 3.0.0 + * + * @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, includeParent) + { + 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; + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomRight + * @since 3.0.0 + * + * @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, includeParent) + { + 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; + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * + * @method Phaser.GameObjects.Components.GetBounds#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [output,$return] + * + * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + // We can use the output object to temporarily store the x/y coords in: + + var TLx, TLy, TRx, TRy, BLx, BLy, BRx, BRy; + + // Instead of doing a check if parent container is + // defined per corner we only do it once. + if (this.parentContainer) + { + var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); + + this.getTopLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BRx = output.x; + BRy = output.y; + } + else + { + this.getTopLeft(output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + + BRx = output.x; + BRy = output.y; + } + + output.x = Math.min(TLx, TRx, BLx, BRx); + output.y = Math.min(TLy, TRy, BLy, BRy); + output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; + output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; + + return output; + } + +}; + +module.exports = GetBounds; + + +/***/ }), +/* 1043 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for visually flipping a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Flip + * @since 3.0.0 + */ + +var Flip = { + + /** + * The horizontally flipped state of the Game Object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipX: false, + + /** + * The vertically flipped state of the Game Object. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipY: false, + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipX + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipX: function () + { + this.flipX = !this.flipX; + + return this; + }, + + /** + * Toggles the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipY + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipY: function () + { + this.flipY = !this.flipY; + + return this; + }, + + /** + * Sets the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * + * @method Phaser.GameObjects.Components.Flip#resetFlip + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + } + +}; + +module.exports = Flip; + + +/***/ }), +/* 1044 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Crop + * @since 3.12.0 + */ + +var Crop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.Crop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.Crop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.Crop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = Crop; + + +/***/ }), +/* 1045 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for calculating and setting the size of a non-Frame based Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.ComputedSize + * @since 3.0.0 + */ + +var ComputedSize = { + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.ComputedSize#setSize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = ComputedSize; + + +/***/ }), +/* 1046 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AlignIn = __webpack_require__(416); +var CONST = __webpack_require__(193); +var GetFastValue = __webpack_require__(2); +var NOOP = __webpack_require__(1); +var Zone = __webpack_require__(125); var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1); @@ -139876,7 +151358,7 @@ module.exports = GridAlign; /***/ }), -/* 1004 */ +/* 1047 */ /***/ (function(module, exports) { /** @@ -139934,7 +151416,7 @@ module.exports = GetLast; /***/ }), -/* 1005 */ +/* 1048 */ /***/ (function(module, exports) { /** @@ -139992,7 +151474,7 @@ module.exports = GetFirst; /***/ }), -/* 1006 */ +/* 1049 */ /***/ (function(module, exports) { /** @@ -140004,7 +151486,7 @@ module.exports = GetFirst; /** * @callback CallCallback * - * @param {Phaser.GameObjects.GameObject} item - [description] + * @param {Phaser.GameObjects.GameObject} item - The Game Object to run the callback on. */ /** @@ -140037,7 +151519,7 @@ module.exports = Call; /***/ }), -/* 1007 */ +/* 1050 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -140046,7 +151528,7 @@ module.exports = Call; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `angle` property, @@ -140078,26 +151560,472 @@ module.exports = Angle; /***/ }), -/* 1008 */, -/* 1009 */, -/* 1010 */, -/* 1011 */, -/* 1012 */, -/* 1013 */, -/* 1014 */, -/* 1015 */, -/* 1016 */, -/* 1017 */, -/* 1018 */, -/* 1019 */, -/* 1020 */, -/* 1021 */, -/* 1022 */, -/* 1023 */, -/* 1024 */, -/* 1025 */, -/* 1026 */, -/* 1027 */ +/* 1051 */ +/***/ (function(module, exports) { + +/** +* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 +* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ +* Cameron Foale (http://www.kibibu.com) +*/ +if (typeof window.Uint32Array !== 'function' && typeof window.Uint32Array !== 'object') +{ + var CheapArray = function (fakeType) + { + var proto = new Array(); // jshint ignore:line + + window[fakeType] = function(arg) { + + if (typeof(arg) === 'number') + { + Array.call(this, arg); + + this.length = arg; + + for (var i = 0; i < this.length; i++) + { + this[i] = 0; + } + } + else + { + Array.call(this, arg.length); + + this.length = arg.length; + + for (var i = 0; i < this.length; i++) + { + this[i] = arg[i]; + } + } + }; + + window[fakeType].prototype = proto; + window[fakeType].constructor = window[fakeType]; + }; + + CheapArray('Float32Array'); // jshint ignore:line + CheapArray('Uint32Array'); // jshint ignore:line + CheapArray('Uint16Array'); // jshint ignore:line + CheapArray('Int16Array'); // jshint ignore:line + CheapArray('ArrayBuffer'); // jshint ignore:line +} + + +/***/ }), +/* 1052 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {// References: +// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ +// https://gist.github.com/1579671 +// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision +// https://gist.github.com/timhall/4078614 +// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame + +// Expected to be used with Browserfiy +// Browserify automatically detects the use of `global` and passes the +// correct reference of `global`, `self`, and finally `window` + +// Date.now +if (!(Date.now && Date.prototype.getTime)) { + Date.now = function now() { + return new Date().getTime(); + }; +} + +// performance.now +if (!(global.performance && global.performance.now)) { + var startTime = Date.now(); + if (!global.performance) { + global.performance = {}; + } + global.performance.now = function () { + return Date.now() - startTime; + }; +} + +// requestAnimationFrame +var lastTime = Date.now(); +var vendors = ['ms', 'moz', 'webkit', 'o']; + +for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { + global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; + global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || + global[vendors[x] + 'CancelRequestAnimationFrame']; +} + +if (!global.requestAnimationFrame) { + global.requestAnimationFrame = function (callback) { + if (typeof callback !== 'function') { + throw new TypeError(callback + 'is not a function'); + } + + var currentTime = Date.now(), + delay = 16 + lastTime - currentTime; + + if (delay < 0) { + delay = 0; + } + + lastTime = currentTime; + + return setTimeout(function () { + lastTime = Date.now(); + callback(performance.now()); + }, delay); + }; +} + +if (!global.cancelAnimationFrame) { + global.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(200))) + +/***/ }), +/* 1053 */ +/***/ (function(module, exports) { + +/** + * performance.now + */ +(function () { + + if ('performance' in window === false) + { + window.performance = {}; + } + + // Thanks IE8 + Date.now = (Date.now || function () { + return new Date().getTime(); + }); + + if ('now' in window.performance === false) + { + var nowOffset = Date.now(); + + if (performance.timing && performance.timing.navigationStart) + { + nowOffset = performance.timing.navigationStart; + } + + window.performance.now = function now () + { + return Date.now() - nowOffset; + } + } + +})(); + + +/***/ }), +/* 1054 */ +/***/ (function(module, exports) { + +// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc +if (!Math.trunc) { + Math.trunc = function trunc(x) { + return x < 0 ? Math.ceil(x) : Math.floor(x); + }; +} + + +/***/ }), +/* 1055 */ +/***/ (function(module, exports) { + +/** + * Also fix for the absent console in IE9 + */ +if (!window.console) +{ + window.console = {}; + window.console.log = window.console.assert = function(){}; + window.console.warn = window.console.assert = function(){}; +} + + +/***/ }), +/* 1056 */ +/***/ (function(module, exports) { + +/* Copyright 2013 Chris Wilson + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + +This monkeypatch library is intended to be included in projects that are +written to the proper AudioContext spec (instead of webkitAudioContext), +and that use the new naming and proper bits of the Web Audio API (e.g. +using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may +have to run on systems that only support the deprecated bits. + +This library should be harmless to include if the browser supports +unprefixed "AudioContext", and/or if it supports the new names. + +The patches this library handles: +if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). +if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or +noteGrainOn(), depending on parameters. + +The following aliases only take effect if the new names are not already in place: + +AudioBufferSourceNode.stop() is aliased to noteOff() +AudioContext.createGain() is aliased to createGainNode() +AudioContext.createDelay() is aliased to createDelayNode() +AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() +AudioContext.createPeriodicWave() is aliased to createWaveTable() +OscillatorNode.start() is aliased to noteOn() +OscillatorNode.stop() is aliased to noteOff() +OscillatorNode.setPeriodicWave() is aliased to setWaveTable() +AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() + +This library does NOT patch the enumerated type changes, as it is +recommended in the specification that implementations support both integer +and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel +BiquadFilterNode.type and OscillatorNode.type. + +*/ + +(function () { + + function fixSetTarget(param) { + if (!param) // if NYI, just return + return; + if (!param.setTargetAtTime) + param.setTargetAtTime = param.setTargetValueAtTime; + } + + if (window.hasOwnProperty('webkitAudioContext') && + !window.hasOwnProperty('AudioContext')) { + window.AudioContext = webkitAudioContext; + + if (!AudioContext.prototype.hasOwnProperty('createGain')) + AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; + if (!AudioContext.prototype.hasOwnProperty('createDelay')) + AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; + if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) + AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; + if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) + AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; + + + AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; + AudioContext.prototype.createGain = function() { + var node = this.internal_createGain(); + fixSetTarget(node.gain); + return node; + }; + + AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; + AudioContext.prototype.createDelay = function(maxDelayTime) { + var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); + fixSetTarget(node.delayTime); + return node; + }; + + AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; + AudioContext.prototype.createBufferSource = function() { + var node = this.internal_createBufferSource(); + if (!node.start) { + node.start = function ( when, offset, duration ) { + if ( offset || duration ) + this.noteGrainOn( when || 0, offset, duration ); + else + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function( when, offset, duration ) { + if( typeof duration !== 'undefined' ) + node.internal_start( when || 0, offset, duration ); + else + node.internal_start( when || 0, offset || 0 ); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + fixSetTarget(node.playbackRate); + return node; + }; + + AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; + AudioContext.prototype.createDynamicsCompressor = function() { + var node = this.internal_createDynamicsCompressor(); + fixSetTarget(node.threshold); + fixSetTarget(node.knee); + fixSetTarget(node.ratio); + fixSetTarget(node.reduction); + fixSetTarget(node.attack); + fixSetTarget(node.release); + return node; + }; + + AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; + AudioContext.prototype.createBiquadFilter = function() { + var node = this.internal_createBiquadFilter(); + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + fixSetTarget(node.Q); + fixSetTarget(node.gain); + return node; + }; + + if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { + AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; + AudioContext.prototype.createOscillator = function() { + var node = this.internal_createOscillator(); + if (!node.start) { + node.start = function ( when ) { + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function ( when ) { + node.internal_start( when || 0); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + if (!node.setPeriodicWave) + node.setPeriodicWave = node.setWaveTable; + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + return node; + }; + } + } + + if (window.hasOwnProperty('webkitOfflineAudioContext') && + !window.hasOwnProperty('OfflineAudioContext')) { + window.OfflineAudioContext = webkitOfflineAudioContext; + } + +})(); + + +/***/ }), +/* 1057 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.isArray +*/ +if (!Array.isArray) +{ + Array.isArray = function (arg) + { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; +} + + +/***/ }), +/* 1058 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.forEach +* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach +*/ +if (!Array.prototype.forEach) +{ + Array.prototype.forEach = function (fun /*, thisArg */) + { + 'use strict'; + + if (this === void 0 || this === null) + { + throw new TypeError(); + } + + var t = Object(this); + var len = t.length >>> 0; + + if (typeof fun !== 'function') + { + throw new TypeError(); + } + + var thisArg = arguments.length >= 2 ? arguments[1] : void 0; + + for (var i = 0; i < len; i++) + { + if (i in t) + { + fun.call(thisArg, t[i], i, t); + } + } + }; +} + + +/***/ }), +/* 1059 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(1058); +__webpack_require__(1057); +__webpack_require__(1056); +__webpack_require__(1055); +__webpack_require__(1054); +__webpack_require__(1053); +__webpack_require__(1052); +__webpack_require__(1051); + + +/***/ }), +/* 1060 */, +/* 1061 */, +/* 1062 */, +/* 1063 */, +/* 1064 */, +/* 1065 */, +/* 1066 */, +/* 1067 */, +/* 1068 */, +/* 1069 */, +/* 1070 */, +/* 1071 */, +/* 1072 */, +/* 1073 */, +/* 1074 */, +/* 1075 */, +/* 1076 */, +/* 1077 */, +/* 1078 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {/** @@ -140106,10 +152034,10 @@ module.exports = Angle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -__webpack_require__(609); +__webpack_require__(1059); -var CONST = __webpack_require__(20); -var Extend = __webpack_require__(17); +var CONST = __webpack_require__(26); +var Extend = __webpack_require__(20); /** * @namespace Phaser @@ -140117,36 +152045,36 @@ var Extend = __webpack_require__(17); var Phaser = { - Actions: __webpack_require__(599), - Animation: __webpack_require__(568), - Cache: __webpack_require__(567), - Cameras: __webpack_require__(960), + Actions: __webpack_require__(417), + Animation: __webpack_require__(993), + Cache: __webpack_require__(992), + Cameras: __webpack_require__(991), Class: __webpack_require__(0), - Create: __webpack_require__(954), - Curves: __webpack_require__(948), - Data: __webpack_require__(544), - Display: __webpack_require__(945), - DOM: __webpack_require__(916), - Events: __webpack_require__(536), - Game: __webpack_require__(534), - GameObjects: __webpack_require__(915), - Geom: __webpack_require__(400), - Input: __webpack_require__(383), - Loader: __webpack_require__(759), - Math: __webpack_require__(745), + Create: __webpack_require__(948), + Curves: __webpack_require__(942), + Data: __webpack_require__(939), + Display: __webpack_require__(937), + DOM: __webpack_require__(908), + Events: __webpack_require__(906), + Game: __webpack_require__(904), + GameObjects: __webpack_require__(876), + Geom: __webpack_require__(274), + Input: __webpack_require__(616), + Loader: __webpack_require__(593), + Math: __webpack_require__(570), Physics: { - Arcade: __webpack_require__(703) + Arcade: __webpack_require__(528) }, - Plugins: __webpack_require__(330), - Scene: __webpack_require__(193), - Scenes: __webpack_require__(328), - Sound: __webpack_require__(326), - Structs: __webpack_require__(325), - Textures: __webpack_require__(324), - Tilemaps: __webpack_require__(668), - Time: __webpack_require__(308), - Tweens: __webpack_require__(306), - Utils: __webpack_require__(619) + Plugins: __webpack_require__(498), + Scene: __webpack_require__(328), + Scenes: __webpack_require__(496), + Sound: __webpack_require__(494), + Structs: __webpack_require__(493), + Textures: __webpack_require__(492), + Tilemaps: __webpack_require__(490), + Time: __webpack_require__(441), + Tweens: __webpack_require__(439), + Utils: __webpack_require__(435) }; @@ -140166,7 +152094,7 @@ global.Phaser = Phaser; * -- Dick Brandon */ -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(215))) +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(200))) /***/ }) /******/ ]); diff --git a/dist/phaser-arcade-physics.min.js b/dist/phaser-arcade-physics.min.js index f5e8f0428..785c2b9a2 100644 --- a/dist/phaser-arcade-physics.min.js +++ b/dist/phaser-arcade-physics.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}(window,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1027)}([function(t,e){function i(t,e,i){var n=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&n.value&&"object"==typeof n.value&&(n=n.value),!(!n||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(n))&&(void 0===n.enumerable&&(n.enumerable=!0),void 0===n.configurable&&(n.configurable=!0),n)}function n(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function s(t,e,s,r){for(var a in e)if(e.hasOwnProperty(a)){var h=i(e,a,s);if(!1!==h){if(n((r||t).prototype,a)){if(o.ignoreFinals)continue;throw new Error("cannot override final property '"+a+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,a,h)}else t.prototype[a]=e[a]}}function r(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},transformMat3:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},transformMat4:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[4]*i+n[12],this.y=n[1]*e+n[5]*i+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,e){var i={},n={install:function(t){for(var e in i)t[e]=i[e]},register:function(t,e){i[t]=e},destroy:function(){i={}}};t.exports=n},function(t,e){t.exports=function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0}},function(t,e,i){"use strict";var n=Object.prototype.hasOwnProperty,s="~";function r(){}function o(t,e,i,n,r){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new function(t,e,i){this.fn=t,this.context=e,this.once=i||!1}(i,n||t,r),a=s?s+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],o]:t._events[a].push(o):(t._events[a]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function h(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(s=!1)),h.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)n.call(t,e)&&i.push(s?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},h.prototype.listeners=function(t){var e=s?s+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,r=i.length,o=new Array(r);n=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=u},function(t,e,i){t.exports={Alpha:i(587),Animation:i(302),BlendMode:i(586),ComputedSize:i(585),Depth:i(584),Flip:i(583),GetBounds:i(582),Mask:i(581),MatrixStack:i(580),Origin:i(579),Pipeline:i(291),ScaleMode:i(578),ScrollFactor:i(577),Size:i(576),Texture:i(575),Tint:i(574),ToJSON:i(573),Transform:i(572),TransformMatrix:i(64),Visible:i(571)}},function(t,e,i){var n=i(297),s={PI2:2*Math.PI,TAU:.5*Math.PI,EPSILON:1e-6,DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,RND:new n};t.exports=s},function(t,e,i){var n=i(8),s=function(){var t,e,i,r,o,a,h=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof h&&(c=h,h=arguments[1]||{},u=2),l===u&&(h=this,--u);u=400&&t.status<=599&&(i=!1),this.resetXHR(),this.loader.nextFile(this,i)},onError:function(){this.resetXHR(),this.loader.nextFile(this,!1)},onProgress:function(t){t.lengthComputable&&(this.bytesLoaded=t.loaded,this.bytesTotal=t.total,this.percentComplete=Math.min(this.bytesLoaded/this.bytesTotal,1),this.loader.emit("fileprogress",this,this.percentComplete))},onProcess:function(){this.state=s.FILE_PROCESSING,this.onProcessComplete()},onProcessComplete:function(){this.state=s.FILE_COMPLETE,this.multiFile&&this.multiFile.onFileComplete(this),this.loader.fileProcessComplete(this)},onProcessError:function(){this.state=s.FILE_ERRORED,this.multiFile&&this.multiFile.onFileFailed(this),this.loader.fileProcessComplete(this)},hasCacheConflict:function(){return this.cache&&this.cache.exists(this.key)},addToCache:function(){this.cache&&this.cache.add(this.key,this.data),this.pendingDestroy()},pendingDestroy:function(t){void 0===t&&(t=this.data);var e=this.key,i=this.type;this.loader.emit("filecomplete",e,i,t),this.loader.emit("filecomplete_"+i+"_"+e,e,i,t),this.loader.flagForRemoval(this)},destroy:function(){this.loader=null,this.cache=null,this.xhrSettings=null,this.multiFile=null,this.linkFile=null,this.data=null}});l.createObjectURL=function(t,e,i){if("function"==typeof URL)t.src=URL.createObjectURL(e);else{var n=new FileReader;n.onload=function(){t.removeAttribute("crossOrigin"),t.src="data:"+(e.type||i)+";base64,"+n.result.split(",")[1]},n.onerror=t.onerror,n.readAsDataURL(e)}},l.revokeObjectURL=function(t){"function"==typeof URL&&URL.revokeObjectURL(t.src)},t.exports=l},function(t,e,i){var n={VERSION:"3.10.1",BlendModes:i(51),ScaleModes:i(59),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=n},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=o.width),void 0===s&&(s=o.height);var a=n(r,"isNotEmpty",!1),h=n(r,"isColliding",!1),u=n(r,"hasInterestingFace",!1);t<0&&(i+=t,t=0),e<0&&(s+=e,e=0),t+i>o.width&&(i=Math.max(o.width-t,0)),e+s>o.height&&(s=Math.max(o.height-e,0));for(var l=[],c=e;c=0;o--)t[o][e]=i+a*n,a++;return t}},function(t,e){t.exports={CSV:0,TILED_JSON:1,ARRAY_2D:2,WELTMEISTER:3}},function(t,e){t.exports={getTintFromFloats:function(t,e,i,n){return((255&(255*n|0))<<24|(255&(255*t|0))<<16|(255&(255*e|0))<<8|255&(255*i|0))>>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,n=0;ns||e>=i||i>s||e+i>s){if(n)throw new Error("Range Error: Values outside acceptable range");return!1}return!0}},function(t,e,i){var n=i(0),s=i(152),r=i(284),o=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=255),this.r=0,this.g=0,this.b=0,this.a=255,this.gl=[0,0,0,1],this._color=0,this._color32=0,this._rgba="",this.setTo(t,e,i,n)},transparent:function(){return this.red=0,this.green=0,this.blue=0,this.alpha=0,this.update()},setTo:function(t,e,i,n){return void 0===n&&(n=255),this.red=t,this.green=e,this.blue=i,this.alpha=n,this.update()},setGLTo:function(t,e,i,n){return void 0===n&&(n=1),this.redGL=t,this.greenGL=e,this.blueGL=i,this.alphaGL=n,this.update()},setFromRGB:function(t){return this.red=t.r,this.green=t.g,this.blue=t.b,t.hasOwnProperty("a")&&(this.alpha=t.a),this.update()},update:function(){return this._color=s(this.r,this.g,this.b),this._color32=r(this.r,this.g,this.b,this.a),this._rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/255+")",this},clone:function(){return new o(this.r,this.g,this.b,this.a)},color:{get:function(){return this._color}},color32:{get:function(){return this._color32}},rgba:{get:function(){return this._rgba}},redGL:{get:function(){return this.gl[0]},set:function(t){this.gl[0]=Math.min(Math.abs(t),1),this.r=Math.floor(255*this.gl[0]),this.update()}},greenGL:{get:function(){return this.gl[1]},set:function(t){this.gl[1]=Math.min(Math.abs(t),1),this.g=Math.floor(255*this.gl[1]),this.update()}},blueGL:{get:function(){return this.gl[2]},set:function(t){this.gl[2]=Math.min(Math.abs(t),1),this.b=Math.floor(255*this.gl[2]),this.update()}},alphaGL:{get:function(){return this.gl[3]},set:function(t){this.gl[3]=Math.min(Math.abs(t),1),this.a=Math.floor(255*this.gl[3]),this.update()}},red:{get:function(){return this.r},set:function(t){t=Math.floor(Math.abs(t)),this.r=Math.min(t,255),this.gl[0]=t/255,this.update()}},green:{get:function(){return this.g},set:function(t){t=Math.floor(Math.abs(t)),this.g=Math.min(t,255),this.gl[1]=t/255,this.update()}},blue:{get:function(){return this.b},set:function(t){t=Math.floor(Math.abs(t)),this.b=Math.min(t,255),this.gl[2]=t/255,this.update()}},alpha:{get:function(){return this.a},set:function(t){t=Math.floor(Math.abs(t)),this.a=Math.min(t,255),this.gl[3]=t/255,this.update()}}});t.exports=o},function(t,e){t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i}},function(t,e){t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(556),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Size,s.Texture,s.Tint,s.Transform,s.Visible,o],initialize:function(t,e,i,n,o){r.call(this,t,"Sprite"),this.anims=new s.Animation(this),this.setTexture(n,o),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline")},preUpdate:function(t,e){this.anims.update(t,e)},play:function(t,e,i){return this.anims.play(t,e,i),this},toJSON:function(){return s.ToJSON(this)}});t.exports=a},function(t,e){t.exports=function(t,e,i,n,s,r){var o;void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=s;o=0;o--)t[o][e]+=i+a*n,a++;return t}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n){this.loader=t,this.type=e,this.key=i,this.files=n,this.complete=!1,this.pending=n.length,this.failed=0,this.config={};for(var s=0;s=t.length)){for(var i=t.length-1,n=t[e],s=e;s=0&&m>=0&&v+m<1}},function(t,e){t.exports={CREATED:0,INIT:1,DELAY:2,OFFSET_DELAY:3,PENDING_RENDER:4,PLAYING_FORWARD:5,PLAYING_BACKWARD:6,HOLD_DELAY:7,REPEAT_DELAY:8,COMPLETE:9,PENDING_ADD:20,PAUSED:21,LOOP_DELAY:22,ACTIVE:23,COMPLETE_DELAY:24,PENDING_REMOVE:25,REMOVED:26}},function(t,e){t.exports=function(t,e,i){return t&&t.hasOwnProperty(e)?t[e]:i}},function(t,e,i){var n=i(453);t.exports=function(t,e){if("string"==typeof t&&n.hasOwnProperty(t)){if(e){var i=e.slice(0);return i.unshift(0),function(e){return i[0]=e,n[t].apply(this,i)}}return n[t]}return"function"==typeof t?t:(Array.isArray(t)&&t.length,n.Power0)}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,n,s,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0}},a:{get:function(){return this.matrix[0]},set:function(t){this.matrix[0]=t}},b:{get:function(){return this.matrix[1]},set:function(t){this.matrix[1]=t}},c:{get:function(){return this.matrix[2]},set:function(t){this.matrix[2]=t}},d:{get:function(){return this.matrix[3]},set:function(t){this.matrix[3]=t}},tx:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},ty:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},rotation:{get:function(){return Math.acos(this.a/this.scaleX)*(Math.atan(-this.c/this.a)<0?-1:1)}},scaleX:{get:function(){return Math.sqrt(this.a*this.a+this.c*this.c)}},scaleY:{get:function(){return Math.sqrt(this.b*this.b+this.d*this.d)}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3];return n[0]=s*i+o*e,n[1]=r*i+a*e,n[2]=s*-e+o*i,n[3]=r*-e+a*i,this},multiply:function(t){var e=this.matrix,i=t.matrix,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],u=i[0],l=i[1],c=i[2],d=i[3],f=i[4],p=i[5];return e[0]=u*n+l*r,e[1]=u*s+l*o,e[2]=c*n+d*r,e[3]=c*s+d*o,e[4]=f*n+p*r+a,e[5]=f*s+p*o+h,this},transform:function(t,e,i,n,s,r){var o=this.matrix,a=o[0],h=o[1],u=o[2],l=o[3],c=o[4],d=o[5];return o[0]=t*a+e*u,o[1]=t*h+e*l,o[2]=i*a+n*u,o[3]=i*h+n*l,o[4]=s*a+r*u+c,o[5]=s*h+r*l+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3],h=n[4],u=n[5];return i.x=t*s+e*o+h,i.y=t*r+e*a+u,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=e*s-i*n;return t[0]=s/a,t[1]=-i/a,t[2]=-n/a,t[3]=e/a,t[4]=(n*o-s*r)/a,t[5]=-(e*o-i*r)/a,this},setTransform:function(t,e,i,n,s,r){var o=this.matrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],n=e[1],s=e[2],r=e[3],o=i*i,a=n*n,h=s*s,u=r*r,l=Math.sqrt(o+h),c=Math.sqrt(a+u);return t.translateX=e[4],t.translateY=e[5],t.scaleX=l,t.scaleY=c,t.rotation=Math.acos(i/l)*(Math.atan(-s/i)<0?-1:1),t},applyITRS:function(t,e,i,n,s){var r=this.matrix,o=Math.sin(i),a=Math.cos(i);return r[4]=t,r[5]=e,r[0]=a*n,r[1]=o*n,r[2]=-o*s,r[3]=a*s,this},destroy:function(){this.matrix=null,this.decomposedMatrix=null}});t.exports=n},function(t,e,i){var n=i(23);t.exports=function(t,e,i){return(i-e)*(t=n(t,0,1))}},function(t,e,i){var n=i(0),s=i(15),r=i(389),o=new n({Mixins:[s.Alpha,s.Flip,s.Visible],initialize:function(t,e,i,n,s,r,o,a){this.layer=t,this.index=e,this.x=i,this.y=n,this.width=s,this.height=r,this.baseWidth=void 0!==o?o:s,this.baseHeight=void 0!==a?a:r,this.pixelX=0,this.pixelY=0,this.updatePixelXY(),this.properties={},this.rotation=0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceLeft=!1,this.faceRight=!1,this.faceTop=!1,this.faceBottom=!1,this.collisionCallback=null,this.collisionCallbackContext=this,this.tint=16777215,this.physics={}},containsPoint:function(t,e){return!(tthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldX(this.x,t):this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldY(this.y,t)-(this.height-this.baseHeight)*e.scaleY:this.y*this.baseHeight-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new r),e.x=this.getLeft(),e.y=this.getTop(),e.width=this.getRight()-e.x,e.height=this.getBottom()-e.y,e},getCenterX:function(t){return this.getLeft(t)+this.width/2},getCenterY:function(t){return this.getTop(t)+this.height/2},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},intersects:function(t,e,i,n){return!(i<=this.pixelX||n<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,n,s){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===n&&(n=t),void 0===s&&(s=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=n,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=n,s)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,n){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==n&&(this.baseHeight=n),this.updatePixelXY(),this},updatePixelXY:function(){return this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight-(this.height-this.baseHeight),this},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.tilemapLayer;return t?t.tileset:null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=o},function(t,e){t.exports=function(t,e){e?t.setCollision(!0,!0,!0,!0,!1):t.resetCollision(!1)}},function(t,e,i){var n=i(0),s=i(60),r=i(227),o=i(226),a=i(96),h=i(153),u=new n({initialize:function(t,e,i,n,s,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this.x3=s,this.y3=r},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return h(this,t)},setTo:function(t,e,i,n,s,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this.x3=s,this.y3=r,this},getLineA:function(t){return void 0===t&&(t=new a),t.setTo(this.x1,this.y1,this.x2,this.y2),t},getLineB:function(t){return void 0===t&&(t=new a),t.setTo(this.x2,this.y2,this.x3,this.y3),t},getLineC:function(t){return void 0===t&&(t=new a),t.setTo(this.x3,this.y3,this.x1,this.y1),t},left:{get:function(){return Math.min(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1<=this.x2&&this.x1<=this.x3?this.x1-t:this.x2<=this.x1&&this.x2<=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},right:{get:function(){return Math.max(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1>=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=u},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(461),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Size,s.Texture,s.Tint,s.Transform,s.Visible,o],initialize:function(t,e,i,n,s){r.call(this,t,"Image"),this.setTexture(n,s),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline")}});t.exports=a},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries=[],Array.isArray(t))for(var e=0;e-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new n;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return this.entries.length=t}}});t.exports=n},function(t,e){t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},function(t,e,i){var n=i(100),s=i(10),r=i(62),o=i(63),a=i(73),h=i(163),u=i(102),l=i(4),c=i(101),d=i(99),f=i(98);t.exports=function(t,e,i){void 0===i&&(i=n);for(var p=i.targets?i.targets:u(e),g=h(e),v=a(e,"delay",i.delay),m=a(e,"duration",i.duration),y=l(e,"easeParams",i.easeParams),x=o(l(e,"ease",i.ease),y),w=a(e,"hold",i.hold),b=a(e,"repeat",i.repeat),T=a(e,"repeatDelay",i.repeatDelay),S=r(e,"yoyo",i.yoyo),A=r(e,"flipX",i.flipX),C=r(e,"flipY",i.flipY),M=[],_=0;_=0;i--){var n=this.sounds[i];n.key===t&&(n.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:o,onBlur:o,onFocus:o,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(n,s){n.pendingRemove||t.call(e||i,n,s,i.sounds)})},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("detune",this,t)}}});t.exports=a},function(t,e,i){var n,s=i(57),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(n=navigator.userAgent,/Edge\/\d+/.test(n)?r.edge=!0:/Chrome\/(\d+)/.test(n)&&!s.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(n)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&s.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(n)?r.opera=!0:/Safari/.test(n)&&!s.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(r.silk=!0),r)},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.parent=t,this.events=e,e||(this.events=t.events?t.events:t),this.list={},this.values={},this._frozen=!1,!t.hasOwnProperty("sys")&&this.events&&this.events.once("destroy",this.destroy,this)},get:function(t){var e=this.list;if(Array.isArray(t)){for(var i=[],n=0;nu&&(r=u),o>u&&(o=u),a=s,h=r;;)if(a=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,n=this.program,s=this.renderer,r=this.vertexSize;s.setProgram(n),s.setVertexBuffer(e);for(var o=0;o=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,a.size,a.type,a.normalized,r,a.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,n=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*n)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,n){return this.renderer.setFloat3(this.program,t,e,i,n),this},setFloat4:function(t,e,i,n,s){return this.renderer.setFloat4(this.program,t,e,i,n,s),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,n){return this.renderer.setInt3(this.program,t,e,i,n),this},setInt4:function(t,e,i,n,s){return this.renderer.setInt4(this.program,t,e,i,n,s),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e){t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},function(t,e,i){var n=i(0),s=i(274),r=i(14),o=i(6),a=new n({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var n=Math.max(1,Math.round(i/e));return s(this.getSpacedPoints(n),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],n=this.getPoint(0,this._tmpVec2A),s=0;i.push(0);for(var r=1;r<=t;r++)s+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(n),i.push(s),n.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++){var n=this.getUtoTmapping(i/t,null,t);e.push(this.getPoint(n))}return e},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=t-1e-4,n=t+1e-4;return i<0&&(i=0),n>1&&(n=1),this.getPoint(i,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var n,s=this.getLengths(i),r=0,o=s.length;n=e?Math.min(e,s[o-1]):t*s[o-1];for(var a,h=0,u=o-1;h<=u;)if((a=s[r=Math.floor(h+(u-h)/2)]-n)<0)h=r+1;else{if(!(a>0)){u=r;break}u=r-1}if(s[r=u]===n)return r/(o-1);var l=s[r];return(r+(n-l)/(s[r+1]-l))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i){this.x=0,this.y=0,this.z=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0)},up:function(){return this.x=0,this.y=1,this.z=0,this},clone:function(){return new n(this.x,this.y,this.z)},crossVectors:function(t,e){var i=t.x,n=t.y,s=t.z,r=e.x,o=e.y,a=e.z;return this.x=n*a-s*o,this.y=s*r-i*a,this.z=i*o-n*r,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},set:function(t,e,i){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return Math.sqrt(e*e+i*i+n*n)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return e*e+i*i+n*n},length:function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},lengthSq:function(){var t=this.x,e=this.y,i=this.z;return t*t+e*e+i*i},normalize:function(){var t=this.x,e=this.y,i=this.z,n=t*t+e*e+i*i;return n>0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return this.x=i*o-n*r,this.y=n*s-e*o,this.z=e*r-i*s,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this},transformMat3:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=e*s[0]+i*s[3]+n*s[6],this.y=e*s[1]+i*s[4]+n*s[7],this.z=e*s[2]+i*s[5]+n*s[8],this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12],this.y=s[1]*e+s[5]*i+s[9]*n+s[13],this.z=s[2]*e+s[6]*i+s[10]*n+s[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=e*s[0]+i*s[4]+n*s[8]+s[12],o=e*s[1]+i*s[5]+n*s[9]+s[13],a=e*s[2]+i*s[6]+n*s[10]+s[14],h=e*s[3]+i*s[7]+n*s[11]+s[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,u=a*i+o*e-s*n,l=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+u*-o-l*-r,this.y=u*a+c*-r+l*-s-h*-o,this.z=l*a+c*-o+h*-r-u*-s,this},project:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=s[0],o=s[1],a=s[2],h=s[3],u=s[4],l=s[5],c=s[6],d=s[7],f=s[8],p=s[9],g=s[10],v=s[11],m=s[12],y=s[13],x=s[14],w=1/(e*h+i*d+n*v+s[15]);return this.x=(e*r+i*u+n*f+m)*w,this.y=(e*o+i*l+n*p+y)*w,this.z=(e*a+i*c+n*g+x)*w,this},unproject:function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,o=this.x-i,a=r-this.y-1-n,h=this.z;return this.x=2*o/s-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,e,i){var n=i(0),s=i(32),r=i(298),o=i(296),a=i(157),h=new n({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=h},function(t,e){t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},function(t,e){t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},function(t,e){t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},function(t,e,i){var n=i(147),s=i(0),r=i(3),o=i(83),a=new s({initialize:function(t){this.parent=t,this.list=[],this.position=0,this.addCallback=r,this.removeCallback=r,this._sortKey=""},add:function(t,e){return e?n.Add(this.list,t):n.Add(this.list,t,0,this.addCallback,this)},addAt:function(t,e,i){return i?n.AddAt(this.list,t,e):n.AddAt(this.list,t,e,0,this.addCallback,this)},getAt:function(t){return this.list[t]},getIndex:function(t){return this.list.indexOf(t)},sort:function(t){return t&&(this._sortKey=t,o.inplace(this.list,this.sortHandler)),this},sortHandler:function(t,e){return t[this._sortKey]-e[this._sortKey]},getByName:function(t){return n.GetFirst(this.list,"name",t)},getRandom:function(t,e){return n.GetRandom(this.list,t,e)},getFirst:function(t,e,i,s){return n.GetFirstElement(this.list,t,e,i,s)},getAll:function(t,e,i,s){return n.GetAll(this.list,t,e,i,s)},count:function(t,e){return n.CountAllMatching(this.list,t,e)},swap:function(t,e){n.Swap(this.list,t,e)},moveTo:function(t,e){return n.MoveTo(this.list,t,e)},remove:function(t,e){return e?n.Remove(this.list,t):n.Remove(this.list,t,this.removeCallback,this)},removeAt:function(t,e){return e?n.RemoveAt(this.list,t):n.RemoveAt(this.list,t,this.removeCallback,this)},removeBetween:function(t,e,i){return i?n.RemoveBetween(this.list,t,e):n.RemoveBetween(this.list,t,e,this.removeCallback,this)},removeAll:function(t){for(var e=this.list.length;e--;)this.remove(this.list[e],t);return this},bringToTop:function(t){return n.BringToTop(this.list,t)},sendToBack:function(t){return n.SendToBack(this.list,t)},moveUp:function(t){return n.MoveUp(this.list,t),t},moveDown:function(t){return n.MoveDown(this.list,t),t},reverse:function(){return this.list.reverse(),this},shuffle:function(){return n.Shuffle(this.list),this},replace:function(t,e){return n.Replace(this.list,t,e)},exists:function(t){return this.list.indexOf(t)>-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){for(var i=[null],n=2;n0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=a},function(t,e,i){var n=i(33);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)||(i[s]=e[s]);return i}},function(t,e){t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},function(t,e,i){var n=i(0),s=i(293),r=i(156),o=i(155),a=i(6),h=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n},getPoint:function(t,e){return s(this,t,e)},getPoints:function(t,e,i){return r(this,t,e,i)},getRandomPoint:function(t){return o(this,t)},setTo:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this},getPointA:function(t){return void 0===t&&(t=new a),t.set(this.x1,this.y1),t},getPointB:function(t){return void 0===t&&(t=new a),t.set(this.x2,this.y2),t},left:{get:function(){return Math.min(this.x1,this.x2)},set:function(t){this.x1<=this.x2?this.x1=t:this.x2=t}},right:{get:function(){return Math.max(this.x1,this.x2)},set:function(t){this.x1>this.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=h},function(t,e){t.exports=function(t){return 2*(t.width+t.height)}},function(t,e){t.exports=function(t,e,i,n,s,r,o,a,h,u,l,c,d){return{target:t,key:e,getEndValue:i,getStartValue:n,ease:s,duration:0,totalDuration:0,delay:0,yoyo:a,hold:0,repeat:0,repeatDelay:0,flipX:c,flipY:d,progress:0,elapsed:0,repeatCounter:0,start:0,current:0,end:0,t1:0,t2:0,gen:{delay:r,duration:o,hold:h,repeat:u,repeatDelay:l},state:0}}},function(t,e,i){var n=i(0),s=i(13),r=i(11),o=i(61),a=new n({initialize:function(t,e,i){this.parent=t,this.parentIsTimeline=t.hasOwnProperty("isTimeline"),this.data=e,this.totalData=e.length,this.targets=i,this.totalTargets=i.length,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.offset=0,this.calculatedOffset=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onRepeat:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},getValue:function(){return this.data[0].current},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},isPaused:function(){return this.state===o.PAUSED},hasTarget:function(t){return-1!==this.targets.indexOf(t)},updateTo:function(t,e,i){for(var n=0;n0&&(n.totalDuration+=n.t2*n.repeat),n.totalDuration>t&&(t=n.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},pause:function(){if(this.state!==o.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=o.PAUSED,this},play:function(t){if(this.state!==o.ACTIVE){this.state!==o.PENDING_REMOVE&&this.state!==o.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.ACTIVE):(this.countdown=this.calculatedOffset,this.state=o.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=o.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(n.elapsed=n.delay,n.state=o.DELAY):n.state=o.PENDING_RENDER}},resume:function(){return this.state===o.PAUSED?(this.paused=!1,this.state=this._pausedState):this.play(),this},seek:function(t){for(var e=this.data,i=0;i=s.totalDuration?(r=1,o=s.duration):n>s.delay&&n<=s.t1?(r=(n=Math.max(0,n-s.delay))/s.t1,o=s.duration*r):n>s.t1&&ns.repeatDelay&&(r=n/s.t1,o=s.duration*r)),s.progress=r,s.elapsed=o;var a=s.ease(s.progress);s.current=s.start+(s.end-s.start)*a,s.target[s.key]=s.current}},setCallback:function(t,e,i,n){return this.callbacks[t]={func:e,scope:n,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},stop:function(t){this.state===o.ACTIVE&&void 0!==t&&this.seek(t),this.state!==o.REMOVED&&(this.state=o.PENDING_REMOVE)},update:function(t,e){if(this.state===o.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var i=!1,n=0;n0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case o.PLAYING_FORWARD:case o.PLAYING_BACKWARD:if(!e.target){e.state=o.COMPLETE;break}var n=e.elapsed,s=e.duration,r=0;(n+=i)>s&&(r=n-s,n=s);var a,h=e.state===o.PLAYING_FORWARD,u=n/s;a=h?e.ease(u):e.ease(1-u),e.current=e.start+(e.end-e.start)*a,e.target[e.key]=e.current,e.elapsed=n,e.progress=u;var l=t.callbacks.onUpdate;l&&(l.params[1]=e.target,l.func.apply(l.scope,l.params)),1===u&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=o.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case o.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PENDING_RENDER);break;case o.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PLAYING_FORWARD);break;case o.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case o.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=o.PLAYING_FORWARD):e.state=o.COMPLETE}return e.state!==o.COMPLETE}});a.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),s.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=a},function(t,e){t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1}},function(t,e){function i(t){return!!t.getStart&&"function"==typeof t.getStart}function n(t){return!!t.getEnd&&"function"==typeof t.getEnd}var s=function(t,e){var r,o,a=function(t,e,i){return i},h=function(t,e,i){return i},u=typeof e;if("number"===u)a=function(){return e};else if("string"===u){var l=e[0],c=parseFloat(e.substr(2));switch(l){case"+":a=function(t,e,i){return i+c};break;case"-":a=function(t,e,i){return i-c};break;case"*":a=function(t,e,i){return i*c};break;case"/":a=function(t,e,i){return i/c};break;default:a=function(){return parseFloat(e)}}}else"function"===u?a=e:"object"===u&&(i(o=e)||n(o))?(n(e)&&(a=e.getEnd),i(e)&&(h=e.getStart)):e.hasOwnProperty("value")&&(r=s(t,e.value));return r||(r={getEnd:a,getStart:h}),r};t.exports=s},function(t,e,i){var n=i(4);t.exports=function(t){var e=n(t,"targets",null);return null===e?e:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","map"),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.widthInPixels=s(t,"widthInPixels",this.width*this.tileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.tileHeight),this.format=s(t,"format",null),this.orientation=s(t,"orientation","orthogonal"),this.version=s(t,"version","1"),this.properties=s(t,"properties",{}),this.layers=s(t,"layers",[]),this.images=s(t,"images",[]),this.objects=s(t,"objects",{}),this.collision=s(t,"collision",{}),this.tilesets=s(t,"tilesets",[]),this.imageCollections=s(t,"imageCollections",[]),this.tiles=s(t,"tiles",[])}});t.exports=r},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","layer"),this.x=s(t,"x",0),this.y=s(t,"y",0),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.baseTileWidth=s(t,"baseTileWidth",this.tileWidth),this.baseTileHeight=s(t,"baseTileHeight",this.tileHeight),this.widthInPixels=s(t,"widthInPixels",this.width*this.baseTileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.baseTileHeight),this.alpha=s(t,"alpha",1),this.visible=s(t,"visible",!0),this.properties=s(t,"properties",{}),this.indexes=s(t,"indexes",[]),this.collideIndexes=s(t,"collideIndexes",[]),this.callbacks=s(t,"callbacks",[]),this.bodies=s(t,"bodies",[]),this.data=s(t,"data",[]),this.tilemapLayer=s(t,"tilemapLayer",null)}});t.exports=r},function(t,e){t.exports=function(t,e,i){return t>=0&&t=0&&eu){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=u)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var v=d.substr(g.length);l[c]=v,h+=g}var m=l[c].length?c:c+1,y=l.slice(m).join(" ").replace(/[ \n]*$/gi,"");s[o+1]=y+" "+(s[o+1]||""),r=s.length;break}h+=f,u-=p}n+=h.replace(/[ \n]*$/gi,"")+"\n"}}return n=n.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var n="",s=t.split(this.splitRegExp),r=0;ro?(h>0&&(n+="\n"),n+=a[h]+" ",o=i-u):(o-=l,n+=a[h],h0&&(a+=l.lineSpacing*p),i.rtl?o=d-o:"right"===i.align?o+=l.width-l.lineWidths[p]:"center"===i.align&&(o+=(l.width-l.lineWidths[p])/2),this.autoRound&&(o=Math.round(o),a=Math.round(a)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],o,a)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],o,a));return e.restore(),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this.text,style:this.style.toJSON(),resolution:this.resolution,padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),s.remove(this.canvas)}});t.exports=p},function(t,e){t.exports=function(t,e){return t.hasOwnProperty(e)}},function(t,e,i){var n=i(599),s=i(0),r=i(1),o=i(4),a=i(254),h=i(70),u=i(34),l=new s({initialize:function(t,e,i){void 0!==i||Array.isArray(e)||"object"!=typeof e||(i=e,e=null),this.scene=t,this.children=new h(e),this.isParent=!0,this.classType=r(i,"classType",u),this.active=r(i,"active",!0),this.maxSize=r(i,"maxSize",-1),this.defaultKey=r(i,"defaultKey",null),this.defaultFrame=r(i,"defaultFrame",null),this.runChildUpdate=r(i,"runChildUpdate",!1),this.createCallback=r(i,"createCallback",null),this.removeCallback=r(i,"removeCallback",null),this.createMultipleCallback=r(i,"createMultipleCallback",null),i&&this.createMultiple(i)},create:function(t,e,i,n,s,r){if(void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.defaultKey),void 0===n&&(n=this.defaultFrame),void 0===s&&(s=!0),void 0===r&&(r=!0),this.isFull())return null;var o=new this.classType(this.scene,t,e,i,n);return this.scene.sys.displayList.add(o),o.preUpdate&&this.scene.sys.updateList.add(o),o.visible=s,o.setActive(r),this.add(o),o},createMultiple:function(t){if(this.isFull())return[];if(Array.isArray(t)||(t=[t]),void 0===t[0].key)return[];for(var e=[],i=0;i=0;l--)if((u=d[l]).active===i){if(++c===e)break}else u=null;return u?("number"==typeof s&&(u.x=s),"number"==typeof r&&(u.y=r),u):n?this.create(s,r,o,a,h):null},get:function(t,e,i,n,s){return this.getFirst(!1,!0,t,e,i,n,s)},getFirstAlive:function(t,e,i,n,s,r){return this.getFirst(!0,t,e,i,n,s,r)},getFirstDead:function(t,e,i,n,s,r){return this.getFirst(!1,t,e,i,n,s,r)},playAnimation:function(t,e){return n.PlayAnimation(this.children.entries,t,e),this},isFull:function(){return-1!==this.maxSize&&this.children.size>=this.maxSize},countActive:function(t){void 0===t&&(t=!0);for(var e=0,i=0;i-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var n,s,r=this.scene.sys;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),d.TargetCamera.setViewport(0,0,e,i),d.TargetCamera.scrollX=this.x,d.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var o=(n=r.textures.get(t)).getSourceImage();o instanceof HTMLCanvasElement&&(s=o.getContext("2d"))}else s=(n=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(s=t.getContext("2d"));return s&&(this.renderCanvas(r.game.renderer,this,0,d.TargetCamera,null,s),r.game.renderer.gl&&n&&(n.source[0].glTexture=r.game.renderer.canvasToTexture(s.canvas,n.source[0].glTexture))),this},preDestroy:function(){this.commandBuffer=[]}});d.TargetCamera=new n(0,0,0,0),t.exports=d},function(t,e){t.exports=function(t){if(!Array.isArray(t)||t.length<2||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i0},isTransitionIn:function(){return this.settings.isTransition},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t){return t?this.resume():this.pause()},start:function(t){t&&(this.settings.data=t),this.settings.status=s.START,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this),this.events.emit("ready",this)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(){this.events.off("transitioninit"),this.events.off("transitionstart"),this.events.off("transitioncomplete"),this.events.off("transitionout"),this.settings.status=s.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this)},destroy:function(){this.settings.status=s.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this),this.events.removeAllListeners();for(var t=["scene","game","anims","cache","plugins","registry","sound","textures","add","camera","displayList","events","make","scenePlugin","updateList"],e=0;e-m&&T>-y&&b-m&&A>-y&&Sc&&(this.scrollX=c),this.scrollYd&&(this.scrollY=d)}this.roundPixels&&(this.scrollX=Math.round(this.scrollX),this.scrollY=Math.round(this.scrollY)),r.loadIdentity(),r.scale(e,e),r.translate(this.x+o,this.y+a),r.rotate(this.rotation),r.scale(s,s),r.translate(-o,-a),this.shakeEffect.preRender()},removeBounds:function(){return this.useBounds=!1,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=r(t),this},setLerp:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.lerp.set(t,e),this},setFollowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.followOffset.set(t,e),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=c(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,n){return this._bounds.setTo(t,e,i,n),this.useBounds=!0,this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){return this.scene=t,this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setZoom:function(t){return void 0===t&&(t=1),this.zoom=t,this},setVisible:function(t){return this.visible=t,this},startFollow:function(t,e,i,s,r,o){void 0===e&&(e=!1),void 0===i&&(i=1),void 0===s&&(s=i),void 0===r&&(r=0),void 0===o&&(o=r),this._follow=t,this.roundPixels=e,i=n(i,0,1),s=n(s,0,1),this.lerp.set(i,s),this.followOffset.set(r,o);var a=this.zoom,h=this.width/2,u=this.height/2;return this.scrollX=(t.x-r-h)/a,this.scrollY=(t.y-o-u)/a,this},stopFollow:function(){return this._follow=null,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},resetFX:function(){return this.shakeEffect.reset(),this.flashEffect.reset(),this.fadeEffect.reset(),this},update:function(t,e){this.visible&&(this.shakeEffect.update(t,e),this.flashEffect.update(t,e),this.fadeEffect.update(t,e))},destroy:function(){this.emit("cameradestroy",this),this.removeAllListeners(),this.resetFX(),this.matrix.destroy(),this.culledObjects=[],this._follow=null,this._bounds=null,this.scene=null},centerX:{get:function(){return this.x+.5*this.width}},centerY:{get:function(){return this.y+.5*this.height}}});t.exports=f},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e0?s.delayedPlay(d,r,o):s.load(r)}return t}},function(t,e,i){var n=i(0),s=i(17),r=new n({initialize:function(t,e,i,n,s,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.cutX,this.cutY,this.cutWidth,this.cutHeight,this.x=0,this.y=0,this.width,this.height,this.halfWidth,this.halfHeight,this.centerX,this.centerY,this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.data={cut:{x:0,y:0,w:0,h:0,r:0,b:0},trim:!1,sourceSize:{w:0,h:0},spriteSourceSize:{x:0,y:0,w:0,h:0},uvs:{x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},radius:0,drawImage:{sx:0,sy:0,sWidth:0,sHeight:0,dWidth:0,dHeight:0}},this.setSize(r,o,n,s)},setSize:function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this.cutX=i,this.cutY=n,this.cutWidth=t,this.cutHeight=e,this.width=t,this.height=e,this.halfWidth=Math.floor(.5*t),this.halfHeight=Math.floor(.5*e),this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2);var s=this.data,r=s.cut;r.x=i,r.y=n,r.w=t,r.h=e,r.r=i+t,r.b=n+e,s.sourceSize.w=t,s.sourceSize.h=e,s.spriteSourceSize.w=t,s.spriteSourceSize.h=e,s.radius=.5*Math.sqrt(t*t+e*e);var o=s.drawImage;return o.sx=i,o.sy=n,o.sWidth=t,o.sHeight=e,o.dWidth=t,o.dHeight=e,this.updateUVs()},setTrim:function(t,e,i,n,s,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=n,a.w=s,a.h=r,this.x=i,this.y=n,this.width=s,this.height=r,this.halfWidth=.5*s,this.halfHeight=.5*r,this.centerX=Math.floor(s/2),this.centerY=Math.floor(r/2),this.updateUVs()},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,n=this.cutHeight,s=this.data.drawImage;s.sWidth=i,s.sHeight=n,s.dWidth=i,s.dHeight=n;var r=this.source.width,o=this.source.height,a=this.data.uvs;return a.x0=t/r,a.y0=e/o,a.x1=t/r,a.y1=(e+n)/o,a.x2=(t+i)/r,a.y2=(e+n)/o,a.x3=(t+i)/r,a.y3=e/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height,i=this.data.uvs;return i.x3=(this.cutX+this.cutHeight)/t,i.y3=(this.cutY+this.cutWidth)/e,i.x2=this.cutX/t,i.y2=(this.cutY+this.cutWidth)/e,i.x1=this.cutX/t,i.y1=this.cutY/e,i.x0=(this.cutX+this.cutHeight)/t,i.y0=this.cutY/e,this},clone:function(){var t=new r(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=s(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},uvs:{get:function(){return this.data.uvs}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=r},function(t,e,i){var n=i(0),s=i(202),r=i(526),o=i(525),a=i(27),h=i(84),u=new n({Extends:h,Mixins:[s],initialize:function(t){h.call(this,{game:t.game,renderer:t.renderer,gl:t.renderer.gl,topology:t.topology?t.topology:t.renderer.gl.TRIANGLES,vertShader:t.vertShader?t.vertShader:o,fragShader:t.fragShader?t.fragShader:r,vertexCapacity:t.vertexCapacity?t.vertexCapacity:12e3,vertexSize:t.vertexSize?t.vertexSize:2*Float32Array.BYTES_PER_ELEMENT+2*Float32Array.BYTES_PER_ELEMENT+4*Uint8Array.BYTES_PER_ELEMENT,attributes:[{name:"inPosition",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:0},{name:"inTexCoord",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:2*Float32Array.BYTES_PER_ELEMENT},{name:"inTint",size:4,type:t.renderer.gl.UNSIGNED_BYTE,normalized:!0,offset:4*Float32Array.BYTES_PER_ELEMENT}]}),this.vertexViewF32=new Float32Array(this.vertexData),this.vertexViewU32=new Uint32Array(this.vertexData),this.maxQuads=2e3,this.batches=[],this.mvpInit()},setTexture2D:function(t,e){if(!t)return this;var i=this.batches;0===i.length&&this.pushBatch();var n=i[i.length-1];return e>0?(n.textures[e-1]&&n.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==n.texture&&n.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,n=this.gl,s=this.renderer,r=this.vertexCount,o=this.topology,a=this.vertexSize,h=this.batches,u=0,l=null;if(0===h.length||0===r)return this.flushLocked=!1,this;n.bufferSubData(n.ARRAY_BUFFER,0,this.bytes.subarray(0,r*a));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(s.setTexture2D(l.texture,0),n.drawArrays(o,l.first,u)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},onBind:function(){return h.prototype.onBind.call(this),this.mvpUpdate(),0===this.batches.length&&this.pushBatch(),this},resize:function(t,e,i){return h.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},drawStaticTilemapLayer:function(t){if(t.vertexCount>0){var e=this.vertexBuffer,i=this.gl,n=this.renderer,s=t.tileset.image.get();n.currentPipeline&&n.currentPipeline.vertexCount>0&&n.flush(),this.vertexBuffer=t.vertexBuffer,n.setPipeline(this),n.setTexture2D(s.source.glTexture,0),i.drawArrays(this.topology,0,t.vertexCount),this.vertexBuffer=e}this.viewIdentity(),this.modelIdentity()},drawEmitterManager:function(t,e,i){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this);var s,r,o,a,h,u,l,c,d,f,p=this.renderer.config.roundPixels,g=t.emitters.list,v=g.length,m=this.vertexViewF32,y=this.vertexViewU32,x=this.renderer,w=this.maxQuads,b=e.scrollX,T=e.scrollY,S=e.matrix.matrix,A=S[0],C=S[1],M=S[2],_=S[3],E=S[4],P=S[5],L=Math.sin,F=Math.cos,k=this.vertexComponentCount,R=this.vertexCapacity,O=t.defaultFrame.source.glTexture;n&&(h=n[0],u=n[1],l=n[2],c=n[3],d=n[4],f=n[5]),this.setTexture2D(O,0);for(var D=0;D=R&&(this.flush(),this.setTexture2D(O,0));for(var V=0;V=R&&(this.flush(),this.setTexture2D(O,0))}}z+=H,Y-=H,this.vertexCount>=R&&(this.flush(),this.setTexture2D(O,0))}}}this.setTexture2D(O,0)},drawBlitter:function(t,e,i){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this);var s=this.renderer.config.roundPixels,r=a.getTintAppendFloatAlpha,o=this.vertexViewF32,h=this.vertexViewU32,u=t.getRenderList(),l=u.length,c=e.matrix.matrix,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],m=c[5],y=e.scrollX*t.scrollFactorX,x=e.scrollY*t.scrollFactorY,w=Math.ceil(l/this.maxQuads),b=0;if(n){var T=n[0],S=n[1],A=n[2],C=n[3],M=n[4],_=n[5],E=-y,P=-x,L=A*d+C*p,F=A*f+C*g,k=M*d+_*p+(E*d+P*p+v),R=M*f+_*g+(E*f+P*g+m);d=T*d+S*p,f=T*f+S*g,p=L,g=F,v=k,m=R,y=0,x=0}for(var O,D=t.x-y,I=t.y-x,B=0;B=this.vertexCapacity&&(this.flush(),O=-1)}}b+=Y,l-=Y,this.vertexCount>=this.vertexCapacity&&this.flush()}},batchSprite:function(t,e,i){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var s,r,o,h,u,l,c=this.renderer.config.roundPixels,d=a.getTintAppendFloatAlpha,f=this.vertexViewF32,p=this.vertexViewU32,g=e.matrix.matrix,v=t.frame,m=v.texture.source[v.sourceIndex].glTexture,y=!!m.isRenderTexture,x=t.flipX,w=t.flipY^y,b=v.uvs,T=v.width*(x?-1:1),S=v.height*(w?-1:1),A=-t.displayOriginX+v.x+v.width*(x?1:0),C=-t.displayOriginY+v.y+v.height*(w?1:0),M=(c?0|A:A)+T,_=(c?0|C:C)+S,E=t.scaleX,P=t.scaleY,L=t.rotation,F=t._alphaTL,k=t._alphaTR,R=t._alphaBL,O=t._alphaBR,D=t._tintTL,I=t._tintTR,B=t._tintBL,Y=t._tintBR,X=Math.sin(L),z=Math.cos(L),N=z*E,U=X*E,G=-X*P,W=z*P,V=t.x,H=t.y,j=g[0],q=g[1],K=g[2],J=g[3],Z=g[4],Q=g[5];if(n){var $=n[0],tt=n[1],et=n[2],it=n[3],nt=n[4],st=n[5],rt=-e.scrollX*t.scrollFactorX,ot=-e.scrollY*t.scrollFactorY,at=$*j+tt*K,ht=$*q+tt*J,ut=et*j+it*K,lt=et*q+it*J;s=N*at+U*ut,r=N*ht+U*lt,o=G*at+W*ut,h=G*ht+W*lt,u=V*at+H*ut+(nt*j+st*K+(rt*j+ot*K+Z)),l=V*ht+H*lt+(nt*q+st*J+(rt*q+ot*J+Q))}else s=N*j+U*K,r=N*q+U*J,o=G*j+W*K,h=G*q+W*J,u=(V-=e.scrollX*t.scrollFactorX)*j+(H-=e.scrollY*t.scrollFactorY)*K+Z,l=V*q+H*J+Q;var ct,dt=A*s+C*o+u,ft=A*r+C*h+l,pt=A*s+_*o+u,gt=A*r+_*h+l,vt=M*s+_*o+u,mt=M*r+_*h+l,yt=M*s+C*o+u,xt=M*r+C*h+l,wt=d(D,F),bt=d(I,k),Tt=d(B,R),St=d(Y,O);c&&(dt|=0,ft|=0,pt|=0,gt|=0,vt|=0,mt|=0,yt|=0,xt|=0),this.setTexture2D(m,0),f[(ct=this.vertexCount*this.vertexComponentCount)+0]=dt,f[ct+1]=ft,f[ct+2]=b.x0,f[ct+3]=b.y0,p[ct+4]=wt,f[ct+5]=pt,f[ct+6]=gt,f[ct+7]=b.x1,f[ct+8]=b.y1,p[ct+9]=Tt,f[ct+10]=vt,f[ct+11]=mt,f[ct+12]=b.x2,f[ct+13]=b.y2,p[ct+14]=St,f[ct+15]=dt,f[ct+16]=ft,f[ct+17]=b.x0,f[ct+18]=b.y0,p[ct+19]=wt,f[ct+20]=vt,f[ct+21]=mt,f[ct+22]=b.x2,f[ct+23]=b.y2,p[ct+24]=St,f[ct+25]=yt,f[ct+26]=xt,f[ct+27]=b.x3,f[ct+28]=b.y3,p[ct+29]=bt,this.vertexCount+=6},batchMesh:function(t,e,i){var n=null;i&&(n=i.matrix);var s=t.vertices,r=s.length,o=r/2|0;this.renderer.setPipeline(this),this.vertexCount+o>this.vertexCapacity&&this.flush();var h,u,l,c,d,f,p=this.renderer.config.roundPixels,g=a.getTintAppendFloatAlpha,v=t.uv,m=t.colors,y=t.alphas,x=this.vertexViewF32,w=this.vertexViewU32,b=e.matrix.matrix,T=t.frame,S=t.texture.source[T.sourceIndex].glTexture,A=t.x,C=t.y,M=t.scaleX,_=t.scaleY,E=t.rotation,P=Math.sin(E),L=Math.cos(E),F=L*M,k=P*M,R=-P*_,O=L*_,D=A,I=C,B=b[0],Y=b[1],X=b[2],z=b[3],N=b[4],U=b[5],G=0;if(n){var W=n[0],V=n[1],H=n[2],j=n[3],q=n[4],K=n[5],J=-e.scrollX*t.scrollFactorX,Z=-e.scrollY*t.scrollFactorY,Q=W*B+V*X,$=W*Y+V*z,tt=H*B+j*X,et=H*Y+j*z;h=F*Q+k*tt,u=F*$+k*et,l=R*Q+O*tt,c=R*$+O*et,d=D*Q+I*tt+(q*B+K*X+(J*B+Z*X+N)),f=D*$+I*et+(q*Y+K*z+(J*Y+Z*z+U))}else h=F*B+k*X,u=F*Y+k*z,l=R*B+O*X,c=R*Y+O*z,d=(D-=e.scrollX*t.scrollFactorX)*B+(I-=e.scrollY*t.scrollFactorY)*X+N,f=D*Y+I*z+U;this.setTexture2D(S,0),G=this.vertexCount*this.vertexComponentCount;for(var it=0,nt=0;itthis.vertexCapacity&&this.flush();var s,r,o,h,u,l,c,d,f,p,g,v,m,y,x=this.renderer.config.roundPixels,w=t.text,b=w.length,T=a.getTintAppendFloatAlpha,S=this.vertexViewF32,A=this.vertexViewU32,C=e.matrix.matrix,M=e.width+50,_=e.height+50,E=t.frame,P=t.texture.source[E.sourceIndex],L=e.scrollX*t.scrollFactorX,F=e.scrollY*t.scrollFactorY,k=t.fontData,R=k.lineHeight,O=t.fontSize/k.size,D=k.chars,I=t.alpha,B=T(t._tintTL,I),Y=T(t._tintTR,I),X=T(t._tintBL,I),z=T(t._tintBR,I),N=t.x,U=t.y,G=E.cutX,W=E.cutY,V=P.width,H=P.height,j=P.glTexture,q=0,K=0,J=0,Z=0,Q=null,$=0,tt=0,et=0,it=0,nt=0,st=0,rt=0,ot=0,at=0,ht=0,ut=0,lt=0,ct=null,dt=0,ft=N+E.x,pt=U+E.y,gt=t.rotation,vt=t.scaleX,mt=t.scaleY,yt=t.letterSpacing,xt=Math.sin(gt),wt=Math.cos(gt),bt=wt*vt,Tt=xt*vt,St=-xt*mt,At=wt*mt,Ct=ft,Mt=pt,_t=C[0],Et=C[1],Pt=C[2],Lt=C[3],Ft=C[4],kt=C[5],Rt=0;if(n){var Ot=n[0],Dt=n[1],It=n[2],Bt=n[3],Yt=n[4],Xt=n[5],zt=-L,Nt=-F,Ut=Ot*_t+Dt*Pt,Gt=Ot*Et+Dt*Lt,Wt=It*_t+Bt*Pt,Vt=It*Et+Bt*Lt;f=bt*Ut+Tt*Wt,p=bt*Gt+Tt*Vt,g=St*Ut+At*Wt,v=St*Gt+At*Vt,m=Ct*Ut+Mt*Wt+(Yt*_t+Xt*Pt+(zt*_t+Nt*Pt+Ft)),y=Ct*Gt+Mt*Vt+(Yt*Et+Xt*Lt+(zt*Et+Nt*Lt+kt))}else f=bt*_t+Tt*Pt,p=bt*Et+Tt*Lt,g=St*_t+At*Pt,v=St*Et+At*Lt,m=(Ct-=L)*_t+(Mt-=F)*Pt+Ft,y=Ct*Et+Mt*Lt+kt;this.setTexture2D(j,0);for(var Ht=0;HtM||r<-50||r>_)&&(o<-50||o>M||h<-50||h>_)&&(u<-50||u>M||l<-50||l>_)&&(c<-50||c>M||d<-50||d>_)||(this.vertexCount+6>this.vertexCapacity&&this.flush(),Rt=this.vertexCount*this.vertexComponentCount,x&&(s|=0,r|=0,o|=0,h|=0,u|=0,l|=0,c|=0,d|=0),S[Rt+0]=s,S[Rt+1]=r,S[Rt+2]=at,S[Rt+3]=ut,A[Rt+4]=B,S[Rt+5]=o,S[Rt+6]=h,S[Rt+7]=at,S[Rt+8]=lt,A[Rt+9]=X,S[Rt+10]=u,S[Rt+11]=l,S[Rt+12]=ht,S[Rt+13]=lt,A[Rt+14]=z,S[Rt+15]=s,S[Rt+16]=r,S[Rt+17]=at,S[Rt+18]=ut,A[Rt+19]=B,S[Rt+20]=u,S[Rt+21]=l,S[Rt+22]=ht,S[Rt+23]=lt,A[Rt+24]=z,S[Rt+25]=c,S[Rt+26]=d,S[Rt+27]=ht,S[Rt+28]=ut,A[Rt+29]=Y,this.vertexCount+=6))}}else q=0,J=0,K+=R,ct=null},batchDynamicBitmapText:function(t,e,i){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var s,r,o,h,u,l,c,d,f,p,g,v,m,y,x,w,b,T,S,A,C=this.renderer.config.roundPixels,M=t.displayCallback,_=t.text,E=_.length,P=a.getTintAppendFloatAlpha,L=this.vertexViewF32,F=this.vertexViewU32,k=this.renderer,R=e.matrix.matrix,O=t.frame,D=t.texture.source[O.sourceIndex],I=e.scrollX*t.scrollFactorX,B=e.scrollY*t.scrollFactorY,Y=t.scrollX,X=t.scrollY,z=t.fontData,N=z.lineHeight,U=t.fontSize/z.size,G=z.chars,W=t.alpha,V=P(t._tintTL,W),H=P(t._tintTR,W),j=P(t._tintBL,W),q=P(t._tintBR,W),K=t.x,J=t.y,Z=O.cutX,Q=O.cutY,$=D.width,tt=D.height,et=D.glTexture,it=0,nt=0,st=0,rt=0,ot=null,at=0,ht=0,ut=0,lt=0,ct=0,dt=0,ft=0,pt=0,gt=0,vt=0,mt=0,yt=0,xt=null,wt=0,bt=K+O.x,Tt=J+O.y,St=t.rotation,At=t.scaleX,Ct=t.scaleY,Mt=t.letterSpacing,_t=Math.sin(St),Et=Math.cos(St),Pt=Et*At,Lt=_t*At,Ft=-_t*Ct,kt=Et*Ct,Rt=bt,Ot=Tt,Dt=R[0],It=R[1],Bt=R[2],Yt=R[3],Xt=R[4],zt=R[5],Nt=t.cropWidth>0||t.cropHeight>0,Ut=0;if(n){var Gt=n[0],Wt=n[1],Vt=n[2],Ht=n[3],jt=n[4],qt=n[5],Kt=-I,Jt=-B,Zt=Gt*Dt+Wt*Bt,Qt=Gt*It+Wt*Yt,$t=Vt*Dt+Ht*Bt,te=Vt*It+Ht*Yt;x=Pt*Zt+Lt*$t,w=Pt*Qt+Lt*te,b=Ft*Zt+kt*$t,T=Ft*Qt+kt*te,S=Rt*Zt+Ot*$t+(jt*Dt+qt*Bt+(Kt*Dt+Jt*Bt+Xt)),A=Rt*Qt+Ot*te+(jt*It+qt*Yt+(Kt*It+Jt*Yt+zt))}else x=Pt*Dt+Lt*Bt,w=Pt*It+Lt*Yt,b=Ft*Dt+kt*Bt,T=Ft*It+kt*Yt,S=(Rt-=I)*Dt+(Ot-=B)*Bt+Xt,A=Rt*It+Ot*Yt+zt;this.setTexture2D(et,0),Nt&&k.pushScissor(t.x,t.y,t.cropWidth*t.scaleX,t.cropHeight*t.scaleY);for(var ee=0;eethis.vertexCapacity&&this.flush(),Ut=this.vertexCount*this.vertexComponentCount,C&&(s|=0,r|=0,o|=0,h|=0,u|=0,l|=0,c|=0,d|=0),L[Ut+0]=s,L[Ut+1]=r,L[Ut+2]=gt,L[Ut+3]=mt,F[Ut+4]=V,L[Ut+5]=o,L[Ut+6]=h,L[Ut+7]=gt,L[Ut+8]=yt,F[Ut+9]=j,L[Ut+10]=u,L[Ut+11]=l,L[Ut+12]=vt,L[Ut+13]=yt,F[Ut+14]=q,L[Ut+15]=s,L[Ut+16]=r,L[Ut+17]=gt,L[Ut+18]=mt,F[Ut+19]=V,L[Ut+20]=u,L[Ut+21]=l,L[Ut+22]=vt,L[Ut+23]=yt,F[Ut+24]=q,L[Ut+25]=c,L[Ut+26]=d,L[Ut+27]=vt,L[Ut+28]=mt,F[Ut+29]=H,this.vertexCount+=6}}}else it=0,st=0,nt+=N,xt=null;Nt&&k.popScissor()},batchText:function(t,e,i){var n=a.getTintAppendFloatAlpha;this.batchTexture(t,t.canvasTexture,t.canvasTexture.width,t.canvasTexture.height,t.x,t.y,t.canvasTexture.width,t.canvasTexture.height,t.scaleX,t.scaleY,t.rotation,t.flipX,t.flipY,t.scrollFactorX,t.scrollFactorY,t.displayOriginX,t.displayOriginY,0,0,t.canvasTexture.width,t.canvasTexture.height,n(t._tintTL,t._alphaTL),n(t._tintTR,t._alphaTR),n(t._tintBL,t._alphaBL),n(t._tintBR,t._alphaBR),0,0,e,i)},batchDynamicTilemapLayer:function(t,e,i){for(var n=t.culledTiles,s=n.length,r=t.tileset.image.get().source.glTexture,o=t.tileset,h=t.scrollFactorX,u=t.scrollFactorY,l=t.alpha,c=t.x,d=t.y,f=t.scaleX,p=t.scaleY,g=a.getTintAppendFloatAlpha,v=0;vthis.vertexCapacity&&this.flush(),d^=e.isRenderTexture?1:0;var L,F,k,R,O,D,I=this.renderer.config.roundPixels,B=this.vertexViewF32,Y=this.vertexViewU32,X=_.matrix.matrix,z=o*(c?1:0)-g,N=a*(d?1:0)-v,U=z+o*(c?-1:1),G=N+a*(d?-1:1),W=s,V=r,H=Math.sin(l),j=Math.cos(l),q=j*h,K=H*h,J=-H*u,Z=j*u,Q=W,$=V,tt=X[0],et=X[1],it=X[2],nt=X[3],st=X[4],rt=X[5];if(P){var ot=P[0],at=P[1],ht=P[2],ut=P[3],lt=P[4],ct=P[5],dt=-_.scrollX*f,ft=-_.scrollY*p,pt=ot*tt+at*it,gt=ot*et+at*nt,vt=ht*tt+ut*it,mt=ht*et+ut*nt;L=q*pt+K*vt,F=q*gt+K*mt,k=J*pt+Z*vt,R=J*gt+Z*mt,O=Q*pt+$*vt+(lt*tt+ct*it+(dt*tt+ft*it+st)),D=Q*gt+$*mt+(lt*et+ct*nt+(dt*et+ft*nt+rt))}else L=q*tt+K*it,F=q*et+K*nt,k=J*tt+Z*it,R=J*et+Z*nt,O=(Q-=_.scrollX*f)*tt+($-=_.scrollY*p)*it+st,D=Q*et+$*nt+rt;var yt,xt=z*L+N*k+O,wt=z*F+N*R+D,bt=z*L+G*k+O,Tt=z*F+G*R+D,St=U*L+G*k+O,At=U*F+G*R+D,Ct=U*L+N*k+O,Mt=U*F+N*R+D,_t=m/i+C,Et=y/n+M,Pt=(m+x)/i+C,Lt=(y+w)/n+M;this.setTexture2D(e,0),yt=this.vertexCount*this.vertexComponentCount,I&&(xt|=0,wt|=0,bt|=0,Tt|=0,St|=0,At|=0,Ct|=0,Mt|=0),B[yt+0]=xt,B[yt+1]=wt,B[yt+2]=_t,B[yt+3]=Et,Y[yt+4]=b,B[yt+5]=bt,B[yt+6]=Tt,B[yt+7]=_t,B[yt+8]=Lt,Y[yt+9]=T,B[yt+10]=St,B[yt+11]=At,B[yt+12]=Pt,B[yt+13]=Lt,Y[yt+14]=S,B[yt+15]=xt,B[yt+16]=wt,B[yt+17]=_t,B[yt+18]=Et,Y[yt+19]=b,B[yt+20]=St,B[yt+21]=At,B[yt+22]=Pt,B[yt+23]=Lt,Y[yt+24]=S,B[yt+25]=Ct,B[yt+26]=Mt,B[yt+27]=Pt,B[yt+28]=Et,Y[yt+29]=A,this.vertexCount+=6},drawTexture:function(t,e,i,n,s,r,o,h,u,l,c){var d=null;c&&(d=c.matrix),this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var f=this.renderer.config.roundPixels,p=this.vertexViewF32,g=this.vertexViewU32,v=e,m=i,y=v+h,x=m+u,w=l[0],b=l[1],T=l[2],S=l[3],A=l[4],C=l[5];if(d){var M=d[0],_=d[1],E=d[2],P=d[3],L=d[4],F=w*_+b*P,k=T*_+S*P,R=A*_+C*P+d[5];w=w*M+b*E,b=F,T=T*M+S*E,S=k,A=A*M+C*E+L,C=R}var O,D=v*w+m*T+A,I=v*b+m*S+C,B=v*w+x*T+A,Y=v*b+x*S+C,X=y*w+x*T+A,z=y*b+x*S+C,N=y*w+m*T+A,U=y*b+m*S+C,G=t.width,W=t.height,V=r/G,H=o/W,j=(r+h)/G,q=(o+u)/W;n=a.getTintAppendFloatAlpha(n,s),this.setTexture2D(t,0),O=this.vertexCount*this.vertexComponentCount,f&&(D|=0,I|=0,B|=0,Y|=0,X|=0,z|=0,N|=0,U|=0),p[O+0]=D,p[O+1]=I,p[O+2]=V,p[O+3]=H,g[O+4]=n,p[O+5]=B,p[O+6]=Y,p[O+7]=V,p[O+8]=q,g[O+9]=n,p[O+10]=X,p[O+11]=z,p[O+12]=j,p[O+13]=q,g[O+14]=n,p[O+15]=D,p[O+16]=I,p[O+17]=V,p[O+18]=H,g[O+19]=n,p[O+20]=X,p[O+21]=z,p[O+22]=j,p[O+23]=q,g[O+24]=n,p[O+25]=N,p[O+26]=U,p[O+27]=j,p[O+28]=H,g[O+29]=n,this.vertexCount+=6,this.flush()},batchGraphics:function(){}});t.exports=u},function(t,e){t.exports=function(t,e,i){var n;if(void 0===i&&(i=!0),e)"string"==typeof e?n=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(n=e);else if(t.parentElement)return t;return n||(n=document.body),i&&n.style&&(n.style.overflow="hidden"),n.appendChild(t),t}},function(t,e){var i,n="";t.exports={disable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!1),t},enable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!0),t},getPrefix:i=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i=(t=t.toString()).length)switch(n){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((s=e-t.length)/2);t=new Array(s-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var n=i(5);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return e.x=t.x+s*Math.cos(i)*t.width/2,e.y=t.y+s*Math.sin(i)*t.height/2,e}},function(t,e,i){var n=i(97),s=i(5);t.exports=function(t,e,i){if(void 0===i&&(i=new s),e<=0||e>=1)return i.x=t.x,i.y=t.y,i;var r=n(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var n=i(5);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o,a){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),void 0===o&&(o={}),void 0===a&&(a={}),this.name=t,this.firstgid=e,this.tileWidth=i,this.tileHeight=n,this.tileMargin=s,this.tileSpacing=r,this.tileProperties=o,this.tileData=a,this.image=null,this.rows=0,this.columns=0,this.total=0,this.texCoordinates=[]},getTileProperties:function(t){return this.containsTileIndex(t)?this.tileProperties[t-this.firstgid]:null},getTileData:function(t){return this.containsTileIndex(t)?this.tileData[t-this.firstgid]:null},getTileCollisionGroup:function(t){var e=this.getTileData(t);return e&&e.objectgroup?e.objectgroup:null},containsTileIndex:function(t){return t>=this.firstgid&&t=0&&g<=1&&v>=0&&v<=1&&(i.x=s+g*(o-s),i.y=r+g*(a-r),!0)}},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(862),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Texture,s.Transform,s.Visible,s.ScrollFactor,o],initialize:function(t,e,i,n,s,o,a,h,u){if(r.call(this,t,"Mesh"),this.setTexture(h,u),this.setPosition(e,i),this.setSizeToFrame(),this.setOrigin(),this.initPipeline("TextureTintPipeline"),n.length!==s.length)throw new Error("Mesh Vertex count must match UV count");var l,c=n.length/2|0;if(o.length>0&&o.length0&&a.length=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(s*a+o*h),e}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var n=i(5);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},function(t,e,i){var n=i(71),s=i(5);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=n(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,u=t.y2,l=0;l1?2-s:s,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},function(t,e,i){var n=i(51),s=i(88),r=i(32),o=i(0),a=i(15),h=i(2),u=i(14),l=i(31),c=new o({Extends:h,Mixins:[a.Depth,a.GetBounds,a.Origin,a.ScaleMode,a.Transform,a.ScrollFactor,a.Visible],initialize:function(t,e,i,s,r){void 0===s&&(s=1),void 0===r&&(r=s),h.call(this,t,"Zone"),this.setPosition(e,i),this.width=s,this.height=r,this.blendMode=n.NORMAL},displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e,i){return void 0===i&&(i=!0),this.width=t,this.height=e,i&&this.input&&this.input.hitArea instanceof u&&(this.input.hitArea.width=t,this.input.hitArea.height=e),this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this},setCircleDropZone:function(t){return this.setDropZone(new s(0,0,t),r)},setRectangleDropZone:function(t,e){var i=-t/2,n=-e/2;return this.setDropZone(new u(i,n,t,e),l)},setDropZone:function(t,e){return void 0===t?this.setRectangleDropZone(this.width,this.height):this.input||this.setInteractive(t,e,!0),this},renderCanvas:function(){},renderWebGL:function(){}});t.exports=c},function(t,e,i){var n=i(0),s=i(9),r=i(72),o=i(61),a=new n({Extends:s,initialize:function(t){s.call(this),this.manager=t,this.isTimeline=!0,this.data=[],this.totalData=0,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},add:function(t){return this.queue(r(this,t))},queue:function(t){return this.isPlaying()||(t.parent=this,t.parentIsTimeline=!0,this.data.push(t),this.totalData=this.data.length),this},hasOffset:function(t){return null!==t.offset},isOffsetAbsolute:function(t){return"number"==typeof t},isOffsetRelative:function(t){if("string"===typeof t){var e=t[0];if("-"===e||"+"===e)return!0}return!1},getRelativeOffset:function(t,e){var i=t[0],n=parseFloat(t.substr(2)),s=e;switch(i){case"+":s+=n;break;case"-":s-=n}return Math.max(0,s)},calcDuration:function(){for(var t=0,e=0,i=0,n=0;n0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=o.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=o.PENDING_REMOVE}},update:function(t,e){if(this.state!==o.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var n=this.totalData,s=0;s0?Math.floor(v/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=a(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=o(e,"yoyo",g.yoyo),g.flipX=o(e,"flipX",g.flipX),g.flipY=o(e,"flipY",g.flipY);for(var m=0;m0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var n=new(i(0))({initialize:function(t){this.pluginManager=t,this.game=t.game,this.scene,this.systems},init:function(){},start:function(){},stop:function(){},boot:function(){},destroy:function(){this.pluginManager=null,this.game=null,this.scene=null,this.systems=null}});t.exports=n},,function(t,e,i){var n=i(0),s=i(19),r=i(1),o=i(108),a=i(8),h=new n({Extends:s,initialize:function(t,e,i,n){if(a(e)){var o=e;e=r(o,"key"),n=r(o,"config",n)}var h={type:"audio",cache:t.cacheManager.audio,extension:i.type,key:e,url:i.url,config:n};s.call(this,t,h),this.locked="ontouchstart"in window,this.loaded=!1,this.filesLoaded=0,this.filesTotal=0},onLoad:function(){this.loaded||(this.loaded=!0,this.loader.nextFile(this,!0))},onError:function(){for(var t=0;t=2&&(this.leftStick.set(r[0].getValue(),r[1].getValue()),s>=4&&this.rightStick.set(r[2].getValue(),r[3].getValue()))},destroy:function(){var t;for(this.removeAllListeners(),this.manager=null,this.pad=null,t=0;t=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",e,this,t),this.pad.emit("down",i,t,this)):this.pressed&&(this.pressed=!1,this.events.emit("up",e,this,t),this.pad.emit("up",i,t,this))},destroy:function(){this.pad=null,this.events=null}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.1},update:function(t){this.value=t},getValue:function(){return Math.abs(this.value)0&&e.cameraFilter&r._id)){var u=r.scrollX*e.scrollFactorX,l=r.scrollY*e.scrollFactorY,c=e.x,d=e.y,f=e.scaleX,p=e.scaleY,g=e.rotation,v=e.commandBuffer,m=a||t.currentContext,y=1,x=1,w=0,b=0,T=1,S=0,A=0,C=0;if(t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,m.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,m.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),m.save(),o){var M=o.matrix;m.transform(M[0],M[1],M[2],M[3],M[4],M[5])}m.translate(c-u,d-l),m.rotate(g),m.scale(f,p),m.fillStyle="#fff",m.globalAlpha=e.alpha;for(var _=0,E=v.length;_>>16,A=(65280&w)>>>8,C=255&w,m.strokeStyle="rgba("+S+","+A+","+C+","+y+")",m.lineWidth=T,_+=3;break;case n.FILL_STYLE:b=v[_+1],x=v[_+2],S=(16711680&b)>>>16,A=(65280&b)>>>8,C=255&b,m.fillStyle="rgba("+S+","+A+","+C+","+x+")",_+=2;break;case n.BEGIN_PATH:m.beginPath();break;case n.CLOSE_PATH:m.closePath();break;case n.FILL_PATH:h||m.fill();break;case n.STROKE_PATH:h||m.stroke();break;case n.FILL_RECT:h?m.rect(v[_+1],v[_+2],v[_+3],v[_+4]):m.fillRect(v[_+1],v[_+2],v[_+3],v[_+4]),_+=4;break;case n.FILL_TRIANGLE:m.beginPath(),m.moveTo(v[_+1],v[_+2]),m.lineTo(v[_+3],v[_+4]),m.lineTo(v[_+5],v[_+6]),m.closePath(),h||m.fill(),_+=6;break;case n.STROKE_TRIANGLE:m.beginPath(),m.moveTo(v[_+1],v[_+2]),m.lineTo(v[_+3],v[_+4]),m.lineTo(v[_+5],v[_+6]),m.closePath(),h||m.stroke(),_+=6;break;case n.LINE_TO:m.lineTo(v[_+1],v[_+2]),_+=2;break;case n.MOVE_TO:m.moveTo(v[_+1],v[_+2]),_+=2;break;case n.LINE_FX_TO:m.lineTo(v[_+1],v[_+2]),_+=5;break;case n.MOVE_FX_TO:m.moveTo(v[_+1],v[_+2]),_+=5;break;case n.SAVE:m.save();break;case n.RESTORE:m.restore();break;case n.TRANSLATE:m.translate(v[_+1],v[_+2]),_+=2;break;case n.SCALE:m.scale(v[_+1],v[_+2]),_+=2;break;case n.ROTATE:m.rotate(v[_+1]),_+=1}m.restore()}}},function(t,e){t.exports=function(t){var e=t.width/2,i=t.height/2,n=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*n/(10+Math.sqrt(4-3*n)))}},function(t,e,i){var n=i(177),s=i(113),r=i(65),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;hr;){if(o-r>600){var h=o-r+1,u=e-r+1,l=Math.log(h),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(h-c)/h)*(u-h/2<0?-1:1),f=Math.max(r,Math.floor(e-u*c/h+d)),p=Math.min(o,Math.floor(e+(h-u)*c/h+d));i(t,e,f,p,a)}var g=t[e],v=r,m=o;for(n(t,r,e),a(t[o],g)>0&&n(t,r,o);v0;)m--}0===a(t[r],g)?n(t,r,m):n(t,++m,o),m<=e&&(r=m+1),e<=m&&(o=m-1)}};function n(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function s(t,e){return te?1:0}t.exports=i},function(t,e){t.exports=function(t){for(var e=t.length,i=t[0].length,n=new Array(i),s=0;s-1;r--)n[s][r]=t[r][s]}return n}},function(t,e,i){t.exports={AtlasXML:i(514),Canvas:i(513),Image:i(512),JSONArray:i(511),JSONHash:i(510),SpriteSheet:i(509),SpriteSheetFromAtlas:i(508),UnityYAML:i(507)}},function(t,e,i){var n=i(22),s=i(0),r=i(85),o=i(59),a=new s({initialize:function(t,e,i,n){var s=t.manager.game;this.renderer=s.renderer,this.texture=t,this.image=e,this.compressionAlgorithm=null,this.resolution=1,this.width=i||e.naturalWidth||e.width||0,this.height=n||e.naturalHeight||e.height||0,this.scaleMode=o.DEFAULT,this.isCanvas=e instanceof HTMLCanvasElement,this.isPowerOf2=r(this.width,this.height),this.glTexture=null,this.init(s)},init:function(t){this.renderer&&this.renderer.gl&&(this.isCanvas?this.glTexture=this.renderer.canvasToTexture(this.image):this.glTexture=this.renderer.createTextureFromSource(this.image,this.width,this.height,this.scaleMode)),t.config.pixelArt&&this.setFilter(1)},setFilter:function(t){this.renderer.gl&&this.renderer.setTextureFilter(this.glTexture,t)},update:function(){this.renderer.gl&&this.isCanvas&&this.renderer.canvasToTexture(this.image,this.glTexture)},destroy:function(){this.glTexture&&this.renderer.deleteTexture(this.glTexture),this.isCanvas&&n.remove(this.image),this.renderer=null,this.texture=null,this.image=null}});t.exports=a},function(t,e,i){var n=i(22),s=i(515),r=i(0),o=i(30),a=i(20),h=i(9),u=i(276),l=i(4),c=i(182),d=i(117),f=new r({Extends:h,initialize:function(t){h.call(this),this.game=t,this.name="TextureManager",this.list={},this._tempCanvas=n.create2D(this,1,1),this._tempContext=this._tempCanvas.getContext("2d"),this._pending=0,t.events.once("boot",this.boot,this)},boot:function(){this._pending=2,this.on("onload",this.updatePending,this),this.on("onerror",this.updatePending,this),this.addBase64("__DEFAULT",this.game.config.defaultImage),this.addBase64("__MISSING",this.game.config.missingImage),this.game.events.once("destroy",this.destroy,this)},updatePending:function(){this._pending--,0===this._pending&&(this.off("onload"),this.off("onerror"),this.game.events.emit("ready"))},checkKey:function(t){return!this.exists(t)||(console.error("Texture key already in use: "+t),!1)},remove:function(t){if("string"==typeof t){if(!this.exists(t))return console.warn("No texture found matching key: "+t),this;t=this.get(t)}return this.list.hasOwnProperty(t.key)&&(delete this.list[t.key],t.destroy(),this.emit("removetexture",t.key)),this},addBase64:function(t,e){if(this.checkKey(t)){var i=this,n=new Image;n.onerror=function(){i.emit("onerror",t)},n.onload=function(){var e=i.create(t,n);c.Image(e,0),i.emit("addtexture",t,e),i.emit("onload",t,e)},n.src=e}},addImage:function(t,e,i){var n=null;return this.checkKey(t)&&(n=this.create(t,e),c.Image(n,0),i&&n.setDataSource(i),this.emit("addtexture",t,n)),n},generate:function(t,e){if(this.checkKey(t)){var i=n.create(this,1,1);return e.canvas=i,u(e),this.addCanvas(t,i)}return null},createCanvas:function(t,e,i){if(void 0===e&&(e=256),void 0===i&&(i=256),this.checkKey(t)){var s=n.create(this,e,i,a.CANVAS,!0);return this.addCanvas(t,s)}return null},addCanvas:function(t,e){var i=null;return this.checkKey(t)&&(i=new s(this,t,e,e.width,e.height),this.list[t]=i,this.emit("addtexture",t,i)),i},addAtlas:function(t,e,i,n){return Array.isArray(i.textures)||Array.isArray(i.frames)?this.addAtlasJSONArray(t,e,i,n):this.addAtlasJSONHash(t,e,i,n)},addAtlasJSONArray:function(t,e,i,n){var s=null;if(this.checkKey(t)){if(s=this.create(t,e),Array.isArray(i))for(var r=1===i.length,o=0;o=0&&t<=r.width&&e>=0&&e<=r.height){t+=s.cutX,e+=s.cutY;var a=this._tempContext;a.clearRect(0,0,1,1),a.drawImage(r,t,e,1,1,0,0,1,1);var h=a.getImageData(0,0,1,1);return new o(h.data[0],h.data[1],h.data[2],h.data[3])}}return null},getPixelAlpha:function(t,e,i,n){var s=this.getFrame(i,n);if(s){var r=s.source.image;if(t>=0&&t<=r.width&&e>=0&&e<=r.height){t+=s.cutX,e+=s.cutY;var o=this._tempContext;return o.clearRect(0,0,1,1),o.drawImage(r,t,e,1,1,0,0,1,1),o.getImageData(0,0,1,1).data[3]}}return null},setTexture:function(t,e,i){return this.list[e]&&(t.texture=this.list[e],t.frame=t.texture.get(i)),t},each:function(t,e){for(var i=[null],n=1;n0)&&(!!n.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!n.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!n.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=n-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,s-n),s=this.audio.currentTime):s=n)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=s}},destroy:function(){n.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},updateMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},updateVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},calculateRate:function(){n.prototype.calculateRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)},mute:{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||this.emit("mute",this,t)}},setMute:function(t){return this.mute=t,this},volume:{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||this.emit("volume",this,t)}},setVolume:function(t){return this.volume=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||(this.calculateRate(),this.emit("rate",this,t))}},setRate:function(t){return this.rate=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||(this.calculateRate(),this.emit("detune",this,t))}},setDetune:function(t){return this.detune=t,this},seek:{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}},setSeek:function(t){return this.seek=t,this},loop:{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}},setLoop:function(t){return this.loop=t,this}});t.exports=s},function(t,e,i){var n=i(79),s=i(0),r=i(189),o=new s({Extends:n,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,n.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){this.locked=!1;var t=this;if(this.game.cache.audio.entries.each(function(e,i){for(var n=0;n-1&&(delete this.keys[n],this.scenes.splice(i,1),this._start.indexOf(n)>-1&&(i=this._start.indexOf(n),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e,i=t.sys,n=i.settings;t.init&&(t.init.call(t,n.data),n.isTransition&&i.events.emit("transitioninit",n.transitionFrom,n.transitionDuration)),i.load&&(e=i.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(n.status=s.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.game.sound.onBlurPausedSounds&&this.game.sound.unlock(),this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this.isProcessing=!0;for(var i=this.scenes.length-1;i>=0;i--){var n=this.scenes[i].sys;n.settings.status>s.START&&n.settings.status<=s.RUNNING&&n.step(t,e)}},resize:function(t,e){for(var i=0;i=s.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this.isProcessing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,n=this.getScene(t),s=this.getAt(i);this.scenes[e]=s,this.scenes[i]=n}}return this},moveUp:function(t){if(this.isProcessing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e=0;t--){this.scenes[t].sys.destroy()}this.update=o,this.scenes=[],this._pending=[],this._start=[],this._queue=[],this.game=null}});t.exports=u},function(t,e,i){var n=i(56);t.exports=function(t,e,i,s){var r;if(void 0===s&&(s=t),!Array.isArray(e))return-1!==(r=t.indexOf(e))?(n(t,r),i&&i.call(s,e),e):null;for(var o=e.length-1;o>=0;){var a=e[o];-1!==(r=t.indexOf(a))?(n(t,r),i&&i.call(s,a)):e.pop(),o--}return e}},function(t,e,i){var n=i(0),s=i(9),r=i(7),o=i(13),a=i(11),h=i(1),u=i(12),l=i(195),c=new n({Extends:s,initialize:function(t){s.call(this),this.game=t,this.plugins=[],this.scenePlugins=[],this._pendingGlobal=[],this._pendingScene=[],t.isBooted?this.boot():t.events.once("boot",this.boot,this)},boot:function(){var t,e,i,n,s,r,o=this.game.config,a=o.installGlobalPlugins;for(a=a.concat(this._pendingGlobal),t=0;t10&&(t=10-this.pointersTotal);for(var i=0;i0},queueTouchStart:function(t){if(this.queue.push(s.TOUCH_START,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueTouchMove:function(t){if(this.queue.push(s.TOUCH_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueTouchEnd:function(t){if(this.queue.push(s.TOUCH_END,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},queueMouseDown:function(t){if(this.queue.push(s.MOUSE_DOWN,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueMouseMove:function(t){if(this.queue.push(s.MOUSE_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueMouseUp:function(t){if(this.queue.push(s.MOUSE_UP,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},addUpCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.upOnce.push(t):this.domCallbacks.up.push(t),this._hasUpCallback=!0,this},addDownCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.downOnce.push(t):this.domCallbacks.down.push(t),this._hasDownCallback=!0,this},addMoveCallback:function(t,e){return void 0===e&&(e=!1),e?this.domCallbacks.moveOnce.push(t):this.domCallbacks.move.push(t),this._hasMoveCallback=!0,this},inputCandidate:function(t){var e=t.input;if(!e||!e.enabled||!t.willRender())return!1;var i=!0,n=t.parentContainer;if(n)do{if(!n.visible){i=!1;break}n=n.parentContainer}while(n);return i},hitTest:function(t,e,i,n){void 0===n&&(n=this._tempHitTest);var s=this._tempPoint,r=i.width,o=i.height;n.length=0;var a=t.x,h=t.y;if(!(a>=i.x&&h>=i.y&&a<=i.x+r&&h<=i.y+o))return n;i.getWorldPoint(a,h,s),t.worldX=s.x,t.worldY=s.y;for(var u={x:0,y:0},l=this.game.config.resolution,d=this._tempMatrix,f=0;fe.length&&(r=e.length),i?(n=e[r-1][i],(s=e[r][i])-t<=t-n?e[r]:e[r-1]):(n=e[r-1],(s=e[r])-t<=t-n?s:n)}},function(t,e,i){var n=i(23),s=i(0),r=i(209),o=i(208),a=i(4),h=new s({initialize:function(t,e,i){this.manager=t,this.key=e,this.type="frame",this.frames=this.getFrames(t.textureManager,a(i,"frames",[]),a(i,"defaultTextureKey",null)),this.frameRate=a(i,"frameRate",null),this.duration=a(i,"duration",null),null===this.duration&&null===this.frameRate?(this.frameRate=24,this.duration=this.frameRate/this.frames.length*1e3):this.duration&&null===this.frameRate?this.frameRate=this.frames.length/(this.duration/1e3):this.duration=this.frames.length/this.frameRate*1e3,this.msPerFrame=1e3/this.frameRate,this.skipMissedFrames=a(i,"skipMissedFrames",!0),this.delay=a(i,"delay",0),this.repeat=a(i,"repeat",0),this.repeatDelay=a(i,"repeatDelay",0),this.yoyo=a(i,"yoyo",!1),this.showOnStart=a(i,"showOnStart",!1),this.hideOnComplete=a(i,"hideOnComplete",!1),this.paused=!1,this.manager.on("pauseall",this.pause,this),this.manager.on("resumeall",this.resume,this)},addFrame:function(t){return this.addFrameAt(this.frames.length,t)},addFrameAt:function(t,e){var i=this.getFrames(this.manager.textureManager,e);if(i.length>0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var n=this.frames.slice(0,t),s=this.frames.slice(t);this.frames=n.concat(i,s)}this.updateFrameSequence()}return this},checkFrame:function(t){return t>=0&&t0){s.isLast=!0,s.nextFrame=u[0],u[0].prevFrame=s;var v=1/(u.length-1);for(r=0;r=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._timeScale=1,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo),t.updateFrame(this.frames[e])},getFrameByProgress:function(t){return t=n(t,0,1),r(t,this.frames,"progress")},nextFrame:function(t){var e=t.currentFrame;e.isLast?t._yoyo?(t.forward=!1,t.updateFrame(e.prevFrame),this.getNextTick(t)):t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.nextFrame),this.getNextTick(t))},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.prevFrame),this.getNextTick(t))},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){if(2===t._pendingStop)return this.completeAnimation(t);t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=t._repeatDelay):(t.repeatCounter--,t.forward=!0,t.updateFrame(t.currentFrame.nextFrame),t.isPlaying&&(this.getNextTick(t),t.pendingRepeat=!1,t.parent.emit("animationrepeat",this,t.currentFrame,t.repeatCounter)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(n.prevFrame=this.frames[i-1],n.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){this.manager.off("pauseall",this.pause,this),this.manager.off("resumeall",this.resume,this),this.manager.remove(this.key);for(var t=0;t=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(t,e,i,s,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=s||(o=e+Math.ceil((i-e)/s/2)*s,n(t,o,e,i,r),a.push(e,o,o,i))}s.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!p(t,e))return i;for(var s,r,o,a,h=[];e;){for(s=0,r=e.children.length;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)},_split:function(t,e){var i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);var r=this._chooseSplitIndex(i,s,n),a=g(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,s,r,o,h,u,l,d,f,p,g,v,m,y;for(u=l=1/0,n=e;n<=i-e;n++)s=a(t,0,n,this.toBBox),r=a(t,n,i,this.toBBox),f=s,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),v=Math.max(f.minY,p.minY),m=Math.min(f.maxX,p.maxX),y=Math.min(f.maxY,p.maxY),o=Math.max(0,m-g)*Math.max(0,y-v),h=c(s)+c(r),o=e;s--)r=t.children[s],h(l,t.leaf?o(r):r),c+=d(l);return c},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)h(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},compareMinX:function(t,e){return t.left-e.left},compareMinY:function(t,e){return t.top-e.top},toBBox:function(t){return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}},t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,n=this._active;for(t=0;tu+l?(g=(p-=u+l)/c,v.x=h.x1+(h.x2-h.x1)*g,v.y=h.y1+(h.y2-h.y1)*g):(g=(p-=u)/l,v.x=a.x1+(a.x2-a.x1)*g,v.y=a.y1+(a.y2-a.y1)*g),r.push(v)}return r}},function(t,e,i){var n=i(5),s=i(71);t.exports=function(t,e,i){void 0===i&&(i=new n);var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=s(r),u=s(o),l=s(a),c=(h+u+l)*e,d=0;return ch+u?(d=(c-=h+u)/l,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/u,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},function(t,e){t.exports=function(t){return 0===t.height?NaN:t.width/t.height}},function(t,e){t.exports=function(t,e,i){for(var n=!1,s=-1,r=t.points.length-1;++s=0&&r>=0&&s+r<1&&(n.push({x:e[b].x,y:e[b].y}),i)));b++);return n}},function(t,e,i){var n=i(0),s=i(145),r=new n({Extends:s,initialize:function(t,e,i,n,r){s.call(this,t,e,i,[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1,1,0],[16777215,16777215,16777215,16777215,16777215,16777215],[1,1,1,1,1,1],n,r),this.resetPosition()},topLeftX:{get:function(){return this.x+this.vertices[0]},set:function(t){this.vertices[0]=t-this.x,this.vertices[6]=t-this.x}},topLeftY:{get:function(){return this.y+this.vertices[1]},set:function(t){this.vertices[1]=t-this.y,this.vertices[7]=t-this.y}},topRightX:{get:function(){return this.x+this.vertices[10]},set:function(t){this.vertices[10]=t-this.x}},topRightY:{get:function(){return this.y+this.vertices[11]},set:function(t){this.vertices[11]=t-this.y}},bottomLeftX:{get:function(){return this.x+this.vertices[2]},set:function(t){this.vertices[2]=t-this.x}},bottomLeftY:{get:function(){return this.y+this.vertices[3]},set:function(t){this.vertices[3]=t-this.y}},bottomRightX:{get:function(){return this.x+this.vertices[4]},set:function(t){this.vertices[4]=t-this.x,this.vertices[8]=t-this.x}},bottomRightY:{get:function(){return this.y+this.vertices[5]},set:function(t){this.vertices[5]=t-this.y,this.vertices[9]=t-this.y}},topLeftAlpha:{get:function(){return this.alphas[0]},set:function(t){this.alphas[0]=t,this.alphas[3]=t}},topRightAlpha:{get:function(){return this.alphas[5]},set:function(t){this.alphas[5]=t}},bottomLeftAlpha:{get:function(){return this.alphas[1]},set:function(t){this.alphas[1]=t}},bottomRightAlpha:{get:function(){return this.alphas[2]},set:function(t){this.alphas[2]=t,this.alphas[4]=t}},topLeftColor:{get:function(){return this.colors[0]},set:function(t){this.colors[0]=t,this.colors[3]=t}},topRightColor:{get:function(){return this.colors[5]},set:function(t){this.colors[5]=t}},bottomLeftColor:{get:function(){return this.colors[1]},set:function(t){this.colors[1]=t}},bottomRightColor:{get:function(){return this.colors[2]},set:function(t){this.colors[2]=t,this.colors[4]=t}},setTopLeft:function(t,e){return this.topLeftX=t,this.topLeftY=e,this},setTopRight:function(t,e){return this.topRightX=t,this.topRightY=e,this},setBottomLeft:function(t,e){return this.bottomLeftX=t,this.bottomLeftY=e,this},setBottomRight:function(t,e){return this.bottomRightX=t,this.bottomRightY=e,this},resetPosition:function(){var t=this.x,e=this.y,i=Math.floor(this.width/2),n=Math.floor(this.height/2);return this.setTopLeft(t-i,e-n),this.setTopRight(t+i,e-n),this.setBottomLeft(t-i,e+n),this.setBottomRight(t+i,e+n),this},resetAlpha:function(){var t=this.alphas;return t[0]=1,t[1]=1,t[2]=1,t[3]=1,t[4]=1,t[5]=1,this},resetColors:function(){var t=this.colors;return t[0]=16777215,t[1]=16777215,t[2]=16777215,t[3]=16777215,t[4]=16777215,t[5]=16777215,this},reset:function(){return this.resetPosition(),this.resetAlpha(),this.resetColors()}});t.exports=r},function(t,e,i){var n=i(22),s=i(0),r=i(15),o=i(20),a=i(2),h=i(411),u=i(886),l=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Size,r.Texture,r.Tint,r.Transform,r.Visible,u],initialize:function(t,e,i,s,r,u,l){var c=t.sys.game.renderer;a.call(this,t,"TileSprite"),this.tilePositionX=0,this.tilePositionY=0,this.dirty=!0,this.tileTexture=null,this.renderer=c,this.setTexture(u,l),this.setPosition(e,i),this.setSize(s,r),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline"),this.potWidth=h(this.frame.width),this.potHeight=h(this.frame.height),this.canvasPattern=null,this.canvasBuffer=n.create2D(this,this.potWidth,this.potHeight),this.canvasBufferCtx=this.canvasBuffer.getContext("2d"),this.oldFrame=null,this.updateTileTexture(),t.sys.game.config.renderType===o.WEBGL&&t.sys.game.renderer.onContextRestored(function(t){var e=t.gl;this.tileTexture=null,this.dirty=!0,this.tileTexture=t.createTexture2D(0,e.LINEAR,e.LINEAR,e.REPEAT,e.REPEAT,e.RGBA,this.canvasBuffer,this.potWidth,this.potHeight)},this)},setTilePosition:function(t,e){return void 0!==t&&(this.tilePositionX=t),void 0!==e&&(this.tilePositionY=e),this},updateTileTexture:function(){(this.dirty||this.oldFrame!==this.frame)&&(this.oldFrame=this.frame,this.canvasBufferCtx.clearRect(0,0,this.canvasBuffer.width,this.canvasBuffer.height),this.renderer.gl?(this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.potWidth,this.potHeight),this.tileTexture=this.renderer.canvasToTexture(this.canvasBuffer,this.tileTexture)):(this.canvasBuffer.width=this.frame.cutWidth,this.canvasBuffer.height=this.frame.cutHeight,this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.frame.cutWidth,this.frame.cutHeight),this.canvasPattern=this.canvasBufferCtx.createPattern(this.canvasBuffer,"repeat")),this.dirty=!1)},preDestroy:function(){this.renderer&&this.renderer.gl&&this.renderer.deleteTexture(this.tileTexture),n.remove(this.canvasBuffer),this.canvasPattern=null,this.canvasBufferCtx=null,this.canvasBuffer=null,this.renderer=null}});t.exports=l},function(t,e,i){var n=i(22),s=i(0),r=i(15),o=i(20),a=i(2),h=i(894),u=i(891),l=i(890),c=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.ComputedSize,r.Depth,r.Flip,r.GetBounds,r.Mask,r.MatrixStack,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Tint,r.Transform,r.Visible,h],initialize:function(t,e,i,s,r){if(void 0===s&&(s=32),void 0===r&&(r=32),a.call(this,t,"RenderTexture"),this.initMatrixStack(),this.renderer=t.sys.game.renderer,this.globalTint=16777215,this.globalAlpha=1,this.canvas=null,this.context=null,this.framebuffer=null,this.renderer.type===o.WEBGL){var h=this.renderer.gl;this.gl=h,this.fill=l.fill,this.clear=l.clear,this.draw=l.draw,this.drawFrame=l.drawFrame,this.texture=this.renderer.createTexture2D(0,h.NEAREST,h.NEAREST,h.CLAMP_TO_EDGE,h.CLAMP_TO_EDGE,h.RGBA,null,s,r,!1),this.framebuffer=this.renderer.createFramebuffer(s,r,this.texture,!1)}else this.renderer.type===o.CANVAS&&(this.fill=u.fill,this.clear=u.clear,this.draw=u.draw,this.drawFrame=u.drawFrame,this.canvas=n.create2D(this,s,r),this.context=this.canvas.getContext("2d"));this.setPosition(e,i),this.setSize(s,r),this.initPipeline("TextureTintPipeline")},resize:function(t,e){if(void 0===e&&(e=t),t!==this.width||e!==this.height){if(this.canvas)this.canvas.width=t,this.canvas.height=e;else{this.renderer.deleteTexture(this.texture),this.renderer.deleteFramebuffer(this.framebuffer);var i=this.renderer.gl;this.texture=this.renderer.createTexture2D(0,i.NEAREST,i.NEAREST,i.CLAMP_TO_EDGE,i.CLAMP_TO_EDGE,i.RGBA,null,t,e,!1),this.framebuffer=this.renderer.createFramebuffer(t,e,this.texture,!1)}this.setSize(t,e)}return this},setGlobalTint:function(t){return this.globalTint=t,this},setGlobalAlpha:function(t){return this.globalAlpha=t,this},preDestroy:function(){this.renderer&&this.renderer.gl&&(this.renderer.deleteTexture(this.texture),this.renderer.deleteFramebuffer(this.framebuffer))}});t.exports=c},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(458),a=i(93),h=i(456),u=i(898),l=new n({Extends:r,Mixins:[s.Depth,s.Pipeline,s.Visible,u],initialize:function(t,e,i,n){if(r.call(this,t,"ParticleEmitterManager"),this.blendMode=-1,this.timeScale=1,this.texture=null,this.frame=null,this.frameNames=[],null===i||"object"!=typeof i&&!Array.isArray(i)||(n=i,i=null),this.setTexture(e,i),this.initPipeline("TextureTintPipeline"),this.emitters=new a(this),this.wells=new a(this),n){Array.isArray(n)||(n=[n]);for(var s=0;s0?e.defaultFrame=i[0]:e.defaultFrame=this.defaultFrame,this},addEmitter:function(t){return this.emitters.add(t)},createEmitter:function(t){return this.addEmitter(new h(this,t))},addGravityWell:function(t){return this.wells.add(t)},createGravityWell:function(t){return this.addGravityWell(new o(t))},emitParticle:function(t,e,i){for(var n=this.emitters.list,s=0;s0)for(var e=this.list,i=new a,n=0;n-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){var i,n=[null],s=this.list.slice(),r=s.length;for(i=2;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}},preDestroy:function(){this.removeAll(!!this.exclusive),this.localTransform.destroy(),this.tempTransformMatrix.destroy(),this.list=[],this._displayList=null}});t.exports=c},function(t,e,i){var n=i(910),s=i(907),r=i(0),o=i(15),a=i(128),h=i(2),u=i(93),l=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Mask,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,n],initialize:function(t,e,i,n,s){h.call(this,t,"Blitter"),this.setTexture(n,s),this.setPosition(e,i),this.initPipeline("TextureTintPipeline"),this.children=new u,this.renderList=[],this.dirty=!1},create:function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new s(this,t,e,i,n);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,n){for(var s=this.createMultiple(e,i,n),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0},preDestroy:function(){this.children.destroy(),this.renderList=[]}});t.exports=l},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(475),a=i(914),h=i(913),u=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Texture,s.Tint,s.Transform,s.Visible,h],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"BitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text="",this.fontSize=o||this.fontData.size,this.letterSpacing=0,this.setText(s),this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds()},setFontSize:function(t){return this.fontSize=t,this},setLetterSpacing:function(t){return void 0===t&&(t=0),this.letterSpacing=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize,letterSpacing:this.letterSpacing};return t.data=e,t}});u.ParseFromAtlas=a,t.exports=u},function(t,e,i){var n=i(4),s=i(95),r=function(t,e,i){for(var n=[],s=0;s0?Math.ceil(t):Math.floor(t)}},function(t,e){t.exports=function(t){return t&&t[0].toUpperCase()+t.slice(1)}},function(t,e,i){var n=i(6);t.exports=function(t,e,i,s,r,o,a,h){void 0===h&&(h=new n);var u=Math.sin(-r),l=Math.cos(-r),c=l*o,d=-u*o,f=u*a,p=l*a,g=c*p-d*f,v=p/g,m=-d/g,y=-f/g,x=c/g,w=(f*s-p*i)/g,b=-(c*s-d*i)/g;return h.x=t*v+e*y+w,h.y=t*m+e*x+b,h}},function(t,e,i){"use strict";function n(t,e,i){i=i||2;var n,a,h,u,l,f,g,v=e&&e.length,m=v?e[0]*i:t.length,y=s(t,0,m,i,!0),x=[];if(!y)return x;if(v&&(y=function(t,e,i,n){var o,a,h,u,l,f=[];for(o=0,a=e.length;o80*i){n=h=t[0],a=u=t[1];for(var w=i;wh&&(h=l),f>u&&(u=f);g=Math.max(h-n,u-a)}return o(y,x,i,n,a,g),x}function s(t,e,i,n,s){var r,o;if(s===C(t,e,i,n)>0)for(r=e;r=e;r-=n)o=T(r,t[r],t[r+1],o);return o&&y(o,o.next)&&(S(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!y(n,n.next)&&0!==m(n.prev,n,n.next))n=n.next;else{if(S(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,s,c,d){if(t){!d&&c&&function(t,e,i,n){var s=t;do{null===s.z&&(s.z=f(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,n,s,r,o,a,h,u=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,u*=2}while(o>1)}(s)}(t,n,s,c);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,n,s,c):a(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),S(t),t=g.next,v=g.next;else if((t=g)===v){d?1===d?o(t=u(t,e,i),e,i,n,s,c,2):2===d&&l(t,e,i,n,s,c):o(r(t),e,i,n,s,c,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(m(e,i,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(g(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&m(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function h(t,e,i,n){var s=t.prev,r=t,o=t.next;if(m(s,r,o)>=0)return!1;for(var a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,l=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,c=f(a,h,e,i,n),d=f(u,l,e,i,n),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function u(t,e,i){var n=t;do{var s=n.prev,r=n.next.next;!y(s,r)&&x(s,n,n.next,r)&&w(s,r)&&w(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),S(n),S(n.next),n=t=r),n=n.next}while(n!==t);return n}function l(t,e,i,n,s,a){var h=t;do{for(var u=h.next.next;u!==h.prev;){if(h.i!==u.i&&v(h,u)){var l=b(h,u);return h=r(h,h.next),l=r(l,l.next),o(h,e,i,n,s,a),void o(l,e,i,n,s,a)}u=u.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,n=e,s=t.x,r=t.y,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var a=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=s&&a>o){if(o=a,a===s){if(r===n.y)return n;if(r===n.next.y)return n.next}i=n.x=n.x&&n.x>=l&&s!==n.x&&g(ri.x)&&w(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=b(e,t);r(i,i.next)}}function f(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&w(t,e)&&w(e,t)&&function(t,e){var i=t,n=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function m(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function y(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,n){return!!(y(t,e)&&y(i,n)||y(t,n)&&y(i,e))||m(t,e,i)>0!=m(t,e,n)>0&&m(i,n,t)>0!=m(i,n,e)>0}function w(t,e){return m(t.prev,t,t.next)<0?m(t,e,t.next)>=0&&m(t,t.prev,e)>=0:m(t,e,t.prev)<0||m(t,t.next,e)<0}function b(t,e){var i=new A(t.i,t.x,t.y),n=new A(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function T(t,e,i,n){var s=new A(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function S(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function C(t,e,i,n){for(var s=0,r=e,o=i-n;r0&&(n+=t[s-1].length,i.holes.push(n))}return i}},function(t,e,i){var n=i(0),s=i(119),r=i(258),o=i(202),a=i(529),h=i(528),u=i(27),l=i(84),c=function(t,e,i,n,s){this.x=t,this.y=e,this.width=i,this.rgb=n,this.alpha=s},d=function(t,e,i,n,s){this.points=[],this.pointsLength=1,this.points[0]=new c(t,e,i,n,s)},f=new Float32Array([1,0,0,1,0,0]),p=new Float32Array(6e3),g=0,v=[],m=new n({Extends:l,Mixins:[o],initialize:function(t){l.call(this,{game:t.game,renderer:t.renderer,gl:t.renderer.gl,topology:t.topology?t.topology:t.renderer.gl.TRIANGLES,vertShader:t.vertShader?t.vertShader:h,fragShader:t.fragShader?t.fragShader:a,vertexCapacity:t.vertexCapcity?t.vertexCapacity:12e3,vertexSize:t.vertexSize?t.vertexSize:2*Float32Array.BYTES_PER_ELEMENT+4*Uint8Array.BYTES_PER_ELEMENT,attributes:[{name:"inPosition",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:0},{name:"inTint",size:4,type:t.renderer.gl.UNSIGNED_BYTE,normalized:!0,offset:2*Float32Array.BYTES_PER_ELEMENT}]}),this.vertexViewF32=new Float32Array(this.vertexData),this.vertexViewU32=new Uint32Array(this.vertexData),this.tempTriangle=[{x:0,y:0,width:0,rgb:16777215,alpha:1},{x:0,y:0,width:0,rgb:16777215,alpha:1},{x:0,y:0,width:0,rgb:16777215,alpha:1},{x:0,y:0,width:0,rgb:16777215,alpha:1}],this.polygonCache=[],this.mvpInit()},onBind:function(){return l.prototype.onBind.call(this),this.mvpUpdate(),this},resize:function(t,e,i){return l.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},batchFillRect:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,m,y){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var x=this.vertexViewF32,w=this.vertexViewU32,b=this.vertexCount*this.vertexComponentCount,T=r+a,S=o+h,A=y[0],C=y[1],M=y[2],_=y[3],E=d*A+f*M,P=d*C+f*_,L=p*A+g*M,F=p*C+g*_,k=v*A+m*M+y[4],R=v*C+m*_+y[5],O=r*E+o*L+k,D=r*P+o*F+R,I=r*E+S*L+k,B=r*P+S*F+R,Y=T*E+S*L+k,X=T*P+S*F+R,z=T*E+o*L+k,N=T*P+o*F+R,U=u.getTintAppendFloatAlphaAndSwap(l,c);x[b+0]=O,x[b+1]=D,w[b+2]=U,x[b+3]=I,x[b+4]=B,w[b+5]=U,x[b+6]=Y,x[b+7]=X,w[b+8]=U,x[b+9]=O,x[b+10]=D,w[b+11]=U,x[b+12]=Y,x[b+13]=X,w[b+14]=U,x[b+15]=z,x[b+16]=N,w[b+17]=U,this.vertexCount+=6},batchFillTriangle:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,m,y,x,w){this.renderer.setPipeline(this),this.vertexCount+3>this.vertexCapacity&&this.flush();var b=this.vertexViewF32,T=this.vertexViewU32,S=this.vertexCount*this.vertexComponentCount,A=w[0],C=w[1],M=w[2],_=w[3],E=p*A+g*M,P=p*C+g*_,L=v*A+m*M,F=v*C+m*_,k=y*A+x*M+w[4],R=y*C+x*_+w[5],O=r*E+o*L+k,D=r*P+o*F+R,I=a*E+h*L+k,B=a*P+h*F+R,Y=l*E+c*L+k,X=l*P+c*F+R,z=u.getTintAppendFloatAlphaAndSwap(d,f);b[S+0]=O,b[S+1]=D,T[S+2]=z,b[S+3]=I,b[S+4]=B,T[S+5]=z,b[S+6]=Y,b[S+7]=X,T[S+8]=z,this.vertexCount+=3},batchStrokeTriangle:function(t,e,i,n,s,r,o,a,h,u,l,c,d,f,p,g,v,m,y,x,w){var b=this.tempTriangle;b[0].x=r,b[0].y=o,b[0].width=c,b[0].rgb=d,b[0].alpha=f,b[1].x=a,b[1].y=h,b[1].width=c,b[1].rgb=d,b[1].alpha=f,b[2].x=u,b[2].y=l,b[2].width=c,b[2].rgb=d,b[2].alpha=f,b[3].x=r,b[3].y=o,b[3].width=c,b[3].rgb=d,b[3].alpha=f,this.batchStrokePath(t,e,i,n,s,b,c,d,f,p,g,v,m,y,x,!1,w)},batchFillPath:function(t,e,i,n,s,o,a,h,l,c,d,f,p,g,v){this.renderer.setPipeline(this);for(var m,y,x,w,b,T,S,A,C,M,_,E,P,L,F,k,R,O=o.length,D=this.polygonCache,I=this.vertexViewF32,B=this.vertexViewU32,Y=0,X=v[0],z=v[1],N=v[2],U=v[3],G=l*X+c*N,W=l*z+c*U,V=d*X+f*N,H=d*z+f*U,j=p*X+g*N+v[4],q=p*z+g*U+v[5],K=u.getTintAppendFloatAlphaAndSwap(a,h),J=0;Jthis.vertexCapacity&&this.flush(),Y=this.vertexCount*this.vertexComponentCount,E=(T=D[x+0])*G+(S=D[x+1])*V+j,P=T*W+S*H+q,L=(A=D[w+0])*G+(C=D[w+1])*V+j,F=A*W+C*H+q,k=(M=D[b+0])*G+(_=D[b+1])*V+j,R=M*W+_*H+q,I[Y+0]=E,I[Y+1]=P,B[Y+2]=K,I[Y+3]=L,I[Y+4]=F,B[Y+5]=K,I[Y+6]=k,I[Y+7]=R,B[Y+8]=K,this.vertexCount+=3;D.length=0},batchStrokePath:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,m){var y,x;this.renderer.setPipeline(this);for(var w,b,T,S,A=r.length,C=this.polygonCache,M=this.vertexViewF32,_=this.vertexViewU32,E=u.getTintAppendFloatAlphaAndSwap,P=0;P+1this.vertexCapacity&&this.flush(),w=C[L-1]||C[F-1],b=C[L],M[(T=this.vertexCount*this.vertexComponentCount)+0]=w[6],M[T+1]=w[7],_[T+2]=E(w[8],h),M[T+3]=w[0],M[T+4]=w[1],_[T+5]=E(w[2],h),M[T+6]=b[9],M[T+7]=b[10],_[T+8]=E(b[11],h),M[T+9]=w[0],M[T+10]=w[1],_[T+11]=E(w[2],h),M[T+12]=w[6],M[T+13]=w[7],_[T+14]=E(w[8],h),M[T+15]=b[3],M[T+16]=b[4],_[T+17]=E(b[5],h),this.vertexCount+=6;C.length=0},batchLine:function(t,e,i,n,s,r,o,a,h,l,c,d,f,p,g,v,m,y,x,w,b){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var T=b[0],S=b[1],A=b[2],C=b[3],M=g*T+v*A,_=g*S+v*C,E=m*T+y*A,P=m*S+y*C,L=x*T+w*A+b[4],F=x*S+w*C+b[5],k=this.vertexViewF32,R=this.vertexViewU32,O=a-r,D=h-o,I=Math.sqrt(O*O+D*D),B=l*(h-o)/I,Y=l*(r-a)/I,X=c*(h-o)/I,z=c*(r-a)/I,N=a-X,U=h-z,G=r-B,W=o-Y,V=a+X,H=h+z,j=r+B,q=o+Y,K=N*M+U*E+L,J=N*_+U*P+F,Z=G*M+W*E+L,Q=G*_+W*P+F,$=V*M+H*E+L,tt=V*_+H*P+F,et=j*M+q*E+L,it=j*_+q*P+F,nt=u.getTintAppendFloatAlphaAndSwap,st=nt(d,p),rt=nt(f,p),ot=this.vertexCount*this.vertexComponentCount;return k[ot+0]=K,k[ot+1]=J,R[ot+2]=rt,k[ot+3]=Z,k[ot+4]=Q,R[ot+5]=st,k[ot+6]=$,k[ot+7]=tt,R[ot+8]=rt,k[ot+9]=Z,k[ot+10]=Q,R[ot+11]=st,k[ot+12]=et,k[ot+13]=it,R[ot+14]=st,k[ot+15]=$,k[ot+16]=tt,R[ot+17]=rt,this.vertexCount+=6,[K,J,f,Z,Q,d,$,tt,f,et,it,d]},batchGraphics:function(t,e,i){if(!(t.commandBuffer.length<=0)){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this);var r,o,a,h,u,l,m,y,x=e.scrollX*t.scrollFactorX,w=e.scrollY*t.scrollFactorY,b=t.x,T=t.y,S=t.scaleX,A=t.scaleY,C=t.rotation,M=t.commandBuffer,_=t.alpha,E=1,P=1,L=0,F=0,k=1,R=e.matrix.matrix,O=null,D=0,I=0,B=0,Y=0,X=0,z=0,N=0,U=0,G=0,W=0,V=null,H=Math.sin,j=Math.cos,q=2*Math.PI,K=H(C),J=j(C),Z=J*S,Q=K*S,$=-K*A,tt=J*A,et=b,it=T,nt=R[0],st=R[1],rt=R[2],ot=R[3],at=R[4],ht=R[5];if(n){var ut=n[0],lt=n[1],ct=n[2],dt=n[3],ft=n[4],pt=n[5],gt=-x,vt=-w,mt=ut*nt+lt*rt,yt=ut*st+lt*ot,xt=ct*nt+dt*rt,wt=ct*st+dt*ot;r=Z*mt+Q*xt,o=Z*yt+Q*wt,a=$*mt+tt*xt,h=$*yt+tt*wt,u=et*mt+it*xt+(ft*nt+pt*rt+(gt*nt+vt*rt+at)),l=et*yt+it*wt+(ft*st+pt*ot+(gt*st+vt*ot+ht))}else r=Z*nt+Q*rt,o=Z*st+Q*ot,a=$*nt+tt*rt,h=$*st+tt*ot,u=(et-=x)*nt+(it-=w)*rt+at,l=et*st+it*ot+ht;v.length=0;for(var bt=0,Tt=M.length;bt0&&(G=G%q-q):G>q?G=q:G<0&&(G=q+G%q);D<1;)I=X+j(Y=G*D+U)*N,B=z+H(Y)*N,O.points.push(new c(I,B,k,L,E*_)),D+=.01;I=X+j(Y=G+U)*N,B=z+H(Y)*N,O.points.push(new c(I,B,k,L,E*_)),bt+=6;break;case s.LINE_STYLE:k=M[bt+1],L=M[bt+2],E=M[bt+3],bt+=3;break;case s.FILL_STYLE:F=M[bt+1],P=M[bt+2],bt+=2;break;case s.BEGIN_PATH:v.length=0,O=null;break;case s.CLOSE_PATH:O&&O.points.length&&O.points.push(O.points[0]);break;case s.FILL_PATH:for(m=0,y=v.length;m=0&&n>=0;return r[0]===t&&r[1]===e&&r[2]===i&&r[3]===n||this.flush(),r[0]=t,r[1]=e,r[2]=i,r[3]=n,this.currentScissorEnabled=o,o?(s.disable(s.SCISSOR_TEST),this):(s.enable(s.SCISSOR_TEST),s.scissor(t,s.drawingBufferHeight-e-n,i,n),this)},pushScissor:function(t,e,i,n){var s=this.scissorStack,r=this.currentScissorIdx,o=this.currentScissor;return s[r+0]=o[0],s[r+1]=o[1],s[r+2]=o[2],s[r+3]=o[3],this.currentScissorIdx+=4,this.setScissor(t,e,i,n),this},popScissor:function(){var t=this.scissorStack,e=this.currentScissorIdx-4,i=t[e+0],n=t[e+1],s=t[e+2],r=t[e+3];return this.currentScissorIdx=e,this.setScissor(i,n,s,r),this},setPipeline:function(t){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==s.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t),this},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl;return t!==this.currentFramebuffer&&(this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,n){var o=this.gl,a=o.NEAREST,h=o.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,r(e,i)&&(h=o.REPEAT),n===s.ScaleModes.LINEAR?a=o.LINEAR:(n===s.ScaleModes.NEAREST||this.config.pixelArt)&&(a=o.NEAREST),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,a,h,h,o.RGBA,t):this.createTexture2D(0,a,a,h,h,o.RGBA,null,e,i)},createTexture2D:function(t,e,i,n,s,r,o,a,h,u){var l=this.gl,c=l.createTexture();return u=void 0===u||null===u||u,this.setTexture2D(c,0),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,e),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,i),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,s),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,n),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,u),null===o||void 0===o?l.texImage2D(l.TEXTURE_2D,t,r,a,h,0,r,l.UNSIGNED_BYTE,null):(l.texImage2D(l.TEXTURE_2D,t,r,r,l.UNSIGNED_BYTE,o),a=o.width,h=o.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=u,c.isRenderTexture=!1,c.width=a,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,n){var s,r=this.gl,o=r.createFramebuffer();if(this.setFramebuffer(o),n){var a=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,a),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(s=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[s])}return o.renderTexture=i,this.setFramebuffer(null),o},createProgram:function(t,e){var i=this.gl,n=i.createProgram(),s=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,t),i.shaderSource(r,e),i.compileShader(s),i.compileShader(r),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(s));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(n,s),i.attachShader(n,r),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(n));return n},createVertexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setVertexBuffer(n),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),n},createIndexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setIndexBuffer(n),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),n},deleteTexture:function(t){var e=this.nativeTextures.indexOf(t);return-1!==e&&o(this.nativeTextures,e),this.gl.deleteTexture(t),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=this.config.resolution,i=Math.floor(t.x*e),n=Math.floor(t.y*e),s=Math.floor(t.width*e),r=Math.floor(t.height*e);if(this.pushScissor(i,n,s,r),t.backgroundColor.alphaGL>0){var o=t.backgroundColor,h=this.pipelines.FlatTintPipeline;h.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,a.getTintFromFloats(o.redGL,o.greenGL,o.blueGL,1),o.alphaGL,1,0,0,1,0,0,[1,0,0,1,0,0]),h.flush()}},postRenderCamera:function(t){var e=this.pipelines.FlatTintPipeline,i=t.flashEffect.postRenderWebGL(e,a.getTintFromFloats);(t.fadeEffect.postRenderWebGL(e,a.getTintFromFloats)||i)&&e.flush(),this.popScissor()},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var n in t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),this.config.clearBeforeRender&&t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),i)i[n].onPreRender()}},render:function(t,e,i,n){if(!this.contextLost){var r=e.list,o=r.length,a=this.pipelines;for(var h in a)a[h].onRender(t,n);this.preRenderCamera(n);for(var u=0;u0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(e*e+i*i+n*n+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return e*e+i*i+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,u=a*i+o*e-s*n,l=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+u*-o-l*-r,this.y=u*a+c*-r+l*-s-h*-o,this.z=l*a+c*-o+h*-r-u*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this},zero:function(){var t=this.val;return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,this},xyz:function(t,e,i){this.identity();var n=this.val;return n[12]=t,n[13]=e,n[14]=i,this},scaling:function(t,e,i){this.zero();var n=this.val;return n[0]=t,n[5]=e,n[10]=i,n[15]=1,this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[3],s=t[6],r=t[7],o=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=s,t[11]=t[14],t[12]=n,t[13]=r,t[14]=o,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8],l=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15],m=e*o-i*r,y=e*a-n*r,x=e*h-s*r,w=i*a-n*o,b=i*h-s*o,T=n*h-s*a,S=u*p-l*f,A=u*g-c*f,C=u*v-d*f,M=l*g-c*p,_=l*v-d*p,E=c*v-d*g,P=m*E-y*_+x*M+w*C-b*A+T*S;return P?(P=1/P,t[0]=(o*E-a*_+h*M)*P,t[1]=(n*_-i*E-s*M)*P,t[2]=(p*T-g*b+v*w)*P,t[3]=(c*b-l*T-d*w)*P,t[4]=(a*C-r*E-h*A)*P,t[5]=(e*E-n*C+s*A)*P,t[6]=(g*x-f*T-v*y)*P,t[7]=(u*T-c*x+d*y)*P,t[8]=(r*_-o*C+h*S)*P,t[9]=(i*C-e*_-s*S)*P,t[10]=(f*b-p*x+v*m)*P,t[11]=(l*x-u*b-d*m)*P,t[12]=(o*A-r*M-a*S)*P,t[13]=(e*M-i*A+n*S)*P,t[14]=(p*y-f*w-g*m)*P,t[15]=(u*w-l*y+c*m)*P,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8],l=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return t[0]=o*(c*v-d*g)-l*(a*v-h*g)+p*(a*d-h*c),t[1]=-(i*(c*v-d*g)-l*(n*v-s*g)+p*(n*d-s*c)),t[2]=i*(a*v-h*g)-o*(n*v-s*g)+p*(n*h-s*a),t[3]=-(i*(a*d-h*c)-o*(n*d-s*c)+l*(n*h-s*a)),t[4]=-(r*(c*v-d*g)-u*(a*v-h*g)+f*(a*d-h*c)),t[5]=e*(c*v-d*g)-u*(n*v-s*g)+f*(n*d-s*c),t[6]=-(e*(a*v-h*g)-r*(n*v-s*g)+f*(n*h-s*a)),t[7]=e*(a*d-h*c)-r*(n*d-s*c)+u*(n*h-s*a),t[8]=r*(l*v-d*p)-u*(o*v-h*p)+f*(o*d-h*l),t[9]=-(e*(l*v-d*p)-u*(i*v-s*p)+f*(i*d-s*l)),t[10]=e*(o*v-h*p)-r*(i*v-s*p)+f*(i*h-s*o),t[11]=-(e*(o*d-h*l)-r*(i*d-s*l)+u*(i*h-s*o)),t[12]=-(r*(l*g-c*p)-u*(o*g-a*p)+f*(o*c-a*l)),t[13]=e*(l*g-c*p)-u*(i*g-n*p)+f*(i*c-n*l),t[14]=-(e*(o*g-a*p)-r*(i*g-n*p)+f*(i*a-n*o)),t[15]=e*(o*c-a*l)-r*(i*c-n*l)+u*(i*a-n*o),this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8],l=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return(e*o-i*r)*(c*v-d*g)-(e*a-n*r)*(l*v-d*p)+(e*h-s*r)*(l*g-c*p)+(i*a-n*o)*(u*v-d*f)-(i*h-s*o)*(u*g-c*f)+(n*h-s*a)*(u*p-l*f)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],u=e[7],l=e[8],c=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=t.val,x=y[0],w=y[1],b=y[2],T=y[3];return e[0]=x*i+w*o+b*l+T*p,e[1]=x*n+w*a+b*c+T*g,e[2]=x*s+w*h+b*d+T*v,e[3]=x*r+w*u+b*f+T*m,x=y[4],w=y[5],b=y[6],T=y[7],e[4]=x*i+w*o+b*l+T*p,e[5]=x*n+w*a+b*c+T*g,e[6]=x*s+w*h+b*d+T*v,e[7]=x*r+w*u+b*f+T*m,x=y[8],w=y[9],b=y[10],T=y[11],e[8]=x*i+w*o+b*l+T*p,e[9]=x*n+w*a+b*c+T*g,e[10]=x*s+w*h+b*d+T*v,e[11]=x*r+w*u+b*f+T*m,x=y[12],w=y[13],b=y[14],T=y[15],e[12]=x*i+w*o+b*l+T*p,e[13]=x*n+w*a+b*c+T*g,e[14]=x*s+w*h+b*d+T*v,e[15]=x*r+w*u+b*f+T*m,this},multiplyLocal:function(t){var e=[],i=this.val,n=t.val;return e[0]=i[0]*n[0]+i[1]*n[4]+i[2]*n[8]+i[3]*n[12],e[1]=i[0]*n[1]+i[1]*n[5]+i[2]*n[9]+i[3]*n[13],e[2]=i[0]*n[2]+i[1]*n[6]+i[2]*n[10]+i[3]*n[14],e[3]=i[0]*n[3]+i[1]*n[7]+i[2]*n[11]+i[3]*n[15],e[4]=i[4]*n[0]+i[5]*n[4]+i[6]*n[8]+i[7]*n[12],e[5]=i[4]*n[1]+i[5]*n[5]+i[6]*n[9]+i[7]*n[13],e[6]=i[4]*n[2]+i[5]*n[6]+i[6]*n[10]+i[7]*n[14],e[7]=i[4]*n[3]+i[5]*n[7]+i[6]*n[11]+i[7]*n[15],e[8]=i[8]*n[0]+i[9]*n[4]+i[10]*n[8]+i[11]*n[12],e[9]=i[8]*n[1]+i[9]*n[5]+i[10]*n[9]+i[11]*n[13],e[10]=i[8]*n[2]+i[9]*n[6]+i[10]*n[10]+i[11]*n[14],e[11]=i[8]*n[3]+i[9]*n[7]+i[10]*n[11]+i[11]*n[15],e[12]=i[12]*n[0]+i[13]*n[4]+i[14]*n[8]+i[15]*n[12],e[13]=i[12]*n[1]+i[13]*n[5]+i[14]*n[9]+i[15]*n[13],e[14]=i[12]*n[2]+i[13]*n[6]+i[14]*n[10]+i[15]*n[14],e[15]=i[12]*n[3]+i[13]*n[7]+i[14]*n[11]+i[15]*n[15],this.fromArray(e)},translate:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[12]=s[0]*e+s[4]*i+s[8]*n+s[12],s[13]=s[1]*e+s[5]*i+s[9]*n+s[13],s[14]=s[2]*e+s[6]*i+s[10]*n+s[14],s[15]=s[3]*e+s[7]*i+s[11]*n+s[15],this},scale:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[0]=s[0]*e,s[1]=s[1]*e,s[2]=s[2]*e,s[3]=s[3]*e,s[4]=s[4]*i,s[5]=s[5]*i,s[6]=s[6]*i,s[7]=s[7]*i,s[8]=s[8]*n,s[9]=s[9]*n,s[10]=s[10]*n,s[11]=s[11]*n,this},makeRotationAxis:function(t,e){var i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,a=t.z,h=s*r,u=s*o;return this.fromArray([h*r+i,h*o-n*a,h*a+n*o,0,h*o+n*a,u*o+i,u*a-n*r,0,h*a-n*o,u*a+n*r,s*a*a+i,0,0,0,0,1]),this},rotate:function(t,e){var i=this.val,n=e.x,s=e.y,r=e.z,o=Math.sqrt(n*n+s*s+r*r);if(Math.abs(o)<1e-6)return null;n*=o=1/o,s*=o,r*=o;var a=Math.sin(t),h=Math.cos(t),u=1-h,l=i[0],c=i[1],d=i[2],f=i[3],p=i[4],g=i[5],v=i[6],m=i[7],y=i[8],x=i[9],w=i[10],b=i[11],T=n*n*u+h,S=s*n*u+r*a,A=r*n*u-s*a,C=n*s*u-r*a,M=s*s*u+h,_=r*s*u+n*a,E=n*r*u+s*a,P=s*r*u-n*a,L=r*r*u+h;return i[0]=l*T+p*S+y*A,i[1]=c*T+g*S+x*A,i[2]=d*T+v*S+w*A,i[3]=f*T+m*S+b*A,i[4]=l*C+p*M+y*_,i[5]=c*C+g*M+x*_,i[6]=d*C+v*M+w*_,i[7]=f*C+m*M+b*_,i[8]=l*E+p*P+y*L,i[9]=c*E+g*P+x*L,i[10]=d*E+v*P+w*L,i[11]=f*E+m*P+b*L,this},rotateX:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],u=e[9],l=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+u*i,e[6]=o*n+l*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=u*n-r*i,e[10]=l*n-o*i,e[11]=c*n-a*i,this},rotateY:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],u=e[9],l=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-u*i,e[2]=o*n-l*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+u*n,e[10]=o*i+l*n,e[11]=a*i+c*n,this},rotateZ:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],u=e[5],l=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+u*i,e[2]=o*n+l*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=u*n-r*i,e[6]=l*n-o*i,e[7]=c*n-a*i,this},fromRotationTranslation:function(t,e){var i=this.val,n=t.x,s=t.y,r=t.z,o=t.w,a=n+n,h=s+s,u=r+r,l=n*a,c=n*h,d=n*u,f=s*h,p=s*u,g=r*u,v=o*a,m=o*h,y=o*u;return i[0]=1-(f+g),i[1]=c+y,i[2]=d-m,i[3]=0,i[4]=c-y,i[5]=1-(l+g),i[6]=p+v,i[7]=0,i[8]=d+m,i[9]=p-v,i[10]=1-(l+f),i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},fromQuat:function(t){var e=this.val,i=t.x,n=t.y,s=t.z,r=t.w,o=i+i,a=n+n,h=s+s,u=i*o,l=i*a,c=i*h,d=n*a,f=n*h,p=s*h,g=r*o,v=r*a,m=r*h;return e[0]=1-(d+p),e[1]=l+m,e[2]=c-v,e[3]=0,e[4]=l-m,e[5]=1-(u+p),e[6]=f+g,e[7]=0,e[8]=c+v,e[9]=f-g,e[10]=1-(u+d),e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},frustum:function(t,e,i,n,s,r){var o=this.val,a=1/(e-t),h=1/(n-i),u=1/(s-r);return o[0]=2*s*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2*s*h,o[6]=0,o[7]=0,o[8]=(e+t)*a,o[9]=(n+i)*h,o[10]=(r+s)*u,o[11]=-1,o[12]=0,o[13]=0,o[14]=r*s*2*u,o[15]=0,this},perspective:function(t,e,i,n){var s=this.val,r=1/Math.tan(t/2),o=1/(i-n);return s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+i)*o,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*i*o,s[15]=0,this},perspectiveLH:function(t,e,i,n){var s=this.val;return s[0]=2*i/t,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*i/e,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=-n/(i-n),s[11]=1,s[12]=0,s[13]=0,s[14]=i*n/(i-n),s[15]=0,this},ortho:function(t,e,i,n,s,r){var o=this.val,a=t-e,h=i-n,u=s-r;return a=0===a?a:1/a,h=0===h?h:1/h,u=0===u?u:1/u,o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*u,o[11]=0,o[12]=(t+e)*a,o[13]=(n+i)*h,o[14]=(r+s)*u,o[15]=1,this},lookAt:function(t,e,i){var n=this.val,s=t.x,r=t.y,o=t.z,a=i.x,h=i.y,u=i.z,l=e.x,c=e.y,d=e.z;if(Math.abs(s-l)<1e-6&&Math.abs(r-c)<1e-6&&Math.abs(o-d)<1e-6)return this.identity();var f=s-l,p=r-c,g=o-d,v=1/Math.sqrt(f*f+p*p+g*g),m=h*(g*=v)-u*(p*=v),y=u*(f*=v)-a*g,x=a*p-h*f;(v=Math.sqrt(m*m+y*y+x*x))?(m*=v=1/v,y*=v,x*=v):(m=0,y=0,x=0);var w=p*x-g*y,b=g*m-f*x,T=f*y-p*m;return(v=Math.sqrt(w*w+b*b+T*T))?(w*=v=1/v,b*=v,T*=v):(w=0,b=0,T=0),n[0]=m,n[1]=w,n[2]=f,n[3]=0,n[4]=y,n[5]=b,n[6]=p,n[7]=0,n[8]=x,n[9]=T,n[10]=g,n[11]=0,n[12]=-(m*s+y*r+x*o),n[13]=-(w*s+b*r+T*o),n[14]=-(f*s+p*r+g*o),n[15]=1,this},yawPitchRoll:function(t,e,i){this.zero(),s.zero(),r.zero();var n=this.val,o=s.val,a=r.val,h=Math.sin(i),u=Math.cos(i);return n[10]=1,n[15]=1,n[0]=u,n[1]=h,n[4]=-h,n[5]=u,h=Math.sin(e),u=Math.cos(e),o[0]=1,o[15]=1,o[5]=u,o[10]=u,o[9]=-h,o[6]=h,h=Math.sin(t),u=Math.cos(t),a[5]=1,a[15]=1,a[0]=u,a[2]=-h,a[8]=h,a[10]=u,this.multiplyLocal(s),this.multiplyLocal(r),this},setWorldMatrix:function(t,e,i,n,o){return this.yawPitchRoll(t.y,t.x,t.z),s.scaling(i.x,i.y,i.z),r.xyz(e.x,e.y,e.z),this.multiplyLocal(s),this.multiplyLocal(r),void 0!==n&&this.multiplyLocal(n),void 0!==o&&this.multiplyLocal(o),this}}),s=new n,r=new n;t.exports=n},function(t,e,i){var n=i(0),s=i(278),r=i(561),o=i(560),a=i(559),h=i(70),u=i(151),l=i(6),c=i(87),d=i(277),f=new c,p=new d,g=new c,v=new c,m=new s,y=new n({initialize:function(t){this.scene=t,this.displayList=t.sys.displayList,this.updateList=t.sys.updateList,this.name="",this.direction=new c(0,0,-1),this.up=new c(0,1,0),this.position=new c,this.pixelScale=128,this.projection=new s,this.view=new s,this.combined=new s,this.invProjectionView=new s,this.near=1,this.far=100,this.ray={origin:new c,direction:new c},this.viewportWidth=0,this.viewportHeight=0,this.billboardMatrixDirty=!0,this.children=new h},setPosition:function(t,e,i){return this.position.set(t,e,i),this.update()},setScene:function(t){return this.scene=t,this},setPixelScale:function(t){return this.pixelScale=t,this.update()},add:function(t){return this.children.set(t),this.updateChildren(),t},remove:function(t){return this.displayList.remove(t.gameObject),this.updateList.remove(t.gameObject),this.children.delete(t),this},clear:function(){for(var t=this.getChildren(),e=0;e16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var n=i(30),s=i(282);t.exports=function(t){var e=s(t);return new n(e.r,e.g,e.b,e.a)}},function(t,e){t.exports=function(t,e,i,n){return n<<24|t<<16|e<<8|i}},function(t,e,i){var n=i(30);t.exports=function(t){var e=new n;t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,n){return e+e+i+i+n+n});var i=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(i){var s=parseInt(i[1],16),r=parseInt(i[2],16),o=parseInt(i[3],16);e.setTo(s,r,o)}return e}},function(t,e){t.exports=function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}},function(t,e){t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)}},function(t,e){t.exports=function(t,e,i,n,s){var r=n+Math.atan2(t.y-i,t.x-e);return t.x=e+s*Math.cos(r),t.y=i+s*Math.sin(r),t}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);for(var i=null,n=0;n>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e0;i--){var n=Math.floor(this.frac()*(e+1)),s=t[n];t[n]=t[i],t[i]=s}return t}});t.exports=n},function(t,e,i){var n=i(136),s=i(65),r=i(16),o=i(5);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=s(e,0,r.PI2);return n(t,a,i)}},function(t,e){t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},,,function(t,e,i){var n=new(i(0))({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.once("remove",this.remove,this),this.isPlaying=!1,this.currentAnim=null,this.currentFrame=null,this._timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this._delay=0,this._repeat=0,this._repeatDelay=0,this._yoyo=!1,this.forward=!0,this.accumulator=0,this.nextTick=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._pendingStop=0,this._pendingStopValue},setDelay:function(t){return void 0===t&&(t=0),this._delay=t,this.parent},getDelay:function(){return this._delay},delayedPlay:function(t,e,i){return this.play(e,!0,i),this.nextTick+=t,this.parent},getCurrentKey:function(){if(this.currentAnim)return this.currentAnim.key},load:function(t,e){return void 0===e&&(e=0),this.isPlaying&&this.stop(),this.animationManager.load(this,t,e),this.parent},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.updateFrame(t),this.parent},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.updateFrame(t),this.parent},isPaused:{get:function(){return this._paused}},play:function(t,e,i){if(void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t)return this.parent;this.load(t,i);var n=this.currentAnim,s=this.parent;return this.repeatCounter=-1===this._repeat?Number.MAX_VALUE:this._repeat,n.getFirstTick(this),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,n.showOnStart&&(s.visible=!0),s.emit("animationstart",this.currentAnim,this.currentFrame),s},getProgress:function(){var t=this.currentFrame.progress;return this.forward||(t=1-t),t},setProgress:function(t){return this.forward||(t=1-t),this.setCurrentFrame(this.currentAnim.getFrameByProgress(t)),this.parent},remove:function(t,e){void 0===e&&(e=this.currentAnim),this.isPlaying&&e.key===this.currentAnim.key&&(this.stop(),this.setCurrentFrame(this.currentAnim.frames[0]))},getRepeat:function(){return this._repeat},setRepeat:function(t){return this._repeat=t,this.repeatCounter=0,this.parent},getRepeatDelay:function(){return this._repeatDelay},setRepeatDelay:function(t){return this._repeatDelay=t,this.parent},restart:function(t){return void 0===t&&(t=!1),this.currentAnim.getFirstTick(this,t),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,this._paused=!1,this.updateFrame(this.currentAnim.frames[0]),this.parent},stop:function(){this._pendingStop=0,this.isPlaying=!1;var t=this.parent;return t.emit("animationcomplete",this.currentAnim,this.currentFrame),t},stopAfterDelay:function(t){return this._pendingStop=1,this._pendingStopValue=t,this.parent},stopOnRepeat:function(){return this._pendingStop=2,this.parent},stopOnFrame:function(t){return this._pendingStop=3,this._pendingStopValue=t,this.parent},setTimeScale:function(t){return void 0===t&&(t=1),this._timeScale=t,this.parent},getTimeScale:function(){return this._timeScale},getTotalFrames:function(){return this.currentAnim.frames.length},update:function(t,e){if(this.currentAnim&&this.isPlaying&&!this.currentAnim.paused){if(this.accumulator+=e*this._timeScale,1===this._pendingStop&&(this._pendingStopValue-=e,this._pendingStopValue<=0))return this.currentAnim.completeAnimation(this);this.accumulator>=this.nextTick&&this.currentAnim.setFrame(this)}},setCurrentFrame:function(t){var e=this.parent;return this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,e.setSizeToFrame(),t.frame.customPivot?e.setOrigin(t.frame.pivotX,t.frame.pivotY):e.updateDisplayOrigin(),e},updateFrame:function(t){var e=this.setCurrentFrame(t);if(this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;e.emit("animationupdate",i,t),3===this._pendingStop&&this._pendingStopValue===t&&this.currentAnim.completeAnimation(this)}},setYoyo:function(t){return void 0===t&&(t=!1),this._yoyo=t,this.parent},getYoyo:function(){return this._yoyo},destroy:function(){this.animationManager.off("remove",this.remove,this),this.animationManager=null,this.parent=null,this.currentAnim=null,this.currentFrame=null}});t.exports=n},function(t,e,i){var n=i(0),s=i(161),r=i(12),o=i(160),a=i(61),h=i(72),u=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this.timeScale=1,this._add=[],this._pending=[],this._active=[],this._destroy=[],this._toProcess=0,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.systems.events.once("destroy",this.destroy,this)},start:function(){var t=this.systems.events;t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this),this.timeScale=1},createTimeline:function(t){return o(this,t)},timeline:function(t){var e=o(this,t);return e.paused||(this._add.push(e),this._toProcess++),e},create:function(t){return h(this,t)},add:function(t){var e=h(this,t);return this._add.push(e),this._toProcess++,e},existing:function(t){return this._add.push(t),this._toProcess++,this},addCounter:function(t){var e=s(this,t);return this._add.push(e),this._toProcess++,e},preUpdate:function(){if(0!==this._toProcess){var t,e,i=this._destroy,n=this._active;for(t=0;t-1&&this._active.splice(s,1),n.destroy()}for(i=0;i=n.delay)){var s=n.elapsed-n.delay;n.elapsed=n.delay,!n.hasDispatched&&n.callback&&(n.hasDispatched=!0,n.callback.apply(n.callbackScope,n.args)),n.repeatCount>0?(n.repeatCount--,n.elapsed=s,n.hasDispatched=!1):this._pendingRemoval.push(n)}}}},shutdown:function(){var t;for(t=0;ta&&(a=e.layer[u].width),e.layer[u].height>h&&(h=e.layer[u].height);var l=new s({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:n.WELTMEISTER});return l.layers=r(e,i),l.tilesets=o(e),l}},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","object layer"),this.opacity=s(t,"opacity",1),this.properties=s(t,"properties",{}),this.propertyTypes=s(t,"propertytypes",{}),this.type=s(t,"type","objectgroup"),this.visible=s(t,"visible",!0),this.objects=s(t,"objects",[])}});t.exports=r},function(t,e,i){var n=i(633),s=i(316),r=function(t){return{x:t.x,y:t.y}},o=["id","name","type","rotation","properties","visible","x","y","width","height"];t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var a=n(t,o);if(a.x+=e,a.y+=i,t.gid){var h=s(t.gid);a.gid=h.gid,a.flippedHorizontal=h.flippedHorizontal,a.flippedVertical=h.flippedVertical,a.flippedAntiDiagonal=h.flippedAntiDiagonal}else t.polyline?a.polyline=t.polyline.map(r):t.polygon?a.polygon=t.polygon.map(r):t.ellipse?(a.ellipse=t.ellipse,a.width=t.width,a.height=t.height):t.text?(a.width=t.width,a.height=t.height,a.text=t.text):(a.rectangle=!0,a.width=t.width,a.height=t.height);return a}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|n,this.imageMargin=0|s,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&t-1}return!1}},function(t,e,i){var n=i(21);t.exports=function(t,e,i,s,r,o,a){for(var h=n(i,s,r,o,null,a),u=0;u=this._duration&&this.transitionComplete()},transitionComplete:function(){var t=this._target.sys,e=this._target.sys.settings;this.systems.events.off("update",this.step,this),t.events.emit("transitioncomplete",this.scene),e.isTransition=!1,e.transitionFrom=null,this._duration=0,this._target=null,this._onUpdate=null,this._onUpdateScope=null,this._willRemove?this.manager.remove(this.key):this._willSleep?this.systems.sleep():this.manager.stop(this.key)},add:function(t,e,i){return this.manager.add(t,e,i),this},launch:function(t,e){return t&&t!==this.key&&(this.settings.status!==r.RUNNING?this.manager.queueOp("start",t,e):this.manager.start(t,e)),this},run:function(t,e){return this.settings.status!==r.RUNNING?this.manager.queueOp("run",t,e):this.manager.run(t,e),this},pause:function(t){return void 0===t&&(t=this.key),this.manager.pause(t),this},resume:function(t){return void 0===t&&(t=this.key),this.manager.resume(t),this},sleep:function(t){return void 0===t&&(t=this.key),this.manager.sleep(t),this},wake:function(t){return void 0===t&&(t=this.key),this.manager.wake(t),this},switch:function(t){return t!==this.key&&(this.settings.status!==r.RUNNING?this.manager.queueOp("switch",this.key,t):this.manager.switch(this.key,t)),this},stop:function(t){return void 0===t&&(t=this.key),this.manager.stop(t),this},setActive:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setActive(t),this},setVisible:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setVisible(t),this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},getIndex:function(t){return void 0===t&&(t=this.key),this.manager.getIndex(t)},shutdown:function(){var t=this.systems.events;t.off("shutdown",this.shutdown,this),t.off("postupdate",this.step,this),t.off("transitionout")},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null,this.settings=null,this.manager=null}});a.register("ScenePlugin",h,"scenePlugin"),t.exports=h},function(t,e,i){var n=i(55),s=i(17),r={SceneManager:i(194),ScenePlugin:i(327),Settings:i(192),Systems:i(118)};r=s(!1,r,n),t.exports=r},function(t,e,i){var n=i(165),s=new(i(0))({Extends:n,initialize:function(t,e){n.call(this,e),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this)},boot:function(){}});t.exports=s},function(t,e,i){t.exports={BasePlugin:i(165),DefaultPlugins:i(121),PluginCache:i(12),PluginManager:i(196),ScenePlugin:i(329)}},,,,function(t,e,i){var n=i(32),s=i(0),r=i(42),o=i(31),a=i(6),h=new s({initialize:function(t,e){var i=e.width?e.width:64,n=e.height?e.height:64;this.world=t,this.gameObject=e,this.debugShowBody=t.defaults.debugShowStaticBody,this.debugBodyColor=t.defaults.staticBodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new a,this.position=new a(e.x-e.displayOriginX,e.y-e.displayOriginY),this.width=i,this.height=n,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center=new a(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=a.ZERO,this.allowGravity=!1,this.gravity=a.ZERO,this.bounce=a.ZERO,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.mass=1,this.immovable=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.physicsType=r.STATIC_BODY,this._dx=0,this._dy=0},setGameObject:function(t,e){return t&&t!==this.gameObject&&(this.gameObject.body=null,t.body=this,this.gameObject=t),e&&this.updateFromGameObject(),this},updateFromGameObject:function(){this.world.staticTree.remove(this);var t=this.gameObject;return t.getTopLeft(this.position),this.width=t.displayWidth,this.height=t.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.world.staticTree.insert(this),this},setOffset:function(t,e){return void 0===e&&(e=t),this.world.staticTree.remove(this),this.position.x-=this.offset.x,this.position.y-=this.offset.y,this.offset.set(t,e),this.position.x+=this.offset.x,this.position.y+=this.offset.y,this.updateCenter(),this.world.staticTree.insert(this),this},setSize:function(t,e,i,n){return void 0===i&&(i=this.offset.x),void 0===n&&(n=this.offset.y),this.world.staticTree.remove(this),this.width=t,this.height=e,this.halfWidth=Math.floor(t/2),this.halfHeight=Math.floor(e/2),this.offset.set(i,n),this.updateCenter(),this.isCircle=!1,this.radius=0,this.world.staticTree.insert(this),this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):o(this,t,e)},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},function(t,e){t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},function(t,e,i){var n=i(42);t.exports=function(t,e,i,s){var r=0,o=t.deltaAbsY()+e.deltaAbsY()+s;return 0===t._dy&&0===e._dy?(t.embedded=!0,e.embedded=!0):t._dy>e._dy?(r=t.bottom-e.y)>o&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?r=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.down=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.up=!0)):t._dyo&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?r=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.up=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.down=!0))),t.overlapY=r,e.overlapY=r,r}},function(t,e,i){var n=i(42);t.exports=function(t,e,i,s){var r=0,o=t.deltaAbsX()+e.deltaAbsX()+s;return 0===t._dx&&0===e._dx?(t.embedded=!0,e.embedded=!0):t._dx>e._dx?(r=t.right-e.x)>o&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?r=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.right=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.left=!0)):t._dxo&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?r=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.left=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.right=!0))),t.overlapX=r,e.overlapX=r,r}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=n,this.collideCallback=s,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=n},function(t,e,i){var n=i(32),s=i(0),r=i(42),o=i(150),a=i(14),h=i(31),u=i(64),l=i(6),c=new s({initialize:function(t,e){var i=e.width?e.width:64,n=e.height?e.height:64;this.world=t,this.gameObject=e,this.transform={x:e.x,y:e.y,rotation:e.angle,scaleX:e.scaleX,scaleY:e.scaleY,displayOriginX:e.displayOriginX,displayOriginY:e.displayOriginY},this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new l,this.position=new l(e.x,e.y),this.prev=new l(e.x,e.y),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=i,this.height=n,this.sourceWidth=i,this.sourceHeight=n,e.frame&&(this.sourceWidth=e.frame.realWidth,this.sourceHeight=e.frame.realHeight),this.halfWidth=Math.abs(i/2),this.halfHeight=Math.abs(n/2),this.center=new l(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=new l,this.newVelocity=new l,this.deltaMax=new l,this.acceleration=new l,this.allowDrag=!0,this.drag=new l,this.allowGravity=!0,this.gravity=new l,this.bounce=new l,this.worldBounce=null,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.maxVelocity=new l(1e4,1e4),this.friction=new l(1,0),this.useDamping=!1,this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=r.FACING_NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.physicsType=r.DYNAMIC_BODY,this._reset=!0,this._sx=e.scaleX,this._sy=e.scaleY,this._dx=0,this._dy=0,this._bounds=new a,this._tempMatrix=new u},updateBounds:function(){var t=this.gameObject,e=this.transform;if(t.parentContainer){var i=t.getWorldTransformMatrix(this._tempMatrix);e.x=i.tx,e.y=i.ty,e.rotation=o(i.rotation),e.scaleX=i.scaleX,e.scaleY=i.scaleY}else e.x=t.x,e.y=t.y,e.rotation=t.angle,e.scaleX=t.scaleX,e.scaleY=t.scaleY;var n=!1;if(this.syncBounds){var s=t.getBounds(this._bounds);this.width=s.width,this.height=s.height,n=!0}else{var r=Math.abs(e.scaleX),a=Math.abs(e.scaleY);this._sx===r&&this._sy===a||(this.width=this.sourceWidth*r,this.height=this.sourceHeight*a,this._sx=r,this._sy=a,n=!0)}n&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},update:function(t){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds();var e=this.transform;if(this.position.x=e.x+e.scaleX*(this.offset.x-e.displayOriginX),this.position.y=e.y+e.scaleY*(this.offset.y-e.displayOriginY),this.updateCenter(),this.rotation=e.rotation,this.preRotation=this.rotation,this._reset&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves){this.world.updateMotion(this,t);var i=this.velocity.x,n=this.velocity.y;this.newVelocity.set(i*t,n*t),this.position.add(this.newVelocity),this.updateCenter(),this.angle=Math.atan2(n,i),this.speed=Math.sqrt(i*i+n*n),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.world.emit("worldbounds",this,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)}this._dx=this.deltaX(),this._dy=this.deltaY()},postUpdate:function(){this._dx=this.deltaX(),this._dy=this.deltaY(),this.moves&&(0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.gameObject.x+=this._dx,this.gameObject.y+=this._dy,this._reset=!0),this._dx<0?this.facing=r.FACING_LEFT:this._dx>0&&(this.facing=r.FACING_RIGHT),this._dy<0?this.facing=r.FACING_UP:this._dy>0&&(this.facing=r.FACING_DOWN),this.allowRotation&&(this.gameObject.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y},checkWorldBounds:function(){var t=this.position,e=this.world.bounds,i=this.world.checkCollision,n=this.worldBounce?-this.worldBounce.x:-this.bounce.x,s=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=n,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=s,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setSize:function(t,e,i){void 0===i&&(i=!0);var n=this.gameObject;if(this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&n.getCenter){var s=n.displayWidth/2,r=n.displayHeight/2;this.offset.set(s-this.halfWidth,r-this.halfHeight)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i.setPosition(t,e),i.getTopLeft(this.position),this.prev.copy(this.position),this.rotation=i.angle,this.preRotation=i.angle,this.updateBounds(),this.updateCenter()},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):h(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this._dx>0?this._dx:-this._dx},deltaAbsY:function(){return this._dy>0?this._dy:-this._dy},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,n=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor),this.isCircle?t.strokeCircle(i,n,this.width/2):t.strokeRect(e.x,e.y,this.width,this.height)),this.debugShowVelocity&&(t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.velocity.x/2,n+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t){return void 0===t&&(t=!0),this.collideWorldBounds=t,this},setVelocity:function(t,e){return this.velocity.set(t,e),this},setVelocityX:function(t){return this.velocity.x=t,this},setVelocityY:function(t){return this.velocity.y=t,this},setMaxVelocity:function(t,e){return this.maxVelocity.set(t,e),this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setAllowDrag:function(t){return void 0===t&&(t=!0),this.allowDrag=t,this},setAllowGravity:function(t){return void 0===t&&(t=!0),this.allowGravity=t,this},setAllowRotation:function(t){return void 0===t&&(t=!0),this.allowRotation=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return void 0===t&&(t=!0),this.immovable=t,this},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=c},function(t,e,i){var n=i(339),s=i(23),r=i(0),o=i(338),a=i(42),h=i(58),u=i(9),l=i(351),c=i(350),d=i(349),f=i(337),p=i(336),g=i(4),v=i(223),m=i(689),y=i(14),x=i(222),w=i(688),b=i(683),T=i(682),S=i(70),A=i(334),C=i(335),M=i(6),_=i(39),E=new r({Extends:u,initialize:function(t,e){u.call(this),this.scene=t,this.bodies=new S,this.staticBodies=new S,this.pendingDestroy=new S,this.colliders=new v,this.gravity=new M(g(e,"gravity.x",0),g(e,"gravity.y",0)),this.bounds=new y(g(e,"x",0),g(e,"y",0),g(e,"width",t.sys.game.config.width),g(e,"height",t.sys.game.config.height)),this.checkCollision={up:g(e,"checkCollision.up",!0),down:g(e,"checkCollision.down",!0),left:g(e,"checkCollision.left",!0),right:g(e,"checkCollision.right",!0)},this.fps=g(e,"fps",60),this._elapsed=0,this._frameTime=1/this.fps,this._frameTimeMS=1e3*this._frameTime,this.stepsLastFrame=0,this.timeScale=g(e,"timeScale",1),this.OVERLAP_BIAS=g(e,"overlapBias",4),this.TILE_BIAS=g(e,"tileBias",16),this.forceX=g(e,"forceX",!1),this.isPaused=g(e,"isPaused",!1),this._total=0,this.drawDebug=g(e,"debug",!1),this.debugGraphic,this.defaults={debugShowBody:g(e,"debugShowBody",!0),debugShowStaticBody:g(e,"debugShowStaticBody",!0),debugShowVelocity:g(e,"debugShowVelocity",!0),bodyDebugColor:g(e,"debugBodyColor",16711935),staticBodyDebugColor:g(e,"debugStaticBodyColor",255),velocityDebugColor:g(e,"debugVelocityColor",65280)},this.maxEntries=g(e,"maxEntries",16),this.useTree=g(e,"useTree",!0),this.tree=new x(this.maxEntries),this.staticTree=new x(this.maxEntries),this.treeMinMax={minX:0,minY:0,maxX:0,maxY:0},this.drawDebug&&this.createDebugGraphic()},enable:function(t,e){void 0===e&&(e=a.DYNAMIC_BODY),Array.isArray(t)||(t=[t]);for(var i=0;i=s;)this._elapsed-=s,i++,this.step(n);this.stepsLastFrame=i}},step:function(t){var e,i,n=this.bodies.entries,s=n.length;for(e=0;e0){var u=this.tree,l=this.staticTree;for(o=(r=s.entries).length,t=0;ta.bottom)&&(h.xa.right))return this.separateCircle(t,e,s)}var u=!1,l=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)u.right&&(a=h(l.x,l.y,u.right,u.y)-l.radius):l.y>u.bottom&&(l.xu.right&&(a=h(l.x,l.y,u.right,u.bottom)-l.radius)),a*=-1}else a=t.halfWidth+e.halfWidth-h(t.center.x,t.center.y,e.center.x,e.center.y);if(i||0===a||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==a&&(t.onOverlap||e.onOverlap)&&this.emit("overlap",t.gameObject,e.gameObject,t,e),0!==a;var c=t.velocity.x,d=t.velocity.y,g=t.mass,v=e.velocity.x,m=e.velocity.y,y=e.mass,x=c*Math.cos(o)+d*Math.sin(o),w=c*Math.sin(o)-d*Math.cos(o),b=v*Math.cos(o)+m*Math.sin(o),T=v*Math.sin(o)-m*Math.cos(o),S=((g-y)*x+2*y*b)/(g+y),A=(2*g*x+(y-g)*b)/(g+y);t.immovable||(t.velocity.x=(S*Math.cos(o)-w*Math.sin(o))*t.bounce.x,t.velocity.y=(w*Math.cos(o)+S*Math.sin(o))*t.bounce.y,c=t.velocity.x,d=t.velocity.y),e.immovable||(e.velocity.x=(A*Math.cos(o)-T*Math.sin(o))*e.bounce.x,e.velocity.y=(T*Math.cos(o)+A*Math.sin(o))*e.bounce.y,v=e.velocity.x,m=e.velocity.y),Math.abs(o)0&&!t.immovable&&v>c?t.velocity.x*=-1:v<0&&!e.immovable&&c0&&!t.immovable&&m>d?t.velocity.y*=-1:m<0&&!e.immovable&&dMath.PI/2&&(c<0&&!t.immovable&&v0&&!e.immovable&&c>v?e.velocity.x*=-1:d<0&&!t.immovable&&m0&&!e.immovable&&c>m&&(e.velocity.y*=-1));var C=this._frameTime;return t.immovable||(t.x+=t.velocity.x*C-a*Math.cos(o),t.y+=t.velocity.y*C-a*Math.sin(o)),e.immovable||(e.x+=e.velocity.x*C+a*Math.cos(o),e.y+=e.velocity.y*C+a*Math.sin(o)),(t.onCollide||e.onCollide)&&this.emit("collide",t.gameObject,e.gameObject,t,e),!0},intersects:function(t,e){return t!==e&&(t.isCircle||e.isCircle?t.isCircle?e.isCircle?h(t.center.x,t.center.y,e.center.x,e.center.y)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):this.circleBodyIntersects(e,t):!(t.right<=e.position.x||t.bottom<=e.position.y||t.position.x>=e.right||t.position.y>=e.bottom))},circleBodyIntersects:function(t,e){var i=s(t.center.x,e.left,e.right),n=s(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!0)},collide:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!1)},collideObjects:function(t,e,i,n,s,r){var o;t.isParent&&void 0===t.physicsType&&(t=t.children.entries),e&&e.isParent&&void 0===e.physicsType&&(e=e.children.entries);var a=Array.isArray(t),h=Array.isArray(e);if(this._total=0,a||h)if(!a&&h)for(o=0;o0},collideHandler:function(t,e,i,n,s,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,n,s,r);if(!t||!e)return!1;if(t.body){if(e.body)return this.collideSpriteVsSprite(t,e,i,n,s,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,n,s,r)}else if(t.isParent){if(e.body)return this.collideSpriteVsGroup(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,n,s,r)}else if(t.isTilemap){if(e.body)return this.collideSpriteVsTilemapLayer(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,n,s,r)}},collideSpriteVsSprite:function(t,e,i,n,s,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,n,s,r)&&(i&&i.call(s,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,n,s,r){var o,h,u,l=t.body;if(0!==e.length&&l&&l.enable)if(this.useTree){var c=this.treeMinMax;c.minX=l.left,c.minY=l.top,c.maxX=l.right,c.maxY=l.bottom;var d=e.physicsType===a.DYNAMIC_BODY?this.tree.search(c):this.staticTree.search(c);for(h=d.length,o=0;oc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,u+=d}c.tileHeight>c.baseTileHeight&&(l+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f,p=e.getTilesWithinWorldXY(a,h,u,l);if(0===p.length)return!1;for(var g={left:0,right:0,top:0,bottom:0},v=0;ve-i}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)=0?t:t+2*Math.PI}},function(t,e,i){var n=i(0),s=i(18),r=i(70),o=i(9),a=i(7),h=i(1),u=i(12),l=i(75),c=new n({Extends:o,initialize:function(t){o.call(this);var e=t.sys.game.config,i=t.sys.settings.loader;this.scene=t,this.systems=t.sys,this.cacheManager=t.sys.cache,this.textureManager=t.sys.textures,a.install(this),this.prefix="",this.path="",this.baseURL="",this.setBaseURL(h(i,"baseURL",e.loaderBaseURL)),this.setPath(h(i,"path",e.loaderPath)),this.setPrefix(h(i,"prefix",e.loaderPrefix)),this.maxParallelDownloads=h(i,"maxParallelDownloads",e.loaderMaxParallelDownloads),this.xhr=l(h(i,"responseType",e.loaderResponseType),h(i,"async",e.loaderAsync),h(i,"user",e.loaderUser),h(i,"password",e.loaderPassword),h(i,"timeout",e.loaderTimeout)),this.crossOrigin=h(i,"crossOrigin",e.loaderCrossOrigin),this.totalToLoad=0,this.progress=0,this.list=new r,this.inflight=new r,this.queue=new r,this._deleteQueue=new r,this.totalFailed=0,this.totalComplete=0,this.state=s.LOADER_IDLE,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.pluginStart,this)},boot:function(){this.systems.events.once("destroy",this.destroy,this)},pluginStart:function(){this.systems.events.once("shutdown",this.shutdown,this)},setBaseURL:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.baseURL=t,this},setPath:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.path=t,this},setPrefix:function(t){return void 0===t&&(t=""),this.prefix=t,this},setCORS:function(t){return this.crossOrigin=t,this},addFile:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e0},isLoading:function(){return this.state===s.LOADER_LOADING||this.state===s.LOADER_PROCESSING},isReady:function(){return this.state===s.LOADER_IDLE||this.state===s.LOADER_COMPLETE},start:function(){this.isReady()&&(this.progress=0,this.totalFailed=0,this.totalComplete=0,this.totalToLoad=this.list.size,this.emit("start",this),0===this.list.size?this.loadComplete():(this.state=s.LOADER_LOADING,this.inflight.clear(),this.queue.clear(),this.updateProgress(),this.checkLoadQueue(),this.systems.events.on("update",this.update,this)))},updateProgress:function(){this.progress=1-(this.list.size+this.inflight.size)/this.totalToLoad,this.emit("progress",this.progress)},update:function(){this.state===s.LOADER_LOADING&&this.list.size>0&&this.inflight.size0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(s=!0,i=n(t,e))}else s=!0,i=n(t,e);return!s&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e,i){var n=i(0),s=i(9),r=i(4),o=i(76),a=i(171),h=i(109),u=i(170),l=i(369),c=i(368),d=i(367),f=new n({Extends:s,initialize:function(t){s.call(this),this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.enabled=!0,this.target,this.keys=[],this.combos=[],this.queue=[],this.onKeyHandler,t.pluginEvents.once("boot",this.boot,this),t.pluginEvents.on("start",this.start,this)},boot:function(){var t=this.settings.input,e=this.scene.sys.game.config;this.enabled=r(t,"keyboard",e.inputKeyboard),this.target=r(t,"keyboard.target",e.inputKeyboardEventTarget),this.sceneInputPlugin.pluginEvents.once("destroy",this.destroy,this)},start:function(){this.enabled&&this.startListeners(),this.sceneInputPlugin.pluginEvents.once("shutdown",this.shutdown,this)},isActive:function(){return this.enabled&&this.scene.sys.isActive()},startListeners:function(){var t=this,e=function(e){if(!e.defaultPrevented&&t.isActive()){t.queue.push(e);var i=t.keys[e.keyCode];i&&i.preventDefault&&e.preventDefault()}};this.onKeyHandler=e,this.target.addEventListener("keydown",e,!1),this.target.addEventListener("keyup",e,!1),this.sceneInputPlugin.pluginEvents.on("update",this.update,this)},stopListeners:function(){this.target.removeEventListener("keydown",this.onKeyHandler),this.target.removeEventListener("keyup",this.onKeyHandler),this.sceneInputPlugin.pluginEvents.off("update",this.update)},createCursorKeys:function(){return this.addKeys({up:h.UP,down:h.DOWN,left:h.LEFT,right:h.RIGHT,space:h.SPACE,shift:h.SHIFT})},addKeys:function(t){var e={};if("string"==typeof t){t=t.split(",");for(var i=0;i-1?e[i]=t:e[t.keyCode]=t,t}return"string"==typeof t&&(t=h[t.toUpperCase()]),e[t]||(e[t]=new a(t)),e[t]},removeKey:function(t){var e=this.keys;if(t instanceof a){var i=e.indexOf(t);i>-1&&(this.keys[i]=void 0)}else"string"==typeof t&&(t=h[t.toUpperCase()]);e[t]&&(e[t]=void 0)},createCombo:function(t,e){return new u(this,t,e)},update:function(){var t=this.queue.length;if(this.enabled&&0!==t)for(var e=this.queue.splice(0,t),i=this.keys,n=0;n=e}}},function(t,e,i){var n=i(88),s=i(32),r=i(0),o=i(175),a=i(375),h=i(58),u=i(114),l=i(54),c=i(9),d=i(1),f=i(76),p=i(8),g=i(12),v=i(14),m=i(31),y=i(68),x=i(60),w=new r({Extends:c,initialize:function(t){c.call(this),this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.manager=t.sys.game.input,this.pluginEvents=new c,this.enabled=!0,this.displayList,this.cameras,f.install(this),this.mouse=this.manager.mouse,this.topOnly=!0,this.pollRate=-1,this._pollTimer=0,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this._temp=[],this._tempZones=[],this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],this._draggable=[],this._drag={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._over={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._validTypes=["onDown","onUp","onOver","onOut","onMove","onDragStart","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop"],t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.cameras=this.systems.cameras,this.displayList=this.systems.displayList,this.systems.events.once("destroy",this.destroy,this),this.pluginEvents.emit("boot")},start:function(){var t=this.systems.events;t.on("transitionstart",this.transitionIn,this),t.on("transitionout",this.transitionOut,this),t.on("transitioncomplete",this.transitionComplete,this),t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this),this.enabled=!0,this.pluginEvents.emit("start")},preUpdate:function(){this.pluginEvents.emit("preUpdate");var t=this._pendingRemoval,e=this._pendingInsertion,i=t.length,n=e.length;if(0!==i||0!==n){for(var s=this._list,r=0;r-1&&(s.splice(a,1),this.clear(o))}t.length=0,this._pendingRemoval.length=0,this._list=s.concat(e.splice(0))}},isActive:function(){return this.enabled&&this.scene.sys.isActive()},update:function(t,e){if(this.isActive()){this.pluginEvents.emit("update",t,e);var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var n=i.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(n=!0,this._pollTimer=this.pollRate)),n)for(var s=this.manager.pointers,r=0;r0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}}},clear:function(t){var e=t.input;if(e){this.queueForRemoval(t),e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t}},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,n){return void 0===n&&(n=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input&&n&&!t.input.dropZone&&(t.input.dropZone=n),this},hitTestPointer:function(t){for(var e=this.cameras.getCamerasBelowPointer(t),i=0;i0)return t.camera=n,s}return[]},processDownEvents:function(t){var e=this._temp;this.emit("pointerdown",t,e);for(var i=0,n=0;n0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var a=[];for(i=0;i1&&(this.sortGameObjects(a),this.topOnly&&a.splice(1)),this._drag[t.id]=a,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&h(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(s=this._drag[t.id],i=0;i0?(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),r.target=u[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),u[0]?(r.target=u[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):r.target=null)}else!r.target&&u[0]&&(r.target=u[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target));var c=t.x-n.input.dragX,d=t.y-n.input.dragY;n.emit("drag",t,c,d),this.emit("drag",t,n,c,d)}return s.length}if(5===t.dragState){for(s=this._drag[t.id],i=0;i0)for(this.sortGameObjects(s),this.emit("pointerout",t,s),e=0;e0)for(this.sortGameObjects(r),this.emit("pointerover",t,r),e=0;e-1&&this._draggable.splice(s,1)}return this},makePixelPerfect:function(t){void 0===t&&(t=1);var e=this.systems.textures;return a(e,t)},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);var n=!1,s=!1,r=!1,a=!1;if(p(e)){var h=e;e=d(h,"hitArea",null),i=d(h,"hitAreaCallback",null),n=d(h,"draggable",!1),s=d(h,"dropZone",!1),r=d(h,"cursor",!1),a=d(h,"useHandCursor",!1);var u=d(h,"pixelPerfect",!1),l=d(h,"alphaTolerance",1);u&&(e={},i=this.makePixelPerfect(l)),e&&i||this.setHitAreaFromTexture(t)}else"function"!=typeof e||i||(i=e,e={});for(var c=0;ct.width*t.height)&&e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottom0){var d=(a*r+h*o)/u;l*=d,c*=d}return i.x=t.x1+l,i.y=t.y1+c,l*l+c*c<=u&&l*r+c*o>=0&&n(e,i.x,i.y)}},function(t,e){t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.righte.right||t.y>e.bottom)}},function(t,e,i){t.exports={CircleToCircle:i(844),CircleToRectangle:i(843),GetRectangleIntersection:i(842),LineToCircle:i(397),LineToLine:i(144),LineToRectangle:i(841),PointToLine:i(396),PointToLineSegment:i(840),RectangleToRectangle:i(398),RectangleToTriangle:i(839),RectangleToValues:i(838),TriangleToCircle:i(837),TriangleToLine:i(836),TriangleToTriangle:i(835)}},function(t,e,i){t.exports={Circle:i(854),Ellipse:i(249),Intersects:i(399),Line:i(834),Point:i(816),Polygon:i(802),Rectangle:i(389),Triangle:i(774)}},function(t,e,i){var n=i(0),s=i(402),r=i(148),o=i(27),a=new n({initialize:function(){this.lightPool=[],this.lights=[],this.culledLights=[],this.ambientColor={r:.1,g:.1,b:.1},this.active=!1},enable:function(){return this.active=!0,this},disable:function(){return this.active=!1,this},cull:function(t){var e=this.lights,i=this.culledLights,n=e.length,s=t.x+t.width/2,o=t.y+t.height/2,a=(t.width+t.height)/2,h={x:0,y:0},u=t.matrix,l=this.systems.game.config.height;i.length=0;for(var c=0;c0?(h=this.lightPool.pop()).set(t,e,i,a[0],a[1],a[2],r):h=new s(t,e,i,a[0],a[1],a[2],r),this.lights.push(h),h},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&(this.lightPool.push(t),this.lights.splice(e,1)),this},shutdown:function(){for(;this.lights.length>0;)this.lightPool.push(this.lights.pop());this.ambientColor={r:.1,g:.1,b:.1},this.culledLights.length=0,this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=a},function(t,e,i){var n=i(0),s=i(27),r=new n({initialize:function(t,e,i,n,s,r,o){this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1},set:function(t,e,i,n,s,r,o){return this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1,this},setScrollFactor:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this},setColor:function(t){var e=s.getFloatsFromUintRGB(t);return this.r=e[0],this.g=e[1],this.b=e[2],this},setIntensity:function(t){return this.intensity=t,this},setPosition:function(t,e){return this.x=t,this.y=e,this},setRadius:function(t){return this.radius=t,this}});t.exports=r},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(110);s.register("text",function(t,e){void 0===t&&(t={});var i=r(t,"text",""),s=r(t,"style",null),a=r(t,"padding",null);null!==a&&(s.padding=a);var h=new o(this.scene,0,0,i,s);return void 0!==e&&(t.add=e),n(this.scene,h,t),h.autoRound=r(t,"autoRound",!0),h.resolution=r(t,"resolution",1),h})},function(t,e,i){var n=i(24),s=i(127),r=i(13),o=i(10),a=i(34);r.register("sprite",function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),h=new a(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),n(this.scene,h,t),s(h,t),h})},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(69);s.register("image",function(t,e){void 0===t&&(t={});var i=r(t,"key",null),s=r(t,"frame",null),a=new o(this.scene,0,0,i,s);return void 0!==e&&(t.add=e),n(this.scene,a,t),a})},function(t,e,i){var n=i(13),s=i(115);n.register("graphics",function(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new s(this.scene,t);return t.add&&this.scene.sys.displayList.add(i),i})},function(t,e,i){var n=i(110);i(11).register("text",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(11),s=i(34);n.register("sprite",function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.displayList.add(r),this.updateList.add(r),r})},function(t,e,i){var n=i(69);i(11).register("image",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(115);i(11).register("graphics",function(t){return this.displayList.add(new n(this.scene,t))})},function(t,e){t.exports=function(t){var e=Math.log(t)/.6931471805599453;return 1<r;h--){for(u=0;u0&&e.cameraFilter&s._id||""===e.text)){var o=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,o.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,o.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var a=e.canvas;if(o.save(),void 0!==r){var h=r.matrix;o.transform(h[0],h[1],h[2],h[3],h[4],h[5])}var u=e.x-s.scrollX*e.scrollFactorX,l=e.y-s.scrollY*e.scrollFactorY;t.config.roundPixels&&(u|=0,l|=0),o.translate(u,l),o.rotate(e.rotation),o.scale(e.scaleX,e.scaleY),o.translate(a.width*(e.flipX?1:0),a.height*(e.flipY?1:0)),o.scale(e.flipX?-1:1,e.flipY?-1:1),o.drawImage(a,0,0,a.width,a.height,-e.displayOriginX,-e.displayOriginY,a.width,a.height),o.restore()}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||""===e.text||(e.dirty&&(e.canvasTexture=t.canvasToTexture(e.canvas,e.canvasTexture),e.dirty=!1),this.pipeline.batchText(this,s,r))}},function(t,e,i){var n=i(3),s=i(3);n=i(415),s=i(414),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e,i){var n=t.canvas,s=t.context,r=t.style,o=[],a=0,h=i.length;r.maxLines>0&&r.maxLinesc&&(f=-c),0!==f&&(d+=f>0?f*i.length:f*(i.length-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},function(t,e,i){var n=i(0),s=i(38),r=i(62),o=i(4),a=i(34),h=i(61),u=i(6),l=new n({Extends:a,initialize:function(t,e,i,n,s,r){a.call(this,t,i,n,s,r),this.path=e,this.rotateToPath=!1,this.pathRotationVerticalAdjust=!1,this.pathRotationOffset=0,this.pathOffset=new u(i,n),this.pathVector=new u,this.pathTween,this.pathConfig=null,this._prevDirection=h.PLAYING_FORWARD},setPath:function(t,e){void 0===e&&(e=this.pathConfig);var i=this.pathTween;return i&&i.isPlaying()&&i.stop(),this.path=t,e&&this.startFollow(e),this},setRotateToPath:function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=!1),this.rotateToPath=t,this.pathRotationOffset=e,this.pathRotationVerticalAdjust=i,this},isFollowing:function(){var t=this.pathTween;return t&&t.isPlaying()},startFollow:function(t,e){void 0===t&&(t={}),void 0===e&&(e=0);var i=this.pathTween;i&&i.isPlaying()&&i.stop(),"number"==typeof t&&(t={duration:t}),t.from=0,t.to=1;var n=r(t,"positionOnPath",!1);if(this.rotateToPath=r(t,"rotateToPath",!1),this.pathRotationOffset=o(t,"rotationOffset",0),this.pathRotationVerticalAdjust=r(t,"verticalAdjust",!1),this.pathTween=this.scene.sys.tweens.addCounter(t),this.path.getStartPoint(this.pathOffset),n&&(this.x=this.pathOffset.x,this.y=this.pathOffset.y),this.pathOffset.x=this.x-this.pathOffset.x,this.pathOffset.y=this.y-this.pathOffset.y,this._prevDirection=h.PLAYING_FORWARD,this.rotateToPath){var a=this.path.getPoint(.1);this.rotation=Math.atan2(a.y-this.y,a.x-this.x)+s(this.pathRotationOffset)}return this.pathConfig=t,this},pauseFollow:function(){var t=this.pathTween;return t&&t.isPlaying()&&t.pause(),this},resumeFollow:function(){var t=this.pathTween;return t&&t.isPaused()&&t.resume(),this},stopFollow:function(){var t=this.pathTween;return t&&t.isPlaying()&&t.stop(),this},preUpdate:function(t,e){this.anims.update(t,e);var i=this.pathTween;if(i){var n=i.data[0];if(n.state!==h.PLAYING_FORWARD&&n.state!==h.PLAYING_BACKWARD)return;var r=this.pathVector;this.path.getPoint(i.getValue(),r),r.add(this.pathOffset);var o=this.x,a=this.y;this.setPosition(r.x,r.y);var u=this.x-o,l=this.y-a;if(0===u&&0===l)return;if(n.state!==this._prevDirection)return void(this._prevDirection=n.state);this.rotateToPath&&(this.rotation=Math.atan2(l,u)+s(this.pathRotationOffset),this.pathRotationVerticalAdjust&&(this.flipY=0!==this.rotation&&n.state===h.PLAYING_BACKWARD))}}});t.exports=l},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t){this.source=t,this._tempVec=new s},getPoint:function(t){var e=this._tempVec;this.source.getRandomPoint(e),t.x=e.x,t.y=e.y}});t.exports=r},function(t,e){t.exports=function(t,e){for(var i=0;i=1?1:1/e*(1+(e*t|0))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e,i){var n=i(247),s=i(246),r=i(245),o=i(244),a=i(243),h=i(242),u=i(241),l=i(240),c=i(239),d=i(238),f=i(237),p=i(236);t.exports={Power0:u,Power1:l.Out,Power2:o.Out,Power3:c.Out,Power4:d.Out,Linear:u,Quad:l.Out,Cubic:o.Out,Quart:c.Out,Quint:d.Out,Sine:f.Out,Expo:h.Out,Circ:r.Out,Elastic:a.Out,Back:n.Out,Bounce:s.Out,Stepped:p,"Quad.easeIn":l.In,"Cubic.easeIn":o.In,"Quart.easeIn":c.In,"Quint.easeIn":d.In,"Sine.easeIn":f.In,"Expo.easeIn":h.In,"Circ.easeIn":r.In,"Elastic.easeIn":a.In,"Back.easeIn":n.In,"Bounce.easeIn":s.In,"Quad.easeOut":l.Out,"Cubic.easeOut":o.Out,"Quart.easeOut":c.Out,"Quint.easeOut":d.Out,"Sine.easeOut":f.Out,"Expo.easeOut":h.Out,"Circ.easeOut":r.Out,"Elastic.easeOut":a.Out,"Back.easeOut":n.Out,"Bounce.easeOut":s.Out,"Quad.easeInOut":l.InOut,"Cubic.easeInOut":o.InOut,"Quart.easeInOut":c.InOut,"Quint.easeInOut":d.InOut,"Sine.easeInOut":f.InOut,"Expo.easeInOut":h.InOut,"Circ.easeInOut":r.InOut,"Elastic.easeInOut":a.InOut,"Back.easeInOut":n.InOut,"Bounce.easeInOut":s.InOut}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s){void 0===n&&(n=!1),void 0===s&&(s=!0),this.source=t,this.points=[],this.quantity=e,this.stepRate=i,this.yoyo=n,this.counter=-1,this.seamless=s,this._length=0,this._direction=0,this.updateSource()},updateSource:function(){if(this.points=this.source.getPoints(this.quantity,this.stepRate),this.seamless){var t=this.points[0],e=this.points[this.points.length-1];t.x===e.x&&t.y===e.y&&this.points.pop()}var i=this._length;return this._length=this.points.length,this._lengththis._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=this.source.contains(t.x,t.y);return e&&this.killOnEnter||!e&&!this.killOnEnter}});t.exports=n},function(t,e,i){var n=i(51),s=i(0),r=i(15),o=i(455),a=i(454),h=i(899),u=i(1),l=i(146),c=i(420),d=i(111),f=i(457),p=i(419),g=i(14),v=i(83),m=i(6),y=i(39),x=new s({Mixins:[r.BlendMode,r.Mask,r.ScrollFactor,r.Visible],initialize:function(t,e){this.manager=t,this.texture=t.texture,this.frames=[t.defaultFrame],this.defaultFrame=t.defaultFrame,this.configFastMap=["active","blendMode","collideBottom","collideLeft","collideRight","collideTop","deathCallback","deathCallbackScope","emitCallback","emitCallbackScope","follow","frequency","gravityX","gravityY","maxParticles","name","on","particleBringToTop","particleClass","radial","timeScale","trackVisible","visible"],this.configOpMap=["accelerationX","accelerationY","angle","alpha","bounce","delay","lifespan","maxVelocityX","maxVelocityY","moveToX","moveToY","quantity","rotate","scaleX","scaleY","speedX","speedY","tint","x","y"],this.name="",this.particleClass=f,this.x=new h(e,"x",0),this.y=new h(e,"y",0),this.radial=!0,this.gravityX=0,this.gravityY=0,this.acceleration=!1,this.accelerationX=new h(e,"accelerationX",0,!0),this.accelerationY=new h(e,"accelerationY",0,!0),this.maxVelocityX=new h(e,"maxVelocityX",1e4,!0),this.maxVelocityY=new h(e,"maxVelocityY",1e4,!0),this.speedX=new h(e,"speedX",0,!0),this.speedY=new h(e,"speedY",0,!0),this.moveTo=!1,this.moveToX=new h(e,"moveToX",0,!0),this.moveToY=new h(e,"moveToY",0,!0),this.bounce=new h(e,"bounce",0,!0),this.scaleX=new h(e,"scaleX",1),this.scaleY=new h(e,"scaleY",1),this.tint=new h(e,"tint",4294967295),this.alpha=new h(e,"alpha",1),this.lifespan=new h(e,"lifespan",1e3),this.angle=new h(e,"angle",{min:0,max:360}),this.rotate=new h(e,"rotate",0),this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.maxParticles=0,this.quantity=new h(e,"quantity",1,!0),this.delay=new h(e,"delay",0,!0),this.frequency=0,this.on=!0,this.particleBringToTop=!0,this.timeScale=1,this.emitZone=null,this.deathZone=null,this.bounds=null,this.collideLeft=!0,this.collideRight=!0,this.collideTop=!0,this.collideBottom=!0,this.active=!0,this.visible=!0,this.blendMode=n.NORMAL,this.follow=null,this.followOffset=new m,this.trackVisible=!1,this.currentFrame=0,this.randomFrame=!0,this.frameQuantity=1,this.dead=[],this.alive=[],this._counter=0,this._frameCounter=0,e&&this.fromJSON(e)},fromJSON:function(t){if(!t)return this;var e=0,i="";for(e=0;e0&&this.getParticleCount()===this.maxParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,n=i.length,s=0;s0?n.pop():new this.particleClass(this)).fire(e,i),this.particleBringToTop?this.alive.push(r):this.alive.unshift(r),this.emitCallback&&this.emitCallback.call(this.emitCallbackScope,r,this),this.atLimit())break}return r}},preUpdate:function(t,e){var i=(e*=this.timeScale)/1e3;this.trackVisible&&(this.visible=this.follow.visible);for(var n=this.manager.getProcessors(),s=this.alive,r=s.length,o=0;o0){var l=s.splice(s.length-u,u),c=this.deathCallback,d=this.deathCallbackScope;if(c)for(var f=0;f0&&(this._counter-=e,this._counter<=0&&(this.emitParticle(),this._counter=this.frequency-Math.abs(this._counter))))},depthSortCallback:function(t,e){return t.y-e.y},indexSortCallback:function(t,e){return t.index-e.index}});t.exports=x},function(t,e,i){var n=i(0),s=i(38),r=i(58),o=function(t){return(t>>16)+(65280&t)+((255&t)<<16)},a=new n({initialize:function(t){this.emitter=t,this.frame=null,this.index=0,this.x=0,this.y=0,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.tint=16777215,this.color=16777215,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215,current:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1}}},isAlive:function(){return this.lifeCurrent>0},fire:function(t,e){var i=this.emitter;this.frame=i.getFrame(),i.emitZone&&i.emitZone.getPoint(this),void 0===t?(i.follow&&(this.x+=i.follow.x+i.followOffset.x),this.x+=i.x.onEmit(this,"x")):this.x+=t,void 0===e?(i.follow&&(this.y+=i.follow.y+i.followOffset.y),this.y+=i.y.onEmit(this,"y")):this.y+=e,this.life=i.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0;var n=i.speedX.onEmit(this,"speedX"),a=i.speedY?i.speedY.onEmit(this,"speedY"):n;if(i.radial){var h=s(i.angle.onEmit(this,"angle"));this.velocityX=Math.cos(h)*Math.abs(n),this.velocityY=Math.sin(h)*Math.abs(a)}else if(i.moveTo){var u=i.moveToX.onEmit(this,"moveToX"),l=i.moveToY?i.moveToY.onEmit(this,"moveToY"):u,c=Math.atan2(l-this.y,u-this.x),d=r(this.x,this.y,u,l)/(this.life/1e3);this.velocityX=Math.cos(c)*d,this.velocityY=Math.sin(c)*d}else this.velocityX=n,this.velocityY=a;i.acceleration&&(this.accelerationX=i.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=i.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=i.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=i.maxVelocityY.onEmit(this,"maxVelocityY"),this.delayCurrent=i.delay.onEmit(this,"delay"),this.scaleX=i.scaleX.onEmit(this,"scaleX"),this.scaleY=i.scaleY?i.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=i.rotate.onEmit(this,"rotate"),this.rotation=s(this.angle),this.bounce=i.bounce.onEmit(this,"bounce"),this.alpha=i.alpha.onEmit(this,"alpha"),this.tint=i.tint.onEmit(this,"tint");var f=255&(255*this.alpha|0);this.color=(f<<24|o(this.tint))>>>0,this.index=i.alive.length},computeVelocity:function(t,e,i,n){var s=this.velocityX,r=this.velocityY,o=this.accelerationX,a=this.accelerationY,h=this.maxVelocityX,u=this.maxVelocityY;s+=t.gravityX*i,r+=t.gravityY*i,o&&(s+=o*i),a&&(r+=a*i),s>h?s=h:s<-h&&(s=-h),r>u?r=u:r<-u&&(r=-u),this.velocityX=s,this.velocityY=r;for(var l=0;le.right&&t.collideRight&&(this.x=e.right,this.velocityX*=i),this.ye.bottom&&t.collideBottom&&(this.y=e.bottom,this.velocityY*=i)},update:function(t,e,i){if(this.delayCurrent>0)return this.delayCurrent-=t,!1;var n=this.emitter,r=1-this.lifeCurrent/this.life;if(this.lifeT=r,this.computeVelocity(n,t,e,i),this.x+=this.velocityX*e,this.y+=this.velocityY*e,n.bounds&&this.checkBounds(n),n.deathZone&&n.deathZone.willKill(this))return this.lifeCurrent=0,!0;this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),n.scaleY?this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY):this.scaleY=this.scaleX,this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=s(this.angle),this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),this.tint=n.tint.onUpdate(this,"tint",r,this.tint);var a=255&(255*this.alpha|0);return this.color=(a<<24|o(this.tint))>>>0,this.lifeCurrent-=t,this.lifeCurrent<=0}});t.exports=a},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t,e,i,n,r){if("object"==typeof t){var o=t;t=s(o,"x",0),e=s(o,"y",0),i=s(o,"power",0),n=s(o,"epsilon",100),r=s(o,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=50);this.x=t,this.y=e,this.active=!0,this._gravity=r,this._power=0,this._epsilon=0,this.power=i,this.epsilon=n},update:function(t,e){var i=this.x-t.x,n=this.y-t.y,s=i*i+n*n;if(0!==s){var r=Math.sqrt(s);s0&&e.cameraFilter&s._id||t.drawImage(e,s,r)}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(460),s=i(459),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchGraphics(this,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(462),s=i(176),s=i(176),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(14);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e,i){var n=i(54);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(54);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(114);t.exports=function(t){return new n(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},function(t,e,i){var n=i(14);t.exports=function(t,e,i){void 0===i&&(i=new n);var s=Math.min(t.x,e.x),r=Math.min(t.y,e.y),o=Math.max(t.right,e.right)-s,a=Math.max(t.bottom,e.bottom)-r;return i.setTo(s,r,o,a)}},function(t,e){function i(t,e){return parseInt(t.getAttribute(e),10)}t.exports=function(t,e,n,s){void 0===e&&(e=0),void 0===n&&(n=0);var r={},o=t.getElementsByTagName("info")[0],a=t.getElementsByTagName("common")[0];r.font=o.getAttribute("face"),r.size=i(o,"size"),r.lineHeight=i(a,"lineHeight")+n,r.chars={};var h=t.getElementsByTagName("char"),u=void 0!==s&&s.trimmed;if(u)var l=s.height,c=s.width;for(var d=0;dy&&(s=y),r>x&&(r=x);var A=y+v-s,C=x+m-r;o-1&&this._list.splice(s,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;i0&&(t.splice(i,1),t.unshift(e)),e}},function(t,e){t.exports=function(t,e,i){var n=t.indexOf(e),s=t.indexOf(i);return-1!==n&&-1===s&&(t[n]=i,!0)}},function(t,e,i){var n=i(56);t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return n(t,s)}},function(t,e,i){var n=i(29);t.exports=function(t,e,i,s,r){if(void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===r&&(r=t),n(t,e,i)){var o=i-e,a=t.splice(e,o);if(s)for(var h=0;ht.length-1)throw new Error("Index out of bounds");var r=n(t,e);return i&&i.call(s,r),r}},function(t,e,i){var n=i(255);t.exports=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=null),void 0===i&&(i=1),null===e&&(e=t,t=0);for(var s=[],r=Math.max(n((e-t)/(i||1)),0),o=0;o=t.length)throw new Error("Supplied index out of bounds");return n!==i&&(t.splice(n,1),t.splice(i,0,e)),e}},function(t,e){t.exports=function(t,e){var i=t.indexOf(e);if(i>0){var n=t[i-1],s=t.indexOf(n);t[i]=n,t[s]=e}return t}},function(t,e,i){var n=i(29);t.exports=function(t,e,i,s,r){if(void 0===s&&(s=0),void 0===r&&(r=t.length),n(t,s,r))for(var o=s;o0){var o=n-t.length;if(o<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.splice(i,0,e),s&&s.call(r,e),e):null;for(var a=e.length-1;a>=0;)-1!==t.indexOf(e[a])&&e.pop(),a--;if(0===(a=e.length))return null;n>0&&a>o&&(e.splice(o),a=o);for(var h=a;h>0;h--){var u=e[h];t.splice(i,0,u),s&&s.call(r,u)}return e}},function(t,e){t.exports=function(t,e,i,n,s){if(void 0===s&&(s=t),i>0){var r=i-t.length;if(r<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.push(e),n&&n.call(s,e),e):null;for(var o=e.length-1;o>=0;)-1!==t.indexOf(e[o])&&e.pop(),o--;if(0===(o=e.length))return null;i>0&&o>r&&(e.splice(r),o=r);for(var a=0;a0||!this.inFocus)&&(this._coolDown--,r=Math.min(r,this._target)),r>this._min&&(r=n[i],r=Math.min(r,this._min)),n[i]=r,this.deltaIndex++,this.deltaIndex>s&&(this.deltaIndex=0);for(var o=0,a=0;athis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var h=o/this._target;this.callback(t,o,h),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=a},function(t,e){var i=0,n=function(t,e,n,s){var r=i-s.y-s.height;t.add(n,e,s.x,r,s.width,s.height)};t.exports=function(t,e,s){var r=t.source[e];t.add("__BASE",e,0,0,r.width,r.height),i=r.height;for(var o=s.split("\n"),a=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",u="",l={x:0,y:0,width:0,height:0},c=0;cx||a<-x)&&(a=0),a<0&&(a=x+a),-1!==h&&(x=a+(h+1));for(var M=u,_=u,E=0,P=e.sourceIndex,L=0;Lg||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var v=f,m=f,y=0,x=0,w=0;wr&&(y=b-r),T>o&&(x=T-o),t.add(w,e,i+v,s+m,h-y,u-x),(v+=h+p)+h>r&&(v=f,m+=u+p)}return t}},function(t,e,i){var n=i(33);t.exports=function(t,e,i){if(i.frames){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);var r,o=i.frames;for(var a in o){var h=o[a];r=t.add(a,e,h.frame.x,h.frame.y,h.frame.w,h.frame.h),h.trimmed&&r.setTrim(h.sourceSize.w,h.sourceSize.h,h.spriteSourceSize.x,h.spriteSourceSize.y,h.spriteSourceSize.w,h.spriteSourceSize.h),h.rotated&&(r.rotated=!0,r.updateUVsInverted()),r.customData=n(h)}for(var u in i)"frames"!==u&&(Array.isArray(i[u])?t.customData[u]=i[u].slice(0):t.customData[u]=i[u]);return t}console.warn("Invalid Texture Atlas JSON Hash given, missing 'frames' Object")}},function(t,e,i){var n=i(33);t.exports=function(t,e,i){if(i.frames||i.textures){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);for(var r,o=Array.isArray(i.textures)?i.textures[e].frames:i.frames,a=0;a=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(s.dolby=!0)}}catch(t){}return s}()},function(t,e,i){var n=i(57),s=i(80),r={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),n.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){t.exports={os:i(57),browser:i(80),features:i(120),input:i(522),audio:i(521),video:i(520),fullscreen:i(519),canvasFeatures:i(203)}},function(t,e,i){var n=i(20);t.exports=function(t){var e=t.config;if(!e.hideBanner){var i="WebGL";e.renderType===n.CANVAS?i="Canvas":e.renderType===n.HEADLESS&&(i="Headless");var s,r=e.audio,o=t.device.audio;if(s=!o.webAudio||r&&r.disableWebAudio?r&&r.noAudio||!o.webAudio&&!o.audioData?"No Audio":"HTML5 Audio":"Web Audio",t.device.browser.ie)window.console&&console.log("Phaser v"+n.VERSION+" / https://phaser.io");else{var a,h="",u=[h];Array.isArray(e.bannerBackgroundColor)?(e.bannerBackgroundColor.forEach(function(t){h=h.concat("%c "),u.push("background: "+t),a=t}),u[u.length-1]="color: "+e.bannerTextColor+"; background: "+a):(h=h.concat("%c "),u.push("color: "+e.bannerTextColor+"; background: "+e.bannerBackgroundColor)),u.push("background: #fff"),e.gameTitle&&(h=h.concat(e.gameTitle),e.gameVersion&&(h=h.concat(" v"+e.gameVersion)),e.hidePhaser||(h=h.concat(" / "))),e.hidePhaser||(h=h.concat("Phaser v"+n.VERSION+" ("+i+" | "+s+")")),h=h.concat(" %c "+e.gameURL),u[0]=h,console.log.apply(console,u)}}}},function(t,e){t.exports=["#define SHADER_NAME PHASER_TEXTURE_TINT_VS","","precision mediump float;","","uniform mat4 uProjectionMatrix;","uniform mat4 uViewMatrix;","uniform mat4 uModelMatrix;","","attribute vec2 inPosition;","attribute vec2 inTexCoord;","attribute vec4 inTint;","","varying vec2 outTexCoord;","varying vec4 outTint;","","void main ()","{"," gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);"," outTexCoord = inTexCoord;"," outTint = inTint;","}","",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_TEXTURE_TINT_FS","","precision mediump float;","","uniform sampler2D uMainSampler;","","varying vec2 outTexCoord;","varying vec4 outTint;","","void main()","{"," vec4 texel = texture2D(uMainSampler, outTexCoord);"," texel *= vec4(outTint.rgb * outTint.a, outTint.a);"," gl_FragColor = texel;","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS","","precision mediump float;","","struct Light","{"," vec2 position;"," vec3 color;"," float intensity;"," float radius;","};","","const int kMaxLights = %LIGHT_COUNT%;","","uniform vec4 uCamera; /* x, y, rotation, zoom */","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uNormSampler;","uniform vec3 uAmbientLightColor;","uniform Light uLights[kMaxLights];","","varying vec2 outTexCoord;","varying vec4 outTint;","","void main()","{"," vec3 finalColor = vec3(0.0, 0.0, 0.0);"," vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);"," vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;"," vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));"," vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;",""," for (int index = 0; index < kMaxLights; ++index)"," {"," Light light = uLights[index];"," vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);"," vec3 lightNormal = normalize(lightDir);"," float distToSurf = length(lightDir) * uCamera.w;"," float diffuseFactor = max(dot(normal, lightNormal), 0.0);"," float radius = (light.radius / res.x * uCamera.w) * uCamera.w;"," float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);"," vec3 diffuse = light.color * diffuseFactor;"," finalColor += (attenuation * diffuse) * light.intensity;"," }",""," vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);"," gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);","","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_FLAT_TINT_VS","","precision mediump float;","","uniform mat4 uProjectionMatrix;","uniform mat4 uViewMatrix;","uniform mat4 uModelMatrix;","","attribute vec2 inPosition;","attribute vec4 inTint;","","varying vec4 outTint;","","void main () {"," gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);"," outTint = inTint;","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_FLAT_TINT_FS","","precision mediump float;","","varying vec4 outTint;","","void main() {"," gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_VS","","precision mediump float;","","attribute vec2 inPosition;","","void main()","{"," gl_Position = vec4(inPosition, 0.0, 1.0);","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_FS","","precision mediump float;","","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uMaskSampler;","uniform bool uInvertMaskAlpha;","","void main()","{"," vec2 uv = gl_FragCoord.xy / uResolution;"," vec4 mainColor = texture2D(uMainSampler, uv);"," vec4 maskColor = texture2D(uMaskSampler, uv);"," float alpha = mainColor.a;",""," if (!uInvertMaskAlpha)"," {"," alpha *= (maskColor.a);"," }"," else"," {"," alpha *= (1.0 - maskColor.a);"," }",""," gl_FragColor = vec4(mainColor.rgb * alpha, alpha);","}",""].join("\n")},function(t,e,i){var n=i(272),s=i(22),r=i(20),o=i(120);t.exports=function(t){var e,a,h=t.config;if(h.renderType!==r.HEADLESS)if(h.renderType===r.CANVAS||h.renderType!==r.CANVAS&&!o.webGL){if(!o.canvas)throw new Error("Cannot create Canvas or WebGL context, aborting.");h.renderType=r.CANVAS}else h.renderType=r.WEBGL;h.pixelArt&&s.disableSmoothing(),h.canvas?t.canvas=h.canvas:t.canvas=s.create(t,h.width,h.height,h.renderType),h.canvasStyle&&(t.canvas.style=h.canvasStyle),h.pixelArt&&n.setCrisp(t.canvas),1!==h.zoom&&(t.canvas.style.width=(h.width*h.zoom).toString()+"px",t.canvas.style.height=(h.height*h.zoom).toString()+"px"),h.renderType!==r.HEADLESS&&(e=i(267),a=i(262),h.renderType===r.WEBGL?(t.renderer=new a(t),t.context=null):(t.renderer=new e(t),t.context=t.renderer.gameContext))}},function(t,e,i){var n=i(0),s=i(20),r=i(1),o=i(4),a=i(8),h=i(16),u=i(3),l=i(121),c=i(132),d=new n({initialize:function(t){void 0===t&&(t={});this.width=o(t,"width",1024),this.height=o(t,"height",768),this.zoom=o(t,"zoom",1),this.resolution=o(t,"resolution",1),this.renderType=o(t,"type",s.AUTO),this.parent=o(t,"parent",null),this.canvas=o(t,"canvas",null),this.context=o(t,"context",null),this.canvasStyle=o(t,"canvasStyle",null),this.sceneConfig=o(t,"scene",null),this.seed=o(t,"seed",[(Date.now()*Math.random()).toString()]),h.RND.init(this.seed),this.gameTitle=o(t,"title",""),this.gameURL=o(t,"url","https://phaser.io"),this.gameVersion=o(t,"version",""),this.autoFocus=o(t,"autoFocus",!0),this.inputKeyboard=o(t,"input.keyboard",!0),this.inputKeyboardEventTarget=o(t,"input.keyboard.target",window),this.inputMouse=o(t,"input.mouse",!0),this.inputMouseEventTarget=o(t,"input.mouse.target",null),this.inputMouseCapture=o(t,"input.mouse.capture",!0),this.inputTouch=o(t,"input.touch",!0),this.inputTouchEventTarget=o(t,"input.touch.target",null),this.inputTouchCapture=o(t,"input.touch.capture",!0),this.inputActivePointers=o(t,"input.activePointers",1),this.inputGamepad=o(t,"input.gamepad",!1),this.inputGamepadEventTarget=o(t,"input.gamepad.target",window),this.disableContextMenu=o(t,"disableContextMenu",!1),this.audio=o(t,"audio"),this.hideBanner=!1===o(t,"banner",null),this.hidePhaser=o(t,"banner.hidePhaser",!1),this.bannerTextColor=o(t,"banner.text","#ffffff"),this.bannerBackgroundColor=o(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=o(t,"fps",null);var e=o(t,"render",t);this.antialias=o(e,"antialias",!0),this.pixelArt=o(e,"pixelArt",!1),this.autoResize=o(e,"autoResize",!1),this.roundPixels=o(e,"roundPixels",!1),this.transparent=o(e,"transparent",!1),this.clearBeforeRender=o(e,"clearBeforeRender",!0),this.premultipliedAlpha=o(e,"premultipliedAlpha",!0),this.preserveDrawingBuffer=o(e,"preserveDrawingBuffer",!1),this.failIfMajorPerformanceCaveat=o(e,"failIfMajorPerformanceCaveat",!1),this.powerPreference=o(e,"powerPreference","default");var i=o(t,"backgroundColor",0);this.backgroundColor=c(i),0===i&&this.transparent&&(this.backgroundColor.alpha=0),this.preBoot=o(t,"callbacks.preBoot",u),this.postBoot=o(t,"callbacks.postBoot",u),this.physics=o(t,"physics",{}),this.defaultPhysicsSystem=o(this.physics,"default",!1),this.loaderBaseURL=o(t,"loader.baseURL",""),this.loaderPath=o(t,"loader.path",""),this.loaderMaxParallelDownloads=o(t,"loader.maxParallelDownloads",32),this.loaderCrossOrigin=o(t,"loader.crossOrigin",void 0),this.loaderResponseType=o(t,"loader.responseType",""),this.loaderAsync=o(t,"loader.async",!0),this.loaderUser=o(t,"loader.user",""),this.loaderPassword=o(t,"loader.password",""),this.loaderTimeout=o(t,"loader.timeout",0),this.installGlobalPlugins=[],this.installScenePlugins=[];var n=o(t,"plugins",null),d=l.DefaultScene;n&&(Array.isArray(n)?this.defaultPlugins=n:a(n)&&(this.installGlobalPlugins=r(n,"global",[]),this.installScenePlugins=r(n,"scene",[]),Array.isArray(n.default)?d=n.default:Array.isArray(n.defaultMerge)&&(d=d.concat(n.defaultMerge)))),this.defaultPlugins=d;var f="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=o(t,"images.default",f+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=o(t,"images.missing",f+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==")}});t.exports=d},function(t,e,i){var n=i(130),s=i(207),r=i(205),o=i(22),a=i(0),h=i(533),u=i(532),l=i(81),c=i(524),d=i(523),f=i(271),p=i(9),g=i(201),v=i(196),m=i(194),y=i(191),x=i(184),w=i(506),b=i(505),T=new a({initialize:function(t){this.config=new h(t),this.renderer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new p,this.anims=new s(this),this.textures=new x(this),this.cache=new r(this),this.registry=new l(this),this.input=new g(this,this.config),this.scene=new m(this,this.config.sceneConfig),this.device=d,this.sound=y.create(this),this.loop=new w(this,this.config.fps),this.plugins=new v(this,this.config),this.pendingDestroy=!1,this.removeCanvas=!1,this.hasFocus=!1,this.isOver=!0,f(this.boot.bind(this))},boot:function(){this.isBooted=!0,this.config.preBoot(this),u(this),c(this),n(this.canvas,this.config.parent),this.events.emit("boot"),this.events.once("ready",this.start,this)},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),b(this);var t=this.events;t.on("hidden",this.onHidden,this),t.on("visible",this.onVisible,this),t.on("blur",this.onBlur,this),t.on("focus",this.onFocus,this)},step:function(t,e){if(this.pendingDestroy)return this.runDestroy();var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e);var n=this.renderer;n.preRender(),i.emit("prerender",n,t,e),this.scene.render(n),n.postRender(),i.emit("postrender",n,t,e)},headlessStep:function(t,e){var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e),i.emit("prerender"),i.emit("postrender")},onHidden:function(){this.loop.pause(),this.events.emit("pause")},onVisible:function(){this.loop.resume(),this.events.emit("resume")},onBlur:function(){this.hasFocus=!1,this.loop.blur()},onFocus:function(){this.hasFocus=!0,this.loop.focus()},resize:function(t,e){this.config.width=t,this.config.height=e,this.renderer.resize(t,e),this.input.resize(),this.scene.resize(t,e),this.events.emit("resize",t,e)},destroy:function(t){this.pendingDestroy=!0,this.removeCanvas=t},runDestroy:function(){this.events.emit("destroy"),this.events.removeAllListeners(),this.scene.destroy(),this.renderer&&this.renderer.destroy(),this.removeCanvas&&this.canvas&&(o.remove(this.canvas),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)),this.loop.destroy(),this.pendingDestroy=!1}});t.exports=T},function(t,e,i){var n=i(0),s=i(9),r=i(12),o=new n({Extends:s,initialize:function(){s.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",o,"events"),t.exports=o},function(t,e,i){t.exports={EventEmitter:i(535)}},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var h,u=[],l=!1,c=-1;function d(){l&&h&&(l=!1,h.length?u=h.concat(u):c=-1,u.length&&f())}function f(){if(!l){var t=a(d);l=!0;for(var e=u.length;e;){for(h=u,u=[];++c1)for(var i=1;i1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}},function(t,e){t.exports=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},function(t,e,i){var n=i(30);n.ColorToRGBA=i(923),n.ComponentToHex=i(541),n.GetColor=i(152),n.GetColor32=i(284),n.HexStringToColor=i(285),n.HSLToColor=i(922),n.HSVColorWheel=i(921),n.HSVToRGB=i(539),n.HueToComponent=i(540),n.IntegerToColor=i(283),n.IntegerToRGB=i(282),n.Interpolate=i(920),n.ObjectToColor=i(281),n.RandomRGB=i(919),n.RGBStringToColor=i(280),n.RGBToHSV=i(918),n.RGBToString=i(917),n.ValueToColor=i(132),t.exports=n},function(t,e,i){var n=i(0),s=i(81),r=i(12),o=new n({Extends:s,initialize:function(t){s.call(this,t,t.sys.events),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.events=this.systems.events,this.events.once("destroy",this.destroy,this)},start:function(){this.events.once("shutdown",this.shutdown,this)},shutdown:function(){this.systems.events.off("shutdown",this.shutdown,this)},destroy:function(){s.prototype.destroy.call(this),this.events.off("start",this.start,this),this.scene=null,this.systems=null}});r.register("DataManagerPlugin",o,"data"),t.exports=o},function(t,e,i){t.exports={DataManager:i(81),DataManagerPlugin:i(543)}},function(t,e,i){var n=i(273),s=i(0),r=i(86),o=i(6),a=new s({Extends:r,initialize:function(t){void 0===t&&(t=[]),r.call(this,"SplineCurve"),this.points=[],this.addPoints(t)},addPoints:function(t){for(var e=0;ei.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(n(a,h.x,u.x,l.x,c.x),n(a,h.y,u.y,l.y,c.y))},toJSON:function(){for(var t=[],e=0;ei;)n-=i;n0&&e.cameraFilter&s._id||t.drawImage(e,s,r)}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(555),s=i(554),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},fromMat4:function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=n,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8],l=u*r-o*h,c=-u*s+o*a,d=h*s-r*a,f=e*l+i*c+n*d;return f?(f=1/f,t[0]=l*f,t[1]=(-u*i+n*h)*f,t[2]=(o*i-n*r)*f,t[3]=c*f,t[4]=(u*e-n*a)*f,t[5]=(-o*e+n*s)*f,t[6]=d*f,t[7]=(-h*e+i*a)*f,t[8]=(r*e-i*s)*f,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8];return t[0]=r*u-o*h,t[1]=n*h-i*u,t[2]=i*o-n*r,t[3]=o*a-s*u,t[4]=e*u-n*a,t[5]=n*s-e*o,t[6]=s*h-r*a,t[7]=i*a-e*h,t[8]=e*r-i*s,this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],u=t[8];return e*(u*r-o*h)+i*(-u*s+o*a)+n*(h*s-r*a)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],u=e[7],l=e[8],c=t.val,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],m=c[5],y=c[6],x=c[7],w=c[8];return e[0]=d*i+f*r+p*h,e[1]=d*n+f*o+p*u,e[2]=d*s+f*a+p*l,e[3]=g*i+v*r+m*h,e[4]=g*n+v*o+m*u,e[5]=g*s+v*a+m*l,e[6]=y*i+x*r+w*h,e[7]=y*n+x*o+w*u,e[8]=y*s+x*a+w*l,this},translate:function(t){var e=this.val,i=t.x,n=t.y;return e[6]=i*e[0]+n*e[3]+e[6],e[7]=i*e[1]+n*e[4]+e[7],e[8]=i*e[2]+n*e[5]+e[8],this},rotate:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=Math.sin(t),u=Math.cos(t);return e[0]=u*i+h*r,e[1]=u*n+h*o,e[2]=u*s+h*a,e[3]=u*r-h*i,e[4]=u*o-h*n,e[5]=u*a-h*s,this},scale:function(t){var e=this.val,i=t.x,n=t.y;return e[0]=i*e[0],e[1]=i*e[1],e[2]=i*e[2],e[3]=n*e[3],e[4]=n*e[4],e[5]=n*e[5],this},fromQuat:function(t){var e=t.x,i=t.y,n=t.z,s=t.w,r=e+e,o=i+i,a=n+n,h=e*r,u=e*o,l=e*a,c=i*o,d=i*a,f=n*a,p=s*r,g=s*o,v=s*a,m=this.val;return m[0]=1-(c+f),m[3]=u+v,m[6]=l-g,m[1]=u-v,m[4]=1-(h+f),m[7]=d+p,m[2]=l+g,m[5]=d-p,m[8]=1-(h+c),this},normalFromMat4:function(t){var e=t.val,i=this.val,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],u=e[6],l=e[7],c=e[8],d=e[9],f=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],x=n*h-s*a,w=n*u-r*a,b=n*l-o*a,T=s*u-r*h,S=s*l-o*h,A=r*l-o*u,C=c*v-d*g,M=c*m-f*g,_=c*y-p*g,E=d*m-f*v,P=d*y-p*v,L=f*y-p*m,F=x*L-w*P+b*E+T*_-S*M+A*C;return F?(F=1/F,i[0]=(h*L-u*P+l*E)*F,i[1]=(u*_-a*L-l*M)*F,i[2]=(a*P-h*_+l*C)*F,i[3]=(r*P-s*L-o*E)*F,i[4]=(n*L-r*_+o*M)*F,i[5]=(s*_-n*P-o*C)*F,i[6]=(v*A-m*S+y*T)*F,i[7]=(m*b-g*A-y*w)*F,i[8]=(g*S-v*b+y*x)*F,this):null}});t.exports=n},function(t,e,i){var n=i(0),s=i(87),r=i(557),o=new Int8Array([1,2,0]),a=new Float32Array([0,0,0]),h=new s(1,0,0),u=new s(0,1,0),l=new s,c=new r,d=new n({initialize:function(t,e,i,n){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},set:function(t,e,i,n){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},normalize:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(l.copy(h).cross(t).length()<1e-6&&l.copy(u).cross(t),l.normalize(),this.setAxisAngle(l,Math.PI)):i>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(l.copy(t).cross(e),this.x=l.x,this.y=l.y,this.z=l.z,this.w=1+i,this.normalize())},setAxes:function(t,e,i){var n=c.val;return n[0]=e.x,n[3]=e.y,n[6]=e.z,n[1]=i.x,n[4]=i.y,n[7]=i.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(c).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=Math.cos(e),this},multiply:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.x=e*h+s*r+i*a-n*o,this.y=i*h+s*o+n*r-e*a,this.z=n*h+s*a+e*o-i*r,this.w=s*h-e*r-i*o-n*a,this},slerp:function(t,e){var i=this.x,n=this.y,s=this.z,r=this.w,o=t.x,a=t.y,h=t.z,u=t.w,l=i*o+n*a+s*h+r*u;l<0&&(l=-l,o=-o,a=-a,h=-h,u=-u);var c=1-e,d=e;if(1-l>1e-6){var f=Math.acos(l),p=Math.sin(f);c=Math.sin((1-e)*f)/p,d=Math.sin(e*f)/p}return this.x=c*i+d*o,this.y=c*n+d*a,this.z=c*s+d*h,this.w=c*r+d*u,this},invert:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-e*r,this.z=-i*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+s*r,this.y=i*o+n*r,this.z=n*o-i*r,this.w=s*o-e*r,this},rotateY:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o-n*r,this.y=i*o+s*r,this.z=n*o+e*r,this.w=s*o-i*r,this},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+i*r,this.y=i*o-e*r,this.z=n*o+s*r,this.w=s*o-n*r,this},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(1-t*t-e*e-i*i),this},fromMat3:function(t){var e,i=t.val,n=i[0]+i[4]+i[8];if(n>0)e=Math.sqrt(n+1),this.w=.5*e,e=.5/e,this.x=(i[7]-i[5])*e,this.y=(i[2]-i[6])*e,this.z=(i[3]-i[1])*e;else{var s=0;i[4]>i[0]&&(s=1),i[8]>i[3*s+s]&&(s=2);var r=o[s],h=o[r];e=Math.sqrt(i[3*s+s]-i[3*r+r]-i[3*h+h]+1),a[s]=.5*e,e=.5/e,a[r]=(i[3*r+s]+i[3*s+r])*e,a[h]=(i[3*h+s]+i[3*s+h])*e,this.x=a[0],this.y=a[1],this.z=a[2],this.w=(i[3*h+r]-i[3*r+h])*e}return this}});t.exports=d},function(t,e,i){var n=i(87),s=i(278),r=i(558),o=new s,a=new r,h=new n;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t.x=(2*Math.random()-1)*e,t.y=(2*Math.random()-1)*e,t.z=(2*Math.random()-1)*e,t.w=(2*Math.random()-1)*e,t}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI,n=2*Math.random()-1,s=Math.sqrt(1-n*n)*e;return t.x=Math.cos(i)*s,t.y=Math.sin(i)*s,t.z=n*e,t}},function(t,e,i){var n=i(123),s=i(0),r=i(1),o=i(12),a=i(31),h=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.currentCameraId=1,this.cameras=[],this.cameraPool=[],this.main,this.baseScale=1,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){var t=this.systems;t.settings.cameras?this.fromJSON(t.settings.cameras):this.add(),this.main=this.cameras[0],this.systems.events.once("destroy",this.destroy,this)},start:function(){this.main||this.boot();var t=this.systems.events;t.on("update",this.update,this),t.once("shutdown",this.shutdown,this)},add:function(t,e,i,s,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===s&&(s=this.scene.sys.game.config.height),void 0===r&&(r=!1),void 0===o&&(o="");var a=null;return this.cameraPool.length>0?(a=this.cameraPool.pop()).setViewport(t,e,i,s):a=new n(t,e,i,s),a.setName(o),a.setScene(this.scene),this.cameras.push(a),r&&(this.main=a),a._id=this.currentCameraId,this.currentCameraId=this.currentCameraId<<1,a},addExisting:function(t){var e=this.cameras.indexOf(t),i=this.cameraPool.indexOf(t);return e<0&&i>=0?(this.cameras.push(t),this.cameraPool.slice(i,1),t):null},fromJSON:function(t){Array.isArray(t)||(t=[t]);for(var e=this.scene.sys.game.config.width,i=this.scene.sys.game.config.height,n=0;n=0&&this.cameras.length>1&&(this.cameraPool.push(this.cameras[e]),this.cameras.splice(e,1),this.main===t&&(this.main=this.cameras[0]))},render:function(t,e,i){for(var n=this.cameras,s=this.baseScale,r=0,o=n.length;r0;)this.cameraPool.push(this.cameras.pop());return this.main=this.add(),this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i-h&&(c-=h,n+=u),f=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},function(t,e){var i={_visible:!0,visible:{get:function(){return this._visible},set:function(t){t?(this._visible=!0,this.renderFlags|=1):(this._visible=!1,this.renderFlags&=-2)}},setVisible:function(t){return this.visible=t,this}};t.exports=i},function(t,e,i){var n=i(16),s=i(64),r=i(212),o=i(211),a={_scaleX:1,_scaleY:1,_rotation:0,x:0,y:0,z:0,w:0,scaleX:{get:function(){return this._scaleX},set:function(t){this._scaleX=t,0===this._scaleX?this.renderFlags&=-5:this.renderFlags|=4}},scaleY:{get:function(){return this._scaleY},set:function(t){this._scaleY=t,0===this._scaleY?this.renderFlags&=-5:this.renderFlags|=4}},angle:{get:function(){return o(this._rotation*n.RAD_TO_DEG)},set:function(t){this.rotation=o(t)*n.DEG_TO_RAD}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=r(t)}},setPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=i,this.w=n,this},setRandomPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),this.x=t+Math.random()*i,this.y=e+Math.random()*n,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,this},setScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this},setX:function(t){return void 0===t&&(t=0),this.x=t,this},setY:function(t){return void 0===t&&(t=0),this.y=t,this},setZ:function(t){return void 0===t&&(t=0),this.z=t,this},setW:function(t){return void 0===t&&(t=0),this.w=t,this},getLocalTransformMatrix:function(t){return void 0===t&&(t=new s),t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY)},getWorldTransformMatrix:function(t){void 0===t&&(t=new s);var e=this.parentContainer;if(!e)return this.getLocalTransformMatrix(t);for(var i=[];e;)i.unshift(e),e=e.parentContainer;t.loadIdentity();for(var n=i.length,r=0;r>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,clearTint:function(){return this.setTint(16777215),this},setTint:function(t,e,n,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,n=t,s=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(n),this._tintBR=i(s),this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t)}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t)}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t)}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t)}},tint:{set:function(t){this.setTint(t,t,t,t)}}};t.exports=n},function(t,e){var i={texture:null,frame:null,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e,i){var n=i(59),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e){var i={matrixStack:null,currentMatrix:null,currentMatrixIndex:0,initMatrixStack:function(){return this.matrixStack=new Float32Array(6e3),this.currentMatrix=new Float32Array([1,0,0,1,0,0]),this.currentMatrixIndex=0,this},save:function(){if(this.currentMatrixIndex>=this.matrixStack.length)return this;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return this.currentMatrixIndex+=6,t[i+0]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=e[3],t[i+4]=e[4],t[i+5]=e[5],this},restore:function(){if(this.currentMatrixIndex<=0)return this;this.currentMatrixIndex-=6;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],e[4]=t[i+4],e[5]=t[i+5],this},loadIdentity:function(){return this.setTransform(1,0,0,1,0,0),this},transform:function(t,e,i,n,s,r){var o=this.currentMatrix,a=o[0],h=o[1],u=o[2],l=o[3],c=o[4],d=o[5];return o[0]=a*t+u*e,o[1]=h*t+l*e,o[2]=a*i+u*n,o[3]=h*i+l*n,o[4]=a*s+u*r+c,o[5]=h*s+l*r+d,this},setTransform:function(t,e,i,n,s,r){var o=this.currentMatrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},translate:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3],a=i[4],h=i[5];return i[4]=n*t+r*e+a,i[5]=s*t+o*e+h,this},scale:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3];return i[0]=n*t,i[1]=s*t,i[2]=r*e,i[3]=o*e,this},rotate:function(t){var e=this.currentMatrix,i=e[0],n=e[1],s=e[2],r=e[3],o=Math.sin(t),a=Math.cos(t);return e[0]=i*a+s*o,e[1]=n*a+r*o,e[2]=i*-o+s*a,e[3]=n*-o+r*a,this}};t.exports=i},function(t,e,i){var n=i(214),s=i(213),r={mask:null,setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask.destroy(),this.mask=null,this},createBitmapMask:function(t){return void 0===t&&this.texture&&(t=this),new n(this.scene,t)},createGeometryMask:function(t){return void 0===t&&"Graphics"===this.type&&(t=this),new s(this.scene,t)}};t.exports=r},function(t,e,i){var n=i(14),s=i(292),r=i(6),o={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getTopRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBounds:function(t){var e,i,s,r,o,a,h,u;if(void 0===t&&(t=new n),this.parentContainer){var l=this.parentContainer.getBoundsTransformMatrix();this.getTopLeft(t),l.transformPoint(t.x,t.y,t),e=t.x,i=t.y,this.getTopRight(t),l.transformPoint(t.x,t.y,t),s=t.x,r=t.y,this.getBottomLeft(t),l.transformPoint(t.x,t.y,t),o=t.x,a=t.y,this.getBottomRight(t),l.transformPoint(t.x,t.y,t),h=t.x,u=t.y}else this.getTopLeft(t),e=t.x,i=t.y,this.getTopRight(t),s=t.x,r=t.y,this.getBottomLeft(t),o=t.x,a=t.y,this.getBottomRight(t),h=t.x,u=t.y;return t.x=Math.min(e,s,o,h),t.y=Math.min(i,r,a,u),t.width=Math.max(e,s,o,h)-t.x,t.height=Math.max(i,r,a,u)-t.y,t}};t.exports=o},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e){var i={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.scene.sys.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=i},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}}},function(t,e,i){var n=i(51),s={_blendMode:n.NORMAL,blendMode:{get:function(){return this._blendMode},set:function(t){"string"==typeof t&&(t=n[t]),(t|=0)>=0&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,e,i){var n=i(23),s={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,s){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=n(t,0,1),this._alphaTR=n(e,0,1),this._alphaBL=n(i,0,1),this._alphaBR=n(s,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=n(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=n(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=n(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=n(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=n(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=s},function(t,e,i){var n=i(46),s=i(44),r=i(45),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(92),s=i(44),r=i(91),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(89),s=i(46),r=i(90),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(89),s=i(48),r=i(90),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(91),s=i(90);t.exports=function(t,e,i){return n(t,e),s(t,i)}},function(t,e,i){var n=i(593),s=i(92),r=i(89);t.exports=function(t,e,i,o){return void 0===i&&(i=0),void 0===o&&(o=0),n(t,s(e)+i,r(e)+o),t}},function(t,e,i){var n=i(50),s=i(46),r=i(49),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(48),r=i(49),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(92),r=i(49),o=i(91);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(299),s=[];s[n.BOTTOM_CENTER]=i(597),s[n.BOTTOM_LEFT]=i(596),s[n.BOTTOM_RIGHT]=i(595),s[n.CENTER]=i(594),s[n.LEFT_CENTER]=i(592),s[n.RIGHT_CENTER]=i(591),s[n.TOP_CENTER]=i(590),s[n.TOP_LEFT]=i(589),s[n.TOP_RIGHT]=i(588);t.exports=function(t,e,i,n,r){return s[i](t,e,n,r)}},function(t,e,i){t.exports={Angle:i(1007),Call:i(1006),GetFirst:i(1005),GetLast:i(1004),GridAlign:i(1003),IncAlpha:i(1002),IncX:i(1001),IncXY:i(1e3),IncY:i(999),PlaceOnCircle:i(998),PlaceOnEllipse:i(997),PlaceOnLine:i(996),PlaceOnRectangle:i(995),PlaceOnTriangle:i(994),PlayAnimation:i(993),PropertyValueInc:i(35),PropertyValueSet:i(25),RandomCircle:i(992),RandomEllipse:i(991),RandomLine:i(990),RandomRectangle:i(989),RandomTriangle:i(988),Rotate:i(987),RotateAround:i(986),RotateAroundDistance:i(985),ScaleX:i(984),ScaleXY:i(983),ScaleY:i(982),SetAlpha:i(981),SetBlendMode:i(980),SetDepth:i(979),SetHitArea:i(978),SetOrigin:i(977),SetRotation:i(976),SetScale:i(975),SetScaleX:i(974),SetScaleY:i(973),SetTint:i(972),SetVisible:i(971),SetX:i(970),SetXY:i(969),SetY:i(968),ShiftPosition:i(967),Shuffle:i(966),SmootherStep:i(965),SmoothStep:i(964),Spread:i(963),ToggleVisible:i(962),WrapInRectangle:i(961)}},function(t,e){if("function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var i=function(t){var e=new Array;window[t]=function(t){if("number"==typeof t){Array.call(this,t),this.length=t;for(var e=0;e>>0;if("function"!=typeof t)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,s=0;s0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=this.tileset,a=t.gameContext,h=r.length,u=o.image.getSourceImage(),l=e.x-s.scrollX*e.scrollFactorX,c=e.y-s.scrollY*e.scrollFactorY;a.save(),a.translate(l,c),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY),a.scale(e.flipX?-1:1,e.flipY?-1:1),a.globalAlpha=e.alpha;for(var d=0;d0&&e.cameraFilter&s._id||(e.upload(s),this.pipeline.drawStaticTilemapLayer(e,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(623),s=i(622),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=r.length,a=e.tileset.image.getSourceImage(),h=this.tileset,u=e.x-s.scrollX*e.scrollFactorX,l=e.y-s.scrollY*e.scrollFactorY,c=t.gameContext;c.save(),c.translate(u,l),c.rotate(e.rotation),c.scale(e.scaleX,e.scaleY),c.scale(e.flipX?-1:1,e.flipY?-1:1);for(var d=0;d0&&e.cameraFilter&s._id||(e.cull(s),this.pipeline.batchDynamicTilemapLayer(e,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(626),s=i(625),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(137);t.exports=function(t){for(var e=[],i=[],s=0;s-1?new s(a,f,c,l,o.tilesize,o.tilesize):e?null:new s(a,-1,c,l,o.tilesize,o.tilesize),h.push(d)}u.push(h),h=[]}a.data=u,i.push(a)}return i}},function(t,e,i){var n=i(17);t.exports=function(t){for(var e,i,s,r,o,a=0;a>>0;return n}},function(t,e,i){var n=i(636),s=i(1),r=i(104),o=i(316),a=i(66);t.exports=function(t,e){for(var i=[],h=0;h0){var m=new a(l,v.gid,c,f.length,t.tilewidth,t.tileheight);m.rotation=v.rotation,m.flipX=v.flipped,d.push(m)}else{var y=e?null:new a(l,-1,c,f.length,t.tilewidth,t.tileheight);d.push(y)}++c===u.width&&(f.push(d),c=0,d=[])}l.data=f,i.push(l)}}return i}},function(t,e,i){t.exports={Parse:i(319),Parse2DArray:i(217),ParseCSV:i(318),Impact:i(312),Tiled:i(317)}},function(t,e,i){var n=i(53),s=i(52),r=i(6);t.exports=function(t,e,i,o,a,h){return void 0===o&&(o=new r(0,0)),o.x=n(t,i,a,h),o.y=s(e,i,a,h),o}},function(t,e,i){var n=i(21);t.exports=function(t,e,i,s,r,o){if(void 0!==r){var a,h=n(t,e,i,s,null,o),u=0;for(a=0;a0&&n(a,t)}}e&&s(0,0,i.width,i.height,i)}},function(t,e,i){var n=i(67),s=i(40),r=i(111);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0);for(var a=0;ae)){for(var h=t;h<=e;h++)r(h,i,a);for(var u=0;u=t&&c.index<=e&&n(c,i)}o&&s(0,0,a.width,a.height,a)}}},function(t,e,i){var n=i(67),s=i(40),r=i(218);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a=0;r--)for(s=n.width-1;s>=0;s--)if((o=n.data[r][s])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;r=S&&F>=A&&L+a<=C&&F+h<=M&&i.push(P)}}return i}},function(t,e,i){var n=i(139),s=i(138),r=i(21),o=i(322);t.exports=function(t,e,i,a,h,u){void 0===i&&(i={}),Array.isArray(t)||(t=[t]);var l=u.tilemapLayer;void 0===a&&(a=l.scene),void 0===h&&(h=a.cameras.main);var c,d=r(0,0,u.width,u.height,null,u),f=[];for(c=0;c=0&&p=0&&g0?1:-1),u=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),l=.5*(h+u);h-=l,u-=l,t.velocity.y=l+h*t.bounce.y,e.velocity.y=l+u*e.bounce.y}return!0}},function(t,e,i){var n=i(337);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.x,a=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=r,e.velocity.x=o-a*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=r,t.velocity.x=a-o*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{r*=.5,t.x-=r,e.x+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),u=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),l=.5*(h+u);h-=l,u-=l,t.velocity.x=l+h*t.bounce.x,e.velocity.x=l+u*e.bounce.x}return!0}},function(t,e){t.exports=function(t,e){e<0?t.blocked.up=!0:e>0&&(t.blocked.down=!0),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},function(t,e,i){var n=i(684);t.exports=function(t,e,i,s,r){var o=0;return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom>i&&(o=t.bottom-i)>r&&(o=0),0!==o&&(t.customSeparateY?t.overlapY=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?t.blocked.left=!0:e>0&&(t.blocked.right=!0),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},function(t,e,i){var n=i(686);t.exports=function(t,e,i,s,r){var o=0;return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right>i&&(o=t.right-i)>r&&(o=0),0!==o&&(t.customSeparateX?t.overlapX=o:n(t,o)),o}},function(t,e,i){var n=i(687),s=i(685),r=i(335);t.exports=function(t,e,i,o,a,h){var u=o.left,l=o.top,c=o.right,d=o.bottom,f=i.faceLeft||i.faceRight,p=i.faceTop||i.faceBottom;if(!f&&!p)return!1;var g=0,v=0,m=0,y=1;if(e.deltaAbsX()>e.deltaAbsY()?m=-1:e.deltaAbsX()=0;a--){var h=e[a],u=r(s,o,h.x,h.y);u=0;a--){var h=e[a],u=r(s,o,h.x,h.y);u>i&&(n=h,i=u)}return n},moveTo:function(t,e,i,n,s){void 0===n&&(n=60),void 0===s&&(s=0);var o=Math.atan2(i-t.y,e-t.x);return s>0&&(n=r(t.x,t.y,e,i)/(s/1e3)),t.body.velocity.setToPolar(o,n),o},moveToObject:function(t,e,i,n){return this.moveTo(t,e.x,e.y,i,n)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new l),i.setToPolar(s(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new l),i.setToPolar(t,e)},shutdown:function(){var t=this.systems.events;t.off("update",this.world.update,this.world),t.off("postupdate",this.world.postUpdate,this.world),t.off("shutdown",this.shutdown,this),this.add.destroy(),this.world.destroy(),this.add=null,this.world=null},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null}});u.register("ArcadePhysics",d,"arcadePhysics"),t.exports=d},function(t,e,i){var n=i(42),s=i(17),r={ArcadePhysics:i(702),Body:i(339),Collider:i(338),Factory:i(345),Group:i(342),Image:i(344),Sprite:i(142),StaticBody:i(334),StaticGroup:i(341),World:i(340)};r=s(!1,r,n),t.exports=r},function(t,e){t.exports=function(t,e,i){return Math.abs(t-e)<=i}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),n*=Math.PI/t;for(var s=[],r=[],o=0;o1?void 0!==n?(s=(n-t)/(n-i))<0&&(s=0):s=1:s<0&&(s=0),s}},function(t,e){t.exports=function(t,e,i){return Math.max(t-e,i)}},function(t,e){t.exports=function(t,e,i){return Math.min(t+e,i)}},function(t,e){t.exports=function(t){return t===parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t){return t==parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t,e){return t/e/1e3}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.floor(t*n)/n}},function(t,e){t.exports=function(t,e){return Math.abs(t-e)}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.ceil(t*n)/n}},function(t,e){t.exports=function(t){for(var e=0,i=0;i0&&0==(t&t-1)}},function(t,e,i){t.exports={GetNext:i(411),IsSize:i(85),IsValue:i(722)}},function(t,e,i){var n=i(287);t.exports=function(t,e,i){return e+(i-e)*n(t,0,1)}},function(t,e,i){var n=i(286);t.exports=function(t,e,i){return e+(i-e)*n(t,0,1)}},function(t,e,i){var n=i(122);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return e<0?n(t[0],t[1],s):e>1?n(t[i],t[i-1],i-s):n(t[r],t[r+1>i?i:r+1],s-r)}},function(t,e,i){var n=i(273);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return t[0]===t[i]?(e<0&&(r=Math.floor(s=i*(1+e))),n(s-r,t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i])):e<0?t[0]-(n(-s,t[0],t[0],t[1],t[1])-t[0]):e>1?t[i]-(n(s-i,t[i],t[i],t[i-1],t[i-1])-t[i]):n(s-r,t[r?r-1:0],t[r],t[i=n.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:e'),i.push(''),i.push(''),i.push(this.xhrLoader.responseText),i.push(""),i.push(""),i.push("");var n=[i.join("\n")],o=this;try{var a=new window.Blob(n,{type:"image/svg+xml;charset=utf-8"})}catch(t){return o.state=s.FILE_ERRORED,void o.onProcessComplete()}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(o.data),o.onProcessComplete()},this.data.onerror=function(){r.revokeObjectURL(o.data),o.onProcessError()},r.createObjectURL(this.data,a,"image/svg+xml")},addToCache:function(){var t=this.cache.addImage(this.key,this.data);this.pendingDestroy(t)}});o.register("html",function(t,e,i,n,s){if(Array.isArray(t))for(var r=0;r0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r)e.x&&t.ye.y}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e,i){var n=Math.min(t.x,e),s=Math.max(t.right,e);t.x=n,t.width=s-n;var r=Math.min(t.y,i),o=Math.max(t.bottom,i);return t.y=r,t.height=o-r,t}},function(t,e){t.exports=function(t,e){var i=Math.min(t.x,e.x),n=Math.max(t.right,e.right);t.x=i,t.width=n-i;var s=Math.min(t.y,e.y),r=Math.max(t.bottom,e.bottom);return t.y=s,t.height=r-s,t}},function(t,e){t.exports=function(t,e){for(var i=t.x,n=t.right,s=t.y,r=t.bottom,o=0;on(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},function(t,e,i){var n=i(228);t.exports=function(t,e){var i=n(t);return ii&&(i=h.x),h.xr&&(r=h.y),h.ye.right||t.righte.bottom||t.bottom0||(c=s(e),(d=n(t,c,!0)).length>0)}},function(t,e,i){var n=i(60),s=i(144);t.exports=function(t,e){return!!(n(t,e.getPointA())||n(t,e.getPointB())||s(t.getLineA(),e)||s(t.getLineB(),e)||s(t.getLineC(),e))}},function(t,e,i){var n=i(397),s=i(60);t.exports=function(t,e){return!(t.left>e.right||t.righte.bottom||t.bottomt.right+r||it.bottom+r||st.right||e.rightt.bottom||e.bottom0}},function(t,e,i){var n=i(396);t.exports=function(t,e){if(!n(t,e))return!1;var i=Math.min(e.x1,e.x2),s=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=s&&t.y>=r&&t.y<=o}},function(t,e){t.exports=function(t,e){var i=t.x1,n=t.y1,s=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,u=e.bottom,l=0;if(i>=o&&i<=h&&n>=a&&n<=u||s>=o&&s<=h&&r>=a&&r<=u)return!0;if(i=o){if((l=n+(r-n)*(o-i)/(s-i))>a&&l<=u)return!0}else if(i>h&&s<=h&&(l=n+(r-n)*(h-i)/(s-i))>=a&&l<=u)return!0;if(n=a){if((l=i+(s-i)*(a-n)/(r-n))>=o&&l<=h)return!0}else if(n>u&&r<=u&&(l=i+(s-i)*(u-n)/(r-n))>=o&&l<=h)return!0;return!1}},function(t,e,i){var n=i(14),s=i(398);t.exports=function(t,e,i){return void 0===i&&(i=new n),s(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},function(t,e){t.exports=function(t,e){var i=e.width/2,n=e.height/2,s=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-n),o=i+t.radius,a=n+t.radius;if(s>o||r>a)return!1;if(s<=i||r<=n)return!0;var h=s-i,u=r-n;return h*h+u*u<=t.radius*t.radius}},function(t,e,i){var n=i(58);t.exports=function(t,e){return n(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(14);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},function(t,e,i){var n=i(32);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(32);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(88);t.exports=function(t){return new n(t.x,t.y,t.radius)}},function(t,e){t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},function(t,e,i){var n=i(88);n.Area=i(853),n.Circumference=i(295),n.CircumferencePoint=i(136),n.Clone=i(852),n.Contains=i(32),n.ContainsPoint=i(851),n.ContainsRect=i(850),n.CopyFrom=i(849),n.Equals=i(848),n.GetBounds=i(847),n.GetPoint=i(298),n.GetPoints=i(296),n.Offset=i(846),n.OffsetPoint=i(845),n.Random=i(157),t.exports=n},function(t,e,i){var n=i(0),s=i(401),r=i(12),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",o,"lights"),t.exports=o},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(232);s.register("quad",function(t,e){void 0===t&&(t={});var i=r(t,"x",0),s=r(t,"y",0),a=r(t,"key",null),h=r(t,"frame",null),u=new o(this.scene,i,s,a,h);return void 0!==e&&(t.add=e),n(this.scene,u,t),u})},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(4),a=i(145);s.register("mesh",function(t,e){void 0===t&&(t={});var i=r(t,"key",null),s=r(t,"frame",null),h=o(t,"vertices",[]),u=o(t,"colors",[]),l=o(t,"alphas",[]),c=o(t,"uv",[]),d=new a(this.scene,0,0,h,c,u,l,i,s);return void 0!==e&&(t.add=e),n(this.scene,d,t),d})},function(t,e,i){var n=i(232);i(11).register("quad",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(145);i(11).register("mesh",function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))})},function(t,e){t.exports=function(){}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchMesh(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(861),s=i(860),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(13),s=i(10),r=i(158);n.register("zone",function(t){var e=s(t,"x",0),i=s(t,"y",0),n=s(t,"width",1),o=s(t,"height",n);return new r(this.scene,e,i,n,o)})},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(233);s.register("tileSprite",function(t,e){void 0===t&&(t={});var i=r(t,"x",0),s=r(t,"y",0),a=r(t,"width",512),h=r(t,"height",512),u=r(t,"key",""),l=r(t,"frame",""),c=new o(this.scene,i,s,a,h,u,l);return void 0!==e&&(t.add=e),n(this.scene,c,t),c})},function(t,e,i){var n=i(253),s=i(24),r=i(13),o=i(10),a=i(4);r.register("bitmapText",function(t,e){void 0===t&&(t={});var i=a(t,"font",""),r=o(t,"text",""),h=o(t,"size",!1),u=new n(this.scene,0,0,i,r,h);return void 0!==e&&(t.add=e),s(this.scene,u,t),u})},function(t,e,i){var n=i(24),s=i(127),r=i(13),o=i(10),a=i(151);r.register("sprite3D",function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),h=new a(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),n(this.scene,h,t),s(h,t),h})},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(234);s.register("renderTexture",function(t,e){void 0===t&&(t={});var i=r(t,"x",0),s=r(t,"y",0),a=r(t,"width",32),h=r(t,"height",32),u=new o(this.scene,i,s,a,h);return void 0!==e&&(t.add=e),n(this.scene,u,t),u})},function(t,e,i){var n=i(13),s=i(10),r=i(1),o=i(235);n.register("particles",function(t,e){void 0===t&&(t={});var i=s(t,"key",null),n=s(t,"frame",null),a=r(t,"emitters",null),h=new o(this.scene,i,n,a);return void 0!==e&&(t.add=e),r(t,"add",!1)&&this.displayList.add(h),this.updateList.add(h),h})},function(t,e,i){var n=i(13),s=i(112);n.register("group",function(t){return new s(this.scene,null,t)})},function(t,e,i){var n=i(250),s=i(24),r=i(13),o=i(10);r.register("dynamicBitmapText",function(t,e){void 0===t&&(t={});var i=o(t,"font",""),r=o(t,"text",""),a=o(t,"size",!1),h=new n(this.scene,0,0,i,r,a);return void 0!==e&&(t.add=e),s(this.scene,h,t),h})},function(t,e,i){var n=i(24),s=i(251),r=i(13),o=i(10);r.register("container",function(t,e){void 0===t&&(t={});var i=o(t,"x",0),r=o(t,"y",0),a=new s(this.scene,i,r);return void 0!==e&&(t.add=e),n(this.scene,a,t),a})},function(t,e,i){var n=i(252),s=i(24),r=i(13),o=i(10);r.register("blitter",function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),a=new n(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),s(this.scene,a,t),a})},function(t,e,i){var n=i(158);i(11).register("zone",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(233);i(11).register("tileSprite",function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))})},function(t,e,i){var n=i(253);i(11).register("bitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(151);i(11).register("sprite3D",function(t,e,i,s,r){var o=new n(this.scene,t,e,i,s,r);return this.displayList.add(o.gameObject),this.updateList.add(o.gameObject),o})},function(t,e,i){var n=i(11),s=i(234);n.register("renderTexture",function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))})},function(t,e,i){var n=i(11),s=i(418);n.register("follower",function(t,e,i,n,r){var o=new s(this.scene,t,e,i,n,r);return this.displayList.add(o),this.updateList.add(o),o})},function(t,e,i){var n=i(11),s=i(235);n.register("particles",function(t,e,i){var n=new s(this.scene,t,e,i);return this.displayList.add(n),this.updateList.add(n),n})},function(t,e,i){var n=i(112);i(11).register("group",function(t,e){return"object"==typeof t&&void 0===e&&(e=t,t=[]),this.updateList.add(new n(this.scene,t,e))})},function(t,e,i){var n=i(250);i(11).register("dynamicBitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(251);i(11).register("container",function(t,e,i){return this.displayList.add(new n(this.scene,t,e,i))})},function(t,e,i){var n=i(252);i(11).register("blitter",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var o=t.currentContext,a=e.frame;e.updateTileTexture(),t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,o.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,o.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var h=a.x-e.originX*e.width,u=a.y-e.originY*e.height,l=e.x-s.scrollX*e.scrollFactorX,c=e.y-s.scrollY*e.scrollFactorY,d=1,f=1;if(e.flipX&&(d=-1,h+=e.width),e.flipY&&(f=-1,u+=e.height),t.config.roundPixels&&(h|=0,u|=0,l|=0,c|=0),o.save(),void 0!==r){var p=r.matrix;o.transform(p[0],p[1],p[2],p[3],p[4],p[5])}o.translate(h,u),o.translate(l,c),o.scale(d,f),o.translate(e.originX*e.width,e.originY*e.height),o.rotate(d*f*e.rotation),o.scale(this.scaleX,this.scaleY),o.translate(-e.originX*e.width,-e.originY*e.height),o.translate(-this.tilePositionX,-this.tilePositionY),o.fillStyle=e.canvasPattern,o.fillRect(this.tilePositionX,this.tilePositionY,e.width,e.height),o.restore()}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||(e.updateTileTexture(),this.pipeline.batchTileSprite(this,s,r))}},function(t,e,i){var n=i(3),s=i(3);n=i(885),s=i(884),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(4);t.exports=function(t,e){var i=e.width,s=e.height,r=Math.floor(i/2),o=Math.floor(s/2),a=n(e,"chars","");if(""!==a){var h=n(e,"image",""),u=n(e,"offset.x",0),l=n(e,"offset.y",0),c=n(e,"spacing.x",0),d=n(e,"spacing.y",0),f=n(e,"charsPerRow",null);null===f&&(f=t.sys.textures.getFrame(h).width/i)>a.length&&(f=a.length);for(var p=u,g=l,v={retroFont:!0,font:h,size:i,lineHeight:s,chars:{}},m=0,y=0;y?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",TEXT_SET2:" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET3:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",TEXT_SET4:"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",TEXT_SET5:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",TEXT_SET6:"ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",TEXT_SET7:"AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",TEXT_SET8:"0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET9:"ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",TEXT_SET10:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET11:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789"}},function(t,e,i){var n=i(888),s=i(17),r={Parse:i(887)};r=s(!1,r,n),t.exports=r},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);this.renderer.setFramebuffer(this.framebuffer);var s=this.gl;return s.clearColor(e/255,i/255,n/255,1),s.clear(s.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},clear:function(){this.renderer.setFramebuffer(this.framebuffer);var t=this.gl;return t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},draw:function(t,e,i,n){var s=t.source[e.sourceIndex].glTexture,r=(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16);return this.renderer.setFramebuffer(this.framebuffer),this.renderer.pipelines.TextureTintPipeline.projOrtho(0,this.renderer.pipelines.TextureTintPipeline.width,0,this.renderer.pipelines.TextureTintPipeline.height,-1e3,1e3),this.renderer.pipelines.TextureTintPipeline.drawTexture(s,i,n,r,this.globalAlpha,e.cutX,e.cutY,e.cutWidth,e.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,-1e3,1e3),this}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);return this.context.fillStyle="rgb("+e+","+i+","+n+")",this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this},clear:function(){return this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.restore(),this},draw:function(t,e,i,n){var s=e.canvasData,r=e.source.image,o=this.currentMatrix;return this.context.globalAlpha=this.globalAlpha,this.context.setTransform(o[0],o[1],o[2],o[3],o[4],o[5]),this.context.drawImage(r,s.sx,s.sy,s.sWidth,s.sHeight,i,n,s.dWidth,s.dHeight),this}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var o=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,o.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,o.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var a=0,h=0,u=1,l=1;if(e.flipX?(u=-1,a-=e.canvas.width-e.displayOriginX):a-=e.displayOriginX,e.flipY?(l=-1,h-=e.canvas.height-e.displayOriginY):h-=e.displayOriginY,o.save(),void 0!==r){var c=r.matrix;o.transform(c[0],c[1],c[2],c[3],c[4],c[5])}o.translate(e.x-s.scrollX*e.scrollFactorX,e.y-s.scrollY*e.scrollFactorY),o.rotate(e.rotation),o.scale(e.scaleX,e.scaleY),o.scale(u,l),o.drawImage(e.canvas,a,h),o.restore()}}},function(t,e,i){var n=i(2),s=i(27);t.exports=function(t,e,i,r,o){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&r._id||this.pipeline.batchTexture(e,e.texture,e.texture.width,e.texture.height,e.x,e.y,e.width,e.height,e.scaleX,e.scaleY,e.rotation,e.flipX,!e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,e.texture.width,e.texture.height,s.getTintAppendFloatAlpha(e.tintTopLeft,e.alphaTopLeft),s.getTintAppendFloatAlpha(e.tintTopRight,e.alphaTopRight),s.getTintAppendFloatAlpha(e.tintBottomLeft,e.alphaBottomLeft),s.getTintAppendFloatAlpha(e.tintBottomRight,e.alphaBottomRight),0,0,r,o)}},function(t,e,i){var n=i(3),s=i(3);n=i(893),s=i(892),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){t.exports={DeathZone:i(455),EdgeZone:i(454),RandomZone:i(419)}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){var o=e.emitters.list;if(!(0===o.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=t.currentContext;if(a.save(),void 0!==r){var h=r.matrix;a.transform(h[0],h[1],h[2],h[3],h[4],h[5])}for(var u=0;u>24&255)/255;if(!(x<=0)){var w=y.frame,b=.5*w.width,T=.5*w.height,S=w.canvasData,A=-b,C=-T,M=y.x-p,_=y.y-g;v&&(M|=0,_|=0),a.globalAlpha=x,a.save(),a.translate(M,_),a.rotate(y.rotation),a.scale(y.scaleX,y.scaleY),a.drawImage(w.source.image,S.sx,S.sy,S.sWidth,S.sHeight,A,C,S.dWidth,S.dHeight),a.restore()}}a.globalAlpha=f}}a.restore()}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){0===e.emitters.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.drawEmitterManager(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(897),s=i(896),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(0),s=i(248),r=i(63),o=i(1),a=i(39),h=new n({initialize:function(t,e,i,n){void 0===n&&(n=!1),this.propertyKey=e,this.propertyValue=i,this.defaultValue=i,this.steps=0,this.counter=0,this.start=0,this.end=0,this.ease,this.emitOnly=n,this.onEmit=this.defaultEmit,this.onUpdate=this.defaultUpdate,this.loadConfig(t)},loadConfig:function(t,e){void 0===t&&(t={}),e&&(this.propertyKey=e),this.propertyValue=o(t,this.propertyKey,this.defaultValue),this.setMethods(),this.emitOnly&&(this.onUpdate=this.defaultUpdate)},toJSON:function(){return this.propertyValue},onChange:function(t){return this.propertyValue=t,this.setMethods()},setMethods:function(){var t=this.propertyValue,e=typeof t;if("number"===e)this.onEmit=this.staticValueEmit,this.onUpdate=this.staticValueUpdate;else if(Array.isArray(t))this.onEmit=this.randomStaticValueEmit;else if("function"===e)this.emitOnly?this.onEmit=t:this.onUpdate=t;else if("object"===e&&(this.has(t,"random")||this.hasBoth(t,"start","end")||this.hasBoth(t,"min","max"))){this.start=this.has(t,"start")?t.start:t.min,this.end=this.has(t,"end")?t.end:t.max;var i=this.hasBoth(t,"min","max")||this.has(t,"random");if(i){var n=t.random;Array.isArray(n)&&(this.start=n[0],this.end=n[1]),this.onEmit=this.randomRangedValueEmit}if(this.has(t,"steps"))this.steps=t.steps,this.counter=this.start,this.onEmit=this.steppedEmit;else{var s=this.has(t,"ease")?t.ease:"Linear";this.ease=r(s),i||(this.onEmit=this.easedValueEmit),this.onUpdate=this.easeValueUpdate}}else"object"===e&&this.hasEither(t,"onEmit","onUpdate")&&(this.has(t,"onEmit")&&(this.onEmit=t.onEmit),this.has(t,"onUpdate")&&(this.onUpdate=t.onUpdate));return this},has:function(t,e){return t.hasOwnProperty(e)},hasBoth:function(t,e,i){return t.hasOwnProperty(e)&&t.hasOwnProperty(i)},hasEither:function(t,e,i){return t.hasOwnProperty(e)||t.hasOwnProperty(i)},defaultEmit:function(t,e,i){return i},defaultUpdate:function(t,e,i,n){return n},staticValueEmit:function(){return this.propertyValue},staticValueUpdate:function(){return this.propertyValue},randomStaticValueEmit:function(){var t=Math.floor(Math.random()*this.propertyValue.length);return this.propertyValue[t]},randomRangedValueEmit:function(t,e){var i=s(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i),i},steppedEmit:function(){var t=this.counter,e=this.counter+(this.end-this.start)/this.steps;return this.counter=a(e,this.start,this.end),t},easedValueEmit:function(t,e){if(t&&t.data[e]){var i=t.data[e];i.min=this.start,i.max=this.end}return this.start},easeValueUpdate:function(t,e,i){var n=t.data[e];return(n.max-n.min)*this.ease(i)+n.min}});t.exports=h},function(t,e,i){t.exports={GravityWell:i(458),Particle:i(457),ParticleEmitter:i(456),ParticleEmitterManager:i(235),Zones:i(895)}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length;if(!(n.RENDER_MASK!==e.renderFlags||0===a||e.cameraFilter>0&&e.cameraFilter&s._id)){var h=e.frame,u=e.displayCallback,l=s.scrollX*e.scrollFactorX,c=s.scrollY*e.scrollFactorY,d=e.fontData.chars,f=e.fontData.lineHeight,p=0,g=0,v=0,m=0,y=null,x=0,w=0,b=0,T=0,S=0,A=0,C=null,M=0,_=t.currentContext,E=e.frame.source.image,P=h.cutX,L=h.cutY,F=0,k=e.fontSize/e.fontData.size;if(t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,_.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,_.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),_.save(),void 0!==r){var R=r.matrix;_.transform(R[0],R[1],R[2],R[3],R[4],R[5])}_.translate(e.x,e.y),_.rotate(e.rotation),_.translate(-e.displayOriginX,-e.displayOriginY),_.scale(e.scaleX,e.scaleY),e.cropWidth>0&&e.cropHeight>0&&(_.save(),_.beginPath(),_.rect(0,0,e.cropWidth,e.cropHeight),_.clip());for(var O=t.config.roundPixels,D=0;D0&&e.cropHeight>0&&_.restore(),_.restore()}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){var o=e.text.length;n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchDynamicBitmapText(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(902),s=i(901),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var o=e.list,a=e.localTransform;void 0===r?a.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY):(a.loadIdentity(),a.multiply(r),a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY));for(var h=e._alpha,u=e.scrollFactorX,l=e.scrollFactorY,c=0;c0&&e.cameraFilter&s._id)){var o=e.list,a=e.localTransform;void 0===r?a.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY):(a.loadIdentity(),a.multiply(r),a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY));for(var h=e._alpha,u=e.scrollFactorX,l=e.scrollFactorY,c=0;c0&&e.cameraFilter&s._id)){var o=e.getRenderList();t.setBlendMode(e.blendMode);var a=t.gameContext,h=e.x-s.scrollX*e.scrollFactorX,u=e.y-s.scrollY*e.scrollFactorY;if(a.save(),void 0!==r){var l=r.matrix;a.transform(l[0],l[1],l[2],l[3],l[4],l[5])}for(var c=0;c0&&e.cameraFilter&s._id||this.pipeline.drawBlitter(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(909),s=i(908),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length;if(!(n.RENDER_MASK!==e.renderFlags||0===a||e.cameraFilter>0&&e.cameraFilter&s._id)){var h=e.frame,u=e.fontData.chars,l=e.fontData.lineHeight,c=e.letterSpacing,d=0,f=0,p=0,g=0,v=null,m=0,y=0,x=0,w=0,b=0,T=0,S=null,A=0,C=t.currentContext,M=e.frame.source.image,_=h.cutX,E=h.cutY,P=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,C.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,C.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var L=t.config.roundPixels,F=e.x-s.scrollX*e.scrollFactorX+e.frame.x,k=e.y-s.scrollY*e.scrollFactorY+e.frame.y;if(L&&(F|=0,k|=0),C.save(),void 0!==r){var R=r.matrix;C.transform(R[0],R[1],R[2],R[3],R[4],R[5])}C.translate(F,k),C.rotate(e.rotation),C.translate(-e.displayOriginX,-e.displayOriginY),C.scale(e.scaleX,e.scaleY);for(var O=0;O0&&e.cameraFilter&s._id||this.pipeline.batchBitmapText(this,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(912),s=i(911),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(474);t.exports=function(t,e,i,s,r,o,a){var h=t.sys.textures.getFrame(i,s),u=t.sys.cache.xml.get(r);if(h&&u){var l=n(u,o,a,h);return t.sys.cache.bitmapFont.add(e,{data:l,texture:i,frame:s}),!0}return!1}},function(t,e,i){var n={DisplayList:i(504),GameObjectCreator:i(13),GameObjectFactory:i(11),UpdateList:i(476),Components:i(15),BuildGameObject:i(24),BuildGameObjectAnimation:i(127),GameObject:i(2),BitmapText:i(253),Blitter:i(252),Container:i(251),DynamicBitmapText:i(250),Graphics:i(115),Group:i(112),Image:i(69),Particles:i(900),PathFollower:i(418),RenderTexture:i(234),RetroFont:i(889),Sprite3D:i(151),Sprite:i(34),Text:i(110),TileSprite:i(233),Zone:i(158),Factories:{Blitter:i(883),Container:i(882),DynamicBitmapText:i(881),Graphics:i(410),Group:i(880),Image:i(409),Particles:i(879),PathFollower:i(878),RenderTexture:i(877),Sprite3D:i(876),Sprite:i(408),StaticBitmapText:i(875),Text:i(407),TileSprite:i(874),Zone:i(873)},Creators:{Blitter:i(872),Container:i(871),DynamicBitmapText:i(870),Graphics:i(406),Group:i(869),Image:i(405),Particles:i(868),RenderTexture:i(867),Sprite3D:i(866),Sprite:i(404),StaticBitmapText:i(865),Text:i(403),TileSprite:i(864),Zone:i(863)}};n.Mesh=i(145),n.Quad=i(232),n.Factories.Mesh=i(859),n.Factories.Quad=i(858),n.Creators.Mesh=i(857),n.Creators.Quad=i(856),n.Light=i(402),i(401),i(855),t.exports=n},function(t,e,i){t.exports={AddToDOM:i(130),DOMContentLoaded:i(271),ParseXML:i(270),RemoveFromDOM:i(269),RequestAnimationFrame:i(268)}},function(t,e,i){var n=i(541);t.exports=function(t,e,i,s,r){return void 0===s&&(s=255),void 0===r&&(r="#"),"#"===r?"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1):"0x"+n(s)+n(t)+n(e)+n(i)}},function(t,e){t.exports=function(t,e,i){t/=255,e/=255,i/=255;var n=Math.min(t,e,i),s=Math.max(t,e,i),r=s-n,o=0;return s!==n&&(s===t?o=(e-i)/r+(e>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},function(t,e){t.exports=function(t,e){void 0===e&&(e="none");return["-webkit-","-khtml-","-moz-","-ms-",""].forEach(function(i){t.style[i+"user-select"]=e}),t.style["-webkit-touch-callout"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}},function(t,e){t.exports=function(t,e){return void 0===e&&(e="none"),t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}},function(t,e,i){t.exports={Interpolation:i(272),Pool:i(22),Smoothing:i(131),TouchAction:i(925),UserSelect:i(924)}},function(t,e){t.exports=function(t){return t.height*t.originY}},function(t,e){t.exports=function(t){return t.width*t.originX}},function(t,e,i){t.exports={CenterOn:i(593),GetBottom:i(50),GetCenterX:i(92),GetCenterY:i(89),GetLeft:i(48),GetOffsetX:i(928),GetOffsetY:i(927),GetRight:i(46),GetTop:i(44),SetBottom:i(49),SetCenterX:i(91),SetCenterY:i(90),SetLeft:i(47),SetRight:i(45),SetTop:i(43)}},function(t,e,i){var n=i(46),s=i(44),r=i(49),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(49),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)-a),t}},function(t,e,i){var n=i(92),s=i(44),r=i(49),o=i(91);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(46),s=i(44),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(89),s=i(46),r=i(90),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(46),r=i(49),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(45),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(89),s=i(48),r=i(90),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(48),r=i(49),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(46),r=i(45),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(48),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(92),r=i(91),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){t.exports={BottomCenter:i(941),BottomLeft:i(940),BottomRight:i(939),LeftBottom:i(938),LeftCenter:i(937),LeftTop:i(936),RightBottom:i(935),RightCenter:i(934),RightTop:i(933),TopCenter:i(932),TopLeft:i(931),TopRight:i(930)}},function(t,e,i){t.exports={BottomCenter:i(597),BottomLeft:i(596),BottomRight:i(595),Center:i(594),LeftCenter:i(592),QuickSet:i(598),RightCenter:i(591),TopCenter:i(590),TopLeft:i(589),TopRight:i(588)}},function(t,e,i){var n=i(299),s=i(17),r={In:i(943),To:i(942)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Align:i(944),Bounds:i(929),Canvas:i(926),Color:i(542),Masks:i(538)}},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t,e){this.active=!1,this.p0=new s(t,e)},getPoint:function(t,e){return void 0===e&&(e=new s),e.copy(this.p0)},getPointAt:function(t,e){return this.getPoint(t,e)},getResolution:function(){return 1},getLength:function(){return 0},toJSON:function(){return{type:"MoveTo",points:[this.p0.x,this.p0.y]}}});t.exports=r},function(t,e,i){var n=i(0),s=i(551),r=i(549),o=i(11),a=i(548),h=i(946),u=i(547),l=i(14),c=i(545),d=i(6),f=new n({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.name="",this.curves=[],this.cacheLengths=[],this.autoClose=!1,this.startPoint=new d,this._tmpVec2A=new d,this._tmpVec2B=new d,"object"==typeof t?this.fromJSON(t):this.startPoint.set(t,e)},add:function(t){return this.curves.push(t),this},circleTo:function(t,e,i){return void 0===e&&(e=!1),this.ellipseTo(t,t,0,360,e,i)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return t.equals(e)||this.curves.push(new a(e,t)),this},cubicBezierTo:function(t,e,i,n,r,o){var a,h,u,l=this.getEndPoint();return t instanceof d?(a=t,h=e,u=i):(a=new d(i,n),h=new d(r,o),u=new d(t,e)),this.add(new s(l,a,h,u))},quadraticBezierTo:function(t,e,i,n){var s,r,o=this.getEndPoint();return t instanceof d?(s=t,r=e):(s=new d(i,n),r=new d(t,e)),this.add(new u(o,s,r))},draw:function(t,e){for(var i=0;i0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),n=this.getCurveLengths(),s=0;s=i){var r=n[s]-i,o=this.curves[s],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}s++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],n=0;n1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e0;){this.cameras.pop().destroy()}return this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoom<.1&&(e.zoom=.1))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(4),r=new n({initialize:function(t){this.camera=s(t,"camera",null),this.left=s(t,"left",null),this.right=s(t,"right",null),this.up=s(t,"up",null),this.down=s(t,"down",null),this.zoomIn=s(t,"zoomIn",null),this.zoomOut=s(t,"zoomOut",null),this.zoomSpeed=s(t,"zoomSpeed",.01),this.speedX=0,this.speedY=0;var e=s(t,"speed",null);"number"==typeof e?(this.speedX=e,this.speedY=e):(this.speedX=s(t,"speed.x",0),this.speedY=s(t,"speed.y",0)),this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this.up&&this.up.isDown?e.scrollY-=this.speedY*t|0:this.down&&this.down.isDown&&(e.scrollY+=this.speedY*t|0),this.left&&this.left.isDown?e.scrollX-=this.speedX*t|0:this.right&&this.right.isDown&&(e.scrollX+=this.speedX*t|0),this.zoomIn&&this.zoomIn.isDown?(e.zoom-=this.zoomSpeed,e.zoom<.1&&(e.zoom=.1)):this.zoomOut&&this.zoomOut.isDown&&(e.zoom+=this.zoomSpeed)}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){t.exports={FixedKeyControl:i(958),SmoothedKeyControl:i(957)}},function(t,e,i){t.exports={Controls:i(959),Scene2D:i(566),Sprite3D:i(956)}},function(t,e,i){var n=i(39);t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=0;s1)if(0===s){var d=t.length-1;for(o=t[d].x,a=t[d].y,h=d-1;h>=0;h--)u=(c=t[h]).x,l=c.y,c.x=o,c.y=a,o=u,a=l;t[d].x=e,t[d].y=i}else{for(o=t[0].x,a=t[0].y,h=1;h0?s(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},transformMat3:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},transformMat4:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[4]*i+n[12],this.y=n[1]*e+n[5]*i+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,e){t.exports=function(t,e,i){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(e.indexOf(".")){for(var n=e.split("."),s=t,r=i,o=0;o=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=l},function(t,e){t.exports={getTintFromFloats:function(t,e,i,n){return((255&(255*n|0))<<24|(255&(255*t|0))<<16|(255&(255*e|0))<<8|255&(255*i|0))>>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,n=0;no.width&&(i=Math.max(o.width-t,0)),e+s>o.height&&(s=Math.max(o.height-e,0));for(var u=[],c=e;c0&&this.cameraFilter&t.id)},getIndexList:function(){for(var t=this,e=this.parentContainer,i=[];e&&(i.unshift(e.getIndex(t)),t=e,e.parentContainer);)e=e.parentContainer;return i.unshift(this.scene.sys.displayList.getIndex(t)),i},destroy:function(t){if(void 0===t&&(t=!1),this.scene&&!this.ignoreDestroy){this.preDestroy&&this.preDestroy.call(this),this.emit("destroy",this);var e=this.scene.sys;t||(e.displayList.remove(this),e.updateList.remove(this)),this.input&&(e.input.clear(this),this.input=void 0),this.data&&(this.data.destroy(),this.data=void 0),this.body&&(this.body.destroy(),this.body=void 0),t||e.queueDepthSort(),this.active=!1,this.visible=!1,this.scene=void 0,this.parentContainer=void 0,this.removeAllListeners()}}});a.RENDER_MASK=15,t.exports=a},function(t,e,i){var n=i(8),s=function(){var t,e,i,r,o,a,h=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof h&&(c=h,h=arguments[1]||{},l=2),u===l&&(h=this,--l);l=400&&t.status<=599&&(i=!1),this.resetXHR(),this.loader.nextFile(this,i)},onError:function(){this.resetXHR(),this.loader.nextFile(this,!1)},onProgress:function(t){t.lengthComputable&&(this.bytesLoaded=t.loaded,this.bytesTotal=t.total,this.percentComplete=Math.min(this.bytesLoaded/this.bytesTotal,1),this.loader.emit("fileprogress",this,this.percentComplete))},onProcess:function(){this.state=s.FILE_PROCESSING,this.onProcessComplete()},onProcessComplete:function(){this.state=s.FILE_COMPLETE,this.multiFile&&this.multiFile.onFileComplete(this),this.loader.fileProcessComplete(this)},onProcessError:function(){this.state=s.FILE_ERRORED,this.multiFile&&this.multiFile.onFileFailed(this),this.loader.fileProcessComplete(this)},hasCacheConflict:function(){return this.cache&&this.cache.exists(this.key)},addToCache:function(){this.cache&&this.cache.add(this.key,this.data),this.pendingDestroy()},pendingDestroy:function(t){void 0===t&&(t=this.data);var e=this.key,i=this.type;this.loader.emit("filecomplete",e,i,t),this.loader.emit("filecomplete-"+i+"-"+e,e,i,t),this.loader.flagForRemoval(this)},destroy:function(){this.loader=null,this.cache=null,this.xhrSettings=null,this.multiFile=null,this.linkFile=null,this.data=null}});u.createObjectURL=function(t,e,i){if("function"==typeof URL)t.src=URL.createObjectURL(e);else{var n=new FileReader;n.onload=function(){t.removeAttribute("crossOrigin"),t.src="data:"+(e.type||i)+";base64,"+n.result.split(",")[1]},n.onerror=t.onerror,n.readAsDataURL(e)}},u.revokeObjectURL=function(t){"function"==typeof URL&&URL.revokeObjectURL(t.src)},t.exports=u},function(t,e){t.exports=function(t,e,i,n,s){var r=n.alpha*i.alpha;if(r<=0)return!1;var o=t._tempMatrix1.copyFromArray(n.matrix.matrix),a=t._tempMatrix2.applyITRS(i.x,i.y,i.rotation,i.scaleX,i.scaleY),h=t._tempMatrix3;return s?(o.multiplyWithOffset(s,-n.scrollX*i.scrollFactorX,-n.scrollY*i.scrollFactorY),a.e=i.x,a.f=i.y,o.multiply(a,h)):(a.e-=n.scrollX*i.scrollFactorX,a.f-=n.scrollY*i.scrollFactorY,o.multiply(a,h)),e.globalCompositeOperation=t.blendModes[i.blendMode],e.globalAlpha=r,e.save(),h.setToContext(e),!0}},function(t,e){t.exports=function(t,e,i){return Math.max(e,Math.min(i,t))}},function(t,e,i){var n,s,r,o=i(26),a=i(120),h=[],l=!1;t.exports={create2D:function(t,e,i){return n(t,e,i,o.CANVAS)},create:n=function(t,e,i,n,r){var u;void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=o.CANVAS),void 0===r&&(r=!1);var c=s(n);return null===c?(c={parent:t,canvas:document.createElement("canvas"),type:n},n===o.CANVAS&&h.push(c),u=c.canvas):(c.parent=t,u=c.canvas),r&&(c.parent=u),u.width=e,u.height=i,l&&n===o.CANVAS&&a.disable(u.getContext("2d")),u},createWebGL:function(t,e,i){return n(t,e,i,o.WEBGL)},disableSmoothing:function(){l=!0},enableSmoothing:function(){l=!1},first:s=function(t){if(void 0===t&&(t=o.CANVAS),t===o.WEBGL)return null;for(var e=0;e=0;o--)t[o][e]=i+a*n,a++;return t}},function(t,e,i){var n={VERSION:"3.15.1",BlendModes:i(66),ScaleModes:i(94),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=n},function(t,e,i){var n=i(0),s=i(14),r=i(19),o=i(54),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.ComputedSize,s.Depth,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Transform,s.Visible],initialize:function(t,e,i){void 0===e&&(e="Shape"),r.call(this,t,e),this.geom=i,this.pathData=[],this.pathIndexes=[],this.fillColor=16777215,this.fillAlpha=1,this.strokeColor=16777215,this.strokeAlpha=1,this.lineWidth=1,this.isFilled=!1,this.isStroked=!1,this.closePath=!0,this._tempLine=new o,this.initPipeline()},setFillStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.isFilled=!1:(this.fillColor=t,this.fillAlpha=e,this.isFilled=!0),this},setStrokeStyle:function(t,e,i){return void 0===i&&(i=1),void 0===t?this.isStroked=!1:(this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i,this.isStroked=!0),this},setClosePath:function(t){return this.closePath=t,this},preDestroy:function(){this.geom=null,this._tempLine=null,this.pathData=[],this.pathIndexes=[]}});t.exports=a},function(t,e,i){var n=i(66),s=i(12),r=i(94);t.exports=function(t,e,i){e.x=s(i,"x",0),e.y=s(i,"y",0),e.depth=s(i,"depth",0),e.flipX=s(i,"flipX",!1),e.flipY=s(i,"flipY",!1);var o=s(i,"scale",null);"number"==typeof o?e.setScale(o):null!==o&&(e.scaleX=s(o,"x",1),e.scaleY=s(o,"y",1));var a=s(i,"scrollFactor",null);"number"==typeof a?e.setScrollFactor(a):null!==a&&(e.scrollFactorX=s(a,"x",1),e.scrollFactorY=s(a,"y",1)),e.rotation=s(i,"rotation",0);var h=s(i,"angle",null);null!==h&&(e.angle=h),e.alpha=s(i,"alpha",1);var l=s(i,"origin",null);if("number"==typeof l)e.setOrigin(l);else if(null!==l){var u=s(l,"x",.5),c=s(l,"y",.5);e.setOrigin(u,c)}return e.scaleMode=s(i,"scaleMode",r.DEFAULT),e.blendMode=s(i,"blendMode",n.NORMAL),e.visible=s(i,"visible",!0),s(i,"add",!0)&&t.sys.displayList.add(e),e.preUpdate&&t.sys.updateList.add(e),e}},function(t,e){t.exports={CSV:0,TILED_JSON:1,ARRAY_2D:2,WELTMEISTER:3}},function(t,e){t.exports=function(t,e,i){var n=i||e.fillColor,s=e.fillAlpha,r=(16711680&n)>>>16,o=(65280&n)>>>8,a=255&n;t.fillStyle="rgba("+r+","+o+","+a+","+s+")"}},function(t,e,i){var n=i(16);t.exports=function(t){return t*n.DEG_TO_RAD}},function(t,e){t.exports=function(t,e,i,n,s,r){var o;void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=s;o=0;o--)t[o][e]+=i+a*n,a++;return t}},,function(t,e,i){var n=i(102),s=i(17);t.exports=function(t,e,i,r,o){for(var a=null,h=null,l=null,u=null,c=s(t,e,i,r,null,o),d=0;d>>16,r=(65280&i)>>>8,o=255&i;t.strokeStyle="rgba("+s+","+r+","+o+","+n+")",t.lineWidth=e.lineWidth}},function(t,e,i){var n=i(0),s=i(177),r=i(376),o=i(176),a=i(375),h=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=255),this.r=0,this.g=0,this.b=0,this.a=255,this._h=0,this._s=0,this._v=0,this._locked=!1,this.gl=[0,0,0,1],this._color=0,this._color32=0,this._rgba="",this.setTo(t,e,i,n)},transparent:function(){return this._locked=!0,this.red=0,this.green=0,this.blue=0,this.alpha=0,this._locked=!1,this.update(!0)},setTo:function(t,e,i,n,s){return void 0===n&&(n=255),void 0===s&&(s=!0),this._locked=!0,this.red=t,this.green=e,this.blue=i,this.alpha=n,this._locked=!1,this.update(s)},setGLTo:function(t,e,i,n){return void 0===n&&(n=1),this._locked=!0,this.redGL=t,this.greenGL=e,this.blueGL=i,this.alphaGL=n,this._locked=!1,this.update(!0)},setFromRGB:function(t){return this._locked=!0,this.red=t.r,this.green=t.g,this.blue=t.b,t.hasOwnProperty("a")&&(this.alpha=t.a),this._locked=!1,this.update(!0)},setFromHSV:function(t,e,i){return o(t,e,i,this)},update:function(t){if(void 0===t&&(t=!1),this._locked)return this;var e=this.r,i=this.g,n=this.b,o=this.a;return this._color=s(e,i,n),this._color32=r(e,i,n,o),this._rgba="rgba("+e+","+i+","+n+","+o/255+")",t&&a(e,i,n,this),this},updateHSV:function(){var t=this.r,e=this.g,i=this.b;return a(t,e,i,this),this},clone:function(){return new h(this.r,this.g,this.b,this.a)},gray:function(t){return this.setTo(t,t,t)},random:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t)),n=Math.floor(t+Math.random()*(e-t)),s=Math.floor(t+Math.random()*(e-t));return this.setTo(i,n,s)},randomGray:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t));return this.setTo(i,i,i)},saturate:function(t){return this.s+=t/100,this},desaturate:function(t){return this.s-=t/100,this},lighten:function(t){return this.v+=t/100,this},darken:function(t){return this.v-=t/100,this},brighten:function(t){var e=this.r,i=this.g,n=this.b;return e=Math.max(0,Math.min(255,e-Math.round(-t/100*255))),i=Math.max(0,Math.min(255,i-Math.round(-t/100*255))),n=Math.max(0,Math.min(255,n-Math.round(-t/100*255))),this.setTo(e,i,n)},color:{get:function(){return this._color}},color32:{get:function(){return this._color32}},rgba:{get:function(){return this._rgba}},redGL:{get:function(){return this.gl[0]},set:function(t){this.gl[0]=Math.min(Math.abs(t),1),this.r=Math.floor(255*this.gl[0]),this.update(!0)}},greenGL:{get:function(){return this.gl[1]},set:function(t){this.gl[1]=Math.min(Math.abs(t),1),this.g=Math.floor(255*this.gl[1]),this.update(!0)}},blueGL:{get:function(){return this.gl[2]},set:function(t){this.gl[2]=Math.min(Math.abs(t),1),this.b=Math.floor(255*this.gl[2]),this.update(!0)}},alphaGL:{get:function(){return this.gl[3]},set:function(t){this.gl[3]=Math.min(Math.abs(t),1),this.a=Math.floor(255*this.gl[3]),this.update()}},red:{get:function(){return this.r},set:function(t){t=Math.floor(Math.abs(t)),this.r=Math.min(t,255),this.gl[0]=t/255,this.update(!0)}},green:{get:function(){return this.g},set:function(t){t=Math.floor(Math.abs(t)),this.g=Math.min(t,255),this.gl[1]=t/255,this.update(!0)}},blue:{get:function(){return this.b},set:function(t){t=Math.floor(Math.abs(t)),this.b=Math.min(t,255),this.gl[2]=t/255,this.update(!0)}},alpha:{get:function(){return this.a},set:function(t){t=Math.floor(Math.abs(t)),this.a=Math.min(t,255),this.gl[3]=t/255,this.update()}},h:{get:function(){return this._h},set:function(t){this._h=t,o(t,this._s,this._v,this)}},s:{get:function(){return this._s},set:function(t){this._s=t,o(this._h,t,this._v,this)}},v:{get:function(){return this._v},set:function(t){this._v=t,o(this._h,this._s,t,this)}}});t.exports=h},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(t,e,i,n,s,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,n,s,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0}},a:{get:function(){return this.matrix[0]},set:function(t){this.matrix[0]=t}},b:{get:function(){return this.matrix[1]},set:function(t){this.matrix[1]=t}},c:{get:function(){return this.matrix[2]},set:function(t){this.matrix[2]=t}},d:{get:function(){return this.matrix[3]},set:function(t){this.matrix[3]=t}},e:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},f:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},tx:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},ty:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},rotation:{get:function(){return Math.acos(this.a/this.scaleX)*(Math.atan(-this.c/this.a)<0?-1:1)}},scaleX:{get:function(){return Math.sqrt(this.a*this.a+this.c*this.c)}},scaleY:{get:function(){return Math.sqrt(this.b*this.b+this.d*this.d)}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3];return n[0]=s*i+o*e,n[1]=r*i+a*e,n[2]=s*-e+o*i,n[3]=r*-e+a*i,this},multiply:function(t,e){var i=this.matrix,n=t.matrix,s=i[0],r=i[1],o=i[2],a=i[3],h=i[4],l=i[5],u=n[0],c=n[1],d=n[2],f=n[3],p=n[4],g=n[5],v=void 0===e?this:e;return v.a=u*s+c*o,v.b=u*r+c*a,v.c=d*s+f*o,v.d=d*r+f*a,v.e=p*s+g*o+h,v.f=p*r+g*a+l,v},multiplyWithOffset:function(t,e,i){var n=this.matrix,s=t.matrix,r=n[0],o=n[1],a=n[2],h=n[3],l=e*r+i*a+n[4],u=e*o+i*h+n[5],c=s[0],d=s[1],f=s[2],p=s[3],g=s[4],v=s[5];return n[0]=c*r+d*a,n[1]=c*o+d*h,n[2]=f*r+p*a,n[3]=f*o+p*h,n[4]=g*r+v*a+l,n[5]=g*o+v*h+u,this},transform:function(t,e,i,n,s,r){var o=this.matrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=t*a+e*l,o[1]=t*h+e*u,o[2]=i*a+n*l,o[3]=i*h+n*u,o[4]=s*a+r*l+c,o[5]=s*h+r*u+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3],h=n[4],l=n[5];return i.x=t*s+e*o+h,i.y=t*r+e*a+l,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=e*s-i*n;return t[0]=s/a,t[1]=-i/a,t[2]=-n/a,t[3]=e/a,t[4]=(n*o-s*r)/a,t[5]=-(e*o-i*r)/a,this},copyFrom:function(t){var e=this.matrix;return e[0]=t.a,e[1]=t.b,e[2]=t.c,e[3]=t.d,e[4]=t.e,e[5]=t.f,this},copyFromArray:function(t){var e=this.matrix;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],this},copyToContext:function(t){var e=this.matrix;return t.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t},setToContext:function(t){var e=this.matrix;return t.setTransform(e[0],e[1],e[2],e[3],e[4],e[5]),t},copyToArray:function(t){var e=this.matrix;return void 0===t?t=[e[0],e[1],e[2],e[3],e[4],e[5]]:(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5]),t},setTransform:function(t,e,i,n,s,r){var o=this.matrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],n=e[1],s=e[2],r=e[3],o=i*i,a=n*n,h=s*s,l=r*r,u=Math.sqrt(o+h),c=Math.sqrt(a+l);return t.translateX=e[4],t.translateY=e[5],t.scaleX=u,t.scaleY=c,t.rotation=Math.acos(i/u)*(Math.atan(-s/i)<0?-1:1),t},applyITRS:function(t,e,i,n,s){var r=this.matrix,o=Math.sin(i),a=Math.cos(i);return r[4]=t,r[5]=e,r[0]=a*n,r[1]=o*n,r[2]=-o*s,r[3]=a*s,this},applyInverse:function(t,e,i){void 0===i&&(i=new s);var n=this.matrix,r=n[0],o=n[1],a=n[2],h=n[3],l=n[4],u=n[5],c=1/(r*h+a*-o);return i.x=h*c*t+-a*c*e+(u*a-l*h)*c,i.y=r*c*e+-o*c*t+(-u*r+l*o)*c,i},getX:function(t,e){return t*this.a+e*this.c+this.e},getY:function(t,e){return t*this.b+e*this.d+this.f},getCSSMatrix:function(){var t=this.matrix;return"matrix("+t[0]+","+t[1]+","+t[2]+","+t[3]+","+t[4]+","+t[5]+")"},destroy:function(){this.matrix=null,this.decomposedMatrix=null}});t.exports=r},function(t,e){t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i}},function(t,e){t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t,e){return t.y=e+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y-t.height*t.originY}},function(t,e){t.exports=function(t,e){return t.x=e-t.width+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x+t.width-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.x=e+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.y=e-t.height+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y+t.height-t.height*t.originY}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileHeight,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.y+i.scrollY*(1-r.scrollFactorY),s*=r.scaleY),e?Math.floor(t/s):t/s}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileWidth,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.x+i.scrollX*(1-r.scrollFactorX),s*=r.scaleX),e?Math.floor(t/s):t/s}},function(t,e,i){var n=i(0),s=i(18),r=i(21),o=i(7),a=i(2),h=i(4),l=i(8),u=new n({Extends:r,initialize:function(t,e,i,n,o){var u="json";if(l(e)){var c=e;e=a(c,"key"),i=a(c,"url"),n=a(c,"xhrSettings"),u=a(c,"extension",u),o=a(c,"dataKey",o)}var d={type:"json",cache:t.cacheManager.json,extension:u,responseType:"text",key:e,url:i,xhrSettings:n,config:o};r.call(this,t,d),l(i)&&(this.data=o?h(i,o):i,this.state=s.FILE_POPULATED)},onProcess:function(){if(this.state!==s.FILE_POPULATED){this.state=s.FILE_PROCESSING;var t=JSON.parse(this.xhrLoader.responseText),e=this.config;this.data="string"==typeof e?h(t,e,t):t}this.onProcessComplete()}});o.register("json",function(t,e,i,n){if(Array.isArray(t))for(var s=0;sthis.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=h},function(t,e,i){var n=i(0),s=i(14),r=i(265),o=new n({Mixins:[s.Alpha,s.Flip,s.Visible],initialize:function(t,e,i,n,s,r,o,a){this.layer=t,this.index=e,this.x=i,this.y=n,this.width=s,this.height=r,this.baseWidth=void 0!==o?o:s,this.baseHeight=void 0!==a?a:r,this.pixelX=0,this.pixelY=0,this.updatePixelXY(),this.properties={},this.rotation=0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceLeft=!1,this.faceRight=!1,this.faceTop=!1,this.faceBottom=!1,this.collisionCallback=null,this.collisionCallbackContext=this,this.tint=16777215,this.physics={}},containsPoint:function(t,e){return!(tthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldX(this.x,t):this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldY(this.y,t)-(this.height-this.baseHeight)*e.scaleY:this.y*this.baseHeight-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new r),e.x=this.getLeft(),e.y=this.getTop(),e.width=this.getRight()-e.x,e.height=this.getBottom()-e.y,e},getCenterX:function(t){return this.getLeft(t)+this.width/2},getCenterY:function(t){return this.getTop(t)+this.height/2},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},intersects:function(t,e,i,n){return!(i<=this.pixelX||n<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,n,s){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===n&&(n=t),void 0===s&&(s=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=n,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=n,s)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,n){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==n&&(this.baseHeight=n),this.updatePixelXY(),this},updatePixelXY:function(){return this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight-(this.height-this.baseHeight),this},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.tilemapLayer;return t?t.tileset:null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=o},function(t,e){t.exports=function(t,e){e?t.setCollision(!0,!0,!0,!0,!1):t.resetCollision(!1)}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n){this.loader=t,this.type=e,this.key=i,this.files=n,this.complete=!1,this.pending=n.length,this.failed=0,this.config={};for(var s=0;s=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=l},function(t,e,i){var n=i(10);t.exports=function(t,e,i,s,r){var o=t.strokeTint,a=n.getTintAppendFloatAlphaAndSwap(e.strokeColor,e.strokeAlpha*i);o.TL=a,o.TR=a,o.BL=a,o.BR=a;var h=e.pathData,l=h.length-1,u=e.lineWidth,c=u/2,d=h[0]-s,f=h[1]-r;e.closePath||(l-=2);for(var p=2;ps||e>=i||i>s||e+i>s){if(n)throw new Error("Range Error: Values outside acceptable range");return!1}return!0}},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e,i){"use strict";function n(t,e,i){i=i||2;var n,a,h,l,u,f,g,v=e&&e.length,m=v?e[0]*i:t.length,y=s(t,0,m,i,!0),x=[];if(!y)return x;if(v&&(y=function(t,e,i,n){var o,a,h,l,u,f=[];for(o=0,a=e.length;o80*i){n=h=t[0],a=l=t[1];for(var w=i;wh&&(h=u),f>l&&(l=f);g=Math.max(h-n,l-a)}return o(y,x,i,n,a,g),x}function s(t,e,i,n,s){var r,o;if(s===A(t,e,i,n)>0)for(r=e;r=e;r-=n)o=b(r,t[r],t[r+1],o);return o&&y(o,o.next)&&(_(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!y(n,n.next)&&0!==m(n.prev,n,n.next))n=n.next;else{if(_(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,s,c,d){if(t){!d&&c&&function(t,e,i,n){var s=t;do{null===s.z&&(s.z=f(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,n,s,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,l*=2}while(o>1)}(s)}(t,n,s,c);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,n,s,c):a(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),_(t),t=g.next,v=g.next;else if((t=g)===v){d?1===d?o(t=l(t,e,i),e,i,n,s,c,2):2===d&&u(t,e,i,n,s,c):o(r(t),e,i,n,s,c,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(m(e,i,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(g(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&m(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function h(t,e,i,n){var s=t.prev,r=t,o=t.next;if(m(s,r,o)>=0)return!1;for(var a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,u=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,c=f(a,h,e,i,n),d=f(l,u,e,i,n),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&m(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function l(t,e,i){var n=t;do{var s=n.prev,r=n.next.next;!y(s,r)&&x(s,n,n.next,r)&&w(s,r)&&w(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),_(n),_(n.next),n=t=r),n=n.next}while(n!==t);return n}function u(t,e,i,n,s,a){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var u=T(h,l);return h=r(h,h.next),u=r(u,u.next),o(h,e,i,n,s,a),void o(u,e,i,n,s,a)}l=l.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,n=e,s=t.x,r=t.y,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var a=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=s&&a>o){if(o=a,a===s){if(r===n.y)return n;if(r===n.next.y)return n.next}i=n.x=n.x&&n.x>=u&&s!==n.x&&g(ri.x)&&w(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=T(e,t);r(i,i.next)}}function f(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&w(t,e)&&w(e,t)&&function(t,e){var i=t,n=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function m(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function y(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,n){return!!(y(t,e)&&y(i,n)||y(t,n)&&y(i,e))||m(t,e,i)>0!=m(t,e,n)>0&&m(i,n,t)>0!=m(i,n,e)>0}function w(t,e){return m(t.prev,t,t.next)<0?m(t,e,t.next)>=0&&m(t,t.prev,e)>=0:m(t,e,t.prev)<0||m(t,t.next,e)<0}function T(t,e){var i=new S(t.i,t.x,t.y),n=new S(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function b(t,e,i,n){var s=new S(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function _(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function A(t,e,i,n){for(var s=0,r=e,o=i-n;r0&&(n+=t[s-1].length,i.holes.push(n))}return i}},function(t,e){t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},function(t,e){t.exports={SKIP_CHECK:-1,NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16}},,function(t,e){t.exports=function(t){return Math.atan2(t.y2-t.y1,t.x2-t.x1)}},function(t,e){t.exports=function(t,e,i){var n=t.x3-t.x1,s=t.y3-t.y1,r=t.x2-t.x1,o=t.y2-t.y1,a=e-t.x1,h=i-t.y1,l=n*n+s*s,u=n*r+s*o,c=n*a+s*h,d=r*r+o*o,f=r*a+o*h,p=l*d-u*u,g=0===p?0:1/p,v=(d*c-u*f)*g,m=(l*f-u*c)*g;return v>=0&&m>=0&&v+m<1}},function(t,e,i){var n=i(0),s=i(173),r=i(9),o=i(3),a=new n({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var n=Math.max(1,Math.round(i/e));return s(this.getSpacedPoints(n),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],n=this.getPoint(0,this._tmpVec2A),s=0;i.push(0);for(var r=1;r<=t;r++)s+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(n),i.push(s),n.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++){var n=this.getUtoTmapping(i/t,null,t);e.push(this.getPoint(n))}return e},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=t-1e-4,n=t+1e-4;return i<0&&(i=0),n>1&&(n=1),this.getPoint(i,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var n,s=this.getLengths(i),r=0,o=s.length;n=e?Math.min(e,s[o-1]):t*s[o-1];for(var a,h=0,l=o-1;h<=l;)if((a=s[r=Math.floor(h+(l-h)/2)]-n)<0)h=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(s[r=l]===n)return r/(o-1);var u=s[r];return(r+(n-u)/(s[r+1]-u))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},function(t,e,i){var n=i(0),s=i(40),r=i(405),o=i(403),a=i(191),h=new n({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=h},function(t,e){t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},function(t,e){t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},function(t,e){t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},,function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","map"),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.widthInPixels=s(t,"widthInPixels",this.width*this.tileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.tileHeight),this.format=s(t,"format",null),this.orientation=s(t,"orientation","orthogonal"),this.renderOrder=s(t,"renderOrder","right-down"),this.version=s(t,"version","1"),this.properties=s(t,"properties",{}),this.layers=s(t,"layers",[]),this.images=s(t,"images",[]),this.objects=s(t,"objects",{}),this.collision=s(t,"collision",{}),this.tilesets=s(t,"tilesets",[]),this.imageCollections=s(t,"imageCollections",[]),this.tiles=s(t,"tiles",[])}});t.exports=r},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","layer"),this.x=s(t,"x",0),this.y=s(t,"y",0),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.baseTileWidth=s(t,"baseTileWidth",this.tileWidth),this.baseTileHeight=s(t,"baseTileHeight",this.tileHeight),this.widthInPixels=s(t,"widthInPixels",this.width*this.baseTileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.baseTileHeight),this.alpha=s(t,"alpha",1),this.visible=s(t,"visible",!0),this.properties=s(t,"properties",{}),this.indexes=s(t,"indexes",[]),this.collideIndexes=s(t,"collideIndexes",[]),this.callbacks=s(t,"callbacks",[]),this.bodies=s(t,"bodies",[]),this.data=s(t,"data",[]),this.tilemapLayer=s(t,"tilemapLayer",null)}});t.exports=r},function(t,e){t.exports=function(t,e,i){return t>=0&&t=0&&e=0;u--)if((l=d[u]).active===i){if(++c===e)break}else l=null;return l?("number"==typeof s&&(l.x=s),"number"==typeof r&&(l.y=r),l):n?this.create(s,r,o,a,h):null},get:function(t,e,i,n,s){return this.getFirst(!1,!0,t,e,i,n,s)},getFirstAlive:function(t,e,i,n,s,r){return this.getFirst(!0,t,e,i,n,s,r)},getFirstDead:function(t,e,i,n,s,r){return this.getFirst(!1,t,e,i,n,s,r)},playAnimation:function(t,e){return n.PlayAnimation(this.children.entries,t,e),this},isFull:function(){return-1!==this.maxSize&&this.children.size>=this.maxSize},countActive:function(t){void 0===t&&(t=!0);for(var e=0,i=0;i=t.length)){for(var i=t.length-1,n=t[e],s=e;s-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new n;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return t=this.firstgid&&t=0&&g<=1&&v>=0&&v<=1&&(i.x=s+g*(o-s),i.y=r+g*(a-r),!0)}},function(t,e,i){var n=i(0),s=i(14),r=i(19),o=i(731),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Texture,s.Transform,s.Visible,s.ScrollFactor,o],initialize:function(t,e,i,n,s,o,a,h,l){if(r.call(this,t,"Mesh"),n.length!==s.length)throw new Error("Mesh Vertex count must match UV count");var u,c=n.length/2|0;if(o.length>0&&o.length0&&a.lengthl&&(r=l),o>l&&(o=l),a=s,h=r;;)if(a-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){for(var i=[null],n=2;n0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=a},function(t,e,i){var n=i(0),s=i(23),r=i(20),o=new n({initialize:function(t,e,i,n,s,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.glTexture=this.source.glTexture,this.cutX,this.cutY,this.cutWidth,this.cutHeight,this.x=0,this.y=0,this.width,this.height,this.halfWidth,this.halfHeight,this.centerX,this.centerY,this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.u0=0,this.v0=0,this.u1=0,this.v1=0,this.data={cut:{x:0,y:0,w:0,h:0,r:0,b:0},trim:!1,sourceSize:{w:0,h:0},spriteSourceSize:{x:0,y:0,w:0,h:0,r:0,b:0},radius:0,drawImage:{x:0,y:0,width:0,height:0}},this.setSize(r,o,n,s)},setSize:function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this.cutX=i,this.cutY=n,this.cutWidth=t,this.cutHeight=e,this.width=t,this.height=e,this.halfWidth=Math.floor(.5*t),this.halfHeight=Math.floor(.5*e),this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2);var s=this.data,r=s.cut;r.x=i,r.y=n,r.w=t,r.h=e,r.r=i+t,r.b=n+e,s.sourceSize.w=t,s.sourceSize.h=e,s.spriteSourceSize.w=t,s.spriteSourceSize.h=e,s.radius=.5*Math.sqrt(t*t+e*e);var o=s.drawImage;return o.x=i,o.y=n,o.width=t,o.height=e,this.updateUVs()},setTrim:function(t,e,i,n,s,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=n,a.w=s,a.h=r,a.r=i+s,a.b=n+r,this.x=i,this.y=n,this.width=s,this.height=r,this.halfWidth=.5*s,this.halfHeight=.5*r,this.centerX=Math.floor(s/2),this.centerY=Math.floor(r/2),this.updateUVs()},setCropUVs:function(t,e,i,n,r,o,a){var h=this.cutX,l=this.cutY,u=this.cutWidth,c=this.cutHeight,d=this.realWidth,f=this.realHeight,p=h+(e=s(e,0,d)),g=l+(i=s(i,0,f)),v=n=s(n,0,d-e),m=r=s(r,0,f-i),y=this.data;if(y.trim){var x=y.spriteSourceSize,w=e+(n=s(n,0,u-e)),T=i+(r=s(r,0,c-i));if(!(x.rw||x.y>T)){var b=Math.max(x.x,e),_=Math.max(x.y,i),S=Math.min(x.r,w)-b,A=Math.min(x.b,T)-_;v=S,m=A,p=o?h+(u-(b-x.x)-S):h+(b-x.x),g=a?l+(c-(_-x.y)-A):l+(_-x.y),e=b,i=_,n=S,r=A}else p=0,g=0,v=0,m=0}else o&&(p=h+(u-e-n)),a&&(g=l+(c-i-r));var C=this.source.width,M=this.source.height;return t.u0=Math.max(0,p/C),t.v0=Math.max(0,g/M),t.u1=Math.min(1,(p+v)/C),t.v1=Math.min(1,(g+m)/M),t.x=e,t.y=i,t.cx=p,t.cy=g,t.cw=v,t.ch=m,t.width=n,t.height=r,t.flipX=o,t.flipY=a,t},updateCropUVs:function(t,e,i){return this.setCropUVs(t,t.x,t.y,t.width,t.height,e,i)},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,n=this.cutHeight,s=this.data.drawImage;s.width=i,s.height=n;var r=this.source.width,o=this.source.height;return this.u0=t/r,this.v0=e/o,this.u1=(t+i)/r,this.v1=(e+n)/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height;return this.u0=(this.cutX+this.cutHeight)/t,this.v0=this.cutY/e,this.u1=this.cutX/t,this.v1=(this.cutY+this.cutWidth)/e,this},clone:function(){var t=new o(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=r(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=o},function(t,e,i){var n=i(0),s=i(11),r=i(20),o=i(1),a=new n({Extends:s,initialize:function(t,e,i){s.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=this.duration||0,this.totalDuration=this.totalDuration||0,this.config={mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0},this.currentConfig=this.config,this.config=r(this.config,i),this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(console.error("addMarker "+t.name+" already exists in Sound"),!1):(t=r(!0,{name:"",start:0,duration:this.totalDuration-(t.start||0),config:{mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0}},t),this.markers[t.name]=t,!0))},updateMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(this.markers[t.name]=r(!0,this.markers[t.name],t),!0):(console.warn("Audio Marker: "+t.name+" missing in Sound: "+this.key),!1))},removeMarker:function(t){var e=this.markers[t];return e?(this.markers[t]=null,e):null},play:function(t,e){if(void 0===t&&(t=""),"object"==typeof t&&(e=t,t=""),"string"!=typeof t)return!1;if(t){if(!this.markers[t])return console.warn("Marker: "+t+" missing in Sound: "+this.key),!1;this.currentMarker=this.markers[t],this.currentConfig=this.currentMarker.config,this.duration=this.currentMarker.duration}else this.currentMarker=null,this.currentConfig=this.config,this.duration=this.totalDuration;return this.resetConfig(),this.currentConfig=r(this.currentConfig,e),this.isPlaying=!0,this.isPaused=!1,!0},pause:function(){return!(this.isPaused||!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!0,!0)},resume:function(){return!(!this.isPaused||this.isPlaying)&&(this.isPlaying=!0,this.isPaused=!1,!0)},stop:function(){return!(!this.isPaused&&!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!1,this.resetConfig(),!0)},applyConfig:function(){this.mute=this.currentConfig.mute,this.volume=this.currentConfig.volume,this.rate=this.currentConfig.rate,this.detune=this.currentConfig.detune,this.loop=this.currentConfig.loop},resetConfig:function(){this.currentConfig.seek=0,this.currentConfig.delay=0},update:o,calculateRate:function(){var t=this.currentConfig.detune+this.manager.detune,e=Math.pow(1.0005777895065548,t);this.totalRate=this.currentConfig.rate*this.manager.rate*e},destroy:function(){this.pendingRemove||(this.emit("destroy",this),this.pendingRemove=!0,this.manager=null,this.key="",this.removeAllListeners(),this.isPlaying=!1,this.isPaused=!1,this.config=null,this.currentConfig=null,this.markers=null,this.currentMarker=null)}});t.exports=a},function(t,e,i){var n=i(0),s=i(63),r=i(11),o=i(1),a=new n({Extends:r,initialize:function(t){r.call(this),this.game=t,this.jsonCache=t.cache.json,this.sounds=[],this.mute=!1,this.volume=1,this.pauseOnBlur=!0,this._rate=1,this._detune=0,this.locked=this.locked||!1,this.unlocked=!1,t.events.on("blur",function(){this.pauseOnBlur&&this.onBlur()},this),t.events.on("focus",function(){this.pauseOnBlur&&this.onFocus()},this),t.events.on("prestep",this.update,this),t.events.once("destroy",this.destroy,this)},add:o,addAudioSprite:function(t,e){void 0===e&&(e={});var i=this.add(t,e);for(var n in i.spritemap=this.jsonCache.get(t).spritemap,i.spritemap)if(i.spritemap.hasOwnProperty(n)){var r=s(e),o=i.spritemap[n];r.loop=!!o.hasOwnProperty("loop")&&o.loop,i.addMarker({name:n,start:o.start,duration:o.end-o.start,config:r})}return i},play:function(t,e){var i=this.add(t);return i.once("ended",i.destroy,i),e?e.name?(i.addMarker(e),i.play(e.name)):i.play(e):i.play()},playAudioSprite:function(t,e,i){var n=this.addAudioSprite(t);return n.once("ended",n.destroy,n),n.play(e,i)},remove:function(t){var e=this.sounds.indexOf(t);return-1!==e&&(t.destroy(),this.sounds.splice(e,1),!0)},removeByKey:function(t){for(var e=0,i=this.sounds.length-1;i>=0;i--){var n=this.sounds[i];n.key===t&&(n.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:o,onBlur:o,onFocus:o,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(n,s){n.pendingRemove||t.call(e||i,n,s,i.sounds)})},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("detune",this,t)}}});t.exports=a},function(t,e){t.exports={PENDING:0,INIT:1,START:2,LOADING:3,CREATING:4,RUNNING:5,PAUSED:6,SLEEPING:7,SHUTDOWN:8,DESTROYED:9}},function(t,e){t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},function(t,e,i){var n,s=i(92),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(n=navigator.userAgent,/Edge\/\d+/.test(n)?r.edge=!0:/Chrome\/(\d+)/.test(n)&&!s.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(n)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&s.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(n)?r.opera=!0:/Safari/.test(n)&&!s.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(r.silk=!0),r)},function(t,e){t.exports=function(t,e,i){return(e-t)*i+t}},function(t,e){var i,n="";t.exports={disable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!1),t},enable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!0),t},getPrefix:i=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i-m&&b>-y&&T-m&&S>-y&&_s&&(t=s),t},clampY:function(t){var e=this._bounds,i=this.displayHeight,n=e.y+(i-this.height)/2,s=Math.max(n,n+e.height-i);return ts&&(t=s),t},removeBounds:function(){return this.useBounds=!1,this.dirty=!0,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=r(t),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=l(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,n,s){return this._bounds.setTo(t,e,i,n),this.dirty=!0,this.useBounds=!0,s?this.centerToBounds():(this.scrollX=this.clampX(this.scrollX),this.scrollY=this.clampY(this.scrollY)),this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){this.scene&&this._customViewport&&this.sceneManager.customViewports--,this.scene=t,this.config=t.sys.game.config,this.sceneManager=t.sys.game.scene;var e=this.config.resolution;return this.resolution=e,this._cx=this._x*e,this._cy=this._y*e,this._cw=this._width*e,this._ch=this._height*e,this.updateSystem(),this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setZoom:function(t){return void 0===t&&(t=1),0===t&&(t=.001),this.zoom=t,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},update:function(){},updateSystem:function(){if(this.config){var t=0!==this._x||0!==this._y||this.config.width!==this._width||this.config.height!==this._height,e=this.sceneManager;t&&!this._customViewport?e.customViewports++:!t&&this._customViewport&&e.customViewports--,this.dirty=!0,this._customViewport=t}},destroy:function(){this.emit("cameradestroy",this),this.removeAllListeners(),this.matrix.destroy(),this.culledObjects=[],this._customViewport&&this.sceneManager.customViewports--,this._bounds=null,this.scene=null,this.config=null,this.sceneManager=null},x:{get:function(){return this._x},set:function(t){this._x=t,this._cx=t*this.resolution,this.updateSystem()}},y:{get:function(){return this._y},set:function(t){this._y=t,this._cy=t*this.resolution,this.updateSystem()}},width:{get:function(){return this._width},set:function(t){this._width=t,this._cw=t*this.resolution,this.updateSystem()}},height:{get:function(){return this._height},set:function(t){this._height=t,this._ch=t*this.resolution,this.updateSystem()}},scrollX:{get:function(){return this._scrollX},set:function(t){this._scrollX=t,this.dirty=!0}},scrollY:{get:function(){return this._scrollY},set:function(t){this._scrollY=t,this.dirty=!0}},zoom:{get:function(){return this._zoom},set:function(t){this._zoom=t,this.dirty=!0}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=t,this.dirty=!0}},centerX:{get:function(){return this.x+.5*this.width}},centerY:{get:function(){return this.y+.5*this.height}},displayWidth:{get:function(){return this.width/this.zoom}},displayHeight:{get:function(){return this.height/this.zoom}}});t.exports=c},function(t,e){t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.parent=t,this.events=e,e||(this.events=t.events?t.events:t),this.list={},this.values={},this._frozen=!1,!t.hasOwnProperty("sys")&&this.events&&this.events.once("destroy",this.destroy,this)},get:function(t){var e=this.list;if(Array.isArray(t)){for(var i=[],n=0;n0&&(n.totalDuration+=n.t2*n.repeat),n.totalDuration>t&&(t=n.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},pause:function(){if(this.state!==o.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=o.PAUSED,this},play:function(t){if(this.state!==o.ACTIVE){this.state!==o.PENDING_REMOVE&&this.state!==o.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.ACTIVE):(this.countdown=this.calculatedOffset,this.state=o.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=o.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.parent.makeActive(this))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(n.elapsed=n.delay,n.state=o.DELAY):n.state=o.PENDING_RENDER}},resume:function(){return this.state===o.PAUSED?(this.paused=!1,this.state=this._pausedState):this.play(),this},seek:function(t){for(var e=this.data,i=0;i=s.totalDuration?(r=1,o=s.duration):n>s.delay&&n<=s.t1?(r=(n=Math.max(0,n-s.delay))/s.t1,o=s.duration*r):n>s.t1&&ns.repeatDelay&&(r=n/s.t1,o=s.duration*r)),s.progress=r,s.elapsed=o;var a=s.ease(s.progress);s.current=s.start+(s.end-s.start)*a,s.target[s.key]=s.current}},setCallback:function(t,e,i,n){return this.callbacks[t]={func:e,scope:n,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},stop:function(t){this.state===o.ACTIVE&&void 0!==t&&this.seek(t),this.state!==o.REMOVED&&(this.state!==o.PAUSED&&this.state!==o.PENDING_ADD||(this.parent._destroy.push(this),this.parent._toProcess++),this.state=o.PENDING_REMOVE)},update:function(t,e){if(this.state===o.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var i=!1,n=0;n0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case o.PLAYING_FORWARD:case o.PLAYING_BACKWARD:if(!e.target){e.state=o.COMPLETE;break}var n=e.elapsed,s=e.duration,r=0;(n+=i)>s&&(r=n-s,n=s);var a,h=e.state===o.PLAYING_FORWARD,l=n/s;a=h?e.ease(l):e.ease(1-l),e.current=e.start+(e.end-e.start)*a,e.target[e.key]=e.current,e.elapsed=n,e.progress=l;var u=t.callbacks.onUpdate;u&&(u.params[1]=e.target,u.func.apply(u.scope,u.params)),1===l&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=o.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case o.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PENDING_RENDER);break;case o.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PLAYING_FORWARD);break;case o.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case o.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=o.PLAYING_FORWARD):e.state=o.COMPLETE}return e.state!==o.COMPLETE}});a.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),s.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=a},function(t,e){t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1}},function(t,e){function i(t){return!!t.getStart&&"function"==typeof t.getStart}function n(t){return!!t.getEnd&&"function"==typeof t.getEnd}var s=function(t,e){var r,o,a=function(t,e,i){return i},h=function(t,e,i){return i},l=typeof e;if("number"===l)a=function(){return e};else if("string"===l){var u=e[0],c=parseFloat(e.substr(2));switch(u){case"+":a=function(t,e,i){return i+c};break;case"-":a=function(t,e,i){return i-c};break;case"*":a=function(t,e,i){return i*c};break;case"/":a=function(t,e,i){return i/c};break;default:a=function(){return parseFloat(e)}}}else"function"===l?a=e:"object"===l&&(i(o=e)||n(o))?(n(e)&&(a=e.getEnd),i(e)&&(h=e.getStart)):e.hasOwnProperty("value")&&(r=s(t,e.value));return r||(r={getEnd:a,getStart:h}),r};t.exports=s},function(t,e,i){var n=i(4);t.exports=function(t){var e=n(t,"targets",null);return null===e?e:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},function(t,e,i){var n=i(29),s=i(77),r=i(217),o=i(209);t.exports=function(t,e,i,a,h,l,u,c){void 0===i&&(i=32),void 0===a&&(a=32),void 0===h&&(h=10),void 0===l&&(l=10),void 0===c&&(c=!1);var d=null;if(Array.isArray(u))d=r(void 0!==e?e:"map",n.ARRAY_2D,u,i,a,c);else if(void 0!==e){var f=t.cache.tilemap.get(e);f?d=r(e,f.format,f.data,i,a,c):console.warn("No map data found for key "+e)}return null===d&&(d=new s({tileWidth:i,tileHeight:a,width:h,height:l})),new o(t,d)}},function(t,e,i){var n=i(29),s=i(78),r=i(77),o=i(55);t.exports=function(t,e,i,a,h){for(var l=new s({tileWidth:i,tileHeight:a}),u=new r({name:t,tileWidth:i,tileHeight:a,format:n.ARRAY_2D,layers:[l]}),c=[],d=e.length,f=0,p=0;p0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return this.x=i*o-n*r,this.y=n*s-e*o,this.z=e*r-i*s,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this},transformMat3:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=e*s[0]+i*s[3]+n*s[6],this.y=e*s[1]+i*s[4]+n*s[7],this.z=e*s[2]+i*s[5]+n*s[8],this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12],this.y=s[1]*e+s[5]*i+s[9]*n+s[13],this.z=s[2]*e+s[6]*i+s[10]*n+s[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=e*s[0]+i*s[4]+n*s[8]+s[12],o=e*s[1]+i*s[5]+n*s[9]+s[13],a=e*s[2]+i*s[6]+n*s[10]+s[14],h=e*s[3]+i*s[7]+n*s[11]+s[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},project:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=s[0],o=s[1],a=s[2],h=s[3],l=s[4],u=s[5],c=s[6],d=s[7],f=s[8],p=s[9],g=s[10],v=s[11],m=s[12],y=s[13],x=s[14],w=1/(e*h+i*d+n*v+s[15]);return this.x=(e*r+i*l+n*f+m)*w,this.y=(e*o+i*u+n*p+y)*w,this.z=(e*a+i*c+n*g+x)*w,this},unproject:function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,o=this.x-i,a=r-this.y-1-n,h=this.z;return this.x=2*o/s-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,e,i){var n=i(0),s=i(18),r=i(21),o=i(7),a=i(2),h=i(8),l=i(343),u=new n({Extends:r,initialize:function(t,e,i,n){var s="xml";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),n=a(o,"xhrSettings"),s=a(o,"extension",s)}var l={type:"xml",cache:t.cacheManager.xml,extension:s,responseType:"text",key:e,url:i,xhrSettings:n};r.call(this,t,l)},onProcess:function(){this.state=s.FILE_PROCESSING,this.data=l(this.xhrLoader.responseText),this.data?this.onProcessComplete():(console.warn("Invalid XMLFile: "+this.key),this.onProcessError())}});o.register("xml",function(t,e,i){if(Array.isArray(t))for(var n=0;n=0&&r>=0&&s+r<1&&(n.push({x:e[T].x,y:e[T].y}),i)));T++);return n}},function(t,e){t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.righte.right||t.y>e.bottom)}},function(t,e,i){var n=i(0),s=i(108),r=new n({Extends:s,initialize:function(t,e,i,n,r){s.call(this,t,e,i,[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1,1,0],[16777215,16777215,16777215,16777215,16777215,16777215],[1,1,1,1,1,1],n,r),this.resetPosition()},setFrame:function(t){return this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,t=this.frame,this.uv[0]=t.u0,this.uv[1]=t.v0,this.uv[2]=t.u0,this.uv[3]=t.v1,this.uv[4]=t.u1,this.uv[5]=t.v1,this.uv[6]=t.u0,this.uv[7]=t.v0,this.uv[8]=t.u1,this.uv[9]=t.v1,this.uv[10]=t.u1,this.uv[11]=t.v0,this},topLeftX:{get:function(){return this.x+this.vertices[0]},set:function(t){this.vertices[0]=t-this.x,this.vertices[6]=t-this.x}},topLeftY:{get:function(){return this.y+this.vertices[1]},set:function(t){this.vertices[1]=t-this.y,this.vertices[7]=t-this.y}},topRightX:{get:function(){return this.x+this.vertices[10]},set:function(t){this.vertices[10]=t-this.x}},topRightY:{get:function(){return this.y+this.vertices[11]},set:function(t){this.vertices[11]=t-this.y}},bottomLeftX:{get:function(){return this.x+this.vertices[2]},set:function(t){this.vertices[2]=t-this.x}},bottomLeftY:{get:function(){return this.y+this.vertices[3]},set:function(t){this.vertices[3]=t-this.y}},bottomRightX:{get:function(){return this.x+this.vertices[4]},set:function(t){this.vertices[4]=t-this.x,this.vertices[8]=t-this.x}},bottomRightY:{get:function(){return this.y+this.vertices[5]},set:function(t){this.vertices[5]=t-this.y,this.vertices[9]=t-this.y}},topLeftAlpha:{get:function(){return this.alphas[0]},set:function(t){this.alphas[0]=t,this.alphas[3]=t}},topRightAlpha:{get:function(){return this.alphas[5]},set:function(t){this.alphas[5]=t}},bottomLeftAlpha:{get:function(){return this.alphas[1]},set:function(t){this.alphas[1]=t}},bottomRightAlpha:{get:function(){return this.alphas[2]},set:function(t){this.alphas[2]=t,this.alphas[4]=t}},topLeftColor:{get:function(){return this.colors[0]},set:function(t){this.colors[0]=t,this.colors[3]=t}},topRightColor:{get:function(){return this.colors[5]},set:function(t){this.colors[5]=t}},bottomLeftColor:{get:function(){return this.colors[1]},set:function(t){this.colors[1]=t}},bottomRightColor:{get:function(){return this.colors[2]},set:function(t){this.colors[2]=t,this.colors[4]=t}},setTopLeft:function(t,e){return this.topLeftX=t,this.topLeftY=e,this},setTopRight:function(t,e){return this.topRightX=t,this.topRightY=e,this},setBottomLeft:function(t,e){return this.bottomLeftX=t,this.bottomLeftY=e,this},setBottomRight:function(t,e){return this.bottomRightX=t,this.bottomRightY=e,this},resetPosition:function(){var t=this.x,e=this.y,i=Math.floor(this.width/2),n=Math.floor(this.height/2);return this.setTopLeft(t-i,e-n),this.setTopRight(t+i,e-n),this.setBottomLeft(t-i,e+n),this.setBottomRight(t+i,e+n),this},resetAlpha:function(){var t=this.alphas;return t[0]=1,t[1]=1,t[2]=1,t[3]=1,t[4]=1,t[5]=1,this},resetColors:function(){var t=this.colors;return t[0]=16777215,t[1]=16777215,t[2]=16777215,t[3]=16777215,t[4]=16777215,t[5]=16777215,this},reset:function(){return this.resetPosition(),this.resetAlpha(),this.resetColors()}});t.exports=r},function(t,e){t.exports=function(t,e,i){for(var n=!1,s=-1,r=t.points.length-1;++sl){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var v=d.substr(g.length);u[c]=v,h+=g}var m=u[c].length?c:c+1,y=u.slice(m).join(" ").replace(/[ \n]*$/gi,"");s[o+1]=y+" "+(s[o+1]||""),r=s.length;break}h+=f,l-=p}n+=h.replace(/[ \n]*$/gi,"")+"\n"}}return n=n.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var n="",s=t.split(this.splitRegExp),r=0;ro?(h>0&&(n+="\n"),n+=a[h]+" ",o=i-l):(o-=u,n+=a[h],h0&&(a+=u.lineSpacing*p),i.rtl?o=d-o:"right"===i.align?o+=u.width-u.lineWidths[p]:"center"===i.align&&(o+=(u.width-u.lineWidths[p])/2),this.autoRound&&(o=Math.round(o),a=Math.round(a)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],o,a)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],o,a));return e.restore(),this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(t,this.frame.source.glTexture,!0),this.frame.glTexture=this.frame.source.glTexture),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},text:{get:function(){return this._text},set:function(t){this.setText(t)}},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this._text,style:this.style.toJSON(),padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),s.remove(this.canvas),this.texture.destroy()}});t.exports=p},function(t,e,i){var n=i(121),s=i(24),r=i(0),o=i(14),a=i(26),h=i(113),l=i(19),u=i(817),c=i(295),d=new r({Extends:l,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Crop,o.Depth,o.Flip,o.GetBounds,o.Mask,o.Origin,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Tint,o.Transform,o.Visible,u],initialize:function(t,e,i,r,o){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=32),void 0===o&&(o=32),l.call(this,t,"RenderTexture"),this.renderer=t.sys.game.renderer,this.textureManager=t.sys.textures,this.globalTint=16777215,this.globalAlpha=1,this.canvas=s.create2D(this,r,o),this.context=this.canvas.getContext("2d"),this.framebuffer=null,this._crop=this.resetCropObject(),this.texture=t.sys.textures.addCanvas(c(),this.canvas),this.frame=this.texture.get(),this._saved=!1,this.camera=new n(0,0,r,o),this.dirty=!1,this.gl=null;var h=this.renderer;if(h.type===a.WEBGL){var u=h.gl;this.gl=u,this.drawGameObject=this.batchGameObjectWebGL,this.framebuffer=h.createFramebuffer(r,o,this.frame.source.glTexture,!1)}else h.type===a.CANVAS&&(this.drawGameObject=this.batchGameObjectCanvas);this.camera.setScene(t),this.setPosition(e,i),this.setSize(r,o),this.setOrigin(0,0),this.initPipeline()},setSize:function(t,e){return this.resize(t,e)},resize:function(t,e){if(void 0===e&&(e=t),t!==this.width||e!==this.height){if(this.canvas.width=t,this.canvas.height=e,this.gl){var i=this.gl;this.renderer.deleteTexture(this.frame.source.glTexture),this.renderer.deleteFramebuffer(this.framebuffer),this.frame.source.glTexture=this.renderer.createTexture2D(0,i.NEAREST,i.NEAREST,i.CLAMP_TO_EDGE,i.CLAMP_TO_EDGE,i.RGBA,null,t,e,!1),this.framebuffer=this.renderer.createFramebuffer(t,e,this.frame.source.glTexture,!1),this.frame.glTexture=this.frame.source.glTexture}this.frame.source.width=t,this.frame.source.height=e,this.camera.setSize(t,e),this.frame.setSize(t,e),this.width=t,this.height=e}return this},setGlobalTint:function(t){return this.globalTint=t,this},setGlobalAlpha:function(t){return this.globalAlpha=t,this},saveTexture:function(t){return this.textureManager.renameTexture(this.texture.key,t),this._saved=!0,this.texture},fill:function(t,e){void 0===e&&(e=1);var i=255&(t>>16|0),n=255&(t>>8|0),s=255&(0|t);if(this.gl){this.renderer.setFramebuffer(this.framebuffer);var r=this.gl;r.clearColor(i/255,n/255,s/255,e),r.clear(r.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null)}else this.context.fillStyle="rgb("+i+","+n+","+s+")",this.context.fillRect(0,0,this.canvas.width,this.canvas.height);return this},clear:function(){if(this.dirty){if(this.gl){this.renderer.setFramebuffer(this.framebuffer);var t=this.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null)}else{var e=this.context;e.save(),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,this.canvas.width,this.canvas.height),e.restore()}this.dirty=!1}return this},draw:function(t,e,i,n,s){void 0===n&&(n=this.globalAlpha),s=void 0===s?(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16):(s>>16)+(65280&s)+((255&s)<<16),Array.isArray(t)||(t=[t]);var r=this.gl;if(this.camera.preRender(1,1,1),r){this.renderer.setFramebuffer(this.framebuffer);var o=this.pipeline;o.projOrtho(0,this.width,0,this.height,-1e3,1e3),this.batchList(t,e,i,n,s),o.flush(),this.renderer.setFramebuffer(null),o.projOrtho(0,o.width,o.height,0,-1e3,1e3)}else this.renderer.setContext(this.context),this.batchList(t,e,i,n,s),this.renderer.setContext();return this.dirty=!0,this},drawFrame:function(t,e,i,n,s,r){void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=this.globalAlpha),r=void 0===r?(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16):(r>>16)+(65280&r)+((255&r)<<16);var o=this.gl,a=this.textureManager.getFrame(t,e);if(a){if(this.camera.preRender(1,1,1),o){this.renderer.setFramebuffer(this.framebuffer);var h=this.pipeline;h.projOrtho(0,this.width,0,this.height,-1e3,1e3),h.batchTextureFrame(a,i,n,r,s,this.camera.matrix,null),h.flush(),this.renderer.setFramebuffer(null),h.projOrtho(0,h.width,h.height,0,-1e3,1e3)}else this.batchTextureFrame(a,i,n,s,r);this.dirty=!0}return this},batchList:function(t,e,i,n,s){for(var r=0;r0?e.defaultFrame=i[0]:e.defaultFrame=this.defaultFrame,this},addEmitter:function(t){return this.emitters.add(t)},createEmitter:function(t){return this.addEmitter(new h(this,t))},addGravityWell:function(t){return this.wells.add(t)},createGravityWell:function(t){return this.addGravityWell(new o(t))},emitParticle:function(t,e,i){for(var n=this.emitters.list,s=0;s-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var n,s,r=this.scene.sys,o=r.game.renderer;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),w.TargetCamera.setScene(this.scene),w.TargetCamera.setViewport(0,0,e,i),w.TargetCamera.scrollX=this.x,w.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var a=(n=r.textures.get(t)).getSourceImage();a instanceof HTMLCanvasElement&&(s=a.getContext("2d"))}else s=(n=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(s=t.getContext("2d"));return s&&(this.renderCanvas(o,this,0,w.TargetCamera,null,s,!1),n&&n.refresh()),this},preDestroy:function(){this.commandBuffer=[]}});w.TargetCamera=new n,t.exports=w},function(t,e,i){var n=i(109),s=i(0),r=i(834),o=new s({Extends:n,Mixins:[r],initialize:function(t,e,i,s,r,o,a){n.call(this,t,e,i,s,r,o,a),this.type="DynamicBitmapText",this.scrollX=0,this.scrollY=0,this.cropWidth=0,this.cropHeight=0,this.displayCallback,this.callbackData={color:0,tint:{topLeft:0,topRight:0,bottomLeft:0,bottomRight:0},index:0,charCode:0,x:0,y:0,scale:0,rotation:0,data:0}},setSize:function(t,e){return this.cropWidth=t,this.cropHeight=e,this},setDisplayCallback:function(t){return this.displayCallback=t,this},setScrollX:function(t){return this.scrollX=t,this},setScrollY:function(t){return this.scrollY=t,this}});t.exports=o},function(t,e,i){var n=i(164),s=i(66),r=i(0),o=i(14),a=i(19),h=i(9),l=i(837),u=i(309),c=i(3),d=new r({Extends:a,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Depth,o.Mask,o.ScrollFactor,o.Transform,o.Visible,l],initialize:function(t,e,i,n){a.call(this,t,"Container"),this.list=[],this.exclusive=!0,this.maxSize=-1,this.position=0,this.localTransform=new o.TransformMatrix,this.tempTransformMatrix=new o.TransformMatrix,this._displayList=t.sys.displayList,this._sortKey="",this._sysEvents=t.sys.events,this.setPosition(e,i),this.clearAlpha(),this.setBlendMode(s.SKIP_CHECK),n&&this.add(n)},originX:{get:function(){return.5}},originY:{get:function(){return.5}},displayOriginX:{get:function(){return.5*this.width}},displayOriginY:{get:function(){return.5*this.height}},setExclusive:function(t){return void 0===t&&(t=!0),this.exclusive=t,this},getBounds:function(t){if(void 0===t&&(t=new h),t.setTo(this.x,this.y,0,0),this.list.length>0)for(var e=this.list,i=new h,n=0;n-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){var i,n=[null],s=this.list.slice(),r=s.length;for(i=2;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}},preDestroy:function(){this.removeAll(!!this.exclusive),this.localTransform.destroy(),this.tempTransformMatrix.destroy(),this.list=[],this._displayList=null}});t.exports=d},function(t,e,i){var n=i(841),s=i(838),r=i(0),o=i(14),a=i(113),h=i(19),l=i(112),u=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Mask,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,n],initialize:function(t,e,i,n,s){h.call(this,t,"Blitter"),this.setTexture(n,s),this.setPosition(e,i),this.initPipeline(),this.children=new l,this.renderList=[],this.dirty=!1},create:function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new s(this,t,e,i,n);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,n){for(var s=this.createMultiple(e,i,n),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0},preDestroy:function(){this.children.destroy(),this.renderList=[]}});t.exports=u},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var n=e+Math.floor(Math.random()*i);return void 0===t[n]?null:t[n]}},function(t,e){t.exports=function(t){if(!Array.isArray(t)||t.length<2||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i0},isTransitionIn:function(){return this.settings.isTransition},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t,e){return t?this.resume(e):this.pause(e)},start:function(t){t&&(this.settings.data=t),this.settings.status=s.START,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this),this.events.emit("ready",this,t)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(t){this.events.off("transitioninit"),this.events.off("transitionstart"),this.events.off("transitioncomplete"),this.events.off("transitionout"),this.settings.status=s.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this,t)},destroy:function(){this.settings.status=s.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this),this.events.removeAllListeners();for(var t=["scene","game","anims","cache","plugins","registry","sound","textures","add","camera","displayList","events","make","scenePlugin","updateList"],e=0;e=(t=t.toString()).length)switch(n){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((s=e-t.length)/2);t=new Array(s-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}},function(t,e){t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)}},function(t,e){t.exports=function(t,e,i,n,s){var r=n+Math.atan2(t.y-i,t.x-e);return t.x=e+s*Math.cos(r),t.y=i+s*Math.sin(r),t}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=t.x2-t.x1,s=t.y2-t.y1,r=t.x3-t.x1,o=t.y3-t.y1,a=Math.random(),h=Math.random();return a+h>=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(s*a+o*h),e}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return e.x=t.x+s*Math.cos(i)*t.width/2,e.y=t.y+s*Math.sin(i)*t.height/2,e}},function(t,e){var i={defaultPipeline:null,pipeline:null,initPipeline:function(t){void 0===t&&(t="TextureTintPipeline");var e=this.scene.sys.game.renderer;return!!(e&&e.gl&&e.hasPipeline(t))&&(this.defaultPipeline=e.getPipeline(t),this.pipeline=this.defaultPipeline,!0)},setPipeline:function(t){var e=this.scene.sys.game.renderer;return e&&e.gl&&e.hasPipeline(t)&&(this.pipeline=e.getPipeline(t)),this},resetPipeline:function(){return this.pipeline=this.defaultPipeline,null!==this.pipeline},getPipelineName:function(){return this.pipeline.name}};t.exports=i},function(t,e,i){var n=i(6);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},function(t,e,i){var n=i(65),s=i(6);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=n(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,l=t.y2,u=0;u=1)return i.x=t.x,i.y=t.y,i;var r=n(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),r=s>1?2-s:s,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},function(t,e,i){var n=i(6);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},function(t,e){t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},,,function(t,e,i){var n=i(0),s=i(64),r=i(2),o=i(894),a=i(893),h=i(892),l=i(38),u=i(10),c=i(197),d=new n({Extends:c,Mixins:[o],initialize:function(t){var e=t.renderer.config;c.call(this,{game:t.game,renderer:t.renderer,gl:t.renderer.gl,topology:r(t,"topology",t.renderer.gl.TRIANGLES),vertShader:r(t,"vertShader",h),fragShader:r(t,"fragShader",a),vertexCapacity:r(t,"vertexCapacity",6*e.batchSize),vertexSize:r(t,"vertexSize",5*Float32Array.BYTES_PER_ELEMENT+4*Uint8Array.BYTES_PER_ELEMENT),attributes:[{name:"inPosition",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:0},{name:"inTexCoord",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:2*Float32Array.BYTES_PER_ELEMENT},{name:"inTintEffect",size:1,type:t.renderer.gl.FLOAT,normalized:!1,offset:4*Float32Array.BYTES_PER_ELEMENT},{name:"inTint",size:4,type:t.renderer.gl.UNSIGNED_BYTE,normalized:!0,offset:5*Float32Array.BYTES_PER_ELEMENT}]}),this.vertexViewF32=new Float32Array(this.vertexData),this.vertexViewU32=new Uint32Array(this.vertexData),this.maxQuads=e.batchSize,this.batches=[],this._tempMatrix1=new l,this._tempMatrix2=new l,this._tempMatrix3=new l,this._tempMatrix4=new l,this.tempTriangle=[{x:0,y:0,width:0},{x:0,y:0,width:0},{x:0,y:0,width:0},{x:0,y:0,width:0}],this.tintEffect=2,this.strokeTint={TL:0,TR:0,BL:0,BR:0},this.fillTint={TL:0,TR:0,BL:0,BR:0},this.currentFrame={u0:0,v0:0,u1:1,v1:1},this.firstQuad=[0,0,0,0,0],this.prevQuad=[0,0,0,0,0],this.polygonCache=[],this.mvpInit()},onBind:function(){return c.prototype.onBind.call(this),this.mvpUpdate(),0===this.batches.length&&this.pushBatch(),this},resize:function(t,e,i){return c.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},setTexture2D:function(t,e){t||(t=this.renderer.blankTexture.glTexture,e=0);var i=this.batches;0===i.length&&this.pushBatch();var n=i[i.length-1];return e>0?(n.textures[e-1]&&n.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==n.texture&&n.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,n=this.gl,s=this.vertexCount,r=this.topology,o=this.vertexSize,a=this.renderer,h=this.batches,l=0,u=null;if(0===h.length||0===s)return this.flushLocked=!1,this;n.bufferSubData(n.ARRAY_BUFFER,0,this.bytes.subarray(0,s*o));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(a.setTexture2D(u.texture,0),n.drawArrays(r,u.first,l)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},batchSprite:function(t,e,i){this.renderer.setPipeline(this);var n=this._tempMatrix1,s=this._tempMatrix2,r=this._tempMatrix3,o=t.frame,a=o.glTexture,h=o.u0,l=o.v0,c=o.u1,d=o.v1,f=o.x,p=o.y,g=o.cutWidth,v=o.cutHeight,m=-t.displayOriginX+f,y=-t.displayOriginY+p;if(t.isCropped){var x=t._crop;x.flipX===t.flipX&&x.flipY===t.flipY||o.updateCropUVs(x,t.flipX,t.flipY),h=x.u0,l=x.v0,c=x.u1,d=x.v1,g=x.width,v=x.height,f=x.x,p=x.y,m=-t.displayOriginX+f,y=-t.displayOriginY+p}t.flipX&&(m+=g,g*=-1),t.flipY&&(y+=v,v*=-1);var w=m+g,T=y+v;s.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),n.copyFrom(e.matrix),i?(n.multiplyWithOffset(i,-e.scrollX*t.scrollFactorX,-e.scrollY*t.scrollFactorY),s.e=t.x,s.f=t.y,n.multiply(s,r)):(s.e-=e.scrollX*t.scrollFactorX,s.f-=e.scrollY*t.scrollFactorY,n.multiply(s,r));var b=r.getX(m,y),_=r.getY(m,y),S=r.getX(m,T),A=r.getY(m,T),C=r.getX(w,T),M=r.getY(w,T),E=r.getX(w,y),P=r.getY(w,y),L=u.getTintAppendFloatAlpha(t._tintTL,e.alpha*t._alphaTL),F=u.getTintAppendFloatAlpha(t._tintTR,e.alpha*t._alphaTR),k=u.getTintAppendFloatAlpha(t._tintBL,e.alpha*t._alphaBL),R=u.getTintAppendFloatAlpha(t._tintBR,e.alpha*t._alphaBR);e.roundPixels&&(b|=0,_|=0,S|=0,A|=0,C|=0,M|=0,E|=0,P|=0),this.setTexture2D(a,0);var O=t._isTinted&&t.tintFill;this.batchQuad(b,_,S,A,C,M,E,P,h,l,c,d,L,F,k,R,O)},batchQuad:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f,p,g,v){var m=!1;this.vertexCount+6>this.vertexCapacity&&(this.flush(),m=!0);var y=this.vertexViewF32,x=this.vertexViewU32,w=this.vertexCount*this.vertexComponentCount-1;return y[++w]=t,y[++w]=e,y[++w]=h,y[++w]=l,y[++w]=v,x[++w]=d,y[++w]=i,y[++w]=n,y[++w]=h,y[++w]=c,y[++w]=v,x[++w]=p,y[++w]=s,y[++w]=r,y[++w]=u,y[++w]=c,y[++w]=v,x[++w]=g,y[++w]=t,y[++w]=e,y[++w]=h,y[++w]=l,y[++w]=v,x[++w]=d,y[++w]=s,y[++w]=r,y[++w]=u,y[++w]=c,y[++w]=v,x[++w]=g,y[++w]=o,y[++w]=a,y[++w]=u,y[++w]=l,y[++w]=v,x[++w]=f,this.vertexCount+=6,m},batchTri:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f){var p=!1;this.vertexCount+3>this.vertexCapacity&&(this.flush(),p=!0);var g=this.vertexViewF32,v=this.vertexViewU32,m=this.vertexCount*this.vertexComponentCount-1;return g[++m]=t,g[++m]=e,g[++m]=o,g[++m]=a,g[++m]=f,v[++m]=u,g[++m]=i,g[++m]=n,g[++m]=o,g[++m]=l,g[++m]=f,v[++m]=c,g[++m]=s,g[++m]=r,g[++m]=h,g[++m]=l,g[++m]=f,v[++m]=d,this.vertexCount+=3,p},batchTexture:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f,p,g,v,m,y,x,w,T,b,_,S,A,C,M,E,P,L){this.renderer.setPipeline(this,t);var F=this._tempMatrix1,k=this._tempMatrix2,R=this._tempMatrix3,O=m/i+C,D=y/n+M,I=(m+x)/i+C,B=(y+w)/n+M,Y=o,X=a,z=-g,N=-v;if(t.isCropped){var U=t._crop;Y=U.width,X=U.height,o=U.width,a=U.height;var G=m=U.x,W=y=U.y;c&&(G=x-U.x-U.width),d&&!e.isRenderTexture&&(W=w-U.y-U.height),O=G/i+C,D=W/n+M,I=(G+U.width)/i+C,B=(W+U.height)/n+M,z=-g+m,N=-v+y}d^=!L&&e.isRenderTexture?1:0,c&&(Y*=-1,z+=o),d&&(X*=-1,N+=a);var V=z+Y,H=N+X;k.applyITRS(s,r,u,h,l),F.copyFrom(E.matrix),P?(F.multiplyWithOffset(P,-E.scrollX*f,-E.scrollY*p),k.e=s,k.f=r,F.multiply(k,R)):(k.e-=E.scrollX*f,k.f-=E.scrollY*p,F.multiply(k,R));var j=R.getX(z,N),q=R.getY(z,N),K=R.getX(z,H),J=R.getY(z,H),Z=R.getX(V,H),Q=R.getY(V,H),$=R.getX(V,N),tt=R.getY(V,N);E.roundPixels&&(j|=0,q|=0,K|=0,J|=0,Z|=0,Q|=0,$|=0,tt|=0),this.setTexture2D(e,0),this.batchQuad(j,q,K,J,Z,Q,$,tt,O,D,I,B,T,b,_,S,A)},batchTextureFrame:function(t,e,i,n,s,r,o){this.renderer.setPipeline(this);var a=this._tempMatrix1.copyFrom(r),h=this._tempMatrix2,l=e+t.width,c=i+t.height;o?a.multiply(o,h):h=a;var d=h.getX(e,i),f=h.getY(e,i),p=h.getX(e,c),g=h.getY(e,c),v=h.getX(l,c),m=h.getY(l,c),y=h.getX(l,i),x=h.getY(l,i);this.setTexture2D(t.glTexture,0),n=u.getTintAppendFloatAlpha(n,s),this.batchQuad(d,f,p,g,v,m,y,x,t.u0,t.v0,t.u1,t.v1,n,n,n,n,0)},drawFillRect:function(t,e,i,n,s,r){var o=t+i,a=e+n,h=u.getTintAppendFloatAlphaAndSwap(s,r);this.batchQuad(t,e,t,a,o,a,o,e,0,0,1,1,h,h,h,h,2)},batchFillRect:function(t,e,i,n,s,r){this.renderer.setPipeline(this);var o=this._tempMatrix3;r&&r.multiply(s,o);var a=t+i,h=e+n,l=o.getX(t,e),u=o.getY(t,e),c=o.getX(t,h),d=o.getY(t,h),f=o.getX(a,h),p=o.getY(a,h),g=o.getX(a,e),v=o.getY(a,e),m=this.currentFrame,y=m.u0,x=m.v0,w=m.u1,T=m.v1;this.batchQuad(l,u,c,d,f,p,g,v,y,x,w,T,this.fillTint.TL,this.fillTint.TR,this.fillTint.BL,this.fillTint.BR,this.tintEffect)},batchFillTriangle:function(t,e,i,n,s,r,o,a){this.renderer.setPipeline(this);var h=this._tempMatrix3;a&&a.multiply(o,h);var l=h.getX(t,e),u=h.getY(t,e),c=h.getX(i,n),d=h.getY(i,n),f=h.getX(s,r),p=h.getY(s,r),g=this.currentFrame,v=g.u0,m=g.v0,y=g.u1,x=g.v1;this.batchTri(l,u,c,d,f,p,v,m,y,x,this.fillTint.TL,this.fillTint.TR,this.fillTint.BL,this.tintEffect)},batchStrokeTriangle:function(t,e,i,n,s,r,o,a,h){var l=this.tempTriangle;l[0].x=t,l[0].y=e,l[0].width=o,l[1].x=i,l[1].y=n,l[1].width=o,l[2].x=s,l[2].y=r,l[2].width=o,l[3].x=t,l[3].y=e,l[3].width=o,this.batchStrokePath(l,o,!1,a,h)},batchFillPath:function(t,e,i){this.renderer.setPipeline(this);var n=this._tempMatrix3;i&&i.multiply(e,n);for(var r,o,a=t.length,h=this.polygonCache,l=this.fillTint.TL,u=this.fillTint.TR,c=this.fillTint.BL,d=this.tintEffect,f=0;f0&&H[4]?this.batchQuad(R,O,P,L,H[0],H[1],H[2],H[3],U,G,W,V,B,Y,X,z,I):(j[0]=R,j[1]=O,j[2]=P,j[3]=L,j[4]=1),h&&j[4]?this.batchQuad(M,E,F,k,j[0],j[1],j[2],j[3],U,G,W,V,B,Y,X,z,I):(H[0]=M,H[1]=E,H[2]=F,H[3]=k,H[4]=1)}}});t.exports=d},function(t,e,i){var n=i(0),s=i(10),r=new n({initialize:function(t){this.name="WebGLPipeline",this.game=t.game,this.view=t.game.canvas,this.resolution=t.game.config.resolution,this.width=t.game.config.width*this.resolution,this.height=t.game.config.height*this.resolution,this.gl=t.gl,this.vertexCount=0,this.vertexCapacity=t.vertexCapacity,this.renderer=t.renderer,this.vertexData=t.vertices?t.vertices:new ArrayBuffer(t.vertexCapacity*t.vertexSize),this.vertexBuffer=this.renderer.createVertexBuffer(t.vertices?t.vertices:this.vertexData.byteLength,this.gl.STREAM_DRAW),this.program=this.renderer.createProgram(t.vertShader,t.fragShader),this.attributes=t.attributes,this.vertexSize=t.vertexSize,this.topology=t.topology,this.bytes=new Uint8Array(this.vertexData),this.vertexComponentCount=s.getComponentCount(t.attributes,this.gl),this.flushLocked=!1,this.active=!1},boot:function(){},addAttribute:function(t,e,i,n,s){return this.attributes.push({name:t,size:e,type:this.renderer.glFormats[i],normalized:n,offset:s}),this},shouldFlush:function(){return this.vertexCount>=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,n=this.program,s=this.renderer,r=this.vertexSize;s.setProgram(n),s.setVertexBuffer(e);for(var o=0;o=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,a.size,a.type,a.normalized,r,a.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,n=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*n)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,n){return this.renderer.setFloat3(this.program,t,e,i,n),this},setFloat4:function(t,e,i,n,s){return this.renderer.setFloat4(this.program,t,e,i,n,s),this},setFloat1v:function(t,e){return this.renderer.setFloat1v(this.program,t,e),this},setFloat2v:function(t,e){return this.renderer.setFloat2v(this.program,t,e),this},setFloat3v:function(t,e){return this.renderer.setFloat3v(this.program,t,e),this},setFloat4v:function(t,e){return this.renderer.setFloat4v(this.program,t,e),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,n){return this.renderer.setInt3(this.program,t,e,i,n),this},setInt4:function(t,e,i,n,s){return this.renderer.setInt4(this.program,t,e,i,n,s),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e,i){var n=i(53);t.exports=function(t){return n(t,-180,180)}},function(t,e,i){var n=i(53);t.exports=function(t){return n(t,-Math.PI,Math.PI)}},function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){var n=i(0),s=i(11),r=i(97),o=i(83),a=new n({Extends:s,initialize:function(t){s.call(this),this.manager=t,this.isTimeline=!0,this.data=[],this.totalData=0,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},add:function(t){return this.queue(r(this,t))},queue:function(t){return this.isPlaying()||(t.parent=this,t.parentIsTimeline=!0,this.data.push(t),this.totalData=this.data.length),this},hasOffset:function(t){return null!==t.offset},isOffsetAbsolute:function(t){return"number"==typeof t},isOffsetRelative:function(t){if("string"===typeof t){var e=t[0];if("-"===e||"+"===e)return!0}return!1},getRelativeOffset:function(t,e){var i=t[0],n=parseFloat(t.substr(2)),s=e;switch(i){case"+":s+=n;break;case"-":s-=n}return Math.max(0,s)},calcDuration:function(){for(var t=0,e=0,i=0,n=0;n0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=o.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=o.PENDING_REMOVE}},update:function(t,e){if(this.state!==o.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var n=this.totalData,s=0;s0?Math.floor(v/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=a(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=o(e,"yoyo",g.yoyo),g.flipX=o(e,"flipX",g.flipX),g.flipY=o(e,"flipY",g.flipY);for(var m=0;m0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var n=i(0),s=i(14),r=i(26),o=i(19),a=i(446),h=i(103),l=i(38),u=i(10),c=new n({Extends:o,Mixins:[s.Alpha,s.BlendMode,s.ComputedSize,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.Transform,s.Visible,s.ScrollFactor,a],initialize:function(t,e,i,n,s,a){o.call(this,t,"StaticTilemapLayer"),this.isTilemap=!0,this.tilemap=e,this.layerIndex=i,this.layer=e.layers[i],this.layer.tilemapLayer=this,this.tileset=[],this.culledTiles=[],this.skipCull=!1,this.tilesDrawn=0,this.tilesTotal=this.layer.width*this.layer.height,this.cullPaddingX=1,this.cullPaddingY=1,this.cullCallback=h.CullTiles,this.renderer=t.sys.game.renderer,this.vertexBuffer=[],this.bufferData=[],this.vertexViewF32=[],this.vertexViewU32=[],this.dirty=[],this.vertexCount=[],this._renderOrder=0,this._tempMatrix=new l,this.gidMap=[],this.setTilesets(n),this.setAlpha(this.layer.alpha),this.setPosition(s,a),this.setOrigin(),this.setSize(this.layer.tileWidth*this.layer.width,this.layer.tileHeight*this.layer.height),this.updateVBOData(),this.initPipeline("TextureTintPipeline"),t.sys.game.config.renderType===r.WEBGL&&t.sys.game.renderer.onContextRestored(function(){this.updateVBOData()},this)},setTilesets:function(t){var e=[],i=[],n=this.tilemap;Array.isArray(t)||(t=[t]);for(var s=0;sv||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));else if(1===p)for(o=0;o=0;a--)!(r=f[o][a])||r.indexv||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));else if(2===p)for(o=u-1;o>=0;o--)for(a=0;av||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));else if(3===p)for(o=u-1;o>=0;o--)for(a=l-1;a>=0;a--)!(r=f[o][a])||r.indexv||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));this.dirty[e]=!1,null===m?(m=i.createVertexBuffer(y,n.STATIC_DRAW),this.vertexBuffer[e]=m):(i.setVertexBuffer(m),n.bufferSubData(n.ARRAY_BUFFER,0,y))}return this},batchTile:function(t,e,i,n,s,r,o){var a=i.getTileTextureCoordinates(e.index);if(!a)return t;var h=a.x/n,l=a.y/s,c=(a.x+e.width)/n,d=(a.y+e.height)/s,f=this._tempMatrix,p=e.width,g=e.height,v=p/2,m=g/2,y=-v,x=-m;e.flipX&&(p*=-1,y+=e.width),e.flipY&&(g*=-1,x+=e.height);var w=y+p,T=x+g;f.applyITRS(v+e.pixelX,m+e.pixelY,e.rotation,1,1);var b=u.getTintAppendFloatAlpha(16777215,r.alpha*this.alpha*e.alpha),_=f.getX(y,x),S=f.getY(y,x),A=f.getX(y,T),C=f.getY(y,T),M=f.getX(w,T),E=f.getY(w,T),P=f.getX(w,x),L=f.getY(w,x);r.roundPixels&&(_|=0,S|=0,A|=0,C|=0,M|=0,E|=0,P|=0,L|=0);var F=this.vertexViewF32[o],k=this.vertexViewU32[o];return F[++t]=_,F[++t]=S,F[++t]=h,F[++t]=l,F[++t]=0,k[++t]=b,F[++t]=A,F[++t]=C,F[++t]=h,F[++t]=d,F[++t]=0,k[++t]=b,F[++t]=M,F[++t]=E,F[++t]=c,F[++t]=d,F[++t]=0,k[++t]=b,F[++t]=_,F[++t]=S,F[++t]=h,F[++t]=l,F[++t]=0,k[++t]=b,F[++t]=M,F[++t]=E,F[++t]=c,F[++t]=d,F[++t]=0,k[++t]=b,F[++t]=P,F[++t]=L,F[++t]=c,F[++t]=l,F[++t]=0,k[++t]=b,this.vertexCount[o]+=6,t},setRenderOrder:function(t){if("string"==typeof t&&(t=["right-down","left-down","right-up","left-up"].indexOf(t)),t>=0&&t<4){this._renderOrder=t;for(var e=0;e=0&&t<4&&(this._renderOrder=t),this},calculateFacesAt:function(t,e){return a.CalculateFacesAt(t,e,this.layer),this},calculateFacesWithin:function(t,e,i,n){return a.CalculateFacesWithin(t,e,i,n,this.layer),this},createFromTiles:function(t,e,i,n,s){return a.CreateFromTiles(t,e,i,n,s,this.layer)},cull:function(t){return this.cullCallback(this.layer,t,this.culledTiles,this._renderOrder)},copy:function(t,e,i,n,s,r,o){return a.Copy(t,e,i,n,s,r,o,this.layer),this},destroy:function(){this.layer.tilemapLayer===this&&(this.layer.tilemapLayer=void 0),this.tilemap=void 0,this.layer=void 0,this.culledTiles.length=0,this.cullCallback=null,this.gidMap=[],this.tileset=[],o.prototype.destroy.call(this)},fill:function(t,e,i,n,s,r){return a.Fill(t,e,i,n,s,r,this.layer),this},filterTiles:function(t,e,i,n,s,r,o){return a.FilterTiles(t,e,i,n,s,r,o,this.layer)},findByIndex:function(t,e,i){return a.FindByIndex(t,e,i,this.layer)},findTile:function(t,e,i,n,s,r,o){return a.FindTile(t,e,i,n,s,r,o,this.layer)},forEachTile:function(t,e,i,n,s,r,o){return a.ForEachTile(t,e,i,n,s,r,o,this.layer),this},getTileAt:function(t,e,i){return a.GetTileAt(t,e,i,this.layer)},getTileAtWorldXY:function(t,e,i,n){return a.GetTileAtWorldXY(t,e,i,n,this.layer)},getTilesWithin:function(t,e,i,n,s){return a.GetTilesWithin(t,e,i,n,s,this.layer)},getTilesWithinShape:function(t,e,i){return a.GetTilesWithinShape(t,e,i,this.layer)},getTilesWithinWorldXY:function(t,e,i,n,s,r){return a.GetTilesWithinWorldXY(t,e,i,n,s,r,this.layer)},hasTileAt:function(t,e){return a.HasTileAt(t,e,this.layer)},hasTileAtWorldXY:function(t,e,i){return a.HasTileAtWorldXY(t,e,i,this.layer)},putTileAt:function(t,e,i,n){return a.PutTileAt(t,e,i,n,this.layer)},putTileAtWorldXY:function(t,e,i,n,s){return a.PutTileAtWorldXY(t,e,i,n,s,this.layer)},putTilesAt:function(t,e,i,n){return a.PutTilesAt(t,e,i,n,this.layer),this},randomize:function(t,e,i,n,s){return a.Randomize(t,e,i,n,s,this.layer),this},removeTileAt:function(t,e,i,n){return a.RemoveTileAt(t,e,i,n,this.layer)},removeTileAtWorldXY:function(t,e,i,n,s){return a.RemoveTileAtWorldXY(t,e,i,n,s,this.layer)},renderDebug:function(t,e){return a.RenderDebug(t,e,this.layer),this},replaceByIndex:function(t,e,i,n,s,r){return a.ReplaceByIndex(t,e,i,n,s,r,this.layer),this},setSkipCull:function(t){return void 0===t&&(t=!0),this.skipCull=t,this},setCullPadding:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=1),this.cullPaddingX=t,this.cullPaddingY=e,this},setCollision:function(t,e,i){return a.SetCollision(t,e,i,this.layer),this},setCollisionBetween:function(t,e,i,n){return a.SetCollisionBetween(t,e,i,n,this.layer),this},setCollisionByProperty:function(t,e,i){return a.SetCollisionByProperty(t,e,i,this.layer),this},setCollisionByExclusion:function(t,e,i){return a.SetCollisionByExclusion(t,e,i,this.layer),this},setCollisionFromCollisionGroup:function(t,e){return a.SetCollisionFromCollisionGroup(t,e,this.layer),this},setTileIndexCallback:function(t,e,i){return a.SetTileIndexCallback(t,e,i,this.layer),this},setTileLocationCallback:function(t,e,i,n,s,r){return a.SetTileLocationCallback(t,e,i,n,s,r,this.layer),this},shuffle:function(t,e,i,n){return a.Shuffle(t,e,i,n,this.layer),this},swapByIndex:function(t,e,i,n,s,r){return a.SwapByIndex(t,e,i,n,s,r,this.layer),this},tileToWorldX:function(t,e){return a.TileToWorldX(t,e,this.layer)},tileToWorldY:function(t,e){return a.TileToWorldY(t,e,this.layer)},tileToWorldXY:function(t,e,i,n){return a.TileToWorldXY(t,e,i,n,this.layer)},weightedRandomize:function(t,e,i,n,s){return a.WeightedRandomize(t,e,i,n,s,this.layer),this},worldToTileX:function(t,e,i){return a.WorldToTileX(t,e,i,this.layer)},worldToTileY:function(t,e,i){return a.WorldToTileY(t,e,i,this.layer)},worldToTileXY:function(t,e,i,n,s){return a.WorldToTileXY(t,e,i,n,s,this.layer)}});t.exports=h},function(t,e,i){var n=i(0),s=i(31),r=i(208),o=i(20),a=i(29),h=i(78),l=i(242),u=i(207),c=i(55),d=i(103),f=i(99),p=new n({initialize:function(t,e){this.scene=t,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.width=e.width,this.height=e.height,this.orientation=e.orientation,this.renderOrder=e.renderOrder,this.format=e.format,this.version=e.version,this.properties=e.properties,this.widthInPixels=e.widthInPixels,this.heightInPixels=e.heightInPixels,this.imageCollections=e.imageCollections,this.images=e.images,this.layers=e.layers,this.tilesets=e.tilesets,this.objects=e.objects,this.currentLayerIndex=0},setRenderOrder:function(t){var e=["right-down","left-down","right-up","left-up"];return"number"==typeof t&&(t=e[t]),e.indexOf(t)>-1&&(this.renderOrder=t),this},addTilesetImage:function(t,e,i,n,s,r,o){if(void 0===t)return null;if(void 0!==e&&null!==e||(e=t),!this.scene.sys.textures.exists(e))return console.warn("Invalid Tileset Image: "+e),null;var h=this.scene.sys.textures.get(e),l=this.getTilesetIndex(t);if(null===l&&this.format===a.TILED_JSON)return console.warn("No data found for Tileset: "+t),null;var u=this.tilesets[l];return u?(u.setTileSize(i,n),u.setSpacing(s,r),u.setImage(h),u):(void 0===i&&(i=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===s&&(s=0),void 0===r&&(r=0),void 0===o&&(o=0),(u=new f(t,o,i,n,s,r)).setImage(h),this.tilesets.push(u),u)},convertLayerToStatic:function(t){if(null===(t=this.getLayer(t)))return null;var e=t.tilemapLayer;if(!(e&&e instanceof r))return null;var i=new u(e.scene,e.tilemap,e.layerIndex,e.tileset,e.x,e.y);return this.scene.sys.displayList.add(i),e.destroy(),i},copy:function(t,e,i,n,s,r,o,a){return a=this.getLayer(a),this._isStaticCall(a,"copy")?this:(null!==a&&d.Copy(t,e,i,n,s,r,o,a),this)},createBlankDynamicLayer:function(t,e,i,n,s,o,a,l){if(void 0===a&&(a=e.tileWidth),void 0===l&&(l=e.tileHeight),void 0===s&&(s=this.width),void 0===o&&(o=this.height),void 0===i&&(i=0),void 0===n&&(n=0),null!==this.getLayerIndex(t))return console.warn("Invalid Tilemap Layer ID: "+t),null;for(var u,d=new h({name:t,tileWidth:a,tileHeight:l,width:s,height:o}),f=0;fa&&(a=e.layer[l].width),e.layer[l].height>h&&(h=e.layer[l].height);var u=new s({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:n.WELTMEISTER});return u.layers=r(e,i),u.tilesets=o(e),u}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","object layer"),this.opacity=s(t,"opacity",1),this.properties=s(t,"properties",{}),this.propertyTypes=s(t,"propertytypes",{}),this.type=s(t,"type","objectgroup"),this.visible=s(t,"visible",!0),this.objects=s(t,"objects",[])}});t.exports=r},function(t,e,i){var n=i(455),s=i(214),r=function(t){return{x:t.x,y:t.y}},o=["id","name","type","rotation","properties","visible","x","y","width","height"];t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var a=n(t,o);if(a.x+=e,a.y+=i,t.gid){var h=s(t.gid);a.gid=h.gid,a.flippedHorizontal=h.flippedHorizontal,a.flippedVertical=h.flippedVertical,a.flippedAntiDiagonal=h.flippedAntiDiagonal}else t.polyline?a.polyline=t.polyline.map(r):t.polygon?a.polygon=t.polygon.map(r):t.ellipse?(a.ellipse=t.ellipse,a.width=t.width,a.height=t.height):t.text?(a.width=t.width,a.height=t.height,a.text=t.text):(a.rectangle=!0,a.width=t.width,a.height=t.height);return a}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|n,this.imageMargin=0|s,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&t-1}return!1}},function(t,e,i){var n=i(17);t.exports=function(t,e,i,s,r,o,a){for(var h=n(i,s,r,o,null,a),l=0;l0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):o(this,t,e)},postUpdate:function(){},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},function(t,e){t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},function(t,e,i){var n=i(313);function s(t){if(!(this instanceof s))return new s(t,[".left",".top",".right",".bottom"]);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}function r(t,e,i){if(!i)return e.indexOf(t);for(var n=0;n=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(t,e,i,s,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=s||(o=e+Math.ceil((i-e)/s/2)*s,n(t,o,e,i,r),a.push(e,o,o,i))}s.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!p(t,e))return i;for(var s,r,o,a,h=[];e;){for(s=0,r=e.children.length;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)},_split:function(t,e){var i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);var r=this._chooseSplitIndex(i,s,n),a=g(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,s,r,o,h,l,u,d,f,p,g,v,m,y;for(l=u=1/0,n=e;n<=i-e;n++)s=a(t,0,n,this.toBBox),r=a(t,n,i,this.toBBox),f=s,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),v=Math.max(f.minY,p.minY),m=Math.min(f.maxX,p.maxX),y=Math.min(f.maxY,p.maxY),o=Math.max(0,m-g)*Math.max(0,y-v),h=c(s)+c(r),o=e;s--)r=t.children[s],h(u,t.leaf?o(r):r),c+=d(u);return c},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)h(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},compareMinX:function(t,e){return t.left-e.left},compareMinY:function(t,e){return t.top-e.top},toBBox:function(t){return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}},t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,n=this._active;for(t=0;te._dy?(r=t.bottom-e.y)>o&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?r=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.down=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.up=!0)):t._dyo&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?r=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.up=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.down=!0))),t.overlapY=r,e.overlapY=r,r}},function(t,e,i){var n=i(35);t.exports=function(t,e,i,s){var r=0,o=t.deltaAbsX()+e.deltaAbsX()+s;return 0===t._dx&&0===e._dx?(t.embedded=!0,e.embedded=!0):t._dx>e._dx?(r=t.right-e.x)>o&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?r=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.right=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.left=!0)):t._dxo&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?r=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.left=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.right=!0))),t.overlapX=r,e.overlapX=r,r}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=n,this.collideCallback=s,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=n},function(t,e,i){var n=i(40),s=i(0),r=i(35),o=i(172),a=i(9),h=i(39),l=i(3),u=new s({initialize:function(t,e){var i=e.width?e.width:64,n=e.height?e.height:64;this.world=t,this.gameObject=e,this.transform={x:e.x,y:e.y,rotation:e.angle,scaleX:e.scaleX,scaleY:e.scaleY,displayOriginX:e.displayOriginX,displayOriginY:e.displayOriginY},this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new l,this.position=new l(e.x,e.y),this.prev=new l(e.x,e.y),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=i,this.height=n,this.sourceWidth=i,this.sourceHeight=n,e.frame&&(this.sourceWidth=e.frame.realWidth,this.sourceHeight=e.frame.realHeight),this.halfWidth=Math.abs(i/2),this.halfHeight=Math.abs(n/2),this.center=new l(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=new l,this.newVelocity=new l,this.deltaMax=new l,this.acceleration=new l,this.allowDrag=!0,this.drag=new l,this.allowGravity=!0,this.gravity=new l,this.bounce=new l,this.worldBounce=null,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.maxVelocity=new l(1e4,1e4),this.friction=new l(1,0),this.useDamping=!1,this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=r.FACING_NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.physicsType=r.DYNAMIC_BODY,this._reset=!0,this._sx=e.scaleX,this._sy=e.scaleY,this._dx=0,this._dy=0,this._bounds=new a},updateBounds:function(){var t=this.gameObject,e=this.transform;if(t.parentContainer){var i=t.getWorldTransformMatrix(this.world._tempMatrix,this.world._tempMatrix2);e.x=i.tx,e.y=i.ty,e.rotation=o(i.rotation),e.scaleX=i.scaleX,e.scaleY=i.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY}else e.x=t.x,e.y=t.y,e.rotation=t.angle,e.scaleX=t.scaleX,e.scaleY=t.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY;var n=!1;if(this.syncBounds){var s=t.getBounds(this._bounds);this.width=s.width,this.height=s.height,n=!0}else{var r=Math.abs(e.scaleX),a=Math.abs(e.scaleY);this._sx===r&&this._sy===a||(this.width=this.sourceWidth*r,this.height=this.sourceHeight*a,this._sx=r,this._sy=a,n=!0)}n&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},update:function(t){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds();var e=this.transform;if(this.position.x=e.x+e.scaleX*(this.offset.x-e.displayOriginX),this.position.y=e.y+e.scaleY*(this.offset.y-e.displayOriginY),this.updateCenter(),this.rotation=e.rotation,this.preRotation=this.rotation,this._reset&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves){this.world.updateMotion(this,t);var i=this.velocity.x,n=this.velocity.y;this.newVelocity.set(i*t,n*t),this.position.add(this.newVelocity),this.updateCenter(),this.angle=Math.atan2(n,i),this.speed=Math.sqrt(i*i+n*n),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.world.emit("worldbounds",this,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)}this._dx=this.position.x-this.prev.x,this._dy=this.position.y-this.prev.y},postUpdate:function(){this._dx=this.position.x-this.prev.x,this._dy=this.position.y-this.prev.y,this.moves&&(0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.gameObject.x+=this._dx,this.gameObject.y+=this._dy,this._reset=!0),this._dx<0?this.facing=r.FACING_LEFT:this._dx>0&&(this.facing=r.FACING_RIGHT),this._dy<0?this.facing=r.FACING_UP:this._dy>0&&(this.facing=r.FACING_DOWN),this.allowRotation&&(this.gameObject.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y},checkWorldBounds:function(){var t=this.position,e=this.world.bounds,i=this.world.checkCollision,n=this.worldBounce?-this.worldBounce.x:-this.bounce.x,s=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=n,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=s,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setSize:function(t,e,i){void 0===i&&(i=!0);var n=this.gameObject;if(!t&&n.frame&&(t=n.frame.realWidth),!e&&n.frame&&(e=n.frame.realHeight),this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&n.getCenter){var s=n.displayWidth/2,r=n.displayHeight/2;this.offset.set(s-this.halfWidth,r-this.halfHeight)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i.setPosition(t,e),i.getTopLeft(this.position),this.prev.copy(this.position),this.rotation=i.angle,this.preRotation=i.angle,this.updateBounds(),this.updateCenter()},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):h(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this._dx>0?this._dx:-this._dx},deltaAbsY:function(){return this._dy>0?this._dy:-this._dy},deltaX:function(){return this._dx},deltaY:function(){return this._dy},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,n=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor),this.isCircle?t.strokeCircle(i,n,this.width/2):t.strokeRect(e.x,e.y,this.width,this.height)),this.debugShowVelocity&&(t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.velocity.x/2,n+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t){return void 0===t&&(t=!0),this.collideWorldBounds=t,this},setVelocity:function(t,e){return this.velocity.set(t,e),this.speed=Math.sqrt(t*t+e*e),this},setVelocityX:function(t){this.velocity.x=t;var e=t,i=this.velocity.y;return this.speed=Math.sqrt(e*e+i*i),this},setVelocityY:function(t){this.velocity.y=t;var e=this.velocity.x,i=t;return this.speed=Math.sqrt(e*e+i*i),this},setMaxVelocity:function(t,e){return this.maxVelocity.set(t,e),this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setAllowDrag:function(t){return void 0===t&&(t=!0),this.allowDrag=t,this},setAllowGravity:function(t){return void 0===t&&(t=!0),this.allowGravity=t,this},setAllowRotation:function(t){return void 0===t&&(t=!0),this.allowRotation=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return void 0===t&&(t=!0),this.immovable=t,this},setEnable:function(t){return void 0===t&&(t=!0),this.enable=t,this},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=u},function(t,e,i){var n=i(232),s=i(23),r=i(0),o=i(231),a=i(35),h=i(52),l=i(11),u=i(248),c=i(247),d=i(246),f=i(230),p=i(229),g=i(4),v=i(228),m=i(514),y=i(9),x=i(227),w=i(513),T=i(508),b=i(507),_=i(95),S=i(225),A=i(226),C=i(38),M=i(3),E=i(53),P=new r({Extends:l,initialize:function(t,e){l.call(this),this.scene=t,this.bodies=new _,this.staticBodies=new _,this.pendingDestroy=new _,this.colliders=new v,this.gravity=new M(g(e,"gravity.x",0),g(e,"gravity.y",0)),this.bounds=new y(g(e,"x",0),g(e,"y",0),g(e,"width",t.sys.game.config.width),g(e,"height",t.sys.game.config.height)),this.checkCollision={up:g(e,"checkCollision.up",!0),down:g(e,"checkCollision.down",!0),left:g(e,"checkCollision.left",!0),right:g(e,"checkCollision.right",!0)},this.fps=g(e,"fps",60),this._elapsed=0,this._frameTime=1/this.fps,this._frameTimeMS=1e3*this._frameTime,this.stepsLastFrame=0,this.timeScale=g(e,"timeScale",1),this.OVERLAP_BIAS=g(e,"overlapBias",4),this.TILE_BIAS=g(e,"tileBias",16),this.forceX=g(e,"forceX",!1),this.isPaused=g(e,"isPaused",!1),this._total=0,this.drawDebug=g(e,"debug",!1),this.debugGraphic,this.defaults={debugShowBody:g(e,"debugShowBody",!0),debugShowStaticBody:g(e,"debugShowStaticBody",!0),debugShowVelocity:g(e,"debugShowVelocity",!0),bodyDebugColor:g(e,"debugBodyColor",16711935),staticBodyDebugColor:g(e,"debugStaticBodyColor",255),velocityDebugColor:g(e,"debugVelocityColor",65280)},this.maxEntries=g(e,"maxEntries",16),this.useTree=g(e,"useTree",!0),this.tree=new x(this.maxEntries),this.staticTree=new x(this.maxEntries),this.treeMinMax={minX:0,minY:0,maxX:0,maxY:0},this._tempMatrix=new C,this._tempMatrix2=new C,this.drawDebug&&this.createDebugGraphic()},enable:function(t,e){void 0===e&&(e=a.DYNAMIC_BODY),Array.isArray(t)||(t=[t]);for(var i=0;i=s;)this._elapsed-=s,i++,this.step(n);this.stepsLastFrame=i}},step:function(t){var e,i,n=this.bodies.entries,s=n.length;for(e=0;e0){var l=this.tree,u=this.staticTree;for(o=(r=s.entries).length,t=0;ta.bottom)&&(h.xa.right))return this.separateCircle(t,e,s)}var l=!1,u=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)l.right&&(a=h(u.x,u.y,l.right,l.y)-u.radius):u.y>l.bottom&&(u.xl.right&&(a=h(u.x,u.y,l.right,l.bottom)-u.radius)),a*=-1}else a=t.halfWidth+e.halfWidth-h(t.center.x,t.center.y,e.center.x,e.center.y);if(i||0===a||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==a&&(t.onOverlap||e.onOverlap)&&this.emit("overlap",t.gameObject,e.gameObject,t,e),0!==a;var c=t.velocity.x,d=t.velocity.y,g=t.mass,v=e.velocity.x,m=e.velocity.y,y=e.mass,x=c*Math.cos(o)+d*Math.sin(o),w=c*Math.sin(o)-d*Math.cos(o),T=v*Math.cos(o)+m*Math.sin(o),b=v*Math.sin(o)-m*Math.cos(o),_=((g-y)*x+2*y*T)/(g+y),S=(2*g*x+(y-g)*T)/(g+y);t.immovable||(t.velocity.x=(_*Math.cos(o)-w*Math.sin(o))*t.bounce.x,t.velocity.y=(w*Math.cos(o)+_*Math.sin(o))*t.bounce.y,c=t.velocity.x,d=t.velocity.y),e.immovable||(e.velocity.x=(S*Math.cos(o)-b*Math.sin(o))*e.bounce.x,e.velocity.y=(b*Math.cos(o)+S*Math.sin(o))*e.bounce.y,v=e.velocity.x,m=e.velocity.y),Math.abs(o)0&&!t.immovable&&v>c?t.velocity.x*=-1:v<0&&!e.immovable&&c0&&!t.immovable&&m>d?t.velocity.y*=-1:m<0&&!e.immovable&&dMath.PI/2&&(c<0&&!t.immovable&&v0&&!e.immovable&&c>v?e.velocity.x*=-1:d<0&&!t.immovable&&m0&&!e.immovable&&c>m&&(e.velocity.y*=-1));var A=this._frameTime;return t.immovable||(t.x+=t.velocity.x*A-a*Math.cos(o),t.y+=t.velocity.y*A-a*Math.sin(o)),e.immovable||(e.x+=e.velocity.x*A+a*Math.cos(o),e.y+=e.velocity.y*A+a*Math.sin(o)),(t.onCollide||e.onCollide)&&this.emit("collide",t.gameObject,e.gameObject,t,e),t.postUpdate(),e.postUpdate(),!0},intersects:function(t,e){return t!==e&&(t.isCircle||e.isCircle?t.isCircle?e.isCircle?h(t.center.x,t.center.y,e.center.x,e.center.y)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):this.circleBodyIntersects(e,t):!(t.right<=e.position.x||t.bottom<=e.position.y||t.position.x>=e.right||t.position.y>=e.bottom))},circleBodyIntersects:function(t,e){var i=s(t.center.x,e.left,e.right),n=s(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!0)},collide:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!1)},collideObjects:function(t,e,i,n,s,r){var o;t.isParent&&void 0===t.physicsType&&(t=t.children.entries),e&&e.isParent&&void 0===e.physicsType&&(e=e.children.entries);var a=Array.isArray(t),h=Array.isArray(e);if(this._total=0,a||h)if(!a&&h)for(o=0;o0},collideHandler:function(t,e,i,n,s,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,n,s,r);if(!t||!e)return!1;if(t.body){if(e.body)return this.collideSpriteVsSprite(t,e,i,n,s,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,n,s,r)}else if(t.isParent){if(e.body)return this.collideSpriteVsGroup(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,n,s,r)}else if(t.isTilemap){if(e.body)return this.collideSpriteVsTilemapLayer(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,n,s,r)}},collideSpriteVsSprite:function(t,e,i,n,s,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,n,s,r)&&(i&&i.call(s,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,n,s,r){var o,h,l,u=t.body;if(0!==e.length&&u&&u.enable)if(this.useTree){var c=this.treeMinMax;c.minX=u.left,c.minY=u.top,c.maxX=u.right,c.maxY=u.bottom;var d=e.physicsType===a.DYNAMIC_BODY?this.tree.search(c):this.staticTree.search(c);for(h=d.length,o=0;oc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,l+=d}c.tileHeight>c.baseTileHeight&&(u+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f,p=e.getTilesWithinWorldXY(a,h,l,u);if(0===p.length)return!1;for(var g={left:0,right:0,top:0,bottom:0},v=0;v0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(u.copy(h).cross(t).length()<1e-6&&u.copy(l).cross(t),u.normalize(),this.setAxisAngle(u,Math.PI)):i>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(u.copy(t).cross(e),this.x=u.x,this.y=u.y,this.z=u.z,this.w=1+i,this.normalize())},setAxes:function(t,e,i){var n=c.val;return n[0]=e.x,n[3]=e.y,n[6]=e.z,n[1]=i.x,n[4]=i.y,n[7]=i.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(c).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=Math.cos(e),this},multiply:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.x=e*h+s*r+i*a-n*o,this.y=i*h+s*o+n*r-e*a,this.z=n*h+s*a+e*o-i*r,this.w=s*h-e*r-i*o-n*a,this},slerp:function(t,e){var i=this.x,n=this.y,s=this.z,r=this.w,o=t.x,a=t.y,h=t.z,l=t.w,u=i*o+n*a+s*h+r*l;u<0&&(u=-u,o=-o,a=-a,h=-h,l=-l);var c=1-e,d=e;if(1-u>1e-6){var f=Math.acos(u),p=Math.sin(f);c=Math.sin((1-e)*f)/p,d=Math.sin(e*f)/p}return this.x=c*i+d*o,this.y=c*n+d*a,this.z=c*s+d*h,this.w=c*r+d*l,this},invert:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-e*r,this.z=-i*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+s*r,this.y=i*o+n*r,this.z=n*o-i*r,this.w=s*o-e*r,this},rotateY:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o-n*r,this.y=i*o+s*r,this.z=n*o+e*r,this.w=s*o-i*r,this},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+i*r,this.y=i*o-e*r,this.z=n*o+s*r,this.w=s*o-n*r,this},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(1-t*t-e*e-i*i),this},fromMat3:function(t){var e,i=t.val,n=i[0]+i[4]+i[8];if(n>0)e=Math.sqrt(n+1),this.w=.5*e,e=.5/e,this.x=(i[7]-i[5])*e,this.y=(i[2]-i[6])*e,this.z=(i[3]-i[1])*e;else{var s=0;i[4]>i[0]&&(s=1),i[8]>i[3*s+s]&&(s=2);var r=o[s],h=o[r];e=Math.sqrt(i[3*s+s]-i[3*r+r]-i[3*h+h]+1),a[s]=.5*e,e=.5/e,a[r]=(i[3*r+s]+i[3*s+r])*e,a[h]=(i[3*h+s]+i[3*s+h])*e,this.x=a[0],this.y=a[1],this.z=a[2],this.w=(i[3*h+r]-i[3*r+h])*e}return this}});t.exports=d},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this},zero:function(){var t=this.val;return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,this},xyz:function(t,e,i){this.identity();var n=this.val;return n[12]=t,n[13]=e,n[14]=i,this},scaling:function(t,e,i){this.zero();var n=this.val;return n[0]=t,n[5]=e,n[10]=i,n[15]=1,this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[3],s=t[6],r=t[7],o=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=s,t[11]=t[14],t[12]=n,t[13]=r,t[14]=o,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15],m=e*o-i*r,y=e*a-n*r,x=e*h-s*r,w=i*a-n*o,T=i*h-s*o,b=n*h-s*a,_=l*p-u*f,S=l*g-c*f,A=l*v-d*f,C=u*g-c*p,M=u*v-d*p,E=c*v-d*g,P=m*E-y*M+x*C+w*A-T*S+b*_;return P?(P=1/P,t[0]=(o*E-a*M+h*C)*P,t[1]=(n*M-i*E-s*C)*P,t[2]=(p*b-g*T+v*w)*P,t[3]=(c*T-u*b-d*w)*P,t[4]=(a*A-r*E-h*S)*P,t[5]=(e*E-n*A+s*S)*P,t[6]=(g*x-f*b-v*y)*P,t[7]=(l*b-c*x+d*y)*P,t[8]=(r*M-o*A+h*_)*P,t[9]=(i*A-e*M-s*_)*P,t[10]=(f*T-p*x+v*m)*P,t[11]=(u*x-l*T-d*m)*P,t[12]=(o*S-r*C-a*_)*P,t[13]=(e*C-i*S+n*_)*P,t[14]=(p*y-f*w-g*m)*P,t[15]=(l*w-u*y+c*m)*P,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return t[0]=o*(c*v-d*g)-u*(a*v-h*g)+p*(a*d-h*c),t[1]=-(i*(c*v-d*g)-u*(n*v-s*g)+p*(n*d-s*c)),t[2]=i*(a*v-h*g)-o*(n*v-s*g)+p*(n*h-s*a),t[3]=-(i*(a*d-h*c)-o*(n*d-s*c)+u*(n*h-s*a)),t[4]=-(r*(c*v-d*g)-l*(a*v-h*g)+f*(a*d-h*c)),t[5]=e*(c*v-d*g)-l*(n*v-s*g)+f*(n*d-s*c),t[6]=-(e*(a*v-h*g)-r*(n*v-s*g)+f*(n*h-s*a)),t[7]=e*(a*d-h*c)-r*(n*d-s*c)+l*(n*h-s*a),t[8]=r*(u*v-d*p)-l*(o*v-h*p)+f*(o*d-h*u),t[9]=-(e*(u*v-d*p)-l*(i*v-s*p)+f*(i*d-s*u)),t[10]=e*(o*v-h*p)-r*(i*v-s*p)+f*(i*h-s*o),t[11]=-(e*(o*d-h*u)-r*(i*d-s*u)+l*(i*h-s*o)),t[12]=-(r*(u*g-c*p)-l*(o*g-a*p)+f*(o*c-a*u)),t[13]=e*(u*g-c*p)-l*(i*g-n*p)+f*(i*c-n*u),t[14]=-(e*(o*g-a*p)-r*(i*g-n*p)+f*(i*a-n*o)),t[15]=e*(o*c-a*u)-r*(i*c-n*u)+l*(i*a-n*o),this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return(e*o-i*r)*(c*v-d*g)-(e*a-n*r)*(u*v-d*p)+(e*h-s*r)*(u*g-c*p)+(i*a-n*o)*(l*v-d*f)-(i*h-s*o)*(l*g-c*f)+(n*h-s*a)*(l*p-u*f)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=t.val,x=y[0],w=y[1],T=y[2],b=y[3];return e[0]=x*i+w*o+T*u+b*p,e[1]=x*n+w*a+T*c+b*g,e[2]=x*s+w*h+T*d+b*v,e[3]=x*r+w*l+T*f+b*m,x=y[4],w=y[5],T=y[6],b=y[7],e[4]=x*i+w*o+T*u+b*p,e[5]=x*n+w*a+T*c+b*g,e[6]=x*s+w*h+T*d+b*v,e[7]=x*r+w*l+T*f+b*m,x=y[8],w=y[9],T=y[10],b=y[11],e[8]=x*i+w*o+T*u+b*p,e[9]=x*n+w*a+T*c+b*g,e[10]=x*s+w*h+T*d+b*v,e[11]=x*r+w*l+T*f+b*m,x=y[12],w=y[13],T=y[14],b=y[15],e[12]=x*i+w*o+T*u+b*p,e[13]=x*n+w*a+T*c+b*g,e[14]=x*s+w*h+T*d+b*v,e[15]=x*r+w*l+T*f+b*m,this},multiplyLocal:function(t){var e=[],i=this.val,n=t.val;return e[0]=i[0]*n[0]+i[1]*n[4]+i[2]*n[8]+i[3]*n[12],e[1]=i[0]*n[1]+i[1]*n[5]+i[2]*n[9]+i[3]*n[13],e[2]=i[0]*n[2]+i[1]*n[6]+i[2]*n[10]+i[3]*n[14],e[3]=i[0]*n[3]+i[1]*n[7]+i[2]*n[11]+i[3]*n[15],e[4]=i[4]*n[0]+i[5]*n[4]+i[6]*n[8]+i[7]*n[12],e[5]=i[4]*n[1]+i[5]*n[5]+i[6]*n[9]+i[7]*n[13],e[6]=i[4]*n[2]+i[5]*n[6]+i[6]*n[10]+i[7]*n[14],e[7]=i[4]*n[3]+i[5]*n[7]+i[6]*n[11]+i[7]*n[15],e[8]=i[8]*n[0]+i[9]*n[4]+i[10]*n[8]+i[11]*n[12],e[9]=i[8]*n[1]+i[9]*n[5]+i[10]*n[9]+i[11]*n[13],e[10]=i[8]*n[2]+i[9]*n[6]+i[10]*n[10]+i[11]*n[14],e[11]=i[8]*n[3]+i[9]*n[7]+i[10]*n[11]+i[11]*n[15],e[12]=i[12]*n[0]+i[13]*n[4]+i[14]*n[8]+i[15]*n[12],e[13]=i[12]*n[1]+i[13]*n[5]+i[14]*n[9]+i[15]*n[13],e[14]=i[12]*n[2]+i[13]*n[6]+i[14]*n[10]+i[15]*n[14],e[15]=i[12]*n[3]+i[13]*n[7]+i[14]*n[11]+i[15]*n[15],this.fromArray(e)},translate:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[12]=s[0]*e+s[4]*i+s[8]*n+s[12],s[13]=s[1]*e+s[5]*i+s[9]*n+s[13],s[14]=s[2]*e+s[6]*i+s[10]*n+s[14],s[15]=s[3]*e+s[7]*i+s[11]*n+s[15],this},scale:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[0]=s[0]*e,s[1]=s[1]*e,s[2]=s[2]*e,s[3]=s[3]*e,s[4]=s[4]*i,s[5]=s[5]*i,s[6]=s[6]*i,s[7]=s[7]*i,s[8]=s[8]*n,s[9]=s[9]*n,s[10]=s[10]*n,s[11]=s[11]*n,this},makeRotationAxis:function(t,e){var i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,a=t.z,h=s*r,l=s*o;return this.fromArray([h*r+i,h*o-n*a,h*a+n*o,0,h*o+n*a,l*o+i,l*a-n*r,0,h*a-n*o,l*a+n*r,s*a*a+i,0,0,0,0,1]),this},rotate:function(t,e){var i=this.val,n=e.x,s=e.y,r=e.z,o=Math.sqrt(n*n+s*s+r*r);if(Math.abs(o)<1e-6)return null;n*=o=1/o,s*=o,r*=o;var a=Math.sin(t),h=Math.cos(t),l=1-h,u=i[0],c=i[1],d=i[2],f=i[3],p=i[4],g=i[5],v=i[6],m=i[7],y=i[8],x=i[9],w=i[10],T=i[11],b=n*n*l+h,_=s*n*l+r*a,S=r*n*l-s*a,A=n*s*l-r*a,C=s*s*l+h,M=r*s*l+n*a,E=n*r*l+s*a,P=s*r*l-n*a,L=r*r*l+h;return i[0]=u*b+p*_+y*S,i[1]=c*b+g*_+x*S,i[2]=d*b+v*_+w*S,i[3]=f*b+m*_+T*S,i[4]=u*A+p*C+y*M,i[5]=c*A+g*C+x*M,i[6]=d*A+v*C+w*M,i[7]=f*A+m*C+T*M,i[8]=u*E+p*P+y*L,i[9]=c*E+g*P+x*L,i[10]=d*E+v*P+w*L,i[11]=f*E+m*P+T*L,this},rotateX:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],l=e[9],u=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+l*i,e[6]=o*n+u*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=l*n-r*i,e[10]=u*n-o*i,e[11]=c*n-a*i,this},rotateY:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],l=e[9],u=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-l*i,e[2]=o*n-u*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+l*n,e[10]=o*i+u*n,e[11]=a*i+c*n,this},rotateZ:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],l=e[5],u=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+l*i,e[2]=o*n+u*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=l*n-r*i,e[6]=u*n-o*i,e[7]=c*n-a*i,this},fromRotationTranslation:function(t,e){var i=this.val,n=t.x,s=t.y,r=t.z,o=t.w,a=n+n,h=s+s,l=r+r,u=n*a,c=n*h,d=n*l,f=s*h,p=s*l,g=r*l,v=o*a,m=o*h,y=o*l;return i[0]=1-(f+g),i[1]=c+y,i[2]=d-m,i[3]=0,i[4]=c-y,i[5]=1-(u+g),i[6]=p+v,i[7]=0,i[8]=d+m,i[9]=p-v,i[10]=1-(u+f),i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},fromQuat:function(t){var e=this.val,i=t.x,n=t.y,s=t.z,r=t.w,o=i+i,a=n+n,h=s+s,l=i*o,u=i*a,c=i*h,d=n*a,f=n*h,p=s*h,g=r*o,v=r*a,m=r*h;return e[0]=1-(d+p),e[1]=u+m,e[2]=c-v,e[3]=0,e[4]=u-m,e[5]=1-(l+p),e[6]=f+g,e[7]=0,e[8]=c+v,e[9]=f-g,e[10]=1-(l+d),e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},frustum:function(t,e,i,n,s,r){var o=this.val,a=1/(e-t),h=1/(n-i),l=1/(s-r);return o[0]=2*s*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2*s*h,o[6]=0,o[7]=0,o[8]=(e+t)*a,o[9]=(n+i)*h,o[10]=(r+s)*l,o[11]=-1,o[12]=0,o[13]=0,o[14]=r*s*2*l,o[15]=0,this},perspective:function(t,e,i,n){var s=this.val,r=1/Math.tan(t/2),o=1/(i-n);return s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+i)*o,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*i*o,s[15]=0,this},perspectiveLH:function(t,e,i,n){var s=this.val;return s[0]=2*i/t,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*i/e,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=-n/(i-n),s[11]=1,s[12]=0,s[13]=0,s[14]=i*n/(i-n),s[15]=0,this},ortho:function(t,e,i,n,s,r){var o=this.val,a=t-e,h=i-n,l=s-r;return a=0===a?a:1/a,h=0===h?h:1/h,l=0===l?l:1/l,o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*l,o[11]=0,o[12]=(t+e)*a,o[13]=(n+i)*h,o[14]=(r+s)*l,o[15]=1,this},lookAt:function(t,e,i){var n=this.val,s=t.x,r=t.y,o=t.z,a=i.x,h=i.y,l=i.z,u=e.x,c=e.y,d=e.z;if(Math.abs(s-u)<1e-6&&Math.abs(r-c)<1e-6&&Math.abs(o-d)<1e-6)return this.identity();var f=s-u,p=r-c,g=o-d,v=1/Math.sqrt(f*f+p*p+g*g),m=h*(g*=v)-l*(p*=v),y=l*(f*=v)-a*g,x=a*p-h*f;(v=Math.sqrt(m*m+y*y+x*x))?(m*=v=1/v,y*=v,x*=v):(m=0,y=0,x=0);var w=p*x-g*y,T=g*m-f*x,b=f*y-p*m;return(v=Math.sqrt(w*w+T*T+b*b))?(w*=v=1/v,T*=v,b*=v):(w=0,T=0,b=0),n[0]=m,n[1]=w,n[2]=f,n[3]=0,n[4]=y,n[5]=T,n[6]=p,n[7]=0,n[8]=x,n[9]=b,n[10]=g,n[11]=0,n[12]=-(m*s+y*r+x*o),n[13]=-(w*s+T*r+b*o),n[14]=-(f*s+p*r+g*o),n[15]=1,this},yawPitchRoll:function(t,e,i){this.zero(),s.zero(),r.zero();var n=this.val,o=s.val,a=r.val,h=Math.sin(i),l=Math.cos(i);return n[10]=1,n[15]=1,n[0]=l,n[1]=h,n[4]=-h,n[5]=l,h=Math.sin(e),l=Math.cos(e),o[0]=1,o[15]=1,o[5]=l,o[10]=l,o[9]=-h,o[6]=h,h=Math.sin(t),l=Math.cos(t),a[5]=1,a[15]=1,a[0]=l,a[2]=-h,a[8]=h,a[10]=l,this.multiplyLocal(s),this.multiplyLocal(r),this},setWorldMatrix:function(t,e,i,n,o){return this.yawPitchRoll(t.y,t.x,t.z),s.scaling(i.x,i.y,i.z),r.xyz(e.x,e.y,e.z),this.multiplyLocal(s),this.multiplyLocal(r),void 0!==n&&this.multiplyLocal(n),void 0!==o&&this.multiplyLocal(o),this}}),s=new n,r=new n;t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},fromMat4:function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=n,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=l*r-o*h,c=-l*s+o*a,d=h*s-r*a,f=e*u+i*c+n*d;return f?(f=1/f,t[0]=u*f,t[1]=(-l*i+n*h)*f,t[2]=(o*i-n*r)*f,t[3]=c*f,t[4]=(l*e-n*a)*f,t[5]=(-o*e+n*s)*f,t[6]=d*f,t[7]=(-h*e+i*a)*f,t[8]=(r*e-i*s)*f,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return t[0]=r*l-o*h,t[1]=n*h-i*l,t[2]=i*o-n*r,t[3]=o*a-s*l,t[4]=e*l-n*a,t[5]=n*s-e*o,t[6]=s*h-r*a,t[7]=i*a-e*h,t[8]=e*r-i*s,this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return e*(l*r-o*h)+i*(-l*s+o*a)+n*(h*s-r*a)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=t.val,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],m=c[5],y=c[6],x=c[7],w=c[8];return e[0]=d*i+f*r+p*h,e[1]=d*n+f*o+p*l,e[2]=d*s+f*a+p*u,e[3]=g*i+v*r+m*h,e[4]=g*n+v*o+m*l,e[5]=g*s+v*a+m*u,e[6]=y*i+x*r+w*h,e[7]=y*n+x*o+w*l,e[8]=y*s+x*a+w*u,this},translate:function(t){var e=this.val,i=t.x,n=t.y;return e[6]=i*e[0]+n*e[3]+e[6],e[7]=i*e[1]+n*e[4]+e[7],e[8]=i*e[2]+n*e[5]+e[8],this},rotate:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=Math.sin(t),l=Math.cos(t);return e[0]=l*i+h*r,e[1]=l*n+h*o,e[2]=l*s+h*a,e[3]=l*r-h*i,e[4]=l*o-h*n,e[5]=l*a-h*s,this},scale:function(t){var e=this.val,i=t.x,n=t.y;return e[0]=i*e[0],e[1]=i*e[1],e[2]=i*e[2],e[3]=n*e[3],e[4]=n*e[4],e[5]=n*e[5],this},fromQuat:function(t){var e=t.x,i=t.y,n=t.z,s=t.w,r=e+e,o=i+i,a=n+n,h=e*r,l=e*o,u=e*a,c=i*o,d=i*a,f=n*a,p=s*r,g=s*o,v=s*a,m=this.val;return m[0]=1-(c+f),m[3]=l+v,m[6]=u-g,m[1]=l-v,m[4]=1-(h+f),m[7]=d+p,m[2]=u+g,m[5]=d-p,m[8]=1-(h+c),this},normalFromMat4:function(t){var e=t.val,i=this.val,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],x=n*h-s*a,w=n*l-r*a,T=n*u-o*a,b=s*l-r*h,_=s*u-o*h,S=r*u-o*l,A=c*v-d*g,C=c*m-f*g,M=c*y-p*g,E=d*m-f*v,P=d*y-p*v,L=f*y-p*m,F=x*L-w*P+T*E+b*M-_*C+S*A;return F?(F=1/F,i[0]=(h*L-l*P+u*E)*F,i[1]=(l*M-a*L-u*C)*F,i[2]=(a*P-h*M+u*A)*F,i[3]=(r*P-s*L-o*E)*F,i[4]=(n*L-r*M+o*C)*F,i[5]=(s*M-n*P-o*A)*F,i[6]=(v*S-m*_+y*b)*F,i[7]=(m*T-g*S-y*w)*F,i[8]=(g*_-v*T+y*x)*F,this):null}});t.exports=n},function(t,e){t.exports=function(t,e){var i=t.x,n=t.y;return t.x=i*Math.cos(e)-n*Math.sin(e),t.y=i*Math.sin(e)+n*Math.cos(e),t}},function(t,e){t.exports=function(t,e,i,n){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.ceil(t/e),n?(i+t)/e:i+t)}},function(t,e){t.exports=function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e}},function(t,e,i){var n=i(244);t.exports=function(t,e){return n(t)/n(e)/n(t-e)}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),te-i}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)=0?t:t+2*Math.PI}},function(t,e,i){var n=i(0),s=i(18),r=i(21),o=i(7),a=i(2),h=i(8),l=new n({Extends:r,initialize:function(t,e,i,n){var s="txt";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),n=a(o,"xhrSettings"),s=a(o,"extension",s)}var l={type:"text",cache:t.cacheManager.text,extension:s,responseType:"text",key:e,url:i,xhrSettings:n};r.call(this,t,l)},onProcess:function(){this.state=s.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()}});o.register("text",function(t,e,i){if(Array.isArray(t))for(var n=0;n=2&&(this.leftStick.set(r[0].getValue(),r[1].getValue()),s>=4&&this.rightStick.set(r[2].getValue(),r[3].getValue()))},destroy:function(){var t;for(this.removeAllListeners(),this.manager=null,this.pad=null,t=0;t=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",e,this,t),this.pad.emit("down",i,t,this)):this.pressed&&(this.pressed=!1,this.events.emit("up",e,this,t),this.pad.emit("up",i,t,this))},destroy:function(){this.pad=null,this.events=null}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.1},update:function(t){this.value=t},getValue:function(){return Math.abs(this.value)t.width*t.height)&&e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottom0){var d=(a*r+h*o)/l;u*=d,c*=d}return i.x=t.x1+u,i.y=t.y1+c,u*u+c*c<=l&&u*r+c*o>=0&&n(e,i.x,i.y)}},function(t,e,i){t.exports={CircleToCircle:i(703),CircleToRectangle:i(702),GetRectangleIntersection:i(701),LineToCircle:i(272),LineToLine:i(107),LineToRectangle:i(700),PointToLine:i(271),PointToLineSegment:i(699),RectangleToRectangle:i(148),RectangleToTriangle:i(698),RectangleToValues:i(697),TriangleToCircle:i(696),TriangleToLine:i(695),TriangleToTriangle:i(694)}},function(t,e,i){t.exports={Circle:i(723),Ellipse:i(713),Intersects:i(273),Line:i(693),Point:i(675),Polygon:i(661),Rectangle:i(265),Triangle:i(631)}},function(t,e,i){var n=i(0),s=i(276),r=i(10),o=new n({initialize:function(){this.lightPool=[],this.lights=[],this.culledLights=[],this.ambientColor={r:.1,g:.1,b:.1},this.active=!1,this.maxLights=-1},enable:function(){return-1===this.maxLights&&(this.maxLights=this.scene.sys.game.renderer.config.maxLights),this.active=!0,this},disable:function(){return this.active=!1,this},cull:function(t){var e=this.lights,i=this.culledLights,n=e.length,s=t.x+t.width/2,r=t.y+t.height/2,o=(t.width+t.height)/2,a={x:0,y:0},h=t.matrix,l=this.systems.game.config.height;i.length=0;for(var u=0;u0?(h=this.lightPool.pop()).set(t,e,i,a[0],a[1],a[2],o):h=new s(t,e,i,a[0],a[1],a[2],o),this.lights.push(h),h},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&(this.lightPool.push(t),this.lights.splice(e,1)),this},shutdown:function(){for(;this.lights.length>0;)this.lightPool.push(this.lights.pop());this.ambientColor={r:.1,g:.1,b:.1},this.culledLights.length=0,this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=o},function(t,e,i){var n=i(0),s=i(10),r=new n({initialize:function(t,e,i,n,s,r,o){this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1},set:function(t,e,i,n,s,r,o){return this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1,this},setScrollFactor:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this},setColor:function(t){var e=s.getFloatsFromUintRGB(t);return this.r=e[0],this.g=e[1],this.b=e[2],this},setIntensity:function(t){return this.intensity=t,this},setPosition:function(t,e){return this.x=t,this.y=e,this},setRadius:function(t){return this.radius=t,this}});t.exports=r},function(t,e,i){var n=i(65),s=i(6);t.exports=function(t,e,i,r){void 0===r&&(r=[]);var o=t.getLineA(),a=t.getLineB(),h=t.getLineC(),l=n(o),u=n(a),c=n(h),d=l+u+c;e||(e=d/i);for(var f=0;fl+u?(g=(p-=l+u)/c,v.x=h.x1+(h.x2-h.x1)*g,v.y=h.y1+(h.y2-h.y1)*g):(g=(p-=l)/u,v.x=a.x1+(a.x2-a.x1)*g,v.y=a.y1+(a.y2-a.y1)*g),r.push(v)}return r}},function(t,e,i){var n=i(6),s=i(65);t.exports=function(t,e,i){void 0===i&&(i=new n);var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=s(r),l=s(o),u=s(a),c=(h+l+u)*e,d=0;return ch+l?(d=(c-=h+l)/u,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/l,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},function(t,e,i){var n=i(0),s=i(27),r=i(59),o=i(772),a=new n({Extends:s,Mixins:[o],initialize:function(t,e,i,n,o,a,h,l,u,c,d){void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=128),void 0===a&&(a=64),void 0===h&&(h=0),void 0===l&&(l=128),void 0===u&&(u=128),s.call(this,t,"Triangle",new r(n,o,a,h,l,u));var f=this.geom.right-this.geom.left,p=this.geom.bottom-this.geom.top;this.setPosition(e,i),this.setSize(f,p),void 0!==c&&this.setFillStyle(c,d),this.updateDisplayOrigin(),this.updateData()},setTo:function(t,e,i,n,s,r){return this.geom.setTo(t,e,i,n,s,r),this.updateData()},updateData:function(){var t=[],e=this.geom,i=this._tempLine;return e.getLineA(i),t.push(i.x1,i.y1,i.x2,i.y2),e.getLineB(i),t.push(i.x2,i.y2),e.getLineC(i),t.push(i.x2,i.y2),this.pathData=t,this}});t.exports=a},function(t,e,i){var n=i(775),s=i(0),r=i(64),o=i(27),a=new s({Extends:o,Mixins:[n],initialize:function(t,e,i,n,s,r,a,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=5),void 0===s&&(s=32),void 0===r&&(r=64),o.call(this,t,"Star",null),this._points=n,this._innerRadius=s,this._outerRadius=r,this.setPosition(e,i),this.setSize(2*r,2*r),void 0!==a&&this.setFillStyle(a,h),this.updateDisplayOrigin(),this.updateData()},setPoints:function(t){return this._points=t,this.updateData()},setInnerRadius:function(t){return this._innerRadius=t,this.updateData()},setOuterRadius:function(t){return this._outerRadius=t,this.updateData()},points:{get:function(){return this._points},set:function(t){this._points=t,this.updateData()}},innerRadius:{get:function(){return this._innerRadius},set:function(t){this._innerRadius=t,this.updateData()}},outerRadius:{get:function(){return this._outerRadius},set:function(t){this._outerRadius=t,this.updateData()}},updateData:function(){var t=[],e=this._points,i=this._innerRadius,n=this._outerRadius,s=Math.PI/2*3,o=Math.PI/e,a=n,h=n;t.push(a,h+-n);for(var l=0;l0&&r.push(i([0,0],n[0])),e=0;e1&&r.push(i([0,0],n[n.length-1])),t.setTo(r)}},function(t,e,i){var n=i(65),s=i(54);t.exports=function(t){for(var e=t.points,i=0,r=0;rc+v)){var m=g.getPoint((u-c)/v);o.push(m);break}c+=v}return o}},function(t,e,i){var n=i(9);t.exports=function(t,e){void 0===e&&(e=new n);for(var i,s=1/0,r=1/0,o=-s,a=-r,h=0;h0&&(s=-h.PI2+s%h.PI2):s>h.PI2?s=h.PI2:s<0&&(s=h.PI2+s%h.PI2);for(var u,c=[a+Math.cos(n)*i,l+Math.sin(n)*i];e<1;)u=s*e+n,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),e+=t;return u=s+n,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),c.push(a+Math.cos(n)*i,l+Math.sin(n)*i),this.pathIndexes=o(c),this.pathData=c,this}});t.exports=u},function(t,e){t.exports=function(t){var e=Math.log(t)/.6931471805599453;return 1<this._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=this.source.contains(t.x,t.y);return e&&this.killOnEnter||!e&&!this.killOnEnter}});t.exports=n},function(t,e,i){var n=i(66),s=i(0),r=i(14),o=i(301),a=i(300),h=i(822),l=i(2),u=i(162),c=i(298),d=i(85),f=i(303),p=i(297),g=i(9),v=i(110),m=i(3),y=i(53),x=new s({Mixins:[r.BlendMode,r.Mask,r.ScrollFactor,r.Visible],initialize:function(t,e){this.manager=t,this.texture=t.texture,this.frames=[t.defaultFrame],this.defaultFrame=t.defaultFrame,this.configFastMap=["active","blendMode","collideBottom","collideLeft","collideRight","collideTop","deathCallback","deathCallbackScope","emitCallback","emitCallbackScope","follow","frequency","gravityX","gravityY","maxParticles","name","on","particleBringToTop","particleClass","radial","timeScale","trackVisible","visible"],this.configOpMap=["accelerationX","accelerationY","angle","alpha","bounce","delay","lifespan","maxVelocityX","maxVelocityY","moveToX","moveToY","quantity","rotate","scaleX","scaleY","speedX","speedY","tint","x","y"],this.name="",this.particleClass=f,this.x=new h(e,"x",0),this.y=new h(e,"y",0),this.radial=!0,this.gravityX=0,this.gravityY=0,this.acceleration=!1,this.accelerationX=new h(e,"accelerationX",0,!0),this.accelerationY=new h(e,"accelerationY",0,!0),this.maxVelocityX=new h(e,"maxVelocityX",1e4,!0),this.maxVelocityY=new h(e,"maxVelocityY",1e4,!0),this.speedX=new h(e,"speedX",0,!0),this.speedY=new h(e,"speedY",0,!0),this.moveTo=!1,this.moveToX=new h(e,"moveToX",0,!0),this.moveToY=new h(e,"moveToY",0,!0),this.bounce=new h(e,"bounce",0,!0),this.scaleX=new h(e,"scaleX",1),this.scaleY=new h(e,"scaleY",1),this.tint=new h(e,"tint",4294967295),this.alpha=new h(e,"alpha",1),this.lifespan=new h(e,"lifespan",1e3),this.angle=new h(e,"angle",{min:0,max:360}),this.rotate=new h(e,"rotate",0),this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.maxParticles=0,this.quantity=new h(e,"quantity",1,!0),this.delay=new h(e,"delay",0,!0),this.frequency=0,this.on=!0,this.particleBringToTop=!0,this.timeScale=1,this.emitZone=null,this.deathZone=null,this.bounds=null,this.collideLeft=!0,this.collideRight=!0,this.collideTop=!0,this.collideBottom=!0,this.active=!0,this.visible=!0,this.blendMode=n.NORMAL,this.follow=null,this.followOffset=new m,this.trackVisible=!1,this.currentFrame=0,this.randomFrame=!0,this.frameQuantity=1,this.dead=[],this.alive=[],this._counter=0,this._frameCounter=0,e&&this.fromJSON(e)},fromJSON:function(t){if(!t)return this;var e=0,i="";for(e=0;e0&&this.getParticleCount()===this.maxParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,n=i.length,s=0;s0?n.pop():new this.particleClass(this)).fire(e,i),this.particleBringToTop?this.alive.push(r):this.alive.unshift(r),this.emitCallback&&this.emitCallback.call(this.emitCallbackScope,r,this),this.atLimit())break}return r}},preUpdate:function(t,e){var i=(e*=this.timeScale)/1e3;this.trackVisible&&(this.visible=this.follow.visible);for(var n=this.manager.getProcessors(),s=this.alive,r=s.length,o=0;o0){var u=s.splice(s.length-l,l),c=this.deathCallback,d=this.deathCallbackScope;if(c)for(var f=0;f0&&(this._counter-=e,this._counter<=0&&(this.emitParticle(),this._counter=this.frequency-Math.abs(this._counter))))},depthSortCallback:function(t,e){return t.y-e.y},indexSortCallback:function(t,e){return t.index-e.index}});t.exports=x},function(t,e,i){var n=i(0),s=i(31),r=i(52),o=new n({initialize:function(t){this.emitter=t,this.frame=null,this.index=0,this.x=0,this.y=0,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.tint=16777215,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215,current:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1}}},isAlive:function(){return this.lifeCurrent>0},fire:function(t,e){var i=this.emitter;this.frame=i.getFrame(),i.emitZone&&i.emitZone.getPoint(this),void 0===t?(i.follow&&(this.x+=i.follow.x+i.followOffset.x),this.x+=i.x.onEmit(this,"x")):this.x+=t,void 0===e?(i.follow&&(this.y+=i.follow.y+i.followOffset.y),this.y+=i.y.onEmit(this,"y")):this.y+=e,this.life=i.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0;var n=i.speedX.onEmit(this,"speedX"),o=i.speedY?i.speedY.onEmit(this,"speedY"):n;if(i.radial){var a=s(i.angle.onEmit(this,"angle"));this.velocityX=Math.cos(a)*Math.abs(n),this.velocityY=Math.sin(a)*Math.abs(o)}else if(i.moveTo){var h=i.moveToX.onEmit(this,"moveToX"),l=i.moveToY?i.moveToY.onEmit(this,"moveToY"):h,u=Math.atan2(l-this.y,h-this.x),c=r(this.x,this.y,h,l)/(this.life/1e3);this.velocityX=Math.cos(u)*c,this.velocityY=Math.sin(u)*c}else this.velocityX=n,this.velocityY=o;i.acceleration&&(this.accelerationX=i.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=i.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=i.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=i.maxVelocityY.onEmit(this,"maxVelocityY"),this.delayCurrent=i.delay.onEmit(this,"delay"),this.scaleX=i.scaleX.onEmit(this,"scaleX"),this.scaleY=i.scaleY?i.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=i.rotate.onEmit(this,"rotate"),this.rotation=s(this.angle),this.bounce=i.bounce.onEmit(this,"bounce"),this.alpha=i.alpha.onEmit(this,"alpha"),this.tint=i.tint.onEmit(this,"tint"),this.index=i.alive.length},computeVelocity:function(t,e,i,n){var s=this.velocityX,r=this.velocityY,o=this.accelerationX,a=this.accelerationY,h=this.maxVelocityX,l=this.maxVelocityY;s+=t.gravityX*i,r+=t.gravityY*i,o&&(s+=o*i),a&&(r+=a*i),s>h?s=h:s<-h&&(s=-h),r>l?r=l:r<-l&&(r=-l),this.velocityX=s,this.velocityY=r;for(var u=0;ue.right&&t.collideRight&&(this.x=e.right,this.velocityX*=i),this.ye.bottom&&t.collideBottom&&(this.y=e.bottom,this.velocityY*=i)},update:function(t,e,i){if(this.delayCurrent>0)return this.delayCurrent-=t,!1;var n=this.emitter,r=1-this.lifeCurrent/this.life;return this.lifeT=r,this.computeVelocity(n,t,e,i),this.x+=this.velocityX*e,this.y+=this.velocityY*e,n.bounds&&this.checkBounds(n),n.deathZone&&n.deathZone.willKill(this)?(this.lifeCurrent=0,!0):(this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),n.scaleY?this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY):this.scaleY=this.scaleX,this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=s(this.angle),this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),this.tint=n.tint.onUpdate(this,"tint",r,this.tint),this.lifeCurrent-=t,this.lifeCurrent<=0)}});t.exports=o},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t,e,i,n,r){if("object"==typeof t){var o=t;t=s(o,"x",0),e=s(o,"y",0),i=s(o,"power",0),n=s(o,"epsilon",100),r=s(o,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=50);this.x=t,this.y=e,this.active=!0,this._gravity=r,this._power=0,this._epsilon=0,this.power=i,this.epsilon=n},update:function(t,e){var i=this.x-t.x,n=this.y-t.y,s=i*i+n*n;if(0!==s){var r=Math.sqrt(s);s>>16,y=(65280&p)>>>8,x=255&p,c.strokeStyle="rgba("+m+","+y+","+x+","+d+")",c.lineWidth=v,w+=3;break;case n.FILL_STYLE:g=l[w+1],f=l[w+2],m=(16711680&g)>>>16,y=(65280&g)>>>8,x=255&g,c.fillStyle="rgba("+m+","+y+","+x+","+f+")",w+=2;break;case n.BEGIN_PATH:c.beginPath();break;case n.CLOSE_PATH:c.closePath();break;case n.FILL_PATH:h||c.fill();break;case n.STROKE_PATH:h||c.stroke();break;case n.FILL_RECT:h?c.rect(l[w+1],l[w+2],l[w+3],l[w+4]):c.fillRect(l[w+1],l[w+2],l[w+3],l[w+4]),w+=4;break;case n.FILL_TRIANGLE:c.beginPath(),c.moveTo(l[w+1],l[w+2]),c.lineTo(l[w+3],l[w+4]),c.lineTo(l[w+5],l[w+6]),c.closePath(),h||c.fill(),w+=6;break;case n.STROKE_TRIANGLE:c.beginPath(),c.moveTo(l[w+1],l[w+2]),c.lineTo(l[w+3],l[w+4]),c.lineTo(l[w+5],l[w+6]),c.closePath(),h||c.stroke(),w+=6;break;case n.LINE_TO:c.lineTo(l[w+1],l[w+2]),w+=2;break;case n.MOVE_TO:c.moveTo(l[w+1],l[w+2]),w+=2;break;case n.LINE_FX_TO:c.lineTo(l[w+1],l[w+2]),w+=5;break;case n.MOVE_FX_TO:c.moveTo(l[w+1],l[w+2]),w+=5;break;case n.SAVE:c.save();break;case n.RESTORE:c.restore();break;case n.TRANSLATE:c.translate(l[w+1],l[w+2]),w+=2;break;case n.SCALE:c.scale(l[w+1],l[w+2]),w+=2;break;case n.ROTATE:c.rotate(l[w+1]),w+=1;break;case n.GRADIENT_FILL_STYLE:w+=5;break;case n.GRADIENT_LINE_STYLE:w+=6;break;case n.SET_TEXTURE:w+=2}c.restore()}}},function(t,e){t.exports=function(t){var e=t.width/2,i=t.height/2,n=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*n/(10+Math.sqrt(4-3*n)))}},function(t,e,i){var n=i(306),s=i(156),r=i(93),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;h0?s.delayedPlay(d,r,o):s.load(r)}return t}},function(t,e,i){var n=i(4),s=i(122),r=function(t,e,i){for(var n=[],s=0;sr;){if(o-r>600){var h=o-r+1,l=e-r+1,u=Math.log(h),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(h-c)/h)*(l-h/2<0?-1:1),f=Math.max(r,Math.floor(e-l*c/h+d)),p=Math.min(o,Math.floor(e+(h-l)*c/h+d));i(t,e,f,p,a)}var g=t[e],v=r,m=o;for(n(t,r,e),a(t[o],g)>0&&n(t,r,o);v0;)m--}0===a(t[r],g)?n(t,r,m):n(t,++m,o),m<=e&&(r=m+1),e<=m&&(o=m-1)}};function n(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function s(t,e){return te?1:0}t.exports=i},function(t,e){t.exports=function(t){return t>0?Math.ceil(t):Math.floor(t)}},function(t,e){t.exports=function(t){for(var e=t.length,i=t[0].length,n=new Array(i),s=0;s-1;r--)n[s][r]=t[r][s]}return n}},function(t,e,i){t.exports={AtlasXML:i(886),Canvas:i(885),Image:i(884),JSONArray:i(883),JSONHash:i(882),SpriteSheet:i(881),SpriteSheetFromAtlas:i(880),UnityYAML:i(879)}},function(t,e,i){var n=i(24),s=i(0),r=i(117),o=i(94),a=new s({initialize:function(t,e,i,n){var s=t.manager.game;this.renderer=s.renderer,this.texture=t,this.source=e,this.image=e,this.compressionAlgorithm=null,this.resolution=1,this.width=i||e.naturalWidth||e.width||0,this.height=n||e.naturalHeight||e.height||0,this.scaleMode=o.DEFAULT,this.isCanvas=e instanceof HTMLCanvasElement,this.isRenderTexture="RenderTexture"===e.type,this.isPowerOf2=r(this.width,this.height),this.glTexture=null,this.init(s)},init:function(t){this.renderer&&(this.renderer.gl?this.isCanvas?this.glTexture=this.renderer.canvasToTexture(this.image):this.isRenderTexture?(this.image=this.source.canvas,this.glTexture=this.renderer.createTextureFromSource(null,this.width,this.height,this.scaleMode)):this.glTexture=this.renderer.createTextureFromSource(this.image,this.width,this.height,this.scaleMode):this.isRenderTexture&&(this.image=this.source.canvas)),t.config.antialias||this.setFilter(1)},setFilter:function(t){this.renderer.gl&&this.renderer.setTextureFilter(this.glTexture,t)},update:function(){this.renderer.gl&&this.isCanvas&&(this.glTexture=this.renderer.canvasToTexture(this.image,this.glTexture))},destroy:function(){this.glTexture&&this.renderer.deleteTexture(this.glTexture),this.isCanvas&&n.remove(this.image),this.renderer=null,this.texture=null,this.source=null,this.image=null,this.glTexture=null}});t.exports=a},function(t,e,i){var n=i(24),s=i(887),r=i(0),o=i(37),a=i(26),h=i(11),l=i(357),u=i(4),c=i(316),d=i(165),f=new r({Extends:h,initialize:function(t){h.call(this),this.game=t,this.name="TextureManager",this.list={},this._tempCanvas=n.create2D(this,1,1),this._tempContext=this._tempCanvas.getContext("2d"),this._pending=0,t.events.once("boot",this.boot,this)},boot:function(){this._pending=2,this.on("onload",this.updatePending,this),this.on("onerror",this.updatePending,this),this.addBase64("__DEFAULT",this.game.config.defaultImage),this.addBase64("__MISSING",this.game.config.missingImage),this.game.events.once("destroy",this.destroy,this)},updatePending:function(){this._pending--,0===this._pending&&(this.off("onload"),this.off("onerror"),this.game.events.emit("texturesready"))},checkKey:function(t){return!this.exists(t)||(console.error("Texture key already in use: "+t),!1)},remove:function(t){if("string"==typeof t){if(!this.exists(t))return console.warn("No texture found matching key: "+t),this;t=this.get(t)}return this.list.hasOwnProperty(t.key)&&(delete this.list[t.key],t.destroy(),this.emit("removetexture",t.key)),this},addBase64:function(t,e){if(this.checkKey(t)){var i=this,n=new Image;n.onerror=function(){i.emit("onerror",t)},n.onload=function(){var e=i.create(t,n);c.Image(e,0),i.emit("addtexture",t,e),i.emit("onload",t,e)},n.src=e}return this},getBase64:function(t,e,i,s){void 0===i&&(i="image/png"),void 0===s&&(s=.92);var r="",o=this.getFrame(t,e);if(o){var a=o.canvasData,h=n.create2D(this,a.width,a.height);h.getContext("2d").drawImage(o.source.image,a.x,a.y,a.width,a.height,0,0,a.width,a.height),r=h.toDataURL(i,s),n.remove(h)}return r},addImage:function(t,e,i){var n=null;return this.checkKey(t)&&(n=this.create(t,e),c.Image(n,0),i&&n.setDataSource(i),this.emit("addtexture",t,n)),n},addRenderTexture:function(t,e){var i=null;return this.checkKey(t)&&((i=this.create(t,e)).add("__BASE",0,0,0,e.width,e.height),this.emit("addtexture",t,i)),i},generate:function(t,e){if(this.checkKey(t)){var i=n.create(this,1,1);return e.canvas=i,l(e),this.addCanvas(t,i)}return null},createCanvas:function(t,e,i){if(void 0===e&&(e=256),void 0===i&&(i=256),this.checkKey(t)){var s=n.create(this,e,i,a.CANVAS,!0);return this.addCanvas(t,s)}return null},addCanvas:function(t,e,i){void 0===i&&(i=!1);var n=null;return i?n=new s(this,t,e,e.width,e.height):this.checkKey(t)&&(n=new s(this,t,e,e.width,e.height),this.list[t]=n,this.emit("addtexture",t,n)),n},addAtlas:function(t,e,i,n){return Array.isArray(i.textures)||Array.isArray(i.frames)?this.addAtlasJSONArray(t,e,i,n):this.addAtlasJSONHash(t,e,i,n)},addAtlasJSONArray:function(t,e,i,n){var s=null;if(this.checkKey(t)){if(s=this.create(t,e),Array.isArray(i))for(var r=1===i.length,o=0;o=r.x&&t=r.y&&e=r.x&&t=r.y&&e0)&&(!!n.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!n.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!n.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=n-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,s-n),s=this.audio.currentTime):s=n)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=s}},destroy:function(){n.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},updateMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},updateVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},calculateRate:function(){n.prototype.calculateRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)},mute:{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||this.emit("mute",this,t)}},setMute:function(t){return this.mute=t,this},volume:{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||this.emit("volume",this,t)}},setVolume:function(t){return this.volume=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||(this.calculateRate(),this.emit("rate",this,t))}},setRate:function(t){return this.rate=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||(this.calculateRate(),this.emit("detune",this,t))}},setDetune:function(t){return this.detune=t,this},seek:{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}},setSeek:function(t){return this.seek=t,this},loop:{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}},setLoop:function(t){return this.loop=t,this}});t.exports=s},function(t,e,i){var n=i(115),s=i(0),r=i(323),o=new s({Extends:n,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,n.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){this.locked=!1;var t=this;if(this.game.cache.audio.entries.each(function(e,i){for(var n=0;n-1&&(delete this.keys[n],this.scenes.splice(i,1),this._start.indexOf(n)>-1&&(i=this._start.indexOf(n),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e,i=t.sys,n=i.settings;t.init&&(t.init.call(t,n.data),n.status=s.INIT,n.isTransition&&i.events.emit("transitioninit",n.transitionFrom,n.transitionDuration)),i.load&&(e=i.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(n.status=s.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.game.sound.onBlurPausedSounds&&this.game.sound.unlock(),this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this.isProcessing=!0;for(var i=this.scenes.length-1;i>=0;i--){var n=this.scenes[i].sys;n.settings.status>s.START&&n.settings.status<=s.RUNNING&&n.step(t,e)}},resize:function(t,e){for(var i=0;i=s.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this.isProcessing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,n=this.getScene(t),s=this.getAt(i);this.scenes[e]=s,this.scenes[i]=n}}return this},moveUp:function(t){if(this.isProcessing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e=0;){var a=e[o];-1!==(r=t.indexOf(a))?(n(t,r),i&&i.call(s,a)):e.pop(),o--}return e}},function(t,e,i){var n=i(0),s=i(11),r=i(7),o=i(13),a=i(5),h=i(2),l=i(15),u=i(330),c=new n({Extends:s,initialize:function(t){s.call(this),this.game=t,this.plugins=[],this.scenePlugins=[],this._pendingGlobal=[],this._pendingScene=[],t.isBooted?this.boot():t.events.once("boot",this.boot,this)},boot:function(){var t,e,i,n,s,r,o,a=this.game.config,l=a.installGlobalPlugins;for(l=l.concat(this._pendingGlobal),t=0;t10&&(t=10-this.pointersTotal);for(var i=0;i0},queueTouchStart:function(t){if(this.queue.push(s.TOUCH_START,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueTouchMove:function(t){if(this.queue.push(s.TOUCH_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueTouchEnd:function(t){if(this.queue.push(s.TOUCH_END,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},queueTouchCancel:function(t){this.queue.push(s.TOUCH_CANCEL,t)},queueMouseDown:function(t){if(this.queue.push(s.MOUSE_DOWN,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueMouseMove:function(t){if(this.queue.push(s.MOUSE_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueMouseUp:function(t){if(this.queue.push(s.MOUSE_UP,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},addUpCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.upOnce.push(t):this.domCallbacks.up.push(t),this._hasUpCallback=!0,this},addDownCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.downOnce.push(t):this.domCallbacks.down.push(t),this._hasDownCallback=!0,this},addMoveCallback:function(t,e){return void 0===e&&(e=!1),e?this.domCallbacks.moveOnce.push(t):this.domCallbacks.move.push(t),this._hasMoveCallback=!0,this},inputCandidate:function(t,e){var i=t.input;if(!i||!i.enabled||!t.willRender(e))return!1;var n=!0,s=t.parentContainer;if(s)do{if(!s.willRender(e)){n=!1;break}s=s.parentContainer}while(s);return n},hitTest:function(t,e,i,n){void 0===n&&(n=this._tempHitTest);var s=this._tempPoint,r=i.scrollX,o=i.scrollY;n.length=0;var a=t.x,h=t.y;1!==i.resolution&&(a+=i._x,h+=i._y),i.getWorldPoint(a,h,s),t.worldX=s.x,t.worldY=s.y;for(var l={x:0,y:0},u=this._tempMatrix,d=this._tempMatrix2,f=0;f1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}},function(t,e){t.exports=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},function(t,e,i){var n=i(37);n.ColorToRGBA=i(915),n.ComponentToHex=i(346),n.GetColor=i(177),n.GetColor32=i(376),n.HexStringToColor=i(377),n.HSLToColor=i(914),n.HSVColorWheel=i(913),n.HSVToRGB=i(176),n.HueToComponent=i(345),n.IntegerToColor=i(374),n.IntegerToRGB=i(373),n.Interpolate=i(912),n.ObjectToColor=i(372),n.RandomRGB=i(911),n.RGBStringToColor=i(371),n.RGBToHSV=i(375),n.RGBToString=i(910),n.ValueToColor=i(178),t.exports=n},function(t,e){t.exports={setCrisp:function(t){return["optimizeSpeed","crisp-edges","-moz-crisp-edges","-webkit-optimize-contrast","optimize-contrast","pixelated"].forEach(function(e){t.style["image-rendering"]=e}),t.style.msInterpolationMode="nearest-neighbor",t},setBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}}},function(t,e,i){var n=i(171),s=i(0),r=i(70),o=i(3),a=new s({Extends:r,initialize:function(t){void 0===t&&(t=[]),r.call(this,"SplineCurve"),this.points=[],this.addPoints(t)},addPoints:function(t){for(var e=0;ei.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(n(a,h.x,l.x,u.x,c.x),n(a,h.y,l.y,u.y,c.y))},toJSON:function(){for(var t=[],e=0;ei;)n-=i;n16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var n=i(37),s=i(373);t.exports=function(t){var e=s(t);return new n(e.r,e.g,e.b,e.a)}},function(t,e){t.exports=function(t,e,i,n){void 0===n&&(n={h:0,s:0,v:0}),t/=255,e/=255,i/=255;var s=Math.min(t,e,i),r=Math.max(t,e,i),o=r-s,a=0,h=0===r?0:o/r,l=r;return r!==s&&(r===t?a=(e-i)/o+(ef.right&&(p=u(p,p+(v-f.right),this.lerp.x)),mf.bottom&&(g=u(g,g+(m-f.bottom),this.lerp.y))):(p=u(p,v-l,this.lerp.x),g=u(g,m-c,this.lerp.y))}this.useBounds&&(p=this.clampX(p),g=this.clampY(g)),this.roundPixels&&(l=Math.round(l),c=Math.round(c)),this.scrollX=p,this.scrollY=g;var y=p+s,x=g+o;this.midPoint.set(y,x);var w=i/a,T=n/a;this.worldView.setTo(y-w/2,x-T/2,w,T),h.loadIdentity(),h.scale(e,e),h.translate(this.x+l,this.y+c),h.rotate(this.rotation),h.scale(a,a),h.translate(-l,-c),this.shakeEffect.preRender()},setLerp:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.lerp.set(t,e),this},setFollowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.followOffset.set(t,e),this},startFollow:function(t,e,i,n,s,r){void 0===e&&(e=!1),void 0===i&&(i=1),void 0===n&&(n=i),void 0===s&&(s=0),void 0===r&&(r=s),this._follow=t,this.roundPixels=e,i=o(i,0,1),n=o(n,0,1),this.lerp.set(i,n),this.followOffset.set(s,r);var a=this.width/2,h=this.height/2,l=t.x-s,u=t.y-r;return this.midPoint.set(l,u),this.scrollX=l-a,this.scrollY=u-h,this},stopFollow:function(){return this._follow=null,this},resetFX:function(){return this.panEffect.reset(),this.shakeEffect.reset(),this.flashEffect.reset(),this.fadeEffect.reset(),this},update:function(t,e){this.visible&&(this.panEffect.update(t,e),this.zoomEffect.update(t,e),this.shakeEffect.update(t,e),this.flashEffect.update(t,e),this.fadeEffect.update(t,e))},destroy:function(){this.clearRenderToTexture(),this.resetFX(),n.prototype.destroy.call(this),this._follow=null,this.deadzone=null}});t.exports=f},function(t,e,i){var n=i(380),s=new(i(0))({initialize:function(t){this.game=t,this.binary=new n,this.bitmapFont=new n,this.json=new n,this.physics=new n,this.shader=new n,this.audio=new n,this.text=new n,this.html=new n,this.obj=new n,this.tilemap=new n,this.xml=new n,this.custom={},this.game.events.once("destroy",this.destroy,this)},addCustom:function(t){return this.custom.hasOwnProperty(t)||(this.custom[t]=new n),this.custom[t]},destroy:function(){for(var t=["binary","bitmapFont","json","physics","shader","audio","text","html","obj","tilemap","xml"],e=0;ee.length&&(r=e.length),i?(n=e[r-1][i],(s=e[r][i])-t<=t-n?e[r]:e[r-1]):(n=e[r-1],(s=e[r])-t<=t-n?s:n)}},function(t,e,i){var n=i(23),s=i(0),r=i(383),o=i(382),a=i(4),h=new s({initialize:function(t,e,i){this.manager=t,this.key=e,this.type="frame",this.frames=this.getFrames(t.textureManager,a(i,"frames",[]),a(i,"defaultTextureKey",null)),this.frameRate=a(i,"frameRate",null),this.duration=a(i,"duration",null),null===this.duration&&null===this.frameRate?(this.frameRate=24,this.duration=this.frameRate/this.frames.length*1e3):this.duration&&null===this.frameRate?this.frameRate=this.frames.length/(this.duration/1e3):this.duration=this.frames.length/this.frameRate*1e3,this.msPerFrame=1e3/this.frameRate,this.skipMissedFrames=a(i,"skipMissedFrames",!0),this.delay=a(i,"delay",0),this.repeat=a(i,"repeat",0),this.repeatDelay=a(i,"repeatDelay",0),this.yoyo=a(i,"yoyo",!1),this.showOnStart=a(i,"showOnStart",!1),this.hideOnComplete=a(i,"hideOnComplete",!1),this.paused=!1,this.manager.on("pauseall",this.pause,this),this.manager.on("resumeall",this.resume,this)},addFrame:function(t){return this.addFrameAt(this.frames.length,t)},addFrameAt:function(t,e){var i=this.getFrames(this.manager.textureManager,e);if(i.length>0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var n=this.frames.slice(0,t),s=this.frames.slice(t);this.frames=n.concat(i,s)}this.updateFrameSequence()}return this},checkFrame:function(t){return t>=0&&t0){s.isLast=!0,s.nextFrame=l[0],l[0].prevFrame=s;var v=1/(l.length-1);for(r=0;r=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo);var i=this.frames[e];0!==e||t.forward||(i=this.getLastFrame()),t.updateFrame(i)},getFrameByProgress:function(t){return t=n(t,0,1),r(t,this.frames,"progress")},nextFrame:function(t){var e=t.currentFrame;e.isLast?t._yoyo?this.handleYoyoFrame(t,!1):t.repeatCounter>0?t._reverse&&t.forward?t.forward=!1:this.repeatAnimation(t):this.completeAnimation(t):this.updateAndGetNextTick(t,e.nextFrame)},handleYoyoFrame:function(t,e){if(e||(e=!1),t._reverse===!e&&t.repeatCounter>0)return t.forward=e,void this.repeatAnimation(t);if(t._reverse===e||0!==t.repeatCounter){t.forward=e;var i=e?t.currentFrame.nextFrame:t.currentFrame.prevFrame;this.updateAndGetNextTick(t,i)}else this.completeAnimation(t)},getLastFrame:function(){return this.frames[this.frames.length-1]},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t._yoyo?this.handleYoyoFrame(t,!0):t.repeatCounter>0?t._reverse&&!t.forward?(t.currentFrame=this.getLastFrame(),this.repeatAnimation(t)):(t.forward=!0,this.repeatAnimation(t)):this.completeAnimation(t):this.updateAndGetNextTick(t,e.prevFrame)},updateAndGetNextTick:function(t,e){t.updateFrame(e),this.getNextTick(t)},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){if(2===t._pendingStop)return this.completeAnimation(t);t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=t._repeatDelay):(t.repeatCounter--,t.updateFrame(t.currentFrame[t.forward?"nextFrame":"prevFrame"]),t.isPlaying&&(this.getNextTick(t),t.pendingRepeat=!1,t.parent.emit("animationrepeat",this,t.currentFrame,t.repeatCounter,t.parent)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(n.prevFrame=this.frames[i-1],n.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){this.manager.off("pauseall",this.pause,this),this.manager.off("resumeall",this.resume,this),this.manager.remove(this.key);for(var t=0;t-h&&(c-=h,n+=l),f=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},function(t,e){var i={_visible:!0,visible:{get:function(){return this._visible},set:function(t){t?(this._visible=!0,this.renderFlags|=1):(this._visible=!1,this.renderFlags&=-2)}},setVisible:function(t){return this.visible=t,this}};t.exports=i},function(t,e,i){var n=i(16),s=i(38),r=i(199),o=i(198),a={_scaleX:1,_scaleY:1,_rotation:0,x:0,y:0,z:0,w:0,scaleX:{get:function(){return this._scaleX},set:function(t){this._scaleX=t,0===this._scaleX?this.renderFlags&=-5:this.renderFlags|=4}},scaleY:{get:function(){return this._scaleY},set:function(t){this._scaleY=t,0===this._scaleY?this.renderFlags&=-5:this.renderFlags|=4}},angle:{get:function(){return o(this._rotation*n.RAD_TO_DEG)},set:function(t){this.rotation=o(t)*n.DEG_TO_RAD}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=r(t)}},setPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=i,this.w=n,this},setRandomPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),this.x=t+Math.random()*i,this.y=e+Math.random()*n,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,this},setScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this},setX:function(t){return void 0===t&&(t=0),this.x=t,this},setY:function(t){return void 0===t&&(t=0),this.y=t,this},setZ:function(t){return void 0===t&&(t=0),this.z=t,this},setW:function(t){return void 0===t&&(t=0),this.w=t,this},getLocalTransformMatrix:function(t){return void 0===t&&(t=new s),t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY)},getWorldTransformMatrix:function(t,e){void 0===t&&(t=new s),void 0===e&&(e=new s);var i=this.parentContainer;if(!i)return this.getLocalTransformMatrix(t);for(t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY);i;)e.applyITRS(i.x,i.y,i._rotation,i._scaleX,i._scaleY),e.multiply(t,t),i=i.parentContainer;return t}};t.exports=a},function(t,e){t.exports=function(t){var e={name:t.name,type:t.type,x:t.x,y:t.y,depth:t.depth,scale:{x:t.scaleX,y:t.scaleY},origin:{x:t.originX,y:t.originY},flipX:t.flipX,flipY:t.flipY,rotation:t.rotation,alpha:t.alpha,visible:t.visible,scaleMode:t.scaleMode,blendMode:t.blendMode,textureKey:"",frameKey:"",data:{}};return t.texture&&(e.textureKey=t.texture.key,e.frameKey=t.frame.name),e}},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.geometryMask=e},setShape:function(t){this.geometryMask=t},preRenderWebGL:function(t,e,i){var n=t.gl,s=this.geometryMask;t.flush(),n.enable(n.STENCIL_TEST),n.clear(n.STENCIL_BUFFER_BIT),n.colorMask(!1,!1,!1,!1),n.stencilFunc(n.NOTEQUAL,1,1),n.stencilOp(n.REPLACE,n.REPLACE,n.REPLACE),s.renderWebGL(t,s,0,i),t.flush(),n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.EQUAL,1,1),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)},postRenderWebGL:function(t){var e=t.gl;t.flush(),e.disable(e.STENCIL_TEST)},preRenderCanvas:function(t,e,i){var n=this.geometryMask;t.currentContext.save(),n.renderCanvas(t,n,0,i,null,null,!0),t.currentContext.clip()},postRenderCanvas:function(t){t.currentContext.restore()},destroy:function(){this.geometryMask=null}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){var i=t.sys.game.renderer;if(this.renderer=i,this.bitmapMask=e,this.maskTexture=null,this.mainTexture=null,this.dirty=!0,this.mainFramebuffer=null,this.maskFramebuffer=null,this.invertAlpha=!1,i&&i.gl){var n=i.width,s=i.height,r=0==(n&n-1)&&0==(s&s-1),o=i.gl,a=r?o.REPEAT:o.CLAMP_TO_EDGE,h=o.LINEAR;this.mainTexture=i.createTexture2D(0,h,h,a,a,o.RGBA,null,n,s),this.maskTexture=i.createTexture2D(0,h,h,a,a,o.RGBA,null,n,s),this.mainFramebuffer=i.createFramebuffer(n,s,this.mainTexture,!1),this.maskFramebuffer=i.createFramebuffer(n,s,this.maskTexture,!1),i.onContextRestored(function(t){var e=t.width,i=t.height,n=0==(e&e-1)&&0==(i&i-1),s=t.gl,r=n?s.REPEAT:s.CLAMP_TO_EDGE,o=s.LINEAR;this.mainTexture=t.createTexture2D(0,o,o,r,r,s.RGBA,null,e,i),this.maskTexture=t.createTexture2D(0,o,o,r,r,s.RGBA,null,e,i),this.mainFramebuffer=t.createFramebuffer(e,i,this.mainTexture,!1),this.maskFramebuffer=t.createFramebuffer(e,i,this.maskTexture,!1)},this)}},setBitmap:function(t){this.bitmapMask=t},preRenderWebGL:function(t,e,i){t.pipelines.BitmapMaskPipeline.beginMask(this,e,i)},postRenderWebGL:function(t){t.pipelines.BitmapMaskPipeline.endMask(this)},preRenderCanvas:function(){},postRenderCanvas:function(){},destroy:function(){this.bitmapMask=null;var t=this.renderer;t&&t.gl&&(t.deleteTexture(this.mainTexture),t.deleteTexture(this.maskTexture),t.deleteFramebuffer(this.mainFramebuffer),t.deleteFramebuffer(this.maskFramebuffer)),this.mainTexture=null,this.maskTexture=null,this.mainFramebuffer=null,this.maskFramebuffer=null,this.renderer=null}});t.exports=n},function(t,e,i){var n=i(394),s=i(393),r={mask:null,setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this},createBitmapMask:function(t){return void 0===t&&this.texture&&(t=this),new n(this.scene,t)},createGeometryMask:function(t){return void 0===t&&"Graphics"===this.type&&(t=this),new s(this.scene,t)}};t.exports=r},function(t,e){t.exports=function(t,e,i,n){var s=Math.cos(n),r=Math.sin(n),o=t.x-e,a=t.y-i;return t.x=o*s-a*r+e,t.y=o*r+a*s+i,t}},function(t,e,i){var n=i(6);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x1+(t.x2-t.x1)*e,i.y=t.y1+(t.y2-t.y1)*e,i}},function(t,e,i){var n=i(190),s=i(124);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=s(t)/i);for(var o=0;o=-1&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,e,i){var n=i(23),s={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,s){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=n(t,0,1),this._alphaTR=n(e,0,1),this._alphaBL=n(i,0,1),this._alphaBR=n(s,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=n(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=n(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=n(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=n(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=n(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=s},function(t,e){t.exports=function(t){return Math.PI*t.radius*2}},function(t,e,i){var n=i(402),s=i(192),r=i(93),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;h>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e0;i--){var n=Math.floor(this.frac()*(e+1)),s=t[n];t[n]=t[i],t[i]=s}return t}});t.exports=n},function(t,e,i){var n=i(192),s=i(93),r=i(16),o=i(6);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=s(e,0,r.PI2);return n(t,a,i)}},function(t,e,i){var n=i(44),s=i(42),r=i(43),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(46),s=i(42),r=i(45),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(75),s=i(42),r=i(74),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(72),s=i(44),r=i(73),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(72),s=i(46),r=i(73),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(74),s=i(73);t.exports=function(t,e,i){return n(t,e),s(t,i)}},function(t,e,i){var n=i(411),s=i(75),r=i(72);t.exports=function(t,e,i,o){return void 0===i&&(i=0),void 0===o&&(o=0),n(t,s(e)+i,r(e)+o),t}},function(t,e,i){var n=i(48),s=i(44),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(46),r=i(47),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(75),r=i(47),o=i(74);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(193),s=[];s[n.BOTTOM_CENTER]=i(415),s[n.BOTTOM_LEFT]=i(414),s[n.BOTTOM_RIGHT]=i(413),s[n.CENTER]=i(412),s[n.LEFT_CENTER]=i(410),s[n.RIGHT_CENTER]=i(409),s[n.TOP_CENTER]=i(408),s[n.TOP_LEFT]=i(407),s[n.TOP_RIGHT]=i(406);t.exports=function(t,e,i,n,r){return s[i](t,e,n,r)}},function(t,e,i){t.exports={Angle:i(1050),Call:i(1049),GetFirst:i(1048),GetLast:i(1047),GridAlign:i(1046),IncAlpha:i(1035),IncX:i(1034),IncXY:i(1033),IncY:i(1032),PlaceOnCircle:i(1031),PlaceOnEllipse:i(1030),PlaceOnLine:i(1029),PlaceOnRectangle:i(1028),PlaceOnTriangle:i(1027),PlayAnimation:i(1026),PropertyValueInc:i(32),PropertyValueSet:i(25),RandomCircle:i(1025),RandomEllipse:i(1024),RandomLine:i(1023),RandomRectangle:i(1022),RandomTriangle:i(1021),Rotate:i(1020),RotateAround:i(1019),RotateAroundDistance:i(1018),ScaleX:i(1017),ScaleXY:i(1016),ScaleY:i(1015),SetAlpha:i(1014),SetBlendMode:i(1013),SetDepth:i(1012),SetHitArea:i(1011),SetOrigin:i(1010),SetRotation:i(1009),SetScale:i(1008),SetScaleX:i(1007),SetScaleY:i(1006),SetTint:i(1005),SetVisible:i(1004),SetX:i(1003),SetXY:i(1002),SetY:i(1001),ShiftPosition:i(1e3),Shuffle:i(999),SmootherStep:i(998),SmoothStep:i(997),Spread:i(996),ToggleVisible:i(995),WrapInRectangle:i(994)}},,,function(t,e,i){var n=i(0),s=i(895),r=i(196),o=10,a=new n({Extends:r,initialize:function(t){o=t.maxLights,t.fragShader=s.replace("%LIGHT_COUNT%",o.toString()),r.call(this,t),this.defaultNormalMap},boot:function(){this.defaultNormalMap=this.game.textures.getFrame("__DEFAULT")},onBind:function(t){r.prototype.onBind.call(this);var e=this.renderer,i=this.program;return this.mvpUpdate(),e.setInt1(i,"uNormSampler",1),e.setFloat2(i,"uResolution",this.width,this.height),t&&this.setNormalMap(t),this},onRender:function(t,e){this.active=!1;var i=t.sys.lights;if(!i||i.lights.length<=0||!i.active)return this;var n=i.cull(e),s=Math.min(n.length,o);if(0===s)return this;this.active=!0;var r,a=this.renderer,h=this.program,l=e.matrix,u={x:0,y:0},c=a.height;for(r=0;r0&&n>0&&s.scissor(t,this.drawingBufferHeight-e-n,i,n))},popScissor:function(){var t=this.scissorStack;t.pop();var e=t[t.length-1];e&&this.setScissor(e[0],e[1],e[2],e[3]),this.currentScissor=e},setPipeline:function(t,e){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(e),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==r.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t,!0)},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setBlankTexture:function(t){void 0===t&&(t=!1),!t&&0===this.currentActiveTextureUnit&&this.currentTextures[0]||this.setTexture2D(this.blankTexture.glTexture,0)},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl,i=this.width,n=this.height;return t!==this.currentFramebuffer&&(t&&t.renderTexture?(i=t.renderTexture.width,n=t.renderTexture.height):this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),e.viewport(0,0,i,n),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,n){var s=this.gl,a=s.NEAREST,h=s.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,o(e,i)&&(h=s.REPEAT),n===r.ScaleModes.LINEAR&&this.config.antialias&&(a=s.LINEAR),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,a,h,h,s.RGBA,t):this.createTexture2D(0,a,a,h,h,s.RGBA,null,e,i)},createTexture2D:function(t,e,i,n,s,r,o,a,h,l){l=void 0===l||null===l||l;var u=this.gl,c=u.createTexture();return this.setTexture2D(c,0),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,e),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,i),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,s),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,n),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),null===o||void 0===o?u.texImage2D(u.TEXTURE_2D,t,r,a,h,0,r,u.UNSIGNED_BYTE,null):(u.texImage2D(u.TEXTURE_2D,t,r,r,u.UNSIGNED_BYTE,o),a=o.width,h=o.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=l,c.isRenderTexture=!1,c.width=a,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,n){var s,r=this.gl,o=r.createFramebuffer();if(this.setFramebuffer(o),n){var a=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,a),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(s=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[s])}return o.renderTexture=i,this.setFramebuffer(null),o},createProgram:function(t,e){var i=this.gl,n=i.createProgram(),s=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,t),i.shaderSource(r,e),i.compileShader(s),i.compileShader(r),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(s));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(n,s),i.attachShader(n,r),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(n));return n},createVertexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setVertexBuffer(n),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),n},createIndexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setIndexBuffer(n),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),n},deleteTexture:function(t){var e=this.nativeTextures.indexOf(t);return-1!==e&&a(this.nativeTextures,e),this.gl.deleteTexture(t),this.currentTextures[0]===t&&this.setBlankTexture(!0),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=t._cx,i=t._cy,n=t._cw,s=t._ch,r=this.pipelines.TextureTintPipeline,o=t.backgroundColor;if(t.renderToTexture){this.flush(),this.pushScissor(e,i,n,-s),this.setFramebuffer(t.framebuffer);var a=this.gl;a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT),r.projOrtho(e,n+e,i,s+i,-1e3,1e3),o.alphaGL>0&&r.drawFillRect(e,i,n+e,s+i,l.getTintFromFloats(o.redGL,o.greenGL,o.blueGL,1),o.alphaGL),t.emit("prerender",t)}else this.pushScissor(e,i,n,s),o.alphaGL>0&&r.drawFillRect(e,i,n,s,l.getTintFromFloats(o.redGL,o.greenGL,o.blueGL,1),o.alphaGL)},postRenderCamera:function(t){var e=this.pipelines.TextureTintPipeline;if(t.flashEffect.postRenderWebGL(e,l.getTintFromFloats),t.fadeEffect.postRenderWebGL(e,l.getTintFromFloats),t.dirty=!1,this.popScissor(),t.renderToTexture){e.flush(),this.setFramebuffer(null),t.emit("postrender",t),e.projOrtho(0,e.width,e.height,0,-1e3,1e3);var i=l.getTintAppendFloatAlpha;(t.pipeline?t.pipeline:e).batchTexture(t,t.glTexture,t.width,t.height,t.x,t.y,t.width,t.height,t.zoom,t.zoom,t.rotation,t.flipX,!t.flipY,1,1,0,0,0,0,t.width,t.height,i(t._tintTL,t._alphaTL),i(t._tintTR,t._alphaTR),i(t._tintBL,t._alphaBL),i(t._tintBR,t._alphaBR),t._isTinted&&t.tintFill,0,0,this.defaultCamera,null),this.setBlankTexture(!0)}},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var n in this.config.clearBeforeRender&&(t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT)),t.enable(t.SCISSOR_TEST),i)i[n].onPreRender();this.currentScissor=[0,0,this.width,this.height],this.scissorStack=[this.currentScissor],this.game.scene.customViewports&&t.scissor(0,this.drawingBufferHeight-this.height,this.width,this.height),this.setPipeline(this.pipelines.TextureTintPipeline)}},render:function(t,e,i,n){if(!this.contextLost){var s=e.list,o=s.length,a=this.pipelines;for(var h in a)a[h].onRender(t,n);this.preRenderCamera(n);for(var l=0;l=0?g=-(g+d):g<0&&(g=Math.abs(g)-d)),-1===y&&(v>=0?v=-(v+f):v<0&&(v=Math.abs(v)-f))}a.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),o.copyFrom(i.matrix),n?(o.multiplyWithOffset(n,-i.scrollX*t.scrollFactorX,-i.scrollY*t.scrollFactorY),a.e=t.x,a.f=t.y,o.multiply(a,h)):(a.e-=i.scrollX*t.scrollFactorX,a.f-=i.scrollY*t.scrollFactorY,o.multiply(a,h)),r.save(),h.setToContext(r),r.scale(m,y),r.globalCompositeOperation=this.blendModes[t.blendMode],r.globalAlpha=s,r.drawImage(e.source.image,u,c,d,f,g,v,d/p,f/p),r.restore()}},destroy:function(){this.gameCanvas=null,this.gameContext=null,this.game=null}});t.exports=u},function(t,e,i){var n=new(i(0))({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.once("remove",this.remove,this),this.isPlaying=!1,this.currentAnim=null,this.currentFrame=null,this._timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this._delay=0,this._repeat=0,this._repeatDelay=0,this._yoyo=!1,this.forward=!0,this._reverse=!1,this.accumulator=0,this.nextTick=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._pendingStop=0,this._pendingStopValue},setDelay:function(t){return void 0===t&&(t=0),this._delay=t,this.parent},getDelay:function(){return this._delay},delayedPlay:function(t,e,i){return this.play(e,!0,i),this.nextTick+=t,this.parent},getCurrentKey:function(){if(this.currentAnim)return this.currentAnim.key},load:function(t,e){return void 0===e&&(e=0),this.isPlaying&&this.stop(),this.animationManager.load(this,t,e),this.parent},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.updateFrame(t),this.parent},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.updateFrame(t),this.parent},isPaused:{get:function(){return this._paused}},play:function(t,e,i){return void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t?this.parent:(this.forward=!0,this._reverse=!1,this._startAnimation(t,i))},playReverse:function(t,e,i){return void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t?this.parent:(this.forward=!1,this._reverse=!0,this._startAnimation(t,i))},_startAnimation:function(t,e){this.load(t,e);var i=this.currentAnim,n=this.parent;return this.repeatCounter=-1===this._repeat?Number.MAX_VALUE:this._repeat,i.getFirstTick(this),this.isPlaying=!0,this.pendingRepeat=!1,i.showOnStart&&(n.visible=!0),n.emit("animationstart",this.currentAnim,this.currentFrame,n),n},reverse:function(t){return this.isPlaying&&this.currentAnim.key===t?(this._reverse=!this._reverse,this.forward=!this.forward,this.parent):this.parent},getProgress:function(){var t=this.currentFrame.progress;return this.forward||(t=1-t),t},setProgress:function(t){return this.forward||(t=1-t),this.setCurrentFrame(this.currentAnim.getFrameByProgress(t)),this.parent},remove:function(t,e){void 0===e&&(e=this.currentAnim),this.isPlaying&&e.key===this.currentAnim.key&&(this.stop(),this.setCurrentFrame(this.currentAnim.frames[0]))},getRepeat:function(){return this._repeat},setRepeat:function(t){return this._repeat=t,this.repeatCounter=0,this.parent},getRepeatDelay:function(){return this._repeatDelay},setRepeatDelay:function(t){return this._repeatDelay=t,this.parent},restart:function(t){void 0===t&&(t=!1),this.currentAnim.getFirstTick(this,t),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,this._paused=!1,this.updateFrame(this.currentAnim.frames[0]);var e=this.parent;return e.emit("animationrestart",this.currentAnim,this.currentFrame,e),this.parent},stop:function(){this._pendingStop=0,this.isPlaying=!1;var t=this.parent;return t.emit("animationcomplete",this.currentAnim,this.currentFrame,t),t},stopAfterDelay:function(t){return this._pendingStop=1,this._pendingStopValue=t,this.parent},stopOnRepeat:function(){return this._pendingStop=2,this.parent},stopOnFrame:function(t){return this._pendingStop=3,this._pendingStopValue=t,this.parent},setTimeScale:function(t){return void 0===t&&(t=1),this._timeScale=t,this.parent},getTimeScale:function(){return this._timeScale},getTotalFrames:function(){return this.currentAnim.frames.length},update:function(t,e){if(this.currentAnim&&this.isPlaying&&!this.currentAnim.paused){if(this.accumulator+=e*this._timeScale,1===this._pendingStop&&(this._pendingStopValue-=e,this._pendingStopValue<=0))return this.currentAnim.completeAnimation(this);this.accumulator>=this.nextTick&&this.currentAnim.setFrame(this)}},setCurrentFrame:function(t){var e=this.parent;return this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,e.isCropped&&e.frame.updateCropUVs(e._crop,e.flipX,e.flipY),e.setSizeToFrame(),t.frame.customPivot?e.setOrigin(t.frame.pivotX,t.frame.pivotY):e.updateDisplayOrigin(),e},updateFrame:function(t){var e=this.setCurrentFrame(t);if(this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;e.emit("animationupdate",i,t,e),3===this._pendingStop&&this._pendingStopValue===t&&this.currentAnim.completeAnimation(this)}},setYoyo:function(t){return void 0===t&&(t=!1),this._yoyo=t,this.parent},getYoyo:function(){return this._yoyo},destroy:function(){this.animationManager.off("remove",this.remove,this),this.animationManager=null,this.parent=null,this.currentAnim=null,this.currentFrame=null}});t.exports=n},function(t,e){t.exports=function(t){return t.split("").reverse().join("")}},function(t,e){t.exports=function(t,e){return t.replace(/%([0-9]+)/g,function(t,i){return e[Number(i)-1]})}},function(t,e,i){t.exports={Format:i(429),Pad:i(179),Reverse:i(428),UppercaseFirst:i(327),UUID:i(295)}},function(t,e,i){var n=i(63);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)&&(i[s]=e[s]);return i}},function(t,e){t.exports=function(t,e){for(var i=0;i-1&&(e.state=a.REMOVED,s.splice(r,1)):(e.state=a.REMOVED,n.splice(r,1))}for(i.length=0,i=this._add,t=0;t-1&&this._active.splice(s,1),n.destroy()}for(i=0;i=n.delay)){var s=n.elapsed-n.delay;n.elapsed=n.delay,!n.hasDispatched&&n.callback&&(n.hasDispatched=!0,n.callback.apply(n.callbackScope,n.args)),n.repeatCount>0?(n.repeatCount--,n.elapsed=s,n.hasDispatched=!1):this._pendingRemoval.push(n)}}}},shutdown:function(){var t;for(t=0;t0&&(t.currentPipeline&&t.currentPipeline.vertexCount>0&&t.flush(),r.vertexBuffer=e.vertexBuffer[a],t.setPipeline(r),t.setTexture2D(s[a].glTexture,0),t.gl.drawArrays(r.topology,0,e.vertexCount[a]));r.vertexBuffer=o,r.viewIdentity(),r.modelIdentity()}},function(t,e,i){var n=i(1),s=i(1);n=i(445),s=i(444),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e,i,n,s){e.cull(n);var r=e.culledTiles,o=r.length;if(0!==o){var a=t._tempMatrix1,h=t._tempMatrix2,l=t._tempMatrix3;h.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),a.copyFrom(n.matrix);var u=t.currentContext,c=e.gidMap;u.save(),s?(a.multiplyWithOffset(s,-n.scrollX*e.scrollFactorX,-n.scrollY*e.scrollFactorY),h.e=e.x,h.f=e.y,a.multiply(h,l),l.copyToContext(u)):(h.e-=n.scrollX*e.scrollFactorX,h.f-=n.scrollY*e.scrollFactorY,h.copyToContext(u));for(var d=n.alpha*e.alpha,f=0;f-1?new s(a,f,c,u,o.tilesize,o.tilesize):e?null:new s(a,-1,c,u,o.tilesize,o.tilesize),h.push(d)}l.push(h),h=[]}a.data=l,i.push(a)}return i}},function(t,e,i){var n=i(20);t.exports=function(t){for(var e,i,s,r,o,a=0;a1){if(Array.isArray(l.tiles)){for(var c={},d={},f=0;f>>0;return n}},function(t,e,i){var n=i(458),s=i(2),r=i(78),o=i(214),a=i(55);t.exports=function(t,e){for(var i=[],h=0;h0){var m=new a(u,v.gid,c,f.length,t.tilewidth,t.tileheight);m.rotation=v.rotation,m.flipX=v.flipped,d.push(m)}else{var y=e?null:new a(u,-1,c,f.length,t.tilewidth,t.tileheight);d.push(y)}++c===l.width&&(f.push(d),c=0,d=[])}u.data=f,i.push(u)}}return i}},function(t,e,i){t.exports={Parse:i(217),Parse2DArray:i(133),ParseCSV:i(216),Impact:i(210),Tiled:i(215)}},function(t,e,i){var n=i(50),s=i(49),r=i(3);t.exports=function(t,e,i,o,a,h){return void 0===o&&(o=new r(0,0)),o.x=n(t,i,a,h),o.y=s(e,i,a,h),o}},function(t,e,i){var n=i(17);t.exports=function(t,e,i,s,r,o){if(void 0!==r){var a,h=n(t,e,i,s,null,o),l=0;for(a=0;a0&&n(a,t)}}e&&s(0,0,i.width,i.height,i)}},function(t,e,i){var n=i(56),s=i(34),r=i(85);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0);for(var a=0;ae)){for(var h=t;h<=e;h++)r(h,i,a);for(var l=0;l=t&&c.index<=e&&n(c,i)}o&&s(0,0,a.width,a.height,a)}}},function(t,e,i){var n=i(56),s=i(34),r=i(134);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a=0;r--)for(s=n.width-1;s>=0;s--)if((o=n.data[r][s])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;r=v;o--)(h=c[a][o])&&-1!==h.index&&h.visible&&0!==h.alpha&&i.push(h);else if(2===r)for(a=x;a>=y;a--)for(o=v;o=y;a--)for(o=m;o>=v;o--)(h=c[a][o])&&-1!==h.index&&h.visible&&0!==h.alpha&&i.push(h);return u.tilesDrawn=i.length,u.tilesTotal=d*f,i}},function(t,e,i){var n=i(101),s=i(100),r=i(17),o=i(220);t.exports=function(t,e,i,a,h,l){void 0===i&&(i={}),Array.isArray(t)||(t=[t]);var u=l.tilemapLayer;void 0===a&&(a=u.scene),void 0===h&&(h=a.cameras.main);var c,d=r(0,0,l.width,l.height,null,l),f=[];for(c=0;c=0&&p=0&&g=this._duration&&this.transitionComplete()},transitionComplete:function(){var t=this._target.sys,e=this._target.sys.settings;this.systems.events.off("update",this.step,this),t.events.emit("transitioncomplete",this.scene),e.isTransition=!1,e.transitionFrom=null,this._duration=0,this._target=null,this._onUpdate=null,this._onUpdateScope=null,this._willRemove?this.manager.remove(this.key):this._willSleep?this.systems.sleep():this.manager.stop(this.key)},add:function(t,e,i){return this.manager.add(t,e,i),this},launch:function(t,e){return t&&t!==this.key&&this.manager.queueOp("start",t,e),this},run:function(t,e){return t&&t!==this.key&&this.manager.queueOp("run",t,e),this},pause:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("pause",t,e),this},resume:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("resume",t,e),this},sleep:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("sleep",t,e),this},wake:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("wake",t,e),this},switch:function(t){return t!==this.key&&this.manager.queueOp("switch",this.key,t),this},stop:function(t){return void 0===t&&(t=this.key),this.manager.queueOp("stop",t),this},setActive:function(t,e,i){void 0===e&&(e=this.key);var n=this.manager.getScene(e);return n&&n.sys.setActive(t,i),this},setVisible:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setVisible(t),this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},getIndex:function(t){return void 0===t&&(t=this.key),this.manager.getIndex(t)},shutdown:function(){var t=this.systems.events;t.off("shutdown",this.shutdown,this),t.off("postupdate",this.step,this),t.off("transitionout")},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null,this.settings=null,this.manager=null}});o.register("ScenePlugin",a,"scenePlugin"),t.exports=a},function(t,e,i){var n=i(116),s=i(20),r={SceneManager:i(329),ScenePlugin:i(495),Settings:i(326),Systems:i(166)};r=s(!1,r,n),t.exports=r},function(t,e,i){var n=i(221),s=new(i(0))({Extends:n,initialize:function(t,e){n.call(this,e),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this)},boot:function(){}});t.exports=s},function(t,e,i){t.exports={BasePlugin:i(221),DefaultPlugins:i(167),PluginCache:i(15),PluginManager:i(331),ScenePlugin:i(497)}},,,,,,,,,function(t,e,i){var n=i(229);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateY||e.customSeparateY)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.y,a=e.velocity.y;if(t.immovable||e.immovable)t.immovable?(e.y+=r,e.velocity.y=o-a*e.bounce.y,t.moves&&(e.x+=(t.x-t.prev.x)*t.friction.x)):(t.y-=r,t.velocity.y=a-o*t.bounce.y,e.moves&&(t.x+=(e.x-e.prev.x)*e.friction.x));else{r*=.5,t.y-=r,e.y+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.y=u+h*t.bounce.y,e.velocity.y=u+l*e.bounce.y}return!0}},function(t,e,i){var n=i(230);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.x,a=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=r,e.velocity.x=o-a*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=r,t.velocity.x=a-o*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{r*=.5,t.x-=r,e.x+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.x=u+h*t.bounce.x,e.velocity.x=u+l*e.bounce.x}return!0}},function(t,e){t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.up=!0):e>0&&(t.blocked.none=!1,t.blocked.down=!0),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},function(t,e,i){var n=i(509);t.exports=function(t,e,i,s,r){var o=0;return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom>i&&(o=t.bottom-i)>r&&(o=0),0!==o&&(t.customSeparateY?t.overlapY=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.left=!0):e>0&&(t.blocked.none=!1,t.blocked.right=!0),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},function(t,e,i){var n=i(511);t.exports=function(t,e,i,s,r){var o=0;return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right>i&&(o=t.right-i)>r&&(o=0),0!==o&&(t.customSeparateX?t.overlapX=o:n(t,o)),o}},function(t,e,i){var n=i(512),s=i(510),r=i(226);t.exports=function(t,e,i,o,a,h){var l=o.left,u=o.top,c=o.right,d=o.bottom,f=i.faceLeft||i.faceRight,p=i.faceTop||i.faceBottom;if(!f&&!p)return!1;var g=0,v=0,m=0,y=1;if(e.deltaAbsX()>e.deltaAbsY()?m=-1:e.deltaAbsX()=0;a--){var h=e[a],l=o(s,r,h.x,h.y);l=0;a--){var h=e[a],l=o(s,r,h.x,h.y);l>i&&(n=h,i=l)}return n},moveTo:function(t,e,i,n,s){void 0===n&&(n=60),void 0===s&&(s=0);var o=Math.atan2(i-t.y,e-t.x);return s>0&&(n=r(t.x,t.y,e,i)/(s/1e3)),t.body.velocity.setToPolar(o,n),o},moveToObject:function(t,e,i,n){return this.moveTo(t,e.x,e.y,i,n)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new c),i.setToPolar(s(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new c),i.setToPolar(t,e)},shutdown:function(){if(this.world){var t=this.systems.events;t.off("update",this.world.update,this.world),t.off("postupdate",this.world.postUpdate,this.world),t.off("shutdown",this.shutdown,this),this.add.destroy(),this.world.destroy(),this.add=null,this.world=null}},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null}});u.register("ArcadePhysics",f,"arcadePhysics"),t.exports=f},function(t,e,i){var n=i(35),s=i(20),r={ArcadePhysics:i(527),Body:i(232),Collider:i(231),Factory:i(238),Group:i(235),Image:i(237),Sprite:i(104),StaticBody:i(225),StaticGroup:i(234),World:i(233)};r=s(!1,r,n),t.exports=r},function(t,e,i){var n=i(138),s=i(240),r=i(239),o=new s,a=new r,h=new n;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n){this.x=0,this.y=0,this.z=0,this.w=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)},clone:function(){return new n(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this.w=t.w||0,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},set:function(t,e,i,n){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this.w+=t.w||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this.w-=t.w||0,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},normalize:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(e*e+i*i+n*n+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return e*e+i*i+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,e){t.exports=function(t,e,i){return Math.abs(t-e)<=i}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),n*=Math.PI/t;for(var s=[],r=[],o=0;o1?void 0!==n?(s=(n-t)/(n-i))<0&&(s=0):s=1:s<0&&(s=0),s}},function(t,e){t.exports=function(t,e,i){return Math.max(t-e,i)}},function(t,e){t.exports=function(t,e,i){return Math.min(t+e,i)}},function(t,e){t.exports=function(t){return t===parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t){return t==parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t,e){return t/e/1e3}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.floor(t*n)/n}},function(t,e){t.exports=function(t,e){return Math.abs(t-e)}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.ceil(t*n)/n}},function(t,e){t.exports=function(t){for(var e=0,i=0;i0&&0==(t&t-1)}},function(t,e,i){t.exports={GetNext:i(294),IsSize:i(117),IsValue:i(549)}},function(t,e,i){var n=i(182);t.exports=function(t,e,i){return e+(i-e)*n(t,0,1)}},function(t,e,i){var n=i(119);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return e<0?n(t[0],t[1],s):e>1?n(t[i],t[i-1],i-s):n(t[r],t[r+1>i?i:r+1],s-r)}},function(t,e,i){var n=i(171);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return t[0]===t[i]?(e<0&&(r=Math.floor(s=i*(1+e))),n(s-r,t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i])):e<0?t[0]-(n(-s,t[0],t[0],t[1],t[1])-t[0]):e>1?t[i]-(n(s-i,t[i],t[i],t[i-1],t[i-1])-t[i]):n(s-r,t[r?r-1:0],t[r],t[i=n.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:e0},isLoading:function(){return this.state===s.LOADER_LOADING||this.state===s.LOADER_PROCESSING},isReady:function(){return this.state===s.LOADER_IDLE||this.state===s.LOADER_COMPLETE},start:function(){this.isReady()&&(this.progress=0,this.totalFailed=0,this.totalComplete=0,this.totalToLoad=this.list.size,this.emit("start",this),0===this.list.size?this.loadComplete():(this.state=s.LOADER_LOADING,this.inflight.clear(),this.queue.clear(),this.updateProgress(),this.checkLoadQueue(),this.systems.events.on("update",this.update,this)))},updateProgress:function(){this.progress=1-(this.list.size+this.inflight.size)/this.totalToLoad,this.emit("progress",this.progress)},update:function(){this.state===s.LOADER_LOADING&&this.list.size>0&&this.inflight.size'),i.push(''),i.push(''),i.push(this.xhrLoader.responseText),i.push(""),i.push(""),i.push("");var n=[i.join("\n")],o=this;try{var a=new window.Blob(n,{type:"image/svg+xml;charset=utf-8"})}catch(t){return o.state=s.FILE_ERRORED,void o.onProcessComplete()}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(o.data),o.onProcessComplete()},this.data.onerror=function(){r.revokeObjectURL(o.data),o.onProcessError()},r.createObjectURL(this.data,a,"image/svg+xml")},addToCache:function(){var t=this.cache.addImage(this.key,this.data);this.pendingDestroy(t)}});o.register("htmlTexture",function(t,e,i,n,s){if(Array.isArray(t))for(var r=0;r0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(s=!0,i=n(t,e))}else s=!0,i=n(t,e);return!s&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e,i){var n=i(0),s=i(11),r=i(4),o=i(106),a=i(256),h=i(143),l=i(255),u=i(602),c=i(601),d=i(600),f=i(142),p=new n({Extends:s,initialize:function(t){s.call(this),this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.enabled=!0,this.target,this.keys=[],this.combos=[],this.queue=[],this.onKeyHandler,this.time=0,t.pluginEvents.once("boot",this.boot,this),t.pluginEvents.on("start",this.start,this)},boot:function(){var t=this.settings.input,e=this.scene.sys.game.config;this.enabled=r(t,"keyboard",e.inputKeyboard),this.target=r(t,"keyboard.target",e.inputKeyboardEventTarget),this.sceneInputPlugin.pluginEvents.once("destroy",this.destroy,this)},start:function(){this.enabled&&this.startListeners(),this.sceneInputPlugin.pluginEvents.once("shutdown",this.shutdown,this)},isActive:function(){return this.enabled&&this.scene.sys.isActive()},startListeners:function(){var t=this,e=function(e){if(!e.defaultPrevented&&t.isActive()){t.queue.push(e);var i=t.keys[e.keyCode];i&&i.preventDefault&&e.preventDefault()}};this.onKeyHandler=e,this.target.addEventListener("keydown",e,!1),this.target.addEventListener("keyup",e,!1),this.sceneInputPlugin.pluginEvents.on("update",this.update,this)},stopListeners:function(){this.target.removeEventListener("keydown",this.onKeyHandler),this.target.removeEventListener("keyup",this.onKeyHandler),this.sceneInputPlugin.pluginEvents.off("update",this.update)},createCursorKeys:function(){return this.addKeys({up:h.UP,down:h.DOWN,left:h.LEFT,right:h.RIGHT,space:h.SPACE,shift:h.SHIFT})},addKeys:function(t){var e={};if("string"==typeof t){t=t.split(",");for(var i=0;i-1?e[i]=t:e[t.keyCode]=t,t}return"string"==typeof t&&(t=h[t.toUpperCase()]),e[t]||(e[t]=new a(t)),e[t]},removeKey:function(t){var e=this.keys;if(t instanceof a){var i=e.indexOf(t);i>-1&&(this.keys[i]=void 0)}else"string"==typeof t&&(t=h[t.toUpperCase()]);e[t]&&(e[t]=void 0)},createCombo:function(t,e){return new l(this,t,e)},checkDown:function(t,e){if(this.enabled&&t.isDown){var i=f(this.time-t.timeDown,e);if(i>t._tick)return t._tick=i,!0}return!1},update:function(t){this.time=t;var e=this.queue.length;if(this.enabled&&0!==e)for(var i=this.queue.splice(0,e),n=this.keys,s=0;s=e}}},function(t,e,i){var n=i(71),s=i(40),r=i(0),o=i(260),a=i(608),h=i(52),l=i(90),u=i(89),c=i(11),d=i(2),f=i(106),p=i(8),g=i(15),v=i(9),m=i(39),y=i(59),x=i(69),w=new r({Extends:c,initialize:function(t){c.call(this),this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.manager=t.sys.game.input,this.pluginEvents=new c,this.enabled=!0,this.displayList,this.cameras,f.install(this),this.mouse=this.manager.mouse,this.topOnly=!0,this.pollRate=-1,this._pollTimer=0;var e={cancelled:!1};this._eventContainer={stopPropagation:function(){e.cancelled=!0}},this._eventData=e,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this._temp=[],this._tempZones=[],this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],this._draggable=[],this._drag={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._over={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._validTypes=["onDown","onUp","onOver","onOut","onMove","onDragStart","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop"],t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.cameras=this.systems.cameras,this.displayList=this.systems.displayList,this.systems.events.once("destroy",this.destroy,this),this.pluginEvents.emit("boot")},start:function(){var t=this.systems.events;t.on("transitionstart",this.transitionIn,this),t.on("transitionout",this.transitionOut,this),t.on("transitioncomplete",this.transitionComplete,this),t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this),this.enabled=!0,this.pluginEvents.emit("start")},preUpdate:function(){this.pluginEvents.emit("preUpdate");var t=this._pendingRemoval,e=this._pendingInsertion,i=t.length,n=e.length;if(0!==i||0!==n){for(var s=this._list,r=0;r-1&&(s.splice(a,1),this.clear(o))}t.length=0,this._pendingRemoval.length=0,this._list=s.concat(e.splice(0))}},isActive:function(){return this.enabled&&this.scene.sys.isActive()},update:function(t,e){if(this.isActive()){this.pluginEvents.emit("update",t,e);var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var n=i.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(n=!0,this._pollTimer=this.pollRate)),n)for(var s=this.manager.pointers,r=0;r0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}}},clear:function(t){var e=t.input;if(e){this.queueForRemoval(t),e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,this.manager.resetCursor(e),t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t}},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,n){return void 0===n&&(n=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input&&n&&!t.input.dropZone&&(t.input.dropZone=n),this},hitTestPointer:function(t){for(var e=this.cameras.getCamerasBelowPointer(t),i=0;i0)return t.camera=n,s}return t.camera=e[0],[]},processDownEvents:function(t){var e=0,i=this._temp,n=this._eventData,s=this._eventContainer;n.cancelled=!1;for(var r=!1,o=0;o0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var a=[];for(i=0;i1&&(this.sortGameObjects(a),this.topOnly&&a.splice(1)),this._drag[t.id]=a,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&h(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(s=this._drag[t.id],i=0;i0?(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),l[0]?(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):r.target=null)}else!r.target&&l[0]&&(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target));var c=t.x-n.input.dragX,d=t.y-n.input.dragY;n.emit("drag",t,c,d),this.emit("drag",t,n,c,d)}return s.length}if(5===t.dragState){for(s=this._drag[t.id],i=0;i0){for(this.sortGameObjects(s),e=0;e0){for(this.sortGameObjects(r),e=0;e-1&&this._draggable.splice(s,1)}return this},makePixelPerfect:function(t){void 0===t&&(t=1);var e=this.systems.textures;return a(e,t)},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);var n=!1,s=!1,r=!1,a=!1;if(p(e)){var h=e;e=d(h,"hitArea",null),i=d(h,"hitAreaCallback",null),n=d(h,"draggable",!1),s=d(h,"dropZone",!1),r=d(h,"cursor",!1),a=d(h,"useHandCursor",!1);var l=d(h,"pixelPerfect",!1),u=d(h,"alphaTolerance",1);l&&(e={},i=this.makePixelPerfect(u)),e&&i||this.setHitAreaFromTexture(t)}else"function"!=typeof e||i||(i=e,e={});for(var c=0;c0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r)e.x&&t.ye.y}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e,i){var n=Math.min(t.x,e),s=Math.max(t.right,e);t.x=n,t.width=s-n;var r=Math.min(t.y,i),o=Math.max(t.bottom,i);return t.y=r,t.height=o-r,t}},function(t,e){t.exports=function(t,e){var i=Math.min(t.x,e.x),n=Math.max(t.right,e.right);t.x=i,t.width=n-i;var s=Math.min(t.y,e.y),r=Math.max(t.bottom,e.bottom);return t.y=s,t.height=r-s,t}},function(t,e){t.exports=function(t,e){for(var i=t.x,n=t.right,s=t.y,r=t.bottom,o=0;on(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},function(t,e,i){var n=i(145);t.exports=function(t,e){var i=n(t);return ii&&(i=h.x),h.xr&&(r=h.y),h.ye.right||t.righte.bottom||t.bottom0||(c=s(e),(d=n(t,c,!0)).length>0)}},function(t,e,i){var n=i(69),s=i(107);t.exports=function(t,e){return!!(n(t,e.getPointA())||n(t,e.getPointB())||s(t.getLineA(),e)||s(t.getLineB(),e)||s(t.getLineC(),e))}},function(t,e,i){var n=i(272),s=i(69);t.exports=function(t,e){return!(t.left>e.right||t.righte.bottom||t.bottomt.right+r||it.bottom+r||st.right||e.rightt.bottom||e.bottom0}},function(t,e,i){var n=i(271);t.exports=function(t,e){if(!n(t,e))return!1;var i=Math.min(e.x1,e.x2),s=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=s&&t.y>=r&&t.y<=o}},function(t,e){t.exports=function(t,e){var i=t.x1,n=t.y1,s=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,l=e.bottom,u=0;if(i>=o&&i<=h&&n>=a&&n<=l||s>=o&&s<=h&&r>=a&&r<=l)return!0;if(i=o){if((u=n+(r-n)*(o-i)/(s-i))>a&&u<=l)return!0}else if(i>h&&s<=h&&(u=n+(r-n)*(h-i)/(s-i))>=a&&u<=l)return!0;if(n=a){if((u=i+(s-i)*(a-n)/(r-n))>=o&&u<=h)return!0}else if(n>l&&r<=l&&(u=i+(s-i)*(l-n)/(r-n))>=o&&u<=h)return!0;return!1}},function(t,e,i){var n=i(9),s=i(148);t.exports=function(t,e,i){return void 0===i&&(i=new n),s(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},function(t,e){t.exports=function(t,e){var i=e.width/2,n=e.height/2,s=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-n),o=i+t.radius,a=n+t.radius;if(s>o||r>a)return!1;if(s<=i||r<=n)return!0;var h=s-i,l=r-n;return h*h+l*l<=t.radius*t.radius}},function(t,e,i){var n=i(52);t.exports=function(t,e){return n(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(9);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e,i){var n=i(89);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(89);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(90);t.exports=function(t){return new n(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},function(t,e,i){var n=i(90);n.Area=i(712),n.Circumference=i(306),n.CircumferencePoint=i(156),n.Clone=i(711),n.Contains=i(89),n.ContainsPoint=i(710),n.ContainsRect=i(709),n.CopyFrom=i(708),n.Equals=i(707),n.GetBounds=i(706),n.GetPoint=i(308),n.GetPoints=i(307),n.Offset=i(705),n.OffsetPoint=i(704),n.Random=i(185),t.exports=n},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(9);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},function(t,e,i){var n=i(40);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(40);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(71);t.exports=function(t){return new n(t.x,t.y,t.radius)}},function(t,e){t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},function(t,e,i){var n=i(71);n.Area=i(722),n.Circumference=i(402),n.CircumferencePoint=i(192),n.Clone=i(721),n.Contains=i(40),n.ContainsPoint=i(720),n.ContainsRect=i(719),n.CopyFrom=i(718),n.Equals=i(717),n.GetBounds=i(716),n.GetPoint=i(405),n.GetPoints=i(403),n.Offset=i(715),n.OffsetPoint=i(714),n.Random=i(191),t.exports=n},function(t,e,i){var n=i(0),s=i(275),r=i(15),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",o,"lights"),t.exports=o},function(t,e,i){var n=i(28),s=i(13),r=i(12),o=i(149);s.register("quad",function(t,e){void 0===t&&(t={});var i=r(t,"x",0),s=r(t,"y",0),a=r(t,"key",null),h=r(t,"frame",null),l=new o(this.scene,i,s,a,h);return void 0!==e&&(t.add=e),n(this.scene,l,t),l})},function(t,e,i){var n=i(28),s=i(13),r=i(12),o=i(4),a=i(108);s.register("mesh",function(t,e){void 0===t&&(t={});var i=r(t,"key",null),s=r(t,"frame",null),h=o(t,"vertices",[]),l=o(t,"colors",[]),u=o(t,"alphas",[]),c=o(t,"uv",[]),d=new a(this.scene,0,0,h,c,l,u,i,s);return void 0!==e&&(t.add=e),n(this.scene,d,t),d})},function(t,e,i){var n=i(149);i(5).register("quad",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(108);i(5).register("mesh",function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))})},function(t,e){t.exports=function(){}},function(t,e,i){var n=i(10);t.exports=function(t,e,i,s,r){var o=this.pipeline;t.setPipeline(o,e);var a=o._tempMatrix1,h=o._tempMatrix2,l=o._tempMatrix3;h.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),a.copyFrom(s.matrix),r?(a.multiplyWithOffset(r,-s.scrollX*e.scrollFactorX,-s.scrollY*e.scrollFactorY),h.e=e.x,h.f=e.y,a.multiply(h,l)):(h.e-=s.scrollX*e.scrollFactorX,h.f-=s.scrollY*e.scrollFactorY,a.multiply(h,l));var u=e.frame.glTexture,c=e.vertices,d=e.uv,f=e.colors,p=e.alphas,g=c.length,v=Math.floor(.5*g);o.vertexCount+v>=o.vertexCapacity&&o.flush(),o.setTexture2D(u,0);for(var m=o.vertexViewF32,y=o.vertexViewU32,x=o.vertexCount*o.vertexComponentCount-1,w=0,T=e.tintFill,b=0;b0)for(u=o.fillTint,c=n.getTintAppendFloatAlphaAndSwap(e.fillColor,e.fillAlpha*d),u.TL=c,u.TR=c,u.BL=c,u.BR=c,M=0;M0)for(u=o.fillTint,c=n.getTintAppendFloatAlphaAndSwap(e.altFillColor,e.altFillAlpha*d),u.TL=c,u.TR=c,u.BL=c,u.BR=c,M=0;M0){var F=o.strokeTint,k=n.getTintAppendFloatAlphaAndSwap(e.outlineFillColor,e.outlineFillAlpha*d);for(F.TL=k,F.TR=k,F.BL=k,F.BR=k,C=1;Cr;h--){for(l=0;l0&&r.maxLines1&&(d+=f*(i.length-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},function(t,e,i){var n=i(4);t.exports=function(t,e){var i=e.width,s=e.height,r=Math.floor(i/2),o=Math.floor(s/2),a=n(e,"chars","");if(""!==a){var h=n(e,"image",""),l=n(e,"offset.x",0),u=n(e,"offset.y",0),c=n(e,"spacing.x",0),d=n(e,"spacing.y",0),f=n(e,"lineSpacing",0),p=n(e,"charsPerRow",null);null===p&&(p=t.sys.textures.getFrame(h).width/i)>a.length&&(p=a.length);for(var g=l,v=u,m={retroFont:!0,font:h,size:i,lineHeight:s+f,chars:{}},y=0,x=0;x?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",TEXT_SET2:" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET3:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",TEXT_SET4:"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",TEXT_SET5:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",TEXT_SET6:"ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",TEXT_SET7:"AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",TEXT_SET8:"0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET9:"ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",TEXT_SET10:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET11:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789"}},function(t,e,i){var n=i(813),s=i(20),r={Parse:i(812)};r=s(!1,r,n),t.exports=r},function(t,e){t.exports=function(t,e,i,n,s){t.batchSprite(e,e.frame,n,s)}},function(t,e,i){var n=i(10);t.exports=function(t,e,i,s,r){var o=e.frame,a=o.width,h=o.height,l=n.getTintAppendFloatAlpha;this.pipeline.batchTexture(e,o.glTexture,a,h,e.x,e.y,a,h,e.scaleX,e.scaleY,e.rotation,e.flipX,!e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,a,h,l(e._tintTL,s.alpha*e._alphaTL),l(e._tintTR,s.alpha*e._alphaTR),l(e._tintBL,s.alpha*e._alphaBL),l(e._tintBR,s.alpha*e._alphaBR),e._isTinted&&e.tintFill,0,0,s,r),t.setBlankTexture(!0)}},function(t,e,i){var n=i(1),s=i(1);n=i(816),s=i(815),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){t.exports={DeathZone:i(301),EdgeZone:i(300),RandomZone:i(297)}},function(t,e){t.exports=function(t,e,i,n,s){var r=e.emitters.list,o=r.length;if(0!==o){var a=t._tempMatrix1.copyFrom(n.matrix),h=t._tempMatrix2,l=t._tempMatrix3,u=t._tempMatrix4.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY);a.multiply(u);var c=n.roundPixels,d=t.currentContext;d.save();for(var f=0;f0&&(X=X%b-b):X>b?X=b:X<0&&(X=b+X%b),null===C&&(C=new o(D+Math.cos(Y)*B,I+Math.sin(Y)*B,v),_.push(C),O+=.01);O<1+N;)T=X*O+Y,x=D+Math.cos(T)*B,w=I+Math.sin(T)*B,C.points.push(new r(x,w,v)),O+=.01;T=X+Y,x=D+Math.cos(T)*B,w=I+Math.sin(T)*B,C.points.push(new r(x,w,v));break;case n.FILL_RECT:u.setTexture2D(E),u.batchFillRect(p[++P],p[++P],p[++P],p[++P],f,c);break;case n.FILL_TRIANGLE:u.setTexture2D(E),u.batchFillTriangle(p[++P],p[++P],p[++P],p[++P],p[++P],p[++P],f,c);break;case n.STROKE_TRIANGLE:u.setTexture2D(E),u.batchStrokeTriangle(p[++P],p[++P],p[++P],p[++P],p[++P],p[++P],v,f,c);break;case n.LINE_TO:null!==C?C.points.push(new r(p[++P],p[++P],v)):(C=new o(p[++P],p[++P],v),_.push(C));break;case n.MOVE_TO:C=new o(p[++P],p[++P],v),_.push(C);break;case n.SAVE:a.push(f.copyToArray());break;case n.RESTORE:f.copyFromArray(a.pop());break;case n.TRANSLATE:D=p[++P],I=p[++P],f.translate(D,I);break;case n.SCALE:D=p[++P],I=p[++P],f.scale(D,I);break;case n.ROTATE:f.rotate(p[++P]);break;case n.SET_TEXTURE:var U=p[++P],G=p[++P];u.currentFrame=U,u.setTexture2D(U.glTexture,0),u.tintEffect=G,E=U.glTexture;break;case n.CLEAR_TEXTURE:u.currentFrame=t.blankTexture,u.tintEffect=2,E=t.blankTexture.glTexture}}}},function(t,e,i){var n=i(1),s=i(1);n=i(830),s=i(305),s=i(305),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(22);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length,h=t.currentContext;if(0!==a&&n(t,h,e,s,r)){var l=e.frame,u=e.displayCallback,c=s.scrollX*e.scrollFactorX,d=s.scrollY*e.scrollFactorY,f=e.fontData.chars,p=e.fontData.lineHeight,g=0,v=0,m=0,y=0,x=null,w=0,T=0,b=0,_=0,S=0,A=0,C=null,M=0,E=e.frame.source.image,P=l.cutX,L=l.cutY,F=0,k=e.fontSize/e.fontData.size;e.cropWidth>0&&e.cropHeight>0&&(h.save(),h.beginPath(),h.rect(0,0,e.cropWidth,e.cropHeight),h.clip());for(var R=0;R0&&e.cropHeight>0&&h.restore(),h.restore()}}},function(t,e,i){var n=i(10);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length;if(0!==a){var h=this.pipeline;t.setPipeline(h,e);var l=e.cropWidth>0||e.cropHeight>0;l&&(h.flush(),t.pushScissor(e.x,e.y,e.cropWidth*e.scaleX,e.cropHeight*e.scaleY));var u=h._tempMatrix1,c=h._tempMatrix2,d=h._tempMatrix3,f=h._tempMatrix4;c.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),u.copyFrom(s.matrix),r?(u.multiplyWithOffset(r,-s.scrollX*e.scrollFactorX,-s.scrollY*e.scrollFactorY),c.e=e.x,c.f=e.y,u.multiply(c,d)):(c.e-=s.scrollX*e.scrollFactorX,c.f-=s.scrollY*e.scrollFactorY,u.multiply(c,d));var p=e.frame,g=p.glTexture,v=p.cutX,m=p.cutY,y=g.width,x=g.height,w=e._isTinted&&e.tintFill,T=n.getTintAppendFloatAlpha(e._tintTL,s.alpha*e._alphaTL),b=n.getTintAppendFloatAlpha(e._tintTR,s.alpha*e._alphaTR),_=n.getTintAppendFloatAlpha(e._tintBL,s.alpha*e._alphaBL),S=n.getTintAppendFloatAlpha(e._tintBR,s.alpha*e._alphaBR);h.setTexture2D(g,0);var A,C,M=0,E=0,P=0,L=0,F=e.letterSpacing,k=0,R=0,O=0,D=0,I=e.scrollX,B=e.scrollY,Y=e.fontData,X=Y.chars,z=Y.lineHeight,N=e.fontSize/Y.size,U=0,G=e._align,W=0,V=0;e.getTextBounds(!1);var H=e._bounds.lines;1===G?V=(H.longest-H.lengths[0])/2:2===G&&(V=H.longest-H.lengths[0]);for(var j=s.roundPixels,q=e.displayCallback,K=e.callbackData,J=0;Jv&&(r=v),o>m&&(o=m);var L=v+g.xAdvance,F=m+u;aA&&(A=M),MA&&(A=M),M-1&&this._list.splice(s,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;i0&&(t.splice(i,1),t.unshift(e)),e}},function(t,e){t.exports=function(t,e,i){var n=t.indexOf(e),s=t.indexOf(i);return-1!==n&&-1===s&&(t[n]=i,!0)}},function(t,e,i){var n=i(91);t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return n(t,s)}},function(t,e,i){var n=i(62);t.exports=function(t,e,i,s,r){if(void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===r&&(r=t),n(t,e,i)){var o=i-e,a=t.splice(e,o);if(s)for(var h=0;ht.length-1)throw new Error("Index out of bounds");var r=n(t,e);return i&&i.call(s,r),r}},function(t,e,i){var n=i(314);t.exports=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=null),void 0===i&&(i=1),null===e&&(e=t,t=0);for(var s=[],r=Math.max(n((e-t)/(i||1)),0),o=0;o=t.length)throw new Error("Supplied index out of bounds");return n!==i&&(t.splice(n,1),t.splice(i,0,e)),e}},function(t,e){t.exports=function(t,e){var i=t.indexOf(e);if(i>0){var n=t[i-1],s=t.indexOf(n);t[i]=n,t[s]=e}return t}},function(t,e,i){var n=i(62);t.exports=function(t,e,i,s,r){if(void 0===s&&(s=0),void 0===r&&(r=t.length),n(t,s,r))for(var o=s;o0){var o=n-t.length;if(o<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.splice(i,0,e),s&&s.call(r,e),e):null;for(var a=e.length-1;a>=0;)-1!==t.indexOf(e[a])&&e.pop(),a--;if(0===(a=e.length))return null;n>0&&a>o&&(e.splice(o),a=o);for(var h=a-1;h>=0;h--){var l=e[h];t.splice(i,0,l),s&&s.call(r,l)}return e}},function(t,e){t.exports=function(t,e,i,n,s){if(void 0===s&&(s=t),i>0){var r=i-t.length;if(r<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.push(e),n&&n.call(s,e),e):null;for(var o=e.length-1;o>=0;)-1!==t.indexOf(e[o])&&e.pop(),o--;if(0===(o=e.length))return null;i>0&&o>r&&(e.splice(r),o=r);for(var a=0;a0||!this.inFocus)&&(this._coolDown--,r=Math.min(r,this._target)),r>this._min&&(r=n[i],r=Math.min(r,this._min)),n[i]=r,this.deltaIndex++,this.deltaIndex>s&&(this.deltaIndex=0);for(var o=0,a=0;athis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var h=o/this._target;this.callback(t,o,h),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=a},function(t,e){var i=0,n=function(t,e,n,s){var r=i-s.y-s.height;t.add(n,e,s.x,r,s.width,s.height)};t.exports=function(t,e,s){var r=t.source[e];t.add("__BASE",e,0,0,r.width,r.height),i=r.height;for(var o=s.split("\n"),a=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",l="",u={x:0,y:0,width:0,height:0},c=0;cx||a<-x)&&(a=0),a<0&&(a=x+a),-1!==h&&(x=a+(h+1));for(var C=l,M=l,E=0,P=e.sourceIndex,L=0;Lg||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var v=f,m=f,y=0,x=0,w=0;wr&&(y=T-r),b>o&&(x=b-o),t.add(w,e,i+v,s+m,h-y,l-x),(v+=h+p)+h>r&&(v=f,m+=l+p)}return t}},function(t,e,i){var n=i(63);t.exports=function(t,e,i){if(i.frames){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);var r,o=i.frames;for(var a in o){var h=o[a];r=t.add(a,e,h.frame.x,h.frame.y,h.frame.w,h.frame.h),h.trimmed&&r.setTrim(h.sourceSize.w,h.sourceSize.h,h.spriteSourceSize.x,h.spriteSourceSize.y,h.spriteSourceSize.w,h.spriteSourceSize.h),h.rotated&&(r.rotated=!0,r.updateUVsInverted()),r.customData=n(h)}for(var l in i)"frames"!==l&&(Array.isArray(i[l])?t.customData[l]=i[l].slice(0):t.customData[l]=i[l]);return t}console.warn("Invalid Texture Atlas JSON Hash given, missing 'frames' Object")}},function(t,e,i){var n=i(63);t.exports=function(t,e,i){if(i.frames||i.textures){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);for(var r,o=Array.isArray(i.textures)?i.textures[e].frames:i.frames,a=0;a=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(s.dolby=!0)}}catch(t){}return s}()},function(t,e,i){var n=i(92),s=i(118),r={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),n.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){var n=i(0),s=i(26),r=i(340),o=i(2),a=i(4),h=i(8),l=i(16),u=i(1),c=i(167),d=i(178),f=new n({initialize:function(t){void 0===t&&(t={});this.width=a(t,"width",1024),this.height=a(t,"height",768),this.zoom=a(t,"zoom",1),this.resolution=a(t,"resolution",1),this.parent=a(t,"parent",null),this.scaleMode=a(t,"scaleMode",0),this.expandParent=a(t,"expandParent",!1),this.minWidth=a(t,"minWidth",0),this.maxWidth=a(t,"maxWidth",0),this.minHeight=a(t,"minHeight",0),this.maxHeight=a(t,"maxHeight",0);var e=a(t,"scale",null);e&&(this.width=a(e,"width",this.width),this.height=a(e,"height",this.height),this.zoom=a(e,"zoom",this.zoom),this.resolution=a(e,"resolution",this.resolution),this.parent=a(e,"parent",this.parent),this.scaleMode=a(e,"mode",this.scaleMode),this.expandParent=a(e,"mode",this.expandParent),this.minWidth=a(e,"min.width",this.minWidth),this.maxWidth=a(e,"max.width",this.maxWidth),this.minHeight=a(e,"min.height",this.minHeight),this.maxHeight=a(e,"max.height",this.maxHeight)),this.renderType=a(t,"type",s.AUTO),this.canvas=a(t,"canvas",null),this.context=a(t,"context",null),this.canvasStyle=a(t,"canvasStyle",null),this.sceneConfig=a(t,"scene",null),this.seed=a(t,"seed",[(Date.now()*Math.random()).toString()]),l.RND.init(this.seed),this.gameTitle=a(t,"title",""),this.gameURL=a(t,"url","https://phaser.io"),this.gameVersion=a(t,"version",""),this.autoFocus=a(t,"autoFocus",!0),this.domCreateContainer=a(t,"dom.createContainer",!1),this.domBehindCanvas=a(t,"dom.behindCanvas",!1),this.inputKeyboard=a(t,"input.keyboard",!0),this.inputKeyboardEventTarget=a(t,"input.keyboard.target",window),this.inputMouse=a(t,"input.mouse",!0),this.inputMouseEventTarget=a(t,"input.mouse.target",null),this.inputMouseCapture=a(t,"input.mouse.capture",!0),this.inputTouch=a(t,"input.touch",r.input.touch),this.inputTouchEventTarget=a(t,"input.touch.target",null),this.inputTouchCapture=a(t,"input.touch.capture",!0),this.inputActivePointers=a(t,"input.activePointers",1),this.inputGamepad=a(t,"input.gamepad",!1),this.inputGamepadEventTarget=a(t,"input.gamepad.target",window),this.disableContextMenu=a(t,"disableContextMenu",!1),this.audio=a(t,"audio"),this.hideBanner=!1===a(t,"banner",null),this.hidePhaser=a(t,"banner.hidePhaser",!1),this.bannerTextColor=a(t,"banner.text","#ffffff"),this.bannerBackgroundColor=a(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=a(t,"fps",null);var i=a(t,"render",t);this.autoResize=a(i,"autoResize",!0),this.antialias=a(i,"antialias",!0),this.roundPixels=a(i,"roundPixels",!1),this.pixelArt=a(i,"pixelArt",!1),this.pixelArt&&(this.antialias=!1,this.roundPixels=!0),this.transparent=a(i,"transparent",!1),this.clearBeforeRender=a(i,"clearBeforeRender",!0),this.premultipliedAlpha=a(i,"premultipliedAlpha",!0),this.preserveDrawingBuffer=a(i,"preserveDrawingBuffer",!1),this.failIfMajorPerformanceCaveat=a(i,"failIfMajorPerformanceCaveat",!1),this.powerPreference=a(i,"powerPreference","default"),this.batchSize=a(i,"batchSize",2e3),this.maxLights=a(i,"maxLights",10);var n=a(t,"backgroundColor",0);this.backgroundColor=d(n),0===n&&this.transparent&&(this.backgroundColor.alpha=0),this.preBoot=a(t,"callbacks.preBoot",u),this.postBoot=a(t,"callbacks.postBoot",u),this.physics=a(t,"physics",{}),this.defaultPhysicsSystem=a(this.physics,"default",!1),this.loaderBaseURL=a(t,"loader.baseURL",""),this.loaderPath=a(t,"loader.path",""),this.loaderMaxParallelDownloads=a(t,"loader.maxParallelDownloads",32),this.loaderCrossOrigin=a(t,"loader.crossOrigin",void 0),this.loaderResponseType=a(t,"loader.responseType",""),this.loaderAsync=a(t,"loader.async",!0),this.loaderUser=a(t,"loader.user",""),this.loaderPassword=a(t,"loader.password",""),this.loaderTimeout=a(t,"loader.timeout",0),this.installGlobalPlugins=[],this.installScenePlugins=[];var f=a(t,"plugins",null),p=c.DefaultScene;f&&(Array.isArray(f)?this.defaultPlugins=f:h(f)&&(this.installGlobalPlugins=o(f,"global",[]),this.installScenePlugins=o(f,"scene",[]),Array.isArray(f.default)?p=f.default:Array.isArray(f.defaultMerge)&&(p=p.concat(f.defaultMerge)))),this.defaultPlugins=p;var g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=a(t,"images.default",g+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=a(t,"images.missing",g+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=="),window&&(window.FORCE_WEBGL?this.renderType=s.WEBGL:window.FORCE_CANVAS&&(this.renderType=s.CANVAS))}});t.exports=f},function(t,e,i){var n=i(169),s=i(381),r=i(379),o=i(24),a=i(0),h=i(903),l=i(898),u=i(123),c=i(891),d=i(340),f=i(344),p=i(11),g=i(338),v=i(15),m=i(331),y=i(329),x=i(325),w=i(318),T=i(878),b=i(877),_=new a({initialize:function(t){this.config=new h(t),this.renderer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new p,this.anims=new s(this),this.textures=new w(this),this.cache=new r(this),this.registry=new u(this),this.input=new g(this,this.config),this.scene=new y(this,this.config.sceneConfig),this.device=d,this.sound=x.create(this),this.loop=new T(this,this.config.fps),this.plugins=new m(this,this.config),this.pendingDestroy=!1,this.removeCanvas=!1,this.noReturn=!1,this.hasFocus=!1,this.isOver=!0,f(this.boot.bind(this))},boot:function(){v.hasCore("EventEmitter")?(this.isBooted=!0,this.config.preBoot(this),l(this),c(this),n(this.canvas,this.config.parent),this.events.emit("boot"),this.events.once("texturesready",this.texturesReady,this)):console.warn("Aborting. Core Plugins missing.")},texturesReady:function(){this.events.emit("ready"),this.start()},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),b(this);var t=this.events;t.on("hidden",this.onHidden,this),t.on("visible",this.onVisible,this),t.on("blur",this.onBlur,this),t.on("focus",this.onFocus,this)},step:function(t,e){if(this.pendingDestroy)return this.runDestroy();var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e);var n=this.renderer;n.preRender(),i.emit("prerender",n,t,e),this.scene.render(n),n.postRender(),i.emit("postrender",n,t,e)},headlessStep:function(t,e){var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e),i.emit("prerender"),i.emit("postrender")},onHidden:function(){this.loop.pause(),this.events.emit("pause")},onVisible:function(){this.loop.resume(),this.events.emit("resume")},onBlur:function(){this.hasFocus=!1,this.loop.blur()},onFocus:function(){this.hasFocus=!0,this.loop.focus()},resize:function(t,e){this.config.width=t,this.config.height=e,this.renderer.resize(t,e),this.input.resize(),this.scene.resize(t,e),this.events.emit("resize",t,e)},destroy:function(t,e){void 0===e&&(e=!1),this.pendingDestroy=!0,this.removeCanvas=t,this.noReturn=e},runDestroy:function(){this.events.emit("destroy"),this.events.removeAllListeners(),this.scene.destroy(),this.renderer&&this.renderer.destroy(),this.removeCanvas&&this.canvas&&(o.remove(this.canvas),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)),this.loop.destroy(),this.pendingDestroy=!1}});t.exports=_},function(t,e,i){var n=i(0),s=i(11),r=i(15),o=new n({Extends:s,initialize:function(){s.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",o,"events"),t.exports=o},function(t,e,i){t.exports={EventEmitter:i(905)}},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var h,l=[],u=!1,c=-1;function d(){u&&h&&(u=!1,h.length?l=h.concat(l):c=-1,l.length&&f())}function f(){if(!u){var t=a(d);u=!0;for(var e=l.length;e;){for(h=l,l=[];++c1)for(var i=1;i>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},function(t,e){t.exports=function(t,e){void 0===e&&(e="none");return["-webkit-","-khtml-","-moz-","-ms-",""].forEach(function(i){t.style[i+"user-select"]=e}),t.style["-webkit-touch-callout"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}},function(t,e){t.exports=function(t,e){return void 0===e&&(e="none"),t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}},function(t,e,i){t.exports={CanvasInterpolation:i(348),CanvasPool:i(24),Smoothing:i(120),TouchAction:i(917),UserSelect:i(916)}},function(t,e){t.exports=function(t){return t.height*t.originY}},function(t,e){t.exports=function(t){return t.width*t.originX}},function(t,e,i){t.exports={CenterOn:i(411),GetBottom:i(48),GetCenterX:i(75),GetCenterY:i(72),GetLeft:i(46),GetOffsetX:i(920),GetOffsetY:i(919),GetRight:i(44),GetTop:i(42),SetBottom:i(47),SetCenterX:i(74),SetCenterY:i(73),SetLeft:i(45),SetRight:i(43),SetTop:i(41)}},function(t,e,i){var n=i(44),s=i(42),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(46),s=i(42),r=i(47),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)-a),t}},function(t,e,i){var n=i(75),s=i(42),r=i(47),o=i(74);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(44),s=i(42),r=i(45),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(72),s=i(44),r=i(73),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(47),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(46),s=i(42),r=i(43),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(72),s=i(46),r=i(73),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(46),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(43),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(46),r=i(45),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(75),r=i(74),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){t.exports={BottomCenter:i(933),BottomLeft:i(932),BottomRight:i(931),LeftBottom:i(930),LeftCenter:i(929),LeftTop:i(928),RightBottom:i(927),RightCenter:i(926),RightTop:i(925),TopCenter:i(924),TopLeft:i(923),TopRight:i(922)}},function(t,e,i){t.exports={BottomCenter:i(415),BottomLeft:i(414),BottomRight:i(413),Center:i(412),LeftCenter:i(410),QuickSet:i(416),RightCenter:i(409),TopCenter:i(408),TopLeft:i(407),TopRight:i(406)}},function(t,e,i){var n=i(193),s=i(20),r={In:i(935),To:i(934)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Align:i(936),Bounds:i(921),Canvas:i(918),Color:i(347),Masks:i(909)}},function(t,e,i){var n=i(0),s=i(123),r=i(15),o=new n({Extends:s,initialize:function(t){s.call(this,t,t.sys.events),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.events=this.systems.events,this.events.once("destroy",this.destroy,this)},start:function(){this.events.once("shutdown",this.shutdown,this)},shutdown:function(){this.systems.events.off("shutdown",this.shutdown,this)},destroy:function(){s.prototype.destroy.call(this),this.events.off("start",this.start,this),this.scene=null,this.systems=null}});r.register("DataManagerPlugin",o,"data"),t.exports=o},function(t,e,i){t.exports={DataManager:i(123),DataManagerPlugin:i(938)}},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(t,e){this.active=!1,this.p0=new s(t,e)},getPoint:function(t,e){return void 0===e&&(e=new s),e.copy(this.p0)},getPointAt:function(t,e){return this.getPoint(t,e)},getResolution:function(){return 1},getLength:function(){return 0},toJSON:function(){return{type:"MoveTo",points:[this.p0.x,this.p0.y]}}});t.exports=r},function(t,e,i){var n=i(0),s=i(355),r=i(353),o=i(5),a=i(352),h=i(940),l=i(351),u=i(9),c=i(349),d=i(3),f=new n({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.name="",this.curves=[],this.cacheLengths=[],this.autoClose=!1,this.startPoint=new d,this._tmpVec2A=new d,this._tmpVec2B=new d,"object"==typeof t?this.fromJSON(t):this.startPoint.set(t,e)},add:function(t){return this.curves.push(t),this},circleTo:function(t,e,i){return void 0===e&&(e=!1),this.ellipseTo(t,t,0,360,e,i)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return t.equals(e)||this.curves.push(new a(e,t)),this},cubicBezierTo:function(t,e,i,n,r,o){var a,h,l,u=this.getEndPoint();return t instanceof d?(a=t,h=e,l=i):(a=new d(i,n),h=new d(r,o),l=new d(t,e)),this.add(new s(u,a,h,l))},quadraticBezierTo:function(t,e,i,n){var s,r,o=this.getEndPoint();return t instanceof d?(s=t,r=e):(s=new d(i,n),r=new d(t,e)),this.add(new l(o,s,r))},draw:function(t,e){for(var i=0;i0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),n=this.getCurveLengths(),s=0;s=i){var r=n[s]-i,o=this.curves[s],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}s++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],n=0;n1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e0&&(h.preRender(r,o),t.render(n,e,i,h))}},resetAll:function(){for(var t=0;t=1?1:1/e*(1+(e*t|0))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e,i){var n=i(23),s=i(0),r=i(3),o=i(174),a=new s({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.source=new r,this.current=new r,this.destination=new r,this.ease,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,n,s,r,a){void 0===i&&(i=1e3),void 0===n&&(n=o.Linear),void 0===s&&(s=!1),void 0===r&&(r=null),void 0===a&&(a=this.camera.scene);var h=this.camera;return!s&&this.isRunning?h:(this.isRunning=!0,this.duration=i,this.progress=0,this.source.set(h.scrollX,h.scrollY),this.destination.set(t,e),h.getScroll(t,e,this.current),"string"==typeof n&&o.hasOwnProperty(n)?this.ease=o[n]:"function"==typeof n&&(this.ease=n),this._elapsed=0,this._onUpdate=r,this._onUpdateScope=a,this.camera.emit("camerapanstart",this.camera,this,i,t,e),h)},update:function(t,e){if(this.isRunning){this._elapsed+=e;var i=n(this._elapsed/this.duration,0,1);this.progress=i;var s=this.camera;if(this._elapsed0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoom<.1&&(e.zoom=.1))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(4),r=new n({initialize:function(t){this.camera=s(t,"camera",null),this.left=s(t,"left",null),this.right=s(t,"right",null),this.up=s(t,"up",null),this.down=s(t,"down",null),this.zoomIn=s(t,"zoomIn",null),this.zoomOut=s(t,"zoomOut",null),this.zoomSpeed=s(t,"zoomSpeed",.01),this.speedX=0,this.speedY=0;var e=s(t,"speed",null);"number"==typeof e?(this.speedX=e,this.speedY=e):(this.speedX=s(t,"speed.x",0),this.speedY=s(t,"speed.y",0)),this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this.up&&this.up.isDown?e.scrollY-=this.speedY*t|0:this.down&&this.down.isDown&&(e.scrollY+=this.speedY*t|0),this.left&&this.left.isDown?e.scrollX-=this.speedX*t|0:this.right&&this.right.isDown&&(e.scrollX+=this.speedX*t|0),this.zoomIn&&this.zoomIn.isDown?(e.zoom-=this.zoomSpeed,e.zoom<.1&&(e.zoom=.1)):this.zoomOut&&this.zoomOut.isDown&&(e.zoom+=this.zoomSpeed)}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){t.exports={FixedKeyControl:i(989),SmoothedKeyControl:i(988)}},function(t,e,i){t.exports={Controls:i(990),Scene2D:i(987)}},function(t,e,i){t.exports={BaseCache:i(380),CacheManager:i(379)}},function(t,e,i){t.exports={Animation:i(384),AnimationFrame:i(382),AnimationManager:i(381)}},function(t,e,i){var n=i(53);t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=0;s1)if(0===s){var d=t.length-1;for(o=t[d].x,a=t[d].y,h=d-1;h>=0;h--)l=(c=t[h]).x,u=c.y,c.x=o,c.y=a,o=l,a=u;t[d].x=e,t[d].y=i}else{for(o=t[0].x,a=t[0].y,h=1;h0?s(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,_isTinted:!1,tintFill:!1,clearTint:function(){return this.setTint(16777215),this._isTinted=!1,this},setTint:function(t,e,n,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,n=t,s=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(n),this._tintBR=i(s),this._isTinted=!0,this.tintFill=!1,this},setTintFill:function(t,e,i,n){return this.setTint(t,e,i,n),this.tintFill=!0,this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t),this._isTinted=!0}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t),this._isTinted=!0}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t),this._isTinted=!0}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t),this._isTinted=!0}},tint:{set:function(t){this.setTint(t,t,t,t)}},isTinted:{get:function(){return this._isTinted}}};t.exports=n},function(t,e){var i={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,n){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,n,this.flipX,this.flipY);else{var s=t;this.frame.setCropUVs(this._crop,s.x,s.y,s.width,s.height,this.flipX,this.flipY)}this.isCropped=!0}return this},setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this.isCropped&&this.frame.updateCropUVs(this._crop,this.flipX,this.flipY),this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=i},function(t,e){var i={texture:null,frame:null,isCropped:!1,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e,i){var n=i(94),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e,i){var n=i(9),s=i(396),r=i(3),o={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getTopRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBounds:function(t){var e,i,s,r,o,a,h,l;if(void 0===t&&(t=new n),this.parentContainer){var u=this.parentContainer.getBoundsTransformMatrix();this.getTopLeft(t),u.transformPoint(t.x,t.y,t),e=t.x,i=t.y,this.getTopRight(t),u.transformPoint(t.x,t.y,t),s=t.x,r=t.y,this.getBottomLeft(t),u.transformPoint(t.x,t.y,t),o=t.x,a=t.y,this.getBottomRight(t),u.transformPoint(t.x,t.y,t),h=t.x,l=t.y}else this.getTopLeft(t),e=t.x,i=t.y,this.getTopRight(t),s=t.x,r=t.y,this.getBottomLeft(t),o=t.x,a=t.y,this.getBottomRight(t),h=t.x,l=t.y;return t.x=Math.min(e,s,o,h),t.y=Math.min(i,r,a,l),t.width=Math.max(e,s,o,h)-t.x,t.height=Math.max(i,r,a,l)-t.y,t}};t.exports=o},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e){var i={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,n){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,n,this.flipX,this.flipY);else{var s=t;this.frame.setCropUVs(this._crop,s.x,s.y,s.width,s.height,this.flipX,this.flipY)}this.isCropped=!0}return this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=i},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}}},function(t,e,i){var n=i(416),s=i(193),r=i(2),o=i(1),a=new(i(125))({sys:{queueDepthSort:o,events:{once:o}}},0,0,1,1);t.exports=function(t,e){void 0===e&&(e={});var i=r(e,"width",-1),o=r(e,"height",-1),h=r(e,"cellWidth",1),l=r(e,"cellHeight",h),u=r(e,"position",s.TOP_LEFT),c=r(e,"x",0),d=r(e,"y",0),f=0,p=0,g=i*h,v=o*l;a.setPosition(c,d),a.setSize(h,l);for(var m=0;m>>0;if("function"!=typeof t)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,s=0;s - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Taken from klasse by mattdesl https://github.com/mattdesl/klasse - -function hasGetterOrSetter (def) -{ - return (!!def.get && typeof def.get === 'function') || (!!def.set && typeof def.set === 'function'); -} - -function getProperty (definition, k, isClassDescriptor) -{ - // This may be a lightweight object, OR it might be a property that was defined previously. - - // For simple class descriptors we can just assume its NOT previously defined. - var def = (isClassDescriptor) ? definition[k] : Object.getOwnPropertyDescriptor(definition, k); - - if (!isClassDescriptor && def.value && typeof def.value === 'object') - { - def = def.value; - } - - // This might be a regular property, or it may be a getter/setter the user defined in a class. - if (def && hasGetterOrSetter(def)) - { - if (typeof def.enumerable === 'undefined') - { - def.enumerable = true; - } - - if (typeof def.configurable === 'undefined') - { - def.configurable = true; - } - - return def; - } - else - { - return false; - } -} - -function hasNonConfigurable (obj, k) -{ - var prop = Object.getOwnPropertyDescriptor(obj, k); - - if (!prop) - { - return false; - } - - if (prop.value && typeof prop.value === 'object') - { - prop = prop.value; - } - - if (prop.configurable === false) - { - return true; - } - - return false; -} - -function extend (ctor, definition, isClassDescriptor, extend) -{ - for (var k in definition) - { - if (!definition.hasOwnProperty(k)) - { - continue; - } - - var def = getProperty(definition, k, isClassDescriptor); - - if (def !== false) - { - // If Extends is used, we will check its prototype to see if the final variable exists. - - var parent = extend || ctor; - - if (hasNonConfigurable(parent.prototype, k)) - { - // Just skip the final property - if (Class.ignoreFinals) - { - continue; - } - - // We cannot re-define a property that is configurable=false. - // So we will consider them final and throw an error. This is by - // default so it is clear to the developer what is happening. - // You can set ignoreFinals to true if you need to extend a class - // which has configurable=false; it will simply not re-define final properties. - throw new Error('cannot override final property \'' + k + '\', set Class.ignoreFinals = true to skip'); - } - - Object.defineProperty(ctor.prototype, k, def); - } - else - { - ctor.prototype[k] = definition[k]; - } - } -} - -function mixin (myClass, mixins) -{ - if (!mixins) - { - return; - } - - if (!Array.isArray(mixins)) - { - mixins = [ mixins ]; - } - - for (var i = 0; i < mixins.length; i++) - { - extend(myClass, mixins[i].prototype || mixins[i]); - } -} - -/** - * Creates a new class with the given descriptor. - * The constructor, defined by the name `initialize`, - * is an optional function. If unspecified, an anonymous - * function will be used which calls the parent class (if - * one exists). - * - * You can also use `Extends` and `Mixins` to provide subclassing - * and inheritance. - * - * @class Class - * @constructor - * @param {Object} definition a dictionary of functions for the class - * @example - * - * var MyClass = new Phaser.Class({ - * - * initialize: function() { - * this.foo = 2.0; - * }, - * - * bar: function() { - * return this.foo + 5; - * } - * }); - */ -function Class (definition) -{ - if (!definition) - { - definition = {}; - } - - // The variable name here dictates what we see in Chrome debugger - var initialize; - var Extends; - - if (definition.initialize) - { - if (typeof definition.initialize !== 'function') - { - throw new Error('initialize must be a function'); - } - - initialize = definition.initialize; - - // Usually we should avoid 'delete' in V8 at all costs. - // However, its unlikely to make any performance difference - // here since we only call this on class creation (i.e. not object creation). - delete definition.initialize; - } - else if (definition.Extends) - { - var base = definition.Extends; - - initialize = function () - { - base.apply(this, arguments); - }; - } - else - { - initialize = function () {}; - } - - if (definition.Extends) - { - initialize.prototype = Object.create(definition.Extends.prototype); - initialize.prototype.constructor = initialize; - - // For getOwnPropertyDescriptor to work, we need to act directly on the Extends (or Mixin) - - Extends = definition.Extends; - - delete definition.Extends; - } - else - { - initialize.prototype.constructor = initialize; - } - - // Grab the mixins, if they are specified... - var mixins = null; - - if (definition.Mixins) - { - mixins = definition.Mixins; - delete definition.Mixins; - } - - // First, mixin if we can. - mixin(initialize, mixins); - - // Now we grab the actual definition which defines the overrides. - extend(initialize, definition, true, Extends); - - return initialize; -} - -Class.extend = extend; -Class.mixin = mixin; -Class.ignoreFinals = false; - -module.exports = Class; - - -/***/ }), -/* 1 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Finds the key within the top level of the {@link source} object, or returns {@link defaultValue} - * - * @function Phaser.Utils.Object.GetFastValue - * @since 3.0.0 - * - * @param {object} source - The object to search - * @param {string} key - The key for the property on source. Must exist at the top level of the source object (no periods) - * @param {*} [defaultValue] - The default value to use if the key does not exist. - * - * @return {*} The value if found; otherwise, defaultValue (null if none provided) - */ -var GetFastValue = function (source, key, defaultValue) -{ - var t = typeof(source); - - if (!source || t === 'number' || t === 'string') - { - return defaultValue; - } - else if (source.hasOwnProperty(key) && source[key] !== undefined) - { - return source[key]; - } - else - { - return defaultValue; - } -}; - -module.exports = GetFastValue; - - -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var DataManager = __webpack_require__(81); -var EventEmitter = __webpack_require__(9); - -/** - * @classdesc - * The base class that all Game Objects extend. - * You don't create GameObjects directly and they cannot be added to the display list. - * Instead, use them as the base for your own custom classes. - * - * @class GameObject - * @memberOf Phaser.GameObjects - * @extends Phaser.Events.EventEmitter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. - * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`. - */ -var GameObject = new Class({ - - Extends: EventEmitter, - - initialize: - - function GameObject (scene, type) - { - EventEmitter.call(this); - - /** - * The Scene to which this Game Object belongs. - * Game Objects can only belong to one Scene. - * - * @name Phaser.GameObjects.GameObject#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A textual representation of this Game Object, i.e. `sprite`. - * Used internally by Phaser but is available for your own custom classes to populate. - * - * @name Phaser.GameObjects.GameObject#type - * @type {string} - * @since 3.0.0 - */ - this.type = type; - - /** - * The parent Container of this Game Object, if it has one. - * - * @name Phaser.GameObjects.GameObject#parentContainer - * @type {Phaser.GameObjects.Container} - * @since 3.4.0 - */ - this.parentContainer = null; - - /** - * The name of this Game Object. - * Empty by default and never populated by Phaser, this is left for developers to use. - * - * @name Phaser.GameObjects.GameObject#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The active state of this Game Object. - * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. - * An active object is one which is having its logic and internal systems updated. - * - * @name Phaser.GameObjects.GameObject#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * The Tab Index of the Game Object. - * Reserved for future use by plugins and the Input Manager. - * - * @name Phaser.GameObjects.GameObject#tabIndex - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.tabIndex = -1; - - /** - * A Data Manager. - * It allows you to store, query and get key/value paired information specific to this Game Object. - * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. - * - * @name Phaser.GameObjects.GameObject#data - * @type {Phaser.Data.DataManager} - * @default null - * @since 3.0.0 - */ - this.data = null; - - /** - * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. - * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. - * If those components are not used by your custom class then you can use this bitmask as you wish. - * - * @name Phaser.GameObjects.GameObject#renderFlags - * @type {integer} - * @default 15 - * @since 3.0.0 - */ - this.renderFlags = 15; - - /** - * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly. Instead call `Camera.ignore`. - * - * @name Phaser.GameObjects.GameObject#cameraFilter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cameraFilter = 0; - - /** - * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. - * Not usually set directly. Instead call `GameObject.setInteractive()`. - * - * @name Phaser.GameObjects.GameObject#input - * @type {?Phaser.Input.InteractiveObject} - * @default null - * @since 3.0.0 - */ - this.input = null; - - /** - * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. - * - * @name Phaser.GameObjects.GameObject#body - * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} - * @default null - * @since 3.0.0 - */ - 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 - scene.sys.queueDepthSort(); - - scene.sys.events.once('shutdown', this.destroy, this); - }, - - /** - * Sets the `active` property of this Game Object and returns this Game Object for further chaining. - * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. - * - * @method Phaser.GameObjects.GameObject#setActive - * @since 3.0.0 - * - * @param {boolean} value - True if this Game Object should be set as active, false if not. - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setActive: function (value) - { - this.active = value; - - return this; - }, - - /** - * Sets the `name` property of this Game Object and returns this Game Object for further chaining. - * The `name` property is not populated by Phaser and is presented for your own use. - * - * @method Phaser.GameObjects.GameObject#setName - * @since 3.0.0 - * - * @param {string} value - The name to be given to this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setName: function (value) - { - this.name = value; - - return this; - }, - - /** - * Adds a Data Manager component to this Game Object. - * - * @method Phaser.GameObjects.GameObject#setDataEnabled - * @since 3.0.0 - * @see Phaser.Data.DataManager - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setDataEnabled: function () - { - if (!this.data) - { - this.data = new DataManager(this); - } - - return this; - }, - - /** - * Allows you to store a key value pair within this Game Objects Data Manager. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * sprite.setData('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `getData`: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or you can access the value directly via the `values` property, where it works like any other variable: - * - * ```javascript - * sprite.data.values.gold += 50; - * ``` - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * - * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. - * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. - * - * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * - * @method Phaser.GameObjects.GameObject#setData - * @since 3.0.0 - * - * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. - * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. - * - * @return {this} This GameObject. - */ - setData: function (key, value) - { - if (!this.data) - { - this.data = new DataManager(this); - } - - this.data.set(key, value); - - return this; - }, - - /** - * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. - * - * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * sprite.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: - * - * ```javascript - * sprite.getData([ 'gold', 'armor', 'health' ]); - * ``` - * - * This approach is useful for destructuring arrays in ES6. - * - * @method Phaser.GameObjects.GameObject#getData - * @since 3.0.0 - * - * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. - * - * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. - */ - getData: function (key) - { - if (!this.data) - { - this.data = new DataManager(this); - } - - return this.data.get(key); - }, - - /** - * Pass this Game Object to the Input Manager to enable it for Input. - * - * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area - * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced - * input detection. - * - * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If - * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific - * shape for it to use. - * - * You can also provide an Input Configuration Object as the only argument to this method. - * - * @method Phaser.GameObjects.GameObject#setInteractive - * @since 3.0.0 - * - * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. - * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setInteractive: function (shape, callback, dropZone) - { - this.scene.sys.input.enable(this, shape, callback, dropZone); - - return this; - }, - - /** - * If this Game Object has previously been enabled for input, this will disable it. - * - * An object that is disabled for input stops processing or being considered for - * input events, but can be turned back on again at any time by simply calling - * `setInteractive()` with no arguments provided. - * - * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. - * - * @method Phaser.GameObjects.GameObject#disableInteractive - * @since 3.7.0 - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - disableInteractive: function () - { - if (this.input) - { - this.input.enabled = (this.input.enabled) ? false : true; - } - - return this; - }, - - /** - * If this Game Object has previously been enabled for input, this will remove it. - * - * The Interactive Object that was assigned to this Game Object will be destroyed, - * removed from the Input Manager and cleared from this Game Object. - * - * If you wish to re-enable this Game Object at a later date you will need to - * re-create its InteractiveOobject by calling `setInteractive` again. - * - * If you wish to only temporarily stop an object from receiving input then use - * `disableInteractive` instead, as that toggles the interactive state, where-as - * this erases it completely. - * - * @method Phaser.GameObjects.GameObject#removeInteractive - * @since 3.7.0 - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - removeInteractive: function () - { - this.scene.sys.input.clear(this); - - this.input = undefined; - - return this; - }, - - /** - * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. - * - * @method Phaser.GameObjects.GameObject#update - * @since 3.0.0 - */ - update: function () - { - }, - - /** - * Returns a JSON representation of the Game Object. - * - * @method Phaser.GameObjects.GameObject#toJSON - * @since 3.0.0 - * - * @return {JSONGameObject} A JSON representation of the Game Object. - */ - toJSON: function () - { - return Components.ToJSON(this); - }, - - /** - * Compares the renderMask with the renderFlags to see if this Game Object will render or not. - * - * @method Phaser.GameObjects.GameObject#willRender - * @since 3.0.0 - * - * @return {boolean} True if the Game Object should be rendered, otherwise false. - */ - willRender: function () - { - return (GameObject.RENDER_MASK === this.renderFlags); - }, - - /** - * Returns an array containing the display list index of either this Game Object, or if it has one, - * its parent Container. It then iterates up through all of the parent containers until it hits the - * root of the display list (which is index 0 in the returned array). - * - * Used internally by the InputPlugin but also useful if you wish to find out the display depth of - * this Game Object and all of its ancestors. - * - * @method Phaser.GameObjects.GameObject#getIndexList - * @since 3.4.0 - * - * @return {integer[]} An array of display list position indexes. - */ - getIndexList: function () - { - // eslint-disable-next-line consistent-this - var child = this; - var parent = this.parentContainer; - - var indexes = []; - - while (parent) - { - // indexes.unshift([parent.getIndex(child), parent.name]); - indexes.unshift(parent.getIndex(child)); - - child = parent; - - if (!parent.parentContainer) - { - break; - } - else - { - parent = parent.parentContainer; - } - } - - // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']); - indexes.unshift(this.scene.sys.displayList.getIndex(child)); - - return indexes; - }, - - /** - * Destroys this Game Object removing it from the Display List and Update List and - * severing all ties to parent resources. - * - * Also removes itself from the Input Manager and Physics Manager if previously enabled. - * - * Use this to remove a Game Object from your game if you don't ever plan to use it again. - * As long as no reference to it exists within your own code it should become free for - * garbage collection by the browser. - * - * If you just want to temporarily disable an object then look at using the - * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. - * - * @method Phaser.GameObjects.GameObject#destroy - * @since 3.0.0 - */ - destroy: function () - { - // This Game Object had already been destroyed - if (!this.scene || this.ignoreDestroy) - { - return; - } - - if (this.preDestroy) - { - this.preDestroy.call(this); - } - - this.emit('destroy', this); - - var sys = this.scene.sys; - - sys.displayList.remove(this); - sys.updateList.remove(this); - - if (this.input) - { - sys.input.clear(this); - this.input = undefined; - } - - if (this.data) - { - this.data.destroy(); - - this.data = undefined; - } - - if (this.body) - { - this.body.destroy(); - this.body = undefined; - } - - // Tell the Scene to re-sort the children - sys.queueDepthSort(); - - this.active = false; - this.visible = false; - - this.scene = undefined; - - this.parentContainer = undefined; - - this.removeAllListeners(); - } - -}); - -/** - * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. - * - * @constant {integer} RENDER_MASK - * @memberOf Phaser.GameObjects.GameObject - * @default - */ -GameObject.RENDER_MASK = 15; - -module.exports = GameObject; - - -/***/ }), -/* 3 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A NOOP (No Operation) callback function. - * - * Used internally by Phaser when it's more expensive to determine if a callback exists - * than it is to just invoke an empty function. - * - * @function Phaser.Utils.NOOP - * @since 3.0.0 - */ -var NOOP = function () -{ - // NOOP -}; - -module.exports = NOOP; - - -/***/ }), -/* 4 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Source object -// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' -// The default value to use if the key doesn't exist - -/** - * [description] - * - * @function Phaser.Utils.Object.GetValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {*} [description] - */ -var GetValue = function (source, key, defaultValue) -{ - if (!source || typeof source === 'number') - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else if (key.indexOf('.')) - { - var keys = key.split('.'); - var parent = source; - var value = defaultValue; - - // Use for loop here so we can break early - for (var i = 0; i < keys.length; i++) - { - if (parent.hasOwnProperty(keys[i])) - { - // Yes it has a key property, let's carry on down - value = parent[keys[i]]; - - parent = parent[keys[i]]; - } - else - { - // Can't go any further, so reset to default - value = defaultValue; - break; - } - } - - return value; - } - else - { - return defaultValue; - } -}; - -module.exports = GetValue; - - -/***/ }), -/* 5 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * Defines a Point in 2D space, with an x and y component. - * - * @class Point - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - The x coordinate of this Point. - * @param {number} [y=x] - The y coordinate of this Point. - */ -var Point = new Class({ - - initialize: - - function Point (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - /** - * The x coordinate of this Point. - * - * @name Phaser.Geom.Point#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * The y coordinate of this Point. - * - * @name Phaser.Geom.Point#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - }, - - /** - * Set the x and y coordinates of the point to the given values. - * - * @method Phaser.Geom.Point#setTo - * @since 3.0.0 - * - * @param {number} [x=0] - The x coordinate of this Point. - * @param {number} [y=x] - The y coordinate of this Point. - * - * @return {Phaser.Geom.Point} This Point object. - */ - setTo: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - } - -}); - -module.exports = Point; - - -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @typedef {object} Vector2Like - * - * @property {number} x - The x component. - * @property {number} y - The y component. - */ - -/** - * @classdesc - * A representation of a vector in 2D space. - * - * A two-component vector. - * - * @class Vector2 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - The x component. - * @param {number} [y] - The y component. - */ -var Vector2 = new Class({ - - initialize: - - function Vector2 (x, y) - { - /** - * The x component of this Vector. - * - * @name Phaser.Math.Vector2#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The y component of this Vector. - * - * @name Phaser.Math.Vector2#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - } - else - { - if (y === undefined) { y = x; } - - this.x = x || 0; - this.y = y || 0; - } - }, - - /** - * Make a clone of this Vector2. - * - * @method Phaser.Math.Vector2#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Vector2} A clone of this Vector2. - */ - clone: function () - { - return new Vector2(this.x, this.y); - }, - - /** - * Copy the components of a given Vector into this Vector. - * - * @method Phaser.Math.Vector2#copy - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - The Vector to copy the components from. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - copy: function (src) - { - this.x = src.x || 0; - this.y = src.y || 0; - - return this; - }, - - /** - * Set the component values of this Vector from a given Vector2Like object. - * - * @method Phaser.Math.Vector2#setFromObject - * @since 3.0.0 - * - * @param {Vector2Like} obj - The object containing the component values to set for this Vector. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - setFromObject: function (obj) - { - this.x = obj.x || 0; - this.y = obj.y || 0; - - return this; - }, - - /** - * Set the `x` and `y` components of the this Vector to the given `x` and `y` values. - * - * @method Phaser.Math.Vector2#set - * @since 3.0.0 - * - * @param {number} x - The x value to set for this Vector. - * @param {number} [y=x] - The y value to set for this Vector. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - set: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * This method is an alias for `Vector2.set`. - * - * @method Phaser.Math.Vector2#setTo - * @since 3.4.0 - * - * @param {number} x - The x value to set for this Vector. - * @param {number} [y=x] - The y value to set for this Vector. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - setTo: function (x, y) - { - return this.set(x, y); - }, - - /** - * Sets the `x` and `y` values of this object from a given polar coordinate. - * - * @method Phaser.Math.Vector2#setToPolar - * @since 3.0.0 - * - * @param {float} azimuth - The angular coordinate, in radians. - * @param {float} [radius=1] - The radial coordinate (length). - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - setToPolar: function (azimuth, radius) - { - if (radius == null) { radius = 1; } - - this.x = Math.cos(azimuth) * radius; - this.y = Math.sin(azimuth) * radius; - - return this; - }, - - /** - * Check whether this Vector is equal to a given Vector. - * - * Performs a strict equality check against each Vector's components. - * - * @method Phaser.Math.Vector2#equals - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} v - The vector to compare with this Vector. - * - * @return {boolean} Whether the given Vector is equal to this Vector. - */ - equals: function (v) - { - return ((this.x === v.x) && (this.y === v.y)); - }, - - /** - * Calculate the angle between this Vector and the positive x-axis, in radians. - * - * @method Phaser.Math.Vector2#angle - * @since 3.0.0 - * - * @return {number} The angle between this Vector, and the positive x-axis, given in radians. - */ - angle: function () - { - // computes the angle in radians with respect to the positive x-axis - - var angle = Math.atan2(this.y, this.x); - - if (angle < 0) - { - angle += 2 * Math.PI; - } - - return angle; - }, - - /** - * Add a given Vector to this Vector. Addition is component-wise. - * - * @method Phaser.Math.Vector2#add - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - The Vector to add to this Vector. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - add: function (src) - { - this.x += src.x; - this.y += src.y; - - return this; - }, - - /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * - * @method Phaser.Math.Vector2#subtract - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - The Vector to subtract from this Vector. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - subtract: function (src) - { - this.x -= src.x; - this.y -= src.y; - - return this; - }, - - /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * - * @method Phaser.Math.Vector2#multiply - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - The Vector to multiply this Vector by. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - multiply: function (src) - { - this.x *= src.x; - this.y *= src.y; - - return this; - }, - - /** - * Scale this Vector by the given value. - * - * @method Phaser.Math.Vector2#scale - * @since 3.0.0 - * - * @param {number} value - The value to scale this Vector by. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - scale: function (value) - { - if (isFinite(value)) - { - this.x *= value; - this.y *= value; - } - else - { - this.x = 0; - this.y = 0; - } - - return this; - }, - - /** - * Perform a component-wise division between this Vector and the given Vector. - * - * Divides this Vector by the given Vector. - * - * @method Phaser.Math.Vector2#divide - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - The Vector to divide this Vector by. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - divide: function (src) - { - this.x /= src.x; - this.y /= src.y; - - return this; - }, - - /** - * Negate the `x` and `y` components of this Vector. - * - * @method Phaser.Math.Vector2#negate - * @since 3.0.0 - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - negate: function () - { - this.x = -this.x; - this.y = -this.y; - - return this; - }, - - /** - * Calculate the distance between this Vector and the given Vector. - * - * @method Phaser.Math.Vector2#distance - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to. - * - * @return {number} The distance from this Vector to the given Vector. - */ - distance: function (src) - { - var dx = src.x - this.x; - var dy = src.y - this.y; - - return Math.sqrt(dx * dx + dy * dy); - }, - - /** - * Calculate the distance between this Vector, and the given Vector, squared. - * - * @method Phaser.Math.Vector2#distanceSq - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to. - * - * @return {number} The distance from this Vector to the given Vector, squared. - */ - distanceSq: function (src) - { - var dx = src.x - this.x; - var dy = src.y - this.y; - - return dx * dx + dy * dy; - }, - - /** - * Calculate the length (or magnitude) of this Vector. - * - * @method Phaser.Math.Vector2#length - * @since 3.0.0 - * - * @return {number} The length of this Vector. - */ - length: function () - { - var x = this.x; - var y = this.y; - - return Math.sqrt(x * x + y * y); - }, - - /** - * Calculate the length of this Vector squared. - * - * @method Phaser.Math.Vector2#lengthSq - * @since 3.0.0 - * - * @return {number} The length of this Vector, squared. - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - - return x * x + y * y; - }, - - /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. - * - * @method Phaser.Math.Vector2#normalize - * @since 3.0.0 - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var len = x * x + y * y; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - } - - return this; - }, - - /** - * Right-hand normalize (make unit length) this Vector. - * - * @method Phaser.Math.Vector2#normalizeRightHand - * @since 3.0.0 - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - normalizeRightHand: function () - { - var x = this.x; - - this.x = this.y * -1; - this.y = x; - - return this; - }, - - /** - * Calculate the dot product of this Vector and the given Vector. - * - * @method Phaser.Math.Vector2#dot - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - The Vector2 to dot product with this Vector2. - * - * @return {number} The dot product of this Vector and the given Vector. - */ - dot: function (src) - { - return this.x * src.x + this.y * src.y; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector2#cross - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - [description] - * - * @return {number} [description] - */ - cross: function (src) - { - return this.x * src.y - this.y * src.x; - }, - - /** - * Linearly interpolate between this Vector and the given Vector. - * - * Interpolates this Vector towards the given Vector. - * - * @method Phaser.Math.Vector2#lerp - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} src - The Vector2 to interpolate towards. - * @param {number} [t=0] - The interpolation percentage, between 0 and 1. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - lerp: function (src, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - - this.x = ax + t * (src.x - ax); - this.y = ay + t * (src.y - ay); - - return this; - }, - - /** - * Transform this Vector with the given Matrix. - * - * @method Phaser.Math.Vector2#transformMat3 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector2 with. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - transformMat3: function (mat) - { - var x = this.x; - var y = this.y; - var m = mat.val; - - this.x = m[0] * x + m[3] * y + m[6]; - this.y = m[1] * x + m[4] * y + m[7]; - - return this; - }, - - /** - * Transform this Vector with the given Matrix. - * - * @method Phaser.Math.Vector2#transformMat4 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector2 with. - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - transformMat4: function (mat) - { - var x = this.x; - var y = this.y; - var m = mat.val; - - this.x = m[0] * x + m[4] * y + m[12]; - this.y = m[1] * x + m[5] * y + m[13]; - - return this; - }, - - /** - * Make this Vector the zero vector (0, 0). - * - * @method Phaser.Math.Vector2#reset - * @since 3.0.0 - * - * @return {Phaser.Math.Vector2} This Vector2. - */ - reset: function () - { - this.x = 0; - this.y = 0; - - return this; - } - -}); - -/** - * A static zero Vector2 for use by reference. - * - * @method Phaser.Math.Vector2.ZERO - * @since 3.1.0 - */ -Vector2.ZERO = new Vector2(); - -module.exports = Vector2; - - -/***/ }), -/* 7 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var types = {}; - -var FileTypesManager = { - - /** - * Static method called when a LoaderPlugin is created. - * - * Loops through the local types object and injects all of them as - * properties into the LoaderPlugin instance. - * - * @method Phaser.Loader.FileTypesManager.register - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - The LoaderPlugin to install the types into. - */ - install: function (loader) - { - for (var key in types) - { - loader[key] = types[key]; - } - }, - - /** - * Static method called directly by the File Types. - * - * The key is a reference to the function used to load the files via the Loader, i.e. `image`. - * - * @method Phaser.Loader.FileTypesManager.register - * @since 3.0.0 - * - * @param {string} key - The key that will be used as the method name in the LoaderPlugin. - * @param {function} factoryFunction - The function that will be called when LoaderPlugin.key is invoked. - */ - register: function (key, factoryFunction) - { - types[key] = factoryFunction; - }, - - /** - * Removed all associated file types. - * - * @method Phaser.Loader.FileTypesManager.destroy - * @since 3.0.0 - */ - destroy: function () - { - types = {}; - } - -}; - -module.exports = FileTypesManager; - - -/***/ }), -/* 8 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * This is a slightly modified version of jQuery.isPlainObject. - * A plain object is an object whose internal class property is [object Object]. - * - * @function Phaser.Utils.Object.IsPlainObject - * @since 3.0.0 - * - * @param {object} obj - The object to inspect. - * - * @return {boolean} `true` if the object is plain, otherwise `false`. - */ -var IsPlainObject = function (obj) -{ - // Not plain objects: - // - Any object or value whose internal [[Class]] property is not "[object Object]" - // - DOM nodes - // - window - if (typeof(obj) !== 'object' || obj.nodeType || obj === obj.window) - { - return false; - } - - // Support: Firefox <20 - // The try/catch suppresses exceptions thrown when attempting to access - // the "constructor" property of certain host objects, ie. |window.location| - // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 - try - { - if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) - { - return false; - } - } - catch (e) - { - return false; - } - - // If the function hasn't returned already, we're confident that - // |obj| is a plain object, created by {} or constructed with new Object - return true; -}; - -module.exports = IsPlainObject; - - -/***/ }), -/* 9 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var has = Object.prototype.hasOwnProperty - , prefix = '~'; - -/** - * Constructor to create a storage for our `EE` objects. - * An `Events` instance is a plain object whose properties are event names. - * - * @constructor - * @private - */ -function Events() {} - -// -// We try to not inherit from `Object.prototype`. In some engines creating an -// instance in this way is faster than calling `Object.create(null)` directly. -// If `Object.create(null)` is not supported we prefix the event names with a -// character to make sure that the built-in object properties are not -// overridden or used as an attack vector. -// -if (Object.create) { - Events.prototype = Object.create(null); - - // - // This hack is needed because the `__proto__` property is still inherited in - // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. - // - if (!new Events().__proto__) prefix = false; -} - -/** - * Representation of a single event listener. - * - * @param {Function} fn The listener function. - * @param {*} context The context to invoke the listener with. - * @param {Boolean} [once=false] Specify if the listener is a one-time listener. - * @constructor - * @private - */ -function EE(fn, context, once) { - this.fn = fn; - this.context = context; - this.once = once || false; -} - -/** - * Add a listener for a given event. - * - * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. - * @param {(String|Symbol)} event The event name. - * @param {Function} fn The listener function. - * @param {*} context The context to invoke the listener with. - * @param {Boolean} once Specify if the listener is a one-time listener. - * @returns {EventEmitter} - * @private - */ -function addListener(emitter, event, fn, context, once) { - if (typeof fn !== 'function') { - throw new TypeError('The listener must be a function'); - } - - var listener = new EE(fn, context || emitter, once) - , evt = prefix ? prefix + event : event; - - if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; - else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); - else emitter._events[evt] = [emitter._events[evt], listener]; - - return emitter; -} - -/** - * Clear event by name. - * - * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. - * @param {(String|Symbol)} evt The Event name. - * @private - */ -function clearEvent(emitter, evt) { - if (--emitter._eventsCount === 0) emitter._events = new Events(); - else delete emitter._events[evt]; -} - -/** - * Minimal `EventEmitter` interface that is molded against the Node.js - * `EventEmitter` interface. - * - * @constructor - * @public - */ -function EventEmitter() { - this._events = new Events(); - this._eventsCount = 0; -} - -/** - * Return an array listing the events for which the emitter has registered - * listeners. - * - * @returns {Array} - * @public - */ -EventEmitter.prototype.eventNames = function eventNames() { - var names = [] - , events - , name; - - if (this._eventsCount === 0) return names; - - for (name in (events = this._events)) { - if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); - } - - if (Object.getOwnPropertySymbols) { - return names.concat(Object.getOwnPropertySymbols(events)); - } - - return names; -}; - -/** - * Return the listeners registered for a given event. - * - * @param {(String|Symbol)} event The event name. - * @returns {Array} The registered listeners. - * @public - */ -EventEmitter.prototype.listeners = function listeners(event) { - var evt = prefix ? prefix + event : event - , handlers = this._events[evt]; - - if (!handlers) return []; - if (handlers.fn) return [handlers.fn]; - - for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { - ee[i] = handlers[i].fn; - } - - return ee; -}; - -/** - * Return the number of listeners listening to a given event. - * - * @param {(String|Symbol)} event The event name. - * @returns {Number} The number of listeners. - * @public - */ -EventEmitter.prototype.listenerCount = function listenerCount(event) { - var evt = prefix ? prefix + event : event - , listeners = this._events[evt]; - - if (!listeners) return 0; - if (listeners.fn) return 1; - return listeners.length; -}; - -/** - * Calls each of the listeners registered for a given event. - * - * @param {(String|Symbol)} event The event name. - * @returns {Boolean} `true` if the event had listeners, else `false`. - * @public - */ -EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return false; - - var listeners = this._events[evt] - , len = arguments.length - , args - , i; - - if (listeners.fn) { - if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); - - switch (len) { - case 1: return listeners.fn.call(listeners.context), true; - case 2: return listeners.fn.call(listeners.context, a1), true; - case 3: return listeners.fn.call(listeners.context, a1, a2), true; - case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; - case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; - case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; - } - - for (i = 1, args = new Array(len -1); i < len; i++) { - args[i - 1] = arguments[i]; - } - - listeners.fn.apply(listeners.context, args); - } else { - var length = listeners.length - , j; - - for (i = 0; i < length; i++) { - if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); - - switch (len) { - case 1: listeners[i].fn.call(listeners[i].context); break; - case 2: listeners[i].fn.call(listeners[i].context, a1); break; - case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; - case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; - default: - if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { - args[j - 1] = arguments[j]; - } - - listeners[i].fn.apply(listeners[i].context, args); - } - } - } - - return true; -}; - -/** - * Add a listener for a given event. - * - * @param {(String|Symbol)} event The event name. - * @param {Function} fn The listener function. - * @param {*} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @public - */ -EventEmitter.prototype.on = function on(event, fn, context) { - return addListener(this, event, fn, context, false); -}; - -/** - * Add a one-time listener for a given event. - * - * @param {(String|Symbol)} event The event name. - * @param {Function} fn The listener function. - * @param {*} [context=this] The context to invoke the listener with. - * @returns {EventEmitter} `this`. - * @public - */ -EventEmitter.prototype.once = function once(event, fn, context) { - return addListener(this, event, fn, context, true); -}; - -/** - * Remove the listeners of a given event. - * - * @param {(String|Symbol)} event The event name. - * @param {Function} fn Only remove the listeners that match this function. - * @param {*} context Only remove the listeners that have this context. - * @param {Boolean} once Only remove one-time listeners. - * @returns {EventEmitter} `this`. - * @public - */ -EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { - var evt = prefix ? prefix + event : event; - - if (!this._events[evt]) return this; - if (!fn) { - clearEvent(this, evt); - return this; - } - - var listeners = this._events[evt]; - - if (listeners.fn) { - if ( - listeners.fn === fn && - (!once || listeners.once) && - (!context || listeners.context === context) - ) { - clearEvent(this, evt); - } - } else { - for (var i = 0, events = [], length = listeners.length; i < length; i++) { - if ( - listeners[i].fn !== fn || - (once && !listeners[i].once) || - (context && listeners[i].context !== context) - ) { - events.push(listeners[i]); - } - } - - // - // Reset the array, or remove it completely if we have no more listeners. - // - if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; - else clearEvent(this, evt); - } - - return this; -}; - -/** - * Remove all listeners, or those of the specified event. - * - * @param {(String|Symbol)} [event] The event name. - * @returns {EventEmitter} `this`. - * @public - */ -EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { - var evt; - - if (event) { - evt = prefix ? prefix + event : event; - if (this._events[evt]) clearEvent(this, evt); - } else { - this._events = new Events(); - this._eventsCount = 0; - } - - return this; -}; - -// -// Alias methods names because people roll like that. -// -EventEmitter.prototype.off = EventEmitter.prototype.removeListener; -EventEmitter.prototype.addListener = EventEmitter.prototype.on; - -// -// Expose the prefix. -// -EventEmitter.prefixed = prefix; - -// -// Allow `EventEmitter` to be imported as module namespace. -// -EventEmitter.EventEmitter = EventEmitter; - -// -// Expose the module. -// -if (true) { - module.exports = EventEmitter; -} - - -/***/ }), -/* 10 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH = __webpack_require__(16); -var GetValue = __webpack_require__(4); - -// Allowed types: - -// Implicit -// { -// x: 4 -// } -// -// From function -// { -// x: function () -// } -// -// Randomly pick one element from the array -// { -// x: [a, b, c, d, e, f] -// } -// -// Random integer between min and max: -// { -// x: { randInt: [min, max] } -// } -// -// Random float between min and max: -// { -// x: { randFloat: [min, max] } -// } - -/** - * [description] - * - * @function Phaser.Utils.Object.GetAdvancedValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {*} [description] - */ -var GetAdvancedValue = function (source, key, defaultValue) -{ - var value = GetValue(source, key, null); - - if (value === null) - { - return defaultValue; - } - else if (Array.isArray(value)) - { - return MATH.RND.pick(value); - } - else if (typeof value === 'object') - { - if (value.hasOwnProperty('randInt')) - { - return MATH.RND.integerInRange(value.randInt[0], value.randInt[1]); - } - else if (value.hasOwnProperty('randFloat')) - { - return MATH.RND.realInRange(value.randFloat[0], value.randFloat[1]); - } - } - else if (typeof value === 'function') - { - return value(key); - } - - return value; -}; - -module.exports = GetAdvancedValue; - - -/***/ }), -/* 11 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * The Game Object Factory is a Scene plugin that allows you to quickly create many common - * types of Game Objects and have them automatically registered with the Scene. - * - * Game Objects directly register themselves with the Factory and inject their own creation - * methods into the class. - * - * @class GameObjectFactory - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. - */ -var GameObjectFactory = new Class({ - - initialize: - - function GameObjectFactory (scene) - { - /** - * The Scene to which this Game Object Factory belongs. - * - * @name Phaser.GameObjects.GameObjectFactory#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene.Systems. - * - * @name Phaser.GameObjects.GameObjectFactory#systems - * @type {Phaser.Scenes.Systems} - * @protected - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * A reference to the Scene Display List. - * - * @name Phaser.GameObjects.GameObjectFactory#displayList - * @type {Phaser.GameObjects.DisplayList} - * @protected - * @since 3.0.0 - */ - this.displayList; - - /** - * A reference to the Scene Update List. - * - * @name Phaser.GameObjects.GameObjectFactory#updateList; - * @type {Phaser.GameObjects.UpdateList} - * @protected - * @since 3.0.0 - */ - this.updateList; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.GameObjects.GameObjectFactory#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.displayList = this.systems.displayList; - this.updateList = this.systems.updateList; - - this.systems.events.once('destroy', this.destroy, 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.GameObjects.GameObjectFactory#start - * @private - * @since 3.5.0 - */ - start: function () - { - this.systems.events.once('shutdown', this.shutdown, this); - }, - - /** - * Adds an existing Game Object to this Scene. - * - * If the Game Object renders, it will be added to the Display List. - * If it has a `preUpdate` method, it will be added to the Update List. - * - * @method Phaser.GameObjects.GameObjectFactory#existing - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - The child to be added to this Scene. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was added. - */ - existing: function (child) - { - if (child.renderCanvas || child.renderWebGL) - { - this.displayList.add(child); - } - - if (child.preUpdate) - { - this.updateList.add(child); - } - - return child; - }, - - /** - * 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 () - { - this.systems.events.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.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; - } - -}); - -// Static method called directly by the Game Object factory functions - -GameObjectFactory.register = function (factoryType, factoryFunction) -{ - if (!GameObjectFactory.prototype.hasOwnProperty(factoryType)) - { - GameObjectFactory.prototype[factoryType] = factoryFunction; - } -}; - -PluginCache.register('GameObjectFactory', GameObjectFactory, 'add'); - -module.exports = GameObjectFactory; - - -/***/ }), -/* 12 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Contains the plugins that Phaser uses globally and locally. -// These are the source objects, not instantiated. -var corePlugins = {}; - -// Contains the plugins that the dev has loaded into their game -// These are the source objects, not instantiated. -var customPlugins = {}; - -/** - * @typedef {object} CorePluginContainer - * - * @property {string} key - The unique name of this plugin in the core plugin cache. - * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. - * @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used. - * @property {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? - */ - -/** - * @typedef {object} CustomPluginContainer - * - * @property {string} key - The unique name of this plugin in the custom plugin cache. - * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. - */ - -var PluginCache = {}; - -/** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * - * @method Phaser.Plugins.PluginCache.register - * @since 3.8.0 - * - * @param {string} key - A reference used to get this plugin from the plugin cache. - * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. - * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. - * @param {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? - */ -PluginCache.register = function (key, plugin, mapping, custom) -{ - if (custom === undefined) { custom = false; } - - corePlugins[key] = { plugin: plugin, mapping: mapping, custom: custom }; -}; - -/** - * Stores a custom plugin in the global plugin cache. - * The key must be unique, within the scope of the cache. - * - * @method Phaser.Plugins.PluginCache.registerCustom - * @since 3.8.0 - * - * @param {string} key - A reference used to get this plugin from the plugin cache. - * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. - * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. - */ -PluginCache.registerCustom = function (key, plugin, mapping) -{ - customPlugins[key] = { plugin: plugin, mapping: mapping }; -}; - -/** - * Checks if the given key is already being used in the core plugin cache. - * - * @method Phaser.Plugins.PluginCache.hasCore - * @since 3.8.0 - * - * @param {string} key - The key to check for. - * - * @return {boolean} `true` if the key is already in use in the core cache, otherwise `false`. - */ -PluginCache.hasCore = function (key) -{ - return corePlugins.hasOwnProperty(key); -}; - -/** - * Checks if the given key is already being used in the custom plugin cache. - * - * @method Phaser.Plugins.PluginCache.hasCustom - * @since 3.8.0 - * - * @param {string} key - The key to check for. - * - * @return {boolean} `true` if the key is already in use in the custom cache, otherwise `false`. - */ -PluginCache.hasCustom = function (key) -{ - return customPlugins.hasOwnProperty(key); -}; - -/** - * Returns the core plugin object from the cache based on the given key. - * - * @method Phaser.Plugins.PluginCache.getCore - * @since 3.8.0 - * - * @param {string} key - The key of the core plugin to get. - * - * @return {CorePluginContainer} The core plugin object. - */ -PluginCache.getCore = function (key) -{ - return corePlugins[key]; -}; - -/** - * Returns the custom plugin object from the cache based on the given key. - * - * @method Phaser.Plugins.PluginCache.getCustom - * @since 3.8.0 - * - * @param {string} key - The key of the custom plugin to get. - * - * @return {CustomPluginContainer} The custom plugin object. - */ -PluginCache.getCustom = function (key) -{ - return customPlugins[key]; -}; - -/** - * Returns an object from the custom cache based on the given key that can be instantiated. - * - * @method Phaser.Plugins.PluginCache.getCustomClass - * @since 3.8.0 - * - * @param {string} key - The key of the custom plugin to get. - * - * @return {function} The custom plugin object. - */ -PluginCache.getCustomClass = function (key) -{ - return (customPlugins.hasOwnProperty(key)) ? customPlugins[key].plugin : null; -}; - -/** - * Removes a core plugin based on the given key. - * - * @method Phaser.Plugins.PluginCache.remove - * @since 3.8.0 - * - * @param {string} key - The key of the core plugin to remove. - */ -PluginCache.remove = function (key) -{ - if (corePlugins.hasOwnProperty(key)) - { - delete corePlugins[key]; - } -}; - -/** - * Removes a custom plugin based on the given key. - * - * @method Phaser.Plugins.PluginCache.removeCustom - * @since 3.8.0 - * - * @param {string} key - The key of the custom plugin to remove. - */ -PluginCache.removeCustom = function (key) -{ - if (customPlugins.hasOwnProperty(key)) - { - delete customPlugins[key]; - } -}; - -module.exports = PluginCache; - - -/***/ }), -/* 13 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * The Game Object Creator is a Scene plugin that allows you to quickly create many common - * types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically - * added to the Scene. - * - * Game Objects directly register themselves with the Creator and inject their own creation - * methods into the class. - * - * @class GameObjectCreator - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. - */ -var GameObjectCreator = new Class({ - - initialize: - - function GameObjectCreator (scene) - { - /** - * The Scene to which this Game Object Creator belongs. - * - * @name Phaser.GameObjects.GameObjectCreator#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene.Systems. - * - * @name Phaser.GameObjects.GameObjectCreator#systems - * @type {Phaser.Scenes.Systems} - * @protected - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * A reference to the Scene Display List. - * - * @name Phaser.GameObjects.GameObjectCreator#displayList - * @type {Phaser.GameObjects.DisplayList} - * @protected - * @since 3.0.0 - */ - this.displayList; - - /** - * A reference to the Scene Update List. - * - * @name Phaser.GameObjects.GameObjectCreator#updateList; - * @type {Phaser.GameObjects.UpdateList} - * @protected - * @since 3.0.0 - */ - this.updateList; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.GameObjects.GameObjectCreator#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.displayList = this.systems.displayList; - this.updateList = this.systems.updateList; - - this.systems.events.once('destroy', this.destroy, 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.GameObjects.GameObjectCreator#start - * @private - * @since 3.5.0 - */ - start: function () - { - this.systems.events.once('shutdown', this.shutdown, 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.GameObjects.GameObjectCreator#shutdown - * @private - * @since 3.0.0 - */ - shutdown: function () - { - this.systems.events.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.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; - } - -}); - -// Static method called directly by the Game Object creator functions - -GameObjectCreator.register = function (factoryType, factoryFunction) -{ - if (!GameObjectCreator.prototype.hasOwnProperty(factoryType)) - { - GameObjectCreator.prototype[factoryType] = factoryFunction; - } -}; - -PluginCache.register('GameObjectCreator', GameObjectCreator, 'make'); - -module.exports = GameObjectCreator; - - -/***/ }), -/* 14 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(31); -var GetPoint = __webpack_require__(135); -var GetPoints = __webpack_require__(294); -var Line = __webpack_require__(96); -var Random = __webpack_require__(154); - -/** - * @classdesc - * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) - * - * @class Rectangle - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width=0] - [description] - * @param {number} [height=0] - [description] - */ -var Rectangle = new Class({ - - initialize: - - function Rectangle (x, y, width, height) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = 0; } - if (height === undefined) { height = 0; } - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#width - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.width = width; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#height - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.height = height; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#contains - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [output,$return] - * - * @param {integer} quantity - [description] - * @param {number} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getRandomPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} [point] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setTo: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setEmpty: function () - { - return this.setTo(0, 0, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} [height=width] - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#isEmpty - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isEmpty: function () - { - return (this.width <= 0 || this.height <= 0); - }, - - /** - * Returns a Line object that corresponds to the top of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineA - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. - */ - getLineA: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.x, this.y, this.right, this.y); - - return line; - }, - - /** - * Returns a Line object that corresponds to the right of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineB - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. - */ - getLineB: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.right, this.y, this.right, this.bottom); - - return line; - }, - - /** - * Returns a Line object that corresponds to the bottom of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineC - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. - */ - getLineC: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.right, this.bottom, this.x, this.bottom); - - return line; - }, - - /** - * Returns a Line object that corresponds to the left of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineD - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. - */ - getLineD: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.x, this.bottom, this.x, this.y); - - return line; - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.x; - }, - - set: function (value) - { - if (value >= this.right) - { - this.width = 0; - } - else - { - this.width = this.right - value; - } - - this.x = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.x + this.width; - }, - - set: function (value) - { - if (value <= this.x) - { - this.width = 0; - } - else - { - this.width = value - this.x; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y; - }, - - set: function (value) - { - if (value >= this.bottom) - { - this.height = 0; - } - else - { - this.height = (this.bottom - value); - } - - this.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + this.height; - }, - - set: function (value) - { - if (value <= this.y) - { - this.height = 0; - } - else - { - this.height = value - this.y; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerX - * @type {number} - * @since 3.0.0 - */ - centerX: { - - get: function () - { - return this.x + (this.width / 2); - }, - - set: function (value) - { - this.x = value - (this.width / 2); - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerY - * @type {number} - * @since 3.0.0 - */ - centerY: { - - get: function () - { - return this.y + (this.height / 2); - }, - - set: function (value) - { - this.y = value - (this.height / 2); - } - - } - -}); - -module.exports = Rectangle; - - -/***/ }), -/* 15 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects.Components - */ - -module.exports = { - - Alpha: __webpack_require__(587), - Animation: __webpack_require__(302), - BlendMode: __webpack_require__(586), - ComputedSize: __webpack_require__(585), - Depth: __webpack_require__(584), - Flip: __webpack_require__(583), - GetBounds: __webpack_require__(582), - Mask: __webpack_require__(581), - MatrixStack: __webpack_require__(580), - Origin: __webpack_require__(579), - Pipeline: __webpack_require__(291), - ScaleMode: __webpack_require__(578), - ScrollFactor: __webpack_require__(577), - Size: __webpack_require__(576), - Texture: __webpack_require__(575), - Tint: __webpack_require__(574), - ToJSON: __webpack_require__(573), - Transform: __webpack_require__(572), - TransformMatrix: __webpack_require__(64), - Visible: __webpack_require__(571) - -}; - - -/***/ }), -/* 16 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RND = __webpack_require__(297); - -var MATH_CONST = { - - /** - * The value of PI * 2. - * - * @name Phaser.Math.PI2 - * @type {number} - * @since 3.0.0 - */ - PI2: Math.PI * 2, - - /** - * The value of PI * 0.5. - * - * @name Phaser.Math.TAU - * @type {number} - * @since 3.0.0 - */ - TAU: Math.PI * 0.5, - - /** - * An epsilon value (1.0e-6) - * - * @name Phaser.Math.EPSILON - * @type {number} - * @since 3.0.0 - */ - EPSILON: 1.0e-6, - - /** - * For converting degrees to radians (PI / 180) - * - * @name Phaser.Math.DEG_TO_RAD - * @type {number} - * @since 3.0.0 - */ - DEG_TO_RAD: Math.PI / 180, - - /** - * For converting radians to degrees (180 / PI) - * - * @name Phaser.Math.RAD_TO_DEG - * @type {number} - * @since 3.0.0 - */ - RAD_TO_DEG: 180 / Math.PI, - - /** - * An instance of the Random Number Generator. - * - * @name Phaser.Math.RND - * @type {Phaser.Math.RandomDataGenerator} - * @since 3.0.0 - */ - RND: new RND() - -}; - -module.exports = MATH_CONST; - - -/***/ }), -/* 17 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsPlainObject = __webpack_require__(8); - -// @param {boolean} deep - Perform a deep copy? -// @param {object} target - The target object to copy to. -// @return {object} The extended object. - -/** - * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ - * - * @function Phaser.Utils.Object.Extend - * @since 3.0.0 - * - * @return {object} [description] - */ -var Extend = function () -{ - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; - - // Handle a deep copy situation - if (typeof target === 'boolean') - { - deep = target; - target = arguments[1] || {}; - - // skip the boolean and the target - i = 2; - } - - // extend Phaser if only one argument is passed - if (length === i) - { - target = this; - --i; - } - - for (; i < length; i++) - { - // Only deal with non-null/undefined values - if ((options = arguments[i]) != null) - { - // Extend the base object - for (name in options) - { - src = target[name]; - copy = options[name]; - - // Prevent never-ending loop - if (target === copy) - { - continue; - } - - // Recurse if we're merging plain objects or arrays - if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) - { - if (copyIsArray) - { - copyIsArray = false; - clone = src && Array.isArray(src) ? src : []; - } - else - { - clone = src && IsPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[name] = Extend(deep, clone, copy); - - // Don't bring in undefined values - } - else if (copy !== undefined) - { - target[name] = copy; - } - } - } - } - - // Return the modified object - return target; -}; - -module.exports = Extend; - - -/***/ }), -/* 18 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var FILE_CONST = { - - /** - * The Loader is idle. - * - * @name Phaser.Loader.LOADER_IDLE - * @type {integer} - * @since 3.0.0 - */ - LOADER_IDLE: 0, - - /** - * The Loader is actively loading. - * - * @name Phaser.Loader.LOADER_LOADING - * @type {integer} - * @since 3.0.0 - */ - LOADER_LOADING: 1, - - /** - * The Loader is processing files is has loaded. - * - * @name Phaser.Loader.LOADER_PROCESSING - * @type {integer} - * @since 3.0.0 - */ - LOADER_PROCESSING: 2, - - /** - * The Loader has completed loading and processing. - * - * @name Phaser.Loader.LOADER_COMPLETE - * @type {integer} - * @since 3.0.0 - */ - LOADER_COMPLETE: 3, - - /** - * The Loader is shutting down. - * - * @name Phaser.Loader.LOADER_SHUTDOWN - * @type {integer} - * @since 3.0.0 - */ - LOADER_SHUTDOWN: 4, - - /** - * The Loader has been destroyed. - * - * @name Phaser.Loader.LOADER_DESTROYED - * @type {integer} - * @since 3.0.0 - */ - LOADER_DESTROYED: 5, - - /** - * File is in the load queue but not yet started - * - * @name Phaser.Loader.FILE_PENDING - * @type {integer} - * @since 3.0.0 - */ - FILE_PENDING: 10, - - /** - * File has been started to load by the loader (onLoad called) - * - * @name Phaser.Loader.FILE_LOADING - * @type {integer} - * @since 3.0.0 - */ - FILE_LOADING: 11, - - /** - * File has loaded successfully, awaiting processing - * - * @name Phaser.Loader.FILE_LOADED - * @type {integer} - * @since 3.0.0 - */ - FILE_LOADED: 12, - - /** - * File failed to load - * - * @name Phaser.Loader.FILE_FAILED - * @type {integer} - * @since 3.0.0 - */ - FILE_FAILED: 13, - - /** - * File is being processed (onProcess callback) - * - * @name Phaser.Loader.FILE_PROCESSING - * @type {integer} - * @since 3.0.0 - */ - FILE_PROCESSING: 14, - - /** - * The File has errored somehow during processing. - * - * @name Phaser.Loader.FILE_ERRORED - * @type {integer} - * @since 3.0.0 - */ - FILE_ERRORED: 16, - - /** - * File has finished processing. - * - * @name Phaser.Loader.FILE_COMPLETE - * @type {integer} - * @since 3.0.0 - */ - FILE_COMPLETE: 17, - - /** - * File has been destroyed - * - * @name Phaser.Loader.FILE_DESTROYED - * @type {integer} - * @since 3.0.0 - */ - FILE_DESTROYED: 18, - - /** - * File was populated from local data and doesn't need an HTTP request - * - * @name Phaser.Loader.FILE_POPULATED - * @type {integer} - * @since 3.0.0 - */ - FILE_POPULATED: 19 - -}; - -module.exports = FILE_CONST; - - -/***/ }), -/* 19 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var GetFastValue = __webpack_require__(1); -var GetURL = __webpack_require__(108); -var MergeXHRSettings = __webpack_require__(107); -var XHRLoader = __webpack_require__(169); -var XHRSettings = __webpack_require__(75); - -/** - * @typedef {object} FileConfig - * - * @property {string} type - The file type string (image, json, etc) for sorting within the Loader. - * @property {string} key - Unique cache key (unique within its file type) - * @property {string} [url] - The URL of the file, not including baseURL. - * @property {string} [path] - The path of the file, not including the baseURL. - * @property {string} [extension] - The default extension this file uses. - * @property {XMLHttpRequestResponseType} [responseType] - The responseType to be used by the XHR request. - * @property {(XHRSettingsObject|false)} [xhrSettings=false] - Custom XHR Settings specific to this file and merged with the Loader defaults. - * @property {any} [config] - A config object that can be used by file types to store transitional data. - */ - -/** - * @classdesc - * The base File class used by all File Types that the Loader can support. - * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. - * - * @class File - * @memberOf Phaser.Loader - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. - * @param {FileConfig} fileConfig - The file configuration object, as created by the file type. - */ -var File = new Class({ - - initialize: - - function File (loader, fileConfig) - { - /** - * A reference to the Loader that is going to load this file. - * - * @name Phaser.Loader.File#loader - * @type {Phaser.Loader.LoaderPlugin} - * @since 3.0.0 - */ - this.loader = loader; - - /** - * A reference to the Cache, or Texture Manager, that is going to store this file if it loads. - * - * @name Phaser.Loader.File#cache - * @type {(Phaser.Cache.BaseCache|Phaser.Textures.TextureManager)} - * @since 3.7.0 - */ - this.cache = GetFastValue(fileConfig, 'cache', false); - - /** - * The file type string (image, json, etc) for sorting within the Loader. - * - * @name Phaser.Loader.File#type - * @type {string} - * @since 3.0.0 - */ - this.type = GetFastValue(fileConfig, 'type', false); - - /** - * Unique cache key (unique within its file type) - * - * @name Phaser.Loader.File#key - * @type {string} - * @since 3.0.0 - */ - this.key = GetFastValue(fileConfig, 'key', false); - - var loadKey = this.key; - - if (loader.prefix && loader.prefix !== '') - { - this.key = loader.prefix + loadKey; - } - - if (!this.type || !this.key) - { - throw new Error('Error calling \'Loader.' + this.type + '\' invalid key provided.'); - } - - /** - * The URL of the file, not including baseURL. - * Automatically has Loader.path prepended to it. - * - * @name Phaser.Loader.File#url - * @type {string} - * @since 3.0.0 - */ - this.url = GetFastValue(fileConfig, 'url'); - - if (this.url === undefined) - { - this.url = loader.path + loadKey + '.' + GetFastValue(fileConfig, 'extension', ''); - } - else if (typeof(this.url) !== 'function') - { - this.url = loader.path + this.url; - } - - /** - * The final URL this file will load from, including baseURL and path. - * Set automatically when the Loader calls 'load' on this file. - * - * @name Phaser.Loader.File#src - * @type {string} - * @since 3.0.0 - */ - this.src = ''; - - /** - * The merged XHRSettings for this file. - * - * @name Phaser.Loader.File#xhrSettings - * @type {XHRSettingsObject} - * @since 3.0.0 - */ - this.xhrSettings = XHRSettings(GetFastValue(fileConfig, 'responseType', undefined)); - - if (GetFastValue(fileConfig, 'xhrSettings', false)) - { - this.xhrSettings = MergeXHRSettings(this.xhrSettings, GetFastValue(fileConfig, 'xhrSettings', {})); - } - - /** - * The XMLHttpRequest instance (as created by XHR Loader) that is loading this File. - * - * @name Phaser.Loader.File#xhrLoader - * @type {?XMLHttpRequest} - * @since 3.0.0 - */ - this.xhrLoader = null; - - /** - * The current state of the file. One of the FILE_CONST values. - * - * @name Phaser.Loader.File#state - * @type {integer} - * @since 3.0.0 - */ - this.state = (typeof(this.url) === 'function') ? CONST.FILE_POPULATED : CONST.FILE_PENDING; - - /** - * The total size of this file. - * Set by onProgress and only if loading via XHR. - * - * @name Phaser.Loader.File#bytesTotal - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.bytesTotal = 0; - - /** - * Updated as the file loads. - * Only set if loading via XHR. - * - * @name Phaser.Loader.File#bytesLoaded - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.bytesLoaded = -1; - - /** - * A percentage value between 0 and 1 indicating how much of this file has loaded. - * Only set if loading via XHR. - * - * @name Phaser.Loader.File#percentComplete - * @type {float} - * @default -1 - * @since 3.0.0 - */ - this.percentComplete = -1; - - /** - * For CORs based loading. - * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set) - * - * @name Phaser.Loader.File#crossOrigin - * @type {(string|undefined)} - * @since 3.0.0 - */ - this.crossOrigin = undefined; - - /** - * The processed file data, stored here after the file has loaded. - * - * @name Phaser.Loader.File#data - * @type {*} - * @since 3.0.0 - */ - this.data = undefined; - - /** - * A config object that can be used by file types to store transitional data. - * - * @name Phaser.Loader.File#config - * @type {*} - * @since 3.0.0 - */ - this.config = GetFastValue(fileConfig, 'config', {}); - - /** - * If this is a multipart file, i.e. an atlas and its json together, then this is a reference - * to the parent MultiFile. Set and used internally by the Loader or specific file types. - * - * @name Phaser.Loader.File#multiFile - * @type {?Phaser.Loader.MultiFile} - * @since 3.7.0 - */ - this.multiFile; - - /** - * Does this file have an associated linked file? Such as an image and a normal map. - * Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't - * actually bound by data, where-as a linkFile is. - * - * @name Phaser.Loader.File#linkFile - * @type {?Phaser.Loader.File} - * @since 3.7.0 - */ - this.linkFile; - }, - - /** - * Links this File with another, so they depend upon each other for loading and processing. - * - * @method Phaser.Loader.File#setLink - * @since 3.7.0 - * - * @param {Phaser.Loader.File} fileB - The file to link to this one. - */ - setLink: function (fileB) - { - this.linkFile = fileB; - - fileB.linkFile = this; - }, - - /** - * Resets the XHRLoader instance this file is using. - * - * @method Phaser.Loader.File#resetXHR - * @since 3.0.0 - */ - resetXHR: function () - { - if (this.xhrLoader) - { - this.xhrLoader.onload = undefined; - this.xhrLoader.onerror = undefined; - this.xhrLoader.onprogress = undefined; - } - }, - - /** - * Called by the Loader, starts the actual file downloading. - * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. - * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. - * - * @method Phaser.Loader.File#load - * @since 3.0.0 - */ - load: function () - { - if (this.state === CONST.FILE_POPULATED) - { - // Can happen for example in a JSONFile if they've provided a JSON object instead of a URL - this.loader.nextFile(this, true); - } - else - { - this.src = GetURL(this, this.loader.baseURL); - - if (this.src.indexOf('data:') === 0) - { - console.warn('Local data URIs are not supported: ' + this.key); - } - else - { - // The creation of this XHRLoader starts the load process going. - // It will automatically call the following, based on the load outcome: - // - // xhr.onload = this.onLoad - // xhr.onerror = this.onError - // xhr.onprogress = this.onProgress - - this.xhrLoader = XHRLoader(this, this.loader.xhr); - } - } - }, - - /** - * Called when the file finishes loading, is sent a DOM ProgressEvent. - * - * @method Phaser.Loader.File#onLoad - * @since 3.0.0 - * - * @param {XMLHttpRequest} xhr - The XMLHttpRequest that caused this onload event. - * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this load. - */ - onLoad: function (xhr, event) - { - var success = !(event.target && event.target.status !== 200); - - // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called. - if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) - { - success = false; - } - - this.resetXHR(); - - this.loader.nextFile(this, success); - }, - - /** - * Called if the file errors while loading, is sent a DOM ProgressEvent. - * - * @method Phaser.Loader.File#onError - * @since 3.0.0 - * - * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this error. - */ - onError: function () - { - this.resetXHR(); - - this.loader.nextFile(this, false); - }, - - /** - * Called during the file load progress. Is sent a DOM ProgressEvent. - * - * @method Phaser.Loader.File#onProgress - * @since 3.0.0 - * - * @param {ProgressEvent} event - The DOM ProgressEvent. - */ - onProgress: function (event) - { - if (event.lengthComputable) - { - this.bytesLoaded = event.loaded; - this.bytesTotal = event.total; - - this.percentComplete = Math.min((this.bytesLoaded / this.bytesTotal), 1); - - this.loader.emit('fileprogress', this, this.percentComplete); - } - }, - - /** - * Usually overridden by the FileTypes and is called by Loader.nextFile. - * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage. - * - * @method Phaser.Loader.File#onProcess - * @since 3.0.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.onProcessComplete(); - }, - - /** - * Called when the File has completed processing. - * Checks on the state of its multifile, if set. - * - * @method Phaser.Loader.File#onProcessComplete - * @since 3.7.0 - */ - onProcessComplete: function () - { - this.state = CONST.FILE_COMPLETE; - - if (this.multiFile) - { - this.multiFile.onFileComplete(this); - } - - this.loader.fileProcessComplete(this); - }, - - /** - * Called when the File has completed processing but it generated an error. - * Checks on the state of its multifile, if set. - * - * @method Phaser.Loader.File#onProcessError - * @since 3.7.0 - */ - onProcessError: function () - { - this.state = CONST.FILE_ERRORED; - - if (this.multiFile) - { - this.multiFile.onFileFailed(this); - } - - this.loader.fileProcessComplete(this); - }, - - /** - * Checks if a key matching the one used by this file exists in the target Cache or not. - * This is called automatically by the LoaderPlugin to decide if the file can be safely - * loaded or will conflict. - * - * @method Phaser.Loader.File#hasCacheConflict - * @since 3.7.0 - * - * @return {boolean} `true` if adding this file will cause a conflict, otherwise `false`. - */ - hasCacheConflict: function () - { - return (this.cache && this.cache.exists(this.key)); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * This method is often overridden by specific file types. - * - * @method Phaser.Loader.File#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.cache) - { - this.cache.add(this.key, this.data); - } - - this.pendingDestroy(); - }, - - /** - * You can listen for this event from the LoaderPlugin. It is dispatched _every time_ - * a file loads and is sent 3 arguments, which allow you to identify the file: - * - * ```javascript - * this.load.on('filecomplete', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * @event Phaser.Loader.File#fileCompleteEvent - * @param {string} key - The key of the file that just loaded and finished processing. - * @param {string} type - The type of the file that just loaded and finished processing. - * @param {any} data - The data of the file. - */ - - /** - * You can listen for this event from the LoaderPlugin. It is dispatched only once per - * file and you have to use a special listener handle to pick it up. - * - * The string of the event is based on the file type and the key you gave it, split up - * using hyphens. - * - * For example, if you have loaded an image with a key of `monster`, you can listen for it - * using the following: - * - * ```javascript - * this.load.on('filecomplete-image-monster', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * Or, if you have loaded a texture atlas with a key of `Level1`: - * - * ```javascript - * this.load.on('filecomplete-atlas-Level1', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: - * - * ```javascript - * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { - * // Your handler code - * }); - * ``` - * - * @event Phaser.Loader.File#singleFileCompleteEvent - * @param {any} data - The data of the file. - */ - - /** - * Called once the file has been added to its cache and is now ready for deletion from the Loader. - * It will emit a `filecomplete` event from the LoaderPlugin. - * - * @method Phaser.Loader.File#pendingDestroy - * @fires Phaser.Loader.File#fileCompleteEvent - * @fires Phaser.Loader.File#singleFileCompleteEvent - * @since 3.7.0 - */ - pendingDestroy: function (data) - { - if (data === undefined) { data = this.data; } - - var key = this.key; - var type = this.type; - - this.loader.emit('filecomplete', key, type, data); - this.loader.emit('filecomplete_' + type + '_' + key, key, type, data); - - this.loader.flagForRemoval(this); - }, - - /** - * Destroy this File and any references it holds. - * - * @method Phaser.Loader.File#destroy - * @since 3.7.0 - */ - destroy: function () - { - this.loader = null; - this.cache = null; - this.xhrSettings = null; - this.multiFile = null; - this.linkFile = null; - this.data = null; - } - -}); - -/** - * Static method for creating object URL using URL API and setting it as image 'src' attribute. - * If URL API is not supported (usually on old browsers) it falls back to creating Base64 encoded url using FileReader. - * - * @method Phaser.Loader.File.createObjectURL - * @static - * @param {HTMLImageElement} image - Image object which 'src' attribute should be set to object URL. - * @param {Blob} blob - A Blob object to create an object URL for. - * @param {string} defaultType - Default mime type used if blob type is not available. - */ -File.createObjectURL = function (image, blob, defaultType) -{ - if (typeof URL === 'function') - { - image.src = URL.createObjectURL(blob); - } - else - { - var reader = new FileReader(); - - reader.onload = function () - { - image.removeAttribute('crossOrigin'); - image.src = 'data:' + (blob.type || defaultType) + ';base64,' + reader.result.split(',')[1]; - }; - - reader.onerror = image.onerror; - - reader.readAsDataURL(blob); - } -}; - -/** - * Static method for releasing an existing object URL which was previously created - * by calling {@link File#createObjectURL} method. - * - * @method Phaser.Loader.File.revokeObjectURL - * @static - * @param {HTMLImageElement} image - Image object which 'src' attribute should be revoked. - */ -File.revokeObjectURL = function (image) -{ - if (typeof URL === 'function') - { - URL.revokeObjectURL(image.src); - } -}; - -module.exports = File; - - -/***/ }), -/* 20 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Global consts. - * - * @ignore - */ - -var CONST = { - - /** - * Phaser Release Version - * - * @name Phaser.VERSION - * @readOnly - * @type {string} - * @since 3.0.0 - */ - VERSION: '3.10.1', - - BlendModes: __webpack_require__(51), - - ScaleModes: __webpack_require__(59), - - /** - * AUTO Detect Renderer. - * - * @name Phaser.AUTO - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - AUTO: 0, - - /** - * Canvas Renderer. - * - * @name Phaser.CANVAS - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - CANVAS: 1, - - /** - * WebGL Renderer. - * - * @name Phaser.WEBGL - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - WEBGL: 2, - - /** - * Headless Renderer. - * - * @name Phaser.HEADLESS - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - HEADLESS: 3, - - /** - * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead - * to help you remember what the value is doing in your code. - * - * @name Phaser.FOREVER - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - FOREVER: -1, - - /** - * Direction constant. - * - * @name Phaser.NONE - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - NONE: 4, - - /** - * Direction constant. - * - * @name Phaser.UP - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - UP: 5, - - /** - * Direction constant. - * - * @name Phaser.DOWN - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - DOWN: 6, - - /** - * Direction constant. - * - * @name Phaser.LEFT - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - LEFT: 7, - - /** - * Direction constant. - * - * @name Phaser.RIGHT - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - RIGHT: 8 - -}; - -module.exports = CONST; - - -/***/ }), -/* 21 */, -/* 22 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(20); -var Smoothing = __webpack_require__(131); - -// The pool into which the canvas elements are placed. -var pool = []; - -// Automatically apply smoothing(false) to created Canvas elements -var _disableContextSmoothing = false; - -/** - * The CanvasPool is a global static object, that allows Phaser to recycle and pool 2D Context Canvas DOM elements. - * It does not pool WebGL Contexts, because once the context options are set they cannot be modified again, - * which is useless for some of the Phaser pipelines / renderer. - * - * This singleton is instantiated as soon as Phaser loads, before a Phaser.Game instance has even been created. - * Which means all instances of Phaser Games on the same page can share the one single pool. - * - * @namespace Phaser.Display.Canvas.CanvasPool - * @since 3.0.0 - */ -var CanvasPool = function () -{ - /** - * Creates a new Canvas DOM element, or pulls one from the pool if free. - * - * @function Phaser.Display.Canvas.CanvasPool.create - * @since 3.0.0 - * - * @param {*} parent - The parent of the Canvas object. - * @param {integer} [width=1] - The width of the Canvas. - * @param {integer} [height=1] - The height of the Canvas. - * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. - * @param {boolean} [selfParent=false] - Use the generated Canvas element as the parent? - * - * @return {HTMLCanvasElement} [description] - */ - var create = function (parent, width, height, canvasType, selfParent) - { - if (width === undefined) { width = 1; } - if (height === undefined) { height = 1; } - if (canvasType === undefined) { canvasType = CONST.CANVAS; } - if (selfParent === undefined) { selfParent = false; } - - var canvas; - var container = first(canvasType); - - if (container === null) - { - container = { - parent: parent, - canvas: document.createElement('canvas'), - type: canvasType - }; - - if (canvasType === CONST.CANVAS) - { - pool.push(container); - } - - canvas = container.canvas; - } - else - { - container.parent = parent; - - canvas = container.canvas; - } - - if (selfParent) - { - container.parent = canvas; - } - - canvas.width = width; - canvas.height = height; - - if (_disableContextSmoothing && canvasType === CONST.CANVAS) - { - Smoothing.disable(canvas.getContext('2d')); - } - - return canvas; - }; - - /** - * Creates a new Canvas DOM element, or pulls one from the pool if free. - * - * @function Phaser.Display.Canvas.CanvasPool.create2D - * @since 3.0.0 - * - * @param {*} parent - The parent of the Canvas object. - * @param {integer} [width=1] - The width of the Canvas. - * @param {integer} [height=1] - The height of the Canvas. - * - * @return {HTMLCanvasElement} [description] - */ - var create2D = function (parent, width, height) - { - return create(parent, width, height, CONST.CANVAS); - }; - - /** - * Creates a new Canvas DOM element, or pulls one from the pool if free. - * - * @function Phaser.Display.Canvas.CanvasPool.createWebGL - * @since 3.0.0 - * - * @param {*} parent - The parent of the Canvas object. - * @param {integer} [width=1] - The width of the Canvas. - * @param {integer} [height=1] - The height of the Canvas. - * - * @return {HTMLCanvasElement} [description] - */ - var createWebGL = function (parent, width, height) - { - return create(parent, width, height, CONST.WEBGL); - }; - - /** - * Gets the first free canvas index from the pool. - * - * @function Phaser.Display.Canvas.CanvasPool.first - * @since 3.0.0 - * - * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. - * - * @return {HTMLCanvasElement} [description] - */ - var first = function (canvasType) - { - if (canvasType === undefined) { canvasType = CONST.CANVAS; } - - if (canvasType === CONST.WEBGL) - { - return null; - } - - for (var i = 0; i < pool.length; i++) - { - var container = pool[i]; - - if (!container.parent && container.type === canvasType) - { - return container; - } - } - - return null; - }; - - /** - * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. - * The canvas has its width and height set to 1, and its parent attribute nulled. - * - * @function Phaser.Display.Canvas.CanvasPool.remove - * @since 3.0.0 - * - * @param {*} parent - [description] - */ - var remove = function (parent) - { - // Check to see if the parent is a canvas object - var isCanvas = parent instanceof HTMLCanvasElement; - - pool.forEach(function (container) - { - if ((isCanvas && container.canvas === parent) || (!isCanvas && container.parent === parent)) - { - container.parent = null; - container.canvas.width = 1; - container.canvas.height = 1; - } - }); - }; - - /** - * Gets the total number of used canvas elements in the pool. - * - * @function Phaser.Display.Canvas.CanvasPool.total - * @since 3.0.0 - * - * @return {integer} [description] - */ - var total = function () - { - var c = 0; - - pool.forEach(function (container) - { - if (container.parent) - { - c++; - } - }); - - return c; - }; - - /** - * Gets the total number of free canvas elements in the pool. - * - * @function Phaser.Display.Canvas.CanvasPool.free - * @since 3.0.0 - * - * @return {integer} [description] - */ - var free = function () - { - return pool.length - total(); - }; - - /** - * Disable context smoothing on any new Canvas element created. - * - * @function Phaser.Display.Canvas.CanvasPool.disableSmoothing - * @since 3.0.0 - */ - var disableSmoothing = function () - { - _disableContextSmoothing = true; - }; - - /** - * Enable context smoothing on any new Canvas element created. - * - * @function Phaser.Display.Canvas.CanvasPool.enableSmoothing - * @since 3.0.0 - */ - var enableSmoothing = function () - { - _disableContextSmoothing = false; - }; - - return { - create2D: create2D, - create: create, - createWebGL: createWebGL, - disableSmoothing: disableSmoothing, - enableSmoothing: enableSmoothing, - first: first, - free: free, - pool: pool, - remove: remove, - total: total - }; -}; - -// If we export the called function here, it'll only be invoked once (not every time it's required). -module.exports = CanvasPool(); - - -/***/ }), -/* 23 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Force a value within the boundaries by clamping it to the range `min`, `max`. - * - * @function Phaser.Math.Clamp - * @since 3.0.0 - * - * @param {number} value - The value to be clamped. - * @param {number} min - The minimum bounds. - * @param {number} max - The maximum bounds. - * - * @return {number} The clamped value. - */ -var Clamp = function (value, min, max) -{ - return Math.max(min, Math.min(max, value)); -}; - -module.exports = Clamp; - - -/***/ }), -/* 24 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlendModes = __webpack_require__(51); -var GetAdvancedValue = __webpack_require__(10); -var ScaleModes = __webpack_require__(59); - -/** - * @typedef {object} GameObjectConfig - * - * @property {number} [x=0] - The x position of the Game Object. - * @property {number} [y=0] - The y position of the Game Object. - * @property {number} [depth=0] - The depth of the GameObject. - * @property {boolean} [flipX=false] - The horizontally flipped state of the Game Object. - * @property {boolean} [flipY=false] - The vertically flipped state of the Game Object. - * @property {?(number|object)} [scale=null] - The scale of the GameObject. - * @property {?(number|object)} [scrollFactor=null] - The scroll factor of the GameObject. - * @property {number} [rotation=0] - The rotation angle of the Game Object, in radians. - * @property {?number} [angle=null] - The rotation angle of the Game Object, in degrees. - * @property {number} [alpha=1] - The alpha (opacity) of the Game Object. - * @property {?(number|object)} [origin=null] - The origin of the Game Object. - * @property {number} [scaleMode=ScaleModes.DEFAULT] - The scale mode of the GameObject. - * @property {number} [blendMode=BlendModes.DEFAULT] - The blend mode of the GameObject. - * @property {boolean} [visible=true] - The visible state of the Game Object. - * @property {boolean} [add=true] - Add the GameObject to the scene. - */ - -/** - * Builds a Game Object using the provided configuration object. - * - * @function Phaser.GameObjects.BuildGameObject - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - A reference to the Scene. - * @param {Phaser.GameObjects.GameObject} gameObject - The initial GameObject. - * @param {GameObjectConfig} config - The config to build the GameObject with. - * - * @return {Phaser.GameObjects.GameObject} The built Game Object. - */ -var BuildGameObject = function (scene, gameObject, config) -{ - // Position - - gameObject.x = GetAdvancedValue(config, 'x', 0); - gameObject.y = GetAdvancedValue(config, 'y', 0); - gameObject.depth = GetAdvancedValue(config, 'depth', 0); - - // Flip - - gameObject.flipX = GetAdvancedValue(config, 'flipX', false); - gameObject.flipY = GetAdvancedValue(config, 'flipY', false); - - // Scale - // Either: { scale: 2 } or { scale: { x: 2, y: 2 }} - - var scale = GetAdvancedValue(config, 'scale', null); - - if (typeof scale === 'number') - { - gameObject.setScale(scale); - } - else if (scale !== null) - { - gameObject.scaleX = GetAdvancedValue(scale, 'x', 1); - gameObject.scaleY = GetAdvancedValue(scale, 'y', 1); - } - - // ScrollFactor - // Either: { scrollFactor: 2 } or { scrollFactor: { x: 2, y: 2 }} - - var scrollFactor = GetAdvancedValue(config, 'scrollFactor', null); - - if (typeof scrollFactor === 'number') - { - gameObject.setScrollFactor(scrollFactor); - } - else if (scrollFactor !== null) - { - gameObject.scrollFactorX = GetAdvancedValue(scrollFactor, 'x', 1); - gameObject.scrollFactorY = GetAdvancedValue(scrollFactor, 'y', 1); - } - - // Rotation - - gameObject.rotation = GetAdvancedValue(config, 'rotation', 0); - - var angle = GetAdvancedValue(config, 'angle', null); - - if (angle !== null) - { - gameObject.angle = angle; - } - - // Alpha - - gameObject.alpha = GetAdvancedValue(config, 'alpha', 1); - - // Origin - // Either: { origin: 0.5 } or { origin: { x: 0.5, y: 0.5 }} - - var origin = GetAdvancedValue(config, 'origin', null); - - if (typeof origin === 'number') - { - gameObject.setOrigin(origin); - } - else if (origin !== null) - { - var ox = GetAdvancedValue(origin, 'x', 0.5); - var oy = GetAdvancedValue(origin, 'y', 0.5); - - gameObject.setOrigin(ox, oy); - } - - // ScaleMode - - gameObject.scaleMode = GetAdvancedValue(config, 'scaleMode', ScaleModes.DEFAULT); - - // BlendMode - - gameObject.blendMode = GetAdvancedValue(config, 'blendMode', BlendModes.NORMAL); - - // Visible - - gameObject.visible = GetAdvancedValue(config, 'visible', true); - - // Add to Scene - - var add = GetAdvancedValue(config, 'add', true); - - if (add) - { - scene.sys.displayList.add(gameObject); - } - - if (gameObject.preUpdate) - { - scene.sys.updateList.add(gameObject); - } - - return gameObject; -}; - -module.exports = BuildGameObject; - - -/***/ }), -/* 25 */, -/* 26 */, -/* 27 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Renderer.WebGL.Utils - * @since 3.0.0 - */ -module.exports = { - - /** - * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 - * - * @function Phaser.Renderer.WebGL.Utils.getTintFromFloats - * @since 3.0.0 - * - * @param {number} r - Red component in a range from 0.0 to 1.0 - * @param {number} g - [description] - * @param {number} b - [description] - * @param {number} a - Alpha component in a range from 0.0 to 1.0 - * - * @return {number} [description] - */ - getTintFromFloats: function (r, g, b, a) - { - var ur = ((r * 255.0)|0) & 0xFF; - var ug = ((g * 255.0)|0) & 0xFF; - var ub = ((b * 255.0)|0) & 0xFF; - var ua = ((a * 255.0)|0) & 0xFF; - - return ((ua << 24) | (ur << 16) | (ug << 8) | ub) >>> 0; - }, - - /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 - * - * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha - * @since 3.0.0 - * - * @param {number} rgb - Uint24 representing RGB components - * @param {number} a - Float32 representing Alpha component - * - * @return {number} Packed RGBA as Uint32 - */ - getTintAppendFloatAlpha: function (rgb, a) - { - var ua = ((a * 255.0)|0) & 0xFF; - return ((ua << 24) | rgb) >>> 0; - }, - - /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a - * swizzled Uint32 - * - * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlphaAndSwap - * @since 3.0.0 - * - * @param {number} rgb - Uint24 representing RGB components - * @param {number} a - Float32 representing Alpha component - * - * @return {number} Packed RGBA as Uint32 - */ - getTintAppendFloatAlphaAndSwap: function (rgb, a) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - var ua = ((a * 255.0)|0) & 0xFF; - - return ((ua << 24) | (ub << 16) | (ug << 8) | ur) >>> 0; - }, - - /** - * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 - * - * @function Phaser.Renderer.WebGL.Utils.getFloatsFromUintRGB - * @since 3.0.0 - * - * @param {number} rgb - RGB packed as a Uint24 - * - * @return {array} Array of floats representing each component as a float - */ - getFloatsFromUintRGB: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - return [ ur / 255.0, ug / 255.0, ub / 255.0 ]; - }, - - /** - * Counts how many attributes of 32 bits a vertex has - * - * @function Phaser.Renderer.WebGL.Utils.getComponentCount - * @since 3.0.0 - * - * @param {array} attributes - Array of attributes - * @param {WebGLRenderingContext} glContext - WebGLContext used for check types - * - * @return {number} Count of 32 bit attributes in vertex - */ - getComponentCount: function (attributes, glContext) - { - var count = 0; - - for (var index = 0; index < attributes.length; ++index) - { - var element = attributes[index]; - - if (element.type === glContext.FLOAT) - { - count += element.size; - } - else - { - count += 1; // We'll force any other type to be 32 bit. for now - } - } - - return count; - } - -}; - - -/***/ }), -/* 28 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var GetValue = __webpack_require__(4); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.JSONFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the JSON Cache. - * @property {string|any} [url] - The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly added to the Cache. - * @property {string} [extension='json'] - The default file extension to use if no url is provided. - * @property {string} [dataKey] - If specified instead of the whole JSON file being parsed and added to the Cache, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#json method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#json. - * - * @class JSONFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. - */ -var JSONFile = new Class({ - - Extends: File, - - initialize: - - // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object - // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing - - function JSONFile (loader, key, url, xhrSettings, dataKey) - { - var extension = 'json'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - dataKey = GetFastValue(config, 'dataKey', dataKey); - } - - var fileConfig = { - type: 'json', - cache: loader.cacheManager.json, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings, - config: dataKey - }; - - File.call(this, loader, fileConfig); - - if (IsPlainObject(url)) - { - // Object provided instead of a URL, so no need to actually load it (populate data with value) - if (dataKey) - { - this.data = GetValue(url, dataKey); - } - else - { - this.data = url; - } - - this.state = CONST.FILE_POPULATED; - } - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.JSONFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - if (this.state !== CONST.FILE_POPULATED) - { - this.state = CONST.FILE_PROCESSING; - - var json = JSON.parse(this.xhrLoader.responseText); - - var key = this.config; - - if (typeof key === 'string') - { - this.data = GetValue(json, key, json); - } - else - { - this.data = json; - } - } - - this.onProcessComplete(); - } - -}); - -/** - * Adds a JSON file, or array of JSON files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.json('wavedata', 'files/AlienWaveData.json'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the JSON Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.json({ - * key: 'wavedata', - * url: 'files/AlienWaveData.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.json('wavedata', 'files/AlienWaveData.json'); - * // and later in your game ... - * var data = this.cache.json.get('wavedata'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the JSON Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" - * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, - * rather than the whole file. For example, if your JSON data had a structure like this: - * - * ```json - * { - * "level1": { - * "baddies": { - * "aliens": {}, - * "boss": {} - * } - * }, - * "level2": {}, - * "level3": {} - * } - * ``` - * - * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. - * - * Note: The ability to load this type of file will only be available if the JSON File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#json - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig|Phaser.Loader.FileTypes.JSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('json', function (key, url, dataKey, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new JSONFile(this, key[i])); - } - } - else - { - this.addFile(new JSONFile(this, key, url, xhrSettings, dataKey)); - } - - return this; -}); - -module.exports = JSONFile; - - -/***/ }), -/* 29 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Tests if the start and end indexes are a safe range for the given array. - * - * @function Phaser.Utils.Array.SafeRange - * @since 3.4.0 - * - * @param {array} array - The array to check. - * @param {integer} startIndex - The start index. - * @param {integer} endIndex - The end index. - * @param {boolean} [throwError=true] - Throw an error if the range is out of bounds. - * - * @return {boolean} True if the range is safe, otherwise false. - */ -var SafeRange = function (array, startIndex, endIndex, throwError) -{ - var len = array.length; - - if (startIndex < 0 || - startIndex > len || - startIndex >= endIndex || - endIndex > len || - startIndex + endIndex > len) - { - if (throwError) - { - throw new Error('Range Error: Values outside acceptable range'); - } - - return false; - } - else - { - return true; - } -}; - -module.exports = SafeRange; - - -/***/ }), -/* 30 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetColor = __webpack_require__(152); -var GetColor32 = __webpack_require__(284); - -/** - * @classdesc - * The Color class holds a single color value and allows for easy modification and reading of it. - * - * @class Color - * @memberOf Phaser.Display - * @constructor - * @since 3.0.0 - * - * @param {integer} [red=0] - The red color value. A number between 0 and 255. - * @param {integer} [green=0] - The green color value. A number between 0 and 255. - * @param {integer} [blue=0] - The blue color value. A number between 0 and 255. - * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. - */ -var Color = new Class({ - - initialize: - - function Color (red, green, blue, alpha) - { - if (red === undefined) { red = 0; } - if (green === undefined) { green = 0; } - if (blue === undefined) { blue = 0; } - if (alpha === undefined) { alpha = 255; } - - /** - * The internal red color value. - * - * @name Phaser.Display.Color#r - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.r = 0; - - /** - * The internal green color value. - * - * @name Phaser.Display.Color#g - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.g = 0; - - /** - * The internal blue color value. - * - * @name Phaser.Display.Color#b - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.b = 0; - - /** - * The internal alpha color value. - * - * @name Phaser.Display.Color#a - * @type {number} - * @private - * @default 255 - * @since 3.0.0 - */ - this.a = 255; - - /** - * An array containing the calculated color values for WebGL use. - * - * @name Phaser.Display.Color#gl - * @type {number[]} - * @since 3.0.0 - */ - this.gl = [ 0, 0, 0, 1 ]; - - /** - * Pre-calculated internal color value. - * - * @name Phaser.Display.Color#_color - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._color = 0; - - /** - * Pre-calculated internal color32 value. - * - * @name Phaser.Display.Color#_color32 - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._color32 = 0; - - /** - * Pre-calculated internal color rgb string value. - * - * @name Phaser.Display.Color#_rgba - * @type {string} - * @private - * @default '' - * @since 3.0.0 - */ - this._rgba = ''; - - this.setTo(red, green, blue, alpha); - }, - - /** - * Sets this color to be transparent. Sets all values to zero. - * - * @method Phaser.Display.Color#transparent - * @since 3.0.0 - * - * @return {Phaser.Display.Color} This Color object. - */ - transparent: function () - { - this.red = 0; - this.green = 0; - this.blue = 0; - this.alpha = 0; - - return this.update(); - }, - - /** - * Sets the color of this Color component. - * - * @method Phaser.Display.Color#setTo - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. - * - * @return {Phaser.Display.Color} This Color object. - */ - setTo: function (red, green, blue, alpha) - { - if (alpha === undefined) { alpha = 255; } - - this.red = red; - this.green = green; - this.blue = blue; - this.alpha = alpha; - - return this.update(); - }, - - /** - * Sets the red, green, blue and alpha GL values of this Color component. - * - * @method Phaser.Display.Color#setGLTo - * @since 3.0.0 - * - * @param {float} red - The red color value. A number between 0 and 1. - * @param {float} green - The green color value. A number between 0 and 1. - * @param {float} blue - The blue color value. A number between 0 and 1. - * @param {float} [alpha=1] - The alpha value. A number between 0 and 1. - * - * @return {Phaser.Display.Color} This Color object. - */ - setGLTo: function (red, green, blue, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.redGL = red; - this.greenGL = green; - this.blueGL = blue; - this.alphaGL = alpha; - - return this.update(); - }, - - /** - * Sets the color based on the color object given. - * - * @method Phaser.Display.Color#setFromRGB - * @since 3.0.0 - * - * @param {InputColorObject} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. - * - * @return {Phaser.Display.Color} This Color object. - */ - setFromRGB: function (color) - { - this.red = color.r; - this.green = color.g; - this.blue = color.b; - - if (color.hasOwnProperty('a')) - { - this.alpha = color.a; - } - - return this.update(); - }, - - /** - * Updates the internal cache values. - * - * @method Phaser.Display.Color#update - * @since 3.0.0 - * - * @return {Phaser.Display.Color} This Color object. - */ - update: function () - { - this._color = GetColor(this.r, this.g, this.b); - this._color32 = GetColor32(this.r, this.g, this.b, this.a); - this._rgba = 'rgba(' + this.r + ',' + this.g + ',' + this.b + ',' + (this.a / 255) + ')'; - - return this; - }, - - /** - * Returns a new Color component using the values from this one. - * - * @method Phaser.Display.Color#clone - * @since 3.0.0 - * - * @return {Phaser.Display.Color} A new Color object. - */ - clone: function () - { - return new Color(this.r, this.g, this.b, this.a); - }, - - /** - * The color of this Color component, not including the alpha channel. - * - * @name Phaser.Display.Color#color - * @type {number} - * @readOnly - * @since 3.0.0 - */ - color: { - - get: function () - { - return this._color; - } - - }, - - /** - * The color of this Color component, including the alpha channel. - * - * @name Phaser.Display.Color#color32 - * @type {number} - * @readOnly - * @since 3.0.0 - */ - color32: { - - get: function () - { - return this._color32; - } - - }, - - /** - * The color of this Color component as a string which can be used in CSS color values. - * - * @name Phaser.Display.Color#rgba - * @type {string} - * @readOnly - * @since 3.0.0 - */ - rgba: { - - get: function () - { - return this._rgba; - } - - }, - - /** - * The red color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#redGL - * @type {float} - * @since 3.0.0 - */ - redGL: { - - get: function () - { - return this.gl[0]; - }, - - set: function (value) - { - this.gl[0] = Math.min(Math.abs(value), 1); - - this.r = Math.floor(this.gl[0] * 255); - - this.update(); - } - - }, - - /** - * The green color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#greenGL - * @type {float} - * @since 3.0.0 - */ - greenGL: { - - get: function () - { - return this.gl[1]; - }, - - set: function (value) - { - this.gl[1] = Math.min(Math.abs(value), 1); - - this.g = Math.floor(this.gl[1] * 255); - - this.update(); - } - - }, - - /** - * The blue color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#blueGL - * @type {float} - * @since 3.0.0 - */ - blueGL: { - - get: function () - { - return this.gl[2]; - }, - - set: function (value) - { - this.gl[2] = Math.min(Math.abs(value), 1); - - this.b = Math.floor(this.gl[2] * 255); - - this.update(); - } - - }, - - /** - * The alpha color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#alphaGL - * @type {float} - * @since 3.0.0 - */ - alphaGL: { - - get: function () - { - return this.gl[3]; - }, - - set: function (value) - { - this.gl[3] = Math.min(Math.abs(value), 1); - - this.a = Math.floor(this.gl[3] * 255); - - this.update(); - } - - }, - - /** - * The red color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#red - * @type {number} - * @since 3.0.0 - */ - red: { - - get: function () - { - return this.r; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.r = Math.min(value, 255); - - this.gl[0] = value / 255; - - this.update(); - } - - }, - - /** - * The green color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#green - * @type {number} - * @since 3.0.0 - */ - green: { - - get: function () - { - return this.g; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.g = Math.min(value, 255); - - this.gl[1] = value / 255; - - this.update(); - } - - }, - - /** - * The blue color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#blue - * @type {number} - * @since 3.0.0 - */ - blue: { - - get: function () - { - return this.b; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.b = Math.min(value, 255); - - this.gl[2] = value / 255; - - this.update(); - } - - }, - - /** - * The alpha color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#alpha - * @type {number} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this.a; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.a = Math.min(value, 255); - - this.gl[3] = value / 255; - - this.update(); - } - - } - -}); - -module.exports = Color; - - -/***/ }), -/* 31 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (rect, x, y) -{ - if (rect.width <= 0 || rect.height <= 0) - { - return false; - } - - return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); -}; - -module.exports = Contains; - - -/***/ }), -/* 32 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Circle contains the given x / y coordinates. - * - * @function Phaser.Geom.Circle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {number} x - The x coordinate to check within the circle. - * @param {number} y - The y coordinate to check within the circle. - * - * @return {boolean} True if the coordinates are within the circle, otherwise false. - */ -var Contains = function (circle, x, y) -{ - // Check if x/y are within the bounds first - if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) - { - var dx = (circle.x - x) * (circle.x - x); - var dy = (circle.y - y) * (circle.y - y); - - return (dx + dy) <= (circle.radius * circle.radius); - } - else - { - return false; - } -}; - -module.exports = Contains; - - -/***/ }), -/* 33 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Shallow Object Clone. Will not clone nested objects. - * - * @function Phaser.Utils.Object.Clone - * @since 3.0.0 - * - * @param {object} obj - the object from which to clone - * - * @return {object} a new object with the same properties as the input obj - */ -var Clone = function (obj) -{ - var clone = {}; - - for (var key in obj) - { - if (Array.isArray(obj[key])) - { - clone[key] = obj[key].slice(0); - } - else - { - clone[key] = obj[key]; - } - } - - return clone; -}; - -module.exports = Clone; - - -/***/ }), -/* 34 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var SpriteRender = __webpack_require__(556); - -/** - * @classdesc - * A Sprite Game Object. - * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - * - * @class Sprite - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Sprite = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - SpriteRender - ], - - initialize: - - function Sprite (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Sprite'); - - /** - * The Animation Controller of this Sprite. - * - * @name Phaser.GameObjects.Sprite#anims - * @type {Phaser.GameObjects.Components.Animation} - * @since 3.0.0 - */ - this.anims = new Components.Animation(this); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - }, - - /** - * Update this Sprite's animations. - * - * @method Phaser.GameObjects.Sprite#preUpdate - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp. - * @param {number} delta - The delta time, in ms, elapsed since the last frame. - */ - preUpdate: function (time, delta) - { - this.anims.update(time, delta); - }, - - /** - * Start playing the given animation. - * - * @method Phaser.GameObjects.Sprite#play - * @since 3.0.0 - * - * @param {string} key - The string-based key of the animation to play. - * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. - * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. - * - * @return {Phaser.GameObjects.Sprite} This Game Object. - */ - play: function (key, ignoreIfPlaying, startFrame) - { - this.anims.play(key, ignoreIfPlaying, startFrame); - - return this; - }, - - /** - * Build a JSON representation of this Sprite. - * - * @method Phaser.GameObjects.Sprite#toJSON - * @since 3.0.0 - * - * @return {JSONGameObject} A JSON representation of the Game Object. - */ - toJSON: function () - { - var data = Components.ToJSON(this); - - // Extra Sprite data is added here - - return data; - } - -}); - -module.exports = Sprite; - - -/***/ }), -/* 35 */, -/* 36 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after - * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont. - * - * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. - * - * @class MultiFile - * @memberOf Phaser.Loader - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. - * @param {string} type - The file type string for sorting within the Loader. - * @param {string} key - The key of the file within the loader. - * @param {Phaser.Loader.File[]} files - An array of Files that make-up this MultiFile. - */ -var MultiFile = new Class({ - - initialize: - - function MultiFile (loader, type, key, files) - { - /** - * A reference to the Loader that is going to load this file. - * - * @name Phaser.Loader.MultiFile#loader - * @type {Phaser.Loader.LoaderPlugin} - * @since 3.7.0 - */ - this.loader = loader; - - /** - * The file type string for sorting within the Loader. - * - * @name Phaser.Loader.MultiFile#type - * @type {string} - * @since 3.7.0 - */ - this.type = type; - - /** - * Unique cache key (unique within its file type) - * - * @name Phaser.Loader.MultiFile#key - * @type {string} - * @since 3.7.0 - */ - this.key = key; - - /** - * Array of files that make up this MultiFile. - * - * @name Phaser.Loader.MultiFile#files - * @type {Phaser.Loader.File[]} - * @since 3.7.0 - */ - this.files = files; - - /** - * The completion status of this MultiFile. - * - * @name Phaser.Loader.MultiFile#complete - * @type {boolean} - * @default false - * @since 3.7.0 - */ - this.complete = false; - - /** - * The number of files to load. - * - * @name Phaser.Loader.MultiFile#pending - * @type {integer} - * @since 3.7.0 - */ - - this.pending = files.length; - - /** - * The number of files that failed to load. - * - * @name Phaser.Loader.MultiFile#failed - * @type {integer} - * @default 0 - * @since 3.7.0 - */ - this.failed = 0; - - /** - * A storage container for transient data that the loading files need. - * - * @name Phaser.Loader.MultiFile#config - * @type {any} - * @since 3.7.0 - */ - this.config = {}; - - // Link the files - for (var i = 0; i < files.length; i++) - { - files[i].multiFile = this; - } - }, - - /** - * Checks if this MultiFile is ready to process its children or not. - * - * @method Phaser.Loader.MultiFile#isReadyToProcess - * @since 3.7.0 - * - * @return {boolean} `true` if all children of this MultiFile have loaded, otherwise `false`. - */ - isReadyToProcess: function () - { - return (this.pending === 0 && this.failed === 0 && !this.complete); - }, - - /** - * Adds another child to this MultiFile, increases the pending count and resets the completion status. - * - * @method Phaser.Loader.MultiFile#addToMultiFile - * @since 3.7.0 - * - * @param {Phaser.Loader.File} files - The File to add to this MultiFile. - * - * @return {Phaser.Loader.MultiFile} This MultiFile instance. - */ - addToMultiFile: function (file) - { - this.files.push(file); - - file.multiFile = this; - - this.pending++; - - this.complete = false; - - return this; - }, - - /** - * Called by each File when it finishes loading. - * - * @method Phaser.Loader.MultiFile#onFileComplete - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The File that has completed processing. - */ - onFileComplete: function (file) - { - var index = this.files.indexOf(file); - - if (index !== -1) - { - this.pending--; - } - }, - - /** - * Called by each File that fails to load. - * - * @method Phaser.Loader.MultiFile#onFileFailed - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The File that has failed to load. - */ - onFileFailed: function (file) - { - var index = this.files.indexOf(file); - - if (index !== -1) - { - this.failed++; - } - } - -}); - -module.exports = MultiFile; - - -/***/ }), -/* 37 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.ImageFrameConfig - * - * @property {integer} frameWidth - The width of the frame in pixels. - * @property {integer} [frameHeight] - The height of the frame in pixels. Uses the `frameWidth` value if not provided. - * @property {integer} [startFrame=0] - The first frame to start parsing from. - * @property {integer} [endFrame] - The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions. - * @property {integer} [margin=0] - The margin in the image. This is the space around the edge of the frames. - * @property {integer} [spacing=0] - The spacing between each frame in the image. - */ - -/** - * @typedef {object} Phaser.Loader.FileTypes.ImageFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='png'] - The default file extension to use if no url is provided. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image. - * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Image File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. - * - * @class ImageFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. - */ -var ImageFile = new Class({ - - Extends: File, - - initialize: - - function ImageFile (loader, key, url, xhrSettings, frameConfig) - { - var extension = 'png'; - var normalMapURL; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - normalMapURL = GetFastValue(config, 'normalMap'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - frameConfig = GetFastValue(config, 'frameConfig'); - } - - if (Array.isArray(url)) - { - normalMapURL = url[1]; - url = url[0]; - } - - var fileConfig = { - type: 'image', - cache: loader.textureManager, - extension: extension, - responseType: 'blob', - key: key, - url: url, - xhrSettings: xhrSettings, - config: frameConfig - }; - - File.call(this, loader, fileConfig); - - // Do we have a normal map to load as well? - if (normalMapURL) - { - var normalMap = new ImageFile(loader, this.key, normalMapURL, xhrSettings, frameConfig); - - normalMap.type = 'normalMap'; - - this.setLink(normalMap); - - loader.addFile(normalMap); - } - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.ImageFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - var _this = this; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessComplete(); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessError(); - }; - - File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.ImageFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var texture; - var linkFile = this.linkFile; - - if (linkFile && linkFile.state === CONST.FILE_COMPLETE) - { - if (this.type === 'image') - { - texture = this.cache.addImage(this.key, this.data, linkFile.data); - } - else - { - texture = this.cache.addImage(linkFile.key, linkFile.data, this.data); - } - - this.pendingDestroy(texture); - - linkFile.pendingDestroy(texture); - } - else if (!linkFile) - { - texture = this.cache.addImage(this.key, this.data); - - this.pendingDestroy(texture); - } - } - -}); - -/** - * Adds an Image, or array of Images, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.image('logo', 'images/phaserLogo.png'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback - * of animated gifs to Canvas elements. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.image({ - * key: 'logo', - * url: 'images/AtariLogo.png' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.image('logo', 'images/AtariLogo.png'); - * // and later in your game ... - * this.add.image(x, y, 'logo'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.image({ - * key: 'logo', - * url: 'images/AtariLogo.png', - * normalMap: 'images/AtariLogo-n.png' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#image - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('image', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new ImageFile(this, key[i])); - } - } - else - { - this.addFile(new ImageFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = ImageFile; - - -/***/ }), -/* 38 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); - -/** - * Convert the given angle from degrees, to the equivalent angle in radians. - * - * @function Phaser.Math.DegToRad - * @since 3.0.0 - * - * @param {integer} degrees - The angle (in degrees) to convert to radians. - * - * @return {float} The given angle converted to radians. - */ -var DegToRad = function (degrees) -{ - return degrees * CONST.DEG_TO_RAD; -}; - -module.exports = DegToRad; - - -/***/ }), -/* 39 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Wrap the given `value` between `min` and `max. - * - * @function Phaser.Math.Wrap - * @since 3.0.0 - * - * @param {number} value - The value to wrap. - * @param {number} min - The minimum value. - * @param {number} max - The maximum value. - * - * @return {number} The wrapped value. - */ -var Wrap = function (value, min, max) -{ - var range = max - min; - - return (min + ((((value - min) % range) + range) % range)); -}; - -module.exports = Wrap; - - -/***/ }), -/* 40 */, -/* 41 */, -/* 42 */, -/* 43 */, -/* 44 */, -/* 45 */, -/* 46 */, -/* 47 */, -/* 48 */, -/* 49 */, -/* 50 */, -/* 51 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Phaser Blend Modes. - * - * @name Phaser.BlendModes - * @enum {integer} - * @memberOf Phaser - * @readOnly - * @since 3.0.0 - */ - -module.exports = { - - /** - * Skips the Blend Mode check in the renderer. - * - * @name Phaser.BlendModes.SKIP_CHECK - */ - SKIP_CHECK: -1, - - /** - * Normal blend mode. - * - * @name Phaser.BlendModes.NORMAL - */ - NORMAL: 0, - - /** - * Add blend mode. - * - * @name Phaser.BlendModes.ADD - */ - ADD: 1, - - /** - * Multiply blend mode. - * - * @name Phaser.BlendModes.MULTIPLY - */ - MULTIPLY: 2, - - /** - * Screen blend mode. - * - * @name Phaser.BlendModes.SCREEN - */ - SCREEN: 3, - - /** - * Overlay blend mode. - * - * @name Phaser.BlendModes.OVERLAY - */ - OVERLAY: 4, - - /** - * Darken blend mode. - * - * @name Phaser.BlendModes.DARKEN - */ - DARKEN: 5, - - /** - * Lighten blend mode. - * - * @name Phaser.BlendModes.LIGHTEN - */ - LIGHTEN: 6, - - /** - * Color Dodge blend mode. - * - * @name Phaser.BlendModes.COLOR_DODGE - */ - COLOR_DODGE: 7, - - /** - * Color Burn blend mode. - * - * @name Phaser.BlendModes.COLOR_BURN - */ - COLOR_BURN: 8, - - /** - * Hard Light blend mode. - * - * @name Phaser.BlendModes.HARD_LIGHT - */ - HARD_LIGHT: 9, - - /** - * Soft Light blend mode. - * - * @name Phaser.BlendModes.SOFT_LIGHT - */ - SOFT_LIGHT: 10, - - /** - * Difference blend mode. - * - * @name Phaser.BlendModes.DIFFERENCE - */ - DIFFERENCE: 11, - - /** - * Exclusion blend mode. - * - * @name Phaser.BlendModes.EXCLUSION - */ - EXCLUSION: 12, - - /** - * Hue blend mode. - * - * @name Phaser.BlendModes.HUE - */ - HUE: 13, - - /** - * Saturation blend mode. - * - * @name Phaser.BlendModes.SATURATION - */ - SATURATION: 14, - - /** - * Color blend mode. - * - * @name Phaser.BlendModes.COLOR - */ - COLOR: 15, - - /** - * Luminosity blend mode. - * - * @name Phaser.BlendModes.LUMINOSITY - */ - LUMINOSITY: 16 - -}; - - -/***/ }), -/* 52 */, -/* 53 */, -/* 54 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Ellipse contains the given x / y coordinates. - * - * @function Phaser.Geom.Ellipse.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {number} x - The x coordinate to check within the ellipse. - * @param {number} y - The y coordinate to check within the ellipse. - * - * @return {boolean} True if the coordinates are within the ellipse, otherwise false. - */ -var Contains = function (ellipse, x, y) -{ - if (ellipse.width <= 0 || ellipse.height <= 0) - { - return false; - } - - // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 - var normx = ((x - ellipse.x) / ellipse.width); - var normy = ((y - ellipse.y) / ellipse.height); - - normx *= normx; - normy *= normy; - - return (normx + normy < 0.25); -}; - -module.exports = Contains; - - -/***/ }), -/* 55 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Scene consts. - * - * @ignore - */ - -var CONST = { - - /** - * Scene state. - * - * @name Phaser.Scenes.PENDING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - PENDING: 0, - - /** - * Scene state. - * - * @name Phaser.Scenes.INIT - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - INIT: 1, - - /** - * Scene state. - * - * @name Phaser.Scenes.START - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - START: 2, - - /** - * Scene state. - * - * @name Phaser.Scenes.LOADING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - LOADING: 3, - - /** - * Scene state. - * - * @name Phaser.Scenes.CREATING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - CREATING: 4, - - /** - * Scene state. - * - * @name Phaser.Scenes.RUNNING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - RUNNING: 5, - - /** - * Scene state. - * - * @name Phaser.Scenes.PAUSED - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - PAUSED: 6, - - /** - * Scene state. - * - * @name Phaser.Scenes.SLEEPING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - SLEEPING: 7, - - /** - * Scene state. - * - * @name Phaser.Scenes.SHUTDOWN - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - SHUTDOWN: 8, - - /** - * Scene state. - * - * @name Phaser.Scenes.DESTROYED - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - DESTROYED: 9 - -}; - -module.exports = CONST; - - -/***/ }), -/* 56 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Removes a single item from an array and returns it without creating gc, like the native splice does. - * Based on code by Mike Reinstein. - * - * @function Phaser.Utils.Array.SpliceOne - * @since 3.0.0 - * - * @param {array} array - [description] - * @param {integer} index - [description] - * - * @return {*} [description] - */ -var SpliceOne = function (array, index) -{ - if (index >= array.length) - { - return; - } - - var len = array.length - 1; - - var item = array[index]; - - for (var i = index; i < len; i++) - { - array[i] = array[i + 1]; - } - - array.length = len; - - return item; -}; - -module.exports = SpliceOne; - - -/***/ }), -/* 57 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process) {/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the operating system of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.os` from within any Scene. - * - * @typedef {object} Phaser.Device.OS - * @since 3.0.0 - * - * @property {boolean} android - Is running on android? - * @property {boolean} chromeOS - Is running on chromeOS? - * @property {boolean} cocoonJS - Is the game running under CocoonJS? - * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? - * @property {boolean} cordova - Is the game running under Apache Cordova? - * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? - * @property {boolean} desktop - Is running on a desktop? - * @property {boolean} ejecta - Is the game running under Ejecta? - * @property {boolean} electron - Is the game running under GitHub Electron? - * @property {boolean} iOS - Is running on iOS? - * @property {boolean} iPad - Is running on iPad? - * @property {boolean} iPhone - Is running on iPhone? - * @property {boolean} kindle - Is running on an Amazon Kindle? - * @property {boolean} linux - Is running on linux? - * @property {boolean} macOS - Is running on macOS? - * @property {boolean} node - Is the game running under Node.js? - * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? - * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView - * @property {boolean} windows - Is running on windows? - * @property {boolean} windowsPhone - Is running on a Windows Phone? - * @property {number} iOSVersion - If running in iOS this will contain the major version number. - * @property {number} pixelRatio - PixelRatio of the host device? - */ -var OS = { - - android: false, - chromeOS: false, - cocoonJS: false, - cocoonJSApp: false, - cordova: false, - crosswalk: false, - desktop: false, - ejecta: false, - electron: false, - iOS: false, - iOSVersion: 0, - iPad: false, - iPhone: false, - kindle: false, - linux: false, - macOS: false, - node: false, - nodeWebkit: false, - pixelRatio: 1, - webApp: false, - windows: false, - windowsPhone: false - -}; - -function init () -{ - var ua = navigator.userAgent; - - if (/Windows/.test(ua)) - { - OS.windows = true; - } - else if (/Mac OS/.test(ua)) - { - OS.macOS = true; - } - else if (/Android/.test(ua)) - { - OS.android = true; - } - else if (/Linux/.test(ua)) - { - OS.linux = true; - } - else if (/iP[ao]d|iPhone/i.test(ua)) - { - OS.iOS = true; - (navigator.appVersion).match(/OS (\d+)/); - OS.iOSVersion = parseInt(RegExp.$1, 10); - } - else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) - { - OS.kindle = true; - - // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... - // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" - } - else if (/CrOS/.test(ua)) - { - OS.chromeOS = true; - } - - if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) - { - OS.android = false; - OS.iOS = false; - OS.macOS = false; - OS.windows = true; - OS.windowsPhone = true; - } - - var silk = (/Silk/).test(ua); - - if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) - { - OS.desktop = true; - } - - // Windows Phone / Table reset - if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) - { - OS.desktop = false; - } - - // WebApp mode in iOS - if (navigator.standalone) - { - OS.webApp = true; - } - - if (window.cordova !== undefined) - { - OS.cordova = true; - } - - if (process && process.versions && process.versions.node) - { - OS.node = true; - } - - if (OS.node && typeof process.versions === 'object') - { - OS.nodeWebkit = !!process.versions['node-webkit']; - - OS.electron = !!process.versions.electron; - } - - if (navigator.isCocoonJS) - { - OS.cocoonJS = true; - - try - { - OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); - } - catch (error) - { - OS.cocoonJSApp = false; - } - } - - if (window.ejecta !== undefined) - { - OS.ejecta = true; - } - - if ((/Crosswalk/).test(ua)) - { - OS.crosswalk = true; - } - - OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; - OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; - - OS.pixelRatio = window['devicePixelRatio'] || 1; - - return OS; -} - -module.exports = init(); - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(537))) - -/***/ }), -/* 58 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the distance between two sets of coordinates (points). - * - * @function Phaser.Math.Distance.Between - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the first point. - * @param {number} y1 - The y coordinate of the first point. - * @param {number} x2 - The x coordinate of the second point. - * @param {number} y2 - The y coordinate of the second point. - * - * @return {number} The distance between each point. - */ -var DistanceBetween = function (x1, y1, x2, y2) -{ - var dx = x1 - x2; - var dy = y1 - y2; - - return Math.sqrt(dx * dx + dy * dy); -}; - -module.exports = DistanceBetween; - - -/***/ }), -/* 59 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Phaser Scale Modes. - * - * @name Phaser.ScaleModes - * @enum {integer} - * @memberOf Phaser - * @readOnly - * @since 3.0.0 - */ - -module.exports = { - - /** - * Default Scale Mode (Linear). - * - * @name Phaser.ScaleModes.DEFAULT - */ - DEFAULT: 0, - - /** - * Linear Scale Mode. - * - * @name Phaser.ScaleModes.LINEAR - */ - LINEAR: 0, - - /** - * Nearest Scale Mode. - * - * @name Phaser.ScaleModes.NEAREST - */ - NEAREST: 1 - -}; - - -/***/ }), -/* 60 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// http://www.blackpawn.com/texts/pointinpoly/ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (triangle, x, y) -{ - var v0x = triangle.x3 - triangle.x1; - var v0y = triangle.y3 - triangle.y1; - - var v1x = triangle.x2 - triangle.x1; - var v1y = triangle.y2 - triangle.y1; - - var v2x = x - triangle.x1; - var v2y = y - triangle.y1; - - var dot00 = (v0x * v0x) + (v0y * v0y); - var dot01 = (v0x * v1x) + (v0y * v1y); - var dot02 = (v0x * v2x) + (v0y * v2y); - var dot11 = (v1x * v1x) + (v1y * v1y); - var dot12 = (v1x * v2x) + (v1y * v2y); - - // Compute barycentric coordinates - var b = ((dot00 * dot11) - (dot01 * dot01)); - var inv = (b === 0) ? 0 : (1 / b); - var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; - var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; - - return (u >= 0 && v >= 0 && (u + v < 1)); -}; - -module.exports = Contains; - - -/***/ }), -/* 61 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TWEEN_CONST = { - - /** - * TweenData state. - * - * @name Phaser.Tweens.CREATED - * @type {integer} - * @since 3.0.0 - */ - CREATED: 0, - - /** - * TweenData state. - * - * @name Phaser.Tweens.INIT - * @type {integer} - * @since 3.0.0 - */ - INIT: 1, - - /** - * TweenData state. - * - * @name Phaser.Tweens.DELAY - * @type {integer} - * @since 3.0.0 - */ - DELAY: 2, - - /** - * TweenData state. - * - * @name Phaser.Tweens.OFFSET_DELAY - * @type {integer} - * @since 3.0.0 - */ - OFFSET_DELAY: 3, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PENDING_RENDER - * @type {integer} - * @since 3.0.0 - */ - PENDING_RENDER: 4, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PLAYING_FORWARD - * @type {integer} - * @since 3.0.0 - */ - PLAYING_FORWARD: 5, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PLAYING_BACKWARD - * @type {integer} - * @since 3.0.0 - */ - PLAYING_BACKWARD: 6, - - /** - * TweenData state. - * - * @name Phaser.Tweens.HOLD_DELAY - * @type {integer} - * @since 3.0.0 - */ - HOLD_DELAY: 7, - - /** - * TweenData state. - * - * @name Phaser.Tweens.REPEAT_DELAY - * @type {integer} - * @since 3.0.0 - */ - REPEAT_DELAY: 8, - - /** - * TweenData state. - * - * @name Phaser.Tweens.COMPLETE - * @type {integer} - * @since 3.0.0 - */ - COMPLETE: 9, - - // Tween specific (starts from 20 to cleanly allow extra TweenData consts in the future) - - /** - * Tween state. - * - * @name Phaser.Tweens.PENDING_ADD - * @type {integer} - * @since 3.0.0 - */ - PENDING_ADD: 20, - - /** - * Tween state. - * - * @name Phaser.Tweens.PAUSED - * @type {integer} - * @since 3.0.0 - */ - PAUSED: 21, - - /** - * Tween state. - * - * @name Phaser.Tweens.LOOP_DELAY - * @type {integer} - * @since 3.0.0 - */ - LOOP_DELAY: 22, - - /** - * Tween state. - * - * @name Phaser.Tweens.ACTIVE - * @type {integer} - * @since 3.0.0 - */ - ACTIVE: 23, - - /** - * Tween state. - * - * @name Phaser.Tweens.COMPLETE_DELAY - * @type {integer} - * @since 3.0.0 - */ - COMPLETE_DELAY: 24, - - /** - * Tween state. - * - * @name Phaser.Tweens.PENDING_REMOVE - * @type {integer} - * @since 3.0.0 - */ - PENDING_REMOVE: 25, - - /** - * Tween state. - * - * @name Phaser.Tweens.REMOVED - * @type {integer} - * @since 3.0.0 - */ - REMOVED: 26 - -}; - -module.exports = TWEEN_CONST; - - -/***/ }), -/* 62 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetBoolean - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {*} [description] - */ -var GetBoolean = function (source, key, defaultValue) -{ - if (!source) - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else - { - return defaultValue; - } -}; - -module.exports = GetBoolean; - - -/***/ }), -/* 63 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var EaseMap = __webpack_require__(453); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetEaseFunction - * @since 3.0.0 - * - * @param {(string|function)} ease - [description] - * @param {array} easeParams - [description] - * - * @return {function} [description] - */ -var GetEaseFunction = function (ease, easeParams) -{ - if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) - { - if (easeParams) - { - var cloneParams = easeParams.slice(0); - - cloneParams.unshift(0); - - return function (v) - { - cloneParams[0] = v; - - return EaseMap[ease].apply(this, cloneParams); - }; - } - else - { - // String based look-up - return EaseMap[ease]; - } - } - else if (typeof ease === 'function') - { - // Custom function - return ease; - } - else if (Array.isArray(ease) && ease.length === 4) - { - // Bezier function (TODO) - } - - return EaseMap.Power0; -}; - -module.exports = GetEaseFunction; - - -/***/ }), -/* 64 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class TransformMatrix - * @memberOf Phaser.GameObjects.Components - * @constructor - * @since 3.0.0 - * - * @param {number} [a=1] - The Scale X value. - * @param {number} [b=0] - The Shear Y value. - * @param {number} [c=0] - The Shear X value. - * @param {number} [d=1] - The Scale Y value. - * @param {number} [tx=0] - The Translate X value. - * @param {number} [ty=0] - The Translate Y value. - */ -var TransformMatrix = new Class({ - - initialize: - - function TransformMatrix (a, b, c, d, tx, ty) - { - if (a === undefined) { a = 1; } - if (b === undefined) { b = 0; } - if (c === undefined) { c = 0; } - if (d === undefined) { d = 1; } - if (tx === undefined) { tx = 0; } - if (ty === undefined) { ty = 0; } - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#matrix - * @type {Float32Array} - * @since 3.0.0 - */ - this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix - * @type {object} - * @since 3.0.0 - */ - this.decomposedMatrix = { - translateX: 0, - translateY: 0, - scaleX: 1, - scaleY: 1, - rotation: 0 - }; - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#a - * @type {number} - * @since 3.4.0 - */ - a: { - - get: function () - { - return this.matrix[0]; - }, - - set: function (value) - { - this.matrix[0] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#b - * @type {number} - * @since 3.4.0 - */ - b: { - - get: function () - { - return this.matrix[1]; - }, - - set: function (value) - { - this.matrix[1] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#c - * @type {number} - * @since 3.4.0 - */ - c: { - - get: function () - { - return this.matrix[2]; - }, - - set: function (value) - { - this.matrix[2] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#d - * @type {number} - * @since 3.4.0 - */ - d: { - - get: function () - { - return this.matrix[3]; - }, - - set: function (value) - { - this.matrix[3] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#tx - * @type {number} - * @since 3.4.0 - */ - tx: { - - get: function () - { - return this.matrix[4]; - }, - - set: function (value) - { - this.matrix[4] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#ty - * @type {number} - * @since 3.4.0 - */ - ty: { - - get: function () - { - return this.matrix[5]; - }, - - set: function (value) - { - this.matrix[5] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#rotation - * @type {number} - * @readOnly - * @since 3.4.0 - */ - rotation: { - - get: function () - { - return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1); - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#scaleX - * @type {number} - * @readOnly - * @since 3.4.0 - */ - scaleX: { - - get: function () - { - return Math.sqrt((this.a * this.a) + (this.c * this.c)); - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#scaleY - * @type {number} - * @readOnly - * @since 3.4.0 - */ - scaleY: { - - get: function () - { - return Math.sqrt((this.b * this.b) + (this.d * this.d)); - } - - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity - * @since 3.0.0 - * - * @return {this} This TransformMatrix. - */ - loadIdentity: function () - { - var matrix = this.matrix; - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 1; - matrix[4] = 0; - matrix[5] = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#translate - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {this} This TransformMatrix. - */ - translate: function (x, y) - { - var matrix = this.matrix; - - matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; - matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#scale - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {this} This TransformMatrix. - */ - scale: function (x, y) - { - var matrix = this.matrix; - - matrix[0] *= x; - matrix[1] *= x; - matrix[2] *= y; - matrix[3] *= y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#rotate - * @since 3.0.0 - * - * @param {number} radian - [description] - * - * @return {this} This TransformMatrix. - */ - rotate: function (radian) - { - var radianSin = Math.sin(radian); - var radianCos = Math.cos(radian); - var matrix = this.matrix; - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - - matrix[0] = a * radianCos + c * radianSin; - matrix[1] = b * radianCos + d * radianSin; - matrix[2] = a * -radianSin + c * radianCos; - matrix[3] = b * -radianSin + d * radianCos; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#multiply - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - [description] - * - * @return {this} This TransformMatrix. - */ - multiply: function (rhs) - { - var matrix = this.matrix; - var otherMatrix = rhs.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - var a1 = otherMatrix[0]; - var b1 = otherMatrix[1]; - var c1 = otherMatrix[2]; - var d1 = otherMatrix[3]; - var tx1 = otherMatrix[4]; - var ty1 = otherMatrix[5]; - - matrix[0] = a1 * a0 + b1 * c0; - matrix[1] = a1 * b0 + b1 * d0; - matrix[2] = c1 * a0 + d1 * c0; - matrix[3] = c1 * b0 + d1 * d0; - matrix[4] = tx1 * a0 + ty1 * c0 + tx0; - matrix[5] = tx1 * b0 + ty1 * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transform - * @since 3.0.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This TransformMatrix. - */ - transform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - matrix[0] = a * a0 + b * c0; - matrix[1] = a * b0 + b * d0; - matrix[2] = c * a0 + d * c0; - matrix[3] = c * b0 + d * d0; - matrix[4] = tx * a0 + ty * c0 + tx0; - matrix[5] = tx * b0 + ty * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - [description] - * - * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} [description] - */ - transformPoint: function (x, y, point) - { - if (point === undefined) { point = { x: 0, y: 0 }; } - - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - point.x = x * a + y * c + tx; - point.y = x * b + y * d + ty; - - return point; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#invert - * @since 3.0.0 - * - * @return {this} This TransformMatrix. - */ - invert: function () - { - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - var n = a * d - b * c; - - matrix[0] = d / n; - matrix[1] = -b / n; - matrix[2] = -c / n; - matrix[3] = a / n; - matrix[4] = (c * ty - d * tx) / n; - matrix[5] = -(a * ty - b * tx) / n; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#setTransform - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {this} This TransformMatrix. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - matrix[0] = a; - matrix[1] = b; - matrix[2] = c; - matrix[3] = d; - matrix[4] = tx; - matrix[5] = ty; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix - * @since 3.0.0 - * - * @return {object} [description] - */ - decomposeMatrix: function () - { - var decomposedMatrix = this.decomposedMatrix; - - var matrix = this.matrix; - - // a = scale X (1) - // b = shear Y (0) - // c = shear X (0) - // d = scale Y (1) - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - - var a2 = a * a; - var b2 = b * b; - var c2 = c * c; - var d2 = d * d; - - var sx = Math.sqrt(a2 + c2); - var sy = Math.sqrt(b2 + d2); - - decomposedMatrix.translateX = matrix[4]; - decomposedMatrix.translateY = matrix[5]; - - decomposedMatrix.scaleX = sx; - decomposedMatrix.scaleY = sy; - - decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); - - return decomposedMatrix; - }, - - /** - * Identity + Translate + Rotate + Scale - * - * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} rotation - [description] - * @param {number} scaleX - [description] - * @param {number} scaleY - [description] - * - * @return {this} This TransformMatrix. - */ - applyITRS: function (x, y, rotation, scaleX, scaleY) - { - var matrix = this.matrix; - - var radianSin = Math.sin(rotation); - var radianCos = Math.cos(rotation); - - // Translate - matrix[4] = x; - matrix[5] = y; - - // Rotate and Scale - matrix[0] = radianCos * scaleX; - matrix[1] = radianSin * scaleX; - matrix[2] = -radianSin * scaleY; - matrix[3] = radianCos * scaleY; - - return this; - }, - - /** - * Destroys this Transform Matrix. - * - * @method Phaser.GameObjects.Components.TransformMatrix#destroy - * @since 3.4.0 - */ - destroy: function () - { - this.matrix = null; - this.decomposedMatrix = null; - } - -}); - -module.exports = TransformMatrix; - - -/***/ }), -/* 65 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); - -/** - * Return a value based on the range between `min` and `max` and the percentage given. - * - * @function Phaser.Math.FromPercent - * @since 3.0.0 - * - * @param {float} percent - A value between 0 and 1 representing the percentage. - * @param {number} min - The minimum value. - * @param {number} [max] - The maximum value. - * - * @return {number} The value that is `percent` percent between `min` and `max`. - */ -var FromPercent = function (percent, min, max) -{ - percent = Clamp(percent, 0, 1); - - return (max - min) * percent; -}; - -module.exports = FromPercent; - - -/***/ }), -/* 66 */, -/* 67 */, -/* 68 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(60); -var GetPoint = __webpack_require__(227); -var GetPoints = __webpack_require__(226); -var Line = __webpack_require__(96); -var Random = __webpack_require__(153); - -/** - * @classdesc - * A triangle is a plane created by connecting three points. - * The first two arguments specify the first point, the middle two arguments - * specify the second point, and the last two arguments specify the third point. - * - * @class Triangle - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] - */ -var Triangle = new Class({ - - initialize: - - function Triangle (x1, y1, x2, y2, x3, y3) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - if (x3 === undefined) { x3 = 0; } - if (y3 === undefined) { y3 = 0; } - - /** - * [description] - * - * @name Phaser.Geom.Triangle#x1 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x1 = x1; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#y1 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y1 = y1; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#x2 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x2 = x2; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#y2 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y2 = y2; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#x3 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x3 = x3; - - /** - * [description] - * - * @name Phaser.Geom.Triangle#y3 - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y3 = y3; - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#contains - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [output,$return] - * - * @param {integer} quantity - [description] - * @param {number} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#getRandomPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} [point] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * [description] - * - * @method Phaser.Geom.Triangle#setTo - * @since 3.0.0 - * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] - * - * @return {Phaser.Geom.Triangle} This Triangle object. - */ - setTo: function (x1, y1, x2, y2, x3, y3) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - if (x3 === undefined) { x3 = 0; } - if (y3 === undefined) { y3 = 0; } - - this.x1 = x1; - this.y1 = y1; - - this.x2 = x2; - this.y2 = y2; - - this.x3 = x3; - this.y3 = y3; - - return this; - }, - - /** - * Returns a Line object that corresponds to Line A of this Triangle. - * - * @method Phaser.Geom.Triangle#getLineA - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to line A of this Triangle. - */ - getLineA: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.x1, this.y1, this.x2, this.y2); - - return line; - }, - - /** - * Returns a Line object that corresponds to Line B of this Triangle. - * - * @method Phaser.Geom.Triangle#getLineB - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to line B of this Triangle. - */ - getLineB: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.x2, this.y2, this.x3, this.y3); - - return line; - }, - - /** - * Returns a Line object that corresponds to Line C of this Triangle. - * - * @method Phaser.Geom.Triangle#getLineC - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to line C of this Triangle. - */ - getLineC: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.x3, this.y3, this.x1, this.y1); - - return line; - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return Math.min(this.x1, this.x2, this.x3); - }, - - set: function (value) - { - var diff = 0; - - if (this.x1 <= this.x2 && this.x1 <= this.x3) - { - diff = this.x1 - value; - } - else if (this.x2 <= this.x1 && this.x2 <= this.x3) - { - diff = this.x2 - value; - } - else - { - diff = this.x3 - value; - } - - this.x1 -= diff; - this.x2 -= diff; - this.x3 -= diff; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return Math.max(this.x1, this.x2, this.x3); - }, - - set: function (value) - { - var diff = 0; - - if (this.x1 >= this.x2 && this.x1 >= this.x3) - { - diff = this.x1 - value; - } - else if (this.x2 >= this.x1 && this.x2 >= this.x3) - { - diff = this.x2 - value; - } - else - { - diff = this.x3 - value; - } - - this.x1 -= diff; - this.x2 -= diff; - this.x3 -= diff; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return Math.min(this.y1, this.y2, this.y3); - }, - - set: function (value) - { - var diff = 0; - - if (this.y1 <= this.y2 && this.y1 <= this.y3) - { - diff = this.y1 - value; - } - else if (this.y2 <= this.y1 && this.y2 <= this.y3) - { - diff = this.y2 - value; - } - else - { - diff = this.y3 - value; - } - - this.y1 -= diff; - this.y2 -= diff; - this.y3 -= diff; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Triangle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return Math.max(this.y1, this.y2, this.y3); - }, - - set: function (value) - { - var diff = 0; - - if (this.y1 >= this.y2 && this.y1 >= this.y3) - { - diff = this.y1 - value; - } - else if (this.y2 >= this.y1 && this.y2 >= this.y3) - { - diff = this.y2 - value; - } - else - { - diff = this.y3 - value; - } - - this.y1 -= diff; - this.y2 -= diff; - this.y3 -= diff; - } - - } - -}); - -module.exports = Triangle; - - -/***/ }), -/* 69 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var ImageRender = __webpack_require__(461); - -/** - * @classdesc - * An Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - * - * @class Image - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Image = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - ImageRender - ], - - initialize: - - function Image (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Image'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - } - -}); - -module.exports = Image; - - -/***/ }), -/* 70 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback EachSetCallback - * @generic E - [entry] - * - * @param {*} entry - [description] - * @param {number} index - [description] - * - * @return {?boolean} [description] - */ - -/** - * @classdesc - * A Set is a collection of unique elements. - * - * @class Set - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic T - * @genericUse {T[]} - [elements] - * - * @param {Array.<*>} [elements] - [description] - */ -var Set = new Class({ - - initialize: - - function Set (elements) - { - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.Set#entries - * @type {Array.<*>} - * @default [] - * @since 3.0.0 - */ - this.entries = []; - - if (Array.isArray(elements)) - { - for (var i = 0; i < elements.length; i++) - { - this.set(elements[i]); - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#set - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {*} value - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - set: function (value) - { - if (this.entries.indexOf(value) === -1) - { - this.entries.push(value); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#get - * @since 3.0.0 - * - * @genericUse {T} - [value,$return] - * - * @param {string} property - [description] - * @param {*} value - [description] - * - * @return {*} [description] - */ - get: function (property, value) - { - for (var i = 0; i < this.entries.length; i++) - { - var entry = this.entries[i]; - - if (entry[property] === value) - { - return entry; - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#getArray - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @return {Array.<*>} [description] - */ - getArray: function () - { - return this.entries.slice(0); - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#delete - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {*} value - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - delete: function (value) - { - var index = this.entries.indexOf(value); - - if (index > -1) - { - this.entries.splice(index, 1); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#dump - * @since 3.0.0 - */ - dump: function () - { - // eslint-disable-next-line no-console - console.group('Set'); - - for (var i = 0; i < this.entries.length; i++) - { - var entry = this.entries[i]; - console.log(entry); - } - - // eslint-disable-next-line no-console - console.groupEnd(); - }, - - /** - * For when you know this Set will be modified during the iteration. - * - * @method Phaser.Structs.Set#each - * @since 3.0.0 - * - * @genericUse {EachSetCallback.} - [callback] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {EachSetCallback} callback - [description] - * @param {*} callbackScope - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - each: function (callback, callbackScope) - { - var i; - var temp = this.entries.slice(); - var len = temp.length; - - if (callbackScope) - { - for (i = 0; i < len; i++) - { - if (callback.call(callbackScope, temp[i], i) === false) - { - break; - } - } - } - else - { - for (i = 0; i < len; i++) - { - if (callback(temp[i], i) === false) - { - break; - } - } - } - - return this; - }, - - /** - * For when you absolutely know this Set won't be modified during the iteration. - * - * @method Phaser.Structs.Set#iterate - * @since 3.0.0 - * - * @genericUse {EachSetCallback.} - [callback] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {EachSetCallback} callback - [description] - * @param {*} callbackScope - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - iterate: function (callback, callbackScope) - { - var i; - var len = this.entries.length; - - if (callbackScope) - { - for (i = 0; i < len; i++) - { - if (callback.call(callbackScope, this.entries[i], i) === false) - { - break; - } - } - } - else - { - for (i = 0; i < len; i++) - { - if (callback(this.entries[i], i) === false) - { - break; - } - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#iterateLocal - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {string} callbackKey - [description] - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - * - * @return {Phaser.Structs.Set} This Set object. - */ - iterateLocal: function (callbackKey) - { - var i; - var args = []; - - for (i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - var len = this.entries.length; - - for (i = 0; i < len; i++) - { - var entry = this.entries[i]; - - entry[callbackKey].apply(entry, args); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#clear - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @return {Phaser.Structs.Set} This Set object. - */ - clear: function () - { - this.entries.length = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#contains - * @since 3.0.0 - * - * @genericUse {T} - [value] - * - * @param {*} value - [description] - * - * @return {boolean} [description] - */ - contains: function (value) - { - return (this.entries.indexOf(value) > -1); - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#union - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [set,$return] - * - * @param {Phaser.Structs.Set} set - [description] - * - * @return {Phaser.Structs.Set} [description] - */ - union: function (set) - { - var newSet = new Set(); - - set.entries.forEach(function (value) - { - newSet.set(value); - }); - - this.entries.forEach(function (value) - { - newSet.set(value); - }); - - return newSet; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#intersect - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [set,$return] - * - * @param {Phaser.Structs.Set} set - [description] - * - * @return {Phaser.Structs.Set} [description] - */ - intersect: function (set) - { - var newSet = new Set(); - - this.entries.forEach(function (value) - { - if (set.contains(value)) - { - newSet.set(value); - } - }); - - return newSet; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#difference - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [set,$return] - * - * @param {Phaser.Structs.Set} set - [description] - * - * @return {Phaser.Structs.Set} [description] - */ - difference: function (set) - { - var newSet = new Set(); - - this.entries.forEach(function (value) - { - if (!set.contains(value)) - { - newSet.set(value); - } - }); - - return newSet; - }, - - /** - * [description] - * - * @name Phaser.Structs.Set#size - * @type {integer} - * @since 3.0.0 - */ - size: { - - get: function () - { - return this.entries.length; - }, - - set: function (value) - { - return this.entries.length = value; - } - - } - -}); - -module.exports = Set; - - -/***/ }), -/* 71 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Length - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Length = function (line) -{ - return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); -}; - -module.exports = Length; - - -/***/ }), -/* 72 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Defaults = __webpack_require__(100); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(62); -var GetEaseFunction = __webpack_require__(63); -var GetNewValue = __webpack_require__(73); -var GetProps = __webpack_require__(163); -var GetTargets = __webpack_require__(102); -var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(101); -var Tween = __webpack_require__(99); -var TweenData = __webpack_require__(98); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.TweenBuilder - * @since 3.0.0 - * - * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] - * @param {object} config - [description] - * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ -var TweenBuilder = function (parent, config, defaults) -{ - if (defaults === undefined) - { - defaults = Defaults; - } - - // Create arrays of the Targets and the Properties - var targets = (defaults.targets) ? defaults.targets : GetTargets(config); - - // var props = (defaults.props) ? defaults.props : GetProps(config); - var props = GetProps(config); - - // Default Tween values - var delay = GetNewValue(config, 'delay', defaults.delay); - var duration = GetNewValue(config, 'duration', defaults.duration); - var easeParams = GetValue(config, 'easeParams', defaults.easeParams); - var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); - var hold = GetNewValue(config, 'hold', defaults.hold); - var repeat = GetNewValue(config, 'repeat', defaults.repeat); - var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - var flipX = GetBoolean(config, 'flipX', defaults.flipX); - var flipY = GetBoolean(config, 'flipY', defaults.flipY); - - var data = []; - - // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } - for (var p = 0; p < props.length; p++) - { - var key = props[p].key; - var value = props[p].value; - - // Create 1 TweenData per target, per property - for (var t = 0; t < targets.length; t++) - { - var ops = GetValueOp(key, value); - - var tweenData = TweenData( - targets[t], - key, - ops.getEnd, - ops.getStart, - GetEaseFunction(GetValue(value, 'ease', ease), easeParams), - GetNewValue(value, 'delay', delay), - GetNewValue(value, 'duration', duration), - GetBoolean(value, 'yoyo', yoyo), - GetNewValue(value, 'hold', hold), - GetNewValue(value, 'repeat', repeat), - GetNewValue(value, 'repeatDelay', repeatDelay), - GetBoolean(value, 'flipX', flipX), - GetBoolean(value, 'flipY', flipY) - ); - - data.push(tweenData); - } - } - - var tween = new Tween(parent, data, targets); - - tween.offset = GetAdvancedValue(config, 'offset', null); - tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - tween.paused = GetBoolean(config, 'paused', false); - tween.useFrames = GetBoolean(config, 'useFrames', false); - - // Set the Callbacks - var scope = GetValue(config, 'callbackScope', tween); - - // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params - var tweenArray = [ tween, null ]; - - var callbacks = Tween.TYPES; - - for (var i = 0; i < callbacks.length; i++) - { - var type = callbacks[i]; - - var callback = GetValue(config, type, false); - - if (callback) - { - var callbackScope = GetValue(config, type + 'Scope', scope); - var callbackParams = GetValue(config, type + 'Params', []); - - // The null is reset to be the Tween target - tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); - } - } - - return tween; -}; - -module.exports = TweenBuilder; - - -/***/ }), -/* 73 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetNewValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {function} [description] - */ -var GetNewValue = function (source, key, defaultValue) -{ - var valueCallback; - - if (source.hasOwnProperty(key)) - { - var t = typeof(source[key]); - - if (t === 'function') - { - valueCallback = function (index, totalTargets, target) - { - return source[key](index, totalTargets, target); - }; - } - else - { - valueCallback = function () - { - return source[key]; - }; - } - } - else if (typeof defaultValue === 'function') - { - valueCallback = defaultValue; - } - else - { - valueCallback = function () - { - return defaultValue; - }; - } - - return valueCallback; -}; - -module.exports = GetNewValue; - - -/***/ }), -/* 74 */, -/* 75 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} XHRSettingsObject - * - * @property {XMLHttpRequestResponseType} responseType - The response type of the XHR request, i.e. `blob`, `text`, etc. - * @property {boolean} [async=true] - Should the XHR request use async or not? - * @property {string} [user=''] - Optional username for the XHR request. - * @property {string} [password=''] - Optional password for the XHR request. - * @property {integer} [timeout=0] - Optional XHR timeout value. - * @property {(string|undefined)} [header] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. - * @property {(string|undefined)} [headerValue] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. - * @property {(string|undefined)} [requestedWith] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. - * @property {(string|undefined)} [overrideMimeType] - Provide a custom mime-type to use instead of the default. - */ - -/** - * Creates an XHRSettings Object with default values. - * - * @function Phaser.Loader.XHRSettings - * @since 3.0.0 - * - * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. - * @param {boolean} [async=true] - Should the XHR request use async or not? - * @param {string} [user=''] - Optional username for the XHR request. - * @param {string} [password=''] - Optional password for the XHR request. - * @param {integer} [timeout=0] - Optional XHR timeout value. - * - * @return {XHRSettingsObject} The XHRSettings object as used by the Loader. - */ -var XHRSettings = function (responseType, async, user, password, timeout) -{ - if (responseType === undefined) { responseType = ''; } - if (async === undefined) { async = true; } - if (user === undefined) { user = ''; } - if (password === undefined) { password = ''; } - if (timeout === undefined) { timeout = 0; } - - // Before sending a request, set the xhr.responseType to "text", - // "arraybuffer", "blob", or "document", depending on your data needs. - // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". - - return { - - // Ignored by the Loader, only used by File. - responseType: responseType, - - async: async, - - // credentials - user: user, - password: password, - - // timeout in ms (0 = no timeout) - timeout: timeout, - - // setRequestHeader - header: undefined, - headerValue: undefined, - requestedWith: false, - - // overrideMimeType - overrideMimeType: undefined - - }; -}; - -module.exports = XHRSettings; - - -/***/ }), -/* 76 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -// Contains the plugins that Phaser uses globally and locally. -// These are the source objects, not instantiated. -var inputPlugins = {}; - -/** - * @typedef {object} InputPluginContainer - * - * @property {string} key - The unique name of this plugin in the input plugin cache. - * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. - * @property {string} [mapping] - If this plugin is to be injected into the Input Plugin, this is the property key map used. - */ - -var InputPluginCache = {}; - -/** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * - * @method Phaser.Input.InputPluginCache.register - * @since 3.10.0 - * - * @param {string} key - A reference used to get this plugin from the plugin cache. - * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. - * @param {string} mapping - If this plugin is to be injected into the Input Plugin, this is the property key used. - * @param {string} settingsKey - The key in the Scene Settings to check to see if this plugin should install or not. - * @param {string} configKey - The key in the Game Config to check to see if this plugin should install or not. - */ -InputPluginCache.register = function (key, plugin, mapping, settingsKey, configKey) -{ - inputPlugins[key] = { plugin: plugin, mapping: mapping, settingsKey: settingsKey, configKey: configKey }; -}; - -/** - * Returns the input plugin object from the cache based on the given key. - * - * @method Phaser.Input.InputPluginCache.getCore - * @since 3.10.0 - * - * @param {string} key - The key of the input plugin to get. - * - * @return {InputPluginContainer} The input plugin object. - */ -InputPluginCache.getPlugin = function (key) -{ - return inputPlugins[key]; -}; - -/** - * Installs all of the registered Input Plugins into the given target. - * - * @method Phaser.Input.InputPluginCache.install - * @since 3.10.0 - * - * @param {Phaser.Input.InputPlugin} target - The target InputPlugin to install the plugins into. - */ -InputPluginCache.install = function (target) -{ - var sys = target.scene.sys; - var settings = sys.settings.input; - var config = sys.game.config; - - for (var key in inputPlugins) - { - var source = inputPlugins[key].plugin; - var mapping = inputPlugins[key].mapping; - var settingsKey = inputPlugins[key].settingsKey; - var configKey = inputPlugins[key].configKey; - - if (GetValue(settings, settingsKey, config[configKey])) - { - target[mapping] = new source(target); - } - } -}; - -/** - * Removes an input plugin based on the given key. - * - * @method Phaser.Input.InputPluginCache.remove - * @since 3.10.0 - * - * @param {string} key - The key of the input plugin to remove. - */ -InputPluginCache.remove = function (key) -{ - if (inputPlugins.hasOwnProperty(key)) - { - delete inputPlugins[key]; - } -}; - -module.exports = InputPluginCache; - - -/***/ }), -/* 77 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. - -var CheckMatrix = __webpack_require__(116); -var TransposeMatrix = __webpack_require__(181); - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.RotateMatrix - * @since 3.0.0 - * - * @param {array} matrix - The array to rotate. - * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. - * - * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. - */ -var RotateMatrix = function (matrix, direction) -{ - if (direction === undefined) { direction = 90; } - - if (!CheckMatrix(matrix)) - { - return null; - } - - if (typeof direction !== 'string') - { - direction = ((direction % 360) + 360) % 360; - } - - if (direction === 90 || direction === -270 || direction === 'rotateLeft') - { - matrix = TransposeMatrix(matrix); - matrix.reverse(); - } - else if (direction === -90 || direction === 270 || direction === 'rotateRight') - { - matrix.reverse(); - matrix = TransposeMatrix(matrix); - } - else if (Math.abs(direction) === 180 || direction === 'rotate180') - { - for (var i = 0; i < matrix.length; i++) - { - matrix[i].reverse(); - } - - matrix.reverse(); - } - - return matrix; -}; - -module.exports = RotateMatrix; - - -/***/ }), -/* 78 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Extend = __webpack_require__(17); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * Class containing all the shared state and behavior of a sound object, independent of the implementation. - * - * @class BaseSound - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - */ -var BaseSound = new Class({ - - Extends: EventEmitter, - - initialize: - - function BaseSound (manager, key, config) - { - EventEmitter.call(this); - - /** - * Local reference to the sound manager. - * - * @name Phaser.Sound.BaseSound#manager - * @type {Phaser.Sound.BaseSoundManager} - * @private - * @since 3.0.0 - */ - this.manager = manager; - - /** - * Asset key for the sound. - * - * @name Phaser.Sound.BaseSound#key - * @type {string} - * @readOnly - * @since 3.0.0 - */ - this.key = key; - - /** - * Flag indicating if sound is currently playing. - * - * @name Phaser.Sound.BaseSound#isPlaying - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isPlaying = false; - - /** - * Flag indicating if sound is currently paused. - * - * @name Phaser.Sound.BaseSound#isPaused - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isPaused = false; - - /** - * A property that holds the value of sound's actual playback rate, - * after its rate and detune values has been combined with global - * rate and detune values. - * - * @name Phaser.Sound.BaseSound#totalRate - * @type {number} - * @default 1 - * @readOnly - * @since 3.0.0 - */ - this.totalRate = 1; - - /** - * A value representing the duration, in seconds. - * It could be total sound duration or a marker duration. - * - * @name Phaser.Sound.BaseSound#duration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.duration = this.duration || 0; - - /** - * The total duration of the sound in seconds. - * - * @name Phaser.Sound.BaseSound#totalDuration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.totalDuration = this.totalDuration || 0; - - /** - * A config object used to store default sound settings' values. - * Default values will be set by properties' setters. - * - * @name Phaser.Sound.BaseSound#config - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.config = { - - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - - }; - - /** - * Reference to the currently used config. - * It could be default config or marker config. - * - * @name Phaser.Sound.BaseSound#currentConfig - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.currentConfig = this.config; - - this.config = Extend(this.config, config); - - /** - * Object containing markers definitions. - * - * @name Phaser.Sound.BaseSound#markers - * @type {Object.} - * @default {} - * @readOnly - * @since 3.0.0 - */ - this.markers = {}; - - /** - * Currently playing marker. - * 'null' if whole sound is playing. - * - * @name Phaser.Sound.BaseSound#currentMarker - * @type {SoundMarker} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.currentMarker = null; - - /** - * Flag indicating if destroy method was called on this sound. - * - * @name Phaser.Sound.BaseSound#pendingRemove - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.pendingRemove = false; - }, - - /** - * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. - * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. - * - * @method Phaser.Sound.BaseSound#addMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object. - * - * @return {boolean} Whether the marker was added successfully. - */ - addMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - - if (this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.error('addMarker ' + marker.name + ' already exists in Sound'); - - return false; - } - - marker = Extend(true, { - name: '', - start: 0, - duration: this.totalDuration - (marker.start || 0), - config: { - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - } - }, marker); - - this.markers[marker.name] = marker; - - return true; - }, - - /** - * Updates previously added marker. - * - * @method Phaser.Sound.BaseSound#updateMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object with updated values. - * - * @return {boolean} Whether the marker was updated successfully. - */ - updateMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - - if (!this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.warn('Audio Marker: ' + marker.name + ' missing in Sound: ' + this.key); - - return false; - } - - this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); - - return true; - }, - - /** - * Removes a marker from the sound. - * - * @method Phaser.Sound.BaseSound#removeMarker - * @since 3.0.0 - * - * @param {string} markerName - The name of the marker to remove. - * - * @return {?SoundMarker} Removed marker object or 'null' if there was no marker with provided name. - */ - removeMarker: function (markerName) - { - var marker = this.markers[markerName]; - - if (!marker) - { - return null; - } - - this.markers[markerName] = null; - - return marker; - }, - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * - * @method Phaser.Sound.BaseSound#play - * @since 3.0.0 - * - * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (markerName, config) - { - if (markerName === undefined) { markerName = ''; } - - if (typeof markerName === 'object') - { - config = markerName; - markerName = ''; - } - - if (typeof markerName !== 'string') - { - return false; - } - - if (!markerName) - { - this.currentMarker = null; - this.currentConfig = this.config; - this.duration = this.totalDuration; - } - else - { - if (!this.markers[markerName]) - { - // eslint-disable-next-line no-console - console.warn('Marker: ' + markerName + ' missing in Sound: ' + this.key); - - return false; - } - - this.currentMarker = this.markers[markerName]; - this.currentConfig = this.currentMarker.config; - this.duration = this.currentMarker.duration; - } - - this.resetConfig(); - - this.currentConfig = Extend(this.currentConfig, config); - - this.isPlaying = true; - this.isPaused = false; - - return true; - }, - - /** - * Pauses the sound. - * - * @method Phaser.Sound.BaseSound#pause - * @since 3.0.0 - * - * @return {boolean} Whether the sound was paused successfully. - */ - pause: function () - { - if (this.isPaused || !this.isPlaying) - { - return false; - } - - this.isPlaying = false; - this.isPaused = true; - - return true; - }, - - /** - * Resumes the sound. - * - * @method Phaser.Sound.BaseSound#resume - * @since 3.0.0 - * - * @return {boolean} Whether the sound was resumed successfully. - */ - resume: function () - { - if (!this.isPaused || this.isPlaying) - { - return false; - } - - this.isPlaying = true; - this.isPaused = false; - - return true; - }, - - /** - * Stop playing this sound. - * - * @method Phaser.Sound.BaseSound#stop - * @since 3.0.0 - * - * @return {boolean} Whether the sound was stopped successfully. - */ - stop: function () - { - if (!this.isPaused && !this.isPlaying) - { - return false; - } - - this.isPlaying = false; - this.isPaused = false; - - this.resetConfig(); - - return true; - }, - - /** - * Method used internally for applying config values to some of the sound properties. - * - * @method Phaser.Sound.BaseSound#applyConfig - * @protected - * @since 3.0.0 - */ - applyConfig: function () - { - this.mute = this.currentConfig.mute; - this.volume = this.currentConfig.volume; - this.rate = this.currentConfig.rate; - this.detune = this.currentConfig.detune; - this.loop = this.currentConfig.loop; - }, - - /** - * Method used internally for resetting values of some of the config properties. - * - * @method Phaser.Sound.BaseSound#resetConfig - * @protected - * @since 3.0.0 - */ - resetConfig: function () - { - this.currentConfig.seek = 0; - this.currentConfig.delay = 0; - }, - - /** - * Update method called automatically by sound manager on every game step. - * - * @method Phaser.Sound.BaseSound#update - * @override - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: NOOP, - - /** - * Method used internally to calculate total playback rate of the sound. - * - * @method Phaser.Sound.BaseSound#calculateRate - * @protected - * @since 3.0.0 - */ - calculateRate: function () - { - var cent = 1.0005777895065548; // Math.pow(2, 1/1200); - var totalDetune = this.currentConfig.detune + this.manager.detune; - var detuneRate = Math.pow(cent, totalDetune); - - this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; - }, - - /** - * Destroys this sound and all associated events and marks it for removal from the sound manager. - * - * @method Phaser.Sound.BaseSound#destroy - * @since 3.0.0 - */ - destroy: function () - { - if (this.pendingRemove) - { - return; - } - - this.emit('destroy', this); - this.pendingRemove = true; - this.manager = null; - this.key = ''; - this.removeAllListeners(); - this.isPlaying = false; - this.isPaused = false; - this.config = null; - this.currentConfig = null; - this.markers = null; - this.currentMarker = null; - } - -}); - -module.exports = BaseSound; - - -/***/ }), -/* 79 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Clone = __webpack_require__(33); -var EventEmitter = __webpack_require__(9); -var NOOP = __webpack_require__(3); - -/** - * @callback EachActiveSoundCallback - * - * @param {Phaser.Sound.BaseSoundManager} manager - The SoundManager - * @param {Phaser.Sound.BaseSound} sound - The current active Sound - * @param {number} index - The index of the current active Sound - * @param {Phaser.Sound.BaseSound[]} sounds - All sounds - */ - -/** - * Audio sprite sound type. - * - * @typedef {Phaser.Sound.BaseSound} Phaser.Sound.BaseSound.AudioSpriteSound - * - * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. - */ - -/** - * @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 - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var BaseSoundManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function BaseSoundManager (game) - { - EventEmitter.call(this); - - /** - * Local reference to game. - * - * @name Phaser.Sound.BaseSoundManager#game - * @type {Phaser.Game} - * @readOnly - * @since 3.0.0 - */ - this.game = game; - - /** - * Local reference to the JSON Cache, as used by Audio Sprites. - * - * @name Phaser.Sound.BaseSoundManager#jsonCache - * @type {Phaser.Cache.BaseCache} - * @readOnly - * @since 3.7.0 - */ - this.jsonCache = game.cache.json; - - /** - * An array containing all added sounds. - * - * @name Phaser.Sound.BaseSoundManager#sounds - * @type {Phaser.Sound.BaseSound[]} - * @default [] - * @private - * @since 3.0.0 - */ - this.sounds = []; - - /** - * Global mute setting. - * - * @name Phaser.Sound.BaseSoundManager#mute - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.mute = false; - - /** - * Global volume setting. - * - * @name Phaser.Sound.BaseSoundManager#volume - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.volume = 1; - - /** - * Flag indicating if sounds should be paused when game looses focus, - * for instance when user switches to another tab/program/app. - * - * @name Phaser.Sound.BaseSoundManager#pauseOnBlur - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.pauseOnBlur = true; - - /** - * Property that actually holds the value of global playback rate. - * - * @name Phaser.Sound.BaseSoundManager#_rate - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._rate = 1; - - /** - * Property that actually holds the value of global detune. - * - * @name Phaser.Sound.BaseSoundManager#_detune - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._detune = 0; - - /** - * Mobile devices require sounds to be triggered from an explicit user action, - * such as a tap, before any sound can be loaded/played on a web page. - * Set to true if the audio system is currently locked awaiting user interaction. - * - * @name Phaser.Sound.BaseSoundManager#locked - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.locked = this.locked || false; - - /** - * Flag used internally for handling when the audio system - * has been unlocked, if there ever was a need for it. - * - * @name Phaser.Sound.BaseSoundManager#unlocked - * @type {boolean} - * @default false - * @private - * @since 3.0.0 - */ - this.unlocked = false; - - game.events.on('blur', function () - { - if (this.pauseOnBlur) - { - this.onBlur(); - } - }, this); - - game.events.on('focus', function () - { - if (this.pauseOnBlur) - { - this.onFocus(); - } - }, this); - - game.events.on('prestep', this.update, this); - game.events.once('destroy', this.destroy, this); - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.BaseSoundManager#add - * @override - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.BaseSound} The new sound instance. - */ - add: NOOP, - - /** - * Adds a new audio sprite sound into the sound manager. - * Audio Sprites are a combination of audio files and a JSON configuration. - * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite - * - * @method Phaser.Sound.BaseSoundManager#addAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.BaseSound.AudioSpriteSound} The new audio sprite sound instance. - */ - addAudioSprite: function (key, config) - { - if (config === undefined) { config = {}; } - - var sound = this.add(key, config); - - sound.spritemap = this.jsonCache.get(key).spritemap; - - for (var markerName in sound.spritemap) - { - if (!sound.spritemap.hasOwnProperty(markerName)) - { - continue; - } - - var markerConfig = Clone(config); - - var marker = sound.spritemap[markerName]; - - markerConfig.loop = (marker.hasOwnProperty('loop')) ? marker.loop : false; - - sound.addMarker({ - name: markerName, - start: marker.start, - duration: marker.end - marker.start, - config: markerConfig - }); - } - - return sound; - }, - - /** - * Enables playing sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#play - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {(SoundConfig|SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (key, extra) - { - var sound = this.add(key); - - sound.once('ended', sound.destroy, sound); - - if (extra) - { - if (extra.name) - { - sound.addMarker(extra); - - return sound.play(extra.name); - } - else - { - return sound.play(extra); - } - } - else - { - return sound.play(); - } - }, - - /** - * Enables playing audio sprite sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#playAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {string} spriteName - The name of the sound sprite to play. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {boolean} Whether the audio sprite sound started playing successfully. - */ - playAudioSprite: function (key, spriteName, config) - { - var sound = this.addAudioSprite(key); - - sound.once('ended', sound.destroy, sound); - - return sound.play(spriteName, config); - }, - - /** - * Removes a sound from the sound manager. - * The removed sound is destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#remove - * @since 3.0.0 - * - * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. - * - * @return {boolean} True if the sound was removed successfully, otherwise false. - */ - remove: function (sound) - { - var index = this.sounds.indexOf(sound); - - if (index !== -1) - { - sound.destroy(); - - this.sounds.splice(index, 1); - - return true; - } - - return false; - }, - - /** - * Removes all sounds from the sound manager that have an asset key matching the given value. - * The removed sounds are destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#removeByKey - * @since 3.0.0 - * - * @param {string} key - The key to match when removing sound objects. - * - * @return {number} The number of matching sound objects that were removed. - */ - removeByKey: function (key) - { - var removed = 0; - - for (var i = this.sounds.length - 1; i >= 0; i--) - { - var sound = this.sounds[i]; - - if (sound.key === key) - { - sound.destroy(); - - this.sounds.splice(i, 1); - - removed++; - } - } - - return removed; - }, - - /** - * @event Phaser.Sound.BaseSoundManager#pauseall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - - /** - * Pauses all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#pauseAll - * @fires Phaser.Sound.BaseSoundManager#pauseall - * @since 3.0.0 - */ - pauseAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.pause(); - }); - - this.emit('pauseall', this); - }, - - /** - * @event Phaser.Sound.BaseSoundManager#resumeall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - - /** - * Resumes all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#resumeAll - * @fires Phaser.Sound.BaseSoundManager#resumeall - * @since 3.0.0 - */ - resumeAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.resume(); - }); - - this.emit('resumeall', this); - }, - - /** - * @event Phaser.Sound.BaseSoundManager#stopall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - - /** - * Stops all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#stopAll - * @fires Phaser.Sound.BaseSoundManager#stopall - * @since 3.0.0 - */ - stopAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.stop(); - }); - - this.emit('stopall', this); - }, - - /** - * Method used internally for unlocking audio playback on devices that - * require user interaction before any sound can be played on a web page. - * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - * - * @method Phaser.Sound.BaseSoundManager#unlock - * @override - * @protected - * @since 3.0.0 - */ - unlock: NOOP, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onBlur - * @override - * @protected - * @since 3.0.0 - */ - onBlur: NOOP, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onFocus - * @override - * @protected - * @since 3.0.0 - */ - onFocus: NOOP, - - /** - * Update method called on every game step. - * Removes destroyed sounds and updates every active sound in the game. - * - * @method Phaser.Sound.BaseSoundManager#update - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: function (time, delta) - { - if (this.unlocked) - { - this.unlocked = false; - this.locked = false; - - /** - * @event Phaser.Sound.BaseSoundManager#unlocked - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - this.emit('unlocked', this); - } - - for (var i = this.sounds.length - 1; i >= 0; i--) - { - if (this.sounds[i].pendingRemove) - { - this.sounds.splice(i, 1); - } - } - - this.sounds.forEach(function (sound) - { - sound.update(time, delta); - }); - }, - - /** - * Destroys all the sounds in the game and all associated events. - * - * @method Phaser.Sound.BaseSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllListeners(); - - this.forEachActiveSound(function (sound) - { - sound.destroy(); - }); - - this.sounds.length = 0; - this.sounds = null; - - this.game = null; - }, - - /** - * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. - * - * @method Phaser.Sound.BaseSoundManager#forEachActiveSound - * @private - * @since 3.0.0 - * - * @param {EachActiveSoundCallback} callback - Callback function. (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Manager.BaseSound[]) => void - * @param {*} [scope] - Callback context. - */ - forEachActiveSound: function (callback, scope) - { - var _this = this; - - this.sounds.forEach(function (sound, index) - { - if (!sound.pendingRemove) - { - callback.call(scope || _this, sound, index, _this.sounds); - } - }); - }, - - /** - * @event Phaser.Sound.BaseSoundManager#rate - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. - */ - - /** - * 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. - * - * @method Phaser.Sound.BaseSoundManager#setRate - * @fires Phaser.Sound.BaseSoundManager#rate - * @since 3.3.0 - * - * @param {number} value - Global playback rate at which all the sounds will be played. - * - * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. - */ - setRate: function (value) - { - this.rate = value; - - return this; - }, - - /** - * Global playback rate at which all the sounds will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audio's playback speed. - * - * @name Phaser.Sound.BaseSoundManager#rate - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rate: { - - get: function () - { - return this._rate; - }, - - set: function (value) - { - this._rate = value; - - this.forEachActiveSound(function (sound) - { - sound.calculateRate(); - }); - - this.emit('rate', this, value); - } - - }, - - /** - * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @method Phaser.Sound.BaseSoundManager#setDetune - * @fires Phaser.Sound.BaseSoundManager#detune - * @since 3.3.0 - * - * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. - */ - setDetune: function (value) - { - this.detune = value; - - return this; - }, - - /** - * @event Phaser.Sound.BaseSoundManager#detune - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. - */ - - /** - * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @name Phaser.Sound.BaseSoundManager#detune - * @type {number} - * @default 0 - * @since 3.0.0 - */ - detune: { - - get: function () - { - return this._detune; - }, - - set: function (value) - { - this._detune = value; - - this.forEachActiveSound(function (sound) - { - sound.calculateRate(); - }); - - this.emit('detune', this, value); - } - - } - -}); - -module.exports = BaseSoundManager; - - -/***/ }), -/* 80 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(57); - -/** - * Determines the browser type and version running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.browser` from within any Scene. - * - * @typedef {object} Phaser.Device.Browser - * @since 3.0.0 - * - * @property {boolean} chrome - Set to true if running in Chrome. - * @property {boolean} edge - Set to true if running in Microsoft Edge browser. - * @property {boolean} firefox - Set to true if running in Firefox. - * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). - * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. - * @property {boolean} opera - Set to true if running in Opera. - * @property {boolean} safari - Set to true if running in Safari. - * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) - * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) - * @property {number} chromeVersion - If running in Chrome this will contain the major version number. - * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. - * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. - * @property {number} safariVersion - If running in Safari this will contain the major version number. - * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} - */ -var Browser = { - - chrome: false, - chromeVersion: 0, - edge: false, - firefox: false, - firefoxVersion: 0, - ie: false, - ieVersion: 0, - mobileSafari: false, - opera: false, - safari: false, - safariVersion: 0, - silk: false, - trident: false, - tridentVersion: 0 - -}; - -function init () -{ - var ua = navigator.userAgent; - - if (/Edge\/\d+/.test(ua)) - { - Browser.edge = true; - } - else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) - { - Browser.chrome = true; - Browser.chromeVersion = parseInt(RegExp.$1, 10); - } - else if ((/Firefox\D+(\d+)/).test(ua)) - { - Browser.firefox = true; - Browser.firefoxVersion = parseInt(RegExp.$1, 10); - } - else if ((/AppleWebKit/).test(ua) && OS.iOS) - { - Browser.mobileSafari = true; - } - else if ((/MSIE (\d+\.\d+);/).test(ua)) - { - Browser.ie = true; - Browser.ieVersion = parseInt(RegExp.$1, 10); - } - else if ((/Opera/).test(ua)) - { - Browser.opera = true; - } - else if ((/Safari/).test(ua) && !OS.windowsPhone) - { - Browser.safari = true; - } - else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) - { - Browser.ie = true; - Browser.trident = true; - Browser.tridentVersion = parseInt(RegExp.$1, 10); - Browser.ieVersion = parseInt(RegExp.$3, 10); - } - - // Silk gets its own if clause because its ua also contains 'Safari' - if ((/Silk/).test(ua)) - { - Browser.silk = true; - } - - return Browser; -} - -module.exports = init(); - - -/***/ }), -/* 81 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback DataEachCallback - * - * @param {*} parent - The parent object of the DataManager. - * @param {string} key - The key of the value. - * @param {*} value - The value. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. - */ - -/** - * @classdesc - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - * - * @class DataManager - * @memberOf Phaser.Data - * @constructor - * @since 3.0.0 - * - * @param {object} parent - The object that this DataManager belongs to. - * @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter. - */ -var DataManager = new Class({ - - initialize: - - function DataManager (parent, eventEmitter) - { - /** - * The object that this DataManager belongs to. - * - * @name Phaser.Data.DataManager#parent - * @type {*} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * The DataManager's event emitter. - * - * @name Phaser.Data.DataManager#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events = eventEmitter; - - if (!eventEmitter) - { - this.events = (parent.events) ? parent.events : parent; - } - - /** - * The data list. - * - * @name Phaser.Data.DataManager#list - * @type {Object.} - * @default {} - * @since 3.0.0 - */ - this.list = {}; - - /** - * The public values list. You can use this to access anything you have stored - * in this Data Manager. For example, if you set a value called `gold` you can - * access it via: - * - * ```javascript - * this.data.values.gold; - * ``` - * - * You can also modify it directly: - * - * ```javascript - * this.data.values.gold += 1000; - * ``` - * - * Doing so will emit a `setdata` event from the parent of this Data Manager. - * - * @name Phaser.Data.DataManager#values - * @type {Object.} - * @default {} - * @since 3.10.0 - */ - this.values = {}; - - /** - * Whether setting data is frozen for this DataManager. - * - * @name Phaser.Data.DataManager#_frozen - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._frozen = false; - - if (!parent.hasOwnProperty('sys') && this.events) - { - this.events.once('destroy', this.destroy, this); - } - }, - - /** - * Retrieves the value for the given key, or undefined if it doesn't exist. - * - * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * - * ```javascript - * this.data.get('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * this.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: - * - * ```javascript - * this.data.get([ 'gold', 'armor', 'health' ]); - * ``` - * - * This approach is useful for destructuring arrays in ES6. - * - * @method Phaser.Data.DataManager#get - * @since 3.0.0 - * - * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. - * - * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. - */ - get: function (key) - { - var list = this.list; - - if (Array.isArray(key)) - { - var output = []; - - for (var i = 0; i < key.length; i++) - { - output.push(list[key[i]]); - } - - return output; - } - else - { - return list[key]; - } - }, - - /** - * Retrieves all data values in a new object. - * - * @method Phaser.Data.DataManager#getAll - * @since 3.0.0 - * - * @return {Object.} All data values. - */ - getAll: function () - { - var results = {}; - - for (var key in this.list) - { - if (this.list.hasOwnProperty(key)) - { - results[key] = this.list[key]; - } - } - - return results; - }, - - /** - * Queries the DataManager for the values of keys matching the given regular expression. - * - * @method Phaser.Data.DataManager#query - * @since 3.0.0 - * - * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). - * - * @return {Object.} The values of the keys matching the search string. - */ - query: function (search) - { - var results = {}; - - for (var key in this.list) - { - if (this.list.hasOwnProperty(key) && key.match(search)) - { - results[key] = this.list[key]; - } - } - - return results; - }, - - /** - * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * data.set('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `get`: - * - * ```javascript - * data.get('gold'); - * ``` - * - * Or you can access the value directly via the `values` property, where it works like any other variable: - * - * ```javascript - * data.values.gold += 50; - * ``` - * - * When the value is first set, a `setdata` event is emitted. - * - * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. - * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. - * - * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * - * @method Phaser.Data.DataManager#set - * @since 3.0.0 - * - * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. - * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - set: function (key, data) - { - if (this._frozen) - { - return this; - } - - if (typeof key === 'string') - { - return this.setValue(key, data); - } - else - { - for (var entry in key) - { - this.setValue(entry, key[entry]); - } - } - - return this; - }, - - /** - * Internal value setter, called automatically by the `set` method. - * - * @method Phaser.Data.DataManager#setValue - * @private - * @since 3.10.0 - * - * @param {string} key - The key to set the value for. - * @param {*} data - The value to set. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - setValue: function (key, data) - { - if (this._frozen) - { - return this; - } - - if (this.has(key)) - { - // Hit the key getter, which will in turn emit the events. - this.values[key] = data; - } - else - { - var _this = this; - var list = this.list; - var events = this.events; - var parent = this.parent; - - Object.defineProperty(this.values, key, { - - enumerable: true, - - get: function () - { - return list[key]; - }, - - set: function (value) - { - if (!_this._frozen) - { - list[key] = value; - - events.emit('changedata', parent, key, data); - events.emit('changedata_' + key, parent, data); - } - } - - }); - - list[key] = data; - - events.emit('setdata', parent, key, data); - } - - return this; - }, - - /** - * Passes all data entries to the given callback. - * - * @method Phaser.Data.DataManager#each - * @since 3.0.0 - * - * @param {DataEachCallback} callback - The function to call. - * @param {*} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - each: function (callback, context) - { - var args = [ this.parent, null, undefined ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var key in this.list) - { - args[1] = key; - args[2] = this.list[key]; - - callback.apply(context, args); - } - - return this; - }, - - /** - * Merge the given object of key value pairs into this DataManager. - * - * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) - * will emit a `changedata` event. - * - * @method Phaser.Data.DataManager#merge - * @since 3.0.0 - * - * @param {Object.} data - The data to merge. - * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - merge: function (data, overwrite) - { - if (overwrite === undefined) { overwrite = true; } - - // Merge data from another component into this one - for (var key in data) - { - if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) - { - this.setValue(key, data[key]); - } - } - - return this; - }, - - /** - * Remove the value for the given key. - * - * If the key is found in this Data Manager it is removed from the internal lists and a - * `removedata` event is emitted. - * - * You can also pass in an array of keys, in which case all keys in the array will be removed: - * - * ```javascript - * this.data.remove([ 'gold', 'armor', 'health' ]); - * ``` - * - * @method Phaser.Data.DataManager#remove - * @since 3.0.0 - * - * @param {(string|string[])} key - The key to remove, or an array of keys to remove. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - remove: function (key) - { - if (this._frozen) - { - return this; - } - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - this.removeValue(key[i]); - } - } - else - { - return this.removeValue(key); - } - - return this; - }, - - /** - * Internal value remover, called automatically by the `remove` method. - * - * @method Phaser.Data.DataManager#removeValue - * @private - * @since 3.10.0 - * - * @param {string} key - The key to set the value for. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - removeValue: function (key) - { - if (this.has(key)) - { - var data = this.list[key]; - - delete this.list[key]; - delete this.values[key]; - - this.events.emit('removedata', this, key, data); - } - - return this; - }, - - /** - * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. - * - * @method Phaser.Data.DataManager#pop - * @since 3.0.0 - * - * @param {string} key - The key of the value to retrieve and delete. - * - * @return {*} The value of the given key. - */ - pop: function (key) - { - var data = undefined; - - if (!this._frozen && this.has(key)) - { - data = this.list[key]; - - delete this.list[key]; - delete this.values[key]; - - this.events.emit('removedata', this, key, data); - } - - return data; - }, - - /** - * Determines whether the given key is set in this Data Manager. - * - * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * - * @method Phaser.Data.DataManager#has - * @since 3.0.0 - * - * @param {string} key - The key to check. - * - * @return {boolean} Returns `true` if the key exists, otherwise `false`. - */ - has: function (key) - { - return this.list.hasOwnProperty(key); - }, - - /** - * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts - * to create new values or update existing ones. - * - * @method Phaser.Data.DataManager#setFreeze - * @since 3.0.0 - * - * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - setFreeze: function (value) - { - this._frozen = value; - - return this; - }, - - /** - * Delete all data in this Data Manager and unfreeze it. - * - * @method Phaser.Data.DataManager#reset - * @since 3.0.0 - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - reset: function () - { - for (var key in this.list) - { - delete this.list[key]; - delete this.values[key]; - } - - this._frozen = false; - - return this; - }, - - /** - * Destroy this data manager. - * - * @method Phaser.Data.DataManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.reset(); - - this.events.off('changedata'); - this.events.off('setdata'); - this.events.off('removedata'); - - this.parent = null; - }, - - /** - * Gets or sets the frozen state of this Data Manager. - * A frozen Data Manager will block all attempts to create new values or update existing ones. - * - * @name Phaser.Data.DataManager#freeze - * @type {boolean} - * @since 3.0.0 - */ - freeze: { - - get: function () - { - return this._frozen; - }, - - set: function (value) - { - this._frozen = (value) ? true : false; - } - - }, - - /** - * Return the total number of entries in this Data Manager. - * - * @name Phaser.Data.DataManager#count - * @type {integer} - * @since 3.0.0 - */ - count: { - - get: function () - { - var i = 0; - - for (var key in this.list) - { - if (this.list[key] !== undefined) - { - i++; - } - } - - return i; - } - - } - -}); - -module.exports = DataManager; - - -/***/ }), -/* 82 */, -/* 83 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -//! stable.js 0.1.6, https://github.com/Two-Screen/stable -//! © 2017 Angry Bytes and contributors. MIT licensed. - -(function() { - -// A stable array sort, because `Array#sort()` is not guaranteed stable. -// This is an implementation of merge sort, without recursion. - -var stable = function(arr, comp) { - return exec(arr.slice(), comp); -}; - -stable.inplace = function(arr, comp) { - var result = exec(arr, comp); - - // This simply copies back if the result isn't in the original array, - // which happens on an odd number of passes. - if (result !== arr) { - pass(result, null, arr.length, arr); - } - - return arr; -}; - -// Execute the sort using the input array and a second buffer as work space. -// Returns one of those two, containing the final result. -function exec(arr, comp) { - if (typeof(comp) !== 'function') { - comp = function(a, b) { - return String(a).localeCompare(b); - }; - } - - // Short-circuit when there's nothing to sort. - var len = arr.length; - if (len <= 1) { - return arr; - } - - // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. - // Chunks are the size of the left or right hand in merge sort. - // Stop when the left-hand covers all of the array. - var buffer = new Array(len); - for (var chk = 1; chk < len; chk *= 2) { - pass(arr, comp, chk, buffer); - - var tmp = arr; - arr = buffer; - buffer = tmp; - } - - return arr; -} - -// Run a single pass with the given chunk size. -var pass = function(arr, comp, chk, result) { - var len = arr.length; - var i = 0; - // Step size / double chunk size. - var dbl = chk * 2; - // Bounds of the left and right chunks. - var l, r, e; - // Iterators over the left and right chunk. - var li, ri; - - // Iterate over pairs of chunks. - for (l = 0; l < len; l += dbl) { - r = l + chk; - e = r + chk; - if (r > len) r = len; - if (e > len) e = len; - - // Iterate both chunks in parallel. - li = l; - ri = r; - while (true) { - // Compare the chunks. - if (li < r && ri < e) { - // This works for a regular `sort()` compatible comparator, - // but also for a simple comparator like: `a > b` - if (comp(arr[li], arr[ri]) <= 0) { - result[i++] = arr[li++]; - } - else { - result[i++] = arr[ri++]; - } - } - // Nothing to compare, just flush what's left. - else if (li < r) { - result[i++] = arr[li++]; - } - else if (ri < e) { - result[i++] = arr[ri++]; - } - // Both iterators are at the chunk ends. - else { - break; - } - } - } -}; - -// Export using CommonJS or to the window. -if (true) { - module.exports = stable; -} -else {} - -})(); - -/***/ }), -/* 84 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Utils = __webpack_require__(27); - -/** - * @classdesc - * WebGLPipeline is a class that describes the way elements will be rendererd - * in WebGL, specially focused on batching vertices (batching is not provided). - * Pipelines are mostly used for describing 2D rendering passes but it's - * flexible enough to be used for any type of rendering including 3D. - * Internally WebGLPipeline will handle things like compiling shaders, - * creating vertex buffers, assigning primitive topology and binding - * vertex attributes. - * - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - gl: Current WebGL context. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - vertices: An optional buffer of vertices - * - attributes: An array describing the vertex attributes - * - * The vertex attributes properties are: - * - name : String - Name of the attribute in the vertex shader - * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 - * - type : GLenum - WebGL type (gl.BYTE, gl.SHORT, gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.FLOAT) - * - normalized : boolean - Is the attribute normalized - * - offset : integer - The offset in bytes to the current attribute in the vertex. Equivalent to offsetof(vertex, attrib) in C - * Here you can find more information of how to describe an attribute: - * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer - * - * @class WebGLPipeline - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var WebGLPipeline = new Class({ - - initialize: - - function WebGLPipeline (config) - { - /** - * Name of the Pipeline. Used for identifying - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#name - * @type {string} - * @since 3.0.0 - */ - this.name = 'WebGLPipeline'; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = config.game; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#view - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.view = config.game.canvas; - - /** - * Used to store the current game resolution - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#resolution - * @type {number} - * @since 3.0.0 - */ - this.resolution = config.game.config.resolution; - - /** - * Width of the current viewport - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#width - * @type {number} - * @since 3.0.0 - */ - this.width = config.game.config.width * this.resolution; - - /** - * Height of the current viewport - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#height - * @type {number} - * @since 3.0.0 - */ - this.height = config.game.config.height * this.resolution; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#gl - * @type {WebGLRenderingContext} - * @since 3.0.0 - */ - this.gl = config.gl; - - /** - * How many vertices have been fed to the current pipeline. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.vertexCount = 0; - - /** - * The limit of vertices that the pipeline can hold - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity - * @type {integer} - * @since 3.0.0 - */ - this.vertexCapacity = config.vertexCapacity; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#renderer - * @type {Phaser.Renderer.WebGL.WebGLRenderer} - * @since 3.0.0 - */ - this.renderer = config.renderer; - - /** - * Raw byte buffer of vertices. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexData - * @type {ArrayBuffer} - * @since 3.0.0 - */ - this.vertexData = (config.vertices ? config.vertices : new ArrayBuffer(config.vertexCapacity * config.vertexSize)); - - /** - * The handle to a WebGL vertex buffer object. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer - * @type {WebGLBuffer} - * @since 3.0.0 - */ - this.vertexBuffer = this.renderer.createVertexBuffer((config.vertices ? config.vertices : this.vertexData.byteLength), this.gl.STREAM_DRAW); - - /** - * The handle to a WebGL program - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#program - * @type {WebGLProgram} - * @since 3.0.0 - */ - this.program = this.renderer.createProgram(config.vertShader, config.fragShader); - - /** - * Array of objects that describe the vertex attributes - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#attributes - * @type {object} - * @since 3.0.0 - */ - this.attributes = config.attributes; - - /** - * The size in bytes of the vertex - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexSize - * @type {integer} - * @since 3.0.0 - */ - this.vertexSize = config.vertexSize; - - /** - * The primitive topology which the pipeline will use to submit draw calls - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#topology - * @type {integer} - * @since 3.0.0 - */ - this.topology = config.topology; - - /** - * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources - * to the GPU. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#bytes - * @type {Uint8Array} - * @since 3.0.0 - */ - this.bytes = new Uint8Array(this.vertexData); - - /** - * This will store the amount of components of 32 bit length - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexComponentCount - * @type {integer} - * @since 3.0.0 - */ - this.vertexComponentCount = Utils.getComponentCount(config.attributes, this.gl); - - /** - * Indicates if the current pipeline is flushing the contents to the GPU. - * When the variable is set the flush function will be locked. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#flushLocked - * @type {boolean} - * @since 3.1.0 - */ - this.flushLocked = false; - - /** - * Indicates if the current pipeline is active or not for this frame only. - * Reset in the onRender method. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#active - * @type {boolean} - * @since 3.10.0 - */ - this.active = false; - }, - - /** - * Adds a description of vertex attribute to the pipeline - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#addAttribute - * @since 3.2.0 - * - * @param {string} name - Name of the vertex attribute - * @param {integer} size - Vertex component size - * @param {integer} type - Type of the attribute - * @param {boolean} normalized - Is the value normalized to a range - * @param {integer} offset - Byte offset to the beginning of the first element in the vertex - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - addAttribute: function (name, size, type, normalized, offset) - { - this.attributes.push({ - name: name, - size: size, - type: this.renderer.glFormats[type], - normalized: normalized, - offset: offset - }); - - return this; - }, - - /** - * Check if the current batch of vertices is full. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush - * @since 3.0.0 - * - * @return {boolean} [description] - */ - shouldFlush: function () - { - return (this.vertexCount >= this.vertexCapacity); - }, - - /** - * Resizes the properties used to describe the viewport - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - resize: function (width, height, resolution) - { - this.width = width * resolution; - this.height = height * resolution; - return this; - }, - - /** - * Binds the pipeline resources, including programs, vertex buffers and binds attributes - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#bind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - bind: function () - { - var gl = this.gl; - var vertexBuffer = this.vertexBuffer; - var attributes = this.attributes; - var program = this.program; - var renderer = this.renderer; - var vertexSize = this.vertexSize; - - renderer.setProgram(program); - renderer.setVertexBuffer(vertexBuffer); - - for (var index = 0; index < attributes.length; ++index) - { - var element = attributes[index]; - var location = gl.getAttribLocation(program, element.name); - - if (location >= 0) - { - gl.enableVertexAttribArray(location); - gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexSize, element.offset); - } - else - { - gl.disableVertexAttribArray(location); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onBind: function () - { - // This is for updating uniform data it's called on each bind attempt. - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onPreRender - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onPreRender: function () - { - // called once every frame - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onRender - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onRender: function () - { - // called for each camera - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onPostRender - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onPostRender: function () - { - // called once every frame - return this; - }, - - /** - * Uploads the vertex data and emits a draw call - * for the current batch of vertices. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#flush - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - flush: function () - { - if (this.flushLocked) { return this; } - - this.flushLocked = true; - - var gl = this.gl; - var vertexCount = this.vertexCount; - var topology = this.topology; - var vertexSize = this.vertexSize; - - if (vertexCount === 0) - { - this.flushLocked = false; - return; - } - - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); - gl.drawArrays(topology, 0, vertexCount); - - this.vertexCount = 0; - this.flushLocked = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#destroy - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - destroy: function () - { - var gl = this.gl; - - gl.deleteProgram(this.program); - gl.deleteBuffer(this.vertexBuffer); - - delete this.program; - delete this.vertexBuffer; - delete this.gl; - - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {float} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat1: function (name, x) - { - this.renderer.setFloat1(this.program, name, x); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat2: function (name, x, y) - { - - this.renderer.setFloat2(this.program, name, x, y); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat3: function (name, x, y, z) - { - - this.renderer.setFloat3(this.program, name, x, y, z); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4 - * @since 3.2.0 - * - * @param {string} name - Name of the uniform - * @param {float} x - X component of the uniform - * @param {float} y - Y component of the uniform - * @param {float} z - Z component of the uniform - * @param {float} w - W component of the uniform - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat4: function (name, x, y, z, w) - { - - this.renderer.setFloat4(this.program, name, x, y, z, w); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt1 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {integer} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt1: function (name, x) - { - this.renderer.setInt1(this.program, name, x); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt2 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt2: function (name, x, y) - { - this.renderer.setInt2(this.program, name, x, y); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt3 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt3: function (name, x, y, z) - { - this.renderer.setInt3(this.program, name, x, y, z); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt4 - * @since 3.2.0 - * - * @param {string} name - Name of the uniform - * @param {integer} x - X component of the uniform - * @param {integer} y - Y component of the uniform - * @param {integer} z - Z component of the uniform - * @param {integer} w - W component of the uniform - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt4: function (name, x, y, z, w) - { - this.renderer.setInt4(this.program, name, x, y, z, w); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setMatrix2: function (name, transpose, matrix) - { - this.renderer.setMatrix2(this.program, name, transpose, matrix); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * [description] - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setMatrix3: function (name, transpose, matrix) - { - this.renderer.setMatrix3(this.program, name, transpose, matrix); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4 - * @since 3.2.0 - * - * @param {string} name - Name of the uniform - * @param {boolean} transpose - Should the matrix be transpose - * @param {Float32Array} matrix - Matrix data - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setMatrix4: function (name, transpose, matrix) - { - this.renderer.setMatrix4(this.program, name, transpose, matrix); - return this; - } - -}); - -module.exports = WebGLPipeline; - - -/***/ }), -/* 85 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks if the given `width` and `height` are a power of two. - * Useful for checking texture dimensions. - * - * @function Phaser.Math.Pow2.IsSizePowerOfTwo - * @since 3.0.0 - * - * @param {number} width - The width. - * @param {number} height - The height. - * - * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. - */ -var IsSizePowerOfTwo = function (width, height) -{ - return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); -}; - -module.exports = IsSizePowerOfTwo; - - -/***/ }), -/* 86 */, -/* 87 */, -/* 88 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(32); -var GetPoint = __webpack_require__(298); -var GetPoints = __webpack_require__(296); -var Random = __webpack_require__(157); - -/** - * @classdesc - * A Circle object. - * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render a Circle you should look at the capabilities of the Graphics class. - * - * @class Circle - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the circle. - * @param {number} [y=0] - The y position of the center of the circle. - * @param {number} [radius=0] - The radius of the circle. - */ -var Circle = new Class({ - - initialize: - - function Circle (x, y, radius) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (radius === undefined) { radius = 0; } - - /** - * The x position of the center of the circle. - * - * @name Phaser.Geom.Circle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the center of the circle. - * - * @name Phaser.Geom.Circle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * The internal radius of the circle. - * - * @name Phaser.Geom.Circle#_radius - * @type {number} - * @private - * @since 3.0.0 - */ - this._radius = radius; - - /** - * The internal diameter of the circle. - * - * @name Phaser.Geom.Circle#_diameter - * @type {number} - * @private - * @since 3.0.0 - */ - this._diameter = radius * 2; - }, - - /** - * Check to see if the Circle contains the given x / y coordinates. - * - * @method Phaser.Geom.Circle#contains - * @since 3.0.0 - * - * @param {number} x - The x coordinate to check within the circle. - * @param {number} y - The y coordinate to check within the circle. - * - * @return {boolean} True if the coordinates are within the circle, otherwise false. - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @method Phaser.Geom.Circle#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. - */ - getPoint: function (position, point) - { - return GetPoint(this, position, point); - }, - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. - * - * @method Phaser.Geom.Circle#getPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [output,$return] - * - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param {(array|Phaser.Geom.Point[])} [output] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {(array|Phaser.Geom.Point[])} An array of Point objects pertaining to the points around the circumference of the circle. - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * Returns a uniformly distributed random point from anywhere within the Circle. - * - * @method Phaser.Geom.Circle#getRandomPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * Sets the x, y and radius of this circle. - * - * @method Phaser.Geom.Circle#setTo - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the circle. - * @param {number} [y=0] - The y position of the center of the circle. - * @param {number} [radius=0] - The radius of the circle. - * - * @return {Phaser.Geom.Circle} This Circle object. - */ - setTo: function (x, y, radius) - { - this.x = x; - this.y = y; - this._radius = radius; - this._diameter = radius * 2; - - return this; - }, - - /** - * Sets this Circle to be empty with a radius of zero. - * Does not change its position. - * - * @method Phaser.Geom.Circle#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Circle} This Circle object. - */ - setEmpty: function () - { - this._radius = 0; - this._diameter = 0; - - return this; - }, - - /** - * Sets the position of this Circle. - * - * @method Phaser.Geom.Circle#setPosition - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the circle. - * @param {number} [y=0] - The y position of the center of the circle. - * - * @return {Phaser.Geom.Circle} This Circle object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Checks to see if the Circle is empty: has a radius of zero. - * - * @method Phaser.Geom.Circle#isEmpty - * @since 3.0.0 - * - * @return {boolean} True if the Circle is empty, otherwise false. - */ - isEmpty: function () - { - return (this._radius <= 0); - }, - - /** - * The radius of the Circle. - * - * @name Phaser.Geom.Circle#radius - * @type {number} - * @since 3.0.0 - */ - radius: { - - get: function () - { - return this._radius; - }, - - set: function (value) - { - this._radius = value; - this._diameter = value * 2; - } - - }, - - /** - * The diameter of the Circle. - * - * @name Phaser.Geom.Circle#diameter - * @type {number} - * @since 3.0.0 - */ - diameter: { - - get: function () - { - return this._diameter; - }, - - set: function (value) - { - this._diameter = value; - this._radius = value * 0.5; - } - - }, - - /** - * The left position of the Circle. - * - * @name Phaser.Geom.Circle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.x - this._radius; - }, - - set: function (value) - { - this.x = value + this._radius; - } - - }, - - /** - * The right position of the Circle. - * - * @name Phaser.Geom.Circle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.x + this._radius; - }, - - set: function (value) - { - this.x = value - this._radius; - } - - }, - - /** - * The top position of the Circle. - * - * @name Phaser.Geom.Circle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y - this._radius; - }, - - set: function (value) - { - this.y = value + this._radius; - } - - }, - - /** - * The bottom position of the Circle. - * - * @name Phaser.Geom.Circle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + this._radius; - }, - - set: function (value) - { - this.y = value - this._radius; - } - - } - -}); - -module.exports = Circle; - - -/***/ }), -/* 89 */, -/* 90 */, -/* 91 */, -/* 92 */, -/* 93 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArrayUtils = __webpack_require__(147); -var Class = __webpack_require__(0); -var NOOP = __webpack_require__(3); -var StableSort = __webpack_require__(83); - -/** - * @callback EachListCallback - * @generic I - [item] - * - * @param {*} item - [description] - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ - -/** - * @classdesc - * [description] - * - * @class List - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic T - * - * @param {*} parent - [description] - */ -var List = new Class({ - - initialize: - - function List (parent) - { - /** - * The parent of this list. - * - * @name Phaser.Structs.List#parent - * @type {*} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * The objects that belong to this collection. - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.List#list - * @type {Array.<*>} - * @default [] - * @since 3.0.0 - */ - this.list = []; - - /** - * [description] - * - * @name Phaser.Structs.List#position - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.position = 0; - - /** - * A callback that is invoked every time a child is added to this list. - * - * @name Phaser.Structs.List#addCallback - * @type {function} - * @since 3.4.0 - */ - this.addCallback = NOOP; - - /** - * A callback that is invoked every time a child is removed from this list. - * - * @name Phaser.Structs.List#removeCallback - * @type {function} - * @since 3.4.0 - */ - this.removeCallback = NOOP; - - /** - * The property key to sort by. - * - * @name Phaser.Structs.List#_sortKey - * @type {string} - * @since 3.4.0 - */ - this._sortKey = ''; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#add - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*|Array.<*>} child - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. - * - * @return {*} [description] - */ - add: function (child, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.Add(this.list, child); - } - else - { - return ArrayUtils.Add(this.list, child, 0, this.addCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#addAt - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * @param {integer} [index=0] - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. - * - * @return {*} [description] - */ - addAt: function (child, index, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.AddAt(this.list, child, index); - } - else - { - return ArrayUtils.AddAt(this.list, child, index, 0, this.addCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getAt - * @since 3.0.0 - * - * @genericUse {T} - [$return] - * - * @param {integer} index - [description] - * - * @return {*} [description] - */ - getAt: function (index) - { - return this.list[index]; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getIndex - * @since 3.0.0 - * - * @genericUse {T} - [child] - * - * @param {*} child - [description] - * - * @return {integer} [description] - */ - getIndex: function (child) - { - // Return -1 if given child isn't a child of this display list - return this.list.indexOf(child); - }, - - /** - * Sort the contents of this List so the items are in order based - * on the given property. For example, `sort('alpha')` would sort the List - * contents based on the value of their `alpha` property. - * - * @method Phaser.Structs.List#sort - * @since 3.0.0 - * - * @genericUse {T[]} - [children,$return] - * - * @param {string} property - The property to lexically sort by. - * - * @return {Array.<*>} [description] - */ - sort: function (property) - { - if (property) - { - this._sortKey = property; - - StableSort.inplace(this.list, this.sortHandler); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#sortHandler - * @private - * @since 3.4.0 - * - * @genericUse {T} - [childA,childB] - * - * @param {*} childA - [description] - * @param {*} childB - [description] - * - * @return {integer} [description] - */ - sortHandler: function (childA, childB) - { - return childA[this._sortKey] - childB[this._sortKey]; - }, - - /** - * Searches for the first instance of a child with its `name` - * property matching the given argument. Should more than one child have - * the same name only the first is returned. - * - * @method Phaser.Structs.List#getByName - * @since 3.0.0 - * - * @genericUse {T | null} - [$return] - * - * @param {string} name - The name to search for. - * - * @return {?*} The first child with a matching name, or null if none were found. - */ - getByName: function (name) - { - return ArrayUtils.GetFirst(this.list, 'name', name); - }, - - /** - * Returns a random child from the group. - * - * @method Phaser.Structs.List#getRandom - * @since 3.0.0 - * - * @genericUse {T | null} - [$return] - * - * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child). - * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from. - * - * @return {?*} A random child of this Group. - */ - getRandom: function (startIndex, length) - { - return ArrayUtils.GetRandom(this.list, startIndex, length); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getFirst - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {T | null} - [$return] - * - * @param {string} property - [description] - * @param {*} value - [description] - * @param {number} [startIndex=0] - [description] - * @param {number} [endIndex] - [description] - * - * @return {?*} [description] - */ - getFirst: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); - }, - - /** - * Returns all children in this List. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('parent')` would return only children that have a property called `parent`. - * - * You can also specify a value to compare the property to: - * - * `getAll('visible', true)` would return only children that have their visible property set to `true`. - * - * Optionally you can specify a start and end index. For example if this List had 100 children, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 children in the List. - * - * @method Phaser.Structs.List#getAll - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {T[]} - [$return] - * - * @param {string} [property] - An optional property to test against the value argument. - * @param {*} [value] - If property is set then Child.property must strictly equal this value to be included in the results. - * @param {integer} [startIndex] - The first child index to start the search from. - * @param {integer} [endIndex] - The last child index to search up until. - * - * @return {Array.<*>} [description] - */ - getAll: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#count - * @since 3.0.0 - * - * @genericUse {T} - [value] - * - * @param {string} property - [description] - * @param {*} value - [description] - * - * @return {integer} [description] - */ - count: function (property, value) - { - return ArrayUtils.CountAllMatching(this.list, property, value); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#swap - * @since 3.0.0 - * - * @genericUse {T} - [child1,child2] - * - * @param {*} child1 - [description] - * @param {*} child2 - [description] - */ - swap: function (child1, child2) - { - ArrayUtils.Swap(this.list, child1, child2); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#moveTo - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * @param {integer} index - [description] - * - * @return {*} [description] - */ - moveTo: function (child, index) - { - return ArrayUtils.MoveTo(this.list, child, index); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#remove - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {*} [description] - */ - remove: function (child, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.Remove(this.list, child); - } - else - { - return ArrayUtils.Remove(this.list, child, this.removeCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#removeAt - * @since 3.0.0 - * - * @genericUse {T} - [$return] - * - * @param {integer} index - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {*} [description] - */ - removeAt: function (index, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.RemoveAt(this.list, index); - } - else - { - return ArrayUtils.RemoveAt(this.list, index, this.removeCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#removeBetween - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @param {integer} [startIndex=0] - [description] - * @param {integer} [endIndex] - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {Array.<*>} [description] - */ - removeBetween: function (startIndex, endIndex, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex); - } - else - { - return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeCallback, this); - } - }, - - /** - * Removes all the items. - * - * @method Phaser.Structs.List#removeAll - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.List.} - [$return] - * - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {Phaser.Structs.List} This List object. - */ - removeAll: function (skipCallback) - { - var i = this.list.length; - - while (i--) - { - this.remove(this.list[i], skipCallback); - } - - return this; - }, - - /** - * Brings the given child to the top of this List. - * - * @method Phaser.Structs.List#bringToTop - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - bringToTop: function (child) - { - return ArrayUtils.BringToTop(this.list, child); - }, - - /** - * Sends the given child to the bottom of this List. - * - * @method Phaser.Structs.List#sendToBack - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - sendToBack: function (child) - { - return ArrayUtils.SendToBack(this.list, child); - }, - - /** - * Moves the given child up one place in this group unless it's already at the top. - * - * @method Phaser.Structs.List#moveUp - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - moveUp: function (child) - { - ArrayUtils.MoveUp(this.list, child); - - return child; - }, - - /** - * Moves the given child down one place in this group unless it's already at the bottom. - * - * @method Phaser.Structs.List#moveDown - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - moveDown: function (child) - { - ArrayUtils.MoveDown(this.list, child); - - return child; - }, - - /** - * Reverses the order of all children in this List. - * - * @method Phaser.Structs.List#reverse - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.List.} - [$return] - * - * @return {Phaser.Structs.List} This List object. - */ - reverse: function () - { - this.list.reverse(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#shuffle - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.List.} - [$return] - * - * @return {Phaser.Structs.List} This List object. - */ - shuffle: function () - { - ArrayUtils.Shuffle(this.list); - - return this; - }, - - /** - * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. - * - * @method Phaser.Structs.List#replace - * @since 3.0.0 - * - * @genericUse {T} - [oldChild,newChild,$return] - * - * @param {*} oldChild - The child in this List that will be replaced. - * @param {*} newChild - The child to be inserted into this List. - * - * @return {*} Returns the oldChild that was replaced within this group. - */ - replace: function (oldChild, newChild) - { - return ArrayUtils.Replace(this.list, oldChild, newChild); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#exists - * @since 3.0.0 - * - * @genericUse {T} - [child] - * - * @param {*} child - [description] - * - * @return {boolean} True if the item is found in the list, otherwise false. - */ - exists: function (child) - { - return (this.list.indexOf(child) > -1); - }, - - /** - * Sets the property `key` to the given value on all members of this List. - * - * @method Phaser.Structs.List#setAll - * @since 3.0.0 - * - * @genericUse {T} - [value] - * - * @param {string} property - [description] - * @param {*} value - [description] - * @param {integer} [startIndex] - The first child index to start the search from. - * @param {integer} [endIndex] - The last child index to search up until. - */ - setAll: function (property, value, startIndex, endIndex) - { - ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); - - return this; - }, - - /** - * Passes all children to the given callback. - * - * @method Phaser.Structs.List#each - * @since 3.0.0 - * - * @genericUse {EachListCallback.} - [callback] - * - * @param {EachListCallback} callback - The function to call. - * @param {*} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ - each: function (callback, context) - { - var args = [ null ]; - - for (var i = 2; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = 0; i < this.list.length; i++) - { - args[0] = this.list[i]; - - callback.apply(context, args); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAll(); - - this.list = []; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAll(); - - this.parent = null; - this.addCallback = null; - this.removeCallback = null; - }, - - /** - * [description] - * - * @name Phaser.Structs.List#length - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - length: { - - get: function () - { - return this.list.length; - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#first - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - first: { - - get: function () - { - this.position = 0; - - if (this.list.length > 0) - { - return this.list[0]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#last - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - last: { - - get: function () - { - if (this.list.length > 0) - { - this.position = this.list.length - 1; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#next - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - next: { - - get: function () - { - if (this.position < this.list.length) - { - this.position++; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#previous - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - previous: { - - get: function () - { - if (this.position > 0) - { - this.position--; - - return this.list[this.position]; - } - else - { - return null; - } - } - - } - -}); - -module.exports = List; - - -/***/ }), -/* 94 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(33); - -/** - * Creates a new Object using all values from obj1 and obj2. - * If a value exists in both obj1 and obj2, the value in obj1 is used. - * - * @function Phaser.Utils.Object.Merge - * @since 3.0.0 - * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] - * - * @return {object} [description] - */ -var Merge = function (obj1, obj2) -{ - var clone = Clone(obj1); - - for (var key in obj2) - { - if (!clone.hasOwnProperty(key)) - { - clone[key] = obj2[key]; - } - } - - return clone; -}; - -module.exports = Merge; - - -/***/ }), -/* 95 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Shuffles the contents of the given array using the Fisher-Yates implementation. - * - * The original array is modified directly and returned. - * - * @function Phaser.Utils.Array.Shuffle - * @since 3.0.0 - * - * @param {array} array - The array to shuffle. This array is modified in place. - * - * @return {array} The shuffled array. - */ -var Shuffle = function (array) -{ - for (var i = array.length - 1; i > 0; i--) - { - var j = Math.floor(Math.random() * (i + 1)); - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - - return array; -}; - -module.exports = Shuffle; - - -/***/ }), -/* 96 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetPoint = __webpack_require__(293); -var GetPoints = __webpack_require__(156); -var Random = __webpack_require__(155); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * Defines a Line segment, a part of a line between two endpoints. - * - * @class Line - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x1=0] - The x coordinate of the lines starting point. - * @param {number} [y1=0] - The y coordinate of the lines starting point. - * @param {number} [x2=0] - The x coordinate of the lines ending point. - * @param {number} [y2=0] - The y coordinate of the lines ending point. - */ -var Line = new Class({ - - initialize: - - function Line (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - - /** - * The x coordinate of the lines starting point. - * - * @name Phaser.Geom.Line#x1 - * @type {number} - * @since 3.0.0 - */ - this.x1 = x1; - - /** - * The y coordinate of the lines starting point. - * - * @name Phaser.Geom.Line#y1 - * @type {number} - * @since 3.0.0 - */ - this.y1 = y1; - - /** - * The x coordinate of the lines ending point. - * - * @name Phaser.Geom.Line#x2 - * @type {number} - * @since 3.0.0 - */ - this.x2 = x2; - - /** - * The y coordinate of the lines ending point. - * - * @name Phaser.Geom.Line#y2 - * @type {number} - * @since 3.0.0 - */ - this.y2 = y2; - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] - * - * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point on the line. - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * Get a random Point on the Line. - * - * @method Phaser.Geom.Line#getRandomPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {(Phaser.Geom.Point|object)} [point] - An instance of a Point to be modified. - * - * @return {Phaser.Geom.Point} A random Point on the Line. - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * Set new coordinates for the line endpoints. - * - * @method Phaser.Geom.Line#setTo - * @since 3.0.0 - * - * @param {number} [x1=0] - The x coordinate of the lines starting point. - * @param {number} [y1=0] - The y coordinate of the lines starting point. - * @param {number} [x2=0] - The x coordinate of the lines ending point. - * @param {number} [y2=0] - The y coordinate of the lines ending point. - * - * @return {Phaser.Geom.Line} This Line object. - */ - setTo: function (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - - this.x1 = x1; - this.y1 = y1; - - this.x2 = x2; - this.y2 = y2; - - return this; - }, - - /** - * Returns a Vector2 object that corresponds to the start of this Line. - * - * @method Phaser.Geom.Line#getPointA - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [vec2,$return] - * - * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. - */ - getPointA: function (vec2) - { - if (vec2 === undefined) { vec2 = new Vector2(); } - - vec2.set(this.x1, this.y1); - - return vec2; - }, - - /** - * Returns a Vector2 object that corresponds to the start of this Line. - * - * @method Phaser.Geom.Line#getPointB - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [vec2,$return] - * - * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. - */ - getPointB: function (vec2) - { - if (vec2 === undefined) { vec2 = new Vector2(); } - - vec2.set(this.x2, this.y2); - - return vec2; - }, - - /** - * The left position of the Line. - * - * @name Phaser.Geom.Line#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return Math.min(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 <= this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The right position of the Line. - * - * @name Phaser.Geom.Line#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return Math.max(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 > this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The top position of the Line. - * - * @name Phaser.Geom.Line#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return Math.min(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 <= this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } - } - - }, - - /** - * The bottom position of the Line. - * - * @name Phaser.Geom.Line#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return Math.max(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 > this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } - } - - } - -}); - -module.exports = Line; - - -/***/ }), -/* 97 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Perimeter - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {number} [description] - */ -var Perimeter = function (rect) -{ - return 2 * (rect.width + rect.height); -}; - -module.exports = Perimeter; - - -/***/ }), -/* 98 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} TweenDataGenConfig - * - * @property {function} delay - [description] - * @property {function} duration - [description] - * @property {function} hold - [description] - * @property {function} repeat - [description] - * @property {function} repeatDelay - [description] - */ - -/** - * @typedef {object} Phaser.Tweens.TweenDataConfig - * - * @property {object} target - The target to tween. - * @property {string} key - The property of the target being tweened. - * @property {function} getEndValue - The returned value sets what the property will be at the END of the Tween. - * @property {function} getStartValue - The returned value sets what the property will be at the START of the Tween. - * @property {function} ease - The ease function this tween uses. - * @property {number} [duration=0] - Duration of the tween in ms/frames, excludes time for yoyo or repeats. - * @property {number} [totalDuration=0] - The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) - * @property {number} [delay=0] - Time in ms/frames before tween will start. - * @property {boolean} [yoyo=false] - Cause the tween to return back to its start value after hold has expired. - * @property {number} [hold=0] - Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - * @property {integer} [repeat=0] - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - * @property {number} [repeatDelay=0] - Time in ms/frames before the repeat will start. - * @property {boolean} [flipX=false] - Automatically call toggleFlipX when the TweenData yoyos or repeats - * @property {boolean} [flipY=false] - Automatically call toggleFlipY when the TweenData yoyos or repeats - * @property {float} [progress=0] - Between 0 and 1 showing completion of this TweenData. - * @property {float} [elapsed=0] - Delta counter - * @property {integer} [repeatCounter=0] - How many repeats are left to run? - * @property {number} [start=0] - Ease value data. - * @property {number} [current=0] - Ease value data. - * @property {number} [end=0] - Ease value data. - * @property {number} [t1=0] - Time duration 1. - * @property {number} [t2=0] - Time duration 2. - * @property {TweenDataGenConfig} [gen] - LoadValue generation functions. - * @property {integer} [state=0] - TWEEN_CONST.CREATED - */ - -/** - * [description] - * - * @function Phaser.Tweens.TweenData - * @since 3.0.0 - * - * @param {object} target - [description] - * @param {string} key - [description] - * @param {function} getEnd - [description] - * @param {function} getStart - [description] - * @param {function} ease - [description] - * @param {number} delay - [description] - * @param {number} duration - [description] - * @param {boolean} yoyo - [description] - * @param {number} hold - [description] - * @param {number} repeat - [description] - * @param {number} repeatDelay - [description] - * @param {boolean} flipX - [description] - * @param {boolean} flipY - [description] - * - * @return {TweenDataConfig} [description] - */ -var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) -{ - return { - - // The target to tween - target: target, - - // The property of the target to tween - key: key, - - // The returned value sets what the property will be at the END of the Tween. - getEndValue: getEnd, - - // The returned value sets what the property will be at the START of the Tween. - getStartValue: getStart, - - // The ease function this tween uses. - ease: ease, - - // Duration of the tween in ms/frames, excludes time for yoyo or repeats. - duration: 0, - - // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) - totalDuration: 0, - - // Time in ms/frames before tween will start. - delay: 0, - - // Cause the tween to return back to its start value after hold has expired. - yoyo: yoyo, - - // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - hold: 0, - - // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - repeat: 0, - - // Time in ms/frames before the repeat will start. - repeatDelay: 0, - - // Automatically call toggleFlipX when the TweenData yoyos or repeats - flipX: flipX, - - // Automatically call toggleFlipY when the TweenData yoyos or repeats - flipY: flipY, - - // Between 0 and 1 showing completion of this TweenData. - progress: 0, - - // Delta counter. - elapsed: 0, - - // How many repeats are left to run? - repeatCounter: 0, - - // Ease Value Data: - - start: 0, - current: 0, - end: 0, - - // Time Durations - t1: 0, - t2: 0, - - // LoadValue generation functions - gen: { - delay: delay, - duration: duration, - hold: hold, - repeat: repeat, - repeatDelay: repeatDelay - }, - - // TWEEN_CONST.CREATED - state: 0 - }; -}; - -module.exports = TweenData; - - -/***/ }), -/* 99 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GameObjectCreator = __webpack_require__(13); -var GameObjectFactory = __webpack_require__(11); -var TWEEN_CONST = __webpack_require__(61); - -/** - * @classdesc - * [description] - * - * @class Tween - * @memberOf Phaser.Tweens - * @constructor - * @since 3.0.0 - * - * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] - * @param {Phaser.Tweens.TweenDataConfig[]} data - [description] - * @param {array} targets - [description] - */ -var Tween = new Class({ - - initialize: - - function Tween (parent, data, targets) - { - /** - * [description] - * - * @name Phaser.Tweens.Tween#parent - * @type {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * Is the parent of this Tween a Timeline? - * - * @name Phaser.Tweens.Tween#parentIsTimeline - * @type {boolean} - * @since 3.0.0 - */ - this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); - - /** - * An array of TweenData objects, each containing a unique property and target being tweened. - * - * @name Phaser.Tweens.Tween#data - * @type {Phaser.Tweens.TweenDataConfig[]} - * @since 3.0.0 - */ - this.data = data; - - /** - * data array doesn't change, so we can cache the length - * - * @name Phaser.Tweens.Tween#totalData - * @type {integer} - * @since 3.0.0 - */ - this.totalData = data.length; - - /** - * An array of references to the target/s this Tween is operating on - * - * @name Phaser.Tweens.Tween#targets - * @type {object[]} - * @since 3.0.0 - */ - this.targets = targets; - - /** - * Cached target total (not necessarily the same as the data total) - * - * @name Phaser.Tweens.Tween#totalTargets - * @type {integer} - * @since 3.0.0 - */ - this.totalTargets = targets.length; - - /** - * If true then duration, delay, etc values are all frame totals. - * - * @name Phaser.Tweens.Tween#useFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useFrames = false; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * - * @name Phaser.Tweens.Tween#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) - * - * @name Phaser.Tweens.Tween#loop - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loop = 0; - - /** - * Time in ms/frames before the tween loops. - * - * @name Phaser.Tweens.Tween#loopDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopDelay = 0; - - /** - * How many loops are left to run? - * - * @name Phaser.Tweens.Tween#loopCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopCounter = 0; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) - * - * @name Phaser.Tweens.Tween#completeDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.completeDelay = 0; - - /** - * Countdown timer (used by timeline offset, loopDelay and completeDelay) - * - * @name Phaser.Tweens.Tween#countdown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.countdown = 0; - - /** - * Set only if this Tween is part of a Timeline. - * - * @name Phaser.Tweens.Tween#offset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.offset = 0; - - /** - * Set only if this Tween is part of a Timeline. The calculated offset amount. - * - * @name Phaser.Tweens.Tween#calculatedOffset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.calculatedOffset = 0; - - /** - * The current state of the tween - * - * @name Phaser.Tweens.Tween#state - * @type {integer} - * @since 3.0.0 - */ - this.state = TWEEN_CONST.PENDING_ADD; - - /** - * The state of the tween when it was paused (used by Resume) - * - * @name Phaser.Tweens.Tween#_pausedState - * @type {integer} - * @private - * @since 3.0.0 - */ - this._pausedState = TWEEN_CONST.PENDING_ADD; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - * - * @name Phaser.Tweens.Tween#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * Elapsed time in ms/frames of this run through the Tween. - * - * @name Phaser.Tweens.Tween#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalElapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalElapsed = 0; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - * - * @name Phaser.Tweens.Tween#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - * - * @name Phaser.Tweens.Tween#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * Time in ms/frames for the Tween to complete (including looping) - * - * @name Phaser.Tweens.Tween#totalDuration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalDuration = 0; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalProgress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalProgress = 0; - - /** - * An object containing the various Tween callback references. - * - * @name Phaser.Tweens.Tween#callbacks - * @type {object} - * @default 0 - * @since 3.0.0 - */ - this.callbacks = { - onComplete: null, - onLoop: null, - onRepeat: null, - onStart: null, - onUpdate: null, - onYoyo: null - }; - - this.callbackScope; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#getValue - * @since 3.0.0 - * - * @return {number} [description] - */ - getValue: function () - { - return this.data[0].current; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setTimeScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - setTimeScale: function (value) - { - this.timeScale = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#getTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#isPlaying - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPlaying: function () - { - return (this.state === TWEEN_CONST.ACTIVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#isPaused - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPaused: function () - { - return (this.state === TWEEN_CONST.PAUSED); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#hasTarget - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - hasTarget: function (target) - { - return (this.targets.indexOf(target) !== -1); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTo - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {*} value - [description] - * @param {boolean} startToCurrent - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - updateTo: function (key, value, startToCurrent) - { - for (var i = 0; i < this.totalData; i++) - { - var tweenData = this.data[i]; - - if (tweenData.key === key) - { - tweenData.end = value; - - if (startToCurrent) - { - tweenData.start = tweenData.current; - } - - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#restart - * @since 3.0.0 - */ - restart: function () - { - if (this.state === TWEEN_CONST.REMOVED) - { - this.seek(0); - this.parent.makeActive(this); - } - else - { - this.stop(); - this.play(); - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#calcDuration - * @since 3.0.0 - */ - calcDuration: function () - { - var max = 0; - - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - // Set t1 (duration + hold + yoyo) - tweenData.t1 = tweenData.duration + tweenData.hold; - - if (tweenData.yoyo) - { - tweenData.t1 += tweenData.duration; - } - - // Set t2 (repeatDelay + duration + hold + yoyo) - tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; - - // Total Duration - tweenData.totalDuration = tweenData.delay + tweenData.t1; - - if (tweenData.repeat === -1) - { - tweenData.totalDuration += (tweenData.t2 * 999999999999); - } - else if (tweenData.repeat > 0) - { - tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); - } - - if (tweenData.totalDuration > max) - { - // Get the longest TweenData from the Tween, used to calculate the Tween TD - max = tweenData.totalDuration; - } - } - - // Excludes loop values - this.duration = max; - - this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; - - if (this.loopCounter > 0) - { - this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); - } - else - { - this.totalDuration = this.duration + this.completeDelay; - } - }, - - /** - * Called by TweenManager.preUpdate as part of its loop to check pending and active tweens. - * Should not be called directly. - * - * @method Phaser.Tweens.Tween#init - * @since 3.0.0 - * - * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. - */ - init: function () - { - var data = this.data; - var totalTargets = this.totalTargets; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - var target = tweenData.target; - var gen = tweenData.gen; - - tweenData.delay = gen.delay(i, totalTargets, target); - tweenData.duration = gen.duration(i, totalTargets, target); - tweenData.hold = gen.hold(i, totalTargets, target); - tweenData.repeat = gen.repeat(i, totalTargets, target); - tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); - } - - this.calcDuration(); - - this.progress = 0; - this.totalProgress = 0; - this.elapsed = 0; - this.totalElapsed = 0; - - // You can't have a paused Tween if it's part of a Timeline - if (this.paused && !this.parentIsTimeline) - { - this.state = TWEEN_CONST.PENDING_ADD; - this._pausedState = TWEEN_CONST.INIT; - - return false; - } - else - { - this.state = TWEEN_CONST.INIT; - - return true; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#nextState - * @since 3.0.0 - */ - nextState: function () - { - if (this.loopCounter > 0) - { - this.elapsed = 0; - this.progress = 0; - this.loopCounter--; - - var onLoop = this.callbacks.onLoop; - - if (onLoop) - { - onLoop.params[1] = this.targets; - - onLoop.func.apply(onLoop.scope, onLoop.params); - } - - this.resetTweenData(true); - - if (this.loopDelay > 0) - { - this.countdown = this.loopDelay; - this.state = TWEEN_CONST.LOOP_DELAY; - } - else - { - this.state = TWEEN_CONST.ACTIVE; - } - } - else if (this.completeDelay > 0) - { - this.countdown = this.completeDelay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#pause - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - pause: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - this.paused = true; - - this._pausedState = this.state; - - this.state = TWEEN_CONST.PAUSED; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#play - * @since 3.0.0 - * - * @param {boolean} resetFromTimeline - [description] - */ - play: function (resetFromTimeline) - { - if (this.state === TWEEN_CONST.ACTIVE) - { - return; - } - else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) - { - this.init(); - this.parent.makeActive(this); - resetFromTimeline = true; - } - - var onStart = this.callbacks.onStart; - - if (this.parentIsTimeline) - { - this.resetTweenData(resetFromTimeline); - - if (this.calculatedOffset === 0) - { - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - else - { - this.countdown = this.calculatedOffset; - - this.state = TWEEN_CONST.OFFSET_DELAY; - } - } - else if (this.paused) - { - this.paused = false; - - this.parent.makeActive(this); - } - else - { - this.resetTweenData(resetFromTimeline); - - this.state = TWEEN_CONST.ACTIVE; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resetTweenData - * @since 3.0.0 - * - * @param {boolean} resetFromLoop - [description] - */ - resetTweenData: function (resetFromLoop) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - tweenData.progress = 0; - tweenData.elapsed = 0; - - tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; - - if (resetFromLoop) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); - - tweenData.current = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else if (tweenData.delay > 0) - { - tweenData.elapsed = tweenData.delay; - tweenData.state = TWEEN_CONST.DELAY; - } - else - { - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resume - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - resume: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - this.paused = false; - - this.state = this._pausedState; - } - else - { - this.play(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#seek - * @since 3.0.0 - * - * @param {float} toPosition - A value between 0 and 1. - */ - seek: function (toPosition) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - // This won't work with loop > 0 yet - var ms = this.totalDuration * toPosition; - - var tweenData = data[i]; - var progress = 0; - var elapsed = 0; - - if (ms <= tweenData.delay) - { - progress = 0; - elapsed = 0; - } - else if (ms >= tweenData.totalDuration) - { - progress = 1; - elapsed = tweenData.duration; - } - else if (ms > tweenData.delay && ms <= tweenData.t1) - { - // Keep it zero bound - ms = Math.max(0, ms - tweenData.delay); - - // Somewhere in the first playthru range - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - else if (ms > tweenData.t1 && ms < tweenData.totalDuration) - { - // Somewhere in repeat land - ms -= tweenData.delay; - ms -= tweenData.t1; - - // var repeats = Math.floor(ms / tweenData.t2); - - // remainder - ms = ((ms / tweenData.t2) % 1) * tweenData.t2; - - if (ms > tweenData.repeatDelay) - { - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - } - - tweenData.progress = progress; - tweenData.elapsed = elapsed; - - var v = tweenData.ease(tweenData.progress); - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); - - // if (tweenData.current === 0) - // { - // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); - // } - - tweenData.target[tweenData.key] = tweenData.current; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setCallback - * @since 3.0.0 - * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] - * @param {object} [scope] - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - setCallback: function (type, callback, params, scope) - { - this.callbacks[type] = { func: callback, scope: scope, params: params }; - - return this; - }, - - /** - * Flags the Tween as being complete, whatever stage of progress it is at. - * - * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` - * argument is provided, in which case the Tween will delay for that period of time before calling the callback. - * - * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. - * - * @method Phaser.Tweens.Tween#complete - * @since 3.2.0 - * - * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. - */ - complete: function (delay) - { - if (delay === undefined) { delay = 0; } - - if (delay) - { - this.countdown = delay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - * - * @method Phaser.Tweens.Tween#stop - * @since 3.0.0 - * - * @param {float} [resetTo] - A value between 0 and 1. - */ - stop: function (resetTo) - { - if (this.state === TWEEN_CONST.ACTIVE) - { - if (resetTo !== undefined) - { - this.seek(resetTo); - } - } - - if (this.state !== TWEEN_CONST.REMOVED) - { - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - * - * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. - */ - update: function (timestamp, delta) - { - if (this.state === TWEEN_CONST.PAUSED) - { - return false; - } - - if (this.useFrames) - { - delta = 1 * this.parent.timeScale; - } - - delta *= this.timeScale; - - this.elapsed += delta; - this.progress = Math.min(this.elapsed / this.duration, 1); - - this.totalElapsed += delta; - this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); - - switch (this.state) - { - case TWEEN_CONST.ACTIVE: - - var stillRunning = false; - - for (var i = 0; i < this.totalData; i++) - { - if (this.updateTweenData(this, this.data[i], delta)) - { - stillRunning = true; - } - } - - // Anything still running? If not, we're done - if (!stillRunning) - { - this.nextState(); - } - - break; - - case TWEEN_CONST.LOOP_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.OFFSET_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onStart = this.callbacks.onStart; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.COMPLETE_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - - break; - } - - return (this.state === TWEEN_CONST.PENDING_REMOVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setStateFromEnd - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromEnd: function (tween, tweenData, diff) - { - if (tweenData.yoyo) - { - // We've hit the end of a Playing Forward TweenData and we have a yoyo - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. - // If you're tweening several properties it can fire for all of them, at once. - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onYoyo = tween.callbacks.onYoyo; - - if (onYoyo) - { - // Element 1 is reserved for the target of the yoyo (and needs setting here) - onYoyo.params[1] = tweenData.target; - - onYoyo.func.apply(onYoyo.scope, onYoyo.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - return TWEEN_CONST.PLAYING_BACKWARD; - } - else if (tweenData.repeatCounter > 0) - { - // We've hit the end of a Playing Forward TweenData and we have a Repeat. - // So we're going to go right back to the start to repeat it again. - - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - /** - * Was PLAYING_BACKWARD and has hit the start. - * - * @method Phaser.Tweens.Tween#setStateFromStart - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromStart: function (tween, tweenData, diff) - { - if (tweenData.repeatCounter > 0) - { - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - // - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTweenData - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] - * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true - * - * @return {boolean} [description] - */ - updateTweenData: function (tween, tweenData, delta) - { - switch (tweenData.state) - { - case TWEEN_CONST.PLAYING_FORWARD: - case TWEEN_CONST.PLAYING_BACKWARD: - - if (!tweenData.target) - { - tweenData.state = TWEEN_CONST.COMPLETE; - break; - } - - var elapsed = tweenData.elapsed; - var duration = tweenData.duration; - var diff = 0; - - elapsed += delta; - - if (elapsed > duration) - { - diff = elapsed - duration; - elapsed = duration; - } - - var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); - var progress = elapsed / duration; - - var v; - - if (forward) - { - v = tweenData.ease(progress); - } - else - { - v = tweenData.ease(1 - progress); - } - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - tweenData.target[tweenData.key] = tweenData.current; - - tweenData.elapsed = elapsed; - tweenData.progress = progress; - - var onUpdate = tween.callbacks.onUpdate; - - if (onUpdate) - { - onUpdate.params[1] = tweenData.target; - - onUpdate.func.apply(onUpdate.scope, onUpdate.params); - } - - if (progress === 1) - { - if (forward) - { - if (tweenData.hold > 0) - { - tweenData.elapsed = tweenData.hold - diff; - - tweenData.state = TWEEN_CONST.HOLD_DELAY; - } - else - { - tweenData.state = this.setStateFromEnd(tween, tweenData, diff); - } - } - else - { - tweenData.state = this.setStateFromStart(tween, tweenData, diff); - } - } - - break; - - case TWEEN_CONST.DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - - break; - - case TWEEN_CONST.REPEAT_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - - break; - - case TWEEN_CONST.HOLD_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); - } - - break; - - case TWEEN_CONST.PENDING_RENDER: - - if (tweenData.target) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else - { - tweenData.state = TWEEN_CONST.COMPLETE; - } - - break; - } - - // Return TRUE if this TweenData still playing, otherwise return FALSE - return (tweenData.state !== TWEEN_CONST.COMPLETE); - } - -}); - -Tween.TYPES = [ - 'onComplete', - 'onLoop', - 'onRepeat', - 'onStart', - 'onUpdate', - 'onYoyo' -]; - -/** - * Creates a new Tween object. - * - * Note: This method will only be available Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectFactory.register('tween', function (config) -{ - return this.scene.sys.tweens.add(config); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - -/** - * Creates a new Tween object and returns it. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectCreator.register('tween', function (config) -{ - return this.scene.sys.tweens.create(config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - -module.exports = Tween; - - -/***/ }), -/* 100 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} Phaser.Tweens.TweenConfigDefaults - * - * @property {(object|object[])} targets - [description] - * @property {number} [delay=0] - [description] - * @property {number} [duration=1000] - [description] - * @property {string} [ease='Power0'] - [description] - * @property {array} [easeParams] - [description] - * @property {number} [hold=0] - [description] - * @property {number} [repeat=0] - [description] - * @property {number} [repeatDelay=0] - [description] - * @property {boolean} [yoyo=false] - [description] - * @property {boolean} [flipX=false] - [description] - * @property {boolean} [flipY=false] - [description] - */ - -var TWEEN_DEFAULTS = { - targets: null, - delay: 0, - duration: 1000, - ease: 'Power0', - easeParams: null, - hold: 0, - repeat: 0, - repeatDelay: 0, - yoyo: false, - flipX: false, - flipY: false -}; - -module.exports = TWEEN_DEFAULTS; - - -/***/ }), -/* 101 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function hasGetStart (def) -{ - return (!!def.getStart && typeof def.getStart === 'function'); -} - -function hasGetEnd (def) -{ - return (!!def.getEnd && typeof def.getEnd === 'function'); -} - -function hasGetters (def) -{ - return hasGetStart(def) || hasGetEnd(def); -} - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetValueOp - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {*} propertyValue - [description] - * - * @return {function} [description] - */ -var GetValueOp = function (key, propertyValue) -{ - var callbacks; - - // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) - var getEnd = function (target, key, value) { return value; }; - - // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) - var getStart = function (target, key, value) { return value; }; - - var t = typeof(propertyValue); - - if (t === 'number') - { - // props: { - // x: 400, - // y: 300 - // } - - getEnd = function () - { - return propertyValue; - }; - } - else if (t === 'string') - { - // props: { - // x: '+=400', - // y: '-=300', - // z: '*=2', - // w: '/=2' - // } - - var op = propertyValue[0]; - var num = parseFloat(propertyValue.substr(2)); - - switch (op) - { - case '+': - getEnd = function (target, key, value) - { - return value + num; - }; - break; - - case '-': - getEnd = function (target, key, value) - { - return value - num; - }; - break; - - case '*': - getEnd = function (target, key, value) - { - return value * num; - }; - break; - - case '/': - getEnd = function (target, key, value) - { - return value / num; - }; - break; - - default: - getEnd = function () - { - return parseFloat(propertyValue); - }; - } - } - else if (t === 'function') - { - // The same as setting just the getEnd function and no getStart - - // props: { - // x: function (target, key, value) { return value + 50); }, - // } - - getEnd = propertyValue; - } - else if (t === 'object' && hasGetters(propertyValue)) - { - /* - x: { - // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. - getEnd: function (target, key, value) - { - return value; - }, - - // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. - getStart: function (target, key, value) - { - return value; - } - } - */ - - if (hasGetEnd(propertyValue)) - { - getEnd = propertyValue.getEnd; - } - - if (hasGetStart(propertyValue)) - { - getStart = propertyValue.getStart; - } - } - else if (propertyValue.hasOwnProperty('value')) - { - // Value may still be a string, function or a number - // props: { - // x: { value: 400, ... }, - // y: { value: 300, ... } - // } - - callbacks = GetValueOp(key, propertyValue.value); - } - - // If callback not set by the else if block above then set it here and return it - if (!callbacks) - { - callbacks = { - getEnd: getEnd, - getStart: getStart - }; - } - - return callbacks; -}; - -module.exports = GetValueOp; - - -/***/ }), -/* 102 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetTargets - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {array} [description] - */ -var GetTargets = function (config) -{ - var targets = GetValue(config, 'targets', null); - - if (targets === null) - { - return targets; - } - - if (typeof targets === 'function') - { - targets = targets.call(); - } - - if (!Array.isArray(targets)) - { - targets = [ targets ]; - } - - return targets; -}; - -module.exports = GetTargets; - - -/***/ }), -/* 103 */, -/* 104 */, -/* 105 */, -/* 106 */, -/* 107 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Extend = __webpack_require__(17); -var XHRSettings = __webpack_require__(75); - -/** - * Takes two XHRSettings Objects and creates a new XHRSettings object from them. - * - * The new object is seeded by the values given in the global settings, but any setting in - * the local object overrides the global ones. - * - * @function Phaser.Loader.MergeXHRSettings - * @since 3.0.0 - * - * @param {XHRSettingsObject} global - The global XHRSettings object. - * @param {XHRSettingsObject} local - The local XHRSettings object. - * - * @return {XHRSettingsObject} A newly formed XHRSettings object. - */ -var MergeXHRSettings = function (global, local) -{ - var output = (global === undefined) ? XHRSettings() : Extend({}, global); - - if (local) - { - for (var setting in local) - { - if (local[setting] !== undefined) - { - output[setting] = local[setting]; - } - } - } - - return output; -}; - -module.exports = MergeXHRSettings; - - -/***/ }), -/* 108 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Given a File and a baseURL value this returns the URL the File will use to download from. - * - * @function Phaser.Loader.GetURL - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - The File object. - * @param {string} baseURL - A default base URL. - * - * @return {string} The URL the File will use. - */ -var GetURL = function (file, baseURL) -{ - if (!file.url) - { - return false; - } - - if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) - { - return file.url; - } - else - { - return baseURL + file.url; - } -}; - -module.exports = GetURL; - - -/***/ }), -/* 109 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Keyboard Codes. - * - * @name Phaser.Input.Keyboard.KeyCodes - * @enum {integer} - * @memberOf Phaser.Input.Keyboard - * @readOnly - * @since 3.0.0 - */ - -var KeyCodes = { - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACKSPACE - */ - BACKSPACE: 8, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.TAB - */ - TAB: 9, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ENTER - */ - ENTER: 13, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SHIFT - */ - SHIFT: 16, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CTRL - */ - CTRL: 17, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ALT - */ - ALT: 18, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAUSE - */ - PAUSE: 19, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CAPS_LOCK - */ - CAPS_LOCK: 20, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ESC - */ - ESC: 27, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SPACE - */ - SPACE: 32, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAGE_UP - */ - PAGE_UP: 33, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAGE_DOWN - */ - PAGE_DOWN: 34, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.END - */ - END: 35, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.HOME - */ - HOME: 36, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.LEFT - */ - LEFT: 37, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.UP - */ - UP: 38, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.RIGHT - */ - RIGHT: 39, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.DOWN - */ - DOWN: 40, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PRINT_SCREEN - */ - PRINT_SCREEN: 42, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.INSERT - */ - INSERT: 45, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.DELETE - */ - DELETE: 46, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ZERO - */ - ZERO: 48, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ONE - */ - ONE: 49, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.TWO - */ - TWO: 50, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.THREE - */ - THREE: 51, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FOUR - */ - FOUR: 52, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FIVE - */ - FIVE: 53, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SIX - */ - SIX: 54, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SEVEN - */ - SEVEN: 55, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.EIGHT - */ - EIGHT: 56, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NINE - */ - NINE: 57, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ZERO - */ - NUMPAD_ZERO: 96, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ONE - */ - NUMPAD_ONE: 97, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_TWO - */ - NUMPAD_TWO: 98, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_THREE - */ - NUMPAD_THREE: 99, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FOUR - */ - NUMPAD_FOUR: 100, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FIVE - */ - NUMPAD_FIVE: 101, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SIX - */ - NUMPAD_SIX: 102, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SEVEN - */ - NUMPAD_SEVEN: 103, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_EIGHT - */ - NUMPAD_EIGHT: 104, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_NINE - */ - NUMPAD_NINE: 105, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.A - */ - A: 65, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.B - */ - B: 66, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.C - */ - C: 67, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.D - */ - D: 68, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.E - */ - E: 69, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F - */ - F: 70, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.G - */ - G: 71, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.H - */ - H: 72, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.I - */ - I: 73, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.J - */ - J: 74, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.K - */ - K: 75, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.L - */ - L: 76, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.M - */ - M: 77, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.N - */ - N: 78, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.O - */ - O: 79, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.P - */ - P: 80, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Q - */ - Q: 81, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.R - */ - R: 82, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.S - */ - S: 83, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.T - */ - T: 84, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.U - */ - U: 85, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.V - */ - V: 86, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.W - */ - W: 87, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.X - */ - X: 88, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Y - */ - Y: 89, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Z - */ - Z: 90, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F1 - */ - F1: 112, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F2 - */ - F2: 113, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F3 - */ - F3: 114, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F4 - */ - F4: 115, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F5 - */ - F5: 116, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F6 - */ - F6: 117, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F7 - */ - F7: 118, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F8 - */ - F8: 119, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F9 - */ - F9: 120, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F10 - */ - F10: 121, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F11 - */ - F11: 122, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F12 - */ - F12: 123, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON - */ - SEMICOLON: 186, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PLUS - */ - PLUS: 187, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.COMMA - */ - COMMA: 188, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.MINUS - */ - MINUS: 189, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PERIOD - */ - PERIOD: 190, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FORWARD_SLASH - */ - FORWARD_SLASH: 191, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACK_SLASH - */ - BACK_SLASH: 220, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.QUOTES - */ - QUOTES: 222, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACKTICK - */ - BACKTICK: 192, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.OPEN_BRACKET - */ - OPEN_BRACKET: 219, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET - */ - CLOSED_BRACKET: 221 - -}; - -module.exports = KeyCodes; - - -/***/ }), -/* 110 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AddToDOM = __webpack_require__(130); -var CanvasPool = __webpack_require__(22); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var CONST = __webpack_require__(20); -var GameObject = __webpack_require__(2); -var GetTextSize = __webpack_require__(417); -var GetValue = __webpack_require__(4); -var RemoveFromDOM = __webpack_require__(269); -var TextRender = __webpack_require__(416); -var TextStyle = __webpack_require__(413); - -/** - * @classdesc - * [description] - * - * @class Text - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {(string|string[])} text - The text this Text object will display. - * @param {object} style - The text style configuration object. - */ -var Text = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Tint, - Components.Transform, - Components.Visible, - TextRender - ], - - initialize: - - function Text (scene, x, y, text, style) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - GameObject.call(this, scene, 'Text'); - - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * The canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = CanvasPool.create(this); - - /** - * The context of the canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context = this.canvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#style - * @type {Phaser.GameObjects.Text.TextStyle} - * @since 3.0.0 - */ - this.style = new TextStyle(this, style); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#autoRound - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.autoRound = true; - - /** - * The Regular Expression that is used to split the text up into lines, in - * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. - * You can change this RegExp to be anything else that you may need. - * - * @name Phaser.GameObjects.Text#splitRegExp - * @type {object} - * @since 3.0.0 - */ - this.splitRegExp = /(?:\r\n|\r|\n)/; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#resolution - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.resolution = 1; - - /** - * Specify a padding value which is added to the line width and height when calculating the Text size. - * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. - * - * @name Phaser.GameObjects.Text#padding - * @type {{left:number,right:number,top:number,bottom:number}} - * @since 3.0.0 - */ - this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#width - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.width = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#height - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.height = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#canvasTexture - * @type {HTMLCanvasElement} - * @default null - * @since 3.0.0 - */ - this.canvasTexture = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#dirty - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.dirty = false; - - this.initRTL(); - - if (style && style.padding) - { - this.setPadding(style.padding); - } - - if (style && style.lineSpacing) - { - this._lineSpacing = style.lineSpacing; - } - - this.setText(text); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function () - { - this.canvasTexture = null; - this.dirty = true; - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#initRTL - * @since 3.0.0 - */ - initRTL: function () - { - if (!this.style.rtl) - { - return; - } - - // Here is where the crazy starts. - // - // Due to browser implementation issues, you cannot fillText BiDi text to a canvas - // that is not part of the DOM. It just completely ignores the direction property. - - this.canvas.dir = 'rtl'; - - // Experimental atm, but one day ... - this.context.direction = 'rtl'; - - // Add it to the DOM, but hidden within the parent canvas. - this.canvas.style.display = 'none'; - - AddToDOM(this.canvas, this.scene.sys.canvas); - - // And finally we set the x origin - this.originX = 1; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. - * - * @method Phaser.GameObjects.Text#runWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * - * @return {string} The text after wrapping has been applied. - */ - runWordWrap: function (text) - { - var style = this.style; - - if (style.wordWrapCallback) - { - var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); - - if (Array.isArray(wrappedLines)) - { - wrappedLines = wrappedLines.join('\n'); - } - - return wrappedLines; - } - else if (style.wordWrapWidth) - { - if (style.wordWrapUseAdvanced) - { - return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); - } - else - { - return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); - } - } - else - { - return text; - } - }, - - /** - * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be - * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a - * single character. - * - * @method Phaser.GameObjects.Text#advancedWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - advancedWordWrap: function (text, context, wordWrapWidth) - { - var output = ''; - - // Condense consecutive spaces and split into lines - var lines = text - .replace(/ +/gi, ' ') - .split(this.splitRegExp); - - var linesCount = lines.length; - - for (var i = 0; i < linesCount; i++) - { - var line = lines[i]; - var out = ''; - - // Trim whitespace - line = line.replace(/^ *|\s*$/gi, ''); - - // If entire line is less than wordWrapWidth append the entire line and exit early - var lineWidth = context.measureText(line).width; - - if (lineWidth < wordWrapWidth) - { - output += line + '\n'; - continue; - } - - // Otherwise, calculate new lines - var currentLineWidth = wordWrapWidth; - - // Split into words - var words = line.split(' '); - - for (var j = 0; j < words.length; j++) - { - var word = words[j]; - var wordWithSpace = word + ' '; - var wordWidth = context.measureText(wordWithSpace).width; - - if (wordWidth > currentLineWidth) - { - // Break word - if (j === 0) - { - // Shave off letters from word until it's small enough - var newWord = wordWithSpace; - - while (newWord.length) - { - newWord = newWord.slice(0, -1); - wordWidth = context.measureText(newWord).width; - - if (wordWidth <= currentLineWidth) - { - break; - } - } - - // If wordWrapWidth is too small for even a single letter, shame user - // failure with a fatal error - if (!newWord.length) - { - throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); - } - - // Replace current word in array with remainder - var secondPart = word.substr(newWord.length); - - words[j] = secondPart; - - // Append first piece to output - out += newWord; - } - - // If existing word length is 0, don't include it - var offset = (words[j].length) ? j : j + 1; - - // Collapse rest of sentence and remove any trailing white space - var remainder = words.slice(offset).join(' ') - .replace(/[ \n]*$/gi, ''); - - // Prepend remainder to next line - lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); - linesCount = lines.length; - - break; // Processing on this line - - // Append word with space to output - } - else - { - out += wordWithSpace; - currentLineWidth -= wordWidth; - } - } - - // Append processed line to output - output += out.replace(/[ \n]*$/gi, '') + '\n'; - } - - // Trim the end of the string - output = output.replace(/[\s|\n]*$/gi, ''); - - return output; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Spaces are not collapsed and whitespace is not trimmed. - * - * @method Phaser.GameObjects.Text#basicWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - basicWordWrap: function (text, context, wordWrapWidth) - { - var result = ''; - var lines = text.split(this.splitRegExp); - - for (var i = 0; i < lines.length; i++) - { - var spaceLeft = wordWrapWidth; - var words = lines[i].split(' '); - - for (var j = 0; j < words.length; j++) - { - var wordWidth = context.measureText(words[j]).width; - var wordWidthWithSpace = wordWidth + context.measureText(' ').width; - - if (wordWidthWithSpace > spaceLeft) - { - // Skip printing the newline if it's the first word of the line that is greater - // than the word wrap width. - if (j > 0) - { - result += '\n'; - } - - result += words[j] + ' '; - spaceLeft = wordWrapWidth - wordWidth; - } - else - { - spaceLeft -= wordWidthWithSpace; - result += words[j]; - - if (j < (words.length - 1)) - { - result += ' '; - } - } - } - - if (i < lines.length - 1) - { - result += '\n'; - } - } - - return result; - }, - - /** - * Runs the given text through this Text objects word wrapping and returns the results as an - * array, where each element of the array corresponds to a wrapped line of text. - * - * @method Phaser.GameObjects.Text#getWrappedText - * @since 3.0.0 - * - * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. - * - * @return {string[]} An array of strings with the pieces of wrapped text. - */ - getWrappedText: function (text) - { - if (text === undefined) { text = this.text; } - - this.style.syncFont(this.canvas, this.context); - - var wrappedLines = this.runWordWrap(text); - - return wrappedLines.split(this.splitRegExp); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setText - * @since 3.0.0 - * - * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this Text object. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateText(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStyle - * @since 3.0.0 - * - * @param {object} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStyle: function (style) - { - return this.style.setStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFont - * @since 3.0.0 - * - * @param {string} font - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFont: function (font) - { - return this.style.setFont(font); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontFamily - * @since 3.0.0 - * - * @param {string} family - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontFamily: function (family) - { - return this.style.setFontFamily(family); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontSize - * @since 3.0.0 - * - * @param {number} size - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontSize: function (size) - { - return this.style.setFontSize(size); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontStyle - * @since 3.0.0 - * - * @param {string} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontStyle: function (style) - { - return this.style.setFontStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFixedSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFixedSize: function (width, height) - { - return this.style.setFixedSize(width, height); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setBackgroundColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setBackgroundColor: function (color) - { - return this.style.setBackgroundColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFill - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFill: function (color) - { - return this.style.setFill(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setColor: function (color) - { - return this.style.setColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStroke - * @since 3.0.0 - * - * @param {string} color - [description] - * @param {number} thickness - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStroke: function (color, thickness) - { - return this.style.setStroke(color, thickness); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadow - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {string} color - [description] - * @param {number} blur - [description] - * @param {boolean} shadowStroke - [description] - * @param {boolean} shadowFill - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadow: function (x, y, color, blur, shadowStroke, shadowFill) - { - return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowOffset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowOffset: function (x, y) - { - return this.style.setShadowOffset(x, y); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowColor: function (color) - { - return this.style.setShadowColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowBlur - * @since 3.0.0 - * - * @param {number} blur - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowBlur: function (blur) - { - return this.style.setShadowBlur(blur); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowStroke - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowStroke: function (enabled) - { - return this.style.setShadowStroke(enabled); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowFill - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowFill: function (enabled) - { - return this.style.setShadowFill(enabled); - }, - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * - * @method Phaser.GameObjects.Text#setWordWrapWidth - * @since 3.0.0 - * - * @param {?number} width - The maximum width of a line in pixels. Set to null to remove wrapping. - * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapWidth: function (width, useAdvancedWrap) - { - return this.style.setWordWrapWidth(width, useAdvancedWrap); - }, - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * - * @method Phaser.GameObjects.Text#setWordWrapCallback - * @since 3.0.0 - * - * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapCallback: function (callback, scope) - { - return this.style.setWordWrapCallback(callback, scope); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setAlign - * @since 3.0.0 - * - * @param {string} align - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setAlign: function (align) - { - return this.style.setAlign(align); - }, - - /** - * 'left' can be an object. - * If only 'left' and 'top' are given they are treated as 'x' and 'y' - * - * @method Phaser.GameObjects.Text#setPadding - * @since 3.0.0 - * - * @param {(number|object)} left - [description] - * @param {number} top - [description] - * @param {number} right - [description] - * @param {number} bottom - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setPadding: function (left, top, right, bottom) - { - if (typeof left === 'object') - { - var config = left; - - // If they specify x and/or y this applies to all - var x = GetValue(config, 'x', null); - - if (x !== null) - { - left = x; - right = x; - } - else - { - left = GetValue(config, 'left', 0); - right = GetValue(config, 'right', left); - } - - var y = GetValue(config, 'y', null); - - if (y !== null) - { - top = y; - bottom = y; - } - else - { - top = GetValue(config, 'top', 0); - bottom = GetValue(config, 'bottom', top); - } - } - else - { - if (left === undefined) { left = 0; } - if (top === undefined) { top = left; } - if (right === undefined) { right = left; } - if (bottom === undefined) { bottom = top; } - } - - this.padding.left = left; - this.padding.top = top; - this.padding.right = right; - this.padding.bottom = bottom; - - return this.updateText(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setMaxLines - * @since 3.0.0 - * - * @param {integer} [max=0] - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setMaxLines: function (max) - { - return this.style.setMaxLines(max); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#updateText - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - updateText: function () - { - var canvas = this.canvas; - var context = this.context; - var style = this.style; - var resolution = this.resolution; - var size = style.metrics; - - style.syncFont(canvas, context); - - var outputText = this.text; - - if (style.wordWrapWidth || style.wordWrapCallback) - { - outputText = this.runWordWrap(this.text); - } - - // Split text into lines - var lines = outputText.split(this.splitRegExp); - - var textSize = GetTextSize(this, size, lines); - - var padding = this.padding; - - var w = textSize.width + padding.left + padding.right; - var h = textSize.height + padding.top + padding.bottom; - - if (style.fixedWidth === 0) - { - this.width = w; - } - - if (style.fixedHeight === 0) - { - this.height = h; - } - - this.updateDisplayOrigin(); - - w *= resolution; - h *= resolution; - - w = Math.max(w, 1); - h = Math.max(h, 1); - - if (canvas.width !== w || canvas.height !== h) - { - canvas.width = w; - canvas.height = h; - style.syncFont(canvas, context); // Resizing resets the context - } - else - { - context.clearRect(0, 0, w, h); - } - - context.save(); - - // context.scale(resolution, resolution); - - if (style.backgroundColor) - { - context.fillStyle = style.backgroundColor; - context.fillRect(0, 0, w, h); - } - - style.syncStyle(canvas, context); - - context.textBaseline = 'alphabetic'; - - // Apply padding - context.translate(padding.left, padding.top); - - var linePositionX; - var linePositionY; - - // Draw text line by line - for (var i = 0; i < textSize.lines; i++) - { - linePositionX = style.strokeThickness / 2; - linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; - - if (i > 0) - { - linePositionY += (textSize.lineSpacing * i); - } - - if (style.rtl) - { - linePositionX = w - linePositionX; - } - else if (style.align === 'right') - { - linePositionX += textSize.width - textSize.lineWidths[i]; - } - else if (style.align === 'center') - { - linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; - } - - if (this.autoRound) - { - linePositionX = Math.round(linePositionX); - linePositionY = Math.round(linePositionY); - } - - if (style.strokeThickness) - { - this.style.syncShadow(context, style.shadowStroke); - - context.strokeText(lines[i], linePositionX, linePositionY); - } - - if (style.color) - { - this.style.syncShadow(context, style.shadowFill); - - context.fillText(lines[i], linePositionX, linePositionY); - } - } - - context.restore(); - - this.dirty = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#getTextMetrics - * @since 3.0.0 - * - * @return {object} [description] - */ - getTextMetrics: function () - { - return this.style.getTextMetrics(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#toJSON - * @since 3.0.0 - * - * @return {JSONGameObject} A JSON representation of the Game Object. - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra Text data is added here - - var data = { - autoRound: this.autoRound, - text: this.text, - style: this.style.toJSON(), - resolution: this.resolution, - padding: { - left: this.padding.left, - right: this.padding.right, - top: this.padding.top, - bottom: this.padding.bottom - } - }; - - out.data = data; - - return out; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.Text#preDestroy - * @protected - * @since 3.0.0 - */ - preDestroy: function () - { - if (this.style.rtl) - { - RemoveFromDOM(this.canvas); - } - - CanvasPool.remove(this.canvas); - } - -}); - -module.exports = Text; - - -/***/ }), -/* 111 */, -/* 112 */, -/* 113 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. - * - * @function Phaser.Geom.Ellipse.CircumferencePoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. - * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. - */ -var CircumferencePoint = function (ellipse, angle, out) -{ - if (out === undefined) { out = new Point(); } - - var halfWidth = ellipse.width / 2; - var halfHeight = ellipse.height / 2; - - out.x = ellipse.x + halfWidth * Math.cos(angle); - out.y = ellipse.y + halfHeight * Math.sin(angle); - - return out; -}; - -module.exports = CircumferencePoint; - - -/***/ }), -/* 114 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(54); -var GetPoint = __webpack_require__(179); -var GetPoints = __webpack_require__(178); -var Random = __webpack_require__(134); - -/** - * @classdesc - * An Ellipse object. - * - * This is a geometry object, containing numerical values and related methods to inspect and modify them. - * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. - * To render an Ellipse you should look at the capabilities of the Graphics class. - * - * @class Ellipse - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of the center of the ellipse. - * @param {number} [y=0] - The y position of the center of the ellipse. - * @param {number} [width=0] - The width of the ellipse. - * @param {number} [height=0] - The height of the ellipse. - */ -var Ellipse = new Class({ - - initialize: - - function Ellipse (x, y, width, height) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = 0; } - if (height === undefined) { height = 0; } - - /** - * The x position of the center of the ellipse. - * - * @name Phaser.Geom.Ellipse#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the center of the ellipse. - * - * @name Phaser.Geom.Ellipse#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * The width of the ellipse. - * - * @name Phaser.Geom.Ellipse#width - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the ellipse. - * - * @name Phaser.Geom.Ellipse#height - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.height = height; - }, - - /** - * Check to see if the Ellipse contains the given x / y coordinates. - * - * @method Phaser.Geom.Ellipse#contains - * @since 3.0.0 - * - * @param {number} x - The x coordinate to check within the ellipse. - * @param {number} y - The y coordinate to check within the ellipse. - * - * @return {boolean} True if the coordinates are within the ellipse, otherwise false. - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @method Phaser.Geom.Ellipse#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. - */ - getPoint: function (position, point) - { - return GetPoint(this, position, point); - }, - - /** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * - * @method Phaser.Geom.Ellipse#getPoints - * @since 3.0.0 - * - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. - * - * @method Phaser.Geom.Ellipse#getRandomPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * Sets the x, y, width and height of this ellipse. - * - * @method Phaser.Geom.Ellipse#setTo - * @since 3.0.0 - * - * @param {number} x - The x position of the center of the ellipse. - * @param {number} y - The y position of the center of the ellipse. - * @param {number} width - The width of the ellipse. - * @param {number} height - The height of the ellipse. - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setTo: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * Sets this Ellipse to be empty with a width and height of zero. - * Does not change its position. - * - * @method Phaser.Geom.Ellipse#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setEmpty: function () - { - this.width = 0; - this.height = 0; - - return this; - }, - - /** - * Sets the position of this Ellipse. - * - * @method Phaser.Geom.Ellipse#setPosition - * @since 3.0.0 - * - * @param {number} x - The x position of the center of the ellipse. - * @param {number} y - The y position of the center of the ellipse. - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Sets the size of this Ellipse. - * Does not change its position. - * - * @method Phaser.Geom.Ellipse#setSize - * @since 3.0.0 - * - * @param {number} width - The width of the ellipse. - * @param {number} [height=width] - The height of the ellipse. - * - * @return {Phaser.Geom.Ellipse} This Ellipse object. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * Checks to see if the Ellipse is empty: has a width or height equal to zero. - * - * @method Phaser.Geom.Ellipse#isEmpty - * @since 3.0.0 - * - * @return {boolean} True if the Ellipse is empty, otherwise false. - */ - isEmpty: function () - { - return (this.width <= 0 || this.height <= 0); - }, - - /** - * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. - * - * @method Phaser.Geom.Ellipse#getMinorRadius - * @since 3.0.0 - * - * @return {number} The minor radius. - */ - getMinorRadius: function () - { - return Math.min(this.width, this.height) / 2; - }, - - /** - * Returns the major radius of the ellipse. Also known as the Semi Major Axis. - * - * @method Phaser.Geom.Ellipse#getMajorRadius - * @since 3.0.0 - * - * @return {number} The major radius. - */ - getMajorRadius: function () - { - return Math.max(this.width, this.height) / 2; - }, - - /** - * The left position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.x - (this.width / 2); - }, - - set: function (value) - { - this.x = value + (this.width / 2); - } - - }, - - /** - * The right position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.x + (this.width / 2); - }, - - set: function (value) - { - this.x = value - (this.width / 2); - } - - }, - - /** - * The top position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y - (this.height / 2); - }, - - set: function (value) - { - this.y = value + (this.height / 2); - } - - }, - - /** - * The bottom position of the Ellipse. - * - * @name Phaser.Geom.Ellipse#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + (this.height / 2); - }, - - set: function (value) - { - this.y = value - (this.height / 2); - } - - } - -}); - -module.exports = Ellipse; - - -/***/ }), -/* 115 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(123); -var Class = __webpack_require__(0); -var Commands = __webpack_require__(119); -var Components = __webpack_require__(15); -var Ellipse = __webpack_require__(249); -var GameObject = __webpack_require__(2); -var GetValue = __webpack_require__(4); -var MATH_CONST = __webpack_require__(16); -var Render = __webpack_require__(463); - -/** - * Graphics line style (or stroke style) settings. - * - * @typedef {object} GraphicsLineStyle - * - * @property {number} width - The stroke width. - * @property {number} color - The stroke color. - * @property {number} alpha - The stroke alpha. - */ - -/** - * Graphics fill style settings. - * - * @typedef {object} GraphicsFillStyle - * - * @property {number} color - The fill color. - * @property {number} alpha - The fill alpha. - */ - -/** - * Graphics style settings. - * - * @typedef {object} GraphicsStyles - * - * @property {GraphicsLineStyle} lineStyle - The style applied to shape outlines. - * @property {GraphicsFillStyle} fillStyle - The style applied to shape areas. - */ - -/** - * Options for the Graphics game Object. - * - * @typedef {object} GraphicsOptions - * @extends GraphicsStyles - * - * @property {number} x - The x coordinate of the Graphics. - * @property {number} y - The y coordinate of the Graphics. - */ - -/** - * @classdesc - * A Graphics object is a way to draw primitive shapes to you game. Primitives include forms of geometry, such as - * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics - * object it will be empty. - * - * To draw to it you must first specify a line style or fill style (or both), draw shapes using paths, and finally - * fill or stroke them. For example: - * - * ```javascript - * graphics.lineStyle(5, 0xFF00FF, 1.0); - * graphics.beginPath(); - * graphics.moveTo(100, 100); - * graphics.lineTo(200, 200); - * graphics.closePath(); - * graphics.strokePath(); - * ``` - * - * There are also many helpful methods that draw and fill/stroke common shapes for you. - * - * ```javascript - * graphics.lineStyle(5, 0xFF00FF, 1.0); - * graphics.fillStyle(0xFFFFFF, 1.0); - * graphics.fillRect(50, 50, 400, 200); - * graphics.strokeRect(50, 50, 400, 200); - * ``` - * - * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or WebGL. - * Under Canvas it will use the HTML Canvas context drawing operations to draw the path. - * Under WebGL the graphics data is decomposed into polygons. Both of these are expensive processes, especially with - * complex shapes. - * - * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help - * performance by calling {@link Phaser.GameObjects.Graphics#generateTexture}. This will 'bake' the Graphics object into - * a Texture, and return it. You can then use this Texture for Sprites or other display objects. If your Graphics object - * updates frequently then you should avoid doing this, as it will constantly generate new textures, which will consume - * memory. - * - * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful - * in their complexity and quantity of them in your game. - * - * @class Graphics - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - The Scene to which this Graphics object belongs. - * @param {GraphicsOptions} options - Options that set the position and default style of this Graphics object. - */ -var Graphics = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Pipeline, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - Render - ], - - initialize: - - function Graphics (scene, options) - { - var x = GetValue(options, 'x', 0); - var y = GetValue(options, 'y', 0); - - GameObject.call(this, scene, 'Graphics'); - - this.setPosition(x, y); - this.initPipeline('FlatTintPipeline'); - - /** - * The horizontal display origin of the Graphics. - * - * @name Phaser.GameObjects.Graphics#displayOriginX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.displayOriginX = 0; - - /** - * The vertical display origin of the Graphics. - * - * @name Phaser.GameObjects.Graphics#displayOriginY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.displayOriginY = 0; - - /** - * The array of commands used to render the Graphics. - * - * @name Phaser.GameObjects.Graphics#commandBuffer - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.commandBuffer = []; - - /** - * The default fill color for shapes rendered by this Graphics object. - * - * @name Phaser.GameObjects.Graphics#defaultFillColor - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.defaultFillColor = -1; - - /** - * The default fill alpha for shapes rendered by this Graphics object. - * - * @name Phaser.GameObjects.Graphics#defaultFillAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.defaultFillAlpha = 1; - - /** - * The default stroke width for shapes rendered by this Graphics object. - * - * @name Phaser.GameObjects.Graphics#defaultStrokeWidth - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.defaultStrokeWidth = 1; - - /** - * The default stroke color for shapes rendered by this Graphics object. - * - * @name Phaser.GameObjects.Graphics#defaultStrokeColor - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.defaultStrokeColor = -1; - - /** - * The default stroke alpha for shapes rendered by this Graphics object. - * - * @name Phaser.GameObjects.Graphics#defaultStrokeAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.defaultStrokeAlpha = 1; - - /** - * Internal property that keeps track of the line width style setting. - * - * @name Phaser.GameObjects.Graphics#_lineWidth - * @type {number} - * @private - * @since 3.0.0 - */ - this._lineWidth = 1.0; - - this.setDefaultStyles(options); - }, - - /** - * Set the default style settings for this Graphics object. - * - * @method Phaser.GameObjects.Graphics#setDefaultStyles - * @since 3.0.0 - * - * @param {GraphicsStyles} options - The styles to set as defaults. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - setDefaultStyles: function (options) - { - if (GetValue(options, 'lineStyle', null)) - { - this.defaultStrokeWidth = GetValue(options, 'lineStyle.width', 1); - this.defaultStrokeColor = GetValue(options, 'lineStyle.color', 0xffffff); - this.defaultStrokeAlpha = GetValue(options, 'lineStyle.alpha', 1); - - this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); - } - - if (GetValue(options, 'fillStyle', null)) - { - this.defaultFillColor = GetValue(options, 'fillStyle.color', 0xffffff); - this.defaultFillAlpha = GetValue(options, 'fillStyle.alpha', 1); - - this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); - } - - return this; - }, - - /** - * Set the current line style. - * - * @method Phaser.GameObjects.Graphics#lineStyle - * @since 3.0.0 - * - * @param {number} lineWidth - The stroke width. - * @param {number} color - The stroke color. - * @param {number} [alpha=1] - The stroke alpha. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineStyle: function (lineWidth, color, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.commandBuffer.push( - Commands.LINE_STYLE, - lineWidth, color, alpha - ); - - this._lineWidth = lineWidth; - - return this; - }, - - /** - * Set the current fill style. - * - * @method Phaser.GameObjects.Graphics#fillStyle - * @since 3.0.0 - * - * @param {number} color - The fill color. - * @param {number} [alpha=1] - The fill alpha. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillStyle: function (color, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.commandBuffer.push( - Commands.FILL_STYLE, - color, alpha - ); - - return this; - }, - - /** - * Start a new shape path. - * - * @method Phaser.GameObjects.Graphics#beginPath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - beginPath: function () - { - this.commandBuffer.push( - Commands.BEGIN_PATH - ); - - return this; - }, - - /** - * Close the current path. - * - * @method Phaser.GameObjects.Graphics#closePath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - closePath: function () - { - this.commandBuffer.push( - Commands.CLOSE_PATH - ); - - return this; - }, - - /** - * Fill the current path. - * - * @method Phaser.GameObjects.Graphics#fillPath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPath: function () - { - this.commandBuffer.push( - Commands.FILL_PATH - ); - - return this; - }, - - /** - * Stroke the current path. - * - * @method Phaser.GameObjects.Graphics#strokePath - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokePath: function () - { - this.commandBuffer.push( - Commands.STROKE_PATH - ); - - return this; - }, - - /** - * Fill the given circle. - * - * @method Phaser.GameObjects.Graphics#fillCircleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The circle to fill. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillCircleShape: function (circle) - { - return this.fillCircle(circle.x, circle.y, circle.radius); - }, - - /** - * Stroke the given circle. - * - * @method Phaser.GameObjects.Graphics#strokeCircleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The circle to stroke. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeCircleShape: function (circle) - { - return this.strokeCircle(circle.x, circle.y, circle.radius); - }, - - /** - * Fill a circle with the given position and radius. - * - * @method Phaser.GameObjects.Graphics#fillCircle - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the center of the circle. - * @param {number} y - The y coordinate of the center of the circle. - * @param {number} radius - The radius of the circle. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillCircle: function (x, y, radius) - { - this.beginPath(); - this.arc(x, y, radius, 0, MATH_CONST.PI2); - this.fillPath(); - - return this; - }, - - /** - * Stroke a circle with the given position and radius. - * - * @method Phaser.GameObjects.Graphics#strokeCircle - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the center of the circle. - * @param {number} y - The y coordinate of the center of the circle. - * @param {number} radius - The radius of the circle. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeCircle: function (x, y, radius) - { - this.beginPath(); - this.arc(x, y, radius, 0, MATH_CONST.PI2); - this.strokePath(); - - return this; - }, - - /** - * Fill the given rectangle. - * - * @method Phaser.GameObjects.Graphics#fillRectShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - The rectangle to fill. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillRectShape: function (rect) - { - return this.fillRect(rect.x, rect.y, rect.width, rect.height); - }, - - /** - * Stroke the given rectangle. - * - * @method Phaser.GameObjects.Graphics#strokeRectShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - The rectangle to stroke. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeRectShape: function (rect) - { - return this.strokeRect(rect.x, rect.y, rect.width, rect.height); - }, - - /** - * Fill a rectangle with the given position and size. - * - * @method Phaser.GameObjects.Graphics#fillRect - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the top-left of the rectangle. - * @param {number} y - The y coordinate of the top-left of the rectangle. - * @param {number} width - The width of the rectangle. - * @param {number} height - The height of the rectangle. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillRect: function (x, y, width, height) - { - this.commandBuffer.push( - Commands.FILL_RECT, - x, y, width, height - ); - - return this; - }, - - /** - * Stroke a rectangle with the given position and size. - * - * @method Phaser.GameObjects.Graphics#strokeRect - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the top-left of the rectangle. - * @param {number} y - The y coordinate of the top-left of the rectangle. - * @param {number} width - The width of the rectangle. - * @param {number} height - The height of the rectangle. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeRect: function (x, y, width, height) - { - var lineWidthHalf = this._lineWidth / 2; - var minx = x - lineWidthHalf; - var maxx = x + lineWidthHalf; - - this.beginPath(); - this.moveTo(x, y); - this.lineTo(x, y + height); - this.strokePath(); - - this.beginPath(); - this.moveTo(x + width, y); - this.lineTo(x + width, y + height); - this.strokePath(); - - this.beginPath(); - this.moveTo(minx, y); - this.lineTo(maxx + width, y); - this.strokePath(); - - this.beginPath(); - this.moveTo(minx, y + height); - this.lineTo(maxx + width, y + height); - this.strokePath(); - - return this; - }, - - /** - * Fill the given point. - * - * Draws a square at the given position, 1 pixel in size by default. - * - * @method Phaser.GameObjects.Graphics#fillPointShape - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - The point to fill. - * @param {number} [size=1] - The size of the square to draw. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPointShape: function (point, size) - { - return this.fillPoint(point.x, point.y, size); - }, - - /** - * Fill a point at the given position. - * - * Draws a square at the given position, 1 pixel in size by default. - * - * @method Phaser.GameObjects.Graphics#fillPoint - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the point. - * @param {number} y - The y coordinate of the point. - * @param {number} [size=1] - The size of the square to draw. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPoint: function (x, y, size) - { - if (!size || size < 1) - { - size = 1; - } - else - { - x -= (size / 2); - y -= (size / 2); - } - - this.commandBuffer.push( - Commands.FILL_RECT, - x, y, size, size - ); - - return this; - }, - - /** - * Fill the given triangle. - * - * @method Phaser.GameObjects.Graphics#fillTriangleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - The triangle to fill. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillTriangleShape: function (triangle) - { - return this.fillTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); - }, - - /** - * Stroke the given triangle. - * - * @method Phaser.GameObjects.Graphics#strokeTriangleShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - The triangle to stroke. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeTriangleShape: function (triangle) - { - return this.strokeTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); - }, - - /** - * Fill a triangle with the given points. - * - * @method Phaser.GameObjects.Graphics#fillTriangle - * @since 3.0.0 - * - * @param {number} x0 - The x coordinate of the first point. - * @param {number} y0 - The y coordinate of the first point. - * @param {number} x1 - The x coordinate of the second point. - * @param {number} y1 - The y coordinate of the second point. - * @param {number} x2 - The x coordinate of the third point. - * @param {number} y2 - The y coordinate of the third point. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillTriangle: function (x0, y0, x1, y1, x2, y2) - { - this.commandBuffer.push( - Commands.FILL_TRIANGLE, - x0, y0, x1, y1, x2, y2 - ); - - return this; - }, - - /** - * Stroke a triangle with the given points. - * - * @method Phaser.GameObjects.Graphics#strokeTriangle - * @since 3.0.0 - * - * @param {number} x0 - The x coordinate of the first point. - * @param {number} y0 - The y coordinate of the first point. - * @param {number} x1 - The x coordinate of the second point. - * @param {number} y1 - The y coordinate of the second point. - * @param {number} x2 - The x coordinate of the third point. - * @param {number} y2 - The y coordinate of the third point. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeTriangle: function (x0, y0, x1, y1, x2, y2) - { - this.commandBuffer.push( - Commands.STROKE_TRIANGLE, - x0, y0, x1, y1, x2, y2 - ); - - return this; - }, - - /** - * Draw the given line. - * - * @method Phaser.GameObjects.Graphics#strokeLineShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - The line to stroke. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeLineShape: function (line) - { - return this.lineBetween(line.x1, line.y1, line.x2, line.y2); - }, - - /** - * Draw a line between the given points. - * - * @method Phaser.GameObjects.Graphics#lineBetween - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the start point of the line. - * @param {number} y1 - The y coordinate of the start point of the line. - * @param {number} x2 - The x coordinate of the end point of the line. - * @param {number} y2 - The y coordinate of the end point of the line. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineBetween: function (x1, y1, x2, y2) - { - this.beginPath(); - this.moveTo(x1, y1); - this.lineTo(x2, y2); - this.strokePath(); - - return this; - }, - - /** - * Draw a line from the current drawing position to the given position. - * - * Moves the current drawing position to the given position. - * - * @method Phaser.GameObjects.Graphics#lineTo - * @since 3.0.0 - * - * @param {number} x - The x coordinate to draw the line to. - * @param {number} y - The y coordinate to draw the line to. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineTo: function (x, y) - { - this.commandBuffer.push( - Commands.LINE_TO, - x, y - ); - - return this; - }, - - /** - * Move the current drawing position to the given position. - * - * @method Phaser.GameObjects.Graphics#moveTo - * @since 3.0.0 - * - * @param {number} x - The x coordinate to move to. - * @param {number} y - The y coordinate to move to. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - moveTo: function (x, y) - { - this.commandBuffer.push( - Commands.MOVE_TO, - x, y - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#lineFxTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - lineFxTo: function (x, y, width, rgb) - { - this.commandBuffer.push( - Commands.LINE_FX_TO, - x, y, width, rgb, 1 - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#moveFxTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - moveFxTo: function (x, y, width, rgb) - { - this.commandBuffer.push( - Commands.MOVE_FX_TO, - x, y, width, rgb, 1 - ); - - return this; - }, - - /** - * Stroke the shape represented by the given array of points. - * - * Pass `true` to `autoClose` to close the shape automatically. - * - * @method Phaser.GameObjects.Graphics#strokePoints - * @since 3.0.0 - * - * @param {(array|Phaser.Geom.Point[])} points - The points to stroke. - * @param {boolean} [autoClose=false] - When `true`, the shape is closed by joining the last point to the first point. - * @param {integer} [endIndex] - The index of `points` to stop drawing at. Defaults to `points.length`. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokePoints: function (points, autoClose, endIndex) - { - if (autoClose === undefined) { autoClose = false; } - if (endIndex === undefined) { endIndex = points.length; } - - this.beginPath(); - - this.moveTo(points[0].x, points[0].y); - - for (var i = 1; i < endIndex; i++) - { - this.lineTo(points[i].x, points[i].y); - } - - if (autoClose) - { - this.lineTo(points[0].x, points[0].y); - } - - this.strokePath(); - - return this; - }, - - /** - * Fill the shape represented by the given array of points. - * - * Pass `true` to `autoClose` to close the shape automatically. - * - * @method Phaser.GameObjects.Graphics#fillPoints - * @since 3.0.0 - * - * @param {(array|Phaser.Geom.Point[])} points - The points to fill. - * @param {boolean} [autoClose=false] - Whether to automatically close the polygon. - * @param {integer} [endIndex] - The index of `points` to stop at. Defaults to `points.length`. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillPoints: function (points, autoClose, endIndex) - { - if (autoClose === undefined) { autoClose = false; } - if (endIndex === undefined) { endIndex = points.length; } - - this.beginPath(); - - this.moveTo(points[0].x, points[0].y); - - for (var i = 1; i < endIndex; i++) - { - this.lineTo(points[i].x, points[i].y); - } - - if (autoClose) - { - this.lineTo(points[0].x, points[0].y); - } - - this.fillPath(); - - return this; - }, - - /** - * Stroke the given ellipse. - * - * @method Phaser.GameObjects.Graphics#strokeEllipseShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The ellipse to stroke. - * @param {integer} [smoothness=32] - The number of points to draw the ellipse with. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeEllipseShape: function (ellipse, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var points = ellipse.getPoints(smoothness); - - return this.strokePoints(points, true); - }, - - /** - * Stroke an ellipse with the given position and size. - * - * @method Phaser.GameObjects.Graphics#strokeEllipse - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the center of the ellipse. - * @param {number} y - The y coordinate of the center of the ellipse. - * @param {number} width - The width of the ellipse. - * @param {number} height - The height of the ellipse. - * @param {integer} [smoothness=32] - The number of points to draw the ellipse with. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - strokeEllipse: function (x, y, width, height, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var ellipse = new Ellipse(x, y, width, height); - - var points = ellipse.getPoints(smoothness); - - return this.strokePoints(points, true); - }, - - /** - * Fill the given ellipse. - * - * @method Phaser.GameObjects.Graphics#fillEllipseShape - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The ellipse to fill. - * @param {integer} [smoothness=32] - The number of points to draw the ellipse with. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillEllipseShape: function (ellipse, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var points = ellipse.getPoints(smoothness); - - return this.fillPoints(points, true); - }, - - /** - * Fill an ellipse with the given position and size. - * - * @method Phaser.GameObjects.Graphics#fillEllipse - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the center of the ellipse. - * @param {number} y - The y coordinate of the center of the ellipse. - * @param {number} width - The width of the ellipse. - * @param {number} height - The height of the ellipse. - * @param {integer} [smoothness=32] - The number of points to draw the ellipse with. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - fillEllipse: function (x, y, width, height, smoothness) - { - if (smoothness === undefined) { smoothness = 32; } - - var ellipse = new Ellipse(x, y, width, height); - - var points = ellipse.getPoints(smoothness); - - return this.fillPoints(points, true); - }, - - /** - * Draw an arc. - * - * This method can be used to create circles, or parts of circles. - * - * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling - * this method to draw the arc. - * - * @method Phaser.GameObjects.Graphics#arc - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the center of the circle. - * @param {number} y - The y coordinate of the center of the circle. - * @param {number} radius - The radius of the circle. - * @param {number} startAngle - The starting angle, in radians. - * @param {number} endAngle - The ending angle, in radians. - * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - arc: function (x, y, radius, startAngle, endAngle, anticlockwise) - { - this.commandBuffer.push( - Commands.ARC, - x, y, radius, startAngle, endAngle, anticlockwise - ); - - return this; - }, - - /** - * Creates a pie-chart slice shape centered at `x`, `y` with the given radius. - * You must define the start and end angle of the slice. - * - * Setting the `anticlockwise` argument to `true` creates a shape similar to Pacman. - * Setting it to `false` creates a shape like a slice of pie. - * - * This method will begin a new path and close the path at the end of it. - * To display the actual slice you need to call either `strokePath` or `fillPath` after it. - * - * @method Phaser.GameObjects.Graphics#slice - * @since 3.4.0 - * - * @param {number} x - The horizontal center of the slice. - * @param {number} y - The vertical center of the slice. - * @param {number} radius - The radius of the slice. - * @param {number} startAngle - The start angle of the slice, given in radians. - * @param {number} endAngle - The end angle of the slice, given in radians. - * @param {boolean} [anticlockwise=false] - Draw the slice piece anticlockwise or clockwise? - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - slice: function (x, y, radius, startAngle, endAngle, anticlockwise) - { - if (anticlockwise === undefined) { anticlockwise = false; } - - this.commandBuffer.push(Commands.BEGIN_PATH); - - this.commandBuffer.push(Commands.MOVE_TO, x, y); - - this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise); - - this.commandBuffer.push(Commands.CLOSE_PATH); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#save - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - save: function () - { - this.commandBuffer.push( - Commands.SAVE - ); - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Graphics#restore - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - restore: function () - { - this.commandBuffer.push( - Commands.RESTORE - ); - - return this; - }, - - /** - * Translate the graphics. - * - * @method Phaser.GameObjects.Graphics#translate - * @since 3.0.0 - * - * @param {number} x - The horizontal translation to apply. - * @param {number} y - The vertical translation to apply. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - translate: function (x, y) - { - this.commandBuffer.push( - Commands.TRANSLATE, - x, y - ); - - return this; - }, - - /** - * Scale the graphics. - * - * @method Phaser.GameObjects.Graphics#scale - * @since 3.0.0 - * - * @param {number} x - The horizontal scale to apply. - * @param {number} y - The vertical scale to apply. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - scale: function (x, y) - { - this.commandBuffer.push( - Commands.SCALE, - x, y - ); - - return this; - }, - - /** - * Rotate the graphics. - * - * @method Phaser.GameObjects.Graphics#rotate - * @since 3.0.0 - * - * @param {number} radians - The rotation angle, in radians. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - rotate: function (radians) - { - this.commandBuffer.push( - Commands.ROTATE, - radians - ); - - return this; - }, - - /** - * Clear the command buffer and reset the fill style and line style to their defaults. - * - * @method Phaser.GameObjects.Graphics#clear - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - clear: function () - { - this.commandBuffer.length = 0; - - if (this.defaultFillColor > -1) - { - this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); - } - - if (this.defaultStrokeColor > -1) - { - this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); - } - - return this; - }, - - /** - * Generate a texture from this Graphics object. - * - * If `key` is a string it'll generate a new texture using it and add it into the - * Texture Manager (assuming no key conflict happens). - * - * If `key` is a Canvas it will draw the texture to that canvas context. Note that it will NOT - * automatically upload it to the GPU in WebGL mode. - * - * @method Phaser.GameObjects.Graphics#generateTexture - * @since 3.0.0 - * - * @param {(string|HTMLCanvasElement)} key - The key to store the texture with in the Texture Manager, or a Canvas to draw to. - * @param {integer} [width] - The width of the graphics to generate. - * @param {integer} [height] - The height of the graphics to generate. - * - * @return {Phaser.GameObjects.Graphics} This Game Object. - */ - generateTexture: function (key, width, height) - { - var sys = this.scene.sys; - - if (width === undefined) { width = sys.game.config.width; } - if (height === undefined) { height = sys.game.config.height; } - - Graphics.TargetCamera.setViewport(0, 0, width, height); - Graphics.TargetCamera.scrollX = this.x; - Graphics.TargetCamera.scrollY = this.y; - - var texture; - var ctx; - - if (typeof key === 'string') - { - if (sys.textures.exists(key)) - { - // Key is a string, it DOES exist in the Texture Manager AND is a canvas, so draw to it - - texture = sys.textures.get(key); - - var src = texture.getSourceImage(); - - if (src instanceof HTMLCanvasElement) - { - ctx = src.getContext('2d'); - } - } - else - { - // Key is a string and doesn't exist in the Texture Manager, so generate and save it - - texture = sys.textures.createCanvas(key, width, height); - - ctx = texture.getSourceImage().getContext('2d'); - } - } - else if (key instanceof HTMLCanvasElement) - { - // Key is a Canvas, so draw to it - - ctx = key.getContext('2d'); - } - - if (ctx) - { - this.renderCanvas(sys.game.renderer, this, 0.0, Graphics.TargetCamera, null, ctx); - - if (sys.game.renderer.gl && texture) - { - texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture); - } - } - - return this; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.Graphics#preDestroy - * @protected - * @since 3.9.0 - */ - preDestroy: function () - { - this.commandBuffer = []; - } - -}); - -/** - * A Camera used specifically by the Graphics system for rendering to textures. - * - * @name Phaser.GameObjects.Graphics.TargetCamera - * @type {Phaser.Cameras.Scene2D.Camera} - * @since 3.1.0 - */ -Graphics.TargetCamera = new Camera(0, 0, 0, 0); - -module.exports = Graphics; - - -/***/ }), -/* 116 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** -* A Matrix is simply an array of arrays, where each sub-array (the rows) have the same length: -* -* let matrix2 = [ -* [ 1, 1, 1, 1, 1, 1 ], -* [ 2, 0, 0, 0, 0, 4 ], -* [ 2, 0, 1, 2, 0, 4 ], -* [ 2, 0, 3, 4, 0, 4 ], -* [ 2, 0, 0, 0, 0, 4 ], -* [ 3, 3, 3, 3, 3, 3 ] -*]; -*/ - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.CheckMatrix - * @since 3.0.0 - * - * @param {array} matrix - [description] - * - * @return {boolean} [description] - */ -var CheckMatrix = function (matrix) -{ - if (!Array.isArray(matrix) || matrix.length < 2 || !Array.isArray(matrix[0])) - { - return false; - } - - // How long is the first row? - var size = matrix[0].length; - - // Validate the rest of the rows are the same length - for (var i = 1; i < matrix.length; i++) - { - if (matrix[i].length !== size) - { - return false; - } - } - - return true; -}; - -module.exports = CheckMatrix; - - -/***/ }), -/* 117 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Frame = __webpack_require__(128); -var TextureSource = __webpack_require__(183); - -/** - * @classdesc - * A Texture consists of a source, usually an Image from the Cache, and a collection of Frames. - * The Frames represent the different areas of the Texture. For example a texture atlas - * may have many Frames, one for each element within the atlas. Where-as a single image would have - * just one frame, that encompasses the whole image. - * - * Textures are managed by the global TextureManager. This is a singleton class that is - * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. - * - * Sprites and other Game Objects get the texture data they need from the TextureManager. - * - * @class Texture - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. - * @param {string} key - The unique string-based key of this Texture. - * @param {(HTMLImageElement[]|HTMLCanvasElement[])} source - An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. - * @param {number} [width] - The width of the Texture. This is optional and automatically derived from the source images. - * @param {number} [height] - The height of the Texture. This is optional and automatically derived from the source images. - */ -var Texture = new Class({ - - initialize: - - function Texture (manager, key, source, width, height) - { - if (!Array.isArray(source)) - { - source = [ source ]; - } - - /** - * A reference to the Texture Manager this Texture belongs to. - * - * @name Phaser.Textures.Texture#manager - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * The unique string-based key of this Texture. - * - * @name Phaser.Textures.Texture#key - * @type {string} - * @since 3.0.0 - */ - this.key = key; - - /** - * An array of TextureSource instances. - * These are unique to this Texture and contain the actual Image (or Canvas) data. - * - * @name Phaser.Textures.Texture#source - * @type {Phaser.Textures.TextureSource[]} - * @since 3.0.0 - */ - this.source = []; - - /** - * An array of TextureSource data instances. - * Used to store additional data images, such as normal maps or specular maps. - * - * @name Phaser.Textures.Texture#dataSource - * @type {array} - * @since 3.0.0 - */ - this.dataSource = []; - - /** - * A key-value object pair associating the unique Frame keys with the Frames objects. - * - * @name Phaser.Textures.Texture#frames - * @type {object} - * @since 3.0.0 - */ - this.frames = {}; - - /** - * Any additional data that was set in the source JSON (if any), - * or any extra data you'd like to store relating to this texture - * - * @name Phaser.Textures.Texture#customData - * @type {object} - * @since 3.0.0 - */ - this.customData = {}; - - /** - * The name of the first frame of the Texture. - * - * @name Phaser.Textures.Texture#firstFrame - * @type {string} - * @since 3.0.0 - */ - this.firstFrame = '__BASE'; - - /** - * The total number of Frames in this Texture. - * - * @name Phaser.Textures.Texture#frameTotal - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.frameTotal = 0; - - // Load the Sources - for (var i = 0; i < source.length; i++) - { - this.source.push(new TextureSource(this, source[i], width, height)); - } - }, - - /** - * Adds a new Frame to this Texture. - * - * A Frame is a rectangular region of a TextureSource with a unique index or string-based key. - * - * @method Phaser.Textures.Texture#add - * @since 3.0.0 - * - * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. - * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. - * @param {number} x - The x coordinate of the top-left of this Frame. - * @param {number} y - The y coordinate of the top-left of this Frame. - * @param {number} width - The width of this Frame. - * @param {number} height - The height of this Frame. - * - * @return {Phaser.Textures.Frame} The Frame that was added to this Texture. - */ - add: function (name, sourceIndex, x, y, width, height) - { - var frame = new Frame(this, name, sourceIndex, x, y, width, height); - - this.frames[name] = frame; - - // Set the first frame of the Texture (other than __BASE) - // This is used to ensure we don't spam the display with entire - // atlases of sprite sheets, but instead just the first frame of them - // should the dev incorrectly specify the frame index - if (this.frameTotal === 1) - { - this.firstFrame = name; - } - - this.frameTotal++; - - return frame; - }, - - /** - * Checks to see if a Frame matching the given key exists within this Texture. - * - * @method Phaser.Textures.Texture#has - * @since 3.0.0 - * - * @param {string} name - The key of the Frame to check for. - * - * @return {boolean} True if a Frame with the matching key exists in this Texture. - */ - has: function (name) - { - return (this.frames[name]); - }, - - /** - * Gets a Frame from this Texture based on either the key or the index of the Frame. - * - * In a Texture Atlas Frames are typically referenced by a key. - * In a Sprite Sheet Frames are referenced by an index. - * Passing no value for the name returns the base texture. - * - * @method Phaser.Textures.Texture#get - * @since 3.0.0 - * - * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. - * - * @return {Phaser.Textures.Frame} The Texture Frame. - */ - get: function (name) - { - // null, undefined, empty string, zero - if (!name) - { - name = this.firstFrame; - } - - var frame = this.frames[name]; - - if (!frame) - { - console.warn('No Texture.frame found with name ' + name); - - frame = this.frames[this.firstFrame]; - } - - return frame; - }, - - /** - * Takes the given TextureSource and returns the index of it within this Texture. - * If it's not in this Texture, it returns -1. - * Unless this Texture has multiple TextureSources, such as with a multi-atlas, this - * method will always return zero or -1. - * - * @method Phaser.Textures.Texture#getTextureSourceIndex - * @since 3.0.0 - * - * @param {Phaser.Textures.TextureSource} source - The TextureSource to check. - * - * @return {integer} The index of the TextureSource within this Texture, or -1 if not in this Texture. - */ - getTextureSourceIndex: function (source) - { - for (var i = 0; i < this.source.length; i++) - { - if (this.source[i] === source) - { - return i; - } - } - - return -1; - }, - - /** - * Returns an array of all the Frames in the given TextureSource. - * - * @method Phaser.Textures.Texture#getFramesFromTextureSource - * @since 3.0.0 - * - * @param {integer} sourceIndex - The index of the TextureSource to get the Frames from. - * - * @return {Phaser.Textures.Frame[]} An array of Texture Frames. - */ - getFramesFromTextureSource: function (sourceIndex) - { - var out = []; - - for (var frameName in this.frames) - { - if (frameName === '__BASE') - { - continue; - } - - var frame = this.frames[frameName]; - - if (frame.sourceIndex === sourceIndex) - { - out.push(frame.name); - } - } - - return out; - }, - - /** - * Returns an array with all of the names of the Frames in this Texture. - * - * Useful if you want to randomly assign a Frame to a Game Object, as you can - * pick a random element from the returned array. - * - * @method Phaser.Textures.Texture#getFrameNames - * @since 3.0.0 - * - * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? - * - * @return {string[]} An array of all Frame names in this Texture. - */ - getFrameNames: function (includeBase) - { - if (includeBase === undefined) { includeBase = false; } - - var out = Object.keys(this.frames); - - if (!includeBase) - { - var idx = out.indexOf('__BASE'); - - if (idx !== -1) - { - out.splice(idx, 1); - } - } - - return out; - }, - - /** - * Given a Frame name, return the source image it uses to render with. - * - * This will return the actual DOM Image or Canvas element. - * - * @method Phaser.Textures.Texture#getSourceImage - * @since 3.0.0 - * - * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. - * - * @return {(HTMLImageElement|HTMLCanvasElement)} The DOM Image or Canvas Element. - */ - getSourceImage: function (name) - { - if (name === undefined || name === null || this.frameTotal === 1) - { - name = '__BASE'; - } - - var frame = this.frames[name]; - - if (!frame) - { - console.warn('No Texture.frame found with name ' + name); - - return this.frames['__BASE'].source.image; - } - else - { - return frame.source.image; - } - }, - - /** - * Given a Frame name, return the data source image it uses to render with. - * You can use this to get the normal map for an image for example. - * - * This will return the actual DOM Image. - * - * @method Phaser.Textures.Texture#getDataSourceImage - * @since 3.7.0 - * - * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. - * - * @return {(HTMLImageElement|HTMLCanvasElement)} The DOM Image or Canvas Element. - */ - getDataSourceImage: function (name) - { - if (name === undefined || name === null || this.frameTotal === 1) - { - name = '__BASE'; - } - - var frame = this.frames[name]; - var idx; - - if (!frame) - { - console.warn('No Texture.frame found with name ' + name); - - idx = this.frames['__BASE'].sourceIndex; - } - else - { - idx = frame.sourceIndex; - } - - return this.dataSource[idx].image; - }, - - /** - * Adds a data source image to this Texture. - * - * An example of a data source image would be a normal map, where all of the Frames for this Texture - * equally apply to the normal map. - * - * @method Phaser.Textures.Texture#setDataSource - * @since 3.0.0 - * - * @param {(HTMLImageElement|HTMLCanvasElement)} data - The source image. - */ - setDataSource: function (data) - { - if (!Array.isArray(data)) - { - data = [ data ]; - } - - for (var i = 0; i < data.length; i++) - { - var source = this.source[i]; - - this.dataSource.push(new TextureSource(this, data[i], source.width, source.height)); - } - }, - - /** - * Sets the Filter Mode for this Texture. - * - * The mode can be either Linear, the default, or Nearest. - * - * For pixel-art you should use Nearest. - * - * The mode applies to the entire Texture, not just a specific Frame of it. - * - * @method Phaser.Textures.Texture#setFilter - * @since 3.0.0 - * - * @param {Phaser.Textures.FilterMode} filterMode - The Filter Mode. - */ - setFilter: function (filterMode) - { - var i; - - for (i = 0; i < this.source.length; i++) - { - this.source[i].setFilter(filterMode); - } - - for (i = 0; i < this.dataSource.length; i++) - { - this.dataSource[i].setFilter(filterMode); - } - }, - - /** - * Destroys this Texture and releases references to its sources and frames. - * - * @method Phaser.Textures.Texture#destroy - * @since 3.0.0 - */ - destroy: function () - { - var i; - - for (i = 0; i < this.source.length; i++) - { - this.source[i].destroy(); - } - - for (i = 0; i < this.dataSource.length; i++) - { - this.dataSource[i].destroy(); - } - - for (var frameName in this.frames) - { - var frame = this.frames[frameName]; - - frame.destroy(); - } - - this.source = []; - this.dataSource = []; - this.frames = {}; - this.manager = null; - } - -}); - -module.exports = Texture; - - -/***/ }), -/* 118 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(55); -var DefaultPlugins = __webpack_require__(121); -var GetPhysicsPlugins = __webpack_require__(518); -var GetScenePlugins = __webpack_require__(517); -var NOOP = __webpack_require__(3); -var Settings = __webpack_require__(192); - -/** - * @classdesc - * The Scene Systems class. - * - * This class is available from within a Scene under the property `sys`. - * It is responsible for managing all of the plugins a Scene has running, including the display list, and - * handling the update step and renderer. It also contains references to global systems belonging to Game. - * - * @class Systems - * @memberOf Phaser.Scenes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene that owns this Systems instance. - * @param {(string|Phaser.Scenes.Settings.Config)} config - Scene specific configuration settings. - */ -var Systems = new Class({ - - initialize: - - function Systems (scene, config) - { - /** - * [description] - * - * @name Phaser.Scenes.Systems#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#config - * @type {(string|Phaser.Scenes.Settings.Config)} - * @since 3.0.0 - */ - this.config = config; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#settings - * @type {Phaser.Scenes.Settings.Object} - * @since 3.0.0 - */ - this.settings = Settings.create(config); - - /** - * A handy reference to the Scene canvas / context. - * - * @name Phaser.Scenes.Systems#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context; - - // Global Systems - these are single-instance global managers that belong to Game - - /** - * [description] - * - * @name Phaser.Scenes.Systems#anims - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.anims; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#cache - * @type {Phaser.Cache.CacheManager} - * @since 3.0.0 - */ - this.cache; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#plugins - * @type {Phaser.Plugins.PluginManager} - * @since 3.0.0 - */ - this.plugins; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#registry - * @type {Phaser.Data.DataManager} - * @since 3.0.0 - */ - this.registry; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#sound - * @type {Phaser.Sound.BaseSoundManager} - * @since 3.0.0 - */ - this.sound; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#textures - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.textures; - - // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems - - /** - * [description] - * - * @name Phaser.Scenes.Systems#add - * @type {Phaser.GameObjects.GameObjectFactory} - * @since 3.0.0 - */ - this.add; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#cameras - * @type {Phaser.Cameras.Scene2D.CameraManager} - * @since 3.0.0 - */ - this.cameras; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#displayList - * @type {Phaser.GameObjects.DisplayList} - * @since 3.0.0 - */ - this.displayList; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#make - * @type {Phaser.GameObjects.GameObjectCreator} - * @since 3.0.0 - */ - this.make; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#scenePlugin - * @type {Phaser.Scenes.ScenePlugin} - * @since 3.0.0 - */ - this.scenePlugin; - - /** - * [description] - * - * @name Phaser.Scenes.Systems#updateList - * @type {Phaser.GameObjects.UpdateList} - * @since 3.0.0 - */ - this.updateList; - - /** - * The Scene Update function. - * - * This starts out as NOOP during init, preload and create, and at the end of create - * it swaps to be whatever the Scene.update function is. - * - * @name Phaser.Scenes.Systems#sceneUpdate - * @type {function} - * @private - * @since 3.10.0 - */ - this.sceneUpdate = NOOP; - }, - - /** - * 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 instance. - */ - init: function (game) - { - this.settings.status = CONST.INIT; - - // This will get replaced by the SceneManager with the actual update function, if it exists, once create is over. - this.sceneUpdate = NOOP; - - this.game = game; - - this.canvas = game.canvas; - this.context = game.context; - - var pluginManager = game.plugins; - - this.plugins = pluginManager; - - pluginManager.addToScene(this, DefaultPlugins.Global, [ DefaultPlugins.CoreScene, GetScenePlugins(this), GetPhysicsPlugins(this) ]); - - this.events.emit('boot', this); - - this.settings.isBooted = true; - }, - - /** - * Called by a plugin, it tells the System to install the plugin locally. - * - * @method Phaser.Scenes.Systems#install - * @private - * @since 3.0.0 - * - * @param {array} plugin - An array of plugins to install into this Scene. - */ - install: function (plugin) - { - if (!Array.isArray(plugin)) - { - plugin = [ plugin ]; - } - - this.plugins.installLocal(this, plugin); - }, - - /** - * 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 - * - * @param {number} time - The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). - * @param {number} delta - The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. - */ - step: function (time, delta) - { - this.events.emit('preupdate', time, delta); - - this.events.emit('update', time, delta); - - this.sceneUpdate.call(this.scene, time, delta); - - this.events.emit('postupdate', time, delta); - }, - - /** - * 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 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - */ - render: function (renderer) - { - var displayList = this.displayList; - - displayList.depthSort(); - - this.cameras.render(renderer, displayList); - - this.events.emit('render', renderer); - }, - - /** - * Force a sort of the display list on the next render. - * - * @method Phaser.Scenes.Systems#queueDepthSort - * @since 3.0.0 - */ - queueDepthSort: function () - { - this.displayList.queueDepthSort(); - }, - - /** - * Immediately sorts the display list if the flag is set. - * - * @method Phaser.Scenes.Systems#depthSort - * @since 3.0.0 - */ - depthSort: function () - { - this.displayList.depthSort(); - }, - - /** - * Pause this Scene. - * A paused Scene still renders, it just doesn't run ANY of its update handlers or systems. - * - * @method Phaser.Scenes.Systems#pause - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - pause: function () - { - if (this.settings.active) - { - this.settings.status = CONST.PAUSED; - - this.settings.active = false; - - this.events.emit('pause', this); - } - - return this; - }, - - /** - * Resume this Scene from a paused state. - * - * @method Phaser.Scenes.Systems#resume - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - resume: function () - { - if (!this.settings.active) - { - this.settings.status = CONST.RUNNING; - - this.settings.active = true; - - this.events.emit('resume', this); - } - - return this; - }, - - /** - * Send this Scene to sleep. - * - * 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 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - sleep: function () - { - this.settings.status = CONST.SLEEPING; - - this.settings.active = false; - this.settings.visible = false; - - this.events.emit('sleep', this); - - return this; - }, - - /** - * Wake-up this Scene if it was previously asleep. - * - * @method Phaser.Scenes.Systems#wake - * @since 3.0.0 - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - wake: function () - { - var settings = this.settings; - - 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; - }, - - /** - * Is this Scene sleeping? - * - * @method Phaser.Scenes.Systems#isSleeping - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isSleeping: function () - { - return (this.settings.status === CONST.SLEEPING); - }, - - /** - * Is this Scene active? - * - * @method Phaser.Scenes.Systems#isActive - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isActive: function () - { - 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? - * - * @method Phaser.Scenes.Systems#isVisible - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isVisible: function () - { - return this.settings.visible; - }, - - /** - * 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 - * - * @param {boolean} value - [description] - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - setVisible: function (value) - { - this.settings.visible = value; - - return this; - }, - - /** - * 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 - If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. - * - * @return {Phaser.Scenes.Systems} This Systems object. - */ - setActive: function (value) - { - if (value) - { - return this.resume(); - } - else - { - return this.pause(); - } - }, - - /** - * Start this Scene running and rendering. - * Called automatically by the SceneManager. - * - * @method Phaser.Scenes.Systems#start - * @since 3.0.0 - * - * @param {object} data - Optional data object that may have been passed to this Scene from another. - */ - start: function (data) - { - if (data) - { - this.settings.data = data; - } - - this.settings.status = CONST.START; - - this.settings.active = true; - this.settings.visible = true; - - // For plugins to listen out for - this.events.emit('start', this); - - // For user-land code to listen out for - this.events.emit('ready', this); - }, - - /** - * Called automatically by the SceneManager if the Game resizes. - * Dispatches an event you can respond to in your game code. - * - * @method Phaser.Scenes.Systems#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the game. - * @param {number} height - The new height of the game. - */ - resize: function (width, height) - { - this.events.emit('resize', width, height); - }, - - /** - * 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; - this.settings.visible = false; - - this.events.emit('shutdown', this); - }, - - /** - * 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 () - { - this.settings.status = CONST.DESTROYED; - - this.settings.active = false; - 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; - } - } - -}); - -module.exports = Systems; - - -/***/ }), -/* 119 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects.Graphics.Commands - */ - -module.exports = { - - ARC: 0, - BEGIN_PATH: 1, - CLOSE_PATH: 2, - FILL_RECT: 3, - LINE_TO: 4, - MOVE_TO: 5, - LINE_STYLE: 6, - FILL_STYLE: 7, - FILL_PATH: 8, - STROKE_PATH: 9, - FILL_TRIANGLE: 10, - STROKE_TRIANGLE: 11, - LINE_FX_TO: 12, - MOVE_FX_TO: 13, - SAVE: 14, - RESTORE: 15, - TRANSLATE: 16, - SCALE: 17, - ROTATE: 18 - -}; - - -/***/ }), -/* 120 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(57); -var Browser = __webpack_require__(80); -var CanvasPool = __webpack_require__(22); - -/** - * Determines the features of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.features` from within any Scene. - * - * @typedef {object} Phaser.Device.Features - * @since 3.0.0 - * - * @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. - * @property {boolean} canvas - Is canvas available? - * @property {boolean} file - Is file available? - * @property {boolean} fileSystem - Is fileSystem available? - * @property {boolean} getUserMedia - Does the device support the getUserMedia API? - * @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays) - * @property {boolean} localStorage - Is localStorage available? - * @property {boolean} pointerLock - Is Pointer Lock available? - * @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views? - * @property {boolean} vibration - Does the device support the Vibration API? - * @property {boolean} webGL - Is webGL available? - * @property {boolean} worker - Is worker available? - */ -var Features = { - - canvas: false, - canvasBitBltShift: null, - file: false, - fileSystem: false, - getUserMedia: true, - littleEndian: false, - localStorage: false, - pointerLock: false, - support32bit: false, - vibration: false, - webGL: false, - worker: false - -}; - -// Check Little or Big Endian system. -// @author Matt DesLauriers (@mattdesl) -function checkIsLittleEndian () -{ - var a = new ArrayBuffer(4); - var b = new Uint8Array(a); - var c = new Uint32Array(a); - - b[0] = 0xa1; - b[1] = 0xb2; - b[2] = 0xc3; - b[3] = 0xd4; - - if (c[0] === 0xd4c3b2a1) - { - return true; - } - - if (c[0] === 0xa1b2c3d4) - { - return false; - } - else - { - // Could not determine endianness - return null; - } -} - -function init () -{ - Features.canvas = !!window['CanvasRenderingContext2D'] || OS.cocoonJS; - - try - { - Features.localStorage = !!localStorage.getItem; - } - catch (error) - { - Features.localStorage = false; - } - - Features.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; - Features.fileSystem = !!window['requestFileSystem']; - - var isUint8 = false; - - var testWebGL = function () - { - if (window['WebGLRenderingContext']) - { - try - { - var canvas = CanvasPool.createWebGL(this); - - if (OS.cocoonJS) - { - canvas.screencanvas = false; - } - - var ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); - - var canvas2D = CanvasPool.create2D(this); - - var ctx2D = canvas2D.getContext('2d'); - - // Can't be done on a webgl context - var image = ctx2D.createImageData(1, 1); - - // Test to see if ImageData uses CanvasPixelArray or Uint8ClampedArray. - // @author Matt DesLauriers (@mattdesl) - isUint8 = image.data instanceof Uint8ClampedArray; - - CanvasPool.remove(canvas); - CanvasPool.remove(canvas2D); - - return !!ctx; - } - catch (e) - { - return false; - } - } - - return false; - }; - - Features.webGL = testWebGL(); - - Features.worker = !!window['Worker']; - - Features.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; - - navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; - - window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; - - Features.getUserMedia = Features.getUserMedia && !!navigator.getUserMedia && !!window.URL; - - // Older versions of firefox (< 21) apparently claim support but user media does not actually work - if (Browser.firefox && Browser.firefoxVersion < 21) - { - Features.getUserMedia = false; - } - - // Excludes iOS versions as they generally wrap UIWebView (eg. Safari WebKit) and it - // is safer to not try and use the fast copy-over method. - if (!OS.iOS && (Browser.ie || Browser.firefox || Browser.chrome)) - { - Features.canvasBitBltShift = true; - } - - // Known not to work - if (Browser.safari || Browser.mobileSafari) - { - Features.canvasBitBltShift = false; - } - - navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate; - - if (navigator.vibrate) - { - Features.vibration = true; - } - - if (typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined' && typeof Uint32Array !== 'undefined') - { - Features.littleEndian = checkIsLittleEndian(); - } - - Features.support32bit = ( - typeof ArrayBuffer !== 'undefined' && - typeof Uint8ClampedArray !== 'undefined' && - typeof Int32Array !== 'undefined' && - Features.littleEndian !== null && - isUint8 - ); - - return Features; -} - -module.exports = init(); - - -/***/ }), -/* 121 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} Phaser.Plugins.DefaultPlugins - * - * @property {array} Global - These are the Global Managers that are created by the Phaser.Game instance. - * @property {array} CoreScene - These are the core plugins that are installed into every Scene.Systems instance, no matter what. - * @property {array} DefaultScene - These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - */ - -var DefaultPlugins = { - - /** - * These are the Global Managers that are created by the Phaser.Game instance. - * They are referenced from Scene.Systems so that plugins can use them. - * - * @name Phaser.Plugins.Global - * @type {array} - * @since 3.0.0 - */ - Global: [ - - 'anims', - 'cache', - 'plugins', - 'registry', - 'sound', - 'textures' - - ], - - /** - * These are the core plugins that are installed into every Scene.Systems instance, no matter what. - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are created in the order in which they appear in this array and EventEmitter is always first. - * - * @name Phaser.Plugins.CoreScene - * @type {array} - * @since 3.0.0 - */ - CoreScene: [ - - 'EventEmitter', - - 'CameraManager', - 'GameObjectCreator', - 'GameObjectFactory', - 'ScenePlugin', - 'DisplayList', - 'UpdateList' - - ], - - /** - * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - * - * You can elect not to have these plugins by either creating a DefaultPlugins object as part - * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array - * and building your own bundle. - * - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are always created in the order in which they appear in the array. - * - * @name Phaser.Plugins.DefaultScene - * @type {array} - * @since 3.0.0 - */ - DefaultScene: [ - - 'CameraManager3D', - 'Clock', - 'DataManagerPlugin', - 'InputPlugin', - 'Loader', - 'TweenManager', - 'LightsPlugin' - - ] - -}; - -module.exports = DefaultPlugins; - - -/***/ }), -/* 122 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates a linear (interpolation) value over t. - * - * @function Phaser.Math.Linear - * @since 3.0.0 - * - * @param {number} p0 - The first point. - * @param {number} p1 - The second point. - * @param {float} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. - * - * @return {number} The step t% of the way between p0 and p1. - */ -var Linear = function (p0, p1, t) -{ - return (p1 - p0) * t + p0; -}; - -module.exports = Linear; - - -/***/ }), -/* 123 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var Effects = __webpack_require__(204); -var EventEmitter = __webpack_require__(9); -var Linear = __webpack_require__(122); -var Rectangle = __webpack_require__(14); -var TransformMatrix = __webpack_require__(64); -var ValueToColor = __webpack_require__(132); -var Vector2 = __webpack_require__(6); - -/** - * @typedef {object} JSONCameraBounds - * @property {number} x - The horizontal position of camera - * @property {number} y - The vertical position of camera - * @property {number} width - The width size of camera - * @property {number} height - The height size of camera - */ - -/** - * @typedef {object} JSONCamera - * - * @property {string} name - The name of the camera - * @property {number} x - The horizontal position of camera - * @property {number} y - The vertical position of camera - * @property {number} width - The width size of camera - * @property {number} height - The height size of camera - * @property {number} zoom - The zoom of camera - * @property {number} rotation - The rotation of camera - * @property {boolean} roundPixels - The round pixels st status of camera - * @property {number} scrollX - The horizontal scroll of camera - * @property {number} scrollY - The vertical scroll of camera - * @property {string} backgroundColor - The background color of camera - * @property {(JSONCameraBounds|undefined)} [bounds] - The bounds of camera - */ - -/** - * @classdesc - * A Camera. - * - * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, - * and can be positioned, rotated, zoomed and scrolled accordingly. - * - * A Camera consists of two elements: The viewport and the scroll values. - * - * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are - * created the same size as your game, but their position and size can be set to anything. This means if you - * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, - * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). - * - * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this - * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the - * viewport, and changing the viewport has no impact on the scrolling. - * - * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, - * allowing you to filter Game Objects out on a per-Camera basis. - * - * A Camera also has built-in special effects including Fade, Flash and Camera Shake. - * - * @class Camera - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Cameras.Scene2D - * @constructor - * @since 3.0.0 - * - * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. - * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. - * @param {number} width - The width of the Camera, in pixels. - * @param {number} height - The height of the Camera, in pixels. - */ -var Camera = new Class({ - - Extends: EventEmitter, - - initialize: - - function Camera (x, y, width, height) - { - EventEmitter.call(this); - - /** - * A reference to the Scene this camera belongs to. - * - * @name Phaser.Cameras.Scene2D.Camera#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene; - - /** - * The name of the Camera. This is left empty for your own use. - * - * @name Phaser.Cameras.Scene2D.Camera#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The x position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The width of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#width - * @type {number} - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#height - * @type {number} - * @since 3.0.0 - */ - this.height = height; - - /** - * Should this camera round its pixel values to integers? - * - * @name Phaser.Cameras.Scene2D.Camera#roundPixels - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.roundPixels = false; - - /** - * Is this Camera visible or not? - * - * A visible camera will render and perform input tests. - * An invisible camera will not render anything and will skip input tests. - * - * @name Phaser.Cameras.Scene2D.Camera#visible - * @type {boolean} - * @default true - * @since 3.10.0 - */ - this.visible = true; - - /** - * Is this Camera using a bounds to restrict scrolling movement? - * Set this property along with the bounds via `Camera.setBounds`. - * - * @name Phaser.Cameras.Scene2D.Camera#useBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useBounds = false; - - /** - * The bounds the camera is restrained to during scrolling. - * - * @name Phaser.Cameras.Scene2D.Camera#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); - - /** - * Does this Camera allow the Game Objects it renders to receive input events? - * - * @name Phaser.Cameras.Scene2D.Camera#inputEnabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.inputEnabled = true; - - /** - * The horizontal scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * The vertical scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * The Camera zoom value. Change this value to zoom in, or out of, a Scene. - * Set to 1 to return to the default zoom level. - * - * @name Phaser.Cameras.Scene2D.Camera#zoom - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.zoom = 1; - - /** - * The rotation of the Camera. This influences the rendering of all Game Objects visible by this camera. - * - * @name Phaser.Cameras.Scene2D.Camera#rotation - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotation = 0; - - /** - * A local transform matrix used for internal calculations. - * - * @name Phaser.Cameras.Scene2D.Camera#matrix - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @since 3.0.0 - */ - this.matrix = new TransformMatrix(1, 0, 0, 1, 0, 0); - - /** - * Does this Camera have a transparent background? - * - * @name Phaser.Cameras.Scene2D.Camera#transparent - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.transparent = true; - - /** - * The background color of this Camera. Only used if `transparent` is `false`. - * - * @name Phaser.Cameras.Scene2D.Camera#backgroundColor - * @type {Phaser.Display.Color} - * @since 3.0.0 - */ - this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); - - /** - * The Camera Fade effect handler. - * To fade this camera see the `Camera.fade` methods. - * - * @name Phaser.Cameras.Scene2D.Camera#fadeEffect - * @type {Phaser.Cameras.Scene2D.Effects.Fade} - * @since 3.5.0 - */ - this.fadeEffect = new Effects.Fade(this); - - /** - * The Camera Flash effect handler. - * To flash this camera see the `Camera.flash` method. - * - * @name Phaser.Cameras.Scene2D.Camera#flashEffect - * @type {Phaser.Cameras.Scene2D.Effects.Flash} - * @since 3.5.0 - */ - this.flashEffect = new Effects.Flash(this); - - /** - * The Camera Shake effect handler. - * To shake this camera see the `Camera.shake` method. - * - * @name Phaser.Cameras.Scene2D.Camera#shakeEffect - * @type {Phaser.Cameras.Scene2D.Effects.Shake} - * @since 3.5.0 - */ - this.shakeEffect = new Effects.Shake(this); - - /** - * Should the camera cull Game Objects before checking them for input hit tests? - * In some special cases it may be beneficial to disable this. - * - * @name Phaser.Cameras.Scene2D.Camera#disableCull - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.disableCull = false; - - /** - * A temporary array of culled objects. - * - * @name Phaser.Cameras.Scene2D.Camera#culledObjects - * @type {Phaser.GameObjects.GameObject[]} - * @default [] - * @since 3.0.0 - */ - this.culledObjects = []; - - /** - * The linear interpolation value to use when following a target. - * - * Can also be set via `setLerp` or as part of the `startFollow` call. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - * - * @name Phaser.Cameras.Scene2D.Camera#lerp - * @type {Phaser.Math.Vector2} - * @since 3.9.0 - */ - this.lerp = new Vector2(1, 1); - - /** - * The values stored in this property are subtracted from the Camera targets position, allowing you to - * offset the camera from the actual target x/y coordinates by this amount. - * Can also be set via `setFollowOffset` or as part of the `startFollow` call. - * - * @name Phaser.Cameras.Scene2D.Camera#followOffset - * @type {Phaser.Math.Vector2} - * @since 3.9.0 - */ - this.followOffset = new Vector2(); - - /** - * Internal follow target reference. - * - * @name Phaser.Cameras.Scene2D.Camera#_follow - * @type {?any} - * @private - * @default null - * @since 3.0.0 - */ - this._follow = null; - - /** - * Internal camera ID. Assigned by the Camera Manager and used in the camera pool. - * - * @name Phaser.Cameras.Scene2D.Camera#_id - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._id = 0; - }, - - /** - * Scrolls the Camera so that it is looking at the center of the Camera Bounds (if previously enabled) - * - * @method Phaser.Cameras.Scene2D.Camera#centerToBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToBounds: function () - { - if (this.useBounds) - { - this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5); - this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5); - } - - return this; - }, - - /** - * Scrolls the Camera so that it is re-centered based on its viewport size. - * - * @method Phaser.Cameras.Scene2D.Camera#centerToSize - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToSize: function () - { - this.scrollX = this.width * 0.5; - this.scrollY = this.height * 0.5; - - return this; - }, - - /** - * Takes an array of Game Objects and returns a new array featuring only those objects - * visible by this camera. - * - * @method Phaser.Cameras.Scene2D.Camera#cull - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] - * - * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. - * - * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. - */ - cull: function (renderableObjects) - { - if (this.disableCull) - { - return renderableObjects; - } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return renderableObjects; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var culledObjects = this.culledObjects; - var length = renderableObjects.length; - - determinant = 1 / determinant; - - culledObjects.length = 0; - - for (var index = 0; index < length; ++index) - { - var object = renderableObjects[index]; - - if (!object.hasOwnProperty('width') || object.parentContainer) - { - culledObjects.push(object); - continue; - } - - var objectW = object.width; - var objectH = object.height; - var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); - var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); - var tx = (objectX * mva + objectY * mvc + mve); - var ty = (objectX * mvb + objectY * mvd + mvf); - var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); - var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); - var cullW = cameraW + objectW; - var cullH = cameraH + objectH; - - if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH && - tw > -objectW && th > -objectH && tw < cullW && th < cullH) - { - culledObjects.push(object); - } - } - - return culledObjects; - }, - - /** - * Fades the Camera in from the given color over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#fadeIn - * @since 3.3.0 - * - * @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 {function} [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} This Camera instance. - */ - fadeIn: function (duration, red, green, blue, callback, context) - { - return this.fadeEffect.start(false, duration, red, green, blue, true, callback, context); - }, - - /** - * Fades the Camera out to the given color over the duration specified. - * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. - * - * @method Phaser.Cameras.Scene2D.Camera#fadeOut - * @since 3.3.0 - * - * @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 {function} [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} This Camera instance. - */ - fadeOut: function (duration, red, green, blue, callback, context) - { - return this.fadeEffect.start(true, duration, red, green, blue, true, callback, context); - }, - - /** - * Fades the Camera from the given color to transparent over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#fadeFrom - * @since 3.5.0 - * - * @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 {function} [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} This Camera instance. - */ - fadeFrom: function (duration, red, green, blue, force, callback, context) - { - return this.fadeEffect.start(false, duration, red, green, blue, force, callback, context); - }, - - /** - * Fades the Camera from transparent to the given color over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#fade - * @since 3.0.0 - * - * @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 {function} [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} This Camera instance. - */ - fade: function (duration, red, green, blue, force, callback, context) - { - return this.fadeEffect.start(true, duration, red, green, blue, force, callback, context); - }, - - /** - * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#flash - * @since 3.0.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 {function} [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} This Camera instance. - */ - flash: function (duration, red, green, blue, force, callback, context) - { - return this.flashEffect.start(duration, red, green, blue, force, callback, context); - }, - - /** - * Shakes the Camera by the given intensity over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#shake - * @since 3.0.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 {function} [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} This Camera instance. - */ - shake: function (duration, intensity, force, callback, context) - { - return this.shakeEffect.start(duration, intensity, force, callback, context); - }, - - /** - * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. - * You can optionally provide a Vector2, or similar object, to store the results in. - * - * @method Phaser.Cameras.Scene2D.Camera#getWorldPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [output,$return] - * - * @param {number} x - The x position to convert to world space. - * @param {number} y - The y position to convert to world space. - * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. - */ - getWorldPoint: function (x, y, output) - { - if (output === undefined) { output = new Vector2(); } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - output.x = x; - output.y = y; - - return output; - } - - determinant = 1 / determinant; - - var ima = mvd * determinant; - var imb = -mvb * determinant; - var imc = -mvc * determinant; - var imd = mva * determinant; - var ime = (mvc * mvf - mvd * mve) * determinant; - var imf = (mvb * mve - mva * mvf) * determinant; - - var c = Math.cos(this.rotation); - var s = Math.sin(this.rotation); - - var zoom = this.zoom; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - - var sx = x + ((scrollX * c - scrollY * s) * zoom); - var sy = y + ((scrollX * s + scrollY * c) * zoom); - - /* Apply transform to point */ - output.x = (sx * ima + sy * imc + ime); - output.y = (sx * imb + sy * imd + imf); - - return output; - }, - - /** - * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings - * so that they are ignored by this Camera. This means they will not be rendered by this Camera. - * - * @method Phaser.Cameras.Scene2D.Camera#ignore - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObject - The Game Object, or array of Game Objects, to be ignored by this Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - ignore: function (gameObject) - { - var id = this._id; - - if (Array.isArray(gameObject)) - { - for (var i = 0; i < gameObject.length; i++) - { - gameObject[i].cameraFilter |= id; - } - } - else - { - gameObject.cameraFilter |= id; - } - - return this; - }, - - /** - * Internal preRender step. - * - * @method Phaser.Cameras.Scene2D.Camera#preRender - * @protected - * @since 3.0.0 - * - * @param {number} baseScale - The base scale, as set in the Camera Manager. - * @param {number} resolution - The game resolution. - */ - preRender: function (baseScale, resolution) - { - var width = this.width; - var height = this.height; - var zoom = this.zoom * baseScale; - var matrix = this.matrix; - var originX = width / 2; - var originY = height / 2; - var follow = this._follow; - - if (follow) - { - this.scrollX = Linear(this.scrollX, (follow.x - this.followOffset.x) - originX, this.lerp.x) / zoom; - this.scrollY = Linear(this.scrollY, (follow.y - this.followOffset.y) - originY, this.lerp.y) / zoom; - } - - if (this.useBounds) - { - var bounds = this._bounds; - - var bw = Math.max(0, bounds.right - width); - var bh = Math.max(0, bounds.bottom - height); - - if (this.scrollX < bounds.x) - { - this.scrollX = bounds.x; - } - else if (this.scrollX > bw) - { - this.scrollX = bw; - } - - if (this.scrollY < bounds.y) - { - this.scrollY = bounds.y; - } - else if (this.scrollY > bh) - { - this.scrollY = bh; - } - } - - if (this.roundPixels) - { - this.scrollX = Math.round(this.scrollX); - this.scrollY = Math.round(this.scrollY); - } - - matrix.loadIdentity(); - matrix.scale(resolution, resolution); - matrix.translate(this.x + originX, this.y + originY); - matrix.rotate(this.rotation); - matrix.scale(zoom, zoom); - matrix.translate(-originX, -originY); - - this.shakeEffect.preRender(); - }, - - /** - * If this Camera has previously had movement bounds set on it, this will remove them. - * - * @method Phaser.Cameras.Scene2D.Camera#removeBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - removeBounds: function () - { - this.useBounds = false; - - this._bounds.setEmpty(); - - return this; - }, - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setAngle - * @since 3.0.0 - * - * @param {number} [value=0] - The cameras angle of rotation, given in degrees. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setAngle: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = DegToRad(value); - - return this; - }, - - /** - * Sets the linear interpolation value to use when following a target. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - * - * @method Phaser.Cameras.Scene2D.Camera#setLerp - * @since 3.9.0 - * - * @param {number} [x=1] - The amount added to the horizontal linear interpolation of the follow target. - * @param {number} [y=1] - The amount added to the vertical linear interpolation of the follow target. - * - * @return {this} This Camera instance. - */ - setLerp: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.lerp.set(x, y); - - return this; - }, - - /** - * Sets the horizontal and vertical offset of the camera from its follow target. - * The values are subtracted from the targets position during the Cameras update step. - * - * @method Phaser.Cameras.Scene2D.Camera#setFollowOffset - * @since 3.9.0 - * - * @param {number} [x=0] - The horizontal offset from the camera follow target.x position. - * @param {number} [y=0] - The vertical offset from the camera follow target.y position. - * - * @return {this} This Camera instance. - */ - setFollowOffset: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - this.followOffset.set(x, y); - - return this; - }, - - /** - * Sets the background color for this Camera. - * - * By default a Camera has a transparent background but it can be given a solid color, with any level - * of transparency, via this method. - * - * The color value can be specified using CSS color notation, hex or numbers. - * - * @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor - * @since 3.0.0 - * - * @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBackgroundColor: function (color) - { - if (color === undefined) { color = 'rgba(0,0,0,0)'; } - - this.backgroundColor = ValueToColor(color); - - this.transparent = (this.backgroundColor.alpha === 0); - - return this; - }, - - /** - * Set the world bounds for this Camera. - * - * A Camera bounds controls where the camera can scroll to within the world. It does not limit - * rendering of the camera, or placement of the viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setBounds - * @since 3.0.0 - * - * @param {integer} x - The top-left x coordinate of the bounds. - * @param {integer} y - The top-left y coordinate of the bounds. - * @param {integer} width - The width of the bounds, in pixels. - * @param {integer} height - The height of the bounds, in pixels. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBounds: function (x, y, width, height) - { - this._bounds.setTo(x, y, width, height); - - this.useBounds = true; - - return this; - }, - - /** - * Sets the name of this Camera. - * This value is for your own use and isn't used internally. - * - * @method Phaser.Cameras.Scene2D.Camera#setName - * @since 3.0.0 - * - * @param {string} [value=''] - The name of the Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setName: function (value) - { - if (value === undefined) { value = ''; } - - this.name = value; - - return this; - }, - - /** - * Set the position of the Camera viewport within the game. - * - * This does not change where the camera is 'looking'. See `setScroll` to control that. - * - * @method Phaser.Cameras.Scene2D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the Camera viewport. - * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setRotation - * @since 3.0.0 - * - * @param {number} [value=0] - The rotation of the Camera, in radians. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRotation: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = value; - - return this; - }, - - /** - * Should the Camera round pixel values to whole integers when scrolling? - * In some types of game this is required to prevent sub-pixel aliasing. - * - * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels - * @since 3.0.0 - * - * @param {boolean} value - `true` to round Camera pixels, `false` to not. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRoundPixels: function (value) - { - this.roundPixels = value; - - return this; - }, - - /** - * Sets the Scene the Camera is bound to. - * - * @method Phaser.Cameras.Scene2D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene the camera is bound to. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * Set the position of where the Camera is looking within the game. - * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. - * Use this method, or the scroll properties, to move your camera around the game world. - * - * This does not change where the camera viewport is placed. See `setPosition` to control that. - * - * @method Phaser.Cameras.Scene2D.Camera#setScroll - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the Camera in the game world. - * @param {number} [y=x] - The y coordinate of the Camera in the game world. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScroll: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollX = x; - this.scrollY = y; - - return this; - }, - - /** - * Set the size of the Camera viewport. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setSize - * @since 3.0.0 - * - * @param {integer} width - The width of the Camera viewport. - * @param {integer} [height=width] - The height of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * This method sets the position and size of the Camera viewport in a single call. - * - * If you're trying to change where the Camera is looking at in your game, then see - * the method `Camera.setScroll` instead. This method is for changing the viewport - * itself, not what the camera can see. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the Camera viewport. - * @param {number} y - The top-left y coordinate of the Camera viewport. - * @param {integer} width - The width of the Camera viewport. - * @param {integer} [height=width] - The height of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setViewport: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * Set the zoom value of the Camera. - * - * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. - * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. - * - * A value of 1 means 'no zoom' and is the default. - * - * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setZoom - * @since 3.0.0 - * - * @param {float} [value=1] - The zoom value of the Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setZoom: function (value) - { - if (value === undefined) { value = 1; } - - this.zoom = value; - - return this; - }, - - /** - * Sets the visibility of this Camera. - * - * An invisible Camera will skip rendering and input tests of everything it can see. - * - * @method Phaser.Cameras.Scene2D.Camera#setVisible - * @since 3.10.0 - * - * @param {boolean} value - The visible state of the Camera. - * - * @return {this} This Camera instance. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * Sets the Camera to follow a Game Object. - * - * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object - * in its center. - * - * You can set the linear interpolation value used in the follow code. - * Use low lerp values (such as 0.1) to automatically smooth the camera motion. - * - * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel - * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to - * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom - * value on the camera. So be sure to keep the camera zoom to integers. - * - * @method Phaser.Cameras.Scene2D.Camera#startFollow - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. - * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? - * @param {float} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. - * @param {float} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. - * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. - * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. - * - * @return {this} This Camera instance. - */ - startFollow: function (target, roundPixels, lerpX, lerpY, offsetX, offsetY) - { - if (roundPixels === undefined) { roundPixels = false; } - if (lerpX === undefined) { lerpX = 1; } - if (lerpY === undefined) { lerpY = lerpX; } - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = offsetX; } - - this._follow = target; - - this.roundPixels = roundPixels; - - lerpX = Clamp(lerpX, 0, 1); - lerpY = Clamp(lerpY, 0, 1); - - this.lerp.set(lerpX, lerpY); - - this.followOffset.set(offsetX, offsetY); - - // Move the camera there immediately, to avoid a large lerp during preUpdate - var zoom = this.zoom; - var originX = this.width / 2; - var originY = this.height / 2; - - this.scrollX = (target.x - offsetX - originX) / zoom; - this.scrollY = (target.y - offsetY - originY) / zoom; - - return this; - }, - - /** - * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. - * - * @method Phaser.Cameras.Scene2D.Camera#stopFollow - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - stopFollow: function () - { - this._follow = null; - - return this; - }, - - /** - * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. - * - * @method Phaser.Cameras.Scene2D.Camera#toJSON - * @since 3.0.0 - * - * @return {JSONCamera} A well-formed object suitable for conversion to JSON. - */ - toJSON: function () - { - var output = { - name: this.name, - x: this.x, - y: this.y, - width: this.width, - height: this.height, - zoom: this.zoom, - rotation: this.rotation, - roundPixels: this.roundPixels, - scrollX: this.scrollX, - scrollY: this.scrollY, - backgroundColor: this.backgroundColor.rgba - }; - - if (this.useBounds) - { - output['bounds'] = { - x: this._bounds.x, - y: this._bounds.y, - width: this._bounds.width, - height: this._bounds.height - }; - } - - return output; - }, - - /** - * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to - * remove the fade. - * - * @method Phaser.Cameras.Scene2D.Camera#resetFX - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - resetFX: function () - { - this.shakeEffect.reset(); - this.flashEffect.reset(); - this.fadeEffect.reset(); - - return this; - }, - - /** - * Internal method called automatically by the Camera Manager. - * - * @method Phaser.Cameras.Scene2D.Camera#update - * @protected - * @since 3.0.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.visible) - { - this.shakeEffect.update(time, delta); - this.flashEffect.update(time, delta); - this.fadeEffect.update(time, delta); - } - }, - - /** - * This event is fired when a camera is destroyed by the Camera Manager. - * - * @event CameraDestroyEvent - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that was destroyed. - */ - - /** - * Destroys this Camera instance. You rarely need to call this directly. - * - * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as - * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. - * - * @method Phaser.Cameras.Scene2D.Camera#destroy - * @fires CameraDestroyEvent - * @since 3.0.0 - */ - destroy: function () - { - this.emit('cameradestroy', this); - - this.removeAllListeners(); - - this.resetFX(); - - this.matrix.destroy(); - - this.culledObjects = []; - - this._follow = null; - - this._bounds = null; - - this.scene = null; - }, - - /** - * The x position of the center of the Camera's viewport, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#centerX - * @type {number} - * @readOnly - * @since 3.10.0 - */ - centerX: { - - get: function () - { - return this.x + (0.5 * this.width); - } - - }, - - /** - * The y position of the center of the Camera's viewport, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#centerY - * @type {number} - * @readOnly - * @since 3.10.0 - */ - centerY: { - - get: function () - { - return this.y + (0.5 * this.height); - } - - } - -}); - -module.exports = Camera; - - -/***/ }), -/* 124 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback EachMapCallback - * @generic E - [entry] - * - * @param {string} key - [description] - * @param {*} entry - [description] - * - * @return {?boolean} [description] - */ - -/** - * @classdesc - * The keys of a Map can be arbitrary values. - * var map = new Map([ - * [ 1, 'one' ], - * [ 2, 'two' ], - * [ 3, 'three' ] - * ]); - * - * @class Map - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic K - * @generic V - * @genericUse {V[]} - [elements] - * - * @param {Array.<*>} elements - [description] - */ -var Map = new Class({ - - initialize: - - function Map (elements) - { - /** - * [description] - * - * @genericUse {Object.} - [$type] - * - * @name Phaser.Structs.Map#entries - * @type {Object.} - * @default {} - * @since 3.0.0 - */ - this.entries = {}; - - /** - * [description] - * - * @name Phaser.Structs.Map#size - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.size = 0; - - if (Array.isArray(elements)) - { - for (var i = 0; i < elements.length; i++) - { - this.set(elements[i][0], elements[i][1]); - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#set - * @since 3.0.0 - * - * @genericUse {K} - [key] - * @genericUse {V} - [value] - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @param {string} key - [description] - * @param {*} value - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - set: function (key, value) - { - if (!this.has(key)) - { - this.entries[key] = value; - this.size++; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#get - * @since 3.0.0 - * - * @genericUse {K} - [key] - * @genericUse {V} - [$return] - * - * @param {string} key - [description] - * - * @return {*} [description] - */ - get: function (key) - { - if (this.has(key)) - { - return this.entries[key]; - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#getArray - * @since 3.0.0 - * - * @genericUse {V[]} - [$return] - * - * @return {Array.<*>} [description] - */ - getArray: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#has - * @since 3.0.0 - * - * @genericUse {K} - [key] - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (key) - { - return (this.entries.hasOwnProperty(key)); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#delete - * @since 3.0.0 - * - * @genericUse {K} - [key] - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @param {string} key - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - delete: function (key) - { - if (this.has(key)) - { - delete this.entries[key]; - this.size--; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#clear - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @return {Phaser.Structs.Map} This Map object. - */ - clear: function () - { - Object.keys(this.entries).forEach(function (prop) - { - delete this.entries[prop]; - - }, this); - - this.size = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#keys - * @since 3.0.0 - * - * @genericUse {K[]} - [$return] - * - * @return {string[]} [description] - */ - keys: function () - { - return Object.keys(this.entries); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#values - * @since 3.0.0 - * - * @genericUse {V[]} - [$return] - * - * @return {Array.<*>} [description] - */ - values: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#dump - * @since 3.0.0 - */ - dump: function () - { - var entries = this.entries; - - // eslint-disable-next-line no-console - console.group('Map'); - - for (var key in entries) - { - console.log(key, entries[key]); - } - - // eslint-disable-next-line no-console - console.groupEnd(); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#each - * @since 3.0.0 - * - * @genericUse {EachMapCallback.} - [callback] - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @param {EachMapCallback} callback - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - each: function (callback) - { - var entries = this.entries; - - for (var key in entries) - { - if (callback(key, entries[key]) === false) - { - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#contains - * @since 3.0.0 - * - * @genericUse {V} - [value] - * - * @param {*} value - [description] - * - * @return {boolean} [description] - */ - contains: function (value) - { - var entries = this.entries; - - for (var key in entries) - { - if (entries[key] === value) - { - return true; - } - } - - return false; - }, - - /** - * Merges all new keys from the given Map into this one - * If it encounters a key that already exists it will be skipped - * unless override = true. - * - * @method Phaser.Structs.Map#merge - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Map.} - [map,$return] - * - * @param {Phaser.Structs.Map} map - [description] - * @param {boolean} [override=false] - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - merge: function (map, override) - { - if (override === undefined) { override = false; } - - var local = this.entries; - var source = map.entries; - - for (var key in source) - { - if (local.hasOwnProperty(key) && override) - { - local[key] = source[key]; - } - else - { - this.set(key, source[key]); - } - } - - return this; - } - -}); - -module.exports = Map; - - -/***/ }), -/* 125 */, -/* 126 */, -/* 127 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetAdvancedValue = __webpack_require__(10); - -/** - * Adds an Animation component to a Sprite and populates it based on the given config. - * - * @function Phaser.GameObjects.BuildGameObjectAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - The sprite to add an Animation component to. - * @param {object} config - The animation config. - * - * @return {Phaser.GameObjects.Sprite} The updated Sprite. - */ -var BuildGameObjectAnimation = function (sprite, config) -{ - var animConfig = GetAdvancedValue(config, 'anims', null); - - if (animConfig === null) - { - return sprite; - } - - if (typeof animConfig === 'string') - { - // { anims: 'key' } - sprite.anims.play(animConfig); - } - else if (typeof animConfig === 'object') - { - // { anims: { - // key: string - // startFrame: [string|integer] - // delay: [float] - // repeat: [integer] - // repeatDelay: [float] - // yoyo: [boolean] - // play: [boolean] - // delayedPlay: [boolean] - // } - // } - - var anims = sprite.anims; - - var key = GetAdvancedValue(animConfig, 'key', undefined); - var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); - - var delay = GetAdvancedValue(animConfig, 'delay', 0); - var repeat = GetAdvancedValue(animConfig, 'repeat', 0); - var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); - var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); - - var play = GetAdvancedValue(animConfig, 'play', false); - var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); - - anims.delay(delay); - anims.repeat(repeat); - anims.repeatDelay(repeatDelay); - anims.yoyo(yoyo); - - if (play) - { - anims.play(key, startFrame); - } - else if (delayedPlay > 0) - { - anims.delayedPlay(delayedPlay, key, startFrame); - } - else - { - anims.load(key); - } - } - - return sprite; -}; - -module.exports = BuildGameObjectAnimation; - - -/***/ }), -/* 128 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Extend = __webpack_require__(17); - -/** - * @classdesc - * A Frame is a section of a Texture. - * - * @class Frame - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. - * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. - * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. - * @param {number} x - The x coordinate of the top-left of this Frame. - * @param {number} y - The y coordinate of the top-left of this Frame. - * @param {number} width - The width of this Frame. - * @param {number} height - The height of this Frame. - */ -var Frame = new Class({ - - initialize: - - function Frame (texture, name, sourceIndex, x, y, width, height) - { - /** - * The Texture this Frame is a part of. - * - * @name Phaser.Textures.Frame#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - this.texture = texture; - - /** - * The name of this Frame. - * The name is unique within the Texture. - * - * @name Phaser.Textures.Frame#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The TextureSource this Frame is part of. - * - * @name Phaser.Textures.Frame#source - * @type {Phaser.Textures.TextureSource} - * @since 3.0.0 - */ - this.source = texture.source[sourceIndex]; - - /** - * The index of the TextureSource in the Texture sources array. - * - * @name Phaser.Textures.Frame#sourceIndex - * @type {integer} - * @since 3.0.0 - */ - this.sourceIndex = sourceIndex; - - /** - * X position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutX - * @type {integer} - * @since 3.0.0 - */ - this.cutX; - - /** - * Y position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutY - * @type {integer} - * @since 3.0.0 - */ - this.cutY; - - /** - * The width of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutWidth - * @type {integer} - * @since 3.0.0 - */ - this.cutWidth; - - /** - * The height of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutHeight - * @type {integer} - * @since 3.0.0 - */ - this.cutHeight; - - /** - * The X rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#x - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The Y rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#y - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The rendering width of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#width - * @type {integer} - * @since 3.0.0 - */ - this.width; - - /** - * The rendering height of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#height - * @type {integer} - * @since 3.0.0 - */ - this.height; - - /** - * Half the width, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfWidth - * @type {integer} - * @since 3.0.0 - */ - this.halfWidth; - - /** - * Half the height, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfHeight - * @type {integer} - * @since 3.0.0 - */ - this.halfHeight; - - /** - * The x center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerX - * @type {integer} - * @since 3.0.0 - */ - this.centerX; - - /** - * The y center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerY - * @type {integer} - * @since 3.0.0 - */ - this.centerY; - - /** - * The horizontal pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotX = 0; - - /** - * The vertical pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotY = 0; - - /** - * Does this Frame have a custom pivot point? - * - * @name Phaser.Textures.Frame#customPivot - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customPivot = false; - - /** - * **CURRENTLY UNSUPPORTED** - * - * Is this frame is rotated or not in the Texture? - * Rotation allows you to use rotated frames in texture atlas packing. - * It has nothing to do with Sprite rotation. - * - * @name Phaser.Textures.Frame#rotated - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rotated = false; - - /** - * Over-rides the Renderer setting. - * -1 = use Renderer Setting - * 0 = No rounding - * 1 = Round - * - * @name Phaser.Textures.Frame#autoRound - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.autoRound = -1; - - /** - * Any Frame specific custom data can be stored here. - * - * @name Phaser.Textures.Frame#customData - * @type {object} - * @since 3.0.0 - */ - this.customData = {}; - - /** - * The un-modified source frame, trim and UV data. - * - * @name Phaser.Textures.Frame#data - * @type {object} - * @private - * @since 3.0.0 - */ - this.data = { - cut: { - x: 0, - y: 0, - w: 0, - h: 0, - r: 0, - b: 0 - }, - trim: false, - sourceSize: { - w: 0, - h: 0 - }, - spriteSourceSize: { - x: 0, - y: 0, - w: 0, - h: 0 - }, - uvs: { - x0: 0, - y0: 0, - x1: 0, - y1: 0, - x2: 0, - y2: 0, - x3: 0, - y3: 0 - }, - radius: 0, - drawImage: { - sx: 0, - sy: 0, - sWidth: 0, - sHeight: 0, - dWidth: 0, - dHeight: 0 - } - }; - - this.setSize(width, height, x, y); - }, - - /** - * Sets the width, height, x and y of this Frame. - * - * This is called automatically by the constructor - * and should rarely be changed on-the-fly. - * - * @method Phaser.Textures.Frame#setSize - * @since 3.7.0 - * - * @param {integer} width - The width of the frame before being trimmed. - * @param {integer} height - The height of the frame before being trimmed. - * @param {integer} [x=0] - The x coordinate of the top-left of this Frame. - * @param {integer} [y=0] - The y coordinate of the top-left of this Frame. - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - setSize: function (width, height, x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - this.cutX = x; - this.cutY = y; - this.cutWidth = width; - this.cutHeight = height; - - this.width = width; - this.height = height; - - this.halfWidth = Math.floor(width * 0.5); - this.halfHeight = Math.floor(height * 0.5); - - this.centerX = Math.floor(width / 2); - this.centerY = Math.floor(height / 2); - - var data = this.data; - var cut = data.cut; - - cut.x = x; - cut.y = y; - cut.w = width; - cut.h = height; - cut.r = x + width; - cut.b = y + height; - - data.sourceSize.w = width; - data.sourceSize.h = height; - - data.spriteSourceSize.w = width; - data.spriteSourceSize.h = height; - - data.radius = 0.5 * Math.sqrt(width * width + height * height); - - var drawImage = data.drawImage; - - drawImage.sx = x; - drawImage.sy = y; - drawImage.sWidth = width; - drawImage.sHeight = height; - drawImage.dWidth = width; - drawImage.dHeight = height; - - return this.updateUVs(); - }, - - /** - * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. - * - * @method Phaser.Textures.Frame#setTrim - * @since 3.0.0 - * - * @param {number} actualWidth - The width of the frame before being trimmed. - * @param {number} actualHeight - The height of the frame before being trimmed. - * @param {number} destX - The destination X position of the trimmed frame for display. - * @param {number} destY - The destination Y position of the trimmed frame for display. - * @param {number} destWidth - The destination width of the trimmed frame for display. - * @param {number} destHeight - The destination height of the trimmed frame for display. - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) - { - var data = this.data; - var ss = data.spriteSourceSize; - - // Store actual values - - data.trim = true; - - data.sourceSize.w = actualWidth; - data.sourceSize.h = actualHeight; - - ss.x = destX; - ss.y = destY; - ss.w = destWidth; - ss.h = destHeight; - - // Adjust properties - this.x = destX; - this.y = destY; - - this.width = destWidth; - this.height = destHeight; - - this.halfWidth = destWidth * 0.5; - this.halfHeight = destHeight * 0.5; - - this.centerX = Math.floor(destWidth / 2); - this.centerY = Math.floor(destHeight / 2); - - return this.updateUVs(); - }, - - /** - * Updates the internal WebGL UV cache and the drawImage cache. - * - * @method Phaser.Textures.Frame#updateUVs - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVs: function () - { - var cx = this.cutX; - var cy = this.cutY; - var cw = this.cutWidth; - var ch = this.cutHeight; - - // Canvas data - - var cd = this.data.drawImage; - - cd.sWidth = cw; - cd.sHeight = ch; - cd.dWidth = cw; - cd.dHeight = ch; - - // WebGL data - - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x0 = cx / tw; - uvs.y0 = cy / th; - - uvs.x1 = cx / tw; - uvs.y1 = (cy + ch) / th; - - uvs.x2 = (cx + cw) / tw; - uvs.y2 = (cy + ch) / th; - - uvs.x3 = (cx + cw) / tw; - uvs.y3 = cy / th; - - return this; - }, - - /** - * Updates the internal WebGL UV cache. - * - * @method Phaser.Textures.Frame#updateUVsInverted - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVsInverted: function () - { - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x3 = (this.cutX + this.cutHeight) / tw; - uvs.y3 = (this.cutY + this.cutWidth) / th; - - uvs.x2 = this.cutX / tw; - uvs.y2 = (this.cutY + this.cutWidth) / th; - - uvs.x1 = this.cutX / tw; - uvs.y1 = this.cutY / th; - - uvs.x0 = (this.cutX + this.cutHeight) / tw; - uvs.y0 = this.cutY / th; - - return this; - }, - - /** - * Clones this Frame into a new Frame object. - * - * @method Phaser.Textures.Frame#clone - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} A clone of this Frame. - */ - clone: function () - { - var clone = new Frame(this.texture, this.name, this.sourceIndex); - - clone.cutX = this.cutX; - clone.cutY = this.cutY; - clone.cutWidth = this.cutWidth; - clone.cutHeight = this.cutHeight; - - clone.x = this.x; - clone.y = this.y; - - clone.width = this.width; - clone.height = this.height; - - clone.halfWidth = this.halfWidth; - clone.halfHeight = this.halfHeight; - - clone.centerX = this.centerX; - clone.centerY = this.centerY; - - clone.rotated = this.rotated; - - clone.data = Extend(true, clone.data, this.data); - - clone.updateUVs(); - - return clone; - }, - - /** - * Destroys this Frames references. - * - * @method Phaser.Textures.Frame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.texture = null; - - this.source = null; - }, - - /** - * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realWidth - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realWidth: { - - get: function () - { - return this.data.sourceSize.w; - } - - }, - - /** - * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realHeight - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realHeight: { - - get: function () - { - return this.data.sourceSize.h; - } - - }, - - /** - * The UV data for this Frame. - * - * @name Phaser.Textures.Frame#uvs - * @type {object} - * @readOnly - * @since 3.0.0 - */ - uvs: { - - get: function () - { - return this.data.uvs; - } - - }, - - /** - * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) - * - * @name Phaser.Textures.Frame#radius - * @type {number} - * @readOnly - * @since 3.0.0 - */ - radius: { - - get: function () - { - return this.data.radius; - } - - }, - - /** - * Is the Frame trimmed or not? - * - * @name Phaser.Textures.Frame#trimmed - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - trimmed: { - - get: function () - { - return this.data.trim; - } - - }, - - /** - * The Canvas drawImage data object. - * - * @name Phaser.Textures.Frame#canvasData - * @type {object} - * @readOnly - * @since 3.0.0 - */ - canvasData: { - - get: function () - { - return this.data.drawImage; - } - - } - -}); - -module.exports = Frame; - - -/***/ }), -/* 129 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var ModelViewProjection = __webpack_require__(202); -var ShaderSourceFS = __webpack_require__(526); -var ShaderSourceVS = __webpack_require__(525); -var Utils = __webpack_require__(27); -var WebGLPipeline = __webpack_require__(84); - -/** - * @classdesc - * TextureTintPipeline implements the rendering infrastructure - * for displaying textured objects - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class TextureTintPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var TextureTintPipeline = new Class({ - - Extends: WebGLPipeline, - - Mixins: [ - ModelViewProjection - ], - - initialize: - - function TextureTintPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 6 * 2000), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2 + - Float32Array.BYTES_PER_ELEMENT * 2 + - Uint8Array.BYTES_PER_ELEMENT * 4), - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - }, - { - name: 'inTexCoord', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: Float32Array.BYTES_PER_ELEMENT * 2 - }, - { - name: 'inTint', - size: 4, - type: config.renderer.gl.UNSIGNED_BYTE, - normalized: true, - offset: Float32Array.BYTES_PER_ELEMENT * 4 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewU32 - * @type {Uint32Array} - * @since 3.0.0 - */ - this.vertexViewU32 = new Uint32Array(this.vertexData); - - /** - * Size of the batch. - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#maxQuads - * @type {integer} - * @default 2000 - * @since 3.0.0 - */ - this.maxQuads = 2000; - - /** - * Collection of batch information - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batches - * @type {array} - * @since 3.1.0 - */ - this.batches = []; - - this.mvpInit(); - }, - - /** - * Assigns a texture to the current batch. If a texture is already set it creates - * a new batch object. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#setTexture2D - * @since 3.1.0 - * - * @param {WebGLTexture} texture - WebGLTexture that will be assigned to the current batch. - * @param {integer} textureUnit - Texture unit to which the texture needs to be bound. - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - setTexture2D: function (texture, unit) - { - if (!texture) - { - return this; - } - - var batches = this.batches; - - if (batches.length === 0) - { - this.pushBatch(); - } - - var batch = batches[batches.length - 1]; - - if (unit > 0) - { - if (batch.textures[unit - 1] && - batch.textures[unit - 1] !== texture) - { - this.pushBatch(); - } - - batches[batches.length - 1].textures[unit - 1] = texture; - } - else - { - if (batch.texture !== null && - batch.texture !== texture) - { - this.pushBatch(); - } - - batches[batches.length - 1].texture = texture; - } - - return this; - }, - - /** - * Creates a new batch object and pushes it to a batch array. - * The batch object contains information relevant to the current - * vertex batch like the offset in the vertex buffer, vertex count and - * the textures used by that batch. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#pushBatch - * @since 3.1.0 - */ - pushBatch: function () - { - var batch = { - first: this.vertexCount, - texture: null, - textures: [] - }; - - this.batches.push(batch); - }, - - /** - * Binds, uploads resources and processes all batches generating draw calls. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#flush - * @since 3.1.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This Pipeline. - */ - flush: function () - { - if (this.flushLocked) - { - return this; - } - - this.flushLocked = true; - - var gl = this.gl; - var renderer = this.renderer; - var vertexCount = this.vertexCount; - var topology = this.topology; - var vertexSize = this.vertexSize; - var batches = this.batches; - var batchCount = batches.length; - var batchVertexCount = 0; - var batch = null; - var batchNext; - var textureIndex; - var nTexture; - - if (batchCount === 0 || vertexCount === 0) - { - this.flushLocked = false; - return this; - } - - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); - - for (var index = 0; index < batches.length - 1; ++index) - { - batch = batches[index]; - batchNext = batches[index + 1]; - - if (batch.textures.length > 0) - { - for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) - { - nTexture = batch.textures[textureIndex]; - - if (nTexture) - { - renderer.setTexture2D(nTexture, 1 + textureIndex); - } - } - - gl.activeTexture(gl.TEXTURE0); - } - - batchVertexCount = batchNext.first - batch.first; - - if (batch.texture === null || batchVertexCount <= 0) { continue; } - - renderer.setTexture2D(batch.texture, 0); - gl.drawArrays(topology, batch.first, batchVertexCount); - } - - // Left over data - batch = batches[batches.length - 1]; - - if (batch.textures.length > 0) - { - for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) - { - nTexture = batch.textures[textureIndex]; - - if (nTexture) - { - renderer.setTexture2D(nTexture, 1 + textureIndex); - } - } - - gl.activeTexture(gl.TEXTURE0); - } - - batchVertexCount = vertexCount - batch.first; - - if (batch.texture && batchVertexCount > 0) - { - renderer.setTexture2D(batch.texture, 0); - gl.drawArrays(topology, batch.first, batchVertexCount); - } - - this.vertexCount = 0; - batches.length = 0; - this.pushBatch(); - this.flushLocked = false; - - return this; - }, - - /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - - this.mvpUpdate(); - - if (this.batches.length === 0) - { - this.pushBatch(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); - return this; - }, - - /** - * Renders immediately a static tilemap. This function won't use - * the batching functionality of the pipeline. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawStaticTilemapLayer: function (tilemap) - { - if (tilemap.vertexCount > 0) - { - var pipelineVertexBuffer = this.vertexBuffer; - var gl = this.gl; - var renderer = this.renderer; - var frame = tilemap.tileset.image.get(); - - if (renderer.currentPipeline && - renderer.currentPipeline.vertexCount > 0) - { - renderer.flush(); - } - - this.vertexBuffer = tilemap.vertexBuffer; - renderer.setPipeline(this); - renderer.setTexture2D(frame.source.glTexture, 0); - gl.drawArrays(this.topology, 0, tilemap.vertexCount); - this.vertexBuffer = pipelineVertexBuffer; - } - - this.viewIdentity(); - this.modelIdentity(); - }, - - /** - * Renders contents of a ParticleEmitterManager. It'll batch all particles if possible. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawEmitterManager: function (emitterManager, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var roundPixels = this.renderer.config.roundPixels; - var emitters = emitterManager.emitters.list; - var emitterCount = emitters.length; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var renderer = this.renderer; - var maxQuads = this.maxQuads; - var cameraScrollX = camera.scrollX; - var cameraScrollY = camera.scrollY; - var cameraMatrix = camera.matrix.matrix; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var sin = Math.sin; - var cos = Math.cos; - var vertexComponentCount = this.vertexComponentCount; - var vertexCapacity = this.vertexCapacity; - var texture = emitterManager.defaultFrame.source.glTexture; - var pca, pcb, pcc, pcd, pce, pcf; - var pma, pmb, pmc, pmd, pme, pmf; - - if (parentMatrix) - { - pma = parentMatrix[0]; - pmb = parentMatrix[1]; - pmc = parentMatrix[2]; - pmd = parentMatrix[3]; - pme = parentMatrix[4]; - pmf = parentMatrix[5]; - } - - this.setTexture2D(texture, 0); - - for (var emitterIndex = 0; emitterIndex < emitterCount; ++emitterIndex) - { - var emitter = emitters[emitterIndex]; - var particles = emitter.alive; - var aliveLength = particles.length; - var batchCount = Math.ceil(aliveLength / maxQuads); - var particleOffset = 0; - var scrollX = cameraScrollX * emitter.scrollFactorX; - var scrollY = cameraScrollY * emitter.scrollFactorY; - - if (parentMatrix) - { - var cse = -scrollX; - var csf = -scrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - pca = pma * cma + pmb * cmc; - pcb = pma * cmb + pmb * cmd; - pcc = pmc * cma + pmd * cmc; - pcd = pmc * cmb + pmd * cmd; - pce = pme * cma + pmf * cmc + pse; - pcf = pme * cmb + pmf * cmd + psf; - - cma = pca; - cmb = pcb; - cmc = pcc; - cmd = pcd; - cme = pce; - cmf = pcf; - - scrollX = 0.0; - scrollY = 0.0; - } - - if (!emitter.visible || aliveLength === 0) - { - continue; - } - - renderer.setBlendMode(emitter.blendMode); - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - - for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) - { - var batchSize = Math.min(aliveLength, maxQuads); - - for (var index = 0; index < batchSize; ++index) - { - var particle = particles[particleOffset + index]; - - if (particle.alpha <= 0) - { - continue; - } - - var frame = particle.frame; - var uvs = frame.uvs; - var x = -(frame.halfWidth); - var y = -(frame.halfHeight); - var color = particle.color; - var xw = x + frame.width; - var yh = y + frame.height; - var sr = sin(particle.rotation); - var cr = cos(particle.rotation); - var sra = cr * particle.scaleX; - var srb = sr * particle.scaleX; - var src = -sr * particle.scaleY; - var srd = cr * particle.scaleY; - var sre = particle.x - scrollX; - var srf = particle.y - scrollY; - var mva = sra * cma + srb * cmc; - var mvb = sra * cmb + srb * cmd; - var mvc = src * cma + srd * cmc; - var mvd = src * cmb + srd * cmd; - var mve = sre * cma + srf * cmc + cme; - var mvf = sre * cmb + srf * cmd + cmf; - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = this.vertexCount * vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = color; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = color; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = color; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = color; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = color; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = color; - - this.vertexCount += 6; - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - - } - - particleOffset += batchSize; - aliveLength -= batchSize; - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - } - } - - this.setTexture2D(texture, 0); - }, - - /** - * Batches blitter game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawBlitter: function (blitter, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var list = blitter.getRenderList(); - var length = list.length; - var cameraMatrix = camera.matrix.matrix; - var a = cameraMatrix[0]; - var b = cameraMatrix[1]; - var c = cameraMatrix[2]; - var d = cameraMatrix[3]; - var e = cameraMatrix[4]; - var f = cameraMatrix[5]; - var cameraScrollX = camera.scrollX * blitter.scrollFactorX; - var cameraScrollY = camera.scrollY * blitter.scrollFactorY; - var batchCount = Math.ceil(length / this.maxQuads); - var batchOffset = 0; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * a + csf * c + e; - var psf = cse * b + csf * d + f; - var pca = pma * a + pmb * c; - var pcb = pma * b + pmb * d; - var pcc = pmc * a + pmd * c; - var pcd = pmc * b + pmd * d; - var pce = pme * a + pmf * c + pse; - var pcf = pme * b + pmf * d + psf; - - a = pca; - b = pcb; - c = pcc; - d = pcd; - e = pce; - f = pcf; - - cameraScrollX = 0.0; - cameraScrollY = 0.0; - } - - var blitterX = blitter.x - cameraScrollX; - var blitterY = blitter.y - cameraScrollY; - - var prevTextureSourceIndex; - - for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) - { - var batchSize = Math.min(length, this.maxQuads); - - for (var index = 0; index < batchSize; ++index) - { - var bob = list[batchOffset + index]; - var frame = bob.frame; - var alpha = bob.alpha; - - if (alpha === 0) - { - // Nothing to see here, moving on ... - continue; - } - - var tint = getTint(0xffffff, alpha); - var uvs = frame.uvs; - var flipX = bob.flipX; - var flipY = bob.flipY; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = blitterX + bob.x + frame.x + (frame.width * ((flipX) ? 1.0 : 0.0)); - var y = blitterY + bob.y + frame.y + (frame.height * ((flipY) ? 1.0 : 0.0)); - var xw = x + width; - var yh = y + height; - var tx0 = x * a + y * c + e; - var ty0 = x * b + y * d + f; - var tx1 = xw * a + yh * c + e; - var ty1 = xw * b + yh * d + f; - - // Bind texture only if the Texture Source is different from before - if (frame.sourceIndex !== prevTextureSourceIndex) - { - this.setTexture2D(frame.texture.source[frame.sourceIndex].glTexture, 0); - - prevTextureSourceIndex = frame.sourceIndex; - } - - var vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = tint; - vertexViewF32[vertexOffset + 5] = tx0; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = tint; - vertexViewF32[vertexOffset + 10] = tx1; - vertexViewF32[vertexOffset + 11] = ty1; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = tint; - vertexViewF32[vertexOffset + 20] = tx1; - vertexViewF32[vertexOffset + 21] = ty1; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = tint; - vertexViewF32[vertexOffset + 25] = tx1; - vertexViewF32[vertexOffset + 26] = ty0; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = tint; - - this.vertexCount += 6; - - if (this.vertexCount >= this.vertexCapacity) - { - this.flush(); - - prevTextureSourceIndex = -1; - } - } - - batchOffset += batchSize; - length -= batchSize; - - if (this.vertexCount >= this.vertexCapacity) - { - this.flush(); - } - } - }, - - /** - * Batches Sprite game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchSprite: function (sprite, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var frame = sprite.frame; - var texture = frame.texture.source[frame.sourceIndex].glTexture; - var forceFlipY = (texture.isRenderTexture ? true : false); - var flipX = sprite.flipX; - var flipY = sprite.flipY ^ forceFlipY; - var uvs = frame.uvs; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = -sprite.displayOriginX + frame.x + ((frame.width) * (flipX ? 1.0 : 0.0)); - var y = -sprite.displayOriginY + frame.y + ((frame.height) * (flipY ? 1.0 : 0.0)); - var xw = (roundPixels ? (x|0) : x) + width; - var yh = (roundPixels ? (y|0) : y) + height; - var scaleX = sprite.scaleX; - var scaleY = sprite.scaleY; - var rotation = sprite.rotation; - var alphaTL = sprite._alphaTL; - var alphaTR = sprite._alphaTR; - var alphaBL = sprite._alphaBL; - var alphaBR = sprite._alphaBR; - var tintTL = sprite._tintTL; - var tintTR = sprite._tintTR; - var tintBL = sprite._tintBL; - var tintBR = sprite._tintBR; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = sprite.x; - var srf = sprite.y; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * sprite.scrollFactorX; - var csf = -camera.scrollY * sprite.scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * sprite.scrollFactorX; - srf -= camera.scrollY * sprite.scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vTintTL = getTint(tintTL, alphaTL); - var vTintTR = getTint(tintTR, alphaTR); - var vTintBL = getTint(tintBL, alphaBL); - var vTintBR = getTint(tintBR, alphaBR); - var vertexOffset = 0; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - }, - - /** - * Batches Mesh game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchMesh: function (mesh, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - var vertices = mesh.vertices; - var length = vertices.length; - var vertexCount = (length / 2)|0; - - this.renderer.setPipeline(this); - - if (this.vertexCount + vertexCount > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var uvs = mesh.uv; - var colors = mesh.colors; - var alphas = mesh.alphas; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var frame = mesh.frame; - var texture = mesh.texture.source[frame.sourceIndex].glTexture; - var translateX = mesh.x; - var translateY = mesh.y; - var scaleX = mesh.scaleX; - var scaleY = mesh.scaleY; - var rotation = mesh.rotation; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * mesh.scrollFactorX; - var csf = -camera.scrollY * mesh.scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * mesh.scrollFactorX; - srf -= camera.scrollY * mesh.scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - for (var index = 0, index0 = 0; index < length; index += 2) - { - var x = vertices[index + 0]; - var y = vertices[index + 1]; - var tx = x * mva + y * mvc + mve; - var ty = x * mvb + y * mvd + mvf; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx; - vertexViewF32[vertexOffset + 1] = ty; - vertexViewF32[vertexOffset + 2] = uvs[index + 0]; - vertexViewF32[vertexOffset + 3] = uvs[index + 1]; - vertexViewU32[vertexOffset + 4] = getTint(colors[index0], alphas[index0]); - - vertexOffset += 5; - index0 += 1; - } - - this.vertexCount += vertexCount; - }, - - /** - * Batches BitmapText game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var text = bitmapText.text; - var textLength = text.length; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var cameraWidth = camera.width + 50; - var cameraHeight = camera.height + 50; - var cameraX = -50; - var cameraY = -50; - var frame = bitmapText.frame; - var textureSource = bitmapText.texture.source[frame.sourceIndex]; - var cameraScrollX = camera.scrollX * bitmapText.scrollFactorX; - var cameraScrollY = camera.scrollY * bitmapText.scrollFactorY; - var fontData = bitmapText.fontData; - var lineHeight = fontData.lineHeight; - var scale = (bitmapText.fontSize / fontData.size); - var chars = fontData.chars; - var alpha = bitmapText.alpha; - var vTintTL = getTint(bitmapText._tintTL, alpha); - var vTintTR = getTint(bitmapText._tintTR, alpha); - var vTintBL = getTint(bitmapText._tintBL, alpha); - var vTintBR = getTint(bitmapText._tintBR, alpha); - var srcX = bitmapText.x; - var srcY = bitmapText.y; - var textureX = frame.cutX; - var textureY = frame.cutY; - var textureWidth = textureSource.width; - var textureHeight = textureSource.height; - var texture = textureSource.glTexture; - var xAdvance = 0; - var yAdvance = 0; - var indexCount = 0; - var charCode = 0; - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - var x = 0; - var y = 0; - var xw = 0; - var yh = 0; - - var tx0; - var ty0; - var tx1; - var ty1; - var tx2; - var ty2; - var tx3; - var ty3; - - var umin = 0; - var umax = 0; - var vmin = 0; - var vmax = 0; - var lastGlyph = null; - var lastCharCode = 0; - var translateX = srcX + frame.x; - var translateY = srcY + frame.y; - var rotation = bitmapText.rotation; - var scaleX = bitmapText.scaleX; - var scaleY = bitmapText.scaleY; - var letterSpacing = bitmapText.letterSpacing; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) * scale; - y = (glyph.yOffset + yAdvance) * scale; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - x -= bitmapText.displayOriginX; - y -= bitmapText.displayOriginY; - - xw = x + glyphW * scale; - yh = y + glyphH * scale; - tx0 = x * mva + y * mvc + mve; - ty0 = x * mvb + y * mvd + mvf; - tx1 = x * mva + yh * mvc + mve; - ty1 = x * mvb + yh * mvd + mvf; - tx2 = xw * mva + yh * mvc + mve; - ty2 = xw * mvb + yh * mvd + mvf; - tx3 = xw * mva + y * mvc + mve; - ty3 = xw * mvb + y * mvd + mvf; - - umin = glyphX / textureWidth; - umax = (glyphX + glyphW) / textureWidth; - vmin = glyphY / textureHeight; - vmax = (glyphY + glyphH) / textureHeight; - - if ((tx0 < cameraX || tx0 > cameraWidth || ty0 < cameraY || ty0 > cameraHeight) && - (tx1 < cameraX || tx1 > cameraWidth || ty1 < cameraY || ty1 > cameraHeight) && - (tx2 < cameraX || tx2 > cameraWidth || ty2 < cameraY || ty2 > cameraHeight) && - (tx3 < cameraX || tx3 > cameraWidth || ty3 < cameraY || ty3 > cameraHeight)) - { - continue; - } - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = umin; - vertexViewF32[vertexOffset + 3] = vmin; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = umin; - vertexViewF32[vertexOffset + 8] = vmax; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = umax; - vertexViewF32[vertexOffset + 13] = vmax; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = umin; - vertexViewF32[vertexOffset + 18] = vmin; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = umax; - vertexViewF32[vertexOffset + 23] = vmax; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = umax; - vertexViewF32[vertexOffset + 28] = vmin; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - } - }, - - /** - * Batches DynamicBitmapText game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var displayCallback = bitmapText.displayCallback; - var text = bitmapText.text; - var textLength = text.length; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var renderer = this.renderer; - var cameraMatrix = camera.matrix.matrix; - var frame = bitmapText.frame; - var textureSource = bitmapText.texture.source[frame.sourceIndex]; - var cameraScrollX = camera.scrollX * bitmapText.scrollFactorX; - var cameraScrollY = camera.scrollY * bitmapText.scrollFactorY; - var scrollX = bitmapText.scrollX; - var scrollY = bitmapText.scrollY; - var fontData = bitmapText.fontData; - var lineHeight = fontData.lineHeight; - var scale = (bitmapText.fontSize / fontData.size); - var chars = fontData.chars; - var alpha = bitmapText.alpha; - var vTintTL = getTint(bitmapText._tintTL, alpha); - var vTintTR = getTint(bitmapText._tintTR, alpha); - var vTintBL = getTint(bitmapText._tintBL, alpha); - var vTintBR = getTint(bitmapText._tintBR, alpha); - var srcX = bitmapText.x; - var srcY = bitmapText.y; - var textureX = frame.cutX; - var textureY = frame.cutY; - var textureWidth = textureSource.width; - var textureHeight = textureSource.height; - var texture = textureSource.glTexture; - var xAdvance = 0; - var yAdvance = 0; - var indexCount = 0; - var charCode = 0; - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - var x = 0; - var y = 0; - var xw = 0; - var tx0; - var ty0; - var tx1; - var ty1; - var tx2; - var ty2; - var tx3; - var ty3; - var yh = 0; - var umin = 0; - var umax = 0; - var vmin = 0; - var vmax = 0; - var lastGlyph = null; - var lastCharCode = 0; - var translateX = srcX + frame.x; - var translateY = srcY + frame.y; - var rotation = bitmapText.rotation; - var scaleX = bitmapText.scaleX; - var scaleY = bitmapText.scaleY; - var letterSpacing = bitmapText.letterSpacing; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var crop = (bitmapText.cropWidth > 0 || bitmapText.cropHeight > 0); - var uta, utb, utc, utd, ute, utf; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - if (crop) - { - renderer.pushScissor( - bitmapText.x, - bitmapText.y, - bitmapText.cropWidth * bitmapText.scaleX, - bitmapText.cropHeight * bitmapText.scaleY - ); - } - - for (var index = 0; index < textLength; ++index) - { - scale = (bitmapText.fontSize / bitmapText.fontData.size); - rotation = 0; - - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) - scrollX; - y = (glyph.yOffset + yAdvance) - scrollY; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - if (displayCallback) - { - var output = displayCallback({ - color: 0, - tint: { - topLeft: vTintTL, - topRight: vTintTR, - bottomLeft: vTintBL, - bottomRight: vTintBR - }, - index: index, - charCode: charCode, - x: x, - y: y, - scale: scale, - rotation: 0, - data: glyph.data - }); - - x = output.x; - y = output.y; - scale = output.scale; - rotation = output.rotation; - - if (output.color) - { - vTintTL = output.color; - vTintTR = output.color; - vTintBL = output.color; - vTintBR = output.color; - } - else - { - vTintTL = output.tint.topLeft; - vTintTR = output.tint.topRight; - vTintBL = output.tint.bottomLeft; - vTintBR = output.tint.bottomRight; - } - - vTintTL = getTint(vTintTL, alpha); - vTintTR = getTint(vTintTR, alpha); - vTintBL = getTint(vTintBL, alpha); - vTintBR = getTint(vTintBR, alpha); - } - - x -= bitmapText.displayOriginX; - y -= bitmapText.displayOriginY; - x *= scale; - y *= scale; - - sr = Math.sin(rotation); - cr = Math.cos(rotation); - uta = cr * scale; - utb = sr * scale; - utc = -sr * scale; - utd = cr * scale; - ute = x; - utf = y; - - sra = uta * mva + utb * mvc; - srb = uta * mvb + utb * mvd; - src = utc * mva + utd * mvc; - srd = utc * mvb + utd * mvd; - sre = ute * mva + utf * mvc + mve; - srf = ute * mvb + utf * mvd + mvf; - - xw = glyphW; - yh = glyphH; - tx0 = sre; - ty0 = srf; - tx1 = yh * src + sre; - ty1 = yh * srd + srf; - tx2 = xw * sra + yh * src + sre; - ty2 = xw * srb + yh * srd + srf; - tx3 = xw * sra + sre; - ty3 = xw * srb + srf; - - umin = glyphX / textureWidth; - umax = (glyphX + glyphW) / textureWidth; - vmin = glyphY / textureHeight; - vmax = (glyphY + glyphH) / textureHeight; - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = umin; - vertexViewF32[vertexOffset + 3] = vmin; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = umin; - vertexViewF32[vertexOffset + 8] = vmax; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = umax; - vertexViewF32[vertexOffset + 13] = vmax; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = umin; - vertexViewF32[vertexOffset + 18] = vmin; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = umax; - vertexViewF32[vertexOffset + 23] = vmax; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = umax; - vertexViewF32[vertexOffset + 28] = vmin; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - } - - if (crop) - { - renderer.popScissor(); - } - }, - - /** - * Batches Text game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchText: function (text, camera, parentTransformMatrix) - { - var getTint = Utils.getTintAppendFloatAlpha; - - this.batchTexture( - text, - text.canvasTexture, - text.canvasTexture.width, text.canvasTexture.height, - text.x, text.y, - text.canvasTexture.width, text.canvasTexture.height, - text.scaleX, text.scaleY, - text.rotation, - text.flipX, text.flipY, - text.scrollFactorX, text.scrollFactorY, - text.displayOriginX, text.displayOriginY, - 0, 0, text.canvasTexture.width, text.canvasTexture.height, - getTint(text._tintTL, text._alphaTL), - getTint(text._tintTR, text._alphaTR), - getTint(text._tintBL, text._alphaBL), - getTint(text._tintBR, text._alphaBR), - 0, 0, - camera, - parentTransformMatrix - ); - }, - - /** - * Batches DynamicTilemapLayer game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix) - { - var renderTiles = tilemapLayer.culledTiles; - var length = renderTiles.length; - var texture = tilemapLayer.tileset.image.get().source.glTexture; - var tileset = tilemapLayer.tileset; - var scrollFactorX = tilemapLayer.scrollFactorX; - var scrollFactorY = tilemapLayer.scrollFactorY; - var alpha = tilemapLayer.alpha; - var x = tilemapLayer.x; - var y = tilemapLayer.y; - var sx = tilemapLayer.scaleX; - var sy = tilemapLayer.scaleY; - var getTint = Utils.getTintAppendFloatAlpha; - - for (var index = 0; index < length; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } - - var frameWidth = tile.width; - var frameHeight = tile.height; - var frameX = tileTexCoords.x; - var frameY = tileTexCoords.y; - var tint = getTint(tile.tint, alpha * tile.alpha); - - this.batchTexture( - tilemapLayer, - texture, - texture.width, texture.height, - (tile.width / 2) + x + tile.pixelX * sx, (tile.height / 2) + y + tile.pixelY * sy, - tile.width * sx, tile.height * sy, - 1, 1, - tile.rotation, - tile.flipX, tile.flipY, - scrollFactorX, scrollFactorY, - (tile.width / 2), (tile.height / 2), - frameX, frameY, frameWidth, frameHeight, - tint, tint, tint, tint, - 0, 0, - camera, - parentTransformMatrix - ); - } - }, - - /** - * Batches TileSprite game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchTileSprite: function (tileSprite, camera, parentTransformMatrix) - { - var getTint = Utils.getTintAppendFloatAlpha; - - this.batchTexture( - tileSprite, - tileSprite.tileTexture, - tileSprite.frame.width, tileSprite.frame.height, - tileSprite.x, tileSprite.y, - tileSprite.width, tileSprite.height, - tileSprite.scaleX, tileSprite.scaleY, - tileSprite.rotation, - tileSprite.flipX, tileSprite.flipY, - tileSprite.scrollFactorX, tileSprite.scrollFactorY, - tileSprite.originX * tileSprite.width, tileSprite.originY * tileSprite.height, - 0, 0, tileSprite.width, tileSprite.height, - getTint(tileSprite._tintTL, tileSprite._alphaTL), - getTint(tileSprite._tintTR, tileSprite._alphaTR), - getTint(tileSprite._tintBL, tileSprite._alphaBL), - getTint(tileSprite._tintBR, tileSprite._alphaBR), - (tileSprite.tilePositionX % tileSprite.frame.width) / tileSprite.frame.width, - (tileSprite.tilePositionY % tileSprite.frame.height) / tileSprite.frame.height, - camera, - parentTransformMatrix - ); - }, - - /** - * Generic function for batching a textured quad - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject - * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad - * @param {integer} textureWidth - Real texture width - * @param {integer} textureHeight - Real texture height - * @param {float} srcX - X coordinate of the quad - * @param {float} srcY - Y coordinate of the quad - * @param {float} srcWidth - Width of the quad - * @param {float} srcHeight - Height of the quad - * @param {float} scaleX - X component of scale - * @param {float} scaleY - Y component of scale - * @param {float} rotation - Rotation of the quad - * @param {boolean} flipX - Indicates if the quad is horizontally flipped - * @param {boolean} flipY - Indicates if the quad is vertically flipped - * @param {float} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll - * @param {float} scrollFactorY - By which factor is the quad effected by the camera vertical scroll - * @param {float} displayOriginX - Horizontal origin in pixels - * @param {float} displayOriginY - Vertical origin in pixels - * @param {float} frameX - X coordinate of the texture frame - * @param {float} frameY - Y coordinate of the texture frame - * @param {float} frameWidth - Width of the texture frame - * @param {float} frameHeight - Height of the texture frame - * @param {integer} tintTL - Tint for top left - * @param {integer} tintTR - Tint for top right - * @param {integer} tintBL - Tint for bottom left - * @param {integer} tintBR - Tint for bottom right - * @param {float} uOffset - Horizontal offset on texture coordinate - * @param {float} vOffset - Vertical offset on texture coordinate - * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container - */ - batchTexture: function ( - gameObject, - texture, - textureWidth, textureHeight, - srcX, srcY, - srcWidth, srcHeight, - scaleX, scaleY, - rotation, - flipX, flipY, - scrollFactorX, scrollFactorY, - displayOriginX, displayOriginY, - frameX, frameY, frameWidth, frameHeight, - tintTL, tintTR, tintBL, tintBR, - uOffset, vOffset, - camera, - parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); - - var roundPixels = this.renderer.config.roundPixels; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var width = srcWidth * (flipX ? -1.0 : 1.0); - var height = srcHeight * (flipY ? -1.0 : 1.0); - var x = -displayOriginX + ((srcWidth) * (flipX ? 1.0 : 0.0)); - var y = -displayOriginY + ((srcHeight) * (flipY ? 1.0 : 0.0)); - var xw = x + width; - var yh = y + height; - var translateX = srcX; - var translateY = srcY; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * scrollFactorX; - var csf = -camera.scrollY * scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * scrollFactorX; - srf -= camera.scrollY * scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = 0; - var u0 = (frameX / textureWidth) + uOffset; - var v0 = (frameY / textureHeight) + vOffset; - var u1 = (frameX + frameWidth) / textureWidth + uOffset; - var v1 = (frameY + frameHeight) / textureHeight + vOffset; - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = u0; - vertexViewF32[vertexOffset + 3] = v0; - vertexViewU32[vertexOffset + 4] = tintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = u0; - vertexViewF32[vertexOffset + 8] = v1; - vertexViewU32[vertexOffset + 9] = tintTR; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = u1; - vertexViewF32[vertexOffset + 13] = v1; - vertexViewU32[vertexOffset + 14] = tintBL; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = u0; - vertexViewF32[vertexOffset + 18] = v0; - vertexViewU32[vertexOffset + 19] = tintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = u1; - vertexViewF32[vertexOffset + 23] = v1; - vertexViewU32[vertexOffset + 24] = tintBL; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = u1; - vertexViewF32[vertexOffset + 28] = v0; - vertexViewU32[vertexOffset + 29] = tintBR; - - this.vertexCount += 6; - }, - - /** - * Immediately draws a texture with no batching. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawTexture - * @since 3.2.0 - * - * @param {WebGLTexture} texture [description] - * @param {number} srcX - [description] - * @param {number} srcY - [description] - * @param {number} tint - [description] - * @param {number} alpha - [description] - * @param {number} frameX - [description] - * @param {number} frameY - [description] - * @param {number} frameWidth - [description] - * @param {number} frameHeight - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} transformMatrix - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This Pipeline. - */ - drawTexture: function ( - texture, - srcX, srcY, - tint, alpha, - frameX, frameY, frameWidth, frameHeight, - transformMatrix, - parentTransformMatrix - ) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var width = frameWidth; - var height = frameHeight; - var x = srcX; - var y = srcY; - var xw = x + width; - var yh = y + height; - var mva = transformMatrix[0]; - var mvb = transformMatrix[1]; - var mvc = transformMatrix[2]; - var mvd = transformMatrix[3]; - var mve = transformMatrix[4]; - var mvf = transformMatrix[5]; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var pca = mva * pma + mvb * pmc; - var pcb = mva * pmb + mvb * pmd; - var pcc = mvc * pma + mvd * pmc; - var pcd = mvc * pmb + mvd * pmd; - var pce = mve * pma + mvf * pmc + pme; - var pcf = mve * pmb + mvf * pmd + pmf; - mva = pca; - mvb = pcb; - mvc = pcc; - mvd = pcd; - mve = pce; - mvf = pcf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = 0; - var textureWidth = texture.width; - var textureHeight = texture.height; - var u0 = (frameX / textureWidth); - var v0 = (frameY / textureHeight); - var u1 = (frameX + frameWidth) / textureWidth; - var v1 = (frameY + frameHeight) / textureHeight; - tint = Utils.getTintAppendFloatAlpha(tint, alpha); - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = u0; - vertexViewF32[vertexOffset + 3] = v0; - vertexViewU32[vertexOffset + 4] = tint; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = u0; - vertexViewF32[vertexOffset + 8] = v1; - vertexViewU32[vertexOffset + 9] = tint; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = u1; - vertexViewF32[vertexOffset + 13] = v1; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = u0; - vertexViewF32[vertexOffset + 18] = v0; - vertexViewU32[vertexOffset + 19] = tint; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = u1; - vertexViewF32[vertexOffset + 23] = v1; - vertexViewU32[vertexOffset + 24] = tint; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = u1; - vertexViewF32[vertexOffset + 28] = v0; - vertexViewU32[vertexOffset + 29] = tint; - - this.vertexCount += 6; - - // Force an immediate draw - this.flush(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchGraphics - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchGraphics: function () - { - // Stub - } - -}); - -module.exports = TextureTintPipeline; - - -/***/ }), -/* 130 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. - * If no parent was given or falls back to using `document.body`. - * - * @function Phaser.DOM.AddToDOM - * @since 3.0.0 - * - * @param {HTMLElement} element - The element to be added to the DOM. Usually a Canvas object. - * @param {(string|HTMLElement)} [parent] - The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. - * @param {boolean} [overflowHidden=true] - Whether or not to hide overflowing content inside the parent. - * - * @return {HTMLElement} The element that was added to the DOM. - */ -var AddToDOM = function (element, parent, overflowHidden) -{ - if (overflowHidden === undefined) { overflowHidden = true; } - - var target; - - if (parent) - { - if (typeof parent === 'string') - { - // Hopefully an element ID - target = document.getElementById(parent); - } - else if (typeof parent === 'object' && parent.nodeType === 1) - { - // Quick test for a HTMLelement - target = parent; - } - } - else if (element.parentElement) - { - return element; - } - - // Fallback, covers an invalid ID and a non HTMLelement object - if (!target) - { - target = document.body; - } - - if (overflowHidden && target.style) - { - target.style.overflow = 'hidden'; - } - - target.appendChild(element); - - return element; -}; - -module.exports = AddToDOM; - - -/***/ }), -/* 131 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Browser specific prefix, so not going to change between contexts, only between browsers -var prefix = ''; - -/** - * @namespace Phaser.Display.Canvas.Smoothing - * @since 3.0.0 - */ -var Smoothing = function () -{ - /** - * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. - * - * @function Phaser.Display.Canvas.Smoothing.getPrefix - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {string} [description] - */ - var getPrefix = function (context) - { - var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; - - for (var i = 0; i < vendors.length; i++) - { - var s = vendors[i] + 'mageSmoothingEnabled'; - - if (s in context) - { - return s; - } - } - - return null; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.enable - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] - */ - var enable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = true; - } - - return context; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.disable - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] - */ - var disable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = false; - } - - return context; - }; - - /** - * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. - * Returns null if no smoothing prefix is available. - * - * @function Phaser.Display.Canvas.Smoothing.isEnabled - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {?boolean} [description] - */ - var isEnabled = function (context) - { - return (prefix !== null) ? context[prefix] : null; - }; - - return { - disable: disable, - enable: enable, - getPrefix: getPrefix, - isEnabled: isEnabled - }; - -}; - -module.exports = Smoothing(); - - -/***/ }), -/* 132 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HexStringToColor = __webpack_require__(285); -var IntegerToColor = __webpack_require__(283); -var ObjectToColor = __webpack_require__(281); -var RGBStringToColor = __webpack_require__(280); - -/** - * Converts the given source color value into an instance of a Color class. - * The value can be either a string, prefixed with `rgb` or a hex string, a number or an Object. - * - * @function Phaser.Display.Color.ValueToColor - * @since 3.0.0 - * - * @param {(string|number|InputColorObject)} input - The source color value to convert. - * - * @return {Phaser.Display.Color} A Color object. - */ -var ValueToColor = function (input) -{ - var t = typeof input; - - switch (t) - { - case 'string': - - if (input.substr(0, 3).toLowerCase() === 'rgb') - { - return RGBStringToColor(input); - } - else - { - return HexStringToColor(input); - } - - case 'number': - - return IntegerToColor(input); - - case 'object': - - return ObjectToColor(input); - } -}; - -module.exports = ValueToColor; - - -/***/ }), -/* 133 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes the given string and pads it out, to the length required, using the character - * specified. For example if you need a string to be 6 characters long, you can call: - * - * `pad('bob', 6, '-', 2)` - * - * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. - * - * You can also use it to pad numbers (they are always returned as strings): - * - * `pad(512, 6, '0', 1)` - * - * Would return: `000512` with the string padded to the left. - * - * If you don't specify a direction it'll pad to both sides: - * - * `pad('c64', 7, '*')` - * - * Would return: `**c64**` - * - * @function Phaser.Utils.String.Pad - * @since 3.0.0 - * - * @param {string} str - The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. - * @param {integer} [len=0] - The number of characters to be added. - * @param {string} [pad=" "] - The string to pad it out with (defaults to a space). - * @param {integer} [dir=3] - The direction dir = 1 (left), 2 (right), 3 (both). - * - * @return {string} The padded string. - */ -var Pad = function (str, len, pad, dir) -{ - if (len === undefined) { len = 0; } - if (pad === undefined) { pad = ' '; } - if (dir === undefined) { dir = 3; } - - str = str.toString(); - - var padlen = 0; - - if (len + 1 >= str.length) - { - switch (dir) - { - case 1: - str = new Array(len + 1 - str.length).join(pad) + str; - break; - - case 3: - var right = Math.ceil((padlen = len - str.length) / 2); - var left = padlen - right; - str = new Array(left + 1).join(pad) + str + new Array(right + 1).join(pad); - break; - - default: - str = str + new Array(len + 1 - str.length).join(pad); - break; - } - } - - return str; -}; - -module.exports = Pad; - - -/***/ }), -/* 134 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a uniformly distributed random point from anywhere within the given Ellipse. - * - * @function Phaser.Geom.Ellipse.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get a random point from. - * @param {(Phaser.Geom.Point|object)} [out] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. - */ -var Random = function (ellipse, out) -{ - if (out === undefined) { out = new Point(); } - - var p = Math.random() * Math.PI * 2; - var s = Math.sqrt(Math.random()); - - out.x = ellipse.x + ((s * Math.cos(p)) * ellipse.width / 2); - out.y = ellipse.y + ((s * Math.sin(p)) * ellipse.height / 2); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 135 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Perimeter = __webpack_require__(97); -var Point = __webpack_require__(5); - -/** - * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. - * - * @function Phaser.Geom.Rectangle.GetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var GetPoint = function (rectangle, position, out) -{ - if (out === undefined) { out = new Point(); } - - if (position <= 0 || position >= 1) - { - out.x = rectangle.x; - out.y = rectangle.y; - - return out; - } - - var p = Perimeter(rectangle) * position; - - if (position > 0.5) - { - p -= (rectangle.width + rectangle.height); - - if (p <= rectangle.width) - { - // Face 3 - out.x = rectangle.right - p; - out.y = rectangle.bottom; - } - else - { - // Face 4 - out.x = rectangle.x; - out.y = rectangle.bottom - (p - rectangle.width); - } - } - else if (p <= rectangle.width) - { - // Face 1 - out.x = rectangle.x + p; - out.y = rectangle.y; - } - else - { - // Face 2 - out.x = rectangle.right; - out.y = rectangle.y + (p - rectangle.width); - } - - return out; -}; - -module.exports = GetPoint; - - -/***/ }), -/* 136 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * - * @function Phaser.Geom.Circle.CircumferencePoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. - * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. - */ -var CircumferencePoint = function (circle, angle, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = circle.x + (circle.radius * Math.cos(angle)); - out.y = circle.y + (circle.radius * Math.sin(angle)); - - return out; -}; - -module.exports = CircumferencePoint; - - -/***/ }), -/* 137 */, -/* 138 */, -/* 139 */, -/* 140 */, -/* 141 */, -/* 142 */, -/* 143 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); -var ParseXML = __webpack_require__(270); - -/** - * @typedef {object} Phaser.Loader.FileTypes.XMLFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='xml'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single XML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. - * - * @class XMLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var XMLFile = new Class({ - - Extends: File, - - initialize: - - function XMLFile (loader, key, url, xhrSettings) - { - var extension = 'xml'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'xml', - cache: loader.cacheManager.xml, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.XMLFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = ParseXML(this.xhrLoader.responseText); - - if (this.data) - { - this.onProcessComplete(); - } - else - { - console.warn('Invalid XMLFile: ' + this.key); - - this.onProcessError(); - } - } - -}); - -/** - * Adds an XML file, or array of XML files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.xml('wavedata', 'files/AlienWaveData.xml'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global XML Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the XML Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the XML Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.xml({ - * key: 'wavedata', - * url: 'files/AlienWaveData.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.XMLFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.xml('wavedata', 'files/AlienWaveData.xml'); - * // and later in your game ... - * var data = this.cache.xml.get('wavedata'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the XML Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" - * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the XML File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#xml - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig|Phaser.Loader.FileTypes.XMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('xml', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new XMLFile(this, key[i])); - } - } - else - { - this.addFile(new XMLFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = XMLFile; - - -/***/ }), -/* 144 */, -/* 145 */, -/* 146 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns a Random element from the array. - * - * @function Phaser.Utils.Array.GetRandom - * @since 3.0.0 - * - * @param {array} array - The array to select the random entry from. - * @param {integer} [startIndex=0] - An optional start index. - * @param {integer} [length=array.length] - An optional length, the total number of elements (from the startIndex) to choose from. - * - * @return {object} A random element from the array, or `null` if no element could be found in the range given. - */ -var GetRandom = function (array, startIndex, length) -{ - if (startIndex === undefined) { startIndex = 0; } - if (length === undefined) { length = array.length; } - - var randomIndex = startIndex + Math.floor(Math.random() * length); - - return (array[randomIndex] === undefined) ? null : array[randomIndex]; -}; - -module.exports = GetRandom; - - -/***/ }), -/* 147 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils.Array - */ - -module.exports = { - - Matrix: __webpack_require__(503), - - Add: __webpack_require__(496), - AddAt: __webpack_require__(495), - BringToTop: __webpack_require__(494), - CountAllMatching: __webpack_require__(493), - Each: __webpack_require__(492), - EachInRange: __webpack_require__(491), - FindClosestInSorted: __webpack_require__(209), - GetAll: __webpack_require__(490), - GetFirst: __webpack_require__(489), - GetRandom: __webpack_require__(146), - MoveDown: __webpack_require__(488), - MoveTo: __webpack_require__(487), - MoveUp: __webpack_require__(486), - NumberArray: __webpack_require__(485), - NumberArrayStep: __webpack_require__(484), - QuickSelect: __webpack_require__(180), - Range: __webpack_require__(254), - Remove: __webpack_require__(195), - RemoveAt: __webpack_require__(483), - RemoveBetween: __webpack_require__(482), - RemoveRandomElement: __webpack_require__(481), - Replace: __webpack_require__(480), - RotateLeft: __webpack_require__(290), - RotateRight: __webpack_require__(289), - SafeRange: __webpack_require__(29), - SendToBack: __webpack_require__(479), - SetAll: __webpack_require__(478), - Shuffle: __webpack_require__(95), - SpliceOne: __webpack_require__(56), - StableSort: __webpack_require__(83), - Swap: __webpack_require__(477) - -}; - - -/***/ }), -/* 148 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(527); -var TextureTintPipeline = __webpack_require__(129); - -var LIGHT_COUNT = 10; - -/** - * @classdesc - * ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights. - * This pipeline extends TextureTintPipeline so it implements all it's rendering functions - * and batching system. - * - * @class ForwardDiffuseLightPipeline - * @extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var ForwardDiffuseLightPipeline = new Class({ - - Extends: TextureTintPipeline, - - initialize: - - function ForwardDiffuseLightPipeline (config) - { - config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); - - TextureTintPipeline.call(this, config); - }, - - /** - * This function binds it's base class resources and this lights 2D resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onBind - * @override - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline} [description] - */ - onBind: function () - { - TextureTintPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - this.mvpUpdate(); - - renderer.setInt1(program, 'uNormSampler', 1); - renderer.setFloat2(program, 'uResolution', this.width, this.height); - - return this; - }, - - /** - * This function sets all the needed resources for each camera pass. - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onRender - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline} [description] - */ - onRender: function (scene, camera) - { - this.active = false; - - var lightManager = scene.sys.lights; - - if (!lightManager || lightManager.lights.length <= 0 || !lightManager.active) - { - // Passthru - return this; - } - - var lights = lightManager.cull(camera); - var lightCount = Math.min(lights.length, LIGHT_COUNT); - - if (lightCount === 0) - { - return this; - } - - this.active = true; - - var renderer = this.renderer; - var program = this.program; - var cameraMatrix = camera.matrix; - var point = {x: 0, y: 0}; - var height = renderer.height; - var index; - - for (index = 0; index < LIGHT_COUNT; ++index) - { - // Reset lights - renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); - } - - renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); - renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); - - for (index = 0; index < lightCount; ++index) - { - var light = lights[index]; - var lightName = 'uLights[' + index + '].'; - - cameraMatrix.transformPoint(light.x, light.y, point); - - renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); - renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); - renderer.setFloat1(program, lightName + 'intensity', light.intensity); - renderer.setFloat1(program, lightName + 'radius', light.radius); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawStaticTilemapLayer - * @override - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawStaticTilemapLayer: function (tilemap, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tilemap.tileset.image.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. StaticTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - drawEmitterManager: function (emitterManager, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = emitterManager.texture.dataSource[emitterManager.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. EmitterManager rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - drawBlitter: function (blitter, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = blitter.texture.dataSource[blitter.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Blitter rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchSprite: function (sprite, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = sprite.texture.dataSource[sprite.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Sprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchMesh: function (mesh, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = mesh.texture.dataSource[mesh.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Mesh rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera, parentTransformMatrix); - - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = bitmapText.texture.dataSource[bitmapText.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. BitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var normalTexture = bitmapText.texture.dataSource[bitmapText.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicBitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchText: function (text, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = text.texture.dataSource[text.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchText.call(this, text, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Text rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchText(text, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tilemapLayer.tileset.image.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchTileSprite: function (tileSprite, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tileSprite.texture.dataSource[tileSprite.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. TileSprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera, parentTransformMatrix); - } - } - -}); - -ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; - -module.exports = ForwardDiffuseLightPipeline; - - -/***/ }), -/* 149 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compute a random integer between the `min` and `max` values, inclusive. - * - * @function Phaser.Math.Between - * @since 3.0.0 - * - * @param {integer} min - The minimum value. - * @param {integer} max - The maximum value. - * - * @return {integer} The random integer. - */ -var Between = function (min, max) -{ - return Math.floor(Math.random() * (max - min + 1) + min); -}; - -module.exports = Between; - - -/***/ }), -/* 150 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); - -/** - * Convert the given angle in radians, to the equivalent angle in degrees. - * - * @function Phaser.Math.RadToDeg - * @since 3.0.0 - * - * @param {float} radians - The angle in radians to convert ot degrees. - * - * @return {integer} The given angle converted to degrees. - */ -var RadToDeg = function (radians) -{ - return radians * CONST.RAD_TO_DEG; -}; - -module.exports = RadToDeg; - - -/***/ }), -/* 151 */, -/* 152 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Given 3 separate color values this will return an integer representation of it. - * - * @function Phaser.Display.Color.GetColor - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * - * @return {number} The combined color value. - */ -var GetColor = function (red, green, blue) -{ - return red << 16 | green << 8 | blue; -}; - -module.exports = GetColor; - - -/***/ }), -/* 153 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Random = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - - // Basis vectors - var ux = triangle.x2 - triangle.x1; - var uy = triangle.y2 - triangle.y1; - - var vx = triangle.x3 - triangle.x1; - var vy = triangle.y3 - triangle.y1; - - // Random point within the unit square - var r = Math.random(); - var s = Math.random(); - - // Point outside the triangle? Remap it. - if (r + s >= 1) - { - r = 1 - r; - s = 1 - s; - } - - out.x = triangle.x1 + ((ux * r) + (vx * s)); - out.y = triangle.y1 + ((uy * r) + (vy * s)); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 154 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} out - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Random = function (rect, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = rect.x + (Math.random() * rect.width); - out.y = rect.y + (Math.random() * rect.height); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 155 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a random point on a given Line. - * - * @function Phaser.Geom.Line.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - The Line to calculate the random Point on. - * @param {(Phaser.Geom.Point|object)} [out] - An instance of a Point to be modified. - * - * @return {(Phaser.Geom.Point|object)} A random Point on the Line. - */ -var Random = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - var t = Math.random(); - - out.x = line.x1 + t * (line.x2 - line.x1); - out.y = line.y1 + t * (line.y2 - line.y1); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 156 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(71); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ -var GetPoints = function (line, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = Length(line) / stepRate; - } - - var x1 = line.x1; - var y1 = line.y1; - - var x2 = line.x2; - var y2 = line.y2; - - for (var i = 0; i < quantity; i++) - { - var position = i / quantity; - - var x = x1 + (x2 - x1) * position; - var y = y1 + (y2 - y1) * position; - - out.push(new Point(x, y)); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 157 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a uniformly distributed random point from anywhere within the given Circle. - * - * @function Phaser.Geom.Circle.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to get a random point from. - * @param {(Phaser.Geom.Point|object)} [out] - A Point or point-like object to set the random `x` and `y` values in. - * - * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. - */ -var Random = function (circle, out) -{ - if (out === undefined) { out = new Point(); } - - var t = 2 * Math.PI * Math.random(); - var u = Math.random() + Math.random(); - var r = (u > 1) ? 2 - u : u; - var x = r * Math.cos(t); - var y = r * Math.sin(t); - - out.x = circle.x + (x * circle.radius); - out.y = circle.y + (y * circle.radius); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 158 */, -/* 159 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var TweenBuilder = __webpack_require__(72); -var TWEEN_CONST = __webpack_require__(61); - -/** - * @classdesc - * [description] - * - * @class Timeline - * @memberOf Phaser.Tweens - * @extends Phaser.Events.EventEmitter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Tweens.TweenManager} manager - [description] - */ -var Timeline = new Class({ - - Extends: EventEmitter, - - initialize: - - function Timeline (manager) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Tweens.Timeline#manager - * @type {Phaser.Tweens.TweenManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * [description] - * - * @name Phaser.Tweens.Timeline#isTimeline - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.isTimeline = true; - - /** - * An array of Tween objects, each containing a unique property and target being tweened. - * - * @name Phaser.Tweens.Timeline#data - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.data = []; - - /** - * data array doesn't usually change, so we can cache the length - * - * @name Phaser.Tweens.Timeline#totalData - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalData = 0; - - /** - * If true then duration, delay, etc values are all frame totals. - * - * @name Phaser.Tweens.Timeline#useFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useFrames = false; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * - * @name Phaser.Tweens.Timeline#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) - * - * @name Phaser.Tweens.Timeline#loop - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loop = 0; - - /** - * Time in ms/frames before the tween loops. - * - * @name Phaser.Tweens.Timeline#loopDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopDelay = 0; - - /** - * How many loops are left to run? - * - * @name Phaser.Tweens.Timeline#loopCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopCounter = 0; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) - * - * @name Phaser.Tweens.Timeline#completeDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.completeDelay = 0; - - /** - * Countdown timer (used by loopDelay and completeDelay) - * - * @name Phaser.Tweens.Timeline#countdown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.countdown = 0; - - /** - * The current state of the tween - * - * @name Phaser.Tweens.Timeline#state - * @type {integer} - * @since 3.0.0 - */ - this.state = TWEEN_CONST.PENDING_ADD; - - /** - * The state of the tween when it was paused (used by Resume) - * - * @name Phaser.Tweens.Timeline#_pausedState - * @type {integer} - * @private - * @since 3.0.0 - */ - this._pausedState = TWEEN_CONST.PENDING_ADD; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - * - * @name Phaser.Tweens.Timeline#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * Elapsed time in ms/frames of this run through the Tween. - * - * @name Phaser.Tweens.Timeline#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - * - * @name Phaser.Tweens.Timeline#totalElapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalElapsed = 0; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - * - * @name Phaser.Tweens.Timeline#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - * - * @name Phaser.Tweens.Timeline#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * Time in ms/frames for all Tweens to complete (including looping) - * - * @name Phaser.Tweens.Timeline#totalDuration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalDuration = 0; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - * - * @name Phaser.Tweens.Timeline#totalProgress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalProgress = 0; - - this.callbacks = { - onComplete: null, - onLoop: null, - onStart: null, - onUpdate: null, - onYoyo: null - }; - - this.callbackScope; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#setTimeScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - setTimeScale: function (value) - { - this.timeScale = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#getTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#isPlaying - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isPlaying: function () - { - return (this.state === TWEEN_CONST.ACTIVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#add - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - add: function (config) - { - return this.queue(TweenBuilder(this, config)); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#queue - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - queue: function (tween) - { - if (!this.isPlaying()) - { - tween.parent = this; - tween.parentIsTimeline = true; - - this.data.push(tween); - - this.totalData = this.data.length; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#hasOffset - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {boolean} [description] - */ - hasOffset: function (tween) - { - return (tween.offset !== null); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#isOffsetAbsolute - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {boolean} [description] - */ - isOffsetAbsolute: function (value) - { - return (typeof(value) === 'number'); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#isOffsetRelative - * @since 3.0.0 - * - * @param {string} value - [description] - * - * @return {boolean} [description] - */ - isOffsetRelative: function (value) - { - var t = typeof(value); - - if (t === 'string') - { - var op = value[0]; - - if (op === '-' || op === '+') - { - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#getRelativeOffset - * @since 3.0.0 - * - * @param {string} value - [description] - * @param {number} base - [description] - * - * @return {number} [description] - */ - getRelativeOffset: function (value, base) - { - var op = value[0]; - var num = parseFloat(value.substr(2)); - var result = base; - - switch (op) - { - case '+': - result += num; - break; - - case '-': - result -= num; - break; - } - - // Cannot ever be < 0 - return Math.max(0, result); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#calcDuration - * @since 3.0.0 - */ - calcDuration: function () - { - var prevEnd = 0; - var totalDuration = 0; - var offsetDuration = 0; - - for (var i = 0; i < this.totalData; i++) - { - var tween = this.data[i]; - - tween.init(); - - if (this.hasOffset(tween)) - { - if (this.isOffsetAbsolute(tween.offset)) - { - // An actual number, so it defines the start point from the beginning of the timeline - tween.calculatedOffset = tween.offset; - - if (tween.offset === 0) - { - offsetDuration = 0; - } - } - else if (this.isOffsetRelative(tween.offset)) - { - // A relative offset (i.e. '-=1000', so starts at 'offset' ms relative to the PREVIOUS Tweens ending time) - tween.calculatedOffset = this.getRelativeOffset(tween.offset, prevEnd); - } - } - else - { - // Sequential - tween.calculatedOffset = offsetDuration; - } - - prevEnd = tween.totalDuration + tween.calculatedOffset; - - totalDuration += tween.totalDuration; - offsetDuration += tween.totalDuration; - } - - // Excludes loop values - this.duration = totalDuration; - - this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; - - if (this.loopCounter > 0) - { - this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); - } - else - { - this.totalDuration = this.duration + this.completeDelay; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#init - * @since 3.0.0 - * - * @return {boolean} [description] - */ - init: function () - { - this.calcDuration(); - - this.progress = 0; - this.totalProgress = 0; - - if (this.paused) - { - this.state = TWEEN_CONST.PAUSED; - - return false; - } - else - { - return true; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#resetTweens - * @since 3.0.0 - * - * @param {boolean} resetFromLoop - [description] - */ - resetTweens: function (resetFromLoop) - { - for (var i = 0; i < this.totalData; i++) - { - var tween = this.data[i]; - - tween.play(resetFromLoop); - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#setCallback - * @since 3.0.0 - * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] - * @param {object} [scope] - [description] - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - setCallback: function (type, callback, params, scope) - { - if (Timeline.TYPES.indexOf(type) !== -1) - { - this.callbacks[type] = { func: callback, scope: scope, params: params }; - } - - return this; - }, - - /** - * Delegates #makeActive to the Tween manager. - * - * @method Phaser.Tweens.Timeline#makeActive - * @since 3.3.0 - * - * @param {Phaser.Tweens.Tween} tween - The tween object to make active. - * - * @return {Phaser.Tweens.TweenManager} The Timeline's Tween Manager object. - */ - makeActive: function (tween) - { - return this.manager.makeActive(tween); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#play - * @since 3.0.0 - */ - play: function () - { - if (this.state === TWEEN_CONST.ACTIVE) - { - return; - } - - if (this.paused) - { - this.paused = false; - - this.manager.makeActive(this); - - return; - } - else - { - this.resetTweens(false); - - this.state = TWEEN_CONST.ACTIVE; - } - - var onStart = this.callbacks.onStart; - - if (onStart) - { - onStart.func.apply(onStart.scope, onStart.params); - } - - this.emit('start', this); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#nextState - * @since 3.0.0 - */ - nextState: function () - { - if (this.loopCounter > 0) - { - // Reset the elapsed time - // TODO: Probably ought to be set to the remainder from elapsed - duration - // as the tweens nearly always over-run by a few ms due to rAf - - this.elapsed = 0; - this.progress = 0; - - this.loopCounter--; - - var onLoop = this.callbacks.onLoop; - - if (onLoop) - { - onLoop.func.apply(onLoop.scope, onLoop.params); - } - - this.emit('loop', this, this.loopCounter); - - this.resetTweens(true); - - if (this.loopDelay > 0) - { - this.countdown = this.loopDelay; - this.state = TWEEN_CONST.LOOP_DELAY; - } - else - { - this.state = TWEEN_CONST.ACTIVE; - } - } - else if (this.completeDelay > 0) - { - this.countdown = this.completeDelay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.emit('complete', this); - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. - * Otherwise, returns false. - * - * @method Phaser.Tweens.Timeline#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - * - * @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager. - */ - update: function (timestamp, delta) - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - var rawDelta = delta; - - if (this.useFrames) - { - delta = 1 * this.manager.timeScale; - } - - delta *= this.timeScale; - - this.elapsed += delta; - this.progress = Math.min(this.elapsed / this.duration, 1); - - this.totalElapsed += delta; - this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); - - switch (this.state) - { - case TWEEN_CONST.ACTIVE: - - var stillRunning = this.totalData; - - for (var i = 0; i < this.totalData; i++) - { - var tween = this.data[i]; - - if (tween.update(timestamp, rawDelta)) - { - stillRunning--; - } - } - - var onUpdate = this.callbacks.onUpdate; - - if (onUpdate) - { - onUpdate.func.apply(onUpdate.scope, onUpdate.params); - } - - this.emit('update', this); - - // Anything still running? If not, we're done - if (stillRunning === 0) - { - this.nextState(); - } - - break; - - case TWEEN_CONST.LOOP_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.COMPLETE_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.emit('complete', this); - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - - break; - } - - return (this.state === TWEEN_CONST.PENDING_REMOVE); - }, - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - * - * @method Phaser.Tweens.Timeline#stop - * @since 3.0.0 - */ - stop: function () - { - this.state = TWEEN_CONST.PENDING_REMOVE; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#pause - * @since 3.0.0 - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - pause: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; - } - - this.paused = true; - - this._pausedState = this.state; - - this.state = TWEEN_CONST.PAUSED; - - this.emit('pause', this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#resume - * @since 3.0.0 - * - * @return {Phaser.Tweens.Timeline} This Timeline object. - */ - resume: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - this.paused = false; - - this.state = this._pausedState; - } - - this.emit('resume', this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#hasTarget - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - hasTarget: function (target) - { - for (var i = 0; i < this.data.length; i++) - { - if (this.data[i].hasTarget(target)) - { - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Timeline#destroy - * @since 3.0.0 - */ - destroy: function () - { - for (var i = 0; i < this.data.length; i++) - { - this.data[i].stop(); - } - - } -}); - -Timeline.TYPES = [ 'onStart', 'onUpdate', 'onLoop', 'onComplete', 'onYoyo' ]; - -module.exports = Timeline; - - -/***/ }), -/* 160 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(33); -var Defaults = __webpack_require__(100); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(62); -var GetEaseFunction = __webpack_require__(63); -var GetNewValue = __webpack_require__(73); -var GetTargets = __webpack_require__(102); -var GetTweens = __webpack_require__(162); -var GetValue = __webpack_require__(4); -var Timeline = __webpack_require__(159); -var TweenBuilder = __webpack_require__(72); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.TimelineBuilder - * @since 3.0.0 - * - * @param {Phaser.Tweens.TweenManager} manager - [description] - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Timeline} [description] - */ -var TimelineBuilder = function (manager, config) -{ - var timeline = new Timeline(manager); - - var tweens = GetTweens(config); - - if (tweens.length === 0) - { - timeline.paused = true; - - return timeline; - } - - var defaults = Clone(Defaults); - - defaults.targets = GetTargets(config); - - // totalDuration: If specified each tween in the Timeline is given an equal portion of the totalDuration - - var totalDuration = GetAdvancedValue(config, 'totalDuration', 0); - - if (totalDuration > 0) - { - defaults.duration = Math.floor(totalDuration / tweens.length); - } - else - { - defaults.duration = GetNewValue(config, 'duration', defaults.duration); - } - - defaults.delay = GetNewValue(config, 'delay', defaults.delay); - defaults.easeParams = GetValue(config, 'easeParams', defaults.easeParams); - defaults.ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), defaults.easeParams); - defaults.hold = GetNewValue(config, 'hold', defaults.hold); - defaults.repeat = GetNewValue(config, 'repeat', defaults.repeat); - defaults.repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - defaults.yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - defaults.flipX = GetBoolean(config, 'flipX', defaults.flipX); - defaults.flipY = GetBoolean(config, 'flipY', defaults.flipY); - - // Create the Tweens - for (var i = 0; i < tweens.length; i++) - { - timeline.queue(TweenBuilder(timeline, tweens[i], defaults)); - } - - timeline.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - timeline.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - timeline.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - timeline.paused = GetBoolean(config, 'paused', false); - timeline.useFrames = GetBoolean(config, 'useFrames', false); - - // Callbacks - - var scope = GetValue(config, 'callbackScope', timeline); - - var timelineArray = [ timeline ]; - - var onStart = GetValue(config, 'onStart', false); - - // The Start of the Timeline - if (onStart) - { - var onStartScope = GetValue(config, 'onStartScope', scope); - var onStartParams = GetValue(config, 'onStartParams', []); - - timeline.setCallback('onStart', onStart, timelineArray.concat(onStartParams), onStartScope); - } - - var onUpdate = GetValue(config, 'onUpdate', false); - - // Every time the Timeline updates (regardless which Tweens are running) - if (onUpdate) - { - var onUpdateScope = GetValue(config, 'onUpdateScope', scope); - var onUpdateParams = GetValue(config, 'onUpdateParams', []); - - timeline.setCallback('onUpdate', onUpdate, timelineArray.concat(onUpdateParams), onUpdateScope); - } - - var onLoop = GetValue(config, 'onLoop', false); - - // Called when the whole Timeline loops - if (onLoop) - { - var onLoopScope = GetValue(config, 'onLoopScope', scope); - var onLoopParams = GetValue(config, 'onLoopParams', []); - - timeline.setCallback('onLoop', onLoop, timelineArray.concat(onLoopParams), onLoopScope); - } - - var onYoyo = GetValue(config, 'onYoyo', false); - - // Called when a Timeline yoyos - if (onYoyo) - { - var onYoyoScope = GetValue(config, 'onYoyoScope', scope); - var onYoyoParams = GetValue(config, 'onYoyoParams', []); - - timeline.setCallback('onYoyo', onYoyo, timelineArray.concat(null, onYoyoParams), onYoyoScope); - } - - var onComplete = GetValue(config, 'onComplete', false); - - // Called when the Timeline completes, after the completeDelay, etc. - if (onComplete) - { - var onCompleteScope = GetValue(config, 'onCompleteScope', scope); - var onCompleteParams = GetValue(config, 'onCompleteParams', []); - - timeline.setCallback('onComplete', onComplete, timelineArray.concat(onCompleteParams), onCompleteScope); - } - - return timeline; -}; - -module.exports = TimelineBuilder; - - -/***/ }), -/* 161 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Defaults = __webpack_require__(100); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(62); -var GetEaseFunction = __webpack_require__(63); -var GetNewValue = __webpack_require__(73); -var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(101); -var Tween = __webpack_require__(99); -var TweenData = __webpack_require__(98); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.NumberTweenBuilder - * @since 3.0.0 - * - * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] - * @param {object} config - [description] - * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ -var NumberTweenBuilder = function (parent, config, defaults) -{ - if (defaults === undefined) - { - defaults = Defaults; - } - - // var tween = this.tweens.addCounter({ - // from: 100, - // to: 200, - // ... (normal tween properties) - // }) - // - // Then use it in your game via: - // - // tween.getValue() - - var from = GetValue(config, 'from', 0); - var to = GetValue(config, 'to', 1); - - var targets = [ { value: from } ]; - - var delay = GetNewValue(config, 'delay', defaults.delay); - var duration = GetNewValue(config, 'duration', defaults.duration); - var easeParams = GetValue(config, 'easeParams', defaults.easeParams); - var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); - var hold = GetNewValue(config, 'hold', defaults.hold); - var repeat = GetNewValue(config, 'repeat', defaults.repeat); - var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - - var data = []; - - var ops = GetValueOp('value', to); - - var tweenData = TweenData( - targets[0], - 'value', - ops.getEnd, - ops.getStart, - ease, - delay, - duration, - yoyo, - hold, - repeat, - repeatDelay, - false, - false - ); - - tweenData.start = from; - tweenData.current = from; - tweenData.to = to; - - data.push(tweenData); - - var tween = new Tween(parent, data, targets); - - tween.offset = GetAdvancedValue(config, 'offset', null); - tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - tween.paused = GetBoolean(config, 'paused', false); - tween.useFrames = GetBoolean(config, 'useFrames', false); - - // Set the Callbacks - var scope = GetValue(config, 'callbackScope', tween); - - // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params - var tweenArray = [ tween, null ]; - - var callbacks = Tween.TYPES; - - for (var i = 0; i < callbacks.length; i++) - { - var type = callbacks[i]; - - var callback = GetValue(config, type, false); - - if (callback) - { - var callbackScope = GetValue(config, type + 'Scope', scope); - var callbackParams = GetValue(config, type + 'Params', []); - - // The null is reset to be the Tween target - tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); - } - } - - return tween; -}; - -module.exports = NumberTweenBuilder; - - -/***/ }), -/* 162 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetTweens - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {array} [description] - */ -var GetTweens = function (config) -{ - var tweens = GetValue(config, 'tweens', null); - - if (tweens === null) - { - return []; - } - else if (typeof tweens === 'function') - { - tweens = tweens.call(); - } - - if (!Array.isArray(tweens)) - { - tweens = [ tweens ]; - } - - return tweens; -}; - -module.exports = GetTweens; - - -/***/ }), -/* 163 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RESERVED = __webpack_require__(304); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetProps - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {array} [description] - */ -var GetProps = function (config) -{ - var key; - var keys = []; - - // First see if we have a props object - - if (config.hasOwnProperty('props')) - { - for (key in config.props) - { - // Skip any property that starts with an underscore - if (key.substr(0, 1) !== '_') - { - keys.push({ key: key, value: config.props[key] }); - } - } - } - else - { - for (key in config) - { - // Skip any property that is in the ReservedProps list or that starts with an underscore - if (RESERVED.indexOf(key) === -1 && key.substr(0, 1) !== '_') - { - keys.push({ key: key, value: config[key] }); - } - } - } - - return keys; -}; - -module.exports = GetProps; - - -/***/ }), -/* 164 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); - -/** - * @typedef {object} TimerEventConfig - * - * @property {number} [delay=0] - [description] - * @property {number} [repeat=0] - [description] - * @property {boolean} [loop=false] - [description] - * @property {function} [callback] - [description] - * @property {*} [callbackScope] - [description] - * @property {Array.<*>} [args] - [description] - * @property {number} [timeScale=1] - [description] - * @property {number} [startAt=1] - [description] - * @property {boolean} [paused=false] - [description] - */ - -/** - * @classdesc - * [description] - * - * @class TimerEvent - * @memberOf Phaser.Time - * @constructor - * @since 3.0.0 - * - * @param {TimerEventConfig} config - [description] - */ -var TimerEvent = new Class({ - - initialize: - - function TimerEvent (config) - { - /** - * The delay in ms at which this TimerEvent fires. - * - * @name Phaser.Time.TimerEvent#delay - * @type {number} - * @default 0 - * @readOnly - * @since 3.0.0 - */ - this.delay = 0; - - /** - * The total number of times this TimerEvent will repeat before finishing. - * - * @name Phaser.Time.TimerEvent#repeat - * @type {number} - * @default 0 - * @readOnly - * @since 3.0.0 - */ - this.repeat = 0; - - /** - * If repeating this contains the current repeat count. - * - * @name Phaser.Time.TimerEvent#repeatCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.repeatCount = 0; - - /** - * True if this TimerEvent loops, otherwise false. - * - * @name Phaser.Time.TimerEvent#loop - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.loop = false; - - /** - * The callback that will be called when the TimerEvent occurs. - * - * @name Phaser.Time.TimerEvent#callback - * @type {function} - * @since 3.0.0 - */ - this.callback; - - /** - * The scope in which the callback will be called. - * - * @name Phaser.Time.TimerEvent#callbackScope - * @type {object} - * @since 3.0.0 - */ - this.callbackScope; - - /** - * Additional arguments to be passed to the callback. - * - * @name Phaser.Time.TimerEvent#args - * @type {array} - * @since 3.0.0 - */ - this.args; - - /** - * Scale the time causing this TimerEvent to update. - * - * @name Phaser.Time.TimerEvent#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Start this many MS into the elapsed (useful if you want a long duration with repeat, but for the first loop to fire quickly) - * - * @name Phaser.Time.TimerEvent#startAt - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.startAt = 0; - - /** - * [description] - * - * @name Phaser.Time.TimerEvent#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * [description] - * - * @name Phaser.Time.TimerEvent#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * [description] - * - * @name Phaser.Time.TimerEvent#hasDispatched - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.hasDispatched = false; - - this.reset(config); - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#reset - * @since 3.0.0 - * - * @param {TimerEventConfig} config - [description] - * - * @return {Phaser.Time.TimerEvent} This TimerEvent object. - */ - reset: function (config) - { - this.delay = GetFastValue(config, 'delay', 0); - - // Can also be set to -1 for an infinite loop (same as setting loop: true) - this.repeat = GetFastValue(config, 'repeat', 0); - - this.loop = GetFastValue(config, 'loop', false); - - this.callback = GetFastValue(config, 'callback', undefined); - - this.callbackScope = GetFastValue(config, 'callbackScope', this.callback); - - this.args = GetFastValue(config, 'args', []); - - this.timeScale = GetFastValue(config, 'timeScale', 1); - - this.startAt = GetFastValue(config, 'startAt', 0); - - this.paused = GetFastValue(config, 'paused', false); - - this.elapsed = this.startAt; - this.hasDispatched = false; - this.repeatCount = (this.repeat === -1 || this.loop) ? 999999999999 : this.repeat; - - return this; - }, - - /** - * Gets the progress of the current iteration, not factoring in repeats. - * - * @method Phaser.Time.TimerEvent#getProgress - * @since 3.0.0 - * - * @return {number} [description] - */ - getProgress: function () - { - return (this.elapsed / this.delay); - }, - - /** - * Gets the progress of the timer overall, factoring in repeats. - * - * @method Phaser.Time.TimerEvent#getOverallProgress - * @since 3.0.0 - * - * @return {number} [description] - */ - getOverallProgress: function () - { - if (this.repeat > 0) - { - var totalDuration = this.delay + (this.delay * this.repeat); - var totalElapsed = this.elapsed + (this.delay * (this.repeat - this.repeatCount)); - - return (totalElapsed / totalDuration); - } - else - { - return this.getProgress(); - } - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#getRepeatCount - * @since 3.0.0 - * - * @return {number} [description] - */ - getRepeatCount: function () - { - return this.repeatCount; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#getElapsed - * @since 3.0.0 - * - * @return {number} [description] - */ - getElapsed: function () - { - return this.elapsed; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#getElapsedSeconds - * @since 3.0.0 - * - * @return {number} [description] - */ - getElapsedSeconds: function () - { - return this.elapsed * 0.001; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#remove - * @since 3.0.0 - * - * @param {function} dispatchCallback - [description] - */ - remove: function (dispatchCallback) - { - if (dispatchCallback === undefined) { dispatchCallback = false; } - - this.elapsed = this.delay; - - this.hasDispatched = !dispatchCallback; - - this.repeatCount = 0; - }, - - /** - * [description] - * - * @method Phaser.Time.TimerEvent#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.callback = undefined; - this.callbackScope = undefined; - this.args = []; - } - -}); - -module.exports = TimerEvent; - - -/***/ }), -/* 165 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* @author Richard Davey -* @copyright 2018 Photon Storm Ltd. -* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} -*/ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A Global Plugin is installed just once into the Game owned Plugin Manager. - * It can listen for Game events and respond to them. - * - * @class BasePlugin - * @memberOf Phaser.Plugins - * @constructor - * @since 3.8.0 - * - * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager. - */ -var BasePlugin = new Class({ - - initialize: - - function BasePlugin (pluginManager) - { - /** - * A handy reference to the Plugin Manager that is responsible for this plugin. - * Can be used as a route to gain access to game systems and events. - * - * @name Phaser.Plugins.BasePlugin#pluginManager - * @type {Phaser.Plugins.PluginManager} - * @protected - * @since 3.8.0 - */ - this.pluginManager = pluginManager; - - /** - * A reference to the Game instance this plugin is running under. - * - * @name Phaser.Plugins.BasePlugin#game - * @type {Phaser.Game} - * @protected - * @since 3.8.0 - */ - this.game = pluginManager.game; - - /** - * A reference to the Scene that has installed this plugin. - * Only set if it's a Scene Plugin, otherwise `null`. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * You cannot use it during the `init` method, but you can during the `boot` method. - * - * @name Phaser.Plugins.BasePlugin#scene - * @type {?Phaser.Scene} - * @protected - * @since 3.8.0 - */ - this.scene; - - /** - * A reference to the Scene Systems of the Scene that has installed this plugin. - * Only set if it's a Scene Plugin, otherwise `null`. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * You cannot use it during the `init` method, but you can during the `boot` method. - * - * @name Phaser.Plugins.BasePlugin#systems - * @type {?Phaser.Scenes.Systems} - * @protected - * @since 3.8.0 - */ - this.systems; - }, - - /** - * Called by the PluginManager when this plugin is first instantiated. - * It will never be called again on this instance. - * In here you can set-up whatever you need for this plugin to run. - * If a plugin is set to automatically start then `BasePlugin.start` will be called immediately after this. - * - * @method Phaser.Plugins.BasePlugin#init - * @since 3.8.0 - */ - init: function () - { - }, - - /** - * Called by the PluginManager when this plugin is started. - * If a plugin is stopped, and then started again, this will get called again. - * Typically called immediately after `BasePlugin.init`. - * - * @method Phaser.Plugins.BasePlugin#start - * @since 3.8.0 - */ - start: function () - { - // Here are the game-level events you can listen to. - // At the very least you should offer a destroy handler for when the game closes down. - - // var eventEmitter = this.game.events; - - // eventEmitter.once('destroy', this.gameDestroy, this); - // eventEmitter.on('pause', this.gamePause, this); - // eventEmitter.on('resume', this.gameResume, this); - // eventEmitter.on('resize', this.gameResize, this); - // eventEmitter.on('prestep', this.gamePreStep, this); - // eventEmitter.on('step', this.gameStep, this); - // eventEmitter.on('poststep', this.gamePostStep, this); - // eventEmitter.on('prerender', this.gamePreRender, this); - // eventEmitter.on('postrender', this.gamePostRender, this); - }, - - /** - * Called by the PluginManager when this plugin is stopped. - * The game code has requested that your plugin stop doing whatever it does. - * It is now considered as 'inactive' by the PluginManager. - * Handle that process here (i.e. stop listening for events, etc) - * If the plugin is started again then `BasePlugin.start` will be called again. - * - * @method Phaser.Plugins.BasePlugin#stop - * @since 3.8.0 - */ - stop: function () - { - }, - - /** - * If this is a Scene Plugin (i.e. installed into a Scene) then this method is called when the Scene boots. - * By this point the plugin properties `scene` and `systems` will have already been set. - * In here you can listen for Scene events and set-up whatever you need for this plugin to run. - * - * @method Phaser.Plugins.BasePlugin#boot - * @since 3.8.0 - */ - boot: function () - { - // Here are the Scene events you can listen to. - // At the very least you should offer a destroy handler for when the Scene closes down. - - // var eventEmitter = this.systems.events; - - // eventEmitter.once('destroy', this.sceneDestroy, this); - // eventEmitter.on('start', this.sceneStart, this); - // eventEmitter.on('preupdate', this.scenePreUpdate, this); - // eventEmitter.on('update', this.sceneUpdate, this); - // eventEmitter.on('postupdate', this.scenePostUpdate, this); - // eventEmitter.on('pause', this.scenePause, this); - // eventEmitter.on('resume', this.sceneResume, this); - // eventEmitter.on('sleep', this.sceneSleep, this); - // eventEmitter.on('wake', this.sceneWake, this); - // eventEmitter.on('shutdown', this.sceneShutdown, this); - // eventEmitter.on('destroy', this.sceneDestroy, this); - }, - - /** - * Game instance has been destroyed. - * You must release everything in here, all references, all objects, free it all up. - * - * @method Phaser.Plugins.BasePlugin#destroy - * @since 3.8.0 - */ - destroy: function () - { - this.pluginManager = null; - this.game = null; - this.scene = null; - this.systems = null; - } - -}); - -module.exports = BasePlugin; - - -/***/ }), -/* 166 */, -/* 167 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var File = __webpack_require__(19); -var GetFastValue = __webpack_require__(1); -var GetURL = __webpack_require__(108); -var IsPlainObject = __webpack_require__(8); - -/** - * @classdesc - * A single Audio File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. - * - * @class HTML5AudioFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.AudioFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [urlConfig] - The absolute or relative URL to load this file from. - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var HTML5AudioFile = new Class({ - - Extends: File, - - initialize: - - function HTML5AudioFile (loader, key, urlConfig, audioConfig) - { - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - audioConfig = GetFastValue(config, 'config', audioConfig); - } - - var fileConfig = { - type: 'audio', - cache: loader.cacheManager.audio, - extension: urlConfig.type, - key: key, - url: urlConfig.url, - config: audioConfig - }; - - File.call(this, loader, fileConfig); - - // New properties specific to this class - this.locked = 'ontouchstart' in window; - this.loaded = false; - this.filesLoaded = 0; - this.filesTotal = 0; - }, - - /** - * Called when the file finishes loading. - * - * @method Phaser.Loader.FileTypes.HTML5AudioFile#onLoad - * @since 3.0.0 - */ - onLoad: function () - { - if (this.loaded) - { - return; - } - - this.loaded = true; - - this.loader.nextFile(this, true); - }, - - /** - * Called if the file errors while loading. - * - * @method Phaser.Loader.FileTypes.HTML5AudioFile#onError - * @since 3.0.0 - */ - onError: function () - { - for (var i = 0; i < this.data.length; i++) - { - var audio = this.data[i]; - - audio.oncanplaythrough = null; - audio.onerror = null; - } - - this.loader.nextFile(this, false); - }, - - /** - * Called during the file load progress. Is sent a DOM ProgressEvent. - * - * @method Phaser.Loader.FileTypes.HTML5AudioFile#onProgress - * @since 3.0.0 - */ - onProgress: function (event) - { - var audio = event.target; - - audio.oncanplaythrough = null; - audio.onerror = null; - - this.filesLoaded++; - - this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1); - - this.loader.emit('fileprogress', this, this.percentComplete); - - if (this.filesLoaded === this.filesTotal) - { - this.onLoad(); - } - }, - - /** - * Called by the Loader, starts the actual file downloading. - * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. - * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. - * - * @method Phaser.Loader.FileTypes.HTML5AudioFile#load - * @since 3.0.0 - */ - load: function () - { - this.data = []; - - var instances = (this.config && this.config.instances) || 1; - - this.filesTotal = instances; - this.filesLoaded = 0; - this.percentComplete = 0; - - for (var i = 0; i < instances; i++) - { - var audio = new Audio(); - - audio.dataset.name = this.key + ('0' + i).slice(-2); - audio.dataset.used = 'false'; - - 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); - } - - this.data.push(audio); - } - - for (i = 0; i < this.data.length; i++) - { - audio = this.data[i]; - audio.src = GetURL(this, this.loader.baseURL); - - if (!this.locked) - { - audio.load(); - } - } - - if (this.locked) - { - // This is super-dangerous but works. Race condition potential high. - // Is there another way? - setTimeout(this.onLoad.bind(this)); - } - } - -}); - -module.exports = HTML5AudioFile; - - -/***/ }), -/* 168 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var HTML5AudioFile = __webpack_require__(167); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.AudioFileConfig - * - * @property {string} key - The key of the file. Must be unique within the Loader and Audio Cache. - * @property {string} [urlConfig] - The absolute or relative URL to load the file from. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @property {AudioContext} [audioContext] - The AudioContext this file will use to process itself. - */ - -/** - * @classdesc - * A single Audio File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. - * - * @class AudioFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.AudioFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {any} [urlConfig] - The absolute or relative URL to load this file from in a config object. - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {AudioContext} [audioContext] - The AudioContext this file will use to process itself. - */ -var AudioFile = new Class({ - - Extends: File, - - initialize: - - // URL is an object created by AudioFile.findAudioURL - function AudioFile (loader, key, urlConfig, xhrSettings, audioContext) - { - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - audioContext = GetFastValue(config, 'context', audioContext); - } - - var fileConfig = { - type: 'audio', - cache: loader.cacheManager.audio, - extension: urlConfig.type, - responseType: 'arraybuffer', - key: key, - url: urlConfig.url, - xhrSettings: xhrSettings, - config: { context: audioContext } - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.AudioFile#onProcess - * @since 3.0.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - var _this = this; - - // interesting read https://github.com/WebAudio/web-audio-api/issues/1305 - this.config.context.decodeAudioData(this.xhrLoader.response, - function (audioBuffer) - { - _this.data = audioBuffer; - - _this.onProcessComplete(); - }, - function (e) - { - // eslint-disable-next-line no-console - console.error('Error decoding audio: ' + this.key + ' - ', e.message); - - _this.onProcessError(); - } - ); - - this.config.context = null; - } - -}); - -AudioFile.create = function (loader, key, urls, config, xhrSettings) -{ - var game = loader.systems.game; - var audioConfig = game.config.audio; - var deviceAudio = game.device.audio; - - // url may be inside key, which may be an object - if (IsPlainObject(key)) - { - urls = GetFastValue(key, 'url', []); - config = GetFastValue(key, 'config', {}); - } - - var urlConfig = AudioFile.getAudioURL(game, urls); - - if (!urlConfig) - { - return null; - } - - // https://developers.google.com/web/updates/2012/02/HTML5-audio-and-the-Web-Audio-API-are-BFFs - // var stream = GetFastValue(config, 'stream', false); - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - return new AudioFile(loader, key, urlConfig, xhrSettings, game.sound.context); - } - else - { - return new HTML5AudioFile(loader, key, urlConfig, config); - } -}; - -AudioFile.getAudioURL = function (game, urls) -{ - if (!Array.isArray(urls)) - { - urls = [ urls ]; - } - - for (var i = 0; i < urls.length; i++) - { - var url = GetFastValue(urls[i], 'url', urls[i]); - - if (url.indexOf('blob:') === 0 || url.indexOf('data:') === 0) - { - return url; - } - - var audioType = url.match(/\.([a-zA-Z0-9]+)($|\?)/); - - audioType = GetFastValue(urls[i], 'type', (audioType) ? audioType[1] : '').toLowerCase(); - - if (game.device.audio[audioType]) - { - return { - url: url, - type: audioType - }; - } - } - - return null; -}; - -/** - * Adds an Audio or HTML5Audio file, or array of audio files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.audio('title', [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ]); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Audio Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Audio Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.audio({ - * key: 'title', - * url: [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ] - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.AudioFileConfig` for more details. - * - * The URLs can be relative or absolute. If the URLs are relative the `Loader.baseURL` and `Loader.path` values will be prepended to them. - * - * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. - * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on - * browser support. - * - * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. - * - * Note: The ability to load this type of file will only be available if the Audio File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#audio - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.AudioFileConfig|Phaser.Loader.FileTypes.AudioFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {(string|string[])} [urls] - The absolute or relative URL to load the audio files from. - * @param {any} [config] - An object containing an `instances` property for HTML5Audio. Defaults to 1. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('audio', function (key, urls, config, xhrSettings) -{ - var game = this.systems.game; - var audioConfig = game.config.audio; - var deviceAudio = game.device.audio; - - if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - // Sounds are disabled, so skip loading audio - return this; - } - - var audioFile; - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - audioFile = AudioFile.create(this, key[i]); - - if (audioFile) - { - this.addFile(audioFile); - } - } - } - else - { - audioFile = AudioFile.create(this, key, urls, config, xhrSettings); - - if (audioFile) - { - this.addFile(audioFile); - } - } - - return this; -}); - -module.exports = AudioFile; - - -/***/ }), -/* 169 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MergeXHRSettings = __webpack_require__(107); - -/** - * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings - * and starts the download of it. It uses the Files own XHRSettings and merges them - * with the global XHRSettings object to set the xhr values before download. - * - * @function Phaser.Loader.XHRLoader - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - The File to download. - * @param {XHRSettingsObject} globalXHRSettings - The global XHRSettings object. - * - * @return {XMLHttpRequest} The XHR object. - */ -var XHRLoader = function (file, globalXHRSettings) -{ - var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings); - - var xhr = new XMLHttpRequest(); - - xhr.open('GET', file.src, config.async, config.user, config.password); - - xhr.responseType = file.xhrSettings.responseType; - xhr.timeout = config.timeout; - - if (config.header && config.headerValue) - { - xhr.setRequestHeader(config.header, config.headerValue); - } - - if (config.requestedWith) - { - xhr.setRequestHeader('X-Requested-With', config.requestedWith); - } - - if (config.overrideMimeType) - { - xhr.overrideMimeType(config.overrideMimeType); - } - - // After a successful request, the xhr.response property will contain the requested data as a DOMString, ArrayBuffer, Blob, or Document (depending on what was set for responseType.) - - xhr.onload = file.onLoad.bind(file, xhr); - xhr.onerror = file.onError.bind(file); - xhr.onprogress = file.onProgress.bind(file); - - // This is the only standard method, the ones above are browser additions (maybe not universal?) - // xhr.onreadystatechange - - xhr.send(); - - return xhr; -}; - -module.exports = XHRLoader; - - -/***/ }), -/* 170 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); -var ProcessKeyCombo = __webpack_require__(372); -var ResetKeyCombo = __webpack_require__(370); - -/** - * @callback KeyboardKeydownCallback - * - * @param {KeyboardEvent} event - The Keyboard Event. - */ - -/** - * @typedef {object} KeyComboConfig - * - * @property {boolean} [resetOnWrongKey=true] - If they press the wrong key do we reset the combo? - * @property {number} [maxKeyDelay=0] - The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. - * @property {boolean} [resetOnMatch=false] - If previously matched and they press the first key of the combo again, will it reset? - * @property {boolean} [deleteOnMatch=false] - If the combo matches, will it delete itself? - */ - -/** - * @classdesc - * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them - * it will emit a `keycombomatch` event from the Keyboard Manager. - * - * The keys to be listened for can be defined as: - * - * A string (i.e. 'ATARI') - * An array of either integers (key codes) or strings, or a mixture of both - * An array of objects (such as Key objects) with a public 'keyCode' property - * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) - * you could pass the following array of key codes: - * - * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); - * - * this.input.keyboard.on('keycombomatch', function (event) { - * console.log('Konami Code entered!'); - * }); - * ``` - * - * Or, to listen for the user entering the word PHASER: - * - * ```javascript - * this.input.keyboard.createCombo('PHASER'); - * ``` - * - * @class KeyCombo - * @memberOf Phaser.Input.Keyboard - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.KeyboardPlugin} keyboardPlugin - A reference to the Keyboard Plugin. - * @param {(string|integer[]|object[])} keys - The keys that comprise this combo. - * @param {KeyComboConfig} [config] - A Key Combo configuration object. - */ -var KeyCombo = new Class({ - - initialize: - - function KeyCombo (keyboardPlugin, keys, config) - { - if (config === undefined) { config = {}; } - - // Can't have a zero or single length combo (string or array based) - if (keys.length < 2) - { - return false; - } - - /** - * A reference to the Keyboard Manager - * - * @name Phaser.Input.Keyboard.KeyCombo#manager - * @type {Phaser.Input.Keyboard.KeyboardPlugin} - * @since 3.0.0 - */ - this.manager = keyboardPlugin; - - /** - * A flag that controls if this Key Combo is actively processing keys or not. - * - * @name Phaser.Input.Keyboard.KeyCombo#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * An array of the keycodes that comprise this combo. - * - * @name Phaser.Input.Keyboard.KeyCombo#keyCodes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.keyCodes = []; - - // if 'keys' is a string we need to get the keycode of each character in it - - for (var i = 0; i < keys.length; i++) - { - var char = keys[i]; - - if (typeof char === 'string') - { - this.keyCodes.push(char.toUpperCase().charCodeAt(0)); - } - else if (typeof char === 'number') - { - this.keyCodes.push(char); - } - else if (char.hasOwnProperty('keyCode')) - { - this.keyCodes.push(char.keyCode); - } - } - - /** - * The current keyCode the combo is waiting for. - * - * @name Phaser.Input.Keyboard.KeyCombo#current - * @type {integer} - * @since 3.0.0 - */ - this.current = this.keyCodes[0]; - - /** - * The current index of the key being waited for in the 'keys' string. - * - * @name Phaser.Input.Keyboard.KeyCombo#index - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.index = 0; - - /** - * The length of this combo (in keycodes) - * - * @name Phaser.Input.Keyboard.KeyCombo#size - * @type {number} - * @since 3.0.0 - */ - this.size = this.keyCodes.length; - - /** - * The time the previous key in the combo was matched. - * - * @name Phaser.Input.Keyboard.KeyCombo#timeLastMatched - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeLastMatched = 0; - - /** - * Has this Key Combo been matched yet? - * - * @name Phaser.Input.Keyboard.KeyCombo#matched - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.matched = false; - - /** - * The time the entire combo was matched. - * - * @name Phaser.Input.Keyboard.KeyCombo#timeMatched - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeMatched = 0; - - /** - * If they press the wrong key do we reset the combo? - * - * @name Phaser.Input.Keyboard.KeyCombo#resetOnWrongKey - * @type {boolean} - * @default 0 - * @since 3.0.0 - */ - this.resetOnWrongKey = GetFastValue(config, 'resetOnWrongKey', true); - - /** - * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. - * - * @name Phaser.Input.Keyboard.KeyCombo#maxKeyDelay - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.maxKeyDelay = GetFastValue(config, 'maxKeyDelay', 0); - - /** - * If previously matched and they press the first key of the combo again, will it reset? - * - * @name Phaser.Input.Keyboard.KeyCombo#resetOnMatch - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.resetOnMatch = GetFastValue(config, 'resetOnMatch', false); - - /** - * If the combo matches, will it delete itself? - * - * @name Phaser.Input.Keyboard.KeyCombo#deleteOnMatch - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.deleteOnMatch = GetFastValue(config, 'deleteOnMatch', false); - - var _this = this; - - var onKeyDownHandler = function (event) - { - if (_this.matched || !_this.enabled) - { - return; - } - - var matched = ProcessKeyCombo(event, _this); - - if (matched) - { - _this.manager.emit('keycombomatch', _this, event); - - if (_this.resetOnMatch) - { - ResetKeyCombo(_this); - } - else if (_this.deleteOnMatch) - { - _this.destroy(); - } - } - }; - - /** - * The internal Key Down handler. - * - * @name Phaser.Input.Keyboard.KeyCombo#onKeyDown - * @private - * @type {KeyboardKeydownCallback} - * @since 3.0.0 - */ - this.onKeyDown = onKeyDownHandler; - - this.manager.on('keydown', onKeyDownHandler); - }, - - /** - * How far complete is this combo? A value between 0 and 1. - * - * @name Phaser.Input.Keyboard.KeyCombo#progress - * @type {number} - * @readOnly - * @since 3.0.0 - */ - progress: { - - get: function () - { - return this.index / this.size; - } - - }, - - /** - * Destroys this Key Combo and all of its references. - * - * @method Phaser.Input.Keyboard.KeyCombo#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enabled = false; - this.keyCodes = []; - - this.manager.off('keydown', this.onKeyDown); - - this.manager = null; - } - -}); - -module.exports = KeyCombo; - - -/***/ }), -/* 171 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A generic Key object which can be passed to the Process functions (and so on) - * keycode must be an integer - * - * @class Key - * @memberOf Phaser.Input.Keyboard - * @constructor - * @since 3.0.0 - * - * @param {integer} keyCode - The keycode of this key. - */ -var Key = new Class({ - - initialize: - - function Key (keyCode) - { - /** - * The keycode of this key. - * - * @name Phaser.Input.Keyboard.Key#keyCode - * @type {integer} - * @since 3.0.0 - */ - this.keyCode = keyCode; - - /** - * The original DOM event. - * - * @name Phaser.Input.Keyboard.Key#originalEvent - * @type {KeyboardEvent} - * @since 3.0.0 - */ - this.originalEvent = undefined; - - /** - * Should this Key prevent event propagation? - * - * @name Phaser.Input.Keyboard.Key#preventDefault - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.preventDefault = true; - - /** - * Can this Key be processed? - * - * @name Phaser.Input.Keyboard.Key#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. - * - * @name Phaser.Input.Keyboard.Key#isDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isDown = false; - - /** - * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. - * - * @name Phaser.Input.Keyboard.Key#isUp - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.isUp = true; - - /** - * The down state of the ALT key, if pressed at the same time as this key. - * - * @name Phaser.Input.Keyboard.Key#altKey - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.altKey = false; - - /** - * The down state of the CTRL key, if pressed at the same time as this key. - * - * @name Phaser.Input.Keyboard.Key#ctrlKey - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.ctrlKey = false; - - /** - * The down state of the SHIFT key, if pressed at the same time as this key. - * - * @name Phaser.Input.Keyboard.Key#shiftKey - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.shiftKey = false; - - /** - * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. - * - * @name Phaser.Input.Keyboard.Key#location - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.location = 0; - - /** - * The timestamp when the key was last pressed down. - * - * @name Phaser.Input.Keyboard.Key#timeDown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeDown = 0; - - /** - * The number of milliseconds this key has been held down for. - * If the key is down this value holds the duration of that key press and is constantly updated. - * If the key is up it holds the duration of the previous down session. - * - * @name Phaser.Input.Keyboard.Key#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * The timestamp when the key was last released. - * - * @name Phaser.Input.Keyboard.Key#timeUp - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.timeUp = 0; - - /** - * If a key is held down this holds down the number of times the key has 'repeated'. - * - * @name Phaser.Input.Keyboard.Key#repeats - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.repeats = 0; - - /** - * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) - * - * @name Phaser.Input.Keyboard.Key#_justDown - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._justDown = false; - - /** - * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) - * - * @name Phaser.Input.Keyboard.Key#_justUp - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._justUp = false; - }, - - /** - * Resets this Key object back to its default un-pressed state. - * - * @method Phaser.Input.Keyboard.Key.reset - * @since 3.6.0 - * - * @return {Phaser.Input.Keyboard.Key} This Key instance. - */ - reset: function () - { - this.preventDefault = true; - this.enabled = true; - this.isDown = false; - this.isUp = true; - this.altKey = false; - this.ctrlKey = false; - this.shiftKey = false; - this.timeDown = 0; - this.duration = 0; - this.timeUp = 0; - this.repeats = 0; - this._justDown = false; - this._justUp = false; - - return this; - } - -}); - -module.exports = Key; - - -/***/ }), -/* 172 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Axis = __webpack_require__(174); -var Button = __webpack_require__(173); -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * A single Gamepad. - * - * These are created, updated and managed by the Gamepad Plugin. - * - * @class Gamepad - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.Gamepad.GamepadPlugin} manager - A reference to the Gamepad Plugin. - * @param {Pad} pad - The Gamepad object, as extracted from GamepadEvent. - */ -var Gamepad = new Class({ - - Extends: EventEmitter, - - initialize: - - function Gamepad (manager, pad) - { - EventEmitter.call(this); - - /** - * A reference to the Gamepad Plugin. - * - * @name Phaser.Input.Gamepad.Gamepad#manager - * @type {Phaser.Input.Gamepad.GamepadPlugin} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * A reference to the native Gamepad object that is connected to the browser. - * - * @name Phaser.Input.Gamepad.Gamepad#pad - * @type {any} - * @since 3.10.0 - */ - this.pad = pad; - - /** - * A string containing some information about the controller. - * - * This is not strictly specified, but in Firefox it will contain three pieces of information - * separated by dashes (-): two 4-digit hexadecimal strings containing the USB vendor and - * product id of the controller, and the name of the controller as provided by the driver. - * In Chrome it will contain the name of the controller as provided by the driver, - * followed by vendor and product 4-digit hexadecimal strings. - * - * @name Phaser.Input.Gamepad.Gamepad#id - * @type {string} - * @since 3.0.0 - */ - this.id = pad.id; - - /** - * An integer that is unique for each Gamepad currently connected to the system. - * This can be used to distinguish multiple controllers. - * Note that disconnecting a device and then connecting a new device may reuse the previous index. - * - * @name Phaser.Input.Gamepad.Gamepad#index - * @type {number} - * @since 3.0.0 - */ - this.index = pad.index; - - var buttons = []; - - for (var i = 0; i < pad.buttons.length; i++) - { - buttons.push(new Button(this, i)); - } - - /** - * An array of Gamepad Button objects, corresponding to the different buttons available on the Gamepad. - * - * @name Phaser.Input.Gamepad.Gamepad#buttons - * @type {Phaser.Input.Gamepad.Button[]} - * @since 3.0.0 - */ - this.buttons = buttons; - - var axes = []; - - for (i = 0; i < pad.axes.length; i++) - { - axes.push(new Axis(this, i)); - } - - /** - * An array of Gamepad Axis objects, corresponding to the different axes available on the Gamepad, if any. - * - * @name Phaser.Input.Gamepad.Gamepad#axes - * @type {Phaser.Input.Gamepad.Axis[]} - * @since 3.0.0 - */ - this.axes = axes; - - /** - * The Gamepad's Haptic Actuator (Vibration / Rumble support). - * This is highly experimental and only set if both present on the device, - * and exposed by both the hardware and browser. - * - * @name Phaser.Input.Gamepad.Gamepad#vibration - * @type {GamepadHapticActuator} - * @since 3.10.0 - */ - this.vibration = pad.vibrationActuator; - - // https://w3c.github.io/gamepad/#remapping - - var _noButton = { value: 0, pressed: false }; - - /** - * A reference to the Left Button in the Left Cluster. - * - * @name Phaser.Input.Gamepad.Gamepad#_LCLeft - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._LCLeft = (buttons[14]) ? buttons[14] : _noButton; - - /** - * A reference to the Right Button in the Left Cluster. - * - * @name Phaser.Input.Gamepad.Gamepad#_LCRight - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._LCRight = (buttons[15]) ? buttons[15] : _noButton; - - /** - * A reference to the Top Button in the Left Cluster. - * - * @name Phaser.Input.Gamepad.Gamepad#_LCTop - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._LCTop = (buttons[12]) ? buttons[12] : _noButton; - - /** - * A reference to the Bottom Button in the Left Cluster. - * - * @name Phaser.Input.Gamepad.Gamepad#_LCBottom - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._LCBottom = (buttons[13]) ? buttons[13] : _noButton; - - /** - * A reference to the Left Button in the Right Cluster. - * - * @name Phaser.Input.Gamepad.Gamepad#_RCLeft - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._RCLeft = (buttons[2]) ? buttons[2] : _noButton; - - /** - * A reference to the Right Button in the Right Cluster. - * - * @name Phaser.Input.Gamepad.Gamepad#_RCRight - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._RCRight = (buttons[1]) ? buttons[1] : _noButton; - - /** - * A reference to the Top Button in the Right Cluster. - * - * @name Phaser.Input.Gamepad.Gamepad#_RCTop - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._RCTop = (buttons[3]) ? buttons[3] : _noButton; - - /** - * A reference to the Bottom Button in the Right Cluster. - * - * @name Phaser.Input.Gamepad.Gamepad#_RCBottom - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._RCBottom = (buttons[0]) ? buttons[0] : _noButton; - - /** - * A reference to the Top Left Front Button (L1 Shoulder Button) - * - * @name Phaser.Input.Gamepad.Gamepad#_FBLeftTop - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._FBLeftTop = (buttons[4]) ? buttons[4] : _noButton; - - /** - * A reference to the Bottom Left Front Button (L2 Shoulder Button) - * - * @name Phaser.Input.Gamepad.Gamepad#_FBLeftBottom - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._FBLeftBottom = (buttons[6]) ? buttons[6] : _noButton; - - /** - * A reference to the Top Right Front Button (R1 Shoulder Button) - * - * @name Phaser.Input.Gamepad.Gamepad#_FBRightTop - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._FBRightTop = (buttons[5]) ? buttons[5] : _noButton; - - /** - * A reference to the Bottom Right Front Button (R2 Shoulder Button) - * - * @name Phaser.Input.Gamepad.Gamepad#_FBRightBottom - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._FBRightBottom = (buttons[7]) ? buttons[7] : _noButton; - - var _noAxis = { value: 0 }; - - /** - * A reference to the Horizontal Axis for the Left Stick. - * - * @name Phaser.Input.Gamepad.Gamepad#_HAxisLeft - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._HAxisLeft = (axes[0]) ? axes[0] : _noAxis; - - /** - * A reference to the Vertical Axis for the Left Stick. - * - * @name Phaser.Input.Gamepad.Gamepad#_VAxisLeft - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._VAxisLeft = (axes[1]) ? axes[1] : _noAxis; - - /** - * A reference to the Horizontal Axis for the Right Stick. - * - * @name Phaser.Input.Gamepad.Gamepad#_HAxisRight - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._HAxisRight = (axes[2]) ? axes[2] : _noAxis; - - /** - * A reference to the Vertical Axis for the Right Stick. - * - * @name Phaser.Input.Gamepad.Gamepad#_VAxisRight - * @type {Phaser.Input.Gamepad.Button} - * @private - * @since 3.10.0 - */ - this._VAxisRight = (axes[3]) ? axes[3] : _noAxis; - - /** - * A Vector2 containing the most recent values from the Gamepad's left axis stick. - * This is updated automatically as part of the Gamepad.update cycle. - * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. - * The values are based on the Axis thresholds. - * If the Gamepad does not have a left axis stick, the values will always be zero. - * - * @name Phaser.Input.Gamepad.Gamepad#leftStick - * @type {Phaser.Math.Vector2} - * @since 3.10.0 - */ - this.leftStick = new Vector2(); - - /** - * A Vector2 containing the most recent values from the Gamepad's right axis stick. - * This is updated automatically as part of the Gamepad.update cycle. - * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. - * The values are based on the Axis thresholds. - * If the Gamepad does not have a right axis stick, the values will always be zero. - * - * @name Phaser.Input.Gamepad.Gamepad#rightStick - * @type {Phaser.Math.Vector2} - * @since 3.10.0 - */ - this.rightStick = new Vector2(); - }, - - /** - * Gets the total number of axis this Gamepad claims to support. - * - * @method Phaser.Input.Gamepad.Gamepad#getAxisTotal - * @since 3.10.0 - * - * @return {integer} The total number of axes this Gamepad claims to support. - */ - getAxisTotal: function () - { - return this.axes.length; - }, - - /** - * Gets the value of an axis based on the given index. - * The index must be valid within the range of axes supported by this Gamepad. - * The return value will be a float between 0 and 1. - * - * @method Phaser.Input.Gamepad.Gamepad#getAxisValue - * @since 3.10.0 - * - * @param {integer} index - The index of the axes to get the value for. - * - * @return {number} The value of the axis, between 0 and 1. - */ - getAxisValue: function (index) - { - return this.axes[index].getValue(); - }, - - /** - * Sets the threshold value of all axis on this Gamepad. - * The value is a float between 0 and 1 and is the amount below which the axis is considered as not having been moved. - * - * @method Phaser.Input.Gamepad.Gamepad#setAxisThreshold - * @since 3.10.0 - * - * @param {number} value - A value between 0 and 1. - */ - setAxisThreshold: function (value) - { - for (var i = 0; i < this.axes.length; i++) - { - this.axes[i].threshold = value; - } - }, - - /** - * Gets the total number of buttons this Gamepad claims to have. - * - * @method Phaser.Input.Gamepad.Gamepad#getButtonTotal - * @since 3.10.0 - * - * @return {integer} The total number of buttons this Gamepad claims to have. - */ - getButtonTotal: function () - { - return this.buttons.length; - }, - - /** - * Gets the value of a button based on the given index. - * The index must be valid within the range of buttons supported by this Gamepad. - * - * The return value will be either 0 or 1 for an analogue button, or a float between 0 and 1 - * for a pressure-sensitive digital button, such as the shoulder buttons on a Dual Shock. - * - * @method Phaser.Input.Gamepad.Gamepad#getButtonValue - * @since 3.10.0 - * - * @param {integer} index - The index of the button to get the value for. - * - * @return {number} The value of the button, between 0 and 1. - */ - getButtonValue: function (index) - { - return this.buttons[index].value; - }, - - /** - * Returns if the button is pressed down or not. - * The index must be valid within the range of buttons supported by this Gamepad. - * - * @method Phaser.Input.Gamepad.Gamepad#isButtonDown - * @since 3.10.0 - * - * @param {integer} index - The index of the button to get the value for. - * - * @return {boolean} `true` if the button is considered as being pressed down, otherwise `false`. - */ - isButtonDown: function (index) - { - return this.buttons[index].pressed; - }, - - /** - * Internal update handler for this Gamepad. - * Called automatically by the Gamepad Manager as part of its update. - * - * @method Phaser.Input.Gamepad.Gamepad#update - * @private - * @since 3.0.0 - */ - update: function (pad) - { - var i; - - // Sync the button values - - var localButtons = this.buttons; - var gamepadButtons = pad.buttons; - - var len = localButtons.length; - - for (i = 0; i < len; i++) - { - localButtons[i].update(gamepadButtons[i].value); - } - - // Sync the axis values - - var localAxes = this.axes; - var gamepadAxes = pad.axes; - - len = localAxes.length; - - for (i = 0; i < len; i++) - { - localAxes[i].update(gamepadAxes[i]); - } - - if (len >= 2) - { - this.leftStick.set(localAxes[0].getValue(), localAxes[1].getValue()); - - if (len >= 4) - { - this.rightStick.set(localAxes[2].getValue(), localAxes[3].getValue()); - } - } - }, - - /** - * Destroys this Gamepad instance, its buttons and axes, and releases external references it holds. - * - * @method Phaser.Input.Gamepad.Gamepad#destroy - * @since 3.10.0 - */ - destroy: function () - { - this.removeAllListeners(); - - this.manager = null; - this.pad = null; - - var i; - - for (i = 0; i < this.buttons.length; i++) - { - this.buttons[i].destroy(); - } - - for (i = 0; i < this.axes.length; i++) - { - this.axes[i].destroy(); - } - - this.buttons = []; - this.axes = []; - }, - - /** - * Is this Gamepad currently connected or not? - * - * @name Phaser.Input.Gamepad.Gamepad#connected - * @type {boolean} - * @default true - * @since 3.0.0 - */ - connected: { - - get: function () - { - return this.pad.connected; - } - - }, - - /** - * A timestamp containing the most recent time this Gamepad was updated. - * - * @name Phaser.Input.Gamepad.Gamepad#timestamp - * @type {number} - * @since 3.0.0 - */ - timestamp: { - - get: function () - { - return this.pad.timestamp; - } - - }, - - /** - * Is the Gamepad's Left button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad left button under standard Gamepad mapping. - * - * @name Phaser.Input.Gamepad.Gamepad#left - * @type {boolean} - * @since 3.10.0 - */ - left: { - - get: function () - { - return this._LCLeft.pressed; - } - - }, - - /** - * Is the Gamepad's Right button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad right button under standard Gamepad mapping. - * - * @name Phaser.Input.Gamepad.Gamepad#right - * @type {boolean} - * @since 3.10.0 - */ - right: { - - get: function () - { - return this._LCRight.pressed; - } - - }, - - /** - * Is the Gamepad's Up button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad up button under standard Gamepad mapping. - * - * @name Phaser.Input.Gamepad.Gamepad#up - * @type {boolean} - * @since 3.10.0 - */ - up: { - - get: function () - { - return this._LCTop.pressed; - } - - }, - - /** - * Is the Gamepad's Down button being pressed? - * If the Gamepad doesn't have this button it will always return false. - * This is the d-pad down button under standard Gamepad mapping. - * - * @name Phaser.Input.Gamepad.Gamepad#down - * @type {boolean} - * @since 3.10.0 - */ - down: { - - get: function () - { - return this._LCBottom.pressed; - } - - }, - - /** - * Is the Gamepad's bottom button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the X button. - * On an XBox controller it's the A button. - * - * @name Phaser.Input.Gamepad.Gamepad#A - * @type {boolean} - * @since 3.10.0 - */ - A: { - - get: function () - { - return this._RCBottom.pressed; - } - - }, - - /** - * Is the Gamepad's top button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the Triangle button. - * On an XBox controller it's the Y button. - * - * @name Phaser.Input.Gamepad.Gamepad#Y - * @type {boolean} - * @since 3.10.0 - */ - Y: { - - get: function () - { - return this._RCTop.pressed; - } - - }, - - /** - * Is the Gamepad's left button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the Square button. - * On an XBox controller it's the X button. - * - * @name Phaser.Input.Gamepad.Gamepad#X - * @type {boolean} - * @since 3.10.0 - */ - X: { - - get: function () - { - return this._RCLeft.pressed; - } - - }, - - /** - * Is the Gamepad's right button in the right button cluster being pressed? - * If the Gamepad doesn't have this button it will always return false. - * On a Dual Shock controller it's the Circle button. - * On an XBox controller it's the B button. - * - * @name Phaser.Input.Gamepad.Gamepad#B - * @type {boolean} - * @since 3.10.0 - */ - B: { - - get: function () - { - return this._RCRight.pressed; - } - - }, - - /** - * Returns the value of the Gamepad's top left shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the L1 button. - * On an XBox controller it's the LB button. - * - * @name Phaser.Input.Gamepad.Gamepad#L1 - * @type {number} - * @since 3.10.0 - */ - L1: { - - get: function () - { - return this._FBLeftTop.value; - } - - }, - - /** - * Returns the value of the Gamepad's bottom left shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the L2 button. - * On an XBox controller it's the LT button. - * - * @name Phaser.Input.Gamepad.Gamepad#L2 - * @type {number} - * @since 3.10.0 - */ - L2: { - - get: function () - { - return this._FBLeftBottom.value; - } - - }, - - /** - * Returns the value of the Gamepad's top right shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the R1 button. - * On an XBox controller it's the RB button. - * - * @name Phaser.Input.Gamepad.Gamepad#R1 - * @type {number} - * @since 3.10.0 - */ - R1: { - - get: function () - { - return this._FBRightTop.value; - } - - }, - - /** - * Returns the value of the Gamepad's bottom right shoulder button. - * If the Gamepad doesn't have this button it will always return zero. - * The value is a float between 0 and 1, corresponding to how depressed the button is. - * On a Dual Shock controller it's the R2 button. - * On an XBox controller it's the RT button. - * - * @name Phaser.Input.Gamepad.Gamepad#R2 - * @type {number} - * @since 3.10.0 - */ - R2: { - - get: function () - { - return this._FBRightBottom.value; - } - - } - -}); - -module.exports = Gamepad; - - -/***/ }), -/* 173 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * Contains information about a specific button on a Gamepad. - * Button objects are created automatically by the Gamepad as they are needed. - * - * @class Button - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.Gamepad.Gamepad} pad - A reference to the Gamepad that this Button belongs to. - * @param {integer} index - The index of this Button. - */ -var Button = new Class({ - - initialize: - - function Button (pad, index) - { - /** - * A reference to the Gamepad that this Button belongs to. - * - * @name Phaser.Input.Gamepad.Button#pad - * @type {Phaser.Input.Gamepad.Gamepad} - * @since 3.0.0 - */ - this.pad = pad; - - /** - * An event emitter to use to emit the button events. - * - * @name Phaser.Input.Gamepad.Button#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events = pad.manager; - - /** - * The index of this Button. - * - * @name Phaser.Input.Gamepad.Button#index - * @type {integer} - * @since 3.0.0 - */ - this.index = index; - - /** - * Between 0 and 1. - * - * @name Phaser.Input.Gamepad.Button#value - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.value = 0; - - /** - * Can be set for analogue buttons to enable a 'pressure' threshold, - * before a button is considered as being 'pressed'. - * - * @name Phaser.Input.Gamepad.Button#threshold - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.threshold = 1; - - /** - * Is the Button being pressed down or not? - * - * @name Phaser.Input.Gamepad.Button#pressed - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.pressed = false; - }, - - /** - * Internal update handler for this Button. - * Called automatically by the Gamepad as part of its update. - * - * @method Phaser.Input.Gamepad.Button#update - * @private - * @since 3.0.0 - * - * @param {number} value - The GamepadButton value. - */ - update: function (value) - { - this.value = value; - - var pad = this.pad; - var index = this.index; - - if (value >= this.threshold) - { - if (!this.pressed) - { - this.pressed = true; - this.events.emit('down', pad, this, value); - this.pad.emit('down', index, value, this); - } - } - else if (this.pressed) - { - this.pressed = false; - this.events.emit('up', pad, this, value); - this.pad.emit('up', index, value, this); - } - }, - - /** - * Destroys this Button instance and releases external references it holds. - * - * @method Phaser.Input.Gamepad.Button#destroy - * @since 3.10.0 - */ - destroy: function () - { - this.pad = null; - this.events = null; - } - -}); - -module.exports = Button; - - -/***/ }), -/* 174 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * Contains information about a specific Gamepad Axis. - * Axis objects are created automatically by the Gamepad as they are needed. - * - * @class Axis - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.Gamepad.Gamepad} pad - A reference to the Gamepad that this Axis belongs to. - * @param {integer} index - The index of this Axis. - */ -var Axis = new Class({ - - initialize: - - function Axis (pad, index) - { - /** - * A reference to the Gamepad that this Axis belongs to. - * - * @name Phaser.Input.Gamepad.Axis#pad - * @type {Phaser.Input.Gamepad.Gamepad} - * @since 3.0.0 - */ - this.pad = pad; - - /** - * An event emitter to use to emit the axis events. - * - * @name Phaser.Input.Gamepad.Axis#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events = pad.events; - - /** - * The index of this Axis. - * - * @name Phaser.Input.Gamepad.Axis#index - * @type {integer} - * @since 3.0.0 - */ - this.index = index; - - /** - * The raw axis value, between -1 and 1 with 0 being dead center. - * Use the method `getValue` to get a normalized value with the threshold applied. - * - * @name Phaser.Input.Gamepad.Axis#value - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.value = 0; - - /** - * Movement tolerance threshold below which axis values are ignored in `getValue`. - * - * @name Phaser.Input.Gamepad.Axis#threshold - * @type {float} - * @default 0.1 - * @since 3.0.0 - */ - this.threshold = 0.1; - }, - - /** - * Internal update handler for this Axis. - * Called automatically by the Gamepad as part of its update. - * - * @method Phaser.Input.Gamepad.Axis#update - * @private - * @since 3.0.0 - * - * @param {float} value - The value of the axis movement. - */ - update: function (value) - { - this.value = value; - }, - - /** - * Applies the `threshold` value to the axis and returns it. - * - * @method Phaser.Input.Gamepad.Axis#getValue - * @since 3.0.0 - * - * @return {float} The axis value, adjusted for the movement threshold. - */ - getValue: function () - { - return (Math.abs(this.value) < this.threshold) ? 0 : this.value; - }, - - /** - * Destroys this Axis instance and releases external references it holds. - * - * @method Phaser.Input.Gamepad.Axis#destroy - * @since 3.10.0 - */ - destroy: function () - { - this.pad = null; - this.events = null; - } - -}); - -module.exports = Axis; - - -/***/ }), -/* 175 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @callback HitAreaCallback - * - * @param {any} hitArea - The hit area object. - * @param {number} x - The translated x coordinate of the hit test event. - * @param {number} y - The translated y coordinate of the hit test event. - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that invoked the hit test. - * - * @return {boolean} `true` if the coordinates fall within the space of the hitArea, otherwise `false`. - */ - -/** - * @typedef {object} Phaser.Input.InteractiveObject - * - * @property {Phaser.GameObjects.GameObject} gameObject - The Game Object to which this Interactive Object is bound. - * @property {boolean} enabled - Is this Interactive Object currently enabled for input events? - * @property {boolean} draggable - Is this Interactive Object draggable? Enable with `InputPlugin.setDraggable`. - * @property {boolean} dropZone - Is this Interactive Object a drag-targets drop zone? Set when the object is created. - * @property {(boolean|string)} cursor - Should this Interactive Object change the cursor (via css) when over? (desktop only) - * @property {?Phaser.GameObjects.GameObject} target - An optional drop target for a draggable Interactive Object. - * @property {Phaser.Cameras.Scene2D.Camera} camera - The most recent Camera to be tested against this Interactive Object. - * @property {any} hitArea - The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. - * @property {HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests. - * @property {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. - * @property {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. - * @property {(0|1|2)} dragState - The current drag state of this Interactive Object. 0 = Not being dragged, 1 = being checked for drag, or 2 = being actively dragged. - * @property {number} dragStartX - The x coordinate that the Pointer started dragging this Interactive Object from. - * @property {number} dragStartY - The y coordinate that the Pointer started dragging this Interactive Object from. - * @property {number} dragX - The x coordinate that this Interactive Object is currently being dragged to. - * @property {number} dragY - The y coordinate that this Interactive Object is currently being dragged to. - */ - -/** - * Creates a new Interactive Object. - * - * This is called automatically by the Input Manager when you enable a Game Object for input. - * - * The resulting Interactive Object is mapped to the Game Object's `input` property. - * - * @function Phaser.Input.CreateInteractiveObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to which this Interactive Object is bound. - * @param {any} hitArea - The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. - * @param {HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests. - * - * @return {Phaser.Input.InteractiveObject} The new Interactive Object. - */ -var CreateInteractiveObject = function (gameObject, hitArea, hitAreaCallback) -{ - return { - - gameObject: gameObject, - - enabled: true, - draggable: false, - dropZone: false, - cursor: false, - - target: null, - - camera: null, - - hitArea: hitArea, - hitAreaCallback: hitAreaCallback, - - localX: 0, - localY: 0, - - // 0 = Not being dragged - // 1 = Being checked for dragging - // 2 = Being dragged - dragState: 0, - - dragStartX: 0, - dragStartY: 0, - - dragX: 0, - dragY: 0 - - }; -}; - -module.exports = CreateInteractiveObject; - - -/***/ }), -/* 176 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Commands = __webpack_require__(119); -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Graphics#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - * @param {CanvasRenderingContext2D} [renderTargetCtx] - The target rendering context. - * @param {boolean} allowClip - [description] - */ -var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - var srcX = src.x; - var srcY = src.y; - var srcScaleX = src.scaleX; - var srcScaleY = src.scaleY; - var srcRotation = src.rotation; - var commandBuffer = src.commandBuffer; - var ctx = renderTargetCtx || renderer.currentContext; - var lineAlpha = 1.0; - var fillAlpha = 1.0; - var lineColor = 0; - var fillColor = 0; - var lineWidth = 1.0; - var red = 0; - var green = 0; - var blue = 0; - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - ctx.save(); - if (parentMatrix) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); - ctx.rotate(srcRotation); - ctx.scale(srcScaleX, srcScaleY); - ctx.fillStyle = '#fff'; - ctx.globalAlpha = src.alpha; - - for (var index = 0, length = commandBuffer.length; index < length; ++index) - { - var commandID = commandBuffer[index]; - - switch (commandID) - { - case Commands.ARC: - ctx.arc( - commandBuffer[index + 1], - commandBuffer[index + 2], - commandBuffer[index + 3], - commandBuffer[index + 4], - commandBuffer[index + 5], - commandBuffer[index + 6] - ); - index += 6; - break; - - case Commands.LINE_STYLE: - lineWidth = commandBuffer[index + 1]; - lineColor = commandBuffer[index + 2]; - lineAlpha = commandBuffer[index + 3]; - red = ((lineColor & 0xFF0000) >>> 16); - green = ((lineColor & 0xFF00) >>> 8); - blue = (lineColor & 0xFF); - ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + lineAlpha + ')'; - ctx.lineWidth = lineWidth; - index += 3; - break; - - case Commands.FILL_STYLE: - fillColor = commandBuffer[index + 1]; - fillAlpha = commandBuffer[index + 2]; - red = ((fillColor & 0xFF0000) >>> 16); - green = ((fillColor & 0xFF00) >>> 8); - blue = (fillColor & 0xFF); - ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; - index += 2; - break; - - case Commands.BEGIN_PATH: - ctx.beginPath(); - break; - - case Commands.CLOSE_PATH: - ctx.closePath(); - break; - - case Commands.FILL_PATH: - if (!allowClip) - { - ctx.fill(); - } - break; - - case Commands.STROKE_PATH: - if (!allowClip) - { - ctx.stroke(); - } - break; - - case Commands.FILL_RECT: - if (!allowClip) - { - ctx.fillRect( - commandBuffer[index + 1], - commandBuffer[index + 2], - commandBuffer[index + 3], - commandBuffer[index + 4] - ); - } - else - { - ctx.rect( - commandBuffer[index + 1], - commandBuffer[index + 2], - commandBuffer[index + 3], - commandBuffer[index + 4] - ); - } - index += 4; - break; - - case Commands.FILL_TRIANGLE: - ctx.beginPath(); - ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); - ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); - ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); - ctx.closePath(); - if (!allowClip) - { - ctx.fill(); - } - index += 6; - break; - - case Commands.STROKE_TRIANGLE: - ctx.beginPath(); - ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); - ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); - ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); - ctx.closePath(); - if (!allowClip) - { - ctx.stroke(); - } - index += 6; - break; - - case Commands.LINE_TO: - ctx.lineTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.MOVE_TO: - ctx.moveTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.LINE_FX_TO: - ctx.lineTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 5; - break; - - case Commands.MOVE_FX_TO: - ctx.moveTo( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 5; - break; - - case Commands.SAVE: - ctx.save(); - break; - - case Commands.RESTORE: - ctx.restore(); - break; - - case Commands.TRANSLATE: - ctx.translate( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.SCALE: - ctx.scale( - commandBuffer[index + 1], - commandBuffer[index + 2] - ); - index += 2; - break; - - case Commands.ROTATE: - ctx.rotate( - commandBuffer[index + 1] - ); - index += 1; - break; - - default: - // console.error('Phaser: Invalid Graphics Command ID ' + commandID); - break; - } - } - - ctx.restore(); -}; - -module.exports = GraphicsCanvasRenderer; - - -/***/ }), -/* 177 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the circumference of the given Ellipse. - * - * @function Phaser.Geom.Ellipse.Circumference - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference of. - * - * @return {number} The circumference of th Ellipse. - */ -var Circumference = function (ellipse) -{ - var rx = ellipse.width / 2; - var ry = ellipse.height / 2; - var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2); - - return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h))))); -}; - -module.exports = Circumference; - - -/***/ }), -/* 178 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circumference = __webpack_require__(177); -var CircumferencePoint = __webpack_require__(113); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); - -/** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, - * based on the given quantity or stepRate values. - * - * @function Phaser.Geom.Ellipse.GetPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [out,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the points from. - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. - * @param {(array|Phaser.Geom.Point[])} [out] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {(array|Phaser.Geom.Point[])} An array of Point objects pertaining to the points around the circumference of the ellipse. - */ -var GetPoints = function (ellipse, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = Circumference(ellipse) / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); - - out.push(CircumferencePoint(ellipse, angle)); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 179 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CircumferencePoint = __webpack_require__(113); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @function Phaser.Geom.Ellipse.GetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. - * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. - */ -var GetPoint = function (ellipse, position, out) -{ - if (out === undefined) { out = new Point(); } - - var angle = FromPercent(position, 0, MATH_CONST.PI2); - - return CircumferencePoint(ellipse, angle, out); -}; - -module.exports = GetPoint; - - -/***/ }), -/* 180 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// This is from the quickselect npm package: https://www.npmjs.com/package/quickselect -// Coded by https://www.npmjs.com/~mourner (Vladimir Agafonkin) - -// https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm - -// Floyd-Rivest selection algorithm: -// Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right]; -// The k-th element will have the (k - left + 1)th smallest value in [left, right] - -/** - * [description] - * - * @function Phaser.Utils.Array.QuickSelect - * @since 3.0.0 - * - * @param {array} arr - [description] - * @param {number} k - [description] - * @param {number} left - [description] - * @param {number} right - [description] - * @param {function} compare - [description] - */ -var QuickSelect = function (arr, k, left, right, compare) -{ - left = left || 0; - right = right || (arr.length - 1); - compare = compare || defaultCompare; - - while (right > left) - { - if (right - left > 600) - { - var n = right - left + 1; - var m = k - left + 1; - var z = Math.log(n); - var s = 0.5 * Math.exp(2 * z / 3); - var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); - var newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); - var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); - - QuickSelect(arr, k, newLeft, newRight, compare); - } - - var t = arr[k]; - var i = left; - var j = right; - - swap(arr, left, k); - - if (compare(arr[right], t) > 0) - { - swap(arr, left, right); - } - - while (i < j) - { - swap(arr, i, j); - - i++; - j--; - - while (compare(arr[i], t) < 0) - { - i++; - } - - while (compare(arr[j], t) > 0) - { - j--; - } - } - - if (compare(arr[left], t) === 0) - { - swap(arr, left, j); - } - else - { - j++; - swap(arr, j, right); - } - - if (j <= k) - { - left = j + 1; - } - - if (k <= j) - { - right = j - 1; - } - } -}; - -function swap (arr, i, j) -{ - var tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; -} - -function defaultCompare (a, b) -{ - return a < b ? -1 : a > b ? 1 : 0; -} - -module.exports = QuickSelect; - - -/***/ }), -/* 181 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Transposes the elements of the given matrix (array of arrays). -// The transpose of a matrix is a new matrix whose rows are the columns of the original. - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.TransposeMatrix - * @since 3.0.0 - * - * @param {array} array - The array matrix to transpose. - * - * @return {array} A new array matrix which is a transposed version of the given array. - */ -var TransposeMatrix = function (array) -{ - var sourceRowCount = array.length; - var sourceColCount = array[0].length; - - var result = new Array(sourceColCount); - - for (var i = 0; i < sourceColCount; i++) - { - result[i] = new Array(sourceRowCount); - - for (var j = sourceRowCount - 1; j > -1; j--) - { - result[i][j] = array[j][i]; - } - } - - return result; -}; - -module.exports = TransposeMatrix; - - -/***/ }), -/* 182 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Textures.Parsers - */ - -module.exports = { - - AtlasXML: __webpack_require__(514), - Canvas: __webpack_require__(513), - Image: __webpack_require__(512), - JSONArray: __webpack_require__(511), - JSONHash: __webpack_require__(510), - SpriteSheet: __webpack_require__(509), - SpriteSheetFromAtlas: __webpack_require__(508), - UnityYAML: __webpack_require__(507) - -}; - - -/***/ }), -/* 183 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(22); -var Class = __webpack_require__(0); -var IsSizePowerOfTwo = __webpack_require__(85); -var ScaleModes = __webpack_require__(59); - -/** - * @classdesc - * A Texture Source is the encapsulation of the actual source data for a Texture. - * This is typically an Image Element, loaded from the file system or network, or a Canvas Element. - * - * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. - * - * @class TextureSource - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture this TextureSource belongs to. - * @param {(HTMLImageElement|HTMLCanvasElement)} source - The source image data. - * @param {integer} [width] - Optional width of the source image. If not given it's derived from the source itself. - * @param {integer} [height] - Optional height of the source image. If not given it's derived from the source itself. - */ -var TextureSource = new Class({ - - initialize: - - function TextureSource (texture, source, width, height) - { - var game = texture.manager.game; - - /** - * The Texture this TextureSource belongs to. - * - * @name Phaser.Textures.TextureSource#renderer - * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} - * @since 3.7.0 - */ - this.renderer = game.renderer; - - /** - * The Texture this TextureSource belongs to. - * - * @name Phaser.Textures.TextureSource#texture - * @type {string} - * @since 3.0.0 - */ - this.texture = texture; - - /** - * The source image data. This is either an Image Element, or a Canvas Element. - * - * @name Phaser.Textures.TextureSource#image - * @type {(HTMLImageElement|HTMLCanvasElement)} - * @since 3.0.0 - */ - this.image = source; - - /** - * Currently un-used. - * - * @name Phaser.Textures.TextureSource#compressionAlgorithm - * @type {integer} - * @default null - * @since 3.0.0 - */ - this.compressionAlgorithm = null; - - /** - * The resolution of the source image. - * - * @name Phaser.Textures.TextureSource#resolution - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.resolution = 1; - - /** - * The width of the source image. If not specified in the constructor it will check - * the `naturalWidth` and then `width` properties of the source image. - * - * @name Phaser.Textures.TextureSource#width - * @type {integer} - * @since 3.0.0 - */ - this.width = width || source.naturalWidth || source.width || 0; - - /** - * The height of the source image. If not specified in the constructor it will check - * the `naturalHeight` and then `height` properties of the source image. - * - * @name Phaser.Textures.TextureSource#height - * @type {integer} - * @since 3.0.0 - */ - this.height = height || source.naturalHeight || source.height || 0; - - /** - * The Scale Mode the image will use when rendering. - * Either Linear or Nearest. - * - * @name Phaser.Textures.TextureSource#scaleMode - * @type {number} - * @since 3.0.0 - */ - this.scaleMode = ScaleModes.DEFAULT; - - /** - * Is the source image a Canvas Element? - * - * @name Phaser.Textures.TextureSource#isCanvas - * @type {boolean} - * @since 3.0.0 - */ - this.isCanvas = (source instanceof HTMLCanvasElement); - - /** - * Are the source image dimensions a power of two? - * - * @name Phaser.Textures.TextureSource#isPowerOf2 - * @type {boolean} - * @since 3.0.0 - */ - this.isPowerOf2 = IsSizePowerOfTwo(this.width, this.height); - - /** - * The WebGL Texture of the source image. - * - * @name Phaser.Textures.TextureSource#glTexture - * @type {?WebGLTexture} - * @default null - * @since 3.0.0 - */ - this.glTexture = null; - - this.init(game); - }, - - /** - * Creates a WebGL Texture, if required, and sets the Texture filter mode. - * - * @method Phaser.Textures.TextureSource#init - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser Game instance. - */ - init: function (game) - { - if (this.renderer && this.renderer.gl) - { - if (this.isCanvas) - { - this.glTexture = this.renderer.canvasToTexture(this.image); - } - else - { - this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); - } - } - - if (game.config.pixelArt) - { - this.setFilter(1); - } - }, - - /** - * Sets the Filter Mode for this Texture. - * - * The mode can be either Linear, the default, or Nearest. - * - * For pixel-art you should use Nearest. - * - * @method Phaser.Textures.TextureSource#setFilter - * @since 3.0.0 - * - * @param {Phaser.Textures.FilterMode} filterMode - The Filter Mode. - */ - setFilter: function (filterMode) - { - if (this.renderer.gl) - { - this.renderer.setTextureFilter(this.glTexture, filterMode); - } - }, - - /** - * If this TextureSource is backed by a Canvas and is running under WebGL, - * it updates the WebGLTexture using the canvas data. - * - * @method Phaser.Textures.TextureSource#update - * @since 3.7.0 - */ - update: function () - { - if (this.renderer.gl && this.isCanvas) - { - this.renderer.canvasToTexture(this.image, this.glTexture); - } - }, - - /** - * Destroys this Texture Source and nulls the references. - * - * @method Phaser.Textures.TextureSource#destroy - * @since 3.0.0 - */ - destroy: function () - { - if (this.glTexture) - { - this.renderer.deleteTexture(this.glTexture); - } - - if (this.isCanvas) - { - CanvasPool.remove(this.image); - } - - this.renderer = null; - this.texture = null; - this.image = null; - } - -}); - -module.exports = TextureSource; - - -/***/ }), -/* 184 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(22); -var CanvasTexture = __webpack_require__(515); -var Class = __webpack_require__(0); -var Color = __webpack_require__(30); -var CONST = __webpack_require__(20); -var EventEmitter = __webpack_require__(9); -var GenerateTexture = __webpack_require__(276); -var GetValue = __webpack_require__(4); -var Parser = __webpack_require__(182); -var Texture = __webpack_require__(117); - -/** - * @callback EachTextureCallback - * - * @param {Phaser.Textures.Texture} texture - [description] - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ - -/** - * @classdesc - * Textures are managed by the global TextureManager. This is a singleton class that is - * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. - * - * Sprites and other Game Objects get the texture data they need from the TextureManager. - * - * Access it via `scene.textures`. - * - * @class TextureManager - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - */ -var TextureManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function TextureManager (game) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#name - * @type {string} - * @since 3.0.0 - */ - this.name = 'TextureManager'; - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#list - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.list = {}; - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#_tempCanvas - * @type {HTMLCanvasElement} - * @private - * @since 3.0.0 - */ - this._tempCanvas = CanvasPool.create2D(this, 1, 1); - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#_tempContext - * @type {CanvasRenderingContext2D} - * @private - * @since 3.0.0 - */ - this._tempContext = this._tempCanvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.Textures.TextureManager#_pending - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._pending = 0; - - game.events.once('boot', this.boot, this); - }, - - /** - * [description] - * - * @method Phaser.Textures.TextureManager#boot - * @since 3.0.0 - */ - boot: function () - { - this._pending = 2; - - this.on('onload', this.updatePending, this); - this.on('onerror', this.updatePending, this); - - this.addBase64('__DEFAULT', this.game.config.defaultImage); - this.addBase64('__MISSING', this.game.config.missingImage); - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Textures.TextureManager#updatePending - * @since 3.0.0 - */ - updatePending: function () - { - this._pending--; - - if (this._pending === 0) - { - this.off('onload'); - this.off('onerror'); - - this.game.events.emit('ready'); - } - }, - - /** - * Checks the given texture key and throws a console.warn if the key is already in use, then returns false. - * If you wish to avoid the console.warn then use `TextureManager.exists` instead. - * - * @method Phaser.Textures.TextureManager#checkKey - * @since 3.7.0 - * - * @param {string} key - The texture key to check. - * - * @return {boolean} `true` if it's safe to use the texture key, otherwise `false`. - */ - checkKey: function (key) - { - if (this.exists(key)) - { - // eslint-disable-next-line no-console - console.error('Texture key already in use: ' + key); - - return false; - } - - return true; - }, - - /** - * Removes a Texture from the Texture Manager and destroys it. This will immediately - * clear all references to it from the Texture Manager, and if it has one, destroy its - * WebGLTexture. This will emit a `removetexture` event. - * - * Note: If you have any Game Objects still using this texture they will start throwing - * errors the next time they try to render. Make sure that removing the texture is the final - * step when clearing down to avoid this. - * - * @method Phaser.Textures.TextureManager#remove - * @since 3.7.0 - * - * @param {(string|Phaser.Textures.Texture)} key - The key of the Texture to remove, or a reference to it. - * - * @return {Phaser.Textures.TextureManager} The Texture Manager. - */ - remove: function (key) - { - if (typeof key === 'string') - { - if (this.exists(key)) - { - key = this.get(key); - } - else - { - console.warn('No texture found matching key: ' + key); - return this; - } - } - - // By this point key should be a Texture, if not, the following fails anyway - if (this.list.hasOwnProperty(key.key)) - { - delete this.list[key.key]; - - key.destroy(); - - this.emit('removetexture', key.key); - } - - return this; - }, - - /** - * Adds a new Texture to the Texture Manager created from the given Base64 encoded data. - * - * @method Phaser.Textures.TextureManager#addBase64 - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {*} data - The Base64 encoded data. - */ - addBase64: function (key, data) - { - if (this.checkKey(key)) - { - var _this = this; - - var image = new Image(); - - image.onerror = function () - { - _this.emit('onerror', key); - }; - - image.onload = function () - { - var texture = _this.create(key, image); - - Parser.Image(texture, 0); - - _this.emit('addtexture', key, texture); - - _this.emit('onload', key, texture); - }; - - image.src = data; - } - }, - - /** - * Adds a new Texture to the Texture Manager created from the given Image element. - * - * @method Phaser.Textures.TextureManager#addImage - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLImageElement} source - The source Image element. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - addImage: function (key, source, dataSource) - { - var texture = null; - - if (this.checkKey(key)) - { - texture = this.create(key, source); - - Parser.Image(texture, 0); - - if (dataSource) - { - texture.setDataSource(dataSource); - } - - this.emit('addtexture', key, texture); - } - - return texture; - }, - - /** - * Creates a new Texture using the given config values. - * Generated textures consist of a Canvas element to which the texture data is drawn. - * See the Phaser.Create function for the more direct way to create textures. - * - * @method Phaser.Textures.TextureManager#generate - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {object} config - [description] - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - generate: function (key, config) - { - if (this.checkKey(key)) - { - var canvas = CanvasPool.create(this, 1, 1); - - config.canvas = canvas; - - GenerateTexture(config); - - return this.addCanvas(key, canvas); - } - else - { - return null; - } - }, - - /** - * Creates a new Texture using a blank Canvas element of the size given. - * - * Canvas elements are automatically pooled and calling this method will - * extract a free canvas from the CanvasPool, or create one if none are available. - * - * @method Phaser.Textures.TextureManager#createCanvas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {integer} [width=256]- The width of the Canvas element. - * @param {integer} [height=256] - The height of the Canvas element. - * - * @return {?Phaser.Textures.CanvasTexture} The Canvas Texture that was created, or `null` if the key is already in use. - */ - createCanvas: function (key, width, height) - { - if (width === undefined) { width = 256; } - if (height === undefined) { height = 256; } - - if (this.checkKey(key)) - { - var canvas = CanvasPool.create(this, width, height, CONST.CANVAS, true); - - return this.addCanvas(key, canvas); - } - - return null; - }, - - /** - * Creates a new Canvas Texture object from an existing Canvas element and adds - * it to this Texture Manager. - * - * @method Phaser.Textures.TextureManager#addCanvas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLCanvasElement} source - The Canvas element to form the base of the new Texture. - * - * @return {?Phaser.Textures.CanvasTexture} The Canvas Texture that was created, or `null` if the key is already in use. - */ - addCanvas: function (key, source) - { - var texture = null; - - if (this.checkKey(key)) - { - texture = new CanvasTexture(this, key, source, source.width, source.height); - - this.list[key] = texture; - - this.emit('addtexture', key, texture); - } - - return texture; - }, - - /** - * Adds a new Texture Atlas to this Texture Manager. - * It can accept either JSON Array or JSON Hash formats, as exported by Texture Packer and similar software. - * - * @method Phaser.Textures.TextureManager#addAtlas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLImageElement} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - addAtlas: function (key, source, data, dataSource) - { - // New Texture Packer format? - if (Array.isArray(data.textures) || Array.isArray(data.frames)) - { - return this.addAtlasJSONArray(key, source, data, dataSource); - } - else - { - return this.addAtlasJSONHash(key, source, data, dataSource); - } - }, - - /** - * Adds a Texture Atlas to this Texture Manager. - * The frame data of the atlas must be stored in an Array within the JSON. - * This is known as a JSON Array in software such as Texture Packer. - * - * @method Phaser.Textures.TextureManager#addAtlasJSONArray - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {(HTMLImageElement|HTMLImageElement[])} source - The source Image element/s. - * @param {(object|object[])} data - The Texture Atlas data/s. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - addAtlasJSONArray: function (key, source, data, dataSource) - { - var texture = null; - - if (this.checkKey(key)) - { - texture = this.create(key, source); - - // Multi-Atlas? - if (Array.isArray(data)) - { - var singleAtlasFile = (data.length === 1); // multi-pack with one atlas file for all images - - // !! Assumes the textures are in the same order in the source array as in the json data !! - for (var i = 0; i < texture.source.length; i++) - { - var atlasData = singleAtlasFile ? data[0] : data[i]; - - Parser.JSONArray(texture, i, atlasData); - } - } - else - { - Parser.JSONArray(texture, 0, data); - } - - if (dataSource) - { - texture.setDataSource(dataSource); - } - - this.emit('addtexture', key, texture); - } - - return texture; - }, - - /** - * Adds a Texture Atlas to this Texture Manager. - * The frame data of the atlas must be stored in an Object within the JSON. - * This is known as a JSON Hash in software such as Texture Packer. - * - * @method Phaser.Textures.TextureManager#addAtlasJSONHash - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLImageElement} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - addAtlasJSONHash: function (key, source, data, dataSource) - { - var texture = null; - - if (this.checkKey(key)) - { - texture = this.create(key, source); - - if (Array.isArray(data)) - { - for (var i = 0; i < data.length; i++) - { - Parser.JSONHash(texture, i, data[i]); - } - } - else - { - Parser.JSONHash(texture, 0, data); - } - - if (dataSource) - { - texture.setDataSource(dataSource); - } - - this.emit('addtexture', key, texture); - } - - return texture; - }, - - /** - * Adds a Texture Atlas to this Texture Manager, where the atlas data is given - * in the XML format. - * - * @method Phaser.Textures.TextureManager#addAtlasXML - * @since 3.7.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLImageElement} source - The source Image element. - * @param {object} data - The Texture Atlas XML data. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - addAtlasXML: function (key, source, data, dataSource) - { - var texture = null; - - if (this.checkKey(key)) - { - texture = this.create(key, source); - - Parser.AtlasXML(texture, 0, data); - - if (dataSource) - { - texture.setDataSource(dataSource); - } - - this.emit('addtexture', key, texture); - } - - return texture; - }, - - /** - * Adds a Unity Texture Atlas to this Texture Manager. - * The data must be in the form of a Unity YAML file. - * - * @method Phaser.Textures.TextureManager#addUnityAtlas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLImageElement} source - The source Image element. - * @param {object} data - The Texture Atlas data. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - addUnityAtlas: function (key, source, data, dataSource) - { - var texture = null; - - if (this.checkKey(key)) - { - texture = this.create(key, source); - - Parser.UnityYAML(texture, 0, data); - - if (dataSource) - { - texture.setDataSource(dataSource); - } - - this.emit('addtexture', key, texture); - } - - return texture; - }, - - /** - * @typedef {object} SpriteSheetConfig - * - * @property {integer} frameWidth - The fixed width of each frame. - * @property {integer} [frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. - * @property {integer} [startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. - * @property {integer} [endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - * @property {integer} [margin=0] - If the frames have been drawn with a margin, specify the amount here. - * @property {integer} [spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. - */ - - /** - * Adds a Sprite Sheet to this Texture Manager. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @method Phaser.Textures.TextureManager#addSpriteSheet - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLImageElement} source - The source Image element. - * @param {SpriteSheetConfig} config - The configuration object for this Sprite Sheet. - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - addSpriteSheet: function (key, source, config) - { - var texture = null; - - if (this.checkKey(key)) - { - texture = this.create(key, source); - - var width = texture.source[0].width; - var height = texture.source[0].height; - - Parser.SpriteSheet(texture, 0, 0, 0, width, height, config); - - this.emit('addtexture', key, texture); - } - - return texture; - }, - - /** - * @typedef {object} SpriteSheetFromAtlasConfig - * - * @property {string} atlas - The key of the Texture Atlas in which this Sprite Sheet can be found. - * @property {string} frame - The key of the Texture Atlas Frame in which this Sprite Sheet can be found. - * @property {integer} frameWidth - The fixed width of each frame. - * @property {integer} [frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. - * @property {integer} [startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. - * @property {integer} [endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". - * @property {integer} [margin=0] - If the frames have been drawn with a margin, specify the amount here. - * @property {integer} [spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. - */ - - /** - * Adds a Sprite Sheet to this Texture Manager, where the Sprite Sheet exists as a Frame within a Texture Atlas. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @method Phaser.Textures.TextureManager#addSpriteSheetFromAtlas - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {SpriteSheetFromAtlasConfig} config - The configuration object for this Sprite Sheet. - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - addSpriteSheetFromAtlas: function (key, config) - { - if (!this.checkKey(key)) - { - return null; - } - - var atlasKey = GetValue(config, 'atlas', null); - var atlasFrame = GetValue(config, 'frame', null); - - if (!atlasKey || !atlasFrame) - { - return; - } - - var atlas = this.get(atlasKey); - var sheet = atlas.get(atlasFrame); - - if (sheet) - { - var texture = this.create(key, sheet.source.image); - - if (sheet.trimmed) - { - // If trimmed we need to help the parser adjust - Parser.SpriteSheetFromAtlas(texture, sheet, config); - } - else - { - Parser.SpriteSheet(texture, 0, sheet.cutX, sheet.cutY, sheet.cutWidth, sheet.cutHeight, config); - } - - this.emit('addtexture', key, texture); - - return texture; - } - }, - - /** - * Creates a new Texture using the given source and dimensions. - * - * @method Phaser.Textures.TextureManager#create - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {HTMLImageElement} source - The source Image element. - * @param {integer} width - The width of the Texture. - * @param {integer} height - The height of the Texture. - * - * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. - */ - create: function (key, source, width, height) - { - var texture = null; - - if (this.checkKey(key)) - { - texture = new Texture(this, key, source, width, height); - - this.list[key] = texture; - } - - return texture; - }, - - /** - * Checks the given key to see if a Texture using it exists within this Texture Manager. - * - * @method Phaser.Textures.TextureManager#exists - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * - * @return {boolean} Returns `true` if a Texture matching the given key exists in this Texture Manager. - */ - exists: function (key) - { - return (this.list.hasOwnProperty(key)); - }, - - /** - * Returns a Texture from the Texture Manager that matches the given key. - * If the key is undefined it will return the `__DEFAULT` Texture. - * If the key is given, but not found, it will return the `__MISSING` Texture. - * - * @method Phaser.Textures.TextureManager#get - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * - * @return {Phaser.Textures.Texture} The Texture that was created. - */ - get: function (key) - { - if (key === undefined) { key = '__DEFAULT'; } - - if (this.list[key]) - { - return this.list[key]; - } - else - { - return this.list['__MISSING']; - } - }, - - /** - * Takes a Texture key and Frame name and returns a clone of that Frame if found. - * - * @method Phaser.Textures.TextureManager#cloneFrame - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {(string|integer)} frame - The string or index of the Frame to be cloned. - * - * @return {Phaser.Textures.Frame} A Clone of the given Frame. - */ - cloneFrame: function (key, frame) - { - if (this.list[key]) - { - return this.list[key].get(frame).clone(); - } - }, - - /** - * Takes a Texture key and Frame name and returns a reference to that Frame, if found. - * - * @method Phaser.Textures.TextureManager#getFrame - * @since 3.0.0 - * - * @param {string} key - The unique string-based key of the Texture. - * @param {(string|integer)} frame - The string or index of the Frame. - * - * @return {Phaser.Textures.Frame} A Texture Frame object. - */ - getFrame: function (key, frame) - { - if (this.list[key]) - { - return this.list[key].get(frame); - } - }, - - /** - * Returns an array with all of the keys of all Textures in this Texture Manager. - * The output array will exclude the `__DEFAULT` and `__MISSING` keys. - * - * @method Phaser.Textures.TextureManager#getTextureKeys - * @since 3.0.0 - * - * @return {string[]} An array containing all of the Texture keys stored in this Texture Manager. - */ - getTextureKeys: function () - { - var output = []; - - for (var key in this.list) - { - if (key !== '__DEFAULT' && key !== '__MISSING') - { - output.push(key); - } - } - - return output; - }, - - /** - * Given a Texture and an `x` and `y` coordinate this method will return a new - * Color object that has been populated with the color and alpha values of the pixel - * at that location in the Texture. - * - * @method Phaser.Textures.TextureManager#getPixel - * @since 3.0.0 - * - * @param {integer} x - The x coordinate of the pixel within the Texture. - * @param {integer} y - The y coordinate of the pixel within the Texture. - * @param {string} key - The unique string-based key of the Texture. - * @param {(string|integer)} frame - The string or index of the Frame. - * - * @return {?Phaser.Display.Color} A Color object populated with the color values of the requested pixel, - * or `null` if the coordinates were out of bounds. - */ - getPixel: function (x, y, key, frame) - { - var textureFrame = this.getFrame(key, frame); - - if (textureFrame) - { - var source = textureFrame.source.image; - - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) - { - x += textureFrame.cutX; - y += textureFrame.cutY; - - // if (textureFrame.trimmed) - // { - // x -= this.sprite.texture.trim.x; - // y -= this.sprite.texture.trim.y; - // } - - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); - - return new Color(rgb.data[0], rgb.data[1], rgb.data[2], rgb.data[3]); - } - } - - return null; - }, - - /** - * Given a Texture and an `x` and `y` coordinate this method will return a value between 0 and 255 - * corresponding to the alpha value of the pixel at that location in the Texture. If the coordinate - * is out of bounds it will return null. - * - * @method Phaser.Textures.TextureManager#getPixelAlpha - * @since 3.10.0 - * - * @param {integer} x - The x coordinate of the pixel within the Texture. - * @param {integer} y - The y coordinate of the pixel within the Texture. - * @param {string} key - The unique string-based key of the Texture. - * @param {(string|integer)} frame - The string or index of the Frame. - * - * @return {integer} A value between 0 and 255, or `null` if the coordinates were out of bounds. - */ - getPixelAlpha: function (x, y, key, frame) - { - var textureFrame = this.getFrame(key, frame); - - if (textureFrame) - { - var source = textureFrame.source.image; - - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) - { - x += textureFrame.cutX; - y += textureFrame.cutY; - - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); - - return rgb.data[3]; - } - } - - return null; - }, - - /** - * Sets the given Game Objects `texture` and `frame` properties so that it uses - * the Texture and Frame specified in the `key` and `frame` arguments to this method. - * - * @method Phaser.Textures.TextureManager#setTexture - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {string} key - The unique string-based key of the Texture. - * @param {(string|integer)} frame - The string or index of the Frame. - * - * @return {Phaser.GameObjects.GameObject} The Game Object the texture was set on. - */ - setTexture: function (gameObject, key, frame) - { - if (this.list[key]) - { - gameObject.texture = this.list[key]; - gameObject.frame = gameObject.texture.get(frame); - } - - return gameObject; - }, - - /** - * Passes all Textures to the given callback. - * - * @method Phaser.Textures.TextureManager#each - * @since 3.0.0 - * - * @param {EachTextureCallback} callback - The callback function to be sent the Textures. - * @param {object} scope - The value to use as `this` when executing the callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ - each: function (callback, scope) - { - var args = [ null ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var texture in this.list) - { - args[0] = this.list[texture]; - - callback.apply(scope, args); - } - }, - - /** - * Destroys the Texture Manager and all Textures stored within it. - * - * @method Phaser.Textures.TextureManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - for (var texture in this.list) - { - this.list[texture].destroy(); - } - - this.list = {}; - - this.game = null; - - CanvasPool.remove(this._tempCanvas); - } - -}); - -module.exports = TextureManager; - - -/***/ }), -/* 185 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseSound = __webpack_require__(78); -var Class = __webpack_require__(0); - -/** - * @classdesc - * Web Audio API implementation of the sound. - * - * @class WebAudioSound - * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Sound.WebAudioSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. - */ -var WebAudioSound = new Class({ - - Extends: BaseSound, - - initialize: - - function WebAudioSound (manager, key, config) - { - if (config === undefined) { config = {}; } - - /** - * Audio buffer containing decoded data of the audio asset to be played. - * - * @name Phaser.Sound.WebAudioSound#audioBuffer - * @type {AudioBuffer} - * @private - * @since 3.0.0 - */ - this.audioBuffer = manager.game.cache.audio.get(key); - - if (!this.audioBuffer) - { - // eslint-disable-next-line no-console - console.warn('Audio cache entry missing: ' + key); - return; - } - - /** - * A reference to an audio source node used for playing back audio from - * audio data stored in Phaser.Sound.WebAudioSound#audioBuffer. - * - * @name Phaser.Sound.WebAudioSound#source - * @type {AudioBufferSourceNode} - * @private - * @default null - * @since 3.0.0 - */ - this.source = null; - - /** - * A reference to a second audio source used for gapless looped playback. - * - * @name Phaser.Sound.WebAudioSound#loopSource - * @type {AudioBufferSourceNode} - * @private - * @default null - * @since 3.0.0 - */ - this.loopSource = null; - - /** - * Gain node responsible for controlling this sound's muting. - * - * @name Phaser.Sound.WebAudioSound#muteNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.muteNode = manager.context.createGain(); - - /** - * Gain node responsible for controlling this sound's volume. - * - * @name Phaser.Sound.WebAudioSound#volumeNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.volumeNode = manager.context.createGain(); - - /** - * The time at which the sound should have started playback from the beginning. - * Based on BaseAudioContext.currentTime value. - * - * @name Phaser.Sound.WebAudioSound#playTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.playTime = 0; - - /** - * The time at which the sound source should have actually started playback. - * Based on BaseAudioContext.currentTime value. - * - * @name Phaser.Sound.WebAudioSound#startTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.startTime = 0; - - /** - * The time at which the sound loop source should actually start playback. - * Based on BaseAudioContext.currentTime value. - * - * @name Phaser.Sound.WebAudioSound#loopTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.loopTime = 0; - - /** - * An array where we keep track of all rate updates during playback. - * Array of object types: { time: number, rate: number } - * - * @name Phaser.Sound.WebAudioSound#rateUpdates - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this.rateUpdates = []; - - /** - * Used for keeping track when sound source playback has ended - * so its state can be updated accordingly. - * - * @name Phaser.Sound.WebAudioSound#hasEnded - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.hasEnded = false; - - /** - * Used for keeping track when sound source has looped - * so its state can be updated accordingly. - * - * @name Phaser.Sound.WebAudioSound#hasLooped - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.hasLooped = false; - - this.muteNode.connect(this.volumeNode); - - this.volumeNode.connect(manager.destination); - - this.duration = this.audioBuffer.duration; - - this.totalDuration = this.audioBuffer.duration; - - BaseSound.call(this, manager, key, config); - }, - - /** - * @event Phaser.Sound.WebAudioSound#playEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. - */ - - /** - * Play this sound, or a marked section of it. - * - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * - * @method Phaser.Sound.WebAudioSound#play - * @fires Phaser.Sound.WebAudioSound#playEvent - * @since 3.0.0 - * - * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (markerName, config) - { - if (!BaseSound.prototype.play.call(this, markerName, config)) - { - return false; - } - - // \/\/\/ isPlaying = true, isPaused = false \/\/\/ - this.stopAndRemoveBufferSource(); - this.createAndStartBufferSource(); - - this.emit('play', this); - - return true; - }, - - /** - * @event Phaser.Sound.WebAudioSound#pauseEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. - */ - - /** - * Pauses the sound. - * - * @method Phaser.Sound.WebAudioSound#pause - * @fires Phaser.Sound.WebAudioSound#pauseEvent - * @since 3.0.0 - * - * @return {boolean} Whether the sound was paused successfully. - */ - pause: function () - { - if (this.manager.context.currentTime < this.startTime) - { - return false; - } - - if (!BaseSound.prototype.pause.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = false, isPaused = true \/\/\/ - this.currentConfig.seek = this.getCurrentTime(); // Equivalent to setting paused time - this.stopAndRemoveBufferSource(); - - this.emit('pause', this); - - return true; - }, - - /** - * @event Phaser.Sound.WebAudioSound#resumeEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. - */ - - /** - * Resumes the sound. - * - * @method Phaser.Sound.WebAudioSound#resume - * @fires Phaser.Sound.WebAudioSound#resumeEvent - * @since 3.0.0 - * - * @return {boolean} Whether the sound was resumed successfully. - */ - resume: function () - { - if (this.manager.context.currentTime < this.startTime) - { - return false; - } - - if (!BaseSound.prototype.resume.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = true, isPaused = false \/\/\/ - this.createAndStartBufferSource(); - - this.emit('resume', this); - - return true; - }, - - /** - * @event Phaser.Sound.WebAudioSound#stopEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. - */ - - /** - * Stop playing this sound. - * - * @method Phaser.Sound.WebAudioSound#stop - * @fires Phaser.Sound.WebAudioSound#stopEvent - * @since 3.0.0 - * - * @return {boolean} Whether the sound was stopped successfully. - */ - stop: function () - { - if (!BaseSound.prototype.stop.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = false, isPaused = false \/\/\/ - this.stopAndRemoveBufferSource(); - - this.emit('stop', this); - - return true; - }, - - /** - * Used internally. - * - * @method Phaser.Sound.WebAudioSound#createAndStartBufferSource - * @private - * @since 3.0.0 - */ - createAndStartBufferSource: function () - { - var seek = this.currentConfig.seek; - var delay = this.currentConfig.delay; - var when = this.manager.context.currentTime + delay; - var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek; - var duration = this.duration - seek; - - this.playTime = when - seek; - this.startTime = when; - this.source = this.createBufferSource(); - - this.applyConfig(); - - this.source.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); - - this.resetConfig(); - }, - - /** - * Used internally. - * - * @method Phaser.Sound.WebAudioSound#createAndStartLoopBufferSource - * @private - * @since 3.0.0 - */ - createAndStartLoopBufferSource: function () - { - var when = this.getLoopTime(); - var offset = this.currentMarker ? this.currentMarker.start : 0; - var duration = this.duration; - - this.loopTime = when; - this.loopSource = this.createBufferSource(); - this.loopSource.playbackRate.setValueAtTime(this.totalRate, 0); - this.loopSource.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); - }, - - /** - * Used internally. - * - * @method Phaser.Sound.WebAudioSound#createBufferSource - * @private - * @since 3.0.0 - * - * @return {AudioBufferSourceNode} - */ - createBufferSource: function () - { - var _this = this; - var source = this.manager.context.createBufferSource(); - - source.buffer = this.audioBuffer; - - source.connect(this.muteNode); - - source.onended = function (ev) - { - if (ev.target === _this.source) - { - // sound ended - if (_this.currentConfig.loop) - { - _this.hasLooped = true; - } - else - { - _this.hasEnded = true; - } - } - - // else was stopped - }; - - return source; - }, - - /** - * Used internally. - * - * @method Phaser.Sound.WebAudioSound#stopAndRemoveBufferSource - * @private - * @since 3.0.0 - */ - stopAndRemoveBufferSource: function () - { - if (this.source) - { - this.source.stop(); - this.source.disconnect(); - this.source = null; - } - - this.playTime = 0; - this.startTime = 0; - - this.stopAndRemoveLoopBufferSource(); - }, - - /** - * Used internally. - * - * @method Phaser.Sound.WebAudioSound#stopAndRemoveLoopBufferSource - * @private - * @since 3.0.0 - */ - stopAndRemoveLoopBufferSource: function () - { - if (this.loopSource) - { - this.loopSource.stop(); - this.loopSource.disconnect(); - this.loopSource = null; - } - - this.loopTime = 0; - }, - - /** - * Method used internally for applying config values to some of the sound properties. - * - * @method Phaser.Sound.WebAudioSound#applyConfig - * @protected - * @since 3.0.0 - */ - applyConfig: function () - { - this.rateUpdates.length = 0; - - this.rateUpdates.push({ - time: 0, - rate: 1 - }); - - BaseSound.prototype.applyConfig.call(this); - }, - - /** - * @event Phaser.Sound.WebAudioSound#endedEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - - /** - * @event Phaser.Sound.WebAudioSound#loopedEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - */ - - /** - * Update method called automatically by sound manager on every game step. - * - * @method Phaser.Sound.WebAudioSound#update - * @fires Phaser.Sound.WebAudioSound#endedEvent - * @fires Phaser.Sound.WebAudioSound#loopedEvent - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - // eslint-disable-next-line no-unused-vars - update: function (time, delta) - { - if (this.hasEnded) - { - this.hasEnded = false; - - BaseSound.prototype.stop.call(this); - - this.stopAndRemoveBufferSource(); - - this.emit('ended', this); - } - else if (this.hasLooped) - { - this.hasLooped = false; - this.source = this.loopSource; - this.loopSource = null; - this.playTime = this.startTime = this.loopTime; - this.rateUpdates.length = 0; - - this.rateUpdates.push({ - time: 0, - rate: this.totalRate - }); - - this.createAndStartLoopBufferSource(); - - this.emit('looped', this); - } - }, - - /** - * Calls Phaser.Sound.BaseSound#destroy method - * and cleans up all Web Audio API related stuff. - * - * @method Phaser.Sound.WebAudioSound#destroy - * @since 3.0.0 - */ - destroy: function () - { - BaseSound.prototype.destroy.call(this); - - this.audioBuffer = null; - this.stopAndRemoveBufferSource(); - this.muteNode.disconnect(); - this.muteNode = null; - this.volumeNode.disconnect(); - this.volumeNode = null; - this.rateUpdates.length = 0; - this.rateUpdates = null; - }, - - /** - * Method used internally to calculate total playback rate of the sound. - * - * @method Phaser.Sound.WebAudioSound#calculateRate - * @protected - * @since 3.0.0 - */ - calculateRate: function () - { - BaseSound.prototype.calculateRate.call(this); - - var now = this.manager.context.currentTime; - - if (this.source && typeof this.totalRate === 'number') - { - this.source.playbackRate.setValueAtTime(this.totalRate, now); - } - - if (this.isPlaying) - { - this.rateUpdates.push({ - time: Math.max(this.startTime, now) - this.playTime, - rate: this.totalRate - }); - - if (this.loopSource) - { - this.stopAndRemoveLoopBufferSource(); - this.createAndStartLoopBufferSource(); - } - } - }, - - /** - * Method used internally for calculating current playback time of a playing sound. - * - * @method Phaser.Sound.WebAudioSound#getCurrentTime - * @private - * @since 3.0.0 - */ - getCurrentTime: function () - { - var currentTime = 0; - - for (var i = 0; i < this.rateUpdates.length; i++) - { - var nextTime = 0; - - if (i < this.rateUpdates.length - 1) - { - nextTime = this.rateUpdates[i + 1].time; - } - else - { - nextTime = this.manager.context.currentTime - this.playTime; - } - - currentTime += (nextTime - this.rateUpdates[i].time) * this.rateUpdates[i].rate; - } - - return currentTime; - }, - - /** - * Method used internally for calculating the time - * at witch the loop source should start playing. - * - * @method Phaser.Sound.WebAudioSound#getLoopTime - * @private - * @since 3.0.0 - */ - getLoopTime: function () - { - var lastRateUpdateCurrentTime = 0; - - for (var i = 0; i < this.rateUpdates.length - 1; i++) - { - lastRateUpdateCurrentTime += (this.rateUpdates[i + 1].time - this.rateUpdates[i].time) * this.rateUpdates[i].rate; - } - - var lastRateUpdate = this.rateUpdates[this.rateUpdates.length - 1]; - - return this.playTime + lastRateUpdate.time + (this.duration - lastRateUpdateCurrentTime) / lastRateUpdate.rate; - }, - - /** - * @event Phaser.Sound.WebAudioSound#rateEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted the event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#rate property. - */ - - /** - * Rate at which this Sound will be played. - * 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. - * - * @name Phaser.Sound.WebAudioSound#rate - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rate: { - - get: function () - { - return this.currentConfig.rate; - }, - - set: function (value) - { - this.currentConfig.rate = value; - - this.calculateRate(); - - this.emit('rate', this, value); - } - - }, - - /** - * Sets the playback rate of this Sound. - * - * 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. - * - * @method Phaser.Sound.WebAudioSound#setRate - * @fires Phaser.Sound.WebAudioSound#rateEvent - * @since 3.3.0 - * - * @param {number} value - The playback rate at of this Sound. - * - * @return {Phaser.Sound.WebAudioSound} This Sound. - */ - setRate: function (value) - { - this.rate = value; - - return this; - }, - - /** - * @event Phaser.Sound.WebAudioSound#detuneEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#detune property. - */ - - /** - * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @name Phaser.Sound.WebAudioSound#detune - * @type {number} - * @default 0 - * @since 3.0.0 - */ - detune: { - - get: function () - { - return this.currentConfig.detune; - }, - - set: function (value) - { - this.currentConfig.detune = value; - - this.calculateRate(); - - this.emit('detune', this, value); - } - - }, - - /** - * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @method Phaser.Sound.WebAudioSound#setDetune - * @fires Phaser.Sound.WebAudioSound#detuneEvent - * @since 3.3.0 - * - * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @return {Phaser.Sound.WebAudioSound} This Sound. - */ - setDetune: function (value) - { - this.detune = value; - - return this; - }, - - /** - * @event Phaser.Sound.WebAudioSound#muteEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#mute property. - */ - - /** - * 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} - * @default false - * @since 3.0.0 - */ - mute: { - - get: function () - { - return (this.muteNode.gain.value === 0); - }, - - set: function (value) - { - this.currentConfig.mute = value; - this.muteNode.gain.setValueAtTime(value ? 0 : 1, 0); - - this.emit('mute', this, value); - } - - }, - - /** - * Sets the muted state of this Sound. - * - * @method Phaser.Sound.WebAudioSound#setMute - * @fires Phaser.Sound.WebAudioSound#muteEvent - * @since 3.4.0 - * - * @param {boolean} value - `true` to mute this sound, `false` to unmute it. - * - * @return {Phaser.Sound.WebAudioSound} This Sound instance. - */ - setMute: function (value) - { - this.mute = value; - - return this; - }, - - /** - * @event Phaser.Sound.WebAudioSound#volumeEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#volume property. - */ - - /** - * Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume). - * - * @name Phaser.Sound.WebAudioSound#volume - * @type {number} - * @default 1 - * @since 3.0.0 - */ - volume: { - - get: function () - { - return this.volumeNode.gain.value; - }, - - set: function (value) - { - this.currentConfig.volume = value; - this.volumeNode.gain.setValueAtTime(value, 0); - - this.emit('volume', this, value); - } - }, - - /** - * Sets the volume of this Sound. - * - * @method Phaser.Sound.WebAudioSound#setVolume - * @fires Phaser.Sound.WebAudioSound#volumeEvent - * @since 3.4.0 - * - * @param {number} value - The volume of the sound. - * - * @return {Phaser.Sound.WebAudioSound} This Sound instance. - */ - setVolume: function (value) - { - this.volume = value; - - return this; - }, - - /** - * @event Phaser.Sound.WebAudioSound#seekEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#seek property. - */ - - /** - * 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} - * @since 3.0.0 - */ - seek: { - - get: function () - { - if (this.isPlaying) - { - if (this.manager.context.currentTime < this.startTime) - { - return this.startTime - this.playTime; - } - - return this.getCurrentTime(); - } - else if (this.isPaused) - { - return this.currentConfig.seek; - } - else - { - return 0; - } - }, - - set: function (value) - { - if (this.manager.context.currentTime < this.startTime) - { - return; - } - - if (this.isPlaying || this.isPaused) - { - value = Math.min(Math.max(0, value), this.duration); - - this.currentConfig.seek = value; - - if (this.isPlaying) - { - this.stopAndRemoveBufferSource(); - this.createAndStartBufferSource(); - } - - this.emit('seek', this, value); - } - } - }, - - /** - * Seeks to a specific point in this sound. - * - * @method Phaser.Sound.WebAudioSound#setSeek - * @fires Phaser.Sound.WebAudioSound#seekEvent - * @since 3.4.0 - * - * @param {number} value - The point in the sound to seek to. - * - * @return {Phaser.Sound.WebAudioSound} This Sound instance. - */ - setSeek: function (value) - { - this.seek = value; - - return this; - }, - - /** - * @event Phaser.Sound.WebAudioSound#loopEvent - * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#loop property. - */ - - /** - * Flag indicating whether or not the sound or current sound marker will loop. - * - * @name Phaser.Sound.WebAudioSound#loop - * @type {boolean} - * @default false - * @since 3.0.0 - */ - loop: { - - get: function () - { - return this.currentConfig.loop; - }, - - set: function (value) - { - this.currentConfig.loop = value; - - if (this.isPlaying) - { - this.stopAndRemoveLoopBufferSource(); - - if (value) - { - this.createAndStartLoopBufferSource(); - } - } - - this.emit('loop', this, value); - } - }, - - /** - * Sets the loop state of this Sound. - * - * @method Phaser.Sound.WebAudioSound#setLoop - * @fires Phaser.Sound.WebAudioSound#loopEvent - * @since 3.4.0 - * - * @param {boolean} value - `true` to loop this sound, `false` to not loop it. - * - * @return {Phaser.Sound.WebAudioSound} This Sound instance. - */ - setLoop: function (value) - { - this.loop = value; - - return this; - } - -}); - -module.exports = WebAudioSound; - - -/***/ }), -/* 186 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseSoundManager = __webpack_require__(79); -var Class = __webpack_require__(0); -var WebAudioSound = __webpack_require__(185); - -/** - * @classdesc - * Web Audio API implementation of the sound manager. - * - * @class WebAudioSoundManager - * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var WebAudioSoundManager = new Class({ - - Extends: BaseSoundManager, - - initialize: - - function WebAudioSoundManager (game) - { - /** - * The AudioContext being used for playback. - * - * @name Phaser.Sound.WebAudioSoundManager#context - * @type {AudioContext} - * @private - * @since 3.0.0 - */ - this.context = this.createAudioContext(game); - - /** - * Gain node responsible for controlling global muting. - * - * @name Phaser.Sound.WebAudioSoundManager#masterMuteNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.masterMuteNode = this.context.createGain(); - - /** - * Gain node responsible for controlling global volume. - * - * @name Phaser.Sound.WebAudioSoundManager#masterVolumeNode - * @type {GainNode} - * @private - * @since 3.0.0 - */ - this.masterVolumeNode = this.context.createGain(); - - this.masterMuteNode.connect(this.masterVolumeNode); - - this.masterVolumeNode.connect(this.context.destination); - - /** - * Destination node for connecting individual sounds to. - * - * @name Phaser.Sound.WebAudioSoundManager#destination - * @type {AudioNode} - * @private - * @since 3.0.0 - */ - this.destination = this.masterMuteNode; - - this.locked = this.context.state === 'suspended' && ('ontouchstart' in window || 'onclick' in window); - - BaseSoundManager.call(this, game); - - if (this.locked) - { - this.unlock(); - } - }, - - /** - * Method responsible for instantiating and returning AudioContext instance. - * If an instance of an AudioContext class was provided through the game config, - * that instance will be returned instead. This can come in handy if you are reloading - * a Phaser game on a page that never properly refreshes (such as in an SPA project) - * and you want to reuse already instantiated AudioContext. - * - * @method Phaser.Sound.WebAudioSoundManager#createAudioContext - * @private - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - * - * @return {AudioContext} The AudioContext instance to be used for playback. - */ - createAudioContext: function (game) - { - var audioConfig = game.config.audio; - - if (audioConfig && audioConfig.context) - { - audioConfig.context.resume(); - - return audioConfig.context; - } - - return new AudioContext(); - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.WebAudioSoundManager#add - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.WebAudioSound} The new sound instance. - */ - add: function (key, config) - { - var sound = new WebAudioSound(this, key, config); - - this.sounds.push(sound); - - return sound; - }, - - /** - * Unlocks Web Audio API on the initial input event. - * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - * - * @method Phaser.Sound.WebAudioSoundManager#unlock - * @since 3.0.0 - */ - unlock: function () - { - var _this = this; - - var unlock = function () - { - _this.context.resume().then(function () - { - document.body.removeEventListener('touchstart', unlock); - document.body.removeEventListener('touchend', unlock); - document.body.removeEventListener('click', unlock); - - _this.unlocked = true; - }); - }; - - if (document.body) - { - document.body.addEventListener('touchstart', unlock, false); - document.body.addEventListener('touchend', unlock, false); - document.body.addEventListener('click', unlock, false); - } - }, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.WebAudioSoundManager#onBlur - * @protected - * @since 3.0.0 - */ - onBlur: function () - { - this.context.suspend(); - }, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.WebAudioSoundManager#onFocus - * @protected - * @since 3.0.0 - */ - onFocus: function () - { - this.context.resume(); - }, - - /** - * Calls Phaser.Sound.BaseSoundManager#destroy method - * and cleans up all Web Audio API related stuff. - * - * @method Phaser.Sound.WebAudioSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.destination = null; - this.masterVolumeNode.disconnect(); - this.masterVolumeNode = null; - this.masterMuteNode.disconnect(); - this.masterMuteNode = null; - - if (this.game.config.audio && this.game.config.audio.context) - { - this.context.suspend(); - } - else - { - var _this = this; - - this.context.close().then(function () - { - - _this.context = null; - - }); - } - - BaseSoundManager.prototype.destroy.call(this); - }, - - /** - * @event Phaser.Sound.WebAudioSoundManager#muteEvent - * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSoundManager#mute property. - */ - - /** - * Sets the muted state of all this Sound Manager. - * - * @method Phaser.Sound.WebAudioSoundManager#setMute - * @fires Phaser.Sound.WebAudioSoundManager#muteEvent - * @since 3.3.0 - * - * @param {boolean} value - `true` to mute all sounds, `false` to unmute them. - * - * @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager. - */ - setMute: function (value) - { - this.mute = value; - - return this; - }, - - /** - * @name Phaser.Sound.WebAudioSoundManager#mute - * @type {boolean} - * @fires Phaser.Sound.WebAudioSoundManager#MuteEvent - * @since 3.0.0 - */ - mute: { - - get: function () - { - return (this.masterMuteNode.gain.value === 0); - }, - - set: function (value) - { - this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0); - - this.emit('mute', this, value); - } - - }, - - /** - * @event Phaser.Sound.WebAudioSoundManager#VolumeEvent - * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.WebAudioSoundManager#volume property. - */ - - /** - * Sets the volume of this Sound Manager. - * - * @method Phaser.Sound.WebAudioSoundManager#setVolume - * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent - * @since 3.3.0 - * - * @param {number} value - The global volume of this Sound Manager. - * - * @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager. - */ - setVolume: function (value) - { - this.volume = value; - - return this; - }, - - /** - * @name Phaser.Sound.WebAudioSoundManager#volume - * @type {number} - * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent - * @since 3.0.0 - */ - volume: { - - get: function () - { - return this.masterVolumeNode.gain.value; - }, - - set: function (value) - { - this.masterVolumeNode.gain.setValueAtTime(value, 0); - - this.emit('volume', this, value); - } - - } - -}); - -module.exports = WebAudioSoundManager; - - -/***/ }), -/* 187 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseSound = __webpack_require__(78); -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Extend = __webpack_require__(17); - -/** - * @classdesc - * No audio implementation of the sound. It is used if audio has been - * disabled in the game config or the device doesn't support any audio. - * - * It represents a graceful degradation of sound logic that provides - * minimal functionality and prevents Phaser projects that use audio from - * breaking on devices that don't support any audio playback technologies. - * - * @class NoAudioSound - * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Sound.NoAudioSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. - */ -var NoAudioSound = new Class({ - - Extends: EventEmitter, - - initialize: - - function NoAudioSound (manager, key, config) - { - if (config === void 0) { config = {}; } - - EventEmitter.call(this); - - this.manager = manager; - this.key = key; - this.isPlaying = false; - this.isPaused = false; - this.totalRate = 1; - this.duration = 0; - this.totalDuration = 0; - - this.config = Extend({ - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - }, config); - - this.currentConfig = this.config; - this.mute = false; - this.volume = 1; - this.rate = 1; - this.detune = 0; - this.seek = 0; - this.loop = false; - this.markers = {}; - this.currentMarker = null; - this.pendingRemove = false; - }, - - // eslint-disable-next-line no-unused-vars - addMarker: function (marker) - { - return false; - }, - - // eslint-disable-next-line no-unused-vars - updateMarker: function (marker) - { - return false; - }, - - // eslint-disable-next-line no-unused-vars - removeMarker: function (markerName) - { - return null; - }, - - // eslint-disable-next-line no-unused-vars - play: function (markerName, config) - { - return false; - }, - - pause: function () - { - return false; - }, - - resume: function () - { - return false; - }, - - stop: function () - { - return false; - }, - - destroy: function () - { - this.manager.remove(this); - - BaseSound.prototype.destroy.call(this); - } -}); - -module.exports = NoAudioSound; - - -/***/ }), -/* 188 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseSoundManager = __webpack_require__(79); -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var NoAudioSound = __webpack_require__(187); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * No audio implementation of the sound manager. It is used if audio has been - * disabled in the game config or the device doesn't support any audio. - * - * It represents a graceful degradation of sound manager logic that provides - * minimal functionality and prevents Phaser projects that use audio from - * breaking on devices that don't support any audio playback technologies. - * - * @class NoAudioSoundManager - * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var NoAudioSoundManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function NoAudioSoundManager (game) - { - EventEmitter.call(this); - - this.game = game; - this.sounds = []; - this.mute = false; - this.volume = 1; - this.rate = 1; - this.detune = 0; - this.pauseOnBlur = true; - this.locked = false; - }, - - add: function (key, config) - { - var sound = new NoAudioSound(this, key, config); - - this.sounds.push(sound); - - return sound; - }, - - addAudioSprite: function (key, config) - { - var sound = this.add(key, config); - - sound.spritemap = {}; - - return sound; - }, - - // eslint-disable-next-line no-unused-vars - play: function (key, extra) - { - return false; - }, - - // eslint-disable-next-line no-unused-vars - playAudioSprite: function (key, spriteName, config) - { - return false; - }, - - remove: function (sound) - { - return BaseSoundManager.prototype.remove.call(this, sound); - }, - - removeByKey: function (key) - { - return BaseSoundManager.prototype.removeByKey.call(this, key); - }, - - pauseAll: NOOP, - resumeAll: NOOP, - stopAll: NOOP, - update: NOOP, - setRate: NOOP, - setDetune: NOOP, - setMute: NOOP, - setVolume: NOOP, - - forEachActiveSound: function (callbackfn, scope) - { - BaseSoundManager.prototype.forEachActiveSound.call(this, callbackfn, scope); - }, - - destroy: function () - { - BaseSoundManager.prototype.destroy.call(this); - } - -}); - -module.exports = NoAudioSoundManager; - - -/***/ }), -/* 189 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseSound = __webpack_require__(78); -var Class = __webpack_require__(0); - -/** - * @classdesc - * HTML5 Audio implementation of the sound. - * - * @class HTML5AudioSound - * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Sound.HTML5AudioSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. - */ -var HTML5AudioSound = new Class({ - - Extends: BaseSound, - - initialize: - - function HTML5AudioSound (manager, key, config) - { - if (config === undefined) { config = {}; } - - /** - * An array containing all HTML5 Audio tags that could be used for individual - * sound's playback. Number of instances depends on the config value passed - * to the Loader#audio method call, default is 1. - * - * @name Phaser.Sound.HTML5AudioSound#tags - * @type {HTMLAudioElement[]} - * @private - * @since 3.0.0 - */ - this.tags = manager.game.cache.audio.get(key); - - if (!this.tags) - { - // eslint-disable-next-line no-console - console.warn('Audio cache entry missing: ' + key); - return; - } - - /** - * Reference to an HTML5 Audio tag used for playing sound. - * - * @name Phaser.Sound.HTML5AudioSound#audio - * @type {HTMLAudioElement} - * @private - * @default null - * @since 3.0.0 - */ - this.audio = null; - - /** - * Timestamp as generated by the Request Animation Frame or SetTimeout - * representing the time at which the delayed sound playback should start. - * Set to 0 if sound playback is not delayed. - * - * @name Phaser.Sound.HTML5AudioSound#startTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.startTime = 0; - - /** - * Audio tag's playback position recorded on previous - * update method call. Set to 0 if sound is not playing. - * - * @name Phaser.Sound.HTML5AudioSound#previousTime - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.previousTime = 0; - - this.duration = this.tags[0].duration; - - this.totalDuration = this.tags[0].duration; - - BaseSound.call(this, manager, key, config); - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#playEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - */ - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * - * @method Phaser.Sound.HTML5AudioSound#play - * @fires Phaser.Sound.HTML5AudioSound#playEvent - * @since 3.0.0 - * - * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (markerName, config) - { - if (this.manager.isLocked(this, 'play', [ markerName, config ])) - { - return false; - } - - if (!BaseSound.prototype.play.call(this, markerName, config)) - { - return false; - } - - // \/\/\/ isPlaying = true, isPaused = false \/\/\/ - if (!this.pickAndPlayAudioTag()) - { - return false; - } - - this.emit('play', this); - - return true; - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#pauseEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - */ - - /** - * Pauses the sound. - * - * @method Phaser.Sound.HTML5AudioSound#pause - * @fires Phaser.Sound.HTML5AudioSound#pauseEvent - * @since 3.0.0 - * - * @return {boolean} Whether the sound was paused successfully. - */ - pause: function () - { - if (this.manager.isLocked(this, 'pause')) - { - return false; - } - - if (this.startTime > 0) - { - return false; - } - - if (!BaseSound.prototype.pause.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = false, isPaused = true \/\/\/ - this.currentConfig.seek = this.audio.currentTime - (this.currentMarker ? this.currentMarker.start : 0); - - this.stopAndReleaseAudioTag(); - - this.emit('pause', this); - - return true; - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#resumeEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - */ - - /** - * Resumes the sound. - * - * @method Phaser.Sound.HTML5AudioSound#resume - * @fires Phaser.Sound.HTML5AudioSound#resumeEvent - * @since 3.0.0 - * - * @return {boolean} Whether the sound was resumed successfully. - */ - resume: function () - { - if (this.manager.isLocked(this, 'resume')) - { - return false; - } - - if (this.startTime > 0) - { - return false; - } - - if (!BaseSound.prototype.resume.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = true, isPaused = false \/\/\/ - if (!this.pickAndPlayAudioTag()) - { - return false; - } - - this.emit('resume', this); - - return true; - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#stopEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - */ - - /** - * Stop playing this sound. - * - * @method Phaser.Sound.HTML5AudioSound#stop - * @fires Phaser.Sound.HTML5AudioSound#stopEvent - * @since 3.0.0 - * - * @return {boolean} Whether the sound was stopped successfully. - */ - stop: function () - { - if (this.manager.isLocked(this, 'stop')) - { - return false; - } - - if (!BaseSound.prototype.stop.call(this)) - { - return false; - } - - // \/\/\/ isPlaying = false, isPaused = false \/\/\/ - this.stopAndReleaseAudioTag(); - - this.emit('stop', this); - - return true; - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.HTML5AudioSound#pickAndPlayAudioTag - * @private - * @since 3.0.0 - * - * @return {boolean} Whether the sound was assigned an audio tag successfully. - */ - pickAndPlayAudioTag: function () - { - if (!this.pickAudioTag()) - { - this.reset(); - return false; - } - - var seek = this.currentConfig.seek; - var delay = this.currentConfig.delay; - var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek; - - this.previousTime = offset; - this.audio.currentTime = offset; - this.applyConfig(); - - if (delay === 0) - { - this.startTime = 0; - - if (this.audio.paused) - { - this.playCatchPromise(); - } - } - else - { - this.startTime = window.performance.now() + delay * 1000; - - if (!this.audio.paused) - { - this.audio.pause(); - } - } - - this.resetConfig(); - - return true; - }, - - /** - * This method performs the audio tag pooling logic. It first looks for - * unused audio tag to assign to this sound object. If there are no unused - * audio tags, based on HTML5AudioSoundManager#override property value, it - * looks for sound with most advanced playback and hijacks its audio tag or - * does nothing. - * - * @method Phaser.Sound.HTML5AudioSound#pickAudioTag - * @private - * @since 3.0.0 - * - * @return {boolean} Whether the sound was assigned an audio tag successfully. - */ - pickAudioTag: function () - { - if (this.audio) - { - return true; - } - - for (var i = 0; i < this.tags.length; i++) - { - var audio = this.tags[i]; - - if (audio.dataset.used === 'false') - { - audio.dataset.used = 'true'; - this.audio = audio; - return true; - } - } - - if (!this.manager.override) - { - return false; - } - - var otherSounds = []; - - this.manager.forEachActiveSound(function (sound) - { - if (sound.key === this.key && sound.audio) - { - otherSounds.push(sound); - } - }, this); - - otherSounds.sort(function (a1, a2) - { - if (a1.loop === a2.loop) - { - // sort by progress - return (a2.seek / a2.duration) - (a1.seek / a1.duration); - } - return a1.loop ? 1 : -1; - }); - - var selectedSound = otherSounds[0]; - - this.audio = selectedSound.audio; - - selectedSound.reset(); - selectedSound.audio = null; - selectedSound.startTime = 0; - selectedSound.previousTime = 0; - - return true; - }, - - /** - * Method used for playing audio tag and catching possible exceptions - * thrown from rejected Promise returned from play method call. - * - * @method Phaser.Sound.HTML5AudioSound#playCatchPromise - * @private - * @since 3.0.0 - */ - playCatchPromise: function () - { - var playPromise = this.audio.play(); - - if (playPromise) - { - // eslint-disable-next-line no-unused-vars - playPromise.catch(function (reason) - { - console.warn(reason); - }); - } - }, - - /** - * Used internally to do what the name says. - * - * @method Phaser.Sound.HTML5AudioSound#stopAndReleaseAudioTag - * @private - * @since 3.0.0 - */ - stopAndReleaseAudioTag: function () - { - this.audio.pause(); - this.audio.dataset.used = 'false'; - this.audio = null; - this.startTime = 0; - this.previousTime = 0; - }, - - /** - * Method used internally to reset sound state, usually when stopping sound - * or when hijacking audio tag from another sound. - * - * @method Phaser.Sound.HTML5AudioSound#reset - * @private - * @since 3.0.0 - */ - reset: function () - { - BaseSound.prototype.stop.call(this); - }, - - /** - * Method used internally by sound manager for pausing sound if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.HTML5AudioSoundManager#onBlur - * @private - * @since 3.0.0 - */ - onBlur: function () - { - this.isPlaying = false; - this.isPaused = true; - - this.currentConfig.seek = this.audio.currentTime - (this.currentMarker ? this.currentMarker.start : 0); - - this.currentConfig.delay = Math.max(0, (this.startTime - window.performance.now()) / 1000); - - this.stopAndReleaseAudioTag(); - }, - - /** - * Method used internally by sound manager for resuming sound if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.HTML5AudioSound#onFocus - * @private - * @since 3.0.0 - */ - onFocus: function () - { - this.isPlaying = true; - this.isPaused = false; - this.pickAndPlayAudioTag(); - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#loopedEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - */ - - /** - * @event Phaser.Sound.HTML5AudioSound#endedEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - */ - - /** - * Update method called automatically by sound manager on every game step. - * - * @method Phaser.Sound.HTML5AudioSound#update - * @fires Phaser.Sound.HTML5AudioSound#loopedEvent - * @fires Phaser.Sound.HTML5AudioSound#endedEvent - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - // eslint-disable-next-line no-unused-vars - update: function (time, delta) - { - if (!this.isPlaying) - { - return; - } - - // handling delayed playback - if (this.startTime > 0) - { - if (this.startTime < time - this.manager.audioPlayDelay) - { - this.audio.currentTime += Math.max(0, time - this.startTime) / 1000; - this.startTime = 0; - this.previousTime = this.audio.currentTime; - this.playCatchPromise(); - } - - return; - } - - // handle looping and ending - var startTime = this.currentMarker ? this.currentMarker.start : 0; - var endTime = startTime + this.duration; - var currentTime = this.audio.currentTime; - - if (this.currentConfig.loop) - { - if (currentTime >= endTime - this.manager.loopEndOffset) - { - this.audio.currentTime = startTime + Math.max(0, currentTime - endTime); - currentTime = this.audio.currentTime; - } - else if (currentTime < startTime) - { - this.audio.currentTime += startTime; - currentTime = this.audio.currentTime; - } - - if (currentTime < this.previousTime) - { - this.emit('looped', this); - } - } - else if (currentTime >= endTime) - { - this.reset(); - - this.stopAndReleaseAudioTag(); - - this.emit('ended', this); - - return; - } - - this.previousTime = currentTime; - }, - - /** - * Calls Phaser.Sound.BaseSound#destroy method - * and cleans up all HTML5 Audio related stuff. - * - * @method Phaser.Sound.HTML5AudioSound#destroy - * @since 3.0.0 - */ - destroy: function () - { - BaseSound.prototype.destroy.call(this); - - this.tags = null; - - if (this.audio) - { - this.stopAndReleaseAudioTag(); - } - }, - - /** - * Method used internally to determine mute setting of the sound. - * - * @method Phaser.Sound.HTML5AudioSound#updateMute - * @private - * @since 3.0.0 - */ - updateMute: function () - { - if (this.audio) - { - this.audio.muted = this.currentConfig.mute || this.manager.mute; - } - }, - - /** - * Method used internally to calculate total volume of the sound. - * - * @method Phaser.Sound.HTML5AudioSound#updateVolume - * @private - * @since 3.0.0 - */ - updateVolume: function () - { - if (this.audio) - { - this.audio.volume = this.currentConfig.volume * this.manager.volume; - } - }, - - /** - * Method used internally to calculate total playback rate of the sound. - * - * @method Phaser.Sound.HTML5AudioSound#calculateRate - * @protected - * @since 3.0.0 - */ - calculateRate: function () - { - BaseSound.prototype.calculateRate.call(this); - - if (this.audio) - { - this.audio.playbackRate = this.totalRate; - } - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#muteEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSound#mute property. - */ - - /** - * 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} - * @default false - * @since 3.0.0 - */ - mute: { - - get: function () - { - return this.currentConfig.mute; - }, - - set: function (value) - { - this.currentConfig.mute = value; - - if (this.manager.isLocked(this, 'mute', value)) - { - return; - } - - this.emit('mute', this, value); - } - }, - - /** - * Sets the muted state of this Sound. - * - * @method Phaser.Sound.HTML5AudioSound#setMute - * @fires Phaser.Sound.HTML5AudioSound#muteEvent - * @since 3.4.0 - * - * @param {boolean} value - `true` to mute this sound, `false` to unmute it. - * - * @return {Phaser.Sound.HTML5AudioSound} This Sound instance. - */ - setMute: function (value) - { - this.mute = value; - - return this; - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#volumeEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSound#volume property. - */ - - /** - * Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume). - * - * @name Phaser.Sound.HTML5AudioSound#volume - * @type {number} - * @default 1 - * @since 3.0.0 - */ - volume: { - - get: function () - { - return this.currentConfig.volume; - }, - - set: function (value) - { - this.currentConfig.volume = value; - - if (this.manager.isLocked(this, 'volume', value)) - { - return; - } - - this.emit('volume', this, value); - } - }, - - /** - * Sets the volume of this Sound. - * - * @method Phaser.Sound.HTML5AudioSound#setVolume - * @fires Phaser.Sound.HTML5AudioSound#volumeEvent - * @since 3.4.0 - * - * @param {number} value - The volume of the sound. - * - * @return {Phaser.Sound.HTML5AudioSound} This Sound instance. - */ - setVolume: function (value) - { - this.volume = value; - - return this; - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#rateEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted the event. - * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSound#rate property. - */ - - /** - * Rate at which this Sound will be played. - * 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. - * - * @name Phaser.Sound.HTML5AudioSound#rate - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rate: { - - get: function () - { - return this.currentConfig.rate; - }, - - set: function (value) - { - this.currentConfig.rate = value; - - if (this.manager.isLocked(this, 'rate', value)) - { - return; - } - else - { - this.calculateRate(); - - this.emit('rate', this, value); - } - } - - }, - - /** - * Sets the playback rate of this Sound. - * - * 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. - * - * @method Phaser.Sound.HTML5AudioSound#setRate - * @fires Phaser.Sound.HTML5AudioSound#rateEvent - * @since 3.3.0 - * - * @param {number} value - The playback rate at of this Sound. - * - * @return {Phaser.Sound.HTML5AudioSound} This Sound. - */ - setRate: function (value) - { - this.rate = value; - - return this; - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#detuneEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the Sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSound#detune property. - */ - - /** - * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @name Phaser.Sound.HTML5AudioSound#detune - * @type {number} - * @default 0 - * @since 3.0.0 - */ - detune: { - - get: function () - { - return this.currentConfig.detune; - }, - - set: function (value) - { - this.currentConfig.detune = value; - - if (this.manager.isLocked(this, 'detune', value)) - { - return; - } - else - { - this.calculateRate(); - - this.emit('detune', this, value); - } - } - - }, - - /** - * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @method Phaser.Sound.HTML5AudioSound#setDetune - * @fires Phaser.Sound.HTML5AudioSound#detuneEvent - * @since 3.3.0 - * - * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @return {Phaser.Sound.HTML5AudioSound} This Sound. - */ - setDetune: function (value) - { - this.detune = value; - - return this; - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#seekEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSound#seek property. - */ - - /** - * 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} - * @since 3.0.0 - */ - seek: { - - get: function () - { - if (this.isPlaying) - { - return this.audio.currentTime - (this.currentMarker ? this.currentMarker.start : 0); - } - else if (this.isPaused) - { - return this.currentConfig.seek; - } - else - { - return 0; - } - }, - - set: function (value) - { - if (this.manager.isLocked(this, 'seek', value)) - { - return; - } - - if (this.startTime > 0) - { - return; - } - - if (this.isPlaying || this.isPaused) - { - value = Math.min(Math.max(0, value), this.duration); - - if (this.isPlaying) - { - this.previousTime = value; - this.audio.currentTime = value; - } - else if (this.isPaused) - { - this.currentConfig.seek = value; - } - - this.emit('seek', this, value); - } - } - }, - - /** - * Seeks to a specific point in this sound. - * - * @method Phaser.Sound.HTML5AudioSound#setSeek - * @fires Phaser.Sound.HTML5AudioSound#seekEvent - * @since 3.4.0 - * - * @param {number} value - The point in the sound to seek to. - * - * @return {Phaser.Sound.HTML5AudioSound} This Sound instance. - */ - setSeek: function (value) - { - this.seek = value; - - return this; - }, - - /** - * @event Phaser.Sound.HTML5AudioSound#loopEvent - * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSound#loop property. - */ - - /** - * Flag indicating whether or not the sound or current sound marker will loop. - * - * @name Phaser.Sound.HTML5AudioSound#loop - * @type {boolean} - * @default false - * @since 3.0.0 - */ - loop: { - - get: function () - { - return this.currentConfig.loop; - }, - - set: function (value) - { - this.currentConfig.loop = value; - - if (this.manager.isLocked(this, 'loop', value)) - { - return; - } - - if (this.audio) - { - this.audio.loop = value; - } - - this.emit('loop', this, value); - } - - }, - - /** - * Sets the loop state of this Sound. - * - * @method Phaser.Sound.HTML5AudioSound#setLoop - * @fires Phaser.Sound.HTML5AudioSound#loopEvent - * @since 3.4.0 - * - * @param {boolean} value - `true` to loop this sound, `false` to not loop it. - * - * @return {Phaser.Sound.HTML5AudioSound} This Sound instance. - */ - setLoop: function (value) - { - this.loop = value; - - return this; - } - -}); - -module.exports = HTML5AudioSound; - - -/***/ }), -/* 190 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseSoundManager = __webpack_require__(79); -var Class = __webpack_require__(0); -var HTML5AudioSound = __webpack_require__(189); - -/** - * HTML5 Audio implementation of the Sound Manager. - * - * @class HTML5AudioSoundManager - * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var HTML5AudioSoundManager = new Class({ - - Extends: BaseSoundManager, - - initialize: - - function HTML5AudioSoundManager (game) - { - /** - * Flag indicating whether if there are no idle instances of HTML5 Audio tag, - * for any particular sound, if one of the used tags should be hijacked and used - * for succeeding playback or if succeeding Phaser.Sound.HTML5AudioSound#play - * call should be ignored. - * - * @name Phaser.Sound.HTML5AudioSoundManager#override - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.override = true; - - /** - * Value representing time difference, in seconds, between calling - * play method on an audio tag and when it actually starts playing. - * It is used to achieve more accurate delayed sound playback. - * - * You might need to tweak this value to get the desired results - * since audio play delay varies depending on the browser/platform. - * - * @name Phaser.Sound.HTML5AudioSoundManager#audioPlayDelay - * @type {number} - * @default 0.1 - * @since 3.0.0 - */ - this.audioPlayDelay = 0.1; - - /** - * A value by which we should offset the loop end marker of the - * looping sound to compensate for lag, caused by changing audio - * tag playback position, in order to achieve gapless looping. - * - * You might need to tweak this value to get the desired results - * since loop lag varies depending on the browser/platform. - * - * @name Phaser.Sound.HTML5AudioSoundManager#loopEndOffset - * @type {number} - * @default 0.05 - * @since 3.0.0 - */ - this.loopEndOffset = 0.05; - - /** - * An array for keeping track of all the sounds - * that were paused when game lost focus. - * - * @name Phaser.Sound.HTML5AudioSoundManager#onBlurPausedSounds - * @type {Phaser.Sound.HTML5AudioSound[]} - * @private - * @default [] - * @since 3.0.0 - */ - this.onBlurPausedSounds = []; - - this.locked = 'ontouchstart' in window; - - /** - * A queue of all actions performed on sound objects while audio was locked. - * Once the audio gets unlocked, after an explicit user interaction, - * all actions will be performed in chronological order. - * Array of object types: { sound: Phaser.Sound.HTML5AudioSound, name: string, value?: * } - * - * @name Phaser.Sound.HTML5AudioSoundManager#lockedActionsQueue - * @type {array} - * @private - * @since 3.0.0 - */ - this.lockedActionsQueue = this.locked ? [] : null; - - /** - * Property that actually holds the value of global mute - * for HTML5 Audio sound manager implementation. - * - * @name Phaser.Sound.HTML5AudioSoundManager#_mute - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._mute = false; - - /** - * Property that actually holds the value of global volume - * for HTML5 Audio sound manager implementation. - * - * @name Phaser.Sound.HTML5AudioSoundManager#_volume - * @type {boolean} - * @private - * @default 1 - * @since 3.0.0 - */ - this._volume = 1; - - BaseSoundManager.call(this, game); - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.HTML5AudioSoundManager#add - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.HTML5AudioSound} The new sound instance. - */ - add: function (key, config) - { - var sound = new HTML5AudioSound(this, key, config); - - this.sounds.push(sound); - - return sound; - }, - - /** - * Unlocks HTML5 Audio loading and playback on mobile - * devices on the initial explicit user interaction. - * - * @method Phaser.Sound.HTML5AudioSoundManager#unlock - * @since 3.0.0 - */ - unlock: function () - { - this.locked = false; - - var _this = this; - - this.game.cache.audio.entries.each(function (key, tags) - { - for (var i = 0; i < tags.length; i++) - { - if (tags[i].dataset.locked === 'true') - { - _this.locked = true; - - return false; - } - } - - return true; - }); - - if (!this.locked) - { - return; - } - - var moved = false; - - var detectMove = function () - { - moved = true; - }; - - var unlock = function () - { - if (moved) - { - moved = false; - return; - } - - document.body.removeEventListener('touchmove', detectMove); - document.body.removeEventListener('touchend', unlock); - - var lockedTags = []; - - _this.game.cache.audio.entries.each(function (key, tags) - { - for (var i = 0; i < tags.length; i++) - { - var tag = tags[i]; - - if (tag.dataset.locked === 'true') - { - lockedTags.push(tag); - } - } - - return true; - }); - - 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; - }; - - lockedTags.forEach(function (tag) - { - tag.load(); - }); - }; - - this.once('unlocked', function () - { - this.forEachActiveSound(function (sound) - { - if (sound.currentMarker === null && sound.duration === 0) - { - sound.duration = sound.tags[0].duration; - } - - sound.totalDuration = sound.tags[0].duration; - }); - - while (this.lockedActionsQueue.length) - { - var lockedAction = this.lockedActionsQueue.shift(); - - if (lockedAction.sound[lockedAction.prop].apply) - { - lockedAction.sound[lockedAction.prop].apply(lockedAction.sound, lockedAction.value || []); - } - else - { - lockedAction.sound[lockedAction.prop] = lockedAction.value; - } - } - - }, this); - - document.body.addEventListener('touchmove', detectMove, false); - document.body.addEventListener('touchend', unlock, false); - }, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.HTML5AudioSoundManager#onBlur - * @protected - * @since 3.0.0 - */ - onBlur: function () - { - this.forEachActiveSound(function (sound) - { - if (sound.isPlaying) - { - this.onBlurPausedSounds.push(sound); - sound.onBlur(); - } - }); - }, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.HTML5AudioSoundManager#onFocus - * @protected - * @since 3.0.0 - */ - onFocus: function () - { - this.onBlurPausedSounds.forEach(function (sound) - { - sound.onFocus(); - }); - - this.onBlurPausedSounds.length = 0; - }, - - /** - * Calls Phaser.Sound.BaseSoundManager#destroy method - * and cleans up all HTML5 Audio related stuff. - * - * @method Phaser.Sound.HTML5AudioSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - BaseSoundManager.prototype.destroy.call(this); - - this.onBlurPausedSounds.length = 0; - this.onBlurPausedSounds = null; - }, - - /** - * Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters - * to check if sound manager is locked and then either perform action immediately or queue it - * to be performed once the sound manager gets unlocked. - * - * @method Phaser.Sound.HTML5AudioSoundManager#isLocked - * @protected - * @since 3.0.0 - * - * @param {Phaser.Sound.HTML5AudioSound} sound - Sound object on which to perform queued action. - * @param {string} prop - Name of the method to be called or property to be assigned a value to. - * @param {*} [value] - An optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property. - * - * @return {boolean} Whether the sound manager is locked. - */ - isLocked: function (sound, prop, value) - { - if (sound.tags[0].dataset.locked === 'true') - { - this.lockedActionsQueue.push({ - sound: sound, - prop: prop, - value: value - }); - - return true; - } - - return false; - }, - - /** - * @event Phaser.Sound.HTML5AudioSoundManager#muteEvent - * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#mute property. - */ - - /** - * Sets the muted state of all this Sound Manager. - * - * @method Phaser.Sound.HTML5AudioSoundManager#setMute - * @fires Phaser.Sound.HTML5AudioSoundManager#muteEvent - * @since 3.3.0 - * - * @param {boolean} value - `true` to mute all sounds, `false` to unmute them. - * - * @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager. - */ - setMute: function (value) - { - this.mute = value; - - return this; - }, - - /** - * @name Phaser.Sound.HTML5AudioSoundManager#mute - * @type {boolean} - * @fires Phaser.Sound.HTML5AudioSoundManager#muteEvent - * @since 3.0.0 - */ - mute: { - - get: function () - { - return this._mute; - }, - - set: function (value) - { - this._mute = value; - - this.forEachActiveSound(function (sound) - { - sound.updateMute(); - }); - - this.emit('mute', this, value); - } - - }, - - /** - * @event Phaser.Sound.HTML5AudioSoundManager#volumeEvent - * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#volume property. - */ - - /** - * Sets the volume of this Sound Manager. - * - * @method Phaser.Sound.HTML5AudioSoundManager#setVolume - * @fires Phaser.Sound.HTML5AudioSoundManager#volumeEvent - * @since 3.3.0 - * - * @param {number} value - The global volume of this Sound Manager. - * - * @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager. - */ - setVolume: function (value) - { - this.volume = value; - - return this; - }, - - /** - * @name Phaser.Sound.HTML5AudioSoundManager#volume - * @type {number} - * @fires Phaser.Sound.HTML5AudioSoundManager#volumeEvent - * @since 3.0.0 - */ - volume: { - - get: function () - { - return this._volume; - }, - - set: function (value) - { - this._volume = value; - - this.forEachActiveSound(function (sound) - { - sound.updateVolume(); - }); - - this.emit('volume', this, value); - } - - } - -}); - -module.exports = HTML5AudioSoundManager; - - -/***/ }), -/* 191 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HTML5AudioSoundManager = __webpack_require__(190); -var NoAudioSoundManager = __webpack_require__(188); -var WebAudioSoundManager = __webpack_require__(186); - -/** - * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. - * - * Be aware of https://developers.google.com/web/updates/2017/09/autoplay-policy-changes - * - * @function Phaser.Sound.SoundManagerCreator - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var SoundManagerCreator = { - - create: function (game) - { - var audioConfig = game.config.audio; - var deviceAudio = game.device.audio; - - if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - return new NoAudioSoundManager(game); - } - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - return new WebAudioSoundManager(game); - } - - return new HTML5AudioSoundManager(game); - } - -}; - -module.exports = SoundManagerCreator; - - -/***/ }), -/* 192 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(55); -var GetValue = __webpack_require__(4); -var Merge = __webpack_require__(94); -var InjectionMap = __webpack_require__(516); - -/** - * @namespace Phaser.Scenes.Settings - */ - -/** - * @typedef {object} Phaser.Scenes.Settings.Config - * - * @property {string} [key] - [description] - * @property {boolean} [active=false] - [description] - * @property {boolean} [visible=true] - [description] - * @property {(false|Phaser.Loader.FileTypes.PackFileConfig)} [pack=false] - [description] - * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} [cameras=null] - [description] - * @property {Object.} [map] - Overwrites the default injection map for a scene. - * @property {Object.} [mapAdd] - Extends the injection map for a scene. - * @property {object} [physics={}] - [description] - * @property {object} [loader={}] - [description] - * @property {(false|*)} [plugins=false] - [description] - */ - -/** - * @typedef {object} Phaser.Scenes.Settings.Object - * - * @property {number} status - [description] - * @property {string} key - [description] - * @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|Phaser.Loader.FileTypes.PackFileConfig)} pack - [description] - * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} cameras - [description] - * @property {Object.} map - [description] - * @property {object} physics - [description] - * @property {object} loader - [description] - * @property {(false|*)} plugins - [description] - */ - -var Settings = { - - /** - * Takes a Scene configuration object and returns a fully formed Systems object. - * - * @function Phaser.Scenes.Settings.create - * @since 3.0.0 - * - * @param {(string|Phaser.Scenes.Settings.Config)} config - [description] - * - * @return {Phaser.Scenes.Settings.Object} [description] - */ - create: function (config) - { - if (typeof config === 'string') - { - config = { key: config }; - } - else if (config === undefined) - { - // Pass the 'hasOwnProperty' checks - config = {}; - } - - return { - - status: CONST.PENDING, - - key: GetValue(config, 'key', ''), - active: GetValue(config, 'active', false), - visible: GetValue(config, 'visible', true), - - isBooted: false, - - isTransition: false, - transitionFrom: null, - transitionDuration: 0, - transitionAllowInput: true, - - // Loader payload array - - data: {}, - - pack: GetValue(config, 'pack', false), - - // Cameras - - cameras: GetValue(config, 'cameras', null), - - // Scene Property Injection Map - - map: GetValue(config, 'map', Merge(InjectionMap, GetValue(config, 'mapAdd', {}))), - - // Physics - - physics: GetValue(config, 'physics', {}), - - // Loader - - loader: GetValue(config, 'loader', {}), - - // Plugins - - plugins: GetValue(config, 'plugins', false), - - // Input - - input: GetValue(config, 'input', {}) - - }; - } - -}; - -module.exports = Settings; - - -/***/ }), -/* 193 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Systems = __webpack_require__(118); - -/** - * @classdesc - * [description] - * - * @class Scene - * @memberOf Phaser - * @constructor - * @since 3.0.0 - * - * @param {(string|Phaser.Scenes.Settings.Config)} config - Scene specific configuration settings. - */ -var Scene = new Class({ - - initialize: - - function Scene (config) - { - /** - * The Scene Systems. You must never overwrite this property, or all hell will break lose. - * - * @name Phaser.Scene#sys - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.sys = new Systems(this, config); - - /** - * A reference to the Phaser.Game instance. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game; - - /** - * A reference to the global Animation Manager. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#anims - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.anims; - - /** - * A reference to the global Cache. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#cache - * @type {Phaser.Cache.CacheManager} - * @since 3.0.0 - */ - this.cache; - - /** - * A reference to the game level Data Manager. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#registry - * @type {Phaser.Data.DataManager} - * @since 3.0.0 - */ - this.registry; - - /** - * A reference to the Sound Manager. - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - * - * @name Phaser.Scene#sound - * @type {Phaser.Sound.BaseSoundManager} - * @since 3.0.0 - */ - this.sound; - - /** - * A reference to the Texture Manager. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#textures - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.textures; - - /** - * A scene level Event Emitter. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events; - - /** - * A scene level Camera System. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#cameras - * @type {Phaser.Cameras.Scene2D.CameraManager} - * @since 3.0.0 - */ - this.cameras; - - /** - * A scene level 3D Camera System. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#cameras3d - * @type {Phaser.Cameras.Sprite3D.CameraManager} - * @since 3.0.0 - */ - this.cameras3d; - - /** - * A scene level Game Object Factory. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#add - * @type {Phaser.GameObjects.GameObjectFactory} - * @since 3.0.0 - */ - this.add; - - /** - * A scene level Game Object Creator. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#make - * @type {Phaser.GameObjects.GameObjectCreator} - * @since 3.0.0 - */ - this.make; - - /** - * A reference to the Scene Manager Plugin. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#scene - * @type {Phaser.Scenes.ScenePlugin} - * @since 3.0.0 - */ - this.scene; - - /** - * A scene level Game Object Display List. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#children - * @type {Phaser.GameObjects.DisplayList} - * @since 3.0.0 - */ - this.children; - - /** - * A scene level Lights Manager Plugin. - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - * - * @name Phaser.Scene#lights - * @type {Phaser.GameObjects.LightsManager} - * @since 3.0.0 - */ - this.lights; - - /** - * A scene level Data Manager Plugin. - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - * - * @name Phaser.Scene#data - * @type {Phaser.Data.DataManager} - * @since 3.0.0 - */ - this.data; - - /** - * A scene level Input Manager Plugin. - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - * - * @name Phaser.Scene#input - * @type {Phaser.Input.InputPlugin} - * @since 3.0.0 - */ - this.input; - - /** - * A scene level Loader Plugin. - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - * - * @name Phaser.Scene#load - * @type {Phaser.Loader.LoaderPlugin} - * @since 3.0.0 - */ - this.load; - - /** - * A scene level Time and Clock Plugin. - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - * - * @name Phaser.Scene#time - * @type {Phaser.Time.Clock} - * @since 3.0.0 - */ - this.time; - - /** - * A scene level Tween Manager Plugin. - * This property will only be available if defined in the Scene Injection Map and the plugin is installed. - * - * @name Phaser.Scene#tweens - * @type {Phaser.Tweens.TweenManager} - * @since 3.0.0 - */ - this.tweens; - - /** - * A scene level Arcade Physics Plugin. - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - * - * @name Phaser.Scene#physics - * @type {Phaser.Physics.Arcade.ArcadePhysics} - * @since 3.0.0 - */ - this.physics; - - /** - * A scene level Impact Physics Plugin. - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - * - * @name Phaser.Scene#impact - * @type {Phaser.Physics.Impact.ImpactPhysics} - * @since 3.0.0 - */ - this.impact; - - /** - * A scene level Matter Physics Plugin. - * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. - * - * @name Phaser.Scene#matter - * @type {Phaser.Physics.Matter.MatterPhysics} - * @since 3.0.0 - */ - this.matter; - }, - - /** - * Should be overridden by your own Scenes. - * - * @method Phaser.Scene#update - * @override - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - update: function () - { - } - -}); - -module.exports = Scene; - - -/***/ }), -/* 194 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(55); -var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var Scene = __webpack_require__(193); -var Systems = __webpack_require__(118); - -/** - * @classdesc - * The Scene Manager. - * - * The Scene Manager is a Game level system, responsible for creating, processing and updating all of the - * Scenes in a Game instance. - * - * - * @class SceneManager - * @memberOf Phaser.Scenes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance this Scene Manager belongs to. - * @param {object} sceneConfig - Scene specific configuration settings. - */ -var SceneManager = new Class({ - - initialize: - - function SceneManager (game, sceneConfig) - { - /** - * The Game that this SceneManager belongs to. - * - * @name Phaser.Scenes.SceneManager#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * An object that maps the keys to the scene so we can quickly get a scene from a key without iteration. - * - * @name Phaser.Scenes.SceneManager#keys - * @type {object} - * @since 3.0.0 - */ - this.keys = {}; - - /** - * The array in which all of the scenes are kept. - * - * @name Phaser.Scenes.SceneManager#scenes - * @type {array} - * @since 3.0.0 - */ - this.scenes = []; - - /** - * Scenes pending to be added are stored in here until the manager has time to add it. - * - * @name Phaser.Scenes.SceneManager#_pending - * @type {array} - * @private - * @since 3.0.0 - */ - this._pending = []; - - /** - * An array of scenes waiting to be started once the game has booted. - * - * @name Phaser.Scenes.SceneManager#_start - * @type {array} - * @private - * @since 3.0.0 - */ - this._start = []; - - /** - * An operations queue, because we don't manipulate the scenes array during processing. - * - * @name Phaser.Scenes.SceneManager#_queue - * @type {array} - * @private - * @since 3.0.0 - */ - this._queue = []; - - /** - * Boot time data to merge. - * - * @name Phaser.Scenes.SceneManager#_data - * @type {object} - * @private - * @since 3.4.0 - */ - this._data = {}; - - /** - * Is the Scene Manager actively processing the Scenes list? - * - * @name Phaser.Scenes.SceneManager#isProcessing - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isProcessing = false; - - /** - * Has the Scene Manager properly started? - * - * @name Phaser.Scenes.SceneManager#isBooted - * @type {boolean} - * @default false - * @readOnly - * @since 3.4.0 - */ - this.isBooted = false; - - if (sceneConfig) - { - if (!Array.isArray(sceneConfig)) - { - sceneConfig = [ sceneConfig ]; - } - - for (var i = 0; i < sceneConfig.length; i++) - { - // The i === 0 part just autostarts the first Scene given (unless it says otherwise in its config) - this._pending.push({ - key: 'default', - scene: sceneConfig[i], - autoStart: (i === 0), - data: {} - }); - } - } - - game.events.once('ready', this.bootQueue, this); - }, - - /** - * Internal first-time Scene boot handler. - * - * @method Phaser.Scenes.SceneManager#bootQueue - * @private - * @since 3.2.0 - */ - bootQueue: function () - { - if (this.isBooted) - { - return; - } - - var i; - var entry; - var key; - var sceneConfig; - - for (i = 0; i < this._pending.length; i++) - { - entry = this._pending[i]; - - key = entry.key; - sceneConfig = entry.scene; - - var newScene; - - if (sceneConfig instanceof Scene) - { - newScene = this.createSceneFromInstance(key, sceneConfig); - } - else if (typeof sceneConfig === 'object') - { - newScene = this.createSceneFromObject(key, sceneConfig); - } - else if (typeof sceneConfig === 'function') - { - newScene = this.createSceneFromFunction(key, sceneConfig); - } - - // Replace key in case the scene changed it - key = newScene.sys.settings.key; - - this.keys[key] = newScene; - - this.scenes.push(newScene); - - // Any data to inject? - if (this._data[key]) - { - newScene.sys.settings.data = this._data[key].data; - - if (this._data[key].autoStart) - { - entry.autoStart = true; - } - } - - if (entry.autoStart || newScene.sys.settings.active) - { - this._start.push(key); - } - } - - // Clear the pending lists - this._pending.length = 0; - - this._data = {}; - - this.isBooted = true; - - // _start might have been populated by the above - for (i = 0; i < this._start.length; i++) - { - entry = this._start[i]; - - this.start(entry); - } - - this._start.length = 0; - }, - - /** - * Process the Scene operations queue. - * - * @method Phaser.Scenes.SceneManager#processQueue - * @since 3.0.0 - */ - processQueue: function () - { - var pendingLength = this._pending.length; - var queueLength = this._queue.length; - - if (pendingLength === 0 && queueLength === 0) - { - return; - } - - var i; - var entry; - - if (pendingLength) - { - for (i = 0; i < pendingLength; i++) - { - entry = this._pending[i]; - - this.add(entry.key, entry.scene, entry.autoStart, entry.data); - } - - // _start might have been populated by this.add - for (i = 0; i < this._start.length; i++) - { - entry = this._start[i]; - - this.start(entry); - } - - // Clear the pending lists - this._start.length = 0; - this._pending.length = 0; - - return; - } - - for (i = 0; i < this._queue.length; i++) - { - entry = this._queue[i]; - - this[entry.op](entry.keyA, entry.keyB); - } - - this._queue.length = 0; - }, - - /** - * Adds a new Scene into the SceneManager. - * You must give each Scene a unique key by which you'll identify it. - * - * The `sceneConfig` can be: - * - * * A `Phaser.Scene` object, or an object that extends it. - * * A plain JavaScript object - * * A JavaScript ES6 Class that extends `Phaser.Scene` - * * A JavaScript ES5 prototype based Class - * * A JavaScript function - * - * If a function is given then a new Scene will be created by calling it. - * - * @method Phaser.Scenes.SceneManager#add - * @since 3.0.0 - * - * @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. - * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The config for the Scene - * @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added. - * @param {object} [data] - Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`. - * - * @return {?Phaser.Scene} The added Scene, if it was added immediately, otherwise `null`. - */ - add: function (key, sceneConfig, autoStart, data) - { - if (autoStart === undefined) { autoStart = false; } - if (data === undefined) { data = {}; } - - // If processing or not booted then put scene into a holding pattern - if (this.isProcessing || !this.isBooted) - { - this._pending.push({ - key: key, - scene: sceneConfig, - autoStart: autoStart, - data: data - }); - - if (!this.isBooted) - { - this._data[key] = { data: data }; - } - - return null; - } - - key = this.getKey(key, sceneConfig); - - var newScene; - - if (sceneConfig instanceof Scene) - { - newScene = this.createSceneFromInstance(key, sceneConfig); - } - else if (typeof sceneConfig === 'object') - { - sceneConfig.key = key; - - newScene = this.createSceneFromObject(key, sceneConfig); - } - else if (typeof sceneConfig === 'function') - { - newScene = this.createSceneFromFunction(key, sceneConfig); - } - - // Any data to inject? - newScene.sys.settings.data = data; - - // Replace key in case the scene changed it - key = newScene.sys.settings.key; - - this.keys[key] = newScene; - - this.scenes.push(newScene); - - if (autoStart || newScene.sys.settings.active) - { - if (this._pending.length) - { - this._start.push(key); - } - else - { - this.start(key); - } - } - - return newScene; - }, - - /** - * Removes a Scene from the SceneManager. - * - * The Scene is removed from the local scenes array, it's key is cleared from the keys - * cache and Scene.Systems.destroy is then called on it. - * - * If the SceneManager is processing the Scenes when this method is called it wil - * queue the operation for the next update sequence. - * - * @method Phaser.Scenes.SceneManager#remove - * @since 3.2.0 - * - * @param {(string|Phaser.Scene)} scene - The Scene to be removed. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - remove: function (key) - { - if (this.isProcessing) - { - this._queue.push({ op: 'remove', keyA: key, keyB: null }); - } - else - { - var sceneToRemove = this.getScene(key); - - if (!sceneToRemove || sceneToRemove.sys.isTransitioning()) - { - return this; - } - - var index = this.scenes.indexOf(sceneToRemove); - var sceneKey = sceneToRemove.sys.settings.key; - - if (index > -1) - { - delete this.keys[sceneKey]; - this.scenes.splice(index, 1); - - if (this._start.indexOf(sceneKey) > -1) - { - index = this._start.indexOf(sceneKey); - this._start.splice(index, 1); - } - - sceneToRemove.sys.destroy(); - } - } - - return this; - }, - - /** - * Boot the given Scene. - * - * @method Phaser.Scenes.SceneManager#bootScene - * @private - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to boot. - */ - bootScene: function (scene) - { - var sys = scene.sys; - var settings = sys.settings; - - if (scene.init) - { - scene.init.call(scene, settings.data); - - if (settings.isTransition) - { - sys.events.emit('transitioninit', settings.transitionFrom, settings.transitionDuration); - } - } - - var loader; - - if (sys.load) - { - loader = sys.load; - - loader.reset(); - } - - if (loader && scene.preload) - { - scene.preload.call(scene); - - // Is the loader empty? - if (loader.list.size === 0) - { - this.create(scene); - } - else - { - settings.status = CONST.LOADING; - - // Start the loader going as we have something in the queue - loader.once('complete', this.loadComplete, this); - - loader.start(); - } - } - else - { - // No preload? Then there was nothing to load either - this.create(scene); - } - }, - - /** - * Handles load completion for a Scene's Loader. - * - * Starts the Scene that the Loader belongs to. - * - * @method Phaser.Scenes.SceneManager#loadComplete - * @private - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - The loader that has completed loading. - */ - loadComplete: function (loader) - { - 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); - }, - - /** - * Handle payload completion for a Scene. - * - * @method Phaser.Scenes.SceneManager#payloadComplete - * @private - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - The loader that has completed loading its Scene's payload. - */ - payloadComplete: function (loader) - { - this.bootScene(loader.scene); - }, - - /** - * Updates the Scenes. - * - * @method Phaser.Scenes.SceneManager#update - * @since 3.0.0 - * - * @param {number} time - Time elapsed. - * @param {number} delta - Delta time from the last update. - */ - update: function (time, delta) - { - this.processQueue(); - - this.isProcessing = true; - - // Loop through the active scenes in reverse order - for (var i = this.scenes.length - 1; i >= 0; i--) - { - var sys = this.scenes[i].sys; - - if (sys.settings.status > CONST.START && sys.settings.status <= CONST.RUNNING) - { - sys.step(time, delta); - } - } - }, - - /** - * Informs the Scenes of the Game being resized. - * - * @method Phaser.Scenes.SceneManager#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the game. - * @param {number} height - The new height of the game. - */ - resize: function (width, height) - { - // Loop through the scenes in forward order - for (var i = 0; i < this.scenes.length; i++) - { - var sys = this.scenes[i].sys; - - sys.resize(width, height); - } - }, - - /** - * Renders the Scenes. - * - * @method Phaser.Scenes.SceneManager#render - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The renderer to use. - */ - render: function (renderer) - { - // Loop through the scenes in forward order - for (var i = 0; i < this.scenes.length; i++) - { - var sys = this.scenes[i].sys; - - if (sys.settings.visible && sys.settings.status >= CONST.LOADING && sys.settings.status < CONST.SLEEPING) - { - sys.render(renderer); - } - } - - this.isProcessing = false; - }, - - /** - * Calls the given Scene's {@link Phaser.Scene#create} method and updates its status. - * - * @method Phaser.Scenes.SceneManager#create - * @private - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to create. - */ - 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); - } - } - - // If the Scene has an update function we'll set it now, otherwise it'll remain as NOOP - if (scene.update) - { - sys.sceneUpdate = scene.update; - } - - settings.status = CONST.RUNNING; - }, - - /** - * Creates and initializes a Scene from a function. - * - * @method Phaser.Scenes.SceneManager#createSceneFromFunction - * @private - * @since 3.0.0 - * - * @param {string} key - The key of the Scene. - * @param {function} scene - The function to create the Scene from. - * - * @return {Phaser.Scene} The created Scene. - */ - createSceneFromFunction: function (key, scene) - { - var newScene = new scene(); - - if (newScene instanceof Scene) - { - var configKey = newScene.sys.settings.key; - - if (configKey !== '') - { - key = configKey; - } - - if (this.keys.hasOwnProperty(key)) - { - throw new Error('Cannot add a Scene with duplicate key: ' + key); - } - - return this.createSceneFromInstance(key, newScene); - } - else - { - newScene.sys = new Systems(newScene); - - newScene.sys.settings.key = key; - - newScene.sys.init(this.game); - - return newScene; - } - }, - - /** - * Creates and initializes a Scene instance. - * - * @method Phaser.Scenes.SceneManager#createSceneFromInstance - * @private - * @since 3.0.0 - * - * @param {string} key - The key of the Scene. - * @param {Phaser.Scene} newScene - The Scene instance. - * - * @return {Phaser.Scene} The created Scene. - */ - createSceneFromInstance: function (key, newScene) - { - var configKey = newScene.sys.settings.key; - - if (configKey !== '') - { - key = configKey; - } - else - { - newScene.sys.settings.key = key; - } - - newScene.sys.init(this.game); - - return newScene; - }, - - /** - * Creates and initializes a Scene from an Object definition. - * - * @method Phaser.Scenes.SceneManager#createSceneFromObject - * @private - * @since 3.0.0 - * - * @param {string} key - The key of the Scene. - * @param {(string|Phaser.Scenes.Settings.Config)} sceneConfig - The Scene config. - * - * @return {Phaser.Scene} The created Scene. - */ - createSceneFromObject: function (key, sceneConfig) - { - var newScene = new Scene(sceneConfig); - - var configKey = newScene.sys.settings.key; - - if (configKey !== '') - { - key = configKey; - } - else - { - newScene.sys.settings.key = key; - } - - newScene.sys.init(this.game); - - // Extract callbacks - - var defaults = [ 'init', 'preload', 'create', 'update', 'render' ]; - - for (var i = 0; i < defaults.length; i++) - { - var sceneCallback = GetValue(sceneConfig, defaults[i], null); - - if (sceneCallback) - { - newScene[defaults[i]] = sceneCallback; - } - } - - // Now let's move across any other functions or properties that may exist in the extend object: - - /* - scene: { - preload: preload, - create: create, - extend: { - hello: 1, - test: 'atari', - addImage: addImage - } - } - */ - - if (sceneConfig.hasOwnProperty('extend')) - { - for (var propertyKey in sceneConfig.extend) - { - var value = sceneConfig.extend[propertyKey]; - - if (propertyKey === 'data' && newScene.hasOwnProperty('data') && typeof value === 'object') - { - // Populate the DataManager - newScene.data.merge(value); - } - else if (propertyKey !== 'sys') - { - newScene[propertyKey] = value; - } - } - } - - return newScene; - }, - - /** - * Retrieves the key of a Scene from a Scene config. - * - * @method Phaser.Scenes.SceneManager#getKey - * @private - * @since 3.0.0 - * - * @param {string} key - The key to check in the Scene config. - * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The Scene config. - * - * @return {string} The Scene key. - */ - getKey: function (key, sceneConfig) - { - if (!key) { key = 'default'; } - - if (typeof sceneConfig === 'function') - { - return key; - } - else if (sceneConfig instanceof Scene) - { - key = sceneConfig.sys.settings.key; - } - else if (typeof sceneConfig === 'object' && sceneConfig.hasOwnProperty('key')) - { - key = sceneConfig.key; - } - - // By this point it's either 'default' or extracted from the Scene - - if (this.keys.hasOwnProperty(key)) - { - throw new Error('Cannot add a Scene with duplicate key: ' + key); - } - else - { - return key; - } - }, - - /** - * Retrieves a Scene. - * - * @method Phaser.Scenes.SceneManager#getScene - * @since 3.0.0 - * - * @param {string|Phaser.Scene} key - The Scene to retrieve. - * - * @return {?Phaser.Scene} The Scene. - */ - getScene: function (key) - { - if (typeof key === 'string') - { - if (this.keys[key]) - { - return this.keys[key]; - } - } - else - { - for (var i = 0; i < this.scenes.length; i++) - { - if (key === this.scenes[i]) - { - return key; - } - } - } - - return null; - }, - - /** - * Determines whether a Scene is active. - * - * @method Phaser.Scenes.SceneManager#isActive - * @since 3.0.0 - * - * @param {string} key - The Scene to check. - * - * @return {boolean} Whether the Scene is active. - */ - isActive: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - return scene.sys.isActive(); - } - - return null; - }, - - /** - * Determines whether a Scene is visible. - * - * @method Phaser.Scenes.SceneManager#isVisible - * @since 3.0.0 - * - * @param {string} key - The Scene to check. - * - * @return {boolean} Whether the Scene is visible. - */ - isVisible: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - return scene.sys.isVisible(); - } - - return null; - }, - - /** - * Determines whether a Scene is sleeping. - * - * @method Phaser.Scenes.SceneManager#isSleeping - * @since 3.0.0 - * - * @param {string} key - The Scene to check. - * - * @return {boolean} Whether the Scene is sleeping. - */ - isSleeping: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - return scene.sys.isSleeping(); - } - - return null; - }, - - /** - * Pauses the given Scene. - * - * @method Phaser.Scenes.SceneManager#pause - * @since 3.0.0 - * - * @param {string} key - The Scene to pause. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - pause: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.pause(); - } - - return this; - }, - - /** - * Resumes the given Scene. - * - * @method Phaser.Scenes.SceneManager#resume - * @since 3.0.0 - * - * @param {string} key - The Scene to resume. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - resume: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.resume(); - } - - return this; - }, - - /** - * Puts the given Scene to sleep. - * - * @method Phaser.Scenes.SceneManager#sleep - * @since 3.0.0 - * - * @param {string} key - The Scene to put to sleep. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - sleep: function (key) - { - var scene = this.getScene(key); - - if (scene && !scene.sys.isTransitioning()) - { - scene.sys.sleep(); - } - - return this; - }, - - /** - * Awakens the given Scene. - * - * @method Phaser.Scenes.SceneManager#wake - * @since 3.0.0 - * - * @param {string} key - The Scene to wake up. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - wake: function (key) - { - var scene = this.getScene(key); - - if (scene) - { - scene.sys.wake(); - } - - return this; - }, - - /** - * Runs the given Scene, but does not change the state of this Scene. - * - * If the given Scene is paused, it will resume it. If sleeping, it will wake it. - * If not running at all, it will be started. - * - * Use this if you wish to open a modal Scene by calling `pause` on the current - * Scene, then `run` on the modal Scene. - * - * @method Phaser.Scenes.SceneManager#run - * @since 3.10.0 - * - * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. - * - * @return {Phaser.Scenes.SceneManager} This Scene Manager. - */ - run: function (key, data) - { - var scene = this.getScene(key); - - if (!scene) - { - return this; - } - - if (scene.sys.isSleeping()) - { - // Sleeping? - scene.sys.wake(); - } - else if (scene.sys.isBooted && !scene.sys.isActive()) - { - // Paused? - scene.sys.resume(); - } - else - { - // Not actually running? - this.start(key, data); - } - }, - - /** - * Starts the given Scene. - * - * @method Phaser.Scenes.SceneManager#start - * @since 3.0.0 - * - * @param {string} key - The Scene to start. - * @param {object} [data] - Optional data object to pass to Scene.Settings and Scene.init. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - start: function (key, data) - { - // If the Scene Manager is not running, then put the Scene into a holding pattern - if (!this.isBooted) - { - this._data[key] = { - autoStart: true, - data: data - }; - - return this; - } - - var scene = this.getScene(key); - - if (scene) - { - scene.sys.start(data); - - var loader; - - if (scene.sys.load) - { - loader = scene.sys.load; - } - - // Files payload? - if (loader && scene.sys.settings.hasOwnProperty('pack')) - { - loader.reset(); - - if (loader.addPack({ payload: scene.sys.settings.pack })) - { - scene.sys.settings.status = CONST.LOADING; - - loader.once('complete', this.payloadComplete, this); - - loader.start(); - - return this; - } - } - - this.bootScene(scene); - } - - return this; - }, - - /** - * Stops the given Scene. - * - * @method Phaser.Scenes.SceneManager#stop - * @since 3.0.0 - * - * @param {string} key - The Scene to stop. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - stop: function (key) - { - var scene = this.getScene(key); - - if (scene && !scene.sys.isTransitioning()) - { - scene.sys.shutdown(); - } - - return this; - }, - - /** - * Sleeps one one Scene and starts the other. - * - * @method Phaser.Scenes.SceneManager#switch - * @since 3.0.0 - * - * @param {string} from - The Scene to sleep. - * @param {string} to - The Scene to start. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - switch: function (from, to) - { - var sceneA = this.getScene(from); - var sceneB = this.getScene(to); - - if (sceneA && sceneB && sceneA !== sceneB) - { - this.sleep(from); - - if (this.isSleeping(to)) - { - this.wake(to); - } - else - { - this.start(to); - } - } - - return this; - }, - - /** - * Retrieves a Scene by numeric index. - * - * @method Phaser.Scenes.SceneManager#getAt - * @since 3.0.0 - * - * @param {integer} index - The index of the Scene to retrieve. - * - * @return {(Phaser.Scene|undefined)} The Scene. - */ - getAt: function (index) - { - return this.scenes[index]; - }, - - /** - * Retrieves the numeric index of a Scene. - * - * @method Phaser.Scenes.SceneManager#getIndex - * @since 3.0.0 - * - * @param {(string|Phaser.Scene)} key - The key of the Scene. - * - * @return {integer} The index of the Scene. - */ - getIndex: function (key) - { - var scene = this.getScene(key); - - return this.scenes.indexOf(scene); - }, - - /** - * Brings a Scene to the top of the Scenes list. - * - * This means it will render above all other Scenes. - * - * @method Phaser.Scenes.SceneManager#bringToTop - * @since 3.0.0 - * - * @param {(string|Phaser.Scene)} key - The Scene to move. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - bringToTop: function (key) - { - if (this.isProcessing) - { - this._queue.push({ op: 'bringToTop', keyA: key, keyB: null }); - } - else - { - var index = this.getIndex(key); - - if (index !== -1 && index < this.scenes.length) - { - var scene = this.getScene(key); - - this.scenes.splice(index, 1); - this.scenes.push(scene); - } - } - - return this; - }, - - /** - * Sends a Scene to the back of the Scenes list. - * - * This means it will render below all other Scenes. - * - * @method Phaser.Scenes.SceneManager#sendToBack - * @since 3.0.0 - * - * @param {(string|Phaser.Scene)} key - The Scene to move. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - sendToBack: function (key) - { - if (this.isProcessing) - { - this._queue.push({ op: 'sendToBack', keyA: key, keyB: null }); - } - else - { - var index = this.getIndex(key); - - if (index !== -1 && index > 0) - { - var scene = this.getScene(key); - - this.scenes.splice(index, 1); - this.scenes.unshift(scene); - } - } - - return this; - }, - - /** - * Moves a Scene down one position in the Scenes list. - * - * @method Phaser.Scenes.SceneManager#moveDown - * @since 3.0.0 - * - * @param {(string|Phaser.Scene)} key - The Scene to move. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - moveDown: function (key) - { - if (this.isProcessing) - { - this._queue.push({ op: 'moveDown', keyA: key, keyB: null }); - } - else - { - var indexA = this.getIndex(key); - - if (indexA > 0) - { - var indexB = indexA - 1; - var sceneA = this.getScene(key); - var sceneB = this.getAt(indexB); - - this.scenes[indexA] = sceneB; - this.scenes[indexB] = sceneA; - } - } - - return this; - }, - - /** - * Moves a Scene up one position in the Scenes list. - * - * @method Phaser.Scenes.SceneManager#moveUp - * @since 3.0.0 - * - * @param {(string|Phaser.Scene)} key - The Scene to move. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - moveUp: function (key) - { - if (this.isProcessing) - { - this._queue.push({ op: 'moveUp', keyA: key, keyB: null }); - } - else - { - var indexA = this.getIndex(key); - - if (indexA < this.scenes.length - 1) - { - var indexB = indexA + 1; - var sceneA = this.getScene(key); - var sceneB = this.getAt(indexB); - - this.scenes[indexA] = sceneB; - this.scenes[indexB] = sceneA; - } - } - - return this; - }, - - /** - * Moves a Scene so it is immediately above another Scene in the Scenes list. - * - * This means it will render over the top of the other Scene. - * - * @method Phaser.Scenes.SceneManager#moveAbove - * @since 3.2.0 - * - * @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above. - * @param {(string|Phaser.Scene)} keyB - The Scene to be moved. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - moveAbove: function (keyA, keyB) - { - if (keyA === keyB) - { - return this; - } - - if (this.isProcessing) - { - this._queue.push({ op: 'moveAbove', keyA: keyA, keyB: keyB }); - } - else - { - var indexA = this.getIndex(keyA); - var indexB = this.getIndex(keyB); - - if (indexA !== -1 && indexB !== -1) - { - var tempScene = this.getAt(indexB); - - // Remove - this.scenes.splice(indexB, 1); - - // Add in new location - this.scenes.splice(indexA + 1, 0, tempScene); - } - } - - return this; - }, - - /** - * Moves a Scene so it is immediately below another Scene in the Scenes list. - * - * This means it will render behind the other Scene. - * - * @method Phaser.Scenes.SceneManager#moveBelow - * @since 3.2.0 - * - * @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above. - * @param {(string|Phaser.Scene)} keyB - The Scene to be moved. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - moveBelow: function (keyA, keyB) - { - if (keyA === keyB) - { - return this; - } - - if (this.isProcessing) - { - this._queue.push({ op: 'moveBelow', keyA: keyA, keyB: keyB }); - } - else - { - var indexA = this.getIndex(keyA); - var indexB = this.getIndex(keyB); - - if (indexA !== -1 && indexB !== -1) - { - var tempScene = this.getAt(indexB); - - // Remove - this.scenes.splice(indexB, 1); - - if (indexA === 0) - { - this.scenes.unshift(tempScene); - } - else - { - // Add in new location - this.scenes.splice(indexA, 0, tempScene); - } - } - } - - return this; - }, - - /** - * Queue a Scene operation for the next update. - * - * @method Phaser.Scenes.SceneManager#queueOp - * @private - * @since 3.0.0 - * - * @param {string} op - The operation to perform. - * @param {(string|Phaser.Scene)} keyA - Scene A. - * @param {(string|Phaser.Scene)} [keyB] - Scene B. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - queueOp: function (op, keyA, keyB) - { - this._queue.push({ op: op, keyA: keyA, keyB: keyB }); - - return this; - }, - - /** - * Swaps the positions of two Scenes in the Scenes list. - * - * @method Phaser.Scenes.SceneManager#swapPosition - * @since 3.0.0 - * - * @param {(string|Phaser.Scene)} keyA - The first Scene to swap. - * @param {(string|Phaser.Scene)} keyB - The second Scene to swap. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - swapPosition: function (keyA, keyB) - { - if (keyA === keyB) - { - return this; - } - - if (this.isProcessing) - { - this._queue.push({ op: 'swapPosition', keyA: keyA, keyB: keyB }); - } - else - { - var indexA = this.getIndex(keyA); - var indexB = this.getIndex(keyB); - - if (indexA !== indexB && indexA !== -1 && indexB !== -1) - { - var tempScene = this.getAt(indexA); - - this.scenes[indexA] = this.scenes[indexB]; - this.scenes[indexB] = tempScene; - } - } - - return this; - }, - - /** - * Dumps debug information about each Scene to the developer console. - * - * @method Phaser.Scenes.SceneManager#dump - * @since 3.2.0 - */ - dump: function () - { - var out = []; - var map = [ 'pending', 'init', 'start', 'loading', 'creating', 'running', 'paused', 'sleeping', 'shutdown', 'destroyed' ]; - - for (var i = 0; i < this.scenes.length; i++) - { - var sys = this.scenes[i].sys; - - var key = (sys.settings.visible && (sys.settings.status === CONST.RUNNING || sys.settings.status === CONST.PAUSED)) ? '[*] ' : '[-] '; - key += sys.settings.key + ' (' + map[sys.settings.status] + ')'; - - out.push(key); - } - - console.log(out.join('\n')); - }, - - /** - * Destroy the SceneManager and all of its Scene's systems. - * - * @method Phaser.Scenes.SceneManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - for (var i = this.scenes.length - 1; i >= 0; i--) - { - var sys = this.scenes[i].sys; - - sys.destroy(); - } - - this.update = NOOP; - - this.scenes = []; - - this._pending = []; - this._start = []; - this._queue = []; - - this.game = null; - } - -}); - -module.exports = SceneManager; - - -/***/ }), -/* 195 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SpliceOne = __webpack_require__(56); - -/** - * Removes the given item, or array of items, from the array. - * - * The array is modified in-place. - * - * You can optionally specify a callback to be invoked for each item successfully removed from the array. - * - * @function Phaser.Utils.Array.Remove - * @since 3.4.0 - * - * @param {array} array - The array to be modified. - * @param {*|Array.<*>} item - The item, or array of items, to be removed from the array. - * @param {function} [callback] - A callback to be invoked for each item successfully removed from the array. - * @param {object} [context] - The context in which the callback is invoked. - * - * @return {*|Array.<*>} The item, or array of items, that were successfully removed from the array. - */ -var Remove = function (array, item, callback, context) -{ - if (context === undefined) { context = array; } - - var index; - - // Fast path to avoid array mutation and iteration - if (!Array.isArray(item)) - { - index = array.indexOf(item); - - if (index !== -1) - { - SpliceOne(array, index); - - if (callback) - { - callback.call(context, item); - } - - return item; - } - else - { - return null; - } - } - - // If we got this far, we have an array of items to remove - - var itemLength = item.length - 1; - - while (itemLength >= 0) - { - var entry = item[itemLength]; - - index = array.indexOf(entry); - - if (index !== -1) - { - SpliceOne(array, index); - - if (callback) - { - callback.call(context, entry); - } - } - else - { - // Item wasn't found in the array, so remove it from our return results - item.pop(); - } - - itemLength--; - } - - return item; -}; - -module.exports = Remove; - - -/***/ }), -/* 196 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var FileTypesManager = __webpack_require__(7); -var GameObjectCreator = __webpack_require__(13); -var GameObjectFactory = __webpack_require__(11); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); -var Remove = __webpack_require__(195); - -/** - * @typedef {object} GlobalPlugin - * - * @property {string} key - The unique name of this plugin within the plugin cache. - * @property {function} plugin - An instance of the plugin. - * @property {boolean} [active] - Is the plugin active or not? - * @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used. - */ - -/** - * @classdesc - * The PluginManager is responsible for installing and adding plugins to Phaser. - * - * It is a global system and therefore belongs to the Game instance, not a specific Scene. - * - * It works in conjunction with the PluginCache. Core internal plugins automatically register themselves - * with the Cache, but it's the Plugin Manager that is responsible for injecting them into the Scenes. - * - * There are two types of plugin: - * - * 1) A Global Plugin - * 2) A Scene Plugin - * - * A Global Plugin is a plugin that lives within the Plugin Manager rather than a Scene. You can get - * access to it by calling `PluginManager.get` and providing a key. Any Scene that requests a plugin in - * this way will all get access to the same plugin instance, allowing you to use a single plugin across - * multiple Scenes. - * - * A Scene Plugin is a plugin dedicated to running within a Scene. These are different to Global Plugins - * in that their instances do not live within the Plugin Manager, but within the Scene Systems class instead. - * And that every Scene created is given its own unique instance of a Scene Plugin. Examples of core Scene - * Plugins include the Input Plugin, the Tween Plugin and the physics Plugins. - * - * You can add a plugin to Phaser in three different ways: - * - * 1) Preload it - * 2) Include it in your source code and install it via the Game Config - * 3) Include it in your source code and install it within a Scene - * - * For examples of all of these approaches please see the Phaser 3 Examples Repo `plugins` folder. - * - * For information on creating your own plugin please see the Phaser 3 Plugin Template. - * - * @class PluginManager - * @memberOf Phaser.Plugins - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - The game instance that owns this Plugin Manager. - */ -var PluginManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function PluginManager (game) - { - EventEmitter.call(this); - - /** - * The game instance that owns this Plugin Manager. - * - * @name Phaser.Plugins.PluginManager#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * The global plugins currently running and managed by this Plugin Manager. - * A plugin must have been started at least once in order to appear in this list. - * - * @name Phaser.Plugins.PluginManager#plugins - * @type {GlobalPlugin[]} - * @since 3.8.0 - */ - this.plugins = []; - - /** - * A list of plugin keys that should be installed into Scenes as well as the Core Plugins. - * - * @name Phaser.Plugins.PluginManager#scenePlugins - * @type {string[]} - * @since 3.8.0 - */ - this.scenePlugins = []; - - /** - * A temporary list of plugins to install when the game has booted. - * - * @name Phaser.Plugins.PluginManager#_pendingGlobal - * @private - * @type {array} - * @since 3.8.0 - */ - this._pendingGlobal = []; - - /** - * A temporary list of scene plugins to install when the game has booted. - * - * @name Phaser.Plugins.PluginManager#_pendingScene - * @private - * @type {array} - * @since 3.8.0 - */ - this._pendingScene = []; - - if (game.isBooted) - { - this.boot(); - } - else - { - game.events.once('boot', this.boot, this); - } - }, - - /** - * Run once the game has booted and installs all of the plugins configured in the Game Config. - * - * @method Phaser.Plugins.PluginManager#boot - * @protected - * @since 3.0.0 - */ - boot: function () - { - var i; - var entry; - var key; - var plugin; - var start; - var mapping; - var config = this.game.config; - - // Any plugins to install? - var list = config.installGlobalPlugins; - - // Any plugins added outside of the game config, but before the game booted? - list = list.concat(this._pendingGlobal); - - for (i = 0; i < list.length; i++) - { - entry = list[i]; - - // { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test' } - - key = GetFastValue(entry, 'key', null); - plugin = GetFastValue(entry, 'plugin', null); - start = GetFastValue(entry, 'start', false); - mapping = GetFastValue(entry, 'mapping', null); - - if (key && plugin) - { - this.install(key, plugin, start, mapping); - } - } - - // Any scene plugins to install? - list = config.installScenePlugins; - - // Any plugins added outside of the game config, but before the game booted? - list = list.concat(this._pendingScene); - - for (i = 0; i < list.length; i++) - { - entry = list[i]; - - // { key: 'moveSpritePlugin', plugin: MoveSpritePlugin, , mapping: 'move' } - - key = GetFastValue(entry, 'key', null); - plugin = GetFastValue(entry, 'plugin', null); - mapping = GetFastValue(entry, 'mapping', null); - - if (key && plugin) - { - this.installScenePlugin(key, plugin, mapping); - } - } - - this._pendingGlobal = []; - this._pendingScene = []; - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * Called by the Scene Systems class. Tells the plugin manager to install all Scene plugins into it. - * - * First it will install global references, i.e. references from the Game systems into the Scene Systems (and Scene if mapped.) - * Then it will install Core Scene Plugins followed by Scene Plugins registered with the PluginManager. - * Finally it will install any references to Global Plugins that have a Scene mapping property into the Scene itself. - * - * @method Phaser.Plugins.PluginManager#addToScene - * @protected - * @since 3.8.0 - * - * @param {Phaser.Scenes.Systems} sys - The Scene Systems class to install all the plugins in to. - * @param {array} globalPlugins - An array of global plugins to install. - * @param {array} scenePlugins - An array of scene plugins to install. - */ - addToScene: function (sys, globalPlugins, scenePlugins) - { - var i; - var pluginKey; - var pluginList; - var game = this.game; - var scene = sys.scene; - var map = sys.settings.map; - var isBooted = sys.settings.isBooted; - - // Reference the GlobalPlugins from Game into Scene.Systems - for (i = 0; i < globalPlugins.length; i++) - { - pluginKey = globalPlugins[i]; - - if (game[pluginKey]) - { - sys[pluginKey] = game[pluginKey]; - - // Scene level injection - if (map.hasOwnProperty(pluginKey)) - { - scene[map[pluginKey]] = sys[pluginKey]; - } - } - } - - for (var s = 0; s < scenePlugins.length; s++) - { - pluginList = scenePlugins[s]; - - for (i = 0; i < pluginList.length; i++) - { - pluginKey = pluginList[i]; - - if (!PluginCache.hasCore(pluginKey)) - { - continue; - } - - var source = PluginCache.getCore(pluginKey); - - var plugin = new source.plugin(scene, this); - - sys[source.mapping] = plugin; - - // Scene level injection - if (source.custom) - { - scene[source.mapping] = plugin; - } - else if (map.hasOwnProperty(source.mapping)) - { - scene[map[source.mapping]] = plugin; - } - - // Scene is already booted, usually because this method is being called at run-time, so boot the plugin - if (isBooted) - { - plugin.boot(); - } - } - } - - // And finally, inject any 'global scene plugins' - pluginList = this.plugins; - - for (i = 0; i < pluginList.length; i++) - { - var entry = pluginList[i]; - - if (entry.mapping) - { - scene[entry.mapping] = entry.plugin; - } - } - }, - - /** - * Called by the Scene Systems class. Returns a list of plugins to be installed. - * - * @method Phaser.Plugins.PluginManager#getDefaultScenePlugins - * @protected - * @since 3.8.0 - * - * @return {string[]} A list keys of all the Scene Plugins to install. - */ - getDefaultScenePlugins: function () - { - var list = this.game.config.defaultPlugins; - - // Merge in custom Scene plugins - list = list.concat(this.scenePlugins); - - return list; - }, - - /** - * Installs a new Scene Plugin into the Plugin Manager and optionally adds it - * to the given Scene as well. A Scene Plugin added to the manager in this way - * will be automatically installed into all new Scenes using the key and mapping given. - * - * The `key` property is what the plugin is injected into Scene.Systems as. - * The `mapping` property is optional, and if specified is what the plugin is installed into - * the Scene as. For example: - * - * ```javascript - * this.plugins.installScenePlugin('powerupsPlugin', pluginCode, 'powerups'); - * - * // and from within the scene: - * this.sys.powerupsPlugin; // key value - * this.powerups; // mapping value - * ``` - * - * This method is called automatically by Phaser if you install your plugins using either the - * Game Configuration object, or by preloading them via the Loader. - * - * @method Phaser.Plugins.PluginManager#installScenePlugin - * @since 3.8.0 - * - * @param {string} key - The property key that will be used to add this plugin to Scene.Systems. - * @param {function} plugin - The plugin code. This should be the non-instantiated version. - * @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use. - * @param {Phaser.Scene} [addToScene] - Optionally automatically add this plugin to the given Scene. - */ - installScenePlugin: function (key, plugin, mapping, addToScene) - { - if (typeof plugin !== 'function') - { - console.warn('Invalid Scene Plugin: ' + key); - return; - } - - if (PluginCache.hasCore(key)) - { - console.warn('Scene Plugin key in use: ' + key); - return; - } - - PluginCache.register(key, plugin, mapping, true); - - this.scenePlugins.push(key); - - if (addToScene) - { - var instance = new plugin(addToScene, this); - - addToScene.sys[key] = instance; - - if (mapping && mapping !== '') - { - addToScene[mapping] = instance; - } - - instance.boot(); - } - }, - - /** - * Installs a new Global Plugin into the Plugin Manager and optionally starts it running. - * A global plugin belongs to the Plugin Manager, rather than a specific Scene, and can be accessed - * and used by all Scenes in your game. - * - * The `key` property is what you use to access this plugin from the Plugin Manager. - * - * ```javascript - * this.plugins.install('powerupsPlugin', pluginCode); - * - * // and from within the scene: - * this.plugins.get('powerupsPlugin'); - * ``` - * - * This method is called automatically by Phaser if you install your plugins using either the - * Game Configuration object, or by preloading them via the Loader. - * - * The same plugin can be installed multiple times into the Plugin Manager by simply giving each - * instance its own unique key. - * - * @method Phaser.Plugins.PluginManager#install - * @since 3.8.0 - * - * @param {string} key - The unique handle given to this plugin within the Plugin Manager. - * @param {function} plugin - The plugin code. This should be the non-instantiated version. - * @param {boolean} [start=false] - Automatically start the plugin running? This is always `true` if you provide a mapping value. - * @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use. - */ - install: function (key, plugin, start, mapping) - { - if (start === undefined) { start = false; } - if (mapping === undefined) { mapping = null; } - - if (typeof plugin !== 'function') - { - console.warn('Invalid Plugin: ' + key); - return; - } - - if (PluginCache.hasCustom(key)) - { - console.warn('Plugin key in use: ' + key); - return; - } - - if (mapping !== null) - { - start = true; - } - - if (!this.game.isBooted) - { - this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping }); - } - else - { - // Add it to the plugin store - PluginCache.registerCustom(key, plugin, mapping); - - if (start) - { - return this.start(key); - } - } - }, - - /** - * Gets an index of a global plugin based on the given key. - * - * @method Phaser.Plugins.PluginManager#getIndex - * @protected - * @since 3.8.0 - * - * @param {string} key - The unique plugin key. - * - * @return {integer} The index of the plugin within the plugins array. - */ - getIndex: function (key) - { - var list = this.plugins; - - for (var i = 0; i < list.length; i++) - { - var entry = list[i]; - - if (entry.key === key) - { - return i; - } - } - - return -1; - }, - - /** - * Gets a global plugin based on the given key. - * - * @method Phaser.Plugins.PluginManager#getEntry - * @protected - * @since 3.8.0 - * - * @param {string} key - The unique plugin key. - * - * @return {GlobalPlugin} The plugin entry. - */ - getEntry: function (key) - { - var idx = this.getIndex(key); - - if (idx !== -1) - { - return this.plugins[idx]; - } - }, - - /** - * Checks if the given global plugin, based on its key, is active or not. - * - * @method Phaser.Plugins.PluginManager#isActive - * @since 3.8.0 - * - * @param {string} key - The unique plugin key. - * - * @return {boolean} `true` if the plugin is active, otherwise `false`. - */ - isActive: function (key) - { - var entry = this.getEntry(key); - - return (entry && entry.active); - }, - - /** - * Starts a global plugin running. - * - * If the plugin was previously active then calling `start` will reset it to an active state and then - * call its `start` method. - * - * If the plugin has never been run before a new instance of it will be created within the Plugin Manager, - * its active state set and then both of its `init` and `start` methods called, in that order. - * - * If the plugin is already running under the given key then nothing happens. - * - * @method Phaser.Plugins.PluginManager#start - * @since 3.8.0 - * - * @param {string} key - The key of the plugin to start. - * @param {string} [runAs] - Run the plugin under a new key. This allows you to run one plugin multiple times. - * - * @return {?Phaser.Plugins.BasePlugin} The plugin that was started, or `null` if invalid key given or plugin is already stopped. - */ - start: function (key, runAs) - { - if (runAs === undefined) { runAs = key; } - - var entry = this.getEntry(runAs); - - // Plugin already running under this key? - if (entry && !entry.active) - { - // It exists, we just need to start it up again - entry.active = true; - entry.plugin.start(); - } - else if (!entry) - { - entry = this.createEntry(key, runAs); - } - - return (entry) ? entry.plugin : null; - }, - - /** - * Creates a new instance of a global plugin, adds an entry into the plugins array and returns it. - * - * @method Phaser.Plugins.PluginManager#createEntry - * @private - * @since 3.9.0 - * - * @param {string} key - The key of the plugin to create an instance of. - * @param {string} [runAs] - Run the plugin under a new key. This allows you to run one plugin multiple times. - * - * @return {?Phaser.Plugins.BasePlugin} The plugin that was started, or `null` if invalid key given. - */ - createEntry: function (key, runAs) - { - var entry = PluginCache.getCustom(key); - - if (entry) - { - var instance = new entry.plugin(this); - - entry = { - key: runAs, - plugin: instance, - active: true, - mapping: entry.mapping - }; - - this.plugins.push(entry); - - instance.init(); - instance.start(); - } - - return entry; - }, - - /** - * Stops a global plugin from running. - * - * If the plugin is active then its active state will be set to false and the plugins `stop` method - * will be called. - * - * If the plugin is not already running, nothing will happen. - * - * @method Phaser.Plugins.PluginManager#stop - * @since 3.8.0 - * - * @param {string} key - The key of the plugin to stop. - * - * @return {Phaser.Plugins.PluginManager} The Plugin Manager. - */ - stop: function (key) - { - var entry = this.getEntry(key); - - if (entry && entry.active) - { - entry.active = false; - entry.plugin.stop(); - } - - return this; - }, - - /** - * Gets a global plugin from the Plugin Manager based on the given key and returns it. - * - * If it cannot find an active plugin based on the key, but there is one in the Plugin Cache with the same key, - * then it will create a new instance of the cached plugin and return that. - * - * @method Phaser.Plugins.PluginManager#get - * @since 3.8.0 - * - * @param {string} key - The key of the plugin to get. - * @param {boolean} [autoStart=true] - Automatically start a new instance of the plugin if found in the cache, but not actively running. - * - * @return {?(Phaser.Plugins.BasePlugin|function)} The plugin, or `null` if no plugin was found matching the key. - */ - get: function (key, autoStart) - { - if (autoStart === undefined) { autoStart = true; } - - var entry = this.getEntry(key); - - if (entry) - { - return entry.plugin; - } - else - { - var plugin = this.getClass(key); - - if (plugin && autoStart) - { - entry = this.createEntry(key, key); - - return (entry) ? entry.plugin : null; - } - else if (plugin) - { - return plugin; - } - } - - return null; - }, - - /** - * Returns the plugin class from the cache. - * Used internally by the Plugin Manager. - * - * @method Phaser.Plugins.PluginManager#getClass - * @since 3.8.0 - * - * @param {string} key - The key of the plugin to get. - * - * @return {Phaser.Plugins.BasePlugin} A Plugin object - */ - getClass: function (key) - { - return PluginCache.getCustomClass(key); - }, - - /** - * Removes a global plugin from the Plugin Manager and Plugin Cache. - * - * It is up to you to remove all references to this plugin that you may hold within your game code. - * - * @method Phaser.Plugins.PluginManager#removeGlobalPlugin - * @since 3.8.0 - * - * @param {string} key - The key of the plugin to remove. - */ - removeGlobalPlugin: function (key) - { - var entry = this.getEntry(key); - - if (entry) - { - Remove(this.plugins, entry); - } - - PluginCache.removeCustom(key); - }, - - /** - * Removes a scene plugin from the Plugin Manager and Plugin Cache. - * - * This will not remove the plugin from any active Scenes that are already using it. - * - * It is up to you to remove all references to this plugin that you may hold within your game code. - * - * @method Phaser.Plugins.PluginManager#removeScenePlugin - * @since 3.8.0 - * - * @param {string} key - The key of the plugin to remove. - */ - removeScenePlugin: function (key) - { - Remove(this.scenePlugins, key); - - PluginCache.remove(key); - }, - - /** - * Registers a new type of Game Object with the global Game Object Factory and / or Creator. - * This is usually called from within your Plugin code and is a helpful short-cut for creating - * new Game Objects. - * - * The key is the property that will be injected into the factories and used to create the - * Game Object. For example: - * - * ```javascript - * this.plugins.registerGameObject('clown', clownFactoryCallback, clownCreatorCallback); - * // later in your game code: - * this.add.clown(); - * this.make.clown(); - * ``` - * - * The callbacks are what are called when the factories try to create a Game Object - * matching the given key. It's important to understand that the callbacks are invoked within - * the context of the GameObjectFactory. In this context there are several properties available - * to use: - * - * this.scene - A reference to the Scene that owns the GameObjectFactory. - * this.displayList - A reference to the Display List the Scene owns. - * this.updateList - A reference to the Update List the Scene owns. - * - * See the GameObjectFactory and GameObjectCreator classes for more details. - * Any public property or method listed is available from your callbacks under `this`. - * - * @method Phaser.Plugins.PluginManager#registerGameObject - * @since 3.8.0 - * - * @param {string} key - The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`. - * @param {function} [factoryCallback] - The callback to invoke when the Game Object Factory is called. - * @param {function} [creatorCallback] - The callback to invoke when the Game Object Creator is called. - */ - registerGameObject: function (key, factoryCallback, creatorCallback) - { - if (factoryCallback) - { - GameObjectFactory.register(key, factoryCallback); - } - - if (creatorCallback) - { - GameObjectCreator.register(key, creatorCallback); - } - - return this; - }, - - /** - * Registers a new file type with the global File Types Manager, making it available to all Loader - * Plugins created after this. - * - * This is usually called from within your Plugin code and is a helpful short-cut for creating - * new loader file types. - * - * The key is the property that will be injected into the Loader Plugin and used to load the - * files. For example: - * - * ```javascript - * this.plugins.registerFileType('wad', doomWadLoaderCallback); - * // later in your preload code: - * this.load.wad(); - * ``` - * - * The callback is what is called when the loader tries to load a file matching the given key. - * It's important to understand that the callback is invoked within - * the context of the LoaderPlugin. In this context there are several properties / methods available - * to use: - * - * this.addFile - A method to add the new file to the load queue. - * this.scene - The Scene that owns the Loader Plugin instance. - * - * See the LoaderPlugin class for more details. Any public property or method listed is available from - * your callback under `this`. - * - * @method Phaser.Plugins.PluginManager#registerFileType - * @since 3.8.0 - * - * @param {string} key - The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`. - * @param {function} callback - The callback to invoke when the Game Object Factory is called. - * @param {Phaser.Scene} [addToScene] - Optionally add this file type into the Loader Plugin owned by the given Scene. - */ - registerFileType: function (key, callback, addToScene) - { - FileTypesManager.register(key, callback); - - if (addToScene && addToScene.sys.load) - { - addToScene.sys.load[key] = callback; - } - }, - - /** - * Destroys this Plugin Manager and all associated plugins. - * It will iterate all plugins found and call their `destroy` methods. - * Note that the PluginCache is NOT cleared by this as it doesn't hold any plugin instances. - * - * @method Phaser.Plugins.PluginManager#destroy - * @since 3.8.0 - */ - destroy: function () - { - for (var i = 0; i < this.plugins.length; i++) - { - this.plugins[i].plugin.destroy(); - } - - this.game = null; - this.plugins = []; - this.scenePlugins = []; - } - -}); - -/* - * "Sometimes, the elegant implementation is just a function. - * Not a method. Not a class. Not a framework. Just a function." - * -- John Carmack - */ - -module.exports = PluginManager; - - -/***/ }), -/* 197 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -// https://developer.mozilla.org/en-US/docs/Web/API/Touch_events -// https://patrickhlauke.github.io/touch/tests/results/ -// https://www.html5rocks.com/en/mobile/touch/ - -/** - * @classdesc - * The Touch Manager is a helper class that belongs to the Input Manager. - * - * Its role is to listen for native DOM Touch Events and then pass them onto the Input Manager for further processing. - * - * You do not need to create this class directly, the Input Manager will create an instance of it automatically. - * - * @class TouchManager - * @memberOf Phaser.Input.Touch - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} inputManager - A reference to the Input Manager. - */ -var TouchManager = new Class({ - - initialize: - - function TouchManager (inputManager) - { - /** - * A reference to the Input Manager. - * - * @name Phaser.Input.Touch.TouchManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; - - /** - * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. - * - * @name Phaser.Input.Touch.TouchManager#capture - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.capture = true; - - /** - * A boolean that controls if the Touch Manager is enabled or not. - * Can be toggled on the fly. - * - * @name Phaser.Input.Touch.TouchManager#enabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.enabled = false; - - /** - * The Touch Event target, as defined in the Game Config. - * Typically the canvas to which the game is rendering, but can be any interactive DOM element. - * - * @name Phaser.Input.Touch.TouchManager#target - * @type {any} - * @since 3.0.0 - */ - this.target; - - inputManager.events.once('boot', this.boot, this); - }, - - /** - * The Touch Manager boot process. - * - * @method Phaser.Input.Touch.TouchManager#boot - * @private - * @since 3.0.0 - */ - boot: function () - { - var config = this.manager.config; - - this.enabled = config.inputTouch; - this.target = config.inputTouchEventTarget; - this.capture = config.inputTouchCapture; - - if (!this.target) - { - this.target = this.manager.game.canvas; - } - - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * The Touch Start Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchStart - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch Start Event. - */ - onTouchStart: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchStart(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Touch Move Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchMove - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch Move Event. - */ - onTouchMove: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchMove(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Touch End Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchEnd - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch End Event. - */ - onTouchEnd: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchEnd(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * Starts the Touch Event listeners running. - * This is called automatically and does not need to be manually invoked. - * - * @method Phaser.Input.Touch.TouchManager#startListeners - * @since 3.0.0 - */ - startListeners: function () - { - var target = this.target; - - var passive = { passive: true }; - var nonPassive = { passive: false }; - - if (this.capture) - { - target.addEventListener('touchstart', this.onTouchStart.bind(this), nonPassive); - target.addEventListener('touchmove', this.onTouchMove.bind(this), nonPassive); - target.addEventListener('touchend', this.onTouchEnd.bind(this), nonPassive); - } - else - { - target.addEventListener('touchstart', this.onTouchStart.bind(this), passive); - target.addEventListener('touchmove', this.onTouchMove.bind(this), passive); - target.addEventListener('touchend', this.onTouchEnd.bind(this), passive); - } - }, - - /** - * Stops the Touch Event listeners. - * This is called automatically and does not need to be manually invoked. - * - * @method Phaser.Input.Touch.TouchManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - var target = this.target; - - target.removeEventListener('touchstart', this.onTouchStart); - target.removeEventListener('touchmove', this.onTouchMove); - target.removeEventListener('touchend', this.onTouchEnd); - }, - - /** - * Destroys this Touch Manager instance. - * - * @method Phaser.Input.Touch.TouchManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - - this.target = null; - this.manager = null; - } - -}); - -module.exports = TouchManager; - - -/***/ }), -/* 198 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * A Pointer object encapsulates both mouse and touch input within Phaser. - * - * By default, Phaser will create 2 pointers for your game to use. If you require more, i.e. for a multi-touch - * game, then use the `InputPlugin.addPointer` method to do so, rather than instantiating this class directly, - * otherwise it won't be managed by the input system. - * - * You can reference the current active pointer via `InputPlugin.activePointer`. You can also use the properties - * `InputPlugin.pointer1` through to `pointer10`, for each pointer you have enabled in your game. - * - * The properties of this object are set by the Input Plugin during processing. This object is then sent in all - * input related events that the Input Plugin emits, so you can reference properties from it directly in your - * callbacks. - * - * @class Pointer - * @memberOf Phaser.Input - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} manager - A reference to the Input Manager. - * @param {integer} id - The internal ID of this Pointer. - */ -var Pointer = new Class({ - - initialize: - - function Pointer (manager, id) - { - /** - * A reference to the Input Manager. - * - * @name Phaser.Input.Pointer#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * The internal ID of this Pointer. - * - * @name Phaser.Input.Pointer#id - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.id = id; - - /** - * The most recent native DOM Event this Pointer has processed. - * - * @name Phaser.Input.Pointer#event - * @type {(TouchEvent|MouseEvent)} - * @since 3.0.0 - */ - this.event; - - /** - * The camera the Pointer interacted with during its last update. - * - * A Pointer can only ever interact with one camera at once, which will be the top-most camera - * in the list should multiple cameras be positioned on-top of each other. - * - * @name Phaser.Input.Pointer#camera - * @type {Phaser.Cameras.Scene2D.Camera} - * @default null - * @since 3.0.0 - */ - this.camera = null; - - /** - * 0: No button or un-initialized - * 1: Left button - * 2: Right button - * 4: Wheel button or middle button - * 8: 4th button (typically the "Browser Back" button) - * 16: 5th button (typically the "Browser Forward" button) - * - * For a mouse configured for left-handed use, the button actions are reversed. - * In this case, the values are read from right to left. - * - * @name Phaser.Input.Pointer#buttons - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.buttons = 0; - - /** - * The position of the Pointer in screen space. - * - * @name Phaser.Input.Pointer#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(); - - /** - * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. - * - * @name Phaser.Input.Pointer#worldX - * @type {number} - * @default 0 - * @since 3.10.0 - */ - this.worldX = 0; - - /** - * The y position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. - * - * @name Phaser.Input.Pointer#worldY - * @type {number} - * @default 0 - * @since 3.10.0 - */ - this.worldY = 0; - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - * - * @name Phaser.Input.Pointer#downX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.downX = 0; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. - * - * @name Phaser.Input.Pointer#downY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.downY = 0; - - /** - * Time when Button 1 (left button), or Touch, was pressed, used for dragging objects. - * - * @name Phaser.Input.Pointer#downTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.downTime = 0; - - /** - * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - * - * @name Phaser.Input.Pointer#upX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.upX = 0; - - /** - * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. - * - * @name Phaser.Input.Pointer#upY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.upY = 0; - - /** - * Time when Button 1 (left button), or Touch, was released, used for dragging objects. - * - * @name Phaser.Input.Pointer#upTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.upTime = 0; - - /** - * Is the primary button down? (usually button 0, the left mouse button) - * - * @name Phaser.Input.Pointer#primaryDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.primaryDown = false; - - /** - * The Drag State of the Pointer: - * - * 0 = Not dragging anything - * 1 = Being checked if dragging - * 2 = Dragging something - * - * @name Phaser.Input.Pointer#dragState - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.dragState = 0; - - /** - * Is _any_ button on this pointer considered as being down? - * - * @name Phaser.Input.Pointer#isDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isDown = false; - - /** - * A dirty flag for this Pointer, used internally by the Input Plugin. - * - * @name Phaser.Input.Pointer#dirty - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.dirty = false; - - /** - * Is this Pointer considered as being "just down" or not? - * - * @name Phaser.Input.Pointer#justDown - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.justDown = false; - - /** - * Is this Pointer considered as being "just up" or not? - * - * @name Phaser.Input.Pointer#justUp - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.justUp = false; - - /** - * Is this Pointer considered as being "just moved" or not? - * - * @name Phaser.Input.Pointer#justMoved - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.justMoved = false; - - /** - * Did the previous input event come from a Touch input (true) or Mouse? (false) - * - * @name Phaser.Input.Pointer#wasTouch - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.wasTouch = false; - - /** - * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. - * - * @name Phaser.Input.Pointer#movementX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.movementX = 0; - - /** - * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. - * - * @name Phaser.Input.Pointer#movementY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.movementY = 0; - - /** - * The identifier property of the Pointer as set by the DOM event when this Pointer is started. - * - * @name Phaser.Input.Pointer#identifier - * @type {number} - * @since 3.10.0 - */ - this.identifier = 0; - - /** - * The pointerId property of the Pointer as set by the DOM event when this Pointer is started. - * The browser can and will recycle this value. - * - * @name Phaser.Input.Pointer#pointerId - * @type {number} - * @since 3.10.0 - */ - this.pointerId = null; - - /** - * An active Pointer is one that is currently pressed down on the display. - * A Mouse is always considered as active. - * - * @name Phaser.Input.Pointer#active - * @type {boolean} - * @since 3.10.0 - */ - this.active = (id === 0) ? true : false; - }, - - /** - * Takes a Camera and returns a Vector2 containing the translated position of this Pointer - * within that Camera. This can be used to convert this Pointers position into camera space. - * - * @method Phaser.Input.Pointer#positionToCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the translation. - * @param {(Phaser.Math.Vector2|object)} [output] - A Vector2-like object in which to store the translated position. - * - * @return {(Phaser.Math.Vector2|object)} A Vector2 containing the translated coordinates of this Pointer, based on the given camera. - */ - positionToCamera: function (camera, output) - { - return camera.getWorldPoint(this.x, this.y, output); - }, - - /** - * Resets the temporal properties of this Pointer. - * Called automatically by the Input Plugin each update. - * - * @method Phaser.Input.Pointer#reset - * @private - * @since 3.0.0 - */ - reset: function () - { - this.dirty = false; - - this.justDown = false; - this.justUp = false; - this.justMoved = false; - - this.movementX = 0; - this.movementY = 0; - }, - - /** - * Internal method to handle a Mouse Up Event. - * - * @method Phaser.Input.Pointer#up - * @private - * @since 3.0.0 - * - * @param {MouseEvent} event - The Mouse Event to process. - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - */ - up: function (event, time) - { - if (event.buttons) - { - this.buttons = event.buttons; - } - - this.event = event; - - // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); - - // 0: Main button pressed, usually the left button or the un-initialized state - if (event.button === 0) - { - this.primaryDown = false; - this.upX = this.x; - this.upY = this.y; - this.upTime = time; - } - - this.justUp = true; - this.isDown = false; - - this.dirty = true; - - this.wasTouch = false; - }, - - /** - * Internal method to handle a Mouse Down Event. - * - * @method Phaser.Input.Pointer#down - * @private - * @since 3.0.0 - * - * @param {MouseEvent} event - The Mouse Event to process. - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - */ - down: function (event, time) - { - if (event.buttons) - { - this.buttons = event.buttons; - } - - this.event = event; - - // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); - - // 0: Main button pressed, usually the left button or the un-initialized state - if (event.button === 0) - { - this.primaryDown = true; - this.downX = this.x; - this.downY = this.y; - this.downTime = time; - } - - this.justDown = true; - this.isDown = true; - - this.dirty = true; - - this.wasTouch = false; - }, - - /** - * Internal method to handle a Mouse Move Event. - * - * @method Phaser.Input.Pointer#move - * @private - * @since 3.0.0 - * - * @param {MouseEvent} event - The Mouse Event to process. - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - */ - move: function (event) - { - if (event.buttons) - { - this.buttons = event.buttons; - } - - this.event = event; - - // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); - - if (this.manager.mouse.locked) - { - // Multiple DOM events may occur within one frame, but only one Phaser event will fire - this.movementX += event.movementX || event.mozMovementX || event.webkitMovementX || 0; - this.movementY += event.movementY || event.mozMovementY || event.webkitMovementY || 0; - } - - this.justMoved = true; - - this.dirty = true; - - this.wasTouch = false; - }, - - /** - * Internal method to handle a Touch Start Event. - * - * @method Phaser.Input.Pointer#touchstart - * @private - * @since 3.0.0 - * - * @param {TouchEvent} event - The Touch Event to process. - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - */ - touchstart: function (event, time) - { - if (event['pointerId']) - { - this.pointerId = event.pointerId; - } - - this.identifier = event.identifier; - this.target = event.target; - this.active = true; - - this.buttons = 1; - - this.event = event; - - // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); - - this.primaryDown = true; - this.downX = this.x; - this.downY = this.y; - this.downTime = time; - - this.justDown = true; - this.isDown = true; - - this.dirty = true; - - this.wasTouch = true; - }, - - /** - * Internal method to handle a Touch Move Event. - * - * @method Phaser.Input.Pointer#touchmove - * @private - * @since 3.0.0 - * - * @param {TouchEvent} event - The Touch Event to process. - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - */ - touchmove: function (event) - { - this.event = event; - - // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); - - this.justMoved = true; - - this.dirty = true; - - this.wasTouch = true; - }, - - /** - * Internal method to handle a Touch End Event. - * - * @method Phaser.Input.Pointer#touchend - * @private - * @since 3.0.0 - * - * @param {TouchEvent} event - The Touch Event to process. - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - */ - touchend: function (event, time) - { - this.buttons = 0; - - this.event = event; - - // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); - - this.primaryDown = false; - this.upX = this.x; - this.upY = this.y; - this.upTime = time; - - this.justUp = true; - this.isDown = false; - - this.dirty = true; - - this.wasTouch = true; - - this.active = false; - }, - - /** - * Checks to see if any buttons are being held down on this Pointer. - * - * @method Phaser.Input.Pointer#noButtonDown - * @since 3.0.0 - * - * @return {boolean} `true` if no buttons are being held down. - */ - noButtonDown: function () - { - return (this.buttons === 0); - }, - - /** - * Checks to see if the left button is being held down on this Pointer. - * - * @method Phaser.Input.Pointer#leftButtonDown - * @since 3.0.0 - * - * @return {boolean} `true` if the left button is being held down. - */ - leftButtonDown: function () - { - return (this.buttons & 1); - }, - - /** - * Checks to see if the right button is being held down on this Pointer. - * - * @method Phaser.Input.Pointer#rightButtonDown - * @since 3.0.0 - * - * @return {boolean} `true` if the right button is being held down. - */ - rightButtonDown: function () - { - return (this.buttons & 2); - }, - - /** - * Checks to see if the middle button is being held down on this Pointer. - * - * @method Phaser.Input.Pointer#middleButtonDown - * @since 3.0.0 - * - * @return {boolean} `true` if the middle button is being held down. - */ - middleButtonDown: function () - { - return (this.buttons & 4); - }, - - /** - * Checks to see if the back button is being held down on this Pointer. - * - * @method Phaser.Input.Pointer#backButtonDown - * @since 3.0.0 - * - * @return {boolean} `true` if the back button is being held down. - */ - backButtonDown: function () - { - return (this.buttons & 8); - }, - - /** - * Checks to see if the forward button is being held down on this Pointer. - * - * @method Phaser.Input.Pointer#forwardButtonDown - * @since 3.0.0 - * - * @return {boolean} `true` if the forward button is being held down. - */ - forwardButtonDown: function () - { - return (this.buttons & 16); - }, - - /** - * Destroys this Pointer instance and resets its external references. - * - * @method Phaser.Input.Pointer#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.camera = null; - this.manager = null; - this.position = null; - }, - - /** - * The x position of this Pointer. - * The value is in screen space. - * See `worldX` to get a camera converted position. - * - * @name Phaser.Input.Pointer#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - } - - }, - - /** - * The y position of this Pointer. - * The value is in screen space. - * See `worldY` to get a camera converted position. - * - * @name Phaser.Input.Pointer#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - } - - } - -}); - -module.exports = Pointer; - - -/***/ }), -/* 199 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Features = __webpack_require__(120); - -// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent -// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md - -/** - * @classdesc - * The Mouse Manager is a helper class that belongs to the Input Manager. - * - * Its role is to listen for native DOM Mouse Events and then pass them onto the Input Manager for further processing. - * - * You do not need to create this class directly, the Input Manager will create an instance of it automatically. - * - * @class MouseManager - * @memberOf Phaser.Input.Mouse - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Input.InputManager} inputManager - A reference to the Input Manager. - */ -var MouseManager = new Class({ - - initialize: - - function MouseManager (inputManager) - { - /** - * A reference to the Input Manager. - * - * @name Phaser.Input.Mouse.MouseManager#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = inputManager; - - /** - * If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully. - * - * @name Phaser.Input.Mouse.MouseManager#capture - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.capture = true; - - /** - * A boolean that controls if the Mouse Manager is enabled or not. - * Can be toggled on the fly. - * - * @name Phaser.Input.Mouse.MouseManager#enabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.enabled = false; - - /** - * The Touch Event target, as defined in the Game Config. - * Typically the canvas to which the game is rendering, but can be any interactive DOM element. - * - * @name Phaser.Input.Mouse.MouseManager#target - * @type {any} - * @since 3.0.0 - */ - this.target; - - /** - * If the mouse has been pointer locked successfully this will be set to true. - * - * @name Phaser.Input.Mouse.MouseManager#locked - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.locked = false; - - inputManager.events.once('boot', this.boot, this); - }, - - /** - * The Touch Manager boot process. - * - * @method Phaser.Input.Mouse.MouseManager#boot - * @private - * @since 3.0.0 - */ - boot: function () - { - var config = this.manager.config; - - this.enabled = config.inputMouse; - this.target = config.inputMouseEventTarget; - this.capture = config.inputMouseCapture; - - if (!this.target) - { - this.target = this.manager.game.canvas; - } - - if (config.disableContextMenu) - { - this.disableContextMenu(); - } - - if (this.enabled) - { - this.startListeners(); - } - }, - - /** - * Attempts to disable the context menu from appearing if you right-click on the browser. - * - * Works by listening for the `contextmenu` event and prevent defaulting it. - * - * Use this if you need to enable right-button mouse support in your game, and the browser - * menu keeps getting in the way. - * - * @method Phaser.Input.Mouse.MouseManager#disableContextMenu - * @since 3.0.0 - * - * @return {Phaser.Input.Mouse.MouseManager} This Mouse Manager instance. - */ - disableContextMenu: function () - { - document.body.addEventListener('contextmenu', function (event) - { - event.preventDefault(); - return false; - }); - - return this; - }, - - /** - * If the browser supports it, you can request that the pointer be locked to the browser window. - * - * This is classically known as 'FPS controls', where the pointer can't leave the browser until - * the user presses an exit key. - * - * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, - * from the games Input Manager, with an `isPointerLocked` property. - * - * It is important to note that pointer lock can only be enabled after an 'engagement gesture', - * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. - * - * @method Phaser.Input.Mouse.MouseManager#requestPointerLock - * @since 3.0.0 - */ - requestPointerLock: function () - { - if (Features.pointerLock) - { - var element = this.target; - element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; - element.requestPointerLock(); - } - }, - - /** - * Internal pointerLockChange handler. - * - * @method Phaser.Input.Mouse.MouseManager#pointerLockChange - * @since 3.0.0 - * - * @param {MouseEvent} event - The native event from the browser. - */ - pointerLockChange: function (event) - { - var element = this.target; - - this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; - - this.manager.queue.push(event); - }, - - /** - * If the browser supports pointer lock, this will request that the pointer lock is released. If - * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be - * dispatched - from the game's input manager - with an `isPointerLocked` property. - * - * @method Phaser.Input.Mouse.MouseManager#releasePointerLock - * @since 3.0.0 - */ - releasePointerLock: function () - { - if (Features.pointerLock) - { - document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; - document.exitPointerLock(); - } - }, - - /** - * The Mouse Move Event Handler. - * - * @method Phaser.Input.Mouse.MouseManager#onMouseMove - * @since 3.10.0 - * - * @param {MouseEvent} event - The native DOM Mouse Move Event. - */ - onMouseMove: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueMouseMove(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Mouse Down Event Handler. - * - * @method Phaser.Input.Mouse.MouseManager#onMouseDown - * @since 3.10.0 - * - * @param {MouseEvent} event - The native DOM Mouse Down Event. - */ - onMouseDown: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueMouseDown(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Mouse Up Event Handler. - * - * @method Phaser.Input.Mouse.MouseManager#onMouseUp - * @since 3.10.0 - * - * @param {MouseEvent} event - The native DOM Mouse Up Event. - */ - onMouseUp: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueMouseUp(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * Starts the Mouse Event listeners running. - * This is called automatically and does not need to be manually invoked. - * - * @method Phaser.Input.Mouse.MouseManager#startListeners - * @since 3.0.0 - */ - startListeners: function () - { - var target = this.target; - - var passive = { passive: true }; - var nonPassive = { passive: false }; - - if (this.capture) - { - target.addEventListener('mousemove', this.onMouseMove.bind(this), nonPassive); - target.addEventListener('mousedown', this.onMouseDown.bind(this), nonPassive); - target.addEventListener('mouseup', this.onMouseUp.bind(this), nonPassive); - } - else - { - target.addEventListener('mousemove', this.onMouseMove.bind(this), passive); - target.addEventListener('mousedown', this.onMouseDown.bind(this), passive); - target.addEventListener('mouseup', this.onMouseUp.bind(this), passive); - } - - if (Features.pointerLock) - { - this.pointerLockChange = this.pointerLockChange.bind(this); - - document.addEventListener('pointerlockchange', this.pointerLockChange, true); - document.addEventListener('mozpointerlockchange', this.pointerLockChange, true); - document.addEventListener('webkitpointerlockchange', this.pointerLockChange, true); - } - }, - - /** - * Stops the Mouse Event listeners. - * This is called automatically and does not need to be manually invoked. - * - * @method Phaser.Input.Mouse.MouseManager#stopListeners - * @since 3.0.0 - */ - stopListeners: function () - { - var target = this.target; - - target.removeEventListener('mousemove', this.onMouseMove); - target.removeEventListener('mousedown', this.onMouseDown); - target.removeEventListener('mouseup', this.onMouseUp); - - if (Features.pointerLock) - { - document.removeEventListener('pointerlockchange', this.pointerLockChange, true); - document.removeEventListener('mozpointerlockchange', this.pointerLockChange, true); - document.removeEventListener('webkitpointerlockchange', this.pointerLockChange, true); - } - }, - - /** - * Destroys this Mouse Manager instance. - * - * @method Phaser.Input.Mouse.MouseManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stopListeners(); - - this.target = null; - this.manager = null; - } - -}); - -module.exports = MouseManager; - - -/***/ }), -/* 200 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var INPUT_CONST = { - - /** - * The mouse pointer is being held down. - * - * @name Phaser.Input.MOUSE_DOWN - * @type {integer} - * @since 3.10.0 - */ - MOUSE_DOWN: 0, - - /** - * The mouse pointer is being moved. - * - * @name Phaser.Input.MOUSE_MOVE - * @type {integer} - * @since 3.10.0 - */ - MOUSE_MOVE: 1, - - /** - * The mouse pointer is released. - * - * @name Phaser.Input.MOUSE_UP - * @type {integer} - * @since 3.10.0 - */ - MOUSE_UP: 2, - - /** - * A touch pointer has been started. - * - * @name Phaser.Input.TOUCH_START - * @type {integer} - * @since 3.10.0 - */ - TOUCH_START: 3, - - /** - * A touch pointer has been started. - * - * @name Phaser.Input.TOUCH_MOVE - * @type {integer} - * @since 3.10.0 - */ - TOUCH_MOVE: 4, - - /** - * A touch pointer has been started. - * - * @name Phaser.Input.TOUCH_END - * @type {integer} - * @since 3.10.0 - */ - TOUCH_END: 5, - - /** - * The pointer lock has changed. - * - * @name Phaser.Input.POINTER_LOCK_CHANGE - * @type {integer} - * @since 3.10.0 - */ - POINTER_LOCK_CHANGE: 6 - -}; - -module.exports = INPUT_CONST; - - -/***/ }), -/* 201 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(200); -var EventEmitter = __webpack_require__(9); -var Mouse = __webpack_require__(199); -var Pointer = __webpack_require__(198); -var Rectangle = __webpack_require__(14); -var Touch = __webpack_require__(197); -var TransformMatrix = __webpack_require__(64); -var TransformXY = __webpack_require__(257); - -/** - * @classdesc - * The Input Manager is responsible for handling the pointer related systems in a single Phaser Game instance. - * - * Based on the Game Config it will create handlers for mouse and touch support. - * - * Keyboard and Gamepad are plugins, handled directly by the InputPlugin class. - * - * It then manages the event queue, pointer creation and general hit test related operations. - * - * You rarely need to interact with the Input Manager directly, and as such, all of its properties and methods - * should be considered private. Instead, you should use the Input Plugin, which is a Scene level system, responsible - * for dealing with all input events for a Scene. - * - * @class InputManager - * @memberOf Phaser.Input - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Game instance that owns the Input Manager. - * @param {object} config - The Input Configuration object, as set in the Game Config. - */ -var InputManager = new Class({ - - initialize: - - function InputManager (game, config) - { - /** - * The Game instance that owns the Input Manager. - * A Game only maintains on instance of the Input Manager at any time. - * - * @name Phaser.Input.InputManager#game - * @type {Phaser.Game} - * @readOnly - * @since 3.0.0 - */ - this.game = game; - - /** - * The Canvas that is used for all DOM event input listeners. - * - * @name Phaser.Input.InputManager#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas; - - /** - * The Input Configuration object, as set in the Game Config. - * - * @name Phaser.Input.InputManager#config - * @type {object} - * @since 3.0.0 - */ - this.config = config; - - /** - * If set, the Input Manager will run its update loop every frame. - * - * @name Phaser.Input.InputManager#enabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enabled = true; - - /** - * The Event Emitter instance that the Input Manager uses to emit events from. - * - * @name Phaser.Input.InputManager#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events = new EventEmitter(); - - /** - * A standard FIFO queue for the native DOM events waiting to be handled by the Input Manager. - * - * @name Phaser.Input.InputManager#queue - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.queue = []; - - /** - * DOM Callbacks container. - * - * @name Phaser.Input.InputManager#domCallbacks - * @private - * @type {object} - * @since 3.10.0 - */ - this.domCallbacks = { up: [], down: [], move: [], upOnce: [], downOnce: [], moveOnce: [] }; - - /** - * Are there any up callbacks defined? - * - * @name Phaser.Input.InputManager#_hasUpCallback - * @private - * @type {boolean} - * @since 3.10.0 - */ - this._hasUpCallback = false; - - /** - * Are there any down callbacks defined? - * - * @name Phaser.Input.InputManager#_hasDownCallback - * @private - * @type {boolean} - * @since 3.10.0 - */ - this._hasDownCallback = false; - - /** - * Are there any move callbacks defined? - * - * @name Phaser.Input.InputManager#_hasMoveCallback - * @private - * @type {boolean} - * @since 3.10.0 - */ - this._hasMoveCallback = false; - - /** - * Is a custom cursor currently set? (desktop only) - * - * @name Phaser.Input.InputManager#_customCursor - * @private - * @type {string} - * @since 3.10.0 - */ - this._customCursor = ''; - - /** - * Custom cursor tracking value. - * - * 0 - No change. - * 1 - Set new cursor. - * 2 - Reset cursor. - * - * @name Phaser.Input.InputManager#_setCursor - * @private - * @type {integer} - * @since 3.10.0 - */ - this._setCursor = 0; - - /** - * The default CSS cursor to be used when interacting with your game. - * - * See the `setDefaultCursor` method for more details. - * - * @name Phaser.Input.InputManager#defaultCursor - * @type {string} - * @since 3.10.0 - */ - this.defaultCursor = ''; - - /** - * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. - * - * @name Phaser.Input.InputManager#mouse - * @type {?Phaser.Input.Mouse.MouseManager} - * @since 3.0.0 - */ - this.mouse = (config.inputMouse) ? new Mouse(this) : null; - - /** - * A reference to the Touch Manager class, if enabled via the `input.touch` Game Config property. - * - * @name Phaser.Input.InputManager#touch - * @type {Phaser.Input.Touch.TouchManager} - * @since 3.0.0 - */ - this.touch = (config.inputTouch) ? new Touch(this) : null; - - /** - * An array of Pointers that have been added to the game. - * The first entry is reserved for the Mouse Pointer, the rest are Touch Pointers. - * - * By default there is 1 touch pointer enabled. If you need more use the `addPointer` method to start them, - * or set the `input.activePointers` property in the Game Config. - * - * @name Phaser.Input.InputManager#pointers - * @type {Phaser.Input.Pointer[]} - * @since 3.10.0 - */ - this.pointers = []; - - /** - * The number of touch objects activated and being processed each update. - * - * You can change this by either calling `addPointer` at run-time, or by - * setting the `input.activePointers` property in the Game Config. - * - * @name Phaser.Input.InputManager#pointersTotal - * @type {integer} - * @readOnly - * @since 3.10.0 - */ - this.pointersTotal = config.inputActivePointers; - - if (config.inputTouch && this.pointersTotal === 1) - { - this.pointersTotal = 2; - } - - for (var i = 0; i <= this.pointersTotal; i++) - { - this.pointers.push(new Pointer(this, i)); - } - - /** - * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. - * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` - * which will always map to the most recently interacted pointer. - * - * @name Phaser.Input.InputManager#mousePointer - * @type {?Phaser.Input.Pointer} - * @since 3.10.0 - */ - this.mousePointer = (config.inputMouse) ? this.pointers[0] : null; - - /** - * The most recently active Pointer object. - * - * If you've only 1 Pointer in your game then this will accurately be either the first finger touched, or the mouse. - * - * If your game doesn't need to support multi-touch then you can safely use this property in all of your game - * code and it will adapt to be either the mouse or the touch, based on device. - * - * @name Phaser.Input.InputManager#activePointer - * @type {Phaser.Input.Pointer} - * @since 3.0.0 - */ - this.activePointer = this.pointers[0]; - - /** - * Reset every frame. Set to `true` if any of the Pointers are dirty this frame. - * - * @name Phaser.Input.InputManager#dirty - * @type {boolean} - * @since 3.10.0 - */ - this.dirty = false; - - /** - * The Scale factor being applied to input coordinates. - * - * @name Phaser.Input.InputManager#scale - * @type { { x:number, y:number } } - * @since 3.0.0 - */ - this.scale = { x: 1, y: 1 }; - - /** - * If the top-most Scene in the Scene List receives an input it will stop input from - * propagating any lower down the scene list, i.e. if you have a UI Scene at the top - * and click something on it, that click will not then be passed down to any other - * Scene below. Disable this to have input events passed through all Scenes, all the time. - * - * @name Phaser.Input.InputManager#globalTopOnly - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.globalTopOnly = true; - - /** - * An internal flag that controls if the Input Manager will ignore or process native DOM events this frame. - * Set via the InputPlugin.stopPropagation method. - * - * @name Phaser.Input.InputManager#ignoreEvents - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.ignoreEvents = false; - - /** - * The bounds of the Input Manager, used for pointer hit test calculations. - * - * @name Phaser.Input.InputManager#bounds - * @type {Phaser.Geom.Rectangle} - * @since 3.0.0 - */ - this.bounds = new Rectangle(); - - /** - * A re-cycled point-like object to store hit test values in. - * - * @name Phaser.Input.InputManager#_tempPoint - * @type {{x:number,y:number}} - * @private - * @since 3.0.0 - */ - this._tempPoint = { x: 0, y: 0 }; - - /** - * A re-cycled array to store hit results in. - * - * @name Phaser.Input.InputManager#_tempHitTest - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._tempHitTest = []; - - /** - * A re-cycled matrix used in hit test calculations. - * - * @name Phaser.Input.InputManager#_tempMatrix - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @private - * @since 3.4.0 - */ - this._tempMatrix = new TransformMatrix(); - - game.events.once('boot', this.boot, this); - }, - - /** - * The Boot handler is called by Phaser.Game when it first starts up. - * The renderer is available by now. - * - * @method Phaser.Input.InputManager#boot - * @protected - * @since 3.0.0 - */ - boot: function () - { - this.canvas = this.game.canvas; - - this.updateBounds(); - - this.events.emit('boot'); - - this.game.events.on('prestep', this.update, this); - this.game.events.on('poststep', this.postUpdate, this); - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * Updates the Input Manager bounds rectangle to match the bounding client rectangle of the - * canvas element being used to track input events. - * - * @method Phaser.Input.InputManager#updateBounds - * @since 3.0.0 - */ - updateBounds: function () - { - var bounds = this.bounds; - - var clientRect = this.canvas.getBoundingClientRect(); - - bounds.x = clientRect.left + window.pageXOffset - document.documentElement.clientLeft; - bounds.y = clientRect.top + window.pageYOffset - document.documentElement.clientTop; - bounds.width = clientRect.width; - bounds.height = clientRect.height; - }, - - /** - * Resizes the Input Manager internal values, including the bounds and scale factor. - * - * @method Phaser.Input.InputManager#resize - * @since 3.2.0 - */ - resize: function () - { - this.updateBounds(); - - // Game config size - var gw = this.game.config.width; - var gh = this.game.config.height; - - // Actual canvas size - var bw = this.bounds.width; - var bh = this.bounds.height; - - // Scale factor - this.scale.x = gw / bw; - this.scale.y = gh / bh; - }, - - /** - * Internal update loop, called automatically by the Game Step. - * - * @method Phaser.Input.InputManager#update - * @private - * @since 3.0.0 - * - * @param {number} time - The time stamp value of this game step. - */ - update: function (time) - { - var i; - - this._setCursor = 0; - - this.events.emit('update'); - - this.ignoreEvents = false; - - this.dirty = false; - - var len = this.queue.length; - - var pointers = this.pointers; - - for (i = 0; i < this.pointersTotal; i++) - { - pointers[i].reset(); - } - - if (!this.enabled || len === 0) - { - return; - } - - this.dirty = true; - - this.updateBounds(); - - this.scale.x = this.game.config.width / this.bounds.width; - this.scale.y = this.game.config.height / this.bounds.height; - - // Clears the queue array, and also means we don't work on array data that could potentially - // be modified during the processing phase - var queue = this.queue.splice(0, len); - var mouse = this.mousePointer; - - // Process the event queue, dispatching all of the events that have stored up - for (i = 0; i < len; i += 2) - { - var type = queue[i]; - var event = queue[i + 1]; - - switch (type) - { - case CONST.MOUSE_DOWN: - mouse.down(event, time); - break; - - case CONST.MOUSE_MOVE: - mouse.move(event, time); - break; - - case CONST.MOUSE_UP: - mouse.up(event, time); - break; - - case CONST.TOUCH_START: - this.startPointer(event, time); - break; - - case CONST.TOUCH_MOVE: - this.updatePointer(event, time); - break; - - case CONST.TOUCH_END: - this.stopPointer(event, time); - break; - - case CONST.POINTER_LOCK_CHANGE: - this.events.emit('pointerlockchange', event, this.mouse.locked); - break; - } - } - }, - - /** - * Internal post-update, called automatically by the Game step. - * - * @method Phaser.Input.InputManager#postUpdate - * @private - * @since 3.10.0 - */ - postUpdate: function () - { - if (this._setCursor === 1) - { - this.canvas.style.cursor = this._customCursor; - } - else if (this._setCursor === 2) - { - this.canvas.style.cursor = this.defaultCursor; - } - }, - - /** - * Tells the Input system to set a custom cursor. - * - * This cursor will be the default cursor used when interacting with the game canvas. - * - * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. - * - * Any valid CSS cursor value is allowed, including paths to image files, i.e.: - * - * ```javascript - * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); - * ``` - * - * Please read about the differences between browsers when it comes to the file formats and sizes they support: - * - * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor - * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property - * - * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. - * - * @method Phaser.Input.InputManager#setDefaultCursor - * @since 3.10.0 - * - * @param {string} cursor - The CSS to be used when setting the default cursor. - */ - setDefaultCursor: function (cursor) - { - this.defaultCursor = cursor; - - if (this.canvas.style.cursor !== cursor) - { - this.canvas.style.cursor = cursor; - } - }, - - /** - * Called by the InputPlugin when processing over and out events. - * - * Tells the Input Manager to set a custom cursor during its postUpdate step. - * - * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor - * - * @method Phaser.Input.InputManager#setCursor - * @private - * @since 3.10.0 - * - * @param {Phaser.Input.InteractiveObject} interactiveObject - The Interactive Object that called this method. - */ - setCursor: function (interactiveObject) - { - if (interactiveObject.cursor) - { - this._setCursor = 1; - this._customCursor = interactiveObject.cursor; - } - }, - - /** - * Called by the InputPlugin when processing over and out events. - * - * Tells the Input Manager to clear the hand cursor, if set, during its postUpdate step. - * - * @method Phaser.Input.InputManager#resetCursor - * @private - * @since 3.10.0 - * - * @param {Phaser.Input.InteractiveObject} interactiveObject - The Interactive Object that called this method. - */ - resetCursor: function (interactiveObject) - { - if (interactiveObject.cursor) - { - this._setCursor = 2; - } - }, - - // event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element) - // event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element - // event.changedTouches = the touches that CHANGED in this event, not the total number of them - - /** - * Called by the main update loop when a Touch Start Event is received. - * - * @method Phaser.Input.InputManager#startPointer - * @private - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM event to be processed. - * @param {number} time - The time stamp value of this game step. - */ - startPointer: function (event, time) - { - var pointers = this.pointers; - - for (var c = 0; c < event.changedTouches.length; c++) - { - var changedTouch = event.changedTouches[c]; - - for (var i = 1; i < this.pointersTotal; i++) - { - var pointer = pointers[i]; - - if (!pointer.active) - { - pointer.touchstart(changedTouch, time); - this.activePointer = pointer; - break; - } - } - } - }, - - /** - * Called by the main update loop when a Touch Move Event is received. - * - * @method Phaser.Input.InputManager#updatePointer - * @private - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM event to be processed. - * @param {number} time - The time stamp value of this game step. - */ - updatePointer: function (event, time) - { - var pointers = this.pointers; - - for (var c = 0; c < event.changedTouches.length; c++) - { - var changedTouch = event.changedTouches[c]; - - for (var i = 1; i < this.pointersTotal; i++) - { - var pointer = pointers[i]; - - if (pointer.active && pointer.identifier === changedTouch.identifier) - { - pointer.touchmove(changedTouch, time); - this.activePointer = pointer; - break; - } - } - } - }, - - // For touch end its a list of the touch points that have been removed from the surface - // https://developer.mozilla.org/en-US/docs/DOM/TouchList - // event.changedTouches = the touches that CHANGED in this event, not the total number of them - - /** - * Called by the main update loop when a Touch End Event is received. - * - * @method Phaser.Input.InputManager#stopPointer - * @private - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM event to be processed. - * @param {number} time - The time stamp value of this game step. - */ - stopPointer: function (event, time) - { - var pointers = this.pointers; - - for (var c = 0; c < event.changedTouches.length; c++) - { - var changedTouch = event.changedTouches[c]; - - for (var i = 1; i < this.pointersTotal; i++) - { - var pointer = pointers[i]; - - if (pointer.active && pointer.identifier === changedTouch.identifier) - { - pointer.touchend(changedTouch, time); - break; - } - } - } - }, - - /** - * Adds new Pointer objects to the Input Manager. - * - * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. - * - * You can create more either by calling this method, or by setting the `input.activePointers` property - * in the Game Config, up to a maximum of 10 pointers. - * - * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added - * via this method. - * - * @method Phaser.Input.InputManager#addPointer - * @since 3.10.0 - * - * @param {integer} [quantity=1] The number of new Pointers to create. A maximum of 10 is allowed in total. - * - * @return {Phaser.Input.Pointer[]} An array containing all of the new Pointer objects that were created. - */ - addPointer: function (quantity) - { - if (quantity === undefined) { quantity = 1; } - - var output = []; - - if (this.pointersTotal + quantity > 10) - { - quantity = 10 - this.pointersTotal; - } - - for (var i = 0; i < quantity; i++) - { - var id = this.pointers.length; - - var pointer = new Pointer(this, id); - - this.pointers.push(pointer); - - this.pointersTotal++; - - output.push(pointer); - } - - return output; - }, - - /** - * Process any pending DOM callbacks. - * - * @method Phaser.Input.InputManager#processDomCallbacks - * @private - * @since 3.10.0 - * - * @param {array} once - The isOnce callbacks to invoke. - * @param {array} every - The every frame callbacks to invoke. - * @param {any} event - The native DOM event that is passed to the callbacks. - * - * @return {boolean} `true` if there are callbacks still in the list, otherwise `false`. - */ - processDomCallbacks: function (once, every, event) - { - var i = 0; - - for (i = 0; i < once.length; i++) - { - once[i](event); - } - - for (i = 0; i < every.length; i++) - { - every[i](event); - } - - once = []; - - return (every.length > 0); - }, - - /** - * Queues a touch start event, as passed in by the TouchManager. - * Also dispatches any DOM callbacks for this event. - * - * @method Phaser.Input.InputManager#queueTouchStart - * @private - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch event. - */ - queueTouchStart: function (event) - { - this.queue.push(CONST.TOUCH_START, event); - - if (this._hasDownCallback) - { - var callbacks = this.domCallbacks; - - this._hasDownCallback = this.processDomCallbacks(callbacks.downOnce, callbacks.down, event); - } - }, - - /** - * Queues a touch move event, as passed in by the TouchManager. - * Also dispatches any DOM callbacks for this event. - * - * @method Phaser.Input.InputManager#queueTouchMove - * @private - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch event. - */ - queueTouchMove: function (event) - { - this.queue.push(CONST.TOUCH_MOVE, event); - - if (this._hasMoveCallback) - { - var callbacks = this.domCallbacks; - - this._hasMoveCallback = this.processDomCallbacks(callbacks.moveOnce, callbacks.move, event); - } - }, - - /** - * Queues a touch end event, as passed in by the TouchManager. - * Also dispatches any DOM callbacks for this event. - * - * @method Phaser.Input.InputManager#queueTouchEnd - * @private - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch event. - */ - queueTouchEnd: function (event) - { - this.queue.push(CONST.TOUCH_END, event); - - if (this._hasUpCallback) - { - var callbacks = this.domCallbacks; - - this._hasUpCallback = this.processDomCallbacks(callbacks.upOnce, callbacks.up, event); - } - }, - - /** - * Queues a mouse down event, as passed in by the MouseManager. - * Also dispatches any DOM callbacks for this event. - * - * @method Phaser.Input.InputManager#queueMouseDown - * @private - * @since 3.10.0 - * - * @param {MouseEvent} event - The native DOM Mouse event. - */ - queueMouseDown: function (event) - { - this.queue.push(CONST.MOUSE_DOWN, event); - - if (this._hasDownCallback) - { - var callbacks = this.domCallbacks; - - this._hasDownCallback = this.processDomCallbacks(callbacks.downOnce, callbacks.down, event); - } - }, - - /** - * Queues a mouse move event, as passed in by the MouseManager. - * Also dispatches any DOM callbacks for this event. - * - * @method Phaser.Input.InputManager#queueMouseMove - * @private - * @since 3.10.0 - * - * @param {MouseEvent} event - The native DOM Mouse event. - */ - queueMouseMove: function (event) - { - this.queue.push(CONST.MOUSE_MOVE, event); - - if (this._hasMoveCallback) - { - var callbacks = this.domCallbacks; - - this._hasMoveCallback = this.processDomCallbacks(callbacks.moveOnce, callbacks.move, event); - } - }, - - /** - * Queues a mouse up event, as passed in by the MouseManager. - * Also dispatches any DOM callbacks for this event. - * - * @method Phaser.Input.InputManager#queueMouseUp - * @private - * @since 3.10.0 - * - * @param {MouseEvent} event - The native DOM Mouse event. - */ - queueMouseUp: function (event) - { - this.queue.push(CONST.MOUSE_UP, event); - - if (this._hasUpCallback) - { - var callbacks = this.domCallbacks; - - this._hasUpCallback = this.processDomCallbacks(callbacks.upOnce, callbacks.up, event); - } - }, - - /** - * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is released, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * - * @method Phaser.Input.InputManager#addUpCallback - * @since 3.10.0 - * - * @param {function} callback - The callback to be invoked on this dom event. - * @param {boolean} [isOnce=true] - `true` if the callback will only be invoked once, `false` to call every time this event happens. - * - * @return {this} The Input Manager. - */ - addUpCallback: function (callback, isOnce) - { - if (isOnce === undefined) { isOnce = true; } - - if (isOnce) - { - this.domCallbacks.upOnce.push(callback); - } - else - { - this.domCallbacks.up.push(callback); - } - - this._hasUpCallback = true; - - return this; - }, - - /** - * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is down, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * - * @method Phaser.Input.InputManager#addDownCallback - * @since 3.10.0 - * - * @param {function} callback - The callback to be invoked on this dom event. - * @param {boolean} [isOnce=true] - `true` if the callback will only be invoked once, `false` to call every time this event happens. - * - * @return {this} The Input Manager. - */ - addDownCallback: function (callback, isOnce) - { - if (isOnce === undefined) { isOnce = true; } - - if (isOnce) - { - this.domCallbacks.downOnce.push(callback); - } - else - { - this.domCallbacks.down.push(callback); - } - - this._hasDownCallback = true; - - return this; - }, - - /** - * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is moved, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * - * @method Phaser.Input.InputManager#addMoveCallback - * @since 3.10.0 - * - * @param {function} callback - The callback to be invoked on this dom event. - * @param {boolean} [isOnce=false] - `true` if the callback will only be invoked once, `false` to call every time this event happens. - * - * @return {this} The Input Manager. - */ - addMoveCallback: function (callback, isOnce) - { - if (isOnce === undefined) { isOnce = false; } - - if (isOnce) - { - this.domCallbacks.moveOnce.push(callback); - } - else - { - this.domCallbacks.move.push(callback); - } - - this._hasMoveCallback = true; - - return this; - }, - - /** - * Checks if the given Game Object should be considered as a candidate for input or not. - * - * Checks if the Game Object has an input component that is enabled, that it will render, - * and finally, if it has a parent, that the parent parent, or any ancestor, is visible or not. - * - * @method Phaser.Input.InputManager#inputCandidate - * @private - * @since 3.10.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to test. - * - * @return {boolean} `true` if the Game Object should be considered for input, otherwise `false`. - */ - inputCandidate: function (gameObject) - { - var input = gameObject.input; - - if (!input || !input.enabled || !gameObject.willRender()) - { - return false; - } - - var visible = true; - var parent = gameObject.parentContainer; - - if (parent) - { - do - { - if (!parent.visible) - { - visible = false; - break; - } - - parent = parent.parentContainer; - - } while (parent); - } - - return visible; - }, - - /** - * Performs a hit test using the given Pointer and camera, against an array of interactive Game Objects. - * - * The Game Objects are culled against the camera, and then the coordinates are translated into the local camera space - * and used to determine if they fall within the remaining Game Objects hit areas or not. - * - * If nothing is matched an empty array is returned. - * - * This method is called automatically by InputPlugin.hitTestPointer and doesn't usually need to be invoked directly. - * - * @method Phaser.Input.InputManager#hitTest - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - The Pointer to test against. - * @param {array} gameObjects - An array of interactive Game Objects to check. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against. - * @param {array} [output] - An array to store the results in. If not given, a new empty array is created. - * - * @return {array} An array of the Game Objects that were hit during this hit test. - */ - hitTest: function (pointer, gameObjects, camera, output) - { - if (output === undefined) { output = this._tempHitTest; } - - var tempPoint = this._tempPoint; - var cameraW = camera.width; - var cameraH = camera.height; - - output.length = 0; - - var x = pointer.x; - var y = pointer.y; - - if (!(x >= camera.x && y >= camera.y && x <= camera.x + cameraW && y <= camera.y + cameraH)) - { - return output; - } - - // Stores the world point inside of tempPoint - camera.getWorldPoint(x, y, tempPoint); - - pointer.worldX = tempPoint.x; - pointer.worldY = tempPoint.y; - - // Disable until fixed. - // var culledGameObjects = camera.cull(gameObjects); - - var point = { x: 0, y: 0 }; - - var res = this.game.config.resolution; - - var matrix = this._tempMatrix; - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - - if (!this.inputCandidate(gameObject)) - { - continue; - } - - var px = tempPoint.x * res + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX; - var py = tempPoint.y * res + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY; - - if (gameObject.parentContainer) - { - gameObject.getWorldTransformMatrix(matrix); - - TransformXY(px, py, matrix.tx, matrix.ty, matrix.rotation, matrix.scaleX, matrix.scaleY, point); - } - else - { - TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); - } - - if (this.pointWithinHitArea(gameObject, point.x, point.y)) - { - output.push(gameObject); - } - } - - return output; - }, - - /** - * Checks if the given x and y coordinate are within the hit area of the Game Object. - * - * This method assumes that the coordinate values have already been translated into the space of the Game Object. - * - * If the coordinates are within the hit area they are set into the Game Objects Input `localX` and `localY` properties. - * - * @method Phaser.Input.InputManager#pointWithinHitArea - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object to check against. - * @param {number} x - The translated x coordinate for the hit test. - * @param {number} y - The translated y coordinate for the hit test. - * - * @return {boolean} `true` if the coordinates were inside the Game Objects hit area, otherwise `false`. - */ - pointWithinHitArea: function (gameObject, x, y) - { - // Normalize the origin - x += gameObject.displayOriginX; - y += gameObject.displayOriginY; - - var input = gameObject.input; - - if (input && input.hitAreaCallback(input.hitArea, x, y, gameObject)) - { - input.localX = x; - input.localY = y; - - return true; - } - else - { - return false; - } - }, - - /** - * Checks if the given x and y coordinate are within the hit area of the Interactive Object. - * - * This method assumes that the coordinate values have already been translated into the space of the Interactive Object. - * - * If the coordinates are within the hit area they are set into the Interactive Objects Input `localX` and `localY` properties. - * - * @method Phaser.Input.InputManager#pointWithinInteractiveObject - * @since 3.0.0 - * - * @param {Phaser.Input.InteractiveObject} object - The Interactive Object to check against. - * @param {number} x - The translated x coordinate for the hit test. - * @param {number} y - The translated y coordinate for the hit test. - * - * @return {boolean} `true` if the coordinates were inside the Game Objects hit area, otherwise `false`. - */ - pointWithinInteractiveObject: function (object, x, y) - { - if (!object.hitArea) - { - return false; - } - - // Normalize the origin - x += object.gameObject.displayOriginX; - y += object.gameObject.displayOriginY; - - object.localX = x; - object.localY = y; - - return object.hitAreaCallback(object.hitArea, x, y, object); - }, - - /** - * Transforms the pageX and pageY values of a Pointer into the scaled coordinate space of the Input Manager. - * - * @method Phaser.Input.InputManager#transformPointer - * @since 3.10.0 - * - * @param {Phaser.Input.Pointer} pointer - The Pointer to transform the values for. - * - * @return {number} The translated value. - */ - transformPointer: function (pointer, pageX, pageY) - { - pointer.x = (pageX - this.bounds.left) * this.scale.x; - pointer.y = (pageY - this.bounds.top) * this.scale.y; - }, - - /** - * Transforms the pageX value into the scaled coordinate space of the Input Manager. - * - * @method Phaser.Input.InputManager#transformX - * @since 3.0.0 - * - * @param {number} pageX - The DOM pageX value. - * - * @return {number} The translated value. - */ - transformX: function (pageX) - { - return (pageX - this.bounds.left) * this.scale.x; - }, - - /** - * Transforms the pageY value into the scaled coordinate space of the Input Manager. - * - * @method Phaser.Input.InputManager#transformY - * @since 3.0.0 - * - * @param {number} pageY - The DOM pageY value. - * - * @return {number} The translated value. - */ - transformY: function (pageY) - { - return (pageY - this.bounds.top) * this.scale.y; - }, - - /** - * Returns the left offset of the Input bounds. - * - * @method Phaser.Input.InputManager#getOffsetX - * @since 3.0.0 - * - * @return {number} The left bounds value. - */ - getOffsetX: function () - { - return this.bounds.left; - }, - - /** - * Returns the top offset of the Input bounds. - * - * @method Phaser.Input.InputManager#getOffsetY - * @since 3.0.0 - * - * @return {number} The top bounds value. - */ - getOffsetY: function () - { - return this.bounds.top; - }, - - /** - * Returns the horizontal Input Scale value. - * - * @method Phaser.Input.InputManager#getScaleX - * @since 3.0.0 - * - * @return {number} The horizontal scale factor of the input. - */ - getScaleX: function () - { - return this.game.config.width / this.bounds.width; - }, - - /** - * Returns the vertical Input Scale value. - * - * @method Phaser.Input.InputManager#getScaleY - * @since 3.0.0 - * - * @return {number} The vertical scale factor of the input. - */ - getScaleY: function () - { - return this.game.config.height / this.bounds.height; - }, - - /** - * Destroys the Input Manager and all of its systems. - * - * There is no way to recover from doing this. - * - * @method Phaser.Input.InputManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.events.removeAllListeners(); - - if (this.mouse) - { - this.mouse.destroy(); - } - - if (this.touch) - { - this.touch.destroy(); - } - - for (var i = 0; i < this.pointers.length; i++) - { - this.pointers[i].destroy(); - } - - this.domCallbacks = {}; - this.pointers = []; - this.queue = []; - this._tempHitTest = []; - this._tempMatrix.destroy(); - this.canvas = null; - this.game = null; - } - -}); - -module.exports = InputManager; - - -/***/ }), -/* 202 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -/** - * Implements a model view projection matrices. - * Pipelines can implement this for doing 2D and 3D rendering. - */ - -var ModelViewProjection = { - - /** - * Dirty flag for checking if model matrix needs to be updated on GPU. - */ - modelMatrixDirty: false, - - /** - * Dirty flag for checking if view matrix needs to be updated on GPU. - */ - viewMatrixDirty: false, - - /** - * Dirty flag for checking if projection matrix needs to be updated on GPU. - */ - projectionMatrixDirty: false, - - /** - * Model matrix - */ - modelMatrix: null, - - /** - * View matrix - */ - viewMatrix: null, - - /** - * Projection matrix - */ - projectionMatrix: null, - - /** - * Initializes MVP matrices with an identity matrix - */ - mvpInit: function () - { - this.modelMatrixDirty = true; - this.viewMatrixDirty = true; - this.projectionMatrixDirty = true; - - this.modelMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.viewMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.projectionMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - return this; - }, - - /** - * If dirty flags are set then the matrices are uploaded to the GPU. - */ - mvpUpdate: function () - { - var program = this.program; - - if (this.modelMatrixDirty) - { - this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); - this.modelMatrixDirty = false; - } - - if (this.viewMatrixDirty) - { - this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); - this.viewMatrixDirty = false; - } - - if (this.projectionMatrixDirty) - { - this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); - this.projectionMatrixDirty = false; - } - - return this; - }, - - /** - * Loads an identity matrix to the model matrix - */ - modelIdentity: function () - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = 1; - modelMatrix[1] = 0; - modelMatrix[2] = 0; - modelMatrix[3] = 0; - modelMatrix[4] = 0; - modelMatrix[5] = 1; - modelMatrix[6] = 0; - modelMatrix[7] = 0; - modelMatrix[8] = 0; - modelMatrix[9] = 0; - modelMatrix[10] = 1; - modelMatrix[11] = 0; - modelMatrix[12] = 0; - modelMatrix[13] = 0; - modelMatrix[14] = 0; - modelMatrix[15] = 1; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Scale model matrix - */ - modelScale: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = modelMatrix[0] * x; - modelMatrix[1] = modelMatrix[1] * x; - modelMatrix[2] = modelMatrix[2] * x; - modelMatrix[3] = modelMatrix[3] * x; - modelMatrix[4] = modelMatrix[4] * y; - modelMatrix[5] = modelMatrix[5] * y; - modelMatrix[6] = modelMatrix[6] * y; - modelMatrix[7] = modelMatrix[7] * y; - modelMatrix[8] = modelMatrix[8] * z; - modelMatrix[9] = modelMatrix[9] * z; - modelMatrix[10] = modelMatrix[10] * z; - modelMatrix[11] = modelMatrix[11] * z; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Translate model matrix - */ - modelTranslate: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; - modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; - modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; - modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; - - this.modelMatrixDirty = true; - - return this; - }, - - - /** - * Rotates the model matrix in the X axis. - */ - modelRotateX: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[4] = a10 * c + a20 * s; - modelMatrix[5] = a11 * c + a21 * s; - modelMatrix[6] = a12 * c + a22 * s; - modelMatrix[7] = a13 * c + a23 * s; - modelMatrix[8] = a20 * c - a10 * s; - modelMatrix[9] = a21 * c - a11 * s; - modelMatrix[10] = a22 * c - a12 * s; - modelMatrix[11] = a23 * c - a13 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Rotates the model matrix in the Y axis. - */ - modelRotateY: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[0] = a00 * c - a20 * s; - modelMatrix[1] = a01 * c - a21 * s; - modelMatrix[2] = a02 * c - a22 * s; - modelMatrix[3] = a03 * c - a23 * s; - modelMatrix[8] = a00 * s + a20 * c; - modelMatrix[9] = a01 * s + a21 * c; - modelMatrix[10] = a02 * s + a22 * c; - modelMatrix[11] = a03 * s + a23 * c; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Rotates the model matrix in the Z axis. - */ - modelRotateZ: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - - modelMatrix[0] = a00 * c + a10 * s; - modelMatrix[1] = a01 * c + a11 * s; - modelMatrix[2] = a02 * c + a12 * s; - modelMatrix[3] = a03 * c + a13 * s; - modelMatrix[4] = a10 * c - a00 * s; - modelMatrix[5] = a11 * c - a01 * s; - modelMatrix[6] = a12 * c - a02 * s; - modelMatrix[7] = a13 * c - a03 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Loads identity matrix into the view matrix - */ - viewIdentity: function () - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = 1; - viewMatrix[1] = 0; - viewMatrix[2] = 0; - viewMatrix[3] = 0; - viewMatrix[4] = 0; - viewMatrix[5] = 1; - viewMatrix[6] = 0; - viewMatrix[7] = 0; - viewMatrix[8] = 0; - viewMatrix[9] = 0; - viewMatrix[10] = 1; - viewMatrix[11] = 0; - viewMatrix[12] = 0; - viewMatrix[13] = 0; - viewMatrix[14] = 0; - viewMatrix[15] = 1; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Scales view matrix - */ - viewScale: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = viewMatrix[0] * x; - viewMatrix[1] = viewMatrix[1] * x; - viewMatrix[2] = viewMatrix[2] * x; - viewMatrix[3] = viewMatrix[3] * x; - viewMatrix[4] = viewMatrix[4] * y; - viewMatrix[5] = viewMatrix[5] * y; - viewMatrix[6] = viewMatrix[6] * y; - viewMatrix[7] = viewMatrix[7] * y; - viewMatrix[8] = viewMatrix[8] * z; - viewMatrix[9] = viewMatrix[9] * z; - viewMatrix[10] = viewMatrix[10] * z; - viewMatrix[11] = viewMatrix[11] * z; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Translates view matrix - */ - viewTranslate: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; - viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; - viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; - viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Rotates view matrix in the X axis. - */ - viewRotateX: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[4] = a10 * c + a20 * s; - viewMatrix[5] = a11 * c + a21 * s; - viewMatrix[6] = a12 * c + a22 * s; - viewMatrix[7] = a13 * c + a23 * s; - viewMatrix[8] = a20 * c - a10 * s; - viewMatrix[9] = a21 * c - a11 * s; - viewMatrix[10] = a22 * c - a12 * s; - viewMatrix[11] = a23 * c - a13 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Rotates view matrix in the Y axis. - */ - viewRotateY: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[0] = a00 * c - a20 * s; - viewMatrix[1] = a01 * c - a21 * s; - viewMatrix[2] = a02 * c - a22 * s; - viewMatrix[3] = a03 * c - a23 * s; - viewMatrix[8] = a00 * s + a20 * c; - viewMatrix[9] = a01 * s + a21 * c; - viewMatrix[10] = a02 * s + a22 * c; - viewMatrix[11] = a03 * s + a23 * c; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Rotates view matrix in the Z axis. - */ - viewRotateZ: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - - viewMatrix[0] = a00 * c + a10 * s; - viewMatrix[1] = a01 * c + a11 * s; - viewMatrix[2] = a02 * c + a12 * s; - viewMatrix[3] = a03 * c + a13 * s; - viewMatrix[4] = a10 * c - a00 * s; - viewMatrix[5] = a11 * c - a01 * s; - viewMatrix[6] = a12 * c - a02 * s; - viewMatrix[7] = a13 * c - a03 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Loads a 2D view matrix (3x2 matrix) into a 4x4 view matrix - */ - viewLoad2D: function (matrix2D) - { - var vm = this.viewMatrix; - - vm[0] = matrix2D[0]; - vm[1] = matrix2D[1]; - vm[2] = 0.0; - vm[3] = 0.0; - vm[4] = matrix2D[2]; - vm[5] = matrix2D[3]; - vm[6] = 0.0; - vm[7] = 0.0; - vm[8] = matrix2D[4]; - vm[9] = matrix2D[5]; - vm[10] = 1.0; - vm[11] = 0.0; - vm[12] = 0.0; - vm[13] = 0.0; - vm[14] = 0.0; - vm[15] = 1.0; - - this.viewMatrixDirty = true; - - return this; - }, - - - /** - * Copies a 4x4 matrix into the view matrix - */ - viewLoad: function (matrix) - { - var vm = this.viewMatrix; - - vm[0] = matrix[0]; - vm[1] = matrix[1]; - vm[2] = matrix[2]; - vm[3] = matrix[3]; - vm[4] = matrix[4]; - vm[5] = matrix[5]; - vm[6] = matrix[6]; - vm[7] = matrix[7]; - vm[8] = matrix[8]; - vm[9] = matrix[9]; - vm[10] = matrix[10]; - vm[11] = matrix[11]; - vm[12] = matrix[12]; - vm[13] = matrix[13]; - vm[14] = matrix[14]; - vm[15] = matrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Loads identity matrix into the projection matrix. - */ - projIdentity: function () - { - var projectionMatrix = this.projectionMatrix; - - projectionMatrix[0] = 1; - projectionMatrix[1] = 0; - projectionMatrix[2] = 0; - projectionMatrix[3] = 0; - projectionMatrix[4] = 0; - projectionMatrix[5] = 1; - projectionMatrix[6] = 0; - projectionMatrix[7] = 0; - projectionMatrix[8] = 0; - projectionMatrix[9] = 0; - projectionMatrix[10] = 1; - projectionMatrix[11] = 0; - projectionMatrix[12] = 0; - projectionMatrix[13] = 0; - projectionMatrix[14] = 0; - projectionMatrix[15] = 1; - - this.projectionMatrixDirty = true; - - return this; - }, - - /** - * Sets up an orthographics projection matrix - */ - projOrtho: function (left, right, bottom, top, near, far) - { - var projectionMatrix = this.projectionMatrix; - var leftRight = 1.0 / (left - right); - var bottomTop = 1.0 / (bottom - top); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = -2.0 * leftRight; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = -2.0 * bottomTop; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = 2.0 * nearFar; - projectionMatrix[11] = 0.0; - projectionMatrix[12] = (left + right) * leftRight; - projectionMatrix[13] = (top + bottom) * bottomTop; - projectionMatrix[14] = (far + near) * nearFar; - projectionMatrix[15] = 1.0; - - this.projectionMatrixDirty = true; - return this; - }, - - /** - * Sets up a perspective projection matrix - */ - projPersp: function (fovy, aspectRatio, near, far) - { - var projectionMatrix = this.projectionMatrix; - var fov = 1.0 / Math.tan(fovy / 2.0); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = fov / aspectRatio; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = fov; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = (far + near) * nearFar; - projectionMatrix[11] = -1.0; - projectionMatrix[12] = 0.0; - projectionMatrix[13] = 0.0; - projectionMatrix[14] = (2.0 * far * near) * nearFar; - projectionMatrix[15] = 0.0; - - this.projectionMatrixDirty = true; - return this; - } -}; - -module.exports = ModelViewProjection; - - -/***/ }), -/* 203 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(22); - -/** - * Determines the canvas features of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.canvasFeatures` from within any Scene. - * - * @typedef {object} Phaser.Device.CanvasFeatures - * @since 3.0.0 - * - * @property {boolean} supportInverseAlpha - Set to true if the browser supports inversed alpha. - * @property {boolean} supportNewBlendModes - Set to true if the browser supports new canvas blend modes. - */ -var CanvasFeatures = { - - supportInverseAlpha: false, - supportNewBlendModes: false - -}; - -function checkBlendMode () -{ - var pngHead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/'; - var pngEnd = 'AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg=='; - - var magenta = new Image(); - - magenta.onload = function () - { - var yellow = new Image(); - - yellow.onload = function () - { - var canvas = CanvasPool.create(yellow, 6, 1); - var context = canvas.getContext('2d'); - - context.globalCompositeOperation = 'multiply'; - - context.drawImage(magenta, 0, 0); - context.drawImage(yellow, 2, 0); - - if (!context.getImageData(2, 0, 1, 1)) - { - return false; - } - - var data = context.getImageData(2, 0, 1, 1).data; - - CanvasPool.remove(yellow); - - CanvasFeatures.supportNewBlendModes = (data[0] === 255 && data[1] === 0 && data[2] === 0); - }; - - yellow.src = pngHead + '/wCKxvRF' + pngEnd; - }; - - magenta.src = pngHead + 'AP804Oa6' + pngEnd; - - return false; -} - -function checkInverseAlpha () -{ - var canvas = CanvasPool.create(this, 2, 1); - var context = canvas.getContext('2d'); - - context.fillStyle = 'rgba(10, 20, 30, 0.5)'; - - // Draw a single pixel - context.fillRect(0, 0, 1, 1); - - // Get the color values - var s1 = context.getImageData(0, 0, 1, 1); - - if (s1 === null) - { - return false; - } - - // Plot them to x2 - context.putImageData(s1, 1, 0); - - // Get those values - var s2 = context.getImageData(1, 0, 1, 1); - - // Compare and return - return (s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]); -} - -function init () -{ - if (document !== undefined) - { - CanvasFeatures.supportNewBlendModes = checkBlendMode(); - CanvasFeatures.supportInverseAlpha = checkInverseAlpha(); - } - - return CanvasFeatures; -} - -module.exports = init(); - - -/***/ }), -/* 204 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @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: __webpack_require__(565), - Flash: __webpack_require__(564), - Shake: __webpack_require__(563) - -}; - - -/***/ }), -/* 205 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BaseCache = __webpack_require__(206); -var Class = __webpack_require__(0); - -/** - * @classdesc - * The Cache Manager is the global cache owned and maintained by the Game instance. - * - * Various systems, such as the file Loader, rely on this cache in order to store the files - * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache - * instances, one per type of file. You can also add your own custom caches. - * - * @class CacheManager - * @memberOf Phaser.Cache - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this CacheManager. - */ -var CacheManager = new Class({ - - initialize: - - function CacheManager (game) - { - /** - * A reference to the Phaser.Game instance that owns this CacheManager. - * - * @name Phaser.Cache.CacheManager#game - * @type {Phaser.Game} - * @protected - * @since 3.0.0 - */ - this.game = game; - - /** - * A Cache storing all binary files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#binary - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.binary = new BaseCache(); - - /** - * A Cache storing all bitmap font data files, typically added via the Loader. - * Only the font data is stored in this cache, the textures are part of the Texture Manager. - * - * @name Phaser.Cache.CacheManager#bitmapFont - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.bitmapFont = new BaseCache(); - - /** - * A Cache storing all JSON data files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#json - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.json = new BaseCache(); - - /** - * A Cache storing all physics data files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#physics - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.physics = new BaseCache(); - - /** - * A Cache storing all shader source files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#shader - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.shader = new BaseCache(); - - /** - * A Cache storing all non-streaming audio files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#audio - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.audio = new BaseCache(); - - /** - * A Cache storing all text files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#text - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.text = new BaseCache(); - - /** - * A Cache storing all WaveFront OBJ files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#obj - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.obj = new BaseCache(); - - /** - * A Cache storing all tilemap data files, typically added via the Loader. - * Only the data is stored in this cache, the textures are part of the Texture Manager. - * - * @name Phaser.Cache.CacheManager#tilemap - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.tilemap = new BaseCache(); - - /** - * A Cache storing all xml data files, typically added via the Loader. - * - * @name Phaser.Cache.CacheManager#xml - * @type {Phaser.Cache.BaseCache} - * @since 3.0.0 - */ - this.xml = new BaseCache(); - - /** - * An object that contains your own custom BaseCache entries. - * Add to this via the `addCustom` method. - * - * @name Phaser.Cache.CacheManager#custom - * @type {Object.} - * @since 3.0.0 - */ - this.custom = {}; - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * Add your own custom Cache for storing your own files. - * The cache will be available under `Cache.custom.key`. - * The cache will only be created if the key is not already in use. - * - * @method Phaser.Cache.CacheManager#addCustom - * @since 3.0.0 - * - * @param {string} key - The unique key of your custom cache. - * - * @return {Phaser.Cache.BaseCache} A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead. - */ - addCustom: function (key) - { - if (!this.custom.hasOwnProperty(key)) - { - this.custom[key] = new BaseCache(); - } - - return this.custom[key]; - }, - - /** - * Removes all entries from all BaseCaches and destroys all custom caches. - * - * @method Phaser.Cache.CacheManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - var keys = [ - 'binary', - 'bitmapFont', - 'json', - 'physics', - 'shader', - 'audio', - 'text', - 'obj', - 'tilemap', - 'xml' - ]; - - for (var i = 0; i < keys.length; i++) - { - this[keys[i]].destroy(); - this[keys[i]] = null; - } - - for (var key in this.custom) - { - this.custom[key].destroy(); - } - - this.custom = null; - - this.game = null; - } - -}); - -module.exports = CacheManager; - - -/***/ }), -/* 206 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(124); -var EventEmitter = __webpack_require__(9); - -/** - * @classdesc - * The BaseCache is a base Cache class that can be used for storing references to any kind of data. - * - * Data can be added, retrieved and removed based on the given keys. - * - * Keys are string-based. - * - * @class BaseCache - * @memberOf Phaser.Cache - * @constructor - * @since 3.0.0 - */ -var BaseCache = new Class({ - - initialize: - - function BaseCache () - { - /** - * The Map in which the cache objects are stored. - * - * You can query the Map directly or use the BaseCache methods. - * - * @name Phaser.Cache.BaseCache#entries - * @type {Phaser.Structs.Map.} - * @since 3.0.0 - */ - this.entries = new CustomMap(); - - /** - * An instance of EventEmitter used by the cache to emit related events. - * - * @name Phaser.Cache.BaseCache#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events = new EventEmitter(); - }, - - /** - * Cache add event. - * - * This event is fired by the Cache each time a new object is added to it. - * - * @event Phaser.Cache.BaseCache#addEvent - * @param {Phaser.Cache.BaseCache} cache - The BaseCache to which the object was added. - * @param {string} key - The key of the object added to the cache. - * @param {*} object - A reference to the object added to the cache. - */ - - /** - * Adds an item to this cache. The item is referenced by a unique string, which you are responsible - * for setting and keeping track of. The item can only be retrieved by using this string. - * - * @method Phaser.Cache.BaseCache#add - * @fires Phaser.Cache.BaseCache#addEvent - * @since 3.0.0 - * - * @param {string} key - The unique key by which the data added to the cache will be referenced. - * @param {*} data - The data to be stored in the cache. - * - * @return {Phaser.Cache.BaseCache} This BaseCache object. - */ - add: function (key, data) - { - this.entries.set(key, data); - - this.events.emit('add', this, key, data); - - return this; - }, - - /** - * Checks if this cache contains an item matching the given key. - * This performs the same action as `BaseCache.exists`. - * - * @method Phaser.Cache.BaseCache#has - * @since 3.0.0 - * - * @param {string} key - The unique key of the item to be checked in this cache. - * - * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. - */ - has: function (key) - { - return this.entries.has(key); - }, - - /** - * Checks if this cache contains an item matching the given key. - * This performs the same action as `BaseCache.has` and is called directly by the Loader. - * - * @method Phaser.Cache.BaseCache#exists - * @since 3.7.0 - * - * @param {string} key - The unique key of the item to be checked in this cache. - * - * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. - */ - exists: function (key) - { - return this.entries.has(key); - }, - - /** - * Gets an item from this cache based on the given key. - * - * @method Phaser.Cache.BaseCache#get - * @since 3.0.0 - * - * @param {string} key - The unique key of the item to be retrieved from this cache. - * - * @return {*} The item in the cache, or `null` if no item matching the given key was found. - */ - get: function (key) - { - return this.entries.get(key); - }, - - /** - * Cache remove event. - * - * This event is fired by the Cache each time an object is removed from it. - * - * @event Phaser.Cache.BaseCache#removeEvent - * @param {Phaser.Cache.BaseCache} cache - The BaseCache from which the object was removed. - * @param {string} key - The key of the object removed from the cache. - * @param {*} object - The object that was removed from the cache. - */ - - /** - * Removes and item from this cache based on the given key. - * - * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. - * No additional checks are done on the item removed. If other systems or parts of your game code - * are relying on this item, it is up to you to sever those relationships prior to removing the item. - * - * @method Phaser.Cache.BaseCache#remove - * @fires Phaser.Cache.BaseCache#removeEvent - * @since 3.0.0 - * - * @param {string} key - The unique key of the item to remove from the cache. - * - * @return {Phaser.Cache.BaseCache} This BaseCache object. - */ - remove: function (key) - { - var entry = this.get(key); - - if (entry) - { - this.entries.delete(key); - - this.events.emit('remove', this, key, entry.data); - } - - return this; - }, - - /** - * Destroys this cache and all items within it. - * - * @method Phaser.Cache.BaseCache#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.entries.clear(); - this.events.removeAllListeners(); - - this.entries = null; - this.events = null; - } - -}); - -module.exports = BaseCache; - - -/***/ }), -/* 207 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Animation = __webpack_require__(210); -var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(124); -var EventEmitter = __webpack_require__(9); -var GetValue = __webpack_require__(4); -var Pad = __webpack_require__(133); - -/** - * @typedef {object} JSONAnimationManager - * - * @property {JSONAnimation[]} anims - [description] - * @property {number} globalTimeScale - [description] - */ - -/** - * @classdesc - * The Animation Manager. - * - * Animations are managed by the global Animation Manager. This is a singleton class that is - * responsible for creating and delivering animations and their corresponding data to all Game Objects. - * Unlike plugins it is owned by the Game instance, not the Scene. - * - * Sprites and other Game Objects get the data they need from the AnimationManager. - * - * @class AnimationManager - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Animations - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - */ -var AnimationManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function AnimationManager (game) - { - EventEmitter.call(this); - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#game - * @type {Phaser.Game} - * @protected - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#textureManager - * @type {Phaser.Textures.TextureManager} - * @protected - * @since 3.0.0 - */ - this.textureManager = null; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#globalTimeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.globalTimeScale = 1; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#anims - * @type {Phaser.Structs.Map.} - * @protected - * @since 3.0.0 - */ - this.anims = new CustomMap(); - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * [description] - * - * @name Phaser.Animations.AnimationManager#name - * @type {string} - * @since 3.0.0 - */ - this.name = 'AnimationManager'; - - game.events.once('boot', this.boot, this); - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#boot - * @since 3.0.0 - */ - boot: function () - { - this.textureManager = this.game.textures; - - this.game.events.once('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#add - * @fires AddAnimationEvent - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.Animations.Animation} animation - [description] - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - add: function (key, animation) - { - if (this.anims.has(key)) - { - console.warn('Animation with key', key, 'already exists'); - return; - } - - animation.key = key; - - this.anims.set(key, animation); - - this.emit('add', key, animation); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#create - * @fires AddAnimationEvent - * @since 3.0.0 - * - * @param {AnimationConfig} config - [description] - * - * @return {Phaser.Animations.Animation} The Animation that was created. - */ - create: function (config) - { - var key = config.key; - - if (!key || this.anims.has(key)) - { - console.warn('Invalid Animation Key, or Key already in use: ' + key); - return; - } - - var anim = new Animation(this, key, config); - - this.anims.set(key, anim); - - this.emit('add', key, anim); - - return anim; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#fromJSON - * @since 3.0.0 - * - * @param {(string|JSONAnimationManager|JSONAnimation)} data - [description] - * @param {boolean} [clearCurrentAnimations=false] - [description] - * - * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. - */ - fromJSON: function (data, clearCurrentAnimations) - { - if (clearCurrentAnimations === undefined) { clearCurrentAnimations = false; } - - if (clearCurrentAnimations) - { - this.anims.clear(); - } - - // Do we have a String (i.e. from JSON, or an Object?) - if (typeof data === 'string') - { - data = JSON.parse(data); - } - - var output = []; - - // Array of animations, or a single animation? - if (data.hasOwnProperty('anims') && Array.isArray(data.anims)) - { - for (var i = 0; i < data.anims.length; i++) - { - output.push(this.create(data.anims[i])); - } - - if (data.hasOwnProperty('globalTimeScale')) - { - this.globalTimeScale = data.globalTimeScale; - } - } - else if (data.hasOwnProperty('key') && data.type === 'frame') - { - output.push(this.create(data)); - } - - return output; - }, - - /** - * @typedef {object} GenerateFrameNamesConfig - * - * @property {string} [prefix=''] - [description] - * @property {integer} [start=0] - [description] - * @property {integer} [end=0] - [description] - * @property {string} [suffix=''] - [description] - * @property {integer} [zeroPad=0] - [description] - * @property {AnimationFrameConfig[]} [outputArray=[]] - [description] - * @property {boolean} [frames=false] - [description] - */ - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#generateFrameNames - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {GenerateFrameNamesConfig} [config] - [description] - * - * @return {AnimationFrameConfig[]} [description] - */ - generateFrameNames: function (key, config) - { - var prefix = GetValue(config, 'prefix', ''); - var start = GetValue(config, 'start', 0); - var end = GetValue(config, 'end', 0); - var suffix = GetValue(config, 'suffix', ''); - var zeroPad = GetValue(config, 'zeroPad', 0); - var out = GetValue(config, 'outputArray', []); - var frames = GetValue(config, 'frames', false); - - var texture = this.textureManager.get(key); - - if (!texture) - { - return out; - } - - var diff = (start < end) ? 1 : -1; - - // Adjust because we use i !== end in the for loop - end += diff; - - var i; - var frame; - - if (!config) - { - // Use every frame in the atlas? - frames = texture.getFrameNames(); - - for (i = 0; i < frames.length; i++) - { - out.push({ key: key, frame: frames[i] }); - } - } - else if (Array.isArray(frames)) - { - // Have they provided their own custom frame sequence array? - for (i = 0; i < frames.length; i++) - { - frame = prefix + Pad(frames[i], zeroPad, '0', 1) + suffix; - - if (texture.has(frame)) - { - out.push({ key: key, frame: frame }); - } - } - } - else - { - for (i = start; i !== end; i += diff) - { - frame = prefix + Pad(i, zeroPad, '0', 1) + suffix; - - if (texture.has(frame)) - { - out.push({ key: key, frame: frame }); - } - } - } - - return out; - }, - - /** - * @typedef {object} GenerateFrameNumbersConfig - * - * @property {integer} [start=0] - [description] - * @property {integer} [end=-1] - [description] - * @property {boolean} [first=false] - [description] - * @property {AnimationFrameConfig[]} [outputArray=[]] - [description] - * @property {boolean} [frames=false] - [description] - */ - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#generateFrameNumbers - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {GenerateFrameNumbersConfig} config - [description] - * - * @return {AnimationFrameConfig[]} [description] - */ - generateFrameNumbers: function (key, config) - { - var startFrame = GetValue(config, 'start', 0); - var endFrame = GetValue(config, 'end', -1); - var firstFrame = GetValue(config, 'first', false); - var out = GetValue(config, 'outputArray', []); - var frames = GetValue(config, 'frames', false); - - var texture = this.textureManager.get(key); - - if (!texture) - { - return out; - } - - if (firstFrame && texture.has(firstFrame)) - { - out.push({ key: key, frame: firstFrame }); - } - - var i; - - // Have they provided their own custom frame sequence array? - if (Array.isArray(frames)) - { - for (i = 0; i < frames.length; i++) - { - if (texture.has(frames[i])) - { - out.push({ key: key, frame: frames[i] }); - } - } - } - else - { - // No endFrame then see if we can get it - if (endFrame === -1) - { - endFrame = texture.frameTotal; - } - - for (i = startFrame; i <= endFrame; i++) - { - if (texture.has(i)) - { - out.push({ key: key, frame: i }); - } - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#get - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Animations.Animation} [description] - */ - get: function (key) - { - return this.anims.get(key); - }, - - /** - * Load an Animation into a Game Objects Animation Component. - * - * @method Phaser.Animations.AnimationManager#load - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {string} key - [description] - * @param {(string|integer)} [startFrame] - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - load: function (child, key, startFrame) - { - var anim = this.get(key); - - if (anim) - { - anim.load(child, startFrame); - } - - return child; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#pauseAll - * @fires PauseAllAnimationEvent - * @since 3.0.0 - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - pauseAll: function () - { - if (!this.paused) - { - this.paused = true; - - this.emit('pauseall'); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#play - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {Phaser.GameObjects.GameObject} child - [description] - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - play: function (key, child) - { - if (!Array.isArray(child)) - { - child = [ child ]; - } - - var anim = this.get(key); - - if (!anim) - { - return; - } - - for (var i = 0; i < child.length; i++) - { - child[i].anims.play(key); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#remove - * @fires RemoveAnimationEvent - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {Phaser.Animations.Animation} [description] - */ - remove: function (key) - { - var anim = this.get(key); - - if (anim) - { - this.emit('remove', key, anim); - - this.anims.delete(key); - } - - return anim; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#resumeAll - * @fires ResumeAllAnimationEvent - * @since 3.0.0 - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - resumeAll: function () - { - if (this.paused) - { - this.paused = false; - - this.emit('resumeall'); - } - - return this; - }, - - /** - * Takes an array of Game Objects that have the Animation Component and then - * starts the given animation playing on them, each one offset by the - * `stagger` amount given to this method. - * - * @method Phaser.Animations.AnimationManager#staggerPlay - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] - * - * @param {string} key - The key of the animation to play on the Game Objects. - * @param {Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have the Animation Component. - * @param {number} [stagger=0] - The amount of time, in milliseconds, to offset each play time by. - * - * @return {Phaser.Animations.AnimationManager} This Animation Manager. - */ - staggerPlay: function (key, children, stagger) - { - if (stagger === undefined) { stagger = 0; } - - if (!Array.isArray(children)) - { - children = [ children ]; - } - - var anim = this.get(key); - - if (!anim) - { - return; - } - - for (var i = 0; i < children.length; i++) - { - children[i].anims.delayedPlay(stagger * i, key); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#toJSON - * @since 3.0.0 - * - * @param {string} key - [description] - * - * @return {JSONAnimationManager} [description] - */ - toJSON: function (key) - { - if (key !== undefined && key !== '') - { - return this.anims.get(key).toJSON(); - } - else - { - var output = { - anims: [], - globalTimeScale: this.globalTimeScale - }; - - this.anims.each(function (animationKey, animation) - { - output.anims.push(animation.toJSON()); - }); - - return output; - } - }, - - /** - * [description] - * - * @method Phaser.Animations.AnimationManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.anims.clear(); - - this.textureManager = null; - - this.game = null; - } - -}); - -module.exports = AnimationManager; - - -/***/ }), -/* 208 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @typedef {object} JSONAnimationFrame - * - * @property {string} key - The key of the Texture this AnimationFrame uses. - * @property {(string|integer)} frame - The key of the Frame within the Texture that this AnimationFrame uses. - * @property {number} duration - Additional time (in ms) that this frame should appear for during playback. - */ - -/** - * @classdesc - * A single frame in an Animation sequence. - * - * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other - * frames in the animation, and index data. It also has the ability to fire its own `onUpdate` callback - * and modify the animation timing. - * - * AnimationFrames are generated automatically by the Animation class. - * - * @class AnimationFrame - * @memberOf Phaser.Animations - * @constructor - * @since 3.0.0 - * - * @param {string} textureKey - The key of the Texture this AnimationFrame uses. - * @param {(string|integer)} textureFrame - The key of the Frame within the Texture that this AnimationFrame uses. - * @param {integer} index - The index of this AnimationFrame within the Animation sequence. - * @param {Phaser.Textures.Frame} frame - A reference to the Texture Frame this AnimationFrame uses for rendering. - */ -var AnimationFrame = new Class({ - - initialize: - - function AnimationFrame (textureKey, textureFrame, index, frame) - { - /** - * The key of the Texture this AnimationFrame uses. - * - * @name Phaser.Animations.AnimationFrame#textureKey - * @type {string} - * @since 3.0.0 - */ - this.textureKey = textureKey; - - /** - * The key of the Frame within the Texture that this AnimationFrame uses. - * - * @name Phaser.Animations.AnimationFrame#textureFrame - * @type {(string|integer)} - * @since 3.0.0 - */ - this.textureFrame = textureFrame; - - /** - * The index of this AnimationFrame within the Animation sequence. - * - * @name Phaser.Animations.AnimationFrame#index - * @type {integer} - * @since 3.0.0 - */ - this.index = index; - - /** - * A reference to the Texture Frame this AnimationFrame uses for rendering. - * - * @name Phaser.Animations.AnimationFrame#frame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - this.frame = frame; - - /** - * Is this the first frame in an animation sequence? - * - * @name Phaser.Animations.AnimationFrame#isFirst - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isFirst = false; - - /** - * Is this the last frame in an animation sequence? - * - * @name Phaser.Animations.AnimationFrame#isLast - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isLast = false; - - /** - * A reference to the AnimationFrame that comes before this one in the animation, if any. - * - * @name Phaser.Animations.AnimationFrame#prevFrame - * @type {?Phaser.Animations.AnimationFrame} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.prevFrame = null; - - /** - * A reference to the AnimationFrame that comes after this one in the animation, if any. - * - * @name Phaser.Animations.AnimationFrame#nextFrame - * @type {?Phaser.Animations.AnimationFrame} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.nextFrame = null; - - /** - * Additional time (in ms) that this frame should appear for during playback. - * The value is added onto the msPerFrame set by the animation. - * - * @name Phaser.Animations.AnimationFrame#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * What % through the animation does this frame come? - * This value is generated when the animation is created and cached here. - * - * @name Phaser.Animations.AnimationFrame#progress - * @type {number} - * @default 0 - * @readOnly - * @since 3.0.0 - */ - this.progress = 0; - }, - - /** - * Generates a JavaScript object suitable for converting to JSON. - * - * @method Phaser.Animations.AnimationFrame#toJSON - * @since 3.0.0 - * - * @return {JSONAnimationFrame} The AnimationFrame data. - */ - toJSON: function () - { - return { - key: this.textureKey, - frame: this.textureFrame, - duration: this.duration - }; - }, - - /** - * Destroys this object by removing references to external resources and callbacks. - * - * @method Phaser.Animations.AnimationFrame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.frame = undefined; - } - -}); - -module.exports = AnimationFrame; - - -/***/ }), -/* 209 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Utils.Array.FindClosestInSorted - * @since 3.0.0 - * - * @param {number} value - The value to search for in the array. - * @param {array} array - The array to search, which must be sorted. - * @param {string} [key] - An optional property key. If specified the array elements property will be checked against value. - * - * @return {number|object} The nearest value found in the array, or if a `key` was given, the nearest object with the matching property value. - */ -var FindClosestInSorted = function (value, array, key) -{ - if (!array.length) - { - return NaN; - } - else if (array.length === 1) - { - return array[0]; - } - - var i = 1; - var low; - var high; - - if (key) - { - if (value < array[0][key]) - { - return array[0]; - } - - while (array[i][key] < value) - { - i++; - } - } - else - { - while (array[i] < value) - { - i++; - } - } - - if (i > array.length) - { - i = array.length; - } - - if (key) - { - low = array[i - 1][key]; - high = array[i][key]; - - return ((high - value) <= (value - low)) ? array[i] : array[i - 1]; - } - else - { - low = array[i - 1]; - high = array[i]; - - return ((high - value) <= (value - low)) ? high : low; - } -}; - -module.exports = FindClosestInSorted; - - -/***/ }), -/* 210 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); -var FindClosestInSorted = __webpack_require__(209); -var Frame = __webpack_require__(208); -var GetValue = __webpack_require__(4); - -/** - * @typedef {object} JSONAnimation - * - * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) - * @property {string} type - A frame based animation (as opposed to a bone based animation) - * @property {JSONAnimationFrame[]} frames - [description] - * @property {integer} frameRate - The frame rate of playback in frames per second (default 24 if duration is null) - * @property {integer} duration - How long the animation should play for in milliseconds. If not given its derived from frameRate. - * @property {boolean} skipMissedFrames - Skip frames if the time lags, or always advanced anyway? - * @property {integer} delay - Delay before starting playback. Value given in milliseconds. - * @property {integer} repeat - Number of times to repeat the animation (-1 for infinity) - * @property {integer} repeatDelay - Delay before the animation repeats. Value given in milliseconds. - * @property {boolean} yoyo - Should the animation yoyo? (reverse back down to the start) before repeating? - * @property {boolean} showOnStart - Should sprite.visible = true when the animation starts to play? - * @property {boolean} hideOnComplete - Should sprite.visible = false when the animation finishes? - */ - -/** - * @typedef {object} AnimationFrameConfig - * - * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) - * @property {(string|number)} frame - [description] - * @property {float} [duration=0] - [description] - * @property {boolean} [visible] - [description] - */ - -/** - * @typedef {object} AnimationConfig - * - * @property {string} [key] - The key that the animation will be associated with. i.e. sprite.animations.play(key) - * @property {AnimationFrameConfig[]} [frames] - An object containing data used to generate the frames for the animation - * @property {string} [defaultTextureKey=null] - The key of the texture all frames of the animation will use. Can be overridden on a per frame basis. - * @property {integer} [frameRate] - The frame rate of playback in frames per second (default 24 if duration is null) - * @property {integer} [duration] - How long the animation should play for in milliseconds. If not given its derived from frameRate. - * @property {boolean} [skipMissedFrames=true] - Skip frames if the time lags, or always advanced anyway? - * @property {integer} [delay=0] - Delay before starting playback. Value given in milliseconds. - * @property {integer} [repeat=0] - Number of times to repeat the animation (-1 for infinity) - * @property {integer} [repeatDelay=0] - Delay before the animation repeats. Value given in milliseconds. - * @property {boolean} [yoyo=false] - Should the animation yoyo? (reverse back down to the start) before repeating? - * @property {boolean} [showOnStart=false] - Should sprite.visible = true when the animation starts to play? - * @property {boolean} [hideOnComplete=false] - Should sprite.visible = false when the animation finishes? - */ - -/** - * @classdesc - * A Frame based Animation. - * - * This consists of a key, some default values (like the frame rate) and a bunch of Frame objects. - * - * The Animation Manager creates these. Game Objects don't own an instance of these directly. - * Game Objects have the Animation Component, which are like playheads to global Animations (these objects) - * So multiple Game Objects can have playheads all pointing to this one Animation instance. - * - * @class Animation - * @memberOf Phaser.Animations - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Animations.AnimationManager} manager - [description] - * @param {string} key - [description] - * @param {AnimationConfig} config - [description] - */ -var Animation = new Class({ - - initialize: - - function Animation (manager, key, config) - { - /** - * A reference to the global Animation Manager - * - * @name Phaser.Animations.Animation#manager - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.manager = manager; - - /** - * The unique identifying string for this animation - * - * @name Phaser.Animations.Animation#key - * @type {string} - * @since 3.0.0 - */ - this.key = key; - - /** - * A frame based animation (as opposed to a bone based animation) - * - * @name Phaser.Animations.Animation#type - * @type {string} - * @default frame - * @since 3.0.0 - */ - this.type = 'frame'; - - /** - * Extract all the frame data into the frames array - * - * @name Phaser.Animations.Animation#frames - * @type {Phaser.Animations.AnimationFrame[]} - * @since 3.0.0 - */ - this.frames = this.getFrames( - manager.textureManager, - GetValue(config, 'frames', []), - GetValue(config, 'defaultTextureKey', null) - ); - - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - * - * @name Phaser.Animations.Animation#frameRate - * @type {integer} - * @default 24 - * @since 3.0.0 - */ - this.frameRate = GetValue(config, 'frameRate', null); - - /** - * How long the animation should play for, in milliseconds. - * If the `frameRate` property has been set then it overrides this value, - * otherwise the `frameRate` is derived from `duration`. - * - * @name Phaser.Animations.Animation#duration - * @type {integer} - * @since 3.0.0 - */ - this.duration = GetValue(config, 'duration', null); - - if (this.duration === null && this.frameRate === null) - { - // No duration or frameRate given, use default frameRate of 24fps - this.frameRate = 24; - this.duration = (this.frameRate / this.frames.length) * 1000; - } - else if (this.duration && this.frameRate === null) - { - // Duration given but no frameRate, so set the frameRate based on duration - // I.e. 12 frames in the animation, duration = 4000 ms - // So frameRate is 12 / (4000 / 1000) = 3 fps - this.frameRate = this.frames.length / (this.duration / 1000); - } - else - { - // frameRate given, derive duration from it (even if duration also specified) - // I.e. 15 frames in the animation, frameRate = 30 fps - // So duration is 15 / 30 = 0.5 * 1000 (half a second, or 500ms) - this.duration = (this.frames.length / this.frameRate) * 1000; - } - - /** - * How many ms per frame, not including frame specific modifiers. - * - * @name Phaser.Animations.Animation#msPerFrame - * @type {integer} - * @since 3.0.0 - */ - this.msPerFrame = 1000 / this.frameRate; - - /** - * Skip frames if the time lags, or always advanced anyway? - * - * @name Phaser.Animations.Animation#skipMissedFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true); - - /** - * The delay in ms before the playback will begin. - * - * @name Phaser.Animations.Animation#delay - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.delay = GetValue(config, 'delay', 0); - - /** - * Number of times to repeat the animation. Set to -1 to repeat forever. - * - * @name Phaser.Animations.Animation#repeat - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.repeat = GetValue(config, 'repeat', 0); - - /** - * The delay in ms before the a repeat playthrough starts. - * - * @name Phaser.Animations.Animation#repeatDelay - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.repeatDelay = GetValue(config, 'repeatDelay', 0); - - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - * - * @name Phaser.Animations.Animation#yoyo - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.yoyo = GetValue(config, 'yoyo', false); - - /** - * Should sprite.visible = true when the animation starts to play? - * - * @name Phaser.Animations.Animation#showOnStart - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.showOnStart = GetValue(config, 'showOnStart', false); - - /** - * Should sprite.visible = false when the animation finishes? - * - * @name Phaser.Animations.Animation#hideOnComplete - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.hideOnComplete = GetValue(config, 'hideOnComplete', false); - - /** - * Global pause. All Game Objects using this Animation instance are impacted by this property. - * - * @name Phaser.Animations.Animation#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - this.manager.on('pauseall', this.pause, this); - this.manager.on('resumeall', this.resume, this); - }, - - /** - * Add frames to the end of the animation. - * - * @method Phaser.Animations.Animation#addFrame - * @since 3.0.0 - * - * @param {(string|AnimationFrameConfig[])} config - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - addFrame: function (config) - { - return this.addFrameAt(this.frames.length, config); - }, - - /** - * Add frame/s into the animation. - * - * @method Phaser.Animations.Animation#addFrameAt - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {(string|AnimationFrameConfig[])} config - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - addFrameAt: function (index, config) - { - var newFrames = this.getFrames(this.manager.textureManager, config); - - if (newFrames.length > 0) - { - if (index === 0) - { - this.frames = newFrames.concat(this.frames); - } - else if (index === this.frames.length) - { - this.frames = this.frames.concat(newFrames); - } - else - { - var pre = this.frames.slice(0, index); - var post = this.frames.slice(index); - - this.frames = pre.concat(newFrames, post); - } - - this.updateFrameSequence(); - } - - return this; - }, - - /** - * Check if the given frame index is valid. - * - * @method Phaser.Animations.Animation#checkFrame - * @since 3.0.0 - * - * @param {integer} index - The index to be checked. - * - * @return {boolean} `true` if the index is valid, otherwise `false`. - */ - checkFrame: function (index) - { - return (index >= 0 && index < this.frames.length); - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#completeAnimation - * @protected - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - completeAnimation: function (component) - { - if (this.hideOnComplete) - { - component.parent.visible = false; - } - - component.stop(); - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getFirstTick - * @protected - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - * @param {boolean} [includeDelay=true] - [description] - */ - getFirstTick: function (component, includeDelay) - { - if (includeDelay === undefined) { includeDelay = true; } - - // When is the first update due? - component.accumulator = 0; - component.nextTick = component.msPerFrame + component.currentFrame.duration; - - if (includeDelay) - { - component.nextTick += component._delay; - } - }, - - /** - * Returns the AnimationFrame at the provided index - * - * @method Phaser.Animations.Animation#getFrameAt - * @protected - * @since 3.0.0 - * - * @param {integer} index - The index in the AnimationFrame array - * - * @return {Phaser.Animations.AnimationFrame} The frame at the index provided from the animation sequence - */ - getFrameAt: function (index) - { - return this.frames[index]; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getFrames - * @since 3.0.0 - * - * @param {Phaser.Textures.TextureManager} textureManager - [description] - * @param {(string|AnimationFrameConfig[])} frames - [description] - * @param {string} [defaultTextureKey] - [description] - * - * @return {Phaser.Animations.AnimationFrame[]} [description] - */ - getFrames: function (textureManager, frames, defaultTextureKey) - { - var out = []; - var prev; - var animationFrame; - var index = 1; - var i; - var textureKey; - - // if frames is a string, we'll get all the frames from the texture manager as if it's a sprite sheet - if (typeof frames === 'string') - { - textureKey = frames; - - var texture = textureManager.get(textureKey); - var frameKeys = texture.getFrameNames(); - - frames = []; - - frameKeys.forEach(function (idx, value) - { - frames.push({ key: textureKey, frame: value }); - }); - } - - if (!Array.isArray(frames) || frames.length === 0) - { - return out; - } - - for (i = 0; i < frames.length; i++) - { - var item = frames[i]; - - var key = GetValue(item, 'key', defaultTextureKey); - - if (!key) - { - continue; - } - - // Could be an integer or a string - var frame = GetValue(item, 'frame', 0); - - // The actual texture frame - var textureFrame = textureManager.getFrame(key, frame); - - animationFrame = new Frame(key, frame, index, textureFrame); - - animationFrame.duration = GetValue(item, 'duration', 0); - - animationFrame.isFirst = (!prev); - - // The previously created animationFrame - if (prev) - { - prev.nextFrame = animationFrame; - - animationFrame.prevFrame = prev; - } - - out.push(animationFrame); - - prev = animationFrame; - - index++; - } - - if (out.length > 0) - { - animationFrame.isLast = true; - - // Link them end-to-end, so they loop - animationFrame.nextFrame = out[0]; - - out[0].prevFrame = animationFrame; - - // Generate the progress data - - var slice = 1 / (out.length - 1); - - for (i = 0; i < out.length; i++) - { - out[i].progress = i * slice; - } - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#getNextTick - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - getNextTick: function (component) - { - // accumulator += delta * _timeScale - // after a large delta surge (perf issue for example) we need to adjust for it here - - // When is the next update due? - component.accumulator -= component.nextTick; - - component.nextTick = component.msPerFrame + component.currentFrame.duration; - }, - - /** - * Loads the Animation values into the Animation Component. - * - * @method Phaser.Animations.Animation#load - * @private - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component to load values into. - * @param {integer} startFrame - The start frame of the animation to load. - */ - load: function (component, startFrame) - { - if (startFrame >= this.frames.length) - { - startFrame = 0; - } - - if (component.currentAnim !== this) - { - component.currentAnim = this; - - component.frameRate = this.frameRate; - component.duration = this.duration; - component.msPerFrame = this.msPerFrame; - component.skipMissedFrames = this.skipMissedFrames; - - component._timeScale = 1; - component._delay = this.delay; - component._repeat = this.repeat; - component._repeatDelay = this.repeatDelay; - component._yoyo = this.yoyo; - } - - component.updateFrame(this.frames[startFrame]); - }, - - /** - * Returns the frame closest to the given progress value between 0 and 1. - * - * @method Phaser.Animations.Animation#getFrameByProgress - * @since 3.4.0 - * - * @param {float} value - A value between 0 and 1. - * - * @return {Phaser.Animations.AnimationFrame} The frame closest to the given progress value. - */ - getFrameByProgress: function (value) - { - value = Clamp(value, 0, 1); - - return FindClosestInSorted(value, this.frames, 'progress'); - }, - - /** - * Advance the animation frame. - * - * @method Phaser.Animations.Animation#nextFrame - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component to advance. - */ - nextFrame: function (component) - { - var frame = component.currentFrame; - - // TODO: Add frame skip support - - if (frame.isLast) - { - // We're at the end of the animation - - // Yoyo? (happens before repeat) - if (component._yoyo) - { - component.forward = false; - - component.updateFrame(frame.prevFrame); - - // Delay for the current frame - this.getNextTick(component); - } - else if (component.repeatCounter > 0) - { - // Repeat (happens before complete) - this.repeatAnimation(component); - } - else - { - this.completeAnimation(component); - } - } - else - { - component.updateFrame(frame.nextFrame); - - this.getNextTick(component); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#previousFrame - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - previousFrame: function (component) - { - var frame = component.currentFrame; - - // TODO: Add frame skip support - - if (frame.isFirst) - { - // We're at the start of the animation - - if (component.repeatCounter > 0) - { - // Repeat (happens before complete) - this.repeatAnimation(component); - } - else - { - this.completeAnimation(component); - } - } - else - { - component.updateFrame(frame.prevFrame); - - this.getNextTick(component); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#removeFrame - * @since 3.0.0 - * - * @param {Phaser.Animations.AnimationFrame} frame - [description] - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - removeFrame: function (frame) - { - var index = this.frames.indexOf(frame); - - if (index !== -1) - { - this.removeFrameAt(index); - } - - return this; - }, - - /** - * Removes a frame from the AnimationFrame array at the provided index - * and updates the animation accordingly. - * - * @method Phaser.Animations.Animation#removeFrameAt - * @since 3.0.0 - * - * @param {integer} index - The index in the AnimationFrame array - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - removeFrameAt: function (index) - { - this.frames.splice(index, 1); - - this.updateFrameSequence(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#repeatAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - repeatAnimation: function (component) - { - if (component._pendingStop === 2) - { - return this.completeAnimation(component); - } - - if (component._repeatDelay > 0 && component.pendingRepeat === false) - { - component.pendingRepeat = true; - component.accumulator -= component.nextTick; - component.nextTick += component._repeatDelay; - } - else - { - component.repeatCounter--; - - component.forward = true; - - component.updateFrame(component.currentFrame.nextFrame); - - if (component.isPlaying) - { - this.getNextTick(component); - - component.pendingRepeat = false; - - component.parent.emit('animationrepeat', this, component.currentFrame, component.repeatCounter); - } - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#setFrame - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.Animation} component - [description] - */ - setFrame: function (component) - { - // Work out which frame should be set next on the child, and set it - if (component.forward) - { - this.nextFrame(component); - } - else - { - this.previousFrame(component); - } - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#toJSON - * @since 3.0.0 - * - * @return {JSONAnimation} [description] - */ - toJSON: function () - { - var output = { - key: this.key, - type: this.type, - frames: [], - frameRate: this.frameRate, - duration: this.duration, - skipMissedFrames: this.skipMissedFrames, - delay: this.delay, - repeat: this.repeat, - repeatDelay: this.repeatDelay, - yoyo: this.yoyo, - showOnStart: this.showOnStart, - hideOnComplete: this.hideOnComplete - }; - - this.frames.forEach(function (frame) - { - output.frames.push(frame.toJSON()); - }); - - return output; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#updateFrameSequence - * @since 3.0.0 - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - updateFrameSequence: function () - { - var len = this.frames.length; - var slice = 1 / (len - 1); - - for (var i = 0; i < len; i++) - { - var frame = this.frames[i]; - - frame.index = i + 1; - frame.isFirst = false; - frame.isLast = false; - frame.progress = i * slice; - - if (i === 0) - { - frame.isFirst = true; - frame.isLast = (len === 1); - frame.prevFrame = this.frames[len - 1]; - frame.nextFrame = this.frames[i + 1]; - } - else if (i === len - 1) - { - frame.isLast = true; - frame.prevFrame = this.frames[len - 2]; - frame.nextFrame = this.frames[0]; - } - else if (len > 1) - { - frame.prevFrame = this.frames[i - 1]; - frame.nextFrame = this.frames[i + 1]; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#pause - * @since 3.0.0 - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - pause: function () - { - this.paused = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#resume - * @since 3.0.0 - * - * @return {Phaser.Animations.Animation} This Animation object. - */ - resume: function () - { - this.paused = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Animations.Animation#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.manager.off('pauseall', this.pause, this); - this.manager.off('resumeall', this.resume, this); - - this.manager.remove(this.key); - - for (var i = 0; i < this.frames.length; i++) - { - this.frames[i].destroy(); - } - - this.frames = []; - - this.manager = null; - } - -}); - -module.exports = Animation; - - -/***/ }), -/* 211 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Wrap = __webpack_require__(39); - -/** - * Wrap an angle in degrees. - * - * Wraps the angle to a value in the range of -180 to 180. - * - * @function Phaser.Math.Angle.WrapDegrees - * @since 3.0.0 - * - * @param {number} angle - The angle to wrap, in degrees. - * - * @return {number} The wrapped angle, in degrees. - */ -var WrapDegrees = function (angle) -{ - return Wrap(angle, -180, 180); -}; - -module.exports = WrapDegrees; - - -/***/ }), -/* 212 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MathWrap = __webpack_require__(39); - -/** - * Wrap an angle. - * - * Wraps the angle to a value in the range of -PI to PI. - * - * @function Phaser.Math.Angle.Wrap - * @since 3.0.0 - * - * @param {number} angle - The angle to wrap, in radians. - * - * @return {number} The wrapped angle, in radians. - */ -var Wrap = function (angle) -{ - return MathWrap(angle, -Math.PI, Math.PI); -}; - -module.exports = Wrap; - - -/***/ }), -/* 213 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class GeometryMask - * @memberOf Phaser.Display.Masks - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] - */ -var GeometryMask = new Class({ - - initialize: - - function GeometryMask (scene, graphicsGeometry) - { - /** - * [description] - * - * @name Phaser.Display.Masks.GeometryMask#geometryMask - * @type {Phaser.GameObjects.Graphics} - * @since 3.0.0 - */ - this.geometryMask = graphicsGeometry; - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#setShape - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] - */ - setShape: function (graphicsGeometry) - { - this.geometryMask = graphicsGeometry; - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderWebGL: function (renderer, mask, camera) - { - var gl = renderer.gl; - var geometryMask = this.geometryMask; - - // Force flushing before drawing to stencil buffer - renderer.flush(); - - // Enable and setup GL state to write to stencil buffer - gl.enable(gl.STENCIL_TEST); - gl.clear(gl.STENCIL_BUFFER_BIT); - gl.colorMask(false, false, false, false); - gl.stencilFunc(gl.NOTEQUAL, 1, 1); - gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE); - - // Write stencil buffer - geometryMask.renderWebGL(renderer, geometryMask, 0.0, camera); - renderer.flush(); - - // Use stencil buffer to affect next rendering object - gl.colorMask(true, true, true, true); - gl.stencilFunc(gl.EQUAL, 1, 1); - gl.stencilOp(gl.INVERT, gl.INVERT, gl.INVERT); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - */ - postRenderWebGL: function (renderer) - { - var gl = renderer.gl; - - // Force flush before disabling stencil test - renderer.flush(); - gl.disable(gl.STENCIL_TEST); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderCanvas: function (renderer, mask, camera) - { - var geometryMask = this.geometryMask; - - renderer.currentContext.save(); - - geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, undefined, null, true); - - renderer.currentContext.clip(); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - */ - postRenderCanvas: function (renderer) - { - renderer.currentContext.restore(); - }, - - /** - * Destroys this GeometryMask and nulls any references it holds. - * - * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, - * so be sure to call `clearMask` on any Game Object using it, before destroying it. - * - * @method Phaser.Display.Masks.GeometryMask#destroy - * @since 3.7.0 - */ - destroy: function () - { - this.geometryMask = null; - } - -}); - -module.exports = GeometryMask; - - -/***/ }), -/* 214 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class BitmapMask - * @memberOf Phaser.Display.Masks - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. - */ -var BitmapMask = new Class({ - - initialize: - - function BitmapMask (scene, renderable) - { - var renderer = scene.sys.game.renderer; - - /** - * A renderable Game Object that uses a texture, such as a Sprite. - * - * @name Phaser.Display.Masks.BitmapMask#bitmapMask - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.bitmapMask = renderable; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#maskTexture - * @type {WebGLTexture} - * @default null - * @since 3.0.0 - */ - this.maskTexture = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#mainTexture - * @type {WebGLTexture} - * @default null - * @since 3.0.0 - */ - this.mainTexture = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#dirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.dirty = true; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#mainFramebuffer - * @type {WebGLFramebuffer} - * @since 3.0.0 - */ - this.mainFramebuffer = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#maskFramebuffer - * @type {WebGLFramebuffer} - * @since 3.0.0 - */ - this.maskFramebuffer = null; - - /** - * [description] - * - * @name Phaser.Display.Masks.BitmapMask#invertAlpha - * @type {boolean} - * @since 3.1.2 - */ - this.invertAlpha = false; - - if (renderer && renderer.gl) - { - var width = renderer.width; - var height = renderer.height; - var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); - var gl = renderer.gl; - var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; - var filter = gl.LINEAR; - - this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); - this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); - - renderer.onContextRestored(function (renderer) - { - var width = renderer.width; - var height = renderer.height; - var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); - var gl = renderer.gl; - var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; - var filter = gl.LINEAR; - - this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); - this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); - - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#setBitmap - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. - */ - setBitmap: function (renderable) - { - this.bitmapMask = renderable; - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#preRenderWebGL - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} maskedObject - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. - */ - preRenderWebGL: function (renderer, maskedObject, camera) - { - renderer.pipelines.BitmapMaskPipeline.beginMask(this, maskedObject, camera); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#postRenderWebGL - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - */ - postRenderWebGL: function (renderer) - { - renderer.pipelines.BitmapMaskPipeline.endMask(this); - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#preRenderCanvas - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. - */ - preRenderCanvas: function () - { - // NOOP - }, - - /** - * [description] - * - * @method Phaser.Display.Masks.BitmapMask#postRenderCanvas - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - */ - postRenderCanvas: function () - { - // NOOP - }, - - /** - * Destroys this BitmapMask and nulls any references it holds. - * - * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, - * so be sure to call `clearMask` on any Game Object using it, before destroying it. - * - * @method Phaser.Display.Masks.BitmapMask#destroy - * @since 3.7.0 - */ - destroy: function () - { - this.bitmapMask = null; - this.mainTexture = null; - this.maskTexture = null; - this.mainFramebuffer = null; - this.maskFramebuffer = null; - } - -}); - -module.exports = BitmapMask; - - -/***/ }), -/* 215 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1, eval)("this"); -} catch (e) { - // This works if the window reference is available - if (typeof window === "object") g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }), -/* 216 */, -/* 217 */, -/* 218 */, -/* 219 */, -/* 220 */, -/* 221 */, -/* 222 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var quickselect = __webpack_require__(180); - -/** - * @classdesc - * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. - * It's based on an optimized R-tree data structure with bulk insertion support. - * - * Spatial index is a special data structure for points and rectangles that allows you to perform queries like - * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). - * - * This version of RBush uses a fixed min/max accessor structure of `[ '.left', '.top', '.right', '.bottom' ]`. - * This is to avoid the eval like function creation that the original library used, which caused CSP policy violations. - * - * @class RTree - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - */ - -function rbush (maxEntries) -{ - var format = [ '.left', '.top', '.right', '.bottom' ]; - - if (!(this instanceof rbush)) return new rbush(maxEntries, format); - - // max entries in a node is 9 by default; min node fill is 40% for best performance - this._maxEntries = Math.max(4, maxEntries || 9); - this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); - - this.clear(); -} - -rbush.prototype = { - - all: function () - { - return this._all(this.data, []); - }, - - search: function (bbox) - { - var node = this.data, - result = [], - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return result; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf) result.push(child); - else if (contains(bbox, childBBox)) this._all(child, result); - else nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return result; - }, - - collides: function (bbox) - { - var node = this.data, - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return false; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf || contains(bbox, childBBox)) return true; - nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return false; - }, - - load: function (data) - { - if (!(data && data.length)) return this; - - if (data.length < this._minEntries) { - for (var i = 0, len = data.length; i < len; i++) { - this.insert(data[i]); - } - return this; - } - - // recursively build the tree with the given data from scratch using OMT algorithm - var node = this._build(data.slice(), 0, data.length - 1, 0); - - if (!this.data.children.length) { - // save as is if tree is empty - this.data = node; - - } else if (this.data.height === node.height) { - // split root if trees have the same height - this._splitRoot(this.data, node); - - } else { - if (this.data.height < node.height) { - // swap trees if inserted one is bigger - var tmpNode = this.data; - this.data = node; - node = tmpNode; - } - - // insert the small tree into the large tree at appropriate level - this._insert(node, this.data.height - node.height - 1, true); - } - - return this; - }, - - insert: function (item) - { - if (item) this._insert(item, this.data.height - 1); - return this; - }, - - clear: function () - { - this.data = createNode([]); - return this; - }, - - remove: function (item, equalsFn) - { - if (!item) return this; - - var node = this.data, - bbox = this.toBBox(item), - path = [], - indexes = [], - i, parent, index, goingUp; - - // depth-first iterative tree traversal - while (node || path.length) { - - if (!node) { // go up - node = path.pop(); - parent = path[path.length - 1]; - i = indexes.pop(); - goingUp = true; - } - - if (node.leaf) { // check current node - index = findItem(item, node.children, equalsFn); - - if (index !== -1) { - // item found, remove the item and condense tree upwards - node.children.splice(index, 1); - path.push(node); - this._condense(path); - return this; - } - } - - if (!goingUp && !node.leaf && contains(node, bbox)) { // go down - path.push(node); - indexes.push(i); - i = 0; - parent = node; - node = node.children[0]; - - } else if (parent) { // go right - i++; - node = parent.children[i]; - goingUp = false; - - } else node = null; // nothing found - } - - return this; - }, - - toBBox: function (item) { return item; }, - - compareMinX: compareNodeMinX, - compareMinY: compareNodeMinY, - - toJSON: function () { return this.data; }, - - fromJSON: function (data) - { - this.data = data; - return this; - }, - - _all: function (node, result) - { - var nodesToSearch = []; - while (node) { - if (node.leaf) result.push.apply(result, node.children); - else nodesToSearch.push.apply(nodesToSearch, node.children); - - node = nodesToSearch.pop(); - } - return result; - }, - - _build: function (items, left, right, height) - { - var N = right - left + 1, - M = this._maxEntries, - node; - - if (N <= M) { - // reached leaf level; return leaf - node = createNode(items.slice(left, right + 1)); - calcBBox(node, this.toBBox); - return node; - } - - if (!height) { - // target height of the bulk-loaded tree - height = Math.ceil(Math.log(N) / Math.log(M)); - - // target number of root entries to maximize storage utilization - M = Math.ceil(N / Math.pow(M, height - 1)); - } - - node = createNode([]); - node.leaf = false; - node.height = height; - - // split the items into M mostly square tiles - - var N2 = Math.ceil(N / M), - N1 = N2 * Math.ceil(Math.sqrt(M)), - i, j, right2, right3; - - multiSelect(items, left, right, N1, this.compareMinX); - - for (i = left; i <= right; i += N1) { - - right2 = Math.min(i + N1 - 1, right); - - multiSelect(items, i, right2, N2, this.compareMinY); - - for (j = i; j <= right2; j += N2) { - - right3 = Math.min(j + N2 - 1, right2); - - // pack each entry recursively - node.children.push(this._build(items, j, right3, height - 1)); - } - } - - calcBBox(node, this.toBBox); - - return node; - }, - - _chooseSubtree: function (bbox, node, level, path) - { - var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; - - while (true) { - path.push(node); - - if (node.leaf || path.length - 1 === level) break; - - minArea = minEnlargement = Infinity; - - for (i = 0, len = node.children.length; i < len; i++) { - child = node.children[i]; - area = bboxArea(child); - enlargement = enlargedArea(bbox, child) - area; - - // choose entry with the least area enlargement - if (enlargement < minEnlargement) { - minEnlargement = enlargement; - minArea = area < minArea ? area : minArea; - targetNode = child; - - } else if (enlargement === minEnlargement) { - // otherwise choose one with the smallest area - if (area < minArea) { - minArea = area; - targetNode = child; - } - } - } - - node = targetNode || node.children[0]; - } - - return node; - }, - - _insert: function (item, level, isNode) - { - var toBBox = this.toBBox, - bbox = isNode ? item : toBBox(item), - insertPath = []; - - // find the best node for accommodating the item, saving all nodes along the path too - var node = this._chooseSubtree(bbox, this.data, level, insertPath); - - // put the item into the node - node.children.push(item); - extend(node, bbox); - - // split on node overflow; propagate upwards if necessary - while (level >= 0) { - if (insertPath[level].children.length > this._maxEntries) { - this._split(insertPath, level); - level--; - } else break; - } - - // adjust bboxes along the insertion path - this._adjustParentBBoxes(bbox, insertPath, level); - }, - - // split overflowed node into two - _split: function (insertPath, level) - { - var node = insertPath[level], - M = node.children.length, - m = this._minEntries; - - this._chooseSplitAxis(node, m, M); - - var splitIndex = this._chooseSplitIndex(node, m, M); - - var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); - newNode.height = node.height; - newNode.leaf = node.leaf; - - calcBBox(node, this.toBBox); - calcBBox(newNode, this.toBBox); - - if (level) insertPath[level - 1].children.push(newNode); - else this._splitRoot(node, newNode); - }, - - _splitRoot: function (node, newNode) - { - // split root node - this.data = createNode([node, newNode]); - this.data.height = node.height + 1; - this.data.leaf = false; - calcBBox(this.data, this.toBBox); - }, - - _chooseSplitIndex: function (node, m, M) - { - var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; - - minOverlap = minArea = Infinity; - - for (i = m; i <= M - m; i++) { - bbox1 = distBBox(node, 0, i, this.toBBox); - bbox2 = distBBox(node, i, M, this.toBBox); - - overlap = intersectionArea(bbox1, bbox2); - area = bboxArea(bbox1) + bboxArea(bbox2); - - // choose distribution with minimum overlap - if (overlap < minOverlap) { - minOverlap = overlap; - index = i; - - minArea = area < minArea ? area : minArea; - - } else if (overlap === minOverlap) { - // otherwise choose distribution with minimum area - if (area < minArea) { - minArea = area; - index = i; - } - } - } - - return index; - }, - - // sorts node children by the best axis for split - _chooseSplitAxis: function (node, m, M) - { - var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, - compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, - xMargin = this._allDistMargin(node, m, M, compareMinX), - yMargin = this._allDistMargin(node, m, M, compareMinY); - - // if total distributions margin value is minimal for x, sort by minX, - // otherwise it's already sorted by minY - if (xMargin < yMargin) node.children.sort(compareMinX); - }, - - // total margin of all possible split distributions where each node is at least m full - _allDistMargin: function (node, m, M, compare) - { - node.children.sort(compare); - - var toBBox = this.toBBox, - leftBBox = distBBox(node, 0, m, toBBox), - rightBBox = distBBox(node, M - m, M, toBBox), - margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), - i, child; - - for (i = m; i < M - m; i++) { - child = node.children[i]; - extend(leftBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(leftBBox); - } - - for (i = M - m - 1; i >= m; i--) { - child = node.children[i]; - extend(rightBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(rightBBox); - } - - return margin; - }, - - _adjustParentBBoxes: function (bbox, path, level) - { - // adjust bboxes along the given tree path - for (var i = level; i >= 0; i--) { - extend(path[i], bbox); - } - }, - - _condense: function (path) - { - // go through the path, removing empty nodes and updating bboxes - for (var i = path.length - 1, siblings; i >= 0; i--) { - if (path[i].children.length === 0) { - if (i > 0) { - siblings = path[i - 1].children; - siblings.splice(siblings.indexOf(path[i]), 1); - - } else this.clear(); - - } else calcBBox(path[i], this.toBBox); - } - }, - - compareMinX: function (a, b) - { - return a.left - b.left; - }, - - compareMinY: function (a, b) - { - return a.top - b.top; - }, - - toBBox: function (a) - { - return { - minX: a.left, - minY: a.top, - maxX: a.right, - maxY: a.bottom - }; - } -}; - -function findItem (item, items, equalsFn) -{ - if (!equalsFn) return items.indexOf(item); - - for (var i = 0; i < items.length; i++) { - if (equalsFn(item, items[i])) return i; - } - return -1; -} - -// calculate node's bbox from bboxes of its children -function calcBBox (node, toBBox) -{ - distBBox(node, 0, node.children.length, toBBox, node); -} - -// min bounding rectangle of node children from k to p-1 -function distBBox (node, k, p, toBBox, destNode) -{ - if (!destNode) destNode = createNode(null); - destNode.minX = Infinity; - destNode.minY = Infinity; - destNode.maxX = -Infinity; - destNode.maxY = -Infinity; - - for (var i = k, child; i < p; i++) { - child = node.children[i]; - extend(destNode, node.leaf ? toBBox(child) : child); - } - - return destNode; -} - -function extend (a, b) -{ - a.minX = Math.min(a.minX, b.minX); - a.minY = Math.min(a.minY, b.minY); - a.maxX = Math.max(a.maxX, b.maxX); - a.maxY = Math.max(a.maxY, b.maxY); - return a; -} - -function compareNodeMinX (a, b) { return a.minX - b.minX; } -function compareNodeMinY (a, b) { return a.minY - b.minY; } - -function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } -function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } - -function enlargedArea (a, b) -{ - return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * - (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); -} - -function intersectionArea (a, b) -{ - var minX = Math.max(a.minX, b.minX), - minY = Math.max(a.minY, b.minY), - maxX = Math.min(a.maxX, b.maxX), - maxY = Math.min(a.maxY, b.maxY); - - return Math.max(0, maxX - minX) * - Math.max(0, maxY - minY); -} - -function contains (a, b) -{ - return a.minX <= b.minX && - a.minY <= b.minY && - b.maxX <= a.maxX && - b.maxY <= a.maxY; -} - -function intersects (a, b) -{ - return b.minX <= a.maxX && - b.minY <= a.maxY && - b.maxX >= a.minX && - b.maxY >= a.minY; -} - -function createNode (children) -{ - return { - children: children, - height: 1, - leaf: true, - minX: Infinity, - minY: Infinity, - maxX: -Infinity, - maxY: -Infinity - }; -} - -// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; -// combines selection algorithm with binary divide & conquer approach - -function multiSelect (arr, left, right, n, compare) -{ - var stack = [left, right], - mid; - - while (stack.length) - { - right = stack.pop(); - left = stack.pop(); - - if (right - left <= n) continue; - - mid = left + Math.ceil((right - left) / n / 2) * n; - quickselect(arr, mid, left, right, compare); - - stack.push(left, mid, mid, right); - } -} - -module.exports = rbush; - -/***/ }), -/* 223 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class ProcessQueue - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic T - */ -var ProcessQueue = new Class({ - - initialize: - - function ProcessQueue () - { - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.ProcessQueue#_pending - * @type {Array.<*>} - * @private - * @default [] - * @since 3.0.0 - */ - this._pending = []; - - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.ProcessQueue#_active - * @type {Array.<*>} - * @private - * @default [] - * @since 3.0.0 - */ - this._active = []; - - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.ProcessQueue#_destroy - * @type {Array.<*>} - * @private - * @default [] - * @since 3.0.0 - */ - this._destroy = []; - - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_toProcess - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#add - * @since 3.0.0 - * - * @genericUse {T} - [item] - * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] - * - * @param {*} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - add: function (item) - { - this._pending.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#remove - * @since 3.0.0 - * - * @genericUse {T} - [item] - * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] - * - * @param {*} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - remove: function (item) - { - this._destroy.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#update - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @return {Array.<*>} [description] - */ - update: function () - { - if (this._toProcess === 0) - { - // Quick bail - return this._active; - } - - var list = this._destroy; - var active = this._active; - var i; - var item; - - // Clear the 'destroy' list - for (i = 0; i < list.length; i++) - { - item = list[i]; - - // Remove from the 'active' array - var idx = active.indexOf(item); - - if (idx !== -1) - { - active.splice(idx, 1); - } - } - - list.length = 0; - - // Process the pending addition list - // This stops callbacks and out of sync events from populating the active array mid-way during an update - - list = this._pending; - - for (i = 0; i < list.length; i++) - { - item = list[i]; - - this._active.push(item); - } - - list.length = 0; - - this._toProcess = 0; - - // The owner of this queue can now safely do whatever it needs to with the active list - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#getActive - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @return {Array.<*>} [description] - */ - getActive: function () - { - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#destroy - * @since 3.0.0 - */ - destroy: function () - { - this._pending = []; - this._active = []; - this._destroy = []; - } - -}); - -module.exports = ProcessQueue; - - -/***/ }), -/* 224 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.TextFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='txt'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Text File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. - * - * @class TextFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var TextFile = new Class({ - - Extends: File, - - initialize: - - function TextFile (loader, key, url, xhrSettings) - { - var extension = 'txt'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'text', - cache: loader.cacheManager.text, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.TextFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onProcessComplete(); - } - -}); - -/** - * Adds a Text file, or array of Text files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.text('story', files/IntroStory.txt'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Text Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Text Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.text({ - * key: 'story', - * url: 'files/IntroStory.txt' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.image('story', 'files/IntroStory.txt'); - * // and later in your game ... - * var data = this.cache.text.get('story'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Text Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" - * and no URL is given then the Loader will set the URL to be "story.txt". It will always add `.txt` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Text File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#text - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.TextFileConfig|Phaser.Loader.FileTypes.TextFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('text', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TextFile(this, key[i])); - } - } - else - { - this.addFile(new TextFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = TextFile; - - -/***/ }), -/* 225 */, -/* 226 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(71); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {integer} quantity - [description] - * @param {number} stepRate - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ -var GetPoints = function (triangle, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = perimeter / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var p = perimeter * (i / quantity); - var localPosition = 0; - - var point = new Point(); - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - out.push(point); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 227 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var Length = __webpack_require__(71); - -// Position is a value between 0 and 1 -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetPoint = function (triangle, position, out) -{ - if (out === undefined) { out = new Point(); } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - if (position <= 0 || position >= 1) - { - out.x = line1.x1; - out.y = line1.y1; - - return out; - } - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - var p = perimeter * position; - var localPosition = 0; - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - return out; -}; - -module.exports = GetPoint; - - -/***/ }), -/* 228 */, -/* 229 */, -/* 230 */, -/* 231 */, -/* 232 */, -/* 233 */, -/* 234 */, -/* 235 */, -/* 236 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Stepped - */ - -module.exports = __webpack_require__(421); - - -/***/ }), -/* 237 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Sine - */ - -module.exports = { - - In: __webpack_require__(424), - Out: __webpack_require__(423), - InOut: __webpack_require__(422) - -}; - - -/***/ }), -/* 238 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Quintic - */ - -module.exports = { - - In: __webpack_require__(427), - Out: __webpack_require__(426), - InOut: __webpack_require__(425) - -}; - - -/***/ }), -/* 239 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Quartic - */ - -module.exports = { - - In: __webpack_require__(430), - Out: __webpack_require__(429), - InOut: __webpack_require__(428) - -}; - - -/***/ }), -/* 240 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Quadratic - */ - -module.exports = { - - In: __webpack_require__(433), - Out: __webpack_require__(432), - InOut: __webpack_require__(431) - -}; - - -/***/ }), -/* 241 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Linear - */ - -module.exports = __webpack_require__(434); - - -/***/ }), -/* 242 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Expo - */ - -module.exports = { - - In: __webpack_require__(437), - Out: __webpack_require__(436), - InOut: __webpack_require__(435) - -}; - - -/***/ }), -/* 243 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Elastic - */ - -module.exports = { - - In: __webpack_require__(440), - Out: __webpack_require__(439), - InOut: __webpack_require__(438) - -}; - - -/***/ }), -/* 244 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Cubic - */ - -module.exports = { - - In: __webpack_require__(443), - Out: __webpack_require__(442), - InOut: __webpack_require__(441) - -}; - - -/***/ }), -/* 245 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Circular - */ - -module.exports = { - - In: __webpack_require__(446), - Out: __webpack_require__(445), - InOut: __webpack_require__(444) - -}; - - -/***/ }), -/* 246 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Bounce - */ - -module.exports = { - - In: __webpack_require__(449), - Out: __webpack_require__(448), - InOut: __webpack_require__(447) - -}; - - -/***/ }), -/* 247 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Back - */ - -module.exports = { - - In: __webpack_require__(452), - Out: __webpack_require__(451), - InOut: __webpack_require__(450) - -}; - - -/***/ }), -/* 248 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Generate a random floating point number between the two given bounds, minimum inclusive, maximum exclusive. - * - * @function Phaser.Math.FloatBetween - * @since 3.0.0 - * - * @param {float} min - The lower bound for the float, inclusive. - * @param {float} max - The upper bound for the float exclusive. - * - * @return {float} A random float within the given range. - */ -var FloatBetween = function (min, max) -{ - return Math.random() * (max - min) + min; -}; - -module.exports = FloatBetween; - - -/***/ }), -/* 249 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Ellipse = __webpack_require__(114); - -Ellipse.Area = __webpack_require__(472); -Ellipse.Circumference = __webpack_require__(177); -Ellipse.CircumferencePoint = __webpack_require__(113); -Ellipse.Clone = __webpack_require__(471); -Ellipse.Contains = __webpack_require__(54); -Ellipse.ContainsPoint = __webpack_require__(470); -Ellipse.ContainsRect = __webpack_require__(469); -Ellipse.CopyFrom = __webpack_require__(468); -Ellipse.Equals = __webpack_require__(467); -Ellipse.GetBounds = __webpack_require__(466); -Ellipse.GetPoint = __webpack_require__(179); -Ellipse.GetPoints = __webpack_require__(178); -Ellipse.Offset = __webpack_require__(465); -Ellipse.OffsetPoint = __webpack_require__(464); -Ellipse.Random = __webpack_require__(134); - -module.exports = Ellipse; - - -/***/ }), -/* 250 */, -/* 251 */, -/* 252 */, -/* 253 */, -/* 254 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); -var Shuffle = __webpack_require__(95); - -var BuildChunk = function (a, b, qty) -{ - var out = []; - - for (var aIndex = 0; aIndex < a.length; aIndex++) - { - for (var bIndex = 0; bIndex < b.length; bIndex++) - { - for (var i = 0; i < qty; i++) - { - out.push({ a: a[aIndex], b: b[bIndex] }); - } - } - } - - return out; -}; - -// options = repeat, random, randomB, yoyo, max, qty - -// Range ([a,b,c], [1,2,3]) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2,3], qty = 3) = -// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 - -// Range ([a,b,c], [1,2,3], repeat x1) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = -// Maybe if max is set then repeat goes to -1 automatically? -// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) - -// Range ([a], [1,2,3,4,5], random = true) = -// a4, a1, a5, a2, a3 - -// Range ([a, b], [1,2,3], random = true) = -// b3, a2, a1, b1, a3, b2 - -// Range ([a, b, c], [1,2,3], randomB = true) = -// a3, a1, a2, b2, b3, b1, c1, c3, c2 - -// Range ([a], [1,2,3,4,5], yoyo = true) = -// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 - -// Range ([a, b], [1,2,3], yoyo = true) = -// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 - -/** - * [description] - * - * @function Phaser.Utils.Array.Range - * @since 3.0.0 - * - * @param {array} a - [description] - * @param {array} b - [description] - * @param {object} options - [description] - * - * @return {array} [description] - */ -var Range = function (a, b, options) -{ - var max = GetValue(options, 'max', 0); - var qty = GetValue(options, 'qty', 1); - var random = GetValue(options, 'random', false); - var randomB = GetValue(options, 'randomB', false); - var repeat = GetValue(options, 'repeat', 0); - var yoyo = GetValue(options, 'yoyo', false); - - var out = []; - - if (randomB) - { - Shuffle(b); - } - - // Endless repeat, so limit by max - if (repeat === -1) - { - if (max === 0) - { - repeat = 0; - } - else - { - // Work out how many repeats we need - var total = (a.length * b.length) * qty; - - if (yoyo) - { - total *= 2; - } - - repeat = Math.ceil(max / total); - } - } - - for (var i = 0; i <= repeat; i++) - { - var chunk = BuildChunk(a, b, qty); - - if (random) - { - Shuffle(chunk); - } - - out = out.concat(chunk); - - if (yoyo) - { - chunk.reverse(); - - out = out.concat(chunk); - } - } - - if (max) - { - out.splice(max); - } - - return out; -}; - -module.exports = Range; - - -/***/ }), -/* 255 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Round a given number so it is further away from zero. That is, positive numbers are rounded up, and negative numbers are rounded down. - * - * @function Phaser.Math.RoundAwayFromZero - * @since 3.0.0 - * - * @param {number} value - The number to round. - * - * @return {number} The rounded number, rounded away from zero. - */ -var RoundAwayFromZero = function (value) -{ - // "Opposite" of truncate. - return (value > 0) ? Math.ceil(value) : Math.floor(value); -}; - -module.exports = RoundAwayFromZero; - - -/***/ }), -/* 256 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Capitalizes the first letter of a string if there is one. - * @example - * UppercaseFirst('abc'); - * // returns 'Abc' - * @example - * UppercaseFirst('the happy family'); - * // returns 'The happy family' - * @example - * UppercaseFirst(''); - * // returns '' - * - * @function Phaser.Utils.String.UppercaseFirst - * @since 3.0.0 - * - * @param {string} str - The string to capitalize. - * - * @return {string} A new string, same as the first, but with the first letter capitalized. - */ -var UppercaseFirst = function (str) -{ - return str && str[0].toUpperCase() + str.slice(1); -}; - -module.exports = UppercaseFirst; - - -/***/ }), -/* 257 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Vector2 = __webpack_require__(6); - -/** - * Takes the `x` and `y` coordinates and transforms them into the same space as - * defined by the position, rotation and scale values. - * - * @function Phaser.Math.TransformXY - * @since 3.0.0 - * - * @param {number} x - The x coordinate to be transformed. - * @param {number} y - The y coordinate to be transformed. - * @param {number} positionX - Horizontal position of the transform point. - * @param {number} positionY - Vertical position of the transform point. - * @param {number} rotation - Rotation of the transform point, in radians. - * @param {number} scaleX - Horizontal scale of the transform point. - * @param {number} scaleY - Vertical scale of the transform point. - * @param {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} [output] - The output vector, point or object for the translated coordinates. - * - * @return {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} The translated point. - */ -var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) -{ - if (output === undefined) { output = new Vector2(); } - - // ITRS - - var sr = Math.sin(-rotation); - var cr = Math.cos(-rotation); - - var a = cr * scaleX; - var b = -sr * scaleX; - var c = sr * scaleY; - var d = cr * scaleY; - - // Invert - - var n = a * d - b * c; - - var m0 = d / n; - var m1 = -b / n; - var m2 = -c / n; - var m3 = a / n; - var m4 = (c * positionY - d * positionX) / n; - var m5 = -(a * positionY - b * positionX) / n; - - // Transform - - output.x = x * m0 + y * m2 + m4; - output.y = x * m1 + y * m3 + m5; - - return output; -}; - -module.exports = TransformXY; - - -/***/ }), -/* 258 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// 2.1.1 (Mar 17, 2016) - -/* -ISC License - -Copyright (c) 2016, Mapbox - -Permission to use, copy, modify, and/or distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright notice -and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - */ - - - -module.exports = earcut; - -/* -vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. -holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). -dimensions is the number of coordinates per vertice in the input array (2 by default). -Each group of three vertice indices in the resulting array forms a triangle. - */ - -function earcut(data, holeIndices, dim) { - - dim = dim || 2; - - var hasHoles = holeIndices && holeIndices.length, - outerLen = hasHoles ? holeIndices[0] * dim : data.length, - outerNode = linkedList(data, 0, outerLen, dim, true), - triangles = []; - - if (!outerNode) return triangles; - - var minX, minY, maxX, maxY, x, y, size; - - if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); - - // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox - if (data.length > 80 * dim) { - minX = maxX = data[0]; - minY = maxY = data[1]; - - for (var i = dim; i < outerLen; i += dim) { - x = data[i]; - y = data[i + 1]; - if (x < minX) minX = x; - if (y < minY) minY = y; - if (x > maxX) maxX = x; - if (y > maxY) maxY = y; - } - - // minX, minY and size are later used to transform coords into integers for z-order calculation - size = Math.max(maxX - minX, maxY - minY); - } - - earcutLinked(outerNode, triangles, dim, minX, minY, size); - - return triangles; -} - -// create a circular doubly linked list from polygon points in the specified winding order -function linkedList(data, start, end, dim, clockwise) { - var i, last; - - if (clockwise === (signedArea(data, start, end, dim) > 0)) { - for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); - } else { - for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); - } - - if (last && equals(last, last.next)) { - removeNode(last); - last = last.next; - } - - return last; -} - -// eliminate colinear or duplicate points -function filterPoints(start, end) { - if (!start) return start; - if (!end) end = start; - - var p = start, - again; - do { - again = false; - - if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { - removeNode(p); - p = end = p.prev; - if (p === p.next) return null; - again = true; - - } else { - p = p.next; - } - } while (again || p !== end); - - return end; -} - -// main ear slicing loop which triangulates a polygon (given as a linked list) -function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { - if (!ear) return; - - // interlink polygon nodes in z-order - if (!pass && size) indexCurve(ear, minX, minY, size); - - var stop = ear, - prev, next; - - // iterate through ears, slicing them one by one - while (ear.prev !== ear.next) { - prev = ear.prev; - next = ear.next; - - if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { - // cut off the triangle - triangles.push(prev.i / dim); - triangles.push(ear.i / dim); - triangles.push(next.i / dim); - - removeNode(ear); - - // skipping the next vertice leads to less sliver triangles - ear = next.next; - stop = next.next; - - continue; - } - - ear = next; - - // if we looped through the whole remaining polygon and can't find any more ears - if (ear === stop) { - // try filtering points and slicing again - if (!pass) { - earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); - - // if this didn't work, try curing all small self-intersections locally - } else if (pass === 1) { - ear = cureLocalIntersections(ear, triangles, dim); - earcutLinked(ear, triangles, dim, minX, minY, size, 2); - - // as a last resort, try splitting the remaining polygon into two - } else if (pass === 2) { - splitEarcut(ear, triangles, dim, minX, minY, size); - } - - break; - } - } -} - -// check whether a polygon node forms a valid ear with adjacent nodes -function isEar(ear) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // now make sure we don't have other points inside the potential ear - var p = ear.next.next; - - while (p !== ear.prev) { - if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.next; - } - - return true; -} - -function isEarHashed(ear, minX, minY, size) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // triangle bbox; min & max are calculated like this for speed - var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), - minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), - maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), - maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); - - // z-order range for the current triangle bbox; - var minZ = zOrder(minTX, minTY, minX, minY, size), - maxZ = zOrder(maxTX, maxTY, minX, minY, size); - - // first look for points inside the triangle in increasing z-order - var p = ear.nextZ; - - while (p && p.z <= maxZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.nextZ; - } - - // then look for points in decreasing z-order - p = ear.prevZ; - - while (p && p.z >= minZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.prevZ; - } - - return true; -} - -// go through all polygon nodes and cure small local self-intersections -function cureLocalIntersections(start, triangles, dim) { - var p = start; - do { - var a = p.prev, - b = p.next.next; - - if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { - - triangles.push(a.i / dim); - triangles.push(p.i / dim); - triangles.push(b.i / dim); - - // remove two nodes involved - removeNode(p); - removeNode(p.next); - - p = start = b; - } - p = p.next; - } while (p !== start); - - return p; -} - -// try splitting polygon into two and triangulate them independently -function splitEarcut(start, triangles, dim, minX, minY, size) { - // look for a valid diagonal that divides the polygon into two - var a = start; - do { - var b = a.next.next; - while (b !== a.prev) { - if (a.i !== b.i && isValidDiagonal(a, b)) { - // split the polygon in two by the diagonal - var c = splitPolygon(a, b); - - // filter colinear points around the cuts - a = filterPoints(a, a.next); - c = filterPoints(c, c.next); - - // run earcut on each half - earcutLinked(a, triangles, dim, minX, minY, size); - earcutLinked(c, triangles, dim, minX, minY, size); - return; - } - b = b.next; - } - a = a.next; - } while (a !== start); -} - -// link every hole into the outer loop, producing a single-ring polygon without holes -function eliminateHoles(data, holeIndices, outerNode, dim) { - var queue = [], - i, len, start, end, list; - - for (i = 0, len = holeIndices.length; i < len; i++) { - start = holeIndices[i] * dim; - end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - list = linkedList(data, start, end, dim, false); - if (list === list.next) list.steiner = true; - queue.push(getLeftmost(list)); - } - - queue.sort(compareX); - - // process holes from left to right - for (i = 0; i < queue.length; i++) { - eliminateHole(queue[i], outerNode); - outerNode = filterPoints(outerNode, outerNode.next); - } - - return outerNode; -} - -function compareX(a, b) { - return a.x - b.x; -} - -// find a bridge between vertices that connects hole with an outer ring and and link it -function eliminateHole(hole, outerNode) { - outerNode = findHoleBridge(hole, outerNode); - if (outerNode) { - var b = splitPolygon(outerNode, hole); - filterPoints(b, b.next); - } -} - -// David Eberly's algorithm for finding a bridge between hole and outer polygon -function findHoleBridge(hole, outerNode) { - var p = outerNode, - hx = hole.x, - hy = hole.y, - qx = -Infinity, - m; - - // find a segment intersected by a ray from the hole's leftmost point to the left; - // segment's endpoint with lesser x will be potential connection point - do { - if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { - var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); - if (x <= hx && x > qx) { - qx = x; - if (x === hx) { - if (hy === p.y) return p; - if (hy === p.next.y) return p.next; - } - m = p.x < p.next.x ? p : p.next; - } - } - p = p.next; - } while (p !== outerNode); - - if (!m) return null; - - if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint - - // look for points inside the triangle of hole point, segment intersection and endpoint; - // if there are no points found, we have a valid connection; - // otherwise choose the point of the minimum angle with the ray as connection point - - var stop = m, - mx = m.x, - my = m.y, - tanMin = Infinity, - tan; - - p = m.next; - - while (p !== stop) { - if (hx >= p.x && p.x >= mx && hx !== p.x && - pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { - - tan = Math.abs(hy - p.y) / (hx - p.x); // tangential - - if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { - m = p; - tanMin = tan; - } - } - - p = p.next; - } - - return m; -} - -// interlink polygon nodes in z-order -function indexCurve(start, minX, minY, size) { - var p = start; - do { - if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); - p.prevZ = p.prev; - p.nextZ = p.next; - p = p.next; - } while (p !== start); - - p.prevZ.nextZ = null; - p.prevZ = null; - - sortLinked(p); -} - -// Simon Tatham's linked list merge sort algorithm -// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html -function sortLinked(list) { - var i, p, q, e, tail, numMerges, pSize, qSize, - inSize = 1; - - do { - p = list; - list = null; - tail = null; - numMerges = 0; - - while (p) { - numMerges++; - q = p; - pSize = 0; - for (i = 0; i < inSize; i++) { - pSize++; - q = q.nextZ; - if (!q) break; - } - qSize = inSize; - - while (pSize > 0 || (qSize > 0 && q)) { - - if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { - e = p; - p = p.nextZ; - pSize--; - } else { - e = q; - q = q.nextZ; - qSize--; - } - - if (tail) tail.nextZ = e; - else list = e; - - e.prevZ = tail; - tail = e; - } - - p = q; - } - - tail.nextZ = null; - inSize *= 2; - - } while (numMerges > 1); - - return list; -} - -// z-order of a point given coords and size of the data bounding box -function zOrder(x, y, minX, minY, size) { - // coords are transformed into non-negative 15-bit integer range - x = 32767 * (x - minX) / size; - y = 32767 * (y - minY) / size; - - x = (x | (x << 8)) & 0x00FF00FF; - x = (x | (x << 4)) & 0x0F0F0F0F; - x = (x | (x << 2)) & 0x33333333; - x = (x | (x << 1)) & 0x55555555; - - y = (y | (y << 8)) & 0x00FF00FF; - y = (y | (y << 4)) & 0x0F0F0F0F; - y = (y | (y << 2)) & 0x33333333; - y = (y | (y << 1)) & 0x55555555; - - return x | (y << 1); -} - -// find the leftmost node of a polygon ring -function getLeftmost(start) { - var p = start, - leftmost = start; - do { - if (p.x < leftmost.x) leftmost = p; - p = p.next; - } while (p !== start); - - return leftmost; -} - -// check if a point lies within a convex triangle -function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { - return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && - (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && - (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; -} - -// check if a diagonal between two polygon nodes is valid (lies in polygon interior) -function isValidDiagonal(a, b) { - return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && - locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); -} - -// signed area of a triangle -function area(p, q, r) { - return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); -} - -// check if two points are equal -function equals(p1, p2) { - return p1.x === p2.x && p1.y === p2.y; -} - -// check if two segments intersect -function intersects(p1, q1, p2, q2) { - if ((equals(p1, q1) && equals(p2, q2)) || - (equals(p1, q2) && equals(p2, q1))) return true; - return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && - area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; -} - -// check if a polygon diagonal intersects any polygon segments -function intersectsPolygon(a, b) { - var p = a; - do { - if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && - intersects(p, p.next, a, b)) return true; - p = p.next; - } while (p !== a); - - return false; -} - -// check if a polygon diagonal is locally inside the polygon -function locallyInside(a, b) { - return area(a.prev, a, a.next) < 0 ? - area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : - area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; -} - -// check if the middle point of a polygon diagonal is inside the polygon -function middleInside(a, b) { - var p = a, - inside = false, - px = (a.x + b.x) / 2, - py = (a.y + b.y) / 2; - do { - if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && - (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) - inside = !inside; - p = p.next; - } while (p !== a); - - return inside; -} - -// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; -// if one belongs to the outer ring and another to a hole, it merges it into a single ring -function splitPolygon(a, b) { - var a2 = new Node(a.i, a.x, a.y), - b2 = new Node(b.i, b.x, b.y), - an = a.next, - bp = b.prev; - - a.next = b; - b.prev = a; - - a2.next = an; - an.prev = a2; - - b2.next = a2; - a2.prev = b2; - - bp.next = b2; - b2.prev = bp; - - return b2; -} - -// create a node and optionally link it with previous one (in a circular doubly linked list) -function insertNode(i, x, y, last) { - var p = new Node(i, x, y); - - if (!last) { - p.prev = p; - p.next = p; - - } else { - p.next = last.next; - p.prev = last; - last.next.prev = p; - last.next = p; - } - return p; -} - -function removeNode(p) { - p.next.prev = p.prev; - p.prev.next = p.next; - - if (p.prevZ) p.prevZ.nextZ = p.nextZ; - if (p.nextZ) p.nextZ.prevZ = p.prevZ; -} - -function Node(i, x, y) { - // vertice index in coordinates array - this.i = i; - - // vertex coordinates - this.x = x; - this.y = y; - - // previous and next vertice nodes in a polygon ring - this.prev = null; - this.next = null; - - // z-order curve value - this.z = null; - - // previous and next nodes in z-order - this.prevZ = null; - this.nextZ = null; - - // indicates whether this is a steiner point - this.steiner = false; -} - -// return a percentage difference between the polygon area and its triangulation area; -// used to verify correctness of triangulation -earcut.deviation = function (data, holeIndices, dim, triangles) { - var hasHoles = holeIndices && holeIndices.length; - var outerLen = hasHoles ? holeIndices[0] * dim : data.length; - - var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); - if (hasHoles) { - for (var i = 0, len = holeIndices.length; i < len; i++) { - var start = holeIndices[i] * dim; - var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - polygonArea -= Math.abs(signedArea(data, start, end, dim)); - } - } - - var trianglesArea = 0; - for (i = 0; i < triangles.length; i += 3) { - var a = triangles[i] * dim; - var b = triangles[i + 1] * dim; - var c = triangles[i + 2] * dim; - trianglesArea += Math.abs( - (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - - (data[a] - data[b]) * (data[c + 1] - data[a + 1])); - } - - return polygonArea === 0 && trianglesArea === 0 ? 0 : - Math.abs((trianglesArea - polygonArea) / polygonArea); -}; - -function signedArea(data, start, end, dim) { - var sum = 0; - for (var i = start, j = end - dim; i < end; i += dim) { - sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); - j = i; - } - return sum; -} - -// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts -earcut.flatten = function (data) { - var dim = data[0][0].length, - result = {vertices: [], holes: [], dimensions: dim}, - holeIndex = 0; - - for (var i = 0; i < data.length; i++) { - for (var j = 0; j < data[i].length; j++) { - for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); - } - if (i > 0) { - holeIndex += data[i - 1].length; - result.holes.push(holeIndex); - } - } - return result; -}; - -/***/ }), -/* 259 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Commands = __webpack_require__(119); -var Earcut = __webpack_require__(258); -var ModelViewProjection = __webpack_require__(202); -var ShaderSourceFS = __webpack_require__(529); -var ShaderSourceVS = __webpack_require__(528); -var Utils = __webpack_require__(27); -var WebGLPipeline = __webpack_require__(84); - -var Point = function (x, y, width, rgb, alpha) -{ - this.x = x; - this.y = y; - this.width = width; - this.rgb = rgb; - this.alpha = alpha; -}; - -var Path = function (x, y, width, rgb, alpha) -{ - this.points = []; - this.pointsLength = 1; - this.points[0] = new Point(x, y, width, rgb, alpha); -}; - -var currentMatrix = new Float32Array([ 1, 0, 0, 1, 0, 0 ]); -var matrixStack = new Float32Array(6 * 1000); -var matrixStackLength = 0; -var pathArray = []; - -/** - * @classdesc - * The FlatTintPipeline is used for rendering flat colored shapes. - * Mostly used by the Graphics game object. - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class FlatTintPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. - */ -var FlatTintPipeline = new Class({ - - Extends: WebGLPipeline, - - Mixins: [ - ModelViewProjection - ], - - initialize: - - function FlatTintPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapcity ? config.vertexCapacity : 12000), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2 + - Uint8Array.BYTES_PER_ELEMENT * 4), - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - }, - { - name: 'inTint', - size: 4, - type: config.renderer.gl.UNSIGNED_BYTE, - normalized: true, - offset: Float32Array.BYTES_PER_ELEMENT * 2 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#vertexViewU32 - * @type {Uint32Array} - * @since 3.0.0 - */ - this.vertexViewU32 = new Uint32Array(this.vertexData); - - /** - * Used internally to draw triangles - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#tempTriangle - * @type {array} - * @since 3.0.0 - */ - this.tempTriangle = [ - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0} - ]; - - /** - * Used internally by for triangulating a polyong - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#polygonCache - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.polygonCache = []; - - this.mvpInit(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - this.mvpUpdate(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); - - return this; - }, - - /** - * Pushes a rectangle into the vertex batch - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillRect - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x - Horiztonal top left coordinate of the rectangle - * @param {float} y - Vertical top left coordinate of the rectangle - * @param {float} width - Width of the rectangle - * @param {float} height - Height of the rectangle - * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillRect: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x, y, width, height, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = this.vertexCount * this.vertexComponentCount; - var xw = x + width; - var yh = y + height; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tx0 = x * a + y * c + e; - var ty0 = x * b + y * d + f; - var tx1 = x * a + yh * c + e; - var ty1 = x * b + yh * d + f; - var tx2 = xw * a + yh * c + e; - var ty2 = xw * b + yh * d + f; - var tx3 = xw * a + y * c + e; - var ty3 = xw * b + y * d + f; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - vertexViewF32[vertexOffset + 9] = tx0; - vertexViewF32[vertexOffset + 10] = ty0; - vertexViewU32[vertexOffset + 11] = tint; - vertexViewF32[vertexOffset + 12] = tx2; - vertexViewF32[vertexOffset + 13] = ty2; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx3; - vertexViewF32[vertexOffset + 16] = ty3; - vertexViewU32[vertexOffset + 17] = tint; - - this.vertexCount += 6; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillTriangle - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - Point 0 x coordinate - * @param {float} y0 - Point 0 y coordinate - * @param {float} x1 - Point 1 x coordinate - * @param {float} y1 - Point 1 y coordinate - * @param {float} x2 - Point 2 x coordinate - * @param {float} y2 - Point 2 y coordinate - * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 3 > this.vertexCapacity) - { - this.flush(); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = this.vertexCount * this.vertexComponentCount; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tx0 = x0 * a + y0 * c + e; - var ty0 = x0 * b + y0 * d + f; - var tx1 = x1 * a + y1 * c + e; - var ty1 = x1 * b + y1 * d + f; - var tx2 = x2 * a + y2 * c + e; - var ty2 = x2 * b + y2 * d + f; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - - this.vertexCount += 3; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokeTriangle - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - [description] - * @param {float} y0 - [description] - * @param {float} x1 - [description] - * @param {float} y1 - [description] - * @param {float} x2 - [description] - * @param {float} y2 - [description] - * @param {float} lineWidth - Size of the line as a float value - * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchStrokeTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, currentMatrix) - { - var tempTriangle = this.tempTriangle; - - tempTriangle[0].x = x0; - tempTriangle[0].y = y0; - tempTriangle[0].width = lineWidth; - tempTriangle[0].rgb = lineColor; - tempTriangle[0].alpha = lineAlpha; - tempTriangle[1].x = x1; - tempTriangle[1].y = y1; - tempTriangle[1].width = lineWidth; - tempTriangle[1].rgb = lineColor; - tempTriangle[1].alpha = lineAlpha; - tempTriangle[2].x = x2; - tempTriangle[2].y = y2; - tempTriangle[2].width = lineWidth; - tempTriangle[2].rgb = lineColor; - tempTriangle[2].alpha = lineAlpha; - tempTriangle[3].x = x0; - tempTriangle[3].y = y0; - tempTriangle[3].width = lineWidth; - tempTriangle[3].rgb = lineColor; - tempTriangle[3].alpha = lineAlpha; - - this.batchStrokePath( - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - tempTriangle, lineWidth, lineColor, lineAlpha, - a, b, c, d, e, f, - false, - currentMatrix - ); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillPath - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} path - Collection of points that represent the path - * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillPath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - var length = path.length; - var polygonCache = this.polygonCache; - var polygonIndexArray; - var point; - var v0, v1, v2; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = 0; - var x0, y0, x1, y1, x2, y2; - var tx0, ty0, tx1, ty1, tx2, ty2; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - for (var pathIndex = 0; pathIndex < length; ++pathIndex) - { - point = path[pathIndex]; - polygonCache.push(point.x, point.y); - } - - polygonIndexArray = Earcut(polygonCache); - length = polygonIndexArray.length; - - for (var index = 0; index < length; index += 3) - { - v0 = polygonIndexArray[index + 0] * 2; - v1 = polygonIndexArray[index + 1] * 2; - v2 = polygonIndexArray[index + 2] * 2; - - if (this.vertexCount + 3 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - x0 = polygonCache[v0 + 0]; - y0 = polygonCache[v0 + 1]; - x1 = polygonCache[v1 + 0]; - y1 = polygonCache[v1 + 1]; - x2 = polygonCache[v2 + 0]; - y2 = polygonCache[v2 + 1]; - - tx0 = x0 * a + y0 * c + e; - ty0 = x0 * b + y0 * d + f; - tx1 = x1 * a + y1 * c + e; - ty1 = x1 * b + y1 * d + f; - tx2 = x2 * a + y2 * c + e; - ty2 = x2 * b + y2 * d + f; - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - - this.vertexCount += 3; - } - - polygonCache.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokePath - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {array} path - [description] - * @param {float} lineWidth - [description] - * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component - * @param {boolean} isLastPath - Indicates if the path should be closed - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchStrokePath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, isLastPath, currentMatrix) - { - this.renderer.setPipeline(this); - - var point0, point1; - var pathLength = path.length; - var polylines = this.polygonCache; - var last, curr; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset; - var line; - var getTint = Utils.getTintAppendFloatAlphaAndSwap; - - for (var pathIndex = 0; pathIndex + 1 < pathLength; pathIndex += 1) - { - point0 = path[pathIndex]; - point1 = path[pathIndex + 1]; - - line = this.batchLine( - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - point0.x, point0.y, - point1.x, point1.y, - point0.width / 2, point1.width / 2, - point0.rgb, point1.rgb, lineAlpha, - a, b, c, d, e, f, - currentMatrix - ); - - polylines.push(line); - } - - /* Render joints */ - for (var index = 1, polylinesLength = polylines.length; index < polylinesLength; ++index) - { - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - last = polylines[index - 1] || polylines[polylinesLength - 1]; - curr = polylines[index]; - vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = last[3 * 2 + 0]; - vertexViewF32[vertexOffset + 1] = last[3 * 2 + 1]; - vertexViewU32[vertexOffset + 2] = getTint(last[3 * 2 + 2], lineAlpha); - vertexViewF32[vertexOffset + 3] = last[3 * 0 + 0]; - vertexViewF32[vertexOffset + 4] = last[3 * 0 + 1]; - vertexViewU32[vertexOffset + 5] = getTint(last[3 * 0 + 2], lineAlpha); - vertexViewF32[vertexOffset + 6] = curr[3 * 3 + 0]; - vertexViewF32[vertexOffset + 7] = curr[3 * 3 + 1]; - vertexViewU32[vertexOffset + 8] = getTint(curr[3 * 3 + 2], lineAlpha); - vertexViewF32[vertexOffset + 9] = last[3 * 0 + 0]; - vertexViewF32[vertexOffset + 10] = last[3 * 0 + 1]; - vertexViewU32[vertexOffset + 11] = getTint(last[3 * 0 + 2], lineAlpha); - vertexViewF32[vertexOffset + 12] = last[3 * 2 + 0]; - vertexViewF32[vertexOffset + 13] = last[3 * 2 + 1]; - vertexViewU32[vertexOffset + 14] = getTint(last[3 * 2 + 2], lineAlpha); - vertexViewF32[vertexOffset + 15] = curr[3 * 1 + 0]; - vertexViewF32[vertexOffset + 16] = curr[3 * 1 + 1]; - vertexViewU32[vertexOffset + 17] = getTint(curr[3 * 1 + 2], lineAlpha); - - this.vertexCount += 6; - } - - polylines.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchLine - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} ax - X coordinate to the start of the line - * @param {float} ay - Y coordinate to the start of the line - * @param {float} bx - X coordinate to the end of the line - * @param {float} by - Y coordinate to the end of the line - * @param {float} aLineWidth - Width of the start of the line - * @param {float} bLineWidth - Width of the end of the line - * @param {integer} aLineColor - RGB color packed as a uint - * @param {integer} bLineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchLine: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, ax, ay, bx, by, aLineWidth, bLineWidth, aLineColor, bLineColor, lineAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var dx = bx - ax; - var dy = by - ay; - var len = Math.sqrt(dx * dx + dy * dy); - var al0 = aLineWidth * (by - ay) / len; - var al1 = aLineWidth * (ax - bx) / len; - var bl0 = bLineWidth * (by - ay) / len; - var bl1 = bLineWidth * (ax - bx) / len; - var lx0 = bx - bl0; - var ly0 = by - bl1; - var lx1 = ax - al0; - var ly1 = ay - al1; - var lx2 = bx + bl0; - var ly2 = by + bl1; - var lx3 = ax + al0; - var ly3 = ay + al1; - var x0 = lx0 * a + ly0 * c + e; - var y0 = lx0 * b + ly0 * d + f; - var x1 = lx1 * a + ly1 * c + e; - var y1 = lx1 * b + ly1 * d + f; - var x2 = lx2 * a + ly2 * c + e; - var y2 = lx2 * b + ly2 * d + f; - var x3 = lx3 * a + ly3 * c + e; - var y3 = lx3 * b + ly3 * d + f; - var getTint = Utils.getTintAppendFloatAlphaAndSwap; - var aTint = getTint(aLineColor, lineAlpha); - var bTint = getTint(bLineColor, lineAlpha); - var vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = x0; - vertexViewF32[vertexOffset + 1] = y0; - vertexViewU32[vertexOffset + 2] = bTint; - vertexViewF32[vertexOffset + 3] = x1; - vertexViewF32[vertexOffset + 4] = y1; - vertexViewU32[vertexOffset + 5] = aTint; - vertexViewF32[vertexOffset + 6] = x2; - vertexViewF32[vertexOffset + 7] = y2; - vertexViewU32[vertexOffset + 8] = bTint; - vertexViewF32[vertexOffset + 9] = x1; - vertexViewF32[vertexOffset + 10] = y1; - vertexViewU32[vertexOffset + 11] = aTint; - vertexViewF32[vertexOffset + 12] = x3; - vertexViewF32[vertexOffset + 13] = y3; - vertexViewU32[vertexOffset + 14] = aTint; - vertexViewF32[vertexOffset + 15] = x2; - vertexViewF32[vertexOffset + 16] = y2; - vertexViewU32[vertexOffset + 17] = bTint; - - this.vertexCount += 6; - - return [ - x0, y0, bLineColor, - x1, y1, aLineColor, - x2, y2, bLineColor, - x3, y3, aLineColor - ]; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchGraphics - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchGraphics: function (graphics, camera, parentTransformMatrix) - { - if (graphics.commandBuffer.length <= 0) { return; } - - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var cameraScrollX = camera.scrollX * graphics.scrollFactorX; - var cameraScrollY = camera.scrollY * graphics.scrollFactorY; - var srcX = graphics.x; - var srcY = graphics.y; - var srcScaleX = graphics.scaleX; - var srcScaleY = graphics.scaleY; - var srcRotation = graphics.rotation; - var commands = graphics.commandBuffer; - var alpha = graphics.alpha; - var lineAlpha = 1.0; - var fillAlpha = 1.0; - var lineColor = 0; - var fillColor = 0; - var lineWidth = 1.0; - var cameraMatrix = camera.matrix.matrix; - var lastPath = null; - var iteration = 0; - var iterStep = 0.01; - var tx = 0; - var ty = 0; - var ta = 0; - var x = 0; - var y = 0; - var radius = 0; - var startAngle = 0; - var endAngle = 0; - var anticlockwise = 0; - var path = null; - var sin = Math.sin; - var cos = Math.cos; - var PI2 = Math.PI * 2; - var sr = sin(srcRotation); - var cr = cos(srcRotation); - var sra = cr * srcScaleX; - var srb = sr * srcScaleX; - var src = -sr * srcScaleY; - var srd = cr * srcScaleY; - var sre = srcX; - var srf = srcY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var pathArrayIndex; - var pathArrayLength; - - pathArray.length = 0; - - for (var cmdIndex = 0, cmdLength = commands.length; cmdIndex < cmdLength; ++cmdIndex) - { - cmd = commands[cmdIndex]; - - switch (cmd) - { - case Commands.ARC: - iteration = 0; - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - radius = commands[cmdIndex + 3]; - startAngle = commands[cmdIndex + 4]; - endAngle = commands[cmdIndex + 5]; - anticlockwise = commands[cmdIndex + 6]; - - if (lastPath === null) - { - lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - iteration += iterStep; - } - - endAngle -= startAngle; - - if (anticlockwise) - { - if (endAngle < -PI2) - { - endAngle = -PI2; - } - else if (endAngle > 0) - { - endAngle = -PI2 + endAngle % PI2; - } - } - else if (endAngle > PI2) - { - endAngle = PI2; - } - else if (endAngle < 0) - { - endAngle = PI2 + endAngle % PI2; - } - - while (iteration < 1) - { - ta = endAngle * iteration + startAngle; - tx = x + cos(ta) * radius; - ty = y + sin(ta) * radius; - - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); - - iteration += iterStep; - } - - ta = endAngle + startAngle; - tx = x + cos(ta) * radius; - ty = y + sin(ta) * radius; - - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); - - cmdIndex += 6; - break; - - case Commands.LINE_STYLE: - lineWidth = commands[cmdIndex + 1]; - lineColor = commands[cmdIndex + 2]; - lineAlpha = commands[cmdIndex + 3]; - cmdIndex += 3; - break; - - case Commands.FILL_STYLE: - fillColor = commands[cmdIndex + 1]; - fillAlpha = commands[cmdIndex + 2]; - cmdIndex += 2; - break; - - case Commands.BEGIN_PATH: - pathArray.length = 0; - lastPath = null; - break; - - case Commands.CLOSE_PATH: - if (lastPath && lastPath.points.length) - { - lastPath.points.push(lastPath.points[0]); - } - break; - - case Commands.FILL_PATH: - for (pathArrayIndex = 0, pathArrayLength = pathArray.length; - pathArrayIndex < pathArrayLength; - ++pathArrayIndex) - { - this.batchFillPath( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - pathArray[pathArrayIndex].points, - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - } - break; - - case Commands.STROKE_PATH: - for (pathArrayIndex = 0, pathArrayLength = pathArray.length; - pathArrayIndex < pathArrayLength; - ++pathArrayIndex) - { - path = pathArray[pathArrayIndex]; - this.batchStrokePath( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - path.points, - lineWidth, - lineColor, - lineAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - path === this._lastPath, - currentMatrix - ); - } - break; - - case Commands.FILL_RECT: - this.batchFillRect( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 4; - break; - - case Commands.FILL_TRIANGLE: - this.batchFillTriangle( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Triangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5], - commands[cmdIndex + 6], - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 6; - break; - - case Commands.STROKE_TRIANGLE: - this.batchStrokeTriangle( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Triangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5], - commands[cmdIndex + 6], - lineWidth, - lineColor, - lineAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 6; - break; - - case Commands.LINE_TO: - if (lastPath !== null) - { - lastPath.points.push(new Point(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha)); - } - else - { - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - } - cmdIndex += 2; - break; - - case Commands.MOVE_TO: - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - cmdIndex += 2; - break; - - case Commands.LINE_FX_TO: - if (lastPath !== null) - { - lastPath.points.push(new Point( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - )); - } - else - { - lastPath = new Path( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - ); - pathArray.push(lastPath); - } - cmdIndex += 5; - break; - - case Commands.MOVE_FX_TO: - lastPath = new Path( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - ); - pathArray.push(lastPath); - cmdIndex += 5; - break; - - case Commands.SAVE: - matrixStack[matrixStackLength + 0] = currentMatrix[0]; - matrixStack[matrixStackLength + 1] = currentMatrix[1]; - matrixStack[matrixStackLength + 2] = currentMatrix[2]; - matrixStack[matrixStackLength + 3] = currentMatrix[3]; - matrixStack[matrixStackLength + 4] = currentMatrix[4]; - matrixStack[matrixStackLength + 5] = currentMatrix[5]; - matrixStackLength += 6; - break; - - case Commands.RESTORE: - matrixStackLength -= 6; - currentMatrix[0] = matrixStack[matrixStackLength + 0]; - currentMatrix[1] = matrixStack[matrixStackLength + 1]; - currentMatrix[2] = matrixStack[matrixStackLength + 2]; - currentMatrix[3] = matrixStack[matrixStackLength + 3]; - currentMatrix[4] = matrixStack[matrixStackLength + 4]; - currentMatrix[5] = matrixStack[matrixStackLength + 5]; - break; - - case Commands.TRANSLATE: - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - currentMatrix[4] = currentMatrix[0] * x + currentMatrix[2] * y + currentMatrix[4]; - currentMatrix[5] = currentMatrix[1] * x + currentMatrix[3] * y + currentMatrix[5]; - cmdIndex += 2; - break; - - case Commands.SCALE: - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - currentMatrix[0] *= x; - currentMatrix[1] *= x; - currentMatrix[2] *= y; - currentMatrix[3] *= y; - cmdIndex += 2; - break; - - case Commands.ROTATE: - y = commands[cmdIndex + 1]; - x = sin(y); - y = cos(y); - sra = currentMatrix[0]; - srb = currentMatrix[1]; - src = currentMatrix[2]; - srd = currentMatrix[3]; - currentMatrix[0] = y * sra + x * src; - currentMatrix[1] = y * srb + x * srd; - currentMatrix[2] = -x * sra + y * src; - currentMatrix[3] = -x * srb + y * srd; - cmdIndex += 1; - break; - - default: - // eslint-disable-next-line no-console - console.error('Phaser: Invalid Graphics Command ID ' + cmd); - break; - } - } - }, - - // Stubs - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawStaticTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawEmitterManager: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawBlitter: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchSprite: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchMesh: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchTileSprite: function () - { - } - -}); - -module.exports = FlatTintPipeline; - - -/***/ }), -/* 260 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(531); -var ShaderSourceVS = __webpack_require__(530); -var WebGLPipeline = __webpack_require__(84); - -/** - * @classdesc - * BitmapMaskPipeline handles all bitmap masking rendering in WebGL. It works by using - * sampling two texture on the fragment shader and using the fragment's alpha to clip the region. - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class BitmapMaskPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. - */ -var BitmapMaskPipeline = new Class({ - - Extends: WebGLPipeline, - - initialize: - - function BitmapMaskPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2), - - vertices: new Float32Array([ - -1, +1, -1, -7, +7, +1 - ]).buffer, - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Size of the batch. - * - * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#maxQuads - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.maxQuads = 1; - - /** - * Dirty flag to check if resolution properties need to be updated on the - * masking shader. - * - * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resolutionDirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.resolutionDirty = true; - }, - - /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - if (this.resolutionDirty) - { - renderer.setFloat2(program, 'uResolution', this.width, this.height); - renderer.setInt1(program, 'uMainSampler', 0); - renderer.setInt1(program, 'uMaskSampler', 1); - this.resolutionDirty = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.resolutionDirty = true; - return this; - }, - - /** - * Binds necessary resources and renders the mask to a separated framebuffer. - * The framebuffer for the masked object is also bound for further use. - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#beginMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - GameObject used as mask. - * @param {Phaser.GameObjects.GameObject} maskedObject - GameObject masked by the mask GameObject. - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - beginMask: function (mask, maskedObject, camera) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - var visible = bitmapMask.visible; - - if (bitmapMask && gl) - { - // First we clear the mask framebuffer - renderer.setFramebuffer(mask.maskFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - - // We render out mask source - bitmapMask.visible = true; - bitmapMask.renderWebGL(renderer, bitmapMask, 0.0, camera); - bitmapMask.visible = visible; - renderer.flush(); - - // Bind and clear our main source (masked object) - renderer.setFramebuffer(mask.mainFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - } - }, - - /** - * The masked game object's framebuffer is unbound and it's texture - * is bound together with the mask texture and the mask shader and - * a draw call with a single quad is processed. Here is where the - * masking effect is applied. - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#endMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - GameObject used as a mask. - */ - endMask: function (mask) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - - if (bitmapMask) - { - // Return to default framebuffer - renderer.setFramebuffer(null); - - // Bind bitmap mask pipeline and draw - renderer.setPipeline(this); - - renderer.setTexture2D(mask.maskTexture, 1); - renderer.setTexture2D(mask.mainTexture, 0); - renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); - - // Finally draw a triangle filling the whole screen - gl.drawArrays(this.topology, 0, 3); - } - } - -}); - -module.exports = BitmapMaskPipeline; - - -/***/ }), -/* 261 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Renderer.Snapshot.WebGL - * @since 3.0.0 - * - * @param {HTMLCanvasElement} sourceCanvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] - * - * @return {HTMLImageElement} [description] - */ -var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) -{ - if (!type) { type = 'image/png'; } - if (!encoderOptions) { encoderOptions = 0.92; } - - var gl = sourceCanvas.getContext('experimental-webgl'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); - - // CanvasPool? - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - var imageData; - - canvas.width = gl.drawingBufferWidth; - canvas.height = gl.drawingBufferHeight; - - imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - - var data = imageData.data; - - for (var y = 0; y < canvas.height; y += 1) - { - for (var x = 0; x < canvas.width; x += 1) - { - var si = ((canvas.height - y) * canvas.width + x) * 4; - var di = (y * canvas.width + x) * 4; - data[di + 0] = pixels[si + 0]; - data[di + 1] = pixels[si + 1]; - data[di + 2] = pixels[si + 2]; - data[di + 3] = pixels[si + 3]; - } - } - - ctx.putImageData(imageData, 0, 0); - - var src = canvas.toDataURL(type, encoderOptions); - var image = new Image(); - - image.src = src; - - return image; -}; - -module.exports = WebGLSnapshot; - - -/***/ }), -/* 262 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var IsSizePowerOfTwo = __webpack_require__(85); -var SpliceOne = __webpack_require__(56); -var Utils = __webpack_require__(27); -var WebGLSnapshot = __webpack_require__(261); - -// Default Pipelines -var BitmapMaskPipeline = __webpack_require__(260); -var FlatTintPipeline = __webpack_require__(259); -var ForwardDiffuseLightPipeline = __webpack_require__(148); -var TextureTintPipeline = __webpack_require__(129); - -/** - * @callback WebGLContextCallback - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] - */ - -/** - * @typedef {object} SnapshotState - * - * @property {SnapshotCallback} callback - [description] - * @property {string} type - [description] - * @property {float} encoder - [description] - */ - -/** - * @classdesc - * WebGLRenderer is a class that contains the needed functionality to keep the - * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of - * any context change that happens for WebGL rendering inside of Phaser. This means - * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL - * rendering ecosystem they might pollute the current WebGLRenderingContext state producing - * unexpected behaviour. It's recommended that WebGL interaction is done through - * WebGLRenderer and/or WebGLPipeline. - * - * @class WebGLRenderer - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - */ -var WebGLRenderer = new Class({ - - initialize: - - function WebGLRenderer (game) - { - // eslint-disable-next-line consistent-this - var renderer = this; - - var gameConfig = game.config; - - var contextCreationConfig = { - alpha: gameConfig.transparent, - depth: false, // enable when 3D is added in the future - antialias: gameConfig.antialias, - premultipliedAlpha: gameConfig.premultipliedAlpha, - stencil: true, - preserveDrawingBuffer: gameConfig.preserveDrawingBuffer, - failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat, - powerPreference: gameConfig.powerPreference - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#config - * @type {RendererConfig} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: gameConfig.clearBeforeRender, - pixelArt: gameConfig.pixelArt, - backgroundColor: gameConfig.backgroundColor, - contextCreation: contextCreationConfig, - resolution: gameConfig.resolution, - autoResize: gameConfig.autoResize, - roundPixels: gameConfig.roundPixels, - maxTextures: gameConfig.maxTextures, - maxTextureSize: gameConfig.maxTextureSize - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.WEBGL; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks - * @type {WebGLContextCallback[]} - * @since 3.0.0 - */ - this.lostContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks - * @type {WebGLContextCallback[]} - * @since 3.0.0 - */ - this.restoredContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.blendModes = []; - - /** - * Keeps track of any WebGLTexture created with the current WebGLRenderingContext - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.nativeTextures = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.contextLost = false; - - /** - * This object will store all pipelines created through addPipeline - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines - * @type {object} - * @default null - * @since 3.0.0 - */ - this.pipelines = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState - * @type {SnapshotState} - * @since 3.0.0 - */ - this.snapshotState = { - callback: null, - type: null, - encoder: null - }; - - // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) - - /** - * Cached value for the last texture unit that was used - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit - * @type {integer} - * @since 3.1.0 - */ - this.currentActiveTextureUnit = 0; - - /** - * An array of the last texture handles that were bound to the WebGLRenderingContext - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures - * @type {array} - * @since 3.0.0 - */ - this.currentTextures = new Array(16); - - /** - * Current framebuffer in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer - * @type {WebGLFramebuffer} - * @default null - * @since 3.0.0 - */ - this.currentFramebuffer = null; - - /** - * Current WebGLPipeline in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @since 3.0.0 - */ - this.currentPipeline = null; - - /** - * Current WebGLProgram in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram - * @type {WebGLProgram} - * @default null - * @since 3.0.0 - */ - this.currentProgram = null; - - /** - * Current WebGLBuffer (Vertex buffer) in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentVertexBuffer = null; - - /** - * Current WebGLBuffer (Index buffer) in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentIndexBuffer = null; - - /** - * Current blend mode in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode - * @type {integer} - * @since 3.0.0 - */ - this.currentBlendMode = Infinity; - - /** - * Indicates if the the scissor state is enabled in WebGLRenderingContext - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.currentScissorEnabled = false; - - /** - * Stores the current scissor data - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor - * @type {Uint32Array} - * @since 3.0.0 - */ - this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); - - /** - * Index to the scissor stack top - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorIdx - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScissorIdx = 0; - - /** - * Stack of scissor data - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack - * @type {Uint32Array} - * @since 3.0.0 - */ - this.scissorStack = new Uint32Array(4 * 1000); - - // Setup context lost and restore event listeners - - this.canvas.addEventListener('webglcontextlost', function (event) - { - renderer.contextLost = true; - event.preventDefault(); - - for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) - { - var callback = renderer.lostContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - this.canvas.addEventListener('webglcontextrestored', function () - { - renderer.contextLost = false; - renderer.init(renderer.config); - for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) - { - var callback = renderer.restoredContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - // These are initialized post context creation - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#gl - * @type {WebGLRenderingContext} - * @default null - * @since 3.0.0 - */ - this.gl = null; - - /** - * Array of strings that indicate which WebGL extensions are supported by the browser - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions - * @type {object} - * @default null - * @since 3.0.0 - */ - this.supportedExtensions = null; - - /** - * Extensions loaded into the current context - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.extensions = {}; - - /** - * Stores the current WebGL component formats for further use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats - * @type {array} - * @default [] - * @since 3.2.0 - */ - this.glFormats = []; - - /** - * Stores the supported WebGL texture compression formats. - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#compression - * @type {array} - * @since 3.8.0 - */ - this.compression = { - ETC1: false, - PVRTC: false, - S3TC: false - }; - - this.init(this.config); - }, - - /** - * Creates a new WebGLRenderingContext and initializes all internal - * state. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#init - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - init: function (config) - { - var gl; - var canvas = this.canvas; - var clearColor = config.backgroundColor; - - // Did they provide their own context? - if (this.game.config.context) - { - gl = this.game.config.context; - } - else - { - gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); - } - - if (!gl || gl.isContextLost()) - { - this.contextLost = true; - - throw new Error('This browser does not support WebGL. Try using the Canvas pipeline.'); - } - - this.gl = gl; - - // Set it back into the Game, so devs can access it from there too - this.game.context = gl; - - for (var i = 0; i <= 16; i++) - { - this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); - } - - this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; - this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; - this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; - - this.glFormats[0] = gl.BYTE; - this.glFormats[1] = gl.SHORT; - this.glFormats[2] = gl.UNSIGNED_BYTE; - this.glFormats[3] = gl.UNSIGNED_SHORT; - this.glFormats[4] = gl.FLOAT; - - // Load supported extensions - var exts = gl.getSupportedExtensions(); - - if (!config.maxTextures) - { - config.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); - } - - if (!config.maxTextureSize) - { - config.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); - } - - var extString = 'WEBGL_compressed_texture_'; - var wkExtString = 'WEBKIT_' + extString; - - this.compression.ETC1 = gl.getExtension(extString + 'etc1') || gl.getExtension(wkExtString + 'etc1'); - this.compression.PVRTC = gl.getExtension(extString + 'pvrtc') || gl.getExtension(wkExtString + 'pvrtc'); - this.compression.S3TC = gl.getExtension(extString + 's3tc') || gl.getExtension(wkExtString + 's3tc'); - - this.supportedExtensions = exts; - - // Setup initial WebGL state - gl.disable(gl.DEPTH_TEST); - gl.disable(gl.CULL_FACE); - gl.disable(gl.SCISSOR_TEST); - gl.enable(gl.BLEND); - gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); - - // Initialize all textures to null - for (var index = 0; index < this.currentTextures.length; ++index) - { - this.currentTextures[index] = null; - } - - // Clear previous pipelines and reload default ones - this.pipelines = {}; - - this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('FlatTintPipeline', new FlatTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); - this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this })); - - this.setBlendMode(CONST.BlendModes.NORMAL); - this.resize(this.width, this.height); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - resize: function (width, height) - { - var gl = this.gl; - var pipelines = this.pipelines; - var resolution = this.config.resolution; - - this.width = Math.floor(width * resolution); - this.height = Math.floor(height * resolution); - - this.canvas.width = this.width; - this.canvas.height = this.height; - - if (this.config.autoResize) - { - this.canvas.style.width = (this.width / resolution) + 'px'; - this.canvas.style.height = (this.height / resolution) + 'px'; - } - - gl.viewport(0, 0, this.width, this.height); - - // Update all registered pipelines - for (var pipelineName in pipelines) - { - pipelines[pipelineName].resize(width, height, resolution); - } - - this.currentScissor.set([ 0, 0, this.width, this.height ]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored - * @since 3.0.0 - * - * @param {WebGLContextCallback} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextRestored: function (callback, target) - { - this.restoredContextCallbacks.push([ callback, target ]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost - * @since 3.0.0 - * - * @param {WebGLContextCallback} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextLost: function (callback, target) - { - this.lostContextCallbacks.push([ callback, target ]); - - return this; - }, - - /** - * Checks if a WebGL extension is supported - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension - * @since 3.0.0 - * - * @param {string} extensionName - Name of the WebGL extension - * - * @return {boolean} [description] - */ - hasExtension: function (extensionName) - { - return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; - }, - - /** - * Loads a WebGL extension - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension - * @since 3.0.0 - * - * @param {string} extensionName - [description] - * - * @return {object} WebGL extension if the extension is supported - */ - getExtension: function (extensionName) - { - if (!this.hasExtension(extensionName)) { return null; } - - if (!(extensionName in this.extensions)) - { - this.extensions[extensionName] = this.gl.getExtension(extensionName); - } - - return this.extensions[extensionName]; - }, - - /** - * Flushes the current pipeline if the pipeline is bound - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#flush - * @since 3.0.0 - */ - flush: function () - { - if (this.currentPipeline) - { - this.currentPipeline.flush(); - } - }, - - /* Renderer State Manipulation Functions */ - - /** - * Checks if a pipeline is present in the current WebGLRenderer - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - Name of the pipeline - * - * @return {boolean} [description] - */ - hasPipeline: function (pipelineName) - { - return (pipelineName in this.pipelines); - }, - - /** - * Returns the pipeline by name if the pipeline exists - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - getPipeline: function (pipelineName) - { - return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; - }, - - /** - * Removes a pipeline by name - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - removePipeline: function (pipelineName) - { - delete this.pipelines[pipelineName]; - - return this; - }, - - /** - * Adds a pipeline instance into the collection of pipelines - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - Pipeline instance must extend WebGLPipeline - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} The instance that was passed. - */ - addPipeline: function (pipelineName, pipelineInstance) - { - if (!this.hasPipeline(pipelineName)) - { - this.pipelines[pipelineName] = pipelineInstance; - } - else - { - console.warn('Pipeline', pipelineName, ' already exists.'); - } - - pipelineInstance.name = pipelineName; - - this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); - - return pipelineInstance; - }, - - /** - * Sets the current scissor state - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setScissor: function (x, y, w, h) - { - var gl = this.gl; - var currentScissor = this.currentScissor; - var enabled = (x === 0 && y === 0 && w === gl.canvas.width && h === gl.canvas.height && w >= 0 && h >= 0); - - if (currentScissor[0] !== x || - currentScissor[1] !== y || - currentScissor[2] !== w || - currentScissor[3] !== h) - { - this.flush(); - } - - currentScissor[0] = x; - currentScissor[1] = y; - currentScissor[2] = w; - currentScissor[3] = h; - - this.currentScissorEnabled = enabled; - - if (enabled) - { - gl.disable(gl.SCISSOR_TEST); - - return this; - } - - gl.enable(gl.SCISSOR_TEST); - gl.scissor(x, (gl.drawingBufferHeight - y - h), w, h); - - return this; - }, - - /** - * Pushes a new scissor state. This is used to set nested scissor states. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - pushScissor: function (x, y, w, h) - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx; - var currentScissor = this.currentScissor; - - scissorStack[stackIndex + 0] = currentScissor[0]; - scissorStack[stackIndex + 1] = currentScissor[1]; - scissorStack[stackIndex + 2] = currentScissor[2]; - scissorStack[stackIndex + 3] = currentScissor[3]; - - this.currentScissorIdx += 4; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * Pops the last scissor state and sets it. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - popScissor: function () - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx - 4; - - var x = scissorStack[stackIndex + 0]; - var y = scissorStack[stackIndex + 1]; - var w = scissorStack[stackIndex + 2]; - var h = scissorStack[stackIndex + 3]; - - this.currentScissorIdx = stackIndex; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * Binds a WebGLPipeline and sets it as the current pipeline to be used. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline - * @since 3.0.0 - * - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setPipeline: function (pipelineInstance) - { - if (this.currentPipeline !== pipelineInstance || - this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || - this.currentPipeline.program !== this.currentProgram) - { - this.flush(); - this.currentPipeline = pipelineInstance; - this.currentPipeline.bind(); - } - - this.currentPipeline.onBind(); - - return this.currentPipeline; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode - * @since 3.0.0 - * - * @param {integer} blendModeId - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setBlendMode: function (blendModeId) - { - var gl = this.gl; - var blendMode = this.blendModes[blendModeId]; - - if (blendModeId !== CONST.BlendModes.SKIP_CHECK && - this.currentBlendMode !== blendModeId) - { - this.flush(); - - gl.enable(gl.BLEND); - gl.blendEquation(blendMode.equation); - - if (blendMode.func.length > 2) - { - gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); - } - else - { - gl.blendFunc(blendMode.func[0], blendMode.func[1]); - } - - this.currentBlendMode = blendModeId; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#addBlendMode - * @since 3.0.0 - * - * @param {function} func - [description] - * @param {function} equation - [description] - * - * @return {integer} [description] - */ - addBlendMode: function (func, equation) - { - var index = this.blendModes.push({ func: func, equation: equation }); - - return index - 1; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#updateBlendMode - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {function} func - [description] - * @param {function} equation - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - updateBlendMode: function (index, func, equation) - { - if (this.blendModes[index]) - { - this.blendModes[index].func = func; - - if (equation) - { - this.blendModes[index].equation = equation; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#removeBlendMode - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - removeBlendMode: function (index) - { - if (index > 16 && this.blendModes[index]) - { - this.blendModes.splice(index, 1); - } - - return this; - }, - - /** - * Binds a texture at a texture unit. If a texture is already - * bound to that unit it will force a flush on the current pipeline. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D - * @since 3.0.0 - * - * @param {WebGLTexture} texture - The WebGL texture that needs to be bound - * @param {integer} textureUnit - The texture unit to which the texture will be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setTexture2D: function (texture, textureUnit) - { - var gl = this.gl; - - if (texture !== this.currentTextures[textureUnit]) - { - this.flush(); - - if (this.currentActiveTextureUnit !== textureUnit) - { - gl.activeTexture(gl.TEXTURE0 + textureUnit); - - this.currentActiveTextureUnit = textureUnit; - } - - gl.bindTexture(gl.TEXTURE_2D, texture); - - this.currentTextures[textureUnit] = texture; - } - - return this; - }, - - /** - * Binds a framebuffer. If there was another framebuffer already bound - * it will force a pipeline flush. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setFramebuffer: function (framebuffer) - { - var gl = this.gl; - - if (framebuffer !== this.currentFramebuffer) - { - this.flush(); - - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - - this.currentFramebuffer = framebuffer; - } - - return this; - }, - - /** - * Binds a program. If there was another program already bound - * it will force a pipeline flush - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - The program that needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setProgram: function (program) - { - var gl = this.gl; - - if (program !== this.currentProgram) - { - this.flush(); - - gl.useProgram(program); - - this.currentProgram = program; - } - - return this; - }, - - /** - * Bounds a vertex buffer. If there is a vertex buffer already bound - * it'll force a pipeline flush. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - The buffer that needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setVertexBuffer: function (vertexBuffer) - { - var gl = this.gl; - - if (vertexBuffer !== this.currentVertexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - - this.currentVertexBuffer = vertexBuffer; - } - - return this; - }, - - /** - * Bounds a index buffer. If there is a index buffer already bound - * it'll force a pipeline flush. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} indexBuffer - The buffer the needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setIndexBuffer: function (indexBuffer) - { - var gl = this.gl; - - if (indexBuffer !== this.currentIndexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); - - this.currentIndexBuffer = indexBuffer; - } - - return this; - }, - - /* Renderer Resource Creation Functions */ - - /** - * Creates a texture from an image source. If the source is not valid - * it creates an empty texture - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} scaleMode - [description] - * - * @return {WebGLTexture} [description] - */ - createTextureFromSource: function (source, width, height, scaleMode) - { - var gl = this.gl; - var filter = gl.NEAREST; - var wrap = gl.CLAMP_TO_EDGE; - var texture = null; - - width = source ? source.width : width; - height = source ? source.height : height; - - if (IsSizePowerOfTwo(width, height)) - { - wrap = gl.REPEAT; - } - - if (scaleMode === CONST.ScaleModes.LINEAR) - { - filter = gl.LINEAR; - } - else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt) - { - filter = gl.NEAREST; - } - - if (!source && typeof width === 'number' && typeof height === 'number') - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - } - else - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); - } - - return texture; - }, - - /** - * A wrapper for creating a WebGLTexture. If not pixel data is passed - * it will create an empty texture. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D - * @since 3.0.0 - * - * @param {integer} mipLevel - Mip level of the texture - * @param {integer} minFilter - Filtering of the texture - * @param {integer} magFilter - Filtering of the texture - * @param {integer} wrapT - Wrapping mode of the texture - * @param {integer} wrapS - Wrapping mode of the texture - * @param {integer} format - Which format does the texture use - * @param {object} pixels - pixel data - * @param {integer} width - Width of the texture in pixels - * @param {integer} height - Height of the texture in pixels - * @param {boolean} pma - Does the texture hace premultiplied alpha. - * - * @return {WebGLTexture} Raw WebGLTexture - */ - createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) - { - var gl = this.gl; - var texture = gl.createTexture(); - - pma = (pma === undefined || pma === null) ? true : pma; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); - - if (pixels === null || pixels === undefined) - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); - } - else - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); - width = pixels.width; - height = pixels.height; - } - - this.setTexture2D(null, 0); - - texture.isAlphaPremultiplied = pma; - texture.isRenderTexture = false; - texture.width = width; - texture.height = height; - - this.nativeTextures.push(texture); - - return texture; - }, - - /** - * Wrapper for creating WebGLFramebuffer. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer - * @since 3.0.0 - * - * @param {integer} width - Width in pixels of the framebuffer - * @param {integer} height - Height in pixels of the framebuffer - * @param {WebGLTexture} renderTexture - The color texture to where the color pixels are written - * @param {boolean} addDepthStencilBuffer - Indicates if the current framebuffer support depth and stencil buffers - * - * @return {WebGLFramebuffer} Raw WebGLFramebuffer - */ - createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) - { - var gl = this.gl; - var framebuffer = gl.createFramebuffer(); - var complete = 0; - - this.setFramebuffer(framebuffer); - - if (addDepthStencilBuffer) - { - var depthStencilBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); - } - - renderTexture.isRenderTexture = true; - renderTexture.isAlphaPremultiplied = false; - - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); - - complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); - - if (complete !== gl.FRAMEBUFFER_COMPLETE) - { - var errors = { - 36054: 'Incomplete Attachment', - 36055: 'Missing Attachment', - 36057: 'Incomplete Dimensions', - 36061: 'Framebuffer Unsupported' - }; - - throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); - } - - framebuffer.renderTexture = renderTexture; - - this.setFramebuffer(null); - - return framebuffer; - }, - - /** - * Wrapper for creating a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram - * @since 3.0.0 - * - * @param {string} vertexShader - Source to the vertex shader - * @param {string} fragmentShader - Source to the fragment shader - * - * @return {WebGLProgram} Raw WebGLProgram - */ - createProgram: function (vertexShader, fragmentShader) - { - var gl = this.gl; - var program = gl.createProgram(); - var vs = gl.createShader(gl.VERTEX_SHADER); - var fs = gl.createShader(gl.FRAGMENT_SHADER); - - gl.shaderSource(vs, vertexShader); - gl.shaderSource(fs, fragmentShader); - gl.compileShader(vs); - gl.compileShader(fs); - - if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); - } - if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); - } - - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.linkProgram(program); - - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) - { - throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); - } - - return program; - }, - - /** - * Wrapper for creating a vertex buffer. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo - * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW - * - * @return {WebGLBuffer} Raw vertex buffer - */ - createVertexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var vertexBuffer = gl.createBuffer(); - - this.setVertexBuffer(vertexBuffer); - - gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); - - this.setVertexBuffer(null); - - return vertexBuffer; - }, - - /** - * Wrapper for creating a vertex buffer. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo - * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW - * - * @return {WebGLBuffer} Raw index buffer - */ - createIndexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var indexBuffer = gl.createBuffer(); - - this.setIndexBuffer(indexBuffer); - - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); - - this.setIndexBuffer(null); - - return indexBuffer; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture - * @since 3.0.0 - * - * @param {WebGLTexture} texture - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteTexture: function (texture) - { - var index = this.nativeTextures.indexOf(texture); - - if (index !== -1) - { - SpliceOne(this.nativeTextures, index); - } - - this.gl.deleteTexture(texture); - - return this; - }, - - /** - * Wrapper for deleting a raw WebGLFramebuffer - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteFramebuffer: function (framebuffer) - { - this.gl.deleteFramebuffer(framebuffer); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteProgram: function (program) - { - this.gl.deleteProgram(program); - - return this; - }, - - /** - * Wrapper for deleting a vertex or index buffer - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteBuffer: function (buffer) - { - this.gl.deleteBuffer(buffer); - - return this; - }, - - /* Rendering Functions */ - - /** - * Handles any clipping needed by the camera and renders the background - * color if a color is visible. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderCamera: function (camera) - { - var resolution = this.config.resolution; - - var cx = Math.floor(camera.x * resolution); - var cy = Math.floor(camera.y * resolution); - var cw = Math.floor(camera.width * resolution); - var ch = Math.floor(camera.height * resolution); - - this.pushScissor(cx, cy, cw, ch); - - if (camera.backgroundColor.alphaGL > 0) - { - var color = camera.backgroundColor; - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1.0), - color.alphaGL, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); - - FlatTintPipeline.flush(); - } - }, - - /** - * Renders the foreground camera effects like flash and fading. - * It resets the current scissor state. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - postRenderCamera: function (camera) - { - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - var isFlashing = camera.flashEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); - var isFading = camera.fadeEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); - - if (isFading || isFlashing) - { - FlatTintPipeline.flush(); - } - - this.popScissor(); - }, - - /** - * Clears the current vertex buffer and updates pipelines. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - if (this.contextLost) { return; } - - var gl = this.gl; - var color = this.config.backgroundColor; - var pipelines = this.pipelines; - - // Bind custom framebuffer here - gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); - - if (this.config.clearBeforeRender) - { - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); - } - - for (var key in pipelines) - { - pipelines[key].onPreRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.GameObject} children - [description] - * @param {number} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - if (this.contextLost) { return; } - - var list = children.list; - var childCount = list.length; - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onRender(scene, camera); - } - - this.preRenderCamera(camera); - - for (var index = 0; index < childCount; ++index) - { - var child = list[index]; - - if (!child.willRender()) - { - continue; - } - - if (child.blendMode !== this.currentBlendMode) - { - this.setBlendMode(child.blendMode); - } - - if (child.mask) - { - child.mask.preRenderWebGL(this, child, camera); - } - - child.renderWebGL(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderWebGL(this, child); - } - } - - this.flush(); - this.setBlendMode(CONST.BlendModes.NORMAL); - this.postRenderCamera(camera); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - if (this.contextLost) { return; } - - // Unbind custom framebuffer here - - if (this.snapshotState.callback) - { - this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); - this.snapshotState.callback = null; - } - - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onPostRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot - * @since 3.0.0 - * - * @param {SnapshotCallback} callback - [description] - * @param {string} type - [description] - * @param {float} encoderOptions - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotState.callback = callback; - this.snapshotState.type = type; - this.snapshotState.encoder = encoderOptions; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture - * @since 3.0.0 - * - * @param {HTMLCanvasElement} srcCanvas - [description] - * @param {WebGLTexture} [dstTexture] - [description] - * - * @return {WebGLTexture} [description] - */ - canvasToTexture: function (srcCanvas, dstTexture) - { - var gl = this.gl; - - if (!dstTexture) - { - var wrapping = gl.CLAMP_TO_EDGE; - - if (IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) - { - wrapping = gl.REPEAT; - } - - dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); - } - else - { - this.setTexture2D(dstTexture, 0); - - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); - - dstTexture.width = srcCanvas.width; - dstTexture.height = srcCanvas.height; - - this.setTexture2D(null, 0); - } - - return dstTexture; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter - * @since 3.0.0 - * - * @param {integer} texture - [description] - * @param {integer} filter - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setTextureFilter: function (texture, filter) - { - var gl = this.gl; - var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); - - this.setTexture2D(null, 0); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat1: function (program, name, x) - { - this.setProgram(program); - - this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat2: function (program, name, x, y) - { - this.setProgram(program); - - this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat3: function (program, name, x, y, z) - { - this.setProgram(program); - - this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); - - return this; - }, - - /** - * Sets uniform of a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - Target program - * @param {string} name - Name of the uniform - * @param {float} x - X component - * @param {float} y - Y component - * @param {float} z - Z component - * @param {float} w - W component - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat4: function (program, name, x, y, z, w) - { - this.setProgram(program); - - this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt1: function (program, name, x) - { - this.setProgram(program); - - this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt2: function (program, name, x, y) - { - this.setProgram(program); - - this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt3: function (program, name, x, y, z) - { - this.setProgram(program); - - this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); - - return this; - }, - - /** - * Sets uniform of a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - Target Program - * @param {string} name - Name of the uniform - * @param {integer} x - X component - * @param {integer} y - Y component - * @param {integer} z - Z component - * @param {integer} w - W component - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt4: function (program, name, x, y, z, w) - { - this.setProgram(program); - - this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix2: function (program, name, transpose, matrix) - { - this.setProgram(program); - - this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix3: function (program, name, transpose, matrix) - { - this.setProgram(program); - - this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); - - return this; - }, - - /** - * Sets uniform of a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - Target program - * @param {string} name - Name of the uniform - * @param {boolean} transpose - Is the matrix transposed - * @param {Float32Array} matrix - Matrix data - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix4: function (program, name, transpose, matrix) - { - this.setProgram(program); - - this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); - - return this; - }, - - /** - * Returns the maximum number of texture units that can be used in a fragment shader. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextures - * @since 3.8.0 - * - * @return {integer} The maximum number of textures WebGL supports. - */ - getMaxTextures: function () - { - return this.config.maxTextures; - }, - - /** - * Returns the largest texture size (either width or height) that can be created. - * Note that VRAM may not allow a texture of any given size, it just expresses - * hardware / driver support for a given size. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextureSize - * @since 3.8.0 - * - * @return {integer} ... - */ - getMaxTextureSize: function () - { - return this.config.maxTextureSize; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Clear-up anything that should be cleared :) - for (var key in this.pipelines) - { - this.pipelines[key].destroy(); - - delete this.pipelines[key]; - } - - for (var index = 0; index < this.nativeTextures.length; ++index) - { - this.deleteTexture(this.nativeTextures[index]); - - delete this.nativeTextures[index]; - } - - delete this.gl; - delete this.game; - - this.contextLost = true; - this.extensions = {}; - this.nativeTextures.length = 0; - } - -}); - -module.exports = WebGLRenderer; - - -/***/ }), -/* 263 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var modes = __webpack_require__(51); -var CanvasFeatures = __webpack_require__(203); - -/** - * [description] - * - * @function Phaser.Renderer.Canvas.GetBlendModes - * @since 3.0.0 - * - * @return {array} [description] - */ -var GetBlendModes = function () -{ - var output = []; - var useNew = CanvasFeatures.supportNewBlendModes; - - output[modes.NORMAL] = 'source-over'; - output[modes.ADD] = 'lighter'; - output[modes.MULTIPLY] = (useNew) ? 'multiply' : 'source-over'; - output[modes.SCREEN] = (useNew) ? 'screen' : 'source-over'; - output[modes.OVERLAY] = (useNew) ? 'overlay' : 'source-over'; - output[modes.DARKEN] = (useNew) ? 'darken' : 'source-over'; - output[modes.LIGHTEN] = (useNew) ? 'lighten' : 'source-over'; - output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : 'source-over'; - output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : 'source-over'; - output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : 'source-over'; - output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : 'source-over'; - output[modes.DIFFERENCE] = (useNew) ? 'difference' : 'source-over'; - output[modes.EXCLUSION] = (useNew) ? 'exclusion' : 'source-over'; - output[modes.HUE] = (useNew) ? 'hue' : 'source-over'; - output[modes.SATURATION] = (useNew) ? 'saturation' : 'source-over'; - output[modes.COLOR] = (useNew) ? 'color' : 'source-over'; - output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : 'source-over'; - - return output; -}; - -module.exports = GetBlendModes; - - -/***/ }), -/* 264 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var roundPixels = false; - -/** - * [description] - * - * @function Phaser.Renderer.Canvas.DrawImage - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} src - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - [description] - */ -var DrawImage = function (src, camera, parentMatrix) -{ - var ctx = this.currentContext; - var frame = src.frame; - var cd = frame.canvasData; - - // Blend Mode - - if (this.currentBlendMode !== src.blendMode) - { - this.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = this.blendModes[src.blendMode]; - } - - // Alpha - - if (this.currentAlpha !== src.alpha) - { - this.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - - if (this.currentScaleMode !== src.scaleMode) - { - this.currentScaleMode = src.scaleMode; - - // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); - } - - var dx = frame.x; - var dy = frame.y; - - var fx = 1; - var fy = 1; - - if (src.flipX) - { - fx = -1; - dx -= cd.dWidth - src.displayOriginX; - } - else - { - dx -= src.displayOriginX; - } - - if (src.flipY) - { - fy = -1; - dy -= cd.dHeight - src.displayOriginY; - } - else - { - dy -= src.displayOriginY; - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - dx |= 0; - dy |= 0; - } - - // Perform Matrix ITRS - - ctx.save(); - - if (parentMatrix) - { - var matrix = parentMatrix.matrix; - - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(fx, fy); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - - ctx.restore(); -}; - -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return DrawImage; -}; - - -/***/ }), -/* 265 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Renderer.Snapshot.Canvas - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] - * - * @return {HTMLImageElement} [description] - */ -var CanvasSnapshot = function (canvas, type, encoderOptions) -{ - if (type === undefined) { type = 'image/png'; } - if (encoderOptions === undefined) { encoderOptions = 0.92; } - - var src = canvas.toDataURL(type, encoderOptions); - - var image = new Image(); - - image.src = src; - - return image; -}; - -module.exports = CanvasSnapshot; - - -/***/ }), -/* 266 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var roundPixels = false; - -/** - * No scaling, anchor, rotation or effects, literally draws the frame directly to the canvas. - * - * @function Phaser.Renderer.Canvas.BlitImage - * @since 3.0.0 - * - * @param {number} dx - The x coordinate to render the Frame to. - * @param {number} dy - The y coordinate to render the Frame to. - * @param {Phaser.Textures.Frame} frame - The Frame to render. - */ -var BlitImage = function (dx, dy, frame) -{ - var ctx = this.currentContext; - var cd = frame.canvasData; - - if (roundPixels) - { - dx |= 0; - dy |= 0; - } - - ctx.drawImage( - frame.source.image, - cd.sx, - cd.sy, - cd.sWidth, - cd.sHeight, - dx, - dy, - cd.dWidth, - cd.dHeight - ); -}; - -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return BlitImage; -}; - - -/***/ }), -/* 267 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlitImage = __webpack_require__(266); -var CanvasSnapshot = __webpack_require__(265); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var DrawImage = __webpack_require__(264); -var GetBlendModes = __webpack_require__(263); -var ScaleModes = __webpack_require__(59); -var Smoothing = __webpack_require__(131); - -/** - * @classdesc - * [description] - * - * @class CanvasRenderer - * @memberOf Phaser.Renderer.Canvas - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. - */ -var CanvasRenderer = new Class({ - - initialize: - - function CanvasRenderer (game) - { - /** - * The Phaser Game instance that owns this renderer. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.CANVAS; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.drawCount = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#config - * @type {RendererConfig} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: game.config.clearBeforeRender, - pixelArt: game.config.pixelArt, - backgroundColor: game.config.backgroundColor, - resolution: game.config.resolution, - autoResize: game.config.autoResize, - roundPixels: game.config.roundPixels - }; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode - * @type {integer} - * @since 3.0.0 - */ - this.scaleMode = (game.config.pixelArt) ? ScaleModes.NEAREST : ScaleModes.LINEAR; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.gameCanvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.gameContext = (this.game.config.context) ? this.game.config.context : this.gameCanvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.currentContext = this.gameContext; - - /** - * Map to the required function. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawImage - * @type {function} - * @since 3.0.0 - */ - this.drawImage = DrawImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blitImage - * @type {function} - * @since 3.0.0 - */ - this.blitImage = BlitImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes - * @type {array} - * @since 3.0.0 - */ - this.blendModes = GetBlendModes(); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.currentAlpha = 1; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentBlendMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentBlendMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScaleMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback - * @type {?SnapshotCallback} - * @default null - * @since 3.0.0 - */ - this.snapshotCallback = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType - * @type {?string} - * @default null - * @since 3.0.0 - */ - this.snapshotType = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder - * @type {?number} - * @default null - * @since 3.0.0 - */ - this.snapshotEncoder = null; - - this.init(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#init - * @since 3.0.0 - */ - init: function () - { - this.resize(this.width, this.height); - }, - - /** - * Resize the main game canvas. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resize - * @since 3.0.0 - * - * @param {integer} width - [description] - * @param {integer} height - [description] - */ - resize: function (width, height) - { - var resolution = this.config.resolution; - - this.width = width * resolution; - this.height = height * resolution; - - this.gameCanvas.width = this.width; - this.gameCanvas.height = this.height; - - if (this.config.autoResize) - { - this.gameCanvas.style.width = (this.width / resolution) + 'px'; - this.gameCanvas.style.height = (this.height / resolution) + 'px'; - } - - // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) - if (this.scaleMode === ScaleModes.NEAREST) - { - Smoothing.disable(this.gameContext); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextLost: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextRestored: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform - * @since 3.0.0 - */ - resetTransform: function () - { - this.currentContext.setTransform(1, 0, 0, 1, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode - * @since 3.0.0 - * - * @param {number} blendMode - [description] - * - * @return {number} [description] - */ - setBlendMode: function (blendMode) - { - if (this.currentBlendMode !== blendMode) - { - this.currentContext.globalCompositeOperation = blendMode; - this.currentBlendMode = blendMode; - } - - return this.currentBlendMode; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha - * @since 3.0.0 - * - * @param {float} alpha - [description] - * - * @return {float} [description] - */ - setAlpha: function (alpha) - { - if (this.currentAlpha !== alpha) - { - this.currentContext.globalAlpha = alpha; - this.currentAlpha = alpha; - } - - return this.currentAlpha; - }, - - /** - * Called at the start of the render loop. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - var ctx = this.gameContext; - var config = this.config; - - var width = this.width; - var height = this.height; - - if (config.clearBeforeRender) - { - ctx.clearRect(0, 0, width, height); - } - - if (!config.transparent) - { - ctx.fillStyle = config.backgroundColor.rgba; - ctx.fillRect(0, 0, width, height); - } - - this.drawCount = 0; - }, - - /** - * Renders the Scene to the given Camera. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.DisplayList} children - [description] - * @param {float} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - var ctx = scene.sys.context; - var scissor = (camera.x !== 0 || camera.y !== 0 || camera.width !== ctx.canvas.width || camera.height !== ctx.canvas.height); - var list = children.list; - var resolution = this.config.resolution; - - this.currentContext = ctx; - - // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) - - if (!camera.transparent) - { - ctx.fillStyle = camera.backgroundColor.rgba; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); - } - - if (this.currentAlpha !== 1) - { - ctx.globalAlpha = 1; - this.currentAlpha = 1; - } - - if (this.currentBlendMode !== 0) - { - ctx.globalCompositeOperation = 'source-over'; - this.currentBlendMode = 0; - } - - this.currentScaleMode = 0; - - this.drawCount += list.length; - - if (scissor) - { - ctx.save(); - ctx.beginPath(); - ctx.rect(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); - ctx.clip(); - } - - var matrix = camera.matrix.matrix; - - ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - - for (var c = 0; c < list.length; c++) - { - var child = list[c]; - - if (child.mask) - { - child.mask.preRenderCanvas(this, child, camera); - } - - child.renderCanvas(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderCanvas(this, child, camera); - } - } - - ctx.setTransform(1, 0, 0, 1, 0, 0); - ctx.globalCompositeOperation = 'source-over'; - - camera.flashEffect.postRenderCanvas(ctx); - camera.fadeEffect.postRenderCanvas(ctx); - - // Reset the camera scissor - if (scissor) - { - ctx.restore(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - var ctx = this.gameContext; - - ctx.globalAlpha = 1; - ctx.globalCompositeOperation = 'source-over'; - - this.currentAlpha = 1; - this.currentBlendMode = 0; - - if (this.snapshotCallback) - { - this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); - this.snapshotCallback = null; - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot - * @since 3.0.0 - * - * @param {SnapshotCallback} callback - [description] - * @param {string} type - [description] - * @param {number} encoderOptions - [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotCallback = callback; - this.snapshotType = type; - this.snapshotEncoder = encoderOptions; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.gameCanvas = null; - this.gameContext = null; - - this.game = null; - } - -}); - -module.exports = CanvasRenderer; - - -/***/ }), -/* 268 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * Abstracts away the use of RAF or setTimeOut for the core game update loop. - * This is invoked automatically by the Phaser.Game instance. - * - * @class RequestAnimationFrame - * @memberOf Phaser.DOM - * @constructor - * @since 3.0.0 - */ -var RequestAnimationFrame = new Class({ - - initialize: - - function RequestAnimationFrame () - { - /** - * True if RequestAnimationFrame is running, otherwise false. - * - * @name Phaser.DOM.RequestAnimationFrame#isRunning - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isRunning = false; - - /** - * The callback to be invoked each step. - * - * @name Phaser.DOM.RequestAnimationFrame#callback - * @type {FrameRequestCallback} - * @since 3.0.0 - */ - this.callback = NOOP; - - /** - * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#tick - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tick = 0; - - /** - * True if the step is using setTimeout instead of RAF. - * - * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isSetTimeOut = false; - - /** - * The setTimeout or RAF callback ID used when canceling them. - * - * @name Phaser.DOM.RequestAnimationFrame#timeOutID - * @type {?number} - * @default null - * @since 3.0.0 - */ - this.timeOutID = null; - - /** - * The previous time the step was called. - * - * @name Phaser.DOM.RequestAnimationFrame#lastTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.lastTime = 0; - - var _this = this; - - /** - * The RAF step function. - * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. - * - * @name Phaser.DOM.RequestAnimationFrame#step - * @type {FrameRequestCallback} - * @since 3.0.0 - */ - this.step = function step (timestamp) - { - // DOMHighResTimeStamp - _this.lastTime = _this.tick; - - _this.tick = timestamp; - - _this.callback(timestamp); - - _this.timeOutID = window.requestAnimationFrame(step); - }; - - /** - * The SetTimeout step function. - * Updates the local tick value, invokes the callback and schedules another call to setTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#stepTimeout - * @type {function} - * @since 3.0.0 - */ - this.stepTimeout = function stepTimeout () - { - var d = Date.now(); - - var delay = Math.max(16 + _this.lastTime - d, 0); - - _this.lastTime = _this.tick; - - _this.tick = d; - - _this.callback(d); - - _this.timeOutID = window.setTimeout(stepTimeout, delay); - }; - }, - - /** - * Starts the requestAnimationFrame or setTimeout process running. - * - * @method Phaser.DOM.RequestAnimationFrame#start - * @since 3.0.0 - * - * @param {FrameRequestCallback} callback - The callback to invoke each step. - * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? - */ - start: function (callback, forceSetTimeOut) - { - if (this.isRunning) - { - return; - } - - this.callback = callback; - - this.isSetTimeOut = forceSetTimeOut; - - this.isRunning = true; - - this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); - }, - - /** - * Stops the requestAnimationFrame or setTimeout from running. - * - * @method Phaser.DOM.RequestAnimationFrame#stop - * @since 3.0.0 - */ - stop: function () - { - this.isRunning = false; - - if (this.isSetTimeOut) - { - clearTimeout(this.timeOutID); - } - else - { - window.cancelAnimationFrame(this.timeOutID); - } - }, - - /** - * Stops the step from running and clears the callback reference. - * - * @method Phaser.DOM.RequestAnimationFrame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stop(); - - this.callback = NOOP; - } - -}); - -module.exports = RequestAnimationFrame; - - -/***/ }), -/* 269 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Attempts to remove the element from its parentNode in the DOM. - * - * @function Phaser.DOM.RemoveFromDOM - * @since 3.0.0 - * - * @param {HTMLElement} element - The DOM element to remove from its parent node. - */ -var RemoveFromDOM = function (element) -{ - if (element.parentNode) - { - element.parentNode.removeChild(element); - } -}; - -module.exports = RemoveFromDOM; - - -/***/ }), -/* 270 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes the given data string and parses it as XML. - * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. - * The parsed XML object is returned, or `null` if there was an error while parsing the data. - * - * @function Phaser.DOM.ParseXML - * @since 3.0.0 - * - * @param {string} data - The XML source stored in a string. - * - * @return {?(DOMParser|ActiveXObject)} The parsed XML data, or `null` if the data could not be parsed. - */ -var ParseXML = function (data) -{ - var xml = ''; - - try - { - if (window['DOMParser']) - { - var domparser = new DOMParser(); - xml = domparser.parseFromString(data, 'text/xml'); - } - else - { - xml = new ActiveXObject('Microsoft.XMLDOM'); - xml.loadXML(data); - } - } - catch (e) - { - xml = null; - } - - if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) - { - return null; - } - else - { - return xml; - } -}; - -module.exports = ParseXML; - - -/***/ }), -/* 271 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(57); - -/** - * @callback ContentLoadedCallback - */ - -/** - * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. - * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. - * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. - * - * @function Phaser.DOM.DOMContentLoaded - * @since 3.0.0 - * - * @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded. - */ -var DOMContentLoaded = function (callback) -{ - if (document.readyState === 'complete' || document.readyState === 'interactive') - { - callback(); - - return; - } - - var check = function () - { - document.removeEventListener('deviceready', check, true); - document.removeEventListener('DOMContentLoaded', check, true); - window.removeEventListener('load', check, true); - - callback(); - }; - - if (!document.body) - { - window.setTimeout(check, 20); - } - else if (OS.cordova && !OS.cocoonJS) - { - // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready - document.addEventListener('deviceready', check, false); - } - else - { - document.addEventListener('DOMContentLoaded', check, true); - window.addEventListener('load', check, true); - } -}; - -module.exports = DOMContentLoaded; - - -/***/ }), -/* 272 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Canvas.CanvasInterpolation - * @since 3.0.0 - */ -var CanvasInterpolation = { - - /** - * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). - * - * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. - * - * @return {HTMLCanvasElement} The canvas. - */ - setCrisp: function (canvas) - { - var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; - - types.forEach(function (type) - { - canvas.style['image-rendering'] = type; - }); - - canvas.style.msInterpolationMode = 'nearest-neighbor'; - - return canvas; - }, - - /** - * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). - * - * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. - * - * @return {HTMLCanvasElement} The canvas. - */ - setBicubic: function (canvas) - { - canvas.style['image-rendering'] = 'auto'; - canvas.style.msInterpolationMode = 'bicubic'; - - return canvas; - } - -}; - -module.exports = CanvasInterpolation; - - -/***/ }), -/* 273 */, -/* 274 */, -/* 275 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.ARNE16 - * @since 3.0.0 - * - * @type {Palette} - */ -module.exports = { - 0: '#000', - 1: '#9D9D9D', - 2: '#FFF', - 3: '#BE2633', - 4: '#E06F8B', - 5: '#493C2B', - 6: '#A46422', - 7: '#EB8931', - 8: '#F7E26B', - 9: '#2F484E', - A: '#44891A', - B: '#A3CE27', - C: '#1B2632', - D: '#005784', - E: '#31A2F2', - F: '#B2DCEF' -}; - - -/***/ }), -/* 276 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Arne16 = __webpack_require__(275); -var CanvasPool = __webpack_require__(22); -var GetValue = __webpack_require__(4); - -/** - * @callback GenerateTextureRendererCallback - * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] - */ - -/** - * @typedef {object} GenerateTextureConfig - * - * @property {array} [data=[]] - [description] - * @property {HTMLCanvasElement} [canvas=null] - [description] - * @property {Palette} [palette=Arne16] - [description] - * @property {number} [pixelWidth=1] - [description] - * @property {number} [pixelHeight=1] - [description] - * @property {boolean} [resizeCanvas=true] - [description] - * @property {boolean} [clearCanvas=true] - [description] - * @property {GenerateTextureRendererCallback} [preRender] - [description] - * @property {GenerateTextureRendererCallback} [postRender] - [description] - */ - -/** - * [description] - * - * @function Phaser.Create.GenerateTexture - * @since 3.0.0 - * - * @param {GenerateTextureConfig} config - [description] - * - * @return {HTMLCanvasElement} [description] - */ -var GenerateTexture = function (config) -{ - var data = GetValue(config, 'data', []); - var canvas = GetValue(config, 'canvas', null); - var palette = GetValue(config, 'palette', Arne16); - var pixelWidth = GetValue(config, 'pixelWidth', 1); - var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); - var resizeCanvas = GetValue(config, 'resizeCanvas', true); - var clearCanvas = GetValue(config, 'clearCanvas', true); - var preRender = GetValue(config, 'preRender', null); - var postRender = GetValue(config, 'postRender', null); - - var width = Math.floor(Math.abs(data[0].length * pixelWidth)); - var height = Math.floor(Math.abs(data.length * pixelHeight)); - - if (!canvas) - { - canvas = CanvasPool.create2D(this, width, height); - resizeCanvas = false; - clearCanvas = false; - } - - if (resizeCanvas) - { - canvas.width = width; - canvas.height = height; - } - - var ctx = canvas.getContext('2d'); - - if (clearCanvas) - { - ctx.clearRect(0, 0, width, height); - } - - // preRender Callback? - if (preRender) - { - preRender(canvas, ctx); - } - - // Draw it - for (var y = 0; y < data.length; y++) - { - var row = data[y]; - - for (var x = 0; x < row.length; x++) - { - var d = row[x]; - - if (d !== '.' && d !== ' ') - { - ctx.fillStyle = palette[d]; - ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); - } - } - } - - // postRender Callback? - if (postRender) - { - postRender(canvas, ctx); - } - - return canvas; -}; - -module.exports = GenerateTexture; - - -/***/ }), -/* 277 */, -/* 278 */, -/* 279 */, -/* 280 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); - -/** - * Converts a CSS 'web' string into a Phaser Color object. - * - * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. - * - * @function Phaser.Display.Color.RGBStringToColor - * @since 3.0.0 - * - * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. - * - * @return {Phaser.Display.Color} A Color object. - */ -var RGBStringToColor = function (rgb) -{ - var color = new Color(); - - var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); - - if (result) - { - var r = parseInt(result[1], 10); - var g = parseInt(result[2], 10); - var b = parseInt(result[3], 10); - var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; - - color.setTo(r, g, b, a * 255); - } - - return color; -}; - -module.exports = RGBStringToColor; - - -/***/ }), -/* 281 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); - -/** - * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. - * - * @function Phaser.Display.Color.ObjectToColor - * @since 3.0.0 - * - * @param {InputColorObject} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. - * - * @return {Phaser.Display.Color} A Color object. - */ -var ObjectToColor = function (input) -{ - return new Color(input.r, input.g, input.b, input.a); -}; - -module.exports = ObjectToColor; - - -/***/ }), -/* 282 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Return the component parts of a color as an Object with the properties alpha, red, green, blue. - * - * Alpha will only be set if it exists in the given color (0xAARRGGBB) - * - * @function Phaser.Display.Color.IntegerToRGB - * @since 3.0.0 - * - * @param {integer} input - The color value to convert into a Color object. - * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. - */ -var IntegerToRGB = function (color) -{ - if (color > 16777215) - { - // The color value has an alpha component - return { - a: color >>> 24, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; - } - else - { - return { - a: 255, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; - } -}; - -module.exports = IntegerToRGB; - - -/***/ }), -/* 283 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); -var IntegerToRGB = __webpack_require__(282); - -/** - * Converts the given color value into an instance of a Color object. - * - * @function Phaser.Display.Color.IntegerToColor - * @since 3.0.0 - * - * @param {integer} input - The color value to convert into a Color object. - * - * @return {Phaser.Display.Color} A Color object. - */ -var IntegerToColor = function (input) -{ - var rgb = IntegerToRGB(input); - - return new Color(rgb.r, rgb.g, rgb.b, rgb.a); -}; - -module.exports = IntegerToColor; - - -/***/ }), -/* 284 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Given an alpha and 3 color values this will return an integer representation of it. - * - * @function Phaser.Display.Color.GetColor32 - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * @param {integer} alpha - The alpha color value. A number between 0 and 255. - * - * @return {number} The combined color value. - */ -var GetColor32 = function (red, green, blue, alpha) -{ - return alpha << 24 | red << 16 | green << 8 | blue; -}; - -module.exports = GetColor32; - - -/***/ }), -/* 285 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); - -/** - * Converts a hex string into a Phaser Color object. - * - * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. - * - * An alpha channel is _not_ supported. - * - * @function Phaser.Display.Color.HexStringToColor - * @since 3.0.0 - * - * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. - * - * @return {Phaser.Display.Color} A Color object populated by the values of the given string. - */ -var HexStringToColor = function (hex) -{ - var color = new Color(); - - // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") - hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) - { - return r + r + g + g + b + b; - }); - - var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); - - if (result) - { - var r = parseInt(result[1], 16); - var g = parseInt(result[2], 16); - var b = parseInt(result[3], 16); - - color.setTo(r, g, b); - } - - return color; -}; - -module.exports = HexStringToColor; - - -/***/ }), -/* 286 */, -/* 287 */, -/* 288 */, -/* 289 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the element at the end of the array to the start, shifting all items in the process. - * The "rotation" happens to the right. - * - * @function Phaser.Utils.Array.RotateRight - * @since 3.0.0 - * - * @param {array} array - The array to shift to the right. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. - * - * @return {*} The most recently shifted element. - */ -var RotateRight = function (array, total) -{ - if (total === undefined) { total = 1; } - - var element = null; - - for (var i = 0; i < total; i++) - { - element = array.pop(); - array.unshift(element); - } - - return element; -}; - -module.exports = RotateRight; - - -/***/ }), -/* 290 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the element at the start of the array to the end, shifting all items in the process. - * The "rotation" happens to the left. - * - * @function Phaser.Utils.Array.RotateLeft - * @since 3.0.0 - * - * @param {array} array - The array to shift to the left. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. - * - * @return {*} The most recently shifted element. - */ -var RotateLeft = function (array, total) -{ - if (total === undefined) { total = 1; } - - var element = null; - - for (var i = 0; i < total; i++) - { - element = array.shift(); - array.push(element); - } - - return element; -}; - -module.exports = RotateLeft; - - -/***/ }), -/* 291 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for setting the WebGL rendering pipeline of a Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline - * @webglOnly - * @since 3.0.0 - */ - -var Pipeline = { - - /** - * The initial WebGL pipeline of this Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - defaultPipeline: null, - - /** - * The current WebGL pipeline of this Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline#pipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - pipeline: null, - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#initPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - initPipeline: function (pipelineName) - { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.defaultPipeline = renderer.getPipeline(pipelineName); - this.pipeline = this.defaultPipeline; - - return true; - } - - return false; - }, - - /** - * Sets the active WebGL Pipeline of this Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#setPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - setPipeline: function (pipelineName) - { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.pipeline = renderer.getPipeline(pipelineName); - - return true; - } - - return false; - }, - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * - * @method Phaser.GameObjects.Components.Pipeline#resetPipeline - * @webglOnly - * @since 3.0.0 - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - resetPipeline: function () - { - this.pipeline = this.defaultPipeline; - - return (this.pipeline !== null); - }, - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - * - * @method Phaser.GameObjects.Components.Pipeline#getPipelineName - * @webglOnly - * @since 3.0.0 - * - * @return {string} The string-based name of the pipeline being used by this Game Object. - */ - getPipelineName: function () - { - return this.pipeline.name; - } - -}; - -module.exports = Pipeline; - - -/***/ }), -/* 292 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Rotate a `point` around `x` and `y` by the given `angle`. - * - * @function Phaser.Math.RotateAround - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. - * @param {number} x - The horizontal coordinate to rotate around. - * @param {number} y - The vertical coordinate to rotate around. - * @param {number} angle - The angle of rotation in radians. - * - * @return {Phaser.Geom.Point} The given point, rotated by the given angle around the given coordinates. - */ -var RotateAround = function (point, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); - - var tx = point.x - x; - var ty = point.y - y; - - point.x = tx * c - ty * s + x; - point.y = tx * s + ty * c + y; - - return point; -}; - -module.exports = RotateAround; - - -/***/ }), -/* 293 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// Get a point on the given line 'progress' percentage along its length. -// progress is a value between 0 and 1. - -/** - * [description] - * - * @function Phaser.Geom.Line.GetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetPoint = function (line, position, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = line.x1 + (line.x2 - line.x1) * position; - out.y = line.y1 + (line.y2 - line.y1) * position; - - return out; -}; - -module.exports = GetPoint; - - -/***/ }), -/* 294 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetPoint = __webpack_require__(135); -var Perimeter = __webpack_require__(97); - -// Return an array of points from the perimeter of the rectangle -// each spaced out based on the quantity or step required - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.GetPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {number} step - [description] - * @param {integer} quantity - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ -var GetPoints = function (rectangle, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = Perimeter(rectangle) / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var position = i / quantity; - - out.push(GetPoint(rectangle, position)); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 295 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the circumference of the given Circle. - * - * @function Phaser.Geom.Circle.Circumference - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference of. - * - * @return {number} The circumference of the Circle. - */ -var Circumference = function (circle) -{ - return 2 * (Math.PI * circle.radius); -}; - -module.exports = Circumference; - - -/***/ }), -/* 296 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circumference = __webpack_require__(295); -var CircumferencePoint = __webpack_require__(136); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); - -/** - * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, - * based on the given quantity or stepRate values. - * - * @function Phaser.Geom.Circle.GetPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the points from. - * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. - * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. - * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. - * - * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. - */ -var GetPoints = function (circle, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = Circumference(circle) / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); - - out.push(CircumferencePoint(circle, angle)); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 297 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A seeded random data generator. - * - * @class RandomDataGenerator - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {string[]} [seeds] - The seeds. - */ -var RandomDataGenerator = new Class({ - - initialize: - - function RandomDataGenerator (seeds) - { - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#c - * @type {number} - * @default 1 - * @private - * @since 3.0.0 - */ - this.c = 1; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#s0 - * @type {number} - * @default 0 - * @private - * @since 3.0.0 - */ - this.s0 = 0; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#s1 - * @type {number} - * @default 0 - * @private - * @since 3.0.0 - */ - this.s1 = 0; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#s2 - * @type {number} - * @default 0 - * @private - * @since 3.0.0 - */ - this.s2 = 0; - - /** - * Internal var. - * - * @name Phaser.Math.RandomDataGenerator#n - * @type {number} - * @default 0 - * @private - * @since 3.2.0 - */ - this.n = 0; - - /** - * Signs to choose from. - * - * @name Phaser.Math.RandomDataGenerator#signs - * @type {number[]} - * @since 3.0.0 - */ - this.signs = [ -1, 1 ]; - - if (seeds) - { - this.init(seeds); - } - }, - - /** - * Private random helper. - * - * @method Phaser.Math.RandomDataGenerator#rnd - * @since 3.0.0 - * @private - * - * @return {number} A random number. - */ - rnd: function () - { - var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32 - - this.c = t | 0; - this.s0 = this.s1; - this.s1 = this.s2; - this.s2 = t - this.c; - - return this.s2; - }, - - /** - * Internal method that creates a seed hash. - * - * @method Phaser.Math.RandomDataGenerator#hash - * @since 3.0.0 - * @private - * - * @param {string} data - The value to hash. - * - * @return {number} The hashed value. - */ - hash: function (data) - { - var h; - var n = this.n; - - data = data.toString(); - - for (var i = 0; i < data.length; i++) - { - n += data.charCodeAt(i); - h = 0.02519603282416938 * n; - n = h >>> 0; - h -= n; - h *= n; - n = h >>> 0; - h -= n; - n += h * 0x100000000;// 2^32 - } - - this.n = n; - - return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 - }, - - /** - * Initialize the state of the random data generator. - * - * @method Phaser.Math.RandomDataGenerator#init - * @since 3.0.0 - * - * @param {(string|string[])} seeds - The seeds to initialize the random data generator with. - */ - init: function (seeds) - { - if (typeof seeds === 'string') - { - this.state(seeds); - } - else - { - this.sow(seeds); - } - }, - - /** - * Reset the seed of the random data generator. - * - * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. - * - * @method Phaser.Math.RandomDataGenerator#sow - * @since 3.0.0 - * - * @param {string[]} seeds - The array of seeds: the `toString()` of each value is used. - */ - sow: function (seeds) - { - // Always reset to default seed - this.n = 0xefc8249d; - this.s0 = this.hash(' '); - this.s1 = this.hash(' '); - this.s2 = this.hash(' '); - this.c = 1; - - if (!seeds) - { - return; - } - - // Apply any seeds - for (var i = 0; i < seeds.length && (seeds[i] != null); i++) - { - var seed = seeds[i]; - - this.s0 -= this.hash(seed); - this.s0 += ~~(this.s0 < 0); - this.s1 -= this.hash(seed); - this.s1 += ~~(this.s1 < 0); - this.s2 -= this.hash(seed); - this.s2 += ~~(this.s2 < 0); - } - }, - - /** - * Returns a random integer between 0 and 2^32. - * - * @method Phaser.Math.RandomDataGenerator#integer - * @since 3.0.0 - * - * @return {number} A random integer between 0 and 2^32. - */ - integer: function () - { - // 2^32 - return this.rnd() * 0x100000000; - }, - - /** - * Returns a random real number between 0 and 1. - * - * @method Phaser.Math.RandomDataGenerator#frac - * @since 3.0.0 - * - * @return {number} A random real number between 0 and 1. - */ - frac: function () - { - // 2^-53 - return this.rnd() + (this.rnd() * 0x200000 | 0) * 1.1102230246251565e-16; - }, - - /** - * Returns a random real number between 0 and 2^32. - * - * @method Phaser.Math.RandomDataGenerator#real - * @since 3.0.0 - * - * @return {number} A random real number between 0 and 2^32. - */ - real: function () - { - return this.integer() + this.frac(); - }, - - /** - * Returns a random integer between and including min and max. - * - * @method Phaser.Math.RandomDataGenerator#integerInRange - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random number between min and max. - */ - integerInRange: function (min, max) - { - return Math.floor(this.realInRange(0, max - min + 1) + min); - }, - - /** - * Returns a random integer between and including min and max. - * This method is an alias for RandomDataGenerator.integerInRange. - * - * @method Phaser.Math.RandomDataGenerator#between - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random number between min and max. - */ - between: function (min, max) - { - return Math.floor(this.realInRange(0, max - min + 1) + min); - }, - - /** - * Returns a random real number between min and max. - * - * @method Phaser.Math.RandomDataGenerator#realInRange - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random number between min and max. - */ - realInRange: function (min, max) - { - return this.frac() * (max - min) + min; - }, - - /** - * Returns a random real number between -1 and 1. - * - * @method Phaser.Math.RandomDataGenerator#normal - * @since 3.0.0 - * - * @return {number} A random real number between -1 and 1. - */ - normal: function () - { - return 1 - (2 * this.frac()); - }, - - /** - * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 - * - * @method Phaser.Math.RandomDataGenerator#uuid - * @since 3.0.0 - * - * @return {string} A valid RFC4122 version4 ID hex string - */ - uuid: function () - { - var a = ''; - var b = ''; - - for (b = a = ''; a++ < 36; b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac() * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') - { - // eslint-disable-next-line no-empty - } - - return b; - }, - - /** - * Returns a random element from within the given array. - * - * @method Phaser.Math.RandomDataGenerator#pick - * @since 3.0.0 - * - * @param {array} array - The array to pick a random element from. - * - * @return {*} A random member of the array. - */ - pick: function (array) - { - return array[this.integerInRange(0, array.length - 1)]; - }, - - /** - * Returns a sign to be used with multiplication operator. - * - * @method Phaser.Math.RandomDataGenerator#sign - * @since 3.0.0 - * - * @return {number} -1 or +1. - */ - sign: function () - { - return this.pick(this.signs); - }, - - /** - * Returns a random element from within the given array, favoring the earlier entries. - * - * @method Phaser.Math.RandomDataGenerator#weightedPick - * @since 3.0.0 - * - * @param {array} array - The array to pick a random element from. - * - * @return {*} A random member of the array. - */ - weightedPick: function (array) - { - return array[~~(Math.pow(this.frac(), 2) * (array.length - 1) + 0.5)]; - }, - - /** - * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. - * - * @method Phaser.Math.RandomDataGenerator#timestamp - * @since 3.0.0 - * - * @param {number} min - The minimum value in the range. - * @param {number} max - The maximum value in the range. - * - * @return {number} A random timestamp between min and max. - */ - timestamp: function (min, max) - { - return this.realInRange(min || 946684800000, max || 1577862000000); - }, - - /** - * Returns a random angle between -180 and 180. - * - * @method Phaser.Math.RandomDataGenerator#angle - * @since 3.0.0 - * - * @return {number} A random number between -180 and 180. - */ - angle: function () - { - return this.integerInRange(-180, 180); - }, - - /** - * Returns a random rotation in radians, between -3.141 and 3.141 - * - * @method Phaser.Math.RandomDataGenerator#rotation - * @since 3.0.0 - * - * @return {number} A random number between -3.141 and 3.141 - */ - rotation: function () - { - return this.realInRange(-3.1415926, 3.1415926); - }, - - /** - * Gets or Sets the state of the generator. This allows you to retain the values - * that the generator is using between games, i.e. in a game save file. - * - * To seed this generator with a previously saved state you can pass it as the - * `seed` value in your game config, or call this method directly after Phaser has booted. - * - * Call this method with no parameters to return the current state. - * - * If providing a state it should match the same format that this method - * returns, which is a string with a header `!rnd` followed by the `c`, - * `s0`, `s1` and `s2` values respectively, each comma-delimited. - * - * @method Phaser.Math.RandomDataGenerator#state - * @since 3.0.0 - * - * @param {string} [state] - Generator state to be set. - * - * @return {string} The current state of the generator. - */ - state: function (state) - { - if (typeof state === 'string' && state.match(/^!rnd/)) - { - state = state.split(','); - - this.c = parseFloat(state[1]); - this.s0 = parseFloat(state[2]); - this.s1 = parseFloat(state[3]); - this.s2 = parseFloat(state[4]); - } - - return [ '!rnd', this.c, this.s0, this.s1, this.s2 ].join(','); - }, - - /** - * Shuffles the given array, using the current seed. - * - * @method Phaser.Math.RandomDataGenerator#shuffle - * @since 3.7.0 - * - * @param {array} [array] - The array to be shuffled. - * - * @return {array} The shuffled array. - */ - shuffle: function (array) - { - var len = array.length - 1; - - for (var i = len; i > 0; i--) - { - var randomIndex = Math.floor(this.frac() * (len + 1)); - var itemAtIndex = array[randomIndex]; - - array[randomIndex] = array[i]; - array[i] = itemAtIndex; - } - - return array; - } - -}); - -module.exports = RandomDataGenerator; - - -/***/ }), -/* 298 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CircumferencePoint = __webpack_require__(136); -var FromPercent = __webpack_require__(65); -var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle - * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point - * at 180 degrees around the circle. - * - * @function Phaser.Geom.Circle.GetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. - */ -var GetPoint = function (circle, position, out) -{ - if (out === undefined) { out = new Point(); } - - var angle = FromPercent(position, 0, MATH_CONST.PI2); - - return CircumferencePoint(circle, angle, out); -}; - -module.exports = GetPoint; - - -/***/ }), -/* 299 */, -/* 300 */, -/* 301 */, -/* 302 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * This event is dispatched when an animation starts playing. - * - * @event Phaser.GameObjects.Components.Animation#onStartEvent - * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. - * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. - */ - -/** - * This event is dispatched when an animation repeats. - * - * @event Phaser.GameObjects.Components.Animation#onRepeatEvent - * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. - * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. - * @param {integer} repeatCount - The number of times this animation has repeated. - */ - -/** - * This event is dispatched when an animation updates. This happens when the animation frame changes, - * based on the animation frame rate and other factors like timeScale and delay. - * - * @event Phaser.GameObjects.Components.Animation#onUpdateEvent - * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. - * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. - */ - -/** - * This event is dispatched when an animation completes playing, either naturally or via Animation.stop. - * - * @event Phaser.GameObjects.Components.Animation#onCompleteEvent - * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. - * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. - */ - -/** - * @classdesc - * A Game Object Animation Controller. - * - * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. - * - * @class Animation - * @memberOf Phaser.GameObjects.Components - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} parent - The Game Object to which this animation controller belongs. - */ -var Animation = new Class({ - - initialize: - - function Animation (parent) - { - /** - * The Game Object to which this animation controller belongs. - * - * @name Phaser.GameObjects.Components.Animation#parent - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * A reference to the global Animation Manager. - * - * @name Phaser.GameObjects.Components.Animation#animationManager - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.animationManager = parent.scene.sys.anims; - - this.animationManager.once('remove', this.remove, this); - - /** - * Is an animation currently playing or not? - * - * @name Phaser.GameObjects.Components.Animation#isPlaying - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isPlaying = false; - - /** - * The current Animation loaded into this Animation Controller. - * - * @name Phaser.GameObjects.Components.Animation#currentAnim - * @type {?Phaser.Animations.Animation} - * @default null - * @since 3.0.0 - */ - this.currentAnim = null; - - /** - * The current AnimationFrame being displayed by this Animation Controller. - * - * @name Phaser.GameObjects.Components.Animation#currentFrame - * @type {?Phaser.Animations.AnimationFrame} - * @default null - * @since 3.0.0 - */ - this.currentFrame = null; - - /** - * Time scale factor. - * - * @name Phaser.GameObjects.Components.Animation#_timeScale - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._timeScale = 1; - - /** - * The frame rate of playback in frames per second. - * The default is 24 if the `duration` property is `null`. - * - * @name Phaser.GameObjects.Components.Animation#frameRate - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.frameRate = 0; - - /** - * How long the animation should play for, in milliseconds. - * If the `frameRate` property has been set then it overrides this value, - * otherwise the `frameRate` is derived from `duration`. - * - * @name Phaser.GameObjects.Components.Animation#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * ms per frame, not including frame specific modifiers that may be present in the Animation data. - * - * @name Phaser.GameObjects.Components.Animation#msPerFrame - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.msPerFrame = 0; - - /** - * Skip frames if the time lags, or always advanced anyway? - * - * @name Phaser.GameObjects.Components.Animation#skipMissedFrames - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.skipMissedFrames = true; - - /** - * A delay before starting playback, in milliseconds. - * - * @name Phaser.GameObjects.Components.Animation#_delay - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._delay = 0; - - /** - * Number of times to repeat the animation (-1 for infinity) - * - * @name Phaser.GameObjects.Components.Animation#_repeat - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._repeat = 0; - - /** - * Delay before the repeat starts, in milliseconds. - * - * @name Phaser.GameObjects.Components.Animation#_repeatDelay - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._repeatDelay = 0; - - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - * - * @name Phaser.GameObjects.Components.Animation#_yoyo - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._yoyo = false; - - /** - * Will the playhead move forwards (`true`) or in reverse (`false`) - * - * @name Phaser.GameObjects.Components.Animation#forward - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.forward = true; - - /** - * Internal time overflow accumulator. - * - * @name Phaser.GameObjects.Components.Animation#accumulator - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accumulator = 0; - - /** - * The time point at which the next animation frame will change. - * - * @name Phaser.GameObjects.Components.Animation#nextTick - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.nextTick = 0; - - /** - * An internal counter keeping track of how many repeats are left to play. - * - * @name Phaser.GameObjects.Components.Animation#repeatCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.repeatCounter = 0; - - /** - * An internal flag keeping track of pending repeats. - * - * @name Phaser.GameObjects.Components.Animation#pendingRepeat - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.pendingRepeat = false; - - /** - * Is the Animation paused? - * - * @name Phaser.GameObjects.Components.Animation#_paused - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._paused = false; - - /** - * Was the animation previously playing before being paused? - * - * @name Phaser.GameObjects.Components.Animation#_wasPlaying - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._wasPlaying = false; - - /** - * Internal property tracking if this Animation is waiting to stop. - * - * 0 = No - * 1 = Waiting for ms to pass - * 2 = Waiting for repeat - * 3 = Waiting for specific frame - * - * @name Phaser.GameObjects.Components.Animation#_pendingStop - * @type {integer} - * @private - * @since 3.4.0 - */ - this._pendingStop = 0; - - /** - * Internal property used by _pendingStop. - * - * @name Phaser.GameObjects.Components.Animation#_pendingStopValue - * @type {any} - * @private - * @since 3.4.0 - */ - this._pendingStopValue; - }, - - /** - * Sets the amount of time, in milliseconds, that the animation will be delayed before starting playback. - * - * @method Phaser.GameObjects.Components.Animation#setDelay - * @since 3.4.0 - * - * @param {integer} [value=0] - The amount of time, in milliseconds, to wait before starting playback. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - setDelay: function (value) - { - if (value === undefined) { value = 0; } - - this._delay = value; - - return this.parent; - }, - - /** - * Gets the amount of time, in milliseconds that the animation will be delayed before starting playback. - * - * @method Phaser.GameObjects.Components.Animation#getDelay - * @since 3.4.0 - * - * @return {integer} The amount of time, in milliseconds, the Animation will wait before starting playback. - */ - getDelay: function () - { - return this._delay; - }, - - /** - * Waits for the specified delay, in milliseconds, then starts playback of the requested animation. - * - * @method Phaser.GameObjects.Components.Animation#delayedPlay - * @since 3.0.0 - * - * @param {integer} delay - The delay, in milliseconds, to wait before starting the animation playing. - * @param {string} key - The key of the animation to play. - * @param {integer} [startFrame=0] - The frame of the animation to start from. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - delayedPlay: function (delay, key, startFrame) - { - this.play(key, true, startFrame); - - this.nextTick += delay; - - return this.parent; - }, - - /** - * Returns the key of the animation currently loaded into this component. - * - * @method Phaser.GameObjects.Components.Animation#getCurrentKey - * @since 3.0.0 - * - * @return {string} The key of the Animation loaded into this component. - */ - getCurrentKey: function () - { - if (this.currentAnim) - { - return this.currentAnim.key; - } - }, - - /** - * Internal method used to load an animation into this component. - * - * @method Phaser.GameObjects.Components.Animation#load - * @protected - * @since 3.0.0 - * - * @param {string} key - The key of the animation to load. - * @param {integer} [startFrame=0] - The start frame of the animation to load. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - load: function (key, startFrame) - { - if (startFrame === undefined) { startFrame = 0; } - - if (this.isPlaying) - { - this.stop(); - } - - // Load the new animation in - this.animationManager.load(this, key, startFrame); - - return this.parent; - }, - - /** - * Pause the current animation and set the `isPlaying` property to `false`. - * You can optionally pause it at a specific frame. - * - * @method Phaser.GameObjects.Components.Animation#pause - * @since 3.0.0 - * - * @param {Phaser.Animations.AnimationFrame} [atFrame] - An optional frame to set after pausing the animation. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - pause: function (atFrame) - { - if (!this._paused) - { - this._paused = true; - this._wasPlaying = this.isPlaying; - this.isPlaying = false; - } - - if (atFrame !== undefined) - { - this.updateFrame(atFrame); - } - - return this.parent; - }, - - /** - * Resumes playback of a paused animation and sets the `isPlaying` property to `true`. - * You can optionally tell it to start playback from a specific frame. - * - * @method Phaser.GameObjects.Components.Animation#resume - * @since 3.0.0 - * - * @param {Phaser.Animations.AnimationFrame} [fromFrame] - An optional frame to set before restarting playback. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - resume: function (fromFrame) - { - if (this._paused) - { - this._paused = false; - this.isPlaying = this._wasPlaying; - } - - if (fromFrame !== undefined) - { - this.updateFrame(fromFrame); - } - - return this.parent; - }, - - /** - * `true` if the current animation is paused, otherwise `false`. - * - * @name Phaser.GameObjects.Components.Animation#isPaused - * @readOnly - * @type {boolean} - * @since 3.4.0 - */ - isPaused: { - - get: function () - { - return this._paused; - } - - }, - - /** - * Plays an Animation on the Game Object that owns this Animation Component. - * - * @method Phaser.GameObjects.Components.Animation#play - * @fires Phaser.GameObjects.Components.Animation#onStartEvent - * @since 3.0.0 - * - * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. - * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. - * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - play: function (key, ignoreIfPlaying, startFrame) - { - if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } - if (startFrame === undefined) { startFrame = 0; } - - if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) - { - return this.parent; - } - - this.load(key, startFrame); - - var anim = this.currentAnim; - var gameObject = this.parent; - - // Should give us 9,007,199,254,740,991 safe repeats - this.repeatCounter = (this._repeat === -1) ? Number.MAX_VALUE : this._repeat; - - anim.getFirstTick(this); - - this.forward = true; - this.isPlaying = true; - this.pendingRepeat = false; - - if (anim.showOnStart) - { - gameObject.visible = true; - } - - gameObject.emit('animationstart', this.currentAnim, this.currentFrame); - - return gameObject; - }, - - /** - * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. - * If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different - * because `getProgress` doesn't include any repeats or repeat delays, whereas `getTotalProgress` does. - * - * @method Phaser.GameObjects.Components.Animation#getProgress - * @since 3.4.0 - * - * @return {float} The progress of the current animation, between 0 and 1. - */ - getProgress: function () - { - var p = this.currentFrame.progress; - - if (!this.forward) - { - p = 1 - p; - } - - return p; - }, - - /** - * Takes a value between 0 and 1 and uses it to set how far this animation is through playback. - * Does not factor in repeats or yoyos, but does handle playing forwards or backwards. - * - * @method Phaser.GameObjects.Components.Animation#setProgress - * @since 3.4.0 - * - * @param {float} [value=0] - The progress value, between 0 and 1. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - setProgress: function (value) - { - if (!this.forward) - { - value = 1 - value; - } - - this.setCurrentFrame(this.currentAnim.getFrameByProgress(value)); - - return this.parent; - }, - - /** - * Handle the removal of an animation from the Animation Manager. - * - * @method Phaser.GameObjects.Components.Animation#remove - * @since 3.0.0 - * - * @param {string} [key] - The key of the removed Animation. - * @param {Phaser.Animations.Animation} [animation] - The removed Animation. - */ - remove: function (key, animation) - { - if (animation === undefined) { animation = this.currentAnim; } - - if (this.isPlaying && animation.key === this.currentAnim.key) - { - this.stop(); - - this.setCurrentFrame(this.currentAnim.frames[0]); - } - }, - - /** - * Gets the number of times that the animation will repeat - * after its first iteration. For example, if returns 1, the animation will - * play a total of twice (the initial play plus 1 repeat). - * A value of -1 means the animation will repeat indefinitely. - * - * @method Phaser.GameObjects.Components.Animation#getRepeat - * @since 3.4.0 - * - * @return {integer} The number of times that the animation will repeat. - */ - getRepeat: function () - { - return this._repeat; - }, - - /** - * Sets the number of times that the animation should repeat - * after its first iteration. For example, if repeat is 1, the animation will - * play a total of twice (the initial play plus 1 repeat). - * To repeat indefinitely, use -1. repeat should always be an integer. - * - * @method Phaser.GameObjects.Components.Animation#setRepeat - * @since 3.4.0 - * - * @param {integer} value - The number of times that the animation should repeat. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - setRepeat: function (value) - { - this._repeat = value; - - this.repeatCounter = 0; - - return this.parent; - }, - - /** - * Gets the amount of delay between repeats, if any. - * - * @method Phaser.GameObjects.Components.Animation#getRepeatDelay - * @since 3.4.0 - * - * @return {number} The delay between repeats. - */ - getRepeatDelay: function () - { - return this._repeatDelay; - }, - - /** - * Sets the amount of time in seconds between repeats. - * For example, if `repeat` is 2 and `repeatDelay` is 10, the animation will play initially, - * then wait for 10 seconds before repeating, then play again, then wait another 10 seconds - * before doing its final repeat. - * - * @method Phaser.GameObjects.Components.Animation#setRepeatDelay - * @since 3.4.0 - * - * @param {number} value - The delay to wait between repeats, in seconds. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - setRepeatDelay: function (value) - { - this._repeatDelay = value; - - return this.parent; - }, - - /** - * Restarts the current animation from its beginning, optionally including its delay value. - * - * @method Phaser.GameObjects.Components.Animation#restart - * @since 3.0.0 - * - * @param {boolean} [includeDelay=false] - Whether to include the delay value of the animation when restarting. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - restart: function (includeDelay) - { - if (includeDelay === undefined) { includeDelay = false; } - - this.currentAnim.getFirstTick(this, includeDelay); - - this.forward = true; - this.isPlaying = true; - this.pendingRepeat = false; - this._paused = false; - - // Set frame - this.updateFrame(this.currentAnim.frames[0]); - - return this.parent; - }, - - /** - * Immediately stops the current animation from playing and dispatches the `animationcomplete` event. - * - * @method Phaser.GameObjects.Components.Animation#stop - * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent - * @since 3.0.0 - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - stop: function () - { - this._pendingStop = 0; - - this.isPlaying = false; - - var gameObject = this.parent; - - gameObject.emit('animationcomplete', this.currentAnim, this.currentFrame); - - return gameObject; - }, - - /** - * Stops the current animation from playing after the specified time delay, given in milliseconds. - * - * @method Phaser.GameObjects.Components.Animation#stopAfterDelay - * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent - * @since 3.4.0 - * - * @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. - */ - stopAfterDelay: function (delay) - { - this._pendingStop = 1; - this._pendingStopValue = delay; - - return this.parent; - }, - - /** - * Stops the current animation from playing when it next repeats. - * - * @method Phaser.GameObjects.Components.Animation#stopOnRepeat - * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent - * @since 3.4.0 - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - stopOnRepeat: function () - { - this._pendingStop = 2; - - return this.parent; - }, - - /** - * Stops the current animation from playing when it next sets the given frame. - * If this frame doesn't exist within the animation it will not stop it from playing. - * - * @method Phaser.GameObjects.Components.Animation#stopOnFrame - * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent - * @since 3.4.0 - * - * @param {Phaser.Animations.AnimationFrame} delay - The frame to check before stopping this animation. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - stopOnFrame: function (frame) - { - this._pendingStop = 3; - this._pendingStopValue = frame; - - return this.parent; - }, - - /** - * Sets the Time Scale factor, allowing you to make the animation go go faster or slower than default. - * Where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. - * - * @method Phaser.GameObjects.Components.Animation#setTimeScale - * @since 3.4.0 - * - * @param {number} [value=1] - The time scale factor, where 1 is no change, 0.5 is half speed, etc. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. - */ - setTimeScale: function (value) - { - if (value === undefined) { value = 1; } - - this._timeScale = value; - - return this.parent; - }, - - /** - * Gets the Time Scale factor. - * - * @method Phaser.GameObjects.Components.Animation#getTimeScale - * @since 3.4.0 - * - * @return {number} The Time Scale value. - */ - getTimeScale: function () - { - return this._timeScale; - }, - - /** - * Returns the total number of frames in this animation. - * - * @method Phaser.GameObjects.Components.Animation#getTotalFrames - * @since 3.4.0 - * - * @return {integer} The total number of frames in this animation. - */ - getTotalFrames: function () - { - return this.currentAnim.frames.length; - }, - - /** - * The internal update loop for the Animation Component. - * - * @method Phaser.GameObjects.Components.Animation#update - * @since 3.0.0 - * - * @param {number} time - The current timestamp. - * @param {number} delta - The delta time, in ms, elapsed since the last frame. - */ - update: function (time, delta) - { - if (!this.currentAnim || !this.isPlaying || this.currentAnim.paused) - { - return; - } - - this.accumulator += delta * this._timeScale; - - if (this._pendingStop === 1) - { - this._pendingStopValue -= delta; - - if (this._pendingStopValue <= 0) - { - return this.currentAnim.completeAnimation(this); - } - } - - if (this.accumulator >= this.nextTick) - { - this.currentAnim.setFrame(this); - } - }, - - /** - * Sets the given Animation Frame as being the current frame - * and applies it to the parent Game Object, adjusting its size and origin as needed. - * - * @method Phaser.GameObjects.Components.Animation#setCurrentFrame - * @since 3.4.0 - * - * @param {Phaser.Animations.AnimationFrame} animationFrame - The Animation Frame to set as being current. - * - * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. - */ - setCurrentFrame: function (animationFrame) - { - var gameObject = this.parent; - - this.currentFrame = animationFrame; - - gameObject.texture = animationFrame.frame.texture; - gameObject.frame = animationFrame.frame; - - gameObject.setSizeToFrame(); - - if (animationFrame.frame.customPivot) - { - gameObject.setOrigin(animationFrame.frame.pivotX, animationFrame.frame.pivotY); - } - else - { - gameObject.updateDisplayOrigin(); - } - - return gameObject; - }, - - /** - * Internal frame change handler. - * - * @method Phaser.GameObjects.Components.Animation#updateFrame - * @fires Phaser.GameObjects.Components.Animation#onUpdateEvent - * @private - * @since 3.0.0 - * - * @param {Phaser.Animations.AnimationFrame} animationFrame - The animation frame to change to. - */ - updateFrame: function (animationFrame) - { - var gameObject = this.setCurrentFrame(animationFrame); - - if (this.isPlaying) - { - if (animationFrame.setAlpha) - { - gameObject.alpha = animationFrame.alpha; - } - - var anim = this.currentAnim; - - gameObject.emit('animationupdate', anim, animationFrame); - - if (this._pendingStop === 3 && this._pendingStopValue === animationFrame) - { - this.currentAnim.completeAnimation(this); - } - } - }, - - /** - * Sets if the current Animation will yoyo when it reaches the end. - * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. - * - * @method Phaser.GameObjects.Components.Animation#setYoyo - * @since 3.4.0 - * - * @param {boolean} [value=false] - `true` if the animation should yoyo, `false` to not. - * - * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. - */ - setYoyo: function (value) - { - if (value === undefined) { value = false; } - - this._yoyo = value; - - return this.parent; - }, - - /** - * Gets if the current Animation will yoyo when it reaches the end. - * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. - * - * @method Phaser.GameObjects.Components.Animation#getYoyo - * @since 3.4.0 - * - * @return {boolean} `true` if the animation is set to yoyo, `false` if not. - */ - getYoyo: function () - { - return this._yoyo; - }, - - /** - * Destroy this Animation component. - * - * Unregisters event listeners and cleans up its references. - * - * @method Phaser.GameObjects.Components.Animation#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.animationManager.off('remove', this.remove, this); - - this.animationManager = null; - this.parent = null; - - this.currentAnim = null; - this.currentFrame = null; - } - -}); - -module.exports = Animation; - - -/***/ }), -/* 303 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var NumberTweenBuilder = __webpack_require__(161); -var PluginCache = __webpack_require__(12); -var TimelineBuilder = __webpack_require__(160); -var TWEEN_CONST = __webpack_require__(61); -var TweenBuilder = __webpack_require__(72); - -/** - * @classdesc - * [description] - * - * @class TweenManager - * @memberOf Phaser.Tweens - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var TweenManager = new Class({ - - initialize: - - function TweenManager (scene) - { - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_add - * @type {array} - * @private - * @since 3.0.0 - */ - this._add = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_pending - * @type {array} - * @private - * @since 3.0.0 - */ - this._pending = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_active - * @type {array} - * @private - * @since 3.0.0 - */ - this._active = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_destroy - * @type {array} - * @private - * @since 3.0.0 - */ - this._destroy = []; - - /** - * [description] - * - * @name Phaser.Tweens.TweenManager#_toProcess - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._toProcess = 0; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Tweens.TweenManager#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.systems.events.once('destroy', this.destroy, 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.Tweens.TweenManager#start - * @private - * @since 3.5.0 - */ - start: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); - - this.timeScale = 1; - }, - - /** - * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. - * - * @method Phaser.Tweens.TweenManager#createTimeline - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Timeline} [description] - */ - createTimeline: function (config) - { - return TimelineBuilder(this, config); - }, - - /** - * Create a Tween Timeline and add it to the active Tween list/ - * - * @method Phaser.Tweens.TweenManager#timeline - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Timeline} [description] - */ - timeline: function (config) - { - var timeline = TimelineBuilder(this, config); - - if (!timeline.paused) - { - this._add.push(timeline); - - this._toProcess++; - } - - return timeline; - }, - - /** - * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. - * - * @method Phaser.Tweens.TweenManager#create - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ - create: function (config) - { - return TweenBuilder(this, config); - }, - - /** - * Create a Tween and add it to the active Tween list. - * - * @method Phaser.Tweens.TweenManager#add - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ - add: function (config) - { - var tween = TweenBuilder(this, config); - - this._add.push(tween); - - this._toProcess++; - - return tween; - }, - - /** - * Add an existing tween into the active Tween list. - * - * @method Phaser.Tweens.TweenManager#existing - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {Phaser.Tweens.TweenManager} This Tween Manager object. - */ - existing: function (tween) - { - this._add.push(tween); - - this._toProcess++; - - return this; - }, - - /** - * Create a Tween and add it to the active Tween list. - * - * @method Phaser.Tweens.TweenManager#addCounter - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ - addCounter: function (config) - { - var tween = NumberTweenBuilder(this, config); - - this._add.push(tween); - - this._toProcess++; - - return tween; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#preUpdate - * @since 3.0.0 - */ - preUpdate: function () - { - if (this._toProcess === 0) - { - // Quick bail - return; - } - - var list = this._destroy; - var active = this._active; - var i; - var tween; - - // Clear the 'destroy' list - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - // Remove from the 'active' array - var idx = active.indexOf(tween); - - if (idx !== -1) - { - tween.state = TWEEN_CONST.REMOVED; - active.splice(idx, 1); - } - } - - list.length = 0; - - // Process the addition list - // This stops callbacks and out of sync events from populating the active array mid-way during the update - - list = this._add; - - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - if (tween.state === TWEEN_CONST.PENDING_ADD) - { - // Return true if the Tween should be started right away, otherwise false - if (tween.init()) - { - tween.play(); - - this._active.push(tween); - } - else - { - this._pending.push(tween); - } - } - } - - list.length = 0; - - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - */ - update: function (timestamp, delta) - { - // Process active tweens - var list = this._active; - var tween; - - // Scale the delta - delta *= this.timeScale; - - for (var i = 0; i < list.length; i++) - { - tween = list[i]; - - // If Tween.update returns 'true' then it means it has completed, - // so move it to the destroy list - if (tween.update(timestamp, delta)) - { - this._destroy.push(tween); - this._toProcess++; - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#makeActive - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * - * @return {Phaser.Tweens.TweenManager} This Tween Manager object. - */ - makeActive: function (tween) - { - if (this._add.indexOf(tween) !== -1 || this._active.indexOf(tween) !== -1) - { - return; - } - - var idx = this._pending.indexOf(tween); - - if (idx !== -1) - { - this._pending.splice(idx, 1); - } - - this._add.push(tween); - - tween.state = TWEEN_CONST.PENDING_ADD; - - this._toProcess++; - - return this; - }, - - /** - * Passes all Tweens to the given callback. - * - * @method Phaser.Tweens.TweenManager#each - * @since 3.0.0 - * - * @param {function} callback - [description] - * @param {object} [scope] - [description] - * @param {...*} [args] - [description] - */ - each: function (callback, scope) - { - var args = [ null ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var texture in this.list) - { - args[0] = this.list[texture]; - - callback.apply(scope, args); - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#getAllTweens - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween[]} [description] - */ - getAllTweens: function () - { - var list = this._active; - var output = []; - - for (var i = 0; i < list.length; i++) - { - output.push(list[i]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#getGlobalTimeScale - * @since 3.0.0 - * - * @return {number} [description] - */ - getGlobalTimeScale: function () - { - return this.timeScale; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#getTweensOf - * @since 3.0.0 - * - * @param {(object|array)} target - [description] - * - * @return {Phaser.Tweens.Tween[]} [description] - */ - getTweensOf: function (target) - { - var list = this._active; - var tween; - var output = []; - var i; - - if (Array.isArray(target)) - { - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - for (var t = 0; t < target.length; t++) - { - if (tween.hasTarget(target[t])) - { - output.push(tween); - } - } - } - } - else - { - for (i = 0; i < list.length; i++) - { - tween = list[i]; - - if (tween.hasTarget(target)) - { - output.push(tween); - } - } - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#isTweening - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] - */ - isTweening: function (target) - { - var list = this._active; - var tween; - - for (var i = 0; i < list.length; i++) - { - tween = list[i]; - - if (tween.hasTarget(target) && tween.isPlaying()) - { - return true; - } - } - - return false; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#killAll - * @since 3.0.0 - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - killAll: function () - { - var tweens = this.getAllTweens(); - - for (var i = 0; i < tweens.length; i++) - { - tweens[i].stop(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#killTweensOf - * @since 3.0.0 - * - * @param {(object|array)} target - [description] - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - killTweensOf: function (target) - { - var tweens = this.getTweensOf(target); - - for (var i = 0; i < tweens.length; i++) - { - tweens[i].stop(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#pauseAll - * @since 3.0.0 - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - pauseAll: function () - { - var list = this._active; - - for (var i = 0; i < list.length; i++) - { - list[i].pause(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#resumeAll - * @since 3.0.0 - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - resumeAll: function () - { - var list = this._active; - - for (var i = 0; i < list.length; i++) - { - list[i].resume(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.TweenManager#setGlobalTimeScale - * @since 3.0.0 - * - * @param {float} value - [description] - * - * @return {Phaser.Tweens.TweenManager} [description] - */ - setGlobalTimeScale: function (value) - { - this.timeScale = value; - - return 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.Tweens.TweenManager#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.killAll(); - - this._add = []; - this._pending = []; - this._active = []; - 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); - }, - - /** - * 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 - */ - destroy: function () - { - this.shutdown(); - - this.scene.sys.events.off('start', this.start, this); - - this.scene = null; - this.systems = null; - } - -}); - -PluginCache.register('TweenManager', TweenManager, 'tweens'); - -module.exports = TweenManager; - - -/***/ }), -/* 304 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// RESERVED properties that a Tween config object uses - -// completeDelay: The time the tween will wait before the onComplete event is dispatched once it has completed -// delay: The time the tween will wait before it first starts -// duration: The duration of the tween -// ease: The ease function used by the tween -// easeParams: The parameters to go with the ease function (if any) -// flipX: flip X the GameObject on tween end -// flipY: flip Y the GameObject on tween end// hold: The time the tween will pause before running a yoyo -// hold: The time the tween will pause before running a yoyo -// loop: The time the tween will pause before starting either a yoyo or returning to the start for a repeat -// loopDelay: -// offset: Used when the Tween is part of a Timeline -// paused: Does the tween start in a paused state, or playing? -// props: The properties being tweened by the tween -// repeat: The number of times the tween will repeat itself (a value of 1 means the tween will play twice, as it repeated once) -// repeatDelay: The time the tween will pause for before starting a repeat. The tween holds in the start state. -// targets: The targets the tween is updating. -// useFrames: Use frames or milliseconds? -// yoyo: boolean - Does the tween reverse itself (yoyo) when it reaches the end? - -module.exports = [ - 'callbackScope', - 'completeDelay', - 'delay', - 'duration', - 'ease', - 'easeParams', - 'flipX', - 'flipY', - 'hold', - 'loop', - 'loopDelay', - 'offset', - 'onComplete', - 'onCompleteParams', - 'onCompleteScope', - 'onLoop', - 'onLoopParams', - 'onLoopScope', - 'onRepeat', - 'onRepeatParams', - 'onRepeatScope', - 'onStart', - 'onStartParams', - 'onStartScope', - 'onUpdate', - 'onUpdateParams', - 'onUpdateScope', - 'onYoyo', - 'onYoyoParams', - 'onYoyoScope', - 'paused', - 'props', - 'repeat', - 'repeatDelay', - 'targets', - 'useFrames', - 'yoyo' -]; - - -/***/ }), -/* 305 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tweens.Builders - */ - -module.exports = { - - GetBoolean: __webpack_require__(62), - GetEaseFunction: __webpack_require__(63), - GetNewValue: __webpack_require__(73), - GetProps: __webpack_require__(163), - GetTargets: __webpack_require__(102), - GetTweens: __webpack_require__(162), - GetValueOp: __webpack_require__(101), - NumberTweenBuilder: __webpack_require__(161), - TimelineBuilder: __webpack_require__(160), - TweenBuilder: __webpack_require__(72) - -}; - - -/***/ }), -/* 306 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(61); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser.Tweens - */ - -var Tweens = { - - Builders: __webpack_require__(305), - - TweenManager: __webpack_require__(303), - Tween: __webpack_require__(99), - TweenData: __webpack_require__(98), - Timeline: __webpack_require__(159) - -}; - -// Merge in the consts -Tweens = Extend(false, Tweens, CONST); - -module.exports = Tweens; - - -/***/ }), -/* 307 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); -var TimerEvent = __webpack_require__(164); - -/** - * @classdesc - * [description] - * - * @class Clock - * @memberOf Phaser.Time - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var Clock = new Class({ - - initialize: - - function Clock (scene) - { - /** - * [description] - * - * @name Phaser.Time.Clock#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Time.Clock#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * [description] - * - * @name Phaser.Time.Clock#now - * @type {number} - * @since 3.0.0 - */ - this.now = Date.now(); - - // Scale the delta time coming into the Clock by this factor - // which then influences anything using this Clock for calculations, like TimerEvents - - /** - * [description] - * - * @name Phaser.Time.Clock#timeScale - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * [description] - * - * @name Phaser.Time.Clock#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * [description] - * - * @name Phaser.Time.Clock#_active - * @type {Phaser.Time.TimerEvent[]} - * @private - * @default [] - * @since 3.0.0 - */ - this._active = []; - - /** - * [description] - * - * @name Phaser.Time.Clock#_pendingInsertion - * @type {Phaser.Time.TimerEvent[]} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingInsertion = []; - - /** - * [description] - * - * @name Phaser.Time.Clock#_pendingRemoval - * @type {Phaser.Time.TimerEvent[]} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingRemoval = []; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Time.Clock#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.systems.events.once('destroy', this.destroy, 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.Time.Clock#start - * @private - * @since 3.5.0 - */ - start: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#addEvent - * @since 3.0.0 - * - * @param {TimerEventConfig} config - [description] - * - * @return {Phaser.Time.TimerEvent} [description] - */ - addEvent: function (config) - { - var event = new TimerEvent(config); - - this._pendingInsertion.push(event); - - return event; - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#delayedCall - * @since 3.0.0 - * - * @param {number} delay - [description] - * @param {function} callback - [description] - * @param {Array.<*>} args - [description] - * @param {*} callbackScope - [description] - * - * @return {Phaser.Time.TimerEvent} [description] - */ - delayedCall: function (delay, callback, args, callbackScope) - { - return this.addEvent({ delay: delay, callback: callback, args: args, callbackScope: callbackScope }); - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#clearPendingEvents - * @since 3.0.0 - * - * @return {Phaser.Time.Clock} [description] - */ - clearPendingEvents: function () - { - this._pendingInsertion = []; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#removeAllEvents - * @since 3.0.0 - * - * @return {Phaser.Time.Clock} [description] - */ - removeAllEvents: function () - { - this._pendingRemoval = this._pendingRemoval.concat(this._active); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#preUpdate - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - preUpdate: function () - { - var toRemove = this._pendingRemoval.length; - var toInsert = this._pendingInsertion.length; - - if (toRemove === 0 && toInsert === 0) - { - // Quick bail - return; - } - - var i; - var event; - - // Delete old events - for (i = 0; i < toRemove; i++) - { - event = this._pendingRemoval[i]; - - var index = this._active.indexOf(event); - - if (index > -1) - { - this._active.splice(index, 1); - } - - // Pool them? - event.destroy(); - } - - for (i = 0; i < toInsert; i++) - { - event = this._pendingInsertion[i]; - - this._active.push(event); - } - - // Clear the lists - this._pendingRemoval.length = 0; - this._pendingInsertion.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Time.Clock#update - * @since 3.0.0 - * - * @param {number} time - [description] - * @param {number} delta - [description] - */ - update: function (time, delta) - { - this.now = time; - - if (this.paused) - { - return; - } - - delta *= this.timeScale; - - for (var i = 0; i < this._active.length; i++) - { - var event = this._active[i]; - - if (event.paused) - { - continue; - } - - // Use delta time to increase elapsed. - // Avoids needing to adjust for pause / resume. - // Automatically smoothed by TimeStep class. - // In testing accurate to +- 1ms! - event.elapsed += delta * event.timeScale; - - if (event.elapsed >= event.delay) - { - var remainder = event.elapsed - event.delay; - - // Limit it, in case it's checked in the callback - event.elapsed = event.delay; - - // Process the event - if (!event.hasDispatched && event.callback) - { - event.hasDispatched = true; - event.callback.apply(event.callbackScope, event.args); - } - - if (event.repeatCount > 0) - { - event.repeatCount--; - - event.elapsed = remainder; - event.hasDispatched = false; - } - else - { - this._pendingRemoval.push(event); - } - } - } - }, - - /** - * 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 () - { - var i; - - for (i = 0; i < this._pendingInsertion.length; i++) - { - this._pendingInsertion[i].destroy(); - } - - for (i = 0; i < this._active.length; i++) - { - this._active[i].destroy(); - } - - for (i = 0; i < this._pendingRemoval.length; i++) - { - this._pendingRemoval[i].destroy(); - } - - 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); - }, - - /** - * 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.sys.events.off('start', this.start, this); - - this.scene = null; - this.systems = null; - } - -}); - -PluginCache.register('Clock', Clock, 'time'); - -module.exports = Clock; - - -/***/ }), -/* 308 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Time - */ - -module.exports = { - - Clock: __webpack_require__(307), - TimerEvent: __webpack_require__(164) - -}; - - -/***/ }), -/* 309 */, -/* 310 */, -/* 311 */, -/* 312 */, -/* 313 */, -/* 314 */, -/* 315 */, -/* 316 */, -/* 317 */, -/* 318 */, -/* 319 */, -/* 320 */, -/* 321 */, -/* 322 */, -/* 323 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Filter Types. - * - * @name Phaser.Textures.FilterMode - * @enum {integer} - * @memberOf Phaser.Textures - * @readOnly - * @since 3.0.0 - */ -var CONST = { - - /** - * Linear filter type. - * - * @name Phaser.Textures.FilterMode.LINEAR - */ - LINEAR: 0, - - /** - * Nearest neighbor filter type. - * - * @name Phaser.Textures.FilterMode.NEAREST - */ - NEAREST: 1 - -}; - -module.exports = CONST; - - -/***/ }), -/* 324 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Extend = __webpack_require__(17); -var FilterMode = __webpack_require__(323); - -/** - * @namespace Phaser.Textures - */ - -/** - * Linear filter type. - * - * @name Phaser.Textures.LINEAR - * @constant - */ - -/** - * Nearest Neighbor filter type. - * - * @name Phaser.Textures.NEAREST - * @constant - */ - -var Textures = { - - FilterMode: FilterMode, - Frame: __webpack_require__(128), - Parsers: __webpack_require__(182), - Texture: __webpack_require__(117), - TextureManager: __webpack_require__(184), - TextureSource: __webpack_require__(183) - -}; - -Textures = Extend(false, Textures, FilterMode); - -module.exports = Textures; - - -/***/ }), -/* 325 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Structs - */ - -module.exports = { - - List: __webpack_require__(93), - Map: __webpack_require__(124), - ProcessQueue: __webpack_require__(223), - RTree: __webpack_require__(222), - Set: __webpack_require__(70) - -}; - - -/***/ }), -/* 326 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Sound - */ - -/** - * Config object containing various sound settings. - * - * @typedef {object} SoundConfig - * - * @property {boolean} [mute=false] - Boolean indicating whether the sound should be muted or not. - * @property {number} [volume=1] - A value between 0 (silence) and 1 (full volume). - * @property {number} [rate=1] - Defines the speed at which the sound should be played. - * @property {number} [detune=0] - Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * @property {number} [seek=0] - Position of playback for this sound, in seconds. - * @property {boolean} [loop=false] - Whether or not the sound or current sound marker should loop. - * @property {number} [delay=0] - Time, in seconds, that should elapse before the sound actually starts its playback. - */ - -/** - * Marked section of a sound represented by name, and optionally start time, duration, and config object. - * - * @typedef {object} SoundMarker - * - * @property {string} name - Unique identifier of a sound marker. - * @property {number} [start=0] - Sound position offset at witch playback should start. - * @property {number} [duration] - Playback duration of this marker. - * @property {SoundConfig} [config] - An optional config object containing default marker settings. - */ - -module.exports = { - - SoundManagerCreator: __webpack_require__(191), - - BaseSound: __webpack_require__(78), - BaseSoundManager: __webpack_require__(79), - - WebAudioSound: __webpack_require__(185), - WebAudioSoundManager: __webpack_require__(186), - - HTML5AudioSound: __webpack_require__(189), - HTML5AudioSoundManager: __webpack_require__(190), - - NoAudioSound: __webpack_require__(187), - NoAudioSoundManager: __webpack_require__(188) - -}; - - -/***/ }), -/* 327 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(55); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * A proxy class to the Global Scene Manager. - * - * @class ScenePlugin - * @memberOf Phaser.Scenes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene that this ScenePlugin belongs to. - */ -var ScenePlugin = new Class({ - - initialize: - - function ScenePlugin (scene) - { - /** - * The Scene that this ScenePlugin belongs to. - * - * @name Phaser.Scenes.ScenePlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * The Scene Systems instance of the Scene that this ScenePlugin belongs to. - * - * @name Phaser.Scenes.ScenePlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * The settings of the Scene this ScenePlugin belongs to. - * - * @name Phaser.Scenes.ScenePlugin#settings - * @type {Phaser.Scenes.Settings.Object} - * @since 3.0.0 - */ - this.settings = scene.sys.settings; - - /** - * The key of the Scene this ScenePlugin belongs to. - * - * @name Phaser.Scenes.ScenePlugin#key - * @type {string} - * @since 3.0.0 - */ - this.key = scene.sys.settings.key; - - /** - * The Game's SceneManager. - * - * @name Phaser.Scenes.ScenePlugin#manager - * @type {Phaser.Scenes.SceneManager} - * @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.once('boot', this.boot, this); - scene.sys.events.on('start', this.pluginStart, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Scenes.ScenePlugin#boot - * @private - * @since 3.0.0 - */ - boot: function () - { - this.systems.events.once('destroy', this.destroy, 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.Scenes.ScenePlugin#pluginStart - * @private - * @since 3.5.0 - */ - pluginStart: function () - { - this._target = null; - - this.systems.events.once('shutdown', this.shutdown, this); - }, - - /** - * Shutdown this Scene and run the given one. - * - * @method Phaser.Scenes.ScenePlugin#start - * @since 3.0.0 - * - * @param {string} key - The Scene to start. - * @param {object} [data] - The Scene data. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - start: function (key, data) - { - if (key === undefined) { key = this.key; } - - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', this.key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(this.key); - this.manager.start(key, data); - } - - return this; - }, - - /** - * Restarts this Scene. - * - * @method Phaser.Scenes.ScenePlugin#restart - * @since 3.4.0 - * - * @param {object} [data] - The Scene data. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - restart: function (data) - { - var key = this.key; - - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(key); - this.manager.start(key, data); - } - - 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] - Move the target Scene to be above this one before the transition starts. - * @property {boolean} [moveBelow] - Move 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, GetFastValue(config, 'data')); - } - - 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. - * - * @method Phaser.Scenes.ScenePlugin#add - * @since 3.0.0 - * - * @param {string} key - The Scene key. - * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The config for the Scene. - * @param {boolean} autoStart - Whether to start the Scene after it's added. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - add: function (key, sceneConfig, autoStart) - { - this.manager.add(key, sceneConfig, autoStart); - - return this; - }, - - /** - * Launch the given Scene and run it in parallel with this one. - * - * @method Phaser.Scenes.ScenePlugin#launch - * @since 3.0.0 - * - * @param {string} key - The Scene to launch. - * @param {object} [data] - The Scene data. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - launch: function (key, data) - { - if (key && key !== this.key) - { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('start', key, data); - } - else - { - this.manager.start(key, data); - } - } - - return this; - }, - - /** - * Runs the given Scene, but does not change the state of this Scene. - * - * If the given Scene is paused, it will resume it. If sleeping, it will wake it. - * If not running at all, it will be started. - * - * Use this if you wish to open a modal Scene by calling `pause` on the current - * Scene, then `run` on the modal Scene. - * - * @method Phaser.Scenes.ScenePlugin#run - * @since 3.10.0 - * - * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - run: function (key, data) - { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('run', key, data); - } - else - { - this.manager.run(key, data); - } - - return this; - }, - - /** - * Pause the Scene - this stops the update step from happening but it still renders. - * - * @method Phaser.Scenes.ScenePlugin#pause - * @since 3.0.0 - * - * @param {string} key - The Scene to pause. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - pause: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.pause(key); - - return this; - }, - - /** - * Resume the Scene - starts the update loop again. - * - * @method Phaser.Scenes.ScenePlugin#resume - * @since 3.0.0 - * - * @param {string} key - The Scene to resume. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - resume: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.resume(key); - - return this; - }, - - /** - * Makes the Scene sleep (no update, no render) but doesn't shutdown. - * - * @method Phaser.Scenes.ScenePlugin#sleep - * @since 3.0.0 - * - * @param {string} key - The Scene to put to sleep. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - sleep: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.sleep(key); - - return this; - }, - - /** - * Makes the Scene wake-up (starts update and render) - * - * @method Phaser.Scenes.ScenePlugin#wake - * @since 3.0.0 - * - * @param {string} key - The Scene to wake up. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - wake: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.wake(key); - - return this; - }, - - /** - * Makes this Scene sleep then starts the Scene given. - * - * @method Phaser.Scenes.ScenePlugin#switch - * @since 3.0.0 - * - * @param {string} key - The Scene to start. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - switch: function (key) - { - if (key !== this.key) - { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('switch', this.key, key); - } - else - { - this.manager.switch(this.key, key); - } - } - - return this; - }, - - /** - * Shutdown the Scene, clearing display list, timers, etc. - * - * @method Phaser.Scenes.ScenePlugin#stop - * @since 3.0.0 - * - * @param {string} key - The Scene to stop. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - stop: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.stop(key); - - return this; - }, - - /** - * Sets the active state of the given Scene. - * - * @method Phaser.Scenes.ScenePlugin#setActive - * @since 3.0.0 - * - * @param {boolean} value - The active value. - * @param {string} [key] - The Scene to set the active state for. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - setActive: function (value, key) - { - if (key === undefined) { key = this.key; } - - var scene = this.manager.getScene(key); - - if (scene) - { - scene.sys.setActive(value); - } - - return this; - }, - - /** - * Sets the visible state of the given Scene. - * - * @method Phaser.Scenes.ScenePlugin#setVisible - * @since 3.0.0 - * - * @param {boolean} value - The visible value. - * @param {string} [key] - The Scene to set the visible state for. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - setVisible: function (value, key) - { - if (key === undefined) { key = this.key; } - - var scene = this.manager.getScene(key); - - if (scene) - { - scene.sys.setVisible(value); - } - - return this; - }, - - /** - * Checks if the given Scene is sleeping or not? - * - * @method Phaser.Scenes.ScenePlugin#isSleeping - * @since 3.0.0 - * - * @param {string} key - The Scene to check. - * - * @return {boolean} Whether the Scene is sleeping. - */ - isSleeping: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.isSleeping(key); - }, - - /** - * Checks if the given Scene is active or not? - * - * @method Phaser.Scenes.ScenePlugin#isActive - * @since 3.0.0 - * - * @param {string} key - The Scene to check. - * - * @return {boolean} Whether the Scene is active. - */ - isActive: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.isActive(key); - }, - - /** - * Checks if the given Scene is visible or not? - * - * @method Phaser.Scenes.ScenePlugin#isVisible - * @since 3.0.0 - * - * @param {string} key - The Scene to check. - * - * @return {boolean} Whether the Scene is visible. - */ - isVisible: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.isVisible(key); - }, - - /** - * Swaps the position of two scenes in the Scenes list. - * - * This controls the order in which they are rendered and updated. - * - * @method Phaser.Scenes.ScenePlugin#swapPosition - * @since 3.2.0 - * - * @param {string} keyA - The first Scene to swap. - * @param {string} [keyB] - The second Scene to swap. If none is given it defaults to this Scene. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - swapPosition: function (keyA, keyB) - { - if (keyB === undefined) { keyB = this.key; } - - if (keyA !== keyB) - { - this.manager.swapPosition(keyA, keyB); - } - - return this; - }, - - /** - * Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A. - * - * This controls the order in which they are rendered and updated. - * - * @method Phaser.Scenes.ScenePlugin#moveAbove - * @since 3.2.0 - * - * @param {string} keyA - The Scene that Scene B will be moved to be above. - * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveAbove: function (keyA, keyB) - { - if (keyB === undefined) { keyB = this.key; } - - if (keyA !== keyB) - { - this.manager.moveAbove(keyA, keyB); - } - - return this; - }, - - /** - * Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A. - * - * This controls the order in which they are rendered and updated. - * - * @method Phaser.Scenes.ScenePlugin#moveBelow - * @since 3.2.0 - * - * @param {string} keyA - The Scene that Scene B will be moved to be below. - * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveBelow: function (keyA, keyB) - { - if (keyB === undefined) { keyB = this.key; } - - if (keyA !== keyB) - { - this.manager.moveBelow(keyA, keyB); - } - - return this; - }, - - /** - * Removes a Scene from the SceneManager. - * - * The Scene is removed from the local scenes array, it's key is cleared from the keys - * cache and Scene.Systems.destroy is then called on it. - * - * If the SceneManager is processing the Scenes when this method is called it wil - * queue the operation for the next update sequence. - * - * @method Phaser.Scenes.ScenePlugin#remove - * @since 3.2.0 - * - * @param {(string|Phaser.Scene)} key - The Scene to be removed. - * - * @return {Phaser.Scenes.SceneManager} This SceneManager. - */ - remove: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.remove(key); - - return this; - }, - - /** - * Moves a Scene up one position in the Scenes list. - * - * @method Phaser.Scenes.ScenePlugin#moveUp - * @since 3.0.0 - * - * @param {string} key - The Scene to move. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveUp: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.moveUp(key); - - return this; - }, - - /** - * Moves a Scene down one position in the Scenes list. - * - * @method Phaser.Scenes.ScenePlugin#moveDown - * @since 3.0.0 - * - * @param {string} key - The Scene to move. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - moveDown: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.moveDown(key); - - return this; - }, - - /** - * Brings a Scene to the top of the Scenes list. - * - * This means it will render above all other Scenes. - * - * @method Phaser.Scenes.ScenePlugin#bringToTop - * @since 3.0.0 - * - * @param {string} key - The Scene to move. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - bringToTop: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.bringToTop(key); - - return this; - }, - - /** - * Sends a Scene to the back of the Scenes list. - * - * This means it will render below all other Scenes. - * - * @method Phaser.Scenes.ScenePlugin#sendToBack - * @since 3.0.0 - * - * @param {string} key - The Scene to move. - * - * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. - */ - sendToBack: function (key) - { - if (key === undefined) { key = this.key; } - - this.manager.sendToBack(key); - - return this; - }, - - /** - * Retrieve a Scene. - * - * @method Phaser.Scenes.ScenePlugin#get - * @since 3.0.0 - * - * @param {string} key - The Scene to retrieve. - * - * @return {Phaser.Scene} The Scene. - */ - get: function (key) - { - return this.manager.getScene(key); - }, - - /** - * Retrieves the numeric index of a Scene in the Scenes list. - * - * @method Phaser.Scenes.ScenePlugin#getIndex - * @since 3.7.0 - * - * @param {(string|Phaser.Scene)} [key] - The Scene to get the index of. - * - * @return {integer} The index of the Scene. - */ - getIndex: function (key) - { - if (key === undefined) { key = this.key; } - - return this.manager.getIndex(key); - }, - - /** - * 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 () - { - var eventEmitter = this.systems.events; - - eventEmitter.off('shutdown', this.shutdown, this); - eventEmitter.off('postupdate', this.step, this); - eventEmitter.off('transitionout'); - }, - - /** - * 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 () - { - this.shutdown(); - - this.scene.sys.events.off('start', this.start, this); - - this.scene = null; - this.systems = null; - this.settings = null; - this.manager = null; - } - -}); - -PluginCache.register('ScenePlugin', ScenePlugin, 'scenePlugin'); - -module.exports = ScenePlugin; - - -/***/ }), -/* 328 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(55); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser.Scenes - */ - -var Scene = { - - SceneManager: __webpack_require__(194), - ScenePlugin: __webpack_require__(327), - Settings: __webpack_require__(192), - Systems: __webpack_require__(118) - -}; - -// Merge in the consts -Scene = Extend(false, Scene, CONST); - -module.exports = Scene; - - -/***/ }), -/* 329 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* @author Richard Davey -* @copyright 2018 Photon Storm Ltd. -* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} -*/ - -var BasePlugin = __webpack_require__(165); -var Class = __webpack_require__(0); - -/** - * @classdesc - * A Scene Level Plugin is installed into every Scene and belongs to that Scene. - * It can listen for Scene events and respond to them. - * It can map itself to a Scene property, or into the Scene Systems, or both. - * - * @class ScenePlugin - * @memberOf Phaser.Plugins - * @extends Phaser.Plugins.BasePlugin - * @constructor - * @since 3.8.0 - * - * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. - * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager. - */ -var ScenePlugin = new Class({ - - Extends: BasePlugin, - - initialize: - - function ScenePlugin (scene, pluginManager) - { - BasePlugin.call(this, pluginManager); - - /** - * A reference to the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * - * @name Phaser.Plugins.ScenePlugin#scene - * @type {?Phaser.Scene} - * @protected - * @since 3.8.0 - */ - this.scene = scene; - - /** - * A reference to the Scene Systems of the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * - * @name Phaser.Plugins.ScenePlugin#systems - * @type {?Phaser.Scenes.Systems} - * @protected - * @since 3.8.0 - */ - this.systems = scene.sys; - - scene.sys.events.once('boot', this.boot, this); - }, - - /** - * This method is called when the Scene boots. It is only ever called once. - * - * By this point the plugin properties `scene` and `systems` will have already been set. - * - * In here you can listen for Scene events and set-up whatever you need for this plugin to run. - * Here are the Scene events you can listen to: - * - * start - * ready - * preupdate - * update - * postupdate - * resize - * pause - * resume - * sleep - * wake - * transitioninit - * transitionstart - * transitioncomplete - * transitionout - * shutdown - * destroy - * - * At the very least you should offer a destroy handler for when the Scene closes down, i.e: - * - * ```javascript - * var eventEmitter = this.systems.events; - * eventEmitter.once('destroy', this.sceneDestroy, this); - * ``` - * - * @method Phaser.Plugins.ScenePlugin#boot - * @since 3.8.0 - */ - boot: function () - { - } - -}); - -module.exports = ScenePlugin; - - -/***/ }), -/* 330 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Plugins - */ - -module.exports = { - - BasePlugin: __webpack_require__(165), - DefaultPlugins: __webpack_require__(121), - PluginCache: __webpack_require__(12), - PluginManager: __webpack_require__(196), - ScenePlugin: __webpack_require__(329) - -}; - - -/***/ }), -/* 331 */, -/* 332 */, -/* 333 */, -/* 334 */, -/* 335 */, -/* 336 */, -/* 337 */, -/* 338 */, -/* 339 */, -/* 340 */, -/* 341 */, -/* 342 */, -/* 343 */, -/* 344 */, -/* 345 */, -/* 346 */, -/* 347 */, -/* 348 */, -/* 349 */, -/* 350 */, -/* 351 */, -/* 352 */, -/* 353 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var CustomSet = __webpack_require__(70); -var EventEmitter = __webpack_require__(9); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); -var XHRSettings = __webpack_require__(75); - -/** - * @classdesc - * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. - * You typically interact with it via `this.load` in your Scene. Scenes can have a `preload` method, which is always - * called before the Scenes `create` method, allowing you to preload assets that the Scene may need. - * - * If you call any `this.load` methods from outside of `Scene.preload` then you need to start the Loader going - * yourself by calling `Loader.start()`. It's only automatically started during the Scene preload. - * - * The Loader uses a combination of tag loading (eg. Audio elements) and XHR and provides progress and completion events. - * Files are loaded in parallel by default. The amount of concurrent connections can be controlled in your Game Configuration. - * - * Once the Loader has started loading you are still able to add files to it. These can be injected as a result of a loader - * event, the type of file being loaded (such as a pack file) or other external events. As long as the Loader hasn't finished - * simply adding a new file to it, while running, will ensure it's added into the current queue. - * - * Every Scene has its own instance of the Loader and they are bound to the Scene in which they are created. However, - * assets loaded by the Loader are placed into global game-level caches. For example, loading an XML file will place that - * file inside `Game.cache.xml`, which is accessible from every Scene in your game, no matter who was responsible - * for loading it. The same is true of Textures. A texture loaded in one Scene is instantly available to all other Scenes - * in your game. - * - * The Loader works by using custom File Types. These are stored in the FileTypesManager, which injects them into the Loader - * when it's instantiated. You can create your own custom file types by extending either the File or MultiFile classes. - * See those files for more details. - * - * @class LoaderPlugin - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Loader - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene which owns this Loader instance. - */ -var LoaderPlugin = new Class({ - - Extends: EventEmitter, - - initialize: - - function LoaderPlugin (scene) - { - EventEmitter.call(this); - - var gameConfig = scene.sys.game.config; - var sceneConfig = scene.sys.settings.loader; - - /** - * The Scene which owns this Loader instance. - * - * @name Phaser.Loader.LoaderPlugin#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene Systems. - * - * @name Phaser.Loader.LoaderPlugin#systems - * @type {Phaser.Scenes.Systems} - * @protected - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * A reference to the global Cache Manager. - * - * @name Phaser.Loader.LoaderPlugin#cacheManager - * @type {Phaser.Cache.CacheManager} - * @protected - * @since 3.7.0 - */ - this.cacheManager = scene.sys.cache; - - /** - * A reference to the global Texture Manager. - * - * @name Phaser.Loader.LoaderPlugin#textureManager - * @type {Phaser.Textures.TextureManager} - * @protected - * @since 3.7.0 - */ - this.textureManager = scene.sys.textures; - - // Inject the available filetypes into the Loader - FileTypesManager.install(this); - - /** - * An optional prefix that is automatically prepended to the start of every file key. - * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. - * You can set this directly, or call `Loader.setPrefix()`. It will then affect every file added to the Loader - * from that point on. It does _not_ change any file already in the load queue. - * - * @name Phaser.Loader.LoaderPlugin#prefix - * @type {string} - * @default '' - * @since 3.7.0 - */ - this.prefix = ''; - - /** - * The value of `path`, if set, is placed before any _relative_ file path given. For example: - * - * ```javascript - * this.load.path = "images/sprites/"; - * this.load.image("ball", "ball.png"); - * this.load.image("tree", "level1/oaktree.png"); - * this.load.image("boom", "http://server.com/explode.png"); - * ``` - * - * Would load the `ball` file from `images/sprites/ball.png` and the tree from - * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL - * given as it's an absolute URL. - * - * Please note that the path is added before the filename but *after* the baseURL (if set.) - * - * If you set this property directly then it _must_ end with a "/". Alternatively, call `setPath()` and it'll do it for you. - * - * @name Phaser.Loader.LoaderPlugin#path - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.path = ''; - - /** - * If you want to append a URL before the path of any asset you can set this here. - * - * Useful if allowing the asset base url to be configured outside of the game code. - * - * If you set this property directly then it _must_ end with a "/". Alternatively, call `setBaseURL()` and it'll do it for you. - * - * @name Phaser.Loader.LoaderPlugin#baseURL - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.baseURL = ''; - - this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); - - this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); - - this.setPrefix(GetFastValue(sceneConfig, 'prefix', gameConfig.loaderPrefix)); - - /** - * The number of concurrent / parallel resources to try and fetch at once. - * - * Old browsers limit 6 requests per domain; modern ones, especially those with HTTP/2 don't limit it at all. - * - * The default is 32 but you can change this in your Game Config, or by changing this property before the Loader starts. - * - * @name Phaser.Loader.LoaderPlugin#maxParallelDownloads - * @type {integer} - * @since 3.0.0 - */ - this.maxParallelDownloads = GetFastValue(sceneConfig, 'maxParallelDownloads', gameConfig.loaderMaxParallelDownloads); - - /** - * xhr specific global settings (can be overridden on a per-file basis) - * - * @name Phaser.Loader.LoaderPlugin#xhr - * @type {XHRSettingsObject} - * @since 3.0.0 - */ - this.xhr = XHRSettings( - GetFastValue(sceneConfig, 'responseType', gameConfig.loaderResponseType), - GetFastValue(sceneConfig, 'async', gameConfig.loaderAsync), - GetFastValue(sceneConfig, 'user', gameConfig.loaderUser), - GetFastValue(sceneConfig, 'password', gameConfig.loaderPassword), - GetFastValue(sceneConfig, 'timeout', gameConfig.loaderTimeout) - ); - - /** - * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. - * - * @name Phaser.Loader.LoaderPlugin#crossOrigin - * @type {string} - * @since 3.0.0 - */ - this.crossOrigin = GetFastValue(sceneConfig, 'crossOrigin', gameConfig.loaderCrossOrigin); - - /** - * The total number of files to load. It may not always be accurate because you may add to the Loader during the process - * of loading, especially if you load a Pack File. Therefore this value can change, but in most cases remains static. - * - * @name Phaser.Loader.LoaderPlugin#totalToLoad - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.totalToLoad = 0; - - /** - * The progress of the current load queue, as a float value between 0 and 1. - * This is updated automatically as files complete loading. - * Note that it is possible for this value to go down again if you add content to the current load queue during a load. - * - * @name Phaser.Loader.LoaderPlugin#progress - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * Files are placed in this Set when they're added to the Loader via `addFile`. - * - * They are moved to the `inflight` Set when they start loading, and assuming a successful - * load, to the `queue` Set for further processing. - * - * By the end of the load process this Set will be empty. - * - * @name Phaser.Loader.LoaderPlugin#list - * @type {Phaser.Structs.Set.} - * @since 3.0.0 - */ - this.list = new CustomSet(); - - /** - * Files are stored in this Set while they're in the process of being loaded. - * - * Upon a successful load they are moved to the `queue` Set. - * - * By the end of the load process this Set will be empty. - * - * @name Phaser.Loader.LoaderPlugin#inflight - * @type {Phaser.Structs.Set.} - * @since 3.0.0 - */ - this.inflight = new CustomSet(); - - /** - * Files are stored in this Set while they're being processed. - * - * If the process is successful they are moved to their final destination, which could be - * a Cache or the Texture Manager. - * - * At the end of the load process this Set will be empty. - * - * @name Phaser.Loader.LoaderPlugin#queue - * @type {Phaser.Structs.Set.} - * @since 3.0.0 - */ - this.queue = new CustomSet(); - - /** - * A temporary Set in which files are stored after processing, - * awaiting destruction at the end of the load process. - * - * @name Phaser.Loader.LoaderPlugin#_deleteQueue - * @type {Phaser.Structs.Set.} - * @private - * @since 3.7.0 - */ - this._deleteQueue = new CustomSet(); - - /** - * The total number of files that failed to load during the most recent load. - * This value is reset when you call `Loader.start`. - * - * @name Phaser.Loader.LoaderPlugin#totalFailed - * @type {integer} - * @default 0 - * @since 3.7.0 - */ - this.totalFailed = 0; - - /** - * The total number of files that successfully loaded during the most recent load. - * This value is reset when you call `Loader.start`. - * - * @name Phaser.Loader.LoaderPlugin#totalComplete - * @type {integer} - * @default 0 - * @since 3.7.0 - */ - this.totalComplete = 0; - - /** - * The current state of the Loader. - * - * @name Phaser.Loader.LoaderPlugin#state - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.state = CONST.LOADER_IDLE; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.pluginStart, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Loader.LoaderPlugin#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.systems.events.once('destroy', this.destroy, 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.Loader.LoaderPlugin#pluginStart - * @private - * @since 3.5.1 - */ - pluginStart: function () - { - this.systems.events.once('shutdown', this.shutdown, this); - }, - - /** - * If you want to append a URL before the path of any asset you can set this here. - * - * Useful if allowing the asset base url to be configured outside of the game code. - * - * Once a base URL is set it will affect every file loaded by the Loader from that point on. It does _not_ change any - * file _already_ being loaded. To reset it, call this method with no arguments. - * - * @method Phaser.Loader.LoaderPlugin#setBaseURL - * @since 3.0.0 - * - * @param {string} [url] - The URL to use. Leave empty to reset. - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setBaseURL: function (url) - { - if (url === undefined) { url = ''; } - - if (url !== '' && url.substr(-1) !== '/') - { - url = url.concat('/'); - } - - this.baseURL = url; - - return this; - }, - - /** - * The value of `path`, if set, is placed before any _relative_ file path given. For example: - * - * ```javascript - * this.load.setPath("images/sprites/"); - * this.load.image("ball", "ball.png"); - * this.load.image("tree", "level1/oaktree.png"); - * this.load.image("boom", "http://server.com/explode.png"); - * ``` - * - * Would load the `ball` file from `images/sprites/ball.png` and the tree from - * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL - * given as it's an absolute URL. - * - * Please note that the path is added before the filename but *after* the baseURL (if set.) - * - * Once a path is set it will then affect every file added to the Loader from that point on. It does _not_ change any - * file _already_ in the load queue. To reset it, call this method with no arguments. - * - * @method Phaser.Loader.LoaderPlugin#setPath - * @since 3.0.0 - * - * @param {string} [path] - The path to use. Leave empty to reset. - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setPath: function (path) - { - if (path === undefined) { path = ''; } - - if (path !== '' && path.substr(-1) !== '/') - { - path = path.concat('/'); - } - - this.path = path; - - return this; - }, - - /** - * An optional prefix that is automatically prepended to the start of every file key. - * - * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. - * - * Once a prefix is set it will then affect every file added to the Loader from that point on. It does _not_ change any - * file _already_ in the load queue. To reset it, call this method with no arguments. - * - * @method Phaser.Loader.LoaderPlugin#setPrefix - * @since 3.7.0 - * - * @param {string} [prefix] - The prefix to use. Leave empty to reset. - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setPrefix: function (prefix) - { - if (prefix === undefined) { prefix = ''; } - - this.prefix = prefix; - - return this; - }, - - /** - * Sets the Cross Origin Resource Sharing value used when loading files. - * - * Files can override this value on a per-file basis by specifying an alternative `crossOrigin` value in their file config. - * - * Once CORs is set it will then affect every file loaded by the Loader from that point on, as long as they don't have - * their own CORs setting. To reset it, call this method with no arguments. - * - * For more details about CORs see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS - * - * @method Phaser.Loader.LoaderPlugin#setCORS - * @since 3.0.0 - * - * @param {string} [crossOrigin] - The value to use for the `crossOrigin` property in the load request. - * - * @return {Phaser.Loader.LoaderPlugin} This Loader object. - */ - setCORS: function (crossOrigin) - { - this.crossOrigin = crossOrigin; - - return this; - }, - - /** - * This event is fired when a Loader successfully begins to load its queue. - * - * @event Phaser.Loader.LoaderPlugin#addFileEvent - * @param {string} key - The key of the file that was added. - * @param {string} type - The type of the file that was added. - * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that had the file added to it. - * @param {Phaser.Loader.File} loader - The File object that was added to the Loader. - */ - - /** - * Adds a file, or array of files, into the load queue. - * - * The file must be an instance of `Phaser.Loader.File`, or a class that extends it. The Loader will check that the key - * used by the file won't conflict with any other key either in the loader, the inflight queue or the target cache. - * If allowed it will then add the file into the pending list, read for the load to start. Or, if the load has already - * started, ready for the next batch of files to be pulled from the list to the inflight queue. - * - * You should not normally call this method directly, but rather use one of the Loader methods like `image` or `atlas`, - * however you can call this as long as the file given to it is well formed. - * - * @method Phaser.Loader.LoaderPlugin#addFile - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(Phaser.Loader.File|Phaser.Loader.File[])} file - The file, or array of files, to be added to the load queue. - */ - addFile: function (file) - { - if (!Array.isArray(file)) - { - file = [ file ]; - } - - for (var i = 0; i < file.length; i++) - { - var item = file[i]; - - // Does the file already exist in the cache or texture manager? - // Or will it conflict with a file already in the queue or inflight? - if (!this.keyExists(item)) - { - this.list.set(item); - - this.emit('addfile', item.key, item.type, this, item); - - if (this.isLoading()) - { - this.totalToLoad++; - this.updateProgress(); - } - } - } - }, - - /** - * Checks the key and type of the given file to see if it will conflict with anything already - * in a Cache, the Texture Manager, or the list or inflight queues. - * - * @method Phaser.Loader.LoaderPlugin#keyExists - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The file to check the key of. - * - * @return {boolean} `true` if adding this file will cause a cache or queue conflict, otherwise `false`. - */ - keyExists: function (file) - { - var keyConflict = file.hasCacheConflict(); - - if (!keyConflict) - { - this.list.iterate(function (item) - { - if (item.type === file.type && item.key === file.key) - { - keyConflict = true; - - return false; - } - - }); - } - - if (!keyConflict && this.isLoading()) - { - this.inflight.iterate(function (item) - { - if (item.type === file.type && item.key === file.key) - { - keyConflict = true; - - return false; - } - - }); - - this.queue.iterate(function (item) - { - if (item.type === file.type && item.key === file.key) - { - keyConflict = true; - - return false; - } - - }); - } - - return keyConflict; - }, - - /** - * Takes a well formed, fully parsed pack file object and adds its entries into the load queue. Usually you do not call - * this method directly, but instead use `Loader.pack` and supply a path to a JSON file that holds the - * pack data. However, if you've got the data prepared you can pass it to this method. - * - * You can also provide an optional key. If you do then it will only add the entries from that part of the pack into - * to the load queue. If not specified it will add all entries it finds. For more details about the pack file format - * see the `LoaderPlugin.pack` method. - * - * @method Phaser.Loader.LoaderPlugin#addPack - * @since 3.7.0 - * - * @param {any} data - The Pack File data to be parsed and each entry of it to added to the load queue. - * @param {string} [packKey] - An optional key to use from the pack file data. - * - * @return {boolean} `true` if any files were added to the queue, otherwise `false`. - */ - addPack: function (pack, packKey) - { - // if no packKey provided we'll add everything to the queue - if (packKey && pack.hasOwnProperty(packKey)) - { - pack = { packKey: pack[packKey] }; - } - - var total = 0; - - // Store the loader settings in case this pack replaces them - var currentBaseURL = this.baseURL; - var currentPath = this.path; - var currentPrefix = this.prefix; - - // Here we go ... - for (var key in pack) - { - var config = pack[key]; - - // Any meta data to process? - var baseURL = GetFastValue(config, 'baseURL', currentBaseURL); - var path = GetFastValue(config, 'path', currentPath); - var prefix = GetFastValue(config, 'prefix', currentPrefix); - var files = GetFastValue(config, 'files', null); - var defaultType = GetFastValue(config, 'defaultType', 'void'); - - if (Array.isArray(files)) - { - this.setBaseURL(baseURL); - this.setPath(path); - this.setPrefix(prefix); - - for (var i = 0; i < files.length; i++) - { - var file = files[i]; - var type = (file.hasOwnProperty('type')) ? file.type : defaultType; - - if (this[type]) - { - this[type](file); - total++; - } - } - } - } - - // Reset the loader settings - this.setBaseURL(currentBaseURL); - this.setPath(currentPath); - this.setPrefix(currentPrefix); - - return (total > 0); - }, - - /** - * Is the Loader actively loading, or processing loaded files? - * - * @method Phaser.Loader.LoaderPlugin#isLoading - * @since 3.0.0 - * - * @return {boolean} `true` if the Loader is busy loading or processing, otherwise `false`. - */ - isLoading: function () - { - return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING); - }, - - /** - * Is the Loader ready to start a new load? - * - * @method Phaser.Loader.LoaderPlugin#isReady - * @since 3.0.0 - * - * @return {boolean} `true` if the Loader is ready to start a new load, otherwise `false`. - */ - isReady: function () - { - return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE); - }, - - /** - * This event is fired when a Loader successfully begins to load its queue. - * - * @event Phaser.Loader.LoaderPlugin#startEvent - * @param {Phaser.Loader.LoaderPlugin} loader - The Loader instance that started. - */ - - /** - * Starts the Loader running. This will reset the progress and totals and then emit a `start` event. - * If there is nothing in the queue the Loader will immediately complete, otherwise it will start - * loading the first batch of files. - * - * The Loader is started automatically if the queue is populated within your Scenes `preload` method. - * - * However, outside of this, you need to call this method to start it. - * - * If the Loader is already running this method will simply return. - * - * @method Phaser.Loader.LoaderPlugin#start - * @fires Phaser.Loader.LoaderPlugin#startEvent - * @since 3.0.0 - */ - start: function () - { - if (!this.isReady()) - { - return; - } - - this.progress = 0; - - this.totalFailed = 0; - this.totalComplete = 0; - this.totalToLoad = this.list.size; - - this.emit('start', this); - - if (this.list.size === 0) - { - this.loadComplete(); - } - else - { - this.state = CONST.LOADER_LOADING; - - this.inflight.clear(); - this.queue.clear(); - - this.updateProgress(); - - this.checkLoadQueue(); - - this.systems.events.on('update', this.update, this); - } - }, - - /** - * This event is fired when the Loader updates its progress, typically as a result of - * a file having completed loading. - * - * @event Phaser.Loader.LoaderPlugin#progressEvent - * @param {float} progress - The current progress of the load. A value between 0 and 1. - */ - - /** - * Called automatically during the load process. - * It updates the `progress` value and then emits a progress event, which you can use to - * display a loading bar in your game. - * - * @method Phaser.Loader.LoaderPlugin#updateProgress - * @fires Phaser.Loader.LoaderPlugin#progressEvent - * @since 3.0.0 - */ - updateProgress: function () - { - this.progress = 1 - ((this.list.size + this.inflight.size) / this.totalToLoad); - - this.emit('progress', this.progress); - }, - - /** - * Called automatically during the load process. - * - * @method Phaser.Loader.LoaderPlugin#update - * @since 3.10.0 - */ - update: function () - { - if (this.state === CONST.LOADER_LOADING && this.list.size > 0 && this.inflight.size < this.maxParallelDownloads) - { - this.checkLoadQueue(); - } - }, - - /** - * An internal method called by the Loader. - * - * It will check to see if there are any more files in the pending list that need loading, and if so it will move - * them from the list Set into the inflight Set, set their CORs flag and start them loading. - * - * It will carrying on doing this for each file in the pending list until it runs out, or hits the max allowed parallel downloads. - * - * @method Phaser.Loader.LoaderPlugin#checkLoadQueue - * @private - * @since 3.7.0 - */ - checkLoadQueue: function () - { - this.list.each(function (file) - { - if (file.state === CONST.FILE_POPULATED || (file.state === CONST.FILE_PENDING && this.inflight.size < this.maxParallelDownloads)) - { - this.inflight.set(file); - - this.list.delete(file); - - // If the file doesn't have its own crossOrigin set, we'll use the Loaders (which is undefined by default) - if (!file.crossOrigin) - { - file.crossOrigin = this.crossOrigin; - } - - file.load(); - } - - if (this.inflight.size === this.maxParallelDownloads) - { - // Tells the Set iterator to abort - return false; - } - - }, this); - }, - - /** - * This event is fired when the a file successfully completes loading, _before_ it is processed. - * - * @event Phaser.Loader.LoaderPlugin#loadEvent - * @param {Phaser.Loader.File} file - The file that has completed loading. - */ - - /** - * This event is fired when the a file errors during load. - * - * @event Phaser.Loader.LoaderPlugin#loadErrorEvent - * @param {Phaser.Loader.File} file - The file that has failed to load. - */ - - /** - * An internal method called automatically by the XHRLoader belong to a File. - * - * This method will remove the given file from the inflight Set and update the load progress. - * If the file was successful its `onProcess` method is called, otherwise it is added to the delete queue. - * - * @method Phaser.Loader.LoaderPlugin#nextFile - * @fires Phaser.Loader.LoaderPlugin#loadEvent - * @fires Phaser.Loader.LoaderPlugin#loadErrorEvent - * @since 3.0.0 - * - * @param {Phaser.Loader.File} file - The File that just finished loading, or errored during load. - * @param {boolean} success - `true` if the file loaded successfully, otherwise `false`. - */ - nextFile: function (file, success) - { - this.inflight.delete(file); - - this.updateProgress(); - - if (success) - { - this.totalComplete++; - - this.queue.set(file); - - this.emit('load', file); - - file.onProcess(); - } - else - { - this.totalFailed++; - - this._deleteQueue.set(file); - - this.emit('loaderror', file); - } - }, - - /** - * An internal method that is called automatically by the File when it has finished processing. - * - * If the process was successful, and the File isn't part of a MultiFile, its `addToCache` method is called. - * - * It this then removed from the queue. If there are no more files to load `loadComplete` is called. - * - * @method Phaser.Loader.LoaderPlugin#fileProcessComplete - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The file that has finished processing. - */ - fileProcessComplete: function (file) - { - // This file has failed, so move it to the failed Set - if (file.state === CONST.FILE_ERRORED) - { - if (file.multiFile) - { - file.multiFile.onFileFailed(file); - } - } - else if (file.state === CONST.FILE_COMPLETE) - { - if (file.multiFile) - { - if (file.multiFile.isReadyToProcess()) - { - // If we got here then all files the link file needs are ready to add to the cache - file.multiFile.addToCache(); - } - } - else - { - // If we got here, then the file processed, so let it add itself to its cache - file.addToCache(); - } - } - - // Remove it from the queue - this.queue.delete(file); - - // Nothing left to do? - if (this.list.size === 0 && this.inflight.size === 0 && this.queue.size === 0) - { - this.loadComplete(); - } - }, - - /** - * This event is fired when the Loader has finished loading everything and the queue is empty. - * By this point every loaded file will now be in its associated cache and ready for use. - * - * @event Phaser.Loader.LoaderPlugin#completeEvent - * @param {Phaser.Loader.File} file - The file that has failed to load. - */ - - /** - * Called at the end when the load queue is exhausted and all files have either loaded or errored. - * By this point every loaded file will now be in its associated cache and ready for use. - * - * Also clears down the Sets, puts progress to 1 and clears the deletion queue. - * - * @method Phaser.Loader.LoaderPlugin#loadComplete - * @fires Phaser.Loader.LoaderPlugin#completeEvent - * @since 3.7.0 - */ - loadComplete: function () - { - this.emit('loadcomplete', this); - - this.list.clear(); - this.inflight.clear(); - this.queue.clear(); - - this.progress = 1; - - this.state = CONST.LOADER_COMPLETE; - - this.systems.events.off('update', this.update, this); - - // Call 'destroy' on each file ready for deletion - this._deleteQueue.iterateLocal('destroy'); - - this._deleteQueue.clear(); - - this.emit('complete', this, this.totalComplete, this.totalFailed); - }, - - /** - * Adds a File into the pending-deletion queue. - * - * @method Phaser.Loader.LoaderPlugin#flagForRemoval - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The File to be queued for deletion when the Loader completes. - */ - flagForRemoval: function (file) - { - this._deleteQueue.set(file); - }, - - /** - * Converts the given JSON data into a file that the browser then prompts you to download so you can save it locally. - * - * The data must be well formed JSON and ready-parsed, not a JavaScript object. - * - * @method Phaser.Loader.LoaderPlugin#saveJSON - * @since 3.0.0 - * - * @param {*} data - The JSON data, ready parsed. - * @param {string} [filename=file.json] - The name to save the JSON file as. - * - * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. - */ - saveJSON: function (data, filename) - { - return this.save(JSON.stringify(data), filename); - }, - - /** - * Causes the browser to save the given data as a file to its default Downloads folder. - * - * Creates a DOM level anchor link, assigns it as being a `download` anchor, sets the href - * to be an ObjectURL based on the given data, and then invokes a click event. - * - * @method Phaser.Loader.LoaderPlugin#save - * @since 3.0.0 - * - * @param {*} data - The data to be saved. Will be passed through URL.createObjectURL. - * @param {string} [filename=file.json] - The filename to save the file as. - * @param {string} [filetype=application/json] - The file type to use when saving the file. Defaults to JSON. - * - * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. - */ - save: function (data, filename, filetype) - { - if (filename === undefined) { filename = 'file.json'; } - if (filetype === undefined) { filetype = 'application/json'; } - - var blob = new Blob([ data ], { type: filetype }); - - var url = URL.createObjectURL(blob); - - var a = document.createElement('a'); - - a.download = filename; - a.textContent = 'Download ' + filename; - a.href = url; - a.click(); - - return this; - }, - - /** - * Resets the Loader. - * - * This will clear all lists and reset the base URL, path and prefix. - * - * Warning: If the Loader is currently downloading files, or has files in its queue, they will be aborted. - * - * @method Phaser.Loader.LoaderPlugin#reset - * @since 3.0.0 - */ - reset: function () - { - this.list.clear(); - this.inflight.clear(); - this.queue.clear(); - - var gameConfig = this.systems.game.config; - var sceneConfig = this.systems.settings.loader; - - this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); - this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); - this.setPrefix(GetFastValue(sceneConfig, 'prefix', gameConfig.loaderPrefix)); - - this.state = CONST.LOADER_IDLE; - }, - - /** - * 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; - - this.systems.events.off('update', this.update, this); - this.systems.events.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.Loader.LoaderPlugin#destroy - * @private - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); - - this.state = CONST.LOADER_DESTROYED; - - this.systems.events.off('update', this.update, this); - this.systems.events.off('start', this.pluginStart, this); - - this.list = null; - this.inflight = null; - this.queue = null; - - this.scene = null; - this.systems = null; - this.textureManager = null; - this.cacheManager = null; - } - -}); - -PluginCache.register('Loader', LoaderPlugin, 'load'); - -module.exports = LoaderPlugin; - - -/***/ }), -/* 354 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(37); - -/** - * @typedef {object} Phaser.Loader.FileTypes.SpriteSheetFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='png'] - The default file extension to use if no url is provided. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image. - * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Sprite Sheet Image File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#spritesheet method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spritesheet. - * - * @class SpriteSheetFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.SpriteSheetFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var SpriteSheetFile = new Class({ - - Extends: ImageFile, - - initialize: - - function SpriteSheetFile (loader, key, url, frameConfig, xhrSettings) - { - ImageFile.call(this, loader, key, url, xhrSettings, frameConfig); - - this.type = 'spritesheet'; - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.SpriteSheetFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var texture = this.cache.addSpriteSheet(this.key, this.data, this.config); - - this.pendingDestroy(texture); - } - -}); - -/** - * Adds a Sprite Sheet Image, or array of Sprite Sheet Images, to the current load queue. - * - * The term 'Sprite Sheet' in Phaser means a fixed-size sheet. Where every frame in the sheet is the exact same size, - * and you reference those frames using numbers, not frame names. This is not the same thing as a Texture Atlas, where - * the frames are packed in a way where they take up the least amount of space, and are referenced by their names, - * not numbers. Some articles and software use the term 'Sprite Sheet' to mean Texture Atlas, so please be aware of - * what sort of file you're actually trying to load. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 }); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback - * of animated gifs to Canvas elements. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.spritesheet({ - * key: 'bot', - * url: 'images/robot.png', - * frameConfig: { - * frameWidth: 32, - * frameHeight: 38, - * startFrame: 0, - * endFrame: 8 - * } - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.SpriteSheetFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 }); - * // and later in your game ... - * this.add.image(x, y, 'bot', 0); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `PLAYER.` and the key was `Running` the final key will be `PLAYER.Running` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.spritesheet('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ], { frameWidth: 256, frameHeight: 80 }); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.spritesheet({ - * key: 'logo', - * url: 'images/AtariLogo.png', - * normalMap: 'images/AtariLogo-n.png', - * frameConfig: { - * frameWidth: 256, - * frameHeight: 80 - * } - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Sprite Sheet File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#spritesheet - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.SpriteSheetFileConfig|Phaser.Loader.FileTypes.SpriteSheetFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. At a minimum it should have a `frameWidth` property. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('spritesheet', function (key, url, frameConfig, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new SpriteSheetFile(this, key[i])); - } - } - else - { - this.addFile(new SpriteSheetFile(this, key, url, frameConfig, xhrSettings)); - } - - return this; -}); - -module.exports = SpriteSheetFile; - - -/***/ }), -/* 355 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.ScriptFileConfig - * - * @property {string} key - The key of the file. Must be unique within the Loader. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='js'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#script method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#script. - * - * @class ScriptFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.ScriptFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var ScriptFile = new Class({ - - Extends: File, - - initialize: - - function ScriptFile (loader, key, url, xhrSettings) - { - var extension = 'js'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'script', - cache: false, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.ScriptFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = document.createElement('script'); - this.data.language = 'javascript'; - this.data.type = 'text/javascript'; - this.data.defer = false; - this.data.text = this.xhrLoader.responseText; - - document.head.appendChild(this.data); - - this.onProcessComplete(); - } - -}); - -/** - * Adds a Script file, or array of Script files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.script('aliens', 'lib/aliens.js'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String and not already in-use by another file in the Loader. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.script({ - * key: 'aliens', - * url: 'lib/aliens.js' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.ScriptFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a script element - * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to - * false and then the resulting element will be appended to `document.head`. Any code then in the - * script will be executed. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Script File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#script - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.ScriptFileConfig|Phaser.Loader.FileTypes.ScriptFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('script', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new ScriptFile(this, key[i])); - } - } - else - { - this.addFile(new ScriptFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = ScriptFile; - - -/***/ }), -/* 356 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.PluginFileConfig - * - * @property {string} key - The key of the file. Must be unique within the Loader. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='js'] - The default file extension to use if no url is provided. - * @property {boolean} [start=false] - Automatically start the plugin after loading? - * @property {string} [mapping] - If this plugin is to be injected into the Scene, this is the property key used. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Plugin Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#plugin method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#plugin. - * - * @class PluginFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.PluginFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param {boolean} [start=false] - Automatically start the plugin after loading? - * @param {string} [mapping] - If this plugin is to be injected into the Scene, this is the property key used. - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var PluginFile = new Class({ - - Extends: File, - - initialize: - - function PluginFile (loader, key, url, start, mapping, xhrSettings) - { - var extension = 'js'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - start = GetFastValue(config, 'start'); - mapping = GetFastValue(config, 'mapping'); - } - - var fileConfig = { - type: 'plugin', - cache: false, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings, - config: { - start: start, - mapping: mapping - } - }; - - File.call(this, loader, fileConfig); - - // If the url variable refers to a class, add the plugin directly - if (typeof url === 'function') - { - this.data = url; - - this.state = CONST.FILE_POPULATED; - } - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.PluginFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - var pluginManager = this.loader.systems.plugins; - var config = this.config; - - var start = GetFastValue(config, 'start', false); - var mapping = GetFastValue(config, 'mapping', null); - - if (this.state === CONST.FILE_POPULATED) - { - pluginManager.install(this.key, this.data, start, mapping); - } - else - { - // Plugin added via a js file - this.state = CONST.FILE_PROCESSING; - - this.data = document.createElement('script'); - this.data.language = 'javascript'; - this.data.type = 'text/javascript'; - this.data.defer = false; - this.data.text = this.xhrLoader.responseText; - - document.head.appendChild(this.data); - - pluginManager.install(this.key, window[this.key], start, mapping); - } - - this.onProcessComplete(); - } - -}); - -/** - * Adds a Plugin Script file, or array of plugin files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.plugin('modplayer', 'plugins/ModPlayer.js'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String and not already in-use by another file in the Loader. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.plugin({ - * key: 'modplayer', - * url: 'plugins/ModPlayer.js' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.PluginFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a script element - * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to - * false and then the resulting element will be appended to `document.head`. Any code then in the - * script will be executed. It will then be passed to the Phaser PluginCache.register method. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Plugin File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#plugin - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.PluginFileConfig|Phaser.Loader.FileTypes.PluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {(string|function)} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, a plugin function. - * @param {boolean} [start] - The plugin mapping configuration object. - * @param {string} [mapping] - If this plugin is to be injected into the Scene, this is the property key used. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('plugin', function (key, url, start, mapping, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new PluginFile(this, key[i])); - } - } - else - { - this.addFile(new PluginFile(this, key, url, start, mapping, xhrSettings)); - } - - return this; -}); - -module.exports = PluginFile; - - -/***/ }), -/* 357 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); -var IsPlainObject = __webpack_require__(8); -var JSONFile = __webpack_require__(28); -var MultiFile = __webpack_require__(36); - -/** - * @typedef {object} Phaser.Loader.FileTypes.MultiAtlasFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [atlasURL] - The absolute or relative URL to load the multi atlas json file from. Or, a well formed JSON object. - * @property {string} [atlasExtension='json'] - The default file extension to use for the atlas json if no url is provided. - * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas json file. - * @property {string} [path] - Optional path to use when loading the textures defined in the atlas data. - * @property {string} [baseURL] - Optional Base URL to use when loading the textures defined in the atlas data. - * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture files. - */ - -/** - * @classdesc - * A single Multi Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#multiatlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#multiatlas. - * - * @class MultiAtlasFile - * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @param {string} [atlasURL] - The absolute or relative URL to load the multi atlas json file from. - * @param {string} [path] - Optional path to use when loading the textures defined in the atlas data. - * @param {string} [baseURL] - Optional Base URL to use when loading the textures defined in the atlas data. - * @param {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas json file. - * @param {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture files. - */ -var MultiAtlasFile = new Class({ - - Extends: MultiFile, - - initialize: - - function MultiAtlasFile (loader, key, atlasURL, path, baseURL, atlasXhrSettings, textureXhrSettings) - { - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - atlasURL = GetFastValue(config, 'url'); - atlasXhrSettings = GetFastValue(config, 'xhrSettings'); - path = GetFastValue(config, 'path'); - baseURL = GetFastValue(config, 'baseURL'); - textureXhrSettings = GetFastValue(config, 'textureXhrSettings'); - } - - var data = new JSONFile(loader, key, atlasURL, atlasXhrSettings); - - MultiFile.call(this, loader, 'multiatlas', key, [ data ]); - - this.config.path = path; - this.config.baseURL = baseURL; - this.config.textureXhrSettings = textureXhrSettings; - }, - - /** - * Called by each File when it finishes loading. - * - * @method Phaser.Loader.MultiFile#onFileComplete - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The File that has completed processing. - */ - onFileComplete: function (file) - { - var index = this.files.indexOf(file); - - if (index !== -1) - { - this.pending--; - - if (file.type === 'json' && file.data.hasOwnProperty('textures')) - { - // Inspect the data for the files to now load - var textures = file.data.textures; - - var config = this.config; - var loader = this.loader; - - var currentBaseURL = loader.baseURL; - var currentPath = loader.path; - var currentPrefix = loader.prefix; - - var baseURL = GetFastValue(config, 'baseURL', currentBaseURL); - var path = GetFastValue(config, 'path', currentPath); - var prefix = GetFastValue(config, 'prefix', currentPrefix); - var textureXhrSettings = GetFastValue(config, 'textureXhrSettings'); - - loader.setBaseURL(baseURL); - loader.setPath(path); - loader.setPrefix(prefix); - - for (var i = 0; i < textures.length; i++) - { - // "image": "texture-packer-multi-atlas-0.png", - var textureURL = textures[i].image; - - var key = '_MA_' + textureURL; - - var image = new ImageFile(loader, key, textureURL, textureXhrSettings); - - this.addToMultiFile(image); - - loader.addFile(image); - - // "normalMap": "texture-packer-multi-atlas-0_n.png", - if (textures[i].normalMap) - { - var normalMap = new ImageFile(loader, key, textures[i].normalMap, textureXhrSettings); - - normalMap.type = 'normalMap'; - - image.setLink(normalMap); - - this.addToMultiFile(normalMap); - - loader.addFile(normalMap); - } - } - - // Reset the loader settings - loader.setBaseURL(currentBaseURL); - loader.setPath(currentPath); - loader.setPrefix(currentPrefix); - } - } - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.MultiFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.isReadyToProcess()) - { - var fileJSON = this.files[0]; - - fileJSON.addToCache(); - - var data = []; - var images = []; - var normalMaps = []; - - for (var i = 1; i < this.files.length; i++) - { - var file = this.files[i]; - - if (file.type === 'normalMap') - { - continue; - } - - var key = file.key.substr(4); - var image = file.data; - - // Now we need to find out which json entry this mapped to - for (var t = 0; t < fileJSON.data.textures.length; t++) - { - var item = fileJSON.data.textures[t]; - - if (item.image === key) - { - images.push(image); - - data.push(item); - - if (file.linkFile) - { - normalMaps.push(file.linkFile.data); - } - - break; - } - } - } - - if (normalMaps.length === 0) - { - normalMaps = undefined; - } - - this.loader.textureManager.addAtlasJSONArray(this.key, images, data, normalMaps); - - this.complete = true; - - for (i = 0; i < this.files.length; i++) - { - this.files[i].pendingDestroy(); - } - } - } - -}); - -/** - * Adds a Multi Texture Atlas, or array of multi atlases, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.multiatlas('level1', 'images/Level1.json'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in a JSON file as exported from the application Texture Packer, - * version 4.6.3 or above, where you have made sure to use the Phaser 3 Export option. - * - * The way it works internally is that you provide a URL to the JSON file. Phaser then loads this JSON, parses it and - * extracts which texture files it also needs to load to complete the process. If the JSON also defines normal maps, - * Phaser will load those as well. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.multiatlas({ - * key: 'level1', - * atlasURL: 'images/Level1.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.MultiAtlasFileConfig` for more details. - * - * Instead of passing a URL for the atlas JSON data you can also pass in a well formed JSON object instead. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.multiatlas('level1', 'images/Level1.json'); - * // and later in your game ... - * this.add.image(x, y, 'level1', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Multi Atlas File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#multiatlas - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.7.0 - * - * @param {(string|Phaser.Loader.FileTypes.MultiAtlasFileConfig|Phaser.Loader.FileTypes.MultiAtlasFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {string} [path] - Optional path to use when loading the textures defined in the atlas data. - * @param {string} [baseURL] - Optional Base URL to use when loading the textures defined in the atlas data. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('multiatlas', function (key, atlasURL, path, baseURL, atlasXhrSettings) -{ - var multifile; - - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - multifile = new MultiAtlasFile(this, key[i]); - - this.addFile(multifile.files); - } - } - else - { - multifile = new MultiAtlasFile(this, key, atlasURL, path, baseURL, atlasXhrSettings); - - this.addFile(multifile.files); - } - - return this; -}); - -module.exports = MultiAtlasFile; - - -/***/ }), -/* 358 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AudioFile = __webpack_require__(168); -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); -var JSONFile = __webpack_require__(28); -var MultiFile = __webpack_require__(36); - -/** - * @typedef {object} Phaser.Loader.FileTypes.AudioSpriteFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Audio Cache. - * @property {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @property {XHRSettingsObject} [jsonXhrSettings] - Extra XHR Settings specifically for the json file. - * @property {string} [audioURL] - The absolute or relative URL to load the audio file from. - * @property {any} [audioConfig] - The audio configuration options. - * @property {XHRSettingsObject} [audioXhrSettings] - Extra XHR Settings specifically for the audio file. - */ - -/** - * @classdesc - * An Audio Sprite File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#audioSprite method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audioSprite. - * - * @class AudioSpriteFile - * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param {string} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. - * @param {any} [audioConfig] - The audio configuration options. - * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. - */ -var AudioSpriteFile = new Class({ - - Extends: MultiFile, - - initialize: - - function AudioSpriteFile (loader, key, jsonURL, audioURL, audioConfig, audioXhrSettings, jsonXhrSettings) - { - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - jsonURL = GetFastValue(config, 'jsonURL'); - audioURL = GetFastValue(config, 'audioURL'); - audioConfig = GetFastValue(config, 'audioConfig'); - audioXhrSettings = GetFastValue(config, 'audioXhrSettings'); - jsonXhrSettings = GetFastValue(config, 'jsonXhrSettings'); - } - - var data; - - // No url? then we're going to do a json load and parse it from that - if (!audioURL) - { - data = new JSONFile(loader, key, jsonURL, jsonXhrSettings); - - MultiFile.call(this, loader, 'audiosprite', key, [ data ]); - - this.config.resourceLoad = true; - this.config.audioConfig = audioConfig; - this.config.audioXhrSettings = audioXhrSettings; - } - else - { - var audio = AudioFile.create(loader, key, audioURL, audioConfig, audioXhrSettings); - - if (audio) - { - data = new JSONFile(loader, key, jsonURL, jsonXhrSettings); - - MultiFile.call(this, loader, 'audiosprite', key, [ audio, data ]); - - this.config.resourceLoad = false; - } - } - }, - - /** - * Called by each File when it finishes loading. - * - * @method Phaser.Loader.AudioSpriteFile#onFileComplete - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The File that has completed processing. - */ - onFileComplete: function (file) - { - var index = this.files.indexOf(file); - - if (index !== -1) - { - this.pending--; - - if (this.config.resourceLoad && file.type === 'json' && file.data.hasOwnProperty('resources')) - { - // Inspect the data for the files to now load - var urls = file.data.resources; - - var audioConfig = GetFastValue(this.config, 'audioConfig'); - var audioXhrSettings = GetFastValue(this.config, 'audioXhrSettings'); - - var audio = AudioFile.create(this.loader, file.key, urls, audioConfig, audioXhrSettings); - - if (audio) - { - this.addToMultiFile(audio); - - this.loader.addFile(audio); - } - } - } - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.AudioSpriteFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.isReadyToProcess()) - { - var fileA = this.files[0]; - var fileB = this.files[1]; - - fileA.addToCache(); - fileB.addToCache(); - - this.complete = true; - } - } - -}); - -/** - * Adds a JSON based Audio Sprite, or array of audio sprites, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.audioSprite('kyobi', 'kyobi.json', [ - * 'kyobi.ogg', - * 'kyobi.mp3', - * 'kyobi.m4a' - * ]); - * } - * ``` - * - * Audio Sprites are a combination of audio files and a JSON configuration. - * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite - * - * If the JSON file includes a 'resource' object then you can let Phaser parse it and load the audio - * files automatically based on its content. To do this exclude the audio URLs from the load: - * - * ```javascript - * function preload () - * { - * this.load.audioSprite('kyobi', 'kyobi.json'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * The key must be a unique String. It is used to add the file to the global Audio Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Audio Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.audioSprite({ - * key: 'kyobi', - * jsonURL: 'audio/Kyobi.json', - * audioURL: [ - * 'audio/Kyobi.ogg', - * 'audio/Kyobi.mp3', - * 'audio/Kyobi.m4a' - * ] - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.AudioSpriteFileConfig` for more details. - * - * Instead of passing a URL for the audio JSON data you can also pass in a well formed JSON object instead. - * - * Once the audio has finished loading you can use it create an Audio Sprite by referencing its key: - * - * ```javascript - * this.load.audioSprite('kyobi', 'kyobi.json'); - * // and later in your game ... - * var music = this.sound.addAudioSprite('kyobi'); - * music.play('title'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. - * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on - * browser support. - * - * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. - * - * Note: The ability to load this type of file will only be available if the Audio Sprite File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#audioSprite - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig|Phaser.Loader.FileTypes.AudioSpriteFileConfig[])} key - The key to use for this file, or a file configuration object, or an array of objects. - * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param {string} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. - * @param {any} [audioConfig] - The audio configuration options. - * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader. - */ -FileTypesManager.register('audioSprite', function (key, jsonURL, audioURL, audioConfig, audioXhrSettings, jsonXhrSettings) -{ - var game = this.systems.game; - var gameAudioConfig = game.config.audio; - var deviceAudio = game.device.audio; - - if ((gameAudioConfig && gameAudioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - // Sounds are disabled, so skip loading audio - return this; - } - - var multifile; - - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - multifile = new AudioSpriteFile(this, key[i]); - - if (multifile.files) - { - this.addFile(multifile.files); - } - } - } - else - { - multifile = new AudioSpriteFile(this, key, jsonURL, audioURL, audioConfig, audioXhrSettings, jsonXhrSettings); - - if (multifile.files) - { - this.addFile(multifile.files); - } - } - - return this; -}); - - -/***/ }), -/* 359 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); -var IsPlainObject = __webpack_require__(8); -var JSONFile = __webpack_require__(28); -var MultiFile = __webpack_require__(36); - -/** - * @typedef {object} Phaser.Loader.FileTypes.AtlasJSONFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. - * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. - * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. - * @property {string} [atlasURL] - The absolute or relative URL to load the atlas json file from. Or a well formed JSON object to use instead. - * @property {string} [atlasExtension='json'] - The default file extension to use for the atlas json if no url is provided. - * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas json file. - */ - -/** - * @classdesc - * A single JSON based Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. - * - * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm - * - * @class AtlasJSONFile - * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.AtlasJSONFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. - */ -var AtlasJSONFile = new Class({ - - Extends: MultiFile, - - initialize: - - function AtlasJSONFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) - { - var image; - var data; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - - image = new ImageFile(loader, { - key: key, - url: GetFastValue(config, 'textureURL'), - extension: GetFastValue(config, 'textureExtension', 'png'), - normalMap: GetFastValue(config, 'normalMap'), - xhrSettings: GetFastValue(config, 'textureXhrSettings') - }); - - data = new JSONFile(loader, { - key: key, - url: GetFastValue(config, 'atlasURL'), - extension: GetFastValue(config, 'atlasExtension', 'json'), - xhrSettings: GetFastValue(config, 'atlasXhrSettings') - }); - } - else - { - image = new ImageFile(loader, key, textureURL, textureXhrSettings); - data = new JSONFile(loader, key, atlasURL, atlasXhrSettings); - } - - if (image.linkFile) - { - // Image has a normal map - MultiFile.call(this, loader, 'atlasjson', key, [ image, data, image.linkFile ]); - } - else - { - MultiFile.call(this, loader, 'atlasjson', key, [ image, data ]); - } - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.AtlasJSONFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.isReadyToProcess()) - { - var image = this.files[0]; - var json = this.files[1]; - var normalMap = (this.files[2]) ? this.files[2].data : null; - - this.loader.textureManager.addAtlas(image.key, image.data, json.data, normalMap); - - json.addToCache(); - - this.complete = true; - } - } - -}); - -/** - * Adds a JSON based Texture Atlas, or array of atlases, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in a JSON file, using either the JSON Hash or JSON Array format. - * These files are created by software such as Texture Packer, Shoebox and Adobe Flash / Animate. - * If you are using Texture Packer and have enabled multi-atlas support, then please use the Phaser Multi Atlas loader - * instead of this one. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.atlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * atlasURL: 'images/MainMenu.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.AtlasJSONFileConfig` for more details. - * - * Instead of passing a URL for the atlas JSON data you can also pass in a well formed JSON object instead. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); - * // and later in your game ... - * this.add.image(x, y, 'mainmenu', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.atlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.json'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.atlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * normalMap: 'images/MainMenu-n.png', - * atlasURL: 'images/MainMenu.json' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Atlas JSON File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#atlas - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.AtlasJSONFileConfig|Phaser.Loader.FileTypes.AtlasJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) -{ - var multifile; - - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - multifile = new AtlasJSONFile(this, key[i]); - - this.addFile(multifile.files); - } - } - else - { - multifile = new AtlasJSONFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); - - this.addFile(multifile.files); - } - - return this; -}); - -module.exports = AtlasJSONFile; - - -/***/ }), -/* 360 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(28); - -/** - * @classdesc - * A single Animation JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#animation method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#animation. - * - * @class AnimationJSONFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. - */ -var AnimationJSONFile = new Class({ - - Extends: JSONFile, - - initialize: - - // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object - // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing - - function AnimationJSONFile (loader, key, url, xhrSettings, dataKey) - { - JSONFile.call(this, loader, key, url, xhrSettings, dataKey); - - this.type = 'animationJSON'; - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.AnimationJSONFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - // We need to hook into this event: - this.loader.once('loadcomplete', this.onLoadComplete, this); - - // But the rest is the same as a normal JSON file - JSONFile.prototype.onProcess.call(this); - }, - - /** - * Called at the end of the load process, after the Loader has finished all files in its queue. - * - * @method Phaser.Loader.FileTypes.AnimationJSONFile#onLoadComplete - * @since 3.7.0 - */ - onLoadComplete: function () - { - this.loader.systems.anims.fromJSON(this.data); - - this.pendingDestroy(); - } - -}); - -/** - * Adds an Animation JSON Data file, or array of Animation JSON files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.animation('baddieAnims', 'files/BaddieAnims.json'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the JSON Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.animation({ - * key: 'baddieAnims', - * url: 'files/BaddieAnims.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details. - * - * Once the file has finished loading it will automatically be passed to the global Animation Managers `fromJSON` method. - * This will parse all of the JSON data and create animation data from it. This process happens at the very end - * of the Loader, once every other file in the load queue has finished. The reason for this is to allow you to load - * both animation data and the images it relies upon in the same load call. - * - * Once the animation data has been parsed you will be able to play animations using that data. - * Please see the Animation Manager `fromJSON` method for more details about the format and playback. - * - * You can also access the raw animation data from its Cache using its key: - * - * ```javascript - * this.load.animation('baddieAnims', 'files/BaddieAnims.json'); - * // and later in your game ... - * var data = this.cache.json.get('baddieAnims'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the JSON Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" - * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, - * rather than the whole file. For example, if your JSON data had a structure like this: - * - * ```json - * { - * "level1": { - * "baddies": { - * "aliens": {}, - * "boss": {} - * } - * }, - * "level2": {}, - * "level3": {} - * } - * ``` - * - * And if you only wanted to create animations from the `boss` data, then you could pass `level1.baddies.boss`as the `dataKey`. - * - * Note: The ability to load this type of file will only be available if the JSON File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#animation - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig|Phaser.Loader.FileTypes.JSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {string} [dataKey] - When the Animation JSON file loads only this property will be stored in the Cache and used to create animation data. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('animation', function (key, url, dataKey, xhrSettings) -{ - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - this.addFile(new AnimationJSONFile(this, key[i])); - } - } - else - { - this.addFile(new AnimationJSONFile(this, key, url, xhrSettings, dataKey)); - } - - return this; -}); - -module.exports = AnimationJSONFile; - - -/***/ }), -/* 361 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Input.Touch - */ - -/* eslint-disable */ -module.exports = { - - TouchManager: __webpack_require__(197) - -}; -/* eslint-enable */ - - -/***/ }), -/* 362 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Input.Mouse - */ - -/* eslint-disable */ -module.exports = { - - MouseManager: __webpack_require__(199) - -}; -/* eslint-enable */ - - -/***/ }), -/* 363 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns `true` if the Key was released within the `duration` value given, or `false` if it either isn't up, - * or was released longer ago than then given duration. - * - * @function Phaser.Input.Keyboard.UpDuration - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - The Key object to test. - * @param {integer} [duration=50] - The duration, in ms, within which the key must have been released. - * - * @return {boolean} `true` if the Key was released within `duration` ms, otherwise `false`. - */ -var UpDuration = function (key, duration) -{ - if (duration === undefined) { duration = 50; } - - return (key.isUp && key.duration < duration); -}; - -module.exports = UpDuration; - - -/***/ }), -/* 364 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, - * or was pressed down longer ago than then given duration. - * - * @function Phaser.Input.Keyboard.DownDuration - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - The Key object to test. - * @param {integer} [duration=50] - The duration, in ms, within which the key must have been pressed down. - * - * @return {boolean} `true` if the Key was pressed down within `duration` ms, otherwise `false`. - */ -var DownDuration = function (key, duration) -{ - if (duration === undefined) { duration = 50; } - - return (key.isDown && key.duration < duration); -}; - -module.exports = DownDuration; - - -/***/ }), -/* 365 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * The justUp value allows you to test if this Key has just been released or not. - * - * When you check this value it will return `true` if the Key is up, otherwise `false`. - * - * You can only call JustUp once per key release. It will only return `true` once, until the Key is pressed down and released again. - * This allows you to use it in situations where you want to check if this key is up without using an event, such as in a core game loop. - * - * @function Phaser.Input.Keyboard.JustUp - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - The Key to check to see if it's just up or not. - * - * @return {boolean} `true` if the Key was just released, otherwise `false`. - */ -var JustUp = function (key) -{ - if (key._justUp) - { - key._justUp = false; - - return true; - } - else - { - return false; - } -}; - -module.exports = JustUp; - - -/***/ }), -/* 366 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * The justDown value allows you to test if this Key has just been pressed down or not. - * - * When you check this value it will return `true` if the Key is down, otherwise `false`. - * - * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. - * This allows you to use it in situations where you want to check if this key is down without using an event, such as in a core game loop. - * - * @function Phaser.Input.Keyboard.JustDown - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - The Key to check to see if it's just down or not. - * - * @return {boolean} `true` if the Key was just pressed, otherwise `false`. - */ -var JustDown = function (key) -{ - if (key._justDown) - { - key._justDown = false; - - return true; - } - else - { - return false; - } -}; - -module.exports = JustDown; - - -/***/ }), -/* 367 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the Keyboard Plugin. - * - * @function Phaser.Input.Keyboard.ProcessKeyUp - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - The Key to process the event for. - * @param {KeyboardEvent} event - The native Keyboard event. - * - * @return {Phaser.Input.Keyboard.Key} The Key that was processed. - */ -var ProcessKeyUp = function (key, event) -{ - key.originalEvent = event; - - if (key.preventDefault) - { - event.preventDefault(); - } - - if (!key.enabled) - { - return; - } - - key.isDown = false; - key.isUp = true; - key.timeUp = event.timeStamp; - key.duration = key.timeUp - key.timeDown; - key.repeats = 0; - - key._justDown = false; - key._justUp = true; - - return key; -}; - -module.exports = ProcessKeyUp; - - -/***/ }), -/* 368 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the Keyboard Plugin. - * - * @function Phaser.Input.Keyboard.ProcessKeyDown - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - The Key to process the event for. - * @param {KeyboardEvent} event - The native Keyboard event. - * - * @return {Phaser.Input.Keyboard.Key} The Key that was processed. - */ -var ProcessKeyDown = function (key, event) -{ - key.originalEvent = event; - - if (key.preventDefault) - { - event.preventDefault(); - } - - if (!key.enabled) - { - return; - } - - key.altKey = event.altKey; - key.ctrlKey = event.ctrlKey; - key.shiftKey = event.shiftKey; - key.location = event.location; - - if (key.isDown === false) - { - key.isDown = true; - key.isUp = false; - key.timeDown = event.timeStamp; - key.duration = 0; - key._justDown = true; - key._justUp = false; - } - - key.repeats++; - - return key; -}; - -module.exports = ProcessKeyDown; - - -/***/ }), -/* 369 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var KeyCodes = __webpack_require__(109); - -var KeyMap = {}; - -for (var key in KeyCodes) -{ - KeyMap[KeyCodes[key]] = key; -} - -module.exports = KeyMap; - - -/***/ }), -/* 370 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyCombo class. - * - * @function Phaser.Input.Keyboard.KeyCombo.ResetKeyCombo - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo to reset. - * - * @return {Phaser.Input.Keyboard.KeyCombo} The KeyCombo. - */ -var ResetKeyCombo = function (combo) -{ - combo.current = combo.keyCodes[0]; - combo.index = 0; - combo.timeLastMatched = 0; - combo.matched = false; - combo.timeMatched = 0; - - return combo; -}; - -module.exports = ResetKeyCombo; - - -/***/ }), -/* 371 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the KeyCombo class. - * Return `true` if it reached the end of the combo, `false` if not. - * - * @function Phaser.Input.Keyboard.KeyCombo.AdvanceKeyCombo - * @private - * @since 3.0.0 - * - * @param {KeyboardEvent} event - The native Keyboard Event. - * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to advance. - * - * @return {boolean} `true` if it reached the end of the combo, `false` if not. - */ -var AdvanceKeyCombo = function (event, combo) -{ - combo.timeLastMatched = event.timeStamp; - combo.index++; - - if (combo.index === combo.size) - { - return true; - } - else - { - combo.current = combo.keyCodes[combo.index]; - return false; - } -}; - -module.exports = AdvanceKeyCombo; - - -/***/ }), -/* 372 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AdvanceKeyCombo = __webpack_require__(371); - -/** - * Used internally by the KeyCombo class. - * - * @function Phaser.Input.Keyboard.KeyCombo.ProcessKeyCombo - * @private - * @since 3.0.0 - * - * @param {KeyboardEvent} event - The native Keyboard Event. - * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to be processed. - * - * @return {boolean} `true` if the combo was matched, otherwise `false`. - */ -var ProcessKeyCombo = function (event, combo) -{ - if (combo.matched) - { - return true; - } - - var comboMatched = false; - var keyMatched = false; - - if (event.keyCode === combo.current) - { - // Key was correct - - if (combo.index > 0 && combo.maxKeyDelay > 0) - { - // We have to check to see if the delay between - // the new key and the old one was too long (if enabled) - - var timeLimit = combo.timeLastMatched + combo.maxKeyDelay; - - // Check if they pressed it in time or not - if (event.timeStamp <= timeLimit) - { - keyMatched = true; - comboMatched = AdvanceKeyCombo(event, combo); - } - } - else - { - keyMatched = true; - - // We don't check the time for the first key pressed, so just advance it - comboMatched = AdvanceKeyCombo(event, combo); - } - } - - if (!keyMatched && combo.resetOnWrongKey) - { - // Wrong key was pressed - combo.index = 0; - combo.current = combo.keyCodes[0]; - } - - if (comboMatched) - { - combo.timeLastMatched = event.timeStamp; - combo.matched = true; - combo.timeMatched = event.timeStamp; - } - - return comboMatched; -}; - -module.exports = ProcessKeyCombo; - - -/***/ }), -/* 373 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var GetValue = __webpack_require__(4); -var InputPluginCache = __webpack_require__(76); -var Key = __webpack_require__(171); -var KeyCodes = __webpack_require__(109); -var KeyCombo = __webpack_require__(170); -var KeyMap = __webpack_require__(369); -var ProcessKeyDown = __webpack_require__(368); -var ProcessKeyUp = __webpack_require__(367); - -/** - * @classdesc - * The Keyboard Plugin is an input plugin that belongs to the Scene-owned Input system. - * - * Its role is to listen for native DOM Keyboard Events and then process them. - * - * You do not need to create this class directly, the Input system will create an instance of it automatically. - * - * You can access it from within a Scene using `this.input.keyboard`. For example, you can do: - * - * ```javascript - * this.input.keyboard.on('keydown', callback, context); - * ``` - * - * Or, to listen for a specific key: - * - * ```javascript - * this.input.keyboard.on('keydown_A', callback, context); - * ``` - * - * You can also create Key objects, which you can then poll in your game loop: - * - * ```javascript - * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); - * ``` - * - * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. - * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. - * - * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling. - * For example the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. - * And there are others. So, please check your extensions before opening Phaser issues about keys that don't work. - * - * @class KeyboardPlugin - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Keyboard - * @constructor - * @since 3.10.0 - * - * @param {Phaser.Input.InputPlugin} sceneInputPlugin - A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. - */ -var KeyboardPlugin = new Class({ - - Extends: EventEmitter, - - initialize: - - function KeyboardPlugin (sceneInputPlugin) - { - EventEmitter.call(this); - - /** - * A reference to the Scene that this Input Plugin is responsible for. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#scene - * @type {Phaser.Scene} - * @since 3.10.0 - */ - this.scene = sceneInputPlugin.scene; - - /** - * A reference to the Scene Systems Settings. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#settings - * @type {Phaser.Scenes.Settings.Object} - * @since 3.10.0 - */ - this.settings = this.scene.sys.settings; - - /** - * A reference to the Scene Input Plugin that created this Keyboard Plugin. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#sceneInputPlugin - * @type {Phaser.Input.InputPlugin} - * @since 3.10.0 - */ - this.sceneInputPlugin = sceneInputPlugin; - - /** - * A boolean that controls if the Keyboard Plugin is enabled or not. - * Can be toggled on the fly. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#enabled - * @type {boolean} - * @default true - * @since 3.10.0 - */ - this.enabled = true; - - /** - * The Keyboard Event target, as defined in the Scene or Game Config. - * Typically the browser window, but can be any interactive DOM element. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#target - * @type {any} - * @since 3.10.0 - */ - this.target; - - /** - * An array of Key objects to process. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#keys - * @type {Phaser.Input.Keyboard.Key[]} - * @since 3.10.0 - */ - this.keys = []; - - /** - * An array of KeyCombo objects to process. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#combos - * @type {Phaser.Input.Keyboard.KeyCombo[]} - * @since 3.10.0 - */ - this.combos = []; - - /** - * An internal event queue. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#queue - * @type {KeyboardEvent[]} - * @private - * @since 3.10.0 - */ - this.queue = []; - - /** - * Internal event handler. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#onKeyHandler - * @type {function} - * @private - * @since 3.10.0 - */ - this.onKeyHandler; - - sceneInputPlugin.pluginEvents.once('boot', this.boot, this); - sceneInputPlugin.pluginEvents.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#boot - * @private - * @since 3.10.0 - */ - boot: function () - { - var settings = this.settings.input; - var config = this.scene.sys.game.config; - - this.enabled = GetValue(settings, 'keyboard', config.inputKeyboard); - this.target = GetValue(settings, 'keyboard.target', config.inputKeyboardEventTarget); - - this.sceneInputPlugin.pluginEvents.once('destroy', this.destroy, 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.Input.Keyboard.KeyboardPlugin#start - * @private - * @since 3.10.0 - */ - start: function () - { - if (this.enabled) - { - this.startListeners(); - } - - this.sceneInputPlugin.pluginEvents.once('shutdown', this.shutdown, this); - }, - - /** - * Checks to see if both this plugin and the Scene to which it belongs is active. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#isActive - * @since 3.10.0 - * - * @return {boolean} `true` if the plugin and the Scene it belongs to is active. - */ - isActive: function () - { - return (this.enabled && this.scene.sys.isActive()); - }, - - /** - * Starts the Keyboard Event listeners running. - * This is called automatically and does not need to be manually invoked. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#startListeners - * @private - * @since 3.10.0 - */ - startListeners: function () - { - var _this = this; - - var handler = function (event) - { - if (event.defaultPrevented || !_this.isActive()) - { - // Do nothing if event already handled - return; - } - - _this.queue.push(event); - - var key = _this.keys[event.keyCode]; - - if (key && key.preventDefault) - { - event.preventDefault(); - } - - }; - - this.onKeyHandler = handler; - - this.target.addEventListener('keydown', handler, false); - this.target.addEventListener('keyup', handler, false); - - // Finally, listen for an update event from the Input Plugin - this.sceneInputPlugin.pluginEvents.on('update', this.update, this); - }, - - /** - * Stops the Keyboard Event listeners. - * This is called automatically and does not need to be manually invoked. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#stopListeners - * @private - * @since 3.10.0 - */ - stopListeners: function () - { - this.target.removeEventListener('keydown', this.onKeyHandler); - this.target.removeEventListener('keyup', this.onKeyHandler); - - this.sceneInputPlugin.pluginEvents.off('update', this.update); - }, - - /** - * @typedef {object} CursorKeys - * - * @property {Phaser.Input.Keyboard.Key} [up] - A Key object mapping to the UP arrow key. - * @property {Phaser.Input.Keyboard.Key} [down] - A Key object mapping to the DOWN arrow key. - * @property {Phaser.Input.Keyboard.Key} [left] - A Key object mapping to the LEFT arrow key. - * @property {Phaser.Input.Keyboard.Key} [right] - A Key object mapping to the RIGHT arrow key. - * @property {Phaser.Input.Keyboard.Key} [space] - A Key object mapping to the SPACE BAR key. - * @property {Phaser.Input.Keyboard.Key} [shift] - A Key object mapping to the SHIFT key. - */ - - /** - * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also Space Bar and shift. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#createCursorKeys - * @since 3.10.0 - * - * @return {CursorKeys} An object containing the properties: `up`, `down`, `left`, `right`, `space` and `shift`. - */ - createCursorKeys: function () - { - return this.addKeys({ - up: KeyCodes.UP, - down: KeyCodes.DOWN, - left: KeyCodes.LEFT, - right: KeyCodes.RIGHT, - space: KeyCodes.SPACE, - shift: KeyCodes.SHIFT - }); - }, - - /** - * A practical way to create an object containing user selected hotkeys. - * - * For example: - * - * ```javascript - * this.input.keyboard.addKeys({ 'up': Phaser.Input.Keyboard.KeyCodes.W, 'down': Phaser.Input.Keyboard.KeyCodes.S }); - * ``` - * - * would return an object containing the properties (`up` and `down`) mapped to W and S {@link Phaser.Input.Keyboard.Key} objects. - * - * You can also pass in a comma-separated string: - * - * ```javascript - * this.input.keyboard.addKeys('W,S,A,D'); - * ``` - * - * Which will return an object with the properties W, S, A and D mapped to the relevant Key objects. - * - * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#addKeys - * @since 3.10.0 - * - * @param {(object|string)} keys - An object containing Key Codes, or a comma-separated string. - * - * @return {object} An object containing Key objects mapped to the input properties. - */ - addKeys: function (keys) - { - var output = {}; - - if (typeof keys === 'string') - { - keys = keys.split(','); - - for (var i = 0; i < keys.length; i++) - { - output[keys[i]] = this.addKey(keys[i]); - } - } - else - { - for (var key in keys) - { - output[key] = this.addKey(keys[key]); - } - } - - return output; - }, - - /** - * Adds a Key object to this Keyboard Plugin. - * - * The given argument can be either an existing Key object, a string, such as `A` or `SPACE`, or a key code value. - * - * If a Key object is given, and one already exists matching the same key code, the existing one is replaced with the new one. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#addKey - * @since 3.10.0 - * - * @param {(Phaser.Input.Keyboard.Key|string|integer)} key - Either a Key object, a string, such as `A` or `SPACE`, or a key code value. - * - * @return {Phaser.Input.Keyboard.Key} The newly created Key object, or a reference to it if it already existed in the keys array. - */ - addKey: function (key) - { - var keys = this.keys; - - if (key instanceof Key) - { - var idx = keys.indexOf(key); - - if (idx > -1) - { - keys[idx] = key; - } - else - { - keys[key.keyCode] = key; - } - - return key; - } - - if (typeof key === 'string') - { - key = KeyCodes[key.toUpperCase()]; - } - - if (!keys[key]) - { - keys[key] = new Key(key); - } - - return keys[key]; - }, - - /** - * Removes a Key object from this Keyboard Plugin. - * - * The given argument can be either a Key object, a string, such as `A` or `SPACE`, or a key code value. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#removeKey - * @since 3.10.0 - * - * @param {(Phaser.Input.Keyboard.Key|string|integer)} key - Either a Key object, a string, such as `A` or `SPACE`, or a key code value. - */ - removeKey: function (key) - { - var keys = this.keys; - - if (key instanceof Key) - { - var idx = keys.indexOf(key); - - if (idx > -1) - { - this.keys[idx] = undefined; - } - } - else if (typeof key === 'string') - { - key = KeyCodes[key.toUpperCase()]; - } - - if (keys[key]) - { - keys[key] = undefined; - } - }, - - /** - * Creates a new KeyCombo. - * - * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them - * it will emit a `keycombomatch` event from this Keyboard Plugin. - * - * The keys to be listened for can be defined as: - * - * A string (i.e. 'ATARI') - * An array of either integers (key codes) or strings, or a mixture of both - * An array of objects (such as Key objects) with a public 'keyCode' property - * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) - * you could pass the following array of key codes: - * - * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); - * - * this.input.keyboard.on('keycombomatch', function (event) { - * console.log('Konami Code entered!'); - * }); - * ``` - * - * Or, to listen for the user entering the word PHASER: - * - * ```javascript - * this.input.keyboard.createCombo('PHASER'); - * ``` - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#createCombo - * @since 3.10.0 - * - * @param {(string|integer[]|object[])} keys - The keys that comprise this combo. - * @param {KeyComboConfig} [config] - A Key Combo configuration object. - * - * @return {Phaser.Input.Keyboard.KeyCombo} The new KeyCombo object. - */ - createCombo: function (keys, config) - { - return new KeyCombo(this, keys, config); - }, - - /** - * Internal update handler called by the Input Manager, which is in turn invoked by the Game step. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#update - * @private - * @since 3.10.0 - */ - update: function () - { - var len = this.queue.length; - - if (!this.enabled || len === 0) - { - return; - } - - // Clears the queue array, and also means we don't work on array data that could potentially - // be modified during the processing phase - var queue = this.queue.splice(0, len); - - var keys = this.keys; - - // Process the event queue, dispatching all of the events that have stored up - for (var i = 0; i < len; i++) - { - var event = queue[i]; - var code = event.keyCode; - - if (event.type === 'keydown') - { - if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false)) - { - // Will emit a keyboard or keyup event - this.emit(event.type, event); - - this.emit('keydown_' + KeyMap[code], event); - } - - if (keys[code]) - { - ProcessKeyDown(keys[code], event); - } - } - else - { - // Will emit a keyboard or keyup event - this.emit(event.type, event); - - this.emit('keyup_' + KeyMap[code], event); - - if (keys[code]) - { - ProcessKeyUp(keys[code], event); - } - } - } - }, - - /** - * Shuts the Keyboard Plugin down. - * All this does is remove any listeners bound to it. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#shutdown - * @private - * @since 3.10.0 - */ - shutdown: function () - { - this.stopListeners(); - - this.removeAllListeners(); - }, - - /** - * Destroys this Keyboard Plugin instance and all references it holds, plus clears out local arrays. - * - * @method Phaser.Input.Keyboard.KeyboardPlugin#destroy - * @private - * @since 3.10.0 - */ - destroy: function () - { - this.shutdown(); - - this.keys = []; - this.combos = []; - this.queue = []; - - this.scene = null; - this.settings = null; - this.sceneInputPlugin = null; - this.target = null; - } - -}); - -/** - * An instance of the Keyboard Plugin class, if enabled via the `input.keyboard` Scene or Game Config property. - * Use this to create Key objects and listen for keyboard specific events. - * - * @name Phaser.Input.InputPlugin#keyboard - * @type {?Phaser.Input.Keyboard.KeyboardPlugin} - * @since 3.10.0 - */ -InputPluginCache.register('KeyboardPlugin', KeyboardPlugin, 'keyboard', 'keyboard', 'inputKeyboard'); - -module.exports = KeyboardPlugin; - - -/***/ }), -/* 374 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Input.Keyboard - */ - -module.exports = { - - KeyboardPlugin: __webpack_require__(373), - - Key: __webpack_require__(171), - KeyCodes: __webpack_require__(109), - - KeyCombo: __webpack_require__(170), - - JustDown: __webpack_require__(366), - JustUp: __webpack_require__(365), - DownDuration: __webpack_require__(364), - UpDuration: __webpack_require__(363) - -}; - - -/***/ }), -/* 375 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Creates a new Pixel Perfect Handler function. - * - * Access via `InputPlugin.makePixelPerfect` rather than calling it directly. - * - * @function Phaser.Input.CreatePixelPerfectHandler - * @since 3.10.0 - * - * @param {Phaser.Textures.TextureManager} textureManager - A reference to the Texture Manager. - * @param {integer} alphaTolerance - The alpha level that the pixel should be above to be included as a successful interaction. - * - * @return {function} The new Pixel Perfect Handler function. - */ -var CreatePixelPerfectHandler = function (textureManager, alphaTolerance) -{ - return function (hitArea, x, y, gameObject) - { - var alpha = textureManager.getPixelAlpha(x, y, gameObject.texture.key, gameObject.frame.key); - - return (alpha && alpha >= alphaTolerance); - }; -}; - -module.exports = CreatePixelPerfectHandler; - - -/***/ }), -/* 376 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(88); -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var CreateInteractiveObject = __webpack_require__(175); -var CreatePixelPerfectHandler = __webpack_require__(375); -var DistanceBetween = __webpack_require__(58); -var Ellipse = __webpack_require__(114); -var EllipseContains = __webpack_require__(54); -var EventEmitter = __webpack_require__(9); -var GetFastValue = __webpack_require__(1); -var InputPluginCache = __webpack_require__(76); -var IsPlainObject = __webpack_require__(8); -var PluginCache = __webpack_require__(12); -var Rectangle = __webpack_require__(14); -var RectangleContains = __webpack_require__(31); -var Triangle = __webpack_require__(68); -var TriangleContains = __webpack_require__(60); - -/** - * @classdesc - * The Input Plugin belongs to a Scene and handles all input related events and operations for it. - * - * You can access it from within a Scene using `this.input`. - * - * It emits events directly. For example, you can do: - * - * ```javascript - * this.input.on('pointerdown', callback, context); - * ``` - * - * To listen for a pointer down event anywhere on the game canvas. - * - * Game Objects can be enabled for input by calling their `setInteractive` method. After which they - * will directly emit input events: - * - * ```javascript - * var sprite = this.add.sprite(x, y, texture); - * sprite.setInteractive(); - * sprite.on('pointerdown', callback, context); - * ``` - * - * Please see the Input examples and tutorials for more information. - * - * @class InputPlugin - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - A reference to the Scene that this Input Plugin is responsible for. - */ -var InputPlugin = new Class({ - - Extends: EventEmitter, - - initialize: - - function InputPlugin (scene) - { - EventEmitter.call(this); - - /** - * A reference to the Scene that this Input Plugin is responsible for. - * - * @name Phaser.Input.InputPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene Systems class. - * - * @name Phaser.Input.InputPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * A reference to the Scene Systems Settings. - * - * @name Phaser.Input.InputPlugin#settings - * @type {Phaser.Scenes.Settings.Object} - * @since 3.5.0 - */ - this.settings = scene.sys.settings; - - /** - * A reference to the Game Input Manager. - * - * @name Phaser.Input.InputPlugin#manager - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.manager = scene.sys.game.input; - - /** - * Internal event queue used for plugins only. - * - * @name Phaser.Input.InputPlugin#pluginEvents - * @type {Phaser.Events.EventEmitter} - * @private - * @since 3.10.0 - */ - this.pluginEvents = new EventEmitter(); - - /** - * If set, the Input Plugin will run its update loop every frame. - * - * @name Phaser.Input.InputPlugin#enabled - * @type {boolean} - * @default true - * @since 3.5.0 - */ - this.enabled = true; - - /** - * A reference to the Scene Display List. This property is set during the `boot` method. - * - * @name Phaser.Input.InputPlugin#displayList - * @type {Phaser.GameObjects.DisplayList} - * @since 3.0.0 - */ - this.displayList; - - /** - * A reference to the Scene Cameras Manager. This property is set during the `boot` method. - * - * @name Phaser.Input.InputPlugin#cameras - * @type {Phaser.Cameras.Scene2D.CameraManager} - * @since 3.0.0 - */ - this.cameras; - - // Inject the available input plugins into this class - InputPluginCache.install(this); - - /** - * A reference to the Mouse Manager. - * - * This property is only set if Mouse support has been enabled in your Game Configuration file. - * - * If you just wish to get access to the mouse pointer, use the `mousePointer` property instead. - * - * @name Phaser.Input.InputPlugin#mouse - * @type {?Phaser.Input.Mouse.MouseManager} - * @since 3.0.0 - */ - this.mouse = this.manager.mouse; - - /** - * When set to `true` (the default) the Input Plugin will emulate DOM behavior by only emitting events from - * the top-most Game Objects in the Display List. - * - * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. - * - * @name Phaser.Input.InputPlugin#topOnly - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.topOnly = true; - - /** - * How often should the Pointers be checked? - * - * The value is a time, given in ms, and is the time that must have elapsed between game steps before - * the Pointers will be polled again. When a pointer is polled it runs a hit test to see which Game - * Objects are currently below it, or being interacted with it. - * - * Pointers will *always* be checked if they have been moved by the user, or press or released. - * - * This property only controls how often they will be polled if they have not been updated. - * You should set this if you want to have Game Objects constantly check against the pointers, even - * if the pointer didn't move itself. - * - * Set to 0 to poll constantly. Set to -1 to only poll on user movement. - * - * @name Phaser.Input.InputPlugin#pollRate - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.pollRate = -1; - - /** - * Internal poll timer value. - * - * @name Phaser.Input.InputPlugin#_pollTimer - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._pollTimer = 0; - - /** - * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. - * - * @name Phaser.Input.InputPlugin#dragDistanceThreshold - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.dragDistanceThreshold = 0; - - /** - * The amount of time, in ms, a pointer has to be held down before it thinks it is dragging. - * - * @name Phaser.Input.InputPlugin#dragTimeThreshold - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.dragTimeThreshold = 0; - - /** - * Used to temporarily store the results of the Hit Test - * - * @name Phaser.Input.InputPlugin#_temp - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._temp = []; - - /** - * Used to temporarily store the results of the Hit Test dropZones - * - * @name Phaser.Input.InputPlugin#_tempZones - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._tempZones = []; - - /** - * A list of all Game Objects that have been set to be interactive in the Scene this Input Plugin is managing. - * - * @name Phaser.Input.InputPlugin#_list - * @type {Phaser.GameObjects.GameObject[]} - * @private - * @default [] - * @since 3.0.0 - */ - this._list = []; - - /** - * Objects waiting to be inserted to the list on the next call to 'begin'. - * - * @name Phaser.Input.InputPlugin#_pendingInsertion - * @type {Phaser.GameObjects.GameObject[]} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingInsertion = []; - - /** - * Objects waiting to be removed from the list on the next call to 'begin'. - * - * @name Phaser.Input.InputPlugin#_pendingRemoval - * @type {Phaser.GameObjects.GameObject[]} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingRemoval = []; - - /** - * A list of all Game Objects that have been enabled for dragging. - * - * @name Phaser.Input.InputPlugin#_draggable - * @type {Phaser.GameObjects.GameObject[]} - * @private - * @default [] - * @since 3.0.0 - */ - this._draggable = []; - - /** - * A list of all Interactive Objects currently considered as being 'draggable' by any pointer, indexed by pointer ID. - * - * @name Phaser.Input.InputPlugin#_drag - * @type {{0:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array}} - * @private - * @since 3.0.0 - */ - this._drag = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [] }; - - /** - * A list of all Interactive Objects currently considered as being 'over' by any pointer, indexed by pointer ID. - * - * @name Phaser.Input.InputPlugin#_over - * @type {{0:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array}} - * @private - * @since 3.0.0 - */ - this._over = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [] }; - - /** - * A list of valid DOM event types. - * - * @name Phaser.Input.InputPlugin#_validTypes - * @type {string[]} - * @private - * @since 3.0.0 - */ - this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ]; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Input.InputPlugin#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.cameras = this.systems.cameras; - - this.displayList = this.systems.displayList; - - this.systems.events.once('destroy', this.destroy, this); - - // Registered input plugins listen for this - this.pluginEvents.emit('boot'); - }, - - /** - * 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#start - * @private - * @since 3.5.0 - */ - 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.once('shutdown', this.shutdown, this); - - this.enabled = true; - - // Registered input plugins listen for this - this.pluginEvents.emit('start'); - }, - - /** - * The pre-update handler is responsible for checking the pending removal and insertion lists and - * deleting old Game Objects. - * - * @method Phaser.Input.InputPlugin#preUpdate - * @private - * @since 3.0.0 - */ - preUpdate: function () - { - // Registered input plugins listen for this - this.pluginEvents.emit('preUpdate'); - - var removeList = this._pendingRemoval; - var insertList = this._pendingInsertion; - - var toRemove = removeList.length; - var toInsert = insertList.length; - - if (toRemove === 0 && toInsert === 0) - { - // Quick bail - return; - } - - var current = this._list; - - // Delete old gameObjects - for (var i = 0; i < toRemove; i++) - { - var gameObject = removeList[i]; - - var index = current.indexOf(gameObject); - - if (index > -1) - { - current.splice(index, 1); - - this.clear(gameObject); - } - } - - // Clear the removal list - removeList.length = 0; - this._pendingRemoval.length = 0; - - // Move pendingInsertion to list (also clears pendingInsertion at the same time) - this._list = current.concat(insertList.splice(0)); - }, - - /** - * Checks to see if both this plugin and the Scene to which it belongs is active. - * - * @method Phaser.Input.InputPlugin#isActive - * @since 3.10.0 - * - * @return {boolean} `true` if the plugin and the Scene it belongs to is active. - */ - isActive: function () - { - return (this.enabled && this.scene.sys.isActive()); - }, - - /** - * The internal update loop for the Input Plugin. - * Called automatically by the Scene Systems step. - * - * @method Phaser.Input.InputPlugin#update - * @private - * @since 3.0.0 - * - * @param {number} time - The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). - * @param {number} delta - The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. - */ - update: function (time, delta) - { - if (!this.isActive()) - { - return; - } - - this.pluginEvents.emit('update', time, delta); - - var manager = this.manager; - - // Another Scene above this one has already consumed the input events, or we're in transition - if (manager.globalTopOnly && manager.ignoreEvents) - { - return; - } - - var runUpdate = (manager.dirty || this.pollRate === 0); - - if (this.pollRate > -1) - { - this._pollTimer -= delta; - - if (this._pollTimer < 0) - { - runUpdate = true; - - // Discard timer diff - this._pollTimer = this.pollRate; - } - } - - if (!runUpdate) - { - return; - } - - var pointers = this.manager.pointers; - - for (var i = 0; i < this.manager.pointersTotal; i++) - { - var pointer = pointers[i]; - - // Always reset this array - this._tempZones = []; - - // _temp contains a hit tested and camera culled list of IO objects - this._temp = this.hitTestPointer(pointer); - - this.sortGameObjects(this._temp); - this.sortGameObjects(this._tempZones); - - if (this.topOnly) - { - // Only the top-most one counts now, so safely ignore the rest - if (this._temp.length) - { - this._temp.splice(1); - } - - if (this._tempZones.length) - { - this._tempZones.splice(1); - } - } - - var total = this.processDragEvents(pointer, time); - - // TODO: Enable for touch - if (!pointer.wasTouch) - { - total += this.processOverOutEvents(pointer); - } - - if (pointer.justDown) - { - total += this.processDownEvents(pointer); - } - - if (pointer.justUp) - { - total += this.processUpEvents(pointer); - } - - if (pointer.justMoved) - { - total += this.processMoveEvents(pointer); - } - - if (total > 0 && manager.globalTopOnly) - { - // We interacted with an event in this Scene, so block any Scenes below us from doing the same this frame - manager.ignoreEvents = true; - } - } - }, - - /** - * Clears a Game Object so it no longer has an Interactive Object associated with it. - * The Game Object is then queued for removal from the Input Plugin on the next update. - * - * @method Phaser.Input.InputPlugin#clear - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will have its Interactive Object removed. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that had its Interactive Object removed. - */ - clear: function (gameObject) - { - var input = gameObject.input; - - // If GameObject.input already cleared from higher class - if (!input) - { - return; - } - - this.queueForRemoval(gameObject); - - input.gameObject = undefined; - input.target = undefined; - input.hitArea = undefined; - input.hitAreaCallback = undefined; - input.callbackContext = undefined; - - gameObject.input = null; - - // Clear from _draggable, _drag and _over - var index = this._draggable.indexOf(gameObject); - - if (index > -1) - { - this._draggable.splice(index, 1); - } - - index = this._drag[0].indexOf(gameObject); - - if (index > -1) - { - this._drag[0].splice(index, 1); - } - - index = this._over[0].indexOf(gameObject); - - if (index > -1) - { - this._over[0].splice(index, 1); - } - - return gameObject; - }, - - /** - * Disables Input on a single Game Object. - * - * An input disabled Game Object still retains its Interactive Object component and can be re-enabled - * at any time, by passing it to `InputPlugin.enable`. - * - * @method Phaser.Input.InputPlugin#disable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to have its input system disabled. - */ - disable: function (gameObject) - { - gameObject.input.enabled = false; - }, - - /** - * Enable a Game Object for interaction. - * - * If the Game Object already has an Interactive Object component, it is enabled and returned. - * - * Otherwise, a new Interactive Object component is created and assigned to the Game Object's `input` property. - * - * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area - * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced - * input detection. - * - * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If - * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific - * shape for it to use. - * - * You can also provide an Input Configuration Object as the only argument to this method. - * - * @method Phaser.Input.InputPlugin#enable - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to be enabled for input. - * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area. - * @param {boolean} [dropZone=false] - Is this Game Object a drop zone or not? - * - * @return {Phaser.Input.InputPlugin} This Input Plugin. - */ - enable: function (gameObject, shape, callback, dropZone) - { - if (dropZone === undefined) { dropZone = false; } - - if (gameObject.input) - { - // If it is already has an InteractiveObject then just enable it and return - gameObject.input.enabled = true; - } - else - { - // Create an InteractiveObject and enable it - this.setHitArea(gameObject, shape, callback); - } - - if (gameObject.input && dropZone && !gameObject.input.dropZone) - { - gameObject.input.dropZone = dropZone; - } - - return this; - }, - - /** - * Takes the given Pointer and performs a hit test against it, to see which interactive Game Objects - * it is currently above. - * - * The hit test is performed against which-ever Camera the Pointer is over. If it is over multiple - * cameras, it starts checking the camera at the top of the camera list, and if nothing is found, iterates down the list. - * - * @method Phaser.Input.InputPlugin#hitTestPointer - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - The Pointer to check against the Game Objects. - * - * @return {Phaser.GameObjects.GameObject[]} An array of all the interactive Game Objects the Pointer was above. - */ - hitTestPointer: function (pointer) - { - var cameras = this.cameras.getCamerasBelowPointer(pointer); - - for (var c = 0; c < cameras.length; c++) - { - var camera = cameras[c]; - - // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array. - // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. - var over = this.manager.hitTest(pointer, this._list, camera); - - // Filter out the drop zones - for (var i = 0; i < over.length; i++) - { - var obj = over[i]; - - if (obj.input.dropZone) - { - this._tempZones.push(obj); - } - } - - if (over.length > 0) - { - pointer.camera = camera; - - return over; - } - } - - return []; - }, - - /** - * An internal method that handles the Pointer down event. - * - * @method Phaser.Input.InputPlugin#processDownEvents - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - The Pointer being tested. - * - * @return {integer} The total number of objects interacted with. - */ - processDownEvents: function (pointer) - { - var currentlyOver = this._temp; - - // Contains ALL Game Objects currently over in the array - this.emit('pointerdown', pointer, currentlyOver); - - var total = 0; - - // Go through all objects the pointer was over and fire their events / callbacks - for (var i = 0; i < currentlyOver.length; i++) - { - var gameObject = currentlyOver[i]; - - if (!gameObject.input) - { - continue; - } - - total++; - - gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, pointer.camera); - - this.emit('gameobjectdown', pointer, gameObject); - } - - return total; - }, - - /** - * An internal method that handles the Pointer drag events. - * - * @method Phaser.Input.InputPlugin#processDragEvents - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - The Pointer to check against the Game Objects. - * @param {number} time - The time stamp of the most recent Game step. - * - * @return {integer} The total number of objects interacted with. - */ - processDragEvents: function (pointer, time) - { - if (this._draggable.length === 0) - { - // There are no draggable items, so let's not even bother going further - return 0; - } - - var i; - var gameObject; - var list; - var input; - var currentlyOver = this._temp; - - // 0 = Not dragging anything - // 1 = Primary button down and objects below, so collect a draglist - // 2 = Pointer being checked if meets drag criteria - // 3 = Pointer meets criteria, notify the draglist - // 4 = Pointer actively dragging the draglist and has moved - // 5 = Pointer actively dragging but has been released, notify draglist - - if (pointer.dragState === 0 && pointer.primaryDown && pointer.justDown && currentlyOver.length > 0) - { - pointer.dragState = 1; - } - else if (pointer.dragState > 0 && !pointer.primaryDown && pointer.justUp) - { - pointer.dragState = 5; - } - - // Process the various drag states - - // 1 = Primary button down and objects below, so collect a draglist - if (pointer.dragState === 1) - { - // Get draggable objects, sort them, pick the top (or all) and store them somewhere - var draglist = []; - - for (i = 0; i < currentlyOver.length; i++) - { - gameObject = currentlyOver[i]; - - if (gameObject.input.draggable) - { - draglist.push(gameObject); - } - } - - if (draglist.length === 0) - { - pointer.dragState = 0; - - return 0; - } - else if (draglist.length > 1) - { - this.sortGameObjects(draglist); - - if (this.topOnly) - { - draglist.splice(1); - } - } - - // draglist now contains all potential candidates for dragging - this._drag[pointer.id] = draglist; - - if (this.dragDistanceThreshold === 0 && this.dragTimeThreshold === 0) - { - // No drag criteria, so snap immediately to mode 3 - pointer.dragState = 3; - } - else - { - // Check the distance / time - pointer.dragState = 2; - } - } - - // 2 = Pointer being checked if meets drag criteria - if (pointer.dragState === 2) - { - // Has it moved far enough to be considered a drag? - if (this.dragDistanceThreshold > 0 && DistanceBetween(pointer.x, pointer.y, pointer.downX, pointer.downY) >= this.dragDistanceThreshold) - { - // Alrighty, we've got a drag going on ... - pointer.dragState = 3; - } - - // Held down long enough to be considered a drag? - if (this.dragTimeThreshold > 0 && (time >= pointer.downTime + this.dragTimeThreshold)) - { - // Alrighty, we've got a drag going on ... - pointer.dragState = 3; - } - } - - // 3 = Pointer meets criteria and is freshly down, notify the draglist - if (pointer.dragState === 3) - { - list = this._drag[pointer.id]; - - for (i = 0; i < list.length; i++) - { - gameObject = list[i]; - - input = gameObject.input; - - input.dragState = 2; - - input.dragX = pointer.x - gameObject.x; - input.dragY = pointer.y - gameObject.y; - - input.dragStartX = gameObject.x; - input.dragStartY = gameObject.y; - - gameObject.emit('dragstart', pointer, input.dragX, input.dragY); - - this.emit('dragstart', pointer, gameObject); - } - - pointer.dragState = 4; - - return list.length; - } - - // 4 = Pointer actively dragging the draglist and has moved - if (pointer.dragState === 4 && pointer.justMoved && !pointer.justUp) - { - var dropZones = this._tempZones; - - list = this._drag[pointer.id]; - - for (i = 0; i < list.length; i++) - { - gameObject = list[i]; - - input = gameObject.input; - - // If this GO has a target then let's check it - if (input.target) - { - var index = dropZones.indexOf(input.target); - - // Got a target, are we still over it? - if (index === 0) - { - // We're still over it, and it's still the top of the display list, phew ... - gameObject.emit('dragover', pointer, input.target); - - this.emit('dragover', pointer, gameObject, input.target); - } - else if (index > 0) - { - // Still over it but it's no longer top of the display list (targets must always be at the top) - gameObject.emit('dragleave', pointer, input.target); - - this.emit('dragleave', pointer, gameObject, input.target); - - input.target = dropZones[0]; - - gameObject.emit('dragenter', pointer, input.target); - - this.emit('dragenter', pointer, gameObject, input.target); - } - else - { - // Nope, we've moved on (or the target has!), leave the old target - gameObject.emit('dragleave', pointer, input.target); - - this.emit('dragleave', pointer, gameObject, input.target); - - // Anything new to replace it? - // Yup! - if (dropZones[0]) - { - input.target = dropZones[0]; - - gameObject.emit('dragenter', pointer, input.target); - - this.emit('dragenter', pointer, gameObject, input.target); - } - else - { - // Nope - input.target = null; - } - } - } - else if (!input.target && dropZones[0]) - { - input.target = dropZones[0]; - - gameObject.emit('dragenter', pointer, input.target); - - this.emit('dragenter', pointer, gameObject, input.target); - } - - var dragX = pointer.x - gameObject.input.dragX; - var dragY = pointer.y - gameObject.input.dragY; - - gameObject.emit('drag', pointer, dragX, dragY); - - this.emit('drag', pointer, gameObject, dragX, dragY); - } - - return list.length; - } - - // 5 = Pointer was actively dragging but has been released, notify draglist - if (pointer.dragState === 5) - { - list = this._drag[pointer.id]; - - for (i = 0; i < list.length; i++) - { - gameObject = list[i]; - - input = gameObject.input; - - if (input.dragState === 2) - { - input.dragState = 0; - - input.dragX = input.localX - gameObject.displayOriginX; - input.dragY = input.localY - gameObject.displayOriginY; - - var dropped = false; - - if (input.target) - { - gameObject.emit('drop', pointer, input.target); - - this.emit('drop', pointer, gameObject, input.target); - - input.target = null; - - dropped = true; - } - - // And finally the dragend event - - gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped); - - this.emit('dragend', pointer, gameObject, dropped); - } - } - - pointer.dragState = 0; - - list.splice(0); - } - - return 0; - }, - - /** - * An internal method that handles the Pointer movement event. - * - * @method Phaser.Input.InputPlugin#processMoveEvents - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. - * - * @return {integer} The total number of objects interacted with. - */ - processMoveEvents: function (pointer) - { - var currentlyOver = this._temp; - - this.emit('pointermove', pointer, currentlyOver); - - var total = 0; - - // Go through all objects the pointer was over and fire their events / callbacks - for (var i = 0; i < currentlyOver.length; i++) - { - var gameObject = currentlyOver[i]; - - if (!gameObject.input) - { - continue; - } - - total++; - - gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY); - - this.emit('gameobjectmove', pointer, gameObject); - - if (this.topOnly) - { - break; - } - } - - return total; - }, - - /** - * An internal method that handles the Pointer over and out events. - * - * @method Phaser.Input.InputPlugin#processOverOutEvents - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. - * - * @return {integer} The total number of objects interacted with. - */ - processOverOutEvents: function (pointer) - { - var currentlyOver = this._temp; - - var i; - var gameObject; - var justOut = []; - var justOver = []; - var stillOver = []; - var previouslyOver = this._over[pointer.id]; - var currentlyDragging = this._drag[pointer.id]; - - var manager = this.manager; - - // Go through all objects the pointer was previously over, and see if it still is. - // Splits the previouslyOver array into two parts: justOut and stillOver - - for (i = 0; i < previouslyOver.length; i++) - { - gameObject = previouslyOver[i]; - - if (currentlyOver.indexOf(gameObject) === -1 && currentlyDragging.indexOf(gameObject) === -1) - { - // Not in the currentlyOver array, so must be outside of this object now - justOut.push(gameObject); - } - else - { - // In the currentlyOver array - stillOver.push(gameObject); - } - } - - // Go through all objects the pointer is currently over (the hit test results) - // and if not in the previouslyOver array we know it's a new entry, so add to justOver - for (i = 0; i < currentlyOver.length; i++) - { - gameObject = currentlyOver[i]; - - // Is this newly over? - - if (previouslyOver.indexOf(gameObject) === -1) - { - justOver.push(gameObject); - } - } - - // By this point the arrays are filled, so now we can process what happened... - - // Process the Just Out objects - var total = justOut.length; - - var totalInteracted = 0; - - if (total > 0) - { - this.sortGameObjects(justOut); - - this.emit('pointerout', pointer, justOut); - - // Call onOut for everything in the justOut array - for (i = 0; i < total; i++) - { - gameObject = justOut[i]; - - if (!gameObject.input) - { - continue; - } - - this.emit('gameobjectout', pointer, gameObject); - - gameObject.emit('pointerout', pointer); - - manager.resetCursor(gameObject.input); - - totalInteracted++; - } - } - - // Process the Just Over objects - total = justOver.length; - - if (total > 0) - { - this.sortGameObjects(justOver); - - this.emit('pointerover', pointer, justOver); - - // Call onOver for everything in the justOver array - for (i = 0; i < total; i++) - { - gameObject = justOver[i]; - - if (!gameObject.input) - { - continue; - } - - this.emit('gameobjectover', pointer, gameObject); - - gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY); - - manager.setCursor(gameObject.input); - - totalInteracted++; - } - } - - // Add the contents of justOver to the previously over array - previouslyOver = stillOver.concat(justOver); - - // Then sort it into display list order - this._over[pointer.id] = this.sortGameObjects(previouslyOver); - - return totalInteracted; - }, - - /** - * An internal method that handles the Pointer up events. - * - * @method Phaser.Input.InputPlugin#processUpEvents - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. - * - * @return {integer} The total number of objects interacted with. - */ - processUpEvents: function (pointer) - { - var currentlyOver = this._temp; - - // Contains ALL Game Objects currently up in the array - this.emit('pointerup', pointer, currentlyOver); - - // Go through all objects the pointer was over and fire their events / callbacks - for (var i = 0; i < currentlyOver.length; i++) - { - var gameObject = currentlyOver[i]; - - if (!gameObject.input) - { - continue; - } - - // pointerupoutside - - gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY); - - this.emit('gameobjectup', pointer, gameObject); - } - - return currentlyOver.length; - }, - - /** - * Queues a Game Object for insertion into this Input Plugin on the next update. - * - * @method Phaser.Input.InputPlugin#queueForInsertion - * @private - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to add. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - queueForInsertion: function (child) - { - if (this._pendingInsertion.indexOf(child) === -1 && this._list.indexOf(child) === -1) - { - this._pendingInsertion.push(child); - } - - return this; - }, - - /** - * Queues a Game Object for removal from this Input Plugin on the next update. - * - * @method Phaser.Input.InputPlugin#queueForRemoval - * @private - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to remove. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - queueForRemoval: function (child) - { - this._pendingRemoval.push(child); - - return this; - }, - - /** - * Sets the draggable state of the given array of Game Objects. - * - * They can either be set to be draggable, or can have their draggable state removed by passing `false`. - * - * A Game Object will not fire drag events unless it has been specifically enabled for drag. - * - * @method Phaser.Input.InputPlugin#setDraggable - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to change the draggable state on. - * @param {boolean} [value=true] - Set to `true` if the Game Objects should be made draggable, `false` if they should be unset. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setDraggable: function (gameObjects, value) - { - if (value === undefined) { value = true; } - - if (!Array.isArray(gameObjects)) - { - gameObjects = [ gameObjects ]; - } - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - - gameObject.input.draggable = value; - - var index = this._draggable.indexOf(gameObject); - - if (value && index === -1) - { - this._draggable.push(gameObject); - } - else if (!value && index > -1) - { - this._draggable.splice(index, 1); - } - } - - return this; - }, - - /** - * Creates a function that can be passed to `setInteractive`, `enable` or `setHitArea` that will handle - * pixel-perfect input detection on an Image or Sprite based Game Object, or any custom class that extends them. - * - * The following will create a sprite that is clickable on any pixel that has an alpha value >= 1. - * - * ```javascript - * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect()); - * ``` - * - * The following will create a sprite that is clickable on any pixel that has an alpha value >= 150. - * - * ```javascript - * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect(150)); - * ``` - * - * Once you have made an Interactive Object pixel perfect it impacts all input related events for it: down, up, - * dragstart, drag, etc. - * - * As a pointer interacts with the Game Object it will constantly poll the texture, extracting a single pixel from - * the given coordinates and checking its color values. This is an expensive process, so should only be enabled on - * Game Objects that really need it. - * - * You cannot make non-texture based Game Objects pixel perfect. So this will not work on Graphics, BitmapText, - * Render Textures, Text, Tilemaps, Containers or Particles. - * - * @method Phaser.Input.InputPlugin#makePixelPerfect - * @since 3.10.0 - * - * @param {integer} [alphaTolerance=1] - The alpha level that the pixel should be above to be included as a successful interaction. - * - * @return {function} A Pixel Perfect Handler for use as a hitArea shape callback. - */ - makePixelPerfect: function (alphaTolerance) - { - if (alphaTolerance === undefined) { alphaTolerance = 1; } - - var textureManager = this.systems.textures; - - return CreatePixelPerfectHandler(textureManager, alphaTolerance); - }, - - /** - * @typedef {object} Phaser.Input.InputConfiguration - * - * @property {any} [hitArea] - The object / shape to use as the Hit Area. If not given it will try to create a Rectangle based on the texture frame. - * @property {function} [hitAreaCallback] - The callback that determines if the pointer is within the Hit Area shape or not. - * @property {boolean} [draggable=false] - If `true` the Interactive Object will be set to be draggable and emit drag events. - * @property {boolean} [dropZone=false] - If `true` the Interactive Object will be set to be a drop zone for draggable objects. - * @property {boolean} [useHandCursor=false] - If `true` the Interactive Object will set the `pointer` hand cursor when a pointer is over it. This is a short-cut for setting `cursor: 'pointer'`. - * @property {string} [cursor] - The CSS string to be used when the cursor is over this Interactive Object. - * @property {boolean} [pixelPerfect=false] - If `true` the a pixel perfect function will be set for the hit area callback. Only works with texture based Game Objects. - * @property {integer} [alphaTolerance=1] - If `pixelPerfect` is set, this is the alpha tolerance threshold value used in the callback. - */ - - /** - * Sets the hit area for the given array of Game Objects. - * - * A hit area is typically one of the geometric shapes Phaser provides, such as a `Phaser.Geom.Rectangle` - * or `Phaser.Geom.Circle`. However, it can be any object as long as it works with the provided callback. - * - * If no hit area is provided a Rectangle is created based on the size of the Game Object, if possible - * to calculate. - * - * The hit area callback is the function that takes an `x` and `y` coordinate and returns a boolean if - * those values fall within the area of the shape or not. All of the Phaser geometry objects provide this, - * such as `Phaser.Geom.Rectangle.Contains`. - * - * @method Phaser.Input.InputPlugin#setHitArea - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set the hit area on. - * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setHitArea: function (gameObjects, shape, callback) - { - if (shape === undefined) - { - return this.setHitAreaFromTexture(gameObjects); - } - - if (!Array.isArray(gameObjects)) - { - gameObjects = [ gameObjects ]; - } - - var draggable = false; - var dropZone = false; - var cursor = false; - var useHandCursor = false; - - // Config object? - if (IsPlainObject(shape)) - { - var config = shape; - - shape = GetFastValue(config, 'hitArea', null); - callback = GetFastValue(config, 'hitAreaCallback', null); - draggable = GetFastValue(config, 'draggable', false); - dropZone = GetFastValue(config, 'dropZone', false); - cursor = GetFastValue(config, 'cursor', false); - useHandCursor = GetFastValue(config, 'useHandCursor', false); - - var pixelPerfect = GetFastValue(config, 'pixelPerfect', false); - var alphaTolerance = GetFastValue(config, 'alphaTolerance', 1); - - if (pixelPerfect) - { - shape = {}; - callback = this.makePixelPerfect(alphaTolerance); - } - - // Still no hitArea or callback? - if (!shape || !callback) - { - this.setHitAreaFromTexture(gameObjects); - } - } - else if (typeof shape === 'function' && !callback) - { - callback = shape; - shape = {}; - } - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - - var io = (!gameObject.input) ? CreateInteractiveObject(gameObject, shape, callback) : gameObject.input; - - io.dropZone = dropZone; - io.cursor = (useHandCursor) ? 'pointer' : cursor; - - gameObject.input = io; - - if (draggable) - { - this.setDraggable(gameObject); - } - - this.queueForInsertion(gameObject); - } - - return this; - }, - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Circle` shape, using - * the given coordinates and radius to control its position and size. - * - * @method Phaser.Input.InputPlugin#setHitAreaCircle - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a circle hit area. - * @param {number} x - The center of the circle. - * @param {number} y - The center of the circle. - * @param {number} radius - The radius of the circle. - * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Circle.Contains. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setHitAreaCircle: function (gameObjects, x, y, radius, callback) - { - if (callback === undefined) { callback = CircleContains; } - - var shape = new Circle(x, y, radius); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Ellipse` shape, using - * the given coordinates and dimensions to control its position and size. - * - * @method Phaser.Input.InputPlugin#setHitAreaEllipse - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area. - * @param {number} x - The center of the ellipse. - * @param {number} y - The center of the ellipse. - * @param {number} width - The width of the ellipse. - * @param {number} height - The height of the ellipse. - * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Ellipse.Contains. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setHitAreaEllipse: function (gameObjects, x, y, width, height, callback) - { - if (callback === undefined) { callback = EllipseContains; } - - var shape = new Ellipse(x, y, width, height); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using - * the Game Objects texture frame to define the position and size of the hit area. - * - * @method Phaser.Input.InputPlugin#setHitAreaFromTexture - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area. - * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setHitAreaFromTexture: function (gameObjects, callback) - { - if (callback === undefined) { callback = RectangleContains; } - - if (!Array.isArray(gameObjects)) - { - gameObjects = [ gameObjects ]; - } - - for (var i = 0; i < gameObjects.length; i++) - { - var gameObject = gameObjects[i]; - - var frame = gameObject.frame; - - var width = 0; - var height = 0; - - if (frame) - { - width = frame.realWidth; - height = frame.realHeight; - } - else if (gameObject.width) - { - width = gameObject.width; - height = gameObject.height; - } - - if (gameObject.type === 'Container' && (width === 0 || height === 0)) - { - console.warn('Container.setInteractive() must specify a Shape or call setSize() first'); - continue; - } - - if (width !== 0 && height !== 0) - { - gameObject.input = CreateInteractiveObject(gameObject, new Rectangle(0, 0, width, height), callback); - - this.queueForInsertion(gameObject); - } - } - - return this; - }, - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using - * the given coordinates and dimensions to control its position and size. - * - * @method Phaser.Input.InputPlugin#setHitAreaRectangle - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a rectangular hit area. - * @param {number} x - The top-left of the rectangle. - * @param {number} y - The top-left of the rectangle. - * @param {number} width - The width of the rectangle. - * @param {number} height - The height of the rectangle. - * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setHitAreaRectangle: function (gameObjects, x, y, width, height, callback) - { - if (callback === undefined) { callback = RectangleContains; } - - var shape = new Rectangle(x, y, width, height); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Triangle` shape, using - * the given coordinates to control the position of its points. - * - * @method Phaser.Input.InputPlugin#setHitAreaTriangle - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a triangular hit area. - * @param {number} x1 - The x coordinate of the first point of the triangle. - * @param {number} y1 - The y coordinate of the first point of the triangle. - * @param {number} x2 - The x coordinate of the second point of the triangle. - * @param {number} y2 - The y coordinate of the second point of the triangle. - * @param {number} x3 - The x coordinate of the third point of the triangle. - * @param {number} y3 - The y coordinate of the third point of the triangle. - * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Triangle.Contains. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setHitAreaTriangle: function (gameObjects, x1, y1, x2, y2, x3, y3, callback) - { - if (callback === undefined) { callback = TriangleContains; } - - var shape = new Triangle(x1, y1, x2, y2, x3, y3); - - return this.setHitArea(gameObjects, shape, callback); - }, - - /** - * Sets the Pointers to always poll. - * - * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, - * or being interacted with it, regardless if the Pointer has actually moved or not. - * - * You should enable this if you want objects in your game to fire over / out events, and the objects - * are constantly moving, but the pointer may not have. Polling every frame has additional computation - * costs, especially if there are a large number of interactive objects in your game. - * - * @method Phaser.Input.InputPlugin#setPollAlways - * @since 3.0.0 - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setPollAlways: function () - { - this.pollRate = 0; - this._pollTimer = 0; - - return this; - }, - - /** - * Sets the Pointers to only poll when they are moved or updated. - * - * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, - * or being interacted with it. - * - * @method Phaser.Input.InputPlugin#setPollOnMove - * @since 3.0.0 - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setPollOnMove: function () - { - this.pollRate = -1; - this._pollTimer = 0; - - return this; - }, - - /** - * Sets the poll rate value. This is the amount of time that should have elapsed before a pointer - * will be polled again. See the `setPollAlways` and `setPollOnMove` methods. - * - * @method Phaser.Input.InputPlugin#setPollRate - * @since 3.0.0 - * - * @param {number} value - The amount of time, in ms, that should elapsed before re-polling the pointers. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setPollRate: function (value) - { - this.pollRate = value; - this._pollTimer = 0; - - return this; - }, - - /** - * When set to `true` the global Input Manager will emulate DOM behavior by only emitting events from - * the top-most Game Objects in the Display List. - * - * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. - * - * @method Phaser.Input.InputPlugin#setGlobalTopOnly - * @since 3.0.0 - * - * @param {boolean} value - `true` to only include the top-most Game Object, or `false` to include all Game Objects in a hit test. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setGlobalTopOnly: function (value) - { - this.manager.globalTopOnly = value; - - return this; - }, - - /** - * When set to `true` this Input Plugin will emulate DOM behavior by only emitting events from - * the top-most Game Objects in the Display List. - * - * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. - * - * @method Phaser.Input.InputPlugin#setTopOnly - * @since 3.0.0 - * - * @param {boolean} value - `true` to only include the top-most Game Object, or `false` to include all Game Objects in a hit test. - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - setTopOnly: function (value) - { - this.topOnly = value; - - return this; - }, - - /** - * Given an array of Game Objects, sort the array and return it, so that the objects are in depth index order - * with the lowest at the bottom. - * - * @method Phaser.Input.InputPlugin#sortGameObjects - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} gameObjects - An array of Game Objects to be sorted. - * - * @return {Phaser.GameObjects.GameObject[]} The sorted array of Game Objects. - */ - sortGameObjects: function (gameObjects) - { - if (gameObjects.length < 2) - { - return gameObjects; - } - - this.scene.sys.depthSort(); - - return gameObjects.sort(this.sortHandlerGO.bind(this)); - }, - - /** - * Return the child lowest down the display list (with the smallest index) - * Will iterate through all parent containers, if present. - * - * @method Phaser.Input.InputPlugin#sortHandlerGO - * @private - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} childA - The first Game Object to compare. - * @param {Phaser.GameObjects.GameObject} childB - The second Game Object to compare. - * - * @return {integer} Returns either a negative or positive integer, or zero if they match. - */ - sortHandlerGO: function (childA, childB) - { - if (!childA.parentContainer && !childB.parentContainer) - { - // Quick bail out when neither child has a container - return this.displayList.getIndex(childB) - this.displayList.getIndex(childA); - } - else if (childA.parentContainer === childB.parentContainer) - { - // Quick bail out when both children have the same container - return childB.parentContainer.getIndex(childB) - childA.parentContainer.getIndex(childA); - } - else if (childA.parentContainer === childB) - { - // Quick bail out when childA is a child of childB - return -1; - } - else if (childB.parentContainer === childA) - { - // Quick bail out when childA is a child of childB - return 1; - } - else - { - // Container index check - var listA = childA.getIndexList(); - var listB = childB.getIndexList(); - var len = Math.min(listA.length, listB.length); - - for (var i = 0; i < len; i++) - { - var indexA = listA[i]; - var indexB = listB[i]; - - if (indexA === indexB) - { - // Go to the next level down - continue; - } - else - { - // Non-matching parents, so return - return indexB - indexA; - } - } - } - - // Technically this shouldn't happen, but ... - return 0; - }, - - /** - * Causes the Input Manager to stop emitting any events for the remainder of this game step. - * - * @method Phaser.Input.InputPlugin#stopPropagation - * @since 3.0.0 - * - * @return {Phaser.Input.InputPlugin} This InputPlugin object. - */ - stopPropagation: function () - { - if (this.manager.globalTopOnly) - { - this.manager.ignoreEvents = true; - } - - return this; - }, - - /** - * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is released, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * - * @method Phaser.Input.InputPlugin#addUpCallback - * @since 3.10.0 - * - * @param {function} callback - The callback to be invoked on this DOM event. - * @param {boolean} [isOnce=true] - `true` if the callback will only be invoked once, `false` to call every time this event happens. - * - * @return {this} The Input Plugin. - */ - addUpCallback: function (callback, isOnce) - { - this.manager.addUpCallback(callback, isOnce); - - return this; - }, - - /** - * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is down, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * - * @method Phaser.Input.InputPlugin#addDownCallback - * @since 3.10.0 - * - * @param {function} callback - The callback to be invoked on this dom event. - * @param {boolean} [isOnce=true] - `true` if the callback will only be invoked once, `false` to call every time this event happens. - * - * @return {this} The Input Plugin. - */ - addDownCallback: function (callback, isOnce) - { - this.manager.addDownCallback(callback, isOnce); - - return this; - }, - - /** - * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. - * By setting the `isOnce` argument you can control if the callback is called once, - * or every time the DOM event occurs. - * - * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, - * within the scope of the DOM event handler. Therefore, they are considered as 'native' - * from the perspective of the browser. This means they can be used for tasks such as - * opening new browser windows, or anything which explicitly requires user input to activate. - * However, as a result of this, they come with their own risks, and as such should not be used - * for general game input, but instead be reserved for special circumstances. - * - * If all you're trying to do is execute a callback when a pointer is moved, then - * please use the internal Input event system instead. - * - * Please understand that these callbacks are invoked when the browser feels like doing so, - * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep - * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, - * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating - * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind - * solve. - * - * @method Phaser.Input.InputPlugin#addMoveCallback - * @since 3.10.0 - * - * @param {function} callback - The callback to be invoked on this dom event. - * @param {boolean} [isOnce=false] - `true` if the callback will only be invoked once, `false` to call every time this event happens. - * - * @return {this} The Input Plugin. - */ - addMoveCallback: function (callback, isOnce) - { - this.manager.addMoveCallback(callback, isOnce); - - return this; - }, - - /** - * Adds new Pointer objects to the Input Manager. - * - * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. - * - * You can create more either by calling this method, or by setting the `input.activePointers` property - * in the Game Config, up to a maximum of 10 pointers. - * - * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added - * via this method. - * - * @method Phaser.Input.InputPlugin#addPointer - * @since 3.10.0 - * - * @param {integer} [quantity=1] The number of new Pointers to create. A maximum of 10 is allowed in total. - * - * @return {Phaser.Input.Pointer[]} An array containing all of the new Pointer objects that were created. - */ - addPointer: function (quantity) - { - return this.manager.addPointer(quantity); - }, - - /** - * Tells the Input system to set a custom cursor. - * - * This cursor will be the default cursor used when interacting with the game canvas. - * - * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. - * - * Any valid CSS cursor value is allowed, including paths to image files, i.e.: - * - * ```javascript - * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); - * ``` - * - * Please read about the differences between browsers when it comes to the file formats and sizes they support: - * - * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor - * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property - * - * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. - * - * @method Phaser.Input.InputPlugin#setDefaultCursor - * @since 3.10.0 - * - * @param {string} cursor - The CSS to be used when setting the default cursor. - * - * @return {Phaser.Input.InputPlugin} This Input instance. - */ - setDefaultCursor: function (cursor) - { - this.manager.setDefaultCursor(cursor); - - return this; - }, - - /** - * 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 () - { - // Registered input plugins listen for this - this.pluginEvents.emit('shutdown'); - - this._temp.length = 0; - this._list.length = 0; - this._draggable.length = 0; - this._pendingRemoval.length = 0; - this._pendingInsertion.length = 0; - - for (var i = 0; i < 10; i++) - { - this._drag[i] = []; - this._over[i] = []; - } - - 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); - }, - - /** - * 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(); - - // Registered input plugins listen for this - this.pluginEvents.emit('destroy'); - - this.pluginEvents.removeAllListeners(); - - this.scene.sys.events.off('start', this.start, this); - - this.scene = null; - this.cameras = null; - this.manager = null; - this.events = null; - this.mouse = null; - }, - - /** - * The x coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - * - * @name Phaser.Input.InputPlugin#x - * @type {number} - * @readOnly - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.manager.activePointer.x; - } - - }, - - /** - * The y coordinates of the ActivePointer based on the first camera in the camera list. - * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. - * - * @name Phaser.Input.InputPlugin#y - * @type {number} - * @readOnly - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.manager.activePointer.y; - } - - }, - - /** - * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. - * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` - * which will always map to the most recently interacted pointer. - * - * @name Phaser.Input.InputPlugin#mousePointer - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - mousePointer: { - - get: function () - { - return this.manager.mousePointer; - } - - }, - - /** - * The current active input Pointer. - * - * @name Phaser.Input.InputPlugin#activePointer - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.0.0 - */ - activePointer: { - - get: function () - { - return this.manager.activePointer; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer1 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer1: { - - get: function () - { - return this.manager.pointers[1]; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer2 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer2: { - - get: function () - { - return this.manager.pointers[2]; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer3 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer3: { - - get: function () - { - return this.manager.pointers[3]; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer4 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer4: { - - get: function () - { - return this.manager.pointers[4]; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer5 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer5: { - - get: function () - { - return this.manager.pointers[5]; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer6 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer6: { - - get: function () - { - return this.manager.pointers[6]; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer7 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer7: { - - get: function () - { - return this.manager.pointers[7]; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer8 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer8: { - - get: function () - { - return this.manager.pointers[8]; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer9 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer9: { - - get: function () - { - return this.manager.pointers[9]; - } - - }, - - /** - * A touch-based Pointer object. - * This will be `undefined` by default unless you add a new Pointer using `addPointer`. - * - * @name Phaser.Input.InputPlugin#pointer10 - * @type {Phaser.Input.Pointer} - * @readOnly - * @since 3.10.0 - */ - pointer10: { - - get: function () - { - return this.manager.pointers[10]; - } - - } - -}); - -PluginCache.register('InputPlugin', InputPlugin, 'input'); - -module.exports = InputPlugin; - - -/***/ }), -/* 377 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * XBox 360 Gamepad Configuration. - * - * @name Phaser.Input.Gamepad.Configs.XBOX_360 - * @type {object} - * @since 3.0.0 - */ -module.exports = { - - UP: 12, - DOWN: 13, - LEFT: 14, - RIGHT: 15, - - MENU: 16, - - A: 0, - B: 1, - X: 2, - Y: 3, - - LB: 4, - RB: 5, - - LT: 6, - RT: 7, - - BACK: 8, - START: 9, - - LS: 10, - RS: 11, - - LEFT_STICK_H: 0, - LEFT_STICK_V: 1, - RIGHT_STICK_H: 2, - RIGHT_STICK_V: 3 - -}; - - -/***/ }), -/* 378 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Tatar SNES USB Controller Gamepad Configuration. - * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) - * - * @name Phaser.Input.Gamepad.Configs.SNES_USB - * @type {object} - * @since 3.0.0 - */ -module.exports = { - - UP: 12, - DOWN: 13, - LEFT: 14, - RIGHT: 15, - - SELECT: 8, - START: 9, - - B: 0, - A: 1, - Y: 2, - X: 3, - - LEFT_SHOULDER: 4, - RIGHT_SHOULDER: 5 - -}; - - -/***/ }), -/* 379 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * PlayStation DualShock 4 Gamepad Configuration. - * Sony PlayStation DualShock 4 (v2) wireless controller - * - * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4 - * @type {object} - * @since 3.0.0 - */ -module.exports = { - - UP: 12, - DOWN: 13, - LEFT: 14, - RIGHT: 15, - - SHARE: 8, - OPTIONS: 9, - PS: 16, - TOUCHBAR: 17, - - X: 0, - CIRCLE: 1, - SQUARE: 2, - TRIANGLE: 3, - - L1: 4, - R1: 5, - L2: 6, - R2: 7, - L3: 10, - R3: 11, - - LEFT_STICK_H: 0, - LEFT_STICK_V: 1, - RIGHT_STICK_H: 2, - RIGHT_STICK_V: 3 - -}; - - -/***/ }), -/* 380 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Input.Gamepad.Configs - */ - -module.exports = { - - DUALSHOCK_4: __webpack_require__(379), - SNES_USB: __webpack_require__(378), - XBOX_360: __webpack_require__(377) - -}; - - -/***/ }), -/* 381 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Gamepad = __webpack_require__(172); -var GetValue = __webpack_require__(4); -var InputPluginCache = __webpack_require__(76); - -/** - * @typedef {object} Pad - * - * @property {string} id - The ID of the Gamepad. - * @property {integer} index - The index of the Gamepad. - */ - -/** - * @classdesc - * The Gamepad Plugin is an input plugin that belongs to the Scene-owned Input system. - * - * Its role is to listen for native DOM Gamepad Events and then process them. - * - * You do not need to create this class directly, the Input system will create an instance of it automatically. - * - * You can access it from within a Scene using `this.input.gamepad`. - * - * To listen for a gamepad being connected: - * - * ```javascript - * this.input.gamepad.once('connected', function (pad) { - * // 'pad' is a reference to the gamepad that was just connected - * }); - * ``` - * - * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, - * this is for security reasons. However, it may also trust the page already, in which case you won't get the - * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads - * already connected. - * - * Once you have received the connected event, or polled the gamepads and found them enabled, you can access - * them via the built-in properties `GamepadPlugin.pad1` to `pad4`, for up to 4 game pads. With a reference - * to the gamepads you can poll its buttons and axis sticks. See the properties and methods available on - * the `Gamepad` class for more details. - * - * For more information about Gamepad support in browsers see the following resources: - * - * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API - * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API - * https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ - * http://html5gamepad.com/ - * - * @class GamepadPlugin - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Gamepad - * @constructor - * @since 3.10.0 - * - * @param {Phaser.Input.InputPlugin} sceneInputPlugin - A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. - */ -var GamepadPlugin = new Class({ - - Extends: EventEmitter, - - initialize: - - function GamepadPlugin (sceneInputPlugin) - { - EventEmitter.call(this); - - /** - * A reference to the Scene that this Input Plugin is responsible for. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#scene - * @type {Phaser.Scene} - * @since 3.10.0 - */ - this.scene = sceneInputPlugin.scene; - - /** - * A reference to the Scene Systems Settings. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#settings - * @type {Phaser.Scenes.Settings.Object} - * @since 3.10.0 - */ - this.settings = this.scene.sys.settings; - - /** - * A reference to the Scene Input Plugin that created this Keyboard Plugin. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#sceneInputPlugin - * @type {Phaser.Input.InputPlugin} - * @since 3.10.0 - */ - this.sceneInputPlugin = sceneInputPlugin; - - /** - * A boolean that controls if the Gamepad Manager is enabled or not. - * Can be toggled on the fly. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#enabled - * @type {boolean} - * @default true - * @since 3.10.0 - */ - this.enabled = true; - - /** - * The Gamepad Event target, as defined in the Game Config. - * Typically the browser window, but can be any interactive DOM element. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#target - * @type {any} - * @since 3.10.0 - */ - this.target; - - /** - * An array of the connected Gamepads. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#gamepads - * @type {Phaser.Input.Gamepad.Gamepad[]} - * @default [] - * @since 3.10.0 - */ - this.gamepads = []; - - /** - * An internal event queue. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#queue - * @type {GamepadEvent[]} - * @private - * @since 3.10.0 - */ - this.queue = []; - - /** - * Internal event handler. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#onGamepadHandler - * @type {function} - * @private - * @since 3.10.0 - */ - this.onGamepadHandler; - - /** - * Internal Gamepad reference. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#_pad1 - * @type {Phaser.Input.Gamepad.Gamepad} - * @private - * @since 3.10.0 - */ - this._pad1; - - /** - * Internal Gamepad reference. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#_pad2 - * @type {Phaser.Input.Gamepad.Gamepad} - * @private - * @since 3.10.0 - */ - this._pad2; - - /** - * Internal Gamepad reference. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#_pad3 - * @type {Phaser.Input.Gamepad.Gamepad} - * @private - * @since 3.10.0 - */ - this._pad3; - - /** - * Internal Gamepad reference. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#_pad4 - * @type {Phaser.Input.Gamepad.Gamepad} - * @private - * @since 3.10.0 - */ - this._pad4; - - sceneInputPlugin.pluginEvents.once('boot', this.boot, this); - sceneInputPlugin.pluginEvents.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#boot - * @private - * @since 3.10.0 - */ - boot: function () - { - var game = this.scene.sys.game; - var settings = this.settings.input; - var config = game.config; - - this.enabled = GetValue(settings, 'gamepad', config.inputGamepad) && game.device.input.gamepads; - this.target = GetValue(settings, 'gamepad.target', config.inputGamepadEventTarget); - - this.sceneInputPlugin.pluginEvents.once('destroy', this.destroy, 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.Input.Gamepad.GamepadPlugin#start - * @private - * @since 3.10.0 - */ - start: function () - { - if (this.enabled) - { - this.startListeners(); - } - - this.sceneInputPlugin.pluginEvents.once('shutdown', this.shutdown, this); - }, - - /** - * Checks to see if both this plugin and the Scene to which it belongs is active. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#isActive - * @since 3.10.0 - * - * @return {boolean} `true` if the plugin and the Scene it belongs to is active. - */ - isActive: function () - { - return (this.enabled && this.scene.sys.isActive()); - }, - - /** - * Starts the Gamepad Event listeners running. - * This is called automatically and does not need to be manually invoked. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#startListeners - * @private - * @since 3.10.0 - */ - startListeners: function () - { - var _this = this; - var target = this.target; - - var handler = function (event) - { - // console.log(event); - - if (event.defaultPrevented || !_this.isActive()) - { - // Do nothing if event already handled - return; - } - - _this.refreshPads(); - - _this.queue.push(event); - }; - - this.onGamepadHandler = handler; - - target.addEventListener('gamepadconnected', handler, false); - target.addEventListener('gamepaddisconnected', handler, false); - - // FF also supports gamepadbuttondown, gamepadbuttonup and gamepadaxismove but - // nothing else does, and we can get those values via the gamepads anyway, so we will - // until more browsers support this - - // Finally, listen for an update event from the Input Plugin - this.sceneInputPlugin.pluginEvents.on('update', this.update, this); - }, - - /** - * Stops the Gamepad Event listeners. - * This is called automatically and does not need to be manually invoked. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#stopListeners - * @private - * @since 3.10.0 - */ - stopListeners: function () - { - this.target.removeEventListener('gamepadconnected', this.onGamepadHandler); - this.target.removeEventListener('gamepaddisconnected', this.onGamepadHandler); - - this.sceneInputPlugin.pluginEvents.off('update', this.update); - }, - - /** - * Disconnects all current Gamepads. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#disconnectAll - * @since 3.10.0 - */ - disconnectAll: function () - { - for (var i = 0; i < this.gamepads.length; i++) - { - this.gamepads.connected = false; - } - }, - - /** - * Refreshes the list of connected Gamepads. - * - * This is called automatically when a gamepad is connected or disconnected, - * and during the update loop. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#refreshPads - * @private - * @since 3.10.0 - */ - refreshPads: function () - { - var connectedPads = navigator.getGamepads(); - - if (!connectedPads) - { - this.disconnectAll(); - } - else - { - var currentPads = this.gamepads; - - for (var i = 0; i < connectedPads.length; i++) - { - var livePad = connectedPads[i]; - - // Because sometimes they're null (yes, really) - if (!livePad) - { - continue; - } - - var id = livePad.id; - var index = livePad.index; - var currentPad = currentPads[index]; - - if (!currentPad) - { - // A new Gamepad, not currently stored locally - var newPad = new Gamepad(this, livePad); - - currentPads[index] = newPad; - - if (!this._pad1) - { - this._pad1 = newPad; - } - else if (!this._pad2) - { - this._pad2 = newPad; - } - else if (!this._pad3) - { - this._pad3 = newPad; - } - else if (!this._pad4) - { - this._pad4 = newPad; - } - } - else if (currentPad.id !== id) - { - // A new Gamepad with a different vendor string, but it has got the same index as an old one - currentPad.destroy(); - - currentPads[index] = new Gamepad(this, livePad); - } - else - { - // If neither of these, it's a pad we've already got, so update it - currentPad.update(livePad); - } - } - } - }, - - /** - * Returns an array of all currently connected Gamepads. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#getAll - * @since 3.10.0 - * - * @return {Phaser.Input.Gamepad.Gamepad[]} An array of all currently connected Gamepads. - */ - getAll: function () - { - var out = []; - var pads = this.gamepads; - - for (var i = 0; i < pads.length; i++) - { - if (pads[i]) - { - out.push(pads[i]); - } - } - - return out; - }, - - /** - * Looks-up a single Gamepad based on the given index value. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#getPad - * @since 3.10.0 - * - * @param {number} index - The index of the Gamepad to get. - * - * @return {Phaser.Input.Gamepad.Gamepad} The Gamepad matching the given index, or undefined if none were found. - */ - getPad: function (index) - { - var pads = this.gamepads; - - for (var i = 0; i < pads.length; i++) - { - if (pads[i] && pads[i].index === index) - { - return pads[i]; - } - } - }, - - /** - * The internal update loop. Refreshes all connected gamepads and processes their events. - * - * Called automatically by the Input Manager, invoked from the Game step. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#update - * @private - * @since 3.10.0 - */ - update: function () - { - if (!this.enabled) - { - return; - } - - this.refreshPads(); - - var len = this.queue.length; - - if (len === 0) - { - return; - } - - var queue = this.queue.splice(0, len); - - // Process the event queue, dispatching all of the events that have stored up - for (var i = 0; i < len; i++) - { - var event = queue[i]; - var pad = this.getPad(event.gamepad.index); - - if (event.type === 'gamepadconnected') - { - this.emit('connected', pad, event); - } - else if (event.type === 'gamepaddisconnected') - { - this.emit('disconnected', pad, event); - } - } - }, - - /** - * Shuts the Gamepad Plugin down. - * All this does is remove any listeners bound to it. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#shutdown - * @private - * @since 3.10.0 - */ - shutdown: function () - { - this.stopListeners(); - - this.disconnectAll(); - - this.removeAllListeners(); - }, - - /** - * Destroys this Gamepad Plugin, disconnecting all Gamepads and releasing internal references. - * - * @method Phaser.Input.Gamepad.GamepadPlugin#destroy - * @private - * @since 3.10.0 - */ - destroy: function () - { - this.shutdown(); - - for (var i = 0; i < this.gamepads.length; i++) - { - if (this.gamepads[i]) - { - this.gamepads[i].destroy(); - } - } - - this.gamepads = []; - - this.scene = null; - this.settings = null; - this.sceneInputPlugin = null; - this.target = null; - }, - - /** - * The total number of connected game pads. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#total - * @type {integer} - * @since 3.10.0 - */ - total: { - - get: function () - { - return this.gamepads.length; - } - - }, - - /** - * A reference to the first connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#pad1 - * @type {Phaser.Input.Gamepad.Gamepad} - * @since 3.10.0 - */ - pad1: { - - get: function () - { - return this._pad1; - } - - }, - - /** - * A reference to the second connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#pad2 - * @type {Phaser.Input.Gamepad.Gamepad} - * @since 3.10.0 - */ - pad2: { - - get: function () - { - return this._pad2; - } - - }, - - /** - * A reference to the third connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#pad3 - * @type {Phaser.Input.Gamepad.Gamepad} - * @since 3.10.0 - */ - pad3: { - - get: function () - { - return this._pad3; - } - - }, - - /** - * A reference to the fourth connected Gamepad. - * - * This will be undefined if either no pads are connected, or the browser - * has not yet issued a gamepadconnect, which can happen even if a Gamepad - * is plugged in, but hasn't yet had any buttons pressed on it. - * - * @name Phaser.Input.Gamepad.GamepadPlugin#pad4 - * @type {Phaser.Input.Gamepad.Gamepad} - * @since 3.10.0 - */ - pad4: { - - get: function () - { - return this._pad4; - } - - } - -}); - -/** - * An instance of the Gamepad Plugin class, if enabled via the `input.gamepad` Scene or Game Config property. - * Use this to create access Gamepads connected to the browser and respond to gamepad buttons. - * - * @name Phaser.Input.InputPlugin#gamepad - * @type {?Phaser.Input.Gamepad.GamepadPlugin} - * @since 3.10.0 - */ -InputPluginCache.register('GamepadPlugin', GamepadPlugin, 'gamepad', 'gamepad', 'inputGamepad'); - -module.exports = GamepadPlugin; - - -/***/ }), -/* 382 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Input.Gamepad - */ - -module.exports = { - - Axis: __webpack_require__(174), - Button: __webpack_require__(173), - Gamepad: __webpack_require__(172), - GamepadPlugin: __webpack_require__(381), - - Configs: __webpack_require__(380) -}; - - -/***/ }), -/* 383 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(200); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser.Input - */ - -var Input = { - - CreateInteractiveObject: __webpack_require__(175), - Gamepad: __webpack_require__(382), - InputManager: __webpack_require__(201), - InputPlugin: __webpack_require__(376), - InputPluginCache: __webpack_require__(76), - Keyboard: __webpack_require__(374), - Mouse: __webpack_require__(362), - Pointer: __webpack_require__(198), - Touch: __webpack_require__(361) - -}; - -// Merge in the consts -Input = Extend(false, Input, CONST); - -module.exports = Input; - - -/***/ }), -/* 384 */, -/* 385 */, -/* 386 */, -/* 387 */, -/* 388 */, -/* 389 */, -/* 390 */, -/* 391 */, -/* 392 */, -/* 393 */, -/* 394 */, -/* 395 */, -/* 396 */, -/* 397 */, -/* 398 */, -/* 399 */, -/* 400 */, -/* 401 */, -/* 402 */, -/* 403 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Text = __webpack_require__(110); - -/** - * Creates a new Text Game Object and returns it. - * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#text - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Text} The Game Object that was created. - */ -GameObjectCreator.register('text', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - // style Object = { - // font: [ 'font', '16px Courier' ], - // backgroundColor: [ 'backgroundColor', null ], - // fill: [ 'fill', '#fff' ], - // stroke: [ 'stroke', '#fff' ], - // strokeThickness: [ 'strokeThickness', 0 ], - // shadowOffsetX: [ 'shadow.offsetX', 0 ], - // shadowOffsetY: [ 'shadow.offsetY', 0 ], - // shadowColor: [ 'shadow.color', '#000' ], - // shadowBlur: [ 'shadow.blur', 0 ], - // shadowStroke: [ 'shadow.stroke', false ], - // shadowFill: [ 'shadow.fill', false ], - // align: [ 'align', 'left' ], - // maxLines: [ 'maxLines', 0 ], - // fixedWidth: [ 'fixedWidth', false ], - // fixedHeight: [ 'fixedHeight', false ], - // rtl: [ 'rtl', false ] - // } - - var content = GetAdvancedValue(config, 'text', ''); - var style = GetAdvancedValue(config, 'style', null); - - // Padding - // { padding: 2 } - // { padding: { x: , y: }} - // { padding: { left: , top: }} - // { padding: { left: , right: , top: , bottom: }} - - var padding = GetAdvancedValue(config, 'padding', null); - - if (padding !== null) - { - style.padding = padding; - } - - var text = new Text(this.scene, 0, 0, content, style); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, text, config); - - // Text specific config options: - - text.autoRound = GetAdvancedValue(config, 'autoRound', true); - text.resolution = GetAdvancedValue(config, 'resolution', 1); - - return text; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 404 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var BuildGameObjectAnimation = __webpack_require__(127); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Sprite = __webpack_require__(34); - -/** - * Creates a new Sprite Game Object and returns it. - * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#sprite - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Sprite} The Game Object that was created. - */ -GameObjectCreator.register('sprite', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var sprite = new Sprite(this.scene, 0, 0, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, sprite, config); - - // Sprite specific config options: - - BuildGameObjectAnimation(sprite, config); - - return sprite; -}); - - -/***/ }), -/* 405 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Image = __webpack_require__(69); - -/** - * Creates a new Image Game Object and returns it. - * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#image - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Image} The Game Object that was created. - */ -GameObjectCreator.register('image', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var image = new Image(this.scene, 0, 0, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, image, config); - - return image; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 406 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var Graphics = __webpack_require__(115); - -/** - * Creates a new Graphics Game Object and returns it. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#graphics - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Graphics} The Game Object that was created. - */ -GameObjectCreator.register('graphics', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - var graphics = new Graphics(this.scene, config); - - if (config.add) - { - this.scene.sys.displayList.add(graphics); - } - - return graphics; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 407 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Text = __webpack_require__(110); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#text - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {(string|string[])} text - The text this Text object will display. - * @param {object} [style] - The Text style configuration object. - * - * @return {Phaser.GameObjects.Text} The Game Object that was created. - */ -GameObjectFactory.register('text', function (x, y, text, style) -{ - return this.displayList.add(new Text(this.scene, x, y, text, style)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 408 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(11); -var Sprite = __webpack_require__(34); - -/** - * Creates a new Sprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#sprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Sprite} The Game Object that was created. - */ -GameObjectFactory.register('sprite', function (x, y, key, frame) -{ - var sprite = new Sprite(this.scene, x, y, key, frame); - - this.displayList.add(sprite); - this.updateList.add(sprite); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 409 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Image = __webpack_require__(69); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Image Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Image Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#image - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Image} The Game Object that was created. - */ -GameObjectFactory.register('image', function (x, y, key, frame) -{ - return this.displayList.add(new Image(this.scene, x, y, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 410 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Graphics = __webpack_require__(115); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Graphics Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Graphics Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#graphics - * @since 3.0.0 - * - * @param {GraphicsOptions} [config] - The Graphics configuration. - * - * @return {Phaser.GameObjects.Graphics} The Game Object that was created. - */ -GameObjectFactory.register('graphics', function (config) -{ - return this.displayList.add(new Graphics(this.scene, config)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 411 */, -/* 412 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(22); - -/** - * Calculates the ascent, descent and fontSize of a given font style. - * - * @function Phaser.GameObjects.Text.MeasureText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text.TextStyle} textStyle - The TextStyle object to measure. - * - * @return {object} An object containing the ascent, descent and fontSize of the TextStyle. - */ -var MeasureText = function (textStyle) -{ - // @property {HTMLCanvasElement} canvas - The canvas element that the text is rendered. - var canvas = CanvasPool.create(this); - - // @property {HTMLCanvasElement} context - The context of the canvas element that the text is rendered to. - var context = canvas.getContext('2d'); - - textStyle.syncFont(canvas, context); - - var width = Math.ceil(context.measureText(textStyle.testString).width * textStyle.baselineX); - var baseline = width; - var height = 2 * baseline; - - baseline = baseline * textStyle.baselineY | 0; - - canvas.width = width; - canvas.height = height; - - context.fillStyle = '#f00'; - context.fillRect(0, 0, width, height); - - context.font = textStyle._font; - - context.textBaseline = 'alphabetic'; - context.fillStyle = '#000'; - context.fillText(textStyle.testString, 0, baseline); - - var output = { - ascent: 0, - descent: 0, - fontSize: 0 - }; - - if (!context.getImageData(0, 0, width, height)) - { - output.ascent = baseline; - output.descent = baseline + 6; - output.fontSize = output.ascent + output.descent; - - CanvasPool.remove(canvas); - - return output; - } - - var imagedata = context.getImageData(0, 0, width, height).data; - var pixels = imagedata.length; - var line = width * 4; - var i; - var j; - var idx = 0; - var stop = false; - - // ascent. scan from top to bottom until we find a non red pixel - for (i = 0; i < baseline; i++) - { - for (j = 0; j < line; j += 4) - { - if (imagedata[idx + j] !== 255) - { - stop = true; - break; - } - } - - if (!stop) - { - idx += line; - } - else - { - break; - } - } - - output.ascent = baseline - i; - - idx = pixels - line; - stop = false; - - // descent. scan from bottom to top until we find a non red pixel - for (i = height; i > baseline; i--) - { - for (j = 0; j < line; j += 4) - { - if (imagedata[idx + j] !== 255) - { - stop = true; - break; - } - } - - if (!stop) - { - idx -= line; - } - else - { - break; - } - } - - output.descent = (i - baseline); - output.fontSize = output.ascent + output.descent; - - CanvasPool.remove(canvas); - - return output; -}; - -module.exports = MeasureText; - - -/***/ }), -/* 413 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); -var MeasureText = __webpack_require__(412); - -// Key: [ Object Key, Default Value ] - -/** - * A custom function that will be responsible for wrapping the text. - * @callback TextStyleWordWrapCallback - * - * @param {string} text - The string to wrap. - * @param {Phaser.GameObjects.Text} textObject - The Text instance. - * - * @return {(string|string[])} Should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - */ - -var propertyMap = { - fontFamily: [ 'fontFamily', 'Courier' ], - fontSize: [ 'fontSize', '16px' ], - fontStyle: [ 'fontStyle', '' ], - backgroundColor: [ 'backgroundColor', null ], - color: [ 'color', '#fff' ], - stroke: [ 'stroke', '#fff' ], - strokeThickness: [ 'strokeThickness', 0 ], - shadowOffsetX: [ 'shadow.offsetX', 0 ], - shadowOffsetY: [ 'shadow.offsetY', 0 ], - shadowColor: [ 'shadow.color', '#000' ], - shadowBlur: [ 'shadow.blur', 0 ], - shadowStroke: [ 'shadow.stroke', false ], - shadowFill: [ 'shadow.fill', false ], - align: [ 'align', 'left' ], - maxLines: [ 'maxLines', 0 ], - fixedWidth: [ 'fixedWidth', 0 ], - fixedHeight: [ 'fixedHeight', 0 ], - rtl: [ 'rtl', false ], - testString: [ 'testString', '|MÉqgy' ], - baselineX: [ 'baselineX', 1.2 ], - baselineY: [ 'baselineY', 1.4 ], - wordWrapWidth: [ 'wordWrap.width', null ], - wordWrapCallback: [ 'wordWrap.callback', null ], - wordWrapCallbackScope: [ 'wordWrap.callbackScope', null ], - wordWrapUseAdvanced: [ 'wordWrap.useAdvancedWrap', false ] -}; - -/** - * @classdesc - * [description] - * - * @class TextStyle - * @memberOf Phaser.GameObjects.Text - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling. - * @param {object} style - [description] - */ -var TextStyle = new Class({ - - initialize: - - function TextStyle (text, style) - { - /** - * The Text object that this TextStyle is styling. - * - * @name Phaser.GameObjects.Text.TextStyle#parent - * @type {Phaser.GameObjects.Text} - * @since 3.0.0 - */ - this.parent = text; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#fontFamily - * @type {string} - * @default 'Courier' - * @since 3.0.0 - */ - this.fontFamily; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#fontSize - * @type {string} - * @default '16px' - * @since 3.0.0 - */ - this.fontSize; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#fontStyle - * @type {string} - * @since 3.0.0 - */ - this.fontStyle; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#backgroundColor - * @type {string} - * @since 3.0.0 - */ - this.backgroundColor; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#color - * @type {string} - * @default '#fff' - * @since 3.0.0 - */ - this.color; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#stroke - * @type {string} - * @default '#fff' - * @since 3.0.0 - */ - this.stroke; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#strokeThickness - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.strokeThickness; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#shadowOffsetX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.shadowOffsetX; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#shadowOffsetY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.shadowOffsetY; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#shadowColor - * @type {string} - * @default '#000' - * @since 3.0.0 - */ - this.shadowColor; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#shadowBlur - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.shadowBlur; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#shadowStroke - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.shadowStroke; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#shadowFill - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.shadowFill; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#align - * @type {string} - * @default 'left' - * @since 3.0.0 - */ - this.align; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#maxLines - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.maxLines; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#fixedWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.fixedWidth; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#fixedHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.fixedHeight; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#rtl - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rtl; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#testString - * @type {string} - * @default '|MÉqgy' - * @since 3.0.0 - */ - this.testString; - - /** - * The amount of horizontal padding adding to the width of the text when calculating the font metrics. - * - * @name Phaser.GameObjects.Text.TextStyle#baselineX - * @type {number} - * @default 1.2 - * @since 3.3.0 - */ - this.baselineX; - - /** - * The amount of vertical padding adding to the width of the text when calculating the font metrics. - * - * @name Phaser.GameObjects.Text.TextStyle#baselineY - * @type {number} - * @default 1.4 - * @since 3.3.0 - */ - this.baselineY; - - /** - * [description] - * - * @name Phaser.GameObjects.Text.TextStyle#_font - * @type {string} - * @private - * @since 3.0.0 - */ - this._font; - - // Set to defaults + user style - this.setStyle(style, false); - - var metrics = GetValue(style, 'metrics', false); - - // Provide optional TextMetrics in the style object to avoid the canvas look-up / scanning - // Doing this is reset if you then change the font of this TextStyle after creation - if (metrics) - { - this.metrics = { - ascent: GetValue(metrics, 'ascent', 0), - descent: GetValue(metrics, 'descent', 0), - fontSize: GetValue(metrics, 'fontSize', 0) - }; - } - else - { - this.metrics = MeasureText(this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setStyle - * @since 3.0.0 - * - * @param {CSSStyleRule} style - [description] - * @param {boolean} [updateText=true] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setStyle: function (style, updateText) - { - if (updateText === undefined) { updateText = true; } - - // Avoid type mutation - if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number') - { - style.fontSize = style.fontSize.toString() + 'px'; - } - - for (var key in propertyMap) - { - if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') - { - // Callback & scope should be set without processing the values - this[key] = GetValue(style, propertyMap[key][0], propertyMap[key][1]); - } - else - { - this[key] = GetAdvancedValue(style, propertyMap[key][0], propertyMap[key][1]); - } - } - - // Allow for 'font' override - var font = GetValue(style, 'font', null); - - if (font === null) - { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); - } - else - { - this._font = font; - } - - // Allow for 'fill' to be used in place of 'color' - var fill = GetValue(style, 'fill', null); - - if (fill !== null) - { - this.color = fill; - } - - if (updateText) - { - return this.update(true); - } - else - { - return this.parent; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#syncFont - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] - */ - syncFont: function (canvas, context) - { - context.font = this._font; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#syncStyle - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] - */ - syncStyle: function (canvas, context) - { - context.textBaseline = 'alphabetic'; - - context.fillStyle = this.color; - context.strokeStyle = this.stroke; - - context.lineWidth = this.strokeThickness; - context.lineCap = 'round'; - context.lineJoin = 'round'; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#syncShadow - * @since 3.0.0 - * - * @param {CanvasRenderingContext2D} context - [description] - * @param {boolean} enabled - [description] - */ - syncShadow: function (context, enabled) - { - if (enabled) - { - context.shadowOffsetX = this.shadowOffsetX; - context.shadowOffsetY = this.shadowOffsetY; - context.shadowColor = this.shadowColor; - context.shadowBlur = this.shadowBlur; - } - else - { - context.shadowOffsetX = 0; - context.shadowOffsetY = 0; - context.shadowColor = 0; - context.shadowBlur = 0; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#update - * @since 3.0.0 - * - * @param {boolean} recalculateMetrics - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - update: function (recalculateMetrics) - { - if (recalculateMetrics) - { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); - - this.metrics = MeasureText(this); - } - - return this.parent.updateText(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setFont - * @since 3.0.0 - * - * @param {(string|object)} font - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFont: function (font) - { - if (typeof font === 'string') - { - this.fontFamily = font; - this.fontSize = ''; - this.fontStyle = ''; - } - else - { - this.fontFamily = GetValue(font, 'fontFamily', 'Courier'); - this.fontSize = GetValue(font, 'fontSize', '16px'); - this.fontStyle = GetValue(font, 'fontStyle', ''); - } - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setFontFamily - * @since 3.0.0 - * - * @param {string} family - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFontFamily: function (family) - { - this.fontFamily = family; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setFontStyle - * @since 3.0.0 - * - * @param {string} style - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFontStyle: function (style) - { - this.fontStyle = style; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setFontSize - * @since 3.0.0 - * - * @param {(number|string)} size - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFontSize: function (size) - { - if (typeof size === 'number') - { - size = size.toString() + 'px'; - } - - this.fontSize = size; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setTestString - * @since 3.0.0 - * - * @param {string} string - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setTestString: function (string) - { - this.testString = string; - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setFixedSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFixedSize: function (width, height) - { - this.fixedWidth = width; - this.fixedHeight = height; - - if (width) - { - this.parent.width = width; - } - - if (height) - { - this.parent.height = height; - } - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setBackgroundColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setBackgroundColor: function (color) - { - this.backgroundColor = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setFill - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setFill: function (color) - { - this.color = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setColor: function (color) - { - this.color = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setStroke - * @since 3.0.0 - * - * @param {string} color - [description] - * @param {number} thickness - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setStroke: function (color, thickness) - { - if (color === undefined) - { - // Reset the stroke to zero (disabling it) - this.strokeThickness = 0; - } - else - { - if (thickness === undefined) { thickness = this.strokeThickness; } - - this.stroke = color; - this.strokeThickness = thickness; - } - - return this.update(true); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setShadow - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {string} [color='#000'] - [description] - * @param {number} [blur=0] - [description] - * @param {boolean} [shadowStroke=false] - [description] - * @param {boolean} [shadowFill=true] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadow: function (x, y, color, blur, shadowStroke, shadowFill) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (color === undefined) { color = '#000'; } - if (blur === undefined) { blur = 0; } - if (shadowStroke === undefined) { shadowStroke = false; } - if (shadowFill === undefined) { shadowFill = true; } - - this.shadowOffsetX = x; - this.shadowOffsetY = y; - this.shadowColor = color; - this.shadowBlur = blur; - this.shadowStroke = shadowStroke; - this.shadowFill = shadowFill; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setShadowOffset - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowOffset: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.shadowOffsetX = x; - this.shadowOffsetY = y; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setShadowColor - * @since 3.0.0 - * - * @param {string} [color='#000'] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowColor: function (color) - { - if (color === undefined) { color = '#000'; } - - this.shadowColor = color; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setShadowBlur - * @since 3.0.0 - * - * @param {number} [blur=0] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowBlur: function (blur) - { - if (blur === undefined) { blur = 0; } - - this.shadowBlur = blur; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setShadowStroke - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowStroke: function (enabled) - { - this.shadowStroke = enabled; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setShadowFill - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setShadowFill: function (enabled) - { - this.shadowFill = enabled; - - return this.update(false); - }, - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * - * @method Phaser.GameObjects.Text.TextStyle#setWordWrapWidth - * @since 3.0.0 - * - * @param {number} width - The maximum width of a line in pixels. Set to null to remove wrapping. - * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setWordWrapWidth: function (width, useAdvancedWrap) - { - if (useAdvancedWrap === undefined) { useAdvancedWrap = false; } - - this.wordWrapWidth = width; - this.wordWrapUseAdvanced = useAdvancedWrap; - - return this.update(false); - }, - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * - * @method Phaser.GameObjects.Text.TextStyle#setWordWrapCallback - * @since 3.0.0 - * - * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setWordWrapCallback: function (callback, scope) - { - if (scope === undefined) { scope = null; } - - this.wordWrapCallback = callback; - this.wordWrapCallbackScope = scope; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setAlign - * @since 3.0.0 - * - * @param {string} align - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setAlign: function (align) - { - if (align === undefined) { align = 'left'; } - - this.align = align; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#setMaxLines - * @since 3.0.0 - * - * @param {integer} [max=0] - [description] - * - * @return {Phaser.GameObjects.Text} The parent Text object. - */ - setMaxLines: function (max) - { - if (max === undefined) { max = 0; } - - this.maxLines = max; - - return this.update(false); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#getTextMetrics - * @since 3.0.0 - * - * @return {object} [description] - */ - getTextMetrics: function () - { - var metrics = this.metrics; - - return { - ascent: metrics.ascent, - descent: metrics.descent, - fontSize: metrics.fontSize - }; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - var output = {}; - - for (var key in propertyMap) - { - output[key] = this[key]; - } - - output.metrics = this.getTextMetrics(); - - return output; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text.TextStyle#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.parent = undefined; - } - -}); - -module.exports = TextStyle; - - -/***/ }), -/* 414 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Text#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') - { - return; - } - - var ctx = renderer.currentContext; - - // var resolution = src.resolution; - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var canvas = src.canvas; - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (renderer.config.roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - - ctx.translate(canvas.width * (src.flipX ? 1 : 0), canvas.height * (src.flipY ? 1 : 0)); - - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, -src.displayOriginX, -src.displayOriginY, canvas.width, canvas.height); - - ctx.restore(); -}; - -module.exports = TextCanvasRenderer; - - -/***/ }), -/* 415 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Text#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') - { - return; - } - - if (src.dirty) - { - src.canvasTexture = renderer.canvasToTexture(src.canvas, src.canvasTexture); - src.dirty = false; - } - - this.pipeline.batchText(this, camera, parentMatrix); -}; - -module.exports = TextWebGLRenderer; - - -/***/ }), -/* 416 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(415); -} - -if (true) -{ - renderCanvas = __webpack_require__(414); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 417 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns an object containing dimensions of the Text object. - * - * @function Phaser.GameObjects.Text.GetTextSize - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - The Text object to get the size from. - * @param {number} size - [description] - * @param {array} lines - [description] - * - * @return {object} An object containing dimensions of the Text object. - */ -var GetTextSize = function (text, size, lines) -{ - var canvas = text.canvas; - var context = text.context; - var style = text.style; - - var lineWidths = []; - var maxLineWidth = 0; - var drawnLines = lines.length; - - if (style.maxLines > 0 && style.maxLines < lines.length) - { - drawnLines = style.maxLines; - } - - style.syncFont(canvas, context); - - // Text Width - - for (var i = 0; i < drawnLines; i++) - { - var lineWidth = style.strokeThickness; - - lineWidth += context.measureText(lines[i]).width; - - // Adjust for wrapped text - if (style.wordWrap) - { - lineWidth -= context.measureText(' ').width; - } - - lineWidths[i] = Math.ceil(lineWidth); - maxLineWidth = Math.max(maxLineWidth, lineWidths[i]); - } - - // Text Height - - var lineHeight = size.fontSize + style.strokeThickness; - var height = lineHeight * drawnLines; - var lineSpacing = text._lineSpacing || 0; - - if (lineSpacing < 0 && Math.abs(lineSpacing) > lineHeight) - { - lineSpacing = -lineHeight; - } - - // Adjust for line spacing - if (lineSpacing !== 0) - { - height += (lineSpacing > 0) ? lineSpacing * lines.length : lineSpacing * (lines.length - 1); - } - - return { - width: maxLineWidth, - height: height, - lines: drawnLines, - lineWidths: lineWidths, - lineSpacing: lineSpacing, - lineHeight: lineHeight - }; -}; - -module.exports = GetTextSize; - - -/***/ }), -/* 418 */, -/* 419 */, -/* 420 */, -/* 421 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Stepped easing. - * - * @function Phaser.Math.Easing.Stepped.Stepped - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [steps=1] - The number of steps in the ease. - * - * @return {number} The tweened value. - */ -var Stepped = function (v, steps) -{ - if (steps === undefined) { steps = 1; } - - if (v <= 0) - { - return 0; - } - else if (v >= 1) - { - return 1; - } - else - { - return (((steps * v) | 0) + 1) * (1 / steps); - } -}; - -module.exports = Stepped; - - -/***/ }), -/* 422 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sinusoidal ease-in/out. - * - * @function Phaser.Math.Easing.Sine.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 0.5 * (1 - Math.cos(Math.PI * v)); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 423 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sinusoidal ease-out. - * - * @function Phaser.Math.Easing.Sine.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return Math.sin(v * Math.PI / 2); - } -}; - -module.exports = Out; - - -/***/ }), -/* 424 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sinusoidal ease-in. - * - * @function Phaser.Math.Easing.Sine.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 1 - Math.cos(v * Math.PI / 2); - } -}; - -module.exports = In; - - -/***/ }), -/* 425 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quintic ease-in/out. - * - * @function Phaser.Math.Easing.Quintic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v * v * v + 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 426 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quintic ease-out. - * - * @function Phaser.Math.Easing.Quintic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return --v * v * v * v * v + 1; -}; - -module.exports = Out; - - -/***/ }), -/* 427 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quintic ease-in. - * - * @function Phaser.Math.Easing.Quintic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v * v * v * v; -}; - -module.exports = In; - - -/***/ }), -/* 428 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quartic ease-in/out. - * - * @function Phaser.Math.Easing.Quartic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v * v * v; - } - else - { - return -0.5 * ((v -= 2) * v * v * v - 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 429 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quartic ease-out. - * - * @function Phaser.Math.Easing.Quartic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return 1 - (--v * v * v * v); -}; - -module.exports = Out; - - -/***/ }), -/* 430 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quartic ease-in. - * - * @function Phaser.Math.Easing.Quartic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v * v * v; -}; - -module.exports = In; - - -/***/ }), -/* 431 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quadratic ease-in/out. - * - * @function Phaser.Math.Easing.Quadratic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v; - } - else - { - return -0.5 * (--v * (v - 2) - 1); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 432 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quadratic ease-out. - * - * @function Phaser.Math.Easing.Quadratic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return v * (2 - v); -}; - -module.exports = Out; - - -/***/ }), -/* 433 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quadratic ease-in. - * - * @function Phaser.Math.Easing.Quadratic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v; -}; - -module.exports = In; - - -/***/ }), -/* 434 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Linear easing (no variation). - * - * @function Phaser.Math.Easing.Linear.Linear - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Linear = function (v) -{ - return v; -}; - -module.exports = Linear; - - -/***/ }), -/* 435 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Exponential ease-in/out. - * - * @function Phaser.Math.Easing.Expo.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * Math.pow(2, 10 * (v - 1)); - } - else - { - return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 436 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Exponential ease-out. - * - * @function Phaser.Math.Easing.Expo.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return 1 - Math.pow(2, -10 * v); -}; - -module.exports = Out; - - -/***/ }), -/* 437 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Exponential ease-in. - * - * @function Phaser.Math.Easing.Expo.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return Math.pow(2, 10 * (v - 1)) - 0.001; -}; - -module.exports = In; - - -/***/ }), -/* 438 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Elastic ease-in/out. - * - * @function Phaser.Math.Easing.Elastic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] - * - * @return {number} The tweened value. - */ -var InOut = function (v, amplitude, period) -{ - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } - - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; - - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - if ((v *= 2) < 1) - { - return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } - else - { - return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; - } - } -}; - -module.exports = InOut; - - -/***/ }), -/* 439 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Elastic ease-out. - * - * @function Phaser.Math.Easing.Elastic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] - * - * @return {number} The tweened value. - */ -var Out = function (v, amplitude, period) -{ - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } - - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; - - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); - } -}; - -module.exports = Out; - - -/***/ }), -/* 440 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Elastic ease-in. - * - * @function Phaser.Math.Easing.Elastic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] - * - * @return {number} The tweened value. - */ -var In = function (v, amplitude, period) -{ - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } - - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; - - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } -}; - -module.exports = In; - - -/***/ }), -/* 441 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Cubic ease-in/out. - * - * @function Phaser.Math.Easing.Cubic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v + 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 442 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Cubic ease-out. - * - * @function Phaser.Math.Easing.Cubic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return --v * v * v + 1; -}; - -module.exports = Out; - - -/***/ }), -/* 443 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Cubic ease-in. - * - * @function Phaser.Math.Easing.Cubic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v * v; -}; - -module.exports = In; - - -/***/ }), -/* 444 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Circular ease-in/out. - * - * @function Phaser.Math.Easing.Circular.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return -0.5 * (Math.sqrt(1 - v * v) - 1); - } - else - { - return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 445 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Circular ease-out. - * - * @function Phaser.Math.Easing.Circular.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return Math.sqrt(1 - (--v * v)); -}; - -module.exports = Out; - - -/***/ }), -/* 446 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Circular ease-in. - * - * @function Phaser.Math.Easing.Circular.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return 1 - Math.sqrt(1 - v * v); -}; - -module.exports = In; - - -/***/ }), -/* 447 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Bounce ease-in/out. - * - * @function Phaser.Math.Easing.Bounce.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - var reverse = false; - - if (v < 0.5) - { - v = 1 - (v * 2); - reverse = true; - } - else - { - v = (v * 2) - 1; - } - - if (v < 1 / 2.75) - { - v = 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } - - if (reverse) - { - return (1 - v) * 0.5; - } - else - { - return v * 0.5 + 0.5; - } -}; - -module.exports = InOut; - - -/***/ }), -/* 448 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Bounce ease-out. - * - * @function Phaser.Math.Easing.Bounce.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - if (v < 1 / 2.75) - { - return 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } -}; - -module.exports = Out; - - -/***/ }), -/* 449 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Bounce ease-in. - * - * @function Phaser.Math.Easing.Bounce.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - v = 1 - v; - - if (v < 1 / 2.75) - { - return 1 - (7.5625 * v * v); - } - else if (v < 2 / 2.75) - { - return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); - } - else if (v < 2.5 / 2.75) - { - return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); - } - else - { - return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); - } -}; - -module.exports = In; - - -/***/ }), -/* 450 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Back ease-in/out. - * - * @function Phaser.Math.Easing.Back.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [overshoot=1.70158] - The overshoot amount. - * - * @return {number} The tweened value. - */ -var InOut = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } - - var s = overshoot * 1.525; - - if ((v *= 2) < 1) - { - return 0.5 * (v * v * ((s + 1) * v - s)); - } - else - { - return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 451 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Back ease-out. - * - * @function Phaser.Math.Easing.Back.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [overshoot=1.70158] - The overshoot amount. - * - * @return {number} The tweened value. - */ -var Out = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } - - return --v * v * ((overshoot + 1) * v + overshoot) + 1; -}; - -module.exports = Out; - - -/***/ }), -/* 452 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Back ease-in. - * - * @function Phaser.Math.Easing.Back.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [overshoot=1.70158] - The overshoot amount. - * - * @return {number} The tweened value. - */ -var In = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } - - return v * v * ((overshoot + 1) * v - overshoot); -}; - -module.exports = In; - - -/***/ }), -/* 453 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Back = __webpack_require__(247); -var Bounce = __webpack_require__(246); -var Circular = __webpack_require__(245); -var Cubic = __webpack_require__(244); -var Elastic = __webpack_require__(243); -var Expo = __webpack_require__(242); -var Linear = __webpack_require__(241); -var Quadratic = __webpack_require__(240); -var Quartic = __webpack_require__(239); -var Quintic = __webpack_require__(238); -var Sine = __webpack_require__(237); -var Stepped = __webpack_require__(236); - -// EaseMap -module.exports = { - - Power0: Linear, - Power1: Quadratic.Out, - Power2: Cubic.Out, - Power3: Quartic.Out, - Power4: Quintic.Out, - - Linear: Linear, - Quad: Quadratic.Out, - Cubic: Cubic.Out, - Quart: Quartic.Out, - Quint: Quintic.Out, - Sine: Sine.Out, - Expo: Expo.Out, - Circ: Circular.Out, - Elastic: Elastic.Out, - Back: Back.Out, - Bounce: Bounce.Out, - Stepped: Stepped, - - 'Quad.easeIn': Quadratic.In, - 'Cubic.easeIn': Cubic.In, - 'Quart.easeIn': Quartic.In, - 'Quint.easeIn': Quintic.In, - 'Sine.easeIn': Sine.In, - 'Expo.easeIn': Expo.In, - 'Circ.easeIn': Circular.In, - 'Elastic.easeIn': Elastic.In, - 'Back.easeIn': Back.In, - 'Bounce.easeIn': Bounce.In, - - 'Quad.easeOut': Quadratic.Out, - 'Cubic.easeOut': Cubic.Out, - 'Quart.easeOut': Quartic.Out, - 'Quint.easeOut': Quintic.Out, - 'Sine.easeOut': Sine.Out, - 'Expo.easeOut': Expo.Out, - 'Circ.easeOut': Circular.Out, - 'Elastic.easeOut': Elastic.Out, - 'Back.easeOut': Back.Out, - 'Bounce.easeOut': Bounce.Out, - - 'Quad.easeInOut': Quadratic.InOut, - 'Cubic.easeInOut': Cubic.InOut, - 'Quart.easeInOut': Quartic.InOut, - 'Quint.easeInOut': Quintic.InOut, - 'Sine.easeInOut': Sine.InOut, - 'Expo.easeInOut': Expo.InOut, - 'Circ.easeInOut': Circular.InOut, - 'Elastic.easeInOut': Elastic.InOut, - 'Back.easeInOut': Back.InOut, - 'Bounce.easeInOut': Bounce.InOut - -}; - - -/***/ }), -/* 454 */, -/* 455 */, -/* 456 */, -/* 457 */, -/* 458 */, -/* 459 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Image#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera, parentMatrix); -}; - -module.exports = ImageCanvasRenderer; - - -/***/ }), -/* 460 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Image#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchSprite(src, camera, parentMatrix); -}; - -module.exports = ImageWebGLRenderer; - - -/***/ }), -/* 461 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(460); -} - -if (true) -{ - renderCanvas = __webpack_require__(459); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 462 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Graphics#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Graphics} graphics - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== graphics.renderFlags || (graphics.cameraFilter > 0 && (graphics.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchGraphics(this, camera, parentMatrix); -}; - -module.exports = GraphicsWebGLRenderer; - - -/***/ }), -/* 463 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(462); - - // Needed for Graphics.generateTexture - renderCanvas = __webpack_require__(176); -} - -if (true) -{ - renderCanvas = __webpack_require__(176); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 464 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. - * - * @function Phaser.Geom.Ellipse.OffsetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Ellipse by. - * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. - */ -var OffsetPoint = function (ellipse, point) -{ - ellipse.x += point.x; - ellipse.y += point.y; - - return ellipse; -}; - -module.exports = OffsetPoint; - - -/***/ }), -/* 465 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Ellipse by the values given. - * - * @function Phaser.Geom.Ellipse.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {number} x - The amount to horizontally offset the Ellipse by. - * @param {number} y - The amount to vertically offset the Ellipse by. - * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. - */ -var Offset = function (ellipse, x, y) -{ - ellipse.x += x; - ellipse.y += y; - - return ellipse; -}; - -module.exports = Offset; - - -/***/ }), -/* 466 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * Returns the bounds of the Ellipse object. - * - * @function Phaser.Geom.Ellipse.GetBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. - * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. - * - * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Ellipse bounds. - */ -var GetBounds = function (ellipse, out) -{ - if (out === undefined) { out = new Rectangle(); } - - out.x = ellipse.left; - out.y = ellipse.top; - out.width = ellipse.width; - out.height = ellipse.height; - - return out; -}; - -module.exports = GetBounds; - - -/***/ }), -/* 467 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. - * Returns `true` if they all match, otherwise returns `false`. - * - * @function Phaser.Geom.Ellipse.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. - * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. - * - * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. - */ -var Equals = function (ellipse, toCompare) -{ - return ( - ellipse.x === toCompare.x && - ellipse.y === toCompare.y && - ellipse.width === toCompare.width && - ellipse.height === toCompare.height - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 468 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse - * into the given `dest` Ellipse, then returns the `dest` Ellipse. - * - * @function Phaser.Geom.Ellipse.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Ellipse} O - [dest,$return] - * - * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. - * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. - * - * @return {Phaser.Geom.Ellipse} The dest Ellipse. - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.width, source.height); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 469 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(54); - -/** - * Check to see if the Ellipse contains all four points of the given Rectangle object. - * - * @function Phaser.Geom.Ellipse.ContainsRect - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not. - * - * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. - */ -var ContainsRect = function (ellipse, rect) -{ - return ( - Contains(ellipse, rect.x, rect.y) && - Contains(ellipse, rect.right, rect.y) && - Contains(ellipse, rect.x, rect.bottom) && - Contains(ellipse, rect.right, rect.bottom) - ); -}; - -module.exports = ContainsRect; - - -/***/ }), -/* 470 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(54); - -/** - * Check to see if the Ellipse contains the given Point object. - * - * @function Phaser.Geom.Ellipse.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. - * - * @return {boolean} True if the Point coordinates are within the circle, otherwise false. - */ -var ContainsPoint = function (ellipse, point) -{ - return Contains(ellipse, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 471 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Ellipse = __webpack_require__(114); - -/** - * Creates a new Ellipse instance based on the values contained in the given source. - * - * @function Phaser.Geom.Ellipse.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. - * - * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. - */ -var Clone = function (source) -{ - return new Ellipse(source.x, source.y, source.width, source.height); -}; - -module.exports = Clone; - - -/***/ }), -/* 472 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the area of the Ellipse. - * - * @function Phaser.Geom.Ellipse.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. - * - * @return {number} The area of the Ellipse. - */ -var Area = function (ellipse) -{ - if (ellipse.isEmpty()) - { - return 0; - } - - // units squared - return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); -}; - -module.exports = Area; - - -/***/ }), -/* 473 */, -/* 474 */, -/* 475 */, -/* 476 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * The Update List plugin. - * - * Update Lists belong to a Scene and maintain the list Game Objects to be updated every frame. - * - * Some or all of these Game Objects may also be part of the Scene's [Display List]{@link Phaser.GameObjects.DisplayList}, for Rendering. - * - * @class UpdateList - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene that the Update List belongs to. - */ -var UpdateList = new Class({ - - initialize: - - function UpdateList (scene) - { - /** - * The Scene that the Update List belongs to. - * - * @name Phaser.GameObjects.UpdateList#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * The Scene's Systems. - * - * @name Phaser.GameObjects.UpdateList#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * The list of Game Objects. - * - * @name Phaser.GameObjects.UpdateList#_list - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._list = []; - - /** - * Game Objects that are pending insertion into the list. - * - * @name Phaser.GameObjects.UpdateList#_pendingInsertion - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingInsertion = []; - - /** - * Game Objects that are pending removal from the list. - * - * @name Phaser.GameObjects.UpdateList#_pendingRemoval - * @type {array} - * @private - * @default [] - * @since 3.0.0 - */ - this._pendingRemoval = []; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.GameObjects.UpdateList#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.systems.events.once('destroy', this.destroy, 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.GameObjects.UpdateList#start - * @private - * @since 3.5.0 - */ - start: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('preupdate', this.preUpdate, this); - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); - }, - - /** - * Add a Game Object to the Update List. - * - * @method Phaser.GameObjects.UpdateList#add - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to add. - * - * @return {Phaser.GameObjects.GameObject} The added Game Object. - */ - add: function (child) - { - // Is child already in this list? - - if (this._list.indexOf(child) === -1 && this._pendingInsertion.indexOf(child) === -1) - { - this._pendingInsertion.push(child); - } - - return child; - }, - - /** - * The pre-update step. - * - * Handles Game Objects that are pending insertion to and removal from the list. - * - * @method Phaser.GameObjects.UpdateList#preUpdate - * @since 3.0.0 - */ - preUpdate: function () - { - var toRemove = this._pendingRemoval.length; - var toInsert = this._pendingInsertion.length; - - if (toRemove === 0 && toInsert === 0) - { - // Quick bail - return; - } - - var i; - var gameObject; - - // Delete old gameObjects - for (i = 0; i < toRemove; i++) - { - gameObject = this._pendingRemoval[i]; - - var index = this._list.indexOf(gameObject); - - if (index > -1) - { - this._list.splice(index, 1); - } - } - - // Move pending to active - this._list = this._list.concat(this._pendingInsertion.splice(0)); - - // Clear the lists - this._pendingRemoval.length = 0; - this._pendingInsertion.length = 0; - }, - - /** - * The update step. - * - * Pre-updates every active Game Object in the list. - * - * @method Phaser.GameObjects.UpdateList#update - * @since 3.0.0 - * - * @param {number} time - The current timestamp. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: function (time, delta) - { - for (var i = 0; i < this._list.length; i++) - { - var gameObject = this._list[i]; - - if (gameObject.active) - { - gameObject.preUpdate.call(gameObject, time, delta); - } - } - }, - - /** - * Remove a Game Object from the list. - * - * @method Phaser.GameObjects.UpdateList#remove - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to remove from the list. - * - * @return {Phaser.GameObjects.GameObject} The removed Game Object. - */ - remove: function (child) - { - var index = this._list.indexOf(child); - - if (index !== -1) - { - this._list.splice(index, 1); - } - - return child; - }, - - /** - * Remove all Game Objects from the list. - * - * @method Phaser.GameObjects.UpdateList#removeAll - * @since 3.0.0 - * - * @return {Phaser.GameObjects.UpdateList} This UpdateList. - */ - removeAll: function () - { - var i = this._list.length; - - while (i--) - { - this.remove(this._list[i]); - } - - return 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.GameObjects.UpdateList#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAll(); - - 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); - }, - - /** - * 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 - */ - destroy: function () - { - this.shutdown(); - - this.scene.sys.events.off('start', this.start, this); - - this.scene = null; - this.systems = null; - }, - - /** - * The length of the list. - * - * @name Phaser.GameObjects.UpdateList#length - * @type {integer} - * @readOnly - * @since 3.10.0 - */ - length: { - - get: function () - { - return this._list.length; - } - - } - -}); - -PluginCache.register('UpdateList', UpdateList, 'updateList'); - -module.exports = UpdateList; - - -/***/ }), -/* 477 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Swaps the position of two elements in the given array. - * The elements must exist in the same array. - * The array is modified in-place. - * - * @function Phaser.Utils.Array.Swap - * @since 3.4.0 - * - * @param {array} array - The input array. - * @param {*} item1 - The first element to swap. - * @param {*} item2 - The second element to swap. - * - * @return {array} The input array. - */ -var Swap = function (array, item1, item2) -{ - if (item1 === item2) - { - return; - } - - var index1 = array.indexOf(item1); - var index2 = array.indexOf(item2); - - if (index1 < 0 || index2 < 0) - { - throw new Error('Supplied items must be elements of the same array'); - } - - array[index1] = item2; - array[index2] = item1; - - return array; -}; - -module.exports = Swap; - - -/***/ }), -/* 478 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SafeRange = __webpack_require__(29); - -/** - * Scans the array for elements with the given property. If found, the property is set to the `value`. - * - * For example: `SetAll('visible', true)` would set all elements that have a `visible` property to `false`. - * - * Optionally you can specify a start and end index. For example if the array had 100 elements, - * and you set `startIndex` to 0 and `endIndex` to 50, it would update only the first 50 elements. - * - * @function Phaser.Utils.Array.SetAll - * @since 3.4.0 - * - * @param {array} array - The array to search. - * @param {string} property - The property to test for on each array element. - * @param {*} value - The value to set the property to. - * @param {integer} [startIndex] - An optional start index to search from. - * @param {integer} [endIndex] - An optional end index to search to. - * - * @return {array} The input array. - */ -var SetAll = function (array, property, value, startIndex, endIndex) -{ - if (startIndex === undefined) { startIndex = 0; } - if (endIndex === undefined) { endIndex = array.length; } - - if (SafeRange(array, startIndex, endIndex)) - { - for (var i = startIndex; i < endIndex; i++) - { - var entry = array[i]; - - if (entry.hasOwnProperty(property)) - { - entry[property] = value; - } - } - } - - return array; -}; - -module.exports = SetAll; - - -/***/ }), -/* 479 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the given element to the bottom of the array. - * The array is modified in-place. - * - * @function Phaser.Utils.Array.SendToBack - * @since 3.4.0 - * - * @param {array} array - The array. - * @param {*} item - The element to move. - * - * @return {*} The element that was moved. - */ -var SendToBack = function (array, item) -{ - var currentIndex = array.indexOf(item); - - if (currentIndex !== -1 && currentIndex > 0) - { - array.splice(currentIndex, 1); - array.unshift(item); - } - - return item; -}; - -module.exports = SendToBack; - - -/***/ }), -/* 480 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Replaces an element of the array with the new element. - * The new element cannot already be a member of the array. - * The array is modified in-place. - * - * @function Phaser.Utils.Array.Replace - * @since 3.4.0 - * - * @param {*} oldChild - The element in the array that will be replaced. - * @param {*} newChild - The element to be inserted into the array at the position of `oldChild`. - * - * @return {boolean} Returns true if the oldChild was successfully replaced, otherwise returns false. - */ -var Replace = function (array, oldChild, newChild) -{ - var index1 = array.indexOf(oldChild); - var index2 = array.indexOf(newChild); - - if (index1 !== -1 && index2 === -1) - { - array[index1] = newChild; - - return true; - } - else - { - return false; - } -}; - -module.exports = Replace; - - -/***/ }), -/* 481 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SpliceOne = __webpack_require__(56); - -/** - * Removes a random object from the given array and returns it. - * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. - * - * @function Phaser.Utils.Array.RemoveRandomElement - * @since 3.0.0 - * - * @param {array} array - The array to removed a random element from. - * @param {integer} [start=0] - The array index to start the search from. - * @param {integer} [length=array.length] - Optional restriction on the number of elements to randomly select from. - * - * @return {object} The random element that was removed, or `null` if there were no array elements that fell within the given range. - */ -var RemoveRandomElement = function (array, start, length) -{ - if (start === undefined) { start = 0; } - if (length === undefined) { length = array.length; } - - var randomIndex = start + Math.floor(Math.random() * length); - - return SpliceOne(array, randomIndex); -}; - -module.exports = RemoveRandomElement; - - -/***/ }), -/* 482 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SafeRange = __webpack_require__(29); - -/** - * Removes the item within the given range in the array. - * - * The array is modified in-place. - * - * You can optionally specify a callback to be invoked for the item/s successfully removed from the array. - * - * @function Phaser.Utils.Array.RemoveBetween - * @since 3.4.0 - * - * @param {array} array - The array to be modified. - * @param {integer} startIndex - The start index to remove from. - * @param {integer} endIndex - The end index to remove to. - * @param {function} [callback] - A callback to be invoked for the item removed from the array. - * @param {object} [context] - The context in which the callback is invoked. - * - * @return {Array.<*>} An array of items that were removed. - */ -var RemoveBetween = function (array, startIndex, endIndex, callback, context) -{ - if (startIndex === undefined) { startIndex = 0; } - if (endIndex === undefined) { endIndex = array.length; } - if (context === undefined) { context = array; } - - if (SafeRange(array, startIndex, endIndex)) - { - var size = endIndex - startIndex; - - var removed = array.splice(startIndex, size); - - if (callback) - { - for (var i = 0; i < removed.length; i++) - { - var entry = removed[i]; - - callback.call(context, entry); - } - } - - return removed; - } - else - { - return []; - } -}; - -module.exports = RemoveBetween; - - -/***/ }), -/* 483 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SpliceOne = __webpack_require__(56); - -/** - * Removes the item from the given position in the array. - * - * The array is modified in-place. - * - * You can optionally specify a callback to be invoked for the item if it is successfully removed from the array. - * - * @function Phaser.Utils.Array.RemoveAt - * @since 3.4.0 - * - * @param {array} array - The array to be modified. - * @param {integer} index - The array index to remove the item from. The index must be in bounds or it will throw an error. - * @param {function} [callback] - A callback to be invoked for the item removed from the array. - * @param {object} [context] - The context in which the callback is invoked. - * - * @return {*} The item that was removed. - */ -var RemoveAt = function (array, index, callback, context) -{ - if (context === undefined) { context = array; } - - if (index < 0 || index > array.length - 1) - { - throw new Error('Index out of bounds'); - } - - var item = SpliceOne(array, index); - - if (callback) - { - callback.call(context, item); - } - - return item; -}; - -module.exports = RemoveAt; - - -/***/ }), -/* 484 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RoundAwayFromZero = __webpack_require__(255); - -/** - * Create an array of numbers (positive and/or negative) progressing from `start` - * up to but not including `end` by advancing by `step`. - * - * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. - * - * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; - * for forward compatibility make sure to pass in actual numbers. - * - * @example - * NumberArrayStep(4); - * // => [0, 1, 2, 3] - * - * NumberArrayStep(1, 5); - * // => [1, 2, 3, 4] - * - * NumberArrayStep(0, 20, 5); - * // => [0, 5, 10, 15] - * - * NumberArrayStep(0, -4, -1); - * // => [0, -1, -2, -3] - * - * NumberArrayStep(1, 4, 0); - * // => [1, 1, 1] - * - * NumberArrayStep(0); - * // => [] - * - * @function Phaser.Utils.Array.NumberArrayStep - * @since 3.0.0 - * - * @param {number} [start=0] - The start of the range. - * @param {number} [end=null] - The end of the range. - * @param {number} [step=1] - The value to increment or decrement by. - * - * @return {number[]} [description] - */ -var NumberArrayStep = function (start, end, step) -{ - if (start === undefined) { start = 0; } - if (end === undefined) { end = null; } - if (step === undefined) { step = 1; } - - if (end === null) - { - end = start; - start = 0; - } - - var result = []; - - var total = Math.max(RoundAwayFromZero((end - start) / (step || 1)), 0); - - for (var i = 0; i < total; i++) - { - result.push(start); - start += step; - } - - return result; -}; - -module.exports = NumberArrayStep; - - -/***/ }), -/* 485 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Create an array representing the range of numbers (usually integers), between, and inclusive of, - * the given `start` and `end` arguments. For example: - * - * `var array = numberArray(2, 4); // array = [2, 3, 4]` - * `var array = numberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` - * - * This is equivalent to `numberArrayStep(start, end, 1)`. - * - * You can optionally provide a prefix and / or suffix string. If given the array will contain - * strings, not integers. For example: - * - * `var array = numberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` - * `var array = numberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` - * - * @function Phaser.Utils.Array.NumberArray - * @since 3.0.0 - * - * @param {number} start - The minimum value the array starts with. - * @param {number} end - The maximum value the array contains. - * @param {string} [prefix] - Optional prefix to place before the number. If provided the array will contain strings, not integers. - * @param {string} [suffix] - Optional suffix to place after the number. If provided the array will contain strings, not integers. - * - * @return {(number[]|string[])} The array of number values, or strings if a prefix or suffix was provided. - */ -var NumberArray = function (start, end, prefix, suffix) -{ - var result = []; - - for (var i = start; i <= end; i++) - { - if (prefix || suffix) - { - var key = (prefix) ? prefix + i.toString() : i.toString(); - - if (suffix) - { - key = key.concat(suffix); - } - - result.push(key); - } - else - { - result.push(i); - } - } - - return result; -}; - -module.exports = NumberArray; - - -/***/ }), -/* 486 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the given array element up one place in the array. - * The array is modified in-place. - * - * @function Phaser.Utils.Array.MoveUp - * @since 3.4.0 - * - * @param {array} array - The input array. - * @param {*} item - The element to move up the array. - * - * @return {array} The input array. - */ -var MoveUp = function (array, item) -{ - var currentIndex = array.indexOf(item); - - if (currentIndex !== -1 && currentIndex < array.length - 2) - { - var item2 = array[currentIndex + 1]; - - var index2 = array.indexOf(item2); - - array[currentIndex] = item2; - array[index2] = item; - } - - return array; -}; - -module.exports = MoveUp; - - -/***/ }), -/* 487 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves an element in an array to a new position within the same array. - * The array is modified in-place. - * - * @function Phaser.Utils.Array.MoveTo - * @since 3.4.0 - * - * @param {array} array - The array. - * @param {*} item - The element to move. - * @param {integer} index - The new index that the element will be moved to. - * - * @return {*} The element that was moved. - */ -var MoveTo = function (array, item, index) -{ - var currentIndex = array.indexOf(item); - - if (currentIndex === -1 || index < 0 || index >= array.length) - { - throw new Error('Supplied index out of bounds'); - } - - if (currentIndex !== index) - { - // Remove - array.splice(currentIndex, 1); - - // Add in new location - array.splice(index, 0, item); - } - - return item; -}; - -module.exports = MoveTo; - - -/***/ }), -/* 488 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the given array element down one place in the array. - * The array is modified in-place. - * - * @function Phaser.Utils.Array.MoveDown - * @since 3.4.0 - * - * @param {array} array - The input array. - * @param {*} item - The element to move down the array. - * - * @return {array} The input array. - */ -var MoveDown = function (array, item) -{ - var currentIndex = array.indexOf(item); - - if (currentIndex > 0) - { - var item2 = array[currentIndex - 1]; - - var index2 = array.indexOf(item2); - - array[currentIndex] = item2; - array[index2] = item; - } - - return array; -}; - -module.exports = MoveDown; - - -/***/ }), -/* 489 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SafeRange = __webpack_require__(29); - -/** - * Returns the first element in the array. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('visible', true)` would return the first element that had its `visible` property set. - * - * Optionally you can specify a start and end index. For example if the array had 100 elements, - * and you set `startIndex` to 0 and `endIndex` to 50, it would search only the first 50 elements. - * - * @function Phaser.Utils.Array.GetFirst - * @since 3.4.0 - * - * @param {array} array - The array to search. - * @param {string} [property] - The property to test on each array element. - * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=array.length] - An optional end index to search up to (but not included) - * - * @return {object} The first matching element from the array, or `null` if no element could be found in the range given. - */ -var GetFirst = function (array, property, value, startIndex, endIndex) -{ - if (startIndex === undefined) { startIndex = 0; } - if (endIndex === undefined) { endIndex = array.length; } - - if (SafeRange(array, startIndex, endIndex)) - { - for (var i = startIndex; i < endIndex; i++) - { - var child = array[i]; - - if (!property || - (property && value === undefined && child.hasOwnProperty(property)) || - (property && value !== undefined && child[property] === value)) - { - return child; - } - } - } - - return null; -}; - -module.exports = GetFirst; - - -/***/ }), -/* 490 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SafeRange = __webpack_require__(29); - -/** - * Returns all elements in the array. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('visible', true)` would return only elements that have their visible property set. - * - * Optionally you can specify a start and end index. For example if the array had 100 elements, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 elements. - * - * @function Phaser.Utils.Array.GetAll - * @since 3.4.0 - * - * @param {array} array - The array to search. - * @param {string} [property] - The property to test on each array element. - * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. - * @param {integer} [startIndex] - An optional start index to search from. - * @param {integer} [endIndex] - An optional end index to search to. - * - * @return {array} All matching elements from the array. - */ -var GetAll = function (array, property, value, startIndex, endIndex) -{ - if (startIndex === undefined) { startIndex = 0; } - if (endIndex === undefined) { endIndex = array.length; } - - var output = []; - - if (SafeRange(array, startIndex, endIndex)) - { - for (var i = startIndex; i < endIndex; i++) - { - var child = array[i]; - - if (!property || - (property && value === undefined && child.hasOwnProperty(property)) || - (property && value !== undefined && child[property] === value)) - { - output.push(child); - } - } - } - - return output; -}; - -module.exports = GetAll; - - -/***/ }), -/* 491 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SafeRange = __webpack_require__(29); - -/** - * Passes each element in the array, between the start and end indexes, to the given callback. - * - * @function Phaser.Utils.Array.EachInRange - * @since 3.4.0 - * - * @param {array} array - The array to search. - * @param {function} callback - A callback to be invoked for each item in the array. - * @param {object} context - The context in which the callback is invoked. - * @param {integer} startIndex - The start index to search from. - * @param {integer} endIndex - The end index to search to. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - * - * @return {array} The input array. - */ -var EachInRange = function (array, callback, context, startIndex, endIndex) -{ - if (startIndex === undefined) { startIndex = 0; } - if (endIndex === undefined) { endIndex = array.length; } - - if (SafeRange(array, startIndex, endIndex)) - { - var i; - var args = [ null ]; - - for (i = 5; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = startIndex; i < endIndex; i++) - { - args[0] = array[i]; - - callback.apply(context, args); - } - } - - return array; -}; - -module.exports = EachInRange; - - -/***/ }), -/* 492 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Passes each element in the array to the given callback. - * - * @function Phaser.Utils.Array.Each - * @since 3.4.0 - * - * @param {array} array - The array to search. - * @param {function} callback - A callback to be invoked for each item in the array. - * @param {object} context - The context in which the callback is invoked. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - * - * @return {array} The input array. - */ -var Each = function (array, callback, context) -{ - var i; - var args = [ null ]; - - for (i = 2; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = 0; i < array.length; i++) - { - args[0] = array[i]; - - callback.apply(context, args); - } - - return array; -}; - -module.exports = Each; - - -/***/ }), -/* 493 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SafeRange = __webpack_require__(29); - -/** - * Returns the total number of elements in the array which have a property matching the given value. - * - * @function Phaser.Utils.Array.CountAllMatching - * @since 3.4.0 - * - * @param {array} array - The array to search. - * @param {string} property - The property to test on each array element. - * @param {*} value - The value to test the property against. Must pass a strict (`===`) comparison check. - * @param {integer} [startIndex] - An optional start index to search from. - * @param {integer} [endIndex] - An optional end index to search to. - * - * @return {integer} The total number of elements with properties matching the given value. - */ -var CountAllMatching = function (array, property, value, startIndex, endIndex) -{ - if (startIndex === undefined) { startIndex = 0; } - if (endIndex === undefined) { endIndex = array.length; } - - var total = 0; - - if (SafeRange(array, startIndex, endIndex)) - { - for (var i = startIndex; i < endIndex; i++) - { - var child = array[i]; - - if (child[property] === value) - { - total++; - } - } - } - - return total; -}; - -module.exports = CountAllMatching; - - -/***/ }), -/* 494 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the given element to the top of the array. - * The array is modified in-place. - * - * @function Phaser.Utils.Array.BringToTop - * @since 3.4.0 - * - * @param {array} array - The array. - * @param {*} item - The element to move. - * - * @return {*} The element that was moved. - */ -var BringToTop = function (array, item) -{ - var currentIndex = array.indexOf(item); - - if (currentIndex !== -1 && currentIndex < array.length) - { - array.splice(currentIndex, 1); - array.push(item); - } - - return item; -}; - -module.exports = BringToTop; - - -/***/ }), -/* 495 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds the given item, or array of items, to the array starting at the index specified. - * - * Each item must be unique within the array. - * - * Existing elements in the array are shifted up. - * - * The array is modified in-place and returned. - * - * You can optionally specify a limit to the maximum size of the array. If the quantity of items being - * added will take the array length over this limit, it will stop adding once the limit is reached. - * - * You can optionally specify a callback to be invoked for each item successfully added to the array. - * - * @function Phaser.Utils.Array.AddAt - * @since 3.4.0 - * - * @param {array} array - The array to be added to. - * @param {any|any[]} item - The item, or array of items, to add to the array. - * @param {integer} [index=0] - The index in the array where the item will be inserted. - * @param {integer} [limit] - Optional limit which caps the size of the array. - * @param {function} [callback] - A callback to be invoked for each item successfully added to the array. - * @param {object} [context] - The context in which the callback is invoked. - * - * @return {array} The input array. - */ -var AddAt = function (array, item, index, limit, callback, context) -{ - if (index === undefined) { index = 0; } - if (context === undefined) { context = array; } - - if (limit > 0) - { - var remaining = limit - array.length; - - // There's nothing more we can do here, the array is full - if (remaining <= 0) - { - return null; - } - } - - // Fast path to avoid array mutation and iteration - if (!Array.isArray(item)) - { - if (array.indexOf(item) === -1) - { - array.splice(index, 0, item); - - if (callback) - { - callback.call(context, item); - } - - return item; - } - else - { - return null; - } - } - - // If we got this far, we have an array of items to insert - - // Ensure all the items are unique - var itemLength = item.length - 1; - - while (itemLength >= 0) - { - if (array.indexOf(item[itemLength]) !== -1) - { - // Already exists in array, so remove it - item.pop(); - } - - itemLength--; - } - - // Anything left? - itemLength = item.length; - - if (itemLength === 0) - { - return null; - } - - // Truncate to the limit - if (limit > 0 && itemLength > remaining) - { - item.splice(remaining); - - itemLength = remaining; - } - - for (var i = itemLength; i > 0; i--) - { - var entry = item[i]; - - array.splice(index, 0, entry); - - if (callback) - { - callback.call(context, entry); - } - } - - return item; -}; - -module.exports = AddAt; - - -/***/ }), -/* 496 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds the given item, or array of items, to the array. - * - * Each item must be unique within the array. - * - * The array is modified in-place and returned. - * - * You can optionally specify a limit to the maximum size of the array. If the quantity of items being - * added will take the array length over this limit, it will stop adding once the limit is reached. - * - * You can optionally specify a callback to be invoked for each item successfully added to the array. - * - * @function Phaser.Utils.Array.Add - * @since 3.4.0 - * - * @param {array} array - The array to be added to. - * @param {any|any[]} item - The item, or array of items, to add to the array. Each item must be unique within the array. - * @param {integer} [limit] - Optional limit which caps the size of the array. - * @param {function} [callback] - A callback to be invoked for each item successfully added to the array. - * @param {object} [context] - The context in which the callback is invoked. - * - * @return {array} The input array. - */ -var Add = function (array, item, limit, callback, context) -{ - if (context === undefined) { context = array; } - - if (limit > 0) - { - var remaining = limit - array.length; - - // There's nothing more we can do here, the array is full - if (remaining <= 0) - { - return null; - } - } - - // Fast path to avoid array mutation and iteration - if (!Array.isArray(item)) - { - if (array.indexOf(item) === -1) - { - array.push(item); - - if (callback) - { - callback.call(context, item); - } - - return item; - } - else - { - return null; - } - } - - // If we got this far, we have an array of items to insert - - // Ensure all the items are unique - var itemLength = item.length - 1; - - while (itemLength >= 0) - { - if (array.indexOf(item[itemLength]) !== -1) - { - // Already exists in array, so remove it - item.pop(); - } - - itemLength--; - } - - // Anything left? - itemLength = item.length; - - if (itemLength === 0) - { - return null; - } - - if (limit > 0 && itemLength > remaining) - { - item.splice(remaining); - - itemLength = remaining; - } - - for (var i = 0; i < itemLength; i++) - { - var entry = item[i]; - - array.push(entry); - - if (callback) - { - callback.call(context, entry); - } - } - - return item; -}; - -module.exports = Add; - - -/***/ }), -/* 497 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateMatrix = __webpack_require__(77); - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.RotateRight - * @since 3.0.0 - * - * @param {array} matrix - [description] - * - * @return {array} [description] - */ -var RotateRight = function (matrix) -{ - return RotateMatrix(matrix, -90); -}; - -module.exports = RotateRight; - - -/***/ }), -/* 498 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateMatrix = __webpack_require__(77); - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.RotateLeft - * @since 3.0.0 - * - * @param {array} matrix - [description] - * - * @return {array} [description] - */ -var RotateLeft = function (matrix) -{ - return RotateMatrix(matrix, 90); -}; - -module.exports = RotateLeft; - - -/***/ }), -/* 499 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateMatrix = __webpack_require__(77); - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.Rotate180 - * @since 3.0.0 - * - * @param {array} matrix - [description] - * - * @return {array} [description] - */ -var Rotate180 = function (matrix) -{ - return RotateMatrix(matrix, 180); -}; - -module.exports = Rotate180; - - -/***/ }), -/* 500 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.ReverseRows - * @since 3.0.0 - * - * @param {array} matrix - [description] - * - * @return {array} [description] - */ -var ReverseRows = function (matrix) -{ - return matrix.reverse(); -}; - -module.exports = ReverseRows; - - -/***/ }), -/* 501 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.ReverseColumns - * @since 3.0.0 - * - * @param {array} matrix - [description] - * - * @return {array} [description] - */ -var ReverseColumns = function (matrix) -{ - for (var i = 0; i < matrix.length; i++) - { - matrix[i].reverse(); - } - - return matrix; -}; - -module.exports = ReverseColumns; - - -/***/ }), -/* 502 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Pad = __webpack_require__(133); -var CheckMatrix = __webpack_require__(116); - -// Generates a string (which you can pass to console.log) from the given -// Array Matrix. - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.MatrixToString - * @since 3.0.0 - * - * @param {array} matrix - [description] - * - * @return {string} [description] - */ -var MatrixToString = function (matrix) -{ - var str = ''; - - if (!CheckMatrix(matrix)) - { - return str; - } - - for (var r = 0; r < matrix.length; r++) - { - for (var c = 0; c < matrix[r].length; c++) - { - var cell = matrix[r][c].toString(); - - if (cell !== 'undefined') - { - str += Pad(cell, 2); - } - else - { - str += '?'; - } - - if (c < matrix[r].length - 1) - { - str += ' |'; - } - } - - if (r < matrix.length - 1) - { - str += '\n'; - - for (var i = 0; i < matrix[r].length; i++) - { - str += '---'; - - if (i < matrix[r].length - 1) - { - str += '+'; - } - } - - str += '\n'; - } - - } - - return str; -}; - -module.exports = MatrixToString; - - -/***/ }), -/* 503 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils.Array.Matrix - */ - -module.exports = { - - CheckMatrix: __webpack_require__(116), - MatrixToString: __webpack_require__(502), - ReverseColumns: __webpack_require__(501), - ReverseRows: __webpack_require__(500), - Rotate180: __webpack_require__(499), - RotateLeft: __webpack_require__(498), - RotateMatrix: __webpack_require__(77), - RotateRight: __webpack_require__(497), - TransposeMatrix: __webpack_require__(181) - -}; - - -/***/ }), -/* 504 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var List = __webpack_require__(93); -var PluginCache = __webpack_require__(12); -var StableSort = __webpack_require__(83); - -/** - * @classdesc - * The Display List plugin. - * - * Display Lists belong to a Scene and maintain the list of Game Objects to render every frame. - * - * Some of these Game Objects may also be part of the Scene's [Update List]{@link Phaser.GameObjects.UpdateList}, for updating. - * - * @class DisplayList - * @extends Phaser.Structs.List. - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene that this Display List belongs to. - */ -var DisplayList = new Class({ - - Extends: List, - - initialize: - - function DisplayList (scene) - { - List.call(this, scene); - - /** - * The flag the determines whether Game Objects should be sorted when `depthSort()` is called. - * - * @name Phaser.GameObjects.DisplayList#sortChildrenFlag - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.sortChildrenFlag = false; - - /** - * The Scene that this Display List belongs to. - * - * @name Phaser.GameObjects.DisplayList#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * The Scene's Systems. - * - * @name Phaser.GameObjects.DisplayList#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.GameObjects.DisplayList#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.systems.events.once('destroy', this.destroy, 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.GameObjects.DisplayList#start - * @private - * @since 3.5.0 - */ - start: function () - { - this.systems.events.once('shutdown', this.shutdown, this); - }, - - /** - * Force a sort of the display list on the next call to depthSort. - * - * @method Phaser.GameObjects.DisplayList#queueDepthSort - * @since 3.0.0 - */ - queueDepthSort: function () - { - this.sortChildrenFlag = true; - }, - - /** - * Immediately sorts the display list if the flag is set. - * - * @method Phaser.GameObjects.DisplayList#depthSort - * @since 3.0.0 - */ - depthSort: function () - { - if (this.sortChildrenFlag) - { - StableSort.inplace(this.list, this.sortByDepth); - - this.sortChildrenFlag = false; - } - }, - - /** - * Compare the depth of two Game Objects. - * - * @method Phaser.GameObjects.DisplayList#sortByDepth - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} childA - The first Game Object. - * @param {Phaser.GameObjects.GameObject} childB - The second Game Object. - * - * @return {integer} The difference between the depths of each Game Object. - */ - sortByDepth: function (childA, childB) - { - return childA._depth - childB._depth; - }, - - /** - * Given an array of Game Objects, sort the array and return it, so that - * the objects are in index order with the lowest at the bottom. - * - * @method Phaser.GameObjects.DisplayList#sortGameObjects - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} gameObjects - The array of Game Objects to sort. - * - * @return {array} The sorted array of Game Objects. - */ - sortGameObjects: function (gameObjects) - { - if (gameObjects === undefined) { gameObjects = this.list; } - - this.scene.sys.depthSort(); - - return gameObjects.sort(this.sortIndexHandler.bind(this)); - }, - - /** - * Get the top-most Game Object in the given array of Game Objects, after sorting it. - * - * Note that the given array is sorted in place, even though it isn't returned directly it will still be updated. - * - * @method Phaser.GameObjects.DisplayList#getTopGameObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} gameObjects - The array of Game Objects. - * - * @return {Phaser.GameObjects.GameObject} The top-most Game Object in the array of Game Objects. - */ - getTopGameObject: function (gameObjects) - { - 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(); - - this.systems.events.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; - } - -}); - -PluginCache.register('DisplayList', DisplayList, 'displayList'); - -module.exports = DisplayList; - - -/***/ }), -/* 505 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Visibility Handler hidden event. - * - * The document in which the Game is embedded has entered a hidden state. - * - * @event Phaser.Boot.VisibilityHandler#hidden - */ - -/** - * Visibility Handler visible event. - * - * The document in which the Game is embedded has entered a visible state. - * - * @event Phaser.Boot.VisibilityHandler#visible - */ - -/** - * Visibility Handler blur event. - * - * The window in which the Game is embedded has entered a blurred state. - * - * @event Phaser.Boot.VisibilityHandler#blur - */ - -/** - * Visibility Handler focus event. - * - * The window in which the Game is embedded has entered a focused state. - * - * @event Phaser.Boot.VisibilityHandler#focus - */ - -/** - * The Visibility Handler is responsible for listening out for document level visibility change events. - * This includes `visibilitychange` if the browser supports it, and blur and focus events. It then uses - * the provided Event Emitter and fires the related events. - * - * @function Phaser.Boot.VisibilityHandler - * @fires Phaser.Boot.VisibilityHandler#hidden - * @fires Phaser.Boot.VisibilityHandler#visible - * @fires Phaser.Boot.VisibilityHandler#blur - * @fires Phaser.Boot.VisibilityHandler#focus - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Game instance this Visibility Handler is working on. - */ -var VisibilityHandler = function (game) -{ - var hiddenVar; - var eventEmitter = game.events; - - if (document.hidden !== undefined) - { - hiddenVar = 'visibilitychange'; - } - else - { - var vendors = [ 'webkit', 'moz', 'ms' ]; - - vendors.forEach(function (prefix) - { - if (document[prefix + 'Hidden'] !== undefined) - { - document.hidden = function () - { - return document[prefix + 'Hidden']; - }; - - hiddenVar = prefix + 'visibilitychange'; - } - - }); - } - - var onChange = function (event) - { - if (document.hidden || event.type === 'pause') - { - eventEmitter.emit('hidden'); - } - else - { - eventEmitter.emit('visible'); - } - }; - - if (hiddenVar) - { - document.addEventListener(hiddenVar, onChange, false); - } - - window.onblur = function () - { - eventEmitter.emit('blur'); - }; - - window.onfocus = function () - { - eventEmitter.emit('focus'); - }; - - // Automatically give the window focus unless config says otherwise - if (window.focus && game.config.autoFocus) - { - window.focus(); - - game.canvas.addEventListener('mousedown', function () - { - window.focus(); - }, { passive: true }); - } - - if (game.canvas) - { - game.canvas.onmouseout = function () - { - game.isOver = false; - eventEmitter.emit('mouseout'); - }; - - game.canvas.onmouseover = function () - { - game.isOver = true; - eventEmitter.emit('mouseover'); - }; - } -}; - -module.exports = VisibilityHandler; - - -/***/ }), -/* 506 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var RequestAnimationFrame = __webpack_require__(268); - -// Frame Rate config -// fps: { -// min: 10, -// target: 60, -// forceSetTimeOut: false, -// deltaHistory: 10, -// panicMax: 120 -// } - -// http://www.testufo.com/#test=animation-time-graph - -/** - * @callback TimeStepCallback - * - * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - * @param {number} average - The Delta Average. - * @param {number} interpolation - Interpolation - how far between what is expected and where we are? - */ - -/** - * @classdesc - * [description] - * - * @class TimeStep - * @memberOf Phaser.Boot - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this Time Step. - * @param {FPSConfig} config - */ -var TimeStep = new Class({ - - initialize: - - function TimeStep (game, config) - { - /** - * A reference to the Phaser.Game instance. - * - * @name Phaser.Boot.TimeStep#game - * @type {Phaser.Game} - * @readOnly - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#raf - * @type {Phaser.DOM.RequestAnimationFrame} - * @readOnly - * @since 3.0.0 - */ - this.raf = new RequestAnimationFrame(); - - /** - * A flag that is set once the TimeStep has started running and toggled when it stops. - * - * @name Phaser.Boot.TimeStep#started - * @type {boolean} - * @readOnly - * @default false - * @since 3.0.0 - */ - this.started = false; - - /** - * A flag that is set once the TimeStep has started running and toggled when it stops. - * The difference between this value and `started` is that `running` is toggled when - * the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if - * the TimeStep is actually stopped, not just paused. - * - * @name Phaser.Boot.TimeStep#running - * @type {boolean} - * @readOnly - * @default false - * @since 3.0.0 - */ - this.running = false; - - /** - * The minimum fps rate you want the Time Step to run at. - * - * @name Phaser.Boot.TimeStep#minFps - * @type {integer} - * @default 5 - * @since 3.0.0 - */ - this.minFps = GetValue(config, 'min', 5); - - /** - * The target fps rate for the Time Step to run at. - * - * Setting this value will not actually change the speed at which the browser runs, that is beyond - * the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step - * is spiraling out of control. - * - * @name Phaser.Boot.TimeStep#targetFps - * @type {integer} - * @default 60 - * @since 3.0.0 - */ - this.targetFps = GetValue(config, 'target', 60); - - /** - * The minFps value in ms. - * Defaults to 200ms between frames (i.e. super slow!) - * - * @name Phaser.Boot.TimeStep#_min - * @type {number} - * @private - * @since 3.0.0 - */ - this._min = 1000 / this.minFps; - - /** - * The targetFps value in ms. - * Defaults to 16.66ms between frames (i.e. normal) - * - * @name Phaser.Boot.TimeStep#_target - * @type {number} - * @private - * @since 3.0.0 - */ - this._target = 1000 / this.targetFps; - - /** - * An exponential moving average of the frames per second. - * - * @name Phaser.Boot.TimeStep#actualFps - * @type {integer} - * @readOnly - * @default 60 - * @since 3.0.0 - */ - this.actualFps = this.targetFps; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#nextFpsUpdate - * @type {integer} - * @readOnly - * @default 0 - * @since 3.0.0 - */ - this.nextFpsUpdate = 0; - - /** - * The number of frames processed this second. - * - * @name Phaser.Boot.TimeStep#framesThisSecond - * @type {integer} - * @readOnly - * @default 0 - * @since 3.0.0 - */ - this.framesThisSecond = 0; - - /** - * A callback to be invoked each time the Time Step steps. - * - * @name Phaser.Boot.TimeStep#callback - * @type {TimeStepCallback} - * @default NOOP - * @since 3.0.0 - */ - this.callback = NOOP; - - /** - * You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting - * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. - * - * @name Phaser.Boot.TimeStep#forceSetTimeOut - * @type {boolean} - * @readOnly - * @default false - * @since 3.0.0 - */ - this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false); - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#time - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.time = 0; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#startTime - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.startTime = 0; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#lastTime - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.lastTime = 0; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#frame - * @type {integer} - * @readOnly - * @default 0 - * @since 3.0.0 - */ - this.frame = 0; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#inFocus - * @type {boolean} - * @readOnly - * @default true - * @since 3.0.0 - */ - this.inFocus = true; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#_pauseTime - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._pauseTime = 0; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#_coolDown - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._coolDown = 0; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#delta - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.delta = 0; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#deltaIndex - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.deltaIndex = 0; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#deltaHistory - * @type {integer[]} - * @since 3.0.0 - */ - this.deltaHistory = []; - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#deltaSmoothingMax - * @type {integer} - * @default 10 - * @since 3.0.0 - */ - this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10); - - /** - * [description] - * - * @name Phaser.Boot.TimeStep#panicMax - * @type {integer} - * @default 120 - * @since 3.0.0 - */ - this.panicMax = GetValue(config, 'panicMax', 120); - - /** - * The actual elapsed time in ms between one update and the next. - * Unlike with `delta` no smoothing, capping, or averaging is applied to this value. - * So please be careful when using this value in calculations. - * - * @name Phaser.Boot.TimeStep#rawDelta - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rawDelta = 0; - }, - - /** - * Called when the DOM window.onBlur event triggers. - * - * @method Phaser.Boot.TimeStep#blur - * @since 3.0.0 - */ - blur: function () - { - this.inFocus = false; - }, - - /** - * Called when the DOM window.onFocus event triggers. - * - * @method Phaser.Boot.TimeStep#focus - * @since 3.0.0 - */ - focus: function () - { - this.inFocus = true; - - this.resetDelta(); - }, - - /** - * Called when the visibility API says the game is 'hidden' (tab switch out of view, etc) - * - * @method Phaser.Boot.TimeStep#pause - * @since 3.0.0 - */ - pause: function () - { - this._pauseTime = window.performance.now(); - }, - - /** - * Called when the visibility API says the game is 'visible' again (tab switch back into view, etc) - * - * @method Phaser.Boot.TimeStep#resume - * @since 3.0.0 - */ - resume: function () - { - this.resetDelta(); - - this.startTime += this.time - this._pauseTime; - }, - - /** - * [description] - * - * @method Phaser.Boot.TimeStep#resetDelta - * @since 3.0.0 - */ - resetDelta: function () - { - var now = window.performance.now(); - - this.time = now; - this.lastTime = now; - this.nextFpsUpdate = now + 1000; - this.framesThisSecond = 0; - this.frame = 0; - - // Pre-populate smoothing array - - for (var i = 0; i < this.deltaSmoothingMax; i++) - { - this.deltaHistory[i] = Math.min(this._target, this.deltaHistory[i]); - } - - this.delta = 0; - this.deltaIndex = 0; - - this._coolDown = this.panicMax; - }, - - /** - * Starts the Time Step running, if it is not already doing so. - * Called automatically by the Game Boot process. - * - * @method Phaser.Boot.TimeStep#start - * @since 3.0.0 - * - * @param {TimeStepCallback} callback - The callback to be invoked each time the Time Step steps. - */ - start: function (callback) - { - if (this.started) - { - return this; - } - - this.started = true; - this.running = true; - - for (var i = 0; i < this.deltaSmoothingMax; i++) - { - this.deltaHistory[i] = this._target; - } - - this.resetDelta(); - - this.startTime = window.performance.now(); - - this.callback = callback; - - this.raf.start(this.step.bind(this), this.forceSetTimeOut); - }, - - /** - * The main step method. This is called each time the browser updates, either by Request Animation Frame, - * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. - * You generally should never call this method directly. - * - * @method Phaser.Boot.TimeStep#step - * @since 3.0.0 - * - * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. - */ - step: function (time) - { - this.frame++; - - var before = time - this.lastTime; - - if (before < 0) - { - // Because, Chrome. - before = 0; - } - - this.rawDelta = before; - - var idx = this.deltaIndex; - var history = this.deltaHistory; - var max = this.deltaSmoothingMax; - - // delta time (time is in ms) - var dt = before; - - // When a browser switches tab, then comes back again, it takes around 10 frames before - // the delta time settles down so we employ a 'cooling down' period before we start - // trusting the delta values again, to avoid spikes flooding through our delta average - - if (this._coolDown > 0 || !this.inFocus) - { - this._coolDown--; - - dt = Math.min(dt, this._target); - } - - if (dt > this._min) - { - // Probably super bad start time or browser tab context loss, - // so use the last 'sane' dt value - - dt = history[idx]; - - // Clamp delta to min (in case history has become corrupted somehow) - dt = Math.min(dt, this._min); - } - - // Smooth out the delta over the previous X frames - - // add the delta to the smoothing array - history[idx] = dt; - - // adjusts the delta history array index based on the smoothing count - // this stops the array growing beyond the size of deltaSmoothingMax - this.deltaIndex++; - - if (this.deltaIndex > max) - { - this.deltaIndex = 0; - } - - // Delta Average - var avg = 0; - - // Loop the history array, adding the delta values together - - for (var i = 0; i < max; i++) - { - avg += history[i]; - } - - // Then divide by the array length to get the average delta - avg /= max; - - // Set as the world delta value - this.delta = avg; - - // Real-world timer advance - this.time += this.rawDelta; - - // Update the estimate of the frame rate, `fps`. Every second, the number - // of frames that occurred in that second are included in an exponential - // moving average of all frames per second, with an alpha of 0.25. This - // means that more recent seconds affect the estimated frame rate more than - // older seconds. - // - // When a browser window is NOT minimized, but is covered up (i.e. you're using - // another app which has spawned a window over the top of the browser), then it - // will start to throttle the raf callback time. It waits for a while, and then - // starts to drop the frame rate at 1 frame per second until it's down to just over 1fps. - // So if the game was running at 60fps, and the player opens a new window, then - // after 60 seconds (+ the 'buffer time') it'll be down to 1fps, so rafin'g at 1Hz. - // - // When they make the game visible again, the frame rate is increased at a rate of - // approx. 8fps, back up to 60fps (or the max it can obtain) - // - // There is no easy way to determine if this drop in frame rate is because the - // browser is throttling raf, or because the game is struggling with performance - // because you're asking it to do too much on the device. - - if (time > this.nextFpsUpdate) - { - // Compute the new exponential moving average with an alpha of 0.25. - this.actualFps = 0.25 * this.framesThisSecond + 0.75 * this.actualFps; - this.nextFpsUpdate = time + 1000; - this.framesThisSecond = 0; - } - - this.framesThisSecond++; - - // Interpolation - how far between what is expected and where we are? - var interpolation = avg / this._target; - - this.callback(time, avg, interpolation); - - // Shift time value over - this.lastTime = time; - }, - - /** - * Manually calls TimeStep.step, passing in the performance.now value to it. - * - * @method Phaser.Boot.TimeStep#tick - * @since 3.0.0 - */ - tick: function () - { - this.step(window.performance.now()); - }, - - /** - * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. - * - * @method Phaser.Boot.TimeStep#sleep - * @since 3.0.0 - */ - sleep: function () - { - if (this.running) - { - this.raf.stop(); - - this.running = false; - } - }, - - /** - * Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true. - * The `seamless` argument controls if the wake-up should adjust the start time or not. - * - * @method Phaser.Boot.TimeStep#wake - * @since 3.0.0 - * - * @param {boolean} [seamless=false] - Adjust the startTime based on the lastTime values. - */ - wake: function (seamless) - { - if (this.running) - { - this.sleep(); - } - else if (seamless) - { - this.startTime += -this.lastTime + (this.lastTime = window.performance.now()); - } - - this.raf.start(this.step.bind(this), this.useRAF); - - this.running = true; - - this.step(window.performance.now()); - }, - - /** - * Stops the TimeStep running. - * - * @method Phaser.Boot.TimeStep#stop - * @since 3.0.0 - * - * @return {Phaser.Boot.TimeStep} The TimeStep object. - */ - stop: function () - { - this.running = false; - this.started = false; - - this.raf.stop(); - - return this; - }, - - /** - * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null - * any objects. - * - * @method Phaser.Boot.TimeStep#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stop(); - - this.callback = NOOP; - - this.raf = null; - this.game = null; - } - -}); - -module.exports = TimeStep; - - -/***/ }), -/* 507 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var imageHeight = 0; - -/** - * @function addFrame - * @private - * @since 3.0.0 - */ -var addFrame = function (texture, sourceIndex, name, frame) -{ - // The frame values are the exact coordinates to cut the frame out of the atlas from - - var y = imageHeight - frame.y - frame.height; - - texture.add(name, sourceIndex, frame.x, y, frame.width, frame.height); - - // These are the original (non-trimmed) sprite values - /* - if (src.trimmed) - { - newFrame.setTrim( - src.sourceSize.w, - src.sourceSize.h, - src.spriteSourceSize.x, - src.spriteSourceSize.y, - src.spriteSourceSize.w, - src.spriteSourceSize.h - ); - } - */ -}; - -/** - * Parses a Unity YAML File and creates Frames in the Texture. - * For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html - * - * @function Phaser.Textures.Parsers.UnityYAML - * @memberOf Phaser.Textures.Parsers - * @private - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {object} yaml - The YAML data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var UnityYAML = function (texture, sourceIndex, yaml) -{ - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - imageHeight = source.height; - - var data = yaml.split('\n'); - - var lineRegExp = /^[ ]*(- )*(\w+)+[: ]+(.*)/; - - var prevSprite = ''; - var currentSprite = ''; - var rect = { x: 0, y: 0, width: 0, height: 0 }; - - // var pivot = { x: 0, y: 0 }; - // var border = { x: 0, y: 0, z: 0, w: 0 }; - - for (var i = 0; i < data.length; i++) - { - var results = data[i].match(lineRegExp); - - if (!results) - { - continue; - } - - var isList = (results[1] === '- '); - var key = results[2]; - var value = results[3]; - - if (isList) - { - if (currentSprite !== prevSprite) - { - addFrame(texture, sourceIndex, currentSprite, rect); - - prevSprite = currentSprite; - } - - rect = { x: 0, y: 0, width: 0, height: 0 }; - } - - if (key === 'name') - { - // Start new list - currentSprite = value; - continue; - } - - switch (key) - { - case 'x': - case 'y': - case 'width': - case 'height': - rect[key] = parseInt(value, 10); - break; - - // case 'pivot': - // pivot = eval('var obj = ' + value); - // break; - - // case 'border': - // border = eval('var obj = ' + value); - // break; - } - } - - if (currentSprite !== prevSprite) - { - addFrame(texture, sourceIndex, currentSprite, rect); - } - - return texture; -}; - -module.exports = UnityYAML; - -/* -Example data: - -TextureImporter: - spritePivot: {x: .5, y: .5} - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spritePixelsToUnits: 100 - spriteSheet: - sprites: - - name: asteroids_0 - rect: - serializedVersion: 2 - x: 5 - y: 328 - width: 65 - height: 82 - alignment: 0 - pivot: {x: 0, y: 0} - border: {x: 0, y: 0, z: 0, w: 0} - - name: asteroids_1 - rect: - serializedVersion: 2 - x: 80 - y: 322 - width: 53 - height: 88 - alignment: 0 - pivot: {x: 0, y: 0} - border: {x: 0, y: 0, z: 0, w: 0} - spritePackingTag: Asteroids -*/ - - -/***/ }), -/* 508 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(1); - -/** - * Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @function Phaser.Textures.Parsers.SpriteSheetFromAtlas - * @memberOf Phaser.Textures.Parsers - * @private - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {Phaser.Textures.Frame} frame - The Frame that contains the Sprite Sheet. - * @param {object} config - An object describing how to parse the Sprite Sheet. - * @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet. - * @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided. - * @param {number} [config.startFrame=0] - [description] - * @param {number} [config.endFrame=-1] - [description] - * @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. - * @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var SpriteSheetFromAtlas = function (texture, frame, config) -{ - var frameWidth = GetFastValue(config, 'frameWidth', null); - var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); - - // If missing we can't proceed - if (!frameWidth) - { - throw new Error('TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.'); - } - - // Add in a __BASE entry (for the entire atlas) - // var source = texture.source[sourceIndex]; - // texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - var startFrame = GetFastValue(config, 'startFrame', 0); - var endFrame = GetFastValue(config, 'endFrame', -1); - var margin = GetFastValue(config, 'margin', 0); - var spacing = GetFastValue(config, 'spacing', 0); - - var x = frame.cutX; - var y = frame.cutY; - - var cutWidth = frame.cutWidth; - var cutHeight = frame.cutHeight; - var sheetWidth = frame.realWidth; - var sheetHeight = frame.realHeight; - - var row = Math.floor((sheetWidth - margin + spacing) / (frameWidth + spacing)); - var column = Math.floor((sheetHeight - margin + spacing) / (frameHeight + spacing)); - var total = row * column; - - // trim offsets - - var leftPad = frame.x; - var leftWidth = frameWidth - leftPad; - - var rightWidth = frameWidth - ((sheetWidth - cutWidth) - leftPad); - - var topPad = frame.y; - var topHeight = frameHeight - topPad; - - var bottomHeight = frameHeight - ((sheetHeight - cutHeight) - topPad); - - // console.log('x / y', x, y); - // console.log('cutW / H', cutWidth, cutHeight); - // console.log('sheetW / H', sheetWidth, sheetHeight); - // console.log('row', row, 'column', column, 'total', total); - // console.log('LW', leftWidth, 'RW', rightWidth, 'TH', topHeight, 'BH', bottomHeight); - - if (startFrame > total || startFrame < -total) - { - startFrame = 0; - } - - if (startFrame < 0) - { - // Allow negative skipframes. - startFrame = total + startFrame; - } - - if (endFrame !== -1) - { - total = startFrame + (endFrame + 1); - } - - var sheetFrame; - var frameX = margin; - var frameY = margin; - var frameIndex = 0; - var sourceIndex = frame.sourceIndex; - - for (var sheetY = 0; sheetY < column; sheetY++) - { - var topRow = (sheetY === 0); - var bottomRow = (sheetY === column - 1); - - for (var sheetX = 0; sheetX < row; sheetX++) - { - var leftRow = (sheetX === 0); - var rightRow = (sheetX === row - 1); - - sheetFrame = texture.add(frameIndex, sourceIndex, x + frameX, y + frameY, frameWidth, frameHeight); - - if (leftRow || topRow || rightRow || bottomRow) - { - var destX = (leftRow) ? leftPad : 0; - var destY = (topRow) ? topPad : 0; - var destWidth = frameWidth; - var destHeight = frameHeight; - - if (leftRow) - { - destWidth = leftWidth; - } - else if (rightRow) - { - destWidth = rightWidth; - } - - if (topRow) - { - destHeight = topHeight; - } - else if (bottomRow) - { - destHeight = bottomHeight; - } - - sheetFrame.cutWidth = destWidth; - sheetFrame.cutHeight = destHeight; - - sheetFrame.setTrim(frameWidth, frameHeight, destX, destY, destWidth, destHeight); - } - - frameX += spacing; - - if (leftRow) - { - frameX += leftWidth; - } - else if (rightRow) - { - frameX += rightRow; - } - else - { - frameX += frameWidth; - } - - frameIndex++; - } - - frameX = margin; - frameY += spacing; - - if (topRow) - { - frameY += topHeight; - } - else if (bottomRow) - { - frameY += bottomHeight; - } - else - { - frameY += frameHeight; - } - } - - return texture; -}; - -module.exports = SpriteSheetFromAtlas; - - -/***/ }), -/* 509 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(1); - -/** - * Parses a Sprite Sheet and adds the Frames to the Texture. - * - * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact - * same size and cannot be trimmed or rotated. - * - * @function Phaser.Textures.Parsers.SpriteSheet - * @memberOf Phaser.Textures.Parsers - * @private - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {object} config - An object describing how to parse the Sprite Sheet. - * @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet. - * @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided. - * @param {number} [config.startFrame=0] - [description] - * @param {number} [config.endFrame=-1] - [description] - * @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. - * @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var SpriteSheet = function (texture, sourceIndex, x, y, width, height, config) -{ - var frameWidth = GetFastValue(config, 'frameWidth', null); - var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); - - // If missing we can't proceed - if (frameWidth === null) - { - throw new Error('TextureManager.SpriteSheet: Invalid frameWidth given.'); - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - var startFrame = GetFastValue(config, 'startFrame', 0); - var endFrame = GetFastValue(config, 'endFrame', -1); - var margin = GetFastValue(config, 'margin', 0); - var spacing = GetFastValue(config, 'spacing', 0); - - var row = Math.floor((width - margin + spacing) / (frameWidth + spacing)); - var column = Math.floor((height - margin + spacing) / (frameHeight + spacing)); - var total = row * column; - - if (startFrame > total || startFrame < -total) - { - startFrame = 0; - } - - if (startFrame < 0) - { - // Allow negative skipframes. - startFrame = total + startFrame; - } - - if (endFrame !== -1) - { - total = startFrame + (endFrame + 1); - } - - var fx = margin; - var fy = margin; - var ax = 0; - var ay = 0; - - for (var i = 0; i < total; i++) - { - ax = 0; - ay = 0; - - var w = fx + frameWidth; - var h = fy + frameHeight; - - if (w > width) - { - ax = w - width; - } - - if (h > height) - { - ay = h - height; - } - - texture.add(i, sourceIndex, x + fx, y + fy, frameWidth - ax, frameHeight - ay); - - fx += frameWidth + spacing; - - if (fx + frameWidth > width) - { - fx = margin; - fy += frameHeight + spacing; - } - } - - return texture; -}; - -module.exports = SpriteSheet; - - -/***/ }), -/* 510 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(33); - -/** - * Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. - * JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames. - * - * @function Phaser.Textures.Parsers.JSONHash - * @memberOf Phaser.Textures.Parsers - * @private - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {object} json - The JSON data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var JSONHash = function (texture, sourceIndex, json) -{ - // Malformed? - if (!json['frames']) - { - console.warn('Invalid Texture Atlas JSON Hash given, missing \'frames\' Object'); - return; - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - // By this stage frames is a fully parsed Object - var frames = json['frames']; - var newFrame; - - for (var key in frames) - { - var src = frames[key]; - - // The frame values are the exact coordinates to cut the frame out of the atlas from - newFrame = texture.add(key, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); - - // These are the original (non-trimmed) sprite values - if (src.trimmed) - { - newFrame.setTrim( - src.sourceSize.w, - src.sourceSize.h, - src.spriteSourceSize.x, - src.spriteSourceSize.y, - src.spriteSourceSize.w, - src.spriteSourceSize.h - ); - } - - if (src.rotated) - { - newFrame.rotated = true; - newFrame.updateUVsInverted(); - } - - // Copy over any extra data - newFrame.customData = Clone(src); - } - - // Copy over any additional data that was in the JSON to Texture.customData - for (var dataKey in json) - { - if (dataKey === 'frames') - { - continue; - } - - if (Array.isArray(json[dataKey])) - { - texture.customData[dataKey] = json[dataKey].slice(0); - } - else - { - texture.customData[dataKey] = json[dataKey]; - } - } - - return texture; -}; - -module.exports = JSONHash; - - -/***/ }), -/* 511 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(33); - -/** - * Parses a Texture Atlas JSON Array and adds the Frames to the Texture. - * JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames. - * - * @function Phaser.Textures.Parsers.JSONArray - * @memberOf Phaser.Textures.Parsers - * @private - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {object} json - The JSON data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var JSONArray = function (texture, sourceIndex, json) -{ - // Malformed? - if (!json['frames'] && !json['textures']) - { - console.warn('Invalid Texture Atlas JSON Array'); - return; - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - // By this stage frames is a fully parsed array - var frames = (Array.isArray(json.textures)) ? json.textures[sourceIndex].frames : json.frames; - - var newFrame; - - for (var i = 0; i < frames.length; i++) - { - var src = frames[i]; - - // The frame values are the exact coordinates to cut the frame out of the atlas from - newFrame = texture.add(src.filename, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); - - // These are the original (non-trimmed) sprite values - if (src.trimmed) - { - newFrame.setTrim( - src.sourceSize.w, - src.sourceSize.h, - src.spriteSourceSize.x, - src.spriteSourceSize.y, - src.spriteSourceSize.w, - src.spriteSourceSize.h - ); - } - - if (src.rotated) - { - newFrame.rotated = true; - newFrame.updateUVsInverted(); - } - - if (src.anchor) - { - newFrame.customPivot = true; - newFrame.pivotX = src.anchor.x; - newFrame.pivotY = src.anchor.y; - } - - // Copy over any extra data - newFrame.customData = Clone(src); - } - - // Copy over any additional data that was in the JSON to Texture.customData - for (var dataKey in json) - { - if (dataKey === 'frames') - { - continue; - } - - if (Array.isArray(json[dataKey])) - { - texture.customData[dataKey] = json[dataKey].slice(0); - } - else - { - texture.customData[dataKey] = json[dataKey]; - } - } - - return texture; -}; - -module.exports = JSONArray; - - -/***/ }), -/* 512 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds an Image Element to a Texture. - * - * @function Phaser.Textures.Parsers.Image - * @memberOf Phaser.Textures.Parsers - * @private - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var Image = function (texture, sourceIndex) -{ - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - return texture; -}; - -module.exports = Image; - - -/***/ }), -/* 513 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Adds a Canvas Element to a Texture. - * - * @function Phaser.Textures.Parsers.Canvas - * @memberOf Phaser.Textures.Parsers - * @private - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var Canvas = function (texture, sourceIndex) -{ - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - return texture; -}; - -module.exports = Canvas; - - -/***/ }), -/* 514 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Parses an XML Texture Atlas object and adds all the Frames into a Texture. - * - * @function Phaser.Textures.Parsers.AtlasXML - * @memberOf Phaser.Textures.Parsers - * @private - * @since 3.7.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. - * @param {integer} sourceIndex - The index of the TextureSource. - * @param {*} xml - The XML data. - * - * @return {Phaser.Textures.Texture} The Texture modified by this parser. - */ -var AtlasXML = function (texture, sourceIndex, xml) -{ - // Malformed? - if (!xml.getElementsByTagName('TextureAtlas')) - { - console.warn('Invalid Texture Atlas XML given'); - return; - } - - // Add in a __BASE entry (for the entire atlas) - var source = texture.source[sourceIndex]; - - texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); - - // By this stage frames is a fully parsed array - var frames = xml.getElementsByTagName('SubTexture'); - - var newFrame; - - for (var i = 0; i < frames.length; i++) - { - var frame = frames[i].attributes; - - var name = frame.name.value; - var x = parseInt(frame.x.value, 10); - var y = parseInt(frame.y.value, 10); - var width = parseInt(frame.width.value, 10); - var height = parseInt(frame.height.value, 10); - - // The frame values are the exact coordinates to cut the frame out of the atlas from - newFrame = texture.add(name, sourceIndex, x, y, width, height); - - // These are the original (non-trimmed) sprite values - if (frame.frameX) - { - var frameX = Math.abs(parseInt(frame.frameX.value, 10)); - var frameY = Math.abs(parseInt(frame.frameY.value, 10)); - var frameWidth = parseInt(frame.frameWidth.value, 10); - var frameHeight = parseInt(frame.frameHeight.value, 10); - - newFrame.setTrim( - width, - height, - frameX, - frameY, - frameWidth, - frameHeight - ); - } - } - - return texture; -}; - -module.exports = AtlasXML; - - -/***/ }), -/* 515 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var IsSizePowerOfTwo = __webpack_require__(85); -var Texture = __webpack_require__(117); - -/** - * @classdesc - * A Canvas Texture is a special kind of Texture that is backed by an HTML Canvas Element as its source. - * - * You can use the properties of this texture to draw to the canvas element directly, using all of the standard - * canvas operations available in the browser. Any Game Object can be given this texture and will render with it. - * - * Note: When running under WebGL the Canvas Texture needs to re-generate its base WebGLTexture and reupload it to - * the GPU every time you modify it, otherwise the changes you make to this texture will not be visible. To do this - * you should call `CanvasTexture.refresh()` once you are finished with your changes to the canvas. Try and keep - * this to a minimum, especially on large canvas sizes, or you may inadvertently thrash the GPU by constantly uploading - * texture data to it. This restriction does not apply if using the Canvas Renderer. - * - * It starts with only one frame that covers the whole of the canvas. You can add further frames, that specify - * sections of the canvas using the `add` method. - * - * Should you need to resize the canvas use the `setSize` method so that it accurately updates all of the underlying - * texture data as well. Forgetting to do this (i.e. by changing the canvas size directly from your code) could cause - * graphical errors. - * - * @class CanvasTexture - * @extends Phaser.Textures.Texture - * @memberOf Phaser.Textures - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. - * @param {string} key - The unique string-based key of this Texture. - * @param {HTMLCanvasElement} source - The canvas element that is used as the base of this texture. - * @param {integer} width - The width of the canvas. - * @param {integer} height - The height of the canvas. - */ -var CanvasTexture = new Class({ - - Extends: Texture, - - initialize: - - function CanvasTexture (manager, key, source, width, height) - { - Texture.call(this, manager, key, source, width, height); - - this.add('__BASE', 0, 0, 0, width, height); - - /** - * A reference to the Texture Source of this Canvas. - * - * @name Phaser.Textures.TextureManager#_source - * @type {Phaser.Textures.TextureSource} - * @private - * @since 3.7.0 - */ - this._source = this.frames['__BASE'].source; - - /** - * The source Canvas Element. - * - * @name Phaser.Textures.TextureManager#canvas - * @readOnly - * @type {HTMLCanvasElement} - * @since 3.7.0 - */ - this.canvas = this._source.image; - - /** - * The 2D Canvas Rendering Context. - * - * @name Phaser.Textures.TextureManager#canvas - * @readOnly - * @type {CanvasRenderingContext2D} - * @since 3.7.0 - */ - this.context = this.canvas.getContext('2d'); - - /** - * The width of the Canvas. - * This property is read-only, if you wish to change use `setSize`. - * - * @name Phaser.Textures.TextureManager#width - * @readOnly - * @type {integer} - * @since 3.7.0 - */ - this.width = width; - - /** - * The height of the Canvas. - * This property is read-only, if you wish to change use `setSize`. - * - * @name Phaser.Textures.TextureManager#height - * @readOnly - * @type {integer} - * @since 3.7.0 - */ - this.height = height; - }, - - /** - * This should be called manually if you are running under WebGL. - * It will refresh the WebGLTexture from the Canvas source. Only call this if you know that the - * canvas has changed, as there is a significant GPU texture allocation cost involved in doing so. - * - * @method Phaser.Textures.CanvasTexture#refresh - * @since 3.7.0 - * - * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. - */ - refresh: function () - { - this._source.update(); - - return this; - }, - - /** - * Gets the Canvas Element. - * - * @method Phaser.Textures.CanvasTexture#getCanvas - * @since 3.7.0 - * - * @return {HTMLCanvasElement} The Canvas DOM element this texture is using. - */ - getCanvas: function () - { - return this.canvas; - }, - - /** - * Gets the 2D Canvas Rendering Context. - * - * @method Phaser.Textures.CanvasTexture#getContext - * @since 3.7.0 - * - * @return {CanvasRenderingContext2D} The Canvas Rendering Context this texture is using. - */ - getContext: function () - { - return this.context; - }, - - /** - * Clears this Canvas Texture, resetting it back to transparent. - * - * @method Phaser.Textures.CanvasTexture#clear - * @since 3.7.0 - * - * @return {Phaser.Textures.CanvasTexture} The Canvas Texture. - */ - clear: function () - { - this.context.clearRect(0, 0, this.width, this.height); - - return this; - }, - - /** - * Changes the size of this Canvas Texture. - * - * @method Phaser.Textures.CanvasTexture#setSize - * @since 3.7.0 - * - * @param {integer} width - The new width of the Canvas. - * @param {integer} [height] - The new height of the Canvas. If not given it will use the width as the height. - * - * @return {Phaser.Textures.CanvasTexture} The Canvas Texture. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - if (width !== this.width || height !== this.height) - { - // Update the Canvas - this.canvas.width = width; - this.canvas.height = height; - - // Update the Texture Source - this._source.width = width; - this._source.height = height; - this._source.isPowerOf2 = IsSizePowerOfTwo(width, height); - - // Update the Frame - this.frames['__BASE'].setSize(width, height, 0, 0); - - this.refresh(); - } - - return this; - } - -}); - -module.exports = CanvasTexture; - - -/***/ }), -/* 516 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// These properties get injected into the Scene and map to local systems -// The map value is the property that is injected into the Scene, the key is the Scene.Systems reference. -// These defaults can be modified via the Scene config object -// var config = { -// map: { -// add: 'makeStuff', -// load: 'loader' -// } -// }; - -var InjectionMap = { - - game: 'game', - - anims: 'anims', - cache: 'cache', - plugins: 'plugins', - registry: 'registry', - sound: 'sound', - textures: 'textures', - - events: 'events', - cameras: 'cameras', - cameras3d: 'cameras3d', - add: 'add', - make: 'make', - scenePlugin: 'scene', - displayList: 'children', - lights: 'lights', - - data: 'data', - input: 'input', - load: 'load', - time: 'time', - tweens: 'tweens', - - arcadePhysics: 'physics', - impactPhysics: 'impact', - matterPhysics: 'matter' - -}; - -module.exports = InjectionMap; - - -/***/ }), -/* 517 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(1); - -/** - * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. - * - * @function Phaser.Scenes.GetScenePlugins - * @since 3.0.0 - * - * @param {Phaser.Scenes.Systems} sys - [description] - * - * @return {array} [description] - */ -var GetScenePlugins = function (sys) -{ - var defaultPlugins = sys.plugins.getDefaultScenePlugins(); - - var scenePlugins = GetFastValue(sys.settings, 'plugins', false); - - // Scene Plugins always override Default Plugins - if (Array.isArray(scenePlugins)) - { - return scenePlugins; - } - else if (defaultPlugins) - { - return defaultPlugins; - } - else - { - // No default plugins or plugins in this scene - return []; - } -}; - -module.exports = GetScenePlugins; - - -/***/ }), -/* 518 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(1); -var UppercaseFirst = __webpack_require__(256); - -/** - * Builds an array of which physics plugins should be activated for the given Scene. - * - * @function Phaser.Scenes.GetPhysicsPlugins - * @since 3.0.0 - * - * @param {Phaser.Scenes.Systems} sys - The scene system to get the physics systems of. - * - * @return {array} An array of Physics systems to start for this Scene. - */ -var GetPhysicsPlugins = function (sys) -{ - var defaultSystem = sys.game.config.defaultPhysicsSystem; - var sceneSystems = GetFastValue(sys.settings, 'physics', false); - - if (!defaultSystem && !sceneSystems) - { - // No default physics system or systems in this scene - return; - } - - // Let's build the systems array - var output = []; - - if (defaultSystem) - { - output.push(UppercaseFirst(defaultSystem + 'Physics')); - } - - if (sceneSystems) - { - for (var key in sceneSystems) - { - key = UppercaseFirst(key.concat('Physics')); - - if (output.indexOf(key) === -1) - { - output.push(key); - } - } - } - - // An array of Physics systems to start for this Scene - return output; -}; - -module.exports = GetPhysicsPlugins; - - -/***/ }), -/* 519 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the full screen support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.fullscreen` from within any Scene. - * - * @typedef {object} Phaser.Device.Fullscreen - * @since 3.0.0 - * - * @property {boolean} available - Does the browser support the Full Screen API? - * @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode? - * @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it. - * @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it. - */ -var Fullscreen = { - - available: false, - cancel: '', - keyboard: false, - request: '' - -}; - -/** -* Checks for support of the Full Screen API. -*/ -function init () -{ - var i; - - var fs = [ - 'requestFullscreen', - 'requestFullScreen', - 'webkitRequestFullscreen', - 'webkitRequestFullScreen', - 'msRequestFullscreen', - 'msRequestFullScreen', - 'mozRequestFullScreen', - 'mozRequestFullscreen' - ]; - - var element = document.createElement('div'); - - for (i = 0; i < fs.length; i++) - { - if (element[fs[i]]) - { - Fullscreen.available = true; - Fullscreen.request = fs[i]; - break; - } - } - - var cfs = [ - 'cancelFullScreen', - 'exitFullscreen', - 'webkitCancelFullScreen', - 'webkitExitFullscreen', - 'msCancelFullScreen', - 'msExitFullscreen', - 'mozCancelFullScreen', - 'mozExitFullscreen' - ]; - - if (Fullscreen.available) - { - for (i = 0; i < cfs.length; i++) - { - if (document[cfs[i]]) - { - Fullscreen.cancel = cfs[i]; - break; - } - } - } - - // Keyboard Input? - if (window['Element'] && Element['ALLOW_KEYBOARD_INPUT']) - { - Fullscreen.keyboard = true; - } - - return Fullscreen; -} - -module.exports = init(); - - -/***/ }), -/* 520 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the video support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.video` from within any Scene. - * - * @typedef {object} Phaser.Device.Video - * @since 3.0.0 - * - * @property {boolean} h264Video - Can this device play h264 mp4 video files? - * @property {boolean} hlsVideo - Can this device play hls video files? - * @property {boolean} mp4Video - Can this device play h264 mp4 video files? - * @property {boolean} oggVideo - Can this device play ogg video files? - * @property {boolean} vp9Video - Can this device play vp9 video files? - * @property {boolean} webmVideo - Can this device play webm video files? - */ -var Video = { - - h264Video: false, - hlsVideo: false, - mp4Video: false, - oggVideo: false, - vp9Video: false, - webmVideo: false - -}; - -function init () -{ - var videoElement = document.createElement('video'); - var result = !!videoElement.canPlayType; - - try - { - if (result) - { - if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '')) - { - Video.oggVideo = true; - } - - if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '')) - { - // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546 - Video.h264Video = true; - Video.mp4Video = true; - } - - if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '')) - { - Video.webmVideo = true; - } - - if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '')) - { - Video.vp9Video = true; - } - - if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '')) - { - Video.hlsVideo = true; - } - } - } - catch (e) - { - // Nothing to do - } - - return Video; -} - -module.exports = init(); - - -/***/ }), -/* 521 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Browser = __webpack_require__(80); - -/** - * Determines the audio playback capabilities of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.audio` from within any Scene. - * - * @typedef {object} Phaser.Device.Audio - * @since 3.0.0 - * - * @property {boolean} audioData - Can this device play HTML Audio tags? - * @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files? - * @property {boolean} m4a - Can this device can play m4a files. - * @property {boolean} mp3 - Can this device play mp3 files? - * @property {boolean} ogg - Can this device play ogg files? - * @property {boolean} opus - Can this device play opus files? - * @property {boolean} wav - Can this device play wav files? - * @property {boolean} webAudio - Does this device have the Web Audio API? - * @property {boolean} webm - Can this device play webm files? - */ -var Audio = { - - audioData: false, - dolby: false, - m4a: false, - mp3: false, - ogg: false, - opus: false, - wav: false, - webAudio: false, - webm: false - -}; - -function init () -{ - Audio.audioData = !!(window['Audio']); - - Audio.webAudio = !!(window['AudioContext'] || window['webkitAudioContext']); - - var audioElement = document.createElement('audio'); - - var result = !!audioElement.canPlayType; - - try - { - if (result) - { - if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) - { - Audio.ogg = true; - } - - if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '') || audioElement.canPlayType('audio/opus;').replace(/^no$/, '')) - { - Audio.opus = true; - } - - if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) - { - Audio.mp3 = true; - } - - // Mimetypes accepted: - // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements - // bit.ly/iphoneoscodecs - if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) - { - Audio.wav = true; - } - - if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, '')) - { - Audio.m4a = true; - } - - if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')) - { - Audio.webm = true; - } - - if (audioElement.canPlayType('audio/mp4;codecs="ec-3"') !== '') - { - if (Browser.edge) - { - Audio.dolby = true; - } - else if (Browser.safari && Browser.safariVersion >= 9) - { - if ((/Mac OS X (\d+)_(\d+)/).test(navigator.userAgent)) - { - var major = parseInt(RegExp.$1, 10); - var minor = parseInt(RegExp.$2, 10); - - if ((major === 10 && minor >= 11) || major > 10) - { - Audio.dolby = true; - } - } - } - } - } - } - catch (e) - { - // Nothing to do here - } - - return Audio; -} - -module.exports = init(); - - -/***/ }), -/* 522 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(57); -var Browser = __webpack_require__(80); - -/** - * Determines the input support of the browser running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.input` from within any Scene. - * - * @typedef {object} Phaser.Device.Input - * @since 3.0.0 - * - * @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' - * @property {boolean} gamepads - Is navigator.getGamepads available? - * @property {boolean} mspointer - Is mspointer available? - * @property {boolean} touch - Is touch available? - */ -var Input = { - - gamepads: false, - mspointer: false, - touch: false, - wheelEvent: null - -}; - -function init () -{ - if ('ontouchstart' in document.documentElement || (navigator.maxTouchPoints && navigator.maxTouchPoints >= 1)) - { - Input.touch = true; - } - - if (navigator.msPointerEnabled || navigator.pointerEnabled) - { - Input.mspointer = true; - } - - if (navigator.getGamepads) - { - Input.gamepads = true; - } - - if (!OS.cocoonJS) - { - // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel - if ('onwheel' in window || (Browser.ie && 'WheelEvent' in window)) - { - // DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+ - Input.wheelEvent = 'wheel'; - } - else if ('onmousewheel' in window) - { - // Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7. - Input.wheelEvent = 'mousewheel'; - } - else if (Browser.firefox && 'MouseScrollEvent' in window) - { - // FF prior to 17. This should probably be scrubbed. - Input.wheelEvent = 'DOMMouseScroll'; - } - } - - return Input; -} - -module.exports = init(); - - -/***/ }), -/* 523 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// This singleton is instantiated as soon as Phaser loads, -// before a Phaser.Game instance has even been created. -// Which means all instances of Phaser Games can share it, -// without having to re-poll the device all over again - -/** - * @namespace Phaser.Device - * @since 3.0.0 - */ - -/** - * @typedef {object} Phaser.DeviceConf - * - * @property {Phaser.Device.OS} os - The OS Device functions. - * @property {Phaser.Device.Browser} browser - The Browser Device functions. - * @property {Phaser.Device.Features} features - The Features Device functions. - * @property {Phaser.Device.Input} input - The Input Device functions. - * @property {Phaser.Device.Audio} audio - The Audio Device functions. - * @property {Phaser.Device.Video} video - The Video Device functions. - * @property {Phaser.Device.Fullscreen} fullscreen - The Fullscreen Device functions. - * @property {Phaser.Device.CanvasFeatures} canvasFeatures - The Canvas Device functions. - */ - -module.exports = { - - os: __webpack_require__(57), - browser: __webpack_require__(80), - features: __webpack_require__(120), - input: __webpack_require__(522), - audio: __webpack_require__(521), - video: __webpack_require__(520), - fullscreen: __webpack_require__(519), - canvasFeatures: __webpack_require__(203) - -}; - - -/***/ }), -/* 524 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(20); - -/** - * Called automatically by Phaser.Game and responsible for creating the console.log debug header. - * - * You can customize or disable the header via the Game Config object. - * - * @function Phaser.Boot.DebugHeader - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. - */ -var DebugHeader = function (game) -{ - var config = game.config; - - if (config.hideBanner) - { - return; - } - - var renderType = 'WebGL'; - - if (config.renderType === CONST.CANVAS) - { - renderType = 'Canvas'; - } - else if (config.renderType === CONST.HEADLESS) - { - renderType = 'Headless'; - } - - var audioConfig = config.audio; - var deviceAudio = game.device.audio; - - var audioType; - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - audioType = 'Web Audio'; - } - else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - audioType = 'No Audio'; - } - else - { - audioType = 'HTML5 Audio'; - } - - if (!game.device.browser.ie) - { - var c = ''; - var args = [ c ]; - - if (Array.isArray(config.bannerBackgroundColor)) - { - var lastColor; - - config.bannerBackgroundColor.forEach(function (color) - { - c = c.concat('%c '); - - args.push('background: ' + color); - - lastColor = color; - - }); - - // inject the text color - args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; - } - else - { - c = c.concat('%c '); - - args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); - } - - // URL link background color (always white) - args.push('background: #fff'); - - if (config.gameTitle) - { - c = c.concat(config.gameTitle); - - if (config.gameVersion) - { - c = c.concat(' v' + config.gameVersion); - } - - if (!config.hidePhaser) - { - c = c.concat(' / '); - } - } - - if (!config.hidePhaser) - { - c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); - } - - c = c.concat(' %c ' + config.gameURL); - - // Inject the new string back into the args array - args[0] = c; - - console.log.apply(console, args); - } - else if (window['console']) - { - console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); - } -}; - -module.exports = DebugHeader; - - -/***/ }), -/* 525 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_TEXTURE_TINT_VS', - '', - 'precision mediump float;', - '', - 'uniform mat4 uProjectionMatrix;', - 'uniform mat4 uViewMatrix;', - 'uniform mat4 uModelMatrix;', - '', - 'attribute vec2 inPosition;', - 'attribute vec2 inTexCoord;', - 'attribute vec4 inTint;', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main ()', - '{', - ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', - ' outTexCoord = inTexCoord;', - ' outTint = inTint;', - '}', - '', - '' -].join('\n'); - - -/***/ }), -/* 526 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_TEXTURE_TINT_FS', - '', - 'precision mediump float;', - '', - 'uniform sampler2D uMainSampler;', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main()', - '{', - ' vec4 texel = texture2D(uMainSampler, outTexCoord);', - ' texel *= vec4(outTint.rgb * outTint.a, outTint.a);', - ' gl_FragColor = texel;', - '}', - '' -].join('\n'); - - -/***/ }), -/* 527 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS', - '', - 'precision mediump float;', - '', - 'struct Light', - '{', - ' vec2 position;', - ' vec3 color;', - ' float intensity;', - ' float radius;', - '};', - '', - 'const int kMaxLights = %LIGHT_COUNT%;', - '', - 'uniform vec4 uCamera; /* x, y, rotation, zoom */', - 'uniform vec2 uResolution;', - 'uniform sampler2D uMainSampler;', - 'uniform sampler2D uNormSampler;', - 'uniform vec3 uAmbientLightColor;', - 'uniform Light uLights[kMaxLights];', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main()', - '{', - ' vec3 finalColor = vec3(0.0, 0.0, 0.0);', - ' vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);', - ' vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;', - ' vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));', - ' vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;', - '', - ' for (int index = 0; index < kMaxLights; ++index)', - ' {', - ' Light light = uLights[index];', - ' vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);', - ' vec3 lightNormal = normalize(lightDir);', - ' float distToSurf = length(lightDir) * uCamera.w;', - ' float diffuseFactor = max(dot(normal, lightNormal), 0.0);', - ' float radius = (light.radius / res.x * uCamera.w) * uCamera.w;', - ' float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);', - ' vec3 diffuse = light.color * diffuseFactor;', - ' finalColor += (attenuation * diffuse) * light.intensity;', - ' }', - '', - ' vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);', - ' gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);', - '', - '}', - '' -].join('\n'); - - -/***/ }), -/* 528 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_FLAT_TINT_VS', - '', - 'precision mediump float;', - '', - 'uniform mat4 uProjectionMatrix;', - 'uniform mat4 uViewMatrix;', - 'uniform mat4 uModelMatrix;', - '', - 'attribute vec2 inPosition;', - 'attribute vec4 inTint;', - '', - 'varying vec4 outTint;', - '', - 'void main () {', - ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', - ' outTint = inTint;', - '}', - '' -].join('\n'); - - -/***/ }), -/* 529 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_FLAT_TINT_FS', - '', - 'precision mediump float;', - '', - 'varying vec4 outTint;', - '', - 'void main() {', - ' gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);', - '}', - '' -].join('\n'); - - -/***/ }), -/* 530 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_BITMAP_MASK_VS', - '', - 'precision mediump float;', - '', - 'attribute vec2 inPosition;', - '', - 'void main()', - '{', - ' gl_Position = vec4(inPosition, 0.0, 1.0);', - '}', - '' -].join('\n'); - - -/***/ }), -/* 531 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_BITMAP_MASK_FS', - '', - 'precision mediump float;', - '', - 'uniform vec2 uResolution;', - 'uniform sampler2D uMainSampler;', - 'uniform sampler2D uMaskSampler;', - 'uniform bool uInvertMaskAlpha;', - '', - 'void main()', - '{', - ' vec2 uv = gl_FragCoord.xy / uResolution;', - ' vec4 mainColor = texture2D(uMainSampler, uv);', - ' vec4 maskColor = texture2D(uMaskSampler, uv);', - ' float alpha = mainColor.a;', - '', - ' if (!uInvertMaskAlpha)', - ' {', - ' alpha *= (maskColor.a);', - ' }', - ' else', - ' {', - ' alpha *= (1.0 - maskColor.a);', - ' }', - '', - ' gl_FragColor = vec4(mainColor.rgb * alpha, alpha);', - '}', - '' -].join('\n'); - - -/***/ }), -/* 532 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasInterpolation = __webpack_require__(272); -var CanvasPool = __webpack_require__(22); -var CONST = __webpack_require__(20); -var Features = __webpack_require__(120); - -/** - * Called automatically by Phaser.Game and responsible for creating the renderer it will use. - * - * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. - * - * @function Phaser.Boot.CreateRenderer - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. - */ -var CreateRenderer = function (game) -{ - var config = game.config; - - // Game either requested Canvas, - // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas - - if (config.renderType !== CONST.HEADLESS) - { - if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) - { - if (Features.canvas) - { - // They requested Canvas and their browser supports it - config.renderType = CONST.CANVAS; - } - else - { - throw new Error('Cannot create Canvas or WebGL context, aborting.'); - } - } - else - { - // Game requested WebGL and browser says it supports it - config.renderType = CONST.WEBGL; - } - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasPool.disableSmoothing(); - } - - // Does the game config provide its own canvas element to use? - if (config.canvas) - { - game.canvas = config.canvas; - } - else - { - game.canvas = CanvasPool.create(game, config.width, config.height, config.renderType); - } - - // Does the game config provide some canvas css styles to use? - if (config.canvasStyle) - { - game.canvas.style = config.canvasStyle; - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasInterpolation.setCrisp(game.canvas); - } - - // Zoomed? - if (config.zoom !== 1) - { - game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; - game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; - } - - if (config.renderType === CONST.HEADLESS) - { - // Nothing more to do here - return; - } - - var CanvasRenderer; - var WebGLRenderer; - - if (true) - { - CanvasRenderer = __webpack_require__(267); - WebGLRenderer = __webpack_require__(262); - - // Let the config pick the renderer type, as both are included - if (config.renderType === CONST.WEBGL) - { - game.renderer = new WebGLRenderer(game); - - // The WebGL Renderer sets this value during its init, not on construction - game.context = null; - } - else - { - game.renderer = new CanvasRenderer(game); - game.context = game.renderer.gameContext; - } - } - - if (false) - {} - - if (false) - {} -}; - -module.exports = CreateRenderer; - - -/***/ }), -/* 533 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var GetFastValue = __webpack_require__(1); -var GetValue = __webpack_require__(4); -var IsPlainObject = __webpack_require__(8); -var MATH = __webpack_require__(16); -var NOOP = __webpack_require__(3); -var DefaultPlugins = __webpack_require__(121); -var ValueToColor = __webpack_require__(132); - -/** - * This callback type is completely empty, a no-operation. - * - * @callback NOOP - */ - -/** - * @callback BootCallback - * - * @param {Phaser.Game} game - [description] - */ - -/** - * @typedef {object} FPSConfig - * - * @property {integer} [min=10] - [description] - * @property {integer} [target=60] - [description] - * @property {boolean} [forceSetTimeOut=false] - [description] - * @property {integer} [deltaHistory=10] - [description] - * @property {integer} [panicMax=120] - [description] - */ - -/** - * @typedef {object} LoaderConfig - * - * @property {string} [baseURL] - [description] - * @property {string} [path] - [description] - * @property {integer} [maxParallelDownloads=32] - [description] - * @property {(string|undefined)} [crossOrigin=undefined] - [description] - * @property {string} [responseType] - [description] - * @property {boolean} [async=true] - [description] - * @property {string} [user] - [description] - * @property {string} [password] - [description] - * @property {integer} [timeout=0] - [description] - */ - -/** - * @typedef {object} GameConfig - * - * @property {(integer|string)} [width=1024] - [description] - * @property {(integer|string)} [height=768] - [description] - * @property {number} [zoom=1] - [description] - * @property {number} [resolution=1] - [description] - * @property {number} [type=CONST.AUTO] - [description] - * @property {*} [parent=null] - [description] - * @property {HTMLCanvasElement} [canvas=null] - Provide your own Canvas element for Phaser to use instead of creating one. - * @property {string} [canvasStyle=null] - [description] - * @property {CanvasRenderingContext2D} [context] - Provide your own Canvas Context for Phaser to use, instead of creating one. - * @property {object} [scene=null] - [description] - * @property {string[]} [seed] - [description] - * @property {string} [title=''] - [description] - * @property {string} [url='http://phaser.io'] - [description] - * @property {string} [version=''] - [description] - * @property {boolean} [autoFocus=true] - Automatically call window.focus() when the game boots. - * @property {(boolean|object)} [input] - [description] - * @property {boolean} [input.keyboard=true] - [description] - * @property {*} [input.keyboard.target=window] - [description] - * @property {(boolean|object)} [input.mouse=true] - [description] - * @property {*} [input.mouse.target=null] - [description] - * @property {boolean} [input.touch=true] - [description] - * @property {integer} [input.activePointers=1] - [description] - * @property {*} [input.touch.target=null] - [description] - * @property {boolean} [input.touch.capture=true] - [description] - * @property {(boolean|object)} [input.gamepad=false] - [description] - * @property {boolean} [disableContextMenu=false] - [description] - * @property {(boolean|object)} [banner=false] - [description] - * @property {boolean} [banner.hidePhaser=false] - [description] - * @property {string} [banner.text='#ffffff'] - [description] - * @property {string[]} [banner.background] - [description] - * @property {FPSConfig} [fps] - [description] - * @property {boolean} [render.antialias=true] - [description] - * @property {boolean} [render.pixelArt=false] - [description] - * @property {boolean} [render.autoResize=false] - [description] - * @property {boolean} [render.roundPixels=false] - [description] - * @property {boolean} [render.transparent=false] - [description] - * @property {boolean} [render.clearBeforeRender=true] - [description] - * @property {boolean} [render.premultipliedAlpha=true] - [description] - * @property {boolean} [render.preserveDrawingBuffer=false] - [description] - * @property {boolean} [render.failIfMajorPerformanceCaveat=false] - [description] - * @property {string} [render.powerPreference='default'] - "high-performance", "low-power" or "default" - * @property {(string|number)} [backgroundColor=0x000000] - [description] - * @property {object} [callbacks] - [description] - * @property {BootCallback} [callbacks.preBoot=NOOP] - [description] - * @property {BootCallback} [callbacks.postBoot=NOOP] - [description] - * @property {LoaderConfig} [loader] - [description] - * @property {object} [images] - [description] - * @property {string} [images.default] - [description] - * @property {string} [images.missing] - [description] - * @property {object} [physics] - [description] - */ - -/** - * @classdesc - * [description] - * - * @class Config - * @memberOf Phaser.Boot - * @constructor - * @since 3.0.0 - * - * @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. - */ -var Config = new Class({ - - initialize: - - function Config (config) - { - if (config === undefined) { config = {}; } - - var defaultBannerColor = [ - '#ff0000', - '#ffff00', - '#00ff00', - '#00ffff', - '#000000' - ]; - - var defaultBannerTextColor = '#ffffff'; - - /** - * @const {(integer|string)} Phaser.Boot.Config#width - [description] - */ - this.width = GetValue(config, 'width', 1024); - - /** - * @const {(integer|string)} Phaser.Boot.Config#height - [description] - */ - this.height = GetValue(config, 'height', 768); - - /** - * @const {number} Phaser.Boot.Config#zoom - [description] - */ - this.zoom = GetValue(config, 'zoom', 1); - - /** - * @const {number} Phaser.Boot.Config#resolution - [description] - */ - this.resolution = GetValue(config, 'resolution', 1); - - /** - * @const {number} Phaser.Boot.Config#renderType - [description] - */ - this.renderType = GetValue(config, 'type', CONST.AUTO); - - /** - * @const {?*} Phaser.Boot.Config#parent - [description] - */ - this.parent = GetValue(config, 'parent', null); - - /** - * @const {?HTMLCanvasElement} Phaser.Boot.Config#canvas - Force Phaser to use your own Canvas element instead of creating one. - */ - this.canvas = GetValue(config, 'canvas', null); - - /** - * @const {?(CanvasRenderingContext2D|WebGLRenderingContext)} Phaser.Boot.Config#context - Force Phaser to use your own Canvas context instead of creating one. - */ - this.context = GetValue(config, 'context', null); - - /** - * @const {?string} Phaser.Boot.Config#canvasStyle - [description] - */ - this.canvasStyle = GetValue(config, 'canvasStyle', null); - - /** - * @const {?object} Phaser.Boot.Config#sceneConfig - [description] - */ - this.sceneConfig = GetValue(config, 'scene', null); - - /** - * @const {string[]} Phaser.Boot.Config#seed - [description] - */ - this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]); - - MATH.RND.init(this.seed); - - /** - * @const {string} Phaser.Boot.Config#gameTitle - [description] - */ - this.gameTitle = GetValue(config, 'title', ''); - - /** - * @const {string} Phaser.Boot.Config#gameURL - [description] - */ - this.gameURL = GetValue(config, 'url', 'https://phaser.io'); - - /** - * @const {string} Phaser.Boot.Config#gameVersion - [description] - */ - this.gameVersion = GetValue(config, 'version', ''); - - /** - * @const {boolean} Phaser.Boot.Config#autoFocus - [description] - */ - this.autoFocus = GetValue(config, 'autoFocus', true); - - // Input - - /** - * @const {boolean} Phaser.Boot.Config#inputKeyboard - [description] - */ - this.inputKeyboard = GetValue(config, 'input.keyboard', true); - - /** - * @const {*} Phaser.Boot.Config#inputKeyboardEventTarget - [description] - */ - this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); - - /** - * @const {(boolean|object)} Phaser.Boot.Config#inputMouse - [description] - */ - this.inputMouse = GetValue(config, 'input.mouse', true); - - /** - * @const {?*} Phaser.Boot.Config#inputMouseEventTarget - [description] - */ - this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null); - - /** - * @const {boolean} Phaser.Boot.Config#inputMouseCapture - [description] - */ - this.inputMouseCapture = GetValue(config, 'input.mouse.capture', true); - - /** - * @const {boolean} Phaser.Boot.Config#inputTouch - [description] - */ - this.inputTouch = GetValue(config, 'input.touch', true); - - /** - * @const {?*} Phaser.Boot.Config#inputTouchEventTarget - [description] - */ - this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null); - - /** - * @const {boolean} Phaser.Boot.Config#inputTouchCapture - [description] - */ - this.inputTouchCapture = GetValue(config, 'input.touch.capture', true); - - /** - * @const {integer} Phaser.Boot.Config#inputActivePointers - [description] - */ - this.inputActivePointers = GetValue(config, 'input.activePointers', 1); - - /** - * @const {boolean} Phaser.Boot.Config#inputGamepad - [description] - */ - this.inputGamepad = GetValue(config, 'input.gamepad', false); - - /** - * @const {*} Phaser.Boot.Config#inputGamepadEventTarget - [description] - */ - this.inputGamepadEventTarget = GetValue(config, 'input.gamepad.target', window); - - /** - * @const {boolean} Phaser.Boot.Config#disableContextMenu - [description] - */ - this.disableContextMenu = GetValue(config, 'disableContextMenu', false); - - /** - * @const {any} Phaser.Boot.Config#audio - [description] - */ - this.audio = GetValue(config, 'audio'); - - // If you do: { banner: false } it won't display any banner at all - - /** - * @const {boolean} Phaser.Boot.Config#hideBanner - [description] - */ - this.hideBanner = (GetValue(config, 'banner', null) === false); - - /** - * @const {boolean} Phaser.Boot.Config#hidePhaser - [description] - */ - this.hidePhaser = GetValue(config, 'banner.hidePhaser', false); - - /** - * @const {string} Phaser.Boot.Config#bannerTextColor - [description] - */ - this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); - - /** - * @const {string[]} Phaser.Boot.Config#bannerBackgroundColor - [description] - */ - this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); - - if (this.gameTitle === '' && this.hidePhaser) - { - this.hideBanner = true; - } - - // Frame Rate config - // fps: { - // min: 10, - // target: 60, - // forceSetTimeOut: false, - // deltaHistory: 10 - // } - - /** - * @const {?FPSConfig} Phaser.Boot.Config#fps - [description] - */ - this.fps = GetValue(config, 'fps', null); - - // Renderer Settings - // These can either be in a `render` object within the Config, or specified on their own - - var renderConfig = GetValue(config, 'render', config); - - /** - * @const {boolean} Phaser.Boot.Config#antialias - [description] - */ - this.antialias = GetValue(renderConfig, 'antialias', true); - - /** - * @const {boolean} Phaser.Boot.Config#pixelArt - [description] - */ - this.pixelArt = GetValue(renderConfig, 'pixelArt', false); - - /** - * @const {boolean} Phaser.Boot.Config#autoResize - [description] - */ - this.autoResize = GetValue(renderConfig, 'autoResize', false); - - /** - * @const {boolean} Phaser.Boot.Config#roundPixels - [description] - */ - this.roundPixels = GetValue(renderConfig, 'roundPixels', false); - - /** - * @const {boolean} Phaser.Boot.Config#transparent - [description] - */ - this.transparent = GetValue(renderConfig, 'transparent', false); - - /** - * @const {boolean} Phaser.Boot.Config#zoclearBeforeRenderom - [description] - */ - this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true); - - /** - * @const {boolean} Phaser.Boot.Config#premultipliedAlpha - [description] - */ - this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true); - - /** - * @const {boolean} Phaser.Boot.Config#preserveDrawingBuffer - [description] - */ - this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false); - - /** - * @const {boolean} Phaser.Boot.Config#failIfMajorPerformanceCaveat - [description] - */ - this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false); - - /** - * @const {string} Phaser.Boot.Config#powerPreference - [description] - */ - this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default'); - - var bgc = GetValue(config, 'backgroundColor', 0); - - /** - * @const {Phaser.Display.Color} Phaser.Boot.Config#backgroundColor - [description] - */ - this.backgroundColor = ValueToColor(bgc); - - if (bgc === 0 && this.transparent) - { - this.backgroundColor.alpha = 0; - } - - // Callbacks - - /** - * @const {BootCallback} Phaser.Boot.Config#preBoot - [description] - */ - this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); - - /** - * @const {BootCallback} Phaser.Boot.Config#postBoot - [description] - */ - this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); - - // Physics - // physics: { - // system: 'impact', - // setBounds: true, - // gravity: 0, - // cellSize: 64 - // } - - /** - * @const {object} Phaser.Boot.Config#physics - [description] - */ - this.physics = GetValue(config, 'physics', {}); - - /** - * @const {boolean} Phaser.Boot.Config#defaultPhysicsSystem - [description] - */ - this.defaultPhysicsSystem = GetValue(this.physics, 'default', false); - - // Loader Defaults - - /** - * @const {string} Phaser.Boot.Config#loaderBaseURL - [description] - */ - this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); - - /** - * @const {string} Phaser.Boot.Config#loaderPath - [description] - */ - this.loaderPath = GetValue(config, 'loader.path', ''); - - /** - * @const {integer} Phaser.Boot.Config#loaderMaxParallelDownloads - [description] - */ - this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 32); - - /** - * @const {(string|undefined)} Phaser.Boot.Config#loaderCrossOrigin - [description] - */ - this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); - - /** - * @const {string} Phaser.Boot.Config#loaderResponseType - [description] - */ - this.loaderResponseType = GetValue(config, 'loader.responseType', ''); - - /** - * @const {boolean} Phaser.Boot.Config#loaderAsync - [description] - */ - this.loaderAsync = GetValue(config, 'loader.async', true); - - /** - * @const {string} Phaser.Boot.Config#loaderUser - [description] - */ - this.loaderUser = GetValue(config, 'loader.user', ''); - - /** - * @const {string} Phaser.Boot.Config#loaderPassword - [description] - */ - this.loaderPassword = GetValue(config, 'loader.password', ''); - - /** - * @const {integer} Phaser.Boot.Config#loaderTimeout - [description] - */ - this.loaderTimeout = GetValue(config, 'loader.timeout', 0); - - // Plugins - - /* - * Allows `plugins` property to either be an array, in which case it just replaces - * the default plugins like previously, or a config object. - * - * plugins: { - * global: [ - * { key: 'TestPlugin', plugin: TestPlugin, start: true }, - * ], - * scene: [ - * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } - * ], - * default: [], OR - * defaultMerge: { - * 'ModPlayer' - * } - * } - */ - - /** - * @const {any} Phaser.Boot.Config#installGlobalPlugins - [description] - */ - this.installGlobalPlugins = []; - - /** - * @const {any} Phaser.Boot.Config#installScenePlugins - [description] - */ - this.installScenePlugins = []; - - var plugins = GetValue(config, 'plugins', null); - var defaultPlugins = DefaultPlugins.DefaultScene; - - if (plugins) - { - // Old 3.7 array format? - if (Array.isArray(plugins)) - { - this.defaultPlugins = plugins; - } - else if (IsPlainObject(plugins)) - { - this.installGlobalPlugins = GetFastValue(plugins, 'global', []); - this.installScenePlugins = GetFastValue(plugins, 'scene', []); - - if (Array.isArray(plugins.default)) - { - defaultPlugins = plugins.default; - } - else if (Array.isArray(plugins.defaultMerge)) - { - defaultPlugins = defaultPlugins.concat(plugins.defaultMerge); - } - } - } - - /** - * @const {any} Phaser.Boot.Config#defaultPlugins - The plugins installed into every Scene (in addition to CoreScene and Global). - */ - this.defaultPlugins = defaultPlugins; - - // Default / Missing Images - var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; - - /** - * @const {string} Phaser.Boot.Config#defaultImage - [description] - */ - this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); - - /** - * @const {string} Phaser.Boot.Config#missingImage - [description] - */ - this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); - } - -}); - -module.exports = Config; - - -/***/ }), -/* 534 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AddToDOM = __webpack_require__(130); -var AnimationManager = __webpack_require__(207); -var CacheManager = __webpack_require__(205); -var CanvasPool = __webpack_require__(22); -var Class = __webpack_require__(0); -var Config = __webpack_require__(533); -var CreateRenderer = __webpack_require__(532); -var DataManager = __webpack_require__(81); -var DebugHeader = __webpack_require__(524); -var Device = __webpack_require__(523); -var DOMContentLoaded = __webpack_require__(271); -var EventEmitter = __webpack_require__(9); -var InputManager = __webpack_require__(201); -var PluginManager = __webpack_require__(196); -var SceneManager = __webpack_require__(194); -var SoundManagerCreator = __webpack_require__(191); -var TextureManager = __webpack_require__(184); -var TimeStep = __webpack_require__(506); -var VisibilityHandler = __webpack_require__(505); - -/** - * @classdesc - * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible - * for handling the boot process, parsing the configuration values, creating the renderer, - * and setting-up all of the global Phaser systems, such as sound and input. - * Once that is complete it will start the Scene Manager and then begin the main game loop. - * - * You should generally avoid accessing any of the systems created by Game, and instead use those - * made available to you via the Phaser.Scene Systems class instead. - * - * @class Game - * @memberOf Phaser - * @constructor - * @since 3.0.0 - * - * @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. - */ -var Game = new Class({ - - initialize: - - function Game (config) - { - /** - * The parsed Game Configuration object. - * - * The values stored within this object are read-only and should not be changed at run-time. - * - * @name Phaser.Game#config - * @type {Phaser.Boot.Config} - * @readOnly - * @since 3.0.0 - */ - this.config = new Config(config); - - /** - * A reference to either the Canvas or WebGL Renderer that this Game is using. - * - * @name Phaser.Game#renderer - * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} - * @since 3.0.0 - */ - this.renderer = null; - - /** - * A reference to the HTML Canvas Element that Phaser uses to render the game. - * This is created automatically by Phaser unless you provide a `canvas` property - * in your Game Config. - * - * @name Phaser.Game#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = null; - - /** - * A reference to the Rendering Context belonging to the Canvas Element this game is rendering to. - * If the game is running under Canvas it will be a 2d Canvas Rendering Context. - * If the game is running under WebGL it will be a WebGL Rendering Context. - * This context is created automatically by Phaser unless you provide a `context` property - * in your Game Config. - * - * @name Phaser.Game#context - * @type {(CanvasRenderingContext2D|WebGLRenderingContext)} - * @since 3.0.0 - */ - this.context = null; - - /** - * A flag indicating when this Game instance has finished its boot process. - * - * @name Phaser.Game#isBooted - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isBooted = false; - - /** - * A flag indicating if this Game is currently running its game step or not. - * - * @name Phaser.Game#isRunning - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isRunning = false; - - /** - * An Event Emitter which is used to broadcast game-level events from the global systems. - * - * @name Phaser.Game#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events = new EventEmitter(); - - /** - * An instance of the Animation Manager. - * - * The Animation Manager is a global system responsible for managing all animations used within your game. - * - * @name Phaser.Game#anims - * @type {Phaser.Animations.AnimationManager} - * @since 3.0.0 - */ - this.anims = new AnimationManager(this); - - /** - * An instance of the Texture Manager. - * - * The Texture Manager is a global system responsible for managing all textures being used by your game. - * - * @name Phaser.Game#textures - * @type {Phaser.Textures.TextureManager} - * @since 3.0.0 - */ - this.textures = new TextureManager(this); - - /** - * An instance of the Cache Manager. - * - * The Cache Manager is a global system responsible for caching, accessing and releasing external game assets. - * - * @name Phaser.Game#cache - * @type {Phaser.Cache.CacheManager} - * @since 3.0.0 - */ - this.cache = new CacheManager(this); - - /** - * An instance of the Data Manager - * - * @name Phaser.Game#registry - * @type {Phaser.Data.DataManager} - * @since 3.0.0 - */ - this.registry = new DataManager(this); - - /** - * An instance of the Input Manager. - * - * The Input Manager is a global system responsible for the capture of browser-level input events. - * - * @name Phaser.Game#input - * @type {Phaser.Input.InputManager} - * @since 3.0.0 - */ - this.input = new InputManager(this, this.config); - - /** - * An instance of the Scene Manager. - * - * The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game. - * - * @name Phaser.Game#scene - * @type {Phaser.Scenes.SceneManager} - * @since 3.0.0 - */ - this.scene = new SceneManager(this, this.config.sceneConfig); - - /** - * A reference to the Device inspector. - * - * Contains information about the device running this game, such as OS, browser vendor and feature support. - * Used by various systems to determine capabilities and code paths. - * - * @name Phaser.Game#device - * @type {Phaser.DeviceConf} - * @since 3.0.0 - */ - this.device = Device; - - /** - * An instance of the base Sound Manager. - * - * The Sound Manager is a global system responsible for the playback and updating of all audio in your game. - * - * @name Phaser.Game#sound - * @type {Phaser.Sound.BaseSoundManager} - * @since 3.0.0 - */ - this.sound = SoundManagerCreator.create(this); - - /** - * An instance of the Time Step. - * - * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing - * them and calculating delta values. It then automatically calls the game step. - * - * @name Phaser.Game#loop - * @type {Phaser.Boot.TimeStep} - * @since 3.0.0 - */ - this.loop = new TimeStep(this, this.config.fps); - - /** - * An instance of the Plugin Manager. - * - * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install - * those plugins into Scenes as required. - * - * @name Phaser.Game#plugins - * @type {Phaser.Plugins.PluginManager} - * @since 3.0.0 - */ - this.plugins = new PluginManager(this, this.config); - - /** - * Is this Game pending destruction at the start of the next frame? - * - * @name Phaser.Game#pendingDestroy - * @type {boolean} - * @private - * @since 3.5.0 - */ - this.pendingDestroy = false; - - /** - * Remove the Canvas once the destroy is over? - * - * @name Phaser.Game#removeCanvas - * @type {boolean} - * @private - * @since 3.5.0 - */ - this.removeCanvas = false; - - /** - * Does the window the game is running in currently have focus or not? - * This is modified by the VisibilityHandler. - * - * @name Phaser.Game#hasFocus - * @type {boolean} - * @readOnly - * @since 3.9.0 - */ - this.hasFocus = false; - - /** - * Is the mouse pointer currently over the game canvas or not? - * This is modified by the VisibilityHandler. - * - * @name Phaser.Game#isOver - * @type {boolean} - * @readOnly - * @since 3.10.0 - */ - this.isOver = true; - - // Wait for the DOM Ready event, then call boot. - DOMContentLoaded(this.boot.bind(this)); - }, - - /** - * Game boot event. - * - * This is an internal event dispatched when the game has finished booting, but before it is ready to start running. - * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. - * - * @event Phaser.Game#boot - */ - - /** - * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, - * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. - * It listens for a 'ready' event from the base systems and once received it will call `Game.start`. - * - * @method Phaser.Game#boot - * @protected - * @fires Phaser.Game#boot - * @since 3.0.0 - */ - boot: function () - { - this.isBooted = true; - - this.config.preBoot(this); - - CreateRenderer(this); - - DebugHeader(this); - - AddToDOM(this.canvas, this.config.parent); - - this.events.emit('boot'); - - // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event - this.events.once('ready', this.start, this); - }, - - /** - * Called automatically by Game.boot once all of the global systems have finished setting themselves up. - * By this point the Game is now ready to start the main loop running. - * It will also enable the Visibility Handler. - * - * @method Phaser.Game#start - * @protected - * @since 3.0.0 - */ - start: function () - { - this.isRunning = true; - - this.config.postBoot(this); - - if (this.renderer) - { - this.loop.start(this.step.bind(this)); - } - else - { - this.loop.start(this.headlessStep.bind(this)); - } - - VisibilityHandler(this); - - var eventEmitter = this.events; - - eventEmitter.on('hidden', this.onHidden, this); - eventEmitter.on('visible', this.onVisible, this); - eventEmitter.on('blur', this.onBlur, this); - eventEmitter.on('focus', this.onFocus, this); - }, - - /** - * Game Pre-Step event. - * - * This event is dispatched before the main Step starts. - * By this point none of the Scene updates have happened. - * Hook into it from plugins or systems that need to update before the Scene Manager does. - * - * @event Phaser.Game#prestepEvent - * @param {number} time - [description] - * @param {number} delta - [description] - */ - - /** - * Game Step event. - * - * This event is dispatched after Pre-Step and before the Scene Manager steps. - * Hook into it from plugins or systems that need to update before the Scene Manager does, but after core Systems. - * - * @event Phaser.Game#stepEvent - * @param {number} time - [description] - * @param {number} delta - [description] - */ - - /** - * Game Post-Step event. - * - * This event is dispatched after the Scene Manager has updated. - * Hook into it from plugins or systems that need to do things before the render starts. - * - * @event Phaser.Game#poststepEvent - * @param {number} time - [description] - * @param {number} delta - [description] - */ - - /** - * Game Pre-Render event. - * - * This event is dispatched immediately before any of the Scenes have started to render. - * The renderer will already have been initialized this frame, clearing itself and preparing to receive - * the Scenes for rendering, but it won't have actually drawn anything yet. - * - * @event Phaser.Game#prerenderEvent - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - A reference to the current renderer. - */ - - /** - * Game Post-Render event. - * - * This event is dispatched right at the end of the render process. - * Every Scene will have rendered and drawn to the canvas. - * - * @event Phaser.Game#postrenderEvent - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - A reference to the current renderer. - */ - - /** - * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of - * Request Animation Frame, or Set Timeout on very old browsers.) - * - * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. - * - * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. - * - * @method Phaser.Game#step - * @fires Phaser.Game#prestepEvent - * @fires Phaser.Game#stepEvent - * @fires Phaser.Game#poststepEvent - * @fires Phaser.Game#prerenderEvent - * @fires Phaser.Game#postrenderEvent - * @since 3.0.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. - */ - step: function (time, delta) - { - if (this.pendingDestroy) - { - return this.runDestroy(); - } - - var eventEmitter = this.events; - - // Global Managers like Input and Sound update in the prestep - - eventEmitter.emit('prestep', time, delta); - - // This is mostly meant for user-land code and plugins - - eventEmitter.emit('step', time, delta); - - // Update the Scene Manager and all active Scenes - - this.scene.update(time, delta); - - // Our final event before rendering starts - - eventEmitter.emit('poststep', time, delta); - - var renderer = this.renderer; - - // Run the Pre-render (clearing the canvas, setting background colors, etc) - - renderer.preRender(); - - eventEmitter.emit('prerender', renderer, time, delta); - - // The main render loop. Iterates all Scenes and all Cameras in those scenes, rendering to the renderer instance. - - this.scene.render(renderer); - - // The Post-Render call. Tidies up loose end, takes snapshots, etc. - - renderer.postRender(); - - // The final event before the step repeats. Your last chance to do anything to the canvas before it all starts again. - - eventEmitter.emit('postrender', renderer, time, delta); - }, - - /** - * A special version of the Game Step for the HEADLESS renderer only. - * - * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of - * Request Animation Frame, or Set Timeout on very old browsers.) - * - * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. - * - * This process emits `prerender` and `postrender` events, even though nothing actually displays. - * - * @method Phaser.Game#headlessStep - * @fires Phaser.Game#prerenderEvent - * @fires Phaser.Game#postrenderEvent - * @since 3.2.0 - * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - headlessStep: function (time, delta) - { - var eventEmitter = this.events; - - // Global Managers - - eventEmitter.emit('prestep', time, delta); - - eventEmitter.emit('step', time, delta); - - // Scenes - - this.scene.update(time, delta); - - eventEmitter.emit('poststep', time, delta); - - // Render - - eventEmitter.emit('prerender'); - - eventEmitter.emit('postrender'); - }, - - /** - * Game Pause event. - * - * This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler. - * - * @event Phaser.Game#pauseEvent - */ - - /** - * Called automatically by the Visibility Handler. - * This will pause the main loop and then emit a pause event. - * - * @method Phaser.Game#onHidden - * @protected - * @fires Phaser.Game#pauseEvent - * @since 3.0.0 - */ - onHidden: function () - { - this.loop.pause(); - - this.events.emit('pause'); - }, - - /** - * Game Resume event. - * - * This event is dispatched when the game loop leaves a paused state and resumes running. - * - * @event Phaser.Game#resumeEvent - */ - - /** - * Called automatically by the Visibility Handler. - * This will resume the main loop and then emit a resume event. - * - * @method Phaser.Game#onVisible - * @protected - * @fires Phaser.Game#resumeEvent - * @since 3.0.0 - */ - onVisible: function () - { - this.loop.resume(); - - this.events.emit('resume'); - }, - - /** - * Called automatically by the Visibility Handler. - * This will set the main loop into a 'blurred' state, which pauses it. - * - * @method Phaser.Game#onBlur - * @protected - * @since 3.0.0 - */ - onBlur: function () - { - this.hasFocus = false; - - this.loop.blur(); - }, - - /** - * Called automatically by the Visibility Handler. - * This will set the main loop into a 'focused' state, which resumes it. - * - * @method Phaser.Game#onFocus - * @protected - * @since 3.0.0 - */ - onFocus: function () - { - this.hasFocus = true; - - this.loop.focus(); - }, - - /** - * Game Resize event. - * - * @event Phaser.Game#resizeEvent - * @param {number} width - The new width of the Game. - * @param {number} height - The new height of the Game. - */ - - /** - * Updates the Game Config with the new width and height values given. - * Then resizes the Renderer and Input Manager scale. - * - * @method Phaser.Game#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the game. - * @param {number} height - The new height of the game. - */ - resize: function (width, height) - { - this.config.width = width; - this.config.height = height; - - this.renderer.resize(width, height); - - this.input.resize(); - - this.scene.resize(width, height); - - this.events.emit('resize', width, height); - }, - - /** - * Flags this Game instance as needing to be destroyed on the next frame. - * It will wait until the current frame has completed and then call `runDestroy` internally. - * - * @method Phaser.Game#destroy - * @since 3.0.0 - * - * @param {boolean} removeCanvas - Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. - */ - destroy: function (removeCanvas) - { - this.pendingDestroy = true; - - this.removeCanvas = removeCanvas; - }, - - /** - * Destroys this Phaser.Game instance, all global systems, all sub-systems and all Scenes. - * - * @method Phaser.Game#runDestroy - * @private - * @since 3.5.0 - */ - runDestroy: function () - { - this.events.emit('destroy'); - - this.events.removeAllListeners(); - - this.scene.destroy(); - - if (this.renderer) - { - this.renderer.destroy(); - } - - if (this.removeCanvas && this.canvas) - { - CanvasPool.remove(this.canvas); - - if (this.canvas.parentNode) - { - this.canvas.parentNode.removeChild(this.canvas); - } - } - - this.loop.destroy(); - - this.pendingDestroy = false; - } - -}); - -module.exports = Game; - - -/***/ }), -/* 535 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EE = __webpack_require__(9); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. - * - * @class EventEmitter - * @memberOf Phaser.Events - * @constructor - * @since 3.0.0 - */ -var EventEmitter = new Class({ - - Extends: EE, - - initialize: - - function EventEmitter () - { - EE.call(this); - }, - - /** - * Removes all listeners. - * - * @method Phaser.Events.EventEmitter#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAllListeners(); - }, - - /** - * Removes all listeners. - * - * @method Phaser.Events.EventEmitter#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllListeners(); - } - -}); - -/** - * Return an array listing the events for which the emitter has registered listeners. - * - * @method Phaser.Events.EventEmitter#eventNames - * @since 3.0.0 - * - * @return {array} - */ - -/** - * Return the listeners registered for a given event. - * - * @method Phaser.Events.EventEmitter#listeners - * @since 3.0.0 - * - * @param {(string|symbol)} event - The event name. - * - * @return {array} The registered listeners. - */ - -/** - * Return the number of listeners listening to a given event. - * - * @method Phaser.Events.EventEmitter#listenerCount - * @since 3.0.0 - * - * @param {(string|symbol)} event - The event name. - * - * @return {number} The number of listeners. - */ - -/** - * Calls each of the listeners registered for a given event. - * - * @method Phaser.Events.EventEmitter#emit - * @since 3.0.0 - * - * @param {(string|symbol)} event - The event name. - * @param {...*} [args] - Additional arguments that will be passed to the event handler. - * - * @return {boolean} `true` if the event had listeners, else `false`. - */ - -/** - * Add a listener for a given event. - * - * @method Phaser.Events.EventEmitter#on - * @since 3.0.0 - * - * @param {(string|symbol)} event - The event name. - * @param {function} fn - The listener function. - * @param {*} [context=this] - The context to invoke the listener with. - * - * @return {Phaser.Events.EventEmitter} `this`. - */ - -/** - * Add a listener for a given event. - * - * @method Phaser.Events.EventEmitter#addListener - * @since 3.0.0 - * - * @param {(string|symbol)} event - The event name. - * @param {function} fn - The listener function. - * @param {*} [context=this] - The context to invoke the listener with. - * - * @return {Phaser.Events.EventEmitter} `this`. - */ - -/** - * Add a one-time listener for a given event. - * - * @method Phaser.Events.EventEmitter#once - * @since 3.0.0 - * - * @param {(string|symbol)} event - The event name. - * @param {function} fn - The listener function. - * @param {*} [context=this] - The context to invoke the listener with. - * - * @return {Phaser.Events.EventEmitter} `this`. - */ - -/** - * Remove the listeners of a given event. - * - * @method Phaser.Events.EventEmitter#removeListener - * @since 3.0.0 - * - * @param {(string|symbol)} event - The event name. - * @param {function} fn - Only remove the listeners that match this function. - * @param {*} context - Only remove the listeners that have this context. - * @param {boolean} once - Only remove one-time listeners. - * - * @return {Phaser.Events.EventEmitter} `this`. - */ - -/** - * Remove the listeners of a given event. - * - * @method Phaser.Events.EventEmitter#off - * @since 3.0.0 - * - * @param {(string|symbol)} event - The event name. - * @param {function} fn - Only remove the listeners that match this function. - * @param {*} context - Only remove the listeners that have this context. - * @param {boolean} once - Only remove one-time listeners. - * - * @return {Phaser.Events.EventEmitter} `this`. - */ - -/** - * Remove all listeners, or those of the specified event. - * - * @method Phaser.Events.EventEmitter#removeAllListeners - * @since 3.0.0 - * - * @param {(string|symbol)} [event] - The event name. - * - * @return {Phaser.Events.EventEmitter} `this`. - */ - -PluginCache.register('EventEmitter', EventEmitter, 'events'); - -module.exports = EventEmitter; - - -/***/ }), -/* 536 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Events - */ - -module.exports = { EventEmitter: __webpack_require__(535) }; - - -/***/ }), -/* 537 */ -/***/ (function(module, exports) { - -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - - -/***/ }), -/* 538 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Masks - */ - -module.exports = { - - BitmapMask: __webpack_require__(214), - GeometryMask: __webpack_require__(213) - -}; - - -/***/ }), -/* 539 */, -/* 540 */, -/* 541 */, -/* 542 */, -/* 543 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var DataManager = __webpack_require__(81); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - * - * @class DataManagerPlugin - * @extends Phaser.Data.DataManager - * @memberOf Phaser.Data - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - A reference to the Scene that this DataManager belongs to. - */ -var DataManagerPlugin = new Class({ - - Extends: DataManager, - - initialize: - - function DataManagerPlugin (scene) - { - DataManager.call(this, scene, scene.sys.events); - - /** - * A reference to the Scene that this DataManager belongs to. - * - * @name Phaser.Data.DataManagerPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene's Systems. - * - * @name Phaser.Data.DataManagerPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Data.DataManagerPlugin#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.events = this.systems.events; - - this.events.once('destroy', this.destroy, 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.Data.DataManagerPlugin#start - * @private - * @since 3.5.0 - */ - start: function () - { - this.events.once('shutdown', this.shutdown, 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 () - { - this.systems.events.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.Data.DataManagerPlugin#destroy - * @since 3.5.0 - */ - destroy: function () - { - DataManager.prototype.destroy.call(this); - - this.events.off('start', this.start, this); - - this.scene = null; - this.systems = null; - } - -}); - -PluginCache.register('DataManagerPlugin', DataManagerPlugin, 'data'); - -module.exports = DataManagerPlugin; - - -/***/ }), -/* 544 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Data - */ - -module.exports = { - - DataManager: __webpack_require__(81), - DataManagerPlugin: __webpack_require__(543) - -}; - - -/***/ }), -/* 545 */, -/* 546 */, -/* 547 */, -/* 548 */, -/* 549 */, -/* 550 */, -/* 551 */, -/* 552 */, -/* 553 */, -/* 554 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera, parentMatrix); -}; - -module.exports = SpriteCanvasRenderer; - - -/***/ }), -/* 555 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchSprite(src, camera, parentMatrix); -}; - -module.exports = SpriteWebGLRenderer; - - -/***/ }), -/* 556 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(555); -} - -if (true) -{ - renderCanvas = __webpack_require__(554); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 557 */, -/* 558 */, -/* 559 */, -/* 560 */, -/* 561 */, -/* 562 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(123); -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); -var RectangleContains = __webpack_require__(31); - -/** - * @typedef {object} InputJSONCameraObject - * - * @property {string} [name=''] - [description] - * @property {integer} [x=0] - [description] - * @property {integer} [y=0] - [description] - * @property {integer} [width] - [description] - * @property {integer} [height] - [description] - * @property {float} [zoom=1] - [description] - * @property {float} [rotation=0] - [description] - * @property {boolean} [roundPixels=false] - [description] - * @property {float} [scrollX=0] - [description] - * @property {float} [scrollY=0] - [description] - * @property {(false|string)} [backgroundColor=false] - [description] - * @property {?object} [bounds] - [description] - * @property {number} [bounds.x=0] - [description] - * @property {number} [bounds.y=0] - [description] - * @property {number} [bounds.width] - [description] - * @property {number} [bounds.height] - [description] - */ - -/** - * @classdesc - * [description] - * - * @class CameraManager - * @memberOf Phaser.Cameras.Scene2D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. - */ -var CameraManager = new Class({ - - initialize: - - function CameraManager (scene) - { - /** - * The Scene that owns the Camera Manager plugin. - * - * @name Phaser.Cameras.Scene2D.CameraManager#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * The current Camera ID. - * - * @name Phaser.Cameras.Scene2D.CameraManager#currentCameraId - * @type {number} - * @default 1 - * @readOnly - * @since 3.0.0 - */ - this.currentCameraId = 1; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameras - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameras = []; - - /** - * A pool of Camera objects available to be used by the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameraPool - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameraPool = []; - - /** - * The default Camera in the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#main - * @type {Phaser.Cameras.Scene2D.Camera} - * @since 3.0.0 - */ - this.main; - - /** - * This scale affects all cameras. It's used by Scale Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#baseScale - * @type {number} - * @since 3.0.0 - */ - this.baseScale = 1; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Cameras.Scene2D.CameraManager#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - 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]; - - this.systems.events.once('destroy', this.destroy, 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.Cameras.Scene2D.CameraManager#start - * @private - * @since 3.5.0 - */ - start: function () - { - if (!this.main) - { - this.boot(); - } - - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#add - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] - * @param {boolean} [makeMain=false] - [description] - * @param {string} [name=''] - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - add: function (x, y, width, height, makeMain, name) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = this.scene.sys.game.config.width; } - if (height === undefined) { height = this.scene.sys.game.config.height; } - if (makeMain === undefined) { makeMain = false; } - if (name === undefined) { name = ''; } - - var camera = null; - - if (this.cameraPool.length > 0) - { - camera = this.cameraPool.pop(); - - camera.setViewport(x, y, width, height); - } - else - { - camera = new Camera(x, y, width, height); - } - - camera.setName(name); - camera.setScene(this.scene); - - this.cameras.push(camera); - - if (makeMain) - { - this.main = camera; - } - - camera._id = this.currentCameraId; - - this.currentCameraId = this.currentCameraId << 1; - - return camera; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#addExisting - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - addExisting: function (camera) - { - var index = this.cameras.indexOf(camera); - var poolIndex = this.cameraPool.indexOf(camera); - - if (index < 0 && poolIndex >= 0) - { - this.cameras.push(camera); - this.cameraPool.slice(poolIndex, 1); - - return camera; - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON - * @since 3.0.0 - * - * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - [description] - * - * @return {Phaser.Cameras.Scene2D.CameraManager} [description] - */ - fromJSON: function (config) - { - if (!Array.isArray(config)) - { - config = [ config ]; - } - - var gameWidth = this.scene.sys.game.config.width; - var gameHeight = this.scene.sys.game.config.height; - - for (var i = 0; i < config.length; i++) - { - var cameraConfig = config[i]; - - var x = GetFastValue(cameraConfig, 'x', 0); - var y = GetFastValue(cameraConfig, 'y', 0); - var width = GetFastValue(cameraConfig, 'width', gameWidth); - var height = GetFastValue(cameraConfig, 'height', gameHeight); - - var camera = this.add(x, y, width, height); - - // Direct properties - camera.name = GetFastValue(cameraConfig, 'name', ''); - camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); - camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); - camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); - camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); - camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); - camera.visible = GetFastValue(cameraConfig, 'visible', true); - - // Background Color - - var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); - - if (backgroundColor) - { - camera.setBackgroundColor(backgroundColor); - } - - // Bounds - - var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); - - if (boundsConfig) - { - var bx = GetFastValue(boundsConfig, 'x', 0); - var by = GetFastValue(boundsConfig, 'y', 0); - var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); - var bheight = GetFastValue(boundsConfig, 'height', gameHeight); - - camera.setBounds(bx, by, bwidth, bheight); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCamera - * @since 3.0.0 - * - * @param {string} name - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - getCamera: function (name) - { - for (var i = 0; i < this.cameras.length; i++) - { - if (this.cameras[i].name === name) - { - return this.cameras[i]; - } - } - - return null; - }, - - /** - * Returns an array of all cameras below the given Pointer. - * - * The first camera in the array is the top-most camera in the camera list. - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCamerasBelowPointer - * @since 3.10.0 - * - * @param {Phaser.Input.Pointer} pointer - The Pointer to check against. - * - * @return {Phaser.Cameras.Scene2D.Camera[]} An array of cameras below the Pointer. - */ - getCamerasBelowPointer: function (pointer) - { - var cameras = this.cameras; - - var x = pointer.x; - var y = pointer.y; - - var output = []; - - for (var i = 0; i < cameras.length; i++) - { - var camera = cameras[i]; - - if (camera.visible && camera.inputEnabled && RectangleContains(camera, x, y)) - { - // So the top-most camera is at the top of the search array - output.unshift(camera); - } - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#remove - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - remove: function (camera) - { - var cameraIndex = this.cameras.indexOf(camera); - - if (cameraIndex >= 0 && this.cameras.length > 1) - { - this.cameraPool.push(this.cameras[cameraIndex]); - this.cameras.splice(cameraIndex, 1); - - if (this.main === camera) - { - this.main = this.cameras[0]; - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#render - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. - * @param {Phaser.GameObjects.GameObject[]} children - An array of renderable Game Objects. - * @param {number} interpolation - Interpolation value. Reserved for future use. - */ - render: function (renderer, children, interpolation) - { - var cameras = this.cameras; - var baseScale = this.baseScale; - - for (var i = 0, l = cameras.length; i < l; ++i) - { - var camera = cameras[i]; - - if (camera.visible) - { - camera.preRender(baseScale, renderer.config.resolution); - - renderer.render(this.scene, children, interpolation, camera); - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#resetAll - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - resetAll: function () - { - while (this.cameras.length > 0) - { - this.cameraPool.push(this.cameras.pop()); - } - - this.main = this.add(); - - return this.main; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#update - * @since 3.0.0 - * - * @param {number} timestep - [description] - * @param {number} delta - [description] - */ - update: function (timestep, delta) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].update(timestep, delta); - } - }, - - /** - * Resizes all cameras to the given dimensions. - * - * @method Phaser.Cameras.Scene2D.CameraManager#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the camera. - * @param {number} height - The new height of the camera. - */ - resize: function (width, height) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].setSize(width, height); - } - }, - - /** - * 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 () - { - this.main = undefined; - - for (var i = 0; i < this.cameras.length; i++) - { - this.cameras[i].destroy(); - } - - for (i = 0; i < this.cameraPool.length; i++) - { - this.cameraPool[i].destroy(); - } - - this.cameras = []; - this.cameraPool = []; - - 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; - } - -}); - -PluginCache.register('CameraManager', CameraManager, 'cameras'); - -module.exports = CameraManager; - - -/***/ }), -/* 563 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @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; - - -/***/ }), -/* 564 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); - -/** - * @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.Pipelines.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; - - -/***/ }), -/* 565 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); - -/** - * @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.Pipelines.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; - - -/***/ }), -/* 566 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras.Scene2D - */ - -module.exports = { - - Camera: __webpack_require__(123), - CameraManager: __webpack_require__(562), - Effects: __webpack_require__(204) - -}; - - -/***/ }), -/* 567 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cache - */ - -module.exports = { - - BaseCache: __webpack_require__(206), - CacheManager: __webpack_require__(205) - -}; - - -/***/ }), -/* 568 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Animations - */ - -module.exports = { - - Animation: __webpack_require__(210), - AnimationFrame: __webpack_require__(208), - AnimationManager: __webpack_require__(207) - -}; - - -/***/ }), -/* 569 */, -/* 570 */, -/* 571 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// bitmask flag for GameObject.renderMask -var _FLAG = 1; // 0001 - -/** - * Provides methods used for setting the visibility of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Visible - * @since 3.0.0 - */ - -var Visible = { - - /** - * Private internal value. Holds the visible value. - * - * @name Phaser.GameObjects.Components.Visible#_visible - * @type {boolean} - * @private - * @default true - * @since 3.0.0 - */ - _visible: true, - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @name Phaser.GameObjects.Components.Visible#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - if (value) - { - this._visible = true; - this.renderFlags |= _FLAG; - } - else - { - this._visible = false; - this.renderFlags &= ~_FLAG; - } - } - - }, - - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @method Phaser.GameObjects.Components.Visible#setVisible - * @since 3.0.0 - * - * @param {boolean} value - The visible state of the Game Object. - * - * @return {this} This Game Object instance. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - } -}; - -module.exports = Visible; - - -/***/ }), -/* 572 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var TransformMatrix = __webpack_require__(64); -var WrapAngle = __webpack_require__(212); -var WrapAngleDegrees = __webpack_require__(211); - -// global bitmask flag for GameObject.renderMask (used by Scale) -var _FLAG = 4; // 0100 - -/** - * Provides methods used for getting and setting the position, scale and rotation of a Game Object. - * - * @name Phaser.GameObjects.Components.Transform - * @since 3.0.0 - */ - -var Transform = { - - /** - * Private internal value. Holds the horizontal scale value. - * - * @name Phaser.GameObjects.Components.Transform#_scaleX - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _scaleX: 1, - - /** - * Private internal value. Holds the vertical scale value. - * - * @name Phaser.GameObjects.Components.Transform#_scaleY - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _scaleY: 1, - - /** - * Private internal value. Holds the rotation value in radians. - * - * @name Phaser.GameObjects.Components.Transform#_rotation - * @type {float} - * @private - * @default 0 - * @since 3.0.0 - */ - _rotation: 0, - - /** - * The x position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - x: 0, - - /** - * The y position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - y: 0, - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - * - * @name Phaser.GameObjects.Components.Transform#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - z: 0, - - /** - * The w position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - w: 0, - - /** - * The horizontal scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleX: { - - get: function () - { - return this._scaleX; - }, - - set: function (value) - { - this._scaleX = value; - - if (this._scaleX === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The vertical scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleY: { - - get: function () - { - return this._scaleY; - }, - - set: function (value) - { - this._scaleY = value; - - if (this._scaleY === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The angle of this Game Object as expressed in degrees. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - * - * @name Phaser.GameObjects.Components.Transform#angle - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - angle: { - - get: function () - { - return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); - }, - - set: function (value) - { - // value is in degrees - this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; - } - }, - - /** - * The angle of this Game Object in radians. - * - * If you prefer to work in degrees, see the `angle` property instead. - * - * @name Phaser.GameObjects.Components.Transform#rotation - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this._rotation; - }, - - set: function (value) - { - // value is in radians - this._rotation = WrapAngle(value); - } - }, - - /** - * Sets the position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setPosition - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of this Game Object. - * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value. - * @param {number} [z=0] - The z position of this Game Object. - * @param {number} [w=0] - The w position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setPosition: function (x, y, z, w) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - if (z === undefined) { z = 0; } - if (w === undefined) { w = 0; } - - this.x = x; - this.y = y; - this.z = z; - this.w = w; - - return this; - }, - - /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. - * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * - * @method Phaser.GameObjects.Components.Transform#setRandomPosition - * @since 3.8.0 - * - * @param {number} [x=0] - The x position of the top-left of the random area. - * @param {number} [y=0] - The y position of the top-left of the random area. - * @param {number} [width] - The width of the random area. - * @param {number} [height] - The height of the random area. - * - * @return {this} This Game Object instance. - */ - setRandomPosition: function (x, y, width, height) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = this.scene.sys.game.config.width; } - if (height === undefined) { height = this.scene.sys.game.config.height; } - - this.x = x + (Math.random() * width); - this.y = y + (Math.random() * height); - - return this; - }, - - /** - * Sets the rotation of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setRotation - * @since 3.0.0 - * - * @param {number} [radians=0] - The rotation of this Game Object, in radians. - * - * @return {this} This Game Object instance. - */ - setRotation: function (radians) - { - if (radians === undefined) { radians = 0; } - - this.rotation = radians; - - return this; - }, - - /** - * Sets the angle of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setAngle - * @since 3.0.0 - * - * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. - * - * @return {this} This Game Object instance. - */ - setAngle: function (degrees) - { - if (degrees === undefined) { degrees = 0; } - - this.angle = degrees; - - return this; - }, - - /** - * Sets the scale of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setScale - * @since 3.0.0 - * - * @param {number} x - The horizontal scale of this Game Object. - * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. - * - * @return {this} This Game Object instance. - */ - setScale: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.scaleX = x; - this.scaleY = y; - - return this; - }, - - /** - * Sets the x position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setX - * @since 3.0.0 - * - * @param {number} [value=0] - The x position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setX: function (value) - { - if (value === undefined) { value = 0; } - - this.x = value; - - return this; - }, - - /** - * Sets the y position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setY - * @since 3.0.0 - * - * @param {number} [value=0] - The y position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setY: function (value) - { - if (value === undefined) { value = 0; } - - this.y = value; - - return this; - }, - - /** - * Sets the z position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setZ - * @since 3.0.0 - * - * @param {number} [value=0] - The z position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setZ: function (value) - { - if (value === undefined) { value = 0; } - - this.z = value; - - return this; - }, - - /** - * Sets the w position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setW - * @since 3.0.0 - * - * @param {number} [value=0] - The w position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setW: function (value) - { - if (value === undefined) { value = 0; } - - this.w = value; - - return this; - }, - - /** - * Gets the local transform matrix for this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix - * @since 3.4.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. - * - * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. - */ - getLocalTransformMatrix: function (tempMatrix) - { - if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } - - return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); - }, - - /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * - * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix - * @since 3.4.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. - * - * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. - */ - getWorldTransformMatrix: function (tempMatrix) - { - if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } - - var parent = this.parentContainer; - - if (!parent) - { - return this.getLocalTransformMatrix(tempMatrix); - } - - var parents = []; - - while (parent) - { - parents.unshift(parent); - parent = parent.parentContainer; - } - - tempMatrix.loadIdentity(); - - var length = parents.length; - - for (var i = 0; i < length; ++i) - { - parent = parents[i]; - - tempMatrix.translate(parent.x, parent.y); - tempMatrix.rotate(parent.rotation); - tempMatrix.scale(parent.scaleX, parent.scaleY); - } - - tempMatrix.translate(this.x, this.y); - tempMatrix.rotate(this._rotation); - tempMatrix.scale(this._scaleX, this._scaleY); - - return tempMatrix; - } - -}; - -module.exports = Transform; - - -/***/ }), -/* 573 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} JSONGameObject - * - * @property {string} name - The name of this Game Object. - * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. - * @property {number} x - The x position of this Game Object. - * @property {number} y - The y position of this Game Object. - * @property {object} scale - The scale of this Game Object - * @property {number} scale.x - The horizontal scale of this Game Object. - * @property {number} scale.y - The vertical scale of this Game Object. - * @property {object} origin - The origin of this Game Object. - * @property {float} origin.x - The horizontal origin of this Game Object. - * @property {float} origin.y - The vertical origin of this Game Object. - * @property {boolean} flipX - The horizontally flipped state of the Game Object. - * @property {boolean} flipY - The vertically flipped state of the Game Object. - * @property {number} rotation - The angle of this Game Object in radians. - * @property {float} alpha - The alpha value of the Game Object. - * @property {boolean} visible - The visible state of the Game Object. - * @property {integer} scaleMode - The Scale Mode being used by this Game Object. - * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. - * @property {string} textureKey - The texture key of this Game Object. - * @property {string} frameKey - The frame key of this Game Object. - * @property {object} data - The data of this Game Object. - */ - -/** - * Build a JSON representation of the given Game Object. - * - * This is typically extended further by Game Object specific implementations. - * - * @method Phaser.GameObjects.Components.ToJSON - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON. - * - * @return {JSONGameObject} The JSON representation of the Game Object. - */ -var ToJSON = function (gameObject) -{ - var out = { - name: gameObject.name, - type: gameObject.type, - x: gameObject.x, - y: gameObject.y, - depth: gameObject.depth, - scale: { - x: gameObject.scaleX, - y: gameObject.scaleY - }, - origin: { - x: gameObject.originX, - y: gameObject.originY - }, - flipX: gameObject.flipX, - flipY: gameObject.flipY, - rotation: gameObject.rotation, - alpha: gameObject.alpha, - visible: gameObject.visible, - scaleMode: gameObject.scaleMode, - blendMode: gameObject.blendMode, - textureKey: '', - frameKey: '', - data: {} - }; - - if (gameObject.texture) - { - out.textureKey = gameObject.texture.key; - out.frameKey = gameObject.frame.name; - } - - return out; -}; - -module.exports = ToJSON; - - -/***/ }), -/* 574 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @function GetColor - * @since 3.0.0 - * @private - */ -var GetColor = function (value) -{ - return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); -}; - -/** - * Provides methods used for setting the tint of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Tint - * @webglOnly - * @since 3.0.0 - */ - -var Tint = { - - /** - * Private internal value. Holds the top-left tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintTL - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintTL: 16777215, - - /** - * Private internal value. Holds the top-right tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintTR - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintTR: 16777215, - - /** - * Private internal value. Holds the bottom-left tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintBL - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintBL: 16777215, - - /** - * Private internal value. Holds the bottom-right tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintBR - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintBR: 16777215, - - /** - * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) - * - * @method Phaser.GameObjects.Components.Tint#clearTint - * @webglOnly - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - clearTint: function () - { - this.setTint(0xffffff); - - return this; - }, - - /** - * Sets the tint values for this Game Object. - * - * @method Phaser.GameObjects.Components.Tint#setTint - * @webglOnly - * @since 3.0.0 - * - * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. - * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. - * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. - * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. - * - * @return {this} This Game Object instance. - */ - setTint: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 0xffffff; } - - if (topRight === undefined) - { - topRight = topLeft; - bottomLeft = topLeft; - bottomRight = topLeft; - } - - this._tintTL = GetColor(topLeft); - this._tintTR = GetColor(topRight); - this._tintBL = GetColor(bottomLeft); - this._tintBR = GetColor(bottomRight); - - return this; - }, - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopLeft: { - - get: function () - { - return this._tintTL; - }, - - set: function (value) - { - this._tintTL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopRight: { - - get: function () - { - return this._tintTR; - }, - - set: function (value) - { - this._tintTR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomLeft: { - - get: function () - { - return this._tintBL; - }, - - set: function (value) - { - this._tintBL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomRight: { - - get: function () - { - return this._tintBR; - }, - - set: function (value) - { - this._tintBR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the whole of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tint - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tint: { - - set: function (value) - { - this.setTint(value, value, value, value); - } - } - -}; - -module.exports = Tint; - - -/***/ }), -/* 575 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// bitmask flag for GameObject.renderMask -var _FLAG = 8; // 1000 - -/** - * Provides methods used for getting and setting the texture of a Game Object. - * - * @name Phaser.GameObjects.Components.Texture - * @since 3.0.0 - */ - -var Texture = { - - /** - * The Texture this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#texture - * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} - * @since 3.0.0 - */ - texture: null, - - /** - * The Texture Frame this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#frame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - frame: null, - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * @method Phaser.GameObjects.Components.Texture#setTexture - * @since 3.0.0 - * - * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. - * - * @return {this} This Game Object instance. - */ - setTexture: function (key, frame) - { - this.texture = this.scene.sys.textures.get(key); - - return this.setFrame(frame); - }, - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * - * @method Phaser.GameObjects.Components.Texture#setFrame - * @since 3.0.0 - * - * @param {(string|integer)} frame - The name or index of the frame within the Texture. - * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? - * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? - * - * @return {this} This Game Object instance. - */ - setFrame: function (frame, updateSize, updateOrigin) - { - if (updateSize === undefined) { updateSize = true; } - if (updateOrigin === undefined) { updateOrigin = true; } - - this.frame = this.texture.get(frame); - - if (!this.frame.cutWidth || !this.frame.cutHeight) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - - if (this._sizeComponent && updateSize) - { - this.setSizeToFrame(); - } - - if (this._originComponent && updateOrigin) - { - if (this.frame.customPivot) - { - this.setOrigin(this.frame.pivotX, this.frame.pivotY); - } - else - { - this.updateDisplayOrigin(); - } - } - - return this; - } - -}; - -module.exports = Texture; - - -/***/ }), -/* 576 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the size of a Game Object. - * - * @name Phaser.GameObjects.Components.Size - * @since 3.0.0 - */ - -var Size = { - - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Size#_sizeComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _sizeComponent: true, - - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#width - * @type {number} - * @since 3.0.0 - */ - width: 0, - - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.frame.realWidth; - }, - - set: function (value) - { - this.scaleX = value / this.frame.realWidth; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.frame.realHeight; - }, - - set: function (value) - { - this.scaleY = value / this.frame.realHeight; - } - - }, - - /** - * Sets the size of this Game Object to be that of the given Frame. - * - * @method Phaser.GameObjects.Components.Size#setSizeToFrame - * @since 3.0.0 - * - * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. - * - * @return {this} This Game Object instance. - */ - setSizeToFrame: function (frame) - { - if (frame === undefined) { frame = this.frame; } - - this.width = frame.realWidth; - this.height = frame.realHeight; - - return this; - }, - - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Components.Size#setSize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setSize: function (width, height) - { - this.width = width; - this.height = height; - - return this; - }, - - /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Components.Size#setDisplaySize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setDisplaySize: function (width, height) - { - this.displayWidth = width; - this.displayHeight = height; - - return this; - } - -}; - -module.exports = Size; - - -/***/ }), -/* 577 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the Scroll Factor of a Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor - * @since 3.0.0 - */ - -var ScrollFactor = { - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorX: 1, - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorY: 1, - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor - * @since 3.0.0 - * - * @param {number} x - The horizontal scroll factor of this Game Object. - * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. - * - * @return {this} This Game Object instance. - */ - setScrollFactor: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollFactorX = x; - this.scrollFactorY = y; - - return this; - } - -}; - -module.exports = ScrollFactor; - - -/***/ }), -/* 578 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ScaleModes = __webpack_require__(59); - -/** - * Provides methods used for getting and setting the scale of a Game Object. - * - * @name Phaser.GameObjects.Components.ScaleMode - * @since 3.0.0 - */ - -var ScaleMode = { - - _scaleMode: ScaleModes.DEFAULT, - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @name Phaser.GameObjects.Components.ScaleMode#scaleMode - * @type {Phaser.ScaleModes} - * @since 3.0.0 - */ - scaleMode: { - - get: function () - { - return this._scaleMode; - }, - - set: function (value) - { - if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) - { - this._scaleMode = value; - } - } - - }, - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode - * @since 3.0.0 - * - * @param {Phaser.ScaleModes} value - The Scale Mode to be used by this Game Object. - * - * @return {this} This Game Object instance. - */ - setScaleMode: function (value) - { - this.scaleMode = value; - - return this; - } - -}; - -module.exports = ScaleMode; - - -/***/ }), -/* 579 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the origin of a Game Object. - * Values are normalized, given in the range 0 to 1. - * Display values contain the calculated pixel values. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Origin - * @since 3.0.0 - */ - -var Origin = { - - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Origin#_originComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _originComponent: true, - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originX - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originX: 0.5, - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originY - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originY: 0.5, - - // private + read only - _displayOriginX: 0, - _displayOriginY: 0, - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginX - * @type {float} - * @since 3.0.0 - */ - displayOriginX: { - - get: function () - { - return this._displayOriginX; - }, - - set: function (value) - { - this._displayOriginX = value; - this.originX = value / this.width; - } - - }, - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginY - * @type {float} - * @since 3.0.0 - */ - displayOriginY: { - - get: function () - { - return this._displayOriginY; - }, - - set: function (value) - { - this._displayOriginY = value; - this.originY = value / this.height; - } - - }, - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * - * @method Phaser.GameObjects.Components.Origin#setOrigin - * @since 3.0.0 - * - * @param {number} [x=0.5] - The horizontal origin value. - * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. - * - * @return {this} This Game Object instance. - */ - setOrigin: function (x, y) - { - if (x === undefined) { x = 0.5; } - if (y === undefined) { y = x; } - - this.originX = x; - this.originY = y; - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - * - * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - setOriginFromFrame: function () - { - if (!this.frame || !this.frame.customPivot) - { - return this.setOrigin(); - } - else - { - this.originX = this.frame.pivotX; - this.originY = this.frame.pivotY; - } - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * - * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin - * @since 3.0.0 - * - * @param {number} [x=0] - The horizontal display origin value. - * @param {number} [y=x] - The vertical display origin value. If not defined it will be set to the value of `x`. - * - * @return {this} This Game Object instance. - */ - setDisplayOrigin: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.displayOriginX = x; - this.displayOriginY = y; - - return this; - }, - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - * - * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - updateDisplayOrigin: function () - { - this._displayOriginX = Math.round(this.originX * this.width); - this._displayOriginY = Math.round(this.originY * this.height); - - return this; - } - -}; - -module.exports = Origin; - - -/***/ }), -/* 580 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the transform values of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.MatrixStack - * @since 3.2.0 - */ - -var MatrixStack = { - - /** - * The matrix stack. - * - * @name Phaser.GameObjects.Components.MatrixStack#matrixStack - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - matrixStack: null, - - /** - * The current matrix. - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrix - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - currentMatrix: null, - - /** - * The current index of the top of the matrix stack. - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex - * @type {integer} - * @private - * @since 3.2.0 - */ - currentMatrixIndex: 0, - - /** - * Initialize the matrix stack. - * - * @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - initMatrixStack: function () - { - this.matrixStack = new Float32Array(6000); // up to 1000 matrices - this.currentMatrix = new Float32Array([ 1, 0, 0, 1, 0, 0 ]); - this.currentMatrixIndex = 0; - - return this; - }, - - /** - * Push the current matrix onto the matrix stack. - * - * @method Phaser.GameObjects.Components.MatrixStack#save - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - save: function () - { - if (this.currentMatrixIndex >= this.matrixStack.length) { return this; } - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - this.currentMatrixIndex += 6; - - matrixStack[currentMatrixIndex + 0] = currentMatrix[0]; - matrixStack[currentMatrixIndex + 1] = currentMatrix[1]; - matrixStack[currentMatrixIndex + 2] = currentMatrix[2]; - matrixStack[currentMatrixIndex + 3] = currentMatrix[3]; - matrixStack[currentMatrixIndex + 4] = currentMatrix[4]; - matrixStack[currentMatrixIndex + 5] = currentMatrix[5]; - - return this; - }, - - /** - * Pop the top of the matrix stack into the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#restore - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - restore: function () - { - if (this.currentMatrixIndex <= 0) { return this; } - - this.currentMatrixIndex -= 6; - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - - currentMatrix[0] = matrixStack[currentMatrixIndex + 0]; - currentMatrix[1] = matrixStack[currentMatrixIndex + 1]; - currentMatrix[2] = matrixStack[currentMatrixIndex + 2]; - currentMatrix[3] = matrixStack[currentMatrixIndex + 3]; - currentMatrix[4] = matrixStack[currentMatrixIndex + 4]; - currentMatrix[5] = matrixStack[currentMatrixIndex + 5]; - - return this; - }, - - /** - * Resets the current matrix to the identity matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#loadIdentity - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - loadIdentity: function () - { - this.setTransform(1, 0, 0, 1, 0, 0); - - return this; - }, - - /** - * Transform the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#transform - * @since 3.2.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This Game Object instance. - */ - transform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[0] = m0 * a + m2 * b; - currentMatrix[1] = m1 * a + m3 * b; - currentMatrix[2] = m0 * c + m2 * d; - currentMatrix[3] = m1 * c + m3 * d; - currentMatrix[4] = m0 * tx + m2 * ty + m4; - currentMatrix[5] = m1 * tx + m3 * ty + m5; - - return this; - }, - - /** - * Set a transform matrix as the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#setTransform - * @since 3.2.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This Game Object instance. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - - currentMatrix[0] = a; - currentMatrix[1] = b; - currentMatrix[2] = c; - currentMatrix[3] = d; - currentMatrix[4] = tx; - currentMatrix[5] = ty; - - return this; - }, - - /** - * Translate the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#translate - * @since 3.2.0 - * - * @param {number} x - The horizontal translation value. - * @param {number} y - The vertical translation value. - * - * @return {this} This Game Object instance. - */ - translate: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[4] = m0 * x + m2 * y + m4; - currentMatrix[5] = m1 * x + m3 * y + m5; - - return this; - }, - - /** - * Scale the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#scale - * @since 3.2.0 - * - * @param {number} x - The horizontal scale value. - * @param {number} y - The vertical scale value. - * - * @return {this} This Game Object instance. - */ - scale: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - - currentMatrix[0] = m0 * x; - currentMatrix[1] = m1 * x; - currentMatrix[2] = m2 * y; - currentMatrix[3] = m3 * y; - - return this; - }, - - /** - * Rotate the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#rotate - * @since 3.2.0 - * - * @param {number} t - The angle of rotation, in radians. - * - * @return {this} This Game Object instance. - */ - rotate: function (t) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var st = Math.sin(t); - var ct = Math.cos(t); - - currentMatrix[0] = m0 * ct + m2 * st; - currentMatrix[1] = m1 * ct + m3 * st; - currentMatrix[2] = m0 * -st + m2 * ct; - currentMatrix[3] = m1 * -st + m3 * ct; - - return this; - } - -}; - -module.exports = MatrixStack; - - -/***/ }), -/* 581 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapMask = __webpack_require__(214); -var GeometryMask = __webpack_require__(213); - -/** - * Provides methods used for getting and setting the mask of a Game Object. - * - * @name Phaser.GameObjects.Components.Mask - * @since 3.0.0 - */ - -var Mask = { - - /** - * The Mask this Game Object is using during render. - * - * @name Phaser.GameObjects.Components.Mask#mask - * @type {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} - * @since 3.0.0 - */ - mask: null, - - /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * @method Phaser.GameObjects.Components.Mask#setMask - * @since 3.6.2 - * - * @param {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} mask - The mask this Game Object will use when rendering. - * - * @return {this} This Game Object instance. - */ - setMask: function (mask) - { - this.mask = mask; - - return this; - }, - - /** - * Clears the mask that this Game Object was using. - * - * @method Phaser.GameObjects.Components.Mask#clearMask - * @since 3.6.2 - * - * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? - * - * @return {this} This Game Object instance. - */ - clearMask: function (destroyMask) - { - if (destroyMask === undefined) { destroyMask = false; } - - if (destroyMask) - { - this.mask.destroy(); - } - - this.mask = null; - - return this; - }, - - /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * - * @method Phaser.GameObjects.Components.Mask#createBitmapMask - * @since 3.6.2 - * - * @param {Phaser.GameObjects.GameObject} [renderable] - A renderable Game Object that uses a texture, such as a Sprite. - * - * @return {Phaser.Display.Masks.BitmapMask} This Bitmap Mask that was created. - */ - createBitmapMask: function (renderable) - { - if (renderable === undefined && this.texture) - { - // eslint-disable-next-line consistent-this - renderable = this; - } - - return new BitmapMask(this.scene, renderable); - }, - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * - * @method Phaser.GameObjects.Components.Mask#createGeometryMask - * @since 3.6.2 - * - * @param {Phaser.GameObjects.Graphics} [graphics] - A Graphics Game Object. The geometry within it will be used as the mask. - * - * @return {Phaser.Display.Masks.GeometryMask} This Geometry Mask that was created. - */ - createGeometryMask: function (graphics) - { - if (graphics === undefined && this.type === 'Graphics') - { - // eslint-disable-next-line consistent-this - graphics = this; - } - - return new GeometryMask(this.scene, graphics); - } - -}; - -module.exports = Mask; - - -/***/ }), -/* 582 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); -var RotateAround = __webpack_require__(292); -var Vector2 = __webpack_require__(6); - -/** - * Provides methods used for obtaining the bounds of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.GetBounds - * @since 3.0.0 - */ - -var GetBounds = { - - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getCenter - * @since 3.0.0 - * - * @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. - * - * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. - */ - getCenter: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); - output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); - - return output; - }, - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getTopLeft - * @since 3.0.0 - * - * @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, includeParent) - { - 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); - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getTopRight - * @since 3.0.0 - * - * @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, includeParent) - { - 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); - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft - * @since 3.0.0 - * - * @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, includeParent) - { - 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; - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomRight - * @since 3.0.0 - * - * @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, includeParent) - { - 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; - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the bounds of this Game Object, regardless of origin. - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * - * @method Phaser.GameObjects.Components.GetBounds#getBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [output,$return] - * - * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. - * - * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. - */ - getBounds: function (output) - { - if (output === undefined) { output = new Rectangle(); } - - // We can use the output object to temporarily store the x/y coords in: - - var TLx, TLy, TRx, TRy, BLx, BLy, BRx, BRy; - - // Instead of doing a check if parent container is - // defined per corner we only do it once. - if (this.parentContainer) - { - var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); - - this.getTopLeft(output); - parentMatrix.transformPoint(output.x, output.y, output); - - TLx = output.x; - TLy = output.y; - - this.getTopRight(output); - parentMatrix.transformPoint(output.x, output.y, output); - - TRx = output.x; - TRy = output.y; - - this.getBottomLeft(output); - parentMatrix.transformPoint(output.x, output.y, output); - - BLx = output.x; - BLy = output.y; - - this.getBottomRight(output); - parentMatrix.transformPoint(output.x, output.y, output); - - BRx = output.x; - BRy = output.y; - } - else - { - this.getTopLeft(output); - - TLx = output.x; - TLy = output.y; - - this.getTopRight(output); - - TRx = output.x; - TRy = output.y; - - this.getBottomLeft(output); - - BLx = output.x; - BLy = output.y; - - this.getBottomRight(output); - - BRx = output.x; - BRy = output.y; - } - - output.x = Math.min(TLx, TRx, BLx, BRx); - output.y = Math.min(TLy, TRy, BLy, BRy); - output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; - output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; - - return output; - } - -}; - -module.exports = GetBounds; - - -/***/ }), -/* 583 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for visually flipping a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Flip - * @since 3.0.0 - */ - -var Flip = { - - /** - * The horizontally flipped state of the Game Object. - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipX: false, - - /** - * The vertically flipped state of the Game Object. - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipY: false, - - /** - * Toggles the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipX - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - toggleFlipX: function () - { - this.flipX = !this.flipX; - - return this; - }, - - /** - * Toggles the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipY - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - toggleFlipY: function () - { - this.flipY = !this.flipY; - - return this; - }, - - /** - * Sets the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipX - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {this} This Game Object instance. - */ - setFlipX: function (value) - { - this.flipX = value; - - return this; - }, - - /** - * Sets the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipY - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {this} This Game Object instance. - */ - setFlipY: function (value) - { - this.flipY = value; - - return this; - }, - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlip - * @since 3.0.0 - * - * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {this} This Game Object instance. - */ - setFlip: function (x, y) - { - this.flipX = x; - this.flipY = y; - - return this; - }, - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - * - * @method Phaser.GameObjects.Components.Flip#resetFlip - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - resetFlip: function () - { - this.flipX = false; - this.flipY = false; - - return this; - } - -}; - -module.exports = Flip; - - -/***/ }), -/* 584 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for setting the depth of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Depth - * @since 3.0.0 - */ - -var Depth = { - - /** - * Private internal value. Holds the depth of the Game Object. - * - * @name Phaser.GameObjects.Components.Depth#_depth - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - _depth: 0, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @name Phaser.GameObjects.Components.Depth#depth - * @type {number} - * @since 3.0.0 - */ - depth: { - - get: function () - { - return this._depth; - }, - - set: function (value) - { - this.scene.sys.queueDepthSort(); - this._depth = value; - } - - }, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @method Phaser.GameObjects.Components.Depth#setDepth - * @since 3.0.0 - * - * @param {integer} value - The depth of this Game Object. - * - * @return {this} This Game Object instance. - */ - setDepth: function (value) - { - if (value === undefined) { value = 0; } - - this.depth = value; - - return this; - } - -}; - -module.exports = Depth; - - -/***/ }), -/* 585 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for calculating and setting the size of a non-Frame based Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.ComputedSize - * @since 3.0.0 - */ - -var ComputedSize = { - - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#width - * @type {number} - * @since 3.0.0 - */ - width: 0, - - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.width; - }, - - set: function (value) - { - this.scaleX = value / this.width; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.height; - }, - - set: function (value) - { - this.scaleY = value / this.height; - } - - }, - - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Components.ComputedSize#setSize - * @since 3.4.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setSize: function (width, height) - { - this.width = width; - this.height = height; - - return this; - }, - - /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize - * @since 3.4.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setDisplaySize: function (width, height) - { - this.displayWidth = width; - this.displayHeight = height; - - return this; - } - -}; - -module.exports = ComputedSize; - - -/***/ }), -/* 586 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlendModes = __webpack_require__(51); - -/** - * Provides methods used for setting the blend mode of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.BlendMode - * @since 3.0.0 - */ - -var BlendMode = { - - /** - * Private internal value. Holds the current blend mode. - * - * @name Phaser.GameObjects.Components.BlendMode#_blendMode - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - _blendMode: BlendModes.NORMAL, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @name Phaser.GameObjects.Components.BlendMode#blendMode - * @type {(Phaser.BlendModes|string)} - * @since 3.0.0 - */ - blendMode: { - - get: function () - { - return this._blendMode; - }, - - set: function (value) - { - if (typeof value === 'string') - { - value = BlendModes[value]; - } - - value |= 0; - - if (value >= 0) - { - this._blendMode = value; - } - } - - }, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @method Phaser.GameObjects.Components.BlendMode#setBlendMode - * @since 3.0.0 - * - * @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST. - * - * @return {this} This Game Object instance. - */ - setBlendMode: function (value) - { - this.blendMode = value; - - return this; - } - -}; - -module.exports = BlendMode; - - -/***/ }), -/* 587 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); - -// bitmask flag for GameObject.renderMask -var _FLAG = 2; // 0010 - -/** - * Provides methods used for setting the alpha properties of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Alpha - * @since 3.0.0 - */ - -var Alpha = { - - /** - * Private internal value. Holds the global alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alpha - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alpha: 1, - - /** - * Private internal value. Holds the top-left alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaTL - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaTL: 1, - - /** - * Private internal value. Holds the top-right alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaTR - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaTR: 1, - - /** - * Private internal value. Holds the bottom-left alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaBL - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaBL: 1, - - /** - * Private internal value. Holds the bottom-right alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaBR - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaBR: 1, - - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - * - * @method Phaser.GameObjects.Components.Alpha#clearAlpha - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - clearAlpha: function () - { - return this.setAlpha(1); - }, - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * - * @method Phaser.GameObjects.Components.Alpha#setAlpha - * @since 3.0.0 - * - * @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. - * @param {float} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. - * @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. - * - * @return {this} This Game Object instance. - */ - setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 1; } - - // Treat as if there is only one alpha value for the whole Game Object - if (topRight === undefined) - { - this.alpha = topLeft; - } - else - { - this._alphaTL = Clamp(topLeft, 0, 1); - this._alphaTR = Clamp(topRight, 0, 1); - this._alphaBL = Clamp(bottomLeft, 0, 1); - this._alphaBR = Clamp(bottomRight, 0, 1); - } - - return this; - }, - - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - * - * @name Phaser.GameObjects.Components.Alpha#alpha - * @type {float} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this._alpha; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alpha = v; - this._alphaTL = v; - this._alphaTR = v; - this._alphaBL = v; - this._alphaBR = v; - - if (v === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopLeft: { - - get: function () - { - return this._alphaTL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopRight: { - - get: function () - { - return this._alphaTR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomLeft: { - - get: function () - { - return this._alphaBL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomRight: { - - get: function () - { - return this._alphaBR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - } - -}; - -module.exports = Alpha; - - -/***/ }), -/* 588 */, -/* 589 */, -/* 590 */, -/* 591 */, -/* 592 */, -/* 593 */, -/* 594 */, -/* 595 */, -/* 596 */, -/* 597 */, -/* 598 */, -/* 599 */, -/* 600 */ -/***/ (function(module, exports) { - -/** -* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 -* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ -* Cameron Foale (http://www.kibibu.com) -*/ -if (typeof window.Uint32Array !== 'function' && typeof window.Uint32Array !== 'object') -{ - var CheapArray = function (fakeType) - { - var proto = new Array(); // jshint ignore:line - - window[fakeType] = function(arg) { - - if (typeof(arg) === 'number') - { - Array.call(this, arg); - - this.length = arg; - - for (var i = 0; i < this.length; i++) - { - this[i] = 0; - } - } - else - { - Array.call(this, arg.length); - - this.length = arg.length; - - for (var i = 0; i < this.length; i++) - { - this[i] = arg[i]; - } - } - }; - - window[fakeType].prototype = proto; - window[fakeType].constructor = window[fakeType]; - }; - - CheapArray('Float32Array'); // jshint ignore:line - CheapArray('Uint32Array'); // jshint ignore:line - CheapArray('Uint16Array'); // jshint ignore:line - CheapArray('Int16Array'); // jshint ignore:line - CheapArray('ArrayBuffer'); // jshint ignore:line -} - - -/***/ }), -/* 601 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global) {// References: -// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ -// https://gist.github.com/1579671 -// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision -// https://gist.github.com/timhall/4078614 -// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame - -// Expected to be used with Browserfiy -// Browserify automatically detects the use of `global` and passes the -// correct reference of `global`, `self`, and finally `window` - -// Date.now -if (!(Date.now && Date.prototype.getTime)) { - Date.now = function now() { - return new Date().getTime(); - }; -} - -// performance.now -if (!(global.performance && global.performance.now)) { - var startTime = Date.now(); - if (!global.performance) { - global.performance = {}; - } - global.performance.now = function () { - return Date.now() - startTime; - }; -} - -// requestAnimationFrame -var lastTime = Date.now(); -var vendors = ['ms', 'moz', 'webkit', 'o']; - -for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { - global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; - global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || - global[vendors[x] + 'CancelRequestAnimationFrame']; -} - -if (!global.requestAnimationFrame) { - global.requestAnimationFrame = function (callback) { - if (typeof callback !== 'function') { - throw new TypeError(callback + 'is not a function'); - } - - var currentTime = Date.now(), - delay = 16 + lastTime - currentTime; - - if (delay < 0) { - delay = 0; - } - - lastTime = currentTime; - - return setTimeout(function () { - lastTime = Date.now(); - callback(performance.now()); - }, delay); - }; -} - -if (!global.cancelAnimationFrame) { - global.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; -} - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(215))) - -/***/ }), -/* 602 */ -/***/ (function(module, exports) { - -/** - * performance.now - */ -(function () { - - if ('performance' in window === false) - { - window.performance = {}; - } - - // Thanks IE8 - Date.now = (Date.now || function () { - return new Date().getTime(); - }); - - if ('now' in window.performance === false) - { - var nowOffset = Date.now(); - - if (performance.timing && performance.timing.navigationStart) - { - nowOffset = performance.timing.navigationStart; - } - - window.performance.now = function now () - { - return Date.now() - nowOffset; - } - } - -})(); - - -/***/ }), -/* 603 */ -/***/ (function(module, exports) { - -// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc -if (!Math.trunc) { - Math.trunc = function trunc(x) { - return x < 0 ? Math.ceil(x) : Math.floor(x); - }; -} - - -/***/ }), -/* 604 */ -/***/ (function(module, exports) { - -/** -* A polyfill for Function.prototype.bind -*/ -if (!Function.prototype.bind) { - - /* jshint freeze: false */ - Function.prototype.bind = (function () { - - var slice = Array.prototype.slice; - - return function (thisArg) { - - var target = this, boundArgs = slice.call(arguments, 1); - - if (typeof target !== 'function') - { - throw new TypeError(); - } - - function bound() { - var args = boundArgs.concat(slice.call(arguments)); - target.apply(this instanceof bound ? this : thisArg, args); - } - - bound.prototype = (function F(proto) { - if (proto) - { - F.prototype = proto; - } - - if (!(this instanceof F)) - { - /* jshint supernew: true */ - return new F; - } - })(target.prototype); - - return bound; - }; - })(); -} - - - -/***/ }), -/* 605 */ -/***/ (function(module, exports) { - -/** - * Also fix for the absent console in IE9 - */ -if (!window.console) -{ - window.console = {}; - window.console.log = window.console.assert = function(){}; - window.console.warn = window.console.assert = function(){}; -} - - -/***/ }), -/* 606 */ -/***/ (function(module, exports) { - -/* Copyright 2013 Chris Wilson - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - -This monkeypatch library is intended to be included in projects that are -written to the proper AudioContext spec (instead of webkitAudioContext), -and that use the new naming and proper bits of the Web Audio API (e.g. -using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may -have to run on systems that only support the deprecated bits. - -This library should be harmless to include if the browser supports -unprefixed "AudioContext", and/or if it supports the new names. - -The patches this library handles: -if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). -if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or -noteGrainOn(), depending on parameters. - -The following aliases only take effect if the new names are not already in place: - -AudioBufferSourceNode.stop() is aliased to noteOff() -AudioContext.createGain() is aliased to createGainNode() -AudioContext.createDelay() is aliased to createDelayNode() -AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() -AudioContext.createPeriodicWave() is aliased to createWaveTable() -OscillatorNode.start() is aliased to noteOn() -OscillatorNode.stop() is aliased to noteOff() -OscillatorNode.setPeriodicWave() is aliased to setWaveTable() -AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() - -This library does NOT patch the enumerated type changes, as it is -recommended in the specification that implementations support both integer -and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel -BiquadFilterNode.type and OscillatorNode.type. - -*/ - -(function () { - - function fixSetTarget(param) { - if (!param) // if NYI, just return - return; - if (!param.setTargetAtTime) - param.setTargetAtTime = param.setTargetValueAtTime; - } - - if (window.hasOwnProperty('webkitAudioContext') && - !window.hasOwnProperty('AudioContext')) { - window.AudioContext = webkitAudioContext; - - if (!AudioContext.prototype.hasOwnProperty('createGain')) - AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; - if (!AudioContext.prototype.hasOwnProperty('createDelay')) - AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; - if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) - AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; - if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) - AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; - - - AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; - AudioContext.prototype.createGain = function() { - var node = this.internal_createGain(); - fixSetTarget(node.gain); - return node; - }; - - AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; - AudioContext.prototype.createDelay = function(maxDelayTime) { - var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); - fixSetTarget(node.delayTime); - return node; - }; - - AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; - AudioContext.prototype.createBufferSource = function() { - var node = this.internal_createBufferSource(); - if (!node.start) { - node.start = function ( when, offset, duration ) { - if ( offset || duration ) - this.noteGrainOn( when || 0, offset, duration ); - else - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function( when, offset, duration ) { - if( typeof duration !== 'undefined' ) - node.internal_start( when || 0, offset, duration ); - else - node.internal_start( when || 0, offset || 0 ); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - fixSetTarget(node.playbackRate); - return node; - }; - - AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; - AudioContext.prototype.createDynamicsCompressor = function() { - var node = this.internal_createDynamicsCompressor(); - fixSetTarget(node.threshold); - fixSetTarget(node.knee); - fixSetTarget(node.ratio); - fixSetTarget(node.reduction); - fixSetTarget(node.attack); - fixSetTarget(node.release); - return node; - }; - - AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; - AudioContext.prototype.createBiquadFilter = function() { - var node = this.internal_createBiquadFilter(); - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - fixSetTarget(node.Q); - fixSetTarget(node.gain); - return node; - }; - - if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { - AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; - AudioContext.prototype.createOscillator = function() { - var node = this.internal_createOscillator(); - if (!node.start) { - node.start = function ( when ) { - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function ( when ) { - node.internal_start( when || 0); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - if (!node.setPeriodicWave) - node.setPeriodicWave = node.setWaveTable; - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - return node; - }; - } - } - - if (window.hasOwnProperty('webkitOfflineAudioContext') && - !window.hasOwnProperty('OfflineAudioContext')) { - window.OfflineAudioContext = webkitOfflineAudioContext; - } - -})(); - - -/***/ }), -/* 607 */ -/***/ (function(module, exports) { - -/** -* A polyfill for Array.isArray -*/ -if (!Array.isArray) -{ - Array.isArray = function (arg) - { - return Object.prototype.toString.call(arg) === '[object Array]'; - }; -} - - -/***/ }), -/* 608 */ -/***/ (function(module, exports) { - -/** -* A polyfill for Array.forEach -* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach -*/ -if (!Array.prototype.forEach) -{ - Array.prototype.forEach = function (fun /*, thisArg */) - { - 'use strict'; - - if (this === void 0 || this === null) - { - throw new TypeError(); - } - - var t = Object(this); - var len = t.length >>> 0; - - if (typeof fun !== 'function') - { - throw new TypeError(); - } - - var thisArg = arguments.length >= 2 ? arguments[1] : void 0; - - for (var i = 0; i < len; i++) - { - if (i in t) - { - fun.call(thisArg, t[i], i, t); - } - } - }; -} - - -/***/ }), -/* 609 */ -/***/ (function(module, exports, __webpack_require__) { - -__webpack_require__(608); -__webpack_require__(607); -__webpack_require__(606); -__webpack_require__(605); -__webpack_require__(604); -__webpack_require__(603); -__webpack_require__(602); -__webpack_require__(601); -__webpack_require__(600); - - -/***/ }), -/* 610 */, -/* 611 */, -/* 612 */, -/* 613 */, -/* 614 */, -/* 615 */, -/* 616 */, -/* 617 */, -/* 618 */, -/* 619 */, -/* 620 */, -/* 621 */, -/* 622 */, -/* 623 */, -/* 624 */, -/* 625 */, -/* 626 */, -/* 627 */, -/* 628 */, -/* 629 */, -/* 630 */, -/* 631 */, -/* 632 */, -/* 633 */, -/* 634 */, -/* 635 */, -/* 636 */, -/* 637 */, -/* 638 */, -/* 639 */, -/* 640 */, -/* 641 */, -/* 642 */, -/* 643 */, -/* 644 */, -/* 645 */, -/* 646 */, -/* 647 */, -/* 648 */, -/* 649 */, -/* 650 */, -/* 651 */, -/* 652 */, -/* 653 */, -/* 654 */, -/* 655 */, -/* 656 */, -/* 657 */, -/* 658 */, -/* 659 */, -/* 660 */, -/* 661 */, -/* 662 */, -/* 663 */, -/* 664 */, -/* 665 */, -/* 666 */, -/* 667 */, -/* 668 */, -/* 669 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Renderer.WebGL.Pipelines - */ - -module.exports = { - - BitmapMaskPipeline: __webpack_require__(260), - FlatTintPipeline: __webpack_require__(259), - ForwardDiffuseLightPipeline: __webpack_require__(148), - TextureTintPipeline: __webpack_require__(129) - -}; - - -/***/ }), -/* 670 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Renderer.WebGL - */ - -module.exports = { - - Utils: __webpack_require__(27), - WebGLPipeline: __webpack_require__(84), - WebGLRenderer: __webpack_require__(262), - Pipelines: __webpack_require__(669), - - // Constants - BYTE: 0, - SHORT: 1, - UNSIGNED_BYTE: 2, - UNSIGNED_SHORT: 3, - FLOAT: 4 - -}; - - -/***/ }), -/* 671 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @callback SnapshotCallback - * - * @param {HTMLImageElement} snapshot - [description] - */ - -/** - * @namespace Phaser.Renderer.Snapshot - */ - -module.exports = { - - Canvas: __webpack_require__(265), - WebGL: __webpack_require__(261) - -}; - - -/***/ }), -/* 672 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Renderer.Canvas - */ - -module.exports = { - - BlitImage: __webpack_require__(266), - CanvasRenderer: __webpack_require__(267), - DrawImage: __webpack_require__(264), - GetBlendModes: __webpack_require__(263) - -}; - - -/***/ }), -/* 673 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} RendererConfig - * - * @property {boolean} clearBeforeRender - [description] - * @property {boolean} pixelArt - [description] - * @property {Phaser.Display.Color} backgroundColor - [description] - * @property {number} resolution - [description] - * @property {boolean} autoResize - [description] - * @property {boolean} roundPixels - [description] - */ - -/** - * @namespace Phaser.Renderer - */ - -module.exports = { - - Canvas: __webpack_require__(672), - Snapshot: __webpack_require__(671), - WebGL: __webpack_require__(670) - -}; - - -/***/ }), -/* 674 */, -/* 675 */, -/* 676 */, -/* 677 */, -/* 678 */, -/* 679 */, -/* 680 */, -/* 681 */, -/* 682 */, -/* 683 */, -/* 684 */, -/* 685 */, -/* 686 */, -/* 687 */, -/* 688 */, -/* 689 */, -/* 690 */, -/* 691 */, -/* 692 */, -/* 693 */, -/* 694 */, -/* 695 */, -/* 696 */, -/* 697 */, -/* 698 */, -/* 699 */, -/* 700 */, -/* 701 */, -/* 702 */, -/* 703 */, -/* 704 */, -/* 705 */, -/* 706 */, -/* 707 */, -/* 708 */, -/* 709 */, -/* 710 */, -/* 711 */, -/* 712 */, -/* 713 */, -/* 714 */, -/* 715 */, -/* 716 */, -/* 717 */, -/* 718 */, -/* 719 */, -/* 720 */, -/* 721 */, -/* 722 */, -/* 723 */, -/* 724 */, -/* 725 */, -/* 726 */, -/* 727 */, -/* 728 */, -/* 729 */, -/* 730 */, -/* 731 */, -/* 732 */, -/* 733 */, -/* 734 */, -/* 735 */, -/* 736 */, -/* 737 */, -/* 738 */, -/* 739 */, -/* 740 */, -/* 741 */, -/* 742 */, -/* 743 */, -/* 744 */, -/* 745 */, -/* 746 */, -/* 747 */, -/* 748 */, -/* 749 */, -/* 750 */, -/* 751 */, -/* 752 */, -/* 753 */, -/* 754 */, -/* 755 */, -/* 756 */, -/* 757 */, -/* 758 */, -/* 759 */, -/* 760 */, -/* 761 */, -/* 762 */, -/* 763 */, -/* 764 */, -/* 765 */, -/* 766 */, -/* 767 */, -/* 768 */, -/* 769 */, -/* 770 */, -/* 771 */, -/* 772 */, -/* 773 */, -/* 774 */, -/* 775 */, -/* 776 */, -/* 777 */, -/* 778 */, -/* 779 */, -/* 780 */, -/* 781 */, -/* 782 */, -/* 783 */, -/* 784 */, -/* 785 */, -/* 786 */, -/* 787 */, -/* 788 */, -/* 789 */, -/* 790 */, -/* 791 */, -/* 792 */, -/* 793 */, -/* 794 */, -/* 795 */, -/* 796 */, -/* 797 */, -/* 798 */, -/* 799 */, -/* 800 */, -/* 801 */, -/* 802 */, -/* 803 */, -/* 804 */, -/* 805 */, -/* 806 */, -/* 807 */, -/* 808 */, -/* 809 */, -/* 810 */, -/* 811 */, -/* 812 */, -/* 813 */, -/* 814 */, -/* 815 */, -/* 816 */, -/* 817 */, -/* 818 */, -/* 819 */, -/* 820 */, -/* 821 */, -/* 822 */, -/* 823 */, -/* 824 */, -/* 825 */, -/* 826 */, -/* 827 */, -/* 828 */, -/* 829 */, -/* 830 */, -/* 831 */, -/* 832 */, -/* 833 */, -/* 834 */, -/* 835 */, -/* 836 */, -/* 837 */, -/* 838 */, -/* 839 */, -/* 840 */, -/* 841 */, -/* 842 */, -/* 843 */, -/* 844 */, -/* 845 */, -/* 846 */, -/* 847 */, -/* 848 */, -/* 849 */, -/* 850 */, -/* 851 */, -/* 852 */, -/* 853 */, -/* 854 */, -/* 855 */, -/* 856 */, -/* 857 */, -/* 858 */, -/* 859 */, -/* 860 */, -/* 861 */, -/* 862 */, -/* 863 */, -/* 864 */, -/* 865 */, -/* 866 */, -/* 867 */, -/* 868 */, -/* 869 */, -/* 870 */, -/* 871 */, -/* 872 */, -/* 873 */, -/* 874 */, -/* 875 */, -/* 876 */, -/* 877 */, -/* 878 */, -/* 879 */, -/* 880 */, -/* 881 */, -/* 882 */, -/* 883 */, -/* 884 */, -/* 885 */, -/* 886 */, -/* 887 */, -/* 888 */, -/* 889 */, -/* 890 */, -/* 891 */, -/* 892 */, -/* 893 */, -/* 894 */, -/* 895 */, -/* 896 */, -/* 897 */, -/* 898 */, -/* 899 */, -/* 900 */, -/* 901 */, -/* 902 */, -/* 903 */, -/* 904 */, -/* 905 */, -/* 906 */, -/* 907 */, -/* 908 */, -/* 909 */, -/* 910 */, -/* 911 */, -/* 912 */, -/* 913 */, -/* 914 */, -/* 915 */, -/* 916 */, -/* 917 */, -/* 918 */, -/* 919 */, -/* 920 */, -/* 921 */, -/* 922 */, -/* 923 */, -/* 924 */, -/* 925 */, -/* 926 */, -/* 927 */, -/* 928 */, -/* 929 */, -/* 930 */, -/* 931 */, -/* 932 */, -/* 933 */, -/* 934 */, -/* 935 */, -/* 936 */, -/* 937 */, -/* 938 */, -/* 939 */, -/* 940 */, -/* 941 */, -/* 942 */, -/* 943 */, -/* 944 */, -/* 945 */, -/* 946 */, -/* 947 */, -/* 948 */, -/* 949 */, -/* 950 */, -/* 951 */, -/* 952 */, -/* 953 */, -/* 954 */, -/* 955 */, -/* 956 */, -/* 957 */, -/* 958 */, -/* 959 */, -/* 960 */, -/* 961 */, -/* 962 */, -/* 963 */, -/* 964 */, -/* 965 */, -/* 966 */, -/* 967 */, -/* 968 */, -/* 969 */, -/* 970 */, -/* 971 */, -/* 972 */, -/* 973 */, -/* 974 */, -/* 975 */, -/* 976 */, -/* 977 */, -/* 978 */, -/* 979 */, -/* 980 */, -/* 981 */, -/* 982 */, -/* 983 */, -/* 984 */, -/* 985 */, -/* 986 */, -/* 987 */, -/* 988 */, -/* 989 */, -/* 990 */, -/* 991 */, -/* 992 */, -/* 993 */, -/* 994 */, -/* 995 */, -/* 996 */, -/* 997 */, -/* 998 */, -/* 999 */, -/* 1000 */, -/* 1001 */, -/* 1002 */, -/* 1003 */, -/* 1004 */, -/* 1005 */, -/* 1006 */, -/* 1007 */, -/* 1008 */, -/* 1009 */, -/* 1010 */, -/* 1011 */, -/* 1012 */, -/* 1013 */, -/* 1014 */, -/* 1015 */, -/* 1016 */, -/* 1017 */, -/* 1018 */, -/* 1019 */, -/* 1020 */, -/* 1021 */, -/* 1022 */, -/* 1023 */, -/* 1024 */, -/* 1025 */, -/* 1026 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global) {/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -__webpack_require__(609); - -var CONST = __webpack_require__(20); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser - */ - -var Phaser = { - - Animation: __webpack_require__(568), - Cache: __webpack_require__(567), - Cameras: { Scene2D: __webpack_require__(566) }, - Class: __webpack_require__(0), - Data: __webpack_require__(544), - Display: { Masks: __webpack_require__(538) }, - Events: __webpack_require__(536), - Game: __webpack_require__(534), - GameObjects: { - DisplayList: __webpack_require__(504), - GameObjectCreator: __webpack_require__(13), - GameObjectFactory: __webpack_require__(11), - UpdateList: __webpack_require__(476), - Components: __webpack_require__(15), - BuildGameObject: __webpack_require__(24), - BuildGameObjectAnimation: __webpack_require__(127), - GameObject: __webpack_require__(2), - Graphics: __webpack_require__(115), - Image: __webpack_require__(69), - Sprite: __webpack_require__(34), - Text: __webpack_require__(110), - Factories: { - Graphics: __webpack_require__(410), - Image: __webpack_require__(409), - Sprite: __webpack_require__(408), - Text: __webpack_require__(407) - }, - Creators: { - Graphics: __webpack_require__(406), - Image: __webpack_require__(405), - Sprite: __webpack_require__(404), - Text: __webpack_require__(403) - } - }, - Input: __webpack_require__(383), - Loader: { - FileTypes: { - AnimationJSONFile: __webpack_require__(360), - AtlasJSONFile: __webpack_require__(359), - AudioFile: __webpack_require__(168), - AudioSpriteFile: __webpack_require__(358), - HTML5AudioFile: __webpack_require__(167), - ImageFile: __webpack_require__(37), - JSONFile: __webpack_require__(28), - MultiAtlasFile: __webpack_require__(357), - PluginFile: __webpack_require__(356), - ScriptFile: __webpack_require__(355), - SpriteSheetFile: __webpack_require__(354), - TextFile: __webpack_require__(224), - XMLFile: __webpack_require__(143) - }, - File: __webpack_require__(19), - FileTypesManager: __webpack_require__(7), - GetURL: __webpack_require__(108), - LoaderPlugin: __webpack_require__(353), - MergeXHRSettings: __webpack_require__(107), - MultiFile: __webpack_require__(36), - XHRLoader: __webpack_require__(169), - XHRSettings: __webpack_require__(75) - }, - Math: { - Between: __webpack_require__(149), - DegToRad: __webpack_require__(38), - FloatBetween: __webpack_require__(248), - RadToDeg: __webpack_require__(150), - Vector2: __webpack_require__(6) - }, - Plugins: __webpack_require__(330), - Renderer: __webpack_require__(673), - Scene: __webpack_require__(193), - Scenes: __webpack_require__(328), - Sound: __webpack_require__(326), - Structs: __webpack_require__(325), - Textures: __webpack_require__(324), - Time: __webpack_require__(308), - Tweens: __webpack_require__(306) -}; - -// 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 - */ - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(215))) - -/***/ }) -/******/ ]); -}); \ No newline at end of file diff --git a/dist/phaser-core.min.js b/dist/phaser-core.min.js deleted file mode 100644 index e12af2e85..000000000 --- a/dist/phaser-core.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}(window,function(){return function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:s})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1026)}([function(t,e){function i(t,e,i){var s=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&s.value&&"object"==typeof s.value&&(s=s.value),!(!s||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(s))&&(void 0===s.enumerable&&(s.enumerable=!0),void 0===s.configurable&&(s.configurable=!0),s)}function s(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function n(t,e,n,r){for(var o in e)if(e.hasOwnProperty(o)){var h=i(e,o,n);if(!1!==h){if(s((r||t).prototype,o)){if(a.ignoreFinals)continue;throw new Error("cannot override final property '"+o+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,o,h)}else t.prototype[o]=e[o]}}function r(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,s=this.y;return this.x=i+e*(t.x-i),this.y=s+e*(t.y-s),this},transformMat3:function(t){var e=this.x,i=this.y,s=t.val;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this},transformMat4:function(t){var e=this.x,i=this.y,s=t.val;return this.x=s[0]*e+s[4]*i+s[12],this.y=s[1]*e+s[5]*i+s[13],this},reset:function(){return this.x=0,this.y=0,this}});s.ZERO=new s,t.exports=s},function(t,e){var i={},s={install:function(t){for(var e in i)t[e]=i[e]},register:function(t,e){i[t]=e},destroy:function(){i={}}};t.exports=s},function(t,e){t.exports=function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0}},function(t,e,i){"use strict";var s=Object.prototype.hasOwnProperty,n="~";function r(){}function a(t,e,i,s,r){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new function(t,e,i){this.fn=t,this.context=e,this.once=i||!1}(i,s||t,r),o=n?n+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],a]:t._events[o].push(a):(t._events[o]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function h(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),h.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)s.call(t,e)&&i.push(n?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},h.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,r=i.length,a=new Array(r);s=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=u},function(t,e,i){t.exports={Alpha:i(587),Animation:i(302),BlendMode:i(586),ComputedSize:i(585),Depth:i(584),Flip:i(583),GetBounds:i(582),Mask:i(581),MatrixStack:i(580),Origin:i(579),Pipeline:i(291),ScaleMode:i(578),ScrollFactor:i(577),Size:i(576),Texture:i(575),Tint:i(574),ToJSON:i(573),Transform:i(572),TransformMatrix:i(64),Visible:i(571)}},function(t,e,i){var s=i(297),n={PI2:2*Math.PI,TAU:.5*Math.PI,EPSILON:1e-6,DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,RND:new s};t.exports=n},function(t,e,i){var s=i(8),n=function(){var t,e,i,r,a,o,h=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof h&&(c=h,h=arguments[1]||{},u=2),l===u&&(h=this,--u);u=400&&t.status<=599&&(i=!1),this.resetXHR(),this.loader.nextFile(this,i)},onError:function(){this.resetXHR(),this.loader.nextFile(this,!1)},onProgress:function(t){t.lengthComputable&&(this.bytesLoaded=t.loaded,this.bytesTotal=t.total,this.percentComplete=Math.min(this.bytesLoaded/this.bytesTotal,1),this.loader.emit("fileprogress",this,this.percentComplete))},onProcess:function(){this.state=n.FILE_PROCESSING,this.onProcessComplete()},onProcessComplete:function(){this.state=n.FILE_COMPLETE,this.multiFile&&this.multiFile.onFileComplete(this),this.loader.fileProcessComplete(this)},onProcessError:function(){this.state=n.FILE_ERRORED,this.multiFile&&this.multiFile.onFileFailed(this),this.loader.fileProcessComplete(this)},hasCacheConflict:function(){return this.cache&&this.cache.exists(this.key)},addToCache:function(){this.cache&&this.cache.add(this.key,this.data),this.pendingDestroy()},pendingDestroy:function(t){void 0===t&&(t=this.data);var e=this.key,i=this.type;this.loader.emit("filecomplete",e,i,t),this.loader.emit("filecomplete_"+i+"_"+e,e,i,t),this.loader.flagForRemoval(this)},destroy:function(){this.loader=null,this.cache=null,this.xhrSettings=null,this.multiFile=null,this.linkFile=null,this.data=null}});l.createObjectURL=function(t,e,i){if("function"==typeof URL)t.src=URL.createObjectURL(e);else{var s=new FileReader;s.onload=function(){t.removeAttribute("crossOrigin"),t.src="data:"+(e.type||i)+";base64,"+s.result.split(",")[1]},s.onerror=t.onerror,s.readAsDataURL(e)}},l.revokeObjectURL=function(t){"function"==typeof URL&&URL.revokeObjectURL(t.src)},t.exports=l},function(t,e,i){var s={VERSION:"3.10.1",BlendModes:i(51),ScaleModes:i(59),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=s},,function(t,e,i){var s,n,r,a=i(20),o=i(131),h=[],u=!1;t.exports={create2D:function(t,e,i){return s(t,e,i,a.CANVAS)},create:s=function(t,e,i,s,r){var l;void 0===e&&(e=1),void 0===i&&(i=1),void 0===s&&(s=a.CANVAS),void 0===r&&(r=!1);var c=n(s);return null===c?(c={parent:t,canvas:document.createElement("canvas"),type:s},s===a.CANVAS&&h.push(c),l=c.canvas):(c.parent=t,l=c.canvas),r&&(c.parent=l),l.width=e,l.height=i,u&&s===a.CANVAS&&o.disable(l.getContext("2d")),l},createWebGL:function(t,e,i){return s(t,e,i,a.WEBGL)},disableSmoothing:function(){u=!0},enableSmoothing:function(){u=!1},first:n=function(t){if(void 0===t&&(t=a.CANVAS),t===a.WEBGL)return null;for(var e=0;e>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,s=0;sn||e>=i||i>n||e+i>n){if(s)throw new Error("Range Error: Values outside acceptable range");return!1}return!0}},function(t,e,i){var s=i(0),n=i(152),r=i(284),a=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=255),this.r=0,this.g=0,this.b=0,this.a=255,this.gl=[0,0,0,1],this._color=0,this._color32=0,this._rgba="",this.setTo(t,e,i,s)},transparent:function(){return this.red=0,this.green=0,this.blue=0,this.alpha=0,this.update()},setTo:function(t,e,i,s){return void 0===s&&(s=255),this.red=t,this.green=e,this.blue=i,this.alpha=s,this.update()},setGLTo:function(t,e,i,s){return void 0===s&&(s=1),this.redGL=t,this.greenGL=e,this.blueGL=i,this.alphaGL=s,this.update()},setFromRGB:function(t){return this.red=t.r,this.green=t.g,this.blue=t.b,t.hasOwnProperty("a")&&(this.alpha=t.a),this.update()},update:function(){return this._color=n(this.r,this.g,this.b),this._color32=r(this.r,this.g,this.b,this.a),this._rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/255+")",this},clone:function(){return new a(this.r,this.g,this.b,this.a)},color:{get:function(){return this._color}},color32:{get:function(){return this._color32}},rgba:{get:function(){return this._rgba}},redGL:{get:function(){return this.gl[0]},set:function(t){this.gl[0]=Math.min(Math.abs(t),1),this.r=Math.floor(255*this.gl[0]),this.update()}},greenGL:{get:function(){return this.gl[1]},set:function(t){this.gl[1]=Math.min(Math.abs(t),1),this.g=Math.floor(255*this.gl[1]),this.update()}},blueGL:{get:function(){return this.gl[2]},set:function(t){this.gl[2]=Math.min(Math.abs(t),1),this.b=Math.floor(255*this.gl[2]),this.update()}},alphaGL:{get:function(){return this.gl[3]},set:function(t){this.gl[3]=Math.min(Math.abs(t),1),this.a=Math.floor(255*this.gl[3]),this.update()}},red:{get:function(){return this.r},set:function(t){t=Math.floor(Math.abs(t)),this.r=Math.min(t,255),this.gl[0]=t/255,this.update()}},green:{get:function(){return this.g},set:function(t){t=Math.floor(Math.abs(t)),this.g=Math.min(t,255),this.gl[1]=t/255,this.update()}},blue:{get:function(){return this.b},set:function(t){t=Math.floor(Math.abs(t)),this.b=Math.min(t,255),this.gl[2]=t/255,this.update()}},alpha:{get:function(){return this.a},set:function(t){t=Math.floor(Math.abs(t)),this.a=Math.min(t,255),this.gl[3]=t/255,this.update()}}});t.exports=a},function(t,e){t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i}},function(t,e){t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e,i){var s=i(0),n=i(15),r=i(2),a=i(556),o=new s({Extends:r,Mixins:[n.Alpha,n.BlendMode,n.Depth,n.Flip,n.GetBounds,n.Mask,n.Origin,n.Pipeline,n.ScaleMode,n.ScrollFactor,n.Size,n.Texture,n.Tint,n.Transform,n.Visible,a],initialize:function(t,e,i,s,a){r.call(this,t,"Sprite"),this.anims=new n.Animation(this),this.setTexture(s,a),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline")},preUpdate:function(t,e){this.anims.update(t,e)},play:function(t,e,i){return this.anims.play(t,e,i),this},toJSON:function(){return n.ToJSON(this)}});t.exports=o},,function(t,e,i){var s=new(i(0))({initialize:function(t,e,i,s){this.loader=t,this.type=e,this.key=i,this.files=s,this.complete=!1,this.pending=s.length,this.failed=0,this.config={};for(var n=0;n=t.length)){for(var i=t.length-1,s=t[e],n=e;n=0&&v>=0&&m+v<1}},function(t,e){t.exports={CREATED:0,INIT:1,DELAY:2,OFFSET_DELAY:3,PENDING_RENDER:4,PLAYING_FORWARD:5,PLAYING_BACKWARD:6,HOLD_DELAY:7,REPEAT_DELAY:8,COMPLETE:9,PENDING_ADD:20,PAUSED:21,LOOP_DELAY:22,ACTIVE:23,COMPLETE_DELAY:24,PENDING_REMOVE:25,REMOVED:26}},function(t,e){t.exports=function(t,e,i){return t&&t.hasOwnProperty(e)?t[e]:i}},function(t,e,i){var s=i(453);t.exports=function(t,e){if("string"==typeof t&&s.hasOwnProperty(t)){if(e){var i=e.slice(0);return i.unshift(0),function(e){return i[0]=e,s[t].apply(this,i)}}return s[t]}return"function"==typeof t?t:(Array.isArray(t)&&t.length,s.Power0)}},function(t,e,i){var s=new(i(0))({initialize:function(t,e,i,s,n,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=1),void 0===n&&(n=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,s,n,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0}},a:{get:function(){return this.matrix[0]},set:function(t){this.matrix[0]=t}},b:{get:function(){return this.matrix[1]},set:function(t){this.matrix[1]=t}},c:{get:function(){return this.matrix[2]},set:function(t){this.matrix[2]=t}},d:{get:function(){return this.matrix[3]},set:function(t){this.matrix[3]=t}},tx:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},ty:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},rotation:{get:function(){return Math.acos(this.a/this.scaleX)*(Math.atan(-this.c/this.a)<0?-1:1)}},scaleX:{get:function(){return Math.sqrt(this.a*this.a+this.c*this.c)}},scaleY:{get:function(){return Math.sqrt(this.b*this.b+this.d*this.d)}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),s=this.matrix,n=s[0],r=s[1],a=s[2],o=s[3];return s[0]=n*i+a*e,s[1]=r*i+o*e,s[2]=n*-e+a*i,s[3]=r*-e+o*i,this},multiply:function(t){var e=this.matrix,i=t.matrix,s=e[0],n=e[1],r=e[2],a=e[3],o=e[4],h=e[5],u=i[0],l=i[1],c=i[2],d=i[3],f=i[4],p=i[5];return e[0]=u*s+l*r,e[1]=u*n+l*a,e[2]=c*s+d*r,e[3]=c*n+d*a,e[4]=f*s+p*r+o,e[5]=f*n+p*a+h,this},transform:function(t,e,i,s,n,r){var a=this.matrix,o=a[0],h=a[1],u=a[2],l=a[3],c=a[4],d=a[5];return a[0]=t*o+e*u,a[1]=t*h+e*l,a[2]=i*o+s*u,a[3]=i*h+s*l,a[4]=n*o+r*u+c,a[5]=n*h+r*l+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var s=this.matrix,n=s[0],r=s[1],a=s[2],o=s[3],h=s[4],u=s[5];return i.x=t*n+e*a+h,i.y=t*r+e*o+u,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],s=t[2],n=t[3],r=t[4],a=t[5],o=e*n-i*s;return t[0]=n/o,t[1]=-i/o,t[2]=-s/o,t[3]=e/o,t[4]=(s*a-n*r)/o,t[5]=-(e*a-i*r)/o,this},setTransform:function(t,e,i,s,n,r){var a=this.matrix;return a[0]=t,a[1]=e,a[2]=i,a[3]=s,a[4]=n,a[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],s=e[1],n=e[2],r=e[3],a=i*i,o=s*s,h=n*n,u=r*r,l=Math.sqrt(a+h),c=Math.sqrt(o+u);return t.translateX=e[4],t.translateY=e[5],t.scaleX=l,t.scaleY=c,t.rotation=Math.acos(i/l)*(Math.atan(-n/i)<0?-1:1),t},applyITRS:function(t,e,i,s,n){var r=this.matrix,a=Math.sin(i),o=Math.cos(i);return r[4]=t,r[5]=e,r[0]=o*s,r[1]=a*s,r[2]=-a*n,r[3]=o*n,this},destroy:function(){this.matrix=null,this.decomposedMatrix=null}});t.exports=s},function(t,e,i){var s=i(23);t.exports=function(t,e,i){return(i-e)*(t=s(t,0,1))}},,,function(t,e,i){var s=i(0),n=i(60),r=i(227),a=i(226),o=i(96),h=i(153),u=new s({initialize:function(t,e,i,s,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=s,this.x3=n,this.y3=r},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return a(this,t,e,i)},getRandomPoint:function(t){return h(this,t)},setTo:function(t,e,i,s,n,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=s,this.x3=n,this.y3=r,this},getLineA:function(t){return void 0===t&&(t=new o),t.setTo(this.x1,this.y1,this.x2,this.y2),t},getLineB:function(t){return void 0===t&&(t=new o),t.setTo(this.x2,this.y2,this.x3,this.y3),t},getLineC:function(t){return void 0===t&&(t=new o),t.setTo(this.x3,this.y3,this.x1,this.y1),t},left:{get:function(){return Math.min(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1<=this.x2&&this.x1<=this.x3?this.x1-t:this.x2<=this.x1&&this.x2<=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},right:{get:function(){return Math.max(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1>=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=u},function(t,e,i){var s=i(0),n=i(15),r=i(2),a=i(461),o=new s({Extends:r,Mixins:[n.Alpha,n.BlendMode,n.Depth,n.Flip,n.GetBounds,n.Mask,n.Origin,n.Pipeline,n.ScaleMode,n.ScrollFactor,n.Size,n.Texture,n.Tint,n.Transform,n.Visible,a],initialize:function(t,e,i,s,n){r.call(this,t,"Image"),this.setTexture(s,n),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline")}});t.exports=o},function(t,e,i){var s=new(i(0))({initialize:function(t){if(this.entries=[],Array.isArray(t))for(var e=0;e-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new s;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new s;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new s;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return this.entries.length=t}}});t.exports=s},function(t,e){t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},function(t,e,i){var s=i(100),n=i(10),r=i(62),a=i(63),o=i(73),h=i(163),u=i(102),l=i(4),c=i(101),d=i(99),f=i(98);t.exports=function(t,e,i){void 0===i&&(i=s);for(var p=i.targets?i.targets:u(e),g=h(e),m=o(e,"delay",i.delay),v=o(e,"duration",i.duration),y=l(e,"easeParams",i.easeParams),x=a(l(e,"ease",i.ease),y),w=o(e,"hold",i.hold),T=o(e,"repeat",i.repeat),S=o(e,"repeatDelay",i.repeatDelay),b=r(e,"yoyo",i.yoyo),A=r(e,"flipX",i.flipX),E=r(e,"flipY",i.flipY),_=[],C=0;C=0;i--){var s=this.sounds[i];s.key===t&&(s.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:a,onBlur:a,onFocus:a,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(s,n){s.pendingRemove||t.call(e||i,s,n,i.sounds)})},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("detune",this,t)}}});t.exports=o},function(t,e,i){var s,n=i(57),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(s=navigator.userAgent,/Edge\/\d+/.test(s)?r.edge=!0:/Chrome\/(\d+)/.test(s)&&!n.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(s)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(s)&&n.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(s)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(s)?r.opera=!0:/Safari/.test(s)&&!n.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(s)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(s)&&(r.silk=!0),r)},function(t,e,i){var s=new(i(0))({initialize:function(t,e){this.parent=t,this.events=e,e||(this.events=t.events?t.events:t),this.list={},this.values={},this._frozen=!1,!t.hasOwnProperty("sys")&&this.events&&this.events.once("destroy",this.destroy,this)},get:function(t){var e=this.list;if(Array.isArray(t)){for(var i=[],s=0;su&&(r=u),a>u&&(a=u),o=n,h=r;;)if(o=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,s=this.program,n=this.renderer,r=this.vertexSize;n.setProgram(s),n.setVertexBuffer(e);for(var a=0;a=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,o.size,o.type,o.normalized,r,o.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,s=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*s)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,s){return this.renderer.setFloat3(this.program,t,e,i,s),this},setFloat4:function(t,e,i,s,n){return this.renderer.setFloat4(this.program,t,e,i,s,n),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,s){return this.renderer.setInt3(this.program,t,e,i,s),this},setInt4:function(t,e,i,s,n){return this.renderer.setInt4(this.program,t,e,i,s,n),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e){t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},,,function(t,e,i){var s=i(0),n=i(32),r=i(298),a=i(296),o=i(157),h=new s({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return a(this,t,e,i)},getRandomPoint:function(t){return o(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=h},,,,,function(t,e,i){var s=i(147),n=i(0),r=i(3),a=i(83),o=new n({initialize:function(t){this.parent=t,this.list=[],this.position=0,this.addCallback=r,this.removeCallback=r,this._sortKey=""},add:function(t,e){return e?s.Add(this.list,t):s.Add(this.list,t,0,this.addCallback,this)},addAt:function(t,e,i){return i?s.AddAt(this.list,t,e):s.AddAt(this.list,t,e,0,this.addCallback,this)},getAt:function(t){return this.list[t]},getIndex:function(t){return this.list.indexOf(t)},sort:function(t){return t&&(this._sortKey=t,a.inplace(this.list,this.sortHandler)),this},sortHandler:function(t,e){return t[this._sortKey]-e[this._sortKey]},getByName:function(t){return s.GetFirst(this.list,"name",t)},getRandom:function(t,e){return s.GetRandom(this.list,t,e)},getFirst:function(t,e,i,n){return s.GetFirstElement(this.list,t,e,i,n)},getAll:function(t,e,i,n){return s.GetAll(this.list,t,e,i,n)},count:function(t,e){return s.CountAllMatching(this.list,t,e)},swap:function(t,e){s.Swap(this.list,t,e)},moveTo:function(t,e){return s.MoveTo(this.list,t,e)},remove:function(t,e){return e?s.Remove(this.list,t):s.Remove(this.list,t,this.removeCallback,this)},removeAt:function(t,e){return e?s.RemoveAt(this.list,t):s.RemoveAt(this.list,t,this.removeCallback,this)},removeBetween:function(t,e,i){return i?s.RemoveBetween(this.list,t,e):s.RemoveBetween(this.list,t,e,this.removeCallback,this)},removeAll:function(t){for(var e=this.list.length;e--;)this.remove(this.list[e],t);return this},bringToTop:function(t){return s.BringToTop(this.list,t)},sendToBack:function(t){return s.SendToBack(this.list,t)},moveUp:function(t){return s.MoveUp(this.list,t),t},moveDown:function(t){return s.MoveDown(this.list,t),t},reverse:function(){return this.list.reverse(),this},shuffle:function(){return s.Shuffle(this.list),this},replace:function(t,e){return s.Replace(this.list,t,e)},exists:function(t){return this.list.indexOf(t)>-1},setAll:function(t,e,i,n){return s.SetAll(this.list,t,e,i,n),this},each:function(t,e){for(var i=[null],s=2;s0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=o},function(t,e,i){var s=i(33);t.exports=function(t,e){var i=s(t);for(var n in e)i.hasOwnProperty(n)||(i[n]=e[n]);return i}},function(t,e){t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),s=t[e];t[e]=t[i],t[i]=s}return t}},function(t,e,i){var s=i(0),n=i(293),r=i(156),a=i(155),o=i(6),h=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.x1=t,this.y1=e,this.x2=i,this.y2=s},getPoint:function(t,e){return n(this,t,e)},getPoints:function(t,e,i){return r(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i,s){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.x1=t,this.y1=e,this.x2=i,this.y2=s,this},getPointA:function(t){return void 0===t&&(t=new o),t.set(this.x1,this.y1),t},getPointB:function(t){return void 0===t&&(t=new o),t.set(this.x2,this.y2),t},left:{get:function(){return Math.min(this.x1,this.x2)},set:function(t){this.x1<=this.x2?this.x1=t:this.x2=t}},right:{get:function(){return Math.max(this.x1,this.x2)},set:function(t){this.x1>this.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=h},function(t,e){t.exports=function(t){return 2*(t.width+t.height)}},function(t,e){t.exports=function(t,e,i,s,n,r,a,o,h,u,l,c,d){return{target:t,key:e,getEndValue:i,getStartValue:s,ease:n,duration:0,totalDuration:0,delay:0,yoyo:o,hold:0,repeat:0,repeatDelay:0,flipX:c,flipY:d,progress:0,elapsed:0,repeatCounter:0,start:0,current:0,end:0,t1:0,t2:0,gen:{delay:r,duration:a,hold:h,repeat:u,repeatDelay:l},state:0}}},function(t,e,i){var s=i(0),n=i(13),r=i(11),a=i(61),o=new s({initialize:function(t,e,i){this.parent=t,this.parentIsTimeline=t.hasOwnProperty("isTimeline"),this.data=e,this.totalData=e.length,this.targets=i,this.totalTargets=i.length,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.offset=0,this.calculatedOffset=0,this.state=a.PENDING_ADD,this._pausedState=a.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onRepeat:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},getValue:function(){return this.data[0].current},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===a.ACTIVE},isPaused:function(){return this.state===a.PAUSED},hasTarget:function(t){return-1!==this.targets.indexOf(t)},updateTo:function(t,e,i){for(var s=0;s0&&(s.totalDuration+=s.t2*s.repeat),s.totalDuration>t&&(t=s.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=a.LOOP_DELAY):this.state=a.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=a.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=a.PENDING_REMOVE}},pause:function(){if(this.state!==a.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=a.PAUSED,this},play:function(t){if(this.state!==a.ACTIVE){this.state!==a.PENDING_REMOVE&&this.state!==a.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=a.ACTIVE):(this.countdown=this.calculatedOffset,this.state=a.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=a.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(s.elapsed=s.delay,s.state=a.DELAY):s.state=a.PENDING_RENDER}},resume:function(){return this.state===a.PAUSED?(this.paused=!1,this.state=this._pausedState):this.play(),this},seek:function(t){for(var e=this.data,i=0;i=n.totalDuration?(r=1,a=n.duration):s>n.delay&&s<=n.t1?(r=(s=Math.max(0,s-n.delay))/n.t1,a=n.duration*r):s>n.t1&&sn.repeatDelay&&(r=s/n.t1,a=n.duration*r)),n.progress=r,n.elapsed=a;var o=n.ease(n.progress);n.current=n.start+(n.end-n.start)*o,n.target[n.key]=n.current}},setCallback:function(t,e,i,s){return this.callbacks[t]={func:e,scope:s,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=a.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=a.PENDING_REMOVE}},stop:function(t){this.state===a.ACTIVE&&void 0!==t&&this.seek(t),this.state!==a.REMOVED&&(this.state=a.PENDING_REMOVE)},update:function(t,e){if(this.state===a.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case a.ACTIVE:for(var i=!1,s=0;s0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,a.REPEAT_DELAY):a.PLAYING_FORWARD}return a.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,a.REPEAT_DELAY):a.PLAYING_FORWARD}return a.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case a.PLAYING_FORWARD:case a.PLAYING_BACKWARD:if(!e.target){e.state=a.COMPLETE;break}var s=e.elapsed,n=e.duration,r=0;(s+=i)>n&&(r=s-n,s=n);var o,h=e.state===a.PLAYING_FORWARD,u=s/n;o=h?e.ease(u):e.ease(1-u),e.current=e.start+(e.end-e.start)*o,e.target[e.key]=e.current,e.elapsed=s,e.progress=u;var l=t.callbacks.onUpdate;l&&(l.params[1]=e.target,l.func.apply(l.scope,l.params)),1===u&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=a.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case a.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=a.PENDING_RENDER);break;case a.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=a.PLAYING_FORWARD);break;case a.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case a.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=a.PLAYING_FORWARD):e.state=a.COMPLETE}return e.state!==a.COMPLETE}});o.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),n.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=o},function(t,e){t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1}},function(t,e){function i(t){return!!t.getStart&&"function"==typeof t.getStart}function s(t){return!!t.getEnd&&"function"==typeof t.getEnd}var n=function(t,e){var r,a,o=function(t,e,i){return i},h=function(t,e,i){return i},u=typeof e;if("number"===u)o=function(){return e};else if("string"===u){var l=e[0],c=parseFloat(e.substr(2));switch(l){case"+":o=function(t,e,i){return i+c};break;case"-":o=function(t,e,i){return i-c};break;case"*":o=function(t,e,i){return i*c};break;case"/":o=function(t,e,i){return i/c};break;default:o=function(){return parseFloat(e)}}}else"function"===u?o=e:"object"===u&&(i(a=e)||s(a))?(s(e)&&(o=e.getEnd),i(e)&&(h=e.getStart)):e.hasOwnProperty("value")&&(r=n(t,e.value));return r||(r={getEnd:o,getStart:h}),r};t.exports=n},function(t,e,i){var s=i(4);t.exports=function(t){var e=s(t,"targets",null);return null===e?e:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},,,,,function(t,e,i){var s=i(17),n=i(75);t.exports=function(t,e){var i=void 0===t?n():s({},t);if(e)for(var r in e)void 0!==e[r]&&(i[r]=e[r]);return i}},function(t,e){t.exports=function(t,e){return!!t.url&&(t.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?t.url:e+t.url)}},function(t,e){t.exports={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:42,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,NUMPAD_ZERO:96,NUMPAD_ONE:97,NUMPAD_TWO:98,NUMPAD_THREE:99,NUMPAD_FOUR:100,NUMPAD_FIVE:101,NUMPAD_SIX:102,NUMPAD_SEVEN:103,NUMPAD_EIGHT:104,NUMPAD_NINE:105,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,SEMICOLON:186,PLUS:187,COMMA:188,MINUS:189,PERIOD:190,FORWARD_SLASH:191,BACK_SLASH:220,QUOTES:222,BACKTICK:192,OPEN_BRACKET:219,CLOSED_BRACKET:221}},function(t,e,i){var s=i(130),n=i(22),r=i(0),a=i(15),o=i(20),h=i(2),u=i(417),l=i(4),c=i(269),d=i(416),f=i(413),p=new r({Extends:h,Mixins:[a.Alpha,a.BlendMode,a.ComputedSize,a.Depth,a.Flip,a.GetBounds,a.Mask,a.Origin,a.Pipeline,a.ScaleMode,a.ScrollFactor,a.Tint,a.Transform,a.Visible,d],initialize:function(t,e,i,s,r){void 0===e&&(e=0),void 0===i&&(i=0),h.call(this,t,"Text"),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this.canvas=n.create(this),this.context=this.canvas.getContext("2d"),this.style=new f(this,r),this.autoRound=!0,this.splitRegExp=/(?:\r\n|\r|\n)/,this.text="",this.resolution=1,this.padding={left:0,right:0,top:0,bottom:0},this.width=1,this.height=1,this.canvasTexture=null,this.dirty=!1,this.initRTL(),r&&r.padding&&this.setPadding(r.padding),r&&r.lineSpacing&&(this._lineSpacing=r.lineSpacing),this.setText(s),t.sys.game.config.renderType===o.WEBGL&&t.sys.game.renderer.onContextRestored(function(){this.canvasTexture=null,this.dirty=!0},this)},initRTL:function(){this.style.rtl&&(this.canvas.dir="rtl",this.context.direction="rtl",this.canvas.style.display="none",s(this.canvas,this.scene.sys.canvas),this.originX=1)},runWordWrap:function(t){var e=this.style;if(e.wordWrapCallback){var i=e.wordWrapCallback.call(e.wordWrapCallbackScope,t,this);return Array.isArray(i)&&(i=i.join("\n")),i}return e.wordWrapWidth?e.wordWrapUseAdvanced?this.advancedWordWrap(t,this.context,this.style.wordWrapWidth):this.basicWordWrap(t,this.context,this.style.wordWrapWidth):t},advancedWordWrap:function(t,e,i){for(var s="",n=t.replace(/ +/gi," ").split(this.splitRegExp),r=n.length,a=0;au){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=u)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var m=d.substr(g.length);l[c]=m,h+=g}var v=l[c].length?c:c+1,y=l.slice(v).join(" ").replace(/[ \n]*$/gi,"");n[a+1]=y+" "+(n[a+1]||""),r=n.length;break}h+=f,u-=p}s+=h.replace(/[ \n]*$/gi,"")+"\n"}}return s=s.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var s="",n=t.split(this.splitRegExp),r=0;ra?(h>0&&(s+="\n"),s+=o[h]+" ",a=i-u):(a-=l,s+=o[h],h0&&(o+=l.lineSpacing*p),i.rtl?a=d-a:"right"===i.align?a+=l.width-l.lineWidths[p]:"center"===i.align&&(a+=(l.width-l.lineWidths[p])/2),this.autoRound&&(a=Math.round(a),o=Math.round(o)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],a,o)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],a,o));return e.restore(),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},toJSON:function(){var t=a.ToJSON(this),e={autoRound:this.autoRound,text:this.text,style:this.style.toJSON(),resolution:this.resolution,padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),n.remove(this.canvas)}});t.exports=p},,,function(t,e,i){var s=i(5);t.exports=function(t,e,i){void 0===i&&(i=new s);var n=t.width/2,r=t.height/2;return i.x=t.x+n*Math.cos(e),i.y=t.y+r*Math.sin(e),i}},function(t,e,i){var s=i(0),n=i(54),r=i(179),a=i(178),o=i(134),h=new s({initialize:function(t,e,i,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===s&&(s=0),this.x=t,this.y=e,this.width=i,this.height=s},contains:function(t,e){return n(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return a(this,t,e,i)},getRandomPoint:function(t){return o(this,t)},setTo:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},setEmpty:function(){return this.width=0,this.height=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},isEmpty:function(){return this.width<=0||this.height<=0},getMinorRadius:function(){return Math.min(this.width,this.height)/2},getMajorRadius:function(){return Math.max(this.width,this.height)/2},left:{get:function(){return this.x-this.width/2},set:function(t){this.x=t+this.width/2}},right:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},top:{get:function(){return this.y-this.height/2},set:function(t){this.y=t+this.height/2}},bottom:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=h},function(t,e,i){var s=i(123),n=i(0),r=i(119),a=i(15),o=i(249),h=i(2),u=i(4),l=i(16),c=i(463),d=new n({Extends:h,Mixins:[a.Alpha,a.BlendMode,a.Depth,a.Mask,a.Pipeline,a.Transform,a.Visible,a.ScrollFactor,c],initialize:function(t,e){var i=u(e,"x",0),s=u(e,"y",0);h.call(this,t,"Graphics"),this.setPosition(i,s),this.initPipeline("FlatTintPipeline"),this.displayOriginX=0,this.displayOriginY=0,this.commandBuffer=[],this.defaultFillColor=-1,this.defaultFillAlpha=1,this.defaultStrokeWidth=1,this.defaultStrokeColor=-1,this.defaultStrokeAlpha=1,this._lineWidth=1,this.setDefaultStyles(e)},setDefaultStyles:function(t){return u(t,"lineStyle",null)&&(this.defaultStrokeWidth=u(t,"lineStyle.width",1),this.defaultStrokeColor=u(t,"lineStyle.color",16777215),this.defaultStrokeAlpha=u(t,"lineStyle.alpha",1),this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha)),u(t,"fillStyle",null)&&(this.defaultFillColor=u(t,"fillStyle.color",16777215),this.defaultFillAlpha=u(t,"fillStyle.alpha",1),this.fillStyle(this.defaultFillColor,this.defaultFillAlpha)),this},lineStyle:function(t,e,i){return void 0===i&&(i=1),this.commandBuffer.push(r.LINE_STYLE,t,e,i),this._lineWidth=t,this},fillStyle:function(t,e){return void 0===e&&(e=1),this.commandBuffer.push(r.FILL_STYLE,t,e),this},beginPath:function(){return this.commandBuffer.push(r.BEGIN_PATH),this},closePath:function(){return this.commandBuffer.push(r.CLOSE_PATH),this},fillPath:function(){return this.commandBuffer.push(r.FILL_PATH),this},strokePath:function(){return this.commandBuffer.push(r.STROKE_PATH),this},fillCircleShape:function(t){return this.fillCircle(t.x,t.y,t.radius)},strokeCircleShape:function(t){return this.strokeCircle(t.x,t.y,t.radius)},fillCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,l.PI2),this.fillPath(),this},strokeCircle:function(t,e,i){return this.beginPath(),this.arc(t,e,i,0,l.PI2),this.strokePath(),this},fillRectShape:function(t){return this.fillRect(t.x,t.y,t.width,t.height)},strokeRectShape:function(t){return this.strokeRect(t.x,t.y,t.width,t.height)},fillRect:function(t,e,i,s){return this.commandBuffer.push(r.FILL_RECT,t,e,i,s),this},strokeRect:function(t,e,i,s){var n=this._lineWidth/2,r=t-n,a=t+n;return this.beginPath(),this.moveTo(t,e),this.lineTo(t,e+s),this.strokePath(),this.beginPath(),this.moveTo(t+i,e),this.lineTo(t+i,e+s),this.strokePath(),this.beginPath(),this.moveTo(r,e),this.lineTo(a+i,e),this.strokePath(),this.beginPath(),this.moveTo(r,e+s),this.lineTo(a+i,e+s),this.strokePath(),this},fillPointShape:function(t,e){return this.fillPoint(t.x,t.y,e)},fillPoint:function(t,e,i){return!i||i<1?i=1:(t-=i/2,e-=i/2),this.commandBuffer.push(r.FILL_RECT,t,e,i,i),this},fillTriangleShape:function(t){return this.fillTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},strokeTriangleShape:function(t){return this.strokeTriangle(t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)},fillTriangle:function(t,e,i,s,n,a){return this.commandBuffer.push(r.FILL_TRIANGLE,t,e,i,s,n,a),this},strokeTriangle:function(t,e,i,s,n,a){return this.commandBuffer.push(r.STROKE_TRIANGLE,t,e,i,s,n,a),this},strokeLineShape:function(t){return this.lineBetween(t.x1,t.y1,t.x2,t.y2)},lineBetween:function(t,e,i,s){return this.beginPath(),this.moveTo(t,e),this.lineTo(i,s),this.strokePath(),this},lineTo:function(t,e){return this.commandBuffer.push(r.LINE_TO,t,e),this},moveTo:function(t,e){return this.commandBuffer.push(r.MOVE_TO,t,e),this},lineFxTo:function(t,e,i,s){return this.commandBuffer.push(r.LINE_FX_TO,t,e,i,s,1),this},moveFxTo:function(t,e,i,s){return this.commandBuffer.push(r.MOVE_FX_TO,t,e,i,s,1),this},strokePoints:function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=t.length),this.beginPath(),this.moveTo(t[0].x,t[0].y);for(var s=1;s-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var s,n,r=this.scene.sys;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),d.TargetCamera.setViewport(0,0,e,i),d.TargetCamera.scrollX=this.x,d.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var a=(s=r.textures.get(t)).getSourceImage();a instanceof HTMLCanvasElement&&(n=a.getContext("2d"))}else n=(s=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(n=t.getContext("2d"));return n&&(this.renderCanvas(r.game.renderer,this,0,d.TargetCamera,null,n),r.game.renderer.gl&&s&&(s.source[0].glTexture=r.game.renderer.canvasToTexture(n.canvas,s.source[0].glTexture))),this},preDestroy:function(){this.commandBuffer=[]}});d.TargetCamera=new s(0,0,0,0),t.exports=d},function(t,e){t.exports=function(t){if(!Array.isArray(t)||t.length<2||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i0},isTransitionIn:function(){return this.settings.isTransition},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t){return t?this.resume():this.pause()},start:function(t){t&&(this.settings.data=t),this.settings.status=n.START,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this),this.events.emit("ready",this)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(){this.events.off("transitioninit"),this.events.off("transitionstart"),this.events.off("transitioncomplete"),this.events.off("transitionout"),this.settings.status=n.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this)},destroy:function(){this.settings.status=n.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this),this.events.removeAllListeners();for(var t=["scene","game","anims","cache","plugins","registry","sound","textures","add","camera","displayList","events","make","scenePlugin","updateList"],e=0;e-v&&S>-y&&T-v&&A>-y&&bc&&(this.scrollX=c),this.scrollYd&&(this.scrollY=d)}this.roundPixels&&(this.scrollX=Math.round(this.scrollX),this.scrollY=Math.round(this.scrollY)),r.loadIdentity(),r.scale(e,e),r.translate(this.x+a,this.y+o),r.rotate(this.rotation),r.scale(n,n),r.translate(-a,-o),this.shakeEffect.preRender()},removeBounds:function(){return this.useBounds=!1,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=r(t),this},setLerp:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.lerp.set(t,e),this},setFollowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.followOffset.set(t,e),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=c(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,s){return this._bounds.setTo(t,e,i,s),this.useBounds=!0,this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){return this.scene=t,this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this},setZoom:function(t){return void 0===t&&(t=1),this.zoom=t,this},setVisible:function(t){return this.visible=t,this},startFollow:function(t,e,i,n,r,a){void 0===e&&(e=!1),void 0===i&&(i=1),void 0===n&&(n=i),void 0===r&&(r=0),void 0===a&&(a=r),this._follow=t,this.roundPixels=e,i=s(i,0,1),n=s(n,0,1),this.lerp.set(i,n),this.followOffset.set(r,a);var o=this.zoom,h=this.width/2,u=this.height/2;return this.scrollX=(t.x-r-h)/o,this.scrollY=(t.y-a-u)/o,this},stopFollow:function(){return this._follow=null,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},resetFX:function(){return this.shakeEffect.reset(),this.flashEffect.reset(),this.fadeEffect.reset(),this},update:function(t,e){this.visible&&(this.shakeEffect.update(t,e),this.flashEffect.update(t,e),this.fadeEffect.update(t,e))},destroy:function(){this.emit("cameradestroy",this),this.removeAllListeners(),this.resetFX(),this.matrix.destroy(),this.culledObjects=[],this._follow=null,this._bounds=null,this.scene=null},centerX:{get:function(){return this.x+.5*this.width}},centerY:{get:function(){return this.y+.5*this.height}}});t.exports=f},function(t,e,i){var s=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e0?n.delayedPlay(d,r,a):n.load(r)}return t}},function(t,e,i){var s=i(0),n=i(17),r=new s({initialize:function(t,e,i,s,n,r,a){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.cutX,this.cutY,this.cutWidth,this.cutHeight,this.x=0,this.y=0,this.width,this.height,this.halfWidth,this.halfHeight,this.centerX,this.centerY,this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.data={cut:{x:0,y:0,w:0,h:0,r:0,b:0},trim:!1,sourceSize:{w:0,h:0},spriteSourceSize:{x:0,y:0,w:0,h:0},uvs:{x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},radius:0,drawImage:{sx:0,sy:0,sWidth:0,sHeight:0,dWidth:0,dHeight:0}},this.setSize(r,a,s,n)},setSize:function(t,e,i,s){void 0===i&&(i=0),void 0===s&&(s=0),this.cutX=i,this.cutY=s,this.cutWidth=t,this.cutHeight=e,this.width=t,this.height=e,this.halfWidth=Math.floor(.5*t),this.halfHeight=Math.floor(.5*e),this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2);var n=this.data,r=n.cut;r.x=i,r.y=s,r.w=t,r.h=e,r.r=i+t,r.b=s+e,n.sourceSize.w=t,n.sourceSize.h=e,n.spriteSourceSize.w=t,n.spriteSourceSize.h=e,n.radius=.5*Math.sqrt(t*t+e*e);var a=n.drawImage;return a.sx=i,a.sy=s,a.sWidth=t,a.sHeight=e,a.dWidth=t,a.dHeight=e,this.updateUVs()},setTrim:function(t,e,i,s,n,r){var a=this.data,o=a.spriteSourceSize;return a.trim=!0,a.sourceSize.w=t,a.sourceSize.h=e,o.x=i,o.y=s,o.w=n,o.h=r,this.x=i,this.y=s,this.width=n,this.height=r,this.halfWidth=.5*n,this.halfHeight=.5*r,this.centerX=Math.floor(n/2),this.centerY=Math.floor(r/2),this.updateUVs()},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,s=this.cutHeight,n=this.data.drawImage;n.sWidth=i,n.sHeight=s,n.dWidth=i,n.dHeight=s;var r=this.source.width,a=this.source.height,o=this.data.uvs;return o.x0=t/r,o.y0=e/a,o.x1=t/r,o.y1=(e+s)/a,o.x2=(t+i)/r,o.y2=(e+s)/a,o.x3=(t+i)/r,o.y3=e/a,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height,i=this.data.uvs;return i.x3=(this.cutX+this.cutHeight)/t,i.y3=(this.cutY+this.cutWidth)/e,i.x2=this.cutX/t,i.y2=(this.cutY+this.cutWidth)/e,i.x1=this.cutX/t,i.y1=this.cutY/e,i.x0=(this.cutX+this.cutHeight)/t,i.y0=this.cutY/e,this},clone:function(){var t=new r(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=n(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},uvs:{get:function(){return this.data.uvs}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=r},function(t,e,i){var s=i(0),n=i(202),r=i(526),a=i(525),o=i(27),h=i(84),u=new s({Extends:h,Mixins:[n],initialize:function(t){h.call(this,{game:t.game,renderer:t.renderer,gl:t.renderer.gl,topology:t.topology?t.topology:t.renderer.gl.TRIANGLES,vertShader:t.vertShader?t.vertShader:a,fragShader:t.fragShader?t.fragShader:r,vertexCapacity:t.vertexCapacity?t.vertexCapacity:12e3,vertexSize:t.vertexSize?t.vertexSize:2*Float32Array.BYTES_PER_ELEMENT+2*Float32Array.BYTES_PER_ELEMENT+4*Uint8Array.BYTES_PER_ELEMENT,attributes:[{name:"inPosition",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:0},{name:"inTexCoord",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:2*Float32Array.BYTES_PER_ELEMENT},{name:"inTint",size:4,type:t.renderer.gl.UNSIGNED_BYTE,normalized:!0,offset:4*Float32Array.BYTES_PER_ELEMENT}]}),this.vertexViewF32=new Float32Array(this.vertexData),this.vertexViewU32=new Uint32Array(this.vertexData),this.maxQuads=2e3,this.batches=[],this.mvpInit()},setTexture2D:function(t,e){if(!t)return this;var i=this.batches;0===i.length&&this.pushBatch();var s=i[i.length-1];return e>0?(s.textures[e-1]&&s.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==s.texture&&s.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,s=this.gl,n=this.renderer,r=this.vertexCount,a=this.topology,o=this.vertexSize,h=this.batches,u=0,l=null;if(0===h.length||0===r)return this.flushLocked=!1,this;s.bufferSubData(s.ARRAY_BUFFER,0,this.bytes.subarray(0,r*o));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(n.setTexture2D(l.texture,0),s.drawArrays(a,l.first,u)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},onBind:function(){return h.prototype.onBind.call(this),this.mvpUpdate(),0===this.batches.length&&this.pushBatch(),this},resize:function(t,e,i){return h.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},drawStaticTilemapLayer:function(t){if(t.vertexCount>0){var e=this.vertexBuffer,i=this.gl,s=this.renderer,n=t.tileset.image.get();s.currentPipeline&&s.currentPipeline.vertexCount>0&&s.flush(),this.vertexBuffer=t.vertexBuffer,s.setPipeline(this),s.setTexture2D(n.source.glTexture,0),i.drawArrays(this.topology,0,t.vertexCount),this.vertexBuffer=e}this.viewIdentity(),this.modelIdentity()},drawEmitterManager:function(t,e,i){var s=null;i&&(s=i.matrix),this.renderer.setPipeline(this);var n,r,a,o,h,u,l,c,d,f,p=this.renderer.config.roundPixels,g=t.emitters.list,m=g.length,v=this.vertexViewF32,y=this.vertexViewU32,x=this.renderer,w=this.maxQuads,T=e.scrollX,S=e.scrollY,b=e.matrix.matrix,A=b[0],E=b[1],_=b[2],C=b[3],M=b[4],P=b[5],k=Math.sin,L=Math.cos,R=this.vertexComponentCount,F=this.vertexCapacity,O=t.defaultFrame.source.glTexture;s&&(h=s[0],u=s[1],l=s[2],c=s[3],d=s[4],f=s[5]),this.setTexture2D(O,0);for(var D=0;D=F&&(this.flush(),this.setTexture2D(O,0));for(var H=0;H=F&&(this.flush(),this.setTexture2D(O,0))}}Y+=W,N-=W,this.vertexCount>=F&&(this.flush(),this.setTexture2D(O,0))}}}this.setTexture2D(O,0)},drawBlitter:function(t,e,i){var s=null;i&&(s=i.matrix),this.renderer.setPipeline(this);var n=this.renderer.config.roundPixels,r=o.getTintAppendFloatAlpha,a=this.vertexViewF32,h=this.vertexViewU32,u=t.getRenderList(),l=u.length,c=e.matrix.matrix,d=c[0],f=c[1],p=c[2],g=c[3],m=c[4],v=c[5],y=e.scrollX*t.scrollFactorX,x=e.scrollY*t.scrollFactorY,w=Math.ceil(l/this.maxQuads),T=0;if(s){var S=s[0],b=s[1],A=s[2],E=s[3],_=s[4],C=s[5],M=-y,P=-x,k=A*d+E*p,L=A*f+E*g,R=_*d+C*p+(M*d+P*p+m),F=_*f+C*g+(M*f+P*g+v);d=S*d+b*p,f=S*f+b*g,p=k,g=L,m=R,v=F,y=0,x=0}for(var O,D=t.x-y,I=t.y-x,B=0;B=this.vertexCapacity&&(this.flush(),O=-1)}}T+=N,l-=N,this.vertexCount>=this.vertexCapacity&&this.flush()}},batchSprite:function(t,e,i){var s=null;i&&(s=i.matrix),this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var n,r,a,h,u,l,c=this.renderer.config.roundPixels,d=o.getTintAppendFloatAlpha,f=this.vertexViewF32,p=this.vertexViewU32,g=e.matrix.matrix,m=t.frame,v=m.texture.source[m.sourceIndex].glTexture,y=!!v.isRenderTexture,x=t.flipX,w=t.flipY^y,T=m.uvs,S=m.width*(x?-1:1),b=m.height*(w?-1:1),A=-t.displayOriginX+m.x+m.width*(x?1:0),E=-t.displayOriginY+m.y+m.height*(w?1:0),_=(c?0|A:A)+S,C=(c?0|E:E)+b,M=t.scaleX,P=t.scaleY,k=t.rotation,L=t._alphaTL,R=t._alphaTR,F=t._alphaBL,O=t._alphaBR,D=t._tintTL,I=t._tintTR,B=t._tintBL,N=t._tintBR,U=Math.sin(k),Y=Math.cos(k),X=Y*M,z=U*M,G=-U*P,V=Y*P,H=t.x,W=t.y,j=g[0],q=g[1],K=g[2],J=g[3],Z=g[4],Q=g[5];if(s){var $=s[0],tt=s[1],et=s[2],it=s[3],st=s[4],nt=s[5],rt=-e.scrollX*t.scrollFactorX,at=-e.scrollY*t.scrollFactorY,ot=$*j+tt*K,ht=$*q+tt*J,ut=et*j+it*K,lt=et*q+it*J;n=X*ot+z*ut,r=X*ht+z*lt,a=G*ot+V*ut,h=G*ht+V*lt,u=H*ot+W*ut+(st*j+nt*K+(rt*j+at*K+Z)),l=H*ht+W*lt+(st*q+nt*J+(rt*q+at*J+Q))}else n=X*j+z*K,r=X*q+z*J,a=G*j+V*K,h=G*q+V*J,u=(H-=e.scrollX*t.scrollFactorX)*j+(W-=e.scrollY*t.scrollFactorY)*K+Z,l=H*q+W*J+Q;var ct,dt=A*n+E*a+u,ft=A*r+E*h+l,pt=A*n+C*a+u,gt=A*r+C*h+l,mt=_*n+C*a+u,vt=_*r+C*h+l,yt=_*n+E*a+u,xt=_*r+E*h+l,wt=d(D,L),Tt=d(I,R),St=d(B,F),bt=d(N,O);c&&(dt|=0,ft|=0,pt|=0,gt|=0,mt|=0,vt|=0,yt|=0,xt|=0),this.setTexture2D(v,0),f[(ct=this.vertexCount*this.vertexComponentCount)+0]=dt,f[ct+1]=ft,f[ct+2]=T.x0,f[ct+3]=T.y0,p[ct+4]=wt,f[ct+5]=pt,f[ct+6]=gt,f[ct+7]=T.x1,f[ct+8]=T.y1,p[ct+9]=St,f[ct+10]=mt,f[ct+11]=vt,f[ct+12]=T.x2,f[ct+13]=T.y2,p[ct+14]=bt,f[ct+15]=dt,f[ct+16]=ft,f[ct+17]=T.x0,f[ct+18]=T.y0,p[ct+19]=wt,f[ct+20]=mt,f[ct+21]=vt,f[ct+22]=T.x2,f[ct+23]=T.y2,p[ct+24]=bt,f[ct+25]=yt,f[ct+26]=xt,f[ct+27]=T.x3,f[ct+28]=T.y3,p[ct+29]=Tt,this.vertexCount+=6},batchMesh:function(t,e,i){var s=null;i&&(s=i.matrix);var n=t.vertices,r=n.length,a=r/2|0;this.renderer.setPipeline(this),this.vertexCount+a>this.vertexCapacity&&this.flush();var h,u,l,c,d,f,p=this.renderer.config.roundPixels,g=o.getTintAppendFloatAlpha,m=t.uv,v=t.colors,y=t.alphas,x=this.vertexViewF32,w=this.vertexViewU32,T=e.matrix.matrix,S=t.frame,b=t.texture.source[S.sourceIndex].glTexture,A=t.x,E=t.y,_=t.scaleX,C=t.scaleY,M=t.rotation,P=Math.sin(M),k=Math.cos(M),L=k*_,R=P*_,F=-P*C,O=k*C,D=A,I=E,B=T[0],N=T[1],U=T[2],Y=T[3],X=T[4],z=T[5],G=0;if(s){var V=s[0],H=s[1],W=s[2],j=s[3],q=s[4],K=s[5],J=-e.scrollX*t.scrollFactorX,Z=-e.scrollY*t.scrollFactorY,Q=V*B+H*U,$=V*N+H*Y,tt=W*B+j*U,et=W*N+j*Y;h=L*Q+R*tt,u=L*$+R*et,l=F*Q+O*tt,c=F*$+O*et,d=D*Q+I*tt+(q*B+K*U+(J*B+Z*U+X)),f=D*$+I*et+(q*N+K*Y+(J*N+Z*Y+z))}else h=L*B+R*U,u=L*N+R*Y,l=F*B+O*U,c=F*N+O*Y,d=(D-=e.scrollX*t.scrollFactorX)*B+(I-=e.scrollY*t.scrollFactorY)*U+X,f=D*N+I*Y+z;this.setTexture2D(b,0),G=this.vertexCount*this.vertexComponentCount;for(var it=0,st=0;itthis.vertexCapacity&&this.flush();var n,r,a,h,u,l,c,d,f,p,g,m,v,y,x=this.renderer.config.roundPixels,w=t.text,T=w.length,S=o.getTintAppendFloatAlpha,b=this.vertexViewF32,A=this.vertexViewU32,E=e.matrix.matrix,_=e.width+50,C=e.height+50,M=t.frame,P=t.texture.source[M.sourceIndex],k=e.scrollX*t.scrollFactorX,L=e.scrollY*t.scrollFactorY,R=t.fontData,F=R.lineHeight,O=t.fontSize/R.size,D=R.chars,I=t.alpha,B=S(t._tintTL,I),N=S(t._tintTR,I),U=S(t._tintBL,I),Y=S(t._tintBR,I),X=t.x,z=t.y,G=M.cutX,V=M.cutY,H=P.width,W=P.height,j=P.glTexture,q=0,K=0,J=0,Z=0,Q=null,$=0,tt=0,et=0,it=0,st=0,nt=0,rt=0,at=0,ot=0,ht=0,ut=0,lt=0,ct=null,dt=0,ft=X+M.x,pt=z+M.y,gt=t.rotation,mt=t.scaleX,vt=t.scaleY,yt=t.letterSpacing,xt=Math.sin(gt),wt=Math.cos(gt),Tt=wt*mt,St=xt*mt,bt=-xt*vt,At=wt*vt,Et=ft,_t=pt,Ct=E[0],Mt=E[1],Pt=E[2],kt=E[3],Lt=E[4],Rt=E[5],Ft=0;if(s){var Ot=s[0],Dt=s[1],It=s[2],Bt=s[3],Nt=s[4],Ut=s[5],Yt=-k,Xt=-L,zt=Ot*Ct+Dt*Pt,Gt=Ot*Mt+Dt*kt,Vt=It*Ct+Bt*Pt,Ht=It*Mt+Bt*kt;f=Tt*zt+St*Vt,p=Tt*Gt+St*Ht,g=bt*zt+At*Vt,m=bt*Gt+At*Ht,v=Et*zt+_t*Vt+(Nt*Ct+Ut*Pt+(Yt*Ct+Xt*Pt+Lt)),y=Et*Gt+_t*Ht+(Nt*Mt+Ut*kt+(Yt*Mt+Xt*kt+Rt))}else f=Tt*Ct+St*Pt,p=Tt*Mt+St*kt,g=bt*Ct+At*Pt,m=bt*Mt+At*kt,v=(Et-=k)*Ct+(_t-=L)*Pt+Lt,y=Et*Mt+_t*kt+Rt;this.setTexture2D(j,0);for(var Wt=0;Wt_||r<-50||r>C)&&(a<-50||a>_||h<-50||h>C)&&(u<-50||u>_||l<-50||l>C)&&(c<-50||c>_||d<-50||d>C)||(this.vertexCount+6>this.vertexCapacity&&this.flush(),Ft=this.vertexCount*this.vertexComponentCount,x&&(n|=0,r|=0,a|=0,h|=0,u|=0,l|=0,c|=0,d|=0),b[Ft+0]=n,b[Ft+1]=r,b[Ft+2]=ot,b[Ft+3]=ut,A[Ft+4]=B,b[Ft+5]=a,b[Ft+6]=h,b[Ft+7]=ot,b[Ft+8]=lt,A[Ft+9]=U,b[Ft+10]=u,b[Ft+11]=l,b[Ft+12]=ht,b[Ft+13]=lt,A[Ft+14]=Y,b[Ft+15]=n,b[Ft+16]=r,b[Ft+17]=ot,b[Ft+18]=ut,A[Ft+19]=B,b[Ft+20]=u,b[Ft+21]=l,b[Ft+22]=ht,b[Ft+23]=lt,A[Ft+24]=Y,b[Ft+25]=c,b[Ft+26]=d,b[Ft+27]=ht,b[Ft+28]=ut,A[Ft+29]=N,this.vertexCount+=6))}}else q=0,J=0,K+=F,ct=null},batchDynamicBitmapText:function(t,e,i){var s=null;i&&(s=i.matrix),this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var n,r,a,h,u,l,c,d,f,p,g,m,v,y,x,w,T,S,b,A,E=this.renderer.config.roundPixels,_=t.displayCallback,C=t.text,M=C.length,P=o.getTintAppendFloatAlpha,k=this.vertexViewF32,L=this.vertexViewU32,R=this.renderer,F=e.matrix.matrix,O=t.frame,D=t.texture.source[O.sourceIndex],I=e.scrollX*t.scrollFactorX,B=e.scrollY*t.scrollFactorY,N=t.scrollX,U=t.scrollY,Y=t.fontData,X=Y.lineHeight,z=t.fontSize/Y.size,G=Y.chars,V=t.alpha,H=P(t._tintTL,V),W=P(t._tintTR,V),j=P(t._tintBL,V),q=P(t._tintBR,V),K=t.x,J=t.y,Z=O.cutX,Q=O.cutY,$=D.width,tt=D.height,et=D.glTexture,it=0,st=0,nt=0,rt=0,at=null,ot=0,ht=0,ut=0,lt=0,ct=0,dt=0,ft=0,pt=0,gt=0,mt=0,vt=0,yt=0,xt=null,wt=0,Tt=K+O.x,St=J+O.y,bt=t.rotation,At=t.scaleX,Et=t.scaleY,_t=t.letterSpacing,Ct=Math.sin(bt),Mt=Math.cos(bt),Pt=Mt*At,kt=Ct*At,Lt=-Ct*Et,Rt=Mt*Et,Ft=Tt,Ot=St,Dt=F[0],It=F[1],Bt=F[2],Nt=F[3],Ut=F[4],Yt=F[5],Xt=t.cropWidth>0||t.cropHeight>0,zt=0;if(s){var Gt=s[0],Vt=s[1],Ht=s[2],Wt=s[3],jt=s[4],qt=s[5],Kt=-I,Jt=-B,Zt=Gt*Dt+Vt*Bt,Qt=Gt*It+Vt*Nt,$t=Ht*Dt+Wt*Bt,te=Ht*It+Wt*Nt;x=Pt*Zt+kt*$t,w=Pt*Qt+kt*te,T=Lt*Zt+Rt*$t,S=Lt*Qt+Rt*te,b=Ft*Zt+Ot*$t+(jt*Dt+qt*Bt+(Kt*Dt+Jt*Bt+Ut)),A=Ft*Qt+Ot*te+(jt*It+qt*Nt+(Kt*It+Jt*Nt+Yt))}else x=Pt*Dt+kt*Bt,w=Pt*It+kt*Nt,T=Lt*Dt+Rt*Bt,S=Lt*It+Rt*Nt,b=(Ft-=I)*Dt+(Ot-=B)*Bt+Ut,A=Ft*It+Ot*Nt+Yt;this.setTexture2D(et,0),Xt&&R.pushScissor(t.x,t.y,t.cropWidth*t.scaleX,t.cropHeight*t.scaleY);for(var ee=0;eethis.vertexCapacity&&this.flush(),zt=this.vertexCount*this.vertexComponentCount,E&&(n|=0,r|=0,a|=0,h|=0,u|=0,l|=0,c|=0,d|=0),k[zt+0]=n,k[zt+1]=r,k[zt+2]=gt,k[zt+3]=vt,L[zt+4]=H,k[zt+5]=a,k[zt+6]=h,k[zt+7]=gt,k[zt+8]=yt,L[zt+9]=j,k[zt+10]=u,k[zt+11]=l,k[zt+12]=mt,k[zt+13]=yt,L[zt+14]=q,k[zt+15]=n,k[zt+16]=r,k[zt+17]=gt,k[zt+18]=vt,L[zt+19]=H,k[zt+20]=u,k[zt+21]=l,k[zt+22]=mt,k[zt+23]=yt,L[zt+24]=q,k[zt+25]=c,k[zt+26]=d,k[zt+27]=mt,k[zt+28]=vt,L[zt+29]=W,this.vertexCount+=6}}}else it=0,nt=0,st+=X,xt=null;Xt&&R.popScissor()},batchText:function(t,e,i){var s=o.getTintAppendFloatAlpha;this.batchTexture(t,t.canvasTexture,t.canvasTexture.width,t.canvasTexture.height,t.x,t.y,t.canvasTexture.width,t.canvasTexture.height,t.scaleX,t.scaleY,t.rotation,t.flipX,t.flipY,t.scrollFactorX,t.scrollFactorY,t.displayOriginX,t.displayOriginY,0,0,t.canvasTexture.width,t.canvasTexture.height,s(t._tintTL,t._alphaTL),s(t._tintTR,t._alphaTR),s(t._tintBL,t._alphaBL),s(t._tintBR,t._alphaBR),0,0,e,i)},batchDynamicTilemapLayer:function(t,e,i){for(var s=t.culledTiles,n=s.length,r=t.tileset.image.get().source.glTexture,a=t.tileset,h=t.scrollFactorX,u=t.scrollFactorY,l=t.alpha,c=t.x,d=t.y,f=t.scaleX,p=t.scaleY,g=o.getTintAppendFloatAlpha,m=0;mthis.vertexCapacity&&this.flush(),d^=e.isRenderTexture?1:0;var k,L,R,F,O,D,I=this.renderer.config.roundPixels,B=this.vertexViewF32,N=this.vertexViewU32,U=C.matrix.matrix,Y=a*(c?1:0)-g,X=o*(d?1:0)-m,z=Y+a*(c?-1:1),G=X+o*(d?-1:1),V=n,H=r,W=Math.sin(l),j=Math.cos(l),q=j*h,K=W*h,J=-W*u,Z=j*u,Q=V,$=H,tt=U[0],et=U[1],it=U[2],st=U[3],nt=U[4],rt=U[5];if(P){var at=P[0],ot=P[1],ht=P[2],ut=P[3],lt=P[4],ct=P[5],dt=-C.scrollX*f,ft=-C.scrollY*p,pt=at*tt+ot*it,gt=at*et+ot*st,mt=ht*tt+ut*it,vt=ht*et+ut*st;k=q*pt+K*mt,L=q*gt+K*vt,R=J*pt+Z*mt,F=J*gt+Z*vt,O=Q*pt+$*mt+(lt*tt+ct*it+(dt*tt+ft*it+nt)),D=Q*gt+$*vt+(lt*et+ct*st+(dt*et+ft*st+rt))}else k=q*tt+K*it,L=q*et+K*st,R=J*tt+Z*it,F=J*et+Z*st,O=(Q-=C.scrollX*f)*tt+($-=C.scrollY*p)*it+nt,D=Q*et+$*st+rt;var yt,xt=Y*k+X*R+O,wt=Y*L+X*F+D,Tt=Y*k+G*R+O,St=Y*L+G*F+D,bt=z*k+G*R+O,At=z*L+G*F+D,Et=z*k+X*R+O,_t=z*L+X*F+D,Ct=v/i+E,Mt=y/s+_,Pt=(v+x)/i+E,kt=(y+w)/s+_;this.setTexture2D(e,0),yt=this.vertexCount*this.vertexComponentCount,I&&(xt|=0,wt|=0,Tt|=0,St|=0,bt|=0,At|=0,Et|=0,_t|=0),B[yt+0]=xt,B[yt+1]=wt,B[yt+2]=Ct,B[yt+3]=Mt,N[yt+4]=T,B[yt+5]=Tt,B[yt+6]=St,B[yt+7]=Ct,B[yt+8]=kt,N[yt+9]=S,B[yt+10]=bt,B[yt+11]=At,B[yt+12]=Pt,B[yt+13]=kt,N[yt+14]=b,B[yt+15]=xt,B[yt+16]=wt,B[yt+17]=Ct,B[yt+18]=Mt,N[yt+19]=T,B[yt+20]=bt,B[yt+21]=At,B[yt+22]=Pt,B[yt+23]=kt,N[yt+24]=b,B[yt+25]=Et,B[yt+26]=_t,B[yt+27]=Pt,B[yt+28]=Mt,N[yt+29]=A,this.vertexCount+=6},drawTexture:function(t,e,i,s,n,r,a,h,u,l,c){var d=null;c&&(d=c.matrix),this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var f=this.renderer.config.roundPixels,p=this.vertexViewF32,g=this.vertexViewU32,m=e,v=i,y=m+h,x=v+u,w=l[0],T=l[1],S=l[2],b=l[3],A=l[4],E=l[5];if(d){var _=d[0],C=d[1],M=d[2],P=d[3],k=d[4],L=w*C+T*P,R=S*C+b*P,F=A*C+E*P+d[5];w=w*_+T*M,T=L,S=S*_+b*M,b=R,A=A*_+E*M+k,E=F}var O,D=m*w+v*S+A,I=m*T+v*b+E,B=m*w+x*S+A,N=m*T+x*b+E,U=y*w+x*S+A,Y=y*T+x*b+E,X=y*w+v*S+A,z=y*T+v*b+E,G=t.width,V=t.height,H=r/G,W=a/V,j=(r+h)/G,q=(a+u)/V;s=o.getTintAppendFloatAlpha(s,n),this.setTexture2D(t,0),O=this.vertexCount*this.vertexComponentCount,f&&(D|=0,I|=0,B|=0,N|=0,U|=0,Y|=0,X|=0,z|=0),p[O+0]=D,p[O+1]=I,p[O+2]=H,p[O+3]=W,g[O+4]=s,p[O+5]=B,p[O+6]=N,p[O+7]=H,p[O+8]=q,g[O+9]=s,p[O+10]=U,p[O+11]=Y,p[O+12]=j,p[O+13]=q,g[O+14]=s,p[O+15]=D,p[O+16]=I,p[O+17]=H,p[O+18]=W,g[O+19]=s,p[O+20]=U,p[O+21]=Y,p[O+22]=j,p[O+23]=q,g[O+24]=s,p[O+25]=X,p[O+26]=z,p[O+27]=j,p[O+28]=W,g[O+29]=s,this.vertexCount+=6,this.flush()},batchGraphics:function(){}});t.exports=u},function(t,e){t.exports=function(t,e,i){var s;if(void 0===i&&(i=!0),e)"string"==typeof e?s=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(s=e);else if(t.parentElement)return t;return s||(s=document.body),i&&s.style&&(s.style.overflow="hidden"),s.appendChild(t),t}},function(t,e){var i,s="";t.exports={disable:function(t){return""===s&&(s=i(t)),s&&(t[s]=!1),t},enable:function(t){return""===s&&(s=i(t)),s&&(t[s]=!0),t},getPrefix:i=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i=(t=t.toString()).length)switch(s){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((n=e-t.length)/2);t=new Array(n-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var s=i(5);t.exports=function(t,e){void 0===e&&(e=new s);var i=Math.random()*Math.PI*2,n=Math.sqrt(Math.random());return e.x=t.x+n*Math.cos(i)*t.width/2,e.y=t.y+n*Math.sin(i)*t.height/2,e}},function(t,e,i){var s=i(97),n=i(5);t.exports=function(t,e,i){if(void 0===i&&(i=new n),e<=0||e>=1)return i.x=t.x,i.y=t.y,i;var r=s(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var s=i(5);t.exports=function(t,e,i){return void 0===i&&(i=new s),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},,,,,,,function(t,e,i){var s=i(0),n=i(18),r=i(19),a=i(7),o=i(1),h=i(8),u=i(270),l=new s({Extends:r,initialize:function(t,e,i,s){var n="xml";if(h(e)){var a=e;e=o(a,"key"),i=o(a,"url"),s=o(a,"xhrSettings"),n=o(a,"extension",n)}var u={type:"xml",cache:t.cacheManager.xml,extension:n,responseType:"text",key:e,url:i,xhrSettings:s};r.call(this,t,u)},onProcess:function(){this.state=n.FILE_PROCESSING,this.data=u(this.xhrLoader.responseText),this.data?this.onProcessComplete():(console.warn("Invalid XMLFile: "+this.key),this.onProcessError())}});a.register("xml",function(t,e,i){if(Array.isArray(t))for(var s=0;s=1&&(o=1-o,h=1-h),e.x=t.x1+(i*o+r*h),e.y=t.y1+(n*o+a*h),e}},function(t,e,i){var s=i(5);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var s=i(5);t.exports=function(t,e){void 0===e&&(e=new s);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},function(t,e,i){var s=i(71),n=i(5);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=s(t)/i);for(var a=t.x1,o=t.y1,h=t.x2,u=t.y2,l=0;l1?2-n:n,a=r*Math.cos(i),o=r*Math.sin(i);return e.x=t.x+a*t.radius,e.y=t.y+o*t.radius,e}},,function(t,e,i){var s=i(0),n=i(9),r=i(72),a=i(61),o=new s({Extends:n,initialize:function(t){n.call(this),this.manager=t,this.isTimeline=!0,this.data=[],this.totalData=0,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=a.PENDING_ADD,this._pausedState=a.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===a.ACTIVE},add:function(t){return this.queue(r(this,t))},queue:function(t){return this.isPlaying()||(t.parent=this,t.parentIsTimeline=!0,this.data.push(t),this.totalData=this.data.length),this},hasOffset:function(t){return null!==t.offset},isOffsetAbsolute:function(t){return"number"==typeof t},isOffsetRelative:function(t){if("string"===typeof t){var e=t[0];if("-"===e||"+"===e)return!0}return!1},getRelativeOffset:function(t,e){var i=t[0],s=parseFloat(t.substr(2)),n=e;switch(i){case"+":n+=s;break;case"-":n-=s}return Math.max(0,n)},calcDuration:function(){for(var t=0,e=0,i=0,s=0;s0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=a.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=a.LOOP_DELAY):this.state=a.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=a.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=a.PENDING_REMOVE}},update:function(t,e){if(this.state!==a.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case a.ACTIVE:for(var s=this.totalData,n=0;n0?Math.floor(m/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=o(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=a(e,"yoyo",g.yoyo),g.flipX=a(e,"flipX",g.flipX),g.flipY=a(e,"flipY",g.flipY);for(var v=0;v0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var s=new(i(0))({initialize:function(t){this.pluginManager=t,this.game=t.game,this.scene,this.systems},init:function(){},start:function(){},stop:function(){},boot:function(){},destroy:function(){this.pluginManager=null,this.game=null,this.scene=null,this.systems=null}});t.exports=s},,function(t,e,i){var s=i(0),n=i(19),r=i(1),a=i(108),o=i(8),h=new s({Extends:n,initialize:function(t,e,i,s){if(o(e)){var a=e;e=r(a,"key"),s=r(a,"config",s)}var h={type:"audio",cache:t.cacheManager.audio,extension:i.type,key:e,url:i.url,config:s};n.call(this,t,h),this.locked="ontouchstart"in window,this.loaded=!1,this.filesLoaded=0,this.filesTotal=0},onLoad:function(){this.loaded||(this.loaded=!0,this.loader.nextFile(this,!0))},onError:function(){for(var t=0;t=2&&(this.leftStick.set(r[0].getValue(),r[1].getValue()),n>=4&&this.rightStick.set(r[2].getValue(),r[3].getValue()))},destroy:function(){var t;for(this.removeAllListeners(),this.manager=null,this.pad=null,t=0;t=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",e,this,t),this.pad.emit("down",i,t,this)):this.pressed&&(this.pressed=!1,this.events.emit("up",e,this,t),this.pad.emit("up",i,t,this))},destroy:function(){this.pad=null,this.events=null}});t.exports=s},function(t,e,i){var s=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.1},update:function(t){this.value=t},getValue:function(){return Math.abs(this.value)0&&e.cameraFilter&r._id)){var u=r.scrollX*e.scrollFactorX,l=r.scrollY*e.scrollFactorY,c=e.x,d=e.y,f=e.scaleX,p=e.scaleY,g=e.rotation,m=e.commandBuffer,v=o||t.currentContext,y=1,x=1,w=0,T=0,S=1,b=0,A=0,E=0;if(t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,v.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,v.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),v.save(),a){var _=a.matrix;v.transform(_[0],_[1],_[2],_[3],_[4],_[5])}v.translate(c-u,d-l),v.rotate(g),v.scale(f,p),v.fillStyle="#fff",v.globalAlpha=e.alpha;for(var C=0,M=m.length;C>>16,A=(65280&w)>>>8,E=255&w,v.strokeStyle="rgba("+b+","+A+","+E+","+y+")",v.lineWidth=S,C+=3;break;case s.FILL_STYLE:T=m[C+1],x=m[C+2],b=(16711680&T)>>>16,A=(65280&T)>>>8,E=255&T,v.fillStyle="rgba("+b+","+A+","+E+","+x+")",C+=2;break;case s.BEGIN_PATH:v.beginPath();break;case s.CLOSE_PATH:v.closePath();break;case s.FILL_PATH:h||v.fill();break;case s.STROKE_PATH:h||v.stroke();break;case s.FILL_RECT:h?v.rect(m[C+1],m[C+2],m[C+3],m[C+4]):v.fillRect(m[C+1],m[C+2],m[C+3],m[C+4]),C+=4;break;case s.FILL_TRIANGLE:v.beginPath(),v.moveTo(m[C+1],m[C+2]),v.lineTo(m[C+3],m[C+4]),v.lineTo(m[C+5],m[C+6]),v.closePath(),h||v.fill(),C+=6;break;case s.STROKE_TRIANGLE:v.beginPath(),v.moveTo(m[C+1],m[C+2]),v.lineTo(m[C+3],m[C+4]),v.lineTo(m[C+5],m[C+6]),v.closePath(),h||v.stroke(),C+=6;break;case s.LINE_TO:v.lineTo(m[C+1],m[C+2]),C+=2;break;case s.MOVE_TO:v.moveTo(m[C+1],m[C+2]),C+=2;break;case s.LINE_FX_TO:v.lineTo(m[C+1],m[C+2]),C+=5;break;case s.MOVE_FX_TO:v.moveTo(m[C+1],m[C+2]),C+=5;break;case s.SAVE:v.save();break;case s.RESTORE:v.restore();break;case s.TRANSLATE:v.translate(m[C+1],m[C+2]),C+=2;break;case s.SCALE:v.scale(m[C+1],m[C+2]),C+=2;break;case s.ROTATE:v.rotate(m[C+1]),C+=1}v.restore()}}},function(t,e){t.exports=function(t){var e=t.width/2,i=t.height/2,s=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*s/(10+Math.sqrt(4-3*s)))}},function(t,e,i){var s=i(177),n=i(113),r=i(65),a=i(16);t.exports=function(t,e,i,o){void 0===o&&(o=[]),e||(e=s(t)/i);for(var h=0;hr;){if(a-r>600){var h=a-r+1,u=e-r+1,l=Math.log(h),c=.5*Math.exp(2*l/3),d=.5*Math.sqrt(l*c*(h-c)/h)*(u-h/2<0?-1:1),f=Math.max(r,Math.floor(e-u*c/h+d)),p=Math.min(a,Math.floor(e+(h-u)*c/h+d));i(t,e,f,p,o)}var g=t[e],m=r,v=a;for(s(t,r,e),o(t[a],g)>0&&s(t,r,a);m0;)v--}0===o(t[r],g)?s(t,r,v):s(t,++v,a),v<=e&&(r=v+1),e<=v&&(a=v-1)}};function s(t,e,i){var s=t[e];t[e]=t[i],t[i]=s}function n(t,e){return te?1:0}t.exports=i},function(t,e){t.exports=function(t){for(var e=t.length,i=t[0].length,s=new Array(i),n=0;n-1;r--)s[n][r]=t[r][n]}return s}},function(t,e,i){t.exports={AtlasXML:i(514),Canvas:i(513),Image:i(512),JSONArray:i(511),JSONHash:i(510),SpriteSheet:i(509),SpriteSheetFromAtlas:i(508),UnityYAML:i(507)}},function(t,e,i){var s=i(22),n=i(0),r=i(85),a=i(59),o=new n({initialize:function(t,e,i,s){var n=t.manager.game;this.renderer=n.renderer,this.texture=t,this.image=e,this.compressionAlgorithm=null,this.resolution=1,this.width=i||e.naturalWidth||e.width||0,this.height=s||e.naturalHeight||e.height||0,this.scaleMode=a.DEFAULT,this.isCanvas=e instanceof HTMLCanvasElement,this.isPowerOf2=r(this.width,this.height),this.glTexture=null,this.init(n)},init:function(t){this.renderer&&this.renderer.gl&&(this.isCanvas?this.glTexture=this.renderer.canvasToTexture(this.image):this.glTexture=this.renderer.createTextureFromSource(this.image,this.width,this.height,this.scaleMode)),t.config.pixelArt&&this.setFilter(1)},setFilter:function(t){this.renderer.gl&&this.renderer.setTextureFilter(this.glTexture,t)},update:function(){this.renderer.gl&&this.isCanvas&&this.renderer.canvasToTexture(this.image,this.glTexture)},destroy:function(){this.glTexture&&this.renderer.deleteTexture(this.glTexture),this.isCanvas&&s.remove(this.image),this.renderer=null,this.texture=null,this.image=null}});t.exports=o},function(t,e,i){var s=i(22),n=i(515),r=i(0),a=i(30),o=i(20),h=i(9),u=i(276),l=i(4),c=i(182),d=i(117),f=new r({Extends:h,initialize:function(t){h.call(this),this.game=t,this.name="TextureManager",this.list={},this._tempCanvas=s.create2D(this,1,1),this._tempContext=this._tempCanvas.getContext("2d"),this._pending=0,t.events.once("boot",this.boot,this)},boot:function(){this._pending=2,this.on("onload",this.updatePending,this),this.on("onerror",this.updatePending,this),this.addBase64("__DEFAULT",this.game.config.defaultImage),this.addBase64("__MISSING",this.game.config.missingImage),this.game.events.once("destroy",this.destroy,this)},updatePending:function(){this._pending--,0===this._pending&&(this.off("onload"),this.off("onerror"),this.game.events.emit("ready"))},checkKey:function(t){return!this.exists(t)||(console.error("Texture key already in use: "+t),!1)},remove:function(t){if("string"==typeof t){if(!this.exists(t))return console.warn("No texture found matching key: "+t),this;t=this.get(t)}return this.list.hasOwnProperty(t.key)&&(delete this.list[t.key],t.destroy(),this.emit("removetexture",t.key)),this},addBase64:function(t,e){if(this.checkKey(t)){var i=this,s=new Image;s.onerror=function(){i.emit("onerror",t)},s.onload=function(){var e=i.create(t,s);c.Image(e,0),i.emit("addtexture",t,e),i.emit("onload",t,e)},s.src=e}},addImage:function(t,e,i){var s=null;return this.checkKey(t)&&(s=this.create(t,e),c.Image(s,0),i&&s.setDataSource(i),this.emit("addtexture",t,s)),s},generate:function(t,e){if(this.checkKey(t)){var i=s.create(this,1,1);return e.canvas=i,u(e),this.addCanvas(t,i)}return null},createCanvas:function(t,e,i){if(void 0===e&&(e=256),void 0===i&&(i=256),this.checkKey(t)){var n=s.create(this,e,i,o.CANVAS,!0);return this.addCanvas(t,n)}return null},addCanvas:function(t,e){var i=null;return this.checkKey(t)&&(i=new n(this,t,e,e.width,e.height),this.list[t]=i,this.emit("addtexture",t,i)),i},addAtlas:function(t,e,i,s){return Array.isArray(i.textures)||Array.isArray(i.frames)?this.addAtlasJSONArray(t,e,i,s):this.addAtlasJSONHash(t,e,i,s)},addAtlasJSONArray:function(t,e,i,s){var n=null;if(this.checkKey(t)){if(n=this.create(t,e),Array.isArray(i))for(var r=1===i.length,a=0;a=0&&t<=r.width&&e>=0&&e<=r.height){t+=n.cutX,e+=n.cutY;var o=this._tempContext;o.clearRect(0,0,1,1),o.drawImage(r,t,e,1,1,0,0,1,1);var h=o.getImageData(0,0,1,1);return new a(h.data[0],h.data[1],h.data[2],h.data[3])}}return null},getPixelAlpha:function(t,e,i,s){var n=this.getFrame(i,s);if(n){var r=n.source.image;if(t>=0&&t<=r.width&&e>=0&&e<=r.height){t+=n.cutX,e+=n.cutY;var a=this._tempContext;return a.clearRect(0,0,1,1),a.drawImage(r,t,e,1,1,0,0,1,1),a.getImageData(0,0,1,1).data[3]}}return null},setTexture:function(t,e,i){return this.list[e]&&(t.texture=this.list[e],t.frame=t.texture.get(i)),t},each:function(t,e){for(var i=[null],s=1;s0)&&(!!s.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!s.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!s.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=s-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,n-s),n=this.audio.currentTime):n=s)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=n}},destroy:function(){s.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},updateMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},updateVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},calculateRate:function(){s.prototype.calculateRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)},mute:{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||this.emit("mute",this,t)}},setMute:function(t){return this.mute=t,this},volume:{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||this.emit("volume",this,t)}},setVolume:function(t){return this.volume=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||(this.calculateRate(),this.emit("rate",this,t))}},setRate:function(t){return this.rate=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||(this.calculateRate(),this.emit("detune",this,t))}},setDetune:function(t){return this.detune=t,this},seek:{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}},setSeek:function(t){return this.seek=t,this},loop:{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}},setLoop:function(t){return this.loop=t,this}});t.exports=n},function(t,e,i){var s=i(79),n=i(0),r=i(189),a=new n({Extends:s,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,s.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){this.locked=!1;var t=this;if(this.game.cache.audio.entries.each(function(e,i){for(var s=0;s-1&&(delete this.keys[s],this.scenes.splice(i,1),this._start.indexOf(s)>-1&&(i=this._start.indexOf(s),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e,i=t.sys,s=i.settings;t.init&&(t.init.call(t,s.data),s.isTransition&&i.events.emit("transitioninit",s.transitionFrom,s.transitionDuration)),i.load&&(e=i.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(s.status=n.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.game.sound.onBlurPausedSounds&&this.game.sound.unlock(),this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this.isProcessing=!0;for(var i=this.scenes.length-1;i>=0;i--){var s=this.scenes[i].sys;s.settings.status>n.START&&s.settings.status<=n.RUNNING&&s.step(t,e)}},resize:function(t,e){for(var i=0;i=n.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this.isProcessing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,s=this.getScene(t),n=this.getAt(i);this.scenes[e]=n,this.scenes[i]=s}}return this},moveUp:function(t){if(this.isProcessing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e=0;t--){this.scenes[t].sys.destroy()}this.update=a,this.scenes=[],this._pending=[],this._start=[],this._queue=[],this.game=null}});t.exports=u},function(t,e,i){var s=i(56);t.exports=function(t,e,i,n){var r;if(void 0===n&&(n=t),!Array.isArray(e))return-1!==(r=t.indexOf(e))?(s(t,r),i&&i.call(n,e),e):null;for(var a=e.length-1;a>=0;){var o=e[a];-1!==(r=t.indexOf(o))?(s(t,r),i&&i.call(n,o)):e.pop(),a--}return e}},function(t,e,i){var s=i(0),n=i(9),r=i(7),a=i(13),o=i(11),h=i(1),u=i(12),l=i(195),c=new s({Extends:n,initialize:function(t){n.call(this),this.game=t,this.plugins=[],this.scenePlugins=[],this._pendingGlobal=[],this._pendingScene=[],t.isBooted?this.boot():t.events.once("boot",this.boot,this)},boot:function(){var t,e,i,s,n,r,a=this.game.config,o=a.installGlobalPlugins;for(o=o.concat(this._pendingGlobal),t=0;t10&&(t=10-this.pointersTotal);for(var i=0;i0},queueTouchStart:function(t){if(this.queue.push(n.TOUCH_START,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueTouchMove:function(t){if(this.queue.push(n.TOUCH_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueTouchEnd:function(t){if(this.queue.push(n.TOUCH_END,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},queueMouseDown:function(t){if(this.queue.push(n.MOUSE_DOWN,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueMouseMove:function(t){if(this.queue.push(n.MOUSE_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueMouseUp:function(t){if(this.queue.push(n.MOUSE_UP,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},addUpCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.upOnce.push(t):this.domCallbacks.up.push(t),this._hasUpCallback=!0,this},addDownCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.downOnce.push(t):this.domCallbacks.down.push(t),this._hasDownCallback=!0,this},addMoveCallback:function(t,e){return void 0===e&&(e=!1),e?this.domCallbacks.moveOnce.push(t):this.domCallbacks.move.push(t),this._hasMoveCallback=!0,this},inputCandidate:function(t){var e=t.input;if(!e||!e.enabled||!t.willRender())return!1;var i=!0,s=t.parentContainer;if(s)do{if(!s.visible){i=!1;break}s=s.parentContainer}while(s);return i},hitTest:function(t,e,i,s){void 0===s&&(s=this._tempHitTest);var n=this._tempPoint,r=i.width,a=i.height;s.length=0;var o=t.x,h=t.y;if(!(o>=i.x&&h>=i.y&&o<=i.x+r&&h<=i.y+a))return s;i.getWorldPoint(o,h,n),t.worldX=n.x,t.worldY=n.y;for(var u={x:0,y:0},l=this.game.config.resolution,d=this._tempMatrix,f=0;fe.length&&(r=e.length),i?(s=e[r-1][i],(n=e[r][i])-t<=t-s?e[r]:e[r-1]):(s=e[r-1],(n=e[r])-t<=t-s?n:s)}},function(t,e,i){var s=i(23),n=i(0),r=i(209),a=i(208),o=i(4),h=new n({initialize:function(t,e,i){this.manager=t,this.key=e,this.type="frame",this.frames=this.getFrames(t.textureManager,o(i,"frames",[]),o(i,"defaultTextureKey",null)),this.frameRate=o(i,"frameRate",null),this.duration=o(i,"duration",null),null===this.duration&&null===this.frameRate?(this.frameRate=24,this.duration=this.frameRate/this.frames.length*1e3):this.duration&&null===this.frameRate?this.frameRate=this.frames.length/(this.duration/1e3):this.duration=this.frames.length/this.frameRate*1e3,this.msPerFrame=1e3/this.frameRate,this.skipMissedFrames=o(i,"skipMissedFrames",!0),this.delay=o(i,"delay",0),this.repeat=o(i,"repeat",0),this.repeatDelay=o(i,"repeatDelay",0),this.yoyo=o(i,"yoyo",!1),this.showOnStart=o(i,"showOnStart",!1),this.hideOnComplete=o(i,"hideOnComplete",!1),this.paused=!1,this.manager.on("pauseall",this.pause,this),this.manager.on("resumeall",this.resume,this)},addFrame:function(t){return this.addFrameAt(this.frames.length,t)},addFrameAt:function(t,e){var i=this.getFrames(this.manager.textureManager,e);if(i.length>0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var s=this.frames.slice(0,t),n=this.frames.slice(t);this.frames=s.concat(i,n)}this.updateFrameSequence()}return this},checkFrame:function(t){return t>=0&&t0){n.isLast=!0,n.nextFrame=u[0],u[0].prevFrame=n;var m=1/(u.length-1);for(r=0;r=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._timeScale=1,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo),t.updateFrame(this.frames[e])},getFrameByProgress:function(t){return t=s(t,0,1),r(t,this.frames,"progress")},nextFrame:function(t){var e=t.currentFrame;e.isLast?t._yoyo?(t.forward=!1,t.updateFrame(e.prevFrame),this.getNextTick(t)):t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.nextFrame),this.getNextTick(t))},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.prevFrame),this.getNextTick(t))},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){if(2===t._pendingStop)return this.completeAnimation(t);t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=t._repeatDelay):(t.repeatCounter--,t.forward=!0,t.updateFrame(t.currentFrame.nextFrame),t.isPlaying&&(this.getNextTick(t),t.pendingRepeat=!1,t.parent.emit("animationrepeat",this,t.currentFrame,t.repeatCounter)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(s.prevFrame=this.frames[i-1],s.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){this.manager.off("pauseall",this.pause,this),this.manager.off("resumeall",this.resume,this),this.manager.remove(this.key);for(var t=0;t=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(t,e,i,n,r){for(var a,o=[e,i];o.length;)(i=o.pop())-(e=o.pop())<=n||(a=e+Math.ceil((i-e)/n/2)*n,s(t,a,e,i,r),o.push(e,a,a,i))}n.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],s=this.toBBox;if(!p(t,e))return i;for(var n,r,a,o,h=[];e;){for(n=0,r=e.children.length;n=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)},_split:function(t,e){var i=t[e],s=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,s);var r=this._chooseSplitIndex(i,n,s),o=g(i.children.splice(r,i.children.length-r));o.height=i.height,o.leaf=i.leaf,a(i,this.toBBox),a(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(i,o)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var s,n,r,a,h,u,l,d,f,p,g,m,v,y;for(u=l=1/0,s=e;s<=i-e;s++)n=o(t,0,s,this.toBBox),r=o(t,s,i,this.toBBox),f=n,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),m=Math.max(f.minY,p.minY),v=Math.min(f.maxX,p.maxX),y=Math.min(f.maxY,p.maxY),a=Math.max(0,v-g)*Math.max(0,y-m),h=c(n)+c(r),a=e;n--)r=t.children[n],h(l,t.leaf?a(r):r),c+=d(l);return c},_adjustParentBBoxes:function(t,e,i){for(var s=i;s>=0;s--)h(e[s],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():a(t[i],this.toBBox)},compareMinX:function(t,e){return t.left-e.left},compareMinY:function(t,e){return t.top-e.top},toBBox:function(t){return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}},t.exports=n},function(t,e,i){var s=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,s=this._active;for(t=0;tu+l?(g=(p-=u+l)/c,m.x=h.x1+(h.x2-h.x1)*g,m.y=h.y1+(h.y2-h.y1)*g):(g=(p-=u)/l,m.x=o.x1+(o.x2-o.x1)*g,m.y=o.y1+(o.y2-o.y1)*g),r.push(m)}return r}},function(t,e,i){var s=i(5),n=i(71);t.exports=function(t,e,i){void 0===i&&(i=new s);var r=t.getLineA(),a=t.getLineB(),o=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=n(r),u=n(a),l=n(o),c=(h+u+l)*e,d=0;return ch+u?(d=(c-=h+u)/l,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d):(d=(c-=h)/u,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d),i}},,,,,,,,,function(t,e,i){t.exports=i(421)},function(t,e,i){t.exports={In:i(424),Out:i(423),InOut:i(422)}},function(t,e,i){t.exports={In:i(427),Out:i(426),InOut:i(425)}},function(t,e,i){t.exports={In:i(430),Out:i(429),InOut:i(428)}},function(t,e,i){t.exports={In:i(433),Out:i(432),InOut:i(431)}},function(t,e,i){t.exports=i(434)},function(t,e,i){t.exports={In:i(437),Out:i(436),InOut:i(435)}},function(t,e,i){t.exports={In:i(440),Out:i(439),InOut:i(438)}},function(t,e,i){t.exports={In:i(443),Out:i(442),InOut:i(441)}},function(t,e,i){t.exports={In:i(446),Out:i(445),InOut:i(444)}},function(t,e,i){t.exports={In:i(449),Out:i(448),InOut:i(447)}},function(t,e,i){t.exports={In:i(452),Out:i(451),InOut:i(450)}},function(t,e){t.exports=function(t,e){return Math.random()*(e-t)+t}},function(t,e,i){var s=i(114);s.Area=i(472),s.Circumference=i(177),s.CircumferencePoint=i(113),s.Clone=i(471),s.Contains=i(54),s.ContainsPoint=i(470),s.ContainsRect=i(469),s.CopyFrom=i(468),s.Equals=i(467),s.GetBounds=i(466),s.GetPoint=i(179),s.GetPoints=i(178),s.Offset=i(465),s.OffsetPoint=i(464),s.Random=i(134),t.exports=s},,,,,function(t,e,i){var s=i(4),n=i(95),r=function(t,e,i){for(var s=[],n=0;n0?Math.ceil(t):Math.floor(t)}},function(t,e){t.exports=function(t){return t&&t[0].toUpperCase()+t.slice(1)}},function(t,e,i){var s=i(6);t.exports=function(t,e,i,n,r,a,o,h){void 0===h&&(h=new s);var u=Math.sin(-r),l=Math.cos(-r),c=l*a,d=-u*a,f=u*o,p=l*o,g=c*p-d*f,m=p/g,v=-d/g,y=-f/g,x=c/g,w=(f*n-p*i)/g,T=-(c*n-d*i)/g;return h.x=t*m+e*y+w,h.y=t*v+e*x+T,h}},function(t,e,i){"use strict";function s(t,e,i){i=i||2;var s,o,h,u,l,f,g,m=e&&e.length,v=m?e[0]*i:t.length,y=n(t,0,v,i,!0),x=[];if(!y)return x;if(m&&(y=function(t,e,i,s){var a,o,h,u,l,f=[];for(a=0,o=e.length;a80*i){s=h=t[0],o=u=t[1];for(var w=i;wh&&(h=l),f>u&&(u=f);g=Math.max(h-s,u-o)}return a(y,x,i,s,o,g),x}function n(t,e,i,s,n){var r,a;if(n===E(t,e,i,s)>0)for(r=e;r=e;r-=s)a=S(r,t[r],t[r+1],a);return a&&y(a,a.next)&&(b(a),a=a.next),a}function r(t,e){if(!t)return t;e||(e=t);var i,s=t;do{if(i=!1,s.steiner||!y(s,s.next)&&0!==v(s.prev,s,s.next))s=s.next;else{if(b(s),(s=e=s.prev)===s.next)return null;i=!0}}while(i||s!==e);return e}function a(t,e,i,s,n,c,d){if(t){!d&&c&&function(t,e,i,s){var n=t;do{null===n.z&&(n.z=f(n.x,n.y,e,i,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,s,n,r,a,o,h,u=1;do{for(i=t,t=null,r=null,a=0;i;){for(a++,s=i,o=0,e=0;e0||h>0&&s;)0!==o&&(0===h||!s||i.z<=s.z)?(n=i,i=i.nextZ,o--):(n=s,s=s.nextZ,h--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;i=s}r.nextZ=null,u*=2}while(a>1)}(n)}(t,s,n,c);for(var p,g,m=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,s,n,c):o(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),b(t),t=g.next,m=g.next;else if((t=g)===m){d?1===d?a(t=u(t,e,i),e,i,s,n,c,2):2===d&&l(t,e,i,s,n,c):a(r(t),e,i,s,n,c,1);break}}}function o(t){var e=t.prev,i=t,s=t.next;if(v(e,i,s)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(g(e.x,e.y,i.x,i.y,s.x,s.y,n.x,n.y)&&v(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function h(t,e,i,s){var n=t.prev,r=t,a=t.next;if(v(n,r,a)>=0)return!1;for(var o=n.xr.x?n.x>a.x?n.x:a.x:r.x>a.x?r.x:a.x,l=n.y>r.y?n.y>a.y?n.y:a.y:r.y>a.y?r.y:a.y,c=f(o,h,e,i,s),d=f(u,l,e,i,s),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(n.x,n.y,r.x,r.y,a.x,a.y,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(n.x,n.y,r.x,r.y,a.x,a.y,p.x,p.y)&&v(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function u(t,e,i){var s=t;do{var n=s.prev,r=s.next.next;!y(n,r)&&x(n,s,s.next,r)&&w(n,r)&&w(r,n)&&(e.push(n.i/i),e.push(s.i/i),e.push(r.i/i),b(s),b(s.next),s=t=r),s=s.next}while(s!==t);return s}function l(t,e,i,s,n,o){var h=t;do{for(var u=h.next.next;u!==h.prev;){if(h.i!==u.i&&m(h,u)){var l=T(h,u);return h=r(h,h.next),l=r(l,l.next),a(h,e,i,s,n,o),void a(l,e,i,s,n,o)}u=u.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,s=e,n=t.x,r=t.y,a=-1/0;do{if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){var o=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(o<=n&&o>a){if(a=o,o===n){if(r===s.y)return s;if(r===s.next.y)return s.next}i=s.x=s.x&&s.x>=l&&n!==s.x&&g(ri.x)&&w(s,t)&&(i=s,d=h),s=s.next;return i}(t,e)){var i=T(e,t);r(i,i.next)}}function f(t,e,i,s,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-s)/n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-a)*(s-o)-(i-a)*(e-o)>=0&&(i-a)*(r-o)-(n-a)*(s-o)>=0}function m(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&w(t,e)&&w(e,t)&&function(t,e){var i=t,s=!1,n=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s}(t,e)}function v(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function y(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,s){return!!(y(t,e)&&y(i,s)||y(t,s)&&y(i,e))||v(t,e,i)>0!=v(t,e,s)>0&&v(i,s,t)>0!=v(i,s,e)>0}function w(t,e){return v(t.prev,t,t.next)<0?v(t,e,t.next)>=0&&v(t,t.prev,e)>=0:v(t,e,t.prev)<0||v(t,t.next,e)<0}function T(t,e){var i=new A(t.i,t.x,t.y),s=new A(e.i,e.x,e.y),n=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,s.next=i,i.prev=s,r.next=s,s.prev=r,s}function S(t,e,i,s){var n=new A(t,e,i);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function b(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function E(t,e,i,s){for(var n=0,r=e,a=i-s;r0&&(s+=t[n-1].length,i.holes.push(s))}return i}},function(t,e,i){var s=i(0),n=i(119),r=i(258),a=i(202),o=i(529),h=i(528),u=i(27),l=i(84),c=function(t,e,i,s,n){this.x=t,this.y=e,this.width=i,this.rgb=s,this.alpha=n},d=function(t,e,i,s,n){this.points=[],this.pointsLength=1,this.points[0]=new c(t,e,i,s,n)},f=new Float32Array([1,0,0,1,0,0]),p=new Float32Array(6e3),g=0,m=[],v=new s({Extends:l,Mixins:[a],initialize:function(t){l.call(this,{game:t.game,renderer:t.renderer,gl:t.renderer.gl,topology:t.topology?t.topology:t.renderer.gl.TRIANGLES,vertShader:t.vertShader?t.vertShader:h,fragShader:t.fragShader?t.fragShader:o,vertexCapacity:t.vertexCapcity?t.vertexCapacity:12e3,vertexSize:t.vertexSize?t.vertexSize:2*Float32Array.BYTES_PER_ELEMENT+4*Uint8Array.BYTES_PER_ELEMENT,attributes:[{name:"inPosition",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:0},{name:"inTint",size:4,type:t.renderer.gl.UNSIGNED_BYTE,normalized:!0,offset:2*Float32Array.BYTES_PER_ELEMENT}]}),this.vertexViewF32=new Float32Array(this.vertexData),this.vertexViewU32=new Uint32Array(this.vertexData),this.tempTriangle=[{x:0,y:0,width:0,rgb:16777215,alpha:1},{x:0,y:0,width:0,rgb:16777215,alpha:1},{x:0,y:0,width:0,rgb:16777215,alpha:1},{x:0,y:0,width:0,rgb:16777215,alpha:1}],this.polygonCache=[],this.mvpInit()},onBind:function(){return l.prototype.onBind.call(this),this.mvpUpdate(),this},resize:function(t,e,i){return l.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},batchFillRect:function(t,e,i,s,n,r,a,o,h,l,c,d,f,p,g,m,v,y){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var x=this.vertexViewF32,w=this.vertexViewU32,T=this.vertexCount*this.vertexComponentCount,S=r+o,b=a+h,A=y[0],E=y[1],_=y[2],C=y[3],M=d*A+f*_,P=d*E+f*C,k=p*A+g*_,L=p*E+g*C,R=m*A+v*_+y[4],F=m*E+v*C+y[5],O=r*M+a*k+R,D=r*P+a*L+F,I=r*M+b*k+R,B=r*P+b*L+F,N=S*M+b*k+R,U=S*P+b*L+F,Y=S*M+a*k+R,X=S*P+a*L+F,z=u.getTintAppendFloatAlphaAndSwap(l,c);x[T+0]=O,x[T+1]=D,w[T+2]=z,x[T+3]=I,x[T+4]=B,w[T+5]=z,x[T+6]=N,x[T+7]=U,w[T+8]=z,x[T+9]=O,x[T+10]=D,w[T+11]=z,x[T+12]=N,x[T+13]=U,w[T+14]=z,x[T+15]=Y,x[T+16]=X,w[T+17]=z,this.vertexCount+=6},batchFillTriangle:function(t,e,i,s,n,r,a,o,h,l,c,d,f,p,g,m,v,y,x,w){this.renderer.setPipeline(this),this.vertexCount+3>this.vertexCapacity&&this.flush();var T=this.vertexViewF32,S=this.vertexViewU32,b=this.vertexCount*this.vertexComponentCount,A=w[0],E=w[1],_=w[2],C=w[3],M=p*A+g*_,P=p*E+g*C,k=m*A+v*_,L=m*E+v*C,R=y*A+x*_+w[4],F=y*E+x*C+w[5],O=r*M+a*k+R,D=r*P+a*L+F,I=o*M+h*k+R,B=o*P+h*L+F,N=l*M+c*k+R,U=l*P+c*L+F,Y=u.getTintAppendFloatAlphaAndSwap(d,f);T[b+0]=O,T[b+1]=D,S[b+2]=Y,T[b+3]=I,T[b+4]=B,S[b+5]=Y,T[b+6]=N,T[b+7]=U,S[b+8]=Y,this.vertexCount+=3},batchStrokeTriangle:function(t,e,i,s,n,r,a,o,h,u,l,c,d,f,p,g,m,v,y,x,w){var T=this.tempTriangle;T[0].x=r,T[0].y=a,T[0].width=c,T[0].rgb=d,T[0].alpha=f,T[1].x=o,T[1].y=h,T[1].width=c,T[1].rgb=d,T[1].alpha=f,T[2].x=u,T[2].y=l,T[2].width=c,T[2].rgb=d,T[2].alpha=f,T[3].x=r,T[3].y=a,T[3].width=c,T[3].rgb=d,T[3].alpha=f,this.batchStrokePath(t,e,i,s,n,T,c,d,f,p,g,m,v,y,x,!1,w)},batchFillPath:function(t,e,i,s,n,a,o,h,l,c,d,f,p,g,m){this.renderer.setPipeline(this);for(var v,y,x,w,T,S,b,A,E,_,C,M,P,k,L,R,F,O=a.length,D=this.polygonCache,I=this.vertexViewF32,B=this.vertexViewU32,N=0,U=m[0],Y=m[1],X=m[2],z=m[3],G=l*U+c*X,V=l*Y+c*z,H=d*U+f*X,W=d*Y+f*z,j=p*U+g*X+m[4],q=p*Y+g*z+m[5],K=u.getTintAppendFloatAlphaAndSwap(o,h),J=0;Jthis.vertexCapacity&&this.flush(),N=this.vertexCount*this.vertexComponentCount,M=(S=D[x+0])*G+(b=D[x+1])*H+j,P=S*V+b*W+q,k=(A=D[w+0])*G+(E=D[w+1])*H+j,L=A*V+E*W+q,R=(_=D[T+0])*G+(C=D[T+1])*H+j,F=_*V+C*W+q,I[N+0]=M,I[N+1]=P,B[N+2]=K,I[N+3]=k,I[N+4]=L,B[N+5]=K,I[N+6]=R,I[N+7]=F,B[N+8]=K,this.vertexCount+=3;D.length=0},batchStrokePath:function(t,e,i,s,n,r,a,o,h,l,c,d,f,p,g,m,v){var y,x;this.renderer.setPipeline(this);for(var w,T,S,b,A=r.length,E=this.polygonCache,_=this.vertexViewF32,C=this.vertexViewU32,M=u.getTintAppendFloatAlphaAndSwap,P=0;P+1this.vertexCapacity&&this.flush(),w=E[k-1]||E[L-1],T=E[k],_[(S=this.vertexCount*this.vertexComponentCount)+0]=w[6],_[S+1]=w[7],C[S+2]=M(w[8],h),_[S+3]=w[0],_[S+4]=w[1],C[S+5]=M(w[2],h),_[S+6]=T[9],_[S+7]=T[10],C[S+8]=M(T[11],h),_[S+9]=w[0],_[S+10]=w[1],C[S+11]=M(w[2],h),_[S+12]=w[6],_[S+13]=w[7],C[S+14]=M(w[8],h),_[S+15]=T[3],_[S+16]=T[4],C[S+17]=M(T[5],h),this.vertexCount+=6;E.length=0},batchLine:function(t,e,i,s,n,r,a,o,h,l,c,d,f,p,g,m,v,y,x,w,T){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var S=T[0],b=T[1],A=T[2],E=T[3],_=g*S+m*A,C=g*b+m*E,M=v*S+y*A,P=v*b+y*E,k=x*S+w*A+T[4],L=x*b+w*E+T[5],R=this.vertexViewF32,F=this.vertexViewU32,O=o-r,D=h-a,I=Math.sqrt(O*O+D*D),B=l*(h-a)/I,N=l*(r-o)/I,U=c*(h-a)/I,Y=c*(r-o)/I,X=o-U,z=h-Y,G=r-B,V=a-N,H=o+U,W=h+Y,j=r+B,q=a+N,K=X*_+z*M+k,J=X*C+z*P+L,Z=G*_+V*M+k,Q=G*C+V*P+L,$=H*_+W*M+k,tt=H*C+W*P+L,et=j*_+q*M+k,it=j*C+q*P+L,st=u.getTintAppendFloatAlphaAndSwap,nt=st(d,p),rt=st(f,p),at=this.vertexCount*this.vertexComponentCount;return R[at+0]=K,R[at+1]=J,F[at+2]=rt,R[at+3]=Z,R[at+4]=Q,F[at+5]=nt,R[at+6]=$,R[at+7]=tt,F[at+8]=rt,R[at+9]=Z,R[at+10]=Q,F[at+11]=nt,R[at+12]=et,R[at+13]=it,F[at+14]=nt,R[at+15]=$,R[at+16]=tt,F[at+17]=rt,this.vertexCount+=6,[K,J,f,Z,Q,d,$,tt,f,et,it,d]},batchGraphics:function(t,e,i){if(!(t.commandBuffer.length<=0)){var s=null;i&&(s=i.matrix),this.renderer.setPipeline(this);var r,a,o,h,u,l,v,y,x=e.scrollX*t.scrollFactorX,w=e.scrollY*t.scrollFactorY,T=t.x,S=t.y,b=t.scaleX,A=t.scaleY,E=t.rotation,_=t.commandBuffer,C=t.alpha,M=1,P=1,k=0,L=0,R=1,F=e.matrix.matrix,O=null,D=0,I=0,B=0,N=0,U=0,Y=0,X=0,z=0,G=0,V=0,H=null,W=Math.sin,j=Math.cos,q=2*Math.PI,K=W(E),J=j(E),Z=J*b,Q=K*b,$=-K*A,tt=J*A,et=T,it=S,st=F[0],nt=F[1],rt=F[2],at=F[3],ot=F[4],ht=F[5];if(s){var ut=s[0],lt=s[1],ct=s[2],dt=s[3],ft=s[4],pt=s[5],gt=-x,mt=-w,vt=ut*st+lt*rt,yt=ut*nt+lt*at,xt=ct*st+dt*rt,wt=ct*nt+dt*at;r=Z*vt+Q*xt,a=Z*yt+Q*wt,o=$*vt+tt*xt,h=$*yt+tt*wt,u=et*vt+it*xt+(ft*st+pt*rt+(gt*st+mt*rt+ot)),l=et*yt+it*wt+(ft*nt+pt*at+(gt*nt+mt*at+ht))}else r=Z*st+Q*rt,a=Z*nt+Q*at,o=$*st+tt*rt,h=$*nt+tt*at,u=(et-=x)*st+(it-=w)*rt+ot,l=et*nt+it*at+ht;m.length=0;for(var Tt=0,St=_.length;Tt0&&(G=G%q-q):G>q?G=q:G<0&&(G=q+G%q);D<1;)I=U+j(N=G*D+z)*X,B=Y+W(N)*X,O.points.push(new c(I,B,R,k,M*C)),D+=.01;I=U+j(N=G+z)*X,B=Y+W(N)*X,O.points.push(new c(I,B,R,k,M*C)),Tt+=6;break;case n.LINE_STYLE:R=_[Tt+1],k=_[Tt+2],M=_[Tt+3],Tt+=3;break;case n.FILL_STYLE:L=_[Tt+1],P=_[Tt+2],Tt+=2;break;case n.BEGIN_PATH:m.length=0,O=null;break;case n.CLOSE_PATH:O&&O.points.length&&O.points.push(O.points[0]);break;case n.FILL_PATH:for(v=0,y=m.length;v=0&&s>=0;return r[0]===t&&r[1]===e&&r[2]===i&&r[3]===s||this.flush(),r[0]=t,r[1]=e,r[2]=i,r[3]=s,this.currentScissorEnabled=a,a?(n.disable(n.SCISSOR_TEST),this):(n.enable(n.SCISSOR_TEST),n.scissor(t,n.drawingBufferHeight-e-s,i,s),this)},pushScissor:function(t,e,i,s){var n=this.scissorStack,r=this.currentScissorIdx,a=this.currentScissor;return n[r+0]=a[0],n[r+1]=a[1],n[r+2]=a[2],n[r+3]=a[3],this.currentScissorIdx+=4,this.setScissor(t,e,i,s),this},popScissor:function(){var t=this.scissorStack,e=this.currentScissorIdx-4,i=t[e+0],s=t[e+1],n=t[e+2],r=t[e+3];return this.currentScissorIdx=e,this.setScissor(i,s,n,r),this},setPipeline:function(t){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==n.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t),this},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl;return t!==this.currentFramebuffer&&(this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,s){var a=this.gl,o=a.NEAREST,h=a.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,r(e,i)&&(h=a.REPEAT),s===n.ScaleModes.LINEAR?o=a.LINEAR:(s===n.ScaleModes.NEAREST||this.config.pixelArt)&&(o=a.NEAREST),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,o,o,h,h,a.RGBA,t):this.createTexture2D(0,o,o,h,h,a.RGBA,null,e,i)},createTexture2D:function(t,e,i,s,n,r,a,o,h,u){var l=this.gl,c=l.createTexture();return u=void 0===u||null===u||u,this.setTexture2D(c,0),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,e),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,i),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,n),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,s),l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,u),null===a||void 0===a?l.texImage2D(l.TEXTURE_2D,t,r,o,h,0,r,l.UNSIGNED_BYTE,null):(l.texImage2D(l.TEXTURE_2D,t,r,r,l.UNSIGNED_BYTE,a),o=a.width,h=a.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=u,c.isRenderTexture=!1,c.width=o,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,s){var n,r=this.gl,a=r.createFramebuffer();if(this.setFramebuffer(a),s){var o=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,o),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,o)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(n=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[n])}return a.renderTexture=i,this.setFramebuffer(null),a},createProgram:function(t,e){var i=this.gl,s=i.createProgram(),n=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(n,t),i.shaderSource(r,e),i.compileShader(n),i.compileShader(r),!i.getShaderParameter(n,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(n));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(s,n),i.attachShader(s,r),i.linkProgram(s),!i.getProgramParameter(s,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(s));return s},createVertexBuffer:function(t,e){var i=this.gl,s=i.createBuffer();return this.setVertexBuffer(s),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),s},createIndexBuffer:function(t,e){var i=this.gl,s=i.createBuffer();return this.setIndexBuffer(s),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),s},deleteTexture:function(t){var e=this.nativeTextures.indexOf(t);return-1!==e&&a(this.nativeTextures,e),this.gl.deleteTexture(t),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=this.config.resolution,i=Math.floor(t.x*e),s=Math.floor(t.y*e),n=Math.floor(t.width*e),r=Math.floor(t.height*e);if(this.pushScissor(i,s,n,r),t.backgroundColor.alphaGL>0){var a=t.backgroundColor,h=this.pipelines.FlatTintPipeline;h.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,o.getTintFromFloats(a.redGL,a.greenGL,a.blueGL,1),a.alphaGL,1,0,0,1,0,0,[1,0,0,1,0,0]),h.flush()}},postRenderCamera:function(t){var e=this.pipelines.FlatTintPipeline,i=t.flashEffect.postRenderWebGL(e,o.getTintFromFloats);(t.fadeEffect.postRenderWebGL(e,o.getTintFromFloats)||i)&&e.flush(),this.popScissor()},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var s in t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),this.config.clearBeforeRender&&t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),i)i[s].onPreRender()}},render:function(t,e,i,s){if(!this.contextLost){var r=e.list,a=r.length,o=this.pipelines;for(var h in o)o[h].onRender(t,s);this.preRenderCamera(s);for(var u=0;u16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var s=i(30),n=i(282);t.exports=function(t){var e=n(t);return new s(e.r,e.g,e.b,e.a)}},function(t,e){t.exports=function(t,e,i,s){return s<<24|t<<16|e<<8|i}},function(t,e,i){var s=i(30);t.exports=function(t){var e=new s;t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,s){return e+e+i+i+s+s});var i=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(i){var n=parseInt(i[1],16),r=parseInt(i[2],16),a=parseInt(i[3],16);e.setTo(n,r,a)}return e}},,,,function(t,e){t.exports=function(t,e){void 0===e&&(e=1);for(var i=null,s=0;s>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e0;i--){var s=Math.floor(this.frac()*(e+1)),n=t[s];t[s]=t[i],t[i]=n}return t}});t.exports=s},function(t,e,i){var s=i(136),n=i(65),r=i(16),a=i(5);t.exports=function(t,e,i){void 0===i&&(i=new a);var o=n(e,0,r.PI2);return s(t,o,i)}},,,,function(t,e,i){var s=new(i(0))({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.once("remove",this.remove,this),this.isPlaying=!1,this.currentAnim=null,this.currentFrame=null,this._timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this._delay=0,this._repeat=0,this._repeatDelay=0,this._yoyo=!1,this.forward=!0,this.accumulator=0,this.nextTick=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._pendingStop=0,this._pendingStopValue},setDelay:function(t){return void 0===t&&(t=0),this._delay=t,this.parent},getDelay:function(){return this._delay},delayedPlay:function(t,e,i){return this.play(e,!0,i),this.nextTick+=t,this.parent},getCurrentKey:function(){if(this.currentAnim)return this.currentAnim.key},load:function(t,e){return void 0===e&&(e=0),this.isPlaying&&this.stop(),this.animationManager.load(this,t,e),this.parent},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.updateFrame(t),this.parent},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.updateFrame(t),this.parent},isPaused:{get:function(){return this._paused}},play:function(t,e,i){if(void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t)return this.parent;this.load(t,i);var s=this.currentAnim,n=this.parent;return this.repeatCounter=-1===this._repeat?Number.MAX_VALUE:this._repeat,s.getFirstTick(this),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,s.showOnStart&&(n.visible=!0),n.emit("animationstart",this.currentAnim,this.currentFrame),n},getProgress:function(){var t=this.currentFrame.progress;return this.forward||(t=1-t),t},setProgress:function(t){return this.forward||(t=1-t),this.setCurrentFrame(this.currentAnim.getFrameByProgress(t)),this.parent},remove:function(t,e){void 0===e&&(e=this.currentAnim),this.isPlaying&&e.key===this.currentAnim.key&&(this.stop(),this.setCurrentFrame(this.currentAnim.frames[0]))},getRepeat:function(){return this._repeat},setRepeat:function(t){return this._repeat=t,this.repeatCounter=0,this.parent},getRepeatDelay:function(){return this._repeatDelay},setRepeatDelay:function(t){return this._repeatDelay=t,this.parent},restart:function(t){return void 0===t&&(t=!1),this.currentAnim.getFirstTick(this,t),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,this._paused=!1,this.updateFrame(this.currentAnim.frames[0]),this.parent},stop:function(){this._pendingStop=0,this.isPlaying=!1;var t=this.parent;return t.emit("animationcomplete",this.currentAnim,this.currentFrame),t},stopAfterDelay:function(t){return this._pendingStop=1,this._pendingStopValue=t,this.parent},stopOnRepeat:function(){return this._pendingStop=2,this.parent},stopOnFrame:function(t){return this._pendingStop=3,this._pendingStopValue=t,this.parent},setTimeScale:function(t){return void 0===t&&(t=1),this._timeScale=t,this.parent},getTimeScale:function(){return this._timeScale},getTotalFrames:function(){return this.currentAnim.frames.length},update:function(t,e){if(this.currentAnim&&this.isPlaying&&!this.currentAnim.paused){if(this.accumulator+=e*this._timeScale,1===this._pendingStop&&(this._pendingStopValue-=e,this._pendingStopValue<=0))return this.currentAnim.completeAnimation(this);this.accumulator>=this.nextTick&&this.currentAnim.setFrame(this)}},setCurrentFrame:function(t){var e=this.parent;return this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,e.setSizeToFrame(),t.frame.customPivot?e.setOrigin(t.frame.pivotX,t.frame.pivotY):e.updateDisplayOrigin(),e},updateFrame:function(t){var e=this.setCurrentFrame(t);if(this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;e.emit("animationupdate",i,t),3===this._pendingStop&&this._pendingStopValue===t&&this.currentAnim.completeAnimation(this)}},setYoyo:function(t){return void 0===t&&(t=!1),this._yoyo=t,this.parent},getYoyo:function(){return this._yoyo},destroy:function(){this.animationManager.off("remove",this.remove,this),this.animationManager=null,this.parent=null,this.currentAnim=null,this.currentFrame=null}});t.exports=s},function(t,e,i){var s=i(0),n=i(161),r=i(12),a=i(160),o=i(61),h=i(72),u=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.timeScale=1,this._add=[],this._pending=[],this._active=[],this._destroy=[],this._toProcess=0,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.systems.events.once("destroy",this.destroy,this)},start:function(){var t=this.systems.events;t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this),this.timeScale=1},createTimeline:function(t){return a(this,t)},timeline:function(t){var e=a(this,t);return e.paused||(this._add.push(e),this._toProcess++),e},create:function(t){return h(this,t)},add:function(t){var e=h(this,t);return this._add.push(e),this._toProcess++,e},existing:function(t){return this._add.push(t),this._toProcess++,this},addCounter:function(t){var e=n(this,t);return this._add.push(e),this._toProcess++,e},preUpdate:function(){if(0!==this._toProcess){var t,e,i=this._destroy,s=this._active;for(t=0;t-1&&this._active.splice(n,1),s.destroy()}for(i=0;i=s.delay)){var n=s.elapsed-s.delay;s.elapsed=s.delay,!s.hasDispatched&&s.callback&&(s.hasDispatched=!0,s.callback.apply(s.callbackScope,s.args)),s.repeatCount>0?(s.repeatCount--,s.elapsed=n,s.hasDispatched=!1):this._pendingRemoval.push(s)}}}},shutdown:function(){var t;for(t=0;t=this._duration&&this.transitionComplete()},transitionComplete:function(){var t=this._target.sys,e=this._target.sys.settings;this.systems.events.off("update",this.step,this),t.events.emit("transitioncomplete",this.scene),e.isTransition=!1,e.transitionFrom=null,this._duration=0,this._target=null,this._onUpdate=null,this._onUpdateScope=null,this._willRemove?this.manager.remove(this.key):this._willSleep?this.systems.sleep():this.manager.stop(this.key)},add:function(t,e,i){return this.manager.add(t,e,i),this},launch:function(t,e){return t&&t!==this.key&&(this.settings.status!==r.RUNNING?this.manager.queueOp("start",t,e):this.manager.start(t,e)),this},run:function(t,e){return this.settings.status!==r.RUNNING?this.manager.queueOp("run",t,e):this.manager.run(t,e),this},pause:function(t){return void 0===t&&(t=this.key),this.manager.pause(t),this},resume:function(t){return void 0===t&&(t=this.key),this.manager.resume(t),this},sleep:function(t){return void 0===t&&(t=this.key),this.manager.sleep(t),this},wake:function(t){return void 0===t&&(t=this.key),this.manager.wake(t),this},switch:function(t){return t!==this.key&&(this.settings.status!==r.RUNNING?this.manager.queueOp("switch",this.key,t):this.manager.switch(this.key,t)),this},stop:function(t){return void 0===t&&(t=this.key),this.manager.stop(t),this},setActive:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setActive(t),this},setVisible:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setVisible(t),this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},getIndex:function(t){return void 0===t&&(t=this.key),this.manager.getIndex(t)},shutdown:function(){var t=this.systems.events;t.off("shutdown",this.shutdown,this),t.off("postupdate",this.step,this),t.off("transitionout")},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null,this.settings=null,this.manager=null}});o.register("ScenePlugin",h,"scenePlugin"),t.exports=h},function(t,e,i){var s=i(55),n=i(17),r={SceneManager:i(194),ScenePlugin:i(327),Settings:i(192),Systems:i(118)};r=n(!1,r,s),t.exports=r},function(t,e,i){var s=i(165),n=new(i(0))({Extends:s,initialize:function(t,e){s.call(this,e),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this)},boot:function(){}});t.exports=n},function(t,e,i){t.exports={BasePlugin:i(165),DefaultPlugins:i(121),PluginCache:i(12),PluginManager:i(196),ScenePlugin:i(329)}},,,,,,,,,,,,,,,,,,,,,,,function(t,e,i){var s=i(0),n=i(18),r=i(70),a=i(9),o=i(7),h=i(1),u=i(12),l=i(75),c=new s({Extends:a,initialize:function(t){a.call(this);var e=t.sys.game.config,i=t.sys.settings.loader;this.scene=t,this.systems=t.sys,this.cacheManager=t.sys.cache,this.textureManager=t.sys.textures,o.install(this),this.prefix="",this.path="",this.baseURL="",this.setBaseURL(h(i,"baseURL",e.loaderBaseURL)),this.setPath(h(i,"path",e.loaderPath)),this.setPrefix(h(i,"prefix",e.loaderPrefix)),this.maxParallelDownloads=h(i,"maxParallelDownloads",e.loaderMaxParallelDownloads),this.xhr=l(h(i,"responseType",e.loaderResponseType),h(i,"async",e.loaderAsync),h(i,"user",e.loaderUser),h(i,"password",e.loaderPassword),h(i,"timeout",e.loaderTimeout)),this.crossOrigin=h(i,"crossOrigin",e.loaderCrossOrigin),this.totalToLoad=0,this.progress=0,this.list=new r,this.inflight=new r,this.queue=new r,this._deleteQueue=new r,this.totalFailed=0,this.totalComplete=0,this.state=n.LOADER_IDLE,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.pluginStart,this)},boot:function(){this.systems.events.once("destroy",this.destroy,this)},pluginStart:function(){this.systems.events.once("shutdown",this.shutdown,this)},setBaseURL:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.baseURL=t,this},setPath:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.path=t,this},setPrefix:function(t){return void 0===t&&(t=""),this.prefix=t,this},setCORS:function(t){return this.crossOrigin=t,this},addFile:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e0},isLoading:function(){return this.state===n.LOADER_LOADING||this.state===n.LOADER_PROCESSING},isReady:function(){return this.state===n.LOADER_IDLE||this.state===n.LOADER_COMPLETE},start:function(){this.isReady()&&(this.progress=0,this.totalFailed=0,this.totalComplete=0,this.totalToLoad=this.list.size,this.emit("start",this),0===this.list.size?this.loadComplete():(this.state=n.LOADER_LOADING,this.inflight.clear(),this.queue.clear(),this.updateProgress(),this.checkLoadQueue(),this.systems.events.on("update",this.update,this)))},updateProgress:function(){this.progress=1-(this.list.size+this.inflight.size)/this.totalToLoad,this.emit("progress",this.progress)},update:function(){this.state===n.LOADER_LOADING&&this.list.size>0&&this.inflight.size0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(n=!0,i=s(t,e))}else n=!0,i=s(t,e);return!n&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e,i){var s=i(0),n=i(9),r=i(4),a=i(76),o=i(171),h=i(109),u=i(170),l=i(369),c=i(368),d=i(367),f=new s({Extends:n,initialize:function(t){n.call(this),this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.enabled=!0,this.target,this.keys=[],this.combos=[],this.queue=[],this.onKeyHandler,t.pluginEvents.once("boot",this.boot,this),t.pluginEvents.on("start",this.start,this)},boot:function(){var t=this.settings.input,e=this.scene.sys.game.config;this.enabled=r(t,"keyboard",e.inputKeyboard),this.target=r(t,"keyboard.target",e.inputKeyboardEventTarget),this.sceneInputPlugin.pluginEvents.once("destroy",this.destroy,this)},start:function(){this.enabled&&this.startListeners(),this.sceneInputPlugin.pluginEvents.once("shutdown",this.shutdown,this)},isActive:function(){return this.enabled&&this.scene.sys.isActive()},startListeners:function(){var t=this,e=function(e){if(!e.defaultPrevented&&t.isActive()){t.queue.push(e);var i=t.keys[e.keyCode];i&&i.preventDefault&&e.preventDefault()}};this.onKeyHandler=e,this.target.addEventListener("keydown",e,!1),this.target.addEventListener("keyup",e,!1),this.sceneInputPlugin.pluginEvents.on("update",this.update,this)},stopListeners:function(){this.target.removeEventListener("keydown",this.onKeyHandler),this.target.removeEventListener("keyup",this.onKeyHandler),this.sceneInputPlugin.pluginEvents.off("update",this.update)},createCursorKeys:function(){return this.addKeys({up:h.UP,down:h.DOWN,left:h.LEFT,right:h.RIGHT,space:h.SPACE,shift:h.SHIFT})},addKeys:function(t){var e={};if("string"==typeof t){t=t.split(",");for(var i=0;i-1?e[i]=t:e[t.keyCode]=t,t}return"string"==typeof t&&(t=h[t.toUpperCase()]),e[t]||(e[t]=new o(t)),e[t]},removeKey:function(t){var e=this.keys;if(t instanceof o){var i=e.indexOf(t);i>-1&&(this.keys[i]=void 0)}else"string"==typeof t&&(t=h[t.toUpperCase()]);e[t]&&(e[t]=void 0)},createCombo:function(t,e){return new u(this,t,e)},update:function(){var t=this.queue.length;if(this.enabled&&0!==t)for(var e=this.queue.splice(0,t),i=this.keys,s=0;s=e}}},function(t,e,i){var s=i(88),n=i(32),r=i(0),a=i(175),o=i(375),h=i(58),u=i(114),l=i(54),c=i(9),d=i(1),f=i(76),p=i(8),g=i(12),m=i(14),v=i(31),y=i(68),x=i(60),w=new r({Extends:c,initialize:function(t){c.call(this),this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.manager=t.sys.game.input,this.pluginEvents=new c,this.enabled=!0,this.displayList,this.cameras,f.install(this),this.mouse=this.manager.mouse,this.topOnly=!0,this.pollRate=-1,this._pollTimer=0,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this._temp=[],this._tempZones=[],this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],this._draggable=[],this._drag={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._over={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._validTypes=["onDown","onUp","onOver","onOut","onMove","onDragStart","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop"],t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.cameras=this.systems.cameras,this.displayList=this.systems.displayList,this.systems.events.once("destroy",this.destroy,this),this.pluginEvents.emit("boot")},start:function(){var t=this.systems.events;t.on("transitionstart",this.transitionIn,this),t.on("transitionout",this.transitionOut,this),t.on("transitioncomplete",this.transitionComplete,this),t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this),this.enabled=!0,this.pluginEvents.emit("start")},preUpdate:function(){this.pluginEvents.emit("preUpdate");var t=this._pendingRemoval,e=this._pendingInsertion,i=t.length,s=e.length;if(0!==i||0!==s){for(var n=this._list,r=0;r-1&&(n.splice(o,1),this.clear(a))}t.length=0,this._pendingRemoval.length=0,this._list=n.concat(e.splice(0))}},isActive:function(){return this.enabled&&this.scene.sys.isActive()},update:function(t,e){if(this.isActive()){this.pluginEvents.emit("update",t,e);var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var s=i.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(s=!0,this._pollTimer=this.pollRate)),s)for(var n=this.manager.pointers,r=0;r0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}}},clear:function(t){var e=t.input;if(e){this.queueForRemoval(t),e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t}},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,s){return void 0===s&&(s=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input&&s&&!t.input.dropZone&&(t.input.dropZone=s),this},hitTestPointer:function(t){for(var e=this.cameras.getCamerasBelowPointer(t),i=0;i0)return t.camera=s,n}return[]},processDownEvents:function(t){var e=this._temp;this.emit("pointerdown",t,e);for(var i=0,s=0;s0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var o=[];for(i=0;i1&&(this.sortGameObjects(o),this.topOnly&&o.splice(1)),this._drag[t.id]=o,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&h(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(n=this._drag[t.id],i=0;i0?(s.emit("dragleave",t,r.target),this.emit("dragleave",t,s,r.target),r.target=u[0],s.emit("dragenter",t,r.target),this.emit("dragenter",t,s,r.target)):(s.emit("dragleave",t,r.target),this.emit("dragleave",t,s,r.target),u[0]?(r.target=u[0],s.emit("dragenter",t,r.target),this.emit("dragenter",t,s,r.target)):r.target=null)}else!r.target&&u[0]&&(r.target=u[0],s.emit("dragenter",t,r.target),this.emit("dragenter",t,s,r.target));var c=t.x-s.input.dragX,d=t.y-s.input.dragY;s.emit("drag",t,c,d),this.emit("drag",t,s,c,d)}return n.length}if(5===t.dragState){for(n=this._drag[t.id],i=0;i0)for(this.sortGameObjects(n),this.emit("pointerout",t,n),e=0;e0)for(this.sortGameObjects(r),this.emit("pointerover",t,r),e=0;e-1&&this._draggable.splice(n,1)}return this},makePixelPerfect:function(t){void 0===t&&(t=1);var e=this.systems.textures;return o(e,t)},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);var s=!1,n=!1,r=!1,o=!1;if(p(e)){var h=e;e=d(h,"hitArea",null),i=d(h,"hitAreaCallback",null),s=d(h,"draggable",!1),n=d(h,"dropZone",!1),r=d(h,"cursor",!1),o=d(h,"useHandCursor",!1);var u=d(h,"pixelPerfect",!1),l=d(h,"alphaTolerance",1);u&&(e={},i=this.makePixelPerfect(l)),e&&i||this.setHitAreaFromTexture(t)}else"function"!=typeof e||i||(i=e,e={});for(var c=0;cr;h--){for(u=0;u0&&e.cameraFilter&n._id||""===e.text)){var a=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,a.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,a.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var o=e.canvas;if(a.save(),void 0!==r){var h=r.matrix;a.transform(h[0],h[1],h[2],h[3],h[4],h[5])}var u=e.x-n.scrollX*e.scrollFactorX,l=e.y-n.scrollY*e.scrollFactorY;t.config.roundPixels&&(u|=0,l|=0),a.translate(u,l),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY),a.translate(o.width*(e.flipX?1:0),o.height*(e.flipY?1:0)),a.scale(e.flipX?-1:1,e.flipY?-1:1),a.drawImage(o,0,0,o.width,o.height,-e.displayOriginX,-e.displayOriginY,o.width,o.height),a.restore()}}},function(t,e,i){var s=i(2);t.exports=function(t,e,i,n,r){s.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&n._id||""===e.text||(e.dirty&&(e.canvasTexture=t.canvasToTexture(e.canvas,e.canvasTexture),e.dirty=!1),this.pipeline.batchText(this,n,r))}},function(t,e,i){var s=i(3),n=i(3);s=i(415),n=i(414),t.exports={renderWebGL:s,renderCanvas:n}},function(t,e){t.exports=function(t,e,i){var s=t.canvas,n=t.context,r=t.style,a=[],o=0,h=i.length;r.maxLines>0&&r.maxLinesc&&(f=-c),0!==f&&(d+=f>0?f*i.length:f*(i.length-1)),{width:o,height:d,lines:h,lineWidths:a,lineSpacing:f,lineHeight:c}}},,,,function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t<=0?0:t>=1?1:1/e*(1+(e*t|0))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var s=i/4;return e<1?e=1:s=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-s)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-s)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var s=i/4;return e<1?e=1:s=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-s)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var s=i/4;return e<1?e=1:s=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-s)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e,i){var s=i(247),n=i(246),r=i(245),a=i(244),o=i(243),h=i(242),u=i(241),l=i(240),c=i(239),d=i(238),f=i(237),p=i(236);t.exports={Power0:u,Power1:l.Out,Power2:a.Out,Power3:c.Out,Power4:d.Out,Linear:u,Quad:l.Out,Cubic:a.Out,Quart:c.Out,Quint:d.Out,Sine:f.Out,Expo:h.Out,Circ:r.Out,Elastic:o.Out,Back:s.Out,Bounce:n.Out,Stepped:p,"Quad.easeIn":l.In,"Cubic.easeIn":a.In,"Quart.easeIn":c.In,"Quint.easeIn":d.In,"Sine.easeIn":f.In,"Expo.easeIn":h.In,"Circ.easeIn":r.In,"Elastic.easeIn":o.In,"Back.easeIn":s.In,"Bounce.easeIn":n.In,"Quad.easeOut":l.Out,"Cubic.easeOut":a.Out,"Quart.easeOut":c.Out,"Quint.easeOut":d.Out,"Sine.easeOut":f.Out,"Expo.easeOut":h.Out,"Circ.easeOut":r.Out,"Elastic.easeOut":o.Out,"Back.easeOut":s.Out,"Bounce.easeOut":n.Out,"Quad.easeInOut":l.InOut,"Cubic.easeInOut":a.InOut,"Quart.easeInOut":c.InOut,"Quint.easeInOut":d.InOut,"Sine.easeInOut":f.InOut,"Expo.easeInOut":h.InOut,"Circ.easeInOut":r.InOut,"Elastic.easeInOut":o.InOut,"Back.easeInOut":s.InOut,"Bounce.easeInOut":n.InOut}},,,,,,function(t,e,i){var s=i(2);t.exports=function(t,e,i,n,r){s.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&n._id||t.drawImage(e,n,r)}},function(t,e,i){var s=i(2);t.exports=function(t,e,i,n,r){s.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&n._id||this.pipeline.batchSprite(e,n,r)}},function(t,e,i){var s=i(3),n=i(3);s=i(460),n=i(459),t.exports={renderWebGL:s,renderCanvas:n}},function(t,e,i){var s=i(2);t.exports=function(t,e,i,n,r){s.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&n._id||this.pipeline.batchGraphics(this,n,r)}},function(t,e,i){var s=i(3),n=i(3);s=i(462),n=i(176),n=i(176),t.exports={renderWebGL:s,renderCanvas:n}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var s=i(14);t.exports=function(t,e){return void 0===e&&(e=new s),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e,i){var s=i(54);t.exports=function(t,e){return s(t,e.x,e.y)&&s(t,e.right,e.y)&&s(t,e.x,e.bottom)&&s(t,e.right,e.bottom)}},function(t,e,i){var s=i(54);t.exports=function(t,e){return s(t,e.x,e.y)}},function(t,e,i){var s=i(114);t.exports=function(t){return new s(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},,,,function(t,e,i){var s=i(0),n=i(12),r=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.systems.events.once("destroy",this.destroy,this)},start:function(){var t=this.systems.events;t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this)},add:function(t){return-1===this._list.indexOf(t)&&-1===this._pendingInsertion.indexOf(t)&&this._pendingInsertion.push(t),t},preUpdate:function(){var t=this._pendingRemoval.length,e=this._pendingInsertion.length;if(0!==t||0!==e){var i,s;for(i=0;i-1&&this._list.splice(n,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;i0&&(t.splice(i,1),t.unshift(e)),e}},function(t,e){t.exports=function(t,e,i){var s=t.indexOf(e),n=t.indexOf(i);return-1!==s&&-1===n&&(t[s]=i,!0)}},function(t,e,i){var s=i(56);t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var n=e+Math.floor(Math.random()*i);return s(t,n)}},function(t,e,i){var s=i(29);t.exports=function(t,e,i,n,r){if(void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===r&&(r=t),s(t,e,i)){var a=i-e,o=t.splice(e,a);if(n)for(var h=0;ht.length-1)throw new Error("Index out of bounds");var r=s(t,e);return i&&i.call(n,r),r}},function(t,e,i){var s=i(255);t.exports=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=null),void 0===i&&(i=1),null===e&&(e=t,t=0);for(var n=[],r=Math.max(s((e-t)/(i||1)),0),a=0;a=t.length)throw new Error("Supplied index out of bounds");return s!==i&&(t.splice(s,1),t.splice(i,0,e)),e}},function(t,e){t.exports=function(t,e){var i=t.indexOf(e);if(i>0){var s=t[i-1],n=t.indexOf(s);t[i]=s,t[n]=e}return t}},function(t,e,i){var s=i(29);t.exports=function(t,e,i,n,r){if(void 0===n&&(n=0),void 0===r&&(r=t.length),s(t,n,r))for(var a=n;a0){var a=s-t.length;if(a<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.splice(i,0,e),n&&n.call(r,e),e):null;for(var o=e.length-1;o>=0;)-1!==t.indexOf(e[o])&&e.pop(),o--;if(0===(o=e.length))return null;s>0&&o>a&&(e.splice(a),o=a);for(var h=o;h>0;h--){var u=e[h];t.splice(i,0,u),n&&n.call(r,u)}return e}},function(t,e){t.exports=function(t,e,i,s,n){if(void 0===n&&(n=t),i>0){var r=i-t.length;if(r<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.push(e),s&&s.call(n,e),e):null;for(var a=e.length-1;a>=0;)-1!==t.indexOf(e[a])&&e.pop(),a--;if(0===(a=e.length))return null;i>0&&a>r&&(e.splice(r),a=r);for(var o=0;o0||!this.inFocus)&&(this._coolDown--,r=Math.min(r,this._target)),r>this._min&&(r=s[i],r=Math.min(r,this._min)),s[i]=r,this.deltaIndex++,this.deltaIndex>n&&(this.deltaIndex=0);for(var a=0,o=0;othis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var h=a/this._target;this.callback(t,a,h),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=o},function(t,e){var i=0,s=function(t,e,s,n){var r=i-n.y-n.height;t.add(s,e,n.x,r,n.width,n.height)};t.exports=function(t,e,n){var r=t.source[e];t.add("__BASE",e,0,0,r.width,r.height),i=r.height;for(var a=n.split("\n"),o=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",u="",l={x:0,y:0,width:0,height:0},c=0;cx||o<-x)&&(o=0),o<0&&(o=x+o),-1!==h&&(x=o+(h+1));for(var _=u,C=u,M=0,P=e.sourceIndex,k=0;kg||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var m=f,v=f,y=0,x=0,w=0;wr&&(y=T-r),S>a&&(x=S-a),t.add(w,e,i+m,n+v,h-y,u-x),(m+=h+p)+h>r&&(m=f,v+=u+p)}return t}},function(t,e,i){var s=i(33);t.exports=function(t,e,i){if(i.frames){var n=t.source[e];t.add("__BASE",e,0,0,n.width,n.height);var r,a=i.frames;for(var o in a){var h=a[o];r=t.add(o,e,h.frame.x,h.frame.y,h.frame.w,h.frame.h),h.trimmed&&r.setTrim(h.sourceSize.w,h.sourceSize.h,h.spriteSourceSize.x,h.spriteSourceSize.y,h.spriteSourceSize.w,h.spriteSourceSize.h),h.rotated&&(r.rotated=!0,r.updateUVsInverted()),r.customData=s(h)}for(var u in i)"frames"!==u&&(Array.isArray(i[u])?t.customData[u]=i[u].slice(0):t.customData[u]=i[u]);return t}console.warn("Invalid Texture Atlas JSON Hash given, missing 'frames' Object")}},function(t,e,i){var s=i(33);t.exports=function(t,e,i){if(i.frames||i.textures){var n=t.source[e];t.add("__BASE",e,0,0,n.width,n.height);for(var r,a=Array.isArray(i.textures)?i.textures[e].frames:i.frames,o=0;o=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(n.dolby=!0)}}catch(t){}return n}()},function(t,e,i){var s=i(57),n=i(80),r={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),s.cocoonJS||("onwheel"in window||n.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":n.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){t.exports={os:i(57),browser:i(80),features:i(120),input:i(522),audio:i(521),video:i(520),fullscreen:i(519),canvasFeatures:i(203)}},function(t,e,i){var s=i(20);t.exports=function(t){var e=t.config;if(!e.hideBanner){var i="WebGL";e.renderType===s.CANVAS?i="Canvas":e.renderType===s.HEADLESS&&(i="Headless");var n,r=e.audio,a=t.device.audio;if(n=!a.webAudio||r&&r.disableWebAudio?r&&r.noAudio||!a.webAudio&&!a.audioData?"No Audio":"HTML5 Audio":"Web Audio",t.device.browser.ie)window.console&&console.log("Phaser v"+s.VERSION+" / https://phaser.io");else{var o,h="",u=[h];Array.isArray(e.bannerBackgroundColor)?(e.bannerBackgroundColor.forEach(function(t){h=h.concat("%c "),u.push("background: "+t),o=t}),u[u.length-1]="color: "+e.bannerTextColor+"; background: "+o):(h=h.concat("%c "),u.push("color: "+e.bannerTextColor+"; background: "+e.bannerBackgroundColor)),u.push("background: #fff"),e.gameTitle&&(h=h.concat(e.gameTitle),e.gameVersion&&(h=h.concat(" v"+e.gameVersion)),e.hidePhaser||(h=h.concat(" / "))),e.hidePhaser||(h=h.concat("Phaser v"+s.VERSION+" ("+i+" | "+n+")")),h=h.concat(" %c "+e.gameURL),u[0]=h,console.log.apply(console,u)}}}},function(t,e){t.exports=["#define SHADER_NAME PHASER_TEXTURE_TINT_VS","","precision mediump float;","","uniform mat4 uProjectionMatrix;","uniform mat4 uViewMatrix;","uniform mat4 uModelMatrix;","","attribute vec2 inPosition;","attribute vec2 inTexCoord;","attribute vec4 inTint;","","varying vec2 outTexCoord;","varying vec4 outTint;","","void main ()","{"," gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);"," outTexCoord = inTexCoord;"," outTint = inTint;","}","",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_TEXTURE_TINT_FS","","precision mediump float;","","uniform sampler2D uMainSampler;","","varying vec2 outTexCoord;","varying vec4 outTint;","","void main()","{"," vec4 texel = texture2D(uMainSampler, outTexCoord);"," texel *= vec4(outTint.rgb * outTint.a, outTint.a);"," gl_FragColor = texel;","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS","","precision mediump float;","","struct Light","{"," vec2 position;"," vec3 color;"," float intensity;"," float radius;","};","","const int kMaxLights = %LIGHT_COUNT%;","","uniform vec4 uCamera; /* x, y, rotation, zoom */","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uNormSampler;","uniform vec3 uAmbientLightColor;","uniform Light uLights[kMaxLights];","","varying vec2 outTexCoord;","varying vec4 outTint;","","void main()","{"," vec3 finalColor = vec3(0.0, 0.0, 0.0);"," vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);"," vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;"," vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));"," vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;",""," for (int index = 0; index < kMaxLights; ++index)"," {"," Light light = uLights[index];"," vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);"," vec3 lightNormal = normalize(lightDir);"," float distToSurf = length(lightDir) * uCamera.w;"," float diffuseFactor = max(dot(normal, lightNormal), 0.0);"," float radius = (light.radius / res.x * uCamera.w) * uCamera.w;"," float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);"," vec3 diffuse = light.color * diffuseFactor;"," finalColor += (attenuation * diffuse) * light.intensity;"," }",""," vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);"," gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);","","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_FLAT_TINT_VS","","precision mediump float;","","uniform mat4 uProjectionMatrix;","uniform mat4 uViewMatrix;","uniform mat4 uModelMatrix;","","attribute vec2 inPosition;","attribute vec4 inTint;","","varying vec4 outTint;","","void main () {"," gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);"," outTint = inTint;","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_FLAT_TINT_FS","","precision mediump float;","","varying vec4 outTint;","","void main() {"," gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_VS","","precision mediump float;","","attribute vec2 inPosition;","","void main()","{"," gl_Position = vec4(inPosition, 0.0, 1.0);","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_FS","","precision mediump float;","","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uMaskSampler;","uniform bool uInvertMaskAlpha;","","void main()","{"," vec2 uv = gl_FragCoord.xy / uResolution;"," vec4 mainColor = texture2D(uMainSampler, uv);"," vec4 maskColor = texture2D(uMaskSampler, uv);"," float alpha = mainColor.a;",""," if (!uInvertMaskAlpha)"," {"," alpha *= (maskColor.a);"," }"," else"," {"," alpha *= (1.0 - maskColor.a);"," }",""," gl_FragColor = vec4(mainColor.rgb * alpha, alpha);","}",""].join("\n")},function(t,e,i){var s=i(272),n=i(22),r=i(20),a=i(120);t.exports=function(t){var e,o,h=t.config;if(h.renderType!==r.HEADLESS)if(h.renderType===r.CANVAS||h.renderType!==r.CANVAS&&!a.webGL){if(!a.canvas)throw new Error("Cannot create Canvas or WebGL context, aborting.");h.renderType=r.CANVAS}else h.renderType=r.WEBGL;h.pixelArt&&n.disableSmoothing(),h.canvas?t.canvas=h.canvas:t.canvas=n.create(t,h.width,h.height,h.renderType),h.canvasStyle&&(t.canvas.style=h.canvasStyle),h.pixelArt&&s.setCrisp(t.canvas),1!==h.zoom&&(t.canvas.style.width=(h.width*h.zoom).toString()+"px",t.canvas.style.height=(h.height*h.zoom).toString()+"px"),h.renderType!==r.HEADLESS&&(e=i(267),o=i(262),h.renderType===r.WEBGL?(t.renderer=new o(t),t.context=null):(t.renderer=new e(t),t.context=t.renderer.gameContext))}},function(t,e,i){var s=i(0),n=i(20),r=i(1),a=i(4),o=i(8),h=i(16),u=i(3),l=i(121),c=i(132),d=new s({initialize:function(t){void 0===t&&(t={});this.width=a(t,"width",1024),this.height=a(t,"height",768),this.zoom=a(t,"zoom",1),this.resolution=a(t,"resolution",1),this.renderType=a(t,"type",n.AUTO),this.parent=a(t,"parent",null),this.canvas=a(t,"canvas",null),this.context=a(t,"context",null),this.canvasStyle=a(t,"canvasStyle",null),this.sceneConfig=a(t,"scene",null),this.seed=a(t,"seed",[(Date.now()*Math.random()).toString()]),h.RND.init(this.seed),this.gameTitle=a(t,"title",""),this.gameURL=a(t,"url","https://phaser.io"),this.gameVersion=a(t,"version",""),this.autoFocus=a(t,"autoFocus",!0),this.inputKeyboard=a(t,"input.keyboard",!0),this.inputKeyboardEventTarget=a(t,"input.keyboard.target",window),this.inputMouse=a(t,"input.mouse",!0),this.inputMouseEventTarget=a(t,"input.mouse.target",null),this.inputMouseCapture=a(t,"input.mouse.capture",!0),this.inputTouch=a(t,"input.touch",!0),this.inputTouchEventTarget=a(t,"input.touch.target",null),this.inputTouchCapture=a(t,"input.touch.capture",!0),this.inputActivePointers=a(t,"input.activePointers",1),this.inputGamepad=a(t,"input.gamepad",!1),this.inputGamepadEventTarget=a(t,"input.gamepad.target",window),this.disableContextMenu=a(t,"disableContextMenu",!1),this.audio=a(t,"audio"),this.hideBanner=!1===a(t,"banner",null),this.hidePhaser=a(t,"banner.hidePhaser",!1),this.bannerTextColor=a(t,"banner.text","#ffffff"),this.bannerBackgroundColor=a(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=a(t,"fps",null);var e=a(t,"render",t);this.antialias=a(e,"antialias",!0),this.pixelArt=a(e,"pixelArt",!1),this.autoResize=a(e,"autoResize",!1),this.roundPixels=a(e,"roundPixels",!1),this.transparent=a(e,"transparent",!1),this.clearBeforeRender=a(e,"clearBeforeRender",!0),this.premultipliedAlpha=a(e,"premultipliedAlpha",!0),this.preserveDrawingBuffer=a(e,"preserveDrawingBuffer",!1),this.failIfMajorPerformanceCaveat=a(e,"failIfMajorPerformanceCaveat",!1),this.powerPreference=a(e,"powerPreference","default");var i=a(t,"backgroundColor",0);this.backgroundColor=c(i),0===i&&this.transparent&&(this.backgroundColor.alpha=0),this.preBoot=a(t,"callbacks.preBoot",u),this.postBoot=a(t,"callbacks.postBoot",u),this.physics=a(t,"physics",{}),this.defaultPhysicsSystem=a(this.physics,"default",!1),this.loaderBaseURL=a(t,"loader.baseURL",""),this.loaderPath=a(t,"loader.path",""),this.loaderMaxParallelDownloads=a(t,"loader.maxParallelDownloads",32),this.loaderCrossOrigin=a(t,"loader.crossOrigin",void 0),this.loaderResponseType=a(t,"loader.responseType",""),this.loaderAsync=a(t,"loader.async",!0),this.loaderUser=a(t,"loader.user",""),this.loaderPassword=a(t,"loader.password",""),this.loaderTimeout=a(t,"loader.timeout",0),this.installGlobalPlugins=[],this.installScenePlugins=[];var s=a(t,"plugins",null),d=l.DefaultScene;s&&(Array.isArray(s)?this.defaultPlugins=s:o(s)&&(this.installGlobalPlugins=r(s,"global",[]),this.installScenePlugins=r(s,"scene",[]),Array.isArray(s.default)?d=s.default:Array.isArray(s.defaultMerge)&&(d=d.concat(s.defaultMerge)))),this.defaultPlugins=d;var f="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=a(t,"images.default",f+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=a(t,"images.missing",f+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==")}});t.exports=d},function(t,e,i){var s=i(130),n=i(207),r=i(205),a=i(22),o=i(0),h=i(533),u=i(532),l=i(81),c=i(524),d=i(523),f=i(271),p=i(9),g=i(201),m=i(196),v=i(194),y=i(191),x=i(184),w=i(506),T=i(505),S=new o({initialize:function(t){this.config=new h(t),this.renderer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new p,this.anims=new n(this),this.textures=new x(this),this.cache=new r(this),this.registry=new l(this),this.input=new g(this,this.config),this.scene=new v(this,this.config.sceneConfig),this.device=d,this.sound=y.create(this),this.loop=new w(this,this.config.fps),this.plugins=new m(this,this.config),this.pendingDestroy=!1,this.removeCanvas=!1,this.hasFocus=!1,this.isOver=!0,f(this.boot.bind(this))},boot:function(){this.isBooted=!0,this.config.preBoot(this),u(this),c(this),s(this.canvas,this.config.parent),this.events.emit("boot"),this.events.once("ready",this.start,this)},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),T(this);var t=this.events;t.on("hidden",this.onHidden,this),t.on("visible",this.onVisible,this),t.on("blur",this.onBlur,this),t.on("focus",this.onFocus,this)},step:function(t,e){if(this.pendingDestroy)return this.runDestroy();var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e);var s=this.renderer;s.preRender(),i.emit("prerender",s,t,e),this.scene.render(s),s.postRender(),i.emit("postrender",s,t,e)},headlessStep:function(t,e){var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e),i.emit("prerender"),i.emit("postrender")},onHidden:function(){this.loop.pause(),this.events.emit("pause")},onVisible:function(){this.loop.resume(),this.events.emit("resume")},onBlur:function(){this.hasFocus=!1,this.loop.blur()},onFocus:function(){this.hasFocus=!0,this.loop.focus()},resize:function(t,e){this.config.width=t,this.config.height=e,this.renderer.resize(t,e),this.input.resize(),this.scene.resize(t,e),this.events.emit("resize",t,e)},destroy:function(t){this.pendingDestroy=!0,this.removeCanvas=t},runDestroy:function(){this.events.emit("destroy"),this.events.removeAllListeners(),this.scene.destroy(),this.renderer&&this.renderer.destroy(),this.removeCanvas&&this.canvas&&(a.remove(this.canvas),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)),this.loop.destroy(),this.pendingDestroy=!1}});t.exports=S},function(t,e,i){var s=i(0),n=i(9),r=i(12),a=new s({Extends:n,initialize:function(){n.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",a,"events"),t.exports=a},function(t,e,i){t.exports={EventEmitter:i(535)}},function(t,e){var i,s,n=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function o(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{s="function"==typeof clearTimeout?clearTimeout:a}catch(t){s=a}}();var h,u=[],l=!1,c=-1;function d(){l&&h&&(l=!1,h.length?u=h.concat(u):c=-1,u.length&&f())}function f(){if(!l){var t=o(d);l=!0;for(var e=u.length;e;){for(h=u,u=[];++c1)for(var i=1;i0&&e.cameraFilter&n._id||t.drawImage(e,n,r)}},function(t,e,i){var s=i(2);t.exports=function(t,e,i,n,r){s.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&n._id||this.pipeline.batchSprite(e,n,r)}},function(t,e,i){var s=i(3),n=i(3);s=i(555),n=i(554),t.exports={renderWebGL:s,renderCanvas:n}},,,,,,function(t,e,i){var s=i(123),n=i(0),r=i(1),a=i(12),o=i(31),h=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this.currentCameraId=1,this.cameras=[],this.cameraPool=[],this.main,this.baseScale=1,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){var t=this.systems;t.settings.cameras?this.fromJSON(t.settings.cameras):this.add(),this.main=this.cameras[0],this.systems.events.once("destroy",this.destroy,this)},start:function(){this.main||this.boot();var t=this.systems.events;t.on("update",this.update,this),t.once("shutdown",this.shutdown,this)},add:function(t,e,i,n,r,a){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),void 0===r&&(r=!1),void 0===a&&(a="");var o=null;return this.cameraPool.length>0?(o=this.cameraPool.pop()).setViewport(t,e,i,n):o=new s(t,e,i,n),o.setName(a),o.setScene(this.scene),this.cameras.push(o),r&&(this.main=o),o._id=this.currentCameraId,this.currentCameraId=this.currentCameraId<<1,o},addExisting:function(t){var e=this.cameras.indexOf(t),i=this.cameraPool.indexOf(t);return e<0&&i>=0?(this.cameras.push(t),this.cameraPool.slice(i,1),t):null},fromJSON:function(t){Array.isArray(t)||(t=[t]);for(var e=this.scene.sys.game.config.width,i=this.scene.sys.game.config.height,s=0;s=0&&this.cameras.length>1&&(this.cameraPool.push(this.cameras[e]),this.cameras.splice(e,1),this.main===t&&(this.main=this.cameras[0]))},render:function(t,e,i){for(var s=this.cameras,n=this.baseScale,r=0,a=s.length;r0;)this.cameraPool.push(this.cameras.pop());return this.main=this.add(),this.main},update:function(t,e){for(var i=0,s=this.cameras.length;i>16)+(65280&t)+((255&t)<<16)},s={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,clearTint:function(){return this.setTint(16777215),this},setTint:function(t,e,s,n){return void 0===t&&(t=16777215),void 0===e&&(e=t,s=t,n=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(s),this._tintBR=i(n),this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t)}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t)}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t)}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t)}},tint:{set:function(t){this.setTint(t,t,t,t)}}};t.exports=s},function(t,e){var i={texture:null,frame:null,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e,i){var s=i(59),n={_scaleMode:s.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==s.LINEAR&&t!==s.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=n},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e){var i={matrixStack:null,currentMatrix:null,currentMatrixIndex:0,initMatrixStack:function(){return this.matrixStack=new Float32Array(6e3),this.currentMatrix=new Float32Array([1,0,0,1,0,0]),this.currentMatrixIndex=0,this},save:function(){if(this.currentMatrixIndex>=this.matrixStack.length)return this;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return this.currentMatrixIndex+=6,t[i+0]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=e[3],t[i+4]=e[4],t[i+5]=e[5],this},restore:function(){if(this.currentMatrixIndex<=0)return this;this.currentMatrixIndex-=6;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],e[4]=t[i+4],e[5]=t[i+5],this},loadIdentity:function(){return this.setTransform(1,0,0,1,0,0),this},transform:function(t,e,i,s,n,r){var a=this.currentMatrix,o=a[0],h=a[1],u=a[2],l=a[3],c=a[4],d=a[5];return a[0]=o*t+u*e,a[1]=h*t+l*e,a[2]=o*i+u*s,a[3]=h*i+l*s,a[4]=o*n+u*r+c,a[5]=h*n+l*r+d,this},setTransform:function(t,e,i,s,n,r){var a=this.currentMatrix;return a[0]=t,a[1]=e,a[2]=i,a[3]=s,a[4]=n,a[5]=r,this},translate:function(t,e){var i=this.currentMatrix,s=i[0],n=i[1],r=i[2],a=i[3],o=i[4],h=i[5];return i[4]=s*t+r*e+o,i[5]=n*t+a*e+h,this},scale:function(t,e){var i=this.currentMatrix,s=i[0],n=i[1],r=i[2],a=i[3];return i[0]=s*t,i[1]=n*t,i[2]=r*e,i[3]=a*e,this},rotate:function(t){var e=this.currentMatrix,i=e[0],s=e[1],n=e[2],r=e[3],a=Math.sin(t),o=Math.cos(t);return e[0]=i*o+n*a,e[1]=s*o+r*a,e[2]=i*-a+n*o,e[3]=s*-a+r*o,this}};t.exports=i},function(t,e,i){var s=i(214),n=i(213),r={mask:null,setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask.destroy(),this.mask=null,this},createBitmapMask:function(t){return void 0===t&&this.texture&&(t=this),new s(this.scene,t)},createGeometryMask:function(t){return void 0===t&&"Graphics"===this.type&&(t=this),new n(this.scene,t)}};t.exports=r},function(t,e,i){var s=i(14),n=i(292),r=i(6),a={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&n(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getTopRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&n(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&n(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&n(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBounds:function(t){var e,i,n,r,a,o,h,u;if(void 0===t&&(t=new s),this.parentContainer){var l=this.parentContainer.getBoundsTransformMatrix();this.getTopLeft(t),l.transformPoint(t.x,t.y,t),e=t.x,i=t.y,this.getTopRight(t),l.transformPoint(t.x,t.y,t),n=t.x,r=t.y,this.getBottomLeft(t),l.transformPoint(t.x,t.y,t),a=t.x,o=t.y,this.getBottomRight(t),l.transformPoint(t.x,t.y,t),h=t.x,u=t.y}else this.getTopLeft(t),e=t.x,i=t.y,this.getTopRight(t),n=t.x,r=t.y,this.getBottomLeft(t),a=t.x,o=t.y,this.getBottomRight(t),h=t.x,u=t.y;return t.x=Math.min(e,n,a,h),t.y=Math.min(i,r,o,u),t.width=Math.max(e,n,a,h)-t.x,t.height=Math.max(i,r,o,u)-t.y,t}};t.exports=a},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e){var i={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.scene.sys.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=i},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}}},function(t,e,i){var s=i(51),n={_blendMode:s.NORMAL,blendMode:{get:function(){return this._blendMode},set:function(t){"string"==typeof t&&(t=s[t]),(t|=0)>=0&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=n},function(t,e,i){var s=i(23),n={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,n){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=s(t,0,1),this._alphaTR=s(e,0,1),this._alphaBL=s(i,0,1),this._alphaBR=s(n,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=s(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=s(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=s(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=s(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=s(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=n},,,,,,,,,,,,,function(t,e){if("function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var i=function(t){var e=new Array;window[t]=function(t){if("number"==typeof t){Array.call(this,t),this.length=t;for(var e=0;e>>0;if("function"!=typeof t)throw new TypeError;for(var s=arguments.length>=2?arguments[1]:void 0,n=0;n + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Taken from klasse by mattdesl https://github.com/mattdesl/klasse + +function hasGetterOrSetter (def) +{ + return (!!def.get && typeof def.get === 'function') || (!!def.set && typeof def.set === 'function'); +} + +function getProperty (definition, k, isClassDescriptor) +{ + // This may be a lightweight object, OR it might be a property that was defined previously. + + // For simple class descriptors we can just assume its NOT previously defined. + var def = (isClassDescriptor) ? definition[k] : Object.getOwnPropertyDescriptor(definition, k); + + if (!isClassDescriptor && def.value && typeof def.value === 'object') + { + def = def.value; + } + + // This might be a regular property, or it may be a getter/setter the user defined in a class. + if (def && hasGetterOrSetter(def)) + { + if (typeof def.enumerable === 'undefined') + { + def.enumerable = true; + } + + if (typeof def.configurable === 'undefined') + { + def.configurable = true; + } + + return def; + } + else + { + return false; + } +} + +function hasNonConfigurable (obj, k) +{ + var prop = Object.getOwnPropertyDescriptor(obj, k); + + if (!prop) + { + return false; + } + + if (prop.value && typeof prop.value === 'object') + { + prop = prop.value; + } + + if (prop.configurable === false) + { + return true; + } + + return false; +} + +function extend (ctor, definition, isClassDescriptor, extend) +{ + for (var k in definition) + { + if (!definition.hasOwnProperty(k)) + { + continue; + } + + var def = getProperty(definition, k, isClassDescriptor); + + if (def !== false) + { + // If Extends is used, we will check its prototype to see if the final variable exists. + + var parent = extend || ctor; + + if (hasNonConfigurable(parent.prototype, k)) + { + // Just skip the final property + if (Class.ignoreFinals) + { + continue; + } + + // We cannot re-define a property that is configurable=false. + // So we will consider them final and throw an error. This is by + // default so it is clear to the developer what is happening. + // You can set ignoreFinals to true if you need to extend a class + // which has configurable=false; it will simply not re-define final properties. + throw new Error('cannot override final property \'' + k + '\', set Class.ignoreFinals = true to skip'); + } + + Object.defineProperty(ctor.prototype, k, def); + } + else + { + ctor.prototype[k] = definition[k]; + } + } +} + +function mixin (myClass, mixins) +{ + if (!mixins) + { + return; + } + + if (!Array.isArray(mixins)) + { + mixins = [ mixins ]; + } + + for (var i = 0; i < mixins.length; i++) + { + extend(myClass, mixins[i].prototype || mixins[i]); + } +} + +/** + * Creates a new class with the given descriptor. + * The constructor, defined by the name `initialize`, + * is an optional function. If unspecified, an anonymous + * function will be used which calls the parent class (if + * one exists). + * + * You can also use `Extends` and `Mixins` to provide subclassing + * and inheritance. + * + * @class Class + * @constructor + * @param {Object} definition a dictionary of functions for the class + * @example + * + * var MyClass = new Phaser.Class({ + * + * initialize: function() { + * this.foo = 2.0; + * }, + * + * bar: function() { + * return this.foo + 5; + * } + * }); + */ +function Class (definition) +{ + if (!definition) + { + definition = {}; + } + + // The variable name here dictates what we see in Chrome debugger + var initialize; + var Extends; + + if (definition.initialize) + { + if (typeof definition.initialize !== 'function') + { + throw new Error('initialize must be a function'); + } + + initialize = definition.initialize; + + // Usually we should avoid 'delete' in V8 at all costs. + // However, its unlikely to make any performance difference + // here since we only call this on class creation (i.e. not object creation). + delete definition.initialize; + } + else if (definition.Extends) + { + var base = definition.Extends; + + initialize = function () + { + base.apply(this, arguments); + }; + } + else + { + initialize = function () {}; + } + + if (definition.Extends) + { + initialize.prototype = Object.create(definition.Extends.prototype); + initialize.prototype.constructor = initialize; + + // For getOwnPropertyDescriptor to work, we need to act directly on the Extends (or Mixin) + + Extends = definition.Extends; + + delete definition.Extends; + } + else + { + initialize.prototype.constructor = initialize; + } + + // Grab the mixins, if they are specified... + var mixins = null; + + if (definition.Mixins) + { + mixins = definition.Mixins; + delete definition.Mixins; + } + + // First, mixin if we can. + mixin(initialize, mixins); + + // Now we grab the actual definition which defines the overrides. + extend(initialize, definition, true, Extends); + + return initialize; +} + +Class.extend = extend; +Class.mixin = mixin; +Class.ignoreFinals = false; + +module.exports = Class; + + +/***/ }), +/* 1 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Finds the key within the top level of the {@link source} object, or returns {@link defaultValue} + * + * @function Phaser.Utils.Objects.GetFastValue + * @since 3.0.0 + * + * @param {object} source - The object to search + * @param {string} key - The key for the property on source. Must exist at the top level of the source object (no periods) + * @param {*} [defaultValue] - The default value to use if the key does not exist. + * + * @return {*} The value if found; otherwise, defaultValue (null if none provided) + */ +var GetFastValue = function (source, key, defaultValue) +{ + var t = typeof(source); + + if (!source || t === 'number' || t === 'string') + { + return defaultValue; + } + else if (source.hasOwnProperty(key) && source[key] !== undefined) + { + return source[key]; + } + else + { + return defaultValue; + } +}; + +module.exports = GetFastValue; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A NOOP (No Operation) callback function. + * + * Used internally by Phaser when it's more expensive to determine if a callback exists + * than it is to just invoke an empty function. + * + * @function Phaser.Utils.NOOP + * @since 3.0.0 + */ +var NOOP = function () +{ + // NOOP +}; + +module.exports = NOOP; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @typedef {object} Vector2Like + * + * @property {number} x - The x component. + * @property {number} y - The y component. + */ + +/** + * @classdesc + * A representation of a vector in 2D space. + * + * A two-component vector. + * + * @class Vector2 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number|Vector2Like} [x] - The x component, or an object with `x` and `y` properties. + * @param {number} [y] - The y component. + */ +var Vector2 = new Class({ + + initialize: + + function Vector2 (x, y) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector2#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector2#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + } + else + { + if (y === undefined) { y = x; } + + this.x = x || 0; + this.y = y || 0; + } + }, + + /** + * Make a clone of this Vector2. + * + * @method Phaser.Math.Vector2#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} A clone of this Vector2. + */ + clone: function () + { + return new Vector2(this.x, this.y); + }, + + /** + * Copy the components of a given Vector into this Vector. + * + * @method Phaser.Math.Vector2#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + copy: function (src) + { + this.x = src.x || 0; + this.y = src.y || 0; + + return this; + }, + + /** + * Set the component values of this Vector from a given Vector2Like object. + * + * @method Phaser.Math.Vector2#setFromObject + * @since 3.0.0 + * + * @param {Vector2Like} obj - The object containing the component values to set for this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + setFromObject: function (obj) + { + this.x = obj.x || 0; + this.y = obj.y || 0; + + return this; + }, + + /** + * Set the `x` and `y` components of the this Vector to the given `x` and `y` values. + * + * @method Phaser.Math.Vector2#set + * @since 3.0.0 + * + * @param {number} x - The x value to set for this Vector. + * @param {number} [y=x] - The y value to set for this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + set: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * This method is an alias for `Vector2.set`. + * + * @method Phaser.Math.Vector2#setTo + * @since 3.4.0 + * + * @param {number} x - The x value to set for this Vector. + * @param {number} [y=x] - The y value to set for this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + setTo: function (x, y) + { + return this.set(x, y); + }, + + /** + * Sets the `x` and `y` values of this object from a given polar coordinate. + * + * @method Phaser.Math.Vector2#setToPolar + * @since 3.0.0 + * + * @param {number} azimuth - The angular coordinate, in radians. + * @param {number} [radius=1] - The radial coordinate (length). + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + setToPolar: function (azimuth, radius) + { + if (radius == null) { radius = 1; } + + this.x = Math.cos(azimuth) * radius; + this.y = Math.sin(azimuth) * radius; + + return this; + }, + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict equality check against each Vector's components. + * + * @method Phaser.Math.Vector2#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} v - The vector to compare with this Vector. + * + * @return {boolean} Whether the given Vector is equal to this Vector. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y)); + }, + + /** + * Calculate the angle between this Vector and the positive x-axis, in radians. + * + * @method Phaser.Math.Vector2#angle + * @since 3.0.0 + * + * @return {number} The angle between this Vector, and the positive x-axis, given in radians. + */ + angle: function () + { + // computes the angle in radians with respect to the positive x-axis + + var angle = Math.atan2(this.y, this.x); + + if (angle < 0) + { + angle += 2 * Math.PI; + } + + return angle; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector2#add + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + add: function (src) + { + this.x += src.x; + this.y += src.y; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector2#subtract + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + subtract: function (src) + { + this.x -= src.x; + this.y -= src.y; + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector2#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + multiply: function (src) + { + this.x *= src.x; + this.y *= src.y; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector2#scale + * @since 3.0.0 + * + * @param {number} value - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + scale: function (value) + { + if (isFinite(value)) + { + this.x *= value; + this.y *= value; + } + else + { + this.x = 0; + this.y = 0; + } + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector2#divide + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + divide: function (src) + { + this.x /= src.x; + this.y /= src.y; + + return this; + }, + + /** + * Negate the `x` and `y` components of this Vector. + * + * @method Phaser.Math.Vector2#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector2#distance + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (src) + { + var dx = src.x - this.x; + var dy = src.y - this.y; + + return Math.sqrt(dx * dx + dy * dy); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector2#distanceSq + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (src) + { + var dx = src.x - this.x; + var dy = src.y - this.y; + + return dx * dx + dy * dy; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector2#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + + return Math.sqrt(x * x + y * y); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector2#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + + return x * x + y * y; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector2#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var len = x * x + y * y; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + } + + return this; + }, + + /** + * Right-hand normalize (make unit length) this Vector. + * + * @method Phaser.Math.Vector2#normalizeRightHand + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + normalizeRightHand: function () + { + var x = this.x; + + this.x = this.y * -1; + this.y = x; + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector2#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector2 to dot product with this Vector2. + * + * @return {number} The dot product of this Vector and the given Vector. + */ + dot: function (src) + { + return this.x * src.x + this.y * src.y; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector2#cross + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - [description] + * + * @return {number} [description] + */ + cross: function (src) + { + return this.x * src.y - this.y * src.x; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector2#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector2 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + lerp: function (src, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + + this.x = ax + t * (src.x - ax); + this.y = ay + t * (src.y - ay); + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector2#transformMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector2 with. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + transformMat3: function (mat) + { + var x = this.x; + var y = this.y; + var m = mat.val; + + this.x = m[0] * x + m[3] * y + m[6]; + this.y = m[1] * x + m[4] * y + m[7]; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector2#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector2 with. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[12]; + this.y = m[1] * x + m[5] * y + m[13]; + + return this; + }, + + /** + * Make this Vector the zero vector (0, 0). + * + * @method Phaser.Math.Vector2#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + reset: function () + { + this.x = 0; + this.y = 0; + + return this; + } + +}); + +/** + * A static zero Vector2 for use by reference. + * + * @constant + * @name Phaser.Math.Vector2.ZERO + * @type {Vector2} + * @since 3.1.0 + */ +Vector2.ZERO = new Vector2(); + +module.exports = Vector2; + + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Source object +// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' +// The default value to use if the key doesn't exist + +/** + * Retrieves a value from an object. + * + * @function Phaser.Utils.Objects.GetValue + * @since 3.0.0 + * + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param {*} defaultValue - The value to return if the `key` isn't found in the `source` object. + * + * @return {*} The value of the requested key. + */ +var GetValue = function (source, key, defaultValue) +{ + if (!source || typeof source === 'number') + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else if (key.indexOf('.')) + { + var keys = key.split('.'); + var parent = source; + var value = defaultValue; + + // Use for loop here so we can break early + for (var i = 0; i < keys.length; i++) + { + if (parent.hasOwnProperty(keys[i])) + { + // Yes it has a key property, let's carry on down + value = parent[keys[i]]; + + parent = parent[keys[i]]; + } + else + { + // Can't go any further, so reset to default + value = defaultValue; + break; + } + } + + return value; + } + else + { + return defaultValue; + } +}; + +module.exports = GetValue; + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var PluginCache = __webpack_require__(15); + +/** + * @classdesc + * The Game Object Factory is a Scene plugin that allows you to quickly create many common + * types of Game Objects and have them automatically registered with the Scene. + * + * Game Objects directly register themselves with the Factory and inject their own creation + * methods into the class. + * + * @class GameObjectFactory + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. + */ +var GameObjectFactory = new Class({ + + initialize: + + function GameObjectFactory (scene) + { + /** + * The Scene to which this Game Object Factory belongs. + * + * @name Phaser.GameObjects.GameObjectFactory#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems. + * + * @name Phaser.GameObjects.GameObjectFactory#systems + * @type {Phaser.Scenes.Systems} + * @protected + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.GameObjectFactory#displayList + * @type {Phaser.GameObjects.DisplayList} + * @protected + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Update List. + * + * @name Phaser.GameObjects.GameObjectFactory#updateList; + * @type {Phaser.GameObjects.UpdateList} + * @protected + * @since 3.0.0 + */ + this.updateList; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.GameObjectFactory#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.displayList = this.systems.displayList; + this.updateList = this.systems.updateList; + + this.systems.events.once('destroy', this.destroy, 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.GameObjects.GameObjectFactory#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.systems.events.once('shutdown', this.shutdown, this); + }, + + /** + * Adds an existing Game Object to this Scene. + * + * If the Game Object renders, it will be added to the Display List. + * If it has a `preUpdate` method, it will be added to the Update List. + * + * @method Phaser.GameObjects.GameObjectFactory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The child to be added to this Scene. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was added. + */ + existing: function (child) + { + if (child.renderCanvas || child.renderWebGL) + { + this.displayList.add(child); + } + + if (child.preUpdate) + { + this.updateList.add(child); + } + + return child; + }, + + /** + * 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 () + { + this.systems.events.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.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; + } + +}); + +// Static method called directly by the Game Object factory functions + +GameObjectFactory.register = function (factoryType, factoryFunction) +{ + if (!GameObjectFactory.prototype.hasOwnProperty(factoryType)) + { + GameObjectFactory.prototype[factoryType] = factoryFunction; + } +}; + +PluginCache.register('GameObjectFactory', GameObjectFactory, 'add'); + +module.exports = GameObjectFactory; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * Defines a Point in 2D space, with an x and y component. + * + * @class Point + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of this Point. + * @param {number} [y=x] - The y coordinate of this Point. + */ +var Point = new Class({ + + initialize: + + function Point (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + /** + * The x coordinate of this Point. + * + * @name Phaser.Geom.Point#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y coordinate of this Point. + * + * @name Phaser.Geom.Point#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + }, + + /** + * Set the x and y coordinates of the point to the given values. + * + * @method Phaser.Geom.Point#setTo + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of this Point. + * @param {number} [y=x] - The y coordinate of this Point. + * + * @return {Phaser.Geom.Point} This Point object. + */ + setTo: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + } + +}); + +module.exports = Point; + + +/***/ }), +/* 7 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var types = {}; + +var FileTypesManager = { + + /** + * Static method called when a LoaderPlugin is created. + * + * Loops through the local types object and injects all of them as + * properties into the LoaderPlugin instance. + * + * @method Phaser.Loader.FileTypesManager.register + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The LoaderPlugin to install the types into. + */ + install: function (loader) + { + for (var key in types) + { + loader[key] = types[key]; + } + }, + + /** + * Static method called directly by the File Types. + * + * The key is a reference to the function used to load the files via the Loader, i.e. `image`. + * + * @method Phaser.Loader.FileTypesManager.register + * @since 3.0.0 + * + * @param {string} key - The key that will be used as the method name in the LoaderPlugin. + * @param {function} factoryFunction - The function that will be called when LoaderPlugin.key is invoked. + */ + register: function (key, factoryFunction) + { + types[key] = factoryFunction; + }, + + /** + * Removed all associated file types. + * + * @method Phaser.Loader.FileTypesManager.destroy + * @since 3.0.0 + */ + destroy: function () + { + types = {}; + } + +}; + +module.exports = FileTypesManager; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * This is a slightly modified version of jQuery.isPlainObject. + * A plain object is an object whose internal class property is [object Object]. + * + * @function Phaser.Utils.Objects.IsPlainObject + * @since 3.0.0 + * + * @param {object} obj - The object to inspect. + * + * @return {boolean} `true` if the object is plain, otherwise `false`. + */ +var IsPlainObject = function (obj) +{ + // Not plain objects: + // - Any object or value whose internal [[Class]] property is not "[object Object]" + // - DOM nodes + // - window + if (typeof(obj) !== 'object' || obj.nodeType || obj === obj.window) + { + return false; + } + + // Support: Firefox <20 + // The try/catch suppresses exceptions thrown when attempting to access + // the "constructor" property of certain host objects, ie. |window.location| + // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 + try + { + if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) + { + return false; + } + } + catch (e) + { + return false; + } + + // If the function hasn't returned already, we're confident that + // |obj| is a plain object, created by {} or constructed with new Object + return true; +}; + +module.exports = IsPlainObject; + + +/***/ }), +/* 9 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL.Utils + * @since 3.0.0 + */ +module.exports = { + + /** + * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 + * + * @function Phaser.Renderer.WebGL.Utils.getTintFromFloats + * @since 3.0.0 + * + * @param {number} r - Red component in a range from 0.0 to 1.0 + * @param {number} g - [description] + * @param {number} b - [description] + * @param {number} a - Alpha component in a range from 0.0 to 1.0 + * + * @return {number} [description] + */ + getTintFromFloats: function (r, g, b, a) + { + var ur = ((r * 255.0)|0) & 0xFF; + var ug = ((g * 255.0)|0) & 0xFF; + var ub = ((b * 255.0)|0) & 0xFF; + var ua = ((a * 255.0)|0) & 0xFF; + + return ((ua << 24) | (ur << 16) | (ug << 8) | ub) >>> 0; + }, + + /** + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 + * + * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha + * @since 3.0.0 + * + * @param {number} rgb - Uint24 representing RGB components + * @param {number} a - Float32 representing Alpha component + * + * @return {number} Packed RGBA as Uint32 + */ + getTintAppendFloatAlpha: function (rgb, a) + { + var ua = ((a * 255.0)|0) & 0xFF; + return ((ua << 24) | rgb) >>> 0; + }, + + /** + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a + * swizzled Uint32 + * + * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlphaAndSwap + * @since 3.0.0 + * + * @param {number} rgb - Uint24 representing RGB components + * @param {number} a - Float32 representing Alpha component + * + * @return {number} Packed RGBA as Uint32 + */ + getTintAppendFloatAlphaAndSwap: function (rgb, a) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + var ua = ((a * 255.0)|0) & 0xFF; + + return ((ua << 24) | (ub << 16) | (ug << 8) | ur) >>> 0; + }, + + /** + * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 + * + * @function Phaser.Renderer.WebGL.Utils.getFloatsFromUintRGB + * @since 3.0.0 + * + * @param {number} rgb - RGB packed as a Uint24 + * + * @return {array} Array of floats representing each component as a float + */ + getFloatsFromUintRGB: function (rgb) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + return [ ur / 255.0, ug / 255.0, ub / 255.0 ]; + }, + + /** + * Counts how many attributes of 32 bits a vertex has + * + * @function Phaser.Renderer.WebGL.Utils.getComponentCount + * @since 3.0.0 + * + * @param {array} attributes - Array of attributes + * @param {WebGLRenderingContext} glContext - WebGLContext used for check types + * + * @return {number} Count of 32 bit attributes in vertex + */ + getComponentCount: function (attributes, glContext) + { + var count = 0; + + for (var index = 0; index < attributes.length; ++index) + { + var element = attributes[index]; + + if (element.type === glContext.FLOAT) + { + count += element.size; + } + else + { + count += 1; // We'll force any other type to be 32 bit. for now + } + } + + return count; + } + +}; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(43); +var GetPoint = __webpack_require__(209); +var GetPoints = __webpack_require__(434); +var Line = __webpack_require__(60); +var Random = __webpack_require__(206); + +/** + * @classdesc + * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) + * + * @class Rectangle + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=0] - The Y coordinate of the top left corner of the Rectangle. + * @param {number} [width=0] - The width of the Rectangle. + * @param {number} [height=0] - The height of the Rectangle. + */ +var Rectangle = new Class({ + + initialize: + + function Rectangle (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * The X coordinate of the top left corner of the Rectangle. + * + * @name Phaser.Geom.Rectangle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The Y coordinate of the top left corner of the Rectangle. + * + * @name Phaser.Geom.Rectangle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. + * + * @name Phaser.Geom.Rectangle#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. + * + * @name Phaser.Geom.Rectangle#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * Checks if the given point is inside the Rectangle's bounds. + * + * @method Phaser.Geom.Rectangle#contains + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is within the Rectangle's bounds, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. + * + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. + * + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. + * + * @method Phaser.Geom.Rectangle#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {number} position - The normalized distance into the Rectangle's perimeter to return. + * @param {(Phaser.Geom.Point|object)} [output] - An object to update with the `x` and `y` coordinates of the point. + * + * @return {(Phaser.Geom.Point|object)} The updated `output` object, or a new Point if no `output` object was given. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. + * + * @method Phaser.Geom.Rectangle#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [output,$return] + * + * @param {integer} quantity - The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. + * @param {number} [stepRate] - If `quantity` is 0, determines the normalized distance between each returned point. + * @param {(array|Phaser.Geom.Point[])} [output] - An array to which to append the points. + * + * @return {(array|Phaser.Geom.Point[])} The modified `output` array, or a new array if none was provided. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a random point within the Rectangle's bounds. + * + * @method Phaser.Geom.Rectangle#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} [point] - The object in which to store the `x` and `y` coordinates of the point. + * + * @return {Phaser.Geom.Point} The updated `point`, or a new Point if none was provided. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets the position, width, and height of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setTo + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} y - The Y coordinate of the top left corner of the Rectangle. + * @param {number} width - The width of the Rectangle. + * @param {number} height - The height of the Rectangle. + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Resets the position, width, and height of the Rectangle to 0. + * + * @method Phaser.Geom.Rectangle#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setEmpty: function () + { + return this.setTo(0, 0, 0, 0); + }, + + /** + * Sets the position of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setPosition + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=x] - The Y coordinate of the top left corner of the Rectangle. + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Sets the width and height of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setSize + * @since 3.0.0 + * + * @param {number} width - The width to set the Rectangle to. + * @param {number} [height=width] - The height to set the Rectangle to. + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. + * + * @method Phaser.Geom.Rectangle#isEmpty + * @since 3.0.0 + * + * @return {boolean} `true` if the Rectangle is empty. A Rectangle object is empty if its width or height is less than or equal to 0. + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns a Line object that corresponds to the top of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineA + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.y, this.right, this.y); + + return line; + }, + + /** + * Returns a Line object that corresponds to the right of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.y, this.right, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the bottom of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineC + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.bottom, this.x, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the left of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineD + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. + */ + getLineD: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.bottom, this.x, this.y); + + return line; + }, + + /** + * The x coordinate of the left of the Rectangle. + * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. + * + * @name Phaser.Geom.Rectangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x; + }, + + set: function (value) + { + if (value >= this.right) + { + this.width = 0; + } + else + { + this.width = this.right - value; + } + + this.x = value; + } + + }, + + /** + * The sum of the x and width properties. + * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. + * + * @name Phaser.Geom.Rectangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this.width; + }, + + set: function (value) + { + if (value <= this.x) + { + this.width = 0; + } + else + { + this.width = value - this.x; + } + } + + }, + + /** + * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. + * However it does affect the height property, whereas changing the y value does not affect the height property. + * + * @name Phaser.Geom.Rectangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y; + }, + + set: function (value) + { + if (value >= this.bottom) + { + this.height = 0; + } + else + { + this.height = (this.bottom - value); + } + + this.y = value; + } + + }, + + /** + * The sum of the y and height properties. + * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. + * + * @name Phaser.Geom.Rectangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this.height; + }, + + set: function (value) + { + if (value <= this.y) + { + this.height = 0; + } + else + { + this.height = value - this.y; + } + } + + }, + + /** + * The x coordinate of the center of the Rectangle. + * + * @name Phaser.Geom.Rectangle#centerX + * @type {number} + * @since 3.0.0 + */ + centerX: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * The y coordinate of the center of the Rectangle. + * + * @name Phaser.Geom.Rectangle#centerY + * @type {number} + * @since 3.0.0 + */ + centerY: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + + } + +}); + +module.exports = Rectangle; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var has = Object.prototype.hasOwnProperty + , prefix = '~'; + +/** + * Constructor to create a storage for our `EE` objects. + * An `Events` instance is a plain object whose properties are event names. + * + * @constructor + * @private + */ +function Events() {} + +// +// We try to not inherit from `Object.prototype`. In some engines creating an +// instance in this way is faster than calling `Object.create(null)` directly. +// If `Object.create(null)` is not supported we prefix the event names with a +// character to make sure that the built-in object properties are not +// overridden or used as an attack vector. +// +if (Object.create) { + Events.prototype = Object.create(null); + + // + // This hack is needed because the `__proto__` property is still inherited in + // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. + // + if (!new Events().__proto__) prefix = false; +} + +/** + * Representation of a single event listener. + * + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor + * @private + */ +function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; +} + +/** + * Add a listener for a given event. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} once Specify if the listener is a one-time listener. + * @returns {EventEmitter} + * @private + */ +function addListener(emitter, event, fn, context, once) { + if (typeof fn !== 'function') { + throw new TypeError('The listener must be a function'); + } + + var listener = new EE(fn, context || emitter, once) + , evt = prefix ? prefix + event : event; + + if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; + else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); + else emitter._events[evt] = [emitter._events[evt], listener]; + + return emitter; +} + +/** + * Clear event by name. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} evt The Event name. + * @private + */ +function clearEvent(emitter, evt) { + if (--emitter._eventsCount === 0) emitter._events = new Events(); + else delete emitter._events[evt]; +} + +/** + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. + * + * @constructor + * @public + */ +function EventEmitter() { + this._events = new Events(); + this._eventsCount = 0; +} + +/** + * Return an array listing the events for which the emitter has registered + * listeners. + * + * @returns {Array} + * @public + */ +EventEmitter.prototype.eventNames = function eventNames() { + var names = [] + , events + , name; + + if (this._eventsCount === 0) return names; + + for (name in (events = this._events)) { + if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); + } + + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + + return names; +}; + +/** + * Return the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Array} The registered listeners. + * @public + */ +EventEmitter.prototype.listeners = function listeners(event) { + var evt = prefix ? prefix + event : event + , handlers = this._events[evt]; + + if (!handlers) return []; + if (handlers.fn) return [handlers.fn]; + + for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { + ee[i] = handlers[i].fn; + } + + return ee; +}; + +/** + * Return the number of listeners listening to a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Number} The number of listeners. + * @public + */ +EventEmitter.prototype.listenerCount = function listenerCount(event) { + var evt = prefix ? prefix + event : event + , listeners = this._events[evt]; + + if (!listeners) return 0; + if (listeners.fn) return 1; + return listeners.length; +}; + +/** + * Calls each of the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Boolean} `true` if the event had listeners, else `false`. + * @public + */ +EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return false; + + var listeners = this._events[evt] + , len = arguments.length + , args + , i; + + if (listeners.fn) { + if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); + + switch (len) { + case 1: return listeners.fn.call(listeners.context), true; + case 2: return listeners.fn.call(listeners.context, a1), true; + case 3: return listeners.fn.call(listeners.context, a1, a2), true; + case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + + for (i = 1, args = new Array(len -1); i < len; i++) { + args[i - 1] = arguments[i]; + } + + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length + , j; + + for (i = 0; i < length; i++) { + if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); + + switch (len) { + case 1: listeners[i].fn.call(listeners[i].context); break; + case 2: listeners[i].fn.call(listeners[i].context, a1); break; + case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; + case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; + default: + if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { + args[j - 1] = arguments[j]; + } + + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + + return true; +}; + +/** + * Add a listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.on = function on(event, fn, context) { + return addListener(this, event, fn, context, false); +}; + +/** + * Add a one-time listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.once = function once(event, fn, context) { + return addListener(this, event, fn, context, true); +}; + +/** + * Remove the listeners of a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn Only remove the listeners that match this function. + * @param {*} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return this; + if (!fn) { + clearEvent(this, evt); + return this; + } + + var listeners = this._events[evt]; + + if (listeners.fn) { + if ( + listeners.fn === fn && + (!once || listeners.once) && + (!context || listeners.context === context) + ) { + clearEvent(this, evt); + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if ( + listeners[i].fn !== fn || + (once && !listeners[i].once) || + (context && listeners[i].context !== context) + ) { + events.push(listeners[i]); + } + } + + // + // Reset the array, or remove it completely if we have no more listeners. + // + if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; + else clearEvent(this, evt); + } + + return this; +}; + +/** + * Remove all listeners, or those of the specified event. + * + * @param {(String|Symbol)} [event] The event name. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) clearEvent(this, evt); + } else { + this._events = new Events(); + this._eventsCount = 0; + } + + return this; +}; + +// +// Alias methods names because people roll like that. +// +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; +EventEmitter.prototype.addListener = EventEmitter.prototype.on; + +// +// Expose the prefix. +// +EventEmitter.prefixed = prefix; + +// +// Allow `EventEmitter` to be imported as module namespace. +// +EventEmitter.EventEmitter = EventEmitter; + +// +// Expose the module. +// +if (true) { + module.exports = EventEmitter; +} + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {/** +* The `Matter.Common` module contains utility functions that are common to all modules. +* +* @class Common +*/ + +var Common = {}; + +module.exports = Common; + +(function() { + + Common._nextId = 0; + Common._seed = 0; + Common._nowStartTime = +(new Date()); + + /** + * Extends the object in the first argument using the object in the second argument. + * @method extend + * @param {} obj + * @param {boolean} deep + * @return {} obj extended + */ + Common.extend = function(obj, deep) { + var argsStart, + args, + deepClone; + + if (typeof deep === 'boolean') { + argsStart = 2; + deepClone = deep; + } else { + argsStart = 1; + deepClone = true; + } + + for (var i = argsStart; i < arguments.length; i++) { + var source = arguments[i]; + + if (source) { + for (var prop in source) { + if (deepClone && source[prop] && source[prop].constructor === Object) { + if (!obj[prop] || obj[prop].constructor === Object) { + obj[prop] = obj[prop] || {}; + Common.extend(obj[prop], deepClone, source[prop]); + } else { + obj[prop] = source[prop]; + } + } else { + obj[prop] = source[prop]; + } + } + } + } + + return obj; + }; + + /** + * Creates a new clone of the object, if deep is true references will also be cloned. + * @method clone + * @param {} obj + * @param {bool} deep + * @return {} obj cloned + */ + Common.clone = function(obj, deep) { + return Common.extend({}, deep, obj); + }; + + /** + * Returns the list of keys for the given object. + * @method keys + * @param {} obj + * @return {string[]} keys + */ + Common.keys = function(obj) { + if (Object.keys) + return Object.keys(obj); + + // avoid hasOwnProperty for performance + var keys = []; + for (var key in obj) + keys.push(key); + return keys; + }; + + /** + * Returns the list of values for the given object. + * @method values + * @param {} obj + * @return {array} Array of the objects property values + */ + Common.values = function(obj) { + var values = []; + + if (Object.keys) { + var keys = Object.keys(obj); + for (var i = 0; i < keys.length; i++) { + values.push(obj[keys[i]]); + } + return values; + } + + // avoid hasOwnProperty for performance + for (var key in obj) + values.push(obj[key]); + return values; + }; + + /** + * Gets a value from `base` relative to the `path` string. + * @method get + * @param {} obj The base object + * @param {string} path The path relative to `base`, e.g. 'Foo.Bar.baz' + * @param {number} [begin] Path slice begin + * @param {number} [end] Path slice end + * @return {} The object at the given path + */ + Common.get = function(obj, path, begin, end) { + path = path.split('.').slice(begin, end); + + for (var i = 0; i < path.length; i += 1) { + obj = obj[path[i]]; + } + + return obj; + }; + + /** + * Sets a value on `base` relative to the given `path` string. + * @method set + * @param {} obj The base object + * @param {string} path The path relative to `base`, e.g. 'Foo.Bar.baz' + * @param {} val The value to set + * @param {number} [begin] Path slice begin + * @param {number} [end] Path slice end + * @return {} Pass through `val` for chaining + */ + Common.set = function(obj, path, val, begin, end) { + var parts = path.split('.').slice(begin, end); + Common.get(obj, path, 0, -1)[parts[parts.length - 1]] = val; + return val; + }; + + /** + * Shuffles the given array in-place. + * The function uses a seeded random generator. + * @method shuffle + * @param {array} array + * @return {array} array shuffled randomly + */ + Common.shuffle = function(array) { + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Common.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + return array; + }; + + /** + * Randomly chooses a value from a list with equal probability. + * The function uses a seeded random generator. + * @method choose + * @param {array} choices + * @return {object} A random choice object from the array + */ + Common.choose = function(choices) { + return choices[Math.floor(Common.random() * choices.length)]; + }; + + /** + * Returns true if the object is a HTMLElement, otherwise false. + * @method isElement + * @param {object} obj + * @return {boolean} True if the object is a HTMLElement, otherwise false + */ + Common.isElement = function(obj) { + if (typeof HTMLElement !== 'undefined') { + return obj instanceof HTMLElement; + } + + return !!(obj && obj.nodeType && obj.nodeName); + }; + + /** + * Returns true if the object is an array. + * @method isArray + * @param {object} obj + * @return {boolean} True if the object is an array, otherwise false + */ + Common.isArray = function(obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; + + /** + * Returns true if the object is a function. + * @method isFunction + * @param {object} obj + * @return {boolean} True if the object is a function, otherwise false + */ + Common.isFunction = function(obj) { + return typeof obj === "function"; + }; + + /** + * Returns true if the object is a plain object. + * @method isPlainObject + * @param {object} obj + * @return {boolean} True if the object is a plain object, otherwise false + */ + Common.isPlainObject = function(obj) { + return typeof obj === 'object' && obj.constructor === Object; + }; + + /** + * Returns true if the object is a string. + * @method isString + * @param {object} obj + * @return {boolean} True if the object is a string, otherwise false + */ + Common.isString = function(obj) { + return toString.call(obj) === '[object String]'; + }; + + /** + * Returns the given value clamped between a minimum and maximum value. + * @method clamp + * @param {number} value + * @param {number} min + * @param {number} max + * @return {number} The value clamped between min and max inclusive + */ + Common.clamp = function(value, min, max) { + if (value < min) + return min; + if (value > max) + return max; + return value; + }; + + /** + * Returns the sign of the given value. + * @method sign + * @param {number} value + * @return {number} -1 if negative, +1 if 0 or positive + */ + Common.sign = function(value) { + return value < 0 ? -1 : 1; + }; + + /** + * Returns the current timestamp since the time origin (e.g. from page load). + * The result will be high-resolution including decimal places if available. + * @method now + * @return {number} the current timestamp + */ + Common.now = function() { + if (window.performance) { + if (window.performance.now) { + return window.performance.now(); + } else if (window.performance.webkitNow) { + return window.performance.webkitNow(); + } + } + + return (new Date()) - Common._nowStartTime; + }; + + /** + * Returns a random value between a minimum and a maximum value inclusive. + * The function uses a seeded random generator. + * @method random + * @param {number} min + * @param {number} max + * @return {number} A random number between min and max inclusive + */ + Common.random = function(min, max) { + min = (typeof min !== "undefined") ? min : 0; + max = (typeof max !== "undefined") ? max : 1; + return min + _seededRandom() * (max - min); + }; + + var _seededRandom = function() { + // https://en.wikipedia.org/wiki/Linear_congruential_generator + Common._seed = (Common._seed * 9301 + 49297) % 233280; + return Common._seed / 233280; + }; + + /** + * Converts a CSS hex colour string into an integer. + * @method colorToNumber + * @param {string} colorString + * @return {number} An integer representing the CSS hex string + */ + Common.colorToNumber = function(colorString) { + colorString = colorString.replace('#',''); + + if (colorString.length == 3) { + colorString = colorString.charAt(0) + colorString.charAt(0) + + colorString.charAt(1) + colorString.charAt(1) + + colorString.charAt(2) + colorString.charAt(2); + } + + return parseInt(colorString, 16); + }; + + /** + * The console logging level to use, where each level includes all levels above and excludes the levels below. + * The default level is 'debug' which shows all console messages. + * + * Possible level values are: + * - 0 = None + * - 1 = Debug + * - 2 = Info + * - 3 = Warn + * - 4 = Error + * @property Common.logLevel + * @type {Number} + * @default 1 + */ + Common.logLevel = 1; + + /** + * Shows a `console.log` message only if the current `Common.logLevel` allows it. + * The message will be prefixed with 'matter-js' to make it easily identifiable. + * @method log + * @param ...objs {} The objects to log. + */ + Common.log = function() { + if (console && Common.logLevel > 0 && Common.logLevel <= 3) { + console.log.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); + } + }; + + /** + * Shows a `console.info` message only if the current `Common.logLevel` allows it. + * The message will be prefixed with 'matter-js' to make it easily identifiable. + * @method info + * @param ...objs {} The objects to log. + */ + Common.info = function() { + if (console && Common.logLevel > 0 && Common.logLevel <= 2) { + console.info.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); + } + }; + + /** + * Shows a `console.warn` message only if the current `Common.logLevel` allows it. + * The message will be prefixed with 'matter-js' to make it easily identifiable. + * @method warn + * @param ...objs {} The objects to log. + */ + Common.warn = function() { + if (console && Common.logLevel > 0 && Common.logLevel <= 3) { + console.warn.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); + } + }; + + /** + * Returns the next unique sequential ID. + * @method nextId + * @return {Number} Unique sequential ID + */ + Common.nextId = function() { + return Common._nextId++; + }; + + /** + * A cross browser compatible indexOf implementation. + * @method indexOf + * @param {array} haystack + * @param {object} needle + * @return {number} The position of needle in haystack, otherwise -1. + */ + Common.indexOf = function(haystack, needle) { + if (haystack.indexOf) + return haystack.indexOf(needle); + + for (var i = 0; i < haystack.length; i++) { + if (haystack[i] === needle) + return i; + } + + return -1; + }; + + /** + * A cross browser compatible array map implementation. + * @method map + * @param {array} list + * @param {function} func + * @return {array} Values from list transformed by func. + */ + Common.map = function(list, func) { + if (list.map) { + return list.map(func); + } + + var mapped = []; + + for (var i = 0; i < list.length; i += 1) { + mapped.push(func(list[i])); + } + + return mapped; + }; + + /** + * Takes a directed graph and returns the partially ordered set of vertices in topological order. + * Circular dependencies are allowed. + * @method topologicalSort + * @param {object} graph + * @return {array} Partially ordered set of vertices in topological order. + */ + Common.topologicalSort = function(graph) { + // https://github.com/mgechev/javascript-algorithms + // Copyright (c) Minko Gechev (MIT license) + // Modifications: tidy formatting and naming + var result = [], + visited = [], + temp = []; + + for (var node in graph) { + if (!visited[node] && !temp[node]) { + Common._topologicalSort(node, visited, temp, graph, result); + } + } + + return result; + }; + + Common._topologicalSort = function(node, visited, temp, graph, result) { + var neighbors = graph[node] || []; + temp[node] = true; + + for (var i = 0; i < neighbors.length; i += 1) { + var neighbor = neighbors[i]; + + if (temp[neighbor]) { + // skip circular dependencies + continue; + } + + if (!visited[neighbor]) { + Common._topologicalSort(neighbor, visited, temp, graph, result); + } + } + + temp[node] = false; + visited[node] = true; + + result.push(node); + }; + + /** + * Takes _n_ functions as arguments and returns a new function that calls them in order. + * The arguments applied when calling the new function will also be applied to every function passed. + * The value of `this` refers to the last value returned in the chain that was not `undefined`. + * Therefore if a passed function does not return a value, the previously returned value is maintained. + * After all passed functions have been called the new function returns the last returned value (if any). + * If any of the passed functions are a chain, then the chain will be flattened. + * @method chain + * @param ...funcs {function} The functions to chain. + * @return {function} A new function that calls the passed functions in order. + */ + Common.chain = function() { + var funcs = []; + + for (var i = 0; i < arguments.length; i += 1) { + var func = arguments[i]; + + if (func._chained) { + // flatten already chained functions + funcs.push.apply(funcs, func._chained); + } else { + funcs.push(func); + } + } + + var chain = function() { + // https://github.com/GoogleChrome/devtools-docs/issues/53#issuecomment-51941358 + var lastResult, + args = new Array(arguments.length); + + for (var i = 0, l = arguments.length; i < l; i++) { + args[i] = arguments[i]; + } + + for (i = 0; i < funcs.length; i += 1) { + var result = funcs[i].apply(lastResult, args); + + if (typeof result !== 'undefined') { + lastResult = result; + } + } + + return lastResult; + }; + + chain._chained = funcs; + + return chain; + }; + + /** + * Chains a function to excute before the original function on the given `path` relative to `base`. + * See also docs for `Common.chain`. + * @method chainPathBefore + * @param {} base The base object + * @param {string} path The path relative to `base` + * @param {function} func The function to chain before the original + * @return {function} The chained function that replaced the original + */ + Common.chainPathBefore = function(base, path, func) { + return Common.set(base, path, Common.chain( + func, + Common.get(base, path) + )); + }; + + /** + * Chains a function to excute after the original function on the given `path` relative to `base`. + * See also docs for `Common.chain`. + * @method chainPathAfter + * @param {} base The base object + * @param {string} path The path relative to `base` + * @param {function} func The function to chain after the original + * @return {function} The chained function that replaced the original + */ + Common.chainPathAfter = function(base, path, func) { + return Common.set(base, path, Common.chain( + Common.get(base, path), + func + )); + }; + + /** + * Used to require external libraries outside of the bundle. + * It first looks for the `globalName` on the environment's global namespace. + * If the global is not found, it will fall back to using the standard `require` using the `moduleName`. + * @private + * @method _requireGlobal + * @param {string} globalName The global module name + * @param {string} moduleName The fallback CommonJS module name + * @return {} The loaded module + */ + Common._requireGlobal = function(globalName, moduleName) { + var obj = (typeof window !== 'undefined' ? window[globalName] : typeof global !== 'undefined' ? global[globalName] : null); + + // Breaks webpack :( + // return obj || require(moduleName); + + return obj; + }; +})(); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(213))) + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH = __webpack_require__(18); +var GetValue = __webpack_require__(4); + +// Allowed types: + +// Implicit +// { +// x: 4 +// } +// +// From function +// { +// x: function () +// } +// +// Randomly pick one element from the array +// { +// x: [a, b, c, d, e, f] +// } +// +// Random integer between min and max: +// { +// x: { randInt: [min, max] } +// } +// +// Random float between min and max: +// { +// x: { randFloat: [min, max] } +// } + +/** + * [description] + * + * @function Phaser.Utils.Objects.GetAdvancedValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {*} [description] + */ +var GetAdvancedValue = function (source, key, defaultValue) +{ + var value = GetValue(source, key, null); + + if (value === null) + { + return defaultValue; + } + else if (Array.isArray(value)) + { + return MATH.RND.pick(value); + } + else if (typeof value === 'object') + { + if (value.hasOwnProperty('randInt')) + { + return MATH.RND.integerInRange(value.randInt[0], value.randInt[1]); + } + else if (value.hasOwnProperty('randFloat')) + { + return MATH.RND.realInRange(value.randFloat[0], value.randFloat[1]); + } + } + else if (typeof value === 'function') + { + return value(key); + } + + return value; +}; + +module.exports = GetAdvancedValue; + + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var PluginCache = __webpack_require__(15); + +/** + * @classdesc + * The Game Object Creator is a Scene plugin that allows you to quickly create many common + * types of Game Objects and return them. Unlike the Game Object Factory, they are not automatically + * added to the Scene. + * + * Game Objects directly register themselves with the Creator and inject their own creation + * methods into the class. + * + * @class GameObjectCreator + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. + */ +var GameObjectCreator = new Class({ + + initialize: + + function GameObjectCreator (scene) + { + /** + * The Scene to which this Game Object Creator belongs. + * + * @name Phaser.GameObjects.GameObjectCreator#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems. + * + * @name Phaser.GameObjects.GameObjectCreator#systems + * @type {Phaser.Scenes.Systems} + * @protected + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.GameObjectCreator#displayList + * @type {Phaser.GameObjects.DisplayList} + * @protected + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Update List. + * + * @name Phaser.GameObjects.GameObjectCreator#updateList; + * @type {Phaser.GameObjects.UpdateList} + * @protected + * @since 3.0.0 + */ + this.updateList; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.GameObjectCreator#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.displayList = this.systems.displayList; + this.updateList = this.systems.updateList; + + this.systems.events.once('destroy', this.destroy, 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.GameObjects.GameObjectCreator#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.systems.events.once('shutdown', this.shutdown, 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.GameObjects.GameObjectCreator#shutdown + * @private + * @since 3.0.0 + */ + shutdown: function () + { + this.systems.events.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.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; + } + +}); + +// Static method called directly by the Game Object creator functions + +GameObjectCreator.register = function (factoryType, factoryFunction) +{ + if (!GameObjectCreator.prototype.hasOwnProperty(factoryType)) + { + GameObjectCreator.prototype[factoryType] = factoryFunction; + } +}; + +PluginCache.register('GameObjectCreator', GameObjectCreator, 'make'); + +module.exports = GameObjectCreator; + + +/***/ }), +/* 15 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Contains the plugins that Phaser uses globally and locally. +// These are the source objects, not instantiated. +var corePlugins = {}; + +// Contains the plugins that the dev has loaded into their game +// These are the source objects, not instantiated. +var customPlugins = {}; + +/** + * @typedef {object} CorePluginContainer + * + * @property {string} key - The unique name of this plugin in the core plugin cache. + * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. + * @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @property {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? + */ + +/** + * @typedef {object} CustomPluginContainer + * + * @property {string} key - The unique name of this plugin in the custom plugin cache. + * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. + */ + +var PluginCache = {}; + +/** + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + * + * @method Phaser.Plugins.PluginCache.register + * @since 3.8.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @param {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? + */ +PluginCache.register = function (key, plugin, mapping, custom) +{ + if (custom === undefined) { custom = false; } + + corePlugins[key] = { plugin: plugin, mapping: mapping, custom: custom }; +}; + +/** + * Stores a custom plugin in the global plugin cache. + * The key must be unique, within the scope of the cache. + * + * @method Phaser.Plugins.PluginCache.registerCustom + * @since 3.8.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @param {?any} data - A value to be passed to the plugin's `init` method. + */ +PluginCache.registerCustom = function (key, plugin, mapping, data) +{ + customPlugins[key] = { plugin: plugin, mapping: mapping, data: data }; +}; + +/** + * Checks if the given key is already being used in the core plugin cache. + * + * @method Phaser.Plugins.PluginCache.hasCore + * @since 3.8.0 + * + * @param {string} key - The key to check for. + * + * @return {boolean} `true` if the key is already in use in the core cache, otherwise `false`. + */ +PluginCache.hasCore = function (key) +{ + return corePlugins.hasOwnProperty(key); +}; + +/** + * Checks if the given key is already being used in the custom plugin cache. + * + * @method Phaser.Plugins.PluginCache.hasCustom + * @since 3.8.0 + * + * @param {string} key - The key to check for. + * + * @return {boolean} `true` if the key is already in use in the custom cache, otherwise `false`. + */ +PluginCache.hasCustom = function (key) +{ + return customPlugins.hasOwnProperty(key); +}; + +/** + * Returns the core plugin object from the cache based on the given key. + * + * @method Phaser.Plugins.PluginCache.getCore + * @since 3.8.0 + * + * @param {string} key - The key of the core plugin to get. + * + * @return {CorePluginContainer} The core plugin object. + */ +PluginCache.getCore = function (key) +{ + return corePlugins[key]; +}; + +/** + * Returns the custom plugin object from the cache based on the given key. + * + * @method Phaser.Plugins.PluginCache.getCustom + * @since 3.8.0 + * + * @param {string} key - The key of the custom plugin to get. + * + * @return {CustomPluginContainer} The custom plugin object. + */ +PluginCache.getCustom = function (key) +{ + return customPlugins[key]; +}; + +/** + * Returns an object from the custom cache based on the given key that can be instantiated. + * + * @method Phaser.Plugins.PluginCache.getCustomClass + * @since 3.8.0 + * + * @param {string} key - The key of the custom plugin to get. + * + * @return {function} The custom plugin object. + */ +PluginCache.getCustomClass = function (key) +{ + return (customPlugins.hasOwnProperty(key)) ? customPlugins[key].plugin : null; +}; + +/** + * Removes a core plugin based on the given key. + * + * @method Phaser.Plugins.PluginCache.remove + * @since 3.8.0 + * + * @param {string} key - The key of the core plugin to remove. + */ +PluginCache.remove = function (key) +{ + if (corePlugins.hasOwnProperty(key)) + { + delete corePlugins[key]; + } +}; + +/** + * Removes a custom plugin based on the given key. + * + * @method Phaser.Plugins.PluginCache.removeCustom + * @since 3.8.0 + * + * @param {string} key - The key of the custom plugin to remove. + */ +PluginCache.removeCustom = function (key) +{ + if (customPlugins.hasOwnProperty(key)) + { + delete customPlugins[key]; + } +}; + +/** + * Removes all Core Plugins. + * + * This includes all of the internal system plugins that Phaser needs, like the Input Plugin and Loader Plugin. + * So be sure you only call this if you do not wish to run Phaser again. + * + * @method Phaser.Plugins.PluginCache.destroyCorePlugins + * @since 3.12.0 + */ +PluginCache.destroyCorePlugins = function () +{ + for (var key in corePlugins) + { + if (corePlugins.hasOwnProperty(key)) + { + delete corePlugins[key]; + } + } +}; + +/** + * Removes all Custom Plugins. + * + * @method Phaser.Plugins.PluginCache.destroyCustomPlugins + * @since 3.12.0 + */ +PluginCache.destroyCustomPlugins = function () +{ + for (var key in customPlugins) + { + if (customPlugins.hasOwnProperty(key)) + { + delete customPlugins[key]; + } + } +}; + +module.exports = PluginCache; + + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Components + */ + +module.exports = { + + Alpha: __webpack_require__(438), + Animation: __webpack_require__(437), + BlendMode: __webpack_require__(436), + ComputedSize: __webpack_require__(1117), + Crop: __webpack_require__(1116), + Depth: __webpack_require__(435), + Flip: __webpack_require__(1115), + GetBounds: __webpack_require__(1114), + Mask: __webpack_require__(431), + Origin: __webpack_require__(1113), + Pipeline: __webpack_require__(133), + ScaleMode: __webpack_require__(1112), + ScrollFactor: __webpack_require__(428), + Size: __webpack_require__(1111), + Texture: __webpack_require__(1110), + TextureCrop: __webpack_require__(1109), + Tint: __webpack_require__(1108), + ToJSON: __webpack_require__(427), + Transform: __webpack_require__(426), + TransformMatrix: __webpack_require__(42), + Visible: __webpack_require__(425) + +}; + + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ComponentsToJSON = __webpack_require__(427); +var DataManager = __webpack_require__(102); +var EventEmitter = __webpack_require__(11); + +/** + * @classdesc + * The base class that all Game Objects extend. + * You don't create GameObjects directly and they cannot be added to the display list. + * Instead, use them as the base for your own custom classes. + * + * @class GameObject + * @memberof Phaser.GameObjects + * @extends Phaser.Events.EventEmitter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`. + */ +var GameObject = new Class({ + + Extends: EventEmitter, + + initialize: + + function GameObject (scene, type) + { + EventEmitter.call(this); + + /** + * The Scene to which this Game Object belongs. + * Game Objects can only belong to one Scene. + * + * @name Phaser.GameObjects.GameObject#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A textual representation of this Game Object, i.e. `sprite`. + * Used internally by Phaser but is available for your own custom classes to populate. + * + * @name Phaser.GameObjects.GameObject#type + * @type {string} + * @since 3.0.0 + */ + this.type = type; + + /** + * The parent Container of this Game Object, if it has one. + * + * @name Phaser.GameObjects.GameObject#parentContainer + * @type {Phaser.GameObjects.Container} + * @since 3.4.0 + */ + this.parentContainer = null; + + /** + * The name of this Game Object. + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.GameObject#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The active state of this Game Object. + * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. + * An active object is one which is having its logic and internal systems updated. + * + * @name Phaser.GameObjects.GameObject#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * The Tab Index of the Game Object. + * Reserved for future use by plugins and the Input Manager. + * + * @name Phaser.GameObjects.GameObject#tabIndex + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.tabIndex = -1; + + /** + * A Data Manager. + * It allows you to store, query and get key/value paired information specific to this Game Object. + * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. + * + * @name Phaser.GameObjects.GameObject#data + * @type {Phaser.Data.DataManager} + * @default null + * @since 3.0.0 + */ + this.data = null; + + /** + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. + * + * @name Phaser.GameObjects.GameObject#renderFlags + * @type {integer} + * @default 15 + * @since 3.0.0 + */ + this.renderFlags = 15; + + /** + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + * + * @example + * this.cameraFilter |= camera.id + * + * @name Phaser.GameObjects.GameObject#cameraFilter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cameraFilter = 0; + + /** + * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. + * Not usually set directly. Instead call `GameObject.setInteractive()`. + * + * @name Phaser.GameObjects.GameObject#input + * @type {?Phaser.Input.InteractiveObject} + * @default null + * @since 3.0.0 + */ + this.input = null; + + /** + * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. + * + * @name Phaser.GameObjects.GameObject#body + * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} + * @default null + * @since 3.0.0 + */ + 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 + scene.sys.queueDepthSort(); + }, + + /** + * Sets the `active` property of this Game Object and returns this Game Object for further chaining. + * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. + * + * @method Phaser.GameObjects.GameObject#setActive + * @since 3.0.0 + * + * @param {boolean} value - True if this Game Object should be set as active, false if not. + * + * @return {this} This GameObject. + */ + setActive: function (value) + { + this.active = value; + + return this; + }, + + /** + * Sets the `name` property of this Game Object and returns this Game Object for further chaining. + * The `name` property is not populated by Phaser and is presented for your own use. + * + * @method Phaser.GameObjects.GameObject#setName + * @since 3.0.0 + * + * @param {string} value - The name to be given to this Game Object. + * + * @return {this} This GameObject. + */ + setName: function (value) + { + this.name = value; + + return this; + }, + + /** + * Adds a Data Manager component to this Game Object. + * + * @method Phaser.GameObjects.GameObject#setDataEnabled + * @since 3.0.0 + * @see Phaser.Data.DataManager + * + * @return {this} This GameObject. + */ + setDataEnabled: function () + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this; + }, + + /** + * Allows you to store a key value pair within this Game Objects Data Manager. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * sprite.setData('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `getData`: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * sprite.data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.GameObjects.GameObject#setData + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {this} This GameObject. + */ + setData: function (key, value) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + this.data.set(key, value); + + return this; + }, + + /** + * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * sprite.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * sprite.getData([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.GameObjects.GameObject#getData + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + getData: function (key) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this.data.get(key); + }, + + /** + * Pass this Game Object to the Input Manager to enable it for Input. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * + * @method Phaser.GameObjects.GameObject#setInteractive + * @since 3.0.0 + * + * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? + * + * @return {this} This GameObject. + */ + setInteractive: function (shape, callback, dropZone) + { + this.scene.sys.input.enable(this, shape, callback, dropZone); + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will disable it. + * + * An object that is disabled for input stops processing or being considered for + * input events, but can be turned back on again at any time by simply calling + * `setInteractive()` with no arguments provided. + * + * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. + * + * @method Phaser.GameObjects.GameObject#disableInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + disableInteractive: function () + { + if (this.input) + { + this.input.enabled = false; + } + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. + * + * The Interactive Object that was assigned to this Game Object will be destroyed, + * removed from the Input Manager and cleared from this Game Object. + * + * If you wish to re-enable this Game Object at a later date you will need to + * re-create its InteractiveObject by calling `setInteractive` again. + * + * If you wish to only temporarily stop an object from receiving input then use + * `disableInteractive` instead, as that toggles the interactive state, where-as + * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) + * + * @method Phaser.GameObjects.GameObject#removeInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + removeInteractive: function () + { + this.scene.sys.input.clear(this); + + this.input = undefined; + + return this; + }, + + /** + * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. + * + * @method Phaser.GameObjects.GameObject#update + * @since 3.0.0 + * + * @param {...*} [args] - args + */ + update: function () + { + }, + + /** + * Returns a JSON representation of the Game Object. + * + * @method Phaser.GameObjects.GameObject#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + return ComponentsToJSON(this); + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * + * @method Phaser.GameObjects.GameObject#willRender + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * + * @return {boolean} True if the Game Object should be rendered, otherwise false. + */ + willRender: function (camera) + { + return !(GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter > 0 && (this.cameraFilter & camera.id))); + }, + + /** + * Returns an array containing the display list index of either this Game Object, or if it has one, + * its parent Container. It then iterates up through all of the parent containers until it hits the + * root of the display list (which is index 0 in the returned array). + * + * Used internally by the InputPlugin but also useful if you wish to find out the display depth of + * this Game Object and all of its ancestors. + * + * @method Phaser.GameObjects.GameObject#getIndexList + * @since 3.4.0 + * + * @return {integer[]} An array of display list position indexes. + */ + getIndexList: function () + { + // eslint-disable-next-line consistent-this + var child = this; + var parent = this.parentContainer; + + var indexes = []; + + while (parent) + { + // indexes.unshift([parent.getIndex(child), parent.name]); + indexes.unshift(parent.getIndex(child)); + + child = parent; + + if (!parent.parentContainer) + { + break; + } + else + { + parent = parent.parentContainer; + } + } + + // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']); + indexes.unshift(this.scene.sys.displayList.getIndex(child)); + + return indexes; + }, + + /** + * Destroys this Game Object removing it from the Display List and Update List and + * severing all ties to parent resources. + * + * Also removes itself from the Input Manager and Physics Manager if previously enabled. + * + * Use this to remove a Game Object from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * + * @method Phaser.GameObjects.GameObject#destroy + * @since 3.0.0 + * + * @param {boolean} [fromScene=false] - Is this Game Object being destroyed as the result of a Scene shutdown? + */ + destroy: function (fromScene) + { + if (fromScene === undefined) { fromScene = false; } + + // This Game Object has already been destroyed + if (!this.scene || this.ignoreDestroy) + { + return; + } + + if (this.preDestroy) + { + this.preDestroy.call(this); + } + + this.emit('destroy', this); + + var sys = this.scene.sys; + + if (!fromScene) + { + sys.displayList.remove(this); + sys.updateList.remove(this); + } + + if (this.input) + { + sys.input.clear(this); + this.input = undefined; + } + + if (this.data) + { + this.data.destroy(); + + this.data = undefined; + } + + if (this.body) + { + this.body.destroy(); + this.body = undefined; + } + + // Tell the Scene to re-sort the children + if (!fromScene) + { + sys.queueDepthSort(); + } + + this.active = false; + this.visible = false; + + this.scene = undefined; + + this.parentContainer = undefined; + + this.removeAllListeners(); + } + +}); + +/** + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + * + * @constant {integer} RENDER_MASK + * @memberof Phaser.GameObjects.GameObject + * @default + */ +GameObject.RENDER_MASK = 15; + +module.exports = GameObject; + + +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RND = __webpack_require__(441); + +var MATH_CONST = { + + /** + * The value of PI * 2. + * + * @name Phaser.Math.PI2 + * @type {number} + * @since 3.0.0 + */ + PI2: Math.PI * 2, + + /** + * The value of PI * 0.5. + * + * @name Phaser.Math.TAU + * @type {number} + * @since 3.0.0 + */ + TAU: Math.PI * 0.5, + + /** + * An epsilon value (1.0e-6) + * + * @name Phaser.Math.EPSILON + * @type {number} + * @since 3.0.0 + */ + EPSILON: 1.0e-6, + + /** + * For converting degrees to radians (PI / 180) + * + * @name Phaser.Math.DEG_TO_RAD + * @type {number} + * @since 3.0.0 + */ + DEG_TO_RAD: Math.PI / 180, + + /** + * For converting radians to degrees (180 / PI) + * + * @name Phaser.Math.RAD_TO_DEG + * @type {number} + * @since 3.0.0 + */ + RAD_TO_DEG: 180 / Math.PI, + + /** + * An instance of the Random Number Generator. + * + * @name Phaser.Math.RND + * @type {Phaser.Math.RandomDataGenerator} + * @since 3.0.0 + */ + RND: new RND() + +}; + +module.exports = MATH_CONST; + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(1); + +/** + * @typedef {object} GetTilesWithinFilteringOptions + * + * @property {boolean} [isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @property {boolean} [isColliding=false] - If true, only return tiles that collide on at least one side. + * @property {boolean} [hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + */ + +/** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithin + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {object} GetTilesWithinFilteringOptions - Optional filters to apply when getting the tiles. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithin = function (tileX, tileY, width, height, filteringOptions, layer) +{ + if (tileX === undefined) { tileX = 0; } + if (tileY === undefined) { tileY = 0; } + if (width === undefined) { width = layer.width; } + if (height === undefined) { height = layer.height; } + + var isNotEmpty = GetFastValue(filteringOptions, 'isNotEmpty', false); + var isColliding = GetFastValue(filteringOptions, 'isColliding', false); + var hasInterestingFace = GetFastValue(filteringOptions, 'hasInterestingFace', false); + + // Clip x, y to top left of map, while shrinking width/height to match. + if (tileX < 0) + { + width += tileX; + tileX = 0; + } + if (tileY < 0) + { + height += tileY; + tileY = 0; + } + + // Clip width and height to bottom right of map. + if (tileX + width > layer.width) + { + width = Math.max(layer.width - tileX, 0); + } + if (tileY + height > layer.height) + { + height = Math.max(layer.height - tileY, 0); + } + + var results = []; + + for (var ty = tileY; ty < tileY + height; ty++) + { + for (var tx = tileX; tx < tileX + width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile !== null) + { + if (isNotEmpty && tile.index === -1) { continue; } + if (isColliding && !tile.collides) { continue; } + if (hasInterestingFace && !tile.hasInterestingFace) { continue; } + results.push(tile); + } + } + } + + return results; +}; + +module.exports = GetTilesWithin; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FILE_CONST = { + + /** + * The Loader is idle. + * + * @name Phaser.Loader.LOADER_IDLE + * @type {integer} + * @since 3.0.0 + */ + LOADER_IDLE: 0, + + /** + * The Loader is actively loading. + * + * @name Phaser.Loader.LOADER_LOADING + * @type {integer} + * @since 3.0.0 + */ + LOADER_LOADING: 1, + + /** + * The Loader is processing files is has loaded. + * + * @name Phaser.Loader.LOADER_PROCESSING + * @type {integer} + * @since 3.0.0 + */ + LOADER_PROCESSING: 2, + + /** + * The Loader has completed loading and processing. + * + * @name Phaser.Loader.LOADER_COMPLETE + * @type {integer} + * @since 3.0.0 + */ + LOADER_COMPLETE: 3, + + /** + * The Loader is shutting down. + * + * @name Phaser.Loader.LOADER_SHUTDOWN + * @type {integer} + * @since 3.0.0 + */ + LOADER_SHUTDOWN: 4, + + /** + * The Loader has been destroyed. + * + * @name Phaser.Loader.LOADER_DESTROYED + * @type {integer} + * @since 3.0.0 + */ + LOADER_DESTROYED: 5, + + /** + * File is in the load queue but not yet started + * + * @name Phaser.Loader.FILE_PENDING + * @type {integer} + * @since 3.0.0 + */ + FILE_PENDING: 10, + + /** + * File has been started to load by the loader (onLoad called) + * + * @name Phaser.Loader.FILE_LOADING + * @type {integer} + * @since 3.0.0 + */ + FILE_LOADING: 11, + + /** + * File has loaded successfully, awaiting processing + * + * @name Phaser.Loader.FILE_LOADED + * @type {integer} + * @since 3.0.0 + */ + FILE_LOADED: 12, + + /** + * File failed to load + * + * @name Phaser.Loader.FILE_FAILED + * @type {integer} + * @since 3.0.0 + */ + FILE_FAILED: 13, + + /** + * File is being processed (onProcess callback) + * + * @name Phaser.Loader.FILE_PROCESSING + * @type {integer} + * @since 3.0.0 + */ + FILE_PROCESSING: 14, + + /** + * The File has errored somehow during processing. + * + * @name Phaser.Loader.FILE_ERRORED + * @type {integer} + * @since 3.0.0 + */ + FILE_ERRORED: 16, + + /** + * File has finished processing. + * + * @name Phaser.Loader.FILE_COMPLETE + * @type {integer} + * @since 3.0.0 + */ + FILE_COMPLETE: 17, + + /** + * File has been destroyed + * + * @name Phaser.Loader.FILE_DESTROYED + * @type {integer} + * @since 3.0.0 + */ + FILE_DESTROYED: 18, + + /** + * File was populated from local data and doesn't need an HTTP request + * + * @name Phaser.Loader.FILE_POPULATED + * @type {integer} + * @since 3.0.0 + */ + FILE_POPULATED: 19 + +}; + +module.exports = FILE_CONST; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsPlainObject = __webpack_require__(8); + +// @param {boolean} deep - Perform a deep copy? +// @param {object} target - The target object to copy to. +// @return {object} The extended object. + +/** + * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * + * @function Phaser.Utils.Objects.Extend + * @since 3.0.0 + * + * @return {object} [description] + */ +var Extend = function () +{ + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') + { + deep = target; + target = arguments[1] || {}; + + // skip the boolean and the target + i = 2; + } + + // extend Phaser if only one argument is passed + if (length === i) + { + target = this; + --i; + } + + for (; i < length; i++) + { + // Only deal with non-null/undefined values + if ((options = arguments[i]) != null) + { + // Extend the base object + for (name in options) + { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target === copy) + { + continue; + } + + // Recurse if we're merging plain objects or arrays + if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) + { + if (copyIsArray) + { + copyIsArray = false; + clone = src && Array.isArray(src) ? src : []; + } + else + { + clone = src && IsPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = Extend(deep, clone, copy); + + // Don't bring in undefined values + } + else if (copy !== undefined) + { + target[name] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +module.exports = Extend; + + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var GetFastValue = __webpack_require__(1); +var GetURL = __webpack_require__(157); +var MergeXHRSettings = __webpack_require__(156); +var XHRLoader = __webpack_require__(282); +var XHRSettings = __webpack_require__(115); + +/** + * @typedef {object} FileConfig + * + * @property {string} type - The file type string (image, json, etc) for sorting within the Loader. + * @property {string} key - Unique cache key (unique within its file type) + * @property {string} [url] - The URL of the file, not including baseURL. + * @property {string} [path] - The path of the file, not including the baseURL. + * @property {string} [extension] - The default extension this file uses. + * @property {XMLHttpRequestResponseType} [responseType] - The responseType to be used by the XHR request. + * @property {(XHRSettingsObject|false)} [xhrSettings=false] - Custom XHR Settings specific to this file and merged with the Loader defaults. + * @property {any} [config] - A config object that can be used by file types to store transitional data. + */ + +/** + * @classdesc + * The base File class used by all File Types that the Loader can support. + * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. + * + * @class File + * @memberof Phaser.Loader + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. + * @param {FileConfig} fileConfig - The file configuration object, as created by the file type. + */ +var File = new Class({ + + initialize: + + function File (loader, fileConfig) + { + /** + * A reference to the Loader that is going to load this file. + * + * @name Phaser.Loader.File#loader + * @type {Phaser.Loader.LoaderPlugin} + * @since 3.0.0 + */ + this.loader = loader; + + /** + * A reference to the Cache, or Texture Manager, that is going to store this file if it loads. + * + * @name Phaser.Loader.File#cache + * @type {(Phaser.Cache.BaseCache|Phaser.Textures.TextureManager)} + * @since 3.7.0 + */ + this.cache = GetFastValue(fileConfig, 'cache', false); + + /** + * The file type string (image, json, etc) for sorting within the Loader. + * + * @name Phaser.Loader.File#type + * @type {string} + * @since 3.0.0 + */ + this.type = GetFastValue(fileConfig, 'type', false); + + /** + * Unique cache key (unique within its file type) + * + * @name Phaser.Loader.File#key + * @type {string} + * @since 3.0.0 + */ + this.key = GetFastValue(fileConfig, 'key', false); + + var loadKey = this.key; + + if (loader.prefix && loader.prefix !== '') + { + this.key = loader.prefix + loadKey; + } + + if (!this.type || !this.key) + { + throw new Error('Error calling \'Loader.' + this.type + '\' invalid key provided.'); + } + + /** + * The URL of the file, not including baseURL. + * Automatically has Loader.path prepended to it. + * + * @name Phaser.Loader.File#url + * @type {string} + * @since 3.0.0 + */ + this.url = GetFastValue(fileConfig, 'url'); + + if (this.url === undefined) + { + this.url = loader.path + loadKey + '.' + GetFastValue(fileConfig, 'extension', ''); + } + else if (typeof(this.url) !== 'function') + { + this.url = loader.path + this.url; + } + + /** + * The final URL this file will load from, including baseURL and path. + * Set automatically when the Loader calls 'load' on this file. + * + * @name Phaser.Loader.File#src + * @type {string} + * @since 3.0.0 + */ + this.src = ''; + + /** + * The merged XHRSettings for this file. + * + * @name Phaser.Loader.File#xhrSettings + * @type {XHRSettingsObject} + * @since 3.0.0 + */ + this.xhrSettings = XHRSettings(GetFastValue(fileConfig, 'responseType', undefined)); + + if (GetFastValue(fileConfig, 'xhrSettings', false)) + { + this.xhrSettings = MergeXHRSettings(this.xhrSettings, GetFastValue(fileConfig, 'xhrSettings', {})); + } + + /** + * The XMLHttpRequest instance (as created by XHR Loader) that is loading this File. + * + * @name Phaser.Loader.File#xhrLoader + * @type {?XMLHttpRequest} + * @since 3.0.0 + */ + this.xhrLoader = null; + + /** + * The current state of the file. One of the FILE_CONST values. + * + * @name Phaser.Loader.File#state + * @type {integer} + * @since 3.0.0 + */ + this.state = (typeof(this.url) === 'function') ? CONST.FILE_POPULATED : CONST.FILE_PENDING; + + /** + * The total size of this file. + * Set by onProgress and only if loading via XHR. + * + * @name Phaser.Loader.File#bytesTotal + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.bytesTotal = 0; + + /** + * Updated as the file loads. + * Only set if loading via XHR. + * + * @name Phaser.Loader.File#bytesLoaded + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.bytesLoaded = -1; + + /** + * A percentage value between 0 and 1 indicating how much of this file has loaded. + * Only set if loading via XHR. + * + * @name Phaser.Loader.File#percentComplete + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.percentComplete = -1; + + /** + * For CORs based loading. + * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set) + * + * @name Phaser.Loader.File#crossOrigin + * @type {(string|undefined)} + * @since 3.0.0 + */ + this.crossOrigin = undefined; + + /** + * The processed file data, stored here after the file has loaded. + * + * @name Phaser.Loader.File#data + * @type {*} + * @since 3.0.0 + */ + this.data = undefined; + + /** + * A config object that can be used by file types to store transitional data. + * + * @name Phaser.Loader.File#config + * @type {*} + * @since 3.0.0 + */ + this.config = GetFastValue(fileConfig, 'config', {}); + + /** + * If this is a multipart file, i.e. an atlas and its json together, then this is a reference + * to the parent MultiFile. Set and used internally by the Loader or specific file types. + * + * @name Phaser.Loader.File#multiFile + * @type {?Phaser.Loader.MultiFile} + * @since 3.7.0 + */ + this.multiFile; + + /** + * Does this file have an associated linked file? Such as an image and a normal map. + * Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't + * actually bound by data, where-as a linkFile is. + * + * @name Phaser.Loader.File#linkFile + * @type {?Phaser.Loader.File} + * @since 3.7.0 + */ + this.linkFile; + }, + + /** + * Links this File with another, so they depend upon each other for loading and processing. + * + * @method Phaser.Loader.File#setLink + * @since 3.7.0 + * + * @param {Phaser.Loader.File} fileB - The file to link to this one. + */ + setLink: function (fileB) + { + this.linkFile = fileB; + + fileB.linkFile = this; + }, + + /** + * Resets the XHRLoader instance this file is using. + * + * @method Phaser.Loader.File#resetXHR + * @since 3.0.0 + */ + resetXHR: function () + { + if (this.xhrLoader) + { + this.xhrLoader.onload = undefined; + this.xhrLoader.onerror = undefined; + this.xhrLoader.onprogress = undefined; + } + }, + + /** + * Called by the Loader, starts the actual file downloading. + * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. + * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + * + * @method Phaser.Loader.File#load + * @since 3.0.0 + */ + load: function () + { + if (this.state === CONST.FILE_POPULATED) + { + // Can happen for example in a JSONFile if they've provided a JSON object instead of a URL + this.loader.nextFile(this, true); + } + else + { + this.src = GetURL(this, this.loader.baseURL); + + if (this.src.indexOf('data:') === 0) + { + console.warn('Local data URIs are not supported: ' + this.key); + } + else + { + // The creation of this XHRLoader starts the load process going. + // It will automatically call the following, based on the load outcome: + // + // xhr.onload = this.onLoad + // xhr.onerror = this.onError + // xhr.onprogress = this.onProgress + + this.xhrLoader = XHRLoader(this, this.loader.xhr); + } + } + }, + + /** + * Called when the file finishes loading, is sent a DOM ProgressEvent. + * + * @method Phaser.Loader.File#onLoad + * @since 3.0.0 + * + * @param {XMLHttpRequest} xhr - The XMLHttpRequest that caused this onload event. + * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this load. + */ + onLoad: function (xhr, event) + { + var success = !(event.target && event.target.status !== 200); + + // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called. + if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) + { + success = false; + } + + this.resetXHR(); + + this.loader.nextFile(this, success); + }, + + /** + * Called if the file errors while loading, is sent a DOM ProgressEvent. + * + * @method Phaser.Loader.File#onError + * @since 3.0.0 + * + * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this error. + */ + onError: function () + { + this.resetXHR(); + + this.loader.nextFile(this, false); + }, + + /** + * Called during the file load progress. Is sent a DOM ProgressEvent. + * + * @method Phaser.Loader.File#onProgress + * @since 3.0.0 + * + * @param {ProgressEvent} event - The DOM ProgressEvent. + */ + onProgress: function (event) + { + if (event.lengthComputable) + { + this.bytesLoaded = event.loaded; + this.bytesTotal = event.total; + + this.percentComplete = Math.min((this.bytesLoaded / this.bytesTotal), 1); + + this.loader.emit('fileprogress', this, this.percentComplete); + } + }, + + /** + * Usually overridden by the FileTypes and is called by Loader.nextFile. + * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage. + * + * @method Phaser.Loader.File#onProcess + * @since 3.0.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.onProcessComplete(); + }, + + /** + * Called when the File has completed processing. + * Checks on the state of its multifile, if set. + * + * @method Phaser.Loader.File#onProcessComplete + * @since 3.7.0 + */ + onProcessComplete: function () + { + this.state = CONST.FILE_COMPLETE; + + if (this.multiFile) + { + this.multiFile.onFileComplete(this); + } + + this.loader.fileProcessComplete(this); + }, + + /** + * Called when the File has completed processing but it generated an error. + * Checks on the state of its multifile, if set. + * + * @method Phaser.Loader.File#onProcessError + * @since 3.7.0 + */ + onProcessError: function () + { + this.state = CONST.FILE_ERRORED; + + if (this.multiFile) + { + this.multiFile.onFileFailed(this); + } + + this.loader.fileProcessComplete(this); + }, + + /** + * Checks if a key matching the one used by this file exists in the target Cache or not. + * This is called automatically by the LoaderPlugin to decide if the file can be safely + * loaded or will conflict. + * + * @method Phaser.Loader.File#hasCacheConflict + * @since 3.7.0 + * + * @return {boolean} `true` if adding this file will cause a conflict, otherwise `false`. + */ + hasCacheConflict: function () + { + return (this.cache && this.cache.exists(this.key)); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * This method is often overridden by specific file types. + * + * @method Phaser.Loader.File#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.cache) + { + this.cache.add(this.key, this.data); + } + + this.pendingDestroy(); + }, + + /** + * You can listen for this event from the LoaderPlugin. It is dispatched _every time_ + * a file loads and is sent 3 arguments, which allow you to identify the file: + * + * ```javascript + * this.load.on('filecomplete', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * @event Phaser.Loader.File#fileCompleteEvent + * @param {string} key - The key of the file that just loaded and finished processing. + * @param {string} type - The type of the file that just loaded and finished processing. + * @param {any} data - The data of the file. + */ + + /** + * You can listen for this event from the LoaderPlugin. It is dispatched only once per + * file and you have to use a special listener handle to pick it up. + * + * The string of the event is based on the file type and the key you gave it, split up + * using hyphens. + * + * For example, if you have loaded an image with a key of `monster`, you can listen for it + * using the following: + * + * ```javascript + * this.load.on('filecomplete-image-monster', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a texture atlas with a key of `Level1`: + * + * ```javascript + * this.load.on('filecomplete-atlas-Level1', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: + * + * ```javascript + * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * @event Phaser.Loader.File#singleFileCompleteEvent + * @param {any} data - The data of the file. + */ + + /** + * Called once the file has been added to its cache and is now ready for deletion from the Loader. + * It will emit a `filecomplete` event from the LoaderPlugin. + * + * @method Phaser.Loader.File#pendingDestroy + * @fires Phaser.Loader.File#fileCompleteEvent + * @fires Phaser.Loader.File#singleFileCompleteEvent + * @since 3.7.0 + */ + pendingDestroy: function (data) + { + if (data === undefined) { data = this.data; } + + var key = this.key; + var type = this.type; + + this.loader.emit('filecomplete', key, type, data); + this.loader.emit('filecomplete-' + type + '-' + key, key, type, data); + + this.loader.flagForRemoval(this); + }, + + /** + * Destroy this File and any references it holds. + * + * @method Phaser.Loader.File#destroy + * @since 3.7.0 + */ + destroy: function () + { + this.loader = null; + this.cache = null; + this.xhrSettings = null; + this.multiFile = null; + this.linkFile = null; + this.data = null; + } + +}); + +/** + * Static method for creating object URL using URL API and setting it as image 'src' attribute. + * If URL API is not supported (usually on old browsers) it falls back to creating Base64 encoded url using FileReader. + * + * @method Phaser.Loader.File.createObjectURL + * @static + * @param {HTMLImageElement} image - Image object which 'src' attribute should be set to object URL. + * @param {Blob} blob - A Blob object to create an object URL for. + * @param {string} defaultType - Default mime type used if blob type is not available. + */ +File.createObjectURL = function (image, blob, defaultType) +{ + if (typeof URL === 'function') + { + image.src = URL.createObjectURL(blob); + } + else + { + var reader = new FileReader(); + + reader.onload = function () + { + image.removeAttribute('crossOrigin'); + image.src = 'data:' + (blob.type || defaultType) + ';base64,' + reader.result.split(',')[1]; + }; + + reader.onerror = image.onerror; + + reader.readAsDataURL(blob); + } +}; + +/** + * Static method for releasing an existing object URL which was previously created + * by calling {@link File#createObjectURL} method. + * + * @method Phaser.Loader.File.revokeObjectURL + * @static + * @param {HTMLImageElement} image - Image object which 'src' attribute should be revoked. + */ +File.revokeObjectURL = function (image) +{ + if (typeof URL === 'function') + { + URL.revokeObjectURL(image.src); + } +}; + +module.exports = File; + + +/***/ }), +/* 23 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes a reference to the Canvas Renderer, a Canvas Rendering Context, a Game Object, a Camera and a parent matrix + * and then performs the following steps: + * + * 1) Checks the alpha of the source combined with the Camera alpha. If 0 or less it aborts. + * 2) Takes the Camera and Game Object matrix and multiplies them, combined with the parent matrix if given. + * 3) Sets the blend mode of the context to be that used by the Game Object. + * 4) Sets the alpha value of the context to be that used by the Game Object combined with the Camera. + * 5) Saves the context state. + * 6) Sets the final matrix values into the context via setTransform. + * + * This function is only meant to be used internally. Most of the Canvas Renderer classes use it. + * + * @function Phaser.Renderer.Canvas.SetTransform + * @since 3.12.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {CanvasRenderingContext2D} ctx - The canvas context to set the transform on. + * @param {Phaser.GameObjects.GameObject} src - The Game Object being rendered. Can be any type that extends the base class. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A parent transform matrix to apply to the Game Object before rendering. + * + * @return {boolean} `true` if the Game Object context was set, otherwise `false`. + */ +var SetTransform = function (renderer, ctx, src, camera, parentMatrix) +{ + var alpha = camera.alpha * src.alpha; + + if (alpha <= 0) + { + // Nothing to see, so don't waste time calculating stuff + return false; + } + + var camMatrix = renderer._tempMatrix1.copyFromArray(camera.matrix.matrix); + var gameObjectMatrix = renderer._tempMatrix2.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + var calcMatrix = renderer._tempMatrix3; + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + gameObjectMatrix.e = src.x; + gameObjectMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(gameObjectMatrix, calcMatrix); + } + else + { + gameObjectMatrix.e -= camera.scrollX * src.scrollFactorX; + gameObjectMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(gameObjectMatrix, calcMatrix); + } + + // Blend Mode + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + + // Alpha + ctx.globalAlpha = alpha; + + ctx.save(); + + calcMatrix.setToContext(ctx); + + return true; +}; + +module.exports = SetTransform; + + +/***/ }), +/* 24 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Force a value within the boundaries by clamping it to the range `min`, `max`. + * + * @function Phaser.Math.Clamp + * @since 3.0.0 + * + * @param {number} value - The value to be clamped. + * @param {number} min - The minimum bounds. + * @param {number} max - The maximum bounds. + * + * @return {number} The clamped value. + */ +var Clamp = function (value, min, max) +{ + return Math.max(min, Math.min(max, value)); +}; + +module.exports = Clamp; + + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Body` module contains methods for creating and manipulating body models. +* A `Matter.Body` is a rigid body that can be simulated by a `Matter.Engine`. +* Factories for commonly used body configurations (such as rectangles, circles and other polygons) can be found in the module `Matter.Bodies`. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). + +* @class Body +*/ + +var Body = {}; + +module.exports = Body; + +var Vertices = __webpack_require__(29); +var Vector = __webpack_require__(34); +var Sleeping = __webpack_require__(89); +var Common = __webpack_require__(12); +var Bounds = __webpack_require__(33); +var Axes = __webpack_require__(152); + +(function() { + + Body._inertiaScale = 4; + Body._nextCollidingGroupId = 1; + Body._nextNonCollidingGroupId = -1; + Body._nextCategory = 0x0001; + + /** + * Creates a new rigid body model. The options parameter is an object that specifies any properties you wish to override the defaults. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * Vertices must be specified in clockwise order. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {} options + * @return {body} body + */ + Body.create = function(options) { + var defaults = { + id: Common.nextId(), + type: 'body', + label: 'Body', + gameObject: null, + parts: [], + plugin: {}, + angle: 0, + vertices: Vertices.fromPath('L 0 0 L 40 0 L 40 40 L 0 40'), + position: { x: 0, y: 0 }, + force: { x: 0, y: 0 }, + torque: 0, + positionImpulse: { x: 0, y: 0 }, + previousPositionImpulse: { x: 0, y: 0 }, + constraintImpulse: { x: 0, y: 0, angle: 0 }, + totalContacts: 0, + speed: 0, + angularSpeed: 0, + velocity: { x: 0, y: 0 }, + angularVelocity: 0, + isSensor: false, + isStatic: false, + isSleeping: false, + ignoreGravity: false, + ignorePointer: false, + motion: 0, + sleepThreshold: 60, + density: 0.001, + restitution: 0, + friction: 0.1, + frictionStatic: 0.5, + frictionAir: 0.01, + collisionFilter: { + category: 0x0001, + mask: 0xFFFFFFFF, + group: 0 + }, + slop: 0.05, + timeScale: 1, + render: { + visible: true, + opacity: 1, + sprite: { + xScale: 1, + yScale: 1, + xOffset: 0, + yOffset: 0 + }, + lineWidth: 0 + }, + + events: null, + bounds: null, + chamfer: null, + circleRadius: 0, + positionPrev: null, + anglePrev: 0, + parent: null, + + axes: null, + area: 0, + mass: 0, + inertia: 0, + + _original: null + }; + + var body = Common.extend(defaults, options); + + _initProperties(body, options); + + return body; + }; + + /** + * Returns the next unique group index for which bodies will collide. + * If `isNonColliding` is `true`, returns the next unique group index for which bodies will _not_ collide. + * See `body.collisionFilter` for more information. + * @method nextGroup + * @param {bool} [isNonColliding=false] + * @return {Number} Unique group index + */ + Body.nextGroup = function(isNonColliding) { + if (isNonColliding) + return Body._nextNonCollidingGroupId--; + + return Body._nextCollidingGroupId++; + }; + + /** + * Returns the next unique category bitfield (starting after the initial default category `0x0001`). + * There are 32 available. See `body.collisionFilter` for more information. + * @method nextCategory + * @return {Number} Unique category bitfield + */ + Body.nextCategory = function() { + Body._nextCategory = Body._nextCategory << 1; + return Body._nextCategory; + }; + + /** + * Initialises body properties. + * @method _initProperties + * @private + * @param {body} body + * @param {} [options] + */ + var _initProperties = function(body, options) { + options = options || {}; + + // init required properties (order is important) + Body.set(body, { + bounds: body.bounds || Bounds.create(body.vertices), + positionPrev: body.positionPrev || Vector.clone(body.position), + anglePrev: body.anglePrev || body.angle, + vertices: body.vertices, + parts: body.parts || [body], + isStatic: body.isStatic, + isSleeping: body.isSleeping, + parent: body.parent || body + }); + + Vertices.rotate(body.vertices, body.angle, body.position); + Axes.rotate(body.axes, body.angle); + Bounds.update(body.bounds, body.vertices, body.velocity); + + // allow options to override the automatically calculated properties + Body.set(body, { + axes: options.axes || body.axes, + area: options.area || body.area, + mass: options.mass || body.mass, + inertia: options.inertia || body.inertia + }); + + // render properties + var defaultFillStyle = (body.isStatic ? '#2e2b44' : Common.choose(['#006BA6', '#0496FF', '#FFBC42', '#D81159', '#8F2D56'])), + defaultStrokeStyle = '#000'; + body.render.fillStyle = body.render.fillStyle || defaultFillStyle; + body.render.strokeStyle = body.render.strokeStyle || defaultStrokeStyle; + body.render.sprite.xOffset += -(body.bounds.min.x - body.position.x) / (body.bounds.max.x - body.bounds.min.x); + body.render.sprite.yOffset += -(body.bounds.min.y - body.position.y) / (body.bounds.max.y - body.bounds.min.y); + }; + + /** + * Given a property and a value (or map of), sets the property(s) on the body, using the appropriate setter functions if they exist. + * Prefer to use the actual setter functions in performance critical situations. + * @method set + * @param {body} body + * @param {} settings A property name (or map of properties and values) to set on the body. + * @param {} value The value to set if `settings` is a single property name. + */ + Body.set = function(body, settings, value) { + var property; + + if (typeof settings === 'string') { + property = settings; + settings = {}; + settings[property] = value; + } + + for (property in settings) { + + if (!settings.hasOwnProperty(property)) + continue; + + value = settings[property]; + switch (property) { + + case 'isStatic': + Body.setStatic(body, value); + break; + case 'isSleeping': + Sleeping.set(body, value); + break; + case 'mass': + Body.setMass(body, value); + break; + case 'density': + Body.setDensity(body, value); + break; + case 'inertia': + Body.setInertia(body, value); + break; + case 'vertices': + Body.setVertices(body, value); + break; + case 'position': + Body.setPosition(body, value); + break; + case 'angle': + Body.setAngle(body, value); + break; + case 'velocity': + Body.setVelocity(body, value); + break; + case 'angularVelocity': + Body.setAngularVelocity(body, value); + break; + case 'parts': + Body.setParts(body, value); + break; + default: + body[property] = value; + + } + } + }; + + /** + * Sets the body as static, including isStatic flag and setting mass and inertia to Infinity. + * @method setStatic + * @param {body} body + * @param {bool} isStatic + */ + Body.setStatic = function(body, isStatic) { + for (var i = 0; i < body.parts.length; i++) { + var part = body.parts[i]; + part.isStatic = isStatic; + + if (isStatic) { + part._original = { + restitution: part.restitution, + friction: part.friction, + mass: part.mass, + inertia: part.inertia, + density: part.density, + inverseMass: part.inverseMass, + inverseInertia: part.inverseInertia + }; + + part.restitution = 0; + part.friction = 1; + part.mass = part.inertia = part.density = Infinity; + part.inverseMass = part.inverseInertia = 0; + + part.positionPrev.x = part.position.x; + part.positionPrev.y = part.position.y; + part.anglePrev = part.angle; + part.angularVelocity = 0; + part.speed = 0; + part.angularSpeed = 0; + part.motion = 0; + } else if (part._original) { + part.restitution = part._original.restitution; + part.friction = part._original.friction; + part.mass = part._original.mass; + part.inertia = part._original.inertia; + part.density = part._original.density; + part.inverseMass = part._original.inverseMass; + part.inverseInertia = part._original.inverseInertia; + + part._original = null; + } + } + }; + + /** + * Sets the mass of the body. Inverse mass, density and inertia are automatically updated to reflect the change. + * @method setMass + * @param {body} body + * @param {number} mass + */ + Body.setMass = function(body, mass) { + var moment = body.inertia / (body.mass / 6); + body.inertia = moment * (mass / 6); + body.inverseInertia = 1 / body.inertia; + + body.mass = mass; + body.inverseMass = 1 / body.mass; + body.density = body.mass / body.area; + }; + + /** + * Sets the density of the body. Mass and inertia are automatically updated to reflect the change. + * @method setDensity + * @param {body} body + * @param {number} density + */ + Body.setDensity = function(body, density) { + Body.setMass(body, density * body.area); + body.density = density; + }; + + /** + * Sets the moment of inertia (i.e. second moment of area) of the body of the body. + * Inverse inertia is automatically updated to reflect the change. Mass is not changed. + * @method setInertia + * @param {body} body + * @param {number} inertia + */ + Body.setInertia = function(body, inertia) { + body.inertia = inertia; + body.inverseInertia = 1 / body.inertia; + }; + + /** + * Sets the body's vertices and updates body properties accordingly, including inertia, area and mass (with respect to `body.density`). + * Vertices will be automatically transformed to be orientated around their centre of mass as the origin. + * They are then automatically translated to world space based on `body.position`. + * + * The `vertices` argument should be passed as an array of `Matter.Vector` points (or a `Matter.Vertices` array). + * Vertices must form a convex hull, concave hulls are not supported. + * + * @method setVertices + * @param {body} body + * @param {vector[]} vertices + */ + Body.setVertices = function(body, vertices) { + // change vertices + if (vertices[0].body === body) { + body.vertices = vertices; + } else { + body.vertices = Vertices.create(vertices, body); + } + + // update properties + body.axes = Axes.fromVertices(body.vertices); + body.area = Vertices.area(body.vertices); + Body.setMass(body, body.density * body.area); + + // orient vertices around the centre of mass at origin (0, 0) + var centre = Vertices.centre(body.vertices); + Vertices.translate(body.vertices, centre, -1); + + // update inertia while vertices are at origin (0, 0) + Body.setInertia(body, Body._inertiaScale * Vertices.inertia(body.vertices, body.mass)); + + // update geometry + Vertices.translate(body.vertices, body.position); + Bounds.update(body.bounds, body.vertices, body.velocity); + }; + + /** + * Sets the parts of the `body` and updates mass, inertia and centroid. + * Each part will have its parent set to `body`. + * By default the convex hull will be automatically computed and set on `body`, unless `autoHull` is set to `false.` + * Note that this method will ensure that the first part in `body.parts` will always be the `body`. + * @method setParts + * @param {body} body + * @param [body] parts + * @param {bool} [autoHull=true] + */ + Body.setParts = function(body, parts, autoHull) { + var i; + + // add all the parts, ensuring that the first part is always the parent body + parts = parts.slice(0); + body.parts.length = 0; + body.parts.push(body); + body.parent = body; + + for (i = 0; i < parts.length; i++) { + var part = parts[i]; + if (part !== body) { + part.parent = body; + body.parts.push(part); + } + } + + if (body.parts.length === 1) + return; + + autoHull = typeof autoHull !== 'undefined' ? autoHull : true; + + // find the convex hull of all parts to set on the parent body + if (autoHull) { + var vertices = []; + for (i = 0; i < parts.length; i++) { + vertices = vertices.concat(parts[i].vertices); + } + + Vertices.clockwiseSort(vertices); + + var hull = Vertices.hull(vertices), + hullCentre = Vertices.centre(hull); + + Body.setVertices(body, hull); + Vertices.translate(body.vertices, hullCentre); + } + + // sum the properties of all compound parts of the parent body + var total = Body._totalProperties(body); + + body.area = total.area; + body.parent = body; + body.position.x = total.centre.x; + body.position.y = total.centre.y; + body.positionPrev.x = total.centre.x; + body.positionPrev.y = total.centre.y; + + Body.setMass(body, total.mass); + Body.setInertia(body, total.inertia); + Body.setPosition(body, total.centre); + }; + + /** + * Sets the position of the body instantly. Velocity, angle, force etc. are unchanged. + * @method setPosition + * @param {body} body + * @param {vector} position + */ + Body.setPosition = function(body, position) { + var delta = Vector.sub(position, body.position); + body.positionPrev.x += delta.x; + body.positionPrev.y += delta.y; + + for (var i = 0; i < body.parts.length; i++) { + var part = body.parts[i]; + part.position.x += delta.x; + part.position.y += delta.y; + Vertices.translate(part.vertices, delta); + Bounds.update(part.bounds, part.vertices, body.velocity); + } + }; + + /** + * Sets the angle of the body instantly. Angular velocity, position, force etc. are unchanged. + * @method setAngle + * @param {body} body + * @param {number} angle + */ + Body.setAngle = function(body, angle) { + var delta = angle - body.angle; + body.anglePrev += delta; + + for (var i = 0; i < body.parts.length; i++) { + var part = body.parts[i]; + part.angle += delta; + Vertices.rotate(part.vertices, delta, body.position); + Axes.rotate(part.axes, delta); + Bounds.update(part.bounds, part.vertices, body.velocity); + if (i > 0) { + Vector.rotateAbout(part.position, delta, body.position, part.position); + } + } + }; + + /** + * Sets the linear velocity of the body instantly. Position, angle, force etc. are unchanged. See also `Body.applyForce`. + * @method setVelocity + * @param {body} body + * @param {vector} velocity + */ + Body.setVelocity = function(body, velocity) { + body.positionPrev.x = body.position.x - velocity.x; + body.positionPrev.y = body.position.y - velocity.y; + body.velocity.x = velocity.x; + body.velocity.y = velocity.y; + body.speed = Vector.magnitude(body.velocity); + }; + + /** + * Sets the angular velocity of the body instantly. Position, angle, force etc. are unchanged. See also `Body.applyForce`. + * @method setAngularVelocity + * @param {body} body + * @param {number} velocity + */ + Body.setAngularVelocity = function(body, velocity) { + body.anglePrev = body.angle - velocity; + body.angularVelocity = velocity; + body.angularSpeed = Math.abs(body.angularVelocity); + }; + + /** + * Moves a body by a given vector relative to its current position, without imparting any velocity. + * @method translate + * @param {body} body + * @param {vector} translation + */ + Body.translate = function(body, translation) { + Body.setPosition(body, Vector.add(body.position, translation)); + }; + + /** + * Rotates a body by a given angle relative to its current angle, without imparting any angular velocity. + * @method rotate + * @param {body} body + * @param {number} rotation + * @param {vector} [point] + */ + Body.rotate = function(body, rotation, point) { + if (!point) { + Body.setAngle(body, body.angle + rotation); + } else { + var cos = Math.cos(rotation), + sin = Math.sin(rotation), + dx = body.position.x - point.x, + dy = body.position.y - point.y; + + Body.setPosition(body, { + x: point.x + (dx * cos - dy * sin), + y: point.y + (dx * sin + dy * cos) + }); + + Body.setAngle(body, body.angle + rotation); + } + }; + + /** + * Scales the body, including updating physical properties (mass, area, axes, inertia), from a world-space point (default is body centre). + * @method scale + * @param {body} body + * @param {number} scaleX + * @param {number} scaleY + * @param {vector} [point] + */ + Body.scale = function(body, scaleX, scaleY, point) { + var totalArea = 0, + totalInertia = 0; + + point = point || body.position; + + for (var i = 0; i < body.parts.length; i++) { + var part = body.parts[i]; + + // scale vertices + Vertices.scale(part.vertices, scaleX, scaleY, point); + + // update properties + part.axes = Axes.fromVertices(part.vertices); + part.area = Vertices.area(part.vertices); + Body.setMass(part, body.density * part.area); + + // update inertia (requires vertices to be at origin) + Vertices.translate(part.vertices, { x: -part.position.x, y: -part.position.y }); + Body.setInertia(part, Body._inertiaScale * Vertices.inertia(part.vertices, part.mass)); + Vertices.translate(part.vertices, { x: part.position.x, y: part.position.y }); + + if (i > 0) { + totalArea += part.area; + totalInertia += part.inertia; + } + + // scale position + part.position.x = point.x + (part.position.x - point.x) * scaleX; + part.position.y = point.y + (part.position.y - point.y) * scaleY; + + // update bounds + Bounds.update(part.bounds, part.vertices, body.velocity); + } + + // handle parent body + if (body.parts.length > 1) { + body.area = totalArea; + + if (!body.isStatic) { + Body.setMass(body, body.density * totalArea); + Body.setInertia(body, totalInertia); + } + } + + // handle circles + if (body.circleRadius) { + if (scaleX === scaleY) { + body.circleRadius *= scaleX; + } else { + // body is no longer a circle + body.circleRadius = null; + } + } + }; + + /** + * Performs a simulation step for the given `body`, including updating position and angle using Verlet integration. + * @method update + * @param {body} body + * @param {number} deltaTime + * @param {number} timeScale + * @param {number} correction + */ + Body.update = function(body, deltaTime, timeScale, correction) { + var deltaTimeSquared = Math.pow(deltaTime * timeScale * body.timeScale, 2); + + // from the previous step + var frictionAir = 1 - body.frictionAir * timeScale * body.timeScale, + velocityPrevX = body.position.x - body.positionPrev.x, + velocityPrevY = body.position.y - body.positionPrev.y; + + // update velocity with Verlet integration + body.velocity.x = (velocityPrevX * frictionAir * correction) + (body.force.x / body.mass) * deltaTimeSquared; + body.velocity.y = (velocityPrevY * frictionAir * correction) + (body.force.y / body.mass) * deltaTimeSquared; + + body.positionPrev.x = body.position.x; + body.positionPrev.y = body.position.y; + body.position.x += body.velocity.x; + body.position.y += body.velocity.y; + + // update angular velocity with Verlet integration + body.angularVelocity = ((body.angle - body.anglePrev) * frictionAir * correction) + (body.torque / body.inertia) * deltaTimeSquared; + body.anglePrev = body.angle; + body.angle += body.angularVelocity; + + // track speed and acceleration + body.speed = Vector.magnitude(body.velocity); + body.angularSpeed = Math.abs(body.angularVelocity); + + // transform the body geometry + for (var i = 0; i < body.parts.length; i++) { + var part = body.parts[i]; + + Vertices.translate(part.vertices, body.velocity); + + if (i > 0) { + part.position.x += body.velocity.x; + part.position.y += body.velocity.y; + } + + if (body.angularVelocity !== 0) { + Vertices.rotate(part.vertices, body.angularVelocity, body.position); + Axes.rotate(part.axes, body.angularVelocity); + if (i > 0) { + Vector.rotateAbout(part.position, body.angularVelocity, body.position, part.position); + } + } + + Bounds.update(part.bounds, part.vertices, body.velocity); + } + }; + + /** + * Applies a force to a body from a given world-space position, including resulting torque. + * @method applyForce + * @param {body} body + * @param {vector} position + * @param {vector} force + */ + Body.applyForce = function(body, position, force) { + body.force.x += force.x; + body.force.y += force.y; + var offset = { x: position.x - body.position.x, y: position.y - body.position.y }; + body.torque += offset.x * force.y - offset.y * force.x; + }; + + /** + * Returns the sums of the properties of all compound parts of the parent body. + * @method _totalProperties + * @private + * @param {body} body + * @return {} + */ + Body._totalProperties = function(body) { + // from equations at: + // https://ecourses.ou.edu/cgi-bin/ebook.cgi?doc=&topic=st&chap_sec=07.2&page=theory + // http://output.to/sideway/default.asp?qno=121100087 + + var properties = { + mass: 0, + area: 0, + inertia: 0, + centre: { x: 0, y: 0 } + }; + + // sum the properties of all compound parts of the parent body + for (var i = body.parts.length === 1 ? 0 : 1; i < body.parts.length; i++) { + var part = body.parts[i], + mass = part.mass !== Infinity ? part.mass : 1; + + properties.mass += mass; + properties.area += part.area; + properties.inertia += part.inertia; + properties.centre = Vector.add(properties.centre, Vector.mult(part.position, mass)); + } + + properties.centre = Vector.div(properties.centre, properties.mass); + + return properties; + }; + + /* + * + * Events Documentation + * + */ + + /** + * Fired when a body starts sleeping (where `this` is the body). + * + * @event sleepStart + * @this {body} The body that has started sleeping + * @param {} event An event object + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a body ends sleeping (where `this` is the body). + * + * @event sleepEnd + * @this {body} The body that has ended sleeping + * @param {} event An event object + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` uniquely identifying number generated in `Body.create` by `Common.nextId`. + * + * @property id + * @type number + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "body" + * @readOnly + */ + + /** + * An arbitrary `String` name to help the user identify and manage bodies. + * + * @property label + * @type string + * @default "Body" + */ + + /** + * An array of bodies that make up this body. + * The first body in the array must always be a self reference to the current body instance. + * All bodies in the `parts` array together form a single rigid compound body. + * Parts are allowed to overlap, have gaps or holes or even form concave bodies. + * Parts themselves should never be added to a `World`, only the parent body should be. + * Use `Body.setParts` when setting parts to ensure correct updates of all properties. + * + * @property parts + * @type body[] + */ + + /** + * An object reserved for storing plugin-specific properties. + * + * @property plugin + * @type {} + */ + + /** + * A self reference if the body is _not_ a part of another body. + * Otherwise this is a reference to the body that this is a part of. + * See `body.parts`. + * + * @property parent + * @type body + */ + + /** + * A `Number` specifying the angle of the body, in radians. + * + * @property angle + * @type number + * @default 0 + */ + + /** + * An array of `Vector` objects that specify the convex hull of the rigid body. + * These should be provided about the origin `(0, 0)`. E.g. + * + * [{ x: 0, y: 0 }, { x: 25, y: 50 }, { x: 50, y: 0 }] + * + * When passed via `Body.create`, the vertices are translated relative to `body.position` (i.e. world-space, and constantly updated by `Body.update` during simulation). + * The `Vector` objects are also augmented with additional properties required for efficient collision detection. + * + * Other properties such as `inertia` and `bounds` are automatically calculated from the passed vertices (unless provided via `options`). + * Concave hulls are not currently supported. The module `Matter.Vertices` contains useful methods for working with vertices. + * + * @property vertices + * @type vector[] + */ + + /** + * A `Vector` that specifies the current world-space position of the body. + * + * @property position + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Vector` that specifies the force to apply in the current step. It is zeroed after every `Body.update`. See also `Body.applyForce`. + * + * @property force + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Number` that specifies the torque (turning force) to apply in the current step. It is zeroed after every `Body.update`. + * + * @property torque + * @type number + * @default 0 + */ + + /** + * A `Number` that _measures_ the current speed of the body after the last `Body.update`. It is read-only and always positive (it's the magnitude of `body.velocity`). + * + * @readOnly + * @property speed + * @type number + * @default 0 + */ + + /** + * A `Number` that _measures_ the current angular speed of the body after the last `Body.update`. It is read-only and always positive (it's the magnitude of `body.angularVelocity`). + * + * @readOnly + * @property angularSpeed + * @type number + * @default 0 + */ + + /** + * A `Vector` that _measures_ the current velocity of the body after the last `Body.update`. It is read-only. + * If you need to modify a body's velocity directly, you should either apply a force or simply change the body's `position` (as the engine uses position-Verlet integration). + * + * @readOnly + * @property velocity + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Number` that _measures_ the current angular velocity of the body after the last `Body.update`. It is read-only. + * If you need to modify a body's angular velocity directly, you should apply a torque or simply change the body's `angle` (as the engine uses position-Verlet integration). + * + * @readOnly + * @property angularVelocity + * @type number + * @default 0 + */ + + /** + * A flag that indicates whether a body is considered static. A static body can never change position or angle and is completely fixed. + * If you need to set a body as static after its creation, you should use `Body.setStatic` as this requires more than just setting this flag. + * + * @property isStatic + * @type boolean + * @default false + */ + + /** + * A flag that indicates whether a body is a sensor. Sensor triggers collision events, but doesn't react with colliding body physically. + * + * @property isSensor + * @type boolean + * @default false + */ + + /** + * A flag that indicates whether the body is considered sleeping. A sleeping body acts similar to a static body, except it is only temporary and can be awoken. + * If you need to set a body as sleeping, you should use `Sleeping.set` as this requires more than just setting this flag. + * + * @property isSleeping + * @type boolean + * @default false + */ + + /** + * A `Number` that _measures_ the amount of movement a body currently has (a combination of `speed` and `angularSpeed`). It is read-only and always positive. + * It is used and updated by the `Matter.Sleeping` module during simulation to decide if a body has come to rest. + * + * @readOnly + * @property motion + * @type number + * @default 0 + */ + + /** + * A `Number` that defines the number of updates in which this body must have near-zero velocity before it is set as sleeping by the `Matter.Sleeping` module (if sleeping is enabled by the engine). + * + * @property sleepThreshold + * @type number + * @default 60 + */ + + /** + * A `Number` that defines the density of the body, that is its mass per unit area. + * If you pass the density via `Body.create` the `mass` property is automatically calculated for you based on the size (area) of the object. + * This is generally preferable to simply setting mass and allows for more intuitive definition of materials (e.g. rock has a higher density than wood). + * + * @property density + * @type number + * @default 0.001 + */ + + /** + * A `Number` that defines the mass of the body, although it may be more appropriate to specify the `density` property instead. + * If you modify this value, you must also modify the `body.inverseMass` property (`1 / mass`). + * + * @property mass + * @type number + */ + + /** + * A `Number` that defines the inverse mass of the body (`1 / mass`). + * If you modify this value, you must also modify the `body.mass` property. + * + * @property inverseMass + * @type number + */ + + /** + * A `Number` that defines the moment of inertia (i.e. second moment of area) of the body. + * It is automatically calculated from the given convex hull (`vertices` array) and density in `Body.create`. + * If you modify this value, you must also modify the `body.inverseInertia` property (`1 / inertia`). + * + * @property inertia + * @type number + */ + + /** + * A `Number` that defines the inverse moment of inertia of the body (`1 / inertia`). + * If you modify this value, you must also modify the `body.inertia` property. + * + * @property inverseInertia + * @type number + */ + + /** + * A `Number` that defines the restitution (elasticity) of the body. The value is always positive and is in the range `(0, 1)`. + * A value of `0` means collisions may be perfectly inelastic and no bouncing may occur. + * A value of `0.8` means the body may bounce back with approximately 80% of its kinetic energy. + * Note that collision response is based on _pairs_ of bodies, and that `restitution` values are _combined_ with the following formula: + * + * Math.max(bodyA.restitution, bodyB.restitution) + * + * @property restitution + * @type number + * @default 0 + */ + + /** + * A `Number` that defines the friction of the body. The value is always positive and is in the range `(0, 1)`. + * A value of `0` means that the body may slide indefinitely. + * A value of `1` means the body may come to a stop almost instantly after a force is applied. + * + * The effects of the value may be non-linear. + * High values may be unstable depending on the body. + * The engine uses a Coulomb friction model including static and kinetic friction. + * Note that collision response is based on _pairs_ of bodies, and that `friction` values are _combined_ with the following formula: + * + * Math.min(bodyA.friction, bodyB.friction) + * + * @property friction + * @type number + * @default 0.1 + */ + + /** + * A `Number` that defines the static friction of the body (in the Coulomb friction model). + * A value of `0` means the body will never 'stick' when it is nearly stationary and only dynamic `friction` is used. + * The higher the value (e.g. `10`), the more force it will take to initially get the body moving when nearly stationary. + * This value is multiplied with the `friction` property to make it easier to change `friction` and maintain an appropriate amount of static friction. + * + * @property frictionStatic + * @type number + * @default 0.5 + */ + + /** + * A `Number` that defines the air friction of the body (air resistance). + * A value of `0` means the body will never slow as it moves through space. + * The higher the value, the faster a body slows when moving through space. + * The effects of the value are non-linear. + * + * @property frictionAir + * @type number + * @default 0.01 + */ + + /** + * An `Object` that specifies the collision filtering properties of this body. + * + * Collisions between two bodies will obey the following rules: + * - If the two bodies have the same non-zero value of `collisionFilter.group`, + * they will always collide if the value is positive, and they will never collide + * if the value is negative. + * - If the two bodies have different values of `collisionFilter.group` or if one + * (or both) of the bodies has a value of 0, then the category/mask rules apply as follows: + * + * Each body belongs to a collision category, given by `collisionFilter.category`. This + * value is used as a bit field and the category should have only one bit set, meaning that + * the value of this property is a power of two in the range [1, 2^31]. Thus, there are 32 + * different collision categories available. + * + * Each body also defines a collision bitmask, given by `collisionFilter.mask` which specifies + * the categories it collides with (the value is the bitwise AND value of all these categories). + * + * Using the category/mask rules, two bodies `A` and `B` collide if each includes the other's + * category in its mask, i.e. `(categoryA & maskB) !== 0` and `(categoryB & maskA) !== 0` + * are both true. + * + * @property collisionFilter + * @type object + */ + + /** + * An Integer `Number`, that specifies the collision group this body belongs to. + * See `body.collisionFilter` for more information. + * + * @property collisionFilter.group + * @type object + * @default 0 + */ + + /** + * A bit field that specifies the collision category this body belongs to. + * The category value should have only one bit set, for example `0x0001`. + * This means there are up to 32 unique collision categories available. + * See `body.collisionFilter` for more information. + * + * @property collisionFilter.category + * @type object + * @default 1 + */ + + /** + * A bit mask that specifies the collision categories this body may collide with. + * See `body.collisionFilter` for more information. + * + * @property collisionFilter.mask + * @type object + * @default -1 + */ + + /** + * A `Number` that specifies a tolerance on how far a body is allowed to 'sink' or rotate into other bodies. + * Avoid changing this value unless you understand the purpose of `slop` in physics engines. + * The default should generally suffice, although very large bodies may require larger values for stable stacking. + * + * @property slop + * @type number + * @default 0.05 + */ + + /** + * A `Number` that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed. + * + * @property timeScale + * @type number + * @default 1 + */ + + /** + * An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`. + * + * @property render + * @type object + */ + + /** + * A flag that indicates if the body should be rendered. + * + * @property render.visible + * @type boolean + * @default true + */ + + /** + * Sets the opacity to use when rendering. + * + * @property render.opacity + * @type number + * @default 1 + */ + + /** + * An `Object` that defines the sprite properties to use when rendering, if any. + * + * @property render.sprite + * @type object + */ + + /** + * An `String` that defines the path to the image to use as the sprite texture, if any. + * + * @property render.sprite.texture + * @type string + */ + + /** + * A `Number` that defines the scaling in the x-axis for the sprite, if any. + * + * @property render.sprite.xScale + * @type number + * @default 1 + */ + + /** + * A `Number` that defines the scaling in the y-axis for the sprite, if any. + * + * @property render.sprite.yScale + * @type number + * @default 1 + */ + + /** + * A `Number` that defines the offset in the x-axis for the sprite (normalised by texture width). + * + * @property render.sprite.xOffset + * @type number + * @default 0 + */ + + /** + * A `Number` that defines the offset in the y-axis for the sprite (normalised by texture height). + * + * @property render.sprite.yOffset + * @type number + * @default 0 + */ + + /** + * A `Number` that defines the line width to use when rendering the body outline (if a sprite is not defined). + * A value of `0` means no outline will be rendered. + * + * @property render.lineWidth + * @type number + * @default 0 + */ + + /** + * A `String` that defines the fill style to use when rendering the body (if a sprite is not defined). + * It is the same as when using a canvas, so it accepts CSS style property values. + * + * @property render.fillStyle + * @type string + * @default a random colour + */ + + /** + * A `String` that defines the stroke style to use when rendering the body outline (if a sprite is not defined). + * It is the same as when using a canvas, so it accepts CSS style property values. + * + * @property render.strokeStyle + * @type string + * @default a random colour + */ + + /** + * An array of unique axis vectors (edge normals) used for collision detection. + * These are automatically calculated from the given convex hull (`vertices` array) in `Body.create`. + * They are constantly updated by `Body.update` during the simulation. + * + * @property axes + * @type vector[] + */ + + /** + * A `Number` that _measures_ the area of the body's convex hull, calculated at creation by `Body.create`. + * + * @property area + * @type string + * @default + */ + + /** + * A `Bounds` object that defines the AABB region for the body. + * It is automatically calculated from the given convex hull (`vertices` array) in `Body.create` and constantly updated by `Body.update` during simulation. + * + * @property bounds + * @type bounds + */ + +})(); + + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(28); +var Smoothing = __webpack_require__(130); + +// The pool into which the canvas elements are placed. +var pool = []; + +// Automatically apply smoothing(false) to created Canvas elements +var _disableContextSmoothing = false; + +/** + * The CanvasPool is a global static object, that allows Phaser to recycle and pool 2D Context Canvas DOM elements. + * It does not pool WebGL Contexts, because once the context options are set they cannot be modified again, + * which is useless for some of the Phaser pipelines / renderer. + * + * This singleton is instantiated as soon as Phaser loads, before a Phaser.Game instance has even been created. + * Which means all instances of Phaser Games on the same page can share the one single pool. + * + * @namespace Phaser.Display.Canvas.CanvasPool + * @since 3.0.0 + */ +var CanvasPool = function () +{ + /** + * Creates a new Canvas DOM element, or pulls one from the pool if free. + * + * @function Phaser.Display.Canvas.CanvasPool.create + * @since 3.0.0 + * + * @param {*} parent - The parent of the Canvas object. + * @param {integer} [width=1] - The width of the Canvas. + * @param {integer} [height=1] - The height of the Canvas. + * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. + * @param {boolean} [selfParent=false] - Use the generated Canvas element as the parent? + * + * @return {HTMLCanvasElement} [description] + */ + var create = function (parent, width, height, canvasType, selfParent) + { + if (width === undefined) { width = 1; } + if (height === undefined) { height = 1; } + if (canvasType === undefined) { canvasType = CONST.CANVAS; } + if (selfParent === undefined) { selfParent = false; } + + var canvas; + var container = first(canvasType); + + if (container === null) + { + container = { + parent: parent, + canvas: document.createElement('canvas'), + type: canvasType + }; + + if (canvasType === CONST.CANVAS) + { + pool.push(container); + } + + canvas = container.canvas; + } + else + { + container.parent = parent; + + canvas = container.canvas; + } + + if (selfParent) + { + container.parent = canvas; + } + + canvas.width = width; + canvas.height = height; + + if (_disableContextSmoothing && canvasType === CONST.CANVAS) + { + Smoothing.disable(canvas.getContext('2d')); + } + + return canvas; + }; + + /** + * Creates a new Canvas DOM element, or pulls one from the pool if free. + * + * @function Phaser.Display.Canvas.CanvasPool.create2D + * @since 3.0.0 + * + * @param {*} parent - The parent of the Canvas object. + * @param {integer} [width=1] - The width of the Canvas. + * @param {integer} [height=1] - The height of the Canvas. + * + * @return {HTMLCanvasElement} [description] + */ + var create2D = function (parent, width, height) + { + return create(parent, width, height, CONST.CANVAS); + }; + + /** + * Creates a new Canvas DOM element, or pulls one from the pool if free. + * + * @function Phaser.Display.Canvas.CanvasPool.createWebGL + * @since 3.0.0 + * + * @param {*} parent - The parent of the Canvas object. + * @param {integer} [width=1] - The width of the Canvas. + * @param {integer} [height=1] - The height of the Canvas. + * + * @return {HTMLCanvasElement} [description] + */ + var createWebGL = function (parent, width, height) + { + return create(parent, width, height, CONST.WEBGL); + }; + + /** + * Gets the first free canvas index from the pool. + * + * @function Phaser.Display.Canvas.CanvasPool.first + * @since 3.0.0 + * + * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. + * + * @return {HTMLCanvasElement} [description] + */ + var first = function (canvasType) + { + if (canvasType === undefined) { canvasType = CONST.CANVAS; } + + if (canvasType === CONST.WEBGL) + { + return null; + } + + for (var i = 0; i < pool.length; i++) + { + var container = pool[i]; + + if (!container.parent && container.type === canvasType) + { + return container; + } + } + + return null; + }; + + /** + * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. + * The canvas has its width and height set to 1, and its parent attribute nulled. + * + * @function Phaser.Display.Canvas.CanvasPool.remove + * @since 3.0.0 + * + * @param {*} parent - [description] + */ + var remove = function (parent) + { + // Check to see if the parent is a canvas object + var isCanvas = parent instanceof HTMLCanvasElement; + + pool.forEach(function (container) + { + if ((isCanvas && container.canvas === parent) || (!isCanvas && container.parent === parent)) + { + container.parent = null; + container.canvas.width = 1; + container.canvas.height = 1; + } + }); + }; + + /** + * Gets the total number of used canvas elements in the pool. + * + * @function Phaser.Display.Canvas.CanvasPool.total + * @since 3.0.0 + * + * @return {integer} [description] + */ + var total = function () + { + var c = 0; + + pool.forEach(function (container) + { + if (container.parent) + { + c++; + } + }); + + return c; + }; + + /** + * Gets the total number of free canvas elements in the pool. + * + * @function Phaser.Display.Canvas.CanvasPool.free + * @since 3.0.0 + * + * @return {integer} [description] + */ + var free = function () + { + return pool.length - total(); + }; + + /** + * Disable context smoothing on any new Canvas element created. + * + * @function Phaser.Display.Canvas.CanvasPool.disableSmoothing + * @since 3.0.0 + */ + var disableSmoothing = function () + { + _disableContextSmoothing = true; + }; + + /** + * Enable context smoothing on any new Canvas element created. + * + * @function Phaser.Display.Canvas.CanvasPool.enableSmoothing + * @since 3.0.0 + */ + var enableSmoothing = function () + { + _disableContextSmoothing = false; + }; + + return { + create2D: create2D, + create: create, + createWebGL: createWebGL, + disableSmoothing: disableSmoothing, + enableSmoothing: enableSmoothing, + first: first, + free: free, + pool: pool, + remove: remove, + total: total + }; +}; + +// If we export the called function here, it'll only be invoked once (not every time it's required). +module.exports = CanvasPool(); + + +/***/ }), +/* 27 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` + * + * @function Phaser.Actions.PropertyValueSet + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var PropertyValueSet = function (items, key, value, step, index, direction) +{ + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] = value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] = value + (t * step); + t++; + } + } + + return items; +}; + +module.exports = PropertyValueSet; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Global consts. + * + * @ignore + */ + +var CONST = { + + /** + * Phaser Release Version + * + * @name Phaser.VERSION + * @readonly + * @type {string} + * @since 3.0.0 + */ + VERSION: '3.15.1', + + BlendModes: __webpack_require__(72), + + ScaleModes: __webpack_require__(104), + + /** + * AUTO Detect Renderer. + * + * @name Phaser.AUTO + * @readonly + * @type {integer} + * @since 3.0.0 + */ + AUTO: 0, + + /** + * Canvas Renderer. + * + * @name Phaser.CANVAS + * @readonly + * @type {integer} + * @since 3.0.0 + */ + CANVAS: 1, + + /** + * WebGL Renderer. + * + * @name Phaser.WEBGL + * @readonly + * @type {integer} + * @since 3.0.0 + */ + WEBGL: 2, + + /** + * Headless Renderer. + * + * @name Phaser.HEADLESS + * @readonly + * @type {integer} + * @since 3.0.0 + */ + HEADLESS: 3, + + /** + * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead + * to help you remember what the value is doing in your code. + * + * @name Phaser.FOREVER + * @readonly + * @type {integer} + * @since 3.0.0 + */ + FOREVER: -1, + + /** + * Direction constant. + * + * @name Phaser.NONE + * @readonly + * @type {integer} + * @since 3.0.0 + */ + NONE: 4, + + /** + * Direction constant. + * + * @name Phaser.UP + * @readonly + * @type {integer} + * @since 3.0.0 + */ + UP: 5, + + /** + * Direction constant. + * + * @name Phaser.DOWN + * @readonly + * @type {integer} + * @since 3.0.0 + */ + DOWN: 6, + + /** + * Direction constant. + * + * @name Phaser.LEFT + * @readonly + * @type {integer} + * @since 3.0.0 + */ + LEFT: 7, + + /** + * Direction constant. + * + * @name Phaser.RIGHT + * @readonly + * @type {integer} + * @since 3.0.0 + */ + RIGHT: 8 + +}; + +module.exports = CONST; + + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. +* A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. +* A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Vertices +*/ + +var Vertices = {}; + +module.exports = Vertices; + +var Vector = __webpack_require__(34); +var Common = __webpack_require__(12); + +(function() { + + /** + * Creates a new set of `Matter.Body` compatible vertices. + * The `points` argument accepts an array of `Matter.Vector` points orientated around the origin `(0, 0)`, for example: + * + * [{ x: 0, y: 0 }, { x: 25, y: 50 }, { x: 50, y: 0 }] + * + * The `Vertices.create` method returns a new array of vertices, which are similar to Matter.Vector objects, + * but with some additional references required for efficient collision detection routines. + * + * Vertices must be specified in clockwise order. + * + * Note that the `body` argument is not optional, a `Matter.Body` reference must be provided. + * + * @method create + * @param {vector[]} points + * @param {body} body + */ + Vertices.create = function(points, body) { + var vertices = []; + + for (var i = 0; i < points.length; i++) { + var point = points[i], + vertex = { + x: point.x, + y: point.y, + index: i, + body: body, + isInternal: false, + contact: null + }; + + vertex.contact = { + vertex: vertex, + normalImpulse: 0, + tangentImpulse: 0 + }; + + vertices.push(vertex); + } + + return vertices; + }; + + /** + * Parses a string containing ordered x y pairs separated by spaces (and optionally commas), + * into a `Matter.Vertices` object for the given `Matter.Body`. + * For parsing SVG paths, see `Svg.pathToVertices`. + * @method fromPath + * @param {string} path + * @param {body} body + * @return {vertices} vertices + */ + Vertices.fromPath = function(path, body) { + var pathPattern = /L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/ig, + points = []; + + path.replace(pathPattern, function(match, x, y) { + points.push({ x: parseFloat(x), y: parseFloat(y) }); + }); + + return Vertices.create(points, body); + }; + + /** + * Returns the centre (centroid) of the set of vertices. + * @method centre + * @param {vertices} vertices + * @return {vector} The centre point + */ + Vertices.centre = function(vertices) { + var area = Vertices.area(vertices, true), + centre = { x: 0, y: 0 }, + cross, + temp, + j; + + for (var i = 0; i < vertices.length; i++) { + j = (i + 1) % vertices.length; + cross = Vector.cross(vertices[i], vertices[j]); + temp = Vector.mult(Vector.add(vertices[i], vertices[j]), cross); + centre = Vector.add(centre, temp); + } + + return Vector.div(centre, 6 * area); + }; + + /** + * Returns the average (mean) of the set of vertices. + * @method mean + * @param {vertices} vertices + * @return {vector} The average point + */ + Vertices.mean = function(vertices) { + var average = { x: 0, y: 0 }; + + for (var i = 0; i < vertices.length; i++) { + average.x += vertices[i].x; + average.y += vertices[i].y; + } + + return Vector.div(average, vertices.length); + }; + + /** + * Returns the area of the set of vertices. + * @method area + * @param {vertices} vertices + * @param {bool} signed + * @return {number} The area + */ + Vertices.area = function(vertices, signed) { + var area = 0, + j = vertices.length - 1; + + for (var i = 0; i < vertices.length; i++) { + area += (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); + j = i; + } + + if (signed) + return area / 2; + + return Math.abs(area) / 2; + }; + + /** + * Returns the moment of inertia (second moment of area) of the set of vertices given the total mass. + * @method inertia + * @param {vertices} vertices + * @param {number} mass + * @return {number} The polygon's moment of inertia + */ + Vertices.inertia = function(vertices, mass) { + var numerator = 0, + denominator = 0, + v = vertices, + cross, + j; + + // find the polygon's moment of inertia, using second moment of area + // from equations at http://www.physicsforums.com/showthread.php?t=25293 + for (var n = 0; n < v.length; n++) { + j = (n + 1) % v.length; + cross = Math.abs(Vector.cross(v[j], v[n])); + numerator += cross * (Vector.dot(v[j], v[j]) + Vector.dot(v[j], v[n]) + Vector.dot(v[n], v[n])); + denominator += cross; + } + + return (mass / 6) * (numerator / denominator); + }; + + /** + * Translates the set of vertices in-place. + * @method translate + * @param {vertices} vertices + * @param {vector} vector + * @param {number} scalar + */ + Vertices.translate = function(vertices, vector, scalar) { + var i; + if (scalar) { + for (i = 0; i < vertices.length; i++) { + vertices[i].x += vector.x * scalar; + vertices[i].y += vector.y * scalar; + } + } else { + for (i = 0; i < vertices.length; i++) { + vertices[i].x += vector.x; + vertices[i].y += vector.y; + } + } + + return vertices; + }; + + /** + * Rotates the set of vertices in-place. + * @method rotate + * @param {vertices} vertices + * @param {number} angle + * @param {vector} point + */ + Vertices.rotate = function(vertices, angle, point) { + if (angle === 0) + return; + + var cos = Math.cos(angle), + sin = Math.sin(angle); + + for (var i = 0; i < vertices.length; i++) { + var vertice = vertices[i], + dx = vertice.x - point.x, + dy = vertice.y - point.y; + + vertice.x = point.x + (dx * cos - dy * sin); + vertice.y = point.y + (dx * sin + dy * cos); + } + + return vertices; + }; + + /** + * Returns `true` if the `point` is inside the set of `vertices`. + * @method contains + * @param {vertices} vertices + * @param {vector} point + * @return {boolean} True if the vertices contains point, otherwise false + */ + Vertices.contains = function(vertices, point) { + for (var i = 0; i < vertices.length; i++) { + var vertice = vertices[i], + nextVertice = vertices[(i + 1) % vertices.length]; + if ((point.x - vertice.x) * (nextVertice.y - vertice.y) + (point.y - vertice.y) * (vertice.x - nextVertice.x) > 0) { + return false; + } + } + + return true; + }; + + /** + * Scales the vertices from a point (default is centre) in-place. + * @method scale + * @param {vertices} vertices + * @param {number} scaleX + * @param {number} scaleY + * @param {vector} point + */ + Vertices.scale = function(vertices, scaleX, scaleY, point) { + if (scaleX === 1 && scaleY === 1) + return vertices; + + point = point || Vertices.centre(vertices); + + var vertex, + delta; + + for (var i = 0; i < vertices.length; i++) { + vertex = vertices[i]; + delta = Vector.sub(vertex, point); + vertices[i].x = point.x + delta.x * scaleX; + vertices[i].y = point.y + delta.y * scaleY; + } + + return vertices; + }; + + /** + * Chamfers a set of vertices by giving them rounded corners, returns a new set of vertices. + * The radius parameter is a single number or an array to specify the radius for each vertex. + * @method chamfer + * @param {vertices} vertices + * @param {number[]} radius + * @param {number} quality + * @param {number} qualityMin + * @param {number} qualityMax + */ + Vertices.chamfer = function(vertices, radius, quality, qualityMin, qualityMax) { + if (typeof radius === 'number') { + radius = [radius]; + } else { + radius = radius || [8]; + } + + // quality defaults to -1, which is auto + quality = (typeof quality !== 'undefined') ? quality : -1; + qualityMin = qualityMin || 2; + qualityMax = qualityMax || 14; + + var newVertices = []; + + for (var i = 0; i < vertices.length; i++) { + var prevVertex = vertices[i - 1 >= 0 ? i - 1 : vertices.length - 1], + vertex = vertices[i], + nextVertex = vertices[(i + 1) % vertices.length], + currentRadius = radius[i < radius.length ? i : radius.length - 1]; + + if (currentRadius === 0) { + newVertices.push(vertex); + continue; + } + + var prevNormal = Vector.normalise({ + x: vertex.y - prevVertex.y, + y: prevVertex.x - vertex.x + }); + + var nextNormal = Vector.normalise({ + x: nextVertex.y - vertex.y, + y: vertex.x - nextVertex.x + }); + + var diagonalRadius = Math.sqrt(2 * Math.pow(currentRadius, 2)), + radiusVector = Vector.mult(Common.clone(prevNormal), currentRadius), + midNormal = Vector.normalise(Vector.mult(Vector.add(prevNormal, nextNormal), 0.5)), + scaledVertex = Vector.sub(vertex, Vector.mult(midNormal, diagonalRadius)); + + var precision = quality; + + if (quality === -1) { + // automatically decide precision + precision = Math.pow(currentRadius, 0.32) * 1.75; + } + + precision = Common.clamp(precision, qualityMin, qualityMax); + + // use an even value for precision, more likely to reduce axes by using symmetry + if (precision % 2 === 1) + precision += 1; + + var alpha = Math.acos(Vector.dot(prevNormal, nextNormal)), + theta = alpha / precision; + + for (var j = 0; j < precision; j++) { + newVertices.push(Vector.add(Vector.rotate(radiusVector, theta * j), scaledVertex)); + } + } + + return newVertices; + }; + + /** + * Sorts the input vertices into clockwise order in place. + * @method clockwiseSort + * @param {vertices} vertices + * @return {vertices} vertices + */ + Vertices.clockwiseSort = function(vertices) { + var centre = Vertices.mean(vertices); + + vertices.sort(function(vertexA, vertexB) { + return Vector.angle(centre, vertexA) - Vector.angle(centre, vertexB); + }); + + return vertices; + }; + + /** + * Returns true if the vertices form a convex shape (vertices must be in clockwise order). + * @method isConvex + * @param {vertices} vertices + * @return {bool} `true` if the `vertices` are convex, `false` if not (or `null` if not computable). + */ + Vertices.isConvex = function(vertices) { + // http://paulbourke.net/geometry/polygonmesh/ + // Copyright (c) Paul Bourke (use permitted) + + var flag = 0, + n = vertices.length, + i, + j, + k, + z; + + if (n < 3) + return null; + + for (i = 0; i < n; i++) { + j = (i + 1) % n; + k = (i + 2) % n; + z = (vertices[j].x - vertices[i].x) * (vertices[k].y - vertices[j].y); + z -= (vertices[j].y - vertices[i].y) * (vertices[k].x - vertices[j].x); + + if (z < 0) { + flag |= 1; + } else if (z > 0) { + flag |= 2; + } + + if (flag === 3) { + return false; + } + } + + if (flag !== 0){ + return true; + } else { + return null; + } + }; + + /** + * Returns the convex hull of the input vertices as a new array of points. + * @method hull + * @param {vertices} vertices + * @return [vertex] vertices + */ + Vertices.hull = function(vertices) { + // http://geomalgorithms.com/a10-_hull-1.html + + var upper = [], + lower = [], + vertex, + i; + + // sort vertices on x-axis (y-axis for ties) + vertices = vertices.slice(0); + vertices.sort(function(vertexA, vertexB) { + var dx = vertexA.x - vertexB.x; + return dx !== 0 ? dx : vertexA.y - vertexB.y; + }); + + // build lower hull + for (i = 0; i < vertices.length; i += 1) { + vertex = vertices[i]; + + while (lower.length >= 2 + && Vector.cross3(lower[lower.length - 2], lower[lower.length - 1], vertex) <= 0) { + lower.pop(); + } + + lower.push(vertex); + } + + // build upper hull + for (i = vertices.length - 1; i >= 0; i -= 1) { + vertex = vertices[i]; + + while (upper.length >= 2 + && Vector.cross3(upper[upper.length - 2], upper[upper.length - 1], vertex) <= 0) { + upper.pop(); + } + + upper.push(vertex); + } + + // concatenation of the lower and upper hulls gives the convex hull + // omit last points because they are repeated at the beginning of the other list + upper.pop(); + lower.pop(); + + return upper.concat(lower); + }; + +})(); + + +/***/ }), +/* 30 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Formats + */ + +module.exports = { + + /** + * CSV Map Type + * + * @name Phaser.Tilemaps.Formats.CSV + * @type {number} + * @since 3.0.0 + */ + CSV: 0, + + /** + * Tiled JSON Map Type + * + * @name Phaser.Tilemaps.Formats.TILED_JSON + * @type {number} + * @since 3.0.0 + */ + TILED_JSON: 1, + + /** + * 2D Array Map Type + * + * @name Phaser.Tilemaps.Formats.ARRAY_2D + * @type {number} + * @since 3.0.0 + */ + ARRAY_2D: 2, + + /** + * Weltmeister (Impact.js) Map Type + * + * @name Phaser.Tilemaps.Formats.WELTMEISTER + * @type {number} + * @since 3.0.0 + */ + WELTMEISTER: 3 + +}; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var GameObject = __webpack_require__(17); +var Line = __webpack_require__(60); + +/** + * @classdesc + * The Shape Game Object is a base class for the various different shapes, such as the Arc, Star or Polygon. + * You cannot add a Shape directly to your Scene, it is meant as a base for your own custom Shape classes. + * + * @class Shape + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {string} [type] - The internal type of the Shape. + * @param {any} [data] - The data of the source shape geometry, if any. + */ +var Shape = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Transform, + Components.Visible + ], + + initialize: + + function Shape (scene, type, data) + { + if (type === undefined) { type = 'Shape'; } + + GameObject.call(this, scene, type); + + /** + * The source Shape data. Typically a geometry object. + * You should not manipulate this directly. + * + * @name Phaser.GameObjects.Shape#data + * @type {any} + * @readonly + * @since 3.13.0 + */ + this.geom = data; + + /** + * Holds the polygon path data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathData + * @type {number[]} + * @readonly + * @since 3.13.0 + */ + this.pathData = []; + + /** + * Holds the earcut polygon path index data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathIndexes + * @type {integer[]} + * @readonly + * @since 3.13.0 + */ + this.pathIndexes = []; + + /** + * The fill color used by this Shape. + * + * @name Phaser.GameObjects.Shape#fillColor + * @type {number} + * @since 3.13.0 + */ + this.fillColor = 0xffffff; + + /** + * The fill alpha value used by this Shape. + * + * @name Phaser.GameObjects.Shape#fillAlpha + * @type {number} + * @since 3.13.0 + */ + this.fillAlpha = 1; + + /** + * The stroke color used by this Shape. + * + * @name Phaser.GameObjects.Shape#strokeColor + * @type {number} + * @since 3.13.0 + */ + this.strokeColor = 0xffffff; + + /** + * The stroke alpha value used by this Shape. + * + * @name Phaser.GameObjects.Shape#strokeAlpha + * @type {number} + * @since 3.13.0 + */ + this.strokeAlpha = 1; + + /** + * The stroke line width used by this Shape. + * + * @name Phaser.GameObjects.Shape#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Controls if this Shape is filled or not. + * Note that some Shapes do not support being filled (such as Line shapes) + * + * @name Phaser.GameObjects.Shape#isFilled + * @type {boolean} + * @since 3.13.0 + */ + this.isFilled = false; + + /** + * Controls if this Shape is stroked or not. + * Note that some Shapes do not support being stroked (such as Iso Box shapes) + * + * @name Phaser.GameObjects.Shape#isStroked + * @type {boolean} + * @since 3.13.0 + */ + this.isStroked = false; + + /** + * Controls if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * @name Phaser.GameObjects.Shape#closePath + * @type {boolean} + * @since 3.13.0 + */ + this.closePath = true; + + /** + * Private internal value. + * A Line used when parsing internal path data to avoid constant object re-creation. + * + * @name Phaser.GameObjects.Curve#_tempLine + * @type {Phaser.Geom.Line} + * @private + * @since 3.13.0 + */ + this._tempLine = new Line(); + + this.initPipeline(); + }, + + /** + * Sets the fill color and alpha for this Shape. + * + * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. + * + * Note that some Shapes do not support fill colors, such as the Line shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setFillStyle + * @since 3.13.0 + * + * @param {number} [color] - The color used to fill this shape. If not provided the Shape will not be filled. + * @param {number} [alpha=1] - The alpha value used when filling this shape, if a fill color is given. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (color === undefined) + { + this.isFilled = false; + } + else + { + this.fillColor = color; + this.fillAlpha = alpha; + this.isFilled = true; + } + + return this; + }, + + /** + * Sets the stroke color and alpha for this Shape. + * + * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. + * + * Note that some Shapes do not support being stroked, such as the Iso Box shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setStrokeStyle + * @since 3.13.0 + * + * @param {number} [color] - The color used to stroke this shape. If not provided the Shape will not be stroked. + * @param {number} [alpha=1] - The alpha value used when stroking this shape, if a stroke color is given. + * + * @return {this} This Game Object instance. + */ + setStrokeStyle: function (lineWidth, color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (lineWidth === undefined) + { + this.isStroked = false; + } + else + { + this.lineWidth = lineWidth; + this.strokeColor = color; + this.strokeAlpha = alpha; + this.isStroked = true; + } + + return this; + }, + + /** + * Sets if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setClosePath + * @since 3.13.0 + * + * @param {boolean} value - Set to `true` if the Shape should be closed when stroked, otherwise `false`. + * + * @return {this} This Game Object instance. + */ + setClosePath: function (value) + { + this.closePath = value; + + return this; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Shape#preDestroy + * @protected + * @since 3.13.0 + */ + preDestroy: function () + { + this.geom = null; + this._tempLine = null; + this.pathData = []; + this.pathIndexes = []; + } + +}); + +module.exports = Shape; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(72); +var GetAdvancedValue = __webpack_require__(13); +var ScaleModes = __webpack_require__(104); + +/** + * @typedef {object} GameObjectConfig + * + * @property {number} [x=0] - The x position of the Game Object. + * @property {number} [y=0] - The y position of the Game Object. + * @property {number} [depth=0] - The depth of the GameObject. + * @property {boolean} [flipX=false] - The horizontally flipped state of the Game Object. + * @property {boolean} [flipY=false] - The vertically flipped state of the Game Object. + * @property {?(number|object)} [scale=null] - The scale of the GameObject. + * @property {?(number|object)} [scrollFactor=null] - The scroll factor of the GameObject. + * @property {number} [rotation=0] - The rotation angle of the Game Object, in radians. + * @property {?number} [angle=null] - The rotation angle of the Game Object, in degrees. + * @property {number} [alpha=1] - The alpha (opacity) of the Game Object. + * @property {?(number|object)} [origin=null] - The origin of the Game Object. + * @property {number} [scaleMode=ScaleModes.DEFAULT] - The scale mode of the GameObject. + * @property {number} [blendMode=BlendModes.DEFAULT] - The blend mode of the GameObject. + * @property {boolean} [visible=true] - The visible state of the Game Object. + * @property {boolean} [add=true] - Add the GameObject to the scene. + */ + +/** + * Builds a Game Object using the provided configuration object. + * + * @function Phaser.GameObjects.BuildGameObject + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene. + * @param {Phaser.GameObjects.GameObject} gameObject - The initial GameObject. + * @param {GameObjectConfig} config - The config to build the GameObject with. + * + * @return {Phaser.GameObjects.GameObject} The built Game Object. + */ +var BuildGameObject = function (scene, gameObject, config) +{ + // Position + + gameObject.x = GetAdvancedValue(config, 'x', 0); + gameObject.y = GetAdvancedValue(config, 'y', 0); + gameObject.depth = GetAdvancedValue(config, 'depth', 0); + + // Flip + + gameObject.flipX = GetAdvancedValue(config, 'flipX', false); + gameObject.flipY = GetAdvancedValue(config, 'flipY', false); + + // Scale + // Either: { scale: 2 } or { scale: { x: 2, y: 2 }} + + var scale = GetAdvancedValue(config, 'scale', null); + + if (typeof scale === 'number') + { + gameObject.setScale(scale); + } + else if (scale !== null) + { + gameObject.scaleX = GetAdvancedValue(scale, 'x', 1); + gameObject.scaleY = GetAdvancedValue(scale, 'y', 1); + } + + // ScrollFactor + // Either: { scrollFactor: 2 } or { scrollFactor: { x: 2, y: 2 }} + + var scrollFactor = GetAdvancedValue(config, 'scrollFactor', null); + + if (typeof scrollFactor === 'number') + { + gameObject.setScrollFactor(scrollFactor); + } + else if (scrollFactor !== null) + { + gameObject.scrollFactorX = GetAdvancedValue(scrollFactor, 'x', 1); + gameObject.scrollFactorY = GetAdvancedValue(scrollFactor, 'y', 1); + } + + // Rotation + + gameObject.rotation = GetAdvancedValue(config, 'rotation', 0); + + var angle = GetAdvancedValue(config, 'angle', null); + + if (angle !== null) + { + gameObject.angle = angle; + } + + // Alpha + + gameObject.alpha = GetAdvancedValue(config, 'alpha', 1); + + // Origin + // Either: { origin: 0.5 } or { origin: { x: 0.5, y: 0.5 }} + + var origin = GetAdvancedValue(config, 'origin', null); + + if (typeof origin === 'number') + { + gameObject.setOrigin(origin); + } + else if (origin !== null) + { + var ox = GetAdvancedValue(origin, 'x', 0.5); + var oy = GetAdvancedValue(origin, 'y', 0.5); + + gameObject.setOrigin(ox, oy); + } + + // ScaleMode + + gameObject.scaleMode = GetAdvancedValue(config, 'scaleMode', ScaleModes.DEFAULT); + + // BlendMode + + gameObject.blendMode = GetAdvancedValue(config, 'blendMode', BlendModes.NORMAL); + + // Visible + + gameObject.visible = GetAdvancedValue(config, 'visible', true); + + // Add to Scene + + var add = GetAdvancedValue(config, 'add', true); + + if (add) + { + scene.sys.displayList.add(gameObject); + } + + if (gameObject.preUpdate) + { + scene.sys.updateList.add(gameObject); + } + + return gameObject; +}; + +module.exports = BuildGameObject; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { + +/** +* The `Matter.Bounds` module contains methods for creating and manipulating axis-aligned bounding boxes (AABB). +* +* @class Bounds +*/ + +var Bounds = {}; + +module.exports = Bounds; + +(function() { + + /** + * Creates a new axis-aligned bounding box (AABB) for the given vertices. + * @method create + * @param {vertices} vertices + * @return {bounds} A new bounds object + */ + Bounds.create = function(vertices) { + var bounds = { + min: { x: 0, y: 0 }, + max: { x: 0, y: 0 } + }; + + if (vertices) + Bounds.update(bounds, vertices); + + return bounds; + }; + + /** + * Updates bounds using the given vertices and extends the bounds given a velocity. + * @method update + * @param {bounds} bounds + * @param {vertices} vertices + * @param {vector} velocity + */ + Bounds.update = function(bounds, vertices, velocity) { + bounds.min.x = Infinity; + bounds.max.x = -Infinity; + bounds.min.y = Infinity; + bounds.max.y = -Infinity; + + for (var i = 0; i < vertices.length; i++) { + var vertex = vertices[i]; + if (vertex.x > bounds.max.x) bounds.max.x = vertex.x; + if (vertex.x < bounds.min.x) bounds.min.x = vertex.x; + if (vertex.y > bounds.max.y) bounds.max.y = vertex.y; + if (vertex.y < bounds.min.y) bounds.min.y = vertex.y; + } + + if (velocity) { + if (velocity.x > 0) { + bounds.max.x += velocity.x; + } else { + bounds.min.x += velocity.x; + } + + if (velocity.y > 0) { + bounds.max.y += velocity.y; + } else { + bounds.min.y += velocity.y; + } + } + }; + + /** + * Returns true if the bounds contains the given point. + * @method contains + * @param {bounds} bounds + * @param {vector} point + * @return {boolean} True if the bounds contain the point, otherwise false + */ + Bounds.contains = function(bounds, point) { + return point.x >= bounds.min.x && point.x <= bounds.max.x + && point.y >= bounds.min.y && point.y <= bounds.max.y; + }; + + /** + * Returns true if the two bounds intersect. + * @method overlaps + * @param {bounds} boundsA + * @param {bounds} boundsB + * @return {boolean} True if the bounds overlap, otherwise false + */ + Bounds.overlaps = function(boundsA, boundsB) { + return (boundsA.min.x <= boundsB.max.x && boundsA.max.x >= boundsB.min.x + && boundsA.max.y >= boundsB.min.y && boundsA.min.y <= boundsB.max.y); + }; + + /** + * Translates the bounds by the given vector. + * @method translate + * @param {bounds} bounds + * @param {vector} vector + */ + Bounds.translate = function(bounds, vector) { + bounds.min.x += vector.x; + bounds.max.x += vector.x; + bounds.min.y += vector.y; + bounds.max.y += vector.y; + }; + + /** + * Shifts the bounds to the given position. + * @method shift + * @param {bounds} bounds + * @param {vector} position + */ + Bounds.shift = function(bounds, position) { + var deltaX = bounds.max.x - bounds.min.x, + deltaY = bounds.max.y - bounds.min.y; + + bounds.min.x = position.x; + bounds.max.x = position.x + deltaX; + bounds.min.y = position.y; + bounds.max.y = position.y + deltaY; + }; + +})(); + + +/***/ }), +/* 34 */ +/***/ (function(module, exports) { + +/** +* The `Matter.Vector` module contains methods for creating and manipulating vectors. +* Vectors are the basis of all the geometry related operations in the engine. +* A `Matter.Vector` object is of the form `{ x: 0, y: 0 }`. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Vector +*/ + +// TODO: consider params for reusing vector objects + +var Vector = {}; + +module.exports = Vector; + +(function() { + + /** + * Creates a new vector. + * @method create + * @param {number} x + * @param {number} y + * @return {vector} A new vector + */ + Vector.create = function(x, y) { + return { x: x || 0, y: y || 0 }; + }; + + /** + * Returns a new vector with `x` and `y` copied from the given `vector`. + * @method clone + * @param {vector} vector + * @return {vector} A new cloned vector + */ + Vector.clone = function(vector) { + return { x: vector.x, y: vector.y }; + }; + + /** + * Returns the magnitude (length) of a vector. + * @method magnitude + * @param {vector} vector + * @return {number} The magnitude of the vector + */ + Vector.magnitude = function(vector) { + return Math.sqrt((vector.x * vector.x) + (vector.y * vector.y)); + }; + + /** + * Returns the magnitude (length) of a vector (therefore saving a `sqrt` operation). + * @method magnitudeSquared + * @param {vector} vector + * @return {number} The squared magnitude of the vector + */ + Vector.magnitudeSquared = function(vector) { + return (vector.x * vector.x) + (vector.y * vector.y); + }; + + /** + * Rotates the vector about (0, 0) by specified angle. + * @method rotate + * @param {vector} vector + * @param {number} angle + * @param {vector} [output] + * @return {vector} The vector rotated about (0, 0) + */ + Vector.rotate = function(vector, angle, output) { + var cos = Math.cos(angle), sin = Math.sin(angle); + if (!output) output = {}; + var x = vector.x * cos - vector.y * sin; + output.y = vector.x * sin + vector.y * cos; + output.x = x; + return output; + }; + + /** + * Rotates the vector about a specified point by specified angle. + * @method rotateAbout + * @param {vector} vector + * @param {number} angle + * @param {vector} point + * @param {vector} [output] + * @return {vector} A new vector rotated about the point + */ + Vector.rotateAbout = function(vector, angle, point, output) { + var cos = Math.cos(angle), sin = Math.sin(angle); + if (!output) output = {}; + var x = point.x + ((vector.x - point.x) * cos - (vector.y - point.y) * sin); + output.y = point.y + ((vector.x - point.x) * sin + (vector.y - point.y) * cos); + output.x = x; + return output; + }; + + /** + * Normalises a vector (such that its magnitude is `1`). + * @method normalise + * @param {vector} vector + * @return {vector} A new vector normalised + */ + Vector.normalise = function(vector) { + var magnitude = Vector.magnitude(vector); + if (magnitude === 0) + return { x: 0, y: 0 }; + return { x: vector.x / magnitude, y: vector.y / magnitude }; + }; + + /** + * Returns the dot-product of two vectors. + * @method dot + * @param {vector} vectorA + * @param {vector} vectorB + * @return {number} The dot product of the two vectors + */ + Vector.dot = function(vectorA, vectorB) { + return (vectorA.x * vectorB.x) + (vectorA.y * vectorB.y); + }; + + /** + * Returns the cross-product of two vectors. + * @method cross + * @param {vector} vectorA + * @param {vector} vectorB + * @return {number} The cross product of the two vectors + */ + Vector.cross = function(vectorA, vectorB) { + return (vectorA.x * vectorB.y) - (vectorA.y * vectorB.x); + }; + + /** + * Returns the cross-product of three vectors. + * @method cross3 + * @param {vector} vectorA + * @param {vector} vectorB + * @param {vector} vectorC + * @return {number} The cross product of the three vectors + */ + Vector.cross3 = function(vectorA, vectorB, vectorC) { + return (vectorB.x - vectorA.x) * (vectorC.y - vectorA.y) - (vectorB.y - vectorA.y) * (vectorC.x - vectorA.x); + }; + + /** + * Adds the two vectors. + * @method add + * @param {vector} vectorA + * @param {vector} vectorB + * @param {vector} [output] + * @return {vector} A new vector of vectorA and vectorB added + */ + Vector.add = function(vectorA, vectorB, output) { + if (!output) output = {}; + output.x = vectorA.x + vectorB.x; + output.y = vectorA.y + vectorB.y; + return output; + }; + + /** + * Subtracts the two vectors. + * @method sub + * @param {vector} vectorA + * @param {vector} vectorB + * @param {vector} [output] + * @return {vector} A new vector of vectorA and vectorB subtracted + */ + Vector.sub = function(vectorA, vectorB, output) { + if (!output) output = {}; + output.x = vectorA.x - vectorB.x; + output.y = vectorA.y - vectorB.y; + return output; + }; + + /** + * Multiplies a vector and a scalar. + * @method mult + * @param {vector} vector + * @param {number} scalar + * @return {vector} A new vector multiplied by scalar + */ + Vector.mult = function(vector, scalar) { + return { x: vector.x * scalar, y: vector.y * scalar }; + }; + + /** + * Divides a vector and a scalar. + * @method div + * @param {vector} vector + * @param {number} scalar + * @return {vector} A new vector divided by scalar + */ + Vector.div = function(vector, scalar) { + return { x: vector.x / scalar, y: vector.y / scalar }; + }; + + /** + * Returns the perpendicular vector. Set `negate` to true for the perpendicular in the opposite direction. + * @method perp + * @param {vector} vector + * @param {bool} [negate=false] + * @return {vector} The perpendicular vector + */ + Vector.perp = function(vector, negate) { + negate = negate === true ? -1 : 1; + return { x: negate * -vector.y, y: negate * vector.x }; + }; + + /** + * Negates both components of a vector such that it points in the opposite direction. + * @method neg + * @param {vector} vector + * @return {vector} The negated vector + */ + Vector.neg = function(vector) { + return { x: -vector.x, y: -vector.y }; + }; + + /** + * Returns the angle between the vector `vectorB - vectorA` and the x-axis in radians. + * @method angle + * @param {vector} vectorA + * @param {vector} vectorB + * @return {number} The angle in radians + */ + Vector.angle = function(vectorA, vectorB) { + return Math.atan2(vectorB.y - vectorA.y, vectorB.x - vectorA.x); + }; + + /** + * Temporary vector pool (not thread-safe). + * @property _temp + * @type {vector[]} + * @private + */ + Vector._temp = [ + Vector.create(), Vector.create(), + Vector.create(), Vector.create(), + Vector.create(), Vector.create() + ]; + +})(); + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the fillStyle on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#FillStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the fill style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the fill style from. + */ +var FillStyleCanvas = function (ctx, src, altColor) +{ + var fillColor = (altColor) ? altColor : src.fillColor; + var fillAlpha = src.fillAlpha; + + var red = ((fillColor & 0xFF0000) >>> 16); + var green = ((fillColor & 0xFF00) >>> 8); + var blue = (fillColor & 0xFF); + + ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; +}; + +module.exports = FillStyleCanvas; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(18); + +/** + * Convert the given angle from degrees, to the equivalent angle in radians. + * + * @function Phaser.Math.DegToRad + * @since 3.0.0 + * + * @param {integer} degrees - The angle (in degrees) to convert to radians. + * + * @return {number} The given angle converted to radians. + */ +var DegToRad = function (degrees) +{ + return degrees * CONST.DEG_TO_RAD; +}; + +module.exports = DegToRad; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then adds the given value to it. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` + * + * @function Phaser.Actions.PropertyValueInc + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to be added to the property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var PropertyValueInc = function (items, key, value, step, index, direction) +{ + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] += value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] += value + (t * step); + t++; + } + } + + return items; +}; + +module.exports = PropertyValueInc; + + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(110); +var GetTilesWithin = __webpack_require__(19); + +/** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @function Phaser.Tilemaps.Components.CalculateFacesWithin + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var CalculateFacesWithin = function (tileX, tileY, width, height, layer) +{ + var above = null; + var below = null; + var left = null; + var right = null; + + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + if (tile) + { + if (tile.collides) + { + above = GetTileAt(tile.x, tile.y - 1, true, layer); + below = GetTileAt(tile.x, tile.y + 1, true, layer); + left = GetTileAt(tile.x - 1, tile.y, true, layer); + right = GetTileAt(tile.x + 1, tile.y, true, layer); + + tile.faceTop = (above && above.collides) ? false : true; + tile.faceBottom = (below && below.collides) ? false : true; + tile.faceLeft = (left && left.collides) ? false : true; + tile.faceRight = (right && right.collides) ? false : true; + } + else + { + tile.resetFaces(); + } + } + } +}; + +module.exports = CalculateFacesWithin; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Arcade Physics consts. + * + * @ignore + */ + +var CONST = { + + /** + * Dynamic Body. + * + * @name Phaser.Physics.Arcade.DYNAMIC_BODY + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#physicsType + * @see Phaser.Physics.Arcade.Group#physicsType + */ + DYNAMIC_BODY: 0, + + /** + * Static Body. + * + * @name Phaser.Physics.Arcade.STATIC_BODY + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#physicsType + * @see Phaser.Physics.Arcade.StaticBody#physicsType + */ + STATIC_BODY: 1, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.GROUP + * @readonly + * @type {number} + * @since 3.0.0 + */ + GROUP: 2, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.TILEMAPLAYER + * @readonly + * @type {number} + * @since 3.0.0 + */ + TILEMAPLAYER: 3, + + /** + * Facing no direction (initial value). + * + * @name Phaser.Physics.Arcade.FACING_NONE + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_NONE: 10, + + /** + * Facing up. + * + * @name Phaser.Physics.Arcade.FACING_UP + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_UP: 11, + + /** + * Facing down. + * + * @name Phaser.Physics.Arcade.FACING_DOWN + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_DOWN: 12, + + /** + * Facing left. + * + * @name Phaser.Physics.Arcade.FACING_LEFT + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_LEFT: 13, + + /** + * Facing right. + * + * @name Phaser.Physics.Arcade.FACING_RIGHT + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_RIGHT: 14 + +}; + +module.exports = CONST; + + +/***/ }), +/* 40 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the strokeStyle and lineWidth on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#LineStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the stroke style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the stroke style from. + */ +var LineStyleCanvas = function (ctx, src) +{ + var strokeColor = src.strokeColor; + var strokeAlpha = src.strokeAlpha; + + var red = ((strokeColor & 0xFF0000) >>> 16); + var green = ((strokeColor & 0xFF00) >>> 8); + var blue = (strokeColor & 0xFF); + + ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + strokeAlpha + ')'; + ctx.lineWidth = src.lineWidth; +}; + +module.exports = LineStyleCanvas; + + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetColor = __webpack_require__(195); +var GetColor32 = __webpack_require__(412); +var HSVToRGB = __webpack_require__(194); +var RGBToHSV = __webpack_require__(411); + +/** + * @classdesc + * The Color class holds a single color value and allows for easy modification and reading of it. + * + * @class Color + * @memberof Phaser.Display + * @constructor + * @since 3.0.0 + * + * @param {integer} [red=0] - The red color value. A number between 0 and 255. + * @param {integer} [green=0] - The green color value. A number between 0 and 255. + * @param {integer} [blue=0] - The blue color value. A number between 0 and 255. + * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + */ +var Color = new Class({ + + initialize: + + function Color (red, green, blue, alpha) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + if (alpha === undefined) { alpha = 255; } + + /** + * The internal red color value. + * + * @name Phaser.Display.Color#r + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.r = 0; + + /** + * The internal green color value. + * + * @name Phaser.Display.Color#g + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.g = 0; + + /** + * The internal blue color value. + * + * @name Phaser.Display.Color#b + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.b = 0; + + /** + * The internal alpha color value. + * + * @name Phaser.Display.Color#a + * @type {number} + * @private + * @default 255 + * @since 3.0.0 + */ + this.a = 255; + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#_h + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._h = 0; + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#_s + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._s = 0; + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @name Phaser.Display.Color#_v + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._v = 0; + + /** + * Is this color update locked? + * + * @name Phaser.Display.Color#_locked + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._locked = false; + + /** + * An array containing the calculated color values for WebGL use. + * + * @name Phaser.Display.Color#gl + * @type {number[]} + * @since 3.0.0 + */ + this.gl = [ 0, 0, 0, 1 ]; + + /** + * Pre-calculated internal color value. + * + * @name Phaser.Display.Color#_color + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color = 0; + + /** + * Pre-calculated internal color32 value. + * + * @name Phaser.Display.Color#_color32 + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color32 = 0; + + /** + * Pre-calculated internal color rgb string value. + * + * @name Phaser.Display.Color#_rgba + * @type {string} + * @private + * @default '' + * @since 3.0.0 + */ + this._rgba = ''; + + this.setTo(red, green, blue, alpha); + }, + + /** + * Sets this color to be transparent. Sets all values to zero. + * + * @method Phaser.Display.Color#transparent + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + transparent: function () + { + this._locked = true; + + this.red = 0; + this.green = 0; + this.blue = 0; + this.alpha = 0; + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color of this Color component. + * + * @method Phaser.Display.Color#setTo + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + * @param {boolean} [updateHSV=true] - Update the HSV values after setting the RGB values? + * + * @return {Phaser.Display.Color} This Color object. + */ + setTo: function (red, green, blue, alpha, updateHSV) + { + if (alpha === undefined) { alpha = 255; } + if (updateHSV === undefined) { updateHSV = true; } + + this._locked = true; + + this.red = red; + this.green = green; + this.blue = blue; + this.alpha = alpha; + + this._locked = false; + + return this.update(updateHSV); + }, + + /** + * Sets the red, green, blue and alpha GL values of this Color component. + * + * @method Phaser.Display.Color#setGLTo + * @since 3.0.0 + * + * @param {number} red - The red color value. A number between 0 and 1. + * @param {number} green - The green color value. A number between 0 and 1. + * @param {number} blue - The blue color value. A number between 0 and 1. + * @param {number} [alpha=1] - The alpha value. A number between 0 and 1. + * + * @return {Phaser.Display.Color} This Color object. + */ + setGLTo: function (red, green, blue, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this._locked = true; + + this.redGL = red; + this.greenGL = green; + this.blueGL = blue; + this.alphaGL = alpha; + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color based on the color object given. + * + * @method Phaser.Display.Color#setFromRGB + * @since 3.0.0 + * + * @param {InputColorObject} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromRGB: function (color) + { + this._locked = true; + + this.red = color.r; + this.green = color.g; + this.blue = color.b; + + if (color.hasOwnProperty('a')) + { + this.alpha = color.a; + } + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color based on the hue, saturation and lightness values given. + * + * @method Phaser.Display.Color#setFromHSV + * @since 3.13.0 + * + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromHSV: function (h, s, v) + { + return HSVToRGB(h, s, v, this); + }, + + /** + * Updates the internal cache values. + * + * @method Phaser.Display.Color#update + * @private + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + update: function (updateHSV) + { + if (updateHSV === undefined) { updateHSV = false; } + + if (this._locked) + { + return this; + } + + var r = this.r; + var g = this.g; + var b = this.b; + var a = this.a; + + this._color = GetColor(r, g, b); + this._color32 = GetColor32(r, g, b, a); + this._rgba = 'rgba(' + r + ',' + g + ',' + b + ',' + (a / 255) + ')'; + + if (updateHSV) + { + RGBToHSV(r, g, b, this); + } + + return this; + }, + + /** + * Updates the internal hsv cache values. + * + * @method Phaser.Display.Color#updateHSV + * @private + * @since 3.13.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + updateHSV: function () + { + var r = this.r; + var g = this.g; + var b = this.b; + + RGBToHSV(r, g, b, this); + + return this; + }, + + /** + * Returns a new Color component using the values from this one. + * + * @method Phaser.Display.Color#clone + * @since 3.0.0 + * + * @return {Phaser.Display.Color} A new Color object. + */ + clone: function () + { + return new Color(this.r, this.g, this.b, this.a); + }, + + /** + * Sets this Color object to be grayscaled based on the shade value given. + * + * @method Phaser.Display.Color#gray + * @since 3.13.0 + * + * @param {integer} shade - A value between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + gray: function (shade) + { + return this.setTo(shade, shade, shade); + }, + + /** + * Sets this Color object to be a random color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#random + * @since 3.13.0 + * + * @param {integer} [min=0] - The minimum random color value. Between 0 and 255. + * @param {integer} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + random: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var r = Math.floor(min + Math.random() * (max - min)); + var g = Math.floor(min + Math.random() * (max - min)); + var b = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(r, g, b); + }, + + /** + * Sets this Color object to be a random grayscale color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#randomGray + * @since 3.13.0 + * + * @param {integer} [min=0] - The minimum random color value. Between 0 and 255. + * @param {integer} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + randomGray: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var s = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(s, s, s); + }, + + /** + * Increase the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#saturate + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + saturate: function (amount) + { + this.s += amount / 100; + + return this; + }, + + /** + * Decrease the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#desaturate + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + desaturate: function (amount) + { + this.s -= amount / 100; + + return this; + }, + + /** + * Increase the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#lighten + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + lighten: function (amount) + { + this.v += amount / 100; + + return this; + }, + + /** + * Decrease the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#darken + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + darken: function (amount) + { + this.v -= amount / 100; + + return this; + }, + + /** + * Brighten this Color by the percentage amount given. + * + * @method Phaser.Display.Color#brighten + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + brighten: function (amount) + { + var r = this.r; + var g = this.g; + var b = this.b; + + r = Math.max(0, Math.min(255, r - Math.round(255 * - (amount / 100)))); + g = Math.max(0, Math.min(255, g - Math.round(255 * - (amount / 100)))); + b = Math.max(0, Math.min(255, b - Math.round(255 * - (amount / 100)))); + + return this.setTo(r, g, b); + }, + + /** + * The color of this Color component, not including the alpha channel. + * + * @name Phaser.Display.Color#color + * @type {number} + * @readonly + * @since 3.0.0 + */ + color: { + + get: function () + { + return this._color; + } + + }, + + /** + * The color of this Color component, including the alpha channel. + * + * @name Phaser.Display.Color#color32 + * @type {number} + * @readonly + * @since 3.0.0 + */ + color32: { + + get: function () + { + return this._color32; + } + + }, + + /** + * The color of this Color component as a string which can be used in CSS color values. + * + * @name Phaser.Display.Color#rgba + * @type {string} + * @readonly + * @since 3.0.0 + */ + rgba: { + + get: function () + { + return this._rgba; + } + + }, + + /** + * The red color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#redGL + * @type {number} + * @since 3.0.0 + */ + redGL: { + + get: function () + { + return this.gl[0]; + }, + + set: function (value) + { + this.gl[0] = Math.min(Math.abs(value), 1); + + this.r = Math.floor(this.gl[0] * 255); + + this.update(true); + } + + }, + + /** + * The green color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#greenGL + * @type {number} + * @since 3.0.0 + */ + greenGL: { + + get: function () + { + return this.gl[1]; + }, + + set: function (value) + { + this.gl[1] = Math.min(Math.abs(value), 1); + + this.g = Math.floor(this.gl[1] * 255); + + this.update(true); + } + + }, + + /** + * The blue color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#blueGL + * @type {number} + * @since 3.0.0 + */ + blueGL: { + + get: function () + { + return this.gl[2]; + }, + + set: function (value) + { + this.gl[2] = Math.min(Math.abs(value), 1); + + this.b = Math.floor(this.gl[2] * 255); + + this.update(true); + } + + }, + + /** + * The alpha color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#alphaGL + * @type {number} + * @since 3.0.0 + */ + alphaGL: { + + get: function () + { + return this.gl[3]; + }, + + set: function (value) + { + this.gl[3] = Math.min(Math.abs(value), 1); + + this.a = Math.floor(this.gl[3] * 255); + + this.update(); + } + + }, + + /** + * The red color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#red + * @type {number} + * @since 3.0.0 + */ + red: { + + get: function () + { + return this.r; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.r = Math.min(value, 255); + + this.gl[0] = value / 255; + + this.update(true); + } + + }, + + /** + * The green color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#green + * @type {number} + * @since 3.0.0 + */ + green: { + + get: function () + { + return this.g; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.g = Math.min(value, 255); + + this.gl[1] = value / 255; + + this.update(true); + } + + }, + + /** + * The blue color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#blue + * @type {number} + * @since 3.0.0 + */ + blue: { + + get: function () + { + return this.b; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.b = Math.min(value, 255); + + this.gl[2] = value / 255; + + this.update(true); + } + + }, + + /** + * The alpha color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this.a; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.a = Math.min(value, 255); + + this.gl[3] = value / 255; + + this.update(); + } + + }, + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#h + * @type {number} + * @since 3.13.0 + */ + h: { + + get: function () + { + return this._h; + }, + + set: function (value) + { + this._h = value; + + HSVToRGB(value, this._s, this._v, this); + } + + }, + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#s + * @type {number} + * @since 3.13.0 + */ + s: { + + get: function () + { + return this._s; + }, + + set: function (value) + { + this._s = value; + + HSVToRGB(this._h, value, this._v, this); + } + + }, + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @name Phaser.Display.Color#v + * @type {number} + * @since 3.13.0 + */ + v: { + + get: function () + { + return this._v; + }, + + set: function (value) + { + this._v = value; + + HSVToRGB(this._h, this._s, value, this); + } + + } + +}); + +module.exports = Color; + + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Matrix used for display transformations for rendering. + * + * It is represented like so: + * + * ``` + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * ``` + * + * @class TransformMatrix + * @memberof Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {number} [a=1] - The Scale X value. + * @param {number} [b=0] - The Shear Y value. + * @param {number} [c=0] - The Shear X value. + * @param {number} [d=1] - The Scale Y value. + * @param {number} [tx=0] - The Translate X value. + * @param {number} [ty=0] - The Translate Y value. + */ +var TransformMatrix = new Class({ + + initialize: + + function TransformMatrix (a, b, c, d, tx, ty) + { + if (a === undefined) { a = 1; } + if (b === undefined) { b = 0; } + if (c === undefined) { c = 0; } + if (d === undefined) { d = 1; } + if (tx === undefined) { tx = 0; } + if (ty === undefined) { ty = 0; } + + /** + * The matrix values. + * + * @name Phaser.GameObjects.Components.TransformMatrix#matrix + * @type {Float32Array} + * @since 3.0.0 + */ + this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + + /** + * The decomposed matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * @type {object} + * @since 3.0.0 + */ + this.decomposedMatrix = { + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotation: 0 + }; + }, + + /** + * The Scale X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#a + * @type {number} + * @since 3.4.0 + */ + a: { + + get: function () + { + return this.matrix[0]; + }, + + set: function (value) + { + this.matrix[0] = value; + } + + }, + + /** + * The Shear Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#b + * @type {number} + * @since 3.4.0 + */ + b: { + + get: function () + { + return this.matrix[1]; + }, + + set: function (value) + { + this.matrix[1] = value; + } + + }, + + /** + * The Shear X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#c + * @type {number} + * @since 3.4.0 + */ + c: { + + get: function () + { + return this.matrix[2]; + }, + + set: function (value) + { + this.matrix[2] = value; + } + + }, + + /** + * The Scale Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#d + * @type {number} + * @since 3.4.0 + */ + d: { + + get: function () + { + return this.matrix[3]; + }, + + set: function (value) + { + this.matrix[3] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#e + * @type {number} + * @since 3.11.0 + */ + e: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#f + * @type {number} + * @since 3.11.0 + */ + f: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#tx + * @type {number} + * @since 3.4.0 + */ + tx: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#ty + * @type {number} + * @since 3.4.0 + */ + ty: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The rotation of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#rotation + * @type {number} + * @readonly + * @since 3.4.0 + */ + rotation: { + + get: function () + { + return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1); + } + + }, + + /** + * The horizontal scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleX + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleX: { + + get: function () + { + return Math.sqrt((this.a * this.a) + (this.c * this.c)); + } + + }, + + /** + * The vertical scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleY + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleY: { + + get: function () + { + return Math.sqrt((this.b * this.b) + (this.d * this.d)); + } + + }, + + /** + * Reset the Matrix to an identity matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + loadIdentity: function () + { + var matrix = this.matrix; + + matrix[0] = 1; + matrix[1] = 0; + matrix[2] = 0; + matrix[3] = 1; + matrix[4] = 0; + matrix[5] = 0; + + return this; + }, + + /** + * Translate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @since 3.0.0 + * + * @param {number} x - The horizontal translation value. + * @param {number} y - The vertical translation value. + * + * @return {this} This TransformMatrix. + */ + translate: function (x, y) + { + var matrix = this.matrix; + + matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; + matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; + + return this; + }, + + /** + * Scale the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#scale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale value. + * @param {number} y - The vertical scale value. + * + * @return {this} This TransformMatrix. + */ + scale: function (x, y) + { + var matrix = this.matrix; + + matrix[0] *= x; + matrix[1] *= x; + matrix[2] *= y; + matrix[3] *= y; + + return this; + }, + + /** + * Rotate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#rotate + * @since 3.0.0 + * + * @param {number} angle - The angle of rotation in radians. + * + * @return {this} This TransformMatrix. + */ + rotate: function (angle) + { + var sin = Math.sin(angle); + var cos = Math.cos(angle); + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + matrix[0] = a * cos + c * sin; + matrix[1] = b * cos + d * sin; + matrix[2] = a * -sin + c * cos; + matrix[3] = b * -sin + d * cos; + + return this; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiply + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - The Matrix to multiply by. + * @param {Phaser.GameObjects.Components.TransformMatrix} [out] - An optional Matrix to store the results in. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} Either this TransformMatrix, or the `out` Matrix, if given in the arguments. + */ + multiply: function (rhs, out) + { + var matrix = this.matrix; + var source = rhs.matrix; + + var localA = matrix[0]; + var localB = matrix[1]; + var localC = matrix[2]; + var localD = matrix[3]; + var localE = matrix[4]; + var localF = matrix[5]; + + var sourceA = source[0]; + var sourceB = source[1]; + var sourceC = source[2]; + var sourceD = source[3]; + var sourceE = source[4]; + var sourceF = source[5]; + + var destinationMatrix = (out === undefined) ? this : out; + + destinationMatrix.a = (sourceA * localA) + (sourceB * localC); + destinationMatrix.b = (sourceA * localB) + (sourceB * localD); + destinationMatrix.c = (sourceC * localA) + (sourceD * localC); + destinationMatrix.d = (sourceC * localB) + (sourceD * localD); + destinationMatrix.e = (sourceE * localA) + (sourceF * localC) + localE; + destinationMatrix.f = (sourceE * localB) + (sourceF * localD) + localF; + + return destinationMatrix; + }, + + /** + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiplyWithOffset + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * @param {number} offsetX - Horizontal offset to factor in to the multiplication. + * @param {number} offsetY - Vertical offset to factor in to the multiplication. + * + * @return {this} This TransformMatrix. + */ + multiplyWithOffset: function (src, offsetX, offsetY) + { + var matrix = this.matrix; + var otherMatrix = src.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + var pse = offsetX * a0 + offsetY * c0 + tx0; + var psf = offsetX * b0 + offsetY * d0 + ty0; + + var a1 = otherMatrix[0]; + var b1 = otherMatrix[1]; + var c1 = otherMatrix[2]; + var d1 = otherMatrix[3]; + var tx1 = otherMatrix[4]; + var ty1 = otherMatrix[5]; + + matrix[0] = a1 * a0 + b1 * c0; + matrix[1] = a1 * b0 + b1 * d0; + matrix[2] = c1 * a0 + d1 * c0; + matrix[3] = c1 * b0 + d1 * d0; + matrix[4] = tx1 * a0 + ty1 * c0 + pse; + matrix[5] = tx1 * b0 + ty1 * d0 + psf; + + return this; + }, + + /** + * Transform the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + transform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + matrix[0] = a * a0 + b * c0; + matrix[1] = a * b0 + b * d0; + matrix[2] = c * a0 + d * c0; + matrix[3] = c * b0 + d * d0; + matrix[4] = tx * a0 + ty * c0 + tx0; + matrix[5] = tx * b0 + ty * d0 + ty0; + + return this; + }, + + /** + * Transform a point using this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point to transform. + * @param {number} y - The y coordinate of the point to transform. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - The Point object to store the transformed coordinates. + * + * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} The Point containing the transformed coordinates. + */ + transformPoint: function (x, y, point) + { + if (point === undefined) { point = { x: 0, y: 0 }; } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + point.x = x * a + y * c + tx; + point.y = x * b + y * d + ty; + + return point; + }, + + /** + * Invert the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#invert + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + invert: function () + { + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var n = a * d - b * c; + + matrix[0] = d / n; + matrix[1] = -b / n; + matrix[2] = -c / n; + matrix[3] = a / n; + matrix[4] = (c * ty - d * tx) / n; + matrix[5] = -(a * ty - b * tx) / n; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the matrix given. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFrom + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * + * @return {this} This TransformMatrix. + */ + copyFrom: function (src) + { + var matrix = this.matrix; + + matrix[0] = src.a; + matrix[1] = src.b; + matrix[2] = src.c; + matrix[3] = src.d; + matrix[4] = src.e; + matrix[5] = src.f; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFromArray + * @since 3.11.0 + * + * @param {array} src - The array of values to set into this matrix. + * + * @return {this} This TransformMatrix. + */ + copyFromArray: function (src) + { + var matrix = this.matrix; + + matrix[0] = src[0]; + matrix[1] = src[1]; + matrix[2] = src[2]; + matrix[3] = src[3]; + matrix[4] = src[4]; + matrix[5] = src[5]; + + return this; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + copyToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + setToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToArray + * @since 3.12.0 + * + * @param {array} [out] - The array to copy the matrix values in to. + * + * @return {array} An array where elements 0 to 5 contain the values from this matrix. + */ + copyToArray: function (out) + { + var matrix = this.matrix; + + if (out === undefined) + { + out = [ matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] ]; + } + else + { + out[0] = matrix[0]; + out[1] = matrix[1]; + out[2] = matrix[2]; + out[3] = matrix[3]; + out[4] = matrix[4]; + out[5] = matrix[5]; + } + + return out; + }, + + /** + * Set the values of this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setTransform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + matrix[0] = a; + matrix[1] = b; + matrix[2] = c; + matrix[3] = d; + matrix[4] = tx; + matrix[5] = ty; + + return this; + }, + + /** + * Decompose this Matrix into its translation, scale and rotation values. + * + * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix + * @since 3.0.0 + * + * @return {object} The decomposed Matrix. + */ + decomposeMatrix: function () + { + var decomposedMatrix = this.decomposedMatrix; + + var matrix = this.matrix; + + // a = scale X (1) + // b = shear Y (0) + // c = shear X (0) + // d = scale Y (1) + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + var a2 = a * a; + var b2 = b * b; + var c2 = c * c; + var d2 = d * d; + + var sx = Math.sqrt(a2 + c2); + var sy = Math.sqrt(b2 + d2); + + decomposedMatrix.translateX = matrix[4]; + decomposedMatrix.translateY = matrix[5]; + + decomposedMatrix.scaleX = sx; + decomposedMatrix.scaleY = sy; + + decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); + + return decomposedMatrix; + }, + + /** + * Apply the identity, translate, rotate and scale operations on the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS + * @since 3.0.0 + * + * @param {number} x - The horizontal translation. + * @param {number} y - The vertical translation. + * @param {number} rotation - The angle of rotation in radians. + * @param {number} scaleX - The horizontal scale. + * @param {number} scaleY - The vertical scale. + * + * @return {this} This TransformMatrix. + */ + applyITRS: function (x, y, rotation, scaleX, scaleY) + { + var matrix = this.matrix; + + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); + + // Translate + matrix[4] = x; + matrix[5] = y; + + // Rotate and Scale + matrix[0] = radianCos * scaleX; + matrix[1] = radianSin * scaleX; + matrix[2] = -radianSin * scaleY; + matrix[3] = radianCos * scaleY; + + return this; + }, + + /** + * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of + * the current matrix with its transformation applied. + * + * Can be used to translate points from world to local space. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyInverse + * @since 3.12.0 + * + * @param {number} x - The x position to translate. + * @param {number} y - The y position to translate. + * @param {Phaser.Math.Vector2} [output] - A Vector2, or point-like object, to store the results in. + * + * @return {Phaser.Math.Vector2} The coordinates, inverse-transformed through this matrix. + */ + applyInverse: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var id = 1 / ((a * d) + (c * -b)); + + output.x = (d * id * x) + (-c * id * y) + (((ty * c) - (tx * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-ty * a) + (tx * b)) * id); + + return output; + }, + + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getX + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated x value. + */ + getX: function (x, y) + { + return x * this.a + y * this.c + this.e; + }, + + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getY + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated y value. + */ + getY: function (x, y) + { + return x * this.b + y * this.d + this.f; + }, + + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getCSSMatrix + * @since 3.12.0 + * + * @return {string} A string containing the CSS Transform matrix values. + */ + getCSSMatrix: function () + { + var m = this.matrix; + + return 'matrix(' + m[0] + ',' + m[1] + ',' + m[2] + ',' + m[3] + ',' + m[4] + ',' + m[5] + ')'; + }, + + /** + * Destroys this Transform Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#destroy + * @since 3.4.0 + */ + destroy: function () + { + this.matrix = null; + this.decomposedMatrix = null; + } + +}); + +module.exports = TransformMatrix; + + +/***/ }), +/* 43 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ +var Contains = function (rect, x, y) +{ + if (rect.width <= 0 || rect.height <= 0) + { + return false; + } + + return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); +}; + +module.exports = Contains; + + +/***/ }), +/* 44 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check to see if the Circle contains the given x / y coordinates. + * + * @function Phaser.Geom.Circle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ +var Contains = function (circle, x, y) +{ + // Check if x/y are within the bounds first + if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) + { + var dx = (circle.x - x) * (circle.x - x); + var dy = (circle.y - y) * (circle.y - y); + + return (dx + dy) <= (circle.radius * circle.radius); + } + else + { + return false; + } +}; + +module.exports = Contains; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetTop = function (gameObject, value) +{ + gameObject.y = value + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetTop; + + +/***/ }), +/* 46 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the top coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The top coordinate of the bounds of the Game Object. + */ +var GetTop = function (gameObject) +{ + return gameObject.y - (gameObject.height * gameObject.originY); +}; + +module.exports = GetTop; + + +/***/ }), +/* 47 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetRight = function (gameObject, value) +{ + gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetRight; + + +/***/ }), +/* 48 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the right coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The right coordinate of the bounds of the Game Object. + */ +var GetRight = function (gameObject) +{ + return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); +}; + +module.exports = GetRight; + + +/***/ }), +/* 49 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetLeft = function (gameObject, value) +{ + gameObject.x = value + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetLeft; + + +/***/ }), +/* 50 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the left coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The left coordinate of the bounds of the Game Object. + */ +var GetLeft = function (gameObject) +{ + return gameObject.x - (gameObject.width * gameObject.originX); +}; + +module.exports = GetLeft; + + +/***/ }), +/* 51 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetBottom = function (gameObject, value) +{ + gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetBottom; + + +/***/ }), +/* 52 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the bottom coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The bottom coordinate of the bounds of the Game Object. + */ +var GetBottom = function (gameObject) +{ + return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); +}; + +module.exports = GetBottom; + + +/***/ }), +/* 53 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.WorldToTileY + * @private + * @since 3.0.0 + * + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The Y location in tile units. + */ +var WorldToTileY = function (worldY, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } + + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's vertical scroll + worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + + tileHeight *= tilemapLayer.scaleY; + } + + return snapToFloor + ? Math.floor(worldY / tileHeight) + : worldY / tileHeight; +}; + +module.exports = WorldToTileY; + + +/***/ }), +/* 54 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.WorldToTileX + * @private + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The X location in tile units. + */ +var WorldToTileX = function (worldX, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } + + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's horizontal scroll + worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX)); + + tileWidth *= tilemapLayer.scaleX; + } + + return snapToFloor + ? Math.floor(worldX / tileWidth) + : worldX / tileWidth; +}; + +module.exports = WorldToTileX; + + +/***/ }), +/* 55 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Bodies` module contains factory methods for creating rigid body models +* with commonly used body configurations (such as rectangles, circles and other polygons). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Bodies +*/ + +// TODO: true circle bodies + +var Bodies = {}; + +module.exports = Bodies; + +var Vertices = __webpack_require__(29); +var Common = __webpack_require__(12); +var Body = __webpack_require__(25); +var Bounds = __webpack_require__(33); +var Vector = __webpack_require__(34); +var decomp = __webpack_require__(244); + +(function() { + + /** + * Creates a new rigid body model with a rectangle hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method rectangle + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {object} [options] + * @return {body} A new rectangle body + */ + Bodies.rectangle = function(x, y, width, height, options) { + options = options || {}; + + var rectangle = { + label: 'Rectangle Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath('L 0 0 L ' + width + ' 0 L ' + width + ' ' + height + ' L 0 ' + height) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + rectangle.vertices = Vertices.chamfer(rectangle.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, rectangle, options)); + }; + + /** + * Creates a new rigid body model with a trapezoid hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method trapezoid + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {number} slope + * @param {object} [options] + * @return {body} A new trapezoid body + */ + Bodies.trapezoid = function(x, y, width, height, slope, options) { + options = options || {}; + + slope *= 0.5; + var roof = (1 - (slope * 2)) * width; + + var x1 = width * slope, + x2 = x1 + roof, + x3 = x2 + x1, + verticesPath; + + if (slope < 0.5) { + verticesPath = 'L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } else { + verticesPath = 'L 0 0 L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } + + var trapezoid = { + label: 'Trapezoid Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath(verticesPath) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + trapezoid.vertices = Vertices.chamfer(trapezoid.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, trapezoid, options)); + }; + + /** + * Creates a new rigid body model with a circle hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method circle + * @param {number} x + * @param {number} y + * @param {number} radius + * @param {object} [options] + * @param {number} [maxSides] + * @return {body} A new circle body + */ + Bodies.circle = function(x, y, radius, options, maxSides) { + options = options || {}; + + var circle = { + label: 'Circle Body', + circleRadius: radius + }; + + // approximate circles with polygons until true circles implemented in SAT + maxSides = maxSides || 25; + var sides = Math.ceil(Math.max(10, Math.min(maxSides, radius))); + + // optimisation: always use even number of sides (half the number of unique axes) + if (sides % 2 === 1) + sides += 1; + + return Bodies.polygon(x, y, sides, radius, Common.extend({}, circle, options)); + }; + + /** + * Creates a new rigid body model with a regular polygon hull with the given number of sides. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method polygon + * @param {number} x + * @param {number} y + * @param {number} sides + * @param {number} radius + * @param {object} [options] + * @return {body} A new regular polygon body + */ + Bodies.polygon = function(x, y, sides, radius, options) { + options = options || {}; + + if (sides < 3) + return Bodies.circle(x, y, radius, options); + + var theta = 2 * Math.PI / sides, + path = '', + offset = theta * 0.5; + + for (var i = 0; i < sides; i += 1) { + var angle = offset + (i * theta), + xx = Math.cos(angle) * radius, + yy = Math.sin(angle) * radius; + + path += 'L ' + xx.toFixed(3) + ' ' + yy.toFixed(3) + ' '; + } + + var polygon = { + label: 'Polygon Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath(path) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + polygon.vertices = Vertices.chamfer(polygon.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, polygon, options)); + }; + + /** + * Creates a body using the supplied vertices (or an array containing multiple sets of vertices). + * If the vertices are convex, they will pass through as supplied. + * Otherwise if the vertices are concave, they will be decomposed if [poly-decomp.js](https://github.com/schteppe/poly-decomp.js) is available. + * Note that this process is not guaranteed to support complex sets of vertices (e.g. those with holes may fail). + * By default the decomposition will discard collinear edges (to improve performance). + * It can also optionally discard any parts that have an area less than `minimumArea`. + * If the vertices can not be decomposed, the result will fall back to using the convex hull. + * The options parameter is an object that specifies any `Matter.Body` properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method fromVertices + * @param {number} x + * @param {number} y + * @param [[vector]] vertexSets + * @param {object} [options] + * @param {bool} [flagInternal=false] + * @param {number} [removeCollinear=0.01] + * @param {number} [minimumArea=10] + * @return {body} + */ + Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) { + var body, + parts, + isConvex, + vertices, + i, + j, + k, + v, + z; + + options = options || {}; + parts = []; + + flagInternal = typeof flagInternal !== 'undefined' ? flagInternal : false; + removeCollinear = typeof removeCollinear !== 'undefined' ? removeCollinear : 0.01; + minimumArea = typeof minimumArea !== 'undefined' ? minimumArea : 10; + + if (!decomp) { + Common.warn('Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.'); + } + + // ensure vertexSets is an array of arrays + if (!Common.isArray(vertexSets[0])) { + vertexSets = [vertexSets]; + } + + for (v = 0; v < vertexSets.length; v += 1) { + vertices = vertexSets[v]; + isConvex = Vertices.isConvex(vertices); + + if (isConvex || !decomp) { + if (isConvex) { + vertices = Vertices.clockwiseSort(vertices); + } else { + // fallback to convex hull when decomposition is not possible + vertices = Vertices.hull(vertices); + } + + parts.push({ + position: { x: x, y: y }, + vertices: vertices + }); + } else { + // initialise a decomposition + var concave = vertices.map(function(vertex) { + return [vertex.x, vertex.y]; + }); + + // vertices are concave and simple, we can decompose into parts + decomp.makeCCW(concave); + if (removeCollinear !== false) + decomp.removeCollinearPoints(concave, removeCollinear); + + // use the quick decomposition algorithm (Bayazit) + var decomposed = decomp.quickDecomp(concave); + + // for each decomposed chunk + for (i = 0; i < decomposed.length; i++) { + var chunk = decomposed[i]; + + // convert vertices into the correct structure + var chunkVertices = chunk.map(function(vertices) { + return { + x: vertices[0], + y: vertices[1] + }; + }); + + // skip small chunks + if (minimumArea > 0 && Vertices.area(chunkVertices) < minimumArea) + continue; + + // create a compound part + parts.push({ + position: Vertices.centre(chunkVertices), + vertices: chunkVertices + }); + } + } + } + + // create body parts + for (i = 0; i < parts.length; i++) { + parts[i] = Body.create(Common.extend(parts[i], options)); + } + + // flag internal edges (coincident part edges) + if (flagInternal) { + var coincident_max_dist = 5; + + for (i = 0; i < parts.length; i++) { + var partA = parts[i]; + + for (j = i + 1; j < parts.length; j++) { + var partB = parts[j]; + + if (Bounds.overlaps(partA.bounds, partB.bounds)) { + var pav = partA.vertices, + pbv = partB.vertices; + + // iterate vertices of both parts + for (k = 0; k < partA.vertices.length; k++) { + for (z = 0; z < partB.vertices.length; z++) { + // find distances between the vertices + var da = Vector.magnitudeSquared(Vector.sub(pav[(k + 1) % pav.length], pbv[z])), + db = Vector.magnitudeSquared(Vector.sub(pav[k], pbv[(z + 1) % pbv.length])); + + // if both vertices are very close, consider the edge concident (internal) + if (da < coincident_max_dist && db < coincident_max_dist) { + pav[k].isInternal = true; + pbv[z].isInternal = true; + } + } + } + + } + } + } + } + + if (parts.length > 1) { + // create the parent body to be returned, that contains generated compound parts + body = Body.create(Common.extend({ parts: parts.slice(0) }, options)); + Body.setPosition(body, { x: x, y: y }); + + return body; + } else { + return parts[0]; + } + }; + +})(); + + +/***/ }), +/* 56 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var GetValue = __webpack_require__(4); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.JSONFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the JSON Cache. + * @property {string|any} [url] - The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly added to the Cache. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {string} [dataKey] - If specified instead of the whole JSON file being parsed and added to the Cache, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#json method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#json. + * + * @class JSONFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + */ +var JSONFile = new Class({ + + Extends: File, + + initialize: + + // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object + // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing + + function JSONFile (loader, key, url, xhrSettings, dataKey) + { + var extension = 'json'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + dataKey = GetFastValue(config, 'dataKey', dataKey); + } + + var fileConfig = { + type: 'json', + cache: loader.cacheManager.json, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: dataKey + }; + + File.call(this, loader, fileConfig); + + if (IsPlainObject(url)) + { + // Object provided instead of a URL, so no need to actually load it (populate data with value) + if (dataKey) + { + this.data = GetValue(url, dataKey); + } + else + { + this.data = url; + } + + this.state = CONST.FILE_POPULATED; + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.JSONFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + if (this.state !== CONST.FILE_POPULATED) + { + this.state = CONST.FILE_PROCESSING; + + var json = JSON.parse(this.xhrLoader.responseText); + + var key = this.config; + + if (typeof key === 'string') + { + this.data = GetValue(json, key, json); + } + else + { + this.data = json; + } + } + + this.onProcessComplete(); + } + +}); + +/** + * Adds a JSON file, or array of JSON files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.json('wavedata', 'files/AlienWaveData.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.json({ + * key: 'wavedata', + * url: 'files/AlienWaveData.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.json('wavedata', 'files/AlienWaveData.json'); + * // and later in your game ... + * var data = this.cache.json.get('wavedata'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the JSON File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#json + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig|Phaser.Loader.FileTypes.JSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('json', function (key, url, dataKey, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new JSONFile(this, key[i])); + } + } + else + { + this.addFile(new JSONFile(this, key, url, xhrSettings, dataKey)); + } + + return this; +}); + +module.exports = JSONFile; + + +/***/ }), +/* 57 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var GameObject = __webpack_require__(17); +var SpriteRender = __webpack_require__(896); + +/** + * @classdesc + * A Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Sprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.TextureCrop, + Components.Tint, + Components.Transform, + Components.Visible, + SpriteRender + ], + + initialize: + + function Sprite (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Sprite'); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Sprite#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Animation Controller of this Sprite. + * + * @name Phaser.GameObjects.Sprite#anims + * @type {Phaser.GameObjects.Components.Animation} + * @since 3.0.0 + */ + this.anims = new Components.Animation(this); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initPipeline(); + }, + + /** + * Update this Sprite's animations. + * + * @method Phaser.GameObjects.Sprite#preUpdate + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + }, + + /** + * Start playing the given animation. + * + * @method Phaser.GameObjects.Sprite#play + * @since 3.0.0 + * + * @param {string} key - The string-based key of the animation to play. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.Sprite} This Game Object. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + this.anims.play(key, ignoreIfPlaying, startFrame); + + return this; + }, + + /** + * Build a JSON representation of this Sprite. + * + * @method Phaser.GameObjects.Sprite#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + var data = Components.ToJSON(this); + + // Extra Sprite data is added here + + return data; + }, + + /** + * Handles the pre-destroy step for the Sprite, which removes the Animation component. + * + * @method Phaser.GameObjects.Sprite#preDestroy + * @private + * @since 3.14.0 + */ + preDestroy: function () + { + this.anims.destroy(); + + this.anims = undefined; + } + +}); + +module.exports = Sprite; + + +/***/ }), +/* 58 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the distance between two sets of coordinates (points). + * + * @function Phaser.Math.Distance.Between + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The distance between each point. + */ +var DistanceBetween = function (x1, y1, x2, y2) +{ + var dx = x1 - x2; + var dy = y1 - y2; + + return Math.sqrt(dx * dx + dy * dy); +}; + +module.exports = DistanceBetween; + + +/***/ }), +/* 59 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Wrap the given `value` between `min` and `max. + * + * @function Phaser.Math.Wrap + * @since 3.0.0 + * + * @param {number} value - The value to wrap. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. + * + * @return {number} The wrapped value. + */ +var Wrap = function (value, min, max) +{ + var range = max - min; + + return (min + ((((value - min) % range) + range) % range)); +}; + +module.exports = Wrap; + + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetPoint = __webpack_require__(433); +var GetPoints = __webpack_require__(208); +var Random = __webpack_require__(207); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * Defines a Line segment, a part of a line between two endpoints. + * + * @class Line + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x1=0] - The x coordinate of the lines starting point. + * @param {number} [y1=0] - The y coordinate of the lines starting point. + * @param {number} [x2=0] - The x coordinate of the lines ending point. + * @param {number} [y2=0] - The y coordinate of the lines ending point. + */ +var Line = new Class({ + + initialize: + + function Line (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + /** + * The x coordinate of the lines starting point. + * + * @name Phaser.Geom.Line#x1 + * @type {number} + * @since 3.0.0 + */ + this.x1 = x1; + + /** + * The y coordinate of the lines starting point. + * + * @name Phaser.Geom.Line#y1 + * @type {number} + * @since 3.0.0 + */ + this.y1 = y1; + + /** + * The x coordinate of the lines ending point. + * + * @name Phaser.Geom.Line#x2 + * @type {number} + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * The y coordinate of the lines ending point. + * + * @name Phaser.Geom.Line#y2 + * @type {number} + * @since 3.0.0 + */ + this.y2 = y2; + }, + + /** + * Get a point on a line that's a given percentage along its length. + * + * @method Phaser.Geom.Line#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {(Phaser.Geom.Point|object)} [output] - An optional point, or point-like object, to store the coordinates of the point on the line. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point on the line. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * @method Phaser.Geom.Line#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {integer} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {integer} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param {(array|Phaser.Geom.Point[])} [output] - An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * + * @return {(array|Phaser.Geom.Point[])} An array of Points, or point-like objects, containing the coordinates of the points on the line. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Get a random Point on the Line. + * + * @method Phaser.Geom.Line#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {(Phaser.Geom.Point|object)} [point] - An instance of a Point to be modified. + * + * @return {Phaser.Geom.Point} A random Point on the Line. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Set new coordinates for the line endpoints. + * + * @method Phaser.Geom.Line#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - The x coordinate of the lines starting point. + * @param {number} [y1=0] - The y coordinate of the lines starting point. + * @param {number} [x2=0] - The x coordinate of the lines ending point. + * @param {number} [y2=0] - The y coordinate of the lines ending point. + * + * @return {Phaser.Geom.Line} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + return this; + }, + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * + * @method Phaser.Geom.Line#getPointA + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + */ + getPointA: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x1, this.y1); + + return vec2; + }, + + /** + * Returns a Vector2 object that corresponds to the end of this Line. + * + * @method Phaser.Geom.Line#getPointB + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the end of this Line. + */ + getPointB: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x2, this.y2); + + return vec2; + }, + + /** + * The left position of the Line. + * + * @name Phaser.Geom.Line#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return Math.min(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 <= this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The right position of the Line. + * + * @name Phaser.Geom.Line#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return Math.max(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 > this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The top position of the Line. + * + * @name Phaser.Geom.Line#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return Math.min(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 <= this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + }, + + /** + * The bottom position of the Line. + * + * @name Phaser.Geom.Line#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return Math.max(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 > this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + } + +}); + +module.exports = Line; + + +/***/ }), +/* 61 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var Rectangle = __webpack_require__(293); + +/** + * @classdesc + * A Tile is a representation of a single tile within the Tilemap. This is a lightweight data + * representation, so its position information is stored without factoring in scroll, layer + * scale or layer position. + * + * @class Tile + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Tilemaps.LayerData} layer - The LayerData object in the Tilemap that this tile belongs to. + * @param {integer} index - The unique index of this tile within the map. + * @param {integer} x - The x coordinate of this tile in tile coordinates. + * @param {integer} y - The y coordinate of this tile in tile coordinates. + * @param {integer} width - Width of the tile in pixels. + * @param {integer} height - Height of the tile in pixels. + * @param {integer} baseWidth - The base width a tile in the map (in pixels). Tiled maps support + * multiple tileset sizes within one map, but they are still placed at intervals of the base + * tile width. + * @param {integer} baseHeight - The base height of the tile in pixels (in pixels). Tiled maps + * support multiple tileset sizes within one map, but they are still placed at intervals of the + * base tile height. + */ +var Tile = new Class({ + + Mixins: [ + Components.Alpha, + Components.Flip, + Components.Visible + ], + + initialize: + + function Tile (layer, index, x, y, width, height, baseWidth, baseHeight) + { + /** + * The LayerData in the Tilemap data that this tile belongs to. + * + * @name Phaser.Tilemaps.Tile#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = layer; + + /** + * The index of this tile within the map data corresponding to the tileset, or -1 if this + * represents a blank tile. + * + * @name Phaser.Tilemaps.Tile#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * The x map coordinate of this tile in tile units. + * + * @name Phaser.Tilemaps.Tile#x + * @type {integer} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y map coordinate of this tile in tile units. + * + * @name Phaser.Tilemaps.Tile#y + * @type {integer} + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the tile in pixels. + * + * @name Phaser.Tilemaps.Tile#width + * @type {integer} + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the tile in pixels. + * + * @name Phaser.Tilemaps.Tile#height + * @type {integer} + * @since 3.0.0 + */ + this.height = height; + + /** + * The map's base width of a tile in pixels. Tiled maps support multiple tileset sizes + * within one map, but they are still placed at intervals of the base tile size. + * + * @name Phaser.Tilemaps.Tile#baseWidth + * @type {integer} + * @since 3.0.0 + */ + this.baseWidth = (baseWidth !== undefined) ? baseWidth : width; + + /** + * The map's base height of a tile in pixels. Tiled maps support multiple tileset sizes + * within one map, but they are still placed at intervals of the base tile size. + * + * @name Phaser.Tilemaps.Tile#baseHeight + * @type {integer} + * @since 3.0.0 + */ + this.baseHeight = (baseHeight !== undefined) ? baseHeight : height; + + /** + * The x coordinate of the top left of this tile in pixels. This is relative to the top left + * of the layer this tile is being rendered within. This property does NOT factor in camera + * scroll, layer scale or layer position. + * + * @name Phaser.Tilemaps.Tile#pixelX + * @type {number} + * @since 3.0.0 + */ + this.pixelX = 0; + + /** + * The y coordinate of the top left of this tile in pixels. This is relative to the top left + * of the layer this tile is being rendered within. This property does NOT factor in camera + * scroll, layer scale or layer position. + * + * @name Phaser.Tilemaps.Tile#pixelY + * @type {number} + * @since 3.0.0 + */ + this.pixelY = 0; + + this.updatePixelXY(); + + /** + * Tile specific properties. These usually come from Tiled. + * + * @name Phaser.Tilemaps.Tile#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = {}; + + /** + * The rotation angle of this tile. + * + * @name Phaser.Tilemaps.Tile#rotation + * @type {number} + * @since 3.0.0 + */ + this.rotation = 0; + + /** + * Whether the tile should collide with any object on the left side. + * + * @name Phaser.Tilemaps.Tile#collideLeft + * @type {boolean} + * @since 3.0.0 + */ + this.collideLeft = false; + + /** + * Whether the tile should collide with any object on the right side. + * + * @name Phaser.Tilemaps.Tile#collideRight + * @type {boolean} + * @since 3.0.0 + */ + this.collideRight = false; + + /** + * Whether the tile should collide with any object on the top side. + * + * @name Phaser.Tilemaps.Tile#collideUp + * @type {boolean} + * @since 3.0.0 + */ + this.collideUp = false; + + /** + * Whether the tile should collide with any object on the bottom side. + * + * @name Phaser.Tilemaps.Tile#collideDown + * @type {boolean} + * @since 3.0.0 + */ + this.collideDown = false; + + /** + * Whether the tile's left edge is interesting for collisions. + * + * @name Phaser.Tilemaps.Tile#faceLeft + * @type {boolean} + * @since 3.0.0 + */ + this.faceLeft = false; + + /** + * Whether the tile's right edge is interesting for collisions. + * + * @name Phaser.Tilemaps.Tile#faceRight + * @type {boolean} + * @since 3.0.0 + */ + this.faceRight = false; + + /** + * Whether the tile's top edge is interesting for collisions. + * + * @name Phaser.Tilemaps.Tile#faceTop + * @type {boolean} + * @since 3.0.0 + */ + this.faceTop = false; + + /** + * Whether the tile's bottom edge is interesting for collisions. + * + * @name Phaser.Tilemaps.Tile#faceBottom + * @type {boolean} + * @since 3.0.0 + */ + this.faceBottom = false; + + /** + * Tile collision callback. + * + * @name Phaser.Tilemaps.Tile#collisionCallback + * @type {function} + * @since 3.0.0 + */ + this.collisionCallback = null; + + /** + * The context in which the collision callback will be called. + * + * @name Phaser.Tilemaps.Tile#collisionCallbackContext + * @type {object} + * @since 3.0.0 + */ + this.collisionCallbackContext = this; + + /** + * The tint to apply to this tile. Note: tint is currently a single color value instead of + * the 4 corner tint component on other GameObjects. + * + * @name Phaser.Tilemaps.Tile#tint + * @type {number} + * @default + * @since 3.0.0 + */ + this.tint = 0xffffff; + + /** + * An empty object where physics-engine specific information (e.g. bodies) may be stored. + * + * @name Phaser.Tilemaps.Tile#physics + * @type {object} + * @since 3.0.0 + */ + this.physics = {}; + }, + + /** + * Check if the given x and y world coordinates are within this Tile. This does not factor in + * camera scroll, layer scale or layer position. + * + * @method Phaser.Tilemaps.Tile#containsPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate to test. + * @param {number} y - The y coordinate to test. + * + * @return {boolean} True if the coordinates are within this Tile, otherwise false. + */ + containsPoint: function (x, y) + { + return !(x < this.pixelX || y < this.pixelY || x > this.right || y > this.bottom); + }, + + /** + * Copies the tile data & properties from the given tile to this tile. This copies everything + * except for position and interesting faces. + * + * @method Phaser.Tilemaps.Tile#copy + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.Tile} tile - The tile to copy from. + * + * @return {Phaser.Tilemaps.Tile} This Tile object. + */ + copy: function (tile) + { + this.index = tile.index; + this.alpha = tile.alpha; + this.properties = tile.properties; + this.visible = tile.visible; + this.setFlip(tile.flipX, tile.flipY); + this.tint = tile.tint; + this.rotation = tile.rotation; + this.collideUp = tile.collideUp; + this.collideDown = tile.collideDown; + this.collideLeft = tile.collideLeft; + this.collideRight = tile.collideRight; + this.collisionCallback = tile.collisionCallback; + this.collisionCallbackContext = tile.collisionCallbackContext; + + return this; + }, + + /** + * The collision group for this Tile, defined within the Tileset. This returns a reference to + * the collision group stored within the Tileset, so any modification of the returned object + * will impact all tiles that have the same index as this tile. + * + * @method Phaser.Tilemaps.Tile#getCollisionGroup + * @since 3.0.0 + * + * @return {?object} tileset + */ + getCollisionGroup: function () + { + return this.tileset ? this.tileset.getTileCollisionGroup(this.index) : null; + }, + + /** + * The tile data for this Tile, defined within the Tileset. This typically contains Tiled + * collision data, tile animations and terrain information. This returns a reference to the tile + * data stored within the Tileset, so any modification of the returned object will impact all + * tiles that have the same index as this tile. + * + * @method Phaser.Tilemaps.Tile#getTileData + * @since 3.0.0 + * + * @return {?object} tileset + */ + getTileData: function () + { + return this.tileset ? this.tileset.getTileData(this.index) : null; + }, + + /** + * Gets the world X position of the left side of the tile, factoring in the layers position, + * scale and scroll. + * + * @method Phaser.Tilemaps.Tile#getLeft + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. + * + * @return {number} + */ + getLeft: function (camera) + { + var tilemapLayer = this.tilemapLayer; + + return (tilemapLayer) ? tilemapLayer.tileToWorldX(this.x, camera) : this.x * this.baseWidth; + }, + + /** + * Gets the world X position of the right side of the tile, factoring in the layer's position, + * scale and scroll. + * + * @method Phaser.Tilemaps.Tile#getRight + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. + * + * @return {number} + */ + getRight: function (camera) + { + var tilemapLayer = this.tilemapLayer; + + return (tilemapLayer) ? this.getLeft(camera) + this.width * tilemapLayer.scaleX : this.getLeft(camera) + this.width; + }, + + /** + * Gets the world Y position of the top side of the tile, factoring in the layer's position, + * scale and scroll. + * + * @method Phaser.Tilemaps.Tile#getTop + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. + * + * @return {number} + */ + getTop: function (camera) + { + var tilemapLayer = this.tilemapLayer; + + // Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile in grid + // units is the bottom left, so the y coordinate needs to be adjusted by the difference + // between the base size and this tile's size. + return tilemapLayer + ? tilemapLayer.tileToWorldY(this.y, camera) - (this.height - this.baseHeight) * tilemapLayer.scaleY + : this.y * this.baseHeight - (this.height - this.baseHeight); + }, + + /** + * Gets the world Y position of the bottom side of the tile, factoring in the layer's position, + * scale and scroll. + + * @method Phaser.Tilemaps.Tile#getBottom + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. + * + * @return {number} + */ + getBottom: function (camera) + { + var tilemapLayer = this.tilemapLayer; + return tilemapLayer + ? this.getTop(camera) + this.height * tilemapLayer.scaleY + : this.getTop(camera) + this.height; + }, + + + /** + * Gets the world rectangle bounding box for the tile, factoring in the layers position, + * scale and scroll. + * + * @method Phaser.Tilemaps.Tile#getBounds + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. + * @param {object} [output] - [description] + * + * @return {(Phaser.Geom.Rectangle|object)} + */ + getBounds: function (camera, output) + { + if (output === undefined) { output = new Rectangle(); } + + output.x = this.getLeft(); + output.y = this.getTop(); + output.width = this.getRight() - output.x; + output.height = this.getBottom() - output.y; + + return output; + }, + + /** + * Gets the world X position of the center of the tile, factoring in the layer's position, + * scale and scroll. + * + * @method Phaser.Tilemaps.Tile#getCenterX + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. + * + * @return {number} + */ + getCenterX: function (camera) + { + return this.getLeft(camera) + this.width / 2; + }, + + /** + * Gets the world Y position of the center of the tile, factoring in the layer's position, + * scale and scroll. + * + * @method Phaser.Tilemaps.Tile#getCenterY + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to use to perform the check. + * + * @return {number} + */ + getCenterY: function (camera) + { + return this.getTop(camera) + this.height / 2; + }, + + /** + * Clean up memory. + * + * @method Phaser.Tilemaps.Tile#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.collisionCallback = undefined; + this.collisionCallbackContext = undefined; + this.properties = undefined; + }, + + /** + * Check for intersection with this tile. This does not factor in camera scroll, layer scale or + * layer position. + * + * @method Phaser.Tilemaps.Tile#intersects + * @since 3.0.0 + * + * @param {number} x - The x axis in pixels. + * @param {number} y - The y axis in pixels. + * @param {number} right - The right point. + * @param {number} bottom - The bottom point. + * + * @return {boolean} + */ + intersects: function (x, y, right, bottom) + { + return !( + right <= this.pixelX || bottom <= this.pixelY || + x >= this.right || y >= this.bottom + ); + }, + + /** + * Checks if the tile is interesting. + * + * @method Phaser.Tilemaps.Tile#isInteresting + * @since 3.0.0 + * + * @param {boolean} collides - If true, will consider the tile interesting if it collides on any side. + * @param {boolean} faces - If true, will consider the tile interesting if it has an interesting face. + * + * @return {boolean} True if the Tile is interesting, otherwise false. + */ + isInteresting: function (collides, faces) + { + if (collides && faces) { return (this.canCollide || this.hasInterestingFace); } + else if (collides) { return this.collides; } + else if (faces) { return this.hasInterestingFace; } + return false; + }, + + /** + * Reset collision status flags. + * + * @method Phaser.Tilemaps.Tile#resetCollision + * @since 3.0.0 + * + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate interesting faces for this tile and its neighbors. + * + * @return {Phaser.Tilemaps.Tile} This Tile object. + */ + resetCollision: function (recalculateFaces) + { + if (recalculateFaces === undefined) { recalculateFaces = true; } + + this.collideLeft = false; + this.collideRight = false; + this.collideUp = false; + this.collideDown = false; + + this.faceTop = false; + this.faceBottom = false; + this.faceLeft = false; + this.faceRight = false; + + if (recalculateFaces) + { + var tilemapLayer = this.tilemapLayer; + + if (tilemapLayer) + { + this.tilemapLayer.calculateFacesAt(this.x, this.y); + } + } + + return this; + }, + + /** + * Reset faces. + * + * @method Phaser.Tilemaps.Tile#resetFaces + * @since 3.0.0 + * + * @return {Phaser.Tilemaps.Tile} This Tile object. + */ + resetFaces: function () + { + this.faceTop = false; + this.faceBottom = false; + this.faceLeft = false; + this.faceRight = false; + + return this; + }, + + /** + * Sets the collision flags for each side of this tile and updates the interesting faces list. + * + * @method Phaser.Tilemaps.Tile#setCollision + * @since 3.0.0 + * + * @param {boolean} left - Indicating collide with any object on the left. + * @param {boolean} [right] - Indicating collide with any object on the right. + * @param {boolean} [up] - Indicating collide with any object on the top. + * @param {boolean} [down] - Indicating collide with any object on the bottom. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate interesting faces + * for this tile and its neighbors. + * + * @return {Phaser.Tilemaps.Tile} This Tile object. + */ + setCollision: function (left, right, up, down, recalculateFaces) + { + if (right === undefined) { right = left; } + if (up === undefined) { up = left; } + if (down === undefined) { down = left; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + this.collideLeft = left; + this.collideRight = right; + this.collideUp = up; + this.collideDown = down; + + this.faceLeft = left; + this.faceRight = right; + this.faceTop = up; + this.faceBottom = down; + + if (recalculateFaces) + { + var tilemapLayer = this.tilemapLayer; + + if (tilemapLayer) + { + this.tilemapLayer.calculateFacesAt(this.x, this.y); + } + } + + return this; + }, + + /** + * Set a callback to be called when this tile is hit by an object. The callback must true for + * collision processing to take place. + * + * @method Phaser.Tilemaps.Tile#setCollisionCallback + * @since 3.0.0 + * + * @param {function} callback - Callback function. + * @param {object} context - Callback will be called within this context. + * + * @return {Phaser.Tilemaps.Tile} This Tile object. + */ + setCollisionCallback: function (callback, context) + { + if (callback === null) + { + this.collisionCallback = undefined; + this.collisionCallbackContext = undefined; + } + else + { + this.collisionCallback = callback; + this.collisionCallbackContext = context; + } + + return this; + }, + + /** + * Sets the size of the tile and updates its pixelX and pixelY. + * + * @method Phaser.Tilemaps.Tile#setSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tile in pixels. + * @param {integer} tileHeight - The height of the tile in pixels. + * @param {integer} baseWidth - The base width a tile in the map (in pixels). + * @param {integer} baseHeight - The base height of the tile in pixels (in pixels). + * + * @return {Phaser.Tilemaps.Tile} This Tile object. + */ + setSize: function (tileWidth, tileHeight, baseWidth, baseHeight) + { + if (tileWidth !== undefined) { this.width = tileWidth; } + if (tileHeight !== undefined) { this.height = tileHeight; } + if (baseWidth !== undefined) { this.baseWidth = baseWidth; } + if (baseHeight !== undefined) { this.baseHeight = baseHeight; } + + this.updatePixelXY(); + + return this; + }, + + /** + * Used internally. Updates the tile's world XY position based on the current tile size. + * + * @method Phaser.Tilemaps.Tile#updatePixelXY + * @since 3.0.0 + * + * @return {Phaser.Tilemaps.Tile} This Tile object. + */ + updatePixelXY: function () + { + // Tiled places tiles on a grid of baseWidth x baseHeight. The origin for a tile is the + // bottom left, while the Phaser renderer assumes the origin is the top left. The y + // coordinate needs to be adjusted by the difference. + this.pixelX = this.x * this.baseWidth; + this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight); + + return this; + }, + + /** + * True if this tile can collide on any of its faces or has a collision callback set. + * + * @name Phaser.Tilemaps.Tile#canCollide + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + canCollide: { + get: function () + { + return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback); + } + }, + + /** + * True if this tile can collide on any of its faces. + * + * @name Phaser.Tilemaps.Tile#collides + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + collides: { + get: function () + { + return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown); + } + }, + + /** + * True if this tile has any interesting faces. + * + * @name Phaser.Tilemaps.Tile#hasInterestingFace + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + hasInterestingFace: { + get: function () + { + return (this.faceTop || this.faceBottom || this.faceLeft || this.faceRight); + } + }, + + /** + * The tileset that contains this Tile. This will only return null if accessed from a LayerData + * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. + * + * @name Phaser.Tilemaps.Tile#tileset + * @type {?Phaser.Tilemaps.Tileset} + * @readonly + * @since 3.0.0 + */ + tileset: { + get: function () + { + var tilemapLayer = this.tilemapLayer; + return tilemapLayer ? tilemapLayer.tileset : null; + } + }, + + /** + * The tilemap layer that contains this Tile. This will only return null if accessed from a + * LayerData instance before the tile is placed within a StaticTilemapLayer or + * DynamicTilemapLayer. + * + * @name Phaser.Tilemaps.Tile#tilemapLayer + * @type {?Phaser.Tilemaps.StaticTilemapLayer|Phaser.Tilemaps.DynamicTilemapLayer} + * @readonly + * @since 3.0.0 + */ + tilemapLayer: { + get: function () + { + return this.layer.tilemapLayer; + } + }, + + /** + * The tilemap that contains this Tile. This will only return null if accessed from a LayerData + * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. + * + * @name Phaser.Tilemaps.Tile#tilemap + * @type {?Phaser.Tilemaps.Tilemap} + * @readonly + * @since 3.0.0 + */ + tilemap: { + get: function () + { + var tilemapLayer = this.tilemapLayer; + return tilemapLayer ? tilemapLayer.tilemap : null; + } + } + +}); + +module.exports = Tile; + + +/***/ }), +/* 62 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internally used method to set the colliding state of a tile. This does not recalculate + * interesting faces. + * + * @function Phaser.Tilemaps.Components.SetTileCollision + * @private + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.Tile} tile - The Tile to set the collision on. + * @param {boolean} [collides=true] - Should the tile index collide or not? + */ +var SetTileCollision = function (tile, collides) +{ + if (collides) + { + tile.setCollision(true, true, true, true, false); + } + else + { + tile.resetCollision(false); + } +}; + +module.exports = SetTileCollision; + + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Composite` module contains methods for creating and manipulating composite bodies. +* A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. +* It is important to use the functions in this module to modify composites, rather than directly modifying their properties. +* Note that the `Matter.World` object is also a type of `Matter.Composite` and as such all composite methods here can also operate on a `Matter.World`. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Composite +*/ + +var Composite = {}; + +module.exports = Composite; + +var Events = __webpack_require__(74); +var Common = __webpack_require__(12); +var Bounds = __webpack_require__(33); +var Body = __webpack_require__(25); + +(function() { + + /** + * Creates a new composite. The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properites section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {} [options] + * @return {composite} A new composite + */ + Composite.create = function(options) { + return Common.extend({ + id: Common.nextId(), + type: 'composite', + parent: null, + isModified: false, + bodies: [], + constraints: [], + composites: [], + label: 'Composite', + plugin: {} + }, options); + }; + + /** + * Sets the composite's `isModified` flag. + * If `updateParents` is true, all parents will be set (default: false). + * If `updateChildren` is true, all children will be set (default: false). + * @method setModified + * @param {composite} composite + * @param {boolean} isModified + * @param {boolean} [updateParents=false] + * @param {boolean} [updateChildren=false] + */ + Composite.setModified = function(composite, isModified, updateParents, updateChildren) { + composite.isModified = isModified; + + if (updateParents && composite.parent) { + Composite.setModified(composite.parent, isModified, updateParents, updateChildren); + } + + if (updateChildren) { + for(var i = 0; i < composite.composites.length; i++) { + var childComposite = composite.composites[i]; + Composite.setModified(childComposite, isModified, updateParents, updateChildren); + } + } + }; + + /** + * Generic add function. Adds one or many body(s), constraint(s) or a composite(s) to the given composite. + * Triggers `beforeAdd` and `afterAdd` events on the `composite`. + * @method add + * @param {composite} composite + * @param {} object + * @return {composite} The original composite with the objects added + */ + Composite.add = function(composite, object) { + var objects = [].concat(object); + + Events.trigger(composite, 'beforeAdd', { object: object }); + + for (var i = 0; i < objects.length; i++) { + var obj = objects[i]; + + switch (obj.type) { + + case 'body': + // skip adding compound parts + if (obj.parent !== obj) { + Common.warn('Composite.add: skipped adding a compound body part (you must add its parent instead)'); + break; + } + + Composite.addBody(composite, obj); + break; + case 'constraint': + Composite.addConstraint(composite, obj); + break; + case 'composite': + Composite.addComposite(composite, obj); + break; + case 'mouseConstraint': + Composite.addConstraint(composite, obj.constraint); + break; + + } + } + + Events.trigger(composite, 'afterAdd', { object: object }); + + return composite; + }; + + /** + * Generic remove function. Removes one or many body(s), constraint(s) or a composite(s) to the given composite. + * Optionally searching its children recursively. + * Triggers `beforeRemove` and `afterRemove` events on the `composite`. + * @method remove + * @param {composite} composite + * @param {} object + * @param {boolean} [deep=false] + * @return {composite} The original composite with the objects removed + */ + Composite.remove = function(composite, object, deep) { + var objects = [].concat(object); + + Events.trigger(composite, 'beforeRemove', { object: object }); + + for (var i = 0; i < objects.length; i++) { + var obj = objects[i]; + + switch (obj.type) { + + case 'body': + Composite.removeBody(composite, obj, deep); + break; + case 'constraint': + Composite.removeConstraint(composite, obj, deep); + break; + case 'composite': + Composite.removeComposite(composite, obj, deep); + break; + case 'mouseConstraint': + Composite.removeConstraint(composite, obj.constraint); + break; + + } + } + + Events.trigger(composite, 'afterRemove', { object: object }); + + return composite; + }; + + /** + * Adds a composite to the given composite. + * @private + * @method addComposite + * @param {composite} compositeA + * @param {composite} compositeB + * @return {composite} The original compositeA with the objects from compositeB added + */ + Composite.addComposite = function(compositeA, compositeB) { + compositeA.composites.push(compositeB); + compositeB.parent = compositeA; + Composite.setModified(compositeA, true, true, false); + return compositeA; + }; + + /** + * Removes a composite from the given composite, and optionally searching its children recursively. + * @private + * @method removeComposite + * @param {composite} compositeA + * @param {composite} compositeB + * @param {boolean} [deep=false] + * @return {composite} The original compositeA with the composite removed + */ + Composite.removeComposite = function(compositeA, compositeB, deep) { + var position = compositeA.composites.indexOf(compositeB); + if (position !== -1) { + Composite.removeCompositeAt(compositeA, position); + Composite.setModified(compositeA, true, true, false); + } + + if (deep) { + for (var i = 0; i < compositeA.composites.length; i++){ + Composite.removeComposite(compositeA.composites[i], compositeB, true); + } + } + + return compositeA; + }; + + /** + * Removes a composite from the given composite. + * @private + * @method removeCompositeAt + * @param {composite} composite + * @param {number} position + * @return {composite} The original composite with the composite removed + */ + Composite.removeCompositeAt = function(composite, position) { + composite.composites.splice(position, 1); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Adds a body to the given composite. + * @private + * @method addBody + * @param {composite} composite + * @param {body} body + * @return {composite} The original composite with the body added + */ + Composite.addBody = function(composite, body) { + composite.bodies.push(body); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Removes a body from the given composite, and optionally searching its children recursively. + * @private + * @method removeBody + * @param {composite} composite + * @param {body} body + * @param {boolean} [deep=false] + * @return {composite} The original composite with the body removed + */ + Composite.removeBody = function(composite, body, deep) { + var position = composite.bodies.indexOf(body); + if (position !== -1) { + Composite.removeBodyAt(composite, position); + Composite.setModified(composite, true, true, false); + } + + if (deep) { + for (var i = 0; i < composite.composites.length; i++){ + Composite.removeBody(composite.composites[i], body, true); + } + } + + return composite; + }; + + /** + * Removes a body from the given composite. + * @private + * @method removeBodyAt + * @param {composite} composite + * @param {number} position + * @return {composite} The original composite with the body removed + */ + Composite.removeBodyAt = function(composite, position) { + composite.bodies.splice(position, 1); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Adds a constraint to the given composite. + * @private + * @method addConstraint + * @param {composite} composite + * @param {constraint} constraint + * @return {composite} The original composite with the constraint added + */ + Composite.addConstraint = function(composite, constraint) { + composite.constraints.push(constraint); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Removes a constraint from the given composite, and optionally searching its children recursively. + * @private + * @method removeConstraint + * @param {composite} composite + * @param {constraint} constraint + * @param {boolean} [deep=false] + * @return {composite} The original composite with the constraint removed + */ + Composite.removeConstraint = function(composite, constraint, deep) { + var position = composite.constraints.indexOf(constraint); + if (position !== -1) { + Composite.removeConstraintAt(composite, position); + } + + if (deep) { + for (var i = 0; i < composite.composites.length; i++){ + Composite.removeConstraint(composite.composites[i], constraint, true); + } + } + + return composite; + }; + + /** + * Removes a body from the given composite. + * @private + * @method removeConstraintAt + * @param {composite} composite + * @param {number} position + * @return {composite} The original composite with the constraint removed + */ + Composite.removeConstraintAt = function(composite, position) { + composite.constraints.splice(position, 1); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Removes all bodies, constraints and composites from the given composite. + * Optionally clearing its children recursively. + * @method clear + * @param {composite} composite + * @param {boolean} keepStatic + * @param {boolean} [deep=false] + */ + Composite.clear = function(composite, keepStatic, deep) { + if (deep) { + for (var i = 0; i < composite.composites.length; i++){ + Composite.clear(composite.composites[i], keepStatic, true); + } + } + + if (keepStatic) { + composite.bodies = composite.bodies.filter(function(body) { return body.isStatic; }); + } else { + composite.bodies.length = 0; + } + + composite.constraints.length = 0; + composite.composites.length = 0; + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Returns all bodies in the given composite, including all bodies in its children, recursively. + * @method allBodies + * @param {composite} composite + * @return {body[]} All the bodies + */ + Composite.allBodies = function(composite) { + var bodies = [].concat(composite.bodies); + + for (var i = 0; i < composite.composites.length; i++) + bodies = bodies.concat(Composite.allBodies(composite.composites[i])); + + return bodies; + }; + + /** + * Returns all constraints in the given composite, including all constraints in its children, recursively. + * @method allConstraints + * @param {composite} composite + * @return {constraint[]} All the constraints + */ + Composite.allConstraints = function(composite) { + var constraints = [].concat(composite.constraints); + + for (var i = 0; i < composite.composites.length; i++) + constraints = constraints.concat(Composite.allConstraints(composite.composites[i])); + + return constraints; + }; + + /** + * Returns all composites in the given composite, including all composites in its children, recursively. + * @method allComposites + * @param {composite} composite + * @return {composite[]} All the composites + */ + Composite.allComposites = function(composite) { + var composites = [].concat(composite.composites); + + for (var i = 0; i < composite.composites.length; i++) + composites = composites.concat(Composite.allComposites(composite.composites[i])); + + return composites; + }; + + /** + * Searches the composite recursively for an object matching the type and id supplied, null if not found. + * @method get + * @param {composite} composite + * @param {number} id + * @param {string} type + * @return {object} The requested object, if found + */ + Composite.get = function(composite, id, type) { + var objects, + object; + + switch (type) { + case 'body': + objects = Composite.allBodies(composite); + break; + case 'constraint': + objects = Composite.allConstraints(composite); + break; + case 'composite': + objects = Composite.allComposites(composite).concat(composite); + break; + } + + if (!objects) + return null; + + object = objects.filter(function(object) { + return object.id.toString() === id.toString(); + }); + + return object.length === 0 ? null : object[0]; + }; + + /** + * Moves the given object(s) from compositeA to compositeB (equal to a remove followed by an add). + * @method move + * @param {compositeA} compositeA + * @param {object[]} objects + * @param {compositeB} compositeB + * @return {composite} Returns compositeA + */ + Composite.move = function(compositeA, objects, compositeB) { + Composite.remove(compositeA, objects); + Composite.add(compositeB, objects); + return compositeA; + }; + + /** + * Assigns new ids for all objects in the composite, recursively. + * @method rebase + * @param {composite} composite + * @return {composite} Returns composite + */ + Composite.rebase = function(composite) { + var objects = Composite.allBodies(composite) + .concat(Composite.allConstraints(composite)) + .concat(Composite.allComposites(composite)); + + for (var i = 0; i < objects.length; i++) { + objects[i].id = Common.nextId(); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Translates all children in the composite by a given vector relative to their current positions, + * without imparting any velocity. + * @method translate + * @param {composite} composite + * @param {vector} translation + * @param {bool} [recursive=true] + */ + Composite.translate = function(composite, translation, recursive) { + var bodies = recursive ? Composite.allBodies(composite) : composite.bodies; + + for (var i = 0; i < bodies.length; i++) { + Body.translate(bodies[i], translation); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Rotates all children in the composite by a given angle about the given point, without imparting any angular velocity. + * @method rotate + * @param {composite} composite + * @param {number} rotation + * @param {vector} point + * @param {bool} [recursive=true] + */ + Composite.rotate = function(composite, rotation, point, recursive) { + var cos = Math.cos(rotation), + sin = Math.sin(rotation), + bodies = recursive ? Composite.allBodies(composite) : composite.bodies; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + dx = body.position.x - point.x, + dy = body.position.y - point.y; + + Body.setPosition(body, { + x: point.x + (dx * cos - dy * sin), + y: point.y + (dx * sin + dy * cos) + }); + + Body.rotate(body, rotation); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Scales all children in the composite, including updating physical properties (mass, area, axes, inertia), from a world-space point. + * @method scale + * @param {composite} composite + * @param {number} scaleX + * @param {number} scaleY + * @param {vector} point + * @param {bool} [recursive=true] + */ + Composite.scale = function(composite, scaleX, scaleY, point, recursive) { + var bodies = recursive ? Composite.allBodies(composite) : composite.bodies; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + dx = body.position.x - point.x, + dy = body.position.y - point.y; + + Body.setPosition(body, { + x: point.x + dx * scaleX, + y: point.y + dy * scaleY + }); + + Body.scale(body, scaleX, scaleY); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Returns the union of the bounds of all of the composite's bodies. + * @method bounds + * @param {composite} composite The composite. + * @returns {bounds} The composite bounds. + */ + Composite.bounds = function(composite) { + var bodies = Composite.allBodies(composite), + vertices = []; + + for (var i = 0; i < bodies.length; i += 1) { + var body = bodies[i]; + vertices.push(body.bounds.min, body.bounds.max); + } + + return Bounds.create(vertices); + }; + + /* + * + * Events Documentation + * + */ + + /** + * Fired when a call to `Composite.add` is made, before objects have been added. + * + * @event beforeAdd + * @param {} event An event object + * @param {} event.object The object(s) to be added (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a call to `Composite.add` is made, after objects have been added. + * + * @event afterAdd + * @param {} event An event object + * @param {} event.object The object(s) that have been added (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a call to `Composite.remove` is made, before objects have been removed. + * + * @event beforeRemove + * @param {} event An event object + * @param {} event.object The object(s) to be removed (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a call to `Composite.remove` is made, after objects have been removed. + * + * @event afterRemove + * @param {} event An event object + * @param {} event.object The object(s) that have been removed (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. + * + * @property id + * @type number + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "composite" + * @readOnly + */ + + /** + * An arbitrary `String` name to help the user identify and manage composites. + * + * @property label + * @type string + * @default "Composite" + */ + + /** + * A flag that specifies whether the composite has been modified during the current step. + * Most `Matter.Composite` methods will automatically set this flag to `true` to inform the engine of changes to be handled. + * If you need to change it manually, you should use the `Composite.setModified` method. + * + * @property isModified + * @type boolean + * @default false + */ + + /** + * The `Composite` that is the parent of this composite. It is automatically managed by the `Matter.Composite` methods. + * + * @property parent + * @type composite + * @default null + */ + + /** + * An array of `Body` that are _direct_ children of this composite. + * To add or remove bodies you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. + * If you wish to recursively find all descendants, you should use the `Composite.allBodies` method. + * + * @property bodies + * @type body[] + * @default [] + */ + + /** + * An array of `Constraint` that are _direct_ children of this composite. + * To add or remove constraints you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. + * If you wish to recursively find all descendants, you should use the `Composite.allConstraints` method. + * + * @property constraints + * @type constraint[] + * @default [] + */ + + /** + * An array of `Composite` that are _direct_ children of this composite. + * To add or remove composites you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. + * If you wish to recursively find all descendants, you should use the `Composite.allComposites` method. + * + * @property composites + * @type composite[] + * @default [] + */ + + /** + * An object reserved for storing plugin-specific properties. + * + * @property plugin + * @type {} + */ + +})(); + + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after + * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont. + * + * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. + * + * @class MultiFile + * @memberof Phaser.Loader + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. + * @param {string} type - The file type string for sorting within the Loader. + * @param {string} key - The key of the file within the loader. + * @param {Phaser.Loader.File[]} files - An array of Files that make-up this MultiFile. + */ +var MultiFile = new Class({ + + initialize: + + function MultiFile (loader, type, key, files) + { + /** + * A reference to the Loader that is going to load this file. + * + * @name Phaser.Loader.MultiFile#loader + * @type {Phaser.Loader.LoaderPlugin} + * @since 3.7.0 + */ + this.loader = loader; + + /** + * The file type string for sorting within the Loader. + * + * @name Phaser.Loader.MultiFile#type + * @type {string} + * @since 3.7.0 + */ + this.type = type; + + /** + * Unique cache key (unique within its file type) + * + * @name Phaser.Loader.MultiFile#key + * @type {string} + * @since 3.7.0 + */ + this.key = key; + + /** + * Array of files that make up this MultiFile. + * + * @name Phaser.Loader.MultiFile#files + * @type {Phaser.Loader.File[]} + * @since 3.7.0 + */ + this.files = files; + + /** + * The completion status of this MultiFile. + * + * @name Phaser.Loader.MultiFile#complete + * @type {boolean} + * @default false + * @since 3.7.0 + */ + this.complete = false; + + /** + * The number of files to load. + * + * @name Phaser.Loader.MultiFile#pending + * @type {integer} + * @since 3.7.0 + */ + + this.pending = files.length; + + /** + * The number of files that failed to load. + * + * @name Phaser.Loader.MultiFile#failed + * @type {integer} + * @default 0 + * @since 3.7.0 + */ + this.failed = 0; + + /** + * A storage container for transient data that the loading files need. + * + * @name Phaser.Loader.MultiFile#config + * @type {any} + * @since 3.7.0 + */ + this.config = {}; + + // Link the files + for (var i = 0; i < files.length; i++) + { + files[i].multiFile = this; + } + }, + + /** + * Checks if this MultiFile is ready to process its children or not. + * + * @method Phaser.Loader.MultiFile#isReadyToProcess + * @since 3.7.0 + * + * @return {boolean} `true` if all children of this MultiFile have loaded, otherwise `false`. + */ + isReadyToProcess: function () + { + return (this.pending === 0 && this.failed === 0 && !this.complete); + }, + + /** + * Adds another child to this MultiFile, increases the pending count and resets the completion status. + * + * @method Phaser.Loader.MultiFile#addToMultiFile + * @since 3.7.0 + * + * @param {Phaser.Loader.File} files - The File to add to this MultiFile. + * + * @return {Phaser.Loader.MultiFile} This MultiFile instance. + */ + addToMultiFile: function (file) + { + this.files.push(file); + + file.multiFile = this; + + this.pending++; + + this.complete = false; + + return this; + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.MultiFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + } + }, + + /** + * Called by each File that fails to load. + * + * @method Phaser.Loader.MultiFile#onFileFailed + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has failed to load. + */ + onFileFailed: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.failed++; + } + } + +}); + +module.exports = MultiFile; + + +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.ImageFrameConfig + * + * @property {integer} frameWidth - The width of the frame in pixels. + * @property {integer} [frameHeight] - The height of the frame in pixels. Uses the `frameWidth` value if not provided. + * @property {integer} [startFrame=0] - The first frame to start parsing from. + * @property {integer} [endFrame] - The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions. + * @property {integer} [margin=0] - The margin in the image. This is the space around the edge of the frames. + * @property {integer} [spacing=0] - The spacing between each frame in the image. + */ + +/** + * @typedef {object} Phaser.Loader.FileTypes.ImageFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='png'] - The default file extension to use if no url is provided. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image. + * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Image File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. + * + * @class ImageFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. + */ +var ImageFile = new Class({ + + Extends: File, + + initialize: + + function ImageFile (loader, key, url, xhrSettings, frameConfig) + { + var extension = 'png'; + var normalMapURL; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + normalMapURL = GetFastValue(config, 'normalMap'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + frameConfig = GetFastValue(config, 'frameConfig'); + } + + if (Array.isArray(url)) + { + normalMapURL = url[1]; + url = url[0]; + } + + var fileConfig = { + type: 'image', + cache: loader.textureManager, + extension: extension, + responseType: 'blob', + key: key, + url: url, + xhrSettings: xhrSettings, + config: frameConfig + }; + + File.call(this, loader, fileConfig); + + // Do we have a normal map to load as well? + if (normalMapURL) + { + var normalMap = new ImageFile(loader, this.key, normalMapURL, xhrSettings, frameConfig); + + normalMap.type = 'normalMap'; + + this.setLink(normalMap); + + loader.addFile(normalMap); + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.ImageFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var _this = this; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessError(); + }; + + File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.ImageFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture; + var linkFile = this.linkFile; + + if (linkFile && linkFile.state === CONST.FILE_COMPLETE) + { + if (this.type === 'image') + { + texture = this.cache.addImage(this.key, this.data, linkFile.data); + } + else + { + texture = this.cache.addImage(linkFile.key, linkFile.data, this.data); + } + + this.pendingDestroy(texture); + + linkFile.pendingDestroy(texture); + } + else if (!linkFile) + { + texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + } + +}); + +/** + * Adds an Image, or array of Images, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.image('logo', 'images/phaserLogo.png'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback + * of animated gifs to Canvas elements. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.image({ + * key: 'logo', + * url: 'images/AtariLogo.png' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.image('logo', 'images/AtariLogo.png'); + * // and later in your game ... + * this.add.image(x, y, 'logo'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.image({ + * key: 'logo', + * url: 'images/AtariLogo.png', + * normalMap: 'images/AtariLogo-n.png' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#image + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('image', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ImageFile(this, key[i])); + } + } + else + { + this.addFile(new ImageFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = ImageFile; + + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(76); +var GetPoint = __webpack_require__(306); +var GetPoints = __webpack_require__(305); +var Line = __webpack_require__(60); +var Random = __webpack_require__(202); + +/** + * @classdesc + * A triangle is a plane created by connecting three points. + * The first two arguments specify the first point, the middle two arguments + * specify the second point, and the last two arguments specify the third point. + * + * @class Triangle + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. + */ +var Triangle = new Class({ + + initialize: + + function Triangle (x1, y1, x2, y2, x3, y3) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 0; } + if (y3 === undefined) { y3 = 0; } + + /** + * `x` coordinate of the first point. + * + * @name Phaser.Geom.Triangle#x1 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x1 = x1; + + /** + * `y` coordinate of the first point. + * + * @name Phaser.Geom.Triangle#y1 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y1 = y1; + + /** + * `x` coordinate of the second point. + * + * @name Phaser.Geom.Triangle#x2 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * `y` coordinate of the second point. + * + * @name Phaser.Geom.Triangle#y2 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y2 = y2; + + /** + * `x` coordinate of the third point. + * + * @name Phaser.Geom.Triangle#x3 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x3 = x3; + + /** + * `y` coordinate of the third point. + * + * @name Phaser.Geom.Triangle#y3 + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y3 = y3; + }, + + /** + * Checks whether a given points lies within the triangle. + * + * @method Phaser.Geom.Triangle#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point to check. + * @param {number} y - The y coordinate of the point to check. + * + * @return {boolean} `true` if the coordinate pair is within the triangle, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a specific point on the triangle. + * + * @method Phaser.Geom.Triangle#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {number} position - Position as float within `0` and `1`. `0` equals the first point. + * @param {(Phaser.Geom.Point|object)} [output] - Optional Point, or point-like object, that the calculated point will be written to. + * + * @return {(Phaser.Geom.Point|object)} Calculated `Point` that represents the requested position. It is the same as `output` when this parameter has been given. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (`quantity`) or the distance between two points (`stepRate`). + * + * @method Phaser.Geom.Triangle#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [output,$return] + * + * @param {integer} quantity - Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. + * @param {number} [stepRate] - Distance between two points. Will only be used when `quantity` is falsey. + * @param {(array|Phaser.Geom.Point[])} [output] - Optional Array for writing the calculated points into. Otherwise a new array will be created. + * + * @return {(array|Phaser.Geom.Point[])} Returns a list of calculated `Point` instances or the filled array passed as parameter `output`. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a random point along the triangle. + * + * @method Phaser.Geom.Triangle#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} [point] - Optional `Point` that should be modified. Otherwise a new one will be created. + * + * @return {Phaser.Geom.Point} Random `Point`. When parameter `point` has been provided it will be returned. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. + * + * @method Phaser.Geom.Triangle#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. + * + * @return {Phaser.Geom.Triangle} This Triangle object. + */ + setTo: function (x1, y1, x2, y2, x3, y3) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 0; } + if (y3 === undefined) { y3 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + this.x3 = x3; + this.y3 = y3; + + return this; + }, + + /** + * Returns a Line object that corresponds to Line A of this Triangle. + * + * @method Phaser.Geom.Triangle#getLineA + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line A of this Triangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x1, this.y1, this.x2, this.y2); + + return line; + }, + + /** + * Returns a Line object that corresponds to Line B of this Triangle. + * + * @method Phaser.Geom.Triangle#getLineB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line B of this Triangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x2, this.y2, this.x3, this.y3); + + return line; + }, + + /** + * Returns a Line object that corresponds to Line C of this Triangle. + * + * @method Phaser.Geom.Triangle#getLineC + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to line C of this Triangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x3, this.y3, this.x1, this.y1); + + return line; + }, + + /** + * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + * + * @name Phaser.Geom.Triangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return Math.min(this.x1, this.x2, this.x3); + }, + + set: function (value) + { + var diff = 0; + + if (this.x1 <= this.x2 && this.x1 <= this.x3) + { + diff = this.x1 - value; + } + else if (this.x2 <= this.x1 && this.x2 <= this.x3) + { + diff = this.x2 - value; + } + else + { + diff = this.x3 - value; + } + + this.x1 -= diff; + this.x2 -= diff; + this.x3 -= diff; + } + + }, + + /** + * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. + * + * @name Phaser.Geom.Triangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return Math.max(this.x1, this.x2, this.x3); + }, + + set: function (value) + { + var diff = 0; + + if (this.x1 >= this.x2 && this.x1 >= this.x3) + { + diff = this.x1 - value; + } + else if (this.x2 >= this.x1 && this.x2 >= this.x3) + { + diff = this.x2 - value; + } + else + { + diff = this.x3 - value; + } + + this.x1 -= diff; + this.x2 -= diff; + this.x3 -= diff; + } + + }, + + /** + * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + * + * @name Phaser.Geom.Triangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return Math.min(this.y1, this.y2, this.y3); + }, + + set: function (value) + { + var diff = 0; + + if (this.y1 <= this.y2 && this.y1 <= this.y3) + { + diff = this.y1 - value; + } + else if (this.y2 <= this.y1 && this.y2 <= this.y3) + { + diff = this.y2 - value; + } + else + { + diff = this.y3 - value; + } + + this.y1 -= diff; + this.y2 -= diff; + this.y3 -= diff; + } + + }, + + /** + * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. + * + * @name Phaser.Geom.Triangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return Math.max(this.y1, this.y2, this.y3); + }, + + set: function (value) + { + var diff = 0; + + if (this.y1 >= this.y2 && this.y1 >= this.y3) + { + diff = this.y1 - value; + } + else if (this.y2 >= this.y1 && this.y2 >= this.y3) + { + diff = this.y2 - value; + } + else + { + diff = this.y3 - value; + } + + this.y1 -= diff; + this.y2 -= diff; + this.y3 -= diff; + } + + } + +}); + +module.exports = Triangle; + + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders a stroke outline around the given Shape. + * + * @method Phaser.GameObjects.Shape#StrokePathWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The WebGL Pipeline used to render this Shape. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. + */ +var StrokePathWebGL = function (pipeline, src, alpha, dx, dy) +{ + var strokeTint = pipeline.strokeTint; + var strokeTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.strokeColor, src.strokeAlpha * alpha); + + strokeTint.TL = strokeTintColor; + strokeTint.TR = strokeTintColor; + strokeTint.BL = strokeTintColor; + strokeTint.BR = strokeTintColor; + + var path = src.pathData; + var pathLength = path.length - 1; + var lineWidth = src.lineWidth; + var halfLineWidth = lineWidth / 2; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + pipeline.setTexture2D(); + + pipeline.batchLine( + px1, + py1, + px2, + py2, + halfLineWidth, + halfLineWidth, + lineWidth, + i - 2, + (src.closePath) ? (i === pathLength - 1) : false + ); + + px1 = px2; + py1 = py2; + } +}; + +module.exports = StrokePathWebGL; + + +/***/ }), +/* 68 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Tests if the start and end indexes are a safe range for the given array. + * + * @function Phaser.Utils.Array.SafeRange + * @since 3.4.0 + * + * @param {array} array - The array to check. + * @param {integer} startIndex - The start index. + * @param {integer} endIndex - The end index. + * @param {boolean} [throwError=true] - Throw an error if the range is out of bounds. + * + * @return {boolean} True if the range is safe, otherwise false. + */ +var SafeRange = function (array, startIndex, endIndex, throwError) +{ + var len = array.length; + + if (startIndex < 0 || + startIndex > len || + startIndex >= endIndex || + endIndex > len || + startIndex + endIndex > len) + { + if (throwError) + { + throw new Error('Range Error: Values outside acceptable range'); + } + + return false; + } + else + { + return true; + } +}; + +module.exports = SafeRange; + + +/***/ }), +/* 69 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Shallow Object Clone. Will not clone nested objects. + * + * @function Phaser.Utils.Objects.Clone + * @since 3.0.0 + * + * @param {object} obj - the object from which to clone + * + * @return {object} a new object with the same properties as the input obj + */ +var Clone = function (obj) +{ + var clone = {}; + + for (var key in obj) + { + if (Array.isArray(obj[key])) + { + clone[key] = obj[key].slice(0); + } + else + { + clone[key] = obj[key]; + } + } + + return clone; +}; + +module.exports = Clone; + + +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// 2.1.1 (Mar 17, 2016) + +/* +ISC License + +Copyright (c) 2016, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + */ + + + +module.exports = earcut; + +/* +vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. +holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). +dimensions is the number of coordinates per vertice in the input array (2 by default). +Each group of three vertice indices in the resulting array forms a triangle. + */ + +function earcut(data, holeIndices, dim) { + + dim = dim || 2; + + var hasHoles = holeIndices && holeIndices.length, + outerLen = hasHoles ? holeIndices[0] * dim : data.length, + outerNode = linkedList(data, 0, outerLen, dim, true), + triangles = []; + + if (!outerNode) return triangles; + + var minX, minY, maxX, maxY, x, y, size; + + if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); + + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; + + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + } + + // minX, minY and size are later used to transform coords into integers for z-order calculation + size = Math.max(maxX - minX, maxY - minY); + } + + earcutLinked(outerNode, triangles, dim, minX, minY, size); + + return triangles; +} + +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList(data, start, end, dim, clockwise) { + var i, last; + + if (clockwise === (signedArea(data, start, end, dim) > 0)) { + for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); + } else { + for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); + } + + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + + return last; +} + +// eliminate colinear or duplicate points +function filterPoints(start, end) { + if (!start) return start; + if (!end) end = start; + + var p = start, + again; + do { + again = false; + + if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { + removeNode(p); + p = end = p.prev; + if (p === p.next) return null; + again = true; + + } else { + p = p.next; + } + } while (again || p !== end); + + return end; +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { + if (!ear) return; + + // interlink polygon nodes in z-order + if (!pass && size) indexCurve(ear, minX, minY, size); + + var stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { + // cut off the triangle + triangles.push(prev.i / dim); + triangles.push(ear.i / dim); + triangles.push(next.i / dim); + + removeNode(ear); + + // skipping the next vertice leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(ear, triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, size, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(ear, triangles, dim, minX, minY, size); + } + + break; + } + } +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar(ear) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + var p = ear.next.next; + + while (p !== ear.prev) { + if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.next; + } + + return true; +} + +function isEarHashed(ear, minX, minY, size) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // triangle bbox; min & max are calculated like this for speed + var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), + minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), + maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), + maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); + + // z-order range for the current triangle bbox; + var minZ = zOrder(minTX, minTY, minX, minY, size), + maxZ = zOrder(maxTX, maxTY, minX, minY, size); + + // first look for points inside the triangle in increasing z-order + var p = ear.nextZ; + + while (p && p.z <= maxZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.nextZ; + } + + // then look for points in decreasing z-order + p = ear.prevZ; + + while (p && p.z >= minZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + } + + return true; +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections(start, triangles, dim) { + var p = start; + do { + var a = p.prev, + b = p.next.next; + + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + + triangles.push(a.i / dim); + triangles.push(p.i / dim); + triangles.push(b.i / dim); + + // remove two nodes involved + removeNode(p); + removeNode(p.next); + + p = start = b; + } + p = p.next; + } while (p !== start); + + return p; +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut(start, triangles, dim, minX, minY, size) { + // look for a valid diagonal that divides the polygon into two + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + // split the polygon in two by the diagonal + var c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + + // run earcut on each half + earcutLinked(a, triangles, dim, minX, minY, size); + earcutLinked(c, triangles, dim, minX, minY, size); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], + i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) list.steiner = true; + queue.push(getLeftmost(list)); + } + + queue.sort(compareX); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + eliminateHole(queue[i], outerNode); + outerNode = filterPoints(outerNode, outerNode.next); + } + + return outerNode; +} + +function compareX(a, b) { + return a.x - b.x; +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole(hole, outerNode) { + outerNode = findHoleBridge(hole, outerNode); + if (outerNode) { + var b = splitPolygon(outerNode, hole); + filterPoints(b, b.next); + } +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge(hole, outerNode) { + var p = outerNode, + hx = hole.x, + hy = hole.y, + qx = -Infinity, + m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { + var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + if (x === hx) { + if (hy === p.y) return p; + if (hy === p.next.y) return p.next; + } + m = p.x < p.next.x ? p : p.next; + } + } + p = p.next; + } while (p !== outerNode); + + if (!m) return null; + + if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + var stop = m, + mx = m.x, + my = m.y, + tanMin = Infinity, + tan; + + p = m.next; + + while (p !== stop) { + if (hx >= p.x && p.x >= mx && hx !== p.x && + pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + + tan = Math.abs(hy - p.y) / (hx - p.x); // tangential + + if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { + m = p; + tanMin = tan; + } + } + + p = p.next; + } + + return m; +} + +// interlink polygon nodes in z-order +function indexCurve(start, minX, minY, size) { + var p = start; + do { + if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked(p); +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + + if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + + } while (numMerges > 1); + + return list; +} + +// z-order of a point given coords and size of the data bounding box +function zOrder(x, y, minX, minY, size) { + // coords are transformed into non-negative 15-bit integer range + x = 32767 * (x - minX) / size; + y = 32767 * (y - minY) / size; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); +} + +// find the leftmost node of a polygon ring +function getLeftmost(start) { + var p = start, + leftmost = start; + do { + if (p.x < leftmost.x) leftmost = p; + p = p.next; + } while (p !== start); + + return leftmost; +} + +// check if a point lies within a convex triangle +function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && + (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && + (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal(a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && + locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); +} + +// signed area of a triangle +function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); +} + +// check if two points are equal +function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; +} + +// check if two segments intersect +function intersects(p1, q1, p2, q2) { + if ((equals(p1, q1) && equals(p2, q2)) || + (equals(p1, q2) && equals(p2, q1))) return true; + return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && + area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon(a, b) { + var p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && + intersects(p, p.next, a, b)) return true; + p = p.next; + } while (p !== a); + + return false; +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? + area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : + area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside(a, b) { + var p = a, + inside = false, + px = (a.x + b.x) / 2, + py = (a.y + b.y) / 2; + do { + if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && + (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) + inside = !inside; + p = p.next; + } while (p !== a); + + return inside; +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon(a, b) { + var a2 = new Node(a.i, a.x, a.y), + b2 = new Node(b.i, b.x, b.y), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode(i, x, y, last) { + var p = new Node(i, x, y); + + if (!last) { + p.prev = p; + p.next = p; + + } else { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } + return p; +} + +function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + + if (p.prevZ) p.prevZ.nextZ = p.nextZ; + if (p.nextZ) p.nextZ.prevZ = p.prevZ; +} + +function Node(i, x, y) { + // vertice index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertice nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = null; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; +} + +// return a percentage difference between the polygon area and its triangulation area; +// used to verify correctness of triangulation +earcut.deviation = function (data, holeIndices, dim, triangles) { + var hasHoles = holeIndices && holeIndices.length; + var outerLen = hasHoles ? holeIndices[0] * dim : data.length; + + var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); + if (hasHoles) { + for (var i = 0, len = holeIndices.length; i < len; i++) { + var start = holeIndices[i] * dim; + var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + polygonArea -= Math.abs(signedArea(data, start, end, dim)); + } + } + + var trianglesArea = 0; + for (i = 0; i < triangles.length; i += 3) { + var a = triangles[i] * dim; + var b = triangles[i + 1] * dim; + var c = triangles[i + 2] * dim; + trianglesArea += Math.abs( + (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - + (data[a] - data[b]) * (data[c + 1] - data[a + 1])); + } + + return polygonArea === 0 && trianglesArea === 0 ? 0 : + Math.abs((trianglesArea - polygonArea) / polygonArea); +}; + +function signedArea(data, start, end, dim) { + var sum = 0; + for (var i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + return sum; +} + +// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts +earcut.flatten = function (data) { + var dim = data[0][0].length, + result = {vertices: [], holes: [], dimensions: dim}, + holeIndex = 0; + + for (var i = 0; i < data.length; i++) { + for (var j = 0; j < data[i].length; j++) { + for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); + } + if (i > 0) { + holeIndex += data[i - 1].length; + result.holes.push(holeIndex); + } + } + return result; +}; + +/***/ }), +/* 71 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the length of the given line. + * + * @function Phaser.Geom.Line.Length + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the length of. + * + * @return {number} The length of the line. + */ +var Length = function (line) +{ + return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); +}; + +module.exports = Length; + + +/***/ }), +/* 72 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser Blend Modes. + * + * @name Phaser.BlendModes + * @enum {integer} + * @memberof Phaser + * @readonly + * @since 3.0.0 + */ + +module.exports = { + + /** + * Skips the Blend Mode check in the renderer. + * + * @name Phaser.BlendModes.SKIP_CHECK + */ + SKIP_CHECK: -1, + + /** + * Normal blend mode. + * + * @name Phaser.BlendModes.NORMAL + */ + NORMAL: 0, + + /** + * Add blend mode. + * + * @name Phaser.BlendModes.ADD + */ + ADD: 1, + + /** + * Multiply blend mode. + * + * @name Phaser.BlendModes.MULTIPLY + */ + MULTIPLY: 2, + + /** + * Screen blend mode. + * + * @name Phaser.BlendModes.SCREEN + */ + SCREEN: 3, + + /** + * Overlay blend mode. + * + * @name Phaser.BlendModes.OVERLAY + */ + OVERLAY: 4, + + /** + * Darken blend mode. + * + * @name Phaser.BlendModes.DARKEN + */ + DARKEN: 5, + + /** + * Lighten blend mode. + * + * @name Phaser.BlendModes.LIGHTEN + */ + LIGHTEN: 6, + + /** + * Color Dodge blend mode. + * + * @name Phaser.BlendModes.COLOR_DODGE + */ + COLOR_DODGE: 7, + + /** + * Color Burn blend mode. + * + * @name Phaser.BlendModes.COLOR_BURN + */ + COLOR_BURN: 8, + + /** + * Hard Light blend mode. + * + * @name Phaser.BlendModes.HARD_LIGHT + */ + HARD_LIGHT: 9, + + /** + * Soft Light blend mode. + * + * @name Phaser.BlendModes.SOFT_LIGHT + */ + SOFT_LIGHT: 10, + + /** + * Difference blend mode. + * + * @name Phaser.BlendModes.DIFFERENCE + */ + DIFFERENCE: 11, + + /** + * Exclusion blend mode. + * + * @name Phaser.BlendModes.EXCLUSION + */ + EXCLUSION: 12, + + /** + * Hue blend mode. + * + * @name Phaser.BlendModes.HUE + */ + HUE: 13, + + /** + * Saturation blend mode. + * + * @name Phaser.BlendModes.SATURATION + */ + SATURATION: 14, + + /** + * Color blend mode. + * + * @name Phaser.BlendModes.COLOR + */ + COLOR: 15, + + /** + * Luminosity blend mode. + * + * @name Phaser.BlendModes.LUMINOSITY + */ + LUMINOSITY: 16 + +}; + + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Constraint` module contains methods for creating and manipulating constraints. +* Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). +* The stiffness of constraints can be modified to create springs or elastic. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Constraint +*/ + +var Constraint = {}; + +module.exports = Constraint; + +var Vertices = __webpack_require__(29); +var Vector = __webpack_require__(34); +var Sleeping = __webpack_require__(89); +var Bounds = __webpack_require__(33); +var Axes = __webpack_require__(152); +var Common = __webpack_require__(12); + +(function() { + + Constraint._warming = 0.4; + Constraint._torqueDampen = 1; + Constraint._minLength = 0.000001; + + /** + * Creates a new constraint. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * To simulate a revolute constraint (or pin joint) set `length: 0` and a high `stiffness` value (e.g. `0.7` or above). + * If the constraint is unstable, try lowering the `stiffness` value and / or increasing `engine.constraintIterations`. + * For compound bodies, constraints must be applied to the parent body (not one of its parts). + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {} options + * @return {constraint} constraint + */ + Constraint.create = function(options) { + var constraint = options; + + // if bodies defined but no points, use body centre + if (constraint.bodyA && !constraint.pointA) + constraint.pointA = { x: 0, y: 0 }; + if (constraint.bodyB && !constraint.pointB) + constraint.pointB = { x: 0, y: 0 }; + + // calculate static length using initial world space points + var initialPointA = constraint.bodyA ? Vector.add(constraint.bodyA.position, constraint.pointA) : constraint.pointA, + initialPointB = constraint.bodyB ? Vector.add(constraint.bodyB.position, constraint.pointB) : constraint.pointB, + length = Vector.magnitude(Vector.sub(initialPointA, initialPointB)); + + constraint.length = typeof constraint.length !== 'undefined' ? constraint.length : length; + + // option defaults + constraint.id = constraint.id || Common.nextId(); + constraint.label = constraint.label || 'Constraint'; + constraint.type = 'constraint'; + constraint.stiffness = constraint.stiffness || (constraint.length > 0 ? 1 : 0.7); + constraint.damping = constraint.damping || 0; + constraint.angularStiffness = constraint.angularStiffness || 0; + constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA; + constraint.angleB = constraint.bodyB ? constraint.bodyB.angle : constraint.angleB; + constraint.plugin = {}; + + // render + var render = { + visible: true, + lineWidth: 2, + strokeStyle: '#ffffff', + type: 'line', + anchors: true + }; + + if (constraint.length === 0 && constraint.stiffness > 0.1) { + render.type = 'pin'; + render.anchors = false; + } else if (constraint.stiffness < 0.9) { + render.type = 'spring'; + } + + constraint.render = Common.extend(render, constraint.render); + + return constraint; + }; + + /** + * Prepares for solving by constraint warming. + * @private + * @method preSolveAll + * @param {body[]} bodies + */ + Constraint.preSolveAll = function(bodies) { + for (var i = 0; i < bodies.length; i += 1) { + var body = bodies[i], + impulse = body.constraintImpulse; + + if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { + continue; + } + + body.position.x += impulse.x; + body.position.y += impulse.y; + body.angle += impulse.angle; + } + }; + + /** + * Solves all constraints in a list of collisions. + * @private + * @method solveAll + * @param {constraint[]} constraints + * @param {number} timeScale + */ + Constraint.solveAll = function(constraints, timeScale) { + // Solve fixed constraints first. + for (var i = 0; i < constraints.length; i += 1) { + var constraint = constraints[i], + fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic), + fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); + + if (fixedA || fixedB) { + Constraint.solve(constraints[i], timeScale); + } + } + + // Solve free constraints last. + for (i = 0; i < constraints.length; i += 1) { + constraint = constraints[i]; + fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic); + fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); + + if (!fixedA && !fixedB) { + Constraint.solve(constraints[i], timeScale); + } + } + }; + + /** + * Solves a distance constraint with Gauss-Siedel method. + * @private + * @method solve + * @param {constraint} constraint + * @param {number} timeScale + */ + Constraint.solve = function(constraint, timeScale) { + var bodyA = constraint.bodyA, + bodyB = constraint.bodyB, + pointA = constraint.pointA, + pointB = constraint.pointB; + + if (!bodyA && !bodyB) + return; + + // update reference angle + if (bodyA && !bodyA.isStatic) { + Vector.rotate(pointA, bodyA.angle - constraint.angleA, pointA); + constraint.angleA = bodyA.angle; + } + + // update reference angle + if (bodyB && !bodyB.isStatic) { + Vector.rotate(pointB, bodyB.angle - constraint.angleB, pointB); + constraint.angleB = bodyB.angle; + } + + var pointAWorld = pointA, + pointBWorld = pointB; + + if (bodyA) pointAWorld = Vector.add(bodyA.position, pointA); + if (bodyB) pointBWorld = Vector.add(bodyB.position, pointB); + + if (!pointAWorld || !pointBWorld) + return; + + var delta = Vector.sub(pointAWorld, pointBWorld), + currentLength = Vector.magnitude(delta); + + // prevent singularity + if (currentLength < Constraint._minLength) { + currentLength = Constraint._minLength; + } + + // solve distance constraint with Gauss-Siedel method + var difference = (currentLength - constraint.length) / currentLength, + stiffness = constraint.stiffness < 1 ? constraint.stiffness * timeScale : constraint.stiffness, + force = Vector.mult(delta, difference * stiffness), + massTotal = (bodyA ? bodyA.inverseMass : 0) + (bodyB ? bodyB.inverseMass : 0), + inertiaTotal = (bodyA ? bodyA.inverseInertia : 0) + (bodyB ? bodyB.inverseInertia : 0), + resistanceTotal = massTotal + inertiaTotal, + torque, + share, + normal, + normalVelocity, + relativeVelocity; + + if (constraint.damping) { + var zero = Vector.create(); + normal = Vector.div(delta, currentLength); + + relativeVelocity = Vector.sub( + bodyB && Vector.sub(bodyB.position, bodyB.positionPrev) || zero, + bodyA && Vector.sub(bodyA.position, bodyA.positionPrev) || zero + ); + + normalVelocity = Vector.dot(normal, relativeVelocity); + } + + if (bodyA && !bodyA.isStatic) { + share = bodyA.inverseMass / massTotal; + + // keep track of applied impulses for post solving + bodyA.constraintImpulse.x -= force.x * share; + bodyA.constraintImpulse.y -= force.y * share; + + // apply forces + bodyA.position.x -= force.x * share; + bodyA.position.y -= force.y * share; + + // apply damping + if (constraint.damping) { + bodyA.positionPrev.x -= constraint.damping * normal.x * normalVelocity * share; + bodyA.positionPrev.y -= constraint.damping * normal.y * normalVelocity * share; + } + + // apply torque + torque = (Vector.cross(pointA, force) / resistanceTotal) * Constraint._torqueDampen * bodyA.inverseInertia * (1 - constraint.angularStiffness); + bodyA.constraintImpulse.angle -= torque; + bodyA.angle -= torque; + } + + if (bodyB && !bodyB.isStatic) { + share = bodyB.inverseMass / massTotal; + + // keep track of applied impulses for post solving + bodyB.constraintImpulse.x += force.x * share; + bodyB.constraintImpulse.y += force.y * share; + + // apply forces + bodyB.position.x += force.x * share; + bodyB.position.y += force.y * share; + + // apply damping + if (constraint.damping) { + bodyB.positionPrev.x += constraint.damping * normal.x * normalVelocity * share; + bodyB.positionPrev.y += constraint.damping * normal.y * normalVelocity * share; + } + + // apply torque + torque = (Vector.cross(pointB, force) / resistanceTotal) * Constraint._torqueDampen * bodyB.inverseInertia * (1 - constraint.angularStiffness); + bodyB.constraintImpulse.angle += torque; + bodyB.angle += torque; + } + + }; + + /** + * Performs body updates required after solving constraints. + * @private + * @method postSolveAll + * @param {body[]} bodies + */ + Constraint.postSolveAll = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + impulse = body.constraintImpulse; + + if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { + continue; + } + + Sleeping.set(body, false); + + // update geometry and reset + for (var j = 0; j < body.parts.length; j++) { + var part = body.parts[j]; + + Vertices.translate(part.vertices, impulse); + + if (j > 0) { + part.position.x += impulse.x; + part.position.y += impulse.y; + } + + if (impulse.angle !== 0) { + Vertices.rotate(part.vertices, impulse.angle, body.position); + Axes.rotate(part.axes, impulse.angle); + if (j > 0) { + Vector.rotateAbout(part.position, impulse.angle, body.position, part.position); + } + } + + Bounds.update(part.bounds, part.vertices, body.velocity); + } + + // dampen the cached impulse for warming next step + impulse.angle *= Constraint._warming; + impulse.x *= Constraint._warming; + impulse.y *= Constraint._warming; + } + }; + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. + * + * @property id + * @type number + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "constraint" + * @readOnly + */ + + /** + * An arbitrary `String` name to help the user identify and manage bodies. + * + * @property label + * @type string + * @default "Constraint" + */ + + /** + * An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`. + * + * @property render + * @type object + */ + + /** + * A flag that indicates if the constraint should be rendered. + * + * @property render.visible + * @type boolean + * @default true + */ + + /** + * A `Number` that defines the line width to use when rendering the constraint outline. + * A value of `0` means no outline will be rendered. + * + * @property render.lineWidth + * @type number + * @default 2 + */ + + /** + * A `String` that defines the stroke style to use when rendering the constraint outline. + * It is the same as when using a canvas, so it accepts CSS style property values. + * + * @property render.strokeStyle + * @type string + * @default a random colour + */ + + /** + * A `String` that defines the constraint rendering type. + * The possible values are 'line', 'pin', 'spring'. + * An appropriate render type will be automatically chosen unless one is given in options. + * + * @property render.type + * @type string + * @default 'line' + */ + + /** + * A `Boolean` that defines if the constraint's anchor points should be rendered. + * + * @property render.anchors + * @type boolean + * @default true + */ + + /** + * The first possible `Body` that this constraint is attached to. + * + * @property bodyA + * @type body + * @default null + */ + + /** + * The second possible `Body` that this constraint is attached to. + * + * @property bodyB + * @type body + * @default null + */ + + /** + * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. + * + * @property pointA + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyB` if defined, otherwise a world-space position. + * + * @property pointB + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Number` that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. + * A value of `1` means the constraint should be very stiff. + * A value of `0.2` means the constraint acts like a soft spring. + * + * @property stiffness + * @type number + * @default 1 + */ + + /** + * A `Number` that specifies the damping of the constraint, + * i.e. the amount of resistance applied to each body based on their velocities to limit the amount of oscillation. + * Damping will only be apparent when the constraint also has a very low `stiffness`. + * A value of `0.1` means the constraint will apply heavy damping, resulting in little to no oscillation. + * A value of `0` means the constraint will apply no damping. + * + * @property damping + * @type number + * @default 0 + */ + + /** + * A `Number` that specifies the target resting length of the constraint. + * It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB`. + * + * @property length + * @type number + */ + + /** + * An object reserved for storing plugin-specific properties. + * + * @property plugin + * @type {} + */ + +})(); + + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Events` module contains methods to fire and listen to events on other objects. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Events +*/ + +var Events = {}; + +module.exports = Events; + +var Common = __webpack_require__(12); + +(function() { + + /** + * Subscribes a callback function to the given object's `eventName`. + * @method on + * @param {} object + * @param {string} eventNames + * @param {function} callback + */ + Events.on = function(object, eventNames, callback) { + var names = eventNames.split(' '), + name; + + for (var i = 0; i < names.length; i++) { + name = names[i]; + object.events = object.events || {}; + object.events[name] = object.events[name] || []; + object.events[name].push(callback); + } + + return callback; + }; + + /** + * Removes the given event callback. If no callback, clears all callbacks in `eventNames`. If no `eventNames`, clears all events. + * @method off + * @param {} object + * @param {string} eventNames + * @param {function} callback + */ + Events.off = function(object, eventNames, callback) { + if (!eventNames) { + object.events = {}; + return; + } + + // handle Events.off(object, callback) + if (typeof eventNames === 'function') { + callback = eventNames; + eventNames = Common.keys(object.events).join(' '); + } + + var names = eventNames.split(' '); + + for (var i = 0; i < names.length; i++) { + var callbacks = object.events[names[i]], + newCallbacks = []; + + if (callback && callbacks) { + for (var j = 0; j < callbacks.length; j++) { + if (callbacks[j] !== callback) + newCallbacks.push(callbacks[j]); + } + } + + object.events[names[i]] = newCallbacks; + } + }; + + /** + * Fires all the callbacks subscribed to the given object's `eventName`, in the order they subscribed, if any. + * @method trigger + * @param {} object + * @param {string} eventNames + * @param {} event + */ + Events.trigger = function(object, eventNames, event) { + var names, + name, + callbacks, + eventClone; + + var events = object.events; + + if (events && Common.keys(events).length > 0) { + if (!event) + event = {}; + + names = eventNames.split(' '); + + for (var i = 0; i < names.length; i++) { + name = names[i]; + callbacks = events[name]; + + if (callbacks) { + eventClone = Common.clone(event, false); + eventClone.name = name; + eventClone.source = object; + + for (var j = 0; j < callbacks.length; j++) { + callbacks[j].apply(object, [eventClone]); + } + } + } + } + }; + +})(); + + +/***/ }), +/* 75 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the angle of the line in radians. + * + * @function Phaser.Geom.Line.Angle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the angle of. + * + * @return {number} The angle of the line, in radians. + */ +var Angle = function (line) +{ + return Math.atan2(line.y2 - line.y1, line.x2 - line.x1); +}; + +module.exports = Angle; + + +/***/ }), +/* 76 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// http://www.blackpawn.com/texts/pointinpoly/ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ +var Contains = function (triangle, x, y) +{ + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var v2x = x - triangle.x1; + var v2y = y - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot02 = (v0x * v2x) + (v0y * v2y); + var dot11 = (v1x * v1x) + (v1y * v1y); + var dot12 = (v1x * v2x) + (v1y * v2y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + return (u >= 0 && v >= 0 && (u + v < 1)); +}; + +module.exports = Contains; + + +/***/ }), +/* 77 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Utils.Objects.HasValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * + * @return {boolean} [description] + */ +var HasValue = function (source, key) +{ + return (source.hasOwnProperty(key)); +}; + +module.exports = HasValue; + + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var GameObject = __webpack_require__(17); +var ImageRender = __webpack_require__(893); + +/** + * @classdesc + * An Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Image = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.TextureCrop, + Components.Tint, + Components.Transform, + Components.Visible, + ImageRender + ], + + initialize: + + function Image (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Image'); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Image#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initPipeline(); + } + +}); + +module.exports = Image; + + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(69); + +/** + * Creates a new Object using all values from obj1 and obj2. + * If a value exists in both obj1 and obj2, the value in obj1 is used. + * + * @function Phaser.Utils.Objects.Merge + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var Merge = function (obj1, obj2) +{ + var clone = Clone(obj1); + + for (var key in obj2) + { + if (!clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } + + return clone; +}; + +module.exports = Merge; + + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FromPoints = __webpack_require__(191); +var Rectangle = __webpack_require__(10); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Base Curve class, which all other curve types extend. + * + * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + * + * @class Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {string} type - [description] + */ +var Curve = new Class({ + + initialize: + + function Curve (type) + { + /** + * String based identifier for the type of curve. + * + * @name Phaser.Curves.Curve#type + * @type {string} + * @since 3.0.0 + */ + this.type = type; + + /** + * The default number of divisions within the curve. + * + * @name Phaser.Curves.Curve#defaultDivisions + * @type {integer} + * @default 5 + * @since 3.0.0 + */ + this.defaultDivisions = 5; + + /** + * The quantity of arc length divisions within the curve. + * + * @name Phaser.Curves.Curve#arcLengthDivisions + * @type {integer} + * @default 100 + * @since 3.0.0 + */ + this.arcLengthDivisions = 100; + + /** + * An array of cached arc length values. + * + * @name Phaser.Curves.Curve#cacheArcLengths + * @type {number[]} + * @default [] + * @since 3.0.0 + */ + this.cacheArcLengths = []; + + /** + * Does the data of this curve need updating? + * + * @name Phaser.Curves.Curve#needsUpdate + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.needsUpdate = true; + + /** + * [description] + * + * @name Phaser.Curves.Curve#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * A temporary calculation Vector. + * + * @name Phaser.Curves.Curve#_tmpVec2A + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2A = new Vector2(); + + /** + * A temporary calculation Vector. + * + * @name Phaser.Curves.Curve#_tmpVec2B + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2B = new Vector2(); + }, + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.strokePoints` so will be drawn at whatever the present Graphics stroke color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.Curve#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. + * @param {integer} [pointsTotal=32] - The resolution of the curve. The higher the value the smoother it will render, at the cost of rendering performance. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + // So you can chain graphics calls + return graphics.strokePoints(this.getPoints(pointsTotal)); + }, + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * You can control the accuracy of the bounds. The value given is used to work out how many points + * to plot across the curve. Higher values are more accurate at the cost of calculation speed. + * + * @method Phaser.Curves.Curve#getBounds + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the bounds in. If falsey a new object will be created. + * @param {integer} [accuracy=16] - The accuracy of the bounds calculations. + * + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. + */ + getBounds: function (out, accuracy) + { + if (!out) { out = new Rectangle(); } + if (accuracy === undefined) { accuracy = 16; } + + var len = this.getLength(); + + if (accuracy > len) + { + accuracy = len / 2; + } + + // The length of the curve in pixels + // So we'll have 1 spaced point per 'accuracy' pixels + + var spaced = Math.max(1, Math.round(len / accuracy)); + + return FromPoints(this.getSpacedPoints(spaced), out); + }, + + /** + * Returns an array of points, spaced out X distance pixels apart. + * The smaller the distance, the larger the array will be. + * + * @method Phaser.Curves.Curve#getDistancePoints + * @since 3.0.0 + * + * @param {integer} distance - The distance, in pixels, between each point along the curve. + * + * @return {Phaser.Geom.Point[]} An Array of Point objects. + */ + getDistancePoints: function (distance) + { + var len = this.getLength(); + + var spaced = Math.max(1, len / distance); + + return this.getSpacedPoints(spaced); + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#getEndPoint + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} [out] - Optional Vector object to store the result in. + * + * @return {Phaser.Math.Vector2} Vector2 containing the coordinates of the curves end point. + */ + getEndPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPointAt(1, out); + }, + + // Get total curve arc length + + /** + * [description] + * + * @method Phaser.Curves.Curve#getLength + * @since 3.0.0 + * + * @return {number} [description] + */ + getLength: function () + { + var lengths = this.getLengths(); + + return lengths[lengths.length - 1]; + }, + + // Get list of cumulative segment lengths + + /** + * [description] + * + * @method Phaser.Curves.Curve#getLengths + * @since 3.0.0 + * + * @param {integer} [divisions] - [description] + * + * @return {number[]} [description] + */ + getLengths: function (divisions) + { + if (divisions === undefined) { divisions = this.arcLengthDivisions; } + + if ((this.cacheArcLengths.length === divisions + 1) && !this.needsUpdate) + { + return this.cacheArcLengths; + } + + this.needsUpdate = false; + + var cache = []; + var current; + var last = this.getPoint(0, this._tmpVec2A); + var sum = 0; + + cache.push(0); + + for (var p = 1; p <= divisions; p++) + { + current = this.getPoint(p / divisions, this._tmpVec2B); + + sum += current.distance(last); + + cache.push(sum); + + last.copy(current); + } + + this.cacheArcLengths = cache; + + return cache; // { sums: cache, sum:sum }; Sum is in the last element. + }, + + // Get point at relative position in curve according to arc length + + // - u [0 .. 1] + + /** + * [description] + * + * @method Phaser.Curves.Curve#getPointAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getPointAt: function (u, out) + { + var t = this.getUtoTmapping(u); + + return this.getPoint(t, out); + }, + + // Get sequence of points using getPoint( t ) + + /** + * [description] + * + * @method Phaser.Curves.Curve#getPoints + * @since 3.0.0 + * + * @param {integer} [divisions] - [description] + * + * @return {Phaser.Math.Vector2[]} [description] + */ + getPoints: function (divisions) + { + if (divisions === undefined) { divisions = this.defaultDivisions; } + + var points = []; + + for (var d = 0; d <= divisions; d++) + { + points.push(this.getPoint(d / divisions)); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getRandomPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(Math.random(), out); + }, + + // Get sequence of points using getPointAt( u ) + + /** + * [description] + * + * @method Phaser.Curves.Curve#getSpacedPoints + * @since 3.0.0 + * + * @param {integer} [divisions] - [description] + * + * @return {Phaser.Math.Vector2[]} [description] + */ + getSpacedPoints: function (divisions) + { + if (divisions === undefined) { divisions = this.defaultDivisions; } + + var points = []; + + for (var d = 0; d <= divisions; d++) + { + var t = this.getUtoTmapping(d / divisions, null, divisions); + + points.push(this.getPoint(t)); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPointAt(0, out); + }, + + // Returns a unit vector tangent at t + // In case any sub curve does not implement its tangent derivation, + // 2 points a small delta apart will be used to find its gradient + // which seems to give a reasonable approximation + + /** + * [description] + * + * @method Phaser.Curves.Curve#getTangent + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001) + */ + getTangent: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var delta = 0.0001; + var t1 = t - delta; + var t2 = t + delta; + + // Capping in case of danger + + if (t1 < 0) + { + t1 = 0; + } + + if (t2 > 1) + { + t2 = 1; + } + + this.getPoint(t1, this._tmpVec2A); + this.getPoint(t2, out); + + return out.subtract(this._tmpVec2A).normalize(); + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#getTangentAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getTangentAt: function (u, out) + { + var t = this.getUtoTmapping(u); + + return this.getTangent(t, out); + }, + + // Given a distance in pixels, get a t to find p. + /** + * [description] + * + * @method Phaser.Curves.Curve#getTFromDistance + * @since 3.0.0 + * + * @param {integer} distance - [description] + * @param {integer} [divisions] - [description] + * + * @return {number} [description] + */ + getTFromDistance: function (distance, divisions) + { + if (distance <= 0) + { + return 0; + } + + return this.getUtoTmapping(0, distance, divisions); + }, + + // Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant + + /** + * [description] + * + * @method Phaser.Curves.Curve#getUtoTmapping + * @since 3.0.0 + * + * @param {number} u - [description] + * @param {integer} distance - [description] + * @param {integer} [divisions] - [description] + * + * @return {number} [description] + */ + getUtoTmapping: function (u, distance, divisions) + { + var arcLengths = this.getLengths(divisions); + + var i = 0; + var il = arcLengths.length; + + var targetArcLength; // The targeted u distance value to get + + if (distance) + { + // Cannot overshoot the curve + targetArcLength = Math.min(distance, arcLengths[il - 1]); + } + else + { + targetArcLength = u * arcLengths[il - 1]; + } + + // binary search for the index with largest value smaller than target u distance + + var low = 0; + var high = il - 1; + var comparison; + + while (low <= high) + { + i = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats + + comparison = arcLengths[i] - targetArcLength; + + if (comparison < 0) + { + low = i + 1; + } + else if (comparison > 0) + { + high = i - 1; + } + else + { + high = i; + break; + } + } + + i = high; + + if (arcLengths[i] === targetArcLength) + { + return i / (il - 1); + } + + // we could get finer grain at lengths, or use simple interpolation between two points + + var lengthBefore = arcLengths[i]; + var lengthAfter = arcLengths[i + 1]; + + var segmentLength = lengthAfter - lengthBefore; + + // determine where we are between the 'before' and 'after' points + + var segmentFraction = (targetArcLength - lengthBefore) / segmentLength; + + // add that fractional amount to t + + return (i + segmentFraction) / (il - 1); + }, + + /** + * [description] + * + * @method Phaser.Curves.Curve#updateArcLengths + * @since 3.0.0 + */ + updateArcLengths: function () + { + this.needsUpdate = true; + + this.getLengths(); + } + +}); + +module.exports = Curve; + + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(44); +var GetPoint = __webpack_require__(442); +var GetPoints = __webpack_require__(440); +var Random = __webpack_require__(210); + +/** + * @classdesc + * A Circle object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Circle you should look at the capabilities of the Graphics class. + * + * @class Circle + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * @param {number} [radius=0] - The radius of the circle. + */ +var Circle = new Class({ + + initialize: + + function Circle (x, y, radius) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 0; } + + /** + * The x position of the center of the circle. + * + * @name Phaser.Geom.Circle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the center of the circle. + * + * @name Phaser.Geom.Circle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The internal radius of the circle. + * + * @name Phaser.Geom.Circle#_radius + * @type {number} + * @private + * @since 3.0.0 + */ + this._radius = radius; + + /** + * The internal diameter of the circle. + * + * @name Phaser.Geom.Circle#_diameter + * @type {number} + * @private + * @since 3.0.0 + */ + this._diameter = radius * 2; + }, + + /** + * Check to see if the Circle contains the given x / y coordinates. + * + * @method Phaser.Geom.Circle#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @method Phaser.Geom.Circle#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. + */ + getPoint: function (position, point) + { + return GetPoint(this, position, point); + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Circle#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [output,$return] + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param {(array|Phaser.Geom.Point[])} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {(array|Phaser.Geom.Point[])} An array of Point objects pertaining to the points around the circumference of the circle. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a uniformly distributed random point from anywhere within the Circle. + * + * @method Phaser.Geom.Circle#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets the x, y and radius of this circle. + * + * @method Phaser.Geom.Circle#setTo + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * @param {number} [radius=0] - The radius of the circle. + * + * @return {Phaser.Geom.Circle} This Circle object. + */ + setTo: function (x, y, radius) + { + this.x = x; + this.y = y; + this._radius = radius; + this._diameter = radius * 2; + + return this; + }, + + /** + * Sets this Circle to be empty with a radius of zero. + * Does not change its position. + * + * @method Phaser.Geom.Circle#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Circle} This Circle object. + */ + setEmpty: function () + { + this._radius = 0; + this._diameter = 0; + + return this; + }, + + /** + * Sets the position of this Circle. + * + * @method Phaser.Geom.Circle#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the circle. + * @param {number} [y=0] - The y position of the center of the circle. + * + * @return {Phaser.Geom.Circle} This Circle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Checks to see if the Circle is empty: has a radius of zero. + * + * @method Phaser.Geom.Circle#isEmpty + * @since 3.0.0 + * + * @return {boolean} True if the Circle is empty, otherwise false. + */ + isEmpty: function () + { + return (this._radius <= 0); + }, + + /** + * The radius of the Circle. + * + * @name Phaser.Geom.Circle#radius + * @type {number} + * @since 3.0.0 + */ + radius: { + + get: function () + { + return this._radius; + }, + + set: function (value) + { + this._radius = value; + this._diameter = value * 2; + } + + }, + + /** + * The diameter of the Circle. + * + * @name Phaser.Geom.Circle#diameter + * @type {number} + * @since 3.0.0 + */ + diameter: { + + get: function () + { + return this._diameter; + }, + + set: function (value) + { + this._diameter = value; + this._radius = value * 0.5; + } + + }, + + /** + * The left position of the Circle. + * + * @name Phaser.Geom.Circle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x - this._radius; + }, + + set: function (value) + { + this.x = value + this._radius; + } + + }, + + /** + * The right position of the Circle. + * + * @name Phaser.Geom.Circle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this._radius; + }, + + set: function (value) + { + this.x = value - this._radius; + } + + }, + + /** + * The top position of the Circle. + * + * @name Phaser.Geom.Circle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y - this._radius; + }, + + set: function (value) + { + this.y = value + this._radius; + } + + }, + + /** + * The bottom position of the Circle. + * + * @name Phaser.Geom.Circle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this._radius; + }, + + set: function (value) + { + this.y = value - this._radius; + } + + } + +}); + +module.exports = Circle; + + +/***/ }), +/* 82 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the center y coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetCenterY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The center y coordinate of the bounds of the Game Object. + */ +var GetCenterY = function (gameObject) +{ + return gameObject.y - (gameObject.height * gameObject.originY) + (gameObject.height * 0.5); +}; + +module.exports = GetCenterY; + + +/***/ }), +/* 83 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetCenterY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} y - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetCenterY = function (gameObject, y) +{ + var offsetY = gameObject.height * gameObject.originY; + + gameObject.y = (y + offsetY) - (gameObject.height * 0.5); + + return gameObject; +}; + +module.exports = SetCenterY; + + +/***/ }), +/* 84 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetCenterX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetCenterX = function (gameObject, x) +{ + var offsetX = gameObject.width * gameObject.originX; + + gameObject.x = (x + offsetX) - (gameObject.width * 0.5); + + return gameObject; +}; + +module.exports = SetCenterX; + + +/***/ }), +/* 85 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the center x coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetCenterX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The center x coordinate of the bounds of the Game Object. + */ +var GetCenterX = function (gameObject) +{ + return gameObject.x - (gameObject.width * gameObject.originX) + (gameObject.width * 0.5); +}; + +module.exports = GetCenterX; + + +/***/ }), +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(1); + +/** + * @classdesc + * A class for representing data about a map. Maps are parsed from CSV, Tiled, etc. into this + * format. A Tilemap object get a copy of this data and then unpacks the needed properties into + * itself. + * + * @class MapData + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {object} [config] - [description] + */ +var MapData = new Class({ + + initialize: + + function MapData (config) + { + if (config === undefined) { config = {}; } + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#name + * @type {string} + * @since 3.0.0 + */ + this.name = GetFastValue(config, 'name', 'map'); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#width + * @type {number} + * @since 3.0.0 + */ + this.width = GetFastValue(config, 'width', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#height + * @type {number} + * @since 3.0.0 + */ + this.height = GetFastValue(config, 'height', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#tileWidth + * @type {number} + * @since 3.0.0 + */ + this.tileWidth = GetFastValue(config, 'tileWidth', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#tileHeight + * @type {number} + * @since 3.0.0 + */ + this.tileHeight = GetFastValue(config, 'tileHeight', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#widthInPixels + * @type {number} + * @since 3.0.0 + */ + this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.tileWidth); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#heightInPixels + * @type {number} + * @since 3.0.0 + */ + this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.tileHeight); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#format + * @type {integer} + * @since 3.0.0 + */ + this.format = GetFastValue(config, 'format', null); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#orientation + * @type {string} + * @since 3.0.0 + */ + this.orientation = GetFastValue(config, 'orientation', 'orthogonal'); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#renderOrder + * @type {string} + * @since 3.12.0 + */ + this.renderOrder = GetFastValue(config, 'renderOrder', 'right-down'); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#version + * @type {string} + * @since 3.0.0 + */ + this.version = GetFastValue(config, 'version', '1'); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = GetFastValue(config, 'properties', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#layers + * @type {array} + * @since 3.0.0 + */ + this.layers = GetFastValue(config, 'layers', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#images + * @type {array} + * @since 3.0.0 + */ + this.images = GetFastValue(config, 'images', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#objects + * @type {object} + * @since 3.0.0 + */ + this.objects = GetFastValue(config, 'objects', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#collision + * @type {object} + * @since 3.0.0 + */ + this.collision = GetFastValue(config, 'collision', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#tilesets + * @type {array} + * @since 3.0.0 + */ + this.tilesets = GetFastValue(config, 'tilesets', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#imageCollections + * @type {array} + * @since 3.0.0 + */ + this.imageCollections = GetFastValue(config, 'imageCollections', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#tiles + * @type {array} + * @since 3.0.0 + */ + this.tiles = GetFastValue(config, 'tiles', []); + } + +}); + +module.exports = MapData; + + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(1); + +/** + * @classdesc + * A class for representing data about about a layer in a map. Maps are parsed from CSV, Tiled, + * etc. into this format. Tilemap, StaticTilemapLayer and DynamicTilemapLayer have a reference + * to this data and use it to look up and perform operations on tiles. + * + * @class LayerData + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {object} [config] - [description] + */ +var LayerData = new Class({ + + initialize: + + function LayerData (config) + { + if (config === undefined) { config = {}; } + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#name + * @type {string} + * @since 3.0.0 + */ + this.name = GetFastValue(config, 'name', 'layer'); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#x + * @type {number} + * @since 3.0.0 + */ + this.x = GetFastValue(config, 'x', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#y + * @type {number} + * @since 3.0.0 + */ + this.y = GetFastValue(config, 'y', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#width + * @type {number} + * @since 3.0.0 + */ + this.width = GetFastValue(config, 'width', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#height + * @type {number} + * @since 3.0.0 + */ + this.height = GetFastValue(config, 'height', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#tileWidth + * @type {number} + * @since 3.0.0 + */ + this.tileWidth = GetFastValue(config, 'tileWidth', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#tileHeight + * @type {number} + * @since 3.0.0 + */ + this.tileHeight = GetFastValue(config, 'tileHeight', 0); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#baseTileWidth + * @type {number} + * @since 3.0.0 + */ + this.baseTileWidth = GetFastValue(config, 'baseTileWidth', this.tileWidth); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#baseTileHeight + * @type {number} + * @since 3.0.0 + */ + this.baseTileHeight = GetFastValue(config, 'baseTileHeight', this.tileHeight); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#widthInPixels + * @type {number} + * @since 3.0.0 + */ + this.widthInPixels = GetFastValue(config, 'widthInPixels', this.width * this.baseTileWidth); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#heightInPixels + * @type {number} + * @since 3.0.0 + */ + this.heightInPixels = GetFastValue(config, 'heightInPixels', this.height * this.baseTileHeight); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#alpha + * @type {number} + * @since 3.0.0 + */ + this.alpha = GetFastValue(config, 'alpha', 1); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#visible + * @type {boolean} + * @since 3.0.0 + */ + this.visible = GetFastValue(config, 'visible', true); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = GetFastValue(config, 'properties', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#indexes + * @type {array} + * @since 3.0.0 + */ + this.indexes = GetFastValue(config, 'indexes', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#collideIndexes + * @type {array} + * @since 3.0.0 + */ + this.collideIndexes = GetFastValue(config, 'collideIndexes', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#callbacks + * @type {array} + * @since 3.0.0 + */ + this.callbacks = GetFastValue(config, 'callbacks', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#bodies + * @type {array} + * @since 3.0.0 + */ + this.bodies = GetFastValue(config, 'bodies', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#data + * @type {array} + * @since 3.0.0 + */ + this.data = GetFastValue(config, 'data', []); + + /** + * [description] + * + * @name Phaser.Tilemaps.LayerData#tilemapLayer + * @type {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} + * @since 3.0.0 + */ + this.tilemapLayer = GetFastValue(config, 'tilemapLayer', null); + } + +}); + +module.exports = LayerData; + + +/***/ }), +/* 88 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks if the given tile coordinates are within the bounds of the layer. + * + * @function Phaser.Tilemaps.Components.IsInLayerBounds + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {boolean} `true` if the tile coordinates are within the bounds of the layer, otherwise `false`. + */ +var IsInLayerBounds = function (tileX, tileY, layer) +{ + return (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height); +}; + +module.exports = IsInLayerBounds; + + +/***/ }), +/* 89 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Sleeping` module contains methods to manage the sleeping state of bodies. +* +* @class Sleeping +*/ + +var Sleeping = {}; + +module.exports = Sleeping; + +var Events = __webpack_require__(74); + +(function() { + + Sleeping._motionWakeThreshold = 0.18; + Sleeping._motionSleepThreshold = 0.08; + Sleeping._minBias = 0.9; + + /** + * Puts bodies to sleep or wakes them up depending on their motion. + * @method update + * @param {body[]} bodies + * @param {number} timeScale + */ + Sleeping.update = function(bodies, timeScale) { + var timeFactor = timeScale * timeScale * timeScale; + + // update bodies sleeping status + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + motion = body.speed * body.speed + body.angularSpeed * body.angularSpeed; + + // wake up bodies if they have a force applied + if (body.force.x !== 0 || body.force.y !== 0) { + Sleeping.set(body, false); + continue; + } + + var minMotion = Math.min(body.motion, motion), + maxMotion = Math.max(body.motion, motion); + + // biased average motion estimation between frames + body.motion = Sleeping._minBias * minMotion + (1 - Sleeping._minBias) * maxMotion; + + if (body.sleepThreshold > 0 && body.motion < Sleeping._motionSleepThreshold * timeFactor) { + body.sleepCounter += 1; + + if (body.sleepCounter >= body.sleepThreshold) + Sleeping.set(body, true); + } else if (body.sleepCounter > 0) { + body.sleepCounter -= 1; + } + } + }; + + /** + * Given a set of colliding pairs, wakes the sleeping bodies involved. + * @method afterCollisions + * @param {pair[]} pairs + * @param {number} timeScale + */ + Sleeping.afterCollisions = function(pairs, timeScale) { + var timeFactor = timeScale * timeScale * timeScale; + + // wake up bodies involved in collisions + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + + // don't wake inactive pairs + if (!pair.isActive) + continue; + + var collision = pair.collision, + bodyA = collision.bodyA.parent, + bodyB = collision.bodyB.parent; + + // don't wake if at least one body is static + if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic) + continue; + + if (bodyA.isSleeping || bodyB.isSleeping) { + var sleepingBody = (bodyA.isSleeping && !bodyA.isStatic) ? bodyA : bodyB, + movingBody = sleepingBody === bodyA ? bodyB : bodyA; + + if (!sleepingBody.isStatic && movingBody.motion > Sleeping._motionWakeThreshold * timeFactor) { + Sleeping.set(sleepingBody, false); + } + } + } + }; + + /** + * Set a body as sleeping or awake. + * @method set + * @param {body} body + * @param {boolean} isSleeping + */ + Sleeping.set = function(body, isSleeping) { + var wasSleeping = body.isSleeping; + + if (isSleeping) { + body.isSleeping = true; + body.sleepCounter = body.sleepThreshold; + + body.positionImpulse.x = 0; + body.positionImpulse.y = 0; + + body.positionPrev.x = body.position.x; + body.positionPrev.y = body.position.y; + + body.anglePrev = body.angle; + body.speed = 0; + body.angularSpeed = 0; + body.motion = 0; + + if (!wasSleeping) { + Events.trigger(body, 'sleepStart'); + } + } else { + body.isSleeping = false; + body.sleepCounter = 0; + + if (wasSleeping) { + Events.trigger(body, 'sleepEnd'); + } + } + }; + +})(); + + +/***/ }), +/* 90 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Collision Types - Determine if and how entities collide with each other. + * + * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, + * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE + * collisions, both entities are moved. LITE or PASSIVE entities don't collide + * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. + * FIXED collisions is undefined. + * + * @name Phaser.Physics.Impact.TYPE + * @enum {integer} + * @memberof Phaser.Physics.Impact + * @readonly + * @since 3.0.0 + */ +module.exports = { + + /** + * Collides with nothing. + * + * @name Phaser.Physics.Impact.TYPE.NONE + */ + NONE: 0, + + /** + * Type A. Collides with Type B. + * + * @name Phaser.Physics.Impact.TYPE.A + */ + A: 1, + + /** + * Type B. Collides with Type A. + * + * @name Phaser.Physics.Impact.TYPE.B + */ + B: 2, + + /** + * Collides with both types A and B. + * + * @name Phaser.Physics.Impact.TYPE.BOTH + */ + BOTH: 3 + +}; + + +/***/ }), +/* 91 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Collision Types - Determine if and how entities collide with each other. + * + * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, + * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE + * collisions, both entities are moved. LITE or PASSIVE entities don't collide + * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. + * FIXED collisions is undefined. + * + * @name Phaser.Physics.Impact.COLLIDES + * @enum {integer} + * @memberof Phaser.Physics.Impact + * @readonly + * @since 3.0.0 + */ +module.exports = { + + /** + * Never collides. + * + * @name Phaser.Physics.Impact.COLLIDES.NEVER + */ + NEVER: 0, + + /** + * Lite collision. + * + * @name Phaser.Physics.Impact.COLLIDES.LITE + */ + LITE: 1, + + /** + * Passive collision. + * + * @name Phaser.Physics.Impact.COLLIDES.PASSIVE + */ + PASSIVE: 2, + + /** + * Active collision. + * + * @name Phaser.Physics.Impact.COLLIDES.ACTIVE + */ + ACTIVE: 4, + + /** + * Fixed collision. + * + * @name Phaser.Physics.Impact.COLLIDES.FIXED + */ + FIXED: 8 + +}; + + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders a filled path for the given Shape. + * + * @method Phaser.GameObjects.Shape#FillPathWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The WebGL Pipeline used to render this Shape. + * @param {Phaser.GameObjects.Components.TransformMatrix} calcMatrix - The transform matrix used to get the position values. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. + */ +var FillPathWebGL = function (pipeline, calcMatrix, src, alpha, dx, dy) +{ + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + var path = src.pathData; + var pathIndexes = src.pathIndexes; + + for (var i = 0; i < pathIndexes.length; i += 3) + { + var p0 = pathIndexes[i] * 2; + var p1 = pathIndexes[i + 1] * 2; + var p2 = pathIndexes[i + 2] * 2; + + var x0 = path[p0 + 0] - dx; + var y0 = path[p0 + 1] - dy; + var x1 = path[p1 + 0] - dx; + var y1 = path[p1 + 1] - dy; + var x2 = path[p2 + 0] - dx; + var y2 = path[p2 + 1] - dy; + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + pipeline.setTexture2D(); + + pipeline.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, 0, 0, 1, 1, fillTintColor, fillTintColor, fillTintColor, pipeline.tintEffect); + } +}; + +module.exports = FillPathWebGL; + + +/***/ }), +/* 93 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TWEEN_CONST = { + + /** + * TweenData state. + * + * @name Phaser.Tweens.CREATED + * @type {integer} + * @since 3.0.0 + */ + CREATED: 0, + + /** + * TweenData state. + * + * @name Phaser.Tweens.INIT + * @type {integer} + * @since 3.0.0 + */ + INIT: 1, + + /** + * TweenData state. + * + * @name Phaser.Tweens.DELAY + * @type {integer} + * @since 3.0.0 + */ + DELAY: 2, + + /** + * TweenData state. + * + * @name Phaser.Tweens.OFFSET_DELAY + * @type {integer} + * @since 3.0.0 + */ + OFFSET_DELAY: 3, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PENDING_RENDER + * @type {integer} + * @since 3.0.0 + */ + PENDING_RENDER: 4, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PLAYING_FORWARD + * @type {integer} + * @since 3.0.0 + */ + PLAYING_FORWARD: 5, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PLAYING_BACKWARD + * @type {integer} + * @since 3.0.0 + */ + PLAYING_BACKWARD: 6, + + /** + * TweenData state. + * + * @name Phaser.Tweens.HOLD_DELAY + * @type {integer} + * @since 3.0.0 + */ + HOLD_DELAY: 7, + + /** + * TweenData state. + * + * @name Phaser.Tweens.REPEAT_DELAY + * @type {integer} + * @since 3.0.0 + */ + REPEAT_DELAY: 8, + + /** + * TweenData state. + * + * @name Phaser.Tweens.COMPLETE + * @type {integer} + * @since 3.0.0 + */ + COMPLETE: 9, + + // Tween specific (starts from 20 to cleanly allow extra TweenData consts in the future) + + /** + * Tween state. + * + * @name Phaser.Tweens.PENDING_ADD + * @type {integer} + * @since 3.0.0 + */ + PENDING_ADD: 20, + + /** + * Tween state. + * + * @name Phaser.Tweens.PAUSED + * @type {integer} + * @since 3.0.0 + */ + PAUSED: 21, + + /** + * Tween state. + * + * @name Phaser.Tweens.LOOP_DELAY + * @type {integer} + * @since 3.0.0 + */ + LOOP_DELAY: 22, + + /** + * Tween state. + * + * @name Phaser.Tweens.ACTIVE + * @type {integer} + * @since 3.0.0 + */ + ACTIVE: 23, + + /** + * Tween state. + * + * @name Phaser.Tweens.COMPLETE_DELAY + * @type {integer} + * @since 3.0.0 + */ + COMPLETE_DELAY: 24, + + /** + * Tween state. + * + * @name Phaser.Tweens.PENDING_REMOVE + * @type {integer} + * @since 3.0.0 + */ + PENDING_REMOVE: 25, + + /** + * Tween state. + * + * @name Phaser.Tweens.REMOVED + * @type {integer} + * @since 3.0.0 + */ + REMOVED: 26 + +}; + +module.exports = TWEEN_CONST; + + +/***/ }), +/* 94 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Retrieves the value of the given key from an object. + * + * @function Phaser.Tweens.Builders.GetBoolean + * @since 3.0.0 + * + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The key to look for in the `source` object. + * @param {*} defaultValue - The default value to return if the `key` doesn't exist or if no `source` object is provided. + * + * @return {*} The retrieved value. + */ +var GetBoolean = function (source, key, defaultValue) +{ + if (!source) + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else + { + return defaultValue; + } +}; + +module.exports = GetBoolean; + + +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var EaseMap = __webpack_require__(192); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetEaseFunction + * @since 3.0.0 + * + * @param {(string|function)} ease - [description] + * @param {array} easeParams - [description] + * + * @return {function} [description] + */ +var GetEaseFunction = function (ease, easeParams) +{ + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + if (easeParams) + { + var cloneParams = easeParams.slice(0); + + cloneParams.unshift(0); + + return function (v) + { + cloneParams[0] = v; + + return EaseMap[ease].apply(this, cloneParams); + }; + } + else + { + // String based look-up + return EaseMap[ease]; + } + } + else if (typeof ease === 'function') + { + // Custom function + return ease; + } + else if (Array.isArray(ease) && ease.length === 4) + { + // Bezier function (TODO) + } + + return EaseMap.Power0; +}; + +module.exports = GetEaseFunction; + + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback EachSetCallback + * @generic E - [entry] + * + * @param {*} entry - [description] + * @param {number} index - [description] + * + * @return {?boolean} [description] + */ + +/** + * @classdesc + * A Set is a collection of unique elements. + * + * @class Set + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + * @genericUse {T[]} - [elements] + * + * @param {Array.<*>} [elements] - An optional array of elements to insert into this Set. + */ +var Set = new Class({ + + initialize: + + function Set (elements) + { + /** + * The entries of this Set. Stored internally as an array. + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.Set#entries + * @type {Array.<*>} + * @default [] + * @since 3.0.0 + */ + this.entries = []; + + if (Array.isArray(elements)) + { + for (var i = 0; i < elements.length; i++) + { + this.set(elements[i]); + } + } + }, + + /** + * Inserts the provided value into this Set. If the value is already contained in this Set this method will have no effect. + * + * @method Phaser.Structs.Set#set + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {*} value - The value to insert into this Set. + * + * @return {Phaser.Structs.Set} This Set object. + */ + set: function (value) + { + if (this.entries.indexOf(value) === -1) + { + this.entries.push(value); + } + + return this; + }, + + /** + * Get an element of this Set which has a property of the specified name, if that property is equal to the specified value. + * If no elements of this Set satisfy the condition then this method will return `null`. + * + * @method Phaser.Structs.Set#get + * @since 3.0.0 + * + * @genericUse {T} - [value,$return] + * + * @param {string} property - The property name to check on the elements of this Set. + * @param {*} value - The value to check for. + * + * @return {*} The first element of this Set that meets the required condition, or `null` if this Set contains no elements that meet the condition. + */ + get: function (property, value) + { + for (var i = 0; i < this.entries.length; i++) + { + var entry = this.entries[i]; + + if (entry[property] === value) + { + return entry; + } + } + }, + + /** + * Returns an array containing all the values in this Set. + * + * @method Phaser.Structs.Set#getArray + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} An array containing all the values in this Set. + */ + getArray: function () + { + return this.entries.slice(0); + }, + + /** + * Removes the given value from this Set if this Set contains that value. + * + * @method Phaser.Structs.Set#delete + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {*} value - The value to remove from the Set. + * + * @return {Phaser.Structs.Set} This Set object. + */ + delete: function (value) + { + var index = this.entries.indexOf(value); + + if (index > -1) + { + this.entries.splice(index, 1); + } + + return this; + }, + + /** + * Dumps the contents of this Set to the console via `console.group`. + * + * @method Phaser.Structs.Set#dump + * @since 3.0.0 + */ + dump: function () + { + // eslint-disable-next-line no-console + console.group('Set'); + + for (var i = 0; i < this.entries.length; i++) + { + var entry = this.entries[i]; + console.log(entry); + } + + // eslint-disable-next-line no-console + console.groupEnd(); + }, + + /** + * Passes each value in this Set to the given callback. + * Use this function when you know this Set will be modified during the iteration, otherwise use `iterate`. + * + * @method Phaser.Structs.Set#each + * @since 3.0.0 + * + * @genericUse {EachSetCallback.} - [callback] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {EachSetCallback} callback - The callback to be invoked and passed each value this Set contains. + * @param {*} callbackScope - The scope of the callback. + * + * @return {Phaser.Structs.Set} This Set object. + */ + each: function (callback, callbackScope) + { + var i; + var temp = this.entries.slice(); + var len = temp.length; + + if (callbackScope) + { + for (i = 0; i < len; i++) + { + if (callback.call(callbackScope, temp[i], i) === false) + { + break; + } + } + } + else + { + for (i = 0; i < len; i++) + { + if (callback(temp[i], i) === false) + { + break; + } + } + } + + return this; + }, + + /** + * Passes each value in this Set to the given callback. + * For when you absolutely know this Set won't be modified during the iteration. + * + * @method Phaser.Structs.Set#iterate + * @since 3.0.0 + * + * @genericUse {EachSetCallback.} - [callback] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {EachSetCallback} callback - The callback to be invoked and passed each value this Set contains. + * @param {*} callbackScope - The scope of the callback. + * + * @return {Phaser.Structs.Set} This Set object. + */ + iterate: function (callback, callbackScope) + { + var i; + var len = this.entries.length; + + if (callbackScope) + { + for (i = 0; i < len; i++) + { + if (callback.call(callbackScope, this.entries[i], i) === false) + { + break; + } + } + } + else + { + for (i = 0; i < len; i++) + { + if (callback(this.entries[i], i) === false) + { + break; + } + } + } + + return this; + }, + + /** + * Goes through each entry in this Set and invokes the given function on them, passing in the arguments. + * + * @method Phaser.Structs.Set#iterateLocal + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {string} callbackKey - The key of the function to be invoked on each Set entry. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.Structs.Set} This Set object. + */ + iterateLocal: function (callbackKey) + { + var i; + var args = []; + + for (i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + var len = this.entries.length; + + for (i = 0; i < len; i++) + { + var entry = this.entries[i]; + + entry[callbackKey].apply(entry, args); + } + + return this; + }, + + /** + * Clears this Set so that it no longer contains any values. + * + * @method Phaser.Structs.Set#clear + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @return {Phaser.Structs.Set} This Set object. + */ + clear: function () + { + this.entries.length = 0; + + return this; + }, + + /** + * Returns `true` if this Set contains the given value, otherwise returns `false`. + * + * @method Phaser.Structs.Set#contains + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {*} value - The value to check for in this Set. + * + * @return {boolean} `true` if the given value was found in this Set, otherwise `false`. + */ + contains: function (value) + { + return (this.entries.indexOf(value) > -1); + }, + + /** + * Returns a new Set containing all values that are either in this Set or in the Set provided as an argument. + * + * @method Phaser.Structs.Set#union + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - The Set to perform the union with. + * + * @return {Phaser.Structs.Set} A new Set containing all the values in this Set and the Set provided as an argument. + */ + union: function (set) + { + var newSet = new Set(); + + set.entries.forEach(function (value) + { + newSet.set(value); + }); + + this.entries.forEach(function (value) + { + newSet.set(value); + }); + + return newSet; + }, + + /** + * Returns a new Set that contains only the values which are in this Set and that are also in the given Set. + * + * @method Phaser.Structs.Set#intersect + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - The Set to intersect this set with. + * + * @return {Phaser.Structs.Set} The result of the intersection, as a new Set. + */ + intersect: function (set) + { + var newSet = new Set(); + + this.entries.forEach(function (value) + { + if (set.contains(value)) + { + newSet.set(value); + } + }); + + return newSet; + }, + + /** + * Returns a new Set containing all the values in this Set which are *not* also in the given Set. + * + * @method Phaser.Structs.Set#difference + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - The Set to perform the difference with. + * + * @return {Phaser.Structs.Set} A new Set containing all the values in this Set that are not also in the Set provided as an argument to this method. + */ + difference: function (set) + { + var newSet = new Set(); + + this.entries.forEach(function (value) + { + if (!set.contains(value)) + { + newSet.set(value); + } + }); + + return newSet; + }, + + /** + * The size of this Set. This is the number of entries within it. + * Changing the size will truncate the Set if the given value is smaller than the current size. + * Increasing the size larger than the current size has no effect. + * + * @name Phaser.Structs.Set#size + * @type {integer} + * @since 3.0.0 + */ + size: { + + get: function () + { + return this.entries.length; + }, + + set: function (value) + { + if (value < this.entries.length) + { + return this.entries.length = value; + } + else + { + return this.entries.length; + } + } + + } + +}); + +module.exports = Set; + + +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Actions = __webpack_require__(454); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(1); +var GetValue = __webpack_require__(4); +var IsPlainObject = __webpack_require__(8); +var Range = __webpack_require__(340); +var Set = __webpack_require__(96); +var Sprite = __webpack_require__(57); + +/** + * @callback GroupCallback + * + * @param {Phaser.GameObjects.GameObject} item - A group member + */ + +/** + * @callback GroupMultipleCreateCallback + * + * @param {Phaser.GameObjects.GameObject[]} items - The newly created group members + */ + +/** + * @typedef {object} GroupConfig + * + * @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 + * + * 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 A Group is a way for you to create, manipulate, or recycle similar Game Objects. + * + * 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|GroupCreateConfig)} [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. + * + * @see Phaser.Physics.Arcade.Group + * @see Phaser.Physics.Arcade.StaticGroup + */ +var Group = new Class({ + + initialize: + + function Group (scene, children, config) + { + // They can pass in any of the following as the first argument: + + // 1) A single child + // 2) An array of children + // 3) A config object + // 4) An array of config objects + + // Or they can pass in a child, or array of children AND a config object + + if (config) + { + // config has been set, are the children an array? + + if (children && !Array.isArray(children)) + { + children = [ children ]; + } + } + else if (Array.isArray(children)) + { + // No config, so let's check the children argument + + if (IsPlainObject(children[0])) + { + // It's an array of plain config objects + config = children; + children = null; + } + } + else if (IsPlainObject(children)) + { + // Children isn't an array. Is it a config object though? + config = children; + children = null; + } + + /** + * This scene this group belongs to. + * + * @name Phaser.GameObjects.Group#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * Members of this group. + * + * @name Phaser.GameObjects.Group#children + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.children = new Set(children); + + /** + * A flag identifying this object as a group. + * + * @name Phaser.GameObjects.Group#isParent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isParent = true; + + /** + * 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); + + /** + * Whether this group runs its {@link Phaser.GameObjects.Group#preUpdate} method + * (which may update any members). + * + * @name Phaser.GameObjects.Group#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = GetFastValue(config, 'active', true); + + /** + * 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); + + /** + * 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} + * @since 3.0.0 + */ + this.defaultKey = GetFastValue(config, 'defaultKey', null); + + /** + * A default texture frame to use when creating new group members. + * + * @name Phaser.GameObjects.Group#defaultFrame + * @type {(string|integer)} + * @since 3.0.0 + */ + this.defaultFrame = GetFastValue(config, 'defaultFrame', null); + + /** + * 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); + + /** + * A function to be called when adding or creating group members. + * + * @name Phaser.GameObjects.Group#createCallback + * @type {?GroupCallback} + * @since 3.0.0 + */ + this.createCallback = GetFastValue(config, 'createCallback', null); + + /** + * A function to be called when removing group members. + * + * @name Phaser.GameObjects.Group#removeCallback + * @type {?GroupCallback} + * @since 3.0.0 + */ + this.removeCallback = GetFastValue(config, 'removeCallback', null); + + /** + * A function to be called when creating several group members at once. + * + * @name Phaser.GameObjects.Group#createMultipleCallback + * @type {?GroupMultipleCreateCallback} + * @since 3.0.0 + */ + this.createMultipleCallback = GetFastValue(config, 'createMultipleCallback', null); + + if (config) + { + this.createMultiple(config); + } + }, + + /** + * 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 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 {any} The new Game Object (usually a Sprite, etc.). + */ + create: function (x, y, key, frame, visible, active) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (key === undefined) { key = this.defaultKey; } + if (frame === undefined) { frame = this.defaultFrame; } + if (visible === undefined) { visible = true; } + if (active === undefined) { active = true; } + + // Pool? + if (this.isFull()) + { + return null; + } + + var child = new this.classType(this.scene, x, y, key, frame); + + this.scene.sys.displayList.add(child); + + if (child.preUpdate) + { + this.scene.sys.updateList.add(child); + } + + child.visible = visible; + child.setActive(active); + + this.add(child); + + return child; + }, + + /** + * 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|GroupCreateConfig[]} config - Creation settings. This can be a single configuration object or an array of such objects, which will be applied in turn. + * + * @return {any[]} The newly created Game Objects. + */ + createMultiple: function (config) + { + if (this.isFull()) + { + return []; + } + + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var output = []; + + if (config[0].key) + { + for (var i = 0; i < config.length; i++) + { + var entries = this.createFromConfig(config[i]); + + output = output.concat(entries); + } + } + + return output; + }, + + /** + * A helper for {@link Phaser.GameObjects.Group#createMultiple}. + * + * @method Phaser.GameObjects.Group#createFromConfig + * @since 3.0.0 + * + * @param {GroupCreateConfig} options - Creation settings. + * + * @return {any[]} 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); + var frame = GetFastValue(options, 'frame', null); + var visible = GetFastValue(options, 'visible', true); + var active = GetFastValue(options, 'active', true); + + var entries = []; + + // Can't do anything without at least a key + if (key === undefined) + { + return entries; + } + else + { + if (!Array.isArray(key)) + { + key = [ key ]; + } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + } + + // Build an array of key frame pairs to loop through + + var repeat = GetFastValue(options, 'repeat', 0); + var randomKey = GetFastValue(options, 'randomKey', false); + var randomFrame = GetFastValue(options, 'randomFrame', false); + var yoyo = GetFastValue(options, 'yoyo', false); + var quantity = GetFastValue(options, 'frameQuantity', 1); + var max = GetFastValue(options, 'max', 0); + + // If a grid is set we use that to override the quantity? + + var range = Range(key, frame, { + max: max, + qty: quantity, + random: randomKey, + randomB: randomFrame, + repeat: repeat, + yoyo: yoyo + }); + + for (var c = 0; c < range.length; c++) + { + 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): + + var x = GetValue(options, 'setXY.x', 0); + var y = GetValue(options, 'setXY.y', 0); + var stepX = GetValue(options, 'setXY.stepX', 0); + var stepY = GetValue(options, 'setXY.stepY', 0); + + Actions.SetXY(entries, x, y, stepX, stepY); + + var rotation = GetValue(options, 'setRotation.value', 0); + var stepRotation = GetValue(options, 'setRotation.step', 0); + + Actions.SetRotation(entries, rotation, stepRotation); + + var scaleX = GetValue(options, 'setScale.x', 1); + var scaleY = GetValue(options, 'setScale.y', scaleX); + var stepScaleX = GetValue(options, 'setScale.stepX', 0); + var stepScaleY = GetValue(options, 'setScale.stepY', 0); + + Actions.SetScale(entries, scaleX, scaleY, stepScaleX, stepScaleY); + + var alpha = GetValue(options, 'setAlpha.value', 1); + var stepAlpha = GetValue(options, 'setAlpha.step', 0); + + Actions.SetAlpha(entries, alpha, stepAlpha); + + var hitArea = GetFastValue(options, 'hitArea', null); + var hitAreaCallback = GetFastValue(options, 'hitAreaCallback', null); + + if (hitArea) + { + Actions.SetHitArea(entries, hitArea, hitAreaCallback); + } + + var grid = GetFastValue(options, 'gridAlign', false); + + if (grid) + { + Actions.GridAlign(entries, grid); + } + + if (this.createMultipleCallback) + { + this.createMultipleCallback.call(this, entries); + } + + return entries; + }, + + /** + * Updates any group members, if {@link Phaser.GameObjects.Group#runChildUpdate} is enabled. + * + * @method Phaser.GameObjects.Group#preUpdate + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + if (!this.runChildUpdate || this.children.size === 0) + { + return; + } + + // Because a Group child may mess with the length of the Group during its update + var temp = this.children.entries.slice(); + + for (var i = 0; i < temp.length; i++) + { + var item = temp[i]; + + if (item.active) + { + item.update(time, delta); + } + } + }, + + /** + * 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 - The Game Object to add. + * @param {boolean} [addToScene=false] - Also add the Game Object to the scene. + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + add: function (child, addToScene) + { + if (addToScene === undefined) { addToScene = false; } + + if (this.isFull()) + { + return this; + } + + this.children.set(child); + + if (this.createCallback) + { + this.createCallback.call(this, child); + } + + if (addToScene) + { + this.scene.sys.displayList.add(child); + + if (child.preUpdate) + { + this.scene.sys.updateList.add(child); + } + } + + child.on('destroy', this.remove, this); + + return this; + }, + + /** + * 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 - The Game Objects to add. + * @param {boolean} [addToScene=false] - Also add the Game Objects to the scene. + * + * @return {Phaser.GameObjects.Group} This group. + */ + addMultiple: function (children, addToScene) + { + if (addToScene === undefined) { addToScene = false; } + + if (Array.isArray(children)) + { + for (var i = 0; i < children.length; i++) + { + this.add(children[i], addToScene); + } + } + + return this; + }, + + /** + * Removes a member of this Group and optionally removes it from the Scene and / or destroys it. + * + * Calls {@link Phaser.GameObjects.Group#removeCallback}. + * + * @method Phaser.GameObjects.Group#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to remove. + * @param {boolean} [removeFromScene=false] - Optionally remove the Group member from the Scene it belongs to. + * @param {boolean} [destroyChild=false] - Optionally call destroy on the removed Group member. + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + remove: function (child, removeFromScene, destroyChild) + { + if (removeFromScene === undefined) { removeFromScene = false; } + if (destroyChild === undefined) { destroyChild = false; } + + if (!this.children.contains(child)) + { + return this; + } + + this.children.delete(child); + + if (this.removeCallback) + { + this.removeCallback.call(this, child); + } + + child.off('destroy', this.remove, this); + + if (destroyChild) + { + child.destroy(); + } + else if (removeFromScene) + { + child.scene.sys.displayList.remove(child); + + if (child.preUpdate) + { + child.scene.sys.updateList.remove(child); + } + } + + return this; + }, + + /** + * Removes all members of this Group and optionally removes them from the Scene and / or destroys them. + * + * Does not call {@link Phaser.GameObjects.Group#removeCallback}. + * + * @method Phaser.GameObjects.Group#clear + * @since 3.0.0 + * + * @param {boolean} [removeFromScene=false] - Optionally remove each Group member from the Scene. + * @param {boolean} [destroyChild=false] - Optionally call destroy on the removed Group members. + * + * @return {Phaser.GameObjects.Group} This group. + */ + clear: function (removeFromScene, destroyChild) + { + if (removeFromScene === undefined) { removeFromScene = false; } + if (destroyChild === undefined) { destroyChild = false; } + + var children = this.children; + + for (var i = 0; i < children.size; i++) + { + var gameObject = children.entries[i]; + + gameObject.off('destroy', this.remove, this); + + if (destroyChild) + { + gameObject.destroy(); + } + else if (removeFromScene) + { + gameObject.scene.sys.displayList.remove(gameObject); + + if (gameObject.preUpdate) + { + gameObject.scene.sys.updateList.remove(gameObject); + } + } + } + + this.children.clear(); + + return this; + }, + + /** + * 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 - A Game Object. + * + * @return {boolean} True if the Game Object is a member of this group. + */ + contains: function (child) + { + return this.children.contains(child); + }, + + /** + * All members of the group. + * + * @method Phaser.GameObjects.Group#getChildren + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject[]} The group members. + */ + getChildren: function () + { + return this.children.entries; + }, + + /** + * The number of members of the group. + * + * @method Phaser.GameObjects.Group#getLength + * @since 3.0.0 + * + * @return {integer} + */ + getLength: function () + { + return this.children.size; + }, + + /** + * Scans the Group, from top to bottom, 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] - 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 {?any} The first matching group member, or a newly created member, or null. + */ + getFirst: function (state, createIfNull, x, y, key, frame, visible) + { + return this.getHandler(true, 1, state, createIfNull, x, y, key, frame, visible); + }, + + /** + * Scans the Group, from top to bottom, for the nth 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#getFirstNth + * @since 3.6.0 + * + * @param {integer} nth - The nth matching Group member to search for. + * @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 {?any} The first matching group member, or a newly created member, or null. + */ + getFirstNth: function (nth, state, createIfNull, x, y, key, frame, visible) + { + return this.getHandler(true, nth, state, createIfNull, x, y, key, frame, visible); + }, + + /** + * Scans the Group for the last 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#getLast + * @since 3.6.0 + * + * @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 {?any} The first matching group member, or a newly created member, or null. + */ + getLast: function (state, createIfNull, x, y, key, frame, visible) + { + return this.getHandler(false, 1, state, createIfNull, x, y, key, frame, visible); + }, + + /** + * Scans the Group for the last nth 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#getLastNth + * @since 3.6.0 + * + * @param {integer} nth - The nth matching Group member to search for. + * @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 {?any} The first matching group member, or a newly created member, or null. + */ + getLastNth: function (nth, state, createIfNull, x, y, key, frame, visible) + { + return this.getHandler(false, nth, state, createIfNull, x, y, key, frame, visible); + }, + + /** + * Scans the group for the last 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#getHandler + * @private + * @since 3.6.0 + * + * @param {boolean} forwards - Search front to back or back to front? + * @param {integer} nth - Stop matching after nth successful matches. + * @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 {?any} The first matching group member, or a newly created member, or null. + */ + getHandler: function (forwards, nth, state, createIfNull, x, y, key, frame, visible) + { + if (state === undefined) { state = false; } + if (createIfNull === undefined) { createIfNull = false; } + + var gameObject; + + var i; + var total = 0; + var children = this.children.entries; + + if (forwards) + { + for (i = 0; i < children.length; i++) + { + gameObject = children[i]; + + if (gameObject.active === state) + { + total++; + + if (total === nth) + { + break; + } + } + else + { + gameObject = null; + } + } + } + else + { + for (i = children.length - 1; i >= 0; i--) + { + gameObject = children[i]; + + if (gameObject.active === state) + { + total++; + + if (total === nth) + { + break; + } + } + else + { + gameObject = null; + } + } + } + + if (gameObject) + { + if (typeof(x) === 'number') + { + gameObject.x = x; + } + + if (typeof(y) === 'number') + { + gameObject.y = y; + } + + return gameObject; + } + + // Got this far? We need to create or bail + if (createIfNull) + { + return this.create(x, y, key, frame, visible); + } + else + { + return null; + } + }, + + /** + * 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] - 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 {?any} The first inactive group member, or a newly created member, or null. + */ + get: function (x, y, key, frame, visible) + { + return this.getFirst(false, true, x, y, key, frame, visible); + }, + + /** + * 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=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 {any} The first active group member, or a newly created member, or null. + */ + getFirstAlive: function (createIfNull, x, y, key, frame, visible) + { + return this.getFirst(true, createIfNull, x, y, key, frame, visible); + }, + + /** + * 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=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 {any} The first inactive group member, or a newly created member, or null. + */ + getFirstDead: function (createIfNull, x, y, key, frame, visible) + { + return this.getFirst(false, createIfNull, x, y, key, frame, visible); + }, + + /** + * {@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 - 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. + */ + playAnimation: function (key, startFrame) + { + Actions.PlayAnimation(this.children.entries, key, startFrame); + + return this; + }, + + /** + * Whether this group's size at its {@link Phaser.GameObjects.Group#maxSize maximum}. + * + * @method Phaser.GameObjects.Group#isFull + * @since 3.0.0 + * + * @return {boolean} True if the number of members equals {@link Phaser.GameObjects.Group#maxSize}. + */ + isFull: function () + { + if (this.maxSize === -1) + { + return false; + } + else + { + return (this.children.size >= this.maxSize); + } + }, + + /** + * Counts the number of active (or inactive) group members. + * + * @method Phaser.GameObjects.Group#countActive + * @since 3.0.0 + * + * @param {boolean} [value=true] - Count active (true) or inactive (false) group members. + * + * @return {integer} The number of group members with an active state matching the `active` argument. + */ + countActive: function (value) + { + if (value === undefined) { value = true; } + + var total = 0; + + for (var i = 0; i < this.children.size; i++) + { + if (this.children.entries[i].active === value) + { + total++; + } + } + + return total; + }, + + /** + * Counts the number of in-use (active) group members. + * + * @method Phaser.GameObjects.Group#getTotalUsed + * @since 3.0.0 + * + * @return {integer} The number of group members with an active state of true. + */ + getTotalUsed: function () + { + return this.countActive(); + }, + + /** + * 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} maxSize minus the number of active group numbers; or a large number (if maxSize is -1). + */ + getTotalFree: function () + { + var used = this.getTotalUsed(); + var capacity = (this.maxSize === -1) ? 999999999999 : this.maxSize; + + return (capacity - used); + }, + + /** + * Sets the depth of each group member. + * + * @method Phaser.GameObjects.Group#setDepth + * @since 3.0.0 + * + * @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. + */ + setDepth: function (value, step) + { + Actions.SetDepth(this.children.entries, value, step); + + return this; + }, + + /** + * Deactivates a member of this group. + * + * @method Phaser.GameObjects.Group#kill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - A member of this group. + */ + kill: function (gameObject) + { + if (this.children.contains(gameObject)) + { + gameObject.setActive(false); + } + }, + + /** + * Deactivates and hides a member of this group. + * + * @method Phaser.GameObjects.Group#killAndHide + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - A member of this group. + */ + killAndHide: function (gameObject) + { + if (this.children.contains(gameObject)) + { + gameObject.setActive(false); + gameObject.setVisible(false); + } + }, + + /** + * Toggles (flips) the visible state of each member of this group. + * + * @method Phaser.GameObjects.Group#toggleVisible + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Group} This Group object. + */ + toggleVisible: function () + { + Actions.ToggleVisible(this.children.entries); + + return this; + }, + + /** + * 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] - Also {@link Phaser.GameObjects.GameObject#destroy} each group member. + */ + destroy: function (destroyChildren) + { + if (destroyChildren === undefined) { destroyChildren = false; } + + // This Game Object had already been destroyed + if (!this.scene || this.ignoreDestroy) + { + return; + } + + if (destroyChildren) + { + var children = this.children; + + for (var i = 0; i < children.size; i++) + { + var gameObject = children.entries[i]; + + // Remove the event hook first or it'll go all recursive hell on us + gameObject.off('destroy', this.remove, this); + + gameObject.destroy(); + } + } + + this.children.clear(); + + this.scene = undefined; + this.children = undefined; + } + +}); + +module.exports = Group; + + +/***/ }), +/* 98 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check to see if the Ellipse contains the given x / y coordinates. + * + * @function Phaser.Geom.Ellipse.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. + * + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. + */ +var Contains = function (ellipse, x, y) +{ + if (ellipse.width <= 0 || ellipse.height <= 0) + { + return false; + } + + // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 + var normx = ((x - ellipse.x) / ellipse.width); + var normy = ((y - ellipse.y) / ellipse.height); + + normx *= normx; + normy *= normy; + + return (normx + normy < 0.25); +}; + +module.exports = Contains; + + +/***/ }), +/* 99 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(98); +var GetPoint = __webpack_require__(336); +var GetPoints = __webpack_require__(335); +var Random = __webpack_require__(203); + +/** + * @classdesc + * An Ellipse object. + * + * This is a geometry object, containing numerical values and related methods to inspect and modify them. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render an Ellipse you should look at the capabilities of the Graphics class. + * + * @class Ellipse + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of the center of the ellipse. + * @param {number} [y=0] - The y position of the center of the ellipse. + * @param {number} [width=0] - The width of the ellipse. + * @param {number} [height=0] - The height of the ellipse. + */ +var Ellipse = new Class({ + + initialize: + + function Ellipse (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * The x position of the center of the ellipse. + * + * @name Phaser.Geom.Ellipse#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of the center of the ellipse. + * + * @name Phaser.Geom.Ellipse#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the ellipse. + * + * @name Phaser.Geom.Ellipse#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the ellipse. + * + * @name Phaser.Geom.Ellipse#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * Check to see if the Ellipse contains the given x / y coordinates. + * + * @method Phaser.Geom.Ellipse#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. + * + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @method Phaser.Geom.Ellipse#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. + */ + getPoint: function (position, point) + { + return GetPoint(this, position, point); + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Ellipse#getPoints + * @since 3.0.0 + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the ellipse. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * + * @method Phaser.Geom.Ellipse#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {(Phaser.Geom.Point|object)} [point] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets the x, y, width and height of this ellipse. + * + * @method Phaser.Geom.Ellipse#setTo + * @since 3.0.0 + * + * @param {number} x - The x position of the center of the ellipse. + * @param {number} y - The y position of the center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets this Ellipse to be empty with a width and height of zero. + * Does not change its position. + * + * @method Phaser.Geom.Ellipse#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setEmpty: function () + { + this.width = 0; + this.height = 0; + + return this; + }, + + /** + * Sets the position of this Ellipse. + * + * @method Phaser.Geom.Ellipse#setPosition + * @since 3.0.0 + * + * @param {number} x - The x position of the center of the ellipse. + * @param {number} y - The y position of the center of the ellipse. + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Sets the size of this Ellipse. + * Does not change its position. + * + * @method Phaser.Geom.Ellipse#setSize + * @since 3.0.0 + * + * @param {number} width - The width of the ellipse. + * @param {number} [height=width] - The height of the ellipse. + * + * @return {Phaser.Geom.Ellipse} This Ellipse object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * Checks to see if the Ellipse is empty: has a width or height equal to zero. + * + * @method Phaser.Geom.Ellipse#isEmpty + * @since 3.0.0 + * + * @return {boolean} True if the Ellipse is empty, otherwise false. + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns the minor radius of the ellipse. Also known as the Semi Minor Axis. + * + * @method Phaser.Geom.Ellipse#getMinorRadius + * @since 3.0.0 + * + * @return {number} The minor radius. + */ + getMinorRadius: function () + { + return Math.min(this.width, this.height) / 2; + }, + + /** + * Returns the major radius of the ellipse. Also known as the Semi Major Axis. + * + * @method Phaser.Geom.Ellipse#getMajorRadius + * @since 3.0.0 + * + * @return {number} The major radius. + */ + getMajorRadius: function () + { + return Math.max(this.width, this.height) / 2; + }, + + /** + * The left position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x - (this.width / 2); + }, + + set: function (value) + { + this.x = value + (this.width / 2); + } + + }, + + /** + * The right position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * The top position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y - (this.height / 2); + }, + + set: function (value) + { + this.y = value + (this.height / 2); + } + + }, + + /** + * The bottom position of the Ellipse. + * + * @name Phaser.Geom.Ellipse#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + + } + +}); + +module.exports = Ellipse; + + +/***/ }), +/* 100 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Removes a single item from an array and returns it without creating gc, like the native splice does. + * Based on code by Mike Reinstein. + * + * @function Phaser.Utils.Array.SpliceOne + * @since 3.0.0 + * + * @param {array} array - [description] + * @param {integer} index - [description] + * + * @return {*} [description] + */ +var SpliceOne = function (array, index) +{ + if (index >= array.length) + { + return; + } + + var len = array.length - 1; + + var item = array[index]; + + for (var i = index; i < len; i++) + { + array[i] = array[i + 1]; + } + + array.length = len; + + return item; +}; + +module.exports = SpliceOne; + + +/***/ }), +/* 101 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process) {/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the operating system of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.os` from within any Scene. + * + * @typedef {object} Phaser.Device.OS + * @since 3.0.0 + * + * @property {boolean} android - Is running on android? + * @property {boolean} chromeOS - Is running on chromeOS? + * @property {boolean} cocoonJS - Is the game running under CocoonJS? + * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? + * @property {boolean} cordova - Is the game running under Apache Cordova? + * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? + * @property {boolean} desktop - Is running on a desktop? + * @property {boolean} ejecta - Is the game running under Ejecta? + * @property {boolean} electron - Is the game running under GitHub Electron? + * @property {boolean} iOS - Is running on iOS? + * @property {boolean} iPad - Is running on iPad? + * @property {boolean} iPhone - Is running on iPhone? + * @property {boolean} kindle - Is running on an Amazon Kindle? + * @property {boolean} linux - Is running on linux? + * @property {boolean} macOS - Is running on macOS? + * @property {boolean} node - Is the game running under Node.js? + * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? + * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView + * @property {boolean} windows - Is running on windows? + * @property {boolean} windowsPhone - Is running on a Windows Phone? + * @property {number} iOSVersion - If running in iOS this will contain the major version number. + * @property {number} pixelRatio - PixelRatio of the host device? + */ +var OS = { + + android: false, + chromeOS: false, + cocoonJS: false, + cocoonJSApp: false, + cordova: false, + crosswalk: false, + desktop: false, + ejecta: false, + electron: false, + iOS: false, + iOSVersion: 0, + iPad: false, + iPhone: false, + kindle: false, + linux: false, + macOS: false, + node: false, + nodeWebkit: false, + pixelRatio: 1, + webApp: false, + windows: false, + windowsPhone: false + +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Windows/.test(ua)) + { + OS.windows = true; + } + else if (/Mac OS/.test(ua) && !(/like Mac OS/.test(ua))) + { + OS.macOS = true; + } + else if (/Android/.test(ua)) + { + OS.android = true; + } + else if (/Linux/.test(ua)) + { + OS.linux = true; + } + else if (/iP[ao]d|iPhone/i.test(ua)) + { + OS.iOS = true; + + (navigator.appVersion).match(/OS (\d+)/); + + OS.iOSVersion = parseInt(RegExp.$1, 10); + + OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; + OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; + } + else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) + { + OS.kindle = true; + + // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... + // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" + } + else if (/CrOS/.test(ua)) + { + OS.chromeOS = true; + } + + if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) + { + OS.android = false; + OS.iOS = false; + OS.macOS = false; + OS.windows = true; + OS.windowsPhone = true; + } + + var silk = (/Silk/).test(ua); + + if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) + { + OS.desktop = true; + } + + // Windows Phone / Table reset + if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) + { + OS.desktop = false; + } + + // WebApp mode in iOS + if (navigator.standalone) + { + OS.webApp = true; + } + + if (window.cordova !== undefined) + { + OS.cordova = true; + } + + if (typeof process !== 'undefined' && process.versions && process.versions.node) + { + OS.node = true; + } + + if (OS.node && typeof process.versions === 'object') + { + OS.nodeWebkit = !!process.versions['node-webkit']; + + OS.electron = !!process.versions.electron; + } + + if (navigator.isCocoonJS) + { + OS.cocoonJS = true; + + try + { + OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); + } + catch (error) + { + OS.cocoonJSApp = false; + } + } + + if (window.ejecta !== undefined) + { + OS.ejecta = true; + } + + if ((/Crosswalk/).test(ua)) + { + OS.crosswalk = true; + } + + OS.pixelRatio = window['devicePixelRatio'] || 1; + + return OS; +} + +module.exports = init(); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(979))) + +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback DataEachCallback + * + * @param {*} parent - The parent object of the DataManager. + * @param {string} key - The key of the value. + * @param {*} value - The value. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + */ + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManager + * @memberof Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {object} parent - The object that this DataManager belongs to. + * @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter. + */ +var DataManager = new Class({ + + initialize: + + function DataManager (parent, eventEmitter) + { + /** + * The object that this DataManager belongs to. + * + * @name Phaser.Data.DataManager#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The DataManager's event emitter. + * + * @name Phaser.Data.DataManager#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = eventEmitter; + + if (!eventEmitter) + { + this.events = (parent.events) ? parent.events : parent; + } + + /** + * The data list. + * + * @name Phaser.Data.DataManager#list + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * The public values list. You can use this to access anything you have stored + * in this Data Manager. For example, if you set a value called `gold` you can + * access it via: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also modify it directly: + * + * ```javascript + * this.data.values.gold += 1000; + * ``` + * + * Doing so will emit a `setdata` event from the parent of this Data Manager. + * + * Do not modify this object directly. Adding properties directly to this object will not + * emit any events. Always use `DataManager.set` to create new items the first time around. + * + * @name Phaser.Data.DataManager#values + * @type {Object.} + * @default {} + * @since 3.10.0 + */ + this.values = {}; + + /** + * Whether setting data is frozen for this DataManager. + * + * @name Phaser.Data.DataManager#_frozen + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._frozen = false; + + if (!parent.hasOwnProperty('sys') && this.events) + { + this.events.once('destroy', this.destroy, this); + } + }, + + /** + * Retrieves the value for the given key, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * this.data.get('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * this.data.get([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.Data.DataManager#get + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + get: function (key) + { + var list = this.list; + + if (Array.isArray(key)) + { + var output = []; + + for (var i = 0; i < key.length; i++) + { + output.push(list[key[i]]); + } + + return output; + } + else + { + return list[key]; + } + }, + + /** + * Retrieves all data values in a new object. + * + * @method Phaser.Data.DataManager#getAll + * @since 3.0.0 + * + * @return {Object.} All data values. + */ + getAll: function () + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Queries the DataManager for the values of keys matching the given regular expression. + * + * @method Phaser.Data.DataManager#query + * @since 3.0.0 + * + * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). + * + * @return {Object.} The values of the keys matching the search string. + */ + query: function (search) + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key) && key.match(search)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * data.set('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `get`: + * + * ```javascript + * data.get('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#set + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + set: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (typeof key === 'string') + { + return this.setValue(key, data); + } + else + { + for (var entry in key) + { + this.setValue(entry, key[entry]); + } + } + + return this; + }, + + /** + * Internal value setter, called automatically by the `set` method. + * + * @method Phaser.Data.DataManager#setValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * @param {*} data - The value to set. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setValue: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (this.has(key)) + { + // Hit the key getter, which will in turn emit the events. + this.values[key] = data; + } + else + { + var _this = this; + var list = this.list; + var events = this.events; + var parent = this.parent; + + Object.defineProperty(this.values, key, { + + enumerable: true, + + configurable: true, + + get: function () + { + return list[key]; + }, + + set: function (value) + { + if (!_this._frozen) + { + var previousValue = list[key]; + list[key] = value; + + events.emit('changedata', parent, key, value, previousValue); + events.emit('changedata_' + key, parent, value, previousValue); + } + } + + }); + + list[key] = data; + + events.emit('setdata', parent, key, data); + } + + return this; + }, + + /** + * Passes all data entries to the given callback. + * + * @method Phaser.Data.DataManager#each + * @since 3.0.0 + * + * @param {DataEachCallback} callback - The function to call. + * @param {*} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + each: function (callback, context) + { + var args = [ this.parent, null, undefined ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var key in this.list) + { + args[1] = key; + args[2] = this.list[key]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Merge the given object of key value pairs into this DataManager. + * + * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) + * will emit a `changedata` event. + * + * @method Phaser.Data.DataManager#merge + * @since 3.0.0 + * + * @param {Object.} data - The data to merge. + * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + merge: function (data, overwrite) + { + if (overwrite === undefined) { overwrite = true; } + + // Merge data from another component into this one + for (var key in data) + { + if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) + { + this.setValue(key, data[key]); + } + } + + return this; + }, + + /** + * Remove the value for the given key. + * + * If the key is found in this Data Manager it is removed from the internal lists and a + * `removedata` event is emitted. + * + * You can also pass in an array of keys, in which case all keys in the array will be removed: + * + * ```javascript + * this.data.remove([ 'gold', 'armor', 'health' ]); + * ``` + * + * @method Phaser.Data.DataManager#remove + * @since 3.0.0 + * + * @param {(string|string[])} key - The key to remove, or an array of keys to remove. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + remove: function (key) + { + if (this._frozen) + { + return this; + } + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.removeValue(key[i]); + } + } + else + { + return this.removeValue(key); + } + + return this; + }, + + /** + * Internal value remover, called automatically by the `remove` method. + * + * @method Phaser.Data.DataManager#removeValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + removeValue: function (key) + { + if (this.has(key)) + { + var data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this.parent, key, data); + } + + return this; + }, + + /** + * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. + * + * @method Phaser.Data.DataManager#pop + * @since 3.0.0 + * + * @param {string} key - The key of the value to retrieve and delete. + * + * @return {*} The value of the given key. + */ + pop: function (key) + { + var data = undefined; + + if (!this._frozen && this.has(key)) + { + data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this, key, data); + } + + return data; + }, + + /** + * Determines whether the given key is set in this Data Manager. + * + * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#has + * @since 3.0.0 + * + * @param {string} key - The key to check. + * + * @return {boolean} Returns `true` if the key exists, otherwise `false`. + */ + has: function (key) + { + return this.list.hasOwnProperty(key); + }, + + /** + * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts + * to create new values or update existing ones. + * + * @method Phaser.Data.DataManager#setFreeze + * @since 3.0.0 + * + * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setFreeze: function (value) + { + this._frozen = value; + + return this; + }, + + /** + * Delete all data in this Data Manager and unfreeze it. + * + * @method Phaser.Data.DataManager#reset + * @since 3.0.0 + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + reset: function () + { + for (var key in this.list) + { + delete this.list[key]; + delete this.values[key]; + } + + this._frozen = false; + + return this; + }, + + /** + * Destroy this data manager. + * + * @method Phaser.Data.DataManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + + this.events.off('changedata'); + this.events.off('setdata'); + this.events.off('removedata'); + + this.parent = null; + }, + + /** + * Gets or sets the frozen state of this Data Manager. + * A frozen Data Manager will block all attempts to create new values or update existing ones. + * + * @name Phaser.Data.DataManager#freeze + * @type {boolean} + * @since 3.0.0 + */ + freeze: { + + get: function () + { + return this._frozen; + }, + + set: function (value) + { + this._frozen = (value) ? true : false; + } + + }, + + /** + * Return the total number of entries in this Data Manager. + * + * @name Phaser.Data.DataManager#count + * @type {integer} + * @since 3.0.0 + */ + count: { + + get: function () + { + var i = 0; + + for (var key in this.list) + { + if (this.list[key] !== undefined) + { + i++; + } + } + + return i; + } + + } + +}); + +module.exports = DataManager; + + +/***/ }), +/* 103 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); + +/** + * Return a value based on the range between `min` and `max` and the percentage given. + * + * @function Phaser.Math.FromPercent + * @since 3.0.0 + * + * @param {number} percent - A value between 0 and 1 representing the percentage. + * @param {number} min - The minimum value. + * @param {number} [max] - The maximum value. + * + * @return {number} The value that is `percent` percent between `min` and `max`. + */ +var FromPercent = function (percent, min, max) +{ + percent = Clamp(percent, 0, 1); + + return (max - min) * percent; +}; + +module.exports = FromPercent; + + +/***/ }), +/* 104 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser Scale Modes. + * + * @name Phaser.ScaleModes + * @enum {integer} + * @memberof Phaser + * @readonly + * @since 3.0.0 + */ + +module.exports = { + + /** + * Default Scale Mode (Linear). + * + * @name Phaser.ScaleModes.DEFAULT + */ + DEFAULT: 0, + + /** + * Linear Scale Mode. + * + * @name Phaser.ScaleModes.LINEAR + */ + LINEAR: 0, + + /** + * Nearest Scale Mode. + * + * @name Phaser.ScaleModes.NEAREST + */ + NEAREST: 1 + +}; + + +/***/ }), +/* 105 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Defaults = __webpack_require__(138); +var GetAdvancedValue = __webpack_require__(13); +var GetBoolean = __webpack_require__(94); +var GetEaseFunction = __webpack_require__(95); +var GetNewValue = __webpack_require__(106); +var GetProps = __webpack_require__(218); +var GetTargets = __webpack_require__(140); +var GetValue = __webpack_require__(4); +var GetValueOp = __webpack_require__(139); +var Tween = __webpack_require__(137); +var TweenData = __webpack_require__(136); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.TweenBuilder + * @since 3.0.0 + * + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {object} config - [description] + * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ +var TweenBuilder = function (parent, config, defaults) +{ + if (defaults === undefined) + { + defaults = Defaults; + } + + // Create arrays of the Targets and the Properties + var targets = (defaults.targets) ? defaults.targets : GetTargets(config); + + // var props = (defaults.props) ? defaults.props : GetProps(config); + var props = GetProps(config); + + // Default Tween values + var delay = GetNewValue(config, 'delay', defaults.delay); + var duration = GetNewValue(config, 'duration', defaults.duration); + var easeParams = GetValue(config, 'easeParams', defaults.easeParams); + var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); + var hold = GetNewValue(config, 'hold', defaults.hold); + var repeat = GetNewValue(config, 'repeat', defaults.repeat); + var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + var flipX = GetBoolean(config, 'flipX', defaults.flipX); + var flipY = GetBoolean(config, 'flipY', defaults.flipY); + + var data = []; + + // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } + for (var p = 0; p < props.length; p++) + { + var key = props[p].key; + var value = props[p].value; + + // Create 1 TweenData per target, per property + for (var t = 0; t < targets.length; t++) + { + var ops = GetValueOp(key, value); + + var tweenData = TweenData( + targets[t], + key, + ops.getEnd, + ops.getStart, + GetEaseFunction(GetValue(value, 'ease', ease), easeParams), + GetNewValue(value, 'delay', delay), + GetNewValue(value, 'duration', duration), + GetBoolean(value, 'yoyo', yoyo), + GetNewValue(value, 'hold', hold), + GetNewValue(value, 'repeat', repeat), + GetNewValue(value, 'repeatDelay', repeatDelay), + GetBoolean(value, 'flipX', flipX), + GetBoolean(value, 'flipY', flipY) + ); + + data.push(tweenData); + } + } + + var tween = new Tween(parent, data, targets); + + tween.offset = GetAdvancedValue(config, 'offset', null); + tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + tween.paused = GetBoolean(config, 'paused', false); + tween.useFrames = GetBoolean(config, 'useFrames', false); + + // Set the Callbacks + var scope = GetValue(config, 'callbackScope', tween); + + // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params + var tweenArray = [ tween, null ]; + + var callbacks = Tween.TYPES; + + for (var i = 0; i < callbacks.length; i++) + { + var type = callbacks[i]; + + var callback = GetValue(config, type, false); + + if (callback) + { + var callbackScope = GetValue(config, type + 'Scope', scope); + var callbackParams = GetValue(config, type + 'Params', []); + + // The null is reset to be the Tween target + tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); + } + } + + return tween; +}; + +module.exports = TweenBuilder; + + +/***/ }), +/* 106 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetNewValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {function} [description] + */ +var GetNewValue = function (source, key, defaultValue) +{ + var valueCallback; + + if (source.hasOwnProperty(key)) + { + var t = typeof(source[key]); + + if (t === 'function') + { + valueCallback = function (index, totalTargets, target) + { + return source[key](index, totalTargets, target); + }; + } + else + { + valueCallback = function () + { + return source[key]; + }; + } + } + else if (typeof defaultValue === 'function') + { + valueCallback = defaultValue; + } + else + { + valueCallback = function () + { + return defaultValue; + }; + } + + return valueCallback; +}; + +module.exports = GetNewValue; + + +/***/ }), +/* 107 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Tileset is a combination of an image containing the tiles and a container for data about + * each tile. + * + * @class Tileset + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {string} name - The name of the tileset in the map data. + * @param {integer} firstgid - The first tile index this tileset contains. + * @param {integer} [tileWidth=32] - Width of each tile (in pixels). + * @param {integer} [tileHeight=32] - Height of each tile (in pixels). + * @param {integer} [tileMargin=0] - The margin around all tiles in the sheet (in pixels). + * @param {integer} [tileSpacing=0] - The spacing between each tile in the sheet (in pixels). + * @param {object} [tileProperties={}] - Custom properties defined per tile in the Tileset. + * These typically are custom properties created in Tiled when editing a tileset. + * @param {object} [tileData={}] - Data stored per tile. These typically are created in Tiled + * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. + */ +var Tileset = new Class({ + + initialize: + + function Tileset (name, firstgid, tileWidth, tileHeight, tileMargin, tileSpacing, tileProperties, tileData) + { + if (tileWidth === undefined || tileWidth <= 0) { tileWidth = 32; } + if (tileHeight === undefined || tileHeight <= 0) { tileHeight = 32; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (tileProperties === undefined) { tileProperties = {}; } + if (tileData === undefined) { tileData = {}; } + + /** + * The name of the Tileset. + * + * @name Phaser.Tilemaps.Tileset#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The starting index of the first tile index this Tileset contains. + * + * @name Phaser.Tilemaps.Tileset#firstgid + * @type {integer} + * @since 3.0.0 + */ + this.firstgid = firstgid; + + /** + * The width of each tile (in pixels). Use setTileSize to change. + * + * @name Phaser.Tilemaps.Tileset#tileWidth + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileWidth = tileWidth; + + /** + * The height of each tile (in pixels). Use setTileSize to change. + * + * @name Phaser.Tilemaps.Tileset#tileHeight + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileHeight = tileHeight; + + /** + * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.Tileset#tileMargin + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileMargin = tileMargin; + + /** + * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.Tileset#tileSpacing + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileSpacing = tileSpacing; + + /** + * Tileset-specific properties per tile that are typically defined in the Tiled editor in the + * Tileset editor. + * + * @name Phaser.Tilemaps.Tileset#tileProperties + * @type {object} + * @since 3.0.0 + */ + this.tileProperties = tileProperties; + + /** + * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within + * the Tileset collision editor. This is where collision objects and terrain are stored. + * + * @name Phaser.Tilemaps.Tileset#tileData + * @type {object} + * @since 3.0.0 + */ + this.tileData = tileData; + + /** + * The cached image that contains the individual tiles. Use setImage to set. + * + * @name Phaser.Tilemaps.Tileset#image + * @type {?Phaser.Textures.Texture} + * @readonly + * @since 3.0.0 + */ + this.image = null; + + /** + * The gl texture used by the WebGL renderer. + * + * @name Phaser.Tilemaps.Tileset#glTexture + * @type {?WebGLTexture} + * @readonly + * @since 3.11.0 + */ + this.glTexture = null; + + /** + * The number of tile rows in the the tileset. + * + * @name Phaser.Tilemaps.Tileset#rows + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.rows = 0; + + /** + * The number of tile columns in the tileset. + * + * @name Phaser.Tilemaps.Tileset#columns + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.columns = 0; + + /** + * The total number of tiles in the tileset. + * + * @name Phaser.Tilemaps.Tileset#total + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.total = 0; + + /** + * The look-up table to specific tile image texture coordinates (UV in pixels). Each element + * contains the coordinates for a tile in an object of the form {x, y}. + * + * @name Phaser.Tilemaps.Tileset#texCoordinates + * @type {object[]} + * @readonly + * @since 3.0.0 + */ + this.texCoordinates = []; + }, + + /** + * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. + * + * @method Phaser.Tilemaps.Tileset#getTileProperties + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?(object|undefined)} + */ + getTileProperties: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.tileProperties[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained + * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision + * info and terrain mapping. + * + * @method Phaser.Tilemaps.Tileset#getTileData + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object|undefined} + */ + getTileData: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.tileData[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. + * + * @method Phaser.Tilemaps.Tileset#getTileCollisionGroup + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} + */ + getTileCollisionGroup: function (tileIndex) + { + var data = this.getTileData(tileIndex); + + return (data && data.objectgroup) ? data.objectgroup : null; + }, + + /** + * Returns true if and only if this Tileset contains the given tile index. + * + * @method Phaser.Tilemaps.Tileset#containsTileIndex + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {boolean} + */ + containsTileIndex: function (tileIndex) + { + return ( + tileIndex >= this.firstgid && + tileIndex < (this.firstgid + this.total) + ); + }, + + /** + * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. + * Returns null if tile index is not contained in this Tileset. + * + * @method Phaser.Tilemaps.Tileset#getTileTextureCoordinates + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} Object in the form { x, y } representing the top-left UV coordinate + * within the Tileset image. + */ + getTileTextureCoordinates: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.texCoordinates[tileIndex - this.firstgid]; + }, + + /** + * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setImage + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The image that contains the tiles. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setImage: function (texture) + { + this.image = texture; + + this.glTexture = texture.get().source.glTexture; + + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + + return this; + }, + + /** + * Sets the tile width & height and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setTileSize + * @since 3.0.0 + * + * @param {integer} [tileWidth] - The width of a tile in pixels. + * @param {integer} [tileHeight] - The height of a tile in pixels. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setTileSize: function (tileWidth, tileHeight) + { + if (tileWidth !== undefined) { this.tileWidth = tileWidth; } + if (tileHeight !== undefined) { this.tileHeight = tileHeight; } + + if (this.image) + { + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setSpacing + * @since 3.0.0 + * + * @param {integer} [margin] - The margin around the tiles in the sheet (in pixels). + * @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels). + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setSpacing: function (margin, spacing) + { + if (margin !== undefined) { this.tileMargin = margin; } + if (spacing !== undefined) { this.tileSpacing = spacing; } + + if (this.image) + { + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Updates tile texture coordinates and tileset data. + * + * @method Phaser.Tilemaps.Tileset#updateTileData + * @since 3.0.0 + * + * @param {integer} imageWidth - The (expected) width of the image to slice. + * @param {integer} imageHeight - The (expected) height of the image to slice. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + updateTileData: function (imageWidth, imageHeight) + { + var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); + var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); + + if (rowCount % 1 !== 0 || colCount % 1 !== 0) + { + console.warn('Image tile area not tile size multiple in: ' + this.name); + } + + // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated + // - hence the floor when calculating the rows/columns. + rowCount = Math.floor(rowCount); + colCount = Math.floor(colCount); + + this.rows = rowCount; + this.columns = colCount; + + // In Tiled, "empty" spaces in a tileset count as tiles and hence count towards the gid + this.total = rowCount * colCount; + + this.texCoordinates.length = 0; + + var tx = this.tileMargin; + var ty = this.tileMargin; + + for (var y = 0; y < this.rows; y++) + { + for (var x = 0; x < this.columns; x++) + { + this.texCoordinates.push({ x: tx, y: ty }); + tx += this.tileWidth + this.tileSpacing; + } + + tx = this.tileMargin; + ty += this.tileHeight + this.tileSpacing; + } + + return this; + } + +}); + +module.exports = Tileset; + + +/***/ }), +/* 108 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.TileToWorldY + * @private + * @since 3.0.0 + * + * @param {integer} tileY - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} + */ +var TileToWorldY = function (tileY, camera, layer) +{ + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; + var layerWorldY = 0; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + + tileHeight *= tilemapLayer.scaleY; + } + + return layerWorldY + tileY * tileHeight; +}; + +module.exports = TileToWorldY; + + +/***/ }), +/* 109 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.TileToWorldX + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} + */ +var TileToWorldX = function (tileX, camera, layer) +{ + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + var layerWorldX = 0; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX); + + tileWidth *= tilemapLayer.scaleX; + } + + return layerWorldX + tileX * tileWidth; +}; + +module.exports = TileToWorldX; + + +/***/ }), +/* 110 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsInLayerBounds = __webpack_require__(88); + +/** + * Gets a tile at the given tile coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAt = function (tileX, tileY, nonNull, layer) +{ + if (nonNull === undefined) { nonNull = false; } + + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else if (tile.index === -1) + { + return nonNull ? tile : null; + } + else + { + return tile; + } + } + else + { + return null; + } +}; + +module.exports = GetTileAt; + + +/***/ }), +/* 111 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Components + */ + +module.exports = { + + CalculateFacesAt: __webpack_require__(145), + CalculateFacesWithin: __webpack_require__(38), + Copy: __webpack_require__(516), + CreateFromTiles: __webpack_require__(515), + CullTiles: __webpack_require__(514), + Fill: __webpack_require__(513), + FilterTiles: __webpack_require__(512), + FindByIndex: __webpack_require__(511), + FindTile: __webpack_require__(510), + ForEachTile: __webpack_require__(509), + GetTileAt: __webpack_require__(110), + GetTileAtWorldXY: __webpack_require__(508), + GetTilesWithin: __webpack_require__(19), + GetTilesWithinShape: __webpack_require__(507), + GetTilesWithinWorldXY: __webpack_require__(506), + HasTileAt: __webpack_require__(232), + HasTileAtWorldXY: __webpack_require__(505), + IsInLayerBounds: __webpack_require__(88), + PutTileAt: __webpack_require__(144), + PutTileAtWorldXY: __webpack_require__(504), + PutTilesAt: __webpack_require__(503), + Randomize: __webpack_require__(502), + RemoveTileAt: __webpack_require__(231), + RemoveTileAtWorldXY: __webpack_require__(501), + RenderDebug: __webpack_require__(500), + ReplaceByIndex: __webpack_require__(233), + SetCollision: __webpack_require__(499), + SetCollisionBetween: __webpack_require__(498), + SetCollisionByExclusion: __webpack_require__(497), + SetCollisionByProperty: __webpack_require__(496), + SetCollisionFromCollisionGroup: __webpack_require__(495), + SetTileIndexCallback: __webpack_require__(494), + SetTileLocationCallback: __webpack_require__(493), + Shuffle: __webpack_require__(492), + SwapByIndex: __webpack_require__(491), + TileToWorldX: __webpack_require__(109), + TileToWorldXY: __webpack_require__(490), + TileToWorldY: __webpack_require__(108), + WeightedRandomize: __webpack_require__(489), + WorldToTileX: __webpack_require__(54), + WorldToTileXY: __webpack_require__(488), + WorldToTileY: __webpack_require__(53) + +}; + + +/***/ }), +/* 112 */ +/***/ (function(module, exports) { + +/** +* The `Matter.Pair` module contains methods for creating and manipulating collision pairs. +* +* @class Pair +*/ + +var Pair = {}; + +module.exports = Pair; + +(function() { + + /** + * Creates a pair. + * @method create + * @param {collision} collision + * @param {number} timestamp + * @return {pair} A new pair + */ + Pair.create = function(collision, timestamp) { + var bodyA = collision.bodyA, + bodyB = collision.bodyB; + + var pair = { + id: Pair.id(bodyA, bodyB), + bodyA: bodyA, + bodyB: bodyB, + activeContacts: [], + separation: 0, + isActive: true, + confirmedActive: true, + isSensor: bodyA.isSensor || bodyB.isSensor, + timeCreated: timestamp, + timeUpdated: timestamp, + collision: null, + inverseMass: 0, + friction: 0, + frictionStatic: 0, + restitution: 0, + slop: 0 + }; + + Pair.update(pair, collision, timestamp); + + return pair; + }; + + /** + * Updates a pair given a collision. + * @method update + * @param {pair} pair + * @param {collision} collision + * @param {number} timestamp + */ + Pair.update = function(pair, collision, timestamp) { + pair.collision = collision; + + if (collision.collided) { + var supports = collision.supports, + activeContacts = pair.activeContacts, + parentA = collision.parentA, + parentB = collision.parentB; + + pair.inverseMass = parentA.inverseMass + parentB.inverseMass; + pair.friction = Math.min(parentA.friction, parentB.friction); + pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); + pair.restitution = Math.max(parentA.restitution, parentB.restitution); + pair.slop = Math.max(parentA.slop, parentB.slop); + + for (var i = 0; i < supports.length; i++) { + activeContacts[i] = supports[i].contact; + } + + // optimise array size + var supportCount = supports.length; + if (supportCount < activeContacts.length) { + activeContacts.length = supportCount; + } + + pair.separation = collision.depth; + Pair.setActive(pair, true, timestamp); + } else { + if (pair.isActive === true) + Pair.setActive(pair, false, timestamp); + } + }; + + /** + * Set a pair as active or inactive. + * @method setActive + * @param {pair} pair + * @param {bool} isActive + * @param {number} timestamp + */ + Pair.setActive = function(pair, isActive, timestamp) { + if (isActive) { + pair.isActive = true; + pair.timeUpdated = timestamp; + } else { + pair.isActive = false; + pair.activeContacts.length = 0; + } + }; + + /** + * Get the id for the given pair. + * @method id + * @param {body} bodyA + * @param {body} bodyB + * @return {string} Unique pairId + */ + Pair.id = function(bodyA, bodyB) { + if (bodyA.id < bodyB.id) { + return 'A' + bodyA.id + 'B' + bodyB.id; + } else { + return 'A' + bodyB.id + 'B' + bodyA.id; + } + }; + +})(); + + +/***/ }), +/* 113 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Matter.Components + */ + +module.exports = { + + Bounce: __webpack_require__(550), + Collision: __webpack_require__(549), + Force: __webpack_require__(548), + Friction: __webpack_require__(547), + Gravity: __webpack_require__(546), + Mass: __webpack_require__(545), + Static: __webpack_require__(544), + Sensor: __webpack_require__(543), + SetBody: __webpack_require__(542), + Sleep: __webpack_require__(540), + Transform: __webpack_require__(539), + Velocity: __webpack_require__(538) + +}; + + +/***/ }), +/* 114 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(264); +var Sprite = __webpack_require__(57); + +/** + * @classdesc + * An Arcade Physics Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.Sprite + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeSprite = new Class({ + + Extends: Sprite, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeSprite (scene, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + + /** + * This Game Object's Physics Body. + * + * @name Phaser.Physics.Arcade.Sprite#body + * @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} + * @default null + * @since 3.0.0 + */ + this.body = null; + } + +}); + +module.exports = ArcadeSprite; + + +/***/ }), +/* 115 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} XHRSettingsObject + * + * @property {XMLHttpRequestResponseType} responseType - The response type of the XHR request, i.e. `blob`, `text`, etc. + * @property {boolean} [async=true] - Should the XHR request use async or not? + * @property {string} [user=''] - Optional username for the XHR request. + * @property {string} [password=''] - Optional password for the XHR request. + * @property {integer} [timeout=0] - Optional XHR timeout value. + * @property {(string|undefined)} [header] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [headerValue] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [requestedWith] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [overrideMimeType] - Provide a custom mime-type to use instead of the default. + */ + +/** + * Creates an XHRSettings Object with default values. + * + * @function Phaser.Loader.XHRSettings + * @since 3.0.0 + * + * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. + * @param {boolean} [async=true] - Should the XHR request use async or not? + * @param {string} [user=''] - Optional username for the XHR request. + * @param {string} [password=''] - Optional password for the XHR request. + * @param {integer} [timeout=0] - Optional XHR timeout value. + * + * @return {XHRSettingsObject} The XHRSettings object as used by the Loader. + */ +var XHRSettings = function (responseType, async, user, password, timeout) +{ + if (responseType === undefined) { responseType = ''; } + if (async === undefined) { async = true; } + if (user === undefined) { user = ''; } + if (password === undefined) { password = ''; } + if (timeout === undefined) { timeout = 0; } + + // Before sending a request, set the xhr.responseType to "text", + // "arraybuffer", "blob", or "document", depending on your data needs. + // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". + + return { + + // Ignored by the Loader, only used by File. + responseType: responseType, + + async: async, + + // credentials + user: user, + password: password, + + // timeout in ms (0 = no timeout) + timeout: timeout, + + // setRequestHeader + header: undefined, + headerValue: undefined, + requestedWith: false, + + // overrideMimeType + overrideMimeType: undefined + + }; +}; + +module.exports = XHRSettings; + + +/***/ }), +/* 116 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); + +// Contains the plugins that Phaser uses globally and locally. +// These are the source objects, not instantiated. +var inputPlugins = {}; + +/** + * @typedef {object} InputPluginContainer + * + * @property {string} key - The unique name of this plugin in the input plugin cache. + * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. + * @property {string} [mapping] - If this plugin is to be injected into the Input Plugin, this is the property key map used. + */ + +var InputPluginCache = {}; + +/** + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + * + * @method Phaser.Input.InputPluginCache.register + * @since 3.10.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Input Plugin, this is the property key used. + * @param {string} settingsKey - The key in the Scene Settings to check to see if this plugin should install or not. + * @param {string} configKey - The key in the Game Config to check to see if this plugin should install or not. + */ +InputPluginCache.register = function (key, plugin, mapping, settingsKey, configKey) +{ + inputPlugins[key] = { plugin: plugin, mapping: mapping, settingsKey: settingsKey, configKey: configKey }; +}; + +/** + * Returns the input plugin object from the cache based on the given key. + * + * @method Phaser.Input.InputPluginCache.getCore + * @since 3.10.0 + * + * @param {string} key - The key of the input plugin to get. + * + * @return {InputPluginContainer} The input plugin object. + */ +InputPluginCache.getPlugin = function (key) +{ + return inputPlugins[key]; +}; + +/** + * Installs all of the registered Input Plugins into the given target. + * + * @method Phaser.Input.InputPluginCache.install + * @since 3.10.0 + * + * @param {Phaser.Input.InputPlugin} target - The target InputPlugin to install the plugins into. + */ +InputPluginCache.install = function (target) +{ + var sys = target.scene.sys; + var settings = sys.settings.input; + var config = sys.game.config; + + for (var key in inputPlugins) + { + var source = inputPlugins[key].plugin; + var mapping = inputPlugins[key].mapping; + var settingsKey = inputPlugins[key].settingsKey; + var configKey = inputPlugins[key].configKey; + + if (GetValue(settings, settingsKey, config[configKey])) + { + target[mapping] = new source(target); + } + } +}; + +/** + * Removes an input plugin based on the given key. + * + * @method Phaser.Input.InputPluginCache.remove + * @since 3.10.0 + * + * @param {string} key - The key of the input plugin to remove. + */ +InputPluginCache.remove = function (key) +{ + if (inputPlugins.hasOwnProperty(key)) + { + delete inputPlugins[key]; + } +}; + +module.exports = InputPluginCache; + + +/***/ }), +/* 117 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// This is based off an explanation and expanded math presented by Paul Bourke: +// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ + +/** + * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. + * + * @function Phaser.Geom.Intersects.LineToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line1 - The first Line to check. + * @param {Phaser.Geom.Line} line2 - The second Line to check. + * @param {Phaser.Geom.Point} [out] - A Point in which to optionally store the point of intersection. + * + * @return {boolean} `true` if the two Lines intersect, and the `out` object will be populated, if given. Otherwise, `false`. + */ +var LineToLine = function (line1, line2, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = line1.x1; + var y1 = line1.y1; + var x2 = line1.x2; + var y2 = line1.y2; + + var x3 = line2.x1; + var y3 = line2.y1; + var x4 = line2.x2; + var y4 = line2.y2; + + var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + var deNom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + + // Make sure there is not a division by zero - this also indicates that the lines are parallel. + // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). + // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). + + if (deNom === 0) + { + return false; + } + + // Calculate the intermediate fractional point that the lines potentially intersect. + + var uA = numA / deNom; + var uB = numB / deNom; + + // The fractional point will be between 0 and 1 inclusive if the lines intersect. + // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. + + if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) + { + out.x = x1 + (uA * (x2 - x1)); + out.y = y1 + (uA * (y2 - y1)); + + return true; + } + + return false; +}; + +module.exports = LineToLine; + + +/***/ }), +/* 118 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var GameObject = __webpack_require__(17); +var MeshRender = __webpack_require__(798); + +/** + * @classdesc + * A Mesh Game Object. + * + * @class Mesh + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number[]} vertices - An array containing the vertices data for this Mesh. + * @param {number[]} uv - An array containing the uv data for this Mesh. + * @param {number[]} colors - An array containing the color data for this Mesh. + * @param {number[]} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Mesh = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + MeshRender + ], + + initialize: + + function Mesh (scene, x, y, vertices, uv, colors, alphas, texture, frame) + { + GameObject.call(this, scene, 'Mesh'); + + if (vertices.length !== uv.length) + { + throw new Error('Mesh Vertex count must match UV count'); + } + + var verticesUB = (vertices.length / 2) | 0; + + if (colors.length > 0 && colors.length < verticesUB) + { + throw new Error('Mesh Color count must match Vertex count'); + } + + if (alphas.length > 0 && alphas.length < verticesUB) + { + throw new Error('Mesh Alpha count must match Vertex count'); + } + + var i; + + if (colors.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + colors[i] = 0xFFFFFF; + } + } + + if (alphas.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + alphas[i] = 1.0; + } + } + + /** + * An array containing the vertices data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#vertices + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertices = new Float32Array(vertices); + + /** + * An array containing the uv data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#uv + * @type {Float32Array} + * @since 3.0.0 + */ + this.uv = new Float32Array(uv); + + /** + * An array containing the color data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#colors + * @type {Uint32Array} + * @since 3.0.0 + */ + this.colors = new Uint32Array(colors); + + /** + * An array containing the alpha data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#alphas + * @type {Float32Array} + * @since 3.0.0 + */ + this.alphas = new Float32Array(alphas); + + /** + * Fill or additive mode used when blending the color values? + * + * @name Phaser.GameObjects.Mesh#tintFill + * @type {boolean} + * @default false + * @since 3.11.0 + */ + this.tintFill = false; + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOrigin(); + this.initPipeline(); + } + +}); + +module.exports = Mesh; + + +/***/ }), +/* 119 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var GameObject = __webpack_require__(17); +var GetBitmapTextSize = __webpack_require__(913); +var ParseFromAtlas = __webpack_require__(912); +var Render = __webpack_require__(911); + +/** + * The font data for an individual character of a Bitmap Font. + * + * Describes the character's position, size, offset and kerning. + * + * @typedef {object} BitmapFontCharacterData + * + * @property {number} x - The x position of the character. + * @property {number} y - The y position of the character. + * @property {number} width - The width of the character. + * @property {number} height - The height of the character. + * @property {number} centerX - The center x position of the character. + * @property {number} centerY - The center y position of the character. + * @property {number} xOffset - The x offset of the character. + * @property {number} yOffset - The y offset of the character. + * @property {object} data - Extra data for the character. + * @property {Object.} kerning - Kerning values, keyed by character code. + */ + +/** + * Bitmap Font data that can be used by a BitmapText Game Object. + * + * @typedef {object} BitmapFontData + * + * @property {string} font - The name of the font. + * @property {number} size - The size of the font. + * @property {number} lineHeight - The line height of the font. + * @property {boolean} retroFont - Whether this font is a retro font (monospace). + * @property {Object.} chars - The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more. + */ + +/** + * @typedef {object} JSONBitmapText + * @extends {JSONGameObject} + * + * @property {string} font - The name of the font. + * @property {string} text - The text that this Bitmap Text displays. + * @property {number} fontSize - The size of the font. + * @property {number} letterSpacing - Adds / Removes spacing between characters. + * @property {integer} align - The alignment of the text in a multi-line BitmapText object. + */ + +/** + * @classdesc + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * @class BitmapText + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} x - The x coordinate of this Game Object in world space. + * @param {number} y - The y coordinate of this Game Object in world space. + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size of this Bitmap Text. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. + */ +var BitmapText = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function BitmapText (scene, x, y, font, text, size, align) + { + if (text === undefined) { text = ''; } + if (align === undefined) { align = 0; } + + GameObject.call(this, scene, 'BitmapText'); + + /** + * The key of the Bitmap Font used by this Bitmap Text. + * To change the font after creation please use `setFont`. + * + * @name Phaser.GameObjects.BitmapText#font + * @type {string} + * @readonly + * @since 3.0.0 + */ + this.font = font; + + var entry = this.scene.sys.cache.bitmapFont.get(font); + + /** + * The data of the Bitmap Font used by this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#fontData + * @type {BitmapFontData} + * @readonly + * @since 3.0.0 + */ + this.fontData = entry.data; + + /** + * The text that this Bitmap Text object displays. + * + * @name Phaser.GameObjects.BitmapText#_text + * @type {string} + * @private + * @since 3.0.0 + */ + this._text = ''; + + /** + * The font size of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#_fontSize + * @type {number} + * @private + * @since 3.0.0 + */ + this._fontSize = size || this.fontData.size; + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * @name Phaser.GameObjects.BitmapText#_letterSpacing + * @type {number} + * @private + * @since 3.4.0 + */ + this._letterSpacing = 0; + + /** + * Controls the alignment of each line of text in this BitmapText object. + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#_align + * @type {integer} + * @private + * @since 3.11.0 + */ + this._align = align; + + /** + * An object that describes the size of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#_bounds + * @type {BitmapTextSize} + * @private + * @since 3.0.0 + */ + this._bounds = GetBitmapTextSize(this, false, this._bounds); + + /** + * An internal dirty flag for bounds calculation. + * + * @name Phaser.GameObjects.BitmapText#_dirty + * @type {boolean} + * @private + * @since 3.11.0 + */ + this._dirty = false; + + this.setTexture(entry.texture, entry.frame); + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline(); + + this.setText(text); + }, + + /** + * Set the lines of text in this BitmapText to be left-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setLeftAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setLeftAlign: function () + { + this._align = BitmapText.ALIGN_LEFT; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be center-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setCenterAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setCenterAlign: function () + { + this._align = BitmapText.ALIGN_CENTER; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be right-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setRightAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setRightAlign: function () + { + this._align = BitmapText.ALIGN_RIGHT; + + this._dirty = true; + + return this; + }, + + /** + * Set the font size of this Bitmap Text. + * + * @method Phaser.GameObjects.BitmapText#setFontSize + * @since 3.0.0 + * + * @param {number} size - The font size to set. + * + * @return {this} This BitmapText Object. + */ + setFontSize: function (size) + { + this._fontSize = size; + + this._dirty = true; + + return this; + }, + + /** + * Sets the letter spacing between each character of this Bitmap Text. + * Can be a positive value to increase the space, or negative to reduce it. + * Spacing is applied after the kerning values have been set. + * + * @method Phaser.GameObjects.BitmapText#setLetterSpacing + * @since 3.4.0 + * + * @param {number} [spacing=0] - The amount of horizontal space to add between each character. + * + * @return {this} This BitmapText Object. + */ + setLetterSpacing: function (spacing) + { + if (spacing === undefined) { spacing = 0; } + + this._letterSpacing = spacing; + + this._dirty = true; + + return this; + }, + + /** + * Set the textual content of this BitmapText. + * + * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. + * + * @method Phaser.GameObjects.BitmapText#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. + * + * @return {this} This BitmapText Object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this._text = value.toString(); + + this._dirty = true; + + this.updateDisplayOrigin(); + } + + return this; + }, + + /** + * Calculate the bounds of this Bitmap Text. + * + * An object is returned that contains the position, width and height of the Bitmap Text in local and global + * contexts. + * + * Local size is based on just the font size and a [0, 0] position. + * + * Global size takes into account the Game Object's scale, world position and display origin. + * + * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. + * + * @method Phaser.GameObjects.BitmapText#getTextBounds + * @since 3.0.0 + * + * @param {boolean} [round] - Whether to round the results to the nearest integer. + * + * @return {BitmapTextSize} An object that describes the size of this Bitmap Text. + */ + getTextBounds: function (round) + { + // local = The BitmapText based on fontSize and 0x0 coords + // global = The BitmapText, taking into account scale and world position + // lines = The BitmapText line data + + if (this._dirty) + { + GetBitmapTextSize(this, round, this._bounds); + } + + return this._bounds; + }, + + /** + * Changes the font this BitmapText is using to render. + * + * The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved, + * unless overridden via the arguments. + * + * @method Phaser.GameObjects.BitmapText#setFont + * @since 3.11.0 + * + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {number} [size] - The font size of this Bitmap Text. If not specified the current size will be used. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. + * + * @return {this} This BitmapText Object. + */ + setFont: function (key, size, align) + { + if (size === undefined) { size = this._fontSize; } + if (align === undefined) { align = this._align; } + + if (key !== this.font) + { + var entry = this.scene.sys.cache.bitmapFont.get(key); + + if (entry) + { + this.font = key; + this.fontData = entry.data; + this._fontSize = size; + this._align = align; + + this.setTexture(entry.texture, entry.frame); + + GetBitmapTextSize(this, false, this._bounds); + } + } + + return this; + }, + + /** + * Controls the alignment of each line of text in this BitmapText object. + * + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#align + * @type {integer} + * @since 3.11.0 + */ + align: { + + set: function (value) + { + this._align = value; + this._dirty = true; + }, + + get: function () + { + return this._align; + } + + }, + + /** + * The text that this Bitmap Text object displays. + * + * You can also use the method `setText` if you want a chainable way to change the text content. + * + * @name Phaser.GameObjects.BitmapText#text + * @type {string} + * @since 3.0.0 + */ + text: { + + set: function (value) + { + this.setText(value); + }, + + get: function () + { + return this._text; + } + + }, + + /** + * The font size of this Bitmap Text. + * + * You can also use the method `setFontSize` if you want a chainable way to change the font size. + * + * @name Phaser.GameObjects.BitmapText#fontSize + * @type {number} + * @since 3.0.0 + */ + fontSize: { + + set: function (value) + { + this._fontSize = value; + this._dirty = true; + }, + + get: function () + { + return this._fontSize; + } + + }, + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. + * + * @name Phaser.GameObjects.BitmapText#letterSpacing + * @type {number} + * @since 3.0.0 + */ + letterSpacing: { + + set: function (value) + { + this._letterSpacing = value; + this._dirty = true; + }, + + get: function () + { + return this._letterSpacing; + } + + }, + + /** + * The width of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#width + * @type {number} + * @readonly + * @since 3.0.0 + */ + width: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.width; + } + + }, + + /** + * The height of this bitmap text. + * + * @name Phaser.GameObjects.BitmapText#height + * @type {number} + * @readonly + * @since 3.0.0 + */ + height: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.height; + } + + }, + + /** + * Build a JSON representation of this Bitmap Text. + * + * @method Phaser.GameObjects.BitmapText#toJSON + * @since 3.0.0 + * + * @return {JSONBitmapText} A JSON representation of this Bitmap Text. + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra data is added here + + var data = { + font: this.font, + text: this.text, + fontSize: this.fontSize, + letterSpacing: this.letterSpacing, + align: this.align + }; + + out.data = data; + + return out; + } + +}); + +/** + * Left align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_LEFT + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_LEFT = 0; + +/** + * Center align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_CENTER + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_CENTER = 1; + +/** + * Right align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_RIGHT + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_RIGHT = 2; + +BitmapText.ParseFromAtlas = ParseFromAtlas; + +module.exports = BitmapText; + + +/***/ }), +/* 120 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +//! stable.js 0.1.6, https://github.com/Two-Screen/stable +//! © 2017 Angry Bytes and contributors. MIT licensed. + +(function() { + +// A stable array sort, because `Array#sort()` is not guaranteed stable. +// This is an implementation of merge sort, without recursion. + +var stable = function(arr, comp) { + return exec(arr.slice(), comp); +}; + +stable.inplace = function(arr, comp) { + var result = exec(arr, comp); + + // This simply copies back if the result isn't in the original array, + // which happens on an odd number of passes. + if (result !== arr) { + pass(result, null, arr.length, arr); + } + + return arr; +}; + +// Execute the sort using the input array and a second buffer as work space. +// Returns one of those two, containing the final result. +function exec(arr, comp) { + if (typeof(comp) !== 'function') { + comp = function(a, b) { + return String(a).localeCompare(b); + }; + } + + // Short-circuit when there's nothing to sort. + var len = arr.length; + if (len <= 1) { + return arr; + } + + // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. + // Chunks are the size of the left or right hand in merge sort. + // Stop when the left-hand covers all of the array. + var buffer = new Array(len); + for (var chk = 1; chk < len; chk *= 2) { + pass(arr, comp, chk, buffer); + + var tmp = arr; + arr = buffer; + buffer = tmp; + } + + return arr; +} + +// Run a single pass with the given chunk size. +var pass = function(arr, comp, chk, result) { + var len = arr.length; + var i = 0; + // Step size / double chunk size. + var dbl = chk * 2; + // Bounds of the left and right chunks. + var l, r, e; + // Iterators over the left and right chunk. + var li, ri; + + // Iterate over pairs of chunks. + for (l = 0; l < len; l += dbl) { + r = l + chk; + e = r + chk; + if (r > len) r = len; + if (e > len) e = len; + + // Iterate both chunks in parallel. + li = l; + ri = r; + while (true) { + // Compare the chunks. + if (li < r && ri < e) { + // This works for a regular `sort()` compatible comparator, + // but also for a simple comparator like: `a > b` + if (comp(arr[li], arr[ri]) <= 0) { + result[i++] = arr[li++]; + } + else { + result[i++] = arr[ri++]; + } + } + // Nothing to compare, just flush what's left. + else if (li < r) { + result[i++] = arr[li++]; + } + else if (ri < e) { + result[i++] = arr[ri++]; + } + // Both iterators are at the chunk ends. + else { + break; + } + } + } +}; + +// Export using CommonJS or to the window. +if (true) { + module.exports = stable; +} +else {} + +})(); + +/***/ }), +/* 121 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. + +var CheckMatrix = __webpack_require__(179); +var TransposeMatrix = __webpack_require__(343); + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateMatrix + * @since 3.0.0 + * + * @param {array} matrix - The array to rotate. + * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. + * + * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. + */ +var RotateMatrix = function (matrix, direction) +{ + if (direction === undefined) { direction = 90; } + + if (!CheckMatrix(matrix)) + { + return null; + } + + if (typeof direction !== 'string') + { + direction = ((direction % 360) + 360) % 360; + } + + if (direction === 90 || direction === -270 || direction === 'rotateLeft') + { + matrix = TransposeMatrix(matrix); + matrix.reverse(); + } + else if (direction === -90 || direction === 270 || direction === 'rotateRight') + { + matrix.reverse(); + matrix = TransposeMatrix(matrix); + } + else if (Math.abs(direction) === 180 || direction === 'rotate180') + { + for (var i = 0; i < matrix.length; i++) + { + matrix[i].reverse(); + } + + matrix.reverse(); + } + + return matrix; +}; + +module.exports = RotateMatrix; + + +/***/ }), +/* 122 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayUtils = __webpack_require__(180); +var Class = __webpack_require__(0); +var NOOP = __webpack_require__(2); +var StableSort = __webpack_require__(120); + +/** + * @callback EachListCallback + * @generic I - [item] + * + * @param {*} item - The item which is currently being processed. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + +/** + * @classdesc + * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. + * + * @class List + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + * + * @param {*} parent - The parent of this list. + */ +var List = new Class({ + + initialize: + + function List (parent) + { + /** + * The parent of this list. + * + * @name Phaser.Structs.List#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The objects that belong to this collection. + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.List#list + * @type {Array.<*>} + * @default [] + * @since 3.0.0 + */ + this.list = []; + + /** + * The index of the current element. + * + * This is used internally when iterating through the list with the {@link #first}, {@link #last}, {@link #get}, and {@link #previous} properties. + * + * @name Phaser.Structs.List#position + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.position = 0; + + /** + * A callback that is invoked every time a child is added to this list. + * + * @name Phaser.Structs.List#addCallback + * @type {function} + * @since 3.4.0 + */ + this.addCallback = NOOP; + + /** + * A callback that is invoked every time a child is removed from this list. + * + * @name Phaser.Structs.List#removeCallback + * @type {function} + * @since 3.4.0 + */ + this.removeCallback = NOOP; + + /** + * The property key to sort by. + * + * @name Phaser.Structs.List#_sortKey + * @type {string} + * @since 3.4.0 + */ + this._sortKey = ''; + }, + + /** + * Adds the given item to the end of the list. Each item must be unique. + * + * @method Phaser.Structs.List#add + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*|Array.<*>} child - The item, or array of items, to add to the list. + * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. + * + * @return {*} The list's underlying array. + */ + add: function (child, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.Add(this.list, child); + } + else + { + return ArrayUtils.Add(this.list, child, 0, this.addCallback, this); + } + }, + + /** + * Adds an item to list, starting at a specified index. Each item must be unique within the list. + * + * @method Phaser.Structs.List#addAt + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item, or array of items, to add to the list. + * @param {integer} [index=0] - The index in the list at which the element(s) will be inserted. + * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. + * + * @return {*} The List's underlying array. + */ + addAt: function (child, index, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.AddAt(this.list, child, index); + } + else + { + return ArrayUtils.AddAt(this.list, child, index, 0, this.addCallback, this); + } + }, + + /** + * Retrieves the item at a given position inside the List. + * + * @method Phaser.Structs.List#getAt + * @since 3.0.0 + * + * @genericUse {T} - [$return] + * + * @param {integer} index - The index of the item. + * + * @return {*} The retrieved item, or `undefined` if it's outside the List's bounds. + */ + getAt: function (index) + { + return this.list[index]; + }, + + /** + * Locates an item within the List and returns its index. + * + * @method Phaser.Structs.List#getIndex + * @since 3.0.0 + * + * @genericUse {T} - [child] + * + * @param {*} child - The item to locate. + * + * @return {integer} The index of the item within the List, or -1 if it's not in the List. + */ + getIndex: function (child) + { + // Return -1 if given child isn't a child of this display list + return this.list.indexOf(child); + }, + + /** + * Sort the contents of this List so the items are in order based + * on the given property. For example, `sort('alpha')` would sort the List + * contents based on the value of their `alpha` property. + * + * @method Phaser.Structs.List#sort + * @since 3.0.0 + * + * @genericUse {T[]} - [children,$return] + * + * @param {string} property - The property to lexically sort by. + * + * @return {Phaser.Structs.List} This List object. + */ + sort: function (property) + { + if (property) + { + this._sortKey = property; + + StableSort.inplace(this.list, this.sortHandler); + } + + return this; + }, + + /** + * Internal handler for the {@link #sort} method which compares two items. + * + * @method Phaser.Structs.List#sortHandler + * @private + * @since 3.4.0 + * + * @genericUse {T} - [childA,childB] + * + * @param {*} childA - The first item to compare. + * @param {*} childB - The second item to compare. + * + * @return {integer} The result of the comparison, which will be negative if the first item is smaller then second, positive if the first item is larger than the second, or 0 if they're equal. + */ + sortHandler: function (childA, childB) + { + return childA[this._sortKey] - childB[this._sortKey]; + }, + + /** + * Searches for the first instance of a child with its `name` + * property matching the given argument. Should more than one child have + * the same name only the first is returned. + * + * @method Phaser.Structs.List#getByName + * @since 3.0.0 + * + * @genericUse {T | null} - [$return] + * + * @param {string} name - The name to search for. + * + * @return {?*} The first child with a matching name, or null if none were found. + */ + getByName: function (name) + { + return ArrayUtils.GetFirst(this.list, 'name', name); + }, + + /** + * Returns a random child from the group. + * + * @method Phaser.Structs.List#getRandom + * @since 3.0.0 + * + * @genericUse {T | null} - [$return] + * + * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child). + * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from. + * + * @return {?*} A random child of this Group. + */ + getRandom: function (startIndex, length) + { + return ArrayUtils.GetRandom(this.list, startIndex, length); + }, + + /** + * Returns the first element in a given part of the List which matches a specific criterion. + * + * @method Phaser.Structs.List#getFirst + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {T | null} - [$return] + * + * @param {string} property - The name of the property to test or a falsey value to have no criterion. + * @param {*} value - The value to test the `property` against, or `undefined` to allow any value and only check for existence. + * @param {number} [startIndex=0] - The position in the List to start the search at. + * @param {number} [endIndex] - The position in the List to optionally stop the search at. It won't be checked. + * + * @return {?*} The first item which matches the given criterion, or `null` if no such item exists. + */ + getFirst: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns all children in this List. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('parent')` would return only children that have a property called `parent`. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only children that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this List had 100 children, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 children in the List. + * + * @method Phaser.Structs.List#getAll + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {T[]} - [$return] + * + * @param {string} [property] - An optional property to test against the value argument. + * @param {*} [value] - If property is set then Child.property must strictly equal this value to be included in the results. + * @param {integer} [startIndex] - The first child index to start the search from. + * @param {integer} [endIndex] - The last child index to search up until. + * + * @return {Array.<*>} All items of the List which match the given criterion, if any. + */ + getAll: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns the total number of items in the List which have a property matching the given value. + * + * @method Phaser.Structs.List#count + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {string} property - The property to test on each item. + * @param {*} value - The value to test the property against. + * + * @return {integer} The total number of matching elements. + */ + count: function (property, value) + { + return ArrayUtils.CountAllMatching(this.list, property, value); + }, + + /** + * Swaps the positions of two items in the list. + * + * @method Phaser.Structs.List#swap + * @since 3.0.0 + * + * @genericUse {T} - [child1,child2] + * + * @param {*} child1 - The first item to swap. + * @param {*} child2 - The second item to swap. + */ + swap: function (child1, child2) + { + ArrayUtils.Swap(this.list, child1, child2); + }, + + /** + * Moves an item in the List to a new position. + * + * @method Phaser.Structs.List#moveTo + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to move. + * @param {integer} index - Moves an item in the List to a new position. + * + * @return {*} The item that was moved. + */ + moveTo: function (child, index) + { + return ArrayUtils.MoveTo(this.list, child, index); + }, + + /** + * Removes one or many items from the List. + * + * @method Phaser.Structs.List#remove + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item, or array of items, to remove. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {*} The item, or array of items, which were successfully removed from the List. + */ + remove: function (child, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.Remove(this.list, child); + } + else + { + return ArrayUtils.Remove(this.list, child, this.removeCallback, this); + } + }, + + /** + * Removes the item at the given position in the List. + * + * @method Phaser.Structs.List#removeAt + * @since 3.0.0 + * + * @genericUse {T} - [$return] + * + * @param {integer} index - The position to remove the item from. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {*} The item that was removed. + */ + removeAt: function (index, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.RemoveAt(this.list, index); + } + else + { + return ArrayUtils.RemoveAt(this.list, index, this.removeCallback, this); + } + }, + + /** + * Removes the items within the given range in the List. + * + * @method Phaser.Structs.List#removeBetween + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @param {integer} [startIndex=0] - The index to start removing from. + * @param {integer} [endIndex] - The position to stop removing at. The item at this position won't be removed. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {Array.<*>} An array of the items which were removed.[description] + */ + removeBetween: function (startIndex, endIndex, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex); + } + else + { + return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeCallback, this); + } + }, + + /** + * Removes all the items. + * + * @method Phaser.Structs.List#removeAll + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.List.} - [$return] + * + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {Phaser.Structs.List} This List object. + */ + removeAll: function (skipCallback) + { + var i = this.list.length; + + while (i--) + { + this.remove(this.list[i], skipCallback); + } + + return this; + }, + + /** + * Brings the given child to the top of this List. + * + * @method Phaser.Structs.List#bringToTop + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to bring to the top of the List. + * + * @return {*} The item which was moved. + */ + bringToTop: function (child) + { + return ArrayUtils.BringToTop(this.list, child); + }, + + /** + * Sends the given child to the bottom of this List. + * + * @method Phaser.Structs.List#sendToBack + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to send to the back of the list. + * + * @return {*} The item which was moved. + */ + sendToBack: function (child) + { + return ArrayUtils.SendToBack(this.list, child); + }, + + /** + * Moves the given child up one place in this group unless it's already at the top. + * + * @method Phaser.Structs.List#moveUp + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to move up. + * + * @return {*} The item which was moved. + */ + moveUp: function (child) + { + ArrayUtils.MoveUp(this.list, child); + + return child; + }, + + /** + * Moves the given child down one place in this group unless it's already at the bottom. + * + * @method Phaser.Structs.List#moveDown + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to move down. + * + * @return {*} The item which was moved. + */ + moveDown: function (child) + { + ArrayUtils.MoveDown(this.list, child); + + return child; + }, + + /** + * Reverses the order of all children in this List. + * + * @method Phaser.Structs.List#reverse + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.List.} - [$return] + * + * @return {Phaser.Structs.List} This List object. + */ + reverse: function () + { + this.list.reverse(); + + return this; + }, + + /** + * Shuffles the items in the list. + * + * @method Phaser.Structs.List#shuffle + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.List.} - [$return] + * + * @return {Phaser.Structs.List} This List object. + */ + shuffle: function () + { + ArrayUtils.Shuffle(this.list); + + return this; + }, + + /** + * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. + * + * @method Phaser.Structs.List#replace + * @since 3.0.0 + * + * @genericUse {T} - [oldChild,newChild,$return] + * + * @param {*} oldChild - The child in this List that will be replaced. + * @param {*} newChild - The child to be inserted into this List. + * + * @return {*} Returns the oldChild that was replaced within this group. + */ + replace: function (oldChild, newChild) + { + return ArrayUtils.Replace(this.list, oldChild, newChild); + }, + + /** + * Checks if an item exists within the List. + * + * @method Phaser.Structs.List#exists + * @since 3.0.0 + * + * @genericUse {T} - [child] + * + * @param {*} child - The item to check for the existence of. + * + * @return {boolean} `true` if the item is found in the list, otherwise `false`. + */ + exists: function (child) + { + return (this.list.indexOf(child) > -1); + }, + + /** + * Sets the property `key` to the given value on all members of this List. + * + * @method Phaser.Structs.List#setAll + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {string} property - The name of the property to set. + * @param {*} value - The value to set the property to. + * @param {integer} [startIndex] - The first child index to start the search from. + * @param {integer} [endIndex] - The last child index to search up until. + */ + setAll: function (property, value, startIndex, endIndex) + { + ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); + + return this; + }, + + /** + * Passes all children to the given callback. + * + * @method Phaser.Structs.List#each + * @since 3.0.0 + * + * @genericUse {EachListCallback.} - [callback] + * + * @param {EachListCallback} callback - The function to call. + * @param {*} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + each: function (callback, context) + { + var args = [ null ]; + + for (var i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < this.list.length; i++) + { + args[0] = this.list[i]; + + callback.apply(context, args); + } + }, + + /** + * Clears the List and recreates its internal array. + * + * @method Phaser.Structs.List#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAll(); + + this.list = []; + }, + + /** + * Destroys this List. + * + * @method Phaser.Structs.List#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAll(); + + this.parent = null; + this.addCallback = null; + this.removeCallback = null; + }, + + /** + * The number of items inside the List. + * + * @name Phaser.Structs.List#length + * @type {integer} + * @readonly + * @since 3.0.0 + */ + length: { + + get: function () + { + return this.list.length; + } + + }, + + /** + * The first item in the List or `null` for an empty List. + * + * @name Phaser.Structs.List#first + * @type {integer} + * @readonly + * @since 3.0.0 + */ + first: { + + get: function () + { + this.position = 0; + + if (this.list.length > 0) + { + return this.list[0]; + } + else + { + return null; + } + } + + }, + + /** + * The last item in the List, or `null` for an empty List. + * + * @name Phaser.Structs.List#last + * @type {integer} + * @readonly + * @since 3.0.0 + */ + last: { + + get: function () + { + if (this.list.length > 0) + { + this.position = this.list.length - 1; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * The next item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #first} or manually setting the {@link #position} to iterate the List. + * + * @name Phaser.Structs.List#next + * @type {integer} + * @readonly + * @since 3.0.0 + */ + next: { + + get: function () + { + if (this.position < this.list.length) + { + this.position++; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * The previous item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #last} or manually setting the {@link #position} to iterate the List backwards. + * + * @name Phaser.Structs.List#previous + * @type {integer} + * @readonly + * @since 3.0.0 + */ + previous: { + + get: function () + { + if (this.position > 0) + { + this.position--; + + return this.list[this.position]; + } + else + { + return null; + } + } + + } + +}); + +module.exports = List; + + +/***/ }), +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Clamp = __webpack_require__(24); +var Extend = __webpack_require__(21); + +/** + * @classdesc + * A Frame is a section of a Texture. + * + * @class Frame + * @memberof Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. + * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. + * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. + * @param {number} x - The x coordinate of the top-left of this Frame. + * @param {number} y - The y coordinate of the top-left of this Frame. + * @param {number} width - The width of this Frame. + * @param {number} height - The height of this Frame. + */ +var Frame = new Class({ + + initialize: + + function Frame (texture, name, sourceIndex, x, y, width, height) + { + /** + * The Texture this Frame is a part of. + * + * @name Phaser.Textures.Frame#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = texture; + + /** + * The name of this Frame. + * The name is unique within the Texture. + * + * @name Phaser.Textures.Frame#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The TextureSource this Frame is part of. + * + * @name Phaser.Textures.Frame#source + * @type {Phaser.Textures.TextureSource} + * @since 3.0.0 + */ + this.source = texture.source[sourceIndex]; + + /** + * The index of the TextureSource in the Texture sources array. + * + * @name Phaser.Textures.Frame#sourceIndex + * @type {integer} + * @since 3.0.0 + */ + this.sourceIndex = sourceIndex; + + /** + * A reference to the Texture Source WebGL Texture that this Frame is using. + * + * @name Phaser.Textures.Frame#glTexture + * @type {?WebGLTexture} + * @default null + * @since 3.11.0 + */ + this.glTexture = this.source.glTexture; + + /** + * X position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutX + * @type {integer} + * @since 3.0.0 + */ + this.cutX; + + /** + * Y position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutY + * @type {integer} + * @since 3.0.0 + */ + this.cutY; + + /** + * The width of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutWidth + * @type {integer} + * @since 3.0.0 + */ + this.cutWidth; + + /** + * The height of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutHeight + * @type {integer} + * @since 3.0.0 + */ + this.cutHeight; + + /** + * The X rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#x + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The Y rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#y + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The rendering width of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#width + * @type {integer} + * @since 3.0.0 + */ + this.width; + + /** + * The rendering height of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#height + * @type {integer} + * @since 3.0.0 + */ + this.height; + + /** + * Half the width, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfWidth + * @type {integer} + * @since 3.0.0 + */ + this.halfWidth; + + /** + * Half the height, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfHeight + * @type {integer} + * @since 3.0.0 + */ + this.halfHeight; + + /** + * The x center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerX + * @type {integer} + * @since 3.0.0 + */ + this.centerX; + + /** + * The y center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerY + * @type {integer} + * @since 3.0.0 + */ + this.centerY; + + /** + * The horizontal pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotX = 0; + + /** + * The vertical pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotY = 0; + + /** + * Does this Frame have a custom pivot point? + * + * @name Phaser.Textures.Frame#customPivot + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customPivot = false; + + /** + * **CURRENTLY UNSUPPORTED** + * + * Is this frame is rotated or not in the Texture? + * Rotation allows you to use rotated frames in texture atlas packing. + * It has nothing to do with Sprite rotation. + * + * @name Phaser.Textures.Frame#rotated + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotated = false; + + /** + * Over-rides the Renderer setting. + * -1 = use Renderer Setting + * 0 = No rounding + * 1 = Round + * + * @name Phaser.Textures.Frame#autoRound + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.autoRound = -1; + + /** + * Any Frame specific custom data can be stored here. + * + * @name Phaser.Textures.Frame#customData + * @type {object} + * @since 3.0.0 + */ + this.customData = {}; + + /** + * WebGL UV u0 value. + * + * @name Phaser.Textures.Frame#u0 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.u0 = 0; + + /** + * WebGL UV v0 value. + * + * @name Phaser.Textures.Frame#v0 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.v0 = 0; + + /** + * WebGL UV u1 value. + * + * @name Phaser.Textures.Frame#u1 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.u1 = 0; + + /** + * WebGL UV v1 value. + * + * @name Phaser.Textures.Frame#v1 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.v1 = 0; + + /** + * The un-modified source frame, trim and UV data. + * + * @name Phaser.Textures.Frame#data + * @type {object} + * @private + * @since 3.0.0 + */ + this.data = { + cut: { + x: 0, + y: 0, + w: 0, + h: 0, + r: 0, + b: 0 + }, + trim: false, + sourceSize: { + w: 0, + h: 0 + }, + spriteSourceSize: { + x: 0, + y: 0, + w: 0, + h: 0, + r: 0, + b: 0 + }, + radius: 0, + drawImage: { + x: 0, + y: 0, + width: 0, + height: 0 + } + }; + + this.setSize(width, height, x, y); + }, + + /** + * Sets the width, height, x and y of this Frame. + * + * This is called automatically by the constructor + * and should rarely be changed on-the-fly. + * + * @method Phaser.Textures.Frame#setSize + * @since 3.7.0 + * + * @param {integer} width - The width of the frame before being trimmed. + * @param {integer} height - The height of the frame before being trimmed. + * @param {integer} [x=0] - The x coordinate of the top-left of this Frame. + * @param {integer} [y=0] - The y coordinate of the top-left of this Frame. + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + setSize: function (width, height, x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + this.cutX = x; + this.cutY = y; + this.cutWidth = width; + this.cutHeight = height; + + this.width = width; + this.height = height; + + this.halfWidth = Math.floor(width * 0.5); + this.halfHeight = Math.floor(height * 0.5); + + this.centerX = Math.floor(width / 2); + this.centerY = Math.floor(height / 2); + + var data = this.data; + var cut = data.cut; + + cut.x = x; + cut.y = y; + cut.w = width; + cut.h = height; + cut.r = x + width; + cut.b = y + height; + + data.sourceSize.w = width; + data.sourceSize.h = height; + + data.spriteSourceSize.w = width; + data.spriteSourceSize.h = height; + + data.radius = 0.5 * Math.sqrt(width * width + height * height); + + var drawImage = data.drawImage; + + drawImage.x = x; + drawImage.y = y; + drawImage.width = width; + drawImage.height = height; + + return this.updateUVs(); + }, + + /** + * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. + * + * @method Phaser.Textures.Frame#setTrim + * @since 3.0.0 + * + * @param {number} actualWidth - The width of the frame before being trimmed. + * @param {number} actualHeight - The height of the frame before being trimmed. + * @param {number} destX - The destination X position of the trimmed frame for display. + * @param {number} destY - The destination Y position of the trimmed frame for display. + * @param {number} destWidth - The destination width of the trimmed frame for display. + * @param {number} destHeight - The destination height of the trimmed frame for display. + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) + { + var data = this.data; + var ss = data.spriteSourceSize; + + // Store actual values + + data.trim = true; + + data.sourceSize.w = actualWidth; + data.sourceSize.h = actualHeight; + + ss.x = destX; + ss.y = destY; + ss.w = destWidth; + ss.h = destHeight; + ss.r = destX + destWidth; + ss.b = destY + destHeight; + + // Adjust properties + this.x = destX; + this.y = destY; + + this.width = destWidth; + this.height = destHeight; + + this.halfWidth = destWidth * 0.5; + this.halfHeight = destHeight * 0.5; + + this.centerX = Math.floor(destWidth / 2); + this.centerY = Math.floor(destHeight / 2); + + return this.updateUVs(); + }, + + /** + * Takes a crop data object and, based on the rectangular region given, calculates the + * required UV coordinates in order to crop this Frame for WebGL and Canvas rendering. + * + * This is called directly by the Game Object Texture Components `setCrop` method. + * Please use that method to crop a Game Object. + * + * @method Phaser.Textures.Frame#setCropUVs + * @since 3.11.0 + * + * @param {object} crop - The crop data object. This is the `GameObject._crop` property. + * @param {number} x - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. + * @param {number} y - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param {number} width - The width of the crop rectangle. Cannot exceed the Frame width. + * @param {number} height - The height of the crop rectangle. Cannot exceed the Frame height. + * @param {boolean} flipX - Does the parent Game Object have flipX set? + * @param {boolean} flipY - Does the parent Game Object have flipY set? + * + * @return {object} The updated crop data object. + */ + setCropUVs: function (crop, x, y, width, height, flipX, flipY) + { + // Clamp the input values + + var cx = this.cutX; + var cy = this.cutY; + var cw = this.cutWidth; + var ch = this.cutHeight; + var rw = this.realWidth; + var rh = this.realHeight; + + x = Clamp(x, 0, rw); + y = Clamp(y, 0, rh); + + width = Clamp(width, 0, rw - x); + height = Clamp(height, 0, rh - y); + + var ox = cx + x; + var oy = cy + y; + var ow = width; + var oh = height; + + var data = this.data; + + if (data.trim) + { + var ss = data.spriteSourceSize; + + // Need to check for intersection between the cut area and the crop area + // If there is none, we set UV to be empty, otherwise set it to be the intersection area + + width = Clamp(width, 0, cw - x); + height = Clamp(height, 0, ch - y); + + var cropRight = x + width; + var cropBottom = y + height; + + var intersects = !(ss.r < x || ss.b < y || ss.x > cropRight || ss.y > cropBottom); + + if (intersects) + { + var ix = Math.max(ss.x, x); + var iy = Math.max(ss.y, y); + var iw = Math.min(ss.r, cropRight) - ix; + var ih = Math.min(ss.b, cropBottom) - iy; + + ow = iw; + oh = ih; + + if (flipX) + { + ox = cx + (cw - (ix - ss.x) - iw); + } + else + { + ox = cx + (ix - ss.x); + } + + if (flipY) + { + oy = cy + (ch - (iy - ss.y) - ih); + } + else + { + oy = cy + (iy - ss.y); + } + + x = ix; + y = iy; + + width = iw; + height = ih; + } + else + { + ox = 0; + oy = 0; + ow = 0; + oh = 0; + } + } + else + { + if (flipX) + { + ox = cx + (cw - x - width); + } + + if (flipY) + { + oy = cy + (ch - y - height); + } + } + + var tw = this.source.width; + var th = this.source.height; + + // Map the given coordinates into UV space, clamping to the 0-1 range. + + crop.u0 = Math.max(0, ox / tw); + crop.v0 = Math.max(0, oy / th); + crop.u1 = Math.min(1, (ox + ow) / tw); + crop.v1 = Math.min(1, (oy + oh) / th); + + crop.x = x; + crop.y = y; + + crop.cx = ox; + crop.cy = oy; + crop.cw = ow; + crop.ch = oh; + + crop.width = width; + crop.height = height; + + crop.flipX = flipX; + crop.flipY = flipY; + + return crop; + }, + + /** + * Takes a crop data object and recalculates the UVs based on the dimensions inside the crop object. + * Called automatically by `setFrame`. + * + * @method Phaser.Textures.Frame#updateCropUVs + * @since 3.11.0 + * + * @param {object} crop - The crop data object. This is the `GameObject._crop` property. + * @param {boolean} flipX - Does the parent Game Object have flipX set? + * @param {boolean} flipY - Does the parent Game Object have flipY set? + * + * @return {object} The updated crop data object. + */ + updateCropUVs: function (crop, flipX, flipY) + { + return this.setCropUVs(crop, crop.x, crop.y, crop.width, crop.height, flipX, flipY); + }, + + /** + * Updates the internal WebGL UV cache and the drawImage cache. + * + * @method Phaser.Textures.Frame#updateUVs + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVs: function () + { + var cx = this.cutX; + var cy = this.cutY; + var cw = this.cutWidth; + var ch = this.cutHeight; + + // Canvas data + + var cd = this.data.drawImage; + + cd.width = cw; + cd.height = ch; + + // WebGL data + + var tw = this.source.width; + var th = this.source.height; + + this.u0 = cx / tw; + this.v0 = cy / th; + + this.u1 = (cx + cw) / tw; + this.v1 = (cy + ch) / th; + + return this; + }, + + /** + * Updates the internal WebGL UV cache. + * + * @method Phaser.Textures.Frame#updateUVsInverted + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVsInverted: function () + { + var tw = this.source.width; + var th = this.source.height; + + this.u0 = (this.cutX + this.cutHeight) / tw; + this.v0 = this.cutY / th; + + this.u1 = this.cutX / tw; + this.v1 = (this.cutY + this.cutWidth) / th; + + return this; + }, + + /** + * Clones this Frame into a new Frame object. + * + * @method Phaser.Textures.Frame#clone + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} A clone of this Frame. + */ + clone: function () + { + var clone = new Frame(this.texture, this.name, this.sourceIndex); + + clone.cutX = this.cutX; + clone.cutY = this.cutY; + clone.cutWidth = this.cutWidth; + clone.cutHeight = this.cutHeight; + + clone.x = this.x; + clone.y = this.y; + + clone.width = this.width; + clone.height = this.height; + + clone.halfWidth = this.halfWidth; + clone.halfHeight = this.halfHeight; + + clone.centerX = this.centerX; + clone.centerY = this.centerY; + + clone.rotated = this.rotated; + + clone.data = Extend(true, clone.data, this.data); + + clone.updateUVs(); + + return clone; + }, + + /** + * Destroys this Frames references. + * + * @method Phaser.Textures.Frame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.texture = null; + + this.source = null; + }, + + /** + * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realWidth + * @type {number} + * @readonly + * @since 3.0.0 + */ + realWidth: { + + get: function () + { + return this.data.sourceSize.w; + } + + }, + + /** + * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realHeight + * @type {number} + * @readonly + * @since 3.0.0 + */ + realHeight: { + + get: function () + { + return this.data.sourceSize.h; + } + + }, + + /** + * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) + * + * @name Phaser.Textures.Frame#radius + * @type {number} + * @readonly + * @since 3.0.0 + */ + radius: { + + get: function () + { + return this.data.radius; + } + + }, + + /** + * Is the Frame trimmed or not? + * + * @name Phaser.Textures.Frame#trimmed + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + trimmed: { + + get: function () + { + return this.data.trim; + } + + }, + + /** + * The Canvas drawImage data object. + * + * @name Phaser.Textures.Frame#canvasData + * @type {object} + * @readonly + * @since 3.0.0 + */ + canvasData: { + + get: function () + { + return this.data.drawImage; + } + + } + +}); + +module.exports = Frame; + + +/***/ }), +/* 124 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var Extend = __webpack_require__(21); +var NOOP = __webpack_require__(2); + +/** + * @classdesc + * Class containing all the shared state and behavior of a sound object, independent of the implementation. + * + * @class BaseSound + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + */ +var BaseSound = new Class({ + + Extends: EventEmitter, + + initialize: + + function BaseSound (manager, key, config) + { + EventEmitter.call(this); + + /** + * Local reference to the sound manager. + * + * @name Phaser.Sound.BaseSound#manager + * @type {Phaser.Sound.BaseSoundManager} + * @private + * @since 3.0.0 + */ + this.manager = manager; + + /** + * Asset key for the sound. + * + * @name Phaser.Sound.BaseSound#key + * @type {string} + * @readonly + * @since 3.0.0 + */ + this.key = key; + + /** + * Flag indicating if sound is currently playing. + * + * @name Phaser.Sound.BaseSound#isPlaying + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isPlaying = false; + + /** + * Flag indicating if sound is currently paused. + * + * @name Phaser.Sound.BaseSound#isPaused + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isPaused = false; + + /** + * A property that holds the value of sound's actual playback rate, + * after its rate and detune values has been combined with global + * rate and detune values. + * + * @name Phaser.Sound.BaseSound#totalRate + * @type {number} + * @default 1 + * @readonly + * @since 3.0.0 + */ + this.totalRate = 1; + + /** + * A value representing the duration, in seconds. + * It could be total sound duration or a marker duration. + * + * @name Phaser.Sound.BaseSound#duration + * @type {number} + * @readonly + * @since 3.0.0 + */ + this.duration = this.duration || 0; + + /** + * The total duration of the sound in seconds. + * + * @name Phaser.Sound.BaseSound#totalDuration + * @type {number} + * @readonly + * @since 3.0.0 + */ + this.totalDuration = this.totalDuration || 0; + + /** + * A config object used to store default sound settings' values. + * Default values will be set by properties' setters. + * + * @name Phaser.Sound.BaseSound#config + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.config = { + + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + + }; + + /** + * Reference to the currently used config. + * It could be default config or marker config. + * + * @name Phaser.Sound.BaseSound#currentConfig + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.currentConfig = this.config; + + this.config = Extend(this.config, config); + + /** + * Object containing markers definitions. + * + * @name Phaser.Sound.BaseSound#markers + * @type {Object.} + * @default {} + * @readonly + * @since 3.0.0 + */ + this.markers = {}; + + /** + * Currently playing marker. + * 'null' if whole sound is playing. + * + * @name Phaser.Sound.BaseSound#currentMarker + * @type {SoundMarker} + * @default null + * @readonly + * @since 3.0.0 + */ + this.currentMarker = null; + + /** + * Flag indicating if destroy method was called on this sound. + * + * @name Phaser.Sound.BaseSound#pendingRemove + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.pendingRemove = false; + }, + + /** + * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. + * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. + * + * @method Phaser.Sound.BaseSound#addMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object. + * + * @return {boolean} Whether the marker was added successfully. + */ + addMarker: function (marker) + { + if (!marker || !marker.name || typeof marker.name !== 'string') + { + return false; + } + + if (this.markers[marker.name]) + { + // eslint-disable-next-line no-console + console.error('addMarker ' + marker.name + ' already exists in Sound'); + + return false; + } + + marker = Extend(true, { + name: '', + start: 0, + duration: this.totalDuration - (marker.start || 0), + config: { + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + } + }, marker); + + this.markers[marker.name] = marker; + + return true; + }, + + /** + * Updates previously added marker. + * + * @method Phaser.Sound.BaseSound#updateMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object with updated values. + * + * @return {boolean} Whether the marker was updated successfully. + */ + updateMarker: function (marker) + { + if (!marker || !marker.name || typeof marker.name !== 'string') + { + return false; + } + + if (!this.markers[marker.name]) + { + // eslint-disable-next-line no-console + console.warn('Audio Marker: ' + marker.name + ' missing in Sound: ' + this.key); + + return false; + } + + this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); + + return true; + }, + + /** + * Removes a marker from the sound. + * + * @method Phaser.Sound.BaseSound#removeMarker + * @since 3.0.0 + * + * @param {string} markerName - The name of the marker to remove. + * + * @return {?SoundMarker} Removed marker object or 'null' if there was no marker with provided name. + */ + removeMarker: function (markerName) + { + var marker = this.markers[markerName]; + + if (!marker) + { + return null; + } + + this.markers[markerName] = null; + + return marker; + }, + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * + * @method Phaser.Sound.BaseSound#play + * @since 3.0.0 + * + * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. + * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (markerName, config) + { + if (markerName === undefined) { markerName = ''; } + + if (typeof markerName === 'object') + { + config = markerName; + markerName = ''; + } + + if (typeof markerName !== 'string') + { + return false; + } + + if (!markerName) + { + this.currentMarker = null; + this.currentConfig = this.config; + this.duration = this.totalDuration; + } + else + { + if (!this.markers[markerName]) + { + // eslint-disable-next-line no-console + console.warn('Marker: ' + markerName + ' missing in Sound: ' + this.key); + + return false; + } + + this.currentMarker = this.markers[markerName]; + this.currentConfig = this.currentMarker.config; + this.duration = this.currentMarker.duration; + } + + this.resetConfig(); + + this.currentConfig = Extend(this.currentConfig, config); + + this.isPlaying = true; + this.isPaused = false; + + return true; + }, + + /** + * Pauses the sound. + * + * @method Phaser.Sound.BaseSound#pause + * @since 3.0.0 + * + * @return {boolean} Whether the sound was paused successfully. + */ + pause: function () + { + if (this.isPaused || !this.isPlaying) + { + return false; + } + + this.isPlaying = false; + this.isPaused = true; + + return true; + }, + + /** + * Resumes the sound. + * + * @method Phaser.Sound.BaseSound#resume + * @since 3.0.0 + * + * @return {boolean} Whether the sound was resumed successfully. + */ + resume: function () + { + if (!this.isPaused || this.isPlaying) + { + return false; + } + + this.isPlaying = true; + this.isPaused = false; + + return true; + }, + + /** + * Stop playing this sound. + * + * @method Phaser.Sound.BaseSound#stop + * @since 3.0.0 + * + * @return {boolean} Whether the sound was stopped successfully. + */ + stop: function () + { + if (!this.isPaused && !this.isPlaying) + { + return false; + } + + this.isPlaying = false; + this.isPaused = false; + + this.resetConfig(); + + return true; + }, + + /** + * Method used internally for applying config values to some of the sound properties. + * + * @method Phaser.Sound.BaseSound#applyConfig + * @protected + * @since 3.0.0 + */ + applyConfig: function () + { + this.mute = this.currentConfig.mute; + this.volume = this.currentConfig.volume; + this.rate = this.currentConfig.rate; + this.detune = this.currentConfig.detune; + this.loop = this.currentConfig.loop; + }, + + /** + * Method used internally for resetting values of some of the config properties. + * + * @method Phaser.Sound.BaseSound#resetConfig + * @protected + * @since 3.0.0 + */ + resetConfig: function () + { + this.currentConfig.seek = 0; + this.currentConfig.delay = 0; + }, + + /** + * Update method called automatically by sound manager on every game step. + * + * @method Phaser.Sound.BaseSound#update + * @override + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: NOOP, + + /** + * Method used internally to calculate total playback rate of the sound. + * + * @method Phaser.Sound.BaseSound#calculateRate + * @protected + * @since 3.0.0 + */ + calculateRate: function () + { + var cent = 1.0005777895065548; // Math.pow(2, 1/1200); + var totalDetune = this.currentConfig.detune + this.manager.detune; + var detuneRate = Math.pow(cent, totalDetune); + + this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; + }, + + /** + * Destroys this sound and all associated events and marks it for removal from the sound manager. + * + * @method Phaser.Sound.BaseSound#destroy + * @since 3.0.0 + */ + destroy: function () + { + if (this.pendingRemove) + { + return; + } + + this.emit('destroy', this); + this.pendingRemove = true; + this.manager = null; + this.key = ''; + this.removeAllListeners(); + this.isPlaying = false; + this.isPaused = false; + this.config = null; + this.currentConfig = null; + this.markers = null; + this.currentMarker = null; + } + +}); + +module.exports = BaseSound; + + +/***/ }), +/* 125 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Clone = __webpack_require__(69); +var EventEmitter = __webpack_require__(11); +var NOOP = __webpack_require__(2); + +/** + * @callback EachActiveSoundCallback + * + * @param {Phaser.Sound.BaseSoundManager} manager - The SoundManager + * @param {Phaser.Sound.BaseSound} sound - The current active Sound + * @param {number} index - The index of the current active Sound + * @param {Phaser.Sound.BaseSound[]} sounds - All sounds + */ + +/** + * Audio sprite sound type. + * + * @typedef {Phaser.Sound.BaseSound} Phaser.Sound.BaseSound.AudioSpriteSound + * + * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. + */ + +/** + * @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 + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var BaseSoundManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function BaseSoundManager (game) + { + EventEmitter.call(this); + + /** + * Local reference to game. + * + * @name Phaser.Sound.BaseSoundManager#game + * @type {Phaser.Game} + * @readonly + * @since 3.0.0 + */ + this.game = game; + + /** + * Local reference to the JSON Cache, as used by Audio Sprites. + * + * @name Phaser.Sound.BaseSoundManager#jsonCache + * @type {Phaser.Cache.BaseCache} + * @readonly + * @since 3.7.0 + */ + this.jsonCache = game.cache.json; + + /** + * An array containing all added sounds. + * + * @name Phaser.Sound.BaseSoundManager#sounds + * @type {Phaser.Sound.BaseSound[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.sounds = []; + + /** + * Global mute setting. + * + * @name Phaser.Sound.BaseSoundManager#mute + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.mute = false; + + /** + * Global volume setting. + * + * @name Phaser.Sound.BaseSoundManager#volume + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.volume = 1; + + /** + * Flag indicating if sounds should be paused when game looses focus, + * for instance when user switches to another tab/program/app. + * + * @name Phaser.Sound.BaseSoundManager#pauseOnBlur + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.pauseOnBlur = true; + + /** + * Property that actually holds the value of global playback rate. + * + * @name Phaser.Sound.BaseSoundManager#_rate + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._rate = 1; + + /** + * Property that actually holds the value of global detune. + * + * @name Phaser.Sound.BaseSoundManager#_detune + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._detune = 0; + + /** + * Mobile devices require sounds to be triggered from an explicit user action, + * such as a tap, before any sound can be loaded/played on a web page. + * Set to true if the audio system is currently locked awaiting user interaction. + * + * @name Phaser.Sound.BaseSoundManager#locked + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.locked = this.locked || false; + + /** + * Flag used internally for handling when the audio system + * has been unlocked, if there ever was a need for it. + * + * @name Phaser.Sound.BaseSoundManager#unlocked + * @type {boolean} + * @default false + * @private + * @since 3.0.0 + */ + this.unlocked = false; + + game.events.on('blur', function () + { + if (this.pauseOnBlur) + { + this.onBlur(); + } + }, this); + + game.events.on('focus', function () + { + if (this.pauseOnBlur) + { + this.onFocus(); + } + }, this); + + game.events.on('prestep', this.update, this); + game.events.once('destroy', this.destroy, this); + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.BaseSoundManager#add + * @override + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.BaseSound} The new sound instance. + */ + add: NOOP, + + /** + * Adds a new audio sprite sound into the sound manager. + * Audio Sprites are a combination of audio files and a JSON configuration. + * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite + * + * @method Phaser.Sound.BaseSoundManager#addAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.BaseSound.AudioSpriteSound} The new audio sprite sound instance. + */ + addAudioSprite: function (key, config) + { + if (config === undefined) { config = {}; } + + var sound = this.add(key, config); + + sound.spritemap = this.jsonCache.get(key).spritemap; + + for (var markerName in sound.spritemap) + { + if (!sound.spritemap.hasOwnProperty(markerName)) + { + continue; + } + + var markerConfig = Clone(config); + + var marker = sound.spritemap[markerName]; + + markerConfig.loop = (marker.hasOwnProperty('loop')) ? marker.loop : false; + + sound.addMarker({ + name: markerName, + start: marker.start, + duration: marker.end - marker.start, + config: markerConfig + }); + } + + return sound; + }, + + /** + * Enables playing sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#play + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {(SoundConfig|SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (key, extra) + { + var sound = this.add(key); + + sound.once('ended', sound.destroy, sound); + + if (extra) + { + if (extra.name) + { + sound.addMarker(extra); + + return sound.play(extra.name); + } + else + { + return sound.play(extra); + } + } + else + { + return sound.play(); + } + }, + + /** + * Enables playing audio sprite sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#playAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {string} spriteName - The name of the sound sprite to play. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {boolean} Whether the audio sprite sound started playing successfully. + */ + playAudioSprite: function (key, spriteName, config) + { + var sound = this.addAudioSprite(key); + + sound.once('ended', sound.destroy, sound); + + return sound.play(spriteName, config); + }, + + /** + * Removes a sound from the sound manager. + * The removed sound is destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#remove + * @since 3.0.0 + * + * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. + * + * @return {boolean} True if the sound was removed successfully, otherwise false. + */ + remove: function (sound) + { + var index = this.sounds.indexOf(sound); + + if (index !== -1) + { + sound.destroy(); + + this.sounds.splice(index, 1); + + return true; + } + + return false; + }, + + /** + * Removes all sounds from the sound manager that have an asset key matching the given value. + * The removed sounds are destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#removeByKey + * @since 3.0.0 + * + * @param {string} key - The key to match when removing sound objects. + * + * @return {number} The number of matching sound objects that were removed. + */ + removeByKey: function (key) + { + var removed = 0; + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + var sound = this.sounds[i]; + + if (sound.key === key) + { + sound.destroy(); + + this.sounds.splice(i, 1); + + removed++; + } + } + + return removed; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#pauseall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Pauses all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#pauseAll + * @fires Phaser.Sound.BaseSoundManager#pauseall + * @since 3.0.0 + */ + pauseAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.pause(); + }); + + this.emit('pauseall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#resumeall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Resumes all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#resumeAll + * @fires Phaser.Sound.BaseSoundManager#resumeall + * @since 3.0.0 + */ + resumeAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.resume(); + }); + + this.emit('resumeall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#stopall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Stops all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#stopAll + * @fires Phaser.Sound.BaseSoundManager#stopall + * @since 3.0.0 + */ + stopAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.stop(); + }); + + this.emit('stopall', this); + }, + + /** + * Method used internally for unlocking audio playback on devices that + * require user interaction before any sound can be played on a web page. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + * + * @method Phaser.Sound.BaseSoundManager#unlock + * @override + * @protected + * @since 3.0.0 + */ + unlock: NOOP, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onBlur + * @override + * @protected + * @since 3.0.0 + */ + onBlur: NOOP, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onFocus + * @override + * @protected + * @since 3.0.0 + */ + onFocus: NOOP, + + /** + * Update method called on every game step. + * Removes destroyed sounds and updates every active sound in the game. + * + * @method Phaser.Sound.BaseSoundManager#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: function (time, delta) + { + if (this.unlocked) + { + this.unlocked = false; + this.locked = false; + + /** + * @event Phaser.Sound.BaseSoundManager#unlocked + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + this.emit('unlocked', this); + } + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + if (this.sounds[i].pendingRemove) + { + this.sounds.splice(i, 1); + } + } + + this.sounds.forEach(function (sound) + { + sound.update(time, delta); + }); + }, + + /** + * Destroys all the sounds in the game and all associated events. + * + * @method Phaser.Sound.BaseSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.forEachActiveSound(function (sound) + { + sound.destroy(); + }); + + this.sounds.length = 0; + this.sounds = null; + + this.game = null; + }, + + /** + * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. + * + * @method Phaser.Sound.BaseSoundManager#forEachActiveSound + * @private + * @since 3.0.0 + * + * @param {EachActiveSoundCallback} callback - Callback function. (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Manager.BaseSound[]) => void + * @param {*} [scope] - Callback context. + */ + forEachActiveSound: function (callback, scope) + { + var _this = this; + + this.sounds.forEach(function (sound, index) + { + if (!sound.pendingRemove) + { + callback.call(scope || _this, sound, index, _this.sounds); + } + }); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#rate + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. + */ + + /** + * 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. + * + * @method Phaser.Sound.BaseSoundManager#setRate + * @fires Phaser.Sound.BaseSoundManager#rate + * @since 3.3.0 + * + * @param {number} value - Global playback rate at which all the sounds will be played. + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setRate: function (value) + { + this.rate = value; + + return this; + }, + + /** + * Global playback rate at which all the sounds will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audio's playback speed. + * + * @name Phaser.Sound.BaseSoundManager#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rate: { + + get: function () + { + return this._rate; + }, + + set: function (value) + { + this._rate = value; + + this.forEachActiveSound(function (sound) + { + sound.calculateRate(); + }); + + this.emit('rate', this, value); + } + + }, + + /** + * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @method Phaser.Sound.BaseSoundManager#setDetune + * @fires Phaser.Sound.BaseSoundManager#detune + * @since 3.3.0 + * + * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setDetune: function (value) + { + this.detune = value; + + return this; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#detune + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. + */ + + /** + * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.BaseSoundManager#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + detune: { + + get: function () + { + return this._detune; + }, + + set: function (value) + { + this._detune = value; + + this.forEachActiveSound(function (sound) + { + sound.calculateRate(); + }); + + this.emit('detune', this, value); + } + + } + +}); + +module.exports = BaseSoundManager; + + +/***/ }), +/* 126 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Scene consts. + * + * @ignore + */ + +var CONST = { + + /** + * Scene state. + * + * @name Phaser.Scenes.PENDING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + PENDING: 0, + + /** + * Scene state. + * + * @name Phaser.Scenes.INIT + * @readonly + * @type {integer} + * @since 3.0.0 + */ + INIT: 1, + + /** + * Scene state. + * + * @name Phaser.Scenes.START + * @readonly + * @type {integer} + * @since 3.0.0 + */ + START: 2, + + /** + * Scene state. + * + * @name Phaser.Scenes.LOADING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + LOADING: 3, + + /** + * Scene state. + * + * @name Phaser.Scenes.CREATING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + CREATING: 4, + + /** + * Scene state. + * + * @name Phaser.Scenes.RUNNING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + RUNNING: 5, + + /** + * Scene state. + * + * @name Phaser.Scenes.PAUSED + * @readonly + * @type {integer} + * @since 3.0.0 + */ + PAUSED: 6, + + /** + * Scene state. + * + * @name Phaser.Scenes.SLEEPING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + SLEEPING: 7, + + /** + * Scene state. + * + * @name Phaser.Scenes.SHUTDOWN + * @readonly + * @type {integer} + * @since 3.0.0 + */ + SHUTDOWN: 8, + + /** + * Scene state. + * + * @name Phaser.Scenes.DESTROYED + * @readonly + * @type {integer} + * @since 3.0.0 + */ + DESTROYED: 9 + +}; + +module.exports = CONST; + + +/***/ }), +/* 127 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks if the given `width` and `height` are a power of two. + * Useful for checking texture dimensions. + * + * @function Phaser.Math.Pow2.IsSizePowerOfTwo + * @since 3.0.0 + * + * @param {number} width - The width. + * @param {number} height - The height. + * + * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. + */ +var IsSizePowerOfTwo = function (width, height) +{ + return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); +}; + +module.exports = IsSizePowerOfTwo; + + +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(101); + +/** + * Determines the browser type and version running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.browser` from within any Scene. + * + * @typedef {object} Phaser.Device.Browser + * @since 3.0.0 + * + * @property {boolean} chrome - Set to true if running in Chrome. + * @property {boolean} edge - Set to true if running in Microsoft Edge browser. + * @property {boolean} firefox - Set to true if running in Firefox. + * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). + * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. + * @property {boolean} opera - Set to true if running in Opera. + * @property {boolean} safari - Set to true if running in Safari. + * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) + * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) + * @property {number} chromeVersion - If running in Chrome this will contain the major version number. + * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. + * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. + * @property {number} safariVersion - If running in Safari this will contain the major version number. + * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} + */ +var Browser = { + + chrome: false, + chromeVersion: 0, + edge: false, + firefox: false, + firefoxVersion: 0, + ie: false, + ieVersion: 0, + mobileSafari: false, + opera: false, + safari: false, + safariVersion: 0, + silk: false, + trident: false, + tridentVersion: 0 + +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Edge\/\d+/.test(ua)) + { + Browser.edge = true; + } + else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) + { + Browser.chrome = true; + Browser.chromeVersion = parseInt(RegExp.$1, 10); + } + else if ((/Firefox\D+(\d+)/).test(ua)) + { + Browser.firefox = true; + Browser.firefoxVersion = parseInt(RegExp.$1, 10); + } + else if ((/AppleWebKit/).test(ua) && OS.iOS) + { + Browser.mobileSafari = true; + } + else if ((/MSIE (\d+\.\d+);/).test(ua)) + { + Browser.ie = true; + Browser.ieVersion = parseInt(RegExp.$1, 10); + } + else if ((/Opera/).test(ua)) + { + Browser.opera = true; + } + else if ((/Safari/).test(ua) && !OS.windowsPhone) + { + Browser.safari = true; + } + else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) + { + Browser.ie = true; + Browser.trident = true; + Browser.tridentVersion = parseInt(RegExp.$1, 10); + Browser.ieVersion = parseInt(RegExp.$3, 10); + } + + // Silk gets its own if clause because its ua also contains 'Safari' + if ((/Silk/).test(ua)) + { + Browser.silk = true; + } + + return Browser; +} + +module.exports = init(); + + +/***/ }), +/* 129 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates a linear (interpolation) value over t. + * + * @function Phaser.Math.Linear + * @since 3.0.0 + * + * @param {number} p0 - The first point. + * @param {number} p1 - The second point. + * @param {number} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. + * + * @return {number} The step t% of the way between p0 and p1. + */ +var Linear = function (p0, p1, t) +{ + return (p1 - p0) * t + p0; +}; + +module.exports = Linear; + + +/***/ }), +/* 130 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Browser specific prefix, so not going to change between contexts, only between browsers +var prefix = ''; + +/** + * @namespace Phaser.Display.Canvas.Smoothing + * @since 3.0.0 + */ +var Smoothing = function () +{ + /** + * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. + * + * @function Phaser.Display.Canvas.Smoothing.getPrefix + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {string} [description] + */ + var getPrefix = function (context) + { + var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; + + for (var i = 0; i < vendors.length; i++) + { + var s = vendors[i] + 'mageSmoothingEnabled'; + + if (s in context) + { + return s; + } + } + + return null; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.enable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var enable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = true; + } + + return context; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.disable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var disable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = false; + } + + return context; + }; + + /** + * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. + * Returns null if no smoothing prefix is available. + * + * @function Phaser.Display.Canvas.Smoothing.isEnabled + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {?boolean} [description] + */ + var isEnabled = function (context) + { + return (prefix !== null) ? context[prefix] : null; + }; + + return { + disable: disable, + enable: enable, + getPrefix: getPrefix, + isEnabled: isEnabled + }; + +}; + +module.exports = Smoothing(); + + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var DegToRad = __webpack_require__(36); +var EventEmitter = __webpack_require__(11); +var Rectangle = __webpack_require__(10); +var TransformMatrix = __webpack_require__(42); +var ValueToColor = __webpack_require__(196); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} JSONCameraBounds + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + */ + +/** + * @typedef {object} JSONCamera + * + * @property {string} name - The name of the camera + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + * @property {number} zoom - The zoom of camera + * @property {number} rotation - The rotation of camera + * @property {boolean} roundPixels - The round pixels st status of camera + * @property {number} scrollX - The horizontal scroll of camera + * @property {number} scrollY - The vertical scroll of camera + * @property {string} backgroundColor - The background color of camera + * @property {(JSONCameraBounds|undefined)} [bounds] - The bounds of camera + */ + +/** + * @classdesc + * A Base Camera class. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * The Base Camera is extended by the Camera class, which adds in special effects including Fade, + * Flash and Camera Shake, as well as the ability to follow Game Objects. + * + * The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow + * you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate + * to when they were added to the Camera class. + * + * @class BaseCamera + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.12.0 + * + * @extends Phaser.Events.EventEmitter + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.Visible + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var BaseCamera = new Class({ + + Extends: EventEmitter, + + Mixins: [ + Components.Alpha, + Components.Visible + ], + + initialize: + + function BaseCamera (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + EventEmitter.call(this); + + /** + * A reference to the Scene this camera belongs to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene; + + /** + * A reference to the Game Scene Manager. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#sceneManager + * @type {Phaser.Scenes.SceneManager} + * @since 3.12.0 + */ + this.sceneManager; + + /** + * A reference to the Game Config. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#config + * @type {object} + * @readonly + * @since 3.12.0 + */ + this.config; + + /** + * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * This value is a bitmask. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#id + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.id = 0; + + /** + * The name of the Camera. This is left empty for your own use. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The resolution of the Game, used in most Camera calculations. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#resolution + * @type {number} + * @readonly + * @since 3.12.0 + */ + this.resolution = 1; + + /** + * Should this camera round its pixel values to integers? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#roundPixels + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.roundPixels = false; + + /** + * Is this Camera visible or not? + * + * A visible camera will render and perform input tests. + * An invisible camera will not render anything and will skip input tests. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#visible + * @type {boolean} + * @default true + * @since 3.10.0 + */ + + /** + * Is this Camera using a bounds to restrict scrolling movement? + * + * Set this property along with the bounds via `Camera.setBounds`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#useBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useBounds = false; + + /** + * The World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. + * This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. + * If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. + * You can use it for culling or intersection checks. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#worldView + * @type {Phaser.Geom.Rectangle} + * @readonly + * @since 3.11.0 + */ + this.worldView = new Rectangle(); + + /** + * Is this Camera dirty? + * + * A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. + * + * This flag is cleared during the `postRenderCamera` method of the renderer. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#dirty + * @type {boolean} + * @default true + * @since 3.11.0 + */ + this.dirty = true; + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#x + * @type {number} + * @private + * @since 3.0.0 + */ + this._x = x; + + /** + * The y position of the Camera, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#y + * @type {number} + * @private + * @since 3.0.0 + */ + this._y = y; + + /** + * Internal Camera X value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cx + * @type {number} + * @private + * @since 3.12.0 + */ + this._cx = 0; + + /** + * Internal Camera Y value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cy + * @type {number} + * @private + * @since 3.12.0 + */ + this._cy = 0; + + /** + * Internal Camera Width value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cw + * @type {number} + * @private + * @since 3.12.0 + */ + this._cw = 0; + + /** + * Internal Camera Height value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_ch + * @type {number} + * @private + * @since 3.12.0 + */ + this._ch = 0; + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_width + * @type {number} + * @private + * @since 3.11.0 + */ + this._width = width; + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_height + * @type {number} + * @private + * @since 3.11.0 + */ + this._height = height; + + /** + * The bounds the camera is restrained to during scrolling. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollX + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollX = 0; + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollY + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollY = 0; + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_zoom + * @type {number} + * @private + * @default 1 + * @since 3.11.0 + */ + this._zoom = 1; + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._rotation = 0; + + /** + * A local transform matrix used for internal calculations. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#matrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.0.0 + */ + this.matrix = new TransformMatrix(); + + /** + * Does this Camera have a transparent background? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#transparent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.transparent = true; + + /** + * The background color of this Camera. Only used if `transparent` is `false`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#backgroundColor + * @type {Phaser.Display.Color} + * @since 3.0.0 + */ + this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); + + /** + * The Camera alpha value. Setting this property impacts every single object that this Camera + * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, + * or via the chainable `setAlpha` method instead. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#alpha + * @type {number} + * @default 1 + * @since 3.11.0 + */ + + /** + * Should the camera cull Game Objects before checking them for input hit tests? + * In some special cases it may be beneficial to disable this. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#disableCull + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.disableCull = false; + + /** + * A temporary array of culled objects. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#culledObjects + * @type {Phaser.GameObjects.GameObject[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.culledObjects = []; + + /** + * The mid-point of the Camera in 'world' coordinates. + * + * Use it to obtain exactly where in the world the center of the camera is currently looking. + * + * This value is updated in the preRender method, after the scroll values and follower + * have been processed. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#midPoint + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.11.0 + */ + this.midPoint = new Vector2(width / 2, height / 2); + + /** + * The horizontal origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originX + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originX = 0.5; + + /** + * The vertical origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originY + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originY = 0.5; + + /** + * Does this Camera have a custom viewport? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_customViewport + * @type {boolean} + * @private + * @default false + * @since 3.12.0 + */ + this._customViewport = false; + }, + + /** + * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAlpha + * @since 3.11.0 + * + * @param {number} [value=1] - The Camera alpha value. + * + * @return {this} This Camera instance. + */ + + /** + * Sets the rotation origin of this Camera. + * + * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setOrigin + * @since 3.11.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Camera instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this; + }, + + /** + * Calculates what the Camera.scrollX and scrollY values would need to be in order to move + * the Camera so it is centered on the given x and y coordinates, without actually moving + * the Camera there. The results are clamped based on the Camera bounds, if set. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getScroll + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {Phaser.Math.Vector2} [out] - A Vec2 to store the values in. If not given a new Vec2 is created. + * + * @return {Phaser.Math.Vector2} The scroll coordinates stored in the `x` abd `y` properties. + */ + getScroll: function (x, y, out) + { + if (out === undefined) { out = new Vector2(); } + + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + out.x = x - originX; + out.y = y - originY; + + if (this.useBounds) + { + out.x = this.clampX(out.x); + out.y = this.clampY(out.y); + } + + return out; + }, + + /** + * Moves the Camera so that it is centered on the given coordinates, bounds allowing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerOn + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerOn: function (x, y) + { + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + this.midPoint.set(x, y); + + this.scrollX = x - originX; + this.scrollY = y - originY; + + if (this.useBounds) + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerToBounds: function () + { + if (this.useBounds) + { + var bounds = this._bounds; + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + this.midPoint.set(bounds.centerX, bounds.centerY); + + this.scrollX = bounds.centerX - originX; + this.scrollY = bounds.centerY - originY; + } + + return this; + }, + + /** + * Moves the Camera so that it is re-centered based on its viewport size. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToSize + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerToSize: function () + { + this.scrollX = this.width * 0.5; + this.scrollY = this.height * 0.5; + + return this; + }, + + /** + * Takes an array of Game Objects and returns a new array featuring only those objects + * visible by this camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#cull + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] + * + * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. + * + * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. + */ + cull: function (renderableObjects) + { + if (this.disableCull) + { + return renderableObjects; + } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return renderableObjects; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var culledObjects = this.culledObjects; + var length = renderableObjects.length; + + determinant = 1 / determinant; + + culledObjects.length = 0; + + for (var index = 0; index < length; ++index) + { + var object = renderableObjects[index]; + + if (!object.hasOwnProperty('width') || object.parentContainer) + { + culledObjects.push(object); + continue; + } + + var objectW = object.width; + var objectH = object.height; + var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); + var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); + var tx = (objectX * mva + objectY * mvc + mve); + var ty = (objectX * mvb + objectY * mvd + mvf); + var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); + var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); + var cullW = cameraW + objectW; + var cullH = cameraH + objectH; + + if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH && + tw > -objectW && th > -objectH && tw < cullW && th < cullH) + { + culledObjects.push(object); + } + } + + return culledObjects; + }, + + /** + * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. + * You can optionally provide a Vector2, or similar object, to store the results in. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getWorldPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {number} x - The x position to convert to world space. + * @param {number} y - The y position to convert to world space. + * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. + */ + getWorldPoint: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + // Invert Matrix + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + output.x = x; + output.y = y; + + return output; + } + + determinant = 1 / determinant; + + var ima = mvd * determinant; + var imb = -mvb * determinant; + var imc = -mvc * determinant; + var imd = mva * determinant; + var ime = (mvc * mvf - mvd * mve) * determinant; + var imf = (mvb * mve - mva * mvf) * determinant; + + var c = Math.cos(this.rotation); + var s = Math.sin(this.rotation); + + var zoom = this.zoom; + var res = this.resolution; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + + // Works for zoom of 1 with any resolution, but resolution > 1 and zoom !== 1 breaks + var sx = x + ((scrollX * c - scrollY * s) * zoom); + var sy = y + ((scrollX * s + scrollY * c) * zoom); + + // Apply transform to point + output.x = (sx * ima + sy * imc) * res + ime; + output.y = (sx * imb + sy * imd) * res + imf; + + return output; + }, + + /** + * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings + * so that they are ignored by this Camera. This means they will not be rendered by this Camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#ignore + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group)} entries - The Game Object, or array of Game Objects, to be ignored by this Camera. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + ignore: function (entries) + { + var id = this.id; + + if (!Array.isArray(entries)) + { + entries = [ entries ]; + } + + for (var i = 0; i < entries.length; i++) + { + var entry = entries[i]; + + if (Array.isArray(entry)) + { + this.ignore(entry); + } + else if (entry.isParent) + { + this.ignore(entry.getChildren()); + } + else + { + entry.cameraFilter |= id; + } + } + + return this; + }, + + /** + * Internal preRender step. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#preRender + * @protected + * @since 3.0.0 + * + * @param {number} baseScale - The base scale, as set in the Camera Manager. + * @param {number} resolution - The game resolution. + */ + preRender: function (baseScale, resolution) + { + var width = this.width; + var height = this.height; + + var halfWidth = width * 0.5; + var halfHeight = height * 0.5; + + var zoom = this.zoom * baseScale; + var matrix = this.matrix; + + var originX = width * this.originX; + var originY = height * this.originY; + + var sx = this.scrollX; + var sy = this.scrollY; + + if (this.useBounds) + { + sx = this.clampX(sx); + sy = this.clampY(sy); + } + + if (this.roundPixels) + { + originX = Math.round(originX); + originY = Math.round(originY); + } + + // Values are in pixels and not impacted by zooming the Camera + this.scrollX = sx; + this.scrollY = sy; + + var midX = sx + halfWidth; + var midY = sy + halfHeight; + + // The center of the camera, in world space, so taking zoom into account + // Basically the pixel value of what it's looking at in the middle of the cam + this.midPoint.set(midX, midY); + + var displayWidth = width / zoom; + var displayHeight = height / zoom; + + this.worldView.setTo( + midX - (displayWidth / 2), + midY - (displayHeight / 2), + displayWidth, + displayHeight + ); + + matrix.loadIdentity(); + matrix.scale(resolution, resolution); + matrix.translate(this.x + originX, this.y + originY); + matrix.rotate(this.rotation); + matrix.scale(zoom, zoom); + matrix.translate(-originX, -originY); + }, + + /** + * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampX + * @since 3.11.0 + * + * @param {number} x - The value to horizontally scroll clamp. + * + * @return {number} The adjusted value to use as scrollX. + */ + clampX: function (x) + { + var bounds = this._bounds; + + var dw = this.displayWidth; + + var bx = bounds.x + ((dw - this.width) / 2); + var bw = Math.max(bx, bx + bounds.width - dw); + + if (x < bx) + { + x = bx; + } + else if (x > bw) + { + x = bw; + } + + return x; + }, + + /** + * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampY + * @since 3.11.0 + * + * @param {number} y - The value to vertically scroll clamp. + * + * @return {number} The adjusted value to use as scrollY. + */ + clampY: function (y) + { + var bounds = this._bounds; + + var dh = this.displayHeight; + + var by = bounds.y + ((dh - this.height) / 2); + var bh = Math.max(by, by + bounds.height - dh); + + if (y < by) + { + y = by; + } + else if (y > bh) + { + y = bh; + } + + return y; + }, + + /* + var gap = this._zoomInversed; + return gap * Math.round((src.x - this.scrollX * src.scrollFactorX) / gap); + */ + + /** + * If this Camera has previously had movement bounds set on it, this will remove them. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#removeBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + removeBounds: function () + { + this.useBounds = false; + + this.dirty = true; + + this._bounds.setEmpty(); + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAngle + * @since 3.0.0 + * + * @param {number} [value=0] - The cameras angle of rotation, given in degrees. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setAngle: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = DegToRad(value); + + return this; + }, + + /** + * Sets the background color for this Camera. + * + * By default a Camera has a transparent background but it can be given a solid color, with any level + * of transparency, via this method. + * + * The color value can be specified using CSS color notation, hex or numbers. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBackgroundColor + * @since 3.0.0 + * + * @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setBackgroundColor: function (color) + { + if (color === undefined) { color = 'rgba(0,0,0,0)'; } + + this.backgroundColor = ValueToColor(color); + + this.transparent = (this.backgroundColor.alpha === 0); + + return this; + }, + + /** + * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. + * + * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the + * edges and into blank space. It does not limit the placement of Game Objects, or where + * the Camera viewport can be positioned. + * + * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. + * + * Clear the bounds entirely by calling `Camera.removeBounds`. + * + * If you set bounds that are smaller than the viewport it will stop the Camera from being + * able to scroll. The bounds can be positioned where-ever you wish. By default they are from + * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of + * the Camera bounds. However, you can position them anywhere. So if you wanted a game world + * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y + * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find + * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBounds + * @since 3.0.0 + * + * @param {integer} x - The top-left x coordinate of the bounds. + * @param {integer} y - The top-left y coordinate of the bounds. + * @param {integer} width - The width of the bounds, in pixels. + * @param {integer} height - The height of the bounds, in pixels. + * @param {boolean} [centerOn] - If `true` the Camera will automatically be centered on the new bounds. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setBounds: function (x, y, width, height, centerOn) + { + this._bounds.setTo(x, y, width, height); + + this.dirty = true; + this.useBounds = true; + + if (centerOn) + { + this.centerToBounds(); + } + else + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Sets the name of this Camera. + * This value is for your own use and isn't used internally. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setName + * @since 3.0.0 + * + * @param {string} [value=''] - The name of the Camera. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setName: function (value) + { + if (value === undefined) { value = ''; } + + this.name = value; + + return this; + }, + + /** + * Set the position of the Camera viewport within the game. + * + * This does not change where the camera is 'looking'. See `setScroll` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setPosition + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRotation + * @since 3.0.0 + * + * @param {number} [value=0] - The rotation of the Camera, in radians. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setRotation: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = value; + + return this; + }, + + /** + * Should the Camera round pixel values to whole integers when rendering Game Objects? + * + * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRoundPixels + * @since 3.0.0 + * + * @param {boolean} value - `true` to round Camera pixels, `false` to not. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setRoundPixels: function (value) + { + this.roundPixels = value; + + return this; + }, + + /** + * Sets the Scene the Camera is bound to. + * + * Also populates the `resolution` property and updates the internal size values. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene the camera is bound to. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setScene: function (scene) + { + if (this.scene && this._customViewport) + { + this.sceneManager.customViewports--; + } + + this.scene = scene; + + this.config = scene.sys.game.config; + this.sceneManager = scene.sys.game.scene; + + var res = this.config.resolution; + + this.resolution = res; + + this._cx = this._x * res; + this._cy = this._y * res; + this._cw = this._width * res; + this._ch = this._height * res; + + this.updateSystem(); + + return this; + }, + + /** + * Set the position of where the Camera is looking within the game. + * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. + * Use this method, or the scroll properties, to move your camera around the game world. + * + * This does not change where the camera viewport is placed. See `setPosition` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScroll + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the Camera in the game world. + * @param {number} [y=x] - The y coordinate of the Camera in the game world. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setScroll: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollX = x; + this.scrollY = y; + + return this; + }, + + /** + * Set the size of the Camera viewport. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setSize + * @since 3.0.0 + * + * @param {integer} width - The width of the Camera viewport. + * @param {integer} [height=width] - The height of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * This method sets the position and size of the Camera viewport in a single call. + * + * If you're trying to change where the Camera is looking at in your game, then see + * the method `Camera.setScroll` instead. This method is for changing the viewport + * itself, not what the camera can see. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setViewport + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} y - The top-left y coordinate of the Camera viewport. + * @param {integer} width - The width of the Camera viewport. + * @param {integer} [height=width] - The height of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setViewport: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Set the zoom value of the Camera. + * + * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. + * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. + * + * A value of 1 means 'no zoom' and is the default. + * + * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setZoom + * @since 3.0.0 + * + * @param {number} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setZoom: function (value) + { + if (value === undefined) { value = 1; } + + if (value === 0) + { + value = 0.001; + } + + this.zoom = value; + + return this; + }, + + /** + * Sets the visibility of this Camera. + * + * An invisible Camera will skip rendering and input tests of everything it can see. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setVisible + * @since 3.10.0 + * + * @param {boolean} value - The visible state of the Camera. + * + * @return {this} This Camera instance. + */ + + /** + * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#toJSON + * @since 3.0.0 + * + * @return {JSONCamera} A well-formed object suitable for conversion to JSON. + */ + toJSON: function () + { + var output = { + name: this.name, + x: this.x, + y: this.y, + width: this.width, + height: this.height, + zoom: this.zoom, + rotation: this.rotation, + roundPixels: this.roundPixels, + scrollX: this.scrollX, + scrollY: this.scrollY, + backgroundColor: this.backgroundColor.rgba + }; + + if (this.useBounds) + { + output['bounds'] = { + x: this._bounds.x, + y: this._bounds.y, + width: this._bounds.width, + height: this._bounds.height + }; + } + + return output; + }, + + /** + * Internal method called automatically by the Camera Manager. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#update + * @protected + * @since 3.0.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 () + { + // NOOP + }, + + /** + * Internal method called automatically when the viewport changes. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#updateSystem + * @private + * @since 3.12.0 + */ + updateSystem: function () + { + if (!this.config) + { + return; + } + + var custom = (this._x !== 0 || this._y !== 0 || this.config.width !== this._width || this.config.height !== this._height); + + var sceneManager = this.sceneManager; + + if (custom && !this._customViewport) + { + // We need a custom viewport for this Camera + sceneManager.customViewports++; + } + else if (!custom && this._customViewport) + { + // We're turning off a custom viewport for this Camera + sceneManager.customViewports--; + } + + this.dirty = true; + this._customViewport = custom; + }, + + /** + * This event is fired when a camera is destroyed by the Camera Manager. + * + * @event CameraDestroyEvent + * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that was destroyed. + */ + + /** + * Destroys this Camera instance and its internal properties and references. + * Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager. + * + * This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default. + * + * Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction, + * rather than calling this method directly. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#destroy + * @fires CameraDestroyEvent + * @since 3.0.0 + */ + destroy: function () + { + this.emit('cameradestroy', this); + + this.removeAllListeners(); + + this.matrix.destroy(); + + this.culledObjects = []; + + if (this._customViewport) + { + // We're turning off a custom viewport for this Camera + this.sceneManager.customViewports--; + } + + this._bounds = null; + + this.scene = null; + this.config = null; + this.sceneManager = null; + }, + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this._x; + }, + + set: function (value) + { + this._x = value; + this._cx = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The y position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this._y; + }, + + set: function (value) + { + this._y = value; + this._cy = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#width + * @type {number} + * @since 3.0.0 + */ + width: { + + get: function () + { + return this._width; + }, + + set: function (value) + { + this._width = value; + this._cw = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#height + * @type {number} + * @since 3.0.0 + */ + height: { + + get: function () + { + return this._height; + }, + + set: function (value) + { + this._height = value; + this._ch = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollX: { + + get: function () + { + return this._scrollX; + }, + + set: function (value) + { + this._scrollX = value; + this.dirty = true; + } + + }, + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollY: { + + get: function () + { + return this._scrollY; + }, + + set: function (value) + { + this._scrollY = value; + this.dirty = true; + } + + }, + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#zoom + * @type {number} + * @default 1 + * @since 3.0.0 + */ + zoom: { + + get: function () + { + return this._zoom; + }, + + set: function (value) + { + this._zoom = value; + this.dirty = true; + } + + }, + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = value; + this.dirty = true; + } + + }, + + /** + * The x position of the center of the Camera's viewport, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerX + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerX: { + + get: function () + { + return this.x + (0.5 * this.width); + } + + }, + + /** + * The y position of the center of the Camera's viewport, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerY + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerY: { + + get: function () + { + return this.y + (0.5 * this.height); + } + + }, + + /** + * The displayed width of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width + * would be 1600, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a width of 800 and zoom of 2 would have a display width + * of 400 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayWidth + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayWidth: { + + get: function () + { + return this.width / this.zoom; + } + + }, + + /** + * The displayed height of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height + * would be 1200, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a height of 600 and zoom of 2 would have a display height + * of 300 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayHeight + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayHeight: { + + get: function () + { + return this.height / this.zoom; + } + + } + +}); + +module.exports = BaseCamera; + + +/***/ }), +/* 132 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Shuffles the contents of the given array using the Fisher-Yates implementation. + * + * The original array is modified directly and returned. + * + * @function Phaser.Utils.Array.Shuffle + * @since 3.0.0 + * + * @param {array} array - The array to shuffle. This array is modified in place. + * + * @return {array} The shuffled array. + */ +var Shuffle = function (array) +{ + for (var i = array.length - 1; i > 0; i--) + { + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + + return array; +}; + +module.exports = Shuffle; + + +/***/ }), +/* 133 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the WebGL rendering pipeline of a Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline + * @webglOnly + * @since 3.0.0 + */ + +var Pipeline = { + + /** + * The initial WebGL pipeline of this Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + defaultPipeline: null, + + /** + * The current WebGL pipeline of this Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline#pipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + pipeline: null, + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#initPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} [pipelineName=TextureTintPipeline] - The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + initPipeline: function (pipelineName) + { + if (pipelineName === undefined) { pipelineName = 'TextureTintPipeline'; } + + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.defaultPipeline = renderer.getPipeline(pipelineName); + this.pipeline = this.defaultPipeline; + + return true; + } + + return false; + }, + + /** + * Sets the active WebGL Pipeline of this Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#setPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * + * @return {this} This Game Object instance. + */ + setPipeline: function (pipelineName) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.pipeline = renderer.getPipeline(pipelineName); + } + + return this; + }, + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * + * @method Phaser.GameObjects.Components.Pipeline#resetPipeline + * @webglOnly + * @since 3.0.0 + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + resetPipeline: function () + { + this.pipeline = this.defaultPipeline; + + return (this.pipeline !== null); + }, + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + * + * @method Phaser.GameObjects.Components.Pipeline#getPipelineName + * @webglOnly + * @since 3.0.0 + * + * @return {string} The string-based name of the pipeline being used by this Game Object. + */ + getPipelineName: function () + { + return this.pipeline.name; + } + +}; + +module.exports = Pipeline; + + +/***/ }), +/* 134 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var Perimeter = function (rect) +{ + return 2 * (rect.width + rect.height); +}; + +module.exports = Perimeter; + + +/***/ }), +/* 135 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(72); +var Circle = __webpack_require__(81); +var CircleContains = __webpack_require__(44); +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var GameObject = __webpack_require__(17); +var Rectangle = __webpack_require__(10); +var RectangleContains = __webpack_require__(43); + +/** + * @classdesc + * A Zone Game Object. + * + * A Zone is a non-rendering rectangular Game Object that has a position and size. + * It has no texture and never displays, but does live on the display list and + * can be moved, scaled and rotated like any other Game Object. + * + * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods + * specifically for this. It is also useful for object overlap checks, or as a base for your own + * non-displaying Game Objects. + + * The default origin is 0.5, the center of the Zone, the same as with Game Objects. + * + * @class Zone + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @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 {number} [width=1] - The width of the Game Object. + * @param {number} [height=1] - The height of the Game Object. + */ +var Zone = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.GetBounds, + Components.Origin, + Components.ScaleMode, + Components.Transform, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function Zone (scene, x, y, width, height) + { + if (width === undefined) { width = 1; } + if (height === undefined) { height = width; } + + GameObject.call(this, scene, 'Zone'); + + this.setPosition(x, y); + + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Zone#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Zone#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * The Blend Mode of the Game Object. + * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into + * display lists without causing a batch flush. + * + * @name Phaser.GameObjects.Zone#blendMode + * @type {integer} + * @since 3.0.0 + */ + this.blendMode = BlendModes.NORMAL; + + this.updateDisplayOrigin(); + }, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Zone#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setSize: function (width, height, resizeInput) + { + if (resizeInput === undefined) { resizeInput = true; } + + this.width = width; + this.height = height; + + if (resizeInput && this.input && this.input.hitArea instanceof Rectangle) + { + this.input.hitArea.width = width; + this.input.hitArea.height = height; + } + + return this; + }, + + /** + * Sets the display size of this Game Object. + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Zone#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + }, + + /** + * Sets this Zone to be a Circular Drop Zone. + * The circle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setCircleDropZone + * @since 3.0.0 + * + * @param {number} radius - The radius of the Circle that will form the Drop Zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setCircleDropZone: function (radius) + { + return this.setDropZone(new Circle(0, 0, radius), CircleContains); + }, + + /** + * Sets this Zone to be a Rectangle Drop Zone. + * The rectangle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setRectangleDropZone + * @since 3.0.0 + * + * @param {number} width - The width of the rectangle drop zone. + * @param {number} height - The height of the rectangle drop zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setRectangleDropZone: function (width, height) + { + return this.setDropZone(new Rectangle(0, 0, width, height), RectangleContains); + }, + + /** + * Allows you to define your own Geometry shape to be used as a Drop Zone. + * + * @method Phaser.GameObjects.Zone#setDropZone + * @since 3.0.0 + * + * @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. + * @param {HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDropZone: function (shape, callback) + { + if (shape === undefined) + { + this.setRectangleDropZone(this.width, this.height); + } + else if (!this.input) + { + this.setInteractive(shape, callback, true); + } + + return this; + }, + + /** + * A NOOP method so you can pass a Zone to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Zone#setAlpha + * @private + * @since 3.11.0 + */ + setAlpha: function () + { + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderCanvas + * @private + * @since 3.0.0 + */ + renderCanvas: function () + { + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderWebGL + * @private + * @since 3.0.0 + */ + renderWebGL: function () + { + } + +}); + +module.exports = Zone; + + +/***/ }), +/* 136 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} TweenDataGenConfig + * + * @property {function} delay - [description] + * @property {function} duration - [description] + * @property {function} hold - [description] + * @property {function} repeat - [description] + * @property {function} repeatDelay - [description] + */ + +/** + * @typedef {object} Phaser.Tweens.TweenDataConfig + * + * @property {object} target - The target to tween. + * @property {string} key - The property of the target being tweened. + * @property {function} getEndValue - The returned value sets what the property will be at the END of the Tween. + * @property {function} getStartValue - The returned value sets what the property will be at the START of the Tween. + * @property {function} ease - The ease function this tween uses. + * @property {number} [duration=0] - Duration of the tween in ms/frames, excludes time for yoyo or repeats. + * @property {number} [totalDuration=0] - The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + * @property {number} [delay=0] - Time in ms/frames before tween will start. + * @property {boolean} [yoyo=false] - Cause the tween to return back to its start value after hold has expired. + * @property {number} [hold=0] - Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + * @property {integer} [repeat=0] - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + * @property {number} [repeatDelay=0] - Time in ms/frames before the repeat will start. + * @property {boolean} [flipX=false] - Automatically call toggleFlipX when the TweenData yoyos or repeats + * @property {boolean} [flipY=false] - Automatically call toggleFlipY when the TweenData yoyos or repeats + * @property {number} [progress=0] - Between 0 and 1 showing completion of this TweenData. + * @property {number} [elapsed=0] - Delta counter + * @property {integer} [repeatCounter=0] - How many repeats are left to run? + * @property {number} [start=0] - Ease value data. + * @property {number} [current=0] - Ease value data. + * @property {number} [end=0] - Ease value data. + * @property {number} [t1=0] - Time duration 1. + * @property {number} [t2=0] - Time duration 2. + * @property {TweenDataGenConfig} [gen] - LoadValue generation functions. + * @property {integer} [state=0] - TWEEN_CONST.CREATED + */ + +/** + * [description] + * + * @function Phaser.Tweens.TweenData + * @since 3.0.0 + * + * @param {object} target - [description] + * @param {string} key - [description] + * @param {function} getEnd - [description] + * @param {function} getStart - [description] + * @param {function} ease - [description] + * @param {number} delay - [description] + * @param {number} duration - [description] + * @param {boolean} yoyo - [description] + * @param {number} hold - [description] + * @param {number} repeat - [description] + * @param {number} repeatDelay - [description] + * @param {boolean} flipX - [description] + * @param {boolean} flipY - [description] + * + * @return {TweenDataConfig} [description] + */ +var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) +{ + return { + + // The target to tween + target: target, + + // The property of the target to tween + key: key, + + // The returned value sets what the property will be at the END of the Tween. + getEndValue: getEnd, + + // The returned value sets what the property will be at the START of the Tween. + getStartValue: getStart, + + // The ease function this tween uses. + ease: ease, + + // Duration of the tween in ms/frames, excludes time for yoyo or repeats. + duration: 0, + + // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + totalDuration: 0, + + // Time in ms/frames before tween will start. + delay: 0, + + // Cause the tween to return back to its start value after hold has expired. + yoyo: yoyo, + + // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + hold: 0, + + // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + repeat: 0, + + // Time in ms/frames before the repeat will start. + repeatDelay: 0, + + // Automatically call toggleFlipX when the TweenData yoyos or repeats + flipX: flipX, + + // Automatically call toggleFlipY when the TweenData yoyos or repeats + flipY: flipY, + + // Between 0 and 1 showing completion of this TweenData. + progress: 0, + + // Delta counter. + elapsed: 0, + + // How many repeats are left to run? + repeatCounter: 0, + + // Ease Value Data: + + start: 0, + current: 0, + end: 0, + + // Time Durations + t1: 0, + t2: 0, + + // LoadValue generation functions + gen: { + delay: delay, + duration: duration, + hold: hold, + repeat: repeat, + repeatDelay: repeatDelay + }, + + // TWEEN_CONST.CREATED + state: 0 + }; +}; + +module.exports = TweenData; + + +/***/ }), +/* 137 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GameObjectCreator = __webpack_require__(14); +var GameObjectFactory = __webpack_require__(5); +var TWEEN_CONST = __webpack_require__(93); + +/** + * @classdesc + * [description] + * + * @class Tween + * @memberof Phaser.Tweens + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {Phaser.Tweens.TweenDataConfig[]} data - [description] + * @param {array} targets - [description] + */ +var Tween = new Class({ + + initialize: + + function Tween (parent, data, targets) + { + /** + * [description] + * + * @name Phaser.Tweens.Tween#parent + * @type {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * Is the parent of this Tween a Timeline? + * + * @name Phaser.Tweens.Tween#parentIsTimeline + * @type {boolean} + * @since 3.0.0 + */ + this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); + + /** + * An array of TweenData objects, each containing a unique property and target being tweened. + * + * @name Phaser.Tweens.Tween#data + * @type {Phaser.Tweens.TweenDataConfig[]} + * @since 3.0.0 + */ + this.data = data; + + /** + * data array doesn't change, so we can cache the length + * + * @name Phaser.Tweens.Tween#totalData + * @type {integer} + * @since 3.0.0 + */ + this.totalData = data.length; + + /** + * An array of references to the target/s this Tween is operating on + * + * @name Phaser.Tweens.Tween#targets + * @type {object[]} + * @since 3.0.0 + */ + this.targets = targets; + + /** + * Cached target total (not necessarily the same as the data total) + * + * @name Phaser.Tweens.Tween#totalTargets + * @type {integer} + * @since 3.0.0 + */ + this.totalTargets = targets.length; + + /** + * If true then duration, delay, etc values are all frame totals. + * + * @name Phaser.Tweens.Tween#useFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useFrames = false; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * + * @name Phaser.Tweens.Tween#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + * + * @name Phaser.Tweens.Tween#loop + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loop = 0; + + /** + * Time in ms/frames before the tween loops. + * + * @name Phaser.Tweens.Tween#loopDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopDelay = 0; + + /** + * How many loops are left to run? + * + * @name Phaser.Tweens.Tween#loopCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopCounter = 0; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) + * + * @name Phaser.Tweens.Tween#completeDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.completeDelay = 0; + + /** + * Countdown timer (used by timeline offset, loopDelay and completeDelay) + * + * @name Phaser.Tweens.Tween#countdown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.countdown = 0; + + /** + * Set only if this Tween is part of a Timeline. + * + * @name Phaser.Tweens.Tween#offset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.offset = 0; + + /** + * Set only if this Tween is part of a Timeline. The calculated offset amount. + * + * @name Phaser.Tweens.Tween#calculatedOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.calculatedOffset = 0; + + /** + * The current state of the tween + * + * @name Phaser.Tweens.Tween#state + * @type {integer} + * @since 3.0.0 + */ + this.state = TWEEN_CONST.PENDING_ADD; + + /** + * The state of the tween when it was paused (used by Resume) + * + * @name Phaser.Tweens.Tween#_pausedState + * @type {integer} + * @private + * @since 3.0.0 + */ + this._pausedState = TWEEN_CONST.PENDING_ADD; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + * + * @name Phaser.Tweens.Tween#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * Elapsed time in ms/frames of this run through the Tween. + * + * @name Phaser.Tweens.Tween#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalElapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalElapsed = 0; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + * + * @name Phaser.Tweens.Tween#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + * + * @name Phaser.Tweens.Tween#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Time in ms/frames for the Tween to complete (including looping) + * + * @name Phaser.Tweens.Tween#totalDuration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalDuration = 0; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalProgress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalProgress = 0; + + /** + * An object containing the various Tween callback references. + * + * @name Phaser.Tweens.Tween#callbacks + * @type {object} + * @default 0 + * @since 3.0.0 + */ + this.callbacks = { + onComplete: null, + onLoop: null, + onRepeat: null, + onStart: null, + onUpdate: null, + onYoyo: null + }; + + this.callbackScope; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getValue + * @since 3.0.0 + * + * @return {number} [description] + */ + getValue: function () + { + return this.data[0].current; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setTimeScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getTimeScale: function () + { + return this.timeScale; + }, + + /** + * Checks if the Tween is currently active. + * + * @method Phaser.Tweens.Tween#isPlaying + * @since 3.0.0 + * + * @return {boolean} `true` if the Tween is active, otherwise `false`. + */ + isPlaying: function () + { + return (this.state === TWEEN_CONST.ACTIVE); + }, + + /** + * Checks if the Tween is currently paused. + * + * @method Phaser.Tweens.Tween#isPaused + * @since 3.0.0 + * + * @return {boolean} `true` if the Tween is paused, otherwise `false`. + */ + isPaused: function () + { + return (this.state === TWEEN_CONST.PAUSED); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#hasTarget + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + hasTarget: function (target) + { + return (this.targets.indexOf(target) !== -1); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTo + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} value - [description] + * @param {boolean} startToCurrent - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + updateTo: function (key, value, startToCurrent) + { + for (var i = 0; i < this.totalData; i++) + { + var tweenData = this.data[i]; + + if (tweenData.key === key) + { + tweenData.end = value; + + if (startToCurrent) + { + tweenData.start = tweenData.current; + } + + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#restart + * @since 3.0.0 + */ + restart: function () + { + if (this.state === TWEEN_CONST.REMOVED) + { + this.seek(0); + this.parent.makeActive(this); + } + else + { + this.stop(); + this.play(); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#calcDuration + * @since 3.0.0 + */ + calcDuration: function () + { + var max = 0; + + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + // Set t1 (duration + hold + yoyo) + tweenData.t1 = tweenData.duration + tweenData.hold; + + if (tweenData.yoyo) + { + tweenData.t1 += tweenData.duration; + } + + // Set t2 (repeatDelay + duration + hold + yoyo) + tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; + + // Total Duration + tweenData.totalDuration = tweenData.delay + tweenData.t1; + + if (tweenData.repeat === -1) + { + tweenData.totalDuration += (tweenData.t2 * 999999999999); + } + else if (tweenData.repeat > 0) + { + tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); + } + + if (tweenData.totalDuration > max) + { + // Get the longest TweenData from the Tween, used to calculate the Tween TD + max = tweenData.totalDuration; + } + } + + // Excludes loop values + this.duration = max; + + this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; + + if (this.loopCounter > 0) + { + this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); + } + else + { + this.totalDuration = this.duration + this.completeDelay; + } + }, + + /** + * Called by TweenManager.preUpdate as part of its loop to check pending and active tweens. + * Should not be called directly. + * + * @method Phaser.Tweens.Tween#init + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. + */ + init: function () + { + var data = this.data; + var totalTargets = this.totalTargets; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + var target = tweenData.target; + var gen = tweenData.gen; + + tweenData.delay = gen.delay(i, totalTargets, target); + tweenData.duration = gen.duration(i, totalTargets, target); + tweenData.hold = gen.hold(i, totalTargets, target); + tweenData.repeat = gen.repeat(i, totalTargets, target); + tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); + } + + this.calcDuration(); + + this.progress = 0; + this.totalProgress = 0; + this.elapsed = 0; + this.totalElapsed = 0; + + // You can't have a paused Tween if it's part of a Timeline + if (this.paused && !this.parentIsTimeline) + { + this.state = TWEEN_CONST.PENDING_ADD; + this._pausedState = TWEEN_CONST.INIT; + + return false; + } + else + { + this.state = TWEEN_CONST.INIT; + + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#nextState + * @since 3.0.0 + */ + nextState: function () + { + if (this.loopCounter > 0) + { + this.elapsed = 0; + this.progress = 0; + this.loopCounter--; + + var onLoop = this.callbacks.onLoop; + + if (onLoop) + { + onLoop.params[1] = this.targets; + + onLoop.func.apply(onLoop.scope, onLoop.params); + } + + this.resetTweenData(true); + + if (this.loopDelay > 0) + { + this.countdown = this.loopDelay; + this.state = TWEEN_CONST.LOOP_DELAY; + } + else + { + this.state = TWEEN_CONST.ACTIVE; + } + } + else if (this.completeDelay > 0) + { + this.countdown = this.completeDelay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#pause + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + pause: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + this.paused = true; + + this._pausedState = this.state; + + this.state = TWEEN_CONST.PAUSED; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#play + * @since 3.0.0 + * + * @param {boolean} resetFromTimeline - [description] + */ + play: function (resetFromTimeline) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + return; + } + else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) + { + this.init(); + this.parent.makeActive(this); + resetFromTimeline = true; + } + + var onStart = this.callbacks.onStart; + + if (this.parentIsTimeline) + { + this.resetTweenData(resetFromTimeline); + + if (this.calculatedOffset === 0) + { + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + else + { + this.countdown = this.calculatedOffset; + + this.state = TWEEN_CONST.OFFSET_DELAY; + } + } + else if (this.paused) + { + this.paused = false; + + this.parent.makeActive(this); + } + else + { + this.resetTweenData(resetFromTimeline); + + this.state = TWEEN_CONST.ACTIVE; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.parent.makeActive(this); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#resetTweenData + * @since 3.0.0 + * + * @param {boolean} resetFromLoop - [description] + */ + resetTweenData: function (resetFromLoop) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + tweenData.progress = 0; + tweenData.elapsed = 0; + + tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; + + if (resetFromLoop) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); + + tweenData.current = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else if (tweenData.delay > 0) + { + tweenData.elapsed = tweenData.delay; + tweenData.state = TWEEN_CONST.DELAY; + } + else + { + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + } + }, + + /** + * Resumes the playback of a previously paused Tween. + * + * @method Phaser.Tweens.Tween#resume + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + resume: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + this.paused = false; + + this.state = this._pausedState; + } + else + { + this.play(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#seek + * @since 3.0.0 + * + * @param {number} toPosition - A value between 0 and 1. + */ + seek: function (toPosition) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + // This won't work with loop > 0 yet + var ms = this.totalDuration * toPosition; + + var tweenData = data[i]; + var progress = 0; + var elapsed = 0; + + if (ms <= tweenData.delay) + { + progress = 0; + elapsed = 0; + } + else if (ms >= tweenData.totalDuration) + { + progress = 1; + elapsed = tweenData.duration; + } + else if (ms > tweenData.delay && ms <= tweenData.t1) + { + // Keep it zero bound + ms = Math.max(0, ms - tweenData.delay); + + // Somewhere in the first playthru range + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + else if (ms > tweenData.t1 && ms < tweenData.totalDuration) + { + // Somewhere in repeat land + ms -= tweenData.delay; + ms -= tweenData.t1; + + // var repeats = Math.floor(ms / tweenData.t2); + + // remainder + ms = ((ms / tweenData.t2) % 1) * tweenData.t2; + + if (ms > tweenData.repeatDelay) + { + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + } + + tweenData.progress = progress; + tweenData.elapsed = elapsed; + + var v = tweenData.ease(tweenData.progress); + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); + + // if (tweenData.current === 0) + // { + // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); + // } + + tweenData.target[tweenData.key] = tweenData.current; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setCallback + * @since 3.0.0 + * + * @param {string} type - [description] + * @param {function} callback - [description] + * @param {array} [params] - [description] + * @param {object} [scope] - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setCallback: function (type, callback, params, scope) + { + this.callbacks[type] = { func: callback, scope: scope, params: params }; + + return this; + }, + + /** + * Flags the Tween as being complete, whatever stage of progress it is at. + * + * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` + * argument is provided, in which case the Tween will delay for that period of time before calling the callback. + * + * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. + * + * @method Phaser.Tweens.Tween#complete + * @since 3.2.0 + * + * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. + */ + complete: function (delay) + { + if (delay === undefined) { delay = 0; } + + if (delay) + { + this.countdown = delay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + * + * @method Phaser.Tweens.Tween#stop + * @since 3.0.0 + * + * @param {number} [resetTo] - A value between 0 and 1. + */ + stop: function (resetTo) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + if (resetTo !== undefined) + { + this.seek(resetTo); + } + } + + if (this.state !== TWEEN_CONST.REMOVED) + { + if (this.state === TWEEN_CONST.PAUSED || this.state === TWEEN_CONST.PENDING_ADD) + { + this.parent._destroy.push(this); + this.parent._toProcess++; + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + * + * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. + */ + update: function (timestamp, delta) + { + if (this.state === TWEEN_CONST.PAUSED) + { + return false; + } + + if (this.useFrames) + { + delta = 1 * this.parent.timeScale; + } + + delta *= this.timeScale; + + this.elapsed += delta; + this.progress = Math.min(this.elapsed / this.duration, 1); + + this.totalElapsed += delta; + this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); + + switch (this.state) + { + case TWEEN_CONST.ACTIVE: + + var stillRunning = false; + + for (var i = 0; i < this.totalData; i++) + { + if (this.updateTweenData(this, this.data[i], delta)) + { + stillRunning = true; + } + } + + // Anything still running? If not, we're done + if (!stillRunning) + { + this.nextState(); + } + + break; + + case TWEEN_CONST.LOOP_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.OFFSET_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onStart = this.callbacks.onStart; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.COMPLETE_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + + break; + } + + return (this.state === TWEEN_CONST.PENDING_REMOVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setStateFromEnd + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromEnd: function (tween, tweenData, diff) + { + if (tweenData.yoyo) + { + // We've hit the end of a Playing Forward TweenData and we have a yoyo + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. + // If you're tweening several properties it can fire for all of them, at once. + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onYoyo = tween.callbacks.onYoyo; + + if (onYoyo) + { + // Element 1 is reserved for the target of the yoyo (and needs setting here) + onYoyo.params[1] = tweenData.target; + + onYoyo.func.apply(onYoyo.scope, onYoyo.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + return TWEEN_CONST.PLAYING_BACKWARD; + } + else if (tweenData.repeatCounter > 0) + { + // We've hit the end of a Playing Forward TweenData and we have a Repeat. + // So we're going to go right back to the start to repeat it again. + + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + /** + * Was PLAYING_BACKWARD and has hit the start. + * + * @method Phaser.Tweens.Tween#setStateFromStart + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromStart: function (tween, tweenData, diff) + { + if (tweenData.repeatCounter > 0) + { + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + // + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTweenData + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true + * + * @return {boolean} [description] + */ + updateTweenData: function (tween, tweenData, delta) + { + switch (tweenData.state) + { + case TWEEN_CONST.PLAYING_FORWARD: + case TWEEN_CONST.PLAYING_BACKWARD: + + if (!tweenData.target) + { + tweenData.state = TWEEN_CONST.COMPLETE; + break; + } + + var elapsed = tweenData.elapsed; + var duration = tweenData.duration; + var diff = 0; + + elapsed += delta; + + if (elapsed > duration) + { + diff = elapsed - duration; + elapsed = duration; + } + + var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); + var progress = elapsed / duration; + + var v; + + if (forward) + { + v = tweenData.ease(progress); + } + else + { + v = tweenData.ease(1 - progress); + } + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + tweenData.target[tweenData.key] = tweenData.current; + + tweenData.elapsed = elapsed; + tweenData.progress = progress; + + var onUpdate = tween.callbacks.onUpdate; + + if (onUpdate) + { + onUpdate.params[1] = tweenData.target; + + onUpdate.func.apply(onUpdate.scope, onUpdate.params); + } + + if (progress === 1) + { + if (forward) + { + if (tweenData.hold > 0) + { + tweenData.elapsed = tweenData.hold - diff; + + tweenData.state = TWEEN_CONST.HOLD_DELAY; + } + else + { + tweenData.state = this.setStateFromEnd(tween, tweenData, diff); + } + } + else + { + tweenData.state = this.setStateFromStart(tween, tweenData, diff); + } + } + + break; + + case TWEEN_CONST.DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + + break; + + case TWEEN_CONST.REPEAT_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + + break; + + case TWEEN_CONST.HOLD_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); + } + + break; + + case TWEEN_CONST.PENDING_RENDER: + + if (tweenData.target) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else + { + tweenData.state = TWEEN_CONST.COMPLETE; + } + + break; + } + + // Return TRUE if this TweenData still playing, otherwise return FALSE + return (tweenData.state !== TWEEN_CONST.COMPLETE); + } + +}); + +Tween.TYPES = [ + 'onComplete', + 'onLoop', + 'onRepeat', + 'onStart', + 'onUpdate', + 'onYoyo' +]; + +/** + * Creates a new Tween object. + * + * Note: This method will only be available Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectFactory.register('tween', function (config) +{ + return this.scene.sys.tweens.add(config); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +/** + * Creates a new Tween object and returns it. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectCreator.register('tween', function (config) +{ + return this.scene.sys.tweens.create(config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + +module.exports = Tween; + + +/***/ }), +/* 138 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} Phaser.Tweens.TweenConfigDefaults + * + * @property {(object|object[])} targets - The object, or an array of objects, to run the tween on. + * @property {number} [delay=0] - The number of milliseconds to delay before the tween will start. + * @property {number} [duration=1000] - The duration of the tween in milliseconds. + * @property {string} [ease='Power0'] - The easing equation to use for the tween. + * @property {array} [easeParams] - Optional easing parameters. + * @property {number} [hold=0] - The number of milliseconds to hold the tween for before yoyo'ing. + * @property {number} [repeat=0] - The number of times to repeat the tween. + * @property {number} [repeatDelay=0] - The number of milliseconds to pause before a tween will repeat. + * @property {boolean} [yoyo=false] - Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete. + * @property {boolean} [flipX=false] - Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property. + * @property {boolean} [flipY=false] - Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property. + */ + +var TWEEN_DEFAULTS = { + targets: null, + delay: 0, + duration: 1000, + ease: 'Power0', + easeParams: null, + hold: 0, + repeat: 0, + repeatDelay: 0, + yoyo: false, + flipX: false, + flipY: false +}; + +module.exports = TWEEN_DEFAULTS; + + +/***/ }), +/* 139 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function hasGetStart (def) +{ + return (!!def.getStart && typeof def.getStart === 'function'); +} + +function hasGetEnd (def) +{ + return (!!def.getEnd && typeof def.getEnd === 'function'); +} + +function hasGetters (def) +{ + return hasGetStart(def) || hasGetEnd(def); +} + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetValueOp + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} propertyValue - [description] + * + * @return {function} [description] + */ +var GetValueOp = function (key, propertyValue) +{ + var callbacks; + + // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) + var getEnd = function (target, key, value) { return value; }; + + // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) + var getStart = function (target, key, value) { return value; }; + + var t = typeof(propertyValue); + + if (t === 'number') + { + // props: { + // x: 400, + // y: 300 + // } + + getEnd = function () + { + return propertyValue; + }; + } + else if (t === 'string') + { + // props: { + // x: '+=400', + // y: '-=300', + // z: '*=2', + // w: '/=2' + // } + + var op = propertyValue[0]; + var num = parseFloat(propertyValue.substr(2)); + + switch (op) + { + case '+': + getEnd = function (target, key, value) + { + return value + num; + }; + break; + + case '-': + getEnd = function (target, key, value) + { + return value - num; + }; + break; + + case '*': + getEnd = function (target, key, value) + { + return value * num; + }; + break; + + case '/': + getEnd = function (target, key, value) + { + return value / num; + }; + break; + + default: + getEnd = function () + { + return parseFloat(propertyValue); + }; + } + } + else if (t === 'function') + { + // The same as setting just the getEnd function and no getStart + + // props: { + // x: function (target, key, value) { return value + 50); }, + // } + + getEnd = propertyValue; + } + else if (t === 'object' && hasGetters(propertyValue)) + { + /* + x: { + // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. + getEnd: function (target, key, value) + { + return value; + }, + + // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. + getStart: function (target, key, value) + { + return value; + } + } + */ + + if (hasGetEnd(propertyValue)) + { + getEnd = propertyValue.getEnd; + } + + if (hasGetStart(propertyValue)) + { + getStart = propertyValue.getStart; + } + } + else if (propertyValue.hasOwnProperty('value')) + { + // Value may still be a string, function or a number + // props: { + // x: { value: 400, ... }, + // y: { value: 300, ... } + // } + + callbacks = GetValueOp(key, propertyValue.value); + } + + // If callback not set by the else if block above then set it here and return it + if (!callbacks) + { + callbacks = { + getEnd: getEnd, + getStart: getStart + }; + } + + return callbacks; +}; + +module.exports = GetValueOp; + + +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetTargets + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {array} [description] + */ +var GetTargets = function (config) +{ + var targets = GetValue(config, 'targets', null); + + if (targets === null) + { + return targets; + } + + if (typeof targets === 'function') + { + targets = targets.call(); + } + + if (!Array.isArray(targets)) + { + targets = [ targets ]; + } + + return targets; +}; + +module.exports = GetTargets; + + +/***/ }), +/* 141 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(30); +var MapData = __webpack_require__(86); +var Parse = __webpack_require__(230); +var Tilemap = __webpack_require__(222); + +/** + * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When + * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from + * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For + * an empty map, you should specify tileWidth, tileHeight, width & height. + * + * @function Phaser.Tilemaps.ParseToTilemap + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. + * @param {integer} [width=10] - The width of the map in tiles. + * @param {integer} [height=10] - The height of the map in tiles. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} + */ +var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull) +{ + if (tileWidth === undefined) { tileWidth = 32; } + if (tileHeight === undefined) { tileHeight = 32; } + if (width === undefined) { width = 10; } + if (height === undefined) { height = 10; } + if (insertNull === undefined) { insertNull = false; } + + var mapData = null; + + if (Array.isArray(data)) + { + var name = key !== undefined ? key : 'map'; + mapData = Parse(name, Formats.ARRAY_2D, data, tileWidth, tileHeight, insertNull); + } + else if (key !== undefined) + { + var tilemapData = scene.cache.tilemap.get(key); + + if (!tilemapData) + { + console.warn('No map data found for key ' + key); + } + else + { + mapData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull); + } + } + + if (mapData === null) + { + mapData = new MapData({ + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + } + + return new Tilemap(scene, mapData); +}; + +module.exports = ParseToTilemap; + + +/***/ }), +/* 142 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(30); +var LayerData = __webpack_require__(87); +var MapData = __webpack_require__(86); +var Tile = __webpack_require__(61); + +/** + * Parses a 2D array of tile indexes into a new MapData object with a single layer. + * + * @function Phaser.Tilemaps.Parsers.Parse2DArray + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer[][]} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.MapData} [description] + */ +var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull) +{ + var layerData = new LayerData({ + tileWidth: tileWidth, + tileHeight: tileHeight + }); + + var mapData = new MapData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + format: Formats.ARRAY_2D, + layers: [ layerData ] + }); + + var tiles = []; + var height = data.length; + var width = 0; + + for (var y = 0; y < data.length; y++) + { + tiles[y] = []; + var row = data[y]; + + for (var x = 0; x < row.length; x++) + { + var tileIndex = parseInt(row[x], 10); + + if (isNaN(tileIndex) || tileIndex === -1) + { + tiles[y][x] = insertNull + ? null + : new Tile(layerData, -1, x, y, tileWidth, tileHeight); + } + else + { + tiles[y][x] = new Tile(layerData, tileIndex, x, y, tileWidth, tileHeight); + } + } + + if (width === 0) + { + width = row.length; + } + } + + mapData.width = layerData.width = width; + mapData.height = layerData.height = height; + mapData.widthInPixels = layerData.widthInPixels = width * tileWidth; + mapData.heightInPixels = layerData.heightInPixels = height * tileHeight; + layerData.data = tiles; + + return mapData; +}; + +module.exports = Parse2DArray; + + +/***/ }), +/* 143 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internally used method to keep track of the tile indexes that collide within a layer. This + * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. + * + * @function Phaser.Tilemaps.Components.SetLayerCollisionIndex + * @private + * @since 3.0.0 + * + * @param {integer} tileIndex - The tile index to set the collision boolean for. + * @param {boolean} [collides=true] - Should the tile index collide or not? + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetLayerCollisionIndex = function (tileIndex, collides, layer) +{ + var loc = layer.collideIndexes.indexOf(tileIndex); + + if (collides && loc === -1) + { + layer.collideIndexes.push(tileIndex); + } + else if (!collides && loc !== -1) + { + layer.collideIndexes.splice(loc, 1); + } +}; + +module.exports = SetLayerCollisionIndex; + + +/***/ }), +/* 144 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tile = __webpack_require__(61); +var IsInLayerBounds = __webpack_require__(88); +var CalculateFacesAt = __webpack_require__(145); +var SetTileCollision = __webpack_require__(62); + +/** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * @function Phaser.Tilemaps.Components.PutTileAt + * @private + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + */ +var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) +{ + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var oldTile = layer.data[tileY][tileX]; + var oldTileCollides = oldTile && oldTile.collides; + + if (tile instanceof Tile) + { + if (layer.data[tileY][tileX] === null) + { + layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); + } + layer.data[tileY][tileX].copy(tile); + } + else + { + var index = tile; + if (layer.data[tileY][tileX] === null) + { + layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight); + } + else + { + layer.data[tileY][tileX].index = index; + } + } + + // Updating colliding flag on the new tile + var newTile = layer.data[tileY][tileX]; + var collides = layer.collideIndexes.indexOf(newTile.index) !== -1; + SetTileCollision(newTile, collides); + + // Recalculate faces only if the colliding flag at (tileX, tileY) has changed + if (recalculateFaces && (oldTileCollides !== newTile.collides)) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return newTile; +}; + +module.exports = PutTileAt; + + + +/***/ }), +/* 145 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(110); + +/** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @function Phaser.Tilemaps.Components.CalculateFacesAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var CalculateFacesAt = function (tileX, tileY, layer) +{ + var tile = GetTileAt(tileX, tileY, true, layer); + var above = GetTileAt(tileX, tileY - 1, true, layer); + var below = GetTileAt(tileX, tileY + 1, true, layer); + var left = GetTileAt(tileX - 1, tileY, true, layer); + var right = GetTileAt(tileX + 1, tileY, true, layer); + var tileCollides = tile && tile.collides; + + // Assume the changed tile has all interesting edges + if (tileCollides) + { + tile.faceTop = true; + tile.faceBottom = true; + tile.faceLeft = true; + tile.faceRight = true; + } + + // Reset edges that are shared between tile and its neighbors + if (above && above.collides) + { + if (tileCollides) { tile.faceTop = false; } + above.faceBottom = !tileCollides; + } + + if (below && below.collides) + { + if (tileCollides) { tile.faceBottom = false; } + below.faceTop = !tileCollides; + } + + if (left && left.collides) + { + if (tileCollides) { tile.faceLeft = false; } + left.faceRight = !tileCollides; + } + + if (right && right.collides) + { + if (tileCollides) { tile.faceRight = false; } + right.faceLeft = !tileCollides; + } + + if (tile && !tile.collides) { tile.resetFaces(); } + + return tile; +}; + +module.exports = CalculateFacesAt; + + +/***/ }), +/* 146 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.World` module contains methods for creating and manipulating the world composite. +* A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. +* A `Matter.World` has a few additional properties including `gravity` and `bounds`. +* It is important to use the functions in the `Matter.Composite` module to modify the world composite, rather than directly modifying its properties. +* There are also a few methods here that alias those in `Matter.Composite` for easier readability. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class World +* @extends Composite +*/ + +var World = {}; + +module.exports = World; + +var Composite = __webpack_require__(63); +var Constraint = __webpack_require__(73); +var Common = __webpack_require__(12); + +(function() { + + /** + * Creates a new world composite. The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @constructor + * @param {} options + * @return {world} A new world + */ + World.create = function(options) { + var composite = Composite.create(); + + var defaults = { + label: 'World', + gravity: { + x: 0, + y: 1, + scale: 0.001 + }, + bounds: { + min: { x: -Infinity, y: -Infinity }, + max: { x: Infinity, y: Infinity } + } + }; + + return Common.extend(composite, defaults, options); + }; + + /* + * + * Properties Documentation + * + */ + + /** + * The gravity to apply on the world. + * + * @property gravity + * @type object + */ + + /** + * The gravity x component. + * + * @property gravity.x + * @type object + * @default 0 + */ + + /** + * The gravity y component. + * + * @property gravity.y + * @type object + * @default 1 + */ + + /** + * The gravity scale factor. + * + * @property gravity.scale + * @type object + * @default 0.001 + */ + + /** + * A `Bounds` object that defines the world bounds for collision detection. + * + * @property bounds + * @type bounds + * @default { min: { x: -Infinity, y: -Infinity }, max: { x: Infinity, y: Infinity } } + */ + + // World is a Composite body + // see src/module/Outro.js for these aliases: + + /** + * An alias for Composite.add + * @method add + * @param {world} world + * @param {} object + * @return {composite} The original world with the objects added + */ + + /** + * An alias for Composite.remove + * @method remove + * @param {world} world + * @param {} object + * @param {boolean} [deep=false] + * @return {composite} The original world with the objects removed + */ + + /** + * An alias for Composite.clear + * @method clear + * @param {world} world + * @param {boolean} keepStatic + */ + + /** + * An alias for Composite.addComposite + * @method addComposite + * @param {world} world + * @param {composite} composite + * @return {world} The original world with the objects from composite added + */ + + /** + * An alias for Composite.addBody + * @method addBody + * @param {world} world + * @param {body} body + * @return {world} The original world with the body added + */ + + /** + * An alias for Composite.addConstraint + * @method addConstraint + * @param {world} world + * @param {constraint} constraint + * @return {world} The original world with the constraint added + */ + +})(); + + +/***/ }), +/* 147 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Plugin` module contains functions for registering and installing plugins on modules. +* +* @class Plugin +*/ + +var Plugin = {}; + +module.exports = Plugin; + +var Common = __webpack_require__(12); + +(function() { + + Plugin._registry = {}; + + /** + * Registers a plugin object so it can be resolved later by name. + * @method register + * @param plugin {} The plugin to register. + * @return {object} The plugin. + */ + Plugin.register = function(plugin) { + if (!Plugin.isPlugin(plugin)) { + Common.warn('Plugin.register:', Plugin.toString(plugin), 'does not implement all required fields.'); + } + + if (plugin.name in Plugin._registry) { + var registered = Plugin._registry[plugin.name], + pluginVersion = Plugin.versionParse(plugin.version).number, + registeredVersion = Plugin.versionParse(registered.version).number; + + if (pluginVersion > registeredVersion) { + Common.warn('Plugin.register:', Plugin.toString(registered), 'was upgraded to', Plugin.toString(plugin)); + Plugin._registry[plugin.name] = plugin; + } else if (pluginVersion < registeredVersion) { + Common.warn('Plugin.register:', Plugin.toString(registered), 'can not be downgraded to', Plugin.toString(plugin)); + } else if (plugin !== registered) { + Common.warn('Plugin.register:', Plugin.toString(plugin), 'is already registered to different plugin object'); + } + } else { + Plugin._registry[plugin.name] = plugin; + } + + return plugin; + }; + + /** + * Resolves a dependency to a plugin object from the registry if it exists. + * The `dependency` may contain a version, but only the name matters when resolving. + * @method resolve + * @param dependency {string} The dependency. + * @return {object} The plugin if resolved, otherwise `undefined`. + */ + Plugin.resolve = function(dependency) { + return Plugin._registry[Plugin.dependencyParse(dependency).name]; + }; + + /** + * Returns a pretty printed plugin name and version. + * @method toString + * @param plugin {} The plugin. + * @return {string} Pretty printed plugin name and version. + */ + Plugin.toString = function(plugin) { + return typeof plugin === 'string' ? plugin : (plugin.name || 'anonymous') + '@' + (plugin.version || plugin.range || '0.0.0'); + }; + + /** + * Returns `true` if the object meets the minimum standard to be considered a plugin. + * This means it must define the following properties: + * - `name` + * - `version` + * - `install` + * @method isPlugin + * @param obj {} The obj to test. + * @return {boolean} `true` if the object can be considered a plugin otherwise `false`. + */ + Plugin.isPlugin = function(obj) { + return obj && obj.name && obj.version && obj.install; + }; + + /** + * Returns `true` if a plugin with the given `name` been installed on `module`. + * @method isUsed + * @param module {} The module. + * @param name {string} The plugin name. + * @return {boolean} `true` if a plugin with the given `name` been installed on `module`, otherwise `false`. + */ + Plugin.isUsed = function(module, name) { + return module.used.indexOf(name) > -1; + }; + + /** + * Returns `true` if `plugin.for` is applicable to `module` by comparing against `module.name` and `module.version`. + * If `plugin.for` is not specified then it is assumed to be applicable. + * The value of `plugin.for` is a string of the format `'module-name'` or `'module-name@version'`. + * @method isFor + * @param plugin {} The plugin. + * @param module {} The module. + * @return {boolean} `true` if `plugin.for` is applicable to `module`, otherwise `false`. + */ + Plugin.isFor = function(plugin, module) { + var parsed = plugin.for && Plugin.dependencyParse(plugin.for); + return !plugin.for || (module.name === parsed.name && Plugin.versionSatisfies(module.version, parsed.range)); + }; + + /** + * Installs the plugins by calling `plugin.install` on each plugin specified in `plugins` if passed, otherwise `module.uses`. + * For installing plugins on `Matter` see the convenience function `Matter.use`. + * Plugins may be specified either by their name or a reference to the plugin object. + * Plugins themselves may specify further dependencies, but each plugin is installed only once. + * Order is important, a topological sort is performed to find the best resulting order of installation. + * This sorting attempts to satisfy every dependency's requested ordering, but may not be exact in all cases. + * This function logs the resulting status of each dependency in the console, along with any warnings. + * - A green tick ✅ indicates a dependency was resolved and installed. + * - An orange diamond 🔶 indicates a dependency was resolved but a warning was thrown for it or one if its dependencies. + * - A red cross ❌ indicates a dependency could not be resolved. + * Avoid calling this function multiple times on the same module unless you intend to manually control installation order. + * @method use + * @param module {} The module install plugins on. + * @param [plugins=module.uses] {} The plugins to install on module (optional, defaults to `module.uses`). + */ + Plugin.use = function(module, plugins) { + module.uses = (module.uses || []).concat(plugins || []); + + if (module.uses.length === 0) { + Common.warn('Plugin.use:', Plugin.toString(module), 'does not specify any dependencies to install.'); + return; + } + + var dependencies = Plugin.dependencies(module), + sortedDependencies = Common.topologicalSort(dependencies), + status = []; + + for (var i = 0; i < sortedDependencies.length; i += 1) { + if (sortedDependencies[i] === module.name) { + continue; + } + + var plugin = Plugin.resolve(sortedDependencies[i]); + + if (!plugin) { + status.push('❌ ' + sortedDependencies[i]); + continue; + } + + if (Plugin.isUsed(module, plugin.name)) { + continue; + } + + if (!Plugin.isFor(plugin, module)) { + Common.warn('Plugin.use:', Plugin.toString(plugin), 'is for', plugin.for, 'but installed on', Plugin.toString(module) + '.'); + plugin._warned = true; + } + + if (plugin.install) { + plugin.install(module); + } else { + Common.warn('Plugin.use:', Plugin.toString(plugin), 'does not specify an install function.'); + plugin._warned = true; + } + + if (plugin._warned) { + status.push('🔶 ' + Plugin.toString(plugin)); + delete plugin._warned; + } else { + status.push('✅ ' + Plugin.toString(plugin)); + } + + module.used.push(plugin.name); + } + + if (status.length > 0 && !plugin.silent) { + Common.info(status.join(' ')); + } + }; + + /** + * Recursively finds all of a module's dependencies and returns a flat dependency graph. + * @method dependencies + * @param module {} The module. + * @return {object} A dependency graph. + */ + Plugin.dependencies = function(module, tracked) { + var parsedBase = Plugin.dependencyParse(module), + name = parsedBase.name; + + tracked = tracked || {}; + + if (name in tracked) { + return; + } + + module = Plugin.resolve(module) || module; + + tracked[name] = Common.map(module.uses || [], function(dependency) { + if (Plugin.isPlugin(dependency)) { + Plugin.register(dependency); + } + + var parsed = Plugin.dependencyParse(dependency), + resolved = Plugin.resolve(dependency); + + if (resolved && !Plugin.versionSatisfies(resolved.version, parsed.range)) { + Common.warn( + 'Plugin.dependencies:', Plugin.toString(resolved), 'does not satisfy', + Plugin.toString(parsed), 'used by', Plugin.toString(parsedBase) + '.' + ); + + resolved._warned = true; + module._warned = true; + } else if (!resolved) { + Common.warn( + 'Plugin.dependencies:', Plugin.toString(dependency), 'used by', + Plugin.toString(parsedBase), 'could not be resolved.' + ); + + module._warned = true; + } + + return parsed.name; + }); + + for (var i = 0; i < tracked[name].length; i += 1) { + Plugin.dependencies(tracked[name][i], tracked); + } + + return tracked; + }; + + /** + * Parses a dependency string into its components. + * The `dependency` is a string of the format `'module-name'` or `'module-name@version'`. + * See documentation for `Plugin.versionParse` for a description of the format. + * This function can also handle dependencies that are already resolved (e.g. a module object). + * @method dependencyParse + * @param dependency {string} The dependency of the format `'module-name'` or `'module-name@version'`. + * @return {object} The dependency parsed into its components. + */ + Plugin.dependencyParse = function(dependency) { + if (Common.isString(dependency)) { + var pattern = /^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/; + + if (!pattern.test(dependency)) { + Common.warn('Plugin.dependencyParse:', dependency, 'is not a valid dependency string.'); + } + + return { + name: dependency.split('@')[0], + range: dependency.split('@')[1] || '*' + }; + } + + return { + name: dependency.name, + range: dependency.range || dependency.version + }; + }; + + /** + * Parses a version string into its components. + * Versions are strictly of the format `x.y.z` (as in [semver](http://semver.org/)). + * Versions may optionally have a prerelease tag in the format `x.y.z-alpha`. + * Ranges are a strict subset of [npm ranges](https://docs.npmjs.com/misc/semver#advanced-range-syntax). + * Only the following range types are supported: + * - Tilde ranges e.g. `~1.2.3` + * - Caret ranges e.g. `^1.2.3` + * - Exact version e.g. `1.2.3` + * - Any version `*` + * @method versionParse + * @param range {string} The version string. + * @return {object} The version range parsed into its components. + */ + Plugin.versionParse = function(range) { + var pattern = /^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/; + + if (!pattern.test(range)) { + Common.warn('Plugin.versionParse:', range, 'is not a valid version or range.'); + } + + var identifiers = range.split('-'); + range = identifiers[0]; + + var isRange = isNaN(Number(range[0])), + version = isRange ? range.substr(1) : range, + parts = Common.map(version.split('.'), function(part) { + return Number(part); + }); + + return { + isRange: isRange, + version: version, + range: range, + operator: isRange ? range[0] : '', + parts: parts, + prerelease: identifiers[1], + number: parts[0] * 1e8 + parts[1] * 1e4 + parts[2] + }; + }; + + /** + * Returns `true` if `version` satisfies the given `range`. + * See documentation for `Plugin.versionParse` for a description of the format. + * If a version or range is not specified, then any version (`*`) is assumed to satisfy. + * @method versionSatisfies + * @param version {string} The version string. + * @param range {string} The range string. + * @return {boolean} `true` if `version` satisfies `range`, otherwise `false`. + */ + Plugin.versionSatisfies = function(version, range) { + range = range || '*'; + + var rangeParsed = Plugin.versionParse(range), + rangeParts = rangeParsed.parts, + versionParsed = Plugin.versionParse(version), + versionParts = versionParsed.parts; + + if (rangeParsed.isRange) { + if (rangeParsed.operator === '*' || version === '*') { + return true; + } + + if (rangeParsed.operator === '~') { + return versionParts[0] === rangeParts[0] && versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; + } + + if (rangeParsed.operator === '^') { + if (rangeParts[0] > 0) { + return versionParts[0] === rangeParts[0] && versionParsed.number >= rangeParsed.number; + } + + if (rangeParts[1] > 0) { + return versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; + } + + return versionParts[2] === rangeParts[2]; + } + } + + return version === range || version === '*'; + }; + +})(); + + +/***/ }), +/* 148 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Matter = __webpack_require__(240); + +Matter.Body = __webpack_require__(25); +Matter.Composite = __webpack_require__(63); +Matter.World = __webpack_require__(146); + +Matter.Detector = __webpack_require__(150); +Matter.Grid = __webpack_require__(239); +Matter.Pairs = __webpack_require__(238); +Matter.Pair = __webpack_require__(112); +Matter.Query = __webpack_require__(536); +Matter.Resolver = __webpack_require__(237); +Matter.SAT = __webpack_require__(149); + +Matter.Constraint = __webpack_require__(73); + +Matter.Common = __webpack_require__(12); +Matter.Engine = __webpack_require__(236); +Matter.Events = __webpack_require__(74); +Matter.Sleeping = __webpack_require__(89); +Matter.Plugin = __webpack_require__(147); + +Matter.Bodies = __webpack_require__(55); +Matter.Composites = __webpack_require__(243); + +Matter.Axes = __webpack_require__(152); +Matter.Bounds = __webpack_require__(33); +Matter.Svg = __webpack_require__(534); +Matter.Vector = __webpack_require__(34); +Matter.Vertices = __webpack_require__(29); + +// aliases + +Matter.World.add = Matter.Composite.add; +Matter.World.remove = Matter.Composite.remove; +Matter.World.addComposite = Matter.Composite.addComposite; +Matter.World.addBody = Matter.Composite.addBody; +Matter.World.addConstraint = Matter.Composite.addConstraint; +Matter.World.clear = Matter.Composite.clear; + +module.exports = Matter; + + +/***/ }), +/* 149 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.SAT` module contains methods for detecting collisions using the Separating Axis Theorem. +* +* @class SAT +*/ + +// TODO: true circles and curves + +var SAT = {}; + +module.exports = SAT; + +var Vertices = __webpack_require__(29); +var Vector = __webpack_require__(34); + +(function() { + + /** + * Detect collision between two bodies using the Separating Axis Theorem. + * @method collides + * @param {body} bodyA + * @param {body} bodyB + * @param {collision} previousCollision + * @return {collision} collision + */ + SAT.collides = function(bodyA, bodyB, previousCollision) { + var overlapAB, + overlapBA, + minOverlap, + collision, + canReusePrevCol = false; + + if (previousCollision) { + // estimate total motion + var parentA = bodyA.parent, + parentB = bodyB.parent, + motion = parentA.speed * parentA.speed + parentA.angularSpeed * parentA.angularSpeed + + parentB.speed * parentB.speed + parentB.angularSpeed * parentB.angularSpeed; + + // we may be able to (partially) reuse collision result + // but only safe if collision was resting + canReusePrevCol = previousCollision && previousCollision.collided && motion < 0.2; + + // reuse collision object + collision = previousCollision; + } else { + collision = { collided: false, bodyA: bodyA, bodyB: bodyB }; + } + + if (previousCollision && canReusePrevCol) { + // if we can reuse the collision result + // we only need to test the previously found axis + var axisBodyA = collision.axisBody, + axisBodyB = axisBodyA === bodyA ? bodyB : bodyA, + axes = [axisBodyA.axes[previousCollision.axisNumber]]; + + minOverlap = SAT._overlapAxes(axisBodyA.vertices, axisBodyB.vertices, axes); + collision.reused = true; + + if (minOverlap.overlap <= 0) { + collision.collided = false; + return collision; + } + } else { + // if we can't reuse a result, perform a full SAT test + + overlapAB = SAT._overlapAxes(bodyA.vertices, bodyB.vertices, bodyA.axes); + + if (overlapAB.overlap <= 0) { + collision.collided = false; + return collision; + } + + overlapBA = SAT._overlapAxes(bodyB.vertices, bodyA.vertices, bodyB.axes); + + if (overlapBA.overlap <= 0) { + collision.collided = false; + return collision; + } + + if (overlapAB.overlap < overlapBA.overlap) { + minOverlap = overlapAB; + collision.axisBody = bodyA; + } else { + minOverlap = overlapBA; + collision.axisBody = bodyB; + } + + // important for reuse later + collision.axisNumber = minOverlap.axisNumber; + } + + collision.bodyA = bodyA.id < bodyB.id ? bodyA : bodyB; + collision.bodyB = bodyA.id < bodyB.id ? bodyB : bodyA; + collision.collided = true; + collision.depth = minOverlap.overlap; + collision.parentA = collision.bodyA.parent; + collision.parentB = collision.bodyB.parent; + + bodyA = collision.bodyA; + bodyB = collision.bodyB; + + // ensure normal is facing away from bodyA + if (Vector.dot(minOverlap.axis, Vector.sub(bodyB.position, bodyA.position)) < 0) { + collision.normal = { + x: minOverlap.axis.x, + y: minOverlap.axis.y + }; + } else { + collision.normal = { + x: -minOverlap.axis.x, + y: -minOverlap.axis.y + }; + } + + collision.tangent = Vector.perp(collision.normal); + + collision.penetration = collision.penetration || {}; + collision.penetration.x = collision.normal.x * collision.depth; + collision.penetration.y = collision.normal.y * collision.depth; + + // find support points, there is always either exactly one or two + var verticesB = SAT._findSupports(bodyA, bodyB, collision.normal), + supports = []; + + // find the supports from bodyB that are inside bodyA + if (Vertices.contains(bodyA.vertices, verticesB[0])) + supports.push(verticesB[0]); + + if (Vertices.contains(bodyA.vertices, verticesB[1])) + supports.push(verticesB[1]); + + // find the supports from bodyA that are inside bodyB + if (supports.length < 2) { + var verticesA = SAT._findSupports(bodyB, bodyA, Vector.neg(collision.normal)); + + if (Vertices.contains(bodyB.vertices, verticesA[0])) + supports.push(verticesA[0]); + + if (supports.length < 2 && Vertices.contains(bodyB.vertices, verticesA[1])) + supports.push(verticesA[1]); + } + + // account for the edge case of overlapping but no vertex containment + if (supports.length < 1) + supports = [verticesB[0]]; + + collision.supports = supports; + + return collision; + }; + + /** + * Find the overlap between two sets of vertices. + * @method _overlapAxes + * @private + * @param {} verticesA + * @param {} verticesB + * @param {} axes + * @return result + */ + SAT._overlapAxes = function(verticesA, verticesB, axes) { + var projectionA = Vector._temp[0], + projectionB = Vector._temp[1], + result = { overlap: Number.MAX_VALUE }, + overlap, + axis; + + for (var i = 0; i < axes.length; i++) { + axis = axes[i]; + + SAT._projectToAxis(projectionA, verticesA, axis); + SAT._projectToAxis(projectionB, verticesB, axis); + + overlap = Math.min(projectionA.max - projectionB.min, projectionB.max - projectionA.min); + + if (overlap <= 0) { + result.overlap = overlap; + return result; + } + + if (overlap < result.overlap) { + result.overlap = overlap; + result.axis = axis; + result.axisNumber = i; + } + } + + return result; + }; + + /** + * Projects vertices on an axis and returns an interval. + * @method _projectToAxis + * @private + * @param {} projection + * @param {} vertices + * @param {} axis + */ + SAT._projectToAxis = function(projection, vertices, axis) { + var min = Vector.dot(vertices[0], axis), + max = min; + + for (var i = 1; i < vertices.length; i += 1) { + var dot = Vector.dot(vertices[i], axis); + + if (dot > max) { + max = dot; + } else if (dot < min) { + min = dot; + } + } + + projection.min = min; + projection.max = max; + }; + + /** + * Finds supporting vertices given two bodies along a given direction using hill-climbing. + * @method _findSupports + * @private + * @param {} bodyA + * @param {} bodyB + * @param {} normal + * @return [vector] + */ + SAT._findSupports = function(bodyA, bodyB, normal) { + var nearestDistance = Number.MAX_VALUE, + vertexToBody = Vector._temp[0], + vertices = bodyB.vertices, + bodyAPosition = bodyA.position, + distance, + vertex, + vertexA, + vertexB; + + // find closest vertex on bodyB + for (var i = 0; i < vertices.length; i++) { + vertex = vertices[i]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + distance = -Vector.dot(normal, vertexToBody); + + if (distance < nearestDistance) { + nearestDistance = distance; + vertexA = vertex; + } + } + + // find next closest vertex using the two connected to it + var prevIndex = vertexA.index - 1 >= 0 ? vertexA.index - 1 : vertices.length - 1; + vertex = vertices[prevIndex]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + nearestDistance = -Vector.dot(normal, vertexToBody); + vertexB = vertex; + + var nextIndex = (vertexA.index + 1) % vertices.length; + vertex = vertices[nextIndex]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + distance = -Vector.dot(normal, vertexToBody); + if (distance < nearestDistance) { + vertexB = vertex; + } + + return [vertexA, vertexB]; + }; + +})(); + + +/***/ }), +/* 150 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Detector` module contains methods for detecting collisions given a set of pairs. +* +* @class Detector +*/ + +// TODO: speculative contacts + +var Detector = {}; + +module.exports = Detector; + +var SAT = __webpack_require__(149); +var Pair = __webpack_require__(112); +var Bounds = __webpack_require__(33); + +(function() { + + /** + * Finds all collisions given a list of pairs. + * @method collisions + * @param {pair[]} broadphasePairs + * @param {engine} engine + * @return {array} collisions + */ + Detector.collisions = function(broadphasePairs, engine) { + var collisions = [], + pairsTable = engine.pairs.table; + + // @if DEBUG + var metrics = engine.metrics; + // @endif + + for (var i = 0; i < broadphasePairs.length; i++) { + var bodyA = broadphasePairs[i][0], + bodyB = broadphasePairs[i][1]; + + if ((bodyA.isStatic || bodyA.isSleeping) && (bodyB.isStatic || bodyB.isSleeping)) + continue; + + if (!Detector.canCollide(bodyA.collisionFilter, bodyB.collisionFilter)) + continue; + + // @if DEBUG + metrics.midphaseTests += 1; + // @endif + + // mid phase + if (Bounds.overlaps(bodyA.bounds, bodyB.bounds)) { + for (var j = bodyA.parts.length > 1 ? 1 : 0; j < bodyA.parts.length; j++) { + var partA = bodyA.parts[j]; + + for (var k = bodyB.parts.length > 1 ? 1 : 0; k < bodyB.parts.length; k++) { + var partB = bodyB.parts[k]; + + if ((partA === bodyA && partB === bodyB) || Bounds.overlaps(partA.bounds, partB.bounds)) { + // find a previous collision we could reuse + var pairId = Pair.id(partA, partB), + pair = pairsTable[pairId], + previousCollision; + + if (pair && pair.isActive) { + previousCollision = pair.collision; + } else { + previousCollision = null; + } + + // narrow phase + var collision = SAT.collides(partA, partB, previousCollision); + + // @if DEBUG + metrics.narrowphaseTests += 1; + if (collision.reused) + metrics.narrowReuseCount += 1; + // @endif + + if (collision.collided) { + collisions.push(collision); + // @if DEBUG + metrics.narrowDetections += 1; + // @endif + } + } + } + } + } + } + + return collisions; + }; + + /** + * Returns `true` if both supplied collision filters will allow a collision to occur. + * See `body.collisionFilter` for more information. + * @method canCollide + * @param {} filterA + * @param {} filterB + * @return {bool} `true` if collision can occur + */ + Detector.canCollide = function(filterA, filterB) { + if (filterA.group === filterB.group && filterA.group !== 0) + return filterA.group > 0; + + return (filterA.mask & filterB.category) !== 0 && (filterB.mask & filterA.category) !== 0; + }; + +})(); + + +/***/ }), +/* 151 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bodies = __webpack_require__(55); +var Body = __webpack_require__(25); +var Class = __webpack_require__(0); +var Components = __webpack_require__(113); +var GetFastValue = __webpack_require__(1); +var HasValue = __webpack_require__(77); +var Vertices = __webpack_require__(29); + +/** + * @classdesc + * A wrapper around a Tile that provides access to a corresponding Matter body. A tile can only + * have one Matter body associated with it. You can either pass in an existing Matter body for + * the tile or allow the constructor to create the corresponding body for you. If the Tile has a + * collision group (defined in Tiled), those shapes will be used to create the body. If not, the + * tile's rectangle bounding box will be used. + * + * The corresponding body will be accessible on the Tile itself via Tile.physics.matterBody. + * + * Note: not all Tiled collision shapes are supported. See + * Phaser.Physics.Matter.TileBody#setFromTileCollision for more information. + * + * @class TileBody + * @memberof Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Matter.Components.Bounce + * @extends Phaser.Physics.Matter.Components.Collision + * @extends Phaser.Physics.Matter.Components.Friction + * @extends Phaser.Physics.Matter.Components.Gravity + * @extends Phaser.Physics.Matter.Components.Mass + * @extends Phaser.Physics.Matter.Components.Sensor + * @extends Phaser.Physics.Matter.Components.Sleep + * @extends Phaser.Physics.Matter.Components.Static + * + * @param {Phaser.Physics.Matter.World} world - [description] + * @param {Phaser.Tilemaps.Tile} tile - The target tile that should have a Matter body. + * @param {object} [options] - Options to be used when creating the Matter body. See + * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. + * @param {Phaser.Physics.Matter.Matter.Body} [options.body=null] - An existing Matter body to + * be used instead of creating a new one. + * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be + * made static. This defaults to true since typically tiles should not be moved. + * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or + * existing body if options.body is used) to the Matter world. + */ +var MatterTileBody = new Class({ + + Mixins: [ + Components.Bounce, + Components.Collision, + Components.Friction, + Components.Gravity, + Components.Mass, + Components.Sensor, + Components.Sleep, + Components.Static + ], + + initialize: + + function MatterTileBody (world, tile, options) + { + /** + * The tile object the body is associated with. + * + * @name Phaser.Physics.Matter.TileBody#tile + * @type {Phaser.Tilemaps.Tile} + * @since 3.0.0 + */ + this.tile = tile; + + /** + * The Matter world the body exists within. + * + * @name Phaser.Physics.Matter.TileBody#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; + + // Install a reference to 'this' on the tile and ensure there can only be one matter body + // associated with the tile + if (tile.physics.matterBody) + { + tile.physics.matterBody.destroy(); + } + + tile.physics.matterBody = this; + + // Set the body either from an existing body (if provided), the shapes in the tileset + // collision layer (if it exists) or a rectangle matching the tile. + var body = GetFastValue(options, 'body', null); + + var addToWorld = GetFastValue(options, 'addToWorld', true); + + if (!body) + { + var collisionGroup = tile.getCollisionGroup(); + var collisionObjects = GetFastValue(collisionGroup, 'objects', []); + + if (collisionObjects.length > 0) + { + this.setFromTileCollision(options); + } + else + { + this.setFromTileRectangle(options); + } + } + else + { + this.setBody(body, addToWorld); + } + }, + + /** + * Sets the current body to a rectangle that matches the bounds of the tile. + * + * @method Phaser.Physics.Matter.TileBody#setFromTileRectangle + * @since 3.0.0 + * + * @param {object} [options] - Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. + * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be + * made static. This defaults to true since typically tiles should not be moved. + * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or + * existing body if options.body is used) to the Matter world. + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + setFromTileRectangle: function (options) + { + if (options === undefined) { options = {}; } + if (!HasValue(options, 'isStatic')) { options.isStatic = true; } + if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } + + var bounds = this.tile.getBounds(); + var cx = bounds.x + (bounds.width / 2); + var cy = bounds.y + (bounds.height / 2); + var body = Bodies.rectangle(cx, cy, bounds.width, bounds.height, options); + + this.setBody(body, options.addToWorld); + + return this; + }, + + /** + * Sets the current body from the collision group associated with the Tile. This is typically + * set up in Tiled's collision editor. + * + * Note: Matter doesn't support all shapes from Tiled. Rectangles and polygons are directly + * supported. Ellipses are converted into circle bodies. Polylines are treated as if they are + * closed polygons. If a tile has multiple shapes, a multi-part body will be created. Concave + * shapes are supported if poly-decomp library is included. Decomposition is not guaranteed to + * work for complex shapes (e.g. holes), so it's often best to manually decompose a concave + * polygon into multiple convex polygons yourself. + * + * @method Phaser.Physics.Matter.TileBody#setFromTileCollision + * @since 3.0.0 + * + * @param {object} [options] - Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. + * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be + * made static. This defaults to true since typically tiles should not be moved. + * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or + * existing body if options.body is used) to the Matter world. + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + setFromTileCollision: function (options) + { + if (options === undefined) { options = {}; } + if (!HasValue(options, 'isStatic')) { options.isStatic = true; } + if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } + + var sx = this.tile.tilemapLayer.scaleX; + var sy = this.tile.tilemapLayer.scaleY; + var tileX = this.tile.getLeft(); + var tileY = this.tile.getTop(); + var collisionGroup = this.tile.getCollisionGroup(); + var collisionObjects = GetFastValue(collisionGroup, 'objects', []); + + var parts = []; + + for (var i = 0; i < collisionObjects.length; i++) + { + var object = collisionObjects[i]; + var ox = tileX + (object.x * sx); + var oy = tileY + (object.y * sy); + var ow = object.width * sx; + var oh = object.height * sy; + var body = null; + + if (object.rectangle) + { + body = Bodies.rectangle(ox + ow / 2, oy + oh / 2, ow, oh, options); + } + else if (object.ellipse) + { + body = Bodies.circle(ox + ow / 2, oy + oh / 2, ow / 2, options); + } + else if (object.polygon || object.polyline) + { + // Polygons and polylines are both treated as closed polygons + var originalPoints = object.polygon ? object.polygon : object.polyline; + + var points = originalPoints.map(function (p) + { + return { x: p.x * sx, y: p.y * sy }; + }); + + var vertices = Vertices.create(points); + + // Points are relative to the object's origin (first point placed in Tiled), but + // matter expects points to be relative to the center of mass. This only applies to + // convex shapes. When a concave shape is decomposed, multiple parts are created and + // the individual parts are positioned relative to (ox, oy). + if (Vertices.isConvex(points)) + { + var center = Vertices.centre(vertices); + ox += center.x; + oy += center.y; + } + + body = Bodies.fromVertices(ox, oy, vertices, options); + } + + if (body) + { + parts.push(body); + } + } + + if (parts.length === 1) + { + this.setBody(parts[0], options.addToWorld); + } + else if (parts.length > 1) + { + options.parts = parts; + this.setBody(Body.create(options), options.addToWorld); + } + + return this; + }, + + /** + * Sets the current body to the given body. This will remove the previous body, if one already + * exists. + * + * @method Phaser.Physics.Matter.TileBody#setBody + * @since 3.0.0 + * + * @param {MatterJS.Body} body - The new Matter body to use. + * @param {boolean} [addToWorld=true] - Whether or not to add the body to the Matter world. + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + setBody: function (body, addToWorld) + { + if (addToWorld === undefined) { addToWorld = true; } + + if (this.body) + { + this.removeBody(); + } + + this.body = body; + this.body.gameObject = this; + + if (addToWorld) + { + this.world.add(this.body); + } + + return this; + }, + + /** + * Removes the current body from the TileBody and from the Matter world + * + * @method Phaser.Physics.Matter.TileBody#removeBody + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + removeBody: function () + { + if (this.body) + { + this.world.remove(this.body); + this.body.gameObject = undefined; + this.body = undefined; + } + + return this; + }, + + /** + * Removes the current body from the tile and the world. + * + * @method Phaser.Physics.Matter.TileBody#destroy + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + destroy: function () + { + this.removeBody(); + this.tile.physics.matterBody = undefined; + } + +}); + +module.exports = MatterTileBody; + + +/***/ }), +/* 152 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Axes` module contains methods for creating and manipulating sets of axes. +* +* @class Axes +*/ + +var Axes = {}; + +module.exports = Axes; + +var Vector = __webpack_require__(34); +var Common = __webpack_require__(12); + +(function() { + + /** + * Creates a new set of axes from the given vertices. + * @method fromVertices + * @param {vertices} vertices + * @return {axes} A new axes from the given vertices + */ + Axes.fromVertices = function(vertices) { + var axes = {}; + + // find the unique axes, using edge normal gradients + for (var i = 0; i < vertices.length; i++) { + var j = (i + 1) % vertices.length, + normal = Vector.normalise({ + x: vertices[j].y - vertices[i].y, + y: vertices[i].x - vertices[j].x + }), + gradient = (normal.y === 0) ? Infinity : (normal.x / normal.y); + + // limit precision + gradient = gradient.toFixed(3).toString(); + axes[gradient] = normal; + } + + return Common.values(axes); + }; + + /** + * Rotates a set of axes by the given angle. + * @method rotate + * @param {axes} axes + * @param {number} angle + */ + Axes.rotate = function(axes, angle) { + if (angle === 0) + return; + + var cos = Math.cos(angle), + sin = Math.sin(angle); + + for (var i = 0; i < axes.length; i++) { + var axis = axes[i], + xx; + xx = axis.x * cos - axis.y * sin; + axis.y = axis.x * sin + axis.y * cos; + axis.x = xx; + } + }; + +})(); + + +/***/ }), +/* 153 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Impact.Components + */ + +module.exports = { + + Acceleration: __webpack_require__(568), + BodyScale: __webpack_require__(567), + BodyType: __webpack_require__(566), + Bounce: __webpack_require__(565), + CheckAgainst: __webpack_require__(564), + Collides: __webpack_require__(563), + Debug: __webpack_require__(562), + Friction: __webpack_require__(561), + Gravity: __webpack_require__(560), + Offset: __webpack_require__(559), + SetGameObject: __webpack_require__(558), + Velocity: __webpack_require__(557) + +}; + + +/***/ }), +/* 154 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A representation of a vector in 3D space. + * + * A three-component vector. + * + * @class Vector3 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + */ +var Vector3 = new Class({ + + initialize: + + function Vector3 (x, y, z) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector3#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector3#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector3#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.z = 0; + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + }, + + /** + * Set this Vector to point up. + * + * Sets the y component of the vector to 1, and the others to 0. + * + * @method Phaser.Math.Vector3#up + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + up: function () + { + this.x = 0; + this.y = 1; + this.z = 0; + + return this; + }, + + /** + * Make a clone of this Vector3. + * + * @method Phaser.Math.Vector3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} A new Vector3 object containing this Vectors values. + */ + clone: function () + { + return new Vector3(this.x, this.y, this.z); + }, + + /** + * Calculate the cross (vector) product of two given Vectors. + * + * @method Phaser.Math.Vector3#crossVectors + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - The first Vector to multiply. + * @param {Phaser.Math.Vector3} b - The second Vector to multiply. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + crossVectors: function (a, b) + { + var ax = a.x; + var ay = a.y; + var az = a.z; + var bx = b.x; + var by = b.y; + var bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict equality check against each Vector's components. + * + * @method Phaser.Math.Vector3#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to compare against. + * + * @return {boolean} True if the two vectors strictly match, otherwise false. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); + }, + + /** + * Copy the components of a given Vector into this Vector. + * + * @method Phaser.Math.Vector3#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + + return this; + }, + + /** + * Set the `x`, `y`, and `z` components of this Vector to the given `x`, `y`, and `z` values. + * + * @method Phaser.Math.Vector3#set + * @since 3.0.0 + * + * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y and z components. + * @param {number} [y] - The y value to set for this Vector. + * @param {number} [z] - The z value to set for this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + set: function (x, y, z) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + + return this; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector3#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector3#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector3#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector3#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + scale: function (scale) + { + if (isFinite(scale)) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + } + else + { + this.x = 0; + this.y = 0; + this.z = 0; + } + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector3#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + + return this; + }, + + /** + * Negate the `x`, `y` and `z` components of this Vector. + * + * @method Phaser.Math.Vector3#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector3#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector3#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return dx * dx + dy * dy + dz * dz; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector3#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return Math.sqrt(x * x + y * y + z * z); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector3#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return x * x + y * y + z * z; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector3#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var len = x * x + y * y + z * z; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector3#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to dot product with this Vector3. + * + * @return {number} The dot product of this Vector and `v`. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z; + }, + + /** + * Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector. + * + * @method Phaser.Math.Vector3#cross + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector to cross product with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + cross: function (v) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var bx = v.x; + var by = v.y; + var bz = v.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector3#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector3#transformMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformMat3: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = x * m[0] + y * m[3] + z * m[6]; + this.y = x * m[1] + y * m[4] + z * m[7]; + this.z = x * m[2] + y * m[5] + z * m[8]; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector3#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformCoordinates + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformCoordinates: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; + var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; + var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; + var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; + + this.x = tx / tw; + this.y = ty / tw; + this.z = tz / tw; + + return this; + }, + + /** + * Transform this Vector with the given Quaternion. + * + * @method Phaser.Math.Vector3#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformQuat: function (q) + { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, + * e.g. unprojecting a 2D point into 3D space. + * + * @method Phaser.Math.Vector3#project + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to multiply this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + project: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var a00 = m[0]; + var a01 = m[1]; + var a02 = m[2]; + var a03 = m[3]; + var a10 = m[4]; + var a11 = m[5]; + var a12 = m[6]; + var a13 = m[7]; + var a20 = m[8]; + var a21 = m[9]; + var a22 = m[10]; + var a23 = m[11]; + var a30 = m[12]; + var a31 = m[13]; + var a32 = m[14]; + var a33 = m[15]; + + var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); + + this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; + this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; + this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; + + return this; + }, + + /** + * Unproject this point from 2D space to 3D space. + * The point should have its x and y properties set to + * 2D screen space, and the z either at 0 (near plane) + * or 1 (far plane). The provided matrix is assumed to already + * be combined, i.e. projection * view * model. + * + * After this operation, this vector's (x, y, z) components will + * represent the unprojected 3D coordinate. + * + * @method Phaser.Math.Vector3#unproject + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} viewport - Screen x, y, width and height in pixels. + * @param {Phaser.Math.Matrix4} invProjectionView - Combined projection and view matrix. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + unproject: function (viewport, invProjectionView) + { + var viewX = viewport.x; + var viewY = viewport.y; + var viewWidth = viewport.z; + var viewHeight = viewport.w; + + var x = this.x - viewX; + var y = (viewHeight - this.y - 1) - viewY; + var z = this.z; + + this.x = (2 * x) / viewWidth - 1; + this.y = (2 * y) / viewHeight - 1; + this.z = 2 * z - 1; + + return this.project(invProjectionView); + }, + + /** + * Make this Vector the zero vector (0, 0, 0). + * + * @method Phaser.Math.Vector3#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + + return this; + } + +}); + +/* +Vector3.Zero = function () +{ + return new Vector3(0, 0, 0); +}; + +Vector3.Up = function () +{ + return new Vector3(0, 1.0, 0); +}; + +Vector3.Copy = function (source) +{ + return new Vector3(source.x, source.y, source.z); +}; + +Vector3.TransformCoordinates = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; + var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; + + return new Vector3(x / w, y / w, z / w); +}; + +Vector3.TransformNormal = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); + + return new Vector3(x, y, z); +}; + +Vector3.Dot = function (left, right) +{ + return (left.x * right.x + left.y * right.y + left.z * right.z); +}; + +Vector3.Cross = function (left, right) +{ + var x = left.y * right.z - left.z * right.y; + var y = left.z * right.x - left.x * right.z; + var z = left.x * right.y - left.y * right.x; + + return new Vector3(x, y, z); +}; + +Vector3.Normalize = function (vector) +{ + var newVector = Vector3.Copy(vector); + newVector.normalize(); + + return newVector; +}; + +Vector3.Distance = function (value1, value2) +{ + return Math.sqrt(Vector3.DistanceSquared(value1, value2)); +}; + +Vector3.DistanceSquared = function (value1, value2) +{ + var x = value1.x - value2.x; + var y = value1.y - value2.y; + var z = value1.z - value2.z; + + return (x * x) + (y * y) + (z * z); +}; +*/ + +module.exports = Vector3; + + +/***/ }), +/* 155 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); +var ParseXML = __webpack_require__(379); + +/** + * @typedef {object} Phaser.Loader.FileTypes.XMLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='xml'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single XML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. + * + * @class XMLFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var XMLFile = new Class({ + + Extends: File, + + initialize: + + function XMLFile (loader, key, url, xhrSettings) + { + var extension = 'xml'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'xml', + cache: loader.cacheManager.xml, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.XMLFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = ParseXML(this.xhrLoader.responseText); + + if (this.data) + { + this.onProcessComplete(); + } + else + { + console.warn('Invalid XMLFile: ' + this.key); + + this.onProcessError(); + } + } + +}); + +/** + * Adds an XML file, or array of XML files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.xml('wavedata', 'files/AlienWaveData.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global XML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the XML Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the XML Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.xml({ + * key: 'wavedata', + * url: 'files/AlienWaveData.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.XMLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.xml('wavedata', 'files/AlienWaveData.xml'); + * // and later in your game ... + * var data = this.cache.xml.get('wavedata'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the XML Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the XML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#xml + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig|Phaser.Loader.FileTypes.XMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('xml', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new XMLFile(this, key[i])); + } + } + else + { + this.addFile(new XMLFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = XMLFile; + + +/***/ }), +/* 156 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(21); +var XHRSettings = __webpack_require__(115); + +/** + * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * + * The new object is seeded by the values given in the global settings, but any setting in + * the local object overrides the global ones. + * + * @function Phaser.Loader.MergeXHRSettings + * @since 3.0.0 + * + * @param {XHRSettingsObject} global - The global XHRSettings object. + * @param {XHRSettingsObject} local - The local XHRSettings object. + * + * @return {XHRSettingsObject} A newly formed XHRSettings object. + */ +var MergeXHRSettings = function (global, local) +{ + var output = (global === undefined) ? XHRSettings() : Extend({}, global); + + if (local) + { + for (var setting in local) + { + if (local[setting] !== undefined) + { + output[setting] = local[setting]; + } + } + } + + return output; +}; + +module.exports = MergeXHRSettings; + + +/***/ }), +/* 157 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given a File and a baseURL value this returns the URL the File will use to download from. + * + * @function Phaser.Loader.GetURL + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File object. + * @param {string} baseURL - A default base URL. + * + * @return {string} The URL the File will use. + */ +var GetURL = function (file, baseURL) +{ + if (!file.url) + { + return false; + } + + if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) + { + return file.url; + } + else + { + return baseURL + file.url; + } +}; + +module.exports = GetURL; + + +/***/ }), +/* 158 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Snap a value to nearest grid slice, using floor. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10`. + * As will `14` snap to `10`... but `16` will snap to `15`. + * + * @function Phaser.Math.Snap.Floor + * @since 3.0.0 + * + * @param {number} value - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. + * + * @return {number} The snapped value. + */ +var SnapFloor = function (value, gap, start, divide) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.floor(value / gap); + + return (divide) ? (start + value) / gap : start + value; +}; + +module.exports = SnapFloor; + + +/***/ }), +/* 159 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Keyboard Codes. + * + * @name Phaser.Input.Keyboard.KeyCodes + * @enum {integer} + * @memberof Phaser.Input.Keyboard + * @readonly + * @since 3.0.0 + */ + +var KeyCodes = { + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACKSPACE + */ + BACKSPACE: 8, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.TAB + */ + TAB: 9, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ENTER + */ + ENTER: 13, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SHIFT + */ + SHIFT: 16, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CTRL + */ + CTRL: 17, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ALT + */ + ALT: 18, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAUSE + */ + PAUSE: 19, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CAPS_LOCK + */ + CAPS_LOCK: 20, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ESC + */ + ESC: 27, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SPACE + */ + SPACE: 32, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_UP + */ + PAGE_UP: 33, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_DOWN + */ + PAGE_DOWN: 34, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.END + */ + END: 35, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.HOME + */ + HOME: 36, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.LEFT + */ + LEFT: 37, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.UP + */ + UP: 38, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.RIGHT + */ + RIGHT: 39, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.DOWN + */ + DOWN: 40, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PRINT_SCREEN + */ + PRINT_SCREEN: 42, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.INSERT + */ + INSERT: 45, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.DELETE + */ + DELETE: 46, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ZERO + */ + ZERO: 48, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ONE + */ + ONE: 49, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.TWO + */ + TWO: 50, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.THREE + */ + THREE: 51, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FOUR + */ + FOUR: 52, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FIVE + */ + FIVE: 53, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SIX + */ + SIX: 54, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SEVEN + */ + SEVEN: 55, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.EIGHT + */ + EIGHT: 56, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NINE + */ + NINE: 57, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ZERO + */ + NUMPAD_ZERO: 96, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ONE + */ + NUMPAD_ONE: 97, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_TWO + */ + NUMPAD_TWO: 98, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_THREE + */ + NUMPAD_THREE: 99, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FOUR + */ + NUMPAD_FOUR: 100, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FIVE + */ + NUMPAD_FIVE: 101, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SIX + */ + NUMPAD_SIX: 102, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SEVEN + */ + NUMPAD_SEVEN: 103, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_EIGHT + */ + NUMPAD_EIGHT: 104, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_NINE + */ + NUMPAD_NINE: 105, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.A + */ + A: 65, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.B + */ + B: 66, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.C + */ + C: 67, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.D + */ + D: 68, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.E + */ + E: 69, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F + */ + F: 70, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.G + */ + G: 71, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.H + */ + H: 72, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.I + */ + I: 73, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.J + */ + J: 74, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.K + */ + K: 75, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.L + */ + L: 76, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.M + */ + M: 77, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.N + */ + N: 78, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.O + */ + O: 79, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.P + */ + P: 80, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Q + */ + Q: 81, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.R + */ + R: 82, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.S + */ + S: 83, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.T + */ + T: 84, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.U + */ + U: 85, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.V + */ + V: 86, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.W + */ + W: 87, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.X + */ + X: 88, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Y + */ + Y: 89, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Z + */ + Z: 90, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F1 + */ + F1: 112, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F2 + */ + F2: 113, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F3 + */ + F3: 114, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F4 + */ + F4: 115, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F5 + */ + F5: 116, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F6 + */ + F6: 117, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F7 + */ + F7: 118, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F8 + */ + F8: 119, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F9 + */ + F9: 120, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F10 + */ + F10: 121, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F11 + */ + F11: 122, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F12 + */ + F12: 123, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON + */ + SEMICOLON: 186, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PLUS + */ + PLUS: 187, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.COMMA + */ + COMMA: 188, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.MINUS + */ + MINUS: 189, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PERIOD + */ + PERIOD: 190, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FORWARD_SLASH + */ + FORWARD_SLASH: 191, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACK_SLASH + */ + BACK_SLASH: 220, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.QUOTES + */ + QUOTES: 222, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACKTICK + */ + BACKTICK: 192, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.OPEN_BRACKET + */ + OPEN_BRACKET: 219, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET + */ + CLOSED_BRACKET: 221 + +}; + +module.exports = KeyCodes; + + +/***/ }), +/* 160 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.RotateAroundXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var RotateAroundXY = function (triangle, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = triangle.x1 - x; + var ty = triangle.y1 - y; + + triangle.x1 = tx * c - ty * s + x; + triangle.y1 = tx * s + ty * c + y; + + tx = triangle.x2 - x; + ty = triangle.y2 - y; + + triangle.x2 = tx * c - ty * s + x; + triangle.y2 = tx * s + ty * c + y; + + tx = triangle.x3 - x; + ty = triangle.y3 - y; + + triangle.x3 = tx * c - ty * s + x; + triangle.y3 = tx * s + ty * c + y; + + return triangle; +}; + +module.exports = RotateAroundXY; + + +/***/ }), +/* 161 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.GetAspectRatio + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var GetAspectRatio = function (rect) +{ + return (rect.height === 0) ? NaN : rect.width / rect.height; +}; + +module.exports = GetAspectRatio; + + +/***/ }), +/* 162 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rotate a line around the given coordinates by the given angle in radians. + * + * @function Phaser.Geom.Line.RotateAroundXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {number} x - The horizontal coordinate to rotate the line around. + * @param {number} y - The vertical coordinate to rotate the line around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var RotateAroundXY = function (line, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = line.x1 - x; + var ty = line.y1 - y; + + line.x1 = tx * c - ty * s + x; + line.y1 = tx * s + ty * c + y; + + tx = line.x2 - x; + ty = line.y2 - y; + + line.x2 = tx * c - ty * s + x; + line.y2 = tx * s + ty * c + y; + + return line; +}; + +module.exports = RotateAroundXY; + + +/***/ }), +/* 163 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// http://www.blackpawn.com/texts/pointinpoly/ + +// points is an array of Point-like objects with public x/y properties +// returns an array containing all points that are within the triangle, or an empty array if none +// if 'returnFirst' is true it will return after the first point within the triangle is found + +/** + * Filters an array of point-like objects to only those contained within a triangle. + * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). + * + * @function Phaser.Geom.Triangle.ContainsArray + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The triangle that the points are being checked in. + * @param {Phaser.Geom.Point[]} points - An array of point-like objects (objects that have an `x` and `y` property) + * @param {boolean} [returnFirst=false] - If `true`, return an array containing only the first point found that is within the triangle. + * @param {array} [out] - If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. + * + * @return {Phaser.Geom.Point[]} An array containing all the points from `points` that are within the triangle, if an array was provided as `out`, points will be appended to that array and it will also be returned here. + */ +var ContainsArray = function (triangle, points, returnFirst, out) +{ + if (returnFirst === undefined) { returnFirst = false; } + if (out === undefined) { out = []; } + + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot11 = (v1x * v1x) + (v1y * v1y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + + var u; + var v; + var v2x; + var v2y; + var dot02; + var dot12; + + var x1 = triangle.x1; + var y1 = triangle.y1; + + for (var i = 0; i < points.length; i++) + { + v2x = points[i].x - x1; + v2y = points[i].y - y1; + + dot02 = (v0x * v2x) + (v0y * v2y); + dot12 = (v1x * v2x) + (v1y * v2y); + + u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + if (u >= 0 && v >= 0 && (u + v < 1)) + { + out.push({ x: points[i].x, y: points[i].y }); + + if (returnFirst) + { + break; + } + } + } + + return out; +}; + +module.exports = ContainsArray; + + +/***/ }), +/* 164 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var RectangleToRectangle = function (rectA, rectB) +{ + if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) + { + return false; + } + + return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); +}; + +module.exports = RectangleToRectangle; + + +/***/ }), +/* 165 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Mesh = __webpack_require__(118); + +/** + * @classdesc + * A Quad Game Object. + * + * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single + * texture spread across them. + * + * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also + * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. + * + * @class Quad + * @extends Phaser.GameObjects.Mesh + * @memberof Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Quad belongs. + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Quad = new Class({ + + Extends: Mesh, + + initialize: + + function Quad (scene, x, y, texture, frame) + { + // 0----3 + // |\ B| + // | \ | + // | \ | + // | A \| + // | \ + // 1----2 + + var vertices = [ + 0, 0, // tl + 0, 0, // bl + 0, 0, // br + 0, 0, // tl + 0, 0, // br + 0, 0 // tr + ]; + + var uv = [ + 0, 0, // tl + 0, 1, // bl + 1, 1, // br + 0, 0, // tl + 1, 1, // br + 1, 0 // tr + ]; + + var colors = [ + 0xffffff, // tl + 0xffffff, // bl + 0xffffff, // br + 0xffffff, // tl + 0xffffff, // br + 0xffffff // tr + ]; + + var alphas = [ + 1, // tl + 1, // bl + 1, // br + 1, // tl + 1, // br + 1 // tr + ]; + + Mesh.call(this, scene, x, y, vertices, uv, colors, alphas, texture, frame); + + this.resetPosition(); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Quad#setFrame + * @since 3.11.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame) + { + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~8; + } + else + { + this.renderFlags |= 8; + } + + frame = this.frame; + + // TL + this.uv[0] = frame.u0; + this.uv[1] = frame.v0; + + // BL + this.uv[2] = frame.u0; + this.uv[3] = frame.v1; + + // BR + this.uv[4] = frame.u1; + this.uv[5] = frame.v1; + + // TL + this.uv[6] = frame.u0; + this.uv[7] = frame.v0; + + // BR + this.uv[8] = frame.u1; + this.uv[9] = frame.v1; + + // TR + this.uv[10] = frame.u1; + this.uv[11] = frame.v0; + + return this; + }, + + /** + * The top-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftX + * @type {number} + * @since 3.0.0 + */ + topLeftX: { + + get: function () + { + return this.x + this.vertices[0]; + }, + + set: function (value) + { + this.vertices[0] = value - this.x; + this.vertices[6] = value - this.x; + } + + }, + + /** + * The top-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftY + * @type {number} + * @since 3.0.0 + */ + topLeftY: { + + get: function () + { + return this.y + this.vertices[1]; + }, + + set: function (value) + { + this.vertices[1] = value - this.y; + this.vertices[7] = value - this.y; + } + + }, + + /** + * The top-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightX + * @type {number} + * @since 3.0.0 + */ + topRightX: { + + get: function () + { + return this.x + this.vertices[10]; + }, + + set: function (value) + { + this.vertices[10] = value - this.x; + } + + }, + + /** + * The top-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightY + * @type {number} + * @since 3.0.0 + */ + topRightY: { + + get: function () + { + return this.y + this.vertices[11]; + }, + + set: function (value) + { + this.vertices[11] = value - this.y; + } + + }, + + /** + * The bottom-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftX + * @type {number} + * @since 3.0.0 + */ + bottomLeftX: { + + get: function () + { + return this.x + this.vertices[2]; + }, + + set: function (value) + { + this.vertices[2] = value - this.x; + } + + }, + + /** + * The bottom-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftY + * @type {number} + * @since 3.0.0 + */ + bottomLeftY: { + + get: function () + { + return this.y + this.vertices[3]; + }, + + set: function (value) + { + this.vertices[3] = value - this.y; + } + + }, + + /** + * The bottom-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightX + * @type {number} + * @since 3.0.0 + */ + bottomRightX: { + + get: function () + { + return this.x + this.vertices[4]; + }, + + set: function (value) + { + this.vertices[4] = value - this.x; + this.vertices[8] = value - this.x; + } + + }, + + /** + * The bottom-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightY + * @type {number} + * @since 3.0.0 + */ + bottomRightY: { + + get: function () + { + return this.y + this.vertices[5]; + }, + + set: function (value) + { + this.vertices[5] = value - this.y; + this.vertices[9] = value - this.y; + } + + }, + + /** + * The top-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftAlpha + * @type {number} + * @since 3.0.0 + */ + topLeftAlpha: { + + get: function () + { + return this.alphas[0]; + }, + + set: function (value) + { + this.alphas[0] = value; + this.alphas[3] = value; + } + + }, + + /** + * The top-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightAlpha + * @type {number} + * @since 3.0.0 + */ + topRightAlpha: { + + get: function () + { + return this.alphas[5]; + }, + + set: function (value) + { + this.alphas[5] = value; + } + + }, + + /** + * The bottom-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftAlpha + * @type {number} + * @since 3.0.0 + */ + bottomLeftAlpha: { + + get: function () + { + return this.alphas[1]; + }, + + set: function (value) + { + this.alphas[1] = value; + } + + }, + + /** + * The bottom-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightAlpha + * @type {number} + * @since 3.0.0 + */ + bottomRightAlpha: { + + get: function () + { + return this.alphas[2]; + }, + + set: function (value) + { + this.alphas[2] = value; + this.alphas[4] = value; + } + + }, + + /** + * The top-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftColor + * @type {number} + * @since 3.0.0 + */ + topLeftColor: { + + get: function () + { + return this.colors[0]; + }, + + set: function (value) + { + this.colors[0] = value; + this.colors[3] = value; + } + + }, + + /** + * The top-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightColor + * @type {number} + * @since 3.0.0 + */ + topRightColor: { + + get: function () + { + return this.colors[5]; + }, + + set: function (value) + { + this.colors[5] = value; + } + + }, + + /** + * The bottom-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftColor + * @type {number} + * @since 3.0.0 + */ + bottomLeftColor: { + + get: function () + { + return this.colors[1]; + }, + + set: function (value) + { + this.colors[1] = value; + } + + }, + + /** + * The bottom-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightColor + * @type {number} + * @since 3.0.0 + */ + bottomRightColor: { + + get: function () + { + return this.colors[2]; + }, + + set: function (value) + { + this.colors[2] = value; + this.colors[4] = value; + } + + }, + + /** + * Sets the top-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopLeft: function (x, y) + { + this.topLeftX = x; + this.topLeftY = y; + + return this; + }, + + /** + * Sets the top-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopRight: function (x, y) + { + this.topRightX = x; + this.topRightY = y; + + return this; + }, + + /** + * Sets the bottom-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomLeft: function (x, y) + { + this.bottomLeftX = x; + this.bottomLeftY = y; + + return this; + }, + + /** + * Sets the bottom-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomRight: function (x, y) + { + this.bottomRightX = x; + this.bottomRightY = y; + + return this; + }, + + /** + * Resets the positions of the four corner vertices of this Quad. + * + * @method Phaser.GameObjects.Quad#resetPosition + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetPosition: function () + { + var x = this.x; + var y = this.y; + var halfWidth = Math.floor(this.width / 2); + var halfHeight = Math.floor(this.height / 2); + + this.setTopLeft(x - halfWidth, y - halfHeight); + this.setTopRight(x + halfWidth, y - halfHeight); + this.setBottomLeft(x - halfWidth, y + halfHeight); + this.setBottomRight(x + halfWidth, y + halfHeight); + + return this; + }, + + /** + * Resets the alpha values used by this Quad back to 1. + * + * @method Phaser.GameObjects.Quad#resetAlpha + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetAlpha: function () + { + var alphas = this.alphas; + + alphas[0] = 1; + alphas[1] = 1; + alphas[2] = 1; + alphas[3] = 1; + alphas[4] = 1; + alphas[5] = 1; + + return this; + }, + + /** + * Resets the color values used by this Quad back to 0xffffff. + * + * @method Phaser.GameObjects.Quad#resetColors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetColors: function () + { + var colors = this.colors; + + colors[0] = 0xffffff; + colors[1] = 0xffffff; + colors[2] = 0xffffff; + colors[3] = 0xffffff; + colors[4] = 0xffffff; + colors[5] = 0xffffff; + + return this; + }, + + /** + * Resets the position, alpha and color values used by this Quad. + * + * @method Phaser.GameObjects.Quad#reset + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + reset: function () + { + this.resetPosition(); + + this.resetAlpha(); + + return this.resetColors(); + } + +}); + +module.exports = Quad; + + +/***/ }), +/* 166 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Checks whether the x and y coordinates are contained within this polygon. +// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva + +/** + * Checks if a point is within the bounds of a Polygon. + * + * @function Phaser.Geom.Polygon.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to check against. + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is within the bounds of the Polygon, otherwise `false`. + */ +var Contains = function (polygon, x, y) +{ + var inside = false; + + for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) + { + var ix = polygon.points[i].x; + var iy = polygon.points[i].y; + + var jx = polygon.points[j].x; + var jy = polygon.points[j].y; + + if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) + { + inside = !inside; + } + } + + return inside; +}; + +module.exports = Contains; + + +/***/ }), +/* 167 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(166); +var GetPoints = __webpack_require__(312); + +/** + * @classdesc + * [description] + * + * @class Polygon + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Geom.Point[]} [points] - [description] + */ +var Polygon = new Class({ + + initialize: + + function Polygon (points) + { + /** + * The area of this Polygon. + * + * @name Phaser.Geom.Polygon#area + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.area = 0; + + /** + * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] + * + * @name Phaser.Geom.Polygon#points + * @type {Phaser.Geom.Point[]} + * @since 3.0.0 + */ + this.points = []; + + if (points) + { + this.setTo(points); + } + }, + + /** + * Check to see if the Polygon contains the given x / y coordinates. + * + * @method Phaser.Geom.Polygon#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the polygon. + * @param {number} y - The y coordinate to check within the polygon. + * + * @return {boolean} `true` if the coordinates are within the polygon, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * `setTo` may also be called without any arguments to remove all points. + * + * @method Phaser.Geom.Polygon#setTo + * @since 3.0.0 + * + * @param {array} points - [description] + * + * @return {Phaser.Geom.Polygon} This Polygon object. + */ + setTo: function (points) + { + this.area = 0; + this.points = []; + + if (typeof points === 'string') + { + points = points.split(' '); + } + + if (!Array.isArray(points)) + { + return this; + } + + var p; + var y0 = Number.MAX_VALUE; + + // The points argument is an array, so iterate through it + for (var i = 0; i < points.length; i++) + { + p = { x: 0, y: 0 }; + + if (typeof points[i] === 'number' || typeof points[i] === 'string') + { + p.x = parseFloat(points[i]); + p.y = parseFloat(points[i + 1]); + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + + // Lowest boundary + if (p.y < y0) + { + y0 = p.y; + } + } + + this.calculateArea(y0); + + return this; + }, + + /** + * Calculates the area of the Polygon. This is available in the property Polygon.area + * + * @method Phaser.Geom.Polygon#calculateArea + * @since 3.0.0 + * + * @return {number} The area of the polygon. + */ + calculateArea: function () + { + if (this.points.length < 3) + { + this.area = 0; + + return this.area; + } + + var sum = 0; + var p1; + var p2; + + for (var i = 0; i < this.points.length - 1; i++) + { + p1 = this.points[i]; + p2 = this.points[i + 1]; + + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + + p1 = this.points[0]; + p2 = this.points[this.points.length - 1]; + + sum += (p1.x - p2.x) * (p2.y + p1.y); + + this.area = -sum * 0.5; + + return this.area; + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Polygon#getPoints + * @since 3.12.0 + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the perimeter of the Polygon. + */ + getPoints: function (quantity, step, output) + { + return GetPoints(this, quantity, step, output); + } + +}); + +module.exports = Polygon; + + +/***/ }), +/* 168 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(26); +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var CONST = __webpack_require__(28); +var GameObject = __webpack_require__(17); +var GetPowerOfTwo = __webpack_require__(322); +var Smoothing = __webpack_require__(130); +var TileSpriteRender = __webpack_require__(872); +var Vector2 = __webpack_require__(3); + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * @classdesc + * A TileSprite is a Sprite that has a repeating texture. + * + * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and + * are designed so that you can create game backdrops using seamless textures as a source. + * + * You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide + * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means + * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a + * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then + * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use + * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, + * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in + * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you + * provide POT textures for Tile Sprites. + * + * @class TileSprite + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Crop + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {integer} height - The height of the Game Object. If zero it will use the size of the texture frame. + * @param {string} textureKey - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frameKey] - An optional frame from the Texture this Game Object is rendering with. + */ +var TileSprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + TileSpriteRender + ], + + initialize: + + function TileSprite (scene, x, y, width, height, textureKey, frameKey) + { + var renderer = scene.sys.game.renderer; + + GameObject.call(this, scene, 'TileSprite'); + + var displayTexture = scene.sys.textures.get(textureKey); + var displayFrame = displayTexture.get(frameKey); + + if (!width || !height) + { + width = displayFrame.width; + height = displayFrame.height; + } + else + { + width = Math.floor(width); + height = Math.floor(height); + } + + /** + * Internal tile position vector. + * + * @name Phaser.GameObjects.TileSprite#_tilePosition + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 + */ + this._tilePosition = new Vector2(); + + /** + * Internal tile scale vector. + * + * @name Phaser.GameObjects.TileSprite#_tileScale + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 + */ + this._tileScale = new Vector2(1, 1); + + /** + * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. + * + * Such changes include the texture frame and scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + /** + * The renderer in use by this Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = renderer; + + /** + * The Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#canvas + * @type {?HTMLCanvasElement} + * @since 3.12.0 + */ + this.canvas = CanvasPool.create(this, width, height); + + /** + * The Context of the Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#context + * @type {CanvasRenderingContext2D} + * @since 3.12.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * The Texture the TileSprite is using as its fill pattern. + * + * @name Phaser.GameObjects.TileSprite#displayTexture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @private + * @since 3.12.0 + */ + this.displayTexture = displayTexture; + + /** + * The Frame the TileSprite is using as its fill pattern. + * + * @name Phaser.GameObjects.TileSprite#displayFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.12.0 + */ + this.displayFrame = displayFrame; + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.TileSprite#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.TileSprite#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.TileSprite#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.frame = this.texture.get(); + + /** + * The next power of two value from the width of the Fill Pattern frame. + * + * @name Phaser.GameObjects.TileSprite#potWidth + * @type {integer} + * @since 3.0.0 + */ + this.potWidth = GetPowerOfTwo(displayFrame.width); + + /** + * The next power of two value from the height of the Fill Pattern frame. + * + * @name Phaser.GameObjects.TileSprite#potHeight + * @type {integer} + * @since 3.0.0 + */ + this.potHeight = GetPowerOfTwo(displayFrame.height); + + /** + * The Canvas that the TileSprites texture is rendered to. + * This is used to create a WebGL texture from. + * + * @name Phaser.GameObjects.TileSprite#fillCanvas + * @type {HTMLCanvasElement} + * @since 3.12.0 + */ + this.fillCanvas = CanvasPool.create2D(this, this.potWidth, this.potHeight); + + /** + * The Canvas Context used to render the TileSprites texture. + * + * @name Phaser.GameObjects.TileSprite#fillContext + * @type {CanvasRenderingContext2D} + * @since 3.12.0 + */ + this.fillContext = this.fillCanvas.getContext('2d'); + + /** + * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. + * + * @name Phaser.GameObjects.TileSprite#fillPattern + * @type {?(WebGLTexture|CanvasPattern)} + * @since 3.12.0 + */ + this.fillPattern = null; + + this.setPosition(x, y); + this.setSize(width, height); + this.setFrame(frameKey); + this.setOriginFromFrame(); + this.initPipeline(); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function (renderer) + { + var gl = renderer.gl; + + this.dirty = true; + this.fillPattern = null; + this.fillPattern = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.fillCanvas, this.potWidth, this.potHeight); + }, this); + } + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.TileSprite#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.displayTexture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.TileSprite#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame) + { + this.displayFrame = this.displayTexture.get(frame); + + if (!this.displayFrame.cutWidth || !this.displayFrame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + this.dirty = true; + + this.updateTileTexture(); + + return this; + }, + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. + * + * @method Phaser.GameObjects.TileSprite#setTilePosition + * @since 3.3.0 + * + * @param {number} [x] - The x position of this sprite's tiling texture. + * @param {number} [y] - The y position of this sprite's tiling texture. + * + * @return {this} This Tile Sprite instance. + */ + setTilePosition: function (x, y) + { + if (x !== undefined) + { + this.tilePositionX = x; + } + + if (y !== undefined) + { + this.tilePositionY = y; + } + + return this; + }, + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. + * + * @method Phaser.GameObjects.TileSprite#setTileScale + * @since 3.12.0 + * + * @param {number} [x] - The horizontal scale of the tiling texture. + * @param {number} [y] - The vertical scale of the tiling texture. + * + * @return {this} This Tile Sprite instance. + */ + setTileScale: function (x, y) + { + if (x !== undefined) + { + this.tileScaleX = x; + } + + if (y !== undefined) + { + this.tileScaleY = y; + } + + return this; + }, + + /** + * Render the tile texture if it is dirty, or if the frame has changed. + * + * @method Phaser.GameObjects.TileSprite#updateTileTexture + * @private + * @since 3.0.0 + */ + updateTileTexture: function () + { + if (!this.dirty) + { + return; + } + + // Draw the displayTexture to our fillCanvas + + var frame = this.displayFrame; + + var ctx = this.fillContext; + var canvas = this.fillCanvas; + + var fw = this.potWidth; + var fh = this.potHeight; + + if (!this.renderer.gl) + { + fw = frame.cutWidth; + fh = frame.cutHeight; + } + + ctx.clearRect(0, 0, fw, fh); + + canvas.width = fw; + canvas.height = fh; + + ctx.drawImage( + frame.source.image, + frame.cutX, frame.cutY, + frame.cutWidth, frame.cutHeight, + 0, 0, + fw, fh + ); + + if (this.renderer.gl) + { + this.fillPattern = this.renderer.canvasToTexture(canvas, this.fillPattern); + } + else + { + this.fillPattern = ctx.createPattern(canvas, 'repeat'); + } + + this.updateCanvas(); + + this.dirty = false; + }, + + /** + * Draw the fill pattern to the internal canvas. + * + * @method Phaser.GameObjects.TileSprite#updateCanvas + * @private + * @since 3.12.0 + */ + updateCanvas: function () + { + var canvas = this.canvas; + + if (canvas.width !== this.width || canvas.height !== this.height) + { + canvas.width = this.width; + canvas.height = this.height; + + this.frame.setSize(this.width, this.height); + } + + if (!this.dirty || this.renderer && this.renderer.gl) + { + this.dirty = false; + return; + } + + var ctx = this.context; + + if (!this.scene.sys.game.config.antialias) + { + Smoothing.disable(ctx); + } + + var scaleX = this._tileScale.x; + var scaleY = this._tileScale.y; + + var positionX = this._tilePosition.x; + var positionY = this._tilePosition.y; + + ctx.clearRect(0, 0, this.width, this.height); + + ctx.save(); + + ctx.scale(scaleX, scaleY); + + ctx.translate(-positionX, -positionY); + + ctx.fillStyle = this.fillPattern; + + ctx.fillRect(positionX, positionY, this.width / scaleX, this.height / scaleY); + + ctx.restore(); + + this.dirty = false; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.TileSprite#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + if (this.renderer && this.renderer.gl) + { + this.renderer.deleteTexture(this.fillPattern); + } + + CanvasPool.remove(this.canvas); + CanvasPool.remove(this.fillCanvas); + + this.fillPattern = null; + this.fillContext = null; + this.fillCanvas = null; + + this.displayTexture = null; + this.displayFrame = null; + + this.texture.destroy(); + + this.renderer = null; + }, + + /** + * The horizontal scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionX: { + + get: function () + { + return this._tilePosition.x; + }, + + set: function (value) + { + this._tilePosition.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionY: { + + get: function () + { + return this._tilePosition.y; + }, + + set: function (value) + { + this._tilePosition.y = value; + this.dirty = true; + } + + }, + + /** + * The horizontal scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleX + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleX: { + + get: function () + { + return this._tileScale.x; + }, + + set: function (value) + { + this._tileScale.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleY + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleY: { + + get: function () + { + return this._tileScale.y; + }, + + set: function (value) + { + this._tileScale.y = value; + this.dirty = true; + } + + } + +}); + +module.exports = TileSprite; + + +/***/ }), +/* 169 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AddToDOM = __webpack_require__(187); +var CanvasPool = __webpack_require__(26); +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var CONST = __webpack_require__(28); +var GameObject = __webpack_require__(17); +var GetTextSize = __webpack_require__(878); +var GetValue = __webpack_require__(4); +var RemoveFromDOM = __webpack_require__(378); +var TextRender = __webpack_require__(877); +var TextStyle = __webpack_require__(874); + +/** + * @classdesc + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + * + * @class Text + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Crop + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {object} style - The text style configuration object. + */ +var Text = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + TextRender + ], + + initialize: + + function Text (scene, x, y, text, style) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + GameObject.call(this, scene, 'Text'); + + /** + * The renderer in use by this Text object. + * + * @name Phaser.GameObjects.Text#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.12.0 + */ + this.renderer = scene.sys.game.renderer; + + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline(); + + /** + * The canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = CanvasPool.create(this); + + /** + * The context of the canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * The Text Style object. + * + * Manages the style of this Text object. + * + * @name Phaser.GameObjects.Text#style + * @type {Phaser.GameObjects.Text.TextStyle} + * @since 3.0.0 + */ + this.style = new TextStyle(this, style); + + /** + * Whether to automatically round line positions. + * + * @name Phaser.GameObjects.Text#autoRound + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.autoRound = true; + + /** + * The Regular Expression that is used to split the text up into lines, in + * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. + * You can change this RegExp to be anything else that you may need. + * + * @name Phaser.GameObjects.Text#splitRegExp + * @type {object} + * @since 3.0.0 + */ + this.splitRegExp = /(?:\r\n|\r|\n)/; + + /** + * The text to display. + * + * @name Phaser.GameObjects.Text#_text + * @type {string} + * @private + * @since 3.12.0 + */ + this._text = ''; + + /** + * Specify a padding value which is added to the line width and height when calculating the Text size. + * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. + * + * @name Phaser.GameObjects.Text#padding + * @type {{left:number,right:number,top:number,bottom:number}} + * @since 3.0.0 + */ + this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; + + /** + * The width of this Text object. + * + * @name Phaser.GameObjects.Text#width + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.width = 1; + + /** + * The height of this Text object. + * + * @name Phaser.GameObjects.Text#height + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.height = 1; + + /** + * The line spacing value. + * This value is added to the font height to calculate the overall line height. + * Only has an effect if this Text object contains multiple lines of text. + * + * If you update this property directly, instead of using the `setLineSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. + * + * @name Phaser.GameObjects.Text#lineSpacing + * @type {number} + * @since 3.13.0 + */ + this.lineSpacing = 0; + + /** + * Whether the text or its settings have changed and need updating. + * + * @name Phaser.GameObjects.Text#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + // If resolution wasn't set, then we get it from the game config + if (this.style.resolution === 0) + { + this.style.resolution = scene.sys.game.config.resolution; + } + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Text#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + // Create a Texture for this Text object + this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + + // Get the frame + this.frame = this.texture.get(); + + // Set the resolution + this.frame.source.resolution = this.style.resolution; + + if (this.renderer && this.renderer.gl) + { + // Clear the default 1x1 glTexture, as we override it later + this.renderer.deleteTexture(this.frame.source.glTexture); + + this.frame.source.glTexture = null; + } + + this.initRTL(); + + if (style && style.padding) + { + this.setPadding(style.padding); + } + + if (style && style.lineSpacing) + { + this.lineSpacing = style.lineSpacing; + } + + this.setText(text); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.dirty = true; + }, this); + } + }, + + /** + * Initialize right to left text. + * + * @method Phaser.GameObjects.Text#initRTL + * @since 3.0.0 + */ + initRTL: function () + { + if (!this.style.rtl) + { + return; + } + + // Here is where the crazy starts. + // + // Due to browser implementation issues, you cannot fillText BiDi text to a canvas + // that is not part of the DOM. It just completely ignores the direction property. + + this.canvas.dir = 'rtl'; + + // Experimental atm, but one day ... + this.context.direction = 'rtl'; + + // Add it to the DOM, but hidden within the parent canvas. + this.canvas.style.display = 'none'; + + AddToDOM(this.canvas, this.scene.sys.canvas); + + // And finally we set the x origin + this.originX = 1; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. + * + * @method Phaser.GameObjects.Text#runWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * + * @return {string} The text after wrapping has been applied. + */ + runWordWrap: function (text) + { + var style = this.style; + + if (style.wordWrapCallback) + { + var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); + + if (Array.isArray(wrappedLines)) + { + wrappedLines = wrappedLines.join('\n'); + } + + return wrappedLines; + } + else if (style.wordWrapWidth) + { + if (style.wordWrapUseAdvanced) + { + return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); + } + else + { + return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); + } + } + else + { + return text; + } + }, + + /** + * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be + * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a + * single character. + * + * @method Phaser.GameObjects.Text#advancedWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {number} wordWrapWidth - The word wrap width. + * + * @return {string} The wrapped text. + */ + advancedWordWrap: function (text, context, wordWrapWidth) + { + var output = ''; + + // Condense consecutive spaces and split into lines + var lines = text + .replace(/ +/gi, ' ') + .split(this.splitRegExp); + + var linesCount = lines.length; + + for (var i = 0; i < linesCount; i++) + { + var line = lines[i]; + var out = ''; + + // Trim whitespace + line = line.replace(/^ *|\s*$/gi, ''); + + // If entire line is less than wordWrapWidth append the entire line and exit early + var lineWidth = context.measureText(line).width; + + if (lineWidth < wordWrapWidth) + { + output += line + '\n'; + continue; + } + + // Otherwise, calculate new lines + var currentLineWidth = wordWrapWidth; + + // Split into words + var words = line.split(' '); + + for (var j = 0; j < words.length; j++) + { + var word = words[j]; + var wordWithSpace = word + ' '; + var wordWidth = context.measureText(wordWithSpace).width; + + if (wordWidth > currentLineWidth) + { + // Break word + if (j === 0) + { + // Shave off letters from word until it's small enough + var newWord = wordWithSpace; + + while (newWord.length) + { + newWord = newWord.slice(0, -1); + wordWidth = context.measureText(newWord).width; + + if (wordWidth <= currentLineWidth) + { + break; + } + } + + // If wordWrapWidth is too small for even a single letter, shame user + // failure with a fatal error + if (!newWord.length) + { + throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); + } + + // Replace current word in array with remainder + var secondPart = word.substr(newWord.length); + + words[j] = secondPart; + + // Append first piece to output + out += newWord; + } + + // If existing word length is 0, don't include it + var offset = (words[j].length) ? j : j + 1; + + // Collapse rest of sentence and remove any trailing white space + var remainder = words.slice(offset).join(' ') + .replace(/[ \n]*$/gi, ''); + + // Prepend remainder to next line + lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); + linesCount = lines.length; + + break; // Processing on this line + + // Append word with space to output + } + else + { + out += wordWithSpace; + currentLineWidth -= wordWidth; + } + } + + // Append processed line to output + output += out.replace(/[ \n]*$/gi, '') + '\n'; + } + + // Trim the end of the string + output = output.replace(/[\s|\n]*$/gi, ''); + + return output; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Spaces are not collapsed and whitespace is not trimmed. + * + * @method Phaser.GameObjects.Text#basicWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {number} wordWrapWidth - The word wrap width. + * + * @return {string} The wrapped text. + */ + basicWordWrap: function (text, context, wordWrapWidth) + { + var result = ''; + var lines = text.split(this.splitRegExp); + + for (var i = 0; i < lines.length; i++) + { + var spaceLeft = wordWrapWidth; + var words = lines[i].split(' '); + + for (var j = 0; j < words.length; j++) + { + var wordWidth = context.measureText(words[j]).width; + var wordWidthWithSpace = wordWidth + context.measureText(' ').width; + + if (wordWidthWithSpace > spaceLeft) + { + // Skip printing the newline if it's the first word of the line that is greater + // than the word wrap width. + if (j > 0) + { + result += '\n'; + } + + result += words[j] + ' '; + spaceLeft = wordWrapWidth - wordWidth; + } + else + { + spaceLeft -= wordWidthWithSpace; + result += words[j]; + + if (j < (words.length - 1)) + { + result += ' '; + } + } + } + + if (i < lines.length - 1) + { + result += '\n'; + } + } + + return result; + }, + + /** + * Runs the given text through this Text objects word wrapping and returns the results as an + * array, where each element of the array corresponds to a wrapped line of text. + * + * @method Phaser.GameObjects.Text#getWrappedText + * @since 3.0.0 + * + * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. + * + * @return {string[]} An array of strings with the pieces of wrapped text. + */ + getWrappedText: function (text) + { + if (text === undefined) { text = this._text; } + + this.style.syncFont(this.canvas, this.context); + + var wrappedLines = this.runWordWrap(text); + + return wrappedLines.split(this.splitRegExp); + }, + + /** + * Set the text to display. + * + * An array of strings will be joined with `\n` line breaks. + * + * @method Phaser.GameObjects.Text#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this Text object. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this._text) + { + this._text = value.toString(); + + this.updateText(); + } + + return this; + }, + + /** + * Set the text style. + * + * @example + * text.setStyle({ + * fontSize: '64px', + * fontFamily: 'Arial', + * color: '#ffffff', + * align: 'center', + * backgroundColor: '#ff00ff' + * }); + * + * @method Phaser.GameObjects.Text#setStyle + * @since 3.0.0 + * + * @param {object} style - The style settings to set. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStyle: function (style) + { + return this.style.setStyle(style); + }, + + /** + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * + * @method Phaser.GameObjects.Text#setFont + * @since 3.0.0 + * + * @param {string} font - The font family or font settings to set. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFont: function (font) + { + return this.style.setFont(font); + }, + + /** + * Set the font family. + * + * @method Phaser.GameObjects.Text#setFontFamily + * @since 3.0.0 + * + * @param {string} family - The font family. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontFamily: function (family) + { + return this.style.setFontFamily(family); + }, + + /** + * Set the font size. + * + * @method Phaser.GameObjects.Text#setFontSize + * @since 3.0.0 + * + * @param {number} size - The font size. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontSize: function (size) + { + return this.style.setFontSize(size); + }, + + /** + * Set the font style. + * + * @method Phaser.GameObjects.Text#setFontStyle + * @since 3.0.0 + * + * @param {string} style - The font style. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontStyle: function (style) + { + return this.style.setFontStyle(style); + }, + + /** + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * + * @method Phaser.GameObjects.Text#setFixedSize + * @since 3.0.0 + * + * @param {number} width - The fixed width to set. `0` disables fixed width. + * @param {number} height - The fixed height to set. `0` disables fixed height. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFixedSize: function (width, height) + { + return this.style.setFixedSize(width, height); + }, + + /** + * Set the background color. + * + * @method Phaser.GameObjects.Text#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - The background color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setBackgroundColor: function (color) + { + return this.style.setBackgroundColor(color); + }, + + /** + * Set the text fill color. + * + * @method Phaser.GameObjects.Text#setFill + * @since 3.0.0 + * + * @param {string} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFill: function (color) + { + return this.style.setFill(color); + }, + + /** + * Set the text fill color. + * + * @method Phaser.GameObjects.Text#setColor + * @since 3.0.0 + * + * @param {string} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setColor: function (color) + { + return this.style.setColor(color); + }, + + /** + * Set the stroke settings. + * + * @method Phaser.GameObjects.Text#setStroke + * @since 3.0.0 + * + * @param {string} color - The stroke color. + * @param {number} thickness - The stroke thickness. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStroke: function (color, thickness) + { + return this.style.setStroke(color, thickness); + }, + + /** + * Set the shadow settings. + * + * @method Phaser.GameObjects.Text#setShadow + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * @param {string} [color='#000'] - The shadow color. + * @param {number} [blur=0] - The shadow blur radius. + * @param {boolean} [shadowStroke=false] - Whether to stroke the shadow. + * @param {boolean} [shadowFill=true] - Whether to fill the shadow. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); + }, + + /** + * Set the shadow offset. + * + * @method Phaser.GameObjects.Text#setShadowOffset + * @since 3.0.0 + * + * @param {number} x - The horizontal shadow offset. + * @param {number} y - The vertical shadow offset. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowOffset: function (x, y) + { + return this.style.setShadowOffset(x, y); + }, + + /** + * Set the shadow color. + * + * @method Phaser.GameObjects.Text#setShadowColor + * @since 3.0.0 + * + * @param {string} color - The shadow color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowColor: function (color) + { + return this.style.setShadowColor(color); + }, + + /** + * Set the shadow blur radius. + * + * @method Phaser.GameObjects.Text#setShadowBlur + * @since 3.0.0 + * + * @param {number} blur - The shadow blur radius. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowBlur: function (blur) + { + return this.style.setShadowBlur(blur); + }, + + /** + * Enable or disable shadow stroke. + * + * @method Phaser.GameObjects.Text#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow stroke is enabled or not. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowStroke: function (enabled) + { + return this.style.setShadowStroke(enabled); + }, + + /** + * Enable or disable shadow fill. + * + * @method Phaser.GameObjects.Text#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow fill is enabled or not. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowFill: function (enabled) + { + return this.style.setShadowFill(enabled); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.Text#setWordWrapWidth + * @since 3.0.0 + * + * @param {?number} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + return this.style.setWordWrapWidth(width, useAdvancedWrap); + }, + + /** + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.Text#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapCallback: function (callback, scope) + { + return this.style.setWordWrapCallback(callback, scope); + }, + + /** + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. + * + * @method Phaser.GameObjects.Text#setAlign + * @since 3.0.0 + * + * @param {string} align - The text alignment. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setAlign: function (align) + { + return this.style.setAlign(align); + }, + + /** + * Set the resolution used by this Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method, or by specifying it in the Text style configuration object. + * + * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger + * internal Canvas textures for the Text. + * + * Therefore, please use with caution, as the more high res Text you have, the more memory it uses. + * + * @method Phaser.GameObjects.Text#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setResolution: function (value) + { + return this.style.setResolution(value); + }, + + /** + * Sets the line spacing value. + * + * This value is _added_ to the height of the font when calculating the overall line height. + * This only has an effect if this Text object consists of multiple lines of text. + * + * @method Phaser.GameObjects.Text#setLineSpacing + * @since 3.13.0 + * + * @param {number} value - The amount to add to the font height to achieve the overall line height. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setLineSpacing: function (value) + { + this.lineSpacing = value; + + return this.updateText(); + }, + + /** + * Set the text padding. + * + * 'left' can be an object. + * + * If only 'left' and 'top' are given they are treated as 'x' and 'y'. + * + * @method Phaser.GameObjects.Text#setPadding + * @since 3.0.0 + * + * @param {(number|object)} left - The left padding value, or a padding config object. + * @param {number} top - The top padding value. + * @param {number} right - The right padding value. + * @param {number} bottom - The bottom padding value. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setPadding: function (left, top, right, bottom) + { + if (typeof left === 'object') + { + var config = left; + + // If they specify x and/or y this applies to all + var x = GetValue(config, 'x', null); + + if (x !== null) + { + left = x; + right = x; + } + else + { + left = GetValue(config, 'left', 0); + right = GetValue(config, 'right', left); + } + + var y = GetValue(config, 'y', null); + + if (y !== null) + { + top = y; + bottom = y; + } + else + { + top = GetValue(config, 'top', 0); + bottom = GetValue(config, 'bottom', top); + } + } + else + { + if (left === undefined) { left = 0; } + if (top === undefined) { top = left; } + if (right === undefined) { right = left; } + if (bottom === undefined) { bottom = top; } + } + + this.padding.left = left; + this.padding.top = top; + this.padding.right = right; + this.padding.bottom = bottom; + + return this.updateText(); + }, + + /** + * Set the maximum number of lines to draw. + * + * @method Phaser.GameObjects.Text#setMaxLines + * @since 3.0.0 + * + * @param {integer} [max=0] - The maximum number of lines to draw. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setMaxLines: function (max) + { + return this.style.setMaxLines(max); + }, + + /** + * Update the displayed text. + * + * @method Phaser.GameObjects.Text#updateText + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + updateText: function () + { + var canvas = this.canvas; + var context = this.context; + var style = this.style; + var resolution = style.resolution; + var size = style.metrics; + + style.syncFont(canvas, context); + + var outputText = this._text; + + if (style.wordWrapWidth || style.wordWrapCallback) + { + outputText = this.runWordWrap(this._text); + } + + // Split text into lines + var lines = outputText.split(this.splitRegExp); + + var textSize = GetTextSize(this, size, lines); + + var padding = this.padding; + + var w = textSize.width + padding.left + padding.right; + var h = textSize.height + padding.top + padding.bottom; + + if (style.fixedWidth === 0) + { + this.width = w; + } + + if (style.fixedHeight === 0) + { + this.height = h; + } + + this.updateDisplayOrigin(); + + w *= resolution; + h *= resolution; + + w = Math.max(w, 1); + h = Math.max(h, 1); + + if (canvas.width !== w || canvas.height !== h) + { + canvas.width = w; + canvas.height = h; + + this.frame.setSize(w, h); + + style.syncFont(canvas, context); // Resizing resets the context + } + else + { + context.clearRect(0, 0, w, h); + } + + context.save(); + + context.scale(resolution, resolution); + + if (style.backgroundColor) + { + context.fillStyle = style.backgroundColor; + context.fillRect(0, 0, w, h); + } + + style.syncStyle(canvas, context); + + context.textBaseline = 'alphabetic'; + + // Apply padding + context.translate(padding.left, padding.top); + + var linePositionX; + var linePositionY; + + // Draw text line by line + for (var i = 0; i < textSize.lines; i++) + { + linePositionX = style.strokeThickness / 2; + linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; + + if (i > 0) + { + linePositionY += (textSize.lineSpacing * i); + } + + if (style.rtl) + { + linePositionX = w - linePositionX; + } + else if (style.align === 'right') + { + linePositionX += textSize.width - textSize.lineWidths[i]; + } + else if (style.align === 'center') + { + linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; + } + + if (this.autoRound) + { + linePositionX = Math.round(linePositionX); + linePositionY = Math.round(linePositionY); + } + + if (style.strokeThickness) + { + this.style.syncShadow(context, style.shadowStroke); + + context.strokeText(lines[i], linePositionX, linePositionY); + } + + if (style.color) + { + this.style.syncShadow(context, style.shadowFill); + + context.fillText(lines[i], linePositionX, linePositionY); + } + } + + context.restore(); + + if (this.renderer.gl) + { + this.frame.source.glTexture = this.renderer.canvasToTexture(canvas, this.frame.source.glTexture, true); + + this.frame.glTexture = this.frame.source.glTexture; + } + + this.dirty = true; + + return this; + }, + + /** + * Get the current text metrics. + * + * @method Phaser.GameObjects.Text#getTextMetrics + * @since 3.0.0 + * + * @return {object} The text metrics. + */ + getTextMetrics: function () + { + return this.style.getTextMetrics(); + }, + + /** + * The text string being rendered by this Text Game Object. + * + * @name Phaser.GameObjects.Text#text + * @type {string} + * @since 3.0.0 + */ + text: { + + get: function () + { + return this._text; + }, + + set: function (value) + { + this.setText(value); + } + + }, + + /** + * Build a JSON representation of the Text object. + * + * @method Phaser.GameObjects.Text#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Text object. + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra Text data is added here + + var data = { + autoRound: this.autoRound, + text: this._text, + style: this.style.toJSON(), + padding: { + left: this.padding.left, + right: this.padding.right, + top: this.padding.top, + bottom: this.padding.bottom + } + }; + + out.data = data; + + return out; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Text#preDestroy + * @protected + * @since 3.0.0 + */ + preDestroy: function () + { + if (this.style.rtl) + { + RemoveFromDOM(this.canvas); + } + + CanvasPool.remove(this.canvas); + + this.texture.destroy(); + } + +}); + +module.exports = Text; + + +/***/ }), +/* 170 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(131); +var CanvasPool = __webpack_require__(26); +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var CONST = __webpack_require__(28); +var Frame = __webpack_require__(123); +var GameObject = __webpack_require__(17); +var Render = __webpack_require__(884); +var UUID = __webpack_require__(323); + +/** + * @classdesc + * A Render Texture. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. + * + * @class RenderTexture + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.2.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + */ +var RenderTexture = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function RenderTexture (scene, x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 32; } + if (height === undefined) { height = 32; } + + GameObject.call(this, scene, 'RenderTexture'); + + /** + * A reference to either the Canvas or WebGL Renderer that the Game instance is using. + * + * @name Phaser.GameObjects.RenderTexture#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.2.0 + */ + this.renderer = scene.sys.game.renderer; + + /** + * A reference to the Texture Manager. + * + * @name Phaser.GameObjects.RenderTexture#textureManager + * @type {Phaser.Textures.TextureManager} + * @since 3.12.0 + */ + this.textureManager = scene.sys.textures; + + /** + * The tint of the Render Texture when rendered. + * + * @name Phaser.GameObjects.RenderTexture#globalTint + * @type {number} + * @default 0xffffff + * @since 3.2.0 + */ + this.globalTint = 0xffffff; + + /** + * The alpha of the Render Texture when rendered. + * + * @name Phaser.GameObjects.RenderTexture#globalAlpha + * @type {number} + * @default 1 + * @since 3.2.0 + */ + this.globalAlpha = 1; + + /** + * The HTML Canvas Element that the Render Texture is drawing to. + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.GameObjects.RenderTexture#canvas + * @type {HTMLCanvasElement} + * @since 3.2.0 + */ + this.canvas = CanvasPool.create2D(this, width, height); + + /** + * A reference to the Rendering Context belonging to the Canvas Element this Render Texture is drawing to. + * + * @name Phaser.GameObjects.RenderTexture#context + * @type {CanvasRenderingContext2D} + * @since 3.2.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * A reference to the GL Frame Buffer this Render Texture is drawing to. + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.GameObjects.RenderTexture#framebuffer + * @type {?WebGLFramebuffer} + * @since 3.2.0 + */ + this.framebuffer = null; + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.RenderTexture#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Texture corresponding to this Render Texture. + * + * @name Phaser.GameObjects.RenderTexture#texture + * @type {Phaser.Textures.Texture} + * @since 3.12.0 + */ + this.texture = scene.sys.textures.addCanvas(UUID(), this.canvas); + + /** + * The Frame corresponding to this Render Texture. + * + * @name Phaser.GameObjects.RenderTexture#frame + * @type {Phaser.Textures.Frame} + * @since 3.12.0 + */ + this.frame = this.texture.get(); + + /** + * Internal saved texture flag. + * + * @name Phaser.GameObjects.RenderTexture#_saved + * @type {boolean} + * @private + * @since 3.12.0 + */ + this._saved = false; + + /** + * An internal Camera that can be used to move around the Render Texture. + * Control it just like you would any Scene Camera. The difference is that it only impacts the placement of what + * is drawn to the Render Texture. You can scroll, zoom and rotate this Camera. + * + * @name Phaser.GameObjects.RenderTexture#camera + * @type {Phaser.Cameras.Scene2D.BaseCamera} + * @since 3.12.0 + */ + this.camera = new Camera(0, 0, width, height); + + /** + * Is this Render Texture dirty or not? If not it won't spend time clearing or filling itself. + * + * @name Phaser.GameObjects.RenderTexture#dirty + * @type {boolean} + * @since 3.12.0 + */ + this.dirty = false; + + /** + * A reference to the WebGL Rendering Context. + * + * @name Phaser.GameObjects.RenderTexture#gl + * @type {WebGLRenderingContext} + * @default null + * @since 3.0.0 + */ + this.gl = null; + + var renderer = this.renderer; + + if (renderer.type === CONST.WEBGL) + { + var gl = renderer.gl; + + this.gl = gl; + this.drawGameObject = this.batchGameObjectWebGL; + this.framebuffer = renderer.createFramebuffer(width, height, this.frame.source.glTexture, false); + } + else if (renderer.type === CONST.CANVAS) + { + this.drawGameObject = this.batchGameObjectCanvas; + } + + this.camera.setScene(scene); + + this.setPosition(x, y); + this.setSize(width, height); + this.setOrigin(0, 0); + this.initPipeline(); + }, + + /** + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + return this.resize(width, height); + }, + + /** + * Resizes the Render Texture to the new dimensions given. + * + * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. + * In Canvas it will resize the underlying canvas element. + * Both approaches will erase everything currently drawn to the Render Texture. + * + * If the dimensions given are the same as those already being used, calling this method will do nothing. + * + * @method Phaser.GameObjects.RenderTexture#resize + * @since 3.10.0 + * + * @param {number} width - The new width of the Render Texture. + * @param {number} [height] - The new height of the Render Texture. If not specified, will be set the same as the `width`. + * + * @return {this} This Render Texture. + */ + resize: function (width, height) + { + if (height === undefined) { height = width; } + + if (width !== this.width || height !== this.height) + { + this.canvas.width = width; + this.canvas.height = height; + + if (this.gl) + { + var gl = this.gl; + + this.renderer.deleteTexture(this.frame.source.glTexture); + this.renderer.deleteFramebuffer(this.framebuffer); + + this.frame.source.glTexture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); + this.framebuffer = this.renderer.createFramebuffer(width, height, this.frame.source.glTexture, false); + + this.frame.glTexture = this.frame.source.glTexture; + } + + this.frame.source.width = width; + this.frame.source.height = height; + + this.camera.setSize(width, height); + + this.frame.setSize(width, height); + + this.width = width; + this.height = height; + } + + return this; + }, + + /** + * Set the tint to use when rendering this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#setGlobalTint + * @since 3.2.0 + * + * @param {integer} tint - The tint value. + * + * @return {this} This Render Texture. + */ + setGlobalTint: function (tint) + { + this.globalTint = tint; + + return this; + }, + + /** + * Set the alpha to use when rendering this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#setGlobalAlpha + * @since 3.2.0 + * + * @param {number} alpha - The alpha value. + * + * @return {this} This Render Texture. + */ + setGlobalAlpha: function (alpha) + { + this.globalAlpha = alpha; + + return this; + }, + + /** + * Stores a copy of this Render Texture in the Texture Manager using the given key. + * + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this + * Render Texture by using the texture key: + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 128, 128); + * + * // Draw something to the Render Texture + * + * rt.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Updating the contents of this Render Texture will automatically update _any_ Game Object + * that is using it as a texture. Calling `saveTexture` again will not save another copy + * of the same texture, it will just rename the key of the existing copy. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#saveTexture + * @since 3.12.0 + * + * @param {string} key - The unique key to store the texture as within the global Texture Manager. + * + * @return {Phaser.Textures.Texture} The Texture that was saved. + */ + saveTexture: function (key) + { + this.textureManager.renameTexture(this.texture.key, key); + + this._saved = true; + + return this.texture; + }, + + /** + * Fills the Render Texture with the given color. + * + * @method Phaser.GameObjects.RenderTexture#fill + * @since 3.2.0 + * + * @param {number} rgb - The color to fill the Render Texture with. + * @param {number} [alpha=1] - The alpha value used by the fill. + * + * @return {this} This Render Texture instance. + */ + fill: function (rgb, alpha) + { + if (alpha === undefined) { alpha = 1; } + + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + if (this.gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var gl = this.gl; + + gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, alpha); + + gl.clear(gl.COLOR_BUFFER_BIT); + + this.renderer.setFramebuffer(null); + } + else + { + this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; + this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); + } + + return this; + }, + + /** + * Clears the Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#clear + * @since 3.2.0 + * + * @return {this} This Render Texture instance. + */ + clear: function () + { + if (this.dirty) + { + if (this.gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var gl = this.gl; + + gl.clearColor(0, 0, 0, 0); + + gl.clear(gl.COLOR_BUFFER_BIT); + + this.renderer.setFramebuffer(null); + } + else + { + var ctx = this.context; + + ctx.save(); + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + ctx.restore(); + } + + this.dirty = false; + } + + return this; + }, + + /** + * Draws the given object, or an array of objects, to this Render Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Dynamic and Static Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. + * * Another Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot draw a Render Texture to itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * + * @method Phaser.GameObjects.RenderTexture#draw + * @since 3.2.0 + * + * @param {any} entries - Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param {number} [x] - The x position to draw the Frame at, or the offset applied to the object. + * @param {number} [y] - The y position to draw the Frame at, or the offset applied to the object. + * @param {number} [alpha] - The alpha value. Only used for Texture Frames and if not specified defaults to the `globalAlpha` property. Game Objects use their own current alpha value. + * @param {number} [tint] - WebGL only. The tint color value. Only used for Texture Frames and if not specified defaults to the `globalTint` property. Game Objects use their own current tint value. + * + * @return {this} This Render Texture instance. + */ + draw: function (entries, x, y, alpha, tint) + { + if (alpha === undefined) { alpha = this.globalAlpha; } + + if (tint === undefined) + { + tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + } + else + { + tint = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16); + } + + if (!Array.isArray(entries)) + { + entries = [ entries ]; + } + + var gl = this.gl; + + this.camera.preRender(1, 1, 1); + + if (gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var pipeline = this.pipeline; + + pipeline.projOrtho(0, this.width, 0, this.height, -1000.0, 1000.0); + + this.batchList(entries, x, y, alpha, tint); + + pipeline.flush(); + + this.renderer.setFramebuffer(null); + + pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000.0, 1000.0); + } + else + { + this.renderer.setContext(this.context); + + this.batchList(entries, x, y, alpha, tint); + + this.renderer.setContext(); + } + + this.dirty = true; + + return this; + }, + + /** + * Draws the Texture Frame to the Render Texture at the given position. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 800, 600); + * rt.drawFrame(key, frame); + * ``` + * + * You can optionally provide a position, alpha and tint value to apply to the frame + * before it is drawn. + * + * Calling this method will cause a batch flush, so if you've got a stack of things to draw + * in a tight loop, try using the `draw` method instead. + * + * If you need to draw a Sprite to this Render Texture, use the `draw` method instead. + * + * @method Phaser.GameObjects.RenderTexture#drawFrame + * @since 3.12.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} [x=0] - The x position to draw the frame at. + * @param {number} [y=0] - The y position to draw the frame at. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - WebGL only. The tint color to use. If not specified it uses the `globalTint` property. + * + * @return {this} This Render Texture instance. + */ + drawFrame: function (key, frame, x, y, alpha, tint) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (alpha === undefined) { alpha = this.globalAlpha; } + + if (tint === undefined) + { + tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + } + else + { + tint = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16); + } + + var gl = this.gl; + var textureFrame = this.textureManager.getFrame(key, frame); + + if (textureFrame) + { + this.camera.preRender(1, 1, 1); + + if (gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var pipeline = this.pipeline; + + pipeline.projOrtho(0, this.width, 0, this.height, -1000.0, 1000.0); + + pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null); + + pipeline.flush(); + + this.renderer.setFramebuffer(null); + + pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000.0, 1000.0); + } + else + { + this.batchTextureFrame(textureFrame, x, y, alpha, tint); + } + + this.dirty = true; + } + + return this; + }, + + /** + * Internal method that handles the drawing of an array of children. + * + * @method Phaser.GameObjects.RenderTexture#batchList + * @private + * @since 3.12.0 + * + * @param {array} children - The array of Game Objects to draw. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - The tint color to use. If not specified it uses the `globalTint` property. + */ + batchList: function (children, x, y, alpha, tint) + { + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (!entry || entry === this) + { + continue; + } + + if (entry.renderWebGL || entry.renderCanvas) + { + // Game Objects + this.drawGameObject(entry, x, y); + } + else if (entry.isParent || entry.list) + { + // Groups / Display Lists + this.batchGroup(entry.getChildren(), x, y); + } + else if (typeof entry === 'string') + { + // Texture key + this.batchTextureFrameKey(entry, null, x, y, alpha, tint); + } + else if (entry instanceof Frame) + { + // Texture Frame instance + this.batchTextureFrame(entry, x, y, alpha, tint); + } + else if (Array.isArray(entry)) + { + // Another Array + this.batchList(entry, x, y, alpha, tint); + } + } + }, + + /** + * Internal method that handles the drawing a Phaser Group contents. + * + * @method Phaser.GameObjects.RenderTexture#batchGroup + * @private + * @since 3.12.0 + * + * @param {array} children - The array of Game Objects to draw. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + */ + batchGroup: function (children, x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (entry.willRender()) + { + var tx = entry.x + x; + var ty = entry.y + y; + + this.drawGameObject(entry, tx, ty); + } + } + }, + + /** + * Internal method that handles drawing a single Phaser Game Object to this Render Texture using WebGL. + * + * @method Phaser.GameObjects.RenderTexture#batchGameObjectWebGL + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to draw. + * @param {number} x - The x position to draw the Game Object at. + * @param {number} y - The y position to draw the Game Object at. + */ + batchGameObjectWebGL: function (gameObject, x, y) + { + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + var prevX = gameObject.x; + var prevY = gameObject.y; + + this.renderer.setBlendMode(gameObject.blendMode); + + gameObject.setPosition(x, y); + + gameObject.renderWebGL(this.renderer, gameObject, 0, this.camera, null); + + gameObject.setPosition(prevX, prevY); + }, + + /** + * Internal method that handles drawing a single Phaser Game Object to this Render Texture using Canvas. + * + * @method Phaser.GameObjects.RenderTexture#batchGameObjectCanvas + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to draw. + * @param {number} x - The x position to draw the Game Object at. + * @param {number} y - The y position to draw the Game Object at. + */ + batchGameObjectCanvas: function (gameObject, x, y) + { + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + var prevX = gameObject.x; + var prevY = gameObject.y; + + gameObject.setPosition(x, y); + + gameObject.renderCanvas(this.renderer, gameObject, 0, this.camera, null); + + gameObject.setPosition(prevX, prevY); + }, + + /** + * Internal method that handles the drawing of an array of children. + * + * @method Phaser.GameObjects.RenderTexture#batchTextureFrameKey + * @private + * @since 3.12.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - The tint color to use. If not specified it uses the `globalTint` property. + * + * @return {boolean} `true` if the frame was found and drawn, otherwise `false`. + */ + batchTextureFrameKey: function (key, frame, x, y, alpha, tint) + { + var textureFrame = this.textureManager.getFrame(key, frame); + + if (textureFrame) + { + this.batchTextureFrame(textureFrame, x, y, alpha, tint); + } + }, + + /** + * Internal method that handles the drawing of a Texture Frame to this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#batchTextureFrame + * @private + * @since 3.12.0 + * + * @param {Phaser.Textures.Frame} textureFrame - The Texture Frame to draw. + * @param {number} x - The x position to draw the Frame at. + * @param {number} y - The y position to draw the Frame at. + * @param {number} [tint] - A tint color to be applied to the frame drawn to the Render Texture. + */ + batchTextureFrame: function (textureFrame, x, y, alpha, tint) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + if (this.gl) + { + this.pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null); + } + else + { + var ctx = this.context; + var cd = textureFrame.canvasData; + var source = textureFrame.source.image; + + var matrix = this.camera.matrix; + + ctx.globalAlpha = this.globalAlpha; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + ctx.drawImage(source, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height); + } + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.RenderTexture#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + if (!this._saved) + { + CanvasPool.remove(this.canvas); + + if (this.gl) + { + this.renderer.deleteFramebuffer(this.framebuffer); + } + + this.texture.destroy(); + } + } + +}); + +module.exports = RenderTexture; + + +/***/ }), +/* 171 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var GameObject = __webpack_require__(17); +var GravityWell = __webpack_require__(332); +var List = __webpack_require__(122); +var ParticleEmitter = __webpack_require__(330); +var Render = __webpack_require__(888); + +/** + * @classdesc + * A Particle Emitter Manager creates and controls {@link Phaser.GameObjects.Particles.ParticleEmitter Particle Emitters} and {@link Phaser.GameObjects.Particles.GravityWell Gravity Wells}. + * + * @class ParticleEmitterManager + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Emitter Manager belongs. + * @param {string} texture - The key of the Texture this Emitter Manager will use to render particles, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Emitter Manager will use to render particles. + * @param {ParticleEmitterConfig|ParticleEmitterConfig[]} [emitters] - Configuration settings for one or more emitters to create. + */ +var ParticleEmitterManager = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.Pipeline, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + // frame is optional and can contain the emitters array or object if skipped + function ParticleEmitterManager (scene, texture, frame, emitters) + { + GameObject.call(this, scene, 'ParticleEmitterManager'); + + /** + * The blend mode applied to all emitters and particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode + * @type {integer} + * @default -1 + * @private + * @since 3.0.0 + */ + this.blendMode = -1; + + /** + * The time scale applied to all emitters and particles, affecting flow rate, lifespan, and movement. + * Values larger than 1 are faster than normal. + * This is multiplied with any timeScale set on each individual emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * The texture used to render this Emitter Manager's particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture + * @type {Phaser.Textures.Texture} + * @default null + * @since 3.0.0 + */ + this.texture = null; + + /** + * The texture frame used to render this Emitter Manager's particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame + * @type {Phaser.Textures.Frame} + * @default null + * @since 3.0.0 + */ + this.frame = null; + + /** + * Names of this Emitter Manager's texture frames. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames + * @type {string[]} + * @since 3.0.0 + */ + this.frameNames = []; + + // frame is optional and can contain the emitters array or object if skipped + if (frame !== null && (typeof frame === 'object' || Array.isArray(frame))) + { + emitters = frame; + frame = null; + } + + this.setTexture(texture, frame); + + this.initPipeline(); + + /** + * A list of Emitters being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.emitters = new List(this); + + /** + * A list of Gravity Wells being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.wells = new List(this); + + if (emitters) + { + // An array of emitter configs? + if (!Array.isArray(emitters)) + { + emitters = [ emitters ]; + } + + for (var i = 0; i < emitters.length; i++) + { + this.createEmitter(emitters[i]); + } + } + }, + + /** + * Sets the texture and frame this Emitter Manager will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Emitter Manager will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + setFrame: function (frame) + { + this.frame = this.texture.get(frame); + + var frames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); + + var names = []; + + frames.forEach(function (sourceFrame) + { + names.push(sourceFrame.name); + }); + + this.frameNames = names; + + this.defaultFrame = this.frame; + + return this; + }, + + /** + * Assigns texture frames to an emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames + * @since 3.0.0 + * + * @param {(Phaser.Textures.Frame|Phaser.Textures.Frame[])} frames - The texture frames. + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The particle emitter to modify. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + setEmitterFrames: function (frames, emitter) + { + if (!Array.isArray(frames)) + { + frames = [ frames ]; + } + + var out = emitter.frames; + + out.length = 0; + + for (var i = 0; i < frames.length; i++) + { + var frame = frames[i]; + + if (this.frameNames.indexOf(frame) !== -1) + { + out.push(this.texture.get(frame)); + } + } + + if (out.length > 0) + { + emitter.defaultFrame = out[0]; + } + else + { + emitter.defaultFrame = this.defaultFrame; + } + + return this; + }, + + /** + * Adds an existing Particle Emitter to this Emitter Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager. + */ + addEmitter: function (emitter) + { + return this.emitters.add(emitter); + }, + + /** + * Creates a new Particle Emitter object, adds it to this Emitter Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter + * @since 3.0.0 + * + * @param {ParticleEmitterConfig} config - Configuration settings for the Particle Emitter to create. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created. + */ + createEmitter: function (config) + { + return this.addEmitter(new ParticleEmitter(this, config)); + }, + + /** + * Adds an existing Gravity Well object to this Emitter Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager. + */ + addGravityWell: function (well) + { + return this.wells.add(well); + }, + + /** + * Creates a new Gravity Well, adds it to this Emitter Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell + * @since 3.0.0 + * + * @param {GravityWellConfig} config - Configuration settings for the Gravity Well to create. + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. + */ + createGravityWell: function (config) + { + return this.addGravityWell(new GravityWell(config)); + }, + + /** + * Emits particles from each active emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle + * @since 3.0.0 + * + * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * @param {number} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. + * @param {number} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + emitParticle: function (count, x, y) + { + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.emitParticle(count, x, y); + } + } + + return this; + }, + + /** + * Emits particles from each active emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt + * @since 3.0.0 + * + * @param {number} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. + * @param {number} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. + * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * Pauses this Emitter Manager. + * + * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. + * + * The particles will still render, but they will not have any of their logic updated. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * Resumes this Emitter Manager, should it have been previously paused. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * Gets all active particle processors (gravity wells). + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.GravityWell[]} - The active gravity wells. + */ + getProcessors: function () + { + return this.wells.getAll('active', true); + }, + + /** + * Updates all active emitters. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate + * @since 3.0.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. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.preUpdate(time, delta); + } + } + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setAlpha + * @private + * @since 3.10.0 + */ + setAlpha: function () + { + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setScrollFactor + * @private + * @since 3.10.0 + */ + setScrollFactor: function () + { + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setBlendMode + * @private + * @since 3.15.0 + */ + setBlendMode: function () + { + } + +}); + +module.exports = ParticleEmitterManager; + + +/***/ }), +/* 172 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * + * @function Phaser.Geom.Ellipse.CircumferencePoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (ellipse, angle, out) +{ + if (out === undefined) { out = new Point(); } + + var halfWidth = ellipse.width / 2; + var halfHeight = ellipse.height / 2; + + out.x = ellipse.x + halfWidth * Math.cos(angle); + out.y = ellipse.y + halfHeight * Math.sin(angle); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 173 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Graphics.Commands + */ + +module.exports = { + + ARC: 0, + BEGIN_PATH: 1, + CLOSE_PATH: 2, + FILL_RECT: 3, + LINE_TO: 4, + MOVE_TO: 5, + LINE_STYLE: 6, + FILL_STYLE: 7, + FILL_PATH: 8, + STROKE_PATH: 9, + FILL_TRIANGLE: 10, + STROKE_TRIANGLE: 11, + LINE_FX_TO: 12, + MOVE_FX_TO: 13, + SAVE: 14, + RESTORE: 15, + TRANSLATE: 16, + SCALE: 17, + ROTATE: 18, + SET_TEXTURE: 19, + CLEAR_TEXTURE: 20, + GRADIENT_FILL_STYLE: 21, + GRADIENT_LINE_STYLE: 22 + +}; + + +/***/ }), +/* 174 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCamera = __webpack_require__(131); +var Class = __webpack_require__(0); +var Commands = __webpack_require__(173); +var ComponentsAlpha = __webpack_require__(438); +var ComponentsBlendMode = __webpack_require__(436); +var ComponentsDepth = __webpack_require__(435); +var ComponentsMask = __webpack_require__(431); +var ComponentsPipeline = __webpack_require__(133); +var ComponentsTransform = __webpack_require__(426); +var ComponentsVisible = __webpack_require__(425); +var ComponentsScrollFactor = __webpack_require__(428); + +var Ellipse = __webpack_require__(99); +var GameObject = __webpack_require__(17); +var GetFastValue = __webpack_require__(1); +var GetValue = __webpack_require__(4); +var MATH_CONST = __webpack_require__(18); +var Render = __webpack_require__(898); + +/** + * Graphics line style (or stroke style) settings. + * + * @typedef {object} GraphicsLineStyle + * + * @property {number} [width] - The stroke width. + * @property {number} [color] - The stroke color. + * @property {number} [alpha] - The stroke alpha. + */ + +/** + * Graphics fill style settings. + * + * @typedef {object} GraphicsFillStyle + * + * @property {number} [color] - The fill color. + * @property {number} [alpha] - The fill alpha. + */ + +/** + * Graphics style settings. + * + * @typedef {object} GraphicsStyles + * + * @property {GraphicsLineStyle} [lineStyle] - The style applied to shape outlines. + * @property {GraphicsFillStyle} [fillStyle] - The style applied to shape areas. + */ + +/** + * Options for the Graphics game Object. + * + * @typedef {object} GraphicsOptions + * @extends GraphicsStyles + * + * @property {number} [x] - The x coordinate of the Graphics. + * @property {number} [y] - The y coordinate of the Graphics. + */ + +/** + * @classdesc + * A Graphics object is a way to draw primitive shapes to your game. Primitives include forms of geometry, such as + * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics + * object it will be empty. + * + * To draw to it you must first specify a line style or fill style (or both), draw shapes using paths, and finally + * fill or stroke them. For example: + * + * ```javascript + * graphics.lineStyle(5, 0xFF00FF, 1.0); + * graphics.beginPath(); + * graphics.moveTo(100, 100); + * graphics.lineTo(200, 200); + * graphics.closePath(); + * graphics.strokePath(); + * ``` + * + * There are also many helpful methods that draw and fill/stroke common shapes for you. + * + * ```javascript + * graphics.lineStyle(5, 0xFF00FF, 1.0); + * graphics.fillStyle(0xFFFFFF, 1.0); + * graphics.fillRect(50, 50, 400, 200); + * graphics.strokeRect(50, 50, 400, 200); + * ``` + * + * When a Graphics object is rendered it will render differently based on if the game is running under Canvas or WebGL. + * Under Canvas it will use the HTML Canvas context drawing operations to draw the path. + * Under WebGL the graphics data is decomposed into polygons. Both of these are expensive processes, especially with + * complex shapes. + * + * If your Graphics object doesn't change much (or at all) once you've drawn your shape to it, then you will help + * performance by calling {@link Phaser.GameObjects.Graphics#generateTexture}. This will 'bake' the Graphics object into + * a Texture, and return it. You can then use this Texture for Sprites or other display objects. If your Graphics object + * updates frequently then you should avoid doing this, as it will constantly generate new textures, which will consume + * memory. + * + * As you can tell, Graphics objects are a bit of a trade-off. While they are extremely useful, you need to be careful + * in their complexity and quantity of them in your game. + * + * @class Graphics + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Graphics object belongs. + * @param {GraphicsOptions} [options] - Options that set the position and default style of this Graphics object. + */ +var Graphics = new Class({ + + Extends: GameObject, + + Mixins: [ + ComponentsAlpha, + ComponentsBlendMode, + ComponentsDepth, + ComponentsMask, + ComponentsPipeline, + ComponentsTransform, + ComponentsVisible, + ComponentsScrollFactor, + Render + ], + + initialize: + + function Graphics (scene, options) + { + var x = GetValue(options, 'x', 0); + var y = GetValue(options, 'y', 0); + + GameObject.call(this, scene, 'Graphics'); + + this.setPosition(x, y); + this.initPipeline(); + + /** + * The horizontal display origin of the Graphics. + * + * @name Phaser.GameObjects.Graphics#displayOriginX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.displayOriginX = 0; + + /** + * The vertical display origin of the Graphics. + * + * @name Phaser.GameObjects.Graphics#displayOriginY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.displayOriginY = 0; + + /** + * The array of commands used to render the Graphics. + * + * @name Phaser.GameObjects.Graphics#commandBuffer + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.commandBuffer = []; + + /** + * The default fill color for shapes rendered by this Graphics object. + * + * @name Phaser.GameObjects.Graphics#defaultFillColor + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.defaultFillColor = -1; + + /** + * The default fill alpha for shapes rendered by this Graphics object. + * + * @name Phaser.GameObjects.Graphics#defaultFillAlpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.defaultFillAlpha = 1; + + /** + * The default stroke width for shapes rendered by this Graphics object. + * + * @name Phaser.GameObjects.Graphics#defaultStrokeWidth + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.defaultStrokeWidth = 1; + + /** + * The default stroke color for shapes rendered by this Graphics object. + * + * @name Phaser.GameObjects.Graphics#defaultStrokeColor + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.defaultStrokeColor = -1; + + /** + * The default stroke alpha for shapes rendered by this Graphics object. + * + * @name Phaser.GameObjects.Graphics#defaultStrokeAlpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.defaultStrokeAlpha = 1; + + /** + * Internal property that keeps track of the line width style setting. + * + * @name Phaser.GameObjects.Graphics#_lineWidth + * @type {number} + * @private + * @since 3.0.0 + */ + this._lineWidth = 1.0; + + this.setDefaultStyles(options); + }, + + /** + * Set the default style settings for this Graphics object. + * + * @method Phaser.GameObjects.Graphics#setDefaultStyles + * @since 3.0.0 + * + * @param {GraphicsStyles} options - The styles to set as defaults. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + setDefaultStyles: function (options) + { + if (GetValue(options, 'lineStyle', null)) + { + this.defaultStrokeWidth = GetValue(options, 'lineStyle.width', 1); + this.defaultStrokeColor = GetValue(options, 'lineStyle.color', 0xffffff); + this.defaultStrokeAlpha = GetValue(options, 'lineStyle.alpha', 1); + + this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); + } + + if (GetValue(options, 'fillStyle', null)) + { + this.defaultFillColor = GetValue(options, 'fillStyle.color', 0xffffff); + this.defaultFillAlpha = GetValue(options, 'fillStyle.alpha', 1); + + this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); + } + + return this; + }, + + /** + * Set the current line style. + * + * @method Phaser.GameObjects.Graphics#lineStyle + * @since 3.0.0 + * + * @param {number} lineWidth - The stroke width. + * @param {number} color - The stroke color. + * @param {number} [alpha=1] - The stroke alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineStyle: function (lineWidth, color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.LINE_STYLE, + lineWidth, color, alpha + ); + + this._lineWidth = lineWidth; + + return this; + }, + + /** + * Set the current fill style. + * + * @method Phaser.GameObjects.Graphics#fillStyle + * @since 3.0.0 + * + * @param {number} color - The fill color. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillStyle: function (color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.FILL_STYLE, + color, alpha + ); + + return this; + }, + + /** + * Sets a gradient fill style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all filled shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. + * + * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. + * + * This feature is best used only on rectangles and triangles. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#fillGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {integer} topLeft - The tint being applied to the top-left of the Game Object. + * @param {integer} topRight - The tint being applied to the top-right of the Game Object. + * @param {integer} bottomLeft - The tint being applied to the bottom-left of the Game Object. + * @param {integer} bottomRight - The tint being applied to the bottom-right of the Game Object. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillGradientStyle: function (topLeft, topRight, bottomLeft, bottomRight, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.GRADIENT_FILL_STYLE, + alpha, topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Sets a gradient line style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all stroked shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. + * + * This feature is best used only on single lines. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#lineGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {number} lineWidth - The stroke width. + * @param {integer} topLeft - The tint being applied to the top-left of the Game Object. + * @param {integer} topRight - The tint being applied to the top-right of the Game Object. + * @param {integer} bottomLeft - The tint being applied to the bottom-left of the Game Object. + * @param {integer} bottomRight - The tint being applied to the bottom-right of the Game Object. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineGradientStyle: function (lineWidth, topLeft, topRight, bottomLeft, bottomRight, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.GRADIENT_LINE_STYLE, + lineWidth, alpha, topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Sets the texture frame this Graphics Object will use when drawing all shapes defined after calling this. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Once set, all shapes will use this texture. Call this method with no arguments to clear it. + * + * The textures are not tiled. They are stretched to the dimensions of the shapes being rendered. For this reason, + * it works best with seamless / tileable textures. + * + * The mode argument controls how the textures are combined with the fill colors. The default value (0) will + * multiply the texture by the fill color. A value of 1 will use just the fill color, but the alpha data from the texture, + * and a value of 2 will use just the texture and no fill color at all. + * + * @method Phaser.GameObjects.Graphics#setTexture + * @since 3.12.0 + * @webglOnly + * + * @param {string} [key] - The key of the texture to be used, as stored in the Texture Manager. Leave blank to clear a previously set texture. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} [mode=0] - The texture tint mode. 0 is multiply, 1 is alpha only and 2 is texture only. + * + * @return {this} This Game Object. + */ + setTexture: function (key, frame, mode) + { + if (mode === undefined) { mode = 0; } + + if (key === undefined) + { + this.commandBuffer.push( + Commands.CLEAR_TEXTURE + ); + } + else + { + var textureFrame = this.scene.sys.textures.getFrame(key, frame); + + if (textureFrame) + { + if (mode === 2) + { + mode = 3; + } + + this.commandBuffer.push( + Commands.SET_TEXTURE, + textureFrame, + mode + ); + } + } + + return this; + }, + + /** + * Start a new shape path. + * + * @method Phaser.GameObjects.Graphics#beginPath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + beginPath: function () + { + this.commandBuffer.push( + Commands.BEGIN_PATH + ); + + return this; + }, + + /** + * Close the current path. + * + * @method Phaser.GameObjects.Graphics#closePath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + closePath: function () + { + this.commandBuffer.push( + Commands.CLOSE_PATH + ); + + return this; + }, + + /** + * Fill the current path. + * + * @method Phaser.GameObjects.Graphics#fillPath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPath: function () + { + this.commandBuffer.push( + Commands.FILL_PATH + ); + + return this; + }, + + /** + * Stroke the current path. + * + * @method Phaser.GameObjects.Graphics#strokePath + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokePath: function () + { + this.commandBuffer.push( + Commands.STROKE_PATH + ); + + return this; + }, + + /** + * Fill the given circle. + * + * @method Phaser.GameObjects.Graphics#fillCircleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The circle to fill. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillCircleShape: function (circle) + { + return this.fillCircle(circle.x, circle.y, circle.radius); + }, + + /** + * Stroke the given circle. + * + * @method Phaser.GameObjects.Graphics#strokeCircleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The circle to stroke. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeCircleShape: function (circle) + { + return this.strokeCircle(circle.x, circle.y, circle.radius); + }, + + /** + * Fill a circle with the given position and radius. + * + * @method Phaser.GameObjects.Graphics#fillCircle + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the circle. + * @param {number} y - The y coordinate of the center of the circle. + * @param {number} radius - The radius of the circle. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillCircle: function (x, y, radius) + { + this.beginPath(); + this.arc(x, y, radius, 0, MATH_CONST.PI2); + this.fillPath(); + + return this; + }, + + /** + * Stroke a circle with the given position and radius. + * + * @method Phaser.GameObjects.Graphics#strokeCircle + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the circle. + * @param {number} y - The y coordinate of the center of the circle. + * @param {number} radius - The radius of the circle. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeCircle: function (x, y, radius) + { + this.beginPath(); + this.arc(x, y, radius, 0, MATH_CONST.PI2); + this.strokePath(); + + return this; + }, + + /** + * Fill the given rectangle. + * + * @method Phaser.GameObjects.Graphics#fillRectShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The rectangle to fill. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillRectShape: function (rect) + { + return this.fillRect(rect.x, rect.y, rect.width, rect.height); + }, + + /** + * Stroke the given rectangle. + * + * @method Phaser.GameObjects.Graphics#strokeRectShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The rectangle to stroke. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeRectShape: function (rect) + { + return this.strokeRect(rect.x, rect.y, rect.width, rect.height); + }, + + /** + * Fill a rectangle with the given position and size. + * + * @method Phaser.GameObjects.Graphics#fillRect + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillRect: function (x, y, width, height) + { + this.commandBuffer.push( + Commands.FILL_RECT, + x, y, width, height + ); + + return this; + }, + + /** + * Stroke a rectangle with the given position and size. + * + * @method Phaser.GameObjects.Graphics#strokeRect + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeRect: function (x, y, width, height) + { + var lineWidthHalf = this._lineWidth / 2; + var minx = x - lineWidthHalf; + var maxx = x + lineWidthHalf; + + this.beginPath(); + this.moveTo(x, y); + this.lineTo(x, y + height); + this.strokePath(); + + this.beginPath(); + this.moveTo(x + width, y); + this.lineTo(x + width, y + height); + this.strokePath(); + + this.beginPath(); + this.moveTo(minx, y); + this.lineTo(maxx + width, y); + this.strokePath(); + + this.beginPath(); + this.moveTo(minx, y + height); + this.lineTo(maxx + width, y + height); + this.strokePath(); + + return this; + }, + + /** + * Fill a rounded rectangle with the given position, size and radius. + * + * @method Phaser.GameObjects.Graphics#fillRoundedRect + * @since 3.11.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {number} [radius = 20] - The corner radius; It can also be an object to specify different radii for corners + * @param {number} [radius.tl = 20] Top left + * @param {number} [radius.tr = 20] Top right + * @param {number} [radius.br = 20] Bottom right + * @param {number} [radius.bl = 20] Bottom left + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillRoundedRect: function (x, y, width, height, radius) + { + if (radius === undefined) { radius = 20; } + + var tl = radius; + var tr = radius; + var bl = radius; + var br = radius; + + if (typeof radius !== 'number') + { + tl = GetFastValue(radius, 'tl', 20); + tr = GetFastValue(radius, 'tr', 20); + bl = GetFastValue(radius, 'bl', 20); + br = GetFastValue(radius, 'br', 20); + } + + this.beginPath(); + this.moveTo(x + tl, y); + this.lineTo(x + width - tr, y); + this.arc(x + width - tr, y + tr, tr, -MATH_CONST.TAU, 0); + this.lineTo(x + width, y + height - br); + this.arc(x + width - br, y + height - br, br, 0, MATH_CONST.TAU); + this.lineTo(x + bl, y + height); + this.arc(x + bl, y + height - bl, bl, MATH_CONST.TAU, Math.PI); + this.lineTo(x, y + tl); + this.arc(x + tl, y + tl, tl, -Math.PI, -MATH_CONST.TAU); + this.fillPath(); + + return this; + }, + + /** + * Stroke a rounded rectangle with the given position, size and radius. + * + * @method Phaser.GameObjects.Graphics#strokeRoundedRect + * @since 3.11.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {number} [radius = 20] - The corner radius; It can also be an object to specify different radii for corners + * @param {number} [radius.tl = 20] Top left + * @param {number} [radius.tr = 20] Top right + * @param {number} [radius.br = 20] Bottom right + * @param {number} [radius.bl = 20] Bottom left + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeRoundedRect: function (x, y, width, height, radius) + { + if (radius === undefined) { radius = 20; } + + var tl = radius; + var tr = radius; + var bl = radius; + var br = radius; + + if (typeof radius !== 'number') + { + tl = GetFastValue(radius, 'tl', 20); + tr = GetFastValue(radius, 'tr', 20); + bl = GetFastValue(radius, 'bl', 20); + br = GetFastValue(radius, 'br', 20); + } + + this.beginPath(); + this.moveTo(x + tl, y); + this.lineTo(x + width - tr, y); + this.arc(x + width - tr, y + tr, tr, -MATH_CONST.TAU, 0); + this.lineTo(x + width, y + height - br); + this.arc(x + width - br, y + height - br, br, 0, MATH_CONST.TAU); + this.lineTo(x + bl, y + height); + this.arc(x + bl, y + height - bl, bl, MATH_CONST.TAU, Math.PI); + this.lineTo(x, y + tl); + this.arc(x + tl, y + tl, tl, -Math.PI, -MATH_CONST.TAU); + this.strokePath(); + + return this; + }, + + /** + * Fill the given point. + * + * Draws a square at the given position, 1 pixel in size by default. + * + * @method Phaser.GameObjects.Graphics#fillPointShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - The point to fill. + * @param {number} [size=1] - The size of the square to draw. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPointShape: function (point, size) + { + return this.fillPoint(point.x, point.y, size); + }, + + /** + * Fill a point at the given position. + * + * Draws a square at the given position, 1 pixel in size by default. + * + * @method Phaser.GameObjects.Graphics#fillPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point. + * @param {number} y - The y coordinate of the point. + * @param {number} [size=1] - The size of the square to draw. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPoint: function (x, y, size) + { + if (!size || size < 1) + { + size = 1; + } + else + { + x -= (size / 2); + y -= (size / 2); + } + + this.commandBuffer.push( + Commands.FILL_RECT, + x, y, size, size + ); + + return this; + }, + + /** + * Fill the given triangle. + * + * @method Phaser.GameObjects.Graphics#fillTriangleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The triangle to fill. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillTriangleShape: function (triangle) + { + return this.fillTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); + }, + + /** + * Stroke the given triangle. + * + * @method Phaser.GameObjects.Graphics#strokeTriangleShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The triangle to stroke. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeTriangleShape: function (triangle) + { + return this.strokeTriangle(triangle.x1, triangle.y1, triangle.x2, triangle.y2, triangle.x3, triangle.y3); + }, + + /** + * Fill a triangle with the given points. + * + * @method Phaser.GameObjects.Graphics#fillTriangle + * @since 3.0.0 + * + * @param {number} x0 - The x coordinate of the first point. + * @param {number} y0 - The y coordinate of the first point. + * @param {number} x1 - The x coordinate of the second point. + * @param {number} y1 - The y coordinate of the second point. + * @param {number} x2 - The x coordinate of the third point. + * @param {number} y2 - The y coordinate of the third point. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillTriangle: function (x0, y0, x1, y1, x2, y2) + { + this.commandBuffer.push( + Commands.FILL_TRIANGLE, + x0, y0, x1, y1, x2, y2 + ); + + return this; + }, + + /** + * Stroke a triangle with the given points. + * + * @method Phaser.GameObjects.Graphics#strokeTriangle + * @since 3.0.0 + * + * @param {number} x0 - The x coordinate of the first point. + * @param {number} y0 - The y coordinate of the first point. + * @param {number} x1 - The x coordinate of the second point. + * @param {number} y1 - The y coordinate of the second point. + * @param {number} x2 - The x coordinate of the third point. + * @param {number} y2 - The y coordinate of the third point. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeTriangle: function (x0, y0, x1, y1, x2, y2) + { + this.commandBuffer.push( + Commands.STROKE_TRIANGLE, + x0, y0, x1, y1, x2, y2 + ); + + return this; + }, + + /** + * Draw the given line. + * + * @method Phaser.GameObjects.Graphics#strokeLineShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to stroke. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeLineShape: function (line) + { + return this.lineBetween(line.x1, line.y1, line.x2, line.y2); + }, + + /** + * Draw a line between the given points. + * + * @method Phaser.GameObjects.Graphics#lineBetween + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the start point of the line. + * @param {number} y1 - The y coordinate of the start point of the line. + * @param {number} x2 - The x coordinate of the end point of the line. + * @param {number} y2 - The y coordinate of the end point of the line. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineBetween: function (x1, y1, x2, y2) + { + this.beginPath(); + this.moveTo(x1, y1); + this.lineTo(x2, y2); + this.strokePath(); + + return this; + }, + + /** + * Draw a line from the current drawing position to the given position. + * + * Moves the current drawing position to the given position. + * + * @method Phaser.GameObjects.Graphics#lineTo + * @since 3.0.0 + * + * @param {number} x - The x coordinate to draw the line to. + * @param {number} y - The y coordinate to draw the line to. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineTo: function (x, y) + { + this.commandBuffer.push( + Commands.LINE_TO, + x, y + ); + + return this; + }, + + /** + * Move the current drawing position to the given position. + * + * @method Phaser.GameObjects.Graphics#moveTo + * @since 3.0.0 + * + * @param {number} x - The x coordinate to move to. + * @param {number} y - The y coordinate to move to. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + moveTo: function (x, y) + { + this.commandBuffer.push( + Commands.MOVE_TO, + x, y + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#lineFxTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineFxTo: function (x, y, width, rgb) + { + this.commandBuffer.push( + Commands.LINE_FX_TO, + x, y, width, rgb, 1 + ); + + return this; + }, + + /** + * [description] + * + * @method Phaser.GameObjects.Graphics#moveFxTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} rgb - [description] + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + moveFxTo: function (x, y, width, rgb) + { + this.commandBuffer.push( + Commands.MOVE_FX_TO, + x, y, width, rgb, 1 + ); + + return this; + }, + + /** + * Stroke the shape represented by the given array of points. + * + * Pass `true` to `autoClose` to close the shape automatically. + * + * @method Phaser.GameObjects.Graphics#strokePoints + * @since 3.0.0 + * + * @param {(array|Phaser.Geom.Point[])} points - The points to stroke. + * @param {boolean} [autoClose=false] - When `true`, the shape is closed by joining the last point to the first point. + * @param {integer} [endIndex] - The index of `points` to stop drawing at. Defaults to `points.length`. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokePoints: function (points, autoClose, endIndex) + { + if (autoClose === undefined) { autoClose = false; } + if (endIndex === undefined) { endIndex = points.length; } + + this.beginPath(); + + this.moveTo(points[0].x, points[0].y); + + for (var i = 1; i < endIndex; i++) + { + this.lineTo(points[i].x, points[i].y); + } + + if (autoClose) + { + this.lineTo(points[0].x, points[0].y); + } + + this.strokePath(); + + return this; + }, + + /** + * Fill the shape represented by the given array of points. + * + * Pass `true` to `autoClose` to close the shape automatically. + * + * @method Phaser.GameObjects.Graphics#fillPoints + * @since 3.0.0 + * + * @param {(array|Phaser.Geom.Point[])} points - The points to fill. + * @param {boolean} [autoClose=false] - Whether to automatically close the polygon. + * @param {integer} [endIndex] - The index of `points` to stop at. Defaults to `points.length`. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillPoints: function (points, autoClose, endIndex) + { + if (autoClose === undefined) { autoClose = false; } + if (endIndex === undefined) { endIndex = points.length; } + + this.beginPath(); + + this.moveTo(points[0].x, points[0].y); + + for (var i = 1; i < endIndex; i++) + { + this.lineTo(points[i].x, points[i].y); + } + + if (autoClose) + { + this.lineTo(points[0].x, points[0].y); + } + + this.fillPath(); + + return this; + }, + + /** + * Stroke the given ellipse. + * + * @method Phaser.GameObjects.Graphics#strokeEllipseShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The ellipse to stroke. + * @param {integer} [smoothness=32] - The number of points to draw the ellipse with. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeEllipseShape: function (ellipse, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var points = ellipse.getPoints(smoothness); + + return this.strokePoints(points, true); + }, + + /** + * Stroke an ellipse with the given position and size. + * + * @method Phaser.GameObjects.Graphics#strokeEllipse + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the ellipse. + * @param {number} y - The y coordinate of the center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * @param {integer} [smoothness=32] - The number of points to draw the ellipse with. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeEllipse: function (x, y, width, height, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var ellipse = new Ellipse(x, y, width, height); + + var points = ellipse.getPoints(smoothness); + + return this.strokePoints(points, true); + }, + + /** + * Fill the given ellipse. + * + * @method Phaser.GameObjects.Graphics#fillEllipseShape + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The ellipse to fill. + * @param {integer} [smoothness=32] - The number of points to draw the ellipse with. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillEllipseShape: function (ellipse, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var points = ellipse.getPoints(smoothness); + + return this.fillPoints(points, true); + }, + + /** + * Fill an ellipse with the given position and size. + * + * @method Phaser.GameObjects.Graphics#fillEllipse + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the ellipse. + * @param {number} y - The y coordinate of the center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * @param {integer} [smoothness=32] - The number of points to draw the ellipse with. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillEllipse: function (x, y, width, height, smoothness) + { + if (smoothness === undefined) { smoothness = 32; } + + var ellipse = new Ellipse(x, y, width, height); + + var points = ellipse.getPoints(smoothness); + + return this.fillPoints(points, true); + }, + + /** + * Draw an arc. + * + * This method can be used to create circles, or parts of circles. + * + * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically + * close when filled or stroked. + * + * Use the optional `overshoot` argument increase the number of iterations that take place when + * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, + * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. + * + * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling + * this method to draw the arc. + * + * @method Phaser.GameObjects.Graphics#arc + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the center of the circle. + * @param {number} y - The y coordinate of the center of the circle. + * @param {number} radius - The radius of the circle. + * @param {number} startAngle - The starting angle, in radians. + * @param {number} endAngle - The ending angle, in radians. + * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + arc: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) + { + if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } + + this.commandBuffer.push( + Commands.ARC, + x, y, radius, startAngle, endAngle, anticlockwise, overshoot + ); + + return this; + }, + + /** + * Creates a pie-chart slice shape centered at `x`, `y` with the given radius. + * You must define the start and end angle of the slice. + * + * Setting the `anticlockwise` argument to `true` creates a shape similar to Pacman. + * Setting it to `false` creates a shape like a slice of pie. + * + * This method will begin a new path and close the path at the end of it. + * To display the actual slice you need to call either `strokePath` or `fillPath` after it. + * + * @method Phaser.GameObjects.Graphics#slice + * @since 3.4.0 + * + * @param {number} x - The horizontal center of the slice. + * @param {number} y - The vertical center of the slice. + * @param {number} radius - The radius of the slice. + * @param {number} startAngle - The start angle of the slice, given in radians. + * @param {number} endAngle - The end angle of the slice, given in radians. + * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + slice: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) + { + if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } + + this.commandBuffer.push(Commands.BEGIN_PATH); + + this.commandBuffer.push(Commands.MOVE_TO, x, y); + + this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise, overshoot); + + this.commandBuffer.push(Commands.CLOSE_PATH); + + return this; + }, + + /** + * Saves the state of the Graphics by pushing the current state onto a stack. + * + * The most recently saved state can then be restored with {@link Phaser.GameObjects.Graphics#restore}. + * + * @method Phaser.GameObjects.Graphics#save + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + save: function () + { + this.commandBuffer.push( + Commands.SAVE + ); + + return this; + }, + + /** + * Restores the most recently saved state of the Graphics by popping from the state stack. + * + * Use {@link Phaser.GameObjects.Graphics#save} to save the current state, and call this afterwards to restore that state. + * + * If there is no saved state, this command does nothing. + * + * @method Phaser.GameObjects.Graphics#restore + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + restore: function () + { + this.commandBuffer.push( + Commands.RESTORE + ); + + return this; + }, + + /** + * Translate the graphics. + * + * @method Phaser.GameObjects.Graphics#translate + * @since 3.0.0 + * + * @param {number} x - The horizontal translation to apply. + * @param {number} y - The vertical translation to apply. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + translate: function (x, y) + { + this.commandBuffer.push( + Commands.TRANSLATE, + x, y + ); + + return this; + }, + + /** + * Scale the graphics. + * + * @method Phaser.GameObjects.Graphics#scale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale to apply. + * @param {number} y - The vertical scale to apply. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + scale: function (x, y) + { + this.commandBuffer.push( + Commands.SCALE, + x, y + ); + + return this; + }, + + /** + * Rotate the graphics. + * + * @method Phaser.GameObjects.Graphics#rotate + * @since 3.0.0 + * + * @param {number} radians - The rotation angle, in radians. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + rotate: function (radians) + { + this.commandBuffer.push( + Commands.ROTATE, + radians + ); + + return this; + }, + + /** + * Clear the command buffer and reset the fill style and line style to their defaults. + * + * @method Phaser.GameObjects.Graphics#clear + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + clear: function () + { + this.commandBuffer.length = 0; + + if (this.defaultFillColor > -1) + { + this.fillStyle(this.defaultFillColor, this.defaultFillAlpha); + } + + if (this.defaultStrokeColor > -1) + { + this.lineStyle(this.defaultStrokeWidth, this.defaultStrokeColor, this.defaultStrokeAlpha); + } + + return this; + }, + + /** + * Generate a texture from this Graphics object. + * + * If `key` is a string it'll generate a new texture using it and add it into the + * Texture Manager (assuming no key conflict happens). + * + * If `key` is a Canvas it will draw the texture to that canvas context. Note that it will NOT + * automatically upload it to the GPU in WebGL mode. + * + * @method Phaser.GameObjects.Graphics#generateTexture + * @since 3.0.0 + * + * @param {(string|HTMLCanvasElement)} key - The key to store the texture with in the Texture Manager, or a Canvas to draw to. + * @param {integer} [width] - The width of the graphics to generate. + * @param {integer} [height] - The height of the graphics to generate. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + generateTexture: function (key, width, height) + { + var sys = this.scene.sys; + var renderer = sys.game.renderer; + + if (width === undefined) { width = sys.game.config.width; } + if (height === undefined) { height = sys.game.config.height; } + + Graphics.TargetCamera.setScene(this.scene); + Graphics.TargetCamera.setViewport(0, 0, width, height); + Graphics.TargetCamera.scrollX = this.x; + Graphics.TargetCamera.scrollY = this.y; + + var texture; + var ctx; + + if (typeof key === 'string') + { + if (sys.textures.exists(key)) + { + // Key is a string, it DOES exist in the Texture Manager AND is a canvas, so draw to it + + texture = sys.textures.get(key); + + var src = texture.getSourceImage(); + + if (src instanceof HTMLCanvasElement) + { + ctx = src.getContext('2d'); + } + } + else + { + // Key is a string and doesn't exist in the Texture Manager, so generate and save it + + texture = sys.textures.createCanvas(key, width, height); + + ctx = texture.getSourceImage().getContext('2d'); + } + } + else if (key instanceof HTMLCanvasElement) + { + // Key is a Canvas, so draw to it + + ctx = key.getContext('2d'); + } + + if (ctx) + { + // var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) + this.renderCanvas(renderer, this, 0, Graphics.TargetCamera, null, ctx, false); + + if (texture) + { + texture.refresh(); + } + } + + return this; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Graphics#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.commandBuffer = []; + } + +}); + +/** + * A Camera used specifically by the Graphics system for rendering to textures. + * + * @name Phaser.GameObjects.Graphics.TargetCamera + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.1.0 + */ +Graphics.TargetCamera = new BaseCamera(); + +module.exports = Graphics; + + +/***/ }), +/* 175 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(119); +var Class = __webpack_require__(0); +var Render = __webpack_require__(901); + +/** + * @typedef {object} DisplayCallbackConfig + * + * @property {{topLeft:number, topRight:number, bottomLeft:number, bottomRight:number}} tint - The tint of the character being rendered. + * @property {number} index - The index of the character being rendered. + * @property {number} charCode - The character code of the character being rendered. + * @property {number} x - The x position of the character being rendered. + * @property {number} y - The y position of the character being rendered. + * @property {number} scale - The scale of the character being rendered. + * @property {number} rotation - The rotation of the character being rendered. + * @property {any} data - Custom data stored with the character being rendered. + */ + +/** + * @callback DisplayCallback + * + * @param {DisplayCallbackConfig} display - Settings of the character that is about to be rendered. + * + * @return {{x:number, y:number, scale:number, rotation:number}} Altered position, scale and rotation values for the character that is about to be rendered. + */ + +/** + * @classdesc + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * @class DynamicBitmapText + * @extends Phaser.GameObjects.BitmapText + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} x - The x coordinate of this Game Object in world space. + * @param {number} y - The y coordinate of this Game Object in world space. + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size of this Bitmap Text. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. + */ +var DynamicBitmapText = new Class({ + + Extends: BitmapText, + + Mixins: [ + Render + ], + + initialize: + + function DynamicBitmapText (scene, x, y, font, text, size, align) + { + BitmapText.call(this, scene, x, y, font, text, size, align); + + this.type = 'DynamicBitmapText'; + + /** + * The horizontal scroll position of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollX = 0; + + /** + * The vertical scroll position of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollY = 0; + + /** + * The crop width of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#cropWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropWidth = 0; + + /** + * The crop height of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#cropHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropHeight = 0; + + /** + * A callback that alters how each character of the Bitmap Text is rendered. + * + * @name Phaser.GameObjects.DynamicBitmapText#displayCallback + * @type {DisplayCallback} + * @since 3.0.0 + */ + this.displayCallback; + + /** + * The data object that is populated during rendering, then passed to the displayCallback. + * You should modify this object then return it back from the callback. It's updated values + * will be used to render the specific glyph. + * + * Please note that if you need a reference to this object locally in your game code then you + * should shallow copy it, as it's updated and re-used for every glyph in the text. + * + * @name Phaser.GameObjects.DynamicBitmapText#callbackData + * @type {DisplayCallbackConfig} + * @since 3.11.0 + */ + this.callbackData = { + color: 0, + tint: { + topLeft: 0, + topRight: 0, + bottomLeft: 0, + bottomRight: 0 + }, + index: 0, + charCode: 0, + x: 0, + y: 0, + scale: 0, + rotation: 0, + data: 0 + }; + }, + + /** + * Set the crop size of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setSize + * @since 3.0.0 + * + * @param {number} width - The width of the crop. + * @param {number} height - The height of the crop. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setSize: function (width, height) + { + this.cropWidth = width; + this.cropHeight = height; + + return this; + }, + + /** + * Set a callback that alters how each character of the Bitmap Text is rendered. + * + * The callback receives a {@link DisplayCallbackConfig} object that contains information about the character that's + * about to be rendered. + * + * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the + * usual values when rendering. + * + * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback + * @since 3.0.0 + * + * @param {DisplayCallback} callback - The display callback to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setDisplayCallback: function (callback) + { + this.displayCallback = callback; + + return this; + }, + + /** + * Set the horizontal scroll position of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollX + * @since 3.0.0 + * + * @param {number} value - The horizontal scroll position to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollX: function (value) + { + this.scrollX = value; + + return this; + }, + + /** + * Set the vertical scroll position of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollY + * @since 3.0.0 + * + * @param {number} value - The vertical scroll position to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollY: function (value) + { + this.scrollY = value; + + return this; + } + +}); + +module.exports = DynamicBitmapText; + + +/***/ }), +/* 176 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayUtils = __webpack_require__(180); +var BlendModes = __webpack_require__(72); +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var GameObject = __webpack_require__(17); +var Rectangle = __webpack_require__(10); +var Render = __webpack_require__(904); +var Union = __webpack_require__(337); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Container Game Object. + * + * 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. + * + * The position of the Game Object automatically becomes relative to the position of the Container. + * + * When the Container is rendered, all of its children are rendered as well, in the order in which they exist + * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. + * + * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will + * automatically influence all children as well. + * + * Containers can include other Containers for deeply nested transforms. + * + * Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked. + * The masks do not 'stack up'. Only a Container on the root of the display list will use its mask. + * + * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them + * to use as their hit area. Container children can also be enabled for input, independent of the Container. + * + * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, + * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, + * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children + * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure + * your game to work around this. + * + * It's important to understand the impact of using Containers. They add additional processing overhead into + * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true + * for input events. You also loose the ability to set the display depth of Container children in the same + * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost + * every time you create one, try to structure your game around avoiding that where possible. + * + * @class Container + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.4.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. + */ +var Container = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Mask, + Components.ScrollFactor, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function Container (scene, x, y, children) + { + GameObject.call(this, scene, 'Container'); + + /** + * An array holding the children of this Container. + * + * @name Phaser.GameObjects.Container#list + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.4.0 + */ + this.list = []; + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * + * @name Phaser.GameObjects.Container#exclusive + * @type {boolean} + * @default true + * @since 3.4.0 + */ + this.exclusive = true; + + /** + * Containers can have an optional maximum size. If set to anything above 0 it + * will constrict the addition of new Game Objects into the Container, capping off + * the maximum limit the Container can grow in size to. + * + * @name Phaser.GameObjects.Container#maxSize + * @type {integer} + * @default -1 + * @since 3.4.0 + */ + this.maxSize = -1; + + /** + * The cursor position. + * + * @name Phaser.GameObjects.Container#position + * @type {integer} + * @since 3.4.0 + */ + this.position = 0; + + /** + * Internal Transform Matrix used for local space conversion. + * + * @name Phaser.GameObjects.Container#localTransform + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.4.0 + */ + this.localTransform = new Components.TransformMatrix(); + + /** + * Internal temporary Transform Matrix used to avoid object creation. + * + * @name Phaser.GameObjects.Container#tempTransformMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.4.0 + */ + this.tempTransformMatrix = new Components.TransformMatrix(); + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.Container#_displayList + * @type {Phaser.GameObjects.DisplayList} + * @private + * @since 3.4.0 + */ + this._displayList = scene.sys.displayList; + + /** + * The property key to sort by. + * + * @name Phaser.GameObjects.Container#_sortKey + * @type {string} + * @private + * @since 3.4.0 + */ + this._sortKey = ''; + + /** + * A reference to the Scene Systems Event Emitter. + * + * @name Phaser.GameObjects.Container#_sysEvents + * @type {Phaser.Events.EventEmitter} + * @private + * @since 3.9.0 + */ + this._sysEvents = scene.sys.events; + + this.setPosition(x, y); + + this.clearAlpha(); + + this.setBlendMode(BlendModes.SKIP_CHECK); + + if (children) + { + this.add(children); + } + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#originX + * @type {number} + * @readonly + * @since 3.4.0 + */ + originX: { + + get: function () + { + return 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#originY + * @type {number} + * @readonly + * @since 3.4.0 + */ + originY: { + + get: function () + { + return 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#displayOriginX + * @type {number} + * @readonly + * @since 3.4.0 + */ + displayOriginX: { + + get: function () + { + return this.width * 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#displayOriginY + * @type {number} + * @readonly + * @since 3.4.0 + */ + displayOriginY: { + + get: function () + { + return this.height * 0.5; + } + + }, + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * + * @method Phaser.GameObjects.Container#setExclusive + * @since 3.4.0 + * + * @param {boolean} [value=true] - The exclusive state of this Container. + * + * @return {Phaser.GameObjects.Container} This Container. + */ + setExclusive: function (value) + { + if (value === undefined) { value = true; } + + this.exclusive = value; + + return this; + }, + + /** + * Gets the bounds of this Container. It works by iterating all children of the Container, + * getting their respective bounds, and then working out a min-max rectangle from that. + * It does not factor in if the children render or not, all are included. + * + * Some children are unable to return their bounds, such as Graphics objects, in which case + * they are skipped. + * + * Depending on the quantity of children in this Container it could be a really expensive call, + * so cache it and only poll it as needed. + * + * The values are stored and returned in a Rectangle object. + * + * @method Phaser.GameObjects.Container#getBounds + * @since 3.4.0 + * + * @param {Phaser.Geom.Rectangle} [output] - A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + output.setTo(this.x, this.y, 0, 0); + + if (this.list.length > 0) + { + var children = this.list; + var tempRect = new Rectangle(); + + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (entry.getBounds) + { + entry.getBounds(tempRect); + + Union(tempRect, output, output); + } + } + } + + return output; + }, + + /** + * Internal add handler. + * + * @method Phaser.GameObjects.Container#addHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just added to this Container. + */ + addHandler: function (gameObject) + { + gameObject.once('destroy', this.remove, this); + + if (this.exclusive) + { + this._displayList.remove(gameObject); + + if (gameObject.parentContainer) + { + gameObject.parentContainer.remove(gameObject); + } + + gameObject.parentContainer = this; + } + }, + + /** + * Internal remove handler. + * + * @method Phaser.GameObjects.Container#removeHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just removed from this Container. + */ + removeHandler: function (gameObject) + { + gameObject.off('destroy', this.remove); + + if (this.exclusive) + { + gameObject.parentContainer = null; + } + }, + + /** + * Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties, + * and transforms it into the space of this Container, then returns it in the output object. + * + * @method Phaser.GameObjects.Container#pointToContainer + * @since 3.4.0 + * + * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} source - The Source Point to be transformed. + * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} [output] - A destination object to store the transformed point in. If none given a Vector2 will be created and returned. + * + * @return {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} The transformed point. + */ + pointToContainer: function (source, output) + { + if (output === undefined) { output = new Vector2(); } + + if (this.parentContainer) + { + return this.parentContainer.pointToContainer(source, output); + } + + var tempMatrix = this.tempTransformMatrix; + + // No need to loadIdentity because applyITRS overwrites every value anyway + tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY); + + tempMatrix.invert(); + + tempMatrix.transformPoint(source.x, source.y, output); + + return output; + }, + + /** + * Returns the world transform matrix as used for Bounds checks. + * + * The returned matrix is temporal and shouldn't be stored. + * + * @method Phaser.GameObjects.Container#getBoundsTransformMatrix + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The world transform matrix. + */ + getBoundsTransformMatrix: function () + { + return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform); + }, + + /** + * Adds the given Game Object, or array of Game Objects, to this Container. + * + * Each Game Object must be unique within the Container. + * + * @method Phaser.GameObjects.Container#add + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + add: function (child) + { + ArrayUtils.Add(this.list, child, this.maxSize, this.addHandler, this); + + return this; + }, + + /** + * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. + * + * Existing Game Objects in the Container are shifted up. + * + * Each Game Object must be unique within the Container. + * + * @method Phaser.GameObjects.Container#addAt + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. + * @param {integer} [index=0] - The position to insert the Game Object/s at. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + addAt: function (child, index) + { + ArrayUtils.AddAt(this.list, child, index, this.maxSize, this.addHandler, this); + + return this; + }, + + /** + * Returns the Game Object at the given position in this Container. + * + * @method Phaser.GameObjects.Container#getAt + * @since 3.4.0 + * + * @param {integer} index - The position to get the Game Object from. + * + * @return {?Phaser.GameObjects.GameObject} The Game Object at the specified index, or `null` if none found. + */ + getAt: function (index) + { + return this.list[index]; + }, + + /** + * Returns the index of the given Game Object in this Container. + * + * @method Phaser.GameObjects.Container#getIndex + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to search for in this Container. + * + * @return {integer} The index of the Game Object in this Container, or -1 if not found. + */ + getIndex: function (child) + { + return this.list.indexOf(child); + }, + + /** + * Sort the contents of this Container so the items are in order based on the given property. + * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. + * + * @method Phaser.GameObjects.Container#sort + * @since 3.4.0 + * + * @param {string} property - The property to lexically sort by. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + sort: function (property) + { + if (property) + { + this._sortKey = property; + + ArrayUtils.StableSort.inplace(this.list, this.sortHandler); + } + + return this; + }, + + /** + * Internal sort handler method. + * + * @method Phaser.GameObjects.Container#sortHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} childA - The first child to sort. + * @param {Phaser.GameObjects.GameObject} childB - The second child to sort. + * + * @return {integer} The sort results. + */ + sortHandler: function (childA, childB) + { + return childA[this._sortKey] - childB[this._sortKey]; + }, + + /** + * Searches for the first instance of a child with its `name` property matching the given argument. + * Should more than one child have the same name only the first is returned. + * + * @method Phaser.GameObjects.Container#getByName + * @since 3.4.0 + * + * @param {string} name - The name to search for. + * + * @return {?Phaser.GameObjects.GameObject} The first child with a matching name, or `null` if none were found. + */ + getByName: function (name) + { + return ArrayUtils.GetFirst(this.list, 'name', name); + }, + + /** + * Returns a random Game Object from this Container. + * + * @method Phaser.GameObjects.Container#getRandom + * @since 3.4.0 + * + * @param {integer} [startIndex=0] - An optional start index. + * @param {integer} [length] - An optional length, the total number of elements (from the startIndex) to choose from. + * + * @return {?Phaser.GameObjects.GameObject} A random child from the Container, or `null` if the Container is empty. + */ + getRandom: function (startIndex, length) + { + return ArrayUtils.GetRandom(this.list, startIndex, length); + }, + + /** + * Gets the first Game Object in this Container. + * + * You can also specify a property and value to search for, in which case it will return the first + * Game Object in this Container with a matching property and / or value. + * + * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. + * + * You can limit the search to the `startIndex` - `endIndex` range. + * + * @method Phaser.GameObjects.Container#getFirst + * @since 3.4.0 + * + * @param {string} [property] - The property to test on each Game Object in the Container. + * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {?Phaser.GameObjects.GameObject} The first matching Game Object, or `null` if none was found. + */ + getFirst: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns all Game Objects in this Container. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('body')` would return only Game Objects that have a body property. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * + * @method Phaser.GameObjects.Container#getAll + * @since 3.4.0 + * + * @param {string} [property] - The property to test on each Game Object in the Container. + * @param {any} [value] - If property is set then the `property` must strictly equal this value to be included in the results. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {Phaser.GameObjects.GameObject[]} An array of matching Game Objects from this Container. + */ + getAll: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns the total number of Game Objects in this Container that have a property + * matching the given value. + * + * For example: `count('visible', true)` would count all the elements that have their visible property set. + * + * You can optionally limit the operation to the `startIndex` - `endIndex` range. + * + * @method Phaser.GameObjects.Container#count + * @since 3.4.0 + * + * @param {string} property - The property to check. + * @param {any} value - The value to check. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {integer} The total number of Game Objects in this Container with a property matching the given value. + */ + count: function (property, value, startIndex, endIndex) + { + return ArrayUtils.CountAllMatching(this.list, property, value, startIndex, endIndex); + }, + + /** + * Swaps the position of two Game Objects in this Container. + * Both Game Objects must belong to this Container. + * + * @method Phaser.GameObjects.Container#swap + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child1 - The first Game Object to swap. + * @param {Phaser.GameObjects.GameObject} child2 - The second Game Object to swap. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + swap: function (child1, child2) + { + ArrayUtils.Swap(this.list, child1, child2); + + return this; + }, + + /** + * Moves a Game Object to a new position within this Container. + * + * The Game Object must already be a child of this Container. + * + * The Game Object is removed from its old position and inserted into the new one. + * Therefore the Container size does not change. Other children will change position accordingly. + * + * @method Phaser.GameObjects.Container#moveTo + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to move. + * @param {integer} index - The new position of the Game Object in this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + moveTo: function (child, index) + { + ArrayUtils.MoveTo(this.list, child, index); + + return this; + }, + + /** + * Removes the given Game Object, or array of Game Objects, from this Container. + * + * The Game Objects must already be children of this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#remove + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to be removed from the Container. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each child successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + remove: function (child, destroyChild) + { + var removed = ArrayUtils.Remove(this.list, child, this.removeHandler, this); + + if (destroyChild && removed) + { + if (!Array.isArray(removed)) + { + removed = [ removed ]; + } + + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Removes the Game Object at the given position in this Container. + * + * You can also optionally call `destroy` on the Game Object, if one is found. + * + * @method Phaser.GameObjects.Container#removeAt + * @since 3.4.0 + * + * @param {integer} index - The index of the Game Object to be removed. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + removeAt: function (index, destroyChild) + { + var removed = ArrayUtils.RemoveAt(this.list, index, this.removeHandler, this); + + if (destroyChild && removed) + { + removed.destroy(); + } + + return this; + }, + + /** + * Removes the Game Objects between the given positions in this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#removeBetween + * @since 3.4.0 + * + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + removeBetween: function (startIndex, endIndex, destroyChild) + { + var removed = ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeHandler, this); + + if (destroyChild) + { + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Removes all Game Objects from this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#removeAll + * @since 3.4.0 + * + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + removeAll: function (destroyChild) + { + var removed = ArrayUtils.RemoveBetween(this.list, 0, this.list.length, this.removeHandler, this); + + if (destroyChild) + { + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Brings the given Game Object to the top of this Container. + * This will cause it to render on-top of any other objects in the Container. + * + * @method Phaser.GameObjects.Container#bringToTop + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to bring to the top of the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + bringToTop: function (child) + { + ArrayUtils.BringToTop(this.list, child); + + return this; + }, + + /** + * Sends the given Game Object to the bottom of this Container. + * This will cause it to render below any other objects in the Container. + * + * @method Phaser.GameObjects.Container#sendToBack + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to send to the bottom of the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + sendToBack: function (child) + { + ArrayUtils.SendToBack(this.list, child); + + return this; + }, + + /** + * Moves the given Game Object up one place in this Container, unless it's already at the top. + * + * @method Phaser.GameObjects.Container#moveUp + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + moveUp: function (child) + { + ArrayUtils.MoveUp(this.list, child); + + return this; + }, + + /** + * Moves the given Game Object down one place in this Container, unless it's already at the bottom. + * + * @method Phaser.GameObjects.Container#moveDown + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + moveDown: function (child) + { + ArrayUtils.MoveDown(this.list, child); + + return this; + }, + + /** + * Reverses the order of all Game Objects in this Container. + * + * @method Phaser.GameObjects.Container#reverse + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + reverse: function () + { + this.list.reverse(); + + return this; + }, + + /** + * Shuffles the all Game Objects in this Container using the Fisher-Yates implementation. + * + * @method Phaser.GameObjects.Container#shuffle + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + shuffle: function () + { + ArrayUtils.Shuffle(this.list); + + return this; + }, + + /** + * Replaces a Game Object in this Container with the new Game Object. + * The new Game Object cannot already be a child of this Container. + * + * @method Phaser.GameObjects.Container#replace + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} oldChild - The Game Object in this Container that will be replaced. + * @param {Phaser.GameObjects.GameObject} newChild - The Game Object to be added to this Container. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + replace: function (oldChild, newChild, destroyChild) + { + var moved = ArrayUtils.Replace(this.list, oldChild, newChild); + + if (moved) + { + this.addHandler(newChild); + this.removeHandler(oldChild); + + if (destroyChild) + { + oldChild.destroy(); + } + } + + return this; + }, + + /** + * Returns `true` if the given Game Object is a direct child of this Container. + * + * This check does not scan nested Containers. + * + * @method Phaser.GameObjects.Container#exists + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to check for within this Container. + * + * @return {boolean} True if the Game Object is an immediate child of this Container, otherwise false. + */ + exists: function (child) + { + return (this.list.indexOf(child) > -1); + }, + + /** + * Sets the property to the given value on all Game Objects in this Container. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * + * @method Phaser.GameObjects.Container#setAll + * @since 3.4.0 + * + * @param {string} property - The property that must exist on the Game Object. + * @param {any} value - The value to get the property to. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + setAll: function (property, value, startIndex, endIndex) + { + ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); + + return this; + }, + + /** + * @callback EachContainerCallback + * @generic I - [item] + * + * @param {*} item - The child Game Object of the Container. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + + /** + * Passes all Game Objects in this Container to the given callback. + * + * A copy of the Container is made before passing each entry to your callback. + * This protects against the callback itself modifying the Container. + * + * If you know for sure that the callback will not change the size of this Container + * then you can use the more performant `Container.iterate` method instead. + * + * @method Phaser.GameObjects.Container#each + * @since 3.4.0 + * + * @param {function} callback - The function to call. + * @param {object} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + each: function (callback, context) + { + var args = [ null ]; + var i; + var temp = this.list.slice(); + var len = temp.length; + + for (i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < len; i++) + { + args[0] = temp[i]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Passes all Game Objects in this Container to the given callback. + * + * Only use this method when you absolutely know that the Container will not be modified during + * the iteration, i.e. by removing or adding to its contents. + * + * @method Phaser.GameObjects.Container#iterate + * @since 3.4.0 + * + * @param {function} callback - The function to call. + * @param {object} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + iterate: function (callback, context) + { + var args = [ null ]; + var i; + + for (i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < this.list.length; i++) + { + args[0] = this.list[i]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * The number of Game Objects inside this Container. + * + * @name Phaser.GameObjects.Container#length + * @type {integer} + * @readonly + * @since 3.4.0 + */ + length: { + + get: function () + { + return this.list.length; + } + + }, + + /** + * Returns the first Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#first + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + first: { + + get: function () + { + this.position = 0; + + if (this.list.length > 0) + { + return this.list[0]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the last Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#last + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + last: { + + get: function () + { + if (this.list.length > 0) + { + this.position = this.list.length - 1; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the next Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#next + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + next: { + + get: function () + { + if (this.position < this.list.length) + { + this.position++; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the previous Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#previous + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + previous: { + + get: function () + { + if (this.position > 0) + { + this.position--; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Container#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.removeAll(!!this.exclusive); + + this.localTransform.destroy(); + this.tempTransformMatrix.destroy(); + + this.list = []; + this._displayList = null; + } + +}); + +module.exports = Container; + + +/***/ }), +/* 177 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlitterRender = __webpack_require__(908); +var Bob = __webpack_require__(905); +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var Frame = __webpack_require__(123); +var GameObject = __webpack_require__(17); +var List = __webpack_require__(122); + +/** + * @callback Phaser.GameObjects.Blitter.CreateCallback + * + * @param {Phaser.GameObjects.Blitter.Bob} bob - The Bob that was created by the Blitter. + * @param {integer} index - The position of the Bob within the Blitter display list. + */ + +/** + * @classdesc + * A Blitter Game Object. + * + * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. + * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, + * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed + * during rendering. + * + * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this + * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows + * them their speed. + * + * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth + * investigating. They are especially useful for using as a base for your own special effects systems. + * + * @class Blitter + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. + * @param {(string|integer)} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. + */ +var Blitter = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Mask, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + BlitterRender + ], + + initialize: + + function Blitter (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Blitter'); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.initPipeline(); + + /** + * The children of this Blitter. + * This List contains all of the Bob objects created by the Blitter. + * + * @name Phaser.GameObjects.Blitter#children + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.children = new List(); + + /** + * A transient array that holds all of the Bobs that will be rendered this frame. + * The array is re-populated whenever the dirty flag is set. + * + * @name Phaser.GameObjects.Blitter#renderList + * @type {Phaser.GameObjects.Blitter.Bob[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.renderList = []; + + /** + * Is the Blitter considered dirty? + * A 'dirty' Blitter has had its child count changed since the last frame. + * + * @name Phaser.GameObjects.Blitter#dirty + * @type {boolean} + * @since 3.0.0 + */ + this.dirty = false; + }, + + /** + * Creates a new Bob in this Blitter. + * + * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. + * A Bob can use any frame belonging to the texture bound to the Blitter. + * + * @method Phaser.GameObjects.Blitter#create + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. + * + * @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object. + */ + create: function (x, y, frame, visible, index) + { + if (visible === undefined) { visible = true; } + if (index === undefined) { index = this.children.length; } + + if (frame === undefined) + { + frame = this.frame; + } + else if (!(frame instanceof Frame)) + { + frame = this.texture.get(frame); + } + + var bob = new Bob(this, x, y, frame, visible); + + this.children.addAt(bob, index, false); + + this.dirty = true; + + return bob; + }, + + /** + * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. + * + * @method Phaser.GameObjects.Blitter#createFromCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter.CreateCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createFromCallback: function (callback, quantity, frame, visible) + { + var bobs = this.createMultiple(quantity, frame, visible); + + for (var i = 0; i < bobs.length; i++) + { + var bob = bobs[i]; + + callback.call(this, bob, i); + } + + return bobs; + }, + + /** + * Creates multiple Bobs in one call. + * + * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. + * + * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first + * frame and 10 with the second. + * + * @method Phaser.GameObjects.Blitter#createMultiple + * @since 3.0.0 + * + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createMultiple: function (quantity, frame, visible) + { + if (frame === undefined) { frame = this.frame.name; } + if (visible === undefined) { visible = true; } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + + var bobs = []; + var _this = this; + + frame.forEach(function (singleFrame) + { + for (var i = 0; i < quantity; i++) + { + bobs.push(_this.create(0, 0, singleFrame, visible)); + } + }); + + return bobs; + }, + + /** + * Checks if the given child can render or not, by checking its `visible` and `alpha` values. + * + * @method Phaser.GameObjects.Blitter#childCanRender + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter.Bob} child - The Bob to check for rendering. + * + * @return {boolean} Returns `true` if the given child can render, otherwise `false`. + */ + childCanRender: function (child) + { + return (child.visible && child.alpha > 0); + }, + + /** + * Returns an array of Bobs to be rendered. + * If the Blitter is dirty then a new list is generated and stored in `renderList`. + * + * @method Phaser.GameObjects.Blitter#getRenderList + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that will be rendered this frame. + */ + getRenderList: function () + { + if (this.dirty) + { + this.renderList = this.children.list.filter(this.childCanRender, this); + this.dirty = false; + } + + return this.renderList; + }, + + /** + * Removes all Bobs from the children List and clears the dirty flag. + * + * @method Phaser.GameObjects.Blitter#clear + * @since 3.0.0 + */ + clear: function () + { + this.children.removeAll(); + this.dirty = true; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Blitter#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.children.destroy(); + + this.renderList = []; + } + +}); + +module.exports = Blitter; + + +/***/ }), +/* 178 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns a Random element from the array. + * + * @function Phaser.Utils.Array.GetRandom + * @since 3.0.0 + * + * @param {array} array - The array to select the random entry from. + * @param {integer} [startIndex=0] - An optional start index. + * @param {integer} [length=array.length] - An optional length, the total number of elements (from the startIndex) to choose from. + * + * @return {*} A random element from the array, or `null` if no element could be found in the range given. + */ +var GetRandom = function (array, startIndex, length) +{ + if (startIndex === undefined) { startIndex = 0; } + if (length === undefined) { length = array.length; } + + var randomIndex = startIndex + Math.floor(Math.random() * length); + + return (array[randomIndex] === undefined) ? null : array[randomIndex]; +}; + +module.exports = GetRandom; + + +/***/ }), +/* 179 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** +* A Matrix is simply an array of arrays, where each sub-array (the rows) have the same length: +* +* let matrix2 = [ +* [ 1, 1, 1, 1, 1, 1 ], +* [ 2, 0, 0, 0, 0, 4 ], +* [ 2, 0, 1, 2, 0, 4 ], +* [ 2, 0, 3, 4, 0, 4 ], +* [ 2, 0, 0, 0, 0, 4 ], +* [ 3, 3, 3, 3, 3, 3 ] +*]; +*/ + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.CheckMatrix + * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {boolean} [description] + */ +var CheckMatrix = function (matrix) +{ + if (!Array.isArray(matrix) || matrix.length < 2 || !Array.isArray(matrix[0])) + { + return false; + } + + // How long is the first row? + var size = matrix[0].length; + + // Validate the rest of the rows are the same length + for (var i = 1; i < matrix.length; i++) + { + if (matrix[i].length !== size) + { + return false; + } + } + + return true; +}; + +module.exports = CheckMatrix; + + +/***/ }), +/* 180 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.Array + */ + +module.exports = { + + Matrix: __webpack_require__(941), + + Add: __webpack_require__(934), + AddAt: __webpack_require__(933), + BringToTop: __webpack_require__(932), + CountAllMatching: __webpack_require__(931), + Each: __webpack_require__(930), + EachInRange: __webpack_require__(929), + FindClosestInSorted: __webpack_require__(419), + GetAll: __webpack_require__(928), + GetFirst: __webpack_require__(927), + GetRandom: __webpack_require__(178), + MoveDown: __webpack_require__(926), + MoveTo: __webpack_require__(925), + MoveUp: __webpack_require__(924), + NumberArray: __webpack_require__(923), + NumberArrayStep: __webpack_require__(922), + QuickSelect: __webpack_require__(341), + Range: __webpack_require__(340), + Remove: __webpack_require__(359), + RemoveAt: __webpack_require__(921), + RemoveBetween: __webpack_require__(920), + RemoveRandomElement: __webpack_require__(919), + Replace: __webpack_require__(918), + RotateLeft: __webpack_require__(423), + RotateRight: __webpack_require__(422), + SafeRange: __webpack_require__(68), + SendToBack: __webpack_require__(917), + SetAll: __webpack_require__(916), + Shuffle: __webpack_require__(132), + SpliceOne: __webpack_require__(100), + StableSort: __webpack_require__(120), + Swap: __webpack_require__(915) + +}; + + +/***/ }), +/* 181 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Frame = __webpack_require__(123); +var TextureSource = __webpack_require__(346); + +var TEXTURE_MISSING_ERROR = 'Texture.frame missing: '; + +/** + * @classdesc + * A Texture consists of a source, usually an Image from the Cache, and a collection of Frames. + * The Frames represent the different areas of the Texture. For example a texture atlas + * may have many Frames, one for each element within the atlas. Where-as a single image would have + * just one frame, that encompasses the whole image. + * + * Textures are managed by the global TextureManager. This is a singleton class that is + * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. + * + * Sprites and other Game Objects get the texture data they need from the TextureManager. + * + * @class Texture + * @memberof Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. + * @param {string} key - The unique string-based key of this Texture. + * @param {(HTMLImageElement[]|HTMLCanvasElement[])} source - An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. + * @param {number} [width] - The width of the Texture. This is optional and automatically derived from the source images. + * @param {number} [height] - The height of the Texture. This is optional and automatically derived from the source images. + */ +var Texture = new Class({ + + initialize: + + function Texture (manager, key, source, width, height) + { + if (!Array.isArray(source)) + { + source = [ source ]; + } + + /** + * A reference to the Texture Manager this Texture belongs to. + * + * @name Phaser.Textures.Texture#manager + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The unique string-based key of this Texture. + * + * @name Phaser.Textures.Texture#key + * @type {string} + * @since 3.0.0 + */ + this.key = key; + + /** + * An array of TextureSource instances. + * These are unique to this Texture and contain the actual Image (or Canvas) data. + * + * @name Phaser.Textures.Texture#source + * @type {Phaser.Textures.TextureSource[]} + * @since 3.0.0 + */ + this.source = []; + + /** + * An array of TextureSource data instances. + * Used to store additional data images, such as normal maps or specular maps. + * + * @name Phaser.Textures.Texture#dataSource + * @type {array} + * @since 3.0.0 + */ + this.dataSource = []; + + /** + * A key-value object pair associating the unique Frame keys with the Frames objects. + * + * @name Phaser.Textures.Texture#frames + * @type {object} + * @since 3.0.0 + */ + this.frames = {}; + + /** + * Any additional data that was set in the source JSON (if any), + * or any extra data you'd like to store relating to this texture + * + * @name Phaser.Textures.Texture#customData + * @type {object} + * @since 3.0.0 + */ + this.customData = {}; + + /** + * The name of the first frame of the Texture. + * + * @name Phaser.Textures.Texture#firstFrame + * @type {string} + * @since 3.0.0 + */ + this.firstFrame = '__BASE'; + + /** + * The total number of Frames in this Texture. + * + * @name Phaser.Textures.Texture#frameTotal + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.frameTotal = 0; + + // Load the Sources + for (var i = 0; i < source.length; i++) + { + this.source.push(new TextureSource(this, source[i], width, height)); + } + }, + + /** + * Adds a new Frame to this Texture. + * + * A Frame is a rectangular region of a TextureSource with a unique index or string-based key. + * + * @method Phaser.Textures.Texture#add + * @since 3.0.0 + * + * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. + * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. + * @param {number} x - The x coordinate of the top-left of this Frame. + * @param {number} y - The y coordinate of the top-left of this Frame. + * @param {number} width - The width of this Frame. + * @param {number} height - The height of this Frame. + * + * @return {Phaser.Textures.Frame} The Frame that was added to this Texture. + */ + add: function (name, sourceIndex, x, y, width, height) + { + var frame = new Frame(this, name, sourceIndex, x, y, width, height); + + this.frames[name] = frame; + + // Set the first frame of the Texture (other than __BASE) + // This is used to ensure we don't spam the display with entire + // atlases of sprite sheets, but instead just the first frame of them + // should the dev incorrectly specify the frame index + if (this.frameTotal === 1) + { + this.firstFrame = name; + } + + this.frameTotal++; + + return frame; + }, + + /** + * Checks to see if a Frame matching the given key exists within this Texture. + * + * @method Phaser.Textures.Texture#has + * @since 3.0.0 + * + * @param {string} name - The key of the Frame to check for. + * + * @return {boolean} True if a Frame with the matching key exists in this Texture. + */ + has: function (name) + { + return (this.frames[name]); + }, + + /** + * Gets a Frame from this Texture based on either the key or the index of the Frame. + * + * In a Texture Atlas Frames are typically referenced by a key. + * In a Sprite Sheet Frames are referenced by an index. + * Passing no value for the name returns the base texture. + * + * @method Phaser.Textures.Texture#get + * @since 3.0.0 + * + * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. + * + * @return {Phaser.Textures.Frame} The Texture Frame. + */ + get: function (name) + { + // null, undefined, empty string, zero + if (!name) + { + name = this.firstFrame; + } + + var frame = this.frames[name]; + + if (!frame) + { + console.warn(TEXTURE_MISSING_ERROR + name); + + frame = this.frames[this.firstFrame]; + } + + return frame; + }, + + /** + * Takes the given TextureSource and returns the index of it within this Texture. + * If it's not in this Texture, it returns -1. + * Unless this Texture has multiple TextureSources, such as with a multi-atlas, this + * method will always return zero or -1. + * + * @method Phaser.Textures.Texture#getTextureSourceIndex + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureSource} source - The TextureSource to check. + * + * @return {integer} The index of the TextureSource within this Texture, or -1 if not in this Texture. + */ + getTextureSourceIndex: function (source) + { + for (var i = 0; i < this.source.length; i++) + { + if (this.source[i] === source) + { + return i; + } + } + + return -1; + }, + + /** + * Returns an array of all the Frames in the given TextureSource. + * + * @method Phaser.Textures.Texture#getFramesFromTextureSource + * @since 3.0.0 + * + * @param {integer} sourceIndex - The index of the TextureSource to get the Frames from. + * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? + * + * @return {Phaser.Textures.Frame[]} An array of Texture Frames. + */ + getFramesFromTextureSource: function (sourceIndex, includeBase) + { + if (includeBase === undefined) { includeBase = false; } + + var out = []; + + for (var frameName in this.frames) + { + if (frameName === '__BASE' && !includeBase) + { + continue; + } + + var frame = this.frames[frameName]; + + if (frame.sourceIndex === sourceIndex) + { + out.push(frame); + } + } + + return out; + }, + + /** + * Returns an array with all of the names of the Frames in this Texture. + * + * Useful if you want to randomly assign a Frame to a Game Object, as you can + * pick a random element from the returned array. + * + * @method Phaser.Textures.Texture#getFrameNames + * @since 3.0.0 + * + * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? + * + * @return {string[]} An array of all Frame names in this Texture. + */ + getFrameNames: function (includeBase) + { + if (includeBase === undefined) { includeBase = false; } + + var out = Object.keys(this.frames); + + if (!includeBase) + { + var idx = out.indexOf('__BASE'); + + if (idx !== -1) + { + out.splice(idx, 1); + } + } + + return out; + }, + + /** + * Given a Frame name, return the source image it uses to render with. + * + * This will return the actual DOM Image or Canvas element. + * + * @method Phaser.Textures.Texture#getSourceImage + * @since 3.0.0 + * + * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. + * + * @return {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)} The DOM Image, Canvas Element or Render Texture. + */ + getSourceImage: function (name) + { + if (name === undefined || name === null || this.frameTotal === 1) + { + name = '__BASE'; + } + + var frame = this.frames[name]; + + if (frame) + { + return frame.source.image; + } + else + { + console.warn(TEXTURE_MISSING_ERROR + name); + + return this.frames['__BASE'].source.image; + } + }, + + /** + * Given a Frame name, return the data source image it uses to render with. + * You can use this to get the normal map for an image for example. + * + * This will return the actual DOM Image. + * + * @method Phaser.Textures.Texture#getDataSourceImage + * @since 3.7.0 + * + * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. + * + * @return {(HTMLImageElement|HTMLCanvasElement)} The DOM Image or Canvas Element. + */ + getDataSourceImage: function (name) + { + if (name === undefined || name === null || this.frameTotal === 1) + { + name = '__BASE'; + } + + var frame = this.frames[name]; + var idx; + + if (!frame) + { + console.warn(TEXTURE_MISSING_ERROR + name); + + idx = this.frames['__BASE'].sourceIndex; + } + else + { + idx = frame.sourceIndex; + } + + return this.dataSource[idx].image; + }, + + /** + * Adds a data source image to this Texture. + * + * An example of a data source image would be a normal map, where all of the Frames for this Texture + * equally apply to the normal map. + * + * @method Phaser.Textures.Texture#setDataSource + * @since 3.0.0 + * + * @param {(HTMLImageElement|HTMLCanvasElement)} data - The source image. + */ + setDataSource: function (data) + { + if (!Array.isArray(data)) + { + data = [ data ]; + } + + for (var i = 0; i < data.length; i++) + { + var source = this.source[i]; + + this.dataSource.push(new TextureSource(this, data[i], source.width, source.height)); + } + }, + + /** + * Sets the Filter Mode for this Texture. + * + * The mode can be either Linear, the default, or Nearest. + * + * For pixel-art you should use Nearest. + * + * The mode applies to the entire Texture, not just a specific Frame of it. + * + * @method Phaser.Textures.Texture#setFilter + * @since 3.0.0 + * + * @param {Phaser.Textures.FilterMode} filterMode - The Filter Mode. + */ + setFilter: function (filterMode) + { + var i; + + for (i = 0; i < this.source.length; i++) + { + this.source[i].setFilter(filterMode); + } + + for (i = 0; i < this.dataSource.length; i++) + { + this.dataSource[i].setFilter(filterMode); + } + }, + + /** + * Destroys this Texture and releases references to its sources and frames. + * + * @method Phaser.Textures.Texture#destroy + * @since 3.0.0 + */ + destroy: function () + { + var i; + + for (i = 0; i < this.source.length; i++) + { + this.source[i].destroy(); + } + + for (i = 0; i < this.dataSource.length; i++) + { + this.dataSource[i].destroy(); + } + + for (var frameName in this.frames) + { + var frame = this.frames[frameName]; + + frame.destroy(); + } + + this.source = []; + this.dataSource = []; + this.frames = {}; + this.manager = null; + } + +}); + +module.exports = Texture; + + +/***/ }), +/* 182 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(126); +var DefaultPlugins = __webpack_require__(185); +var GetPhysicsPlugins = __webpack_require__(962); +var GetScenePlugins = __webpack_require__(961); +var NOOP = __webpack_require__(2); +var Settings = __webpack_require__(355); + +/** + * @classdesc + * The Scene Systems class. + * + * This class is available from within a Scene under the property `sys`. + * It is responsible for managing all of the plugins a Scene has running, including the display list, and + * handling the update step and renderer. It also contains references to global systems belonging to Game. + * + * @class Systems + * @memberof Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that owns this Systems instance. + * @param {(string|Phaser.Scenes.Settings.Config)} config - Scene specific configuration settings. + */ +var Systems = new Class({ + + initialize: + + function Systems (scene, config) + { + /** + * A reference to the Scene that these Systems belong to. + * + * @name Phaser.Scenes.Systems#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Phaser Game instance. + * + * @name Phaser.Scenes.Systems#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game; + + if (true) + { + /** + * The Facebook Instant Games Plugin. + * + * @name Phaser.Scenes.Systems#facebook + * @type {any} + * @since 3.12.0 + */ + this.facebook; + } + + /** + * The Scene Configuration object, as passed in when creating the Scene. + * + * @name Phaser.Scenes.Systems#config + * @type {(string|Phaser.Scenes.Settings.Config)} + * @since 3.0.0 + */ + this.config = config; + + /** + * The Scene Settings. This is the parsed output based on the Scene configuration. + * + * @name Phaser.Scenes.Systems#settings + * @type {Phaser.Scenes.Settings.Object} + * @since 3.0.0 + */ + this.settings = Settings.create(config); + + /** + * A handy reference to the Scene canvas / context. + * + * @name Phaser.Scenes.Systems#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas; + + /** + * A reference to the Canvas Rendering Context being used by the renderer. + * + * @name Phaser.Scenes.Systems#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context; + + // Global Systems - these are single-instance global managers that belong to Game + + /** + * A reference to the global Animations Manager. + * + * In the default set-up you can access this from within a Scene via the `this.anims` property. + * + * @name Phaser.Scenes.Systems#anims + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.anims; + + /** + * A reference to the global Cache. The Cache stores all files bought in to Phaser via + * the Loader, with the exception of images. Images are stored in the Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.cache` property. + * + * @name Phaser.Scenes.Systems#cache + * @type {Phaser.Cache.CacheManager} + * @since 3.0.0 + */ + this.cache; + + /** + * A reference to the global Plugins Manager. + * + * In the default set-up you can access this from within a Scene via the `this.plugins` property. + * + * @name Phaser.Scenes.Systems#plugins + * @type {Phaser.Plugins.PluginManager} + * @since 3.0.0 + */ + this.plugins; + + /** + * A reference to the global registry. This is a game-wide instance of the Data Manager, allowing + * you to exchange data between Scenes via a universal and shared point. + * + * In the default set-up you can access this from within a Scene via the `this.registry` property. + * + * @name Phaser.Scenes.Systems#registry + * @type {Phaser.Data.DataManager} + * @since 3.0.0 + */ + this.registry; + + /** + * A reference to the global Sound Manager. + * + * In the default set-up you can access this from within a Scene via the `this.sound` property. + * + * @name Phaser.Scenes.Systems#sound + * @type {Phaser.Sound.BaseSoundManager} + * @since 3.0.0 + */ + this.sound; + + /** + * A reference to the global Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.textures` property. + * + * @name Phaser.Scenes.Systems#textures + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.textures; + + // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems + + /** + * A reference to the Scene's Game Object Factory. + * + * Use this to quickly and easily create new Game Object's. + * + * In the default set-up you can access this from within a Scene via the `this.add` property. + * + * @name Phaser.Scenes.Systems#add + * @type {Phaser.GameObjects.GameObjectFactory} + * @since 3.0.0 + */ + this.add; + + /** + * A reference to the Scene's Camera Manager. + * + * Use this to manipulate and create Cameras for this specific Scene. + * + * In the default set-up you can access this from within a Scene via the `this.cameras` property. + * + * @name Phaser.Scenes.Systems#cameras + * @type {Phaser.Cameras.Scene2D.CameraManager} + * @since 3.0.0 + */ + this.cameras; + + /** + * A reference to the Scene's Display List. + * + * Use this to organize the children contained in the display list. + * + * In the default set-up you can access this from within a Scene via the `this.children` property. + * + * @name Phaser.Scenes.Systems#displayList + * @type {Phaser.GameObjects.DisplayList} + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene's Event Manager. + * + * Use this to listen for Scene specific events, such as `pause` and `shutdown`. + * + * In the default set-up you can access this from within a Scene via the `this.events` property. + * + * @name Phaser.Scenes.Systems#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events; + + /** + * A reference to the Scene's Game Object Creator. + * + * Use this to quickly and easily create new Game Object's. The difference between this and the + * Game Object Factory, is that the Creator just creates and returns Game Object instances, it + * doesn't then add them to the Display List or Update List. + * + * In the default set-up you can access this from within a Scene via the `this.make` property. + * + * @name Phaser.Scenes.Systems#make + * @type {Phaser.GameObjects.GameObjectCreator} + * @since 3.0.0 + */ + this.make; + + /** + * A reference to the Scene Manager Plugin. + * + * Use this to manipulate both this and other Scene's in your game, for example to launch a parallel Scene, + * or pause or resume a Scene, or switch from this Scene to another. + * + * In the default set-up you can access this from within a Scene via the `this.scene` property. + * + * @name Phaser.Scenes.Systems#scenePlugin + * @type {Phaser.Scenes.ScenePlugin} + * @since 3.0.0 + */ + this.scenePlugin; + + /** + * A reference to the Scene's Update List. + * + * Use this to organize the children contained in the update list. + * + * The Update List is responsible for managing children that need their `preUpdate` methods called, + * in order to process so internal components, such as Sprites with Animations. + * + * In the default set-up there is no reference to this from within the Scene itself. + * + * @name Phaser.Scenes.Systems#updateList + * @type {Phaser.GameObjects.UpdateList} + * @since 3.0.0 + */ + this.updateList; + + /** + * The Scene Update function. + * + * This starts out as NOOP during init, preload and create, and at the end of create + * it swaps to be whatever the Scene.update function is. + * + * @name Phaser.Scenes.Systems#sceneUpdate + * @type {function} + * @private + * @since 3.10.0 + */ + this.sceneUpdate = NOOP; + }, + + /** + * 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 instance. + */ + init: function (game) + { + this.settings.status = CONST.INIT; + + // This will get replaced by the SceneManager with the actual update function, if it exists, once create is over. + this.sceneUpdate = NOOP; + + this.game = game; + + this.canvas = game.canvas; + this.context = game.context; + + var pluginManager = game.plugins; + + this.plugins = pluginManager; + + pluginManager.addToScene(this, DefaultPlugins.Global, [ DefaultPlugins.CoreScene, GetScenePlugins(this), GetPhysicsPlugins(this) ]); + + this.events.emit('boot', this); + + this.settings.isBooted = true; + }, + + /** + * Called by a plugin, it tells the System to install the plugin locally. + * + * @method Phaser.Scenes.Systems#install + * @private + * @since 3.0.0 + * + * @param {array} plugin - An array of plugins to install into this Scene. + */ + install: function (plugin) + { + if (!Array.isArray(plugin)) + { + plugin = [ plugin ]; + } + + this.plugins.installLocal(this, plugin); + }, + + /** + * 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 + * + * @param {number} time - The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). + * @param {number} delta - The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. + */ + step: function (time, delta) + { + this.events.emit('preupdate', time, delta); + + this.events.emit('update', time, delta); + + this.sceneUpdate.call(this.scene, time, delta); + + this.events.emit('postupdate', time, delta); + }, + + /** + * 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 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The renderer that invoked the render call. + */ + render: function (renderer) + { + var displayList = this.displayList; + + displayList.depthSort(); + + this.cameras.render(renderer, displayList); + + this.events.emit('render', renderer); + }, + + /** + * Force a sort of the display list on the next render. + * + * @method Phaser.Scenes.Systems#queueDepthSort + * @since 3.0.0 + */ + queueDepthSort: function () + { + this.displayList.queueDepthSort(); + }, + + /** + * Immediately sorts the display list if the flag is set. + * + * @method Phaser.Scenes.Systems#depthSort + * @since 3.0.0 + */ + depthSort: function () + { + this.displayList.depthSort(); + }, + + /** + * Pause this Scene. + * A paused Scene still renders, it just doesn't run ANY of its update handlers or systems. + * + * @method Phaser.Scenes.Systems#pause + * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'pause' event. + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + pause: function (data) + { + if (this.settings.active) + { + this.settings.status = CONST.PAUSED; + + this.settings.active = false; + + this.events.emit('pause', this, data); + } + + return this; + }, + + /** + * Resume this Scene from a paused state. + * + * @method Phaser.Scenes.Systems#resume + * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'resume' event. + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + resume: function (data) + { + if (!this.settings.active) + { + this.settings.status = CONST.RUNNING; + + this.settings.active = true; + + this.events.emit('resume', this, data); + } + + return this; + }, + + /** + * Send this Scene to sleep. + * + * 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 + * + * @param {object} [data] - A data object that will be passed in the 'sleep' event. + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + sleep: function (data) + { + this.settings.status = CONST.SLEEPING; + + this.settings.active = false; + this.settings.visible = false; + + this.events.emit('sleep', this, data); + + return this; + }, + + /** + * Wake-up this Scene if it was previously asleep. + * + * @method Phaser.Scenes.Systems#wake + * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'wake' event. + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + wake: function (data) + { + var settings = this.settings; + + settings.status = CONST.RUNNING; + + settings.active = true; + settings.visible = true; + + this.events.emit('wake', this, data); + + if (settings.isTransition) + { + this.events.emit('transitionwake', settings.transitionFrom, settings.transitionDuration); + } + + return this; + }, + + /** + * Is this Scene sleeping? + * + * @method Phaser.Scenes.Systems#isSleeping + * @since 3.0.0 + * + * @return {boolean} `true` if this Scene is asleep, otherwise `false`. + */ + isSleeping: function () + { + return (this.settings.status === CONST.SLEEPING); + }, + + /** + * Is this Scene active? + * + * @method Phaser.Scenes.Systems#isActive + * @since 3.0.0 + * + * @return {boolean} `true` if this Scene is active, otherwise `false`. + */ + isActive: function () + { + return (this.settings.status === CONST.RUNNING); + }, + + /** + * Is this Scene paused? + * + * @method Phaser.Scenes.Systems#isPaused + * @since 3.13.0 + * + * @return {boolean} `true` if this Scene is paused, otherwise `false`. + */ + isPaused: function () + { + return (this.settings.status === CONST.PAUSED); + }, + + /** + * 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? + * + * @method Phaser.Scenes.Systems#isVisible + * @since 3.0.0 + * + * @return {boolean} `true` if this Scene is visible, otherwise `false`. + */ + isVisible: function () + { + return this.settings.visible; + }, + + /** + * 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 + * + * @param {boolean} value - `true` to render this Scene, otherwise `false`. + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + setVisible: function (value) + { + this.settings.visible = value; + + return this; + }, + + /** + * 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 - If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. + * @param {object} [data] - A data object that will be passed in the 'resume' or 'pause' events. + * + * @return {Phaser.Scenes.Systems} This Systems object. + */ + setActive: function (value, data) + { + if (value) + { + return this.resume(data); + } + else + { + return this.pause(data); + } + }, + + /** + * Start this Scene running and rendering. + * Called automatically by the SceneManager. + * + * @method Phaser.Scenes.Systems#start + * @since 3.0.0 + * + * @param {object} data - Optional data object that may have been passed to this Scene from another. + */ + start: function (data) + { + if (data) + { + this.settings.data = data; + } + + this.settings.status = CONST.START; + + this.settings.active = true; + this.settings.visible = true; + + // For plugins to listen out for + this.events.emit('start', this); + + // For user-land code to listen out for + this.events.emit('ready', this, data); + }, + + /** + * Called automatically by the SceneManager if the Game resizes. + * Dispatches an event you can respond to in your game code. + * + * @method Phaser.Scenes.Systems#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (width, height) + { + this.events.emit('resize', width, height); + }, + + /** + * 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 + * + * @param {object} [data] - A data object that will be passed in the 'shutdown' event. + */ + shutdown: function (data) + { + 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; + this.settings.visible = false; + + this.events.emit('shutdown', this, data); + }, + + /** + * 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 () + { + this.settings.status = CONST.DESTROYED; + + this.settings.active = false; + 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; + } + } + +}); + +module.exports = Systems; + + +/***/ }), +/* 183 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(70); +var GetFastValue = __webpack_require__(1); +var ModelViewProjection = __webpack_require__(966); +var ShaderSourceFS = __webpack_require__(965); +var ShaderSourceVS = __webpack_require__(964); +var TransformMatrix = __webpack_require__(42); +var Utils = __webpack_require__(9); +var WebGLPipeline = __webpack_require__(184); + +/** + * @classdesc + * TextureTintPipeline implements the rendering infrastructure + * for displaying textured objects + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + * + * @class TextureTintPipeline + * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @memberof Phaser.Renderer.WebGL.Pipelines + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var TextureTintPipeline = new Class({ + + Extends: WebGLPipeline, + + Mixins: [ + ModelViewProjection + ], + + initialize: + + function TextureTintPipeline (config) + { + var rendererConfig = config.renderer.config; + + // Vertex Size = attribute size added together (2 + 2 + 1 + 4) + + WebGLPipeline.call(this, { + game: config.game, + renderer: config.renderer, + gl: config.renderer.gl, + topology: GetFastValue(config, 'topology', config.renderer.gl.TRIANGLES), + vertShader: GetFastValue(config, 'vertShader', ShaderSourceVS), + fragShader: GetFastValue(config, 'fragShader', ShaderSourceFS), + vertexCapacity: GetFastValue(config, 'vertexCapacity', 6 * rendererConfig.batchSize), + vertexSize: GetFastValue(config, 'vertexSize', Float32Array.BYTES_PER_ELEMENT * 5 + Uint8Array.BYTES_PER_ELEMENT * 4), + attributes: [ + { + name: 'inPosition', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: 0 + }, + { + name: 'inTexCoord', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: Float32Array.BYTES_PER_ELEMENT * 2 + }, + { + name: 'inTintEffect', + size: 1, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: Float32Array.BYTES_PER_ELEMENT * 4 + }, + { + name: 'inTint', + size: 4, + type: config.renderer.gl.UNSIGNED_BYTE, + normalized: true, + offset: Float32Array.BYTES_PER_ELEMENT * 5 + } + ] + }); + + /** + * Float32 view of the array buffer containing the pipeline's vertices. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewF32 + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertexViewF32 = new Float32Array(this.vertexData); + + /** + * Uint32 view of the array buffer containing the pipeline's vertices. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewU32 + * @type {Uint32Array} + * @since 3.0.0 + */ + this.vertexViewU32 = new Uint32Array(this.vertexData); + + /** + * Size of the batch. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#maxQuads + * @type {integer} + * @since 3.0.0 + */ + this.maxQuads = rendererConfig.batchSize; + + /** + * Collection of batch information + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batches + * @type {array} + * @since 3.1.0 + */ + this.batches = []; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + /** + * Used internally to draw stroked triangles. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tempTriangle + * @type {array} + * @private + * @since 3.12.0 + */ + this.tempTriangle = [ + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 } + ]; + + /** + * The tint effect to be applied by the shader in the next geometry draw: + * + * 0 = texture multiplied by color + * 1 = solid color + texture alpha + * 2 = solid color, no texture + * 3 = solid texture, no color + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tintEffect + * @type {number} + * @private + * @since 3.12.0 + */ + this.tintEffect = 2; + + /** + * Cached stroke tint. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#strokeTint + * @type {object} + * @private + * @since 3.12.0 + */ + this.strokeTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; + + /** + * Cached fill tint. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#fillTint + * @type {object} + * @private + * @since 3.12.0 + */ + this.fillTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; + + /** + * Internal texture frame reference. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#currentFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.12.0 + */ + this.currentFrame = { u0: 0, v0: 0, u1: 1, v1: 1 }; + + /** + * Internal path quad cache. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#firstQuad + * @type {array} + * @private + * @since 3.12.0 + */ + this.firstQuad = [ 0, 0, 0, 0, 0 ]; + + /** + * Internal path quad cache. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#prevQuad + * @type {array} + * @private + * @since 3.12.0 + */ + this.prevQuad = [ 0, 0, 0, 0, 0 ]; + + /** + * Used internally for triangulating a polygon. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#polygonCache + * @type {array} + * @private + * @since 3.12.0 + */ + this.polygonCache = []; + + this.mvpInit(); + }, + + /** + * Called every time the pipeline needs to be used. + * It binds all necessary resources. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#onBind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function () + { + WebGLPipeline.prototype.onBind.call(this); + + this.mvpUpdate(); + + if (this.batches.length === 0) + { + this.pushBatch(); + } + + return this; + }, + + /** + * Resizes this pipeline and updates the projection. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#resize + * @since 3.0.0 + * + * @param {number} width - The new width. + * @param {number} height - The new height. + * @param {number} resolution - The resolution. + * + * @return {this} This WebGLPipeline instance. + */ + resize: function (width, height, resolution) + { + WebGLPipeline.prototype.resize.call(this, width, height, resolution); + + this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); + + return this; + }, + + /** + * Assigns a texture to the current batch. If a texture is already set it creates + * a new batch object. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#setTexture2D + * @since 3.1.0 + * + * @param {WebGLTexture} texture - WebGLTexture that will be assigned to the current batch. + * @param {integer} textureUnit - Texture unit to which the texture needs to be bound. + * + * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This pipeline instance. + */ + setTexture2D: function (texture, unit) + { + if (!texture) + { + texture = this.renderer.blankTexture.glTexture; + unit = 0; + } + + var batches = this.batches; + + if (batches.length === 0) + { + this.pushBatch(); + } + + var batch = batches[batches.length - 1]; + + if (unit > 0) + { + if (batch.textures[unit - 1] && + batch.textures[unit - 1] !== texture) + { + this.pushBatch(); + } + + batches[batches.length - 1].textures[unit - 1] = texture; + } + else + { + if (batch.texture !== null && + batch.texture !== texture) + { + this.pushBatch(); + } + + batches[batches.length - 1].texture = texture; + } + + return this; + }, + + /** + * Creates a new batch object and pushes it to a batch array. + * The batch object contains information relevant to the current + * vertex batch like the offset in the vertex buffer, vertex count and + * the textures used by that batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#pushBatch + * @since 3.1.0 + */ + pushBatch: function () + { + var batch = { + first: this.vertexCount, + texture: null, + textures: [] + }; + + this.batches.push(batch); + }, + + /** + * Uploads the vertex data and emits a draw call for the current batch of vertices. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#flush + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + flush: function () + { + if (this.flushLocked) + { + return this; + } + + this.flushLocked = true; + + var gl = this.gl; + var vertexCount = this.vertexCount; + var topology = this.topology; + var vertexSize = this.vertexSize; + var renderer = this.renderer; + + var batches = this.batches; + var batchCount = batches.length; + var batchVertexCount = 0; + var batch = null; + var batchNext; + var textureIndex; + var nTexture; + + if (batchCount === 0 || vertexCount === 0) + { + this.flushLocked = false; + + return this; + } + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); + + for (var index = 0; index < batches.length - 1; index++) + { + batch = batches[index]; + batchNext = batches[index + 1]; + + if (batch.textures.length > 0) + { + for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) + { + nTexture = batch.textures[textureIndex]; + + if (nTexture) + { + renderer.setTexture2D(nTexture, 1 + textureIndex); + } + } + + gl.activeTexture(gl.TEXTURE0); + } + + batchVertexCount = batchNext.first - batch.first; + + if (batch.texture === null || batchVertexCount <= 0) + { + continue; + } + + renderer.setTexture2D(batch.texture, 0); + + gl.drawArrays(topology, batch.first, batchVertexCount); + } + + // Left over data + batch = batches[batches.length - 1]; + + if (batch.textures.length > 0) + { + for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) + { + nTexture = batch.textures[textureIndex]; + + if (nTexture) + { + renderer.setTexture2D(nTexture, 1 + textureIndex); + } + } + + gl.activeTexture(gl.TEXTURE0); + } + + batchVertexCount = vertexCount - batch.first; + + if (batch.texture && batchVertexCount > 0) + { + renderer.setTexture2D(batch.texture, 0); + + gl.drawArrays(topology, batch.first, batchVertexCount); + } + + this.vertexCount = 0; + + batches.length = 0; + + this.pushBatch(); + + this.flushLocked = false; + + return this; + }, + + /** + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchSprite + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.Image|Phaser.GameObjects.Sprite)} sprite - The texture based Game Object to add to the batch. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the rendering transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - The transform matrix of the parent container, if set. + */ + batchSprite: function (sprite, camera, parentTransformMatrix) + { + this.renderer.setPipeline(this); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var frame = sprite.frame; + var texture = frame.glTexture; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + var frameX = frame.x; + var frameY = frame.y; + var frameWidth = frame.cutWidth; + var frameHeight = frame.cutHeight; + + var x = -sprite.displayOriginX + frameX; + var y = -sprite.displayOriginY + frameY; + + if (sprite.isCropped) + { + var crop = sprite._crop; + + if (crop.flipX !== sprite.flipX || crop.flipY !== sprite.flipY) + { + frame.updateCropUVs(crop, sprite.flipX, sprite.flipY); + } + + u0 = crop.u0; + v0 = crop.v0; + u1 = crop.u1; + v1 = crop.v1; + + frameWidth = crop.width; + frameHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + x = -sprite.displayOriginX + frameX; + y = -sprite.displayOriginY + frameY; + } + + if (sprite.flipX) + { + x += frameWidth; + frameWidth *= -1; + } + + if (sprite.flipY) + { + y += frameHeight; + frameHeight *= -1; + } + + var xw = x + frameWidth; + var yh = y + frameHeight; + + spriteMatrix.applyITRS(sprite.x, sprite.y, sprite.rotation, sprite.scaleX, sprite.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * sprite.scrollFactorX, -camera.scrollY * sprite.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = sprite.x; + spriteMatrix.f = sprite.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * sprite.scrollFactorX; + spriteMatrix.f -= camera.scrollY * sprite.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + var tintTL = Utils.getTintAppendFloatAlpha(sprite._tintTL, camera.alpha * sprite._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(sprite._tintTR, camera.alpha * sprite._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(sprite._tintBL, camera.alpha * sprite._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(sprite._tintBR, camera.alpha * sprite._alphaBR); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + this.setTexture2D(texture, 0); + + var tintEffect = (sprite._isTinted && sprite.tintFill); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + }, + + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 6 vertices in the following arrangement: + * + * ``` + * 0----3 + * |\ B| + * | \ | + * | \ | + * | A \| + * | \ + * 1----2 + * ``` + * + * Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3 + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchQuad + * @since 3.12.0 + * + * @param {number} x0 - The top-left x position. + * @param {number} y0 - The top-left y position. + * @param {number} x1 - The bottom-left x position. + * @param {number} y1 - The bottom-left y position. + * @param {number} x2 - The bottom-right x position. + * @param {number} y2 - The bottom-right y position. + * @param {number} x3 - The top-right x position. + * @param {number} y3 - The top-right y position. + * @param {number} u0 - UV u0 value. + * @param {number} v0 - UV v0 value. + * @param {number} u1 - UV u1 value. + * @param {number} v1 - UV v1 value. + * @param {number} tintTL - The top-left tint color value. + * @param {number} tintTR - The top-right tint color value. + * @param {number} tintBL - The bottom-left tint color value. + * @param {number} tintBR - The bottom-right tint color value. + * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. + * + * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. + */ + batchQuad: function (x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect) + { + var hasFlushed = false; + + if (this.vertexCount + 6 > this.vertexCapacity) + { + this.flush(); + + hasFlushed = true; + } + + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + + var vertexOffset = (this.vertexCount * this.vertexComponentCount) - 1; + + vertexViewF32[++vertexOffset] = x0; + vertexViewF32[++vertexOffset] = y0; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x1; + vertexViewF32[++vertexOffset] = y1; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBR; + + vertexViewF32[++vertexOffset] = x0; + vertexViewF32[++vertexOffset] = y0; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBR; + + vertexViewF32[++vertexOffset] = x3; + vertexViewF32[++vertexOffset] = y3; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTR; + + this.vertexCount += 6; + + return hasFlushed; + }, + + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 3 vertices in the following arrangement: + * + * ``` + * 0 + * |\ + * | \ + * | \ + * | \ + * | \ + * 1-----2 + * ``` + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTri + * @since 3.12.0 + * + * @param {number} x1 - The bottom-left x position. + * @param {number} y1 - The bottom-left y position. + * @param {number} x2 - The bottom-right x position. + * @param {number} y2 - The bottom-right y position. + * @param {number} x3 - The top-right x position. + * @param {number} y3 - The top-right y position. + * @param {number} u0 - UV u0 value. + * @param {number} v0 - UV v0 value. + * @param {number} u1 - UV u1 value. + * @param {number} v1 - UV v1 value. + * @param {number} tintTL - The top-left tint color value. + * @param {number} tintTR - The top-right tint color value. + * @param {number} tintBL - The bottom-left tint color value. + * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. + * + * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. + */ + batchTri: function (x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect) + { + var hasFlushed = false; + + if (this.vertexCount + 3 > this.vertexCapacity) + { + this.flush(); + + hasFlushed = true; + } + + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + + var vertexOffset = (this.vertexCount * this.vertexComponentCount) - 1; + + vertexViewF32[++vertexOffset] = x1; + vertexViewF32[++vertexOffset] = y1; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTR; + + vertexViewF32[++vertexOffset] = x3; + vertexViewF32[++vertexOffset] = y3; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBL; + + this.vertexCount += 3; + + return hasFlushed; + }, + + /** + * Generic function for batching a textured quad using argument values instead of a Game Object. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject. + * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad. + * @param {integer} textureWidth - Real texture width. + * @param {integer} textureHeight - Real texture height. + * @param {number} srcX - X coordinate of the quad. + * @param {number} srcY - Y coordinate of the quad. + * @param {number} srcWidth - Width of the quad. + * @param {number} srcHeight - Height of the quad. + * @param {number} scaleX - X component of scale. + * @param {number} scaleY - Y component of scale. + * @param {number} rotation - Rotation of the quad. + * @param {boolean} flipX - Indicates if the quad is horizontally flipped. + * @param {boolean} flipY - Indicates if the quad is vertically flipped. + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll. + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll. + * @param {number} displayOriginX - Horizontal origin in pixels. + * @param {number} displayOriginY - Vertical origin in pixels. + * @param {number} frameX - X coordinate of the texture frame. + * @param {number} frameY - Y coordinate of the texture frame. + * @param {number} frameWidth - Width of the texture frame. + * @param {number} frameHeight - Height of the texture frame. + * @param {integer} tintTL - Tint for top left. + * @param {integer} tintTR - Tint for top right. + * @param {integer} tintBL - Tint for bottom left. + * @param {integer} tintBR - Tint for bottom right. + * @param {number} tintEffect - The tint effect. + * @param {number} uOffset - Horizontal offset on texture coordinate. + * @param {number} vOffset - Vertical offset on texture coordinate. + * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container. + * @param {boolean} [skipFlip=false] - Skip the renderTexture check. + */ + batchTexture: function ( + gameObject, + texture, + textureWidth, textureHeight, + srcX, srcY, + srcWidth, srcHeight, + scaleX, scaleY, + rotation, + flipX, flipY, + scrollFactorX, scrollFactorY, + displayOriginX, displayOriginY, + frameX, frameY, frameWidth, frameHeight, + tintTL, tintTR, tintBL, tintBR, tintEffect, + uOffset, vOffset, + camera, + parentTransformMatrix, + skipFlip) + { + this.renderer.setPipeline(this, gameObject); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var u0 = (frameX / textureWidth) + uOffset; + var v0 = (frameY / textureHeight) + vOffset; + var u1 = (frameX + frameWidth) / textureWidth + uOffset; + var v1 = (frameY + frameHeight) / textureHeight + vOffset; + + var width = srcWidth; + var height = srcHeight; + + var x = -displayOriginX; + var y = -displayOriginY; + + if (gameObject.isCropped) + { + var crop = gameObject._crop; + + width = crop.width; + height = crop.height; + + srcWidth = crop.width; + srcHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + var ox = frameX; + var oy = frameY; + + if (flipX) + { + ox = (frameWidth - crop.x - crop.width); + } + + if (flipY && !texture.isRenderTexture) + { + oy = (frameHeight - crop.y - crop.height); + } + + u0 = (ox / textureWidth) + uOffset; + v0 = (oy / textureHeight) + vOffset; + u1 = (ox + crop.width) / textureWidth + uOffset; + v1 = (oy + crop.height) / textureHeight + vOffset; + + x = -displayOriginX + frameX; + y = -displayOriginY + frameY; + } + + // Invert the flipY if this is a RenderTexture + flipY = flipY ^ (!skipFlip && texture.isRenderTexture ? 1 : 0); + + if (flipX) + { + width *= -1; + x += srcWidth; + } + + if (flipY) + { + height *= -1; + y += srcHeight; + } + + var xw = x + width; + var yh = y + height; + + spriteMatrix.applyITRS(srcX, srcY, rotation, scaleX, scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * scrollFactorX, -camera.scrollY * scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = srcX; + spriteMatrix.f = srcY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * scrollFactorX; + spriteMatrix.f -= camera.scrollY * scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + this.setTexture2D(texture, 0); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + }, + + /** + * Adds a Texture Frame into the batch for rendering. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTextureFrame + * @since 3.12.0 + * + * @param {Phaser.Textures.Frame} frame - The Texture Frame to be rendered. + * @param {number} x - The horizontal position to render the texture at. + * @param {number} y - The vertical position to render the texture at. + * @param {number} tint - The tint color. + * @param {number} alpha - The alpha value. + * @param {Phaser.GameObjects.Components.TransformMatrix} transformMatrix - The Transform Matrix to use for the texture. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - A parent Transform Matrix. + */ + batchTextureFrame: function ( + frame, + x, y, + tint, alpha, + transformMatrix, + parentTransformMatrix + ) + { + this.renderer.setPipeline(this); + + var spriteMatrix = this._tempMatrix1.copyFrom(transformMatrix); + var calcMatrix = this._tempMatrix2; + + var xw = x + frame.width; + var yh = y + frame.height; + + if (parentTransformMatrix) + { + spriteMatrix.multiply(parentTransformMatrix, calcMatrix); + } + else + { + calcMatrix = spriteMatrix; + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + this.setTexture2D(frame.glTexture, 0); + + tint = Utils.getTintAppendFloatAlpha(tint, alpha); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, 0); + }, + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle has no transform values and isn't transformed into the local space. + * Used for directly batching untransformed rectangles, such as Camera background colors. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawFillRect + * @since 3.12.0 + * + * @param {number} x - Horizontal top left coordinate of the rectangle. + * @param {number} y - Vertical top left coordinate of the rectangle. + * @param {number} width - Width of the rectangle. + * @param {number} height - Height of the rectangle. + * @param {number} color - Color of the rectangle to draw. + * @param {number} alpha - Alpha value of the rectangle to draw. + */ + drawFillRect: function (x, y, width, height, color, alpha) + { + var xw = x + width; + var yh = y + height; + + var tint = Utils.getTintAppendFloatAlphaAndSwap(color, alpha); + + this.batchQuad(x, y, x, yh, xw, yh, xw, y, 0, 0, 1, 1, tint, tint, tint, tint, 2); + }, + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle factors in the given transform matrices before adding to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillRect + * @since 3.12.0 + * + * @param {number} x - Horizontal top left coordinate of the rectangle. + * @param {number} y - Vertical top left coordinate of the rectangle. + * @param {number} width - Width of the rectangle. + * @param {number} height - Height of the rectangle. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillRect: function (x, y, width, height, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var xw = x + width; + var yh = y + height; + + var x0 = calcMatrix.getX(x, y); + var y0 = calcMatrix.getY(x, y); + + var x1 = calcMatrix.getX(x, yh); + var y1 = calcMatrix.getY(x, yh); + + var x2 = calcMatrix.getX(xw, yh); + var y2 = calcMatrix.getY(xw, yh); + + var x3 = calcMatrix.getX(xw, y); + var y3 = calcMatrix.getY(xw, y); + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.fillTint.BR, this.tintEffect); + }, + + /** + * Pushes a filled triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillTriangle + * @since 3.12.0 + * + * @param {number} x0 - Point 0 x coordinate. + * @param {number} y0 - Point 0 y coordinate. + * @param {number} x1 - Point 1 x coordinate. + * @param {number} y1 - Point 1 y coordinate. + * @param {number} x2 - Point 2 x coordinate. + * @param {number} y2 - Point 2 y coordinate. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillTriangle: function (x0, y0, x1, y1, x2, y2, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.tintEffect); + }, + + /** + * Pushes a stroked triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * The triangle is created from 3 lines and drawn using the `batchStrokePath` method. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokeTriangle + * @since 3.12.0 + * + * @param {number} x0 - Point 0 x coordinate. + * @param {number} y0 - Point 0 y coordinate. + * @param {number} x1 - Point 1 x coordinate. + * @param {number} y1 - Point 1 y coordinate. + * @param {number} x2 - Point 2 x coordinate. + * @param {number} y2 - Point 2 y coordinate. + * @param {number} lineWidth - The width of the line in pixels. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchStrokeTriangle: function (x0, y0, x1, y1, x2, y2, lineWidth, currentMatrix, parentMatrix) + { + var tempTriangle = this.tempTriangle; + + tempTriangle[0].x = x0; + tempTriangle[0].y = y0; + tempTriangle[0].width = lineWidth; + + tempTriangle[1].x = x1; + tempTriangle[1].y = y1; + tempTriangle[1].width = lineWidth; + + tempTriangle[2].x = x2; + tempTriangle[2].y = y2; + tempTriangle[2].width = lineWidth; + + tempTriangle[3].x = x0; + tempTriangle[3].y = y0; + tempTriangle[3].width = lineWidth; + + this.batchStrokePath(tempTriangle, lineWidth, false, currentMatrix, parentMatrix); + }, + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and then passing it through Earcut, which + * creates a list of polygons. Each polygon is then added to the batch. + * + * The path is always automatically closed because it's filled. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillPath + * @since 3.12.0 + * + * @param {array} path - Collection of points that represent the path. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillPath: function (path, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var length = path.length; + var polygonCache = this.polygonCache; + var polygonIndexArray; + var point; + + var tintTL = this.fillTint.TL; + var tintTR = this.fillTint.TR; + var tintBL = this.fillTint.BL; + var tintEffect = this.tintEffect; + + for (var pathIndex = 0; pathIndex < length; ++pathIndex) + { + point = path[pathIndex]; + polygonCache.push(point.x, point.y); + } + + polygonIndexArray = Earcut(polygonCache); + length = polygonIndexArray.length; + + var frame = this.currentFrame; + + for (var index = 0; index < length; index += 3) + { + var p0 = polygonIndexArray[index + 0] * 2; + var p1 = polygonIndexArray[index + 1] * 2; + var p2 = polygonIndexArray[index + 2] * 2; + + var x0 = polygonCache[p0 + 0]; + var y0 = polygonCache[p0 + 1]; + var x1 = polygonCache[p1 + 0]; + var y1 = polygonCache[p1 + 1]; + var x2 = polygonCache[p2 + 0]; + var y2 = polygonCache[p2 + 1]; + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect); + } + + polygonCache.length = 0; + }, + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and calling `batchLine` for each section + * of the path. + * + * The path is optionally closed at the end. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokePath + * @since 3.12.0 + * + * @param {array} path - Collection of points that represent the path. + * @param {number} lineWidth - The width of the line segments in pixels. + * @param {boolean} pathOpen - Indicates if the path should be closed or left open. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchStrokePath: function (path, lineWidth, pathOpen, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + // Reset the closePath booleans + this.prevQuad[4] = 0; + this.firstQuad[4] = 0; + + var pathLength = path.length - 1; + + for (var pathIndex = 0; pathIndex < pathLength; pathIndex++) + { + var point0 = path[pathIndex]; + var point1 = path[pathIndex + 1]; + + this.batchLine( + point0.x, + point0.y, + point1.x, + point1.y, + point0.width / 2, + point1.width / 2, + lineWidth, + pathIndex, + !pathOpen && (pathIndex === pathLength - 1), + currentMatrix, + parentMatrix + ); + } + }, + + /** + * Creates a quad and adds it to the vertex batch based on the given line values. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchLine + * @since 3.12.0 + * + * @param {number} ax - X coordinate to the start of the line + * @param {number} ay - Y coordinate to the start of the line + * @param {number} bx - X coordinate to the end of the line + * @param {number} by - Y coordinate to the end of the line + * @param {number} aLineWidth - Width of the start of the line + * @param {number} bLineWidth - Width of the end of the line + * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers + */ + batchLine: function (ax, ay, bx, by, aLineWidth, bLineWidth, lineWidth, index, closePath, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var dx = bx - ax; + var dy = by - ay; + + var len = Math.sqrt(dx * dx + dy * dy); + var al0 = aLineWidth * (by - ay) / len; + var al1 = aLineWidth * (ax - bx) / len; + var bl0 = bLineWidth * (by - ay) / len; + var bl1 = bLineWidth * (ax - bx) / len; + + var lx0 = bx - bl0; + var ly0 = by - bl1; + var lx1 = ax - al0; + var ly1 = ay - al1; + var lx2 = bx + bl0; + var ly2 = by + bl1; + var lx3 = ax + al0; + var ly3 = ay + al1; + + // tx0 = bottom right + var brX = calcMatrix.getX(lx0, ly0); + var brY = calcMatrix.getY(lx0, ly0); + + // tx1 = bottom left + var blX = calcMatrix.getX(lx1, ly1); + var blY = calcMatrix.getY(lx1, ly1); + + // tx2 = top right + var trX = calcMatrix.getX(lx2, ly2); + var trY = calcMatrix.getY(lx2, ly2); + + // tx3 = top left + var tlX = calcMatrix.getX(lx3, ly3); + var tlY = calcMatrix.getY(lx3, ly3); + + var tint = this.strokeTint; + var tintEffect = this.tintEffect; + + var tintTL = tint.TL; + var tintTR = tint.TR; + var tintBL = tint.BL; + var tintBR = tint.BR; + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + // TL, BL, BR, TR + this.batchQuad(tlX, tlY, blX, blY, brX, brY, trX, trY, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + + if (lineWidth <= 2) + { + // No point doing a linejoin if the line isn't thick enough + return; + } + + var prev = this.prevQuad; + var first = this.firstQuad; + + if (index > 0 && prev[4]) + { + this.batchQuad(tlX, tlY, blX, blY, prev[0], prev[1], prev[2], prev[3], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + else + { + first[0] = tlX; + first[1] = tlY; + first[2] = blX; + first[3] = blY; + first[4] = 1; + } + + if (closePath && first[4]) + { + // Add a join for the final path segment + this.batchQuad(brX, brY, trX, trY, first[0], first[1], first[2], first[3], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + else + { + // Store it + + prev[0] = brX; + prev[1] = brY; + prev[2] = trX; + prev[3] = trY; + prev[4] = 1; + } + } + +}); + +module.exports = TextureTintPipeline; + + +/***/ }), +/* 184 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(9); + +/** + * @classdesc + * WebGLPipeline is a class that describes the way elements will be rendererd + * in WebGL, specially focused on batching vertices (batching is not provided). + * Pipelines are mostly used for describing 2D rendering passes but it's + * flexible enough to be used for any type of rendering including 3D. + * Internally WebGLPipeline will handle things like compiling shaders, + * creating vertex buffers, assigning primitive topology and binding + * vertex attributes. + * + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - gl: Current WebGL context. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + * - vertices: An optional buffer of vertices + * - attributes: An array describing the vertex attributes + * + * The vertex attributes properties are: + * - name : String - Name of the attribute in the vertex shader + * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 + * - type : GLenum - WebGL type (gl.BYTE, gl.SHORT, gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.FLOAT) + * - normalized : boolean - Is the attribute normalized + * - offset : integer - The offset in bytes to the current attribute in the vertex. Equivalent to offsetof(vertex, attrib) in C + * Here you can find more information of how to describe an attribute: + * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer + * + * @class WebGLPipeline + * @memberof Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var WebGLPipeline = new Class({ + + initialize: + + function WebGLPipeline (config) + { + /** + * Name of the Pipeline. Used for identifying + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'WebGLPipeline'; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = config.game; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#view + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.view = config.game.canvas; + + /** + * Used to store the current game resolution + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#resolution + * @type {number} + * @since 3.0.0 + */ + this.resolution = config.game.config.resolution; + + /** + * Width of the current viewport + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#width + * @type {number} + * @since 3.0.0 + */ + this.width = config.game.config.width * this.resolution; + + /** + * Height of the current viewport + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#height + * @type {number} + * @since 3.0.0 + */ + this.height = config.game.config.height * this.resolution; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#gl + * @type {WebGLRenderingContext} + * @since 3.0.0 + */ + this.gl = config.gl; + + /** + * How many vertices have been fed to the current pipeline. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.vertexCount = 0; + + /** + * The limit of vertices that the pipeline can hold + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity + * @type {integer} + * @since 3.0.0 + */ + this.vertexCapacity = config.vertexCapacity; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#renderer + * @type {Phaser.Renderer.WebGL.WebGLRenderer} + * @since 3.0.0 + */ + this.renderer = config.renderer; + + /** + * Raw byte buffer of vertices. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexData + * @type {ArrayBuffer} + * @since 3.0.0 + */ + this.vertexData = (config.vertices ? config.vertices : new ArrayBuffer(config.vertexCapacity * config.vertexSize)); + + /** + * The handle to a WebGL vertex buffer object. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer + * @type {WebGLBuffer} + * @since 3.0.0 + */ + this.vertexBuffer = this.renderer.createVertexBuffer((config.vertices ? config.vertices : this.vertexData.byteLength), this.gl.STREAM_DRAW); + + /** + * The handle to a WebGL program + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#program + * @type {WebGLProgram} + * @since 3.0.0 + */ + this.program = this.renderer.createProgram(config.vertShader, config.fragShader); + + /** + * Array of objects that describe the vertex attributes + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#attributes + * @type {object} + * @since 3.0.0 + */ + this.attributes = config.attributes; + + /** + * The size in bytes of the vertex + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexSize + * @type {integer} + * @since 3.0.0 + */ + this.vertexSize = config.vertexSize; + + /** + * The primitive topology which the pipeline will use to submit draw calls + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#topology + * @type {integer} + * @since 3.0.0 + */ + this.topology = config.topology; + + /** + * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources + * to the GPU. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#bytes + * @type {Uint8Array} + * @since 3.0.0 + */ + this.bytes = new Uint8Array(this.vertexData); + + /** + * This will store the amount of components of 32 bit length + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexComponentCount + * @type {integer} + * @since 3.0.0 + */ + this.vertexComponentCount = Utils.getComponentCount(config.attributes, this.gl); + + /** + * Indicates if the current pipeline is flushing the contents to the GPU. + * When the variable is set the flush function will be locked. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#flushLocked + * @type {boolean} + * @since 3.1.0 + */ + this.flushLocked = false; + + /** + * Indicates if the current pipeline is active or not for this frame only. + * Reset in the onRender method. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#active + * @type {boolean} + * @since 3.10.0 + */ + this.active = false; + }, + + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#boot + * @since 3.11.0 + */ + boot: function () + { + }, + + /** + * Adds a description of vertex attribute to the pipeline + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#addAttribute + * @since 3.2.0 + * + * @param {string} name - Name of the vertex attribute + * @param {integer} size - Vertex component size + * @param {integer} type - Type of the attribute + * @param {boolean} normalized - Is the value normalized to a range + * @param {integer} offset - Byte offset to the beginning of the first element in the vertex + * + * @return {this} This WebGLPipeline instance. + */ + addAttribute: function (name, size, type, normalized, offset) + { + this.attributes.push({ + name: name, + size: size, + type: this.renderer.glFormats[type], + normalized: normalized, + offset: offset + }); + + return this; + }, + + /** + * Check if the current batch of vertices is full. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush + * @since 3.0.0 + * + * @return {boolean} [description] + */ + shouldFlush: function () + { + return (this.vertexCount >= this.vertexCapacity); + }, + + /** + * Resizes the properties used to describe the viewport + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} resolution - [description] + * + * @return {this} This WebGLPipeline instance. + */ + resize: function (width, height, resolution) + { + this.width = width * resolution; + this.height = height * resolution; + + return this; + }, + + /** + * Binds the pipeline resources, including programs, vertex buffers and binds attributes + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#bind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + bind: function () + { + var gl = this.gl; + var vertexBuffer = this.vertexBuffer; + var attributes = this.attributes; + var program = this.program; + var renderer = this.renderer; + var vertexSize = this.vertexSize; + + renderer.setProgram(program); + renderer.setVertexBuffer(vertexBuffer); + + for (var index = 0; index < attributes.length; ++index) + { + var element = attributes[index]; + var location = gl.getAttribLocation(program, element.name); + + if (location >= 0) + { + gl.enableVertexAttribArray(location); + gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexSize, element.offset); + } + else + { + gl.disableVertexAttribArray(location); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onBind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function () + { + // This is for updating uniform data it's called on each bind attempt. + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onPreRender + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onPreRender: function () + { + // called once every frame + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onRender + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {this} This WebGLPipeline instance. + */ + onRender: function () + { + // called for each camera + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onPostRender + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onPostRender: function () + { + // called once every frame + return this; + }, + + /** + * Uploads the vertex data and emits a draw call + * for the current batch of vertices. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#flush + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + flush: function () + { + if (this.flushLocked) { return this; } + + this.flushLocked = true; + + var gl = this.gl; + var vertexCount = this.vertexCount; + var topology = this.topology; + var vertexSize = this.vertexSize; + + if (vertexCount === 0) + { + this.flushLocked = false; + return; + } + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); + gl.drawArrays(topology, 0, vertexCount); + + this.vertexCount = 0; + this.flushLocked = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#destroy + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + destroy: function () + { + var gl = this.gl; + + gl.deleteProgram(this.program); + gl.deleteBuffer(this.vertexBuffer); + + delete this.program; + delete this.vertexBuffer; + delete this.gl; + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setFloat1: function (name, x) + { + this.renderer.setFloat1(this.program, name, x); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setFloat2: function (name, x, y) + { + this.renderer.setFloat2(this.program, name, x, y); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setFloat3: function (name, x, y, z) + { + this.renderer.setFloat3(this.program, name, x, y, z); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - X component of the uniform + * @param {number} y - Y component of the uniform + * @param {number} z - Z component of the uniform + * @param {number} w - W component of the uniform + * + * @return {this} This WebGLPipeline instance. + */ + setFloat4: function (name, x, y, z, w) + { + this.renderer.setFloat4(this.program, name, x, y, z, w); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat1v: function (name, arr) + { + this.renderer.setFloat1v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat2v: function (name, arr) + { + this.renderer.setFloat2v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat3v: function (name, arr) + { + this.renderer.setFloat3v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat4v: function (name, arr) + { + this.renderer.setFloat4v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt1 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setInt1: function (name, x) + { + this.renderer.setInt1(this.program, name, x); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt2 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setInt2: function (name, x, y) + { + this.renderer.setInt2(this.program, name, x, y); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt3 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setInt3: function (name, x, y, z) + { + this.renderer.setInt3(this.program, name, x, y, z); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt4 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - X component of the uniform + * @param {integer} y - Y component of the uniform + * @param {integer} z - Z component of the uniform + * @param {integer} w - W component of the uniform + * + * @return {this} This WebGLPipeline instance. + */ + setInt4: function (name, x, y, z, w) + { + this.renderer.setInt4(this.program, name, x, y, z, w); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setMatrix2: function (name, transpose, matrix) + { + this.renderer.setMatrix2(this.program, name, transpose, matrix); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setMatrix3: function (name, transpose, matrix) + { + this.renderer.setMatrix3(this.program, name, transpose, matrix); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - Should the matrix be transpose + * @param {Float32Array} matrix - Matrix data + * + * @return {this} This WebGLPipeline instance. + */ + setMatrix4: function (name, transpose, matrix) + { + this.renderer.setMatrix4(this.program, name, transpose, matrix); + + return this; + } + +}); + +module.exports = WebGLPipeline; + + +/***/ }), +/* 185 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} Phaser.Plugins.DefaultPlugins + * + * @property {array} Global - These are the Global Managers that are created by the Phaser.Game instance. + * @property {array} CoreScene - These are the core plugins that are installed into every Scene.Systems instance, no matter what. + * @property {array} DefaultScene - These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + */ + +var DefaultPlugins = { + + /** + * These are the Global Managers that are created by the Phaser.Game instance. + * They are referenced from Scene.Systems so that plugins can use them. + * + * @name Phaser.Plugins.Global + * @type {array} + * @since 3.0.0 + */ + Global: [ + + 'game', + 'anims', + 'cache', + 'plugins', + 'registry', + 'scale', + 'sound', + 'textures' + + ], + + /** + * These are the core plugins that are installed into every Scene.Systems instance, no matter what. + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are created in the order in which they appear in this array and EventEmitter is always first. + * + * @name Phaser.Plugins.CoreScene + * @type {array} + * @since 3.0.0 + */ + CoreScene: [ + + 'EventEmitter', + + 'CameraManager', + 'GameObjectCreator', + 'GameObjectFactory', + 'ScenePlugin', + 'DisplayList', + 'UpdateList' + + ], + + /** + * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + * + * You can elect not to have these plugins by either creating a DefaultPlugins object as part + * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array + * and building your own bundle. + * + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are always created in the order in which they appear in the array. + * + * @name Phaser.Plugins.DefaultScene + * @type {array} + * @since 3.0.0 + */ + DefaultScene: [ + + 'Clock', + 'DataManagerPlugin', + 'InputPlugin', + 'Loader', + 'TweenManager', + 'LightsPlugin' + + ] + +}; + +if (false) +{} + +if (true) +{ + DefaultPlugins.Global.push('facebook'); +} + +module.exports = DefaultPlugins; + + +/***/ }), +/* 186 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(101); +var Browser = __webpack_require__(128); +var CanvasPool = __webpack_require__(26); + +/** + * Determines the features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.features` from within any Scene. + * + * @typedef {object} Phaser.Device.Features + * @since 3.0.0 + * + * @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap. + * @property {boolean} canvas - Is canvas available? + * @property {boolean} file - Is file available? + * @property {boolean} fileSystem - Is fileSystem available? + * @property {boolean} getUserMedia - Does the device support the getUserMedia API? + * @property {boolean} littleEndian - Is the device big or little endian? (only detected if the browser supports TypedArrays) + * @property {boolean} localStorage - Is localStorage available? + * @property {boolean} pointerLock - Is Pointer Lock available? + * @property {boolean} support32bit - Does the device context support 32bit pixel manipulation using array buffer views? + * @property {boolean} vibration - Does the device support the Vibration API? + * @property {boolean} webGL - Is webGL available? + * @property {boolean} worker - Is worker available? + */ +var Features = { + + canvas: false, + canvasBitBltShift: null, + file: false, + fileSystem: false, + getUserMedia: true, + littleEndian: false, + localStorage: false, + pointerLock: false, + support32bit: false, + vibration: false, + webGL: false, + worker: false + +}; + +// Check Little or Big Endian system. +// @author Matt DesLauriers (@mattdesl) +function checkIsLittleEndian () +{ + var a = new ArrayBuffer(4); + var b = new Uint8Array(a); + var c = new Uint32Array(a); + + b[0] = 0xa1; + b[1] = 0xb2; + b[2] = 0xc3; + b[3] = 0xd4; + + if (c[0] === 0xd4c3b2a1) + { + return true; + } + + if (c[0] === 0xa1b2c3d4) + { + return false; + } + else + { + // Could not determine endianness + return null; + } +} + +function init () +{ + Features.canvas = !!window['CanvasRenderingContext2D'] || OS.cocoonJS; + + try + { + Features.localStorage = !!localStorage.getItem; + } + catch (error) + { + Features.localStorage = false; + } + + Features.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; + Features.fileSystem = !!window['requestFileSystem']; + + var isUint8 = false; + + var testWebGL = function () + { + if (window['WebGLRenderingContext']) + { + try + { + var canvas = CanvasPool.createWebGL(this); + + if (OS.cocoonJS) + { + canvas.screencanvas = false; + } + + var ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); + + var canvas2D = CanvasPool.create2D(this); + + var ctx2D = canvas2D.getContext('2d'); + + // Can't be done on a webgl context + var image = ctx2D.createImageData(1, 1); + + // Test to see if ImageData uses CanvasPixelArray or Uint8ClampedArray. + // @author Matt DesLauriers (@mattdesl) + isUint8 = image.data instanceof Uint8ClampedArray; + + CanvasPool.remove(canvas); + CanvasPool.remove(canvas2D); + + return !!ctx; + } + catch (e) + { + return false; + } + } + + return false; + }; + + Features.webGL = testWebGL(); + + Features.worker = !!window['Worker']; + + Features.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; + + navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia; + + window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; + + Features.getUserMedia = Features.getUserMedia && !!navigator.getUserMedia && !!window.URL; + + // Older versions of firefox (< 21) apparently claim support but user media does not actually work + if (Browser.firefox && Browser.firefoxVersion < 21) + { + Features.getUserMedia = false; + } + + // Excludes iOS versions as they generally wrap UIWebView (eg. Safari WebKit) and it + // is safer to not try and use the fast copy-over method. + if (!OS.iOS && (Browser.ie || Browser.firefox || Browser.chrome)) + { + Features.canvasBitBltShift = true; + } + + // Known not to work + if (Browser.safari || Browser.mobileSafari) + { + Features.canvasBitBltShift = false; + } + + navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate; + + if (navigator.vibrate) + { + Features.vibration = true; + } + + if (typeof ArrayBuffer !== 'undefined' && typeof Uint8Array !== 'undefined' && typeof Uint32Array !== 'undefined') + { + Features.littleEndian = checkIsLittleEndian(); + } + + Features.support32bit = ( + typeof ArrayBuffer !== 'undefined' && + typeof Uint8ClampedArray !== 'undefined' && + typeof Int32Array !== 'undefined' && + Features.littleEndian !== null && + isUint8 + ); + + return Features; +} + +module.exports = init(); + + +/***/ }), +/* 187 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. + * If no parent was given it falls back to using `document.body`. + * + * @function Phaser.DOM.AddToDOM + * @since 3.0.0 + * + * @param {HTMLElement} element - The element to be added to the DOM. Usually a Canvas object. + * @param {(string|HTMLElement)} [parent] - The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. + * @param {boolean} [overflowHidden=true] - Whether or not to hide overflowing content inside the parent. + * + * @return {HTMLElement} The element that was added to the DOM. + */ +var AddToDOM = function (element, parent, overflowHidden) +{ + if (overflowHidden === undefined) { overflowHidden = true; } + + var target; + + if (parent) + { + if (typeof parent === 'string') + { + // Hopefully an element ID + target = document.getElementById(parent); + } + else if (typeof parent === 'object' && parent.nodeType === 1) + { + // Quick test for a HTMLElement + target = parent; + } + } + else if (element.parentElement) + { + return element; + } + + // Fallback, covers an invalid ID and a non HTMLElement object + if (!target) + { + target = document.body; + } + + if (overflowHidden && target.style) + { + target.style.overflow = 'hidden'; + } + + target.appendChild(element); + + return element; +}; + +module.exports = AddToDOM; + + +/***/ }), +/* 188 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random integer between the `min` and `max` values, inclusive. + * + * @function Phaser.Math.Between + * @since 3.0.0 + * + * @param {integer} min - The minimum value. + * @param {integer} max - The maximum value. + * + * @return {integer} The random integer. + */ +var Between = function (min, max) +{ + return Math.floor(Math.random() * (max - min + 1) + min); +}; + +module.exports = Between; + + +/***/ }), +/* 189 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates a Catmull-Rom value. + * + * @function Phaser.Math.CatmullRom + * @since 3.0.0 + * + * @param {number} t - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {number} p2 - [description] + * @param {number} p3 - [description] + * + * @return {number} The Catmull-Rom value. + */ +var CatmullRom = function (t, p0, p1, p2, p3) +{ + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + var t2 = t * t; + var t3 = t * t2; + + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; +}; + +module.exports = CatmullRom; + + +/***/ }), +/* 190 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(18); + +/** + * Convert the given angle in radians, to the equivalent angle in degrees. + * + * @function Phaser.Math.RadToDeg + * @since 3.0.0 + * + * @param {number} radians - The angle in radians to convert ot degrees. + * + * @return {integer} The given angle converted to degrees. + */ +var RadToDeg = function (radians) +{ + return radians * CONST.RAD_TO_DEG; +}; + +module.exports = RadToDeg; + + +/***/ }), +/* 191 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +// points is an array of Point-like objects, +// either 2 dimensional arrays, or objects with public x/y properties: +// var points = [ +// [100, 200], +// [200, 400], +// { x: 30, y: 60 } +// ] + +/** + * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. + * + * @function Phaser.Geom.Rectangle.FromPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {array} points - An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. + * @param {Phaser.Geom.Rectangle} [out] - Optional Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted `out` Rectangle, or a new Rectangle if none was provided. + */ +var FromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (points.length === 0) + { + return out; + } + + var minX = Number.MAX_VALUE; + var minY = Number.MAX_VALUE; + + var maxX = Number.MIN_SAFE_INTEGER; + var maxY = Number.MIN_SAFE_INTEGER; + + var p; + var px; + var py; + + for (var i = 0; i < points.length; i++) + { + p = points[i]; + + if (Array.isArray(p)) + { + px = p[0]; + py = p[1]; + } + else + { + px = p.x; + py = p.y; + } + + minX = Math.min(minX, px); + minY = Math.min(minY, py); + + maxX = Math.max(maxX, px); + maxY = Math.max(maxY, py); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; +}; + +module.exports = FromPoints; + + +/***/ }), +/* 192 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Back = __webpack_require__(405); +var Bounce = __webpack_require__(404); +var Circular = __webpack_require__(403); +var Cubic = __webpack_require__(402); +var Elastic = __webpack_require__(401); +var Expo = __webpack_require__(400); +var Linear = __webpack_require__(399); +var Quadratic = __webpack_require__(398); +var Quartic = __webpack_require__(397); +var Quintic = __webpack_require__(396); +var Sine = __webpack_require__(395); +var Stepped = __webpack_require__(394); + +// EaseMap +module.exports = { + + Power0: Linear, + Power1: Quadratic.Out, + Power2: Cubic.Out, + Power3: Quartic.Out, + Power4: Quintic.Out, + + Linear: Linear, + Quad: Quadratic.Out, + Cubic: Cubic.Out, + Quart: Quartic.Out, + Quint: Quintic.Out, + Sine: Sine.Out, + Expo: Expo.Out, + Circ: Circular.Out, + Elastic: Elastic.Out, + Back: Back.Out, + Bounce: Bounce.Out, + Stepped: Stepped, + + 'Quad.easeIn': Quadratic.In, + 'Cubic.easeIn': Cubic.In, + 'Quart.easeIn': Quartic.In, + 'Quint.easeIn': Quintic.In, + 'Sine.easeIn': Sine.In, + 'Expo.easeIn': Expo.In, + 'Circ.easeIn': Circular.In, + 'Elastic.easeIn': Elastic.In, + 'Back.easeIn': Back.In, + 'Bounce.easeIn': Bounce.In, + + 'Quad.easeOut': Quadratic.Out, + 'Cubic.easeOut': Cubic.Out, + 'Quart.easeOut': Quartic.Out, + 'Quint.easeOut': Quintic.Out, + 'Sine.easeOut': Sine.Out, + 'Expo.easeOut': Expo.Out, + 'Circ.easeOut': Circular.Out, + 'Elastic.easeOut': Elastic.Out, + 'Back.easeOut': Back.Out, + 'Bounce.easeOut': Bounce.Out, + + 'Quad.easeInOut': Quadratic.InOut, + 'Cubic.easeInOut': Cubic.InOut, + 'Quart.easeInOut': Quartic.InOut, + 'Quint.easeInOut': Quintic.InOut, + 'Sine.easeInOut': Sine.InOut, + 'Expo.easeInOut': Expo.InOut, + 'Circ.easeInOut': Circular.InOut, + 'Elastic.easeInOut': Elastic.InOut, + 'Back.easeInOut': Back.InOut, + 'Bounce.easeInOut': Bounce.InOut + +}; + + +/***/ }), +/* 193 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Centers this Rectangle so that the center coordinates match the given x and y values. + +/** + * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. + * + * @function Phaser.Geom.Rectangle.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to be centered. + * @param {number} x - The X coordinate of the Rectangle's center. + * @param {number} y - The Y coordinate of the Rectangle's center. + * + * @return {Phaser.Geom.Rectangle} The centered rectangle. + */ +var CenterOn = function (rect, x, y) +{ + rect.x = x - (rect.width / 2); + rect.y = y - (rect.height / 2); + + return rect; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 194 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetColor = __webpack_require__(195); + +/** + * Converts an HSV (hue, saturation and value) color value to RGB. + * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes HSV values are contained in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HSVToRGB + * @since 3.0.0 + * + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * @param {(ColorObject|Phaser.Display.Color)} [out] - A Color object to store the results in. If not given a new ColorObject will be created. + * + * @return {(ColorObject|Phaser.Display.Color)} An object with the red, green and blue values set in the r, g and b properties. + */ +var HSVToRGB = function (h, s, v, out) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var i = Math.floor(h * 6); + var f = h * 6 - i; + + var p = Math.floor((v * (1 - s)) * 255); + var q = Math.floor((v * (1 - f * s)) * 255); + var t = Math.floor((v * (1 - (1 - f) * s)) * 255); + + v = Math.floor(v *= 255); + + var r = v; + var g = v; + var b = v; + + var c = i % 6; + + if (c === 0) + { + g = t; + b = p; + } + else if (c === 1) + { + r = q; + b = p; + } + else if (c === 2) + { + r = p; + b = t; + } + else if (c === 3) + { + r = p; + g = q; + } + else if (c === 4) + { + r = t; + g = p; + } + else if (c === 5) + { + g = p; + b = q; + } + + if (!out) + { + return { r: r, g: g, b: b, color: GetColor(r, g, b) }; + } + else if (out.setTo) + { + return out.setTo(r, g, b, out.alpha, false); + } + else + { + out.r = r; + out.g = g; + out.b = b; + out.color = GetColor(r, g, b); + + return out; + } +}; + +module.exports = HSVToRGB; + + +/***/ }), +/* 195 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given 3 separate color values this will return an integer representation of it. + * + * @function Phaser.Display.Color.GetColor + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * + * @return {number} The combined color value. + */ +var GetColor = function (red, green, blue) +{ + return red << 16 | green << 8 | blue; +}; + +module.exports = GetColor; + + +/***/ }), +/* 196 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HexStringToColor = __webpack_require__(413); +var IntegerToColor = __webpack_require__(410); +var ObjectToColor = __webpack_require__(408); +var RGBStringToColor = __webpack_require__(407); + +/** + * Converts the given source color value into an instance of a Color class. + * The value can be either a string, prefixed with `rgb` or a hex string, a number or an Object. + * + * @function Phaser.Display.Color.ValueToColor + * @since 3.0.0 + * + * @param {(string|number|InputColorObject)} input - The source color value to convert. + * + * @return {Phaser.Display.Color} A Color object. + */ +var ValueToColor = function (input) +{ + var t = typeof input; + + switch (t) + { + case 'string': + + if (input.substr(0, 3).toLowerCase() === 'rgb') + { + return RGBStringToColor(input); + } + else + { + return HexStringToColor(input); + } + + case 'number': + + return IntegerToColor(input); + + case 'object': + + return ObjectToColor(input); + } +}; + +module.exports = ValueToColor; + + +/***/ }), +/* 197 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given string and pads it out, to the length required, using the character + * specified. For example if you need a string to be 6 characters long, you can call: + * + * `pad('bob', 6, '-', 2)` + * + * This would return: `bob---` as it has padded it out to 6 characters, using the `-` on the right. + * + * You can also use it to pad numbers (they are always returned as strings): + * + * `pad(512, 6, '0', 1)` + * + * Would return: `000512` with the string padded to the left. + * + * If you don't specify a direction it'll pad to both sides: + * + * `pad('c64', 7, '*')` + * + * Would return: `**c64**` + * + * @function Phaser.Utils.String.Pad + * @since 3.0.0 + * + * @param {string} str - The target string. `toString()` will be called on the string, which means you can also pass in common data types like numbers. + * @param {integer} [len=0] - The number of characters to be added. + * @param {string} [pad=" "] - The string to pad it out with (defaults to a space). + * @param {integer} [dir=3] - The direction dir = 1 (left), 2 (right), 3 (both). + * + * @return {string} The padded string. + */ +var Pad = function (str, len, pad, dir) +{ + if (len === undefined) { len = 0; } + if (pad === undefined) { pad = ' '; } + if (dir === undefined) { dir = 3; } + + str = str.toString(); + + var padlen = 0; + + if (len + 1 >= str.length) + { + switch (dir) + { + case 1: + str = new Array(len + 1 - str.length).join(pad) + str; + break; + + case 3: + var right = Math.ceil((padlen = len - str.length) / 2); + var left = padlen - right; + str = new Array(left + 1).join(pad) + str + new Array(right + 1).join(pad); + break; + + default: + str = str + new Array(len + 1 - str.length).join(pad); + break; + } + } + + return str; +}; + +module.exports = Pad; + + +/***/ }), +/* 198 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback EachMapCallback + * @generic E - [entry] + * + * @param {string} key - [description] + * @param {*} entry - [description] + * + * @return {?boolean} [description] + */ + +/** + * @classdesc + * The keys of a Map can be arbitrary values. + * + * ```javascript + * var map = new Map([ + * [ 1, 'one' ], + * [ 2, 'two' ], + * [ 3, 'three' ] + * ]); + * ``` + * + * @class Map + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic K + * @generic V + * @genericUse {V[]} - [elements] + * + * @param {Array.<*>} elements - An optional array of key-value pairs to populate this Map with. + */ +var Map = new Class({ + + initialize: + + function Map (elements) + { + /** + * The entries in this Map. + * + * @genericUse {Object.} - [$type] + * + * @name Phaser.Structs.Map#entries + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.entries = {}; + + /** + * The number of key / value pairs in this Map. + * + * @name Phaser.Structs.Map#size + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.size = 0; + + if (Array.isArray(elements)) + { + for (var i = 0; i < elements.length; i++) + { + this.set(elements[i][0], elements[i][1]); + } + } + }, + + /** + * Adds an element with a specified `key` and `value` to this Map. + * + * @method Phaser.Structs.Map#set + * @since 3.0.0 + * + * @genericUse {K} - [key] + * @genericUse {V} - [value] + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @param {string} key - The key of the element to be added to this Map. + * @param {*} value - The value of the element to be added to this Map. + * + * @return {Phaser.Structs.Map} This Map object. + */ + set: function (key, value) + { + if (!this.has(key)) + { + this.entries[key] = value; + this.size++; + } + + return this; + }, + + /** + * Returns the value associated to the `key`, or `undefined` if there is none. + * + * @method Phaser.Structs.Map#get + * @since 3.0.0 + * + * @genericUse {K} - [key] + * @genericUse {V} - [$return] + * + * @param {string} key - The key of the element to return from the `Map` object. + * + * @return {*} The element associated with the specified key or `undefined` if the key can't be found in this Map object. + */ + get: function (key) + { + if (this.has(key)) + { + return this.entries[key]; + } + }, + + /** + * Returns an `Array` of all the values stored in this Map. + * + * @method Phaser.Structs.Map#getArray + * @since 3.0.0 + * + * @genericUse {V[]} - [$return] + * + * @return {Array.<*>} An array of the values stored in this Map. + */ + getArray: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * Returns a boolean indicating whether an element with the specified key exists or not. + * + * @method Phaser.Structs.Map#has + * @since 3.0.0 + * + * @genericUse {K} - [key] + * + * @param {string} key - The key of the element to test for presence of in this Map. + * + * @return {boolean} Returns `true` if an element with the specified key exists in this Map, otherwise `false`. + */ + has: function (key) + { + return (this.entries.hasOwnProperty(key)); + }, + + /** + * Delete the specified element from this Map. + * + * @method Phaser.Structs.Map#delete + * @since 3.0.0 + * + * @genericUse {K} - [key] + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @param {string} key - The key of the element to delete from this Map. + * + * @return {Phaser.Structs.Map} This Map object. + */ + delete: function (key) + { + if (this.has(key)) + { + delete this.entries[key]; + this.size--; + } + + return this; + }, + + /** + * Delete all entries from this Map. + * + * @method Phaser.Structs.Map#clear + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @return {Phaser.Structs.Map} This Map object. + */ + clear: function () + { + Object.keys(this.entries).forEach(function (prop) + { + delete this.entries[prop]; + + }, this); + + this.size = 0; + + return this; + }, + + /** + * Returns all entries keys in this Map. + * + * @method Phaser.Structs.Map#keys + * @since 3.0.0 + * + * @genericUse {K[]} - [$return] + * + * @return {string[]} Array containing entries' keys. + */ + keys: function () + { + return Object.keys(this.entries); + }, + + /** + * Returns an `Array` of all entries. + * + * @method Phaser.Structs.Map#values + * @since 3.0.0 + * + * @genericUse {V[]} - [$return] + * + * @return {Array.<*>} An `Array` of entries. + */ + values: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * Dumps the contents of this Map to the console via `console.group`. + * + * @method Phaser.Structs.Map#dump + * @since 3.0.0 + */ + dump: function () + { + var entries = this.entries; + + // eslint-disable-next-line no-console + console.group('Map'); + + for (var key in entries) + { + console.log(key, entries[key]); + } + + // eslint-disable-next-line no-console + console.groupEnd(); + }, + + /** + * Passes all entries in this Map to the given callback. + * + * @method Phaser.Structs.Map#each + * @since 3.0.0 + * + * @genericUse {EachMapCallback.} - [callback] + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @param {EachMapCallback} callback - The callback which will receive the keys and entries held in this Map. + * + * @return {Phaser.Structs.Map} This Map object. + */ + each: function (callback) + { + var entries = this.entries; + + for (var key in entries) + { + if (callback(key, entries[key]) === false) + { + break; + } + } + + return this; + }, + + /** + * Returns `true` if the value exists within this Map. Otherwise, returns `false`. + * + * @method Phaser.Structs.Map#contains + * @since 3.0.0 + * + * @genericUse {V} - [value] + * + * @param {*} value - The value to search for. + * + * @return {boolean} `true` if the value is found, otherwise `false`. + */ + contains: function (value) + { + var entries = this.entries; + + for (var key in entries) + { + if (entries[key] === value) + { + return true; + } + } + + return false; + }, + + /** + * Merges all new keys from the given Map into this one. + * If it encounters a key that already exists it will be skipped unless override is set to `true`. + * + * @method Phaser.Structs.Map#merge + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Map.} - [map,$return] + * + * @param {Phaser.Structs.Map} map - The Map to merge in to this Map. + * @param {boolean} [override=false] - Set to `true` to replace values in this Map with those from the source map, or `false` to skip them. + * + * @return {Phaser.Structs.Map} This Map object. + */ + merge: function (map, override) + { + if (override === undefined) { override = false; } + + var local = this.entries; + var source = map.entries; + + for (var key in source) + { + if (local.hasOwnProperty(key) && override) + { + local[key] = source[key]; + } + else + { + this.set(key, source[key]); + } + } + + return this; + } + +}); + +module.exports = Map; + + +/***/ }), +/* 199 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate a smooth interpolation percentage of `x` between `min` and `max`. + * + * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, + * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, + * between 0 and 1 otherwise. + * + * @function Phaser.Math.SmoothStep + * @since 3.0.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep} + * + * @param {number} x - The input value. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The percentage of interpolation, between 0 and 1. + */ +var SmoothStep = function (x, min, max) +{ + if (x <= min) + { + return 0; + } + + if (x >= max) + { + return 1; + } + + x = (x - min) / (max - min); + + return x * x * (3 - 2 * x); +}; + +module.exports = SmoothStep; + + +/***/ }), +/* 200 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate a smoother interpolation percentage of `x` between `min` and `max`. + * + * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, + * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, + * between 0 and 1 otherwise. + * + * Produces an even smoother interpolation than {@link Phaser.Math.SmoothStep}. + * + * @function Phaser.Math.SmootherStep + * @since 3.0.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} + * + * @param {number} x - The input value. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The percentage of interpolation, between 0 and 1. + */ +var SmootherStep = function (x, min, max) +{ + x = Math.max(0, Math.min(1, (x - min) / (max - min))); + + return x * x * x * (x * (x * 6 - 15) + 10); +}; + +module.exports = SmootherStep; + + +/***/ }), +/* 201 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RotateAroundDistance + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. + * @param {number} x - The horizontal coordinate to rotate around. + * @param {number} y - The vertical coordinate to rotate around. + * @param {number} angle - The angle of rotation in radians. + * @param {number} distance - [description] + * + * @return {Phaser.Geom.Point} The given point. + */ +var RotateAroundDistance = function (point, x, y, angle, distance) +{ + var t = angle + Math.atan2(point.y - y, point.x - x); + + point.x = x + (distance * Math.cos(t)); + point.y = y + (distance * Math.sin(t)); + + return point; +}; + +module.exports = RotateAroundDistance; + + +/***/ }), +/* 202 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Random = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + // Basis vectors + var ux = triangle.x2 - triangle.x1; + var uy = triangle.y2 - triangle.y1; + + var vx = triangle.x3 - triangle.x1; + var vy = triangle.y3 - triangle.y1; + + // Random point within the unit square + var r = Math.random(); + var s = Math.random(); + + // Point outside the triangle? Remap it. + if (r + s >= 1) + { + r = 1 - r; + s = 1 - s; + } + + out.x = triangle.x1 + ((ux * r) + (vx * s)); + out.y = triangle.y1 + ((uy * r) + (vy * s)); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 203 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a uniformly distributed random point from anywhere within the given Ellipse. + * + * @function Phaser.Geom.Ellipse.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get a random point from. + * @param {(Phaser.Geom.Point|object)} [out] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ +var Random = function (ellipse, out) +{ + if (out === undefined) { out = new Point(); } + + var p = Math.random() * Math.PI * 2; + var s = Math.sqrt(Math.random()); + + out.x = ellipse.x + ((s * Math.cos(p)) * ellipse.width / 2); + out.y = ellipse.y + ((s * Math.sin(p)) * ellipse.height / 2); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 204 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Wrap = __webpack_require__(59); + +/** + * Wrap an angle in degrees. + * + * Wraps the angle to a value in the range of -180 to 180. + * + * @function Phaser.Math.Angle.WrapDegrees + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in degrees. + * + * @return {number} The wrapped angle, in degrees. + */ +var WrapDegrees = function (angle) +{ + return Wrap(angle, -180, 180); +}; + +module.exports = WrapDegrees; + + +/***/ }), +/* 205 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathWrap = __webpack_require__(59); + +/** + * Wrap an angle. + * + * Wraps the angle to a value in the range of -PI to PI. + * + * @function Phaser.Math.Angle.Wrap + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in radians. + * + * @return {number} The wrapped angle, in radians. + */ +var Wrap = function (angle) +{ + return MathWrap(angle, -Math.PI, Math.PI); +}; + +module.exports = Wrap; + + +/***/ }), +/* 206 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a random point within a Rectangle. + * + * @function Phaser.Geom.Rectangle.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to return a point from. + * @param {Phaser.Geom.Point} out - The object to update with the point's coordinates. + * + * @return {Phaser.Geom.Point} The modified `out` object, or a new Point if none was provided. + */ +var Random = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.x + (Math.random() * rect.width); + out.y = rect.y + (Math.random() * rect.height); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 207 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a random point on a given Line. + * + * @function Phaser.Geom.Line.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The Line to calculate the random Point on. + * @param {(Phaser.Geom.Point|object)} [out] - An instance of a Point to be modified. + * + * @return {(Phaser.Geom.Point|object)} A random Point on the Line. + */ +var Random = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + var t = Math.random(); + + out.x = line.x1 + t * (line.x2 - line.x1); + out.y = line.y1 + t * (line.y2 - line.y1); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 208 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(71); +var Point = __webpack_require__(6); + +/** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * @function Phaser.Geom.Line.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line. + * @param {integer} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {number} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param {(array|Phaser.Geom.Point[])} [out] - An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * + * @return {(array|Phaser.Geom.Point[])} An array of Points, or point-like objects, containing the coordinates of the points on the line. + */ +var GetPoints = function (line, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Length(line) / stepRate; + } + + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + var x = x1 + (x2 - x1) * position; + var y = y1 + (y2 - y1) * position; + + out.push(new Point(x, y)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 209 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Perimeter = __webpack_require__(134); +var Point = __webpack_require__(6); + +/** + * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. + * + * @function Phaser.Geom.Rectangle.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {number} position - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var GetPoint = function (rectangle, position, out) +{ + if (out === undefined) { out = new Point(); } + + if (position <= 0 || position >= 1) + { + out.x = rectangle.x; + out.y = rectangle.y; + + return out; + } + + var p = Perimeter(rectangle) * position; + + if (position > 0.5) + { + p -= (rectangle.width + rectangle.height); + + if (p <= rectangle.width) + { + // Face 3 + out.x = rectangle.right - p; + out.y = rectangle.bottom; + } + else + { + // Face 4 + out.x = rectangle.x; + out.y = rectangle.bottom - (p - rectangle.width); + } + } + else if (p <= rectangle.width) + { + // Face 1 + out.x = rectangle.x + p; + out.y = rectangle.y; + } + else + { + // Face 2 + out.x = rectangle.right; + out.y = rectangle.y + (p - rectangle.width); + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 210 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a uniformly distributed random point from anywhere within the given Circle. + * + * @function Phaser.Geom.Circle.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get a random point from. + * @param {(Phaser.Geom.Point|object)} [out] - A Point or point-like object to set the random `x` and `y` values in. + * + * @return {(Phaser.Geom.Point|object)} A Point object with the random values set in the `x` and `y` properties. + */ +var Random = function (circle, out) +{ + if (out === undefined) { out = new Point(); } + + var t = 2 * Math.PI * Math.random(); + var u = Math.random() + Math.random(); + var r = (u > 1) ? 2 - u : u; + var x = r * Math.cos(t); + var y = r * Math.sin(t); + + out.x = circle.x + (x * circle.radius); + out.y = circle.y + (y * circle.radius); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 211 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * + * @function Phaser.Geom.Circle.CircumferencePoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (circle, angle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = circle.x + (circle.radius * Math.cos(angle)); + out.y = circle.y + (circle.radius * Math.sin(angle)); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 212 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ALIGN_CONST = { + + /** + * A constant representing a top-left alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_LEFT + * @since 3.0.0 + * @type {integer} + */ + TOP_LEFT: 0, + + /** + * A constant representing a top-center alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_CENTER + * @since 3.0.0 + * @type {integer} + */ + TOP_CENTER: 1, + + /** + * A constant representing a top-right alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_RIGHT + * @since 3.0.0 + * @type {integer} + */ + TOP_RIGHT: 2, + + /** + * A constant representing a left-top alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_TOP + * @since 3.0.0 + * @type {integer} + */ + LEFT_TOP: 3, + + /** + * A constant representing a left-center alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_CENTER + * @since 3.0.0 + * @type {integer} + */ + LEFT_CENTER: 4, + + /** + * A constant representing a left-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + LEFT_BOTTOM: 5, + + /** + * A constant representing a center alignment or position. + * @constant + * @name Phaser.Display.Align.CENTER + * @since 3.0.0 + * @type {integer} + */ + CENTER: 6, + + /** + * A constant representing a right-top alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_TOP + * @since 3.0.0 + * @type {integer} + */ + RIGHT_TOP: 7, + + /** + * A constant representing a right-center alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_CENTER + * @since 3.0.0 + * @type {integer} + */ + RIGHT_CENTER: 8, + + /** + * A constant representing a right-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + RIGHT_BOTTOM: 9, + + /** + * A constant representing a bottom-left alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_LEFT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_LEFT: 10, + + /** + * A constant representing a bottom-center alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_CENTER + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_CENTER: 11, + + /** + * A constant representing a bottom-right alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_RIGHT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_RIGHT: 12 + +}; + +module.exports = ALIGN_CONST; + + +/***/ }), +/* 213 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1, eval)("this"); +} catch (e) { + // This works if the window reference is available + if (typeof window === "object") g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 214 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var TweenBuilder = __webpack_require__(105); +var TWEEN_CONST = __webpack_require__(93); + +/** + * @classdesc + * [description] + * + * @class Timeline + * @memberof Phaser.Tweens + * @extends Phaser.Events.EventEmitter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Tweens.TweenManager} manager - [description] + */ +var Timeline = new Class({ + + Extends: EventEmitter, + + initialize: + + function Timeline (manager) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Tweens.Timeline#manager + * @type {Phaser.Tweens.TweenManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * [description] + * + * @name Phaser.Tweens.Timeline#isTimeline + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isTimeline = true; + + /** + * An array of Tween objects, each containing a unique property and target being tweened. + * + * @name Phaser.Tweens.Timeline#data + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.data = []; + + /** + * data array doesn't usually change, so we can cache the length + * + * @name Phaser.Tweens.Timeline#totalData + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalData = 0; + + /** + * If true then duration, delay, etc values are all frame totals. + * + * @name Phaser.Tweens.Timeline#useFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useFrames = false; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * + * @name Phaser.Tweens.Timeline#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + * + * @name Phaser.Tweens.Timeline#loop + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loop = 0; + + /** + * Time in ms/frames before the tween loops. + * + * @name Phaser.Tweens.Timeline#loopDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopDelay = 0; + + /** + * How many loops are left to run? + * + * @name Phaser.Tweens.Timeline#loopCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopCounter = 0; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = true (as it never completes) + * + * @name Phaser.Tweens.Timeline#completeDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.completeDelay = 0; + + /** + * Countdown timer (used by loopDelay and completeDelay) + * + * @name Phaser.Tweens.Timeline#countdown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.countdown = 0; + + /** + * The current state of the tween + * + * @name Phaser.Tweens.Timeline#state + * @type {integer} + * @since 3.0.0 + */ + this.state = TWEEN_CONST.PENDING_ADD; + + /** + * The state of the tween when it was paused (used by Resume) + * + * @name Phaser.Tweens.Timeline#_pausedState + * @type {integer} + * @private + * @since 3.0.0 + */ + this._pausedState = TWEEN_CONST.PENDING_ADD; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + * + * @name Phaser.Tweens.Timeline#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * Elapsed time in ms/frames of this run through the Tween. + * + * @name Phaser.Tweens.Timeline#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + * + * @name Phaser.Tweens.Timeline#totalElapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalElapsed = 0; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + * + * @name Phaser.Tweens.Timeline#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + * + * @name Phaser.Tweens.Timeline#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Time in ms/frames for all Tweens to complete (including looping) + * + * @name Phaser.Tweens.Timeline#totalDuration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalDuration = 0; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + * + * @name Phaser.Tweens.Timeline#totalProgress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalProgress = 0; + + this.callbacks = { + onComplete: null, + onLoop: null, + onStart: null, + onUpdate: null, + onYoyo: null + }; + + this.callbackScope; + }, + + /** + * Sets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * + * @method Phaser.Tweens.Timeline#setTimeScale + * @since 3.0.0 + * + * @param {number} value - The time scale value to set. + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + setTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * + * @method Phaser.Tweens.Timeline#getTimeScale + * @since 3.0.0 + * + * @return {number} The value of the time scale applied to this Tween. + */ + getTimeScale: function () + { + return this.timeScale; + }, + + /** + * Check whether or not the Timeline is playing. + * + * @method Phaser.Tweens.Timeline#isPlaying + * @since 3.0.0 + * + * @return {boolean} `true` if this Timeline is active, otherwise `false`. + */ + isPlaying: function () + { + return (this.state === TWEEN_CONST.ACTIVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#add + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + add: function (config) + { + return this.queue(TweenBuilder(this, config)); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#queue + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + queue: function (tween) + { + if (!this.isPlaying()) + { + tween.parent = this; + tween.parentIsTimeline = true; + + this.data.push(tween); + + this.totalData = this.data.length; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#hasOffset + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {boolean} [description] + */ + hasOffset: function (tween) + { + return (tween.offset !== null); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#isOffsetAbsolute + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {boolean} [description] + */ + isOffsetAbsolute: function (value) + { + return (typeof(value) === 'number'); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#isOffsetRelative + * @since 3.0.0 + * + * @param {string} value - [description] + * + * @return {boolean} [description] + */ + isOffsetRelative: function (value) + { + var t = typeof(value); + + if (t === 'string') + { + var op = value[0]; + + if (op === '-' || op === '+') + { + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#getRelativeOffset + * @since 3.0.0 + * + * @param {string} value - [description] + * @param {number} base - [description] + * + * @return {number} [description] + */ + getRelativeOffset: function (value, base) + { + var op = value[0]; + var num = parseFloat(value.substr(2)); + var result = base; + + switch (op) + { + case '+': + result += num; + break; + + case '-': + result -= num; + break; + } + + // Cannot ever be < 0 + return Math.max(0, result); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#calcDuration + * @since 3.0.0 + */ + calcDuration: function () + { + var prevEnd = 0; + var totalDuration = 0; + var offsetDuration = 0; + + for (var i = 0; i < this.totalData; i++) + { + var tween = this.data[i]; + + tween.init(); + + if (this.hasOffset(tween)) + { + if (this.isOffsetAbsolute(tween.offset)) + { + // An actual number, so it defines the start point from the beginning of the timeline + tween.calculatedOffset = tween.offset; + + if (tween.offset === 0) + { + offsetDuration = 0; + } + } + else if (this.isOffsetRelative(tween.offset)) + { + // A relative offset (i.e. '-=1000', so starts at 'offset' ms relative to the PREVIOUS Tweens ending time) + tween.calculatedOffset = this.getRelativeOffset(tween.offset, prevEnd); + } + } + else + { + // Sequential + tween.calculatedOffset = offsetDuration; + } + + prevEnd = tween.totalDuration + tween.calculatedOffset; + + totalDuration += tween.totalDuration; + offsetDuration += tween.totalDuration; + } + + // Excludes loop values + this.duration = totalDuration; + + this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; + + if (this.loopCounter > 0) + { + this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); + } + else + { + this.totalDuration = this.duration + this.completeDelay; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#init + * @since 3.0.0 + * + * @return {boolean} [description] + */ + init: function () + { + this.calcDuration(); + + this.progress = 0; + this.totalProgress = 0; + + if (this.paused) + { + this.state = TWEEN_CONST.PAUSED; + + return false; + } + else + { + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#resetTweens + * @since 3.0.0 + * + * @param {boolean} resetFromLoop - [description] + */ + resetTweens: function (resetFromLoop) + { + for (var i = 0; i < this.totalData; i++) + { + var tween = this.data[i]; + + tween.play(resetFromLoop); + } + }, + + /** + * Sets a callback for the Tween Manager. + * + * @method Phaser.Tweens.Timeline#setCallback + * @since 3.0.0 + * + * @param {string} type - [description] + * @param {function} callback - [description] + * @param {array} [params] - [description] + * @param {object} [scope] - [description] + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + setCallback: function (type, callback, params, scope) + { + if (Timeline.TYPES.indexOf(type) !== -1) + { + this.callbacks[type] = { func: callback, scope: scope, params: params }; + } + + return this; + }, + + /** + * Delegates #makeActive to the Tween manager. + * + * @method Phaser.Tweens.Timeline#makeActive + * @since 3.3.0 + * + * @param {Phaser.Tweens.Tween} tween - The tween object to make active. + * + * @return {Phaser.Tweens.TweenManager} The Timeline's Tween Manager object. + */ + makeActive: function (tween) + { + return this.manager.makeActive(tween); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#play + * @since 3.0.0 + */ + play: function () + { + if (this.state === TWEEN_CONST.ACTIVE) + { + return; + } + + if (this.paused) + { + this.paused = false; + + this.manager.makeActive(this); + + return; + } + else + { + this.resetTweens(false); + + this.state = TWEEN_CONST.ACTIVE; + } + + var onStart = this.callbacks.onStart; + + if (onStart) + { + onStart.func.apply(onStart.scope, onStart.params); + } + + this.emit('start', this); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#nextState + * @since 3.0.0 + */ + nextState: function () + { + if (this.loopCounter > 0) + { + // Reset the elapsed time + // TODO: Probably ought to be set to the remainder from elapsed - duration + // as the tweens nearly always over-run by a few ms due to rAf + + this.elapsed = 0; + this.progress = 0; + + this.loopCounter--; + + var onLoop = this.callbacks.onLoop; + + if (onLoop) + { + onLoop.func.apply(onLoop.scope, onLoop.params); + } + + this.emit('loop', this, this.loopCounter); + + this.resetTweens(true); + + if (this.loopDelay > 0) + { + this.countdown = this.loopDelay; + this.state = TWEEN_CONST.LOOP_DELAY; + } + else + { + this.state = TWEEN_CONST.ACTIVE; + } + } + else if (this.completeDelay > 0) + { + this.countdown = this.completeDelay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.emit('complete', this); + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. + * Otherwise, returns false. + * + * @method Phaser.Tweens.Timeline#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + * + * @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager. + */ + update: function (timestamp, delta) + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + var rawDelta = delta; + + if (this.useFrames) + { + delta = 1 * this.manager.timeScale; + } + + delta *= this.timeScale; + + this.elapsed += delta; + this.progress = Math.min(this.elapsed / this.duration, 1); + + this.totalElapsed += delta; + this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); + + switch (this.state) + { + case TWEEN_CONST.ACTIVE: + + var stillRunning = this.totalData; + + for (var i = 0; i < this.totalData; i++) + { + var tween = this.data[i]; + + if (tween.update(timestamp, rawDelta)) + { + stillRunning--; + } + } + + var onUpdate = this.callbacks.onUpdate; + + if (onUpdate) + { + onUpdate.func.apply(onUpdate.scope, onUpdate.params); + } + + this.emit('update', this); + + // Anything still running? If not, we're done + if (stillRunning === 0) + { + this.nextState(); + } + + break; + + case TWEEN_CONST.LOOP_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.COMPLETE_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.emit('complete', this); + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + + break; + } + + return (this.state === TWEEN_CONST.PENDING_REMOVE); + }, + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + * + * @method Phaser.Tweens.Timeline#stop + * @since 3.0.0 + */ + stop: function () + { + this.state = TWEEN_CONST.PENDING_REMOVE; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#pause + * @since 3.0.0 + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + pause: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + this.paused = true; + + this._pausedState = this.state; + + this.state = TWEEN_CONST.PAUSED; + + this.emit('pause', this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#resume + * @since 3.0.0 + * + * @return {Phaser.Tweens.Timeline} This Timeline object. + */ + resume: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + this.paused = false; + + this.state = this._pausedState; + } + + this.emit('resume', this); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Timeline#hasTarget + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + hasTarget: function (target) + { + for (var i = 0; i < this.data.length; i++) + { + if (this.data[i].hasTarget(target)) + { + return true; + } + } + + return false; + }, + + /** + * Stops all the Tweens in the Timeline immediately, whatever stage of progress they are at and flags them for removal by the TweenManager. + * + * @method Phaser.Tweens.Timeline#destroy + * @since 3.0.0 + */ + destroy: function () + { + for (var i = 0; i < this.data.length; i++) + { + this.data[i].stop(); + } + + } +}); + +Timeline.TYPES = [ 'onStart', 'onUpdate', 'onLoop', 'onComplete', 'onYoyo' ]; + +module.exports = Timeline; + + +/***/ }), +/* 215 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(69); +var Defaults = __webpack_require__(138); +var GetAdvancedValue = __webpack_require__(13); +var GetBoolean = __webpack_require__(94); +var GetEaseFunction = __webpack_require__(95); +var GetNewValue = __webpack_require__(106); +var GetTargets = __webpack_require__(140); +var GetTweens = __webpack_require__(217); +var GetValue = __webpack_require__(4); +var Timeline = __webpack_require__(214); +var TweenBuilder = __webpack_require__(105); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.TimelineBuilder + * @since 3.0.0 + * + * @param {Phaser.Tweens.TweenManager} manager - [description] + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} [description] + */ +var TimelineBuilder = function (manager, config) +{ + var timeline = new Timeline(manager); + + var tweens = GetTweens(config); + + if (tweens.length === 0) + { + timeline.paused = true; + + return timeline; + } + + var defaults = Clone(Defaults); + + defaults.targets = GetTargets(config); + + // totalDuration: If specified each tween in the Timeline is given an equal portion of the totalDuration + + var totalDuration = GetAdvancedValue(config, 'totalDuration', 0); + + if (totalDuration > 0) + { + defaults.duration = Math.floor(totalDuration / tweens.length); + } + else + { + defaults.duration = GetNewValue(config, 'duration', defaults.duration); + } + + defaults.delay = GetNewValue(config, 'delay', defaults.delay); + defaults.easeParams = GetValue(config, 'easeParams', defaults.easeParams); + defaults.ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), defaults.easeParams); + defaults.hold = GetNewValue(config, 'hold', defaults.hold); + defaults.repeat = GetNewValue(config, 'repeat', defaults.repeat); + defaults.repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + defaults.yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + defaults.flipX = GetBoolean(config, 'flipX', defaults.flipX); + defaults.flipY = GetBoolean(config, 'flipY', defaults.flipY); + + // Create the Tweens + for (var i = 0; i < tweens.length; i++) + { + timeline.queue(TweenBuilder(timeline, tweens[i], defaults)); + } + + timeline.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + timeline.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + timeline.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + timeline.paused = GetBoolean(config, 'paused', false); + timeline.useFrames = GetBoolean(config, 'useFrames', false); + + // Callbacks + + var scope = GetValue(config, 'callbackScope', timeline); + + var timelineArray = [ timeline ]; + + var onStart = GetValue(config, 'onStart', false); + + // The Start of the Timeline + if (onStart) + { + var onStartScope = GetValue(config, 'onStartScope', scope); + var onStartParams = GetValue(config, 'onStartParams', []); + + timeline.setCallback('onStart', onStart, timelineArray.concat(onStartParams), onStartScope); + } + + var onUpdate = GetValue(config, 'onUpdate', false); + + // Every time the Timeline updates (regardless which Tweens are running) + if (onUpdate) + { + var onUpdateScope = GetValue(config, 'onUpdateScope', scope); + var onUpdateParams = GetValue(config, 'onUpdateParams', []); + + timeline.setCallback('onUpdate', onUpdate, timelineArray.concat(onUpdateParams), onUpdateScope); + } + + var onLoop = GetValue(config, 'onLoop', false); + + // Called when the whole Timeline loops + if (onLoop) + { + var onLoopScope = GetValue(config, 'onLoopScope', scope); + var onLoopParams = GetValue(config, 'onLoopParams', []); + + timeline.setCallback('onLoop', onLoop, timelineArray.concat(onLoopParams), onLoopScope); + } + + var onYoyo = GetValue(config, 'onYoyo', false); + + // Called when a Timeline yoyos + if (onYoyo) + { + var onYoyoScope = GetValue(config, 'onYoyoScope', scope); + var onYoyoParams = GetValue(config, 'onYoyoParams', []); + + timeline.setCallback('onYoyo', onYoyo, timelineArray.concat(null, onYoyoParams), onYoyoScope); + } + + var onComplete = GetValue(config, 'onComplete', false); + + // Called when the Timeline completes, after the completeDelay, etc. + if (onComplete) + { + var onCompleteScope = GetValue(config, 'onCompleteScope', scope); + var onCompleteParams = GetValue(config, 'onCompleteParams', []); + + timeline.setCallback('onComplete', onComplete, timelineArray.concat(onCompleteParams), onCompleteScope); + } + + return timeline; +}; + +module.exports = TimelineBuilder; + + +/***/ }), +/* 216 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Defaults = __webpack_require__(138); +var GetAdvancedValue = __webpack_require__(13); +var GetBoolean = __webpack_require__(94); +var GetEaseFunction = __webpack_require__(95); +var GetNewValue = __webpack_require__(106); +var GetValue = __webpack_require__(4); +var GetValueOp = __webpack_require__(139); +var Tween = __webpack_require__(137); +var TweenData = __webpack_require__(136); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.NumberTweenBuilder + * @since 3.0.0 + * + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {object} config - [description] + * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ +var NumberTweenBuilder = function (parent, config, defaults) +{ + if (defaults === undefined) + { + defaults = Defaults; + } + + // var tween = this.tweens.addCounter({ + // from: 100, + // to: 200, + // ... (normal tween properties) + // }) + // + // Then use it in your game via: + // + // tween.getValue() + + var from = GetValue(config, 'from', 0); + var to = GetValue(config, 'to', 1); + + var targets = [ { value: from } ]; + + var delay = GetNewValue(config, 'delay', defaults.delay); + var duration = GetNewValue(config, 'duration', defaults.duration); + var easeParams = GetValue(config, 'easeParams', defaults.easeParams); + var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); + var hold = GetNewValue(config, 'hold', defaults.hold); + var repeat = GetNewValue(config, 'repeat', defaults.repeat); + var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + + var data = []; + + var ops = GetValueOp('value', to); + + var tweenData = TweenData( + targets[0], + 'value', + ops.getEnd, + ops.getStart, + ease, + delay, + duration, + yoyo, + hold, + repeat, + repeatDelay, + false, + false + ); + + tweenData.start = from; + tweenData.current = from; + tweenData.to = to; + + data.push(tweenData); + + var tween = new Tween(parent, data, targets); + + tween.offset = GetAdvancedValue(config, 'offset', null); + tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + tween.paused = GetBoolean(config, 'paused', false); + tween.useFrames = GetBoolean(config, 'useFrames', false); + + // Set the Callbacks + var scope = GetValue(config, 'callbackScope', tween); + + // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params + var tweenArray = [ tween, null ]; + + var callbacks = Tween.TYPES; + + for (var i = 0; i < callbacks.length; i++) + { + var type = callbacks[i]; + + var callback = GetValue(config, type, false); + + if (callback) + { + var callbackScope = GetValue(config, type + 'Scope', scope); + var callbackParams = GetValue(config, type + 'Params', []); + + // The null is reset to be the Tween target + tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); + } + } + + return tween; +}; + +module.exports = NumberTweenBuilder; + + +/***/ }), +/* 217 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetTweens + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {array} [description] + */ +var GetTweens = function (config) +{ + var tweens = GetValue(config, 'tweens', null); + + if (tweens === null) + { + return []; + } + else if (typeof tweens === 'function') + { + tweens = tweens.call(); + } + + if (!Array.isArray(tweens)) + { + tweens = [ tweens ]; + } + + return tweens; +}; + +module.exports = GetTweens; + + +/***/ }), +/* 218 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RESERVED = __webpack_require__(464); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetProps + * @since 3.0.0 + * + * @param {object} config - The configuration object of the tween to get the target(s) from. + * + * @return {array} An array of all the targets the tween is operating on. + */ +var GetProps = function (config) +{ + var key; + var keys = []; + + // First see if we have a props object + + if (config.hasOwnProperty('props')) + { + for (key in config.props) + { + // Skip any property that starts with an underscore + if (key.substr(0, 1) !== '_') + { + keys.push({ key: key, value: config.props[key] }); + } + } + } + else + { + for (key in config) + { + // Skip any property that is in the ReservedProps list or that starts with an underscore + if (RESERVED.indexOf(key) === -1 && key.substr(0, 1) !== '_') + { + keys.push({ key: key, value: config[key] }); + } + } + } + + return keys; +}; + +module.exports = GetProps; + + +/***/ }), +/* 219 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(1); + +/** + * @typedef {object} TimerEventConfig + * + * @property {number} [delay=0] - [description] + * @property {number} [repeat=0] - [description] + * @property {boolean} [loop=false] - [description] + * @property {function} [callback] - [description] + * @property {*} [callbackScope] - [description] + * @property {Array.<*>} [args] - [description] + * @property {number} [timeScale=1] - [description] + * @property {number} [startAt=1] - [description] + * @property {boolean} [paused=false] - [description] + */ + +/** + * @classdesc + * [description] + * + * @class TimerEvent + * @memberof Phaser.Time + * @constructor + * @since 3.0.0 + * + * @param {TimerEventConfig} config - [description] + */ +var TimerEvent = new Class({ + + initialize: + + function TimerEvent (config) + { + /** + * The delay in ms at which this TimerEvent fires. + * + * @name Phaser.Time.TimerEvent#delay + * @type {number} + * @default 0 + * @readonly + * @since 3.0.0 + */ + this.delay = 0; + + /** + * The total number of times this TimerEvent will repeat before finishing. + * + * @name Phaser.Time.TimerEvent#repeat + * @type {number} + * @default 0 + * @readonly + * @since 3.0.0 + */ + this.repeat = 0; + + /** + * If repeating this contains the current repeat count. + * + * @name Phaser.Time.TimerEvent#repeatCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatCount = 0; + + /** + * True if this TimerEvent loops, otherwise false. + * + * @name Phaser.Time.TimerEvent#loop + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.loop = false; + + /** + * The callback that will be called when the TimerEvent occurs. + * + * @name Phaser.Time.TimerEvent#callback + * @type {function} + * @since 3.0.0 + */ + this.callback; + + /** + * The scope in which the callback will be called. + * + * @name Phaser.Time.TimerEvent#callbackScope + * @type {object} + * @since 3.0.0 + */ + this.callbackScope; + + /** + * Additional arguments to be passed to the callback. + * + * @name Phaser.Time.TimerEvent#args + * @type {array} + * @since 3.0.0 + */ + this.args; + + /** + * Scale the time causing this TimerEvent to update. + * + * @name Phaser.Time.TimerEvent#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Start this many MS into the elapsed (useful if you want a long duration with repeat, but for the first loop to fire quickly) + * + * @name Phaser.Time.TimerEvent#startAt + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.startAt = 0; + + /** + * [description] + * + * @name Phaser.Time.TimerEvent#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * [description] + * + * @name Phaser.Time.TimerEvent#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * [description] + * + * @name Phaser.Time.TimerEvent#hasDispatched + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.hasDispatched = false; + + this.reset(config); + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#reset + * @since 3.0.0 + * + * @param {TimerEventConfig} config - [description] + * + * @return {Phaser.Time.TimerEvent} This TimerEvent object. + */ + reset: function (config) + { + this.delay = GetFastValue(config, 'delay', 0); + + // Can also be set to -1 for an infinite loop (same as setting loop: true) + this.repeat = GetFastValue(config, 'repeat', 0); + + this.loop = GetFastValue(config, 'loop', false); + + this.callback = GetFastValue(config, 'callback', undefined); + + this.callbackScope = GetFastValue(config, 'callbackScope', this.callback); + + this.args = GetFastValue(config, 'args', []); + + this.timeScale = GetFastValue(config, 'timeScale', 1); + + this.startAt = GetFastValue(config, 'startAt', 0); + + this.paused = GetFastValue(config, 'paused', false); + + this.elapsed = this.startAt; + this.hasDispatched = false; + this.repeatCount = (this.repeat === -1 || this.loop) ? 999999999999 : this.repeat; + + return this; + }, + + /** + * Gets the progress of the current iteration, not factoring in repeats. + * + * @method Phaser.Time.TimerEvent#getProgress + * @since 3.0.0 + * + * @return {number} [description] + */ + getProgress: function () + { + return (this.elapsed / this.delay); + }, + + /** + * Gets the progress of the timer overall, factoring in repeats. + * + * @method Phaser.Time.TimerEvent#getOverallProgress + * @since 3.0.0 + * + * @return {number} [description] + */ + getOverallProgress: function () + { + if (this.repeat > 0) + { + var totalDuration = this.delay + (this.delay * this.repeat); + var totalElapsed = this.elapsed + (this.delay * (this.repeat - this.repeatCount)); + + return (totalElapsed / totalDuration); + } + else + { + return this.getProgress(); + } + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#getRepeatCount + * @since 3.0.0 + * + * @return {number} [description] + */ + getRepeatCount: function () + { + return this.repeatCount; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#getElapsed + * @since 3.0.0 + * + * @return {number} [description] + */ + getElapsed: function () + { + return this.elapsed; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#getElapsedSeconds + * @since 3.0.0 + * + * @return {number} [description] + */ + getElapsedSeconds: function () + { + return this.elapsed * 0.001; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#remove + * @since 3.0.0 + * + * @param {function} dispatchCallback - [description] + */ + remove: function (dispatchCallback) + { + if (dispatchCallback === undefined) { dispatchCallback = false; } + + this.elapsed = this.delay; + + this.hasDispatched = !dispatchCallback; + + this.repeatCount = 0; + }, + + /** + * [description] + * + * @method Phaser.Time.TimerEvent#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.callback = undefined; + this.callbackScope = undefined; + this.args = []; + } + +}); + +module.exports = TimerEvent; + + +/***/ }), +/* 220 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var CONST = __webpack_require__(28); +var GameObject = __webpack_require__(17); +var StaticTilemapLayerRender = __webpack_require__(473); +var TilemapComponents = __webpack_require__(111); +var TransformMatrix = __webpack_require__(42); +var Utils = __webpack_require__(9); + +/** + * @classdesc + * A Static Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. + * + * A Static Tilemap Layer is optimized for rendering speed over flexibility. You cannot apply per-tile + * effects like tint or alpha, or change the tiles or tilesets the layer uses. + * + * Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features. + * + * @class StaticTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + */ +var StaticTilemapLayer = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + StaticTilemapLayerRender + ], + + initialize: + + function StaticTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) + { + GameObject.call(this, scene, 'StaticTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + // Link the LayerData with this static tilemap layer + this.layer.tilemapLayer = this; + + /** + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tileset = []; + + /** + * Used internally by the Canvas renderer. + * This holds the tiles that are visible within the camera in the last frame. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + /** + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#skipCull + * @type {boolean} + * @since 3.12.0 + */ + this.skipCull = false; + + /** + * Canvas only. + * + * The total number of tiles drawn by the renderer in the last frame. + * + * This only works when rending with Canvas. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilesDrawn + * @type {integer} + * @readonly + * @since 3.12.0 + */ + this.tilesDrawn = 0; + + /** + * Canvas only. + * + * The total number of tiles in this layer. Updated every frame. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilesTotal + * @type {integer} + * @readonly + * @since 3.12.0 + */ + this.tilesTotal = this.layer.width * this.layer.height; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullPaddingX + * @type {integer} + * @default 1 + * @since 3.12.0 + */ + this.cullPaddingX = 1; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullPaddingY + * @type {integer} + * @default 1 + * @since 3.12.0 + */ + this.cullPaddingY = 1; + + /** + * Canvas only. + * + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1) The Phaser.Tilemaps.LayerData object for this Layer + * 2) The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3) A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullCallback + * @type {function} + * @since 3.12.0 + */ + this.cullCallback = TilemapComponents.CullTiles; + + /** + * A reference to the renderer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @private + * @since 3.0.0 + */ + this.renderer = scene.sys.game.renderer; + + /** + * An array of vertex buffer objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer + * @type {WebGLBuffer[]} + * @private + * @since 3.0.0 + */ + this.vertexBuffer = []; + + /** + * An array of ArrayBuffer objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData + * @type {ArrayBuffer[]} + * @private + * @since 3.0.0 + */ + this.bufferData = []; + + /** + * An array of Float32 Array objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 + * @type {Float32Array[]} + * @private + * @since 3.0.0 + */ + this.vertexViewF32 = []; + + /** + * An array of Uint32 Array objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 + * @type {Uint32Array[]} + * @private + * @since 3.0.0 + */ + this.vertexViewU32 = []; + + /** + * An array of booleans, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single boolean. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#dirty + * @type {boolean[]} + * @private + * @since 3.0.0 + */ + this.dirty = []; + + /** + * An array of integers, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single integer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount + * @type {integer[]} + * @private + * @since 3.0.0 + */ + this.vertexCount = []; + + /** + * The rendering (draw) order of the tiles in this layer. + * + * The default is 0 which is 'right-down', meaning it will draw the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#_renderOrder + * @type {integer} + * @default 0 + * @private + * @since 3.12.0 + */ + this._renderOrder = 0; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#_tempMatrix + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.14.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#gidMap + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.14.0 + */ + this.gidMap = []; + + this.setTilesets(tileset); + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.updateVBOData(); + + this.initPipeline('TextureTintPipeline'); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.updateVBOData(); + }, this); + } + }, + + /** + * Populates the internal `tileset` array with the Tileset references this Layer requires for rendering. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTilesets + * @private + * @since 3.14.0 + * + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + */ + setTilesets: function (tilesets) + { + var gidMap = []; + var setList = []; + var map = this.tilemap; + + if (!Array.isArray(tilesets)) + { + tilesets = [ tilesets ]; + } + + for (var i = 0; i < tilesets.length; i++) + { + var tileset = tilesets[i]; + + if (typeof tileset === 'string') + { + tileset = map.getTileset(tileset); + } + + if (tileset) + { + setList.push(tileset); + + var s = tileset.firstgid; + + for (var t = 0; t < tileset.total; t++) + { + gidMap[s + t] = tileset; + } + } + } + + this.gidMap = gidMap; + this.tileset = setList; + }, + + /** + * Prepares the VBO data arrays for population by the `upload` method. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#updateVBOData + * @private + * @since 3.14.0 + * + * @return {this} This Tilemap Layer object. + */ + updateVBOData: function () + { + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + this.vertexCount[i] = 0; + this.vertexBuffer[i] = null; + this.bufferData[i] = null; + this.vertexViewF32[i] = null; + this.vertexViewU32[i] = null; + } + + return this; + }, + + /** + * Upload the tile data to a VBO. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#upload + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. + * @param {integer} tilesetIndex - The tileset index. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + upload: function (camera, tilesetIndex) + { + var renderer = this.renderer; + var gl = renderer.gl; + + var pipeline = renderer.pipelines.TextureTintPipeline; + + if (this.dirty[tilesetIndex]) + { + var tileset = this.tileset[tilesetIndex]; + var mapWidth = this.layer.width; + var mapHeight = this.layer.height; + var width = tileset.image.source[0].width; + var height = tileset.image.source[0].height; + var mapData = this.layer.data; + var tile; + var row; + var col; + var renderOrder = this._renderOrder; + var minTileIndex = tileset.firstgid; + var maxTileIndex = tileset.firstgid + tileset.total; + + var vertexBuffer = this.vertexBuffer[tilesetIndex]; + var bufferData = this.bufferData[tilesetIndex]; + var vOffset = -1; + var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; + + this.vertexCount[tilesetIndex] = 0; + + if (bufferData === null) + { + bufferData = new ArrayBuffer(bufferSize); + + this.bufferData[tilesetIndex] = bufferData; + + this.vertexViewF32[tilesetIndex] = new Float32Array(bufferData); + this.vertexViewU32[tilesetIndex] = new Uint32Array(bufferData); + } + + if (renderOrder === 0) + { + // right-down + + for (row = 0; row < mapHeight; row++) + { + for (col = 0; col < mapWidth; col++) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 1) + { + // left-down + + for (row = 0; row < mapHeight; row++) + { + for (col = mapWidth - 1; col >= 0; col--) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 2) + { + // right-up + + for (row = mapHeight - 1; row >= 0; row--) + { + for (col = 0; col < mapWidth; col++) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 3) + { + // left-up + + for (row = mapHeight - 1; row >= 0; row--) + { + for (col = mapWidth - 1; col >= 0; col--) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + + this.dirty[tilesetIndex] = false; + + if (vertexBuffer === null) + { + vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); + + this.vertexBuffer[tilesetIndex] = vertexBuffer; + } + else + { + renderer.setVertexBuffer(vertexBuffer); + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); + } + } + + return this; + }, + + /** + * Add a single tile into the batch. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#batchTile + * @private + * @since 3.12.0 + * + * @param {integer} vOffset - The vertex offset. + * @param {any} tile - The tile being rendered. + * @param {any} tileset - The tileset being used for rendering. + * @param {integer} width - The width of the layer. + * @param {integer} height - The height of the layer. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the layer is being rendered with. + * @param {integer} tilesetIndex - The tileset index. + * + * @return {integer} The new vOffset value. + */ + batchTile: function (vOffset, tile, tileset, width, height, camera, tilesetIndex) + { + var texCoords = tileset.getTileTextureCoordinates(tile.index); + + if (!texCoords) + { + return vOffset; + } + + var u0 = texCoords.x / width; + var v0 = texCoords.y / height; + var u1 = (texCoords.x + tile.width) / width; + var v1 = (texCoords.y + tile.height) / height; + + var matrix = this._tempMatrix; + + var tileWidth = tile.width; + var tileHeight = tile.height; + + var halfTileWidth = tileWidth / 2; + var halfTileHeight = tileHeight / 2; + + var x = -halfTileWidth; + var y = -halfTileHeight; + + if (tile.flipX) + { + tileWidth *= -1; + x += tile.width; + } + + if (tile.flipY) + { + tileHeight *= -1; + y += tile.height; + } + + var xw = x + tileWidth; + var yh = y + tileHeight; + + matrix.applyITRS(halfTileWidth + tile.pixelX, halfTileHeight + tile.pixelY, tile.rotation, 1, 1); + + var tint = Utils.getTintAppendFloatAlpha(0xffffff, camera.alpha * this.alpha * tile.alpha); + + var tx0 = matrix.getX(x, y); + var ty0 = matrix.getY(x, y); + + var tx1 = matrix.getX(x, yh); + var ty1 = matrix.getY(x, yh); + + var tx2 = matrix.getX(xw, yh); + var ty2 = matrix.getY(xw, yh); + + var tx3 = matrix.getX(xw, y); + var ty3 = matrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + var vertexViewF32 = this.vertexViewF32[tilesetIndex]; + var vertexViewU32 = this.vertexViewU32[tilesetIndex]; + + vertexViewF32[++vOffset] = tx0; + vertexViewF32[++vOffset] = ty0; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx1; + vertexViewF32[++vOffset] = ty1; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx2; + vertexViewF32[++vOffset] = ty2; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx0; + vertexViewF32[++vOffset] = ty0; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx2; + vertexViewF32[++vOffset] = ty2; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx3; + vertexViewF32[++vOffset] = ty3; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + this.vertexCount[tilesetIndex] += 6; + + return vOffset; + }, + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap Layer object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'string') + { + renderOrder = orders.indexOf(renderOrder); + } + + if (renderOrder >= 0 && renderOrder < 4) + { + this._renderOrder = renderOrder; + + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + } + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return this.cullCallback(this.layer, camera, this.culledTiles); + }, + + /** + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setSkipCull + * @since 3.12.0 + * + * @param {boolean} [value=true] - Set to `true` to stop culling tiles. Set to `false` to enable culling again. + * + * @return {this} This Tilemap Layer object. + */ + setSkipCull: function (value) + { + if (value === undefined) { value = true; } + + this.skipCull = value; + + return this; + }, + + /** + * Canvas only. + * + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCullPadding + * @since 3.12.0 + * + * @param {integer} [paddingX=1] - The amount of extra horizontal tiles to add to the cull check padding. + * @param {integer} [paddingY=1] - The amount of extra vertical tiles to add to the cull check padding. + * + * @return {this} This Tilemap Layer object. + */ + setCullPadding: function (paddingX, paddingY) + { + if (paddingX === undefined) { paddingX = 1; } + if (paddingY === undefined) { paddingY = 1; } + + this.cullPaddingX = paddingX; + this.cullPaddingY = paddingY; + + return this; + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * + * @return {boolean} + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {boolean} + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} [callbackContext] - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); + }, + + /** + * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.culledTiles.length = 0; + this.cullCallback = null; + + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + this.vertexCount[i] = 0; + this.vertexBuffer[i] = null; + this.bufferData[i] = null; + this.vertexViewF32[i] = null; + this.vertexViewU32[i] = null; + } + + this.gidMap = []; + this.tileset = []; + + GameObject.prototype.destroy.call(this); + } + +}); + +module.exports = StaticTilemapLayer; + + +/***/ }), +/* 221 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var DynamicTilemapLayerRender = __webpack_require__(476); +var GameObject = __webpack_require__(17); +var TilemapComponents = __webpack_require__(111); + +/** + * @classdesc + * A Dynamic Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. + * + * A Dynamic Tilemap Layer trades some speed for being able to apply powerful effects. Unlike a + * Static Tilemap Layer, you can apply per-tile effects like tint or alpha, and you can change the + * tiles in a DynamicTilemapLayer. + * + * Use this over a Static Tilemap Layer when you need those features. + * + * @class DynamicTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + */ +var DynamicTilemapLayer = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + DynamicTilemapLayerRender + ], + + initialize: + + function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) + { + GameObject.call(this, scene, 'DynamicTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + // Link the LayerData with this static tilemap layer + this.layer.tilemapLayer = this; + + /** + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tileset = []; + + /** + * Used internally with the canvas render. This holds the tiles that are visible within the + * camera. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#skipCull + * @type {boolean} + * @since 3.11.0 + */ + this.skipCull = false; + + /** + * The total number of tiles drawn by the renderer in the last frame. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilesDrawn + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.tilesDrawn = 0; + + /** + * The total number of tiles in this layer. Updated every frame. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilesTotal + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.tilesTotal = this.layer.width * this.layer.height; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingX + * @type {integer} + * @default 1 + * @since 3.11.0 + */ + this.cullPaddingX = 1; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingY + * @type {integer} + * @default 1 + * @since 3.11.0 + */ + this.cullPaddingY = 1; + + /** + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1) The Phaser.Tilemaps.LayerData object for this Layer + * 2) The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3) A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullCallback + * @type {function} + * @since 3.11.0 + */ + this.cullCallback = TilemapComponents.CullTiles; + + /** + * The rendering (draw) order of the tiles in this layer. + * + * The default is 0 which is 'right-down', meaning it will draw the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#_renderOrder + * @type {integer} + * @default 0 + * @private + * @since 3.12.0 + */ + this._renderOrder = 0; + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#gidMap + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.14.0 + */ + this.gidMap = []; + + this.setTilesets(tileset); + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.initPipeline('TextureTintPipeline'); + }, + + /** + * Populates the internal `tileset` array with the Tileset references this Layer requires for rendering. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTilesets + * @private + * @since 3.14.0 + * + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + */ + setTilesets: function (tilesets) + { + var gidMap = []; + var setList = []; + var map = this.tilemap; + + if (!Array.isArray(tilesets)) + { + tilesets = [ tilesets ]; + } + + for (var i = 0; i < tilesets.length; i++) + { + var tileset = tilesets[i]; + + if (typeof tileset === 'string') + { + tileset = map.getTileset(tileset); + } + + if (tileset) + { + setList.push(tileset); + + var s = tileset.firstgid; + + for (var t = 0; t < tileset.total; t++) + { + gidMap[s + t] = tileset; + } + } + } + + this.gidMap = gidMap; + this.tileset = setList; + }, + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap Layer object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'string') + { + renderOrder = orders.indexOf(renderOrder); + } + + if (renderOrder >= 0 && renderOrder < 4) + { + this._renderOrder = renderOrder; + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return this.cullCallback(this.layer, camera, this.culledTiles, this._renderOrder); + }, + + /** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#copy + * @since 3.0.0 + * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces) + { + TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.culledTiles.length = 0; + this.cullCallback = null; + + this.gidMap = []; + this.tileset = []; + + GameObject.prototype.destroy.call(this); + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#fill + * @since 3.0.0 + * + * @param {integer} index - The tile index to fill the area with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer); + + return this; + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * + * @return {boolean} `true` if a tile was found at the given location, otherwise `false`. + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * + * @return {boolean} `true` if a tile was found at the given location, otherwise `false`. + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces) + { + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera) + { + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + randomize: function (tileX, tileY, width, height, indexes) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer); + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces) + { + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera) + { + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setSkipCull + * @since 3.11.0 + * + * @param {boolean} [value=true] - Set to `true` to stop culling tiles. Set to `false` to enable culling again. + * + * @return {this} This Tilemap Layer object. + */ + setSkipCull: function (value) + { + if (value === undefined) { value = true; } + + this.skipCull = value; + + return this; + }, + + /** + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCullPadding + * @since 3.11.0 + * + * @param {integer} [paddingX=1] - The amount of extra horizontal tiles to add to the cull check padding. + * @param {integer} [paddingY=1] - The amount of extra vertical tiles to add to the cull check padding. + * + * @return {this} This Tilemap Layer object. + */ + setCullPadding: function (paddingX, paddingY) + { + if (paddingX === undefined) { paddingX = 1; } + if (paddingY === undefined) { paddingY = 1; } + + this.cullPaddingX = paddingX; + this.cullPaddingY = paddingY; + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} [callbackContext] - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + shuffle: function (tileX, tileY, width, height) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer); + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); + } + +}); + +module.exports = DynamicTilemapLayer; + + +/***/ }), +/* 222 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(36); +var DynamicTilemapLayer = __webpack_require__(221); +var Extend = __webpack_require__(21); +var Formats = __webpack_require__(30); +var LayerData = __webpack_require__(87); +var Rotate = __webpack_require__(270); +var StaticTilemapLayer = __webpack_require__(220); +var Tile = __webpack_require__(61); +var TilemapComponents = __webpack_require__(111); +var Tileset = __webpack_require__(107); + +/** + * @callback TilemapFilterCallback + * + * @param {Phaser.GameObjects.GameObject} value - An object found in the filtered area. + * @param {number} index - The index of the object within the array. + * @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found. + * + * @return {Phaser.GameObjects.GameObject} The object. + */ + +/** + * @callback TilemapFindCallback + * + * @param {Phaser.GameObjects.GameObject} value - An object found. + * @param {number} index - The index of the object within the array. + * @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found. + * + * @return {boolean} `true` if the callback should be invoked, otherwise `false`. + */ + +/** + * @classdesc + * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data + * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or + * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display + * objects that actually render tiles. + * + * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free + * software package specifically for creating tile maps, and is available from: + * http://www.mapeditor.org + * + * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only + * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. + * + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a + * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides + * it. + * + * @class Tilemap + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {Phaser.Tilemaps.MapData} mapData - A MapData instance containing Tilemap data. + */ +var Tilemap = new Class({ + + initialize: + + function Tilemap (scene, mapData) + { + /** + * @name Phaser.Tilemaps.Tilemap#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The base width of a tile in pixels. Note that individual layers may have a different tile + * width. + * + * @name Phaser.Tilemaps.Tilemap#tileWidth + * @type {integer} + * @since 3.0.0 + */ + this.tileWidth = mapData.tileWidth; + + /** + * The base height of a tile in pixels. Note that individual layers may have a different + * tile height. + * + * @name Phaser.Tilemaps.Tilemap#tileHeight + * @type {integer} + * @since 3.0.0 + */ + this.tileHeight = mapData.tileHeight; + + /** + * The width of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#width + * @type {number} + * @since 3.0.0 + */ + this.width = mapData.width; + + /** + * The height of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#height + * @type {number} + * @since 3.0.0 + */ + this.height = mapData.height; + + /** + * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. + * + * @name Phaser.Tilemaps.Tilemap#orientation + * @type {string} + * @since 3.0.0 + */ + this.orientation = mapData.orientation; + + /** + * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. + * + * The draw orders are: + * + * right-down + * left-down + * right-up + * left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.Tilemap#renderOrder + * @type {string} + * @since 3.12.0 + */ + this.renderOrder = mapData.renderOrder; + + /** + * The format of the map data. + * + * @name Phaser.Tilemaps.Tilemap#format + * @type {number} + * @since 3.0.0 + */ + this.format = mapData.format; + + /** + * The version of the map data (as specified in Tiled, usually 1). + * + * @name Phaser.Tilemaps.Tilemap#version + * @type {number} + * @since 3.0.0 + */ + this.version = mapData.version; + + /** + * Map specific properties as specified in Tiled. + * + * @name Phaser.Tilemaps.Tilemap#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = mapData.properties; + + /** + * The width of the map in pixels based on width * tileWidth. + * + * @name Phaser.Tilemaps.Tilemap#widthInPixels + * @type {number} + * @since 3.0.0 + */ + this.widthInPixels = mapData.widthInPixels; + + /** + * The height of the map in pixels based on height * tileHeight. + * + * @name Phaser.Tilemaps.Tilemap#heightInPixels + * @type {number} + * @since 3.0.0 + */ + this.heightInPixels = mapData.heightInPixels; + + /** + * + * @name Phaser.Tilemaps.Tilemap#imageCollections + * @type {Phaser.Tilemaps.ImageCollection[]} + * @since 3.0.0 + */ + this.imageCollections = mapData.imageCollections; + + /** + * An array of Tiled Image Layers. + * + * @name Phaser.Tilemaps.Tilemap#images + * @type {array} + * @since 3.0.0 + */ + this.images = mapData.images; + + /** + * An array of Tilemap layer data. + * + * @name Phaser.Tilemaps.Tilemap#layers + * @type {Phaser.Tilemaps.LayerData[]} + * @since 3.0.0 + */ + this.layers = mapData.layers; + + /** + * An array of Tilesets used in the map. + * + * @name Phaser.Tilemaps.Tilemap#tilesets + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tilesets = mapData.tilesets; + + /** + * An array of ObjectLayer instances parsed from Tiled object layers. + * + * @name Phaser.Tilemaps.Tilemap#objects + * @type {Phaser.Tilemaps.ObjectLayer[]} + * @since 3.0.0 + */ + this.objects = mapData.objects; + + /** + * The index of the currently selected LayerData object. + * + * @name Phaser.Tilemaps.Tilemap#currentLayerIndex + * @type {integer} + * @since 3.0.0 + */ + this.currentLayerIndex = 0; + }, + + /** + * Sets the rendering (draw) order of the tiles in this map. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * Calling this method _after_ creating Static or Dynamic Tilemap Layers will **not** automatically + * update them to use the new render order. If you call this method after creating layers, use their + * own `setRenderOrder` methods to change them as needed. + * + * @method Phaser.Tilemaps.Tilemap#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'number') + { + renderOrder = orders[renderOrder]; + } + + if (orders.indexOf(renderOrder) > -1) + { + this.renderOrder = renderOrder; + } + + return this; + }, + + /** + * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. + * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled + * editor. + * + * @method Phaser.Tilemaps.Tilemap#addTilesetImage + * @since 3.0.0 + * + * @param {string} tilesetName - The name of the tileset as specified in the map data. + * @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If + * `undefined` or `null` it will look for an image with a key matching the tilesetName parameter. + * @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not + * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled + * JSON file. + * @param {integer} [tileHeight] - The height of the tiles (in pixels) in the Tileset Image. If + * not given it will default to the map's tileHeight value, or the tileHeight specified in the + * Tiled JSON file. + * @param {integer} [tileMargin] - The margin around the tiles in the sheet (in pixels). If not + * specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [tileSpacing] - The spacing between each the tile in the sheet (in pixels). + * If not specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [gid=0] - If adding multiple tilesets to a blank map, specify the starting + * GID this set will use here. + * + * @return {?Phaser.Tilemaps.Tileset} Returns the Tileset object that was created or updated, or null if it + * failed. + */ + addTilesetImage: function (tilesetName, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) + { + if (tilesetName === undefined) { return null; } + if (key === undefined || key === null) { key = tilesetName; } + + if (!this.scene.sys.textures.exists(key)) + { + console.warn('Invalid Tileset Image: ' + key); + return null; + } + + var texture = this.scene.sys.textures.get(key); + + var index = this.getTilesetIndex(tilesetName); + + if (index === null && this.format === Formats.TILED_JSON) + { + console.warn('No data found for Tileset: ' + tilesetName); + return null; + } + + var tileset = this.tilesets[index]; + + if (tileset) + { + tileset.setTileSize(tileWidth, tileHeight); + tileset.setSpacing(tileMargin, tileSpacing); + tileset.setImage(texture); + + return tileset; + } + + if (tileWidth === undefined) { tileWidth = this.tileWidth; } + if (tileHeight === undefined) { tileHeight = this.tileHeight; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (gid === undefined) { gid = 0; } + + tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); + + tileset.setImage(texture); + + this.tilesets.push(tileset); + + return tileset; + }, + + /** + * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If + * no layer specified, the map's current layer is used. This is useful if you want to manipulate + * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. + * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value + * returned from this method if you want to manipulate the new StaticTilemapLayer. + * + * @method Phaser.Tilemaps.Tilemap#convertLayerToStatic + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer)} [layer] - The name of the layer from Tiled, the + * index of the layer in the map, or a DynamicTilemapLayer. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer that was created, or null if it + * failed. + */ + convertLayerToStatic: function (layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + var dynamicLayer = layer.tilemapLayer; + + if (!dynamicLayer || !(dynamicLayer instanceof DynamicTilemapLayer)) + { + return null; + } + + var staticLayer = new StaticTilemapLayer( + dynamicLayer.scene, + dynamicLayer.tilemap, + dynamicLayer.layerIndex, + dynamicLayer.tileset, + dynamicLayer.x, + dynamicLayer.y + ); + + this.scene.sys.displayList.add(staticLayer); + + dynamicLayer.destroy(); + + return staticLayer; + }, + + /** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#copy + * @since 3.0.0 + * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'copy')) { return this; } + + if (layer !== null) + { + TilemapComponents.Copy( + srcTileX, srcTileY, + width, height, + destTileX, destTileY, + recalculateFaces, layer + ); + } + + return this; + }, + + /** + * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set to this new layer. + * + * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer + * @since 3.0.0 + * + * @param {string} name - The name of this layer. Must be unique within the map. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + * @param {integer} [width] - The width of the layer in tiles. If not specified, it will default to the map's width. + * @param {integer} [height] - The height of the layer in tiles. If not specified, it will default to the map's height. + * @param {integer} [tileWidth] - The width of the tiles the layer uses for calculations. If not specified, it will default to the map's tileWidth. + * @param {integer} [tileHeight] - The height of the tiles the layer uses for calculations. If not specified, it will default to the map's tileHeight. + * + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) + { + if (tileWidth === undefined) { tileWidth = tileset.tileWidth; } + if (tileHeight === undefined) { tileHeight = tileset.tileHeight; } + if (width === undefined) { width = this.width; } + if (height === undefined) { height = this.height; } + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + var index = this.getLayerIndex(name); + + if (index !== null) + { + console.warn('Invalid Tilemap Layer ID: ' + name); + return null; + } + + var layerData = new LayerData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + + var row; + + for (var tileY = 0; tileY < height; tileY++) + { + row = []; + + for (var tileX = 0; tileX < width; tileX++) + { + row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight)); + } + + layerData.data.push(row); + } + + this.layers.push(layerData); + + this.currentLayerIndex = this.layers.length - 1; + + var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); + + dynamicLayer.setRenderOrder(this.renderOrder); + + this.scene.sys.displayList.add(dynamicLayer); + + return dynamicLayer; + }, + + /** + * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more + * information. + * + * @method Phaser.Tilemaps.Tilemap#createDynamicLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createDynamicLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Invalid Tilemap Layer ID: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Tilemap Layer ID already exists:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); + + layer.setRenderOrder(this.renderOrder); + + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Creates a Sprite for every object matching the given gid in the map data. All properties from + * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy + * way to configure Sprite properties from within the map editor. For example giving an object a + * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. + * + * Custom object properties not sharing names with the Sprite's own properties are copied to the + * Sprite's {@link Phaser.GameObjects.Sprite#data data store}. + * + * @method Phaser.Tilemaps.Tilemap#createFromObjects + * @since 3.0.0 + * + * @param {string} name - The name of the object layer (from Tiled) to create Sprites from. + * @param {(integer|string)} id - Either the id (object), gid (tile object) or name (object or + * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects + * with the same graphic. The same name can be used on multiple objects. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromObjects: function (name, id, spriteConfig, scene) + { + if (spriteConfig === undefined) { spriteConfig = {}; } + if (scene === undefined) { scene = this.scene; } + + var objectLayer = this.getObjectLayer(name); + if (!objectLayer) + { + console.warn('Cannot create from object. Invalid objectgroup name given: ' + name); + return; + } + + var objects = objectLayer.objects; + var sprites = []; + + for (var i = 0; i < objects.length; i++) + { + var found = false; + var obj = objects[i]; + + if (obj.gid !== undefined && typeof id === 'number' && obj.gid === id || + obj.id !== undefined && typeof id === 'number' && obj.id === id || + obj.name !== undefined && typeof id === 'string' && obj.name === id) + { + found = true; + } + + if (found) + { + var config = Extend({}, spriteConfig, obj.properties); + + config.x = obj.x; + config.y = obj.y; + + var sprite = this.scene.make.sprite(config); + + sprite.name = obj.name; + + if (obj.width) { sprite.displayWidth = obj.width; } + if (obj.height) { sprite.displayHeight = obj.height; } + + // Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin. + var offset = { + x: sprite.originX * sprite.displayWidth, + y: (sprite.originY - 1) * sprite.displayHeight + }; + + // If the object is rotated, then the origin offset also needs to be rotated. + if (obj.rotation) + { + var angle = DegToRad(obj.rotation); + Rotate(offset, angle); + sprite.rotation = angle; + } + + sprite.x += offset.x; + sprite.y += offset.y; + + if (obj.flippedHorizontal !== undefined || obj.flippedVertical !== undefined) + { + sprite.setFlip(obj.flippedHorizontal, obj.flippedVertical); + } + + if (!obj.visible) { sprite.visible = false; } + + for (var key in obj.properties) + { + if (sprite.hasOwnProperty(key)) + { + continue; + } + + sprite.setData(key, obj.properties[key]); + } + + sprites.push(sprite); + } + } + + return sprites; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.Tilemap#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.GameObjects.Sprite[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, layer); + }, + + /** + * Creates a new StaticTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for + * more information. + * + * @method Phaser.Tilemaps.Tilemap#createStaticLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createStaticLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Invalid Tilemap Layer ID: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Tilemap Layer ID already exists:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); + + layer.setRenderOrder(this.renderOrder); + + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any + * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. + * + * @method Phaser.Tilemaps.Tilemap#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllLayers(); + this.tilesets.length = 0; + this.objects.length = 0; + this.scene = undefined; + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * If no layer specified, the map's current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#fill + * @since 3.0.0 + * + * @param {integer} index - The tile index to fill the area with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'fill')) { return this; } + + if (layer !== null) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, layer); + } + + return this; + }, + + /** + * For each object in the given object layer, run the given filter callback function. Any + * objects that pass the filter test (i.e. where the callback returns true) will returned as a + * new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#filterObjects + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param {TilemapFilterCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject[]} An array of object that match the search, or null if the objectLayer given was invalid. + */ + filterObjects: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.filter(callback, context); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to apply the filter on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to run the search on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findByIndex: function (findIndex, skip, reverse, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindByIndex(findIndex, skip, reverse, layer); + }, + + /** + * Find the first object in the given object layer that satisfies the provided testing function. + * I.e. finds the first object for which `callback` returns true. Similar to + * Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#findObject + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param {TilemapFindCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject} An object that matches the search, or null if no object found. + */ + findObject: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.find(callback, context) || null; + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to run the search on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#forEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to run the search on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer !== null) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + } + + return this; + }, + + /** + * Gets the image layer index based on its name. + * + * @method Phaser.Tilemaps.Tilemap#getImageIndex + * @since 3.0.0 + * + * @param {string} name - The name of the image to get. + * + * @return {integer} The index of the image in this tilemap, or null if not found. + */ + getImageIndex: function (name) + { + return this.getIndex(this.images, name); + }, + + /** + * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name + * property matches the given `name`. + * + * @method Phaser.Tilemaps.Tilemap#getIndex + * @since 3.0.0 + * + * @param {array} location - The Tilemap array to search. + * @param {string} name - The name of the array element to get. + * + * @return {number} The index of the element in the array, or null if not found. + */ + getIndex: function (location, name) + { + for (var i = 0; i < location.length; i++) + { + if (location[i].name === name) + { + return i; + } + } + + return null; + }, + + /** + * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the maps current layer index. + * + * @return {Phaser.Tilemaps.LayerData} The corresponding LayerData within this.layers. + */ + getLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + return index !== null ? this.layers[index] : null; + }, + + /** + * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer + * is found with that name. + * + * @method Phaser.Tilemaps.Tilemap#getObjectLayer + * @since 3.0.0 + * + * @param {string} [name] - The name of the object layer from Tiled. + * + * @return {?Phaser.Tilemaps.ObjectLayer} The corresponding ObjectLayer within this.objects or null. + */ + getObjectLayer: function (name) + { + var index = this.getIndex(this.objects, name); + + return index !== null ? this.objects[index] : null; + }, + + /** + * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndex + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndex: function (layer) + { + if (layer === undefined) + { + return this.currentLayerIndex; + } + else if (typeof layer === 'string') + { + return this.getLayerIndexByName(layer); + } + else if (typeof layer === 'number' && layer < this.layers.length) + { + return layer; + } + else if (layer instanceof StaticTilemapLayer || layer instanceof DynamicTilemapLayer) + { + return layer.layerIndex; + } + else + { + return null; + } + }, + + /** + * Gets the index of the LayerData within this.layers that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndexByName + * @since 3.0.0 + * + * @param {string} name - The name of the layer to get. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndexByName: function (name) + { + return this.getIndex(this.layers, name); + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAt: function (tileX, tileY, nonNull, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) + { + return null; + } + else + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, layer); + } + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinShape: function (shape, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); + }, + + /** + * Gets the Tileset that has the given `name`, or null if an invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getTileset + * @since 3.14.0 + * + * @param {string} name - The name of the Tileset to get. + * + * @return {?Phaser.Tilemaps.Tileset} The Tileset, or `null` if no matching named tileset was found. + */ + getTileset: function (name) + { + var index = this.getIndex(this.tilesets, name); + + return (index !== null) ? this.tilesets[index] : null; + }, + + /** + * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getTilesetIndex + * @since 3.0.0 + * + * @param {string} name - The name of the Tileset to get. + * + * @return {integer} The Tileset index within this.tilesets. + */ + getTilesetIndex: function (name) + { + return this.getIndex(this.tilesets, name); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAt(tileX, tileY, layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAtWorldXY: function (worldX, worldY, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, layer); + }, + + /** + * The LayerData object that is currently selected in the map. You can set this property using + * any type supported by setLayer. + * + * @name Phaser.Tilemaps.Tilemap#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + layer: { + get: function () + { + return this.layers[this.currentLayerIndex]; + }, + + set: function (layer) + { + this.setLayer(layer); + } + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. + * + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid or the coordinates were out of bounds. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTilesAt')) { return this; } + + if (layer !== null) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, layer); + } + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + randomize: function (tileX, tileY, width, height, indexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'randomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, layer); + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesAt(tileX, tileY, layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesWithin: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, layer); + + return this; + }, + + /** + * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or + * DynamicTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeAllLayers + * @since 3.0.0 + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + removeAllLayers: function () + { + // Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData + for (var i = 0; i < this.layers.length; i++) + { + if (this.layers[i].tilemapLayer) + { + this.layers[i].tilemapLayer.destroy(); + } + } + + this.layers.length = 0; + this.currentLayerIndex = 0; + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + renderDebug: function (graphics, styleConfig, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.RenderDebug(graphics, styleConfig, layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'replaceByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollision: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileIndexCallback: function (indexes, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} [callbackContext] - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets the current layer to the LayerData associated with `layer`. + * + * @method Phaser.Tilemaps.Tilemap#setLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + if (index !== null) + { + this.currentLayerIndex = index; + } + + return this; + }, + + /** + * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and + * tileHeight for all layers. This also updates the base size on all tiles across all layers. + * + * @method Phaser.Tilemaps.Tilemap#setBaseTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles the map uses for calculations. + * @param {integer} tileHeight - The height of the tiles the map uses for calculations. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setBaseTileSize: function (tileWidth, tileHeight) + { + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.widthInPixels = this.width * tileWidth; + this.heightInPixels = this.height * tileHeight; + + // Update the base tile size on all layers & tiles + for (var i = 0; i < this.layers.length; i++) + { + this.layers[i].baseTileWidth = tileWidth; + this.layers[i].baseTileHeight = tileHeight; + + var mapData = this.layers[i].data; + var mapWidth = this.layers[i].width; + var mapHeight = this.layers[i].height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) + { + tile.setSize(undefined, undefined, tileWidth, tileHeight); + } + } + } + } + + return this; + }, + + /** + * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's + * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any + * tiles the layer has. + * + * @method Phaser.Tilemaps.Tilemap#setLayerTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles (in pixels) in the layer. + * @param {integer} tileHeight - The height of the tiles (in pixels) in the layer. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayerTileSize: function (tileWidth, tileHeight, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + layer.tileWidth = tileWidth; + layer.tileHeight = tileHeight; + + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) { tile.setSize(tileWidth, tileHeight); } + } + } + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + shuffle: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'shuffle')) { return this; } + + if (layer !== null) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'swapByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldX: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldX(tileX, camera, layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldY: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldY(tileX, camera, layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + tileToWorldXY: function (tileX, tileY, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the map's current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'weightedRandomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, layer); + } + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileX: function (worldX, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileY: function (worldY, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer); + }, + + /** + * Used internally to check if a layer is static and prints out a warning. + * + * @method Phaser.Tilemaps.Tilemap#_isStaticCall + * @private + * @since 3.0.0 + * + * @return {boolean} + */ + _isStaticCall: function (layer, functionName) + { + if (layer.tilemapLayer instanceof StaticTilemapLayer) + { + console.warn(functionName + ': You cannot change the tiles in a static tilemap layer'); + return true; + } + else + { + return false; + } + } + +}); + +module.exports = Tilemap; + + +/***/ }), +/* 223 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(30); +var MapData = __webpack_require__(86); +var ParseTileLayers = __webpack_require__(478); +var ParseTilesets = __webpack_require__(477); + +/** + * @namespace Phaser.Tilemaps.Parsers.Impact + */ + +/** + * Parses a Weltmeister JSON object into a new MapData object. + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Weltmeister JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {?object} [description] + */ +var ParseWeltmeister = function (name, json, insertNull) +{ + if (json.layer.length === 0) + { + console.warn('No layers found in the Weltmeister map: ' + name); + return null; + } + + var width = 0; + var height = 0; + + for (var i = 0; i < json.layer.length; i++) + { + if (json.layer[i].width > width) { width = json.layer[i].width; } + if (json.layer[i].height > height) { height = json.layer[i].height; } + } + + var mapData = new MapData({ + width: width, + height: height, + name: name, + tileWidth: json.layer[0].tilesize, + tileHeight: json.layer[0].tilesize, + format: Formats.WELTMEISTER + }); + + mapData.layers = ParseTileLayers(json, insertNull); + mapData.tilesets = ParseTilesets(json); + + return mapData; +}; + +module.exports = ParseWeltmeister; + + +/***/ }), +/* 224 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(1); + +/** + * @classdesc + * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled + * object layer, except: + * - "x" & "y" properties are ignored since these cannot be changed in Tiled. + * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they + * are ignored as well. + * - "draworder" is ignored. + * + * @class ObjectLayer + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {object} [config] - [description] + */ +var ObjectLayer = new Class({ + + initialize: + + function ObjectLayer (config) + { + if (config === undefined) { config = {}; } + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#name + * @type {string} + * @since 3.0.0 + */ + this.name = GetFastValue(config, 'name', 'object layer'); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#opacity + * @type {number} + * @since 3.0.0 + */ + this.opacity = GetFastValue(config, 'opacity', 1); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = GetFastValue(config, 'properties', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#propertyTypes + * @type {object} + * @since 3.0.0 + */ + this.propertyTypes = GetFastValue(config, 'propertytypes', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#type + * @type {string} + * @since 3.0.0 + */ + this.type = GetFastValue(config, 'type', 'objectgroup'); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#visible + * @type {boolean} + * @since 3.0.0 + */ + this.visible = GetFastValue(config, 'visible', true); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#objects + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.0.0 + */ + this.objects = GetFastValue(config, 'objects', []); + } + +}); + +module.exports = ObjectLayer; + + +/***/ }), +/* 225 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Pick = __webpack_require__(482); +var ParseGID = __webpack_require__(227); + +var copyPoints = function (p) { return { x: p.x, y: p.y }; }; + +var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject + * @since 3.0.0 + * + * @param {object} tiledObject - [description] + * @param {number} [offsetX=0] - [description] + * @param {number} [offsetY=0] - [description] + * + * @return {object} [description] + */ +var ParseObject = function (tiledObject, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + var parsedObject = Pick(tiledObject, commonObjectProps); + + parsedObject.x += offsetX; + parsedObject.y += offsetY; + + if (tiledObject.gid) + { + // Object tiles + var gidInfo = ParseGID(tiledObject.gid); + parsedObject.gid = gidInfo.gid; + parsedObject.flippedHorizontal = gidInfo.flippedHorizontal; + parsedObject.flippedVertical = gidInfo.flippedVertical; + parsedObject.flippedAntiDiagonal = gidInfo.flippedAntiDiagonal; + } + else if (tiledObject.polyline) + { + parsedObject.polyline = tiledObject.polyline.map(copyPoints); + } + else if (tiledObject.polygon) + { + parsedObject.polygon = tiledObject.polygon.map(copyPoints); + } + else if (tiledObject.ellipse) + { + parsedObject.ellipse = tiledObject.ellipse; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + } + else if (tiledObject.text) + { + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + parsedObject.text = tiledObject.text; + } + else + { + // Otherwise, assume it is a rectangle + parsedObject.rectangle = true; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + } + + return parsedObject; +}; + +module.exports = ParseObject; + + +/***/ }), +/* 226 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. + * + * Image Collections are normally created automatically when Tiled data is loaded. + * + * @class ImageCollection + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {string} name - The name of the image collection in the map data. + * @param {integer} firstgid - The first image index this image collection contains. + * @param {integer} [width=32] - Width of widest image (in pixels). + * @param {integer} [height=32] - Height of tallest image (in pixels). + * @param {integer} [margin=0] - The margin around all images in the collection (in pixels). + * @param {integer} [spacing=0] - The spacing between each image in the collection (in pixels). + * @param {object} [properties={}] - Custom Image Collection properties. + */ +var ImageCollection = new Class({ + + initialize: + + function ImageCollection (name, firstgid, width, height, margin, spacing, properties) + { + if (width === undefined || width <= 0) { width = 32; } + if (height === undefined || height <= 0) { height = 32; } + if (margin === undefined) { margin = 0; } + if (spacing === undefined) { spacing = 0; } + + /** + * The name of the Image Collection. + * + * @name Phaser.Tilemaps.ImageCollection#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The Tiled firstgid value. + * This is the starting index of the first image index this Image Collection contains. + * + * @name Phaser.Tilemaps.ImageCollection#firstgid + * @type {integer} + * @since 3.0.0 + */ + this.firstgid = firstgid | 0; + + /** + * The width of the widest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageWidth + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageWidth = width | 0; + + /** + * The height of the tallest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageHeight + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageHeight = height | 0; + + /** + * The margin around the images in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageMarge + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageMargin = margin | 0; + + /** + * The spacing between each image in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageSpacing + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageSpacing = spacing | 0; + + /** + * Image Collection-specific properties that are typically defined in the Tiled editor. + * + * @name Phaser.Tilemaps.ImageCollection#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = properties || {}; + + /** + * The cached images that are a part of this collection. + * + * @name Phaser.Tilemaps.ImageCollection#images + * @type {array} + * @readonly + * @since 3.0.0 + */ + this.images = []; + + /** + * The total number of images in the image collection. + * + * @name Phaser.Tilemaps.ImageCollection#total + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.total = 0; + }, + + /** + * Returns true if and only if this image collection contains the given image index. + * + * @method Phaser.Tilemaps.ImageCollection#containsImageIndex + * @since 3.0.0 + * + * @param {integer} imageIndex - The image index to search for. + * + * @return {boolean} True if this Image Collection contains the given index. + */ + containsImageIndex: function (imageIndex) + { + return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)); + }, + + /** + * Add an image to this Image Collection. + * + * @method Phaser.Tilemaps.ImageCollection#addImage + * @since 3.0.0 + * + * @param {integer} gid - The gid of the image in the Image Collection. + * @param {string} image - The the key of the image in the Image Collection and in the cache. + * + * @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object. + */ + addImage: function (gid, image) + { + this.images.push({ gid: gid, image: image }); + this.total++; + + return this; + } + +}); + +module.exports = ImageCollection; + + +/***/ }), +/* 227 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FLIPPED_HORIZONTAL = 0x80000000; +var FLIPPED_VERTICAL = 0x40000000; +var FLIPPED_ANTI_DIAGONAL = 0x20000000; // Top-right is swapped with bottom-left corners + +/** + * See Tiled documentation on tile flipping: + * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseGID + * @since 3.0.0 + * + * @param {number} gid - [description] + * + * @return {object} [description] + */ +var ParseGID = function (gid) +{ + var flippedHorizontal = Boolean(gid & FLIPPED_HORIZONTAL); + var flippedVertical = Boolean(gid & FLIPPED_VERTICAL); + var flippedAntiDiagonal = Boolean(gid & FLIPPED_ANTI_DIAGONAL); + gid = gid & ~(FLIPPED_HORIZONTAL | FLIPPED_VERTICAL | FLIPPED_ANTI_DIAGONAL); + + // Parse the flip flags into something Phaser can use + var rotation = 0; + var flipped = false; + + if (flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = true; + } + else if (flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = true; + } + else if (!flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = false; + } + else if (!flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = false; + } + + return { + gid: gid, + flippedHorizontal: flippedHorizontal, + flippedVertical: flippedVertical, + flippedAntiDiagonal: flippedAntiDiagonal, + rotation: rotation, + flipped: flipped + }; +}; + +module.exports = ParseGID; + + +/***/ }), +/* 228 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(30); +var MapData = __webpack_require__(86); +var ParseTileLayers = __webpack_require__(486); +var ParseImageLayers = __webpack_require__(484); +var ParseTilesets = __webpack_require__(483); +var ParseObjectLayers = __webpack_require__(481); +var BuildTilesetIndex = __webpack_require__(480); +var AssignTileProperties = __webpack_require__(479); + +/** + * @namespace Phaser.Tilemaps.Parsers.Tiled + */ + +/** + * Parses a Tiled JSON object into a new MapData object. + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Tiled JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {?Phaser.Tilemaps.MapData} The created MapData object, or `null` if the data can't be parsed. + */ +var ParseJSONTiled = function (name, json, insertNull) +{ + if (json.orientation !== 'orthogonal') + { + console.warn('Only orthogonal map types are supported in this version of Phaser'); + return null; + } + + // Map data will consist of: layers, objects, images, tilesets, sizes + var mapData = new MapData({ + width: json.width, + height: json.height, + name: name, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + orientation: json.orientation, + format: Formats.TILED_JSON, + version: json.version, + properties: json.properties, + renderOrder: json.renderorder + }); + + mapData.layers = ParseTileLayers(json, insertNull); + mapData.images = ParseImageLayers(json); + + var sets = ParseTilesets(json); + mapData.tilesets = sets.tilesets; + mapData.imageCollections = sets.imageCollections; + + mapData.objects = ParseObjectLayers(json); + + mapData.tiles = BuildTilesetIndex(mapData); + + AssignTileProperties(mapData); + + return mapData; +}; + +module.exports = ParseJSONTiled; + + +/***/ }), +/* 229 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(30); +var Parse2DArray = __webpack_require__(142); + +/** + * Parses a CSV string of tile indexes into a new MapData object with a single layer. + * + * @function Phaser.Tilemaps.Parsers.ParseCSV + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {string} data - CSV string of tile indexes. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.MapData} The resulting MapData object. + */ +var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) +{ + var array2D = data + .trim() + .split('\n') + .map(function (row) { return row.split(','); }); + + var map = Parse2DArray(name, array2D, tileWidth, tileHeight, insertNull); + map.format = Formats.CSV; + + return map; +}; + +module.exports = ParseCSV; + + +/***/ }), +/* 230 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(30); +var Parse2DArray = __webpack_require__(142); +var ParseCSV = __webpack_require__(229); +var ParseJSONTiled = __webpack_require__(228); +var ParseWeltmeister = __webpack_require__(223); + +/** + * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format + * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & + * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from + * the map data. + * + * @function Phaser.Tilemaps.Parsers.Parse + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer} mapFormat - See ../Formats.js. + * @param {(integer[][]|string|object)} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {integer} tileHeight - The height of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.MapData} The created `MapData` object. + */ +var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) +{ + var newMap; + + switch (mapFormat) + { + case (Formats.ARRAY_2D): + newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.CSV): + newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.TILED_JSON): + newMap = ParseJSONTiled(name, data, insertNull); + break; + case (Formats.WELTMEISTER): + newMap = ParseWeltmeister(name, data, insertNull); + break; + default: + console.warn('Unrecognized tilemap data format: ' + mapFormat); + newMap = null; + } + + return newMap; +}; + +module.exports = Parse; + + +/***/ }), +/* 231 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tile = __webpack_require__(61); +var IsInLayerBounds = __webpack_require__(88); +var CalculateFacesAt = __webpack_require__(145); + +/** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * @function Phaser.Tilemaps.Components.RemoveTileAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + */ +var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer) +{ + if (replaceWithNull === undefined) { replaceWithNull = false; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else + { + layer.data[tileY][tileX] = replaceWithNull + ? null + : new Tile(layer, -1, tileX, tileY, tile.width, tile.height); + } + + // Recalculate faces only if the removed tile was a colliding tile + if (recalculateFaces && tile && tile.collides) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return tile; +}; + +module.exports = RemoveTileAt; + + +/***/ }), +/* 232 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsInLayerBounds = __webpack_require__(88); + +/** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @function Phaser.Tilemaps.Components.HasTileAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ +var HasTileAt = function (tileX, tileY, layer) +{ + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + return (tile !== null && tile.index > -1); + } + else + { + return false; + } + +}; + +module.exports = HasTileAt; + + +/***/ }), +/* 233 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); + +/** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * @function Phaser.Tilemaps.Components.ReplaceByIndex + * @private + * @since 3.0.0 + * + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + if (tiles[i] && tiles[i].index === findIndex) + { + tiles[i].index = newIndex; + } + } +}; + +module.exports = ReplaceByIndex; + + +/***/ }), +/* 234 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* @author Richard Davey +* @copyright 2018 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} +*/ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Global Plugin is installed just once into the Game owned Plugin Manager. + * It can listen for Game events and respond to them. + * + * @class BasePlugin + * @memberof Phaser.Plugins + * @constructor + * @since 3.8.0 + * + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager. + */ +var BasePlugin = new Class({ + + initialize: + + function BasePlugin (pluginManager) + { + /** + * A handy reference to the Plugin Manager that is responsible for this plugin. + * Can be used as a route to gain access to game systems and events. + * + * @name Phaser.Plugins.BasePlugin#pluginManager + * @type {Phaser.Plugins.PluginManager} + * @protected + * @since 3.8.0 + */ + this.pluginManager = pluginManager; + + /** + * A reference to the Game instance this plugin is running under. + * + * @name Phaser.Plugins.BasePlugin#game + * @type {Phaser.Game} + * @protected + * @since 3.8.0 + */ + this.game = pluginManager.game; + + /** + * A reference to the Scene that has installed this plugin. + * Only set if it's a Scene Plugin, otherwise `null`. + * This property is only set when the plugin is instantiated and added to the Scene, not before. + * You cannot use it during the `init` method, but you can during the `boot` method. + * + * @name Phaser.Plugins.BasePlugin#scene + * @type {?Phaser.Scene} + * @protected + * @since 3.8.0 + */ + this.scene; + + /** + * A reference to the Scene Systems of the Scene that has installed this plugin. + * Only set if it's a Scene Plugin, otherwise `null`. + * This property is only set when the plugin is instantiated and added to the Scene, not before. + * You cannot use it during the `init` method, but you can during the `boot` method. + * + * @name Phaser.Plugins.BasePlugin#systems + * @type {?Phaser.Scenes.Systems} + * @protected + * @since 3.8.0 + */ + this.systems; + }, + + /** + * Called by the PluginManager when this plugin is first instantiated. + * It will never be called again on this instance. + * In here you can set-up whatever you need for this plugin to run. + * If a plugin is set to automatically start then `BasePlugin.start` will be called immediately after this. + * + * @method Phaser.Plugins.BasePlugin#init + * @since 3.8.0 + * + * @param {?any} [data] - A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually). + */ + init: function () + { + }, + + /** + * Called by the PluginManager when this plugin is started. + * If a plugin is stopped, and then started again, this will get called again. + * Typically called immediately after `BasePlugin.init`. + * + * @method Phaser.Plugins.BasePlugin#start + * @since 3.8.0 + */ + start: function () + { + // Here are the game-level events you can listen to. + // At the very least you should offer a destroy handler for when the game closes down. + + // var eventEmitter = this.game.events; + + // eventEmitter.once('destroy', this.gameDestroy, this); + // eventEmitter.on('pause', this.gamePause, this); + // eventEmitter.on('resume', this.gameResume, this); + // eventEmitter.on('resize', this.gameResize, this); + // eventEmitter.on('prestep', this.gamePreStep, this); + // eventEmitter.on('step', this.gameStep, this); + // eventEmitter.on('poststep', this.gamePostStep, this); + // eventEmitter.on('prerender', this.gamePreRender, this); + // eventEmitter.on('postrender', this.gamePostRender, this); + }, + + /** + * Called by the PluginManager when this plugin is stopped. + * The game code has requested that your plugin stop doing whatever it does. + * It is now considered as 'inactive' by the PluginManager. + * Handle that process here (i.e. stop listening for events, etc) + * If the plugin is started again then `BasePlugin.start` will be called again. + * + * @method Phaser.Plugins.BasePlugin#stop + * @since 3.8.0 + */ + stop: function () + { + }, + + /** + * If this is a Scene Plugin (i.e. installed into a Scene) then this method is called when the Scene boots. + * By this point the plugin properties `scene` and `systems` will have already been set. + * In here you can listen for Scene events and set-up whatever you need for this plugin to run. + * + * @method Phaser.Plugins.BasePlugin#boot + * @since 3.8.0 + */ + boot: function () + { + // Here are the Scene events you can listen to. + // At the very least you should offer a destroy handler for when the Scene closes down. + + // var eventEmitter = this.systems.events; + + // eventEmitter.once('destroy', this.sceneDestroy, this); + // eventEmitter.on('start', this.sceneStart, this); + // eventEmitter.on('preupdate', this.scenePreUpdate, this); + // eventEmitter.on('update', this.sceneUpdate, this); + // eventEmitter.on('postupdate', this.scenePostUpdate, this); + // eventEmitter.on('pause', this.scenePause, this); + // eventEmitter.on('resume', this.sceneResume, this); + // eventEmitter.on('sleep', this.sceneSleep, this); + // eventEmitter.on('wake', this.sceneWake, this); + // eventEmitter.on('shutdown', this.sceneShutdown, this); + // eventEmitter.on('destroy', this.sceneDestroy, this); + }, + + /** + * Game instance has been destroyed. + * You must release everything in here, all references, all objects, free it all up. + * + * @method Phaser.Plugins.BasePlugin#destroy + * @since 3.8.0 + */ + destroy: function () + { + this.pluginManager = null; + this.game = null; + this.scene = null; + this.systems = null; + } + +}); + +module.exports = BasePlugin; + + +/***/ }), +/* 235 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bodies = __webpack_require__(55); +var Class = __webpack_require__(0); +var Common = __webpack_require__(12); +var Composite = __webpack_require__(63); +var Engine = __webpack_require__(236); +var EventEmitter = __webpack_require__(11); +var GetFastValue = __webpack_require__(1); +var GetValue = __webpack_require__(4); +var MatterBody = __webpack_require__(25); +var MatterEvents = __webpack_require__(74); +var MatterTileBody = __webpack_require__(151); +var MatterWorld = __webpack_require__(146); +var Vector = __webpack_require__(34); + +/** + * @classdesc + * [description] + * + * @class World + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Matter World instance belongs. + * @param {object} config - [description] + */ +var World = new Class({ + + Extends: EventEmitter, + + initialize: + + function World (scene, config) + { + EventEmitter.call(this); + + /** + * The Scene to which this Matter World instance belongs. + * + * @name Phaser.Physics.Matter.World#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * An instance of the MatterJS Engine. + * + * @name Phaser.Physics.Matter.World#engine + * @type {MatterJS.Engine} + * @since 3.0.0 + */ + this.engine = Engine.create(config); + + /** + * A `World` composite object that will contain all simulated bodies and constraints. + * + * @name Phaser.Physics.Matter.World#localWorld + * @type {MatterJS.World} + * @since 3.0.0 + */ + this.localWorld = this.engine.world; + + var gravity = GetValue(config, 'gravity', null); + + if (gravity) + { + this.setGravity(gravity.x, gravity.y, gravity.scale); + } + + /** + * An object containing the 4 wall bodies that bound the physics world. + * + * @name Phaser.Physics.Matter.World#walls + * @type {object} + * @since 3.0.0 + */ + this.walls = { left: null, right: null, top: null, bottom: null }; + + if (GetFastValue(config, 'setBounds', false)) + { + var boundsConfig = config['setBounds']; + + if (typeof boundsConfig === 'boolean') + { + this.setBounds(); + } + else + { + var x = GetFastValue(boundsConfig, 'x', 0); + var y = GetFastValue(boundsConfig, 'y', 0); + var width = GetFastValue(boundsConfig, 'width', scene.sys.game.config.width); + var height = GetFastValue(boundsConfig, 'height', scene.sys.game.config.height); + var thickness = GetFastValue(boundsConfig, 'thickness', 64); + var left = GetFastValue(boundsConfig, 'left', true); + var right = GetFastValue(boundsConfig, 'right', true); + var top = GetFastValue(boundsConfig, 'top', true); + var bottom = GetFastValue(boundsConfig, 'bottom', true); + + this.setBounds(x, y, width, height, thickness, left, right, top, bottom); + } + } + + /** + * A flag that toggles if the world is enabled or not. + * + * @name Phaser.Physics.Matter.World#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = GetValue(config, 'enabled', true); + + /** + * The correction argument is an optional Number that specifies the time correction factor to apply to the update. + * This can help improve the accuracy of the simulation in cases where delta is changing between updates. + * The value of correction is defined as delta / lastDelta, i.e. the percentage change of delta over the last step. + * Therefore the value is always 1 (no correction) when delta constant (or when no correction is desired, which is the default). + * See the paper on Time Corrected Verlet for more information. + * + * @name Phaser.Physics.Matter.World#correction + * @type {number} + * @default 1 + * @since 3.4.0 + */ + this.correction = GetValue(config, 'correction', 1); + + /** + * This function is called every time the core game loop steps, which is bound to the + * Request Animation Frame frequency unless otherwise modified. + * + * The function is passed two values: `time` and `delta`, both of which come from the game step values. + * + * It must return a number. This number is used as the delta value passed to Matter.Engine.update. + * + * You can override this function with your own to define your own timestep. + * + * If you need to update the Engine multiple times in a single game step then call + * `World.update` as many times as required. Each call will trigger the `getDelta` function. + * If you wish to have full control over when the Engine updates then see the property `autoUpdate`. + * + * You can also adjust the number of iterations that Engine.update performs. + * Use the Scene Matter Physics config object to set the following properties: + * + * positionIterations (defaults to 6) + * velocityIterations (defaults to 4) + * constraintIterations (defaults to 2) + * + * Adjusting these values can help performance in certain situations, depending on the physics requirements + * of your game. + * + * @name Phaser.Physics.Matter.World#getDelta + * @type {function} + * @since 3.4.0 + */ + this.getDelta = GetValue(config, 'getDelta', this.update60Hz); + + /** + * Automatically call Engine.update every time the game steps. + * If you disable this then you are responsible for calling `World.step` directly from your game. + * If you call `set60Hz` or `set30Hz` then `autoUpdate` is reset to `true`. + * + * @name Phaser.Physics.Matter.World#autoUpdate + * @type {boolean} + * @default true + * @since 3.4.0 + */ + this.autoUpdate = GetValue(config, 'autoUpdate', true); + + /** + * A flag that controls if the debug graphics will be drawn to or not. + * + * @name Phaser.Physics.Matter.World#drawDebug + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.drawDebug = GetValue(config, 'debug', false); + + /** + * An instance of the Graphics object the debug bodies are drawn to, if enabled. + * + * @name Phaser.Physics.Matter.World#debugGraphic + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.debugGraphic; + + /** + * The default configuration values. + * + * @name Phaser.Physics.Matter.World#defaults + * @type {object} + * @since 3.0.0 + */ + this.defaults = { + debugShowBody: GetFastValue(config, 'debugShowBody', true), + debugShowStaticBody: GetFastValue(config, 'debugShowStaticBody', true), + debugShowVelocity: GetFastValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetFastValue(config, 'debugBodyColor', 0xff00ff), + bodyDebugFillColor: GetFastValue(config, 'bodyDebugFillColor', 0xe3a7e3), + staticBodyDebugColor: GetFastValue(config, 'debugBodyColor', 0x0000ff), + velocityDebugColor: GetFastValue(config, 'debugVelocityColor', 0x00ff00), + debugShowJoint: GetFastValue(config, 'debugShowJoint', true), + jointDebugColor: GetFastValue(config, 'debugJointColor', 0x000000), + debugWireframes: GetFastValue(config, 'debugWireframes', true), + debugShowInternalEdges: GetFastValue(config, 'debugShowInternalEdges', false), + debugShowConvexHulls: GetFastValue(config, 'debugShowConvexHulls', false), + debugConvexHullColor: GetFastValue(config, 'debugConvexHullColor', 0xaaaaaa), + debugShowSleeping: GetFastValue(config, 'debugShowSleeping', false) + }; + + if (this.drawDebug) + { + this.createDebugGraphic(); + } + + this.setEventsProxy(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#setEventsProxy + * @since 3.0.0 + */ + setEventsProxy: function () + { + var _this = this; + var engine = this.engine; + + 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; + + if (pairs.length > 0) + { + bodyA = pairs[0].bodyA; + bodyB = pairs[0].bodyB; + } + + _this.emit('collisionstart', event, bodyA, bodyB); + }); + + MatterEvents.on(engine, 'collisionActive', function (event) + { + var pairs = event.pairs; + var bodyA; + var bodyB; + + if (pairs.length > 0) + { + bodyA = pairs[0].bodyA; + bodyB = pairs[0].bodyB; + } + + _this.emit('collisionactive', event, bodyA, bodyB); + }); + + MatterEvents.on(engine, 'collisionEnd', function (event) + { + var pairs = event.pairs; + var bodyA; + var bodyB; + + if (pairs.length > 0) + { + bodyA = pairs[0].bodyA; + bodyB = pairs[0].bodyB; + } + + _this.emit('collisionend', event, bodyA, bodyB); + }); + }, + + /** + * Sets the bounds of the Physics world to match the given world pixel dimensions. + * You can optionally set which 'walls' to create: left, right, top or bottom. + * If none of the walls are given it will default to use the walls settings it had previously. + * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size + * the newly created bounds will also not have the left and right walls. + * Explicitly state them in the parameters to override this. + * + * @method Phaser.Physics.Matter.World#setBounds + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of the top-left corner of the bounds. + * @param {number} [y=0] - The y coordinate of the top-left corner of the bounds. + * @param {number} [width] - The width of the bounds. + * @param {number} [height] - The height of the bounds. + * @param {number} [thickness=128] - The thickness of each wall, in pixels. + * @param {boolean} [left=true] - If true will create the left bounds wall. + * @param {boolean} [right=true] - If true will create the right bounds wall. + * @param {boolean} [top=true] - If true will create the top bounds wall. + * @param {boolean} [bottom=true] - If true will create the bottom bounds wall. + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + setBounds: function (x, y, width, height, thickness, left, right, top, bottom) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + if (thickness === undefined) { thickness = 128; } + if (left === undefined) { left = true; } + if (right === undefined) { right = true; } + if (top === undefined) { top = true; } + if (bottom === undefined) { bottom = true; } + + this.updateWall(left, 'left', x - thickness, y, thickness, height); + this.updateWall(right, 'right', x + width, y, thickness, height); + this.updateWall(top, 'top', x, y - thickness, width, thickness); + this.updateWall(bottom, 'bottom', x, y + height, width, thickness); + + return this; + }, + + // position = 'left', 'right', 'top' or 'bottom' + /** + * [description] + * + * @method Phaser.Physics.Matter.World#updateWall + * @since 3.0.0 + * + * @param {boolean} add - [description] + * @param {string} position - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + */ + updateWall: function (add, position, x, y, width, height) + { + var wall = this.walls[position]; + + if (add) + { + if (wall) + { + MatterWorld.remove(this.localWorld, wall); + } + + // adjust center + x += (width / 2); + y += (height / 2); + + this.walls[position] = this.create(x, y, width, height, { isStatic: true, friction: 0, frictionStatic: 0 }); + } + else + { + if (wall) + { + MatterWorld.remove(this.localWorld, wall); + } + + this.walls[position] = null; + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#createDebugGraphic + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + createDebugGraphic: function () + { + var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); + + graphic.setDepth(Number.MAX_VALUE); + + this.debugGraphic = graphic; + + this.drawDebug = true; + + return graphic; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#disableGravity + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + disableGravity: function () + { + this.localWorld.gravity.x = 0; + this.localWorld.gravity.y = 0; + this.localWorld.gravity.scale = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#setGravity + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=1] - [description] + * @param {number} [scale] - [description] + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + setGravity: function (x, y, scale) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 1; } + + this.localWorld.gravity.x = x; + this.localWorld.gravity.y = y; + + if (scale !== undefined) + { + this.localWorld.gravity.scale = scale; + } + + return this; + }, + + /** + * Creates a rectangle Matter body and adds it to the world. + * + * @method Phaser.Physics.Matter.World#create + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the body in the world. + * @param {number} y - The vertical position of the body in the world. + * @param {number} width - The width of the body. + * @param {number} height - The height of the body. + * @param {object} options - Optional Matter configuration object. + * + * @return {MatterJS.Body} The Matter.js body that was created. + */ + create: function (x, y, width, height, options) + { + var body = Bodies.rectangle(x, y, width, height, options); + + MatterWorld.add(this.localWorld, body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#add + * @since 3.0.0 + * + * @param {(object|object[])} object - Can be single or an array, and can be a body, composite or constraint + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + add: function (object) + { + MatterWorld.add(this.localWorld, object); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#remove + * @since 3.0.0 + * + * @param {object} object - The object to be removed from the world. + * @param {boolean} deep - [description] + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + remove: function (object, deep) + { + var body = (object.body) ? object.body : object; + + Composite.removeBody(this.localWorld, body, deep); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#removeConstraint + * @since 3.0.0 + * + * @param {MatterJS.Constraint} constraint - [description] + * @param {boolean} deep - [description] + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + removeConstraint: function (constraint, deep) + { + Composite.remove(this.localWorld, constraint, deep); + + return this; + }, + + /** + * Adds MatterTileBody instances for all the colliding tiles within the given tilemap layer. Set + * the appropriate tiles in your layer to collide before calling this method! + * + * @method Phaser.Physics.Matter.World#convertTilemapLayer + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - + * An array of tiles. + * @param {object} [options] - Options to be passed to the MatterTileBody constructor. {@ee Phaser.Physics.Matter.TileBody} + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + convertTilemapLayer: function (tilemapLayer, options) + { + var layerData = tilemapLayer.layer; + var tiles = tilemapLayer.getTilesWithin(0, 0, layerData.width, layerData.height, {isColliding: true}); + + this.convertTiles(tiles, options); + + return this; + }, + + /** + * Adds MatterTileBody instances for the given tiles. This adds bodies regardless of whether the + * tiles are set to collide or not. + * + * @method Phaser.Physics.Matter.World#convertTiles + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.Tile[]} tiles - An array of tiles. + * @param {object} [options] - Options to be passed to the MatterTileBody constructor. {@see Phaser.Physics.Matter.TileBody} + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + convertTiles: function (tiles, options) + { + if (tiles.length === 0) + { + return this; + } + + for (var i = 0; i < tiles.length; i++) + { + new MatterTileBody(this, tiles[i], options); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#nextGroup + * @since 3.0.0 + * + * @param {boolean} isNonColliding - [description] + * + * @return {number} [description] + */ + nextGroup: function (isNonColliding) + { + return MatterBody.nextGroup(isNonColliding); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#nextCategory + * @since 3.0.0 + * + * @return {number} [description] + */ + nextCategory: function () + { + return MatterBody.nextCategory(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + pause: function () + { + this.enabled = false; + + this.emit('pause'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.World} This Matter World object. + */ + resume: function () + { + this.enabled = true; + + this.emit('resume'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#update + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update: function (time, delta) + { + if (this.enabled && this.autoUpdate) + { + Engine.update(this.engine, this.getDelta(time, delta), this.correction); + } + }, + + /** + * Manually advances the physics simulation by one iteration. + * + * You can optionally pass in the `delta` and `correction` values to be used by Engine.update. + * If undefined they use the Matter defaults of 60Hz and no correction. + * + * Calling `step` directly bypasses any checks of `enabled` or `autoUpdate`. + * + * It also ignores any custom `getDelta` functions, as you should be passing the delta + * value in to this call. + * + * You can adjust the number of iterations that Engine.update performs internally. + * Use the Scene Matter Physics config object to set the following properties: + * + * positionIterations (defaults to 6) + * velocityIterations (defaults to 4) + * constraintIterations (defaults to 2) + * + * Adjusting these values can help performance in certain situations, depending on the physics requirements + * of your game. + * + * @method Phaser.Physics.Matter.World#step + * @since 3.4.0 + * + * @param {number} [delta=16.666] - [description] + * @param {number} [correction=1] - [description] + */ + step: function (delta, correction) + { + Engine.update(this.engine, delta, correction); + }, + + /** + * Runs the Matter Engine.update at a fixed timestep of 60Hz. + * + * @method Phaser.Physics.Matter.World#update60Hz + * @since 3.4.0 + * + * @return {number} The delta value to be passed to Engine.update. + */ + update60Hz: function () + { + return 1000 / 60; + }, + + /** + * Runs the Matter Engine.update at a fixed timestep of 30Hz. + * + * @method Phaser.Physics.Matter.World#update30Hz + * @since 3.4.0 + * + * @return {number} The delta value to be passed to Engine.update. + */ + update30Hz: function () + { + return 1000 / 30; + }, + + /** + * Handles the rendering of bodies and debug information to the debug Graphics object, if enabled. + * + * @method Phaser.Physics.Matter.World#postUpdate + * @private + * @since 3.0.0 + */ + postUpdate: function () + { + if (!this.drawDebug) + { + return; + } + + this.debugGraphic.clear(); + + var bodies = Composite.allBodies(this.localWorld); + + if (this.defaults.debugWireframes) + { + if (this.defaults.debugShowConvexHulls) + { + this.renderConvexHulls(bodies); + } + + this.renderWireframes(bodies); + } + else + { + this.renderBodies(bodies); + } + + if (this.defaults.debugShowJoint) + { + this.renderJoints(); + } + }, + + /** + * Renders the debug convex hulls from the given array of bodies. + * + * @method Phaser.Physics.Matter.World#renderConvexHulls + * @private + * @since 3.14.0 + * + * @param {array} bodies - An array of bodies from the localWorld. + */ + renderConvexHulls: function (bodies) + { + var graphics = this.debugGraphic; + + graphics.lineStyle(1, this.defaults.debugConvexHullColor); + + graphics.beginPath(); + + for (var i = 0; i < bodies.length; i++) + { + var body = bodies[i]; + + if (!body.render.visible || body.parts.length === 1) + { + continue; + } + + graphics.moveTo(body.vertices[0].x, body.vertices[0].y); + + for (var j = 1; j < body.vertices.length; j++) + { + graphics.lineTo(body.vertices[j].x, body.vertices[j].y); + } + + graphics.lineTo(body.vertices[0].x, body.vertices[0].y); + } + + graphics.strokePath(); + }, + + /** + * Renders the wireframes of the given array of bodies. + * + * @method Phaser.Physics.Matter.World#renderWireframes + * @private + * @since 3.14.0 + * + * @param {array} bodies - An array of bodies from the localWorld. + */ + renderWireframes: function (bodies) + { + var graphics = this.debugGraphic; + var showInternalEdges = this.defaults.debugShowInternalEdges; + + graphics.lineStyle(1, this.defaults.bodyDebugColor); + + graphics.beginPath(); + + for (var i = 0; i < bodies.length; i++) + { + var body = bodies[i]; + + if (!body.render.visible) + { + continue; + } + + for (var k = (body.parts.length > 1) ? 1 : 0; k < body.parts.length; k++) + { + var part = body.parts[k]; + + var vertLength = part.vertices.length; + + graphics.moveTo(part.vertices[0].x, part.vertices[0].y); + + for (var j = 1; j < vertLength; j++) + { + if (!part.vertices[j - 1].isInternal || showInternalEdges) + { + graphics.lineTo(part.vertices[j].x, part.vertices[j].y); + } + else + { + graphics.moveTo(part.vertices[j].x, part.vertices[j].y); + } + + if (part.vertices[j].isInternal && !showInternalEdges) + { + graphics.moveTo(part.vertices[(j + 1) % vertLength].x, part.vertices[(j + 1) % vertLength].y); + } + } + + graphics.lineTo(part.vertices[0].x, part.vertices[0].y); + } + } + + graphics.strokePath(); + }, + + /** + * Renders the array of bodies. + * + * @method Phaser.Physics.Matter.World#renderBodies + * @private + * @since 3.14.0 + * + * @param {array} bodies - An array of bodies from the localWorld. + */ + renderBodies: function (bodies) + { + var graphics = this.debugGraphic; + + var showInternalEdges = this.defaults.debugShowInternalEdges || !this.defaults.debugWireframes; + var showSleeping = this.defaults.debugShowSleeping; + var wireframes = this.defaults.debugWireframes; + + var body; + var part; + var i; + var k; + + for (i = 0; i < bodies.length; i++) + { + body = bodies[i]; + + if (!body.render.visible) + { + continue; + } + + // Handle compound parts + for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) + { + part = body.parts[k]; + + if (!part.render.visible) + { + continue; + } + + if (showSleeping && body.isSleeping) + { + graphics.lineStyle(1, this.defaults.bodyDebugColor, 0.5 * part.render.opacity); + graphics.fillStyle(this.defaults.bodyDebugColor, 0.5 * part.render.opacity); + } + else + { + graphics.lineStyle(1, this.defaults.bodyDebugColor, part.render.opacity); + graphics.fillStyle(this.defaults.bodyDebugColor, part.render.opacity); + } + + // Part polygon + if (part.circleRadius) + { + graphics.beginPath(); + graphics.arc(part.position.x, part.position.y, part.circleRadius, 0, 2 * Math.PI); + } + else + { + graphics.beginPath(); + graphics.moveTo(part.vertices[0].x, part.vertices[0].y); + + var vertLength = part.vertices.length; + + for (var j = 1; j < vertLength; j++) + { + if (!part.vertices[j - 1].isInternal || showInternalEdges) + { + graphics.lineTo(part.vertices[j].x, part.vertices[j].y); + } + else + { + graphics.moveTo(part.vertices[j].x, part.vertices[j].y); + } + + if (part.vertices[j].isInternal && !showInternalEdges) + { + graphics.moveTo(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y); + } + } + + graphics.lineTo(part.vertices[0].x, part.vertices[0].y); + + graphics.closePath(); + } + + if (!wireframes) + { + graphics.fillPath(); + } + else + { + graphics.strokePath(); + } + } + } + }, + + /** + * Renders world constraints. + * + * @method Phaser.Physics.Matter.World#renderJoints + * @private + * @since 3.14.0 + */ + renderJoints: function () + { + var graphics = this.debugGraphic; + + graphics.lineStyle(2, this.defaults.jointDebugColor); + + // Render constraints + var constraints = Composite.allConstraints(this.localWorld); + + for (var i = 0; i < constraints.length; i++) + { + var constraint = constraints[i]; + + if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) + { + continue; + } + + if (constraint.render.lineWidth) + { + graphics.lineStyle(constraint.render.lineWidth, Common.colorToNumber(constraint.render.strokeStyle)); + } + + var bodyA = constraint.bodyA; + var bodyB = constraint.bodyB; + var start; + var end; + + if (bodyA) + { + start = Vector.add(bodyA.position, constraint.pointA); + } + else + { + start = constraint.pointA; + } + + if (constraint.render.type === 'pin') + { + graphics.beginPath(); + graphics.arc(start.x, start.y, 3, 0, 2 * Math.PI); + graphics.closePath(); + } + else + { + if (bodyB) + { + end = Vector.add(bodyB.position, constraint.pointB); + } + else + { + end = constraint.pointB; + } + + graphics.beginPath(); + graphics.moveTo(start.x, start.y); + + if (constraint.render.type === 'spring') + { + var delta = Vector.sub(end, start); + var normal = Vector.perp(Vector.normalise(delta)); + var coils = Math.ceil(Common.clamp(constraint.length / 5, 12, 20)); + var offset; + + for (var j = 1; j < coils; j += 1) + { + offset = (j % 2 === 0) ? 1 : -1; + + graphics.lineTo( + start.x + delta.x * (j / coils) + normal.x * offset * 4, + start.y + delta.y * (j / coils) + normal.y * offset * 4 + ); + } + } + + graphics.lineTo(end.x, end.y); + } + + if (constraint.render.lineWidth) + { + graphics.strokePath(); + } + + if (constraint.render.anchors) + { + graphics.fillStyle(Common.colorToNumber(constraint.render.strokeStyle)); + graphics.beginPath(); + graphics.arc(start.x, start.y, 6, 0, 2 * Math.PI); + graphics.arc(end.x, end.y, 6, 0, 2 * Math.PI); + graphics.closePath(); + graphics.fillPath(); + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#fromPath + * @since 3.0.0 + * + * @param {string} path - [description] + * @param {array} points - [description] + * + * @return {array} [description] + */ + fromPath: function (path, points) + { + if (points === undefined) { points = []; } + + // var pathPattern = /L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/ig; + + // eslint-disable-next-line no-useless-escape + var pathPattern = /L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/ig; + + path.replace(pathPattern, function (match, x, y) + { + points.push({ x: parseFloat(x), y: parseFloat(y) }); + }); + + return points; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + MatterEvents.off(this.engine); + + this.removeAllListeners(); + + MatterWorld.clear(this.localWorld, false); + + Engine.clear(this.engine); + + if (this.drawDebug) + { + this.debugGraphic.destroy(); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.World#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + } + +}); + +module.exports = World; + + +/***/ }), +/* 236 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Engine` module contains methods for creating and manipulating engines. +* An engine is a controller that manages updating the simulation of the world. +* See `Matter.Runner` for an optional game loop utility. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Engine +*/ + +var Engine = {}; + +module.exports = Engine; + +var World = __webpack_require__(146); +var Sleeping = __webpack_require__(89); +var Resolver = __webpack_require__(237); +var Pairs = __webpack_require__(238); +var Metrics = __webpack_require__(535); +var Grid = __webpack_require__(239); +var Events = __webpack_require__(74); +var Composite = __webpack_require__(63); +var Constraint = __webpack_require__(73); +var Common = __webpack_require__(12); +var Body = __webpack_require__(25); + +(function() { + + /** + * Creates a new engine. The options parameter is an object that specifies any properties you wish to override the defaults. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {object} [options] + * @return {engine} engine + */ + Engine.create = function(element, options) { + // options may be passed as the first (and only) argument + options = Common.isElement(element) ? options : element; + element = Common.isElement(element) ? element : null; + options = options || {}; + + if (element || options.render) { + Common.warn('Engine.create: engine.render is deprecated (see docs)'); + } + + var defaults = { + positionIterations: 6, + velocityIterations: 4, + constraintIterations: 2, + enableSleeping: false, + events: [], + plugin: {}, + timing: { + timestamp: 0, + timeScale: 1 + }, + broadphase: { + controller: Grid + } + }; + + var engine = Common.extend(defaults, options); + + // @deprecated + if (element || engine.render) { + var renderDefaults = { + element: element, + controller: Render + }; + + engine.render = Common.extend(renderDefaults, engine.render); + } + + // @deprecated + if (engine.render && engine.render.controller) { + engine.render = engine.render.controller.create(engine.render); + } + + // @deprecated + if (engine.render) { + engine.render.engine = engine; + } + + engine.world = options.world || World.create(engine.world); + engine.pairs = Pairs.create(); + engine.broadphase = engine.broadphase.controller.create(engine.broadphase); + engine.metrics = engine.metrics || { extended: false }; + + // @if DEBUG + engine.metrics = Metrics.create(engine.metrics); + // @endif + + return engine; + }; + + /** + * Moves the simulation forward in time by `delta` ms. + * The `correction` argument is an optional `Number` that specifies the time correction factor to apply to the update. + * This can help improve the accuracy of the simulation in cases where `delta` is changing between updates. + * The value of `correction` is defined as `delta / lastDelta`, i.e. the percentage change of `delta` over the last step. + * Therefore the value is always `1` (no correction) when `delta` constant (or when no correction is desired, which is the default). + * See the paper on Time Corrected Verlet for more information. + * + * Triggers `beforeUpdate` and `afterUpdate` events. + * Triggers `collisionStart`, `collisionActive` and `collisionEnd` events. + * @method update + * @param {engine} engine + * @param {number} [delta=16.666] + * @param {number} [correction=1] + */ + Engine.update = function(engine, delta, correction) { + delta = delta || 1000 / 60; + correction = correction || 1; + + var world = engine.world, + timing = engine.timing, + broadphase = engine.broadphase, + broadphasePairs = [], + i; + + // increment timestamp + timing.timestamp += delta * timing.timeScale; + + // create an event object + var event = { + timestamp: timing.timestamp + }; + + Events.trigger(engine, 'beforeUpdate', event); + + // get lists of all bodies and constraints, no matter what composites they are in + var allBodies = Composite.allBodies(world), + allConstraints = Composite.allConstraints(world); + + // @if DEBUG + // reset metrics logging + Metrics.reset(engine.metrics); + // @endif + + // if sleeping enabled, call the sleeping controller + if (engine.enableSleeping) + Sleeping.update(allBodies, timing.timeScale); + + // applies gravity to all bodies + Engine._bodiesApplyGravity(allBodies, world.gravity); + + // update all body position and rotation by integration + Engine._bodiesUpdate(allBodies, delta, timing.timeScale, correction, world.bounds); + + // update all constraints (first pass) + Constraint.preSolveAll(allBodies); + for (i = 0; i < engine.constraintIterations; i++) { + Constraint.solveAll(allConstraints, timing.timeScale); + } + Constraint.postSolveAll(allBodies); + + // broadphase pass: find potential collision pairs + if (broadphase.controller) { + // if world is dirty, we must flush the whole grid + if (world.isModified) + broadphase.controller.clear(broadphase); + + // update the grid buckets based on current bodies + broadphase.controller.update(broadphase, allBodies, engine, world.isModified); + broadphasePairs = broadphase.pairsList; + } else { + // if no broadphase set, we just pass all bodies + broadphasePairs = allBodies; + } + + // clear all composite modified flags + if (world.isModified) { + Composite.setModified(world, false, false, true); + } + + // narrowphase pass: find actual collisions, then create or update collision pairs + var collisions = broadphase.detector(broadphasePairs, engine); + + // update collision pairs + var pairs = engine.pairs, + timestamp = timing.timestamp; + Pairs.update(pairs, collisions, timestamp); + Pairs.removeOld(pairs, timestamp); + + // wake up bodies involved in collisions + if (engine.enableSleeping) + Sleeping.afterCollisions(pairs.list, timing.timeScale); + + // trigger collision events + if (pairs.collisionStart.length > 0) + Events.trigger(engine, 'collisionStart', { pairs: pairs.collisionStart }); + + // iteratively resolve position between collisions + Resolver.preSolvePosition(pairs.list); + for (i = 0; i < engine.positionIterations; i++) { + Resolver.solvePosition(pairs.list, allBodies, timing.timeScale); + } + Resolver.postSolvePosition(allBodies); + + // update all constraints (second pass) + Constraint.preSolveAll(allBodies); + for (i = 0; i < engine.constraintIterations; i++) { + Constraint.solveAll(allConstraints, timing.timeScale); + } + Constraint.postSolveAll(allBodies); + + // iteratively resolve velocity between collisions + Resolver.preSolveVelocity(pairs.list); + for (i = 0; i < engine.velocityIterations; i++) { + Resolver.solveVelocity(pairs.list, timing.timeScale); + } + + // trigger collision events + if (pairs.collisionActive.length > 0) + Events.trigger(engine, 'collisionActive', { pairs: pairs.collisionActive }); + + if (pairs.collisionEnd.length > 0) + Events.trigger(engine, 'collisionEnd', { pairs: pairs.collisionEnd }); + + // @if DEBUG + // update metrics log + Metrics.update(engine.metrics, engine); + // @endif + + // clear force buffers + Engine._bodiesClearForces(allBodies); + + Events.trigger(engine, 'afterUpdate', event); + + return engine; + }; + + /** + * Merges two engines by keeping the configuration of `engineA` but replacing the world with the one from `engineB`. + * @method merge + * @param {engine} engineA + * @param {engine} engineB + */ + Engine.merge = function(engineA, engineB) { + Common.extend(engineA, engineB); + + if (engineB.world) { + engineA.world = engineB.world; + + Engine.clear(engineA); + + var bodies = Composite.allBodies(engineA.world); + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + Sleeping.set(body, false); + body.id = Common.nextId(); + } + } + }; + + /** + * Clears the engine including the world, pairs and broadphase. + * @method clear + * @param {engine} engine + */ + Engine.clear = function(engine) { + var world = engine.world; + + Pairs.clear(engine.pairs); + + var broadphase = engine.broadphase; + if (broadphase.controller) { + var bodies = Composite.allBodies(world); + broadphase.controller.clear(broadphase); + broadphase.controller.update(broadphase, bodies, engine, true); + } + }; + + /** + * Zeroes the `body.force` and `body.torque` force buffers. + * @method _bodiesClearForces + * @private + * @param {body[]} bodies + */ + Engine._bodiesClearForces = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + // reset force buffers + body.force.x = 0; + body.force.y = 0; + body.torque = 0; + } + }; + + /** + * Applys a mass dependant force to all given bodies. + * @method _bodiesApplyGravity + * @private + * @param {body[]} bodies + * @param {vector} gravity + */ + Engine._bodiesApplyGravity = function(bodies, gravity) { + var gravityScale = typeof gravity.scale !== 'undefined' ? gravity.scale : 0.001; + + if ((gravity.x === 0 && gravity.y === 0) || gravityScale === 0) { + return; + } + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.ignoreGravity || body.isStatic || body.isSleeping) + continue; + + // apply gravity + body.force.y += body.mass * gravity.y * gravityScale; + body.force.x += body.mass * gravity.x * gravityScale; + } + }; + + /** + * Applys `Body.update` to all given `bodies`. + * @method _bodiesUpdate + * @private + * @param {body[]} bodies + * @param {number} deltaTime + * The amount of time elapsed between updates + * @param {number} timeScale + * @param {number} correction + * The Verlet correction factor (deltaTime / lastDeltaTime) + * @param {bounds} worldBounds + */ + Engine._bodiesUpdate = function(bodies, deltaTime, timeScale, correction, worldBounds) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.isStatic || body.isSleeping) + continue; + + Body.update(body, deltaTime, timeScale, correction); + } + }; + + /** + * An alias for `Runner.run`, see `Matter.Runner` for more information. + * @method run + * @param {engine} engine + */ + + /** + * Fired just before an update + * + * @event beforeUpdate + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update and all collision events + * + * @event afterUpdate + * @param {} event An event object + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update, provides a list of all pairs that have started to collide in the current tick (if any) + * + * @event collisionStart + * @param {} event An event object + * @param {} event.pairs List of affected pairs + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update, provides a list of all pairs that are colliding in the current tick (if any) + * + * @event collisionActive + * @param {} event An event object + * @param {} event.pairs List of affected pairs + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired after engine update, provides a list of all pairs that have ended collision in the current tick (if any) + * + * @event collisionEnd + * @param {} event An event object + * @param {} event.pairs List of affected pairs + * @param {number} event.timestamp The engine.timing.timestamp of the event + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` that specifies the number of position iterations to perform each update. + * The higher the value, the higher quality the simulation will be at the expense of performance. + * + * @property positionIterations + * @type number + * @default 6 + */ + + /** + * An integer `Number` that specifies the number of velocity iterations to perform each update. + * The higher the value, the higher quality the simulation will be at the expense of performance. + * + * @property velocityIterations + * @type number + * @default 4 + */ + + /** + * An integer `Number` that specifies the number of constraint iterations to perform each update. + * The higher the value, the higher quality the simulation will be at the expense of performance. + * The default value of `2` is usually very adequate. + * + * @property constraintIterations + * @type number + * @default 2 + */ + + /** + * A flag that specifies whether the engine should allow sleeping via the `Matter.Sleeping` module. + * Sleeping can improve stability and performance, but often at the expense of accuracy. + * + * @property enableSleeping + * @type boolean + * @default false + */ + + /** + * An `Object` containing properties regarding the timing systems of the engine. + * + * @property timing + * @type object + */ + + /** + * A `Number` that specifies the global scaling factor of time for all bodies. + * A value of `0` freezes the simulation. + * A value of `0.1` gives a slow-motion effect. + * A value of `1.2` gives a speed-up effect. + * + * @property timing.timeScale + * @type number + * @default 1 + */ + + /** + * A `Number` that specifies the current simulation-time in milliseconds starting from `0`. + * It is incremented on every `Engine.update` by the given `delta` argument. + * + * @property timing.timestamp + * @type number + * @default 0 + */ + + /** + * An instance of a `Render` controller. The default value is a `Matter.Render` instance created by `Engine.create`. + * One may also develop a custom renderer module based on `Matter.Render` and pass an instance of it to `Engine.create` via `options.render`. + * + * A minimal custom renderer object must define at least three functions: `create`, `clear` and `world` (see `Matter.Render`). + * It is also possible to instead pass the _module_ reference via `options.render.controller` and `Engine.create` will instantiate one for you. + * + * @property render + * @type render + * @deprecated see Demo.js for an example of creating a renderer + * @default a Matter.Render instance + */ + + /** + * An instance of a broadphase controller. The default value is a `Matter.Grid` instance created by `Engine.create`. + * + * @property broadphase + * @type grid + * @default a Matter.Grid instance + */ + + /** + * A `World` composite object that will contain all simulated bodies and constraints. + * + * @property world + * @type world + * @default a Matter.World instance + */ + + /** + * An object reserved for storing plugin-specific properties. + * + * @property plugin + * @type {} + */ + +})(); + + +/***/ }), +/* 237 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Resolver` module contains methods for resolving collision pairs. +* +* @class Resolver +*/ + +var Resolver = {}; + +module.exports = Resolver; + +var Vertices = __webpack_require__(29); +var Vector = __webpack_require__(34); +var Common = __webpack_require__(12); +var Bounds = __webpack_require__(33); + +(function() { + + Resolver._restingThresh = 4; + Resolver._restingThreshTangent = 6; + Resolver._positionDampen = 0.9; + Resolver._positionWarming = 0.8; + Resolver._frictionNormalMultiplier = 5; + + /** + * Prepare pairs for position solving. + * @method preSolvePosition + * @param {pair[]} pairs + */ + Resolver.preSolvePosition = function(pairs) { + var i, + pair, + activeCount; + + // find total contacts on each body + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive) + continue; + + activeCount = pair.activeContacts.length; + pair.collision.parentA.totalContacts += activeCount; + pair.collision.parentB.totalContacts += activeCount; + } + }; + + /** + * Find a solution for pair positions. + * @method solvePosition + * @param {pair[]} pairs + * @param {body[]} bodies + * @param {number} timeScale + */ + Resolver.solvePosition = function(pairs, bodies, timeScale) { + var i, + normalX, + normalY, + pair, + collision, + bodyA, + bodyB, + normal, + separation, + penetration, + positionImpulseA, + positionImpulseB, + contactShare, + bodyBtoAX, + bodyBtoAY, + positionImpulse, + impulseCoefficient = timeScale * Resolver._positionDampen; + + for (i = 0; i < bodies.length; i++) { + var body = bodies[i]; + body.previousPositionImpulse.x = body.positionImpulse.x; + body.previousPositionImpulse.y = body.positionImpulse.y; + } + + // find impulses required to resolve penetration + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive || pair.isSensor) + continue; + + collision = pair.collision; + bodyA = collision.parentA; + bodyB = collision.parentB; + normal = collision.normal; + + positionImpulseA = bodyA.previousPositionImpulse; + positionImpulseB = bodyB.previousPositionImpulse; + + penetration = collision.penetration; + + bodyBtoAX = positionImpulseB.x - positionImpulseA.x + penetration.x; + bodyBtoAY = positionImpulseB.y - positionImpulseA.y + penetration.y; + + normalX = normal.x; + normalY = normal.y; + + separation = normalX * bodyBtoAX + normalY * bodyBtoAY; + pair.separation = separation; + + positionImpulse = (separation - pair.slop) * impulseCoefficient; + + if (bodyA.isStatic || bodyB.isStatic) + positionImpulse *= 2; + + if (!(bodyA.isStatic || bodyA.isSleeping)) { + contactShare = positionImpulse / bodyA.totalContacts; + bodyA.positionImpulse.x += normalX * contactShare; + bodyA.positionImpulse.y += normalY * contactShare; + } + + if (!(bodyB.isStatic || bodyB.isSleeping)) { + contactShare = positionImpulse / bodyB.totalContacts; + bodyB.positionImpulse.x -= normalX * contactShare; + bodyB.positionImpulse.y -= normalY * contactShare; + } + } + }; + + /** + * Apply position resolution. + * @method postSolvePosition + * @param {body[]} bodies + */ + Resolver.postSolvePosition = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + // reset contact count + body.totalContacts = 0; + + if (body.positionImpulse.x !== 0 || body.positionImpulse.y !== 0) { + // update body geometry + for (var j = 0; j < body.parts.length; j++) { + var part = body.parts[j]; + Vertices.translate(part.vertices, body.positionImpulse); + Bounds.update(part.bounds, part.vertices, body.velocity); + part.position.x += body.positionImpulse.x; + part.position.y += body.positionImpulse.y; + } + + // move the body without changing velocity + body.positionPrev.x += body.positionImpulse.x; + body.positionPrev.y += body.positionImpulse.y; + + if (Vector.dot(body.positionImpulse, body.velocity) < 0) { + // reset cached impulse if the body has velocity along it + body.positionImpulse.x = 0; + body.positionImpulse.y = 0; + } else { + // warm the next iteration + body.positionImpulse.x *= Resolver._positionWarming; + body.positionImpulse.y *= Resolver._positionWarming; + } + } + } + }; + + /** + * Prepare pairs for velocity solving. + * @method preSolveVelocity + * @param {pair[]} pairs + */ + Resolver.preSolveVelocity = function(pairs) { + var i, + j, + pair, + contacts, + collision, + bodyA, + bodyB, + normal, + tangent, + contact, + contactVertex, + normalImpulse, + tangentImpulse, + offset, + impulse = Vector._temp[0], + tempA = Vector._temp[1]; + + for (i = 0; i < pairs.length; i++) { + pair = pairs[i]; + + if (!pair.isActive || pair.isSensor) + continue; + + contacts = pair.activeContacts; + collision = pair.collision; + bodyA = collision.parentA; + bodyB = collision.parentB; + normal = collision.normal; + tangent = collision.tangent; + + // resolve each contact + for (j = 0; j < contacts.length; j++) { + contact = contacts[j]; + contactVertex = contact.vertex; + normalImpulse = contact.normalImpulse; + tangentImpulse = contact.tangentImpulse; + + if (normalImpulse !== 0 || tangentImpulse !== 0) { + // total impulse from contact + impulse.x = (normal.x * normalImpulse) + (tangent.x * tangentImpulse); + impulse.y = (normal.y * normalImpulse) + (tangent.y * tangentImpulse); + + // apply impulse from contact + if (!(bodyA.isStatic || bodyA.isSleeping)) { + offset = Vector.sub(contactVertex, bodyA.position, tempA); + bodyA.positionPrev.x += impulse.x * bodyA.inverseMass; + bodyA.positionPrev.y += impulse.y * bodyA.inverseMass; + bodyA.anglePrev += Vector.cross(offset, impulse) * bodyA.inverseInertia; + } + + if (!(bodyB.isStatic || bodyB.isSleeping)) { + offset = Vector.sub(contactVertex, bodyB.position, tempA); + bodyB.positionPrev.x -= impulse.x * bodyB.inverseMass; + bodyB.positionPrev.y -= impulse.y * bodyB.inverseMass; + bodyB.anglePrev -= Vector.cross(offset, impulse) * bodyB.inverseInertia; + } + } + } + } + }; + + /** + * Find a solution for pair velocities. + * @method solveVelocity + * @param {pair[]} pairs + * @param {number} timeScale + */ + Resolver.solveVelocity = function(pairs, timeScale) { + var timeScaleSquared = timeScale * timeScale, + impulse = Vector._temp[0], + tempA = Vector._temp[1], + tempB = Vector._temp[2], + tempC = Vector._temp[3], + tempD = Vector._temp[4], + tempE = Vector._temp[5]; + + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + + if (!pair.isActive || pair.isSensor) + continue; + + var collision = pair.collision, + bodyA = collision.parentA, + bodyB = collision.parentB, + normal = collision.normal, + tangent = collision.tangent, + contacts = pair.activeContacts, + contactShare = 1 / contacts.length; + + // update body velocities + bodyA.velocity.x = bodyA.position.x - bodyA.positionPrev.x; + bodyA.velocity.y = bodyA.position.y - bodyA.positionPrev.y; + bodyB.velocity.x = bodyB.position.x - bodyB.positionPrev.x; + bodyB.velocity.y = bodyB.position.y - bodyB.positionPrev.y; + bodyA.angularVelocity = bodyA.angle - bodyA.anglePrev; + bodyB.angularVelocity = bodyB.angle - bodyB.anglePrev; + + // resolve each contact + for (var j = 0; j < contacts.length; j++) { + var contact = contacts[j], + contactVertex = contact.vertex, + offsetA = Vector.sub(contactVertex, bodyA.position, tempA), + offsetB = Vector.sub(contactVertex, bodyB.position, tempB), + velocityPointA = Vector.add(bodyA.velocity, Vector.mult(Vector.perp(offsetA), bodyA.angularVelocity), tempC), + velocityPointB = Vector.add(bodyB.velocity, Vector.mult(Vector.perp(offsetB), bodyB.angularVelocity), tempD), + relativeVelocity = Vector.sub(velocityPointA, velocityPointB, tempE), + normalVelocity = Vector.dot(normal, relativeVelocity); + + var tangentVelocity = Vector.dot(tangent, relativeVelocity), + tangentSpeed = Math.abs(tangentVelocity), + tangentVelocityDirection = Common.sign(tangentVelocity); + + // raw impulses + var normalImpulse = (1 + pair.restitution) * normalVelocity, + normalForce = Common.clamp(pair.separation + normalVelocity, 0, 1) * Resolver._frictionNormalMultiplier; + + // coulomb friction + var tangentImpulse = tangentVelocity, + maxFriction = Infinity; + + if (tangentSpeed > pair.friction * pair.frictionStatic * normalForce * timeScaleSquared) { + maxFriction = tangentSpeed; + tangentImpulse = Common.clamp( + pair.friction * tangentVelocityDirection * timeScaleSquared, + -maxFriction, maxFriction + ); + } + + // modify impulses accounting for mass, inertia and offset + var oAcN = Vector.cross(offsetA, normal), + oBcN = Vector.cross(offsetB, normal), + share = contactShare / (bodyA.inverseMass + bodyB.inverseMass + bodyA.inverseInertia * oAcN * oAcN + bodyB.inverseInertia * oBcN * oBcN); + + normalImpulse *= share; + tangentImpulse *= share; + + // handle high velocity and resting collisions separately + if (normalVelocity < 0 && normalVelocity * normalVelocity > Resolver._restingThresh * timeScaleSquared) { + // high normal velocity so clear cached contact normal impulse + contact.normalImpulse = 0; + } else { + // solve resting collision constraints using Erin Catto's method (GDC08) + // impulse constraint tends to 0 + var contactNormalImpulse = contact.normalImpulse; + contact.normalImpulse = Math.min(contact.normalImpulse + normalImpulse, 0); + normalImpulse = contact.normalImpulse - contactNormalImpulse; + } + + // handle high velocity and resting collisions separately + if (tangentVelocity * tangentVelocity > Resolver._restingThreshTangent * timeScaleSquared) { + // high tangent velocity so clear cached contact tangent impulse + contact.tangentImpulse = 0; + } else { + // solve resting collision constraints using Erin Catto's method (GDC08) + // tangent impulse tends to -tangentSpeed or +tangentSpeed + var contactTangentImpulse = contact.tangentImpulse; + contact.tangentImpulse = Common.clamp(contact.tangentImpulse + tangentImpulse, -maxFriction, maxFriction); + tangentImpulse = contact.tangentImpulse - contactTangentImpulse; + } + + // total impulse from contact + impulse.x = (normal.x * normalImpulse) + (tangent.x * tangentImpulse); + impulse.y = (normal.y * normalImpulse) + (tangent.y * tangentImpulse); + + // apply impulse from contact + if (!(bodyA.isStatic || bodyA.isSleeping)) { + bodyA.positionPrev.x += impulse.x * bodyA.inverseMass; + bodyA.positionPrev.y += impulse.y * bodyA.inverseMass; + bodyA.anglePrev += Vector.cross(offsetA, impulse) * bodyA.inverseInertia; + } + + if (!(bodyB.isStatic || bodyB.isSleeping)) { + bodyB.positionPrev.x -= impulse.x * bodyB.inverseMass; + bodyB.positionPrev.y -= impulse.y * bodyB.inverseMass; + bodyB.anglePrev -= Vector.cross(offsetB, impulse) * bodyB.inverseInertia; + } + } + } + }; + +})(); + + +/***/ }), +/* 238 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Pairs` module contains methods for creating and manipulating collision pair sets. +* +* @class Pairs +*/ + +var Pairs = {}; + +module.exports = Pairs; + +var Pair = __webpack_require__(112); +var Common = __webpack_require__(12); + +(function() { + + Pairs._pairMaxIdleLife = 1000; + + /** + * Creates a new pairs structure. + * @method create + * @param {object} options + * @return {pairs} A new pairs structure + */ + Pairs.create = function(options) { + return Common.extend({ + table: {}, + list: [], + collisionStart: [], + collisionActive: [], + collisionEnd: [] + }, options); + }; + + /** + * Updates pairs given a list of collisions. + * @method update + * @param {object} pairs + * @param {collision[]} collisions + * @param {number} timestamp + */ + Pairs.update = function(pairs, collisions, timestamp) { + var pairsList = pairs.list, + pairsTable = pairs.table, + collisionStart = pairs.collisionStart, + collisionEnd = pairs.collisionEnd, + collisionActive = pairs.collisionActive, + collision, + pairId, + pair, + i; + + // clear collision state arrays, but maintain old reference + collisionStart.length = 0; + collisionEnd.length = 0; + collisionActive.length = 0; + + for (i = 0; i < pairsList.length; i++) { + pairsList[i].confirmedActive = false; + } + + for (i = 0; i < collisions.length; i++) { + collision = collisions[i]; + + if (collision.collided) { + pairId = Pair.id(collision.bodyA, collision.bodyB); + + pair = pairsTable[pairId]; + + if (pair) { + // pair already exists (but may or may not be active) + if (pair.isActive) { + // pair exists and is active + collisionActive.push(pair); + } else { + // pair exists but was inactive, so a collision has just started again + collisionStart.push(pair); + } + + // update the pair + Pair.update(pair, collision, timestamp); + pair.confirmedActive = true; + } else { + // pair did not exist, create a new pair + pair = Pair.create(collision, timestamp); + pairsTable[pairId] = pair; + + // push the new pair + collisionStart.push(pair); + pairsList.push(pair); + } + } + } + + // deactivate previously active pairs that are now inactive + for (i = 0; i < pairsList.length; i++) { + pair = pairsList[i]; + if (pair.isActive && !pair.confirmedActive) { + Pair.setActive(pair, false, timestamp); + collisionEnd.push(pair); + } + } + }; + + /** + * Finds and removes pairs that have been inactive for a set amount of time. + * @method removeOld + * @param {object} pairs + * @param {number} timestamp + */ + Pairs.removeOld = function(pairs, timestamp) { + var pairsList = pairs.list, + pairsTable = pairs.table, + indexesToRemove = [], + pair, + collision, + pairIndex, + i; + + for (i = 0; i < pairsList.length; i++) { + pair = pairsList[i]; + collision = pair.collision; + + // never remove sleeping pairs + if (collision.bodyA.isSleeping || collision.bodyB.isSleeping) { + pair.timeUpdated = timestamp; + continue; + } + + // if pair is inactive for too long, mark it to be removed + if (timestamp - pair.timeUpdated > Pairs._pairMaxIdleLife) { + indexesToRemove.push(i); + } + } + + // remove marked pairs + for (i = 0; i < indexesToRemove.length; i++) { + pairIndex = indexesToRemove[i] - i; + pair = pairsList[pairIndex]; + delete pairsTable[pair.id]; + pairsList.splice(pairIndex, 1); + } + }; + + /** + * Clears the given pairs structure. + * @method clear + * @param {pairs} pairs + * @return {pairs} pairs + */ + Pairs.clear = function(pairs) { + pairs.table = {}; + pairs.list.length = 0; + pairs.collisionStart.length = 0; + pairs.collisionActive.length = 0; + pairs.collisionEnd.length = 0; + return pairs; + }; + +})(); + + +/***/ }), +/* 239 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Grid` module contains methods for creating and manipulating collision broadphase grid structures. +* +* @class Grid +*/ + +var Grid = {}; + +module.exports = Grid; + +var Pair = __webpack_require__(112); +var Detector = __webpack_require__(150); +var Common = __webpack_require__(12); + +(function() { + + /** + * Creates a new grid. + * @method create + * @param {} options + * @return {grid} A new grid + */ + Grid.create = function(options) { + var defaults = { + controller: Grid, + detector: Detector.collisions, + buckets: {}, + pairs: {}, + pairsList: [], + bucketWidth: 48, + bucketHeight: 48 + }; + + return Common.extend(defaults, options); + }; + + /** + * The width of a single grid bucket. + * + * @property bucketWidth + * @type number + * @default 48 + */ + + /** + * The height of a single grid bucket. + * + * @property bucketHeight + * @type number + * @default 48 + */ + + /** + * Updates the grid. + * @method update + * @param {grid} grid + * @param {body[]} bodies + * @param {engine} engine + * @param {boolean} forceUpdate + */ + Grid.update = function(grid, bodies, engine, forceUpdate) { + var i, col, row, + world = engine.world, + buckets = grid.buckets, + bucket, + bucketId, + gridChanged = false; + + // @if DEBUG + var metrics = engine.metrics; + metrics.broadphaseTests = 0; + // @endif + + for (i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (body.isSleeping && !forceUpdate) + continue; + + // don't update out of world bodies + if (body.bounds.max.x < world.bounds.min.x || body.bounds.min.x > world.bounds.max.x + || body.bounds.max.y < world.bounds.min.y || body.bounds.min.y > world.bounds.max.y) + continue; + + var newRegion = Grid._getRegion(grid, body); + + // if the body has changed grid region + if (!body.region || newRegion.id !== body.region.id || forceUpdate) { + + // @if DEBUG + metrics.broadphaseTests += 1; + // @endif + + if (!body.region || forceUpdate) + body.region = newRegion; + + var union = Grid._regionUnion(newRegion, body.region); + + // update grid buckets affected by region change + // iterate over the union of both regions + for (col = union.startCol; col <= union.endCol; col++) { + for (row = union.startRow; row <= union.endRow; row++) { + bucketId = Grid._getBucketId(col, row); + bucket = buckets[bucketId]; + + var isInsideNewRegion = (col >= newRegion.startCol && col <= newRegion.endCol + && row >= newRegion.startRow && row <= newRegion.endRow); + + var isInsideOldRegion = (col >= body.region.startCol && col <= body.region.endCol + && row >= body.region.startRow && row <= body.region.endRow); + + // remove from old region buckets + if (!isInsideNewRegion && isInsideOldRegion) { + if (isInsideOldRegion) { + if (bucket) + Grid._bucketRemoveBody(grid, bucket, body); + } + } + + // add to new region buckets + if (body.region === newRegion || (isInsideNewRegion && !isInsideOldRegion) || forceUpdate) { + if (!bucket) + bucket = Grid._createBucket(buckets, bucketId); + Grid._bucketAddBody(grid, bucket, body); + } + } + } + + // set the new region + body.region = newRegion; + + // flag changes so we can update pairs + gridChanged = true; + } + } + + // update pairs list only if pairs changed (i.e. a body changed region) + if (gridChanged) + grid.pairsList = Grid._createActivePairsList(grid); + }; + + /** + * Clears the grid. + * @method clear + * @param {grid} grid + */ + Grid.clear = function(grid) { + grid.buckets = {}; + grid.pairs = {}; + grid.pairsList = []; + }; + + /** + * Finds the union of two regions. + * @method _regionUnion + * @private + * @param {} regionA + * @param {} regionB + * @return {} region + */ + Grid._regionUnion = function(regionA, regionB) { + var startCol = Math.min(regionA.startCol, regionB.startCol), + endCol = Math.max(regionA.endCol, regionB.endCol), + startRow = Math.min(regionA.startRow, regionB.startRow), + endRow = Math.max(regionA.endRow, regionB.endRow); + + return Grid._createRegion(startCol, endCol, startRow, endRow); + }; + + /** + * Gets the region a given body falls in for a given grid. + * @method _getRegion + * @private + * @param {} grid + * @param {} body + * @return {} region + */ + Grid._getRegion = function(grid, body) { + var bounds = body.bounds, + startCol = Math.floor(bounds.min.x / grid.bucketWidth), + endCol = Math.floor(bounds.max.x / grid.bucketWidth), + startRow = Math.floor(bounds.min.y / grid.bucketHeight), + endRow = Math.floor(bounds.max.y / grid.bucketHeight); + + return Grid._createRegion(startCol, endCol, startRow, endRow); + }; + + /** + * Creates a region. + * @method _createRegion + * @private + * @param {} startCol + * @param {} endCol + * @param {} startRow + * @param {} endRow + * @return {} region + */ + Grid._createRegion = function(startCol, endCol, startRow, endRow) { + return { + id: startCol + ',' + endCol + ',' + startRow + ',' + endRow, + startCol: startCol, + endCol: endCol, + startRow: startRow, + endRow: endRow + }; + }; + + /** + * Gets the bucket id at the given position. + * @method _getBucketId + * @private + * @param {} column + * @param {} row + * @return {string} bucket id + */ + Grid._getBucketId = function(column, row) { + return 'C' + column + 'R' + row; + }; + + /** + * Creates a bucket. + * @method _createBucket + * @private + * @param {} buckets + * @param {} bucketId + * @return {} bucket + */ + Grid._createBucket = function(buckets, bucketId) { + var bucket = buckets[bucketId] = []; + return bucket; + }; + + /** + * Adds a body to a bucket. + * @method _bucketAddBody + * @private + * @param {} grid + * @param {} bucket + * @param {} body + */ + Grid._bucketAddBody = function(grid, bucket, body) { + // add new pairs + for (var i = 0; i < bucket.length; i++) { + var bodyB = bucket[i]; + + if (body.id === bodyB.id || (body.isStatic && bodyB.isStatic)) + continue; + + // keep track of the number of buckets the pair exists in + // important for Grid.update to work + var pairId = Pair.id(body, bodyB), + pair = grid.pairs[pairId]; + + if (pair) { + pair[2] += 1; + } else { + grid.pairs[pairId] = [body, bodyB, 1]; + } + } + + // add to bodies (after pairs, otherwise pairs with self) + bucket.push(body); + }; + + /** + * Removes a body from a bucket. + * @method _bucketRemoveBody + * @private + * @param {} grid + * @param {} bucket + * @param {} body + */ + Grid._bucketRemoveBody = function(grid, bucket, body) { + // remove from bucket + bucket.splice(Common.indexOf(bucket, body), 1); + + // update pair counts + for (var i = 0; i < bucket.length; i++) { + // keep track of the number of buckets the pair exists in + // important for _createActivePairsList to work + var bodyB = bucket[i], + pairId = Pair.id(body, bodyB), + pair = grid.pairs[pairId]; + + if (pair) + pair[2] -= 1; + } + }; + + /** + * Generates a list of the active pairs in the grid. + * @method _createActivePairsList + * @private + * @param {} grid + * @return [] pairs + */ + Grid._createActivePairsList = function(grid) { + var pairKeys, + pair, + pairs = []; + + // grid.pairs is used as a hashmap + pairKeys = Common.keys(grid.pairs); + + // iterate over grid.pairs + for (var k = 0; k < pairKeys.length; k++) { + pair = grid.pairs[pairKeys[k]]; + + // if pair exists in at least one bucket + // it is a pair that needs further collision testing so push it + if (pair[2] > 0) { + pairs.push(pair); + } else { + delete grid.pairs[pairKeys[k]]; + } + } + + return pairs; + }; + +})(); + + +/***/ }), +/* 240 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter` module is the top level namespace. It also includes a function for installing plugins on top of the library. +* +* @class Matter +*/ + +var Matter = {}; + +module.exports = Matter; + +var Plugin = __webpack_require__(147); +var Common = __webpack_require__(12); + +(function() { + + /** + * The library name. + * @property name + * @readOnly + * @type {String} + */ + Matter.name = 'matter-js'; + + /** + * The library version. + * @property version + * @readOnly + * @type {String} + */ + Matter.version = '0.14.2'; + + /** + * A list of plugin dependencies to be installed. These are normally set and installed through `Matter.use`. + * Alternatively you may set `Matter.uses` manually and install them by calling `Plugin.use(Matter)`. + * @property uses + * @type {Array} + */ + Matter.uses = []; + + /** + * The plugins that have been installed through `Matter.Plugin.install`. Read only. + * @property used + * @readOnly + * @type {Array} + */ + Matter.used = []; + + /** + * Installs the given plugins on the `Matter` namespace. + * This is a short-hand for `Plugin.use`, see it for more information. + * Call this function once at the start of your code, with all of the plugins you wish to install as arguments. + * Avoid calling this function multiple times unless you intend to manually control installation order. + * @method use + * @param ...plugin {Function} The plugin(s) to install on `base` (multi-argument). + */ + Matter.use = function() { + Plugin.use(Matter, Array.prototype.slice.call(arguments)); + }; + + /** + * Chains a function to excute before the original function on the given `path` relative to `Matter`. + * See also docs for `Common.chain`. + * @method before + * @param {string} path The path relative to `Matter` + * @param {function} func The function to chain before the original + * @return {function} The chained function that replaced the original + */ + Matter.before = function(path, func) { + path = path.replace(/^Matter./, ''); + return Common.chainPathBefore(Matter, path, func); + }; + + /** + * Chains a function to excute after the original function on the given `path` relative to `Matter`. + * See also docs for `Common.chain`. + * @method after + * @param {string} path The path relative to `Matter` + * @param {function} func The function to chain after the original + * @return {function} The chained function that replaced the original + */ + Matter.after = function(path, func) { + path = path.replace(/^Matter./, ''); + return Common.chainPathAfter(Matter, path, func); + }; + +})(); + + +/***/ }), +/* 241 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AnimationComponent = __webpack_require__(437); +var Class = __webpack_require__(0); +var Components = __webpack_require__(113); +var GameObject = __webpack_require__(17); +var GetFastValue = __webpack_require__(1); +var Pipeline = __webpack_require__(133); +var Sprite = __webpack_require__(57); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Matter Physics Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.Sprite + * @memberof Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Matter.Components.Bounce + * @extends Phaser.Physics.Matter.Components.Collision + * @extends Phaser.Physics.Matter.Components.Force + * @extends Phaser.Physics.Matter.Components.Friction + * @extends Phaser.Physics.Matter.Components.Gravity + * @extends Phaser.Physics.Matter.Components.Mass + * @extends Phaser.Physics.Matter.Components.Sensor + * @extends Phaser.Physics.Matter.Components.SetBody + * @extends Phaser.Physics.Matter.Components.Sleep + * @extends Phaser.Physics.Matter.Components.Static + * @extends Phaser.Physics.Matter.Components.Transform + * @extends Phaser.Physics.Matter.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Physics.Matter.World} world - [description] + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {object} [options={}] - Matter.js configuration object. + */ +var MatterSprite = new Class({ + + Extends: Sprite, + + Mixins: [ + Components.Bounce, + Components.Collision, + Components.Force, + Components.Friction, + Components.Gravity, + Components.Mass, + Components.Sensor, + Components.SetBody, + Components.Sleep, + Components.Static, + Components.Transform, + Components.Velocity, + Pipeline + ], + + initialize: + + function MatterSprite (world, x, y, texture, frame, options) + { + GameObject.call(this, world.scene, 'Image'); + + this.anims = new AnimationComponent(this); + + this.setTexture(texture, frame); + this.setSizeToFrame(); + this.setOrigin(); + + /** + * [description] + * + * @name Phaser.Physics.Matter.Sprite#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Matter.Sprite#_tempVec2 + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tempVec2 = new Vector2(x, y); + + var shape = GetFastValue(options, 'shape', null); + + if (shape) + { + this.setBody(shape, options); + } + else + { + this.setRectangle(this.width, this.height, options); + } + + this.setPosition(x, y); + + this.initPipeline('TextureTintPipeline'); + } + +}); + +module.exports = MatterSprite; + + +/***/ }), +/* 242 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(113); +var GameObject = __webpack_require__(17); +var GetFastValue = __webpack_require__(1); +var Image = __webpack_require__(78); +var Pipeline = __webpack_require__(133); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Matter Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.Image + * @memberof Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Matter.Components.Bounce + * @extends Phaser.Physics.Matter.Components.Collision + * @extends Phaser.Physics.Matter.Components.Force + * @extends Phaser.Physics.Matter.Components.Friction + * @extends Phaser.Physics.Matter.Components.Gravity + * @extends Phaser.Physics.Matter.Components.Mass + * @extends Phaser.Physics.Matter.Components.Sensor + * @extends Phaser.Physics.Matter.Components.SetBody + * @extends Phaser.Physics.Matter.Components.Sleep + * @extends Phaser.Physics.Matter.Components.Static + * @extends Phaser.Physics.Matter.Components.Transform + * @extends Phaser.Physics.Matter.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Physics.Matter.World} world - [description] + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {object} [options={}] - Matter.js configuration object. + */ +var MatterImage = new Class({ + + Extends: Image, + + Mixins: [ + Components.Bounce, + Components.Collision, + Components.Force, + Components.Friction, + Components.Gravity, + Components.Mass, + Components.Sensor, + Components.SetBody, + Components.Sleep, + Components.Static, + Components.Transform, + Components.Velocity, + Pipeline + ], + + initialize: + + function MatterImage (world, x, y, texture, frame, options) + { + GameObject.call(this, world.scene, 'Image'); + + this.setTexture(texture, frame); + this.setSizeToFrame(); + this.setOrigin(); + + /** + * [description] + * + * @name Phaser.Physics.Matter.Image#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Matter.Image#_tempVec2 + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tempVec2 = new Vector2(x, y); + + var shape = GetFastValue(options, 'shape', null); + + if (shape) + { + this.setBody(shape, options); + } + else + { + this.setRectangle(this.width, this.height, options); + } + + this.setPosition(x, y); + + this.initPipeline('TextureTintPipeline'); + } + +}); + +module.exports = MatterImage; + + +/***/ }), +/* 243 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Composites` module contains factory methods for creating composite bodies +* with commonly used configurations (such as stacks and chains). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Composites +*/ + +var Composites = {}; + +module.exports = Composites; + +var Composite = __webpack_require__(63); +var Constraint = __webpack_require__(73); +var Common = __webpack_require__(12); +var Body = __webpack_require__(25); +var Bodies = __webpack_require__(55); + +(function() { + + /** + * Create a new composite containing bodies created in the callback in a grid arrangement. + * This function uses the body's bounds to prevent overlaps. + * @method stack + * @param {number} xx + * @param {number} yy + * @param {number} columns + * @param {number} rows + * @param {number} columnGap + * @param {number} rowGap + * @param {function} callback + * @return {composite} A new composite containing objects created in the callback + */ + Composites.stack = function(xx, yy, columns, rows, columnGap, rowGap, callback) { + var stack = Composite.create({ label: 'Stack' }), + x = xx, + y = yy, + lastBody, + i = 0; + + for (var row = 0; row < rows; row++) { + var maxHeight = 0; + + for (var column = 0; column < columns; column++) { + var body = callback(x, y, column, row, lastBody, i); + + if (body) { + var bodyHeight = body.bounds.max.y - body.bounds.min.y, + bodyWidth = body.bounds.max.x - body.bounds.min.x; + + if (bodyHeight > maxHeight) + maxHeight = bodyHeight; + + Body.translate(body, { x: bodyWidth * 0.5, y: bodyHeight * 0.5 }); + + x = body.bounds.max.x + columnGap; + + Composite.addBody(stack, body); + + lastBody = body; + i += 1; + } else { + x += columnGap; + } + } + + y += maxHeight + rowGap; + x = xx; + } + + return stack; + }; + + /** + * Chains all bodies in the given composite together using constraints. + * @method chain + * @param {composite} composite + * @param {number} xOffsetA + * @param {number} yOffsetA + * @param {number} xOffsetB + * @param {number} yOffsetB + * @param {object} options + * @return {composite} A new composite containing objects chained together with constraints + */ + Composites.chain = function(composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options) { + var bodies = composite.bodies; + + for (var i = 1; i < bodies.length; i++) { + var bodyA = bodies[i - 1], + bodyB = bodies[i], + bodyAHeight = bodyA.bounds.max.y - bodyA.bounds.min.y, + bodyAWidth = bodyA.bounds.max.x - bodyA.bounds.min.x, + bodyBHeight = bodyB.bounds.max.y - bodyB.bounds.min.y, + bodyBWidth = bodyB.bounds.max.x - bodyB.bounds.min.x; + + var defaults = { + bodyA: bodyA, + pointA: { x: bodyAWidth * xOffsetA, y: bodyAHeight * yOffsetA }, + bodyB: bodyB, + pointB: { x: bodyBWidth * xOffsetB, y: bodyBHeight * yOffsetB } + }; + + var constraint = Common.extend(defaults, options); + + Composite.addConstraint(composite, Constraint.create(constraint)); + } + + composite.label += ' Chain'; + + return composite; + }; + + /** + * Connects bodies in the composite with constraints in a grid pattern, with optional cross braces. + * @method mesh + * @param {composite} composite + * @param {number} columns + * @param {number} rows + * @param {boolean} crossBrace + * @param {object} options + * @return {composite} The composite containing objects meshed together with constraints + */ + Composites.mesh = function(composite, columns, rows, crossBrace, options) { + var bodies = composite.bodies, + row, + col, + bodyA, + bodyB, + bodyC; + + for (row = 0; row < rows; row++) { + for (col = 1; col < columns; col++) { + bodyA = bodies[(col - 1) + (row * columns)]; + bodyB = bodies[col + (row * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); + } + + if (row > 0) { + for (col = 0; col < columns; col++) { + bodyA = bodies[col + ((row - 1) * columns)]; + bodyB = bodies[col + (row * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyA, bodyB: bodyB }, options))); + + if (crossBrace && col > 0) { + bodyC = bodies[(col - 1) + ((row - 1) * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options))); + } + + if (crossBrace && col < columns - 1) { + bodyC = bodies[(col + 1) + ((row - 1) * columns)]; + Composite.addConstraint(composite, Constraint.create(Common.extend({ bodyA: bodyC, bodyB: bodyB }, options))); + } + } + } + } + + composite.label += ' Mesh'; + + return composite; + }; + + /** + * Create a new composite containing bodies created in the callback in a pyramid arrangement. + * This function uses the body's bounds to prevent overlaps. + * @method pyramid + * @param {number} xx + * @param {number} yy + * @param {number} columns + * @param {number} rows + * @param {number} columnGap + * @param {number} rowGap + * @param {function} callback + * @return {composite} A new composite containing objects created in the callback + */ + Composites.pyramid = function(xx, yy, columns, rows, columnGap, rowGap, callback) { + return Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y, column, row, lastBody, i) { + var actualRows = Math.min(rows, Math.ceil(columns / 2)), + lastBodyWidth = lastBody ? lastBody.bounds.max.x - lastBody.bounds.min.x : 0; + + if (row > actualRows) + return; + + // reverse row order + row = actualRows - row; + + var start = row, + end = columns - 1 - row; + + if (column < start || column > end) + return; + + // retroactively fix the first body's position, since width was unknown + if (i === 1) { + Body.translate(lastBody, { x: (column + (columns % 2 === 1 ? 1 : -1)) * lastBodyWidth, y: 0 }); + } + + var xOffset = lastBody ? column * lastBodyWidth : 0; + + return callback(xx + xOffset + column * columnGap, y, column, row, lastBody, i); + }); + }; + + /** + * Creates a composite with a Newton's Cradle setup of bodies and constraints. + * @method newtonsCradle + * @param {number} xx + * @param {number} yy + * @param {number} number + * @param {number} size + * @param {number} length + * @return {composite} A new composite newtonsCradle body + */ + Composites.newtonsCradle = function(xx, yy, number, size, length) { + var newtonsCradle = Composite.create({ label: 'Newtons Cradle' }); + + for (var i = 0; i < number; i++) { + var separation = 1.9, + circle = Bodies.circle(xx + i * (size * separation), yy + length, size, + { inertia: Infinity, restitution: 1, friction: 0, frictionAir: 0.0001, slop: 1 }), + constraint = Constraint.create({ pointA: { x: xx + i * (size * separation), y: yy }, bodyB: circle }); + + Composite.addBody(newtonsCradle, circle); + Composite.addConstraint(newtonsCradle, constraint); + } + + return newtonsCradle; + }; + + /** + * Creates a composite with simple car setup of bodies and constraints. + * @method car + * @param {number} xx + * @param {number} yy + * @param {number} width + * @param {number} height + * @param {number} wheelSize + * @return {composite} A new composite car body + */ + Composites.car = function(xx, yy, width, height, wheelSize) { + var group = Body.nextGroup(true), + wheelBase = 20, + wheelAOffset = -width * 0.5 + wheelBase, + wheelBOffset = width * 0.5 - wheelBase, + wheelYOffset = 0; + + var car = Composite.create({ label: 'Car' }), + body = Bodies.rectangle(xx, yy, width, height, { + collisionFilter: { + group: group + }, + chamfer: { + radius: height * 0.5 + }, + density: 0.0002 + }); + + var wheelA = Bodies.circle(xx + wheelAOffset, yy + wheelYOffset, wheelSize, { + collisionFilter: { + group: group + }, + friction: 0.8 + }); + + var wheelB = Bodies.circle(xx + wheelBOffset, yy + wheelYOffset, wheelSize, { + collisionFilter: { + group: group + }, + friction: 0.8 + }); + + var axelA = Constraint.create({ + bodyB: body, + pointB: { x: wheelAOffset, y: wheelYOffset }, + bodyA: wheelA, + stiffness: 1, + length: 0 + }); + + var axelB = Constraint.create({ + bodyB: body, + pointB: { x: wheelBOffset, y: wheelYOffset }, + bodyA: wheelB, + stiffness: 1, + length: 0 + }); + + Composite.addBody(car, body); + Composite.addBody(car, wheelA); + Composite.addBody(car, wheelB); + Composite.addConstraint(car, axelA); + Composite.addConstraint(car, axelB); + + return car; + }; + + /** + * Creates a simple soft body like object. + * @method softBody + * @param {number} xx + * @param {number} yy + * @param {number} columns + * @param {number} rows + * @param {number} columnGap + * @param {number} rowGap + * @param {boolean} crossBrace + * @param {number} particleRadius + * @param {} particleOptions + * @param {} constraintOptions + * @return {composite} A new composite softBody + */ + Composites.softBody = function(xx, yy, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions) { + particleOptions = Common.extend({ inertia: Infinity }, particleOptions); + constraintOptions = Common.extend({ stiffness: 0.2, render: { type: 'line', anchors: false } }, constraintOptions); + + var softBody = Composites.stack(xx, yy, columns, rows, columnGap, rowGap, function(x, y) { + return Bodies.circle(x, y, particleRadius, particleOptions); + }); + + Composites.mesh(softBody, columns, rows, crossBrace, constraintOptions); + + softBody.label = 'Soft Body'; + + return softBody; + }; + +})(); + + +/***/ }), +/* 244 */ +/***/ (function(module, exports) { + +/** + * @author Stefan Hedman (http://steffe.se) + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// v0.3.0 + +module.exports = { + decomp: polygonDecomp, + quickDecomp: polygonQuickDecomp, + isSimple: polygonIsSimple, + removeCollinearPoints: polygonRemoveCollinearPoints, + removeDuplicatePoints: polygonRemoveDuplicatePoints, + makeCCW: polygonMakeCCW +}; + +/** + * Compute the intersection between two lines. + * @static + * @method lineInt + * @param {Array} l1 Line vector 1 + * @param {Array} l2 Line vector 2 + * @param {Number} precision Precision to use when checking if the lines are parallel + * @return {Array} The intersection point. + */ +function lineInt(l1,l2,precision){ + precision = precision || 0; + var i = [0,0]; // point + var a1, b1, c1, a2, b2, c2, det; // scalars + a1 = l1[1][1] - l1[0][1]; + b1 = l1[0][0] - l1[1][0]; + c1 = a1 * l1[0][0] + b1 * l1[0][1]; + a2 = l2[1][1] - l2[0][1]; + b2 = l2[0][0] - l2[1][0]; + c2 = a2 * l2[0][0] + b2 * l2[0][1]; + det = a1 * b2 - a2*b1; + if (!scalar_eq(det, 0, precision)) { // lines are not parallel + i[0] = (b2 * c1 - b1 * c2) / det; + i[1] = (a1 * c2 - a2 * c1) / det; + } + return i; +} + +/** + * Checks if two line segments intersects. + * @method segmentsIntersect + * @param {Array} p1 The start vertex of the first line segment. + * @param {Array} p2 The end vertex of the first line segment. + * @param {Array} q1 The start vertex of the second line segment. + * @param {Array} q2 The end vertex of the second line segment. + * @return {Boolean} True if the two line segments intersect + */ +function lineSegmentsIntersect(p1, p2, q1, q2){ + var dx = p2[0] - p1[0]; + var dy = p2[1] - p1[1]; + var da = q2[0] - q1[0]; + var db = q2[1] - q1[1]; + + // segments are parallel + if((da*dy - db*dx) === 0){ + return false; + } + + var s = (dx * (q1[1] - p1[1]) + dy * (p1[0] - q1[0])) / (da * dy - db * dx); + var t = (da * (p1[1] - q1[1]) + db * (q1[0] - p1[0])) / (db * dx - da * dy); + + return (s>=0 && s<=1 && t>=0 && t<=1); +} + +/** + * Get the area of a triangle spanned by the three given points. Note that the area will be negative if the points are not given in counter-clockwise order. + * @static + * @method area + * @param {Array} a + * @param {Array} b + * @param {Array} c + * @return {Number} + */ +function triangleArea(a,b,c){ + return (((b[0] - a[0])*(c[1] - a[1]))-((c[0] - a[0])*(b[1] - a[1]))); +} + +function isLeft(a,b,c){ + return triangleArea(a,b,c) > 0; +} + +function isLeftOn(a,b,c) { + return triangleArea(a, b, c) >= 0; +} + +function isRight(a,b,c) { + return triangleArea(a, b, c) < 0; +} + +function isRightOn(a,b,c) { + return triangleArea(a, b, c) <= 0; +} + +var tmpPoint1 = [], + tmpPoint2 = []; + +/** + * Check if three points are collinear + * @method collinear + * @param {Array} a + * @param {Array} b + * @param {Array} c + * @param {Number} [thresholdAngle=0] Threshold angle to use when comparing the vectors. The function will return true if the angle between the resulting vectors is less than this value. Use zero for max precision. + * @return {Boolean} + */ +function collinear(a,b,c,thresholdAngle) { + if(!thresholdAngle){ + return triangleArea(a, b, c) === 0; + } else { + var ab = tmpPoint1, + bc = tmpPoint2; + + ab[0] = b[0]-a[0]; + ab[1] = b[1]-a[1]; + bc[0] = c[0]-b[0]; + bc[1] = c[1]-b[1]; + + var dot = ab[0]*bc[0] + ab[1]*bc[1], + magA = Math.sqrt(ab[0]*ab[0] + ab[1]*ab[1]), + magB = Math.sqrt(bc[0]*bc[0] + bc[1]*bc[1]), + angle = Math.acos(dot/(magA*magB)); + return angle < thresholdAngle; + } +} + +function sqdist(a,b){ + var dx = b[0] - a[0]; + var dy = b[1] - a[1]; + return dx * dx + dy * dy; +} + +/** + * Get a vertex at position i. It does not matter if i is out of bounds, this function will just cycle. + * @method at + * @param {Number} i + * @return {Array} + */ +function polygonAt(polygon, i){ + var s = polygon.length; + return polygon[i < 0 ? i % s + s : i % s]; +} + +/** + * Clear the polygon data + * @method clear + * @return {Array} + */ +function polygonClear(polygon){ + polygon.length = 0; +} + +/** + * Append points "from" to "to"-1 from an other polygon "poly" onto this one. + * @method append + * @param {Polygon} poly The polygon to get points from. + * @param {Number} from The vertex index in "poly". + * @param {Number} to The end vertex index in "poly". Note that this vertex is NOT included when appending. + * @return {Array} + */ +function polygonAppend(polygon, poly, from, to){ + for(var i=from; i v[br][0])) { + br = i; + } + } + + // reverse poly if clockwise + if (!isLeft(polygonAt(polygon, br - 1), polygonAt(polygon, br), polygonAt(polygon, br + 1))) { + polygonReverse(polygon); + return true; + } else { + return false; + } +} + +/** + * Reverse the vertices in the polygon + * @method reverse + */ +function polygonReverse(polygon){ + var tmp = []; + var N = polygon.length; + for(var i=0; i!==N; i++){ + tmp.push(polygon.pop()); + } + for(var i=0; i!==N; i++){ + polygon[i] = tmp[i]; + } +} + +/** + * Check if a point in the polygon is a reflex point + * @method isReflex + * @param {Number} i + * @return {Boolean} + */ +function polygonIsReflex(polygon, i){ + return isRight(polygonAt(polygon, i - 1), polygonAt(polygon, i), polygonAt(polygon, i + 1)); +} + +var tmpLine1=[], + tmpLine2=[]; + +/** + * Check if two vertices in the polygon can see each other + * @method canSee + * @param {Number} a Vertex index 1 + * @param {Number} b Vertex index 2 + * @return {Boolean} + */ +function polygonCanSee(polygon, a,b) { + var p, dist, l1=tmpLine1, l2=tmpLine2; + + if (isLeftOn(polygonAt(polygon, a + 1), polygonAt(polygon, a), polygonAt(polygon, b)) && isRightOn(polygonAt(polygon, a - 1), polygonAt(polygon, a), polygonAt(polygon, b))) { + return false; + } + dist = sqdist(polygonAt(polygon, a), polygonAt(polygon, b)); + for (var i = 0; i !== polygon.length; ++i) { // for each edge + if ((i + 1) % polygon.length === a || i === a){ // ignore incident edges + continue; + } + if (isLeftOn(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i + 1)) && isRightOn(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i))) { // if diag intersects an edge + l1[0] = polygonAt(polygon, a); + l1[1] = polygonAt(polygon, b); + l2[0] = polygonAt(polygon, i); + l2[1] = polygonAt(polygon, i + 1); + p = lineInt(l1,l2); + if (sqdist(polygonAt(polygon, a), p) < dist) { // if edge is blocking visibility to b + return false; + } + } + } + + return true; +} + +/** + * Check if two vertices in the polygon can see each other + * @method canSee2 + * @param {Number} a Vertex index 1 + * @param {Number} b Vertex index 2 + * @return {Boolean} + */ +function polygonCanSee2(polygon, a,b) { + // for each edge + for (var i = 0; i !== polygon.length; ++i) { + // ignore incident edges + if (i === a || i === b || (i + 1) % polygon.length === a || (i + 1) % polygon.length === b){ + continue; + } + if( lineSegmentsIntersect(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i), polygonAt(polygon, i+1)) ){ + return false; + } + } + return true; +} + +/** + * Copy the polygon from vertex i to vertex j. + * @method copy + * @param {Number} i + * @param {Number} j + * @param {Polygon} [targetPoly] Optional target polygon to save in. + * @return {Polygon} The resulting copy. + */ +function polygonCopy(polygon, i,j,targetPoly){ + var p = targetPoly || []; + polygonClear(p); + if (i < j) { + // Insert all vertices from i to j + for(var k=i; k<=j; k++){ + p.push(polygon[k]); + } + + } else { + + // Insert vertices 0 to j + for(var k=0; k<=j; k++){ + p.push(polygon[k]); + } + + // Insert vertices i to end + for(var k=i; k 0){ + return polygonSlice(polygon, edges); + } else { + return [polygon]; + } +} + +/** + * Slices the polygon given one or more cut edges. If given one, this function will return two polygons (false on failure). If many, an array of polygons. + * @method slice + * @param {Array} cutEdges A list of edges, as returned by .getCutEdges() + * @return {Array} + */ +function polygonSlice(polygon, cutEdges){ + if(cutEdges.length === 0){ + return [polygon]; + } + if(cutEdges instanceof Array && cutEdges.length && cutEdges[0] instanceof Array && cutEdges[0].length===2 && cutEdges[0][0] instanceof Array){ + + var polys = [polygon]; + + for(var i=0; i maxlevel){ + console.warn("quickDecomp: max level ("+maxlevel+") reached."); + return result; + } + + for (var i = 0; i < polygon.length; ++i) { + if (polygonIsReflex(poly, i)) { + reflexVertices.push(poly[i]); + upperDist = lowerDist = Number.MAX_VALUE; + + + for (var j = 0; j < polygon.length; ++j) { + if (isLeft(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && isRightOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j - 1))) { // if line intersects with an edge + p = getIntersectionPoint(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j), polygonAt(poly, j - 1)); // find the point of intersection + if (isRight(polygonAt(poly, i + 1), polygonAt(poly, i), p)) { // make sure it's inside the poly + d = sqdist(poly[i], p); + if (d < lowerDist) { // keep only the closest intersection + lowerDist = d; + lowerInt = p; + lowerIndex = j; + } + } + } + if (isLeft(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j + 1)) && isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j))) { + p = getIntersectionPoint(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j), polygonAt(poly, j + 1)); + if (isLeft(polygonAt(poly, i - 1), polygonAt(poly, i), p)) { + d = sqdist(poly[i], p); + if (d < upperDist) { + upperDist = d; + upperInt = p; + upperIndex = j; + } + } + } + } + + // if there are no vertices to connect to, choose a point in the middle + if (lowerIndex === (upperIndex + 1) % polygon.length) { + //console.log("Case 1: Vertex("+i+"), lowerIndex("+lowerIndex+"), upperIndex("+upperIndex+"), poly.size("+polygon.length+")"); + p[0] = (lowerInt[0] + upperInt[0]) / 2; + p[1] = (lowerInt[1] + upperInt[1]) / 2; + steinerPoints.push(p); + + if (i < upperIndex) { + //lowerPoly.insert(lowerPoly.end(), poly.begin() + i, poly.begin() + upperIndex + 1); + polygonAppend(lowerPoly, poly, i, upperIndex+1); + lowerPoly.push(p); + upperPoly.push(p); + if (lowerIndex !== 0){ + //upperPoly.insert(upperPoly.end(), poly.begin() + lowerIndex, poly.end()); + polygonAppend(upperPoly, poly,lowerIndex,poly.length); + } + //upperPoly.insert(upperPoly.end(), poly.begin(), poly.begin() + i + 1); + polygonAppend(upperPoly, poly,0,i+1); + } else { + if (i !== 0){ + //lowerPoly.insert(lowerPoly.end(), poly.begin() + i, poly.end()); + polygonAppend(lowerPoly, poly,i,poly.length); + } + //lowerPoly.insert(lowerPoly.end(), poly.begin(), poly.begin() + upperIndex + 1); + polygonAppend(lowerPoly, poly,0,upperIndex+1); + lowerPoly.push(p); + upperPoly.push(p); + //upperPoly.insert(upperPoly.end(), poly.begin() + lowerIndex, poly.begin() + i + 1); + polygonAppend(upperPoly, poly,lowerIndex,i+1); + } + } else { + // connect to the closest point within the triangle + //console.log("Case 2: Vertex("+i+"), closestIndex("+closestIndex+"), poly.size("+polygon.length+")\n"); + + if (lowerIndex > upperIndex) { + upperIndex += polygon.length; + } + closestDist = Number.MAX_VALUE; + + if(upperIndex < lowerIndex){ + return result; + } + + for (var j = lowerIndex; j <= upperIndex; ++j) { + if ( + isLeftOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && + isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j)) + ) { + d = sqdist(polygonAt(poly, i), polygonAt(poly, j)); + if (d < closestDist && polygonCanSee2(poly, i, j)) { + closestDist = d; + closestIndex = j % polygon.length; + } + } + } + + if (i < closestIndex) { + polygonAppend(lowerPoly, poly,i,closestIndex+1); + if (closestIndex !== 0){ + polygonAppend(upperPoly, poly,closestIndex,v.length); + } + polygonAppend(upperPoly, poly,0,i+1); + } else { + if (i !== 0){ + polygonAppend(lowerPoly, poly,i,v.length); + } + polygonAppend(lowerPoly, poly,0,closestIndex+1); + polygonAppend(upperPoly, poly,closestIndex,i+1); + } + } + + // solve smallest poly first + if (lowerPoly.length < upperPoly.length) { + polygonQuickDecomp(lowerPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); + polygonQuickDecomp(upperPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); + } else { + polygonQuickDecomp(upperPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); + polygonQuickDecomp(lowerPoly,result,reflexVertices,steinerPoints,delta,maxlevel,level); + } + + return result; + } + } + result.push(polygon); + + return result; +} + +/** + * Remove collinear points in the polygon. + * @method removeCollinearPoints + * @param {Number} [precision] The threshold angle to use when determining whether two edges are collinear. Use zero for finest precision. + * @return {Number} The number of points removed + */ +function polygonRemoveCollinearPoints(polygon, precision){ + var num = 0; + for(var i=polygon.length-1; polygon.length>3 && i>=0; --i){ + if(collinear(polygonAt(polygon, i-1),polygonAt(polygon, i),polygonAt(polygon, i+1),precision)){ + // Remove the middle point + polygon.splice(i%polygon.length,1); + num++; + } + } + return num; +} + +/** + * Remove duplicate points in the polygon. + * @method removeDuplicatePoints + * @param {Number} [precision] The threshold to use when determining whether two points are the same. Use zero for best precision. + */ +function polygonRemoveDuplicatePoints(polygon, precision){ + for(var i=polygon.length-1; i>=1; --i){ + var pi = polygon[i]; + for(var j=i-1; j>=0; --j){ + if(points_eq(pi, polygon[j], precision)){ + polygon.splice(i,1); + continue; + } + } + } +} + +/** + * Check if two scalars are equal + * @static + * @method eq + * @param {Number} a + * @param {Number} b + * @param {Number} [precision] + * @return {Boolean} + */ +function scalar_eq(a,b,precision){ + precision = precision || 0; + return Math.abs(a-b) <= precision; +} + +/** + * Check if two points are equal + * @static + * @method points_eq + * @param {Array} a + * @param {Array} b + * @param {Number} [precision] + * @return {Boolean} + */ +function points_eq(a,b,precision){ + return scalar_eq(a[0],b[0],precision) && scalar_eq(a[1],b[1],precision); +} + + +/***/ }), +/* 245 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bodies = __webpack_require__(55); +var Class = __webpack_require__(0); +var Composites = __webpack_require__(243); +var Constraint = __webpack_require__(73); +var MatterGameObject = __webpack_require__(551); +var MatterImage = __webpack_require__(242); +var MatterSprite = __webpack_require__(241); +var MatterTileBody = __webpack_require__(151); +var PointerConstraint = __webpack_require__(537); + +/** + * @classdesc + * [description] + * + * @class Factory + * @memberof Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Matter.World} world - [description] + */ +var Factory = new Class({ + + initialize: + + function Factory (world) + { + /** + * [description] + * + * @name Phaser.Physics.Matter.Factory#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Matter.Factory#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = world.scene; + + /** + * A reference to the Scene.Systems this Matter Physics instance belongs to. + * + * @name Phaser.Physics.Matter.Factory#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = world.scene.sys; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#rectangle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} options - [description] + * + * @return {MatterJS.Body} A Matter JS Body. + */ + rectangle: function (x, y, width, height, options) + { + var body = Bodies.rectangle(x, y, width, height, options); + + this.world.add(body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#trapezoid + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} slope - [description] + * @param {object} options - [description] + * + * @return {MatterJS.Body} A Matter JS Body. + */ + trapezoid: function (x, y, width, height, slope, options) + { + var body = Bodies.trapezoid(x, y, width, height, slope, options); + + this.world.add(body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#circle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} radius - [description] + * @param {object} options - [description] + * @param {number} maxSides - [description] + * + * @return {MatterJS.Body} A Matter JS Body. + */ + circle: function (x, y, radius, options, maxSides) + { + var body = Bodies.circle(x, y, radius, options, maxSides); + + this.world.add(body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#polygon + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} sides - [description] + * @param {number} radius - [description] + * @param {object} options - [description] + * + * @return {MatterJS.Body} A Matter JS Body. + */ + polygon: function (x, y, sides, radius, options) + { + var body = Bodies.polygon(x, y, sides, radius, options); + + this.world.add(body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#fromVertices + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {array} vertexSets - [description] + * @param {object} options - [description] + * @param {boolean} flagInternal - [description] + * @param {boolean} removeCollinear - [description] + * @param {number} minimumArea - [description] + * + * @return {MatterJS.Body} A Matter JS Body. + */ + fromVertices: function (x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) + { + var body = Bodies.fromVertices(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea); + + this.world.add(body); + + return body; + }, + + /** + * Create a new composite containing Matter Image objects created in a grid arrangement. + * This function uses the body bounds to prevent overlaps. + * + * @method Phaser.Physics.Matter.Factory#imageStack + * @since 3.0.0 + * + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} frame - An optional frame from the Texture this Game Object is rendering with. Set to `null` to skip this value. + * @param {number} x - The horizontal position of this composite in the world. + * @param {number} y - The vertical position of this composite in the world. + * @param {number} columns - The number of columns in the grid. + * @param {number} rows - The number of rows in the grid. + * @param {number} [columnGap=0] - The distance between each column. + * @param {number} [rowGap=0] - The distance between each row. + * @param {object} [options] - [description] + * + * @return {MatterJS.Composite} A Matter JS Composite Stack. + */ + imageStack: function (key, frame, x, y, columns, rows, columnGap, rowGap, options) + { + if (columnGap === undefined) { columnGap = 0; } + if (rowGap === undefined) { rowGap = 0; } + if (options === undefined) { options = {}; } + + var world = this.world; + var displayList = this.sys.displayList; + + options.addToWorld = false; + + var stack = Composites.stack(x, y, columns, rows, columnGap, rowGap, function (x, y) + { + var image = new MatterImage(world, x, y, key, frame, options); + + displayList.add(image); + + return image.body; + }); + + world.add(stack); + + return stack; + }, + + /** + * Create a new composite containing bodies created in the callback in a grid arrangement. + * This function uses the body bounds to prevent overlaps. + * + * @method Phaser.Physics.Matter.Factory#stack + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this composite in the world. + * @param {number} y - The vertical position of this composite in the world. + * @param {number} columns - The number of columns in the grid. + * @param {number} rows - The number of rows in the grid. + * @param {number} columnGap - The distance between each column. + * @param {number} rowGap - The distance between each row. + * @param {function} callback - The callback that creates the stack. + * + * @return {MatterJS.Composite} A new composite containing objects created in the callback. + */ + stack: function (x, y, columns, rows, columnGap, rowGap, callback) + { + var stack = Composites.stack(x, y, columns, rows, columnGap, rowGap, callback); + + this.world.add(stack); + + return stack; + }, + + /** + * Create a new composite containing bodies created in the callback in a pyramid arrangement. + * This function uses the body bounds to prevent overlaps. + * + * @method Phaser.Physics.Matter.Factory#pyramid + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this composite in the world. + * @param {number} y - The vertical position of this composite in the world. + * @param {number} columns - The number of columns in the pyramid. + * @param {number} rows - The number of rows in the pyramid. + * @param {number} columnGap - The distance between each column. + * @param {number} rowGap - The distance between each row. + * @param {function} callback - [description] + * + * @return {MatterJS.Composite} A Matter JS Composite pyramid. + */ + pyramid: function (x, y, columns, rows, columnGap, rowGap, callback) + { + var stack = Composites.pyramid(x, y, columns, rows, columnGap, rowGap, callback); + + this.world.add(stack); + + return stack; + }, + + /** + * Chains all bodies in the given composite together using constraints. + * + * @method Phaser.Physics.Matter.Factory#chain + * @since 3.0.0 + * + * @param {MatterJS.Composite} composite - [description] + * @param {number} xOffsetA - [description] + * @param {number} yOffsetA - [description] + * @param {number} xOffsetB - [description] + * @param {number} yOffsetB - [description] + * @param {object} options - [description] + * + * @return {MatterJS.Composite} A new composite containing objects chained together with constraints. + */ + chain: function (composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options) + { + return Composites.chain(composite, xOffsetA, yOffsetA, xOffsetB, yOffsetB, options); + }, + + /** + * Connects bodies in the composite with constraints in a grid pattern, with optional cross braces. + * + * @method Phaser.Physics.Matter.Factory#mesh + * @since 3.0.0 + * + * @param {MatterJS.Composite} composite - [description] + * @param {number} columns - [description] + * @param {number} rows - [description] + * @param {boolean} crossBrace - [description] + * @param {object} options - [description] + * + * @return {MatterJS.Composite} The composite containing objects meshed together with constraints. + */ + mesh: function (composite, columns, rows, crossBrace, options) + { + return Composites.mesh(composite, columns, rows, crossBrace, options); + }, + + /** + * Creates a composite with a Newton's Cradle setup of bodies and constraints. + * + * @method Phaser.Physics.Matter.Factory#newtonsCradle + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} number - [description] + * @param {number} size - [description] + * @param {number} length - [description] + * + * @return {MatterJS.Composite} A new composite newtonsCradle body. + */ + newtonsCradle: function (x, y, number, size, length) + { + var composite = Composites.newtonsCradle(x, y, number, size, length); + + this.world.add(composite); + + return composite; + }, + + /** + * Creates a composite with simple car setup of bodies and constraints. + * + * @method Phaser.Physics.Matter.Factory#car + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} wheelSize - [description] + * + * @return {MatterJS.Composite} A new composite car body. + */ + car: function (x, y, width, height, wheelSize) + { + var composite = Composites.car(x, y, width, height, wheelSize); + + this.world.add(composite); + + return composite; + }, + + /** + * Creates a simple soft body like object. + * + * @method Phaser.Physics.Matter.Factory#softBody + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this composite in the world. + * @param {number} y - The vertical position of this composite in the world. + * @param {number} columns - The number of columns in the Composite. + * @param {number} rows - The number of rows in the Composite. + * @param {number} columnGap - The distance between each column. + * @param {number} rowGap - The distance between each row. + * @param {boolean} crossBrace - [description] + * @param {number} particleRadius - [description] + * @param {object} particleOptions - [description] + * @param {object} constraintOptions - [description] + * + * @return {MatterJS.Composite} A new composite simple soft body. + */ + softBody: function (x, y, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions) + { + var composite = Composites.softBody(x, y, columns, rows, columnGap, rowGap, crossBrace, particleRadius, particleOptions, constraintOptions); + + this.world.add(composite); + + return composite; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#joint + * @since 3.0.0 + * + * @param {MatterJS.Body} bodyA - [description] + * @param {MatterJS.Body} bodyB - [description] + * @param {number} length - [description] + * @param {number} [stiffness=1] - [description] + * @param {object} [options={}] - [description] + * + * @return {MatterJS.Constraint} A Matter JS Constraint. + */ + joint: function (bodyA, bodyB, length, stiffness, options) + { + return this.constraint(bodyA, bodyB, length, stiffness, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#spring + * @since 3.0.0 + * + * @param {MatterJS.Body} bodyA - [description] + * @param {MatterJS.Body} bodyB - [description] + * @param {number} length - [description] + * @param {number} [stiffness=1] - [description] + * @param {object} [options={}] - [description] + * + * @return {MatterJS.Constraint} A Matter JS Constraint. + */ + spring: function (bodyA, bodyB, length, stiffness, options) + { + return this.constraint(bodyA, bodyB, length, stiffness, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#constraint + * @since 3.0.0 + * + * @param {MatterJS.Body} bodyA - [description] + * @param {MatterJS.Body} bodyB - [description] + * @param {number} length - [description] + * @param {number} [stiffness=1] - [description] + * @param {object} [options={}] - [description] + * + * @return {MatterJS.Constraint} A Matter JS Constraint. + */ + constraint: function (bodyA, bodyB, length, stiffness, options) + { + if (stiffness === undefined) { stiffness = 1; } + if (options === undefined) { options = {}; } + + options.bodyA = (bodyA.type === 'body') ? bodyA : bodyA.body; + options.bodyB = (bodyB.type === 'body') ? bodyB : bodyB.body; + options.length = length; + options.stiffness = stiffness; + + var constraint = Constraint.create(options); + + this.world.add(constraint); + + return constraint; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#worldConstraint + * @since 3.0.0 + * + * @param {MatterJS.Body} bodyB - [description] + * @param {number} length - [description] + * @param {number} [stiffness=1] - [description] + * @param {object} [options={}] - [description] + * + * @return {MatterJS.Constraint} A Matter JS Constraint. + */ + worldConstraint: function (bodyB, length, stiffness, options) + { + if (stiffness === undefined) { stiffness = 1; } + if (options === undefined) { options = {}; } + + options.bodyB = (bodyB.type === 'body') ? bodyB : bodyB.body; + options.length = length; + options.stiffness = stiffness; + + var constraint = Constraint.create(options); + + this.world.add(constraint); + + return constraint; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#mouseSpring + * @since 3.0.0 + * + * @param {object} options - [description] + * + * @return {MatterJS.Constraint} A Matter JS Constraint. + */ + mouseSpring: function (options) + { + return this.pointerConstraint(options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#pointerConstraint + * @since 3.0.0 + * + * @param {object} options - [description] + * + * @return {MatterJS.Constraint} A Matter JS Constraint. + */ + 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); + + return pointerConstraint; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. Set to `null` to skip this value. + * @param {object} [options={}] - [description] + * + * @return {Phaser.Physics.Matter.Image} [description] + */ + image: function (x, y, key, frame, options) + { + var image = new MatterImage(this.world, x, y, key, frame, options); + + this.sys.displayList.add(image); + + return image; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#tileBody + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.Tile} tile - [description] + * @param {object} options - [description] + * + * @return {Phaser.Physics.Matter.TileBody} [description] + */ + tileBody: function (tile, options) + { + var tileBody = new MatterTileBody(this.world, tile, options); + + return tileBody; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. Set to `null` to skip this value. + * @param {object} [options={}] - [description] + * + * @return {Phaser.Physics.Matter.Sprite} [description] + */ + sprite: function (x, y, key, frame, options) + { + var sprite = new MatterSprite(this.world, x, y, key, frame, options); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + return sprite; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Factory#gameObject + * @since 3.3.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to inject the Matter Body in to. + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} The Game Object that had the Matter Body injected into it. + */ + 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; + } + +}); + +module.exports = Factory; + + +/***/ }), +/* 246 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(252); +var Class = __webpack_require__(0); +var COLLIDES = __webpack_require__(91); +var CollisionMap = __webpack_require__(251); +var EventEmitter = __webpack_require__(11); +var GetFastValue = __webpack_require__(1); +var HasValue = __webpack_require__(77); +var Set = __webpack_require__(96); +var Solver = __webpack_require__(555); +var TILEMAP_FORMATS = __webpack_require__(30); +var TYPE = __webpack_require__(90); + +/** + * @typedef {object} Phaser.Physics.Impact.WorldConfig + * + * @property {number} [gravity=0] - Sets {@link Phaser.Physics.Impact.World#gravity} + * @property {number} [cellSize=64] - The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world. + * @property {number} [timeScale=1] - A `Number` that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed. + * @property {number} [maxStep=0.05] - [description] + * @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Impact.World#debug}. + * @property {number} [maxVelocity=100] - The maximum velocity a body can move. + * @property {boolean} [debugShowBody=true] - Whether the Body's boundary is drawn to the debug display. + * @property {boolean} [debugShowVelocity=true] - Whether the Body's velocity is drawn to the debug display. + * @property {number} [debugBodyColor=0xff00ff] - The color of this Body on the debug display. + * @property {number} [debugVelocityColor=0x00ff00] - The color of the Body's velocity on the debug display. + * @property {number} [maxVelocityX=maxVelocity] - Maximum X velocity objects can move. + * @property {number} [maxVelocityY=maxVelocity] - Maximum Y velocity objects can move. + * @property {number} [minBounceVelocity=40] - The minimum velocity an object can be moving at to be considered for bounce. + * @property {number} [gravityFactor=1] - Gravity multiplier. Set to 0 for no gravity. + * @property {number} [bounciness=0] - The default bounce, or restitution, of bodies in the world. + * @property {(object|boolean)} [setBounds] - Should the world have bounds enabled by default? + * @property {number} [setBounds.x=0] - The x coordinate of the world bounds. + * @property {number} [setBounds.y=0] - The y coordinate of the world bounds. + * @property {number} [setBounds.width] - The width of the world bounds. + * @property {number} [setBounds.height] - The height of the world bounds. + * @property {number} [setBounds.thickness=64] - The thickness of the walls of the world bounds. + * @property {boolean} [setBounds.left=true] - Should the left-side world bounds wall be created? + * @property {boolean} [setBounds.right=true] - Should the right-side world bounds wall be created? + * @property {boolean} [setBounds.top=true] - Should the top world bounds wall be created? + * @property {boolean} [setBounds.bottom=true] - Should the bottom world bounds wall be created? + */ + +/** + * An object containing the 4 wall bodies that bound the physics world. + * + * @typedef {object} Phaser.Physics.Impact.WorldDefaults + * + * @property {boolean} debugShowBody - Whether the Body's boundary is drawn to the debug display. + * @property {boolean} debugShowVelocity - Whether the Body's velocity is drawn to the debug display. + * @property {number} bodyDebugColor - The color of this Body on the debug display. + * @property {number} velocityDebugColor - The color of the Body's velocity on the debug display. + * @property {number} maxVelocityX - Maximum X velocity objects can move. + * @property {number} maxVelocityY - Maximum Y velocity objects can move. + * @property {number} minBounceVelocity - The minimum velocity an object can be moving at to be considered for bounce. + * @property {number} gravityFactor - Gravity multiplier. Set to 0 for no gravity. + * @property {number} bounciness - The default bounce, or restitution, of bodies in the world. + */ + +/** + * @typedef {object} Phaser.Physics.Impact.WorldWalls + * + * @property {?Phaser.Physics.Impact.Body} left - The left-side wall of the world bounds. + * @property {?Phaser.Physics.Impact.Body} right - The right-side wall of the world bounds. + * @property {?Phaser.Physics.Impact.Body} top - The top wall of the world bounds. + * @property {?Phaser.Physics.Impact.Body} bottom - The bottom wall of the world bounds. + */ + +/** + * @classdesc + * [description] + * + * @class World + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Physics.Impact.WorldConfig} config - [description] + */ +var World = new Class({ + + Extends: EventEmitter, + + initialize: + + function World (scene, config) + { + EventEmitter.call(this); + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#bodies + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.bodies = new Set(); + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#gravity + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.gravity = GetFastValue(config, 'gravity', 0); + + /** + * Spatial hash cell dimensions + * + * @name Phaser.Physics.Impact.World#cellSize + * @type {integer} + * @default 64 + * @since 3.0.0 + */ + this.cellSize = GetFastValue(config, 'cellSize', 64); + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#collisionMap + * @type {Phaser.Physics.Impact.CollisionMap} + * @since 3.0.0 + */ + this.collisionMap = new CollisionMap(); + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = GetFastValue(config, 'timeScale', 1); + + /** + * Impacts maximum time step is 20 fps. + * + * @name Phaser.Physics.Impact.World#maxStep + * @type {number} + * @default 0.05 + * @since 3.0.0 + */ + this.maxStep = GetFastValue(config, 'maxStep', 0.05); + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#drawDebug + * @type {boolean} + * @since 3.0.0 + */ + this.drawDebug = GetFastValue(config, 'debug', false); + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#debugGraphic + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.debugGraphic; + + var _maxVelocity = GetFastValue(config, 'maxVelocity', 100); + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#defaults + * @type {Phaser.Physics.Impact.WorldDefaults} + * @since 3.0.0 + */ + this.defaults = { + debugShowBody: GetFastValue(config, 'debugShowBody', true), + debugShowVelocity: GetFastValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetFastValue(config, 'debugBodyColor', 0xff00ff), + velocityDebugColor: GetFastValue(config, 'debugVelocityColor', 0x00ff00), + maxVelocityX: GetFastValue(config, 'maxVelocityX', _maxVelocity), + maxVelocityY: GetFastValue(config, 'maxVelocityY', _maxVelocity), + minBounceVelocity: GetFastValue(config, 'minBounceVelocity', 40), + gravityFactor: GetFastValue(config, 'gravityFactor', 1), + bounciness: GetFastValue(config, 'bounciness', 0) + }; + + /** + * An object containing the 4 wall bodies that bound the physics world. + * + * @name Phaser.Physics.Impact.World#walls + * @type {Phaser.Physics.Impact.WorldWalls} + * @since 3.0.0 + */ + this.walls = { left: null, right: null, top: null, bottom: null }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#delta + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.delta = 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.World#_lastId + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._lastId = 0; + + if (GetFastValue(config, 'setBounds', false)) + { + var boundsConfig = config['setBounds']; + + if (typeof boundsConfig === 'boolean') + { + this.setBounds(); + } + else + { + var x = GetFastValue(boundsConfig, 'x', 0); + var y = GetFastValue(boundsConfig, 'y', 0); + var width = GetFastValue(boundsConfig, 'width', scene.sys.game.config.width); + var height = GetFastValue(boundsConfig, 'height', scene.sys.game.config.height); + var thickness = GetFastValue(boundsConfig, 'thickness', 64); + var left = GetFastValue(boundsConfig, 'left', true); + var right = GetFastValue(boundsConfig, 'right', true); + var top = GetFastValue(boundsConfig, 'top', true); + var bottom = GetFastValue(boundsConfig, 'bottom', true); + + this.setBounds(x, y, width, height, thickness, left, right, top, bottom); + } + } + + if (this.drawDebug) + { + this.createDebugGraphic(); + } + }, + + /** + * Sets the collision map for the world either from a Weltmeister JSON level in the cache or from + * a 2D array. If loading from a Weltmeister level, the map must have a layer called "collision". + * + * @method Phaser.Physics.Impact.World#setCollisionMap + * @since 3.0.0 + * + * @param {(string|integer[][])} key - Either a string key that corresponds to a Weltmeister level + * in the cache, or a 2D array of collision IDs. + * @param {integer} tileSize - The size of a tile. This is optional if loading from a Weltmeister + * level in the cache. + * + * @return {?Phaser.Physics.Impact.CollisionMap} The newly created CollisionMap, or null if the method failed to + * create the CollisionMap. + */ + setCollisionMap: function (key, tileSize) + { + if (typeof key === 'string') + { + var tilemapData = this.scene.cache.tilemap.get(key); + + if (!tilemapData || tilemapData.format !== TILEMAP_FORMATS.WELTMEISTER) + { + console.warn('The specified key does not correspond to a Weltmeister tilemap: ' + key); + return null; + } + + var layers = tilemapData.data.layer; + var collisionLayer; + for (var i = 0; i < layers.length; i++) + { + if (layers[i].name === 'collision') + { + collisionLayer = layers[i]; + break; + } + } + + if (tileSize === undefined) { tileSize = collisionLayer.tilesize; } + + this.collisionMap = new CollisionMap(tileSize, collisionLayer.data); + } + else if (Array.isArray(key)) + { + this.collisionMap = new CollisionMap(tileSize, key); + } + else + { + console.warn('Invalid Weltmeister collision map data: ' + key); + } + + return this.collisionMap; + }, + + /** + * Sets the collision map for the world from a tilemap layer. Only tiles that are marked as + * colliding will be used. You can specify the mapping from tiles to slope IDs in a couple of + * ways. The easiest is to use Tiled and the slopeTileProperty option. Alternatively, you can + * manually create a slopeMap that stores the mapping between tile indices and slope IDs. + * + * @method Phaser.Physics.Impact.World#setCollisionMapFromTilemapLayer + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemap layer to use. + * @param {object} [options] - Options for controlling the mapping from tiles to slope IDs. + * @param {string} [options.slopeTileProperty=null] - Slope IDs can be stored on tiles directly + * using Tiled's tileset editor. If a tile has a property with the given slopeTileProperty string + * name, the value of that property for the tile will be used for its slope mapping. E.g. a 45 + * degree slope upward could be given a "slope" property with a value of 2. + * @param {object} [options.slopeMap=null] - A tile index to slope definition map. + * @param {integer} [options.defaultCollidingSlope=null] - If specified, the default slope ID to + * assign to a colliding tile. If not specified, the tile's index is used. + * @param {integer} [options.defaultNonCollidingSlope=0] - The default slope ID to assign to a + * non-colliding tile. + * + * @return {Phaser.Physics.Impact.CollisionMap} The newly created CollisionMap. + */ + setCollisionMapFromTilemapLayer: function (tilemapLayer, options) + { + if (options === undefined) { options = {}; } + var slopeProperty = GetFastValue(options, 'slopeProperty', null); + var slopeMap = GetFastValue(options, 'slopeMap', null); + var collidingSlope = GetFastValue(options, 'defaultCollidingSlope', null); + var nonCollidingSlope = GetFastValue(options, 'defaultNonCollidingSlope', 0); + + var layerData = tilemapLayer.layer; + var tileSize = layerData.baseTileWidth; + var collisionData = []; + + for (var ty = 0; ty < layerData.height; ty++) + { + collisionData[ty] = []; + + for (var tx = 0; tx < layerData.width; tx++) + { + var tile = layerData.data[ty][tx]; + + if (tile && tile.collides) + { + if (slopeProperty !== null && HasValue(tile.properties, slopeProperty)) + { + collisionData[ty][tx] = parseInt(tile.properties[slopeProperty], 10); + } + else if (slopeMap !== null && HasValue(slopeMap, tile.index)) + { + collisionData[ty][tx] = slopeMap[tile.index]; + } + else if (collidingSlope !== null) + { + collisionData[ty][tx] = collidingSlope; + } + else + { + collisionData[ty][tx] = tile.index; + } + } + else + { + collisionData[ty][tx] = nonCollidingSlope; + } + } + } + + this.collisionMap = new CollisionMap(tileSize, collisionData); + + return this.collisionMap; + }, + + /** + * Sets the bounds of the Physics world to match the given world pixel dimensions. + * You can optionally set which 'walls' to create: left, right, top or bottom. + * If none of the walls are given it will default to use the walls settings it had previously. + * I.e. if you previously told it to not have the left or right walls, and you then adjust the world size + * the newly created bounds will also not have the left and right walls. + * Explicitly state them in the parameters to override this. + * + * @method Phaser.Physics.Impact.World#setBounds + * @since 3.0.0 + * + * @param {number} [x] - The x coordinate of the top-left corner of the bounds. + * @param {number} [y] - The y coordinate of the top-left corner of the bounds. + * @param {number} [width] - The width of the bounds. + * @param {number} [height] - The height of the bounds. + * @param {number} [thickness=64] - [description] + * @param {boolean} [left=true] - If true will create the left bounds wall. + * @param {boolean} [right=true] - If true will create the right bounds wall. + * @param {boolean} [top=true] - If true will create the top bounds wall. + * @param {boolean} [bottom=true] - If true will create the bottom bounds wall. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setBounds: function (x, y, width, height, thickness, left, right, top, bottom) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + if (thickness === undefined) { thickness = 64; } + if (left === undefined) { left = true; } + if (right === undefined) { right = true; } + if (top === undefined) { top = true; } + if (bottom === undefined) { bottom = true; } + + this.updateWall(left, 'left', x - thickness, y, thickness, height); + this.updateWall(right, 'right', x + width, y, thickness, height); + this.updateWall(top, 'top', x, y - thickness, width, thickness); + this.updateWall(bottom, 'bottom', x, y + height, width, thickness); + + return this; + }, + + /** + * position = 'left', 'right', 'top' or 'bottom' + * + * @method Phaser.Physics.Impact.World#updateWall + * @since 3.0.0 + * + * @param {boolean} add - [description] + * @param {string} position - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + */ + updateWall: function (add, position, x, y, width, height) + { + var wall = this.walls[position]; + + if (add) + { + if (wall) + { + wall.resetSize(x, y, width, height); + } + else + { + this.walls[position] = this.create(x, y, width, height); + this.walls[position].name = position; + this.walls[position].gravityFactor = 0; + this.walls[position].collides = COLLIDES.FIXED; + } + } + else + { + if (wall) + { + this.bodies.remove(wall); + } + + this.walls[position] = null; + } + }, + + /** + * Creates a Graphics Game Object used for debug display and enables the world for debug drawing. + * + * @method Phaser.Physics.Impact.World#createDebugGraphic + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} The Graphics object created that will have the debug visuals drawn to it. + */ + createDebugGraphic: function () + { + var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); + + graphic.setDepth(Number.MAX_VALUE); + + this.debugGraphic = graphic; + + this.drawDebug = true; + + return graphic; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#getNextID + * @since 3.0.0 + * + * @return {integer} [description] + */ + getNextID: function () + { + return this._lastId++; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#create + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} sizeX - [description] + * @param {number} sizeY - [description] + * + * @return {Phaser.Physics.Impact.Body} The Body that was added to this World. + */ + create: function (x, y, sizeX, sizeY) + { + var body = new Body(this, x, y, sizeX, sizeY); + + this.bodies.set(body); + + return body; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#remove + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} object - The Body to remove from this World. + */ + remove: function (object) + { + this.bodies.delete(object); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + pause: function () + { + this.enabled = false; + + this.emit('pause'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + resume: function () + { + this.enabled = true; + + this.emit('resume'); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#update + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update: function (time, delta) + { + if (!this.enabled || this.bodies.size === 0) + { + return; + } + + // Impact uses a divided delta value that is clamped to the maxStep (20fps) maximum + + var clampedDelta = Math.min(delta / 1000, this.maxStep) * this.timeScale; + + this.delta = clampedDelta; + + // Update all active bodies + + var i; + var body; + var bodies = this.bodies.entries; + var len = bodies.length; + var hash = {}; + var size = this.cellSize; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enabled) + { + body.update(clampedDelta); + } + } + + // Run collision against them all now they're in the new positions from the update + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body && !body.skipHash()) + { + this.checkHash(body, hash, size); + } + } + + if (this.drawDebug) + { + var graphics = this.debugGraphic; + + graphics.clear(); + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body && body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + } + }, + + /** + * Check the body against the spatial hash. + * + * @method Phaser.Physics.Impact.World#checkHash + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} body - [description] + * @param {object} hash - [description] + * @param {number} size - [description] + */ + checkHash: function (body, hash, size) + { + var checked = {}; + + var xmin = Math.floor(body.pos.x / size); + var ymin = Math.floor(body.pos.y / size); + var xmax = Math.floor((body.pos.x + body.size.x) / size) + 1; + var ymax = Math.floor((body.pos.y + body.size.y) / size) + 1; + + for (var x = xmin; x < xmax; x++) + { + for (var y = ymin; y < ymax; y++) + { + if (!hash[x]) + { + hash[x] = {}; + hash[x][y] = [ body ]; + } + else if (!hash[x][y]) + { + hash[x][y] = [ body ]; + } + else + { + var cell = hash[x][y]; + + for (var c = 0; c < cell.length; c++) + { + if (body.touches(cell[c]) && !checked[cell[c].id]) + { + checked[cell[c].id] = true; + + this.checkBodies(body, cell[c]); + } + } + + cell.push(body); + } + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#checkBodies + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} bodyA - [description] + * @param {Phaser.Physics.Impact.Body} bodyB - [description] + */ + checkBodies: function (bodyA, bodyB) + { + // 2 fixed bodies won't do anything + if (bodyA.collides === COLLIDES.FIXED && bodyB.collides === COLLIDES.FIXED) + { + return; + } + + // bitwise checks + if (bodyA.checkAgainst & bodyB.type) + { + bodyA.check(bodyB); + } + + if (bodyB.checkAgainst & bodyA.type) + { + bodyB.check(bodyA); + } + + if (bodyA.collides && bodyB.collides && bodyA.collides + bodyB.collides > COLLIDES.ACTIVE) + { + Solver(this, bodyA, bodyB); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setCollidesNever + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setCollidesNever: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].collides = COLLIDES.NEVER; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setLite + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setLite: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].collides = COLLIDES.LITE; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setPassive + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setPassive: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].collides = COLLIDES.PASSIVE; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setActive + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setActive: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].collides = COLLIDES.ACTIVE; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setFixed + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the collides value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setFixed: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].collides = COLLIDES.FIXED; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setTypeNone + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setTypeNone: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].type = TYPE.NONE; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setTypeA + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setTypeA: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].type = TYPE.A; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setTypeB + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setTypeB: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].type = TYPE.B; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setAvsB + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setAvsB: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].type = TYPE.A; + bodies[i].checkAgainst = TYPE.B; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setBvsA + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setBvsA: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].type = TYPE.B; + bodies[i].checkAgainst = TYPE.A; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setCheckAgainstNone + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setCheckAgainstNone: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].checkAgainst = TYPE.NONE; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setCheckAgainstA + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setCheckAgainstA: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].checkAgainst = TYPE.A; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#setCheckAgainstB + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body[]} bodies - An Array of Impact Bodies to set the type value on. + * + * @return {Phaser.Physics.Impact.World} This World object. + */ + setCheckAgainstB: function (bodies) + { + for (var i = 0; i < bodies.length; i++) + { + bodies[i].checkAgainst = TYPE.B; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAllListeners(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.World#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.scene = null; + + this.bodies.clear(); + + this.bodies = null; + + this.collisionMap = null; + } + +}); + +module.exports = World; + + +/***/ }), +/* 247 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(153); +var Sprite = __webpack_require__(57); + +/** + * @classdesc + * An Impact Physics Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class ImpactSprite + * @extends Phaser.GameObjects.Sprite + * @memberof Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Impact.Components.Acceleration + * @extends Phaser.Physics.Impact.Components.BodyScale + * @extends Phaser.Physics.Impact.Components.BodyType + * @extends Phaser.Physics.Impact.Components.Bounce + * @extends Phaser.Physics.Impact.Components.CheckAgainst + * @extends Phaser.Physics.Impact.Components.Collides + * @extends Phaser.Physics.Impact.Components.Debug + * @extends Phaser.Physics.Impact.Components.Friction + * @extends Phaser.Physics.Impact.Components.Gravity + * @extends Phaser.Physics.Impact.Components.Offset + * @extends Phaser.Physics.Impact.Components.SetGameObject + * @extends Phaser.Physics.Impact.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ImpactSprite = new Class({ + + Extends: Sprite, + + Mixins: [ + Components.Acceleration, + Components.BodyScale, + Components.BodyType, + Components.Bounce, + Components.CheckAgainst, + Components.Collides, + Components.Debug, + Components.Friction, + Components.Gravity, + Components.Offset, + Components.SetGameObject, + Components.Velocity + ], + + initialize: + + function ImpactSprite (world, x, y, texture, frame) + { + Sprite.call(this, world.scene, x, y, texture, frame); + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#body + * @type {Phaser.Physics.Impact.Body} + * @since 3.0.0 + */ + this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height); + + this.body.parent = this; + this.body.gameObject = this; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#size + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.size = this.body.size; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#offset + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.offset = this.body.offset; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#vel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.vel = this.body.vel; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#accel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.accel = this.body.accel; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#friction + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.friction = this.body.friction; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactSprite#maxVel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.maxVel = this.body.maxVel; + } + +}); + +module.exports = ImpactSprite; + + +/***/ }), +/* 248 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(153); +var Image = __webpack_require__(78); + +/** + * @classdesc + * An Impact Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class ImpactImage + * @extends Phaser.GameObjects.Image + * @memberof Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Impact.Components.Acceleration + * @extends Phaser.Physics.Impact.Components.BodyScale + * @extends Phaser.Physics.Impact.Components.BodyType + * @extends Phaser.Physics.Impact.Components.Bounce + * @extends Phaser.Physics.Impact.Components.CheckAgainst + * @extends Phaser.Physics.Impact.Components.Collides + * @extends Phaser.Physics.Impact.Components.Debug + * @extends Phaser.Physics.Impact.Components.Friction + * @extends Phaser.Physics.Impact.Components.Gravity + * @extends Phaser.Physics.Impact.Components.Offset + * @extends Phaser.Physics.Impact.Components.SetGameObject + * @extends Phaser.Physics.Impact.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ImpactImage = new Class({ + + Extends: Image, + + Mixins: [ + Components.Acceleration, + Components.BodyScale, + Components.BodyType, + Components.Bounce, + Components.CheckAgainst, + Components.Collides, + Components.Debug, + Components.Friction, + Components.Gravity, + Components.Offset, + Components.SetGameObject, + Components.Velocity + ], + + initialize: + + function ImpactImage (world, x, y, texture, frame) + { + Image.call(this, world.scene, x, y, texture, frame); + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#body + * @type {Phaser.Physics.Impact.Body} + * @since 3.0.0 + */ + this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height); + + this.body.parent = this; + this.body.gameObject = this; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#size + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.size = this.body.size; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#offset + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.offset = this.body.offset; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#vel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.vel = this.body.vel; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#accel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.accel = this.body.accel; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#friction + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.friction = this.body.friction; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactImage#maxVel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.maxVel = this.body.maxVel; + } + +}); + +module.exports = ImpactImage; + + +/***/ }), +/* 249 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(153); + +/** + * @classdesc + * [description] + * + * @class ImpactBody + * @memberof Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Impact.Components.Acceleration + * @extends Phaser.Physics.Impact.Components.BodyScale + * @extends Phaser.Physics.Impact.Components.BodyType + * @extends Phaser.Physics.Impact.Components.Bounce + * @extends Phaser.Physics.Impact.Components.CheckAgainst + * @extends Phaser.Physics.Impact.Components.Collides + * @extends Phaser.Physics.Impact.Components.Debug + * @extends Phaser.Physics.Impact.Components.Friction + * @extends Phaser.Physics.Impact.Components.Gravity + * @extends Phaser.Physics.Impact.Components.Offset + * @extends Phaser.Physics.Impact.Components.SetGameObject + * @extends Phaser.Physics.Impact.Components.Velocity + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + */ +var ImpactBody = new Class({ + + Mixins: [ + Components.Acceleration, + Components.BodyScale, + Components.BodyType, + Components.Bounce, + Components.CheckAgainst, + Components.Collides, + Components.Debug, + Components.Friction, + Components.Gravity, + Components.Offset, + Components.SetGameObject, + Components.Velocity + ], + + initialize: + + function ImpactBody (world, x, y, width, height) + { + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#body + * @type {Phaser.Physics.Impact.Body} + * @since 3.0.0 + */ + this.body = world.create(x, y, width, height); + + this.body.parent = this; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#size + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.size = this.body.size; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#offset + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.offset = this.body.offset; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#vel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.vel = this.body.vel; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#accel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.accel = this.body.accel; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#friction + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.friction = this.body.friction; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactBody#maxVel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.maxVel = this.body.maxVel; + } + +}); + +module.exports = ImpactBody; + + +/***/ }), +/* 250 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ImpactBody = __webpack_require__(249); +var ImpactImage = __webpack_require__(248); +var ImpactSprite = __webpack_require__(247); + +/** + * @classdesc + * The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects. + * Objects that are created by this Factory are automatically added to the physics world. + * + * @class Factory + * @memberof Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - A reference to the Impact Physics world. + */ +var Factory = new Class({ + + initialize: + + function Factory (world) + { + /** + * A reference to the Impact Physics world. + * + * @name Phaser.Physics.Impact.Factory#world + * @type {Phaser.Physics.Impact.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * A reference to the Scene.Systems this Impact Physics instance belongs to. + * + * @name Phaser.Physics.Impact.Factory#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = world.scene.sys; + }, + + /** + * Creates a new ImpactBody object and adds it to the physics simulation. + * + * @method Phaser.Physics.Impact.Factory#body + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the body in the physics world. + * @param {number} y - The vertical position of the body in the physics world. + * @param {number} width - The width of the body. + * @param {number} height - The height of the body. + * + * @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created. + */ + body: function (x, y, width, height) + { + return new ImpactBody(this.world, x, y, width, height); + }, + + /** + * Adds an Impact Physics Body to the given Game Object. + * + * @method Phaser.Physics.Impact.Factory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to receive the physics body. + * + * @return {Phaser.GameObjects.GameObject} The Game Object. + */ + existing: function (gameObject) + { + var x = gameObject.x - gameObject.frame.centerX; + var y = gameObject.y - gameObject.frame.centerY; + var w = gameObject.width; + var h = gameObject.height; + + gameObject.body = this.world.create(x, y, w, h); + + gameObject.body.parent = gameObject; + gameObject.body.gameObject = gameObject; + + return gameObject; + }, + + /** + * Creates a new ImpactImage object and adds it to the physics world. + * + * @method Phaser.Physics.Impact.Factory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created. + */ + image: function (x, y, key, frame) + { + var image = new ImpactImage(this.world, x, y, key, frame); + + this.sys.displayList.add(image); + + return image; + }, + + /** + * Creates a new ImpactSprite object and adds it to the physics world. + * + * @method Phaser.Physics.Impact.Factory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created. + */ + sprite: function (x, y, key, frame) + { + var sprite = new ImpactSprite(this.world, x, y, key, frame); + + this.sys.displayList.add(sprite); + 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; + } + +}); + +module.exports = Factory; + + +/***/ }), +/* 251 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DefaultDefs = __webpack_require__(569); + +/** + * @classdesc + * [description] + * + * @class CollisionMap + * @memberof Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @param {integer} [tilesize=32] - [description] + * @param {array} [data] - [description] + */ +var CollisionMap = new Class({ + + initialize: + + function CollisionMap (tilesize, data) + { + if (tilesize === undefined) { tilesize = 32; } + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#tilesize + * @type {integer} + * @default 32 + * @since 3.0.0 + */ + this.tilesize = tilesize; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#data + * @type {array} + * @since 3.0.0 + */ + this.data = (Array.isArray(data)) ? data : []; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#width + * @type {number} + * @since 3.0.0 + */ + this.width = (Array.isArray(data)) ? data[0].length : 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#height + * @type {number} + * @since 3.0.0 + */ + this.height = (Array.isArray(data)) ? data.length : 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#lastSlope + * @type {integer} + * @default 55 + * @since 3.0.0 + */ + this.lastSlope = 55; + + /** + * [description] + * + * @name Phaser.Physics.Impact.CollisionMap#tiledef + * @type {object} + * @since 3.0.0 + */ + this.tiledef = DefaultDefs; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.CollisionMap#trace + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} vx - [description] + * @param {number} vy - [description] + * @param {number} objectWidth - [description] + * @param {number} objectHeight - [description] + * + * @return {boolean} [description] + */ + trace: function (x, y, vx, vy, objectWidth, objectHeight) + { + // Set up the trace-result + var res = { + collision: { x: false, y: false, slope: false }, + pos: { x: x + vx, y: y + vy }, + tile: { x: 0, y: 0 } + }; + + if (!this.data) + { + return res; + } + + var steps = Math.ceil(Math.max(Math.abs(vx), Math.abs(vy)) / this.tilesize); + + if (steps > 1) + { + var sx = vx / steps; + var sy = vy / steps; + + for (var i = 0; i < steps && (sx || sy); i++) + { + this.step(res, x, y, sx, sy, objectWidth, objectHeight, vx, vy, i); + + x = res.pos.x; + y = res.pos.y; + + if (res.collision.x) + { + sx = 0; + vx = 0; + } + + if (res.collision.y) + { + sy = 0; + vy = 0; + } + + if (res.collision.slope) + { + break; + } + } + } + else + { + this.step(res, x, y, vx, vy, objectWidth, objectHeight, vx, vy, 0); + } + + return res; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.CollisionMap#step + * @since 3.0.0 + * + * @param {object} res - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} vx - [description] + * @param {number} vy - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} rvx - [description] + * @param {number} rvy - [description] + * @param {number} step - [description] + */ + step: function (res, x, y, vx, vy, width, height, rvx, rvy, step) + { + var t = 0; + var tileX; + var tileY; + var tilesize = this.tilesize; + var mapWidth = this.width; + var mapHeight = this.height; + + // Horizontal + if (vx) + { + var pxOffsetX = (vx > 0 ? width : 0); + var tileOffsetX = (vx < 0 ? tilesize : 0); + + var firstTileY = Math.max(Math.floor(y / tilesize), 0); + var lastTileY = Math.min(Math.ceil((y + height) / tilesize), mapHeight); + + tileX = Math.floor((res.pos.x + pxOffsetX) / tilesize); + + var prevTileX = Math.floor((x + pxOffsetX) / tilesize); + + if (step > 0 || tileX === prevTileX || prevTileX < 0 || prevTileX >= mapWidth) + { + prevTileX = -1; + } + + if (tileX >= 0 && tileX < mapWidth) + { + for (tileY = firstTileY; tileY < lastTileY; tileY++) + { + if (prevTileX !== -1) + { + t = this.data[tileY][prevTileX]; + + if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY)) + { + break; + } + } + + t = this.data[tileY][tileX]; + + if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY))) + { + if (t > 1 && t <= this.lastSlope && res.collision.slope) + { + break; + } + + res.collision.x = true; + res.tile.x = t; + res.pos.x = (tileX * tilesize) - pxOffsetX + tileOffsetX; + x = res.pos.x; + rvx = 0; + + break; + } + } + } + } + + // Vertical + if (vy) + { + var pxOffsetY = (vy > 0 ? height : 0); + var tileOffsetY = (vy < 0 ? tilesize : 0); + + var firstTileX = Math.max(Math.floor(res.pos.x / tilesize), 0); + var lastTileX = Math.min(Math.ceil((res.pos.x + width) / tilesize), mapWidth); + + tileY = Math.floor((res.pos.y + pxOffsetY) / tilesize); + + var prevTileY = Math.floor((y + pxOffsetY) / tilesize); + + if (step > 0 || tileY === prevTileY || prevTileY < 0 || prevTileY >= mapHeight) + { + prevTileY = -1; + } + + if (tileY >= 0 && tileY < mapHeight) + { + for (tileX = firstTileX; tileX < lastTileX; tileX++) + { + if (prevTileY !== -1) + { + t = this.data[prevTileY][tileX]; + + if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY)) + { + break; + } + } + + t = this.data[tileY][tileX]; + + if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY))) + { + if (t > 1 && t <= this.lastSlope && res.collision.slope) + { + break; + } + + res.collision.y = true; + res.tile.y = t; + res.pos.y = tileY * tilesize - pxOffsetY + tileOffsetY; + + break; + } + } + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.CollisionMap#checkDef + * @since 3.0.0 + * + * @param {object} res - [description] + * @param {number} t - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} vx - [description] + * @param {number} vy - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} tileX - [description] + * @param {number} tileY - [description] + * + * @return {boolean} [description] + */ + checkDef: function (res, t, x, y, vx, vy, width, height, tileX, tileY) + { + var def = this.tiledef[t]; + + if (!def) + { + return false; + } + + var tilesize = this.tilesize; + + var lx = (tileX + def[0]) * tilesize; + var ly = (tileY + def[1]) * tilesize; + var lvx = (def[2] - def[0]) * tilesize; + var lvy = (def[3] - def[1]) * tilesize; + var solid = def[4]; + + var tx = x + vx + (lvy < 0 ? width : 0) - lx; + var ty = y + vy + (lvx > 0 ? height : 0) - ly; + + if (lvx * ty - lvy * tx > 0) + { + if (vx * -lvy + vy * lvx < 0) + { + return solid; + } + + var length = Math.sqrt(lvx * lvx + lvy * lvy); + var nx = lvy / length; + var ny = -lvx / length; + + var proj = tx * nx + ty * ny; + var px = nx * proj; + var py = ny * proj; + + if (px * px + py * py >= vx * vx + vy * vy) + { + return solid || (lvx * (ty - vy) - lvy * (tx - vx) < 0.5); + } + + res.pos.x = x + vx - px; + res.pos.y = y + vy - py; + res.collision.slope = { x: lvx, y: lvy, nx: nx, ny: ny }; + + return true; + } + + return false; + } + +}); + +module.exports = CollisionMap; + + +/***/ }), +/* 252 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var COLLIDES = __webpack_require__(91); +var GetVelocity = __webpack_require__(571); +var TYPE = __webpack_require__(90); +var UpdateMotion = __webpack_require__(570); + +/** + * @callback BodyUpdateCallback + * + * @param {Phaser.Physics.Impact.Body} body - [description] + */ + +/** + * @typedef {object} JSONImpactBody + * @todo Replace object types + * + * @property {string} name - [description] + * @property {object} size - [description] + * @property {object} pos - [description] + * @property {object} vel - [description] + * @property {object} accel - [description] + * @property {object} friction - [description] + * @property {object} maxVel - [description] + * @property {number} gravityFactor - [description] + * @property {number} bounciness - [description] + * @property {number} minBounceVelocity - [description] + * @property {Phaser.Physics.Impact.TYPE} type - [description] + * @property {Phaser.Physics.Impact.TYPE} checkAgainst - [description] + * @property {Phaser.Physics.Impact.COLLIDES} collides - [description] + */ + +/** + * @classdesc + * An Impact.js compatible physics body. + * This re-creates the properties you'd get on an Entity and the math needed to update them. + * + * @class Body + * @memberof Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} [sx=16] - [description] + * @param {number} [sy=16] - [description] + */ +var Body = new Class({ + + initialize: + + function Body (world, x, y, sx, sy) + { + if (sx === undefined) { sx = 16; } + if (sy === undefined) { sy = sx; } + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#world + * @type {Phaser.Physics.Impact.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#gameObject + * @type {Phaser.GameObjects.GameObject} + * @default null + * @since 3.0.0 + */ + this.gameObject = null; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * The ImpactBody, ImpactSprite or ImpactImage object that owns this Body, if any. + * + * @name Phaser.Physics.Impact.Body#parent + * @type {?(Phaser.Physics.Impact.ImpactBody|Phaser.Physics.Impact.ImpactImage|Phaser.Physics.Impact.ImpactSprite)} + * @since 3.0.0 + */ + this.parent; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#id + * @type {integer} + * @since 3.0.0 + */ + this.id = world.getNextID(); + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#size + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.size = { x: sx, y: sy }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#offset + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.offset = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#pos + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.pos = { x: x, y: y }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#last + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.last = { x: x, y: y }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#vel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.vel = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#accel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.accel = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#friction + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.friction = { x: 0, y: 0 }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#maxVel + * @type {{x: number, y: number}} + * @since 3.0.0 + */ + this.maxVel = { x: world.defaults.maxVelocityX, y: world.defaults.maxVelocityY }; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#standing + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.standing = false; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#gravityFactor + * @type {number} + * @since 3.0.0 + */ + this.gravityFactor = world.defaults.gravityFactor; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#bounciness + * @type {number} + * @since 3.0.0 + */ + this.bounciness = world.defaults.bounciness; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#minBounceVelocity + * @type {number} + * @since 3.0.0 + */ + this.minBounceVelocity = world.defaults.minBounceVelocity; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#accelGround + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelGround = 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#accelAir + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelAir = 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#jumpSpeed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.jumpSpeed = 0; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#type + * @type {Phaser.Physics.Impact.TYPE} + * @since 3.0.0 + */ + this.type = TYPE.NONE; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#checkAgainst + * @type {Phaser.Physics.Impact.TYPE} + * @since 3.0.0 + */ + this.checkAgainst = TYPE.NONE; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#collides + * @type {Phaser.Physics.Impact.COLLIDES} + * @since 3.0.0 + */ + this.collides = COLLIDES.NEVER; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowBody; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowVelocity = world.defaults.debugShowVelocity; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.bodyDebugColor; + + /** + * [description] + * + * @name Phaser.Physics.Impact.Body#updateCallback + * @type {?BodyUpdateCallback} + * @since 3.0.0 + */ + this.updateCallback; + + /** + * min 44 deg, max 136 deg + * + * @name Phaser.Physics.Impact.Body#slopeStanding + * @type {{ min: number, max: number }} + * @since 3.0.0 + */ + this.slopeStanding = { min: 0.767944870877505, max: 2.3736477827122884 }; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#reset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + */ + reset: function (x, y) + { + this.pos = { x: x, y: y }; + this.last = { x: x, y: y }; + this.vel = { x: 0, y: 0 }; + this.accel = { x: 0, y: 0 }; + this.friction = { x: 0, y: 0 }; + this.maxVel = { x: 100, y: 100 }; + + this.standing = false; + + this.gravityFactor = 1; + this.bounciness = 0; + this.minBounceVelocity = 40; + + this.accelGround = 0; + this.accelAir = 0; + this.jumpSpeed = 0; + + this.type = TYPE.NONE; + this.checkAgainst = TYPE.NONE; + this.collides = COLLIDES.NEVER; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#update + * @since 3.0.0 + * + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update: function (delta) + { + var pos = this.pos; + + this.last.x = pos.x; + this.last.y = pos.y; + + this.vel.y += this.world.gravity * delta * this.gravityFactor; + + this.vel.x = GetVelocity(delta, this.vel.x, this.accel.x, this.friction.x, this.maxVel.x); + this.vel.y = GetVelocity(delta, this.vel.y, this.accel.y, this.friction.y, this.maxVel.y); + + var mx = this.vel.x * delta; + var my = this.vel.y * delta; + + var res = this.world.collisionMap.trace(pos.x, pos.y, mx, my, this.size.x, this.size.y); + + if (this.handleMovementTrace(res)) + { + UpdateMotion(this, res); + } + + var go = this.gameObject; + + if (go) + { + go.x = (pos.x - this.offset.x) + go.displayOriginX * go.scaleX; + go.y = (pos.y - this.offset.y) + go.displayOriginY * go.scaleY; + } + + if (this.updateCallback) + { + this.updateCallback(this); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - [description] + */ + drawDebug: function (graphic) + { + var pos = this.pos; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor, 1); + graphic.strokeRect(pos.x, pos.y, this.size.x, this.size.y); + } + + if (this.debugShowVelocity) + { + var x = pos.x + this.size.x / 2; + var y = pos.y + this.size.y / 2; + + graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); + graphic.lineBetween(x, y, x + this.vel.x, y + this.vel.y); + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} [description] + */ + willDrawDebug: function () + { + return (this.debugShowBody || this.debugShowVelocity); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#skipHash + * @since 3.0.0 + * + * @return {boolean} [description] + */ + skipHash: function () + { + return (!this.enabled || (this.type === 0 && this.checkAgainst === 0 && this.collides === 0)); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#touches + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} other - [description] + * + * @return {boolean} [description] + */ + touches: function (other) + { + return !( + this.pos.x >= other.pos.x + other.size.x || + this.pos.x + this.size.x <= other.pos.x || + this.pos.y >= other.pos.y + other.size.y || + this.pos.y + this.size.y <= other.pos.y + ); + }, + + /** + * Reset the size and position of the physics body. + * + * @method Phaser.Physics.Impact.Body#resetSize + * @since 3.0.0 + * + * @param {number} x - The x coordinate to position the body. + * @param {number} y - The y coordinate to position the body. + * @param {number} width - The width of the body. + * @param {number} height - The height of the body. + * + * @return {Phaser.Physics.Impact.Body} This Body object. + */ + resetSize: function (x, y, width, height) + { + this.pos.x = x; + this.pos.y = y; + this.size.x = width; + this.size.y = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#toJSON + * @since 3.0.0 + * + * @return {JSONImpactBody} [description] + */ + toJSON: function () + { + var output = { + name: this.name, + size: { x: this.size.x, y: this.size.y }, + pos: { x: this.pos.x, y: this.pos.y }, + vel: { x: this.vel.x, y: this.vel.y }, + accel: { x: this.accel.x, y: this.accel.y }, + friction: { x: this.friction.x, y: this.friction.y }, + maxVel: { x: this.maxVel.x, y: this.maxVel.y }, + gravityFactor: this.gravityFactor, + bounciness: this.bounciness, + minBounceVelocity: this.minBounceVelocity, + type: this.type, + checkAgainst: this.checkAgainst, + collides: this.collides + }; + + return output; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#fromJSON + * @todo Code it! + * @since 3.0.0 + * + * @param {object} config - [description] + */ + fromJSON: function () + { + }, + + /** + * Can be overridden by user code + * + * @method Phaser.Physics.Impact.Body#check + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} other - [description] + */ + check: function () + { + }, + + /** + * Can be overridden by user code + * + * @method Phaser.Physics.Impact.Body#collideWith + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} other - [description] + * @param {string} axis - [description] + */ + collideWith: function (other, axis) + { + if (this.parent && this.parent._collideCallback) + { + this.parent._collideCallback.call(this.parent._callbackScope, this, other, axis); + } + }, + + /** + * Can be overridden by user code but must return a boolean. + * + * @method Phaser.Physics.Impact.Body#handleMovementTrace + * @since 3.0.0 + * + * @param {number} res - [description] + * + * @return {boolean} [description] + */ + handleMovementTrace: function () + { + return true; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Body#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.remove(this); + + this.enabled = false; + + this.world = null; + + this.gameObject = null; + + this.parent = null; + } + +}); + +module.exports = Body; + + +/***/ }), +/* 253 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircleContains = __webpack_require__(44); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(39); +var RectangleContains = __webpack_require__(43); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Static Arcade Physics Body. + * + * A Static Body never moves, and isn't automatically synchronized with its parent Game Object. + * That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually. + * + * A Static Body can collide with other Bodies, but is never moved by collisions. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Body}. + * + * @class StaticBody + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ +var StaticBody = new Class({ + + initialize: + + function StaticBody (world, gameObject) + { + var width = (gameObject.width) ? gameObject.width : 64; + var height = (gameObject.height) ? gameObject.height : 64; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#gameObject + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.gameObject = gameObject; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowStaticBody; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.staticBodyDebugColor; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#enable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enable = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#isCircle + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isCircle = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#radius + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.radius = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#offset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.offset = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(this.width / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(this.height / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#velocity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.velocity = Vector2.ZERO; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#allowGravity + * @type {boolean} + * @readonly + * @default false + * @since 3.0.0 + */ + this.allowGravity = false; + + /** + * Gravitational force applied specifically to this Body. Values are in pixels per second squared. Always zero for a Static Body. + * + * @name Phaser.Physics.Arcade.StaticBody#gravity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.gravity = Vector2.ZERO; + + /** + * Rebound, or restitution, following a collision, relative to 1. Always zero for a Static Body. + * + * @name Phaser.Physics.Arcade.StaticBody#bounce + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.bounce = Vector2.ZERO; + + // If true this Body will dispatch events + + /** + * Whether the simulation emits a `worldbounds` event when this StaticBody collides with the world boundary (and `collideWorldBounds` is also true). + * + * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onWorldBounds = false; + + /** + * Whether the simulation emits a `collide` event when this StaticBody collides with another. + * + * @name Phaser.Physics.Arcade.StaticBody#onCollide + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onCollide = false; + + /** + * Whether the simulation emits an `overlap` event when this StaticBody overlaps with another. + * + * @name Phaser.Physics.Arcade.StaticBody#onOverlap + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onOverlap = false; + + /** + * The StaticBody's inertia, relative to a default unit (1). With `bounce`, this affects the exchange of momentum (velocities) during collisions. + * + * @name Phaser.Physics.Arcade.StaticBody#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * Whether this object can be moved by collisions with another body. + * + * @name Phaser.Physics.Arcade.StaticBody#immovable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.immovable = true; + + /** + * A flag disabling the default horizontal separation of colliding bodies. Pass your own `processHandler` to the collider. + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * A flag disabling the default vertical separation of colliding bodies. Pass your own `processHandler` to the collider. + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * The amount of horizontal overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.StaticBody#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * The amount of vertical overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.StaticBody#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * The amount of overlap (before separation), if this StaticBody is circular and colliding with another circular body. + * + * @name Phaser.Physics.Arcade.StaticBody#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * Whether this StaticBody is overlapped with another and both have zero velocity. + * + * @name Phaser.Physics.Arcade.StaticBody#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * Whether this StaticBody interacts with the world boundary. + * + * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * Whether this StaticBody is checked for collisions and for which directions. You can set `checkCollision.none = false` to disable collision checks. + * + * @name Phaser.Physics.Arcade.StaticBody#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * Whether this StaticBody is colliding with another and in which direction. + * + * @name Phaser.Physics.Arcade.StaticBody#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this StaticBody was colliding with another during the last step, and in which direction. + * + * @name Phaser.Physics.Arcade.StaticBody#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this StaticBody is colliding with a tile or the world boundary. + * + * @name Phaser.Physics.Arcade.StaticBody#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * The StaticBody's physics type (static by default). + * + * @name Phaser.Physics.Arcade.StaticBody#physicsType + * @type {integer} + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; + + /** + * The calculated change in the Body's horizontal position during the current step. + * For a static body this is always zero. + * + * @name Phaser.Physics.Arcade.StaticBody#_dx + * @type {number} + * @private + * @default 0 + * @since 3.10.0 + */ + this._dx = 0; + + /** + * The calculated change in the Body's vertical position during the current step. + * For a static body this is always zero. + * + * @name Phaser.Physics.Arcade.StaticBody#_dy + * @type {number} + * @private + * @default 0 + * @since 3.10.0 + */ + this._dy = 0; + }, + + /** + * Changes the Game Object this Body is bound to. + * First it removes its reference from the old Game Object, then sets the new one. + * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. + * + * @method Phaser.Physics.Arcade.StaticBody#setGameObject + * @since 3.1.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The new Game Object that will own this Body. + * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + * + * @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject + */ + setGameObject: function (gameObject, update) + { + if (gameObject && gameObject !== this.gameObject) + { + // Remove this body from the old game object + this.gameObject.body = null; + + gameObject.body = this; + + // Update our reference + this.gameObject = gameObject; + } + + if (update) + { + this.updateFromGameObject(); + } + + return this; + }, + + /** + * Updates this Static Body so that its position and dimensions are updated + * based on the current Game Object it is bound to. + * + * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject + * @since 3.1.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + updateFromGameObject: function () + { + this.world.staticTree.remove(this); + + var gameObject = this.gameObject; + + gameObject.getTopLeft(this.position); + + this.width = gameObject.displayWidth; + this.height = gameObject.displayHeight; + + this.halfWidth = Math.abs(this.width / 2); + this.halfHeight = Math.abs(this.height / 2); + + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * Sets the offset of the body. + * + * @method Phaser.Physics.Arcade.StaticBody#setOffset + * @since 3.4.0 + * + * @param {number} x - The horizontal offset of the Body from the Game Object's center. + * @param {number} y - The vertical offset of the Body from the Game Object's center. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setOffset: function (x, y) + { + if (y === undefined) { y = x; } + + this.world.staticTree.remove(this); + + this.position.x -= this.offset.x; + this.position.y -= this.offset.y; + + this.offset.set(x, y); + + this.position.x += this.offset.x; + this.position.y += this.offset.y; + + this.updateCenter(); + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * Sets the size of the body. + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * + * @method Phaser.Physics.Arcade.StaticBody#setSize + * @since 3.0.0 + * + * @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param {number} [offsetX] - The horizontal offset of the Body from the Game Object's center. + * @param {number} [offsetY] - The vertical offset of the Body from the Game Object's center. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setSize: function (width, height, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + var gameObject = this.gameObject; + + if (!width && gameObject.frame) + { + width = gameObject.frame.realWidth; + } + + if (!height && gameObject.frame) + { + height = gameObject.frame.realHeight; + } + + this.world.staticTree.remove(this); + + this.width = width; + this.height = height; + + this.halfWidth = Math.floor(width / 2); + this.halfHeight = Math.floor(height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.isCircle = false; + this.radius = 0; + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * Sets this Static Body to have a circular body and sets its sizes and position. + * + * @method Phaser.Physics.Arcade.StaticBody#setCircle + * @since 3.0.0 + * + * @param {number} radius - The radius of the StaticBody, in pixels. + * @param {number} [offsetX] - The horizontal offset of the StaticBody from its Game Object, in pixels. + * @param {number} [offsetY] - The vertical offset of the StaticBody from its Game Object, in pixels. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.world.staticTree.remove(this); + + this.isCircle = true; + + this.radius = radius; + + this.width = radius * 2; + this.height = radius * 2; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.world.staticTree.insert(this); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * Updates the StaticBody's `center` from its `position` and dimensions. + * + * @method Phaser.Physics.Arcade.StaticBody#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * Updates this Static Body's position based on the current Game Object it is bound to. + * Similar to `updateFromGameObject`, but doesn't modify the Body's dimensions. + * + * @method Phaser.Physics.Arcade.StaticBody#reset + * @since 3.0.0 + * + * @param {number} x - The x coordinate to reset the body to. + * @param {number} y - The y coordinate to reset the body to. + */ + reset: function (x, y) + { + var gameObject = this.gameObject; + + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + this.world.staticTree.remove(this); + + gameObject.getTopLeft(this.position); + + this.updateCenter(); + + this.world.staticTree.insert(this); + }, + + /** + * NOOP function. A Static Body cannot be stopped. + * + * @method Phaser.Physics.Arcade.StaticBody#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + stop: function () + { + return this; + }, + + /** + * Returns the x and y coordinates of the top left and bottom right points of the StaticBody. + * + * @method Phaser.Physics.Arcade.StaticBody#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - The object which will hold the coordinates of the bounds. + * + * @return {ArcadeBodyBounds} The same object that was passed with `x`, `y`, `right` and `bottom` values matching the respective values of the StaticBody. + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * Checks to see if a given x,y coordinate is colliding with this Static Body. + * + * @method Phaser.Physics.Arcade.StaticBody#hitTest + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check against this body. + * @param {number} y - The y coordinate to check against this body. + * + * @return {boolean} `true` if the given coordinate lies within this body, otherwise `false`. + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * NOOP + * + * @method Phaser.Physics.Arcade.StaticBody#postUpdate + * @since 3.12.0 + */ + postUpdate: function () + { + }, + + /** + * The absolute (non-negative) change in this StaticBody's horizontal position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX + * @since 3.0.0 + * + * @return {number} Always zero for a Static Body. + */ + deltaAbsX: function () + { + return 0; + }, + + /** + * The absolute (non-negative) change in this StaticBody's vertical position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY + * @since 3.0.0 + * + * @return {number} Always zero for a Static Body. + */ + deltaAbsY: function () + { + return 0; + }, + + /** + * The change in this StaticBody's horizontal position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaX + * @since 3.0.0 + * + * @return {number} Always zero for a Static Body. + */ + deltaX: function () + { + return 0; + }, + + /** + * The change in this StaticBody's vertical position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaY + * @since 3.0.0 + * + * @return {number} 0 + */ + deltaY: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaZ + * @since 3.0.0 + * + * @return {number} 0 + */ + deltaZ: function () + { + return 0; + }, + + /** + * Disables this Body and marks it for destruction during the next step. + * + * @method Phaser.Physics.Arcade.StaticBody#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * Draws a graphical representation of the StaticBody for visual debugging purposes. + * + * @method Phaser.Physics.Arcade.StaticBody#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - The Graphics object to use for the debug drawing of the StaticBody. + */ + drawDebug: function (graphic) + { + var pos = this.position; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor, 1); + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + }, + + /** + * Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate. + * + * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} Whether or not the StaticBody is going to show the debug visualization during postUpdate. + */ + willDrawDebug: function () + { + return this.debugShowBody; + }, + + /** + * Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero. + * + * @method Phaser.Physics.Arcade.StaticBody#setMass + * @since 3.0.0 + * + * @param {number} value - The value to set the Mass to. Values of zero or less are changed to 0.1. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setMass: function (value) + { + if (value <= 0) + { + // Causes havoc otherwise + value = 0.1; + } + + this.mass = value; + + return this; + }, + + /** + * The x coordinate of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.x = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * The y coordinate of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.y = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * Returns the left-most x coordinate of the area of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#left + * @type {number} + * @readonly + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.position.x; + } + + }, + + /** + * The right-most x coordinate of the area of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#right + * @type {number} + * @readonly + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.position.x + this.width; + } + + }, + + /** + * The highest y coordinate of the area of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#top + * @type {number} + * @readonly + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.position.y; + } + + }, + + /** + * The lowest y coordinate of the area of the StaticBody. (y + height) + * + * @name Phaser.Physics.Arcade.StaticBody#bottom + * @type {number} + * @readonly + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.position.y + this.height; + } + + } + +}); + +module.exports = StaticBody; + + +/***/ }), +/* 254 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody + * @since 3.0.0 + * + * @param {{ left: number, right: number, top: number, bottom: number }} tileWorldRect - [description] + * @param {Phaser.Physics.Arcade.Body} body - [description] + * + * @return {boolean} [description] + */ +var TileIntersectsBody = function (tileWorldRect, body) +{ + // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this + // should support circle bodies when those are less buggy in v3. + + return !( + body.right <= tileWorldRect.left || + body.bottom <= tileWorldRect.top || + body.position.x >= tileWorldRect.right || + body.position.y >= tileWorldRect.bottom + ); +}; + +module.exports = TileIntersectsBody; + + +/***/ }), +/* 255 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var quickselect = __webpack_require__(341); + +/** + * @classdesc + * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. + * It's based on an optimized R-tree data structure with bulk insertion support. + * + * Spatial index is a special data structure for points and rectangles that allows you to perform queries like + * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). + * + * This version of RBush uses a fixed min/max accessor structure of `[ '.left', '.top', '.right', '.bottom' ]`. + * This is to avoid the eval like function creation that the original library used, which caused CSP policy violations. + * + * @class RTree + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + */ + +function rbush (maxEntries) +{ + var format = [ '.left', '.top', '.right', '.bottom' ]; + + if (!(this instanceof rbush)) return new rbush(maxEntries, format); + + // max entries in a node is 9 by default; min node fill is 40% for best performance + this._maxEntries = Math.max(4, maxEntries || 9); + this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); + + this.clear(); +} + +rbush.prototype = { + + all: function () + { + return this._all(this.data, []); + }, + + search: function (bbox) + { + var node = this.data, + result = [], + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return result; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf) result.push(child); + else if (contains(bbox, childBBox)) this._all(child, result); + else nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return result; + }, + + collides: function (bbox) + { + var node = this.data, + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return false; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf || contains(bbox, childBBox)) return true; + nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return false; + }, + + load: function (data) + { + if (!(data && data.length)) return this; + + if (data.length < this._minEntries) { + for (var i = 0, len = data.length; i < len; i++) { + this.insert(data[i]); + } + return this; + } + + // recursively build the tree with the given data from scratch using OMT algorithm + var node = this._build(data.slice(), 0, data.length - 1, 0); + + if (!this.data.children.length) { + // save as is if tree is empty + this.data = node; + + } else if (this.data.height === node.height) { + // split root if trees have the same height + this._splitRoot(this.data, node); + + } else { + if (this.data.height < node.height) { + // swap trees if inserted one is bigger + var tmpNode = this.data; + this.data = node; + node = tmpNode; + } + + // insert the small tree into the large tree at appropriate level + this._insert(node, this.data.height - node.height - 1, true); + } + + return this; + }, + + insert: function (item) + { + if (item) this._insert(item, this.data.height - 1); + return this; + }, + + clear: function () + { + this.data = createNode([]); + return this; + }, + + remove: function (item, equalsFn) + { + if (!item) return this; + + var node = this.data, + bbox = this.toBBox(item), + path = [], + indexes = [], + i, parent, index, goingUp; + + // depth-first iterative tree traversal + while (node || path.length) { + + if (!node) { // go up + node = path.pop(); + parent = path[path.length - 1]; + i = indexes.pop(); + goingUp = true; + } + + if (node.leaf) { // check current node + index = findItem(item, node.children, equalsFn); + + if (index !== -1) { + // item found, remove the item and condense tree upwards + node.children.splice(index, 1); + path.push(node); + this._condense(path); + return this; + } + } + + if (!goingUp && !node.leaf && contains(node, bbox)) { // go down + path.push(node); + indexes.push(i); + i = 0; + parent = node; + node = node.children[0]; + + } else if (parent) { // go right + i++; + node = parent.children[i]; + goingUp = false; + + } else node = null; // nothing found + } + + return this; + }, + + toBBox: function (item) { return item; }, + + compareMinX: compareNodeMinX, + compareMinY: compareNodeMinY, + + toJSON: function () { return this.data; }, + + fromJSON: function (data) + { + this.data = data; + return this; + }, + + _all: function (node, result) + { + var nodesToSearch = []; + while (node) { + if (node.leaf) result.push.apply(result, node.children); + else nodesToSearch.push.apply(nodesToSearch, node.children); + + node = nodesToSearch.pop(); + } + return result; + }, + + _build: function (items, left, right, height) + { + var N = right - left + 1, + M = this._maxEntries, + node; + + if (N <= M) { + // reached leaf level; return leaf + node = createNode(items.slice(left, right + 1)); + calcBBox(node, this.toBBox); + return node; + } + + if (!height) { + // target height of the bulk-loaded tree + height = Math.ceil(Math.log(N) / Math.log(M)); + + // target number of root entries to maximize storage utilization + M = Math.ceil(N / Math.pow(M, height - 1)); + } + + node = createNode([]); + node.leaf = false; + node.height = height; + + // split the items into M mostly square tiles + + var N2 = Math.ceil(N / M), + N1 = N2 * Math.ceil(Math.sqrt(M)), + i, j, right2, right3; + + multiSelect(items, left, right, N1, this.compareMinX); + + for (i = left; i <= right; i += N1) { + + right2 = Math.min(i + N1 - 1, right); + + multiSelect(items, i, right2, N2, this.compareMinY); + + for (j = i; j <= right2; j += N2) { + + right3 = Math.min(j + N2 - 1, right2); + + // pack each entry recursively + node.children.push(this._build(items, j, right3, height - 1)); + } + } + + calcBBox(node, this.toBBox); + + return node; + }, + + _chooseSubtree: function (bbox, node, level, path) + { + var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; + + while (true) { + path.push(node); + + if (node.leaf || path.length - 1 === level) break; + + minArea = minEnlargement = Infinity; + + for (i = 0, len = node.children.length; i < len; i++) { + child = node.children[i]; + area = bboxArea(child); + enlargement = enlargedArea(bbox, child) - area; + + // choose entry with the least area enlargement + if (enlargement < minEnlargement) { + minEnlargement = enlargement; + minArea = area < minArea ? area : minArea; + targetNode = child; + + } else if (enlargement === minEnlargement) { + // otherwise choose one with the smallest area + if (area < minArea) { + minArea = area; + targetNode = child; + } + } + } + + node = targetNode || node.children[0]; + } + + return node; + }, + + _insert: function (item, level, isNode) + { + var toBBox = this.toBBox, + bbox = isNode ? item : toBBox(item), + insertPath = []; + + // find the best node for accommodating the item, saving all nodes along the path too + var node = this._chooseSubtree(bbox, this.data, level, insertPath); + + // put the item into the node + node.children.push(item); + extend(node, bbox); + + // split on node overflow; propagate upwards if necessary + while (level >= 0) { + if (insertPath[level].children.length > this._maxEntries) { + this._split(insertPath, level); + level--; + } else break; + } + + // adjust bboxes along the insertion path + this._adjustParentBBoxes(bbox, insertPath, level); + }, + + // split overflowed node into two + _split: function (insertPath, level) + { + var node = insertPath[level], + M = node.children.length, + m = this._minEntries; + + this._chooseSplitAxis(node, m, M); + + var splitIndex = this._chooseSplitIndex(node, m, M); + + var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); + newNode.height = node.height; + newNode.leaf = node.leaf; + + calcBBox(node, this.toBBox); + calcBBox(newNode, this.toBBox); + + if (level) insertPath[level - 1].children.push(newNode); + else this._splitRoot(node, newNode); + }, + + _splitRoot: function (node, newNode) + { + // split root node + this.data = createNode([node, newNode]); + this.data.height = node.height + 1; + this.data.leaf = false; + calcBBox(this.data, this.toBBox); + }, + + _chooseSplitIndex: function (node, m, M) + { + var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; + + minOverlap = minArea = Infinity; + + for (i = m; i <= M - m; i++) { + bbox1 = distBBox(node, 0, i, this.toBBox); + bbox2 = distBBox(node, i, M, this.toBBox); + + overlap = intersectionArea(bbox1, bbox2); + area = bboxArea(bbox1) + bboxArea(bbox2); + + // choose distribution with minimum overlap + if (overlap < minOverlap) { + minOverlap = overlap; + index = i; + + minArea = area < minArea ? area : minArea; + + } else if (overlap === minOverlap) { + // otherwise choose distribution with minimum area + if (area < minArea) { + minArea = area; + index = i; + } + } + } + + return index; + }, + + // sorts node children by the best axis for split + _chooseSplitAxis: function (node, m, M) + { + var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, + compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, + xMargin = this._allDistMargin(node, m, M, compareMinX), + yMargin = this._allDistMargin(node, m, M, compareMinY); + + // if total distributions margin value is minimal for x, sort by minX, + // otherwise it's already sorted by minY + if (xMargin < yMargin) node.children.sort(compareMinX); + }, + + // total margin of all possible split distributions where each node is at least m full + _allDistMargin: function (node, m, M, compare) + { + node.children.sort(compare); + + var toBBox = this.toBBox, + leftBBox = distBBox(node, 0, m, toBBox), + rightBBox = distBBox(node, M - m, M, toBBox), + margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), + i, child; + + for (i = m; i < M - m; i++) { + child = node.children[i]; + extend(leftBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(leftBBox); + } + + for (i = M - m - 1; i >= m; i--) { + child = node.children[i]; + extend(rightBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(rightBBox); + } + + return margin; + }, + + _adjustParentBBoxes: function (bbox, path, level) + { + // adjust bboxes along the given tree path + for (var i = level; i >= 0; i--) { + extend(path[i], bbox); + } + }, + + _condense: function (path) + { + // go through the path, removing empty nodes and updating bboxes + for (var i = path.length - 1, siblings; i >= 0; i--) { + if (path[i].children.length === 0) { + if (i > 0) { + siblings = path[i - 1].children; + siblings.splice(siblings.indexOf(path[i]), 1); + + } else this.clear(); + + } else calcBBox(path[i], this.toBBox); + } + }, + + compareMinX: function (a, b) + { + return a.left - b.left; + }, + + compareMinY: function (a, b) + { + return a.top - b.top; + }, + + toBBox: function (a) + { + return { + minX: a.left, + minY: a.top, + maxX: a.right, + maxY: a.bottom + }; + } +}; + +function findItem (item, items, equalsFn) +{ + if (!equalsFn) return items.indexOf(item); + + for (var i = 0; i < items.length; i++) { + if (equalsFn(item, items[i])) return i; + } + return -1; +} + +// calculate node's bbox from bboxes of its children +function calcBBox (node, toBBox) +{ + distBBox(node, 0, node.children.length, toBBox, node); +} + +// min bounding rectangle of node children from k to p-1 +function distBBox (node, k, p, toBBox, destNode) +{ + if (!destNode) destNode = createNode(null); + destNode.minX = Infinity; + destNode.minY = Infinity; + destNode.maxX = -Infinity; + destNode.maxY = -Infinity; + + for (var i = k, child; i < p; i++) { + child = node.children[i]; + extend(destNode, node.leaf ? toBBox(child) : child); + } + + return destNode; +} + +function extend (a, b) +{ + a.minX = Math.min(a.minX, b.minX); + a.minY = Math.min(a.minY, b.minY); + a.maxX = Math.max(a.maxX, b.maxX); + a.maxY = Math.max(a.maxY, b.maxY); + return a; +} + +function compareNodeMinX (a, b) { return a.minX - b.minX; } +function compareNodeMinY (a, b) { return a.minY - b.minY; } + +function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } +function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } + +function enlargedArea (a, b) +{ + return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * + (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); +} + +function intersectionArea (a, b) +{ + var minX = Math.max(a.minX, b.minX), + minY = Math.max(a.minY, b.minY), + maxX = Math.min(a.maxX, b.maxX), + maxY = Math.min(a.maxY, b.maxY); + + return Math.max(0, maxX - minX) * + Math.max(0, maxY - minY); +} + +function contains (a, b) +{ + return a.minX <= b.minX && + a.minY <= b.minY && + b.maxX <= a.maxX && + b.maxY <= a.maxY; +} + +function intersects (a, b) +{ + return b.minX <= a.maxX && + b.minY <= a.maxY && + b.maxX >= a.minX && + b.maxY >= a.minY; +} + +function createNode (children) +{ + return { + children: children, + height: 1, + leaf: true, + minX: Infinity, + minY: Infinity, + maxX: -Infinity, + maxY: -Infinity + }; +} + +// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; +// combines selection algorithm with binary divide & conquer approach + +function multiSelect (arr, left, right, n, compare) +{ + var stack = [left, right], + mid; + + while (stack.length) + { + right = stack.pop(); + left = stack.pop(); + + if (right - left <= n) continue; + + mid = left + Math.ceil((right - left) / n / 2) * n; + quickselect(arr, mid, left, right, compare); + + stack.push(left, mid, mid, right); + } +} + +module.exports = rbush; + +/***/ }), +/* 256 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class ProcessQueue + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + */ +var ProcessQueue = new Class({ + + initialize: + + function ProcessQueue () + { + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.ProcessQueue#_pending + * @type {Array.<*>} + * @private + * @default [] + * @since 3.0.0 + */ + this._pending = []; + + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.ProcessQueue#_active + * @type {Array.<*>} + * @private + * @default [] + * @since 3.0.0 + */ + this._active = []; + + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.ProcessQueue#_destroy + * @type {Array.<*>} + * @private + * @default [] + * @since 3.0.0 + */ + this._destroy = []; + + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_toProcess + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#add + * @since 3.0.0 + * + * @genericUse {T} - [item] + * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + add: function (item) + { + this._pending.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#remove + * @since 3.0.0 + * + * @genericUse {T} - [item] + * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + remove: function (item) + { + this._destroy.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#update + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} [description] + */ + update: function () + { + if (this._toProcess === 0) + { + // Quick bail + return this._active; + } + + var list = this._destroy; + var active = this._active; + var i; + var item; + + // Clear the 'destroy' list + for (i = 0; i < list.length; i++) + { + item = list[i]; + + // Remove from the 'active' array + var idx = active.indexOf(item); + + if (idx !== -1) + { + active.splice(idx, 1); + } + } + + list.length = 0; + + // Process the pending addition list + // This stops callbacks and out of sync events from populating the active array mid-way during an update + + list = this._pending; + + for (i = 0; i < list.length; i++) + { + item = list[i]; + + this._active.push(item); + } + + list.length = 0; + + this._toProcess = 0; + + // The owner of this queue can now safely do whatever it needs to with the active list + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#getActive + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} [description] + */ + getActive: function () + { + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#destroy + * @since 3.0.0 + */ + destroy: function () + { + this._pending = []; + this._active = []; + this._destroy = []; + } + +}); + +module.exports = ProcessQueue; + + +/***/ }), +/* 257 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(39); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.GetOverlapY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {number} [description] + */ +var GetOverlapY = function (body1, body2, overlapOnly, bias) +{ + var overlap = 0; + var maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + bias; + + if (body1._dy === 0 && body2._dy === 0) + { + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1._dy > body2._dy) + { + // Body1 is moving down and/or Body2 is moving up + overlap = body1.bottom - body2.y; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.down === false || body2.checkCollision.up === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.down = true; + + body2.touching.none = false; + body2.touching.up = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.down = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.up = true; + } + } + } + else if (body1._dy < body2._dy) + { + // Body1 is moving up and/or Body2 is moving down + overlap = body1.y - body2.bottom; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.up === false || body2.checkCollision.down === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.up = true; + + body2.touching.none = false; + body2.touching.down = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.up = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.down = true; + } + } + } + + // Resets the overlapY to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapY = overlap; + body2.overlapY = overlap; + + return overlap; +}; + +module.exports = GetOverlapY; + + +/***/ }), +/* 258 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(39); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.GetOverlapX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {number} [description] + */ +var GetOverlapX = function (body1, body2, overlapOnly, bias) +{ + var overlap = 0; + var maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + bias; + + if (body1._dx === 0 && body2._dx === 0) + { + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1._dx > body2._dx) + { + // Body1 is moving right and / or Body2 is moving left + overlap = body1.right - body2.x; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.right === false || body2.checkCollision.left === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.right = true; + + body2.touching.none = false; + body2.touching.left = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.right = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.left = true; + } + } + } + else if (body1._dx < body2._dx) + { + // Body1 is moving left and/or Body2 is moving right + overlap = body1.x - body2.width - body2.x; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.left === false || body2.checkCollision.right === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.left = true; + + body2.touching.none = false; + body2.touching.right = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.left = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.right = true; + } + } + } + + // Resets the overlapX to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapX = overlap; + body2.overlapX = overlap; + + return overlap; +}; + +module.exports = GetOverlapX; + + +/***/ }), +/* 259 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class Collider + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {boolean} overlapOnly - [description] + * @param {ArcadeColliderType} object1 - The first object to check for collision. + * @param {ArcadeColliderType} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {any} callbackContext - The scope in which to call the callbacks. + */ +var Collider = new Class({ + + initialize: + + function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) + { + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#name + * @type {string} + * @since 3.1.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#overlapOnly + * @type {boolean} + * @since 3.0.0 + */ + this.overlapOnly = overlapOnly; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object1 + * @type {ArcadeColliderType} + * @since 3.0.0 + */ + this.object1 = object1; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object2 + * @type {ArcadeColliderType} + * @since 3.0.0 + */ + this.object2 = object2; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#collideCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.collideCallback = collideCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#processCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.processCallback = processCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#callbackContext + * @type {object} + * @since 3.0.0 + */ + this.callbackContext = callbackContext; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#setName + * @since 3.1.0 + * + * @param {string} name - [description] + * + * @return {Phaser.Physics.Arcade.Collider} [description] + */ + setName: function (name) + { + this.name = name; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#update + * @since 3.0.0 + */ + update: function () + { + this.world.collideObjects( + this.object1, + this.object2, + this.collideCallback, + this.processCallback, + this.callbackContext, + this.overlapOnly + ); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.removeCollider(this); + + this.active = false; + + this.world = null; + + this.object1 = null; + this.object2 = null; + + this.collideCallback = null; + this.processCallback = null; + this.callbackContext = null; + } + +}); + +module.exports = Collider; + + +/***/ }), +/* 260 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircleContains = __webpack_require__(44); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(39); +var RadToDeg = __webpack_require__(190); +var Rectangle = __webpack_require__(10); +var RectangleContains = __webpack_require__(43); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} ArcadeBodyBounds + * + * @property {number} x - The left edge. + * @property {number} y - The upper edge. + * @property {number} right - The right edge. + * @property {number} bottom - The lower edge. + */ + +/** + * @typedef {object} ArcadeBodyCollision + * + * @property {boolean} none - True if the Body is not colliding. + * @property {boolean} up - True if the Body is colliding on its upper edge. + * @property {boolean} down - True if the Body is colliding on its lower edge. + * @property {boolean} left - True if the Body is colliding on its left edge. + * @property {boolean} right - True if the Body is colliding on its right edge. + */ + +/** + * @classdesc + * A Dynamic Arcade Body. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticBody}. + * + * @class Body + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics simulation this Body belongs to. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object this Body belongs to. + */ +var Body = new Class({ + + initialize: + + function Body (world, gameObject) + { + var width = (gameObject.width) ? gameObject.width : 64; + var height = (gameObject.height) ? gameObject.height : 64; + + /** + * The Arcade Physics simulation this Body belongs to. + * + * @name Phaser.Physics.Arcade.Body#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * The Game Object this Body belongs to. + * + * @name Phaser.Physics.Arcade.Body#gameObject + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.gameObject = gameObject; + + /** + * Transformations applied to this Body. + * + * @name Phaser.Physics.Arcade.Body#transform + * @type {object} + * @since 3.4.0 + */ + this.transform = { + x: gameObject.x, + y: gameObject.y, + rotation: gameObject.angle, + scaleX: gameObject.scaleX, + scaleY: gameObject.scaleY, + displayOriginX: gameObject.displayOriginX, + displayOriginY: gameObject.displayOriginY + }; + + /** + * Whether the Body's boundary is drawn to the debug display. + * + * @name Phaser.Physics.Arcade.Body#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowBody; + + /** + * Whether the Body's velocity is drawn to the debug display. + * + * @name Phaser.Physics.Arcade.Body#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowVelocity = world.defaults.debugShowVelocity; + + /** + * The color of this Body on the debug display. + * + * @name Phaser.Physics.Arcade.Body#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.bodyDebugColor; + + /** + * Whether this Body is updated by the physics simulation. + * + * @name Phaser.Physics.Arcade.Body#enable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enable = true; + + /** + * Whether this Body's boundary is circular (true) or rectangular (false). + * + * @name Phaser.Physics.Arcade.Body#isCircle + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setCircle + */ + this.isCircle = false; + + /** + * If this Body is circular, this is the unscaled radius of the Body's boundary, as set by setCircle(), in source pixels. + * The true radius is equal to `halfWidth`. + * + * @name Phaser.Physics.Arcade.Body#radius + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setCircle + */ + this.radius = 0; + + /** + * The offset of this Body's position from its Game Object's position, in source pixels. + * + * @name Phaser.Physics.Arcade.Body#offset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setOffset + */ + this.offset = new Vector2(); + + /** + * The position of this Body within the simulation. + * + * @name Phaser.Physics.Arcade.Body#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x, gameObject.y); + + /** + * The position of this Body during the previous step. + * + * @name Phaser.Physics.Arcade.Body#prev + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.prev = new Vector2(gameObject.x, gameObject.y); + + /** + * Whether this Body's `rotation` is affected by its angular acceleration and angular velocity. + * + * @name Phaser.Physics.Arcade.Body#allowRotation + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowRotation = true; + + /** + * This body's rotation, in degrees, based on its angular acceleration and angular velocity. + * The Body's rotation controls the `angle` of its Game Object. + * It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle. + * + * @name Phaser.Physics.Arcade.Body#rotation + * @type {number} + * @since 3.0.0 + */ + this.rotation = gameObject.angle; + + /** + * The Body's rotation, in degrees, during the previous step. + * + * @name Phaser.Physics.Arcade.Body#preRotation + * @type {number} + * @since 3.0.0 + */ + this.preRotation = gameObject.angle; + + /** + * The width of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. + * + * @name Phaser.Physics.Arcade.Body#width + * @type {number} + * @default 64 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. + * + * @name Phaser.Physics.Arcade.Body#height + * @type {number} + * @default 64 + * @since 3.0.0 + */ + this.height = height; + + /** + * The unscaled width of the Body, in source pixels, as set by setSize(). + * The default is the width of the Body's Game Object's texture frame. + * + * @name Phaser.Physics.Arcade.Body#sourceWidth + * @type {number} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setSize + */ + this.sourceWidth = width; + + /** + * The unscaled height of the Body, in source pixels, as set by setSize(). + * The default is the height of the Body's Game Object's texture frame. + * + * @name Phaser.Physics.Arcade.Body#sourceHeight + * @type {number} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setSize + */ + this.sourceHeight = height; + + if (gameObject.frame) + { + this.sourceWidth = gameObject.frame.realWidth; + this.sourceHeight = gameObject.frame.realHeight; + } + + /** + * Half the Body's width, in pixels. + * + * @name Phaser.Physics.Arcade.Body#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(width / 2); + + /** + * Half the Body's height, in pixels. + * + * @name Phaser.Physics.Arcade.Body#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(height / 2); + + /** + * The center of the Body's boundary. + * The midpoint of its `position` (top-left corner) and its bottom-right corner. + * + * @name Phaser.Physics.Arcade.Body#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * The Body's velocity, in pixels per second. + * + * @name Phaser.Physics.Arcade.Body#velocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.velocity = new Vector2(); + + /** + * The Body's calculated velocity, in pixels per second, at the last step. + * + * @name Phaser.Physics.Arcade.Body#newVelocity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.newVelocity = new Vector2(); + + /** + * The Body's absolute maximum change in position, in pixels per step. + * + * @name Phaser.Physics.Arcade.Body#deltaMax + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.deltaMax = new Vector2(); + + /** + * The Body's change in velocity, in pixels per second squared. + * + * @name Phaser.Physics.Arcade.Body#acceleration + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.acceleration = new Vector2(); + + /** + * Whether this Body's velocity is affected by its `drag`. + * + * @name Phaser.Physics.Arcade.Body#allowDrag + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowDrag = true; + + /** + * Absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * + * @name Phaser.Physics.Arcade.Body#drag + * @type {(Phaser.Math.Vector2|number)} + * @since 3.0.0 + */ + this.drag = new Vector2(); + + /** + * Whether this Body's position is affected by gravity (local or world). + * + * @name Phaser.Physics.Arcade.Body#allowGravity + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#gravity + * @see Phaser.Physics.Arcade.World#gravity + */ + this.allowGravity = true; + + /** + * Acceleration due to gravity (specific to this Body), in pixels per second squared. + * Total gravity is the sum of this vector and the simulation's `gravity`. + * + * @name Phaser.Physics.Arcade.Body#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#gravity + */ + this.gravity = new Vector2(); + + /** + * Rebound following a collision, relative to 1. + * + * @name Phaser.Physics.Arcade.Body#bounce + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.bounce = new Vector2(); + + /** + * Rebound following a collision with the world boundary, relative to 1. + * If null, `bounce` is used instead. + * + * @name Phaser.Physics.Arcade.Body#worldBounce + * @type {?Phaser.Math.Vector2} + * @default null + * @since 3.0.0 + */ + this.worldBounce = null; + + // If true this Body will dispatch events + + /** + * Whether the simulation emits a `worldbounds` event when this Body collides with the world boundary (and `collideWorldBounds` is also true). + * + * @name Phaser.Physics.Arcade.Body#onWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#event:worldbounds + */ + this.onWorldBounds = false; + + /** + * Whether the simulation emits a `collide` event when this Body collides with another. + * + * @name Phaser.Physics.Arcade.Body#onCollide + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#event:collide + */ + this.onCollide = false; + + /** + * Whether the simulation emits an `overlap` event when this Body overlaps with another. + * + * @name Phaser.Physics.Arcade.Body#onOverlap + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#event:overlap + */ + this.onOverlap = false; + + /** + * The Body's absolute maximum velocity, in pixels per second. + * The horizontal and vertical components are applied separately. + * + * @name Phaser.Physics.Arcade.Body#maxVelocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.maxVelocity = new Vector2(10000, 10000); + + /** + * If this Body is `immovable` and in motion, `friction` is the proportion of this Body's motion received by the riding Body on each axis, relative to 1. + * The default value (1, 0) moves the riding Body horizontally in equal proportion to this Body and vertically not at all. + * The horizontal component (x) is applied only when two colliding Bodies are separated vertically. + * The vertical component (y) is applied only when two colliding Bodies are separated horizontally. + * + * @name Phaser.Physics.Arcade.Body#friction + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.friction = new Vector2(1, 0); + + /** + * If this Body is using `drag` for deceleration this property controls how the drag is applied. + * If set to `true` drag will use a damping effect rather than a linear approach. If you are + * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in + * the game Asteroids) then you will get a far smoother and more visually correct deceleration + * by using damping, avoiding the axis-drift that is prone with linear deceleration. + * + * If you enable this property then you should use far smaller `drag` values than with linear, as + * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow + * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. + * + * @name Phaser.Physics.Arcade.Body#useDamping + * @type {boolean} + * @default false + * @since 3.10.0 + */ + this.useDamping = false; + + /** + * The rate of change of this Body's `rotation`, in degrees per second. + * + * @name Phaser.Physics.Arcade.Body#angularVelocity + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularVelocity = 0; + + /** + * The Body's angular acceleration (change in angular velocity), in degrees per second squared. + * + * @name Phaser.Physics.Arcade.Body#angularAcceleration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularAcceleration = 0; + + /** + * Loss of angular velocity due to angular movement, in degrees per second. + * + * Angular drag is applied only when angular acceleration is zero. + * + * @name Phaser.Physics.Arcade.Body#angularDrag + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularDrag = 0; + + /** + * The Body's maximum angular velocity, in degrees per second. + * + * @name Phaser.Physics.Arcade.Body#maxAngular + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.maxAngular = 1000; + + /** + * The Body's inertia, relative to a default unit (1). + * With `bounce`, this affects the exchange of momentum (velocities) during collisions. + * + * @name Phaser.Physics.Arcade.Body#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * The calculated angle of this Body's velocity vector, in degrees, during the last step. + * + * @name Phaser.Physics.Arcade.Body#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angle = 0; + + /** + * The calculated magnitude of the Body's velocity, in pixels per second, during the last step. + * + * @name Phaser.Physics.Arcade.Body#speed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speed = 0; + + /** + * The direction of the Body's velocity, as calculated during the last step. + * If the Body is moving on both axes (diagonally), this describes motion on the vertical axis only. + * + * @name Phaser.Physics.Arcade.Body#facing + * @type {integer} + * @since 3.0.0 + */ + this.facing = CONST.FACING_NONE; + + /** + * Whether this Body can be moved by collisions with another Body. + * + * @name Phaser.Physics.Arcade.Body#immovable + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.immovable = false; + + /** + * Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity. + * + * @name Phaser.Physics.Arcade.Body#moves + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.moves = true; + + /** + * A flag disabling the default horizontal separation of colliding bodies. + * Pass your own `collideCallback` to the collider. + * + * @name Phaser.Physics.Arcade.Body#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * A flag disabling the default vertical separation of colliding bodies. + * Pass your own `collideCallback` to the collider. + * + * @name Phaser.Physics.Arcade.Body#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * The amount of horizontal overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.Body#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * The amount of vertical overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.Body#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * The amount of overlap (before separation), if this Body is circular and colliding with another circular body. + * + * @name Phaser.Physics.Arcade.Body#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * Whether this Body is overlapped with another and both have zero velocity. + * + * @name Phaser.Physics.Arcade.Body#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * Whether this Body interacts with the world boundary. + * + * @name Phaser.Physics.Arcade.Body#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * Whether this Body is checked for collisions and for which directions. + * You can set `checkCollision.none = false` to disable collision checks. + * + * @name Phaser.Physics.Arcade.Body#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * Whether this Body is colliding with another and in which direction. + * + * @name Phaser.Physics.Arcade.Body#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this Body was colliding with another during the last step, and in which direction. + * + * @name Phaser.Physics.Arcade.Body#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this Body is colliding with a tile or the world boundary. + * + * @name Phaser.Physics.Arcade.Body#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether to automatically synchronize this Body's dimensions to the dimensions of its Game Object's visual bounds. + * + * @name Phaser.Physics.Arcade.Body#syncBounds + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.GameObjects.Components.GetBounds#getBounds + */ + this.syncBounds = false; + + /** + * Whether this Body is being moved by the `moveTo` or `moveFrom` methods. + * + * @name Phaser.Physics.Arcade.Body#isMoving + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isMoving = false; + + /** + * Whether this Body's movement by `moveTo` or `moveFrom` will be stopped by collisions with other bodies. + * + * @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.stopVelocityOnCollide = true; + + // read-only + + /** + * The Body's physics type (dynamic or static). + * + * @name Phaser.Physics.Arcade.Body#physicsType + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.physicsType = CONST.DYNAMIC_BODY; + + /** + * Whether the Body's position needs updating from its Game Object. + * + * @name Phaser.Physics.Arcade.Body#_reset + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + this._reset = true; + + /** + * Cached horizontal scale of the Body's Game Object. + * + * @name Phaser.Physics.Arcade.Body#_sx + * @type {number} + * @private + * @since 3.0.0 + */ + this._sx = gameObject.scaleX; + + /** + * Cached vertical scale of the Body's Game Object. + * + * @name Phaser.Physics.Arcade.Body#_sy + * @type {number} + * @private + * @since 3.0.0 + */ + this._sy = gameObject.scaleY; + + /** + * The calculated change in the Body's horizontal position during the last step. + * + * @name Phaser.Physics.Arcade.Body#_dx + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._dx = 0; + + /** + * The calculated change in the Body's vertical position during the last step. + * + * @name Phaser.Physics.Arcade.Body#_dy + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._dy = 0; + + /** + * Stores the Game Object's bounds. + * + * @name Phaser.Physics.Arcade.Body#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + }, + + /** + * Updates this Body's transform, dimensions, and position from its Game Object. + * + * @method Phaser.Physics.Arcade.Body#updateBounds + * @since 3.0.0 + */ + updateBounds: function () + { + var sprite = this.gameObject; + + // Container? + + var transform = this.transform; + + if (sprite.parentContainer) + { + var matrix = sprite.getWorldTransformMatrix(this.world._tempMatrix, this.world._tempMatrix2); + + transform.x = matrix.tx; + transform.y = matrix.ty; + transform.rotation = RadToDeg(matrix.rotation); + transform.scaleX = matrix.scaleX; + transform.scaleY = matrix.scaleY; + transform.displayOriginX = sprite.displayOriginX; + transform.displayOriginY = sprite.displayOriginY; + } + else + { + transform.x = sprite.x; + transform.y = sprite.y; + transform.rotation = sprite.angle; + transform.scaleX = sprite.scaleX; + transform.scaleY = sprite.scaleY; + transform.displayOriginX = sprite.displayOriginX; + transform.displayOriginY = sprite.displayOriginY; + } + + var recalc = false; + + if (this.syncBounds) + { + var b = sprite.getBounds(this._bounds); + + this.width = b.width; + this.height = b.height; + recalc = true; + } + else + { + var asx = Math.abs(transform.scaleX); + var asy = Math.abs(transform.scaleY); + + if (this._sx !== asx || this._sy !== asy) + { + this.width = this.sourceWidth * asx; + this.height = this.sourceHeight * asy; + this._sx = asx; + this._sy = asy; + recalc = true; + } + } + + if (recalc) + { + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + this.updateCenter(); + } + }, + + /** + * Updates the Body's `center` from its `position`, `width`, and `height`. + * + * @method Phaser.Physics.Arcade.Body#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * Updates the Body. + * + * @method Phaser.Physics.Arcade.Body#update + * @fires Phaser.Physics.Arcade.World#worldbounds + * @since 3.0.0 + * + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (delta) + { + // Store and reset collision flags + this.wasTouching.none = this.touching.none; + this.wasTouching.up = this.touching.up; + this.wasTouching.down = this.touching.down; + this.wasTouching.left = this.touching.left; + this.wasTouching.right = this.touching.right; + + this.touching.none = true; + this.touching.up = false; + this.touching.down = false; + this.touching.left = false; + this.touching.right = false; + + this.blocked.none = true; + this.blocked.up = false; + this.blocked.down = false; + this.blocked.left = false; + this.blocked.right = false; + + this.overlapR = 0; + this.overlapX = 0; + this.overlapY = 0; + + this.embedded = false; + + // Updates the transform values + this.updateBounds(); + + var sprite = this.transform; + + this.position.x = sprite.x + sprite.scaleX * (this.offset.x - sprite.displayOriginX); + this.position.y = sprite.y + sprite.scaleY * (this.offset.y - sprite.displayOriginY); + + this.updateCenter(); + + this.rotation = sprite.rotation; + + this.preRotation = this.rotation; + + if (this._reset) + { + this.prev.x = this.position.x; + this.prev.y = this.position.y; + } + + if (this.moves) + { + this.world.updateMotion(this, delta); + + var vx = this.velocity.x; + var vy = this.velocity.y; + + this.newVelocity.set(vx * delta, vy * delta); + + this.position.add(this.newVelocity); + + this.updateCenter(); + + this.angle = Math.atan2(vy, vx); + this.speed = Math.sqrt(vx * vx + vy * vy); + + // Now the State update will throw collision checks at the Body + // And finally we'll integrate the new position back to the Sprite in postUpdate + + if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) + { + this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); + } + } + + this._dx = this.position.x - this.prev.x; + this._dy = this.position.y - this.prev.y; + }, + + /** + * Feeds the Body results back into the parent Game Object. + * + * @method Phaser.Physics.Arcade.Body#postUpdate + * @since 3.0.0 + * + * @param {boolean} resetDelta - Reset the delta properties? + */ + postUpdate: function () + { + this._dx = this.position.x - this.prev.x; + this._dy = this.position.y - this.prev.y; + + if (this.moves) + { + if (this.deltaMax.x !== 0 && this._dx !== 0) + { + if (this._dx < 0 && this._dx < -this.deltaMax.x) + { + this._dx = -this.deltaMax.x; + } + else if (this._dx > 0 && this._dx > this.deltaMax.x) + { + this._dx = this.deltaMax.x; + } + } + + if (this.deltaMax.y !== 0 && this._dy !== 0) + { + if (this._dy < 0 && this._dy < -this.deltaMax.y) + { + this._dy = -this.deltaMax.y; + } + else if (this._dy > 0 && this._dy > this.deltaMax.y) + { + this._dy = this.deltaMax.y; + } + } + + this.gameObject.x += this._dx; + this.gameObject.y += this._dy; + + this._reset = true; + } + + if (this._dx < 0) + { + this.facing = CONST.FACING_LEFT; + } + else if (this._dx > 0) + { + this.facing = CONST.FACING_RIGHT; + } + + if (this._dy < 0) + { + this.facing = CONST.FACING_UP; + } + else if (this._dy > 0) + { + this.facing = CONST.FACING_DOWN; + } + + if (this.allowRotation) + { + this.gameObject.angle += this.deltaZ(); + } + + this.prev.x = this.position.x; + this.prev.y = this.position.y; + }, + + /** + * Checks for collisions between this Body and the world boundary and separates them. + * + * @method Phaser.Physics.Arcade.Body#checkWorldBounds + * @since 3.0.0 + * + * @return {boolean} True if this Body is colliding with the world boundary. + */ + checkWorldBounds: function () + { + var pos = this.position; + var bounds = this.world.bounds; + var check = this.world.checkCollision; + + var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x; + var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y; + + if (pos.x < bounds.x && check.left) + { + pos.x = bounds.x; + this.velocity.x *= bx; + this.blocked.left = true; + this.blocked.none = false; + } + else if (this.right > bounds.right && check.right) + { + pos.x = bounds.right - this.width; + this.velocity.x *= bx; + this.blocked.right = true; + this.blocked.none = false; + } + + if (pos.y < bounds.y && check.up) + { + pos.y = bounds.y; + this.velocity.y *= by; + this.blocked.up = true; + this.blocked.none = false; + } + else if (this.bottom > bounds.bottom && check.down) + { + pos.y = bounds.bottom - this.height; + this.velocity.y *= by; + this.blocked.down = true; + this.blocked.none = false; + } + + return !this.blocked.none; + }, + + /** + * Sets the offset of the Body's position from its Game Object's position. + * + * @method Phaser.Physics.Arcade.Body#setOffset + * @since 3.0.0 + * + * @param {number} x - The horizontal offset, in source pixels. + * @param {number} [y=x] - The vertical offset, in source pixels. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setOffset: function (x, y) + { + if (y === undefined) { y = x; } + + this.offset.set(x, y); + + return this; + }, + + /** + * Sizes and positions this Body's boundary, as a rectangle. + * Modifies the Body `offset` if `center` is true (the default). + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * + * @method Phaser.Physics.Arcade.Body#setSize + * @since 3.0.0 + * + * @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param {boolean} [center=true] - Modify the Body's `offset`, placing the Body's center on its Game Object's center. Only works if the Game Object has the `getCenter` method. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setSize: function (width, height, center) + { + if (center === undefined) { center = true; } + + var gameObject = this.gameObject; + + if (!width && gameObject.frame) + { + width = gameObject.frame.realWidth; + } + + if (!height && gameObject.frame) + { + height = gameObject.frame.realHeight; + } + + this.sourceWidth = width; + this.sourceHeight = height; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.updateCenter(); + + if (center && gameObject.getCenter) + { + var ox = gameObject.displayWidth / 2; + var oy = gameObject.displayHeight / 2; + + this.offset.set(ox - this.halfWidth, oy - this.halfHeight); + } + + this.isCircle = false; + this.radius = 0; + + return this; + }, + + /** + * Sizes and positions this Body's boundary, as a circle. + * + * @method Phaser.Physics.Arcade.Body#setCircle + * @since 3.0.0 + * + * @param {number} radius - The radius of the Body, in source pixels. + * @param {number} [offsetX] - The horizontal offset of the Body from its Game Object, in source pixels. + * @param {number} [offsetY] - The vertical offset of the Body from its Game Object, in source pixels. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.isCircle = true; + this.radius = radius; + + this.sourceWidth = radius * 2; + this.sourceHeight = radius * 2; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * If the Body had any velocity or acceleration it is lost as a result of calling this. + * + * @method Phaser.Physics.Arcade.Body#reset + * @since 3.0.0 + * + * @param {number} x - The horizontal position to place the Game Object and Body. + * @param {number} y - The vertical position to place the Game Object and Body. + */ + reset: function (x, y) + { + this.stop(); + + var gameObject = this.gameObject; + + gameObject.setPosition(x, y); + + gameObject.getTopLeft(this.position); + + this.prev.copy(this.position); + + this.rotation = gameObject.angle; + this.preRotation = gameObject.angle; + + this.updateBounds(); + this.updateCenter(); + }, + + /** + * Sets acceleration, velocity, and speed to zero. + * + * @method Phaser.Physics.Arcade.Body#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + stop: function () + { + this.velocity.set(0); + this.acceleration.set(0); + this.speed = 0; + this.angularVelocity = 0; + this.angularAcceleration = 0; + + return this; + }, + + /** + * Copies the coordinates of this Body's edges into an object. + * + * @method Phaser.Physics.Arcade.Body#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - An object to copy the values into. + * + * @return {ArcadeBodyBounds} - An object with {x, y, right, bottom}. + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * Tests if the coordinates are within this Body's boundary. + * + * @method Phaser.Physics.Arcade.Body#hitTest + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate. + * @param {number} y - The vertical coordinate. + * + * @return {boolean} True if (x, y) is within this Body. + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * Whether this Body is touching a tile or the world boundary while moving down. + * + * @method Phaser.Physics.Arcade.Body#onFloor + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#blocked + * + * @return {boolean} True if touching. + */ + onFloor: function () + { + return this.blocked.down; + }, + + /** + * Whether this Body is touching a tile or the world boundary while moving up. + * + * @method Phaser.Physics.Arcade.Body#onCeiling + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#blocked + * + * @return {boolean} True if touching. + */ + onCeiling: function () + { + return this.blocked.up; + }, + + /** + * Whether this Body is touching a tile or the world boundary while moving left or right. + * + * @method Phaser.Physics.Arcade.Body#onWall + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#blocked + * + * @return {boolean} True if touching. + */ + onWall: function () + { + return (this.blocked.left || this.blocked.right); + }, + + /** + * The absolute (non-negative) change in this Body's horizontal position from the previous step. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsX + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaAbsX: function () + { + return (this._dx > 0) ? this._dx : -this._dx; + }, + + /** + * The absolute (non-negative) change in this Body's vertical position from the previous step. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsY + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaAbsY: function () + { + return (this._dy > 0) ? this._dy : -this._dy; + }, + + /** + * The change in this Body's horizontal position from the previous step. + * This value is set during the Body's update phase. + * + * @method Phaser.Physics.Arcade.Body#deltaX + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaX: function () + { + return this._dx; + }, + + /** + * The change in this Body's vertical position from the previous step. + * This value is set during the Body's update phase. + * + * @method Phaser.Physics.Arcade.Body#deltaY + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaY: function () + { + return this._dy; + }, + + /** + * The change in this Body's rotation from the previous step, in degrees. + * + * @method Phaser.Physics.Arcade.Body#deltaZ + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaZ: function () + { + return this.rotation - this.preRotation; + }, + + /** + * Disables this Body and marks it for deletion by the simulation. + * + * @method Phaser.Physics.Arcade.Body#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * Draws this Body's boundary and velocity, if enabled. + * + * @method Phaser.Physics.Arcade.Body#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - The Graphics object to draw on. + */ + drawDebug: function (graphic) + { + var pos = this.position; + + var x = pos.x + this.halfWidth; + var y = pos.y + this.halfHeight; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor); + + if (this.isCircle) + { + graphic.strokeCircle(x, y, this.width / 2); + } + else + { + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + } + + if (this.debugShowVelocity) + { + graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); + graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); + } + }, + + /** + * Whether this Body will be drawn to the debug display. + * + * @method Phaser.Physics.Arcade.Body#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} True if either `debugShowBody` or `debugShowVelocity` are enabled. + */ + willDrawDebug: function () + { + return (this.debugShowBody || this.debugShowVelocity); + }, + + /** + * Sets whether this Body collides with the world boundary. + * + * @method Phaser.Physics.Arcade.Body#setCollideWorldBounds + * @since 3.0.0 + * + * @param {boolean} [value=true] - True (collisions) or false (no collisions). + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCollideWorldBounds: function (value) + { + if (value === undefined) { value = true; } + + this.collideWorldBounds = value; + + return this; + }, + + /** + * Sets the Body's velocity. + * + * @method Phaser.Physics.Arcade.Body#setVelocity + * @since 3.0.0 + * + * @param {number} x - The horizontal velocity, in pixels per second. + * @param {number} [y=x] - The vertical velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocity: function (x, y) + { + this.velocity.set(x, y); + + this.speed = Math.sqrt(x * x + y * y); + + return this; + }, + + /** + * Sets the Body's horizontal velocity. + * + * @method Phaser.Physics.Arcade.Body#setVelocityX + * @since 3.0.0 + * + * @param {number} value - The velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityX: function (value) + { + this.velocity.x = value; + + var vx = value; + var vy = this.velocity.y; + + this.speed = Math.sqrt(vx * vx + vy * vy); + + return this; + }, + + /** + * Sets the Body's vertical velocity. + * + * @method Phaser.Physics.Arcade.Body#setVelocityY + * @since 3.0.0 + * + * @param {number} value - The velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityY: function (value) + { + this.velocity.y = value; + + var vx = this.velocity.x; + var vy = value; + + this.speed = Math.sqrt(vx * vx + vy * vy); + + return this; + }, + + /** + * Sets the Body's maximum velocity. + * + * @method Phaser.Physics.Arcade.Body#setMaxVelocity + * @since 3.10.0 + * + * @param {number} x - The horizontal velocity, in pixels per second. + * @param {number} [y=x] - The vertical velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setMaxVelocity: function (x, y) + { + this.maxVelocity.set(x, y); + + return this; + }, + + /** + * Sets the Body's bounce. + * + * @method Phaser.Physics.Arcade.Body#setBounce + * @since 3.0.0 + * + * @param {number} x - The horizontal bounce, relative to 1. + * @param {number} y - The vertical bounce, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounce: function (x, y) + { + this.bounce.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal bounce. + * + * @method Phaser.Physics.Arcade.Body#setBounceX + * @since 3.0.0 + * + * @param {number} value - The bounce, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceX: function (value) + { + this.bounce.x = value; + + return this; + }, + + /** + * Sets the Body's vertical bounce. + * + * @method Phaser.Physics.Arcade.Body#setBounceY + * @since 3.0.0 + * + * @param {number} value - The bounce, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceY: function (value) + { + this.bounce.y = value; + + return this; + }, + + /** + * Sets the Body's acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAcceleration + * @since 3.0.0 + * + * @param {number} x - The horizontal component, in pixels per second squared. + * @param {number} y - The vertical component, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAcceleration: function (x, y) + { + this.acceleration.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - The acceleration, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationX: function (value) + { + this.acceleration.x = value; + + return this; + }, + + /** + * Sets the Body's vertical acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - The acceleration, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationY: function (value) + { + this.acceleration.y = value; + + return this; + }, + + /** + * Enables or disables drag. + * + * @method Phaser.Physics.Arcade.Body#setAllowDrag + * @since 3.9.0 + * @see Phaser.Physics.Arcade.Body#allowDrag + * + * @param {boolean} [value=true] - `true` to allow drag on this body, or `false` to disable it. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAllowDrag: function (value) + { + if (value === undefined) { value = true; } + + this.allowDrag = value; + + return this; + }, + + /** + * Enables or disables gravity's effect on this Body. + * + * @method Phaser.Physics.Arcade.Body#setAllowGravity + * @since 3.9.0 + * @see Phaser.Physics.Arcade.Body#allowGravity + * + * @param {boolean} [value=true] - `true` to allow gravity on this body, or `false` to disable it. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAllowGravity: function (value) + { + if (value === undefined) { value = true; } + + this.allowGravity = value; + + return this; + }, + + /** + * Enables or disables rotation. + * + * @method Phaser.Physics.Arcade.Body#setAllowRotation + * @since 3.9.0 + * @see Phaser.Physics.Arcade.Body#allowRotation + * + * @param {boolean} [value=true] - `true` to allow rotation on this body, or `false` to disable it. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAllowRotation: function (value) + { + if (value === undefined) { value = true; } + + this.allowRotation = value; + + return this; + }, + + /** + * Sets the Body's drag. + * + * @method Phaser.Physics.Arcade.Body#setDrag + * @since 3.0.0 + * + * @param {number} x - The horizontal component, in pixels per second squared. + * @param {number} y - The vertical component, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDrag: function (x, y) + { + this.drag.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal drag. + * + * @method Phaser.Physics.Arcade.Body#setDragX + * @since 3.0.0 + * + * @param {number} value - The drag, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragX: function (value) + { + this.drag.x = value; + + return this; + }, + + /** + * Sets the Body's vertical drag. + * + * @method Phaser.Physics.Arcade.Body#setDragY + * @since 3.0.0 + * + * @param {number} value - The drag, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragY: function (value) + { + this.drag.y = value; + + return this; + }, + + /** + * Sets the Body's gravity. + * + * @method Phaser.Physics.Arcade.Body#setGravity + * @since 3.0.0 + * + * @param {number} x - The horizontal component, in pixels per second squared. + * @param {number} y - The vertical component, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravity: function (x, y) + { + this.gravity.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal gravity. + * + * @method Phaser.Physics.Arcade.Body#setGravityX + * @since 3.0.0 + * + * @param {number} value - The gravity, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityX: function (value) + { + this.gravity.x = value; + + return this; + }, + + /** + * Sets the Body's vertical gravity. + * + * @method Phaser.Physics.Arcade.Body#setGravityY + * @since 3.0.0 + * + * @param {number} value - The gravity, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityY: function (value) + { + this.gravity.y = value; + + return this; + }, + + /** + * Sets the Body's friction. + * + * @method Phaser.Physics.Arcade.Body#setFriction + * @since 3.0.0 + * + * @param {number} x - The horizontal component, relative to 1. + * @param {number} y - The vertical component, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFriction: function (x, y) + { + this.friction.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal friction. + * + * @method Phaser.Physics.Arcade.Body#setFrictionX + * @since 3.0.0 + * + * @param {number} value - The friction value, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionX: function (value) + { + this.friction.x = value; + + return this; + }, + + /** + * Sets the Body's vertical friction. + * + * @method Phaser.Physics.Arcade.Body#setFrictionY + * @since 3.0.0 + * + * @param {number} value - The friction value, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionY: function (value) + { + this.friction.y = value; + + return this; + }, + + /** + * Sets the Body's angular velocity. + * + * @method Phaser.Physics.Arcade.Body#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - The velocity, in degrees per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularVelocity: function (value) + { + this.angularVelocity = value; + + return this; + }, + + /** + * Sets the Body's angular acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - The acceleration, in degrees per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularAcceleration: function (value) + { + this.angularAcceleration = value; + + return this; + }, + + /** + * Sets the Body's angular drag. + * + * @method Phaser.Physics.Arcade.Body#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - The drag, in degrees per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularDrag: function (value) + { + this.angularDrag = value; + + return this; + }, + + /** + * Sets the Body's mass. + * + * @method Phaser.Physics.Arcade.Body#setMass + * @since 3.0.0 + * + * @param {number} value - The mass value, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setMass: function (value) + { + this.mass = value; + + return this; + }, + + /** + * Sets the Body's `immovable` property. + * + * @method Phaser.Physics.Arcade.Body#setImmovable + * @since 3.0.0 + * + * @param {boolean} [value=true] - The value to assign to `immovable`. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setImmovable: function (value) + { + if (value === undefined) { value = true; } + + this.immovable = value; + + return this; + }, + + /** + * Sets the Body's `enable` property. + * + * @method Phaser.Physics.Arcade.Body#setEnable + * @since 3.15.0 + * + * @param {boolean} [value=true] - The value to assign to `enable`. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setEnable: function (value) + { + if (value === undefined) { value = true; } + + this.enable = value; + + return this; + }, + + /** + * The Body's horizontal position (left edge). + * + * @name Phaser.Physics.Arcade.Body#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + } + + }, + + /** + * The Body's vertical position (top edge). + * + * @name Phaser.Physics.Arcade.Body#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } + + }, + + /** + * The left edge of the Body's boundary. Identical to x. + * + * @name Phaser.Physics.Arcade.Body#left + * @type {number} + * @readonly + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.position.x; + } + + }, + + /** + * The right edge of the Body's boundary. + * + * @name Phaser.Physics.Arcade.Body#right + * @type {number} + * @readonly + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.position.x + this.width; + } + + }, + + /** + * The top edge of the Body's boundary. Identical to y. + * + * @name Phaser.Physics.Arcade.Body#top + * @type {number} + * @readonly + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.position.y; + } + + }, + + /** + * The bottom edge of this Body's boundary. + * + * @name Phaser.Physics.Arcade.Body#bottom + * @type {number} + * @readonly + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.position.y + this.height; + } + + } + +}); + +module.exports = Body; + + +/***/ }), +/* 261 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(260); +var Clamp = __webpack_require__(24); +var Class = __webpack_require__(0); +var Collider = __webpack_require__(259); +var CONST = __webpack_require__(39); +var DistanceBetween = __webpack_require__(58); +var EventEmitter = __webpack_require__(11); +var FuzzyEqual = __webpack_require__(276); +var FuzzyGreaterThan = __webpack_require__(275); +var FuzzyLessThan = __webpack_require__(274); +var GetOverlapX = __webpack_require__(258); +var GetOverlapY = __webpack_require__(257); +var GetValue = __webpack_require__(4); +var ProcessQueue = __webpack_require__(256); +var ProcessTileCallbacks = __webpack_require__(580); +var Rectangle = __webpack_require__(10); +var RTree = __webpack_require__(255); +var SeparateTile = __webpack_require__(579); +var SeparateX = __webpack_require__(574); +var SeparateY = __webpack_require__(573); +var Set = __webpack_require__(96); +var StaticBody = __webpack_require__(253); +var TileIntersectsBody = __webpack_require__(254); +var TransformMatrix = __webpack_require__(42); +var Vector2 = __webpack_require__(3); +var Wrap = __webpack_require__(59); + +/** + * @event Phaser.Physics.Arcade.World#pause + */ + +/** + * @event Phaser.Physics.Arcade.World#resume + */ + +/** + * @event Phaser.Physics.Arcade.World#collide + * @param {Phaser.GameObjects.GameObject} gameObject1 + * @param {Phaser.GameObjects.GameObject} gameObject2 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 + */ + +/** + * @event Phaser.Physics.Arcade.World#overlap + * @param {Phaser.GameObjects.GameObject} gameObject1 + * @param {Phaser.GameObjects.GameObject} gameObject2 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 + */ + +/** + * @event Phaser.Physics.Arcade.World#worldbounds + * @param {Phaser.Physics.Arcade.Body} body + * @param {boolean} up + * @param {boolean} down + * @param {boolean} left + * @param {boolean} right + */ + +/** + * @typedef {object} ArcadeWorldConfig + * + * @property {number} [fps=60] - Sets {@link Phaser.Physics.Arcade.World#fps}. + * @property {number} [timeScale=1] - Sets {@link Phaser.Physics.Arcade.World#timeScale}. + * @property {object} [gravity] - Sets {@link Phaser.Physics.Arcade.World#gravity}. + * @property {number} [gravity.x=0] - The horizontal world gravity value. + * @property {number} [gravity.y=0] - The vertical world gravity value. + * @property {number} [x=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.x}. + * @property {number} [y=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.y}. + * @property {number} [width=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.width}. + * @property {number} [height=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.height}. + * @property {object} [checkCollision] - Sets {@link Phaser.Physics.Arcade.World#checkCollision}. + * @property {boolean} [checkCollision.up=true] - Should bodies collide with the top of the world bounds? + * @property {boolean} [checkCollision.down=true] - Should bodies collide with the bottom of the world bounds? + * @property {boolean} [checkCollision.left=true] - Should bodies collide with the left of the world bounds? + * @property {boolean} [checkCollision.right=true] - Should bodies collide with the right of the world bounds? + * @property {number} [overlapBias=4] - Sets {@link Phaser.Physics.Arcade.World#OVERLAP_BIAS}. + * @property {number} [tileBias=16] - Sets {@link Phaser.Physics.Arcade.World#TILE_BIAS}. + * @property {boolean} [forceX=false] - Sets {@link Phaser.Physics.Arcade.World#forceX}. + * @property {boolean} [isPaused=false] - Sets {@link Phaser.Physics.Arcade.World#isPaused}. + * @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Arcade.World#debug}. + * @property {boolean} [debugShowBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowBody}. + * @property {boolean} [debugShowStaticBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. + * @property {boolean} [debugShowVelocity=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. + * @property {number} [debugBodyColor=0xff00ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugBodyColor}. + * @property {number} [debugStaticBodyColor=0x0000ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugStaticBodyColor}. + * @property {number} [debugVelocityColor=0x00ff00] - Sets {@link Phaser.Physics.Arcade.World#defaults debugVelocityColor}. + * @property {number} [maxEntries=16] - Sets {@link Phaser.Physics.Arcade.World#maxEntries}. + * @property {boolean} [useTree=true] - Sets {@link Phaser.Physics.Arcade.World#useTree}. + */ + +/** + * @typedef {object} CheckCollisionObject + * + * @property {boolean} up - [description] + * @property {boolean} down - [description] + * @property {boolean} left - [description] + * @property {boolean} right - [description] + */ + +/** + * @typedef {object} ArcadeWorldDefaults + * + * @property {boolean} debugShowBody - [description] + * @property {boolean} debugShowStaticBody - [description] + * @property {boolean} debugShowVelocity - [description] + * @property {number} bodyDebugColor - [description] + * @property {number} staticBodyDebugColor - [description] + * @property {number} velocityDebugColor - [description] + */ + +/** + * @typedef {object} ArcadeWorldTreeMinMax + * + * @property {number} minX - [description] + * @property {number} minY - [description] + * @property {number} maxX - [description] + * @property {number} maxY - [description] + */ + +/** + * An Arcade Physics Collider Type. + * + * @typedef {( + * Phaser.GameObjects.GameObject| + * Phaser.GameObjects.Group| + * Phaser.Physics.Arcade.Sprite| + * Phaser.Physics.Arcade.Image| + * Phaser.Physics.Arcade.StaticGroup| + * Phaser.Physics.Arcade.Group| + * Phaser.Tilemaps.DynamicTilemapLayer| + * Phaser.Tilemaps.StaticTilemapLayer| + * Phaser.GameObjects.GameObject[]| + * Phaser.Physics.Arcade.Sprite[]| + * Phaser.Physics.Arcade.Image[]| + * Phaser.Physics.Arcade.StaticGroup[]| + * Phaser.Physics.Arcade.Group[]| + * Phaser.Tilemaps.DynamicTilemapLayer[]| + * Phaser.Tilemaps.StaticTilemapLayer[] + * )} ArcadeColliderType + */ + +/** + * @classdesc + * The Arcade Physics World. + * + * The World is responsible for creating, managing, colliding and updating all of the bodies within it. + * + * An instance of the World belongs to a Phaser.Scene and is accessed via the property `physics.world`. + * + * @class World + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this World instance belongs. + * @param {ArcadeWorldConfig} config - An Arcade Physics Configuration object. + */ +var World = new Class({ + + Extends: EventEmitter, + + initialize: + + function World (scene, config) + { + EventEmitter.call(this); + + /** + * The Scene this simulation belongs to. + * + * @name Phaser.Physics.Arcade.World#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * Dynamic Bodies in this simulation. + * + * @name Phaser.Physics.Arcade.World#bodies + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.bodies = new Set(); + + /** + * Static Bodies in this simulation. + * + * @name Phaser.Physics.Arcade.World#staticBodies + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.staticBodies = new Set(); + + /** + * Static Bodies marked for deletion. + * + * @name Phaser.Physics.Arcade.World#pendingDestroy + * @type {Phaser.Structs.Set.<(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)>} + * @since 3.1.0 + */ + this.pendingDestroy = new Set(); + + /** + * This simulation's collision processors. + * + * @name Phaser.Physics.Arcade.World#colliders + * @type {Phaser.Structs.ProcessQueue.} + * @since 3.0.0 + */ + this.colliders = new ProcessQueue(); + + /** + * Acceleration of Bodies due to gravity, in pixels per second. + * + * @name Phaser.Physics.Arcade.World#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.gravity = new Vector2(GetValue(config, 'gravity.x', 0), GetValue(config, 'gravity.y', 0)); + + /** + * A boundary constraining Bodies. + * + * @name Phaser.Physics.Arcade.World#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.0.0 + */ + this.bounds = new Rectangle( + GetValue(config, 'x', 0), + GetValue(config, 'y', 0), + GetValue(config, 'width', scene.sys.game.config.width), + GetValue(config, 'height', scene.sys.game.config.height) + ); + + /** + * The boundary edges that Bodies can collide with. + * + * @name Phaser.Physics.Arcade.World#checkCollision + * @type {CheckCollisionObject} + * @since 3.0.0 + */ + this.checkCollision = { + up: GetValue(config, 'checkCollision.up', true), + down: GetValue(config, 'checkCollision.down', true), + left: GetValue(config, 'checkCollision.left', true), + right: GetValue(config, 'checkCollision.right', true) + }; + + /** + * The number of physics steps to be taken per second. + * + * This property is read-only. Use the `setFPS` method to modify it at run-time. + * + * @name Phaser.Physics.Arcade.World#fps + * @readonly + * @type {number} + * @default 60 + * @since 3.10.0 + */ + this.fps = GetValue(config, 'fps', 60); + + /** + * The amount of elapsed ms since the last frame. + * + * @name Phaser.Physics.Arcade.World#_elapsed + * @private + * @type {number} + * @since 3.10.0 + */ + this._elapsed = 0; + + /** + * Internal frame time value. + * + * @name Phaser.Physics.Arcade.World#_frameTime + * @private + * @type {number} + * @since 3.10.0 + */ + this._frameTime = 1 / this.fps; + + /** + * Internal frame time ms value. + * + * @name Phaser.Physics.Arcade.World#_frameTimeMS + * @private + * @type {number} + * @since 3.10.0 + */ + this._frameTimeMS = 1000 * this._frameTime; + + /** + * The number of steps that took place in the last frame. + * + * @name Phaser.Physics.Arcade.World#stepsLastFrame + * @readonly + * @type {number} + * @since 3.10.0 + */ + this.stepsLastFrame = 0; + + /** + * Scaling factor applied to the frame rate. + * + * - 1.0 = normal speed + * - 2.0 = half speed + * - 0.5 = double speed + * + * @name Phaser.Physics.Arcade.World#timeScale + * @property {number} + * @default 1 + * @since 3.10.0 + */ + this.timeScale = GetValue(config, 'timeScale', 1); + + /** + * The maximum absolute difference of a Body's per-step velocity and its overlap with another Body that will result in separation on *each axis*. + * Larger values favor separation. + * Smaller values favor no separation. + * + * @name Phaser.Physics.Arcade.World#OVERLAP_BIAS + * @type {number} + * @default 4 + * @since 3.0.0 + */ + this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4); + + /** + * The maximum absolute value of a Body's overlap with a tile that will result in separation on *each axis*. + * Larger values favor separation. + * Smaller values favor no separation. + * The optimum value may be similar to the tile size. + * + * @name Phaser.Physics.Arcade.World#TILE_BIAS + * @type {number} + * @default 16 + * @since 3.0.0 + */ + this.TILE_BIAS = GetValue(config, 'tileBias', 16); + + /** + * Always separate overlapping Bodies horizontally before vertically. + * False (the default) means Bodies are first separated on the axis of greater gravity, or the vertical axis if neither is greater. + * + * @name Phaser.Physics.Arcade.World#forceX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.forceX = GetValue(config, 'forceX', false); + + /** + * Whether the simulation advances with the game loop. + * + * @name Phaser.Physics.Arcade.World#isPaused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPaused = GetValue(config, 'isPaused', false); + + /** + * Temporary total of colliding Bodies. + * + * @name Phaser.Physics.Arcade.World#_total + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._total = 0; + + /** + * Enables the debug display. + * + * @name Phaser.Physics.Arcade.World#drawDebug + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.drawDebug = GetValue(config, 'debug', false); + + /** + * The graphics object drawing the debug display. + * + * @name Phaser.Physics.Arcade.World#debugGraphic + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.debugGraphic; + + /** + * Default debug display settings for new Bodies. + * + * @name Phaser.Physics.Arcade.World#defaults + * @type {ArcadeWorldDefaults} + * @since 3.0.0 + */ + this.defaults = { + debugShowBody: GetValue(config, 'debugShowBody', true), + debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), + debugShowVelocity: GetValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), + staticBodyDebugColor: GetValue(config, 'debugStaticBodyColor', 0x0000ff), + velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) + }; + + /** + * The maximum number of items per node on the RTree. + * + * This is ignored if `useTree` is `false`. If you have a large number of bodies in + * your world then you may find search performance improves by increasing this value, + * to allow more items per node and less node division. + * + * @name Phaser.Physics.Arcade.World#maxEntries + * @type {integer} + * @default 16 + * @since 3.0.0 + */ + this.maxEntries = GetValue(config, 'maxEntries', 16); + + /** + * Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not? + * + * An RTree is a fast way of spatially sorting of all the moving bodies in the world. + * However, at certain limits, the cost of clearing and inserting the bodies into the + * tree every frame becomes more expensive than the search speed gains it provides. + * + * If you have a large number of dynamic bodies in your world then it may be best to + * disable the use of the RTree by setting this property to `true`. + * The number it can cope with depends on browser and device, but a conservative estimate + * of around 5,000 bodies should be considered the max before disabling it. + * + * Note this only applies to dynamic bodies. Static bodies are always kept in an RTree, + * because they don't have to be cleared every frame, so you benefit from the + * massive search speeds all the time. + * + * @name Phaser.Physics.Arcade.World#useTree + * @type {boolean} + * @default true + * @since 3.10.0 + */ + this.useTree = GetValue(config, 'useTree', true); + + /** + * The spatial index of Dynamic Bodies. + * + * @name Phaser.Physics.Arcade.World#tree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.tree = new RTree(this.maxEntries); + + /** + * The spatial index of Static Bodies. + * + * @name Phaser.Physics.Arcade.World#staticTree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.staticTree = new RTree(this.maxEntries); + + /** + * Recycled input for tree searches. + * + * @name Phaser.Physics.Arcade.World#treeMinMax + * @type {ArcadeWorldTreeMinMax} + * @since 3.0.0 + */ + this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; + + /** + * A temporary Transform Matrix used by bodies for calculations without them needing their own local copy. + * + * @name Phaser.Physics.Arcade.World#_tempMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * A temporary Transform Matrix used by bodies for calculations without them needing their own local copy. + * + * @name Phaser.Physics.Arcade.World#_tempMatrix2 + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + if (this.drawDebug) + { + this.createDebugGraphic(); + } + }, + + /** + * Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group. + * + * The difference between this and the `enableBody` method is that you can pass arrays or Groups + * to this method. + * + * You can specify if the bodies are to be Dynamic or Static. A dynamic body can move via velocity and + * acceleration. A static body remains fixed in place and as such is able to use an optimized search + * tree, making it ideal for static elements such as level objects. You can still collide and overlap + * with static bodies. + * + * Normally, rather than calling this method directly, you'd use the helper methods available in the + * Arcade Physics Factory, such as: + * + * ```javascript + * this.physics.add.image(x, y, textureKey); + * this.physics.add.sprite(x, y, textureKey); + * ``` + * + * Calling factory methods encapsulates the creation of a Game Object and the creation of its + * body at the same time. If you are creating custom classes then you can pass them to this + * method to have their bodies created. + * + * @method Phaser.Physics.Arcade.World#enable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to create the bodies. + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + */ + enable: function (object, bodyType) + { + if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } + + if (!Array.isArray(object)) + { + object = [ object ]; + } + + for (var i = 0; i < object.length; i++) + { + var entry = object[i]; + + if (entry.isParent) + { + var children = entry.getChildren(); + + for (var c = 0; c < children.length; c++) + { + var child = children[c]; + + if (child.isParent) + { + // Handle Groups nested inside of Groups + this.enable(child, bodyType); + } + else + { + this.enableBody(child, bodyType); + } + } + } + else + { + this.enableBody(entry, bodyType); + } + } + }, + + /** + * Creates an Arcade Physics Body on a single Game Object. + * + * If the Game Object already has a body, this method will simply add it back into the simulation. + * + * You can specify if the body is Dynamic or Static. A dynamic body can move via velocity and + * acceleration. A static body remains fixed in place and as such is able to use an optimized search + * tree, making it ideal for static elements such as level objects. You can still collide and overlap + * with static bodies. + * + * Normally, rather than calling this method directly, you'd use the helper methods available in the + * Arcade Physics Factory, such as: + * + * ```javascript + * this.physics.add.image(x, y, textureKey); + * this.physics.add.sprite(x, y, textureKey); + * ``` + * + * Calling factory methods encapsulates the creation of a Game Object and the creation of its + * body at the same time. If you are creating custom classes then you can pass them to this + * method to have their bodies created. + * + * @method Phaser.Physics.Arcade.World#enableBody + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object - The Game Object on which to create the body. + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + * + * @return {Phaser.GameObjects.GameObject} The Game Object on which the body was created. + */ + enableBody: function (object, bodyType) + { + if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } + + if (!object.body) + { + if (bodyType === CONST.DYNAMIC_BODY) + { + object.body = new Body(this, object); + } + else if (bodyType === CONST.STATIC_BODY) + { + object.body = new StaticBody(this, object); + } + } + + this.add(object.body); + + return object; + }, + + /** + * Adds an existing Arcade Physics Body or StaticBody to the simulation. + * + * The body is enabled and added to the local search trees. + * + * @method Phaser.Physics.Arcade.World#add + * @since 3.10.0 + * + * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be added to the simulation. + * + * @return {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} The Body that was added to the simulation. + */ + add: function (body) + { + if (body.physicsType === CONST.DYNAMIC_BODY) + { + this.bodies.set(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.set(body); + + this.staticTree.insert(body); + } + + body.enable = true; + + return body; + }, + + /** + * Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group. + * + * The difference between this and the `disableBody` method is that you can pass arrays or Groups + * to this method. + * + * The body itself is not deleted, it just has its `enable` property set to false, which + * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. + * + * @method Phaser.Physics.Arcade.World#disable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to disable the bodies. + */ + disable: function (object) + { + if (!Array.isArray(object)) + { + object = [ object ]; + } + + for (var i = 0; i < object.length; i++) + { + var entry = object[i]; + + if (entry.isParent) + { + var children = entry.getChildren(); + + for (var c = 0; c < children.length; c++) + { + var child = children[c]; + + if (child.isParent) + { + // Handle Groups nested inside of Groups + this.disable(child); + } + else + { + this.disableBody(child.body); + } + } + } + else + { + this.disableBody(entry.body); + } + } + }, + + /** + * Disables an existing Arcade Physics Body or StaticBody and removes it from the simulation. + * + * The body is disabled and removed from the local search trees. + * + * The body itself is not deleted, it just has its `enable` property set to false, which + * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. + * + * @method Phaser.Physics.Arcade.World#disableBody + * @since 3.0.0 + * + * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be disabled. + */ + disableBody: function (body) + { + this.remove(body); + + body.enable = false; + }, + + /** + * Removes an existing Arcade Physics Body or StaticBody from the simulation. + * + * The body is disabled and removed from the local search trees. + * + * The body itself is not deleted, it just has its `enabled` property set to false, which + * means you can re-enable it again at any point by passing it to enable `enable` or `add`. + * + * @method Phaser.Physics.Arcade.World#remove + * @since 3.0.0 + * + * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The body to be removed from the simulation. + */ + remove: function (body) + { + if (body.physicsType === CONST.DYNAMIC_BODY) + { + this.tree.remove(body); + this.bodies.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.delete(body); + this.staticTree.remove(body); + } + }, + + /** + * Creates a Graphics Game Object that the world will use to render the debug display to. + * + * This is called automatically when the World is instantiated if the `debug` config property + * was set to `true`. However, you can call it at any point should you need to display the + * debug Graphic from a fixed point. + * + * You can control which objects are drawn to the Graphics object, and the colors they use, + * by setting the debug properties in the physics config. + * + * You should not typically use this in a production game. Use it to aid during debugging. + * + * @method Phaser.Physics.Arcade.World#createDebugGraphic + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} The Graphics object that was created for use by the World. + */ + createDebugGraphic: function () + { + var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); + + graphic.setDepth(Number.MAX_VALUE); + + this.debugGraphic = graphic; + + this.drawDebug = true; + + return graphic; + }, + + /** + * Sets the position, size and properties of the World boundary. + * + * The World boundary is an invisible rectangle that defines the edges of the World. + * If a Body is set to collide with the world bounds then it will automatically stop + * when it reaches any of the edges. You can optionally set which edges of the boundary + * should be checked against. + * + * @method Phaser.Physics.Arcade.World#setBounds + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the boundary. + * @param {number} y - The top-left y coordinate of the boundary. + * @param {number} width - The width of the boundary. + * @param {number} height - The height of the boundary. + * @param {boolean} [checkLeft] - Should bodies check against the left edge of the boundary? + * @param {boolean} [checkRight] - Should bodies check against the right edge of the boundary? + * @param {boolean} [checkUp] - Should bodies check against the top edge of the boundary? + * @param {boolean} [checkDown] - Should bodies check against the bottom edge of the boundary? + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBounds: function (x, y, width, height, checkLeft, checkRight, checkUp, checkDown) + { + this.bounds.setTo(x, y, width, height); + + if (checkLeft !== undefined) + { + this.setBoundsCollision(checkLeft, checkRight, checkUp, checkDown); + } + + return this; + }, + + /** + * Enables or disables collisions on each edge of the World boundary. + * + * @method Phaser.Physics.Arcade.World#setBoundsCollision + * @since 3.0.0 + * + * @param {boolean} [left=true] - Should bodies check against the left edge of the boundary? + * @param {boolean} [right=true] - Should bodies check against the right edge of the boundary? + * @param {boolean} [up=true] - Should bodies check against the top edge of the boundary? + * @param {boolean} [down=true] - Should bodies check against the bottom edge of the boundary? + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBoundsCollision: function (left, right, up, down) + { + if (left === undefined) { left = true; } + if (right === undefined) { right = true; } + if (up === undefined) { up = true; } + if (down === undefined) { down = true; } + + this.checkCollision.left = left; + this.checkCollision.right = right; + this.checkCollision.up = up; + this.checkCollision.down = down; + + return this; + }, + + /** + * Pauses the simulation. + * + * A paused simulation does not update any existing bodies, or run any Colliders. + * + * However, you can still enable and disable bodies within it, or manually run collide or overlap + * checks. + * + * @method Phaser.Physics.Arcade.World#pause + * @fires Phaser.Physics.Arcade.World#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + pause: function () + { + this.isPaused = true; + + this.emit('pause'); + + return this; + }, + + /** + * Resumes the simulation, if paused. + * + * @method Phaser.Physics.Arcade.World#resume + * @fires Phaser.Physics.Arcade.World#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + resume: function () + { + this.isPaused = false; + + this.emit('resume'); + + return this; + }, + + /** + * Creates a new Collider object and adds it to the simulation. + * + * A Collider is a way to automatically perform collision checks between two objects, + * calling the collide and process callbacks if they occur. + * + * Colliders are run as part of the World update, after all of the Bodies have updated. + * + * By creating a Collider you don't need then call `World.collide` in your `update` loop, + * as it will be handled for you automatically. + * + * @method Phaser.Physics.Arcade.World#addCollider + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#collide + * + * @param {ArcadeColliderType} object1 - The first object to check for collision. + * @param {ArcadeColliderType} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addCollider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, false, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * Creates a new Overlap Collider object and adds it to the simulation. + * + * A Collider is a way to automatically perform overlap checks between two objects, + * calling the collide and process callbacks if they occur. + * + * Colliders are run as part of the World update, after all of the Bodies have updated. + * + * By creating a Collider you don't need then call `World.overlap` in your `update` loop, + * as it will be handled for you automatically. + * + * @method Phaser.Physics.Arcade.World#addOverlap + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object to check for overlap. + * @param {ArcadeColliderType} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects overlap. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects overlap. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addOverlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, true, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * Removes a Collider from the simulation so it is no longer processed. + * + * This method does not destroy the Collider. If you wish to add it back at a later stage you can call + * `World.colliders.add(Collider)`. + * + * If you no longer need the Collider you can call the `Collider.destroy` method instead, which will + * automatically clear all of its references and then remove it from the World. If you call destroy on + * a Collider you _don't_ need to pass it to this method too. + * + * @method Phaser.Physics.Arcade.World#removeCollider + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Collider} collider - The Collider to remove from the simulation. + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + removeCollider: function (collider) + { + this.colliders.remove(collider); + + return this; + }, + + /** + * Sets the frame rate to run the simulation at. + * + * The frame rate value is used to simulate a fixed update time step. This fixed + * time step allows for a straightforward implementation of a deterministic game state. + * + * This frame rate is independent of the frequency at which the game is rendering. The + * higher you set the fps, the more physics simulation steps will occur per game step. + * Conversely, the lower you set it, the less will take place. + * + * You can optionally advance the simulation directly yourself by calling the `step` method. + * + * @method Phaser.Physics.Arcade.World#setFPS + * @since 3.10.0 + * + * @param {integer} framerate - The frame rate to advance the simulation at. + * + * @return {this} This World object. + */ + setFPS: function (framerate) + { + this.fps = framerate; + this._frameTime = 1 / this.fps; + this._frameTimeMS = 1000 * this._frameTime; + + return this; + }, + + /** + * Advances the simulation based on the elapsed time and fps rate. + * + * This is called automatically by your Scene and does not need to be invoked directly. + * + * @method Phaser.Physics.Arcade.World#update + * @protected + * @since 3.0.0 + * + * @param {number} 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.isPaused || this.bodies.size === 0) + { + return; + } + + var stepsThisFrame = 0; + var fixedDelta = this._frameTime; + var msPerFrame = this._frameTimeMS * this.timeScale; + + this._elapsed += delta; + + while (this._elapsed >= msPerFrame) + { + this._elapsed -= msPerFrame; + + stepsThisFrame++; + + this.step(fixedDelta); + } + + this.stepsLastFrame = stepsThisFrame; + }, + + /** + * Advances the simulation by one step. + * + * @method Phaser.Physics.Arcade.World#step + * @since 3.10.0 + * + * @param {number} delta - The delta time amount, in ms, by which to advance the simulation. + */ + step: function (delta) + { + // Update all active bodies + var i; + var body; + var bodies = this.bodies.entries; + var len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.update(delta); + } + } + + // Optionally populate our dynamic collision tree + if (this.useTree) + { + this.tree.clear(); + this.tree.load(bodies); + } + + // Process any colliders + var colliders = this.colliders.update(); + + for (i = 0; i < colliders.length; i++) + { + var collider = colliders[i]; + + if (collider.active) + { + collider.update(); + } + } + + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.postUpdate(); + } + } + }, + + /** + * Updates bodies, draws the debug display, and handles pending queue operations. + * + * @method Phaser.Physics.Arcade.World#postUpdate + * @since 3.0.0 + */ + postUpdate: function () + { + var i; + var body; + + var dynamic = this.bodies; + var staticBodies = this.staticBodies; + var pending = this.pendingDestroy; + + var bodies = dynamic.entries; + var len = bodies.length; + + if (this.drawDebug) + { + var graphics = this.debugGraphic; + + graphics.clear(); + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + + bodies = staticBodies.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + } + + if (pending.size > 0) + { + var dynamicTree = this.tree; + var staticTree = this.staticTree; + + bodies = pending.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.physicsType === CONST.DYNAMIC_BODY) + { + dynamicTree.remove(body); + dynamic.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + staticTree.remove(body); + staticBodies.delete(body); + } + + body.world = undefined; + body.gameObject = undefined; + } + + pending.clear(); + } + }, + + /** + * Calculates a Body's velocity and updates its position. + * + * @method Phaser.Physics.Arcade.World#updateMotion + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body to be updated. + * @param {number} delta - The delta value to be used in the motion calculations. + */ + updateMotion: function (body, delta) + { + if (body.allowRotation) + { + this.computeAngularVelocity(body, delta); + } + + this.computeVelocity(body, delta); + }, + + /** + * Calculates a Body's angular velocity. + * + * @method Phaser.Physics.Arcade.World#computeAngularVelocity + * @since 3.10.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. + * @param {number} delta - The delta value to be used in the calculation. + */ + computeAngularVelocity: function (body, delta) + { + var velocity = body.angularVelocity; + var acceleration = body.angularAcceleration; + var drag = body.angularDrag; + var max = body.maxAngular; + + if (acceleration) + { + velocity += acceleration * delta; + } + else if (body.allowDrag && drag) + { + drag *= delta; + + if (FuzzyGreaterThan(velocity - drag, 0, 0.1)) + { + velocity -= drag; + } + else if (FuzzyLessThan(velocity + drag, 0, 0.1)) + { + velocity += drag; + } + else + { + velocity = 0; + } + } + + velocity = Clamp(velocity, -max, max); + + var velocityDelta = velocity - body.angularVelocity; + + body.angularVelocity += velocityDelta; + body.rotation += (body.angularVelocity * delta); + }, + + /** + * Calculates a Body's per-axis velocity. + * + * @method Phaser.Physics.Arcade.World#computeVelocity + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. + * @param {number} delta - The delta value to be used in the calculation. + */ + computeVelocity: function (body, delta) + { + var velocityX = body.velocity.x; + var accelerationX = body.acceleration.x; + var dragX = body.drag.x; + var maxX = body.maxVelocity.x; + + var velocityY = body.velocity.y; + var accelerationY = body.acceleration.y; + var dragY = body.drag.y; + var maxY = body.maxVelocity.y; + + var speed = body.speed; + var allowDrag = body.allowDrag; + var useDamping = body.useDamping; + + if (body.allowGravity) + { + velocityX += (this.gravity.x + body.gravity.x) * delta; + velocityY += (this.gravity.y + body.gravity.y) * delta; + } + + if (accelerationX) + { + velocityX += accelerationX * delta; + } + else if (allowDrag && dragX) + { + if (useDamping) + { + // Damping based deceleration + velocityX *= dragX; + + if (FuzzyEqual(speed, 0, 0.001)) + { + velocityX = 0; + } + } + else + { + // Linear deceleration + dragX *= delta; + + if (FuzzyGreaterThan(velocityX - dragX, 0, 0.01)) + { + velocityX -= dragX; + } + else if (FuzzyLessThan(velocityX + dragX, 0, 0.01)) + { + velocityX += dragX; + } + else + { + velocityX = 0; + } + } + } + + if (accelerationY) + { + velocityY += accelerationY * delta; + } + else if (allowDrag && dragY) + { + if (useDamping) + { + // Damping based deceleration + velocityY *= dragY; + + if (FuzzyEqual(speed, 0, 0.001)) + { + velocityY = 0; + } + } + else + { + // Linear deceleration + dragY *= delta; + + if (FuzzyGreaterThan(velocityY - dragY, 0, 0.01)) + { + velocityY -= dragY; + } + else if (FuzzyLessThan(velocityY + dragY, 0, 0.01)) + { + velocityY += dragY; + } + else + { + velocityY = 0; + } + } + } + + velocityX = Clamp(velocityX, -maxX, maxX); + velocityY = Clamp(velocityY, -maxY, maxY); + + body.velocity.set(velocityX, velocityY); + }, + + /** + * Separates two Bodies. + * + * @method Phaser.Physics.Arcade.World#separate + * @fires Phaser.Physics.Arcade.World#collide + * @fires Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. + * @param {ArcadePhysicsCallback} [processCallback] - The process callback. + * @param {*} [callbackContext] - The context in which to invoke the callback. + * @param {boolean} [overlapOnly] - If this a collide or overlap check? + * + * @return {boolean} True if separation occurred, otherwise false. + */ + separate: function (body1, body2, processCallback, callbackContext, overlapOnly) + { + if ( + !body1.enable || + !body2.enable || + body1.checkCollision.none || + body2.checkCollision.none || + !this.intersects(body1, body2)) + { + return false; + } + + // They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort. + if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false) + { + return false; + } + + // Circle vs. Circle quick bail out + if (body1.isCircle && body2.isCircle) + { + return this.separateCircle(body1, body2, overlapOnly); + } + + // We define the behavior of bodies in a collision circle and rectangle + // If a collision occurs in the corner points of the rectangle, the body behave like circles + + // Either body1 or body2 is a circle + if (body1.isCircle !== body2.isCircle) + { + var bodyRect = (body1.isCircle) ? body2 : body1; + var bodyCircle = (body1.isCircle) ? body1 : body2; + + var rect = { + x: bodyRect.x, + y: bodyRect.y, + right: bodyRect.right, + bottom: bodyRect.bottom + }; + + var circle = bodyCircle.center; + + if (circle.y < rect.y || circle.y > rect.bottom) + { + if (circle.x < rect.x || circle.x > rect.right) + { + return this.separateCircle(body1, body2, overlapOnly); + } + } + } + + var resultX = false; + var resultY = false; + + // Do we separate on x or y first? + if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + else + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + + var result = (resultX || resultY); + + if (result) + { + if (overlapOnly && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + else + { + body1.postUpdate(); + body2.postUpdate(); + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + } + } + + return result; + }, + + /** + * Separates two Bodies, when both are circular. + * + * @method Phaser.Physics.Arcade.World#separateCircle + * @fires Phaser.Physics.Arcade.World#collide + * @fires Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. + * @param {boolean} [overlapOnly] - If this a collide or overlap check? + * @param {number} bias - A small value added to the calculations. + * + * @return {boolean} True if separation occurred, otherwise false. + */ + separateCircle: function (body1, body2, overlapOnly, bias) + { + // Set the bounding box overlap values into the bodies themselves (hence we don't use the return values here) + GetOverlapX(body1, body2, false, bias); + GetOverlapY(body1, body2, false, bias); + + var dx = body2.center.x - body1.center.x; + var dy = body2.center.y - body1.center.y; + + var angleCollision = Math.atan2(dy, dx); + + var overlap = 0; + + if (body1.isCircle !== body2.isCircle) + { + var rect = { + x: (body2.isCircle) ? body1.position.x : body2.position.x, + y: (body2.isCircle) ? body1.position.y : body2.position.y, + right: (body2.isCircle) ? body1.right : body2.right, + bottom: (body2.isCircle) ? body1.bottom : body2.bottom + }; + + var circle = { + x: (body1.isCircle) ? body1.center.x : body2.center.x, + y: (body1.isCircle) ? body1.center.y : body2.center.y, + radius: (body1.isCircle) ? body1.halfWidth : body2.halfWidth + }; + + if (circle.y < rect.y) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.y) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.y) - circle.radius; + } + } + else if (circle.y > rect.bottom) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.bottom) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.bottom) - circle.radius; + } + } + + overlap *= -1; + } + else + { + overlap = (body1.halfWidth + body2.halfWidth) - DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y); + } + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) + { + if (overlap !== 0 && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + + // return true if there was some overlap, otherwise false + return (overlap !== 0); + } + + // Transform the velocity vector to the coordinate system oriented along the direction of impact. + // This is done to eliminate the vertical component of the velocity + + var b1vx = body1.velocity.x; + var b1vy = body1.velocity.y; + var b1mass = body1.mass; + + var b2vx = body2.velocity.x; + var b2vy = body2.velocity.y; + var b2mass = body2.mass; + + var v1 = { + x: b1vx * Math.cos(angleCollision) + b1vy * Math.sin(angleCollision), + y: b1vx * Math.sin(angleCollision) - b1vy * Math.cos(angleCollision) + }; + + var v2 = { + x: b2vx * Math.cos(angleCollision) + b2vy * Math.sin(angleCollision), + y: b2vx * Math.sin(angleCollision) - b2vy * Math.cos(angleCollision) + }; + + // We expect the new velocity after impact + var tempVel1 = ((b1mass - b2mass) * v1.x + 2 * b2mass * v2.x) / (b1mass + b2mass); + var tempVel2 = (2 * b1mass * v1.x + (b2mass - b1mass) * v2.x) / (b1mass + b2mass); + + // We convert the vector to the original coordinate system and multiplied by factor of rebound + if (!body1.immovable) + { + body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x; + body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y; + + // Reset local var + b1vx = body1.velocity.x; + b1vy = body1.velocity.y; + } + + if (!body2.immovable) + { + body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x; + body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y; + + // Reset local var + b2vx = body2.velocity.x; + b2vy = body2.velocity.y; + } + + // When the collision angle is almost perpendicular to the total initial velocity vector + // (collision on a tangent) vector direction can be determined incorrectly. + // This code fixes the problem + + if (Math.abs(angleCollision) < Math.PI / 2) + { + if ((b1vx > 0) && !body1.immovable && (b2vx > b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx < 0) && !body2.immovable && (b1vx < b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy > 0) && !body1.immovable && (b2vy > b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy < 0) && !body2.immovable && (b1vy < b2vy)) + { + body2.velocity.y *= -1; + } + } + else if (Math.abs(angleCollision) > Math.PI / 2) + { + if ((b1vx < 0) && !body1.immovable && (b2vx < b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx > 0) && !body2.immovable && (b1vx > b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy < 0) && !body1.immovable && (b2vy < b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy > 0) && !body2.immovable && (b1vx > b2vy)) + { + body2.velocity.y *= -1; + } + } + + var delta = this._frameTime; + + if (!body1.immovable) + { + body1.x += (body1.velocity.x * delta) - overlap * Math.cos(angleCollision); + body1.y += (body1.velocity.y * delta) - overlap * Math.sin(angleCollision); + } + + if (!body2.immovable) + { + body2.x += (body2.velocity.x * delta) + overlap * Math.cos(angleCollision); + body2.y += (body2.velocity.y * delta) + overlap * Math.sin(angleCollision); + } + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + + // sync changes back to the bodies + body1.postUpdate(); + body2.postUpdate(); + + return true; + }, + + /** + * Checks to see if two Bodies intersect at all. + * + * @method Phaser.Physics.Arcade.World#intersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - The first body to check. + * @param {Phaser.Physics.Arcade.Body} body2 - The second body to check. + * + * @return {boolean} True if the two bodies intersect, otherwise false. + */ + intersects: function (body1, body2) + { + if (body1 === body2) + { + return false; + } + + if (!body1.isCircle && !body2.isCircle) + { + // Rect vs. Rect + return !( + body1.right <= body2.position.x || + body1.bottom <= body2.position.y || + body1.position.x >= body2.right || + body1.position.y >= body2.bottom + ); + } + else if (body1.isCircle) + { + if (body2.isCircle) + { + // Circle vs. Circle + return DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.halfWidth + body2.halfWidth); + } + else + { + // Circle vs. Rect + return this.circleBodyIntersects(body1, body2); + } + } + else + { + // Rect vs. Circle + return this.circleBodyIntersects(body2, body1); + } + }, + + /** + * Tests if a circular Body intersects with another Body. + * + * @method Phaser.Physics.Arcade.World#circleBodyIntersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} circle - The circular body to test. + * @param {Phaser.Physics.Arcade.Body} body - The rectangular body to test. + * + * @return {boolean} True if the two bodies intersect, otherwise false. + */ + circleBodyIntersects: function (circle, body) + { + var x = Clamp(circle.center.x, body.left, body.right); + var y = Clamp(circle.center.y, body.top, body.bottom); + + var dx = (circle.center.x - x) * (circle.center.x - x); + var dy = (circle.center.y - y) * (circle.center.y - y); + + return (dx + dy) <= (circle.halfWidth * circle.halfWidth); + }, + + /** + * Tests if Game Objects overlap. + * + * @method Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [overlapCallback] - An optional callback function that is called if the objects overlap. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if at least one Game Object overlaps another. + */ + overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) + { + if (overlapCallback === undefined) { overlapCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = overlapCallback; } + + return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + }, + + /** + * Performs a collision check and separation between the two physics enabled objects given, which can be single + * Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups. + * + * If you don't require separation then use {@link #overlap} instead. + * + * If two Groups or arrays are passed, each member of one will be tested against each member of the other. + * + * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. + * + * Two callbacks can be provided. The `collideCallback` is invoked if a collision occurs and the two colliding + * objects are passed to it. + * + * Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable + * for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other. + * The separation that stops two objects penetrating may create a new penetration against a different object. If you + * require a high level of stability please consider using an alternative physics system, such as Matter.js. + * + * @method Phaser.Physics.Arcade.World#collide + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if any overlapping Game Objects were separated, otherwise false. + */ + collide: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + }, + + /** + * Helper for Phaser.Physics.Arcade.World#collide. + * + * @method Phaser.Physics.Arcade.World#collideObjects + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - [description] + * @param {ArcadeColliderType} [object2] - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. + */ + collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + var i; + + if (object1.isParent && object1.physicsType === undefined) + { + object1 = object1.children.entries; + } + + if (object2 && object2.isParent && object2.physicsType === undefined) + { + object2 = object2.children.entries; + } + + var object1isArray = Array.isArray(object1); + var object2isArray = Array.isArray(object2); + + this._total = 0; + + if (!object1isArray && !object2isArray) + { + // Neither of them are arrays - do this first as it's the most common use-case + this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (!object1isArray && object2isArray) + { + // Object 2 is an Array + for (i = 0; i < object2.length; i++) + { + this.collideHandler(object1, object2[i], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else if (object1isArray && !object2isArray) + { + // Object 1 is an Array + for (i = 0; i < object1.length; i++) + { + this.collideHandler(object1[i], object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else + { + // They're both arrays + for (i = 0; i < object1.length; i++) + { + for (var j = 0; j < object2.length; j++) + { + this.collideHandler(object1[i], object2[j], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + } + + return (this._total > 0); + }, + + /** + * Helper for Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap. + * + * @method Phaser.Physics.Arcade.World#collideHandler + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - [description] + * @param {ArcadeColliderType} [object2] - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. + */ + collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + // Collide Group with Self + // Only collide valid objects + if (object2 === undefined && object1.isParent) + { + return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + + // If neither of the objects are set then bail out + if (!object1 || !object2) + { + return false; + } + + // A Body + if (object1.body) + { + if (object2.body) + { + return this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // GROUPS + else if (object1.isParent) + { + if (object2.body) + { + return this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // TILEMAP LAYERS + else if (object1.isTilemap) + { + if (object2.body) + { + return this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + }, + + /** + * Handler for Sprite vs. Sprite collisions. + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite1 - [description] + * @param {Phaser.GameObjects.GameObject} sprite2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (!sprite1.body || !sprite2.body) + { + return false; + } + + if (this.separate(sprite1.body, sprite2.body, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, sprite1, sprite2); + } + + this._total++; + } + + return true; + }, + + /** + * Handler for Sprite vs. Group collisions. + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {Phaser.GameObjects.Group} group - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) + { + var bodyA = sprite.body; + + if (group.length === 0 || !bodyA || !bodyA.enable) + { + return; + } + + // Does sprite collide with anything? + + var i; + var len; + var bodyB; + + if (this.useTree) + { + var minMax = this.treeMinMax; + + minMax.minX = bodyA.left; + minMax.minY = bodyA.top; + minMax.maxX = bodyA.right; + minMax.maxY = bodyA.bottom; + + var results = (group.physicsType === CONST.DYNAMIC_BODY) ? this.tree.search(minMax) : this.staticTree.search(minMax); + + len = results.length; + + for (i = 0; i < len; i++) + { + bodyB = results[i]; + + if (bodyA === bodyB || !group.contains(bodyB.gameObject)) + { + // Skip if comparing against itself, or if bodyB isn't actually part of the Group + continue; + } + + if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); + } + + this._total++; + } + } + } + else + { + var children = group.getChildren(); + var skipIndex = group.children.entries.indexOf(sprite); + + len = children.length; + + for (i = 0; i < len; i++) + { + bodyB = children[i].body; + + if (!bodyB || i === skipIndex || !bodyB.enable) + { + continue; + } + + if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); + } + + this._total++; + } + } + } + }, + + /** + * Helper for Group vs. Tilemap collisions. + * + * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var children = group.getChildren(); + + if (children.length === 0) + { + return false; + } + + var didCollide = false; + + for (var i = 0; i < children.length; i++) + { + if (children[i].body) + { + if (this.collideSpriteVsTilemapLayer(children[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)) + { + didCollide = true; + } + } + } + + return didCollide; + }, + + /** + * Helper for Sprite vs. Tilemap collisions. + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer + * @fires Phaser.Physics.Arcade.World#collide + * @fires Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var body = sprite.body; + + if (!body.enable) + { + return false; + } + + var x = body.position.x; + var y = body.position.y; + var w = body.width; + var h = body.height; + + // TODO: this logic should be encapsulated within the Tilemap API at some point. + // If the maps base tile size differs from the layer's tile size, we need to adjust the + // selection area by the difference between the two. + var layerData = tilemapLayer.layer; + + if (layerData.tileWidth > layerData.baseTileWidth) + { + // The x origin of a tile is the left side, so x and width need to be adjusted. + var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; + x -= xDiff; + w += xDiff; + } + + if (layerData.tileHeight > layerData.baseTileHeight) + { + // The y origin of a tile is the bottom side, so just the height needs to be adjusted. + var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; + h += yDiff; + } + + var mapData = tilemapLayer.getTilesWithinWorldXY(x, y, w, h); + + if (mapData.length === 0) + { + return false; + } + + var tile; + var tileWorldRect = { left: 0, right: 0, top: 0, bottom: 0 }; + + for (var i = 0; i < mapData.length; i++) + { + tile = mapData[i]; + tileWorldRect.left = tilemapLayer.tileToWorldX(tile.x); + tileWorldRect.top = tilemapLayer.tileToWorldY(tile.y); + + // If the map's base tile size differs from the layer's tile size, only the top of the rect + // needs to be adjusted since its origin is (0, 1). + if (tile.baseHeight !== tile.height) + { + tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; + } + + tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; + tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; + + if (TileIntersectsBody(tileWorldRect, body) + && (!processCallback || processCallback.call(callbackContext, sprite, tile)) + && ProcessTileCallbacks(tile, sprite) + && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) + { + this._total++; + + if (collideCallback) + { + collideCallback.call(callbackContext, sprite, tile); + } + + if (overlapOnly && body.onOverlap) + { + sprite.emit('overlap', body.gameObject, tile, body, null); + } + else if (body.onCollide) + { + sprite.emit('collide', body.gameObject, tile, body, null); + } + + // sync changes back to the body + body.postUpdate(); + } + } + }, + + /** + * Helper for Group vs. Group collisions. + * + * @method Phaser.Physics.Arcade.World#collideGroupVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group1 - [description] + * @param {Phaser.GameObjects.Group} group2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (group1.length === 0 || group2.length === 0) + { + return; + } + + var children = group1.getChildren(); + + for (var i = 0; i < children.length; i++) + { + this.collideSpriteVsGroup(children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly); + } + }, + + /** + * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. + * + * If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior). + * + * @method Phaser.Physics.Arcade.World#wrap + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects. + * @param {number} [padding=0] - An amount added to each boundary edge during the operation. + */ + wrap: function (object, padding) + { + if (object.body) + { + this.wrapObject(object, padding); + } + else if (object.getChildren) + { + this.wrapArray(object.getChildren(), padding); + } + else if (Array.isArray(object)) + { + this.wrapArray(object, padding); + } + else + { + this.wrapObject(object, padding); + } + }, + + + /** + * Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapArray + * @since 3.3.0 + * + * @param {Array.<*>} objects - An array of objects to be wrapped. + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapArray: function (objects, padding) + { + for (var i = 0; i < objects.length; i++) + { + this.wrapObject(objects[i], padding); + } + }, + + /** + * Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapObject + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Physics Body, or any object with `x` and `y` coordinates + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapObject: function (object, padding) + { + if (padding === undefined) { padding = 0; } + + object.x = Wrap(object.x, this.bounds.left - padding, this.bounds.right + padding); + object.y = Wrap(object.y, this.bounds.top - padding, this.bounds.bottom + padding); + }, + + /** + * Shuts down the simulation, clearing physics data and removing listeners. + * + * @method Phaser.Physics.Arcade.World#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.tree.clear(); + this.staticTree.clear(); + this.bodies.clear(); + this.staticBodies.clear(); + this.colliders.destroy(); + + this.removeAllListeners(); + }, + + /** + * Shuts down the simulation and disconnects it from the current scene. + * + * @method Phaser.Physics.Arcade.World#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.scene = null; + } + +}); + +module.exports = World; + + +/***/ }), +/* 262 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeSprite = __webpack_require__(114); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(39); +var Group = __webpack_require__(97); +var IsPlainObject = __webpack_require__(8); + +/** + * @classdesc + * An Arcade Physics Static Group object. + * + * All Game Objects created by this Group will automatically be given static Arcade Physics bodies. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Group}. + * + * @class StaticGroup + * @extends Phaser.GameObjects.Group + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The physics simulation. + * @param {Phaser.Scene} scene - The scene this group belongs to. + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. + */ +var StaticPhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function StaticPhysicsGroup (world, scene, children, config) + { + if (!children && !config) + { + config = { + createCallback: this.createCallbackHandler, + removeCallback: this.removeCallbackHandler, + createMultipleCallback: this.createMultipleCallbackHandler, + classType: ArcadeSprite + }; + } + else if (IsPlainObject(children)) + { + // children is a plain object, so swizzle them: + config = children; + children = null; + + config.createCallback = this.createCallbackHandler; + config.removeCallback = this.removeCallbackHandler; + config.createMultipleCallback = this.createMultipleCallbackHandler; + config.classType = ArcadeSprite; + } + else if (Array.isArray(children) && IsPlainObject(children[0])) + { + // children is an array of plain objects + config = children; + children = null; + + config.forEach(function (singleConfig) + { + singleConfig.createCallback = this.createCallbackHandler; + singleConfig.removeCallback = this.removeCallbackHandler; + singleConfig.createMultipleCallback = this.createMultipleCallbackHandler; + singleConfig.classType = ArcadeSprite; + }); + } + + /** + * The physics simulation. + * + * @name Phaser.Physics.Arcade.StaticGroup#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * The scene this group belongs to. + * + * @name Phaser.Physics.Arcade.StaticGroup#physicsType + * @type {integer} + * @default STATIC_BODY + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; + + Group.call(this, scene, children, config); + }, + + /** + * Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation. + * + * @method Phaser.Physics.Arcade.StaticGroup#createCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The new group member. + * + * @see Phaser.Physics.Arcade.World#enableBody + */ + createCallbackHandler: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.STATIC_BODY); + } + }, + + /** + * Disables the group member's physics body, removing it from the simulation. + * + * @method Phaser.Physics.Arcade.StaticGroup#removeCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The group member being removed. + * + * @see Phaser.Physics.Arcade.World#disableBody + */ + removeCallbackHandler: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * Refreshes the group. + * + * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} entries - The newly created group members. + * + * @see Phaser.Physics.Arcade.StaticGroup#refresh + */ + createMultipleCallbackHandler: function () + { + this.refresh(); + }, + + /** + * Resets each Body to the position of its parent Game Object. + * Body sizes aren't changed (use {@link Phaser.Physics.Arcade.Components.Enable#refreshBody} for that). + * + * @method Phaser.Physics.Arcade.StaticGroup#refresh + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticGroup} This group. + * + * @see Phaser.Physics.Arcade.StaticBody#reset + */ + refresh: function () + { + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + children[i].body.reset(); + } + + return this; + } + +}); + +module.exports = StaticPhysicsGroup; + + +/***/ }), +/* 263 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeSprite = __webpack_require__(114); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(39); +var GetFastValue = __webpack_require__(1); +var Group = __webpack_require__(97); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} PhysicsGroupConfig + * @extends GroupConfig + * + * @property {boolean} [collideWorldBounds=false] - Sets {@link Phaser.Physics.Arcade.Body#collideWorldBounds}. + * @property {number} [accelerationX=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.x}. + * @property {number} [accelerationY=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.y}. + * @property {boolean} [allowDrag=true] - Sets {@link Phaser.Physics.Arcade.Body#allowDrag}. + * @property {boolean} [allowGravity=true] - Sets {@link Phaser.Physics.Arcade.Body#allowGravity}. + * @property {boolean} [allowRotation=true] - Sets {@link Phaser.Physics.Arcade.Body#allowRotation}. + * @property {number} [bounceX=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.x}. + * @property {number} [bounceY=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.y}. + * @property {number} [dragX=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.x}. + * @property {number} [dragY=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.y}. + * @property {boolean} [enable=true] - Sets {@link Phaser.Physics.Arcade.Body#enable enable}. + * @property {number} [gravityX=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.x}. + * @property {number} [gravityY=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.y}. + * @property {number} [frictionX=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.x}. + * @property {number} [frictionY=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.y}. + * @property {number} [velocityX=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.x}. + * @property {number} [velocityY=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.y}. + * @property {number} [angularVelocity=0] - Sets {@link Phaser.Physics.Arcade.Body#angularVelocity}. + * @property {number} [angularAcceleration=0] - Sets {@link Phaser.Physics.Arcade.Body#angularAcceleration}. + * @property {number} [angularDrag=0] - Sets {@link Phaser.Physics.Arcade.Body#angularDrag}. + * @property {number} [mass=0] - Sets {@link Phaser.Physics.Arcade.Body#mass}. + * @property {boolean} [immovable=false] - Sets {@link Phaser.Physics.Arcade.Body#immovable}. + */ + +/** + * @typedef {object} PhysicsGroupDefaults + * + * @property {boolean} setCollideWorldBounds - As {@link Phaser.Physics.Arcade.Body#setCollideWorldBounds}. + * @property {number} setAccelerationX - As {@link Phaser.Physics.Arcade.Body#setAccelerationX}. + * @property {number} setAccelerationY - As {@link Phaser.Physics.Arcade.Body#setAccelerationY}. + * @property {boolean} setAllowDrag - As {@link Phaser.Physics.Arcade.Body#setAllowDrag}. + * @property {boolean} setAllowGravity - As {@link Phaser.Physics.Arcade.Body#setAllowGravity}. + * @property {boolean} setAllowRotation - As {@link Phaser.Physics.Arcade.Body#setAllowRotation}. + * @property {number} setBounceX - As {@link Phaser.Physics.Arcade.Body#setBounceX}. + * @property {number} setBounceY - As {@link Phaser.Physics.Arcade.Body#setBounceY}. + * @property {number} setDragX - As {@link Phaser.Physics.Arcade.Body#setDragX}. + * @property {number} setDragY - As {@link Phaser.Physics.Arcade.Body#setDragY}. + * @property {boolean} setEnable - As {@link Phaser.Physics.Arcade.Body#setEnable}. + * @property {number} setGravityX - As {@link Phaser.Physics.Arcade.Body#setGravityX}. + * @property {number} setGravityY - As {@link Phaser.Physics.Arcade.Body#setGravityY}. + * @property {number} setFrictionX - As {@link Phaser.Physics.Arcade.Body#setFrictionX}. + * @property {number} setFrictionY - As {@link Phaser.Physics.Arcade.Body#setFrictionY}. + * @property {number} setVelocityX - As {@link Phaser.Physics.Arcade.Body#setVelocityX}. + * @property {number} setVelocityY - As {@link Phaser.Physics.Arcade.Body#setVelocityY}. + * @property {number} setAngularVelocity - As {@link Phaser.Physics.Arcade.Body#setAngularVelocity}. + * @property {number} setAngularAcceleration - As {@link Phaser.Physics.Arcade.Body#setAngularAcceleration}. + * @property {number} setAngularDrag - As {@link Phaser.Physics.Arcade.Body#setAngularDrag}. + * @property {number} setMass - As {@link Phaser.Physics.Arcade.Body#setMass}. + * @property {boolean} setImmovable - As {@link Phaser.Physics.Arcade.Body#setImmovable}. + */ + +/** + * @classdesc + * An Arcade Physics Group object. + * + * All Game Objects created by this Group will automatically be given dynamic Arcade Physics bodies. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticGroup}. + * + * @class Group + * @extends Phaser.GameObjects.Group + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The physics simulation. + * @param {Phaser.Scene} scene - The scene this group belongs to. + * @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group. + */ +var PhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function PhysicsGroup (world, scene, children, config) + { + if (!children && !config) + { + config = { + createCallback: this.createCallbackHandler, + removeCallback: this.removeCallbackHandler + }; + } + else if (IsPlainObject(children)) + { + // children is a plain object, so swizzle them: + config = children; + children = null; + + config.createCallback = this.createCallbackHandler; + config.removeCallback = this.removeCallbackHandler; + } + else if (Array.isArray(children) && IsPlainObject(children[0])) + { + // children is an array of plain objects + config = children; + children = null; + + config.forEach(function (singleConfig) + { + singleConfig.createCallback = this.createCallbackHandler; + singleConfig.removeCallback = this.removeCallbackHandler; + }); + } + + /** + * The physics simulation. + * + * @name Phaser.Physics.Arcade.Group#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * The class to create new group members from. + * This should be ArcadeImage, ArcadeSprite, or a class extending one of those. + * + * @name Phaser.Physics.Arcade.Group#classType + * @type {(Phaser.Physics.Arcade.Image|Phaser.Physics.Arcade.Sprite)} + * @default ArcadeSprite + */ + config.classType = GetFastValue(config, 'classType', ArcadeSprite); + + /** + * The physics type of the Group's members. + * + * @name Phaser.Physics.Arcade.Group#physicsType + * @type {integer} + * @default DYNAMIC_BODY + * @since 3.0.0 + */ + this.physicsType = CONST.DYNAMIC_BODY; + + /** + * Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument. + * + * @name Phaser.Physics.Arcade.Group#defaults + * @type {PhysicsGroupDefaults} + * @since 3.0.0 + */ + this.defaults = { + setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false), + setAccelerationX: GetFastValue(config, 'accelerationX', 0), + setAccelerationY: GetFastValue(config, 'accelerationY', 0), + setAllowDrag: GetFastValue(config, 'allowDrag', true), + setAllowGravity: GetFastValue(config, 'allowGravity', true), + setAllowRotation: GetFastValue(config, 'allowRotation', true), + setBounceX: GetFastValue(config, 'bounceX', 0), + setBounceY: GetFastValue(config, 'bounceY', 0), + setDragX: GetFastValue(config, 'dragX', 0), + setDragY: GetFastValue(config, 'dragY', 0), + setEnable: GetFastValue(config, 'enable', true), + setGravityX: GetFastValue(config, 'gravityX', 0), + setGravityY: GetFastValue(config, 'gravityY', 0), + setFrictionX: GetFastValue(config, 'frictionX', 0), + setFrictionY: GetFastValue(config, 'frictionY', 0), + setVelocityX: GetFastValue(config, 'velocityX', 0), + setVelocityY: GetFastValue(config, 'velocityY', 0), + setAngularVelocity: GetFastValue(config, 'angularVelocity', 0), + setAngularAcceleration: GetFastValue(config, 'angularAcceleration', 0), + setAngularDrag: GetFastValue(config, 'angularDrag', 0), + setMass: GetFastValue(config, 'mass', 1), + setImmovable: GetFastValue(config, 'immovable', false) + }; + + Group.call(this, scene, children, config); + }, + + /** + * Enables a Game Object's Body and assigns `defaults`. Called when a Group member is added or created. + * + * @method Phaser.Physics.Arcade.Group#createCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object being added. + */ + createCallbackHandler: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.DYNAMIC_BODY); + } + + var body = child.body; + + for (var key in this.defaults) + { + body[key](this.defaults[key]); + } + }, + + /** + * Disables a Game Object's Body. Called when a Group member is removed. + * + * @method Phaser.Physics.Arcade.Group#removeCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object being removed. + */ + removeCallbackHandler: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * Sets the velocity of each Group member. + * + * @method Phaser.Physics.Arcade.Group#setVelocity + * @since 3.0.0 + * + * @param {number} x - The horizontal velocity. + * @param {number} y - The vertical velocity. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x, y), the second (x + step, y + step), and so on. + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocity: function (x, y, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.set(x + (i * step), y + (i * step)); + } + + return this; + }, + + /** + * Sets the horizontal velocity of each Group member. + * + * @method Phaser.Physics.Arcade.Group#setVelocityX + * @since 3.0.0 + * + * @param {number} value - The velocity value. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x), the second (x + step), and so on. + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityX: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.x = value + (i * step); + } + + return this; + }, + + /** + * Sets the vertical velocity of each Group member. + * + * @method Phaser.Physics.Arcade.Group#setVelocityY + * @since 3.0.0 + * + * @param {number} value - The velocity value. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (y), the second (y + step), and so on. + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityY: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.y = value + (i * step); + } + + return this; + } + +}); + +module.exports = PhysicsGroup; + + +/***/ }), +/* 264 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Arcade.Components + */ + +module.exports = { + + Acceleration: __webpack_require__(592), + Angular: __webpack_require__(591), + Bounce: __webpack_require__(590), + Debug: __webpack_require__(589), + Drag: __webpack_require__(588), + Enable: __webpack_require__(587), + Friction: __webpack_require__(586), + Gravity: __webpack_require__(585), + Immovable: __webpack_require__(584), + Mass: __webpack_require__(583), + Size: __webpack_require__(582), + Velocity: __webpack_require__(581) + +}; + + +/***/ }), +/* 265 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(264); +var Image = __webpack_require__(78); + +/** + * @classdesc + * An Arcade Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.Image + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeImage = new Class({ + + Extends: Image, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeImage (scene, x, y, texture, frame) + { + Image.call(this, scene, x, y, texture, frame); + + /** + * This Game Object's Physics Body. + * + * @name Phaser.Physics.Arcade.Image#body + * @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} + * @default null + * @since 3.0.0 + */ + this.body = null; + } + +}); + +module.exports = ArcadeImage; + + +/***/ }), +/* 266 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeImage = __webpack_require__(265); +var ArcadeSprite = __webpack_require__(114); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(39); +var PhysicsGroup = __webpack_require__(263); +var StaticPhysicsGroup = __webpack_require__(262); + +/** + * @classdesc + * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. + * Objects that are created by this Factory are automatically added to the physics world. + * + * @class Factory + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics World instance. + */ +var Factory = new Class({ + + initialize: + + function Factory (world) + { + /** + * A reference to the Arcade Physics World. + * + * @name Phaser.Physics.Arcade.Factory#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * A reference to the Scene this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = world.scene; + + /** + * A reference to the Scene.Systems this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = world.scene.sys; + }, + + /** + * Create a new Arcade Physics Collider object. + * + * @method Phaser.Physics.Arcade.Factory#collider + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for collision. + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + collider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addCollider(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Create a new Arcade Physics Collider Overlap object. + * + * @method Phaser.Physics.Arcade.Factory#overlap + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for overlap. + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + overlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addOverlap(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Adds an Arcade Physics Body to the given Game Object. + * + * @method Phaser.Physics.Arcade.Factory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - A Game Object. + * @param {boolean} [isStatic=false] - Create a Static body (true) or Dynamic body (false). + * + * @return {Phaser.GameObjects.GameObject} The Game Object. + */ + existing: function (gameObject, isStatic) + { + var type = (isStatic) ? CONST.STATIC_BODY : CONST.DYNAMIC_BODY; + + this.world.enableBody(gameObject, type); + + return gameObject; + }, + + /** + * Creates a new Arcade Image object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticImage + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + staticImage: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.STATIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Image object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + image: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.DYNAMIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Sprite object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + staticSprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.STATIC_BODY); + + return sprite; + }, + + /** + * Creates a new Arcade Sprite object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + sprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.DYNAMIC_BODY); + + return sprite; + }, + + /** + * Creates a Static Physics Group object. + * All Game Objects created by this Group will automatically be static Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#staticGroup + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. + * + * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. + */ + staticGroup: function (children, config) + { + return this.sys.updateList.add(new StaticPhysicsGroup(this.world, this.world.scene, children, config)); + }, + + /** + * Creates a Physics Group object. + * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#group + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group. + * + * @return {Phaser.Physics.Arcade.Group} The Group object that was created. + */ + 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; + } + +}); + +module.exports = Factory; + + +/***/ }), +/* 267 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(154); +var Matrix3 = __webpack_require__(269); + +var EPSILON = 0.000001; + +// Some shared 'private' arrays +var siNext = new Int8Array([ 1, 2, 0 ]); +var tmp = new Float32Array([ 0, 0, 0 ]); + +var xUnitVec3 = new Vector3(1, 0, 0); +var yUnitVec3 = new Vector3(0, 1, 0); + +var tmpvec = new Vector3(); +var tmpMat3 = new Matrix3(); + +/** + * @classdesc + * A quaternion. + * + * @class Quaternion + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + * @param {number} [w] - The w component. + */ +var Quaternion = new Class({ + + initialize: + + function Quaternion (x, y, z, w) + { + /** + * The x component of this Quaternion. + * + * @name Phaser.Math.Quaternion#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The y component of this Quaternion. + * + * @name Phaser.Math.Quaternion#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The z component of this Quaternion. + * + * @name Phaser.Math.Quaternion#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The w component of this Quaternion. + * + * @name Phaser.Math.Quaternion#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * Copy the components of a given Quaternion or Vector into this Quaternion. + * + * @method Phaser.Math.Quaternion#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} src - The Quaternion or Vector to copy the components from. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z; + this.w = src.w; + + return this; + }, + + /** + * Set the components of this Quaternion. + * + * @method Phaser.Math.Quaternion#set + * @since 3.0.0 + * + * @param {(number|object)} [x=0] - The x component, or an object containing x, y, z, and w components. + * @param {number} [y=0] - The y component. + * @param {number} [z=0] - The z component. + * @param {number} [w=0] - The w component. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * Add a given Quaternion or Vector to this Quaternion. Addition is component-wise. + * + * @method Phaser.Math.Quaternion#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to add to this Quaternion. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z; + this.w += v.w; + + return this; + }, + + /** + * Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise. + * + * @method Phaser.Math.Quaternion#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to subtract from this Quaternion. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + this.w -= v.w; + + return this; + }, + + /** + * Scale this Quaternion by the given value. + * + * @method Phaser.Math.Quaternion#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Quaternion by. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * Calculate the length of this Quaternion. + * + * @method Phaser.Math.Quaternion#length + * @since 3.0.0 + * + * @return {number} The length of this Quaternion. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * Calculate the length of this Quaternion squared. + * + * @method Phaser.Math.Quaternion#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Quaternion, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * Normalize this Quaternion. + * + * @method Phaser.Math.Quaternion#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Quaternion and the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#dot + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to dot product with this Quaternion. + * + * @return {number} The dot product of this Quaternion and the given Quaternion or Vector. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * Linearly interpolate this Quaternion towards the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#lerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to interpolate towards. + * @param {number} [t=0] - The percentage of interpolation. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotationTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - [description] + * @param {Phaser.Math.Vector3} b - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotationTo: function (a, b) + { + var dot = a.x * b.x + a.y * b.y + a.z * b.z; + + if (dot < -0.999999) + { + if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) + { + tmpvec.copy(yUnitVec3).cross(a); + } + + tmpvec.normalize(); + + return this.setAxisAngle(tmpvec, Math.PI); + + } + else if (dot > 0.999999) + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + } + else + { + tmpvec.copy(a).cross(b); + + this.x = tmpvec.x; + this.y = tmpvec.y; + this.z = tmpvec.z; + this.w = 1 + dot; + + return this.normalize(); + } + }, + + /** + * Set the axes of this Quaternion. + * + * @method Phaser.Math.Quaternion#setAxes + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} view - The view axis. + * @param {Phaser.Math.Vector3} right - The right axis. + * @param {Phaser.Math.Vector3} up - The upwards axis. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + setAxes: function (view, right, up) + { + var m = tmpMat3.val; + + m[0] = right.x; + m[3] = right.y; + m[6] = right.z; + + m[1] = up.x; + m[4] = up.y; + m[7] = up.z; + + m[2] = -view.x; + m[5] = -view.y; + m[8] = -view.z; + + return this.fromMat3(tmpMat3).normalize(); + }, + + /** + * Reset this Matrix to an identity (default) Quaternion. + * + * @method Phaser.Math.Quaternion#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + identity: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + }, + + /** + * Set the axis angle of this Quaternion. + * + * @method Phaser.Math.Quaternion#setAxisAngle + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} axis - The axis. + * @param {number} rad - The angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + setAxisAngle: function (axis, rad) + { + rad = rad * 0.5; + + var s = Math.sin(rad); + + this.x = s * axis.x; + this.y = s * axis.y; + this.z = s * axis.z; + this.w = Math.cos(rad); + + return this; + }, + + /** + * Multiply this Quaternion by the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to multiply this Quaternion by. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + multiply: function (b) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + this.x = ax * bw + aw * bx + ay * bz - az * by; + this.y = ay * bw + aw * by + az * bx - ax * bz; + this.z = az * bw + aw * bz + ax * by - ay * bx; + this.w = aw * bw - ax * bx - ay * by - az * bz; + + return this; + }, + + /** + * Smoothly linearly interpolate this Quaternion towards the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#slerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to interpolate towards. + * @param {number} t - The percentage of interpolation. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + slerp: function (b, t) + { + // benchmarks: http://jsperf.com/quaternion-slerp-implementations + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + // calc cosine + var cosom = ax * bx + ay * by + az * bz + aw * bw; + + // adjust signs (if necessary) + if (cosom < 0) + { + cosom = -cosom; + bx = - bx; + by = - by; + bz = - bz; + bw = - bw; + } + + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + var scale0 = 1 - t; + var scale1 = t; + + // calculate coefficients + if ((1 - cosom) > EPSILON) + { + // standard case (slerp) + var omega = Math.acos(cosom); + var sinom = Math.sin(omega); + + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } + + // calculate final values + this.x = scale0 * ax + scale1 * bx; + this.y = scale0 * ay + scale1 * by; + this.z = scale0 * az + scale1 * bz; + this.w = scale0 * aw + scale1 * bw; + + return this; + }, + + /** + * Invert this Quaternion. + * + * @method Phaser.Math.Quaternion#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + invert: function () + { + var a0 = this.x; + var a1 = this.y; + var a2 = this.z; + var a3 = this.w; + + var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + var invDot = (dot) ? 1 / dot : 0; + + // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + + this.x = -a0 * invDot; + this.y = -a1 * invDot; + this.z = -a2 * invDot; + this.w = a3 * invDot; + + return this; + }, + + /** + * Convert this Quaternion into its conjugate. + * + * Sets the x, y and z components. + * + * @method Phaser.Math.Quaternion#conjugate + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + conjugate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * Rotate this Quaternion on the X axis. + * + * @method Phaser.Math.Quaternion#rotateX + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateX: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + aw * bx; + this.y = ay * bw + az * bx; + this.z = az * bw - ay * bx; + this.w = aw * bw - ax * bx; + + return this; + }, + + /** + * Rotate this Quaternion on the Y axis. + * + * @method Phaser.Math.Quaternion#rotateY + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateY: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var by = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw - az * by; + this.y = ay * bw + aw * by; + this.z = az * bw + ax * by; + this.w = aw * bw - ay * by; + + return this; + }, + + /** + * Rotate this Quaternion on the Z axis. + * + * @method Phaser.Math.Quaternion#rotateZ + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateZ: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bz = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + ay * bz; + this.y = ay * bw - ax * bz; + this.z = az * bw + aw * bz; + this.w = aw * bw - az * bz; + + return this; + }, + + /** + * Create a unit (or rotation) Quaternion from its x, y, and z components. + * + * Sets the w component. + * + * @method Phaser.Math.Quaternion#calculateW + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + calculateW: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + this.w = -Math.sqrt(1.0 - x * x - y * y - z * z); + + return this; + }, + + /** + * Convert the given Matrix into this Quaternion. + * + * @method Phaser.Math.Quaternion#fromMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix to convert from. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + fromMat3: function (mat) + { + // benchmarks: + // http://jsperf.com/typed-array-access-speed + // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion + + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + var m = mat.val; + var fTrace = m[0] + m[4] + m[8]; + var fRoot; + + if (fTrace > 0) + { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + + this.w = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; // 1/(4w) + + this.x = (m[7] - m[5]) * fRoot; + this.y = (m[2] - m[6]) * fRoot; + this.z = (m[3] - m[1]) * fRoot; + } + else + { + // |w| <= 1/2 + var i = 0; + + if (m[4] > m[0]) + { + i = 1; + } + + if (m[8] > m[i * 3 + i]) + { + i = 2; + } + + var j = siNext[i]; + var k = siNext[j]; + + // This isn't quite as clean without array access + fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); + tmp[i] = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; + + tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; + tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; + + this.x = tmp[0]; + this.y = tmp[1]; + this.z = tmp[2]; + this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; + } + + return this; + } + +}); + +module.exports = Quaternion; + + +/***/ }), +/* 268 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +var EPSILON = 0.000001; + +/** + * @classdesc + * A four-dimensional matrix. + * + * @class Matrix4 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} [m] - Optional Matrix4 to copy values from. + */ +var Matrix4 = new Class({ + + initialize: + + function Matrix4 (m) + { + /** + * The matrix values. + * + * @name Phaser.Math.Matrix4#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(16); + + if (m) + { + // Assume Matrix4 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * Make a clone of this Matrix4. + * + * @method Phaser.Math.Matrix4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} A clone of this Matrix4. + */ + clone: function () + { + return new Matrix4(this); + }, + + // TODO - Should work with basic values + + /** + * This method is an alias for `Matrix4.copy`. + * + * @method Phaser.Math.Matrix4#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to set the values of this Matrix's from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * Copy the values of a given Matrix into this Matrix. + * + * @method Phaser.Math.Matrix4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Set the values of this Matrix from the given array. + * + * @method Phaser.Math.Matrix4#fromArray + * @since 3.0.0 + * + * @param {array} a - The array to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Reset this Matrix. + * + * Sets all values to `0`. + * + * @method Phaser.Math.Matrix4#zero + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + zero: function () + { + var out = this.val; + + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 0; + + return this; + }, + + /** + * Set the `x`, `y` and `z` values of this Matrix. + * + * @method Phaser.Math.Matrix4#xyz + * @since 3.0.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * @param {number} z - The z value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + xyz: function (x, y, z) + { + this.identity(); + + var out = this.val; + + out[12] = x; + out[13] = y; + out[14] = z; + + return this; + }, + + /** + * Set the scaling values of this Matrix. + * + * @method Phaser.Math.Matrix4#scaling + * @since 3.0.0 + * + * @param {number} x - The x scaling value. + * @param {number} y - The y scaling value. + * @param {number} z - The z scaling value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scaling: function (x, y, z) + { + this.zero(); + + var out = this.val; + + out[0] = x; + out[5] = y; + out[10] = z; + out[15] = 1; + + return this; + }, + + /** + * Reset this Matrix to an identity (default) matrix. + * + * @method Phaser.Math.Matrix4#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Transpose this Matrix. + * + * @method Phaser.Math.Matrix4#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + transpose: function () + { + var a = this.val; + + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a12 = a[6]; + var a13 = a[7]; + var a23 = a[11]; + + a[1] = a[4]; + a[2] = a[8]; + a[3] = a[12]; + a[4] = a01; + a[6] = a[9]; + a[7] = a[13]; + a[8] = a02; + a[9] = a12; + a[11] = a[14]; + a[12] = a03; + a[13] = a13; + a[14] = a23; + + return this; + }, + + /** + * Invert this Matrix. + * + * @method Phaser.Math.Matrix4#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return this; + }, + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + * + * @method Phaser.Math.Matrix4#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); + a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); + a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); + a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); + a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); + a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); + a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); + a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); + + return this; + }, + + /** + * Calculate the determinant of this Matrix. + * + * @method Phaser.Math.Matrix4#determinant + * @since 3.0.0 + * + * @return {number} The determinant of this Matrix. + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * @method Phaser.Math.Matrix4#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to multiply this Matrix by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b = src.val; + + // Cache only the current line of the second matrix + var b0 = b[0]; + var b1 = b[1]; + var b2 = b[2]; + var b3 = b[3]; + + a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + + a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + + a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + + a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#multiplyLocal + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiplyLocal: function (src) + { + var a = []; + var m1 = this.val; + var m2 = src.val; + + a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; + a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; + a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; + a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; + + a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; + a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; + a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; + a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; + + a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; + a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; + a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; + a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; + + a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; + a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; + a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; + a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; + + return this.fromArray(a); + }, + + /** + * Translate this Matrix using the given Vector. + * + * @method Phaser.Math.Matrix4#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + translate: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix. + * + * @method Phaser.Math.Matrix4#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scale: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[0] = a[0] * x; + a[1] = a[1] * x; + a[2] = a[2] * x; + a[3] = a[3] * x; + + a[4] = a[4] * y; + a[5] = a[5] * y; + a[6] = a[6] * y; + a[7] = a[7] * y; + + a[8] = a[8] * z; + a[9] = a[9] * z; + a[10] = a[10] * z; + a[11] = a[11] * z; + + return this; + }, + + /** + * Derive a rotation matrix around the given axis. + * + * @method Phaser.Math.Matrix4#makeRotationAxis + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis. + * @param {number} angle - The rotation angle in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + makeRotationAxis: function (axis, angle) + { + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + var c = Math.cos(angle); + var s = Math.sin(angle); + var t = 1 - c; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var tx = t * x; + var ty = t * y; + + this.fromArray([ + tx * x + c, tx * y - s * z, tx * z + s * y, 0, + tx * y + s * z, ty * y + c, ty * z - s * x, 0, + tx * z - s * y, ty * z + s * x, t * z * z + c, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + /** + * Apply a rotation transformation to this Matrix. + * + * @method Phaser.Math.Matrix4#rotate + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * @param {Phaser.Math.Vector3} axis - The axis to rotate upon. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotate: function (rad, axis) + { + var a = this.val; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var len = Math.sqrt(x * x + y * y + z * z); + + if (Math.abs(len) < EPSILON) + { + return null; + } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + var s = Math.sin(rad); + var c = Math.cos(rad); + var t = 1 - c; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Construct the elements of the rotation matrix + var b00 = x * x * t + c; + var b01 = y * x * t + z * s; + var b02 = z * x * t - y * s; + + var b10 = x * y * t - z * s; + var b11 = y * y * t + c; + var b12 = z * y * t + x * s; + + var b20 = x * z * t + y * s; + var b21 = y * z * t - x * s; + var b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + a[0] = a00 * b00 + a10 * b01 + a20 * b02; + a[1] = a01 * b00 + a11 * b01 + a21 * b02; + a[2] = a02 * b00 + a12 * b01 + a22 * b02; + a[3] = a03 * b00 + a13 * b01 + a23 * b02; + a[4] = a00 * b10 + a10 * b11 + a20 * b12; + a[5] = a01 * b10 + a11 * b11 + a21 * b12; + a[6] = a02 * b10 + a12 * b11 + a22 * b12; + a[7] = a03 * b10 + a13 * b11 + a23 * b12; + a[8] = a00 * b20 + a10 * b21 + a20 * b22; + a[9] = a01 * b20 + a11 * b21 + a21 * b22; + a[10] = a02 * b20 + a12 * b21 + a22 * b22; + a[11] = a03 * b20 + a13 * b21 + a23 * b22; + + return this; + }, + + /** + * Rotate this matrix on its X axis. + * + * @method Phaser.Math.Matrix4#rotateX + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateX: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[4] = a10 * c + a20 * s; + a[5] = a11 * c + a21 * s; + a[6] = a12 * c + a22 * s; + a[7] = a13 * c + a23 * s; + a[8] = a20 * c - a10 * s; + a[9] = a21 * c - a11 * s; + a[10] = a22 * c - a12 * s; + a[11] = a23 * c - a13 * s; + + return this; + }, + + /** + * Rotate this matrix on its Y axis. + * + * @method Phaser.Math.Matrix4#rotateY + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateY: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c - a20 * s; + a[1] = a01 * c - a21 * s; + a[2] = a02 * c - a22 * s; + a[3] = a03 * c - a23 * s; + a[8] = a00 * s + a20 * c; + a[9] = a01 * s + a21 * c; + a[10] = a02 * s + a22 * c; + a[11] = a03 * s + a23 * c; + + return this; + }, + + /** + * Rotate this matrix on its Z axis. + * + * @method Phaser.Math.Matrix4#rotateZ + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateZ: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c + a10 * s; + a[1] = a01 * c + a11 * s; + a[2] = a02 * c + a12 * s; + a[3] = a03 * c + a13 * s; + a[4] = a10 * c - a00 * s; + a[5] = a11 * c - a01 * s; + a[6] = a12 * c - a02 * s; + a[7] = a13 * c - a03 * s; + + return this; + }, + + /** + * Set the values of this Matrix from the given rotation Quaternion and translation Vector. + * + * @method Phaser.Math.Matrix4#fromRotationTranslation + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set rotation from. + * @param {Phaser.Math.Vector3} v - The Vector to set translation from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromRotationTranslation: function (q, v) + { + // Quaternion math + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = v.x; + out[13] = v.y; + out[14] = v.z; + out[15] = 1; + + return this; + }, + + /** + * Set the values of this Matrix from the given Quaternion. + * + * @method Phaser.Math.Matrix4#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromQuat: function (q) + { + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Generate a frustum matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#frustum + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + frustum: function (left, right, bottom, top, near, far) + { + var out = this.val; + + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + + out[0] = (near * 2) * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (near * 2) * tb; + out[6] = 0; + out[7] = 0; + + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (far * near * 2) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspective + * @since 3.0.0 + * + * @param {number} fovy - Vertical field of view in radians + * @param {number} aspect - Aspect ratio. Typically viewport width /height. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspective: function (fovy, aspect, near, far) + { + var out = this.val; + var f = 1.0 / Math.tan(fovy / 2); + var nf = 1 / (near - far); + + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspectiveLH + * @since 3.0.0 + * + * @param {number} width - The width of the frustum. + * @param {number} height - The height of the frustum. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspectiveLH: function (width, height, near, far) + { + var out = this.val; + + out[0] = (2 * near) / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (2 * near) / height; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = -far / (near - far); + out[11] = 1; + + out[12] = 0; + out[13] = 0; + out[14] = (near * far) / (near - far); + out[15] = 0; + + return this; + }, + + /** + * Generate an orthogonal projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#ortho + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + ortho: function (left, right, bottom, top, near, far) + { + var out = this.val; + var lr = left - right; + var bt = bottom - top; + var nf = near - far; + + // Avoid division by zero + lr = (lr === 0) ? lr : 1 / lr; + bt = (bt === 0) ? bt : 1 / bt; + nf = (nf === 0) ? nf : 1 / nf; + + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; + + return this; + }, + + /** + * Generate a look-at matrix with the given eye position, focal point, and up axis. + * + * @method Phaser.Math.Matrix4#lookAt + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} eye - Position of the viewer + * @param {Phaser.Math.Vector3} center - Point the viewer is looking at + * @param {Phaser.Math.Vector3} up - vec3 pointing up. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + lookAt: function (eye, center, up) + { + var out = this.val; + + var eyex = eye.x; + var eyey = eye.y; + var eyez = eye.z; + + var upx = up.x; + var upy = up.y; + var upz = up.z; + + var centerx = center.x; + var centery = center.y; + var centerz = center.z; + + if (Math.abs(eyex - centerx) < EPSILON && + Math.abs(eyey - centery) < EPSILON && + Math.abs(eyez - centerz) < EPSILON) + { + return this.identity(); + } + + var z0 = eyex - centerx; + var z1 = eyey - centery; + var z2 = eyez - centerz; + + var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + + z0 *= len; + z1 *= len; + z2 *= len; + + var x0 = upy * z2 - upz * z1; + var x1 = upz * z0 - upx * z2; + var x2 = upx * z1 - upy * z0; + + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + + if (!len) + { + x0 = 0; + x1 = 0; + x2 = 0; + } + else + { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + var y0 = z1 * x2 - z2 * x1; + var y1 = z2 * x0 - z0 * x2; + var y2 = z0 * x1 - z1 * x0; + + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + + if (!len) + { + y0 = 0; + y1 = 0; + y2 = 0; + } + else + { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + + return this; + }, + + /** + * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values. + * + * @method Phaser.Math.Matrix4#yawPitchRoll + * @since 3.0.0 + * + * @param {number} yaw - [description] + * @param {number} pitch - [description] + * @param {number} roll - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + yawPitchRoll: function (yaw, pitch, roll) + { + this.zero(); + _tempMat1.zero(); + _tempMat2.zero(); + + var m0 = this.val; + var m1 = _tempMat1.val; + var m2 = _tempMat2.val; + + // Rotate Z + var s = Math.sin(roll); + var c = Math.cos(roll); + + m0[10] = 1; + m0[15] = 1; + m0[0] = c; + m0[1] = s; + m0[4] = -s; + m0[5] = c; + + // Rotate X + s = Math.sin(pitch); + c = Math.cos(pitch); + + m1[0] = 1; + m1[15] = 1; + m1[5] = c; + m1[10] = c; + m1[9] = -s; + m1[6] = s; + + // Rotate Y + s = Math.sin(yaw); + c = Math.cos(yaw); + + m2[5] = 1; + m2[15] = 1; + m2[0] = c; + m2[2] = -s; + m2[8] = s; + m2[10] = c; + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + return this; + }, + + /** + * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix. + * + * @method Phaser.Math.Matrix4#setWorldMatrix + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} rotation - The rotation of the world matrix. + * @param {Phaser.Math.Vector3} position - The position of the world matrix. + * @param {Phaser.Math.Vector3} scale - The scale of the world matrix. + * @param {Phaser.Math.Matrix4} [viewMatrix] - The view matrix. + * @param {Phaser.Math.Matrix4} [projectionMatrix] - The projection matrix. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) + { + this.yawPitchRoll(rotation.y, rotation.x, rotation.z); + + _tempMat1.scaling(scale.x, scale.y, scale.z); + _tempMat2.xyz(position.x, position.y, position.z); + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + if (viewMatrix !== undefined) + { + this.multiplyLocal(viewMatrix); + } + + if (projectionMatrix !== undefined) + { + this.multiplyLocal(projectionMatrix); + } + + return this; + } + +}); + +var _tempMat1 = new Matrix4(); +var _tempMat2 = new Matrix4(); + +module.exports = Matrix4; + + +/***/ }), +/* 269 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A three-dimensional matrix. + * + * Defaults to the identity matrix when instantiated. + * + * @class Matrix3 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} [m] - Optional Matrix3 to copy values from. + */ +var Matrix3 = new Class({ + + initialize: + + function Matrix3 (m) + { + /** + * The matrix values. + * + * @name Phaser.Math.Matrix3#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(9); + + if (m) + { + // Assume Matrix3 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * Make a clone of this Matrix3. + * + * @method Phaser.Math.Matrix3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} A clone of this Matrix3. + */ + clone: function () + { + return new Matrix3(this); + }, + + /** + * This method is an alias for `Matrix3.copy`. + * + * @method Phaser.Math.Matrix3#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to set the values of this Matrix's from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * Copy the values of a given Matrix into this Matrix. + * + * @method Phaser.Math.Matrix3#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * Copy the values of a given Matrix4 into this Matrix3. + * + * @method Phaser.Math.Matrix3#fromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - The Matrix4 to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromMat4: function (m) + { + var a = m.val; + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; + + return this; + }, + + /** + * Set the values of this Matrix from the given array. + * + * @method Phaser.Math.Matrix3#fromArray + * @since 3.0.0 + * + * @param {array} a - The array to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * Reset this Matrix to an identity (default) matrix. + * + * @method Phaser.Math.Matrix3#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + + return this; + }, + + /** + * Transpose this Matrix. + * + * @method Phaser.Math.Matrix3#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + transpose: function () + { + var a = this.val; + var a01 = a[1]; + var a02 = a[2]; + var a12 = a[5]; + + a[1] = a[3]; + a[2] = a[6]; + a[3] = a01; + a[5] = a[7]; + a[6] = a02; + a[7] = a12; + + return this; + }, + + /** + * Invert this Matrix. + * + * @method Phaser.Math.Matrix3#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b01 = a22 * a11 - a12 * a21; + var b11 = -a22 * a10 + a12 * a20; + var b21 = a21 * a10 - a11 * a20; + + // Calculate the determinant + var det = a00 * b01 + a01 * b11 + a02 * b21; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = b01 * det; + a[1] = (-a22 * a01 + a02 * a21) * det; + a[2] = (a12 * a01 - a02 * a11) * det; + a[3] = b11 * det; + a[4] = (a22 * a00 - a02 * a20) * det; + a[5] = (-a12 * a00 + a02 * a10) * det; + a[6] = b21 * det; + a[7] = (-a21 * a00 + a01 * a20) * det; + a[8] = (a11 * a00 - a01 * a10) * det; + + return this; + }, + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + * + * @method Phaser.Math.Matrix3#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + a[0] = (a11 * a22 - a12 * a21); + a[1] = (a02 * a21 - a01 * a22); + a[2] = (a01 * a12 - a02 * a11); + a[3] = (a12 * a20 - a10 * a22); + a[4] = (a00 * a22 - a02 * a20); + a[5] = (a02 * a10 - a00 * a12); + a[6] = (a10 * a21 - a11 * a20); + a[7] = (a01 * a20 - a00 * a21); + a[8] = (a00 * a11 - a01 * a10); + + return this; + }, + + /** + * Calculate the determinant of this Matrix. + * + * @method Phaser.Math.Matrix3#determinant + * @since 3.0.0 + * + * @return {number} The determinant of this Matrix. + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * @method Phaser.Math.Matrix3#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to multiply this Matrix by. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b = src.val; + + var b00 = b[0]; + var b01 = b[1]; + var b02 = b[2]; + var b10 = b[3]; + var b11 = b[4]; + var b12 = b[5]; + var b20 = b[6]; + var b21 = b[7]; + var b22 = b[8]; + + a[0] = b00 * a00 + b01 * a10 + b02 * a20; + a[1] = b00 * a01 + b01 * a11 + b02 * a21; + a[2] = b00 * a02 + b01 * a12 + b02 * a22; + + a[3] = b10 * a00 + b11 * a10 + b12 * a20; + a[4] = b10 * a01 + b11 * a11 + b12 * a21; + a[5] = b10 * a02 + b11 * a12 + b12 * a22; + + a[6] = b20 * a00 + b21 * a10 + b22 * a20; + a[7] = b20 * a01 + b21 * a11 + b22 * a21; + a[8] = b20 * a02 + b21 * a12 + b22 * a22; + + return this; + }, + + /** + * Translate this Matrix using the given Vector. + * + * @method Phaser.Math.Matrix3#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + translate: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[6] = x * a[0] + y * a[3] + a[6]; + a[7] = x * a[1] + y * a[4] + a[7]; + a[8] = x * a[2] + y * a[5] + a[8]; + + return this; + }, + + /** + * Apply a rotation transformation to this Matrix. + * + * @method Phaser.Math.Matrix3#rotate + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + rotate: function (rad) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + + var s = Math.sin(rad); + var c = Math.cos(rad); + + a[0] = c * a00 + s * a10; + a[1] = c * a01 + s * a11; + a[2] = c * a02 + s * a12; + + a[3] = c * a10 - s * a00; + a[4] = c * a11 - s * a01; + a[5] = c * a12 - s * a02; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x` and `y` components of the given Vector to scale the Matrix. + * + * @method Phaser.Math.Matrix3#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + scale: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[0] = x * a[0]; + a[1] = x * a[1]; + a[2] = x * a[2]; + + a[3] = y * a[3]; + a[4] = y * a[4]; + a[5] = y * a[5]; + + return this; + }, + + /** + * Set the values of this Matrix from the given Quaternion. + * + * @method Phaser.Math.Matrix3#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromQuat: function (q) + { + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + var out = this.val; + + out[0] = 1 - (yy + zz); + out[3] = xy + wz; + out[6] = xz - wy; + + out[1] = xy - wz; + out[4] = 1 - (xx + zz); + out[7] = yz + wx; + + out[2] = xz + wy; + out[5] = yz - wx; + out[8] = 1 - (xx + yy); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#normalFromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + normalFromMat4: function (m) + { + var a = m.val; + var out = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + + return this; + } + +}); + +module.exports = Matrix3; + + +/***/ }), +/* 270 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rotate a given point by a given angle around the origin (0, 0), in an anti-clockwise direction. + * + * @function Phaser.Math.Rotate + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. + * @param {number} angle - The angle to be rotated by in an anticlockwise direction. + * + * @return {Phaser.Geom.Point} The given point, rotated by the given angle in an anticlockwise direction. + */ +var Rotate = function (point, angle) +{ + var x = point.x; + var y = point.y; + + point.x = (x * Math.cos(angle)) - (y * Math.sin(angle)); + point.y = (x * Math.sin(angle)) + (y * Math.cos(angle)); + + return point; +}; + +module.exports = Rotate; + + +/***/ }), +/* 271 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Snap a value to nearest grid slice, using ceil. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `15`. + * As will `14` snap to `15`... but `16` will snap to `20`. + * + * @function Phaser.Math.Snap.Ceil + * @since 3.0.0 + * + * @param {number} value - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. + * + * @return {number} The snapped value. + */ +var SnapCeil = function (value, gap, start, divide) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.ceil(value / gap); + + return (divide) ? (start + value) / gap : start + value; +}; + +module.exports = SnapCeil; + + +/***/ }), +/* 272 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the factorial of a given number for integer values greater than 0. + * + * @function Phaser.Math.Factorial + * @since 3.0.0 + * + * @param {number} value - A positive integer to calculate the factorial of. + * + * @return {number} The factorial of the given number. + */ +var Factorial = function (value) +{ + if (value === 0) + { + return 1; + } + + var res = value; + + while (--value) + { + res *= value; + } + + return res; +}; + +module.exports = Factorial; + + +/***/ }), +/* 273 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Factorial = __webpack_require__(272); + +/** + * [description] + * + * @function Phaser.Math.Bernstein + * @since 3.0.0 + * + * @param {number} n - [description] + * @param {number} i - [description] + * + * @return {number} [description] + */ +var Bernstein = function (n, i) +{ + return Factorial(n) / Factorial(i) / Factorial(n - i); +}; + +module.exports = Bernstein; + + +/***/ }), +/* 274 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check whether `a` is fuzzily less than `b`. + * + * `a` is fuzzily less than `b` if it is less than `b + epsilon`. + * + * @function Phaser.Math.Fuzzy.LessThan + * @since 3.0.0 + * + * @param {number} a - The first value. + * @param {number} b - The second value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {boolean} `true` if `a` is fuzzily less than `b`, otherwise `false`. + */ +var LessThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a < b + epsilon; +}; + +module.exports = LessThan; + + +/***/ }), +/* 275 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check whether `a` is fuzzily greater than `b`. + * + * `a` is fuzzily greater than `b` if it is more than `b - epsilon`. + * + * @function Phaser.Math.Fuzzy.GreaterThan + * @since 3.0.0 + * + * @param {number} a - The first value. + * @param {number} b - The second value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {boolean} `true` if `a` is fuzzily greater than than `b`, otherwise `false`. + */ +var GreaterThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a > b - epsilon; +}; + +module.exports = GreaterThan; + + +/***/ }), +/* 276 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check whether the given values are fuzzily equal. + * + * Two numbers are fuzzily equal if their difference is less than `epsilon`. + * + * @function Phaser.Math.Fuzzy.Equal + * @since 3.0.0 + * + * @param {number} a - The first value. + * @param {number} b - The second value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {boolean} `true` if the values are fuzzily equal, otherwise `false`. + */ +var Equal = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.abs(a - b) < epsilon; +}; + +module.exports = Equal; + + +/***/ }), +/* 277 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the distance between two sets of coordinates (points), squared. + * + * @function Phaser.Math.Distance.Squared + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The distance between each point, squared. + */ +var DistanceSquared = function (x1, y1, x2, y2) +{ + var dx = x1 - x2; + var dy = y1 - y2; + + return dx * dx + dy * dy; +}; + +module.exports = DistanceSquared; + + +/***/ }), +/* 278 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Normalize an angle to the [0, 2pi] range. + * + * @function Phaser.Math.Angle.Normalize + * @since 3.0.0 + * + * @param {number} angle - The angle to normalize, in radians. + * + * @return {number} The normalized angle, in radians. + */ +var Normalize = function (angle) +{ + angle = angle % (2 * Math.PI); + + if (angle >= 0) + { + return angle; + } + else + { + return angle + 2 * Math.PI; + } +}; + +module.exports = Normalize; + + +/***/ }), +/* 279 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TextFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='txt'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Text File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. + * + * @class TextFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TextFile = new Class({ + + Extends: File, + + initialize: + + function TextFile (loader, key, url, xhrSettings) + { + var extension = 'txt'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'text', + cache: loader.cacheManager.text, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.TextFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Text file, or array of Text files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.text('story', 'files/IntroStory.txt'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Text Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Text Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.text({ + * key: 'story', + * url: 'files/IntroStory.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.text('story', 'files/IntroStory.txt'); + * // and later in your game ... + * var data = this.cache.text.get('story'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Text Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.txt". It will always add `.txt` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Text File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#text + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig|Phaser.Loader.FileTypes.TextFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('text', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TextFile(this, key[i])); + } + } + else + { + this.addFile(new TextFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TextFile; + + +/***/ }), +/* 280 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var File = __webpack_require__(22); +var GetFastValue = __webpack_require__(1); +var GetURL = __webpack_require__(157); +var IsPlainObject = __webpack_require__(8); + +/** + * @classdesc + * A single Audio File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. + * + * @class HTML5AudioFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.AudioFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [urlConfig] - The absolute or relative URL to load this file from. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var HTML5AudioFile = new Class({ + + Extends: File, + + initialize: + + function HTML5AudioFile (loader, key, urlConfig, audioConfig) + { + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + audioConfig = GetFastValue(config, 'config', audioConfig); + } + + var fileConfig = { + type: 'audio', + cache: loader.cacheManager.audio, + extension: urlConfig.type, + key: key, + url: urlConfig.url, + config: audioConfig + }; + + File.call(this, loader, fileConfig); + + // New properties specific to this class + this.locked = 'ontouchstart' in window; + this.loaded = false; + this.filesLoaded = 0; + this.filesTotal = 0; + }, + + /** + * Called when the file finishes loading. + * + * @method Phaser.Loader.FileTypes.HTML5AudioFile#onLoad + * @since 3.0.0 + */ + onLoad: function () + { + if (this.loaded) + { + return; + } + + this.loaded = true; + + this.loader.nextFile(this, true); + }, + + /** + * Called if the file errors while loading. + * + * @method Phaser.Loader.FileTypes.HTML5AudioFile#onError + * @since 3.0.0 + */ + onError: function () + { + for (var i = 0; i < this.data.length; i++) + { + var audio = this.data[i]; + + audio.oncanplaythrough = null; + audio.onerror = null; + } + + this.loader.nextFile(this, false); + }, + + /** + * Called during the file load progress. Is sent a DOM ProgressEvent. + * + * @method Phaser.Loader.FileTypes.HTML5AudioFile#onProgress + * @since 3.0.0 + */ + onProgress: function (event) + { + var audio = event.target; + + audio.oncanplaythrough = null; + audio.onerror = null; + + this.filesLoaded++; + + this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1); + + this.loader.emit('fileprogress', this, this.percentComplete); + + if (this.filesLoaded === this.filesTotal) + { + this.onLoad(); + } + }, + + /** + * Called by the Loader, starts the actual file downloading. + * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. + * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + * + * @method Phaser.Loader.FileTypes.HTML5AudioFile#load + * @since 3.0.0 + */ + load: function () + { + this.data = []; + + var instances = (this.config && this.config.instances) || 1; + + this.filesTotal = instances; + this.filesLoaded = 0; + this.percentComplete = 0; + + for (var i = 0; i < instances; i++) + { + var audio = new Audio(); + + audio.dataset.name = this.key + ('0' + i).slice(-2); + audio.dataset.used = 'false'; + + 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); + } + + this.data.push(audio); + } + + for (i = 0; i < this.data.length; i++) + { + audio = this.data[i]; + audio.src = GetURL(this, this.loader.baseURL); + + if (!this.locked) + { + audio.load(); + } + } + + if (this.locked) + { + // This is super-dangerous but works. Race condition potential high. + // Is there another way? + setTimeout(this.onLoad.bind(this)); + } + } + +}); + +module.exports = HTML5AudioFile; + + +/***/ }), +/* 281 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(28); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var HTML5AudioFile = __webpack_require__(280); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.AudioFileConfig + * + * @property {string} key - The key of the file. Must be unique within the Loader and Audio Cache. + * @property {string} [urlConfig] - The absolute or relative URL to load the file from. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {AudioContext} [audioContext] - The AudioContext this file will use to process itself. + */ + +/** + * @classdesc + * A single Audio File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audio method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audio. + * + * @class AudioFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.AudioFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {any} [urlConfig] - The absolute or relative URL to load this file from in a config object. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {AudioContext} [audioContext] - The AudioContext this file will use to process itself. + */ +var AudioFile = new Class({ + + Extends: File, + + initialize: + + // URL is an object created by AudioFile.findAudioURL + function AudioFile (loader, key, urlConfig, xhrSettings, audioContext) + { + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + audioContext = GetFastValue(config, 'context', audioContext); + } + + var fileConfig = { + type: 'audio', + cache: loader.cacheManager.audio, + extension: urlConfig.type, + responseType: 'arraybuffer', + key: key, + url: urlConfig.url, + xhrSettings: xhrSettings, + config: { context: audioContext } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.AudioFile#onProcess + * @since 3.0.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var _this = this; + + // interesting read https://github.com/WebAudio/web-audio-api/issues/1305 + this.config.context.decodeAudioData(this.xhrLoader.response, + function (audioBuffer) + { + _this.data = audioBuffer; + + _this.onProcessComplete(); + }, + function (e) + { + // eslint-disable-next-line no-console + console.error('Error decoding audio: ' + this.key + ' - ', e ? e.message : null); + + _this.onProcessError(); + } + ); + + this.config.context = null; + } + +}); + +AudioFile.create = function (loader, key, urls, config, xhrSettings) +{ + var game = loader.systems.game; + var audioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + // url may be inside key, which may be an object + if (IsPlainObject(key)) + { + urls = GetFastValue(key, 'url', []); + config = GetFastValue(key, 'config', {}); + } + + var urlConfig = AudioFile.getAudioURL(game, urls); + + if (!urlConfig) + { + return null; + } + + // https://developers.google.com/web/updates/2012/02/HTML5-audio-and-the-Web-Audio-API-are-BFFs + // var stream = GetFastValue(config, 'stream', false); + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + return new AudioFile(loader, key, urlConfig, xhrSettings, game.sound.context); + } + else + { + return new HTML5AudioFile(loader, key, urlConfig, config); + } +}; + +AudioFile.getAudioURL = function (game, urls) +{ + if (!Array.isArray(urls)) + { + urls = [ urls ]; + } + + for (var i = 0; i < urls.length; i++) + { + var url = GetFastValue(urls[i], 'url', urls[i]); + + if (url.indexOf('blob:') === 0 || url.indexOf('data:') === 0) + { + return url; + } + + var audioType = url.match(/\.([a-zA-Z0-9]+)($|\?)/); + + audioType = GetFastValue(urls[i], 'type', (audioType) ? audioType[1] : '').toLowerCase(); + + if (game.device.audio[audioType]) + { + return { + url: url, + type: audioType + }; + } + } + + return null; +}; + +/** + * Adds an Audio or HTML5Audio file, or array of audio files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.audio('title', [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ]); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Audio Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Audio Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.audio({ + * key: 'title', + * url: [ 'music/Title.ogg', 'music/Title.mp3', 'music/Title.m4a' ] + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AudioFileConfig` for more details. + * + * The URLs can be relative or absolute. If the URLs are relative the `Loader.baseURL` and `Loader.path` values will be prepended to them. + * + * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. + * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on + * browser support. + * + * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. + * + * Note: The ability to load this type of file will only be available if the Audio File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#audio + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.AudioFileConfig|Phaser.Loader.FileTypes.AudioFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {(string|string[])} [urls] - The absolute or relative URL to load the audio files from. + * @param {any} [config] - An object containing an `instances` property for HTML5Audio. Defaults to 1. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('audio', function (key, urls, config, xhrSettings) +{ + var game = this.systems.game; + var audioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + // Sounds are disabled, so skip loading audio + return this; + } + + var audioFile; + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + audioFile = AudioFile.create(this, key[i]); + + if (audioFile) + { + this.addFile(audioFile); + } + } + } + else + { + audioFile = AudioFile.create(this, key, urls, config, xhrSettings); + + if (audioFile) + { + this.addFile(audioFile); + } + } + + return this; +}); + +module.exports = AudioFile; + + +/***/ }), +/* 282 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MergeXHRSettings = __webpack_require__(156); + +/** + * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings + * and starts the download of it. It uses the Files own XHRSettings and merges them + * with the global XHRSettings object to set the xhr values before download. + * + * @function Phaser.Loader.XHRLoader + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File to download. + * @param {XHRSettingsObject} globalXHRSettings - The global XHRSettings object. + * + * @return {XMLHttpRequest} The XHR object. + */ +var XHRLoader = function (file, globalXHRSettings) +{ + var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings); + + var xhr = new XMLHttpRequest(); + + xhr.open('GET', file.src, config.async, config.user, config.password); + + xhr.responseType = file.xhrSettings.responseType; + xhr.timeout = config.timeout; + + if (config.header && config.headerValue) + { + xhr.setRequestHeader(config.header, config.headerValue); + } + + if (config.requestedWith) + { + xhr.setRequestHeader('X-Requested-With', config.requestedWith); + } + + if (config.overrideMimeType) + { + xhr.overrideMimeType(config.overrideMimeType); + } + + // After a successful request, the xhr.response property will contain the requested data as a DOMString, ArrayBuffer, Blob, or Document (depending on what was set for responseType.) + + xhr.onload = file.onLoad.bind(file, xhr); + xhr.onerror = file.onError.bind(file); + xhr.onprogress = file.onProgress.bind(file); + + // This is the only standard method, the ones above are browser additions (maybe not universal?) + // xhr.onreadystatechange + + xhr.send(); + + return xhr; +}; + +module.exports = XHRLoader; + + +/***/ }), +/* 283 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(1); +var ProcessKeyCombo = __webpack_require__(672); +var ResetKeyCombo = __webpack_require__(670); + +/** + * @callback KeyboardKeydownCallback + * + * @param {KeyboardEvent} event - The Keyboard Event. + */ + +/** + * @typedef {object} KeyComboConfig + * + * @property {boolean} [resetOnWrongKey=true] - If they press the wrong key do we reset the combo? + * @property {number} [maxKeyDelay=0] - The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. + * @property {boolean} [resetOnMatch=false] - If previously matched and they press the first key of the combo again, will it reset? + * @property {boolean} [deleteOnMatch=false] - If the combo matches, will it delete itself? + */ + +/** + * @classdesc + * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them + * it will emit a `keycombomatch` event from the Keyboard Manager. + * + * The keys to be listened for can be defined as: + * + * A string (i.e. 'ATARI') + * An array of either integers (key codes) or strings, or a mixture of both + * An array of objects (such as Key objects) with a public 'keyCode' property + * + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) + * you could pass the following array of key codes: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + * + * Or, to listen for the user entering the word PHASER: + * + * ```javascript + * this.input.keyboard.createCombo('PHASER'); + * ``` + * + * @class KeyCombo + * @memberof Phaser.Input.Keyboard + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.KeyboardPlugin} keyboardPlugin - A reference to the Keyboard Plugin. + * @param {(string|integer[]|object[])} keys - The keys that comprise this combo. + * @param {KeyComboConfig} [config] - A Key Combo configuration object. + */ +var KeyCombo = new Class({ + + initialize: + + function KeyCombo (keyboardPlugin, keys, config) + { + if (config === undefined) { config = {}; } + + // Can't have a zero or single length combo (string or array based) + if (keys.length < 2) + { + return false; + } + + /** + * A reference to the Keyboard Manager + * + * @name Phaser.Input.Keyboard.KeyCombo#manager + * @type {Phaser.Input.Keyboard.KeyboardPlugin} + * @since 3.0.0 + */ + this.manager = keyboardPlugin; + + /** + * A flag that controls if this Key Combo is actively processing keys or not. + * + * @name Phaser.Input.Keyboard.KeyCombo#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * An array of the keycodes that comprise this combo. + * + * @name Phaser.Input.Keyboard.KeyCombo#keyCodes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.keyCodes = []; + + // if 'keys' is a string we need to get the keycode of each character in it + + for (var i = 0; i < keys.length; i++) + { + var char = keys[i]; + + if (typeof char === 'string') + { + this.keyCodes.push(char.toUpperCase().charCodeAt(0)); + } + else if (typeof char === 'number') + { + this.keyCodes.push(char); + } + else if (char.hasOwnProperty('keyCode')) + { + this.keyCodes.push(char.keyCode); + } + } + + /** + * The current keyCode the combo is waiting for. + * + * @name Phaser.Input.Keyboard.KeyCombo#current + * @type {integer} + * @since 3.0.0 + */ + this.current = this.keyCodes[0]; + + /** + * The current index of the key being waited for in the 'keys' string. + * + * @name Phaser.Input.Keyboard.KeyCombo#index + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.index = 0; + + /** + * The length of this combo (in keycodes) + * + * @name Phaser.Input.Keyboard.KeyCombo#size + * @type {number} + * @since 3.0.0 + */ + this.size = this.keyCodes.length; + + /** + * The time the previous key in the combo was matched. + * + * @name Phaser.Input.Keyboard.KeyCombo#timeLastMatched + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeLastMatched = 0; + + /** + * Has this Key Combo been matched yet? + * + * @name Phaser.Input.Keyboard.KeyCombo#matched + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.matched = false; + + /** + * The time the entire combo was matched. + * + * @name Phaser.Input.Keyboard.KeyCombo#timeMatched + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeMatched = 0; + + /** + * If they press the wrong key do we reset the combo? + * + * @name Phaser.Input.Keyboard.KeyCombo#resetOnWrongKey + * @type {boolean} + * @default 0 + * @since 3.0.0 + */ + this.resetOnWrongKey = GetFastValue(config, 'resetOnWrongKey', true); + + /** + * The max delay in ms between each key press. Above this the combo is reset. 0 means disabled. + * + * @name Phaser.Input.Keyboard.KeyCombo#maxKeyDelay + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.maxKeyDelay = GetFastValue(config, 'maxKeyDelay', 0); + + /** + * If previously matched and they press the first key of the combo again, will it reset? + * + * @name Phaser.Input.Keyboard.KeyCombo#resetOnMatch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.resetOnMatch = GetFastValue(config, 'resetOnMatch', false); + + /** + * If the combo matches, will it delete itself? + * + * @name Phaser.Input.Keyboard.KeyCombo#deleteOnMatch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.deleteOnMatch = GetFastValue(config, 'deleteOnMatch', false); + + var _this = this; + + var onKeyDownHandler = function (event) + { + if (_this.matched || !_this.enabled) + { + return; + } + + var matched = ProcessKeyCombo(event, _this); + + if (matched) + { + _this.manager.emit('keycombomatch', _this, event); + + if (_this.resetOnMatch) + { + ResetKeyCombo(_this); + } + else if (_this.deleteOnMatch) + { + _this.destroy(); + } + } + }; + + /** + * The internal Key Down handler. + * + * @name Phaser.Input.Keyboard.KeyCombo#onKeyDown + * @private + * @type {KeyboardKeydownCallback} + * @since 3.0.0 + */ + this.onKeyDown = onKeyDownHandler; + + this.manager.on('keydown', onKeyDownHandler); + }, + + /** + * How far complete is this combo? A value between 0 and 1. + * + * @name Phaser.Input.Keyboard.KeyCombo#progress + * @type {number} + * @readonly + * @since 3.0.0 + */ + progress: { + + get: function () + { + return this.index / this.size; + } + + }, + + /** + * Destroys this Key Combo and all of its references. + * + * @method Phaser.Input.Keyboard.KeyCombo#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enabled = false; + this.keyCodes = []; + + this.manager.off('keydown', this.onKeyDown); + + this.manager = null; + } + +}); + +module.exports = KeyCombo; + + +/***/ }), +/* 284 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A generic Key object which can be passed to the Process functions (and so on) + * keycode must be an integer + * + * @class Key + * @memberof Phaser.Input.Keyboard + * @constructor + * @since 3.0.0 + * + * @param {integer} keyCode - The keycode of this key. + */ +var Key = new Class({ + + initialize: + + function Key (keyCode) + { + /** + * The keycode of this key. + * + * @name Phaser.Input.Keyboard.Key#keyCode + * @type {integer} + * @since 3.0.0 + */ + this.keyCode = keyCode; + + /** + * The original DOM event. + * + * @name Phaser.Input.Keyboard.Key#originalEvent + * @type {KeyboardEvent} + * @since 3.0.0 + */ + this.originalEvent = undefined; + + /** + * Should this Key prevent event propagation? + * + * @name Phaser.Input.Keyboard.Key#preventDefault + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.preventDefault = true; + + /** + * Can this Key be processed? + * + * @name Phaser.Input.Keyboard.Key#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * The "down" state of the key. This will remain `true` for as long as the keyboard thinks this key is held down. + * + * @name Phaser.Input.Keyboard.Key#isDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isDown = false; + + /** + * The "up" state of the key. This will remain `true` for as long as the keyboard thinks this key is up. + * + * @name Phaser.Input.Keyboard.Key#isUp + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.isUp = true; + + /** + * The down state of the ALT key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#altKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.altKey = false; + + /** + * The down state of the CTRL key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#ctrlKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.ctrlKey = false; + + /** + * The down state of the SHIFT key, if pressed at the same time as this key. + * + * @name Phaser.Input.Keyboard.Key#shiftKey + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shiftKey = false; + + /** + * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. + * + * @name Phaser.Input.Keyboard.Key#location + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.location = 0; + + /** + * The timestamp when the key was last pressed down. + * + * @name Phaser.Input.Keyboard.Key#timeDown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeDown = 0; + + /** + * The number of milliseconds this key was held down for in the previous down - up sequence. + * + * @name Phaser.Input.Keyboard.Key#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * The timestamp when the key was last released. + * + * @name Phaser.Input.Keyboard.Key#timeUp + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.timeUp = 0; + + /** + * If a key is held down this holds down the number of times the key has 'repeated'. + * + * @name Phaser.Input.Keyboard.Key#repeats + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeats = 0; + + /** + * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) + * + * @name Phaser.Input.Keyboard.Key#_justDown + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._justDown = false; + + /** + * True if the key has just been pressed (NOTE: requires to be reset, see justDown getter) + * + * @name Phaser.Input.Keyboard.Key#_justUp + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._justUp = false; + + /** + * Internal tick counter. + * + * @name Phaser.Input.Keyboard.Key#_tick + * @type {number} + * @private + * @since 3.11.0 + */ + this._tick = -1; + }, + + /** + * Resets this Key object back to its default un-pressed state. + * + * @method Phaser.Input.Keyboard.Key.reset + * @since 3.6.0 + * + * @return {Phaser.Input.Keyboard.Key} This Key instance. + */ + reset: function () + { + this.preventDefault = true; + this.enabled = true; + this.isDown = false; + this.isUp = true; + this.altKey = false; + this.ctrlKey = false; + this.shiftKey = false; + this.timeDown = 0; + this.duration = 0; + this.timeUp = 0; + this.repeats = 0; + this._justDown = false; + this._justUp = false; + this._tick = -1; + + return this; + } + +}); + +module.exports = Key; + + +/***/ }), +/* 285 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Axis = __webpack_require__(287); +var Button = __webpack_require__(286); +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A single Gamepad. + * + * These are created, updated and managed by the Gamepad Plugin. + * + * @class Gamepad + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input.Gamepad + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad.GamepadPlugin} manager - A reference to the Gamepad Plugin. + * @param {Pad} pad - The Gamepad object, as extracted from GamepadEvent. + */ +var Gamepad = new Class({ + + Extends: EventEmitter, + + initialize: + + function Gamepad (manager, pad) + { + EventEmitter.call(this); + + /** + * A reference to the Gamepad Plugin. + * + * @name Phaser.Input.Gamepad.Gamepad#manager + * @type {Phaser.Input.Gamepad.GamepadPlugin} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * A reference to the native Gamepad object that is connected to the browser. + * + * @name Phaser.Input.Gamepad.Gamepad#pad + * @type {any} + * @since 3.10.0 + */ + this.pad = pad; + + /** + * A string containing some information about the controller. + * + * This is not strictly specified, but in Firefox it will contain three pieces of information + * separated by dashes (-): two 4-digit hexadecimal strings containing the USB vendor and + * product id of the controller, and the name of the controller as provided by the driver. + * In Chrome it will contain the name of the controller as provided by the driver, + * followed by vendor and product 4-digit hexadecimal strings. + * + * @name Phaser.Input.Gamepad.Gamepad#id + * @type {string} + * @since 3.0.0 + */ + this.id = pad.id; + + /** + * An integer that is unique for each Gamepad currently connected to the system. + * This can be used to distinguish multiple controllers. + * Note that disconnecting a device and then connecting a new device may reuse the previous index. + * + * @name Phaser.Input.Gamepad.Gamepad#index + * @type {number} + * @since 3.0.0 + */ + this.index = pad.index; + + var buttons = []; + + for (var i = 0; i < pad.buttons.length; i++) + { + buttons.push(new Button(this, i)); + } + + /** + * An array of Gamepad Button objects, corresponding to the different buttons available on the Gamepad. + * + * @name Phaser.Input.Gamepad.Gamepad#buttons + * @type {Phaser.Input.Gamepad.Button[]} + * @since 3.0.0 + */ + this.buttons = buttons; + + var axes = []; + + for (i = 0; i < pad.axes.length; i++) + { + axes.push(new Axis(this, i)); + } + + /** + * An array of Gamepad Axis objects, corresponding to the different axes available on the Gamepad, if any. + * + * @name Phaser.Input.Gamepad.Gamepad#axes + * @type {Phaser.Input.Gamepad.Axis[]} + * @since 3.0.0 + */ + this.axes = axes; + + /** + * The Gamepad's Haptic Actuator (Vibration / Rumble support). + * This is highly experimental and only set if both present on the device, + * and exposed by both the hardware and browser. + * + * @name Phaser.Input.Gamepad.Gamepad#vibration + * @type {GamepadHapticActuator} + * @since 3.10.0 + */ + this.vibration = pad.vibrationActuator; + + // https://w3c.github.io/gamepad/#remapping + + var _noButton = { value: 0, pressed: false }; + + /** + * A reference to the Left Button in the Left Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_LCLeft + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._LCLeft = (buttons[14]) ? buttons[14] : _noButton; + + /** + * A reference to the Right Button in the Left Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_LCRight + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._LCRight = (buttons[15]) ? buttons[15] : _noButton; + + /** + * A reference to the Top Button in the Left Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_LCTop + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._LCTop = (buttons[12]) ? buttons[12] : _noButton; + + /** + * A reference to the Bottom Button in the Left Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_LCBottom + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._LCBottom = (buttons[13]) ? buttons[13] : _noButton; + + /** + * A reference to the Left Button in the Right Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_RCLeft + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._RCLeft = (buttons[2]) ? buttons[2] : _noButton; + + /** + * A reference to the Right Button in the Right Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_RCRight + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._RCRight = (buttons[1]) ? buttons[1] : _noButton; + + /** + * A reference to the Top Button in the Right Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_RCTop + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._RCTop = (buttons[3]) ? buttons[3] : _noButton; + + /** + * A reference to the Bottom Button in the Right Cluster. + * + * @name Phaser.Input.Gamepad.Gamepad#_RCBottom + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._RCBottom = (buttons[0]) ? buttons[0] : _noButton; + + /** + * A reference to the Top Left Front Button (L1 Shoulder Button) + * + * @name Phaser.Input.Gamepad.Gamepad#_FBLeftTop + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._FBLeftTop = (buttons[4]) ? buttons[4] : _noButton; + + /** + * A reference to the Bottom Left Front Button (L2 Shoulder Button) + * + * @name Phaser.Input.Gamepad.Gamepad#_FBLeftBottom + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._FBLeftBottom = (buttons[6]) ? buttons[6] : _noButton; + + /** + * A reference to the Top Right Front Button (R1 Shoulder Button) + * + * @name Phaser.Input.Gamepad.Gamepad#_FBRightTop + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._FBRightTop = (buttons[5]) ? buttons[5] : _noButton; + + /** + * A reference to the Bottom Right Front Button (R2 Shoulder Button) + * + * @name Phaser.Input.Gamepad.Gamepad#_FBRightBottom + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._FBRightBottom = (buttons[7]) ? buttons[7] : _noButton; + + var _noAxis = { value: 0 }; + + /** + * A reference to the Horizontal Axis for the Left Stick. + * + * @name Phaser.Input.Gamepad.Gamepad#_HAxisLeft + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._HAxisLeft = (axes[0]) ? axes[0] : _noAxis; + + /** + * A reference to the Vertical Axis for the Left Stick. + * + * @name Phaser.Input.Gamepad.Gamepad#_VAxisLeft + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._VAxisLeft = (axes[1]) ? axes[1] : _noAxis; + + /** + * A reference to the Horizontal Axis for the Right Stick. + * + * @name Phaser.Input.Gamepad.Gamepad#_HAxisRight + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._HAxisRight = (axes[2]) ? axes[2] : _noAxis; + + /** + * A reference to the Vertical Axis for the Right Stick. + * + * @name Phaser.Input.Gamepad.Gamepad#_VAxisRight + * @type {Phaser.Input.Gamepad.Button} + * @private + * @since 3.10.0 + */ + this._VAxisRight = (axes[3]) ? axes[3] : _noAxis; + + /** + * A Vector2 containing the most recent values from the Gamepad's left axis stick. + * This is updated automatically as part of the Gamepad.update cycle. + * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. + * The values are based on the Axis thresholds. + * If the Gamepad does not have a left axis stick, the values will always be zero. + * + * @name Phaser.Input.Gamepad.Gamepad#leftStick + * @type {Phaser.Math.Vector2} + * @since 3.10.0 + */ + this.leftStick = new Vector2(); + + /** + * A Vector2 containing the most recent values from the Gamepad's right axis stick. + * This is updated automatically as part of the Gamepad.update cycle. + * The H Axis is mapped to the `Vector2.x` property, and the V Axis to the `Vector2.y` property. + * The values are based on the Axis thresholds. + * If the Gamepad does not have a right axis stick, the values will always be zero. + * + * @name Phaser.Input.Gamepad.Gamepad#rightStick + * @type {Phaser.Math.Vector2} + * @since 3.10.0 + */ + this.rightStick = new Vector2(); + }, + + /** + * Gets the total number of axis this Gamepad claims to support. + * + * @method Phaser.Input.Gamepad.Gamepad#getAxisTotal + * @since 3.10.0 + * + * @return {integer} The total number of axes this Gamepad claims to support. + */ + getAxisTotal: function () + { + return this.axes.length; + }, + + /** + * Gets the value of an axis based on the given index. + * The index must be valid within the range of axes supported by this Gamepad. + * The return value will be a float between 0 and 1. + * + * @method Phaser.Input.Gamepad.Gamepad#getAxisValue + * @since 3.10.0 + * + * @param {integer} index - The index of the axes to get the value for. + * + * @return {number} The value of the axis, between 0 and 1. + */ + getAxisValue: function (index) + { + return this.axes[index].getValue(); + }, + + /** + * Sets the threshold value of all axis on this Gamepad. + * The value is a float between 0 and 1 and is the amount below which the axis is considered as not having been moved. + * + * @method Phaser.Input.Gamepad.Gamepad#setAxisThreshold + * @since 3.10.0 + * + * @param {number} value - A value between 0 and 1. + */ + setAxisThreshold: function (value) + { + for (var i = 0; i < this.axes.length; i++) + { + this.axes[i].threshold = value; + } + }, + + /** + * Gets the total number of buttons this Gamepad claims to have. + * + * @method Phaser.Input.Gamepad.Gamepad#getButtonTotal + * @since 3.10.0 + * + * @return {integer} The total number of buttons this Gamepad claims to have. + */ + getButtonTotal: function () + { + return this.buttons.length; + }, + + /** + * Gets the value of a button based on the given index. + * The index must be valid within the range of buttons supported by this Gamepad. + * + * The return value will be either 0 or 1 for an analogue button, or a float between 0 and 1 + * for a pressure-sensitive digital button, such as the shoulder buttons on a Dual Shock. + * + * @method Phaser.Input.Gamepad.Gamepad#getButtonValue + * @since 3.10.0 + * + * @param {integer} index - The index of the button to get the value for. + * + * @return {number} The value of the button, between 0 and 1. + */ + getButtonValue: function (index) + { + return this.buttons[index].value; + }, + + /** + * Returns if the button is pressed down or not. + * The index must be valid within the range of buttons supported by this Gamepad. + * + * @method Phaser.Input.Gamepad.Gamepad#isButtonDown + * @since 3.10.0 + * + * @param {integer} index - The index of the button to get the value for. + * + * @return {boolean} `true` if the button is considered as being pressed down, otherwise `false`. + */ + isButtonDown: function (index) + { + return this.buttons[index].pressed; + }, + + /** + * Internal update handler for this Gamepad. + * Called automatically by the Gamepad Manager as part of its update. + * + * @method Phaser.Input.Gamepad.Gamepad#update + * @private + * @since 3.0.0 + */ + update: function (pad) + { + var i; + + // Sync the button values + + var localButtons = this.buttons; + var gamepadButtons = pad.buttons; + + var len = localButtons.length; + + for (i = 0; i < len; i++) + { + localButtons[i].update(gamepadButtons[i].value); + } + + // Sync the axis values + + var localAxes = this.axes; + var gamepadAxes = pad.axes; + + len = localAxes.length; + + for (i = 0; i < len; i++) + { + localAxes[i].update(gamepadAxes[i]); + } + + if (len >= 2) + { + this.leftStick.set(localAxes[0].getValue(), localAxes[1].getValue()); + + if (len >= 4) + { + this.rightStick.set(localAxes[2].getValue(), localAxes[3].getValue()); + } + } + }, + + /** + * Destroys this Gamepad instance, its buttons and axes, and releases external references it holds. + * + * @method Phaser.Input.Gamepad.Gamepad#destroy + * @since 3.10.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.manager = null; + this.pad = null; + + var i; + + for (i = 0; i < this.buttons.length; i++) + { + this.buttons[i].destroy(); + } + + for (i = 0; i < this.axes.length; i++) + { + this.axes[i].destroy(); + } + + this.buttons = []; + this.axes = []; + }, + + /** + * Is this Gamepad currently connected or not? + * + * @name Phaser.Input.Gamepad.Gamepad#connected + * @type {boolean} + * @default true + * @since 3.0.0 + */ + connected: { + + get: function () + { + return this.pad.connected; + } + + }, + + /** + * A timestamp containing the most recent time this Gamepad was updated. + * + * @name Phaser.Input.Gamepad.Gamepad#timestamp + * @type {number} + * @since 3.0.0 + */ + timestamp: { + + get: function () + { + return this.pad.timestamp; + } + + }, + + /** + * Is the Gamepad's Left button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad left button under standard Gamepad mapping. + * + * @name Phaser.Input.Gamepad.Gamepad#left + * @type {boolean} + * @since 3.10.0 + */ + left: { + + get: function () + { + return this._LCLeft.pressed; + } + + }, + + /** + * Is the Gamepad's Right button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad right button under standard Gamepad mapping. + * + * @name Phaser.Input.Gamepad.Gamepad#right + * @type {boolean} + * @since 3.10.0 + */ + right: { + + get: function () + { + return this._LCRight.pressed; + } + + }, + + /** + * Is the Gamepad's Up button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad up button under standard Gamepad mapping. + * + * @name Phaser.Input.Gamepad.Gamepad#up + * @type {boolean} + * @since 3.10.0 + */ + up: { + + get: function () + { + return this._LCTop.pressed; + } + + }, + + /** + * Is the Gamepad's Down button being pressed? + * If the Gamepad doesn't have this button it will always return false. + * This is the d-pad down button under standard Gamepad mapping. + * + * @name Phaser.Input.Gamepad.Gamepad#down + * @type {boolean} + * @since 3.10.0 + */ + down: { + + get: function () + { + return this._LCBottom.pressed; + } + + }, + + /** + * Is the Gamepad's bottom button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the X button. + * On an XBox controller it's the A button. + * + * @name Phaser.Input.Gamepad.Gamepad#A + * @type {boolean} + * @since 3.10.0 + */ + A: { + + get: function () + { + return this._RCBottom.pressed; + } + + }, + + /** + * Is the Gamepad's top button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Triangle button. + * On an XBox controller it's the Y button. + * + * @name Phaser.Input.Gamepad.Gamepad#Y + * @type {boolean} + * @since 3.10.0 + */ + Y: { + + get: function () + { + return this._RCTop.pressed; + } + + }, + + /** + * Is the Gamepad's left button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Square button. + * On an XBox controller it's the X button. + * + * @name Phaser.Input.Gamepad.Gamepad#X + * @type {boolean} + * @since 3.10.0 + */ + X: { + + get: function () + { + return this._RCLeft.pressed; + } + + }, + + /** + * Is the Gamepad's right button in the right button cluster being pressed? + * If the Gamepad doesn't have this button it will always return false. + * On a Dual Shock controller it's the Circle button. + * On an XBox controller it's the B button. + * + * @name Phaser.Input.Gamepad.Gamepad#B + * @type {boolean} + * @since 3.10.0 + */ + B: { + + get: function () + { + return this._RCRight.pressed; + } + + }, + + /** + * Returns the value of the Gamepad's top left shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the L1 button. + * On an XBox controller it's the LB button. + * + * @name Phaser.Input.Gamepad.Gamepad#L1 + * @type {number} + * @since 3.10.0 + */ + L1: { + + get: function () + { + return this._FBLeftTop.value; + } + + }, + + /** + * Returns the value of the Gamepad's bottom left shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the L2 button. + * On an XBox controller it's the LT button. + * + * @name Phaser.Input.Gamepad.Gamepad#L2 + * @type {number} + * @since 3.10.0 + */ + L2: { + + get: function () + { + return this._FBLeftBottom.value; + } + + }, + + /** + * Returns the value of the Gamepad's top right shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the R1 button. + * On an XBox controller it's the RB button. + * + * @name Phaser.Input.Gamepad.Gamepad#R1 + * @type {number} + * @since 3.10.0 + */ + R1: { + + get: function () + { + return this._FBRightTop.value; + } + + }, + + /** + * Returns the value of the Gamepad's bottom right shoulder button. + * If the Gamepad doesn't have this button it will always return zero. + * The value is a float between 0 and 1, corresponding to how depressed the button is. + * On a Dual Shock controller it's the R2 button. + * On an XBox controller it's the RT button. + * + * @name Phaser.Input.Gamepad.Gamepad#R2 + * @type {number} + * @since 3.10.0 + */ + R2: { + + get: function () + { + return this._FBRightBottom.value; + } + + } + +}); + +module.exports = Gamepad; + + +/***/ }), +/* 286 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * Contains information about a specific button on a Gamepad. + * Button objects are created automatically by the Gamepad as they are needed. + * + * @class Button + * @memberof Phaser.Input.Gamepad + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad.Gamepad} pad - A reference to the Gamepad that this Button belongs to. + * @param {integer} index - The index of this Button. + */ +var Button = new Class({ + + initialize: + + function Button (pad, index) + { + /** + * A reference to the Gamepad that this Button belongs to. + * + * @name Phaser.Input.Gamepad.Button#pad + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.0.0 + */ + this.pad = pad; + + /** + * An event emitter to use to emit the button events. + * + * @name Phaser.Input.Gamepad.Button#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = pad.manager; + + /** + * The index of this Button. + * + * @name Phaser.Input.Gamepad.Button#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * Between 0 and 1. + * + * @name Phaser.Input.Gamepad.Button#value + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.value = 0; + + /** + * Can be set for analogue buttons to enable a 'pressure' threshold, + * before a button is considered as being 'pressed'. + * + * @name Phaser.Input.Gamepad.Button#threshold + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.threshold = 1; + + /** + * Is the Button being pressed down or not? + * + * @name Phaser.Input.Gamepad.Button#pressed + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pressed = false; + }, + + /** + * Internal update handler for this Button. + * Called automatically by the Gamepad as part of its update. + * + * @method Phaser.Input.Gamepad.Button#update + * @private + * @since 3.0.0 + * + * @param {number} value - The GamepadButton value. + */ + update: function (value) + { + this.value = value; + + var pad = this.pad; + var index = this.index; + + if (value >= this.threshold) + { + if (!this.pressed) + { + this.pressed = true; + this.events.emit('down', pad, this, value); + this.pad.emit('down', index, value, this); + } + } + else if (this.pressed) + { + this.pressed = false; + this.events.emit('up', pad, this, value); + this.pad.emit('up', index, value, this); + } + }, + + /** + * Destroys this Button instance and releases external references it holds. + * + * @method Phaser.Input.Gamepad.Button#destroy + * @since 3.10.0 + */ + destroy: function () + { + this.pad = null; + this.events = null; + } + +}); + +module.exports = Button; + + +/***/ }), +/* 287 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * Contains information about a specific Gamepad Axis. + * Axis objects are created automatically by the Gamepad as they are needed. + * + * @class Axis + * @memberof Phaser.Input.Gamepad + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.Gamepad.Gamepad} pad - A reference to the Gamepad that this Axis belongs to. + * @param {integer} index - The index of this Axis. + */ +var Axis = new Class({ + + initialize: + + function Axis (pad, index) + { + /** + * A reference to the Gamepad that this Axis belongs to. + * + * @name Phaser.Input.Gamepad.Axis#pad + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.0.0 + */ + this.pad = pad; + + /** + * An event emitter to use to emit the axis events. + * + * @name Phaser.Input.Gamepad.Axis#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = pad.events; + + /** + * The index of this Axis. + * + * @name Phaser.Input.Gamepad.Axis#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * The raw axis value, between -1 and 1 with 0 being dead center. + * Use the method `getValue` to get a normalized value with the threshold applied. + * + * @name Phaser.Input.Gamepad.Axis#value + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.value = 0; + + /** + * Movement tolerance threshold below which axis values are ignored in `getValue`. + * + * @name Phaser.Input.Gamepad.Axis#threshold + * @type {number} + * @default 0.1 + * @since 3.0.0 + */ + this.threshold = 0.1; + }, + + /** + * Internal update handler for this Axis. + * Called automatically by the Gamepad as part of its update. + * + * @method Phaser.Input.Gamepad.Axis#update + * @private + * @since 3.0.0 + * + * @param {number} value - The value of the axis movement. + */ + update: function (value) + { + this.value = value; + }, + + /** + * Applies the `threshold` value to the axis and returns it. + * + * @method Phaser.Input.Gamepad.Axis#getValue + * @since 3.0.0 + * + * @return {number} The axis value, adjusted for the movement threshold. + */ + getValue: function () + { + return (Math.abs(this.value) < this.threshold) ? 0 : this.value; + }, + + /** + * Destroys this Axis instance and releases external references it holds. + * + * @method Phaser.Input.Gamepad.Axis#destroy + * @since 3.10.0 + */ + destroy: function () + { + this.pad = null; + this.events = null; + } + +}); + +module.exports = Axis; + + +/***/ }), +/* 288 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @callback HitAreaCallback + * + * @param {any} hitArea - The hit area object. + * @param {number} x - The translated x coordinate of the hit test event. + * @param {number} y - The translated y coordinate of the hit test event. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that invoked the hit test. + * + * @return {boolean} `true` if the coordinates fall within the space of the hitArea, otherwise `false`. + */ + +/** + * @typedef {object} Phaser.Input.InteractiveObject + * + * @property {Phaser.GameObjects.GameObject} gameObject - The Game Object to which this Interactive Object is bound. + * @property {boolean} enabled - Is this Interactive Object currently enabled for input events? + * @property {boolean} draggable - Is this Interactive Object draggable? Enable with `InputPlugin.setDraggable`. + * @property {boolean} dropZone - Is this Interactive Object a drag-targets drop zone? Set when the object is created. + * @property {(boolean|string)} cursor - Should this Interactive Object change the cursor (via css) when over? (desktop only) + * @property {?Phaser.GameObjects.GameObject} target - An optional drop target for a draggable Interactive Object. + * @property {Phaser.Cameras.Scene2D.Camera} camera - The most recent Camera to be tested against this Interactive Object. + * @property {any} hitArea - The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. + * @property {HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests. + * @property {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @property {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @property {(0|1|2)} dragState - The current drag state of this Interactive Object. 0 = Not being dragged, 1 = being checked for drag, or 2 = being actively dragged. + * @property {number} dragStartX - The x coordinate that the Pointer started dragging this Interactive Object from. + * @property {number} dragStartY - The y coordinate that the Pointer started dragging this Interactive Object from. + * @property {number} dragX - The x coordinate that this Interactive Object is currently being dragged to. + * @property {number} dragY - The y coordinate that this Interactive Object is currently being dragged to. + */ + +/** + * Creates a new Interactive Object. + * + * This is called automatically by the Input Manager when you enable a Game Object for input. + * + * The resulting Interactive Object is mapped to the Game Object's `input` property. + * + * @function Phaser.Input.CreateInteractiveObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to which this Interactive Object is bound. + * @param {any} hitArea - The hit area for this Interactive Object. Typically a geometry shape, like a Rectangle or Circle. + * @param {HitAreaCallback} hitAreaCallback - The 'contains' check callback that the hit area shape will use for all hit tests. + * + * @return {Phaser.Input.InteractiveObject} The new Interactive Object. + */ +var CreateInteractiveObject = function (gameObject, hitArea, hitAreaCallback) +{ + return { + + gameObject: gameObject, + + enabled: true, + draggable: false, + dropZone: false, + cursor: false, + + target: null, + + camera: null, + + hitArea: hitArea, + hitAreaCallback: hitAreaCallback, + + localX: 0, + localY: 0, + + // 0 = Not being dragged + // 1 = Being checked for dragging + // 2 = Being dragged + dragState: 0, + + dragStartX: 0, + dragStartY: 0, + + dragX: 0, + dragY: 0 + + }; +}; + +module.exports = CreateInteractiveObject; + + +/***/ }), +/* 289 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// The three angle bisectors of a triangle meet in one point called the incenter. +// It is the center of the incircle, the circle inscribed in the triangle. + +function getLength (x1, y1, x2, y2) +{ + var x = x1 - x2; + var y = y1 - y2; + var magnitude = (x * x) + (y * y); + + return Math.sqrt(magnitude); +} + +/** + * [description] + * + * @function Phaser.Geom.Triangle.InCenter + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var InCenter = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = triangle.x1; + var y1 = triangle.y1; + + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + var d1 = getLength(x3, y3, x2, y2); + var d2 = getLength(x1, y1, x3, y3); + var d3 = getLength(x2, y2, x1, y1); + + var p = d1 + d2 + d3; + + out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; + out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; + + return out; +}; + +module.exports = InCenter; + + +/***/ }), +/* 290 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Offset = function (triangle, x, y) +{ + triangle.x1 += x; + triangle.y1 += y; + + triangle.x2 += x; + triangle.y2 += y; + + triangle.x3 += x; + triangle.y3 += y; + + return triangle; +}; + +module.exports = Offset; + + +/***/ }), +/* 291 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) +// meet in the centroid or center of mass (center of gravity). +// The centroid divides each median in a ratio of 2:1 + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Centroid + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Centroid = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; + out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; + + return out; +}; + +module.exports = Centroid; + + +/***/ }), +/* 292 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Checks if rectB is fully contained within rectA + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var ContainsRect = function (rectA, rectB) +{ + // Volume check (if rectB volume > rectA then rectA cannot contain it) + if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) + { + return false; + } + + return ( + (rectB.x > rectA.x && rectB.x < rectA.right) && + (rectB.right > rectA.x && rectB.right < rectA.right) && + (rectB.y > rectA.y && rectB.y < rectA.bottom) && + (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 293 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +Rectangle.Area = __webpack_require__(723); +Rectangle.Ceil = __webpack_require__(722); +Rectangle.CeilAll = __webpack_require__(721); +Rectangle.CenterOn = __webpack_require__(193); +Rectangle.Clone = __webpack_require__(720); +Rectangle.Contains = __webpack_require__(43); +Rectangle.ContainsPoint = __webpack_require__(719); +Rectangle.ContainsRect = __webpack_require__(292); +Rectangle.CopyFrom = __webpack_require__(718); +Rectangle.Decompose = __webpack_require__(298); +Rectangle.Equals = __webpack_require__(717); +Rectangle.FitInside = __webpack_require__(716); +Rectangle.FitOutside = __webpack_require__(715); +Rectangle.Floor = __webpack_require__(714); +Rectangle.FloorAll = __webpack_require__(713); +Rectangle.FromPoints = __webpack_require__(191); +Rectangle.GetAspectRatio = __webpack_require__(161); +Rectangle.GetCenter = __webpack_require__(712); +Rectangle.GetPoint = __webpack_require__(209); +Rectangle.GetPoints = __webpack_require__(434); +Rectangle.GetSize = __webpack_require__(711); +Rectangle.Inflate = __webpack_require__(710); +Rectangle.Intersection = __webpack_require__(709); +Rectangle.MarchingAnts = __webpack_require__(424); +Rectangle.MergePoints = __webpack_require__(708); +Rectangle.MergeRect = __webpack_require__(707); +Rectangle.MergeXY = __webpack_require__(706); +Rectangle.Offset = __webpack_require__(705); +Rectangle.OffsetPoint = __webpack_require__(704); +Rectangle.Overlaps = __webpack_require__(703); +Rectangle.Perimeter = __webpack_require__(134); +Rectangle.PerimeterPoint = __webpack_require__(702); +Rectangle.Random = __webpack_require__(206); +Rectangle.RandomOutside = __webpack_require__(701); +Rectangle.SameDimensions = __webpack_require__(700); +Rectangle.Scale = __webpack_require__(699); +Rectangle.Union = __webpack_require__(337); + +module.exports = Rectangle; + + +/***/ }), +/* 294 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitudeSq + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitudeSq = function (point) +{ + return (point.x * point.x) + (point.y * point.y); +}; + +module.exports = GetMagnitudeSq; + + +/***/ }), +/* 295 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitude + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitude = function (point) +{ + return Math.sqrt((point.x * point.x) + (point.y * point.y)); +}; + +module.exports = GetMagnitude; + + +/***/ }), +/* 296 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(18); +var Wrap = __webpack_require__(59); +var Angle = __webpack_require__(75); + +/** + * Get the angle of the normal of the given line in radians. + * + * @function Phaser.Geom.Line.NormalAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the angle of the normal of. + * + * @return {number} The angle of the normal of the line in radians. + */ +var NormalAngle = function (line) +{ + var angle = Angle(line) - MATH_CONST.TAU; + + return Wrap(angle, -Math.PI, Math.PI); +}; + +module.exports = NormalAngle; + + +/***/ }), +/* 297 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {array} [out] - [description] + * + * @return {array} [description] + */ +var Decompose = function (triangle, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: triangle.x1, y: triangle.y1 }); + out.push({ x: triangle.x2, y: triangle.y2 }); + out.push({ x: triangle.x3, y: triangle.y3 }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 298 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Create an array of points for each corner of a Rectangle + * If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created. + * + * @function Phaser.Geom.Rectangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object to be decomposed. + * @param {array} [out] - If provided, each point will be added to this array. + * + * @return {array} Will return the array you specified or a new array containing the points of the Rectangle. + */ +var Decompose = function (rect, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: rect.x, y: rect.y }); + out.push({ x: rect.right, y: rect.y }); + out.push({ x: rect.right, y: rect.bottom }); + out.push({ x: rect.x, y: rect.bottom }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 299 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.PointToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var PointToLine = function (point, line) +{ + return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); +}; + +module.exports = PointToLine; + + +/***/ }), +/* 300 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on code by Matt DesLauriers +// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md + +var Contains = __webpack_require__(44); +var Point = __webpack_require__(6); + +var tmp = new Point(); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.LineToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Point} [nearest] - [description] + * + * @return {boolean} [description] + */ +var LineToCircle = function (line, circle, nearest) +{ + if (nearest === undefined) { nearest = tmp; } + + if (Contains(circle, line.x1, line.y1)) + { + nearest.x = line.x1; + nearest.y = line.y1; + + return true; + } + + if (Contains(circle, line.x2, line.y2)) + { + nearest.x = line.x2; + nearest.y = line.y2; + + return true; + } + + var dx = line.x2 - line.x1; + var dy = line.y2 - line.y1; + + var lcx = circle.x - line.x1; + var lcy = circle.y - line.y1; + + // project lc onto d, resulting in vector p + var dLen2 = (dx * dx) + (dy * dy); + var px = dx; + var py = dy; + + if (dLen2 > 0) + { + var dp = ((lcx * dx) + (lcy * dy)) / dLen2; + + px *= dp; + py *= dp; + } + + nearest.x = line.x1 + px; + nearest.y = line.y1 + py; + + // len2 of p + var pLen2 = (px * px) + (py * py); + + return ( + pLen2 <= dLen2 && + ((px * dx) + (py * dy)) >= 0 && + Contains(circle, nearest.x, nearest.y) + ); +}; + +module.exports = LineToCircle; + + +/***/ }), +/* 301 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom.Intersects + */ + +module.exports = { + + CircleToCircle: __webpack_require__(770), + CircleToRectangle: __webpack_require__(769), + GetRectangleIntersection: __webpack_require__(768), + LineToCircle: __webpack_require__(300), + LineToLine: __webpack_require__(117), + LineToRectangle: __webpack_require__(767), + PointToLine: __webpack_require__(299), + PointToLineSegment: __webpack_require__(766), + RectangleToRectangle: __webpack_require__(164), + RectangleToTriangle: __webpack_require__(765), + RectangleToValues: __webpack_require__(764), + TriangleToCircle: __webpack_require__(763), + TriangleToLine: __webpack_require__(762), + TriangleToTriangle: __webpack_require__(761) + +}; + + +/***/ }), +/* 302 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom + */ + +module.exports = { + + Circle: __webpack_require__(790), + Ellipse: __webpack_require__(780), + Intersects: __webpack_require__(301), + Line: __webpack_require__(760), + Point: __webpack_require__(742), + Polygon: __webpack_require__(728), + Rectangle: __webpack_require__(293), + Triangle: __webpack_require__(698) + +}; + + +/***/ }), +/* 303 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Light = __webpack_require__(304); +var Utils = __webpack_require__(9); + +/** + * @callback LightForEach + * + * @param {Phaser.GameObjects.Light} light - The Light. + */ + +/** + * @classdesc + * Manages Lights for a Scene. + * + * Affects the rendering of Game Objects using the `Light2D` pipeline. + * + * @class LightsManager + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + */ +var LightsManager = new Class({ + + initialize: + + function LightsManager () + { + /** + * The pool of Lights. + * + * Used to recycle removed Lights for a more efficient use of memory. + * + * @name Phaser.GameObjects.LightsManager#lightPool + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lightPool = []; + + /** + * The Lights in the Scene. + * + * @name Phaser.GameObjects.LightsManager#lights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lights = []; + + /** + * Lights that have been culled from a Camera's viewport. + * + * Lights in this list will not be rendered. + * + * @name Phaser.GameObjects.LightsManager#culledLights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.culledLights = []; + + /** + * The ambient color. + * + * @name Phaser.GameObjects.LightsManager#ambientColor + * @type {{ r: number, g: number, b: number }} + * @since 3.0.0 + */ + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + + /** + * Whether the Lights Manager is enabled. + * + * @name Phaser.GameObjects.LightsManager#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + + /** + * The maximum number of lights that a single Camera and the lights shader can process. + * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. + * + * @name Phaser.GameObjects.LightsManager#maxLights + * @type {integer} + * @readonly + * @since 3.15.0 + */ + this.maxLights = -1; + }, + + /** + * Enable the Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#enable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + enable: function () + { + if (this.maxLights === -1) + { + this.maxLights = this.scene.sys.game.renderer.config.maxLights; + } + + this.active = true; + + return this; + }, + + /** + * Disable the Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#disable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + disable: function () + { + this.active = false; + + return this; + }, + + /** + * Cull any Lights that aren't visible to the given Camera. + * + * Culling Lights improves performance by ensuring that only Lights within a Camera's viewport are rendered. + * + * @method Phaser.GameObjects.LightsManager#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to cull Lights for. + * + * @return {Phaser.GameObjects.Light[]} The culled Lights. + */ + cull: function (camera) + { + var lights = this.lights; + var culledLights = this.culledLights; + var length = lights.length; + var cameraCenterX = camera.x + camera.width / 2.0; + var cameraCenterY = camera.y + camera.height / 2.0; + var cameraRadius = (camera.width + camera.height) / 2.0; + var point = { x: 0, y: 0 }; + var cameraMatrix = camera.matrix; + var viewportHeight = this.systems.game.config.height; + + culledLights.length = 0; + + for (var index = 0; index < length && culledLights.length < this.maxLights; index++) + { + var light = lights[index]; + + cameraMatrix.transformPoint(light.x, light.y, point); + + // We'll just use bounding spheres to test if lights should be rendered + var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); + var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + var distance = Math.sqrt(dx * dx + dy * dy); + + if (distance < light.radius + cameraRadius) + { + culledLights.push(lights[index]); + } + } + + return culledLights; + }, + + /** + * Iterate over each Light with a callback. + * + * @method Phaser.GameObjects.LightsManager#forEachLight + * @since 3.0.0 + * + * @param {LightForEach} callback - The callback that is called with each Light. + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + forEachLight: function (callback) + { + if (!callback) + { + return; + } + + var lights = this.lights; + var length = lights.length; + + for (var index = 0; index < length; ++index) + { + callback(lights[index]); + } + + return this; + }, + + /** + * Set the ambient light color. + * + * @method Phaser.GameObjects.LightsManager#setAmbientColor + * @since 3.0.0 + * + * @param {number} rgb - The integer RGB color of the ambient light. + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + setAmbientColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.ambientColor.r = color[0]; + this.ambientColor.g = color[1]; + this.ambientColor.b = color[2]; + + return this; + }, + + /** + * Returns the maximum number of Lights allowed to appear at once. + * + * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights + * @since 3.0.0 + * + * @return {integer} The maximum number of Lights allowed to appear at once. + */ + getMaxVisibleLights: function () + { + return 10; + }, + + /** + * Get the number of Lights managed by this Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#getLightCount + * @since 3.0.0 + * + * @return {integer} The number of Lights managed by this Lights Manager. + */ + getLightCount: function () + { + return this.lights.length; + }, + + /** + * Add a Light. + * + * @method Phaser.GameObjects.LightsManager#addLight + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal position of the Light. + * @param {number} [y=0] - The vertical position of the Light. + * @param {number} [radius=100] - The radius of the Light. + * @param {number} [rgb=0xffffff] - The integer RGB color of the light. + * @param {number} [intensity=1] - The intensity of the Light. + * + * @return {Phaser.GameObjects.Light} The Light that was added. + */ + addLight: function (x, y, radius, rgb, intensity) + { + var color = null; + var light = null; + + x = (x === undefined) ? 0.0 : x; + y = (y === undefined) ? 0.0 : y; + rgb = (rgb === undefined) ? 0xffffff : rgb; + radius = (radius === undefined) ? 100.0 : radius; + intensity = (intensity === undefined) ? 1.0 : intensity; + + color = Utils.getFloatsFromUintRGB(rgb); + light = null; + + if (this.lightPool.length > 0) + { + light = this.lightPool.pop(); + light.set(x, y, radius, color[0], color[1], color[2], intensity); + } + else + { + light = new Light(x, y, radius, color[0], color[1], color[2], intensity); + } + + this.lights.push(light); + + return light; + }, + + /** + * Remove a Light. + * + * @method Phaser.GameObjects.LightsManager#removeLight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Light} light - The Light to remove. + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + removeLight: function (light) + { + var index = this.lights.indexOf(light); + + if (index >= 0) + { + this.lightPool.push(light); + this.lights.splice(index, 1); + } + + return this; + }, + + /** + * Shut down the Lights Manager. + * + * Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and + * culled Lights. + * + * @method Phaser.GameObjects.LightsManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + while (this.lights.length > 0) + { + this.lightPool.push(this.lights.pop()); + } + + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + this.culledLights.length = 0; + this.lights.length = 0; + }, + + /** + * Destroy the Lights Manager. + * + * Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}. + * + * @method Phaser.GameObjects.LightsManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + } + +}); + +module.exports = LightsManager; + + +/***/ }), +/* 304 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(9); + +/** + * @classdesc + * A 2D point light. + * + * These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`. + * + * Any Game Objects using the Light2D pipeline will then be affected by these Lights. + * + * They can also simply be used to represent a point light for your own purposes. + * + * @class Light + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color of the light. A value between 0 and 1. + * @param {number} g - The green color of the light. A value between 0 and 1. + * @param {number} b - The blue color of the light. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + */ +var Light = new Class({ + + initialize: + + function Light (x, y, radius, r, g, b, intensity) + { + /** + * The horizontal position of the light. + * + * @name Phaser.GameObjects.Light#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The vertical position of the light. + * + * @name Phaser.GameObjects.Light#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The radius of the light. + * + * @name Phaser.GameObjects.Light#radius + * @type {number} + * @since 3.0.0 + */ + this.radius = radius; + + /** + * The red color of the light. A value between 0 and 1. + * + * @name Phaser.GameObjects.Light#r + * @type {number} + * @since 3.0.0 + */ + this.r = r; + + /** + * The green color of the light. A value between 0 and 1. + * + * @name Phaser.GameObjects.Light#g + * @type {number} + * @since 3.0.0 + */ + this.g = g; + + /** + * The blue color of the light. A value between 0 and 1. + * + * @name Phaser.GameObjects.Light#b + * @type {number} + * @since 3.0.0 + */ + this.b = b; + + /** + * The intensity of the light. + * + * @name Phaser.GameObjects.Light#intensity + * @type {number} + * @since 3.0.0 + */ + this.intensity = intensity; + + /** + * The horizontal scroll factor of the light. + * + * @name Phaser.GameObjects.Light#scrollFactorX + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorX = 1.0; + + /** + * The vertical scroll factor of the light. + * + * @name Phaser.GameObjects.Light#scrollFactorY + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorY = 1.0; + }, + + /** + * Set the properties of the light. + * + * Sets both horizontal and vertical scroll factor to 1. Use {@link Phaser.GameObjects.Light#setScrollFactor} to set + * the scroll factor. + * + * @method Phaser.GameObjects.Light#set + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color. A value between 0 and 1. + * @param {number} g - The green color. A value between 0 and 1. + * @param {number} b - The blue color. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + set: function (x, y, radius, r, g, b, intensity) + { + this.x = x; + this.y = y; + + this.radius = radius; + + this.r = r; + this.g = g; + this.b = b; + + this.intensity = intensity; + + this.scrollFactorX = 1; + this.scrollFactorY = 1; + + return this; + }, + + /** + * Set the scroll factor of the light. + * + * @method Phaser.GameObjects.Light#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of the light. + * @param {number} y - The vertical scroll factor of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setScrollFactor: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + }, + + /** + * Set the color of the light from a single integer RGB value. + * + * @method Phaser.GameObjects.Light#setColor + * @since 3.0.0 + * + * @param {number} rgb - The integer RGB color of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.r = color[0]; + this.g = color[1]; + this.b = color[2]; + + return this; + }, + + /** + * Set the intensity of the light. + * + * @method Phaser.GameObjects.Light#setIntensity + * @since 3.0.0 + * + * @param {number} intensity - The intensity of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setIntensity: function (intensity) + { + this.intensity = intensity; + + return this; + }, + + /** + * Set the position of the light. + * + * @method Phaser.GameObjects.Light#setPosition + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setPosition: function (x, y) + { + this.x = x; + this.y = y; + + return this; + }, + + /** + * Set the radius of the light. + * + * @method Phaser.GameObjects.Light#setRadius + * @since 3.0.0 + * + * @param {number} radius - The radius of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setRadius: function (radius) + { + this.radius = radius; + + return this; + } + +}); + +module.exports = Light; + + +/***/ }), +/* 305 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(71); +var Point = __webpack_require__(6); + +/** + * Returns an array of evenly spaced points on the perimeter of a Triangle. + * + * @function Phaser.Geom.Triangle.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the points from. + * @param {integer} quantity - The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. + * @param {number} stepRate - If `quantity` is 0, the distance between each returned point. + * @param {(array|Phaser.Geom.Point[])} [out] - An array to which the points should be appended. + * + * @return {(array|Phaser.Geom.Point[])} The modified `out` array, or a new array if none was provided. + */ +var GetPoints = function (triangle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var p = perimeter * (i / quantity); + var localPosition = 0; + + var point = new Point(); + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + out.push(point); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 306 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); +var Length = __webpack_require__(71); + +// Position is a value between 0 and 1 +/** + * [description] + * + * @function Phaser.Geom.Triangle.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} position - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetPoint = function (triangle, position, out) +{ + if (out === undefined) { out = new Point(); } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + if (position <= 0 || position >= 1) + { + out.x = line1.x1; + out.y = line1.y1; + + return out; + } + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + var p = perimeter * position; + var localPosition = 0; + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 307 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Shape = __webpack_require__(31); +var GeomTriangle = __webpack_require__(66); +var TriangleRender = __webpack_require__(839); + +/** + * @classdesc + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @class Triangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Triangle = new Class({ + + Extends: Shape, + + Mixins: [ + TriangleRender + ], + + initialize: + + function Triangle (scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 128; } + if (x2 === undefined) { x2 = 64; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 128; } + if (y3 === undefined) { y3 = 128; } + + Shape.call(this, scene, 'Triangle', new GeomTriangle(x1, y1, x2, y2, x3, y3)); + + var width = this.geom.right - this.geom.left; + var height = this.geom.bottom - this.geom.top; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the data for the lines that make up this Triangle shape. + * + * @method Phaser.GameObjects.Triangle#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=0] - The vertical position of the first point in the triangle. + * @param {number} [x2=0] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=0] - The horizontal position of the third point in the triangle. + * @param {number} [y3=0] - The vertical position of the third point in the triangle. + * + * @return {this} This Game Object instance. + */ + setTo: function (x1, y1, x2, y2, x3, y3) + { + this.geom.setTo(x1, y1, x2, y2, x3, y3); + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Triangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var rect = this.geom; + var line = this._tempLine; + + rect.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + rect.getLineB(line); + + path.push(line.x2, line.y2); + + rect.getLineC(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + } + +}); + +module.exports = Triangle; + + +/***/ }), +/* 308 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StarRender = __webpack_require__(842); +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(70); +var Shape = __webpack_require__(31); + +/** + * @classdesc + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @class Star + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star. + * @param {number} [outerRadius=64] - The outer radius of the star. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Star = new Class({ + + Extends: Shape, + + Mixins: [ + StarRender + ], + + initialize: + + function Star (scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (points === undefined) { points = 5; } + if (innerRadius === undefined) { innerRadius = 32; } + if (outerRadius === undefined) { outerRadius = 64; } + + Shape.call(this, scene, 'Star', null); + + /** + * Private internal value. + * The number of points in the star. + * + * @name Phaser.GameObjects.Star#_points + * @type {integer} + * @private + * @since 3.13.0 + */ + this._points = points; + + /** + * Private internal value. + * The inner radius of the star. + * + * @name Phaser.GameObjects.Star#_innerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._innerRadius = innerRadius; + + /** + * Private internal value. + * The outer radius of the star. + * + * @name Phaser.GameObjects.Star#_outerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._outerRadius = outerRadius; + + this.setPosition(x, y); + this.setSize(outerRadius * 2, outerRadius * 2); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the number of points that make up the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setPoints + * @since 3.13.0 + * + * @param {integer} value - The amount of points the Star will have. + * + * @return {this} This Game Object instance. + */ + setPoints: function (value) + { + this._points = value; + + return this.updateData(); + }, + + /** + * Sets the inner radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setInnerRadius + * @since 3.13.0 + * + * @param {number} value - The amount to set the inner radius to. + * + * @return {this} This Game Object instance. + */ + setInnerRadius: function (value) + { + this._innerRadius = value; + + return this.updateData(); + }, + + /** + * Sets the outer radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setOuterRadius + * @since 3.13.0 + * + * @param {number} value - The amount to set the outer radius to. + * + * @return {this} This Game Object instance. + */ + setOuterRadius: function (value) + { + this._outerRadius = value; + + return this.updateData(); + }, + + /** + * The number of points that make up the Star shape. + * + * @name Phaser.GameObjects.Star#points + * @type {integer} + * @default 5 + * @since 3.13.0 + */ + points: { + + get: function () + { + return this._points; + }, + + set: function (value) + { + this._points = value; + + this.updateData(); + } + + }, + + /** + * The inner radius of the Star shape. + * + * @name Phaser.GameObjects.Star#innerRadius + * @type {number} + * @default 32 + * @since 3.13.0 + */ + innerRadius: { + + get: function () + { + return this._innerRadius; + }, + + set: function (value) + { + this._innerRadius = value; + + this.updateData(); + } + + }, + + /** + * The outer radius of the Star shape. + * + * @name Phaser.GameObjects.Star#outerRadius + * @type {number} + * @default 64 + * @since 3.13.0 + */ + outerRadius: { + + get: function () + { + return this._outerRadius; + }, + + set: function (value) + { + this._outerRadius = value; + + this.updateData(); + } + + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Star#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + + var points = this._points; + var innerRadius = this._innerRadius; + var outerRadius = this._outerRadius; + + var rot = Math.PI / 2 * 3; + var step = Math.PI / points; + + // So origin 0.5 = the center of the star + var x = outerRadius; + var y = outerRadius; + + path.push(x, y + -outerRadius); + + for (var i = 0; i < points; i++) + { + path.push(x + Math.cos(rot) * outerRadius, y + Math.sin(rot) * outerRadius); + + rot += step; + + path.push(x + Math.cos(rot) * innerRadius, y + Math.sin(rot) * innerRadius); + + rot += step; + } + + path.push(x, y + -outerRadius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Star; + + +/***/ }), +/* 309 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GeomRectangle = __webpack_require__(10); +var Shape = __webpack_require__(31); +var RectangleRender = __webpack_require__(845); + +/** + * @classdesc + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @class Rectangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Rectangle = new Class({ + + Extends: Shape, + + Mixins: [ + RectangleRender + ], + + initialize: + + function Rectangle (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Rectangle', new GeomRectangle(0, 0, width, height)); + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Rectangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var rect = this.geom; + var line = this._tempLine; + + rect.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + rect.getLineB(line); + + path.push(line.x2, line.y2); + + rect.getLineC(line); + + path.push(line.x2, line.y2); + + rect.getLineD(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + } + +}); + +module.exports = Rectangle; + + +/***/ }), +/* 310 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Igor Ognichenko + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var copy = function (out, a) +{ + out[0] = a[0]; + out[1] = a[1]; + + return out; +}; + +/** + * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. + * + * @function Phaser.Geom.Polygon.Smooth + * @since 3.13.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The polygon to be smoothed. The polygon will be modified in-place and returned. + * + * @return {Phaser.Geom.Polygon} The input polygon. + */ +var Smooth = function (polygon) +{ + var i; + var points = []; + var data = polygon.points; + + for (i = 0; i < data.length; i++) + { + points.push([ data[i].x, data[i].y ]); + } + + var output = []; + + if (points.length > 0) + { + output.push(copy([ 0, 0 ], points[0])); + } + + for (i = 0; i < points.length - 1; i++) + { + var p0 = points[i]; + var p1 = points[i + 1]; + var p0x = p0[0]; + var p0y = p0[1]; + var p1x = p1[0]; + var p1y = p1[1]; + + output.push([ 0.85 * p0x + 0.15 * p1x, 0.85 * p0y + 0.15 * p1y ]); + output.push([ 0.15 * p0x + 0.85 * p1x, 0.15 * p0y + 0.85 * p1y ]); + } + + if (points.length > 1) + { + output.push(copy([ 0, 0 ], points[points.length - 1])); + } + + return polygon.setTo(output); +}; + +module.exports = Smooth; + + +/***/ }), +/* 311 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(71); +var Line = __webpack_require__(60); + +/** + * Returns the perimeter of the given Polygon. + * + * @function Phaser.Geom.Polygon.Perimeter + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the perimeter of. + * + * @return {number} The perimeter of the Polygon. + */ +var Perimeter = function (polygon) +{ + var points = polygon.points; + var perimeter = 0; + + for (var i = 0; i < points.length; i++) + { + var pointA = points[i]; + var pointB = points[(i + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + + perimeter += Length(line); + } + + return perimeter; +}; + +module.exports = Perimeter; + + +/***/ }), +/* 312 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(71); +var Line = __webpack_require__(60); +var Perimeter = __webpack_require__(311); + +/** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Polygon.GetPoints + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the perimeter of the Polygon. + */ +var GetPoints = function (polygon, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var points = polygon.points; + var perimeter = Perimeter(polygon); + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var position = perimeter * (i / quantity); + var accumulatedPerimeter = 0; + + for (var j = 0; j < points.length; j++) + { + var pointA = points[j]; + var pointB = points[(j + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + var length = Length(line); + + if (position < accumulatedPerimeter || position > accumulatedPerimeter + length) + { + accumulatedPerimeter += length; + continue; + } + + var point = line.getPoint((position - accumulatedPerimeter) / length); + out.push(point); + + break; + } + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 313 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * [description] + * + * @function Phaser.Geom.Polygon.GetAABB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {(Phaser.Geom.Rectangle|object)} [out] - [description] + * + * @return {(Phaser.Geom.Rectangle|object)} [description] + */ +var GetAABB = function (polygon, out) +{ + if (out === undefined) { out = new Rectangle(); } + + var minX = Infinity; + var minY = Infinity; + var maxX = -minX; + var maxY = -minY; + var p; + + for (var i = 0; i < polygon.points.length; i++) + { + p = polygon.points[i]; + + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; +}; + +module.exports = GetAABB; + + +/***/ }), +/* 314 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PolygonRender = __webpack_require__(848); +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(70); +var GetAABB = __webpack_require__(313); +var GeomPolygon = __webpack_require__(167); +var Shape = __webpack_require__(31); +var Smooth = __webpack_require__(310); + +/** + * @classdesc + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * @class Polygon + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Polygon = new Class({ + + Extends: Shape, + + Mixins: [ + PolygonRender + ], + + initialize: + + function Polygon (scene, x, y, points, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Polygon', new GeomPolygon(points)); + + var bounds = GetAABB(this.geom); + + this.setPosition(x, y); + this.setSize(bounds.width, bounds.height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Smooths the polygon over the number of iterations specified. + * The base polygon data will be updated and replaced with the smoothed values. + * This call can be chained. + * + * @method Phaser.GameObjects.Polygon#smooth + * @since 3.13.0 + * + * @param {integer} [iterations=1] - The number of times to apply the polygon smoothing. + * + * @return {this} This Game Object instance. + */ + smooth: function (iterations) + { + if (iterations === undefined) { iterations = 1; } + + for (var i = 0; i < iterations; i++) + { + Smooth(this.geom); + } + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Polygon#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.points; + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Polygon; + + +/***/ }), +/* 315 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Shape = __webpack_require__(31); +var GeomLine = __webpack_require__(60); +var LineRender = __webpack_require__(851); + +/** + * @classdesc + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * @class Line + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Line = new Class({ + + Extends: Shape, + + Mixins: [ + LineRender + ], + + initialize: + + function Line (scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 128; } + if (y2 === undefined) { y2 = 0; } + + Shape.call(this, scene, 'Line', new GeomLine(x1, y1, x2, y2)); + + var width = this.geom.right - this.geom.left; + var height = this.geom.bottom - this.geom.top; + + /** + * The width (or thickness) of the line. + * See the setLineWidth method for extra details on changing this on WebGL. + * + * @name Phaser.GameObjects.Line#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Private internal value. Holds the start width of the line. + * + * @name Phaser.GameObjects.Line#_startWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._startWidth = 1; + + /** + * Private internal value. Holds the end width of the line. + * + * @name Phaser.GameObjects.Line#_endWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._endWidth = 1; + + this.setPosition(x, y); + this.setSize(width, height); + + if (strokeColor !== undefined) + { + this.setStrokeStyle(1, strokeColor, strokeAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the width of the line. + * + * When using the WebGL renderer you can have different start and end widths. + * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Line#setLineWidth + * @since 3.13.0 + * + * @param {number} startWidth - The start width of the line. + * @param {number} [endWidth] - The end width of the line. Only used in WebGL. + * + * @return {this} This Game Object instance. + */ + setLineWidth: function (startWidth, endWidth) + { + if (endWidth === undefined) { endWidth = startWidth; } + + this._startWidth = startWidth; + this._endWidth = endWidth; + + this.lineWidth = startWidth; + + return this; + }, + + /** + * Sets the start and end coordinates of this Line. + * + * @method Phaser.GameObjects.Line#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=0] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * + * @return {this} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + this.geom.setTo(x1, y1, x2, y2); + + return this; + } + +}); + +module.exports = Line; + + +/***/ }), +/* 316 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var IsoTriangleRender = __webpack_require__(854); +var Shape = __webpack_require__(31); + +/** + * @classdesc + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @class IsoTriangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + */ +var IsoTriangle = new Class({ + + Extends: Shape, + + Mixins: [ + IsoTriangleRender + ], + + initialize: + + function IsoTriangle (scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (reversed === undefined) { reversed = false; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoTriangle', null); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * + * @name Phaser.GameObjects.IsoTriangle#projection + * @type {integer} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. + * + * @name Phaser.GameObjects.IsoTriangle#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls if the top-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls if the left-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls if the right-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + /** + * Sets if the iso triangle will be rendered upside down or not. + * + * @name Phaser.GameObjects.IsoTriangle#isReversed + * @type {boolean} + * @default false + * @since 3.13.0 + */ + this.isReversed = reversed; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setProjection + * @since 3.13.0 + * + * @param {integer} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets if the iso triangle will be rendered upside down or not. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setReversed + * @since 3.13.0 + * + * @param {boolean} reversed - Sets if the iso triangle will be rendered upside down or not. + * + * @return {this} This Game Object instance. + */ + setReversed: function (reversed) + { + this.isReversed = reversed; + + return this; + }, + + /** + * Sets which faces of the iso triangle will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso triangle (only if `reversed` is true) + * @param {boolean} [showLeft=true] - Show the left-face of the iso triangle. + * @param {boolean} [showRight=true] - Show the right-face of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso triangle. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso triangle. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso triangle. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoTriangle; + + +/***/ }), +/* 317 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsoBoxRender = __webpack_require__(857); +var Class = __webpack_require__(0); +var Shape = __webpack_require__(31); + +/** + * @classdesc + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * + * @class IsoBox + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + */ +var IsoBox = new Class({ + + Extends: Shape, + + Mixins: [ + IsoBoxRender + ], + + initialize: + + function IsoBox (scene, x, y, size, height, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoBox', null); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * + * @name Phaser.GameObjects.IsoBox#projection + * @type {integer} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls if the top-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls if the left-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls if the right-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setProjection + * @since 3.13.0 + * + * @param {integer} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets which faces of the iso box will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso box. + * @param {boolean} [showLeft=true] - Show the left-face of the iso box. + * @param {boolean} [showRight=true] - Show the right-face of the iso box. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso box. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso box. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso box. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoBox; + + +/***/ }), +/* 318 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Shape = __webpack_require__(31); +var GridRender = __webpack_require__(860); + +/** + * @classdesc + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @class Grid + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [outlineFillColor] - The color of the lines between the grid cells. See the `setOutline` method. + * @param {number} [outlineFillAlpha] - The alpha of the lines between the grid cells. + */ +var Grid = new Class({ + + Extends: Shape, + + Mixins: [ + GridRender + ], + + initialize: + + function Grid (scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + if (cellWidth === undefined) { cellWidth = 32; } + if (cellHeight === undefined) { cellHeight = 32; } + + Shape.call(this, scene, 'Grid', null); + + /** + * The width of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellWidth + * @type {number} + * @since 3.13.0 + */ + this.cellWidth = cellWidth; + + /** + * The height of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellHeight + * @type {number} + * @since 3.13.0 + */ + this.cellHeight = cellHeight; + + /** + * Will the grid render its cells in the `fillColor`? + * + * @name Phaser.GameObjects.Grid#showCells + * @type {boolean} + * @since 3.13.0 + */ + this.showCells = true; + + /** + * The color of the lines between each grid cell. + * + * @name Phaser.GameObjects.Grid#outlineFillColor + * @type {number} + * @since 3.13.0 + */ + this.outlineFillColor = 0; + + /** + * The alpha value for the color of the lines between each grid cell. + * + * @name Phaser.GameObjects.Grid#outlineFillAlpha + * @type {number} + * @since 3.13.0 + */ + this.outlineFillAlpha = 0; + + /** + * Will the grid display the lines between each cell when it renders? + * + * @name Phaser.GameObjects.Grid#showOutline + * @type {boolean} + * @since 3.13.0 + */ + this.showOutline = true; + + /** + * Will the grid render the alternating cells in the `altFillColor`? + * + * @name Phaser.GameObjects.Grid#showAltCells + * @type {boolean} + * @since 3.13.0 + */ + this.showAltCells = false; + + /** + * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * + * @name Phaser.GameObjects.Grid#altFillColor + * @type {number} + * @since 3.13.0 + */ + this.altFillColor; + + /** + * The alpha the alternating grid cells will be filled with. + * You can also set the alpha of the overall Shape using its `alpha` property. + * + * @name Phaser.GameObjects.Grid#altFillAlpha + * @type {number} + * @since 3.13.0 + */ + this.altFillAlpha; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + if (outlineFillColor !== undefined) + { + this.setOutlineStyle(outlineFillColor, outlineFillAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the fill color and alpha level the grid cells will use when rendering. + * + * If this method is called with no values then the grid cells will not be rendered, + * however the grid lines and alternating cells may still be. + * + * Also see the `setOutlineStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showCells = false; + } + else + { + this.fillColor = fillColor; + this.fillAlpha = fillAlpha; + this.showCells = true; + } + + return this; + }, + + /** + * Sets the fill color and alpha level that the alternating grid cells will use. + * + * If this method is called with no values then alternating grid cells will not be rendered in a different color. + * + * Also see the `setOutlineStyle` and `setFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setAltFillStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setAltFillStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showAltCells = false; + } + else + { + this.altFillColor = fillColor; + this.altFillAlpha = fillAlpha; + this.showAltCells = true; + } + + return this; + }, + + /** + * Sets the fill color and alpha level that the lines between each grid cell will use. + * + * If this method is called with no values then the grid lines will not be rendered at all, however + * the cells themselves may still be if they have colors set. + * + * Also see the `setFillStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setOutlineStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setOutlineStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showOutline = false; + } + else + { + this.outlineFillColor = fillColor; + this.outlineFillAlpha = fillAlpha; + this.showOutline = true; + } + + return this; + } + +}); + +module.exports = Grid; + + +/***/ }), +/* 319 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(70); +var EllipseRender = __webpack_require__(863); +var GeomEllipse = __webpack_require__(99); +var Shape = __webpack_require__(31); + +/** + * @classdesc + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @class Ellipse + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Ellipse = new Class({ + + Extends: Shape, + + Mixins: [ + EllipseRender + ], + + initialize: + + function Ellipse (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Ellipse', new GeomEllipse(width / 2, height / 2, width, height)); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Ellipse#_smoothness + * @type {integer} + * @private + * @since 3.13.0 + */ + this._smoothness = 64; + + this.setPosition(x, y); + + this.width = width; + this.height = height; + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Ellipse#smoothness + * @type {integer} + * @default 64 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSize + * @since 3.13.0 + * + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.geom.setSize(width, height); + + return this.updateData(); + }, + + /** + * Sets the smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSmoothness + * @since 3.13.0 + * + * @param {integer} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Ellipse#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.getPoints(this._smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Ellipse; + + +/***/ }), +/* 320 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CurveRender = __webpack_require__(866); +var Earcut = __webpack_require__(70); +var Rectangle = __webpack_require__(10); +var Shape = __webpack_require__(31); + +/** + * @classdesc + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @class Curve + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Curve = new Class({ + + Extends: Shape, + + Mixins: [ + CurveRender + ], + + initialize: + + function Curve (scene, x, y, curve, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Curve', curve); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Curve#_smoothness + * @type {integer} + * @private + * @since 3.13.0 + */ + this._smoothness = 32; + + /** + * Private internal value. + * The Curve bounds rectangle. + * + * @name Phaser.GameObjects.Curve#_curveBounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.13.0 + */ + this._curveBounds = new Rectangle(); + + this.closePath = false; + + this.setPosition(x, y); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateData(); + }, + + /** + * The smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Curve#smoothness + * @type {integer} + * @default 32 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Curve#setSmoothness + * @since 3.13.0 + * + * @param {integer} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Curve#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var bounds = this._curveBounds; + var smoothness = this._smoothness; + + // Update the bounds in case the underlying data has changed + this.geom.getBounds(bounds, smoothness); + + this.setSize(bounds.width, bounds.height); + this.updateDisplayOrigin(); + + var path = []; + var points = this.geom.getPoints(smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Curve; + + +/***/ }), +/* 321 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcRender = __webpack_require__(869); +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(36); +var Earcut = __webpack_require__(70); +var GeomCircle = __webpack_require__(81); +var MATH_CONST = __webpack_require__(18); +var Shape = __webpack_require__(31); + +/** + * @classdesc + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows + * you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. + * + * @class Arc + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [radius=128] - The radius of the arc. + * @param {integer} [startAngle=0] - The start angle of the arc, in degrees. + * @param {integer} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - The winding order of the start and end angles. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Arc = new Class({ + + Extends: Shape, + + Mixins: [ + ArcRender + ], + + initialize: + + function Arc (scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 128; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (anticlockwise === undefined) { anticlockwise = false; } + + Shape.call(this, scene, 'Arc', new GeomCircle(0, 0, radius)); + + /** + * Private internal value. Holds the start angle in degrees. + * + * @name Phaser.GameObjects.Arc#_startAngle + * @type {integer} + * @private + * @since 3.13.0 + */ + this._startAngle = startAngle; + + /** + * Private internal value. Holds the end angle in degrees. + * + * @name Phaser.GameObjects.Arc#_endAngle + * @type {integer} + * @private + * @since 3.13.0 + */ + this._endAngle = endAngle; + + /** + * Private internal value. Holds the winding order of the start and end angles. + * + * @name Phaser.GameObjects.Arc#_anticlockwise + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._anticlockwise = anticlockwise; + + /** + * Private internal value. Holds the number of iterations used when drawing the arc. + * + * @name Phaser.GameObjects.Arc#_iterations + * @type {number} + * @default 0.01 + * @private + * @since 3.13.0 + */ + this._iterations = 0.01; + + this.setPosition(x, y); + this.setSize(this.geom.radius, this.geom.radius); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * + * @name Phaser.GameObjects.Arc#iterations + * @type {number} + * @default 0.01 + * @since 3.13.0 + */ + iterations: { + + get: function () + { + return this._iterations; + }, + + set: function (value) + { + this._iterations = value; + + this.updateData(); + } + + }, + + /** + * The radius of the arc. + * + * @name Phaser.GameObjects.Arc#radius + * @type {number} + * @since 3.13.0 + */ + radius: { + + get: function () + { + return this.geom.radius; + }, + + set: function (value) + { + this.geom.radius = value; + + this.updateData(); + } + + }, + + /** + * The start angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#startAngle + * @type {integer} + * @since 3.13.0 + */ + startAngle: { + + get: function () + { + return this._startAngle; + }, + + set: function (value) + { + this._startAngle = value; + + this.updateData(); + } + + }, + + /** + * The end angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#endAngle + * @type {integer} + * @since 3.13.0 + */ + endAngle: { + + get: function () + { + return this._endAngle; + }, + + set: function (value) + { + this._endAngle = value; + + this.updateData(); + } + + }, + + /** + * The winding order of the start and end angles. + * + * @name Phaser.GameObjects.Arc#anticlockwise + * @type {boolean} + * @since 3.13.0 + */ + anticlockwise: { + + get: function () + { + return this._anticlockwise; + }, + + set: function (value) + { + this._anticlockwise = value; + + this.updateData(); + } + + }, + + /** + * Sets the radius of the arc. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setRadius + * @since 3.13.0 + * + * @param {number} value - The value to set the radius to. + * + * @return {this} This Game Object instance. + */ + setRadius: function (value) + { + this.radius = value; + + return this; + }, + + /** + * Sets the number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setIterations + * @since 3.13.0 + * + * @param {number} value - The value to set the iterations to. + * + * @return {this} This Game Object instance. + */ + setIterations: function (value) + { + if (value === undefined) { value = 0.01; } + + this.iterations = value; + + return this; + }, + + /** + * Sets the starting angle of the arc, in degrees. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setStartAngle + * @since 3.13.0 + * + * @param {integer} value - The value to set the starting angle to. + * + * @return {this} This Game Object instance. + */ + setStartAngle: function (angle, anticlockwise) + { + this._startAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Sets the ending angle of the arc, in degrees. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setEndAngle + * @since 3.13.0 + * + * @param {integer} value - The value to set the ending angle to. + * + * @return {this} This Game Object instance. + */ + setEndAngle: function (angle, anticlockwise) + { + this._endAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Arc#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var step = this._iterations; + var iteration = step; + + var radius = this.geom.radius; + var startAngle = DegToRad(this._startAngle); + var endAngle = DegToRad(this._endAngle); + var anticlockwise = this._anticlockwise; + + var x = radius / 2; + var y = radius / 2; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -MATH_CONST.PI2) + { + endAngle = -MATH_CONST.PI2; + } + else if (endAngle > 0) + { + endAngle = -MATH_CONST.PI2 + endAngle % MATH_CONST.PI2; + } + } + else if (endAngle > MATH_CONST.PI2) + { + endAngle = MATH_CONST.PI2; + } + else if (endAngle < 0) + { + endAngle = MATH_CONST.PI2 + endAngle % MATH_CONST.PI2; + } + + var path = [ x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius ]; + + var ta; + + while (iteration < 1) + { + ta = endAngle * iteration + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + iteration += step; + } + + ta = endAngle + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + path.push(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Arc; + + +/***/ }), +/* 322 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the nearest power of 2 to the given `value`. + * + * @function Phaser.Math.Pow2.GetPowerOfTwo + * @since 3.0.0 + * + * @param {number} value - The value. + * + * @return {integer} The nearest power of 2 to `value`. + */ +var GetPowerOfTwo = function (value) +{ + var index = Math.log(value) / 0.6931471805599453; + + return (1 << Math.ceil(index)); +}; + +module.exports = GetPowerOfTwo; + + +/***/ }), +/* 323 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Creates and returns an RFC4122 version 4 compliant UUID. + * + * The string is in the form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` where each `x` is replaced with a random + * hexadecimal digit from 0 to f, and `y` is replaced with a random hexadecimal digit from 8 to b. + * + * @function Phaser.Utils.String.UUID + * @since 3.12.0 + * + * @return {string} The UUID string. + */ +var UUID = function () +{ + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) + { + var r = Math.random() * 16 | 0; + var v = (c === 'x') ? r : (r & 0x3 | 0x8); + + return v.toString(16); + }); +}; + +module.exports = UUID; + + +/***/ }), +/* 324 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(36); +var GetBoolean = __webpack_require__(94); +var GetValue = __webpack_require__(4); +var Sprite = __webpack_require__(57); +var TWEEN_CONST = __webpack_require__(93); +var Vector2 = __webpack_require__(3); + +/** + * Settings for a PathFollower. + * + * @typedef {object} PathConfig + * + * @property {number} duration - The duration of the path follow. + * @property {number} from - The start position of the path follow, between 0 and 1. + * @property {number} to - The end position of the path follow, between 0 and 1. + * @property {boolean} [positionOnPath=false] - Whether to position the PathFollower on the Path using its path offset. + * @property {boolean} [rotateToPath=false] - Should the PathFollower automatically rotate to point in the direction of the Path? + * @property {number} [rotationOffset=0] - If the PathFollower is rotating to match the Path, this value is added to the rotation value. This allows you to rotate objects to a path but control the angle of the rotation as well. + * @property {boolean} [verticalAdjust=false] - [description] + */ + +/** + * @classdesc + * A PathFollower Game Object. + * + * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. + * + * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, + * scale it and so on. + * + * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start + * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate + * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. + * + * @class PathFollower + * @extends Phaser.GameObjects.Sprite + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this PathFollower belongs. + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var PathFollower = new Class({ + + Extends: Sprite, + + initialize: + + function PathFollower (scene, path, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + + /** + * The Path this PathFollower is following. It can only follow one Path at a time. + * + * @name Phaser.GameObjects.PathFollower#path + * @type {Phaser.Curves.Path} + * @since 3.0.0 + */ + this.path = path; + + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + * + * @name Phaser.GameObjects.PathFollower#rotateToPath + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotateToPath = false; + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pathRotationVerticalAdjust = false; + + /** + * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) + * this value is added to the rotation value. This allows you to rotate objects to a path but control + * the angle of the rotation as well. + * + * @name Phaser.GameObjects.PathFollower#pathRotationOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pathRotationOffset = 0; + + /** + * An additional vector to add to the PathFollowers position, allowing you to offset it from the + * Path coordinates. + * + * @name Phaser.GameObjects.PathFollower#pathOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathOffset = new Vector2(x, y); + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathVector + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathVector = new Vector2(); + + /** + * The Tween used for following the Path. + * + * @name Phaser.GameObjects.PathFollower#pathTween + * @type {Phaser.Tweens.Tween} + * @since 3.0.0 + */ + this.pathTween; + + /** + * Settings for the PathFollower. + * + * @name Phaser.GameObjects.PathFollower#pathConfig + * @type {?PathConfig} + * @default null + * @since 3.0.0 + */ + this.pathConfig = null; + + /** + * Records the direction of the follower so it can change direction. + * + * @name Phaser.GameObjects.PathFollower#_prevDirection + * @type {integer} + * @private + * @since 3.0.0 + */ + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + }, + + /** + * Set the Path that this PathFollower should follow. + * + * Optionally accepts {@link PathConfig} settings. + * + * @method Phaser.GameObjects.PathFollower#setPath + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @param {PathConfig} [config] - Settings for the PathFollower. + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setPath: function (path, config) + { + if (config === undefined) { config = this.pathConfig; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + this.path = path; + + if (config) + { + this.startFollow(config); + } + + return this; + }, + + /** + * Set whether the PathFollower should automatically rotate to point in the direction of the Path. + * + * @method Phaser.GameObjects.PathFollower#setRotateToPath + * @since 3.0.0 + * + * @param {boolean} value - Whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param {number} [offset=0] - Rotation offset in degrees. + * @param {boolean} [verticalAdjust=false] - [description] + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setRotateToPath: function (value, offset, verticalAdjust) + { + if (offset === undefined) { offset = 0; } + if (verticalAdjust === undefined) { verticalAdjust = false; } + + this.rotateToPath = value; + + this.pathRotationOffset = offset; + this.pathRotationVerticalAdjust = verticalAdjust; + + return this; + }, + + /** + * Is this PathFollower actively following a Path or not? + * + * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + * + * @method Phaser.GameObjects.PathFollower#isFollowing + * @since 3.0.0 + * + * @return {boolean} `true` is this PathFollower is actively following a Path, otherwise `false`. + */ + isFollowing: function () + { + var tween = this.pathTween; + + return (tween && tween.isPlaying()); + }, + + /** + * Starts this PathFollower following its given Path. + * + * @method Phaser.GameObjects.PathFollower#startFollow + * @since 3.3.0 + * + * @param {(number|PathConfig)} [config={}] - The duration of the follow, or a PathFollower config object. + * @param {number} [startAt=0] - Optional start position of the follow, between 0 and 1. + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + startFollow: function (config, startAt) + { + if (config === undefined) { config = {}; } + if (startAt === undefined) { startAt = 0; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + if (typeof config === 'number') + { + config = { duration: config }; + } + + // Override in case they've been specified in the config + config.from = 0; + config.to = 1; + + // Can also read extra values out of the config: + + var positionOnPath = GetBoolean(config, 'positionOnPath', false); + + this.rotateToPath = GetBoolean(config, 'rotateToPath', false); + this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); + this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); + + this.pathTween = this.scene.sys.tweens.addCounter(config); + + // The starting point of the path, relative to this follower + this.path.getStartPoint(this.pathOffset); + + if (positionOnPath) + { + this.x = this.pathOffset.x; + this.y = this.pathOffset.y; + } + + this.pathOffset.x = this.x - this.pathOffset.x; + this.pathOffset.y = this.y - this.pathOffset.y; + + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + + if (this.rotateToPath) + { + // Set the rotation now (in case the tween has a delay on it, etc) + var nextPoint = this.path.getPoint(0.1); + + this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); + } + + this.pathConfig = config; + + return this; + }, + + /** + * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the + * point on the Path at which you paused it. + * + * @method Phaser.GameObjects.PathFollower#pauseFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + pauseFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.pause(); + } + + return this; + }, + + /** + * Resumes a previously paused PathFollower. + * + * If the PathFollower was not paused this has no effect. + * + * @method Phaser.GameObjects.PathFollower#resumeFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + resumeFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPaused()) + { + tween.resume(); + } + + return this; + }, + + /** + * Stops this PathFollower from following the path any longer. + * + * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + * + * @method Phaser.GameObjects.PathFollower#stopFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + stopFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + return this; + }, + + /** + * Internal update handler that advances this PathFollower along the path. + * + * Called automatically by the Scene step, should not typically be called directly. + * + * @method Phaser.GameObjects.PathFollower#preUpdate + * @protected + * @since 3.0.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. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + + var tween = this.pathTween; + + if (tween) + { + var tweenData = tween.data[0]; + + if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) + { + // If delayed, etc then bail out + return; + } + + var pathVector = this.pathVector; + + this.path.getPoint(tween.getValue(), pathVector); + + pathVector.add(this.pathOffset); + + var oldX = this.x; + var oldY = this.y; + + this.setPosition(pathVector.x, pathVector.y); + + var speedX = this.x - oldX; + var speedY = this.y - oldY; + + if (speedX === 0 && speedY === 0) + { + // Bail out early + return; + } + + if (tweenData.state !== this._prevDirection) + { + // We've changed direction, so don't do a rotate this frame + this._prevDirection = tweenData.state; + + return; + } + + if (this.rotateToPath) + { + this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); + + if (this.pathRotationVerticalAdjust) + { + this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); + } + } + } + } + +}); + +module.exports = PathFollower; + + +/***/ }), +/* 325 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @callback RandomZoneSourceCallback + * + * @param {Phaser.Math.Vector2} point - A point to modify. + */ + +/** + * @typedef {object} RandomZoneSource + * + * @property {RandomZoneSourceCallback} getRandomPoint - A function modifying its point argument. + * + * @see Phaser.Geom.Circle + * @see Phaser.Geom.Ellipse + * @see Phaser.Geom.Line + * @see Phaser.Geom.Polygon + * @see Phaser.Geom.Rectangle + * @see Phaser.Geom.Triangle + */ + +/** + * @classdesc + * A zone that places particles randomly within a shape's area. + * + * @class RandomZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {RandomZoneSource} source - An object instance with a `getRandomPoint(point)` method. + */ +var RandomZone = new Class({ + + initialize: + + function RandomZone (source) + { + /** + * An object instance with a `getRandomPoint(point)` method. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#source + * @type {RandomZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * Internal calculation vector. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tempVec = new Vector2(); + }, + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * + * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle. + */ + getPoint: function (particle) + { + var vec = this._tempVec; + + this.source.getRandomPoint(vec); + + particle.x = vec.x; + particle.y = vec.y; + } + +}); + +module.exports = RandomZone; + + +/***/ }), +/* 326 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Verifies that an object contains at least one of the requested keys + * + * @function Phaser.Utils.Objects.HasAny + * @since 3.0.0 + * + * @param {object} source - an object on which to check for key existence + * @param {string[]} keys - an array of keys to search the object for + * + * @return {boolean} true if the source object contains at least one of the keys, false otherwise + */ +var HasAny = function (source, keys) +{ + for (var i = 0; i < keys.length; i++) + { + if (source.hasOwnProperty(keys[i])) + { + return true; + } + } + + return false; +}; + +module.exports = HasAny; + + +/***/ }), +/* 327 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Generate a random floating point number between the two given bounds, minimum inclusive, maximum exclusive. + * + * @function Phaser.Math.FloatBetween + * @since 3.0.0 + * + * @param {number} min - The lower bound for the float, inclusive. + * @param {number} max - The upper bound for the float exclusive. + * + * @return {number} A random float within the given range. + */ +var FloatBetween = function (min, max) +{ + return Math.random() * (max - min) + min; +}; + +module.exports = FloatBetween; + + +/***/ }), +/* 328 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback EdgeZoneSourceCallback + * + * @param {integer} quantity - The number of particles to place on the source edge. If 0, `stepRate` should be used instead. + * @param {number} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to `0`. + * + * @return {Phaser.Geom.Point[]} - The points placed on the source edge. + */ + +/** + * @typedef {object} EdgeZoneSource + * + * @property {EdgeZoneSourceCallback} getPoints - A function placing points on the source's edge or edges. + * + * @see Phaser.Curves.Curve + * @see Phaser.Curves.Path + * @see Phaser.Geom.Circle + * @see Phaser.Geom.Ellipse + * @see Phaser.Geom.Line + * @see Phaser.Geom.Polygon + * @see Phaser.Geom.Rectangle + * @see Phaser.Geom.Triangle + */ + +/** + * @classdesc + * A zone that places particles on a shape's edges. + * + * @class EdgeZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * @param {integer} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @param {number} stepRate - The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @param {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. + * @param {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. + */ +var EdgeZone = new Class({ + + initialize: + + function EdgeZone (source, quantity, stepRate, yoyo, seamless) + { + if (yoyo === undefined) { yoyo = false; } + if (seamless === undefined) { seamless = true; } + + /** + * An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source + * @type {EdgeZoneSource|RandomZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * The points placed on the source edge. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points + * @type {Phaser.Geom.Point[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + /** + * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity + * @type {integer} + * @since 3.0.0 + */ + this.quantity = quantity; + + /** + * The distance between each particle. When set, `quantity` is implied and should be set to 0. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate + * @type {number} + * @since 3.0.0 + */ + this.stepRate = stepRate; + + /** + * Whether particles are placed from start to end and then end to start. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo + * @type {boolean} + * @since 3.0.0 + */ + this.yoyo = yoyo; + + /** + * The counter used for iterating the EdgeZone's points. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.counter = -1; + + /** + * Whether one endpoint will be removed if it's identical to the other. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless + * @type {boolean} + * @since 3.0.0 + */ + this.seamless = seamless; + + /** + * An internal count of the points belonging to this EdgeZone. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._length = 0; + + /** + * An internal value used to keep track of the current iteration direction for the EdgeZone's points. + * + * 0 = forwards, 1 = backwards + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._direction = 0; + + this.updateSource(); + }, + + /** + * Update the {@link Phaser.GameObjects.Particles.Zones.EdgeZone#points} from the EdgeZone's + * {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * + * Also updates internal properties. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + updateSource: function () + { + this.points = this.source.getPoints(this.quantity, this.stepRate); + + // Remove ends? + if (this.seamless) + { + var a = this.points[0]; + var b = this.points[this.points.length - 1]; + + if (a.x === b.x && a.y === b.y) + { + this.points.pop(); + } + } + + var oldLength = this._length; + + this._length = this.points.length; + + // Adjust counter if we now have less points than before + if (this._length < oldLength && this.counter > this._length) + { + this.counter = this._length - 1; + } + + return this; + }, + + /** + * Change the EdgeZone's source. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource + * @since 3.0.0 + * + * @param {EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + changeSource: function (source) + { + this.source = source; + + return this.updateSource(); + }, + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle. + */ + getPoint: function (particle) + { + if (this._direction === 0) + { + this.counter++; + + if (this.counter >= this._length) + { + if (this.yoyo) + { + this._direction = 1; + this.counter = this._length - 1; + } + else + { + this.counter = 0; + } + } + } + else + { + this.counter--; + + if (this.counter === -1) + { + if (this.yoyo) + { + this._direction = 0; + this.counter = 0; + } + else + { + this.counter = this._length - 1; + } + } + } + + var point = this.points[this.counter]; + + if (point) + { + particle.x = point.x; + particle.y = point.y; + } + } + +}); + +module.exports = EdgeZone; + + +/***/ }), +/* 329 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback DeathZoneSourceCallback + * + * @param {number} x - The x coordinate of the particle to check against this source area. + * @param {number} y - The y coordinate of the particle to check against this source area. + * + * @return {boolean} - True if the coordinates are within the source area. + */ + +/** + * @typedef {object} DeathZoneSource + * + * @property {DeathZoneSourceCallback} contains + * + * @see Phaser.Geom.Circle + * @see Phaser.Geom.Ellipse + * @see Phaser.Geom.Polygon + * @see Phaser.Geom.Rectangle + * @see Phaser.Geom.Triangle + */ + +/** + * @classdesc + * A Death Zone. + * + * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. + * + * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own + * object as long as it includes a `contains` method for which the Particles can be tested against. + * + * @class DeathZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {DeathZoneSource} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` + */ +var DeathZone = new Class({ + + initialize: + + function DeathZone (source, killOnEnter) + { + /** + * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#source + * @type {DeathZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * Set to `true` if the Particle should be killed if it enters this zone. + * Set to `false` to kill the Particle if it leaves this zone. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter + * @type {boolean} + * @since 3.0.0 + */ + this.killOnEnter = killOnEnter; + }, + + /** + * Checks if the given Particle will be killed or not by this zone. + * + * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to be checked against this zone. + * + * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. + */ + willKill: function (particle) + { + var withinZone = this.source.contains(particle.x, particle.y); + + return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); + } + +}); + +module.exports = DeathZone; + + +/***/ }), +/* 330 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(72); +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var DeathZone = __webpack_require__(329); +var EdgeZone = __webpack_require__(328); +var EmitterOp = __webpack_require__(889); +var GetFastValue = __webpack_require__(1); +var GetRandom = __webpack_require__(178); +var HasAny = __webpack_require__(326); +var HasValue = __webpack_require__(77); +var Particle = __webpack_require__(331); +var RandomZone = __webpack_require__(325); +var Rectangle = __webpack_require__(10); +var StableSort = __webpack_require__(120); +var Vector2 = __webpack_require__(3); +var Wrap = __webpack_require__(59); + +/** + * @callback ParticleEmitterCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle associated with the call. + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - This particle emitter associated with the call. + */ + +/** + * @callback ParticleDeathCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle that died. +*/ + +/** + * @typedef {object} ParticleEmitterBounds + * + * @property {number} x - The left edge of the rectangle. + * @property {number} y - The top edge of the rectangle. + * @property {number} width - The width of the rectangle. + * @property {number} height - The height of the rectangle. + * + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + */ + +/** + * @typedef {object} ParticleEmitterBoundsAlt + * + * @property {number} x - The left edge of the rectangle. + * @property {number} y - The top edge of the rectangle. + * @property {number} w - The width of the rectangle. + * @property {number} h - The height of the rectangle. + * + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + */ + +/** + * @typedef {object} ParticleEmitterDeathZoneConfig + * + * @property {DeathZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.DeathZone#source}. + * @property {string} [type='onEnter'] - 'onEnter' or 'onLeave'. + */ + +/** + * @typedef {object} ParticleEmitterEdgeZoneConfig + * + * @property {EdgeZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * @property {string} type - 'edge'. + * @property {integer} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @property {number} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @property {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. + * @property {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. + */ + +/** + * @typedef {object} ParticleEmitterRandomZoneConfig + * + * @property {RandomZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.RandomZone#source}. + * @property {string} [type] - 'random'. + */ + +/** + * @typedef {object} ParticleEmitterConfig + * + * @property {boolean} [active] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#active}. + * @property {integer} [blendMode] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#blendMode}. + * @property {*} [callbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope} and {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. + * @property {boolean} [collideBottom] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideBottom}. + * @property {boolean} [collideLeft] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideLeft}. + * @property {boolean} [collideRight] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideRight}. + * @property {boolean} [collideTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideTop}. + * @property {boolean} [deathCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + * @property {*} [deathCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope}. + * @property {function} [emitCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + * @property {*} [emitCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. + * @property {Phaser.GameObjects.GameObject} [follow] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#follow}. + * @property {number} [frequency] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency}. + * @property {number} [gravityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityX}. + * @property {number} [gravityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityY}. + * @property {integer} [maxParticles] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxParticles}. + * @property {string} [name] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#name}. + * @property {boolean} [on] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#on}. + * @property {boolean} [particleBringToTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop}. + * @property {Phaser.GameObjects.Particles.Particle} [particleClass] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleClass}. + * @property {boolean} [radial] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#radial}. + * @property {number} [timeScale] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#timeScale}. + * @property {boolean} [trackVisible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#trackVisible}. + * @property {boolean} [visible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#visible}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [accelerationX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [accelerationY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationY} (emit only). + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [alpha] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#alpha}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [angle] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#angle} (emit only) + * @property {number|number[]|EmitterOpOnEmitCallback|object} [bounce] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#bounce} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [delay] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#delay} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [lifespan] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#lifespan} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [maxVelocityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [maxVelocityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [moveToX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [moveToY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToY} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [quantity] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity} (emit only). + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [rotate] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#rotate}. + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [scale] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setScale}. + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [scaleX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleX}. + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [scaleY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleY}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [speed] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setSpeed} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [speedX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [speedY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedY} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [tint] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#tint}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [x] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#x} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [y] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#y} (emit only). + * @property {object} [emitZone] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone}. + * @property {ParticleEmitterBounds|ParticleEmitterBoundsAlt} [bounds] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setBounds}. + * @property {object} [followOffset] - Assigns to {@link Phaser.GameObjects.Particles.ParticleEmitter#followOffset}. + * @property {number} [followOffset.x] - x-coordinate of the offset. + * @property {number} [followOffset.y] - y-coordinate of the offset. + * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]|ParticleEmitterFrameConfig} [frames] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + */ + +/** + * @typedef {object} ParticleEmitterFrameConfig + * + * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]} [frames] - One or more texture frames. + * @property {boolean} [cycle] - Whether texture frames will be assigned consecutively (true) or at random (false). + * @property {integer} [quantity] - The number of consecutive particles receiving each texture frame, when `cycle` is true. + */ + +/** + * @classdesc + * A particle emitter represents a single particle stream. + * It controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles} and is controlled by a {@link Phaser.GameObjects.Particles.ParticleEmitterManager Particle Emitter Manager}. + * + * @class ParticleEmitter + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} manager - The Emitter Manager this Emitter belongs to. + * @param {ParticleEmitterConfig} config - Settings for this emitter. + */ +var ParticleEmitter = new Class({ + + Mixins: [ + Components.BlendMode, + Components.Mask, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function ParticleEmitter (manager, config) + { + /** + * The Emitter Manager this Emitter belongs to. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#manager + * @type {Phaser.GameObjects.Particles.ParticleEmitterManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The texture assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = manager.texture; + + /** + * The texture frames assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frames + * @type {Phaser.Textures.Frame[]} + * @since 3.0.0 + */ + this.frames = [ manager.defaultFrame ]; + + /** + * The default texture frame assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#defaultFrame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.defaultFrame = manager.defaultFrame; + + /** + * Names of simple configuration properties. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configFastMap + * @type {object} + * @since 3.0.0 + */ + this.configFastMap = [ + 'active', + 'blendMode', + 'collideBottom', + 'collideLeft', + 'collideRight', + 'collideTop', + 'deathCallback', + 'deathCallbackScope', + 'emitCallback', + 'emitCallbackScope', + 'follow', + 'frequency', + 'gravityX', + 'gravityY', + 'maxParticles', + 'name', + 'on', + 'particleBringToTop', + 'particleClass', + 'radial', + 'timeScale', + 'trackVisible', + 'visible' + ]; + + /** + * Names of complex configuration properties. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configOpMap + * @type {object} + * @since 3.0.0 + */ + this.configOpMap = [ + 'accelerationX', + 'accelerationY', + 'angle', + 'alpha', + 'bounce', + 'delay', + 'lifespan', + 'maxVelocityX', + 'maxVelocityY', + 'moveToX', + 'moveToY', + 'quantity', + 'rotate', + 'scaleX', + 'scaleY', + 'speedX', + 'speedY', + 'tint', + 'x', + 'y' + ]; + + /** + * The name of this Particle Emitter. + * + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The Particle Class which will be emitted by this Emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass + * @type {Phaser.GameObjects.Particles.Particle} + * @default Phaser.GameObjects.Particles.Particle + * @since 3.0.0 + */ + this.particleClass = Particle; + + /** + * The x-coordinate of the particle origin (where particles will be emitted). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#x + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition + */ + this.x = new EmitterOp(config, 'x', 0); + + /** + * The y-coordinate of the particle origin (where particles will be emitted). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#y + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition + */ + this.y = new EmitterOp(config, 'y', 0); + + /** + * A radial emitter will emit particles in all directions between angle min and max, + * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. + * A point emitter will emit particles only in the direction derived from the speedX and speedY values. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#radial + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setRadial + */ + this.radial = true; + + /** + * Horizontal acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity + */ + this.gravityX = 0; + + /** + * Vertical acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity + */ + this.gravityY = 0; + + /** + * Whether accelerationX and accelerationY are non-zero. Set automatically during configuration. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.acceleration = false; + + /** + * Horizontal acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.accelerationX = new EmitterOp(config, 'accelerationX', 0, true); + + /** + * Vertical acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.accelerationY = new EmitterOp(config, 'accelerationY', 0, true); + + /** + * The maximum horizontal velocity of emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityX = new EmitterOp(config, 'maxVelocityX', 10000, true); + + /** + * The maximum vertical velocity of emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityY = new EmitterOp(config, 'maxVelocityY', 10000, true); + + /** + * The initial horizontal speed of emitted particles, in pixels per second. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX + */ + this.speedX = new EmitterOp(config, 'speedX', 0, true); + + /** + * The initial vertical speed of emitted particles, in pixels per second. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY + */ + this.speedY = new EmitterOp(config, 'speedY', 0, true); + + /** + * Whether moveToX and moveToY are nonzero. Set automatically during configuration. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.moveTo = false; + + /** + * The x-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.moveToX = new EmitterOp(config, 'moveToX', 0, true); + + /** + * The y-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.moveToY = new EmitterOp(config, 'moveToY', 0, true); + + /** + * Whether particles will rebound when they meet the emitter bounds. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.bounce = new EmitterOp(config, 'bounce', 0, true); + + /** + * The horizontal scale of emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleX + */ + this.scaleX = new EmitterOp(config, 'scaleX', 1); + + /** + * The vertical scale of emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleY + */ + this.scaleY = new EmitterOp(config, 'scaleY', 1); + + /** + * Color tint applied to emitted particles. Any alpha component (0xAA000000) is ignored. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#tint + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0xffffffff + * @since 3.0.0 + */ + this.tint = new EmitterOp(config, 'tint', 0xffffffff); + + /** + * The alpha (transparency) of emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alpha + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setAlpha + */ + this.alpha = new EmitterOp(config, 'alpha', 1); + + /** + * The lifespan of emitted particles, in ms. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1000 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setLifespan + */ + this.lifespan = new EmitterOp(config, 'lifespan', 1000); + + /** + * The angle of the initial velocity of emitted particles, in degrees. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#angle + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default { min: 0, max: 360 } + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setAngle + */ + this.angle = new EmitterOp(config, 'angle', { min: 0, max: 360 }); + + /** + * The rotation of emitted particles, in degrees. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#rotate + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.rotate = new EmitterOp(config, 'rotate', 0); + + /** + * A function to call when a particle is emitted. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback + * @type {?ParticleEmitterCallback} + * @default null + * @since 3.0.0 + */ + this.emitCallback = null; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.emitCallbackScope = null; + + /** + * A function to call when a particle dies. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback + * @type {?ParticleDeathCallback} + * @default null + * @since 3.0.0 + */ + this.deathCallback = null; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.deathCallbackScope = null; + + /** + * Set to hard limit the amount of particle objects this emitter is allowed to create. + * 0 means unlimited. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.maxParticles = 0; + + /** + * How many particles are emitted each time particles are emitted (one explosion or one flow cycle). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @see Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + */ + this.quantity = new EmitterOp(config, 'quantity', 1, true); + + /** + * How many ms to wait after emission before the particles start updating. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#delay + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.delay = new EmitterOp(config, 'delay', 0, true); + + /** + * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. + * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. + * For an exploding emitter, this value will be -1. + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + */ + this.frequency = 0; + + /** + * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). + * Already alive particles will continue to update until they expire. + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#on + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.on = true; + + /** + * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. + * Set to false to send them to the back. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.particleBringToTop = true; + + /** + * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * An object describing a shape to emit particles from. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZone + * @type {?Phaser.GameObjects.Particles.Zones.EdgeZone|Phaser.GameObjects.Particles.Zones.RandomZone} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + */ + this.emitZone = null; + + /** + * An object describing a shape that deactivates particles when they interact with it. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZone + * @type {?Phaser.GameObjects.Particles.Zones.DeathZone} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone + */ + this.deathZone = null; + + /** + * A rectangular boundary constraining particle movement. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounds + * @type {?Phaser.Geom.Rectangle} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + */ + this.bounds = null; + + /** + * Whether particles interact with the left edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideLeft + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideLeft = true; + + /** + * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideRight + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideRight = true; + + /** + * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideTop = true; + + /** + * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideBottom + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideBottom = true; + + /** + * Whether this emitter updates itself and its particles. + * + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#pause} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#resume}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * Set this to false to hide any active particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#visible + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setVisible + */ + this.visible = true; + + /** + * The blend mode of this emitter's particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#blendMode + * @type {integer} + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBlendMode + */ + this.blendMode = BlendModes.NORMAL; + + /** + * A Game Object whose position is used as the particle origin. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#follow + * @type {?Phaser.GameObjects.GameObject} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @see Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + */ + this.follow = null; + + /** + * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + */ + this.followOffset = new Vector2(); + + /** + * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track + * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + */ + this.trackVisible = false; + + /** + * The current texture frame, as an index of {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame + * @type {integer} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame + */ + this.currentFrame = 0; + + /** + * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame + */ + this.randomFrame = true; + + /** + * The number of consecutive particles that receive a single texture frame (per frame cycle). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity + * @type {integer} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame + */ + this.frameQuantity = 1; + + /** + * Inactive particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#dead + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.dead = []; + + /** + * Active particles + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alive + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.alive = []; + + /** + * The time until the next flow cycle. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_counter + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._counter = 0; + + /** + * Counts up to {@link Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_frameCounter + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._frameCounter = 0; + + if (config) + { + this.fromJSON(config); + } + }, + + /** + * Merges configuration settings into the emitter's current settings. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#fromJSON + * @since 3.0.0 + * + * @param {ParticleEmitterConfig} config - Settings for this emitter. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + fromJSON: function (config) + { + if (!config) + { + return this; + } + + // Only update properties from their current state if they exist in the given config + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + if (HasValue(config, key)) + { + this[key] = GetFastValue(config, key); + } + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (HasValue(config, key)) + { + this[key].loadConfig(config); + } + } + + this.acceleration = (this.accelerationX.propertyValue !== 0 || this.accelerationY.propertyValue !== 0); + + this.moveTo = (this.moveToX.propertyValue !== 0 || this.moveToY.propertyValue !== 0); + + // Special 'speed' override + + if (HasValue(config, 'speed')) + { + this.speedX.loadConfig(config, 'speed'); + this.speedY = null; + } + + // If you specify speedX, speedY or moveTo then it changes the emitter from radial to a point emitter + if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) + { + this.radial = false; + } + + // Special 'scale' override + + if (HasValue(config, 'scale')) + { + this.scaleX.loadConfig(config, 'scale'); + this.scaleY = null; + } + + if (HasValue(config, 'callbackScope')) + { + var callbackScope = GetFastValue(config, 'callbackScope', null); + + this.emitCallbackScope = callbackScope; + this.deathCallbackScope = callbackScope; + } + + if (HasValue(config, 'emitZone')) + { + this.setEmitZone(config.emitZone); + } + + if (HasValue(config, 'deathZone')) + { + this.setDeathZone(config.deathZone); + } + + if (HasValue(config, 'bounds')) + { + this.setBounds(config.bounds); + } + + if (HasValue(config, 'followOffset')) + { + this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); + } + + if (HasValue(config, 'frame')) + { + this.setFrame(config.frame); + } + + return this; + }, + + /** + * Creates a description of this emitter suitable for JSON serialization. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON + * @since 3.0.0 + * + * @param {object} [output] - An object to copy output into. + * + * @return {object} - The output object. + */ + toJSON: function (output) + { + if (output === undefined) { output = {}; } + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + output[key] = this[key]; + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (this[key]) + { + output[key] = this[key].toJSON(); + } + } + + // special handlers + if (!this.speedY) + { + delete output.speedX; + output.speed = this.speedX.toJSON(); + } + + if (!this.scaleY) + { + delete output.scaleX; + output.scale = this.scaleX.toJSON(); + } + + return output; + }, + + /** + * Continuously moves the particle origin to follow a Game Object's position. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} target - The Game Object to follow. + * @param {number} [offsetX=0] - Horizontal offset of the particle origin from the Game Object. + * @param {number} [offsetY=0] - Vertical offset of the particle origin from the Game Object. + * @param {boolean} [trackVisible=false] - Whether the emitter's visible state will track the target's visible state. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + startFollow: function (target, offsetX, offsetY, trackVisible) + { + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + if (trackVisible === undefined) { trackVisible = false; } + + this.follow = target; + this.followOffset.set(offsetX, offsetY); + this.trackVisible = trackVisible; + + return this; + }, + + /** + * Stops following a Game Object. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stopFollow: function () + { + this.follow = null; + this.followOffset.set(0, 0); + this.trackVisible = false; + + return this; + }, + + /** + * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} The texture frame. + */ + getFrame: function () + { + if (this.frames.length === 1) + { + return this.defaultFrame; + } + else if (this.randomFrame) + { + return GetRandom(this.frames); + } + else + { + var frame = this.frames[this.currentFrame]; + + this._frameCounter++; + + if (this._frameCounter === this.frameQuantity) + { + this._frameCounter = 0; + this.currentFrame = Wrap(this.currentFrame + 1, 0, this._frameLength); + } + + return frame; + } + }, + + // frame: 0 + // frame: 'red' + // frame: [ 0, 1, 2, 3 ] + // frame: [ 'red', 'green', 'blue', 'pink', 'white' ] + // frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } + + /** + * Sets a pattern for assigning texture frames to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrame + * @since 3.0.0 + * + * @param {(array|string|integer|ParticleEmitterFrameConfig)} frames - One or more texture frames, or a configuration object. + * @param {boolean} [pickRandom=true] - Whether frames should be assigned at random from `frames`. + * @param {integer} [quantity=1] - The number of consecutive particles that will receive each frame. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrame: function (frames, pickRandom, quantity) + { + if (pickRandom === undefined) { pickRandom = true; } + if (quantity === undefined) { quantity = 1; } + + this.randomFrame = pickRandom; + this.frameQuantity = quantity; + this.currentFrame = 0; + this._frameCounter = 0; + + var t = typeof (frames); + + if (Array.isArray(frames) || t === 'string' || t === 'number') + { + this.manager.setEmitterFrames(frames, this); + } + else if (t === 'object') + { + var frameConfig = frames; + + frames = GetFastValue(frameConfig, 'frames', null); + + if (frames) + { + this.manager.setEmitterFrames(frames, this); + } + + var isCycle = GetFastValue(frameConfig, 'cycle', false); + + this.randomFrame = (isCycle) ? false : true; + + this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); + } + + this._frameLength = this.frames.length; + + if (this._frameLength === 1) + { + this.frameQuantity = 1; + this.randomFrame = false; + } + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial + * @since 3.0.0 + * + * @param {boolean} [value=true] - Radial mode (true) or point mode (true). + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setRadial: function (value) + { + if (value === undefined) { value = true; } + + this.radial = value; + + return this; + }, + + /** + * Sets the position of the emitter's particle origin. + * New particles will be emitted here. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} x - The x-coordinate of the particle origin. + * @param {number|float[]|EmitterOpOnEmitCallback|object} y - The y-coordinate of the particle origin. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setPosition: function (x, y) + { + this.x.onChange(x); + this.y.onChange(y); + + return this; + }, + + /** + * Sets or modifies a rectangular boundary constraining the particles. + * + * To remove the boundary, set {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds} to null. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setBounds + * @since 3.0.0 + * + * @param {(number|ParticleEmitterBounds|ParticleEmitterBoundsAlt)} x - The x-coordinate of the left edge of the boundary, or an object representing a rectangle. + * @param {number} y - The y-coordinate of the top edge of the boundary. + * @param {number} width - The width of the boundary. + * @param {number} height - The height of the boundary. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setBounds: function (x, y, width, height) + { + if (typeof x === 'object') + { + var obj = x; + + x = obj.x; + y = obj.y; + width = (HasValue(obj, 'w')) ? obj.w : obj.width; + height = (HasValue(obj, 'h')) ? obj.h : obj.height; + } + + if (this.bounds) + { + this.bounds.setTo(x, y, width, height); + } + else + { + this.bounds = new Rectangle(x, y, width, height); + } + + return this; + }, + + /** + * Sets the initial horizontal speed of emitted particles. + * Changes the emitter to point mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedX: function (value) + { + this.speedX.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + + return this; + }, + + /** + * Sets the initial vertical speed of emitted particles. + * Changes the emitter to point mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedY: function (value) + { + if (this.speedY) + { + this.speedY.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + } + + return this; + }, + + /** + * Sets the initial radial speed of emitted particles. + * Changes the emitter to radial mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeed: function (value) + { + this.speedX.onChange(value); + this.speedY = null; + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = true; + + return this; + }, + + /** + * Sets the horizontal scale of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleX: function (value) + { + this.scaleX.onChange(value); + + return this; + }, + + /** + * Sets the vertical scale of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleY: function (value) + { + this.scaleY.onChange(value); + + return this; + }, + + /** + * Sets the scale of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScale: function (value) + { + this.scaleX.onChange(value); + this.scaleY = null; + + return this; + }, + + /** + * Sets the horizontal gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX + * @since 3.0.0 + * + * @param {number} value - Acceleration due to gravity, in pixels per second squared. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityX: function (value) + { + this.gravityX = value; + + return this; + }, + + /** + * Sets the vertical gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY + * @since 3.0.0 + * + * @param {number} value - Acceleration due to gravity, in pixels per second squared. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityY: function (value) + { + this.gravityY = value; + + return this; + }, + + /** + * Sets the gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity + * @since 3.0.0 + * + * @param {number} x - Horizontal acceleration due to gravity, in pixels per second squared. + * @param {number} y - Vertical acceleration due to gravity, in pixels per second squared. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravity: function (x, y) + { + this.gravityX = x; + this.gravityY = y; + + return this; + }, + + /** + * Sets the opacity of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - A value between 0 (transparent) and 1 (opaque). + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAlpha: function (value) + { + this.alpha.onChange(value); + + return this; + }, + + /** + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitterAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * Sets the lifespan of newly emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The particle lifespan, in ms. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setLifespan: function (value) + { + this.lifespan.onChange(value); + + return this; + }, + + /** + * Sets the number of particles released at each flow cycle or explosion. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} quantity - The number of particles to release at each flow cycle or explosion. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setQuantity: function (quantity) + { + this.quantity.onChange(quantity); + + return this; + }, + + /** + * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @since 3.0.0 + * + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [quantity] - The number of particles to release at each flow cycle or explosion. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrequency: function (frequency, quantity) + { + this.frequency = frequency; + + this._counter = 0; + + if (quantity) + { + this.quantity.onChange(quantity); + } + + return this; + }, + + /** + * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#emitZone}. + * + * An {@link ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. Its {@link EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link EdgeZoneSourceCallback getPoints} method. + * + * A {@link ParticleEmitterRandomZoneConfig RandomZone} places randomly within its interior. Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link RandomZoneSourceCallback getRandomPoint} method. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + * @since 3.0.0 + * + * @param {ParticleEmitterEdgeZoneConfig|ParticleEmitterRandomZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current emit zone. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.emitZone = null; + } + else + { + // Where source = Geom like Circle, or a Path or Curve + // emitZone: { type: 'random', source: X } + // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] } + + var type = GetFastValue(zoneConfig, 'type', 'random'); + var source = GetFastValue(zoneConfig, 'source', null); + + switch (type) + { + case 'random': + + this.emitZone = new RandomZone(source); + + break; + + case 'edge': + + var quantity = GetFastValue(zoneConfig, 'quantity', 1); + var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); + var yoyo = GetFastValue(zoneConfig, 'yoyo', false); + var seamless = GetFastValue(zoneConfig, 'seamless', true); + + this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); + + break; + } + } + + return this; + }, + + /** + * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#deathZone}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone + * @since 3.0.0 + * + * @param {ParticleEmitterDeathZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current death zone. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setDeathZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.deathZone = null; + } + else + { + // Where source = Geom like Circle or Rect that supports a 'contains' function + // deathZone: { type: 'onEnter', source: X } + // deathZone: { type: 'onLeave', source: X } + + var type = GetFastValue(zoneConfig, 'type', 'onEnter'); + var source = GetFastValue(zoneConfig, 'source', null); + + if (source && typeof source.contains === 'function') + { + var killOnEnter = (type === 'onEnter') ? true : false; + + this.deathZone = new DeathZone(source, killOnEnter); + } + } + + return this; + }, + + /** + * Creates inactive particles and adds them to this emitter's pool. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve + * @since 3.0.0 + * + * @param {integer} particleCount - The number of particles to create. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + reserve: function (particleCount) + { + var dead = this.dead; + + for (var i = 0; i < particleCount; i++) + { + dead.push(new this.particleClass(this)); + } + + return this; + }, + + /** + * Gets the number of active (in-use) particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount + * @since 3.0.0 + * + * @return {integer} The number of particles with `active=true`. + */ + getAliveParticleCount: function () + { + return this.alive.length; + }, + + /** + * Gets the number of inactive (available) particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount + * @since 3.0.0 + * + * @return {integer} The number of particles with `active=false`. + */ + getDeadParticleCount: function () + { + return this.dead.length; + }, + + /** + * Gets the total number of particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount + * @since 3.0.0 + * + * @return {integer} The number of particles, including both alive and dead. + */ + getParticleCount: function () + { + return this.getAliveParticleCount() + this.getDeadParticleCount(); + }, + + /** + * Whether this emitter is at its limit (if set). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. + */ + atLimit: function () + { + return (this.maxParticles > 0 && this.getParticleCount() === this.maxParticles); + }, + + /** + * Sets a function to call for each newly emitted particle. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - The function. + * @param {*} [context] - The calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleEmit: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.emitCallback = null; + this.emitCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.emitCallback = callback; + + if (context) + { + this.emitCallbackScope = context; + } + } + + return this; + }, + + /** + * Sets a function to call for each particle death. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath + * @since 3.0.0 + * + * @param {ParticleDeathCallback} callback - The function. + * @param {*} [context] - The function's calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleDeath: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.deathCallback = null; + this.deathCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.deathCallback = callback; + + if (context) + { + this.deathCallbackScope = context; + } + } + + return this; + }, + + /** + * Deactivates every particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + killAll: function () + { + var dead = this.dead; + var alive = this.alive; + + while (alive.length > 0) + { + dead.push(alive.pop()); + } + + return this; + }, + + /** + * Calls a function for each active particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - The function. + * @param {*} context - The function's calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachAlive: function (callback, context) + { + var alive = this.alive; + var length = alive.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(context, alive[index], this); + } + + return this; + }, + + /** + * Calls a function for each inactive particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - The function. + * @param {*} context - The function's calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachDead: function (callback, context) + { + var dead = this.dead; + var length = dead.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(context, dead[index], this); + } + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. + * + * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). + * + * If this emitter is in explode mode (frequency = -1), nothing will happen. + * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#start + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + start: function () + { + this.on = true; + + this._counter = 0; + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on off} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stop + * @since 3.11.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stop: function () + { + this.on = false; + + return this; + }, + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + depthSort: function () + { + StableSort.inplace(this.alive, this.depthSortCallback); + + return this; + }, + + /** + * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. + * + * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#flow + * @since 3.0.0 + * + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [count=1] - The number of particles to emit at each flow cycle. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + flow: function (frequency, count) + { + if (count === undefined) { count = 1; } + + this.frequency = frequency; + + this.quantity.onChange(count); + + return this.start(); + }, + + /** + * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#explode + * @since 3.0.0 + * + * @param {integer} count - The amount of Particles to emit. + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + explode: function (count, x, y) + { + this.frequency = -1; + + return this.emitParticle(count, x, y); + }, + + /** + * Emits particles at a given position (or the emitter's current position). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt + * @since 3.0.0 + * + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. + * @param {integer} [count=this.quantity] - The number of Particles to emit. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * Emits particles at a given position (or the emitter's current position). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle + * @since 3.0.0 + * + * @param {integer} [count=this.quantity] - The number of Particles to emit. + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + * + * @see Phaser.GameObjects.Particles.Particle#fire + */ + emitParticle: function (count, x, y) + { + if (this.atLimit()) + { + return; + } + + if (count === undefined) + { + count = this.quantity.onEmit(); + } + + var dead = this.dead; + + for (var i = 0; i < count; i++) + { + var particle; + + if (dead.length > 0) + { + particle = dead.pop(); + } + else + { + particle = new this.particleClass(this); + } + + particle.fire(x, y); + + if (this.particleBringToTop) + { + this.alive.push(particle); + } + else + { + this.alive.unshift(particle); + } + + if (this.emitCallback) + { + this.emitCallback.call(this.emitCallbackScope, particle, this); + } + + if (this.atLimit()) + { + break; + } + } + + return particle; + }, + + /** + * Updates this emitter and its particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate + * @since 3.0.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. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var step = (delta / 1000); + + if (this.trackVisible) + { + this.visible = this.follow.visible; + } + + // Any particle processors? + var processors = this.manager.getProcessors(); + + var particles = this.alive; + var length = particles.length; + + for (var index = 0; index < length; index++) + { + var particle = particles[index]; + + // update returns `true` if the particle is now dead (lifeStep < 0) + if (particle.update(delta, step, processors)) + { + // Moves the dead particle to the end of the particles array (ready for splicing out later) + var last = particles[length - 1]; + + particles[length - 1] = particle; + particles[index] = last; + + index -= 1; + length -= 1; + } + } + + // Move dead particles to the dead array + var deadLength = particles.length - length; + + if (deadLength > 0) + { + var rip = particles.splice(particles.length - deadLength, deadLength); + + var deathCallback = this.deathCallback; + var deathCallbackScope = this.deathCallbackScope; + + if (deathCallback) + { + for (var i = 0; i < rip.length; i++) + { + deathCallback.call(deathCallbackScope, rip[i]); + } + } + + this.dead.concat(rip); + + StableSort.inplace(particles, this.indexSortCallback); + } + + if (!this.on) + { + return; + } + + if (this.frequency === 0) + { + this.emitParticle(); + } + else if (this.frequency > 0) + { + this._counter -= delta; + + if (this._counter <= 0) + { + this.emitParticle(); + + // counter = frequency - remained from previous delta + this._counter = (this.frequency - Math.abs(this._counter)); + } + } + }, + + /** + * Calculates the difference of two particles, for sorting them by depth. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback + * @since 3.0.0 + * + * @param {object} a - The first particle. + * @param {object} b - The second particle. + * + * @return {integer} The difference of a and b's y coordinates. + */ + depthSortCallback: function (a, b) + { + return a.y - b.y; + }, + + /** + * Calculates the difference of two particles, for sorting them by index. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback + * @since 3.0.0 + * + * @param {object} a - The first particle. + * @param {object} b - The second particle. + * + * @return {integer} The difference of a and b's `index` properties. + */ + indexSortCallback: function (a, b) + { + return a.index - b.index; + } + +}); + +module.exports = ParticleEmitter; + + +/***/ }), +/* 331 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(36); +var DistanceBetween = __webpack_require__(58); + +/** + * @classdesc + * A Particle is a simple Game Object controlled by a Particle Emitter and Manager, and rendered by the Manager. + * It uses its own lightweight physics system, and can interact only with its Emitter's bounds and zones. + * + * @class Particle + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to which this Particle belongs. + */ +var Particle = new Class({ + + initialize: + + function Particle (emitter) + { + /** + * The Emitter to which this Particle belongs. + * + * A Particle can only belong to a single Emitter and is created, updated and destroyed via it. + * + * @name Phaser.GameObjects.Particles.Particle#emitter + * @type {Phaser.GameObjects.Particles.ParticleEmitter} + * @since 3.0.0 + */ + this.emitter = emitter; + + /** + * The texture frame used to render this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#frame + * @type {Phaser.Textures.Frame} + * @default null + * @since 3.0.0 + */ + this.frame = null; + + /** + * The position of this Particle within its Emitter's particle pool. + * + * @name Phaser.GameObjects.Particles.Particle#index + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.index = 0; + + /** + * The x coordinate of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y coordinate of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The x velocity of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#velocityX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.velocityX = 0; + + /** + * The y velocity of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#velocityY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.velocityY = 0; + + /** + * The x acceleration of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#accelerationX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationX = 0; + + /** + * The y acceleration of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#accelerationY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationY = 0; + + /** + * The maximum horizontal velocity this Particle can travel at. + * + * @name Phaser.GameObjects.Particles.Particle#maxVelocityX + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityX = 10000; + + /** + * The maximum vertical velocity this Particle can travel at. + * + * @name Phaser.GameObjects.Particles.Particle#maxVelocityY + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityY = 10000; + + /** + * The bounciness, or restitution, of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#bounce + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.bounce = 0; + + /** + * The horizontal scale of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.scaleX = 1; + + /** + * The vertical scale of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.scaleY = 1; + + /** + * The alpha value of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#alpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.alpha = 1; + + /** + * The angle of this Particle in degrees. + * + * @name Phaser.GameObjects.Particles.Particle#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angle = 0; + + /** + * The angle of this Particle in radians. + * + * @name Phaser.GameObjects.Particles.Particle#rotation + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rotation = 0; + + /** + * The tint applied to this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#tint + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + this.tint = 0xffffff; + + /** + * The lifespan of this Particle in ms. + * + * @name Phaser.GameObjects.Particles.Particle#life + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.life = 1000; + + /** + * The current life of this Particle in ms. + * + * @name Phaser.GameObjects.Particles.Particle#lifeCurrent + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.lifeCurrent = 1000; + + /** + * The delay applied to this Particle upon emission, in ms. + * + * @name Phaser.GameObjects.Particles.Particle#delayCurrent + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.delayCurrent = 0; + + /** + * The normalized lifespan T value, where 0 is the start and 1 is the end. + * + * @name Phaser.GameObjects.Particles.Particle#lifeT + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lifeT = 0; + + /** + * The data used by the ease equation. + * + * @name Phaser.GameObjects.Particles.Particle#data + * @type {object} + * @since 3.0.0 + */ + this.data = { + tint: { min: 0xffffff, max: 0xffffff, current: 0xffffff }, + alpha: { min: 1, max: 1 }, + rotate: { min: 0, max: 0 }, + scaleX: { min: 1, max: 1 }, + scaleY: { min: 1, max: 1 } + }; + }, + + /** + * Checks to see if this Particle is alive and updating. + * + * @method Phaser.GameObjects.Particles.Particle#isAlive + * @since 3.0.0 + * + * @return {boolean} `true` if this Particle is alive and updating, otherwise `false`. + */ + isAlive: function () + { + return (this.lifeCurrent > 0); + }, + + /** + * Starts this Particle from the given coordinates. + * + * @method Phaser.GameObjects.Particles.Particle#fire + * @since 3.0.0 + * + * @param {number} x - The x coordinate to launch this Particle from. + * @param {number} y - The y coordinate to launch this Particle from. + */ + fire: function (x, y) + { + var emitter = this.emitter; + + this.frame = emitter.getFrame(); + + if (emitter.emitZone) + { + // Updates particle.x and particle.y during this call + emitter.emitZone.getPoint(this); + } + + if (x === undefined) + { + if (emitter.follow) + { + this.x += emitter.follow.x + emitter.followOffset.x; + } + + this.x += emitter.x.onEmit(this, 'x'); + } + else + { + this.x += x; + } + + if (y === undefined) + { + if (emitter.follow) + { + this.y += emitter.follow.y + emitter.followOffset.y; + } + + this.y += emitter.y.onEmit(this, 'y'); + } + else + { + this.y += y; + } + + this.life = emitter.lifespan.onEmit(this, 'lifespan'); + this.lifeCurrent = this.life; + this.lifeT = 0; + + var sx = emitter.speedX.onEmit(this, 'speedX'); + var sy = (emitter.speedY) ? emitter.speedY.onEmit(this, 'speedY') : sx; + + if (emitter.radial) + { + var rad = DegToRad(emitter.angle.onEmit(this, 'angle')); + + this.velocityX = Math.cos(rad) * Math.abs(sx); + this.velocityY = Math.sin(rad) * Math.abs(sy); + } + else if (emitter.moveTo) + { + var mx = emitter.moveToX.onEmit(this, 'moveToX'); + var my = (emitter.moveToY) ? emitter.moveToY.onEmit(this, 'moveToY') : mx; + + var angle = Math.atan2(my - this.y, mx - this.x); + + var speed = DistanceBetween(this.x, this.y, mx, my) / (this.life / 1000); + + // We know how many pixels we need to move, but how fast? + // var speed = this.distanceToXY(displayObject, x, y) / (maxTime / 1000); + + this.velocityX = Math.cos(angle) * speed; + this.velocityY = Math.sin(angle) * speed; + } + else + { + this.velocityX = sx; + this.velocityY = sy; + } + + if (emitter.acceleration) + { + this.accelerationX = emitter.accelerationX.onEmit(this, 'accelerationX'); + this.accelerationY = emitter.accelerationY.onEmit(this, 'accelerationY'); + } + + this.maxVelocityX = emitter.maxVelocityX.onEmit(this, 'maxVelocityX'); + this.maxVelocityY = emitter.maxVelocityY.onEmit(this, 'maxVelocityY'); + + this.delayCurrent = emitter.delay.onEmit(this, 'delay'); + + this.scaleX = emitter.scaleX.onEmit(this, 'scaleX'); + this.scaleY = (emitter.scaleY) ? emitter.scaleY.onEmit(this, 'scaleY') : this.scaleX; + + this.angle = emitter.rotate.onEmit(this, 'rotate'); + this.rotation = DegToRad(this.angle); + + this.bounce = emitter.bounce.onEmit(this, 'bounce'); + + this.alpha = emitter.alpha.onEmit(this, 'alpha'); + + this.tint = emitter.tint.onEmit(this, 'tint'); + + this.index = emitter.alive.length; + }, + + /** + * An internal method that calculates the velocity of the Particle. + * + * @method Phaser.GameObjects.Particles.Particle#computeVelocity + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter that is updating this Particle. + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + * @param {array} processors - Particle processors (gravity wells). + */ + computeVelocity: function (emitter, delta, step, processors) + { + var vx = this.velocityX; + var vy = this.velocityY; + + var ax = this.accelerationX; + var ay = this.accelerationY; + + var mx = this.maxVelocityX; + var my = this.maxVelocityY; + + vx += (emitter.gravityX * step); + vy += (emitter.gravityY * step); + + if (ax) + { + vx += (ax * step); + } + + if (ay) + { + vy += (ay * step); + } + + if (vx > mx) + { + vx = mx; + } + else if (vx < -mx) + { + vx = -mx; + } + + if (vy > my) + { + vy = my; + } + else if (vy < -my) + { + vy = -my; + } + + this.velocityX = vx; + this.velocityY = vy; + + // Apply any additional processors + for (var i = 0; i < processors.length; i++) + { + processors[i].update(this, delta, step); + } + }, + + /** + * Checks if this Particle is still within the bounds defined by the given Emitter. + * + * If not, and depending on the Emitter collision flags, the Particle may either stop or rebound. + * + * @method Phaser.GameObjects.Particles.Particle#checkBounds + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to check the bounds against. + */ + checkBounds: function (emitter) + { + var bounds = emitter.bounds; + var bounce = -this.bounce; + + if (this.x < bounds.x && emitter.collideLeft) + { + this.x = bounds.x; + this.velocityX *= bounce; + } + else if (this.x > bounds.right && emitter.collideRight) + { + this.x = bounds.right; + this.velocityX *= bounce; + } + + if (this.y < bounds.y && emitter.collideTop) + { + this.y = bounds.y; + this.velocityY *= bounce; + } + else if (this.y > bounds.bottom && emitter.collideBottom) + { + this.y = bounds.bottom; + this.velocityY *= bounce; + } + }, + + /** + * The main update method for this Particle. + * + * Updates its life values, computes the velocity and repositions the Particle. + * + * @method Phaser.GameObjects.Particles.Particle#update + * @since 3.0.0 + * + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + * @param {array} processors - An optional array of update processors. + * + * @return {boolean} Returns `true` if this Particle has now expired and should be removed, otherwise `false` if still active. + */ + update: function (delta, step, processors) + { + if (this.delayCurrent > 0) + { + this.delayCurrent -= delta; + + return false; + } + + var emitter = this.emitter; + + // How far along in life is this particle? (t = 0 to 1) + var t = 1 - (this.lifeCurrent / this.life); + + this.lifeT = t; + + this.computeVelocity(emitter, delta, step, processors); + + this.x += this.velocityX * step; + this.y += this.velocityY * step; + + if (emitter.bounds) + { + this.checkBounds(emitter); + } + + if (emitter.deathZone && emitter.deathZone.willKill(this)) + { + this.lifeCurrent = 0; + + // No need to go any further, particle has been killed + return true; + } + + this.scaleX = emitter.scaleX.onUpdate(this, 'scaleX', t, this.scaleX); + + if (emitter.scaleY) + { + this.scaleY = emitter.scaleY.onUpdate(this, 'scaleY', t, this.scaleY); + } + else + { + this.scaleY = this.scaleX; + } + + this.angle = emitter.rotate.onUpdate(this, 'rotate', t, this.angle); + this.rotation = DegToRad(this.angle); + + this.alpha = emitter.alpha.onUpdate(this, 'alpha', t, this.alpha); + + this.tint = emitter.tint.onUpdate(this, 'tint', t, this.tint); + + this.lifeCurrent -= delta; + + return (this.lifeCurrent <= 0); + } + +}); + +module.exports = Particle; + + +/***/ }), +/* 332 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(1); + +/** + * @typedef {object} GravityWellConfig + * + * @property {number} [x=0] - The x coordinate of the Gravity Well, in world space. + * @property {number} [y=0] - The y coordinate of the Gravity Well, in world space. + * @property {number} [power=0] - The power of the Gravity Well. + * @property {number} [epsilon=100] - [description] + * @property {number} [gravity=50] - The gravitational force of this Gravity Well. + */ + +/** + * @classdesc + * [description] + * + * @class GravityWell + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {(number|GravityWellConfig)} [x=0] - The x coordinate of the Gravity Well, in world space. + * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. + * @param {number} [power=0] - The power of the Gravity Well. + * @param {number} [epsilon=100] - [description] + * @param {number} [gravity=50] - The gravitational force of this Gravity Well. + */ +var GravityWell = new Class({ + + initialize: + + function GravityWell (x, y, power, epsilon, gravity) + { + if (typeof x === 'object') + { + var config = x; + + x = GetFastValue(config, 'x', 0); + y = GetFastValue(config, 'y', 0); + power = GetFastValue(config, 'power', 0); + epsilon = GetFastValue(config, 'epsilon', 100); + gravity = GetFastValue(config, 'gravity', 50); + } + else + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (power === undefined) { power = 0; } + if (epsilon === undefined) { epsilon = 100; } + if (gravity === undefined) { gravity = 50; } + } + + /** + * The x coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. + * + * @name Phaser.GameObjects.Particles.GravityWell#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * Internal gravity value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_gravity + * @type {number} + * @private + * @since 3.0.0 + */ + this._gravity = gravity; + + /** + * Internal power value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_power + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._power = 0; + + /** + * Internal epsilon value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_epsilon + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._epsilon = 0; + + /** + * The power of the Gravity Well. + * + * @name Phaser.GameObjects.Particles.GravityWell#power + * @type {number} + * @since 3.0.0 + */ + this.power = power; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.GravityWell#epsilon + * @type {number} + * @since 3.0.0 + */ + this.epsilon = epsilon; + }, + + /** + * Takes a Particle and updates it based on the properties of this Gravity Well. + * + * @method Phaser.GameObjects.Particles.GravityWell#update + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + */ + update: function (particle, delta) + { + var x = this.x - particle.x; + var y = this.y - particle.y; + var dSq = x * x + y * y; + + if (dSq === 0) + { + return; + } + + var d = Math.sqrt(dSq); + + if (dSq < this._epsilon) + { + dSq = this._epsilon; + } + + var factor = ((this._power * delta) / (dSq * d)) * 100; + + particle.velocityX += x * factor; + particle.velocityY += y * factor; + }, + + epsilon: { + + get: function () + { + return Math.sqrt(this._epsilon); + }, + + set: function (value) + { + this._epsilon = value * value; + } + + }, + + power: { + + get: function () + { + return this._power / this._gravity; + }, + + set: function (value) + { + this._power = value * this._gravity; + } + + }, + + gravity: { + + get: function () + { + return this._gravity; + }, + + set: function (value) + { + var pwr = this.power; + this._gravity = value; + this.power = pwr; + } + + } + +}); + +module.exports = GravityWell; + + +/***/ }), +/* 333 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Commands = __webpack_require__(173); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Graphics#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + * @param {CanvasRenderingContext2D} [renderTargetCtx] - The target rendering context. + * @param {boolean} allowClip - If `true` then path operations will be used instead of fill operations. + */ +var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) +{ + var commandBuffer = src.commandBuffer; + var commandBufferLength = commandBuffer.length; + + var ctx = renderTargetCtx || renderer.currentContext; + + if (commandBufferLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + var lineAlpha = 1; + var fillAlpha = 1; + var lineColor = 0; + var fillColor = 0; + var lineWidth = 1; + var red = 0; + var green = 0; + var blue = 0; + + ctx.save(); + + // Reset any currently active paths + ctx.beginPath(); + + for (var index = 0; index < commandBufferLength; ++index) + { + var commandID = commandBuffer[index]; + + switch (commandID) + { + case Commands.ARC: + ctx.arc( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4], + commandBuffer[index + 5], + commandBuffer[index + 6] + ); + + // +7 because overshoot is the 7th value, not used in Canvas + index += 7; + break; + + case Commands.LINE_STYLE: + lineWidth = commandBuffer[index + 1]; + lineColor = commandBuffer[index + 2]; + lineAlpha = commandBuffer[index + 3]; + red = ((lineColor & 0xFF0000) >>> 16); + green = ((lineColor & 0xFF00) >>> 8); + blue = (lineColor & 0xFF); + ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + lineAlpha + ')'; + ctx.lineWidth = lineWidth; + index += 3; + break; + + case Commands.FILL_STYLE: + fillColor = commandBuffer[index + 1]; + fillAlpha = commandBuffer[index + 2]; + red = ((fillColor & 0xFF0000) >>> 16); + green = ((fillColor & 0xFF00) >>> 8); + blue = (fillColor & 0xFF); + ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; + index += 2; + break; + + case Commands.BEGIN_PATH: + ctx.beginPath(); + break; + + case Commands.CLOSE_PATH: + ctx.closePath(); + break; + + case Commands.FILL_PATH: + if (!allowClip) + { + ctx.fill(); + } + break; + + case Commands.STROKE_PATH: + if (!allowClip) + { + ctx.stroke(); + } + break; + + case Commands.FILL_RECT: + if (!allowClip) + { + ctx.fillRect( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4] + ); + } + else + { + ctx.rect( + commandBuffer[index + 1], + commandBuffer[index + 2], + commandBuffer[index + 3], + commandBuffer[index + 4] + ); + } + index += 4; + break; + + case Commands.FILL_TRIANGLE: + ctx.beginPath(); + ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); + ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); + ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); + ctx.closePath(); + if (!allowClip) + { + ctx.fill(); + } + index += 6; + break; + + case Commands.STROKE_TRIANGLE: + ctx.beginPath(); + ctx.moveTo(commandBuffer[index + 1], commandBuffer[index + 2]); + ctx.lineTo(commandBuffer[index + 3], commandBuffer[index + 4]); + ctx.lineTo(commandBuffer[index + 5], commandBuffer[index + 6]); + ctx.closePath(); + if (!allowClip) + { + ctx.stroke(); + } + index += 6; + break; + + case Commands.LINE_TO: + ctx.lineTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.MOVE_TO: + ctx.moveTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.LINE_FX_TO: + ctx.lineTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 5; + break; + + case Commands.MOVE_FX_TO: + ctx.moveTo( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 5; + break; + + case Commands.SAVE: + ctx.save(); + break; + + case Commands.RESTORE: + ctx.restore(); + break; + + case Commands.TRANSLATE: + ctx.translate( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.SCALE: + ctx.scale( + commandBuffer[index + 1], + commandBuffer[index + 2] + ); + index += 2; + break; + + case Commands.ROTATE: + ctx.rotate( + commandBuffer[index + 1] + ); + index += 1; + break; + + case Commands.GRADIENT_FILL_STYLE: + index += 5; + break; + + case Commands.GRADIENT_LINE_STYLE: + index += 6; + break; + + case Commands.SET_TEXTURE: + index += 2; + break; + } + } + + ctx.restore(); +}; + +module.exports = GraphicsCanvasRenderer; + + +/***/ }), +/* 334 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the circumference of the given Ellipse. + * + * @function Phaser.Geom.Ellipse.Circumference + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference of. + * + * @return {number} The circumference of th Ellipse. + */ +var Circumference = function (ellipse) +{ + var rx = ellipse.width / 2; + var ry = ellipse.height / 2; + var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2); + + return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h))))); +}; + +module.exports = Circumference; + + +/***/ }), +/* 335 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circumference = __webpack_require__(334); +var CircumferencePoint = __webpack_require__(172); +var FromPercent = __webpack_require__(103); +var MATH_CONST = __webpack_require__(18); + +/** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Ellipse, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Ellipse.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the ellipse and dividing it by the stepRate. + * @param {(array|Phaser.Geom.Point[])} [out] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {(array|Phaser.Geom.Point[])} An array of Point objects pertaining to the points around the circumference of the ellipse. + */ +var GetPoints = function (ellipse, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Circumference(ellipse) / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); + + out.push(CircumferencePoint(ellipse, angle)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 336 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircumferencePoint = __webpack_require__(172); +var FromPercent = __webpack_require__(103); +var MATH_CONST = __webpack_require__(18); +var Point = __webpack_require__(6); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @function Phaser.Geom.Ellipse.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. + */ +var GetPoint = function (ellipse, position, out) +{ + if (out === undefined) { out = new Point(); } + + var angle = FromPercent(position, 0, MATH_CONST.PI2); + + return CircumferencePoint(ellipse, angle, out); +}; + +module.exports = GetPoint; + + +/***/ }), +/* 337 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. + * + * @function Phaser.Geom.Rectangle.Union + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to use. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to use. + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the union in. + * + * @return {Phaser.Geom.Rectangle} The modified `out` Rectangle, or a new Rectangle if none was provided. + */ +var Union = function (rectA, rectB, out) +{ + if (out === undefined) { out = new Rectangle(); } + + // Cache vars so we can use one of the input rects as the output rect + var x = Math.min(rectA.x, rectB.x); + var y = Math.min(rectA.y, rectB.y); + var w = Math.max(rectA.right, rectB.right) - x; + var h = Math.max(rectA.bottom, rectB.bottom) - y; + + return out.setTo(x, y, w, h); +}; + +module.exports = Union; + + +/***/ }), +/* 338 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Read an integer value from an XML Node. + * + * @function getValue + * @since 3.0.0 + * @private + * + * @param {Node} node - The XML Node. + * @param {string} attribute - The attribute to read. + * + * @return {integer} The parsed value. + */ +function getValue (node, attribute) +{ + return parseInt(node.getAttribute(attribute), 10); +} + +/** + * Parse an XML font to Bitmap Font data for the Bitmap Font cache. + * + * @function ParseXMLBitmapFont + * @since 3.0.0 + * @private + * + * @param {XMLDocument} xml - The XML Document to parse the font from. + * @param {integer} [xSpacing=0] - The x-axis spacing to add between each letter. + * @param {integer} [ySpacing=0] - The y-axis spacing to add to the line height. + * @param {Phaser.Textures.Frame} [frame] - The texture frame to take into account while parsing. + * + * @return {BitmapFontData} The parsed Bitmap Font data. + */ +var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame) +{ + if (xSpacing === undefined) { xSpacing = 0; } + if (ySpacing === undefined) { ySpacing = 0; } + + var data = {}; + var info = xml.getElementsByTagName('info')[0]; + var common = xml.getElementsByTagName('common')[0]; + + data.font = info.getAttribute('face'); + data.size = getValue(info, 'size'); + data.lineHeight = getValue(common, 'lineHeight') + ySpacing; + data.chars = {}; + + var letters = xml.getElementsByTagName('char'); + + var adjustForTrim = (frame !== undefined && frame.trimmed); + + if (adjustForTrim) + { + var top = frame.height; + var left = frame.width; + } + + for (var i = 0; i < letters.length; i++) + { + var node = letters[i]; + + var charCode = getValue(node, 'id'); + var gx = getValue(node, 'x'); + var gy = getValue(node, 'y'); + var gw = getValue(node, 'width'); + var gh = getValue(node, 'height'); + + // Handle frame trim issues + + if (adjustForTrim) + { + if (gx < left) + { + left = gx; + } + + if (gy < top) + { + top = gy; + } + } + + data.chars[charCode] = + { + x: gx, + y: gy, + width: gw, + height: gh, + centerX: Math.floor(gw / 2), + centerY: Math.floor(gh / 2), + xOffset: getValue(node, 'xoffset'), + yOffset: getValue(node, 'yoffset'), + xAdvance: getValue(node, 'xadvance') + xSpacing, + data: {}, + kerning: {} + }; + } + + if (adjustForTrim && top !== 0 && left !== 0) + { + // console.log('top and left', top, left, frame.x, frame.y); + + // Now we know the top and left coordinates of the glyphs in the original data + // so we can work out how much to adjust the glyphs by + + for (var code in data.chars) + { + var glyph = data.chars[code]; + + glyph.x -= frame.x; + glyph.y -= frame.y; + } + } + + var kernings = xml.getElementsByTagName('kerning'); + + for (i = 0; i < kernings.length; i++) + { + var kern = kernings[i]; + + var first = getValue(kern, 'first'); + var second = getValue(kern, 'second'); + var amount = getValue(kern, 'amount'); + + data.chars[second].kerning[first] = amount; + } + + return data; +}; + +module.exports = ParseXMLBitmapFont; + + +/***/ }), +/* 339 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAdvancedValue = __webpack_require__(13); + +/** + * Adds an Animation component to a Sprite and populates it based on the given config. + * + * @function Phaser.GameObjects.BuildGameObjectAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - The sprite to add an Animation component to. + * @param {object} config - The animation config. + * + * @return {Phaser.GameObjects.Sprite} The updated Sprite. + */ +var BuildGameObjectAnimation = function (sprite, config) +{ + var animConfig = GetAdvancedValue(config, 'anims', null); + + if (animConfig === null) + { + return sprite; + } + + if (typeof animConfig === 'string') + { + // { anims: 'key' } + sprite.anims.play(animConfig); + } + else if (typeof animConfig === 'object') + { + // { anims: { + // key: string + // startFrame: [string|integer] + // delay: [float] + // repeat: [integer] + // repeatDelay: [float] + // yoyo: [boolean] + // play: [boolean] + // delayedPlay: [boolean] + // } + // } + + var anims = sprite.anims; + + var key = GetAdvancedValue(animConfig, 'key', undefined); + var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); + + var delay = GetAdvancedValue(animConfig, 'delay', 0); + var repeat = GetAdvancedValue(animConfig, 'repeat', 0); + var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); + var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); + + var play = GetAdvancedValue(animConfig, 'play', false); + var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); + + anims.setDelay(delay); + anims.setRepeat(repeat); + anims.setRepeatDelay(repeatDelay); + anims.setYoyo(yoyo); + + if (play) + { + anims.play(key, startFrame); + } + else if (delayedPlay > 0) + { + anims.delayedPlay(delayedPlay, key, startFrame); + } + else + { + anims.load(key); + } + } + + return sprite; +}; + +module.exports = BuildGameObjectAnimation; + + +/***/ }), +/* 340 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); +var Shuffle = __webpack_require__(132); + +var BuildChunk = function (a, b, qty) +{ + var out = []; + + for (var aIndex = 0; aIndex < a.length; aIndex++) + { + for (var bIndex = 0; bIndex < b.length; bIndex++) + { + for (var i = 0; i < qty; i++) + { + out.push({ a: a[aIndex], b: b[bIndex] }); + } + } + } + + return out; +}; + +// options = repeat, random, randomB, yoyo, max, qty + +// Range ([a,b,c], [1,2,3]) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2,3], qty = 3) = +// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 + +// Range ([a,b,c], [1,2,3], repeat x1) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = +// Maybe if max is set then repeat goes to -1 automatically? +// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) + +// Range ([a], [1,2,3,4,5], random = true) = +// a4, a1, a5, a2, a3 + +// Range ([a, b], [1,2,3], random = true) = +// b3, a2, a1, b1, a3, b2 + +// Range ([a, b, c], [1,2,3], randomB = true) = +// a3, a1, a2, b2, b3, b1, c1, c3, c2 + +// Range ([a], [1,2,3,4,5], yoyo = true) = +// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 + +// Range ([a, b], [1,2,3], yoyo = true) = +// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 + +/** + * [description] + * + * @function Phaser.Utils.Array.Range + * @since 3.0.0 + * + * @param {array} a - [description] + * @param {array} b - [description] + * @param {object} options - [description] + * + * @return {array} [description] + */ +var Range = function (a, b, options) +{ + var max = GetValue(options, 'max', 0); + var qty = GetValue(options, 'qty', 1); + var random = GetValue(options, 'random', false); + var randomB = GetValue(options, 'randomB', false); + var repeat = GetValue(options, 'repeat', 0); + var yoyo = GetValue(options, 'yoyo', false); + + var out = []; + + if (randomB) + { + Shuffle(b); + } + + // Endless repeat, so limit by max + if (repeat === -1) + { + if (max === 0) + { + repeat = 0; + } + else + { + // Work out how many repeats we need + var total = (a.length * b.length) * qty; + + if (yoyo) + { + total *= 2; + } + + repeat = Math.ceil(max / total); + } + } + + for (var i = 0; i <= repeat; i++) + { + var chunk = BuildChunk(a, b, qty); + + if (random) + { + Shuffle(chunk); + } + + out = out.concat(chunk); + + if (yoyo) + { + chunk.reverse(); + + out = out.concat(chunk); + } + } + + if (max) + { + out.splice(max); + } + + return out; +}; + +module.exports = Range; + + +/***/ }), +/* 341 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// This is from the quickselect npm package: https://www.npmjs.com/package/quickselect +// Coded by https://www.npmjs.com/~mourner (Vladimir Agafonkin) + +// https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm + +// Floyd-Rivest selection algorithm: +// Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right]; +// The k-th element will have the (k - left + 1)th smallest value in [left, right] + +/** + * [description] + * + * @function Phaser.Utils.Array.QuickSelect + * @since 3.0.0 + * + * @param {array} arr - [description] + * @param {number} k - [description] + * @param {number} left - [description] + * @param {number} right - [description] + * @param {function} compare - [description] + */ +var QuickSelect = function (arr, k, left, right, compare) +{ + left = left || 0; + right = right || (arr.length - 1); + compare = compare || defaultCompare; + + while (right > left) + { + if (right - left > 600) + { + var n = right - left + 1; + var m = k - left + 1; + var z = Math.log(n); + var s = 0.5 * Math.exp(2 * z / 3); + var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1); + var newLeft = Math.max(left, Math.floor(k - m * s / n + sd)); + var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd)); + + QuickSelect(arr, k, newLeft, newRight, compare); + } + + var t = arr[k]; + var i = left; + var j = right; + + swap(arr, left, k); + + if (compare(arr[right], t) > 0) + { + swap(arr, left, right); + } + + while (i < j) + { + swap(arr, i, j); + + i++; + j--; + + while (compare(arr[i], t) < 0) + { + i++; + } + + while (compare(arr[j], t) > 0) + { + j--; + } + } + + if (compare(arr[left], t) === 0) + { + swap(arr, left, j); + } + else + { + j++; + swap(arr, j, right); + } + + if (j <= k) + { + left = j + 1; + } + + if (k <= j) + { + right = j - 1; + } + } +}; + +function swap (arr, i, j) +{ + var tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} + +function defaultCompare (a, b) +{ + return a < b ? -1 : a > b ? 1 : 0; +} + +module.exports = QuickSelect; + + +/***/ }), +/* 342 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Round a given number so it is further away from zero. That is, positive numbers are rounded up, and negative numbers are rounded down. + * + * @function Phaser.Math.RoundAwayFromZero + * @since 3.0.0 + * + * @param {number} value - The number to round. + * + * @return {number} The rounded number, rounded away from zero. + */ +var RoundAwayFromZero = function (value) +{ + // "Opposite" of truncate. + return (value > 0) ? Math.ceil(value) : Math.floor(value); +}; + +module.exports = RoundAwayFromZero; + + +/***/ }), +/* 343 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Transposes the elements of the given matrix (array of arrays). +// The transpose of a matrix is a new matrix whose rows are the columns of the original. + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.TransposeMatrix + * @since 3.0.0 + * + * @param {array} array - The array matrix to transpose. + * + * @return {array} A new array matrix which is a transposed version of the given array. + */ +var TransposeMatrix = function (array) +{ + var sourceRowCount = array.length; + var sourceColCount = array[0].length; + + var result = new Array(sourceColCount); + + for (var i = 0; i < sourceColCount; i++) + { + result[i] = new Array(sourceRowCount); + + for (var j = sourceRowCount - 1; j > -1; j--) + { + result[i][j] = array[j][i]; + } + } + + return result; +}; + +module.exports = TransposeMatrix; + + +/***/ }), +/* 344 */ +/***/ (function(module, exports, __webpack_require__) { + +/* eslint no-console: 0 */ + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AdInstance = __webpack_require__(948); +var Class = __webpack_require__(0); +var DataManager = __webpack_require__(102); +var EventEmitter = __webpack_require__(11); +var Leaderboard = __webpack_require__(947); +var Product = __webpack_require__(945); +var Purchase = __webpack_require__(944); + +/** + * @classdesc + * The Facebook Instant Games Plugin for Phaser 3 provides a seamless bridge between Phaser + * and the Facebook Instant Games API version 6.2. + * + * You can access this plugin via the `facebook` property in a Scene, i.e: + * + * ```javascript + * this.facebook.getPlatform(); + * ``` + * + * If this is unavailable please check to make sure you're using a build of Phaser that has + * this plugin within it. You can quickly check this by looking at the dev tools console + * header - the Phaser version number will have `-FB` after it if this plugin is loaded. + * + * If you are building your own version of Phaser then use this Webpack DefinePlugin flag: + * + * `"typeof PLUGIN_FBINSTANT": JSON.stringify(true)` + * + * You will find that every Instant Games API method has a mapping in this plugin. + * For a full list please consult either the plugin documentation, or the 6.2 SDK documentation + * at https://developers.facebook.com/docs/games/instant-games/sdk/fbinstant6.2 + * + * Internally this plugin uses its own Data Manager to handle seamless user data updates and provides + * handy functions for advertisement displaying, opening share dialogs, logging, leaderboards, purchase API requests, + * loader integration and more. + * + * To get started with Facebook Instant Games you will need to register on Facebook and create a new Instant + * Game app that has its own unique app ID. Facebook have also provided a dashboard interface for setting up + * various features for your game, including leaderboards, ad requests and the payments API. There are lots + * of guides on the Facebook Developers portal to assist with setting these + * various systems up: https://developers.facebook.com/docs/games/instant-games/guides + * + * For more details follow the Quick Start guide here: https://developers.facebook.com/docs/games/instant-games + * + * @class FacebookInstantGamesPlugin + * @memberOf Phaser + * @constructor + * @extends Phaser.Events.EventEmitter + * @since 3.13.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance. + */ +var FacebookInstantGamesPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function FacebookInstantGamesPlugin (game) + { + EventEmitter.call(this); + + /** + * A reference to the Phaser.Game instance. + * + * @name Phaser.FacebookInstantGamesPlugin#game + * @type {Phaser.Game} + * @readOnly + * @since 3.13.0 + */ + this.game = game; + + /** + * A Data Manager instance. + * It allows you to store, query and retrieve any key/value data you may need to store. + * It's also used internally by the plugin to store FBIG API data. + * + * @name Phaser.FacebookInstantGamesPlugin#data + * @type {Phaser.Data.DataManager} + * @since 3.13.0 + */ + this.data = new DataManager(this); + + this.on('setdata', this.setDataHandler, this); + this.on('changedata', this.changeDataHandler, this); + + /** + * Has the Facebook Instant Games API loaded yet? + * This is set automatically during the boot process. + * + * @name Phaser.FacebookInstantGamesPlugin#hasLoaded + * @type {boolean} + * @since 3.13.0 + */ + this.hasLoaded = false; + + /** + * Is the Data Manager currently locked? + * + * @name Phaser.FacebookInstantGamesPlugin#dataLocked + * @type {boolean} + * @since 3.13.0 + */ + this.dataLocked = false; + + /** + * A list of the Facebook Instant Games APIs that are available, + * based on the given platform, context and user privacy settings. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#supportedAPIs + * @type {string[]} + * @since 3.13.0 + */ + this.supportedAPIs = []; + + /** + * Holds the entry point that the game was launched from. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#entryPoint + * @type {string} + * @since 3.13.0 + */ + this.entryPoint = ''; + + /** + * An object that contains any data associated with the entry point that the game was launched from. + * The contents of the object are developer-defined, and can occur from entry points on different platforms. + * This will return null for older mobile clients, as well as when there is no data associated with the particular entry point. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#entryPointData + * @type {any} + * @since 3.13.0 + */ + this.entryPointData = null; + + /** + * A unique identifier for the current game context. This represents a specific context + * that the game is being played in (for example, a particular messenger conversation or facebook post). + * The identifier will be null if game is being played in a solo context. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#contextID + * @type {string} + * @since 3.13.0 + */ + this.contextID = null; + + /** + * The current context in which your game is running. This can be either `null` or + * one of: + * + * `POST` - The game is running inside of a Facebook post. + * `THREAD` - The game is running inside a Facebook Messenger thread. + * `GROUP` - The game is running inside a Facebook Group. + * `SOLO` - This is the default context, the player is the only participant. + * + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#contextType + * @type {?string} + * @since 3.13.0 + */ + this.contextType = null; + + /** + * The current locale. + * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. + * Use this to determine what languages the current game should be localized with. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#locale + * @type {?string} + * @since 3.13.0 + */ + this.locale = null; + + /** + * The platform on which the game is currently running, i.e. `IOS`. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#platform + * @type {?string} + * @since 3.13.0 + */ + this.platform = null; + + /** + * The string representation of the Facebook Instant Games SDK version being used. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#version + * @type {?string} + * @since 3.13.0 + */ + this.version = null; + + /** + * Holds the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. + * This value is populated automatically during boot if the API is supported. + * + * @name Phaser.FacebookInstantGamesPlugin#playerID + * @type {?string} + * @since 3.13.0 + */ + this.playerID = null; + + /** + * The player's localized display name. + * This value is populated automatically during boot if the API is supported. + * + * @name Phaser.FacebookInstantGamesPlugin#playerName + * @type {?string} + * @since 3.13.0 + */ + this.playerName = null; + + /** + * A url to the player's public profile photo. The photo will always be a square, and with dimensions + * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. + * It's recommended to always scale the image to a desired size before rendering. + * This value is populated automatically during boot if the API is supported. + * + * @name Phaser.FacebookInstantGamesPlugin#playerPhotoURL + * @type {?string} + * @since 3.13.0 + */ + this.playerPhotoURL = null; + + /** + * Whether a player can subscribe to the game bot or not. + * + * @name Phaser.FacebookInstantGamesPlugin#playerCanSubscribeBot + * @type {boolean} + * @since 3.13.0 + */ + this.playerCanSubscribeBot = false; + + /** + * Does the current platform and context allow for use of the payments API? + * Currently this is only available on Facebook.com and Android 6+. + * + * @name Phaser.FacebookInstantGamesPlugin#paymentsReady + * @type {boolean} + * @since 3.13.0 + */ + this.paymentsReady = false; + + /** + * The set of products that are registered to the game. + * + * @name Phaser.FacebookInstantGamesPlugin#catalog + * @type {Product[]} + * @since 3.13.0 + */ + this.catalog = []; + + /** + * Contains all of the player's unconsumed purchases. + * The game must fetch the current player's purchases as soon as the client indicates that it is ready to perform payments-related operations, + * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. + * + * @name Phaser.FacebookInstantGamesPlugin#purchases + * @type {Purchase[]} + * @since 3.13.0 + */ + this.purchases = []; + + /** + * Contains all of the leaderboard data, as populated by the `getLeaderboard()` method. + * + * @name Phaser.FacebookInstantGamesPlugin#leaderboards + * @type {Phaser.FacebookInstantGamesPlugin.Leaderboard[]} + * @since 3.13.0 + */ + this.leaderboards = {}; + + /** + * Contains AdInstance objects, as created by the `preloadAds()` method. + * + * @name Phaser.FacebookInstantGamesPlugin#ads + * @type {AdInstance[]} + * @since 3.13.0 + */ + this.ads = []; + }, + + /** + * Internal set data handler. + * + * @method Phaser.FacebookInstantGamesPlugin#setDataHandler + * @private + * @since 3.13.0 + * + * @param {Phaser.Data.DataManager} parent - The parent Data Manager instance. + * @param {string} key - The key of the data. + * @param {any} value - The value of the data. + */ + setDataHandler: function (parent, key, value) + { + if (this.dataLocked) + { + return; + } + + var data = {}; + + data[key] = value; + + var _this = this; + + FBInstant.player.setDataAsync(data).then(function () + { + _this.emit('savedata', data); + }); + }, + + /** + * Internal change data handler. + * + * @method Phaser.FacebookInstantGamesPlugin#changeDataHandler + * @private + * @since 3.13.0 + * + * @param {Phaser.Data.DataManager} parent - The parent Data Manager instance. + * @param {string} key - The key of the data. + * @param {any} value - The value of the data. + */ + changeDataHandler: function (parent, key, value) + { + if (this.dataLocked) + { + return; + } + + var data = {}; + + data[key] = value; + + var _this = this; + + FBInstant.player.setDataAsync(data).then(function () + { + _this.emit('savedata', data); + }); + }, + + /** + * Call this method from your `Scene.preload` in order to sync the load progress + * of the Phaser Loader with the Facebook Instant Games loader display, i.e.: + * + * ```javascript + * this.facebook.showLoadProgress(this); + * this.facebook.once('startgame', this.startGame, this); + * ``` + * + * @method Phaser.FacebookInstantGamesPlugin#showLoadProgress + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene for which you want to show loader progress for. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + showLoadProgress: function (scene) + { + scene.load.on('progress', function (value) + { + if (!this.hasLoaded) + { + FBInstant.setLoadingProgress(value * 100); + } + + }, this); + + scene.load.on('complete', function () + { + if (!this.hasLoaded) + { + this.hasLoaded = true; + + FBInstant.startGameAsync().then(this.gameStarted.bind(this)); + } + + }, this); + + return this; + }, + + /** + * This method is called automatically when the game has finished loading, + * if you used the `showLoadProgress` method. If your game doesn't need to + * load any assets, or you're managing the load yourself, then call this + * method directly to start the API running. + * + * When the API has finished starting this plugin will emit a `startgame` event + * which you should listen for. + * + * @method Phaser.FacebookInstantGamesPlugin#gameStarted + * @since 3.13.0 + */ + gameStarted: function () + { + var APIs = FBInstant.getSupportedAPIs(); + + var supported = {}; + + var dotToUpper = function (match) + { + return match[1].toUpperCase(); + }; + + APIs.forEach(function (api) + { + api = api.replace(/\../g, dotToUpper); + + supported[api] = true; + }); + + this.supportedAPIs = supported; + + this.getID(); + this.getType(); + this.getLocale(); + this.getPlatform(); + this.getSDKVersion(); + + this.getPlayerID(); + this.getPlayerName(); + this.getPlayerPhotoURL(); + + var _this = this; + + FBInstant.onPause(function () + { + _this.emit('pause'); + }); + + FBInstant.getEntryPointAsync().then(function (entrypoint) + { + _this.entryPoint = entrypoint; + _this.entryPointData = FBInstant.getEntryPointData(); + + _this.emit('startgame'); + + }).catch(function (e) + { + console.warn(e); + }); + + // Facebook.com and Android 6 only + if (this.supportedAPIs.paymentsPurchaseAsync) + { + FBInstant.payments.onReady(function () + { + _this.paymentsReady = true; + + }).catch(function (e) + { + console.warn(e); + }); + } + }, + + /** + * Checks to see if a given Facebook Instant Games API is available or not. + * + * @method Phaser.FacebookInstantGamesPlugin#checkAPI + * @since 3.13.0 + * + * @param {string} api - The API to check for, i.e. `player.getID`. + * + * @return {boolean} `true` if the API is supported, otherwise `false`. + */ + checkAPI: function (api) + { + if (!this.supportedAPIs[api]) + { + return false; + } + else + { + return true; + } + }, + + /** + * Returns the unique identifier for the current game context. This represents a specific context + * that the game is being played in (for example, a particular messenger conversation or facebook post). + * The identifier will be null if game is being played in a solo context. + * + * It is only populated if `contextGetID` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getID + * @since 3.13.0 + * + * @return {string} The context ID. + */ + getID: function () + { + if (!this.contextID && this.supportedAPIs.contextGetID) + { + this.contextID = FBInstant.context.getID(); + } + + return this.contextID; + }, + + /** + * Returns the current context in which your game is running. This can be either `null` or one of: + * + * `POST` - The game is running inside of a Facebook post. + * `THREAD` - The game is running inside a Facebook Messenger thread. + * `GROUP` - The game is running inside a Facebook Group. + * `SOLO` - This is the default context, the player is the only participant. + * + * It is only populated if `contextGetType` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getType + * @since 3.13.0 + * + * @return {?string} The context type. + */ + getType: function () + { + if (!this.contextType && this.supportedAPIs.contextGetType) + { + this.contextType = FBInstant.context.getType(); + } + + return this.contextType; + }, + + /** + * Returns the current locale. + * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. + * Use this to determine what languages the current game should be localized with. + * It is only populated if `getLocale` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getLocale + * @since 3.13.0 + * + * @return {?string} The current locale. + */ + getLocale: function () + { + if (!this.locale && this.supportedAPIs.getLocale) + { + this.locale = FBInstant.getLocale(); + } + + return this.locale; + }, + + /** + * Returns the platform on which the game is currently running, i.e. `IOS`. + * It is only populated if `getPlatform` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlatform + * @since 3.13.0 + * + * @return {?string} The current platform. + */ + getPlatform: function () + { + if (!this.platform && this.supportedAPIs.getPlatform) + { + this.platform = FBInstant.getPlatform(); + } + + return this.platform; + }, + + /** + * Returns the string representation of the Facebook Instant Games SDK version being used. + * It is only populated if `getSDKVersion` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getSDKVersion + * @since 3.13.0 + * + * @return {?string} The sdk version. + */ + getSDKVersion: function () + { + if (!this.version && this.supportedAPIs.getSDKVersion) + { + this.version = FBInstant.getSDKVersion(); + } + + return this.version; + }, + + /** + * Returns the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. + * It is only populated if `playerGetID` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlayerID + * @since 3.13.0 + * + * @return {?string} The player ID. + */ + getPlayerID: function () + { + if (!this.playerID && this.supportedAPIs.playerGetID) + { + this.playerID = FBInstant.player.getID(); + } + + return this.playerID; + }, + + /** + * Returns the player's localized display name. + * It is only populated if `playerGetName` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlayerName + * @since 3.13.0 + * + * @return {?string} The player's localized display name. + */ + getPlayerName: function () + { + if (!this.playerName && this.supportedAPIs.playerGetName) + { + this.playerName = FBInstant.player.getName(); + } + + return this.playerName; + }, + + /** + * Returns the url to the player's public profile photo. The photo will always be a square, and with dimensions + * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. + * It's recommended to always scale the image to a desired size before rendering. + * It is only populated if `playerGetPhoto` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlayerPhotoURL + * @since 3.13.0 + * + * @return {?string} The player's photo url. + */ + getPlayerPhotoURL: function () + { + if (!this.playerPhotoURL && this.supportedAPIs.playerGetPhoto) + { + this.playerPhotoURL = FBInstant.player.getPhoto(); + } + + return this.playerPhotoURL; + }, + + /** + * Load the player's photo and store it in the Texture Manager, ready for use in-game. + * + * This method works by using a Scene Loader instance and then asking the Loader to + * retrieve the image. + * + * When complete the plugin will emit a `photocomplete` event, along with the key of the photo. + * + * ```javascript + * this.facebook.loadPlayerPhoto(this, 'player').once('photocomplete', function (key) { + * this.add.image(x, y, 'player); + * }, this); + * ``` + * + * @method Phaser.FacebookInstantGamesPlugin#loadPlayerPhoto + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene that will be responsible for loading this photo. + * @param {string} key - The key to use when storing the photo in the Texture Manager. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + loadPlayerPhoto: function (scene, key) + { + if (this.playerPhotoURL) + { + scene.load.setCORS('anonymous'); + + scene.load.image(key, this.playerPhotoURL); + + scene.load.once('filecomplete_image_' + key, function () + { + this.emit('photocomplete', key); + + }, this); + + scene.load.start(); + } + + return this; + }, + + /** + * Checks if the current player can subscribe to the game bot. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they can subscribe, the `playerCanSubscribeBot` property is set to `true` + * and this plugin will emit the `cansubscribebot` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `cansubscribebotfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#canSubscribeBot + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + canSubscribeBot: function () + { + if (this.supportedAPIs.playerCanSubscribeBotAsync) + { + var _this = this; + + FBInstant.player.canSubscribeBotAsync().then(function () + { + _this.playerCanSubscribeBot = true; + + _this.emit('cansubscribebot'); + + }).catch(function (e) + { + _this.emit('cansubscribebotfail', e); + }); + } + else + { + this.emit('cansubscribebotfail'); + } + + return this; + }, + + /** + * Subscribes the current player to the game bot. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `subscribebot` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `subscribebotfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#subscribeBot + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + subscribeBot: function () + { + if (this.playerCanSubscribeBot) + { + var _this = this; + + FBInstant.player.subscribeBotAsync().then(function () + { + _this.emit('subscribebot'); + + }).catch(function (e) + { + _this.emit('subscribebotfail', e); + }); + } + else + { + this.emit('subscribebotfail'); + } + + return this; + }, + + /** + * Gets the associated data from the player based on the given key, or array of keys. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the data is set into this plugins Data Manager and the + * `getdata` event will be emitted. + * + * @method Phaser.FacebookInstantGamesPlugin#getData + * @since 3.13.0 + * + * @param {(string|string[])} keys - The key/s of the data to retrieve. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getData: function (keys) + { + if (!this.checkAPI('playerGetDataAsync')) + { + return this; + } + + if (!Array.isArray(keys)) + { + keys = [ keys ]; + } + + var _this = this; + + FBInstant.player.getDataAsync(keys).then(function (data) + { + _this.dataLocked = true; + + for (var key in data) + { + _this.data.set(key, data[key]); + } + + _this.dataLocked = false; + + _this.emit('getdata', data); + }); + + return this; + }, + + /** + * Set data to be saved to the designated cloud storage of the current player. The game can store up to 1MB of data for each unique player. + * + * The data save is requested in an async call, so the result isn't available immediately. + * + * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this + * method directly if you need to replace the data object directly. + * + * When the APIs `setDataAsync` call resolves it will emit the `savedata` event from this plugin. If the call fails for some + * reason it will emit `savedatafail` instead. + * + * The call resolving does not necessarily mean that the input has already been persisted. Rather, it means that the data was valid and + * has been scheduled to be saved. It also guarantees that all values that were set are now available in `getData`. + * + * @method Phaser.FacebookInstantGamesPlugin#saveData + * @since 3.13.0 + * + * @param {object} data - An object containing a set of key-value pairs that should be persisted to cloud storage. + * The object must contain only serializable values - any non-serializable values will cause the entire modification to be rejected. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + saveData: function (data) + { + if (!this.checkAPI('playerSetDataAsync')) + { + return this; + } + + var _this = this; + + FBInstant.player.setDataAsync(data).then(function () + { + _this.emit('savedata', data); + + }).catch(function (e) + { + _this.emit('savedatafail', e); + }); + + return this; + }, + + /** + * Immediately flushes any changes to the player data to the designated cloud storage. + * This function is expensive, and should primarily be used for critical changes where persistence needs to be immediate + * and known by the game. Non-critical changes should rely on the platform to persist them in the background. + * NOTE: Calls to player.setDataAsync will be rejected while this function's result is pending. + * + * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this + * method directly if you need to flush the data directly. + * + * When the APIs `flushDataAsync` call resolves it will emit the `flushdata` event from this plugin. If the call fails for some + * reason it will emit `flushdatafail` instead. + * + * @method Phaser.FacebookInstantGamesPlugin#flushData + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + flushData: function () + { + if (!this.checkAPI('playerFlushDataAsync')) + { + return this; + } + + var _this = this; + + FBInstant.player.flushDataAsync().then(function () + { + _this.emit('flushdata'); + + }).catch(function (e) + { + _this.emit('flushdatafail', e); + }); + + return this; + }, + + /** + * Retrieve stats from the designated cloud storage of the current player. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `getstats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `getstatsfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#getStats + * @since 3.13.0 + * + * @param {string[]} [keys] - An optional array of unique keys to retrieve stats for. If the function is called without it, it will fetch all stats. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getStats: function (keys) + { + if (!this.checkAPI('playerGetStatsAsync')) + { + return this; + } + + var _this = this; + + FBInstant.player.getStatsAsync(keys).then(function (data) + { + _this.emit('getstats', data); + + }).catch(function (e) + { + _this.emit('getstatsfail', e); + }); + + return this; + }, + + /** + * Save the stats of the current player to the designated cloud storage. + * + * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, + * all other data types will be ignored. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `savestats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `savestatsfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#saveStats + * @since 3.13.0 + * + * @param {object} data - An object containing a set of key-value pairs that should be persisted to cloud storage as stats. Note that only numerical values are stored. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + saveStats: function (data) + { + if (!this.checkAPI('playerSetStatsAsync')) + { + return this; + } + + var output = {}; + + for (var key in data) + { + if (typeof data[key] === 'number') + { + output[key] = data[key]; + } + } + + var _this = this; + + FBInstant.player.setStatsAsync(output).then(function () + { + _this.emit('savestats', output); + + }).catch(function (e) + { + _this.emit('savestatsfail', e); + }); + + return this; + }, + + /** + * Increment the stats of the current player and save them to the designated cloud storage. + * + * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, + * all other data types will be ignored. + * + * The data object provided for this call should contain offsets for how much to modify the stats by: + * + * ```javascript + * this.facebook.incStats({ + * level: 1, + * zombiesSlain: 17, + * rank: -1 + * }); + * ``` + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `incstats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `incstatsfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#incStats + * @since 3.13.0 + * + * @param {object} data - An object containing a set of key-value pairs indicating how much to increment each stat in cloud storage. Note that only numerical values are processed. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + incStats: function (data) + { + if (!this.checkAPI('playerIncrementStatsAsync')) + { + return this; + } + + var output = {}; + + for (var key in data) + { + if (typeof data[key] === 'number') + { + output[key] = data[key]; + } + } + + var _this = this; + + FBInstant.player.incrementStatsAsync(output).then(function (stats) + { + _this.emit('incstats', stats); + + }).catch(function (e) + { + _this.emit('incstatsfail', e); + }); + + return this; + }, + + /** + * Sets the data associated with the individual gameplay session for the current context. + * + * This function should be called whenever the game would like to update the current session data. + * + * This session data may be used to populate a variety of payloads, such as game play webhooks. + * + * @method Phaser.FacebookInstantGamesPlugin#saveSession + * @since 3.13.0 + * + * @param {object} data - An arbitrary data object, which must be less than or equal to 1000 characters when stringified. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + saveSession: function (data) + { + if (!this.checkAPI('setSessionData')) + { + return this; + } + + var test = JSON.stringify(data); + + if (test.length <= 1000) + { + FBInstant.setSessionData(data); + } + else + { + console.warn('Session data too long. Max 1000 chars.'); + } + + return this; + }, + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * + * @method Phaser.FacebookInstantGamesPlugin#openShare + * @since 3.13.0 + * + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + openShare: function (text, key, frame, sessionData) + { + return this._share('SHARE', text, key, frame, sessionData); + }, + + /** + * This invokes a dialog to let the user invite a friend to play this game, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * + * @method Phaser.FacebookInstantGamesPlugin#openInvite + * @since 3.13.0 + * + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + openInvite: function (text, key, frame, sessionData) + { + return this._share('INVITE', text, key, frame, sessionData); + }, + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * + * @method Phaser.FacebookInstantGamesPlugin#openRequest + * @since 3.13.0 + * + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + openRequest: function (text, key, frame, sessionData) + { + return this._share('REQUEST', text, key, frame, sessionData); + }, + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * + * @method Phaser.FacebookInstantGamesPlugin#openChallenge + * @since 3.13.0 + * + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + openChallenge: function (text, key, frame, sessionData) + { + return this._share('CHALLENGE', text, key, frame, sessionData); + }, + + /** + * Internal share handler. + * + * @method Phaser.FacebookInstantGamesPlugin#_share + * @private + * @since 3.13.0 + * + * @param {string} intent - ("INVITE" | "REQUEST" | "CHALLENGE" | "SHARE") Indicates the intent of the share. + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + _share: function (intent, text, key, frame, sessionData) + { + if (!this.checkAPI('shareAsync')) + { + return this; + } + + if (sessionData === undefined) { sessionData = {}; } + + if (key) + { + var imageData = this.game.textures.getBase64(key, frame); + } + + // intent ("INVITE" | "REQUEST" | "CHALLENGE" | "SHARE") Indicates the intent of the share. + // image string A base64 encoded image to be shared. + // text string A text message to be shared. + // data Object? A blob of data to attach to the share. All game sessions launched from the share will be able to access this blob through FBInstant.getEntryPointData(). + + var payload = { + intent: intent, + image: imageData, + text: text, + data: sessionData + }; + + var _this = this; + + FBInstant.shareAsync(payload).then(function () + { + _this.emit('resume'); + }); + + return this; + }, + + /** + * This function determines whether the number of participants in the current game context is between a given minimum and maximum, inclusive. + * If one of the bounds is null only the other bound will be checked against. + * It will always return the original result for the first call made in a context in a given game play session. + * Subsequent calls, regardless of arguments, will return the answer to the original query until a context change occurs and the query result is reset. + * + * @method Phaser.FacebookInstantGamesPlugin#isSizeBetween + * @since 3.13.0 + * + * @param {integer} [min] - The minimum bound of the context size query. + * @param {integer} [max] - The maximum bound of the context size query. + * + * @return {object} The Context Size Response object in the format: `{answer: boolean, minSize: number?, maxSize: number?}`. + */ + isSizeBetween: function (min, max) + { + if (!this.checkAPI('contextIsSizeBetween')) + { + return this; + } + + return FBInstant.context.isSizeBetween(min, max); + }, + + /** + * Request a switch into a specific context. If the player does not have permission to enter that context, + * or if the player does not provide permission for the game to enter that context, this will emit a `switchfail` event. + * + * Otherwise, the plugin will emit the `switch` event when the game has switched into the specified context. + * + * @method Phaser.FacebookInstantGamesPlugin#switchContext + * @since 3.13.0 + * + * @param {string} contextID - The ID of the desired context. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + switchContext: function (contextID) + { + if (!this.checkAPI('contextSwitchAsync')) + { + return this; + } + + if (contextID !== this.contextID) + { + var _this = this; + + FBInstant.context.switchAsync(contextID).then(function () + { + _this.contextID = FBInstant.context.getID(); + + _this.emit('switch', _this.contextID); + + }).catch(function (e) + { + _this.emit('switchfail', e); + }); + } + + return this; + }, + + /** + * Opens a context selection dialog for the player. If the player selects an available context, + * the client will attempt to switch into that context, and emit the `choose` event if successful. + * Otherwise, if the player exits the menu or the client fails to switch into the new context, the `choosefail` event will be emitted. + * + * @method Phaser.FacebookInstantGamesPlugin#chooseContext + * @since 3.13.0 + * + * @param {string} contextID - The ID of the desired context. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + chooseContext: function (options) + { + if (!this.checkAPI('contextChoseAsync')) + { + return this; + } + + var _this = this; + + FBInstant.context.chooseAsync(options).then(function () + { + _this.contextID = FBInstant.context.getID(); + _this.emit('choose', _this.contextID); + + }).catch(function (e) + { + _this.emit('choosefail', e); + }); + + return this; + }, + + /** + * Attempts to create or switch into a context between a specified player and the current player. + * This plugin will emit the `create` event once the context switch is completed. + * If the API call fails, such as if the player listed is not a Connected Player of the current player or if the + * player does not provide permission to enter the new context, then the plugin will emit a 'createfail' event. + * + * @method Phaser.FacebookInstantGamesPlugin#createContext + * @since 3.13.0 + * + * @param {string} playerID - ID of the player. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + createContext: function (playerID) + { + if (!this.checkAPI('contextCreateAsync')) + { + return this; + } + + var _this = this; + + FBInstant.context.createAsync(playerID).then(function () + { + _this.contextID = FBInstant.context.getID(); + _this.emit('create', _this.contextID); + + }).catch(function (e) + { + _this.emit('createfail', e); + }); + + return this; + }, + + /** + * Fetches an array of ConnectedPlayer objects containing information about active players + * (people who played the game in the last 90 days) that are connected to the current player. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `players` event along + * with the player data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `playersfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlayers + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getPlayers: function () + { + if (!this.checkAPI('playerGetConnectedPlayersAsync')) + { + return this; + } + + var _this = this; + + FBInstant.player.getConnectedPlayersAsync().then(function (players) + { + _this.emit('players', players); + + }).catch(function (e) + { + _this.emit('playersfail', e); + }); + + return this; + }, + + /** + * Fetches the game's product catalog. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `getcatalog` event along + * with the catalog data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `getcatalogfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#getCatalog + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getCatalog: function () + { + if (!this.paymentsReady) + { + return this; + } + + var _this = this; + var catalog = this.catalog; + + FBInstant.payments.getCatalogAsync().then(function (data) + { + catalog = []; + + data.forEach(function (item) + { + catalog.push(Product(item)); + }); + + _this.emit('getcatalog', catalog); + + }).catch(function (e) + { + _this.emit('getcatalogfail', e); + }); + + return this; + }, + + /** + * Begins the purchase flow for a specific product. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `purchase` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `purchasefail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#purchase + * @since 3.13.0 + * + * @param {string} productID - The identifier of the product to purchase. + * @param {string} [developerPayload] - An optional developer-specified payload, to be included in the returned purchase's signed request. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + purchase: function (productID, developerPayload) + { + if (!this.paymentsReady) + { + return this; + } + + var config = {productID: productID}; + + if (developerPayload) + { + config.developerPayload = developerPayload; + } + + var _this = this; + + FBInstant.payments.purchaseAsync(config).then(function (data) + { + var purchase = Purchase(data); + + _this.emit('purchase', purchase); + + }).catch(function (e) + { + _this.emit('purchasefail', e); + }); + + return this; + }, + + /** + * Fetches all of the player's unconsumed purchases. The game must fetch the current player's purchases + * as soon as the client indicates that it is ready to perform payments-related operations, + * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `getpurchases` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `getpurchasesfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#getPurchases + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getPurchases: function () + { + if (!this.paymentsReady) + { + return this; + } + + var _this = this; + var purchases = this.purchases; + + FBInstant.payments.getPurchasesAsync().then(function (data) + { + purchases = []; + + data.forEach(function (item) + { + purchases.push(Purchase(item)); + }); + + _this.emit('getpurchases', purchases); + + }).catch(function (e) + { + _this.emit('getpurchasesfail', e); + }); + + return this; + }, + + /** + * Consumes a specific purchase belonging to the current player. Before provisioning a product's effects to the player, + * the game should request the consumption of the purchased product. Once the purchase is successfully consumed, + * the game should immediately provide the player with the effects of their purchase. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `consumepurchase` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `consumepurchasefail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#consumePurchases + * @since 3.13.0 + * + * @param {string} purchaseToken - The purchase token of the purchase that should be consumed. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + consumePurchases: function (purchaseToken) + { + if (!this.paymentsReady) + { + return this; + } + + var _this = this; + + FBInstant.payments.consumePurchaseAsync(purchaseToken).then(function () + { + _this.emit('consumepurchase', purchaseToken); + + }).catch(function (e) + { + _this.emit('consumepurchasefail', e); + }); + + return this; + }, + + /** + * Informs Facebook of a custom update that occurred in the game. + * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. + * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * The `text` parameter is an update payload with the following structure: + * + * ``` + * text: { + * default: 'X just invaded Y\'s village!', + * localizations: { + * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + + * '\u0642\u0631\u064A\u0629 Y!', + * en_US: 'X just invaded Y\'s village!', + * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', + * } + * } + * ``` + * + * @method Phaser.FacebookInstantGamesPlugin#update + * @since 3.13.0 + * + * @param {string} cta - The call to action text. + * @param {object} text - The text object. + * @param {string} key - The key of the texture to use as the share image. + * @param {(string|integer)} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {string} template - The update template key. + * @param {object} updateData - The update data object payload. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + update: function (cta, text, key, frame, template, updateData) + { + return this._update('CUSTOM', cta, text, key, frame, template, updateData); + }, + + /** + * Informs Facebook of a leaderboard update that occurred in the game. + * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. + * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * The `text` parameter is an update payload with the following structure: + * + * ``` + * text: { + * default: 'X just invaded Y\'s village!', + * localizations: { + * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + + * '\u0642\u0631\u064A\u0629 Y!', + * en_US: 'X just invaded Y\'s village!', + * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', + * } + * } + * ``` + * + * @method Phaser.FacebookInstantGamesPlugin#updateLeaderboard + * @since 3.13.0 + * + * @param {string} cta - The call to action text. + * @param {object} text - The text object. + * @param {string} key - The key of the texture to use as the share image. + * @param {(string|integer)} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {string} template - The update template key. + * @param {object} updateData - The update data object payload. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + updateLeaderboard: function (cta, text, key, frame, template, updateData) + { + return this._update('LEADERBOARD', cta, text, key, frame, template, updateData); + }, + + /** + * Internal update handler. + * + * @method Phaser.FacebookInstantGamesPlugin#_update + * @private + * @since 3.13.0 + * + * @param {string} action - The update action. + * @param {string} cta - The call to action text. + * @param {object} text - The text object. + * @param {string} key - The key of the texture to use as the share image. + * @param {(string|integer)} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {string} template - The update template key. + * @param {object} updateData - The update data object payload. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + _update: function (action, cta, text, key, frame, template, updateData) + { + if (!this.checkAPI('shareAsync')) + { + return this; + } + + if (cta === undefined) { cta = ''; } + + if (typeof text === 'string') + { + text = {default: text}; + } + + if (updateData === undefined) { updateData = {}; } + + if (key) + { + var imageData = this.game.textures.getBase64(key, frame); + } + + var payload = { + action: action, + cta: cta, + image: imageData, + text: text, + template: template, + data: updateData, + strategy: 'IMMEDIATE', + notification: 'NO_PUSH' + }; + + var _this = this; + + FBInstant.updateAsync(payload).then(function () + { + _this.emit('update'); + + }).catch(function (e) + { + _this.emit('updatefail', e); + }); + + return this; + }, + + /** + * Request that the client switch to a different Instant Game. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If the game switches successfully this plugin will emit the `switchgame` event and the client will load the new game. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `switchgamefail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#switchGame + * @since 3.13.0 + * + * @param {string} appID - The Application ID of the Instant Game to switch to. The application must be an Instant Game, and must belong to the same business as the current game. + * @param {object} [data] - An optional data payload. This will be set as the entrypoint data for the game being switched to. Must be less than or equal to 1000 characters when stringified. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + switchGame: function (appID, data) + { + if (!this.checkAPI('switchGameAsync')) + { + return this; + } + + if (data) + { + var test = JSON.stringify(data); + + if (test.length > 1000) + { + console.warn('Switch Game data too long. Max 1000 chars.'); + return this; + } + } + + var _this = this; + + FBInstant.switchGameAsync(appID, data).then(function () + { + _this.emit('switchgame', appID); + + }).catch(function (e) + { + _this.emit('switchgamefail', e); + }); + + return this; + }, + + /** + * Prompts the user to create a shortcut to the game if they are eligible to. + * Can only be called once per session. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If the user choose to create a shortcut this plugin will emit the `shortcutcreated` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `shortcutcreatedfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#createShortcut + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + createShortcut: function () + { + var _this = this; + + FBInstant.canCreateShortcutAsync().then(function (canCreateShortcut) + { + if (canCreateShortcut) + { + FBInstant.createShortcutAsync().then(function () + { + _this.emit('shortcutcreated'); + + }).catch(function (e) + { + _this.emit('shortcutfailed', e); + }); + } + }); + + return this; + }, + + /** + * Quits the game. + * + * @method Phaser.FacebookInstantGamesPlugin#quit + * @since 3.13.0 + */ + quit: function () + { + FBInstant.quit(); + }, + + /** + * Log an app event with FB Analytics. + * + * See https://developers.facebook.com/docs/javascript/reference/v2.8#app_events for more details about FB Analytics. + * + * @method Phaser.FacebookInstantGamesPlugin#log + * @since 3.13.0 + * + * @param {string} name - Name of the event. Must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. + * @param {number} [value] - An optional numeric value that FB Analytics can calculate a sum with. + * @param {object} [params] - An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. Values must be less than 100 characters in length. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + log: function (name, value, params) + { + if (!this.checkAPI('logEvent')) + { + return this; + } + + if (params === undefined) { params = {}; } + + if (name.length >= 2 && name.length <= 40) + { + FBInstant.logEvent(name, parseFloat(value), params); + } + + return this; + }, + + /** + * Attempt to create an instance of an interstitial ad. + * + * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showAd()`. + * + * @method Phaser.FacebookInstantGamesPlugin#preloadAds + * @since 3.13.0 + * + * @param {(string|string[])} placementID - The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + preloadAds: function (placementID) + { + if (!this.checkAPI('getInterstitialAdAsync')) + { + return this; + } + + if (!Array.isArray(placementID)) + { + placementID = [ placementID ]; + } + + var i; + var _this = this; + + var total = 0; + + for (i = 0; i < this.ads.length; i++) + { + if (!this.ads[i].shown) + { + total++; + } + } + + if (total + placementID.length >= 3) + { + console.warn('Too many AdInstances. Show an ad before loading more'); + return this; + } + + for (i = 0; i < placementID.length; i++) + { + var id = placementID[i]; + + FBInstant.getInterstitialAdAsync(id).then(function (data) + { + var ad = AdInstance(data, true); + + _this.ads.push(ad); + + return ad.loadAsync(); + + }).catch(function (e) + { + console.warn(e); + }); + } + + return this; + }, + + /** + * Attempt to create an instance of an interstitial video ad. + * + * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showVideo()`. + * + * @method Phaser.FacebookInstantGamesPlugin#preloadVideoAds + * @since 3.13.0 + * + * @param {(string|string[])} placementID - The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + preloadVideoAds: function (placementID) + { + if (!this.checkAPI('getRewardedVideoAsync')) + { + return this; + } + + if (!Array.isArray(placementID)) + { + placementID = [ placementID ]; + } + + var i; + var _this = this; + + var total = 0; + + for (i = 0; i < this.ads.length; i++) + { + if (!this.ads[i].shown) + { + total++; + } + } + + if (total + placementID.length >= 3) + { + console.warn('Too many AdInstances. Show an ad before loading more'); + return this; + } + + for (i = 0; i < placementID.length; i++) + { + var id = placementID[i]; + + FBInstant.getRewardedVideoAsync(id).then(function (data) + { + var ad = AdInstance(data, true); + + _this.ads.push(ad); + + return ad.loadAsync(); + + }).catch(function (e) + { + console.warn(e); + }); + } + + return this; + }, + + /** + * Displays a previously loaded interstitial ad. + * + * If the ad is successfully displayed this plugin will emit the `showad` event, with the AdInstance object as its parameter. + * + * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. + * + * @method Phaser.FacebookInstantGamesPlugin#showAd + * @since 3.13.0 + * + * @param {string} placementID - The ad placement ID to display. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + showAd: function (placementID) + { + var _this = this; + + for (var i = 0; i < this.ads.length; i++) + { + var ad = this.ads[i]; + + if (ad.placementID === placementID) + { + ad.instance.showAsync().then(function () + { + ad.shown = true; + + _this.emit('showad', ad); + + }).catch(function (e) + { + if (e.code === 'ADS_NO_FILL') + { + _this.emit('adsnofill'); + } + else + { + console.warn(e); + } + }); + } + } + + return this; + }, + + /** + * Displays a previously loaded interstitial video ad. + * + * If the ad is successfully displayed this plugin will emit the `showad` event, with the AdInstance object as its parameter. + * + * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. + * + * @method Phaser.FacebookInstantGamesPlugin#showVideo + * @since 3.13.0 + * + * @param {string} placementID - The ad placement ID to display. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + showVideo: function (placementID) + { + var _this = this; + + for (var i = 0; i < this.ads.length; i++) + { + var ad = this.ads[i]; + + if (ad.placementID === placementID && ad.video) + { + ad.instance.showAsync().then(function () + { + ad.shown = true; + + _this.emit('showad', ad); + + }).catch(function (e) + { + if (e.code === 'ADS_NO_FILL') + { + _this.emit('adsnofill'); + } + else + { + console.warn(e); + } + }); + } + } + + return this; + }, + + /** + * Attempts to match the current player with other users looking for people to play with. + * If successful, a new Messenger group thread will be created containing the matched players and the player will + * be context switched to that thread. This plugin will also dispatch the `matchplayer` event, containing the new context ID and Type. + * + * The default minimum and maximum number of players in one matched thread are 2 and 20 respectively, + * depending on how many players are trying to get matched around the same time. + * + * The values can be changed in `fbapp-config.json`. See the Bundle Config documentation for documentation about `fbapp-config.json`. + * + * @method Phaser.FacebookInstantGamesPlugin#matchPlayer + * @since 3.13.0 + * + * @param {string} [matchTag] - Optional extra information about the player used to group them with similar players. Players will only be grouped with other players with exactly the same tag. The tag must only include letters, numbers, and underscores and be 100 characters or less in length. + * @param {boolean} [switchImmediately=false] - Optional extra parameter that specifies whether the player should be immediately switched to the new context when a match is found. By default this will be false which will mean the player needs explicitly press play after being matched to switch to the new context. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + matchPlayer: function (matchTag, switchImmediately) + { + if (matchTag === undefined) { matchTag = null; } + if (switchImmediately === undefined) { switchImmediately = false; } + + if (!this.checkAPI('matchPlayerAsync')) + { + return this; + } + + var _this = this; + + FBInstant.matchPlayerAsync(matchTag, switchImmediately).then(function () + { + _this.getID(); + _this.getType(); + + _this.emit('matchplayer', _this.contextID, _this.contextType); + }); + + return this; + }, + + /** + * Fetch a specific leaderboard belonging to this Instant Game. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `getleaderboard` event will be emitted along with a Leaderboard object instance. + * + * @method Phaser.FacebookInstantGamesPlugin#getLeaderboard + * @since 3.13.0 + * + * @param {string} name - The name of the leaderboard. Each leaderboard for an Instant Game must have its own distinct name. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getLeaderboard: function (name) + { + if (!this.checkAPI('getLeaderboardAsync')) + { + return this; + } + + var _this = this; + + FBInstant.getLeaderboardAsync(name).then(function (data) + { + var leaderboard = new Leaderboard(_this, data); + + _this.leaderboards[name] = leaderboard; + + _this.emit('getleaderboard', leaderboard); + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + }, + + /** + * Quits the Facebook API and then destroys this plugin. + * + * @method Phaser.FacebookInstantGamesPlugin#destroy + * @since 3.13.0 + */ + destroy: function () + { + FBInstant.quit(); + + this.data.destroy(); + + this.removeAllListeners(); + + this.catalog = []; + this.purchases = []; + this.leaderboards = []; + this.ads = []; + + this.game = null; + } + +}); + +module.exports = FacebookInstantGamesPlugin; + + +/***/ }), +/* 345 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Textures.Parsers + */ + +module.exports = { + + AtlasXML: __webpack_require__(958), + Canvas: __webpack_require__(957), + Image: __webpack_require__(956), + JSONArray: __webpack_require__(955), + JSONHash: __webpack_require__(954), + SpriteSheet: __webpack_require__(953), + SpriteSheetFromAtlas: __webpack_require__(952), + UnityYAML: __webpack_require__(951) + +}; + + +/***/ }), +/* 346 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(26); +var Class = __webpack_require__(0); +var IsSizePowerOfTwo = __webpack_require__(127); +var ScaleModes = __webpack_require__(104); + +/** + * @classdesc + * A Texture Source is the encapsulation of the actual source data for a Texture. + * This is typically an Image Element, loaded from the file system or network, or a Canvas Element. + * + * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. + * + * @class TextureSource + * @memberof Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture this TextureSource belongs to. + * @param {(HTMLImageElement|HTMLCanvasElement)} source - The source image data. + * @param {integer} [width] - Optional width of the source image. If not given it's derived from the source itself. + * @param {integer} [height] - Optional height of the source image. If not given it's derived from the source itself. + */ +var TextureSource = new Class({ + + initialize: + + function TextureSource (texture, source, width, height) + { + var game = texture.manager.game; + + /** + * The Texture this TextureSource belongs to. + * + * @name Phaser.Textures.TextureSource#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.7.0 + */ + this.renderer = game.renderer; + + /** + * The Texture this TextureSource belongs to. + * + * @name Phaser.Textures.TextureSource#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = texture; + + /** + * The source of the image data. + * This is either an Image Element, a Canvas Element or a RenderTexture. + * + * @name Phaser.Textures.TextureSource#source + * @type {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)} + * @since 3.12.0 + */ + this.source = source; + + /** + * The image data. + * This is either an Image element or a Canvas element. + * + * @name Phaser.Textures.TextureSource#image + * @type {(HTMLImageElement|HTMLCanvasElement)} + * @since 3.0.0 + */ + this.image = source; + + /** + * Currently un-used. + * + * @name Phaser.Textures.TextureSource#compressionAlgorithm + * @type {integer} + * @default null + * @since 3.0.0 + */ + this.compressionAlgorithm = null; + + /** + * The resolution of the source image. + * + * @name Phaser.Textures.TextureSource#resolution + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.resolution = 1; + + /** + * The width of the source image. If not specified in the constructor it will check + * the `naturalWidth` and then `width` properties of the source image. + * + * @name Phaser.Textures.TextureSource#width + * @type {integer} + * @since 3.0.0 + */ + this.width = width || source.naturalWidth || source.width || 0; + + /** + * The height of the source image. If not specified in the constructor it will check + * the `naturalHeight` and then `height` properties of the source image. + * + * @name Phaser.Textures.TextureSource#height + * @type {integer} + * @since 3.0.0 + */ + this.height = height || source.naturalHeight || source.height || 0; + + /** + * The Scale Mode the image will use when rendering. + * Either Linear or Nearest. + * + * @name Phaser.Textures.TextureSource#scaleMode + * @type {number} + * @since 3.0.0 + */ + this.scaleMode = ScaleModes.DEFAULT; + + /** + * Is the source image a Canvas Element? + * + * @name Phaser.Textures.TextureSource#isCanvas + * @type {boolean} + * @since 3.0.0 + */ + this.isCanvas = (source instanceof HTMLCanvasElement); + + /** + * Is the source image a Render Texture? + * + * @name Phaser.Textures.TextureSource#isRenderTexture + * @type {boolean} + * @since 3.12.0 + */ + this.isRenderTexture = (source.type === 'RenderTexture'); + + /** + * Are the source image dimensions a power of two? + * + * @name Phaser.Textures.TextureSource#isPowerOf2 + * @type {boolean} + * @since 3.0.0 + */ + this.isPowerOf2 = IsSizePowerOfTwo(this.width, this.height); + + /** + * The WebGL Texture of the source image. + * + * @name Phaser.Textures.TextureSource#glTexture + * @type {?WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.glTexture = null; + + this.init(game); + }, + + /** + * Creates a WebGL Texture, if required, and sets the Texture filter mode. + * + * @method Phaser.Textures.TextureSource#init + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser Game instance. + */ + init: function (game) + { + if (this.renderer) + { + if (this.renderer.gl) + { + if (this.isCanvas) + { + this.glTexture = this.renderer.canvasToTexture(this.image); + } + else if (this.isRenderTexture) + { + this.image = this.source.canvas; + + this.glTexture = this.renderer.createTextureFromSource(null, this.width, this.height, this.scaleMode); + } + else + { + this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + } + } + else if (this.isRenderTexture) + { + this.image = this.source.canvas; + } + } + + if (!game.config.antialias) + { + this.setFilter(1); + } + }, + + /** + * Sets the Filter Mode for this Texture. + * + * The mode can be either Linear, the default, or Nearest. + * + * For pixel-art you should use Nearest. + * + * @method Phaser.Textures.TextureSource#setFilter + * @since 3.0.0 + * + * @param {Phaser.Textures.FilterMode} filterMode - The Filter Mode. + */ + setFilter: function (filterMode) + { + if (this.renderer.gl) + { + this.renderer.setTextureFilter(this.glTexture, filterMode); + } + }, + + /** + * If this TextureSource is backed by a Canvas and is running under WebGL, + * it updates the WebGLTexture using the canvas data. + * + * @method Phaser.Textures.TextureSource#update + * @since 3.7.0 + */ + update: function () + { + if (this.renderer.gl && this.isCanvas) + { + this.glTexture = this.renderer.canvasToTexture(this.image, this.glTexture); + + // Update all the Frames using this TextureSource + + /* + var index = this.texture.getTextureSourceIndex(this); + + var frames = this.texture.getFramesFromTextureSource(index, true); + + for (var i = 0; i < frames.length; i++) + { + frames[i].glTexture = this.glTexture; + } + */ + } + }, + + /** + * Destroys this Texture Source and nulls the references. + * + * @method Phaser.Textures.TextureSource#destroy + * @since 3.0.0 + */ + destroy: function () + { + if (this.glTexture) + { + this.renderer.deleteTexture(this.glTexture); + } + + if (this.isCanvas) + { + CanvasPool.remove(this.image); + } + + this.renderer = null; + this.texture = null; + this.source = null; + this.image = null; + this.glTexture = null; + } + +}); + +module.exports = TextureSource; + + +/***/ }), +/* 347 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(26); +var CanvasTexture = __webpack_require__(959); +var Class = __webpack_require__(0); +var Color = __webpack_require__(41); +var CONST = __webpack_require__(28); +var EventEmitter = __webpack_require__(11); +var GenerateTexture = __webpack_require__(393); +var GetValue = __webpack_require__(4); +var Parser = __webpack_require__(345); +var Texture = __webpack_require__(181); + +/** + * @callback EachTextureCallback + * + * @param {Phaser.Textures.Texture} texture - Each texture in Texture Manager. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + +/** + * @classdesc + * Textures are managed by the global TextureManager. This is a singleton class that is + * responsible for creating and delivering Textures and their corresponding Frames to Game Objects. + * + * Sprites and other Game Objects get the texture data they need from the TextureManager. + * + * Access it via `scene.textures`. + * + * @class TextureManager + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance this Texture Manager belongs to. + */ +var TextureManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function TextureManager (game) + { + EventEmitter.call(this); + + /** + * The Game that this TextureManager belongs to. + * + * @name Phaser.Textures.TextureManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * The name of this manager. + * + * @name Phaser.Textures.TextureManager#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'TextureManager'; + + /** + * An object that has all of textures that Texture Manager creates. + * Textures are assigned to keys so we can access to any texture that this object has directly by key value without iteration. + * + * @name Phaser.Textures.TextureManager#list + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * The temporary canvas element to save an pixel data of an arbitrary texture in getPixel() and getPixelAlpha() method. + * + * @name Phaser.Textures.TextureManager#_tempCanvas + * @type {HTMLCanvasElement} + * @private + * @since 3.0.0 + */ + this._tempCanvas = CanvasPool.create2D(this, 1, 1); + + /** + * The context of the temporary canvas element made to save an pixel data in getPixel() and getPixelAlpha() method. + * + * @name Phaser.Textures.TextureManager#_tempContext + * @type {CanvasRenderingContext2D} + * @private + * @since 3.0.0 + */ + this._tempContext = this._tempCanvas.getContext('2d'); + + /** + * An counting value used for emitting 'ready' event after all of managers in game is loaded. + * + * @name Phaser.Textures.TextureManager#_pending + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._pending = 0; + + game.events.once('boot', this.boot, this); + }, + + /** + * The Boot Handler called by Phaser.Game when it first starts up. + * + * @method Phaser.Textures.TextureManager#boot + * @private + * @since 3.0.0 + */ + boot: function () + { + this._pending = 2; + + this.on('onload', this.updatePending, this); + this.on('onerror', this.updatePending, this); + + this.addBase64('__DEFAULT', this.game.config.defaultImage); + this.addBase64('__MISSING', this.game.config.missingImage); + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * After 'onload' or 'onerror' invoked twice, emit 'ready' event. + * + * @method Phaser.Textures.TextureManager#updatePending + * @private + * @since 3.0.0 + */ + updatePending: function () + { + this._pending--; + + if (this._pending === 0) + { + this.off('onload'); + this.off('onerror'); + + this.game.events.emit('texturesready'); + } + }, + + /** + * Checks the given texture key and throws a console.warn if the key is already in use, then returns false. + * If you wish to avoid the console.warn then use `TextureManager.exists` instead. + * + * @method Phaser.Textures.TextureManager#checkKey + * @since 3.7.0 + * + * @param {string} key - The texture key to check. + * + * @return {boolean} `true` if it's safe to use the texture key, otherwise `false`. + */ + checkKey: function (key) + { + if (this.exists(key)) + { + // eslint-disable-next-line no-console + console.error('Texture key already in use: ' + key); + + return false; + } + + return true; + }, + + /** + * Removes a Texture from the Texture Manager and destroys it. This will immediately + * clear all references to it from the Texture Manager, and if it has one, destroy its + * WebGLTexture. This will emit a `removetexture` event. + * + * Note: If you have any Game Objects still using this texture they will start throwing + * errors the next time they try to render. Make sure that removing the texture is the final + * step when clearing down to avoid this. + * + * @method Phaser.Textures.TextureManager#remove + * @since 3.7.0 + * + * @param {(string|Phaser.Textures.Texture)} key - The key of the Texture to remove, or a reference to it. + * + * @return {Phaser.Textures.TextureManager} The Texture Manager. + */ + remove: function (key) + { + if (typeof key === 'string') + { + if (this.exists(key)) + { + key = this.get(key); + } + else + { + console.warn('No texture found matching key: ' + key); + return this; + } + } + + // By this point key should be a Texture, if not, the following fails anyway + if (this.list.hasOwnProperty(key.key)) + { + delete this.list[key.key]; + + key.destroy(); + + this.emit('removetexture', key.key); + } + + return this; + }, + + /** + * Adds a new Texture to the Texture Manager created from the given Base64 encoded data. + * + * @method Phaser.Textures.TextureManager#addBase64 + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {*} data - The Base64 encoded data. + * + * @return {this} This Texture Manager instance. + */ + addBase64: function (key, data) + { + if (this.checkKey(key)) + { + var _this = this; + + var image = new Image(); + + image.onerror = function () + { + _this.emit('onerror', key); + }; + + image.onload = function () + { + var texture = _this.create(key, image); + + Parser.Image(texture, 0); + + _this.emit('addtexture', key, texture); + + _this.emit('onload', key, texture); + }; + + image.src = data; + } + + return this; + }, + + /** + * Gets an existing texture frame and converts it into a base64 encoded image and returns the base64 data. + * + * You can also provide the image type and encoder options. + * + * @method Phaser.Textures.TextureManager#getBase64 + * @since 3.12.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. + * @param {string} [type='image/png'] - [description] + * @param {number} [encoderOptions=0.92] - [description] + * + * @return {string} The base64 encoded data, or an empty string if the texture frame could not be found. + */ + getBase64: function (key, frame, type, encoderOptions) + { + if (type === undefined) { type = 'image/png'; } + if (encoderOptions === undefined) { encoderOptions = 0.92; } + + var data = ''; + + var textureFrame = this.getFrame(key, frame); + + if (textureFrame) + { + var cd = textureFrame.canvasData; + + var canvas = CanvasPool.create2D(this, cd.width, cd.height); + var ctx = canvas.getContext('2d'); + + ctx.drawImage( + textureFrame.source.image, + cd.x, + cd.y, + cd.width, + cd.height, + 0, + 0, + cd.width, + cd.height + ); + + data = canvas.toDataURL(type, encoderOptions); + + CanvasPool.remove(canvas); + } + + return data; + }, + + /** + * Adds a new Texture to the Texture Manager created from the given Image element. + * + * @method Phaser.Textures.TextureManager#addImage + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addImage: function (key, source, dataSource) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, source); + + Parser.Image(texture, 0); + + if (dataSource) + { + texture.setDataSource(dataSource); + } + + this.emit('addtexture', key, texture); + } + + return texture; + }, + + /** + * Adds a Render Texture to the Texture Manager using the given key. + * This allows you to then use the Render Texture as a normal texture for texture based Game Objects like Sprites. + * + * @method Phaser.Textures.TextureManager#addRenderTexture + * @since 3.12.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {Phaser.GameObjects.RenderTexture} renderTexture - The source Render Texture. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addRenderTexture: function (key, renderTexture) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, renderTexture); + + texture.add('__BASE', 0, 0, 0, renderTexture.width, renderTexture.height); + + this.emit('addtexture', key, texture); + } + + return texture; + }, + + /** + * Creates a new Texture using the given config values. + * Generated textures consist of a Canvas element to which the texture data is drawn. + * See the Phaser.Create function for the more direct way to create textures. + * + * @method Phaser.Textures.TextureManager#generate + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {object} config - The configuration object needed to generate the texture. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + generate: function (key, config) + { + if (this.checkKey(key)) + { + var canvas = CanvasPool.create(this, 1, 1); + + config.canvas = canvas; + + GenerateTexture(config); + + return this.addCanvas(key, canvas); + } + else + { + return null; + } + }, + + /** + * Creates a new Texture using a blank Canvas element of the size given. + * + * Canvas elements are automatically pooled and calling this method will + * extract a free canvas from the CanvasPool, or create one if none are available. + * + * @method Phaser.Textures.TextureManager#createCanvas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {integer} [width=256]- The width of the Canvas element. + * @param {integer} [height=256] - The height of the Canvas element. + * + * @return {?Phaser.Textures.CanvasTexture} The Canvas Texture that was created, or `null` if the key is already in use. + */ + createCanvas: function (key, width, height) + { + if (width === undefined) { width = 256; } + if (height === undefined) { height = 256; } + + if (this.checkKey(key)) + { + var canvas = CanvasPool.create(this, width, height, CONST.CANVAS, true); + + return this.addCanvas(key, canvas); + } + + return null; + }, + + /** + * Creates a new Canvas Texture object from an existing Canvas element + * and adds it to this Texture Manager, unless `skipCache` is true. + * + * @method Phaser.Textures.TextureManager#addCanvas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLCanvasElement} source - The Canvas element to form the base of the new Texture. + * @param {boolean} [skipCache=false] - Skip adding this Texture into the Cache? + * + * @return {?Phaser.Textures.CanvasTexture} The Canvas Texture that was created, or `null` if the key is already in use. + */ + addCanvas: function (key, source, skipCache) + { + if (skipCache === undefined) { skipCache = false; } + + var texture = null; + + if (skipCache) + { + texture = new CanvasTexture(this, key, source, source.width, source.height); + } + else if (this.checkKey(key)) + { + texture = new CanvasTexture(this, key, source, source.width, source.height); + + this.list[key] = texture; + + this.emit('addtexture', key, texture); + } + + return texture; + }, + + /** + * Adds a new Texture Atlas to this Texture Manager. + * It can accept either JSON Array or JSON Hash formats, as exported by Texture Packer and similar software. + * + * @method Phaser.Textures.TextureManager#addAtlas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addAtlas: function (key, source, data, dataSource) + { + // New Texture Packer format? + if (Array.isArray(data.textures) || Array.isArray(data.frames)) + { + return this.addAtlasJSONArray(key, source, data, dataSource); + } + else + { + return this.addAtlasJSONHash(key, source, data, dataSource); + } + }, + + /** + * Adds a Texture Atlas to this Texture Manager. + * The frame data of the atlas must be stored in an Array within the JSON. + * This is known as a JSON Array in software such as Texture Packer. + * + * @method Phaser.Textures.TextureManager#addAtlasJSONArray + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(HTMLImageElement|HTMLImageElement[])} source - The source Image element/s. + * @param {(object|object[])} data - The Texture Atlas data/s. + * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addAtlasJSONArray: function (key, source, data, dataSource) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, source); + + // Multi-Atlas? + if (Array.isArray(data)) + { + var singleAtlasFile = (data.length === 1); // multi-pack with one atlas file for all images + + // !! Assumes the textures are in the same order in the source array as in the json data !! + for (var i = 0; i < texture.source.length; i++) + { + var atlasData = singleAtlasFile ? data[0] : data[i]; + + Parser.JSONArray(texture, i, atlasData); + } + } + else + { + Parser.JSONArray(texture, 0, data); + } + + if (dataSource) + { + texture.setDataSource(dataSource); + } + + this.emit('addtexture', key, texture); + } + + return texture; + }, + + /** + * Adds a Texture Atlas to this Texture Manager. + * The frame data of the atlas must be stored in an Object within the JSON. + * This is known as a JSON Hash in software such as Texture Packer. + * + * @method Phaser.Textures.TextureManager#addAtlasJSONHash + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addAtlasJSONHash: function (key, source, data, dataSource) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, source); + + if (Array.isArray(data)) + { + for (var i = 0; i < data.length; i++) + { + Parser.JSONHash(texture, i, data[i]); + } + } + else + { + Parser.JSONHash(texture, 0, data); + } + + if (dataSource) + { + texture.setDataSource(dataSource); + } + + this.emit('addtexture', key, texture); + } + + return texture; + }, + + /** + * Adds a Texture Atlas to this Texture Manager, where the atlas data is given + * in the XML format. + * + * @method Phaser.Textures.TextureManager#addAtlasXML + * @since 3.7.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas XML data. + * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addAtlasXML: function (key, source, data, dataSource) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, source); + + Parser.AtlasXML(texture, 0, data); + + if (dataSource) + { + texture.setDataSource(dataSource); + } + + this.emit('addtexture', key, texture); + } + + return texture; + }, + + /** + * Adds a Unity Texture Atlas to this Texture Manager. + * The data must be in the form of a Unity YAML file. + * + * @method Phaser.Textures.TextureManager#addUnityAtlas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {object} data - The Texture Atlas data. + * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addUnityAtlas: function (key, source, data, dataSource) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, source); + + Parser.UnityYAML(texture, 0, data); + + if (dataSource) + { + texture.setDataSource(dataSource); + } + + this.emit('addtexture', key, texture); + } + + return texture; + }, + + /** + * @typedef {object} SpriteSheetConfig + * + * @property {integer} frameWidth - The fixed width of each frame. + * @property {integer} [frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. + * @property {integer} [startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. + * @property {integer} [endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". + * @property {integer} [margin=0] - If the frames have been drawn with a margin, specify the amount here. + * @property {integer} [spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. + */ + + /** + * Adds a Sprite Sheet to this Texture Manager. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @method Phaser.Textures.TextureManager#addSpriteSheet + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {SpriteSheetConfig} config - The configuration object for this Sprite Sheet. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addSpriteSheet: function (key, source, config) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, source); + + var width = texture.source[0].width; + var height = texture.source[0].height; + + Parser.SpriteSheet(texture, 0, 0, 0, width, height, config); + + this.emit('addtexture', key, texture); + } + + return texture; + }, + + /** + * @typedef {object} SpriteSheetFromAtlasConfig + * + * @property {string} atlas - The key of the Texture Atlas in which this Sprite Sheet can be found. + * @property {string} frame - The key of the Texture Atlas Frame in which this Sprite Sheet can be found. + * @property {integer} frameWidth - The fixed width of each frame. + * @property {integer} [frameHeight] - The fixed height of each frame. If not set it will use the frameWidth as the height. + * @property {integer} [startFrame=0] - Skip a number of frames. Useful when there are multiple sprite sheets in one Texture. + * @property {integer} [endFrame=-1] - The total number of frames to extract from the Sprite Sheet. The default value of -1 means "extract all frames". + * @property {integer} [margin=0] - If the frames have been drawn with a margin, specify the amount here. + * @property {integer} [spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. + */ + + /** + * Adds a Sprite Sheet to this Texture Manager, where the Sprite Sheet exists as a Frame within a Texture Atlas. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @method Phaser.Textures.TextureManager#addSpriteSheetFromAtlas + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {SpriteSheetFromAtlasConfig} config - The configuration object for this Sprite Sheet. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addSpriteSheetFromAtlas: function (key, config) + { + if (!this.checkKey(key)) + { + return null; + } + + var atlasKey = GetValue(config, 'atlas', null); + var atlasFrame = GetValue(config, 'frame', null); + + if (!atlasKey || !atlasFrame) + { + return; + } + + var atlas = this.get(atlasKey); + var sheet = atlas.get(atlasFrame); + + if (sheet) + { + var texture = this.create(key, sheet.source.image); + + if (sheet.trimmed) + { + // If trimmed we need to help the parser adjust + Parser.SpriteSheetFromAtlas(texture, sheet, config); + } + else + { + Parser.SpriteSheet(texture, 0, sheet.cutX, sheet.cutY, sheet.cutWidth, sheet.cutHeight, config); + } + + this.emit('addtexture', key, texture); + + return texture; + } + }, + + /** + * Creates a new Texture using the given source and dimensions. + * + * @method Phaser.Textures.TextureManager#create + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {HTMLImageElement} source - The source Image element. + * @param {integer} width - The width of the Texture. + * @param {integer} height - The height of the Texture. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + create: function (key, source, width, height) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = new Texture(this, key, source, width, height); + + this.list[key] = texture; + } + + return texture; + }, + + /** + * Checks the given key to see if a Texture using it exists within this Texture Manager. + * + * @method Phaser.Textures.TextureManager#exists + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * + * @return {boolean} Returns `true` if a Texture matching the given key exists in this Texture Manager. + */ + exists: function (key) + { + return (this.list.hasOwnProperty(key)); + }, + + /** + * Returns a Texture from the Texture Manager that matches the given key. + * If the key is undefined it will return the `__DEFAULT` Texture. + * If the key is given, but not found, it will return the `__MISSING` Texture. + * + * @method Phaser.Textures.TextureManager#get + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * + * @return {Phaser.Textures.Texture} The Texture that was created. + */ + get: function (key) + { + if (key === undefined) { key = '__DEFAULT'; } + + if (this.list[key]) + { + return this.list[key]; + } + else + { + return this.list['__MISSING']; + } + }, + + /** + * Takes a Texture key and Frame name and returns a clone of that Frame if found. + * + * @method Phaser.Textures.TextureManager#cloneFrame + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame to be cloned. + * + * @return {Phaser.Textures.Frame} A Clone of the given Frame. + */ + cloneFrame: function (key, frame) + { + if (this.list[key]) + { + return this.list[key].get(frame).clone(); + } + }, + + /** + * Takes a Texture key and Frame name and returns a reference to that Frame, if found. + * + * @method Phaser.Textures.TextureManager#getFrame + * @since 3.0.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. + * + * @return {Phaser.Textures.Frame} A Texture Frame object. + */ + getFrame: function (key, frame) + { + if (this.list[key]) + { + return this.list[key].get(frame); + } + }, + + /** + * Returns an array with all of the keys of all Textures in this Texture Manager. + * The output array will exclude the `__DEFAULT` and `__MISSING` keys. + * + * @method Phaser.Textures.TextureManager#getTextureKeys + * @since 3.0.0 + * + * @return {string[]} An array containing all of the Texture keys stored in this Texture Manager. + */ + getTextureKeys: function () + { + var output = []; + + for (var key in this.list) + { + if (key !== '__DEFAULT' && key !== '__MISSING') + { + output.push(key); + } + } + + return output; + }, + + /** + * Given a Texture and an `x` and `y` coordinate this method will return a new + * Color object that has been populated with the color and alpha values of the pixel + * at that location in the Texture. + * + * @method Phaser.Textures.TextureManager#getPixel + * @since 3.0.0 + * + * @param {integer} x - The x coordinate of the pixel within the Texture. + * @param {integer} y - The y coordinate of the pixel within the Texture. + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame. + * + * @return {?Phaser.Display.Color} A Color object populated with the color values of the requested pixel, + * or `null` if the coordinates were out of bounds. + */ + getPixel: function (x, y, key, frame) + { + var textureFrame = this.getFrame(key, frame); + + if (textureFrame) + { + // Adjust for trim (if not trimmed x and y are just zero) + x -= textureFrame.x; + y -= textureFrame.y; + + var data = textureFrame.data.cut; + + x += data.x; + y += data.y; + + if (x >= data.x && x < data.r && y >= data.y && y < data.b) + { + var ctx = this._tempContext; + + ctx.clearRect(0, 0, 1, 1); + ctx.drawImage(textureFrame.source.image, x, y, 1, 1, 0, 0, 1, 1); + + var rgb = ctx.getImageData(0, 0, 1, 1); + + return new Color(rgb.data[0], rgb.data[1], rgb.data[2], rgb.data[3]); + } + } + + return null; + }, + + /** + * Given a Texture and an `x` and `y` coordinate this method will return a value between 0 and 255 + * corresponding to the alpha value of the pixel at that location in the Texture. If the coordinate + * is out of bounds it will return null. + * + * @method Phaser.Textures.TextureManager#getPixelAlpha + * @since 3.10.0 + * + * @param {integer} x - The x coordinate of the pixel within the Texture. + * @param {integer} y - The y coordinate of the pixel within the Texture. + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame. + * + * @return {integer} A value between 0 and 255, or `null` if the coordinates were out of bounds. + */ + getPixelAlpha: function (x, y, key, frame) + { + var textureFrame = this.getFrame(key, frame); + + if (textureFrame) + { + // Adjust for trim (if not trimmed x and y are just zero) + x -= textureFrame.x; + y -= textureFrame.y; + + var data = textureFrame.data.cut; + + x += data.x; + y += data.y; + + if (x >= data.x && x < data.r && y >= data.y && y < data.b) + { + var ctx = this._tempContext; + + ctx.clearRect(0, 0, 1, 1); + ctx.drawImage(textureFrame.source.image, x, y, 1, 1, 0, 0, 1, 1); + + var rgb = ctx.getImageData(0, 0, 1, 1); + + return rgb.data[3]; + } + } + + return null; + }, + + /** + * Sets the given Game Objects `texture` and `frame` properties so that it uses + * the Texture and Frame specified in the `key` and `frame` arguments to this method. + * + * @method Phaser.Textures.TextureManager#setTexture + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the texture would be set on. + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} frame - The string or index of the Frame. + * + * @return {Phaser.GameObjects.GameObject} The Game Object the texture was set on. + */ + setTexture: function (gameObject, key, frame) + { + if (this.list[key]) + { + gameObject.texture = this.list[key]; + gameObject.frame = gameObject.texture.get(frame); + } + + return gameObject; + }, + + /** + * Changes the key being used by a Texture to the new key provided. + * + * The old key is removed, allowing it to be re-used. + * + * Game Objects are linked to Textures by a reference to the Texture object, so + * all existing references will be retained. + * + * @method Phaser.Textures.TextureManager#renameTexture + * @since 3.12.0 + * + * @param {string} currentKey - The current string-based key of the Texture you wish to rename. + * @param {string} newKey - The new unique string-based key to use for the Texture. + * + * @return {boolean} `true` if the Texture key was successfully renamed, otherwise `false`. + */ + renameTexture: function (currentKey, newKey) + { + var texture = this.get(currentKey); + + if (texture && currentKey !== newKey) + { + texture.key = newKey; + + this.list[newKey] = texture; + + delete this.list[currentKey]; + + return true; + } + + return false; + }, + + /** + * Passes all Textures to the given callback. + * + * @method Phaser.Textures.TextureManager#each + * @since 3.0.0 + * + * @param {EachTextureCallback} callback - The callback function to be sent the Textures. + * @param {object} scope - The value to use as `this` when executing the callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + each: function (callback, scope) + { + var args = [ null ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var texture in this.list) + { + args[0] = this.list[texture]; + + callback.apply(scope, args); + } + }, + + /** + * Destroys the Texture Manager and all Textures stored within it. + * + * @method Phaser.Textures.TextureManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + for (var texture in this.list) + { + this.list[texture].destroy(); + } + + this.list = {}; + + this.game = null; + + CanvasPool.remove(this._tempCanvas); + } + +}); + +module.exports = TextureManager; + + +/***/ }), +/* 348 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSound = __webpack_require__(124); +var Class = __webpack_require__(0); + +/** + * @classdesc + * Web Audio API implementation of the sound. + * + * @class WebAudioSound + * @extends Phaser.Sound.BaseSound + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Sound.WebAudioSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + */ +var WebAudioSound = new Class({ + + Extends: BaseSound, + + initialize: + + function WebAudioSound (manager, key, config) + { + if (config === undefined) { config = {}; } + + /** + * Audio buffer containing decoded data of the audio asset to be played. + * + * @name Phaser.Sound.WebAudioSound#audioBuffer + * @type {AudioBuffer} + * @private + * @since 3.0.0 + */ + this.audioBuffer = manager.game.cache.audio.get(key); + + if (!this.audioBuffer) + { + // eslint-disable-next-line no-console + console.warn('Audio cache entry missing: ' + key); + return; + } + + /** + * A reference to an audio source node used for playing back audio from + * audio data stored in Phaser.Sound.WebAudioSound#audioBuffer. + * + * @name Phaser.Sound.WebAudioSound#source + * @type {AudioBufferSourceNode} + * @private + * @default null + * @since 3.0.0 + */ + this.source = null; + + /** + * A reference to a second audio source used for gapless looped playback. + * + * @name Phaser.Sound.WebAudioSound#loopSource + * @type {AudioBufferSourceNode} + * @private + * @default null + * @since 3.0.0 + */ + this.loopSource = null; + + /** + * Gain node responsible for controlling this sound's muting. + * + * @name Phaser.Sound.WebAudioSound#muteNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.muteNode = manager.context.createGain(); + + /** + * Gain node responsible for controlling this sound's volume. + * + * @name Phaser.Sound.WebAudioSound#volumeNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.volumeNode = manager.context.createGain(); + + /** + * The time at which the sound should have started playback from the beginning. + * Based on BaseAudioContext.currentTime value. + * + * @name Phaser.Sound.WebAudioSound#playTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.playTime = 0; + + /** + * The time at which the sound source should have actually started playback. + * Based on BaseAudioContext.currentTime value. + * + * @name Phaser.Sound.WebAudioSound#startTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.startTime = 0; + + /** + * The time at which the sound loop source should actually start playback. + * Based on BaseAudioContext.currentTime value. + * + * @name Phaser.Sound.WebAudioSound#loopTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.loopTime = 0; + + /** + * An array where we keep track of all rate updates during playback. + * Array of object types: { time: number, rate: number } + * + * @name Phaser.Sound.WebAudioSound#rateUpdates + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this.rateUpdates = []; + + /** + * Used for keeping track when sound source playback has ended + * so its state can be updated accordingly. + * + * @name Phaser.Sound.WebAudioSound#hasEnded + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.hasEnded = false; + + /** + * Used for keeping track when sound source has looped + * so its state can be updated accordingly. + * + * @name Phaser.Sound.WebAudioSound#hasLooped + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.hasLooped = false; + + this.muteNode.connect(this.volumeNode); + + this.volumeNode.connect(manager.destination); + + this.duration = this.audioBuffer.duration; + + this.totalDuration = this.audioBuffer.duration; + + BaseSound.call(this, manager, key, config); + }, + + /** + * @event Phaser.Sound.WebAudioSound#playEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. + */ + + /** + * Play this sound, or a marked section of it. + * + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * + * @method Phaser.Sound.WebAudioSound#play + * @fires Phaser.Sound.WebAudioSound#playEvent + * @since 3.0.0 + * + * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. + * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (markerName, config) + { + if (!BaseSound.prototype.play.call(this, markerName, config)) + { + return false; + } + + // \/\/\/ isPlaying = true, isPaused = false \/\/\/ + this.stopAndRemoveBufferSource(); + this.createAndStartBufferSource(); + + this.emit('play', this); + + return true; + }, + + /** + * @event Phaser.Sound.WebAudioSound#pauseEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. + */ + + /** + * Pauses the sound. + * + * @method Phaser.Sound.WebAudioSound#pause + * @fires Phaser.Sound.WebAudioSound#pauseEvent + * @since 3.0.0 + * + * @return {boolean} Whether the sound was paused successfully. + */ + pause: function () + { + if (this.manager.context.currentTime < this.startTime) + { + return false; + } + + if (!BaseSound.prototype.pause.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = false, isPaused = true \/\/\/ + this.currentConfig.seek = this.getCurrentTime(); // Equivalent to setting paused time + this.stopAndRemoveBufferSource(); + + this.emit('pause', this); + + return true; + }, + + /** + * @event Phaser.Sound.WebAudioSound#resumeEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. + */ + + /** + * Resumes the sound. + * + * @method Phaser.Sound.WebAudioSound#resume + * @fires Phaser.Sound.WebAudioSound#resumeEvent + * @since 3.0.0 + * + * @return {boolean} Whether the sound was resumed successfully. + */ + resume: function () + { + if (this.manager.context.currentTime < this.startTime) + { + return false; + } + + if (!BaseSound.prototype.resume.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = true, isPaused = false \/\/\/ + this.createAndStartBufferSource(); + + this.emit('resume', this); + + return true; + }, + + /** + * @event Phaser.Sound.WebAudioSound#stopEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. + */ + + /** + * Stop playing this sound. + * + * @method Phaser.Sound.WebAudioSound#stop + * @fires Phaser.Sound.WebAudioSound#stopEvent + * @since 3.0.0 + * + * @return {boolean} Whether the sound was stopped successfully. + */ + stop: function () + { + if (!BaseSound.prototype.stop.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = false, isPaused = false \/\/\/ + this.stopAndRemoveBufferSource(); + + this.emit('stop', this); + + return true; + }, + + /** + * Used internally. + * + * @method Phaser.Sound.WebAudioSound#createAndStartBufferSource + * @private + * @since 3.0.0 + */ + createAndStartBufferSource: function () + { + var seek = this.currentConfig.seek; + var delay = this.currentConfig.delay; + var when = this.manager.context.currentTime + delay; + var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek; + var duration = this.duration - seek; + + this.playTime = when - seek; + this.startTime = when; + this.source = this.createBufferSource(); + + this.applyConfig(); + + this.source.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); + + this.resetConfig(); + }, + + /** + * Used internally. + * + * @method Phaser.Sound.WebAudioSound#createAndStartLoopBufferSource + * @private + * @since 3.0.0 + */ + createAndStartLoopBufferSource: function () + { + var when = this.getLoopTime(); + var offset = this.currentMarker ? this.currentMarker.start : 0; + var duration = this.duration; + + this.loopTime = when; + this.loopSource = this.createBufferSource(); + this.loopSource.playbackRate.setValueAtTime(this.totalRate, 0); + this.loopSource.start(Math.max(0, when), Math.max(0, offset), Math.max(0, duration)); + }, + + /** + * Used internally. + * + * @method Phaser.Sound.WebAudioSound#createBufferSource + * @private + * @since 3.0.0 + * + * @return {AudioBufferSourceNode} + */ + createBufferSource: function () + { + var _this = this; + var source = this.manager.context.createBufferSource(); + + source.buffer = this.audioBuffer; + + source.connect(this.muteNode); + + source.onended = function (ev) + { + if (ev.target === _this.source) + { + // sound ended + if (_this.currentConfig.loop) + { + _this.hasLooped = true; + } + else + { + _this.hasEnded = true; + } + } + + // else was stopped + }; + + return source; + }, + + /** + * Used internally. + * + * @method Phaser.Sound.WebAudioSound#stopAndRemoveBufferSource + * @private + * @since 3.0.0 + */ + stopAndRemoveBufferSource: function () + { + if (this.source) + { + this.source.stop(); + this.source.disconnect(); + this.source = null; + } + + this.playTime = 0; + this.startTime = 0; + + this.stopAndRemoveLoopBufferSource(); + }, + + /** + * Used internally. + * + * @method Phaser.Sound.WebAudioSound#stopAndRemoveLoopBufferSource + * @private + * @since 3.0.0 + */ + stopAndRemoveLoopBufferSource: function () + { + if (this.loopSource) + { + this.loopSource.stop(); + this.loopSource.disconnect(); + this.loopSource = null; + } + + this.loopTime = 0; + }, + + /** + * Method used internally for applying config values to some of the sound properties. + * + * @method Phaser.Sound.WebAudioSound#applyConfig + * @protected + * @since 3.0.0 + */ + applyConfig: function () + { + this.rateUpdates.length = 0; + + this.rateUpdates.push({ + time: 0, + rate: 1 + }); + + BaseSound.prototype.applyConfig.call(this); + }, + + /** + * @event Phaser.Sound.WebAudioSound#endedEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + + /** + * @event Phaser.Sound.WebAudioSound#loopedEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + */ + + /** + * Update method called automatically by sound manager on every game step. + * + * @method Phaser.Sound.WebAudioSound#update + * @fires Phaser.Sound.WebAudioSound#endedEvent + * @fires Phaser.Sound.WebAudioSound#loopedEvent + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + // eslint-disable-next-line no-unused-vars + update: function (time, delta) + { + if (this.hasEnded) + { + this.hasEnded = false; + + BaseSound.prototype.stop.call(this); + + this.stopAndRemoveBufferSource(); + + this.emit('ended', this); + } + else if (this.hasLooped) + { + this.hasLooped = false; + this.source = this.loopSource; + this.loopSource = null; + this.playTime = this.startTime = this.loopTime; + this.rateUpdates.length = 0; + + this.rateUpdates.push({ + time: 0, + rate: this.totalRate + }); + + this.createAndStartLoopBufferSource(); + + this.emit('looped', this); + } + }, + + /** + * Calls Phaser.Sound.BaseSound#destroy method + * and cleans up all Web Audio API related stuff. + * + * @method Phaser.Sound.WebAudioSound#destroy + * @since 3.0.0 + */ + destroy: function () + { + BaseSound.prototype.destroy.call(this); + + this.audioBuffer = null; + this.stopAndRemoveBufferSource(); + this.muteNode.disconnect(); + this.muteNode = null; + this.volumeNode.disconnect(); + this.volumeNode = null; + this.rateUpdates.length = 0; + this.rateUpdates = null; + }, + + /** + * Method used internally to calculate total playback rate of the sound. + * + * @method Phaser.Sound.WebAudioSound#calculateRate + * @protected + * @since 3.0.0 + */ + calculateRate: function () + { + BaseSound.prototype.calculateRate.call(this); + + var now = this.manager.context.currentTime; + + if (this.source && typeof this.totalRate === 'number') + { + this.source.playbackRate.setValueAtTime(this.totalRate, now); + } + + if (this.isPlaying) + { + this.rateUpdates.push({ + time: Math.max(this.startTime, now) - this.playTime, + rate: this.totalRate + }); + + if (this.loopSource) + { + this.stopAndRemoveLoopBufferSource(); + this.createAndStartLoopBufferSource(); + } + } + }, + + /** + * Method used internally for calculating current playback time of a playing sound. + * + * @method Phaser.Sound.WebAudioSound#getCurrentTime + * @private + * @since 3.0.0 + */ + getCurrentTime: function () + { + var currentTime = 0; + + for (var i = 0; i < this.rateUpdates.length; i++) + { + var nextTime = 0; + + if (i < this.rateUpdates.length - 1) + { + nextTime = this.rateUpdates[i + 1].time; + } + else + { + nextTime = this.manager.context.currentTime - this.playTime; + } + + currentTime += (nextTime - this.rateUpdates[i].time) * this.rateUpdates[i].rate; + } + + return currentTime; + }, + + /** + * Method used internally for calculating the time + * at witch the loop source should start playing. + * + * @method Phaser.Sound.WebAudioSound#getLoopTime + * @private + * @since 3.0.0 + */ + getLoopTime: function () + { + var lastRateUpdateCurrentTime = 0; + + for (var i = 0; i < this.rateUpdates.length - 1; i++) + { + lastRateUpdateCurrentTime += (this.rateUpdates[i + 1].time - this.rateUpdates[i].time) * this.rateUpdates[i].rate; + } + + var lastRateUpdate = this.rateUpdates[this.rateUpdates.length - 1]; + + return this.playTime + lastRateUpdate.time + (this.duration - lastRateUpdateCurrentTime) / lastRateUpdate.rate; + }, + + /** + * @event Phaser.Sound.WebAudioSound#rateEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted the event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#rate property. + */ + + /** + * Rate at which this Sound will be played. + * 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. + * + * @name Phaser.Sound.WebAudioSound#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rate: { + + get: function () + { + return this.currentConfig.rate; + }, + + set: function (value) + { + this.currentConfig.rate = value; + + this.calculateRate(); + + this.emit('rate', this, value); + } + + }, + + /** + * Sets the playback rate of this Sound. + * + * 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. + * + * @method Phaser.Sound.WebAudioSound#setRate + * @fires Phaser.Sound.WebAudioSound#rateEvent + * @since 3.3.0 + * + * @param {number} value - The playback rate at of this Sound. + * + * @return {Phaser.Sound.WebAudioSound} This Sound. + */ + setRate: function (value) + { + this.rate = value; + + return this; + }, + + /** + * @event Phaser.Sound.WebAudioSound#detuneEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the Sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#detune property. + */ + + /** + * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.WebAudioSound#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + detune: { + + get: function () + { + return this.currentConfig.detune; + }, + + set: function (value) + { + this.currentConfig.detune = value; + + this.calculateRate(); + + this.emit('detune', this, value); + } + + }, + + /** + * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @method Phaser.Sound.WebAudioSound#setDetune + * @fires Phaser.Sound.WebAudioSound#detuneEvent + * @since 3.3.0 + * + * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @return {Phaser.Sound.WebAudioSound} This Sound. + */ + setDetune: function (value) + { + this.detune = value; + + return this; + }, + + /** + * @event Phaser.Sound.WebAudioSound#muteEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#mute property. + */ + + /** + * 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} + * @default false + * @since 3.0.0 + */ + mute: { + + get: function () + { + return (this.muteNode.gain.value === 0); + }, + + set: function (value) + { + this.currentConfig.mute = value; + this.muteNode.gain.setValueAtTime(value ? 0 : 1, 0); + + this.emit('mute', this, value); + } + + }, + + /** + * Sets the muted state of this Sound. + * + * @method Phaser.Sound.WebAudioSound#setMute + * @fires Phaser.Sound.WebAudioSound#muteEvent + * @since 3.4.0 + * + * @param {boolean} value - `true` to mute this sound, `false` to unmute it. + * + * @return {Phaser.Sound.WebAudioSound} This Sound instance. + */ + setMute: function (value) + { + this.mute = value; + + return this; + }, + + /** + * @event Phaser.Sound.WebAudioSound#volumeEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#volume property. + */ + + /** + * Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume). + * + * @name Phaser.Sound.WebAudioSound#volume + * @type {number} + * @default 1 + * @since 3.0.0 + */ + volume: { + + get: function () + { + return this.volumeNode.gain.value; + }, + + set: function (value) + { + this.currentConfig.volume = value; + this.volumeNode.gain.setValueAtTime(value, 0); + + this.emit('volume', this, value); + } + }, + + /** + * Sets the volume of this Sound. + * + * @method Phaser.Sound.WebAudioSound#setVolume + * @fires Phaser.Sound.WebAudioSound#volumeEvent + * @since 3.4.0 + * + * @param {number} value - The volume of the sound. + * + * @return {Phaser.Sound.WebAudioSound} This Sound instance. + */ + setVolume: function (value) + { + this.volume = value; + + return this; + }, + + /** + * @event Phaser.Sound.WebAudioSound#seekEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSound#seek property. + */ + + /** + * 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} + * @since 3.0.0 + */ + seek: { + + get: function () + { + if (this.isPlaying) + { + if (this.manager.context.currentTime < this.startTime) + { + return this.startTime - this.playTime; + } + + return this.getCurrentTime(); + } + else if (this.isPaused) + { + return this.currentConfig.seek; + } + else + { + return 0; + } + }, + + set: function (value) + { + if (this.manager.context.currentTime < this.startTime) + { + return; + } + + if (this.isPlaying || this.isPaused) + { + value = Math.min(Math.max(0, value), this.duration); + + this.currentConfig.seek = value; + + if (this.isPlaying) + { + this.stopAndRemoveBufferSource(); + this.createAndStartBufferSource(); + } + + this.emit('seek', this, value); + } + } + }, + + /** + * Seeks to a specific point in this sound. + * + * @method Phaser.Sound.WebAudioSound#setSeek + * @fires Phaser.Sound.WebAudioSound#seekEvent + * @since 3.4.0 + * + * @param {number} value - The point in the sound to seek to. + * + * @return {Phaser.Sound.WebAudioSound} This Sound instance. + */ + setSeek: function (value) + { + this.seek = value; + + return this; + }, + + /** + * @event Phaser.Sound.WebAudioSound#loopEvent + * @param {Phaser.Sound.WebAudioSound} sound - Reference to the sound that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSound#loop property. + */ + + /** + * Flag indicating whether or not the sound or current sound marker will loop. + * + * @name Phaser.Sound.WebAudioSound#loop + * @type {boolean} + * @default false + * @since 3.0.0 + */ + loop: { + + get: function () + { + return this.currentConfig.loop; + }, + + set: function (value) + { + this.currentConfig.loop = value; + + if (this.isPlaying) + { + this.stopAndRemoveLoopBufferSource(); + + if (value) + { + this.createAndStartLoopBufferSource(); + } + } + + this.emit('loop', this, value); + } + }, + + /** + * Sets the loop state of this Sound. + * + * @method Phaser.Sound.WebAudioSound#setLoop + * @fires Phaser.Sound.WebAudioSound#loopEvent + * @since 3.4.0 + * + * @param {boolean} value - `true` to loop this sound, `false` to not loop it. + * + * @return {Phaser.Sound.WebAudioSound} This Sound instance. + */ + setLoop: function (value) + { + this.loop = value; + + return this; + } + +}); + +module.exports = WebAudioSound; + + +/***/ }), +/* 349 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSoundManager = __webpack_require__(125); +var Class = __webpack_require__(0); +var WebAudioSound = __webpack_require__(348); + +/** + * @classdesc + * Web Audio API implementation of the sound manager. + * + * @class WebAudioSoundManager + * @extends Phaser.Sound.BaseSoundManager + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var WebAudioSoundManager = new Class({ + + Extends: BaseSoundManager, + + initialize: + + function WebAudioSoundManager (game) + { + /** + * The AudioContext being used for playback. + * + * @name Phaser.Sound.WebAudioSoundManager#context + * @type {AudioContext} + * @private + * @since 3.0.0 + */ + this.context = this.createAudioContext(game); + + /** + * Gain node responsible for controlling global muting. + * + * @name Phaser.Sound.WebAudioSoundManager#masterMuteNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.masterMuteNode = this.context.createGain(); + + /** + * Gain node responsible for controlling global volume. + * + * @name Phaser.Sound.WebAudioSoundManager#masterVolumeNode + * @type {GainNode} + * @private + * @since 3.0.0 + */ + this.masterVolumeNode = this.context.createGain(); + + this.masterMuteNode.connect(this.masterVolumeNode); + + this.masterVolumeNode.connect(this.context.destination); + + /** + * Destination node for connecting individual sounds to. + * + * @name Phaser.Sound.WebAudioSoundManager#destination + * @type {AudioNode} + * @private + * @since 3.0.0 + */ + this.destination = this.masterMuteNode; + + this.locked = this.context.state === 'suspended' && ('ontouchstart' in window || 'onclick' in window); + + BaseSoundManager.call(this, game); + + if (this.locked) + { + this.unlock(); + } + }, + + /** + * Method responsible for instantiating and returning AudioContext instance. + * If an instance of an AudioContext class was provided through the game config, + * that instance will be returned instead. This can come in handy if you are reloading + * a Phaser game on a page that never properly refreshes (such as in an SPA project) + * and you want to reuse already instantiated AudioContext. + * + * @method Phaser.Sound.WebAudioSoundManager#createAudioContext + * @private + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + * + * @return {AudioContext} The AudioContext instance to be used for playback. + */ + createAudioContext: function (game) + { + var audioConfig = game.config.audio; + + if (audioConfig && audioConfig.context) + { + audioConfig.context.resume(); + + return audioConfig.context; + } + + return new AudioContext(); + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.WebAudioSoundManager#add + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.WebAudioSound} The new sound instance. + */ + add: function (key, config) + { + var sound = new WebAudioSound(this, key, config); + + this.sounds.push(sound); + + return sound; + }, + + /** + * Unlocks Web Audio API on the initial input event. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + * + * @method Phaser.Sound.WebAudioSoundManager#unlock + * @since 3.0.0 + */ + unlock: function () + { + var _this = this; + + var unlock = function () + { + _this.context.resume().then(function () + { + document.body.removeEventListener('touchstart', unlock); + document.body.removeEventListener('touchend', unlock); + document.body.removeEventListener('click', unlock); + + _this.unlocked = true; + }); + }; + + if (document.body) + { + document.body.addEventListener('touchstart', unlock, false); + document.body.addEventListener('touchend', unlock, false); + document.body.addEventListener('click', unlock, false); + } + }, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.WebAudioSoundManager#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.context.suspend(); + }, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.WebAudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.WebAudioSoundManager#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.context.resume(); + }, + + /** + * Calls Phaser.Sound.BaseSoundManager#destroy method + * and cleans up all Web Audio API related stuff. + * + * @method Phaser.Sound.WebAudioSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.destination = null; + this.masterVolumeNode.disconnect(); + this.masterVolumeNode = null; + this.masterMuteNode.disconnect(); + this.masterMuteNode = null; + + if (this.game.config.audio && this.game.config.audio.context) + { + this.context.suspend(); + } + else + { + var _this = this; + + this.context.close().then(function () + { + + _this.context = null; + + }); + } + + BaseSoundManager.prototype.destroy.call(this); + }, + + /** + * @event Phaser.Sound.WebAudioSoundManager#muteEvent + * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.WebAudioSoundManager#mute property. + */ + + /** + * Sets the muted state of all this Sound Manager. + * + * @method Phaser.Sound.WebAudioSoundManager#setMute + * @fires Phaser.Sound.WebAudioSoundManager#muteEvent + * @since 3.3.0 + * + * @param {boolean} value - `true` to mute all sounds, `false` to unmute them. + * + * @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager. + */ + setMute: function (value) + { + this.mute = value; + + return this; + }, + + /** + * @name Phaser.Sound.WebAudioSoundManager#mute + * @type {boolean} + * @fires Phaser.Sound.WebAudioSoundManager#MuteEvent + * @since 3.0.0 + */ + mute: { + + get: function () + { + return (this.masterMuteNode.gain.value === 0); + }, + + set: function (value) + { + this.masterMuteNode.gain.setValueAtTime(value ? 0 : 1, 0); + + this.emit('mute', this, value); + } + + }, + + /** + * @event Phaser.Sound.WebAudioSoundManager#VolumeEvent + * @param {Phaser.Sound.WebAudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.WebAudioSoundManager#volume property. + */ + + /** + * Sets the volume of this Sound Manager. + * + * @method Phaser.Sound.WebAudioSoundManager#setVolume + * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent + * @since 3.3.0 + * + * @param {number} value - The global volume of this Sound Manager. + * + * @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager. + */ + setVolume: function (value) + { + this.volume = value; + + return this; + }, + + /** + * @name Phaser.Sound.WebAudioSoundManager#volume + * @type {number} + * @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent + * @since 3.0.0 + */ + volume: { + + get: function () + { + return this.masterVolumeNode.gain.value; + }, + + set: function (value) + { + this.masterVolumeNode.gain.setValueAtTime(value, 0); + + this.emit('volume', this, value); + } + + } + +}); + +module.exports = WebAudioSoundManager; + + +/***/ }), +/* 350 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSound = __webpack_require__(124); +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var Extend = __webpack_require__(21); + +/** + * @classdesc + * No audio implementation of the sound. It is used if audio has been + * disabled in the game config or the device doesn't support any audio. + * + * It represents a graceful degradation of sound logic that provides + * minimal functionality and prevents Phaser projects that use audio from + * breaking on devices that don't support any audio playback technologies. + * + * @class NoAudioSound + * @extends Phaser.Sound.BaseSound + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Sound.NoAudioSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + */ +var NoAudioSound = new Class({ + + Extends: EventEmitter, + + initialize: + + function NoAudioSound (manager, key, config) + { + if (config === void 0) { config = {}; } + + EventEmitter.call(this); + + this.manager = manager; + this.key = key; + this.isPlaying = false; + this.isPaused = false; + this.totalRate = 1; + this.duration = 0; + this.totalDuration = 0; + + this.config = Extend({ + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + }, config); + + this.currentConfig = this.config; + this.mute = false; + this.volume = 1; + this.rate = 1; + this.detune = 0; + this.seek = 0; + this.loop = false; + this.markers = {}; + this.currentMarker = null; + this.pendingRemove = false; + }, + + // eslint-disable-next-line no-unused-vars + addMarker: function (marker) + { + return false; + }, + + // eslint-disable-next-line no-unused-vars + updateMarker: function (marker) + { + return false; + }, + + // eslint-disable-next-line no-unused-vars + removeMarker: function (markerName) + { + return null; + }, + + // eslint-disable-next-line no-unused-vars + play: function (markerName, config) + { + return false; + }, + + pause: function () + { + return false; + }, + + resume: function () + { + return false; + }, + + stop: function () + { + return false; + }, + + destroy: function () + { + this.manager.remove(this); + + BaseSound.prototype.destroy.call(this); + } +}); + +module.exports = NoAudioSound; + + +/***/ }), +/* 351 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSoundManager = __webpack_require__(125); +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var NoAudioSound = __webpack_require__(350); +var NOOP = __webpack_require__(2); + +/** + * @classdesc + * No audio implementation of the sound manager. It is used if audio has been + * disabled in the game config or the device doesn't support any audio. + * + * It represents a graceful degradation of sound manager logic that provides + * minimal functionality and prevents Phaser projects that use audio from + * breaking on devices that don't support any audio playback technologies. + * + * @class NoAudioSoundManager + * @extends Phaser.Sound.BaseSoundManager + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var NoAudioSoundManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function NoAudioSoundManager (game) + { + EventEmitter.call(this); + + this.game = game; + this.sounds = []; + this.mute = false; + this.volume = 1; + this.rate = 1; + this.detune = 0; + this.pauseOnBlur = true; + this.locked = false; + }, + + add: function (key, config) + { + var sound = new NoAudioSound(this, key, config); + + this.sounds.push(sound); + + return sound; + }, + + addAudioSprite: function (key, config) + { + var sound = this.add(key, config); + + sound.spritemap = {}; + + return sound; + }, + + // eslint-disable-next-line no-unused-vars + play: function (key, extra) + { + return false; + }, + + // eslint-disable-next-line no-unused-vars + playAudioSprite: function (key, spriteName, config) + { + return false; + }, + + remove: function (sound) + { + return BaseSoundManager.prototype.remove.call(this, sound); + }, + + removeByKey: function (key) + { + return BaseSoundManager.prototype.removeByKey.call(this, key); + }, + + pauseAll: NOOP, + resumeAll: NOOP, + stopAll: NOOP, + update: NOOP, + setRate: NOOP, + setDetune: NOOP, + setMute: NOOP, + setVolume: NOOP, + + forEachActiveSound: function (callbackfn, scope) + { + BaseSoundManager.prototype.forEachActiveSound.call(this, callbackfn, scope); + }, + + destroy: function () + { + BaseSoundManager.prototype.destroy.call(this); + } + +}); + +module.exports = NoAudioSoundManager; + + +/***/ }), +/* 352 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSound = __webpack_require__(124); +var Class = __webpack_require__(0); + +/** + * @classdesc + * HTML5 Audio implementation of the sound. + * + * @class HTML5AudioSound + * @extends Phaser.Sound.BaseSound + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Sound.HTML5AudioSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + */ +var HTML5AudioSound = new Class({ + + Extends: BaseSound, + + initialize: + + function HTML5AudioSound (manager, key, config) + { + if (config === undefined) { config = {}; } + + /** + * An array containing all HTML5 Audio tags that could be used for individual + * sound's playback. Number of instances depends on the config value passed + * to the Loader#audio method call, default is 1. + * + * @name Phaser.Sound.HTML5AudioSound#tags + * @type {HTMLAudioElement[]} + * @private + * @since 3.0.0 + */ + this.tags = manager.game.cache.audio.get(key); + + if (!this.tags) + { + // eslint-disable-next-line no-console + console.warn('Audio cache entry missing: ' + key); + return; + } + + /** + * Reference to an HTML5 Audio tag used for playing sound. + * + * @name Phaser.Sound.HTML5AudioSound#audio + * @type {HTMLAudioElement} + * @private + * @default null + * @since 3.0.0 + */ + this.audio = null; + + /** + * Timestamp as generated by the Request Animation Frame or SetTimeout + * representing the time at which the delayed sound playback should start. + * Set to 0 if sound playback is not delayed. + * + * @name Phaser.Sound.HTML5AudioSound#startTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.startTime = 0; + + /** + * Audio tag's playback position recorded on previous + * update method call. Set to 0 if sound is not playing. + * + * @name Phaser.Sound.HTML5AudioSound#previousTime + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.previousTime = 0; + + this.duration = this.tags[0].duration; + + this.totalDuration = this.tags[0].duration; + + BaseSound.call(this, manager, key, config); + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#playEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + */ + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * + * @method Phaser.Sound.HTML5AudioSound#play + * @fires Phaser.Sound.HTML5AudioSound#playEvent + * @since 3.0.0 + * + * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. + * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (markerName, config) + { + if (this.manager.isLocked(this, 'play', [ markerName, config ])) + { + return false; + } + + if (!BaseSound.prototype.play.call(this, markerName, config)) + { + return false; + } + + // \/\/\/ isPlaying = true, isPaused = false \/\/\/ + if (!this.pickAndPlayAudioTag()) + { + return false; + } + + this.emit('play', this); + + return true; + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#pauseEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + */ + + /** + * Pauses the sound. + * + * @method Phaser.Sound.HTML5AudioSound#pause + * @fires Phaser.Sound.HTML5AudioSound#pauseEvent + * @since 3.0.0 + * + * @return {boolean} Whether the sound was paused successfully. + */ + pause: function () + { + if (this.manager.isLocked(this, 'pause')) + { + return false; + } + + if (this.startTime > 0) + { + return false; + } + + if (!BaseSound.prototype.pause.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = false, isPaused = true \/\/\/ + this.currentConfig.seek = this.audio.currentTime - (this.currentMarker ? this.currentMarker.start : 0); + + this.stopAndReleaseAudioTag(); + + this.emit('pause', this); + + return true; + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#resumeEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + */ + + /** + * Resumes the sound. + * + * @method Phaser.Sound.HTML5AudioSound#resume + * @fires Phaser.Sound.HTML5AudioSound#resumeEvent + * @since 3.0.0 + * + * @return {boolean} Whether the sound was resumed successfully. + */ + resume: function () + { + if (this.manager.isLocked(this, 'resume')) + { + return false; + } + + if (this.startTime > 0) + { + return false; + } + + if (!BaseSound.prototype.resume.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = true, isPaused = false \/\/\/ + if (!this.pickAndPlayAudioTag()) + { + return false; + } + + this.emit('resume', this); + + return true; + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#stopEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + */ + + /** + * Stop playing this sound. + * + * @method Phaser.Sound.HTML5AudioSound#stop + * @fires Phaser.Sound.HTML5AudioSound#stopEvent + * @since 3.0.0 + * + * @return {boolean} Whether the sound was stopped successfully. + */ + stop: function () + { + if (this.manager.isLocked(this, 'stop')) + { + return false; + } + + if (!BaseSound.prototype.stop.call(this)) + { + return false; + } + + // \/\/\/ isPlaying = false, isPaused = false \/\/\/ + this.stopAndReleaseAudioTag(); + + this.emit('stop', this); + + return true; + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.HTML5AudioSound#pickAndPlayAudioTag + * @private + * @since 3.0.0 + * + * @return {boolean} Whether the sound was assigned an audio tag successfully. + */ + pickAndPlayAudioTag: function () + { + if (!this.pickAudioTag()) + { + this.reset(); + return false; + } + + var seek = this.currentConfig.seek; + var delay = this.currentConfig.delay; + var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek; + + this.previousTime = offset; + this.audio.currentTime = offset; + this.applyConfig(); + + if (delay === 0) + { + this.startTime = 0; + + if (this.audio.paused) + { + this.playCatchPromise(); + } + } + else + { + this.startTime = window.performance.now() + delay * 1000; + + if (!this.audio.paused) + { + this.audio.pause(); + } + } + + this.resetConfig(); + + return true; + }, + + /** + * This method performs the audio tag pooling logic. It first looks for + * unused audio tag to assign to this sound object. If there are no unused + * audio tags, based on HTML5AudioSoundManager#override property value, it + * looks for sound with most advanced playback and hijacks its audio tag or + * does nothing. + * + * @method Phaser.Sound.HTML5AudioSound#pickAudioTag + * @private + * @since 3.0.0 + * + * @return {boolean} Whether the sound was assigned an audio tag successfully. + */ + pickAudioTag: function () + { + if (this.audio) + { + return true; + } + + for (var i = 0; i < this.tags.length; i++) + { + var audio = this.tags[i]; + + if (audio.dataset.used === 'false') + { + audio.dataset.used = 'true'; + this.audio = audio; + return true; + } + } + + if (!this.manager.override) + { + return false; + } + + var otherSounds = []; + + this.manager.forEachActiveSound(function (sound) + { + if (sound.key === this.key && sound.audio) + { + otherSounds.push(sound); + } + }, this); + + otherSounds.sort(function (a1, a2) + { + if (a1.loop === a2.loop) + { + // sort by progress + return (a2.seek / a2.duration) - (a1.seek / a1.duration); + } + return a1.loop ? 1 : -1; + }); + + var selectedSound = otherSounds[0]; + + this.audio = selectedSound.audio; + + selectedSound.reset(); + selectedSound.audio = null; + selectedSound.startTime = 0; + selectedSound.previousTime = 0; + + return true; + }, + + /** + * Method used for playing audio tag and catching possible exceptions + * thrown from rejected Promise returned from play method call. + * + * @method Phaser.Sound.HTML5AudioSound#playCatchPromise + * @private + * @since 3.0.0 + */ + playCatchPromise: function () + { + var playPromise = this.audio.play(); + + if (playPromise) + { + // eslint-disable-next-line no-unused-vars + playPromise.catch(function (reason) + { + console.warn(reason); + }); + } + }, + + /** + * Used internally to do what the name says. + * + * @method Phaser.Sound.HTML5AudioSound#stopAndReleaseAudioTag + * @private + * @since 3.0.0 + */ + stopAndReleaseAudioTag: function () + { + this.audio.pause(); + this.audio.dataset.used = 'false'; + this.audio = null; + this.startTime = 0; + this.previousTime = 0; + }, + + /** + * Method used internally to reset sound state, usually when stopping sound + * or when hijacking audio tag from another sound. + * + * @method Phaser.Sound.HTML5AudioSound#reset + * @private + * @since 3.0.0 + */ + reset: function () + { + BaseSound.prototype.stop.call(this); + }, + + /** + * Method used internally by sound manager for pausing sound if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.HTML5AudioSoundManager#onBlur + * @private + * @since 3.0.0 + */ + onBlur: function () + { + this.isPlaying = false; + this.isPaused = true; + + this.currentConfig.seek = this.audio.currentTime - (this.currentMarker ? this.currentMarker.start : 0); + + this.currentConfig.delay = Math.max(0, (this.startTime - window.performance.now()) / 1000); + + this.stopAndReleaseAudioTag(); + }, + + /** + * Method used internally by sound manager for resuming sound if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.HTML5AudioSound#onFocus + * @private + * @since 3.0.0 + */ + onFocus: function () + { + this.isPlaying = true; + this.isPaused = false; + this.pickAndPlayAudioTag(); + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#loopedEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + */ + + /** + * @event Phaser.Sound.HTML5AudioSound#endedEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + */ + + /** + * Update method called automatically by sound manager on every game step. + * + * @method Phaser.Sound.HTML5AudioSound#update + * @fires Phaser.Sound.HTML5AudioSound#loopedEvent + * @fires Phaser.Sound.HTML5AudioSound#endedEvent + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + // eslint-disable-next-line no-unused-vars + update: function (time, delta) + { + if (!this.isPlaying) + { + return; + } + + // handling delayed playback + if (this.startTime > 0) + { + if (this.startTime < time - this.manager.audioPlayDelay) + { + this.audio.currentTime += Math.max(0, time - this.startTime) / 1000; + this.startTime = 0; + this.previousTime = this.audio.currentTime; + this.playCatchPromise(); + } + + return; + } + + // handle looping and ending + var startTime = this.currentMarker ? this.currentMarker.start : 0; + var endTime = startTime + this.duration; + var currentTime = this.audio.currentTime; + + if (this.currentConfig.loop) + { + if (currentTime >= endTime - this.manager.loopEndOffset) + { + this.audio.currentTime = startTime + Math.max(0, currentTime - endTime); + currentTime = this.audio.currentTime; + } + else if (currentTime < startTime) + { + this.audio.currentTime += startTime; + currentTime = this.audio.currentTime; + } + + if (currentTime < this.previousTime) + { + this.emit('looped', this); + } + } + else if (currentTime >= endTime) + { + this.reset(); + + this.stopAndReleaseAudioTag(); + + this.emit('ended', this); + + return; + } + + this.previousTime = currentTime; + }, + + /** + * Calls Phaser.Sound.BaseSound#destroy method + * and cleans up all HTML5 Audio related stuff. + * + * @method Phaser.Sound.HTML5AudioSound#destroy + * @since 3.0.0 + */ + destroy: function () + { + BaseSound.prototype.destroy.call(this); + + this.tags = null; + + if (this.audio) + { + this.stopAndReleaseAudioTag(); + } + }, + + /** + * Method used internally to determine mute setting of the sound. + * + * @method Phaser.Sound.HTML5AudioSound#updateMute + * @private + * @since 3.0.0 + */ + updateMute: function () + { + if (this.audio) + { + this.audio.muted = this.currentConfig.mute || this.manager.mute; + } + }, + + /** + * Method used internally to calculate total volume of the sound. + * + * @method Phaser.Sound.HTML5AudioSound#updateVolume + * @private + * @since 3.0.0 + */ + updateVolume: function () + { + if (this.audio) + { + this.audio.volume = this.currentConfig.volume * this.manager.volume; + } + }, + + /** + * Method used internally to calculate total playback rate of the sound. + * + * @method Phaser.Sound.HTML5AudioSound#calculateRate + * @protected + * @since 3.0.0 + */ + calculateRate: function () + { + BaseSound.prototype.calculateRate.call(this); + + if (this.audio) + { + this.audio.playbackRate = this.totalRate; + } + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#muteEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSound#mute property. + */ + + /** + * 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} + * @default false + * @since 3.0.0 + */ + mute: { + + get: function () + { + return this.currentConfig.mute; + }, + + set: function (value) + { + this.currentConfig.mute = value; + + if (this.manager.isLocked(this, 'mute', value)) + { + return; + } + + this.emit('mute', this, value); + } + }, + + /** + * Sets the muted state of this Sound. + * + * @method Phaser.Sound.HTML5AudioSound#setMute + * @fires Phaser.Sound.HTML5AudioSound#muteEvent + * @since 3.4.0 + * + * @param {boolean} value - `true` to mute this sound, `false` to unmute it. + * + * @return {Phaser.Sound.HTML5AudioSound} This Sound instance. + */ + setMute: function (value) + { + this.mute = value; + + return this; + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#volumeEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSound#volume property. + */ + + /** + * Gets or sets the volume of this sound, a value between 0 (silence) and 1 (full volume). + * + * @name Phaser.Sound.HTML5AudioSound#volume + * @type {number} + * @default 1 + * @since 3.0.0 + */ + volume: { + + get: function () + { + return this.currentConfig.volume; + }, + + set: function (value) + { + this.currentConfig.volume = value; + + if (this.manager.isLocked(this, 'volume', value)) + { + return; + } + + this.emit('volume', this, value); + } + }, + + /** + * Sets the volume of this Sound. + * + * @method Phaser.Sound.HTML5AudioSound#setVolume + * @fires Phaser.Sound.HTML5AudioSound#volumeEvent + * @since 3.4.0 + * + * @param {number} value - The volume of the sound. + * + * @return {Phaser.Sound.HTML5AudioSound} This Sound instance. + */ + setVolume: function (value) + { + this.volume = value; + + return this; + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#rateEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted the event. + * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSound#rate property. + */ + + /** + * Rate at which this Sound will be played. + * 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. + * + * @name Phaser.Sound.HTML5AudioSound#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rate: { + + get: function () + { + return this.currentConfig.rate; + }, + + set: function (value) + { + this.currentConfig.rate = value; + + if (this.manager.isLocked(this, 'rate', value)) + { + return; + } + else + { + this.calculateRate(); + + this.emit('rate', this, value); + } + } + + }, + + /** + * Sets the playback rate of this Sound. + * + * 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. + * + * @method Phaser.Sound.HTML5AudioSound#setRate + * @fires Phaser.Sound.HTML5AudioSound#rateEvent + * @since 3.3.0 + * + * @param {number} value - The playback rate at of this Sound. + * + * @return {Phaser.Sound.HTML5AudioSound} This Sound. + */ + setRate: function (value) + { + this.rate = value; + + return this; + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#detuneEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the Sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSound#detune property. + */ + + /** + * The detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.HTML5AudioSound#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + detune: { + + get: function () + { + return this.currentConfig.detune; + }, + + set: function (value) + { + this.currentConfig.detune = value; + + if (this.manager.isLocked(this, 'detune', value)) + { + return; + } + else + { + this.calculateRate(); + + this.emit('detune', this, value); + } + } + + }, + + /** + * Sets the detune value of this Sound, given in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @method Phaser.Sound.HTML5AudioSound#setDetune + * @fires Phaser.Sound.HTML5AudioSound#detuneEvent + * @since 3.3.0 + * + * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @return {Phaser.Sound.HTML5AudioSound} This Sound. + */ + setDetune: function (value) + { + this.detune = value; + + return this; + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#seekEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSound#seek property. + */ + + /** + * 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} + * @since 3.0.0 + */ + seek: { + + get: function () + { + if (this.isPlaying) + { + return this.audio.currentTime - (this.currentMarker ? this.currentMarker.start : 0); + } + else if (this.isPaused) + { + return this.currentConfig.seek; + } + else + { + return 0; + } + }, + + set: function (value) + { + if (this.manager.isLocked(this, 'seek', value)) + { + return; + } + + if (this.startTime > 0) + { + return; + } + + if (this.isPlaying || this.isPaused) + { + value = Math.min(Math.max(0, value), this.duration); + + if (this.isPlaying) + { + this.previousTime = value; + this.audio.currentTime = value; + } + else if (this.isPaused) + { + this.currentConfig.seek = value; + } + + this.emit('seek', this, value); + } + } + }, + + /** + * Seeks to a specific point in this sound. + * + * @method Phaser.Sound.HTML5AudioSound#setSeek + * @fires Phaser.Sound.HTML5AudioSound#seekEvent + * @since 3.4.0 + * + * @param {number} value - The point in the sound to seek to. + * + * @return {Phaser.Sound.HTML5AudioSound} This Sound instance. + */ + setSeek: function (value) + { + this.seek = value; + + return this; + }, + + /** + * @event Phaser.Sound.HTML5AudioSound#loopEvent + * @param {Phaser.Sound.HTML5AudioSound} sound - Reference to the sound that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSound#loop property. + */ + + /** + * Flag indicating whether or not the sound or current sound marker will loop. + * + * @name Phaser.Sound.HTML5AudioSound#loop + * @type {boolean} + * @default false + * @since 3.0.0 + */ + loop: { + + get: function () + { + return this.currentConfig.loop; + }, + + set: function (value) + { + this.currentConfig.loop = value; + + if (this.manager.isLocked(this, 'loop', value)) + { + return; + } + + if (this.audio) + { + this.audio.loop = value; + } + + this.emit('loop', this, value); + } + + }, + + /** + * Sets the loop state of this Sound. + * + * @method Phaser.Sound.HTML5AudioSound#setLoop + * @fires Phaser.Sound.HTML5AudioSound#loopEvent + * @since 3.4.0 + * + * @param {boolean} value - `true` to loop this sound, `false` to not loop it. + * + * @return {Phaser.Sound.HTML5AudioSound} This Sound instance. + */ + setLoop: function (value) + { + this.loop = value; + + return this; + } + +}); + +module.exports = HTML5AudioSound; + + +/***/ }), +/* 353 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseSoundManager = __webpack_require__(125); +var Class = __webpack_require__(0); +var HTML5AudioSound = __webpack_require__(352); + +/** + * HTML5 Audio implementation of the Sound Manager. + * + * @class HTML5AudioSoundManager + * @extends Phaser.Sound.BaseSoundManager + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var HTML5AudioSoundManager = new Class({ + + Extends: BaseSoundManager, + + initialize: + + function HTML5AudioSoundManager (game) + { + /** + * Flag indicating whether if there are no idle instances of HTML5 Audio tag, + * for any particular sound, if one of the used tags should be hijacked and used + * for succeeding playback or if succeeding Phaser.Sound.HTML5AudioSound#play + * call should be ignored. + * + * @name Phaser.Sound.HTML5AudioSoundManager#override + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.override = true; + + /** + * Value representing time difference, in seconds, between calling + * play method on an audio tag and when it actually starts playing. + * It is used to achieve more accurate delayed sound playback. + * + * You might need to tweak this value to get the desired results + * since audio play delay varies depending on the browser/platform. + * + * @name Phaser.Sound.HTML5AudioSoundManager#audioPlayDelay + * @type {number} + * @default 0.1 + * @since 3.0.0 + */ + this.audioPlayDelay = 0.1; + + /** + * A value by which we should offset the loop end marker of the + * looping sound to compensate for lag, caused by changing audio + * tag playback position, in order to achieve gapless looping. + * + * You might need to tweak this value to get the desired results + * since loop lag varies depending on the browser/platform. + * + * @name Phaser.Sound.HTML5AudioSoundManager#loopEndOffset + * @type {number} + * @default 0.05 + * @since 3.0.0 + */ + this.loopEndOffset = 0.05; + + /** + * An array for keeping track of all the sounds + * that were paused when game lost focus. + * + * @name Phaser.Sound.HTML5AudioSoundManager#onBlurPausedSounds + * @type {Phaser.Sound.HTML5AudioSound[]} + * @private + * @default [] + * @since 3.0.0 + */ + this.onBlurPausedSounds = []; + + this.locked = 'ontouchstart' in window; + + /** + * A queue of all actions performed on sound objects while audio was locked. + * Once the audio gets unlocked, after an explicit user interaction, + * all actions will be performed in chronological order. + * Array of object types: { sound: Phaser.Sound.HTML5AudioSound, name: string, value?: * } + * + * @name Phaser.Sound.HTML5AudioSoundManager#lockedActionsQueue + * @type {array} + * @private + * @since 3.0.0 + */ + this.lockedActionsQueue = this.locked ? [] : null; + + /** + * Property that actually holds the value of global mute + * for HTML5 Audio sound manager implementation. + * + * @name Phaser.Sound.HTML5AudioSoundManager#_mute + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._mute = false; + + /** + * Property that actually holds the value of global volume + * for HTML5 Audio sound manager implementation. + * + * @name Phaser.Sound.HTML5AudioSoundManager#_volume + * @type {boolean} + * @private + * @default 1 + * @since 3.0.0 + */ + this._volume = 1; + + BaseSoundManager.call(this, game); + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.HTML5AudioSoundManager#add + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.HTML5AudioSound} The new sound instance. + */ + add: function (key, config) + { + var sound = new HTML5AudioSound(this, key, config); + + this.sounds.push(sound); + + return sound; + }, + + /** + * Unlocks HTML5 Audio loading and playback on mobile + * devices on the initial explicit user interaction. + * + * @method Phaser.Sound.HTML5AudioSoundManager#unlock + * @since 3.0.0 + */ + unlock: function () + { + this.locked = false; + + var _this = this; + + this.game.cache.audio.entries.each(function (key, tags) + { + for (var i = 0; i < tags.length; i++) + { + if (tags[i].dataset.locked === 'true') + { + _this.locked = true; + + return false; + } + } + + return true; + }); + + if (!this.locked) + { + return; + } + + var moved = false; + + var detectMove = function () + { + moved = true; + }; + + var unlock = function () + { + if (moved) + { + moved = false; + return; + } + + document.body.removeEventListener('touchmove', detectMove); + document.body.removeEventListener('touchend', unlock); + + var lockedTags = []; + + _this.game.cache.audio.entries.each(function (key, tags) + { + for (var i = 0; i < tags.length; i++) + { + var tag = tags[i]; + + if (tag.dataset.locked === 'true') + { + lockedTags.push(tag); + } + } + + return true; + }); + + 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; + }; + + lockedTags.forEach(function (tag) + { + tag.load(); + }); + }; + + this.once('unlocked', function () + { + this.forEachActiveSound(function (sound) + { + if (sound.currentMarker === null && sound.duration === 0) + { + sound.duration = sound.tags[0].duration; + } + + sound.totalDuration = sound.tags[0].duration; + }); + + while (this.lockedActionsQueue.length) + { + var lockedAction = this.lockedActionsQueue.shift(); + + if (lockedAction.sound[lockedAction.prop].apply) + { + lockedAction.sound[lockedAction.prop].apply(lockedAction.sound, lockedAction.value || []); + } + else + { + lockedAction.sound[lockedAction.prop] = lockedAction.value; + } + } + + }, this); + + document.body.addEventListener('touchmove', detectMove, false); + document.body.addEventListener('touchend', unlock, false); + }, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.HTML5AudioSoundManager#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.forEachActiveSound(function (sound) + { + if (sound.isPlaying) + { + this.onBlurPausedSounds.push(sound); + sound.onBlur(); + } + }); + }, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.HTML5AudioSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.HTML5AudioSoundManager#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.onBlurPausedSounds.forEach(function (sound) + { + sound.onFocus(); + }); + + this.onBlurPausedSounds.length = 0; + }, + + /** + * Calls Phaser.Sound.BaseSoundManager#destroy method + * and cleans up all HTML5 Audio related stuff. + * + * @method Phaser.Sound.HTML5AudioSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + BaseSoundManager.prototype.destroy.call(this); + + this.onBlurPausedSounds.length = 0; + this.onBlurPausedSounds = null; + }, + + /** + * Method used internally by Phaser.Sound.HTML5AudioSound class methods and property setters + * to check if sound manager is locked and then either perform action immediately or queue it + * to be performed once the sound manager gets unlocked. + * + * @method Phaser.Sound.HTML5AudioSoundManager#isLocked + * @protected + * @since 3.0.0 + * + * @param {Phaser.Sound.HTML5AudioSound} sound - Sound object on which to perform queued action. + * @param {string} prop - Name of the method to be called or property to be assigned a value to. + * @param {*} [value] - An optional parameter that either holds an array of arguments to be passed to the method call or value to be set to the property. + * + * @return {boolean} Whether the sound manager is locked. + */ + isLocked: function (sound, prop, value) + { + if (sound.tags[0].dataset.locked === 'true') + { + this.lockedActionsQueue.push({ + sound: sound, + prop: prop, + value: value + }); + + return true; + } + + return false; + }, + + /** + * @event Phaser.Sound.HTML5AudioSoundManager#muteEvent + * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#mute property. + */ + + /** + * Sets the muted state of all this Sound Manager. + * + * @method Phaser.Sound.HTML5AudioSoundManager#setMute + * @fires Phaser.Sound.HTML5AudioSoundManager#muteEvent + * @since 3.3.0 + * + * @param {boolean} value - `true` to mute all sounds, `false` to unmute them. + * + * @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager. + */ + setMute: function (value) + { + this.mute = value; + + return this; + }, + + /** + * @name Phaser.Sound.HTML5AudioSoundManager#mute + * @type {boolean} + * @fires Phaser.Sound.HTML5AudioSoundManager#muteEvent + * @since 3.0.0 + */ + mute: { + + get: function () + { + return this._mute; + }, + + set: function (value) + { + this._mute = value; + + this.forEachActiveSound(function (sound) + { + sound.updateMute(); + }); + + this.emit('mute', this, value); + } + + }, + + /** + * @event Phaser.Sound.HTML5AudioSoundManager#volumeEvent + * @param {Phaser.Sound.HTML5AudioSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#volume property. + */ + + /** + * Sets the volume of this Sound Manager. + * + * @method Phaser.Sound.HTML5AudioSoundManager#setVolume + * @fires Phaser.Sound.HTML5AudioSoundManager#volumeEvent + * @since 3.3.0 + * + * @param {number} value - The global volume of this Sound Manager. + * + * @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager. + */ + setVolume: function (value) + { + this.volume = value; + + return this; + }, + + /** + * @name Phaser.Sound.HTML5AudioSoundManager#volume + * @type {number} + * @fires Phaser.Sound.HTML5AudioSoundManager#volumeEvent + * @since 3.0.0 + */ + volume: { + + get: function () + { + return this._volume; + }, + + set: function (value) + { + this._volume = value; + + this.forEachActiveSound(function (sound) + { + sound.updateVolume(); + }); + + this.emit('volume', this, value); + } + + } + +}); + +module.exports = HTML5AudioSoundManager; + + +/***/ }), +/* 354 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HTML5AudioSoundManager = __webpack_require__(353); +var NoAudioSoundManager = __webpack_require__(351); +var WebAudioSoundManager = __webpack_require__(349); + +/** + * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. + * + * Be aware of https://developers.google.com/web/updates/2017/09/autoplay-policy-changes + * + * @function Phaser.Sound.SoundManagerCreator + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var SoundManagerCreator = { + + create: function (game) + { + var audioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + return new NoAudioSoundManager(game); + } + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + return new WebAudioSoundManager(game); + } + + return new HTML5AudioSoundManager(game); + } + +}; + +module.exports = SoundManagerCreator; + + +/***/ }), +/* 355 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(126); +var GetValue = __webpack_require__(4); +var Merge = __webpack_require__(79); +var InjectionMap = __webpack_require__(960); + +/** + * @namespace Phaser.Scenes.Settings + */ + +/** + * @typedef {object} Phaser.Scenes.Settings.Config + * + * @property {string} [key] - [description] + * @property {boolean} [active=false] - [description] + * @property {boolean} [visible=true] - [description] + * @property {(false|Phaser.Loader.FileTypes.PackFileConfig)} [pack=false] - [description] + * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} [cameras=null] - [description] + * @property {Object.} [map] - Overwrites the default injection map for a scene. + * @property {Object.} [mapAdd] - Extends the injection map for a scene. + * @property {object} [physics={}] - [description] + * @property {object} [loader={}] - [description] + * @property {(false|*)} [plugins=false] - [description] + */ + +/** + * @typedef {object} Phaser.Scenes.Settings.Object + * + * @property {number} status - [description] + * @property {string} key - [description] + * @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|Phaser.Loader.FileTypes.PackFileConfig)} pack - [description] + * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} cameras - [description] + * @property {Object.} map - [description] + * @property {object} physics - [description] + * @property {object} loader - [description] + * @property {(false|*)} plugins - [description] + */ + +var Settings = { + + /** + * Takes a Scene configuration object and returns a fully formed Systems object. + * + * @function Phaser.Scenes.Settings.create + * @since 3.0.0 + * + * @param {(string|Phaser.Scenes.Settings.Config)} config - [description] + * + * @return {Phaser.Scenes.Settings.Object} [description] + */ + create: function (config) + { + if (typeof config === 'string') + { + config = { key: config }; + } + else if (config === undefined) + { + // Pass the 'hasOwnProperty' checks + config = {}; + } + + return { + + status: CONST.PENDING, + + key: GetValue(config, 'key', ''), + active: GetValue(config, 'active', false), + visible: GetValue(config, 'visible', true), + + isBooted: false, + + isTransition: false, + transitionFrom: null, + transitionDuration: 0, + transitionAllowInput: true, + + // Loader payload array + + data: {}, + + pack: GetValue(config, 'pack', false), + + // Cameras + + cameras: GetValue(config, 'cameras', null), + + // Scene Property Injection Map + + map: GetValue(config, 'map', Merge(InjectionMap, GetValue(config, 'mapAdd', {}))), + + // Physics + + physics: GetValue(config, 'physics', {}), + + // Loader + + loader: GetValue(config, 'loader', {}), + + // Plugins + + plugins: GetValue(config, 'plugins', false), + + // Input + + input: GetValue(config, 'input', {}) + + }; + } + +}; + +module.exports = Settings; + + +/***/ }), +/* 356 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Capitalizes the first letter of a string if there is one. + * @example + * UppercaseFirst('abc'); + * // returns 'Abc' + * @example + * UppercaseFirst('the happy family'); + * // returns 'The happy family' + * @example + * UppercaseFirst(''); + * // returns '' + * + * @function Phaser.Utils.String.UppercaseFirst + * @since 3.0.0 + * + * @param {string} str - The string to capitalize. + * + * @return {string} A new string, same as the first, but with the first letter capitalized. + */ +var UppercaseFirst = function (str) +{ + return str && str[0].toUpperCase() + str.slice(1); +}; + +module.exports = UppercaseFirst; + + +/***/ }), +/* 357 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Systems = __webpack_require__(182); + +/** + * @classdesc + * [description] + * + * @class Scene + * @memberof Phaser + * @constructor + * @since 3.0.0 + * + * @param {(string|Phaser.Scenes.Settings.Config)} config - Scene specific configuration settings. + */ +var Scene = new Class({ + + initialize: + + function Scene (config) + { + /** + * The Scene Systems. You must never overwrite this property, or all hell will break lose. + * + * @name Phaser.Scene#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = new Systems(this, config); + + /** + * A reference to the Phaser.Game instance. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game; + + /** + * A reference to the global Animation Manager. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#anims + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.anims; + + /** + * A reference to the global Cache. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#cache + * @type {Phaser.Cache.CacheManager} + * @since 3.0.0 + */ + this.cache; + + /** + * A reference to the game level Data Manager. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#registry + * @type {Phaser.Data.DataManager} + * @since 3.0.0 + */ + this.registry; + + /** + * A reference to the Sound Manager. + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + * + * @name Phaser.Scene#sound + * @type {Phaser.Sound.BaseSoundManager} + * @since 3.0.0 + */ + this.sound; + + /** + * A reference to the Texture Manager. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#textures + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.textures; + + /** + * A scene level Event Emitter. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events; + + /** + * A scene level Camera System. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#cameras + * @type {Phaser.Cameras.Scene2D.CameraManager} + * @since 3.0.0 + */ + this.cameras; + + /** + * A scene level Game Object Factory. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#add + * @type {Phaser.GameObjects.GameObjectFactory} + * @since 3.0.0 + */ + this.add; + + /** + * A scene level Game Object Creator. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#make + * @type {Phaser.GameObjects.GameObjectCreator} + * @since 3.0.0 + */ + this.make; + + /** + * A reference to the Scene Manager Plugin. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#scene + * @type {Phaser.Scenes.ScenePlugin} + * @since 3.0.0 + */ + this.scene; + + /** + * A scene level Game Object Display List. + * This property will only be available if defined in the Scene Injection Map. + * + * @name Phaser.Scene#children + * @type {Phaser.GameObjects.DisplayList} + * @since 3.0.0 + */ + this.children; + + /** + * A scene level Lights Manager Plugin. + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + * + * @name Phaser.Scene#lights + * @type {Phaser.GameObjects.LightsManager} + * @since 3.0.0 + */ + this.lights; + + /** + * A scene level Data Manager Plugin. + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + * + * @name Phaser.Scene#data + * @type {Phaser.Data.DataManager} + * @since 3.0.0 + */ + this.data; + + /** + * A scene level Input Manager Plugin. + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + * + * @name Phaser.Scene#input + * @type {Phaser.Input.InputPlugin} + * @since 3.0.0 + */ + this.input; + + /** + * A scene level Loader Plugin. + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + * + * @name Phaser.Scene#load + * @type {Phaser.Loader.LoaderPlugin} + * @since 3.0.0 + */ + this.load; + + /** + * A scene level Time and Clock Plugin. + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + * + * @name Phaser.Scene#time + * @type {Phaser.Time.Clock} + * @since 3.0.0 + */ + this.time; + + /** + * A scene level Tween Manager Plugin. + * This property will only be available if defined in the Scene Injection Map and the plugin is installed. + * + * @name Phaser.Scene#tweens + * @type {Phaser.Tweens.TweenManager} + * @since 3.0.0 + */ + this.tweens; + + /** + * A scene level Arcade Physics Plugin. + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + * + * @name Phaser.Scene#physics + * @type {Phaser.Physics.Arcade.ArcadePhysics} + * @since 3.0.0 + */ + this.physics; + + /** + * A scene level Impact Physics Plugin. + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + * + * @name Phaser.Scene#impact + * @type {Phaser.Physics.Impact.ImpactPhysics} + * @since 3.0.0 + */ + this.impact; + + /** + * A scene level Matter Physics Plugin. + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + * + * @name Phaser.Scene#matter + * @type {Phaser.Physics.Matter.MatterPhysics} + * @since 3.0.0 + */ + this.matter; + }, + + /** + * Should be overridden by your own Scenes. + * + * @method Phaser.Scene#update + * @override + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update: function () + { + } + +}); + +module.exports = Scene; + + +/***/ }), +/* 358 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(126); +var GetValue = __webpack_require__(4); +var NOOP = __webpack_require__(2); +var Scene = __webpack_require__(357); +var Systems = __webpack_require__(182); + +/** + * @classdesc + * The Scene Manager. + * + * The Scene Manager is a Game level system, responsible for creating, processing and updating all of the + * Scenes in a Game instance. + * + * + * @class SceneManager + * @memberof Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance this Scene Manager belongs to. + * @param {object} sceneConfig - Scene specific configuration settings. + */ +var SceneManager = new Class({ + + initialize: + + function SceneManager (game, sceneConfig) + { + /** + * The Game that this SceneManager belongs to. + * + * @name Phaser.Scenes.SceneManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * An object that maps the keys to the scene so we can quickly get a scene from a key without iteration. + * + * @name Phaser.Scenes.SceneManager#keys + * @type {object} + * @since 3.0.0 + */ + this.keys = {}; + + /** + * The array in which all of the scenes are kept. + * + * @name Phaser.Scenes.SceneManager#scenes + * @type {array} + * @since 3.0.0 + */ + this.scenes = []; + + /** + * Scenes pending to be added are stored in here until the manager has time to add it. + * + * @name Phaser.Scenes.SceneManager#_pending + * @type {array} + * @private + * @since 3.0.0 + */ + this._pending = []; + + /** + * An array of scenes waiting to be started once the game has booted. + * + * @name Phaser.Scenes.SceneManager#_start + * @type {array} + * @private + * @since 3.0.0 + */ + this._start = []; + + /** + * An operations queue, because we don't manipulate the scenes array during processing. + * + * @name Phaser.Scenes.SceneManager#_queue + * @type {array} + * @private + * @since 3.0.0 + */ + this._queue = []; + + /** + * Boot time data to merge. + * + * @name Phaser.Scenes.SceneManager#_data + * @type {object} + * @private + * @since 3.4.0 + */ + this._data = {}; + + /** + * Is the Scene Manager actively processing the Scenes list? + * + * @name Phaser.Scenes.SceneManager#isProcessing + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isProcessing = false; + + /** + * Has the Scene Manager properly started? + * + * @name Phaser.Scenes.SceneManager#isBooted + * @type {boolean} + * @default false + * @readonly + * @since 3.4.0 + */ + this.isBooted = false; + + /** + * Do any of the Cameras in any of the Scenes require a custom viewport? + * If not we can skip scissor tests. + * + * @name Phaser.Scenes.SceneManager#customViewports + * @type {number} + * @default 0 + * @since 3.12.0 + */ + this.customViewports = 0; + + if (sceneConfig) + { + if (!Array.isArray(sceneConfig)) + { + sceneConfig = [ sceneConfig ]; + } + + for (var i = 0; i < sceneConfig.length; i++) + { + // The i === 0 part just autostarts the first Scene given (unless it says otherwise in its config) + this._pending.push({ + key: 'default', + scene: sceneConfig[i], + autoStart: (i === 0), + data: {} + }); + } + } + + game.events.once('ready', this.bootQueue, this); + }, + + /** + * Internal first-time Scene boot handler. + * + * @method Phaser.Scenes.SceneManager#bootQueue + * @private + * @since 3.2.0 + */ + bootQueue: function () + { + if (this.isBooted) + { + return; + } + + var i; + var entry; + var key; + var sceneConfig; + + for (i = 0; i < this._pending.length; i++) + { + entry = this._pending[i]; + + key = entry.key; + sceneConfig = entry.scene; + + var newScene; + + if (sceneConfig instanceof Scene) + { + newScene = this.createSceneFromInstance(key, sceneConfig); + } + else if (typeof sceneConfig === 'object') + { + newScene = this.createSceneFromObject(key, sceneConfig); + } + else if (typeof sceneConfig === 'function') + { + newScene = this.createSceneFromFunction(key, sceneConfig); + } + + // Replace key in case the scene changed it + key = newScene.sys.settings.key; + + this.keys[key] = newScene; + + this.scenes.push(newScene); + + // Any data to inject? + if (this._data[key]) + { + newScene.sys.settings.data = this._data[key].data; + + if (this._data[key].autoStart) + { + entry.autoStart = true; + } + } + + if (entry.autoStart || newScene.sys.settings.active) + { + this._start.push(key); + } + } + + // Clear the pending lists + this._pending.length = 0; + + this._data = {}; + + this.isBooted = true; + + // _start might have been populated by the above + for (i = 0; i < this._start.length; i++) + { + entry = this._start[i]; + + this.start(entry); + } + + this._start.length = 0; + }, + + /** + * Process the Scene operations queue. + * + * @method Phaser.Scenes.SceneManager#processQueue + * @since 3.0.0 + */ + processQueue: function () + { + var pendingLength = this._pending.length; + var queueLength = this._queue.length; + + if (pendingLength === 0 && queueLength === 0) + { + return; + } + + var i; + var entry; + + if (pendingLength) + { + for (i = 0; i < pendingLength; i++) + { + entry = this._pending[i]; + + this.add(entry.key, entry.scene, entry.autoStart, entry.data); + } + + // _start might have been populated by this.add + for (i = 0; i < this._start.length; i++) + { + entry = this._start[i]; + + this.start(entry); + } + + // Clear the pending lists + this._start.length = 0; + this._pending.length = 0; + + return; + } + + for (i = 0; i < this._queue.length; i++) + { + entry = this._queue[i]; + + this[entry.op](entry.keyA, entry.keyB); + } + + this._queue.length = 0; + }, + + /** + * Adds a new Scene into the SceneManager. + * You must give each Scene a unique key by which you'll identify it. + * + * The `sceneConfig` can be: + * + * * A `Phaser.Scene` object, or an object that extends it. + * * A plain JavaScript object + * * A JavaScript ES6 Class that extends `Phaser.Scene` + * * A JavaScript ES5 prototype based Class + * * A JavaScript function + * + * If a function is given then a new Scene will be created by calling it. + * + * @method Phaser.Scenes.SceneManager#add + * @since 3.0.0 + * + * @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. + * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The config for the Scene + * @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added. + * @param {object} [data] - Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`. + * + * @return {?Phaser.Scene} The added Scene, if it was added immediately, otherwise `null`. + */ + add: function (key, sceneConfig, autoStart, data) + { + if (autoStart === undefined) { autoStart = false; } + if (data === undefined) { data = {}; } + + // If processing or not booted then put scene into a holding pattern + if (this.isProcessing || !this.isBooted) + { + this._pending.push({ + key: key, + scene: sceneConfig, + autoStart: autoStart, + data: data + }); + + if (!this.isBooted) + { + this._data[key] = { data: data }; + } + + return null; + } + + key = this.getKey(key, sceneConfig); + + var newScene; + + if (sceneConfig instanceof Scene) + { + newScene = this.createSceneFromInstance(key, sceneConfig); + } + else if (typeof sceneConfig === 'object') + { + sceneConfig.key = key; + + newScene = this.createSceneFromObject(key, sceneConfig); + } + else if (typeof sceneConfig === 'function') + { + newScene = this.createSceneFromFunction(key, sceneConfig); + } + + // Any data to inject? + newScene.sys.settings.data = data; + + // Replace key in case the scene changed it + key = newScene.sys.settings.key; + + this.keys[key] = newScene; + + this.scenes.push(newScene); + + if (autoStart || newScene.sys.settings.active) + { + if (this._pending.length) + { + this._start.push(key); + } + else + { + this.start(key); + } + } + + return newScene; + }, + + /** + * Removes a Scene from the SceneManager. + * + * The Scene is removed from the local scenes array, it's key is cleared from the keys + * cache and Scene.Systems.destroy is then called on it. + * + * If the SceneManager is processing the Scenes when this method is called it will + * queue the operation for the next update sequence. + * + * @method Phaser.Scenes.SceneManager#remove + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} scene - The Scene to be removed. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + remove: function (key) + { + if (this.isProcessing) + { + this._queue.push({ op: 'remove', keyA: key, keyB: null }); + } + else + { + var sceneToRemove = this.getScene(key); + + if (!sceneToRemove || sceneToRemove.sys.isTransitioning()) + { + return this; + } + + var index = this.scenes.indexOf(sceneToRemove); + var sceneKey = sceneToRemove.sys.settings.key; + + if (index > -1) + { + delete this.keys[sceneKey]; + this.scenes.splice(index, 1); + + if (this._start.indexOf(sceneKey) > -1) + { + index = this._start.indexOf(sceneKey); + this._start.splice(index, 1); + } + + sceneToRemove.sys.destroy(); + } + } + + return this; + }, + + /** + * Boot the given Scene. + * + * @method Phaser.Scenes.SceneManager#bootScene + * @private + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to boot. + */ + bootScene: function (scene) + { + var sys = scene.sys; + var settings = sys.settings; + + if (scene.init) + { + scene.init.call(scene, settings.data); + + settings.status = CONST.INIT; + + if (settings.isTransition) + { + sys.events.emit('transitioninit', settings.transitionFrom, settings.transitionDuration); + } + } + + var loader; + + if (sys.load) + { + loader = sys.load; + + loader.reset(); + } + + if (loader && scene.preload) + { + scene.preload.call(scene); + + // Is the loader empty? + if (loader.list.size === 0) + { + this.create(scene); + } + else + { + settings.status = CONST.LOADING; + + // Start the loader going as we have something in the queue + loader.once('complete', this.loadComplete, this); + + loader.start(); + } + } + else + { + // No preload? Then there was nothing to load either + this.create(scene); + } + }, + + /** + * Handles load completion for a Scene's Loader. + * + * Starts the Scene that the Loader belongs to. + * + * @method Phaser.Scenes.SceneManager#loadComplete + * @private + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The loader that has completed loading. + */ + loadComplete: function (loader) + { + 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); + }, + + /** + * Handle payload completion for a Scene. + * + * @method Phaser.Scenes.SceneManager#payloadComplete + * @private + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The loader that has completed loading its Scene's payload. + */ + payloadComplete: function (loader) + { + this.bootScene(loader.scene); + }, + + /** + * Updates the Scenes. + * + * @method Phaser.Scenes.SceneManager#update + * @since 3.0.0 + * + * @param {number} time - Time elapsed. + * @param {number} delta - Delta time from the last update. + */ + update: function (time, delta) + { + this.processQueue(); + + this.isProcessing = true; + + // Loop through the active scenes in reverse order + for (var i = this.scenes.length - 1; i >= 0; i--) + { + var sys = this.scenes[i].sys; + + if (sys.settings.status > CONST.START && sys.settings.status <= CONST.RUNNING) + { + sys.step(time, delta); + } + } + }, + + /** + * Informs the Scenes of the Game being resized. + * + * @method Phaser.Scenes.SceneManager#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (width, height) + { + // Loop through the scenes in forward order + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + sys.resize(width, height); + } + }, + + /** + * Renders the Scenes. + * + * @method Phaser.Scenes.SceneManager#render + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The renderer to use. + */ + render: function (renderer) + { + // Loop through the scenes in forward order + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + if (sys.settings.visible && sys.settings.status >= CONST.LOADING && sys.settings.status < CONST.SLEEPING) + { + sys.render(renderer); + } + } + + this.isProcessing = false; + }, + + /** + * Calls the given Scene's {@link Phaser.Scene#create} method and updates its status. + * + * @method Phaser.Scenes.SceneManager#create + * @private + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to create. + */ + create: function (scene) + { + var sys = scene.sys; + var settings = sys.settings; + + if (scene.create) + { + settings.status = CONST.CREATING; + + scene.create.call(scene, settings.data); + + if (settings.isTransition) + { + sys.events.emit('transitionstart', settings.transitionFrom, settings.transitionDuration); + } + } + + // If the Scene has an update function we'll set it now, otherwise it'll remain as NOOP + if (scene.update) + { + sys.sceneUpdate = scene.update; + } + + settings.status = CONST.RUNNING; + }, + + /** + * Creates and initializes a Scene from a function. + * + * @method Phaser.Scenes.SceneManager#createSceneFromFunction + * @private + * @since 3.0.0 + * + * @param {string} key - The key of the Scene. + * @param {function} scene - The function to create the Scene from. + * + * @return {Phaser.Scene} The created Scene. + */ + createSceneFromFunction: function (key, scene) + { + var newScene = new scene(); + + if (newScene instanceof Scene) + { + var configKey = newScene.sys.settings.key; + + if (configKey !== '') + { + key = configKey; + } + + if (this.keys.hasOwnProperty(key)) + { + throw new Error('Cannot add a Scene with duplicate key: ' + key); + } + + return this.createSceneFromInstance(key, newScene); + } + else + { + newScene.sys = new Systems(newScene); + + newScene.sys.settings.key = key; + + newScene.sys.init(this.game); + + return newScene; + } + }, + + /** + * Creates and initializes a Scene instance. + * + * @method Phaser.Scenes.SceneManager#createSceneFromInstance + * @private + * @since 3.0.0 + * + * @param {string} key - The key of the Scene. + * @param {Phaser.Scene} newScene - The Scene instance. + * + * @return {Phaser.Scene} The created Scene. + */ + createSceneFromInstance: function (key, newScene) + { + var configKey = newScene.sys.settings.key; + + if (configKey !== '') + { + key = configKey; + } + else + { + newScene.sys.settings.key = key; + } + + newScene.sys.init(this.game); + + return newScene; + }, + + /** + * Creates and initializes a Scene from an Object definition. + * + * @method Phaser.Scenes.SceneManager#createSceneFromObject + * @private + * @since 3.0.0 + * + * @param {string} key - The key of the Scene. + * @param {(string|Phaser.Scenes.Settings.Config)} sceneConfig - The Scene config. + * + * @return {Phaser.Scene} The created Scene. + */ + createSceneFromObject: function (key, sceneConfig) + { + var newScene = new Scene(sceneConfig); + + var configKey = newScene.sys.settings.key; + + if (configKey !== '') + { + key = configKey; + } + else + { + newScene.sys.settings.key = key; + } + + newScene.sys.init(this.game); + + // Extract callbacks + + var defaults = [ 'init', 'preload', 'create', 'update', 'render' ]; + + for (var i = 0; i < defaults.length; i++) + { + var sceneCallback = GetValue(sceneConfig, defaults[i], null); + + if (sceneCallback) + { + newScene[defaults[i]] = sceneCallback; + } + } + + // Now let's move across any other functions or properties that may exist in the extend object: + + /* + scene: { + preload: preload, + create: create, + extend: { + hello: 1, + test: 'atari', + addImage: addImage + } + } + */ + + if (sceneConfig.hasOwnProperty('extend')) + { + for (var propertyKey in sceneConfig.extend) + { + var value = sceneConfig.extend[propertyKey]; + + if (propertyKey === 'data' && newScene.hasOwnProperty('data') && typeof value === 'object') + { + // Populate the DataManager + newScene.data.merge(value); + } + else if (propertyKey !== 'sys') + { + newScene[propertyKey] = value; + } + } + } + + return newScene; + }, + + /** + * Retrieves the key of a Scene from a Scene config. + * + * @method Phaser.Scenes.SceneManager#getKey + * @private + * @since 3.0.0 + * + * @param {string} key - The key to check in the Scene config. + * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The Scene config. + * + * @return {string} The Scene key. + */ + getKey: function (key, sceneConfig) + { + if (!key) { key = 'default'; } + + if (typeof sceneConfig === 'function') + { + return key; + } + else if (sceneConfig instanceof Scene) + { + key = sceneConfig.sys.settings.key; + } + else if (typeof sceneConfig === 'object' && sceneConfig.hasOwnProperty('key')) + { + key = sceneConfig.key; + } + + // By this point it's either 'default' or extracted from the Scene + + if (this.keys.hasOwnProperty(key)) + { + throw new Error('Cannot add a Scene with duplicate key: ' + key); + } + else + { + return key; + } + }, + + /** + * Retrieves a Scene. + * + * @method Phaser.Scenes.SceneManager#getScene + * @since 3.0.0 + * + * @param {string|Phaser.Scene} key - The Scene to retrieve. + * + * @return {?Phaser.Scene} The Scene. + */ + getScene: function (key) + { + if (typeof key === 'string') + { + if (this.keys[key]) + { + return this.keys[key]; + } + } + else + { + for (var i = 0; i < this.scenes.length; i++) + { + if (key === this.scenes[i]) + { + return key; + } + } + } + + return null; + }, + + /** + * Determines whether a Scene is active. + * + * @method Phaser.Scenes.SceneManager#isActive + * @since 3.0.0 + * + * @param {string} key - The Scene to check. + * + * @return {boolean} Whether the Scene is active. + */ + isActive: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + return scene.sys.isActive(); + } + + return null; + }, + + /** + * Determines whether a Scene is visible. + * + * @method Phaser.Scenes.SceneManager#isVisible + * @since 3.0.0 + * + * @param {string} key - The Scene to check. + * + * @return {boolean} Whether the Scene is visible. + */ + isVisible: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + return scene.sys.isVisible(); + } + + return null; + }, + + /** + * Determines whether a Scene is sleeping. + * + * @method Phaser.Scenes.SceneManager#isSleeping + * @since 3.0.0 + * + * @param {string} key - The Scene to check. + * + * @return {boolean} Whether the Scene is sleeping. + */ + isSleeping: function (key) + { + var scene = this.getScene(key); + + if (scene) + { + return scene.sys.isSleeping(); + } + + return null; + }, + + /** + * Pauses the given Scene. + * + * @method Phaser.Scenes.SceneManager#pause + * @since 3.0.0 + * + * @param {string} key - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its pause event. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + pause: function (key, data) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.pause(data); + } + + return this; + }, + + /** + * Resumes the given Scene. + * + * @method Phaser.Scenes.SceneManager#resume + * @since 3.0.0 + * + * @param {string} key - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its resume event. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + resume: function (key, data) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.resume(data); + } + + return this; + }, + + /** + * Puts the given Scene to sleep. + * + * @method Phaser.Scenes.SceneManager#sleep + * @since 3.0.0 + * + * @param {string} key - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its sleep event. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + sleep: function (key, data) + { + var scene = this.getScene(key); + + if (scene && !scene.sys.isTransitioning()) + { + scene.sys.sleep(data); + } + + return this; + }, + + /** + * Awakens the given Scene. + * + * @method Phaser.Scenes.SceneManager#wake + * @since 3.0.0 + * + * @param {string} key - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its wake event. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + wake: function (key, data) + { + var scene = this.getScene(key); + + if (scene) + { + scene.sys.wake(data); + } + + return this; + }, + + /** + * Runs the given Scene, but does not change the state of this Scene. + * + * If the given Scene is paused, it will resume it. If sleeping, it will wake it. + * If not running at all, it will be started. + * + * Use this if you wish to open a modal Scene by calling `pause` on the current + * Scene, then `run` on the modal Scene. + * + * @method Phaser.Scenes.SceneManager#run + * @since 3.10.0 + * + * @param {string} key - The Scene to run. + * @param {object} [data] - A data object that will be passed to the Scene on start, wake, or resume. + * + * @return {Phaser.Scenes.SceneManager} This Scene Manager. + */ + run: function (key, data) + { + var scene = this.getScene(key); + + if (!scene) + { + for (var i = 0; i < this._pending.length; i++) + { + if (this._pending[i].key === key) + { + this.queueOp('start', key, data); + break; + } + } + return this; + } + + if (scene.sys.isSleeping()) + { + // Sleeping? + scene.sys.wake(data); + } + else if (scene.sys.isBooted && !scene.sys.isActive()) + { + // Paused? + scene.sys.resume(data); + } + else + { + // Not actually running? + this.start(key, data); + } + }, + + /** + * Starts the given Scene. + * + * @method Phaser.Scenes.SceneManager#start + * @since 3.0.0 + * + * @param {string} key - The Scene to start. + * @param {object} [data] - Optional data object to pass to Scene.Settings and Scene.init. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + start: function (key, data) + { + // If the Scene Manager is not running, then put the Scene into a holding pattern + if (!this.isBooted) + { + this._data[key] = { + autoStart: true, + data: data + }; + + return this; + } + + var scene = this.getScene(key); + + if (scene) + { + // If the Scene is already running (perhaps they called start from a launched sub-Scene?) + // then we close it down before starting it again. + if (scene.sys.isActive() || scene.sys.isPaused()) + { + scene.sys.shutdown(); + + scene.sys.start(data); + } + else + { + scene.sys.start(data); + + var loader; + + if (scene.sys.load) + { + loader = scene.sys.load; + } + + // Files payload? + if (loader && scene.sys.settings.hasOwnProperty('pack')) + { + loader.reset(); + + if (loader.addPack({ payload: scene.sys.settings.pack })) + { + scene.sys.settings.status = CONST.LOADING; + + loader.once('complete', this.payloadComplete, this); + + loader.start(); + + return this; + } + } + } + + this.bootScene(scene); + } + + return this; + }, + + /** + * Stops the given Scene. + * + * @method Phaser.Scenes.SceneManager#stop + * @since 3.0.0 + * + * @param {string} key - The Scene to stop. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + stop: function (key) + { + var scene = this.getScene(key); + + if (scene && !scene.sys.isTransitioning()) + { + scene.sys.shutdown(); + } + + return this; + }, + + /** + * Sleeps one one Scene and starts the other. + * + * @method Phaser.Scenes.SceneManager#switch + * @since 3.0.0 + * + * @param {string} from - The Scene to sleep. + * @param {string} to - The Scene to start. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + switch: function (from, to) + { + var sceneA = this.getScene(from); + var sceneB = this.getScene(to); + + if (sceneA && sceneB && sceneA !== sceneB) + { + this.sleep(from); + + if (this.isSleeping(to)) + { + this.wake(to); + } + else + { + this.start(to); + } + } + + return this; + }, + + /** + * Retrieves a Scene by numeric index. + * + * @method Phaser.Scenes.SceneManager#getAt + * @since 3.0.0 + * + * @param {integer} index - The index of the Scene to retrieve. + * + * @return {(Phaser.Scene|undefined)} The Scene. + */ + getAt: function (index) + { + return this.scenes[index]; + }, + + /** + * Retrieves the numeric index of a Scene. + * + * @method Phaser.Scenes.SceneManager#getIndex + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - The key of the Scene. + * + * @return {integer} The index of the Scene. + */ + getIndex: function (key) + { + var scene = this.getScene(key); + + return this.scenes.indexOf(scene); + }, + + /** + * Brings a Scene to the top of the Scenes list. + * + * This means it will render above all other Scenes. + * + * @method Phaser.Scenes.SceneManager#bringToTop + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - The Scene to move. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + bringToTop: function (key) + { + if (this.isProcessing) + { + this._queue.push({ op: 'bringToTop', keyA: key, keyB: null }); + } + else + { + var index = this.getIndex(key); + + if (index !== -1 && index < this.scenes.length) + { + var scene = this.getScene(key); + + this.scenes.splice(index, 1); + this.scenes.push(scene); + } + } + + return this; + }, + + /** + * Sends a Scene to the back of the Scenes list. + * + * This means it will render below all other Scenes. + * + * @method Phaser.Scenes.SceneManager#sendToBack + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - The Scene to move. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + sendToBack: function (key) + { + if (this.isProcessing) + { + this._queue.push({ op: 'sendToBack', keyA: key, keyB: null }); + } + else + { + var index = this.getIndex(key); + + if (index !== -1 && index > 0) + { + var scene = this.getScene(key); + + this.scenes.splice(index, 1); + this.scenes.unshift(scene); + } + } + + return this; + }, + + /** + * Moves a Scene down one position in the Scenes list. + * + * @method Phaser.Scenes.SceneManager#moveDown + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - The Scene to move. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + moveDown: function (key) + { + if (this.isProcessing) + { + this._queue.push({ op: 'moveDown', keyA: key, keyB: null }); + } + else + { + var indexA = this.getIndex(key); + + if (indexA > 0) + { + var indexB = indexA - 1; + var sceneA = this.getScene(key); + var sceneB = this.getAt(indexB); + + this.scenes[indexA] = sceneB; + this.scenes[indexB] = sceneA; + } + } + + return this; + }, + + /** + * Moves a Scene up one position in the Scenes list. + * + * @method Phaser.Scenes.SceneManager#moveUp + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} key - The Scene to move. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + moveUp: function (key) + { + if (this.isProcessing) + { + this._queue.push({ op: 'moveUp', keyA: key, keyB: null }); + } + else + { + var indexA = this.getIndex(key); + + if (indexA < this.scenes.length - 1) + { + var indexB = indexA + 1; + var sceneA = this.getScene(key); + var sceneB = this.getAt(indexB); + + this.scenes[indexA] = sceneB; + this.scenes[indexB] = sceneA; + } + } + + return this; + }, + + /** + * Moves a Scene so it is immediately above another Scene in the Scenes list. + * + * This means it will render over the top of the other Scene. + * + * @method Phaser.Scenes.SceneManager#moveAbove + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above. + * @param {(string|Phaser.Scene)} keyB - The Scene to be moved. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + moveAbove: function (keyA, keyB) + { + if (keyA === keyB) + { + return this; + } + + if (this.isProcessing) + { + this._queue.push({ op: 'moveAbove', keyA: keyA, keyB: keyB }); + } + else + { + var indexA = this.getIndex(keyA); + var indexB = this.getIndex(keyB); + + if (indexA !== -1 && indexB !== -1) + { + var tempScene = this.getAt(indexB); + + // Remove + this.scenes.splice(indexB, 1); + + // Add in new location + this.scenes.splice(indexA + 1, 0, tempScene); + } + } + + return this; + }, + + /** + * Moves a Scene so it is immediately below another Scene in the Scenes list. + * + * This means it will render behind the other Scene. + * + * @method Phaser.Scenes.SceneManager#moveBelow + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} keyA - The Scene that Scene B will be moved above. + * @param {(string|Phaser.Scene)} keyB - The Scene to be moved. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + moveBelow: function (keyA, keyB) + { + if (keyA === keyB) + { + return this; + } + + if (this.isProcessing) + { + this._queue.push({ op: 'moveBelow', keyA: keyA, keyB: keyB }); + } + else + { + var indexA = this.getIndex(keyA); + var indexB = this.getIndex(keyB); + + if (indexA !== -1 && indexB !== -1) + { + var tempScene = this.getAt(indexB); + + // Remove + this.scenes.splice(indexB, 1); + + if (indexA === 0) + { + this.scenes.unshift(tempScene); + } + else + { + // Add in new location + this.scenes.splice(indexA, 0, tempScene); + } + } + } + + return this; + }, + + /** + * Queue a Scene operation for the next update. + * + * @method Phaser.Scenes.SceneManager#queueOp + * @private + * @since 3.0.0 + * + * @param {string} op - The operation to perform. + * @param {(string|Phaser.Scene)} keyA - Scene A. + * @param {(string|Phaser.Scene)} [keyB] - Scene B. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + queueOp: function (op, keyA, keyB) + { + this._queue.push({ op: op, keyA: keyA, keyB: keyB }); + + return this; + }, + + /** + * Swaps the positions of two Scenes in the Scenes list. + * + * @method Phaser.Scenes.SceneManager#swapPosition + * @since 3.0.0 + * + * @param {(string|Phaser.Scene)} keyA - The first Scene to swap. + * @param {(string|Phaser.Scene)} keyB - The second Scene to swap. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + swapPosition: function (keyA, keyB) + { + if (keyA === keyB) + { + return this; + } + + if (this.isProcessing) + { + this._queue.push({ op: 'swapPosition', keyA: keyA, keyB: keyB }); + } + else + { + var indexA = this.getIndex(keyA); + var indexB = this.getIndex(keyB); + + if (indexA !== indexB && indexA !== -1 && indexB !== -1) + { + var tempScene = this.getAt(indexA); + + this.scenes[indexA] = this.scenes[indexB]; + this.scenes[indexB] = tempScene; + } + } + + return this; + }, + + /** + * Dumps debug information about each Scene to the developer console. + * + * @method Phaser.Scenes.SceneManager#dump + * @since 3.2.0 + */ + dump: function () + { + var out = []; + var map = [ 'pending', 'init', 'start', 'loading', 'creating', 'running', 'paused', 'sleeping', 'shutdown', 'destroyed' ]; + + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + var key = (sys.settings.visible && (sys.settings.status === CONST.RUNNING || sys.settings.status === CONST.PAUSED)) ? '[*] ' : '[-] '; + key += sys.settings.key + ' (' + map[sys.settings.status] + ')'; + + out.push(key); + } + + console.log(out.join('\n')); + }, + + /** + * Destroy the SceneManager and all of its Scene's systems. + * + * @method Phaser.Scenes.SceneManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + for (var i = 0; i < this.scenes.length; i++) + { + var sys = this.scenes[i].sys; + + sys.destroy(); + } + + this.update = NOOP; + + this.scenes = []; + + this._pending = []; + this._start = []; + this._queue = []; + + this.game = null; + } + +}); + +module.exports = SceneManager; + + +/***/ }), +/* 359 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SpliceOne = __webpack_require__(100); + +/** + * Removes the given item, or array of items, from the array. + * + * The array is modified in-place. + * + * You can optionally specify a callback to be invoked for each item successfully removed from the array. + * + * @function Phaser.Utils.Array.Remove + * @since 3.4.0 + * + * @param {array} array - The array to be modified. + * @param {*|Array.<*>} item - The item, or array of items, to be removed from the array. + * @param {function} [callback] - A callback to be invoked for each item successfully removed from the array. + * @param {object} [context] - The context in which the callback is invoked. + * + * @return {*|Array.<*>} The item, or array of items, that were successfully removed from the array. + */ +var Remove = function (array, item, callback, context) +{ + if (context === undefined) { context = array; } + + var index; + + // Fast path to avoid array mutation and iteration + if (!Array.isArray(item)) + { + index = array.indexOf(item); + + if (index !== -1) + { + SpliceOne(array, index); + + if (callback) + { + callback.call(context, item); + } + + return item; + } + else + { + return null; + } + } + + // If we got this far, we have an array of items to remove + + var itemLength = item.length - 1; + + while (itemLength >= 0) + { + var entry = item[itemLength]; + + index = array.indexOf(entry); + + if (index !== -1) + { + SpliceOne(array, index); + + if (callback) + { + callback.call(context, entry); + } + } + else + { + // Item wasn't found in the array, so remove it from our return results + item.pop(); + } + + itemLength--; + } + + return item; +}; + +module.exports = Remove; + + +/***/ }), +/* 360 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var FileTypesManager = __webpack_require__(7); +var GameObjectCreator = __webpack_require__(14); +var GameObjectFactory = __webpack_require__(5); +var GetFastValue = __webpack_require__(1); +var PluginCache = __webpack_require__(15); +var Remove = __webpack_require__(359); + +/** + * @typedef {object} GlobalPlugin + * + * @property {string} key - The unique name of this plugin within the plugin cache. + * @property {function} plugin - An instance of the plugin. + * @property {boolean} [active] - Is the plugin active or not? + * @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used. + */ + +/** + * @classdesc + * The PluginManager is responsible for installing and adding plugins to Phaser. + * + * It is a global system and therefore belongs to the Game instance, not a specific Scene. + * + * It works in conjunction with the PluginCache. Core internal plugins automatically register themselves + * with the Cache, but it's the Plugin Manager that is responsible for injecting them into the Scenes. + * + * There are two types of plugin: + * + * 1) A Global Plugin + * 2) A Scene Plugin + * + * A Global Plugin is a plugin that lives within the Plugin Manager rather than a Scene. You can get + * access to it by calling `PluginManager.get` and providing a key. Any Scene that requests a plugin in + * this way will all get access to the same plugin instance, allowing you to use a single plugin across + * multiple Scenes. + * + * A Scene Plugin is a plugin dedicated to running within a Scene. These are different to Global Plugins + * in that their instances do not live within the Plugin Manager, but within the Scene Systems class instead. + * And that every Scene created is given its own unique instance of a Scene Plugin. Examples of core Scene + * Plugins include the Input Plugin, the Tween Plugin and the physics Plugins. + * + * You can add a plugin to Phaser in three different ways: + * + * 1) Preload it + * 2) Include it in your source code and install it via the Game Config + * 3) Include it in your source code and install it within a Scene + * + * For examples of all of these approaches please see the Phaser 3 Examples Repo `plugins` folder. + * + * For information on creating your own plugin please see the Phaser 3 Plugin Template. + * + * @class PluginManager + * @memberof Phaser.Plugins + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The game instance that owns this Plugin Manager. + */ +var PluginManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function PluginManager (game) + { + EventEmitter.call(this); + + /** + * The game instance that owns this Plugin Manager. + * + * @name Phaser.Plugins.PluginManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * The global plugins currently running and managed by this Plugin Manager. + * A plugin must have been started at least once in order to appear in this list. + * + * @name Phaser.Plugins.PluginManager#plugins + * @type {GlobalPlugin[]} + * @since 3.8.0 + */ + this.plugins = []; + + /** + * A list of plugin keys that should be installed into Scenes as well as the Core Plugins. + * + * @name Phaser.Plugins.PluginManager#scenePlugins + * @type {string[]} + * @since 3.8.0 + */ + this.scenePlugins = []; + + /** + * A temporary list of plugins to install when the game has booted. + * + * @name Phaser.Plugins.PluginManager#_pendingGlobal + * @private + * @type {array} + * @since 3.8.0 + */ + this._pendingGlobal = []; + + /** + * A temporary list of scene plugins to install when the game has booted. + * + * @name Phaser.Plugins.PluginManager#_pendingScene + * @private + * @type {array} + * @since 3.8.0 + */ + this._pendingScene = []; + + if (game.isBooted) + { + this.boot(); + } + else + { + game.events.once('boot', this.boot, this); + } + }, + + /** + * Run once the game has booted and installs all of the plugins configured in the Game Config. + * + * @method Phaser.Plugins.PluginManager#boot + * @protected + * @since 3.0.0 + */ + boot: function () + { + var i; + var entry; + var key; + var plugin; + var start; + var mapping; + var data; + var config = this.game.config; + + // Any plugins to install? + var list = config.installGlobalPlugins; + + // Any plugins added outside of the game config, but before the game booted? + list = list.concat(this._pendingGlobal); + + for (i = 0; i < list.length; i++) + { + entry = list[i]; + + // { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test', data: { msg: 'The plugin is alive' } } + + key = GetFastValue(entry, 'key', null); + plugin = GetFastValue(entry, 'plugin', null); + start = GetFastValue(entry, 'start', false); + mapping = GetFastValue(entry, 'mapping', null); + data = GetFastValue(entry, 'data', null); + + if (key && plugin) + { + this.install(key, plugin, start, mapping, data); + } + } + + // Any scene plugins to install? + list = config.installScenePlugins; + + // Any plugins added outside of the game config, but before the game booted? + list = list.concat(this._pendingScene); + + for (i = 0; i < list.length; i++) + { + entry = list[i]; + + // { key: 'moveSpritePlugin', plugin: MoveSpritePlugin, , mapping: 'move' } + + key = GetFastValue(entry, 'key', null); + plugin = GetFastValue(entry, 'plugin', null); + mapping = GetFastValue(entry, 'mapping', null); + + if (key && plugin) + { + this.installScenePlugin(key, plugin, mapping); + } + } + + this._pendingGlobal = []; + this._pendingScene = []; + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * Called by the Scene Systems class. Tells the plugin manager to install all Scene plugins into it. + * + * First it will install global references, i.e. references from the Game systems into the Scene Systems (and Scene if mapped.) + * Then it will install Core Scene Plugins followed by Scene Plugins registered with the PluginManager. + * Finally it will install any references to Global Plugins that have a Scene mapping property into the Scene itself. + * + * @method Phaser.Plugins.PluginManager#addToScene + * @protected + * @since 3.8.0 + * + * @param {Phaser.Scenes.Systems} sys - The Scene Systems class to install all the plugins in to. + * @param {array} globalPlugins - An array of global plugins to install. + * @param {array} scenePlugins - An array of scene plugins to install. + */ + addToScene: function (sys, globalPlugins, scenePlugins) + { + var i; + var pluginKey; + var pluginList; + var game = this.game; + var scene = sys.scene; + var map = sys.settings.map; + var isBooted = sys.settings.isBooted; + + // Reference the GlobalPlugins from Game into Scene.Systems + for (i = 0; i < globalPlugins.length; i++) + { + pluginKey = globalPlugins[i]; + + if (game[pluginKey]) + { + sys[pluginKey] = game[pluginKey]; + + // Scene level injection + if (map.hasOwnProperty(pluginKey)) + { + scene[map[pluginKey]] = sys[pluginKey]; + } + } + else if (pluginKey === 'game' && map.hasOwnProperty(pluginKey)) + { + scene[map[pluginKey]] = game; + } + } + + for (var s = 0; s < scenePlugins.length; s++) + { + pluginList = scenePlugins[s]; + + for (i = 0; i < pluginList.length; i++) + { + pluginKey = pluginList[i]; + + if (!PluginCache.hasCore(pluginKey)) + { + continue; + } + + var source = PluginCache.getCore(pluginKey); + + var plugin = new source.plugin(scene, this); + + sys[source.mapping] = plugin; + + // Scene level injection + if (source.custom) + { + scene[source.mapping] = plugin; + } + else if (map.hasOwnProperty(source.mapping)) + { + scene[map[source.mapping]] = plugin; + } + + // Scene is already booted, usually because this method is being called at run-time, so boot the plugin + if (isBooted) + { + plugin.boot(); + } + } + } + + // And finally, inject any 'global scene plugins' + pluginList = this.plugins; + + for (i = 0; i < pluginList.length; i++) + { + var entry = pluginList[i]; + + if (entry.mapping) + { + scene[entry.mapping] = entry.plugin; + } + } + }, + + /** + * Called by the Scene Systems class. Returns a list of plugins to be installed. + * + * @method Phaser.Plugins.PluginManager#getDefaultScenePlugins + * @protected + * @since 3.8.0 + * + * @return {string[]} A list keys of all the Scene Plugins to install. + */ + getDefaultScenePlugins: function () + { + var list = this.game.config.defaultPlugins; + + // Merge in custom Scene plugins + list = list.concat(this.scenePlugins); + + return list; + }, + + /** + * Installs a new Scene Plugin into the Plugin Manager and optionally adds it + * to the given Scene as well. A Scene Plugin added to the manager in this way + * will be automatically installed into all new Scenes using the key and mapping given. + * + * The `key` property is what the plugin is injected into Scene.Systems as. + * The `mapping` property is optional, and if specified is what the plugin is installed into + * the Scene as. For example: + * + * ```javascript + * this.plugins.installScenePlugin('powerupsPlugin', pluginCode, 'powerups'); + * + * // and from within the scene: + * this.sys.powerupsPlugin; // key value + * this.powerups; // mapping value + * ``` + * + * This method is called automatically by Phaser if you install your plugins using either the + * Game Configuration object, or by preloading them via the Loader. + * + * @method Phaser.Plugins.PluginManager#installScenePlugin + * @since 3.8.0 + * + * @param {string} key - The property key that will be used to add this plugin to Scene.Systems. + * @param {function} plugin - The plugin code. This should be the non-instantiated version. + * @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use. + * @param {Phaser.Scene} [addToScene] - Optionally automatically add this plugin to the given Scene. + */ + installScenePlugin: function (key, plugin, mapping, addToScene) + { + if (typeof plugin !== 'function') + { + console.warn('Invalid Scene Plugin: ' + key); + return; + } + + if (PluginCache.hasCore(key)) + { + console.warn('Scene Plugin key in use: ' + key); + return; + } + + PluginCache.register(key, plugin, mapping, true); + + this.scenePlugins.push(key); + + if (addToScene) + { + var instance = new plugin(addToScene, this); + + addToScene.sys[key] = instance; + + if (mapping && mapping !== '') + { + addToScene[mapping] = instance; + } + + instance.boot(); + } + }, + + /** + * Installs a new Global Plugin into the Plugin Manager and optionally starts it running. + * A global plugin belongs to the Plugin Manager, rather than a specific Scene, and can be accessed + * and used by all Scenes in your game. + * + * The `key` property is what you use to access this plugin from the Plugin Manager. + * + * ```javascript + * this.plugins.install('powerupsPlugin', pluginCode); + * + * // and from within the scene: + * this.plugins.get('powerupsPlugin'); + * ``` + * + * This method is called automatically by Phaser if you install your plugins using either the + * Game Configuration object, or by preloading them via the Loader. + * + * The same plugin can be installed multiple times into the Plugin Manager by simply giving each + * instance its own unique key. + * + * @method Phaser.Plugins.PluginManager#install + * @since 3.8.0 + * + * @param {string} key - The unique handle given to this plugin within the Plugin Manager. + * @param {function} plugin - The plugin code. This should be the non-instantiated version. + * @param {boolean} [start=false] - Automatically start the plugin running? This is always `true` if you provide a mapping value. + * @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use. + * @param {any} [data] - A value passed to the plugin's `init` method. + */ + install: function (key, plugin, start, mapping, data) + { + if (start === undefined) { start = false; } + if (mapping === undefined) { mapping = null; } + if (data === undefined) { data = null; } + + if (typeof plugin !== 'function') + { + console.warn('Invalid Plugin: ' + key); + return; + } + + if (PluginCache.hasCustom(key)) + { + console.warn('Plugin key in use: ' + key); + return; + } + + if (mapping !== null) + { + start = true; + } + + if (!this.game.isBooted) + { + this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping, data: data }); + } + else + { + // Add it to the plugin store + PluginCache.registerCustom(key, plugin, mapping, data); + + if (start) + { + return this.start(key); + } + } + }, + + /** + * Gets an index of a global plugin based on the given key. + * + * @method Phaser.Plugins.PluginManager#getIndex + * @protected + * @since 3.8.0 + * + * @param {string} key - The unique plugin key. + * + * @return {integer} The index of the plugin within the plugins array. + */ + getIndex: function (key) + { + var list = this.plugins; + + for (var i = 0; i < list.length; i++) + { + var entry = list[i]; + + if (entry.key === key) + { + return i; + } + } + + return -1; + }, + + /** + * Gets a global plugin based on the given key. + * + * @method Phaser.Plugins.PluginManager#getEntry + * @protected + * @since 3.8.0 + * + * @param {string} key - The unique plugin key. + * + * @return {GlobalPlugin} The plugin entry. + */ + getEntry: function (key) + { + var idx = this.getIndex(key); + + if (idx !== -1) + { + return this.plugins[idx]; + } + }, + + /** + * Checks if the given global plugin, based on its key, is active or not. + * + * @method Phaser.Plugins.PluginManager#isActive + * @since 3.8.0 + * + * @param {string} key - The unique plugin key. + * + * @return {boolean} `true` if the plugin is active, otherwise `false`. + */ + isActive: function (key) + { + var entry = this.getEntry(key); + + return (entry && entry.active); + }, + + /** + * Starts a global plugin running. + * + * If the plugin was previously active then calling `start` will reset it to an active state and then + * call its `start` method. + * + * If the plugin has never been run before a new instance of it will be created within the Plugin Manager, + * its active state set and then both of its `init` and `start` methods called, in that order. + * + * If the plugin is already running under the given key then nothing happens. + * + * @method Phaser.Plugins.PluginManager#start + * @since 3.8.0 + * + * @param {string} key - The key of the plugin to start. + * @param {string} [runAs] - Run the plugin under a new key. This allows you to run one plugin multiple times. + * + * @return {?Phaser.Plugins.BasePlugin} The plugin that was started, or `null` if invalid key given or plugin is already stopped. + */ + start: function (key, runAs) + { + if (runAs === undefined) { runAs = key; } + + var entry = this.getEntry(runAs); + + // Plugin already running under this key? + if (entry && !entry.active) + { + // It exists, we just need to start it up again + entry.active = true; + entry.plugin.start(); + } + else if (!entry) + { + entry = this.createEntry(key, runAs); + } + + return (entry) ? entry.plugin : null; + }, + + /** + * Creates a new instance of a global plugin, adds an entry into the plugins array and returns it. + * + * @method Phaser.Plugins.PluginManager#createEntry + * @private + * @since 3.9.0 + * + * @param {string} key - The key of the plugin to create an instance of. + * @param {string} [runAs] - Run the plugin under a new key. This allows you to run one plugin multiple times. + * + * @return {?Phaser.Plugins.BasePlugin} The plugin that was started, or `null` if invalid key given. + */ + createEntry: function (key, runAs) + { + var entry = PluginCache.getCustom(key); + + if (entry) + { + var instance = new entry.plugin(this); + + entry = { + key: runAs, + plugin: instance, + active: true, + mapping: entry.mapping, + data: entry.data + }; + + this.plugins.push(entry); + + instance.init(entry.data); + instance.start(); + } + + return entry; + }, + + /** + * Stops a global plugin from running. + * + * If the plugin is active then its active state will be set to false and the plugins `stop` method + * will be called. + * + * If the plugin is not already running, nothing will happen. + * + * @method Phaser.Plugins.PluginManager#stop + * @since 3.8.0 + * + * @param {string} key - The key of the plugin to stop. + * + * @return {Phaser.Plugins.PluginManager} The Plugin Manager. + */ + stop: function (key) + { + var entry = this.getEntry(key); + + if (entry && entry.active) + { + entry.active = false; + entry.plugin.stop(); + } + + return this; + }, + + /** + * Gets a global plugin from the Plugin Manager based on the given key and returns it. + * + * If it cannot find an active plugin based on the key, but there is one in the Plugin Cache with the same key, + * then it will create a new instance of the cached plugin and return that. + * + * @method Phaser.Plugins.PluginManager#get + * @since 3.8.0 + * + * @param {string} key - The key of the plugin to get. + * @param {boolean} [autoStart=true] - Automatically start a new instance of the plugin if found in the cache, but not actively running. + * + * @return {?(Phaser.Plugins.BasePlugin|function)} The plugin, or `null` if no plugin was found matching the key. + */ + get: function (key, autoStart) + { + if (autoStart === undefined) { autoStart = true; } + + var entry = this.getEntry(key); + + if (entry) + { + return entry.plugin; + } + else + { + var plugin = this.getClass(key); + + if (plugin && autoStart) + { + entry = this.createEntry(key, key); + + return (entry) ? entry.plugin : null; + } + else if (plugin) + { + return plugin; + } + } + + return null; + }, + + /** + * Returns the plugin class from the cache. + * Used internally by the Plugin Manager. + * + * @method Phaser.Plugins.PluginManager#getClass + * @since 3.8.0 + * + * @param {string} key - The key of the plugin to get. + * + * @return {Phaser.Plugins.BasePlugin} A Plugin object + */ + getClass: function (key) + { + return PluginCache.getCustomClass(key); + }, + + /** + * Removes a global plugin from the Plugin Manager and Plugin Cache. + * + * It is up to you to remove all references to this plugin that you may hold within your game code. + * + * @method Phaser.Plugins.PluginManager#removeGlobalPlugin + * @since 3.8.0 + * + * @param {string} key - The key of the plugin to remove. + */ + removeGlobalPlugin: function (key) + { + var entry = this.getEntry(key); + + if (entry) + { + Remove(this.plugins, entry); + } + + PluginCache.removeCustom(key); + }, + + /** + * Removes a scene plugin from the Plugin Manager and Plugin Cache. + * + * This will not remove the plugin from any active Scenes that are already using it. + * + * It is up to you to remove all references to this plugin that you may hold within your game code. + * + * @method Phaser.Plugins.PluginManager#removeScenePlugin + * @since 3.8.0 + * + * @param {string} key - The key of the plugin to remove. + */ + removeScenePlugin: function (key) + { + Remove(this.scenePlugins, key); + + PluginCache.remove(key); + }, + + /** + * Registers a new type of Game Object with the global Game Object Factory and / or Creator. + * This is usually called from within your Plugin code and is a helpful short-cut for creating + * new Game Objects. + * + * The key is the property that will be injected into the factories and used to create the + * Game Object. For example: + * + * ```javascript + * this.plugins.registerGameObject('clown', clownFactoryCallback, clownCreatorCallback); + * // later in your game code: + * this.add.clown(); + * this.make.clown(); + * ``` + * + * The callbacks are what are called when the factories try to create a Game Object + * matching the given key. It's important to understand that the callbacks are invoked within + * the context of the GameObjectFactory. In this context there are several properties available + * to use: + * + * this.scene - A reference to the Scene that owns the GameObjectFactory. + * this.displayList - A reference to the Display List the Scene owns. + * this.updateList - A reference to the Update List the Scene owns. + * + * See the GameObjectFactory and GameObjectCreator classes for more details. + * Any public property or method listed is available from your callbacks under `this`. + * + * @method Phaser.Plugins.PluginManager#registerGameObject + * @since 3.8.0 + * + * @param {string} key - The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`. + * @param {function} [factoryCallback] - The callback to invoke when the Game Object Factory is called. + * @param {function} [creatorCallback] - The callback to invoke when the Game Object Creator is called. + */ + registerGameObject: function (key, factoryCallback, creatorCallback) + { + if (factoryCallback) + { + GameObjectFactory.register(key, factoryCallback); + } + + if (creatorCallback) + { + GameObjectCreator.register(key, creatorCallback); + } + + return this; + }, + + /** + * Registers a new file type with the global File Types Manager, making it available to all Loader + * Plugins created after this. + * + * This is usually called from within your Plugin code and is a helpful short-cut for creating + * new loader file types. + * + * The key is the property that will be injected into the Loader Plugin and used to load the + * files. For example: + * + * ```javascript + * this.plugins.registerFileType('wad', doomWadLoaderCallback); + * // later in your preload code: + * this.load.wad(); + * ``` + * + * The callback is what is called when the loader tries to load a file matching the given key. + * It's important to understand that the callback is invoked within + * the context of the LoaderPlugin. In this context there are several properties / methods available + * to use: + * + * this.addFile - A method to add the new file to the load queue. + * this.scene - The Scene that owns the Loader Plugin instance. + * + * See the LoaderPlugin class for more details. Any public property or method listed is available from + * your callback under `this`. + * + * @method Phaser.Plugins.PluginManager#registerFileType + * @since 3.8.0 + * + * @param {string} key - The key of the Game Object that the given callbacks will create, i.e. `image`, `sprite`. + * @param {function} callback - The callback to invoke when the Game Object Factory is called. + * @param {Phaser.Scene} [addToScene] - Optionally add this file type into the Loader Plugin owned by the given Scene. + */ + registerFileType: function (key, callback, addToScene) + { + FileTypesManager.register(key, callback); + + if (addToScene && addToScene.sys.load) + { + addToScene.sys.load[key] = callback; + } + }, + + /** + * Destroys this Plugin Manager and all associated plugins. + * It will iterate all plugins found and call their `destroy` methods. + * + * The PluginCache will remove all custom plugins. + * + * @method Phaser.Plugins.PluginManager#destroy + * @since 3.8.0 + */ + destroy: function () + { + for (var i = 0; i < this.plugins.length; i++) + { + this.plugins[i].plugin.destroy(); + } + + PluginCache.destroyCustomPlugins(); + + if (this.game.noReturn) + { + PluginCache.destroyCorePlugins(); + } + + this.game = null; + this.plugins = []; + this.scenePlugins = []; + } + +}); + +/* + * "Sometimes, the elegant implementation is just a function. + * Not a method. Not a class. Not a framework. Just a function." + * -- John Carmack + */ + +module.exports = PluginManager; + + +/***/ }), +/* 361 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector2 = __webpack_require__(3); + +/** + * Takes the `x` and `y` coordinates and transforms them into the same space as + * defined by the position, rotation and scale values. + * + * @function Phaser.Math.TransformXY + * @since 3.0.0 + * + * @param {number} x - The x coordinate to be transformed. + * @param {number} y - The y coordinate to be transformed. + * @param {number} positionX - Horizontal position of the transform point. + * @param {number} positionY - Vertical position of the transform point. + * @param {number} rotation - Rotation of the transform point, in radians. + * @param {number} scaleX - Horizontal scale of the transform point. + * @param {number} scaleY - Vertical scale of the transform point. + * @param {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} [output] - The output vector, point or object for the translated coordinates. + * + * @return {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} The translated point. + */ +var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) +{ + if (output === undefined) { output = new Vector2(); } + + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); + + // Rotate and Scale + var a = radianCos * scaleX; + var b = radianSin * scaleX; + var c = -radianSin * scaleY; + var d = radianCos * scaleY; + + // Invert + var id = 1 / ((a * d) + (c * -b)); + + output.x = (d * id * x) + (-c * id * y) + (((positionY * c) - (positionX * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-positionY * a) + (positionX * b)) * id); + + return output; +}; + +module.exports = TransformXY; + + +/***/ }), +/* 362 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var NOOP = __webpack_require__(2); + +// https://developer.mozilla.org/en-US/docs/Web/API/Touch_events +// https://patrickhlauke.github.io/touch/tests/results/ +// https://www.html5rocks.com/en/mobile/touch/ + +/** + * @classdesc + * The Touch Manager is a helper class that belongs to the Input Manager. + * + * Its role is to listen for native DOM Touch Events and then pass them onto the Input Manager for further processing. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically. + * + * @class TouchManager + * @memberof Phaser.Input.Touch + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.InputManager} inputManager - A reference to the Input Manager. + */ +var TouchManager = new Class({ + + initialize: + + function TouchManager (inputManager) + { + /** + * A reference to the Input Manager. + * + * @name Phaser.Input.Touch.TouchManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * If true the DOM events will have event.preventDefault applied to them, if false they will propagate fully. + * + * @name Phaser.Input.Touch.TouchManager#capture + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.capture = true; + + /** + * A boolean that controls if the Touch Manager is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Touch.TouchManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * The Touch Event target, as defined in the Game Config. + * Typically the canvas to which the game is rendering, but can be any interactive DOM element. + * + * @name Phaser.Input.Touch.TouchManager#target + * @type {any} + * @since 3.0.0 + */ + this.target; + + /** + * The Touch Start event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchStart + * @type {function} + * @since 3.0.0 + */ + this.onTouchStart = NOOP; + + /** + * The Touch Move event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchMove + * @type {function} + * @since 3.0.0 + */ + this.onTouchMove = NOOP; + + /** + * The Touch End event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchEnd + * @type {function} + * @since 3.0.0 + */ + this.onTouchEnd = NOOP; + + /** + * The Touch Cancel event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchCancel + * @type {function} + * @since 3.15.0 + */ + this.onTouchCancel = NOOP; + + inputManager.events.once('boot', this.boot, this); + }, + + /** + * The Touch Manager boot process. + * + * @method Phaser.Input.Touch.TouchManager#boot + * @private + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputTouch; + this.target = config.inputTouchEventTarget; + this.capture = config.inputTouchCapture; + + if (!this.target) + { + this.target = this.manager.game.canvas; + } + + if (this.enabled && this.target) + { + this.startListeners(); + } + }, + + /** + * Starts the Touch Event listeners running as long as an input target is set. + * + * This method is called automatically if Touch Input is enabled in the game config, + * which it is by default. However, you can call it manually should you need to + * delay input capturing until later in the game. + * + * @method Phaser.Input.Touch.TouchManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var _this = this; + + this.onTouchStart = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchStart(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchMove = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchMove(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchEnd = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchEnd(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchCancel = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchCancel(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + var target = this.target; + + if (!target) + { + return; + } + + var passive = { passive: true }; + var nonPassive = { passive: false }; + + if (this.capture) + { + target.addEventListener('touchstart', this.onTouchStart, nonPassive); + target.addEventListener('touchmove', this.onTouchMove, nonPassive); + target.addEventListener('touchend', this.onTouchEnd, nonPassive); + target.addEventListener('touchcancel', this.onTouchCancel, nonPassive); + } + else + { + target.addEventListener('touchstart', this.onTouchStart, passive); + target.addEventListener('touchmove', this.onTouchMove, passive); + target.addEventListener('touchend', this.onTouchEnd, passive); + } + + this.enabled = true; + }, + + /** + * Stops the Touch Event listeners. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Touch.TouchManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('touchstart', this.onTouchStart); + target.removeEventListener('touchmove', this.onTouchMove); + target.removeEventListener('touchend', this.onTouchEnd); + target.removeEventListener('touchcancel', this.onTouchCancel); + }, + + /** + * Destroys this Touch Manager instance. + * + * @method Phaser.Input.Touch.TouchManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.target = null; + this.enabled = false; + this.manager = null; + } + +}); + +module.exports = TouchManager; + + +/***/ }), +/* 363 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SmoothStep = __webpack_require__(199); + +/** + * A Smooth Step interpolation method. + * + * @function Phaser.Math.Interpolation.SmoothStep + * @since 3.9.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep} + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The interpolated value. + */ +var SmoothStepInterpolation = function (t, min, max) +{ + return min + (max - min) * SmoothStep(t, 0, 1); +}; + +module.exports = SmoothStepInterpolation; + + +/***/ }), +/* 364 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Distance = __webpack_require__(58); +var SmoothStepInterpolation = __webpack_require__(363); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Pointer object encapsulates both mouse and touch input within Phaser. + * + * By default, Phaser will create 2 pointers for your game to use. If you require more, i.e. for a multi-touch + * game, then use the `InputPlugin.addPointer` method to do so, rather than instantiating this class directly, + * otherwise it won't be managed by the input system. + * + * You can reference the current active pointer via `InputPlugin.activePointer`. You can also use the properties + * `InputPlugin.pointer1` through to `pointer10`, for each pointer you have enabled in your game. + * + * The properties of this object are set by the Input Plugin during processing. This object is then sent in all + * input related events that the Input Plugin emits, so you can reference properties from it directly in your + * callbacks. + * + * @class Pointer + * @memberof Phaser.Input + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.InputManager} manager - A reference to the Input Manager. + * @param {integer} id - The internal ID of this Pointer. + */ +var Pointer = new Class({ + + initialize: + + function Pointer (manager, id) + { + /** + * A reference to the Input Manager. + * + * @name Phaser.Input.Pointer#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The internal ID of this Pointer. + * + * @name Phaser.Input.Pointer#id + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.id = id; + + /** + * The most recent native DOM Event this Pointer has processed. + * + * @name Phaser.Input.Pointer#event + * @type {(TouchEvent|MouseEvent)} + * @since 3.0.0 + */ + this.event; + + /** + * The camera the Pointer interacted with during its last update. + * + * A Pointer can only ever interact with one camera at once, which will be the top-most camera + * in the list should multiple cameras be positioned on-top of each other. + * + * @name Phaser.Input.Pointer#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = null; + + /** + * 0: No button or un-initialized + * 1: Left button + * 2: Right button + * 4: Wheel button or middle button + * 8: 4th button (typically the "Browser Back" button) + * 16: 5th button (typically the "Browser Forward" button) + * + * For a mouse configured for left-handed use, the button actions are reversed. + * In this case, the values are read from right to left. + * + * @name Phaser.Input.Pointer#buttons + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.buttons = 0; + + /** + * The position of the Pointer in screen space. + * + * @name Phaser.Input.Pointer#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(); + + /** + * The previous position of the Pointer in screen space. + * + * The old x and y values are stored in here during the InputManager.transformPointer call. + * + * You can use it to track how fast the pointer is moving, or to smoothly interpolate between the old and current position. + * See the `Pointer.getInterpolatedPosition` method to assist in this. + * + * @name Phaser.Input.Pointer#prevPosition + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.prevPosition = new Vector2(); + + /** + * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. + * + * @name Phaser.Input.Pointer#worldX + * @type {number} + * @default 0 + * @since 3.10.0 + */ + this.worldX = 0; + + /** + * The y position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. + * + * @name Phaser.Input.Pointer#worldY + * @type {number} + * @default 0 + * @since 3.10.0 + */ + this.worldY = 0; + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downX = 0; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downY = 0; + + /** + * Time when Button 1 (left button), or Touch, was pressed, used for dragging objects. + * + * @name Phaser.Input.Pointer#downTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.downTime = 0; + + /** + * X coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upX = 0; + + /** + * Y coordinate of the Pointer when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upY = 0; + + /** + * Time when Button 1 (left button), or Touch, was released, used for dragging objects. + * + * @name Phaser.Input.Pointer#upTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.upTime = 0; + + /** + * Is the primary button down? (usually button 0, the left mouse button) + * + * @name Phaser.Input.Pointer#primaryDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.primaryDown = false; + + /** + * The Drag State of the Pointer: + * + * 0 = Not dragging anything + * 1 = Being checked if dragging + * 2 = Dragging something + * + * @name Phaser.Input.Pointer#dragState + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragState = 0; + + /** + * Is _any_ button on this pointer considered as being down? + * + * @name Phaser.Input.Pointer#isDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isDown = false; + + /** + * A dirty flag for this Pointer, used internally by the Input Plugin. + * + * @name Phaser.Input.Pointer#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + /** + * Is this Pointer considered as being "just down" or not? + * + * @name Phaser.Input.Pointer#justDown + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.justDown = false; + + /** + * Is this Pointer considered as being "just up" or not? + * + * @name Phaser.Input.Pointer#justUp + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.justUp = false; + + /** + * Is this Pointer considered as being "just moved" or not? + * + * @name Phaser.Input.Pointer#justMoved + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.justMoved = false; + + /** + * Did the previous input event come from a Touch input (true) or Mouse? (false) + * + * @name Phaser.Input.Pointer#wasTouch + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.wasTouch = false; + + /** + * Did this Pointer get canceled by a touchcancel event? + * + * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! + * + * @name Phaser.Input.Pointer#wasCanceled + * @type {boolean} + * @default false + * @since 3.15.0 + */ + this.wasCanceled = false; + + /** + * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. + * + * @name Phaser.Input.Pointer#movementX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.movementX = 0; + + /** + * If the mouse is locked, the vertical relative movement of the Pointer in pixels since last frame. + * + * @name Phaser.Input.Pointer#movementY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.movementY = 0; + + /** + * The identifier property of the Pointer as set by the DOM event when this Pointer is started. + * + * @name Phaser.Input.Pointer#identifier + * @type {number} + * @since 3.10.0 + */ + this.identifier = 0; + + /** + * The pointerId property of the Pointer as set by the DOM event when this Pointer is started. + * The browser can and will recycle this value. + * + * @name Phaser.Input.Pointer#pointerId + * @type {number} + * @since 3.10.0 + */ + this.pointerId = null; + + /** + * An active Pointer is one that is currently pressed down on the display. + * A Mouse is always considered as active. + * + * @name Phaser.Input.Pointer#active + * @type {boolean} + * @since 3.10.0 + */ + this.active = (id === 0) ? true : false; + }, + + /** + * Takes a Camera and returns a Vector2 containing the translated position of this Pointer + * within that Camera. This can be used to convert this Pointers position into camera space. + * + * @method Phaser.Input.Pointer#positionToCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the translation. + * @param {(Phaser.Math.Vector2|object)} [output] - A Vector2-like object in which to store the translated position. + * + * @return {(Phaser.Math.Vector2|object)} A Vector2 containing the translated coordinates of this Pointer, based on the given camera. + */ + positionToCamera: function (camera, output) + { + return camera.getWorldPoint(this.x, this.y, output); + }, + + /** + * Resets the temporal properties of this Pointer. + * Called automatically by the Input Plugin each update. + * + * @method Phaser.Input.Pointer#reset + * @private + * @since 3.0.0 + */ + reset: function () + { + this.dirty = false; + + this.justDown = false; + this.justUp = false; + this.justMoved = false; + + this.movementX = 0; + this.movementY = 0; + }, + + /** + * Internal method to handle a Mouse Up Event. + * + * @method Phaser.Input.Pointer#up + * @private + * @since 3.0.0 + * + * @param {MouseEvent} event - The Mouse Event to process. + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + up: function (event, time) + { + if (event.buttons) + { + this.buttons = event.buttons; + } + + this.event = event; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY); + + // 0: Main button pressed, usually the left button or the un-initialized state + if (event.button === 0) + { + this.primaryDown = false; + this.upX = this.x; + this.upY = this.y; + this.upTime = time; + } + + this.justUp = true; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = false; + }, + + /** + * Internal method to handle a Mouse Down Event. + * + * @method Phaser.Input.Pointer#down + * @private + * @since 3.0.0 + * + * @param {MouseEvent} event - The Mouse Event to process. + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + down: function (event, time) + { + if (event.buttons) + { + this.buttons = event.buttons; + } + + this.event = event; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY); + + // 0: Main button pressed, usually the left button or the un-initialized state + if (event.button === 0) + { + this.primaryDown = true; + this.downX = this.x; + this.downY = this.y; + this.downTime = time; + } + + this.justDown = true; + this.isDown = true; + + this.dirty = true; + + this.wasTouch = false; + }, + + /** + * Internal method to handle a Mouse Move Event. + * + * @method Phaser.Input.Pointer#move + * @private + * @since 3.0.0 + * + * @param {MouseEvent} event - The Mouse Event to process. + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + move: function (event) + { + if (event.buttons) + { + this.buttons = event.buttons; + } + + this.event = event; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY); + + if (this.manager.mouse.locked) + { + // Multiple DOM events may occur within one frame, but only one Phaser event will fire + this.movementX += event.movementX || event.mozMovementX || event.webkitMovementX || 0; + this.movementY += event.movementY || event.mozMovementY || event.webkitMovementY || 0; + } + + this.justMoved = true; + + this.dirty = true; + + this.wasTouch = false; + }, + + /** + * Internal method to handle a Touch Start Event. + * + * @method Phaser.Input.Pointer#touchstart + * @private + * @since 3.0.0 + * + * @param {TouchEvent} event - The Touch Event to process. + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + touchstart: function (event, time) + { + if (event['pointerId']) + { + this.pointerId = event.pointerId; + } + + this.identifier = event.identifier; + this.target = event.target; + this.active = true; + + this.buttons = 1; + + this.event = event; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY); + + this.primaryDown = true; + this.downX = this.x; + this.downY = this.y; + this.downTime = time; + + this.justDown = true; + this.isDown = true; + + this.dirty = true; + + this.wasTouch = true; + this.wasCanceled = false; + }, + + /** + * Internal method to handle a Touch Move Event. + * + * @method Phaser.Input.Pointer#touchmove + * @private + * @since 3.0.0 + * + * @param {TouchEvent} event - The Touch Event to process. + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + touchmove: function (event) + { + this.event = event; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY); + + this.justMoved = true; + + this.dirty = true; + + this.wasTouch = true; + }, + + /** + * Internal method to handle a Touch End Event. + * + * @method Phaser.Input.Pointer#touchend + * @private + * @since 3.0.0 + * + * @param {TouchEvent} event - The Touch Event to process. + * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + */ + touchend: function (event, time) + { + this.buttons = 0; + + this.event = event; + + // Sets the local x/y properties + this.manager.transformPointer(this, event.pageX, event.pageY); + + this.primaryDown = false; + this.upX = this.x; + this.upY = this.y; + this.upTime = time; + + this.justUp = true; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = true; + this.wasCanceled = false; + + this.active = false; + }, + + /** + * Internal method to handle a Touch Cancel Event. + * + * @method Phaser.Input.Pointer#touchcancel + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The Touch Event to process. + */ + touchcancel: function (event) + { + this.buttons = 0; + + this.event = event; + + this.primaryDown = false; + + this.justUp = false; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = true; + this.wasCanceled = true; + + this.active = false; + }, + + /** + * Checks to see if any buttons are being held down on this Pointer. + * + * @method Phaser.Input.Pointer#noButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if no buttons are being held down. + */ + noButtonDown: function () + { + return (this.buttons === 0); + }, + + /** + * Checks to see if the left button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#leftButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the left button is being held down. + */ + leftButtonDown: function () + { + return (this.buttons & 1); + }, + + /** + * Checks to see if the right button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#rightButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the right button is being held down. + */ + rightButtonDown: function () + { + return (this.buttons & 2); + }, + + /** + * Checks to see if the middle button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#middleButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the middle button is being held down. + */ + middleButtonDown: function () + { + return (this.buttons & 4); + }, + + /** + * Checks to see if the back button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#backButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the back button is being held down. + */ + backButtonDown: function () + { + return (this.buttons & 8); + }, + + /** + * Checks to see if the forward button is being held down on this Pointer. + * + * @method Phaser.Input.Pointer#forwardButtonDown + * @since 3.0.0 + * + * @return {boolean} `true` if the forward button is being held down. + */ + forwardButtonDown: function () + { + return (this.buttons & 16); + }, + + /** + * Returns the distance between the Pointer's current position and where it was + * first pressed down (the `downX` and `downY` properties) + * + * @method Phaser.Input.Pointer#getDistance + * @since 3.13.0 + * + * @return {number} The distance the Pointer has moved since being pressed down. + */ + getDistance: function () + { + return Distance(this.downX, this.downY, this.x, this.y); + }, + + /** + * Takes the previous and current Pointer positions and then generates an array of interpolated values between + * the two. The array will be populated up to the size of the `steps` argument. + * + * ```javaScript + * var points = pointer.getInterpolatedPosition(4); + * + * // points[0] = { x: 0, y: 0 } + * // points[1] = { x: 2, y: 1 } + * // points[2] = { x: 3, y: 2 } + * // points[3] = { x: 6, y: 3 } + * ``` + * + * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer + * events can often fire faster than the main browser loop, and this will help you avoid janky movement + * especially if you have an object following a Pointer. + * + * Note that if you provide an output array it will only be populated up to the number of steps provided. + * It will not clear any previous data that may have existed beyond the range of the steps count. + * + * Internally it uses the Smooth Step interpolation calculation. + * + * @method Phaser.Input.Pointer#getInterpolatedPosition + * @since 3.11.0 + * + * @param {integer} [steps=10] - The number of interpolation steps to use. + * @param {array} [out] - An array to store the results in. If not provided a new one will be created. + * + * @return {array} An array of interpolated values. + */ + getInterpolatedPosition: function (steps, out) + { + if (steps === undefined) { steps = 10; } + if (out === undefined) { out = []; } + + var prevX = this.prevPosition.x; + var prevY = this.prevPosition.y; + + var curX = this.position.x; + var curY = this.position.y; + + for (var i = 0; i < steps; i++) + { + var t = (1 / steps) * i; + + out[i] = { x: SmoothStepInterpolation(t, prevX, curX), y: SmoothStepInterpolation(t, prevY, curY) }; + } + + return out; + }, + + /** + * Destroys this Pointer instance and resets its external references. + * + * @method Phaser.Input.Pointer#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + this.manager = null; + this.position = null; + }, + + /** + * The x position of this Pointer. + * The value is in screen space. + * See `worldX` to get a camera converted position. + * + * @name Phaser.Input.Pointer#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + } + + }, + + /** + * The y position of this Pointer. + * The value is in screen space. + * See `worldY` to get a camera converted position. + * + * @name Phaser.Input.Pointer#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } + + } + +}); + +module.exports = Pointer; + + +/***/ }), +/* 365 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Features = __webpack_require__(186); + +// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent +// https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md + +/** + * @classdesc + * The Mouse Manager is a helper class that belongs to the Input Manager. + * + * Its role is to listen for native DOM Mouse Events and then pass them onto the Input Manager for further processing. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically. + * + * @class MouseManager + * @memberof Phaser.Input.Mouse + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Input.InputManager} inputManager - A reference to the Input Manager. + */ +var MouseManager = new Class({ + + initialize: + + function MouseManager (inputManager) + { + /** + * A reference to the Input Manager. + * + * @name Phaser.Input.Mouse.MouseManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = inputManager; + + /** + * If true the DOM mouse events will have event.preventDefault applied to them, if false they will propagate fully. + * + * @name Phaser.Input.Mouse.MouseManager#capture + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.capture = true; + + /** + * A boolean that controls if the Mouse Manager is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Mouse.MouseManager#enabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.enabled = false; + + /** + * The Touch Event target, as defined in the Game Config. + * Typically the canvas to which the game is rendering, but can be any interactive DOM element. + * + * @name Phaser.Input.Mouse.MouseManager#target + * @type {any} + * @since 3.0.0 + */ + this.target; + + /** + * If the mouse has been pointer locked successfully this will be set to true. + * + * @name Phaser.Input.Mouse.MouseManager#locked + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.locked = false; + + inputManager.events.once('boot', this.boot, this); + }, + + /** + * The Touch Manager boot process. + * + * @method Phaser.Input.Mouse.MouseManager#boot + * @private + * @since 3.0.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputMouse; + this.target = config.inputMouseEventTarget; + this.capture = config.inputMouseCapture; + + if (!this.target) + { + this.target = this.manager.game.canvas; + } + + if (config.disableContextMenu) + { + this.disableContextMenu(); + } + + if (this.enabled) + { + this.startListeners(); + } + }, + + /** + * Attempts to disable the context menu from appearing if you right-click on the browser. + * + * Works by listening for the `contextmenu` event and prevent defaulting it. + * + * Use this if you need to enable right-button mouse support in your game, and the browser + * menu keeps getting in the way. + * + * @method Phaser.Input.Mouse.MouseManager#disableContextMenu + * @since 3.0.0 + * + * @return {Phaser.Input.Mouse.MouseManager} This Mouse Manager instance. + */ + disableContextMenu: function () + { + document.body.addEventListener('contextmenu', function (event) + { + event.preventDefault(); + return false; + }); + + return this; + }, + + /** + * If the browser supports it, you can request that the pointer be locked to the browser window. + * + * This is classically known as 'FPS controls', where the pointer can't leave the browser until + * the user presses an exit key. + * + * If the browser successfully enters a locked state, a `POINTER_LOCK_CHANGE_EVENT` will be dispatched, + * from the games Input Manager, with an `isPointerLocked` property. + * + * It is important to note that pointer lock can only be enabled after an 'engagement gesture', + * see: https://w3c.github.io/pointerlock/#dfn-engagement-gesture. + * + * @method Phaser.Input.Mouse.MouseManager#requestPointerLock + * @since 3.0.0 + */ + requestPointerLock: function () + { + if (Features.pointerLock) + { + var element = this.target; + element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; + element.requestPointerLock(); + } + }, + + /** + * Internal pointerLockChange handler. + * + * @method Phaser.Input.Mouse.MouseManager#pointerLockChange + * @since 3.0.0 + * + * @param {MouseEvent} event - The native event from the browser. + */ + + /* + pointerLockChange: function (event) + { + var element = this.target; + + this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; + + this.manager.queue.push(event); + }, + */ + + /** + * If the browser supports pointer lock, this will request that the pointer lock is released. If + * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be + * dispatched - from the game's input manager - with an `isPointerLocked` property. + * + * @method Phaser.Input.Mouse.MouseManager#releasePointerLock + * @since 3.0.0 + */ + releasePointerLock: function () + { + if (Features.pointerLock) + { + document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; + document.exitPointerLock(); + } + }, + + /** + * The Mouse Move Event Handler. + * + * @method Phaser.Input.Mouse.MouseManager#onMouseMove + * @since 3.10.0 + * + * @param {MouseEvent} event - The native DOM Mouse Move Event. + */ + + /* + onMouseMove: function (event) + { + if (event.defaultPrevented || !this.enabled || !this.manager) + { + // Do nothing if event already handled + return; + } + + this.manager.queueMouseMove(event); + + if (this.capture) + { + event.preventDefault(); + } + }, + */ + + /** + * The Mouse Down Event Handler. + * + * @method Phaser.Input.Mouse.MouseManager#onMouseDown + * @since 3.10.0 + * + * @param {MouseEvent} event - The native DOM Mouse Down Event. + */ + + /* + onMouseDown: function (event) + { + if (event.defaultPrevented || !this.enabled) + { + // Do nothing if event already handled + return; + } + + this.manager.queueMouseDown(event); + + if (this.capture) + { + event.preventDefault(); + } + }, + */ + + /** + * The Mouse Up Event Handler. + * + * @method Phaser.Input.Mouse.MouseManager#onMouseUp + * @since 3.10.0 + * + * @param {MouseEvent} event - The native DOM Mouse Up Event. + */ + + /* + onMouseUp: function (event) + { + if (event.defaultPrevented || !this.enabled) + { + // Do nothing if event already handled + return; + } + + this.manager.queueMouseUp(event); + + if (this.capture) + { + event.preventDefault(); + } + }, + */ + + /** + * Starts the Mouse Event listeners running. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Mouse.MouseManager#startListeners + * @since 3.0.0 + */ + startListeners: function () + { + var _this = this; + + var onMouseMove = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseMove(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + var onMouseDown = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseDown(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + var onMouseUp = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseUp(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onMouseMove = onMouseMove; + this.onMouseDown = onMouseDown; + this.onMouseUp = onMouseUp; + + var target = this.target; + var passive = { passive: true }; + var nonPassive = { passive: false }; + + target.addEventListener('mousemove', onMouseMove, (this.capture) ? nonPassive : passive); + target.addEventListener('mousedown', onMouseDown, (this.capture) ? nonPassive : passive); + target.addEventListener('mouseup', onMouseUp, (this.capture) ? nonPassive : passive); + + if (Features.pointerLock) + { + var onPointerLockChange = function (event) + { + var element = _this.target; + + _this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; + + _this.manager.queue.push(event); + }; + + this.pointerLockChange = onPointerLockChange; + + document.addEventListener('pointerlockchange', onPointerLockChange, true); + document.addEventListener('mozpointerlockchange', onPointerLockChange, true); + document.addEventListener('webkitpointerlockchange', onPointerLockChange, true); + } + }, + + /** + * Stops the Mouse Event listeners. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Mouse.MouseManager#stopListeners + * @since 3.0.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('mousemove', this.onMouseMove); + target.removeEventListener('mousedown', this.onMouseDown); + target.removeEventListener('mouseup', this.onMouseUp); + + if (Features.pointerLock) + { + document.removeEventListener('pointerlockchange', this.pointerLockChange, true); + document.removeEventListener('mozpointerlockchange', this.pointerLockChange, true); + document.removeEventListener('webkitpointerlockchange', this.pointerLockChange, true); + } + }, + + /** + * Destroys this Mouse Manager instance. + * + * @method Phaser.Input.Mouse.MouseManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stopListeners(); + + this.target = null; + this.manager = null; + } + +}); + +module.exports = MouseManager; + + +/***/ }), +/* 366 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var INPUT_CONST = { + + /** + * The mouse pointer is being held down. + * + * @name Phaser.Input.MOUSE_DOWN + * @type {integer} + * @since 3.10.0 + */ + MOUSE_DOWN: 0, + + /** + * The mouse pointer is being moved. + * + * @name Phaser.Input.MOUSE_MOVE + * @type {integer} + * @since 3.10.0 + */ + MOUSE_MOVE: 1, + + /** + * The mouse pointer is released. + * + * @name Phaser.Input.MOUSE_UP + * @type {integer} + * @since 3.10.0 + */ + MOUSE_UP: 2, + + /** + * A touch pointer has been started. + * + * @name Phaser.Input.TOUCH_START + * @type {integer} + * @since 3.10.0 + */ + TOUCH_START: 3, + + /** + * A touch pointer has been started. + * + * @name Phaser.Input.TOUCH_MOVE + * @type {integer} + * @since 3.10.0 + */ + TOUCH_MOVE: 4, + + /** + * A touch pointer has been started. + * + * @name Phaser.Input.TOUCH_END + * @type {integer} + * @since 3.10.0 + */ + TOUCH_END: 5, + + /** + * A touch pointer has been been cancelled by the browser. + * + * @name Phaser.Input.TOUCH_CANCEL + * @type {integer} + * @since 3.15.0 + */ + TOUCH_CANCEL: 7, + + /** + * The pointer lock has changed. + * + * @name Phaser.Input.POINTER_LOCK_CHANGE + * @type {integer} + * @since 3.10.0 + */ + POINTER_LOCK_CHANGE: 6 + +}; + +module.exports = INPUT_CONST; + + +/***/ }), +/* 367 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(366); +var EventEmitter = __webpack_require__(11); +var Mouse = __webpack_require__(365); +var Pointer = __webpack_require__(364); +var Rectangle = __webpack_require__(10); +var Touch = __webpack_require__(362); +var TransformMatrix = __webpack_require__(42); +var TransformXY = __webpack_require__(361); + +/** + * @classdesc + * The Input Manager is responsible for handling the pointer related systems in a single Phaser Game instance. + * + * Based on the Game Config it will create handlers for mouse and touch support. + * + * Keyboard and Gamepad are plugins, handled directly by the InputPlugin class. + * + * It then manages the event queue, pointer creation and general hit test related operations. + * + * You rarely need to interact with the Input Manager directly, and as such, all of its properties and methods + * should be considered private. Instead, you should use the Input Plugin, which is a Scene level system, responsible + * for dealing with all input events for a Scene. + * + * @class InputManager + * @memberof Phaser.Input + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Game instance that owns the Input Manager. + * @param {object} config - The Input Configuration object, as set in the Game Config. + */ +var InputManager = new Class({ + + initialize: + + function InputManager (game, config) + { + /** + * The Game instance that owns the Input Manager. + * A Game only maintains on instance of the Input Manager at any time. + * + * @name Phaser.Input.InputManager#game + * @type {Phaser.Game} + * @readonly + * @since 3.0.0 + */ + this.game = game; + + /** + * The Canvas that is used for all DOM event input listeners. + * + * @name Phaser.Input.InputManager#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas; + + /** + * The Input Configuration object, as set in the Game Config. + * + * @name Phaser.Input.InputManager#config + * @type {object} + * @since 3.0.0 + */ + this.config = config; + + /** + * If set, the Input Manager will run its update loop every frame. + * + * @name Phaser.Input.InputManager#enabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enabled = true; + + /** + * The Event Emitter instance that the Input Manager uses to emit events from. + * + * @name Phaser.Input.InputManager#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + + /** + * A standard FIFO queue for the native DOM events waiting to be handled by the Input Manager. + * + * @name Phaser.Input.InputManager#queue + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.queue = []; + + /** + * DOM Callbacks container. + * + * @name Phaser.Input.InputManager#domCallbacks + * @private + * @type {object} + * @since 3.10.0 + */ + this.domCallbacks = { up: [], down: [], move: [], upOnce: [], downOnce: [], moveOnce: [] }; + + /** + * Are there any up callbacks defined? + * + * @name Phaser.Input.InputManager#_hasUpCallback + * @private + * @type {boolean} + * @since 3.10.0 + */ + this._hasUpCallback = false; + + /** + * Are there any down callbacks defined? + * + * @name Phaser.Input.InputManager#_hasDownCallback + * @private + * @type {boolean} + * @since 3.10.0 + */ + this._hasDownCallback = false; + + /** + * Are there any move callbacks defined? + * + * @name Phaser.Input.InputManager#_hasMoveCallback + * @private + * @type {boolean} + * @since 3.10.0 + */ + this._hasMoveCallback = false; + + /** + * Is a custom cursor currently set? (desktop only) + * + * @name Phaser.Input.InputManager#_customCursor + * @private + * @type {string} + * @since 3.10.0 + */ + this._customCursor = ''; + + /** + * Custom cursor tracking value. + * + * 0 - No change. + * 1 - Set new cursor. + * 2 - Reset cursor. + * + * @name Phaser.Input.InputManager#_setCursor + * @private + * @type {integer} + * @since 3.10.0 + */ + this._setCursor = 0; + + /** + * The default CSS cursor to be used when interacting with your game. + * + * See the `setDefaultCursor` method for more details. + * + * @name Phaser.Input.InputManager#defaultCursor + * @type {string} + * @since 3.10.0 + */ + this.defaultCursor = ''; + + /** + * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. + * + * @name Phaser.Input.InputManager#mouse + * @type {?Phaser.Input.Mouse.MouseManager} + * @since 3.0.0 + */ + this.mouse = (config.inputMouse) ? new Mouse(this) : null; + + /** + * A reference to the Touch Manager class, if enabled via the `input.touch` Game Config property. + * + * @name Phaser.Input.InputManager#touch + * @type {Phaser.Input.Touch.TouchManager} + * @since 3.0.0 + */ + this.touch = (config.inputTouch) ? new Touch(this) : null; + + /** + * An array of Pointers that have been added to the game. + * The first entry is reserved for the Mouse Pointer, the rest are Touch Pointers. + * + * By default there is 1 touch pointer enabled. If you need more use the `addPointer` method to start them, + * or set the `input.activePointers` property in the Game Config. + * + * @name Phaser.Input.InputManager#pointers + * @type {Phaser.Input.Pointer[]} + * @since 3.10.0 + */ + this.pointers = []; + + /** + * The number of touch objects activated and being processed each update. + * + * You can change this by either calling `addPointer` at run-time, or by + * setting the `input.activePointers` property in the Game Config. + * + * @name Phaser.Input.InputManager#pointersTotal + * @type {integer} + * @readonly + * @since 3.10.0 + */ + this.pointersTotal = config.inputActivePointers; + + if (config.inputTouch && this.pointersTotal === 1) + { + this.pointersTotal = 2; + } + + for (var i = 0; i <= this.pointersTotal; i++) + { + this.pointers.push(new Pointer(this, i)); + } + + /** + * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. + * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` + * which will always map to the most recently interacted pointer. + * + * @name Phaser.Input.InputManager#mousePointer + * @type {?Phaser.Input.Pointer} + * @since 3.10.0 + */ + this.mousePointer = (config.inputMouse) ? this.pointers[0] : null; + + /** + * The most recently active Pointer object. + * + * If you've only 1 Pointer in your game then this will accurately be either the first finger touched, or the mouse. + * + * If your game doesn't need to support multi-touch then you can safely use this property in all of your game + * code and it will adapt to be either the mouse or the touch, based on device. + * + * @name Phaser.Input.InputManager#activePointer + * @type {Phaser.Input.Pointer} + * @since 3.0.0 + */ + this.activePointer = this.pointers[0]; + + /** + * Reset every frame. Set to `true` if any of the Pointers are dirty this frame. + * + * @name Phaser.Input.InputManager#dirty + * @type {boolean} + * @since 3.10.0 + */ + this.dirty = false; + + /** + * The Scale factor being applied to input coordinates. + * + * @name Phaser.Input.InputManager#scale + * @type { { x:number, y:number } } + * @since 3.0.0 + */ + this.scale = { x: 1, y: 1 }; + + /** + * If the top-most Scene in the Scene List receives an input it will stop input from + * propagating any lower down the scene list, i.e. if you have a UI Scene at the top + * and click something on it, that click will not then be passed down to any other + * Scene below. Disable this to have input events passed through all Scenes, all the time. + * + * @name Phaser.Input.InputManager#globalTopOnly + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.globalTopOnly = true; + + /** + * An internal flag that controls if the Input Manager will ignore or process native DOM events this frame. + * Set via the InputPlugin.stopPropagation method. + * + * @name Phaser.Input.InputManager#ignoreEvents + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.ignoreEvents = false; + + /** + * The bounds of the Input Manager, used for pointer hit test calculations. + * + * @name Phaser.Input.InputManager#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.0.0 + */ + this.bounds = new Rectangle(); + + /** + * A re-cycled point-like object to store hit test values in. + * + * @name Phaser.Input.InputManager#_tempPoint + * @type {{x:number,y:number}} + * @private + * @since 3.0.0 + */ + this._tempPoint = { x: 0, y: 0 }; + + /** + * A re-cycled array to store hit results in. + * + * @name Phaser.Input.InputManager#_tempHitTest + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._tempHitTest = []; + + /** + * A re-cycled matrix used in hit test calculations. + * + * @name Phaser.Input.InputManager#_tempMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.4.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * A re-cycled matrix used in hit test calculations. + * + * @name Phaser.Input.InputManager#_tempMatrix2 + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + game.events.once('boot', this.boot, this); + }, + + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * The renderer is available by now. + * + * @method Phaser.Input.InputManager#boot + * @protected + * @since 3.0.0 + */ + boot: function () + { + this.canvas = this.game.canvas; + + this.updateBounds(); + + this.events.emit('boot'); + + this.game.events.on('prestep', this.update, this); + this.game.events.on('poststep', this.postUpdate, this); + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * Updates the Input Manager bounds rectangle to match the bounding client rectangle of the + * canvas element being used to track input events. + * + * @method Phaser.Input.InputManager#updateBounds + * @since 3.0.0 + */ + updateBounds: function () + { + var bounds = this.bounds; + + var clientRect = this.canvas.getBoundingClientRect(); + + bounds.x = clientRect.left + window.pageXOffset - document.documentElement.clientLeft; + bounds.y = clientRect.top + window.pageYOffset - document.documentElement.clientTop; + bounds.width = clientRect.width; + bounds.height = clientRect.height; + }, + + /** + * Resizes the Input Manager internal values, including the bounds and scale factor. + * + * @method Phaser.Input.InputManager#resize + * @since 3.2.0 + */ + resize: function () + { + this.updateBounds(); + + // Game config size + var gw = this.game.config.width; + var gh = this.game.config.height; + + // Actual canvas size + var bw = this.bounds.width; + var bh = this.bounds.height; + + // Scale factor + this.scale.x = gw / bw; + this.scale.y = gh / bh; + }, + + /** + * Internal update loop, called automatically by the Game Step. + * + * @method Phaser.Input.InputManager#update + * @private + * @since 3.0.0 + * + * @param {number} time - The time stamp value of this game step. + */ + update: function (time) + { + var i; + + this._setCursor = 0; + + this.events.emit('update'); + + this.ignoreEvents = false; + + this.dirty = false; + + var len = this.queue.length; + + var pointers = this.pointers; + + for (i = 0; i < this.pointersTotal; i++) + { + pointers[i].reset(); + } + + if (!this.enabled || len === 0) + { + return; + } + + this.dirty = true; + + this.updateBounds(); + + this.scale.x = this.game.config.width / this.bounds.width; + this.scale.y = this.game.config.height / this.bounds.height; + + // Clears the queue array, and also means we don't work on array data that could potentially + // be modified during the processing phase + var queue = this.queue.splice(0, len); + var mouse = this.mousePointer; + + // Process the event queue, dispatching all of the events that have stored up + for (i = 0; i < len; i += 2) + { + var type = queue[i]; + var event = queue[i + 1]; + + switch (type) + { + case CONST.MOUSE_DOWN: + mouse.down(event, time); + break; + + case CONST.MOUSE_MOVE: + mouse.move(event, time); + break; + + case CONST.MOUSE_UP: + mouse.up(event, time); + break; + + case CONST.TOUCH_START: + this.startPointer(event, time); + break; + + case CONST.TOUCH_MOVE: + this.updatePointer(event, time); + break; + + case CONST.TOUCH_END: + this.stopPointer(event, time); + break; + + case CONST.TOUCH_CANCEL: + this.cancelPointer(event, time); + break; + + case CONST.POINTER_LOCK_CHANGE: + this.events.emit('pointerlockchange', event, this.mouse.locked); + break; + } + } + }, + + /** + * Internal post-update, called automatically by the Game step. + * + * @method Phaser.Input.InputManager#postUpdate + * @private + * @since 3.10.0 + */ + postUpdate: function () + { + if (this._setCursor === 1) + { + this.canvas.style.cursor = this._customCursor; + } + else if (this._setCursor === 2) + { + this.canvas.style.cursor = this.defaultCursor; + } + }, + + /** + * Tells the Input system to set a custom cursor. + * + * This cursor will be the default cursor used when interacting with the game canvas. + * + * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * + * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * + * ```javascript + * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); + * ``` + * + * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * + * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. + * + * @method Phaser.Input.InputManager#setDefaultCursor + * @since 3.10.0 + * + * @param {string} cursor - The CSS to be used when setting the default cursor. + */ + setDefaultCursor: function (cursor) + { + this.defaultCursor = cursor; + + if (this.canvas.style.cursor !== cursor) + { + this.canvas.style.cursor = cursor; + } + }, + + /** + * Called by the InputPlugin when processing over and out events. + * + * Tells the Input Manager to set a custom cursor during its postUpdate step. + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * + * @method Phaser.Input.InputManager#setCursor + * @private + * @since 3.10.0 + * + * @param {Phaser.Input.InteractiveObject} interactiveObject - The Interactive Object that called this method. + */ + setCursor: function (interactiveObject) + { + if (interactiveObject.cursor) + { + this._setCursor = 1; + this._customCursor = interactiveObject.cursor; + } + }, + + /** + * Called by the InputPlugin when processing over and out events. + * + * Tells the Input Manager to clear the hand cursor, if set, during its postUpdate step. + * + * @method Phaser.Input.InputManager#resetCursor + * @private + * @since 3.10.0 + * + * @param {Phaser.Input.InteractiveObject} interactiveObject - The Interactive Object that called this method. + */ + resetCursor: function (interactiveObject) + { + if (interactiveObject.cursor) + { + this._setCursor = 2; + } + }, + + // event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element) + // event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element + // event.changedTouches = the touches that CHANGED in this event, not the total number of them + + /** + * Called by the main update loop when a Touch Start Event is received. + * + * @method Phaser.Input.InputManager#startPointer + * @private + * @since 3.10.0 + * + * @param {TouchEvent} event - The native DOM event to be processed. + * @param {number} time - The time stamp value of this game step. + */ + startPointer: function (event, time) + { + var pointers = this.pointers; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < this.pointersTotal; i++) + { + var pointer = pointers[i]; + + if (!pointer.active) + { + pointer.touchstart(changedTouch, time); + this.activePointer = pointer; + break; + } + } + } + }, + + /** + * Called by the main update loop when a Touch Move Event is received. + * + * @method Phaser.Input.InputManager#updatePointer + * @private + * @since 3.10.0 + * + * @param {TouchEvent} event - The native DOM event to be processed. + * @param {number} time - The time stamp value of this game step. + */ + updatePointer: function (event, time) + { + var pointers = this.pointers; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < this.pointersTotal; i++) + { + var pointer = pointers[i]; + + if (pointer.active && pointer.identifier === changedTouch.identifier) + { + pointer.touchmove(changedTouch, time); + this.activePointer = pointer; + break; + } + } + } + }, + + // For touch end its a list of the touch points that have been removed from the surface + // https://developer.mozilla.org/en-US/docs/DOM/TouchList + // event.changedTouches = the touches that CHANGED in this event, not the total number of them + + /** + * Called by the main update loop when a Touch End Event is received. + * + * @method Phaser.Input.InputManager#stopPointer + * @private + * @since 3.10.0 + * + * @param {TouchEvent} event - The native DOM event to be processed. + * @param {number} time - The time stamp value of this game step. + */ + stopPointer: function (event, time) + { + var pointers = this.pointers; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < this.pointersTotal; i++) + { + var pointer = pointers[i]; + + if (pointer.active && pointer.identifier === changedTouch.identifier) + { + pointer.touchend(changedTouch, time); + break; + } + } + } + }, + + /** + * Called by the main update loop when a Touch Cancel Event is received. + * + * @method Phaser.Input.InputManager#cancelPointer + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The native DOM event to be processed. + * @param {number} time - The time stamp value of this game step. + */ + cancelPointer: function (event, time) + { + var pointers = this.pointers; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < this.pointersTotal; i++) + { + var pointer = pointers[i]; + + if (pointer.active && pointer.identifier === changedTouch.identifier) + { + pointer.touchend(changedTouch, time); + break; + } + } + } + }, + + /** + * Adds new Pointer objects to the Input Manager. + * + * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * + * You can create more either by calling this method, or by setting the `input.activePointers` property + * in the Game Config, up to a maximum of 10 pointers. + * + * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added + * via this method. + * + * @method Phaser.Input.InputManager#addPointer + * @since 3.10.0 + * + * @param {integer} [quantity=1] The number of new Pointers to create. A maximum of 10 is allowed in total. + * + * @return {Phaser.Input.Pointer[]} An array containing all of the new Pointer objects that were created. + */ + addPointer: function (quantity) + { + if (quantity === undefined) { quantity = 1; } + + var output = []; + + if (this.pointersTotal + quantity > 10) + { + quantity = 10 - this.pointersTotal; + } + + for (var i = 0; i < quantity; i++) + { + var id = this.pointers.length; + + var pointer = new Pointer(this, id); + + this.pointers.push(pointer); + + this.pointersTotal++; + + output.push(pointer); + } + + return output; + }, + + /** + * Process any pending DOM callbacks. + * + * @method Phaser.Input.InputManager#processDomCallbacks + * @private + * @since 3.10.0 + * + * @param {array} once - The isOnce callbacks to invoke. + * @param {array} every - The every frame callbacks to invoke. + * @param {any} event - The native DOM event that is passed to the callbacks. + * + * @return {boolean} `true` if there are callbacks still in the list, otherwise `false`. + */ + processDomCallbacks: function (once, every, event) + { + var i = 0; + + for (i = 0; i < once.length; i++) + { + once[i](event); + } + + for (i = 0; i < every.length; i++) + { + every[i](event); + } + + once = []; + + return (every.length > 0); + }, + + /** + * Queues a touch start event, as passed in by the TouchManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueTouchStart + * @private + * @since 3.10.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + queueTouchStart: function (event) + { + this.queue.push(CONST.TOUCH_START, event); + + if (this._hasDownCallback) + { + var callbacks = this.domCallbacks; + + this._hasDownCallback = this.processDomCallbacks(callbacks.downOnce, callbacks.down, event); + } + }, + + /** + * Queues a touch move event, as passed in by the TouchManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueTouchMove + * @private + * @since 3.10.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + queueTouchMove: function (event) + { + this.queue.push(CONST.TOUCH_MOVE, event); + + if (this._hasMoveCallback) + { + var callbacks = this.domCallbacks; + + this._hasMoveCallback = this.processDomCallbacks(callbacks.moveOnce, callbacks.move, event); + } + }, + + /** + * Queues a touch end event, as passed in by the TouchManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueTouchEnd + * @private + * @since 3.10.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + queueTouchEnd: function (event) + { + this.queue.push(CONST.TOUCH_END, event); + + if (this._hasUpCallback) + { + var callbacks = this.domCallbacks; + + this._hasUpCallback = this.processDomCallbacks(callbacks.upOnce, callbacks.up, event); + } + }, + + /** + * Queues a touch cancel event, as passed in by the TouchManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueTouchCancel + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + queueTouchCancel: function (event) + { + this.queue.push(CONST.TOUCH_CANCEL, event); + }, + + /** + * Queues a mouse down event, as passed in by the MouseManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueMouseDown + * @private + * @since 3.10.0 + * + * @param {MouseEvent} event - The native DOM Mouse event. + */ + queueMouseDown: function (event) + { + this.queue.push(CONST.MOUSE_DOWN, event); + + if (this._hasDownCallback) + { + var callbacks = this.domCallbacks; + + this._hasDownCallback = this.processDomCallbacks(callbacks.downOnce, callbacks.down, event); + } + }, + + /** + * Queues a mouse move event, as passed in by the MouseManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueMouseMove + * @private + * @since 3.10.0 + * + * @param {MouseEvent} event - The native DOM Mouse event. + */ + queueMouseMove: function (event) + { + this.queue.push(CONST.MOUSE_MOVE, event); + + if (this._hasMoveCallback) + { + var callbacks = this.domCallbacks; + + this._hasMoveCallback = this.processDomCallbacks(callbacks.moveOnce, callbacks.move, event); + } + }, + + /** + * Queues a mouse up event, as passed in by the MouseManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueMouseUp + * @private + * @since 3.10.0 + * + * @param {MouseEvent} event - The native DOM Mouse event. + */ + queueMouseUp: function (event) + { + this.queue.push(CONST.MOUSE_UP, event); + + if (this._hasUpCallback) + { + var callbacks = this.domCallbacks; + + this._hasUpCallback = this.processDomCallbacks(callbacks.upOnce, callbacks.up, event); + } + }, + + /** + * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is released, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * + * @method Phaser.Input.InputManager#addUpCallback + * @since 3.10.0 + * + * @param {function} callback - The callback to be invoked on this dom event. + * @param {boolean} [isOnce=true] - `true` if the callback will only be invoked once, `false` to call every time this event happens. + * + * @return {this} The Input Manager. + */ + addUpCallback: function (callback, isOnce) + { + if (isOnce === undefined) { isOnce = true; } + + if (isOnce) + { + this.domCallbacks.upOnce.push(callback); + } + else + { + this.domCallbacks.up.push(callback); + } + + this._hasUpCallback = true; + + return this; + }, + + /** + * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is down, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * + * @method Phaser.Input.InputManager#addDownCallback + * @since 3.10.0 + * + * @param {function} callback - The callback to be invoked on this dom event. + * @param {boolean} [isOnce=true] - `true` if the callback will only be invoked once, `false` to call every time this event happens. + * + * @return {this} The Input Manager. + */ + addDownCallback: function (callback, isOnce) + { + if (isOnce === undefined) { isOnce = true; } + + if (isOnce) + { + this.domCallbacks.downOnce.push(callback); + } + else + { + this.domCallbacks.down.push(callback); + } + + this._hasDownCallback = true; + + return this; + }, + + /** + * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is moved, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * + * @method Phaser.Input.InputManager#addMoveCallback + * @since 3.10.0 + * + * @param {function} callback - The callback to be invoked on this dom event. + * @param {boolean} [isOnce=false] - `true` if the callback will only be invoked once, `false` to call every time this event happens. + * + * @return {this} The Input Manager. + */ + addMoveCallback: function (callback, isOnce) + { + if (isOnce === undefined) { isOnce = false; } + + if (isOnce) + { + this.domCallbacks.moveOnce.push(callback); + } + else + { + this.domCallbacks.move.push(callback); + } + + this._hasMoveCallback = true; + + return this; + }, + + /** + * Checks if the given Game Object should be considered as a candidate for input or not. + * + * Checks if the Game Object has an input component that is enabled, that it will render, + * and finally, if it has a parent, that the parent parent, or any ancestor, is visible or not. + * + * @method Phaser.Input.InputManager#inputCandidate + * @private + * @since 3.10.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to test. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against. + * + * @return {boolean} `true` if the Game Object should be considered for input, otherwise `false`. + */ + inputCandidate: function (gameObject, camera) + { + var input = gameObject.input; + + if (!input || !input.enabled || !gameObject.willRender(camera)) + { + return false; + } + + var visible = true; + var parent = gameObject.parentContainer; + + if (parent) + { + do + { + if (!parent.willRender(camera)) + { + visible = false; + break; + } + + parent = parent.parentContainer; + + } while (parent); + } + + return visible; + }, + + /** + * Performs a hit test using the given Pointer and camera, against an array of interactive Game Objects. + * + * The Game Objects are culled against the camera, and then the coordinates are translated into the local camera space + * and used to determine if they fall within the remaining Game Objects hit areas or not. + * + * If nothing is matched an empty array is returned. + * + * This method is called automatically by InputPlugin.hitTestPointer and doesn't usually need to be invoked directly. + * + * @method Phaser.Input.InputManager#hitTest + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to test against. + * @param {array} gameObjects - An array of interactive Game Objects to check. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against. + * @param {array} [output] - An array to store the results in. If not given, a new empty array is created. + * + * @return {array} An array of the Game Objects that were hit during this hit test. + */ + hitTest: function (pointer, gameObjects, camera, output) + { + if (output === undefined) { output = this._tempHitTest; } + + var tempPoint = this._tempPoint; + + var csx = camera.scrollX; + var csy = camera.scrollY; + + output.length = 0; + + var x = pointer.x; + var y = pointer.y; + + if (camera.resolution !== 1) + { + x += camera._x; + y += camera._y; + } + + // Stores the world point inside of tempPoint + camera.getWorldPoint(x, y, tempPoint); + + pointer.worldX = tempPoint.x; + pointer.worldY = tempPoint.y; + + var point = { x: 0, y: 0 }; + + var matrix = this._tempMatrix; + var parentMatrix = this._tempMatrix2; + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + // Checks if the Game Object can receive input (isn't being ignored by the camera, invisible, etc) + // and also checks all of its parents, if any + if (!this.inputCandidate(gameObject, camera)) + { + continue; + } + + var px = tempPoint.x + (csx * gameObject.scrollFactorX) - csx; + var py = tempPoint.y + (csy * gameObject.scrollFactorY) - csy; + + if (gameObject.parentContainer) + { + gameObject.getWorldTransformMatrix(matrix, parentMatrix); + + matrix.applyInverse(px, py, point); + } + else + { + TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); + } + + if (this.pointWithinHitArea(gameObject, point.x, point.y)) + { + output.push(gameObject); + } + } + + return output; + }, + + /** + * Checks if the given x and y coordinate are within the hit area of the Game Object. + * + * This method assumes that the coordinate values have already been translated into the space of the Game Object. + * + * If the coordinates are within the hit area they are set into the Game Objects Input `localX` and `localY` properties. + * + * @method Phaser.Input.InputManager#pointWithinHitArea + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The interactive Game Object to check against. + * @param {number} x - The translated x coordinate for the hit test. + * @param {number} y - The translated y coordinate for the hit test. + * + * @return {boolean} `true` if the coordinates were inside the Game Objects hit area, otherwise `false`. + */ + pointWithinHitArea: function (gameObject, x, y) + { + // Normalize the origin + x += gameObject.displayOriginX; + y += gameObject.displayOriginY; + + var input = gameObject.input; + + if (input && input.hitAreaCallback(input.hitArea, x, y, gameObject)) + { + input.localX = x; + input.localY = y; + + return true; + } + else + { + return false; + } + }, + + /** + * Checks if the given x and y coordinate are within the hit area of the Interactive Object. + * + * This method assumes that the coordinate values have already been translated into the space of the Interactive Object. + * + * If the coordinates are within the hit area they are set into the Interactive Objects Input `localX` and `localY` properties. + * + * @method Phaser.Input.InputManager#pointWithinInteractiveObject + * @since 3.0.0 + * + * @param {Phaser.Input.InteractiveObject} object - The Interactive Object to check against. + * @param {number} x - The translated x coordinate for the hit test. + * @param {number} y - The translated y coordinate for the hit test. + * + * @return {boolean} `true` if the coordinates were inside the Game Objects hit area, otherwise `false`. + */ + pointWithinInteractiveObject: function (object, x, y) + { + if (!object.hitArea) + { + return false; + } + + // Normalize the origin + x += object.gameObject.displayOriginX; + y += object.gameObject.displayOriginY; + + object.localX = x; + object.localY = y; + + return object.hitAreaCallback(object.hitArea, x, y, object); + }, + + /** + * Transforms the pageX and pageY values of a Pointer into the scaled coordinate space of the Input Manager. + * + * @method Phaser.Input.InputManager#transformPointer + * @since 3.10.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to transform the values for. + * @param {number} pageX - The Page X value. + * @param {number} pageY - The Page Y value. + */ + transformPointer: function (pointer, pageX, pageY) + { + // Store the previous position + pointer.prevPosition.x = pointer.x; + pointer.prevPosition.y = pointer.y; + + pointer.x = (pageX - this.bounds.left) * this.scale.x; + pointer.y = (pageY - this.bounds.top) * this.scale.y; + }, + + /** + * Transforms the pageX value into the scaled coordinate space of the Input Manager. + * + * @method Phaser.Input.InputManager#transformX + * @since 3.0.0 + * + * @param {number} pageX - The DOM pageX value. + * + * @return {number} The translated value. + */ + transformX: function (pageX) + { + return (pageX - this.bounds.left) * this.scale.x; + }, + + /** + * Transforms the pageY value into the scaled coordinate space of the Input Manager. + * + * @method Phaser.Input.InputManager#transformY + * @since 3.0.0 + * + * @param {number} pageY - The DOM pageY value. + * + * @return {number} The translated value. + */ + transformY: function (pageY) + { + return (pageY - this.bounds.top) * this.scale.y; + }, + + /** + * Returns the left offset of the Input bounds. + * + * @method Phaser.Input.InputManager#getOffsetX + * @since 3.0.0 + * + * @return {number} The left bounds value. + */ + getOffsetX: function () + { + return this.bounds.left; + }, + + /** + * Returns the top offset of the Input bounds. + * + * @method Phaser.Input.InputManager#getOffsetY + * @since 3.0.0 + * + * @return {number} The top bounds value. + */ + getOffsetY: function () + { + return this.bounds.top; + }, + + /** + * Returns the horizontal Input Scale value. + * + * @method Phaser.Input.InputManager#getScaleX + * @since 3.0.0 + * + * @return {number} The horizontal scale factor of the input. + */ + getScaleX: function () + { + return this.game.config.width / this.bounds.width; + }, + + /** + * Returns the vertical Input Scale value. + * + * @method Phaser.Input.InputManager#getScaleY + * @since 3.0.0 + * + * @return {number} The vertical scale factor of the input. + */ + getScaleY: function () + { + return this.game.config.height / this.bounds.height; + }, + + /** + * Destroys the Input Manager and all of its systems. + * + * There is no way to recover from doing this. + * + * @method Phaser.Input.InputManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.events.removeAllListeners(); + + if (this.mouse) + { + this.mouse.destroy(); + } + + if (this.touch) + { + this.touch.destroy(); + } + + for (var i = 0; i < this.pointers.length; i++) + { + this.pointers[i].destroy(); + } + + this.domCallbacks = {}; + this.pointers = []; + this.queue = []; + this._tempHitTest = []; + this._tempMatrix.destroy(); + this.canvas = null; + this.game = null; + } + +}); + +module.exports = InputManager; + + +/***/ }), +/* 368 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(967); +var TextureTintPipeline = __webpack_require__(183); + +var LIGHT_COUNT = 10; + +/** + * @classdesc + * ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights. + * This pipeline extends TextureTintPipeline so it implements all it's rendering functions + * and batching system. + * + * @class ForwardDiffuseLightPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline + * @memberof Phaser.Renderer.WebGL.Pipelines + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var ForwardDiffuseLightPipeline = new Class({ + + Extends: TextureTintPipeline, + + initialize: + + function ForwardDiffuseLightPipeline (config) + { + LIGHT_COUNT = config.maxLights; + + config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); + + TextureTintPipeline.call(this, config); + + /** + * Default normal map texture to use. + * + * @name Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#defaultNormalMap + * @type {Phaser.Texture.Frame} + * @private + * @since 3.11.0 + */ + this.defaultNormalMap; + }, + + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#boot + * @override + * @since 3.11.0 + */ + boot: function () + { + this.defaultNormalMap = this.game.textures.getFrame('__DEFAULT'); + }, + + /** + * This function binds its base class resources and this lights 2D resources. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onBind + * @override + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any. + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function (gameObject) + { + TextureTintPipeline.prototype.onBind.call(this); + + var renderer = this.renderer; + var program = this.program; + + this.mvpUpdate(); + + renderer.setInt1(program, 'uNormSampler', 1); + renderer.setFloat2(program, 'uResolution', this.width, this.height); + + if (gameObject) + { + this.setNormalMap(gameObject); + } + + return this; + }, + + /** + * This function sets all the needed resources for each camera pass. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onRender + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {this} This WebGLPipeline instance. + */ + onRender: function (scene, camera) + { + this.active = false; + + var lightManager = scene.sys.lights; + + if (!lightManager || lightManager.lights.length <= 0 || !lightManager.active) + { + // Passthru + return this; + } + + var lights = lightManager.cull(camera); + var lightCount = Math.min(lights.length, LIGHT_COUNT); + + if (lightCount === 0) + { + return this; + } + + this.active = true; + + var renderer = this.renderer; + var program = this.program; + var cameraMatrix = camera.matrix; + var point = {x: 0, y: 0}; + var height = renderer.height; + var index; + + for (index = 0; index < LIGHT_COUNT; ++index) + { + // Reset lights + renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); + } + + renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); + renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); + + for (index = 0; index < lightCount; ++index) + { + var light = lights[index]; + var lightName = 'uLights[' + index + '].'; + + cameraMatrix.transformPoint(light.x, light.y, point); + + renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); + renderer.setFloat1(program, lightName + 'intensity', light.intensity); + renderer.setFloat1(program, lightName + 'radius', light.radius); + } + + return this; + }, + + /** + * Generic function for batching a textured quad + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject + * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad + * @param {integer} textureWidth - Real texture width + * @param {integer} textureHeight - Real texture height + * @param {number} srcX - X coordinate of the quad + * @param {number} srcY - Y coordinate of the quad + * @param {number} srcWidth - Width of the quad + * @param {number} srcHeight - Height of the quad + * @param {number} scaleX - X component of scale + * @param {number} scaleY - Y component of scale + * @param {number} rotation - Rotation of the quad + * @param {boolean} flipX - Indicates if the quad is horizontally flipped + * @param {boolean} flipY - Indicates if the quad is vertically flipped + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll + * @param {number} displayOriginX - Horizontal origin in pixels + * @param {number} displayOriginY - Vertical origin in pixels + * @param {number} frameX - X coordinate of the texture frame + * @param {number} frameY - Y coordinate of the texture frame + * @param {number} frameWidth - Width of the texture frame + * @param {number} frameHeight - Height of the texture frame + * @param {integer} tintTL - Tint for top left + * @param {integer} tintTR - Tint for top right + * @param {integer} tintBL - Tint for bottom left + * @param {integer} tintBR - Tint for bottom right + * @param {number} tintEffect - The tint effect (0 for additive, 1 for replacement) + * @param {number} uOffset - Horizontal offset on texture coordinate + * @param {number} vOffset - Vertical offset on texture coordinate + * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container + */ + batchTexture: function ( + gameObject, + texture, + textureWidth, textureHeight, + srcX, srcY, + srcWidth, srcHeight, + scaleX, scaleY, + rotation, + flipX, flipY, + scrollFactorX, scrollFactorY, + displayOriginX, displayOriginY, + frameX, frameY, frameWidth, frameHeight, + tintTL, tintTR, tintBL, tintBR, tintEffect, + uOffset, vOffset, + camera, + parentTransformMatrix) + { + if (!this.active) + { + return; + } + + this.renderer.setPipeline(this); + + var normalTexture; + + if (gameObject.displayTexture) + { + normalTexture = gameObject.displayTexture.dataSource[gameObject.displayFrame.sourceIndex]; + } + else if (gameObject.texture) + { + normalTexture = gameObject.texture.dataSource[gameObject.frame.sourceIndex]; + } + else if (gameObject.tileset) + { + normalTexture = gameObject.tileset.image.dataSource[0]; + } + + if (!normalTexture) + { + console.warn('Normal map missing or invalid'); + return; + } + + this.setTexture2D(normalTexture.glTexture, 1); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var u0 = (frameX / textureWidth) + uOffset; + var v0 = (frameY / textureHeight) + vOffset; + var u1 = (frameX + frameWidth) / textureWidth + uOffset; + var v1 = (frameY + frameHeight) / textureHeight + vOffset; + + var width = srcWidth; + var height = srcHeight; + + // var x = -displayOriginX + frameX; + // var y = -displayOriginY + frameY; + + var x = -displayOriginX; + var y = -displayOriginY; + + if (gameObject.isCropped) + { + var crop = gameObject._crop; + + width = crop.width; + height = crop.height; + + srcWidth = crop.width; + srcHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + var ox = frameX; + var oy = frameY; + + if (flipX) + { + ox = (frameWidth - crop.x - crop.width); + } + + if (flipY && !texture.isRenderTexture) + { + oy = (frameHeight - crop.y - crop.height); + } + + u0 = (ox / textureWidth) + uOffset; + v0 = (oy / textureHeight) + vOffset; + u1 = (ox + crop.width) / textureWidth + uOffset; + v1 = (oy + crop.height) / textureHeight + vOffset; + + x = -displayOriginX + frameX; + y = -displayOriginY + frameY; + } + + // Invert the flipY if this is a RenderTexture + flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); + + if (flipX) + { + width *= -1; + x += srcWidth; + } + + if (flipY) + { + height *= -1; + y += srcHeight; + } + + // Do we need this? (doubt it) + // if (camera.roundPixels) + // { + // x |= 0; + // y |= 0; + // } + + var xw = x + width; + var yh = y + height; + + spriteMatrix.applyITRS(srcX, srcY, rotation, scaleX, scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * scrollFactorX, -camera.scrollY * scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = srcX; + spriteMatrix.f = srcY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * scrollFactorX; + spriteMatrix.f -= camera.scrollY * scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + this.setTexture2D(texture, 0); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + }, + + /** + * Sets the Game Objects normal map as the active texture. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#setNormalMap + * @since 3.11.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ + setNormalMap: function (gameObject) + { + if (!this.active || !gameObject) + { + return; + } + + var normalTexture; + + if (gameObject.texture) + { + normalTexture = gameObject.texture.dataSource[gameObject.frame.sourceIndex]; + } + + if (!normalTexture) + { + normalTexture = this.defaultNormalMap; + } + + this.setTexture2D(normalTexture.glTexture, 1); + + this.renderer.setPipeline(gameObject.defaultPipeline); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] + * + */ + batchSprite: function (sprite, camera, parentTransformMatrix) + { + if (!this.active) + { + return; + } + + var normalTexture = sprite.texture.dataSource[sprite.frame.sourceIndex]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + + this.setTexture2D(normalTexture.glTexture, 1); + + TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera, parentTransformMatrix); + } + } + +}); + +ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; + +module.exports = ForwardDiffuseLightPipeline; + + +/***/ }), +/* 369 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(969); +var ShaderSourceVS = __webpack_require__(968); +var WebGLPipeline = __webpack_require__(184); + +/** + * @classdesc + * BitmapMaskPipeline handles all bitmap masking rendering in WebGL. It works by using + * sampling two texture on the fragment shader and using the fragment's alpha to clip the region. + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + * + * @class BitmapMaskPipeline + * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @memberof Phaser.Renderer.WebGL.Pipelines + * @constructor + * @since 3.0.0 + * + * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. + */ +var BitmapMaskPipeline = new Class({ + + Extends: WebGLPipeline, + + initialize: + + function BitmapMaskPipeline (config) + { + WebGLPipeline.call(this, { + game: config.game, + renderer: config.renderer, + gl: config.renderer.gl, + topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), + vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), + fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), + vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), + + vertexSize: (config.vertexSize ? config.vertexSize : + Float32Array.BYTES_PER_ELEMENT * 2), + + vertices: new Float32Array([ + -1, +1, -1, -7, +7, +1 + ]).buffer, + + attributes: [ + { + name: 'inPosition', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: 0 + } + ] + }); + + /** + * Float32 view of the array buffer containing the pipeline's vertices. + * + * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#vertexViewF32 + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertexViewF32 = new Float32Array(this.vertexData); + + /** + * Size of the batch. + * + * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#maxQuads + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.maxQuads = 1; + + /** + * Dirty flag to check if resolution properties need to be updated on the + * masking shader. + * + * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resolutionDirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.resolutionDirty = true; + }, + + /** + * Called every time the pipeline needs to be used. + * It binds all necessary resources. + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#onBind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function () + { + WebGLPipeline.prototype.onBind.call(this); + + var renderer = this.renderer; + var program = this.program; + + if (this.resolutionDirty) + { + renderer.setFloat2(program, 'uResolution', this.width, this.height); + renderer.setInt1(program, 'uMainSampler', 0); + renderer.setInt1(program, 'uMaskSampler', 1); + this.resolutionDirty = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} resolution - [description] + * + * @return {this} This WebGLPipeline instance. + */ + resize: function (width, height, resolution) + { + WebGLPipeline.prototype.resize.call(this, width, height, resolution); + this.resolutionDirty = true; + return this; + }, + + /** + * Binds necessary resources and renders the mask to a separated framebuffer. + * The framebuffer for the masked object is also bound for further use. + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#beginMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - GameObject used as mask. + * @param {Phaser.GameObjects.GameObject} maskedObject - GameObject masked by the mask GameObject. + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + beginMask: function (mask, maskedObject, camera) + { + var renderer = this.renderer; + var gl = this.gl; + + // The renderable Game Object that is being used for the bitmap mask + var bitmapMask = mask.bitmapMask; + + if (bitmapMask && gl) + { + renderer.flush(); + + // First we clear the mask framebuffer + renderer.setFramebuffer(mask.maskFramebuffer); + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // We render our mask source + bitmapMask.renderWebGL(renderer, bitmapMask, 0, camera); + renderer.flush(); + + // Bind and clear our main source (masked object) + renderer.setFramebuffer(mask.mainFramebuffer); + + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + } + }, + + /** + * The masked game object's framebuffer is unbound and it's texture + * is bound together with the mask texture and the mask shader and + * a draw call with a single quad is processed. Here is where the + * masking effect is applied. + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#endMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - GameObject used as a mask. + */ + endMask: function (mask) + { + var renderer = this.renderer; + var gl = this.gl; + + // The renderable Game Object that is being used for the bitmap mask + var bitmapMask = mask.bitmapMask; + + if (bitmapMask && gl) + { + // Return to default framebuffer + renderer.setFramebuffer(null); + + // Bind bitmap mask pipeline and draw + renderer.setPipeline(this); + + renderer.setTexture2D(mask.maskTexture, 1); + renderer.setTexture2D(mask.mainTexture, 0); + renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); + + // Finally draw a triangle filling the whole screen + gl.drawArrays(this.topology, 0, 3); + } + } + +}); + +module.exports = BitmapMaskPipeline; + + +/***/ }), +/* 370 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes a snapshot of the current frame displayed by a WebGL canvas. + * + * @function Phaser.Renderer.Snapshot.WebGL + * @since 3.0.0 + * + * @param {HTMLCanvasElement} sourceCanvas - The canvas to take a snapshot of. + * @param {string} [type='image/png'] - The format of the returned image. + * @param {number} [encoderOptions=0.92] - The image quality, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). + * + * @return {HTMLImageElement} A new image which contains a snapshot of the canvas's contents. + */ +var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) +{ + if (!type) { type = 'image/png'; } + if (!encoderOptions) { encoderOptions = 0.92; } + + var gl = sourceCanvas.getContext('experimental-webgl'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); + + // CanvasPool? + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + var imageData; + + canvas.width = gl.drawingBufferWidth; + canvas.height = gl.drawingBufferHeight; + + imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + + var data = imageData.data; + + for (var y = 0; y < canvas.height; y += 1) + { + for (var x = 0; x < canvas.width; x += 1) + { + var si = ((canvas.height - y) * canvas.width + x) * 4; + var di = (y * canvas.width + x) * 4; + data[di + 0] = pixels[si + 0]; + data[di + 1] = pixels[si + 1]; + data[di + 2] = pixels[si + 2]; + data[di + 3] = pixels[si + 3]; + } + } + + ctx.putImageData(imageData, 0, 0); + + var src = canvas.toDataURL(type, encoderOptions); + var image = new Image(); + + image.src = src; + + return image; +}; + +module.exports = WebGLSnapshot; + + +/***/ }), +/* 371 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCamera = __webpack_require__(131); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(28); +var IsSizePowerOfTwo = __webpack_require__(127); +var SpliceOne = __webpack_require__(100); +var TransformMatrix = __webpack_require__(42); +var Utils = __webpack_require__(9); +var WebGLSnapshot = __webpack_require__(370); + +// Default Pipelines +var BitmapMaskPipeline = __webpack_require__(369); +var ForwardDiffuseLightPipeline = __webpack_require__(368); +var TextureTintPipeline = __webpack_require__(183); + +/** + * @callback WebGLContextCallback + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer which owns the context. + */ + +/** + * @typedef {object} SnapshotState + * + * @property {SnapshotCallback} callback - The function to call after the snapshot is taken. + * @property {string} type - The type of the image to create. + * @property {number} encoder - The image quality, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). + */ + +/** + * @classdesc + * WebGLRenderer is a class that contains the needed functionality to keep the + * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of + * any context change that happens for WebGL rendering inside of Phaser. This means + * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL + * rendering ecosystem they might pollute the current WebGLRenderingContext state producing + * unexpected behavior. It's recommended that WebGL interaction is done through + * WebGLRenderer and/or WebGLPipeline. + * + * @class WebGLRenderer + * @memberof Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Game instance which owns this WebGL Renderer. + */ +var WebGLRenderer = new Class({ + + initialize: + + function WebGLRenderer (game) + { + // eslint-disable-next-line consistent-this + var renderer = this; + + var gameConfig = game.config; + + var contextCreationConfig = { + alpha: gameConfig.transparent, + depth: false, // enable when 3D is added in the future + antialias: gameConfig.antialias, + premultipliedAlpha: gameConfig.premultipliedAlpha, + stencil: true, + preserveDrawingBuffer: gameConfig.preserveDrawingBuffer, + failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat, + powerPreference: gameConfig.powerPreference + }; + + /** + * The local configuration settings of this WebGL Renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: gameConfig.clearBeforeRender, + antialias: gameConfig.antialias, + backgroundColor: gameConfig.backgroundColor, + contextCreation: contextCreationConfig, + resolution: gameConfig.resolution, + autoResize: gameConfig.autoResize, + roundPixels: gameConfig.roundPixels, + maxTextures: gameConfig.maxTextures, + maxTextureSize: gameConfig.maxTextureSize, + batchSize: gameConfig.batchSize, + maxLights: gameConfig.maxLights + }; + + /** + * The Game instance which owns this WebGL Renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * A constant which allows the renderer to be easily identified as a WebGL Renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.WEBGL; + + /** + * The width of the canvas being rendered to. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#width + * @type {integer} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * The height of the canvas being rendered to. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#height + * @type {integer} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * The canvas which this WebGL Renderer draws to. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = game.canvas; + + /** + * An array of functions to invoke if the WebGL context is lost. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.lostContextCallbacks = []; + + /** + * An array of functions to invoke if the WebGL context is restored. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.restoredContextCallbacks = []; + + /** + * An array of blend modes supported by the WebGL Renderer. + * + * This array includes the default blend modes as well as any custom blend modes added through {@link #addBlendMode}. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.blendModes = []; + + /** + * Keeps track of any WebGLTexture created with the current WebGLRenderingContext + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.nativeTextures = []; + + /** + * Set to `true` if the WebGL context of the renderer is lost. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.contextLost = false; + + /** + * This object will store all pipelines created through addPipeline + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines + * @type {object} + * @default null + * @since 3.0.0 + */ + this.pipelines = null; + + /** + * Details about the currently scheduled snapshot. + * + * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState + * @type {SnapshotState} + * @since 3.0.0 + */ + this.snapshotState = { + callback: null, + type: null, + encoder: null + }; + + // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) + + /** + * Cached value for the last texture unit that was used + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit + * @type {integer} + * @since 3.1.0 + */ + this.currentActiveTextureUnit = 0; + + /** + * An array of the last texture handles that were bound to the WebGLRenderingContext + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures + * @type {array} + * @since 3.0.0 + */ + this.currentTextures = new Array(16); + + /** + * Current framebuffer in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer + * @type {WebGLFramebuffer} + * @default null + * @since 3.0.0 + */ + this.currentFramebuffer = null; + + /** + * Current WebGLPipeline in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @since 3.0.0 + */ + this.currentPipeline = null; + + /** + * Current WebGLProgram in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram + * @type {WebGLProgram} + * @default null + * @since 3.0.0 + */ + this.currentProgram = null; + + /** + * Current WebGLBuffer (Vertex buffer) in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentVertexBuffer = null; + + /** + * Current WebGLBuffer (Index buffer) in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentIndexBuffer = null; + + /** + * Current blend mode in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode + * @type {integer} + * @since 3.0.0 + */ + this.currentBlendMode = Infinity; + + /** + * Indicates if the the scissor state is enabled in WebGLRenderingContext + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.currentScissorEnabled = false; + + /** + * Stores the current scissor data + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor + * @type {Uint32Array} + * @since 3.0.0 + */ + // this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); + this.currentScissor = null; + + /** + * Stack of scissor data + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack + * @type {Uint32Array} + * @since 3.0.0 + */ + this.scissorStack = []; + + // Setup context lost and restore event listeners + + this.canvas.addEventListener('webglcontextlost', function (event) + { + renderer.contextLost = true; + event.preventDefault(); + + for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) + { + var callback = renderer.lostContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + this.canvas.addEventListener('webglcontextrestored', function () + { + renderer.contextLost = false; + renderer.init(renderer.config); + for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) + { + var callback = renderer.restoredContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + // These are initialized post context creation + + /** + * The underlying WebGL context of the renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#gl + * @type {WebGLRenderingContext} + * @default null + * @since 3.0.0 + */ + this.gl = null; + + /** + * Array of strings that indicate which WebGL extensions are supported by the browser + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions + * @type {object} + * @default null + * @since 3.0.0 + */ + this.supportedExtensions = null; + + /** + * Extensions loaded into the current context + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.extensions = {}; + + /** + * Stores the current WebGL component formats for further use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats + * @type {array} + * @default [] + * @since 3.2.0 + */ + this.glFormats = []; + + /** + * Stores the supported WebGL texture compression formats. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#compression + * @type {array} + * @since 3.8.0 + */ + this.compression = { + ETC1: false, + PVRTC: false, + S3TC: false + }; + + /** + * Cached drawing buffer height to reduce gl calls. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#drawingBufferHeight + * @type {number} + * @readonly + * @since 3.11.0 + */ + this.drawingBufferHeight = 0; + + /** + * A blank 32x32 transparent texture, as used by the Graphics system where needed. + * This is set in the `boot` method. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#blankTexture + * @type {WebGLTexture} + * @readonly + * @since 3.12.0 + */ + this.blankTexture = null; + + this.defaultCamera = new BaseCamera(0, 0, 0, 0); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + this.init(this.config); + }, + + /** + * Creates a new WebGLRenderingContext and initializes all internal + * state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#init + * @since 3.0.0 + * + * @param {object} config - The configuration object for the renderer. + * + * @return {this} This WebGLRenderer instance. + */ + init: function (config) + { + var gl; + var canvas = this.canvas; + var clearColor = config.backgroundColor; + + // Did they provide their own context? + if (this.game.config.context) + { + gl = this.game.config.context; + } + else + { + gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); + } + + if (!gl || gl.isContextLost()) + { + this.contextLost = true; + + throw new Error('WebGL unsupported'); + } + + this.gl = gl; + + // Set it back into the Game, so developers can access it from there too + this.game.context = gl; + + for (var i = 0; i <= 16; i++) + { + this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); + } + + this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; + this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; + this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; + + this.glFormats[0] = gl.BYTE; + this.glFormats[1] = gl.SHORT; + this.glFormats[2] = gl.UNSIGNED_BYTE; + this.glFormats[3] = gl.UNSIGNED_SHORT; + this.glFormats[4] = gl.FLOAT; + + // Load supported extensions + var exts = gl.getSupportedExtensions(); + + if (!config.maxTextures) + { + config.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); + } + + if (!config.maxTextureSize) + { + config.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); + } + + var extString = 'WEBGL_compressed_texture_'; + var wkExtString = 'WEBKIT_' + extString; + + this.compression.ETC1 = gl.getExtension(extString + 'etc1') || gl.getExtension(wkExtString + 'etc1'); + this.compression.PVRTC = gl.getExtension(extString + 'pvrtc') || gl.getExtension(wkExtString + 'pvrtc'); + this.compression.S3TC = gl.getExtension(extString + 's3tc') || gl.getExtension(wkExtString + 's3tc'); + + this.supportedExtensions = exts; + + // Setup initial WebGL state + gl.disable(gl.DEPTH_TEST); + gl.disable(gl.CULL_FACE); + + // gl.disable(gl.SCISSOR_TEST); + + gl.enable(gl.BLEND); + gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); + + // Initialize all textures to null + for (var index = 0; index < this.currentTextures.length; ++index) + { + this.currentTextures[index] = null; + } + + // Clear previous pipelines and reload default ones + this.pipelines = {}; + + this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); + this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); + this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this, maxLights: config.maxLights })); + + this.setBlendMode(CONST.BlendModes.NORMAL); + + this.resize(this.width, this.height); + + this.game.events.once('texturesready', this.boot, this); + + return this; + }, + + /** + * Internal boot handler. Calls 'boot' on each pipeline. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#boot + * @private + * @since 3.11.0 + */ + boot: function () + { + for (var pipelineName in this.pipelines) + { + this.pipelines[pipelineName].boot(); + } + + var blank = this.game.textures.getFrame('__DEFAULT'); + + this.pipelines.TextureTintPipeline.currentFrame = blank; + + this.blankTexture = blank; + }, + + /** + * Resizes the drawing buffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#resize + * @since 3.0.0 + * + * @param {number} width - The width of the renderer. + * @param {number} height - The height of the renderer. + * + * @return {this} This WebGLRenderer instance. + */ + resize: function (width, height) + { + var gl = this.gl; + var pipelines = this.pipelines; + var resolution = this.config.resolution; + + this.width = Math.floor(width * resolution); + this.height = Math.floor(height * resolution); + + this.canvas.width = this.width; + this.canvas.height = this.height; + + if (this.config.autoResize) + { + this.canvas.style.width = (this.width / resolution) + 'px'; + this.canvas.style.height = (this.height / resolution) + 'px'; + } + + gl.viewport(0, 0, this.width, this.height); + + // Update all registered pipelines + for (var pipelineName in pipelines) + { + pipelines[pipelineName].resize(width, height, resolution); + } + + this.drawingBufferHeight = gl.drawingBufferHeight; + + this.defaultCamera.setSize(width, height); + + gl.scissor(0, (this.drawingBufferHeight - this.height), this.width, this.height); + + return this; + }, + + /** + * Adds a callback to be invoked when the WebGL context has been restored by the browser. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - The callback to be invoked on context restoration. + * @param {object} target - The context of the callback. + * + * @return {this} This WebGLRenderer instance. + */ + onContextRestored: function (callback, target) + { + this.restoredContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * Adds a callback to be invoked when the WebGL context has been lost by the browser. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - The callback to be invoked on context loss. + * @param {object} target - The context of the callback. + * + * @return {this} This WebGLRenderer instance. + */ + onContextLost: function (callback, target) + { + this.lostContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * Checks if a WebGL extension is supported + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension + * @since 3.0.0 + * + * @param {string} extensionName - Name of the WebGL extension + * + * @return {boolean} `true` if the extension is supported, otherwise `false`. + */ + hasExtension: function (extensionName) + { + return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; + }, + + /** + * Loads a WebGL extension + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension + * @since 3.0.0 + * + * @param {string} extensionName - The name of the extension to load. + * + * @return {object} WebGL extension if the extension is supported + */ + getExtension: function (extensionName) + { + if (!this.hasExtension(extensionName)) { return null; } + + if (!(extensionName in this.extensions)) + { + this.extensions[extensionName] = this.gl.getExtension(extensionName); + } + + return this.extensions[extensionName]; + }, + + /** + * Flushes the current pipeline if the pipeline is bound + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#flush + * @since 3.0.0 + */ + flush: function () + { + if (this.currentPipeline) + { + this.currentPipeline.flush(); + } + }, + + /** + * Checks if a pipeline is present in the current WebGLRenderer + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline. + * + * @return {boolean} `true` if the given pipeline is loaded, otherwise `false`. + */ + hasPipeline: function (pipelineName) + { + return (pipelineName in this.pipelines); + }, + + /** + * Returns the pipeline by name if the pipeline exists + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline. + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline instance, or `null` if not found. + */ + getPipeline: function (pipelineName) + { + return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; + }, + + /** + * Removes a pipeline by name. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to be removed. + * + * @return {this} This WebGLRenderer instance. + */ + removePipeline: function (pipelineName) + { + delete this.pipelines[pipelineName]; + + return this; + }, + + /** + * Adds a pipeline instance into the collection of pipelines + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - A unique string-based key for the pipeline. + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - A pipeline instance which must extend WebGLPipeline. + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipline instance that was passed. + */ + addPipeline: function (pipelineName, pipelineInstance) + { + if (!this.hasPipeline(pipelineName)) + { + this.pipelines[pipelineName] = pipelineInstance; + } + else + { + console.warn('Pipeline exists: ' + pipelineName); + } + + pipelineInstance.name = pipelineName; + + this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); + + return pipelineInstance; + }, + + /** + * Pushes a new scissor state. This is used to set nested scissor states. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor + * @since 3.0.0 + * + * @param {integer} x - The x position of the scissor. + * @param {integer} y - The y position of the scissor. + * @param {integer} width - The width of the scissor. + * @param {integer} height - The height of the scissor. + * + * @return {integer[]} An array containing the scissor values. + */ + pushScissor: function (x, y, width, height) + { + var scissorStack = this.scissorStack; + + var scissor = [ x, y, width, height ]; + + scissorStack.push(scissor); + + this.setScissor(x, y, width, height); + + this.currentScissor = scissor; + + return scissor; + }, + + /** + * Sets the current scissor state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor + * @since 3.0.0 + * + * @param {integer} x - The x position of the scissor. + * @param {integer} y - The y position of the scissor. + * @param {integer} width - The width of the scissor. + * @param {integer} height - The height of the scissor. + */ + setScissor: function (x, y, width, height) + { + var gl = this.gl; + + var current = this.currentScissor; + + var cx = current[0]; + var cy = current[1]; + var cw = current[2]; + var ch = current[3]; + + if (cx !== x || cy !== y || cw !== width || ch !== height) + { + this.flush(); + + // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/scissor + + if (width > 0 && height > 0) + { + gl.scissor(x, (this.drawingBufferHeight - y - height), width, height); + + } + } + }, + + /** + * Pops the last scissor state and sets it. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor + * @since 3.0.0 + */ + popScissor: function () + { + var scissorStack = this.scissorStack; + + // Remove the current scissor + scissorStack.pop(); + + // Reset the previous scissor + var scissor = scissorStack[scissorStack.length - 1]; + + if (scissor) + { + this.setScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + } + + this.currentScissor = scissor; + }, + + /** + * Binds a WebGLPipeline and sets it as the current pipeline to be used. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline + * @since 3.0.0 + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - The pipeline instance to be activated. + * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any. + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline that was activated. + */ + setPipeline: function (pipelineInstance, gameObject) + { + if (this.currentPipeline !== pipelineInstance || + this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || + this.currentPipeline.program !== this.currentProgram) + { + this.flush(); + this.currentPipeline = pipelineInstance; + this.currentPipeline.bind(); + } + + this.currentPipeline.onBind(gameObject); + + return this.currentPipeline; + }, + + /** + * Sets the blend mode to the value given. + * + * If the current blend mode is different from the one given, the pipeline is flushed and the new + * blend mode is enabled. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode + * @since 3.0.0 + * + * @param {integer} blendModeId - The blend mode to be set. Can be a `BlendModes` const or an integer value. + * + * @return {boolean} `true` if the blend mode was changed as a result of this call, forcing a flush, otherwise `false`. + */ + setBlendMode: function (blendModeId) + { + var gl = this.gl; + var blendMode = this.blendModes[blendModeId]; + + if (blendModeId !== CONST.BlendModes.SKIP_CHECK && this.currentBlendMode !== blendModeId) + { + this.flush(); + + gl.enable(gl.BLEND); + gl.blendEquation(blendMode.equation); + + if (blendMode.func.length > 2) + { + gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); + } + else + { + gl.blendFunc(blendMode.func[0], blendMode.func[1]); + } + + this.currentBlendMode = blendModeId; + + return true; + } + + return false; + }, + + /** + * Creates a new custom blend mode for the renderer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addBlendMode + * @since 3.0.0 + * + * @param {function} func - An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for {@link WebGLRenderingContext#blendFunc()}. + * @param {function} equation - The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for {@link WebGLRenderingContext#blendEquation()}. + * + * @return {integer} The index of the new blend mode, used for referencing it in the future. + */ + addBlendMode: function (func, equation) + { + var index = this.blendModes.push({ func: func, equation: equation }); + + return index - 1; + }, + + /** + * Updates the function bound to a given custom blend mode. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#updateBlendMode + * @since 3.0.0 + * + * @param {integer} index - The index of the custom blend mode. + * @param {function} func - The function to use for the blend mode. + * @param {function} equation - The equation to use for the blend mode. + * + * @return {this} This WebGLRenderer instance. + */ + updateBlendMode: function (index, func, equation) + { + if (this.blendModes[index]) + { + this.blendModes[index].func = func; + + if (equation) + { + this.blendModes[index].equation = equation; + } + } + + return this; + }, + + /** + * Removes a custom blend mode from the renderer. + * Any Game Objects still using this blend mode will error, so be sure to clear them first. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removeBlendMode + * @since 3.0.0 + * + * @param {integer} index - The index of the custom blend mode to be removed. + * + * @return {this} This WebGLRenderer instance. + */ + removeBlendMode: function (index) + { + if (index > 16 && this.blendModes[index]) + { + this.blendModes.splice(index, 1); + } + + return this; + }, + + /** + * Sets the current active texture for texture unit zero to be a blank texture. + * This only happens if there isn't a texture already in use by texture unit zero. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlankTexture + * @private + * @since 3.12.0 + * + * @param {boolean} [force=false] - Force a blank texture set, regardless of what's already bound? + */ + setBlankTexture: function (force) + { + if (force === undefined) { force = false; } + + if (force || this.currentActiveTextureUnit !== 0 || !this.currentTextures[0]) + { + this.setTexture2D(this.blankTexture.glTexture, 0); + } + }, + + /** + * Binds a texture at a texture unit. If a texture is already + * bound to that unit it will force a flush on the current pipeline. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D + * @since 3.0.0 + * + * @param {WebGLTexture} texture - The WebGL texture that needs to be bound. + * @param {integer} textureUnit - The texture unit to which the texture will be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setTexture2D: function (texture, textureUnit) + { + var gl = this.gl; + + if (texture !== this.currentTextures[textureUnit]) + { + this.flush(); + + if (this.currentActiveTextureUnit !== textureUnit) + { + gl.activeTexture(gl.TEXTURE0 + textureUnit); + + this.currentActiveTextureUnit = textureUnit; + } + + gl.bindTexture(gl.TEXTURE_2D, texture); + + this.currentTextures[textureUnit] = texture; + } + + return this; + }, + + /** + * Binds a framebuffer. If there was another framebuffer already bound it will force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setFramebuffer: function (framebuffer) + { + var gl = this.gl; + + var width = this.width; + var height = this.height; + + if (framebuffer !== this.currentFramebuffer) + { + if (framebuffer && framebuffer.renderTexture) + { + width = framebuffer.renderTexture.width; + height = framebuffer.renderTexture.height; + } + else + { + this.flush(); + } + + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + + gl.viewport(0, 0, width, height); + + this.currentFramebuffer = framebuffer; + } + + return this; + }, + + /** + * Binds a program. If there was another program already bound it will force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - The program that needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setProgram: function (program) + { + var gl = this.gl; + + if (program !== this.currentProgram) + { + this.flush(); + + gl.useProgram(program); + + this.currentProgram = program; + } + + return this; + }, + + /** + * Bounds a vertex buffer. If there is a vertex buffer already bound it'll force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - The buffer that needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setVertexBuffer: function (vertexBuffer) + { + var gl = this.gl; + + if (vertexBuffer !== this.currentVertexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + + this.currentVertexBuffer = vertexBuffer; + } + + return this; + }, + + /** + * Bounds a index buffer. If there is a index buffer already bound it'll force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} indexBuffer - The buffer the needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setIndexBuffer: function (indexBuffer) + { + var gl = this.gl; + + if (indexBuffer !== this.currentIndexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + + this.currentIndexBuffer = indexBuffer; + } + + return this; + }, + + /** + * Creates a texture from an image source. If the source is not valid it creates an empty texture. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource + * @since 3.0.0 + * + * @param {object} source - The source of the texture. + * @param {integer} width - The width of the texture. + * @param {integer} height - The height of the texture. + * @param {integer} scaleMode - The scale mode to be used by the texture. + * + * @return {?WebGLTexture} The WebGL Texture that was created, or `null` if it couldn't be created. + */ + createTextureFromSource: function (source, width, height, scaleMode) + { + var gl = this.gl; + var filter = gl.NEAREST; + var wrap = gl.CLAMP_TO_EDGE; + var texture = null; + + width = source ? source.width : width; + height = source ? source.height : height; + + if (IsSizePowerOfTwo(width, height)) + { + wrap = gl.REPEAT; + } + + if (scaleMode === CONST.ScaleModes.LINEAR && this.config.antialias) + { + filter = gl.LINEAR; + } + + if (!source && typeof width === 'number' && typeof height === 'number') + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + } + else + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); + } + + return texture; + }, + + /** + * A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D + * @since 3.0.0 + * + * @param {integer} mipLevel - Mip level of the texture. + * @param {integer} minFilter - Filtering of the texture. + * @param {integer} magFilter - Filtering of the texture. + * @param {integer} wrapT - Wrapping mode of the texture. + * @param {integer} wrapS - Wrapping mode of the texture. + * @param {integer} format - Which format does the texture use. + * @param {object} pixels - pixel data. + * @param {integer} width - Width of the texture in pixels. + * @param {integer} height - Height of the texture in pixels. + * @param {boolean} pma - Does the texture have premultiplied alpha? + * + * @return {WebGLTexture} The WebGLTexture that was created. + */ + createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) + { + pma = (pma === undefined || pma === null) ? true : pma; + + var gl = this.gl; + var texture = gl.createTexture(); + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); + + if (pixels === null || pixels === undefined) + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); + } + else + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); + width = pixels.width; + height = pixels.height; + } + + this.setTexture2D(null, 0); + + texture.isAlphaPremultiplied = pma; + texture.isRenderTexture = false; + texture.width = width; + texture.height = height; + + this.nativeTextures.push(texture); + + return texture; + }, + + /** + * Wrapper for creating WebGLFramebuffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer + * @since 3.0.0 + * + * @param {integer} width - Width in pixels of the framebuffer + * @param {integer} height - Height in pixels of the framebuffer + * @param {WebGLTexture} renderTexture - The color texture to where the color pixels are written + * @param {boolean} addDepthStencilBuffer - Indicates if the current framebuffer support depth and stencil buffers + * + * @return {WebGLFramebuffer} Raw WebGLFramebuffer + */ + createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) + { + var gl = this.gl; + var framebuffer = gl.createFramebuffer(); + var complete = 0; + + this.setFramebuffer(framebuffer); + + if (addDepthStencilBuffer) + { + var depthStencilBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); + } + + renderTexture.isRenderTexture = true; + renderTexture.isAlphaPremultiplied = false; + + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); + + complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); + + if (complete !== gl.FRAMEBUFFER_COMPLETE) + { + var errors = { + 36054: 'Incomplete Attachment', + 36055: 'Missing Attachment', + 36057: 'Incomplete Dimensions', + 36061: 'Framebuffer Unsupported' + }; + + throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); + } + + framebuffer.renderTexture = renderTexture; + + this.setFramebuffer(null); + + return framebuffer; + }, + + /** + * Wrapper for creating a WebGLProgram + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram + * @since 3.0.0 + * + * @param {string} vertexShader - Source to the vertex shader + * @param {string} fragmentShader - Source to the fragment shader + * + * @return {WebGLProgram} Raw WebGLProgram + */ + createProgram: function (vertexShader, fragmentShader) + { + var gl = this.gl; + var program = gl.createProgram(); + var vs = gl.createShader(gl.VERTEX_SHADER); + var fs = gl.createShader(gl.FRAGMENT_SHADER); + + gl.shaderSource(vs, vertexShader); + gl.shaderSource(fs, fragmentShader); + gl.compileShader(vs); + gl.compileShader(fs); + + if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); + } + if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); + } + + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.linkProgram(program); + + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) + { + throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); + } + + return program; + }, + + /** + * Wrapper for creating a vertex buffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo + * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW + * + * @return {WebGLBuffer} Raw vertex buffer + */ + createVertexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var vertexBuffer = gl.createBuffer(); + + this.setVertexBuffer(vertexBuffer); + + gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setVertexBuffer(null); + + return vertexBuffer; + }, + + /** + * Wrapper for creating a vertex buffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - Either ArrayBuffer or an integer indicating the size of the vbo. + * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. + * + * @return {WebGLBuffer} Raw index buffer + */ + createIndexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var indexBuffer = gl.createBuffer(); + + this.setIndexBuffer(indexBuffer); + + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setIndexBuffer(null); + + return indexBuffer; + }, + + /** + * Removes the given texture from the nativeTextures array and then deletes it from the GPU. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture + * @since 3.0.0 + * + * @param {WebGLTexture} texture - The WebGL Texture to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteTexture: function (texture) + { + var index = this.nativeTextures.indexOf(texture); + + if (index !== -1) + { + SpliceOne(this.nativeTextures, index); + } + + this.gl.deleteTexture(texture); + + if (this.currentTextures[0] === texture) + { + // texture we just deleted is in use, so bind a blank texture + this.setBlankTexture(true); + } + + return this; + }, + + /** + * Deletes a WebGLFramebuffer from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - The Framebuffer to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteFramebuffer: function (framebuffer) + { + this.gl.deleteFramebuffer(framebuffer); + + return this; + }, + + /** + * Deletes a WebGLProgram from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - The shader program to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteProgram: function (program) + { + this.gl.deleteProgram(program); + + return this; + }, + + /** + * Deletes a WebGLBuffer from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - The WebGLBuffer to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteBuffer: function (buffer) + { + this.gl.deleteBuffer(buffer); + + return this; + }, + + /** + * Controls the pre-render operations for the given camera. + * Handles any clipping needed by the camera and renders the background color if a color is visible. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to pre-render. + */ + preRenderCamera: function (camera) + { + var cx = camera._cx; + var cy = camera._cy; + var cw = camera._cw; + var ch = camera._ch; + + var TextureTintPipeline = this.pipelines.TextureTintPipeline; + + var color = camera.backgroundColor; + + if (camera.renderToTexture) + { + this.flush(); + + this.pushScissor(cx, cy, cw, -ch); + + this.setFramebuffer(camera.framebuffer); + + var gl = this.gl; + + gl.clearColor(0, 0, 0, 0); + + gl.clear(gl.COLOR_BUFFER_BIT); + + TextureTintPipeline.projOrtho(cx, cw + cx, cy, ch + cy, -1000, 1000); + + if (color.alphaGL > 0) + { + TextureTintPipeline.drawFillRect( + cx, cy, cw + cx, ch + cy, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1), + color.alphaGL + ); + } + + camera.emit('prerender', camera); + } + else + { + this.pushScissor(cx, cy, cw, ch); + + if (color.alphaGL > 0) + { + TextureTintPipeline.drawFillRect( + cx, cy, cw , ch, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1), + color.alphaGL + ); + } + } + }, + + /** + * Controls the post-render operations for the given camera. + * Renders the foreground camera effects like flash and fading. It resets the current scissor state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to post-render. + */ + postRenderCamera: function (camera) + { + var TextureTintPipeline = this.pipelines.TextureTintPipeline; + + camera.flashEffect.postRenderWebGL(TextureTintPipeline, Utils.getTintFromFloats); + camera.fadeEffect.postRenderWebGL(TextureTintPipeline, Utils.getTintFromFloats); + + camera.dirty = false; + + this.popScissor(); + + if (camera.renderToTexture) + { + TextureTintPipeline.flush(); + + this.setFramebuffer(null); + + camera.emit('postrender', camera); + + TextureTintPipeline.projOrtho(0, TextureTintPipeline.width, TextureTintPipeline.height, 0, -1000.0, 1000.0); + + var getTint = Utils.getTintAppendFloatAlpha; + + var pipeline = (camera.pipeline) ? camera.pipeline : TextureTintPipeline; + + pipeline.batchTexture( + camera, + camera.glTexture, + camera.width, camera.height, + camera.x, camera.y, + camera.width, camera.height, + camera.zoom, camera.zoom, + camera.rotation, + camera.flipX, !camera.flipY, + 1, 1, + 0, 0, + 0, 0, camera.width, camera.height, + getTint(camera._tintTL, camera._alphaTL), + getTint(camera._tintTR, camera._alphaTR), + getTint(camera._tintBL, camera._alphaBL), + getTint(camera._tintBR, camera._alphaBR), + (camera._isTinted && camera.tintFill), + 0, 0, + this.defaultCamera, + null + ); + + // Force clear the current texture so that items next in the batch (like Graphics) don't try and use it + this.setBlankTexture(true); + } + }, + + /** + * Clears the current vertex buffer and updates pipelines. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender + * @since 3.0.0 + */ + preRender: function () + { + if (this.contextLost) { return; } + + var gl = this.gl; + var color = this.config.backgroundColor; + var pipelines = this.pipelines; + + if (this.config.clearBeforeRender) + { + gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + } + + gl.enable(gl.SCISSOR_TEST); + + for (var key in pipelines) + { + pipelines[key].onPreRender(); + } + + // TODO - Find a way to stop needing to create these arrays every frame + // and equally not need a huge array buffer created to hold them + + this.currentScissor = [ 0, 0, this.width, this.height ]; + this.scissorStack = [ this.currentScissor ]; + + if (this.game.scene.customViewports) + { + gl.scissor(0, (this.drawingBufferHeight - this.height), this.width, this.height); + } + + this.setPipeline(this.pipelines.TextureTintPipeline); + }, + + /** + * The core render step for a Scene. + * Iterates through the given Game Object's array and renders them with the given Camera. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to render. + * @param {Phaser.GameObjects.GameObject} children - The Game Object's within the Scene to be rendered. + * @param {number} interpolationPercentage - The interpolation percentage to apply. Currently un-used. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Scene Camera to render with. + */ + render: function (scene, children, interpolationPercentage, camera) + { + if (this.contextLost) { return; } + + var list = children.list; + var childCount = list.length; + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onRender(scene, camera); + } + + // Apply scissor for cam region + render background color, if not transparent + this.preRenderCamera(camera); + + for (var i = 0; i < childCount; i++) + { + var child = list[i]; + + if (!child.willRender(camera)) + { + continue; + } + + if (child.blendMode !== this.currentBlendMode) + { + this.setBlendMode(child.blendMode); + } + + var mask = child.mask; + + if (mask) + { + mask.preRenderWebGL(this, child, camera); + + child.renderWebGL(this, child, interpolationPercentage, camera); + + mask.postRenderWebGL(this, child); + } + else + { + child.renderWebGL(this, child, interpolationPercentage, camera); + } + } + + this.setBlendMode(CONST.BlendModes.NORMAL); + + // Applies camera effects and pops the scissor, if set + this.postRenderCamera(camera); + }, + + /** + * The post-render step happens after all Cameras in all Scenes have been rendered. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender + * @since 3.0.0 + */ + postRender: function () + { + if (this.contextLost) { return; } + + this.flush(); + + // Unbind custom framebuffer here + + if (this.snapshotState.callback) + { + this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); + this.snapshotState.callback = null; + } + + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onPostRender(); + } + }, + + /** + * Schedules a snapshot to be taken after the current frame is rendered. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - Function to invoke after the snapshot is created. + * @param {string} type - The format of the image to create, usually `image/png`. + * @param {number} encoderOptions - The image quality, between 0 and 1, to use for image formats with lossy compression (such as `image/jpeg`). + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotState.callback = callback; + this.snapshotState.type = type; + this.snapshotState.encoder = encoderOptions; + + return this; + }, + + /** + * Creates a WebGL Texture based on the given canvas element. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture + * @since 3.0.0 + * + * @param {HTMLCanvasElement} srcCanvas - The Canvas element that will be used to populate the texture. + * @param {WebGLTexture} [dstTexture] - Is this going to replace an existing texture? If so, pass it here. + * @param {boolean} [noRepeat=false] - Should this canvas never be allowed to set REPEAT? (such as for Text objects) + * + * @return {WebGLTexture} The newly created WebGL Texture. + */ + canvasToTexture: function (srcCanvas, dstTexture, noRepeat) + { + if (noRepeat === undefined) { noRepeat = false; } + + var gl = this.gl; + + if (!dstTexture) + { + var wrapping = gl.CLAMP_TO_EDGE; + + if (!noRepeat && IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) + { + wrapping = gl.REPEAT; + } + + dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); + } + else + { + this.setTexture2D(dstTexture, 0); + + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); + + dstTexture.width = srcCanvas.width; + dstTexture.height = srcCanvas.height; + + this.setTexture2D(null, 0); + } + + return dstTexture; + }, + + /** + * Sets the minification and magnification filter for a texture. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter + * @since 3.0.0 + * + * @param {integer} texture - The texture to set the filter for. + * @param {integer} filter - The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. + * + * @return {this} This WebGL Renderer instance. + */ + setTextureFilter: function (texture, filter) + { + var gl = this.gl; + var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); + + this.setTexture2D(null, 0); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setFloat1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setFloat2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setFloat3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, + + /** + * Sets uniform of a WebGLProgram + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - X component + * @param {number} y - Y component + * @param {number} z - Z component + * @param {number} w - W component + * + * @return {this} This WebGL Renderer instance. + */ + setFloat4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + setFloat1v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform1fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + setFloat2v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform2fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + setFloat3v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform3fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + + setFloat4v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform4fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setInt1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setInt2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setInt3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - X component + * @param {integer} y - Y component + * @param {integer} z - Z component + * @param {integer} w - W component + * + * @return {this} This WebGL Renderer instance. + */ + setInt4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setMatrix2: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setMatrix3: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * Sets uniform of a WebGLProgram + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - Is the matrix transposed + * @param {Float32Array} matrix - Matrix data + * + * @return {this} This WebGL Renderer instance. + */ + setMatrix4: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * Returns the maximum number of texture units that can be used in a fragment shader. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextures + * @since 3.8.0 + * + * @return {integer} The maximum number of textures WebGL supports. + */ + getMaxTextures: function () + { + return this.config.maxTextures; + }, + + /** + * Returns the largest texture size (either width or height) that can be created. + * Note that VRAM may not allow a texture of any given size, it just expresses + * hardware / driver support for a given size. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextureSize + * @since 3.8.0 + * + * @return {integer} The maximum supported texture size. + */ + getMaxTextureSize: function () + { + return this.config.maxTextureSize; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Clear-up anything that should be cleared :) + for (var key in this.pipelines) + { + this.pipelines[key].destroy(); + + delete this.pipelines[key]; + } + + for (var index = 0; index < this.nativeTextures.length; ++index) + { + this.deleteTexture(this.nativeTextures[index]); + + delete this.nativeTextures[index]; + } + + delete this.gl; + delete this.game; + + this.contextLost = true; + this.extensions = {}; + this.nativeTextures.length = 0; + } + +}); + +module.exports = WebGLRenderer; + + +/***/ }), +/* 372 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var modes = __webpack_require__(72); +var CanvasFeatures = __webpack_require__(375); + +/** + * [description] + * + * @function Phaser.Renderer.Canvas.GetBlendModes + * @since 3.0.0 + * + * @return {array} [description] + */ +var GetBlendModes = function () +{ + var output = []; + var useNew = CanvasFeatures.supportNewBlendModes; + var so = 'source-over'; + + output[modes.NORMAL] = so; + output[modes.ADD] = 'lighter'; + output[modes.MULTIPLY] = (useNew) ? 'multiply' : so; + output[modes.SCREEN] = (useNew) ? 'screen' : so; + output[modes.OVERLAY] = (useNew) ? 'overlay' : so; + output[modes.DARKEN] = (useNew) ? 'darken' : so; + output[modes.LIGHTEN] = (useNew) ? 'lighten' : so; + output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : so; + output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : so; + output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : so; + output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : so; + output[modes.DIFFERENCE] = (useNew) ? 'difference' : so; + output[modes.EXCLUSION] = (useNew) ? 'exclusion' : so; + output[modes.HUE] = (useNew) ? 'hue' : so; + output[modes.SATURATION] = (useNew) ? 'saturation' : so; + output[modes.COLOR] = (useNew) ? 'color' : so; + output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : so; + + return output; +}; + +module.exports = GetBlendModes; + + +/***/ }), +/* 373 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Renderer.Snapshot.Canvas + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {string} [type='image/png'] - [description] + * @param {number} [encoderOptions=0.92] - [description] + * + * @return {HTMLImageElement} [description] + */ +var CanvasSnapshot = function (canvas, type, encoderOptions) +{ + if (type === undefined) { type = 'image/png'; } + if (encoderOptions === undefined) { encoderOptions = 0.92; } + + var src = canvas.toDataURL(type, encoderOptions); + + var image = new Image(); + + image.src = src; + + return image; +}; + +module.exports = CanvasSnapshot; + + +/***/ }), +/* 374 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasSnapshot = __webpack_require__(373); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(28); +var GetBlendModes = __webpack_require__(372); +var ScaleModes = __webpack_require__(104); +var Smoothing = __webpack_require__(130); +var TransformMatrix = __webpack_require__(42); + +/** + * @classdesc + * [description] + * + * @class CanvasRenderer + * @memberof Phaser.Renderer.Canvas + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. + */ +var CanvasRenderer = new Class({ + + initialize: + + function CanvasRenderer (game) + { + /** + * The Phaser Game instance that owns this renderer. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.CANVAS; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.drawCount = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#width + * @type {number} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#height + * @type {number} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: game.config.clearBeforeRender, + backgroundColor: game.config.backgroundColor, + resolution: game.config.resolution, + autoResize: game.config.autoResize, + antialias: game.config.antialias, + roundPixels: game.config.roundPixels + }; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode + * @type {integer} + * @since 3.0.0 + */ + this.scaleMode = (game.config.antialias) ? ScaleModes.LINEAR : ScaleModes.NEAREST; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.gameCanvas = game.canvas; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.gameContext = (this.game.config.context) ? this.game.config.context : this.gameCanvas.getContext('2d'); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.currentContext = this.gameContext; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes + * @type {array} + * @since 3.0.0 + */ + this.blendModes = GetBlendModes(); + + // image-rendering: optimizeSpeed; + // image-rendering: pixelated; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentScaleMode = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback + * @type {?SnapshotCallback} + * @default null + * @since 3.0.0 + */ + this.snapshotCallback = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType + * @type {?string} + * @default null + * @since 3.0.0 + */ + this.snapshotType = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.snapshotEncoder = null; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + this.init(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#init + * @since 3.0.0 + */ + init: function () + { + this.resize(this.width, this.height); + }, + + /** + * Resize the main game canvas. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resize + * @since 3.0.0 + * + * @param {integer} width - [description] + * @param {integer} height - [description] + */ + resize: function (width, height) + { + var resolution = this.config.resolution; + + this.width = width * resolution; + this.height = height * resolution; + + this.gameCanvas.width = this.width; + this.gameCanvas.height = this.height; + + if (this.config.autoResize) + { + this.gameCanvas.style.width = (this.width / resolution) + 'px'; + this.gameCanvas.style.height = (this.height / resolution) + 'px'; + } + + // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) + if (this.scaleMode === ScaleModes.NEAREST) + { + Smoothing.disable(this.gameContext); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextLost: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextRestored: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform + * @since 3.0.0 + */ + resetTransform: function () + { + this.currentContext.setTransform(1, 0, 0, 1, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode + * @since 3.0.0 + * + * @param {number} blendMode - [description] + * + * @return {this} [description] + */ + setBlendMode: function (blendMode) + { + this.currentContext.globalCompositeOperation = blendMode; + + return this; + }, + + /** + * Changes the Canvas Rendering Context that all draw operations are performed against. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setContext + * @since 3.12.0 + * + * @param {?CanvasRenderingContext2D} [ctx] - The new Canvas Rendering Context to draw everything to. Leave empty to reset to the Game Canvas. + * + * @return {this} The Canvas Renderer instance. + */ + setContext: function (ctx) + { + this.currentContext = (ctx) ? ctx : this.gameContext; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha + * @since 3.0.0 + * + * @param {number} alpha - [description] + * + * @return {this} [description] + */ + setAlpha: function (alpha) + { + this.currentContext.globalAlpha = alpha; + + return this; + }, + + /** + * Called at the start of the render loop. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender + * @since 3.0.0 + */ + preRender: function () + { + var ctx = this.gameContext; + var config = this.config; + + var width = this.width; + var height = this.height; + + if (config.clearBeforeRender) + { + ctx.clearRect(0, 0, width, height); + } + + if (!config.transparent) + { + ctx.fillStyle = config.backgroundColor.rgba; + ctx.fillRect(0, 0, width, height); + } + + this.drawCount = 0; + }, + + /** + * Renders the Scene to the given Camera. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.DisplayList} children - [description] + * @param {number} interpolationPercentage - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + render: function (scene, children, interpolationPercentage, camera) + { + var list = children.list; + var childCount = list.length; + + var cx = camera._cx; + var cy = camera._cy; + var cw = camera._cw; + var ch = camera._ch; + + var ctx = (camera.renderToTexture) ? camera.context : scene.sys.context; + + var scissor = (cx !== 0 || cy !== 0 || cw !== ctx.canvas.width || ch !== ctx.canvas.height); + + this.currentContext = ctx; + + // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) + + if (!camera.transparent) + { + ctx.fillStyle = camera.backgroundColor.rgba; + ctx.fillRect(cx, cy, cw, ch); + } + + ctx.globalAlpha = camera.alpha; + + ctx.globalCompositeOperation = 'source-over'; + + this.drawCount += list.length; + + if (scissor) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(cx, cy, cw, ch); + ctx.clip(); + } + + if (camera.renderToTexture) + { + camera.emit('prerender', camera); + } + + camera.matrix.copyToContext(ctx); + + for (var i = 0; i < childCount; i++) + { + var child = list[i]; + + if (!child.willRender(camera)) + { + continue; + } + + if (child.mask) + { + child.mask.preRenderCanvas(this, child, camera); + } + + child.renderCanvas(this, child, interpolationPercentage, camera); + + if (child.mask) + { + child.mask.postRenderCanvas(this, child, camera); + } + } + + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + + camera.flashEffect.postRenderCanvas(ctx); + camera.fadeEffect.postRenderCanvas(ctx); + + camera.dirty = false; + + // Reset the camera scissor + if (scissor) + { + ctx.restore(); + } + + if (camera.renderToTexture) + { + camera.emit('postrender', camera); + + scene.sys.context.drawImage(camera.canvas, cx, cy); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender + * @since 3.0.0 + */ + postRender: function () + { + var ctx = this.gameContext; + + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + + if (this.snapshotCallback) + { + this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); + this.snapshotCallback = null; + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - [description] + * @param {string} type - [description] + * @param {number} encoderOptions - [description] + */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotCallback = callback; + this.snapshotType = type; + this.snapshotEncoder = encoderOptions; + }, + + /** + * Takes a Sprite Game Object, or any object that extends it, and draws it to the current context. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#batchSprite + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - The texture based Game Object to draw. + * @param {Phaser.Textures.Frame} frame - The frame to draw, doesn't have to be that owned by the Game Object. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the rendering transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - The transform matrix of the parent container, if set. + */ + batchSprite: function (sprite, frame, camera, parentTransformMatrix) + { + var alpha = camera.alpha * sprite.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + + var ctx = this.currentContext; + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var cd = frame.canvasData; + + var frameX = cd.x; + var frameY = cd.y; + var frameWidth = frame.cutWidth; + var frameHeight = frame.cutHeight; + var res = frame.source.resolution; + + var x = -sprite.displayOriginX + frame.x; + var y = -sprite.displayOriginY + frame.y; + + var fx = (sprite.flipX) ? -1 : 1; + var fy = (sprite.flipY) ? -1 : 1; + + if (sprite.isCropped) + { + var crop = sprite._crop; + + if (crop.flipX !== sprite.flipX || crop.flipY !== sprite.flipY) + { + frame.updateCropUVs(crop, sprite.flipX, sprite.flipY); + } + + frameWidth = crop.cw; + frameHeight = crop.ch; + + frameX = crop.cx; + frameY = crop.cy; + + x = -sprite.displayOriginX + crop.x; + y = -sprite.displayOriginY + crop.y; + + if (fx === -1) + { + if (x >= 0) + { + x = -(x + frameWidth); + } + else if (x < 0) + { + x = (Math.abs(x) - frameWidth); + } + } + + if (fy === -1) + { + if (y >= 0) + { + y = -(y + frameHeight); + } + else if (y < 0) + { + y = (Math.abs(y) - frameHeight); + } + } + } + + spriteMatrix.applyITRS(sprite.x, sprite.y, sprite.rotation, sprite.scaleX, sprite.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * sprite.scrollFactorX, -camera.scrollY * sprite.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = sprite.x; + spriteMatrix.f = sprite.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * sprite.scrollFactorX; + spriteMatrix.f -= camera.scrollY * sprite.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + ctx.save(); + + calcMatrix.setToContext(ctx); + + ctx.scale(fx, fy); + + ctx.globalCompositeOperation = this.blendModes[sprite.blendMode]; + + ctx.globalAlpha = alpha; + + ctx.drawImage(frame.source.image, frameX, frameY, frameWidth, frameHeight, x, y, frameWidth / res, frameHeight / res); + + ctx.restore(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.gameCanvas = null; + this.gameContext = null; + + this.game = null; + } + +}); + +module.exports = CanvasRenderer; + + +/***/ }), +/* 375 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(26); + +/** + * Determines the canvas features of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.canvasFeatures` from within any Scene. + * + * @typedef {object} Phaser.Device.CanvasFeatures + * @since 3.0.0 + * + * @property {boolean} supportInverseAlpha - Set to true if the browser supports inversed alpha. + * @property {boolean} supportNewBlendModes - Set to true if the browser supports new canvas blend modes. + */ +var CanvasFeatures = { + + supportInverseAlpha: false, + supportNewBlendModes: false + +}; + +function checkBlendMode () +{ + var pngHead = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/'; + var pngEnd = 'AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg=='; + + var magenta = new Image(); + + magenta.onload = function () + { + var yellow = new Image(); + + yellow.onload = function () + { + var canvas = CanvasPool.create(yellow, 6, 1); + var context = canvas.getContext('2d'); + + context.globalCompositeOperation = 'multiply'; + + context.drawImage(magenta, 0, 0); + context.drawImage(yellow, 2, 0); + + if (!context.getImageData(2, 0, 1, 1)) + { + return false; + } + + var data = context.getImageData(2, 0, 1, 1).data; + + CanvasPool.remove(yellow); + + CanvasFeatures.supportNewBlendModes = (data[0] === 255 && data[1] === 0 && data[2] === 0); + }; + + yellow.src = pngHead + '/wCKxvRF' + pngEnd; + }; + + magenta.src = pngHead + 'AP804Oa6' + pngEnd; + + return false; +} + +function checkInverseAlpha () +{ + var canvas = CanvasPool.create(this, 2, 1); + var context = canvas.getContext('2d'); + + context.fillStyle = 'rgba(10, 20, 30, 0.5)'; + + // Draw a single pixel + context.fillRect(0, 0, 1, 1); + + // Get the color values + var s1 = context.getImageData(0, 0, 1, 1); + + if (s1 === null) + { + return false; + } + + // Plot them to x2 + context.putImageData(s1, 1, 0); + + // Get those values + var s2 = context.getImageData(1, 0, 1, 1); + + // Compare and return + return (s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]); +} + +function init () +{ + if (document !== undefined) + { + CanvasFeatures.supportNewBlendModes = checkBlendMode(); + CanvasFeatures.supportInverseAlpha = checkInverseAlpha(); + } + + return CanvasFeatures; +} + +module.exports = init(); + + +/***/ }), +/* 376 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// This singleton is instantiated as soon as Phaser loads, +// before a Phaser.Game instance has even been created. +// Which means all instances of Phaser Games can share it, +// without having to re-poll the device all over again + +/** + * @namespace Phaser.Device + * @since 3.0.0 + */ + +/** + * @typedef {object} Phaser.DeviceConf + * + * @property {Phaser.Device.OS} os - The OS Device functions. + * @property {Phaser.Device.Browser} browser - The Browser Device functions. + * @property {Phaser.Device.Features} features - The Features Device functions. + * @property {Phaser.Device.Input} input - The Input Device functions. + * @property {Phaser.Device.Audio} audio - The Audio Device functions. + * @property {Phaser.Device.Video} video - The Video Device functions. + * @property {Phaser.Device.Fullscreen} fullscreen - The Fullscreen Device functions. + * @property {Phaser.Device.CanvasFeatures} canvasFeatures - The Canvas Device functions. + */ + +module.exports = { + + os: __webpack_require__(101), + browser: __webpack_require__(128), + features: __webpack_require__(186), + input: __webpack_require__(974), + audio: __webpack_require__(973), + video: __webpack_require__(972), + fullscreen: __webpack_require__(971), + canvasFeatures: __webpack_require__(375) + +}; + + +/***/ }), +/* 377 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var NOOP = __webpack_require__(2); + +/** + * @classdesc + * Abstracts away the use of RAF or setTimeOut for the core game update loop. + * This is invoked automatically by the Phaser.Game instance. + * + * @class RequestAnimationFrame + * @memberof Phaser.DOM + * @constructor + * @since 3.0.0 + */ +var RequestAnimationFrame = new Class({ + + initialize: + + function RequestAnimationFrame () + { + /** + * True if RequestAnimationFrame is running, otherwise false. + * + * @name Phaser.DOM.RequestAnimationFrame#isRunning + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * The callback to be invoked each step. + * + * @name Phaser.DOM.RequestAnimationFrame#callback + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#tick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.tick = 0; + + /** + * True if the step is using setTimeout instead of RAF. + * + * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isSetTimeOut = false; + + /** + * The setTimeout or RAF callback ID used when canceling them. + * + * @name Phaser.DOM.RequestAnimationFrame#timeOutID + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.timeOutID = null; + + /** + * The previous time the step was called. + * + * @name Phaser.DOM.RequestAnimationFrame#lastTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lastTime = 0; + + var _this = this; + + /** + * The RAF step function. + * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. + * + * @name Phaser.DOM.RequestAnimationFrame#step + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.step = function step (timestamp) + { + // DOMHighResTimeStamp + _this.lastTime = _this.tick; + + _this.tick = timestamp; + + _this.timeOutID = window.requestAnimationFrame(step); + + _this.callback(timestamp); + }; + + /** + * The SetTimeout step function. + * Updates the local tick value, invokes the callback and schedules another call to setTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#stepTimeout + * @type {function} + * @since 3.0.0 + */ + this.stepTimeout = function stepTimeout () + { + var d = Date.now(); + + var delay = Math.max(16 + _this.lastTime - d, 0); + + _this.lastTime = _this.tick; + + _this.tick = d; + + _this.timeOutID = window.setTimeout(stepTimeout, delay); + + _this.callback(d); + }; + }, + + /** + * Starts the requestAnimationFrame or setTimeout process running. + * + * @method Phaser.DOM.RequestAnimationFrame#start + * @since 3.0.0 + * + * @param {FrameRequestCallback} callback - The callback to invoke each step. + * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? + */ + start: function (callback, forceSetTimeOut) + { + if (this.isRunning) + { + return; + } + + this.callback = callback; + + this.isSetTimeOut = forceSetTimeOut; + + this.isRunning = true; + + this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); + }, + + /** + * Stops the requestAnimationFrame or setTimeout from running. + * + * @method Phaser.DOM.RequestAnimationFrame#stop + * @since 3.0.0 + */ + stop: function () + { + this.isRunning = false; + + if (this.isSetTimeOut) + { + clearTimeout(this.timeOutID); + } + else + { + window.cancelAnimationFrame(this.timeOutID); + } + }, + + /** + * Stops the step from running and clears the callback reference. + * + * @method Phaser.DOM.RequestAnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.callback = NOOP; + } + +}); + +module.exports = RequestAnimationFrame; + + +/***/ }), +/* 378 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Attempts to remove the element from its parentNode in the DOM. + * + * @function Phaser.DOM.RemoveFromDOM + * @since 3.0.0 + * + * @param {HTMLElement} element - The DOM element to remove from its parent node. + */ +var RemoveFromDOM = function (element) +{ + if (element.parentNode) + { + element.parentNode.removeChild(element); + } +}; + +module.exports = RemoveFromDOM; + + +/***/ }), +/* 379 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given data string and parses it as XML. + * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. + * The parsed XML object is returned, or `null` if there was an error while parsing the data. + * + * @function Phaser.DOM.ParseXML + * @since 3.0.0 + * + * @param {string} data - The XML source stored in a string. + * + * @return {?(DOMParser|ActiveXObject)} The parsed XML data, or `null` if the data could not be parsed. + */ +var ParseXML = function (data) +{ + var xml = ''; + + try + { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(data, 'text/xml'); + } + else + { + xml = new ActiveXObject('Microsoft.XMLDOM'); + xml.loadXML(data); + } + } + catch (e) + { + xml = null; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) + { + return null; + } + else + { + return xml; + } +}; + +module.exports = ParseXML; + + +/***/ }), +/* 380 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(101); + +/** + * @callback ContentLoadedCallback + */ + +/** + * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. + * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. + * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. + * + * @function Phaser.DOM.DOMContentLoaded + * @since 3.0.0 + * + * @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded. + */ +var DOMContentLoaded = function (callback) +{ + if (document.readyState === 'complete' || document.readyState === 'interactive') + { + callback(); + + return; + } + + var check = function () + { + document.removeEventListener('deviceready', check, true); + document.removeEventListener('DOMContentLoaded', check, true); + window.removeEventListener('load', check, true); + + callback(); + }; + + if (!document.body) + { + window.setTimeout(check, 20); + } + else if (OS.cordova && !OS.cocoonJS) + { + // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready + document.addEventListener('deviceready', check, false); + } + else + { + document.addEventListener('DOMContentLoaded', check, true); + window.addEventListener('load', check, true); + } +}; + +module.exports = DOMContentLoaded; + + +/***/ }), +/* 381 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts a hue to an RGB color. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HueToComponent + * @since 3.0.0 + * + * @param {number} p + * @param {number} q + * @param {number} t + * + * @return {number} The combined color value. + */ +var HueToComponent = function (p, q, t) +{ + if (t < 0) + { + t += 1; + } + + if (t > 1) + { + t -= 1; + } + + if (t < 1 / 6) + { + return p + (q - p) * 6 * t; + } + + if (t < 1 / 2) + { + return q; + } + + if (t < 2 / 3) + { + return p + (q - p) * (2 / 3 - t) * 6; + } + + return p; +}; + +module.exports = HueToComponent; + + +/***/ }), +/* 382 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns a string containing a hex representation of the given color component. + * + * @function Phaser.Display.Color.ComponentToHex + * @since 3.0.0 + * + * @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255. + * + * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. + */ +var ComponentToHex = function (color) +{ + var hex = color.toString(16); + + return (hex.length === 1) ? '0' + hex : hex; +}; + +module.exports = ComponentToHex; + + +/***/ }), +/* 383 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} InputColorObject + * + * @property {number} [r] - The red color value in the range 0 to 255. + * @property {number} [g] - The green color value in the range 0 to 255. + * @property {number} [b] - The blue color value in the range 0 to 255. + * @property {number} [a] - The alpha color value in the range 0 to 255. + */ + +/** + * @typedef {Object} ColorObject + * @property {number} r - The red color value in the range 0 to 255. + * @property {number} g - The green color value in the range 0 to 255. + * @property {number} b - The blue color value in the range 0 to 255. + * @property {number} a - The alpha color value in the range 0 to 255. + */ + +var Color = __webpack_require__(41); + +Color.ColorToRGBA = __webpack_require__(987); +Color.ComponentToHex = __webpack_require__(382); +Color.GetColor = __webpack_require__(195); +Color.GetColor32 = __webpack_require__(412); +Color.HexStringToColor = __webpack_require__(413); +Color.HSLToColor = __webpack_require__(986); +Color.HSVColorWheel = __webpack_require__(985); +Color.HSVToRGB = __webpack_require__(194); +Color.HueToComponent = __webpack_require__(381); +Color.IntegerToColor = __webpack_require__(410); +Color.IntegerToRGB = __webpack_require__(409); +Color.Interpolate = __webpack_require__(984); +Color.ObjectToColor = __webpack_require__(408); +Color.RandomRGB = __webpack_require__(983); +Color.RGBStringToColor = __webpack_require__(407); +Color.RGBToHSV = __webpack_require__(411); +Color.RGBToString = __webpack_require__(982); +Color.ValueToColor = __webpack_require__(196); + +module.exports = Color; + + +/***/ }), +/* 384 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Canvas.CanvasInterpolation + * @since 3.0.0 + */ +var CanvasInterpolation = { + + /** + * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setCrisp: function (canvas) + { + var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; + + types.forEach(function (type) + { + canvas.style['image-rendering'] = type; + }); + + canvas.style.msInterpolationMode = 'nearest-neighbor'; + + return canvas; + }, + + /** + * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setBicubic: function (canvas) + { + canvas.style['image-rendering'] = 'auto'; + canvas.style.msInterpolationMode = 'bicubic'; + + return canvas; + } + +}; + +module.exports = CanvasInterpolation; + + +/***/ }), +/* 385 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var CatmullRom = __webpack_require__(189); +var Class = __webpack_require__(0); +var Curve = __webpack_require__(80); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * [description] + * + * @class Spline + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} [points] - [description] + */ +var SplineCurve = new Class({ + + Extends: Curve, + + initialize: + + function SplineCurve (points) + { + if (points === undefined) { points = []; } + + Curve.call(this, 'SplineCurve'); + + /** + * [description] + * + * @name Phaser.Curves.Spline#points + * @type {Phaser.Math.Vector2[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + this.addPoints(points); + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#addPoints + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - [description] + * + * @return {Phaser.Curves.Spline} This curve object. + */ + addPoints: function (points) + { + for (var i = 0; i < points.length; i++) + { + var p = new Vector2(); + + if (typeof points[i] === 'number') + { + p.x = points[i]; + p.y = points[i + 1]; + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#addPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + addPoint: function (x, y) + { + var vec = new Vector2(x, y); + + this.points.push(vec); + + return vec; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Spline#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.points[0]); + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * this.points.length; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Spline#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var points = this.points; + + var point = (points.length - 1) * t; + + var intPoint = Math.floor(point); + + var weight = point - intPoint; + + var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; + var p1 = points[intPoint]; + var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; + var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; + + return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + var points = []; + + for (var i = 0; i < this.points.length; i++) + { + points.push(this.points[i].x); + points.push(this.points[i].y); + } + + return { + type: this.type, + points: points + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.Spline.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Spline} [description] + */ +SplineCurve.fromJSON = function (data) +{ + return new SplineCurve(data.points); +}; + +module.exports = SplineCurve; + + +/***/ }), +/* 386 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * p; +} + +function P1 (t, p) +{ + return 2 * (1 - t) * t * p; +} + +function P2 (t, p) +{ + return t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = end point + +// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js + +/** + * A quadratic bezier interpolation method. + * + * @function Phaser.Math.Interpolation.QuadraticBezier + * @since 3.2.0 + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} p0 - The start point. + * @param {number} p1 - The control point. + * @param {number} p2 - The end point. + * + * @return {number} The interpolated value. + */ +var QuadraticBezierInterpolation = function (t, p0, p1, p2) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2); +}; + +module.exports = QuadraticBezierInterpolation; + + +/***/ }), +/* 387 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(80); +var QuadraticBezierInterpolation = __webpack_require__(386); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * [description] + * + * @class QuadraticBezier + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.2.0 + * + * @param {(Phaser.Math.Vector2|number[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + */ +var QuadraticBezier = new Class({ + + Extends: Curve, + + initialize: + + function QuadraticBezier (p0, p1, p2) + { + Curve.call(this, 'QuadraticBezier'); + + if (Array.isArray(p0)) + { + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p1 = p1; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p2 = p2; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.QuadraticBezier#getStartPoint + * @since 3.2.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#getResolution + * @since 3.2.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.QuadraticBezier#getPoint + * @since 3.2.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + + return out.set( + QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), + QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) + ); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#draw + * @since 3.2.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - `Graphics` object to draw onto. + * @param {integer} [pointsTotal=32] - Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. + * + * @return {Phaser.GameObjects.Graphics} `Graphics` object that was drawn to. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * Converts the curve into a JSON compatible object. + * + * @method Phaser.Curves.QuadraticBezier#toJSON + * @since 3.2.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y + ] + }; + } + +}); + +/** + * Creates a curve from a JSON object, e. g. created by `toJSON`. + * + * @function Phaser.Curves.QuadraticBezier.fromJSON + * @since 3.2.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.QuadraticBezier} The created curve instance. + */ +QuadraticBezier.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + + return new QuadraticBezier(p0, p1, p2); +}; + +module.exports = QuadraticBezier; + + +/***/ }), +/* 388 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(80); +var FromPoints = __webpack_require__(191); +var Rectangle = __webpack_require__(10); +var Vector2 = __webpack_require__(3); + +var tmpVec2 = new Vector2(); + +/** + * @classdesc + * [description] + * + * @class Line + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|number[])} p0 - [description] + * @param {Phaser.Math.Vector2} [p1] - [description] + */ +var LineCurve = new Class({ + + Extends: Curve, + + initialize: + + // vec2s or array + function LineCurve (p0, p1) + { + Curve.call(this, 'LineCurve'); + + if (Array.isArray(p0)) + { + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.Line#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.Line#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + }, + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * @method Phaser.Curves.Line#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the bounds in. If not given a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. + */ + getBounds: function (out) + { + if (out === undefined) { out = new Rectangle(); } + + return FromPoints([ this.p0, this.p1 ], out); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Line#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.Line#getResolution + * @since 3.0.0 + * + * @param {number} [divisions=1] - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + if (divisions === undefined) { divisions = 1; } + + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Line#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + if (t === 1) + { + return out.copy(this.p1); + } + + out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); + + return out; + }, + + // Line curve is linear, so we can overwrite default getPointAt + + /** + * [description] + * + * @method Phaser.Curves.Line#getPointAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.Line#getTangent + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @return {Phaser.Math.Vector2} [description] + */ + getTangent: function () + { + var tangent = tmpVec2.copy(this.p1).subtract(this.p0); + + return tangent.normalize(); + }, + + // Override default Curve.draw because this is better than calling getPoints on a line! + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.Line#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. + */ + draw: function (graphics) + { + graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); + + // So you can chain graphics calls + return graphics; + }, + + /** + * [description] + * + * @method Phaser.Curves.Line#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y + ] + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.Line.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Line} [description] + */ +LineCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + + return new LineCurve(p0, p1); +}; + +module.exports = LineCurve; + + +/***/ }), +/* 389 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(80); +var DegToRad = __webpack_require__(36); +var GetValue = __webpack_require__(4); +var RadToDeg = __webpack_require__(190); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} JSONEllipseCurve + * + * @property {string} type - The of the curve. + * @property {number} x - The x coordinate of the ellipse. + * @property {number} y - The y coordinate of the ellipse. + * @property {number} xRadius - The horizontal radius of ellipse. + * @property {number} yRadius - The vertical radius of ellipse. + * @property {integer} startAngle - The start angle of the ellipse, in degrees. + * @property {integer} endAngle - The end angle of the ellipse, in degrees. + * @property {boolean} clockwise - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @property {integer} rotation - The rotation of ellipse, in degrees. + */ + +/** + * @typedef {object} EllipseCurveConfig + * + * @property {number} [x=0] - The x coordinate of the ellipse. + * @property {number} [y=0] - The y coordinate of the ellipse. + * @property {number} [xRadius=0] - The horizontal radius of the ellipse. + * @property {number} [yRadius=0] - The vertical radius of the ellipse. + * @property {integer} [startAngle=0] - The start angle of the ellipse, in degrees. + * @property {integer} [endAngle=360] - The end angle of the ellipse, in degrees. + * @property {boolean} [clockwise=false] - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @property {integer} [rotation=0] - The rotation of the ellipse, in degrees. + */ + +/** + * @classdesc + * An Elliptical Curve derived from the Base Curve class. + * + * See https://en.wikipedia.org/wiki/Elliptic_curve for more details. + * + * @class Ellipse + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(number|EllipseCurveConfig)} [x=0] - The x coordinate of the ellipse, or an Ellipse Curve configuration object. + * @param {number} [y=0] - The y coordinate of the ellipse. + * @param {number} [xRadius=0] - The horizontal radius of ellipse. + * @param {number} [yRadius=0] - The vertical radius of ellipse. + * @param {integer} [startAngle=0] - The start angle of the ellipse, in degrees. + * @param {integer} [endAngle=360] - The end angle of the ellipse, in degrees. + * @param {boolean} [clockwise=false] - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @param {integer} [rotation=0] - The rotation of the ellipse, in degrees. + */ +var EllipseCurve = new Class({ + + Extends: Curve, + + initialize: + + function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + if (typeof x === 'object') + { + var config = x; + + x = GetValue(config, 'x', 0); + y = GetValue(config, 'y', 0); + xRadius = GetValue(config, 'xRadius', 0); + yRadius = GetValue(config, 'yRadius', xRadius); + startAngle = GetValue(config, 'startAngle', 0); + endAngle = GetValue(config, 'endAngle', 360); + clockwise = GetValue(config, 'clockwise', false); + rotation = GetValue(config, 'rotation', 0); + } + else + { + if (yRadius === undefined) { yRadius = xRadius; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (clockwise === undefined) { clockwise = false; } + if (rotation === undefined) { rotation = 0; } + } + + Curve.call(this, 'EllipseCurve'); + + // Center point + + /** + * The center point of the ellipse. Used for calculating rotation. + * + * @name Phaser.Curves.Ellipse#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + + /** + * The horizontal radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#_xRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._xRadius = xRadius; + + /** + * The vertical radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#_yRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._yRadius = yRadius; + + // Radians + + /** + * The starting angle of the ellipse in radians. + * + * @name Phaser.Curves.Ellipse#_startAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._startAngle = DegToRad(startAngle); + + /** + * The end angle of the ellipse in radians. + * + * @name Phaser.Curves.Ellipse#_endAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._endAngle = DegToRad(endAngle); + + /** + * Anti-clockwise direction. + * + * @name Phaser.Curves.Ellipse#_clockwise + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._clockwise = clockwise; + + /** + * The rotation of the arc. + * + * @name Phaser.Curves.Ellipse#_rotation + * @type {number} + * @private + * @since 3.0.0 + */ + this._rotation = DegToRad(rotation); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Ellipse#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(0, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.Ellipse#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * 2; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Ellipse#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var twoPi = Math.PI * 2; + var deltaAngle = this._endAngle - this._startAngle; + var samePoints = Math.abs(deltaAngle) < Number.EPSILON; + + // ensures that deltaAngle is 0 .. 2 PI + while (deltaAngle < 0) + { + deltaAngle += twoPi; + } + + while (deltaAngle > twoPi) + { + deltaAngle -= twoPi; + } + + if (deltaAngle < Number.EPSILON) + { + if (samePoints) + { + deltaAngle = 0; + } + else + { + deltaAngle = twoPi; + } + } + + if (this._clockwise && !samePoints) + { + if (deltaAngle === twoPi) + { + deltaAngle = - twoPi; + } + else + { + deltaAngle = deltaAngle - twoPi; + } + } + + var angle = this._startAngle + t * deltaAngle; + var x = this.p0.x + this._xRadius * Math.cos(angle); + var y = this.p0.y + this._yRadius * Math.sin(angle); + + if (this._rotation !== 0) + { + var cos = Math.cos(this._rotation); + var sin = Math.sin(this._rotation); + + var tx = x - this.p0.x; + var ty = y - this.p0.y; + + // Rotate the point about the center of the ellipse. + x = tx * cos - ty * sin + this.p0.x; + y = tx * sin + ty * cos + this.p0.y; + } + + return out.set(x, y); + }, + + /** + * Sets the horizontal radius of this curve. + * + * @method Phaser.Curves.Ellipse#setXRadius + * @since 3.0.0 + * + * @param {number} value - The horizontal radius of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setXRadius: function (value) + { + this.xRadius = value; + + return this; + }, + + /** + * Sets the vertical radius of this curve. + * + * @method Phaser.Curves.Ellipse#setYRadius + * @since 3.0.0 + * + * @param {number} value - The vertical radius of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setYRadius: function (value) + { + this.yRadius = value; + + return this; + }, + + /** + * Sets the width of this curve. + * + * @method Phaser.Curves.Ellipse#setWidth + * @since 3.0.0 + * + * @param {number} value - The width of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setWidth: function (value) + { + this.xRadius = value * 2; + + return this; + }, + + /** + * Sets the height of this curve. + * + * @method Phaser.Curves.Ellipse#setHeight + * @since 3.0.0 + * + * @param {number} value - The height of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setHeight: function (value) + { + this.yRadius = value * 2; + + return this; + }, + + /** + * Sets the start angle of this curve. + * + * @method Phaser.Curves.Ellipse#setStartAngle + * @since 3.0.0 + * + * @param {number} value - The start angle of this curve, in radians. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setStartAngle: function (value) + { + this.startAngle = value; + + return this; + }, + + /** + * Sets the end angle of this curve. + * + * @method Phaser.Curves.Ellipse#setEndAngle + * @since 3.0.0 + * + * @param {number} value - The end angle of this curve, in radians. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setEndAngle: function (value) + { + this.endAngle = value; + + return this; + }, + + /** + * Sets if this curve extends clockwise or anti-clockwise. + * + * @method Phaser.Curves.Ellipse#setClockwise + * @since 3.0.0 + * + * @param {boolean} value - The clockwise state of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setClockwise: function (value) + { + this.clockwise = value; + + return this; + }, + + /** + * Sets the rotation of this curve. + * + * @method Phaser.Curves.Ellipse#setRotation + * @since 3.0.0 + * + * @param {number} value - The rotation of this curve, in radians. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setRotation: function (value) + { + this.rotation = value; + + return this; + }, + + /** + * The x coordinate of the center of the ellipse. + * + * @name Phaser.Curves.Ellipse#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.p0.x; + }, + + set: function (value) + { + this.p0.x = value; + } + + }, + + /** + * The y coordinate of the center of the ellipse. + * + * @name Phaser.Curves.Ellipse#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.p0.y; + }, + + set: function (value) + { + this.p0.y = value; + } + + }, + + /** + * The horizontal radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#xRadius + * @type {number} + * @since 3.0.0 + */ + xRadius: { + + get: function () + { + return this._xRadius; + }, + + set: function (value) + { + this._xRadius = value; + } + + }, + + /** + * The vertical radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#yRadius + * @type {number} + * @since 3.0.0 + */ + yRadius: { + + get: function () + { + return this._yRadius; + }, + + set: function (value) + { + this._yRadius = value; + } + + }, + + /** + * The start angle of the ellipse in degrees. + * + * @name Phaser.Curves.Ellipse#startAngle + * @type {number} + * @since 3.0.0 + */ + startAngle: { + + get: function () + { + return RadToDeg(this._startAngle); + }, + + set: function (value) + { + this._startAngle = DegToRad(value); + } + + }, + + /** + * The end angle of the ellipse in degrees. + * + * @name Phaser.Curves.Ellipse#endAngle + * @type {number} + * @since 3.0.0 + */ + endAngle: { + + get: function () + { + return RadToDeg(this._endAngle); + }, + + set: function (value) + { + this._endAngle = DegToRad(value); + } + + }, + + /** + * `true` if the ellipse rotation is clockwise or `false` if anti-clockwise. + * + * @name Phaser.Curves.Ellipse#clockwise + * @type {boolean} + * @since 3.0.0 + */ + clockwise: { + + get: function () + { + return this._clockwise; + }, + + set: function (value) + { + this._clockwise = value; + } + + }, + + /** + * The rotation of the ellipse, relative to the center, in degrees. + * + * @name Phaser.Curves.Ellipse#angle + * @type {number} + * @since 3.14.0 + */ + angle: { + + get: function () + { + return RadToDeg(this._rotation); + }, + + set: function (value) + { + this._rotation = DegToRad(value); + } + + }, + + /** + * The rotation of the ellipse, relative to the center, in radians. + * + * @name Phaser.Curves.Ellipse#rotation + * @type {number} + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = value; + } + + }, + + /** + * JSON serialization of the curve. + * + * @method Phaser.Curves.Ellipse#toJSON + * @since 3.0.0 + * + * @return {JSONEllipseCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + x: this.p0.x, + y: this.p0.y, + xRadius: this._xRadius, + yRadius: this._yRadius, + startAngle: RadToDeg(this._startAngle), + endAngle: RadToDeg(this._endAngle), + clockwise: this._clockwise, + rotation: RadToDeg(this._rotation) + }; + } + +}); + +/** + * Creates a curve from the provided Ellipse Curve Configuration object. + * + * @function Phaser.Curves.Ellipse.fromJSON + * @since 3.0.0 + * + * @param {JSONEllipseCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Ellipse} The ellipse curve constructed from the configuration object. + */ +EllipseCurve.fromJSON = function (data) +{ + return new EllipseCurve(data); +}; + +module.exports = EllipseCurve; + + +/***/ }), +/* 390 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * k * p; +} + +function P1 (t, p) +{ + var k = 1 - t; + + return 3 * k * k * t * p; +} + +function P2 (t, p) +{ + return 3 * (1 - t) * t * t * p; +} + +function P3 (t, p) +{ + return t * t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = control point 2 +// p3 = end point + +// https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a + +/** + * A cubic bezier interpolation method. + * + * @function Phaser.Math.Interpolation.CubicBezier + * @since 3.0.0 + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} p0 - The start point. + * @param {number} p1 - The first control point. + * @param {number} p2 - The second control point. + * @param {number} p3 - The end point. + * + * @return {number} The interpolated value. + */ +var CubicBezierInterpolation = function (t, p0, p1, p2, p3) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2) + P3(t, p3); +}; + +module.exports = CubicBezierInterpolation; + + +/***/ }), +/* 391 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var CubicBezier = __webpack_require__(390); +var Curve = __webpack_require__(80); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A higher-order Bézier curve constructed of four points. + * + * @class CubicBezier + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + * @param {Phaser.Math.Vector2} p3 - End Point. + */ +var CubicBezierCurve = new Class({ + + Extends: Curve, + + initialize: + + function CubicBezierCurve (p0, p1, p2, p3) + { + Curve.call(this, 'CubicBezierCurve'); + + if (Array.isArray(p0)) + { + p3 = new Vector2(p0[6], p0[7]); + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * The start point of this curve. + * + * @name Phaser.Curves.CubicBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * The first control point of this curve. + * + * @name Phaser.Curves.CubicBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + + /** + * The second control point of this curve. + * + * @name Phaser.Curves.CubicBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p2 = p2; + + /** + * The end point of this curve. + * + * @name Phaser.Curves.CubicBezier#p3 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p3 = p3; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.CubicBezier#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * Returns the resolution of this curve. + * + * @method Phaser.Curves.CubicBezier#getResolution + * @since 3.0.0 + * + * @param {number} divisions - The amount of divisions used by this curve. + * + * @return {number} The resolution of the curve. + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.CubicBezier#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + var p3 = this.p3; + + return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * Draws this curve to the specified graphics object. + * + * @method Phaser.Curves.CubicBezier#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The graphics object this curve should be drawn to. + * @param {integer} [pointsTotal=32] - The number of intermediary points that make up this curve. A higher number of points will result in a smoother curve. + * + * @return {Phaser.GameObjects.Graphics} The graphics object this curve was drawn to. Useful for method chaining. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * Returns a JSON object that describes this curve. + * + * @method Phaser.Curves.CubicBezier#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y, + this.p3.x, this.p3.y + ] + }; + } + +}); + +/** + * Generates a curve from a JSON object. + * + * @function Phaser.Curves.CubicBezier.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.CubicBezier} The curve generated from the JSON object. + */ +CubicBezierCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + var p3 = new Vector2(points[6], points[7]); + + return new CubicBezierCurve(p0, p1, p2, p3); +}; + +module.exports = CubicBezierCurve; + + +/***/ }), +/* 392 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.ARNE16 + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#9D9D9D', + 2: '#FFF', + 3: '#BE2633', + 4: '#E06F8B', + 5: '#493C2B', + 6: '#A46422', + 7: '#EB8931', + 8: '#F7E26B', + 9: '#2F484E', + A: '#44891A', + B: '#A3CE27', + C: '#1B2632', + D: '#005784', + E: '#31A2F2', + F: '#B2DCEF' +}; + + +/***/ }), +/* 393 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Arne16 = __webpack_require__(392); +var CanvasPool = __webpack_require__(26); +var GetValue = __webpack_require__(4); + +/** + * @callback GenerateTextureRendererCallback + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {CanvasRenderingContext2D} context - [description] + */ + +/** + * @typedef {object} GenerateTextureConfig + * + * @property {array} [data=[]] - [description] + * @property {HTMLCanvasElement} [canvas=null] - [description] + * @property {Palette} [palette=Arne16] - [description] + * @property {number} [pixelWidth=1] - The width of each 'pixel' in the generated texture. + * @property {number} [pixelHeight=1] - The height of each 'pixel' in the generated texture. + * @property {boolean} [resizeCanvas=true] - [description] + * @property {boolean} [clearCanvas=true] - [description] + * @property {GenerateTextureRendererCallback} [preRender] - [description] + * @property {GenerateTextureRendererCallback} [postRender] - [description] + */ + +/** + * [description] + * + * @function Phaser.Create.GenerateTexture + * @since 3.0.0 + * + * @param {GenerateTextureConfig} config - [description] + * + * @return {HTMLCanvasElement} [description] + */ +var GenerateTexture = function (config) +{ + var data = GetValue(config, 'data', []); + var canvas = GetValue(config, 'canvas', null); + var palette = GetValue(config, 'palette', Arne16); + var pixelWidth = GetValue(config, 'pixelWidth', 1); + var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); + var resizeCanvas = GetValue(config, 'resizeCanvas', true); + var clearCanvas = GetValue(config, 'clearCanvas', true); + var preRender = GetValue(config, 'preRender', null); + var postRender = GetValue(config, 'postRender', null); + + var width = Math.floor(Math.abs(data[0].length * pixelWidth)); + var height = Math.floor(Math.abs(data.length * pixelHeight)); + + if (!canvas) + { + canvas = CanvasPool.create2D(this, width, height); + resizeCanvas = false; + clearCanvas = false; + } + + if (resizeCanvas) + { + canvas.width = width; + canvas.height = height; + } + + var ctx = canvas.getContext('2d'); + + if (clearCanvas) + { + ctx.clearRect(0, 0, width, height); + } + + // preRender Callback? + if (preRender) + { + preRender(canvas, ctx); + } + + // Draw it + for (var y = 0; y < data.length; y++) + { + var row = data[y]; + + for (var x = 0; x < row.length; x++) + { + var d = row[x]; + + if (d !== '.' && d !== ' ') + { + ctx.fillStyle = palette[d]; + ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); + } + } + } + + // postRender Callback? + if (postRender) + { + postRender(canvas, ctx); + } + + return canvas; +}; + +module.exports = GenerateTexture; + + +/***/ }), +/* 394 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Stepped + */ + +module.exports = __webpack_require__(1024); + + +/***/ }), +/* 395 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Sine + */ + +module.exports = { + + In: __webpack_require__(1027), + Out: __webpack_require__(1026), + InOut: __webpack_require__(1025) + +}; + + +/***/ }), +/* 396 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Quintic + */ + +module.exports = { + + In: __webpack_require__(1030), + Out: __webpack_require__(1029), + InOut: __webpack_require__(1028) + +}; + + +/***/ }), +/* 397 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Quartic + */ + +module.exports = { + + In: __webpack_require__(1033), + Out: __webpack_require__(1032), + InOut: __webpack_require__(1031) + +}; + + +/***/ }), +/* 398 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Quadratic + */ + +module.exports = { + + In: __webpack_require__(1036), + Out: __webpack_require__(1035), + InOut: __webpack_require__(1034) + +}; + + +/***/ }), +/* 399 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Linear + */ + +module.exports = __webpack_require__(1037); + + +/***/ }), +/* 400 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Expo + */ + +module.exports = { + + In: __webpack_require__(1040), + Out: __webpack_require__(1039), + InOut: __webpack_require__(1038) + +}; + + +/***/ }), +/* 401 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Elastic + */ + +module.exports = { + + In: __webpack_require__(1043), + Out: __webpack_require__(1042), + InOut: __webpack_require__(1041) + +}; + + +/***/ }), +/* 402 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Cubic + */ + +module.exports = { + + In: __webpack_require__(1046), + Out: __webpack_require__(1045), + InOut: __webpack_require__(1044) + +}; + + +/***/ }), +/* 403 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Circular + */ + +module.exports = { + + In: __webpack_require__(1049), + Out: __webpack_require__(1048), + InOut: __webpack_require__(1047) + +}; + + +/***/ }), +/* 404 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Bounce + */ + +module.exports = { + + In: __webpack_require__(1052), + Out: __webpack_require__(1051), + InOut: __webpack_require__(1050) + +}; + + +/***/ }), +/* 405 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Back + */ + +module.exports = { + + In: __webpack_require__(1055), + Out: __webpack_require__(1054), + InOut: __webpack_require__(1053) + +}; + + +/***/ }), +/* 406 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @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: __webpack_require__(1058), + Flash: __webpack_require__(1057), + Pan: __webpack_require__(1056), + Shake: __webpack_require__(1023), + Zoom: __webpack_require__(1022) + +}; + + +/***/ }), +/* 407 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); + +/** + * Converts a CSS 'web' string into a Phaser Color object. + * + * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * + * @function Phaser.Display.Color.RGBStringToColor + * @since 3.0.0 + * + * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. + * + * @return {Phaser.Display.Color} A Color object. + */ +var RGBStringToColor = function (rgb) +{ + var color = new Color(); + + var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); + + if (result) + { + var r = parseInt(result[1], 10); + var g = parseInt(result[2], 10); + var b = parseInt(result[3], 10); + var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; + + color.setTo(r, g, b, a * 255); + } + + return color; +}; + +module.exports = RGBStringToColor; + + +/***/ }), +/* 408 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); + +/** + * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. + * + * @function Phaser.Display.Color.ObjectToColor + * @since 3.0.0 + * + * @param {InputColorObject} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. + * + * @return {Phaser.Display.Color} A Color object. + */ +var ObjectToColor = function (input) +{ + return new Color(input.r, input.g, input.b, input.a); +}; + +module.exports = ObjectToColor; + + +/***/ }), +/* 409 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * + * Alpha will only be set if it exists in the given color (0xAARRGGBB) + * + * @function Phaser.Display.Color.IntegerToRGB + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + */ +var IntegerToRGB = function (color) +{ + if (color > 16777215) + { + // The color value has an alpha component + return { + a: color >>> 24, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } + else + { + return { + a: 255, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } +}; + +module.exports = IntegerToRGB; + + +/***/ }), +/* 410 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); +var IntegerToRGB = __webpack_require__(409); + +/** + * Converts the given color value into an instance of a Color object. + * + * @function Phaser.Display.Color.IntegerToColor + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {Phaser.Display.Color} A Color object. + */ +var IntegerToColor = function (input) +{ + var rgb = IntegerToRGB(input); + + return new Color(rgb.r, rgb.g, rgb.b, rgb.a); +}; + +module.exports = IntegerToColor; + + +/***/ }), +/* 411 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} HSVColorObject + * + * @property {number} h - The hue color value. A number between 0 and 1 + * @property {number} s - The saturation color value. A number between 0 and 1 + * @property {number} v - The lightness color value. A number between 0 and 1 + */ + +/** + * Converts an RGB color value to HSV (hue, saturation and value). + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.RGBToHSV + * @since 3.0.0 + * + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * @param {(HSVColorObject|Phaser.Display.Color)} [out] - An object to store the color values in. If not given an HSV Color Object will be created. + * + * @return {(HSVColorObject|Phaser.Display.Color)} An object with the properties `h`, `s` and `v` set. + */ +var RGBToHSV = function (r, g, b, out) +{ + if (out === undefined) { out = { h: 0, s: 0, v: 0 }; } + + r /= 255; + g /= 255; + b /= 255; + + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var d = max - min; + + // achromatic by default + var h = 0; + var s = (max === 0) ? 0 : d / max; + var v = max; + + if (max !== min) + { + if (max === r) + { + h = (g - b) / d + ((g < b) ? 6 : 0); + } + else if (max === g) + { + h = (b - r) / d + 2; + } + else if (max === b) + { + h = (r - g) / d + 4; + } + + h /= 6; + } + + if (out.hasOwnProperty('_h')) + { + out._h = h; + out._s = s; + out._v = v; + } + else + { + out.h = h; + out.s = s; + out.v = v; + } + + return out; +}; + +module.exports = RGBToHSV; + + +/***/ }), +/* 412 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given an alpha and 3 color values this will return an integer representation of it. + * + * @function Phaser.Display.Color.GetColor32 + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} alpha - The alpha color value. A number between 0 and 255. + * + * @return {number} The combined color value. + */ +var GetColor32 = function (red, green, blue, alpha) +{ + return alpha << 24 | red << 16 | green << 8 | blue; +}; + +module.exports = GetColor32; + + +/***/ }), +/* 413 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); + +/** + * Converts a hex string into a Phaser Color object. + * + * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. + * + * An alpha channel is _not_ supported. + * + * @function Phaser.Display.Color.HexStringToColor + * @since 3.0.0 + * + * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. + * + * @return {Phaser.Display.Color} A Color object populated by the values of the given string. + */ +var HexStringToColor = function (hex) +{ + var color = new Color(); + + // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") + hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) + { + return r + r + g + g + b + b; + }); + + var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); + + if (result) + { + var r = parseInt(result[1], 16); + var g = parseInt(result[2], 16); + var b = parseInt(result[3], 16); + + color.setTo(r, g, b); + } + + return color; +}; + +module.exports = HexStringToColor; + + +/***/ }), +/* 414 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCamera = __webpack_require__(131); +var CanvasPool = __webpack_require__(26); +var CenterOn = __webpack_require__(193); +var Clamp = __webpack_require__(24); +var Class = __webpack_require__(0); +var Components = __webpack_require__(16); +var Effects = __webpack_require__(406); +var Linear = __webpack_require__(129); +var Rectangle = __webpack_require__(10); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Camera. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * A Camera also has built-in special effects including Fade, Flash and Camera Shake. + * + * @class Camera + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Cameras.Scene2D.BaseCamera + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.Tint + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var Camera = new Class({ + + Extends: BaseCamera, + + Mixins: [ + Components.Flip, + Components.Tint + ], + + initialize: + + function Camera (x, y, width, height) + { + BaseCamera.call(this, x, y, width, height); + + /** + * Does this Camera allow the Game Objects it renders to receive input events? + * + * @name Phaser.Cameras.Scene2D.Camera#inputEnabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.inputEnabled = true; + + /** + * The Camera Fade effect handler. + * To fade this camera see the `Camera.fade` methods. + * + * @name Phaser.Cameras.Scene2D.Camera#fadeEffect + * @type {Phaser.Cameras.Scene2D.Effects.Fade} + * @since 3.5.0 + */ + this.fadeEffect = new Effects.Fade(this); + + /** + * The Camera Flash effect handler. + * To flash this camera see the `Camera.flash` method. + * + * @name Phaser.Cameras.Scene2D.Camera#flashEffect + * @type {Phaser.Cameras.Scene2D.Effects.Flash} + * @since 3.5.0 + */ + this.flashEffect = new Effects.Flash(this); + + /** + * The Camera Shake effect handler. + * To shake this camera see the `Camera.shake` method. + * + * @name Phaser.Cameras.Scene2D.Camera#shakeEffect + * @type {Phaser.Cameras.Scene2D.Effects.Shake} + * @since 3.5.0 + */ + this.shakeEffect = new Effects.Shake(this); + + /** + * The Camera Pan effect handler. + * To pan this camera see the `Camera.pan` method. + * + * @name Phaser.Cameras.Scene2D.Camera#panEffect + * @type {Phaser.Cameras.Scene2D.Effects.Pan} + * @since 3.11.0 + */ + this.panEffect = new Effects.Pan(this); + + /** + * The Camera Zoom effect handler. + * To zoom this camera see the `Camera.zoom` method. + * + * @name Phaser.Cameras.Scene2D.Camera#zoomEffect + * @type {Phaser.Cameras.Scene2D.Effects.Zoom} + * @since 3.11.0 + */ + this.zoomEffect = new Effects.Zoom(this); + + /** + * The linear interpolation value to use when following a target. + * + * Can also be set via `setLerp` or as part of the `startFollow` call. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * + * @name Phaser.Cameras.Scene2D.Camera#lerp + * @type {Phaser.Math.Vector2} + * @since 3.9.0 + */ + this.lerp = new Vector2(1, 1); + + /** + * The values stored in this property are subtracted from the Camera targets position, allowing you to + * offset the camera from the actual target x/y coordinates by this amount. + * Can also be set via `setFollowOffset` or as part of the `startFollow` call. + * + * @name Phaser.Cameras.Scene2D.Camera#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.9.0 + */ + this.followOffset = new Vector2(); + + /** + * The Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * You can directly set this property to be an instance of a Rectangle. Or, you can use the + * `setDeadzone` method for a chainable approach. + * + * The rectangle you provide can have its dimensions adjusted dynamically, however, please + * note that its position is updated every frame, as it is constantly re-centered on the cameras mid point. + * + * Calling `setDeadzone` with no arguments will reset an active deadzone, as will setting this property + * to `null`. + * + * @name Phaser.Cameras.Scene2D.Camera#deadzone + * @type {?Phaser.Geom.Rectangle} + * @since 3.11.0 + */ + this.deadzone = null; + + /** + * Internal follow target reference. + * + * @name Phaser.Cameras.Scene2D.Camera#_follow + * @type {?any} + * @private + * @default null + * @since 3.0.0 + */ + this._follow = null; + + /** + * Is this Camera rendering directly to the canvas or to a texture? + * + * Enable rendering to texture with the method `setRenderToTexture` (just enabling this boolean won't be enough) + * + * Once enabled you can toggle it by switching this property. + * + * To properly remove a render texture you should call the `clearRenderToTexture()` method. + * + * @name Phaser.Cameras.Scene2D.Camera#renderToTexture + * @type {boolean} + * @default false + * @since 3.13.0 + */ + this.renderToTexture = false; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the HTML Canvas Element that the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#canvas + * @type {HTMLCanvasElement} + * @since 3.13.0 + */ + this.canvas = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the Rendering Context belonging to the Canvas element the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#context + * @type {CanvasRenderingContext2D} + * @since 3.13.0 + */ + this.context = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Texture belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#framebuffer + * @type {?WebGLTexture} + * @since 3.13.0 + */ + this.glTexture = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Frame Buffer belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#framebuffer + * @type {?WebGLFramebuffer} + * @since 3.13.0 + */ + this.framebuffer = null; + + /** + * If this Camera has been set to render to a texture and to use a custom pipeline, + * then this holds a reference to the pipeline the Camera is drawing with. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#pipeline + * @type {any} + * @since 3.13.0 + */ + this.pipeline = null; + }, + + /** + * Sets the Camera to render to a texture instead of to the main canvas. + * + * The Camera will redirect all Game Objects it's asked to render to this texture. + * + * During the render sequence, the texture itself will then be rendered to the main canvas. + * + * Doing this gives you the ability to modify the texture before this happens, + * allowing for special effects such as Camera specific shaders, or post-processing + * on the texture. + * + * If running under Canvas the Camera will render to its `canvas` property. + * + * If running under WebGL the Camera will create a frame buffer, which is stored in its `framebuffer` and `glTexture` properties. + * + * If you set a camera to render to a texture then it will emit 2 events during the render loop: + * + * First, it will emit the event `prerender`. This happens right before any Game Object's are drawn to the Camera texture. + * + * Then, it will emit the event `postrender`. This happens after all Game Object's have been drawn, but right before the + * Camera texture is rendered to the main game canvas. It's the final point at which you can manipulate the texture before + * it appears in-game. + * + * You should not enable this unless you plan on actually using the texture it creates + * somehow, otherwise you're just doubling the work required to render your game. + * + * To temporarily disable rendering to a texture, toggle the `renderToTexture` boolean. + * + * If you no longer require the Camera to render to a texture, call the `clearRenderToTexture` method, + * which will delete the respective textures and free-up resources. + * + * @method Phaser.Cameras.Scene2D.Camera#setRenderToTexture + * @since 3.13.0 + * + * @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} [pipeline] - An optional WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setRenderToTexture: function (pipeline) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl) + { + this.glTexture = renderer.createTextureFromSource(null, this.width, this.height, 0); + this.framebuffer = renderer.createFramebuffer(this.width, this.height, this.glTexture, false); + } + else + { + this.canvas = CanvasPool.create2D(this, this.width, this.height); + this.context = this.canvas.getContext('2d'); + } + + this.renderToTexture = true; + + if (pipeline) + { + this.setPipeline(pipeline); + } + + return this; + }, + + /** + * Sets the WebGL pipeline this Camera is using when rendering to a texture. + * + * You can pass either the string-based name of the pipeline, or a reference to the pipeline itself. + * + * Call this method with no arguments to clear any previously set pipeline. + * + * @method Phaser.Cameras.Scene2D.Camera#setPipeline + * @since 3.13.0 + * + * @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} [pipeline] - The WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. Or if left empty it will clear the pipeline. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setPipeline: function (pipeline) + { + if (typeof pipeline === 'string') + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl && renderer.hasPipeline(pipeline)) + { + this.pipeline = renderer.getPipeline(pipeline); + } + } + else + { + this.pipeline = pipeline; + } + + return this; + }, + + /** + * If this Camera was set to render to a texture, this will clear the resources it was using and + * redirect it to render back to the primary Canvas again. + * + * If you only wish to temporarily disable rendering to a texture then you can toggle the + * property `renderToTexture` instead. + * + * @method Phaser.Cameras.Scene2D.Camera#clearRenderToTexture + * @since 3.13.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + clearRenderToTexture: function () + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl) + { + if (this.framebuffer) + { + renderer.deleteFramebuffer(this.framebuffer); + } + + if (this.glTexture) + { + renderer.deleteTexture(this.glTexture); + } + + this.framebuffer = null; + this.glTexture = null; + this.pipeline = null; + } + else + { + CanvasPool.remove(this); + + this.canvas = null; + this.context = null; + } + + this.renderToTexture = false; + + return this; + }, + + /** + * Sets the Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point + * of the camera. This allows you to use the object for additional game related checks, such as + * testing if an object is within it or not via a Rectangle.contains call. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * Calling this method with no arguments will reset an active deadzone. + * + * @method Phaser.Cameras.Scene2D.Camera#setDeadzone + * @since 3.11.0 + * + * @param {number} [width] - The width of the deadzone rectangle in pixels. If not specified the deadzone is removed. + * @param {number} [height] - The height of the deadzone rectangle in pixels. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setDeadzone: function (width, height) + { + if (width === undefined) + { + this.deadzone = null; + } + else + { + if (this.deadzone) + { + this.deadzone.width = width; + this.deadzone.height = height; + } + else + { + this.deadzone = new Rectangle(0, 0, width, height); + } + + if (this._follow) + { + var originX = this.width / 2; + var originY = this.height / 2; + + var fx = this._follow.x - this.followOffset.x; + var fy = this._follow.y - this.followOffset.y; + + this.midPoint.set(fx, fy); + + this.scrollX = fx - originX; + this.scrollY = fy - originY; + } + + CenterOn(this.deadzone, this.midPoint.x, this.midPoint.y); + } + + return this; + }, + + /** + * Fades the Camera in from the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeIn + * @since 3.3.0 + * + * @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 {function} [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} This Camera instance. + */ + fadeIn: function (duration, red, green, blue, callback, context) + { + return this.fadeEffect.start(false, duration, red, green, blue, true, callback, context); + }, + + /** + * Fades the Camera out to the given color over the duration specified. + * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeOut + * @since 3.3.0 + * + * @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 {function} [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} This Camera instance. + */ + fadeOut: function (duration, red, green, blue, callback, context) + { + return this.fadeEffect.start(true, duration, red, green, blue, true, callback, context); + }, + + /** + * Fades the Camera from the given color to transparent over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeFrom + * @since 3.5.0 + * + * @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 {function} [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} This Camera instance. + */ + fadeFrom: function (duration, red, green, blue, force, callback, context) + { + return this.fadeEffect.start(false, duration, red, green, blue, force, callback, context); + }, + + /** + * Fades the Camera from transparent to the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fade + * @since 3.0.0 + * + * @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 {function} [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} This Camera instance. + */ + fade: function (duration, red, green, blue, force, callback, context) + { + return this.fadeEffect.start(true, duration, red, green, blue, force, callback, context); + }, + + /** + * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#flash + * @since 3.0.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 {function} [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} This Camera instance. + */ + flash: function (duration, red, green, blue, force, callback, context) + { + return this.flashEffect.start(duration, red, green, blue, force, callback, context); + }, + + /** + * Shakes the Camera by the given intensity over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#shake + * @since 3.0.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 {function} [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} This Camera instance. + */ + shake: function (duration, intensity, force, callback, context) + { + return this.shakeEffect.start(duration, intensity, force, callback, context); + }, + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Camera#pan + * @since 3.11.0 + * + * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. + * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @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} This Camera instance. + */ + pan: function (x, y, duration, ease, force, callback, context) + { + return this.panEffect.start(x, y, duration, ease, force, callback, context); + }, + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Camera#zoomTo + * @since 3.11.0 + * + * @param {number} zoom - The target Camera zoom value. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @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} This Camera instance. + */ + zoomTo: function (zoom, duration, ease, force, callback, context) + { + return this.zoomEffect.start(zoom, duration, ease, force, callback, context); + }, + + /** + * Internal preRender step. + * + * @method Phaser.Cameras.Scene2D.Camera#preRender + * @protected + * @since 3.0.0 + * + * @param {number} baseScale - The base scale, as set in the Camera Manager. + * @param {number} resolution - The game resolution. + */ + preRender: function (baseScale, resolution) + { + var width = this.width; + var height = this.height; + + var halfWidth = width * 0.5; + var halfHeight = height * 0.5; + + var zoom = this.zoom * baseScale; + var matrix = this.matrix; + + var originX = width * this.originX; + var originY = height * this.originY; + + var follow = this._follow; + var deadzone = this.deadzone; + + var sx = this.scrollX; + var sy = this.scrollY; + + if (deadzone) + { + CenterOn(deadzone, this.midPoint.x, this.midPoint.y); + } + + if (follow) + { + var fx = (follow.x - this.followOffset.x); + var fy = (follow.y - this.followOffset.y); + + if (deadzone) + { + if (fx < deadzone.x) + { + sx = Linear(sx, sx - (deadzone.x - fx), this.lerp.x); + } + else if (fx > deadzone.right) + { + sx = Linear(sx, sx + (fx - deadzone.right), this.lerp.x); + } + + if (fy < deadzone.y) + { + sy = Linear(sy, sy - (deadzone.y - fy), this.lerp.y); + } + else if (fy > deadzone.bottom) + { + sy = Linear(sy, sy + (fy - deadzone.bottom), this.lerp.y); + } + } + else + { + sx = Linear(sx, fx - originX, this.lerp.x); + sy = Linear(sy, fy - originY, this.lerp.y); + } + } + + if (this.useBounds) + { + sx = this.clampX(sx); + sy = this.clampY(sy); + } + + if (this.roundPixels) + { + originX = Math.round(originX); + originY = Math.round(originY); + } + + // Values are in pixels and not impacted by zooming the Camera + this.scrollX = sx; + this.scrollY = sy; + + var midX = sx + halfWidth; + var midY = sy + halfHeight; + + // The center of the camera, in world space, so taking zoom into account + // Basically the pixel value of what it's looking at in the middle of the cam + this.midPoint.set(midX, midY); + + var displayWidth = width / zoom; + var displayHeight = height / zoom; + + this.worldView.setTo( + midX - (displayWidth / 2), + midY - (displayHeight / 2), + displayWidth, + displayHeight + ); + + matrix.loadIdentity(); + matrix.scale(resolution, resolution); + matrix.translate(this.x + originX, this.y + originY); + matrix.rotate(this.rotation); + matrix.scale(zoom, zoom); + matrix.translate(-originX, -originY); + + this.shakeEffect.preRender(); + }, + + /** + * Sets the linear interpolation value to use when following a target. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * + * @method Phaser.Cameras.Scene2D.Camera#setLerp + * @since 3.9.0 + * + * @param {number} [x=1] - The amount added to the horizontal linear interpolation of the follow target. + * @param {number} [y=1] - The amount added to the vertical linear interpolation of the follow target. + * + * @return {this} This Camera instance. + */ + setLerp: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.lerp.set(x, y); + + return this; + }, + + /** + * Sets the horizontal and vertical offset of the camera from its follow target. + * The values are subtracted from the targets position during the Cameras update step. + * + * @method Phaser.Cameras.Scene2D.Camera#setFollowOffset + * @since 3.9.0 + * + * @param {number} [x=0] - The horizontal offset from the camera follow target.x position. + * @param {number} [y=0] - The vertical offset from the camera follow target.y position. + * + * @return {this} This Camera instance. + */ + setFollowOffset: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + this.followOffset.set(x, y); + + return this; + }, + + /** + * Sets the Camera to follow a Game Object. + * + * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object + * in its center. + * + * You can set the linear interpolation value used in the follow code. + * Use low lerp values (such as 0.1) to automatically smooth the camera motion. + * + * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel + * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to + * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom + * value on the camera. So be sure to keep the camera zoom to integers. + * + * @method Phaser.Cameras.Scene2D.Camera#startFollow + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. + * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? + * @param {number} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. + * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. + * + * @return {this} This Camera instance. + */ + startFollow: function (target, roundPixels, lerpX, lerpY, offsetX, offsetY) + { + if (roundPixels === undefined) { roundPixels = false; } + if (lerpX === undefined) { lerpX = 1; } + if (lerpY === undefined) { lerpY = lerpX; } + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = offsetX; } + + this._follow = target; + + this.roundPixels = roundPixels; + + lerpX = Clamp(lerpX, 0, 1); + lerpY = Clamp(lerpY, 0, 1); + + this.lerp.set(lerpX, lerpY); + + this.followOffset.set(offsetX, offsetY); + + var originX = this.width / 2; + var originY = this.height / 2; + + var fx = target.x - offsetX; + var fy = target.y - offsetY; + + this.midPoint.set(fx, fy); + + this.scrollX = fx - originX; + this.scrollY = fy - originY; + + return this; + }, + + /** + * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. + * + * @method Phaser.Cameras.Scene2D.Camera#stopFollow + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + stopFollow: function () + { + this._follow = null; + + return this; + }, + + /** + * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to + * remove the fade. + * + * @method Phaser.Cameras.Scene2D.Camera#resetFX + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + resetFX: function () + { + this.panEffect.reset(); + this.shakeEffect.reset(); + this.flashEffect.reset(); + this.fadeEffect.reset(); + + return this; + }, + + /** + * Internal method called automatically by the Camera Manager. + * + * @method Phaser.Cameras.Scene2D.Camera#update + * @protected + * @since 3.0.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.visible) + { + this.panEffect.update(time, delta); + this.zoomEffect.update(time, delta); + this.shakeEffect.update(time, delta); + this.flashEffect.update(time, delta); + this.fadeEffect.update(time, delta); + } + }, + + /** + * Destroys this Camera instance. You rarely need to call this directly. + * + * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as + * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. + * + * @method Phaser.Cameras.Scene2D.Camera#destroy + * @fires CameraDestroyEvent + * @since 3.0.0 + */ + destroy: function () + { + this.clearRenderToTexture(); + + this.resetFX(); + + BaseCamera.prototype.destroy.call(this); + + this._follow = null; + + this.deadzone = null; + } + +}); + +module.exports = Camera; + + +/***/ }), +/* 415 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCache = __webpack_require__(416); +var Class = __webpack_require__(0); + +/** + * @classdesc + * The Cache Manager is the global cache owned and maintained by the Game instance. + * + * Various systems, such as the file Loader, rely on this cache in order to store the files + * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache + * instances, one per type of file. You can also add your own custom caches. + * + * @class CacheManager + * @memberof Phaser.Cache + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this CacheManager. + */ +var CacheManager = new Class({ + + initialize: + + function CacheManager (game) + { + /** + * A reference to the Phaser.Game instance that owns this CacheManager. + * + * @name Phaser.Cache.CacheManager#game + * @type {Phaser.Game} + * @protected + * @since 3.0.0 + */ + this.game = game; + + /** + * A Cache storing all binary files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#binary + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.binary = new BaseCache(); + + /** + * A Cache storing all bitmap font data files, typically added via the Loader. + * Only the font data is stored in this cache, the textures are part of the Texture Manager. + * + * @name Phaser.Cache.CacheManager#bitmapFont + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.bitmapFont = new BaseCache(); + + /** + * A Cache storing all JSON data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#json + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.json = new BaseCache(); + + /** + * A Cache storing all physics data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#physics + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.physics = new BaseCache(); + + /** + * A Cache storing all shader source files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#shader + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.shader = new BaseCache(); + + /** + * A Cache storing all non-streaming audio files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#audio + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.audio = new BaseCache(); + + /** + * A Cache storing all text files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#text + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.text = new BaseCache(); + + /** + * A Cache storing all html files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#html + * @type {Phaser.Cache.BaseCache} + * @since 3.12.0 + */ + this.html = new BaseCache(); + + /** + * A Cache storing all WaveFront OBJ files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#obj + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.obj = new BaseCache(); + + /** + * A Cache storing all tilemap data files, typically added via the Loader. + * Only the data is stored in this cache, the textures are part of the Texture Manager. + * + * @name Phaser.Cache.CacheManager#tilemap + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.tilemap = new BaseCache(); + + /** + * A Cache storing all xml data files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#xml + * @type {Phaser.Cache.BaseCache} + * @since 3.0.0 + */ + this.xml = new BaseCache(); + + /** + * An object that contains your own custom BaseCache entries. + * Add to this via the `addCustom` method. + * + * @name Phaser.Cache.CacheManager#custom + * @type {Object.} + * @since 3.0.0 + */ + this.custom = {}; + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * Add your own custom Cache for storing your own files. + * The cache will be available under `Cache.custom.key`. + * The cache will only be created if the key is not already in use. + * + * @method Phaser.Cache.CacheManager#addCustom + * @since 3.0.0 + * + * @param {string} key - The unique key of your custom cache. + * + * @return {Phaser.Cache.BaseCache} A reference to the BaseCache that was created. If the key was already in use, a reference to the existing cache is returned instead. + */ + addCustom: function (key) + { + if (!this.custom.hasOwnProperty(key)) + { + this.custom[key] = new BaseCache(); + } + + return this.custom[key]; + }, + + /** + * Removes all entries from all BaseCaches and destroys all custom caches. + * + * @method Phaser.Cache.CacheManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + var keys = [ + 'binary', + 'bitmapFont', + 'json', + 'physics', + 'shader', + 'audio', + 'text', + 'html', + 'obj', + 'tilemap', + 'xml' + ]; + + for (var i = 0; i < keys.length; i++) + { + this[keys[i]].destroy(); + this[keys[i]] = null; + } + + for (var key in this.custom) + { + this.custom[key].destroy(); + } + + this.custom = null; + + this.game = null; + } + +}); + +module.exports = CacheManager; + + +/***/ }), +/* 416 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CustomMap = __webpack_require__(198); +var EventEmitter = __webpack_require__(11); + +/** + * @classdesc + * The BaseCache is a base Cache class that can be used for storing references to any kind of data. + * + * Data can be added, retrieved and removed based on the given keys. + * + * Keys are string-based. + * + * @class BaseCache + * @memberof Phaser.Cache + * @constructor + * @since 3.0.0 + */ +var BaseCache = new Class({ + + initialize: + + function BaseCache () + { + /** + * The Map in which the cache objects are stored. + * + * You can query the Map directly or use the BaseCache methods. + * + * @name Phaser.Cache.BaseCache#entries + * @type {Phaser.Structs.Map.} + * @since 3.0.0 + */ + this.entries = new CustomMap(); + + /** + * An instance of EventEmitter used by the cache to emit related events. + * + * @name Phaser.Cache.BaseCache#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + }, + + /** + * Cache add event. + * + * This event is fired by the Cache each time a new object is added to it. + * + * @event Phaser.Cache.BaseCache#addEvent + * @param {Phaser.Cache.BaseCache} cache - The BaseCache to which the object was added. + * @param {string} key - The key of the object added to the cache. + * @param {*} object - A reference to the object added to the cache. + */ + + /** + * Adds an item to this cache. The item is referenced by a unique string, which you are responsible + * for setting and keeping track of. The item can only be retrieved by using this string. + * + * @method Phaser.Cache.BaseCache#add + * @fires Phaser.Cache.BaseCache#addEvent + * @since 3.0.0 + * + * @param {string} key - The unique key by which the data added to the cache will be referenced. + * @param {*} data - The data to be stored in the cache. + * + * @return {Phaser.Cache.BaseCache} This BaseCache object. + */ + add: function (key, data) + { + this.entries.set(key, data); + + this.events.emit('add', this, key, data); + + return this; + }, + + /** + * Checks if this cache contains an item matching the given key. + * This performs the same action as `BaseCache.exists`. + * + * @method Phaser.Cache.BaseCache#has + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to be checked in this cache. + * + * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. + */ + has: function (key) + { + return this.entries.has(key); + }, + + /** + * Checks if this cache contains an item matching the given key. + * This performs the same action as `BaseCache.has` and is called directly by the Loader. + * + * @method Phaser.Cache.BaseCache#exists + * @since 3.7.0 + * + * @param {string} key - The unique key of the item to be checked in this cache. + * + * @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`. + */ + exists: function (key) + { + return this.entries.has(key); + }, + + /** + * Gets an item from this cache based on the given key. + * + * @method Phaser.Cache.BaseCache#get + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to be retrieved from this cache. + * + * @return {*} The item in the cache, or `null` if no item matching the given key was found. + */ + get: function (key) + { + return this.entries.get(key); + }, + + /** + * Cache remove event. + * + * This event is fired by the Cache each time an object is removed from it. + * + * @event Phaser.Cache.BaseCache#removeEvent + * @param {Phaser.Cache.BaseCache} cache - The BaseCache from which the object was removed. + * @param {string} key - The key of the object removed from the cache. + * @param {*} object - The object that was removed from the cache. + */ + + /** + * Removes and item from this cache based on the given key. + * + * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. + * No additional checks are done on the item removed. If other systems or parts of your game code + * are relying on this item, it is up to you to sever those relationships prior to removing the item. + * + * @method Phaser.Cache.BaseCache#remove + * @fires Phaser.Cache.BaseCache#removeEvent + * @since 3.0.0 + * + * @param {string} key - The unique key of the item to remove from the cache. + * + * @return {Phaser.Cache.BaseCache} This BaseCache object. + */ + remove: function (key) + { + var entry = this.get(key); + + if (entry) + { + this.entries.delete(key); + + this.events.emit('remove', this, key, entry.data); + } + + return this; + }, + + /** + * Destroys this cache and all items within it. + * + * @method Phaser.Cache.BaseCache#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.entries.clear(); + this.events.removeAllListeners(); + + this.entries = null; + this.events = null; + } + +}); + +module.exports = BaseCache; + + +/***/ }), +/* 417 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Animation = __webpack_require__(420); +var Class = __webpack_require__(0); +var CustomMap = __webpack_require__(198); +var EventEmitter = __webpack_require__(11); +var GetValue = __webpack_require__(4); +var Pad = __webpack_require__(197); + +/** + * @typedef {object} JSONAnimationManager + * + * @property {JSONAnimation[]} anims - [description] + * @property {number} globalTimeScale - [description] + */ + +/** + * @classdesc + * The Animation Manager. + * + * Animations are managed by the global Animation Manager. This is a singleton class that is + * responsible for creating and delivering animations and their corresponding data to all Game Objects. + * Unlike plugins it is owned by the Game instance, not the Scene. + * + * Sprites and other Game Objects get the data they need from the AnimationManager. + * + * @class AnimationManager + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance. + */ +var AnimationManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function AnimationManager (game) + { + EventEmitter.call(this); + + /** + * A reference to the Phaser.Game instance. + * + * @name Phaser.Animations.AnimationManager#game + * @type {Phaser.Game} + * @protected + * @since 3.0.0 + */ + this.game = game; + + /** + * A reference to the Texture Manager. + * + * @name Phaser.Animations.AnimationManager#textureManager + * @type {Phaser.Textures.TextureManager} + * @protected + * @since 3.0.0 + */ + this.textureManager = null; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#globalTimeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.globalTimeScale = 1; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#anims + * @type {Phaser.Structs.Map.} + * @protected + * @since 3.0.0 + */ + this.anims = new CustomMap(); + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * [description] + * + * @name Phaser.Animations.AnimationManager#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'AnimationManager'; + + game.events.once('boot', this.boot, this); + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#boot + * @since 3.0.0 + */ + boot: function () + { + this.textureManager = this.game.textures; + + this.game.events.once('destroy', this.destroy, this); + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#add + * @fires AddAnimationEvent + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {Phaser.Animations.Animation} animation - [description] + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + add: function (key, animation) + { + if (this.anims.has(key)) + { + console.warn('Animation with key', key, 'already exists'); + return; + } + + animation.key = key; + + this.anims.set(key, animation); + + this.emit('add', key, animation); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#create + * @fires AddAnimationEvent + * @since 3.0.0 + * + * @param {AnimationConfig} config - [description] + * + * @return {Phaser.Animations.Animation} The Animation that was created. + */ + create: function (config) + { + var key = config.key; + + if (!key || this.anims.has(key)) + { + console.warn('Invalid Animation Key, or Key already in use: ' + key); + return; + } + + var anim = new Animation(this, key, config); + + this.anims.set(key, anim); + + this.emit('add', key, anim); + + return anim; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#fromJSON + * @since 3.0.0 + * + * @param {(string|JSONAnimationManager|JSONAnimation)} data - [description] + * @param {boolean} [clearCurrentAnimations=false] - If set to `true`, the current animations will be removed (`anims.clear()`). If set to `false` (default), the animations in `data` will be added. + * + * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. + */ + fromJSON: function (data, clearCurrentAnimations) + { + if (clearCurrentAnimations === undefined) { clearCurrentAnimations = false; } + + if (clearCurrentAnimations) + { + this.anims.clear(); + } + + // Do we have a String (i.e. from JSON, or an Object?) + if (typeof data === 'string') + { + data = JSON.parse(data); + } + + var output = []; + + // Array of animations, or a single animation? + if (data.hasOwnProperty('anims') && Array.isArray(data.anims)) + { + for (var i = 0; i < data.anims.length; i++) + { + output.push(this.create(data.anims[i])); + } + + if (data.hasOwnProperty('globalTimeScale')) + { + this.globalTimeScale = data.globalTimeScale; + } + } + else if (data.hasOwnProperty('key') && data.type === 'frame') + { + output.push(this.create(data)); + } + + return output; + }, + + /** + * @typedef {object} GenerateFrameNamesConfig + * + * @property {string} [prefix=''] - [description] + * @property {integer} [start=0] - [description] + * @property {integer} [end=0] - [description] + * @property {string} [suffix=''] - [description] + * @property {integer} [zeroPad=0] - [description] + * @property {AnimationFrameConfig[]} [outputArray=[]] - [description] + * @property {boolean} [frames=false] - [description] + */ + + /** + * Generate an array of {@link AnimationFrameConfig} objects from a texture key and configuration object. + * + * Generates objects with string frame names, as configured by the given {@link AnimationFrameConfig}. + * + * @method Phaser.Animations.AnimationManager#generateFrameNames + * @since 3.0.0 + * + * @param {string} key - The key for the texture containing the animation frames. + * @param {GenerateFrameNamesConfig} [config] - The configuration object for the animation frame names. + * + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects. + */ + generateFrameNames: function (key, config) + { + var prefix = GetValue(config, 'prefix', ''); + var start = GetValue(config, 'start', 0); + var end = GetValue(config, 'end', 0); + var suffix = GetValue(config, 'suffix', ''); + var zeroPad = GetValue(config, 'zeroPad', 0); + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); + + var texture = this.textureManager.get(key); + + if (!texture) + { + return out; + } + + var diff = (start < end) ? 1 : -1; + + // Adjust because we use i !== end in the for loop + end += diff; + + var i; + var frame; + + if (!config) + { + // Use every frame in the atlas? + frames = texture.getFrameNames(); + + for (i = 0; i < frames.length; i++) + { + out.push({ key: key, frame: frames[i] }); + } + } + else if (Array.isArray(frames)) + { + // Have they provided their own custom frame sequence array? + for (i = 0; i < frames.length; i++) + { + frame = prefix + Pad(frames[i], zeroPad, '0', 1) + suffix; + + if (texture.has(frame)) + { + out.push({ key: key, frame: frame }); + } + } + } + else + { + for (i = start; i !== end; i += diff) + { + frame = prefix + Pad(i, zeroPad, '0', 1) + suffix; + + if (texture.has(frame)) + { + out.push({ key: key, frame: frame }); + } + } + } + + return out; + }, + + /** + * @typedef {object} GenerateFrameNumbersConfig + * + * @property {integer} [start=0] - The starting frame of the animation. + * @property {integer} [end=-1] - The ending frame of the animation. + * @property {(boolean|integer)} [first=false] - A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. + * @property {AnimationFrameConfig[]} [outputArray=[]] - An array to concatenate the output onto. + * @property {(boolean|integer[])} [frames=false] - A custom sequence of frames. + */ + + /** + * Generate an array of {@link AnimationFrameConfig} objects from a texture key and configuration object. + * + * Generates objects with numbered frame names, as configured by the given {@link GenerateFrameNumbersConfig}. + * + * @method Phaser.Animations.AnimationManager#generateFrameNumbers + * @since 3.0.0 + * + * @param {string} key - The key for the texture containing the animation frames. + * @param {GenerateFrameNumbersConfig} config - The configuration object for the animation frames. + * + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects. + */ + generateFrameNumbers: function (key, config) + { + var startFrame = GetValue(config, 'start', 0); + var endFrame = GetValue(config, 'end', -1); + var firstFrame = GetValue(config, 'first', false); + var out = GetValue(config, 'outputArray', []); + var frames = GetValue(config, 'frames', false); + + var texture = this.textureManager.get(key); + + if (!texture) + { + return out; + } + + if (firstFrame && texture.has(firstFrame)) + { + out.push({ key: key, frame: firstFrame }); + } + + var i; + + // Have they provided their own custom frame sequence array? + if (Array.isArray(frames)) + { + for (i = 0; i < frames.length; i++) + { + if (texture.has(frames[i])) + { + out.push({ key: key, frame: frames[i] }); + } + } + } + else + { + // No endFrame then see if we can get it + if (endFrame === -1) + { + endFrame = texture.frameTotal; + } + + for (i = startFrame; i <= endFrame; i++) + { + if (texture.has(i)) + { + out.push({ key: key, frame: i }); + } + } + } + + return out; + }, + + /** + * Get an Animation. + * + * @method Phaser.Animations.AnimationManager#get + * @since 3.0.0 + * + * @param {string} key - The key of the Animation to retrieve. + * + * @return {Phaser.Animations.Animation} The Animation. + */ + get: function (key) + { + return this.anims.get(key); + }, + + /** + * Load an Animation into a Game Object's Animation Component. + * + * @method Phaser.Animations.AnimationManager#load + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to load the animation into. + * @param {string} key - The key of the animation to load. + * @param {(string|integer)} [startFrame] - The name of a start frame to set on the loaded animation. + * + * @return {Phaser.GameObjects.GameObject} [description] + */ + load: function (child, key, startFrame) + { + var anim = this.get(key); + + if (anim) + { + anim.load(child, startFrame); + } + + return child; + }, + + /** + * Pause all animations. + * + * @method Phaser.Animations.AnimationManager#pauseAll + * @fires PauseAllAnimationEvent + * @since 3.0.0 + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + pauseAll: function () + { + if (!this.paused) + { + this.paused = true; + + this.emit('pauseall'); + } + + return this; + }, + + /** + * Play an animation on the given Game Objects that have an Animation Component. + * + * @method Phaser.Animations.AnimationManager#play + * @since 3.0.0 + * + * @param {string} key - The key of the animation to play on the Game Object. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Objects to play the animation on. + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + play: function (key, child) + { + if (!Array.isArray(child)) + { + child = [ child ]; + } + + var anim = this.get(key); + + if (!anim) + { + return; + } + + for (var i = 0; i < child.length; i++) + { + child[i].anims.play(key); + } + + return this; + }, + + /** + * Remove an animation. + * + * @method Phaser.Animations.AnimationManager#remove + * @fires RemoveAnimationEvent + * @since 3.0.0 + * + * @param {string} key - The key of the animation to remove. + * + * @return {Phaser.Animations.Animation} [description] + */ + remove: function (key) + { + var anim = this.get(key); + + if (anim) + { + this.emit('remove', key, anim); + + this.anims.delete(key); + } + + return anim; + }, + + /** + * Resume all paused animations. + * + * @method Phaser.Animations.AnimationManager#resumeAll + * @fires ResumeAllAnimationEvent + * @since 3.0.0 + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + resumeAll: function () + { + if (this.paused) + { + this.paused = false; + + this.emit('resumeall'); + } + + return this; + }, + + /** + * Takes an array of Game Objects that have an Animation Component and then + * starts the given animation playing on them, each one offset by the + * `stagger` amount given to this method. + * + * @method Phaser.Animations.AnimationManager#staggerPlay + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {string} key - The key of the animation to play on the Game Objects. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have an Animation Component. + * @param {number} [stagger=0] - The amount of time, in milliseconds, to offset each play time by. + * + * @return {Phaser.Animations.AnimationManager} This Animation Manager. + */ + staggerPlay: function (key, children, stagger) + { + if (stagger === undefined) { stagger = 0; } + + if (!Array.isArray(children)) + { + children = [ children ]; + } + + var anim = this.get(key); + + if (!anim) + { + return; + } + + for (var i = 0; i < children.length; i++) + { + children[i].anims.delayedPlay(stagger * i, key); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#toJSON + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {JSONAnimationManager} [description] + */ + toJSON: function (key) + { + if (key !== undefined && key !== '') + { + return this.anims.get(key).toJSON(); + } + else + { + var output = { + anims: [], + globalTimeScale: this.globalTimeScale + }; + + this.anims.each(function (animationKey, animation) + { + output.anims.push(animation.toJSON()); + }); + + return output; + } + }, + + /** + * [description] + * + * @method Phaser.Animations.AnimationManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.anims.clear(); + + this.textureManager = null; + + this.game = null; + } + +}); + +module.exports = AnimationManager; + + +/***/ }), +/* 418 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @typedef {object} JSONAnimationFrame + * + * @property {string} key - The key of the Texture this AnimationFrame uses. + * @property {(string|integer)} frame - The key of the Frame within the Texture that this AnimationFrame uses. + * @property {number} duration - Additional time (in ms) that this frame should appear for during playback. + */ + +/** + * @classdesc + * A single frame in an Animation sequence. + * + * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other + * frames in the animation, and index data. It also has the ability to fire its own `onUpdate` callback + * and modify the animation timing. + * + * AnimationFrames are generated automatically by the Animation class. + * + * @class AnimationFrame + * @memberof Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {string} textureKey - The key of the Texture this AnimationFrame uses. + * @param {(string|integer)} textureFrame - The key of the Frame within the Texture that this AnimationFrame uses. + * @param {integer} index - The index of this AnimationFrame within the Animation sequence. + * @param {Phaser.Textures.Frame} frame - A reference to the Texture Frame this AnimationFrame uses for rendering. + */ +var AnimationFrame = new Class({ + + initialize: + + function AnimationFrame (textureKey, textureFrame, index, frame) + { + /** + * The key of the Texture this AnimationFrame uses. + * + * @name Phaser.Animations.AnimationFrame#textureKey + * @type {string} + * @since 3.0.0 + */ + this.textureKey = textureKey; + + /** + * The key of the Frame within the Texture that this AnimationFrame uses. + * + * @name Phaser.Animations.AnimationFrame#textureFrame + * @type {(string|integer)} + * @since 3.0.0 + */ + this.textureFrame = textureFrame; + + /** + * The index of this AnimationFrame within the Animation sequence. + * + * @name Phaser.Animations.AnimationFrame#index + * @type {integer} + * @since 3.0.0 + */ + this.index = index; + + /** + * A reference to the Texture Frame this AnimationFrame uses for rendering. + * + * @name Phaser.Animations.AnimationFrame#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.frame = frame; + + /** + * Is this the first frame in an animation sequence? + * + * @name Phaser.Animations.AnimationFrame#isFirst + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isFirst = false; + + /** + * Is this the last frame in an animation sequence? + * + * @name Phaser.Animations.AnimationFrame#isLast + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isLast = false; + + /** + * A reference to the AnimationFrame that comes before this one in the animation, if any. + * + * @name Phaser.Animations.AnimationFrame#prevFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @readonly + * @since 3.0.0 + */ + this.prevFrame = null; + + /** + * A reference to the AnimationFrame that comes after this one in the animation, if any. + * + * @name Phaser.Animations.AnimationFrame#nextFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @readonly + * @since 3.0.0 + */ + this.nextFrame = null; + + /** + * Additional time (in ms) that this frame should appear for during playback. + * The value is added onto the msPerFrame set by the animation. + * + * @name Phaser.Animations.AnimationFrame#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * What % through the animation does this frame come? + * This value is generated when the animation is created and cached here. + * + * @name Phaser.Animations.AnimationFrame#progress + * @type {number} + * @default 0 + * @readonly + * @since 3.0.0 + */ + this.progress = 0; + }, + + /** + * Generates a JavaScript object suitable for converting to JSON. + * + * @method Phaser.Animations.AnimationFrame#toJSON + * @since 3.0.0 + * + * @return {JSONAnimationFrame} The AnimationFrame data. + */ + toJSON: function () + { + return { + key: this.textureKey, + frame: this.textureFrame, + duration: this.duration + }; + }, + + /** + * Destroys this object by removing references to external resources and callbacks. + * + * @method Phaser.Animations.AnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.frame = undefined; + } + +}); + +module.exports = AnimationFrame; + + +/***/ }), +/* 419 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Utils.Array.FindClosestInSorted + * @since 3.0.0 + * + * @param {number} value - The value to search for in the array. + * @param {array} array - The array to search, which must be sorted. + * @param {string} [key] - An optional property key. If specified the array elements property will be checked against value. + * + * @return {number|object} The nearest value found in the array, or if a `key` was given, the nearest object with the matching property value. + */ +var FindClosestInSorted = function (value, array, key) +{ + if (!array.length) + { + return NaN; + } + else if (array.length === 1) + { + return array[0]; + } + + var i = 1; + var low; + var high; + + if (key) + { + if (value < array[0][key]) + { + return array[0]; + } + + while (array[i][key] < value) + { + i++; + } + } + else + { + while (array[i] < value) + { + i++; + } + } + + if (i > array.length) + { + i = array.length; + } + + if (key) + { + low = array[i - 1][key]; + high = array[i][key]; + + return ((high - value) <= (value - low)) ? array[i] : array[i - 1]; + } + else + { + low = array[i - 1]; + high = array[i]; + + return ((high - value) <= (value - low)) ? high : low; + } +}; + +module.exports = FindClosestInSorted; + + +/***/ }), +/* 420 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); +var Class = __webpack_require__(0); +var FindClosestInSorted = __webpack_require__(419); +var Frame = __webpack_require__(418); +var GetValue = __webpack_require__(4); + +/** + * @typedef {object} JSONAnimation + * + * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) + * @property {string} type - A frame based animation (as opposed to a bone based animation) + * @property {JSONAnimationFrame[]} frames - [description] + * @property {integer} frameRate - The frame rate of playback in frames per second (default 24 if duration is null) + * @property {integer} duration - How long the animation should play for in milliseconds. If not given its derived from frameRate. + * @property {boolean} skipMissedFrames - Skip frames if the time lags, or always advanced anyway? + * @property {integer} delay - Delay before starting playback. Value given in milliseconds. + * @property {integer} repeat - Number of times to repeat the animation (-1 for infinity) + * @property {integer} repeatDelay - Delay before the animation repeats. Value given in milliseconds. + * @property {boolean} yoyo - Should the animation yoyo? (reverse back down to the start) before repeating? + * @property {boolean} showOnStart - Should sprite.visible = true when the animation starts to play? + * @property {boolean} hideOnComplete - Should sprite.visible = false when the animation finishes? + */ + +/** + * @typedef {object} AnimationFrameConfig + * + * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) + * @property {(string|number)} frame - [description] + * @property {number} [duration=0] - [description] + * @property {boolean} [visible] - [description] + */ + +/** + * @typedef {object} AnimationConfig + * + * @property {string} [key] - The key that the animation will be associated with. i.e. sprite.animations.play(key) + * @property {AnimationFrameConfig[]} [frames] - An object containing data used to generate the frames for the animation + * @property {string} [defaultTextureKey=null] - The key of the texture all frames of the animation will use. Can be overridden on a per frame basis. + * @property {integer} [frameRate] - The frame rate of playback in frames per second (default 24 if duration is null) + * @property {integer} [duration] - How long the animation should play for in milliseconds. If not given its derived from frameRate. + * @property {boolean} [skipMissedFrames=true] - Skip frames if the time lags, or always advanced anyway? + * @property {integer} [delay=0] - Delay before starting playback. Value given in milliseconds. + * @property {integer} [repeat=0] - Number of times to repeat the animation (-1 for infinity) + * @property {integer} [repeatDelay=0] - Delay before the animation repeats. Value given in milliseconds. + * @property {boolean} [yoyo=false] - Should the animation yoyo? (reverse back down to the start) before repeating? + * @property {boolean} [showOnStart=false] - Should sprite.visible = true when the animation starts to play? + * @property {boolean} [hideOnComplete=false] - Should sprite.visible = false when the animation finishes? + */ + +/** + * @classdesc + * A Frame based Animation. + * + * This consists of a key, some default values (like the frame rate) and a bunch of Frame objects. + * + * The Animation Manager creates these. Game Objects don't own an instance of these directly. + * Game Objects have the Animation Component, which are like playheads to global Animations (these objects) + * So multiple Game Objects can have playheads all pointing to this one Animation instance. + * + * @class Animation + * @memberof Phaser.Animations + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationManager} manager - [description] + * @param {string} key - [description] + * @param {AnimationConfig} config - [description] + */ +var Animation = new Class({ + + initialize: + + function Animation (manager, key, config) + { + /** + * A reference to the global Animation Manager + * + * @name Phaser.Animations.Animation#manager + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The unique identifying string for this animation + * + * @name Phaser.Animations.Animation#key + * @type {string} + * @since 3.0.0 + */ + this.key = key; + + /** + * A frame based animation (as opposed to a bone based animation) + * + * @name Phaser.Animations.Animation#type + * @type {string} + * @default frame + * @since 3.0.0 + */ + this.type = 'frame'; + + /** + * Extract all the frame data into the frames array + * + * @name Phaser.Animations.Animation#frames + * @type {Phaser.Animations.AnimationFrame[]} + * @since 3.0.0 + */ + this.frames = this.getFrames( + manager.textureManager, + GetValue(config, 'frames', []), + GetValue(config, 'defaultTextureKey', null) + ); + + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + * + * @name Phaser.Animations.Animation#frameRate + * @type {integer} + * @default 24 + * @since 3.0.0 + */ + this.frameRate = GetValue(config, 'frameRate', null); + + /** + * How long the animation should play for, in milliseconds. + * If the `frameRate` property has been set then it overrides this value, + * otherwise the `frameRate` is derived from `duration`. + * + * @name Phaser.Animations.Animation#duration + * @type {integer} + * @since 3.0.0 + */ + this.duration = GetValue(config, 'duration', null); + + if (this.duration === null && this.frameRate === null) + { + // No duration or frameRate given, use default frameRate of 24fps + this.frameRate = 24; + this.duration = (this.frameRate / this.frames.length) * 1000; + } + else if (this.duration && this.frameRate === null) + { + // Duration given but no frameRate, so set the frameRate based on duration + // I.e. 12 frames in the animation, duration = 4000 ms + // So frameRate is 12 / (4000 / 1000) = 3 fps + this.frameRate = this.frames.length / (this.duration / 1000); + } + else + { + // frameRate given, derive duration from it (even if duration also specified) + // I.e. 15 frames in the animation, frameRate = 30 fps + // So duration is 15 / 30 = 0.5 * 1000 (half a second, or 500ms) + this.duration = (this.frames.length / this.frameRate) * 1000; + } + + /** + * How many ms per frame, not including frame specific modifiers. + * + * @name Phaser.Animations.Animation#msPerFrame + * @type {integer} + * @since 3.0.0 + */ + this.msPerFrame = 1000 / this.frameRate; + + /** + * Skip frames if the time lags, or always advanced anyway? + * + * @name Phaser.Animations.Animation#skipMissedFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.skipMissedFrames = GetValue(config, 'skipMissedFrames', true); + + /** + * The delay in ms before the playback will begin. + * + * @name Phaser.Animations.Animation#delay + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.delay = GetValue(config, 'delay', 0); + + /** + * Number of times to repeat the animation. Set to -1 to repeat forever. + * + * @name Phaser.Animations.Animation#repeat + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.repeat = GetValue(config, 'repeat', 0); + + /** + * The delay in ms before the a repeat playthrough starts. + * + * @name Phaser.Animations.Animation#repeatDelay + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.repeatDelay = GetValue(config, 'repeatDelay', 0); + + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + * + * @name Phaser.Animations.Animation#yoyo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.yoyo = GetValue(config, 'yoyo', false); + + /** + * Should sprite.visible = true when the animation starts to play? + * + * @name Phaser.Animations.Animation#showOnStart + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.showOnStart = GetValue(config, 'showOnStart', false); + + /** + * Should sprite.visible = false when the animation finishes? + * + * @name Phaser.Animations.Animation#hideOnComplete + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.hideOnComplete = GetValue(config, 'hideOnComplete', false); + + /** + * Global pause. All Game Objects using this Animation instance are impacted by this property. + * + * @name Phaser.Animations.Animation#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + this.manager.on('pauseall', this.pause, this); + this.manager.on('resumeall', this.resume, this); + }, + + /** + * Add frames to the end of the animation. + * + * @method Phaser.Animations.Animation#addFrame + * @since 3.0.0 + * + * @param {(string|AnimationFrameConfig[])} config - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + addFrame: function (config) + { + return this.addFrameAt(this.frames.length, config); + }, + + /** + * Add frame/s into the animation. + * + * @method Phaser.Animations.Animation#addFrameAt + * @since 3.0.0 + * + * @param {integer} index - [description] + * @param {(string|AnimationFrameConfig[])} config - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + addFrameAt: function (index, config) + { + var newFrames = this.getFrames(this.manager.textureManager, config); + + if (newFrames.length > 0) + { + if (index === 0) + { + this.frames = newFrames.concat(this.frames); + } + else if (index === this.frames.length) + { + this.frames = this.frames.concat(newFrames); + } + else + { + var pre = this.frames.slice(0, index); + var post = this.frames.slice(index); + + this.frames = pre.concat(newFrames, post); + } + + this.updateFrameSequence(); + } + + return this; + }, + + /** + * Check if the given frame index is valid. + * + * @method Phaser.Animations.Animation#checkFrame + * @since 3.0.0 + * + * @param {integer} index - The index to be checked. + * + * @return {boolean} `true` if the index is valid, otherwise `false`. + */ + checkFrame: function (index) + { + return (index >= 0 && index < this.frames.length); + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#completeAnimation + * @protected + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + completeAnimation: function (component) + { + if (this.hideOnComplete) + { + component.parent.visible = false; + } + + component.stop(); + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getFirstTick + * @protected + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + * @param {boolean} [includeDelay=true] - [description] + */ + getFirstTick: function (component, includeDelay) + { + if (includeDelay === undefined) { includeDelay = true; } + + // When is the first update due? + component.accumulator = 0; + component.nextTick = component.msPerFrame + component.currentFrame.duration; + + if (includeDelay) + { + component.nextTick += component._delay; + } + }, + + /** + * Returns the AnimationFrame at the provided index + * + * @method Phaser.Animations.Animation#getFrameAt + * @protected + * @since 3.0.0 + * + * @param {integer} index - The index in the AnimationFrame array + * + * @return {Phaser.Animations.AnimationFrame} The frame at the index provided from the animation sequence + */ + getFrameAt: function (index) + { + return this.frames[index]; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getFrames + * @since 3.0.0 + * + * @param {Phaser.Textures.TextureManager} textureManager - [description] + * @param {(string|AnimationFrameConfig[])} frames - [description] + * @param {string} [defaultTextureKey] - [description] + * + * @return {Phaser.Animations.AnimationFrame[]} [description] + */ + getFrames: function (textureManager, frames, defaultTextureKey) + { + var out = []; + var prev; + var animationFrame; + var index = 1; + var i; + var textureKey; + + // if frames is a string, we'll get all the frames from the texture manager as if it's a sprite sheet + if (typeof frames === 'string') + { + textureKey = frames; + + var texture = textureManager.get(textureKey); + var frameKeys = texture.getFrameNames(); + + frames = []; + + frameKeys.forEach(function (idx, value) + { + frames.push({ key: textureKey, frame: value }); + }); + } + + if (!Array.isArray(frames) || frames.length === 0) + { + return out; + } + + for (i = 0; i < frames.length; i++) + { + var item = frames[i]; + + var key = GetValue(item, 'key', defaultTextureKey); + + if (!key) + { + continue; + } + + // Could be an integer or a string + var frame = GetValue(item, 'frame', 0); + + // The actual texture frame + var textureFrame = textureManager.getFrame(key, frame); + + animationFrame = new Frame(key, frame, index, textureFrame); + + animationFrame.duration = GetValue(item, 'duration', 0); + + animationFrame.isFirst = (!prev); + + // The previously created animationFrame + if (prev) + { + prev.nextFrame = animationFrame; + + animationFrame.prevFrame = prev; + } + + out.push(animationFrame); + + prev = animationFrame; + + index++; + } + + if (out.length > 0) + { + animationFrame.isLast = true; + + // Link them end-to-end, so they loop + animationFrame.nextFrame = out[0]; + + out[0].prevFrame = animationFrame; + + // Generate the progress data + + var slice = 1 / (out.length - 1); + + for (i = 0; i < out.length; i++) + { + out[i].progress = i * slice; + } + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#getNextTick + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + getNextTick: function (component) + { + // accumulator += delta * _timeScale + // after a large delta surge (perf issue for example) we need to adjust for it here + + // When is the next update due? + component.accumulator -= component.nextTick; + + component.nextTick = component.msPerFrame + component.currentFrame.duration; + }, + + /** + * Loads the Animation values into the Animation Component. + * + * @method Phaser.Animations.Animation#load + * @private + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component to load values into. + * @param {integer} startFrame - The start frame of the animation to load. + */ + load: function (component, startFrame) + { + if (startFrame >= this.frames.length) + { + startFrame = 0; + } + + if (component.currentAnim !== this) + { + component.currentAnim = this; + + component.frameRate = this.frameRate; + component.duration = this.duration; + component.msPerFrame = this.msPerFrame; + component.skipMissedFrames = this.skipMissedFrames; + + component._delay = this.delay; + component._repeat = this.repeat; + component._repeatDelay = this.repeatDelay; + component._yoyo = this.yoyo; + } + + var frame = this.frames[startFrame]; + + if (startFrame === 0 && !component.forward) + { + frame = this.getLastFrame(); + } + + component.updateFrame(frame); + }, + + /** + * Returns the frame closest to the given progress value between 0 and 1. + * + * @method Phaser.Animations.Animation#getFrameByProgress + * @since 3.4.0 + * + * @param {number} value - A value between 0 and 1. + * + * @return {Phaser.Animations.AnimationFrame} The frame closest to the given progress value. + */ + getFrameByProgress: function (value) + { + value = Clamp(value, 0, 1); + + return FindClosestInSorted(value, this.frames, 'progress'); + }, + + /** + * Advance the animation frame. + * + * @method Phaser.Animations.Animation#nextFrame + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component to advance. + */ + nextFrame: function (component) + { + var frame = component.currentFrame; + + // TODO: Add frame skip support + + if (frame.isLast) + { + // We're at the end of the animation + + // Yoyo? (happens before repeat) + if (component._yoyo) + { + this.handleYoyoFrame(component, false); + } + else if (component.repeatCounter > 0) + { + // Repeat (happens before complete) + + if (component._reverse && component.forward) + { + component.forward = false; + } + else + { + this.repeatAnimation(component); + } + } + else + { + this.completeAnimation(component); + } + } + else + { + this.updateAndGetNextTick(component, frame.nextFrame); + } + }, + + /** + * Handle the yoyo functionality in nextFrame and previousFrame methods. + * + * @method Phaser.Animations.Animation#handleYoyoFrame + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component to advance. + * @param {boolean} isReverse - Is animation in reverse mode? (Default: false) + */ + handleYoyoFrame: function (component, isReverse) + { + if (!isReverse) { isReverse = false; } + + if (component._reverse === !isReverse && component.repeatCounter > 0) + { + component.forward = isReverse; + + this.repeatAnimation(component); + + return; + } + + if (component._reverse !== isReverse && component.repeatCounter === 0) + { + this.completeAnimation(component); + + return; + } + + component.forward = isReverse; + + var frame = (isReverse) ? component.currentFrame.nextFrame : component.currentFrame.prevFrame; + + this.updateAndGetNextTick(component, frame); + }, + + /** + * Returns the animation last frame. + * + * @method Phaser.Animations.Animation#getLastFrame + * @since 3.12.0 + * + * @return {Phaser.Animations.AnimationFrame} component - The Animation Last Frame. + */ + getLastFrame: function () + { + return this.frames[this.frames.length - 1]; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#previousFrame + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + previousFrame: function (component) + { + var frame = component.currentFrame; + + // TODO: Add frame skip support + + if (frame.isFirst) + { + // We're at the start of the animation + + if (component._yoyo) + { + this.handleYoyoFrame(component, true); + } + else if (component.repeatCounter > 0) + { + if (component._reverse && !component.forward) + { + component.currentFrame = this.getLastFrame(); + this.repeatAnimation(component); + } + else + { + // Repeat (happens before complete) + component.forward = true; + this.repeatAnimation(component); + } + } + else + { + this.completeAnimation(component); + } + } + else + { + this.updateAndGetNextTick(component, frame.prevFrame); + } + }, + + /** + * Update Frame and Wait next tick. + * + * @method Phaser.Animations.Animation#updateAndGetNextTick + * @private + * @since 3.12.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - An Animation frame. + */ + updateAndGetNextTick: function (component, frame) + { + component.updateFrame(frame); + + this.getNextTick(component); + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#removeFrame + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - [description] + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + removeFrame: function (frame) + { + var index = this.frames.indexOf(frame); + + if (index !== -1) + { + this.removeFrameAt(index); + } + + return this; + }, + + /** + * Removes a frame from the AnimationFrame array at the provided index + * and updates the animation accordingly. + * + * @method Phaser.Animations.Animation#removeFrameAt + * @since 3.0.0 + * + * @param {integer} index - The index in the AnimationFrame array + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + removeFrameAt: function (index) + { + this.frames.splice(index, 1); + + this.updateFrameSequence(); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#repeatAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + repeatAnimation: function (component) + { + if (component._pendingStop === 2) + { + return this.completeAnimation(component); + } + + if (component._repeatDelay > 0 && component.pendingRepeat === false) + { + component.pendingRepeat = true; + component.accumulator -= component.nextTick; + component.nextTick += component._repeatDelay; + } + else + { + component.repeatCounter--; + + component.updateFrame(component.currentFrame[(component.forward) ? 'nextFrame' : 'prevFrame']); + + if (component.isPlaying) + { + this.getNextTick(component); + + component.pendingRepeat = false; + + component.parent.emit('animationrepeat', this, component.currentFrame, component.repeatCounter, component.parent); + } + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#setFrame + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - [description] + */ + setFrame: function (component) + { + // Work out which frame should be set next on the child, and set it + if (component.forward) + { + this.nextFrame(component); + } + else + { + this.previousFrame(component); + } + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#toJSON + * @since 3.0.0 + * + * @return {JSONAnimation} [description] + */ + toJSON: function () + { + var output = { + key: this.key, + type: this.type, + frames: [], + frameRate: this.frameRate, + duration: this.duration, + skipMissedFrames: this.skipMissedFrames, + delay: this.delay, + repeat: this.repeat, + repeatDelay: this.repeatDelay, + yoyo: this.yoyo, + showOnStart: this.showOnStart, + hideOnComplete: this.hideOnComplete + }; + + this.frames.forEach(function (frame) + { + output.frames.push(frame.toJSON()); + }); + + return output; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#updateFrameSequence + * @since 3.0.0 + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + updateFrameSequence: function () + { + var len = this.frames.length; + var slice = 1 / (len - 1); + + for (var i = 0; i < len; i++) + { + var frame = this.frames[i]; + + frame.index = i + 1; + frame.isFirst = false; + frame.isLast = false; + frame.progress = i * slice; + + if (i === 0) + { + frame.isFirst = true; + frame.isLast = (len === 1); + frame.prevFrame = this.frames[len - 1]; + frame.nextFrame = this.frames[i + 1]; + } + else if (i === len - 1) + { + frame.isLast = true; + frame.prevFrame = this.frames[len - 2]; + frame.nextFrame = this.frames[0]; + } + else if (len > 1) + { + frame.prevFrame = this.frames[i - 1]; + frame.nextFrame = this.frames[i + 1]; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#pause + * @since 3.0.0 + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + pause: function () + { + this.paused = true; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#resume + * @since 3.0.0 + * + * @return {Phaser.Animations.Animation} This Animation object. + */ + resume: function () + { + this.paused = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Animations.Animation#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.manager.off('pauseall', this.pause, this); + this.manager.off('resumeall', this.resume, this); + + this.manager.remove(this.key); + + for (var i = 0; i < this.frames.length; i++) + { + this.frames[i].destroy(); + } + + this.frames = []; + + this.manager = null; + } + +}); + +module.exports = Animation; + + +/***/ }), +/* 421 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Using Bresenham's line algorithm this will return an array of all coordinates on this line. + * + * The `start` and `end` points are rounded before this runs as the algorithm works on integers. + * + * @function Phaser.Geom.Line.BresenhamPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line. + * @param {integer} [stepRate=1] - The optional step rate for the points on the line. + * @param {array} [results] - An optional array to push the resulting coordinates into. + * + * @return {object[]} The array of coordinates on the line. + */ +var BresenhamPoints = function (line, stepRate, results) +{ + if (stepRate === undefined) { stepRate = 1; } + if (results === undefined) { results = []; } + + var x1 = Math.round(line.x1); + var y1 = Math.round(line.y1); + var x2 = Math.round(line.x2); + var y2 = Math.round(line.y2); + + var dx = Math.abs(x2 - x1); + var dy = Math.abs(y2 - y1); + var sx = (x1 < x2) ? 1 : -1; + var sy = (y1 < y2) ? 1 : -1; + var err = dx - dy; + + results.push({ x: x1, y: y1 }); + + var i = 1; + + while (!((x1 === x2) && (y1 === y2))) + { + var e2 = err << 1; + + if (e2 > -dy) + { + err -= dy; + x1 += sx; + } + + if (e2 < dx) + { + err += dx; + y1 += sy; + } + + if (i % stepRate === 0) + { + results.push({ x: x1, y: y1 }); + } + + i++; + } + + return results; +}; + +module.exports = BresenhamPoints; + + +/***/ }), +/* 422 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the end of the array to the start, shifting all items in the process. + * The "rotation" happens to the right. + * + * @function Phaser.Utils.Array.RotateRight + * @since 3.0.0 + * + * @param {array} array - The array to shift to the right. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateRight = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.pop(); + array.unshift(element); + } + + return element; +}; + +module.exports = RotateRight; + + +/***/ }), +/* 423 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the start of the array to the end, shifting all items in the process. + * The "rotation" happens to the left. + * + * @function Phaser.Utils.Array.RotateLeft + * @since 3.0.0 + * + * @param {array} array - The array to shift to the left. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateLeft = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.shift(); + array.push(element); + } + + return element; +}; + +module.exports = RotateLeft; + + +/***/ }), +/* 424 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Perimeter = __webpack_require__(134); +var Point = __webpack_require__(6); + +// Return an array of points from the perimeter of the rectangle +// each spaced out based on the quantity or step required + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.MarchingAnts + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} step - [description] + * @param {integer} quantity - [description] + * @param {(array|Phaser.Geom.Point[])} [out] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ +var MarchingAnts = function (rect, step, quantity, out) +{ + if (out === undefined) { out = []; } + + if (!step && !quantity) + { + // Bail out + return out; + } + + // If step is a falsey value (false, null, 0, undefined, etc) then we calculate + // it based on the quantity instead, otherwise we always use the step value + if (!step) + { + step = Perimeter(rect) / quantity; + } + else + { + quantity = Math.round(Perimeter(rect) / step); + } + + var x = rect.x; + var y = rect.y; + var face = 0; + + // Loop across each face of the rectangle + + for (var i = 0; i < quantity; i++) + { + out.push(new Point(x, y)); + + switch (face) + { + + // Top face + case 0: + x += step; + + if (x >= rect.right) + { + face = 1; + y += (x - rect.right); + x = rect.right; + } + break; + + // Right face + case 1: + y += step; + + if (y >= rect.bottom) + { + face = 2; + x -= (y - rect.bottom); + y = rect.bottom; + } + break; + + // Bottom face + case 2: + x -= step; + + if (x <= rect.left) + { + face = 3; + y -= (rect.left - x); + x = rect.left; + } + break; + + // Left face + case 3: + y -= step; + + if (y <= rect.top) + { + face = 0; + y = rect.top; + } + break; + } + } + + return out; +}; + +module.exports = MarchingAnts; + + +/***/ }), +/* 425 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 1; // 0001 + +/** + * Provides methods used for setting the visibility of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Visible + * @since 3.0.0 + */ + +var Visible = { + + /** + * Private internal value. Holds the visible value. + * + * @name Phaser.GameObjects.Components.Visible#_visible + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + _visible: true, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Components.Visible#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + if (value) + { + this._visible = true; + this.renderFlags |= _FLAG; + } + else + { + this._visible = false; + this.renderFlags &= ~_FLAG; + } + } + + }, + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @method Phaser.GameObjects.Components.Visible#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {this} This Game Object instance. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + } +}; + +module.exports = Visible; + + +/***/ }), +/* 426 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(18); +var TransformMatrix = __webpack_require__(42); +var WrapAngle = __webpack_require__(205); +var WrapAngleDegrees = __webpack_require__(204); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 + +/** + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. + * + * @name Phaser.GameObjects.Components.Transform + * @since 3.0.0 + */ + +var Transform = { + + /** + * Private internal value. Holds the horizontal scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleX + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleX: 1, + + /** + * Private internal value. Holds the vertical scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleY + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleY: 1, + + /** + * Private internal value. Holds the rotation value in radians. + * + * @name Phaser.GameObjects.Components.Transform#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + _rotation: 0, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + x: 0, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + y: 0, + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + * + * @name Phaser.GameObjects.Components.Transform#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + z: 0, + + /** + * The w position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + w: 0, + + /** + * The horizontal scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + this._scaleX = value; + + if (this._scaleX === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The vertical scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + this._scaleY = value; + + if (this._scaleY === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + * + * @name Phaser.GameObjects.Components.Transform#angle + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + * + * @name Phaser.GameObjects.Components.Transform#rotation + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + } + }, + + /** + * Sets the position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of this Game Object. + * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value. + * @param {number} [z=0] - The z position of this Game Object. + * @param {number} [w=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setPosition: function (x, y, z, w) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + if (z === undefined) { z = 0; } + if (w === undefined) { w = 0; } + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + }, + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * + * @method Phaser.GameObjects.Components.Transform#setRandomPosition + * @since 3.8.0 + * + * @param {number} [x=0] - The x position of the top-left of the random area. + * @param {number} [y=0] - The y position of the top-left of the random area. + * @param {number} [width] - The width of the random area. + * @param {number} [height] - The height of the random area. + * + * @return {this} This Game Object instance. + */ + setRandomPosition: function (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + + this.x = x + (Math.random() * width); + this.y = y + (Math.random() * height); + + return this; + }, + + /** + * Sets the rotation of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - The rotation of this Game Object, in radians. + * + * @return {this} This Game Object instance. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this.rotation = radians; + + return this; + }, + + /** + * Sets the angle of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. + * + * @return {this} This Game Object instance. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + return this; + }, + + /** + * Sets the scale of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScale: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scaleX = x; + this.scaleY = y; + + return this; + }, + + /** + * Sets the x position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setX + * @since 3.0.0 + * + * @param {number} [value=0] - The x position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setX: function (value) + { + if (value === undefined) { value = 0; } + + this.x = value; + + return this; + }, + + /** + * Sets the y position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setY + * @since 3.0.0 + * + * @param {number} [value=0] - The y position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setY: function (value) + { + if (value === undefined) { value = 0; } + + this.y = value; + + return this; + }, + + /** + * Sets the z position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setZ + * @since 3.0.0 + * + * @param {number} [value=0] - The z position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setZ: function (value) + { + if (value === undefined) { value = 0; } + + this.z = value; + + return this; + }, + + /** + * Sets the w position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setW + * @since 3.0.0 + * + * @param {number} [value=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setW: function (value) + { + if (value === undefined) { value = 0; } + + this.w = value; + + return this; + }, + + /** + * Gets the local transform matrix for this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getLocalTransformMatrix: function (tempMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + + return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + }, + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * + * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A temporary matrix to hold parent values during the calculations. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getWorldTransformMatrix: function (tempMatrix, parentMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + if (parentMatrix === undefined) { parentMatrix = new TransformMatrix(); } + + var parent = this.parentContainer; + + if (!parent) + { + return this.getLocalTransformMatrix(tempMatrix); + } + + tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + + while (parent) + { + parentMatrix.applyITRS(parent.x, parent.y, parent._rotation, parent._scaleX, parent._scaleY); + + parentMatrix.multiply(tempMatrix, tempMatrix); + + parent = parent.parentContainer; + } + + return tempMatrix; + } + +}; + +module.exports = Transform; + + +/***/ }), +/* 427 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} JSONGameObject + * + * @property {string} name - The name of this Game Object. + * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. + * @property {number} x - The x position of this Game Object. + * @property {number} y - The y position of this Game Object. + * @property {object} scale - The scale of this Game Object + * @property {number} scale.x - The horizontal scale of this Game Object. + * @property {number} scale.y - The vertical scale of this Game Object. + * @property {object} origin - The origin of this Game Object. + * @property {number} origin.x - The horizontal origin of this Game Object. + * @property {number} origin.y - The vertical origin of this Game Object. + * @property {boolean} flipX - The horizontally flipped state of the Game Object. + * @property {boolean} flipY - The vertically flipped state of the Game Object. + * @property {number} rotation - The angle of this Game Object in radians. + * @property {number} alpha - The alpha value of the Game Object. + * @property {boolean} visible - The visible state of the Game Object. + * @property {integer} scaleMode - The Scale Mode being used by this Game Object. + * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. + * @property {string} textureKey - The texture key of this Game Object. + * @property {string} frameKey - The frame key of this Game Object. + * @property {object} data - The data of this Game Object. + */ + +/** + * Build a JSON representation of the given Game Object. + * + * This is typically extended further by Game Object specific implementations. + * + * @method Phaser.GameObjects.Components.ToJSON + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON. + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ +var ToJSON = function (gameObject) +{ + var out = { + name: gameObject.name, + type: gameObject.type, + x: gameObject.x, + y: gameObject.y, + depth: gameObject.depth, + scale: { + x: gameObject.scaleX, + y: gameObject.scaleY + }, + origin: { + x: gameObject.originX, + y: gameObject.originY + }, + flipX: gameObject.flipX, + flipY: gameObject.flipY, + rotation: gameObject.rotation, + alpha: gameObject.alpha, + visible: gameObject.visible, + scaleMode: gameObject.scaleMode, + blendMode: gameObject.blendMode, + textureKey: '', + frameKey: '', + data: {} + }; + + if (gameObject.texture) + { + out.textureKey = gameObject.texture.key; + out.frameKey = gameObject.frame.name; + } + + return out; +}; + +module.exports = ToJSON; + + +/***/ }), +/* 428 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the Scroll Factor of a Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor + * @since 3.0.0 + */ + +var ScrollFactor = { + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorX: 1, + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorY: 1, + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of this Game Object. + * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScrollFactor: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + } + +}; + +module.exports = ScrollFactor; + + +/***/ }), +/* 429 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Geometry Mask can be applied to a Game Object to hide any pixels of it which don't intersect a visible pixel from the geometry mask. The mask is essentially a clipping path which can only make a masked pixel fully visible or fully invisible without changing its alpha (opacity). + * + * A Geometry Mask uses a Graphics Game Object to determine which pixels of the masked Game Object(s) should be clipped. For any given point of a masked Game Object's texture, the pixel will only be displayed if the Graphics Game Object of the Geometry Mask has a visible pixel at the same position. The color and alpha of the pixel from the Geometry Mask do not matter. + * + * The Geometry Mask's location matches the location of its Graphics object, not the location of the masked objects. Moving or transforming the underlying Graphics object will change the mask (and affect the visibility of any masked objects), whereas moving or transforming a masked object will not affect the mask. You can think of the Geometry Mask (or rather, of the its Graphics object) as an invisible curtain placed in front of all masked objects which has its own visual properties and, naturally, respects the camera's visual properties, but isn't affected by and doesn't follow the masked objects by itself. + * + * @class GeometryMask + * @memberof Phaser.Display.Masks + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - This parameter is not used. + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics Game Object to use for the Geometry Mask. Doesn't have to be in the Display List. + */ +var GeometryMask = new Class({ + + initialize: + + function GeometryMask (scene, graphicsGeometry) + { + /** + * The Graphics object which describes the Geometry Mask. + * + * @name Phaser.Display.Masks.GeometryMask#geometryMask + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.geometryMask = graphicsGeometry; + }, + + /** + * Sets a new Graphics object for the Geometry Mask. + * + * @method Phaser.Display.Masks.GeometryMask#setShape + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics object which will be used for the Geometry Mask. + */ + setShape: function (graphicsGeometry) + { + this.geometryMask = graphicsGeometry; + }, + + /** + * Renders the Geometry Mask's underlying Graphics object to the OpenGL stencil buffer and enables the stencil test, which clips rendered pixels according to the mask. + * + * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL + * @since 3.0.0 + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to draw to. + * @param {Phaser.GameObjects.GameObject} mask - The Game Object being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the Game Object is being rendered through. + */ + preRenderWebGL: function (renderer, mask, camera) + { + var gl = renderer.gl; + var geometryMask = this.geometryMask; + + // Force flushing before drawing to stencil buffer + renderer.flush(); + + // Enable and setup GL state to write to stencil buffer + gl.enable(gl.STENCIL_TEST); + gl.clear(gl.STENCIL_BUFFER_BIT); + gl.colorMask(false, false, false, false); + gl.stencilFunc(gl.NOTEQUAL, 1, 1); + gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE); + + // Write stencil buffer + geometryMask.renderWebGL(renderer, geometryMask, 0.0, camera); + renderer.flush(); + + // Use stencil buffer to affect next rendering object + gl.colorMask(true, true, true, true); + gl.stencilFunc(gl.EQUAL, 1, 1); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); + }, + + /** + * Flushes all rendered pixels and disables the stencil test of a WebGL context, thus disabling the mask for it. + * + * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL + * @since 3.0.0 + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to draw flush. + */ + postRenderWebGL: function (renderer) + { + var gl = renderer.gl; + + // Force flush before disabling stencil test + renderer.flush(); + + gl.disable(gl.STENCIL_TEST); + }, + + /** + * Sets the clipping path of a 2D canvas context to the Geometry Mask's underlying Graphics object. + * + * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas + * @since 3.0.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance to set the clipping path on. + * @param {Phaser.GameObjects.GameObject} mask - The Game Object being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the Game Object is being rendered through. + */ + preRenderCanvas: function (renderer, mask, camera) + { + var geometryMask = this.geometryMask; + + renderer.currentContext.save(); + + geometryMask.renderCanvas(renderer, geometryMask, 0, camera, null, null, true); + + renderer.currentContext.clip(); + }, + + /** + * Restore the canvas context's previous clipping path, thus turning off the mask for it. + * + * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas + * @since 3.0.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance being restored. + */ + postRenderCanvas: function (renderer) + { + renderer.currentContext.restore(); + }, + + /** + * Destroys this GeometryMask and nulls any references it holds. + * + * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, + * so be sure to call `clearMask` on any Game Object using it, before destroying it. + * + * @method Phaser.Display.Masks.GeometryMask#destroy + * @since 3.7.0 + */ + destroy: function () + { + this.geometryMask = null; + } + +}); + +module.exports = GeometryMask; + + +/***/ }), +/* 430 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class BitmapMask + * @memberof Phaser.Display.Masks + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. + */ +var BitmapMask = new Class({ + + initialize: + + function BitmapMask (scene, renderable) + { + var renderer = scene.sys.game.renderer; + + /** + * A reference to either the Canvas or WebGL Renderer that this Mask is using. + * + * @name Phaser.Display.Masks.BitmapMask#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.11.0 + */ + this.renderer = renderer; + + /** + * A renderable Game Object that uses a texture, such as a Sprite. + * + * @name Phaser.Display.Masks.BitmapMask#bitmapMask + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.bitmapMask = renderable; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#maskTexture + * @type {WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.maskTexture = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#mainTexture + * @type {WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.mainTexture = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#dirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.dirty = true; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#mainFramebuffer + * @type {WebGLFramebuffer} + * @since 3.0.0 + */ + this.mainFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#maskFramebuffer + * @type {WebGLFramebuffer} + * @since 3.0.0 + */ + this.maskFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#invertAlpha + * @type {boolean} + * @since 3.1.2 + */ + this.invertAlpha = false; + + if (renderer && renderer.gl) + { + var width = renderer.width; + var height = renderer.height; + var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); + var gl = renderer.gl; + var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; + var filter = gl.LINEAR; + + this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); + this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); + + renderer.onContextRestored(function (renderer) + { + var width = renderer.width; + var height = renderer.height; + var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); + var gl = renderer.gl; + var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; + var filter = gl.LINEAR; + + this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); + this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); + + }, this); + } + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#setBitmap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. + */ + setBitmap: function (renderable) + { + this.bitmapMask = renderable; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#preRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} maskedObject - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. + */ + preRenderWebGL: function (renderer, maskedObject, camera) + { + renderer.pipelines.BitmapMaskPipeline.beginMask(this, maskedObject, camera); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#postRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderWebGL: function (renderer) + { + renderer.pipelines.BitmapMaskPipeline.endMask(this); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#preRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. + */ + preRenderCanvas: function () + { + // NOOP + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#postRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderCanvas: function () + { + // NOOP + }, + + /** + * Destroys this BitmapMask and nulls any references it holds. + * + * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, + * so be sure to call `clearMask` on any Game Object using it, before destroying it. + * + * @method Phaser.Display.Masks.BitmapMask#destroy + * @since 3.7.0 + */ + destroy: function () + { + this.bitmapMask = null; + + var renderer = this.renderer; + + if (renderer && renderer.gl) + { + renderer.deleteTexture(this.mainTexture); + renderer.deleteTexture(this.maskTexture); + renderer.deleteFramebuffer(this.mainFramebuffer); + renderer.deleteFramebuffer(this.maskFramebuffer); + } + + this.mainTexture = null; + this.maskTexture = null; + this.mainFramebuffer = null; + this.maskFramebuffer = null; + this.renderer = null; + } + +}); + +module.exports = BitmapMask; + + +/***/ }), +/* 431 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapMask = __webpack_require__(430); +var GeometryMask = __webpack_require__(429); + +/** + * Provides methods used for getting and setting the mask of a Game Object. + * + * @name Phaser.GameObjects.Components.Mask + * @since 3.0.0 + */ + +var Mask = { + + /** + * The Mask this Game Object is using during render. + * + * @name Phaser.GameObjects.Components.Mask#mask + * @type {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} + * @since 3.0.0 + */ + mask: null, + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * + * @method Phaser.GameObjects.Components.Mask#setMask + * @since 3.6.2 + * + * @param {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} mask - The mask this Game Object will use when rendering. + * + * @return {this} This Game Object instance. + */ + setMask: function (mask) + { + this.mask = mask; + + return this; + }, + + /** + * Clears the mask that this Game Object was using. + * + * @method Phaser.GameObjects.Components.Mask#clearMask + * @since 3.6.2 + * + * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? + * + * @return {this} This Game Object instance. + */ + clearMask: function (destroyMask) + { + if (destroyMask === undefined) { destroyMask = false; } + + if (destroyMask && this.mask) + { + this.mask.destroy(); + } + + this.mask = null; + + return this; + }, + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * + * @method Phaser.GameObjects.Components.Mask#createBitmapMask + * @since 3.6.2 + * + * @param {Phaser.GameObjects.GameObject} [renderable] - A renderable Game Object that uses a texture, such as a Sprite. + * + * @return {Phaser.Display.Masks.BitmapMask} This Bitmap Mask that was created. + */ + createBitmapMask: function (renderable) + { + if (renderable === undefined && this.texture) + { + // eslint-disable-next-line consistent-this + renderable = this; + } + + return new BitmapMask(this.scene, renderable); + }, + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * + * @method Phaser.GameObjects.Components.Mask#createGeometryMask + * @since 3.6.2 + * + * @param {Phaser.GameObjects.Graphics} [graphics] - A Graphics Game Object. The geometry within it will be used as the mask. + * + * @return {Phaser.Display.Masks.GeometryMask} This Geometry Mask that was created. + */ + createGeometryMask: function (graphics) + { + if (graphics === undefined && this.type === 'Graphics') + { + // eslint-disable-next-line consistent-this + graphics = this; + } + + return new GeometryMask(this.scene, graphics); + } + +}; + +module.exports = Mask; + + +/***/ }), +/* 432 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rotate a `point` around `x` and `y` by the given `angle`. + * + * @function Phaser.Math.RotateAround + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. + * @param {number} x - The horizontal coordinate to rotate around. + * @param {number} y - The vertical coordinate to rotate around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Point} The given point, rotated by the given angle around the given coordinates. + */ +var RotateAround = function (point, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = point.x - x; + var ty = point.y - y; + + point.x = tx * c - ty * s + x; + point.y = tx * s + ty * c + y; + + return point; +}; + +module.exports = RotateAround; + + +/***/ }), +/* 433 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Get a point on a line that's a given percentage along its length. + * + * @function Phaser.Geom.Line.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line. + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point, or point-like object, to store the coordinates of the point on the line. + * + * @return {(Phaser.Geom.Point|object)} The point on the line. + */ +var GetPoint = function (line, position, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = line.x1 + (line.x2 - line.x1) * position; + out.y = line.y1 + (line.y2 - line.y1) * position; + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 434 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetPoint = __webpack_require__(209); +var Perimeter = __webpack_require__(134); + +// Return an array of points from the perimeter of the rectangle +// each spaced out based on the quantity or step required + +/** + * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. + * + * @function Phaser.Geom.Rectangle.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle object to get the points from. + * @param {number} step - [description] + * @param {integer} quantity - [description] + * @param {(array|Phaser.Geom.Point[])} [out] - An optional array to store the points in. + * + * @return {(array|Phaser.Geom.Point[])} An array of Points from the perimeter of the rectangle. + */ +var GetPoints = function (rectangle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Perimeter(rectangle) / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + out.push(GetPoint(rectangle, position)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 435 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Depth + * @since 3.0.0 + */ + +var Depth = { + + /** + * Private internal value. Holds the depth of the Game Object. + * + * @name Phaser.GameObjects.Components.Depth#_depth + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _depth: 0, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @name Phaser.GameObjects.Components.Depth#depth + * @type {number} + * @since 3.0.0 + */ + depth: { + + get: function () + { + return this._depth; + }, + + set: function (value) + { + this.scene.sys.queueDepthSort(); + this._depth = value; + } + + }, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @method Phaser.GameObjects.Components.Depth#setDepth + * @since 3.0.0 + * + * @param {integer} value - The depth of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDepth: function (value) + { + if (value === undefined) { value = 0; } + + this.depth = value; + + return this; + } + +}; + +module.exports = Depth; + + +/***/ }), +/* 436 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(72); + +/** + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.BlendMode + * @since 3.0.0 + */ + +var BlendMode = { + + /** + * Private internal value. Holds the current blend mode. + * + * @name Phaser.GameObjects.Components.BlendMode#_blendMode + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _blendMode: BlendModes.NORMAL, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @name Phaser.GameObjects.Components.BlendMode#blendMode + * @type {(Phaser.BlendModes|string)} + * @since 3.0.0 + */ + blendMode: { + + get: function () + { + return this._blendMode; + }, + + set: function (value) + { + if (typeof value === 'string') + { + value = BlendModes[value]; + } + + value |= 0; + + if (value >= -1) + { + this._blendMode = value; + } + } + + }, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @method Phaser.GameObjects.Components.BlendMode#setBlendMode + * @since 3.0.0 + * + * @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST. + * + * @return {this} This Game Object instance. + */ + setBlendMode: function (value) + { + this.blendMode = value; + + return this; + } + +}; + +module.exports = BlendMode; + + +/***/ }), +/* 437 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * This event is dispatched when an animation starts playing. + * + * Listen for it on the Game Object: `sprite.on('animationstart', listener)` + * + * @event Phaser.GameObjects.Components.Animation#onStartEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. + */ + +/** + * This event is dispatched when an animation restarts. + * + * Listen for it on the Game Object: `sprite.on('animationrestart', listener)` + * + * @event Phaser.GameObjects.Components.Animation#onRestartEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. + */ + +/** + * This event is dispatched when an animation repeats. + * + * Listen for it on the Game Object: `sprite.on('animationrepeat', listener)` + * + * @event Phaser.GameObjects.Components.Animation#onRepeatEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {integer} repeatCount - The number of times this animation has repeated. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. + */ + +/** + * This event is dispatched when an animation updates. This happens when the animation frame changes, + * based on the animation frame rate and other factors like timeScale and delay. + * + * Listen for it on the Game Object: `sprite.on('animationupdate', listener)` + * + * @event Phaser.GameObjects.Components.Animation#onUpdateEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. + */ + +/** + * This event is dispatched when an animation completes playing, either naturally or via Animation.stop. + * + * Listen for it on the Game Object: `sprite.on('animationcomplete', listener)` + * + * @event Phaser.GameObjects.Components.Animation#onCompleteEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. + */ + +/** + * @classdesc + * A Game Object Animation Controller. + * + * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. + * + * @class Animation + * @memberof Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} parent - The Game Object to which this animation controller belongs. + */ +var Animation = new Class({ + + initialize: + + function Animation (parent) + { + /** + * The Game Object to which this animation controller belongs. + * + * @name Phaser.GameObjects.Components.Animation#parent + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * A reference to the global Animation Manager. + * + * @name Phaser.GameObjects.Components.Animation#animationManager + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.animationManager = parent.scene.sys.anims; + + this.animationManager.once('remove', this.remove, this); + + /** + * Is an animation currently playing or not? + * + * @name Phaser.GameObjects.Components.Animation#isPlaying + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPlaying = false; + + /** + * The current Animation loaded into this Animation Controller. + * + * @name Phaser.GameObjects.Components.Animation#currentAnim + * @type {?Phaser.Animations.Animation} + * @default null + * @since 3.0.0 + */ + this.currentAnim = null; + + /** + * The current AnimationFrame being displayed by this Animation Controller. + * + * @name Phaser.GameObjects.Components.Animation#currentFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @since 3.0.0 + */ + this.currentFrame = null; + + /** + * Time scale factor. + * + * @name Phaser.GameObjects.Components.Animation#_timeScale + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._timeScale = 1; + + /** + * The frame rate of playback in frames per second. + * The default is 24 if the `duration` property is `null`. + * + * @name Phaser.GameObjects.Components.Animation#frameRate + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.frameRate = 0; + + /** + * How long the animation should play for, in milliseconds. + * If the `frameRate` property has been set then it overrides this value, + * otherwise the `frameRate` is derived from `duration`. + * + * @name Phaser.GameObjects.Components.Animation#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * ms per frame, not including frame specific modifiers that may be present in the Animation data. + * + * @name Phaser.GameObjects.Components.Animation#msPerFrame + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.msPerFrame = 0; + + /** + * Skip frames if the time lags, or always advanced anyway? + * + * @name Phaser.GameObjects.Components.Animation#skipMissedFrames + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.skipMissedFrames = true; + + /** + * A delay before starting playback, in milliseconds. + * + * @name Phaser.GameObjects.Components.Animation#_delay + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._delay = 0; + + /** + * Number of times to repeat the animation (-1 for infinity) + * + * @name Phaser.GameObjects.Components.Animation#_repeat + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._repeat = 0; + + /** + * Delay before the repeat starts, in milliseconds. + * + * @name Phaser.GameObjects.Components.Animation#_repeatDelay + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._repeatDelay = 0; + + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + * + * @name Phaser.GameObjects.Components.Animation#_yoyo + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._yoyo = false; + + /** + * Will the playhead move forwards (`true`) or in reverse (`false`). + * + * @name Phaser.GameObjects.Components.Animation#forward + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.forward = true; + + /** + * An Internal trigger that's play the animation in reverse mode ('true') or not ('false'), + * needed because forward can be changed by yoyo feature. + * + * @name Phaser.GameObjects.Components.Animation#forward + * @type {boolean} + * @default false + * @since 3.12.0 + */ + this._reverse = false; + + /** + * Internal time overflow accumulator. + * + * @name Phaser.GameObjects.Components.Animation#accumulator + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accumulator = 0; + + /** + * The time point at which the next animation frame will change. + * + * @name Phaser.GameObjects.Components.Animation#nextTick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.nextTick = 0; + + /** + * An internal counter keeping track of how many repeats are left to play. + * + * @name Phaser.GameObjects.Components.Animation#repeatCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatCounter = 0; + + /** + * An internal flag keeping track of pending repeats. + * + * @name Phaser.GameObjects.Components.Animation#pendingRepeat + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pendingRepeat = false; + + /** + * Is the Animation paused? + * + * @name Phaser.GameObjects.Components.Animation#_paused + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._paused = false; + + /** + * Was the animation previously playing before being paused? + * + * @name Phaser.GameObjects.Components.Animation#_wasPlaying + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._wasPlaying = false; + + /** + * Internal property tracking if this Animation is waiting to stop. + * + * 0 = No + * 1 = Waiting for ms to pass + * 2 = Waiting for repeat + * 3 = Waiting for specific frame + * + * @name Phaser.GameObjects.Components.Animation#_pendingStop + * @type {integer} + * @private + * @since 3.4.0 + */ + this._pendingStop = 0; + + /** + * Internal property used by _pendingStop. + * + * @name Phaser.GameObjects.Components.Animation#_pendingStopValue + * @type {any} + * @private + * @since 3.4.0 + */ + this._pendingStopValue; + }, + + /** + * Sets the amount of time, in milliseconds, that the animation will be delayed before starting playback. + * + * @method Phaser.GameObjects.Components.Animation#setDelay + * @since 3.4.0 + * + * @param {integer} [value=0] - The amount of time, in milliseconds, to wait before starting playback. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setDelay: function (value) + { + if (value === undefined) { value = 0; } + + this._delay = value; + + return this.parent; + }, + + /** + * Gets the amount of time, in milliseconds that the animation will be delayed before starting playback. + * + * @method Phaser.GameObjects.Components.Animation#getDelay + * @since 3.4.0 + * + * @return {integer} The amount of time, in milliseconds, the Animation will wait before starting playback. + */ + getDelay: function () + { + return this._delay; + }, + + /** + * Waits for the specified delay, in milliseconds, then starts playback of the requested animation. + * + * @method Phaser.GameObjects.Components.Animation#delayedPlay + * @since 3.0.0 + * + * @param {integer} delay - The delay, in milliseconds, to wait before starting the animation playing. + * @param {string} key - The key of the animation to play. + * @param {integer} [startFrame=0] - The frame of the animation to start from. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + delayedPlay: function (delay, key, startFrame) + { + this.play(key, true, startFrame); + + this.nextTick += delay; + + return this.parent; + }, + + /** + * Returns the key of the animation currently loaded into this component. + * + * @method Phaser.GameObjects.Components.Animation#getCurrentKey + * @since 3.0.0 + * + * @return {string} The key of the Animation loaded into this component. + */ + getCurrentKey: function () + { + if (this.currentAnim) + { + return this.currentAnim.key; + } + }, + + /** + * Internal method used to load an animation into this component. + * + * @method Phaser.GameObjects.Components.Animation#load + * @protected + * @since 3.0.0 + * + * @param {string} key - The key of the animation to load. + * @param {integer} [startFrame=0] - The start frame of the animation to load. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + load: function (key, startFrame) + { + if (startFrame === undefined) { startFrame = 0; } + + if (this.isPlaying) + { + this.stop(); + } + + // Load the new animation in + this.animationManager.load(this, key, startFrame); + + return this.parent; + }, + + /** + * Pause the current animation and set the `isPlaying` property to `false`. + * You can optionally pause it at a specific frame. + * + * @method Phaser.GameObjects.Components.Animation#pause + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} [atFrame] - An optional frame to set after pausing the animation. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + pause: function (atFrame) + { + if (!this._paused) + { + this._paused = true; + this._wasPlaying = this.isPlaying; + this.isPlaying = false; + } + + if (atFrame !== undefined) + { + this.updateFrame(atFrame); + } + + return this.parent; + }, + + /** + * Resumes playback of a paused animation and sets the `isPlaying` property to `true`. + * You can optionally tell it to start playback from a specific frame. + * + * @method Phaser.GameObjects.Components.Animation#resume + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} [fromFrame] - An optional frame to set before restarting playback. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + resume: function (fromFrame) + { + if (this._paused) + { + this._paused = false; + this.isPlaying = this._wasPlaying; + } + + if (fromFrame !== undefined) + { + this.updateFrame(fromFrame); + } + + return this.parent; + }, + + /** + * `true` if the current animation is paused, otherwise `false`. + * + * @name Phaser.GameObjects.Components.Animation#isPaused + * @readonly + * @type {boolean} + * @since 3.4.0 + */ + isPaused: { + + get: function () + { + return this._paused; + } + + }, + + /** + * Plays an Animation on the Game Object that owns this Animation Component. + * + * @method Phaser.GameObjects.Components.Animation#play + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.0.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + if (startFrame === undefined) { startFrame = 0; } + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) + { + return this.parent; + } + + this.forward = true; + this._reverse = false; + + return this._startAnimation(key, startFrame); + }, + + /** + * Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component. + * + * @method Phaser.GameObjects.Components.Animation#playReverse + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + playReverse: function (key, ignoreIfPlaying, startFrame) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + if (startFrame === undefined) { startFrame = 0; } + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) + { + return this.parent; + } + + this.forward = false; + this._reverse = true; + + return this._startAnimation(key, startFrame); + }, + + /** + * Load an Animation and fires 'onStartEvent' event, + * extracted from 'play' method + * + * @method Phaser.GameObjects.Components.Animation#_startAnimation + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + _startAnimation: function (key, startFrame) + { + this.load(key, startFrame); + + var anim = this.currentAnim; + var gameObject = this.parent; + + // Should give us 9,007,199,254,740,991 safe repeats + this.repeatCounter = (this._repeat === -1) ? Number.MAX_VALUE : this._repeat; + + anim.getFirstTick(this); + + this.isPlaying = true; + this.pendingRepeat = false; + + if (anim.showOnStart) + { + gameObject.visible = true; + } + + gameObject.emit('animationstart', this.currentAnim, this.currentFrame, gameObject); + + return gameObject; + }, + + /** + * Reverse an Animation that is already playing on the Game Object. + * + * @method Phaser.GameObjects.Components.Animation#reverse + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + reverse: function (key) + { + if (!this.isPlaying || this.currentAnim.key !== key) { return this.parent; } + this._reverse = !this._reverse; + this.forward = !this.forward; + + return this.parent; + }, + + /** + * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. + * If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different + * because `getProgress` doesn't include any repeats or repeat delays, whereas `getTotalProgress` does. + * + * @method Phaser.GameObjects.Components.Animation#getProgress + * @since 3.4.0 + * + * @return {number} The progress of the current animation, between 0 and 1. + */ + getProgress: function () + { + var p = this.currentFrame.progress; + + if (!this.forward) + { + p = 1 - p; + } + + return p; + }, + + /** + * Takes a value between 0 and 1 and uses it to set how far this animation is through playback. + * Does not factor in repeats or yoyos, but does handle playing forwards or backwards. + * + * @method Phaser.GameObjects.Components.Animation#setProgress + * @since 3.4.0 + * + * @param {number} [value=0] - The progress value, between 0 and 1. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setProgress: function (value) + { + if (!this.forward) + { + value = 1 - value; + } + + this.setCurrentFrame(this.currentAnim.getFrameByProgress(value)); + + return this.parent; + }, + + /** + * Handle the removal of an animation from the Animation Manager. + * + * @method Phaser.GameObjects.Components.Animation#remove + * @since 3.0.0 + * + * @param {string} [key] - The key of the removed Animation. + * @param {Phaser.Animations.Animation} [animation] - The removed Animation. + */ + remove: function (key, animation) + { + if (animation === undefined) { animation = this.currentAnim; } + + if (this.isPlaying && animation.key === this.currentAnim.key) + { + this.stop(); + + this.setCurrentFrame(this.currentAnim.frames[0]); + } + }, + + /** + * Gets the number of times that the animation will repeat + * after its first iteration. For example, if returns 1, the animation will + * play a total of twice (the initial play plus 1 repeat). + * A value of -1 means the animation will repeat indefinitely. + * + * @method Phaser.GameObjects.Components.Animation#getRepeat + * @since 3.4.0 + * + * @return {integer} The number of times that the animation will repeat. + */ + getRepeat: function () + { + return this._repeat; + }, + + /** + * Sets the number of times that the animation should repeat + * after its first iteration. For example, if repeat is 1, the animation will + * play a total of twice (the initial play plus 1 repeat). + * To repeat indefinitely, use -1. repeat should always be an integer. + * + * @method Phaser.GameObjects.Components.Animation#setRepeat + * @since 3.4.0 + * + * @param {integer} value - The number of times that the animation should repeat. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setRepeat: function (value) + { + this._repeat = value; + + this.repeatCounter = 0; + + return this.parent; + }, + + /** + * Gets the amount of delay between repeats, if any. + * + * @method Phaser.GameObjects.Components.Animation#getRepeatDelay + * @since 3.4.0 + * + * @return {number} The delay between repeats. + */ + getRepeatDelay: function () + { + return this._repeatDelay; + }, + + /** + * Sets the amount of time in seconds between repeats. + * For example, if `repeat` is 2 and `repeatDelay` is 10, the animation will play initially, + * then wait for 10 seconds before repeating, then play again, then wait another 10 seconds + * before doing its final repeat. + * + * @method Phaser.GameObjects.Components.Animation#setRepeatDelay + * @since 3.4.0 + * + * @param {number} value - The delay to wait between repeats, in seconds. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setRepeatDelay: function (value) + { + this._repeatDelay = value; + + return this.parent; + }, + + /** + * Restarts the current animation from its beginning, optionally including its delay value. + * + * @method Phaser.GameObjects.Components.Animation#restart + * @fires Phaser.GameObjects.Components.Animation#onRestartEvent + * @since 3.0.0 + * + * @param {boolean} [includeDelay=false] - Whether to include the delay value of the animation when restarting. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + restart: function (includeDelay) + { + if (includeDelay === undefined) { includeDelay = false; } + + this.currentAnim.getFirstTick(this, includeDelay); + + this.forward = true; + this.isPlaying = true; + this.pendingRepeat = false; + this._paused = false; + + // Set frame + this.updateFrame(this.currentAnim.frames[0]); + + var gameObject = this.parent; + + gameObject.emit('animationrestart', this.currentAnim, this.currentFrame, gameObject); + + return this.parent; + }, + + /** + * Immediately stops the current animation from playing and dispatches the `animationcomplete` event. + * + * @method Phaser.GameObjects.Components.Animation#stop + * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stop: function () + { + this._pendingStop = 0; + + this.isPlaying = false; + + var gameObject = this.parent; + + gameObject.emit('animationcomplete', this.currentAnim, this.currentFrame, gameObject); + + return gameObject; + }, + + /** + * Stops the current animation from playing after the specified time delay, given in milliseconds. + * + * @method Phaser.GameObjects.Components.Animation#stopAfterDelay + * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent + * @since 3.4.0 + * + * @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. + */ + stopAfterDelay: function (delay) + { + this._pendingStop = 1; + this._pendingStopValue = delay; + + return this.parent; + }, + + /** + * Stops the current animation from playing when it next repeats. + * + * @method Phaser.GameObjects.Components.Animation#stopOnRepeat + * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent + * @since 3.4.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stopOnRepeat: function () + { + this._pendingStop = 2; + + return this.parent; + }, + + /** + * Stops the current animation from playing when it next sets the given frame. + * If this frame doesn't exist within the animation it will not stop it from playing. + * + * @method Phaser.GameObjects.Components.Animation#stopOnFrame + * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent + * @since 3.4.0 + * + * @param {Phaser.Animations.AnimationFrame} delay - The frame to check before stopping this animation. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stopOnFrame: function (frame) + { + this._pendingStop = 3; + this._pendingStopValue = frame; + + return this.parent; + }, + + /** + * Sets the Time Scale factor, allowing you to make the animation go go faster or slower than default. + * Where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. + * + * @method Phaser.GameObjects.Components.Animation#setTimeScale + * @since 3.4.0 + * + * @param {number} [value=1] - The time scale factor, where 1 is no change, 0.5 is half speed, etc. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setTimeScale: function (value) + { + if (value === undefined) { value = 1; } + + this._timeScale = value; + + return this.parent; + }, + + /** + * Gets the Time Scale factor. + * + * @method Phaser.GameObjects.Components.Animation#getTimeScale + * @since 3.4.0 + * + * @return {number} The Time Scale value. + */ + getTimeScale: function () + { + return this._timeScale; + }, + + /** + * Returns the total number of frames in this animation. + * + * @method Phaser.GameObjects.Components.Animation#getTotalFrames + * @since 3.4.0 + * + * @return {integer} The total number of frames in this animation. + */ + getTotalFrames: function () + { + return this.currentAnim.frames.length; + }, + + /** + * The internal update loop for the Animation Component. + * + * @method Phaser.GameObjects.Components.Animation#update + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (!this.currentAnim || !this.isPlaying || this.currentAnim.paused) + { + return; + } + + this.accumulator += delta * this._timeScale; + + if (this._pendingStop === 1) + { + this._pendingStopValue -= delta; + + if (this._pendingStopValue <= 0) + { + return this.currentAnim.completeAnimation(this); + } + } + + if (this.accumulator >= this.nextTick) + { + this.currentAnim.setFrame(this); + } + }, + + /** + * Sets the given Animation Frame as being the current frame + * and applies it to the parent Game Object, adjusting its size and origin as needed. + * + * @method Phaser.GameObjects.Components.Animation#setCurrentFrame + * @since 3.4.0 + * + * @param {Phaser.Animations.AnimationFrame} animationFrame - The Animation Frame to set as being current. + * + * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. + */ + setCurrentFrame: function (animationFrame) + { + var gameObject = this.parent; + + this.currentFrame = animationFrame; + + gameObject.texture = animationFrame.frame.texture; + gameObject.frame = animationFrame.frame; + + if (gameObject.isCropped) + { + gameObject.frame.updateCropUVs(gameObject._crop, gameObject.flipX, gameObject.flipY); + } + + gameObject.setSizeToFrame(); + + if (animationFrame.frame.customPivot) + { + gameObject.setOrigin(animationFrame.frame.pivotX, animationFrame.frame.pivotY); + } + else + { + gameObject.updateDisplayOrigin(); + } + + return gameObject; + }, + + /** + * Internal frame change handler. + * + * @method Phaser.GameObjects.Components.Animation#updateFrame + * @fires Phaser.GameObjects.Components.Animation#onUpdateEvent + * @private + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} animationFrame - The animation frame to change to. + */ + updateFrame: function (animationFrame) + { + var gameObject = this.setCurrentFrame(animationFrame); + + if (this.isPlaying) + { + if (animationFrame.setAlpha) + { + gameObject.alpha = animationFrame.alpha; + } + + var anim = this.currentAnim; + + gameObject.emit('animationupdate', anim, animationFrame, gameObject); + + if (this._pendingStop === 3 && this._pendingStopValue === animationFrame) + { + this.currentAnim.completeAnimation(this); + } + } + }, + + /** + * Sets if the current Animation will yoyo when it reaches the end. + * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. + * + * @method Phaser.GameObjects.Components.Animation#setYoyo + * @since 3.4.0 + * + * @param {boolean} [value=false] - `true` if the animation should yoyo, `false` to not. + * + * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. + */ + setYoyo: function (value) + { + if (value === undefined) { value = false; } + + this._yoyo = value; + + return this.parent; + }, + + /** + * Gets if the current Animation will yoyo when it reaches the end. + * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. + * + * @method Phaser.GameObjects.Components.Animation#getYoyo + * @since 3.4.0 + * + * @return {boolean} `true` if the animation is set to yoyo, `false` if not. + */ + getYoyo: function () + { + return this._yoyo; + }, + + /** + * Destroy this Animation component. + * + * Unregisters event listeners and cleans up its references. + * + * @method Phaser.GameObjects.Components.Animation#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.animationManager.off('remove', this.remove, this); + + this.animationManager = null; + this.parent = null; + + this.currentAnim = null; + this.currentFrame = null; + } + +}); + +module.exports = Animation; + + +/***/ }), +/* 438 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); + +// bitmask flag for GameObject.renderMask +var _FLAG = 2; // 0010 + +/** + * Provides methods used for setting the alpha properties of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Alpha + * @since 3.0.0 + */ + +var Alpha = { + + /** + * Private internal value. Holds the global alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alpha: 1, + + /** + * Private internal value. Holds the top-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTL: 1, + + /** + * Private internal value. Holds the top-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTR: 1, + + /** + * Private internal value. Holds the bottom-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBL: 1, + + /** + * Private internal value. Holds the bottom-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBR: 1, + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + * + * @method Phaser.GameObjects.Components.Alpha#clearAlpha + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearAlpha: function () + { + return this.setAlpha(1); + }, + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * + * @method Phaser.GameObjects.Components.Alpha#setAlpha + * @since 3.0.0 + * + * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * + * @return {this} This Game Object instance. + */ + setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 1; } + + // Treat as if there is only one alpha value for the whole Game Object + if (topRight === undefined) + { + this.alpha = topLeft; + } + else + { + this._alphaTL = Clamp(topLeft, 0, 1); + this._alphaTR = Clamp(topRight, 0, 1); + this._alphaBL = Clamp(bottomLeft, 0, 1); + this._alphaBR = Clamp(bottomRight, 0, 1); + } + + return this; + }, + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + * + * @name Phaser.GameObjects.Components.Alpha#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alpha = v; + this._alphaTL = v; + this._alphaTR = v; + this._alphaBL = v; + this._alphaBR = v; + + if (v === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopLeft: { + + get: function () + { + return this._alphaTL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopRight: { + + get: function () + { + return this._alphaTR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomLeft: { + + get: function () + { + return this._alphaBL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomRight: { + + get: function () + { + return this._alphaBR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + } + +}; + +module.exports = Alpha; + + +/***/ }), +/* 439 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the circumference of the given Circle. + * + * @function Phaser.Geom.Circle.Circumference + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference of. + * + * @return {number} The circumference of the Circle. + */ +var Circumference = function (circle) +{ + return 2 * (Math.PI * circle.radius); +}; + +module.exports = Circumference; + + +/***/ }), +/* 440 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circumference = __webpack_require__(439); +var CircumferencePoint = __webpack_require__(211); +var FromPercent = __webpack_require__(103); +var MATH_CONST = __webpack_require__(18); + +/** + * Returns an array of Point objects containing the coordinates of the points around the circumference of the Circle, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Circle.GetPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the circumference of the circle and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the circumference of the circle. + */ +var GetPoints = function (circle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Circumference(circle) / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var angle = FromPercent(i / quantity, 0, MATH_CONST.PI2); + + out.push(CircumferencePoint(circle, angle)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 441 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A seeded Random Data Generator. + * + * Access via `Phaser.Math.RND` which is an instance of this class pre-defined + * by Phaser. Or, create your own instance to use as you require. + * + * The `Math.RND` generator is seeded by the Game Config property value `seed`. + * If no such config property exists, a random number is used. + * + * If you create your own instance of this class you should provide a seed for it. + * If no seed is given it will use a 'random' one based on Date.now. + * + * @class RandomDataGenerator + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {(string|string[])} [seeds] - The seeds to use for the random number generator. + */ +var RandomDataGenerator = new Class({ + + initialize: + + function RandomDataGenerator (seeds) + { + if (seeds === undefined) { seeds = [ (Date.now() * Math.random()).toString() ]; } + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#c + * @type {number} + * @default 1 + * @private + * @since 3.0.0 + */ + this.c = 1; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s0 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s0 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s1 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s1 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s2 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s2 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#n + * @type {number} + * @default 0 + * @private + * @since 3.2.0 + */ + this.n = 0; + + /** + * Signs to choose from. + * + * @name Phaser.Math.RandomDataGenerator#signs + * @type {number[]} + * @since 3.0.0 + */ + this.signs = [ -1, 1 ]; + + if (seeds) + { + this.init(seeds); + } + }, + + /** + * Private random helper. + * + * @method Phaser.Math.RandomDataGenerator#rnd + * @since 3.0.0 + * @private + * + * @return {number} A random number. + */ + rnd: function () + { + var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32 + + this.c = t | 0; + this.s0 = this.s1; + this.s1 = this.s2; + this.s2 = t - this.c; + + return this.s2; + }, + + /** + * Internal method that creates a seed hash. + * + * @method Phaser.Math.RandomDataGenerator#hash + * @since 3.0.0 + * @private + * + * @param {string} data - The value to hash. + * + * @return {number} The hashed value. + */ + hash: function (data) + { + var h; + var n = this.n; + + data = data.toString(); + + for (var i = 0; i < data.length; i++) + { + n += data.charCodeAt(i); + h = 0.02519603282416938 * n; + n = h >>> 0; + h -= n; + h *= n; + n = h >>> 0; + h -= n; + n += h * 0x100000000;// 2^32 + } + + this.n = n; + + return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 + }, + + /** + * Initialize the state of the random data generator. + * + * @method Phaser.Math.RandomDataGenerator#init + * @since 3.0.0 + * + * @param {(string|string[])} seeds - The seeds to initialize the random data generator with. + */ + init: function (seeds) + { + if (typeof seeds === 'string') + { + this.state(seeds); + } + else + { + this.sow(seeds); + } + }, + + /** + * Reset the seed of the random data generator. + * + * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. + * + * @method Phaser.Math.RandomDataGenerator#sow + * @since 3.0.0 + * + * @param {string[]} seeds - The array of seeds: the `toString()` of each value is used. + */ + sow: function (seeds) + { + // Always reset to default seed + this.n = 0xefc8249d; + this.s0 = this.hash(' '); + this.s1 = this.hash(' '); + this.s2 = this.hash(' '); + this.c = 1; + + if (!seeds) + { + return; + } + + // Apply any seeds + for (var i = 0; i < seeds.length && (seeds[i] != null); i++) + { + var seed = seeds[i]; + + this.s0 -= this.hash(seed); + this.s0 += ~~(this.s0 < 0); + this.s1 -= this.hash(seed); + this.s1 += ~~(this.s1 < 0); + this.s2 -= this.hash(seed); + this.s2 += ~~(this.s2 < 0); + } + }, + + /** + * Returns a random integer between 0 and 2^32. + * + * @method Phaser.Math.RandomDataGenerator#integer + * @since 3.0.0 + * + * @return {number} A random integer between 0 and 2^32. + */ + integer: function () + { + // 2^32 + return this.rnd() * 0x100000000; + }, + + /** + * Returns a random real number between 0 and 1. + * + * @method Phaser.Math.RandomDataGenerator#frac + * @since 3.0.0 + * + * @return {number} A random real number between 0 and 1. + */ + frac: function () + { + // 2^-53 + return this.rnd() + (this.rnd() * 0x200000 | 0) * 1.1102230246251565e-16; + }, + + /** + * Returns a random real number between 0 and 2^32. + * + * @method Phaser.Math.RandomDataGenerator#real + * @since 3.0.0 + * + * @return {number} A random real number between 0 and 2^32. + */ + real: function () + { + return this.integer() + this.frac(); + }, + + /** + * Returns a random integer between and including min and max. + * + * @method Phaser.Math.RandomDataGenerator#integerInRange + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + integerInRange: function (min, max) + { + return Math.floor(this.realInRange(0, max - min + 1) + min); + }, + + /** + * Returns a random integer between and including min and max. + * This method is an alias for RandomDataGenerator.integerInRange. + * + * @method Phaser.Math.RandomDataGenerator#between + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + between: function (min, max) + { + return Math.floor(this.realInRange(0, max - min + 1) + min); + }, + + /** + * Returns a random real number between min and max. + * + * @method Phaser.Math.RandomDataGenerator#realInRange + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + realInRange: function (min, max) + { + return this.frac() * (max - min) + min; + }, + + /** + * Returns a random real number between -1 and 1. + * + * @method Phaser.Math.RandomDataGenerator#normal + * @since 3.0.0 + * + * @return {number} A random real number between -1 and 1. + */ + normal: function () + { + return 1 - (2 * this.frac()); + }, + + /** + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 + * + * @method Phaser.Math.RandomDataGenerator#uuid + * @since 3.0.0 + * + * @return {string} A valid RFC4122 version4 ID hex string + */ + uuid: function () + { + var a = ''; + var b = ''; + + for (b = a = ''; a++ < 36; b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac() * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') + { + // eslint-disable-next-line no-empty + } + + return b; + }, + + /** + * Returns a random element from within the given array. + * + * @method Phaser.Math.RandomDataGenerator#pick + * @since 3.0.0 + * + * @param {array} array - The array to pick a random element from. + * + * @return {*} A random member of the array. + */ + pick: function (array) + { + return array[this.integerInRange(0, array.length - 1)]; + }, + + /** + * Returns a sign to be used with multiplication operator. + * + * @method Phaser.Math.RandomDataGenerator#sign + * @since 3.0.0 + * + * @return {number} -1 or +1. + */ + sign: function () + { + return this.pick(this.signs); + }, + + /** + * Returns a random element from within the given array, favoring the earlier entries. + * + * @method Phaser.Math.RandomDataGenerator#weightedPick + * @since 3.0.0 + * + * @param {array} array - The array to pick a random element from. + * + * @return {*} A random member of the array. + */ + weightedPick: function (array) + { + return array[~~(Math.pow(this.frac(), 2) * (array.length - 1) + 0.5)]; + }, + + /** + * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. + * + * @method Phaser.Math.RandomDataGenerator#timestamp + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random timestamp between min and max. + */ + timestamp: function (min, max) + { + return this.realInRange(min || 946684800000, max || 1577862000000); + }, + + /** + * Returns a random angle between -180 and 180. + * + * @method Phaser.Math.RandomDataGenerator#angle + * @since 3.0.0 + * + * @return {number} A random number between -180 and 180. + */ + angle: function () + { + return this.integerInRange(-180, 180); + }, + + /** + * Returns a random rotation in radians, between -3.141 and 3.141 + * + * @method Phaser.Math.RandomDataGenerator#rotation + * @since 3.0.0 + * + * @return {number} A random number between -3.141 and 3.141 + */ + rotation: function () + { + return this.realInRange(-3.1415926, 3.1415926); + }, + + /** + * Gets or Sets the state of the generator. This allows you to retain the values + * that the generator is using between games, i.e. in a game save file. + * + * To seed this generator with a previously saved state you can pass it as the + * `seed` value in your game config, or call this method directly after Phaser has booted. + * + * Call this method with no parameters to return the current state. + * + * If providing a state it should match the same format that this method + * returns, which is a string with a header `!rnd` followed by the `c`, + * `s0`, `s1` and `s2` values respectively, each comma-delimited. + * + * @method Phaser.Math.RandomDataGenerator#state + * @since 3.0.0 + * + * @param {string} [state] - Generator state to be set. + * + * @return {string} The current state of the generator. + */ + state: function (state) + { + if (typeof state === 'string' && state.match(/^!rnd/)) + { + state = state.split(','); + + this.c = parseFloat(state[1]); + this.s0 = parseFloat(state[2]); + this.s1 = parseFloat(state[3]); + this.s2 = parseFloat(state[4]); + } + + return [ '!rnd', this.c, this.s0, this.s1, this.s2 ].join(','); + }, + + /** + * Shuffles the given array, using the current seed. + * + * @method Phaser.Math.RandomDataGenerator#shuffle + * @since 3.7.0 + * + * @param {array} [array] - The array to be shuffled. + * + * @return {array} The shuffled array. + */ + shuffle: function (array) + { + var len = array.length - 1; + + for (var i = len; i > 0; i--) + { + var randomIndex = Math.floor(this.frac() * (len + 1)); + var itemAtIndex = array[randomIndex]; + + array[randomIndex] = array[i]; + array[i] = itemAtIndex; + } + + return array; + } + +}); + +module.exports = RandomDataGenerator; + + +/***/ }), +/* 442 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircumferencePoint = __webpack_require__(211); +var FromPercent = __webpack_require__(103); +var MATH_CONST = __webpack_require__(18); +var Point = __webpack_require__(6); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle + * based on the given angle normalized to the range 0 to 1. I.e. a value of 0.5 will give the point + * at 180 degrees around the circle. + * + * @function Phaser.Geom.Circle.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. + */ +var GetPoint = function (circle, position, out) +{ + if (out === undefined) { out = new Point(); } + + var angle = FromPercent(position, 0, MATH_CONST.PI2); + + return CircumferencePoint(circle, angle, out); +}; + +module.exports = GetPoint; + + +/***/ }), +/* 443 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(48); +var GetTop = __webpack_require__(46); +var SetRight = __webpack_require__(47); +var SetTop = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned in the top right of the other. + * + * @function Phaser.Display.Align.In.TopRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }), +/* 444 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(50); +var GetTop = __webpack_require__(46); +var SetLeft = __webpack_require__(49); +var SetTop = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned in the top left of the other. + * + * @function Phaser.Display.Align.In.TopLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }), +/* 445 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterX = __webpack_require__(85); +var GetTop = __webpack_require__(46); +var SetCenterX = __webpack_require__(84); +var SetTop = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned in the top center of the other. + * + * @function Phaser.Display.Align.In.TopCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }), +/* 446 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(82); +var GetRight = __webpack_require__(48); +var SetCenterY = __webpack_require__(83); +var SetRight = __webpack_require__(47); + +/** + * Takes given Game Object and aligns it so that it is positioned in the right center of the other. + * + * @function Phaser.Display.Align.In.RightCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }), +/* 447 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(82); +var GetLeft = __webpack_require__(50); +var SetCenterY = __webpack_require__(83); +var SetLeft = __webpack_require__(49); + +/** + * Takes given Game Object and aligns it so that it is positioned in the left center of the other. + * + * @function Phaser.Display.Align.In.LeftCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }), +/* 448 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetCenterX = __webpack_require__(84); +var SetCenterY = __webpack_require__(83); + +/** + * Positions the Game Object so that it is centered on the given coordinates. + * + * @function Phaser.Display.Bounds.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The horizontal coordinate to position the Game Object on. + * @param {number} y - The vertical coordinate to position the Game Object on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var CenterOn = function (gameObject, x, y) +{ + SetCenterX(gameObject, x); + + return SetCenterY(gameObject, y); +}; + +module.exports = CenterOn; + + +/***/ }), +/* 449 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CenterOn = __webpack_require__(448); +var GetCenterX = __webpack_require__(85); +var GetCenterY = __webpack_require__(82); + +/** + * Takes given Game Object and aligns it so that it is positioned in the center of the other. + * + * @function Phaser.Display.Align.In.Center + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var Center = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = Center; + + +/***/ }), +/* 450 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(52); +var GetRight = __webpack_require__(48); +var SetBottom = __webpack_require__(51); +var SetRight = __webpack_require__(47); + +/** + * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. + * + * @function Phaser.Display.Align.In.BottomRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }), +/* 451 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(52); +var GetLeft = __webpack_require__(50); +var SetBottom = __webpack_require__(51); +var SetLeft = __webpack_require__(49); + +/** + * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. + * + * @function Phaser.Display.Align.In.BottomLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }), +/* 452 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(52); +var GetCenterX = __webpack_require__(85); +var SetBottom = __webpack_require__(51); +var SetCenterX = __webpack_require__(84); + +/** + * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. + * + * @function Phaser.Display.Align.In.BottomCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }), +/* 453 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ALIGN_CONST = __webpack_require__(212); + +var AlignInMap = []; + +AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(452); +AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(451); +AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(450); +AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(449); +AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(447); +AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(446); +AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(445); +AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(444); +AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(443); + +/** + * Takes given Game Object and aligns it so that it is positioned relative to the other. + * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. + * + * @function Phaser.Display.Align.In.QuickSet + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [child,$return] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var QuickSet = function (child, alignIn, position, offsetX, offsetY) +{ + return AlignInMap[position](child, alignIn, offsetX, offsetY); +}; + +module.exports = QuickSet; + + +/***/ }), +/* 454 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Actions + */ + +module.exports = { + + Angle: __webpack_require__(1122), + Call: __webpack_require__(1121), + GetFirst: __webpack_require__(1120), + GetLast: __webpack_require__(1119), + GridAlign: __webpack_require__(1118), + IncAlpha: __webpack_require__(1107), + IncX: __webpack_require__(1106), + IncXY: __webpack_require__(1105), + IncY: __webpack_require__(1104), + PlaceOnCircle: __webpack_require__(1103), + PlaceOnEllipse: __webpack_require__(1102), + PlaceOnLine: __webpack_require__(1101), + PlaceOnRectangle: __webpack_require__(1100), + PlaceOnTriangle: __webpack_require__(1099), + PlayAnimation: __webpack_require__(1098), + PropertyValueInc: __webpack_require__(37), + PropertyValueSet: __webpack_require__(27), + RandomCircle: __webpack_require__(1097), + RandomEllipse: __webpack_require__(1096), + RandomLine: __webpack_require__(1095), + RandomRectangle: __webpack_require__(1094), + RandomTriangle: __webpack_require__(1093), + Rotate: __webpack_require__(1092), + RotateAround: __webpack_require__(1091), + RotateAroundDistance: __webpack_require__(1090), + ScaleX: __webpack_require__(1089), + ScaleXY: __webpack_require__(1088), + ScaleY: __webpack_require__(1087), + SetAlpha: __webpack_require__(1086), + SetBlendMode: __webpack_require__(1085), + SetDepth: __webpack_require__(1084), + SetHitArea: __webpack_require__(1083), + SetOrigin: __webpack_require__(1082), + SetRotation: __webpack_require__(1081), + SetScale: __webpack_require__(1080), + SetScaleX: __webpack_require__(1079), + SetScaleY: __webpack_require__(1078), + SetTint: __webpack_require__(1077), + SetVisible: __webpack_require__(1076), + SetX: __webpack_require__(1075), + SetXY: __webpack_require__(1074), + SetY: __webpack_require__(1073), + ShiftPosition: __webpack_require__(1072), + Shuffle: __webpack_require__(1071), + SmootherStep: __webpack_require__(1070), + SmoothStep: __webpack_require__(1069), + Spread: __webpack_require__(1068), + ToggleVisible: __webpack_require__(1067), + WrapInRectangle: __webpack_require__(1066) + +}; + + +/***/ }), +/* 455 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given string and reverses it, returning the reversed string. + * For example if given the string `Atari 520ST` it would return `TS025 iratA`. + * + * @function Phaser.Utils.String.ReverseString + * @since 3.0.0 + * + * @param {string} string - The string to be reversed. + * + * @return {string} The reversed string. + */ +var ReverseString = function (string) +{ + return string.split('').reverse().join(''); +}; + +module.exports = ReverseString; + + +/***/ }), +/* 456 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes a string and replaces instances of markers with values in the given array. + * The markers take the form of `%1`, `%2`, etc. I.e.: + * + * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` + * + * @function Phaser.Utils.String.Format + * @since 3.0.0 + * + * @param {string} string - The string containing the replacement markers. + * @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead. + * + * @return {string} The string containing replaced values. + */ +var Format = function (string, values) +{ + return string.replace(/%([0-9]+)/g, function (s, n) + { + return values[Number(n) - 1]; + }); +}; + +module.exports = Format; + + +/***/ }), +/* 457 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.String + */ + +module.exports = { + + Format: __webpack_require__(456), + Pad: __webpack_require__(197), + Reverse: __webpack_require__(455), + UppercaseFirst: __webpack_require__(356), + UUID: __webpack_require__(323) + +}; + + +/***/ }), +/* 458 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(69); + +/** + * Creates a new Object using all values from obj1. + * + * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. + * + * @function Phaser.Utils.Objects.MergeRight + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var MergeRight = function (obj1, obj2) +{ + var clone = Clone(obj1); + + for (var key in obj2) + { + if (clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } + + return clone; +}; + +module.exports = MergeRight; + + +/***/ }), +/* 459 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Verifies that an object contains all requested keys + * + * @function Phaser.Utils.Objects.HasAll + * @since 3.0.0 + * + * @param {object} source - an object on which to check for key existence + * @param {string[]} keys - an array of keys to ensure the source object contains + * + * @return {boolean} true if the source object contains all keys, false otherwise. + */ +var HasAll = function (source, keys) +{ + for (var i = 0; i < keys.length; i++) + { + if (!source.hasOwnProperty(keys[i])) + { + return false; + } + } + + return true; +}; + +module.exports = HasAll; + + +/***/ }), +/* 460 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); +var Clamp = __webpack_require__(24); + +/** + * Retrieves and clamps a numerical value from an object. + * + * @function Phaser.Utils.Objects.GetMinMaxValue + * @since 3.0.0 + * + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`). + * @param {number} min - The minimum value which can be returned. + * @param {number} max - The maximum value which can be returned. + * @param {number} defaultValue - The value to return if the property doesn't exist. It's also constrained to the given bounds. + * + * @return {number} The clamped value from the `source` object. + */ +var GetMinMaxValue = function (source, key, min, max, defaultValue) +{ + if (defaultValue === undefined) { defaultValue = min; } + + var value = GetValue(source, key, defaultValue); + + return Clamp(value, min, max); +}; + +module.exports = GetMinMaxValue; + + +/***/ }), +/* 461 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.Object + */ + +module.exports = { + + Clone: __webpack_require__(69), + Extend: __webpack_require__(21), + GetAdvancedValue: __webpack_require__(13), + GetFastValue: __webpack_require__(1), + GetMinMaxValue: __webpack_require__(460), + GetValue: __webpack_require__(4), + HasAll: __webpack_require__(459), + HasAny: __webpack_require__(326), + HasValue: __webpack_require__(77), + IsPlainObject: __webpack_require__(8), + Merge: __webpack_require__(79), + MergeRight: __webpack_require__(458) + +}; + + +/***/ }), +/* 462 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils + */ + +module.exports = { + + Array: __webpack_require__(180), + Objects: __webpack_require__(461), + String: __webpack_require__(457) + +}; + + +/***/ }), +/* 463 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var NumberTweenBuilder = __webpack_require__(216); +var PluginCache = __webpack_require__(15); +var TimelineBuilder = __webpack_require__(215); +var TWEEN_CONST = __webpack_require__(93); +var TweenBuilder = __webpack_require__(105); + +/** + * @classdesc + * [description] + * + * @class TweenManager + * @memberof Phaser.Tweens + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var TweenManager = new Class({ + + initialize: + + function TweenManager (scene) + { + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_add + * @type {array} + * @private + * @since 3.0.0 + */ + this._add = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_pending + * @type {array} + * @private + * @since 3.0.0 + */ + this._pending = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_active + * @type {array} + * @private + * @since 3.0.0 + */ + this._active = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_destroy + * @type {array} + * @private + * @since 3.0.0 + */ + this._destroy = []; + + /** + * [description] + * + * @name Phaser.Tweens.TweenManager#_toProcess + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._toProcess = 0; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Tweens.TweenManager#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.systems.events.once('destroy', this.destroy, 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.Tweens.TweenManager#start + * @private + * @since 3.5.0 + */ + start: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('preupdate', this.preUpdate, this); + eventEmitter.on('update', this.update, this); + eventEmitter.once('shutdown', this.shutdown, this); + + this.timeScale = 1; + }, + + /** + * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. + * + * @method Phaser.Tweens.TweenManager#createTimeline + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} [description] + */ + createTimeline: function (config) + { + return TimelineBuilder(this, config); + }, + + /** + * Create a Tween Timeline and add it to the active Tween list/ + * + * @method Phaser.Tweens.TweenManager#timeline + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Timeline} [description] + */ + timeline: function (config) + { + var timeline = TimelineBuilder(this, config); + + if (!timeline.paused) + { + this._add.push(timeline); + + this._toProcess++; + } + + return timeline; + }, + + /** + * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. + * + * @method Phaser.Tweens.TweenManager#create + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ + create: function (config) + { + return TweenBuilder(this, config); + }, + + /** + * Create a Tween and add it to the active Tween list. + * + * @method Phaser.Tweens.TweenManager#add + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ + add: function (config) + { + var tween = TweenBuilder(this, config); + + this._add.push(tween); + + this._toProcess++; + + return tween; + }, + + /** + * Add an existing tween into the active Tween list. + * + * @method Phaser.Tweens.TweenManager#existing + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {Phaser.Tweens.TweenManager} This Tween Manager object. + */ + existing: function (tween) + { + this._add.push(tween); + + this._toProcess++; + + return this; + }, + + /** + * Create a Tween and add it to the active Tween list. + * + * @method Phaser.Tweens.TweenManager#addCounter + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ + addCounter: function (config) + { + var tween = NumberTweenBuilder(this, config); + + this._add.push(tween); + + this._toProcess++; + + return tween; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#preUpdate + * @since 3.0.0 + */ + preUpdate: function () + { + if (this._toProcess === 0) + { + // Quick bail + return; + } + + var list = this._destroy; + var active = this._active; + var pending = this._pending; + var i; + var tween; + + // Clear the 'destroy' list + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + // Remove from the 'active' array + var idx = active.indexOf(tween); + + if (idx === -1) + { + // Not in the active array, is it in pending instead? + idx = pending.indexOf(tween); + + if (idx > -1) + { + tween.state = TWEEN_CONST.REMOVED; + pending.splice(idx, 1); + } + } + else + { + tween.state = TWEEN_CONST.REMOVED; + active.splice(idx, 1); + } + } + + list.length = 0; + + // Process the addition list + // This stops callbacks and out of sync events from populating the active array mid-way during the update + + list = this._add; + + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + if (tween.state === TWEEN_CONST.PENDING_ADD) + { + // Return true if the Tween should be started right away, otherwise false + if (tween.init()) + { + tween.play(); + + this._active.push(tween); + } + else + { + this._pending.push(tween); + } + } + } + + list.length = 0; + + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update: function (timestamp, delta) + { + // Process active tweens + var list = this._active; + var tween; + + // Scale the delta + delta *= this.timeScale; + + for (var i = 0; i < list.length; i++) + { + tween = list[i]; + + // If Tween.update returns 'true' then it means it has completed, + // so move it to the destroy list + if (tween.update(timestamp, delta)) + { + this._destroy.push(tween); + this._toProcess++; + } + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#makeActive + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * + * @return {Phaser.Tweens.TweenManager} This Tween Manager object. + */ + makeActive: function (tween) + { + if (this._add.indexOf(tween) !== -1 || this._active.indexOf(tween) !== -1) + { + return; + } + + var idx = this._pending.indexOf(tween); + + if (idx !== -1) + { + this._pending.splice(idx, 1); + } + + this._add.push(tween); + + tween.state = TWEEN_CONST.PENDING_ADD; + + this._toProcess++; + + return this; + }, + + /** + * Passes all Tweens to the given callback. + * + * @method Phaser.Tweens.TweenManager#each + * @since 3.0.0 + * + * @param {function} callback - [description] + * @param {object} [scope] - [description] + * @param {...*} [args] - [description] + */ + each: function (callback, scope) + { + var args = [ null ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var texture in this.list) + { + args[0] = this.list[texture]; + + callback.apply(scope, args); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#getAllTweens + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween[]} [description] + */ + getAllTweens: function () + { + var list = this._active; + var output = []; + + for (var i = 0; i < list.length; i++) + { + output.push(list[i]); + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#getGlobalTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getGlobalTimeScale: function () + { + return this.timeScale; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#getTweensOf + * @since 3.0.0 + * + * @param {(object|array)} target - [description] + * + * @return {Phaser.Tweens.Tween[]} [description] + */ + getTweensOf: function (target) + { + var list = this._active; + var tween; + var output = []; + var i; + + if (Array.isArray(target)) + { + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + for (var t = 0; t < target.length; t++) + { + if (tween.hasTarget(target[t])) + { + output.push(tween); + } + } + } + } + else + { + for (i = 0; i < list.length; i++) + { + tween = list[i]; + + if (tween.hasTarget(target)) + { + output.push(tween); + } + } + } + + return output; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#isTweening + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + isTweening: function (target) + { + var list = this._active; + var tween; + + for (var i = 0; i < list.length; i++) + { + tween = list[i]; + + if (tween.hasTarget(target) && tween.isPlaying()) + { + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#killAll + * @since 3.0.0 + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + killAll: function () + { + var tweens = this.getAllTweens(); + + for (var i = 0; i < tweens.length; i++) + { + tweens[i].stop(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#killTweensOf + * @since 3.0.0 + * + * @param {(object|array)} target - [description] + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + killTweensOf: function (target) + { + var tweens = this.getTweensOf(target); + + for (var i = 0; i < tweens.length; i++) + { + tweens[i].stop(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#pauseAll + * @since 3.0.0 + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + pauseAll: function () + { + var list = this._active; + + for (var i = 0; i < list.length; i++) + { + list[i].pause(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#resumeAll + * @since 3.0.0 + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + resumeAll: function () + { + var list = this._active; + + for (var i = 0; i < list.length; i++) + { + list[i].resume(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.TweenManager#setGlobalTimeScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Tweens.TweenManager} [description] + */ + setGlobalTimeScale: function (value) + { + this.timeScale = value; + + return 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.Tweens.TweenManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.killAll(); + + this._add = []; + this._pending = []; + this._active = []; + 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); + }, + + /** + * 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 + */ + destroy: function () + { + this.shutdown(); + + this.scene.sys.events.off('start', this.start, this); + + this.scene = null; + this.systems = null; + } + +}); + +PluginCache.register('TweenManager', TweenManager, 'tweens'); + +module.exports = TweenManager; + + +/***/ }), +/* 464 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// RESERVED properties that a Tween config object uses + +// completeDelay: The time the tween will wait before the onComplete event is dispatched once it has completed +// delay: The time the tween will wait before it first starts +// duration: The duration of the tween +// ease: The ease function used by the tween +// easeParams: The parameters to go with the ease function (if any) +// flipX: flip X the GameObject on tween end +// flipY: flip Y the GameObject on tween end// hold: The time the tween will pause before running a yoyo +// hold: The time the tween will pause before running a yoyo +// loop: The time the tween will pause before starting either a yoyo or returning to the start for a repeat +// loopDelay: +// offset: Used when the Tween is part of a Timeline +// paused: Does the tween start in a paused state, or playing? +// props: The properties being tweened by the tween +// repeat: The number of times the tween will repeat itself (a value of 1 means the tween will play twice, as it repeated once) +// repeatDelay: The time the tween will pause for before starting a repeat. The tween holds in the start state. +// targets: The targets the tween is updating. +// useFrames: Use frames or milliseconds? +// yoyo: boolean - Does the tween reverse itself (yoyo) when it reaches the end? + +module.exports = [ + 'callbackScope', + 'completeDelay', + 'delay', + 'duration', + 'ease', + 'easeParams', + 'flipX', + 'flipY', + 'hold', + 'loop', + 'loopDelay', + 'offset', + 'onComplete', + 'onCompleteParams', + 'onCompleteScope', + 'onLoop', + 'onLoopParams', + 'onLoopScope', + 'onRepeat', + 'onRepeatParams', + 'onRepeatScope', + 'onStart', + 'onStartParams', + 'onStartScope', + 'onUpdate', + 'onUpdateParams', + 'onUpdateScope', + 'onYoyo', + 'onYoyoParams', + 'onYoyoScope', + 'paused', + 'props', + 'repeat', + 'repeatDelay', + 'targets', + 'useFrames', + 'yoyo' +]; + + +/***/ }), +/* 465 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tweens.Builders + */ + +module.exports = { + + GetBoolean: __webpack_require__(94), + GetEaseFunction: __webpack_require__(95), + GetNewValue: __webpack_require__(106), + GetProps: __webpack_require__(218), + GetTargets: __webpack_require__(140), + GetTweens: __webpack_require__(217), + GetValueOp: __webpack_require__(139), + NumberTweenBuilder: __webpack_require__(216), + TimelineBuilder: __webpack_require__(215), + TweenBuilder: __webpack_require__(105) + +}; + + +/***/ }), +/* 466 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(93); +var Extend = __webpack_require__(21); + +/** + * @namespace Phaser.Tweens + */ + +var Tweens = { + + Builders: __webpack_require__(465), + + TweenManager: __webpack_require__(463), + Tween: __webpack_require__(137), + TweenData: __webpack_require__(136), + Timeline: __webpack_require__(214) + +}; + +// Merge in the consts +Tweens = Extend(false, Tweens, CONST); + +module.exports = Tweens; + + +/***/ }), +/* 467 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var PluginCache = __webpack_require__(15); +var TimerEvent = __webpack_require__(219); + +/** + * @classdesc + * [description] + * + * @class Clock + * @memberof Phaser.Time + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var Clock = new Class({ + + initialize: + + function Clock (scene) + { + /** + * [description] + * + * @name Phaser.Time.Clock#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Time.Clock#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * [description] + * + * @name Phaser.Time.Clock#now + * @type {number} + * @since 3.0.0 + */ + this.now = Date.now(); + + // Scale the delta time coming into the Clock by this factor + // which then influences anything using this Clock for calculations, like TimerEvents + + /** + * [description] + * + * @name Phaser.Time.Clock#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * [description] + * + * @name Phaser.Time.Clock#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * [description] + * + * @name Phaser.Time.Clock#_active + * @type {Phaser.Time.TimerEvent[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._active = []; + + /** + * [description] + * + * @name Phaser.Time.Clock#_pendingInsertion + * @type {Phaser.Time.TimerEvent[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingInsertion = []; + + /** + * [description] + * + * @name Phaser.Time.Clock#_pendingRemoval + * @type {Phaser.Time.TimerEvent[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingRemoval = []; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Time.Clock#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.systems.events.once('destroy', this.destroy, 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.Time.Clock#start + * @private + * @since 3.5.0 + */ + start: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('preupdate', this.preUpdate, this); + eventEmitter.on('update', this.update, this); + eventEmitter.once('shutdown', this.shutdown, this); + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#addEvent + * @since 3.0.0 + * + * @param {TimerEventConfig} config - [description] + * + * @return {Phaser.Time.TimerEvent} [description] + */ + addEvent: function (config) + { + var event = new TimerEvent(config); + + this._pendingInsertion.push(event); + + return event; + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#delayedCall + * @since 3.0.0 + * + * @param {number} delay - [description] + * @param {function} callback - [description] + * @param {Array.<*>} args - [description] + * @param {*} callbackScope - [description] + * + * @return {Phaser.Time.TimerEvent} [description] + */ + delayedCall: function (delay, callback, args, callbackScope) + { + return this.addEvent({ delay: delay, callback: callback, args: args, callbackScope: callbackScope }); + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#clearPendingEvents + * @since 3.0.0 + * + * @return {Phaser.Time.Clock} [description] + */ + clearPendingEvents: function () + { + this._pendingInsertion = []; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#removeAllEvents + * @since 3.0.0 + * + * @return {Phaser.Time.Clock} [description] + */ + removeAllEvents: function () + { + this._pendingRemoval = this._pendingRemoval.concat(this._active); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#preUpdate + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + preUpdate: function () + { + var toRemove = this._pendingRemoval.length; + var toInsert = this._pendingInsertion.length; + + if (toRemove === 0 && toInsert === 0) + { + // Quick bail + return; + } + + var i; + var event; + + // Delete old events + for (i = 0; i < toRemove; i++) + { + event = this._pendingRemoval[i]; + + var index = this._active.indexOf(event); + + if (index > -1) + { + this._active.splice(index, 1); + } + + // Pool them? + event.destroy(); + } + + for (i = 0; i < toInsert; i++) + { + event = this._pendingInsertion[i]; + + this._active.push(event); + } + + // Clear the lists + this._pendingRemoval.length = 0; + this._pendingInsertion.length = 0; + }, + + /** + * [description] + * + * @method Phaser.Time.Clock#update + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update: function (time, delta) + { + this.now = time; + + if (this.paused) + { + return; + } + + delta *= this.timeScale; + + for (var i = 0; i < this._active.length; i++) + { + var event = this._active[i]; + + if (event.paused) + { + continue; + } + + // Use delta time to increase elapsed. + // Avoids needing to adjust for pause / resume. + // Automatically smoothed by TimeStep class. + // In testing accurate to +- 1ms! + event.elapsed += delta * event.timeScale; + + if (event.elapsed >= event.delay) + { + var remainder = event.elapsed - event.delay; + + // Limit it, in case it's checked in the callback + event.elapsed = event.delay; + + // Process the event + if (!event.hasDispatched && event.callback) + { + event.hasDispatched = true; + event.callback.apply(event.callbackScope, event.args); + } + + if (event.repeatCount > 0) + { + event.repeatCount--; + + event.elapsed = remainder; + event.hasDispatched = false; + } + else + { + this._pendingRemoval.push(event); + } + } + } + }, + + /** + * 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 () + { + var i; + + for (i = 0; i < this._pendingInsertion.length; i++) + { + this._pendingInsertion[i].destroy(); + } + + for (i = 0; i < this._active.length; i++) + { + this._active[i].destroy(); + } + + for (i = 0; i < this._pendingRemoval.length; i++) + { + this._pendingRemoval[i].destroy(); + } + + 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); + }, + + /** + * 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.sys.events.off('start', this.start, this); + + this.scene = null; + this.systems = null; + } + +}); + +PluginCache.register('Clock', Clock, 'time'); + +module.exports = Clock; + + +/***/ }), +/* 468 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Time + */ + +module.exports = { + + Clock: __webpack_require__(467), + TimerEvent: __webpack_require__(219) + +}; + + +/***/ }), +/* 469 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var ParseToTilemap = __webpack_require__(141); + +/** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * + * @method Phaser.GameObjects.GameObjectFactory#tilemap + * @since 3.0.0 + * + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [width=10] - The width of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer} [height=10] - The height of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. Pass in `null` for no data. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} + */ +GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, width, height, data, insertNull) +{ + // Allow users to specify null to indicate that they want the default value, since null is + // shorter & more legible than undefined. Convert null to undefined to allow ParseToTilemap + // defaults to take effect. + + if (key === null) { key = undefined; } + if (tileWidth === null) { tileWidth = undefined; } + if (tileHeight === null) { tileHeight = undefined; } + if (width === null) { width = undefined; } + if (height === null) { height = undefined; } + + return ParseToTilemap(this.scene, key, tileWidth, tileHeight, width, height, data, insertNull); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 470 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(14); +var ParseToTilemap = __webpack_require__(141); + +/** + * @typedef {object} TilemapConfig + * + * @property {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @property {integer[][]} [data] - Instead of loading from the cache, you can also load directly from a 2D array of tile indexes. + * @property {integer} [tileWidth=32] - The width of a tile in pixels. + * @property {integer} [tileHeight=32] - The height of a tile in pixels. + * @property {integer} [width=10] - The width of the map in tiles. + * @property {integer} [height=10] - The height of the map in tiles. + * @property {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, + * in the map data are handled. If `true`, empty locations will get a value of `null`. If `false`, + * empty location will get a Tile object with an index of -1. If you've a large sparsely populated + * map and the tile data doesn't need to change then setting this value to `true` will help with + * memory consumption. However if your map is small or you need to update the tiles dynamically, + * then leave the default value set. + */ + +/** + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. + * + * @method Phaser.GameObjects.GameObjectCreator#tilemap + * @since 3.0.0 + * + * @param {TilemapConfig} [config] - The config options for the Tilemap. + * + * @return {Phaser.Tilemaps.Tilemap} + */ +GameObjectCreator.register('tilemap', function (config) +{ + // Defaults are applied in ParseToTilemap + var c = (config !== undefined) ? config : {}; + + return ParseToTilemap( + this.scene, + c.key, + c.tileWidth, + c.tileHeight, + c.width, + c.height, + c.data, + c.insertNull + ); +}); + + +/***/ }), +/* 471 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + + if (tileCount === 0) + { + return; + } + + var camMatrix = renderer._tempMatrix1; + var layerMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + var ctx = renderer.currentContext; + var gidMap = src.gidMap; + + ctx.save(); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + layerMatrix.e = src.x; + layerMatrix.f = src.y; + + camMatrix.multiply(layerMatrix, calcMatrix); + + calcMatrix.copyToContext(ctx); + } + else + { + // Undo the camera scroll + layerMatrix.e -= camera.scrollX * src.scrollFactorX; + layerMatrix.f -= camera.scrollY * src.scrollFactorY; + + layerMatrix.copyToContext(ctx); + } + + var alpha = camera.alpha * src.alpha; + + ctx.globalAlpha = camera.alpha * src.alpha; + + for (var i = 0; i < tileCount; i++) + { + var tile = renderTiles[i]; + + var tileset = gidMap[tile.index]; + + if (!tileset) + { + continue; + } + + var image = tileset.image.getSourceImage(); + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords) + { + var halfWidth = tile.width / 2; + var halfHeight = tile.height / 2; + + ctx.save(); + + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale((tile.flipX) ? -1 : 1, (tile.flipY) ? -1 : 1); + } + + ctx.globalAlpha = alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + -halfWidth, -halfHeight, + tile.width, tile.height + ); + + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = StaticTilemapLayerCanvasRenderer; + + +/***/ }), +/* 472 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * A Static Tilemap Layer renders immediately and does not use any batching. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + var tilesets = src.tileset; + + var pipeline = src.pipeline; + var pipelineVertexBuffer = pipeline.vertexBuffer; + + renderer.setPipeline(pipeline); + + pipeline.modelIdentity(); + pipeline.modelTranslate(src.x - (camera.scrollX * src.scrollFactorX), src.y - (camera.scrollY * src.scrollFactorY), 0); + pipeline.modelScale(src.scaleX, src.scaleY, 1); + pipeline.viewLoad2D(camera.matrix.matrix); + + for (var i = 0; i < tilesets.length; i++) + { + src.upload(camera, i); + + if (src.vertexCount[i] > 0) + { + if (renderer.currentPipeline && renderer.currentPipeline.vertexCount > 0) + { + renderer.flush(); + } + + pipeline.vertexBuffer = src.vertexBuffer[i]; + + renderer.setPipeline(pipeline); + + renderer.setTexture2D(tilesets[i].glTexture, 0); + + renderer.gl.drawArrays(pipeline.topology, 0, src.vertexCount[i]); + } + } + + // Restore the pipeline + pipeline.vertexBuffer = pipelineVertexBuffer; + + pipeline.viewIdentity(); + pipeline.modelIdentity(); +}; + +module.exports = StaticTilemapLayerWebGLRenderer; + + +/***/ }), +/* 473 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(472); +} + +if (true) +{ + renderCanvas = __webpack_require__(471); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 474 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + + if (tileCount === 0) + { + return; + } + + var camMatrix = renderer._tempMatrix1; + var layerMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + var ctx = renderer.currentContext; + var gidMap = src.gidMap; + + ctx.save(); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + layerMatrix.e = src.x; + layerMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(layerMatrix, calcMatrix); + + calcMatrix.copyToContext(ctx); + } + else + { + layerMatrix.e -= camera.scrollX * src.scrollFactorX; + layerMatrix.f -= camera.scrollY * src.scrollFactorY; + + layerMatrix.copyToContext(ctx); + } + + var alpha = camera.alpha * src.alpha; + + for (var i = 0; i < tileCount; i++) + { + var tile = renderTiles[i]; + + var tileset = gidMap[tile.index]; + + if (!tileset) + { + continue; + } + + var image = tileset.image.getSourceImage(); + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords) + { + var halfWidth = tile.width / 2; + var halfHeight = tile.height / 2; + + ctx.save(); + + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale((tile.flipX) ? -1 : 1, (tile.flipY) ? -1 : 1); + } + + ctx.globalAlpha = alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + -halfWidth, -halfHeight, + tile.width, tile.height + ); + + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = DynamicTilemapLayerCanvasRenderer; + + +/***/ }), +/* 475 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + var alpha = camera.alpha * src.alpha; + + if (tileCount === 0 || alpha <= 0) + { + return; + } + + var gidMap = src.gidMap; + var pipeline = src.pipeline; + + var getTint = Utils.getTintAppendFloatAlpha; + + var scrollFactorX = src.scrollFactorX; + var scrollFactorY = src.scrollFactorY; + + var x = src.x; + var y = src.y; + + var sx = src.scaleX; + var sy = src.scaleY; + + var tilesets = src.tileset; + + // Loop through each tileset in this layer, drawing just the tiles that are in that set each time + // Doing it this way around allows us to batch tiles using the same tileset + for (var c = 0; c < tilesets.length; c++) + { + var currentSet = tilesets[c]; + var texture = currentSet.glTexture; + + for (var i = 0; i < tileCount; i++) + { + var tile = renderTiles[i]; + + var tileset = gidMap[tile.index]; + + if (tileset !== currentSet) + { + // Skip tiles that aren't in this set + continue; + } + + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords === null) + { + continue; + } + + var frameWidth = tile.width; + var frameHeight = tile.height; + + var frameX = tileTexCoords.x; + var frameY = tileTexCoords.y; + + var tw = tile.width * 0.5; + var th = tile.height * 0.5; + + var tint = getTint(tile.tint, alpha * tile.alpha); + + pipeline.batchTexture( + src, + texture, + texture.width, texture.height, + (tw + x + tile.pixelX) * sx, (th + y + tile.pixelY) * sy, + tile.width, tile.height, + sx, sy, + tile.rotation, + tile.flipX, tile.flipY, + scrollFactorX, scrollFactorY, + tw, th, + frameX, frameY, frameWidth, frameHeight, + tint, tint, tint, tint, false, + 0, 0, + camera, + null, + true + ); + } + } +}; + +module.exports = DynamicTilemapLayerWebGLRenderer; + + +/***/ }), +/* 476 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(475); +} + +if (true) +{ + renderCanvas = __webpack_require__(474); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 477 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(107); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var tilesetsNames = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + // A relative filepath to the source image (within Weltmeister) is used for the name + var tilesetName = layer.tilesetName; + + // Only add unique tilesets that have a valid name. Collision layers will have a blank name. + if (tilesetName !== '' && tilesetsNames.indexOf(tilesetName) === -1) + { + tilesetsNames.push(tilesetName); + + // Tiles are stored with an ID relative to the tileset, rather than a globally unique ID + // across all tilesets. Also, tilesets in Weltmeister have no margin or padding. + tilesets.push(new Tileset(tilesetName, 0, layer.tilesize, layer.tilesize, 0, 0)); + } + } + + return tilesets; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 478 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LayerData = __webpack_require__(87); +var Tile = __webpack_require__(61); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + var layerData = new LayerData({ + name: layer.name, + width: layer.width, + height: layer.height, + tileWidth: layer.tilesize, + tileHeight: layer.tilesize, + visible: layer.visible === 1 + }); + + var row = []; + var tileGrid = []; + + // Loop through the data field in the JSON. This is a 2D array containing the tile indexes, + // one after the other. The indexes are relative to the tileset that contains the tile. + for (var y = 0; y < layer.data.length; y++) + { + for (var x = 0; x < layer.data[y].length; x++) + { + // In Weltmeister, 0 = no tile, but the Tilemap API expects -1 = no tile. + var index = layer.data[y][x] - 1; + + var tile; + + if (index > -1) + { + tile = new Tile(layerData, index, x, y, layer.tilesize, layer.tilesize); + } + else + { + tile = insertNull + ? null + : new Tile(layerData, -1, x, y, layer.tilesize, layer.tilesize); + } + + row.push(tile); + } + + tileGrid.push(row); + row = []; + } + + layerData.data = tileGrid; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 479 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(21); + +/** + * Copy properties from tileset to tiles. + * + * @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + */ +var AssignTileProperties = function (mapData) +{ + var layerData; + var tile; + var sid; + var set; + var row; + + // go through each of the map data layers + for (var i = 0; i < mapData.layers.length; i++) + { + layerData = mapData.layers[i]; + + set = null; + + // rows of tiles + for (var j = 0; j < layerData.data.length; j++) + { + row = layerData.data[j]; + + // individual tiles + for (var k = 0; k < row.length; k++) + { + tile = row[k]; + + if (tile === null || tile.index < 0) + { + continue; + } + + // find the relevant tileset + sid = mapData.tiles[tile.index][2]; + set = mapData.tilesets[sid]; + + // Ensure that a tile's size matches its tileset + tile.width = set.tileWidth; + tile.height = set.tileHeight; + + // if that tile type has any properties, add them to the tile object + if (set.tileProperties && set.tileProperties[tile.index - set.firstgid]) + { + tile.properties = Extend( + tile.properties, set.tileProperties[tile.index - set.firstgid] + ); + } + } + } + } +}; + +module.exports = AssignTileProperties; + + +/***/ }), +/* 480 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Master list of tiles -> x, y, index in tileset. + * + * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + * + * @return {array} [description] + */ +var BuildTilesetIndex = function (mapData) +{ + var tiles = []; + + for (var i = 0; i < mapData.tilesets.length; i++) + { + var set = mapData.tilesets[i]; + + var x = set.tileMargin; + var y = set.tileMargin; + + var count = 0; + var countX = 0; + var countY = 0; + + for (var t = set.firstgid; t < set.firstgid + set.total; t++) + { + // Can add extra properties here as needed + tiles[t] = [ x, y, i ]; + + x += set.tileWidth + set.tileSpacing; + + count++; + + if (count === set.total) + { + break; + } + + countX++; + + if (countX === set.columns) + { + x = set.tileMargin; + y += set.tileHeight + set.tileSpacing; + + countX = 0; + countY++; + + if (countY === set.rows) + { + break; + } + } + } + } + + return tiles; +}; + +module.exports = BuildTilesetIndex; + + +/***/ }), +/* 481 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(1); +var ParseObject = __webpack_require__(225); +var ObjectLayer = __webpack_require__(224); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseObjectLayers = function (json) +{ + var objectLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'objectgroup') + { + continue; + } + + var curo = json.layers[i]; + var offsetX = GetFastValue(curo, 'offsetx', 0); + var offsetY = GetFastValue(curo, 'offsety', 0); + var objects = []; + + for (var j = 0; j < curo.objects.length; j++) + { + var parsedObject = ParseObject(curo.objects[j], offsetX, offsetY); + + objects.push(parsedObject); + } + + var objectLayer = new ObjectLayer(curo); + objectLayer.objects = objects; + + objectLayers.push(objectLayer); + } + + return objectLayers; +}; + +module.exports = ParseObjectLayers; + + +/***/ }), +/* 482 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasValue = __webpack_require__(77); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.Pick + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {array} keys - [description] + * + * @return {object} [description] + */ +var Pick = function (object, keys) +{ + var obj = {}; + + for (var i = 0; i < keys.length; i++) + { + var key = keys[i]; + + if (HasValue(object, key)) + { + obj[key] = object[key]; + } + } + + return obj; +}; + +module.exports = Pick; + + +/***/ }), +/* 483 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(107); +var ImageCollection = __webpack_require__(226); +var ParseObject = __webpack_require__(225); + +/** + * Tilesets & Image Collections + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {object} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var imageCollections = []; + var lastSet = null; + var stringID; + + for (var i = 0; i < json.tilesets.length; i++) + { + // name, firstgid, width, height, margin, spacing, properties + var set = json.tilesets[i]; + + if (set.source) + { + console.warn('Phaser can\'t load external tilesets. Use the Embed Tileset button and then export the map again.'); + } + else if (set.image) + { + var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); + + if (json.version > 1) + { + // Tiled 1.2+ + + if (Array.isArray(set.tiles)) + { + var tiles = {}; + var props = {}; + + for (var t = 0; t < set.tiles.length; t++) + { + var tile = set.tiles[t]; + + // Convert tileproperties + if (tile.properties) + { + var newPropData = {}; + + tile.properties.forEach(function (propData) + { + newPropData[propData['name']] = propData['value']; + }); + + props[tile.id] = newPropData; + } + + // Convert objectgroup + if (tile.objectgroup) + { + tiles[tile.id] = { objectgroup: tile.objectgroup }; + + if (tile.objectgroup.objects) + { + var parsedObjects2 = tile.objectgroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + + tiles[tile.id].objectgroup.objects = parsedObjects2; + } + } + } + + newSet.tileData = tiles; + newSet.tileProperties = props; + } + } + else + { + // Tiled 1 + + // Properties stored per-tile in object with string indexes starting at "0" + if (set.tileproperties) + { + newSet.tileProperties = set.tileproperties; + } + + // Object & terrain shapes stored per-tile in object with string indexes starting at "0" + if (set.tiles) + { + newSet.tileData = set.tiles; + + // Parse the objects into Phaser format to match handling of other Tiled objects + for (stringID in newSet.tileData) + { + var objectGroup = newSet.tileData[stringID].objectgroup; + if (objectGroup && objectGroup.objects) + { + var parsedObjects1 = objectGroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + newSet.tileData[stringID].objectgroup.objects = parsedObjects1; + } + } + } + } + + // For a normal sliced tileset the row/count/size information is computed when updated. + // This is done (again) after the image is set. + newSet.updateTileData(set.imagewidth, set.imageheight); + + tilesets.push(newSet); + } + else + { + var newCollection = new ImageCollection(set.name, set.firstgid, set.tilewidth, + set.tileheight, set.margin, set.spacing, set.properties); + + for (stringID in set.tiles) + { + var image = set.tiles[stringID].image; + var gid = set.firstgid + parseInt(stringID, 10); + newCollection.addImage(gid, image); + } + + imageCollections.push(newCollection); + } + + // We've got a new Tileset, so set the lastgid into the previous one + if (lastSet) + { + lastSet.lastgid = set.firstgid - 1; + } + + lastSet = set; + } + + return { tilesets: tilesets, imageCollections: imageCollections }; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 484 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(1); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseImageLayers = function (json) +{ + var images = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'imagelayer') + { + continue; + } + + var curi = json.layers[i]; + + images.push({ + name: curi.name, + image: curi.image, + x: GetFastValue(curi, 'offsetx', 0) + curi.x, + y: GetFastValue(curi, 'offsety', 0) + curi.y, + alpha: curi.opacity, + visible: curi.visible, + properties: GetFastValue(curi, 'properties', {}) + }); + } + + return images; +}; + +module.exports = ParseImageLayers; + + +/***/ }), +/* 485 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Decode base-64 encoded data, for example as exported by Tiled. + * + * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode + * @since 3.0.0 + * + * @param {object} data - Base-64 encoded data to decode. + * + * @return {array} Array containing the decoded bytes. + */ +var Base64Decode = function (data) +{ + var binaryString = window.atob(data); + var len = binaryString.length; + var bytes = new Array(len / 4); + + // Interpret binaryString as an array of bytes representing little-endian encoded uint32 values. + for (var i = 0; i < len; i += 4) + { + bytes[i / 4] = ( + binaryString.charCodeAt(i) | + binaryString.charCodeAt(i + 1) << 8 | + binaryString.charCodeAt(i + 2) << 16 | + binaryString.charCodeAt(i + 3) << 24 + ) >>> 0; + } + + return bytes; +}; + +module.exports = Base64Decode; + + +/***/ }), +/* 486 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Base64Decode = __webpack_require__(485); +var GetFastValue = __webpack_require__(1); +var LayerData = __webpack_require__(87); +var ParseGID = __webpack_require__(227); +var Tile = __webpack_require__(61); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'tilelayer') + { + continue; + } + + var curl = json.layers[i]; + + // Base64 decode data if necessary. NOTE: uncompressed base64 only. + if (curl.compression) + { + console.warn( + 'TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' + + curl.name + '\'' + ); + continue; + } + else if (curl.encoding && curl.encoding === 'base64') + { + curl.data = Base64Decode(curl.data); + delete curl.encoding; // Allow the same map to be parsed multiple times + } + + var layerData = new LayerData({ + name: curl.name, + x: GetFastValue(curl, 'offsetx', 0) + curl.x, + y: GetFastValue(curl, 'offsety', 0) + curl.y, + width: curl.width, + height: curl.height, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + alpha: curl.opacity, + visible: curl.visible, + properties: GetFastValue(curl, 'properties', {}) + }); + + var x = 0; + var row = []; + var output = []; + + // Loop through the data field in the JSON. + + // This is an array containing the tile indexes, one after the other. -1 = no tile, + // everything else = the tile index (starting at 1 for Tiled, 0 for CSV) If the map + // contains multiple tilesets then the indexes are relative to that which the set starts + // from. Need to set which tileset in the cache = which tileset in the JSON, if you do this + // manually it means you can use the same map data but a new tileset. + + for (var t = 0, len = curl.data.length; t < len; t++) + { + var gidInfo = ParseGID(curl.data[t]); + + // index, x, y, width, height + if (gidInfo.gid > 0) + { + var tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, + json.tileheight); + + // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal + // propeties into flipX, flipY and rotation + tile.rotation = gidInfo.rotation; + tile.flipX = gidInfo.flipped; + + row.push(tile); + } + else + { + var blankTile = insertNull + ? null + : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); + row.push(blankTile); + } + + x++; + + if (x === curl.width) + { + output.push(row); + x = 0; + row = []; + } + } + + layerData.data = output; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 487 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Parsers + */ + +module.exports = { + + Parse: __webpack_require__(230), + Parse2DArray: __webpack_require__(142), + ParseCSV: __webpack_require__(229), + + Impact: __webpack_require__(223), + Tiled: __webpack_require__(228) + +}; + + +/***/ }), +/* 488 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var WorldToTileX = __webpack_require__(54); +var WorldToTileY = __webpack_require__(53); +var Vector2 = __webpack_require__(3); + +/** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.WorldToTileXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in tile units. + */ +var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = WorldToTileX(worldX, snapToFloor, camera, layer); + point.y = WorldToTileY(worldY, snapToFloor, camera, layer); + + return point; +}; + +module.exports = WorldToTileXY; + + +/***/ }), +/* 489 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.WeightedRandomize + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) +{ + if (weightedIndexes === undefined) { return; } + + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var weightTotal = 0; + for (i = 0; i < weightedIndexes.length; i++) + { + weightTotal += weightedIndexes[i].weight; + } + + if (weightTotal <= 0) { return; } + + for (i = 0; i < tiles.length; i++) + { + var rand = Math.random() * weightTotal; + var sum = 0; + var randomIndex = -1; + for (var j = 0; j < weightedIndexes.length; j++) + { + sum += weightedIndexes[j].weight; + if (rand <= sum) + { + var chosen = weightedIndexes[j].index; + randomIndex = Array.isArray(chosen) + ? chosen[Math.floor(Math.random() * chosen.length)] + : chosen; + break; + } + } + + tiles[i].index = randomIndex; + } +}; + +module.exports = WeightedRandomize; + + +/***/ }), +/* 490 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(109); +var TileToWorldY = __webpack_require__(108); +var Vector2 = __webpack_require__(3); + +/** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.TileToWorldXY + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in world coordinates. + */ +var TileToWorldXY = function (tileX, tileY, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = TileToWorldX(tileX, camera, layer); + point.y = TileToWorldY(tileY, camera, layer); + + return point; +}; + +module.exports = TileToWorldXY; + + +/***/ }), +/* 491 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); + +/** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.SwapByIndex + * @private + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) + { + if (tiles[i]) + { + if (tiles[i].index === indexA) + { + tiles[i].index = indexB; + } + else if (tiles[i].index === indexB) + { + tiles[i].index = indexA; + } + } + } +}; + +module.exports = SwapByIndex; + + +/***/ }), +/* 492 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); +var ShuffleArray = __webpack_require__(132); + +/** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.Shuffle + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Shuffle = function (tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var indexes = tiles.map(function (tile) { return tile.index; }); + ShuffleArray(indexes); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = indexes[i]; + } +}; + +module.exports = Shuffle; + + +/***/ }), +/* 493 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); + +/** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @function Phaser.Tilemaps.Components.SetTileLocationCallback + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].setCollisionCallback(callback, callbackContext); + } + +}; + +module.exports = SetTileLocationCallback; + + +/***/ }), +/* 494 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @function Phaser.Tilemaps.Components.SetTileIndexCallback + * @private + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileIndexCallback = function (indexes, callback, callbackContext, layer) +{ + if (typeof indexes === 'number') + { + layer.callbacks[indexes] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + else + { + for (var i = 0, len = indexes.length; i < len; i++) + { + layer.callbacks[indexes[i]] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + } +}; + +module.exports = SetTileIndexCallback; + + +/***/ }), +/* 495 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(62); +var CalculateFacesWithin = __webpack_require__(38); + +/** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup + * @private + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + var collisionGroup = tile.getCollisionGroup(); + + // It's possible in Tiled to have a collision group without any shapes, e.g. create a + // shape and then delete the shape. + if (collisionGroup && collisionGroup.objects && collisionGroup.objects.length > 0) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionFromCollisionGroup; + + +/***/ }), +/* 496 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(62); +var CalculateFacesWithin = __webpack_require__(38); +var HasValue = __webpack_require__(77); + +/** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @function Phaser.Tilemaps.Components.SetCollisionByProperty + * @private + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + for (var property in properties) + { + if (!HasValue(tile.properties, property)) { continue; } + + var values = properties[property]; + if (!Array.isArray(values)) + { + values = [ values ]; + } + + for (var i = 0; i < values.length; i++) + { + if (tile.properties[property] === values[i]) + { + SetTileCollision(tile, collides); + } + } + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionByProperty; + + +/***/ }), +/* 497 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(62); +var CalculateFacesWithin = __webpack_require__(38); +var SetLayerCollisionIndex = __webpack_require__(143); + +/** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionByExclusion + * @private + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Note: this only updates layer.collideIndexes for tile indexes found currently in the layer + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile && indexes.indexOf(tile.index) === -1) + { + SetTileCollision(tile, collides); + SetLayerCollisionIndex(tile.index, collides, layer); + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionByExclusion; + + +/***/ }), +/* 498 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(62); +var CalculateFacesWithin = __webpack_require__(38); +var SetLayerCollisionIndex = __webpack_require__(143); + +/** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionBetween + * @private + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + if (start > stop) { return; } + + // Update the array of colliding indexes + for (var index = start; index <= stop; index++) + { + SetLayerCollisionIndex(index, collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile) + { + if (tile.index >= start && tile.index <= stop) + { + SetTileCollision(tile, collides); + } + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionBetween; + + +/***/ }), +/* 499 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(62); +var CalculateFacesWithin = __webpack_require__(38); +var SetLayerCollisionIndex = __webpack_require__(143); + +/** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollision + * @private + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollision = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Update the array of colliding indexes + for (var i = 0; i < indexes.length; i++) + { + SetLayerCollisionIndex(indexes[i], collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (tile && indexes.indexOf(tile.index) !== -1) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollision; + + +/***/ }), +/* 500 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); +var Color = __webpack_require__(383); + +var defaultTileColor = new Color(105, 210, 231, 150); +var defaultCollidingTileColor = new Color(243, 134, 48, 200); +var defaultFaceColor = new Color(40, 39, 37, 150); + +/** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @function Phaser.Tilemaps.Components.RenderDebug + * @private + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Phaser.Display.Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var RenderDebug = function (graphics, styleConfig, layer) +{ + if (styleConfig === undefined) { styleConfig = {}; } + + // Default colors without needlessly creating Color objects + var tileColor = (styleConfig.tileColor !== undefined) ? styleConfig.tileColor : defaultTileColor; + var collidingTileColor = (styleConfig.collidingTileColor !== undefined) ? styleConfig.collidingTileColor : defaultCollidingTileColor; + var faceColor = (styleConfig.faceColor !== undefined) ? styleConfig.faceColor : defaultFaceColor; + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + + graphics.translate(layer.tilemapLayer.x, layer.tilemapLayer.y); + graphics.scale(layer.tilemapLayer.scaleX, layer.tilemapLayer.scaleY); + + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + var tw = tile.width; + var th = tile.height; + var x = tile.pixelX; + var y = tile.pixelY; + + var color = tile.collides ? collidingTileColor : tileColor; + + if (color !== null) + { + graphics.fillStyle(color.color, color.alpha / 255); + graphics.fillRect(x, y, tw, th); + } + + // Inset the face line to prevent neighboring tile's lines from overlapping + x += 1; + y += 1; + tw -= 2; + th -= 2; + + if (faceColor !== null) + { + graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); + + if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } + if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } + if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } + if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } + } + } +}; + +module.exports = RenderDebug; + + +/***/ }), +/* 501 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RemoveTileAt = __webpack_require__(231); +var WorldToTileX = __webpack_require__(54); +var WorldToTileY = __webpack_require__(53); + +/** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @function Phaser.Tilemaps.Components.RemoveTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + */ +var RemoveTileAtWorldXY = function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); +}; + +module.exports = RemoveTileAtWorldXY; + + +/***/ }), +/* 502 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); +var GetRandom = __webpack_require__(178); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.Randomize + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Randomize = function (tileX, tileY, width, height, indexes, layer) +{ + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + // If no indicies are given, then find all the unique indexes within the specified region + if (indexes === undefined) + { + indexes = []; + for (i = 0; i < tiles.length; i++) + { + if (indexes.indexOf(tiles[i].index) === -1) + { + indexes.push(tiles[i].index); + } + } + } + + for (i = 0; i < tiles.length; i++) + { + tiles[i].index = GetRandom(indexes); + } +}; + +module.exports = Randomize; + + +/***/ }), +/* 503 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CalculateFacesWithin = __webpack_require__(38); +var PutTileAt = __webpack_require__(144); + +/** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @function Phaser.Tilemaps.Components.PutTilesAt + * @private + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) +{ + if (!Array.isArray(tilesArray)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + // Force the input array to be a 2D array + if (!Array.isArray(tilesArray[0])) + { + tilesArray = [ tilesArray ]; + } + + var height = tilesArray.length; + var width = tilesArray[0].length; + + for (var ty = 0; ty < height; ty++) + { + for (var tx = 0; tx < width; tx++) + { + var tile = tilesArray[ty][tx]; + PutTileAt(tile, tileX + tx, tileY + ty, false, layer); + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = PutTilesAt; + + + +/***/ }), +/* 504 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PutTileAt = __webpack_require__(144); +var WorldToTileX = __webpack_require__(54); +var WorldToTileY = __webpack_require__(53); + +/** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @function Phaser.Tilemaps.Components.PutTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + */ +var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return PutTileAt(tile, tileX, tileY, recalculateFaces, layer); +}; + +module.exports = PutTileAtWorldXY; + + +/***/ }), +/* 505 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasTileAt = __webpack_require__(232); +var WorldToTileX = __webpack_require__(54); +var WorldToTileY = __webpack_require__(53); + +/** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @function Phaser.Tilemaps.Components.HasTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The X coordinate of the world position. + * @param {number} worldY - The Y coordinate of the world position. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ +var HasTileAtWorldXY = function (worldX, worldY, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return HasTileAt(tileX, tileY, layer); +}; + +module.exports = HasTileAtWorldXY; + + +/***/ }), +/* 506 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); +var WorldToTileX = __webpack_require__(54); +var WorldToTileY = __webpack_require__(53); + +/** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer) +{ + // Top left corner of the rect, rounded down to include partial tiles + var xStart = WorldToTileX(worldX, true, camera, layer); + var yStart = WorldToTileY(worldY, true, camera, layer); + + // Bottom right corner of the rect, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer)); + + return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer); +}; + +module.exports = GetTilesWithinWorldXY; + + +/***/ }), +/* 507 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Geom = __webpack_require__(302); +var GetTilesWithin = __webpack_require__(19); +var Intersects = __webpack_require__(301); +var NOOP = __webpack_require__(2); +var TileToWorldX = __webpack_require__(109); +var TileToWorldY = __webpack_require__(108); +var WorldToTileX = __webpack_require__(54); +var WorldToTileY = __webpack_require__(53); + +var TriangleToRectangle = function (triangle, rect) +{ + return Intersects.RectangleToTriangle(rect, triangle); +}; + +// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer +// coordinates instead of shifting the tiles. + +/** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinShape + * @private + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) +{ + if (shape === undefined) { return []; } + + // intersectTest is a function with parameters: shape, rect + var intersectTest = NOOP; + if (shape instanceof Geom.Circle) { intersectTest = Intersects.CircleToRectangle; } + else if (shape instanceof Geom.Rectangle) { intersectTest = Intersects.RectangleToRectangle; } + else if (shape instanceof Geom.Triangle) { intersectTest = TriangleToRectangle; } + else if (shape instanceof Geom.Line) { intersectTest = Intersects.LineToRectangle; } + + // Top left corner of the shapes's bounding box, rounded down to include partial tiles + var xStart = WorldToTileX(shape.left, true, camera, layer); + var yStart = WorldToTileY(shape.top, true, camera, layer); + + // Bottom right corner of the shapes's bounding box, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(shape.right, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(shape.bottom, false, camera, layer)); + + // Tiles within bounding rectangle of shape. Bounds are forced to be at least 1 x 1 tile in size + // to grab tiles for shapes that don't have a height or width (e.g. a horizontal line). + var width = Math.max(xEnd - xStart, 1); + var height = Math.max(yEnd - yStart, 1); + var tiles = GetTilesWithin(xStart, yStart, width, height, filteringOptions, layer); + + var tileWidth = layer.tileWidth; + var tileHeight = layer.tileHeight; + if (layer.tilemapLayer) + { + tileWidth *= layer.tilemapLayer.scaleX; + tileHeight *= layer.tilemapLayer.scaleY; + } + + var results = []; + var tileRect = new Geom.Rectangle(0, 0, tileWidth, tileHeight); + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + tileRect.x = TileToWorldX(tile.x, camera, layer); + tileRect.y = TileToWorldY(tile.y, camera, layer); + if (intersectTest(shape, tileRect)) + { + results.push(tile); + } + } + + return results; +}; + +module.exports = GetTilesWithinShape; + + +/***/ }), +/* 508 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(110); +var WorldToTileX = __webpack_require__(54); +var WorldToTileY = __webpack_require__(53); + +/** + * Gets a tile at the given world coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return GetTileAt(tileX, tileY, nonNull, layer); +}; + +module.exports = GetTileAtWorldXY; + + +/***/ }), +/* 509 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); + +/** + * @callback EachTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - The Tile. + * @param {integer} index - The index of the tile. + * @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects. + */ + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @function Phaser.Tilemaps.Components.ForEachTile + * @private + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + + tiles.forEach(callback, context); +}; + +module.exports = ForEachTile; + + +/***/ }), +/* 510 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); + +/** + * @callback FindTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - The Tile. + * @param {integer} index - The index of the tile. + * @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects. + * + * @return {boolean} Return `true` if the callback should run, otherwise `false`. + */ + +/** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FindTile + * @private + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found + */ +var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + return tiles.find(callback, context) || null; +}; + +module.exports = FindTile; + + +/***/ }), +/* 511 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @function Phaser.Tilemaps.Components.FindByIndex + * @private + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} The first (or n skipped) tile with the matching index. + */ +var FindByIndex = function (findIndex, skip, reverse, layer) +{ + if (skip === undefined) { skip = 0; } + if (reverse === undefined) { reverse = false; } + + var count = 0; + var tx; + var ty; + var tile; + + if (reverse) + { + for (ty = layer.height - 1; ty >= 0; ty--) + { + for (tx = layer.width - 1; tx >= 0; tx--) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + else + { + for (ty = 0; ty < layer.height; ty++) + { + for (tx = 0; tx < layer.width; tx++) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + + return null; +}; + +module.exports = FindByIndex; + + +/***/ }), +/* 512 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FilterTiles + * @private + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. + */ +var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + + return tiles.filter(callback, context); +}; + +module.exports = FilterTiles; + + + +/***/ }), +/* 513 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); +var CalculateFacesWithin = __webpack_require__(38); +var SetTileCollision = __webpack_require__(62); + +/** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @function Phaser.Tilemaps.Components.Fill + * @private + * @since 3.0.0 + * + * @param {integer} index - The tile index to fill the area with. + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} recalculateFaces - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The tile layer to use. If not given the current layer is used. + */ +var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) +{ + var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); + + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = index; + + SetTileCollision(tiles[i], doesIndexCollide); + } + + if (recalculateFaces) + { + // Recalculate the faces within the area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Fill; + + +/***/ }), +/* 514 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SnapFloor = __webpack_require__(158); +var SnapCeil = __webpack_require__(271); + +/** + * Returns the tiles in the given layer that are within the camera's viewport. This is used internally. + * + * @function Phaser.Tilemaps.Components.CullTiles + * @private + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * @param {array} [outputArray] - An optional array to store the Tile objects within. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ +var CullTiles = function (layer, camera, outputArray, renderOrder) +{ + if (outputArray === undefined) { outputArray = []; } + if (renderOrder === undefined) { renderOrder = 0; } + + outputArray.length = 0; + + var tilemap = layer.tilemapLayer.tilemap; + var tilemapLayer = layer.tilemapLayer; + + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + + // We need to use the tile sizes defined for the map as a whole, not the layer, + // in order to calculate the bounds correctly. As different sized tiles may be + // placed on the grid and we cannot trust layer.baseTileWidth to give us the true size. + var tileW = Math.floor(tilemap.tileWidth * tilemapLayer.scaleX); + var tileH = Math.floor(tilemap.tileHeight * tilemapLayer.scaleY); + + var drawLeft = 0; + var drawRight = mapWidth; + var drawTop = 0; + var drawBottom = mapHeight; + + if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1) + { + // Camera world view bounds, snapped for scaled tile size + // Cull Padding values are given in tiles, not pixels + + var boundsLeft = SnapFloor(camera.worldView.x - tilemapLayer.x, tileW, 0, true) - tilemapLayer.cullPaddingX; + var boundsRight = SnapCeil(camera.worldView.right - tilemapLayer.x, tileW, 0, true) + tilemapLayer.cullPaddingX; + var boundsTop = SnapFloor(camera.worldView.y - tilemapLayer.y, tileH, 0, true) - tilemapLayer.cullPaddingY; + var boundsBottom = SnapCeil(camera.worldView.bottom - tilemapLayer.y, tileH, 0, true) + tilemapLayer.cullPaddingY; + + drawLeft = Math.max(0, boundsLeft); + drawRight = Math.min(mapWidth, boundsRight); + drawTop = Math.max(0, boundsTop); + drawBottom = Math.min(mapHeight, boundsBottom); + } + + var x; + var y; + var tile; + + if (renderOrder === 0) + { + // right-down + + for (y = drawTop; y < drawBottom; y++) + { + for (x = drawLeft; x < drawRight; x++) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 1) + { + // left-down + + for (y = drawTop; y < drawBottom; y++) + { + for (x = drawRight; x >= drawLeft; x--) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 2) + { + // right-up + + for (y = drawBottom; y >= drawTop; y--) + { + for (x = drawLeft; x < drawRight; x++) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 3) + { + // left-up + + for (y = drawBottom; y >= drawTop; y--) + { + for (x = drawRight; x >= drawLeft; x--) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + + tilemapLayer.tilesDrawn = outputArray.length; + tilemapLayer.tilesTotal = mapWidth * mapHeight; + + return outputArray; +}; + +module.exports = CullTiles; + + +/***/ }), +/* 515 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(109); +var TileToWorldY = __webpack_require__(108); +var GetTilesWithin = __webpack_require__(19); +var ReplaceByIndex = __webpack_require__(233); + +/** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @function Phaser.Tilemaps.Components.CreateFromTiles + * @private + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ +var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, camera, layer) +{ + if (spriteConfig === undefined) { spriteConfig = {}; } + + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + var tilemapLayer = layer.tilemapLayer; + if (scene === undefined) { scene = tilemapLayer.scene; } + if (camera === undefined) { camera = scene.cameras.main; } + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + var sprites = []; + var i; + + for (i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + if (indexes.indexOf(tile.index) !== -1) + { + spriteConfig.x = TileToWorldX(tile.x, camera, layer); + spriteConfig.y = TileToWorldY(tile.y, camera, layer); + + var sprite = scene.make.sprite(spriteConfig); + sprites.push(sprite); + } + } + + if (typeof replacements === 'number') + { + // Assume 1 replacement for all types of tile given + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); + } + } + else if (Array.isArray(replacements)) + { + // Assume 1 to 1 mapping with indexes array + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); + } + } + + return sprites; +}; + +module.exports = CreateFromTiles; + + +/***/ }), +/* 516 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(19); +var CalculateFacesWithin = __webpack_require__(38); + +/** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @function Phaser.Tilemaps.Components.Copy + * @private + * @since 3.0.0 + * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) +{ + if (srcTileX < 0) { srcTileX = 0; } + if (srcTileY < 0) { srcTileY = 0; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer); + + var offsetX = destTileX - srcTileX; + var offsetY = destTileY - srcTileY; + + for (var i = 0; i < srcTiles.length; i++) + { + var tileX = srcTiles[i].x + offsetX; + var tileY = srcTiles[i].y + offsetY; + if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height) + { + if (layer.data[tileY][tileX]) + { + layer.data[tileY][tileX].copy(srcTiles[i]); + } + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Copy; + + +/***/ }), +/* 517 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps + */ + +module.exports = { + + Components: __webpack_require__(111), + Parsers: __webpack_require__(487), + + Formats: __webpack_require__(30), + ImageCollection: __webpack_require__(226), + ParseToTilemap: __webpack_require__(141), + Tile: __webpack_require__(61), + Tilemap: __webpack_require__(222), + TilemapCreator: __webpack_require__(470), + TilemapFactory: __webpack_require__(469), + Tileset: __webpack_require__(107), + + LayerData: __webpack_require__(87), + MapData: __webpack_require__(86), + ObjectLayer: __webpack_require__(224), + + DynamicTilemapLayer: __webpack_require__(221), + StaticTilemapLayer: __webpack_require__(220) + +}; + + +/***/ }), +/* 518 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Filter Types. + * + * @name Phaser.Textures.FilterMode + * @enum {integer} + * @memberof Phaser.Textures + * @readonly + * @since 3.0.0 + */ +var CONST = { + + /** + * Linear filter type. + * + * @name Phaser.Textures.FilterMode.LINEAR + */ + LINEAR: 0, + + /** + * Nearest neighbor filter type. + * + * @name Phaser.Textures.FilterMode.NEAREST + */ + NEAREST: 1 + +}; + +module.exports = CONST; + + +/***/ }), +/* 519 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(21); +var FilterMode = __webpack_require__(518); + +/** + * @namespace Phaser.Textures + */ + +/** + * Linear filter type. + * + * @name Phaser.Textures.LINEAR + * @constant + */ + +/** + * Nearest Neighbor filter type. + * + * @name Phaser.Textures.NEAREST + * @constant + */ + +var Textures = { + + FilterMode: FilterMode, + Frame: __webpack_require__(123), + Parsers: __webpack_require__(345), + Texture: __webpack_require__(181), + TextureManager: __webpack_require__(347), + TextureSource: __webpack_require__(346) + +}; + +Textures = Extend(false, Textures, FilterMode); + +module.exports = Textures; + + +/***/ }), +/* 520 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Structs + */ + +module.exports = { + + List: __webpack_require__(122), + Map: __webpack_require__(198), + ProcessQueue: __webpack_require__(256), + RTree: __webpack_require__(255), + Set: __webpack_require__(96) + +}; + + +/***/ }), +/* 521 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Sound + */ + +/** + * Config object containing various sound settings. + * + * @typedef {object} SoundConfig + * + * @property {boolean} [mute=false] - Boolean indicating whether the sound should be muted or not. + * @property {number} [volume=1] - A value between 0 (silence) and 1 (full volume). + * @property {number} [rate=1] - Defines the speed at which the sound should be played. + * @property {number} [detune=0] - Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * @property {number} [seek=0] - Position of playback for this sound, in seconds. + * @property {boolean} [loop=false] - Whether or not the sound or current sound marker should loop. + * @property {number} [delay=0] - Time, in seconds, that should elapse before the sound actually starts its playback. + */ + +/** + * Marked section of a sound represented by name, and optionally start time, duration, and config object. + * + * @typedef {object} SoundMarker + * + * @property {string} name - Unique identifier of a sound marker. + * @property {number} [start=0] - Sound position offset at witch playback should start. + * @property {number} [duration] - Playback duration of this marker. + * @property {SoundConfig} [config] - An optional config object containing default marker settings. + */ + +module.exports = { + + SoundManagerCreator: __webpack_require__(354), + + BaseSound: __webpack_require__(124), + BaseSoundManager: __webpack_require__(125), + + WebAudioSound: __webpack_require__(348), + WebAudioSoundManager: __webpack_require__(349), + + HTML5AudioSound: __webpack_require__(352), + HTML5AudioSoundManager: __webpack_require__(353), + + NoAudioSound: __webpack_require__(350), + NoAudioSoundManager: __webpack_require__(351) + +}; + + +/***/ }), +/* 522 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(1); +var PluginCache = __webpack_require__(15); + +/** + * @classdesc + * A proxy class to the Global Scene Manager. + * + * @class ScenePlugin + * @memberof Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that this ScenePlugin belongs to. + */ +var ScenePlugin = new Class({ + + initialize: + + function ScenePlugin (scene) + { + /** + * The Scene that this ScenePlugin belongs to. + * + * @name Phaser.Scenes.ScenePlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The Scene Systems instance of the Scene that this ScenePlugin belongs to. + * + * @name Phaser.Scenes.ScenePlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * The settings of the Scene this ScenePlugin belongs to. + * + * @name Phaser.Scenes.ScenePlugin#settings + * @type {Phaser.Scenes.Settings.Object} + * @since 3.0.0 + */ + this.settings = scene.sys.settings; + + /** + * The key of the Scene this ScenePlugin belongs to. + * + * @name Phaser.Scenes.ScenePlugin#key + * @type {string} + * @since 3.0.0 + */ + this.key = scene.sys.settings.key; + + /** + * The Game's SceneManager. + * + * @name Phaser.Scenes.ScenePlugin#manager + * @type {Phaser.Scenes.SceneManager} + * @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 {number} + * @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.once('boot', this.boot, this); + scene.sys.events.on('start', this.pluginStart, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Scenes.ScenePlugin#boot + * @private + * @since 3.0.0 + */ + boot: function () + { + this.systems.events.once('destroy', this.destroy, 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.Scenes.ScenePlugin#pluginStart + * @private + * @since 3.5.0 + */ + pluginStart: function () + { + this._target = null; + + this.systems.events.once('shutdown', this.shutdown, this); + }, + + /** + * Shutdown this Scene and run the given one. + * + * @method Phaser.Scenes.ScenePlugin#start + * @since 3.0.0 + * + * @param {string} [key] - The Scene to start. + * @param {object} [data] - The Scene data. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + start: function (key, data) + { + if (key === undefined) { key = this.key; } + + this.manager.queueOp('stop', this.key); + this.manager.queueOp('start', key, data); + + return this; + }, + + /** + * Restarts this Scene. + * + * @method Phaser.Scenes.ScenePlugin#restart + * @since 3.4.0 + * + * @param {object} [data] - The Scene data. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + restart: function (data) + { + var key = this.key; + + this.manager.queueOp('stop', key); + this.manager.queueOp('start', key, data); + + 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] - Move the target Scene to be above this one before the transition starts. + * @property {boolean} [moveBelow] - Move 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 Scene wakes up. + * + * When the duration of the transition has elapsed it will emit the event `transitioncomplete`. + * These events are cleared of all 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, GetFastValue(config, 'data')); + } + + 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 - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + 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. + * + * @method Phaser.Scenes.ScenePlugin#add + * @since 3.0.0 + * + * @param {string} key - The Scene key. + * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The config for the Scene. + * @param {boolean} autoStart - Whether to start the Scene after it's added. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + add: function (key, sceneConfig, autoStart) + { + this.manager.add(key, sceneConfig, autoStart); + + return this; + }, + + /** + * Launch the given Scene and run it in parallel with this one. + * + * @method Phaser.Scenes.ScenePlugin#launch + * @since 3.0.0 + * + * @param {string} key - The Scene to launch. + * @param {object} [data] - The Scene data. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + launch: function (key, data) + { + if (key && key !== this.key) + { + this.manager.queueOp('start', key, data); + } + + return this; + }, + + /** + * Runs the given Scene, but does not change the state of this Scene. + * + * If the given Scene is paused, it will resume it. If sleeping, it will wake it. + * If not running at all, it will be started. + * + * Use this if you wish to open a modal Scene by calling `pause` on the current + * Scene, then `run` on the modal Scene. + * + * @method Phaser.Scenes.ScenePlugin#run + * @since 3.10.0 + * + * @param {string} key - The Scene to run. + * @param {object} [data] - A data object that will be passed to the Scene and emitted in its ready, wake, or resume events. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + run: function (key, data) + { + if (key && key !== this.key) + { + this.manager.queueOp('run', key, data); + } + + return this; + }, + + /** + * Pause the Scene - this stops the update step from happening but it still renders. + * + * @method Phaser.Scenes.ScenePlugin#pause + * @since 3.0.0 + * + * @param {string} [key] - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its pause event. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + pause: function (key, data) + { + if (key === undefined) { key = this.key; } + + this.manager.queueOp('pause', key, data); + + return this; + }, + + /** + * Resume the Scene - starts the update loop again. + * + * @method Phaser.Scenes.ScenePlugin#resume + * @since 3.0.0 + * + * @param {string} [key] - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its resume event. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + resume: function (key, data) + { + if (key === undefined) { key = this.key; } + + this.manager.queueOp('resume', key, data); + + return this; + }, + + /** + * Makes the Scene sleep (no update, no render) but doesn't shutdown. + * + * @method Phaser.Scenes.ScenePlugin#sleep + * @since 3.0.0 + * + * @param {string} [key] - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its sleep event. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + sleep: function (key, data) + { + if (key === undefined) { key = this.key; } + + this.manager.queueOp('sleep', key, data); + + return this; + }, + + /** + * Makes the Scene wake-up (starts update and render) + * + * @method Phaser.Scenes.ScenePlugin#wake + * @since 3.0.0 + * + * @param {string} [key] - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its wake event. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + wake: function (key, data) + { + if (key === undefined) { key = this.key; } + + this.manager.queueOp('wake', key, data); + + return this; + }, + + /** + * Makes this Scene sleep then starts the Scene given. + * + * @method Phaser.Scenes.ScenePlugin#switch + * @since 3.0.0 + * + * @param {string} key - The Scene to start. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + switch: function (key) + { + if (key !== this.key) + { + this.manager.queueOp('switch', this.key, key); + } + + return this; + }, + + /** + * Shutdown the Scene, clearing display list, timers, etc. + * + * @method Phaser.Scenes.ScenePlugin#stop + * @since 3.0.0 + * + * @param {string} key - The Scene to stop. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + stop: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.queueOp('stop', key); + + return this; + }, + + /** + * Sets the active state of the given Scene. + * + * @method Phaser.Scenes.ScenePlugin#setActive + * @since 3.0.0 + * + * @param {boolean} value - If `true` the Scene will be resumed. If `false` it will be paused. + * @param {string} [key] - The Scene to set the active state of. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted with its events. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + setActive: function (value, key, data) + { + if (key === undefined) { key = this.key; } + + var scene = this.manager.getScene(key); + + if (scene) + { + scene.sys.setActive(value, data); + } + + return this; + }, + + /** + * Sets the visible state of the given Scene. + * + * @method Phaser.Scenes.ScenePlugin#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible value. + * @param {string} [key] - The Scene to set the visible state for. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + setVisible: function (value, key) + { + if (key === undefined) { key = this.key; } + + var scene = this.manager.getScene(key); + + if (scene) + { + scene.sys.setVisible(value); + } + + return this; + }, + + /** + * Checks if the given Scene is sleeping or not? + * + * @method Phaser.Scenes.ScenePlugin#isSleeping + * @since 3.0.0 + * + * @param {string} key - The Scene to check. + * + * @return {boolean} Whether the Scene is sleeping. + */ + isSleeping: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.isSleeping(key); + }, + + /** + * Checks if the given Scene is active or not? + * + * @method Phaser.Scenes.ScenePlugin#isActive + * @since 3.0.0 + * + * @param {string} key - The Scene to check. + * + * @return {boolean} Whether the Scene is active. + */ + isActive: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.isActive(key); + }, + + /** + * Checks if the given Scene is visible or not? + * + * @method Phaser.Scenes.ScenePlugin#isVisible + * @since 3.0.0 + * + * @param {string} key - The Scene to check. + * + * @return {boolean} Whether the Scene is visible. + */ + isVisible: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.isVisible(key); + }, + + /** + * Swaps the position of two scenes in the Scenes list. + * + * This controls the order in which they are rendered and updated. + * + * @method Phaser.Scenes.ScenePlugin#swapPosition + * @since 3.2.0 + * + * @param {string} keyA - The first Scene to swap. + * @param {string} [keyB] - The second Scene to swap. If none is given it defaults to this Scene. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + swapPosition: function (keyA, keyB) + { + if (keyB === undefined) { keyB = this.key; } + + if (keyA !== keyB) + { + this.manager.swapPosition(keyA, keyB); + } + + return this; + }, + + /** + * Swaps the position of two scenes in the Scenes list, so that Scene B is directly above Scene A. + * + * This controls the order in which they are rendered and updated. + * + * @method Phaser.Scenes.ScenePlugin#moveAbove + * @since 3.2.0 + * + * @param {string} keyA - The Scene that Scene B will be moved to be above. + * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveAbove: function (keyA, keyB) + { + if (keyB === undefined) { keyB = this.key; } + + if (keyA !== keyB) + { + this.manager.moveAbove(keyA, keyB); + } + + return this; + }, + + /** + * Swaps the position of two scenes in the Scenes list, so that Scene B is directly below Scene A. + * + * This controls the order in which they are rendered and updated. + * + * @method Phaser.Scenes.ScenePlugin#moveBelow + * @since 3.2.0 + * + * @param {string} keyA - The Scene that Scene B will be moved to be below. + * @param {string} [keyB] - The Scene to be moved. If none is given it defaults to this Scene. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveBelow: function (keyA, keyB) + { + if (keyB === undefined) { keyB = this.key; } + + if (keyA !== keyB) + { + this.manager.moveBelow(keyA, keyB); + } + + return this; + }, + + /** + * Removes a Scene from the SceneManager. + * + * The Scene is removed from the local scenes array, it's key is cleared from the keys + * cache and Scene.Systems.destroy is then called on it. + * + * If the SceneManager is processing the Scenes when this method is called it wil + * queue the operation for the next update sequence. + * + * @method Phaser.Scenes.ScenePlugin#remove + * @since 3.2.0 + * + * @param {(string|Phaser.Scene)} key - The Scene to be removed. + * + * @return {Phaser.Scenes.SceneManager} This SceneManager. + */ + remove: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.remove(key); + + return this; + }, + + /** + * Moves a Scene up one position in the Scenes list. + * + * @method Phaser.Scenes.ScenePlugin#moveUp + * @since 3.0.0 + * + * @param {string} key - The Scene to move. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveUp: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.moveUp(key); + + return this; + }, + + /** + * Moves a Scene down one position in the Scenes list. + * + * @method Phaser.Scenes.ScenePlugin#moveDown + * @since 3.0.0 + * + * @param {string} key - The Scene to move. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + moveDown: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.moveDown(key); + + return this; + }, + + /** + * Brings a Scene to the top of the Scenes list. + * + * This means it will render above all other Scenes. + * + * @method Phaser.Scenes.ScenePlugin#bringToTop + * @since 3.0.0 + * + * @param {string} key - The Scene to move. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + bringToTop: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.bringToTop(key); + + return this; + }, + + /** + * Sends a Scene to the back of the Scenes list. + * + * This means it will render below all other Scenes. + * + * @method Phaser.Scenes.ScenePlugin#sendToBack + * @since 3.0.0 + * + * @param {string} key - The Scene to move. + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ + sendToBack: function (key) + { + if (key === undefined) { key = this.key; } + + this.manager.sendToBack(key); + + return this; + }, + + /** + * Retrieve a Scene. + * + * @method Phaser.Scenes.ScenePlugin#get + * @since 3.0.0 + * + * @param {string} key - The Scene to retrieve. + * + * @return {Phaser.Scene} The Scene. + */ + get: function (key) + { + return this.manager.getScene(key); + }, + + /** + * Retrieves the numeric index of a Scene in the Scenes list. + * + * @method Phaser.Scenes.ScenePlugin#getIndex + * @since 3.7.0 + * + * @param {(string|Phaser.Scene)} [key] - The Scene to get the index of. + * + * @return {integer} The index of the Scene. + */ + getIndex: function (key) + { + if (key === undefined) { key = this.key; } + + return this.manager.getIndex(key); + }, + + /** + * 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 () + { + var eventEmitter = this.systems.events; + + eventEmitter.off('shutdown', this.shutdown, this); + eventEmitter.off('postupdate', this.step, this); + eventEmitter.off('transitionout'); + }, + + /** + * 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 () + { + this.shutdown(); + + this.scene.sys.events.off('start', this.start, this); + + this.scene = null; + this.systems = null; + this.settings = null; + this.manager = null; + } + +}); + +PluginCache.register('ScenePlugin', ScenePlugin, 'scenePlugin'); + +module.exports = ScenePlugin; + + +/***/ }), +/* 523 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(126); +var Extend = __webpack_require__(21); + +/** + * @namespace Phaser.Scenes + */ + +var Scene = { + + SceneManager: __webpack_require__(358), + ScenePlugin: __webpack_require__(522), + Settings: __webpack_require__(355), + Systems: __webpack_require__(182) + +}; + +// Merge in the consts +Scene = Extend(false, Scene, CONST); + +module.exports = Scene; + + +/***/ }), +/* 524 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL.Pipelines + */ + +module.exports = { + + BitmapMaskPipeline: __webpack_require__(369), + ForwardDiffuseLightPipeline: __webpack_require__(368), + TextureTintPipeline: __webpack_require__(183) + +}; + + +/***/ }), +/* 525 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL + */ + +module.exports = { + + Utils: __webpack_require__(9), + WebGLPipeline: __webpack_require__(184), + WebGLRenderer: __webpack_require__(371), + Pipelines: __webpack_require__(524), + + // Constants + BYTE: 0, + SHORT: 1, + UNSIGNED_BYTE: 2, + UNSIGNED_SHORT: 3, + FLOAT: 4 + +}; + + +/***/ }), +/* 526 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @callback SnapshotCallback + * + * @param {HTMLImageElement} snapshot - [description] + */ + +/** + * @namespace Phaser.Renderer.Snapshot + */ + +module.exports = { + + Canvas: __webpack_require__(373), + WebGL: __webpack_require__(370) + +}; + + +/***/ }), +/* 527 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.Canvas + */ + +module.exports = { + + CanvasRenderer: __webpack_require__(374), + GetBlendModes: __webpack_require__(372), + SetTransform: __webpack_require__(23) + +}; + + +/***/ }), +/* 528 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} RendererConfig + * + * @property {boolean} clearBeforeRender - [description] + * @property {boolean} antialias - [description] + * @property {Phaser.Display.Color} backgroundColor - [description] + * @property {number} resolution - [description] + * @property {boolean} autoResize - [description] + * @property {boolean} roundPixels - [description] + */ + +/** + * @namespace Phaser.Renderer + */ + +module.exports = { + + Canvas: __webpack_require__(527), + Snapshot: __webpack_require__(526), + WebGL: __webpack_require__(525) + +}; + + +/***/ }), +/* 529 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* @author Richard Davey +* @copyright 2018 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} +*/ + +var BasePlugin = __webpack_require__(234); +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Scene Level Plugin is installed into every Scene and belongs to that Scene. + * It can listen for Scene events and respond to them. + * It can map itself to a Scene property, or into the Scene Systems, or both. + * + * @class ScenePlugin + * @memberof Phaser.Plugins + * @extends Phaser.Plugins.BasePlugin + * @constructor + * @since 3.8.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager. + */ +var ScenePlugin = new Class({ + + Extends: BasePlugin, + + initialize: + + function ScenePlugin (scene, pluginManager) + { + BasePlugin.call(this, pluginManager); + + this.scene = scene; + this.systems = scene.sys; + + scene.sys.events.once('boot', this.boot, this); + }, + + /** + * This method is called when the Scene boots. It is only ever called once. + * + * By this point the plugin properties `scene` and `systems` will have already been set. + * + * In here you can listen for Scene events and set-up whatever you need for this plugin to run. + * Here are the Scene events you can listen to: + * + * start + * ready + * preupdate + * update + * postupdate + * resize + * pause + * resume + * sleep + * wake + * transitioninit + * transitionstart + * transitioncomplete + * transitionout + * shutdown + * destroy + * + * At the very least you should offer a destroy handler for when the Scene closes down, i.e: + * + * ```javascript + * var eventEmitter = this.systems.events; + * eventEmitter.once('destroy', this.sceneDestroy, this); + * ``` + * + * @method Phaser.Plugins.ScenePlugin#boot + * @since 3.8.0 + */ + boot: function () + { + } + +}); + +module.exports = ScenePlugin; + + +/***/ }), +/* 530 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Plugins + */ + +module.exports = { + + BasePlugin: __webpack_require__(234), + DefaultPlugins: __webpack_require__(185), + PluginCache: __webpack_require__(15), + PluginManager: __webpack_require__(360), + ScenePlugin: __webpack_require__(529) + +}; + + +/***/ }), +/* 531 */ +/***/ (function(module, exports, __webpack_require__) { + +var Matter = __webpack_require__(148); + +/** + * A coordinate wrapping plugin for matter.js. + * See the readme for usage and examples. + * @module MatterWrap + */ +var MatterWrap = { + // plugin meta + name: 'matter-wrap', // PLUGIN_NAME + version: '0.1.4', // PLUGIN_VERSION + for: 'matter-js@^0.13.1', + silent: true, // no console log please + + // installs the plugin where `base` is `Matter` + // you should not need to call this directly. + install: function(base) { + base.after('Engine.update', function() { + MatterWrap.Engine.update(this); + }); + }, + + Engine: { + /** + * Updates the engine by wrapping bodies and composites inside `engine.world`. + * This is called automatically by the plugin. + * @function MatterWrap.Engine.update + * @param {Matter.Engine} engine The engine to update. + * @returns {void} No return value. + */ + update: function(engine) { + var world = engine.world, + bodies = Matter.Composite.allBodies(world), + composites = Matter.Composite.allComposites(world); + + for (var i = 0; i < bodies.length; i += 1) { + var body = bodies[i]; + + if (body.plugin.wrap) { + MatterWrap.Body.wrap(body, body.plugin.wrap); + } + } + + for (i = 0; i < composites.length; i += 1) { + var composite = composites[i]; + + if (composite.plugin.wrap) { + MatterWrap.Composite.wrap(composite, composite.plugin.wrap); + } + } + } + }, + + Bounds: { + /** + * Returns a translation vector that wraps the `objectBounds` inside the `bounds`. + * @function MatterWrap.Bounds.wrap + * @param {Matter.Bounds} objectBounds The bounds of the object to wrap inside the bounds. + * @param {Matter.Bounds} bounds The bounds to wrap the body inside. + * @returns {?Matter.Vector} A translation vector (only if wrapping is required). + */ + wrap: function(objectBounds, bounds) { + var x = null, + y = null; + + if (typeof bounds.min.x !== 'undefined' && typeof bounds.max.x !== 'undefined') { + if (objectBounds.min.x > bounds.max.x) { + x = bounds.min.x - objectBounds.max.x; + } else if (objectBounds.max.x < bounds.min.x) { + x = bounds.max.x - objectBounds.min.x; + } + } + + if (typeof bounds.min.y !== 'undefined' && typeof bounds.max.y !== 'undefined') { + if (objectBounds.min.y > bounds.max.y) { + y = bounds.min.y - objectBounds.max.y; + } else if (objectBounds.max.y < bounds.min.y) { + y = bounds.max.y - objectBounds.min.y; + } + } + + if (x !== null || y !== null) { + return { + x: x || 0, + y: y || 0 + }; + } + } + }, + + Body: { + /** + * Wraps the `body` position such that it always stays within the given bounds. + * Upon crossing a boundary the body will appear on the opposite side of the bounds, + * while maintaining its velocity. + * This is called automatically by the plugin. + * @function MatterWrap.Body.wrap + * @param {Matter.Body} body The body to wrap. + * @param {Matter.Bounds} bounds The bounds to wrap the body inside. + * @returns {?Matter.Vector} The translation vector that was applied (only if wrapping was required). + */ + wrap: function(body, bounds) { + var translation = MatterWrap.Bounds.wrap(body.bounds, bounds); + + if (translation) { + Matter.Body.translate(body, translation); + } + + return translation; + } + }, + + Composite: { + /** + * Returns the union of the bounds of all of the composite's bodies + * (not accounting for constraints). + * @function MatterWrap.Composite.bounds + * @param {Matter.Composite} composite The composite. + * @returns {Matter.Bounds} The composite bounds. + */ + bounds: function(composite) { + var bodies = Matter.Composite.allBodies(composite), + vertices = []; + + for (var i = 0; i < bodies.length; i += 1) { + var body = bodies[i]; + vertices.push(body.bounds.min, body.bounds.max); + } + + return Matter.Bounds.create(vertices); + }, + + /** + * Wraps the `composite` position such that it always stays within the given bounds. + * Upon crossing a boundary the composite will appear on the opposite side of the bounds, + * while maintaining its velocity. + * This is called automatically by the plugin. + * @function MatterWrap.Composite.wrap + * @param {Matter.Composite} composite The composite to wrap. + * @param {Matter.Bounds} bounds The bounds to wrap the composite inside. + * @returns {?Matter.Vector} The translation vector that was applied (only if wrapping was required). + */ + wrap: function(composite, bounds) { + var translation = MatterWrap.Bounds.wrap( + MatterWrap.Composite.bounds(composite), + bounds + ); + + if (translation) { + Matter.Composite.translate(composite, translation); + } + + return translation; + } + } +}; + +module.exports = MatterWrap; + +/** + * @namespace Matter.Body + * @see http://brm.io/matter-js/docs/classes/Body.html + */ + +/** + * This plugin adds a new property `body.plugin.wrap` to instances of `Matter.Body`. + * This is a `Matter.Bounds` instance that specifies the wrapping region. + * @property {Matter.Bounds} body.plugin.wrap + * @memberof Matter.Body + */ + +/** + * This plugin adds a new property `composite.plugin.wrap` to instances of `Matter.Composite`. + * This is a `Matter.Bounds` instance that specifies the wrapping region. + * @property {Matter.Bounds} composite.plugin.wrap + * @memberof Matter.Composite + */ + +/***/ }), +/* 532 */ +/***/ (function(module, exports, __webpack_require__) { + +var Matter = __webpack_require__(148); + +/** + * An attractors plugin for matter.js. + * See the readme for usage and examples. + * @module MatterAttractors + */ +var MatterAttractors = { + // plugin meta + name: 'matter-attractors', // PLUGIN_NAME + version: '0.1.7', // PLUGIN_VERSION + for: 'matter-js@^0.13.1', + silent: true, // no console log please + + // installs the plugin where `base` is `Matter` + // you should not need to call this directly. + install: function(base) { + base.after('Body.create', function() { + MatterAttractors.Body.init(this); + }); + + base.before('Engine.update', function(engine) { + MatterAttractors.Engine.update(engine); + }); + }, + + Body: { + /** + * Initialises the `body` to support attractors. + * This is called automatically by the plugin. + * @function MatterAttractors.Body.init + * @param {Matter.Body} body The body to init. + * @returns {void} No return value. + */ + init: function(body) { + body.plugin.attractors = body.plugin.attractors || []; + } + }, + + Engine: { + /** + * Applies all attractors for all bodies in the `engine`. + * This is called automatically by the plugin. + * @function MatterAttractors.Engine.update + * @param {Matter.Engine} engine The engine to update. + * @returns {void} No return value. + */ + update: function(engine) { + var world = engine.world, + bodies = Matter.Composite.allBodies(world); + + for (var i = 0; i < bodies.length; i += 1) { + var bodyA = bodies[i], + attractors = bodyA.plugin.attractors; + + if (attractors && attractors.length > 0) { + for (var j = i + 1; j < bodies.length; j += 1) { + var bodyB = bodies[j]; + + for (var k = 0; k < attractors.length; k += 1) { + var attractor = attractors[k], + forceVector = attractor; + + if (Matter.Common.isFunction(attractor)) { + forceVector = attractor(bodyA, bodyB); + } + + if (forceVector) { + Matter.Body.applyForce(bodyB, bodyB.position, forceVector); + } + } + } + } + } + } + }, + + /** + * Defines some useful common attractor functions that can be used + * by pushing them to your body's `body.plugin.attractors` array. + * @namespace MatterAttractors.Attractors + * @property {number} gravityConstant The gravitational constant used by the gravity attractor. + */ + Attractors: { + gravityConstant: 0.001, + + /** + * An attractor function that applies Newton's law of gravitation. + * Use this by pushing `MatterAttractors.Attractors.gravity` to your body's `body.plugin.attractors` array. + * The gravitational constant defaults to `0.001` which you can change + * at `MatterAttractors.Attractors.gravityConstant`. + * @function MatterAttractors.Attractors.gravity + * @param {Matter.Body} bodyA The first body. + * @param {Matter.Body} bodyB The second body. + * @returns {void} No return value. + */ + gravity: function(bodyA, bodyB) { + // use Newton's law of gravitation + var bToA = Matter.Vector.sub(bodyB.position, bodyA.position), + distanceSq = Matter.Vector.magnitudeSquared(bToA) || 0.0001, + normal = Matter.Vector.normalise(bToA), + magnitude = -MatterAttractors.Attractors.gravityConstant * (bodyA.mass * bodyB.mass / distanceSq), + force = Matter.Vector.mult(normal, magnitude); + + // to apply forces to both bodies + Matter.Body.applyForce(bodyA, bodyA.position, Matter.Vector.neg(force)); + Matter.Body.applyForce(bodyB, bodyB.position, force); + } + } +}; + +module.exports = MatterAttractors; + +/** + * @namespace Matter.Body + * @see http://brm.io/matter-js/docs/classes/Body.html + */ + +/** + * This plugin adds a new property `body.plugin.attractors` to instances of `Matter.Body`. + * This is an array of callback functions that will be called automatically + * for every pair of bodies, on every engine update. + * @property {Function[]} body.plugin.attractors + * @memberof Matter.Body + */ + +/** + * An attractor function calculates the force to be applied + * to `bodyB`, it should either: + * - return the force vector to be applied to `bodyB` + * - or apply the force to the body(s) itself + * @callback AttractorFunction + * @param {Matter.Body} bodyA + * @param {Matter.Body} bodyB + * @returns {(Vector|undefined)} a force vector (optional) + */ + + +/***/ }), +/* 533 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Factory = __webpack_require__(245); +var GetFastValue = __webpack_require__(1); +var GetValue = __webpack_require__(4); +var MatterAttractors = __webpack_require__(532); +var MatterLib = __webpack_require__(240); +var MatterWrap = __webpack_require__(531); +var Merge = __webpack_require__(79); +var Plugin = __webpack_require__(147); +var PluginCache = __webpack_require__(15); +var World = __webpack_require__(235); +var Vertices = __webpack_require__(29); + +/** + * @classdesc + * [description] + * + * @class MatterPhysics + * @memberof Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var MatterPhysics = new Class({ + + initialize: + + function MatterPhysics (scene) + { + /** + * [description] + * + * @name Phaser.Physics.Matter.MatterPhysics#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Physics.Matter.MatterPhysics#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * [description] + * + * @name Phaser.Physics.Matter.MatterPhysics#config + * @type {object} + * @since 3.0.0 + */ + this.config = this.getConfig(); + + /** + * [description] + * + * @name Phaser.Physics.Matter.MatterPhysics#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world; + + /** + * [description] + * + * @name Phaser.Physics.Matter.MatterPhysics#add + * @type {Phaser.Physics.Matter.Factory} + * @since 3.0.0 + */ + this.add; + + /** + * A reference to the `Matter.Vertices` module which contains methods for creating and manipulating sets of vertices. + * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. + * A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). + * + * @name Phaser.Physics.Matter.MatterPhysics#verts + * @type {MatterJS.Vertices} + * @since 3.14.0 + */ + this.verts = Vertices; + + // 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.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Physics.Matter.MatterPhysics#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.world = new World(this.scene, this.config); + this.add = new Factory(this.world); + + this.systems.events.once('destroy', this.destroy, 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 () + { + if (!this.world) + { + 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); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.MatterPhysics#getConfig + * @since 3.0.0 + * + * @return {object} [description] + */ + getConfig: function () + { + var gameConfig = this.systems.game.config.physics; + var sceneConfig = this.systems.settings.physics; + + var config = Merge( + GetFastValue(sceneConfig, 'matter', {}), + GetFastValue(gameConfig, 'matter', {}) + ); + + return config; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.MatterPhysics#enableAttractorPlugin + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.MatterPhysics} This Matter Physics instance. + */ + enableAttractorPlugin: function () + { + Plugin.register(MatterAttractors); + Plugin.use(MatterLib, MatterAttractors); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.MatterPhysics#enableWrapPlugin + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.MatterPhysics} This Matter Physics instance. + */ + enableWrapPlugin: function () + { + Plugin.register(MatterWrap); + Plugin.use(MatterLib, MatterWrap); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.MatterPhysics#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.World} The Matter World object. + */ + pause: function () + { + return this.world.pause(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.MatterPhysics#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.World} The Matter World object. + */ + resume: function () + { + return this.world.resume(); + }, + + /** + * Sets the Matter Engine to run at fixed timestep of 60Hz and enables `autoUpdate`. + * If you have set a custom `getDelta` function then this will override it. + * + * @method Phaser.Physics.Matter.MatterPhysics#set60Hz + * @since 3.4.0 + * + * @return {Phaser.Physics.Matter.MatterPhysics} This Matter Physics instance. + */ + set60Hz: function () + { + this.world.getDelta = this.world.update60Hz; + this.world.autoUpdate = true; + + return this; + }, + + /** + * Sets the Matter Engine to run at fixed timestep of 30Hz and enables `autoUpdate`. + * If you have set a custom `getDelta` function then this will override it. + * + * @method Phaser.Physics.Matter.MatterPhysics#set30Hz + * @since 3.4.0 + * + * @return {Phaser.Physics.Matter.MatterPhysics} This Matter Physics instance. + */ + set30Hz: function () + { + this.world.getDelta = this.world.update30Hz; + this.world.autoUpdate = true; + + return this; + }, + + /** + * Manually advances the physics simulation by one iteration. + * + * You can optionally pass in the `delta` and `correction` values to be used by Engine.update. + * If undefined they use the Matter defaults of 60Hz and no correction. + * + * Calling `step` directly bypasses any checks of `enabled` or `autoUpdate`. + * + * It also ignores any custom `getDelta` functions, as you should be passing the delta + * value in to this call. + * + * You can adjust the number of iterations that Engine.update performs internally. + * Use the Scene Matter Physics config object to set the following properties: + * + * positionIterations (defaults to 6) + * velocityIterations (defaults to 4) + * constraintIterations (defaults to 2) + * + * Adjusting these values can help performance in certain situations, depending on the physics requirements + * of your game. + * + * @method Phaser.Physics.Matter.MatterPhysics#step + * @since 3.4.0 + * + * @param {number} [delta=16.666] - [description] + * @param {number} [correction=1] - [description] + */ + step: function (delta, correction) + { + this.world.step(delta, correction); + }, + + /** + * 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 () + { + 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.add.destroy(); + this.world.destroy(); + + this.add = null; + this.world = null; + }, + + /** + * 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.scene.sys.events.off('start', this.start, this); + + this.scene = null; + this.systems = null; + } + +}); + +PluginCache.register('MatterPhysics', MatterPhysics, 'matterPhysics'); + +module.exports = MatterPhysics; + + +/***/ }), +/* 534 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Svg` module contains methods for converting SVG images into an array of vector points. +* +* To use this module you also need the SVGPathSeg polyfill: https://github.com/progers/pathseg +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Svg +*/ + +var Svg = {}; + +module.exports = Svg; + +var Bounds = __webpack_require__(33); +var Common = __webpack_require__(12); + +(function() { + + /** + * Converts an SVG path into an array of vector points. + * If the input path forms a concave shape, you must decompose the result into convex parts before use. + * See `Bodies.fromVertices` which provides support for this. + * Note that this function is not guaranteed to support complex paths (such as those with holes). + * You must load the `pathseg.js` polyfill on newer browsers. + * @method pathToVertices + * @param {SVGPathElement} path + * @param {Number} [sampleLength=15] + * @return {Vector[]} points + */ + Svg.pathToVertices = function(path, sampleLength) { + if (typeof window !== 'undefined' && !('SVGPathSeg' in window)) { + Common.warn('Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.'); + } + + // https://github.com/wout/svg.topoly.js/blob/master/svg.topoly.js + var i, il, total, point, segment, segments, + segmentsQueue, lastSegment, + lastPoint, segmentIndex, points = [], + lx, ly, length = 0, x = 0, y = 0; + + sampleLength = sampleLength || 15; + + var addPoint = function(px, py, pathSegType) { + // all odd-numbered path types are relative except PATHSEG_CLOSEPATH (1) + var isRelative = pathSegType % 2 === 1 && pathSegType > 1; + + // when the last point doesn't equal the current point add the current point + if (!lastPoint || px != lastPoint.x || py != lastPoint.y) { + if (lastPoint && isRelative) { + lx = lastPoint.x; + ly = lastPoint.y; + } else { + lx = 0; + ly = 0; + } + + var point = { + x: lx + px, + y: ly + py + }; + + // set last point + if (isRelative || !lastPoint) { + lastPoint = point; + } + + points.push(point); + + x = lx + px; + y = ly + py; + } + }; + + var addSegmentPoint = function(segment) { + var segType = segment.pathSegTypeAsLetter.toUpperCase(); + + // skip path ends + if (segType === 'Z') + return; + + // map segment to x and y + switch (segType) { + + case 'M': + case 'L': + case 'T': + case 'C': + case 'S': + case 'Q': + x = segment.x; + y = segment.y; + break; + case 'H': + x = segment.x; + break; + case 'V': + y = segment.y; + break; + } + + addPoint(x, y, segment.pathSegType); + }; + + // ensure path is absolute + Svg._svgPathToAbsolute(path); + + // get total length + total = path.getTotalLength(); + + // queue segments + segments = []; + for (i = 0; i < path.pathSegList.numberOfItems; i += 1) + segments.push(path.pathSegList.getItem(i)); + + segmentsQueue = segments.concat(); + + // sample through path + while (length < total) { + // get segment at position + segmentIndex = path.getPathSegAtLength(length); + segment = segments[segmentIndex]; + + // new segment + if (segment != lastSegment) { + while (segmentsQueue.length && segmentsQueue[0] != segment) + addSegmentPoint(segmentsQueue.shift()); + + lastSegment = segment; + } + + // add points in between when curving + // TODO: adaptive sampling + switch (segment.pathSegTypeAsLetter.toUpperCase()) { + + case 'C': + case 'T': + case 'S': + case 'Q': + case 'A': + point = path.getPointAtLength(length); + addPoint(point.x, point.y, 0); + break; + + } + + // increment by sample value + length += sampleLength; + } + + // add remaining segments not passed by sampling + for (i = 0, il = segmentsQueue.length; i < il; ++i) + addSegmentPoint(segmentsQueue[i]); + + return points; + }; + + Svg._svgPathToAbsolute = function(path) { + // http://phrogz.net/convert-svg-path-to-all-absolute-commands + // Copyright (c) Gavin Kistner + // http://phrogz.net/js/_ReuseLicense.txt + // Modifications: tidy formatting and naming + var x0, y0, x1, y1, x2, y2, segs = path.pathSegList, + x = 0, y = 0, len = segs.numberOfItems; + + for (var i = 0; i < len; ++i) { + var seg = segs.getItem(i), + segType = seg.pathSegTypeAsLetter; + + if (/[MLHVCSQTA]/.test(segType)) { + if ('x' in seg) x = seg.x; + if ('y' in seg) y = seg.y; + } else { + if ('x1' in seg) x1 = x + seg.x1; + if ('x2' in seg) x2 = x + seg.x2; + if ('y1' in seg) y1 = y + seg.y1; + if ('y2' in seg) y2 = y + seg.y2; + if ('x' in seg) x += seg.x; + if ('y' in seg) y += seg.y; + + switch (segType) { + + case 'm': + segs.replaceItem(path.createSVGPathSegMovetoAbs(x, y), i); + break; + case 'l': + segs.replaceItem(path.createSVGPathSegLinetoAbs(x, y), i); + break; + case 'h': + segs.replaceItem(path.createSVGPathSegLinetoHorizontalAbs(x), i); + break; + case 'v': + segs.replaceItem(path.createSVGPathSegLinetoVerticalAbs(y), i); + break; + case 'c': + segs.replaceItem(path.createSVGPathSegCurvetoCubicAbs(x, y, x1, y1, x2, y2), i); + break; + case 's': + segs.replaceItem(path.createSVGPathSegCurvetoCubicSmoothAbs(x, y, x2, y2), i); + break; + case 'q': + segs.replaceItem(path.createSVGPathSegCurvetoQuadraticAbs(x, y, x1, y1), i); + break; + case 't': + segs.replaceItem(path.createSVGPathSegCurvetoQuadraticSmoothAbs(x, y), i); + break; + case 'a': + segs.replaceItem(path.createSVGPathSegArcAbs(x, y, seg.r1, seg.r2, seg.angle, seg.largeArcFlag, seg.sweepFlag), i); + break; + case 'z': + case 'Z': + x = x0; + y = y0; + break; + + } + } + + if (segType == 'M' || segType == 'm') { + x0 = x; + y0 = y; + } + } + }; + +})(); + +/***/ }), +/* 535 */ +/***/ (function(module, exports, __webpack_require__) { + +// @if DEBUG +/** +* _Internal Class_, not generally used outside of the engine's internals. +* +*/ + +var Metrics = {}; + +module.exports = Metrics; + +var Composite = __webpack_require__(63); +var Common = __webpack_require__(12); + +(function() { + + /** + * Creates a new metrics. + * @method create + * @private + * @return {metrics} A new metrics + */ + Metrics.create = function(options) { + var defaults = { + extended: false, + narrowDetections: 0, + narrowphaseTests: 0, + narrowReuse: 0, + narrowReuseCount: 0, + midphaseTests: 0, + broadphaseTests: 0, + narrowEff: 0.0001, + midEff: 0.0001, + broadEff: 0.0001, + collisions: 0, + buckets: 0, + bodies: 0, + pairs: 0 + }; + + return Common.extend(defaults, false, options); + }; + + /** + * Resets metrics. + * @method reset + * @private + * @param {metrics} metrics + */ + Metrics.reset = function(metrics) { + if (metrics.extended) { + metrics.narrowDetections = 0; + metrics.narrowphaseTests = 0; + metrics.narrowReuse = 0; + metrics.narrowReuseCount = 0; + metrics.midphaseTests = 0; + metrics.broadphaseTests = 0; + metrics.narrowEff = 0; + metrics.midEff = 0; + metrics.broadEff = 0; + metrics.collisions = 0; + metrics.buckets = 0; + metrics.pairs = 0; + metrics.bodies = 0; + } + }; + + /** + * Updates metrics. + * @method update + * @private + * @param {metrics} metrics + * @param {engine} engine + */ + Metrics.update = function(metrics, engine) { + if (metrics.extended) { + var world = engine.world, + bodies = Composite.allBodies(world); + + metrics.collisions = metrics.narrowDetections; + metrics.pairs = engine.pairs.list.length; + metrics.bodies = bodies.length; + metrics.midEff = (metrics.narrowDetections / (metrics.midphaseTests || 1)).toFixed(2); + metrics.narrowEff = (metrics.narrowDetections / (metrics.narrowphaseTests || 1)).toFixed(2); + metrics.broadEff = (1 - (metrics.broadphaseTests / (bodies.length || 1))).toFixed(2); + metrics.narrowReuse = (metrics.narrowReuseCount / (metrics.narrowphaseTests || 1)).toFixed(2); + //var broadphase = engine.broadphase[engine.broadphase.current]; + //if (broadphase.instance) + // metrics.buckets = Common.keys(broadphase.instance.buckets).length; + } + }; + +})(); +// @endif + + +/***/ }), +/* 536 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Query` module contains methods for performing collision queries. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Query +*/ + +var Query = {}; + +module.exports = Query; + +var Vector = __webpack_require__(34); +var SAT = __webpack_require__(149); +var Bounds = __webpack_require__(33); +var Bodies = __webpack_require__(55); +var Vertices = __webpack_require__(29); + +(function() { + + /** + * Returns a list of collisions between `body` and `bodies`. + * @method collides + * @param {body} body + * @param {body[]} bodies + * @return {object[]} Collisions + */ + Query.collides = function(body, bodies) { + var collisions = []; + + for (var i = 0; i < bodies.length; i++) { + var bodyA = bodies[i]; + + if (Bounds.overlaps(bodyA.bounds, body.bounds)) { + for (var j = bodyA.parts.length === 1 ? 0 : 1; j < bodyA.parts.length; j++) { + var part = bodyA.parts[j]; + + if (Bounds.overlaps(part.bounds, body.bounds)) { + var collision = SAT.collides(part, body); + + if (collision.collided) { + collisions.push(collision); + break; + } + } + } + } + } + + return collisions; + }; + + /** + * Casts a ray segment against a set of bodies and returns all collisions, ray width is optional. Intersection points are not provided. + * @method ray + * @param {body[]} bodies + * @param {vector} startPoint + * @param {vector} endPoint + * @param {number} [rayWidth] + * @return {object[]} Collisions + */ + Query.ray = function(bodies, startPoint, endPoint, rayWidth) { + rayWidth = rayWidth || 1e-100; + + var rayAngle = Vector.angle(startPoint, endPoint), + rayLength = Vector.magnitude(Vector.sub(startPoint, endPoint)), + rayX = (endPoint.x + startPoint.x) * 0.5, + rayY = (endPoint.y + startPoint.y) * 0.5, + ray = Bodies.rectangle(rayX, rayY, rayLength, rayWidth, { angle: rayAngle }), + collisions = Query.collides(ray, bodies); + + for (var i = 0; i < collisions.length; i += 1) { + var collision = collisions[i]; + collision.body = collision.bodyB = collision.bodyA; + } + + return collisions; + }; + + /** + * Returns all bodies whose bounds are inside (or outside if set) the given set of bounds, from the given set of bodies. + * @method region + * @param {body[]} bodies + * @param {bounds} bounds + * @param {bool} [outside=false] + * @return {body[]} The bodies matching the query + */ + Query.region = function(bodies, bounds, outside) { + var result = []; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + overlaps = Bounds.overlaps(body.bounds, bounds); + if ((overlaps && !outside) || (!overlaps && outside)) + result.push(body); + } + + return result; + }; + + /** + * Returns all bodies whose vertices contain the given point, from the given set of bodies. + * @method point + * @param {body[]} bodies + * @param {vector} point + * @return {body[]} The bodies matching the query + */ + Query.point = function(bodies, point) { + var result = []; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i]; + + if (Bounds.contains(body.bounds, point)) { + for (var j = body.parts.length === 1 ? 0 : 1; j < body.parts.length; j++) { + var part = body.parts[j]; + + if (Bounds.contains(part.bounds, point) + && Vertices.contains(part.vertices, point)) { + result.push(body); + break; + } + } + } + } + + return result; + }; + +})(); + + +/***/ }), +/* 537 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bounds = __webpack_require__(33); +var Class = __webpack_require__(0); +var Composite = __webpack_require__(63); +var Constraint = __webpack_require__(73); +var Detector = __webpack_require__(150); +var GetFastValue = __webpack_require__(1); +var Merge = __webpack_require__(79); +var Sleeping = __webpack_require__(89); +var Vector2 = __webpack_require__(3); +var Vertices = __webpack_require__(29); + +/** + * @classdesc + * [description] + * + * @class PointerConstraint + * @memberof Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Physics.Matter.World} world - [description] + * @param {object} options - [description] + */ +var PointerConstraint = new Class({ + + initialize: + + function PointerConstraint (scene, world, options) + { + if (options === undefined) { options = {}; } + + // Defaults + var defaults = { + label: 'Pointer Constraint', + pointA: { x: 0, y: 0 }, + pointB: { x: 0, y: 0 }, + damping: 0, + length: 0.01, + stiffness: 0.1, + angularStiffness: 1, + collisionFilter: { + category: 0x0001, + mask: 0xFFFFFFFF, + group: 0 + } + }; + + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.0.0 + */ + var camera = GetFastValue(options, 'camera', null); + + if (!camera) + { + this.camera = scene.sys.cameras.main; + } + else + { + this.camera = camera; + + delete options.camera; + } + + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#pointer + * @type {Phaser.Input.Pointer} + * @default null + * @since 3.0.0 + */ + this.pointer = null; + + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * The transformed position. + * + * @name Phaser.Physics.Matter.PointerConstraint#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Matter.PointerConstraint#constraint + * @type {object} + * @since 3.0.0 + */ + this.constraint = Constraint.create(Merge(options, defaults)); + + this.world.on('beforeupdate', this.update, this); + + scene.sys.input.on('pointerdown', this.onDown, this); + + scene.sys.input.on('pointerup', this.onUp, this); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#onDown + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - [description] + */ + onDown: function (pointer) + { + this.pointer = pointer; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#onUp + * @since 3.0.0 + */ + onUp: function () + { + this.pointer = null; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#getBodyPart + * @since 3.0.0 + * + * @param {MatterJS.Body} body - [description] + * @param {Phaser.Math.Vector2} position - [description] + * + * @return {boolean} [description] + */ + getBodyPart: function (body, position) + { + var constraint = this.constraint; + + var start = (body.parts.length > 1) ? 1 : 0; + + for (var i = start; i < body.parts.length; i++) + { + var part = body.parts[i]; + + if (Vertices.contains(part.vertices, position)) + { + constraint.bodyB = body; + + constraint.pointA.x = position.x; + constraint.pointA.y = position.y; + + constraint.pointB.x = position.x - body.position.x; + constraint.pointB.y = position.y - body.position.y; + + constraint.angleB = body.angle; + + Sleeping.set(body, false); + + return true; + } + } + + return false; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#update + * @since 3.0.0 + */ + update: function () + { + if (!this.active) + { + return; + } + + var pointer = this.pointer; + var constraint = this.constraint; + + if (!pointer) + { + // Pointer is up / released + if (constraint.bodyB) + { + constraint.bodyB = null; + } + } + else + { + var pos = this.position; + + this.camera.getWorldPoint(pointer.x, pointer.y, pos); + + if (constraint.bodyB) + { + // Pointer is down and we have bodyB, so wake it up + Sleeping.set(constraint.bodyB, false); + + constraint.pointA.x = pos.x; + constraint.pointA.y = pos.y; + } + else + { + var bodies = Composite.allBodies(this.world.localWorld); + + // Pointer is down and no bodyB, so check if we've hit anything + for (var i = 0; i < bodies.length; i++) + { + var body = bodies[i]; + + if (!body.ignorePointer && Bounds.contains(body.bounds, pos) && + Detector.canCollide(body.collisionFilter, constraint.collisionFilter)) + { + if (this.getBodyPart(body, pos)) + { + break; + } + } + } + } + } + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.PointerConstraint#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.removeConstraint(this.constraint); + + this.constraint = null; + + this.world.off('beforeupdate', this.update); + + this.scene.sys.input.off('pointerdown', this.onDown, this); + + this.scene.sys.input.off('pointerup', this.onUp, this); + } + +}); + +module.exports = PointerConstraint; + + +/***/ }), +/* 538 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(25); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Velocity + * @since 3.0.0 + */ +var Velocity = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Velocity#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAngularVelocity: function (value) + { + Body.setAngularVelocity(this.body, value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Velocity#setVelocityX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityX: function (x) + { + this._tempVec2.set(x, this.body.velocity.y); + + Body.setVelocity(this.body, this._tempVec2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Velocity#setVelocityY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocityY: function (y) + { + this._tempVec2.set(this.body.velocity.x, y); + + Body.setVelocity(this.body, this._tempVec2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Velocity#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setVelocity: function (x, y) + { + this._tempVec2.set(x, y); + + Body.setVelocity(this.body, this._tempVec2); + + return this; + } + +}; + +module.exports = Velocity; + + +/***/ }), +/* 539 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(25); +var MATH_CONST = __webpack_require__(18); +var WrapAngle = __webpack_require__(205); +var WrapAngleDegrees = __webpack_require__(204); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 + +// Transform Component + +/** + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. + * + * @name Phaser.Physics.Matter.Components.Transform + * @since 3.0.0 + */ +var Transform = { + + /** + * The x position of this Game Object. + * + * @name Phaser.Physics.Matter.Components.Transform#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.body.position.x; + }, + + set: function (value) + { + this._tempVec2.set(value, this.y); + + Body.setPosition(this.body, this._tempVec2); + } + + }, + + /** + * The y position of this Game Object. + * + * @name Phaser.Physics.Matter.Components.Transform#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.body.position.y; + }, + + set: function (value) + { + this._tempVec2.set(this.x, value); + + Body.setPosition(this.body, this._tempVec2); + } + + }, + + /** + * The horizontal scale of this Game Object. + * + * @name Phaser.Physics.Matter.Components.Transform#scaleX + * @type {number} + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + var factor = 1 / this._scaleX; + + this._scaleX = value; + + if (this._scaleX === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + // Reset Matter scale back to 1 (sigh) + Body.scale(this.body, factor, this._scaleY); + + Body.scale(this.body, value, this._scaleY); + } + + }, + + /** + * The vertical scale of this Game Object. + * + * @name Phaser.Physics.Matter.Components.Transform#scaleY + * @type {number} + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + var factor = 1 / this._scaleY; + + this._scaleY = value; + + if (this._scaleY === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + Body.scale(this.body, this._scaleX, factor); + + Body.scale(this.body, this._scaleX, value); + } + + }, + + /** + * Use `angle` to set or get rotation of the physics body associated to this GameObject. Unlike rotation, when using set the value can be in degrees, which will be converted to radians internally. + * + * @name Phaser.Physics.Matter.Components.Transform#angle + * @type {number} + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this.body.angle * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * Use `rotation` to set or get the rotation of the physics body associated with this GameObject. The value when set must be in radians. + * + * @name Phaser.Physics.Matter.Components.Transform#rotation + * @type {number} + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this.body.angle; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + + Body.setAngle(this.body, this._rotation); + } + }, + + /** + * Sets the position of the physics body along x and y axes. Both the parameters to this function are optional and if not passed any they default to 0. + * + * @method Phaser.Physics.Matter.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal position of the body. + * @param {number} [y=x] - The vertical position of the body. + * + * @return {this} This Game Object. + */ + setPosition: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this._tempVec2.set(x, y); + + Body.setPosition(this.body, this._tempVec2); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - [description] + * + * @return {this} This Game Object. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this._rotation = WrapAngle(radians); + + Body.setAngle(this.body, radians); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Transform#setFixedRotation + * @since 3.0.0 + * + * @return {this} This Game Object. + */ + setFixedRotation: function () + { + Body.setInertia(this.body, Infinity); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - [description] + * + * @return {this} This Game Object. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + Body.setAngle(this.body, this.rotation); + + return this; + }, + + /** + * Sets the scale of this Game Object. + * + * @method Phaser.Physics.Matter.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} [x=1] - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the x value. + * @param {Phaser.Math.Vector2} [point] - The point (Vector2) from which scaling will occur. + * + * @return {this} This Game Object. + */ + setScale: function (x, y, point) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + var factorX = 1 / this._scaleX; + var factorY = 1 / this._scaleY; + + this._scaleX = x; + this._scaleY = y; + + Body.scale(this.body, factorX, factorY, point); + + Body.scale(this.body, x, y, point); + + return this; + } + +}; + +module.exports = Transform; + + +/***/ }), +/* 540 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MatterEvents = __webpack_require__(74); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Sleep + * @since 3.0.0 + */ +var Sleep = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sleep#setSleepThreshold + * @since 3.0.0 + * + * @param {number} [value=60] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSleepThreshold: function (value) + { + if (value === undefined) { value = 60; } + + this.body.sleepThreshold = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sleep#setSleepEvents + * @since 3.0.0 + * + * @param {boolean} start - [description] + * @param {boolean} end - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSleepEvents: function (start, end) + { + this.setSleepStartEvent(start); + this.setSleepEndEvent(end); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sleep#setSleepStartEvent + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSleepStartEvent: function (value) + { + if (value) + { + var world = this.world; + + MatterEvents.on(this.body, 'sleepStart', function (event) + { + world.emit('sleepstart', event, this); + }); + } + else + { + MatterEvents.off(this.body, 'sleepStart'); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sleep#setSleepEndEvent + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSleepEndEvent: function (value) + { + if (value) + { + var world = this.world; + + MatterEvents.on(this.body, 'sleepEnd', function (event) + { + world.emit('sleepend', event, this); + }); + } + else + { + MatterEvents.off(this.body, 'sleepEnd'); + } + + return this; + } + +}; + +module.exports = Sleep; + + +/***/ }), +/* 541 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Joachim Grill + * @copyright 2018 CodeAndWeb GmbH + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bodies = __webpack_require__(55); +var Body = __webpack_require__(25); +var Bounds = __webpack_require__(33); +var Common = __webpack_require__(12); +var GetFastValue = __webpack_require__(1); +var Vector = __webpack_require__(34); +var Vertices = __webpack_require__(29); + +/** + * Use PhysicsEditorParser.parseBody() to build a Matter body object, based on a physics data file + * created and exported with PhysicsEditor (https://www.codeandweb.com/physicseditor). + * + * @namespace Phaser.Physics.Matter.PhysicsEditorParser + * @since 3.10.0 + */ +var PhysicsEditorParser = { + + /** + * Parses a body element exported by PhysicsEditor. + * + * @function Phaser.Physics.Matter.PhysicsEditorParser.parseBody + * @since 3.10.0 + * + * @param {number} x - x position. + * @param {number} y - y position. + * @param {number} w - width. + * @param {number} h - height. + * @param {object} config - body configuration and fixture (child body) definitions. + * + * @return {object} A matter body, consisting of several parts (child bodies) + */ + parseBody: function (x, y, w, h, config) + { + var fixtureConfigs = GetFastValue(config, 'fixtures', []); + var fixtures = []; + + for (var fc = 0; fc < fixtureConfigs.length; fc++) + { + var fixtureParts = this.parseFixture(fixtureConfigs[fc]); + + for (var i = 0; i < fixtureParts.length; i++) + { + fixtures.push(fixtureParts[i]); + } + } + + var matterConfig = Common.extend({}, false, config); + + delete matterConfig.fixtures; + delete matterConfig.type; + + var body = Body.create(matterConfig); + + Body.setParts(body, fixtures); + body.render.sprite.xOffset = body.position.x / w; + body.render.sprite.yOffset = body.position.y / h; + Body.setPosition(body, { x: x, y: y }); + + return body; + }, + + + /** + * Parses an element of the "fixtures" list exported by PhysicsEditor + * + * @function Phaser.Physics.Matter.PhysicsEditorParser.parseFixture + * @since 3.10.0 + * + * @param {object} fixtureConfig - the fixture object to parse + * + * @return {object[]} - A list of matter bodies + */ + parseFixture: function (fixtureConfig) + { + var matterConfig = Common.extend({}, false, fixtureConfig); + + delete matterConfig.circle; + delete matterConfig.vertices; + + var fixtures; + + if (fixtureConfig.circle) + { + var x = GetFastValue(fixtureConfig.circle, 'x'); + var y = GetFastValue(fixtureConfig.circle, 'y'); + var r = GetFastValue(fixtureConfig.circle, 'radius'); + fixtures = [ Bodies.circle(x, y, r, matterConfig) ]; + } + else if (fixtureConfig.vertices) + { + fixtures = this.parseVertices(fixtureConfig.vertices, matterConfig); + } + + return fixtures; + }, + + /** + * Parses the "vertices" lists exported by PhysicsEditor. + * + * @function Phaser.Physics.Matter.PhysicsEditorParser.parseVertices + * @since 3.10.0 + * + * @param {object} vertexSets - The vertex lists to parse. + * @param {object} options - Matter body options. + * + * @return {object[]} - A list of matter bodies. + */ + parseVertices: function (vertexSets, options) + { + var i, j, k, v, z; + var parts = []; + + options = options || {}; + + for (v = 0; v < vertexSets.length; v += 1) + { + parts.push(Body.create(Common.extend({ + position: Vertices.centre(vertexSets[v]), + vertices: vertexSets[v] + }, options))); + } + + // flag coincident part edges + var coincidentMaxDist = 5; + + for (i = 0; i < parts.length; i++) + { + var partA = parts[i]; + + for (j = i + 1; j < parts.length; j++) + { + var partB = parts[j]; + + if (Bounds.overlaps(partA.bounds, partB.bounds)) + { + var pav = partA.vertices, + pbv = partB.vertices; + + // iterate vertices of both parts + for (k = 0; k < partA.vertices.length; k++) + { + for (z = 0; z < partB.vertices.length; z++) + { + // find distances between the vertices + var da = Vector.magnitudeSquared(Vector.sub(pav[(k + 1) % pav.length], pbv[z])), + db = Vector.magnitudeSquared(Vector.sub(pav[k], pbv[(z + 1) % pbv.length])); + + // if both vertices are very close, consider the edge concident (internal) + if (da < coincidentMaxDist && db < coincidentMaxDist) + { + pav[k].isInternal = true; + pbv[z].isInternal = true; + } + } + } + + } + } + } + + return parts; + } +}; + +module.exports = PhysicsEditorParser; + + +/***/ }), +/* 542 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bodies = __webpack_require__(55); +var Body = __webpack_require__(25); +var GetFastValue = __webpack_require__(1); +var PhysicsEditorParser = __webpack_require__(541); +var Vertices = __webpack_require__(29); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.SetBody + * @since 3.0.0 + */ +var SetBody = { + + // Calling any of these methods resets previous properties you may have set on the body, including plugins, mass, etc + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setRectangle + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setRectangle: function (width, height, options) + { + return this.setBody({ type: 'rectangle', width: width, height: height }, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setCircle + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCircle: function (radius, options) + { + return this.setBody({ type: 'circle', radius: radius }, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setPolygon + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {number} sides - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setPolygon: function (radius, sides, options) + { + return this.setBody({ type: 'polygon', sides: sides, radius: radius }, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setTrapezoid + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} slope - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setTrapezoid: function (width, height, slope, options) + { + return this.setBody({ type: 'trapezoid', width: width, height: height, slope: slope }, options); + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setExistingBody + * @since 3.0.0 + * + * @param {MatterJS.Body} body - [description] + * @param {boolean} [addToWorld=true] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setExistingBody: function (body, addToWorld) + { + if (addToWorld === undefined) + { + addToWorld = true; + } + + if (this.body) + { + this.world.remove(this.body); + } + + this.body = body; + + for (var i = 0; i < body.parts.length; i++) + { + body.parts[i].gameObject = this; + } + + var _this = this; + + body.destroy = function destroy () + { + _this.world.remove(_this.body); + _this.body.gameObject = null; + }; + + if (addToWorld) + { + this.world.add(body); + } + + if (this._originComponent) + { + this.setOrigin(body.render.sprite.xOffset, body.render.sprite.yOffset); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.SetBody#setBody + * @since 3.0.0 + * + * @param {object} config - [description] + * @param {object} options - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBody: function (config, options) + { + if (!config) + { + return this; + } + + var body; + + // Allow them to do: shape: 'circle' instead of shape: { type: 'circle' } + if (typeof config === 'string') + { + // Using defaults + config = { type: config }; + } + + var shapeType = GetFastValue(config, 'type', 'rectangle'); + var bodyX = GetFastValue(config, 'x', this._tempVec2.x); + var bodyY = GetFastValue(config, 'y', this._tempVec2.y); + var bodyWidth = GetFastValue(config, 'width', this.width); + var bodyHeight = GetFastValue(config, 'height', this.height); + + switch (shapeType) + { + case 'rectangle': + body = Bodies.rectangle(bodyX, bodyY, bodyWidth, bodyHeight, options); + break; + + case 'circle': + var radius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); + var maxSides = GetFastValue(config, 'maxSides', 25); + body = Bodies.circle(bodyX, bodyY, radius, options, maxSides); + break; + + case 'trapezoid': + var slope = GetFastValue(config, 'slope', 0.5); + body = Bodies.trapezoid(bodyX, bodyY, bodyWidth, bodyHeight, slope, options); + break; + + case 'polygon': + var sides = GetFastValue(config, 'sides', 5); + var pRadius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); + body = Bodies.polygon(bodyX, bodyY, sides, pRadius, options); + break; + + case 'fromVertices': + case 'fromVerts': + + var verts = GetFastValue(config, 'verts', null); + + if (verts) + { + // Has the verts array come from Vertices.fromPath, or is it raw? + if (typeof verts === 'string') + { + verts = Vertices.fromPath(verts); + } + + if (this.body && !this.body.hasOwnProperty('temp')) + { + Body.setVertices(this.body, verts); + + body = this.body; + } + else + { + var flagInternal = GetFastValue(config, 'flagInternal', false); + var removeCollinear = GetFastValue(config, 'removeCollinear', 0.01); + var minimumArea = GetFastValue(config, 'minimumArea', 10); + + body = Bodies.fromVertices(bodyX, bodyY, verts, options, flagInternal, removeCollinear, minimumArea); + } + } + + break; + + case 'fromPhysicsEditor': + body = PhysicsEditorParser.parseBody(bodyX, bodyY, bodyWidth, bodyHeight, config); + break; + } + + if (body) + { + this.setExistingBody(body, config.addToWorld); + } + + return this; + } + +}; + +module.exports = SetBody; + + +/***/ }), +/* 543 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Sensor + * @since 3.0.0 + */ +var Sensor = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sensor#setSensor + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setSensor: function (value) + { + this.body.isSensor = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Sensor#isSensor + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isSensor: function () + { + return this.body.isSensor; + } + +}; + +module.exports = Sensor; + + +/***/ }), +/* 544 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(25); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Static + * @since 3.0.0 + */ +var Static = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Static#setStatic + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setStatic: function (value) + { + Body.setStatic(this.body, value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Static#isStatic + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isStatic: function () + { + return this.body.isStatic; + } + +}; + +module.exports = Static; + + +/***/ }), +/* 545 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(25); +var Vector2 = __webpack_require__(3); + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Mass + * @since 3.0.0 + */ +var Mass = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Mass#setMass + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setMass: function (value) + { + Body.setMass(this.body, value); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Mass#setDensity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDensity: function (value) + { + Body.setDensity(this.body, value); + + return this; + }, + + /** + * The body's center of mass. + * + * @name Phaser.Physics.Matter.Components.Mass#centerOfMass + * @readonly + * @since 3.10.0 + * + * @return {Phaser.Math.Vector2} The center of mass. + */ + centerOfMass: { + + get: function () + { + return new Vector2(this.body.render.sprite.xOffset * this.width, this.body.render.sprite.yOffset * this.height); + } + } + +}; + +module.exports = Mass; + + +/***/ }), +/* 546 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A component to manipulate world gravity for Matter.js bodies. + * + * @name Phaser.Physics.Matter.Components.Gravity + * @since 3.0.0 + */ +var Gravity = { + + /** + * A togglable function for ignoring world gravity in real-time on the current body. + * + * @method Phaser.Physics.Matter.Components.Gravity#setIgnoreGravity + * @since 3.0.0 + * + * @param {boolean} value - Set to true to ignore the effect of world gravity, or false to not ignore it. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setIgnoreGravity: function (value) + { + this.body.ignoreGravity = value; + + return this; + } + +}; + +module.exports = Gravity; + + +/***/ }), +/* 547 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Friction + * @since 3.0.0 + */ +var Friction = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Friction#setFriction + * @since 3.0.0 + * + * @param {number} value - [description] + * @param {number} [air] - [description] + * @param {number} [fstatic] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFriction: function (value, air, fstatic) + { + this.body.friction = value; + + if (air !== undefined) + { + this.body.frictionAir = air; + } + + if (fstatic !== undefined) + { + this.body.frictionStatic = fstatic; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Friction#setFrictionAir + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionAir: function (value) + { + this.body.frictionAir = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Friction#setFrictionStatic + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionStatic: function (value) + { + this.body.frictionStatic = value; + + return this; + } + +}; + +module.exports = Friction; + + +/***/ }), +/* 548 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(25); + +/** + * A component to apply force to Matter.js bodies. + * + * @name Phaser.Physics.Matter.Components.Force + * @since 3.0.0 + */ +var Force = { + + // force = vec2 / point + + /** + * Applies a force to a body. + * + * @method Phaser.Physics.Matter.Components.Force#applyForce + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} force - A Vector that specifies the force to apply. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + applyForce: function (force) + { + this._tempVec2.set(this.body.position.x, this.body.position.y); + + Body.applyForce(this.body, this._tempVec2, force); + + return this; + }, + + /** + * Applies a force to a body from a given position. + * + * @method Phaser.Physics.Matter.Components.Force#applyForceFrom + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} position - The position in which the force comes from. + * @param {Phaser.Math.Vector2} force - A Vector that specifies the force to apply. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + applyForceFrom: function (position, force) + { + Body.applyForce(this.body, position, force); + + return this; + }, + + /** + * Apply thrust to the forward position of the body. + * + * @method Phaser.Physics.Matter.Components.Force#thrust + * @since 3.0.0 + * + * @param {number} speed - A speed value to be applied to a directional force. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + thrust: function (speed) + { + var angle = this.body.angle; + + this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); + + Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); + + return this; + }, + + /** + * Apply thrust to the left position of the body. + * + * @method Phaser.Physics.Matter.Components.Force#thrustLeft + * @since 3.0.0 + * + * @param {number} speed - A speed value to be applied to a directional force. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + thrustLeft: function (speed) + { + var angle = this.body.angle - Math.PI / 2; + + this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); + + Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); + + return this; + }, + + /** + * Apply thrust to the right position of the body. + * + * @method Phaser.Physics.Matter.Components.Force#thrustRight + * @since 3.0.0 + * + * @param {number} speed - A speed value to be applied to a directional force. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + thrustRight: function (speed) + { + var angle = this.body.angle + Math.PI / 2; + + this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); + + Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); + + return this; + }, + + /** + * Apply thrust to the back position of the body. + * + * @method Phaser.Physics.Matter.Components.Force#thrustBack + * @since 3.0.0 + * + * @param {number} speed - A speed value to be applied to a directional force. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + thrustBack: function (speed) + { + var angle = this.body.angle - Math.PI; + + this._tempVec2.set(speed * Math.cos(angle), speed * Math.sin(angle)); + + Body.applyForce(this.body, { x: this.body.position.x, y: this.body.position.y }, this._tempVec2); + + return this; + } + +}; + +module.exports = Force; + + +/***/ }), +/* 549 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Collision + * @since 3.0.0 + */ +var Collision = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Collision#setCollisionCategory + * @since 3.0.0 + * + * @param {number} value - Unique category bitfield. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollisionCategory: function (value) + { + this.body.collisionFilter.category = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Collision#setCollisionGroup + * @since 3.0.0 + * + * @param {number} value - Unique group index. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollisionGroup: function (value) + { + this.body.collisionFilter.group = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Collision#setCollidesWith + * @since 3.0.0 + * + * @param {(number|number[])} categories - A unique category bitfield, or an array of them. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollidesWith: function (categories) + { + var flags = 0; + + if (!Array.isArray(categories)) + { + flags = categories; + } + else + { + for (var i = 0; i < categories.length; i++) + { + flags |= categories[i]; + } + } + + this.body.collisionFilter.mask = flags; + + return this; + } + +}; + +module.exports = Collision; + + +/***/ }), +/* 550 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Matter.Components.Bounce + * @since 3.0.0 + */ +var Bounce = { + + /** + * [description] + * + * @method Phaser.Physics.Matter.Components.Bounce#setBounce + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounce: function (value) + { + this.body.restitution = value; + + return this; + } + +}; + +module.exports = Bounce; + + +/***/ }), +/* 551 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Components = __webpack_require__(113); +var GetFastValue = __webpack_require__(1); +var Vector2 = __webpack_require__(3); + +/** + * Internal function to check if the object has a getter or setter. + * + * @function hasGetterOrSetter + * @private + * + * @param {object} def - The object to check. + * + * @return {boolean} True if it has a getter or setter, otherwise false. + */ +function hasGetterOrSetter (def) +{ + return (!!def.get && typeof def.get === 'function') || (!!def.set && typeof def.set === 'function'); +} + +/** + * [description] + * + * @function Phaser.Physics.Matter.MatterGameObject + * @since 3.3.0 + * + * @param {Phaser.Physics.Matter.World} world - The Matter world to add the body to. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will have the Matter body applied to it. + * @param {object} options - Matter options config object. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was created with the Matter body. + */ +var MatterGameObject = function (world, gameObject, options) +{ + if (options === undefined) { options = {}; } + + var x = gameObject.x; + var y = gameObject.y; + + // Temp body pos to avoid body null checks + gameObject.body = { + temp: true, + position: { + x: x, + y: y + } + }; + + var mixins = [ + Components.Bounce, + Components.Collision, + Components.Force, + Components.Friction, + Components.Gravity, + Components.Mass, + Components.Sensor, + Components.SetBody, + Components.Sleep, + Components.Static, + Components.Transform, + Components.Velocity + ]; + + // First let's inject all of the components into the Game Object + mixins.forEach(function (mixin) + { + for (var key in mixin) + { + if (hasGetterOrSetter(mixin[key])) + { + Object.defineProperty(gameObject, key, { + get: mixin[key].get, + set: mixin[key].set + }); + } + else + { + Object.defineProperty(gameObject, key, {value: mixin[key]}); + } + } + + }); + + gameObject.world = world; + + gameObject._tempVec2 = new Vector2(x, y); + + var shape = GetFastValue(options, 'shape', null); + + if (!shape) + { + shape = 'rectangle'; + } + + gameObject.setBody(shape, options); + + return gameObject; +}; + +module.exports = MatterGameObject; + + +/***/ }), +/* 552 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Matter + */ + +module.exports = { + + Factory: __webpack_require__(245), + Image: __webpack_require__(242), + Matter: __webpack_require__(148), + MatterPhysics: __webpack_require__(533), + PolyDecomp: __webpack_require__(244), + Sprite: __webpack_require__(241), + TileBody: __webpack_require__(151), + World: __webpack_require__(235) + +}; + +/** + * @namespace MatterJS + */ + +/** + * @classdesc + * The `Matter.Body` module contains methods for creating and manipulating body models. + * A `Matter.Body` is a rigid body that can be simulated by a `Matter.Engine`. + * Factories for commonly used body configurations (such as rectangles, circles and other polygons) can be found in the module `Matter.Bodies`. + * + * @class MatterJS.Body + */ + +/** + * @classdesc + * The `Matter.Composite` module contains methods for creating and manipulating composite bodies. + * A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. + * It is important to use the functions in this module to modify composites, rather than directly modifying their properties. + * Note that the `Matter.World` object is also a type of `Matter.Composite` and as such all composite methods here can also operate on a `Matter.World`. + * + * @class MatterJS.Composite + */ + +/** + * @classdesc + * The `Matter.World` module contains methods for creating and manipulating the world composite. + * A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. + * A `Matter.World` has a few additional properties including `gravity` and `bounds`. + * It is important to use the functions in the `Matter.Composite` module to modify the world composite, rather than directly modifying its properties. + * There are also a few methods here that alias those in `Matter.Composite` for easier readability. + * + * @class MatterJS.World + * @extends MatterJS.Composite + */ + +/** + * @classdesc + * The `Matter.Constraint` module contains methods for creating and manipulating constraints. + * Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). + * The stiffness of constraints can be modified to create springs or elastic. + * + * @class MatterJS.Constraint + */ + +/** + * @classdesc + * The `Matter.Engine` module contains methods for creating and manipulating engines. + * An engine is a controller that manages updating the simulation of the world. + * + * @class MatterJS.Engine + */ + +/** + * @classdesc +* The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. +* A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. +* A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). +* +* @class MatterJS.Vertices +*/ + + +/***/ }), +/* 553 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Impact.SeperateY + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Impact.Body} top - [description] + * @param {Phaser.Physics.Impact.Body} bottom - [description] + * @param {Phaser.Physics.Impact.Body} [weak] - [description] + */ +var SeperateY = function (world, top, bottom, weak) +{ + var nudge = (top.pos.y + top.size.y - bottom.pos.y); + var nudgeX; + var resTop; + + if (weak) + { + var strong = (top === weak) ? bottom : top; + + weak.vel.y = -weak.vel.y * weak.bounciness + strong.vel.y; + + // Riding on a platform? + nudgeX = 0; + + if (weak === top && Math.abs(weak.vel.y - strong.vel.y) < weak.minBounceVelocity) + { + weak.standing = true; + nudgeX = strong.vel.x * world.delta; + } + + var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, nudgeX, weak === top ? -nudge : nudge, weak.size.x, weak.size.y); + + weak.pos.y = resWeak.pos.y; + weak.pos.x = resWeak.pos.x; + } + else if (world.gravity && (bottom.standing || top.vel.y > 0)) + { + resTop = world.collisionMap.trace(top.pos.x, top.pos.y, 0, -(top.pos.y + top.size.y - bottom.pos.y), top.size.x, top.size.y); + + top.pos.y = resTop.pos.y; + + if (top.bounciness > 0 && top.vel.y > top.minBounceVelocity) + { + top.vel.y *= -top.bounciness; + } + else + { + top.standing = true; + top.vel.y = 0; + } + } + else + { + var v2 = (top.vel.y - bottom.vel.y) / 2; + + top.vel.y = -v2; + bottom.vel.y = v2; + + nudgeX = bottom.vel.x * world.delta; + + resTop = world.collisionMap.trace(top.pos.x, top.pos.y, nudgeX, -nudge / 2, top.size.x, top.size.y); + + top.pos.y = resTop.pos.y; + + var resBottom = world.collisionMap.trace(bottom.pos.x, bottom.pos.y, 0, nudge / 2, bottom.size.x, bottom.size.y); + + bottom.pos.y = resBottom.pos.y; + } +}; + +module.exports = SeperateY; + + +/***/ }), +/* 554 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Impact.SeperateX + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Impact.Body} left - [description] + * @param {Phaser.Physics.Impact.Body} right - [description] + * @param {Phaser.Physics.Impact.Body} [weak] - [description] + */ +var SeperateX = function (world, left, right, weak) +{ + var nudge = left.pos.x + left.size.x - right.pos.x; + + // We have a weak entity, so just move this one + if (weak) + { + var strong = (left === weak) ? right : left; + + weak.vel.x = -weak.vel.x * weak.bounciness + strong.vel.x; + + var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, weak === left ? -nudge : nudge, 0, weak.size.x, weak.size.y); + + weak.pos.x = resWeak.pos.x; + } + else + { + var v2 = (left.vel.x - right.vel.x) / 2; + + left.vel.x = -v2; + right.vel.x = v2; + + var resLeft = world.collisionMap.trace(left.pos.x, left.pos.y, -nudge / 2, 0, left.size.x, left.size.y); + + left.pos.x = Math.floor(resLeft.pos.x); + + var resRight = world.collisionMap.trace(right.pos.x, right.pos.y, nudge / 2, 0, right.size.x, right.size.y); + + right.pos.x = Math.ceil(resRight.pos.x); + } +}; + +module.exports = SeperateX; + + +/***/ }), +/* 555 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var COLLIDES = __webpack_require__(91); +var SeperateX = __webpack_require__(554); +var SeperateY = __webpack_require__(553); + +/** + * Impact Physics Solver + * + * @function Phaser.Physics.Impact.Solver + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Impact.Body} bodyA - [description] + * @param {Phaser.Physics.Impact.Body} bodyB - [description] + */ +var Solver = function (world, bodyA, bodyB) +{ + var weak = null; + + if (bodyA.collides === COLLIDES.LITE || bodyB.collides === COLLIDES.FIXED) + { + weak = bodyA; + } + else if (bodyB.collides === COLLIDES.LITE || bodyA.collides === COLLIDES.FIXED) + { + weak = bodyB; + } + + if (bodyA.last.x + bodyA.size.x > bodyB.last.x && bodyA.last.x < bodyB.last.x + bodyB.size.x) + { + if (bodyA.last.y < bodyB.last.y) + { + SeperateY(world, bodyA, bodyB, weak); + } + else + { + SeperateY(world, bodyB, bodyA, weak); + } + + bodyA.collideWith(bodyB, 'y'); + bodyB.collideWith(bodyA, 'y'); + + world.emit('collide', bodyA, bodyB, 'y'); + } + else if (bodyA.last.y + bodyA.size.y > bodyB.last.y && bodyA.last.y < bodyB.last.y + bodyB.size.y) + { + if (bodyA.last.x < bodyB.last.x) + { + SeperateX(world, bodyA, bodyB, weak); + } + else + { + SeperateX(world, bodyB, bodyA, weak); + } + + bodyA.collideWith(bodyB, 'x'); + bodyB.collideWith(bodyA, 'x'); + + world.emit('collide', bodyA, bodyB, 'x'); + } +}; + +module.exports = Solver; + + +/***/ }), +/* 556 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Factory = __webpack_require__(250); +var GetFastValue = __webpack_require__(1); +var Merge = __webpack_require__(79); +var PluginCache = __webpack_require__(15); +var World = __webpack_require__(246); + +/** + * @classdesc + * [description] + * + * @class ImpactPhysics + * @memberof Phaser.Physics.Impact + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var ImpactPhysics = new Class({ + + initialize: + + function ImpactPhysics (scene) + { + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#config + * @type {object} + * @since 3.0.0 + */ + this.config = this.getConfig(); + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#world + * @type {Phaser.Physics.Impact.World} + * @since 3.0.0 + */ + this.world; + + /** + * [description] + * + * @name Phaser.Physics.Impact.ImpactPhysics#add + * @type {Phaser.Physics.Impact.Factory} + * @since 3.0.0 + */ + this.add; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Physics.Impact.ImpactPhysics#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.world = new World(this.scene, this.config); + this.add = new Factory(this.world); + + this.systems.events.once('destroy', this.destroy, 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 () + { + if (!this.world) + { + 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); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.ImpactPhysics#getConfig + * @since 3.0.0 + * + * @return {object} [description] + */ + getConfig: function () + { + var gameConfig = this.systems.game.config.physics; + var sceneConfig = this.systems.settings.physics; + + var config = Merge( + GetFastValue(sceneConfig, 'impact', {}), + GetFastValue(gameConfig, 'impact', {}) + ); + + return config; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.ImpactPhysics#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Impact.World} The Impact World object. + */ + pause: function () + { + return this.world.pause(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.ImpactPhysics#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Impact.World} The Impact World object. + */ + resume: function () + { + return this.world.resume(); + }, + + /** + * 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 () + { + var eventEmitter = this.systems.events; + + eventEmitter.off('update', this.world.update, this.world); + eventEmitter.off('shutdown', this.shutdown, this); + + this.add.destroy(); + this.world.destroy(); + + this.add = null; + this.world = null; + }, + + /** + * 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.scene.sys.events.off('start', this.start, this); + + this.scene = null; + this.systems = null; + } + +}); + +PluginCache.register('ImpactPhysics', ImpactPhysics, 'impactPhysics'); + +module.exports = ImpactPhysics; + + +/***/ }), +/* 557 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The Impact Velocity component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.Velocity + * @since 3.0.0 + */ +var Velocity = { + + /** + * Sets the horizontal velocity of the physics body. + * + * @method Phaser.Physics.Impact.Components.Velocity#setVelocityX + * @since 3.0.0 + * + * @param {number} x - The horizontal velocity value. + * + * @return {this} This Game Object. + */ + setVelocityX: function (x) + { + this.vel.x = x; + + return this; + }, + + /** + * Sets the vertical velocity of the physics body. + * + * @method Phaser.Physics.Impact.Components.Velocity#setVelocityY + * @since 3.0.0 + * + * @param {number} y - The vertical velocity value. + * + * @return {this} This Game Object. + */ + setVelocityY: function (y) + { + this.vel.y = y; + + return this; + }, + + /** + * Sets the horizontal and vertical velocities of the physics body. + * + * @method Phaser.Physics.Impact.Components.Velocity#setVelocity + * @since 3.0.0 + * + * @param {number} x - The horizontal velocity value. + * @param {number} [y=x] - The vertical velocity value. If not given, defaults to the horizontal value. + * + * @return {this} This Game Object. + */ + setVelocity: function (x, y) + { + if (y === undefined) { y = x; } + + this.vel.x = x; + this.vel.y = y; + + return this; + }, + + /** + * Sets the maximum velocity this body can travel at. + * + * @method Phaser.Physics.Impact.Components.Velocity#setMaxVelocity + * @since 3.0.0 + * + * @param {number} x - The maximum allowed horizontal velocity. + * @param {number} [y=x] - The maximum allowed vertical velocity. If not given, defaults to the horizontal value. + * + * @return {this} This Game Object. + */ + setMaxVelocity: function (x, y) + { + if (y === undefined) { y = x; } + + this.maxVel.x = x; + this.maxVel.y = y; + + return this; + } + +}; + +module.exports = Velocity; + + +/***/ }), +/* 558 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The Impact Set Game Object component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.SetGameObject + * @since 3.0.0 + */ +var SetGameObject = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.SetGameObject#setGameObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {boolean} [sync=true] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGameObject: function (gameObject, sync) + { + if (sync === undefined) { sync = true; } + + if (gameObject) + { + this.body.gameObject = gameObject; + + if (sync) + { + this.syncGameObject(); + } + } + else + { + this.body.gameObject = null; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.SetGameObject#syncGameObject + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + syncGameObject: function () + { + var gameObject = this.body.gameObject; + + if (gameObject) + { + this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY); + } + + return this; + } + +}; + +module.exports = SetGameObject; + + +/***/ }), +/* 559 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The Impact Offset component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.Offset + * @since 3.0.0 + */ +var Offset = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Offset#setOffset + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setOffset: function (x, y, width, height) + { + this.body.offset.x = x; + this.body.offset.y = y; + + if (width) + { + this.setBodySize(width, height); + } + + return this; + } + +}; + +module.exports = Offset; + + +/***/ }), +/* 560 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The Impact Gravity component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.Gravity + * @since 3.0.0 + */ +var Gravity = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Gravity#setGravity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setGravity: function (value) + { + this.body.gravityFactor = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Gravity#gravity + * @type {number} + * @since 3.0.0 + */ + gravity: { + + get: function () + { + return this.body.gravityFactor; + }, + + set: function (value) + { + this.body.gravityFactor = value; + } + + } + +}; + +module.exports = Gravity; + + +/***/ }), +/* 561 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The Impact Friction component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.Friction + * @since 3.0.0 + */ +var Friction = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Friction#setFrictionX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionX: function (x) + { + this.friction.x = x; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Friction#setFrictionY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFrictionY: function (y) + { + this.friction.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Friction#setFriction + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFriction: function (x, y) + { + this.friction.x = x; + this.friction.y = y; + + return this; + } + +}; + +module.exports = Friction; + + +/***/ }), +/* 562 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The Impact Debug component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.Debug + * @since 3.0.0 + */ +var Debug = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Debug#setDebug + * @since 3.0.0 + * + * @param {boolean} showBody - [description] + * @param {boolean} showVelocity - [description] + * @param {number} bodyColor - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDebug: function (showBody, showVelocity, bodyColor) + { + this.debugShowBody = showBody; + this.debugShowVelocity = showVelocity; + this.debugBodyColor = bodyColor; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Debug#setDebugBodyColor + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setDebugBodyColor: function (value) + { + this.body.debugBodyColor = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Debug#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + debugShowBody: { + + get: function () + { + return this.body.debugShowBody; + }, + + set: function (value) + { + this.body.debugShowBody = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Debug#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + debugShowVelocity: { + + get: function () + { + return this.body.debugShowVelocity; + }, + + set: function (value) + { + this.body.debugShowVelocity = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Debug#debugBodyColor + * @type {number} + * @since 3.0.0 + */ + debugBodyColor: { + + get: function () + { + return this.body.debugBodyColor; + }, + + set: function (value) + { + this.body.debugBodyColor = value; + } + + } + +}; + +module.exports = Debug; + + +/***/ }), +/* 563 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var COLLIDES = __webpack_require__(91); + +/** + * @callback CollideCallback + * + * @param {Phaser.Physics.Impact.Body} body - [description] + * @param {Phaser.Physics.Impact.Body} other - [description] + * @param {string} axis - [description] + */ + +/** + * The Impact Collides component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.Collides + * @since 3.0.0 + */ +var Collides = { + + _collideCallback: null, + _callbackScope: null, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setCollideCallback + * @since 3.0.0 + * + * @param {CollideCallback} callback - [description] + * @param {*} scope - [description] + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollideCallback: function (callback, scope) + { + this._collideCallback = callback; + + if (scope) + { + this._callbackScope = scope; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setCollidesNever + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCollidesNever: function () + { + this.body.collides = COLLIDES.NEVER; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setLiteCollision + * @since 3.6.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setLiteCollision: function () + { + this.body.collides = COLLIDES.LITE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setPassiveCollision + * @since 3.6.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setPassiveCollision: function () + { + this.body.collides = COLLIDES.PASSIVE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setActiveCollision + * @since 3.6.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setActiveCollision: function () + { + this.body.collides = COLLIDES.ACTIVE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.Collides#setFixedCollision + * @since 3.6.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setFixedCollision: function () + { + this.body.collides = COLLIDES.FIXED; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.Collides#collides + * @type {number} + * @since 3.0.0 + */ + collides: { + + get: function () + { + return this.body.collides; + }, + + set: function (value) + { + this.body.collides = value; + } + + } + +}; + +module.exports = Collides; + + +/***/ }), +/* 564 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TYPE = __webpack_require__(90); + +/** + * The Impact Check Against component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.CheckAgainst + * @since 3.0.0 + */ +var CheckAgainst = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setAvsB + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setAvsB: function () + { + this.setTypeA(); + + return this.setCheckAgainstB(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setBvsA + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBvsA: function () + { + this.setTypeB(); + + return this.setCheckAgainstA(); + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstNone + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCheckAgainstNone: function () + { + this.body.checkAgainst = TYPE.NONE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstA + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCheckAgainstA: function () + { + this.body.checkAgainst = TYPE.A; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstB + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setCheckAgainstB: function () + { + this.body.checkAgainst = TYPE.B; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Impact.Components.CheckAgainst#checkAgainst + * @type {number} + * @since 3.0.0 + */ + checkAgainst: { + + get: function () + { + return this.body.checkAgainst; + }, + + set: function (value) + { + this.body.checkAgainst = value; + } + + } + +}; + +module.exports = CheckAgainst; + + +/***/ }), +/* 565 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The Impact Bounce component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.Bounce + * @since 3.0.0 + */ +var Bounce = { + + /** + * Sets the impact physics bounce, or restitution, value. + * + * @method Phaser.Physics.Impact.Components.Bounce#setBounce + * @since 3.0.0 + * + * @param {number} value - A value between 0 (no rebound) and 1 (full rebound) + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setBounce: function (value) + { + this.body.bounciness = value; + + return this; + }, + + /** + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. + * + * @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity + * @since 3.0.0 + * + * @param {number} value - The minimum allowed velocity. + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setMinBounceVelocity: function (value) + { + this.body.minBounceVelocity = value; + + return this; + }, + + /** + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) + * + * @name Phaser.Physics.Impact.Components.Bounce#bounce + * @type {number} + * @since 3.0.0 + */ + bounce: { + + get: function () + { + return this.body.bounciness; + }, + + set: function (value) + { + this.body.bounciness = value; + } + + } + +}; + +module.exports = Bounce; + + +/***/ }), +/* 566 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TYPE = __webpack_require__(90); + +/** + * The Impact Body Type component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.BodyType + * @since 3.0.0 + */ +var BodyType = { + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyType#getBodyType + * @since 3.0.0 + * + * @return {number} [description] + */ + getBodyType: function () + { + return this.body.type; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyType#setTypeNone + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setTypeNone: function () + { + this.body.type = TYPE.NONE; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyType#setTypeA + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setTypeA: function () + { + this.body.type = TYPE.A; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Impact.Components.BodyType#setTypeB + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} This Game Object. + */ + setTypeB: function () + { + this.body.type = TYPE.B; + + return this; + } + +}; + +module.exports = BodyType; + + +/***/ }), +/* 567 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The Impact Body Scale component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.BodyScale + * @since 3.0.0 + */ +var BodyScale = { + + /** + * Sets the size of the physics body. + * + * @method Phaser.Physics.Impact.Components.BodyScale#setBodySize + * @since 3.0.0 + * + * @param {number} width - The width of the body in pixels. + * @param {number} [height=width] - The height of the body in pixels. + * + * @return {this} This Game Object. + */ + setBodySize: function (width, height) + { + if (height === undefined) { height = width; } + + this.body.size.x = Math.round(width); + this.body.size.y = Math.round(height); + + return this; + }, + + /** + * Sets the scale of the physics body. + * + * @method Phaser.Physics.Impact.Components.BodyScale#setBodyScale + * @since 3.0.0 + * + * @param {number} scaleX - The horizontal scale of the body. + * @param {number} [scaleY] - The vertical scale of the body. If not given, will use the horizontal scale value. + * + * @return {this} This Game Object. + */ + setBodyScale: function (scaleX, scaleY) + { + if (scaleY === undefined) { scaleY = scaleX; } + + var gameObject = this.body.gameObject; + + if (gameObject) + { + gameObject.setScale(scaleX, scaleY); + + return this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY); + } + else + { + return this.setBodySize(this.body.size.x * scaleX, this.body.size.y * scaleY); + } + } + +}; + +module.exports = BodyScale; + + +/***/ }), +/* 568 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The Impact Acceleration component. + * Should be applied as a mixin. + * + * @name Phaser.Physics.Impact.Components.Acceleration + * @since 3.0.0 + */ +var Acceleration = { + + /** + * Sets the horizontal acceleration of this body. + * + * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX + * @since 3.0.0 + * + * @param {number} x - The amount of acceleration to apply. + * + * @return {this} This Game Object. + */ + setAccelerationX: function (x) + { + this.accel.x = x; + + return this; + }, + + /** + * Sets the vertical acceleration of this body. + * + * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY + * @since 3.0.0 + * + * @param {number} y - The amount of acceleration to apply. + * + * @return {this} This Game Object. + */ + setAccelerationY: function (y) + { + this.accel.y = y; + + return this; + }, + + /** + * Sets the horizontal and vertical acceleration of this body. + * + * @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration + * @since 3.0.0 + * + * @param {number} x - The amount of horizontal acceleration to apply. + * @param {number} y - The amount of vertical acceleration to apply. + * + * @return {this} This Game Object. + */ + setAcceleration: function (x, y) + { + this.accel.x = x; + this.accel.y = y; + + return this; + } + +}; + +module.exports = Acceleration; + + +/***/ }), +/* 569 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var H = 0.5; +var N = 1 / 3; +var M = 2 / 3; + +// Tile ID to Slope defs. +// First 4 elements = line data, final = solid or non-solid behind the line + +module.exports = { + + 2: [ 0, 1, 1, 0, true ], + 3: [ 0, 1, 1, H, true ], + 4: [ 0, H, 1, 0, true ], + 5: [ 0, 1, 1, M, true ], + 6: [ 0, M, 1, N, true ], + 7: [ 0, N, 1, 0, true ], + 8: [ H, 1, 0, 0, true ], + 9: [ 1, 0, H, 1, true ], + 10: [ H, 1, 1, 0, true ], + 11: [ 0, 0, H, 1, true ], + 12: [ 0, 0, 1, 0, false ], + 13: [ 1, 1, 0, 0, true ], + 14: [ 1, H, 0, 0, true ], + 15: [ 1, 1, 0, H, true ], + 16: [ 1, N, 0, 0, true ], + 17: [ 1, M, 0, N, true ], + 18: [ 1, 1, 0, M, true ], + 19: [ 1, 1, H, 0, true ], + 20: [ H, 0, 0, 1, true ], + 21: [ 0, 1, H, 0, true ], + 22: [ H, 0, 1, 1, true ], + 23: [ 1, 1, 0, 1, false ], + 24: [ 0, 0, 1, 1, true ], + 25: [ 0, 0, 1, H, true ], + 26: [ 0, H, 1, 1, true ], + 27: [ 0, 0, 1, N, true ], + 28: [ 0, N, 1, M, true ], + 29: [ 0, M, 1, 1, true ], + 30: [ N, 1, 0, 0, true ], + 31: [ 1, 0, M, 1, true ], + 32: [ M, 1, 1, 0, true ], + 33: [ 0, 0, N, 1, true ], + 34: [ 1, 0, 1, 1, false ], + 35: [ 1, 0, 0, 1, true ], + 36: [ 1, H, 0, 1, true ], + 37: [ 1, 0, 0, H, true ], + 38: [ 1, M, 0, 1, true ], + 39: [ 1, N, 0, M, true ], + 40: [ 1, 0, 0, N, true ], + 41: [ M, 1, N, 0, true ], + 42: [ M, 0, N, 1, true ], + 43: [ N, 1, M, 0, true ], + 44: [ N, 0, M, 1, true ], + 45: [ 0, 1, 0, 0, false ], + 52: [ 1, 1, M, 0, true ], + 53: [ N, 0, 0, 1, true ], + 54: [ 0, 1, N, 0, true ], + 55: [ M, 0, 1, 1, true ] + +}; + + +/***/ }), +/* 570 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Set up the trace-result + * var res = { + * collision: {x: false, y: false, slope: false}, + * pos: {x: x, y: y}, + * tile: {x: 0, y: 0} + * }; + * + * @function Phaser.Physics.Impact.UpdateMotion + * @since 3.0.0 + * + * @param {Phaser.Physics.Impact.Body} body - [description] + * @param {object} res - [description] + */ +var UpdateMotion = function (body, res) +{ + body.standing = false; + + // Y + if (res.collision.y) + { + if (body.bounciness > 0 && Math.abs(body.vel.y) > body.minBounceVelocity) + { + body.vel.y *= -body.bounciness; + } + else + { + if (body.vel.y > 0) + { + body.standing = true; + } + + body.vel.y = 0; + } + } + + // X + if (res.collision.x) + { + if (body.bounciness > 0 && Math.abs(body.vel.x) > body.minBounceVelocity) + { + body.vel.x *= -body.bounciness; + } + else + { + body.vel.x = 0; + } + } + + // SLOPE + if (res.collision.slope) + { + var s = res.collision.slope; + + if (body.bounciness > 0) + { + var proj = body.vel.x * s.nx + body.vel.y * s.ny; + + body.vel.x = (body.vel.x - s.nx * proj * 2) * body.bounciness; + body.vel.y = (body.vel.y - s.ny * proj * 2) * body.bounciness; + } + else + { + var lengthSquared = s.x * s.x + s.y * s.y; + var dot = (body.vel.x * s.x + body.vel.y * s.y) / lengthSquared; + + body.vel.x = s.x * dot; + body.vel.y = s.y * dot; + + var angle = Math.atan2(s.x, s.y); + + if (angle > body.slopeStanding.min && angle < body.slopeStanding.max) + { + body.standing = true; + } + } + } + + body.pos.x = res.pos.x; + body.pos.y = res.pos.y; +}; + +module.exports = UpdateMotion; + + +/***/ }), +/* 571 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); + +/** + * [description] + * + * @function Phaser.Physics.Impact.GetVelocity + * @since 3.0.0 + * + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + * @param {number} vel - [description] + * @param {number} accel - [description] + * @param {number} friction - [description] + * @param {number} max - [description] + * + * @return {number} [description] + */ +var GetVelocity = function (delta, vel, accel, friction, max) +{ + if (accel) + { + return Clamp(vel + accel * delta, -max, max); + } + else if (friction) + { + var frictionDelta = friction * delta; + + if (vel - frictionDelta > 0) + { + return vel - frictionDelta; + } + else if (vel + frictionDelta < 0) + { + return vel + frictionDelta; + } + else + { + return 0; + } + } + + return Clamp(vel, -max, max); +}; + +module.exports = GetVelocity; + + +/***/ }), +/* 572 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * An Impact.js compatible physics world, body and solver, for those who are used + * to the Impact way of defining and controlling physics bodies. Also works with + * the new Loader support for Weltmeister map data. + * + * World updated to run off the Phaser main loop. + * Body extended to support additional setter functions. + * + * To create the map data you'll need Weltmeister, which comes with Impact + * and can be purchased from http://impactjs.com + * + * My thanks to Dominic Szablewski for his permission to support Impact in Phaser. + * + * @namespace Phaser.Physics.Impact + */ +module.exports = { + + Body: __webpack_require__(252), + COLLIDES: __webpack_require__(91), + CollisionMap: __webpack_require__(251), + Factory: __webpack_require__(250), + Image: __webpack_require__(248), + ImpactBody: __webpack_require__(249), + ImpactPhysics: __webpack_require__(556), + Sprite: __webpack_require__(247), + TYPE: __webpack_require__(90), + World: __webpack_require__(246) + +}; + + +/***/ }), +/* 573 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetOverlapY = __webpack_require__(257); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.SeparateY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ +var SeparateY = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapY(body1, body2, overlapOnly, bias); + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateY || body2.customSeparateY) + { + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); + } + + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.y; + var v2 = body2.velocity.y; + + if (!body1.immovable && !body2.immovable) + { + overlap *= 0.5; + + body1.y -= overlap; + body2.y += overlap; + + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; + + nv1 -= avg; + nv2 -= avg; + + body1.velocity.y = avg + nv1 * body1.bounce.y; + body2.velocity.y = avg + nv2 * body2.bounce.y; + } + else if (!body1.immovable) + { + body1.y -= overlap; + body1.velocity.y = v2 - v1 * body1.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body2.moves) + { + body1.x += (body2.x - body2.prev.x) * body2.friction.x; + } + } + else + { + body2.y += overlap; + body2.velocity.y = v1 - v2 * body2.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body1.moves) + { + body2.x += (body1.x - body1.prev.x) * body1.friction.x; + } + } + + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; + +module.exports = SeparateY; + + +/***/ }), +/* 574 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetOverlapX = __webpack_require__(258); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.SeparateX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ +var SeparateX = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapX(body1, body2, overlapOnly, bias); + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) + { + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); + } + + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.x; + var v2 = body2.velocity.x; + + if (!body1.immovable && !body2.immovable) + { + overlap *= 0.5; + + body1.x -= overlap; + body2.x += overlap; + + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; + + nv1 -= avg; + nv2 -= avg; + + body1.velocity.x = avg + nv1 * body1.bounce.x; + body2.velocity.x = avg + nv2 * body2.bounce.x; + } + else if (!body1.immovable) + { + body1.x -= overlap; + body1.velocity.x = v2 - v1 * body1.bounce.x; + + // This is special case code that handles things like vertically moving platforms you can ride + if (body2.moves) + { + body1.y += (body2.y - body2.prev.y) * body2.friction.y; + } + } + else + { + body2.x += overlap; + body2.velocity.x = v1 - v2 * body2.bounce.x; + + // This is special case code that handles things like vertically moving platforms you can ride + if (body1.moves) + { + body2.y += (body1.y - body1.prev.y) * body1.friction.y; + } + } + + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; + +module.exports = SeparateX; + + +/***/ }), +/* 575 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} y - The y separation amount. + */ +var ProcessTileSeparationY = function (body, y) +{ + if (y < 0) + { + body.blocked.none = false; + body.blocked.up = true; + } + else if (y > 0) + { + body.blocked.none = false; + body.blocked.down = true; + } + + body.position.y -= y; + + if (body.bounce.y === 0) + { + body.velocity.y = 0; + } + else + { + body.velocity.y = -body.velocity.y * body.bounce.y; + } +}; + +module.exports = ProcessTileSeparationY; + + +/***/ }), +/* 576 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationY = __webpack_require__(575); + +/** + * Check the body against the given tile on the Y axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileTop - [description] + * @param {number} tileBottom - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) +{ + var oy = 0; + + if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) + { + // Body is moving UP + if (tile.faceBottom && body.y < tileBottom) + { + oy = body.y - tileBottom; + + if (oy < -tileBias) + { + oy = 0; + } + } + } + else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) + { + // Body is moving DOWN + if (tile.faceTop && body.bottom > tileTop) + { + oy = body.bottom - tileTop; + + if (oy > tileBias) + { + oy = 0; + } + } + } + + if (oy !== 0) + { + if (body.customSeparateY) + { + body.overlapY = oy; + } + else + { + ProcessTileSeparationY(body, oy); + } + } + + return oy; +}; + +module.exports = TileCheckY; + + +/***/ }), +/* 577 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} x - The x separation amount. + */ +var ProcessTileSeparationX = function (body, x) +{ + if (x < 0) + { + body.blocked.none = false; + body.blocked.left = true; + } + else if (x > 0) + { + body.blocked.none = false; + body.blocked.right = true; + } + + body.position.x -= x; + + if (body.bounce.x === 0) + { + body.velocity.x = 0; + } + else + { + body.velocity.x = -body.velocity.x * body.bounce.x; + } +}; + +module.exports = ProcessTileSeparationX; + + +/***/ }), +/* 578 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationX = __webpack_require__(577); + +/** + * Check the body against the given tile on the X axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileLeft - [description] + * @param {number} tileRight - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) +{ + var ox = 0; + + if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) + { + // Body is moving LEFT + if (tile.faceRight && body.x < tileRight) + { + ox = body.x - tileRight; + + if (ox < -tileBias) + { + ox = 0; + } + } + } + else if (body.deltaX() > 0 && !body.blocked.right && tile.collideLeft && body.checkCollision.right) + { + // Body is moving RIGHT + if (tile.faceLeft && body.right > tileLeft) + { + ox = body.right - tileLeft; + + if (ox > tileBias) + { + ox = 0; + } + } + } + + if (ox !== 0) + { + if (body.customSeparateX) + { + body.overlapX = ox; + } + else + { + ProcessTileSeparationX(body, ox); + } + } + + return ox; +}; + +module.exports = TileCheckX; + + +/***/ }), +/* 579 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileCheckX = __webpack_require__(578); +var TileCheckY = __webpack_require__(576); +var TileIntersectsBody = __webpack_require__(254); + +/** + * The core separation function to separate a physics body and a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.SeparateTile + * @since 3.0.0 + * + * @param {number} i - [description] + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. + * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemapLayer to collide against. + * @param {number} tileBias - [description] + * + * @return {boolean} Returns true if the body was separated, otherwise false. + */ +var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) +{ + var tileLeft = tileWorldRect.left; + var tileTop = tileWorldRect.top; + var tileRight = tileWorldRect.right; + var tileBottom = tileWorldRect.bottom; + var faceHorizontal = tile.faceLeft || tile.faceRight; + var faceVertical = tile.faceTop || tile.faceBottom; + + // We don't need to go any further if this tile doesn't actually have any colliding faces. This + // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't + // needed for separation. + if (!faceHorizontal && !faceVertical) + { + return false; + } + + var ox = 0; + var oy = 0; + var minX = 0; + var minY = 1; + + if (body.deltaAbsX() > body.deltaAbsY()) + { + // Moving faster horizontally, check X axis first + minX = -1; + } + else if (body.deltaAbsX() < body.deltaAbsY()) + { + // Moving faster vertically, check Y axis first + minY = -1; + } + + if (body.deltaX() !== 0 && body.deltaY() !== 0 && faceHorizontal && faceVertical) + { + // We only need do this if both axes have colliding faces AND we're moving in both + // directions + minX = Math.min(Math.abs(body.position.x - tileRight), Math.abs(body.right - tileLeft)); + minY = Math.min(Math.abs(body.position.y - tileBottom), Math.abs(body.bottom - tileTop)); + } + + if (minX < minY) + { + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + + // That's horizontal done, check if we still intersects? If not then we can return now + if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + } + } + else + { + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + + // That's vertical done, check if we still intersects? If not then we can return now + if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + } + } + + return (ox !== 0 || oy !== 0); +}; + +module.exports = SeparateTile; + + +/***/ }), +/* 580 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.Tilemap} tile - [description] + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * + * @return {boolean} [description] + */ +var ProcessTileCallbacks = function (tile, sprite) +{ + // Tile callbacks take priority over layer level callbacks + if (tile.collisionCallback) + { + return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); + } + else if (tile.layer.callbacks[tile.index]) + { + return !tile.layer.callbacks[tile.index].callback.call( + tile.layer.callbacks[tile.index].callbackContext, sprite, tile + ); + } + + return true; +}; + +module.exports = ProcessTileCallbacks; + + +/***/ }), +/* 581 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Velocity + * @since 3.0.0 + */ +var Velocity = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. + */ + setVelocity: function (x, y) + { + this.body.setVelocity(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {this} This Game Object. + */ + setVelocityX: function (x) + { + this.body.setVelocityX(x); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {this} This Game Object. + */ + setVelocityY: function (y) + { + this.body.setVelocityY(y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. + */ + setMaxVelocity: function (x, y) + { + this.body.maxVelocity.set(x, y); + + return this; + } + +}; + +module.exports = Velocity; + + +/***/ }), +/* 582 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods for setting the size of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.Physics.Arcade.Components.Size + * @since 3.0.0 + */ +var Size = { + + /** + * Sets the body offset. This allows you to adjust the difference between the center of the body + * and the x and y coordinates of the parent Game Object. + * + * @method Phaser.Physics.Arcade.Components.Size#setOffset + * @since 3.0.0 + * + * @param {number} x - The amount to offset the body from the parent Game Object along the x-axis. + * @param {number} [y=x] - The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. + * + * @return {this} This Game Object. + */ + setOffset: function (x, y) + { + this.body.setOffset(x, y); + + return this; + }, + + /** + * Sets the size of this physics body. Setting the size does not adjust the dimensions + * of the parent Game Object. + * + * @method Phaser.Physics.Arcade.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The new width of the physics body, in pixels. + * @param {number} height - The new height of the physics body, in pixels. + * @param {boolean} [center=true] - Should the body be re-positioned so its center aligns with the parent Game Object? + * + * @return {this} This Game Object. + */ + setSize: function (width, height, center) + { + this.body.setSize(width, height, center); + + return this; + }, + + /** + * Sets this physics body to use a circle for collision instead of a rectangle. + * + * @method Phaser.Physics.Arcade.Components.Size#setCircle + * @since 3.0.0 + * + * @param {number} radius - The radius of the physics body, in pixels. + * @param {number} [offsetX] - The amount to offset the body from the parent Game Object along the x-axis. + * @param {number} [offsetY] - The amount to offset the body from the parent Game Object along the y-axis. + * + * @return {this} This Game Object. + */ + setCircle: function (radius, offsetX, offsetY) + { + this.body.setCircle(radius, offsetX, offsetY); + + return this; + } + +}; + +module.exports = Size; + + +/***/ }), +/* 583 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Mass + * @since 3.0.0 + */ +var Mass = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Mass#setMass + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setMass: function (value) + { + this.body.mass = value; + + return this; + } + +}; + +module.exports = Mass; + + +/***/ }), +/* 584 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Immovable + * @since 3.0.0 + */ +var Immovable = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable + * @since 3.0.0 + * + * @param {boolean} [value=true] - [description] + * + * @return {this} This Game Object. + */ + setImmovable: function (value) + { + if (value === undefined) { value = true; } + + this.body.immovable = value; + + return this; + } + +}; + +module.exports = Immovable; + + +/***/ }), +/* 585 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods for setting the gravity properties of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.Physics.Arcade.Components.Gravity + * @since 3.0.0 + */ +var Gravity = { + + /** + * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. + * + * If only one value is provided, this value will be used for both the X and Y axis. + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravity + * @since 3.0.0 + * + * @param {number} x - The gravitational force to be applied to the X-axis. + * @param {number} [y=x] - The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. + * + * @return {this} This Game Object. + */ + setGravity: function (x, y) + { + this.body.gravity.set(x, y); + + return this; + }, + + /** + * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX + * @since 3.0.0 + * + * @param {number} x - The gravitational force to be applied to the X-axis. + * + * @return {this} This Game Object. + */ + setGravityX: function (x) + { + this.body.gravity.x = x; + + return this; + }, + + /** + * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY + * @since 3.0.0 + * + * @param {number} y - The gravitational force to be applied to the Y-axis. + * + * @return {this} This Game Object. + */ + setGravityY: function (y) + { + this.body.gravity.y = y; + + return this; + } + +}; + +module.exports = Gravity; + + +/***/ }), +/* 586 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @name Phaser.Physics.Arcade.Components.Friction + * @since 3.0.0 + */ +var Friction = { + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @method Phaser.Physics.Arcade.Components.Friction#setFriction + * @since 3.0.0 + * + * @param {number} x - The amount of horizontal friction to apply. + * @param {number} [y=x] - The amount of vertical friction to apply. + * + * @return {this} This Game Object. + */ + setFriction: function (x, y) + { + this.body.friction.set(x, y); + + return this; + }, + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX + * @since 3.0.0 + * + * @param {number} x - The amount of friction to apply. + * + * @return {this} This Game Object. + */ + setFrictionX: function (x) + { + this.body.friction.x = x; + + return this; + }, + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY + * @since 3.0.0 + * + * @param {number} x - The amount of friction to apply. + * + * @return {this} This Game Object. + */ + setFrictionY: function (y) + { + this.body.friction.y = y; + + return this; + } + +}; + +module.exports = Friction; + + +/***/ }), +/* 587 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Enable + * @since 3.0.0 + */ +var Enable = { + + /** + * Enables this Game Object's Body. + * + * @method Phaser.Physics.Arcade.Components.Enable#enableBody + * @since 3.0.0 + * + * @param {boolean} reset - Also reset the Body and place it at (x, y). + * @param {number} x - The horizontal position to place the Game Object and Body. + * @param {number} y - The horizontal position to place the Game Object and Body. + * @param {boolean} enableGameObject - Also activate this Game Object. + * @param {boolean} showGameObject - Also show this Game Object. + * + * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.Body#enable + * @see Phaser.Physics.Arcade.StaticBody#enable + * @see Phaser.Physics.Arcade.Body#reset + * @see Phaser.Physics.Arcade.StaticBody#reset + * @see Phaser.GameObjects.GameObject#active + * @see Phaser.GameObjects.GameObject#visible + */ + enableBody: function (reset, x, y, enableGameObject, showGameObject) + { + if (reset) + { + this.body.reset(x, y); + } + + if (enableGameObject) + { + this.body.gameObject.active = true; + } + + if (showGameObject) + { + this.body.gameObject.visible = true; + } + + this.body.enable = true; + + return this; + }, + + /** + * Stops and disables this Game Object's Body. + * + * @method Phaser.Physics.Arcade.Components.Enable#disableBody + * @since 3.0.0 + * + * @param {boolean} [disableGameObject=false] - Also deactivate this Game Object. + * @param {boolean} [hideGameObject=false] - Also hide this Game Object. + * + * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.Body#enable + * @see Phaser.Physics.Arcade.StaticBody#enable + * @see Phaser.GameObjects.GameObject#active + * @see Phaser.GameObjects.GameObject#visible + */ + disableBody: function (disableGameObject, hideGameObject) + { + if (disableGameObject === undefined) { disableGameObject = false; } + if (hideGameObject === undefined) { hideGameObject = false; } + + this.body.stop(); + + this.body.enable = false; + + if (disableGameObject) + { + this.body.gameObject.active = false; + } + + if (hideGameObject) + { + this.body.gameObject.visible = false; + } + + return this; + }, + + /** + * Syncs the Body's position and size with its parent Game Object. + * You don't need to call this for Dynamic Bodies, as it happens automatically. + * But for Static bodies it's a useful way of modifying the position of a Static Body + * in the Physics World, based on its Game Object. + * + * @method Phaser.Physics.Arcade.Components.Enable#refreshBody + * @since 3.1.0 + * + * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject + */ + refreshBody: function () + { + this.body.updateFromGameObject(); + + return this; + } + +}; + +module.exports = Enable; + + +/***/ }), +/* 588 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Drag + * @since 3.0.0 + */ +var Drag = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDrag + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. + */ + setDrag: function (x, y) + { + this.body.drag.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setDragX: function (value) + { + this.body.drag.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setDragY: function (value) + { + this.body.drag.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDamping + * @since 3.10.0 + * + * @param {boolean} value - `true` to use damping for deceleration, or `false` to use linear deceleration. + * + * @return {this} This Game Object. + */ + setDamping: function (value) + { + this.body.useDamping = value; + + return this; + } + +}; + +module.exports = Drag; + + +/***/ }), +/* 589 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug + * @since 3.0.0 + */ +var Debug = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebug + * @since 3.0.0 + * + * @param {boolean} showBody - [description] + * @param {boolean} showVelocity - [description] + * @param {number} bodyColor - [description] + * + * @return {this} This Game Object. + */ + setDebug: function (showBody, showVelocity, bodyColor) + { + this.debugShowBody = showBody; + this.debugShowVelocity = showVelocity; + this.debugBodyColor = bodyColor; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setDebugBodyColor: function (value) + { + this.body.debugBodyColor = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + debugShowBody: { + + get: function () + { + return this.body.debugShowBody; + }, + + set: function (value) + { + this.body.debugShowBody = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + debugShowVelocity: { + + get: function () + { + return this.body.debugShowVelocity; + }, + + set: function (value) + { + this.body.debugShowVelocity = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor + * @type {number} + * @since 3.0.0 + */ + debugBodyColor: { + + get: function () + { + return this.body.debugBodyColor; + }, + + set: function (value) + { + this.body.debugBodyColor = value; + } + + } + +}; + +module.exports = Debug; + + +/***/ }), +/* 590 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Bounce + * @since 3.0.0 + */ +var Bounce = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounce + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. + */ + setBounce: function (x, y) + { + this.body.bounce.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setBounceX: function (value) + { + this.body.bounce.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setBounceY: function (value) + { + this.body.bounce.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {this} This Game Object. + */ + setCollideWorldBounds: function (value) + { + this.body.collideWorldBounds = value; + + return this; + } + +}; + +module.exports = Bounce; + + +/***/ }), +/* 591 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Angular + * @since 3.0.0 + */ +var Angular = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setAngularVelocity: function (value) + { + this.body.angularVelocity = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setAngularAcceleration: function (value) + { + this.body.angularAcceleration = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setAngularDrag: function (value) + { + this.body.angularDrag = value; + + return this; + } + +}; + +module.exports = Angular; + + +/***/ }), +/* 592 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the acceleration properties of an Arcade Body. + * + * @name Phaser.Physics.Arcade.Components.Acceleration + * @since 3.0.0 + */ +var Acceleration = { + + /** + * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration + * @since 3.0.0 + * + * @param {number} x - The horizontal acceleration + * @param {number} [y=x] - The vertical acceleration + * + * @return {this} This Game Object. + */ + setAcceleration: function (x, y) + { + this.body.acceleration.set(x, y); + + return this; + }, + + /** + * Sets the body's horizontal acceleration. + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - The horizontal acceleration + * + * @return {this} This Game Object. + */ + setAccelerationX: function (value) + { + this.body.acceleration.x = value; + + return this; + }, + + /** + * Sets the body's vertical acceleration. + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - The vertical acceleration + * + * @return {this} This Game Object. + */ + setAccelerationY: function (value) + { + this.body.acceleration.y = value; + + return this; + } + +}; + +module.exports = Acceleration; + + +/***/ }), +/* 593 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(36); +var DistanceBetween = __webpack_require__(58); +var DistanceSquared = __webpack_require__(277); +var Factory = __webpack_require__(266); +var GetFastValue = __webpack_require__(1); +var Merge = __webpack_require__(79); +var PluginCache = __webpack_require__(15); +var Vector2 = __webpack_require__(3); +var World = __webpack_require__(261); + +/** + * @classdesc + * The Arcade Physics Plugin belongs to a Scene and sets up and manages the Scene's physics simulation. + * It also holds some useful methods for moving and rotating Arcade Physics Bodies. + * + * You can access it from within a Scene using `this.physics`. + * + * @class ArcadePhysics + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that this Plugin belongs to. + */ +var ArcadePhysics = new Class({ + + initialize: + + function ArcadePhysics (scene) + { + /** + * The Scene that this Plugin belongs to. + * + * @name Phaser.Physics.Arcade.ArcadePhysics#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The Scene's Systems. + * + * @name Phaser.Physics.Arcade.ArcadePhysics#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A configuration object. Union of the `physics.arcade.*` properties of the GameConfig and SceneConfig objects. + * + * @name Phaser.Physics.Arcade.ArcadePhysics#config + * @type {object} + * @since 3.0.0 + */ + this.config = this.getConfig(); + + /** + * The physics simulation. + * + * @name Phaser.Physics.Arcade.ArcadePhysics#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world; + + /** + * An object holding the Arcade Physics factory methods. + * + * @name Phaser.Physics.Arcade.ArcadePhysics#add + * @type {Phaser.Physics.Arcade.Factory} + * @since 3.0.0 + */ + this.add; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.world = new World(this.scene, this.config); + this.add = new Factory(this.world); + + this.systems.events.once('destroy', this.destroy, 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 () + { + if (!this.world) + { + 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); + }, + + /** + * Creates the physics configuration for the current Scene. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig + * @since 3.0.0 + * + * @return {object} The physics configuration. + */ + getConfig: function () + { + var gameConfig = this.systems.game.config.physics; + var sceneConfig = this.systems.settings.physics; + + var config = Merge( + GetFastValue(sceneConfig, 'arcade', {}), + GetFastValue(gameConfig, 'arcade', {}) + ); + + return config; + }, + + /** + * Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap} + * + * @method Phaser.Physics.Arcade.ArcadePhysics#overlap + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if at least one Game Object overlaps another. + * + * @see Phaser.Physics.Arcade.World#overlap + */ + overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) + { + if (overlapCallback === undefined) { overlapCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = overlapCallback; } + + return this.world.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + }, + + /** + * Tests if Game Objects overlap and separates them (if possible). See {@link Phaser.Physics.Arcade.World#collide}. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#collide + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if any overlapping Game Objects were separated, otherwise false. + * + * @see Phaser.Physics.Arcade.World#collide + */ + collide: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + return this.world.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + }, + + /** + * Pauses the simulation. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} The simulation. + */ + pause: function () + { + return this.world.pause(); + }, + + /** + * Resumes the simulation (if paused). + * + * @method Phaser.Physics.Arcade.ArcadePhysics#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} The simulation. + */ + resume: function () + { + return this.world.resume(); + }, + + /** + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) + * + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateTo + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to accelerate towards. + * @param {number} y - The y coordinate to accelerate towards. + * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + accelerateTo: function (gameObject, x, y, speed, xSpeedMax, ySpeedMax) + { + if (speed === undefined) { speed = 60; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + gameObject.body.acceleration.setToPolar(angle, speed); + + if (xSpeedMax !== undefined && ySpeedMax !== undefined) + { + gameObject.body.maxVelocity.set(xSpeedMax, ySpeedMax); + } + + return angle; + }, + + /** + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) + * + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateToObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {Phaser.GameObjects.GameObject} destination - The Game Object to move towards. Can be any object but must have visible x/y properties. + * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + accelerateToObject: function (gameObject, destination, speed, xSpeedMax, ySpeedMax) + { + return this.accelerateTo(gameObject, destination.x, destination.y, speed, xSpeedMax, ySpeedMax); + }, + + /** + * Finds the Body closest to a source point or object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#closest + * @since 3.0.0 + * + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * + * @return {Phaser.Physics.Arcade.Body} The closest Body to the given source point. + */ + closest: function (source) + { + var bodies = this.world.tree.all(); + + var min = Number.MAX_VALUE; + var closest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) + { + var target = bodies[i]; + var distance = DistanceSquared(x, y, target.x, target.y); + + if (distance < min) + { + closest = target; + min = distance; + } + } + + return closest; + }, + + /** + * Finds the Body farthest from a source point or object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#furthest + * @since 3.0.0 + * + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * + * @return {Phaser.Physics.Arcade.Body} The Body furthest from the given source point. + */ + furthest: function (source) + { + var bodies = this.world.tree.all(); + + var max = -1; + var farthest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) + { + var target = bodies[i]; + var distance = DistanceSquared(x, y, target.x, target.y); + + if (distance > max) + { + farthest = target; + max = distance; + } + } + + return farthest; + }, + + /** + * Move the given display object towards the x/y coordinates at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @method Phaser.Physics.Arcade.ArcadePhysics#moveTo + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to move towards. + * @param {number} y - The y coordinate to move towards. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveTo: function (gameObject, x, y, speed, maxTime) + { + if (speed === undefined) { speed = 60; } + if (maxTime === undefined) { maxTime = 0; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + if (maxTime > 0) + { + // We know how many pixels we need to move, but how fast? + speed = DistanceBetween(gameObject.x, gameObject.y, x, y) / (maxTime / 1000); + } + + gameObject.body.velocity.setToPolar(angle, speed); + + return angle; + }, + + /** + * Move the given display object towards the destination object at a steady velocity. + * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @method Phaser.Physics.Arcade.ArcadePhysics#moveToObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {object} destination - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveToObject: function (gameObject, destination, speed, maxTime) + { + return this.moveTo(gameObject, destination.x, destination.y, speed, maxTime); + }, + + /** + * Given the angle (in degrees) and speed calculate the velocity and return it as a vector, or set it to the given vector object. + * One way to use this is: velocityFromAngle(angle, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromAngle + * @since 3.0.0 + * + * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param {number} [speed=60] - The speed it will move, in pixels per second squared. + * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. + */ + velocityFromAngle: function (angle, speed, vec2) + { + if (speed === undefined) { speed = 60; } + if (vec2 === undefined) { vec2 = new Vector2(); } + + return vec2.setToPolar(DegToRad(angle), speed); + }, + + /** + * Given the rotation (in radians) and speed calculate the velocity and return it as a vector, or set it to the given vector object. + * One way to use this is: velocityFromRotation(rotation, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromRotation + * @since 3.0.0 + * + * @param {number} rotation - The angle in radians. + * @param {number} [speed=60] - The speed it will move, in pixels per second squared + * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. + */ + velocityFromRotation: function (rotation, speed, vec2) + { + if (speed === undefined) { speed = 60; } + if (vec2 === undefined) { vec2 = new Vector2(); } + + return vec2.setToPolar(rotation, speed); + }, + + /** + * 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 () + { + if (!this.world) + { + // Already destroyed + return; + } + + 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.add.destroy(); + this.world.destroy(); + + this.add = null; + this.world = null; + }, + + /** + * 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.scene.sys.events.off('start', this.start, this); + + this.scene = null; + this.systems = null; + } + +}); + +PluginCache.register('ArcadePhysics', ArcadePhysics, 'arcadePhysics'); + +module.exports = ArcadePhysics; + + +/***/ }), +/* 594 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(39); +var Extend = __webpack_require__(21); + +/** + * @callback ArcadePhysicsCallback + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + */ + +/** + * @namespace Phaser.Physics.Arcade + */ + +var Arcade = { + + ArcadePhysics: __webpack_require__(593), + Body: __webpack_require__(260), + Collider: __webpack_require__(259), + Factory: __webpack_require__(266), + Group: __webpack_require__(263), + Image: __webpack_require__(265), + Sprite: __webpack_require__(114), + StaticBody: __webpack_require__(253), + StaticGroup: __webpack_require__(262), + World: __webpack_require__(261) + +}; + +// Merge in the consts +Arcade = Extend(false, Arcade, CONST); + +module.exports = Arcade; + + +/***/ }), +/* 595 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics + */ + +module.exports = { + + Arcade: __webpack_require__(594), + Impact: __webpack_require__(572), + Matter: __webpack_require__(552) + +}; + + +/***/ }), +/* 596 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector3 = __webpack_require__(154); +var Matrix4 = __webpack_require__(268); +var Quaternion = __webpack_require__(267); + +var tmpMat4 = new Matrix4(); +var tmpQuat = new Quaternion(); +var tmpVec3 = new Vector3(); + +/** + * Rotates a vector in place by axis angle. + * + * This is the same as transforming a point by an + * axis-angle quaternion, but it has higher precision. + * + * @function Phaser.Math.RotateVec3 + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec - The vector to be rotated. + * @param {Phaser.Math.Vector3} axis - The axis to rotate around. + * @param {number} radians - The angle of rotation in radians. + * + * @return {Phaser.Math.Vector3} The given vector. + */ +var RotateVec3 = function (vec, axis, radians) +{ + // Set the quaternion to our axis angle + tmpQuat.setAxisAngle(axis, radians); + + // Create a rotation matrix from the axis angle + tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); + + // Multiply our vector by the rotation matrix + return vec.transformMat4(tmpMat4); +}; + +module.exports = RotateVec3; + + +/***/ }), +/* 597 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A representation of a vector in 4D space. + * + * A four-component vector. + * + * @class Vector4 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + * @param {number} [w] - The w component. + */ +var Vector4 = new Class({ + + initialize: + + function Vector4 (x, y, z, w) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector4#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector4#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector4#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.z = 0; + + /** + * The w component of this Vector. + * + * @name Phaser.Math.Vector4#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.w = 0; + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * Make a clone of this Vector4. + * + * @method Phaser.Math.Vector4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} A clone of this Vector4. + */ + clone: function () + { + return new Vector4(this.x, this.y, this.z, this.w); + }, + + /** + * Copy the components of a given Vector into this Vector. + * + * @method Phaser.Math.Vector4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + this.w = src.w || 0; + + return this; + }, + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict quality check against each Vector's components. + * + * @method Phaser.Math.Vector4#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - The vector to check equality with. + * + * @return {boolean} A boolean indicating whether the two Vectors are equal or not. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); + }, + + /** + * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. + * + * @method Phaser.Math.Vector4#set + * @since 3.0.0 + * + * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y, z and w components. + * @param {number} y - The y value to set for this Vector. + * @param {number} z - The z value to set for this Vector. + * @param {number} w - The z value to set for this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector4#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + this.w += v.w || 0; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector4#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + this.w -= v.w || 0; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector4#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector4#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector4#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector4#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector4#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - The Vector4 to dot product with this Vector4. + * + * @return {number} The dot product of this Vector and the given Vector. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector4#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - The Vector4 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector4#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + this.w *= v.w || 1; + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector4#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + this.w /= v.w || 1; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector4#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector4#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return dx * dx + dy * dy + dz * dz + dw * dw; + }, + + /** + * Negate the `x`, `y`, `z` and `w` components of this Vector. + * + * @method Phaser.Math.Vector4#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector4#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector4 with. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + + return this; + }, + + /** + * Transform this Vector with the given Quaternion. + * + * @method Phaser.Math.Vector4#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + transformQuat: function (q) + { + // TODO: is this really the same as Vector3? + // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Make this Vector the zero vector (0, 0, 0, 0). + * + * @method Phaser.Math.Vector4#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 0; + + return this; + } + +}); + +// TODO: Check if these are required internally, if not, remove. +Vector4.prototype.sub = Vector4.prototype.subtract; +Vector4.prototype.mul = Vector4.prototype.multiply; +Vector4.prototype.div = Vector4.prototype.divide; +Vector4.prototype.dist = Vector4.prototype.distance; +Vector4.prototype.distSq = Vector4.prototype.distanceSq; +Vector4.prototype.len = Vector4.prototype.length; +Vector4.prototype.lenSq = Vector4.prototype.lengthSq; + +module.exports = Vector4; + + +/***/ }), +/* 598 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks if the two values are within the given `tolerance` of each other. + * + * @function Phaser.Math.Within + * @since 3.0.0 + * + * @param {number} a - The first value to use in the calculation. + * @param {number} b - The second value to use in the calculation. + * @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range. + * + * @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`. + */ +var Within = function (a, b, tolerance) +{ + return (Math.abs(a - b) <= tolerance); +}; + +module.exports = Within; + + +/***/ }), +/* 599 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} SinCosTable + * + * @property {number} sin - The sine value. + * @property {number} cos - The cosine value. + * @property {number} length - The length. + */ + +/** + * Generate a series of sine and cosine values. + * + * @function Phaser.Math.SinCosTableGenerator + * @since 3.0.0 + * + * @param {number} length - The number of values to generate. + * @param {number} [sinAmp=1] - The sine value amplitude. + * @param {number} [cosAmp=1] - The cosine value amplitude. + * @param {number} [frequency=1] - The frequency of the values. + * + * @return {SinCosTable} The generated values. + */ +var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency) +{ + if (sinAmp === undefined) { sinAmp = 1; } + if (cosAmp === undefined) { cosAmp = 1; } + if (frequency === undefined) { frequency = 1; } + + frequency *= Math.PI / length; + + var cos = []; + var sin = []; + + for (var c = 0; c < length; c++) + { + cosAmp -= sinAmp * frequency; + sinAmp += cosAmp * frequency; + + cos[c] = cosAmp; + sin[c] = sinAmp; + } + + return { + sin: sin, + cos: cos, + length: length + }; +}; + +module.exports = SinCosTableGenerator; + + +/***/ }), +/* 600 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Round a value to a given decimal place. + * + * @function Phaser.Math.RoundTo + * @since 3.0.0 + * + * @param {number} value - The value to round. + * @param {integer} [place=0] - The place to round to. + * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. + * + * @return {number} The rounded value. + */ +var RoundTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.round(value * p) / p; +}; + +module.exports = RoundTo; + + +/***/ }), +/* 601 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random four-dimensional vector. + * + * @function Phaser.Math.RandomXYZW + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} vec4 - The Vector to compute random values for. + * @param {number} [scale=1] - The scale of the random values. + * + * @return {Phaser.Math.Vector4} The given Vector. + */ +var RandomXYZW = function (vec4, scale) +{ + if (scale === undefined) { scale = 1; } + + // TODO: Not spherical; should fix this for more uniform distribution + vec4.x = (Math.random() * 2 - 1) * scale; + vec4.y = (Math.random() * 2 - 1) * scale; + vec4.z = (Math.random() * 2 - 1) * scale; + vec4.w = (Math.random() * 2 - 1) * scale; + + return vec4; +}; + +module.exports = RandomXYZW; + + +/***/ }), +/* 602 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random position vector in a spherical area, optionally defined by the given radius. + * + * @function Phaser.Math.RandomXYZ + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec3 - The Vector to compute random values for. + * @param {number} [radius=1] - The radius. + * + * @return {Phaser.Math.Vector3} The given Vector. + */ +var RandomXYZ = function (vec3, radius) +{ + if (radius === undefined) { radius = 1; } + + var r = Math.random() * 2 * Math.PI; + var z = (Math.random() * 2) - 1; + var zScale = Math.sqrt(1 - z * z) * radius; + + vec3.x = Math.cos(r) * zScale; + vec3.y = Math.sin(r) * zScale; + vec3.z = z * radius; + + return vec3; +}; + +module.exports = RandomXYZ; + + +/***/ }), +/* 603 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random unit vector. + * + * Computes random values for the given vector between -1 and 1 that can be used to represent a direction. + * + * Optionally accepts a scale value to scale the resulting vector by. + * + * @function Phaser.Math.RandomXY + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} vector - The Vector to compute random values for. + * @param {number} [scale=1] - The scale of the random values. + * + * @return {Phaser.Math.Vector2} The given Vector. + */ +var RandomXY = function (vector, scale) +{ + if (scale === undefined) { scale = 1; } + + var r = Math.random() * 2 * Math.PI; + + vector.x = Math.cos(r) * scale; + vector.y = Math.sin(r) * scale; + + return vector; +}; + +module.exports = RandomXY; + + +/***/ }), +/* 604 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Work out what percentage `value` is of the range between `min` and `max`. + * If `max` isn't given then it will return the percentage of `value` to `min`. + * + * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. + * + * @function Phaser.Math.Percent + * @since 3.0.0 + * + * @param {number} value - The value to determine the percentage of. + * @param {number} min - The minimum value. + * @param {number} [max] - The maximum value. + * @param {number} [upperMax] - The mid-way point in the range that represents 100%. + * + * @return {number} A value between 0 and 1 representing the percentage. + */ +var Percent = function (value, min, max, upperMax) +{ + if (max === undefined) { max = min + 1; } + + var percentage = (value - min) / (max - min); + + if (percentage > 1) + { + if (upperMax !== undefined) + { + percentage = ((upperMax - value)) / (upperMax - max); + + if (percentage < 0) + { + percentage = 0; + } + } + else + { + percentage = 1; + } + } + else if (percentage < 0) + { + percentage = 0; + } + + return percentage; +}; + +module.exports = Percent; + + +/***/ }), +/* 605 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Subtract an `amount` from `value`, limiting the minimum result to `min`. + * + * @function Phaser.Math.MinSub + * @since 3.0.0 + * + * @param {number} value - The value to subtract from. + * @param {number} amount - The amount to subtract. + * @param {number} min - The minimum value to return. + * + * @return {number} The resulting value. + */ +var MinSub = function (value, amount, min) +{ + return Math.max(value - amount, min); +}; + +module.exports = MinSub; + + +/***/ }), +/* 606 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Add an `amount` to a `value`, limiting the maximum result to `max`. + * + * @function Phaser.Math.MaxAdd + * @since 3.0.0 + * + * @param {number} value - The value to add to. + * @param {number} amount - The amount to add. + * @param {number} max - The maximum value to return. + * + * @return {number} The resulting value. + */ +var MaxAdd = function (value, amount, max) +{ + return Math.min(value + amount, max); +}; + +module.exports = MaxAdd; + + +/***/ }), +/* 607 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check if a given value is an even number using a strict type check. + * + * @function Phaser.Math.IsEvenStrict + * @since 3.0.0 + * + * @param {number} value - The number to perform the check with. + * + * @return {boolean} Whether the number is even or not. + */ +var IsEvenStrict = function (value) +{ + // Use strict equality === for "is number" test + return (value === parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEvenStrict; + + +/***/ }), +/* 608 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check if a given value is an even number. + * + * @function Phaser.Math.IsEven + * @since 3.0.0 + * + * @param {number} value - The number to perform the check with. + * + * @return {boolean} Whether the number is even or not. + */ +var IsEven = function (value) +{ + // Use abstract equality == for "is number" test + + // eslint-disable-next-line eqeqeq + return (value == parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEven; + + +/***/ }), +/* 609 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the speed required to cover a distance in the time given. + * + * @function Phaser.Math.GetSpeed + * @since 3.0.0 + * + * @param {number} distance - The distance to travel in pixels. + * @param {integer} time - The time, in ms, to cover the distance in. + * + * @return {number} The amount you will need to increment the position by each step in order to cover the distance in the time given. + */ +var GetSpeed = function (distance, time) +{ + return (distance / time) / 1000; +}; + +module.exports = GetSpeed; + + +/***/ }), +/* 610 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Floors to some place comparative to a `base`, default is 10 for decimal place. + * + * The `place` is represented by the power applied to `base` to get that place. + * + * @function Phaser.Math.FloorTo + * @since 3.0.0 + * + * @param {number} value - The value to round. + * @param {integer} [place=0] - The place to round to. + * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. + * + * @return {number} The rounded value. + */ +var FloorTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.floor(value * p) / p; +}; + +module.exports = FloorTo; + + +/***/ }), +/* 611 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the positive difference of two given numbers. + * + * @function Phaser.Math.Difference + * @since 3.0.0 + * + * @param {number} a - The first number in the calculation. + * @param {number} b - The second number in the calculation. + * + * @return {number} The positive difference of the two given numbers. + */ +var Difference = function (a, b) +{ + return Math.abs(a - b); +}; + +module.exports = Difference; + + +/***/ }), +/* 612 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Ceils to some place comparative to a `base`, default is 10 for decimal place. + * + * The `place` is represented by the power applied to `base` to get that place. + * + * @function Phaser.Math.CeilTo + * @since 3.0.0 + * + * @param {number} value - The value to round. + * @param {number} [place=0] - The place to round to. + * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. + * + * @return {number} The rounded value. + */ +var CeilTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.ceil(value * p) / p; +}; + +module.exports = CeilTo; + + +/***/ }), +/* 613 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the mean average of the given values. + * + * @function Phaser.Math.Average + * @since 3.0.0 + * + * @param {number[]} values - The values to average. + * + * @return {number} The average value. + */ +var Average = function (values) +{ + var sum = 0; + + for (var i = 0; i < values.length; i++) + { + sum += (+values[i]); + } + + return sum / values.length; +}; + +module.exports = Average; + + +/***/ }), +/* 614 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Snap a value to nearest grid slice, using rounding. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10` whereas `14` will snap to `15`. + * + * @function Phaser.Math.Snap.To + * @since 3.0.0 + * + * @param {number} value - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. + * + * @return {number} The snapped value. + */ +var SnapTo = function (value, gap, start, divide) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.round(value / gap); + + return (divide) ? (start + value) / gap : start + value; +}; + +module.exports = SnapTo; + + +/***/ }), +/* 615 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Snap + */ + +module.exports = { + + Ceil: __webpack_require__(271), + Floor: __webpack_require__(158), + To: __webpack_require__(614) + +}; + + +/***/ }), +/* 616 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Tests the value and returns `true` if it is a power of two. + * + * @function Phaser.Math.Pow2.IsValuePowerOfTwo + * @since 3.0.0 + * + * @param {number} value - The value to check if it's a power of two. + * + * @return {boolean} Returns `true` if `value` is a power of two, otherwise `false`. + */ +var IsValuePowerOfTwo = function (value) +{ + return (value > 0 && (value & (value - 1)) === 0); +}; + +module.exports = IsValuePowerOfTwo; + + +/***/ }), +/* 617 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Pow2 + */ + +module.exports = { + + GetNext: __webpack_require__(322), + IsSize: __webpack_require__(127), + IsValue: __webpack_require__(616) + +}; + + +/***/ }), +/* 618 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SmootherStep = __webpack_require__(200); + +/** + * A Smoother Step interpolation method. + * + * @function Phaser.Math.Interpolation.SmootherStep + * @since 3.9.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The interpolated value. + */ +var SmootherStepInterpolation = function (t, min, max) +{ + return min + (max - min) * SmootherStep(t, 0, 1); +}; + +module.exports = SmootherStepInterpolation; + + +/***/ }), +/* 619 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Linear = __webpack_require__(129); + +/** + * A linear interpolation method. + * + * @function Phaser.Math.Interpolation.Linear + * @since 3.0.0 + * @see {@link https://en.wikipedia.org/wiki/Linear_interpolation} + * + * @param {number[]} v - The input array of values to interpolate between. + * @param {!number} k - The percentage of interpolation, between 0 and 1. + * + * @return {!number} The interpolated value. + */ +var LinearInterpolation = function (v, k) +{ + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + + if (k < 0) + { + return Linear(v[0], v[1], f); + } + + if (k > 1) + { + return Linear(v[m], v[m - 1], m - f); + } + + return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); +}; + +module.exports = LinearInterpolation; + + +/***/ }), +/* 620 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CatmullRom = __webpack_require__(189); + +/** + * A Catmull-Rom interpolation method. + * + * @function Phaser.Math.Interpolation.CatmullRom + * @since 3.0.0 + * + * @param {number[]} v - The input array of values to interpolate between. + * @param {number} k - The percentage of interpolation, between 0 and 1. + * + * @return {number} The interpolated value. + */ +var CatmullRomInterpolation = function (v, k) +{ + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + + if (v[0] === v[m]) + { + if (k < 0) + { + i = Math.floor(f = m * (1 + k)); + } + + return CatmullRom(f - i, v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m]); + } + else + { + if (k < 0) + { + return v[0] - (CatmullRom(-f, v[0], v[0], v[1], v[1]) - v[0]); + } + + if (k > 1) + { + return v[m] - (CatmullRom(f - m, v[m], v[m], v[m - 1], v[m - 1]) - v[m]); + } + + return CatmullRom(f - i, v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2]); + } +}; + +module.exports = CatmullRomInterpolation; + + +/***/ }), +/* 621 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bernstein = __webpack_require__(273); + +/** + * A bezier interpolation method. + * + * @function Phaser.Math.Interpolation.Bezier + * @since 3.0.0 + * + * @param {number[]} v - The input array of values to interpolate between. + * @param {number} k - The percentage of interpolation, between 0 and 1. + * + * @return {number} The interpolated value. + */ +var BezierInterpolation = function (v, k) +{ + var b = 0; + var n = v.length - 1; + + for (var i = 0; i <= n; i++) + { + b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * Bernstein(n, i); + } + + return b; +}; + +module.exports = BezierInterpolation; + + +/***/ }), +/* 622 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Interpolation + */ + +module.exports = { + + Bezier: __webpack_require__(621), + CatmullRom: __webpack_require__(620), + CubicBezier: __webpack_require__(390), + Linear: __webpack_require__(619), + QuadraticBezier: __webpack_require__(386), + SmoothStep: __webpack_require__(363), + SmootherStep: __webpack_require__(618) + +}; + + +/***/ }), +/* 623 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the fuzzy floor of the given value. + * + * @function Phaser.Math.Fuzzy.Floor + * @since 3.0.0 + * + * @param {number} value - The value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {number} The floor of the value. + */ +var Floor = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.floor(value + epsilon); +}; + +module.exports = Floor; + + +/***/ }), +/* 624 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the fuzzy ceiling of the given value. + * + * @function Phaser.Math.Fuzzy.Ceil + * @since 3.0.0 + * + * @param {number} value - The value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {number} The fuzzy ceiling of the value. + */ +var Ceil = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.ceil(value - epsilon); +}; + +module.exports = Ceil; + + +/***/ }), +/* 625 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Fuzzy + */ + +module.exports = { + + Ceil: __webpack_require__(624), + Equal: __webpack_require__(276), + Floor: __webpack_require__(623), + GreaterThan: __webpack_require__(275), + LessThan: __webpack_require__(274) + +}; + + +/***/ }), +/* 626 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing + */ + +module.exports = { + + Back: __webpack_require__(405), + Bounce: __webpack_require__(404), + Circular: __webpack_require__(403), + Cubic: __webpack_require__(402), + Elastic: __webpack_require__(401), + Expo: __webpack_require__(400), + Linear: __webpack_require__(399), + Quadratic: __webpack_require__(398), + Quartic: __webpack_require__(397), + Quintic: __webpack_require__(396), + Sine: __webpack_require__(395), + Stepped: __webpack_require__(394) + +}; + + +/***/ }), +/* 627 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the distance between two sets of coordinates (points) to the power of `pow`. + * + * @function Phaser.Math.Distance.Power + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * @param {number} pow - The exponent. + * + * @return {number} The distance between each point. + */ +var DistancePower = function (x1, y1, x2, y2, pow) +{ + if (pow === undefined) { pow = 2; } + + return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow)); +}; + +module.exports = DistancePower; + + +/***/ }), +/* 628 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Distance + */ + +module.exports = { + + Between: __webpack_require__(58), + Power: __webpack_require__(627), + Squared: __webpack_require__(277) + +}; + + +/***/ }), +/* 629 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Gets the shortest angle between `angle1` and `angle2`. + * + * Both angles must be in the range -180 to 180, which is the same clamped + * range that `sprite.angle` uses, so you can pass in two sprite angles to + * this method and get the shortest angle back between the two of them. + * + * The angle returned will be in the same range. If the returned angle is + * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's + * a clockwise rotation. + * + * TODO: Wrap the angles in this function? + * + * @function Phaser.Math.Angle.ShortestBetween + * @since 3.0.0 + * + * @param {number} angle1 - The first angle in the range -180 to 180. + * @param {number} angle2 - The second angle in the range -180 to 180. + * + * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. + */ +var ShortestBetween = function (angle1, angle2) +{ + var difference = angle2 - angle1; + + if (difference === 0) + { + return 0; + } + + var times = Math.floor((difference - (-180)) / 360); + + return difference - (times * 360); + +}; + +module.exports = ShortestBetween; + + +/***/ }), +/* 630 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(18); + +/** + * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. + * + * @function Phaser.Math.Angle.RotateTo + * @since 3.0.0 + * + * @param {number} currentAngle - The current angle, in radians. + * @param {number} targetAngle - The target angle to rotate to, in radians. + * @param {number} [lerp=0.05] - The lerp value to add to the current angle. + * + * @return {number} The adjusted angle. + */ +var RotateTo = function (currentAngle, targetAngle, lerp) +{ + if (lerp === undefined) { lerp = 0.05; } + + if (currentAngle === targetAngle) + { + return currentAngle; + } + + if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp)) + { + currentAngle = targetAngle; + } + else + { + if (Math.abs(targetAngle - currentAngle) > Math.PI) + { + if (targetAngle < currentAngle) + { + targetAngle += MATH_CONST.PI2; + } + else + { + targetAngle -= MATH_CONST.PI2; + } + } + + if (targetAngle > currentAngle) + { + currentAngle += lerp; + } + else if (targetAngle < currentAngle) + { + currentAngle -= lerp; + } + } + + return currentAngle; +}; + +module.exports = RotateTo; + + +/***/ }), +/* 631 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Normalize = __webpack_require__(278); + +/** + * Reverse the given angle. + * + * @function Phaser.Math.Angle.Reverse + * @since 3.0.0 + * + * @param {number} angle - The angle to reverse, in radians. + * + * @return {number} The reversed angle, in radians. + */ +var Reverse = function (angle) +{ + return Normalize(angle + Math.PI); +}; + +module.exports = Reverse; + + +/***/ }), +/* 632 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * The difference between this method and {@link Phaser.Math.Angle.BetweenPoints} is that this assumes the y coordinate + * travels down the screen. + * + * @function Phaser.Math.Angle.BetweenPointsY + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - The first point. + * @param {(Phaser.Geom.Point|object)} point2 - The second point. + * + * @return {number} The angle in radians. + */ +var BetweenPointsY = function (point1, point2) +{ + return Math.atan2(point2.x - point1.x, point2.y - point1.y); +}; + +module.exports = BetweenPointsY; + + +/***/ }), +/* 633 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * Calculates the angle of the vector from the first point to the second point. + * + * @function Phaser.Math.Angle.BetweenPoints + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - The first point. + * @param {(Phaser.Geom.Point|object)} point2 - The second point. + * + * @return {number} The angle in radians. + */ +var BetweenPoints = function (point1, point2) +{ + return Math.atan2(point2.y - point1.y, point2.x - point1.x); +}; + +module.exports = BetweenPoints; + + +/***/ }), +/* 634 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * + * The difference between this method and {@link Phaser.Math.Angle.Between} is that this assumes the y coordinate + * travels down the screen. + * + * @function Phaser.Math.Angle.BetweenY + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The angle in radians. + */ +var BetweenY = function (x1, y1, x2, y2) +{ + return Math.atan2(x2 - x1, y2 - y1); +}; + +module.exports = BetweenY; + + +/***/ }), +/* 635 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * + * @function Phaser.Math.Angle.Between + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The angle in radians. + */ +var Between = function (x1, y1, x2, y2) +{ + return Math.atan2(y2 - y1, x2 - x1); +}; + +module.exports = Between; + + +/***/ }), +/* 636 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Angle + */ + +module.exports = { + + Between: __webpack_require__(635), + BetweenY: __webpack_require__(634), + BetweenPoints: __webpack_require__(633), + BetweenPointsY: __webpack_require__(632), + Reverse: __webpack_require__(631), + RotateTo: __webpack_require__(630), + ShortestBetween: __webpack_require__(629), + Normalize: __webpack_require__(278), + Wrap: __webpack_require__(205), + WrapDegrees: __webpack_require__(204) + +}; + + +/***/ }), +/* 637 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(18); +var Extend = __webpack_require__(21); + +/** + * @namespace Phaser.Math + */ + +var PhaserMath = { + + // Collections of functions + Angle: __webpack_require__(636), + Distance: __webpack_require__(628), + Easing: __webpack_require__(626), + Fuzzy: __webpack_require__(625), + Interpolation: __webpack_require__(622), + Pow2: __webpack_require__(617), + Snap: __webpack_require__(615), + + // Expose the RNG Class + RandomDataGenerator: __webpack_require__(441), + + // Single functions + Average: __webpack_require__(613), + Bernstein: __webpack_require__(273), + Between: __webpack_require__(188), + CatmullRom: __webpack_require__(189), + CeilTo: __webpack_require__(612), + Clamp: __webpack_require__(24), + DegToRad: __webpack_require__(36), + Difference: __webpack_require__(611), + Factorial: __webpack_require__(272), + FloatBetween: __webpack_require__(327), + FloorTo: __webpack_require__(610), + FromPercent: __webpack_require__(103), + GetSpeed: __webpack_require__(609), + IsEven: __webpack_require__(608), + IsEvenStrict: __webpack_require__(607), + Linear: __webpack_require__(129), + MaxAdd: __webpack_require__(606), + MinSub: __webpack_require__(605), + Percent: __webpack_require__(604), + RadToDeg: __webpack_require__(190), + RandomXY: __webpack_require__(603), + RandomXYZ: __webpack_require__(602), + RandomXYZW: __webpack_require__(601), + Rotate: __webpack_require__(270), + RotateAround: __webpack_require__(432), + RotateAroundDistance: __webpack_require__(201), + RoundAwayFromZero: __webpack_require__(342), + RoundTo: __webpack_require__(600), + SinCosTableGenerator: __webpack_require__(599), + SmootherStep: __webpack_require__(200), + SmoothStep: __webpack_require__(199), + TransformXY: __webpack_require__(361), + Within: __webpack_require__(598), + Wrap: __webpack_require__(59), + + // Vector classes + Vector2: __webpack_require__(3), + Vector3: __webpack_require__(154), + Vector4: __webpack_require__(597), + Matrix3: __webpack_require__(269), + Matrix4: __webpack_require__(268), + Quaternion: __webpack_require__(267), + RotateVec3: __webpack_require__(596) + +}; + +// Merge in the consts + +PhaserMath = Extend(false, PhaserMath, CONST); + +// Export it + +module.exports = PhaserMath; + + +/***/ }), +/* 638 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var CustomSet = __webpack_require__(96); +var EventEmitter = __webpack_require__(11); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var PluginCache = __webpack_require__(15); +var XHRSettings = __webpack_require__(115); + +/** + * @classdesc + * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. + * You typically interact with it via `this.load` in your Scene. Scenes can have a `preload` method, which is always + * called before the Scenes `create` method, allowing you to preload assets that the Scene may need. + * + * If you call any `this.load` methods from outside of `Scene.preload` then you need to start the Loader going + * yourself by calling `Loader.start()`. It's only automatically started during the Scene preload. + * + * The Loader uses a combination of tag loading (eg. Audio elements) and XHR and provides progress and completion events. + * Files are loaded in parallel by default. The amount of concurrent connections can be controlled in your Game Configuration. + * + * Once the Loader has started loading you are still able to add files to it. These can be injected as a result of a loader + * event, the type of file being loaded (such as a pack file) or other external events. As long as the Loader hasn't finished + * simply adding a new file to it, while running, will ensure it's added into the current queue. + * + * Every Scene has its own instance of the Loader and they are bound to the Scene in which they are created. However, + * assets loaded by the Loader are placed into global game-level caches. For example, loading an XML file will place that + * file inside `Game.cache.xml`, which is accessible from every Scene in your game, no matter who was responsible + * for loading it. The same is true of Textures. A texture loaded in one Scene is instantly available to all other Scenes + * in your game. + * + * The Loader works by using custom File Types. These are stored in the FileTypesManager, which injects them into the Loader + * when it's instantiated. You can create your own custom file types by extending either the File or MultiFile classes. + * See those files for more details. + * + * @class LoaderPlugin + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Loader + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene which owns this Loader instance. + */ +var LoaderPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function LoaderPlugin (scene) + { + EventEmitter.call(this); + + var gameConfig = scene.sys.game.config; + var sceneConfig = scene.sys.settings.loader; + + /** + * The Scene which owns this Loader instance. + * + * @name Phaser.Loader.LoaderPlugin#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene Systems. + * + * @name Phaser.Loader.LoaderPlugin#systems + * @type {Phaser.Scenes.Systems} + * @protected + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the global Cache Manager. + * + * @name Phaser.Loader.LoaderPlugin#cacheManager + * @type {Phaser.Cache.CacheManager} + * @protected + * @since 3.7.0 + */ + this.cacheManager = scene.sys.cache; + + /** + * A reference to the global Texture Manager. + * + * @name Phaser.Loader.LoaderPlugin#textureManager + * @type {Phaser.Textures.TextureManager} + * @protected + * @since 3.7.0 + */ + this.textureManager = scene.sys.textures; + + // Inject the available filetypes into the Loader + FileTypesManager.install(this); + + /** + * An optional prefix that is automatically prepended to the start of every file key. + * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. + * You can set this directly, or call `Loader.setPrefix()`. It will then affect every file added to the Loader + * from that point on. It does _not_ change any file already in the load queue. + * + * @name Phaser.Loader.LoaderPlugin#prefix + * @type {string} + * @default '' + * @since 3.7.0 + */ + this.prefix = ''; + + /** + * The value of `path`, if set, is placed before any _relative_ file path given. For example: + * + * ```javascript + * this.load.path = "images/sprites/"; + * this.load.image("ball", "ball.png"); + * this.load.image("tree", "level1/oaktree.png"); + * this.load.image("boom", "http://server.com/explode.png"); + * ``` + * + * Would load the `ball` file from `images/sprites/ball.png` and the tree from + * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL + * given as it's an absolute URL. + * + * Please note that the path is added before the filename but *after* the baseURL (if set.) + * + * If you set this property directly then it _must_ end with a "/". Alternatively, call `setPath()` and it'll do it for you. + * + * @name Phaser.Loader.LoaderPlugin#path + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.path = ''; + + /** + * If you want to append a URL before the path of any asset you can set this here. + * + * Useful if allowing the asset base url to be configured outside of the game code. + * + * If you set this property directly then it _must_ end with a "/". Alternatively, call `setBaseURL()` and it'll do it for you. + * + * @name Phaser.Loader.LoaderPlugin#baseURL + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.baseURL = ''; + + this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); + + this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); + + this.setPrefix(GetFastValue(sceneConfig, 'prefix', gameConfig.loaderPrefix)); + + /** + * The number of concurrent / parallel resources to try and fetch at once. + * + * Old browsers limit 6 requests per domain; modern ones, especially those with HTTP/2 don't limit it at all. + * + * The default is 32 but you can change this in your Game Config, or by changing this property before the Loader starts. + * + * @name Phaser.Loader.LoaderPlugin#maxParallelDownloads + * @type {integer} + * @since 3.0.0 + */ + this.maxParallelDownloads = GetFastValue(sceneConfig, 'maxParallelDownloads', gameConfig.loaderMaxParallelDownloads); + + /** + * xhr specific global settings (can be overridden on a per-file basis) + * + * @name Phaser.Loader.LoaderPlugin#xhr + * @type {XHRSettingsObject} + * @since 3.0.0 + */ + this.xhr = XHRSettings( + GetFastValue(sceneConfig, 'responseType', gameConfig.loaderResponseType), + GetFastValue(sceneConfig, 'async', gameConfig.loaderAsync), + GetFastValue(sceneConfig, 'user', gameConfig.loaderUser), + GetFastValue(sceneConfig, 'password', gameConfig.loaderPassword), + GetFastValue(sceneConfig, 'timeout', gameConfig.loaderTimeout) + ); + + /** + * The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'. + * + * @name Phaser.Loader.LoaderPlugin#crossOrigin + * @type {string} + * @since 3.0.0 + */ + this.crossOrigin = GetFastValue(sceneConfig, 'crossOrigin', gameConfig.loaderCrossOrigin); + + /** + * The total number of files to load. It may not always be accurate because you may add to the Loader during the process + * of loading, especially if you load a Pack File. Therefore this value can change, but in most cases remains static. + * + * @name Phaser.Loader.LoaderPlugin#totalToLoad + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.totalToLoad = 0; + + /** + * The progress of the current load queue, as a float value between 0 and 1. + * This is updated automatically as files complete loading. + * Note that it is possible for this value to go down again if you add content to the current load queue during a load. + * + * @name Phaser.Loader.LoaderPlugin#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Files are placed in this Set when they're added to the Loader via `addFile`. + * + * They are moved to the `inflight` Set when they start loading, and assuming a successful + * load, to the `queue` Set for further processing. + * + * By the end of the load process this Set will be empty. + * + * @name Phaser.Loader.LoaderPlugin#list + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.list = new CustomSet(); + + /** + * Files are stored in this Set while they're in the process of being loaded. + * + * Upon a successful load they are moved to the `queue` Set. + * + * By the end of the load process this Set will be empty. + * + * @name Phaser.Loader.LoaderPlugin#inflight + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.inflight = new CustomSet(); + + /** + * Files are stored in this Set while they're being processed. + * + * If the process is successful they are moved to their final destination, which could be + * a Cache or the Texture Manager. + * + * At the end of the load process this Set will be empty. + * + * @name Phaser.Loader.LoaderPlugin#queue + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.queue = new CustomSet(); + + /** + * A temporary Set in which files are stored after processing, + * awaiting destruction at the end of the load process. + * + * @name Phaser.Loader.LoaderPlugin#_deleteQueue + * @type {Phaser.Structs.Set.} + * @private + * @since 3.7.0 + */ + this._deleteQueue = new CustomSet(); + + /** + * The total number of files that failed to load during the most recent load. + * This value is reset when you call `Loader.start`. + * + * @name Phaser.Loader.LoaderPlugin#totalFailed + * @type {integer} + * @default 0 + * @since 3.7.0 + */ + this.totalFailed = 0; + + /** + * The total number of files that successfully loaded during the most recent load. + * This value is reset when you call `Loader.start`. + * + * @name Phaser.Loader.LoaderPlugin#totalComplete + * @type {integer} + * @default 0 + * @since 3.7.0 + */ + this.totalComplete = 0; + + /** + * The current state of the Loader. + * + * @name Phaser.Loader.LoaderPlugin#state + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.state = CONST.LOADER_IDLE; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.pluginStart, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Loader.LoaderPlugin#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.systems.events.once('destroy', this.destroy, 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.Loader.LoaderPlugin#pluginStart + * @private + * @since 3.5.1 + */ + pluginStart: function () + { + this.systems.events.once('shutdown', this.shutdown, this); + }, + + /** + * If you want to append a URL before the path of any asset you can set this here. + * + * Useful if allowing the asset base url to be configured outside of the game code. + * + * Once a base URL is set it will affect every file loaded by the Loader from that point on. It does _not_ change any + * file _already_ being loaded. To reset it, call this method with no arguments. + * + * @method Phaser.Loader.LoaderPlugin#setBaseURL + * @since 3.0.0 + * + * @param {string} [url] - The URL to use. Leave empty to reset. + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setBaseURL: function (url) + { + if (url === undefined) { url = ''; } + + if (url !== '' && url.substr(-1) !== '/') + { + url = url.concat('/'); + } + + this.baseURL = url; + + return this; + }, + + /** + * The value of `path`, if set, is placed before any _relative_ file path given. For example: + * + * ```javascript + * this.load.setPath("images/sprites/"); + * this.load.image("ball", "ball.png"); + * this.load.image("tree", "level1/oaktree.png"); + * this.load.image("boom", "http://server.com/explode.png"); + * ``` + * + * Would load the `ball` file from `images/sprites/ball.png` and the tree from + * `images/sprites/level1/oaktree.png` but the file `boom` would load from the URL + * given as it's an absolute URL. + * + * Please note that the path is added before the filename but *after* the baseURL (if set.) + * + * Once a path is set it will then affect every file added to the Loader from that point on. It does _not_ change any + * file _already_ in the load queue. To reset it, call this method with no arguments. + * + * @method Phaser.Loader.LoaderPlugin#setPath + * @since 3.0.0 + * + * @param {string} [path] - The path to use. Leave empty to reset. + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setPath: function (path) + { + if (path === undefined) { path = ''; } + + if (path !== '' && path.substr(-1) !== '/') + { + path = path.concat('/'); + } + + this.path = path; + + return this; + }, + + /** + * An optional prefix that is automatically prepended to the start of every file key. + * + * If prefix was `MENU.` and you load an image with the key 'Background' the resulting key would be `MENU.Background`. + * + * Once a prefix is set it will then affect every file added to the Loader from that point on. It does _not_ change any + * file _already_ in the load queue. To reset it, call this method with no arguments. + * + * @method Phaser.Loader.LoaderPlugin#setPrefix + * @since 3.7.0 + * + * @param {string} [prefix] - The prefix to use. Leave empty to reset. + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setPrefix: function (prefix) + { + if (prefix === undefined) { prefix = ''; } + + this.prefix = prefix; + + return this; + }, + + /** + * Sets the Cross Origin Resource Sharing value used when loading files. + * + * Files can override this value on a per-file basis by specifying an alternative `crossOrigin` value in their file config. + * + * Once CORs is set it will then affect every file loaded by the Loader from that point on, as long as they don't have + * their own CORs setting. To reset it, call this method with no arguments. + * + * For more details about CORs see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS + * + * @method Phaser.Loader.LoaderPlugin#setCORS + * @since 3.0.0 + * + * @param {string} [crossOrigin] - The value to use for the `crossOrigin` property in the load request. + * + * @return {Phaser.Loader.LoaderPlugin} This Loader object. + */ + setCORS: function (crossOrigin) + { + this.crossOrigin = crossOrigin; + + return this; + }, + + /** + * This event is fired when a Loader successfully begins to load its queue. + * + * @event Phaser.Loader.LoaderPlugin#addFileEvent + * @param {string} key - The key of the file that was added. + * @param {string} type - The type of the file that was added. + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that had the file added to it. + * @param {Phaser.Loader.File} loader - The File object that was added to the Loader. + */ + + /** + * Adds a file, or array of files, into the load queue. + * + * The file must be an instance of `Phaser.Loader.File`, or a class that extends it. The Loader will check that the key + * used by the file won't conflict with any other key either in the loader, the inflight queue or the target cache. + * If allowed it will then add the file into the pending list, read for the load to start. Or, if the load has already + * started, ready for the next batch of files to be pulled from the list to the inflight queue. + * + * You should not normally call this method directly, but rather use one of the Loader methods like `image` or `atlas`, + * however you can call this as long as the file given to it is well formed. + * + * @method Phaser.Loader.LoaderPlugin#addFile + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(Phaser.Loader.File|Phaser.Loader.File[])} file - The file, or array of files, to be added to the load queue. + */ + addFile: function (file) + { + if (!Array.isArray(file)) + { + file = [ file ]; + } + + for (var i = 0; i < file.length; i++) + { + var item = file[i]; + + // Does the file already exist in the cache or texture manager? + // Or will it conflict with a file already in the queue or inflight? + if (!this.keyExists(item)) + { + this.list.set(item); + + this.emit('addfile', item.key, item.type, this, item); + + if (this.isLoading()) + { + this.totalToLoad++; + this.updateProgress(); + } + } + } + }, + + /** + * Checks the key and type of the given file to see if it will conflict with anything already + * in a Cache, the Texture Manager, or the list or inflight queues. + * + * @method Phaser.Loader.LoaderPlugin#keyExists + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The file to check the key of. + * + * @return {boolean} `true` if adding this file will cause a cache or queue conflict, otherwise `false`. + */ + keyExists: function (file) + { + var keyConflict = file.hasCacheConflict(); + + if (!keyConflict) + { + this.list.iterate(function (item) + { + if (item.type === file.type && item.key === file.key) + { + keyConflict = true; + + return false; + } + + }); + } + + if (!keyConflict && this.isLoading()) + { + this.inflight.iterate(function (item) + { + if (item.type === file.type && item.key === file.key) + { + keyConflict = true; + + return false; + } + + }); + + this.queue.iterate(function (item) + { + if (item.type === file.type && item.key === file.key) + { + keyConflict = true; + + return false; + } + + }); + } + + return keyConflict; + }, + + /** + * Takes a well formed, fully parsed pack file object and adds its entries into the load queue. Usually you do not call + * this method directly, but instead use `Loader.pack` and supply a path to a JSON file that holds the + * pack data. However, if you've got the data prepared you can pass it to this method. + * + * You can also provide an optional key. If you do then it will only add the entries from that part of the pack into + * to the load queue. If not specified it will add all entries it finds. For more details about the pack file format + * see the `LoaderPlugin.pack` method. + * + * @method Phaser.Loader.LoaderPlugin#addPack + * @since 3.7.0 + * + * @param {any} data - The Pack File data to be parsed and each entry of it to added to the load queue. + * @param {string} [packKey] - An optional key to use from the pack file data. + * + * @return {boolean} `true` if any files were added to the queue, otherwise `false`. + */ + addPack: function (pack, packKey) + { + // if no packKey provided we'll add everything to the queue + if (packKey && pack.hasOwnProperty(packKey)) + { + pack = { packKey: pack[packKey] }; + } + + var total = 0; + + // Store the loader settings in case this pack replaces them + var currentBaseURL = this.baseURL; + var currentPath = this.path; + var currentPrefix = this.prefix; + + // Here we go ... + for (var key in pack) + { + var config = pack[key]; + + // Any meta data to process? + var baseURL = GetFastValue(config, 'baseURL', currentBaseURL); + var path = GetFastValue(config, 'path', currentPath); + var prefix = GetFastValue(config, 'prefix', currentPrefix); + var files = GetFastValue(config, 'files', null); + var defaultType = GetFastValue(config, 'defaultType', 'void'); + + if (Array.isArray(files)) + { + this.setBaseURL(baseURL); + this.setPath(path); + this.setPrefix(prefix); + + for (var i = 0; i < files.length; i++) + { + var file = files[i]; + var type = (file.hasOwnProperty('type')) ? file.type : defaultType; + + if (this[type]) + { + this[type](file); + total++; + } + } + } + } + + // Reset the loader settings + this.setBaseURL(currentBaseURL); + this.setPath(currentPath); + this.setPrefix(currentPrefix); + + return (total > 0); + }, + + /** + * Is the Loader actively loading, or processing loaded files? + * + * @method Phaser.Loader.LoaderPlugin#isLoading + * @since 3.0.0 + * + * @return {boolean} `true` if the Loader is busy loading or processing, otherwise `false`. + */ + isLoading: function () + { + return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING); + }, + + /** + * Is the Loader ready to start a new load? + * + * @method Phaser.Loader.LoaderPlugin#isReady + * @since 3.0.0 + * + * @return {boolean} `true` if the Loader is ready to start a new load, otherwise `false`. + */ + isReady: function () + { + return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE); + }, + + /** + * This event is fired when a Loader successfully begins to load its queue. + * + * @event Phaser.Loader.LoaderPlugin#startEvent + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader instance that started. + */ + + /** + * Starts the Loader running. This will reset the progress and totals and then emit a `start` event. + * If there is nothing in the queue the Loader will immediately complete, otherwise it will start + * loading the first batch of files. + * + * The Loader is started automatically if the queue is populated within your Scenes `preload` method. + * + * However, outside of this, you need to call this method to start it. + * + * If the Loader is already running this method will simply return. + * + * @method Phaser.Loader.LoaderPlugin#start + * @fires Phaser.Loader.LoaderPlugin#startEvent + * @since 3.0.0 + */ + start: function () + { + if (!this.isReady()) + { + return; + } + + this.progress = 0; + + this.totalFailed = 0; + this.totalComplete = 0; + this.totalToLoad = this.list.size; + + this.emit('start', this); + + if (this.list.size === 0) + { + this.loadComplete(); + } + else + { + this.state = CONST.LOADER_LOADING; + + this.inflight.clear(); + this.queue.clear(); + + this.updateProgress(); + + this.checkLoadQueue(); + + this.systems.events.on('update', this.update, this); + } + }, + + /** + * This event is fired when the Loader updates its progress, typically as a result of + * a file having completed loading. + * + * @event Phaser.Loader.LoaderPlugin#progressEvent + * @param {number} progress - The current progress of the load. A value between 0 and 1. + */ + + /** + * Called automatically during the load process. + * It updates the `progress` value and then emits a progress event, which you can use to + * display a loading bar in your game. + * + * @method Phaser.Loader.LoaderPlugin#updateProgress + * @fires Phaser.Loader.LoaderPlugin#progressEvent + * @since 3.0.0 + */ + updateProgress: function () + { + this.progress = 1 - ((this.list.size + this.inflight.size) / this.totalToLoad); + + this.emit('progress', this.progress); + }, + + /** + * Called automatically during the load process. + * + * @method Phaser.Loader.LoaderPlugin#update + * @since 3.10.0 + */ + update: function () + { + if (this.state === CONST.LOADER_LOADING && this.list.size > 0 && this.inflight.size < this.maxParallelDownloads) + { + this.checkLoadQueue(); + } + }, + + /** + * An internal method called by the Loader. + * + * It will check to see if there are any more files in the pending list that need loading, and if so it will move + * them from the list Set into the inflight Set, set their CORs flag and start them loading. + * + * It will carrying on doing this for each file in the pending list until it runs out, or hits the max allowed parallel downloads. + * + * @method Phaser.Loader.LoaderPlugin#checkLoadQueue + * @private + * @since 3.7.0 + */ + checkLoadQueue: function () + { + this.list.each(function (file) + { + if (file.state === CONST.FILE_POPULATED || (file.state === CONST.FILE_PENDING && this.inflight.size < this.maxParallelDownloads)) + { + this.inflight.set(file); + + this.list.delete(file); + + // If the file doesn't have its own crossOrigin set, we'll use the Loaders (which is undefined by default) + if (!file.crossOrigin) + { + file.crossOrigin = this.crossOrigin; + } + + file.load(); + } + + if (this.inflight.size === this.maxParallelDownloads) + { + // Tells the Set iterator to abort + return false; + } + + }, this); + }, + + /** + * This event is fired when the a file successfully completes loading, _before_ it is processed. + * + * @event Phaser.Loader.LoaderPlugin#loadEvent + * @param {Phaser.Loader.File} file - The file that has completed loading. + */ + + /** + * This event is fired when the a file errors during load. + * + * @event Phaser.Loader.LoaderPlugin#loadErrorEvent + * @param {Phaser.Loader.File} file - The file that has failed to load. + */ + + /** + * An internal method called automatically by the XHRLoader belong to a File. + * + * This method will remove the given file from the inflight Set and update the load progress. + * If the file was successful its `onProcess` method is called, otherwise it is added to the delete queue. + * + * @method Phaser.Loader.LoaderPlugin#nextFile + * @fires Phaser.Loader.LoaderPlugin#loadEvent + * @fires Phaser.Loader.LoaderPlugin#loadErrorEvent + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File that just finished loading, or errored during load. + * @param {boolean} success - `true` if the file loaded successfully, otherwise `false`. + */ + nextFile: function (file, success) + { + // Has the game been destroyed during load? If so, bail out now. + if (!this.inflight) + { + return; + } + + this.inflight.delete(file); + + this.updateProgress(); + + if (success) + { + this.totalComplete++; + + this.queue.set(file); + + this.emit('load', file); + + file.onProcess(); + } + else + { + this.totalFailed++; + + this._deleteQueue.set(file); + + this.emit('loaderror', file); + + this.fileProcessComplete(file); + } + }, + + /** + * An internal method that is called automatically by the File when it has finished processing. + * + * If the process was successful, and the File isn't part of a MultiFile, its `addToCache` method is called. + * + * It this then removed from the queue. If there are no more files to load `loadComplete` is called. + * + * @method Phaser.Loader.LoaderPlugin#fileProcessComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The file that has finished processing. + */ + fileProcessComplete: function (file) + { + // Has the game been destroyed during load? If so, bail out now. + if (!this.scene || !this.systems || !this.systems.game || this.systems.game.pendingDestroy) + { + return; + } + + // This file has failed, so move it to the failed Set + if (file.state === CONST.FILE_ERRORED) + { + if (file.multiFile) + { + file.multiFile.onFileFailed(file); + } + } + else if (file.state === CONST.FILE_COMPLETE) + { + if (file.multiFile) + { + if (file.multiFile.isReadyToProcess()) + { + // If we got here then all files the link file needs are ready to add to the cache + file.multiFile.addToCache(); + } + } + else + { + // If we got here, then the file processed, so let it add itself to its cache + file.addToCache(); + } + } + + // Remove it from the queue + this.queue.delete(file); + + // Nothing left to do? + + if (this.list.size === 0 && this.inflight.size === 0 && this.queue.size === 0) + { + this.loadComplete(); + } + }, + + /** + * This event is fired when the Loader has finished loading everything and the queue is empty. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * @event Phaser.Loader.LoaderPlugin#completeEvent + * @param {Phaser.Loader.File} file - The file that has failed to load. + */ + + /** + * Called at the end when the load queue is exhausted and all files have either loaded or errored. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * Also clears down the Sets, puts progress to 1 and clears the deletion queue. + * + * @method Phaser.Loader.LoaderPlugin#loadComplete + * @fires Phaser.Loader.LoaderPlugin#completeEvent + * @since 3.7.0 + */ + loadComplete: function () + { + this.emit('loadcomplete', this); + + this.list.clear(); + this.inflight.clear(); + this.queue.clear(); + + this.progress = 1; + + this.state = CONST.LOADER_COMPLETE; + + this.systems.events.off('update', this.update, this); + + // Call 'destroy' on each file ready for deletion + this._deleteQueue.iterateLocal('destroy'); + + this._deleteQueue.clear(); + + this.emit('complete', this, this.totalComplete, this.totalFailed); + }, + + /** + * Adds a File into the pending-deletion queue. + * + * @method Phaser.Loader.LoaderPlugin#flagForRemoval + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File to be queued for deletion when the Loader completes. + */ + flagForRemoval: function (file) + { + this._deleteQueue.set(file); + }, + + /** + * Converts the given JSON data into a file that the browser then prompts you to download so you can save it locally. + * + * The data must be well formed JSON and ready-parsed, not a JavaScript object. + * + * @method Phaser.Loader.LoaderPlugin#saveJSON + * @since 3.0.0 + * + * @param {*} data - The JSON data, ready parsed. + * @param {string} [filename=file.json] - The name to save the JSON file as. + * + * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. + */ + saveJSON: function (data, filename) + { + return this.save(JSON.stringify(data), filename); + }, + + /** + * Causes the browser to save the given data as a file to its default Downloads folder. + * + * Creates a DOM level anchor link, assigns it as being a `download` anchor, sets the href + * to be an ObjectURL based on the given data, and then invokes a click event. + * + * @method Phaser.Loader.LoaderPlugin#save + * @since 3.0.0 + * + * @param {*} data - The data to be saved. Will be passed through URL.createObjectURL. + * @param {string} [filename=file.json] - The filename to save the file as. + * @param {string} [filetype=application/json] - The file type to use when saving the file. Defaults to JSON. + * + * @return {Phaser.Loader.LoaderPlugin} This Loader plugin. + */ + save: function (data, filename, filetype) + { + if (filename === undefined) { filename = 'file.json'; } + if (filetype === undefined) { filetype = 'application/json'; } + + var blob = new Blob([ data ], { type: filetype }); + + var url = URL.createObjectURL(blob); + + var a = document.createElement('a'); + + a.download = filename; + a.textContent = 'Download ' + filename; + a.href = url; + a.click(); + + return this; + }, + + /** + * Resets the Loader. + * + * This will clear all lists and reset the base URL, path and prefix. + * + * Warning: If the Loader is currently downloading files, or has files in its queue, they will be aborted. + * + * @method Phaser.Loader.LoaderPlugin#reset + * @since 3.0.0 + */ + reset: function () + { + this.list.clear(); + this.inflight.clear(); + this.queue.clear(); + + var gameConfig = this.systems.game.config; + var sceneConfig = this.systems.settings.loader; + + this.setBaseURL(GetFastValue(sceneConfig, 'baseURL', gameConfig.loaderBaseURL)); + this.setPath(GetFastValue(sceneConfig, 'path', gameConfig.loaderPath)); + this.setPrefix(GetFastValue(sceneConfig, 'prefix', gameConfig.loaderPrefix)); + + this.state = CONST.LOADER_IDLE; + }, + + /** + * 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; + + this.systems.events.off('update', this.update, this); + this.systems.events.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.Loader.LoaderPlugin#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.state = CONST.LOADER_DESTROYED; + + this.systems.events.off('update', this.update, this); + this.systems.events.off('start', this.pluginStart, this); + + this.list = null; + this.inflight = null; + this.queue = null; + + this.scene = null; + this.systems = null; + this.textureManager = null; + this.cacheManager = null; + } + +}); + +PluginCache.register('Loader', LoaderPlugin, 'load'); + +module.exports = LoaderPlugin; + + +/***/ }), +/* 639 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var ImageFile = __webpack_require__(65); +var IsPlainObject = __webpack_require__(8); +var MultiFile = __webpack_require__(64); +var TextFile = __webpack_require__(279); + +/** + * @typedef {object} Phaser.Loader.FileTypes.UnityAtlasFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [atlasURL] - The absolute or relative URL to load the atlas data file from. + * @property {string} [atlasExtension='txt'] - The default file extension to use for the atlas data if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas data file. + */ + +/** + * @classdesc + * A single text file based Unity Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#unityAtlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#unityAtlas. + * + * @class UnityAtlasFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + */ +var UnityAtlasFile = new Class({ + + Extends: MultiFile, + + initialize: + + function UnityAtlasFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new TextFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'txt'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new TextFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'unityatlas', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'unityatlas', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.UnityAtlasFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.failed === 0 && !this.complete) + { + var image = this.files[0]; + var text = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addUnityAtlas(image.key, image.data, text.data, normalMap); + + text.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Adds a Unity YAML based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.UnityAtlasFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Unity Atlas File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#unityAtlas + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig|Phaser.Loader.FileTypes.UnityAtlasFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new UnityAtlasFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new UnityAtlasFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = UnityAtlasFile; + + +/***/ }), +/* 640 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(56); +var TILEMAP_FORMATS = __webpack_require__(30); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TilemapJSONFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Tiled Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. + * + * @class TilemapJSONFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TilemapJSONFile = new Class({ + + Extends: JSONFile, + + initialize: + + function TilemapJSONFile (loader, key, url, xhrSettings) + { + JSONFile.call(this, loader, key, url, xhrSettings); + + this.type = 'tilemapJSON'; + + this.cache = loader.cacheManager.tilemap; + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.TilemapJSONFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var tiledata = { format: TILEMAP_FORMATS.TILED_JSON, data: this.data }; + + this.cache.add(this.key, tiledata); + + this.pendingDestroy(tiledata); + } + +}); + +/** + * Adds a Tiled JSON Tilemap file, or array of map files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); + * } + * ``` + * + * The Tilemap data is created using the Tiled Map Editor and selecting JSON as the export format. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapTiledJSON({ + * key: 'level1', + * url: 'maps/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapJSONFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" + * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Tilemap JSON File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig|Phaser.Loader.FileTypes.TilemapJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapJSONFile(this, key[i])); + } + } + else + { + this.addFile(new TilemapJSONFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TilemapJSONFile; + + +/***/ }), +/* 641 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(56); +var TILEMAP_FORMATS = __webpack_require__(30); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TilemapImpactFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Impact.js Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. + * + * @class TilemapImpactFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TilemapImpactFile = new Class({ + + Extends: JSONFile, + + initialize: + + function TilemapImpactFile (loader, key, url, xhrSettings) + { + JSONFile.call(this, loader, key, url, xhrSettings); + + this.type = 'tilemapJSON'; + + this.cache = loader.cacheManager.tilemap; + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.TilemapImpactFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var tiledata = { format: TILEMAP_FORMATS.WELTMEISTER, data: this.data }; + + this.cache.add(this.key, tiledata); + + this.pendingDestroy(tiledata); + } + +}); + +/** + * Adds an Impact.js Tilemap file, or array of map files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.tilemapImpact('level1', 'maps/Level1.json'); + * } + * ``` + * + * Impact Tilemap data is created the Impact.js Map Editor called Weltmeister. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapImpact({ + * key: 'level1', + * url: 'maps/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapImpactFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapImpact('level1', 'maps/Level1.json'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" + * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Tilemap Impact File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#tilemapImpact + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig|Phaser.Loader.FileTypes.TilemapImpactFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('tilemapImpact', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapImpactFile(this, key[i])); + } + } + else + { + this.addFile(new TilemapImpactFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TilemapImpactFile; + + +/***/ }), +/* 642 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); +var TILEMAP_FORMATS = __webpack_require__(30); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TilemapCSVFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='csv'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Tilemap CSV File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. + * + * @class TilemapCSVFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TilemapCSVFile = new Class({ + + Extends: File, + + initialize: + + function TilemapCSVFile (loader, key, url, xhrSettings) + { + var extension = 'csv'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'tilemapCSV', + cache: loader.cacheManager.tilemap, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + + this.tilemapFormat = TILEMAP_FORMATS.CSV; + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.TilemapCSVFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.TilemapCSVFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var tiledata = { format: this.tilemapFormat, data: this.data }; + + this.cache.add(this.key, tiledata); + + this.pendingDestroy(tiledata); + } + +}); + +/** + * Adds a CSV Tilemap file, or array of CSV files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.tilemapCSV('level1', 'maps/Level1.csv'); + * } + * ``` + * + * Tilemap CSV data can be created in a text editor, or a 3rd party app that exports as CSV. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapCSV({ + * key: 'level1', + * url: 'maps/Level1.csv' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapCSVFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapCSV('level1', 'maps/Level1.csv'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" + * and no URL is given then the Loader will set the URL to be "level.csv". It will always add `.csv` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Tilemap CSV File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#tilemapCSV + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig|Phaser.Loader.FileTypes.TilemapCSVFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapCSVFile(this, key[i])); + } + } + else + { + this.addFile(new TilemapCSVFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TilemapCSVFile; + + +/***/ }), +/* 643 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.SVGSizeConfig + * + * @property {integer} [width] - An optional width. The SVG will be resized to this size before being rendered to a texture. + * @property {integer} [height] - An optional height. The SVG will be resized to this size before being rendered to a texture. + * @property {number} [scale] - An optional scale. If given it overrides the width / height properties. The SVG is scaled by the scale factor before being rendered to a texture. + */ + +/** + * @typedef {object} Phaser.Loader.FileTypes.SVGFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='svg'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. + */ + +/** + * @classdesc + * A single SVG File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. + * + * @class SVGFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var SVGFile = new Class({ + + Extends: File, + + initialize: + + function SVGFile (loader, key, url, svgConfig, xhrSettings) + { + var extension = 'svg'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + svgConfig = GetFastValue(config, 'svgConfig', {}); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'svg', + cache: loader.textureManager, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + width: GetFastValue(svgConfig, 'width'), + height: GetFastValue(svgConfig, 'height'), + scale: GetFastValue(svgConfig, 'scale') + } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.SVGFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var text = this.xhrLoader.responseText; + var svg = [ text ]; + var width = this.config.width; + var height = this.config.height; + var scale = this.config.scale; + + resize: if (width && height || scale) + { + var xml = null; + var parser = new DOMParser(); + xml = parser.parseFromString(text, 'text/xml'); + var svgXML = xml.getElementsByTagName('svg')[0]; + + var hasViewBox = svgXML.hasAttribute('viewBox'); + var svgWidth = parseFloat(svgXML.getAttribute('width')); + var svgHeight = parseFloat(svgXML.getAttribute('height')); + + if (!hasViewBox && svgWidth && svgHeight) + { + // If there's no viewBox attribute, set one + svgXML.setAttribute('viewBox', '0 0 ' + svgWidth + ' ' + svgHeight); + } + else if (hasViewBox && !svgWidth && !svgHeight) + { + // Get the w/h from the viewbox + var viewBox = svgXML.getAttribute('viewBox').split(/\s+|,/); + + svgWidth = viewBox[2]; + svgHeight = viewBox[3]; + } + + if (scale) + { + if (svgWidth && svgHeight) + { + width = svgWidth * scale; + height = svgHeight * scale; + } + else + { + break resize; + } + } + + svgXML.setAttribute('width', width.toString() + 'px'); + svgXML.setAttribute('height', height.toString() + 'px'); + + svg = [ (new XMLSerializer()).serializeToString(svgXML) ]; + } + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + this.onProcessError(); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var _this = this; + var retry = false; + + this.data.onload = function () + { + if (!retry) + { + File.revokeObjectURL(_this.data); + } + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + // Safari 8 re-try + if (!retry) + { + retry = true; + + File.revokeObjectURL(_this.data); + + _this.data.src = 'data:image/svg+xml,' + encodeURIComponent(svg.join('')); + } + else + { + _this.onProcessError(); + } + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.SVGFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + +}); + +/** + * Adds an SVG File, or array of SVG Files, to the current load queue. When the files are loaded they + * will be rendered to bitmap textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SVGFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.svg('morty', 'images/Morty.svg'); + * // and later in your game ... + * this.add.image(x, y, 'morty'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can optionally pass an SVG Resize Configuration object when you load an SVG file. By default the SVG will be rendered to a texture + * at the same size defined in the SVG file attributes. However, this isn't always desirable. You may wish to resize the SVG (either down + * or up) to improve texture clarity, or reduce texture memory consumption. You can either specify an exact width and height to resize + * the SVG to: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { width: 300, height: 600 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * width: 300, + * height: 600 + * } + * }); + * ``` + * + * Alternatively, you can just provide a scale factor instead: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { scale: 2.5 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * scale: 2.5 + * } + * }); + * ``` + * + * If scale, width and height values are all given, the scale has priority and the width and height values are ignored. + * + * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#svg + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig|Phaser.Loader.FileTypes.SVGFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('svg', function (key, url, svgConfig, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new SVGFile(this, key[i])); + } + } + else + { + this.addFile(new SVGFile(this, key, url, svgConfig, xhrSettings)); + } + + return this; +}); + +module.exports = SVGFile; + + + +/***/ }), +/* 644 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(65); + +/** + * @typedef {object} Phaser.Loader.FileTypes.SpriteSheetFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='png'] - The default file extension to use if no url is provided. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image. + * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Sprite Sheet Image File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#spritesheet method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spritesheet. + * + * @class SpriteSheetFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.SpriteSheetFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var SpriteSheetFile = new Class({ + + Extends: ImageFile, + + initialize: + + function SpriteSheetFile (loader, key, url, frameConfig, xhrSettings) + { + ImageFile.call(this, loader, key, url, xhrSettings, frameConfig); + + this.type = 'spritesheet'; + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.SpriteSheetFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture = this.cache.addSpriteSheet(this.key, this.data, this.config); + + this.pendingDestroy(texture); + } + +}); + +/** + * Adds a Sprite Sheet Image, or array of Sprite Sheet Images, to the current load queue. + * + * The term 'Sprite Sheet' in Phaser means a fixed-size sheet. Where every frame in the sheet is the exact same size, + * and you reference those frames using numbers, not frame names. This is not the same thing as a Texture Atlas, where + * the frames are packed in a way where they take up the least amount of space, and are referenced by their names, + * not numbers. Some articles and software use the term 'Sprite Sheet' to mean Texture Atlas, so please be aware of + * what sort of file you're actually trying to load. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 }); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback + * of animated gifs to Canvas elements. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.spritesheet({ + * key: 'bot', + * url: 'images/robot.png', + * frameConfig: { + * frameWidth: 32, + * frameHeight: 38, + * startFrame: 0, + * endFrame: 8 + * } + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SpriteSheetFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 }); + * // and later in your game ... + * this.add.image(x, y, 'bot', 0); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `PLAYER.` and the key was `Running` the final key will be `PLAYER.Running` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.spritesheet('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ], { frameWidth: 256, frameHeight: 80 }); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.spritesheet({ + * key: 'logo', + * url: 'images/AtariLogo.png', + * normalMap: 'images/AtariLogo-n.png', + * frameConfig: { + * frameWidth: 256, + * frameHeight: 80 + * } + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Sprite Sheet File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#spritesheet + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.SpriteSheetFileConfig|Phaser.Loader.FileTypes.SpriteSheetFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. At a minimum it should have a `frameWidth` property. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('spritesheet', function (key, url, frameConfig, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new SpriteSheetFile(this, key[i])); + } + } + else + { + this.addFile(new SpriteSheetFile(this, key, url, frameConfig, xhrSettings)); + } + + return this; +}); + +module.exports = SpriteSheetFile; + + +/***/ }), +/* 645 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.ScriptFileConfig + * + * @property {string} key - The key of the file. Must be unique within the Loader. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='js'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#script method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#script. + * + * @class ScriptFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.ScriptFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var ScriptFile = new Class({ + + Extends: File, + + initialize: + + function ScriptFile (loader, key, url, xhrSettings) + { + var extension = 'js'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'script', + cache: false, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.ScriptFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = document.createElement('script'); + this.data.language = 'javascript'; + this.data.type = 'text/javascript'; + this.data.defer = false; + this.data.text = this.xhrLoader.responseText; + + document.head.appendChild(this.data); + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Script file, or array of Script files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.script('aliens', 'lib/aliens.js'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String and not already in-use by another file in the Loader. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.script({ + * key: 'aliens', + * url: 'lib/aliens.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ScriptFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a script element + * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to + * false and then the resulting element will be appended to `document.head`. Any code then in the + * script will be executed. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Script File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#script + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.ScriptFileConfig|Phaser.Loader.FileTypes.ScriptFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('script', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ScriptFile(this, key[i])); + } + } + else + { + this.addFile(new ScriptFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = ScriptFile; + + +/***/ }), +/* 646 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.ScenePluginFileConfig + * + * @property {string} key - The key of the file. Must be unique within the Loader. + * @property {(string|function)} [url] - The absolute or relative URL to load the file from. Or, a Scene Plugin. + * @property {string} [extension='js'] - The default file extension to use if no url is provided. + * @property {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. + * @property {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Scene Plugin Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#scenePlugin method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scenePlugin. + * + * @class ScenePluginFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.8.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. + * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var ScenePluginFile = new Class({ + + Extends: File, + + initialize: + + function ScenePluginFile (loader, key, url, systemKey, sceneKey, xhrSettings) + { + var extension = 'js'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + systemKey = GetFastValue(config, 'systemKey'); + sceneKey = GetFastValue(config, 'sceneKey'); + } + + var fileConfig = { + type: 'scenePlugin', + cache: false, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + systemKey: systemKey, + sceneKey: sceneKey + } + }; + + File.call(this, loader, fileConfig); + + // If the url variable refers to a class, add the plugin directly + if (typeof url === 'function') + { + this.data = url; + + this.state = CONST.FILE_POPULATED; + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.ScenePluginFile#onProcess + * @since 3.8.0 + */ + onProcess: function () + { + var pluginManager = this.loader.systems.plugins; + var config = this.config; + + var key = this.key; + var systemKey = GetFastValue(config, 'systemKey', key); + var sceneKey = GetFastValue(config, 'sceneKey', key); + + if (this.state === CONST.FILE_POPULATED) + { + pluginManager.installScenePlugin(systemKey, this.data, sceneKey, this.loader.scene); + } + else + { + // Plugin added via a js file + this.state = CONST.FILE_PROCESSING; + + this.data = document.createElement('script'); + this.data.language = 'javascript'; + this.data.type = 'text/javascript'; + this.data.defer = false; + this.data.text = this.xhrLoader.responseText; + + document.head.appendChild(this.data); + + pluginManager.installScenePlugin(systemKey, window[this.key], sceneKey, this.loader.scene); + } + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Scene Plugin Script file, or array of plugin files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.scenePlugin('ModPlayer', 'plugins/ModPlayer.js', 'modPlayer', 'mods'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String and not already in-use by another file in the Loader. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.scenePlugin({ + * key: 'modplayer', + * url: 'plugins/ModPlayer.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ScenePluginFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a script element + * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to + * false and then the resulting element will be appended to `document.head`. Any code then in the + * script will be executed. It will then be passed to the Phaser PluginCache.register method. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Script File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#scenePlugin + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.8.0 + * + * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig|Phaser.Loader.FileTypes.ScenePluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {(string|function)} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, set to a plugin function. + * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. + * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('scenePlugin', function (key, url, systemKey, sceneKey, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ScenePluginFile(this, key[i])); + } + } + else + { + this.addFile(new ScenePluginFile(this, key, url, systemKey, sceneKey, xhrSettings)); + } + + return this; +}); + +module.exports = ScenePluginFile; + + +/***/ }), +/* 647 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.PluginFileConfig + * + * @property {string} key - The key of the file. Must be unique within the Loader. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='js'] - The default file extension to use if no url is provided. + * @property {boolean} [start=false] - Automatically start the plugin after loading? + * @property {string} [mapping] - If this plugin is to be injected into the Scene, this is the property key used. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Plugin Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#plugin method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#plugin. + * + * @class PluginFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.PluginFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param {boolean} [start=false] - Automatically start the plugin after loading? + * @param {string} [mapping] - If this plugin is to be injected into the Scene, this is the property key used. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var PluginFile = new Class({ + + Extends: File, + + initialize: + + function PluginFile (loader, key, url, start, mapping, xhrSettings) + { + var extension = 'js'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + start = GetFastValue(config, 'start'); + mapping = GetFastValue(config, 'mapping'); + } + + var fileConfig = { + type: 'plugin', + cache: false, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + start: start, + mapping: mapping + } + }; + + File.call(this, loader, fileConfig); + + // If the url variable refers to a class, add the plugin directly + if (typeof url === 'function') + { + this.data = url; + + this.state = CONST.FILE_POPULATED; + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.PluginFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + var pluginManager = this.loader.systems.plugins; + var config = this.config; + + var start = GetFastValue(config, 'start', false); + var mapping = GetFastValue(config, 'mapping', null); + + if (this.state === CONST.FILE_POPULATED) + { + pluginManager.install(this.key, this.data, start, mapping); + } + else + { + // Plugin added via a js file + this.state = CONST.FILE_PROCESSING; + + this.data = document.createElement('script'); + this.data.language = 'javascript'; + this.data.type = 'text/javascript'; + this.data.defer = false; + this.data.text = this.xhrLoader.responseText; + + document.head.appendChild(this.data); + + pluginManager.install(this.key, window[this.key], start, mapping); + } + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Plugin Script file, or array of plugin files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.plugin('modplayer', 'plugins/ModPlayer.js'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String and not already in-use by another file in the Loader. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.plugin({ + * key: 'modplayer', + * url: 'plugins/ModPlayer.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.PluginFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a script element + * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to + * false and then the resulting element will be appended to `document.head`. Any code then in the + * script will be executed. It will then be passed to the Phaser PluginCache.register method. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Plugin File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#plugin + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.PluginFileConfig|Phaser.Loader.FileTypes.PluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {(string|function)} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, a plugin function. + * @param {boolean} [start] - The plugin mapping configuration object. + * @param {string} [mapping] - If this plugin is to be injected into the Scene, this is the property key used. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('plugin', function (key, url, start, mapping, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new PluginFile(this, key[i])); + } + } + else + { + this.addFile(new PluginFile(this, key, url, start, mapping, xhrSettings)); + } + + return this; +}); + +module.exports = PluginFile; + + +/***/ }), +/* 648 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(56); + +/** + * @typedef {object} Phaser.Loader.FileTypes.PackFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the JSON Cache. + * @property {string|any} [url] - The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly processed. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {string} [dataKey] - If specified instead of the whole JSON file being parsed, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single JSON Pack File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#pack method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#pack. + * + * @class PackFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + */ +var PackFile = new Class({ + + Extends: JSONFile, + + initialize: + + // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object + // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing + + function PackFile (loader, key, url, xhrSettings, dataKey) + { + JSONFile.call(this, loader, key, url, xhrSettings, dataKey); + + this.type = 'packfile'; + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.PackFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + if (this.state !== CONST.FILE_POPULATED) + { + this.state = CONST.FILE_PROCESSING; + + this.data = JSON.parse(this.xhrLoader.responseText); + } + + // Let's pass the pack file data over to the Loader ... + this.loader.addPack(this.data, this.config); + + this.onProcessComplete(); + } + +}); + +/** + * Adds a JSON File Pack, or array of packs, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.pack('level1', 'data/Level1Files.json'); + * } + * ``` + * + * A File Pack is a JSON file (or object) that contains details about other files that should be added into the Loader. + * Here is a small example: + * + * ```json + * { + * "test1": { + * "files": [ + * { + * "type": "image", + * "key": "taikodrummaster", + * "url": "assets/pics/taikodrummaster.jpg" + * }, + * { + * "type": "image", + * "key": "sukasuka-chtholly", + * "url": "assets/pics/sukasuka-chtholly.png" + * } + * ] + * }, + * "meta": { + * "generated": "1401380327373", + * "app": "Phaser 3 Asset Packer", + * "url": "https://phaser.io", + * "version": "1.0", + * "copyright": "Photon Storm Ltd. 2018" + * } + * } + * ``` + * + * The pack can be split into sections. In the example above you'll see a section called `test1. You can tell + * the `load.pack` method to parse only a particular section of a pack. The pack is stored in the JSON Cache, + * so you can pass it to the Loader to process additional sections as needed in your game, or you can just load + * them all at once without specifying anything. + * + * The pack file can contain an entry for any type of file that Phaser can load. The object structures exactly + * match that of the file type configs, and all properties available within the file type configs can be used + * in the pack file too. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.pack({ + * key: 'level1', + * url: 'data/Level1Files.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.PackFileConfig` for more details. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the Pack File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#pack + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.PackFileConfig|Phaser.Loader.FileTypes.PackFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('pack', function (key, url, packKey, xhrSettings) +{ + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.addFile(new PackFile(this, key[i])); + } + } + else + { + this.addFile(new PackFile(this, key, url, xhrSettings, packKey)); + } + + return this; +}); + +module.exports = PackFile; + + +/***/ }), +/* 649 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var ImageFile = __webpack_require__(65); +var IsPlainObject = __webpack_require__(8); +var JSONFile = __webpack_require__(56); +var MultiFile = __webpack_require__(64); + +/** + * @typedef {object} Phaser.Loader.FileTypes.MultiAtlasFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [atlasURL] - The absolute or relative URL to load the multi atlas json file from. Or, a well formed JSON object. + * @property {string} [atlasExtension='json'] - The default file extension to use for the atlas json if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas json file. + * @property {string} [path] - Optional path to use when loading the textures defined in the atlas data. + * @property {string} [baseURL] - Optional Base URL to use when loading the textures defined in the atlas data. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture files. + */ + +/** + * @classdesc + * A single Multi Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#multiatlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#multiatlas. + * + * @class MultiAtlasFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @param {string} [atlasURL] - The absolute or relative URL to load the multi atlas json file from. + * @param {string} [path] - Optional path to use when loading the textures defined in the atlas data. + * @param {string} [baseURL] - Optional Base URL to use when loading the textures defined in the atlas data. + * @param {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas json file. + * @param {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture files. + */ +var MultiAtlasFile = new Class({ + + Extends: MultiFile, + + initialize: + + function MultiAtlasFile (loader, key, atlasURL, path, baseURL, atlasXhrSettings, textureXhrSettings) + { + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + atlasURL = GetFastValue(config, 'url'); + atlasXhrSettings = GetFastValue(config, 'xhrSettings'); + path = GetFastValue(config, 'path'); + baseURL = GetFastValue(config, 'baseURL'); + textureXhrSettings = GetFastValue(config, 'textureXhrSettings'); + } + + var data = new JSONFile(loader, key, atlasURL, atlasXhrSettings); + + MultiFile.call(this, loader, 'multiatlas', key, [ data ]); + + this.config.path = path; + this.config.baseURL = baseURL; + this.config.textureXhrSettings = textureXhrSettings; + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.MultiFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + + if (file.type === 'json' && file.data.hasOwnProperty('textures')) + { + // Inspect the data for the files to now load + var textures = file.data.textures; + + var config = this.config; + var loader = this.loader; + + var currentBaseURL = loader.baseURL; + var currentPath = loader.path; + var currentPrefix = loader.prefix; + + var baseURL = GetFastValue(config, 'baseURL', currentBaseURL); + var path = GetFastValue(config, 'path', currentPath); + var prefix = GetFastValue(config, 'prefix', currentPrefix); + var textureXhrSettings = GetFastValue(config, 'textureXhrSettings'); + + loader.setBaseURL(baseURL); + loader.setPath(path); + loader.setPrefix(prefix); + + for (var i = 0; i < textures.length; i++) + { + // "image": "texture-packer-multi-atlas-0.png", + var textureURL = textures[i].image; + + var key = '_MA_' + textureURL; + + var image = new ImageFile(loader, key, textureURL, textureXhrSettings); + + this.addToMultiFile(image); + + loader.addFile(image); + + // "normalMap": "texture-packer-multi-atlas-0_n.png", + if (textures[i].normalMap) + { + var normalMap = new ImageFile(loader, key, textures[i].normalMap, textureXhrSettings); + + normalMap.type = 'normalMap'; + + image.setLink(normalMap); + + this.addToMultiFile(normalMap); + + loader.addFile(normalMap); + } + } + + // Reset the loader settings + loader.setBaseURL(currentBaseURL); + loader.setPath(currentPath); + loader.setPrefix(currentPrefix); + } + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.MultiFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var fileJSON = this.files[0]; + + fileJSON.addToCache(); + + var data = []; + var images = []; + var normalMaps = []; + + for (var i = 1; i < this.files.length; i++) + { + var file = this.files[i]; + + if (file.type === 'normalMap') + { + continue; + } + + var key = file.key.substr(4); + var image = file.data; + + // Now we need to find out which json entry this mapped to + for (var t = 0; t < fileJSON.data.textures.length; t++) + { + var item = fileJSON.data.textures[t]; + + if (item.image === key) + { + images.push(image); + + data.push(item); + + if (file.linkFile) + { + normalMaps.push(file.linkFile.data); + } + + break; + } + } + } + + if (normalMaps.length === 0) + { + normalMaps = undefined; + } + + this.loader.textureManager.addAtlasJSONArray(this.key, images, data, normalMaps); + + this.complete = true; + + for (i = 0; i < this.files.length; i++) + { + this.files[i].pendingDestroy(); + } + } + } + +}); + +/** + * Adds a Multi Texture Atlas, or array of multi atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.multiatlas('level1', 'images/Level1.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a JSON file as exported from the application Texture Packer, + * version 4.6.3 or above, where you have made sure to use the Phaser 3 Export option. + * + * The way it works internally is that you provide a URL to the JSON file. Phaser then loads this JSON, parses it and + * extracts which texture files it also needs to load to complete the process. If the JSON also defines normal maps, + * Phaser will load those as well. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.multiatlas({ + * key: 'level1', + * atlasURL: 'images/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.MultiAtlasFileConfig` for more details. + * + * Instead of passing a URL for the atlas JSON data you can also pass in a well formed JSON object instead. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.multiatlas('level1', 'images/Level1.json'); + * // and later in your game ... + * this.add.image(x, y, 'level1', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Multi Atlas File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#multiatlas + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.MultiAtlasFileConfig|Phaser.Loader.FileTypes.MultiAtlasFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {string} [path] - Optional path to use when loading the textures defined in the atlas data. + * @param {string} [baseURL] - Optional Base URL to use when loading the textures defined in the atlas data. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('multiatlas', function (key, atlasURL, path, baseURL, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new MultiAtlasFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new MultiAtlasFile(this, key, atlasURL, path, baseURL, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = MultiAtlasFile; + + +/***/ }), +/* 650 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.HTMLTextureFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='html'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {integer} [width=512] - The width of the texture the HTML will be rendered to. + * @property {integer} [height=512] - The height of the texture the HTML will be rendered to. + */ + +/** + * @classdesc + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#htmlTexture method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#htmlTexture. + * + * @class HTMLTextureFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.12.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.HTMLTextureFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {integer} [width] - The width of the texture the HTML will be rendered to. + * @param {integer} [height] - The height of the texture the HTML will be rendered to. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var HTMLTextureFile = new Class({ + + Extends: File, + + initialize: + + function HTMLTextureFile (loader, key, url, width, height, xhrSettings) + { + if (width === undefined) { width = 512; } + if (height === undefined) { height = 512; } + + var extension = 'html'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + width = GetFastValue(config, 'width', width); + height = GetFastValue(config, 'height', height); + } + + var fileConfig = { + type: 'html', + cache: loader.textureManager, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + width: width, + height: height + } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.HTMLTextureFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var w = this.config.width; + var h = this.config.height; + + var data = []; + + data.push(''); + data.push(''); + data.push(''); + data.push(this.xhrLoader.responseText); + data.push(''); + data.push(''); + data.push(''); + + var svg = [ data.join('\n') ]; + var _this = this; + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + _this.state = CONST.FILE_ERRORED; + + _this.onProcessComplete(); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessError(); + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.HTMLTextureFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + +}); + +/** + * Adds an HTML File, or array of HTML Files, to the current load queue. When the files are loaded they + * will be rendered to textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.htmlTexture({ + * key: 'instructions', + * url: 'content/intro.html', + * width: 256, + * height: 512 + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLTextureFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); + * // and later in your game ... + * this.add.image(x, y, 'instructions'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * The width and height are the size of the texture to which the HTML will be rendered. It's not possible to determine these + * automatically, so you will need to provide them, either as arguments or in the file config object. + * When the HTML file has loaded a new SVG element is created with a size and viewbox set to the width and height given. + * The SVG file has a body tag added to it, with the HTML file contents included. It then calls `window.Blob` on the SVG, + * and if successful is added to the Texture Manager, otherwise it fails processing. The overall quality of the rendered + * HTML depends on your browser, and some of them may not even support the svg / blob process used. Be aware that there are + * limitations on what HTML can be inside an SVG. You can find out more details in this + * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). + * + * Note: The ability to load this type of file will only be available if the HTMLTextureFile File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#htmlTexture + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.12.0 + * + * @param {(string|Phaser.Loader.FileTypes.HTMLTextureFileConfig|Phaser.Loader.FileTypes.HTMLTextureFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {integer} [width=512] - The width of the texture the HTML will be rendered to. + * @param {integer} [height=512] - The height of the texture the HTML will be rendered to. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('htmlTexture', function (key, url, width, height, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new HTMLTextureFile(this, key[i])); + } + } + else + { + this.addFile(new HTMLTextureFile(this, key, url, width, height, xhrSettings)); + } + + return this; +}); + +module.exports = HTMLTextureFile; + + +/***/ }), +/* 651 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.HTMLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='html'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. + * + * @class HTMLFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.12.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var HTMLFile = new Class({ + + Extends: File, + + initialize: + + function HTMLFile (loader, key, url, xhrSettings) + { + var extension = 'html'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'text', + cache: loader.cacheManager.html, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.HTMLFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds an HTML file, or array of HTML files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.html('story', 'files/LoginForm.html'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global HTML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the HTML Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the HTML Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.html({ + * key: 'login', + * url: 'files/LoginForm.html' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.html('login', 'files/LoginForm.html'); + * // and later in your game ... + * var data = this.cache.html.get('login'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the html from the HTML Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the HTML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#html + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.12.0 + * + * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig|Phaser.Loader.FileTypes.HTMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('html', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new HTMLFile(this, key[i])); + } + } + else + { + this.addFile(new HTMLFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = HTMLFile; + + +/***/ }), +/* 652 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.GLSLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='glsl'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single GLSL File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl. + * + * @class GLSLFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var GLSLFile = new Class({ + + Extends: File, + + initialize: + + function GLSLFile (loader, key, url, xhrSettings) + { + var extension = 'glsl'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'glsl', + cache: loader.cacheManager.shader, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.GLSLFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a GLSL file, or array of GLSL files, to the current load queue. + * In Phaser 3 GLSL files are just plain Text files at the current moment in time. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.glsl('plasma', 'shaders/Plasma.glsl'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Shader Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Shader Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Shader Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.glsl({ + * key: 'plasma', + * url: 'shaders/Plasma.glsl' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.GLSLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.glsl('plasma', 'shaders/Plasma.glsl'); + * // and later in your game ... + * var data = this.cache.shader.get('plasma'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `FX.` and the key was `Plasma` the final key will be `FX.Plasma` and + * this is what you would use to retrieve the text from the Shader Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "plasma" + * and no URL is given then the Loader will set the URL to be "plasma.glsl". It will always add `.glsl` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the GLSL File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#glsl + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.GLSLFileConfig|Phaser.Loader.FileTypes.GLSLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.glsl`, i.e. if `key` was "alien" then the URL will be "alien.glsl". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('glsl', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new GLSLFile(this, key[i])); + } + } + else + { + this.addFile(new GLSLFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = GLSLFile; + + +/***/ }), +/* 653 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var ImageFile = __webpack_require__(65); +var IsPlainObject = __webpack_require__(8); +var MultiFile = __webpack_require__(64); +var ParseXMLBitmapFont = __webpack_require__(338); +var XMLFile = __webpack_require__(155); + +/** + * @typedef {object} Phaser.Loader.FileTypes.BitmapFontFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [fontDataURL] - The absolute or relative URL to load the font data xml file from. + * @property {string} [fontDataExtension='xml'] - The default file extension to use for the font data xml if no url is provided. + * @property {XHRSettingsObject} [fontDataXhrSettings] - Extra XHR Settings specifically for the font data xml file. + */ + +/** + * @classdesc + * A single Bitmap Font based File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. + * + * @class BitmapFontFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + */ +var BitmapFontFile = new Class({ + + Extends: MultiFile, + + initialize: + + function BitmapFontFile (loader, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new XMLFile(loader, { + key: key, + url: GetFastValue(config, 'fontDataURL'), + extension: GetFastValue(config, 'fontDataExtension', 'xml'), + xhrSettings: GetFastValue(config, 'fontDataXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new XMLFile(loader, key, fontDataURL, fontDataXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'bitmapfont', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'bitmapfont', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.BitmapFontFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var xml = this.files[1]; + + image.addToCache(); + xml.addToCache(); + + this.loader.cacheManager.bitmapFont.add(image.key, { data: ParseXMLBitmapFont(xml.data), texture: image.key, frame: null }); + + this.complete = true; + } + } + +}); + +/** + * Adds an XML based Bitmap Font, or array of fonts, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + + * ```javascript + * function preload () + * { + * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the font data to be provided in an XML file format. + * These files are created by software such as the [Angelcode Bitmap Font Generator](http://www.angelcode.com/products/bmfont/), + * [Littera](http://kvazars.com/littera/) or [Glyph Designer](https://71squared.com/glyphdesigner) + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.BitmapFontFileConfig` for more details. + * + * Once the atlas has finished loading you can use key of it when creating a Bitmap Text Game Object: + * + * ```javascript + * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * // and later in your game ... + * this.add.bitmapText(x, y, 'goldenFont', 'Hello World'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use when creating a Bitmap Text object. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.bitmapFont('goldenFont', [ 'images/GoldFont.png', 'images/GoldFont-n.png' ], 'images/GoldFont.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * normalMap: 'images/GoldFont-n.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Bitmap Font File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#bitmapFont + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig|Phaser.Loader.FileTypes.BitmapFontFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('bitmapFont', function (key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new BitmapFontFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new BitmapFontFile(this, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = BitmapFontFile; + + +/***/ }), +/* 654 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(20); +var File = __webpack_require__(22); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.BinaryFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Binary Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='bin'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ + +/** + * @classdesc + * A single Binary File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. + * + * @class BinaryFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ +var BinaryFile = new Class({ + + Extends: File, + + initialize: + + function BinaryFile (loader, key, url, xhrSettings, dataType) + { + var extension = 'bin'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + dataType = GetFastValue(config, 'dataType', dataType); + } + + var fileConfig = { + type: 'binary', + cache: loader.cacheManager.binary, + extension: extension, + responseType: 'arraybuffer', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { dataType: dataType } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.BinaryFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var ctor = this.config.dataType; + + this.data = (ctor) ? new ctor(this.xhrLoader.response) : this.xhrLoader.response; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Binary file, or array of Binary files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.binary('doom', 'files/Doom.wad'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Binary Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Binary Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Binary Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.binary({ + * key: 'doom', + * url: 'files/Doom.wad', + * dataType: Uint8Array + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.BinaryFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.binary('doom', 'files/Doom.wad'); + * // and later in your game ... + * var data = this.cache.binary.get('doom'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Data` the final key will be `LEVEL1.Data` and + * this is what you would use to retrieve the text from the Binary Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "doom" + * and no URL is given then the Loader will set the URL to be "doom.bin". It will always add `.bin` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Binary File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#binary + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig|Phaser.Loader.FileTypes.BinaryFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('binary', function (key, url, dataType, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new BinaryFile(this, key[i])); + } + } + else + { + this.addFile(new BinaryFile(this, key, url, xhrSettings, dataType)); + } + + return this; +}); + +module.exports = BinaryFile; + + +/***/ }), +/* 655 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AudioFile = __webpack_require__(281); +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var IsPlainObject = __webpack_require__(8); +var JSONFile = __webpack_require__(56); +var MultiFile = __webpack_require__(64); + +/** + * @typedef {object} Phaser.Loader.FileTypes.AudioSpriteFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Audio Cache. + * @property {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. + * @property {XHRSettingsObject} [jsonXhrSettings] - Extra XHR Settings specifically for the json file. + * @property {{(string|string[])}} [audioURL] - The absolute or relative URL to load the audio file from. + * @property {any} [audioConfig] - The audio configuration options. + * @property {XHRSettingsObject} [audioXhrSettings] - Extra XHR Settings specifically for the audio file. + */ + +/** + * @classdesc + * An Audio Sprite File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#audioSprite method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#audioSprite. + * + * @class AudioSpriteFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. + * @param {{(string|string[])}} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {any} [audioConfig] - The audio configuration options. + * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. + */ +var AudioSpriteFile = new Class({ + + Extends: MultiFile, + + initialize: + + function AudioSpriteFile (loader, key, jsonURL, audioURL, audioConfig, audioXhrSettings, jsonXhrSettings) + { + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + jsonURL = GetFastValue(config, 'jsonURL'); + audioURL = GetFastValue(config, 'audioURL'); + audioConfig = GetFastValue(config, 'audioConfig'); + audioXhrSettings = GetFastValue(config, 'audioXhrSettings'); + jsonXhrSettings = GetFastValue(config, 'jsonXhrSettings'); + } + + var data; + + // No url? then we're going to do a json load and parse it from that + if (!audioURL) + { + data = new JSONFile(loader, key, jsonURL, jsonXhrSettings); + + MultiFile.call(this, loader, 'audiosprite', key, [ data ]); + + this.config.resourceLoad = true; + this.config.audioConfig = audioConfig; + this.config.audioXhrSettings = audioXhrSettings; + } + else + { + var audio = AudioFile.create(loader, key, audioURL, audioConfig, audioXhrSettings); + + if (audio) + { + data = new JSONFile(loader, key, jsonURL, jsonXhrSettings); + + MultiFile.call(this, loader, 'audiosprite', key, [ audio, data ]); + + this.config.resourceLoad = false; + } + } + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.AudioSpriteFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + + if (this.config.resourceLoad && file.type === 'json' && file.data.hasOwnProperty('resources')) + { + // Inspect the data for the files to now load + var urls = file.data.resources; + + var audioConfig = GetFastValue(this.config, 'audioConfig'); + var audioXhrSettings = GetFastValue(this.config, 'audioXhrSettings'); + + var audio = AudioFile.create(this.loader, file.key, urls, audioConfig, audioXhrSettings); + + if (audio) + { + this.addToMultiFile(audio); + + this.loader.addFile(audio); + } + } + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.AudioSpriteFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var fileA = this.files[0]; + var fileB = this.files[1]; + + fileA.addToCache(); + fileB.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Adds a JSON based Audio Sprite, or array of audio sprites, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.audioSprite('kyobi', 'kyobi.json', [ + * 'kyobi.ogg', + * 'kyobi.mp3', + * 'kyobi.m4a' + * ]); + * } + * ``` + * + * Audio Sprites are a combination of audio files and a JSON configuration. + * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite + * + * If the JSON file includes a 'resource' object then you can let Phaser parse it and load the audio + * files automatically based on its content. To do this exclude the audio URLs from the load: + * + * ```javascript + * function preload () + * { + * this.load.audioSprite('kyobi', 'kyobi.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global Audio Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Audio Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Audio Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.audioSprite({ + * key: 'kyobi', + * jsonURL: 'audio/Kyobi.json', + * audioURL: [ + * 'audio/Kyobi.ogg', + * 'audio/Kyobi.mp3', + * 'audio/Kyobi.m4a' + * ] + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AudioSpriteFileConfig` for more details. + * + * Instead of passing a URL for the audio JSON data you can also pass in a well formed JSON object instead. + * + * Once the audio has finished loading you can use it create an Audio Sprite by referencing its key: + * + * ```javascript + * this.load.audioSprite('kyobi', 'kyobi.json'); + * // and later in your game ... + * var music = this.sound.addAudioSprite('kyobi'); + * music.play('title'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * Due to different browsers supporting different audio file types you should usually provide your audio files in a variety of formats. + * ogg, mp3 and m4a are the most common. If you provide an array of URLs then the Loader will determine which _one_ file to load based on + * browser support. + * + * If audio has been disabled in your game, either via the game config, or lack of support from the device, then no audio will be loaded. + * + * Note: The ability to load this type of file will only be available if the Audio Sprite File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#audioSprite + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig|Phaser.Loader.FileTypes.AudioSpriteFileConfig[])} key - The key to use for this file, or a file configuration object, or an array of objects. + * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. + * @param {(string|string[])} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {any} [audioConfig] - The audio configuration options. + * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader. + */ +FileTypesManager.register('audioSprite', function (key, jsonURL, audioURL, audioConfig, audioXhrSettings, jsonXhrSettings) +{ + var game = this.systems.game; + var gameAudioConfig = game.config.audio; + var deviceAudio = game.device.audio; + + if ((gameAudioConfig && gameAudioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + // Sounds are disabled, so skip loading audio + return this; + } + + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new AudioSpriteFile(this, key[i]); + + if (multifile.files) + { + this.addFile(multifile.files); + } + } + } + else + { + multifile = new AudioSpriteFile(this, key, jsonURL, audioURL, audioConfig, audioXhrSettings, jsonXhrSettings); + + if (multifile.files) + { + this.addFile(multifile.files); + } + } + + return this; +}); + + +/***/ }), +/* 656 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var ImageFile = __webpack_require__(65); +var IsPlainObject = __webpack_require__(8); +var MultiFile = __webpack_require__(64); +var XMLFile = __webpack_require__(155); + +/** + * @typedef {object} Phaser.Loader.FileTypes.AtlasXMLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [atlasURL] - The absolute or relative URL to load the atlas xml file from. + * @property {string} [atlasExtension='xml'] - The default file extension to use for the atlas xml if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas xml file. + */ + +/** + * @classdesc + * A single XML based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. + * + * @class AtlasXMLFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + */ +var AtlasXMLFile = new Class({ + + Extends: MultiFile, + + initialize: + + function AtlasXMLFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new XMLFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'xml'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new XMLFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'atlasxml', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'atlasxml', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.AtlasXMLFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var xml = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addAtlasXML(image.key, image.data, xml.data, normalMap); + + xml.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Adds an XML based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in an XML file format. + * These files are created by software such as Shoebox and Adobe Flash / Animate. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AtlasXMLFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.atlasXML('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Atlas XML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#atlasXML + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig|Phaser.Loader.FileTypes.AtlasXMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('atlasXML', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new AtlasXMLFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new AtlasXMLFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = AtlasXMLFile; + + +/***/ }), +/* 657 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(1); +var ImageFile = __webpack_require__(65); +var IsPlainObject = __webpack_require__(8); +var JSONFile = __webpack_require__(56); +var MultiFile = __webpack_require__(64); + +/** + * @typedef {object} Phaser.Loader.FileTypes.AtlasJSONFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [atlasURL] - The absolute or relative URL to load the atlas json file from. Or a well formed JSON object to use instead. + * @property {string} [atlasExtension='json'] - The default file extension to use for the atlas json if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas json file. + */ + +/** + * @classdesc + * A single JSON based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlas. + * + * https://www.codeandweb.com/texturepacker/tutorials/how-to-create-sprite-sheets-for-phaser3?source=photonstorm + * + * @class AtlasJSONFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.AtlasJSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + */ +var AtlasJSONFile = new Class({ + + Extends: MultiFile, + + initialize: + + function AtlasJSONFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new JSONFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'json'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new JSONFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'atlasjson', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'atlasjson', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.AtlasJSONFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var json = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addAtlas(image.key, image.data, json.data, normalMap); + + json.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Adds a JSON based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a JSON file, using either the JSON Hash or JSON Array format. + * These files are created by software such as Texture Packer, Shoebox and Adobe Flash / Animate. + * If you are using Texture Packer and have enabled multi-atlas support, then please use the Phaser Multi Atlas loader + * instead of this one. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.atlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AtlasJSONFileConfig` for more details. + * + * Instead of passing a URL for the atlas JSON data you can also pass in a well formed JSON object instead. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.atlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.atlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.json'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.atlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.json' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Atlas JSON File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#atlas + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.AtlasJSONFileConfig|Phaser.Loader.FileTypes.AtlasJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas json data file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas json file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('atlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new AtlasJSONFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new AtlasJSONFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = AtlasJSONFile; + + +/***/ }), +/* 658 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(56); + +/** + * @classdesc + * A single Animation JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#animation method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#animation. + * + * @class AnimationJSONFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + */ +var AnimationJSONFile = new Class({ + + Extends: JSONFile, + + initialize: + + // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object + // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing + + function AnimationJSONFile (loader, key, url, xhrSettings, dataKey) + { + JSONFile.call(this, loader, key, url, xhrSettings, dataKey); + + this.type = 'animationJSON'; + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.AnimationJSONFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + // We need to hook into this event: + this.loader.once('loadcomplete', this.onLoadComplete, this); + + // But the rest is the same as a normal JSON file + JSONFile.prototype.onProcess.call(this); + }, + + /** + * Called at the end of the load process, after the Loader has finished all files in its queue. + * + * @method Phaser.Loader.FileTypes.AnimationJSONFile#onLoadComplete + * @since 3.7.0 + */ + onLoadComplete: function () + { + this.loader.systems.anims.fromJSON(this.data); + + this.pendingDestroy(); + } + +}); + +/** + * Adds an Animation JSON Data file, or array of Animation JSON files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.animation('baddieAnims', 'files/BaddieAnims.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.animation({ + * key: 'baddieAnims', + * url: 'files/BaddieAnims.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details. + * + * Once the file has finished loading it will automatically be passed to the global Animation Managers `fromJSON` method. + * This will parse all of the JSON data and create animation data from it. This process happens at the very end + * of the Loader, once every other file in the load queue has finished. The reason for this is to allow you to load + * both animation data and the images it relies upon in the same load call. + * + * Once the animation data has been parsed you will be able to play animations using that data. + * Please see the Animation Manager `fromJSON` method for more details about the format and playback. + * + * You can also access the raw animation data from its Cache using its key: + * + * ```javascript + * this.load.animation('baddieAnims', 'files/BaddieAnims.json'); + * // and later in your game ... + * var data = this.cache.json.get('baddieAnims'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And if you only wanted to create animations from the `boss` data, then you could pass `level1.baddies.boss`as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the JSON File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#animation + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig|Phaser.Loader.FileTypes.JSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {string} [dataKey] - When the Animation JSON file loads only this property will be stored in the Cache and used to create animation data. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('animation', function (key, url, dataKey, xhrSettings) +{ + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.addFile(new AnimationJSONFile(this, key[i])); + } + } + else + { + this.addFile(new AnimationJSONFile(this, key, url, xhrSettings, dataKey)); + } + + return this; +}); + +module.exports = AnimationJSONFile; + + +/***/ }), +/* 659 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Loader.FileTypes + */ + +module.exports = { + + AnimationJSONFile: __webpack_require__(658), + AtlasJSONFile: __webpack_require__(657), + AtlasXMLFile: __webpack_require__(656), + AudioFile: __webpack_require__(281), + AudioSpriteFile: __webpack_require__(655), + BinaryFile: __webpack_require__(654), + BitmapFontFile: __webpack_require__(653), + GLSLFile: __webpack_require__(652), + HTML5AudioFile: __webpack_require__(280), + HTMLFile: __webpack_require__(651), + HTMLTextureFile: __webpack_require__(650), + ImageFile: __webpack_require__(65), + JSONFile: __webpack_require__(56), + MultiAtlasFile: __webpack_require__(649), + PackFile: __webpack_require__(648), + PluginFile: __webpack_require__(647), + ScenePluginFile: __webpack_require__(646), + ScriptFile: __webpack_require__(645), + SpriteSheetFile: __webpack_require__(644), + SVGFile: __webpack_require__(643), + TextFile: __webpack_require__(279), + TilemapCSVFile: __webpack_require__(642), + TilemapImpactFile: __webpack_require__(641), + TilemapJSONFile: __webpack_require__(640), + UnityAtlasFile: __webpack_require__(639), + XMLFile: __webpack_require__(155) + +}; + + +/***/ }), +/* 660 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(20); +var Extend = __webpack_require__(21); + +/** + * @namespace Phaser.Loader + */ + +var Loader = { + + FileTypes: __webpack_require__(659), + + File: __webpack_require__(22), + FileTypesManager: __webpack_require__(7), + GetURL: __webpack_require__(157), + LoaderPlugin: __webpack_require__(638), + MergeXHRSettings: __webpack_require__(156), + MultiFile: __webpack_require__(64), + XHRLoader: __webpack_require__(282), + XHRSettings: __webpack_require__(115) + +}; + +// Merge in the consts +Loader = Extend(false, Loader, CONST); + +module.exports = Loader; + + +/***/ }), +/* 661 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Input.Touch + */ + +/* eslint-disable */ +module.exports = { + + TouchManager: __webpack_require__(362) + +}; +/* eslint-enable */ + + +/***/ }), +/* 662 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Input.Mouse + */ + +/* eslint-disable */ +module.exports = { + + MouseManager: __webpack_require__(365) + +}; +/* eslint-enable */ + + +/***/ }), +/* 663 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns `true` if the Key was released within the `duration` value given, or `false` if it either isn't up, + * or was released longer ago than then given duration. + * + * @function Phaser.Input.Keyboard.UpDuration + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key object to test. + * @param {integer} [duration=50] - The duration, in ms, within which the key must have been released. + * + * @return {boolean} `true` if the Key was released within `duration` ms, otherwise `false`. + */ +var UpDuration = function (key, duration) +{ + if (duration === undefined) { duration = 50; } + + return (key.isUp && key.duration < duration); +}; + +module.exports = UpDuration; + + +/***/ }), +/* 664 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, + * or was pressed down longer ago than then given duration. + * + * @function Phaser.Input.Keyboard.DownDuration + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key object to test. + * @param {integer} [duration=50] - The duration, in ms, within which the key must have been pressed down. + * + * @return {boolean} `true` if the Key was pressed down within `duration` ms, otherwise `false`. + */ +var DownDuration = function (key, duration) +{ + if (duration === undefined) { duration = 50; } + + return (key.isDown && key.duration < duration); +}; + +module.exports = DownDuration; + + +/***/ }), +/* 665 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The justUp value allows you to test if this Key has just been released or not. + * + * When you check this value it will return `true` if the Key is up, otherwise `false`. + * + * You can only call JustUp once per key release. It will only return `true` once, until the Key is pressed down and released again. + * This allows you to use it in situations where you want to check if this key is up without using an event, such as in a core game loop. + * + * @function Phaser.Input.Keyboard.JustUp + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key to check to see if it's just up or not. + * + * @return {boolean} `true` if the Key was just released, otherwise `false`. + */ +var JustUp = function (key) +{ + if (key._justUp) + { + key._justUp = false; + + return true; + } + else + { + return false; + } +}; + +module.exports = JustUp; + + +/***/ }), +/* 666 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * The justDown value allows you to test if this Key has just been pressed down or not. + * + * When you check this value it will return `true` if the Key is down, otherwise `false`. + * + * You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. + * This allows you to use it in situations where you want to check if this key is down without using an event, such as in a core game loop. + * + * @function Phaser.Input.Keyboard.JustDown + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key to check to see if it's just down or not. + * + * @return {boolean} `true` if the Key was just pressed, otherwise `false`. + */ +var JustDown = function (key) +{ + if (key._justDown) + { + key._justDown = false; + + return true; + } + else + { + return false; + } +}; + +module.exports = JustDown; + + +/***/ }), +/* 667 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the Keyboard Plugin. + * + * @function Phaser.Input.Keyboard.ProcessKeyUp + * @private + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key to process the event for. + * @param {KeyboardEvent} event - The native Keyboard event. + * + * @return {Phaser.Input.Keyboard.Key} The Key that was processed. + */ +var ProcessKeyUp = function (key, event) +{ + key.originalEvent = event; + + if (key.preventDefault) + { + event.preventDefault(); + } + + if (!key.enabled) + { + return; + } + + key.isDown = false; + key.isUp = true; + key.timeUp = event.timeStamp; + key.duration = key.timeUp - key.timeDown; + key.repeats = 0; + + key._justDown = false; + key._justUp = true; + key._tick = -1; + + return key; +}; + +module.exports = ProcessKeyUp; + + +/***/ }), +/* 668 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the Keyboard Plugin. + * + * @function Phaser.Input.Keyboard.ProcessKeyDown + * @private + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.Key} key - The Key to process the event for. + * @param {KeyboardEvent} event - The native Keyboard event. + * + * @return {Phaser.Input.Keyboard.Key} The Key that was processed. + */ +var ProcessKeyDown = function (key, event) +{ + key.originalEvent = event; + + if (key.preventDefault) + { + event.preventDefault(); + } + + if (!key.enabled) + { + return; + } + + key.altKey = event.altKey; + key.ctrlKey = event.ctrlKey; + key.shiftKey = event.shiftKey; + key.location = event.location; + + if (key.isDown === false) + { + key.isDown = true; + key.isUp = false; + key.timeDown = event.timeStamp; + key.duration = 0; + key._justDown = true; + key._justUp = false; + } + + key.repeats++; + + return key; +}; + +module.exports = ProcessKeyDown; + + +/***/ }), +/* 669 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var KeyCodes = __webpack_require__(159); + +var KeyMap = {}; + +for (var key in KeyCodes) +{ + KeyMap[KeyCodes[key]] = key; +} + +module.exports = KeyMap; + + +/***/ }), +/* 670 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyCombo class. + * + * @function Phaser.Input.Keyboard.KeyCombo.ResetKeyCombo + * @private + * @since 3.0.0 + * + * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo to reset. + * + * @return {Phaser.Input.Keyboard.KeyCombo} The KeyCombo. + */ +var ResetKeyCombo = function (combo) +{ + combo.current = combo.keyCodes[0]; + combo.index = 0; + combo.timeLastMatched = 0; + combo.matched = false; + combo.timeMatched = 0; + + return combo; +}; + +module.exports = ResetKeyCombo; + + +/***/ }), +/* 671 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Used internally by the KeyCombo class. + * Return `true` if it reached the end of the combo, `false` if not. + * + * @function Phaser.Input.Keyboard.KeyCombo.AdvanceKeyCombo + * @private + * @since 3.0.0 + * + * @param {KeyboardEvent} event - The native Keyboard Event. + * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to advance. + * + * @return {boolean} `true` if it reached the end of the combo, `false` if not. + */ +var AdvanceKeyCombo = function (event, combo) +{ + combo.timeLastMatched = event.timeStamp; + combo.index++; + + if (combo.index === combo.size) + { + return true; + } + else + { + combo.current = combo.keyCodes[combo.index]; + return false; + } +}; + +module.exports = AdvanceKeyCombo; + + +/***/ }), +/* 672 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AdvanceKeyCombo = __webpack_require__(671); + +/** + * Used internally by the KeyCombo class. + * + * @function Phaser.Input.Keyboard.KeyCombo.ProcessKeyCombo + * @private + * @since 3.0.0 + * + * @param {KeyboardEvent} event - The native Keyboard Event. + * @param {Phaser.Input.Keyboard.KeyCombo} combo - The KeyCombo object to be processed. + * + * @return {boolean} `true` if the combo was matched, otherwise `false`. + */ +var ProcessKeyCombo = function (event, combo) +{ + if (combo.matched) + { + return true; + } + + var comboMatched = false; + var keyMatched = false; + + if (event.keyCode === combo.current) + { + // Key was correct + + if (combo.index > 0 && combo.maxKeyDelay > 0) + { + // We have to check to see if the delay between + // the new key and the old one was too long (if enabled) + + var timeLimit = combo.timeLastMatched + combo.maxKeyDelay; + + // Check if they pressed it in time or not + if (event.timeStamp <= timeLimit) + { + keyMatched = true; + comboMatched = AdvanceKeyCombo(event, combo); + } + } + else + { + keyMatched = true; + + // We don't check the time for the first key pressed, so just advance it + comboMatched = AdvanceKeyCombo(event, combo); + } + } + + if (!keyMatched && combo.resetOnWrongKey) + { + // Wrong key was pressed + combo.index = 0; + combo.current = combo.keyCodes[0]; + } + + if (comboMatched) + { + combo.timeLastMatched = event.timeStamp; + combo.matched = true; + combo.timeMatched = event.timeStamp; + } + + return comboMatched; +}; + +module.exports = ProcessKeyCombo; + + +/***/ }), +/* 673 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var GetValue = __webpack_require__(4); +var InputPluginCache = __webpack_require__(116); +var Key = __webpack_require__(284); +var KeyCodes = __webpack_require__(159); +var KeyCombo = __webpack_require__(283); +var KeyMap = __webpack_require__(669); +var ProcessKeyDown = __webpack_require__(668); +var ProcessKeyUp = __webpack_require__(667); +var SnapFloor = __webpack_require__(158); + +/** + * @classdesc + * The Keyboard Plugin is an input plugin that belongs to the Scene-owned Input system. + * + * Its role is to listen for native DOM Keyboard Events and then process them. + * + * You do not need to create this class directly, the Input system will create an instance of it automatically. + * + * You can access it from within a Scene using `this.input.keyboard`. For example, you can do: + * + * ```javascript + * this.input.keyboard.on('keydown', callback, context); + * ``` + * + * Or, to listen for a specific key: + * + * ```javascript + * this.input.keyboard.on('keydown_A', callback, context); + * ``` + * + * You can also create Key objects, which you can then poll in your game loop: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * ``` + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. + * + * Also please be aware that certain browser extensions can disable or override Phaser keyboard handling. + * For example the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * And there are others. So, please check your extensions before opening Phaser issues about keys that don't work. + * + * @class KeyboardPlugin + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input.Keyboard + * @constructor + * @since 3.10.0 + * + * @param {Phaser.Input.InputPlugin} sceneInputPlugin - A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. + */ +var KeyboardPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function KeyboardPlugin (sceneInputPlugin) + { + EventEmitter.call(this); + + /** + * A reference to the Scene that this Input Plugin is responsible for. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#scene + * @type {Phaser.Scene} + * @since 3.10.0 + */ + this.scene = sceneInputPlugin.scene; + + /** + * A reference to the Scene Systems Settings. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#settings + * @type {Phaser.Scenes.Settings.Object} + * @since 3.10.0 + */ + this.settings = this.scene.sys.settings; + + /** + * A reference to the Scene Input Plugin that created this Keyboard Plugin. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#sceneInputPlugin + * @type {Phaser.Input.InputPlugin} + * @since 3.10.0 + */ + this.sceneInputPlugin = sceneInputPlugin; + + /** + * A boolean that controls if the Keyboard Plugin is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#enabled + * @type {boolean} + * @default true + * @since 3.10.0 + */ + this.enabled = true; + + /** + * The Keyboard Event target, as defined in the Scene or Game Config. + * Typically the browser window, but can be any interactive DOM element. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#target + * @type {any} + * @since 3.10.0 + */ + this.target; + + /** + * An array of Key objects to process. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#keys + * @type {Phaser.Input.Keyboard.Key[]} + * @since 3.10.0 + */ + this.keys = []; + + /** + * An array of KeyCombo objects to process. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#combos + * @type {Phaser.Input.Keyboard.KeyCombo[]} + * @since 3.10.0 + */ + this.combos = []; + + /** + * An internal event queue. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#queue + * @type {KeyboardEvent[]} + * @private + * @since 3.10.0 + */ + this.queue = []; + + /** + * Internal event handler. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#onKeyHandler + * @type {function} + * @private + * @since 3.10.0 + */ + this.onKeyHandler; + + /** + * Internal time value. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#time + * @type {number} + * @private + * @since 3.11.0 + */ + this.time = 0; + + sceneInputPlugin.pluginEvents.once('boot', this.boot, this); + sceneInputPlugin.pluginEvents.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#boot + * @private + * @since 3.10.0 + */ + boot: function () + { + var settings = this.settings.input; + var config = this.scene.sys.game.config; + + this.enabled = GetValue(settings, 'keyboard', config.inputKeyboard); + this.target = GetValue(settings, 'keyboard.target', config.inputKeyboardEventTarget); + + this.sceneInputPlugin.pluginEvents.once('destroy', this.destroy, 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.Input.Keyboard.KeyboardPlugin#start + * @private + * @since 3.10.0 + */ + start: function () + { + if (this.enabled) + { + this.startListeners(); + } + + this.sceneInputPlugin.pluginEvents.once('shutdown', this.shutdown, this); + }, + + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#isActive + * @since 3.10.0 + * + * @return {boolean} `true` if the plugin and the Scene it belongs to is active. + */ + isActive: function () + { + return (this.enabled && this.scene.sys.isActive()); + }, + + /** + * Starts the Keyboard Event listeners running. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#startListeners + * @private + * @since 3.10.0 + */ + startListeners: function () + { + var _this = this; + + var handler = function (event) + { + if (event.defaultPrevented || !_this.isActive()) + { + // Do nothing if event already handled + return; + } + + _this.queue.push(event); + + var key = _this.keys[event.keyCode]; + + if (key && key.preventDefault) + { + event.preventDefault(); + } + + }; + + this.onKeyHandler = handler; + + this.target.addEventListener('keydown', handler, false); + this.target.addEventListener('keyup', handler, false); + + // Finally, listen for an update event from the Input Plugin + this.sceneInputPlugin.pluginEvents.on('update', this.update, this); + }, + + /** + * Stops the Keyboard Event listeners. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#stopListeners + * @private + * @since 3.10.0 + */ + stopListeners: function () + { + this.target.removeEventListener('keydown', this.onKeyHandler); + this.target.removeEventListener('keyup', this.onKeyHandler); + + this.sceneInputPlugin.pluginEvents.off('update', this.update); + }, + + /** + * @typedef {object} CursorKeys + * @memberof Phaser.Input.Keyboard + * + * @property {Phaser.Input.Keyboard.Key} [up] - A Key object mapping to the UP arrow key. + * @property {Phaser.Input.Keyboard.Key} [down] - A Key object mapping to the DOWN arrow key. + * @property {Phaser.Input.Keyboard.Key} [left] - A Key object mapping to the LEFT arrow key. + * @property {Phaser.Input.Keyboard.Key} [right] - A Key object mapping to the RIGHT arrow key. + * @property {Phaser.Input.Keyboard.Key} [space] - A Key object mapping to the SPACE BAR key. + * @property {Phaser.Input.Keyboard.Key} [shift] - A Key object mapping to the SHIFT key. + */ + + /** + * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also Space Bar and shift. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#createCursorKeys + * @since 3.10.0 + * + * @return {CursorKeys} An object containing the properties: `up`, `down`, `left`, `right`, `space` and `shift`. + */ + createCursorKeys: function () + { + return this.addKeys({ + up: KeyCodes.UP, + down: KeyCodes.DOWN, + left: KeyCodes.LEFT, + right: KeyCodes.RIGHT, + space: KeyCodes.SPACE, + shift: KeyCodes.SHIFT + }); + }, + + /** + * A practical way to create an object containing user selected hotkeys. + * + * For example: + * + * ```javascript + * this.input.keyboard.addKeys({ 'up': Phaser.Input.Keyboard.KeyCodes.W, 'down': Phaser.Input.Keyboard.KeyCodes.S }); + * ``` + * + * would return an object containing the properties (`up` and `down`) mapped to W and S {@link Phaser.Input.Keyboard.Key} objects. + * + * You can also pass in a comma-separated string: + * + * ```javascript + * this.input.keyboard.addKeys('W,S,A,D'); + * ``` + * + * Which will return an object with the properties W, S, A and D mapped to the relevant Key objects. + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#addKeys + * @since 3.10.0 + * + * @param {(object|string)} keys - An object containing Key Codes, or a comma-separated string. + * + * @return {object} An object containing Key objects mapped to the input properties. + */ + addKeys: function (keys) + { + var output = {}; + + if (typeof keys === 'string') + { + keys = keys.split(','); + + for (var i = 0; i < keys.length; i++) + { + var currentKey = keys[i].trim(); + + if (currentKey) + { + output[currentKey] = this.addKey(currentKey); + } + } + } + else + { + for (var key in keys) + { + output[key] = this.addKey(keys[key]); + } + } + + return output; + }, + + /** + * Adds a Key object to this Keyboard Plugin. + * + * The given argument can be either an existing Key object, a string, such as `A` or `SPACE`, or a key code value. + * + * If a Key object is given, and one already exists matching the same key code, the existing one is replaced with the new one. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#addKey + * @since 3.10.0 + * + * @param {(Phaser.Input.Keyboard.Key|string|integer)} key - Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * + * @return {Phaser.Input.Keyboard.Key} The newly created Key object, or a reference to it if it already existed in the keys array. + */ + addKey: function (key) + { + var keys = this.keys; + + if (key instanceof Key) + { + var idx = keys.indexOf(key); + + if (idx > -1) + { + keys[idx] = key; + } + else + { + keys[key.keyCode] = key; + } + + return key; + } + + if (typeof key === 'string') + { + key = KeyCodes[key.toUpperCase()]; + } + + if (!keys[key]) + { + keys[key] = new Key(key); + } + + return keys[key]; + }, + + /** + * Removes a Key object from this Keyboard Plugin. + * + * The given argument can be either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#removeKey + * @since 3.10.0 + * + * @param {(Phaser.Input.Keyboard.Key|string|integer)} key - Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + */ + removeKey: function (key) + { + var keys = this.keys; + + if (key instanceof Key) + { + var idx = keys.indexOf(key); + + if (idx > -1) + { + this.keys[idx] = undefined; + } + } + else if (typeof key === 'string') + { + key = KeyCodes[key.toUpperCase()]; + } + + if (keys[key]) + { + keys[key] = undefined; + } + }, + + /** + * Creates a new KeyCombo. + * + * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them + * it will emit a `keycombomatch` event from this Keyboard Plugin. + * + * The keys to be listened for can be defined as: + * + * A string (i.e. 'ATARI') + * An array of either integers (key codes) or strings, or a mixture of both + * An array of objects (such as Key objects) with a public 'keyCode' property + * + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) + * you could pass the following array of key codes: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + * + * Or, to listen for the user entering the word PHASER: + * + * ```javascript + * this.input.keyboard.createCombo('PHASER'); + * ``` + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#createCombo + * @since 3.10.0 + * + * @param {(string|integer[]|object[])} keys - The keys that comprise this combo. + * @param {KeyComboConfig} [config] - A Key Combo configuration object. + * + * @return {Phaser.Input.Keyboard.KeyCombo} The new KeyCombo object. + */ + createCombo: function (keys, config) + { + return new KeyCombo(this, keys, config); + }, + + /** + * Checks if the given Key object is currently being held down. + * + * The difference between this method and checking the `Key.isDown` property directly is that you can provide + * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted + * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it + * will only return `true` every 100ms. + * + * If the Keyboard Plugin has been disabled, this method will always return `false`. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#checkDown + * @since 3.11.0 + * + * @param {Phaser.Input.Keyboard.Key} key - A Key object. + * @param {number} [duration=0] - The duration which must have elapsed before this Key is considered as being down. + * + * @return {boolean} `True` if the Key is down within the duration specified, otherwise `false`. + */ + checkDown: function (key, duration) + { + if (this.enabled && key.isDown) + { + var t = SnapFloor(this.time - key.timeDown, duration); + + if (t > key._tick) + { + key._tick = t; + + return true; + } + } + + return false; + }, + + /** + * Internal update handler called by the Input Manager, which is in turn invoked by the Game step. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#update + * @private + * @since 3.10.0 + * + * @param {number} time - The game loop time value. + */ + update: function (time) + { + this.time = time; + + var len = this.queue.length; + + if (!this.enabled || len === 0) + { + return; + } + + // Clears the queue array, and also means we don't work on array data that could potentially + // be modified during the processing phase + var queue = this.queue.splice(0, len); + + var keys = this.keys; + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + var code = event.keyCode; + + if (event.type === 'keydown') + { + if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false)) + { + // Will emit a keyboard or keyup event + this.emit(event.type, event); + + this.emit('keydown_' + KeyMap[code], event); + } + + if (keys[code]) + { + ProcessKeyDown(keys[code], event); + } + } + else + { + // Will emit a keyboard or keyup event + this.emit(event.type, event); + + this.emit('keyup_' + KeyMap[code], event); + + if (keys[code]) + { + ProcessKeyUp(keys[code], event); + } + } + } + }, + + /** + * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. + * This can only reset keys created via the `addKey`, `addKeys` or `createCursors` methods. + * If you have created a Key object directly you'll need to reset it yourself. + * + * This method is called automatically when the Keyboard Plugin shuts down, but can be + * invoked directly at any time you require. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#resetKeys + * @since 3.15.0 + */ + resetKeys: function () + { + var keys = this.keys; + + for (var i = 0; i < keys.length; i++) + { + // Because it's a sparsely populated array + if (keys[i]) + { + keys[i].reset(); + } + } + + return this; + }, + + /** + * Shuts this Keyboard Plugin down. This performs the following tasks: + * + * 1 - Resets all keys created by this Keyboard plugin. + * 2 - Stops and removes the keyboard event listeners. + * 3 - Clears out any pending requests in the queue, without processing them. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#shutdown + * @private + * @since 3.10.0 + */ + shutdown: function () + { + this.resetKeys(); + + this.stopListeners(); + + this.removeAllListeners(); + + this.queue = []; + }, + + /** + * Destroys this Keyboard Plugin instance and all references it holds, plus clears out local arrays. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#destroy + * @private + * @since 3.10.0 + */ + destroy: function () + { + this.shutdown(); + + this.keys = []; + this.combos = []; + this.queue = []; + + this.scene = null; + this.settings = null; + this.sceneInputPlugin = null; + this.target = null; + } + +}); + +/** + * An instance of the Keyboard Plugin class, if enabled via the `input.keyboard` Scene or Game Config property. + * Use this to create Key objects and listen for keyboard specific events. + * + * @name Phaser.Input.InputPlugin#keyboard + * @type {?Phaser.Input.Keyboard.KeyboardPlugin} + * @since 3.10.0 + */ +InputPluginCache.register('KeyboardPlugin', KeyboardPlugin, 'keyboard', 'keyboard', 'inputKeyboard'); + +module.exports = KeyboardPlugin; + + +/***/ }), +/* 674 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Input.Keyboard + */ + +module.exports = { + + KeyboardPlugin: __webpack_require__(673), + + Key: __webpack_require__(284), + KeyCodes: __webpack_require__(159), + + KeyCombo: __webpack_require__(283), + + JustDown: __webpack_require__(666), + JustUp: __webpack_require__(665), + DownDuration: __webpack_require__(664), + UpDuration: __webpack_require__(663) + +}; + + +/***/ }), +/* 675 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Creates a new Pixel Perfect Handler function. + * + * Access via `InputPlugin.makePixelPerfect` rather than calling it directly. + * + * @function Phaser.Input.CreatePixelPerfectHandler + * @since 3.10.0 + * + * @param {Phaser.Textures.TextureManager} textureManager - A reference to the Texture Manager. + * @param {integer} alphaTolerance - The alpha level that the pixel should be above to be included as a successful interaction. + * + * @return {function} The new Pixel Perfect Handler function. + */ +var CreatePixelPerfectHandler = function (textureManager, alphaTolerance) +{ + return function (hitArea, x, y, gameObject) + { + var alpha = textureManager.getPixelAlpha(x, y, gameObject.texture.key, gameObject.frame.name); + + return (alpha && alpha >= alphaTolerance); + }; +}; + +module.exports = CreatePixelPerfectHandler; + + +/***/ }), +/* 676 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(81); +var CircleContains = __webpack_require__(44); +var Class = __webpack_require__(0); +var CreateInteractiveObject = __webpack_require__(288); +var CreatePixelPerfectHandler = __webpack_require__(675); +var DistanceBetween = __webpack_require__(58); +var Ellipse = __webpack_require__(99); +var EllipseContains = __webpack_require__(98); +var EventEmitter = __webpack_require__(11); +var GetFastValue = __webpack_require__(1); +var InputPluginCache = __webpack_require__(116); +var IsPlainObject = __webpack_require__(8); +var PluginCache = __webpack_require__(15); +var Rectangle = __webpack_require__(10); +var RectangleContains = __webpack_require__(43); +var Triangle = __webpack_require__(66); +var TriangleContains = __webpack_require__(76); + +/** + * @classdesc + * The Input Plugin belongs to a Scene and handles all input related events and operations for it. + * + * You can access it from within a Scene using `this.input`. + * + * It emits events directly. For example, you can do: + * + * ```javascript + * this.input.on('pointerdown', callback, context); + * ``` + * + * To listen for a pointer down event anywhere on the game canvas. + * + * Game Objects can be enabled for input by calling their `setInteractive` method. After which they + * will directly emit input events: + * + * ```javascript + * var sprite = this.add.sprite(x, y, texture); + * sprite.setInteractive(); + * sprite.on('pointerdown', callback, context); + * ``` + * + * Please see the Input examples and tutorials for more information. + * + * @class InputPlugin + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that this Input Plugin is responsible for. + */ +var InputPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function InputPlugin (scene) + { + EventEmitter.call(this); + + /** + * A reference to the Scene that this Input Plugin is responsible for. + * + * @name Phaser.Input.InputPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene Systems class. + * + * @name Phaser.Input.InputPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the Scene Systems Settings. + * + * @name Phaser.Input.InputPlugin#settings + * @type {Phaser.Scenes.Settings.Object} + * @since 3.5.0 + */ + this.settings = scene.sys.settings; + + /** + * A reference to the Game Input Manager. + * + * @name Phaser.Input.InputPlugin#manager + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.manager = scene.sys.game.input; + + /** + * Internal event queue used for plugins only. + * + * @name Phaser.Input.InputPlugin#pluginEvents + * @type {Phaser.Events.EventEmitter} + * @private + * @since 3.10.0 + */ + this.pluginEvents = new EventEmitter(); + + /** + * If set, the Input Plugin will run its update loop every frame. + * + * @name Phaser.Input.InputPlugin#enabled + * @type {boolean} + * @default true + * @since 3.5.0 + */ + this.enabled = true; + + /** + * A reference to the Scene Display List. This property is set during the `boot` method. + * + * @name Phaser.Input.InputPlugin#displayList + * @type {Phaser.GameObjects.DisplayList} + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Cameras Manager. This property is set during the `boot` method. + * + * @name Phaser.Input.InputPlugin#cameras + * @type {Phaser.Cameras.Scene2D.CameraManager} + * @since 3.0.0 + */ + this.cameras; + + // Inject the available input plugins into this class + InputPluginCache.install(this); + + /** + * A reference to the Mouse Manager. + * + * This property is only set if Mouse support has been enabled in your Game Configuration file. + * + * If you just wish to get access to the mouse pointer, use the `mousePointer` property instead. + * + * @name Phaser.Input.InputPlugin#mouse + * @type {?Phaser.Input.Mouse.MouseManager} + * @since 3.0.0 + */ + this.mouse = this.manager.mouse; + + /** + * When set to `true` (the default) the Input Plugin will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + * + * @name Phaser.Input.InputPlugin#topOnly + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.topOnly = true; + + /** + * How often should the Pointers be checked? + * + * The value is a time, given in ms, and is the time that must have elapsed between game steps before + * the Pointers will be polled again. When a pointer is polled it runs a hit test to see which Game + * Objects are currently below it, or being interacted with it. + * + * Pointers will *always* be checked if they have been moved by the user, or press or released. + * + * This property only controls how often they will be polled if they have not been updated. + * You should set this if you want to have Game Objects constantly check against the pointers, even + * if the pointer didn't move itself. + * + * Set to 0 to poll constantly. Set to -1 to only poll on user movement. + * + * @name Phaser.Input.InputPlugin#pollRate + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.pollRate = -1; + + /** + * Internal poll timer value. + * + * @name Phaser.Input.InputPlugin#_pollTimer + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._pollTimer = 0; + + var _eventData = { cancelled: false }; + + /** + * Internal event propagation callback container. + * + * @name Phaser.Input.InputPlugin#_eventContainer + * @type {object} + * @private + * @since 3.13.0 + */ + this._eventContainer = { + stopPropagation: function () + { + _eventData.cancelled = true; + } + }; + + /** + * Internal event propagation data object. + * + * @name Phaser.Input.InputPlugin#_eventData + * @type {object} + * @private + * @since 3.13.0 + */ + this._eventData = _eventData; + + /** + * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. + * + * @name Phaser.Input.InputPlugin#dragDistanceThreshold + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragDistanceThreshold = 0; + + /** + * The amount of time, in ms, a pointer has to be held down before it thinks it is dragging. + * + * @name Phaser.Input.InputPlugin#dragTimeThreshold + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragTimeThreshold = 0; + + /** + * Used to temporarily store the results of the Hit Test + * + * @name Phaser.Input.InputPlugin#_temp + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._temp = []; + + /** + * Used to temporarily store the results of the Hit Test dropZones + * + * @name Phaser.Input.InputPlugin#_tempZones + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._tempZones = []; + + /** + * A list of all Game Objects that have been set to be interactive in the Scene this Input Plugin is managing. + * + * @name Phaser.Input.InputPlugin#_list + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._list = []; + + /** + * Objects waiting to be inserted to the list on the next call to 'begin'. + * + * @name Phaser.Input.InputPlugin#_pendingInsertion + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingInsertion = []; + + /** + * Objects waiting to be removed from the list on the next call to 'begin'. + * + * @name Phaser.Input.InputPlugin#_pendingRemoval + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingRemoval = []; + + /** + * A list of all Game Objects that have been enabled for dragging. + * + * @name Phaser.Input.InputPlugin#_draggable + * @type {Phaser.GameObjects.GameObject[]} + * @private + * @default [] + * @since 3.0.0 + */ + this._draggable = []; + + /** + * A list of all Interactive Objects currently considered as being 'draggable' by any pointer, indexed by pointer ID. + * + * @name Phaser.Input.InputPlugin#_drag + * @type {{0:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array}} + * @private + * @since 3.0.0 + */ + this._drag = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [] }; + + /** + * A list of all Interactive Objects currently considered as being 'over' by any pointer, indexed by pointer ID. + * + * @name Phaser.Input.InputPlugin#_over + * @type {{0:Array,2:Array,3:Array,4:Array,5:Array,6:Array,7:Array,8:Array,9:Array}} + * @private + * @since 3.0.0 + */ + this._over = { 0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [], 7: [], 8: [], 9: [], 10: [] }; + + /** + * A list of valid DOM event types. + * + * @name Phaser.Input.InputPlugin#_validTypes + * @type {string[]} + * @private + * @since 3.0.0 + */ + this._validTypes = [ 'onDown', 'onUp', 'onOver', 'onOut', 'onMove', 'onDragStart', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragLeave', 'onDragOver', 'onDrop' ]; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Input.InputPlugin#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.cameras = this.systems.cameras; + + this.displayList = this.systems.displayList; + + this.systems.events.once('destroy', this.destroy, this); + + // Registered input plugins listen for this + this.pluginEvents.emit('boot'); + }, + + /** + * 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#start + * @private + * @since 3.5.0 + */ + 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.once('shutdown', this.shutdown, this); + + this.enabled = true; + + // Registered input plugins listen for this + this.pluginEvents.emit('start'); + }, + + /** + * The pre-update handler is responsible for checking the pending removal and insertion lists and + * deleting old Game Objects. + * + * @method Phaser.Input.InputPlugin#preUpdate + * @private + * @since 3.0.0 + */ + preUpdate: function () + { + // Registered input plugins listen for this + this.pluginEvents.emit('preUpdate'); + + var removeList = this._pendingRemoval; + var insertList = this._pendingInsertion; + + var toRemove = removeList.length; + var toInsert = insertList.length; + + if (toRemove === 0 && toInsert === 0) + { + // Quick bail + return; + } + + var current = this._list; + + // Delete old gameObjects + for (var i = 0; i < toRemove; i++) + { + var gameObject = removeList[i]; + + var index = current.indexOf(gameObject); + + if (index > -1) + { + current.splice(index, 1); + + this.clear(gameObject); + } + } + + // Clear the removal list + removeList.length = 0; + this._pendingRemoval.length = 0; + + // Move pendingInsertion to list (also clears pendingInsertion at the same time) + this._list = current.concat(insertList.splice(0)); + }, + + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + * + * @method Phaser.Input.InputPlugin#isActive + * @since 3.10.0 + * + * @return {boolean} `true` if the plugin and the Scene it belongs to is active. + */ + isActive: function () + { + return (this.enabled && this.scene.sys.isActive()); + }, + + /** + * The internal update loop for the Input Plugin. + * Called automatically by the Scene Systems step. + * + * @method Phaser.Input.InputPlugin#update + * @private + * @since 3.0.0 + * + * @param {number} time - The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). + * @param {number} delta - The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. + */ + update: function (time, delta) + { + if (!this.isActive()) + { + return; + } + + this.pluginEvents.emit('update', time, delta); + + var manager = this.manager; + + // Another Scene above this one has already consumed the input events, or we're in transition + if (manager.globalTopOnly && manager.ignoreEvents) + { + return; + } + + var runUpdate = (manager.dirty || this.pollRate === 0); + + if (this.pollRate > -1) + { + this._pollTimer -= delta; + + if (this._pollTimer < 0) + { + runUpdate = true; + + // Discard timer diff + this._pollTimer = this.pollRate; + } + } + + if (!runUpdate) + { + return; + } + + var pointers = this.manager.pointers; + + for (var i = 0; i < this.manager.pointersTotal; i++) + { + var pointer = pointers[i]; + + // Always reset this array + this._tempZones = []; + + // _temp contains a hit tested and camera culled list of IO objects + this._temp = this.hitTestPointer(pointer); + + this.sortGameObjects(this._temp); + this.sortGameObjects(this._tempZones); + + if (this.topOnly) + { + // Only the top-most one counts now, so safely ignore the rest + if (this._temp.length) + { + this._temp.splice(1); + } + + if (this._tempZones.length) + { + this._tempZones.splice(1); + } + } + + var total = this.processDragEvents(pointer, time); + + // TODO: Enable for touch + if (!pointer.wasTouch) + { + total += this.processOverOutEvents(pointer); + } + + if (pointer.justDown) + { + total += this.processDownEvents(pointer); + } + + if (pointer.justUp) + { + total += this.processUpEvents(pointer); + } + + if (pointer.justMoved) + { + total += this.processMoveEvents(pointer); + } + + if (total > 0 && manager.globalTopOnly) + { + // We interacted with an event in this Scene, so block any Scenes below us from doing the same this frame + manager.ignoreEvents = true; + } + } + }, + + /** + * Clears a Game Object so it no longer has an Interactive Object associated with it. + * The Game Object is then queued for removal from the Input Plugin on the next update. + * + * @method Phaser.Input.InputPlugin#clear + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will have its Interactive Object removed. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that had its Interactive Object removed. + */ + clear: function (gameObject) + { + var input = gameObject.input; + + // If GameObject.input already cleared from higher class + if (!input) + { + return; + } + + this.queueForRemoval(gameObject); + + input.gameObject = undefined; + input.target = undefined; + input.hitArea = undefined; + input.hitAreaCallback = undefined; + input.callbackContext = undefined; + + this.manager.resetCursor(input); + + gameObject.input = null; + + // Clear from _draggable, _drag and _over + var index = this._draggable.indexOf(gameObject); + + if (index > -1) + { + this._draggable.splice(index, 1); + } + + index = this._drag[0].indexOf(gameObject); + + if (index > -1) + { + this._drag[0].splice(index, 1); + } + + index = this._over[0].indexOf(gameObject); + + if (index > -1) + { + this._over[0].splice(index, 1); + } + + return gameObject; + }, + + /** + * Disables Input on a single Game Object. + * + * An input disabled Game Object still retains its Interactive Object component and can be re-enabled + * at any time, by passing it to `InputPlugin.enable`. + * + * @method Phaser.Input.InputPlugin#disable + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to have its input system disabled. + */ + disable: function (gameObject) + { + gameObject.input.enabled = false; + }, + + /** + * Enable a Game Object for interaction. + * + * If the Game Object already has an Interactive Object component, it is enabled and returned. + * + * Otherwise, a new Interactive Object component is created and assigned to the Game Object's `input` property. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * + * @method Phaser.Input.InputPlugin#enable + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to be enabled for input. + * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area. + * @param {boolean} [dropZone=false] - Is this Game Object a drop zone or not? + * + * @return {Phaser.Input.InputPlugin} This Input Plugin. + */ + enable: function (gameObject, shape, callback, dropZone) + { + if (dropZone === undefined) { dropZone = false; } + + if (gameObject.input) + { + // If it is already has an InteractiveObject then just enable it and return + gameObject.input.enabled = true; + } + else + { + // Create an InteractiveObject and enable it + this.setHitArea(gameObject, shape, callback); + } + + if (gameObject.input && dropZone && !gameObject.input.dropZone) + { + gameObject.input.dropZone = dropZone; + } + + return this; + }, + + /** + * Takes the given Pointer and performs a hit test against it, to see which interactive Game Objects + * it is currently above. + * + * The hit test is performed against which-ever Camera the Pointer is over. If it is over multiple + * cameras, it starts checking the camera at the top of the camera list, and if nothing is found, iterates down the list. + * + * @method Phaser.Input.InputPlugin#hitTestPointer + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check against the Game Objects. + * + * @return {Phaser.GameObjects.GameObject[]} An array of all the interactive Game Objects the Pointer was above. + */ + hitTestPointer: function (pointer) + { + var cameras = this.cameras.getCamerasBelowPointer(pointer); + + for (var c = 0; c < cameras.length; c++) + { + var camera = cameras[c]; + + // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'over' array. + // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. + var over = this.manager.hitTest(pointer, this._list, camera); + + // Filter out the drop zones + for (var i = 0; i < over.length; i++) + { + var obj = over[i]; + + if (obj.input.dropZone) + { + this._tempZones.push(obj); + } + } + + if (over.length > 0) + { + pointer.camera = camera; + + return over; + } + } + + // If we got this far then there were no Game Objects below the pointer, but it was still over + // a camera, so set that the top-most one into the pointer + + pointer.camera = cameras[0]; + + return []; + }, + + /** + * An internal method that handles the Pointer down event. + * + * @method Phaser.Input.InputPlugin#processDownEvents + * @private + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer being tested. + * + * @return {integer} The total number of objects interacted with. + */ + processDownEvents: function (pointer) + { + var total = 0; + var currentlyOver = this._temp; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input) + { + continue; + } + + total++; + + gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectdown', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + // Contains ALL Game Objects currently over in the array + if (!aborted) + { + this.emit('pointerdown', pointer, currentlyOver); + } + + return total; + }, + + /** + * An internal method that handles the Pointer drag events. + * + * @method Phaser.Input.InputPlugin#processDragEvents + * @private + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check against the Game Objects. + * @param {number} time - The time stamp of the most recent Game step. + * + * @return {integer} The total number of objects interacted with. + */ + processDragEvents: function (pointer, time) + { + if (this._draggable.length === 0) + { + // There are no draggable items, so let's not even bother going further + return 0; + } + + var i; + var gameObject; + var list; + var input; + var currentlyOver = this._temp; + + // 0 = Not dragging anything + // 1 = Primary button down and objects below, so collect a draglist + // 2 = Pointer being checked if meets drag criteria + // 3 = Pointer meets criteria, notify the draglist + // 4 = Pointer actively dragging the draglist and has moved + // 5 = Pointer actively dragging but has been released, notify draglist + + if (pointer.dragState === 0 && pointer.primaryDown && pointer.justDown && currentlyOver.length > 0) + { + pointer.dragState = 1; + } + else if (pointer.dragState > 0 && !pointer.primaryDown && pointer.justUp) + { + pointer.dragState = 5; + } + + // Process the various drag states + + // 1 = Primary button down and objects below, so collect a draglist + if (pointer.dragState === 1) + { + // Get draggable objects, sort them, pick the top (or all) and store them somewhere + var draglist = []; + + for (i = 0; i < currentlyOver.length; i++) + { + gameObject = currentlyOver[i]; + + if (gameObject.input.draggable && (gameObject.input.dragState === 0)) + { + draglist.push(gameObject); + } + } + + if (draglist.length === 0) + { + pointer.dragState = 0; + + return 0; + } + else if (draglist.length > 1) + { + this.sortGameObjects(draglist); + + if (this.topOnly) + { + draglist.splice(1); + } + } + + // draglist now contains all potential candidates for dragging + this._drag[pointer.id] = draglist; + + if (this.dragDistanceThreshold === 0 && this.dragTimeThreshold === 0) + { + // No drag criteria, so snap immediately to mode 3 + pointer.dragState = 3; + } + else + { + // Check the distance / time + pointer.dragState = 2; + } + } + + // 2 = Pointer being checked if meets drag criteria + if (pointer.dragState === 2) + { + // Has it moved far enough to be considered a drag? + if (this.dragDistanceThreshold > 0 && DistanceBetween(pointer.x, pointer.y, pointer.downX, pointer.downY) >= this.dragDistanceThreshold) + { + // Alrighty, we've got a drag going on ... + pointer.dragState = 3; + } + + // Held down long enough to be considered a drag? + if (this.dragTimeThreshold > 0 && (time >= pointer.downTime + this.dragTimeThreshold)) + { + // Alrighty, we've got a drag going on ... + pointer.dragState = 3; + } + } + + // 3 = Pointer meets criteria and is freshly down, notify the draglist + if (pointer.dragState === 3) + { + list = this._drag[pointer.id]; + + for (i = 0; i < list.length; i++) + { + gameObject = list[i]; + + input = gameObject.input; + + input.dragState = 2; + + input.dragX = pointer.x - gameObject.x; + input.dragY = pointer.y - gameObject.y; + + input.dragStartX = gameObject.x; + input.dragStartY = gameObject.y; + + gameObject.emit('dragstart', pointer, input.dragX, input.dragY); + + this.emit('dragstart', pointer, gameObject); + } + + pointer.dragState = 4; + + return list.length; + } + + // 4 = Pointer actively dragging the draglist and has moved + if (pointer.dragState === 4 && pointer.justMoved && !pointer.justUp) + { + var dropZones = this._tempZones; + + list = this._drag[pointer.id]; + + for (i = 0; i < list.length; i++) + { + gameObject = list[i]; + + input = gameObject.input; + + // If this GO has a target then let's check it + if (input.target) + { + var index = dropZones.indexOf(input.target); + + // Got a target, are we still over it? + if (index === 0) + { + // We're still over it, and it's still the top of the display list, phew ... + gameObject.emit('dragover', pointer, input.target); + + this.emit('dragover', pointer, gameObject, input.target); + } + else if (index > 0) + { + // Still over it but it's no longer top of the display list (targets must always be at the top) + gameObject.emit('dragleave', pointer, input.target); + + this.emit('dragleave', pointer, gameObject, input.target); + + input.target = dropZones[0]; + + gameObject.emit('dragenter', pointer, input.target); + + this.emit('dragenter', pointer, gameObject, input.target); + } + else + { + // Nope, we've moved on (or the target has!), leave the old target + gameObject.emit('dragleave', pointer, input.target); + + this.emit('dragleave', pointer, gameObject, input.target); + + // Anything new to replace it? + // Yup! + if (dropZones[0]) + { + input.target = dropZones[0]; + + gameObject.emit('dragenter', pointer, input.target); + + this.emit('dragenter', pointer, gameObject, input.target); + } + else + { + // Nope + input.target = null; + } + } + } + else if (!input.target && dropZones[0]) + { + input.target = dropZones[0]; + + gameObject.emit('dragenter', pointer, input.target); + + this.emit('dragenter', pointer, gameObject, input.target); + } + + var dragX = pointer.x - gameObject.input.dragX; + var dragY = pointer.y - gameObject.input.dragY; + + gameObject.emit('drag', pointer, dragX, dragY); + + this.emit('drag', pointer, gameObject, dragX, dragY); + } + + return list.length; + } + + // 5 = Pointer was actively dragging but has been released, notify draglist + if (pointer.dragState === 5) + { + list = this._drag[pointer.id]; + + for (i = 0; i < list.length; i++) + { + gameObject = list[i]; + + input = gameObject.input; + + if (input.dragState === 2) + { + input.dragState = 0; + + input.dragX = input.localX - gameObject.displayOriginX; + input.dragY = input.localY - gameObject.displayOriginY; + + var dropped = false; + + if (input.target) + { + gameObject.emit('drop', pointer, input.target); + + this.emit('drop', pointer, gameObject, input.target); + + input.target = null; + + dropped = true; + } + + // And finally the dragend event + + gameObject.emit('dragend', pointer, input.dragX, input.dragY, dropped); + + this.emit('dragend', pointer, gameObject, dropped); + } + } + + pointer.dragState = 0; + + list.splice(0); + } + + return 0; + }, + + /** + * An internal method that handles the Pointer movement event. + * + * @method Phaser.Input.InputPlugin#processMoveEvents + * @private + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {integer} The total number of objects interacted with. + */ + processMoveEvents: function (pointer) + { + var total = 0; + var currentlyOver = this._temp; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input) + { + continue; + } + + total++; + + gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectmove', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + if (this.topOnly) + { + break; + } + } + + if (!aborted) + { + this.emit('pointermove', pointer, currentlyOver); + } + + return total; + }, + + /** + * An internal method that handles the Pointer over and out events. + * + * @method Phaser.Input.InputPlugin#processOverOutEvents + * @private + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {integer} The total number of objects interacted with. + */ + processOverOutEvents: function (pointer) + { + var currentlyOver = this._temp; + + var i; + var gameObject; + var justOut = []; + var justOver = []; + var stillOver = []; + var previouslyOver = this._over[pointer.id]; + var currentlyDragging = this._drag[pointer.id]; + + var manager = this.manager; + + // Go through all objects the pointer was previously over, and see if it still is. + // Splits the previouslyOver array into two parts: justOut and stillOver + + for (i = 0; i < previouslyOver.length; i++) + { + gameObject = previouslyOver[i]; + + if (currentlyOver.indexOf(gameObject) === -1 && currentlyDragging.indexOf(gameObject) === -1) + { + // Not in the currentlyOver array, so must be outside of this object now + justOut.push(gameObject); + } + else + { + // In the currentlyOver array + stillOver.push(gameObject); + } + } + + // Go through all objects the pointer is currently over (the hit test results) + // and if not in the previouslyOver array we know it's a new entry, so add to justOver + for (i = 0; i < currentlyOver.length; i++) + { + gameObject = currentlyOver[i]; + + // Is this newly over? + + if (previouslyOver.indexOf(gameObject) === -1) + { + justOver.push(gameObject); + } + } + + // By this point the arrays are filled, so now we can process what happened... + + // Process the Just Out objects + var total = justOut.length; + + var totalInteracted = 0; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; + + if (total > 0) + { + this.sortGameObjects(justOut); + + // Call onOut for everything in the justOut array + for (i = 0; i < total; i++) + { + gameObject = justOut[i]; + + if (!gameObject.input) + { + continue; + } + + gameObject.emit('pointerout', pointer, _eventContainer); + + manager.resetCursor(gameObject.input); + + totalInteracted++; + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectout', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + this.emit('pointerout', pointer, justOut); + } + } + + // Process the Just Over objects + total = justOver.length; + + _eventData.cancelled = false; + + aborted = false; + + if (total > 0) + { + this.sortGameObjects(justOver); + + // Call onOver for everything in the justOver array + for (i = 0; i < total; i++) + { + gameObject = justOver[i]; + + if (!gameObject.input) + { + continue; + } + + gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + manager.setCursor(gameObject.input); + + totalInteracted++; + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectover', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + this.emit('pointerover', pointer, justOver); + } + } + + // Add the contents of justOver to the previously over array + previouslyOver = stillOver.concat(justOver); + + // Then sort it into display list order + this._over[pointer.id] = this.sortGameObjects(previouslyOver); + + return totalInteracted; + }, + + /** + * An internal method that handles the Pointer up events. + * + * @method Phaser.Input.InputPlugin#processUpEvents + * @private + * @since 3.0.0 + * + * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. + * + * @return {integer} The total number of objects interacted with. + */ + processUpEvents: function (pointer) + { + var currentlyOver = this._temp; + + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; + + // Go through all objects the pointer was over and fire their events / callbacks + for (var i = 0; i < currentlyOver.length; i++) + { + var gameObject = currentlyOver[i]; + + if (!gameObject.input) + { + continue; + } + + // pointerupoutside + + gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectup', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + // Contains ALL Game Objects currently up in the array + this.emit('pointerup', pointer, currentlyOver); + } + + return currentlyOver.length; + }, + + /** + * Queues a Game Object for insertion into this Input Plugin on the next update. + * + * @method Phaser.Input.InputPlugin#queueForInsertion + * @private + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to add. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + queueForInsertion: function (child) + { + if (this._pendingInsertion.indexOf(child) === -1 && this._list.indexOf(child) === -1) + { + this._pendingInsertion.push(child); + } + + return this; + }, + + /** + * Queues a Game Object for removal from this Input Plugin on the next update. + * + * @method Phaser.Input.InputPlugin#queueForRemoval + * @private + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to remove. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + queueForRemoval: function (child) + { + this._pendingRemoval.push(child); + + return this; + }, + + /** + * Sets the draggable state of the given array of Game Objects. + * + * They can either be set to be draggable, or can have their draggable state removed by passing `false`. + * + * A Game Object will not fire drag events unless it has been specifically enabled for drag. + * + * @method Phaser.Input.InputPlugin#setDraggable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to change the draggable state on. + * @param {boolean} [value=true] - Set to `true` if the Game Objects should be made draggable, `false` if they should be unset. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setDraggable: function (gameObjects, value) + { + if (value === undefined) { value = true; } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + gameObject.input.draggable = value; + + var index = this._draggable.indexOf(gameObject); + + if (value && index === -1) + { + this._draggable.push(gameObject); + } + else if (!value && index > -1) + { + this._draggable.splice(index, 1); + } + } + + return this; + }, + + /** + * Creates a function that can be passed to `setInteractive`, `enable` or `setHitArea` that will handle + * pixel-perfect input detection on an Image or Sprite based Game Object, or any custom class that extends them. + * + * The following will create a sprite that is clickable on any pixel that has an alpha value >= 1. + * + * ```javascript + * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect()); + * ``` + * + * The following will create a sprite that is clickable on any pixel that has an alpha value >= 150. + * + * ```javascript + * this.add.sprite(x, y, key).setInteractive(this.input.makePixelPerfect(150)); + * ``` + * + * Once you have made an Interactive Object pixel perfect it impacts all input related events for it: down, up, + * dragstart, drag, etc. + * + * As a pointer interacts with the Game Object it will constantly poll the texture, extracting a single pixel from + * the given coordinates and checking its color values. This is an expensive process, so should only be enabled on + * Game Objects that really need it. + * + * You cannot make non-texture based Game Objects pixel perfect. So this will not work on Graphics, BitmapText, + * Render Textures, Text, Tilemaps, Containers or Particles. + * + * @method Phaser.Input.InputPlugin#makePixelPerfect + * @since 3.10.0 + * + * @param {integer} [alphaTolerance=1] - The alpha level that the pixel should be above to be included as a successful interaction. + * + * @return {function} A Pixel Perfect Handler for use as a hitArea shape callback. + */ + makePixelPerfect: function (alphaTolerance) + { + if (alphaTolerance === undefined) { alphaTolerance = 1; } + + var textureManager = this.systems.textures; + + return CreatePixelPerfectHandler(textureManager, alphaTolerance); + }, + + /** + * @typedef {object} Phaser.Input.InputConfiguration + * + * @property {any} [hitArea] - The object / shape to use as the Hit Area. If not given it will try to create a Rectangle based on the texture frame. + * @property {function} [hitAreaCallback] - The callback that determines if the pointer is within the Hit Area shape or not. + * @property {boolean} [draggable=false] - If `true` the Interactive Object will be set to be draggable and emit drag events. + * @property {boolean} [dropZone=false] - If `true` the Interactive Object will be set to be a drop zone for draggable objects. + * @property {boolean} [useHandCursor=false] - If `true` the Interactive Object will set the `pointer` hand cursor when a pointer is over it. This is a short-cut for setting `cursor: 'pointer'`. + * @property {string} [cursor] - The CSS string to be used when the cursor is over this Interactive Object. + * @property {boolean} [pixelPerfect=false] - If `true` the a pixel perfect function will be set for the hit area callback. Only works with texture based Game Objects. + * @property {integer} [alphaTolerance=1] - If `pixelPerfect` is set, this is the alpha tolerance threshold value used in the callback. + */ + + /** + * Sets the hit area for the given array of Game Objects. + * + * A hit area is typically one of the geometric shapes Phaser provides, such as a `Phaser.Geom.Rectangle` + * or `Phaser.Geom.Circle`. However, it can be any object as long as it works with the provided callback. + * + * If no hit area is provided a Rectangle is created based on the size of the Game Object, if possible + * to calculate. + * + * The hit area callback is the function that takes an `x` and `y` coordinate and returns a boolean if + * those values fall within the area of the shape or not. All of the Phaser geometry objects provide this, + * such as `Phaser.Geom.Rectangle.Contains`. + * + * @method Phaser.Input.InputPlugin#setHitArea + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set the hit area on. + * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} [callback] - The 'contains' function to invoke to check if the pointer is within the hit area. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitArea: function (gameObjects, shape, callback) + { + if (shape === undefined) + { + return this.setHitAreaFromTexture(gameObjects); + } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + var draggable = false; + var dropZone = false; + var cursor = false; + var useHandCursor = false; + + // Config object? + if (IsPlainObject(shape)) + { + var config = shape; + + shape = GetFastValue(config, 'hitArea', null); + callback = GetFastValue(config, 'hitAreaCallback', null); + draggable = GetFastValue(config, 'draggable', false); + dropZone = GetFastValue(config, 'dropZone', false); + cursor = GetFastValue(config, 'cursor', false); + useHandCursor = GetFastValue(config, 'useHandCursor', false); + + var pixelPerfect = GetFastValue(config, 'pixelPerfect', false); + var alphaTolerance = GetFastValue(config, 'alphaTolerance', 1); + + if (pixelPerfect) + { + shape = {}; + callback = this.makePixelPerfect(alphaTolerance); + } + + // Still no hitArea or callback? + if (!shape || !callback) + { + this.setHitAreaFromTexture(gameObjects); + } + } + else if (typeof shape === 'function' && !callback) + { + callback = shape; + shape = {}; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + var io = (!gameObject.input) ? CreateInteractiveObject(gameObject, shape, callback) : gameObject.input; + + io.dropZone = dropZone; + io.cursor = (useHandCursor) ? 'pointer' : cursor; + + gameObject.input = io; + + if (draggable) + { + this.setDraggable(gameObject); + } + + this.queueForInsertion(gameObject); + } + + return this; + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Circle` shape, using + * the given coordinates and radius to control its position and size. + * + * @method Phaser.Input.InputPlugin#setHitAreaCircle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a circle hit area. + * @param {number} x - The center of the circle. + * @param {number} y - The center of the circle. + * @param {number} radius - The radius of the circle. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Circle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaCircle: function (gameObjects, x, y, radius, callback) + { + if (callback === undefined) { callback = CircleContains; } + + var shape = new Circle(x, y, radius); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Ellipse` shape, using + * the given coordinates and dimensions to control its position and size. + * + * @method Phaser.Input.InputPlugin#setHitAreaEllipse + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area. + * @param {number} x - The center of the ellipse. + * @param {number} y - The center of the ellipse. + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Ellipse.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaEllipse: function (gameObjects, x, y, width, height, callback) + { + if (callback === undefined) { callback = EllipseContains; } + + var shape = new Ellipse(x, y, width, height); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using + * the Game Objects texture frame to define the position and size of the hit area. + * + * @method Phaser.Input.InputPlugin#setHitAreaFromTexture + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having an ellipse hit area. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaFromTexture: function (gameObjects, callback) + { + if (callback === undefined) { callback = RectangleContains; } + + if (!Array.isArray(gameObjects)) + { + gameObjects = [ gameObjects ]; + } + + for (var i = 0; i < gameObjects.length; i++) + { + var gameObject = gameObjects[i]; + + var frame = gameObject.frame; + + var width = 0; + var height = 0; + + if (frame) + { + width = frame.realWidth; + height = frame.realHeight; + } + else if (gameObject.width) + { + width = gameObject.width; + height = gameObject.height; + } + + if (gameObject.type === 'Container' && (width === 0 || height === 0)) + { + console.warn('Container.setInteractive() must specify a Shape or call setSize() first'); + continue; + } + + if (width !== 0 && height !== 0) + { + gameObject.input = CreateInteractiveObject(gameObject, new Rectangle(0, 0, width, height), callback); + + this.queueForInsertion(gameObject); + } + } + + return this; + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Rectangle` shape, using + * the given coordinates and dimensions to control its position and size. + * + * @method Phaser.Input.InputPlugin#setHitAreaRectangle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a rectangular hit area. + * @param {number} x - The top-left of the rectangle. + * @param {number} y - The top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Rectangle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaRectangle: function (gameObjects, x, y, width, height, callback) + { + if (callback === undefined) { callback = RectangleContains; } + + var shape = new Rectangle(x, y, width, height); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * Sets the hit area for an array of Game Objects to be a `Phaser.Geom.Triangle` shape, using + * the given coordinates to control the position of its points. + * + * @method Phaser.Input.InputPlugin#setHitAreaTriangle + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObjects - An array of Game Objects to set as having a triangular hit area. + * @param {number} x1 - The x coordinate of the first point of the triangle. + * @param {number} y1 - The y coordinate of the first point of the triangle. + * @param {number} x2 - The x coordinate of the second point of the triangle. + * @param {number} y2 - The y coordinate of the second point of the triangle. + * @param {number} x3 - The x coordinate of the third point of the triangle. + * @param {number} y3 - The y coordinate of the third point of the triangle. + * @param {HitAreaCallback} [callback] - The hit area callback. If undefined it uses Triangle.Contains. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setHitAreaTriangle: function (gameObjects, x1, y1, x2, y2, x3, y3, callback) + { + if (callback === undefined) { callback = TriangleContains; } + + var shape = new Triangle(x1, y1, x2, y2, x3, y3); + + return this.setHitArea(gameObjects, shape, callback); + }, + + /** + * Sets the Pointers to always poll. + * + * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, + * or being interacted with it, regardless if the Pointer has actually moved or not. + * + * You should enable this if you want objects in your game to fire over / out events, and the objects + * are constantly moving, but the pointer may not have. Polling every frame has additional computation + * costs, especially if there are a large number of interactive objects in your game. + * + * @method Phaser.Input.InputPlugin#setPollAlways + * @since 3.0.0 + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setPollAlways: function () + { + this.pollRate = 0; + this._pollTimer = 0; + + return this; + }, + + /** + * Sets the Pointers to only poll when they are moved or updated. + * + * When a pointer is polled it runs a hit test to see which Game Objects are currently below it, + * or being interacted with it. + * + * @method Phaser.Input.InputPlugin#setPollOnMove + * @since 3.0.0 + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setPollOnMove: function () + { + this.pollRate = -1; + this._pollTimer = 0; + + return this; + }, + + /** + * Sets the poll rate value. This is the amount of time that should have elapsed before a pointer + * will be polled again. See the `setPollAlways` and `setPollOnMove` methods. + * + * @method Phaser.Input.InputPlugin#setPollRate + * @since 3.0.0 + * + * @param {number} value - The amount of time, in ms, that should elapsed before re-polling the pointers. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setPollRate: function (value) + { + this.pollRate = value; + this._pollTimer = 0; + + return this; + }, + + /** + * When set to `true` the global Input Manager will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + * + * @method Phaser.Input.InputPlugin#setGlobalTopOnly + * @since 3.0.0 + * + * @param {boolean} value - `true` to only include the top-most Game Object, or `false` to include all Game Objects in a hit test. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setGlobalTopOnly: function (value) + { + this.manager.globalTopOnly = value; + + return this; + }, + + /** + * When set to `true` this Input Plugin will emulate DOM behavior by only emitting events from + * the top-most Game Objects in the Display List. + * + * If set to `false` it will emit events from all Game Objects below a Pointer, not just the top one. + * + * @method Phaser.Input.InputPlugin#setTopOnly + * @since 3.0.0 + * + * @param {boolean} value - `true` to only include the top-most Game Object, or `false` to include all Game Objects in a hit test. + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + setTopOnly: function (value) + { + this.topOnly = value; + + return this; + }, + + /** + * Given an array of Game Objects, sort the array and return it, so that the objects are in depth index order + * with the lowest at the bottom. + * + * @method Phaser.Input.InputPlugin#sortGameObjects + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - An array of Game Objects to be sorted. + * + * @return {Phaser.GameObjects.GameObject[]} The sorted array of Game Objects. + */ + sortGameObjects: function (gameObjects) + { + if (gameObjects.length < 2) + { + return gameObjects; + } + + this.scene.sys.depthSort(); + + return gameObjects.sort(this.sortHandlerGO.bind(this)); + }, + + /** + * Return the child lowest down the display list (with the smallest index) + * Will iterate through all parent containers, if present. + * + * @method Phaser.Input.InputPlugin#sortHandlerGO + * @private + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} childA - The first Game Object to compare. + * @param {Phaser.GameObjects.GameObject} childB - The second Game Object to compare. + * + * @return {integer} Returns either a negative or positive integer, or zero if they match. + */ + sortHandlerGO: function (childA, childB) + { + if (!childA.parentContainer && !childB.parentContainer) + { + // Quick bail out when neither child has a container + return this.displayList.getIndex(childB) - this.displayList.getIndex(childA); + } + else if (childA.parentContainer === childB.parentContainer) + { + // Quick bail out when both children have the same container + return childB.parentContainer.getIndex(childB) - childA.parentContainer.getIndex(childA); + } + else if (childA.parentContainer === childB) + { + // Quick bail out when childA is a child of childB + return -1; + } + else if (childB.parentContainer === childA) + { + // Quick bail out when childA is a child of childB + return 1; + } + else + { + // Container index check + var listA = childA.getIndexList(); + var listB = childB.getIndexList(); + var len = Math.min(listA.length, listB.length); + + for (var i = 0; i < len; i++) + { + var indexA = listA[i]; + var indexB = listB[i]; + + if (indexA === indexB) + { + // Go to the next level down + continue; + } + else + { + // Non-matching parents, so return + return indexB - indexA; + } + } + } + + // Technically this shouldn't happen, but ... + return 0; + }, + + /** + * Causes the Input Manager to stop emitting any events for the remainder of this game step. + * + * @method Phaser.Input.InputPlugin#stopPropagation + * @since 3.0.0 + * + * @return {Phaser.Input.InputPlugin} This InputPlugin object. + */ + stopPropagation: function () + { + if (this.manager.globalTopOnly) + { + this.manager.ignoreEvents = true; + } + + return this; + }, + + /** + * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is released, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * + * @method Phaser.Input.InputPlugin#addUpCallback + * @since 3.10.0 + * + * @param {function} callback - The callback to be invoked on this DOM event. + * @param {boolean} [isOnce=true] - `true` if the callback will only be invoked once, `false` to call every time this event happens. + * + * @return {this} The Input Plugin. + */ + addUpCallback: function (callback, isOnce) + { + this.manager.addUpCallback(callback, isOnce); + + return this; + }, + + /** + * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is down, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * + * @method Phaser.Input.InputPlugin#addDownCallback + * @since 3.10.0 + * + * @param {function} callback - The callback to be invoked on this dom event. + * @param {boolean} [isOnce=true] - `true` if the callback will only be invoked once, `false` to call every time this event happens. + * + * @return {this} The Input Plugin. + */ + addDownCallback: function (callback, isOnce) + { + this.manager.addDownCallback(callback, isOnce); + + return this; + }, + + /** + * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. + * By setting the `isOnce` argument you can control if the callback is called once, + * or every time the DOM event occurs. + * + * Callbacks passed to this method are invoked _immediately_ when the DOM event happens, + * within the scope of the DOM event handler. Therefore, they are considered as 'native' + * from the perspective of the browser. This means they can be used for tasks such as + * opening new browser windows, or anything which explicitly requires user input to activate. + * However, as a result of this, they come with their own risks, and as such should not be used + * for general game input, but instead be reserved for special circumstances. + * + * If all you're trying to do is execute a callback when a pointer is moved, then + * please use the internal Input event system instead. + * + * Please understand that these callbacks are invoked when the browser feels like doing so, + * which may be entirely out of the normal flow of the Phaser Game Loop. Therefore, you should absolutely keep + * Phaser related operations to a minimum in these callbacks. For example, don't destroy Game Objects, + * change Scenes or manipulate internal systems, otherwise you run a very real risk of creating + * heisenbugs (https://en.wikipedia.org/wiki/Heisenbug) that prove a challenge to reproduce, never mind + * solve. + * + * @method Phaser.Input.InputPlugin#addMoveCallback + * @since 3.10.0 + * + * @param {function} callback - The callback to be invoked on this dom event. + * @param {boolean} [isOnce=false] - `true` if the callback will only be invoked once, `false` to call every time this event happens. + * + * @return {this} The Input Plugin. + */ + addMoveCallback: function (callback, isOnce) + { + this.manager.addMoveCallback(callback, isOnce); + + return this; + }, + + /** + * Adds new Pointer objects to the Input Manager. + * + * By default Phaser creates 2 pointer objects: `mousePointer` and `pointer1`. + * + * You can create more either by calling this method, or by setting the `input.activePointers` property + * in the Game Config, up to a maximum of 10 pointers. + * + * The first 10 pointers are available via the `InputPlugin.pointerX` properties, once they have been added + * via this method. + * + * @method Phaser.Input.InputPlugin#addPointer + * @since 3.10.0 + * + * @param {integer} [quantity=1] The number of new Pointers to create. A maximum of 10 is allowed in total. + * + * @return {Phaser.Input.Pointer[]} An array containing all of the new Pointer objects that were created. + */ + addPointer: function (quantity) + { + return this.manager.addPointer(quantity); + }, + + /** + * Tells the Input system to set a custom cursor. + * + * This cursor will be the default cursor used when interacting with the game canvas. + * + * If an Interactive Object also sets a custom cursor, this is the cursor that is reset after its use. + * + * Any valid CSS cursor value is allowed, including paths to image files, i.e.: + * + * ```javascript + * this.input.setDefaultCursor('url(assets/cursors/sword.cur), pointer'); + * ``` + * + * Please read about the differences between browsers when it comes to the file formats and sizes they support: + * + * https://developer.mozilla.org/en-US/docs/Web/CSS/cursor + * https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_User_Interface/Using_URL_values_for_the_cursor_property + * + * It's up to you to pick a suitable cursor format that works across the range of browsers you need to support. + * + * @method Phaser.Input.InputPlugin#setDefaultCursor + * @since 3.10.0 + * + * @param {string} cursor - The CSS to be used when setting the default cursor. + * + * @return {Phaser.Input.InputPlugin} This Input instance. + */ + setDefaultCursor: function (cursor) + { + this.manager.setDefaultCursor(cursor); + + return this; + }, + + /** + * 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 () + { + // Registered input plugins listen for this + this.pluginEvents.emit('shutdown'); + + this._temp.length = 0; + this._list.length = 0; + this._draggable.length = 0; + this._pendingRemoval.length = 0; + this._pendingInsertion.length = 0; + + for (var i = 0; i < 10; i++) + { + this._drag[i] = []; + this._over[i] = []; + } + + 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); + }, + + /** + * 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(); + + // Registered input plugins listen for this + this.pluginEvents.emit('destroy'); + + this.pluginEvents.removeAllListeners(); + + this.scene.sys.events.off('start', this.start, this); + + this.scene = null; + this.cameras = null; + this.manager = null; + this.events = null; + this.mouse = null; + }, + + /** + * The x coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + * + * @name Phaser.Input.InputPlugin#x + * @type {number} + * @readonly + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.manager.activePointer.x; + } + + }, + + /** + * The y coordinates of the ActivePointer based on the first camera in the camera list. + * This is only safe to use if your game has just 1 non-transformed camera and doesn't use multi-touch. + * + * @name Phaser.Input.InputPlugin#y + * @type {number} + * @readonly + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.manager.activePointer.y; + } + + }, + + /** + * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. + * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` + * which will always map to the most recently interacted pointer. + * + * @name Phaser.Input.InputPlugin#mousePointer + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + mousePointer: { + + get: function () + { + return this.manager.mousePointer; + } + + }, + + /** + * The current active input Pointer. + * + * @name Phaser.Input.InputPlugin#activePointer + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.0.0 + */ + activePointer: { + + get: function () + { + return this.manager.activePointer; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer1 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer1: { + + get: function () + { + return this.manager.pointers[1]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer2 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer2: { + + get: function () + { + return this.manager.pointers[2]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer3 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer3: { + + get: function () + { + return this.manager.pointers[3]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer4 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer4: { + + get: function () + { + return this.manager.pointers[4]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer5 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer5: { + + get: function () + { + return this.manager.pointers[5]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer6 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer6: { + + get: function () + { + return this.manager.pointers[6]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer7 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer7: { + + get: function () + { + return this.manager.pointers[7]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer8 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer8: { + + get: function () + { + return this.manager.pointers[8]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer9 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer9: { + + get: function () + { + return this.manager.pointers[9]; + } + + }, + + /** + * A touch-based Pointer object. + * This will be `undefined` by default unless you add a new Pointer using `addPointer`. + * + * @name Phaser.Input.InputPlugin#pointer10 + * @type {Phaser.Input.Pointer} + * @readonly + * @since 3.10.0 + */ + pointer10: { + + get: function () + { + return this.manager.pointers[10]; + } + + } + +}); + +PluginCache.register('InputPlugin', InputPlugin, 'input'); + +module.exports = InputPlugin; + + +/***/ }), +/* 677 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * XBox 360 Gamepad Configuration. + * + * @name Phaser.Input.Gamepad.Configs.XBOX_360 + * @type {object} + * @since 3.0.0 + */ +module.exports = { + + UP: 12, + DOWN: 13, + LEFT: 14, + RIGHT: 15, + + MENU: 16, + + A: 0, + B: 1, + X: 2, + Y: 3, + + LB: 4, + RB: 5, + + LT: 6, + RT: 7, + + BACK: 8, + START: 9, + + LS: 10, + RS: 11, + + LEFT_STICK_H: 0, + LEFT_STICK_V: 1, + RIGHT_STICK_H: 2, + RIGHT_STICK_V: 3 + +}; + + +/***/ }), +/* 678 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Tatar SNES USB Controller Gamepad Configuration. + * USB Gamepad (STANDARD GAMEPAD Vendor: 0079 Product: 0011) + * + * @name Phaser.Input.Gamepad.Configs.SNES_USB + * @type {object} + * @since 3.0.0 + */ +module.exports = { + + UP: 12, + DOWN: 13, + LEFT: 14, + RIGHT: 15, + + SELECT: 8, + START: 9, + + B: 0, + A: 1, + Y: 2, + X: 3, + + LEFT_SHOULDER: 4, + RIGHT_SHOULDER: 5 + +}; + + +/***/ }), +/* 679 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * PlayStation DualShock 4 Gamepad Configuration. + * Sony PlayStation DualShock 4 (v2) wireless controller + * + * @name Phaser.Input.Gamepad.Configs.DUALSHOCK_4 + * @type {object} + * @since 3.0.0 + */ +module.exports = { + + UP: 12, + DOWN: 13, + LEFT: 14, + RIGHT: 15, + + SHARE: 8, + OPTIONS: 9, + PS: 16, + TOUCHBAR: 17, + + X: 0, + CIRCLE: 1, + SQUARE: 2, + TRIANGLE: 3, + + L1: 4, + R1: 5, + L2: 6, + R2: 7, + L3: 10, + R3: 11, + + LEFT_STICK_H: 0, + LEFT_STICK_V: 1, + RIGHT_STICK_H: 2, + RIGHT_STICK_V: 3 + +}; + + +/***/ }), +/* 680 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Input.Gamepad.Configs + */ + +module.exports = { + + DUALSHOCK_4: __webpack_require__(679), + SNES_USB: __webpack_require__(678), + XBOX_360: __webpack_require__(677) + +}; + + +/***/ }), +/* 681 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var Gamepad = __webpack_require__(285); +var GetValue = __webpack_require__(4); +var InputPluginCache = __webpack_require__(116); + +/** + * @typedef {object} Pad + * + * @property {string} id - The ID of the Gamepad. + * @property {integer} index - The index of the Gamepad. + */ + +/** + * @classdesc + * The Gamepad Plugin is an input plugin that belongs to the Scene-owned Input system. + * + * Its role is to listen for native DOM Gamepad Events and then process them. + * + * You do not need to create this class directly, the Input system will create an instance of it automatically. + * + * You can access it from within a Scene using `this.input.gamepad`. + * + * To listen for a gamepad being connected: + * + * ```javascript + * this.input.gamepad.once('connected', function (pad) { + * // 'pad' is a reference to the gamepad that was just connected + * }); + * ``` + * + * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, + * this is for security reasons. However, it may also trust the page already, in which case you won't get the + * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads + * already connected. + * + * Once you have received the connected event, or polled the gamepads and found them enabled, you can access + * them via the built-in properties `GamepadPlugin.pad1` to `pad4`, for up to 4 game pads. With a reference + * to the gamepads you can poll its buttons and axis sticks. See the properties and methods available on + * the `Gamepad` class for more details. + * + * For more information about Gamepad support in browsers see the following resources: + * + * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API + * https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API + * https://www.smashingmagazine.com/2015/11/gamepad-api-in-web-games/ + * http://html5gamepad.com/ + * + * @class GamepadPlugin + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input.Gamepad + * @constructor + * @since 3.10.0 + * + * @param {Phaser.Input.InputPlugin} sceneInputPlugin - A reference to the Scene Input Plugin that the KeyboardPlugin belongs to. + */ +var GamepadPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function GamepadPlugin (sceneInputPlugin) + { + EventEmitter.call(this); + + /** + * A reference to the Scene that this Input Plugin is responsible for. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#scene + * @type {Phaser.Scene} + * @since 3.10.0 + */ + this.scene = sceneInputPlugin.scene; + + /** + * A reference to the Scene Systems Settings. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#settings + * @type {Phaser.Scenes.Settings.Object} + * @since 3.10.0 + */ + this.settings = this.scene.sys.settings; + + /** + * A reference to the Scene Input Plugin that created this Keyboard Plugin. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#sceneInputPlugin + * @type {Phaser.Input.InputPlugin} + * @since 3.10.0 + */ + this.sceneInputPlugin = sceneInputPlugin; + + /** + * A boolean that controls if the Gamepad Manager is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#enabled + * @type {boolean} + * @default true + * @since 3.10.0 + */ + this.enabled = true; + + /** + * The Gamepad Event target, as defined in the Game Config. + * Typically the browser window, but can be any interactive DOM element. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#target + * @type {any} + * @since 3.10.0 + */ + this.target; + + /** + * An array of the connected Gamepads. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#gamepads + * @type {Phaser.Input.Gamepad.Gamepad[]} + * @default [] + * @since 3.10.0 + */ + this.gamepads = []; + + /** + * An internal event queue. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#queue + * @type {GamepadEvent[]} + * @private + * @since 3.10.0 + */ + this.queue = []; + + /** + * Internal event handler. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#onGamepadHandler + * @type {function} + * @private + * @since 3.10.0 + */ + this.onGamepadHandler; + + /** + * Internal Gamepad reference. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#_pad1 + * @type {Phaser.Input.Gamepad.Gamepad} + * @private + * @since 3.10.0 + */ + this._pad1; + + /** + * Internal Gamepad reference. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#_pad2 + * @type {Phaser.Input.Gamepad.Gamepad} + * @private + * @since 3.10.0 + */ + this._pad2; + + /** + * Internal Gamepad reference. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#_pad3 + * @type {Phaser.Input.Gamepad.Gamepad} + * @private + * @since 3.10.0 + */ + this._pad3; + + /** + * Internal Gamepad reference. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#_pad4 + * @type {Phaser.Input.Gamepad.Gamepad} + * @private + * @since 3.10.0 + */ + this._pad4; + + sceneInputPlugin.pluginEvents.once('boot', this.boot, this); + sceneInputPlugin.pluginEvents.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#boot + * @private + * @since 3.10.0 + */ + boot: function () + { + var game = this.scene.sys.game; + var settings = this.settings.input; + var config = game.config; + + this.enabled = GetValue(settings, 'gamepad', config.inputGamepad) && game.device.input.gamepads; + this.target = GetValue(settings, 'gamepad.target', config.inputGamepadEventTarget); + + this.sceneInputPlugin.pluginEvents.once('destroy', this.destroy, 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.Input.Gamepad.GamepadPlugin#start + * @private + * @since 3.10.0 + */ + start: function () + { + if (this.enabled) + { + this.startListeners(); + } + + this.sceneInputPlugin.pluginEvents.once('shutdown', this.shutdown, this); + }, + + /** + * Checks to see if both this plugin and the Scene to which it belongs is active. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#isActive + * @since 3.10.0 + * + * @return {boolean} `true` if the plugin and the Scene it belongs to is active. + */ + isActive: function () + { + return (this.enabled && this.scene.sys.isActive()); + }, + + /** + * Starts the Gamepad Event listeners running. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#startListeners + * @private + * @since 3.10.0 + */ + startListeners: function () + { + var _this = this; + var target = this.target; + + var handler = function (event) + { + // console.log(event); + + if (event.defaultPrevented || !_this.isActive()) + { + // Do nothing if event already handled + return; + } + + _this.refreshPads(); + + _this.queue.push(event); + }; + + this.onGamepadHandler = handler; + + target.addEventListener('gamepadconnected', handler, false); + target.addEventListener('gamepaddisconnected', handler, false); + + // FF also supports gamepadbuttondown, gamepadbuttonup and gamepadaxismove but + // nothing else does, and we can get those values via the gamepads anyway, so we will + // until more browsers support this + + // Finally, listen for an update event from the Input Plugin + this.sceneInputPlugin.pluginEvents.on('update', this.update, this); + }, + + /** + * Stops the Gamepad Event listeners. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#stopListeners + * @private + * @since 3.10.0 + */ + stopListeners: function () + { + this.target.removeEventListener('gamepadconnected', this.onGamepadHandler); + this.target.removeEventListener('gamepaddisconnected', this.onGamepadHandler); + + this.sceneInputPlugin.pluginEvents.off('update', this.update); + }, + + /** + * Disconnects all current Gamepads. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#disconnectAll + * @since 3.10.0 + */ + disconnectAll: function () + { + for (var i = 0; i < this.gamepads.length; i++) + { + this.gamepads.connected = false; + } + }, + + /** + * Refreshes the list of connected Gamepads. + * + * This is called automatically when a gamepad is connected or disconnected, + * and during the update loop. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#refreshPads + * @private + * @since 3.10.0 + */ + refreshPads: function () + { + var connectedPads = navigator.getGamepads(); + + if (!connectedPads) + { + this.disconnectAll(); + } + else + { + var currentPads = this.gamepads; + + for (var i = 0; i < connectedPads.length; i++) + { + var livePad = connectedPads[i]; + + // Because sometimes they're null (yes, really) + if (!livePad) + { + continue; + } + + var id = livePad.id; + var index = livePad.index; + var currentPad = currentPads[index]; + + if (!currentPad) + { + // A new Gamepad, not currently stored locally + var newPad = new Gamepad(this, livePad); + + currentPads[index] = newPad; + + if (!this._pad1) + { + this._pad1 = newPad; + } + else if (!this._pad2) + { + this._pad2 = newPad; + } + else if (!this._pad3) + { + this._pad3 = newPad; + } + else if (!this._pad4) + { + this._pad4 = newPad; + } + } + else if (currentPad.id !== id) + { + // A new Gamepad with a different vendor string, but it has got the same index as an old one + currentPad.destroy(); + + currentPads[index] = new Gamepad(this, livePad); + } + else + { + // If neither of these, it's a pad we've already got, so update it + currentPad.update(livePad); + } + } + } + }, + + /** + * Returns an array of all currently connected Gamepads. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#getAll + * @since 3.10.0 + * + * @return {Phaser.Input.Gamepad.Gamepad[]} An array of all currently connected Gamepads. + */ + getAll: function () + { + var out = []; + var pads = this.gamepads; + + for (var i = 0; i < pads.length; i++) + { + if (pads[i]) + { + out.push(pads[i]); + } + } + + return out; + }, + + /** + * Looks-up a single Gamepad based on the given index value. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#getPad + * @since 3.10.0 + * + * @param {number} index - The index of the Gamepad to get. + * + * @return {Phaser.Input.Gamepad.Gamepad} The Gamepad matching the given index, or undefined if none were found. + */ + getPad: function (index) + { + var pads = this.gamepads; + + for (var i = 0; i < pads.length; i++) + { + if (pads[i] && pads[i].index === index) + { + return pads[i]; + } + } + }, + + /** + * The internal update loop. Refreshes all connected gamepads and processes their events. + * + * Called automatically by the Input Manager, invoked from the Game step. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#update + * @private + * @since 3.10.0 + */ + update: function () + { + if (!this.enabled) + { + return; + } + + this.refreshPads(); + + var len = this.queue.length; + + if (len === 0) + { + return; + } + + var queue = this.queue.splice(0, len); + + // Process the event queue, dispatching all of the events that have stored up + for (var i = 0; i < len; i++) + { + var event = queue[i]; + var pad = this.getPad(event.gamepad.index); + + if (event.type === 'gamepadconnected') + { + this.emit('connected', pad, event); + } + else if (event.type === 'gamepaddisconnected') + { + this.emit('disconnected', pad, event); + } + } + }, + + /** + * Shuts the Gamepad Plugin down. + * All this does is remove any listeners bound to it. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#shutdown + * @private + * @since 3.10.0 + */ + shutdown: function () + { + this.stopListeners(); + + this.disconnectAll(); + + this.removeAllListeners(); + }, + + /** + * Destroys this Gamepad Plugin, disconnecting all Gamepads and releasing internal references. + * + * @method Phaser.Input.Gamepad.GamepadPlugin#destroy + * @private + * @since 3.10.0 + */ + destroy: function () + { + this.shutdown(); + + for (var i = 0; i < this.gamepads.length; i++) + { + if (this.gamepads[i]) + { + this.gamepads[i].destroy(); + } + } + + this.gamepads = []; + + this.scene = null; + this.settings = null; + this.sceneInputPlugin = null; + this.target = null; + }, + + /** + * The total number of connected game pads. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#total + * @type {integer} + * @since 3.10.0 + */ + total: { + + get: function () + { + return this.gamepads.length; + } + + }, + + /** + * A reference to the first connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#pad1 + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.10.0 + */ + pad1: { + + get: function () + { + return this._pad1; + } + + }, + + /** + * A reference to the second connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#pad2 + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.10.0 + */ + pad2: { + + get: function () + { + return this._pad2; + } + + }, + + /** + * A reference to the third connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#pad3 + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.10.0 + */ + pad3: { + + get: function () + { + return this._pad3; + } + + }, + + /** + * A reference to the fourth connected Gamepad. + * + * This will be undefined if either no pads are connected, or the browser + * has not yet issued a gamepadconnect, which can happen even if a Gamepad + * is plugged in, but hasn't yet had any buttons pressed on it. + * + * @name Phaser.Input.Gamepad.GamepadPlugin#pad4 + * @type {Phaser.Input.Gamepad.Gamepad} + * @since 3.10.0 + */ + pad4: { + + get: function () + { + return this._pad4; + } + + } + +}); + +/** + * An instance of the Gamepad Plugin class, if enabled via the `input.gamepad` Scene or Game Config property. + * Use this to create access Gamepads connected to the browser and respond to gamepad buttons. + * + * @name Phaser.Input.InputPlugin#gamepad + * @type {?Phaser.Input.Gamepad.GamepadPlugin} + * @since 3.10.0 + */ +InputPluginCache.register('GamepadPlugin', GamepadPlugin, 'gamepad', 'gamepad', 'inputGamepad'); + +module.exports = GamepadPlugin; + + +/***/ }), +/* 682 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Input.Gamepad + */ + +module.exports = { + + Axis: __webpack_require__(287), + Button: __webpack_require__(286), + Gamepad: __webpack_require__(285), + GamepadPlugin: __webpack_require__(681), + + Configs: __webpack_require__(680) +}; + + +/***/ }), +/* 683 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(366); +var Extend = __webpack_require__(21); + +/** + * @namespace Phaser.Input + */ + +var Input = { + + CreateInteractiveObject: __webpack_require__(288), + Gamepad: __webpack_require__(682), + InputManager: __webpack_require__(367), + InputPlugin: __webpack_require__(676), + InputPluginCache: __webpack_require__(116), + Keyboard: __webpack_require__(674), + Mouse: __webpack_require__(662), + Pointer: __webpack_require__(364), + Touch: __webpack_require__(661) + +}; + +// Merge in the consts +Input = Extend(false, Input, CONST); + +module.exports = Input; + + +/***/ }), +/* 684 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(160); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.RotateAroundPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} point - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var RotateAroundPoint = function (triangle, point, angle) +{ + return RotateAroundXY(triangle, point.x, point.y, angle); +}; + +module.exports = RotateAroundPoint; + + +/***/ }), +/* 685 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(160); +var InCenter = __webpack_require__(289); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Rotate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Rotate = function (triangle, angle) +{ + var point = InCenter(triangle); + + return RotateAroundXY(triangle, point.x, point.y, angle); +}; + +module.exports = Rotate; + + +/***/ }), +/* 686 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(71); + +// The 2D area of a triangle. The area value is always non-negative. + +/** + * Gets the length of the perimeter of the given triangle. + * + * @function Phaser.Geom.Triangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {number} [description] + */ +var Perimeter = function (triangle) +{ + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + return (Length(line1) + Length(line2) + Length(line3)); +}; + +module.exports = Perimeter; + + +/***/ }), +/* 687 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns true if two triangles have the same coordinates. + * + * @function Phaser.Geom.Triangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The first triangle to check. + * @param {Phaser.Geom.Triangle} toCompare - The second triangle to check. + * + * @return {boolean} `true` if the two given triangles have the exact same coordinates, otherwise `false`. + */ +var Equals = function (triangle, toCompare) +{ + return ( + triangle.x1 === toCompare.x1 && + triangle.y1 === toCompare.y1 && + triangle.x2 === toCompare.x2 && + triangle.y2 === toCompare.y2 && + triangle.x3 === toCompare.x3 && + triangle.y3 === toCompare.y3 + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 688 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one Triangle to a destination Triangle. + * + * @function Phaser.Geom.Triangle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [dest,$return] + * + * @param {Phaser.Geom.Triangle} source - The source Triangle to copy the values from. + * @param {Phaser.Geom.Triangle} dest - The destination Triangle to copy the values to. + * + * @return {Phaser.Geom.Triangle} The destination Triangle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 689 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(76); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} point - [description] + * + * @return {boolean} [description] + */ +var ContainsPoint = function (triangle, point) +{ + return Contains(triangle, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 690 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(66); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} source - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Clone = function (source) +{ + return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; + +module.exports = Clone; + + +/***/ }), +/* 691 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(81); + +// Adapted from https://gist.github.com/mutoo/5617691 + +/** + * [description] + * + * @function Phaser.Geom.Triangle.CircumCircle + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Circle} [out] - [description] + * + * @return {Phaser.Geom.Circle} [description] + */ +var CircumCircle = function (triangle, out) +{ + if (out === undefined) { out = new Circle(); } + + // A + var x1 = triangle.x1; + var y1 = triangle.y1; + + // B + var x2 = triangle.x2; + var y2 = triangle.y2; + + // C + var x3 = triangle.x3; + var y3 = triangle.y3; + + var A = x2 - x1; + var B = y2 - y1; + var C = x3 - x1; + var D = y3 - y1; + var E = A * (x1 + x2) + B * (y1 + y2); + var F = C * (x1 + x3) + D * (y1 + y3); + var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); + + var dx; + var dy; + + // If the points of the triangle are collinear, then just find the + // extremes and use the midpoint as the center of the circumcircle. + + if (Math.abs(G) < 0.000001) + { + var minX = Math.min(x1, x2, x3); + var minY = Math.min(y1, y2, y3); + dx = (Math.max(x1, x2, x3) - minX) * 0.5; + dy = (Math.max(y1, y2, y3) - minY) * 0.5; + + out.x = minX + dx; + out.y = minY + dy; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + else + { + out.x = (D * E - B * F) / G; + out.y = (A * F - C * E) / G; + dx = out.x - x1; + dy = out.y - y1; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + + return out; +}; + +module.exports = CircumCircle; + + +/***/ }), +/* 692 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector2 = __webpack_require__(3); + +// Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html + +/** + * Computes the determinant of a 2x2 matrix. Uses standard double-precision arithmetic, so is susceptible to round-off error. + * + * @function det + * @private + * @since 3.0.0 + * + * @param {number} m00 - The [0,0] entry of the matrix. + * @param {number} m01 - The [0,1] entry of the matrix. + * @param {number} m10 - The [1,0] entry of the matrix. + * @param {number} m11 - The [1,1] entry of the matrix. + * + * @return {number} the determinant. + */ +function det (m00, m01, m10, m11) +{ + return (m00 * m11) - (m01 * m10); +} + +/** + * Computes the circumcentre of a triangle. The circumcentre is the centre of + * the circumcircle, the smallest circle which encloses the triangle. It is also + * the common intersection point of the perpendicular bisectors of the sides of + * the triangle, and is the only point which has equal distance to all three + * vertices of the triangle. + * + * @function Phaser.Geom.Triangle.CircumCenter + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ +var CircumCenter = function (triangle, out) +{ + if (out === undefined) { out = new Vector2(); } + + var cx = triangle.x3; + var cy = triangle.y3; + + var ax = triangle.x1 - cx; + var ay = triangle.y1 - cy; + + var bx = triangle.x2 - cx; + var by = triangle.y2 - cy; + + var denom = 2 * det(ax, ay, bx, by); + var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); + var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); + + out.x = cx - numx / denom; + out.y = cy + numy / denom; + + return out; +}; + +module.exports = CircumCenter; + + +/***/ }), +/* 693 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Centroid = __webpack_require__(291); +var Offset = __webpack_require__(290); + +/** + * @callback CenterFunction + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + +/** + * Positions the Triangle so that it is centered on the given coordinates. + * + * @function Phaser.Geom.Triangle.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The triangle to be positioned. + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {CenterFunction} [centerFunc] - The function used to center the triangle. Defaults to Centroid centering. + * + * @return {Phaser.Geom.Triangle} The Triangle that was centered. + */ +var CenterOn = function (triangle, x, y, centerFunc) +{ + if (centerFunc === undefined) { centerFunc = Centroid; } + + // Get the center of the triangle + var center = centerFunc(triangle); + + // Difference + var diffX = x - center.x; + var diffY = y - center.y; + + return Offset(triangle, diffX, diffY); +}; + +module.exports = CenterOn; + + +/***/ }), +/* 694 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(66); + +// Builds a right triangle, with one 90 degree angle and two acute angles +// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) +// w/h can be positive or negative and represent the length of each side + +/** + * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. + * + * @function Phaser.Geom.Triangle.BuildRight + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. + * @param {number} y - The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. + * @param {number} width - The length of the side which is to the left or to the right of the right angle. + * @param {number} height - The length of the side which is above or below the right angle. + * + * @return {Phaser.Geom.Triangle} The constructed right Triangle. + */ +var BuildRight = function (x, y, width, height) +{ + if (height === undefined) { height = width; } + + // 90 degree angle + var x1 = x; + var y1 = y; + + var x2 = x; + var y2 = y - height; + + var x3 = x + width; + var y3 = y; + + return new Triangle(x1, y1, x2, y2, x3, y3); +}; + +module.exports = BuildRight; + + +/***/ }), +/* 695 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var EarCut = __webpack_require__(70); +var Triangle = __webpack_require__(66); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.BuildFromPolygon + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle[]} O - [out,$return] + * + * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] + * @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). + * @param {number} [scaleX=1] - [description] + * @param {number} [scaleY=1] - [description] + * @param {(array|Phaser.Geom.Triangle[])} [out] - [description] + * + * @return {(array|Phaser.Geom.Triangle[])} [description] + */ +var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) +{ + if (holes === undefined) { holes = null; } + if (scaleX === undefined) { scaleX = 1; } + if (scaleY === undefined) { scaleY = 1; } + if (out === undefined) { out = []; } + + var tris = EarCut(data, holes); + + var a; + var b; + var c; + + var x1; + var y1; + + var x2; + var y2; + + var x3; + var y3; + + for (var i = 0; i < tris.length; i += 3) + { + a = tris[i]; + b = tris[i + 1]; + c = tris[i + 2]; + + x1 = data[a * 2] * scaleX; + y1 = data[(a * 2) + 1] * scaleY; + + x2 = data[b * 2] * scaleX; + y2 = data[(b * 2) + 1] * scaleY; + + x3 = data[c * 2] * scaleX; + y3 = data[(c * 2) + 1] * scaleY; + + out.push(new Triangle(x1, y1, x2, y2, x3, y3)); + } + + return out; +}; + +module.exports = BuildFromPolygon; + + +/***/ }), +/* 696 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(66); + +/** + * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). + * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. + * + * @function Phaser.Geom.Triangle.BuildEquilateral + * @since 3.0.0 + * + * @param {number} x - x coordinate of the top point of the triangle. + * @param {number} y - y coordinate of the top point of the triangle. + * @param {number} length - Length of each side of the triangle. + * + * @return {Phaser.Geom.Triangle} The Triangle object of the given size. + */ +var BuildEquilateral = function (x, y, length) +{ + var height = length * (Math.sqrt(3) / 2); + + var x1 = x; + var y1 = y; + + var x2 = x + (length / 2); + var y2 = y + height; + + var x3 = x - (length / 2); + var y3 = y + height; + + return new Triangle(x1, y1, x2, y2, x3, y3); +}; + +module.exports = BuildEquilateral; + + +/***/ }), +/* 697 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// The 2D area of a triangle. The area value is always non-negative. + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {number} [description] + */ +var Area = function (triangle) +{ + var x1 = triangle.x1; + var y1 = triangle.y1; + + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); +}; + +module.exports = Area; + + +/***/ }), +/* 698 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(66); + +Triangle.Area = __webpack_require__(697); +Triangle.BuildEquilateral = __webpack_require__(696); +Triangle.BuildFromPolygon = __webpack_require__(695); +Triangle.BuildRight = __webpack_require__(694); +Triangle.CenterOn = __webpack_require__(693); +Triangle.Centroid = __webpack_require__(291); +Triangle.CircumCenter = __webpack_require__(692); +Triangle.CircumCircle = __webpack_require__(691); +Triangle.Clone = __webpack_require__(690); +Triangle.Contains = __webpack_require__(76); +Triangle.ContainsArray = __webpack_require__(163); +Triangle.ContainsPoint = __webpack_require__(689); +Triangle.CopyFrom = __webpack_require__(688); +Triangle.Decompose = __webpack_require__(297); +Triangle.Equals = __webpack_require__(687); +Triangle.GetPoint = __webpack_require__(306); +Triangle.GetPoints = __webpack_require__(305); +Triangle.InCenter = __webpack_require__(289); +Triangle.Perimeter = __webpack_require__(686); +Triangle.Offset = __webpack_require__(290); +Triangle.Random = __webpack_require__(202); +Triangle.Rotate = __webpack_require__(685); +Triangle.RotateAroundPoint = __webpack_require__(684); +Triangle.RotateAroundXY = __webpack_require__(160); + +module.exports = Triangle; + + +/***/ }), +/* 699 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Scales the width and height of this Rectangle by the given amounts. + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Scale + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var Scale = function (rect, x, y) +{ + if (y === undefined) { y = x; } + + rect.width *= x; + rect.height *= y; + + return rect; +}; + +module.exports = Scale; + + +/***/ }), +/* 700 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. + * + * @function Phaser.Geom.Rectangle.SameDimensions + * @since 3.15.0 + * + * @param {Phaser.Geom.Rectangle} rect - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} toCompare - The second Rectangle object. + * + * @return {boolean} `true` if the objects have equivalent values for the `width` and `height` properties, otherwise `false`. + */ +var SameDimensions = function (rect, toCompare) +{ + return (rect.width === toCompare.width && rect.height === toCompare.height); +}; + +module.exports = SameDimensions; + + +/***/ }), +/* 701 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Between = __webpack_require__(188); +var ContainsRect = __webpack_require__(292); +var Point = __webpack_require__(6); + +/** + * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. + * The inner Rectangle must be fully contained within the outer rectangle. + * + * @function Phaser.Geom.Rectangle.RandomOutside + * @since 3.10.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} outer - The outer Rectangle to get the random point within. + * @param {Phaser.Geom.Rectangle} inner - The inner Rectangle to exclude from the returned point. + * @param {Phaser.Geom.Point} [out] - A Point, or Point-like object to store the result in. If not specified, a new Point will be created. + * + * @return {Phaser.Geom.Point} A Point object containing the random values in its `x` and `y` properties. + */ +var RandomOutside = function (outer, inner, out) +{ + if (out === undefined) { out = new Point(); } + + if (ContainsRect(outer, inner)) + { + // Pick a random quadrant + // + // The quadrants don't extend the full widths / heights of the outer rect to give + // us a better uniformed distribution, otherwise you get clumping in the corners where + // the 4 quads would overlap + + switch (Between(0, 3)) + { + case 0: // Top + out.x = outer.x + (Math.random() * (inner.right - outer.x)); + out.y = outer.y + (Math.random() * (inner.top - outer.y)); + break; + + case 1: // Bottom + out.x = inner.x + (Math.random() * (outer.right - inner.x)); + out.y = inner.bottom + (Math.random() * (outer.bottom - inner.bottom)); + break; + + case 2: // Left + out.x = outer.x + (Math.random() * (inner.x - outer.x)); + out.y = inner.y + (Math.random() * (outer.bottom - inner.y)); + break; + + case 3: // Right + out.x = inner.right + (Math.random() * (outer.right - inner.right)); + out.y = outer.y + (Math.random() * (inner.bottom - outer.y)); + break; + } + } + + return out; +}; + +module.exports = RandomOutside; + + +/***/ }), +/* 702 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); +var DegToRad = __webpack_require__(36); + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.PerimeterPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {integer} angle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var PerimeterPoint = function (rectangle, angle, out) +{ + if (out === undefined) { out = new Point(); } + + angle = DegToRad(angle); + + var s = Math.sin(angle); + var c = Math.cos(angle); + + var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; + var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; + + if (Math.abs(dx * s) < Math.abs(dy * c)) + { + dy = (dx * s) / c; + } + else + { + dx = (dy * c) / s; + } + + out.x = dx + rectangle.centerX; + out.y = dy + rectangle.centerY; + + return out; +}; + +module.exports = PerimeterPoint; + + +/***/ }), +/* 703 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Overlaps + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var Overlaps = function (rectA, rectB) +{ + return ( + rectA.x < rectB.right && + rectA.right > rectB.x && + rectA.y < rectB.bottom && + rectA.bottom > rectB.y + ); +}; + +module.exports = Overlaps; + + +/***/ }), +/* 704 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector). + * + * @function Phaser.Geom.Rectangle.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2)} point - The point whose coordinates should be used as an offset. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var OffsetPoint = function (rect, point) +{ + rect.x += point.x; + rect.y += point.y; + + return rect; +}; + +module.exports = OffsetPoint; + + +/***/ }), +/* 705 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Nudges (translates) the top left corner of a Rectangle by a given offset. + * + * @function Phaser.Geom.Rectangle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {number} x - The distance to move the Rectangle horizontally. + * @param {number} y - The distance to move the Rectangle vertically. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var Offset = function (rect, x, y) +{ + rect.x += x; + rect.y += y; + + return rect; +}; + +module.exports = Offset; + + +/***/ }), +/* 706 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. + * + * @function Phaser.Geom.Rectangle.MergeXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged and modified. + * @param {number} x - The X coordinate of the point which should be merged. + * @param {number} y - The Y coordinate of the point which should be merged. + * + * @return {Phaser.Geom.Rectangle} The modified `target` Rectangle. + */ +var MergeXY = function (target, x, y) +{ + var minX = Math.min(target.x, x); + var maxX = Math.max(target.right, x); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, y); + var maxY = Math.max(target.bottom, y); + + target.y = minY; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergeXY; + + +/***/ }), +/* 707 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Merges source rectangle into target rectangle and returns target +// Neither rect should have negative widths or heights + +/** + * Merges the source rectangle into the target rectangle and returns the target. + * Neither rectangle should have a negative width or height. + * + * @function Phaser.Geom.Rectangle.MergeRect + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - Target rectangle. Will be modified to include source rectangle. + * @param {Phaser.Geom.Rectangle} source - Rectangle that will be merged into target rectangle. + * + * @return {Phaser.Geom.Rectangle} Modified target rectangle that contains source rectangle. + */ +var MergeRect = function (target, source) +{ + var minX = Math.min(target.x, source.x); + var maxX = Math.max(target.right, source.right); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, source.y); + var maxY = Math.max(target.bottom, source.bottom); + + target.y = minY; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergeRect; + + +/***/ }), +/* 708 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. + * + * @function Phaser.Geom.Rectangle.MergePoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged. + * @param {Phaser.Geom.Point[]} points - An array of Points (or any object with public `x` and `y` properties) which should be merged with the Rectangle. + * + * @return {Phaser.Geom.Rectangle} The modified Rectangle. + */ +var MergePoints = function (target, points) +{ + var minX = target.x; + var maxX = target.right; + var minY = target.y; + var maxY = target.bottom; + + for (var i = 0; i < points.length; i++) + { + minX = Math.min(minX, points[i].x); + maxX = Math.max(maxX, points[i].x); + minY = Math.min(minY, points[i].y); + maxY = Math.max(maxY, points[i].y); + } + + target.x = minX; + target.y = minY; + target.width = maxX - minX; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergePoints; + + +/***/ }), +/* 709 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); +var Intersects = __webpack_require__(164); + +/** + * Takes two Rectangles and first checks to see if they intersect. + * If they intersect it will return the area of intersection in the `out` Rectangle. + * If they do not intersect, the `out` Rectangle will have a width and height of zero. + * + * @function Phaser.Geom.Rectangle.Intersection + * @since 3.11.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle to store the intersection results in. + * + * @return {Phaser.Geom.Rectangle} The intersection result. If the width and height are zero, no intersection occurred. + */ +var Intersection = function (rectA, rectB, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (Intersects(rectA, rectB)) + { + out.x = Math.max(rectA.x, rectB.x); + out.y = Math.max(rectA.y, rectB.y); + out.width = Math.min(rectA.right, rectB.right) - out.x; + out.height = Math.min(rectA.bottom, rectB.bottom) - out.y; + } + else + { + out.setEmpty(); + } + + return out; +}; + +module.exports = Intersection; + + +/***/ }), +/* 710 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CenterOn = __webpack_require__(193); + +// Increases the size of the Rectangle object by the specified amounts. +// The center point of the Rectangle object stays the same, and its size increases +// to the left and right by the x value, and to the top and the bottom by the y value. + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Inflate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var Inflate = function (rect, x, y) +{ + var cx = rect.centerX; + var cy = rect.centerY; + + rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); + + return CenterOn(rect, cx, cy); +}; + +module.exports = Inflate; + + +/***/ }), +/* 711 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// The size of the Rectangle object, expressed as a Point object +// with the values of the width and height properties. + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.GetSize + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetSize = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.width; + out.y = rect.height; + + return out; +}; + +module.exports = GetSize; + + +/***/ }), +/* 712 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns the center of a Rectangle as a Point. + * + * @function Phaser.Geom.Rectangle.GetCenter + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the center of. + * @param {(Phaser.Geom.Point|object)} [out] - Optional point-like object to update with the center coordinates. + * + * @return {(Phaser.Geom.Point|object)} The modified `out` object, or a new Point if none was provided. + */ +var GetCenter = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.centerX; + out.y = rect.centerY; + + return out; +}; + +module.exports = GetCenter; + + +/***/ }), +/* 713 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. + * + * @function Phaser.Geom.Rectangle.FloorAll + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var FloorAll = function (rect) +{ + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + rect.width = Math.floor(rect.width); + rect.height = Math.floor(rect.height); + + return rect; +}; + +module.exports = FloorAll; + + +/***/ }), +/* 714 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Floor + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var Floor = function (rect) +{ + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + + return rect; +}; + +module.exports = Floor; + + +/***/ }), +/* 715 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAspectRatio = __webpack_require__(161); + +// Fits the target rectangle around the source rectangle. +// Preserves aspect ration. +// Scales and centers the target rectangle to the source rectangle + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.FitOutside + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var FitOutside = function (target, source) +{ + var ratio = GetAspectRatio(target); + + if (ratio > GetAspectRatio(source)) + { + // Wider than Tall + target.setSize(source.height * ratio, source.height); + } + else + { + // Taller than Wide + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - target.width / 2, + source.centerY - target.height / 2 + ); +}; + +module.exports = FitOutside; + + +/***/ }), +/* 716 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAspectRatio = __webpack_require__(161); + +// Fits the target rectangle into the source rectangle. +// Preserves aspect ratio. +// Scales and centers the target rectangle to the source rectangle + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.FitInside + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var FitInside = function (target, source) +{ + var ratio = GetAspectRatio(target); + + if (ratio < GetAspectRatio(source)) + { + // Taller than Wide + target.setSize(source.height * ratio, source.height); + } + else + { + // Wider than Tall + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - (target.width / 2), + source.centerY - (target.height / 2) + ); +}; + +module.exports = FitInside; + + +/***/ }), +/* 717 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} toCompare - [description] + * + * @return {boolean} [description] + */ +var Equals = function (rect, toCompare) +{ + return ( + rect.x === toCompare.x && + rect.y === toCompare.y && + rect.width === toCompare.width && + rect.height === toCompare.height + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 718 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one Rectangle to a destination Rectangle. + * + * @function Phaser.Geom.Rectangle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [dest,$return] + * + * @param {Phaser.Geom.Rectangle} source - The source Rectangle to copy the values from. + * @param {Phaser.Geom.Rectangle} dest - The destination Rectangle to copy the values to. + * + * @return {Phaser.Geom.Rectangle} The destination Rectangle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 719 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(43); + +/** + * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. + * + * @function Phaser.Geom.Rectangle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object. + * @param {Phaser.Geom.Point} point - The point object to be checked. Can be a Phaser Point object or any object with x and y values. + * + * @return {boolean} A value of true if the Rectangle object contains the specified point, otherwise false. + */ +var ContainsPoint = function (rect, point) +{ + return Contains(rect, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 720 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * Creates a new Rectangle which is identical to the given one. + * + * @function Phaser.Geom.Rectangle.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} source - The Rectangle to clone. + * + * @return {Phaser.Geom.Rectangle} The newly created Rectangle, which is separate from the given one. + */ +var Clone = function (source) +{ + return new Rectangle(source.x, source.y, source.width, source.height); +}; + +module.exports = Clone; + + +/***/ }), +/* 721 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.CeilAll + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var CeilAll = function (rect) +{ + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + rect.width = Math.ceil(rect.width); + rect.height = Math.ceil(rect.height); + + return rect; +}; + +module.exports = CeilAll; + + +/***/ }), +/* 722 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. + * + * @function Phaser.Geom.Rectangle.Ceil + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var Ceil = function (rect) +{ + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + + return rect; +}; + +module.exports = Ceil; + + +/***/ }), +/* 723 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var Area = function (rect) +{ + return rect.width * rect.height; +}; + +module.exports = Area; + + +/***/ }), +/* 724 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Polygon.Reverse + * @since 3.0.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * + * @return {Phaser.Geom.Polygon} [description] + */ +var Reverse = function (polygon) +{ + polygon.points.reverse(); + + return polygon; +}; + +module.exports = Reverse; + + +/***/ }), +/* 725 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] + +/** + * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], + * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant + * array for the point's X and Y coordinate. + * + * @function Phaser.Geom.Polygon.GetNumberArray + * @since 3.0.0 + * + * @generic {number[]} O - [output,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon whose points to export. + * @param {(array|number[])} [output] - An array to which the points' coordinates should be appended. + * + * @return {(array|number[])} The modified `output` array, or a new array if none was given. + */ +var GetNumberArray = function (polygon, output) +{ + if (output === undefined) { output = []; } + + for (var i = 0; i < polygon.points.length; i++) + { + output.push(polygon.points[i].x); + output.push(polygon.points[i].y); + } + + return output; +}; + +module.exports = GetNumberArray; + + +/***/ }), +/* 726 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(166); + +/** + * [description] + * + * @function Phaser.Geom.Polygon.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {Phaser.Geom.Point} point - [description] + * + * @return {boolean} [description] + */ +var ContainsPoint = function (polygon, point) +{ + return Contains(polygon, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 727 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Polygon = __webpack_require__(167); + +/** + * [description] + * + * @function Phaser.Geom.Polygon.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * + * @return {Phaser.Geom.Polygon} [description] + */ +var Clone = function (polygon) +{ + return new Polygon(polygon.points); +}; + +module.exports = Clone; + + +/***/ }), +/* 728 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Polygon = __webpack_require__(167); + +Polygon.Clone = __webpack_require__(727); +Polygon.Contains = __webpack_require__(166); +Polygon.ContainsPoint = __webpack_require__(726); +Polygon.GetAABB = __webpack_require__(313); +Polygon.GetNumberArray = __webpack_require__(725); +Polygon.GetPoints = __webpack_require__(312); +Polygon.Perimeter = __webpack_require__(311); +Polygon.Reverse = __webpack_require__(724); +Polygon.Smooth = __webpack_require__(310); + +module.exports = Polygon; + + +/***/ }), +/* 729 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetMagnitude = __webpack_require__(295); + +/** + * [description] + * + * @function Phaser.Geom.Point.SetMagnitude + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} point - [description] + * @param {number} magnitude - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var SetMagnitude = function (point, magnitude) +{ + if (point.x !== 0 || point.y !== 0) + { + var m = GetMagnitude(point); + + point.x /= m; + point.y /= m; + } + + point.x *= magnitude; + point.y *= magnitude; + + return point; +}; + +module.exports = SetMagnitude; + + +/***/ }), +/* 730 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Point.ProjectUnit + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var ProjectUnit = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var amt = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = ProjectUnit; + + +/***/ }), +/* 731 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); +var GetMagnitudeSq = __webpack_require__(294); + +/** + * [description] + * + * @function Phaser.Geom.Point.Project + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Project = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var dot = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + var amt = dot / GetMagnitudeSq(pointB); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = Project; + + +/***/ }), +/* 732 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Point.Negative + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Negative = function (point, out) +{ + if (out === undefined) { out = new Point(); } + + return out.setTo(-point.x, -point.y); +}; + +module.exports = Negative; + + +/***/ }), +/* 733 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Swaps the X and the Y coordinate of a point. + * + * @function Phaser.Geom.Point.Invert + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} point - The Point to modify. + * + * @return {Phaser.Geom.Point} The modified `point`. + */ +var Invert = function (point) +{ + return point.setTo(point.y, point.x); +}; + +module.exports = Invert; + + +/***/ }), +/* 734 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Interpolate two given Point objects, based on `t` value. Return result either as new Point if `out` parameter is omitted or load result into Point passed as `out` parameter and return it. For `out` parameter you can also use any object with public x/y properties. + * + * @function Phaser.Geom.Point.Interpolate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {number} [t=0] - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Interpolate = function (pointA, pointB, t, out) +{ + if (t === undefined) { t = 0; } + if (out === undefined) { out = new Point(); } + + out.x = pointA.x + ((pointB.x - pointA.x) * t); + out.y = pointA.y + ((pointB.y - pointA.y) * t); + + return out; +}; + +module.exports = Interpolate; + + +/***/ }), +/* 735 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. + * + * @function Phaser.Geom.Point.GetRectangleFromPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Rectangle} [out] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var GetRectangleFromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + var xMax = Number.NEGATIVE_INFINITY; + var xMin = Number.POSITIVE_INFINITY; + var yMax = Number.NEGATIVE_INFINITY; + var yMin = Number.POSITIVE_INFINITY; + + for (var i = 0; i < points.length; i++) + { + var point = points[i]; + + if (point.x > xMax) + { + xMax = point.x; + } + + if (point.x < xMin) + { + xMin = point.x; + } + + if (point.y > yMax) + { + yMax = point.y; + } + + if (point.y < yMin) + { + yMin = point.y; + } + } + + out.x = xMin; + out.y = yMin; + out.width = xMax - xMin; + out.height = yMax - yMin; + + return out; +}; + +module.exports = GetRectangleFromPoints; + + +/***/ }), +/* 736 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Point.GetCentroid + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var GetCentroid = function (points, out) +{ + if (out === undefined) { out = new Point(); } + + if (!Array.isArray(points)) + { + throw new Error('GetCentroid points argument must be an array'); + } + + var len = points.length; + + if (len < 1) + { + throw new Error('GetCentroid points array must not be empty'); + } + else if (len === 1) + { + out.x = points[0].x; + out.y = points[0].y; + } + else + { + for (var i = 0; i < len; i++) + { + out.x += points[i].x; + out.y += points[i].y; + } + + out.x /= len; + out.y /= len; + } + + return out; +}; + +module.exports = GetCentroid; + + +/***/ }), +/* 737 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Apply `Math.ceil()` to each coordinate of the given Point. + * + * @function Phaser.Geom.Point.Floor + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} point - The Point to floor. + * + * @return {Phaser.Geom.Point} The Point with `Math.floor()` applied to its coordinates. + */ +var Floor = function (point) +{ + return point.setTo(Math.floor(point.x), Math.floor(point.y)); +}; + +module.exports = Floor; + + +/***/ }), +/* 738 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A comparison of two `Point` objects to see if they are equal. + * + * @function Phaser.Geom.Point.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - The original `Point` to compare against. + * @param {Phaser.Geom.Point} toCompare - The second `Point` to compare. + * + * @return {boolean} Returns true if the both `Point` objects are equal. + */ +var Equals = function (point, toCompare) +{ + return (point.x === toCompare.x && point.y === toCompare.y); +}; + +module.exports = Equals; + + +/***/ }), +/* 739 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one Point to a destination Point. + * + * @function Phaser.Geom.Point.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [dest,$return] + * + * @param {Phaser.Geom.Point} source - The source Point to copy the values from. + * @param {Phaser.Geom.Point} dest - The destination Point to copy the values to. + * + * @return {Phaser.Geom.Point} The destination Point. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 740 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Clone the given Point. + * + * @function Phaser.Geom.Point.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} source - The source Point to clone. + * + * @return {Phaser.Geom.Point} The cloned Point. + */ +var Clone = function (source) +{ + return new Point(source.x, source.y); +}; + +module.exports = Clone; + + +/***/ }), +/* 741 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Apply `Math.ceil()` to each coordinate of the given Point. + * + * @function Phaser.Geom.Point.Ceil + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} point - The Point to ceil. + * + * @return {Phaser.Geom.Point} The Point with `Math.ceil()` applied to its coordinates. + */ +var Ceil = function (point) +{ + return point.setTo(Math.ceil(point.x), Math.ceil(point.y)); +}; + +module.exports = Ceil; + + +/***/ }), +/* 742 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +Point.Ceil = __webpack_require__(741); +Point.Clone = __webpack_require__(740); +Point.CopyFrom = __webpack_require__(739); +Point.Equals = __webpack_require__(738); +Point.Floor = __webpack_require__(737); +Point.GetCentroid = __webpack_require__(736); +Point.GetMagnitude = __webpack_require__(295); +Point.GetMagnitudeSq = __webpack_require__(294); +Point.GetRectangleFromPoints = __webpack_require__(735); +Point.Interpolate = __webpack_require__(734); +Point.Invert = __webpack_require__(733); +Point.Negative = __webpack_require__(732); +Point.Project = __webpack_require__(731); +Point.ProjectUnit = __webpack_require__(730); +Point.SetMagnitude = __webpack_require__(729); + +module.exports = Point; + + +/***/ }), +/* 743 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the width of the given line. + * + * @function Phaser.Geom.Line.Width + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the width of. + * + * @return {number} The width of the line. + */ +var Width = function (line) +{ + return Math.abs(line.x1 - line.x2); +}; + +module.exports = Width; + + +/***/ }), +/* 744 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the slope of the given line. + * + * @function Phaser.Geom.Line.Slope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the slope of. + * + * @return {number} The slope of the line. + */ +var Slope = function (line) +{ + return (line.y2 - line.y1) / (line.x2 - line.x1); +}; + +module.exports = Slope; + + +/***/ }), +/* 745 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Set a line to a given position, angle and length. + * + * @function Phaser.Geom.Line.SetToAngle + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to set. + * @param {number} x - The horizontal start position of the line. + * @param {number} y - The vertical start position of the line. + * @param {number} angle - The angle of the line in radians. + * @param {number} length - The length of the line. + * + * @return {Phaser.Geom.Line} The updated line. + */ +var SetToAngle = function (line, x, y, angle, length) +{ + line.x1 = x; + line.y1 = y; + + line.x2 = x + (Math.cos(angle) * length); + line.y2 = y + (Math.sin(angle) * length); + + return line; +}; + +module.exports = SetToAngle; + + +/***/ }), +/* 746 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(162); + +/** + * Rotate a line around a point by the given angle in radians. + * + * @function Phaser.Geom.Line.RotateAroundPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {(Phaser.Geom.Point|object)} point - The point to rotate the line around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var RotateAroundPoint = function (line, point, angle) +{ + return RotateAroundXY(line, point.x, point.y, angle); +}; + +module.exports = RotateAroundPoint; + + +/***/ }), +/* 747 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(162); + +/** + * Rotate a line around its midpoint by the given angle in radians. + * + * @function Phaser.Geom.Line.Rotate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var Rotate = function (line, angle) +{ + var x = (line.x1 + line.x2) / 2; + var y = (line.y1 + line.y2) / 2; + + return RotateAroundXY(line, x, y, angle); +}; + +module.exports = Rotate; + + +/***/ }), +/* 748 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Angle = __webpack_require__(75); +var NormalAngle = __webpack_require__(296); + +/** + * Calculate the reflected angle between two lines. + * + * This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. + * + * @function Phaser.Geom.Line.ReflectAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} lineA - The first line. + * @param {Phaser.Geom.Line} lineB - The second line. + * + * @return {number} The reflected angle between each line. + */ +var ReflectAngle = function (lineA, lineB) +{ + return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); +}; + +module.exports = ReflectAngle; + + +/***/ }), +/* 749 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the perpendicular slope of the given line. + * + * @function Phaser.Geom.Line.PerpSlope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the perpendicular slope of. + * + * @return {number} The perpendicular slope of the line. + */ +var PerpSlope = function (line) +{ + return -((line.x2 - line.x1) / (line.y2 - line.y1)); +}; + +module.exports = PerpSlope; + + +/***/ }), +/* 750 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offset a line by the given amount. + * + * @function Phaser.Geom.Line.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to offset. + * @param {number} x - The horizontal offset to add to the line. + * @param {number} y - The vertical offset to add to the line. + * + * @return {Phaser.Geom.Line} The offset line. + */ +var Offset = function (line, x, y) +{ + line.x1 += x; + line.y1 += y; + + line.x2 += x; + line.y2 += y; + + return line; +}; + +module.exports = Offset; + + +/***/ }), +/* 751 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(18); +var Angle = __webpack_require__(75); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalY + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * + * @return {number} [description] + */ +var NormalY = function (line) +{ + return Math.sin(Angle(line) - MATH_CONST.TAU); +}; + +module.exports = NormalY; + + +/***/ }), +/* 752 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(18); +var Angle = __webpack_require__(75); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalX + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The Line object to get the normal value from. + * + * @return {number} [description] + */ +var NormalX = function (line) +{ + return Math.cos(Angle(line) - MATH_CONST.TAU); +}; + +module.exports = NormalX; + + +/***/ }), +/* 753 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the height of the given line. + * + * @function Phaser.Geom.Line.Height + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the height of. + * + * @return {number} The height of the line. + */ +var Height = function (line) +{ + return Math.abs(line.y1 - line.y2); +}; + +module.exports = Height; + + +/***/ }), +/* 754 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(18); +var Angle = __webpack_require__(75); +var Point = __webpack_require__(6); + +/** + * Calculate the normal of the given line. + * + * The normal of a line is a vector that points perpendicular from it. + * + * @function Phaser.Geom.Line.GetNormal + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to calculate the normal of. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point object to store the normal in. + * + * @return {(Phaser.Geom.Point|object)} The normal of the Line. + */ +var GetNormal = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + var a = Angle(line) - MATH_CONST.TAU; + + out.x = Math.cos(a); + out.y = Math.sin(a); + + return out; +}; + +module.exports = GetNormal; + + +/***/ }), +/* 755 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Get the midpoint of the given line. + * + * @function Phaser.Geom.Line.GetMidPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to get the midpoint of. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point object to store the midpoint in. + * + * @return {(Phaser.Geom.Point|object)} The midpoint of the Line. + */ +var GetMidPoint = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (line.x1 + line.x2) / 2; + out.y = (line.y1 + line.y2) / 2; + + return out; +}; + +module.exports = GetMidPoint; + + +/***/ }), +/* 756 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compare two lines for strict equality. + * + * @function Phaser.Geom.Line.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The first line to compare. + * @param {Phaser.Geom.Line} toCompare - The second line to compare. + * + * @return {boolean} Whether the two lines are equal. + */ +var Equals = function (line, toCompare) +{ + return ( + line.x1 === toCompare.x1 && + line.y1 === toCompare.y1 && + line.x2 === toCompare.x2 && + line.y2 === toCompare.y2 + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 757 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one line to a destination line. + * + * @function Phaser.Geom.Line.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [dest,$return] + * + * @param {Phaser.Geom.Line} source - The source line to copy the values from. + * @param {Phaser.Geom.Line} dest - The destination line to copy the values to. + * + * @return {Phaser.Geom.Line} The destination line. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 758 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(60); + +/** + * Clone the given line. + * + * @function Phaser.Geom.Line.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} source - The source line to clone. + * + * @return {Phaser.Geom.Line} The cloned line. + */ +var Clone = function (source) +{ + return new Line(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = Clone; + + +/***/ }), +/* 759 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + + +/** + * Center a line on the given coordinates. + * + * @function Phaser.Geom.Line.CenterOn + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to center. + * @param {number} x - The horizontal coordinate to center the line on. + * @param {number} y - The vertical coordinate to center the line on. + * + * @return {Phaser.Geom.Line} The centered line. + */ +var CenterOn = function (line, x, y) +{ + var tx = x - ((line.x1 + line.x2) / 2); + var ty = y - ((line.y1 + line.y2) / 2); + + line.x1 += tx; + line.y1 += ty; + + line.x2 += tx; + line.y2 += ty; + + return line; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 760 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(60); + +Line.Angle = __webpack_require__(75); +Line.BresenhamPoints = __webpack_require__(421); +Line.CenterOn = __webpack_require__(759); +Line.Clone = __webpack_require__(758); +Line.CopyFrom = __webpack_require__(757); +Line.Equals = __webpack_require__(756); +Line.GetMidPoint = __webpack_require__(755); +Line.GetNormal = __webpack_require__(754); +Line.GetPoint = __webpack_require__(433); +Line.GetPoints = __webpack_require__(208); +Line.Height = __webpack_require__(753); +Line.Length = __webpack_require__(71); +Line.NormalAngle = __webpack_require__(296); +Line.NormalX = __webpack_require__(752); +Line.NormalY = __webpack_require__(751); +Line.Offset = __webpack_require__(750); +Line.PerpSlope = __webpack_require__(749); +Line.Random = __webpack_require__(207); +Line.ReflectAngle = __webpack_require__(748); +Line.Rotate = __webpack_require__(747); +Line.RotateAroundPoint = __webpack_require__(746); +Line.RotateAroundXY = __webpack_require__(162); +Line.SetToAngle = __webpack_require__(745); +Line.Slope = __webpack_require__(744); +Line.Width = __webpack_require__(743); + +module.exports = Line; + + +/***/ }), +/* 761 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ContainsArray = __webpack_require__(163); +var Decompose = __webpack_require__(297); +var LineToLine = __webpack_require__(117); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangleA - [description] + * @param {Phaser.Geom.Triangle} triangleB - [description] + * + * @return {boolean} [description] + */ +var TriangleToTriangle = function (triangleA, triangleB) +{ + // First the cheapest ones: + + if ( + triangleA.left > triangleB.right || + triangleA.right < triangleB.left || + triangleA.top > triangleB.bottom || + triangleA.bottom < triangleB.top) + { + return false; + } + + var lineAA = triangleA.getLineA(); + var lineAB = triangleA.getLineB(); + var lineAC = triangleA.getLineC(); + + var lineBA = triangleB.getLineA(); + var lineBB = triangleB.getLineB(); + var lineBC = triangleB.getLineC(); + + // Now check the lines against each line of TriangleB + if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) + { + return true; + } + + if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) + { + return true; + } + + if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) + { + return true; + } + + // Nope, so check to see if any of the points of triangleA are within triangleB + + var points = Decompose(triangleA); + var within = ContainsArray(triangleB, points, true); + + if (within.length > 0) + { + return true; + } + + // Finally check to see if any of the points of triangleB are within triangleA + + points = Decompose(triangleB); + within = ContainsArray(triangleA, points, true); + + if (within.length > 0) + { + return true; + } + + return false; +}; + +module.exports = TriangleToTriangle; + + +/***/ }), +/* 762 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(76); +var LineToLine = __webpack_require__(117); + +/** + * Checks if a Triangle and a Line intersect. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". + * + * @function Phaser.Geom.Intersects.TriangleToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check with. + * @param {Phaser.Geom.Line} line - The Line to check with. + * + * @return {boolean} `true` if the Triangle and the Line intersect, otherwise `false`. + */ +var TriangleToLine = function (triangle, line) +{ + // If the Triangle contains either the start or end point of the line, it intersects + if (Contains(triangle, line.getPointA()) || Contains(triangle, line.getPointB())) + { + return true; + } + + // Now check the line against each line of the Triangle + if (LineToLine(triangle.getLineA(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineB(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineC(), line)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToLine; + + +/***/ }), +/* 763 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineToCircle = __webpack_require__(300); +var Contains = __webpack_require__(76); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * + * @return {boolean} [description] + */ +var TriangleToCircle = function (triangle, circle) +{ + // First the cheapest ones: + + if ( + triangle.left > circle.right || + triangle.right < circle.left || + triangle.top > circle.bottom || + triangle.bottom < circle.top) + { + return false; + } + + if (Contains(triangle, circle.x, circle.y)) + { + return true; + } + + if (LineToCircle(triangle.getLineA(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineB(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineC(), circle)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToCircle; + + +/***/ }), +/* 764 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToValues + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} left - [description] + * @param {number} right - [description] + * @param {number} top - [description] + * @param {number} bottom - [description] + * @param {number} [tolerance=0] - [description] + * + * @return {boolean} [description] + */ +var RectangleToValues = function (rect, left, right, top, bottom, tolerance) +{ + if (tolerance === undefined) { tolerance = 0; } + + return !( + left > rect.right + tolerance || + right < rect.left - tolerance || + top > rect.bottom + tolerance || + bottom < rect.top - tolerance + ); +}; + +module.exports = RectangleToValues; + + +/***/ }), +/* 765 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineToLine = __webpack_require__(117); +var Contains = __webpack_require__(43); +var ContainsArray = __webpack_require__(163); +var Decompose = __webpack_require__(298); + +/** + * Checks for intersection between Rectangle shape and Triangle shape. + * + * @function Phaser.Geom.Intersects.RectangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - Rectangle object to test. + * @param {Phaser.Geom.Triangle} triangle - Triangle object to test. + * + * @return {boolean} A value of `true` if objects intersect; otherwise `false`. + */ +var RectangleToTriangle = function (rect, triangle) +{ + // First the cheapest ones: + + if ( + triangle.left > rect.right || + triangle.right < rect.left || + triangle.top > rect.bottom || + triangle.bottom < rect.top) + { + return false; + } + + var triA = triangle.getLineA(); + var triB = triangle.getLineB(); + var triC = triangle.getLineC(); + + // Are any of the triangle points within the rectangle? + + if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) + { + return true; + } + + if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) + { + return true; + } + + if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) + { + return true; + } + + // Cheap tests over, now to see if any of the lines intersect ... + + var rectA = rect.getLineA(); + var rectB = rect.getLineB(); + var rectC = rect.getLineC(); + var rectD = rect.getLineD(); + + if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) + { + return true; + } + + if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) + { + return true; + } + + if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) + { + return true; + } + + // None of the lines intersect, so are any rectangle points within the triangle? + + var points = Decompose(rect); + var within = ContainsArray(triangle, points, true); + + return (within.length > 0); +}; + +module.exports = RectangleToTriangle; + + +/***/ }), +/* 766 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PointToLine = __webpack_require__(299); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.PointToLineSegment + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var PointToLineSegment = function (point, line) +{ + if (!PointToLine(point, line)) + { + return false; + } + + var xMin = Math.min(line.x1, line.x2); + var xMax = Math.max(line.x1, line.x2); + var yMin = Math.min(line.y1, line.y2); + var yMax = Math.max(line.y1, line.y2); + + return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); +}; + +module.exports = PointToLineSegment; + + +/***/ }), +/* 767 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like + * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. + * + * An intersection is considered valid if: + * + * The line starts within, or ends within, the Rectangle. + * The line segment intersects one of the 4 rectangle edges. + * + * The for the purposes of this function rectangles are considered 'solid'. + * + * @function Phaser.Geom.Intersects.LineToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Rectangle|object)} rect - [description] + * + * @return {boolean} [description] + */ +var LineToRectangle = function (line, rect) +{ + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var bx1 = rect.x; + var by1 = rect.y; + var bx2 = rect.right; + var by2 = rect.bottom; + + var t = 0; + + // If the start or end of the line is inside the rect then we assume + // collision, as rects are solid for our use-case. + + if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || + (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) + { + return true; + } + + if (x1 < bx1 && x2 >= bx1) + { + // Left edge + t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); + + if (t > by1 && t <= by2) + { + return true; + } + } + else if (x1 > bx2 && x2 <= bx2) + { + // Right edge + t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); + + if (t >= by1 && t <= by2) + { + return true; + } + } + + if (y1 < by1 && y2 >= by1) + { + // Top edge + t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + else if (y1 > by2 && y2 <= by2) + { + // Bottom edge + t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + + return false; +}; + +module.exports = LineToRectangle; + + +/***/ }), +/* 768 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); +var RectangleToRectangle = __webpack_require__(164); + +/** + * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. + * + * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it wil be empty Rectangle (all values set to zero). + * + * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersetion, it will be returned without any change. + * + * @function Phaser.Geom.Intersects.GetRectangleIntersection + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [output,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle object. + * @param {Phaser.Geom.Rectangle} [output] - Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. + * + * @return {Phaser.Geom.Rectangle} A rectangle object with intersection data. + */ +var GetRectangleIntersection = function (rectA, rectB, output) +{ + if (output === undefined) { output = new Rectangle(); } + + if (RectangleToRectangle(rectA, rectB)) + { + output.x = Math.max(rectA.x, rectB.x); + output.y = Math.max(rectA.y, rectB.y); + output.width = Math.min(rectA.right, rectB.right) - output.x; + output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; + } + + return output; +}; + +module.exports = GetRectangleIntersection; + + +/***/ }), +/* 769 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.CircleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {boolean} [description] + */ +var CircleToRectangle = function (circle, rect) +{ + var halfWidth = rect.width / 2; + var halfHeight = rect.height / 2; + + var cx = Math.abs(circle.x - rect.x - halfWidth); + var cy = Math.abs(circle.y - rect.y - halfHeight); + var xDist = halfWidth + circle.radius; + var yDist = halfHeight + circle.radius; + + if (cx > xDist || cy > yDist) + { + return false; + } + else if (cx <= halfWidth || cy <= halfHeight) + { + return true; + } + else + { + var xCornerDist = cx - halfWidth; + var yCornerDist = cy - halfHeight; + var xCornerDistSq = xCornerDist * xCornerDist; + var yCornerDistSq = yCornerDist * yCornerDist; + var maxCornerDistSq = circle.radius * circle.radius; + + return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); + } +}; + +module.exports = CircleToRectangle; + + +/***/ }), +/* 770 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DistanceBetween = __webpack_require__(58); + +/** + * Checks if two Circles intersect. + * + * @function Phaser.Geom.Intersects.CircleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circleA - The first Circle to check for intersection. + * @param {Phaser.Geom.Circle} circleB - The second Circle to check for intersection. + * + * @return {boolean} `true` if the two Circles intersect, otherwise `false`. + */ +var CircleToCircle = function (circleA, circleB) +{ + return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); +}; + +module.exports = CircleToCircle; + + +/***/ }), +/* 771 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. + * + * @function Phaser.Geom.Ellipse.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + */ +var OffsetPoint = function (ellipse, point) +{ + ellipse.x += point.x; + ellipse.y += point.y; + + return ellipse; +}; + +module.exports = OffsetPoint; + + +/***/ }), +/* 772 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Ellipse by the values given. + * + * @function Phaser.Geom.Ellipse.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Ellipse by. + * @param {number} y - The amount to vertically offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + */ +var Offset = function (ellipse, x, y) +{ + ellipse.x += x; + ellipse.y += y; + + return ellipse; +}; + +module.exports = Offset; + + +/***/ }), +/* 773 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * Returns the bounds of the Ellipse object. + * + * @function Phaser.Geom.Ellipse.GetBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Ellipse bounds. + */ +var GetBounds = function (ellipse, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = ellipse.left; + out.y = ellipse.top; + out.width = ellipse.width; + out.height = ellipse.height; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }), +/* 774 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Ellipse.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. + * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. + * + * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. + */ +var Equals = function (ellipse, toCompare) +{ + return ( + ellipse.x === toCompare.x && + ellipse.y === toCompare.y && + ellipse.width === toCompare.width && + ellipse.height === toCompare.height + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 775 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse + * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * + * @function Phaser.Geom.Ellipse.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [dest,$return] + * + * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. + * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. + * + * @return {Phaser.Geom.Ellipse} The destination Ellipse. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 776 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(98); + +/** + * Check to see if the Ellipse contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Ellipse.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. + */ +var ContainsRect = function (ellipse, rect) +{ + return ( + Contains(ellipse, rect.x, rect.y) && + Contains(ellipse, rect.right, rect.y) && + Contains(ellipse, rect.x, rect.bottom) && + Contains(ellipse, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 777 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(98); + +/** + * Check to see if the Ellipse contains the given Point object. + * + * @function Phaser.Geom.Ellipse.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. + */ +var ContainsPoint = function (ellipse, point) +{ + return Contains(ellipse, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 778 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(99); + +/** + * Creates a new Ellipse instance based on the values contained in the given source. + * + * @function Phaser.Geom.Ellipse.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. + * + * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. + */ +var Clone = function (source) +{ + return new Ellipse(source.x, source.y, source.width, source.height); +}; + +module.exports = Clone; + + +/***/ }), +/* 779 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the Ellipse. + * + * @function Phaser.Geom.Ellipse.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. + * + * @return {number} The area of the Ellipse. + */ +var Area = function (ellipse) +{ + if (ellipse.isEmpty()) + { + return 0; + } + + // units squared + return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); +}; + +module.exports = Area; + + +/***/ }), +/* 780 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(99); + +Ellipse.Area = __webpack_require__(779); +Ellipse.Circumference = __webpack_require__(334); +Ellipse.CircumferencePoint = __webpack_require__(172); +Ellipse.Clone = __webpack_require__(778); +Ellipse.Contains = __webpack_require__(98); +Ellipse.ContainsPoint = __webpack_require__(777); +Ellipse.ContainsRect = __webpack_require__(776); +Ellipse.CopyFrom = __webpack_require__(775); +Ellipse.Equals = __webpack_require__(774); +Ellipse.GetBounds = __webpack_require__(773); +Ellipse.GetPoint = __webpack_require__(336); +Ellipse.GetPoints = __webpack_require__(335); +Ellipse.Offset = __webpack_require__(772); +Ellipse.OffsetPoint = __webpack_require__(771); +Ellipse.Random = __webpack_require__(203); + +module.exports = Ellipse; + + +/***/ }), +/* 781 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. + * + * @function Phaser.Geom.Circle.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [circle,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var OffsetPoint = function (circle, point) +{ + circle.x += point.x; + circle.y += point.y; + + return circle; +}; + +module.exports = OffsetPoint; + + +/***/ }), +/* 782 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given. + * + * @function Phaser.Geom.Circle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [circle,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Circle by. + * @param {number} y - The amount to vertically offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var Offset = function (circle, x, y) +{ + circle.x += x; + circle.y += y; + + return circle; +}; + +module.exports = Offset; + + +/***/ }), +/* 783 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); + +/** + * Returns the bounds of the Circle object. + * + * @function Phaser.Geom.Circle.GetBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Circles bounds. + */ +var GetBounds = function (circle, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = circle.left; + out.y = circle.top; + out.width = circle.diameter; + out.height = circle.diameter; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }), +/* 784 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compares the `x`, `y` and `radius` properties of the two given Circles. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Circle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The first Circle to compare. + * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. + * + * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. + */ +var Equals = function (circle, toCompare) +{ + return ( + circle.x === toCompare.x && + circle.y === toCompare.y && + circle.radius === toCompare.radius + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 785 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copies the `x`, `y` and `radius` properties from the `source` Circle + * into the given `dest` Circle, then returns the `dest` Circle. + * + * @function Phaser.Geom.Circle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [dest,$return] + * + * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. + * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. + * + * @return {Phaser.Geom.Circle} The destination Circle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.radius); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 786 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(44); + +/** + * Check to see if the Circle contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Circle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Circle or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. + */ +var ContainsRect = function (circle, rect) +{ + return ( + Contains(circle, rect.x, rect.y) && + Contains(circle, rect.right, rect.y) && + Contains(circle, rect.x, rect.bottom) && + Contains(circle, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 787 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(44); + +/** + * Check to see if the Circle contains the given Point object. + * + * @function Phaser.Geom.Circle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. + */ +var ContainsPoint = function (circle, point) +{ + return Contains(circle, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 788 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(81); + +/** + * Creates a new Circle instance based on the values contained in the given source. + * + * @function Phaser.Geom.Circle.Clone + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|object)} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. + * + * @return {Phaser.Geom.Circle} A clone of the source Circle. + */ +var Clone = function (source) +{ + return new Circle(source.x, source.y, source.radius); +}; + +module.exports = Clone; + + +/***/ }), +/* 789 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the circle. + * + * @function Phaser.Geom.Circle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. + * + * @return {number} The area of the Circle. + */ +var Area = function (circle) +{ + return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; +}; + +module.exports = Area; + + +/***/ }), +/* 790 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(81); + +Circle.Area = __webpack_require__(789); +Circle.Circumference = __webpack_require__(439); +Circle.CircumferencePoint = __webpack_require__(211); +Circle.Clone = __webpack_require__(788); +Circle.Contains = __webpack_require__(44); +Circle.ContainsPoint = __webpack_require__(787); +Circle.ContainsRect = __webpack_require__(786); +Circle.CopyFrom = __webpack_require__(785); +Circle.Equals = __webpack_require__(784); +Circle.GetBounds = __webpack_require__(783); +Circle.GetPoint = __webpack_require__(442); +Circle.GetPoints = __webpack_require__(440); +Circle.Offset = __webpack_require__(782); +Circle.OffsetPoint = __webpack_require__(781); +Circle.Random = __webpack_require__(210); + +module.exports = Circle; + + +/***/ }), +/* 791 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var LightsManager = __webpack_require__(303); +var PluginCache = __webpack_require__(15); + +/** + * @classdesc + * A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for the Light2D pipeline. + * + * Available from within a Scene via `this.lights`. + * + * Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method: + * + * ```javascript + * // Enable the Lights Manager because it is disabled by default + * this.lights.enable(); + * + * // Create a Light at [400, 300] with a radius of 200 + * this.lights.addLight(400, 300, 200); + * ``` + * + * For Game Objects to be affected by the Lights when rendered, you will need to set them to use the `Light2D` pipeline like so: + * + * ```javascript + * sprite.setPipeline('Light2D'); + * ``` + * + * @class LightsPlugin + * @extends Phaser.GameObjects.LightsManager + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that this Lights Plugin belongs to. + */ +var LightsPlugin = new Class({ + + Extends: LightsManager, + + initialize: + + function LightsPlugin (scene) + { + /** + * A reference to the Scene that this Lights Plugin belongs to. + * + * @name Phaser.GameObjects.LightsPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene's systems. + * + * @name Phaser.GameObjects.LightsPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + if (!scene.sys.settings.isBooted) + { + scene.sys.events.once('boot', this.boot, this); + } + + LightsManager.call(this); + }, + + /** + * Boot the Lights Plugin. + * + * @method Phaser.GameObjects.LightsPlugin#boot + * @since 3.0.0 + */ + boot: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); + }, + + /** + * Destroy the Lights Plugin. + * + * Cleans up all references. + * + * @method Phaser.GameObjects.LightsPlugin#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.scene = undefined; + this.systems = undefined; + } + +}); + +PluginCache.register('LightsPlugin', LightsPlugin, 'lights'); + +module.exports = LightsPlugin; + + +/***/ }), +/* 792 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(32); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var Quad = __webpack_require__(165); + +/** + * Creates a new Quad Game Object and returns it. + * + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#quad + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. + */ +GameObjectCreator.register('quad', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var quad = new Quad(this.scene, x, y, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, quad, config); + + return quad; +}); + + +/***/ }), +/* 793 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(32); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var GetValue = __webpack_require__(4); +var Mesh = __webpack_require__(118); + +/** + * Creates a new Mesh Game Object and returns it. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#mesh + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +GameObjectCreator.register('mesh', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var vertices = GetValue(config, 'vertices', []); + var colors = GetValue(config, 'colors', []); + var alphas = GetValue(config, 'alphas', []); + var uv = GetValue(config, 'uv', []); + + var mesh = new Mesh(this.scene, 0, 0, vertices, uv, colors, alphas, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, mesh, config); + + return mesh; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 794 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Quad = __webpack_require__(165); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Quad Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#quad + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('quad', function (x, y, key, frame) + { + return this.displayList.add(new Quad(this.scene, x, y, key, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 795 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Mesh = __webpack_require__(118); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Mesh Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#mesh + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number[]} vertices - An array containing the vertices data for this Mesh. + * @param {number[]} uv - An array containing the uv data for this Mesh. + * @param {number[]} colors - An array containing the color data for this Mesh. + * @param {number[]} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame) + { + return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, colors, alphas, texture, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 796 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects. + * + * @method Phaser.GameObjects.Mesh#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var MeshCanvasRenderer = function () +{ +}; + +module.exports = MeshCanvasRenderer; + + +/***/ }), +/* 797 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Mesh#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + + var vertices = src.vertices; + var uvs = src.uv; + var colors = src.colors; + var alphas = src.alphas; + + var meshVerticesLength = vertices.length; + var vertexCount = Math.floor(meshVerticesLength * 0.5); + + if (pipeline.vertexCount + vertexCount >= pipeline.vertexCapacity) + { + pipeline.flush(); + } + + pipeline.setTexture2D(texture, 0); + + var vertexViewF32 = pipeline.vertexViewF32; + var vertexViewU32 = pipeline.vertexViewU32; + + var vertexOffset = (pipeline.vertexCount * pipeline.vertexComponentCount) - 1; + + var colorIndex = 0; + var tintEffect = src.tintFill; + + for (var i = 0; i < meshVerticesLength; i += 2) + { + var x = vertices[i + 0]; + var y = vertices[i + 1]; + + var tx = x * calcMatrix.a + y * calcMatrix.c + calcMatrix.e; + var ty = x * calcMatrix.b + y * calcMatrix.d + calcMatrix.f; + + if (camera.roundPixels) + { + tx |= 0; + ty |= 0; + } + + vertexViewF32[++vertexOffset] = tx; + vertexViewF32[++vertexOffset] = ty; + vertexViewF32[++vertexOffset] = uvs[i + 0]; + vertexViewF32[++vertexOffset] = uvs[i + 1]; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = Utils.getTintAppendFloatAlpha(colors[colorIndex], camera.alpha * alphas[colorIndex]); + + colorIndex++; + } + + pipeline.vertexCount += vertexCount; +}; + +module.exports = MeshWebGLRenderer; + + +/***/ }), +/* 798 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(797); +} + +if (true) +{ + renderCanvas = __webpack_require__(796); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 799 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var Zone = __webpack_require__(135); + +/** + * Creates a new Zone Game Object and returns it. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#zone + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectCreator.register('zone', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 1); + var height = GetAdvancedValue(config, 'height', width); + + return new Zone(this.scene, x, y, width, height); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 800 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(32); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var TileSprite = __webpack_require__(168); + +/** + * @typedef {object} TileSprite + * @extends GameObjectConfig + * + * @property {number} [x=0] - The x coordinate of the Tile Sprite. + * @property {number} [y=0] - The y coordinate of the Tile Sprite. + * @property {integer} [width=512] - The width of the Tile Sprite. If zero it will use the size of the texture frame. + * @property {integer} [height=512] - The height of the Tile Sprite. If zero it will use the size of the texture frame. + * @property {string} [key=''] - The key of the Texture this Tile Sprite will use to render with, as stored in the Texture Manager. + * @property {string} [frame=''] - An optional frame from the Texture this Tile Sprite is rendering with. + */ + +/** + * Creates a new TileSprite Game Object and returns it. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tileSprite + * @since 3.0.0 + * + * @param {TileSprite} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectCreator.register('tileSprite', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 512); + var height = GetAdvancedValue(config, 'height', 512); + var key = GetAdvancedValue(config, 'key', ''); + var frame = GetAdvancedValue(config, 'frame', ''); + + var tile = new TileSprite(this.scene, x, y, width, height, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, tile, config); + + return tile; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 801 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(32); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var Text = __webpack_require__(169); + +/** + * Creates a new Text Game Object and returns it. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#text + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Text} The Game Object that was created. + */ +GameObjectCreator.register('text', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + // style Object = { + // font: [ 'font', '16px Courier' ], + // backgroundColor: [ 'backgroundColor', null ], + // fill: [ 'fill', '#fff' ], + // stroke: [ 'stroke', '#fff' ], + // strokeThickness: [ 'strokeThickness', 0 ], + // shadowOffsetX: [ 'shadow.offsetX', 0 ], + // shadowOffsetY: [ 'shadow.offsetY', 0 ], + // shadowColor: [ 'shadow.color', '#000' ], + // shadowBlur: [ 'shadow.blur', 0 ], + // shadowStroke: [ 'shadow.stroke', false ], + // shadowFill: [ 'shadow.fill', false ], + // align: [ 'align', 'left' ], + // maxLines: [ 'maxLines', 0 ], + // fixedWidth: [ 'fixedWidth', false ], + // fixedHeight: [ 'fixedHeight', false ], + // rtl: [ 'rtl', false ] + // } + + var content = GetAdvancedValue(config, 'text', ''); + var style = GetAdvancedValue(config, 'style', null); + + // Padding + // { padding: 2 } + // { padding: { x: , y: }} + // { padding: { left: , top: }} + // { padding: { left: , right: , top: , bottom: }} + + var padding = GetAdvancedValue(config, 'padding', null); + + if (padding !== null) + { + style.padding = padding; + } + + var text = new Text(this.scene, 0, 0, content, style); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, text, config); + + // Text specific config options: + + text.autoRound = GetAdvancedValue(config, 'autoRound', true); + text.resolution = GetAdvancedValue(config, 'resolution', 1); + + return text; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 802 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(119); +var BuildGameObject = __webpack_require__(32); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var GetValue = __webpack_require__(4); + +/** + * Creates a new Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#bitmapText + * @since 3.0.0 + * + * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectCreator.register('bitmapText', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var font = GetValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + var align = GetValue(config, 'align', 0); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 803 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(32); +var BuildGameObjectAnimation = __webpack_require__(339); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var Sprite = __webpack_require__(57); + +/** + * @typedef {object} SpriteConfig + * @extends GameObjectConfig + * + * @property {string} [key] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @property {(number|string)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ + +/** + * Creates a new Sprite Game Object and returns it. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#sprite + * @since 3.0.0 + * + * @param {SpriteConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Sprite} The Game Object that was created. + */ +GameObjectCreator.register('sprite', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var sprite = new Sprite(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, sprite, config); + + // Sprite specific config options: + + BuildGameObjectAnimation(sprite, config); + + return sprite; +}); + + +/***/ }), +/* 804 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(32); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var RenderTexture = __webpack_require__(170); + +/** + * @typedef {object} RenderTextureConfig + * + * @property {number} [x=0] - The x coordinate of the RenderTexture's position. + * @property {number} [y=0] - The y coordinate of the RenderTexture's position. + * @property {number} [width=32] - The width of the RenderTexture. + * @property {number} [height=32] - The height of the RenderTexture. + */ + +/** + * Creates a new Render Texture Game Object and returns it. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#renderTexture + * @since 3.2.0 + * + * @param {RenderTextureConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectCreator.register('renderTexture', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 32); + var height = GetAdvancedValue(config, 'height', 32); + + var renderTexture = new RenderTexture(this.scene, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, renderTexture, config); + + return renderTexture; +}); + + +/***/ }), +/* 805 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var GetFastValue = __webpack_require__(1); +var ParticleEmitterManager = __webpack_require__(171); + +/** + * Creates a new Particle Emitter Manager Game Object and returns it. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#particles + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectCreator.register('particles', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var emitters = GetFastValue(config, 'emitters', null); + + // frame is optional and can contain the emitters array or object if skipped + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + var add = GetFastValue(config, 'add', false); + + if (add) + { + this.displayList.add(manager); + } + + this.updateList.add(manager); + + return manager; +}); + + +/***/ }), +/* 806 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(32); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); +var Image = __webpack_require__(78); + +/** + * Creates a new Image Game Object and returns it. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#image + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Image} The Game Object that was created. + */ +GameObjectCreator.register('image', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var image = new Image(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, image, config); + + return image; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 807 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(14); +var Group = __webpack_require__(97); + +/** + * Creates a new Group Game Object and returns it. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#group + * @since 3.0.0 + * + * @param {GroupConfig} config - The configuration object this Game Object will use to create itself. + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectCreator.register('group', function (config) +{ + return new Group(this.scene, null, config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 808 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(14); +var Graphics = __webpack_require__(174); + +/** + * Creates a new Graphics Game Object and returns it. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#graphics + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Graphics} The Game Object that was created. + */ +GameObjectCreator.register('graphics', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + var graphics = new Graphics(this.scene, config); + + if (config.add) + { + this.scene.sys.displayList.add(graphics); + } + + return graphics; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 809 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(175); +var BuildGameObject = __webpack_require__(32); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); + +/** + * @typedef {object} BitmapTextConfig + * @extends GameObjectConfig + * + * @property {string} [font=''] - The key of the font to use from the BitmapFont cache. + * @property {string} [text=''] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @property {(number|false)} [size=false] - The font size to set. + */ + +/** + * Creates a new Dynamic Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText + * @since 3.0.0 + *² + * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectCreator.register('dynamicBitmapText', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var font = GetAdvancedValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 810 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(32); +var Container = __webpack_require__(176); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); + +/** + * Creates a new Container Game Object and returns it. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#container + * @since 3.4.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Container} The Game Object that was created. + */ +GameObjectCreator.register('container', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + + var container = new Container(this.scene, x, y); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, container, config); + + return container; +}); + + +/***/ }), +/* 811 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(177); +var BuildGameObject = __webpack_require__(32); +var GameObjectCreator = __webpack_require__(14); +var GetAdvancedValue = __webpack_require__(13); + +/** + * Creates a new Blitter Game Object and returns it. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#blitter + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectCreator.register('blitter', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var blitter = new Blitter(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, blitter, config); + + return blitter; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 812 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Triangle = __webpack_require__(307); + +/** + * Creates a new Triangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Triangle Game Object has been built into Phaser. + * + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @method Phaser.GameObjects.GameObjectFactory#triangle + * @since 3.13.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 {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Triangle} The Game Object that was created. + */ +GameObjectFactory.register('triangle', function (x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) +{ + return this.displayList.add(new Triangle(this.scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 813 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Star = __webpack_require__(308); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Star Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Star Game Object has been built into Phaser. + * + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#star + * @since 3.13.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 {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star. + * @param {number} [outerRadius=64] - The outer radius of the star. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Star} The Game Object that was created. + */ +GameObjectFactory.register('star', function (x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) +{ + return this.displayList.add(new Star(this.scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 814 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Rectangle = __webpack_require__(309); + +/** + * Creates a new Rectangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. + * + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @method Phaser.GameObjects.GameObjectFactory#rectangle + * @since 3.13.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 {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Rectangle} The Game Object that was created. + */ +GameObjectFactory.register('rectangle', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Rectangle(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 815 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Polygon = __webpack_require__(314); + +/** + * Creates a new Polygon Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Polygon Game Object has been built into Phaser. + * + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * @method Phaser.GameObjects.GameObjectFactory#polygon + * @since 3.13.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 {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Polygon} The Game Object that was created. + */ +GameObjectFactory.register('polygon', function (x, y, points, fillColor, fillAlpha) +{ + return this.displayList.add(new Polygon(this.scene, x, y, points, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 816 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Line = __webpack_require__(315); + +/** + * Creates a new Line Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Line Game Object has been built into Phaser. + * + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * @method Phaser.GameObjects.GameObjectFactory#line + * @since 3.13.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 {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Line} The Game Object that was created. + */ +GameObjectFactory.register('line', function (x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) +{ + return this.displayList.add(new Line(this.scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha)); +}); + + +/***/ }), +/* 817 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var IsoTriangle = __webpack_require__(316); + +/** + * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. + * + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @method Phaser.GameObjects.GameObjectFactory#isotriangle + * @since 3.13.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 {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + * + * @return {Phaser.GameObjects.IsoTriangle} The Game Object that was created. + */ +GameObjectFactory.register('isotriangle', function (x, y, size, height, reversed, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoTriangle(this.scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight)); +}); + + +/***/ }), +/* 818 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var IsoBox = __webpack_require__(317); + +/** + * Creates a new IsoBox Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. + * + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * + * @method Phaser.GameObjects.GameObjectFactory#isobox + * @since 3.13.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 {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + * + * @return {Phaser.GameObjects.IsoBox} The Game Object that was created. + */ +GameObjectFactory.register('isobox', function (x, y, size, height, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoBox(this.scene, x, y, size, height, fillTop, fillLeft, fillRight)); +}); + + +/***/ }), +/* 819 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Grid = __webpack_require__(318); + +/** + * Creates a new Grid Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Grid Game Object has been built into Phaser. + * + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @method Phaser.GameObjects.GameObjectFactory#grid + * @since 3.13.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 {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [outlineFillColor] - The color of the lines between the grid cells. + * @param {number} [outlineFillAlpha] - The alpha of the lines between the grid cells. + * + * @return {Phaser.GameObjects.Grid} The Game Object that was created. + */ +GameObjectFactory.register('grid', function (x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha) +{ + return this.displayList.add(new Grid(this.scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha)); +}); + + +/***/ }), +/* 820 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(319); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Ellipse Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. + * + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#ellipse + * @since 3.13.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 {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Ellipse} The Game Object that was created. + */ +GameObjectFactory.register('ellipse', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Ellipse(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 821 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Curve = __webpack_require__(320); + +/** + * Creates a new Curve Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Curve Game Object has been built into Phaser. + * + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#curve + * @since 3.13.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 {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Curve} The Game Object that was created. + */ +GameObjectFactory.register('curve', function (x, y, curve, fillColor, fillAlpha) +{ + return this.displayList.add(new Curve(this.scene, x, y, curve, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 822 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Arc = __webpack_require__(321); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Arc Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * @method Phaser.GameObjects.GameObjectFactory#arc + * @since 3.13.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 {number} [radius=128] - The radius of the arc. + * @param {integer} [startAngle=0] - The start angle of the arc, in degrees. + * @param {integer} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - The winding order of the start and end angles. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('arc', function (x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha)); +}); + +/** + * Creates a new Circle Shape Game Object and adds it to the Scene. + * + * A Circle is an Arc with no defined start and end angle, making it render as a complete circle. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#circle + * @since 3.13.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 {number} [radius=128] - The radius of the circle. + * @param {number} [fillColor] - The color the circle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('circle', function (x, y, radius, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, 0, 360, false, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 823 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Zone = __webpack_require__(135); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Zone Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#zone + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectFactory.register('zone', function (x, y, width, height) +{ + return this.displayList.add(new Zone(this.scene, x, y, width, height)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 824 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileSprite = __webpack_require__(168); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new TileSprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tileSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {integer} height - The height of the Game Object. If zero it will use the size of the texture frame. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) +{ + return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 825 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Text = __webpack_require__(169); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Text Game Object and adds it to the Scene. + * + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + * + * Note: This method will only be available if the Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#text + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {object} [style] - The Text style configuration object. + * + * @return {Phaser.GameObjects.Text} The Game Object that was created. + */ +GameObjectFactory.register('text', function (x, y, text, style) +{ + return this.displayList.add(new Text(this.scene, x, y, text, style)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 826 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(119); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#bitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectFactory.register('bitmapText', function (x, y, font, text, size, align) +{ + return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size, align)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 827 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Sprite = __webpack_require__(57); + +/** + * Creates a new Sprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Sprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Sprite} The Game Object that was created. + */ +GameObjectFactory.register('sprite', function (x, y, key, frame) +{ + var sprite = new Sprite(this.scene, x, y, key, frame); + + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 828 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var RenderTexture = __webpack_require__(170); + +/** + * Creates a new Render Texture Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. + * + * @method Phaser.GameObjects.GameObjectFactory#renderTexture + * @since 3.2.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectFactory.register('renderTexture', function (x, y, width, height) +{ + return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); +}); + + +/***/ }), +/* 829 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var PathFollower = __webpack_require__(324); + +/** + * Creates a new PathFollower Game Object and adds it to the Scene. + * + * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#follower + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. + */ +GameObjectFactory.register('follower', function (path, x, y, key, frame) +{ + var sprite = new PathFollower(this.scene, path, x, y, key, frame); + + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 830 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var ParticleEmitterManager = __webpack_require__(171); + +/** + * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#particles + * @since 3.0.0 + * + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer|object)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {ParticleEmitterConfig|ParticleEmitterConfig[]} [emitters] - Configuration settings for one or more emitters to create. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectFactory.register('particles', function (key, frame, emitters) +{ + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + this.displayList.add(manager); + this.updateList.add(manager); + + return manager; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 831 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Image = __webpack_require__(78); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Image Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Image} The Game Object that was created. + */ +GameObjectFactory.register('image', function (x, y, key, frame) +{ + return this.displayList.add(new Image(this.scene, x, y, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 832 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Group = __webpack_require__(97); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Group Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#group + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupConfig[])} [children] - Game Objects to add to this Group; or the `config` argument. + * @param {GroupConfig} [config] - A Group Configuration object. + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectFactory.register('group', function (children, config) +{ + return this.updateList.add(new Group(this.scene, children, config)); +}); + + +/***/ }), +/* 833 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Graphics = __webpack_require__(174); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Graphics Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Graphics Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#graphics + * @since 3.0.0 + * + * @param {GraphicsOptions} [config] - The Graphics configuration. + * + * @return {Phaser.GameObjects.Graphics} The Game Object that was created. + */ +GameObjectFactory.register('graphics', function (config) +{ + return this.displayList.add(new Graphics(this.scene, config)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 834 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DynamicBitmapText = __webpack_require__(175); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) +{ + return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 835 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Container = __webpack_require__(176); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Container Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#container + * @since 3.4.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. + * + * @return {Phaser.GameObjects.Container} The Game Object that was created. + */ +GameObjectFactory.register('container', function (x, y, children) +{ + return this.displayList.add(new Container(this.scene, x, y, children)); +}); + + +/***/ }), +/* 836 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(177); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Blitter Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#blitter + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} key - The key of the Texture the Blitter object will use. + * @param {(string|integer)} [frame] - The default Frame children of the Blitter will use. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectFactory.register('blitter', function (x, y, key, frame) +{ + return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 837 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(35); +var LineStyleCanvas = __webpack_require__(40); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + ctx.beginPath(); + + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.lineTo(x3, y3); + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = TriangleCanvasRenderer; + + +/***/ }), +/* 838 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StrokePathWebGL = __webpack_require__(67); +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + var fillTint = pipeline.fillTint; + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + pipeline.setTexture2D(); + + pipeline.batchFillTriangle( + x1, + y1, + x2, + y2, + x3, + y3, + shapeMatrix, + camMatrix + ); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = TriangleWebGLRenderer; + + +/***/ }), +/* 839 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(838); +} + +if (true) +{ + renderCanvas = __webpack_require__(837); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 840 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(35); +var LineStyleCanvas = __webpack_require__(40); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = StarCanvasRenderer; + + +/***/ }), +/* 841 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(92); +var StrokePathWebGL = __webpack_require__(67); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = StarWebGLRenderer; + + +/***/ }), +/* 842 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(841); +} + +if (true) +{ + renderCanvas = __webpack_require__(840); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 843 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(35); +var LineStyleCanvas = __webpack_require__(40); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.rect( + -dx, + -dy, + src.width, + src.height + ); + + ctx.stroke(); + } + } +}; + +module.exports = RectangleCanvasRenderer; + + +/***/ }), +/* 844 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StrokePathWebGL = __webpack_require__(67); +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + var fillTint = pipeline.fillTint; + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + pipeline.batchFillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = RectangleWebGLRenderer; + + +/***/ }), +/* 845 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(844); +} + +if (true) +{ + renderCanvas = __webpack_require__(843); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 846 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(35); +var LineStyleCanvas = __webpack_require__(40); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = PolygonCanvasRenderer; + + +/***/ }), +/* 847 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(92); +var StrokePathWebGL = __webpack_require__(67); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = PolygonWebGLRenderer; + + +/***/ }), +/* 848 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(847); +} + +if (true) +{ + renderCanvas = __webpack_require__(846); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 849 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineStyleCanvas = __webpack_require__(40); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.moveTo(src.geom.x1 - dx, src.geom.y1 - dy); + ctx.lineTo(src.geom.x2 - dx, src.geom.y2 - dy); + + ctx.stroke(); + } + } +}; + +module.exports = LineCanvasRenderer; + + +/***/ }), +/* 850 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isStroked) + { + var strokeTint = pipeline.strokeTint; + var color = Utils.getTintAppendFloatAlphaAndSwap(src.strokeColor, src.strokeAlpha * alpha); + + strokeTint.TL = color; + strokeTint.TR = color; + strokeTint.BL = color; + strokeTint.BR = color; + + var startWidth = src._startWidth; + var endWidth = src._endWidth; + + pipeline.setTexture2D(); + + pipeline.batchLine( + src.geom.x1 - dx, + src.geom.y1 - dy, + src.geom.x2 - dx, + src.geom.y2 - dy, + startWidth, + endWidth, + 1, + 0, + false, + shapeMatrix, + camMatrix + ); + } +}; + +module.exports = LineWebGLRenderer; + + +/***/ }), +/* 851 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(850); +} + +if (true) +{ + renderCanvas = __webpack_require__(849); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 852 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(35); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + // Top Face + + if (src.showTop && reversed) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(0, sizeB - height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + } +}; + +module.exports = IsoTriangleCanvasRenderer; + + +/***/ }), +/* 853 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + var alpha = camera.alpha * src.alpha; + + if (!src.isFilled) + { + return; + } + + var tint; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + // Top Face + + if (src.showTop && reversed) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillTop, alpha); + + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, -sizeB - height); + y1 = calcMatrix.getY(0, -sizeB - height); + + x2 = calcMatrix.getX(sizeA, -height); + y2 = calcMatrix.getY(sizeA, -height); + + var x3 = calcMatrix.getX(0, sizeB - height); + var y3 = calcMatrix.getY(0, sizeB - height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillLeft, alpha); + + if (reversed) + { + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + else + { + x0 = calcMatrix.getX(-sizeA, 0); + y0 = calcMatrix.getY(-sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + + pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillRight, alpha); + + if (reversed) + { + x0 = calcMatrix.getX(sizeA, -height); + y0 = calcMatrix.getY(sizeA, -height); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + else + { + x0 = calcMatrix.getX(sizeA, 0); + y0 = calcMatrix.getY(sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + + pipeline.setTexture2D(); + + pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2); + } +}; + +module.exports = IsoTriangleWebGLRenderer; + + +/***/ }), +/* 854 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(853); +} + +if (true) +{ + renderCanvas = __webpack_require__(852); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 855 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(35); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + // Top Face + + if (src.showTop) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, -1); + ctx.lineTo(0, sizeB - 1); + ctx.lineTo(-sizeA, -1); + ctx.lineTo(-sizeA, -height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(-sizeA, -height); + ctx.lineTo(-sizeA, 0); + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, 0); + + ctx.fill(); + } + } +}; + +module.exports = IsoBoxCanvasRenderer; + + +/***/ }), +/* 856 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var alpha = camera.alpha * src.alpha; + + if (!src.isFilled) + { + return; + } + + var tint; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + var x3; + var y3; + + // Top Face + + if (src.showTop) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillTop, alpha); + + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, -sizeB - height); + y1 = calcMatrix.getY(0, -sizeB - height); + + x2 = calcMatrix.getX(sizeA, -height); + y2 = calcMatrix.getY(sizeA, -height); + + x3 = calcMatrix.getX(0, sizeB - height); + y3 = calcMatrix.getY(0, sizeB - height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillLeft, alpha); + + x0 = calcMatrix.getX(-sizeA, 0); + y0 = calcMatrix.getY(-sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + + x3 = calcMatrix.getX(-sizeA, -height); + y3 = calcMatrix.getY(-sizeA, -height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillRight, alpha); + + x0 = calcMatrix.getX(sizeA, 0); + y0 = calcMatrix.getY(sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + + x3 = calcMatrix.getX(sizeA, -height); + y3 = calcMatrix.getY(sizeA, -height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } +}; + +module.exports = IsoBoxWebGLRenderer; + + +/***/ }), +/* 857 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(856); +} + +if (true) +{ + renderCanvas = __webpack_require__(855); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 858 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(35); +var LineStyleCanvas = __webpack_require__(40); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.rect( + -dx, + -dy, + src.width, + src.height + ); + + ctx.stroke(); + } + } +}; + +module.exports = RectangleCanvasRenderer; + + +/***/ }), +/* 859 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Grid#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Grid} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + calcMatrix.translate(-src._displayOriginX, -src._displayOriginY); + + var alpha = camera.alpha * src.alpha; + + // Work out the grid size + + var width = src.width; + var height = src.height; + + var cellWidth = src.cellWidth; + var cellHeight = src.cellHeight; + + var gridWidth = Math.ceil(width / cellWidth); + var gridHeight = Math.ceil(height / cellHeight); + + var cellWidthA = cellWidth; + var cellHeightA = cellHeight; + + var cellWidthB = cellWidth - ((gridWidth * cellWidth) - width); + var cellHeightB = cellHeight - ((gridHeight * cellHeight) - height); + + var fillTint; + var fillTintColor; + + var showCells = src.showCells; + var showAltCells = src.showAltCells; + var showOutline = src.showOutline; + + var x = 0; + var y = 0; + var r = 0; + var cw = 0; + var ch = 0; + + if (showOutline) + { + // To make room for the grid lines (in case alpha < 1) + cellWidthA--; + cellHeightA--; + + if (cellWidthB === cellWidth) + { + cellWidthB--; + } + + if (cellHeightB === cellHeight) + { + cellHeightB--; + } + } + + if (showCells && src.fillAlpha > 0) + { + fillTint = pipeline.fillTint; + fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && r) + { + r = 0; + continue; + } + + r++; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + pipeline.setTexture2D(); + + pipeline.batchFillRect( + x * cellWidth, + y * cellHeight, + cw, + ch + ); + } + } + } + + if (showAltCells && src.altFillAlpha > 0) + { + fillTint = pipeline.fillTint; + fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.altFillColor, src.altFillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && !r) + { + r = 1; + continue; + } + + r = 0; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + pipeline.setTexture2D(); + + pipeline.batchFillRect( + x * cellWidth, + y * cellHeight, + cw, + ch + ); + } + } + } + + if (showOutline && src.outlineFillAlpha > 0) + { + var strokeTint = pipeline.strokeTint; + var color = Utils.getTintAppendFloatAlphaAndSwap(src.outlineFillColor, src.outlineFillAlpha * alpha); + + strokeTint.TL = color; + strokeTint.TR = color; + strokeTint.BL = color; + strokeTint.BR = color; + + for (x = 1; x < gridWidth; x++) + { + var x1 = x * cellWidth; + + pipeline.setTexture2D(); + + pipeline.batchLine(x1, 0, x1, height, 1, 1, 1, 0, false); + } + + for (y = 1; y < gridHeight; y++) + { + var y1 = y * cellHeight; + + pipeline.setTexture2D(); + + pipeline.batchLine(0, y1, width, y1, 1, 1, 1, 0, false); + } + } +}; + +module.exports = GridWebGLRenderer; + + +/***/ }), +/* 860 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(859); +} + +if (true) +{ + renderCanvas = __webpack_require__(858); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 861 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(35); +var LineStyleCanvas = __webpack_require__(40); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = EllipseCanvasRenderer; + + +/***/ }), +/* 862 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(92); +var StrokePathWebGL = __webpack_require__(67); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = EllipseWebGLRenderer; + + +/***/ }), +/* 863 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(862); +} + +if (true) +{ + renderCanvas = __webpack_require__(861); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 864 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(35); +var LineStyleCanvas = __webpack_require__(40); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = CurveCanvasRenderer; + + +/***/ }), +/* 865 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(92); +var StrokePathWebGL = __webpack_require__(67); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = CurveWebGLRenderer; + + +/***/ }), +/* 866 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(865); +} + +if (true) +{ + renderCanvas = __webpack_require__(864); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 867 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DegToRad = __webpack_require__(36); +var FillStyleCanvas = __webpack_require__(35); +var LineStyleCanvas = __webpack_require__(40); +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var radius = src.radius; + + ctx.beginPath(); + + ctx.arc( + (radius) - src.originX * (radius * 2), + (radius) - src.originY * (radius * 2), + radius, + DegToRad(src._startAngle), + DegToRad(src._endAngle), + src.anticlockwise + ); + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = ArcCanvasRenderer; + + +/***/ }), +/* 868 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(92); +var StrokePathWebGL = __webpack_require__(67); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = ArcWebGLRenderer; + + +/***/ }), +/* 869 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(868); +} + +if (true) +{ + renderCanvas = __webpack_require__(867); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 870 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + src.updateCanvas(); + + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = TileSpriteCanvasRenderer; + + +/***/ }), +/* 871 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + src.updateCanvas(); + + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + src.fillPattern, + src.displayFrame.width * src.tileScaleX, src.displayFrame.height * src.tileScaleY, + src.x, src.y, + src.width, src.height, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.originX * src.width, src.originY * src.height, + 0, 0, src.width, src.height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + (src.tilePositionX % src.displayFrame.width) / src.displayFrame.width, + (src.tilePositionY % src.displayFrame.height) / src.displayFrame.height, + camera, + parentMatrix + ); +}; + +module.exports = TileSpriteWebGLRenderer; + + +/***/ }), +/* 872 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(871); +} + +if (true) +{ + renderCanvas = __webpack_require__(870); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 873 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(26); + +/** + * Calculates the ascent, descent and fontSize of a given font style. + * + * @function Phaser.GameObjects.Text.MeasureText + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text.TextStyle} textStyle - The TextStyle object to measure. + * + * @return {object} An object containing the ascent, descent and fontSize of the TextStyle. + */ +var MeasureText = function (textStyle) +{ + // @property {HTMLCanvasElement} canvas - The canvas element that the text is rendered. + var canvas = CanvasPool.create(this); + + // @property {HTMLCanvasElement} context - The context of the canvas element that the text is rendered to. + var context = canvas.getContext('2d'); + + textStyle.syncFont(canvas, context); + + var width = Math.ceil(context.measureText(textStyle.testString).width * textStyle.baselineX); + var baseline = width; + var height = 2 * baseline; + + baseline = baseline * textStyle.baselineY | 0; + + canvas.width = width; + canvas.height = height; + + context.fillStyle = '#f00'; + context.fillRect(0, 0, width, height); + + context.font = textStyle._font; + + context.textBaseline = 'alphabetic'; + context.fillStyle = '#000'; + context.fillText(textStyle.testString, 0, baseline); + + var output = { + ascent: 0, + descent: 0, + fontSize: 0 + }; + + if (!context.getImageData(0, 0, width, height)) + { + output.ascent = baseline; + output.descent = baseline + 6; + output.fontSize = output.ascent + output.descent; + + CanvasPool.remove(canvas); + + return output; + } + + var imagedata = context.getImageData(0, 0, width, height).data; + var pixels = imagedata.length; + var line = width * 4; + var i; + var j; + var idx = 0; + var stop = false; + + // ascent. scan from top to bottom until we find a non red pixel + for (i = 0; i < baseline; i++) + { + for (j = 0; j < line; j += 4) + { + if (imagedata[idx + j] !== 255) + { + stop = true; + break; + } + } + + if (!stop) + { + idx += line; + } + else + { + break; + } + } + + output.ascent = baseline - i; + + idx = pixels - line; + stop = false; + + // descent. scan from bottom to top until we find a non red pixel + for (i = height; i > baseline; i--) + { + for (j = 0; j < line; j += 4) + { + if (imagedata[idx + j] !== 255) + { + stop = true; + break; + } + } + + if (!stop) + { + idx -= line; + } + else + { + break; + } + } + + output.descent = (i - baseline); + output.fontSize = output.ascent + output.descent; + + CanvasPool.remove(canvas); + + return output; +}; + +module.exports = MeasureText; + + +/***/ }), +/* 874 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetAdvancedValue = __webpack_require__(13); +var GetValue = __webpack_require__(4); +var MeasureText = __webpack_require__(873); + +// Key: [ Object Key, Default Value ] + +/** + * A custom function that will be responsible for wrapping the text. + * @callback TextStyleWordWrapCallback + * + * @param {string} text - The string to wrap. + * @param {Phaser.GameObjects.Text} textObject - The Text instance. + * + * @return {(string|string[])} Should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + */ + +var propertyMap = { + fontFamily: [ 'fontFamily', 'Courier' ], + fontSize: [ 'fontSize', '16px' ], + fontStyle: [ 'fontStyle', '' ], + backgroundColor: [ 'backgroundColor', null ], + color: [ 'color', '#fff' ], + stroke: [ 'stroke', '#fff' ], + strokeThickness: [ 'strokeThickness', 0 ], + shadowOffsetX: [ 'shadow.offsetX', 0 ], + shadowOffsetY: [ 'shadow.offsetY', 0 ], + shadowColor: [ 'shadow.color', '#000' ], + shadowBlur: [ 'shadow.blur', 0 ], + shadowStroke: [ 'shadow.stroke', false ], + shadowFill: [ 'shadow.fill', false ], + align: [ 'align', 'left' ], + maxLines: [ 'maxLines', 0 ], + fixedWidth: [ 'fixedWidth', 0 ], + fixedHeight: [ 'fixedHeight', 0 ], + resolution: [ 'resolution', 0 ], + rtl: [ 'rtl', false ], + testString: [ 'testString', '|MÉqgy' ], + baselineX: [ 'baselineX', 1.2 ], + baselineY: [ 'baselineY', 1.4 ], + wordWrapWidth: [ 'wordWrap.width', null ], + wordWrapCallback: [ 'wordWrap.callback', null ], + wordWrapCallbackScope: [ 'wordWrap.callbackScope', null ], + wordWrapUseAdvanced: [ 'wordWrap.useAdvancedWrap', false ] +}; + +/** + * Font metrics for a Text Style object. + * + * @typedef {object} BitmapTextMetrics + * + * @property {number} ascent - The ascent of the font. + * @property {number} descent - The descent of the font. + * @property {number} fontSize - The size of the font. + */ + +/** + * @classdesc + * Style settings for a Text object. + * + * @class TextStyle + * @memberof Phaser.GameObjects.Text + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling. + * @param {object} style - The style settings to set. + */ +var TextStyle = new Class({ + + initialize: + + function TextStyle (text, style) + { + /** + * The Text object that this TextStyle is styling. + * + * @name Phaser.GameObjects.Text.TextStyle#parent + * @type {Phaser.GameObjects.Text} + * @since 3.0.0 + */ + this.parent = text; + + /** + * The font family. + * + * @name Phaser.GameObjects.Text.TextStyle#fontFamily + * @type {string} + * @default 'Courier' + * @since 3.0.0 + */ + this.fontFamily; + + /** + * The font size. + * + * @name Phaser.GameObjects.Text.TextStyle#fontSize + * @type {string} + * @default '16px' + * @since 3.0.0 + */ + this.fontSize; + + /** + * The font style. + * + * @name Phaser.GameObjects.Text.TextStyle#fontStyle + * @type {string} + * @since 3.0.0 + */ + this.fontStyle; + + /** + * The background color. + * + * @name Phaser.GameObjects.Text.TextStyle#backgroundColor + * @type {string} + * @since 3.0.0 + */ + this.backgroundColor; + + /** + * The text fill color. + * + * @name Phaser.GameObjects.Text.TextStyle#color + * @type {string} + * @default '#fff' + * @since 3.0.0 + */ + this.color; + + /** + * The text stroke color. + * + * @name Phaser.GameObjects.Text.TextStyle#stroke + * @type {string} + * @default '#fff' + * @since 3.0.0 + */ + this.stroke; + + /** + * The text stroke thickness. + * + * @name Phaser.GameObjects.Text.TextStyle#strokeThickness + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.strokeThickness; + + /** + * The horizontal shadow offset. + * + * @name Phaser.GameObjects.Text.TextStyle#shadowOffsetX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowOffsetX; + + /** + * The vertical shadow offset. + * + * @name Phaser.GameObjects.Text.TextStyle#shadowOffsetY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowOffsetY; + + /** + * The shadow color. + * + * @name Phaser.GameObjects.Text.TextStyle#shadowColor + * @type {string} + * @default '#000' + * @since 3.0.0 + */ + this.shadowColor; + + /** + * The shadow blur radius. + * + * @name Phaser.GameObjects.Text.TextStyle#shadowBlur + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.shadowBlur; + + /** + * Whether shadow stroke is enabled or not. + * + * @name Phaser.GameObjects.Text.TextStyle#shadowStroke + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shadowStroke; + + /** + * Whether shadow fill is enabled or not. + * + * @name Phaser.GameObjects.Text.TextStyle#shadowFill + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.shadowFill; + + /** + * The text alignment. + * + * @name Phaser.GameObjects.Text.TextStyle#align + * @type {string} + * @default 'left' + * @since 3.0.0 + */ + this.align; + + /** + * The maximum number of lines to draw. + * + * @name Phaser.GameObjects.Text.TextStyle#maxLines + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.maxLines; + + /** + * The fixed width of the text. + * + * `0` means no fixed with. + * + * @name Phaser.GameObjects.Text.TextStyle#fixedWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.fixedWidth; + + /** + * The fixed height of the text. + * + * `0` means no fixed height. + * + * @name Phaser.GameObjects.Text.TextStyle#fixedHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.fixedHeight; + + /** + * The resolution the text is rendered to its internal canvas at. + * The default is 0, which means it will use the resolution set in the Game Config. + * + * @name Phaser.GameObjects.Text.TextStyle#resolution + * @type {number} + * @default 0 + * @since 3.12.0 + */ + this.resolution; + + /** + * Whether the text should render right to left. + * + * @name Phaser.GameObjects.Text.TextStyle#rtl + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rtl; + + /** + * The test string to use when measuring the font. + * + * @name Phaser.GameObjects.Text.TextStyle#testString + * @type {string} + * @default '|MÉqgy' + * @since 3.0.0 + */ + this.testString; + + /** + * The amount of horizontal padding adding to the width of the text when calculating the font metrics. + * + * @name Phaser.GameObjects.Text.TextStyle#baselineX + * @type {number} + * @default 1.2 + * @since 3.3.0 + */ + this.baselineX; + + /** + * The amount of vertical padding adding to the width of the text when calculating the font metrics. + * + * @name Phaser.GameObjects.Text.TextStyle#baselineY + * @type {number} + * @default 1.4 + * @since 3.3.0 + */ + this.baselineY; + + /** + * The font style, size and family. + * + * @name Phaser.GameObjects.Text.TextStyle#_font + * @type {string} + * @private + * @since 3.0.0 + */ + this._font; + + // Set to defaults + user style + this.setStyle(style, false, true); + + var metrics = GetValue(style, 'metrics', false); + + // Provide optional TextMetrics in the style object to avoid the canvas look-up / scanning + // Doing this is reset if you then change the font of this TextStyle after creation + if (metrics) + { + this.metrics = { + ascent: GetValue(metrics, 'ascent', 0), + descent: GetValue(metrics, 'descent', 0), + fontSize: GetValue(metrics, 'fontSize', 0) + }; + } + else + { + this.metrics = MeasureText(this); + } + }, + + /** + * Set the text style. + * + * @example + * text.setStyle({ + * fontSize: '64px', + * fontFamily: 'Arial', + * color: '#ffffff', + * align: 'center', + * backgroundColor: '#ff00ff' + * }); + * + * @method Phaser.GameObjects.Text.TextStyle#setStyle + * @since 3.0.0 + * + * @param {object} style - The style settings to set. + * @param {boolean} [updateText=true] - Whether to update the text immediately. + * @param {boolean} [setDefaults=false] - Use the default values is not set, or the local values. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setStyle: function (style, updateText, setDefaults) + { + if (updateText === undefined) { updateText = true; } + if (setDefaults === undefined) { setDefaults = false; } + + // Avoid type mutation + if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number') + { + style.fontSize = style.fontSize.toString() + 'px'; + } + + for (var key in propertyMap) + { + var value = (setDefaults) ? propertyMap[key][1] : this[key]; + + if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') + { + // Callback & scope should be set without processing the values + this[key] = GetValue(style, propertyMap[key][0], value); + } + else + { + this[key] = GetAdvancedValue(style, propertyMap[key][0], value); + } + } + + // Allow for 'font' override + var font = GetValue(style, 'font', null); + + if (font === null) + { + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); + } + else + { + this._font = font; + } + + // Allow for 'fill' to be used in place of 'color' + var fill = GetValue(style, 'fill', null); + + if (fill !== null) + { + this.color = fill; + } + + if (updateText) + { + return this.update(true); + } + else + { + return this.parent; + } + }, + + /** + * Synchronize the font settings to the given Canvas Rendering Context. + * + * @method Phaser.GameObjects.Text.TextStyle#syncFont + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The Canvas Element. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + */ + syncFont: function (canvas, context) + { + context.font = this._font; + }, + + /** + * Synchronize the text style settings to the given Canvas Rendering Context. + * + * @method Phaser.GameObjects.Text.TextStyle#syncStyle + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The Canvas Element. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + */ + syncStyle: function (canvas, context) + { + context.textBaseline = 'alphabetic'; + + context.fillStyle = this.color; + context.strokeStyle = this.stroke; + + context.lineWidth = this.strokeThickness; + context.lineCap = 'round'; + context.lineJoin = 'round'; + }, + + /** + * Synchronize the shadow settings to the given Canvas Rendering Context. + * + * @method Phaser.GameObjects.Text.TextStyle#syncShadow + * @since 3.0.0 + * + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {boolean} enabled - Whether shadows are enabled or not. + */ + syncShadow: function (context, enabled) + { + if (enabled) + { + context.shadowOffsetX = this.shadowOffsetX; + context.shadowOffsetY = this.shadowOffsetY; + context.shadowColor = this.shadowColor; + context.shadowBlur = this.shadowBlur; + } + else + { + context.shadowOffsetX = 0; + context.shadowOffsetY = 0; + context.shadowColor = 0; + context.shadowBlur = 0; + } + }, + + /** + * Update the style settings for the parent Text object. + * + * @method Phaser.GameObjects.Text.TextStyle#update + * @since 3.0.0 + * + * @param {boolean} recalculateMetrics - Whether to recalculate font and text metrics. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + update: function (recalculateMetrics) + { + if (recalculateMetrics) + { + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); + + this.metrics = MeasureText(this); + } + + return this.parent.updateText(); + }, + + /** + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * + * @method Phaser.GameObjects.Text.TextStyle#setFont + * @since 3.0.0 + * + * @param {(string|object)} font - The font family or font settings to set. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFont: function (font) + { + var fontFamily = font; + var fontSize = ''; + var fontStyle = ''; + + if (typeof font !== 'string') + { + fontFamily = GetValue(font, 'fontFamily', 'Courier'); + fontSize = GetValue(font, 'fontSize', '16px'); + fontStyle = GetValue(font, 'fontStyle', ''); + } + + if (fontFamily !== this.fontFamily || fontSize !== this.fontSize || fontStyle !== this.fontStyle) + { + this.fontFamily = fontFamily; + this.fontSize = fontSize; + this.fontStyle = fontStyle; + + this.update(true); + } + + return this.parent; + }, + + /** + * Set the font family. + * + * @method Phaser.GameObjects.Text.TextStyle#setFontFamily + * @since 3.0.0 + * + * @param {string} family - The font family. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontFamily: function (family) + { + if (this.fontFamily !== family) + { + this.fontFamily = family; + + this.update(true); + } + + return this.parent; + }, + + /** + * Set the font style. + * + * @method Phaser.GameObjects.Text.TextStyle#setFontStyle + * @since 3.0.0 + * + * @param {string} style - The font style. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontStyle: function (style) + { + if (this.fontStyle !== style) + { + this.fontStyle = style; + + this.update(true); + } + + return this.parent; + }, + + /** + * Set the font size. + * + * @method Phaser.GameObjects.Text.TextStyle#setFontSize + * @since 3.0.0 + * + * @param {(number|string)} size - The font size. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFontSize: function (size) + { + if (typeof size === 'number') + { + size = size.toString() + 'px'; + } + + if (this.fontSize !== size) + { + this.fontSize = size; + + this.update(true); + } + + return this.parent; + }, + + /** + * Set the test string to use when measuring the font. + * + * @method Phaser.GameObjects.Text.TextStyle#setTestString + * @since 3.0.0 + * + * @param {string} string - The test string to use when measuring the font. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setTestString: function (string) + { + this.testString = string; + + return this.update(true); + }, + + /** + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * + * @method Phaser.GameObjects.Text.TextStyle#setFixedSize + * @since 3.0.0 + * + * @param {number} width - The fixed width to set. + * @param {number} height - The fixed height to set. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFixedSize: function (width, height) + { + this.fixedWidth = width; + this.fixedHeight = height; + + if (width) + { + this.parent.width = width; + } + + if (height) + { + this.parent.height = height; + } + + return this.update(false); + }, + + /** + * Set the background color. + * + * @method Phaser.GameObjects.Text.TextStyle#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - The background color. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setBackgroundColor: function (color) + { + this.backgroundColor = color; + + return this.update(false); + }, + + /** + * Set the text fill color. + * + * @method Phaser.GameObjects.Text.TextStyle#setFill + * @since 3.0.0 + * + * @param {string} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setFill: function (color) + { + this.color = color; + + return this.update(false); + }, + + /** + * Set the text fill color. + * + * @method Phaser.GameObjects.Text.TextStyle#setColor + * @since 3.0.0 + * + * @param {string} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setColor: function (color) + { + this.color = color; + + return this.update(false); + }, + + /** + * Set the resolution used by the Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method. It allows for much clearer text on High DPI devices, + * at the cost of memory because it uses larger internal Canvas textures for the Text. + * + * Please use with caution, as the more high res Text you have, the more memory it uses up. + * + * @method Phaser.GameObjects.Text.TextStyle#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setResolution: function (value) + { + this.resolution = value; + + return this.update(false); + }, + + /** + * Set the stroke settings. + * + * @method Phaser.GameObjects.Text.TextStyle#setStroke + * @since 3.0.0 + * + * @param {string} color - The stroke color. + * @param {number} thickness - The stroke thickness. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setStroke: function (color, thickness) + { + if (thickness === undefined) { thickness = this.strokeThickness; } + + if (color === undefined && this.strokeThickness !== 0) + { + // Reset the stroke to zero (disabling it) + this.strokeThickness = 0; + + this.update(true); + } + else if (this.stroke !== color || this.strokeThickness !== thickness) + { + this.stroke = color; + this.strokeThickness = thickness; + + this.update(true); + } + + return this.parent; + }, + + /** + * Set the shadow settings. + * + * Calling this method always re-measures the parent Text object, + * so only call it when you actually change the shadow settings. + * + * @method Phaser.GameObjects.Text.TextStyle#setShadow + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * @param {string} [color='#000'] - The shadow color. + * @param {number} [blur=0] - The shadow blur radius. + * @param {boolean} [shadowStroke=false] - Whether to stroke the shadow. + * @param {boolean} [shadowFill=true] - Whether to fill the shadow. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (color === undefined) { color = '#000'; } + if (blur === undefined) { blur = 0; } + if (shadowStroke === undefined) { shadowStroke = false; } + if (shadowFill === undefined) { shadowFill = true; } + + this.shadowOffsetX = x; + this.shadowOffsetY = y; + this.shadowColor = color; + this.shadowBlur = blur; + this.shadowStroke = shadowStroke; + this.shadowFill = shadowFill; + + return this.update(false); + }, + + /** + * Set the shadow offset. + * + * @method Phaser.GameObjects.Text.TextStyle#setShadowOffset + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowOffset: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.shadowOffsetX = x; + this.shadowOffsetY = y; + + return this.update(false); + }, + + /** + * Set the shadow color. + * + * @method Phaser.GameObjects.Text.TextStyle#setShadowColor + * @since 3.0.0 + * + * @param {string} [color='#000'] - The shadow color. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowColor: function (color) + { + if (color === undefined) { color = '#000'; } + + this.shadowColor = color; + + return this.update(false); + }, + + /** + * Set the shadow blur radius. + * + * @method Phaser.GameObjects.Text.TextStyle#setShadowBlur + * @since 3.0.0 + * + * @param {number} [blur=0] - The shadow blur radius. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowBlur: function (blur) + { + if (blur === undefined) { blur = 0; } + + this.shadowBlur = blur; + + return this.update(false); + }, + + /** + * Enable or disable shadow stroke. + * + * @method Phaser.GameObjects.Text.TextStyle#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow stroke is enabled or not. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowStroke: function (enabled) + { + this.shadowStroke = enabled; + + return this.update(false); + }, + + /** + * Enable or disable shadow fill. + * + * @method Phaser.GameObjects.Text.TextStyle#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow fill is enabled or not. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setShadowFill: function (enabled) + { + this.shadowFill = enabled; + + return this.update(false); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. + * + * Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.Text.TextStyle#setWordWrapWidth + * @since 3.0.0 + * + * @param {number} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + if (useAdvancedWrap === undefined) { useAdvancedWrap = false; } + + this.wordWrapWidth = width; + this.wordWrapUseAdvanced = useAdvancedWrap; + + return this.update(false); + }, + + /** + * Set a custom callback for wrapping lines. + * + * Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.Text.TextStyle#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setWordWrapCallback: function (callback, scope) + { + if (scope === undefined) { scope = null; } + + this.wordWrapCallback = callback; + this.wordWrapCallbackScope = scope; + + return this.update(false); + }, + + /** + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. + * + * @method Phaser.GameObjects.Text.TextStyle#setAlign + * @since 3.0.0 + * + * @param {string} align - The text alignment. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setAlign: function (align) + { + if (align === undefined) { align = 'left'; } + + this.align = align; + + return this.update(false); + }, + + /** + * Set the maximum number of lines to draw. + * + * @method Phaser.GameObjects.Text.TextStyle#setMaxLines + * @since 3.0.0 + * + * @param {integer} [max=0] - The maximum number of lines to draw. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setMaxLines: function (max) + { + if (max === undefined) { max = 0; } + + this.maxLines = max; + + return this.update(false); + }, + + /** + * Get the current text metrics. + * + * @method Phaser.GameObjects.Text.TextStyle#getTextMetrics + * @since 3.0.0 + * + * @return {BitmapTextMetrics} The text metrics. + */ + getTextMetrics: function () + { + var metrics = this.metrics; + + return { + ascent: metrics.ascent, + descent: metrics.descent, + fontSize: metrics.fontSize + }; + }, + + /** + * Build a JSON representation of this Text Style. + * + * @method Phaser.GameObjects.Text.TextStyle#toJSON + * @since 3.0.0 + * + * @return {object} A JSON representation of this Text Style. + */ + toJSON: function () + { + var output = {}; + + for (var key in propertyMap) + { + output[key] = this[key]; + } + + output.metrics = this.getTextMetrics(); + + return output; + }, + + /** + * Destroy this Text Style. + * + * @method Phaser.GameObjects.Text.TextStyle#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent = undefined; + } + +}); + +module.exports = TextStyle; + + +/***/ }), +/* 875 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Text#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + if (src.text !== '') + { + renderer.batchSprite(src, src.frame, camera, parentMatrix); + } +}; + +module.exports = TextCanvasRenderer; + + +/***/ }), +/* 876 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Text#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Text} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + if (src.text === '') + { + return; + } + + var frame = src.frame; + var width = frame.width; + var height = frame.height; + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + frame.glTexture, + width, height, + src.x, src.y, + width / src.style.resolution, height / src.style.resolution, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.displayOriginX, src.displayOriginY, + 0, 0, width, height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + 0, 0, + camera, + parentMatrix + ); +}; + +module.exports = TextWebGLRenderer; + + +/***/ }), +/* 877 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(876); +} + +if (true) +{ + renderCanvas = __webpack_require__(875); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 878 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns an object containing dimensions of the Text object. + * + * @function Phaser.GameObjects.Text.GetTextSize + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Text} text - The Text object to calculate the size from. + * @param {BitmapTextMetrics} size - The Text metrics to use when calculating the size. + * @param {array} lines - The lines of text to calculate the size from. + * + * @return {object} An object containing dimensions of the Text object. + */ +var GetTextSize = function (text, size, lines) +{ + var canvas = text.canvas; + var context = text.context; + var style = text.style; + + var lineWidths = []; + var maxLineWidth = 0; + var drawnLines = lines.length; + + if (style.maxLines > 0 && style.maxLines < lines.length) + { + drawnLines = style.maxLines; + } + + style.syncFont(canvas, context); + + // Text Width + + for (var i = 0; i < drawnLines; i++) + { + var lineWidth = style.strokeThickness; + + lineWidth += context.measureText(lines[i]).width; + + // Adjust for wrapped text + if (style.wordWrap) + { + lineWidth -= context.measureText(' ').width; + } + + lineWidths[i] = Math.ceil(lineWidth); + maxLineWidth = Math.max(maxLineWidth, lineWidths[i]); + } + + // Text Height + + var lineHeight = size.fontSize + style.strokeThickness; + var height = lineHeight * drawnLines; + var lineSpacing = text.lineSpacing; + + // Adjust for line spacing + if (lines.length > 1) + { + height += lineSpacing * (lines.length - 1); + } + + return { + width: maxLineWidth, + height: height, + lines: drawnLines, + lineWidths: lineWidths, + lineSpacing: lineSpacing, + lineHeight: lineHeight + }; +}; + +module.exports = GetTextSize; + + +/***/ }), +/* 879 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); + +/** + * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor + * and create a BitmapText object using a fixed-width retro font. + * + * @function Phaser.GameObjects.RetroFont.Parse + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - A reference to the Phaser Scene. + * @param {Phaser.GameObjects.RetroFont.Config} config - The font configuration object. + * + * @return {object} A parsed Bitmap Font data entry for the Bitmap Font cache. + */ +var ParseRetroFont = function (scene, config) +{ + var w = config.width; + var h = config.height; + var cx = Math.floor(w / 2); + var cy = Math.floor(h / 2); + var letters = GetValue(config, 'chars', ''); + + if (letters === '') + { + return; + } + + var key = GetValue(config, 'image', ''); + var offsetX = GetValue(config, 'offset.x', 0); + var offsetY = GetValue(config, 'offset.y', 0); + var spacingX = GetValue(config, 'spacing.x', 0); + var spacingY = GetValue(config, 'spacing.y', 0); + var lineSpacing = GetValue(config, 'lineSpacing', 0); + + var charsPerRow = GetValue(config, 'charsPerRow', null); + + if (charsPerRow === null) + { + charsPerRow = scene.sys.textures.getFrame(key).width / w; + + if (charsPerRow > letters.length) + { + charsPerRow = letters.length; + } + } + + var x = offsetX; + var y = offsetY; + + var data = { + retroFont: true, + font: key, + size: w, + lineHeight: h + lineSpacing, + chars: {} + }; + + var r = 0; + + for (var i = 0; i < letters.length; i++) + { + // var node = letters[i]; + + var charCode = letters.charCodeAt(i); + + data.chars[charCode] = + { + x: x, + y: y, + width: w, + height: h, + centerX: cx, + centerY: cy, + xOffset: 0, + yOffset: 0, + xAdvance: w, + data: {}, + kerning: {} + }; + + r++; + + if (r === charsPerRow) + { + r = 0; + x = offsetX; + y += h + spacingY; + } + else + { + x += w + spacingX; + } + } + + var entry = { + data: data, + frame: null, + texture: key + }; + + return entry; +}; + +module.exports = ParseRetroFont; + + +/***/ }), +/* 880 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RETRO_FONT_CONST = { + + /** + * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET1 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET1: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', + + /** + * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET2 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET2: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET3 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET3: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ', + + /** + * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET4 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET4: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789', + + /** + * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET5 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET5: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789', + + /** + * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET6 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET6: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' ', + + /** + * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET7 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET7: 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39', + + /** + * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET8 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET8: '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET9 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET9: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!', + + /** + * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET10 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET10: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET11 + * @since 3.6.0 + * @type {string} + */ + TEXT_SET11: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789' + +}; + +module.exports = RETRO_FONT_CONST; + + +/***/ }), +/* 881 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RETRO_FONT_CONST = __webpack_require__(880); +var Extend = __webpack_require__(21); + +/** + * @typedef {object} Phaser.GameObjects.RetroFont.Config + * + * @property {string} image - The key of the image containing the font. + * @property {number} offset.x - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. + * @property {number} offset.y - If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. + * @property {number} width - The width of each character in the font set. + * @property {number} height - The height of each character in the font set. + * @property {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. + * @property {number} charsPerRow - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. + * @property {number} spacing.x - If the characters in the font set have horizontal spacing between them set the required amount here. + * @property {number} spacing.y - If the characters in the font set have vertical spacing between them set the required amount here. + * @property {number} lineSpacing - The amount of vertical space to add to the line height of the font. +*/ + +/** + * @namespace Phaser.GameObjects.RetroFont + * @since 3.6.0 + */ + +var RetroFont = { Parse: __webpack_require__(879) }; + +// Merge in the consts +RetroFont = Extend(false, RetroFont, RETRO_FONT_CONST); + +module.exports = RetroFont; + + +/***/ }), +/* 882 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderCanvas + * @since 3.2.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RenderTextureCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = RenderTextureCanvasRenderer; + + +/***/ }), +/* 883 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderWebGL + * @since 3.2.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RenderTextureWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var frame = src.frame; + var width = frame.width; + var height = frame.height; + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + frame.glTexture, + width, height, + src.x, src.y, + width, height, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, !src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.displayOriginX, src.displayOriginY, + 0, 0, width, height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + 0, 0, + camera, + parentMatrix + ); + + // Force clear the current texture so that items next in the batch (like Graphics) don't try and use it + renderer.setBlankTexture(true); +}; + +module.exports = RenderTextureWebGLRenderer; + + +/***/ }), +/* 884 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(883); +} + +if (true) +{ + renderCanvas = __webpack_require__(882); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 885 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Particles.Zones + */ + +module.exports = { + + DeathZone: __webpack_require__(329), + EdgeZone: __webpack_require__(328), + RandomZone: __webpack_require__(325) + +}; + + +/***/ }), +/* 886 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.EmitterManager#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) +{ + var emitters = emitterManager.emitters.list; + var emittersLength = emitters.length; + + if (emittersLength === 0) + { + return; + } + + var camMatrix = renderer._tempMatrix1.copyFrom(camera.matrix); + var calcMatrix = renderer._tempMatrix2; + var particleMatrix = renderer._tempMatrix3; + var managerMatrix = renderer._tempMatrix4.applyITRS(emitterManager.x, emitterManager.y, emitterManager.rotation, emitterManager.scaleX, emitterManager.scaleY); + + camMatrix.multiply(managerMatrix); + + var roundPixels = camera.roundPixels; + + var ctx = renderer.currentContext; + + ctx.save(); + + for (var e = 0; e < emittersLength; e++) + { + var emitter = emitters[e]; + var particles = emitter.alive; + var particleCount = particles.length; + + if (!emitter.visible || particleCount === 0) + { + continue; + } + + var scrollX = camera.scrollX * emitter.scrollFactorX; + var scrollY = camera.scrollY * emitter.scrollFactorY; + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -scrollX, -scrollY); + + scrollX = 0; + scrollY = 0; + } + + ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; + + for (var i = 0; i < particleCount; i++) + { + var particle = particles[i]; + + var alpha = particle.alpha * camera.alpha; + + if (alpha <= 0) + { + continue; + } + + var frame = particle.frame; + var cd = frame.canvasData; + + var x = -(frame.halfWidth); + var y = -(frame.halfHeight); + + particleMatrix.applyITRS(0, 0, particle.rotation, particle.scaleX, particle.scaleY); + + particleMatrix.e = particle.x - scrollX; + particleMatrix.f = particle.y - scrollY; + + camMatrix.multiply(particleMatrix, calcMatrix); + + ctx.globalAlpha = alpha; + + ctx.save(); + + calcMatrix.copyToContext(ctx); + + if (roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height); + + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = ParticleManagerCanvasRenderer; + + +/***/ }), +/* 887 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.EmitterManager#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) +{ + var emitters = emitterManager.emitters.list; + var emittersLength = emitters.length; + + if (emittersLength === 0) + { + return; + } + + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1.copyFrom(camera.matrix); + var calcMatrix = pipeline._tempMatrix2; + var particleMatrix = pipeline._tempMatrix3; + var managerMatrix = pipeline._tempMatrix4.applyITRS(emitterManager.x, emitterManager.y, emitterManager.rotation, emitterManager.scaleX, emitterManager.scaleY); + + camMatrix.multiply(managerMatrix); + + renderer.setPipeline(pipeline); + + var roundPixels = camera.roundPixels; + var texture = emitterManager.defaultFrame.glTexture; + var getTint = Utils.getTintAppendFloatAlphaAndSwap; + + pipeline.setTexture2D(texture, 0); + + for (var e = 0; e < emittersLength; e++) + { + var emitter = emitters[e]; + var particles = emitter.alive; + var particleCount = particles.length; + + if (!emitter.visible || particleCount === 0) + { + continue; + } + + var scrollX = camera.scrollX * emitter.scrollFactorX; + var scrollY = camera.scrollY * emitter.scrollFactorY; + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -scrollX, -scrollY); + + scrollX = 0; + scrollY = 0; + } + + if (renderer.setBlendMode(emitter.blendMode)) + { + // Rebind the texture if we've flushed + pipeline.setTexture2D(texture, 0); + } + + var tintEffect = 0; + + for (var i = 0; i < particleCount; i++) + { + var particle = particles[i]; + + var alpha = particle.alpha * camera.alpha; + + if (alpha <= 0) + { + continue; + } + + var frame = particle.frame; + + var x = -(frame.halfWidth); + var y = -(frame.halfHeight); + var xw = x + frame.width; + var yh = y + frame.height; + + particleMatrix.applyITRS(0, 0, particle.rotation, particle.scaleX, particle.scaleY); + + particleMatrix.e = particle.x - scrollX; + particleMatrix.f = particle.y - scrollY; + + camMatrix.multiply(particleMatrix, calcMatrix); + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + var tint = getTint(particle.tint, alpha); + + if (pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect)) + { + pipeline.setTexture2D(texture, 0); + } + } + } +}; + +module.exports = ParticleManagerWebGLRenderer; + + +/***/ }), +/* 888 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(887); +} + +if (true) +{ + renderCanvas = __webpack_require__(886); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 889 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FloatBetween = __webpack_require__(327); +var GetEaseFunction = __webpack_require__(95); +var GetFastValue = __webpack_require__(1); +var Wrap = __webpack_require__(59); + +/** + * The returned value sets what the property will be at the START of the particle's life, on emit. + * @callback EmitterOpOnEmitCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + +/** + * The returned value updates the property for the duration of the particle's life. + * @callback EmitterOpOnUpdateCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The normalized lifetime of the particle, between 0 (start) and 1 (end). + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + +/** + * Defines an operation yielding a random value within a range. + * @typedef {object} EmitterOpRandomConfig + * + * @property {number[]} random - The minimum and maximum values, as [min, max]. + */ + +/** + * Defines an operation yielding a random value within a range. + * @typedef {object} EmitterOpRandomMinMaxConfig + * + * @property {number} min - The minimum value. + * @property {number} max - The maximum value. + */ + +/** + * Defines an operation yielding a random value within a range. + * @typedef {object} EmitterOpRandomStartEndConfig + * + * @property {number} start - The starting value. + * @property {number} end - The ending value. + * @property {boolean} random - If false, this becomes {@link EmitterOpEaseConfig}. + */ + +/** + * Defines an operation yielding a value incremented continuously across a range. + * @typedef {object} EmitterOpEaseConfig + * + * @property {number} start - The starting value. + * @property {number} end - The ending value. + * @property {string} [ease='Linear'] - The name of the easing function. + */ + +/** + * Defines an operation yielding a value incremented by steps across a range. + * @typedef {object} EmitterOpSteppedConfig + * + * @property {number} start - The starting value. + * @property {number} end - The ending value. + * @property {number} steps - The number of steps between start and end. + */ + +/** + * @typedef {object} EmitterOpCustomEmitConfig + * + * @property {EmitterOpOnEmitCallback} onEmit - [description] + */ + +/** + * @typedef {object} EmitterOpCustomUpdateConfig + * + * @property {EmitterOpOnEmitCallback} [onEmit] - [description] + * @property {EmitterOpOnUpdateCallback} onUpdate - [description] + */ + +/** + * @classdesc + * A Particle Emitter property. + * + * Facilitates changing Particle properties as they are emitted and throughout their lifetime. + * + * @class EmitterOp + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {ParticleEmitterConfig} config - Settings for the Particle Emitter that owns this property. + * @param {string} key - The name of the property. + * @param {number} defaultValue - The default value of the property. + * @param {boolean} [emitOnly=false] - Whether the property can only be modified when a Particle is emitted. + */ +var EmitterOp = new Class({ + + initialize: + + function EmitterOp (config, key, defaultValue, emitOnly) + { + if (emitOnly === undefined) + { + emitOnly = false; + } + + /** + * The name of this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey + * @type {string} + * @since 3.0.0 + */ + this.propertyKey = key; + + /** + * The value of this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue + * @type {number} + * @since 3.0.0 + */ + this.propertyValue = defaultValue; + + /** + * The default value of this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue + * @type {number} + * @since 3.0.0 + */ + this.defaultValue = defaultValue; + + /** + * The number of steps for stepped easing between {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} values, per emit. + * + * @name Phaser.GameObjects.Particles.EmitterOp#steps + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.steps = 0; + + /** + * The step counter for stepped easing, per emit. + * + * @name Phaser.GameObjects.Particles.EmitterOp#counter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.counter = 0; + + /** + * The start value for this property to ease between. + * + * @name Phaser.GameObjects.Particles.EmitterOp#start + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.start = 0; + + /** + * The end value for this property to ease between. + * + * @name Phaser.GameObjects.Particles.EmitterOp#end + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.end = 0; + + /** + * The easing function to use for updating this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#ease + * @type {?function} + * @since 3.0.0 + */ + this.ease; + + /** + * Whether this property can only be modified when a Particle is emitted. + * + * Set to `true` to allow only {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} callbacks to be set and + * affect this property. + * + * Set to `false` to allow both {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks to be set and affect this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly + * @type {boolean} + * @since 3.0.0 + */ + this.emitOnly = emitOnly; + + /** + * The callback to run for Particles when they are emitted from the Particle Emitter. + * + * @name Phaser.GameObjects.Particles.EmitterOp#onEmit + * @type {EmitterOpOnEmitCallback} + * @since 3.0.0 + */ + this.onEmit = this.defaultEmit; + + /** + * The callback to run for Particles when they are updated. + * + * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate + * @type {EmitterOpOnUpdateCallback} + * @since 3.0.0 + */ + this.onUpdate = this.defaultUpdate; + + this.loadConfig(config); + }, + + /** + * Load the property from a Particle Emitter configuration object. + * + * Optionally accepts a new property key to use, replacing the current one. + * + * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig + * @since 3.0.0 + * + * @param {ParticleEmitterConfig} [config] - Settings for the Particle Emitter that owns this property. + * @param {string} [newKey] - The new key to use for this property, if any. + */ + loadConfig: function (config, newKey) + { + if (config === undefined) + { + config = {}; + } + + if (newKey) + { + this.propertyKey = newKey; + } + + this.propertyValue = GetFastValue( + config, + this.propertyKey, + this.defaultValue + ); + + this.setMethods(); + + if (this.emitOnly) + { + // Reset it back again + this.onUpdate = this.defaultUpdate; + } + }, + + /** + * Build a JSON representation of this Particle Emitter property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#toJSON + * @since 3.0.0 + * + * @return {object} A JSON representation of this Particle Emitter property. + */ + toJSON: function () + { + return this.propertyValue; + }, + + /** + * Change the current value of the property and update its callback methods. + * + * @method Phaser.GameObjects.Particles.EmitterOp#onChange + * @since 3.0.0 + * + * @param {number} value - The value of the property. + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + onChange: function (value) + { + this.propertyValue = value; + + return this.setMethods(); + }, + + /** + * Update the {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks based on the type of the current + * {@link Phaser.GameObjects.Particles.EmitterOp#propertyValue}. + * + * @method Phaser.GameObjects.Particles.EmitterOp#setMethods + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + setMethods: function () + { + var value = this.propertyValue; + + var t = typeof value; + + if (t === 'number') + { + // Explicit static value: + // x: 400 + + this.onEmit = this.staticValueEmit; + this.onUpdate = this.staticValueUpdate; // How? + } + else if (Array.isArray(value)) + { + // Picks a random element from the array: + // x: [ 100, 200, 300, 400 ] + + this.onEmit = this.randomStaticValueEmit; + } + else if (t === 'function') + { + // The same as setting just the onUpdate function and no onEmit (unless this op is an emitOnly one) + // Custom callback, must return a value: + + /* + x: function (particle, key, t, value) + { + return value + 50; + } + */ + + if (this.emitOnly) + { + this.onEmit = value; + } + else + { + this.onUpdate = value; + } + } + else if (t === 'object' && (this.has(value, 'random') || this.hasBoth(value, 'start', 'end') || this.hasBoth(value, 'min', 'max'))) + { + this.start = this.has(value, 'start') ? value.start : value.min; + this.end = this.has(value, 'end') ? value.end : value.max; + + var isRandom = (this.hasBoth(value, 'min', 'max') || this.has(value, 'random')); + + // A random starting value (using 'min | max' instead of 'start | end' automatically implies a random value) + + // x: { start: 100, end: 400, random: true } OR { min: 100, max: 400 } OR { random: [ 100, 400 ] } + + if (isRandom) + { + var rnd = value.random; + + // x: { random: [ 100, 400 ] } = the same as doing: x: { start: 100, end: 400, random: true } + if (Array.isArray(rnd)) + { + this.start = rnd[0]; + this.end = rnd[1]; + } + + this.onEmit = this.randomRangedValueEmit; + } + + if (this.has(value, 'steps')) + { + // A stepped (per emit) range + + // x: { start: 100, end: 400, steps: 64 } + + // Increments a value stored in the emitter + + this.steps = value.steps; + this.counter = this.start; + + this.onEmit = this.steppedEmit; + } + else + { + // An eased range (defaults to Linear if not specified) + + // x: { start: 100, end: 400, [ ease: 'Linear' ] } + + var easeType = this.has(value, 'ease') ? value.ease : 'Linear'; + + this.ease = GetEaseFunction(easeType); + + if (!isRandom) + { + this.onEmit = this.easedValueEmit; + } + + // BUG: alpha, rotate, scaleX, scaleY, or tint are eased here if {min, max} is given. + // Probably this branch should exclude isRandom entirely. + + this.onUpdate = this.easeValueUpdate; + } + } + else if (t === 'object' && this.hasEither(value, 'onEmit', 'onUpdate')) + { + // Custom onEmit and onUpdate callbacks + + /* + x: { + // Called at the start of the particles life, when it is being created + onEmit: function (particle, key, t, value) + { + return value; + }, + + // Called during the particles life on each update + onUpdate: function (particle, key, t, value) + { + return value; + } + } + */ + + if (this.has(value, 'onEmit')) + { + this.onEmit = value.onEmit; + } + + if (this.has(value, 'onUpdate')) + { + this.onUpdate = value.onUpdate; + } + } + + return this; + }, + + /** + * Check whether an object has the given property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#has + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key - The key of the property to look for in the object. + * + * @return {boolean} `true` if the property exists in the object, `false` otherwise. + */ + has: function (object, key) + { + return object.hasOwnProperty(key); + }, + + /** + * Check whether an object has both of the given properties. + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key1 - The key of the first property to check the object for. + * @param {string} key2 - The key of the second property to check the object for. + * + * @return {boolean} `true` if both properties exist in the object, `false` otherwise. + */ + hasBoth: function (object, key1, key2) + { + return object.hasOwnProperty(key1) && object.hasOwnProperty(key2); + }, + + /** + * Check whether an object has at least one of the given properties. + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasEither + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key1 - The key of the first property to check the object for. + * @param {string} key2 - The key of the second property to check the object for. + * + * @return {boolean} `true` if at least one of the properties exists in the object, `false` if neither exist. + */ + hasEither: function (object, key1, key2) + { + return object.hasOwnProperty(key1) || object.hasOwnProperty(key2); + }, + + /** + * The returned value sets what the property will be at the START of the particles life, on emit. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} [value] - The current value of the property. + * + * @return {number} The new value of hte property. + */ + defaultEmit: function (particle, key, value) + { + return value; + }, + + /** + * The returned value updates the property for the duration of the particles life. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The T value (between 0 and 1) + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + defaultUpdate: function (particle, key, t, value) + { + return value; + }, + + /** + * An `onEmit` callback that returns the current value of the property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit + * @since 3.0.0 + * + * @return {number} The current value of the property. + */ + staticValueEmit: function () + { + return this.propertyValue; + }, + + /** + * An `onUpdate` callback that returns the current value of the property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate + * @since 3.0.0 + * + * @return {number} The current value of the property. + */ + staticValueUpdate: function () + { + return this.propertyValue; + }, + + /** + * An `onEmit` callback that returns a random value from the current value array. + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit + * @since 3.0.0 + * + * @return {number} The new value of the property. + */ + randomStaticValueEmit: function () + { + var randomIndex = Math.floor(Math.random() * this.propertyValue.length); + + return this.propertyValue[randomIndex]; + }, + + /** + * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The key of the property. + * + * @return {number} The new value of the property. + */ + randomRangedValueEmit: function (particle, key) + { + var value = FloatBetween(this.start, this.end); + + if (particle && particle.data[key]) + { + particle.data[key].min = value; + } + + return value; + }, + + /** + * An `onEmit` callback that returns a stepped value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit + * @since 3.0.0 + * + * @return {number} The new value of the property. + */ + steppedEmit: function () + { + var current = this.counter; + + var next = this.counter + (this.end - this.start) / this.steps; + + this.counter = Wrap(next, this.start, this.end); + + return current; + }, + + /** + * An `onEmit` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * + * @return {number} The new value of the property. + */ + easedValueEmit: function (particle, key) + { + if (particle && particle.data[key]) + { + var data = particle.data[key]; + + data.min = this.start; + data.max = this.end; + } + + return this.start; + }, + + /** + * An `onUpdate` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The T value (between 0 and 1) + * + * @return {number} The new value of the property. + */ + easeValueUpdate: function (particle, key, t) + { + var data = particle.data[key]; + + return (data.max - data.min) * this.ease(t) + data.min; + } +}); + +module.exports = EmitterOp; + + +/***/ }), +/* 890 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Particles + */ + +module.exports = { + + GravityWell: __webpack_require__(332), + Particle: __webpack_require__(331), + ParticleEmitter: __webpack_require__(330), + ParticleEmitterManager: __webpack_require__(171), + Zones: __webpack_require__(885) + +}; + + +/***/ }), +/* 891 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Image#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = ImageCanvasRenderer; + + +/***/ }), +/* 892 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Image#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Image} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + this.pipeline.batchSprite(src, camera, parentMatrix); +}; + +module.exports = ImageWebGLRenderer; + + +/***/ }), +/* 893 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(892); +} + +if (true) +{ + renderCanvas = __webpack_require__(891); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 894 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = SpriteCanvasRenderer; + + +/***/ }), +/* 895 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + this.pipeline.batchSprite(src, camera, parentMatrix); +}; + +module.exports = SpriteWebGLRenderer; + + +/***/ }), +/* 896 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(895); +} + +if (true) +{ + renderCanvas = __webpack_require__(894); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 897 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Commands = __webpack_require__(173); +var Utils = __webpack_require__(9); + +// TODO: Remove the use of this +var Point = function (x, y, width) +{ + this.x = x; + this.y = y; + this.width = width; +}; + +// TODO: Remove the use of this +var Path = function (x, y, width) +{ + this.points = []; + this.pointsLength = 1; + this.points[0] = new Point(x, y, width); +}; + +var matrixStack = []; + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Graphics#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + if (src.commandBuffer.length === 0) + { + return; + } + + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var graphicsMatrix = pipeline._tempMatrix2; + var currentMatrix = pipeline._tempMatrix4; + + renderer.setPipeline(pipeline); + + currentMatrix.loadIdentity(); + + graphicsMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + graphicsMatrix.e = src.x; + graphicsMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(graphicsMatrix); + } + else + { + graphicsMatrix.e -= camera.scrollX * src.scrollFactorX; + graphicsMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(graphicsMatrix); + } + + var commands = src.commandBuffer; + var alpha = camera.alpha * src.alpha; + + var lineWidth = 1; + var fillTint = pipeline.fillTint; + var strokeTint = pipeline.strokeTint; + + var tx = 0; + var ty = 0; + var ta = 0; + var iterStep = 0.01; + var PI2 = Math.PI * 2; + + var cmd; + + var path = []; + var pathIndex = 0; + var pathOpen = false; + var lastPath = null; + + var getTint = Utils.getTintAppendFloatAlphaAndSwap; + + var currentTexture = renderer.blankTexture.glTexture; + + for (var cmdIndex = 0; cmdIndex < commands.length; cmdIndex++) + { + cmd = commands[cmdIndex]; + + switch (cmd) + { + case Commands.BEGIN_PATH: + + path.length = 0; + lastPath = null; + pathOpen = true; + break; + + case Commands.CLOSE_PATH: + + pathOpen = false; + + if (lastPath && lastPath.points.length) + { + lastPath.points.push(lastPath.points[0]); + } + break; + + case Commands.FILL_PATH: + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + pipeline.setTexture2D(currentTexture); + + pipeline.batchFillPath( + path[pathIndex].points, + currentMatrix, + camMatrix + ); + } + break; + + case Commands.STROKE_PATH: + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + pipeline.setTexture2D(currentTexture); + + pipeline.batchStrokePath( + path[pathIndex].points, + lineWidth, + pathOpen, + currentMatrix, + camMatrix + ); + } + break; + + case Commands.LINE_STYLE: + lineWidth = commands[++cmdIndex]; + var strokeColor = commands[++cmdIndex]; + var strokeAlpha = commands[++cmdIndex] * alpha; + var strokeTintColor = getTint(strokeColor, strokeAlpha); + strokeTint.TL = strokeTintColor; + strokeTint.TR = strokeTintColor; + strokeTint.BL = strokeTintColor; + strokeTint.BR = strokeTintColor; + break; + + case Commands.FILL_STYLE: + var fillColor = commands[++cmdIndex]; + var fillAlpha = commands[++cmdIndex] * alpha; + var fillTintColor = getTint(fillColor, fillAlpha); + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + break; + + case Commands.GRADIENT_FILL_STYLE: + var gradientFillAlpha = commands[++cmdIndex] * alpha; + fillTint.TL = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.TR = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.BL = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.BR = getTint(commands[++cmdIndex], gradientFillAlpha); + break; + + case Commands.GRADIENT_LINE_STYLE: + lineWidth = commands[++cmdIndex]; + var gradientLineAlpha = commands[++cmdIndex] * alpha; + strokeTint.TL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.TR = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BR = getTint(commands[++cmdIndex], gradientLineAlpha); + break; + + case Commands.ARC: + var iteration = 0; + var x = commands[++cmdIndex]; + var y = commands[++cmdIndex]; + var radius = commands[++cmdIndex]; + var startAngle = commands[++cmdIndex]; + var endAngle = commands[++cmdIndex]; + var anticlockwise = commands[++cmdIndex]; + var overshoot = commands[++cmdIndex]; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -PI2) + { + endAngle = -PI2; + } + else if (endAngle > 0) + { + endAngle = -PI2 + endAngle % PI2; + } + } + else if (endAngle > PI2) + { + endAngle = PI2; + } + else if (endAngle < 0) + { + endAngle = PI2 + endAngle % PI2; + } + + if (lastPath === null) + { + lastPath = new Path(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius, lineWidth); + path.push(lastPath); + iteration += iterStep; + } + + while (iteration < 1 + overshoot) + { + ta = endAngle * iteration + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.points.push(new Point(tx, ty, lineWidth)); + + iteration += iterStep; + } + + ta = endAngle + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.points.push(new Point(tx, ty, lineWidth)); + + break; + + case Commands.FILL_RECT: + pipeline.setTexture2D(currentTexture); + pipeline.batchFillRect( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + currentMatrix, + camMatrix + ); + break; + + case Commands.FILL_TRIANGLE: + pipeline.setTexture2D(currentTexture); + pipeline.batchFillTriangle( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + currentMatrix, + camMatrix + ); + break; + + case Commands.STROKE_TRIANGLE: + pipeline.setTexture2D(currentTexture); + pipeline.batchStrokeTriangle( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + lineWidth, + currentMatrix, + camMatrix + ); + break; + + case Commands.LINE_TO: + if (lastPath !== null) + { + lastPath.points.push(new Point(commands[++cmdIndex], commands[++cmdIndex], lineWidth)); + } + else + { + lastPath = new Path(commands[++cmdIndex], commands[++cmdIndex], lineWidth); + path.push(lastPath); + } + break; + + case Commands.MOVE_TO: + lastPath = new Path(commands[++cmdIndex], commands[++cmdIndex], lineWidth); + path.push(lastPath); + break; + + case Commands.SAVE: + matrixStack.push(currentMatrix.copyToArray()); + break; + + case Commands.RESTORE: + currentMatrix.copyFromArray(matrixStack.pop()); + break; + + case Commands.TRANSLATE: + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.translate(x, y); + break; + + case Commands.SCALE: + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.scale(x, y); + break; + + case Commands.ROTATE: + currentMatrix.rotate(commands[++cmdIndex]); + break; + + case Commands.SET_TEXTURE: + var frame = commands[++cmdIndex]; + var mode = commands[++cmdIndex]; + + pipeline.currentFrame = frame; + pipeline.setTexture2D(frame.glTexture, 0); + pipeline.tintEffect = mode; + + currentTexture = frame.glTexture; + + break; + + case Commands.CLEAR_TEXTURE: + pipeline.currentFrame = renderer.blankTexture; + pipeline.tintEffect = 2; + currentTexture = renderer.blankTexture.glTexture; + break; + } + } +}; + +module.exports = GraphicsWebGLRenderer; + + +/***/ }), +/* 898 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(897); + + // Needed for Graphics.generateTexture + renderCanvas = __webpack_require__(333); +} + +if (true) +{ + renderCanvas = __webpack_require__(333); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 899 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src.text; + var textLength = text.length; + + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + var textureFrame = src.frame; + + var displayCallback = src.displayCallback; + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + + var xAdvance = 0; + var yAdvance = 0; + + var indexCount = 0; + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + // var ctx = renderer.currentContext; + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var rotation = 0; + var scale = (src.fontSize / src.fontData.size); + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(0, 0, src.cropWidth, src.cropHeight); + ctx.clip(); + } + + for (var index = 0; index < textLength; ++index) + { + // Reset the scale (in case the callback changed it) + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + charCode = text.charCodeAt(index); + + if (charCode === 10) + { + xAdvance = 0; + indexCount = 0; + yAdvance += lineHeight; + lastGlyph = null; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = (indexCount + glyph.xOffset + xAdvance) - src.scrollX; + y = (glyph.yOffset + yAdvance) - src.scrollY; + + // This could be optimized so that it doesn't even bother drawing it if the x/y is out of range + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (displayCallback) + { + var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + } + + x *= scale; + y *= scale; + + x -= cameraScrollX; + y -= cameraScrollY; + + if (camera.roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.rotate(rotation); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + + xAdvance += glyph.xAdvance; + indexCount += 1; + lastGlyph = glyph; + lastCharCode = charCode; + } + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = DynamicBitmapTextCanvasRenderer; + + +/***/ }), +/* 900 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DynamicBitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src.text; + var textLength = text.length; + + if (textLength === 0) + { + return; + } + + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var crop = (src.cropWidth > 0 || src.cropHeight > 0); + + if (crop) + { + pipeline.flush(); + + renderer.pushScissor( + src.x, + src.y, + src.cropWidth * src.scaleX, + src.cropHeight * src.scaleY + ); + } + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + var fontMatrix = pipeline._tempMatrix4; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = texture.width; + var textureHeight = texture.height; + + var tintEffect = (src._isTinted && src.tintFill); + var tintTL = Utils.getTintAppendFloatAlpha(src._tintTL, camera.alpha * src._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(src._tintTR, camera.alpha * src._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, camera.alpha * src._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, camera.alpha * src._alphaBR); + + pipeline.setTexture2D(texture, 0); + + var xAdvance = 0; + var yAdvance = 0; + var charCode = 0; + var lastCharCode = 0; + var letterSpacing = src.letterSpacing; + var glyph; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + var lastGlyph; + var scrollX = src.scrollX; + var scrollY = src.scrollY; + + var fontData = src.fontData; + var chars = fontData.chars; + var lineHeight = fontData.lineHeight; + var scale = (src.fontSize / fontData.size); + var rotation = 0; + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + var roundPixels = camera.roundPixels; + var displayCallback = src.displayCallback; + var callbackData = src.callbackData; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + // Carriage-return + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + var x = (glyph.xOffset + xAdvance) - scrollX; + var y = (glyph.yOffset + yAdvance) - scrollY; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + if (displayCallback) + { + callbackData.color = 0; + callbackData.tint.topLeft = tintTL; + callbackData.tint.topRight = tintTR; + callbackData.tint.bottomLeft = tintBL; + callbackData.tint.bottomRight = tintBR; + callbackData.index = i; + callbackData.charCode = charCode; + callbackData.x = x; + callbackData.y = y; + callbackData.scale = scale; + callbackData.rotation = rotation; + callbackData.data = glyph.data; + + var output = displayCallback(callbackData); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + + if (output.color) + { + tintTL = output.color; + tintTR = output.color; + tintBL = output.color; + tintBR = output.color; + } + else + { + tintTL = output.tint.topLeft; + tintTR = output.tint.topRight; + tintBL = output.tint.bottomLeft; + tintBR = output.tint.bottomRight; + } + + tintTL = Utils.getTintAppendFloatAlpha(tintTL, camera.alpha * src._alphaTL); + tintTR = Utils.getTintAppendFloatAlpha(tintTR, camera.alpha * src._alphaTR); + tintBL = Utils.getTintAppendFloatAlpha(tintBL, camera.alpha * src._alphaBL); + tintBR = Utils.getTintAppendFloatAlpha(tintBR, camera.alpha * src._alphaBR); + } + + x *= scale; + y *= scale; + + x -= src.displayOriginX; + y -= src.displayOriginY; + + x += lineOffsetX; + + fontMatrix.applyITRS(x, y, rotation, scale, scale); + + calcMatrix.multiply(fontMatrix, spriteMatrix); + + var u0 = glyphX / textureWidth; + var v0 = glyphY / textureHeight; + var u1 = (glyphX + glyphW) / textureWidth; + var v1 = (glyphY + glyphH) / textureHeight; + + var xw = glyphW; + var yh = glyphH; + + var tx0 = spriteMatrix.e; + var ty0 = spriteMatrix.f; + + var tx1 = yh * spriteMatrix.c + spriteMatrix.e; + var ty1 = yh * spriteMatrix.d + spriteMatrix.f; + + var tx2 = xw * spriteMatrix.a + yh * spriteMatrix.c + spriteMatrix.e; + var ty2 = xw * spriteMatrix.b + yh * spriteMatrix.d + spriteMatrix.f; + + var tx3 = xw * spriteMatrix.a + spriteMatrix.e; + var ty3 = xw * spriteMatrix.b + spriteMatrix.f; + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + + if (crop) + { + pipeline.flush(); + + renderer.popScissor(); + } +}; + +module.exports = DynamicBitmapTextWebGLRenderer; + + +/***/ }), +/* 901 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(900); +} + +if (true) +{ + renderCanvas = __webpack_require__(899); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 902 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Container#renderCanvas + * @since 3.4.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ContainerCanvasRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) +{ + var children = container.list; + + if (children.length === 0) + { + return; + } + + var transformMatrix = container.localTransform; + + if (parentMatrix) + { + transformMatrix.loadIdentity(); + transformMatrix.multiply(parentMatrix); + transformMatrix.translate(container.x, container.y); + transformMatrix.rotate(container.rotation); + transformMatrix.scale(container.scaleX, container.scaleY); + } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode) + { + // If Container is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } + + var alpha = container._alpha; + var scrollFactorX = container.scrollFactorX; + var scrollFactorY = container.scrollFactorY; + + for (var i = 0; i < children.length; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlpha = child._alpha; + var childBlendMode = child._blendMode; + var childScrollFactorX = child.scrollFactorX; + var childScrollFactorY = child.scrollFactorY; + + // Set parent values + child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); + child.setAlpha(childAlpha * alpha); + + if (containerHasBlendMode) + { + child.setBlendMode(container._blendMode); + } + + // Render + child.renderCanvas(renderer, child, interpolationPercentage, camera, transformMatrix); + + // Restore original values + child.setAlpha(childAlpha); + child.setScrollFactor(childScrollFactorX, childScrollFactorY); + child.setBlendMode(childBlendMode); + } +}; + +module.exports = ContainerCanvasRenderer; + + +/***/ }), +/* 903 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Container#renderWebGL + * @since 3.4.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ContainerWebGLRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) +{ + var children = container.list; + + if (children.length === 0) + { + return; + } + + var transformMatrix = container.localTransform; + + if (parentMatrix) + { + transformMatrix.loadIdentity(); + transformMatrix.multiply(parentMatrix); + transformMatrix.translate(container.x, container.y); + transformMatrix.rotate(container.rotation); + transformMatrix.scale(container.scaleX, container.scaleY); + } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode) + { + // If Container is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } + + var alpha = container._alpha; + var scrollFactorX = container.scrollFactorX; + var scrollFactorY = container.scrollFactorY; + + for (var i = 0; i < children.length; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlpha = child._alpha; + var childScrollFactorX = child.scrollFactorX; + var childScrollFactorY = child.scrollFactorY; + + if (!containerHasBlendMode && child.blendMode !== renderer.currentBlendMode) + { + // If Container doesn't have its own blend mode, then a child can have one + renderer.setBlendMode(child.blendMode); + } + + // Set parent values + child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); + child.setAlpha(childAlpha * alpha); + + // Render + child.renderWebGL(renderer, child, interpolationPercentage, camera, transformMatrix); + + // Restore original values + child.setAlpha(childAlpha); + child.setScrollFactor(childScrollFactorX, childScrollFactorY); + } +}; + +module.exports = ContainerWebGLRenderer; + + +/***/ }), +/* 904 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(903); +} + +if (true) +{ + renderCanvas = __webpack_require__(902); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 905 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Bob Game Object. + * + * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * + * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle + * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it + * must be a Frame within the Texture used by the parent Blitter. + * + * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will + * have their positions impacted by this change as well. + * + * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be + * handled via the Blitter parent. + * + * @class Bob + * @memberof Phaser.GameObjects.Blitter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. + * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. + * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. + * @param {(string|integer)} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. + * @param {boolean} visible - Should the Bob render visible or not to start with? + */ +var Bob = new Class({ + + initialize: + + function Bob (blitter, x, y, frame, visible) + { + /** + * The Blitter object that this Bob belongs to. + * + * @name Phaser.GameObjects.Blitter.Bob#parent + * @type {Phaser.GameObjects.Blitter} + * @since 3.0.0 + */ + this.parent = blitter; + + /** + * The x position of this Bob, relative to the x position of the Blitter. + * + * @name Phaser.GameObjects.Blitter.Bob#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of this Bob, relative to the y position of the Blitter. + * + * @name Phaser.GameObjects.Blitter.Bob#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The frame that the Bob uses to render with. + * To change the frame use the `Bob.setFrame` method. + * + * @name Phaser.GameObjects.Blitter.Bob#frame + * @type {Phaser.Textures.Frame} + * @protected + * @since 3.0.0 + */ + this.frame = frame; + + /** + * A blank object which can be used to store data related to this Bob in. + * + * @name Phaser.GameObjects.Blitter.Bob#data + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.data = {}; + + /** + * The visible state of this Bob. + * + * @name Phaser.GameObjects.Blitter.Bob#_visible + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._visible = visible; + + /** + * The alpha value of this Bob. + * + * @name Phaser.GameObjects.Blitter.Bob#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._alpha = 1; + + /** + * The horizontally flipped state of the Bob. + * A Bob that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture. + * + * @name Phaser.GameObjects.Blitter.Bob#flipX + * @type {boolean} + * @since 3.0.0 + */ + this.flipX = false; + + /** + * The vertically flipped state of the Bob. + * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture. + * + * @name Phaser.GameObjects.Blitter.Bob#flipY + * @type {boolean} + * @since 3.0.0 + */ + this.flipY = false; + }, + + /** + * Changes the Texture Frame being used by this Bob. + * The frame must be part of the Texture the parent Blitter is using. + * If no value is given it will use the default frame of the Blitter parent. + * + * @method Phaser.GameObjects.Blitter.Bob#setFrame + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The frame to be used during rendering. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFrame: function (frame) + { + if (frame === undefined) + { + this.frame = this.parent.frame; + } + else + { + this.frame = this.parent.texture.get(frame); + } + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. + * + * @method Phaser.GameObjects.Blitter.Bob#resetFlip + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + }, + + /** + * Resets this Bob. + * + * Changes the position to the values given, and optionally changes the frame. + * + * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. + * + * @method Phaser.GameObjects.Blitter.Bob#reset + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + reset: function (x, y, frame) + { + this.x = x; + this.y = y; + + this.flipX = false; + this.flipY = false; + + this._alpha = 1; + this._visible = true; + + this.parent.dirty = true; + + if (frame) + { + this.setFrame(frame); + } + + return this; + }, + + /** + * Sets the horizontal flipped state of this Bob. + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Bob. + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Bob. + * + * @method Phaser.GameObjects.Blitter.Bob#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Sets the visibility of this Bob. + * + * An invisible Bob will skip rendering. + * + * @method Phaser.GameObjects.Blitter.Bob#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + }, + + /** + * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * A Bob with alpha 0 will skip rendering. + * + * @method Phaser.GameObjects.Blitter.Bob#setAlpha + * @since 3.0.0 + * + * @param {number} value - The alpha value used for this Bob. Between 0 and 1. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setAlpha: function (value) + { + this.alpha = value; + + return this; + }, + + /** + * Destroys this Bob instance. + * Removes itself from the Blitter and clears the parent, frame and data properties. + * + * @method Phaser.GameObjects.Blitter.Bob#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent.dirty = true; + + this.parent.children.remove(this); + + this.parent = undefined; + this.frame = undefined; + this.data = undefined; + }, + + /** + * The visible state of the Bob. + * + * An invisible Bob will skip rendering. + * + * @name Phaser.GameObjects.Blitter.Bob#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + this._visible = value; + this.parent.dirty = true; + } + + }, + + /** + * The alpha value of the Bob, between 0 and 1. + * + * A Bob with alpha 0 will skip rendering. + * + * @name Phaser.GameObjects.Blitter.Bob#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + this._alpha = value; + this.parent.dirty = true; + } + + } + +}); + +module.exports = Bob; + + +/***/ }), +/* 906 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var list = src.getRenderList(); + + if (list.length === 0) + { + return; + } + + var ctx = renderer.currentContext; + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + + // Blend Mode + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + + var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; + var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; + + ctx.save(); + + if (parentMatrix) + { + parentMatrix.copyToContext(ctx); + } + + var roundPixels = camera.roundPixels; + + // Render bobs + for (var i = 0; i < list.length; i++) + { + var bob = list[i]; + var flip = (bob.flipX || bob.flipY); + var frame = bob.frame; + var cd = frame.canvasData; + var dx = frame.x; + var dy = frame.y; + var fx = 1; + var fy = 1; + + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + + ctx.globalAlpha = bobAlpha; + + if (!flip) + { + if (roundPixels) + { + dx |= 0; + dy |= 0; + } + + ctx.drawImage( + frame.source.image, + cd.x, + cd.y, + cd.width, + cd.height, + dx + bob.x + cameraScrollX, + dy + bob.y + cameraScrollY, + cd.width, + cd.height + ); + } + else + { + if (bob.flipX) + { + fx = -1; + dx -= cd.width; + } + + if (bob.flipY) + { + fy = -1; + dy -= cd.height; + } + + ctx.save(); + ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); + ctx.scale(fx, fy); + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, dx, dy, cd.width, cd.height); + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = BlitterCanvasRenderer; + + +/***/ }), +/* 907 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var list = src.getRenderList(); + + if (list.length === 0) + { + return; + } + + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + + var calcMatrix = pipeline._tempMatrix1; + + calcMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + calcMatrix.multiplyWithOffset(parentMatrix, -cameraScrollX, -cameraScrollY); + + cameraScrollX = 0; + cameraScrollY = 0; + } + + var blitterX = src.x - cameraScrollX; + var blitterY = src.y - cameraScrollY; + var prevTextureSourceIndex = -1; + var tintEffect = false; + var alpha = camera.alpha * src.alpha; + var roundPixels = camera.roundPixels; + + for (var index = 0; index < list.length; index++) + { + var bob = list[index]; + var frame = bob.frame; + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + + var width = frame.width; + var height = frame.height; + + var x = blitterX + bob.x + frame.x; + var y = blitterY + bob.y + frame.y; + + if (bob.flipX) + { + width *= -1; + x += frame.width; + } + + if (bob.flipY) + { + height *= -1; + y += frame.height; + } + + var xw = x + width; + var yh = y + height; + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(xw, yh); + var ty1 = calcMatrix.getY(xw, yh); + + var tint = Utils.getTintAppendFloatAlpha(0xffffff, bobAlpha); + + // Bind texture only if the Texture Source is different from before + if (frame.sourceIndex !== prevTextureSourceIndex) + { + pipeline.setTexture2D(frame.glTexture, 0); + + prevTextureSourceIndex = frame.sourceIndex; + } + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + } + + // TL x/y, BL x/y, BR x/y, TR x/y + if (pipeline.batchQuad(tx0, ty0, tx0, ty1, tx1, ty1, tx1, ty0, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect)) + { + prevTextureSourceIndex = -1; + } + } +}; + +module.exports = BlitterWebGLRenderer; + + +/***/ }), +/* 908 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(907); +} + +if (true) +{ + renderCanvas = __webpack_require__(906); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 909 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTransform = __webpack_require__(23); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.BitmapText#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src._text; + var textLength = text.length; + + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + var textureFrame = src.frame; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + var letterSpacing = src._letterSpacing; + + var xAdvance = 0; + var yAdvance = 0; + + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var scale = (src._fontSize / src.fontData.size); + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + ctx.translate(-src.displayOriginX, -src.displayOriginY); + + var roundPixels = camera.roundPixels; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = glyph.xOffset + xAdvance; + y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + x *= scale; + y *= scale; + + x += lineOffsetX; + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + if (roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = BitmapTextCanvasRenderer; + + +/***/ }), +/* 910 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(9); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.BitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src._text; + var textLength = text.length; + + if (textLength === 0) + { + return; + } + + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = texture.width; + var textureHeight = texture.height; + + var tintEffect = (src._isTinted && src.tintFill); + var tintTL = Utils.getTintAppendFloatAlpha(src._tintTL, camera.alpha * src._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(src._tintTR, camera.alpha * src._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, camera.alpha * src._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, camera.alpha * src._alphaBR); + + pipeline.setTexture2D(texture, 0); + + var xAdvance = 0; + var yAdvance = 0; + var charCode = 0; + var lastCharCode = 0; + var letterSpacing = src._letterSpacing; + var glyph; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + var lastGlyph; + + var fontData = src.fontData; + var chars = fontData.chars; + var lineHeight = fontData.lineHeight; + var scale = (src._fontSize / fontData.size); + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + var roundPixels = camera.roundPixels; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + // Carriage-return + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + var x = glyph.xOffset + xAdvance; + var y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + x *= scale; + y *= scale; + + x -= src.displayOriginX; + y -= src.displayOriginY; + + x += lineOffsetX; + + var u0 = glyphX / textureWidth; + var v0 = glyphY / textureHeight; + var u1 = (glyphX + glyphW) / textureWidth; + var v1 = (glyphY + glyphH) / textureHeight; + + var xw = x + (glyphW * scale); + var yh = y + (glyphH * scale); + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } +}; + +module.exports = BitmapTextWebGLRenderer; + + +/***/ }), +/* 911 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(2); +var renderCanvas = __webpack_require__(2); + +if (true) +{ + renderWebGL = __webpack_require__(910); +} + +if (true) +{ + renderCanvas = __webpack_require__(909); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 912 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ParseXMLBitmapFont = __webpack_require__(338); + +/** + * Parse an XML Bitmap Font from an Atlas. + * + * Adds the parsed Bitmap Font data to the cache with the `fontName` key. + * + * @function ParseFromAtlas + * @since 3.0.0 + * @private + * + * @param {Phaser.Scene} scene - The Scene to parse the Bitmap Font for. + * @param {string} fontName - The key of the font to add to the Bitmap Font cache. + * @param {string} textureKey - The key of the BitmapFont's texture. + * @param {string} frameKey - The key of the BitmapFont texture's frame. + * @param {string} xmlKey - The key of the XML data of the font to parse. + * @param {integer} xSpacing - The x-axis spacing to add between each letter. + * @param {integer} ySpacing - The y-axis spacing to add to the line height. + * + * @return {boolean} Whether the parsing was successful or not. + */ +var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) +{ + var frame = scene.sys.textures.getFrame(textureKey, frameKey); + var xml = scene.sys.cache.xml.get(xmlKey); + + if (frame && xml) + { + var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame); + + scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey }); + + return true; + } + else + { + return false; + } +}; + +module.exports = ParseFromAtlas; + + +/***/ }), +/* 913 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} BitmapTextSize + * + * @property {GlobalBitmapTextSize} global - The position and size of the BitmapText, taking into account the position and scale of the Game Object. + * @property {LocalBitmapTextSize} local - The position and size of the BitmapText, taking just the font size into account. + */ + +/** + * The position and size of the Bitmap Text in global space, taking into account the Game Object's scale and world position. + * + * @typedef {object} GlobalBitmapTextSize + * + * @property {number} x - The x position of the BitmapText, taking into account the x position and scale of the Game Object. + * @property {number} y - The y position of the BitmapText, taking into account the y position and scale of the Game Object. + * @property {number} width - The width of the BitmapText, taking into account the x scale of the Game Object. + * @property {number} height - The height of the BitmapText, taking into account the y scale of the Game Object. + */ + +/** + * The position and size of the Bitmap Text in local space, taking just the font size into account. + * + * @typedef {object} LocalBitmapTextSize + * + * @property {number} x - The x position of the BitmapText. + * @property {number} y - The y position of the BitmapText. + * @property {number} width - The width of the BitmapText. + * @property {number} height - The height of the BitmapText. + */ + +/** + * Calculate the position, width and height of a BitmapText Game Object. + * + * Returns a BitmapTextSize object that contains global and local variants of the Game Objects x and y coordinates and + * its width and height. + * + * The global position and size take into account the Game Object's position and scale. + * + * The local position and size just takes into account the font data. + * + * @function GetBitmapTextSize + * @since 3.0.0 + * @private + * + * @param {(Phaser.GameObjects.DynamicBitmapText|Phaser.GameObjects.BitmapText)} src - The BitmapText to calculate the position, width and height of. + * @param {boolean} [round] - Whether to round the results to the nearest integer. + * @param {object} [out] - Optional object to store the results in, to save constant object creation. + * + * @return {BitmapTextSize} The calculated position, width and height of the BitmapText. + */ +var GetBitmapTextSize = function (src, round, out) +{ + if (out === undefined) + { + out = { + local: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + global: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + lines: { + shortest: 0, + longest: 0, + lengths: null + } + }; + } + + var text = src.text; + var textLength = text.length; + + var bx = Number.MAX_VALUE; + var by = Number.MAX_VALUE; + var bw = 0; + var bh = 0; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + var letterSpacing = src.letterSpacing; + + var xAdvance = 0; + var yAdvance = 0; + + var charCode = 0; + + var glyph = null; + + var x = 0; + var y = 0; + + var scale = (src.fontSize / src.fontData.size); + var sx = scale * src.scaleX; + var sy = scale * src.scaleY; + + var lastGlyph = null; + var lastCharCode = 0; + var lineWidths = []; + var shortestLine = Number.MAX_VALUE; + var longestLine = 0; + var currentLine = 0; + var currentLineWidth = 0; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + if (charCode === 10) + { + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + lineWidths[currentLine] = currentLineWidth; + + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + currentLine++; + currentLineWidth = 0; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + x = xAdvance; + y = yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (bx > x) + { + bx = x; + } + + if (by > y) + { + by = y; + } + + var gw = x + glyph.xAdvance; + var gh = y + lineHeight; + + if (bw < gw) + { + bw = gw; + } + + if (bh < gh) + { + bh = gh; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + currentLineWidth = gw * scale; + } + + lineWidths[currentLine] = currentLineWidth; + + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + var local = out.local; + var global = out.global; + var lines = out.lines; + + local.x = bx * scale; + local.y = by * scale; + local.width = bw * scale; + local.height = bh * scale; + + global.x = (src.x - src.displayOriginX) + (bx * sx); + global.y = (src.y - src.displayOriginY) + (by * sy); + global.width = bw * sx; + global.height = bh * sy; + + lines.shortest = shortestLine; + lines.longest = longestLine; + lines.lengths = lineWidths; + + if (round) + { + local.x = Math.round(local.x); + local.y = Math.round(local.y); + local.width = Math.round(local.width); + local.height = Math.round(local.height); + + global.x = Math.round(global.x); + global.y = Math.round(global.y); + global.width = Math.round(global.width); + global.height = Math.round(global.height); + + lines.shortest = Math.round(shortestLine); + lines.longest = Math.round(longestLine); + } + + return out; +}; + +module.exports = GetBitmapTextSize; + + +/***/ }), +/* 914 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var PluginCache = __webpack_require__(15); + +/** + * @classdesc + * The Update List plugin. + * + * Update Lists belong to a Scene and maintain the list Game Objects to be updated every frame. + * + * Some or all of these Game Objects may also be part of the Scene's [Display List]{@link Phaser.GameObjects.DisplayList}, for Rendering. + * + * @class UpdateList + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that the Update List belongs to. + */ +var UpdateList = new Class({ + + initialize: + + function UpdateList (scene) + { + /** + * The Scene that the Update List belongs to. + * + * @name Phaser.GameObjects.UpdateList#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The Scene's Systems. + * + * @name Phaser.GameObjects.UpdateList#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * The list of Game Objects. + * + * @name Phaser.GameObjects.UpdateList#_list + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._list = []; + + /** + * Game Objects that are pending insertion into the list. + * + * @name Phaser.GameObjects.UpdateList#_pendingInsertion + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingInsertion = []; + + /** + * Game Objects that are pending removal from the list. + * + * @name Phaser.GameObjects.UpdateList#_pendingRemoval + * @type {array} + * @private + * @default [] + * @since 3.0.0 + */ + this._pendingRemoval = []; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.UpdateList#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.systems.events.once('destroy', this.destroy, 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.GameObjects.UpdateList#start + * @private + * @since 3.5.0 + */ + start: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('preupdate', this.preUpdate, this); + eventEmitter.on('update', this.update, this); + eventEmitter.once('shutdown', this.shutdown, this); + }, + + /** + * Add a Game Object to the Update List. + * + * @method Phaser.GameObjects.UpdateList#add + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to add. + * + * @return {Phaser.GameObjects.GameObject} The added Game Object. + */ + add: function (child) + { + // Is child already in this list? + + if (this._list.indexOf(child) === -1 && this._pendingInsertion.indexOf(child) === -1) + { + this._pendingInsertion.push(child); + } + + return child; + }, + + /** + * The pre-update step. + * + * Handles Game Objects that are pending insertion to and removal from the list. + * + * @method Phaser.GameObjects.UpdateList#preUpdate + * @since 3.0.0 + */ + preUpdate: function () + { + var toRemove = this._pendingRemoval.length; + var toInsert = this._pendingInsertion.length; + + if (toRemove === 0 && toInsert === 0) + { + // Quick bail + return; + } + + var i; + var gameObject; + + // Delete old gameObjects + for (i = 0; i < toRemove; i++) + { + gameObject = this._pendingRemoval[i]; + + var index = this._list.indexOf(gameObject); + + if (index > -1) + { + this._list.splice(index, 1); + } + } + + // Move pending to active + this._list = this._list.concat(this._pendingInsertion.splice(0)); + + // Clear the lists + this._pendingRemoval.length = 0; + this._pendingInsertion.length = 0; + }, + + /** + * The update step. + * + * Pre-updates every active Game Object in the list. + * + * @method Phaser.GameObjects.UpdateList#update + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: function (time, delta) + { + for (var i = 0; i < this._list.length; i++) + { + var gameObject = this._list[i]; + + if (gameObject.active) + { + gameObject.preUpdate.call(gameObject, time, delta); + } + } + }, + + /** + * Remove a Game Object from the list. + * + * @method Phaser.GameObjects.UpdateList#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to remove from the list. + * + * @return {Phaser.GameObjects.GameObject} The removed Game Object. + */ + remove: function (child) + { + var index = this._list.indexOf(child); + + if (index !== -1) + { + this._list.splice(index, 1); + } + + return child; + }, + + /** + * Remove all Game Objects from the list. + * + * @method Phaser.GameObjects.UpdateList#removeAll + * @since 3.0.0 + * + * @return {Phaser.GameObjects.UpdateList} This UpdateList. + */ + removeAll: function () + { + var i = this._list.length; + + while (i--) + { + this.remove(this._list[i]); + } + + return 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.GameObjects.UpdateList#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + var i = this._list.length; + + while (i--) + { + this._list[i].destroy(true); + } + + i = this._pendingRemoval.length; + + while (i--) + { + this._pendingRemoval[i].destroy(true); + } + + i = this._pendingInsertion.length; + + while (i--) + { + this._pendingInsertion[i].destroy(true); + } + + 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); + }, + + /** + * 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 + */ + destroy: function () + { + this.shutdown(); + + this.scene.sys.events.off('start', this.start, this); + + this.scene = null; + this.systems = null; + }, + + /** + * The length of the list. + * + * @name Phaser.GameObjects.UpdateList#length + * @type {integer} + * @readonly + * @since 3.10.0 + */ + length: { + + get: function () + { + return this._list.length; + } + + } + +}); + +PluginCache.register('UpdateList', UpdateList, 'updateList'); + +module.exports = UpdateList; + + +/***/ }), +/* 915 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Swaps the position of two elements in the given array. + * The elements must exist in the same array. + * The array is modified in-place. + * + * @function Phaser.Utils.Array.Swap + * @since 3.4.0 + * + * @param {array} array - The input array. + * @param {*} item1 - The first element to swap. + * @param {*} item2 - The second element to swap. + * + * @return {array} The input array. + */ +var Swap = function (array, item1, item2) +{ + if (item1 === item2) + { + return; + } + + var index1 = array.indexOf(item1); + var index2 = array.indexOf(item2); + + if (index1 < 0 || index2 < 0) + { + throw new Error('Supplied items must be elements of the same array'); + } + + array[index1] = item2; + array[index2] = item1; + + return array; +}; + +module.exports = Swap; + + +/***/ }), +/* 916 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SafeRange = __webpack_require__(68); + +/** + * Scans the array for elements with the given property. If found, the property is set to the `value`. + * + * For example: `SetAll('visible', true)` would set all elements that have a `visible` property to `false`. + * + * Optionally you can specify a start and end index. For example if the array had 100 elements, + * and you set `startIndex` to 0 and `endIndex` to 50, it would update only the first 50 elements. + * + * @function Phaser.Utils.Array.SetAll + * @since 3.4.0 + * + * @param {array} array - The array to search. + * @param {string} property - The property to test for on each array element. + * @param {*} value - The value to set the property to. + * @param {integer} [startIndex] - An optional start index to search from. + * @param {integer} [endIndex] - An optional end index to search to. + * + * @return {array} The input array. + */ +var SetAll = function (array, property, value, startIndex, endIndex) +{ + if (startIndex === undefined) { startIndex = 0; } + if (endIndex === undefined) { endIndex = array.length; } + + if (SafeRange(array, startIndex, endIndex)) + { + for (var i = startIndex; i < endIndex; i++) + { + var entry = array[i]; + + if (entry.hasOwnProperty(property)) + { + entry[property] = value; + } + } + } + + return array; +}; + +module.exports = SetAll; + + +/***/ }), +/* 917 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the given element to the bottom of the array. + * The array is modified in-place. + * + * @function Phaser.Utils.Array.SendToBack + * @since 3.4.0 + * + * @param {array} array - The array. + * @param {*} item - The element to move. + * + * @return {*} The element that was moved. + */ +var SendToBack = function (array, item) +{ + var currentIndex = array.indexOf(item); + + if (currentIndex !== -1 && currentIndex > 0) + { + array.splice(currentIndex, 1); + array.unshift(item); + } + + return item; +}; + +module.exports = SendToBack; + + +/***/ }), +/* 918 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Replaces an element of the array with the new element. + * The new element cannot already be a member of the array. + * The array is modified in-place. + * + * @function Phaser.Utils.Array.Replace + * @since 3.4.0 + * + * @param {*} oldChild - The element in the array that will be replaced. + * @param {*} newChild - The element to be inserted into the array at the position of `oldChild`. + * + * @return {boolean} Returns true if the oldChild was successfully replaced, otherwise returns false. + */ +var Replace = function (array, oldChild, newChild) +{ + var index1 = array.indexOf(oldChild); + var index2 = array.indexOf(newChild); + + if (index1 !== -1 && index2 === -1) + { + array[index1] = newChild; + + return true; + } + else + { + return false; + } +}; + +module.exports = Replace; + + +/***/ }), +/* 919 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SpliceOne = __webpack_require__(100); + +/** + * Removes a random object from the given array and returns it. + * Will return null if there are no array items that fall within the specified range or if there is no item for the randomly chosen index. + * + * @function Phaser.Utils.Array.RemoveRandomElement + * @since 3.0.0 + * + * @param {array} array - The array to removed a random element from. + * @param {integer} [start=0] - The array index to start the search from. + * @param {integer} [length=array.length] - Optional restriction on the number of elements to randomly select from. + * + * @return {object} The random element that was removed, or `null` if there were no array elements that fell within the given range. + */ +var RemoveRandomElement = function (array, start, length) +{ + if (start === undefined) { start = 0; } + if (length === undefined) { length = array.length; } + + var randomIndex = start + Math.floor(Math.random() * length); + + return SpliceOne(array, randomIndex); +}; + +module.exports = RemoveRandomElement; + + +/***/ }), +/* 920 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SafeRange = __webpack_require__(68); + +/** + * Removes the item within the given range in the array. + * + * The array is modified in-place. + * + * You can optionally specify a callback to be invoked for the item/s successfully removed from the array. + * + * @function Phaser.Utils.Array.RemoveBetween + * @since 3.4.0 + * + * @param {array} array - The array to be modified. + * @param {integer} startIndex - The start index to remove from. + * @param {integer} endIndex - The end index to remove to. + * @param {function} [callback] - A callback to be invoked for the item removed from the array. + * @param {object} [context] - The context in which the callback is invoked. + * + * @return {Array.<*>} An array of items that were removed. + */ +var RemoveBetween = function (array, startIndex, endIndex, callback, context) +{ + if (startIndex === undefined) { startIndex = 0; } + if (endIndex === undefined) { endIndex = array.length; } + if (context === undefined) { context = array; } + + if (SafeRange(array, startIndex, endIndex)) + { + var size = endIndex - startIndex; + + var removed = array.splice(startIndex, size); + + if (callback) + { + for (var i = 0; i < removed.length; i++) + { + var entry = removed[i]; + + callback.call(context, entry); + } + } + + return removed; + } + else + { + return []; + } +}; + +module.exports = RemoveBetween; + + +/***/ }), +/* 921 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SpliceOne = __webpack_require__(100); + +/** + * Removes the item from the given position in the array. + * + * The array is modified in-place. + * + * You can optionally specify a callback to be invoked for the item if it is successfully removed from the array. + * + * @function Phaser.Utils.Array.RemoveAt + * @since 3.4.0 + * + * @param {array} array - The array to be modified. + * @param {integer} index - The array index to remove the item from. The index must be in bounds or it will throw an error. + * @param {function} [callback] - A callback to be invoked for the item removed from the array. + * @param {object} [context] - The context in which the callback is invoked. + * + * @return {*} The item that was removed. + */ +var RemoveAt = function (array, index, callback, context) +{ + if (context === undefined) { context = array; } + + if (index < 0 || index > array.length - 1) + { + throw new Error('Index out of bounds'); + } + + var item = SpliceOne(array, index); + + if (callback) + { + callback.call(context, item); + } + + return item; +}; + +module.exports = RemoveAt; + + +/***/ }), +/* 922 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RoundAwayFromZero = __webpack_require__(342); + +/** + * Create an array of numbers (positive and/or negative) progressing from `start` + * up to but not including `end` by advancing by `step`. + * + * If `start` is less than `end` a zero-length range is created unless a negative `step` is specified. + * + * Certain values for `start` and `end` (eg. NaN/undefined/null) are currently coerced to 0; + * for forward compatibility make sure to pass in actual numbers. + * + * @example + * NumberArrayStep(4); + * // => [0, 1, 2, 3] + * + * NumberArrayStep(1, 5); + * // => [1, 2, 3, 4] + * + * NumberArrayStep(0, 20, 5); + * // => [0, 5, 10, 15] + * + * NumberArrayStep(0, -4, -1); + * // => [0, -1, -2, -3] + * + * NumberArrayStep(1, 4, 0); + * // => [1, 1, 1] + * + * NumberArrayStep(0); + * // => [] + * + * @function Phaser.Utils.Array.NumberArrayStep + * @since 3.0.0 + * + * @param {number} [start=0] - The start of the range. + * @param {number} [end=null] - The end of the range. + * @param {number} [step=1] - The value to increment or decrement by. + * + * @return {number[]} [description] + */ +var NumberArrayStep = function (start, end, step) +{ + if (start === undefined) { start = 0; } + if (end === undefined) { end = null; } + if (step === undefined) { step = 1; } + + if (end === null) + { + end = start; + start = 0; + } + + var result = []; + + var total = Math.max(RoundAwayFromZero((end - start) / (step || 1)), 0); + + for (var i = 0; i < total; i++) + { + result.push(start); + start += step; + } + + return result; +}; + +module.exports = NumberArrayStep; + + +/***/ }), +/* 923 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Create an array representing the range of numbers (usually integers), between, and inclusive of, + * the given `start` and `end` arguments. For example: + * + * `var array = numberArray(2, 4); // array = [2, 3, 4]` + * `var array = numberArray(0, 9); // array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]` + * + * This is equivalent to `numberArrayStep(start, end, 1)`. + * + * You can optionally provide a prefix and / or suffix string. If given the array will contain + * strings, not integers. For example: + * + * `var array = numberArray(1, 4, 'Level '); // array = ["Level 1", "Level 2", "Level 3", "Level 4"]` + * `var array = numberArray(5, 7, 'HD-', '.png'); // array = ["HD-5.png", "HD-6.png", "HD-7.png"]` + * + * @function Phaser.Utils.Array.NumberArray + * @since 3.0.0 + * + * @param {number} start - The minimum value the array starts with. + * @param {number} end - The maximum value the array contains. + * @param {string} [prefix] - Optional prefix to place before the number. If provided the array will contain strings, not integers. + * @param {string} [suffix] - Optional suffix to place after the number. If provided the array will contain strings, not integers. + * + * @return {(number[]|string[])} The array of number values, or strings if a prefix or suffix was provided. + */ +var NumberArray = function (start, end, prefix, suffix) +{ + var result = []; + + for (var i = start; i <= end; i++) + { + if (prefix || suffix) + { + var key = (prefix) ? prefix + i.toString() : i.toString(); + + if (suffix) + { + key = key.concat(suffix); + } + + result.push(key); + } + else + { + result.push(i); + } + } + + return result; +}; + +module.exports = NumberArray; + + +/***/ }), +/* 924 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the given array element up one place in the array. + * The array is modified in-place. + * + * @function Phaser.Utils.Array.MoveUp + * @since 3.4.0 + * + * @param {array} array - The input array. + * @param {*} item - The element to move up the array. + * + * @return {array} The input array. + */ +var MoveUp = function (array, item) +{ + var currentIndex = array.indexOf(item); + + if (currentIndex !== -1 && currentIndex < array.length - 2) + { + var item2 = array[currentIndex + 1]; + + var index2 = array.indexOf(item2); + + array[currentIndex] = item2; + array[index2] = item; + } + + return array; +}; + +module.exports = MoveUp; + + +/***/ }), +/* 925 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves an element in an array to a new position within the same array. + * The array is modified in-place. + * + * @function Phaser.Utils.Array.MoveTo + * @since 3.4.0 + * + * @param {array} array - The array. + * @param {*} item - The element to move. + * @param {integer} index - The new index that the element will be moved to. + * + * @return {*} The element that was moved. + */ +var MoveTo = function (array, item, index) +{ + var currentIndex = array.indexOf(item); + + if (currentIndex === -1 || index < 0 || index >= array.length) + { + throw new Error('Supplied index out of bounds'); + } + + if (currentIndex !== index) + { + // Remove + array.splice(currentIndex, 1); + + // Add in new location + array.splice(index, 0, item); + } + + return item; +}; + +module.exports = MoveTo; + + +/***/ }), +/* 926 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the given array element down one place in the array. + * The array is modified in-place. + * + * @function Phaser.Utils.Array.MoveDown + * @since 3.4.0 + * + * @param {array} array - The input array. + * @param {*} item - The element to move down the array. + * + * @return {array} The input array. + */ +var MoveDown = function (array, item) +{ + var currentIndex = array.indexOf(item); + + if (currentIndex > 0) + { + var item2 = array[currentIndex - 1]; + + var index2 = array.indexOf(item2); + + array[currentIndex] = item2; + array[index2] = item; + } + + return array; +}; + +module.exports = MoveDown; + + +/***/ }), +/* 927 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SafeRange = __webpack_require__(68); + +/** + * Returns the first element in the array. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('visible', true)` would return the first element that had its `visible` property set. + * + * Optionally you can specify a start and end index. For example if the array had 100 elements, + * and you set `startIndex` to 0 and `endIndex` to 50, it would search only the first 50 elements. + * + * @function Phaser.Utils.Array.GetFirst + * @since 3.4.0 + * + * @param {array} array - The array to search. + * @param {string} [property] - The property to test on each array element. + * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=array.length] - An optional end index to search up to (but not included) + * + * @return {object} The first matching element from the array, or `null` if no element could be found in the range given. + */ +var GetFirst = function (array, property, value, startIndex, endIndex) +{ + if (startIndex === undefined) { startIndex = 0; } + if (endIndex === undefined) { endIndex = array.length; } + + if (SafeRange(array, startIndex, endIndex)) + { + for (var i = startIndex; i < endIndex; i++) + { + var child = array[i]; + + if (!property || + (property && value === undefined && child.hasOwnProperty(property)) || + (property && value !== undefined && child[property] === value)) + { + return child; + } + } + } + + return null; +}; + +module.exports = GetFirst; + + +/***/ }), +/* 928 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SafeRange = __webpack_require__(68); + +/** + * Returns all elements in the array. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('visible', true)` would return only elements that have their visible property set. + * + * Optionally you can specify a start and end index. For example if the array had 100 elements, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 elements. + * + * @function Phaser.Utils.Array.GetAll + * @since 3.4.0 + * + * @param {array} array - The array to search. + * @param {string} [property] - The property to test on each array element. + * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. + * @param {integer} [startIndex] - An optional start index to search from. + * @param {integer} [endIndex] - An optional end index to search to. + * + * @return {array} All matching elements from the array. + */ +var GetAll = function (array, property, value, startIndex, endIndex) +{ + if (startIndex === undefined) { startIndex = 0; } + if (endIndex === undefined) { endIndex = array.length; } + + var output = []; + + if (SafeRange(array, startIndex, endIndex)) + { + for (var i = startIndex; i < endIndex; i++) + { + var child = array[i]; + + if (!property || + (property && value === undefined && child.hasOwnProperty(property)) || + (property && value !== undefined && child[property] === value)) + { + output.push(child); + } + } + } + + return output; +}; + +module.exports = GetAll; + + +/***/ }), +/* 929 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SafeRange = __webpack_require__(68); + +/** + * Passes each element in the array, between the start and end indexes, to the given callback. + * + * @function Phaser.Utils.Array.EachInRange + * @since 3.4.0 + * + * @param {array} array - The array to search. + * @param {function} callback - A callback to be invoked for each item in the array. + * @param {object} context - The context in which the callback is invoked. + * @param {integer} startIndex - The start index to search from. + * @param {integer} endIndex - The end index to search to. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {array} The input array. + */ +var EachInRange = function (array, callback, context, startIndex, endIndex) +{ + if (startIndex === undefined) { startIndex = 0; } + if (endIndex === undefined) { endIndex = array.length; } + + if (SafeRange(array, startIndex, endIndex)) + { + var i; + var args = [ null ]; + + for (i = 5; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = startIndex; i < endIndex; i++) + { + args[0] = array[i]; + + callback.apply(context, args); + } + } + + return array; +}; + +module.exports = EachInRange; + + +/***/ }), +/* 930 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Passes each element in the array to the given callback. + * + * @function Phaser.Utils.Array.Each + * @since 3.4.0 + * + * @param {array} array - The array to search. + * @param {function} callback - A callback to be invoked for each item in the array. + * @param {object} context - The context in which the callback is invoked. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the current array item. + * + * @return {array} The input array. + */ +var Each = function (array, callback, context) +{ + var i; + var args = [ null ]; + + for (i = 3; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < array.length; i++) + { + args[0] = array[i]; + + callback.apply(context, args); + } + + return array; +}; + +module.exports = Each; + + +/***/ }), +/* 931 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SafeRange = __webpack_require__(68); + +/** + * Returns the total number of elements in the array which have a property matching the given value. + * + * @function Phaser.Utils.Array.CountAllMatching + * @since 3.4.0 + * + * @param {array} array - The array to search. + * @param {string} property - The property to test on each array element. + * @param {*} value - The value to test the property against. Must pass a strict (`===`) comparison check. + * @param {integer} [startIndex] - An optional start index to search from. + * @param {integer} [endIndex] - An optional end index to search to. + * + * @return {integer} The total number of elements with properties matching the given value. + */ +var CountAllMatching = function (array, property, value, startIndex, endIndex) +{ + if (startIndex === undefined) { startIndex = 0; } + if (endIndex === undefined) { endIndex = array.length; } + + var total = 0; + + if (SafeRange(array, startIndex, endIndex)) + { + for (var i = startIndex; i < endIndex; i++) + { + var child = array[i]; + + if (child[property] === value) + { + total++; + } + } + } + + return total; +}; + +module.exports = CountAllMatching; + + +/***/ }), +/* 932 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the given element to the top of the array. + * The array is modified in-place. + * + * @function Phaser.Utils.Array.BringToTop + * @since 3.4.0 + * + * @param {array} array - The array. + * @param {*} item - The element to move. + * + * @return {*} The element that was moved. + */ +var BringToTop = function (array, item) +{ + var currentIndex = array.indexOf(item); + + if (currentIndex !== -1 && currentIndex < array.length) + { + array.splice(currentIndex, 1); + array.push(item); + } + + return item; +}; + +module.exports = BringToTop; + + +/***/ }), +/* 933 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds the given item, or array of items, to the array starting at the index specified. + * + * Each item must be unique within the array. + * + * Existing elements in the array are shifted up. + * + * The array is modified in-place and returned. + * + * You can optionally specify a limit to the maximum size of the array. If the quantity of items being + * added will take the array length over this limit, it will stop adding once the limit is reached. + * + * You can optionally specify a callback to be invoked for each item successfully added to the array. + * + * @function Phaser.Utils.Array.AddAt + * @since 3.4.0 + * + * @param {array} array - The array to be added to. + * @param {any|any[]} item - The item, or array of items, to add to the array. + * @param {integer} [index=0] - The index in the array where the item will be inserted. + * @param {integer} [limit] - Optional limit which caps the size of the array. + * @param {function} [callback] - A callback to be invoked for each item successfully added to the array. + * @param {object} [context] - The context in which the callback is invoked. + * + * @return {array} The input array. + */ +var AddAt = function (array, item, index, limit, callback, context) +{ + if (index === undefined) { index = 0; } + if (context === undefined) { context = array; } + + if (limit > 0) + { + var remaining = limit - array.length; + + // There's nothing more we can do here, the array is full + if (remaining <= 0) + { + return null; + } + } + + // Fast path to avoid array mutation and iteration + if (!Array.isArray(item)) + { + if (array.indexOf(item) === -1) + { + array.splice(index, 0, item); + + if (callback) + { + callback.call(context, item); + } + + return item; + } + else + { + return null; + } + } + + // If we got this far, we have an array of items to insert + + // Ensure all the items are unique + var itemLength = item.length - 1; + + while (itemLength >= 0) + { + if (array.indexOf(item[itemLength]) !== -1) + { + // Already exists in array, so remove it + item.pop(); + } + + itemLength--; + } + + // Anything left? + itemLength = item.length; + + if (itemLength === 0) + { + return null; + } + + // Truncate to the limit + if (limit > 0 && itemLength > remaining) + { + item.splice(remaining); + + itemLength = remaining; + } + + for (var i = itemLength - 1; i >= 0; i--) + { + var entry = item[i]; + + array.splice(index, 0, entry); + + if (callback) + { + callback.call(context, entry); + } + } + + return item; +}; + +module.exports = AddAt; + + +/***/ }), +/* 934 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds the given item, or array of items, to the array. + * + * Each item must be unique within the array. + * + * The array is modified in-place and returned. + * + * You can optionally specify a limit to the maximum size of the array. If the quantity of items being + * added will take the array length over this limit, it will stop adding once the limit is reached. + * + * You can optionally specify a callback to be invoked for each item successfully added to the array. + * + * @function Phaser.Utils.Array.Add + * @since 3.4.0 + * + * @param {array} array - The array to be added to. + * @param {any|any[]} item - The item, or array of items, to add to the array. Each item must be unique within the array. + * @param {integer} [limit] - Optional limit which caps the size of the array. + * @param {function} [callback] - A callback to be invoked for each item successfully added to the array. + * @param {object} [context] - The context in which the callback is invoked. + * + * @return {array} The input array. + */ +var Add = function (array, item, limit, callback, context) +{ + if (context === undefined) { context = array; } + + if (limit > 0) + { + var remaining = limit - array.length; + + // There's nothing more we can do here, the array is full + if (remaining <= 0) + { + return null; + } + } + + // Fast path to avoid array mutation and iteration + if (!Array.isArray(item)) + { + if (array.indexOf(item) === -1) + { + array.push(item); + + if (callback) + { + callback.call(context, item); + } + + return item; + } + else + { + return null; + } + } + + // If we got this far, we have an array of items to insert + + // Ensure all the items are unique + var itemLength = item.length - 1; + + while (itemLength >= 0) + { + if (array.indexOf(item[itemLength]) !== -1) + { + // Already exists in array, so remove it + item.pop(); + } + + itemLength--; + } + + // Anything left? + itemLength = item.length; + + if (itemLength === 0) + { + return null; + } + + if (limit > 0 && itemLength > remaining) + { + item.splice(remaining); + + itemLength = remaining; + } + + for (var i = 0; i < itemLength; i++) + { + var entry = item[i]; + + array.push(entry); + + if (callback) + { + callback.call(context, entry); + } + } + + return item; +}; + +module.exports = Add; + + +/***/ }), +/* 935 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateMatrix = __webpack_require__(121); + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateRight + * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] + */ +var RotateRight = function (matrix) +{ + return RotateMatrix(matrix, -90); +}; + +module.exports = RotateRight; + + +/***/ }), +/* 936 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateMatrix = __webpack_require__(121); + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateLeft + * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] + */ +var RotateLeft = function (matrix) +{ + return RotateMatrix(matrix, 90); +}; + +module.exports = RotateLeft; + + +/***/ }), +/* 937 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateMatrix = __webpack_require__(121); + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.Rotate180 + * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] + */ +var Rotate180 = function (matrix) +{ + return RotateMatrix(matrix, 180); +}; + +module.exports = Rotate180; + + +/***/ }), +/* 938 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.ReverseRows + * @since 3.0.0 + * + * @param {array} matrix - [description] + * + * @return {array} [description] + */ +var ReverseRows = function (matrix) +{ + return matrix.reverse(); +}; + +module.exports = ReverseRows; + + +/***/ }), +/* 939 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Reverses the columns in the given Array Matrix. + * + * @function Phaser.Utils.Array.Matrix.ReverseColumns + * @since 3.0.0 + * + * @param {array} matrix - The array matrix to reverse the columns for. + * + * @return {array} The column reversed matrix. + */ +var ReverseColumns = function (matrix) +{ + for (var i = 0; i < matrix.length; i++) + { + matrix[i].reverse(); + } + + return matrix; +}; + +module.exports = ReverseColumns; + + +/***/ }), +/* 940 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Pad = __webpack_require__(197); +var CheckMatrix = __webpack_require__(179); + +// Generates a string (which you can pass to console.log) from the given +// Array Matrix. + +/** + * Generates a string (which you can pass to console.log) from the given Array Matrix. + * + * @function Phaser.Utils.Array.Matrix.MatrixToString + * @since 3.0.0 + * + * @param {array} matrix - A 2-dimensional array. + * + * @return {string} A string representing the matrix. + */ +var MatrixToString = function (matrix) +{ + var str = ''; + + if (!CheckMatrix(matrix)) + { + return str; + } + + for (var r = 0; r < matrix.length; r++) + { + for (var c = 0; c < matrix[r].length; c++) + { + var cell = matrix[r][c].toString(); + + if (cell !== 'undefined') + { + str += Pad(cell, 2); + } + else + { + str += '?'; + } + + if (c < matrix[r].length - 1) + { + str += ' |'; + } + } + + if (r < matrix.length - 1) + { + str += '\n'; + + for (var i = 0; i < matrix[r].length; i++) + { + str += '---'; + + if (i < matrix[r].length - 1) + { + str += '+'; + } + } + + str += '\n'; + } + + } + + return str; +}; + +module.exports = MatrixToString; + + +/***/ }), +/* 941 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.Array.Matrix + */ + +module.exports = { + + CheckMatrix: __webpack_require__(179), + MatrixToString: __webpack_require__(940), + ReverseColumns: __webpack_require__(939), + ReverseRows: __webpack_require__(938), + Rotate180: __webpack_require__(937), + RotateLeft: __webpack_require__(936), + RotateMatrix: __webpack_require__(121), + RotateRight: __webpack_require__(935), + TransposeMatrix: __webpack_require__(343) + +}; + + +/***/ }), +/* 942 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var List = __webpack_require__(122); +var PluginCache = __webpack_require__(15); +var StableSort = __webpack_require__(120); + +/** + * @classdesc + * The Display List plugin. + * + * Display Lists belong to a Scene and maintain the list of Game Objects to render every frame. + * + * Some of these Game Objects may also be part of the Scene's [Update List]{@link Phaser.GameObjects.UpdateList}, for updating. + * + * @class DisplayList + * @extends Phaser.Structs.List. + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that this Display List belongs to. + */ +var DisplayList = new Class({ + + Extends: List, + + initialize: + + function DisplayList (scene) + { + List.call(this, scene); + + /** + * The flag the determines whether Game Objects should be sorted when `depthSort()` is called. + * + * @name Phaser.GameObjects.DisplayList#sortChildrenFlag + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.sortChildrenFlag = false; + + /** + * The Scene that this Display List belongs to. + * + * @name Phaser.GameObjects.DisplayList#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The Scene's Systems. + * + * @name Phaser.GameObjects.DisplayList#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.DisplayList#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.systems.events.once('destroy', this.destroy, 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.GameObjects.DisplayList#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.systems.events.once('shutdown', this.shutdown, this); + }, + + /** + * Force a sort of the display list on the next call to depthSort. + * + * @method Phaser.GameObjects.DisplayList#queueDepthSort + * @since 3.0.0 + */ + queueDepthSort: function () + { + this.sortChildrenFlag = true; + }, + + /** + * Immediately sorts the display list if the flag is set. + * + * @method Phaser.GameObjects.DisplayList#depthSort + * @since 3.0.0 + */ + depthSort: function () + { + if (this.sortChildrenFlag) + { + StableSort.inplace(this.list, this.sortByDepth); + + this.sortChildrenFlag = false; + } + }, + + /** + * Compare the depth of two Game Objects. + * + * @method Phaser.GameObjects.DisplayList#sortByDepth + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} childA - The first Game Object. + * @param {Phaser.GameObjects.GameObject} childB - The second Game Object. + * + * @return {integer} The difference between the depths of each Game Object. + */ + sortByDepth: function (childA, childB) + { + return childA._depth - childB._depth; + }, + + /** + * Given an array of Game Objects, sort the array and return it, so that + * the objects are in index order with the lowest at the bottom. + * + * @method Phaser.GameObjects.DisplayList#sortGameObjects + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - The array of Game Objects to sort. + * + * @return {array} The sorted array of Game Objects. + */ + sortGameObjects: function (gameObjects) + { + if (gameObjects === undefined) { gameObjects = this.list; } + + this.scene.sys.depthSort(); + + return gameObjects.sort(this.sortIndexHandler.bind(this)); + }, + + /** + * Get the top-most Game Object in the given array of Game Objects, after sorting it. + * + * Note that the given array is sorted in place, even though it isn't returned directly it will still be updated. + * + * @method Phaser.GameObjects.DisplayList#getTopGameObject + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} gameObjects - The array of Game Objects. + * + * @return {Phaser.GameObjects.GameObject} The top-most Game Object in the array of Game Objects. + */ + getTopGameObject: function (gameObjects) + { + this.sortGameObjects(gameObjects); + + return gameObjects[gameObjects.length - 1]; + }, + + /** + * All members of the group. + * + * @method Phaser.GameObjects.DisplayList#getChildren + * @since 3.12.0 + * + * @return {Phaser.GameObjects.GameObject[]} The group members. + */ + getChildren: function () + { + return this.list; + }, + + /** + * 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 () + { + var i = this.list.length; + + while (i--) + { + this.list[i].destroy(true); + } + + this.list.length = 0; + + this.systems.events.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; + } + +}); + +PluginCache.register('DisplayList', DisplayList, 'displayList'); + +module.exports = DisplayList; + + +/***/ }), +/* 943 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects + */ + +var GameObjects = { + + DisplayList: __webpack_require__(942), + GameObjectCreator: __webpack_require__(14), + GameObjectFactory: __webpack_require__(5), + UpdateList: __webpack_require__(914), + + Components: __webpack_require__(16), + + BuildGameObject: __webpack_require__(32), + BuildGameObjectAnimation: __webpack_require__(339), + GameObject: __webpack_require__(17), + BitmapText: __webpack_require__(119), + Blitter: __webpack_require__(177), + Container: __webpack_require__(176), + DynamicBitmapText: __webpack_require__(175), + Graphics: __webpack_require__(174), + Group: __webpack_require__(97), + Image: __webpack_require__(78), + Particles: __webpack_require__(890), + PathFollower: __webpack_require__(324), + RenderTexture: __webpack_require__(170), + RetroFont: __webpack_require__(881), + Sprite: __webpack_require__(57), + Text: __webpack_require__(169), + TileSprite: __webpack_require__(168), + Zone: __webpack_require__(135), + + // Shapes + + Shape: __webpack_require__(31), + Arc: __webpack_require__(321), + Curve: __webpack_require__(320), + Ellipse: __webpack_require__(319), + Grid: __webpack_require__(318), + IsoBox: __webpack_require__(317), + IsoTriangle: __webpack_require__(316), + Line: __webpack_require__(315), + Polygon: __webpack_require__(314), + Rectangle: __webpack_require__(309), + Star: __webpack_require__(308), + Triangle: __webpack_require__(307), + + // Game Object Factories + + Factories: { + Blitter: __webpack_require__(836), + Container: __webpack_require__(835), + DynamicBitmapText: __webpack_require__(834), + Graphics: __webpack_require__(833), + Group: __webpack_require__(832), + Image: __webpack_require__(831), + Particles: __webpack_require__(830), + PathFollower: __webpack_require__(829), + RenderTexture: __webpack_require__(828), + Sprite: __webpack_require__(827), + StaticBitmapText: __webpack_require__(826), + Text: __webpack_require__(825), + TileSprite: __webpack_require__(824), + Zone: __webpack_require__(823), + + // Shapes + Arc: __webpack_require__(822), + Curve: __webpack_require__(821), + Ellipse: __webpack_require__(820), + Grid: __webpack_require__(819), + IsoBox: __webpack_require__(818), + IsoTriangle: __webpack_require__(817), + Line: __webpack_require__(816), + Polygon: __webpack_require__(815), + Rectangle: __webpack_require__(814), + Star: __webpack_require__(813), + Triangle: __webpack_require__(812) + }, + + Creators: { + Blitter: __webpack_require__(811), + Container: __webpack_require__(810), + DynamicBitmapText: __webpack_require__(809), + Graphics: __webpack_require__(808), + Group: __webpack_require__(807), + Image: __webpack_require__(806), + Particles: __webpack_require__(805), + RenderTexture: __webpack_require__(804), + Sprite: __webpack_require__(803), + StaticBitmapText: __webpack_require__(802), + Text: __webpack_require__(801), + TileSprite: __webpack_require__(800), + Zone: __webpack_require__(799) + } + +}; + +if (false) +{} + +if (true) +{ + // WebGL only Game Objects + GameObjects.Mesh = __webpack_require__(118); + GameObjects.Quad = __webpack_require__(165); + + GameObjects.Factories.Mesh = __webpack_require__(795); + GameObjects.Factories.Quad = __webpack_require__(794); + + GameObjects.Creators.Mesh = __webpack_require__(793); + GameObjects.Creators.Quad = __webpack_require__(792); + + GameObjects.Light = __webpack_require__(304); + + __webpack_require__(303); + __webpack_require__(791); +} + +module.exports = GameObjects; + + +/***/ }), +/* 944 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(1); + +/** + * @typedef {object} Purchase + * + * @property {string} [developerPayload] - A developer-specified string, provided during the purchase of the product. + * @property {string} [paymentID] - The identifier for the purchase transaction. + * @property {string} [productID] - The product's game-specified identifier. + * @property {string} [purchaseTime] - Unix timestamp of when the purchase occurred. + * @property {string} [purchaseToken] - A token representing the purchase that may be used to consume the purchase. + * @property {string} [signedRequest] - Server-signed encoding of the purchase request. + */ + +var Purchase = function (data) +{ + return { + developerPayload: GetFastValue(data, 'developerPayload', ''), + paymentID: GetFastValue(data, 'paymentID', ''), + productID: GetFastValue(data, 'productID', ''), + purchaseTime: GetFastValue(data, 'purchaseTime', ''), + purchaseToken: GetFastValue(data, 'purchaseToken', ''), + signedRequest: GetFastValue(data, 'signedRequest', '') + }; +}; + +module.exports = Purchase; + + +/***/ }), +/* 945 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(1); + +/** + * @typedef {object} Product + * + * @property {string} [title] - The title of the product. + * @property {string} [productID] - The product's game-specified identifier. + * @property {string} [description] - The product description. + * @property {string} [imageURI] - A link to the product's associated image. + * @property {string} [price] - The price of the product. + * @property {string} [priceCurrencyCode] - The currency code for the product. + */ + +var Product = function (data) +{ + return { + title: GetFastValue(data, 'title', ''), + productID: GetFastValue(data, 'productID', ''), + description: GetFastValue(data, 'description', ''), + imageURI: GetFastValue(data, 'imageURI', ''), + price: GetFastValue(data, 'price', ''), + priceCurrencyCode: GetFastValue(data, 'priceCurrencyCode', '') + }; +}; + +module.exports = Product; + + +/***/ }), +/* 946 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} LeaderboardScore + * + * @property {integer} score - An integer score value. + * @property {string} scoreFormatted - The score value, formatted with the score format associated with the leaderboard. + * @property {integer} timestamp - The Unix timestamp of when the leaderboard entry was last updated. + * @property {integer} rank - The entry's leaderboard ranking. + * @property {string} data - The developer-specified payload associated with the score, or null if one was not set. + * @property {string} playerName - The player's localized display name. + * @property {string} playerPhotoURL - A url to the player's public profile photo. + * @property {string} playerID - The game's unique identifier for the player. + */ + +var LeaderboardScore = function (entry) +{ + return { + score: entry.getScore(), + scoreFormatted: entry.getFormattedScore(), + timestamp: entry.getTimestamp(), + rank: entry.getRank(), + data: entry.getExtraData(), + playerName: entry.getPlayer().getName(), + playerPhotoURL: entry.getPlayer().getPhoto(), + playerID: entry.getPlayer().getID() + }; +}; + +module.exports = LeaderboardScore; + + +/***/ }), +/* 947 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var LeaderboardScore = __webpack_require__(946); + +/** + * @classdesc + * This class represents one single Leaderboard that belongs to a Facebook Instant Game. + * + * You do not need to instantiate this class directly, it will be created when you use the + * `getLeaderboard()` method of the main plugin. + * + * @class Leaderboard + * @memberOf Phaser.FacebookInstantGamesPlugin + * @constructor + * @since 3.13.0 + * + * @param {Phaser.FacebookInstantGamesPlugin} plugin - A reference to the Facebook Instant Games Plugin. + * @param {any} data - An Instant Game leaderboard instance. + */ +var Leaderboard = new Class({ + + Extends: EventEmitter, + + initialize: + + function Leaderboard (plugin, data) + { + EventEmitter.call(this); + + /** + * A reference to the Facebook Instant Games Plugin. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#plugin + * @type {Phaser.FacebookInstantGamesPlugin} + * @since 3.13.0 + */ + this.plugin = plugin; + + /** + * An Instant Game leaderboard instance. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#ref + * @type {any} + * @since 3.13.0 + */ + this.ref = data; + + /** + * The name of the leaderboard. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#name + * @type {string} + * @since 3.13.0 + */ + this.name = data.getName(); + + /** + * The ID of the context that the leaderboard is associated with, or null if the leaderboard is not tied to a particular context. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#contextID + * @type {string} + * @since 3.13.0 + */ + this.contextID = data.getContextID(); + + /** + * The total number of player entries in the leaderboard. + * This value defaults to zero. Populate it via the `getEntryCount()` method. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#entryCount + * @type {integer} + * @since 3.13.0 + */ + this.entryCount = 0; + + /** + * The players score object. + * This value defaults to `null`. Populate it via the `getPlayerScore()` method. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#playerScore + * @type {LeaderboardScore} + * @since 3.13.0 + */ + this.playerScore = null; + + /** + * The scores in the Leaderboard from the currently requested range. + * This value defaults to an empty array. Populate it via the `getScores()` method. + * The contents of this array are reset each time `getScores()` is called. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#scores + * @type {LeaderboardScore[]} + * @since 3.13.0 + */ + this.scores = []; + + this.getEntryCount(); + }, + + /** + * Fetches the total number of player entries in the leaderboard. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getentrycount` event along with the count and name of the Leaderboard. + * + * @method Phaser.FacebookInstantGamesPlugin.Leaderboard#getEntryCount + * @since 3.13.0 + * + * @return {this} This Leaderboard instance. + */ + getEntryCount: function () + { + var _this = this; + + this.ref.getEntryCountAsync().then(function (count) + { + _this.entryCount = count; + + _this.emit('getentrycount', count, _this.name); + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + }, + + /** + * Updates the player's score. If the player has an existing score, the old score will only be replaced if the new score is better than it. + * NOTE: If the leaderboard is associated with a specific context, the game must be in that context to set a score for the player. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `setscore` event along with the score, any extra data and the name of the Leaderboard. + * + * @method Phaser.FacebookInstantGamesPlugin.Leaderboard#setScore + * @since 3.13.0 + * + * @param {integer} score - The new score for the player. Must be a 64-bit integer number. + * @param {string} [data] - Metadata to associate with the stored score. Must be less than 2KB in size. + * + * @return {this} This Leaderboard instance. + */ + setScore: function (score, data) + { + if (data === undefined) { data = ''; } + + var _this = this; + + this.ref.setScoreAsync(score, data).then(function (entry) + { + _this.emit('setscore', entry.getScore(), entry.getExtraData(), _this.name); + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + }, + + /** + * Gets the players leaderboard entry and stores it in the `playerScore` property. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getplayerscore` event along with the score and the name of the Leaderboard. + * + * @method Phaser.FacebookInstantGamesPlugin.Leaderboard#getPlayerScore + * @since 3.13.0 + * + * @return {this} This Leaderboard instance. + */ + getPlayerScore: function () + { + var _this = this; + + this.ref.getPlayerEntryAsync().then(function (entry) + { + var score = LeaderboardScore(entry); + + _this.playerScore = score; + + _this.emit('getplayerscore', score, _this.name); + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + }, + + /** + * Retrieves a set of leaderboard entries, ordered by score ranking in the leaderboard. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getplayerscore` event along with the score and the name of the Leaderboard. + * + * @method Phaser.FacebookInstantGamesPlugin.Leaderboard#getScores + * @since 3.13.0 + * + * @param {integer} [count=10] - The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query. + * @param {integer} [offset=0] - The offset from the top of the leaderboard that entries will be fetched from. + * + * @return {this} This Leaderboard instance. + */ + getScores: function (count, offset) + { + if (count === undefined) { count = 10; } + if (offset === undefined) { offset = 0; } + + var _this = this; + + this.ref.getEntriesAsync().then(function (entries) + { + _this.scores = []; + + entries.forEach(function (entry) + { + _this.scores.push(LeaderboardScore(entry)); + }); + + _this.emit('getscores', _this.scores, _this.name); + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + } + +}); + +module.exports = Leaderboard; + + +/***/ }), +/* 948 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} AdInstance + * + * @property {any} instance - Represents an instance of an ad. + * @property {string} placementID - The Audience Network placement ID of this ad instance. + * @property {boolean} shown - Has this ad already been shown in-game? + * @property {boolean} video - Is this a video ad? + */ + +var AdInstance = function (instance, video) +{ + return { + instance: instance, + placementID: instance.getPlacementID(), + shown: false, + video: video + }; +}; + +module.exports = AdInstance; + + +/***/ }), +/* 949 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Visibility Handler hidden event. + * + * The document in which the Game is embedded has entered a hidden state. + * + * @event Phaser.Boot.VisibilityHandler#hidden + */ + +/** + * Visibility Handler visible event. + * + * The document in which the Game is embedded has entered a visible state. + * + * @event Phaser.Boot.VisibilityHandler#visible + */ + +/** + * Visibility Handler blur event. + * + * The window in which the Game is embedded has entered a blurred state. + * + * @event Phaser.Boot.VisibilityHandler#blur + */ + +/** + * Visibility Handler focus event. + * + * The window in which the Game is embedded has entered a focused state. + * + * @event Phaser.Boot.VisibilityHandler#focus + */ + +/** + * The Visibility Handler is responsible for listening out for document level visibility change events. + * This includes `visibilitychange` if the browser supports it, and blur and focus events. It then uses + * the provided Event Emitter and fires the related events. + * + * @function Phaser.Boot.VisibilityHandler + * @fires Phaser.Boot.VisibilityHandler#hidden + * @fires Phaser.Boot.VisibilityHandler#visible + * @fires Phaser.Boot.VisibilityHandler#blur + * @fires Phaser.Boot.VisibilityHandler#focus + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Game instance this Visibility Handler is working on. + */ +var VisibilityHandler = function (game) +{ + var hiddenVar; + var eventEmitter = game.events; + + if (document.hidden !== undefined) + { + hiddenVar = 'visibilitychange'; + } + else + { + var vendors = [ 'webkit', 'moz', 'ms' ]; + + vendors.forEach(function (prefix) + { + if (document[prefix + 'Hidden'] !== undefined) + { + document.hidden = function () + { + return document[prefix + 'Hidden']; + }; + + hiddenVar = prefix + 'visibilitychange'; + } + + }); + } + + var onChange = function (event) + { + if (document.hidden || event.type === 'pause') + { + eventEmitter.emit('hidden'); + } + else + { + eventEmitter.emit('visible'); + } + }; + + if (hiddenVar) + { + document.addEventListener(hiddenVar, onChange, false); + } + + window.onblur = function () + { + eventEmitter.emit('blur'); + }; + + window.onfocus = function () + { + eventEmitter.emit('focus'); + }; + + // Automatically give the window focus unless config says otherwise + if (window.focus && game.config.autoFocus) + { + window.focus(); + + game.canvas.addEventListener('mousedown', function () + { + window.focus(); + }, { passive: true }); + } + + if (game.canvas) + { + game.canvas.onmouseout = function () + { + game.isOver = false; + eventEmitter.emit('mouseout'); + }; + + game.canvas.onmouseover = function () + { + game.isOver = true; + eventEmitter.emit('mouseover'); + }; + } +}; + +module.exports = VisibilityHandler; + + +/***/ }), +/* 950 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetValue = __webpack_require__(4); +var NOOP = __webpack_require__(2); +var RequestAnimationFrame = __webpack_require__(377); + +// Frame Rate config +// fps: { +// min: 10, +// target: 60, +// forceSetTimeOut: false, +// deltaHistory: 10, +// panicMax: 120 +// } + +// http://www.testufo.com/#test=animation-time-graph + +/** + * @callback TimeStepCallback + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} average - The Delta Average. + * @param {number} interpolation - Interpolation - how far between what is expected and where we are? + */ + +/** + * @classdesc + * [description] + * + * @class TimeStep + * @memberof Phaser.Boot + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance that owns this Time Step. + * @param {FPSConfig} config + */ +var TimeStep = new Class({ + + initialize: + + function TimeStep (game, config) + { + /** + * A reference to the Phaser.Game instance. + * + * @name Phaser.Boot.TimeStep#game + * @type {Phaser.Game} + * @readonly + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#raf + * @type {Phaser.DOM.RequestAnimationFrame} + * @readonly + * @since 3.0.0 + */ + this.raf = new RequestAnimationFrame(); + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + * + * @name Phaser.Boot.TimeStep#started + * @type {boolean} + * @readonly + * @default false + * @since 3.0.0 + */ + this.started = false; + + /** + * A flag that is set once the TimeStep has started running and toggled when it stops. + * The difference between this value and `started` is that `running` is toggled when + * the TimeStep is sent to sleep, where-as `started` remains `true`, only changing if + * the TimeStep is actually stopped, not just paused. + * + * @name Phaser.Boot.TimeStep#running + * @type {boolean} + * @readonly + * @default false + * @since 3.0.0 + */ + this.running = false; + + /** + * The minimum fps rate you want the Time Step to run at. + * + * @name Phaser.Boot.TimeStep#minFps + * @type {integer} + * @default 5 + * @since 3.0.0 + */ + this.minFps = GetValue(config, 'min', 5); + + /** + * The target fps rate for the Time Step to run at. + * + * Setting this value will not actually change the speed at which the browser runs, that is beyond + * the control of Phaser. Instead, it allows you to determine performance issues and if the Time Step + * is spiraling out of control. + * + * @name Phaser.Boot.TimeStep#targetFps + * @type {integer} + * @default 60 + * @since 3.0.0 + */ + this.targetFps = GetValue(config, 'target', 60); + + /** + * The minFps value in ms. + * Defaults to 200ms between frames (i.e. super slow!) + * + * @name Phaser.Boot.TimeStep#_min + * @type {number} + * @private + * @since 3.0.0 + */ + this._min = 1000 / this.minFps; + + /** + * The targetFps value in ms. + * Defaults to 16.66ms between frames (i.e. normal) + * + * @name Phaser.Boot.TimeStep#_target + * @type {number} + * @private + * @since 3.0.0 + */ + this._target = 1000 / this.targetFps; + + /** + * An exponential moving average of the frames per second. + * + * @name Phaser.Boot.TimeStep#actualFps + * @type {integer} + * @readonly + * @default 60 + * @since 3.0.0 + */ + this.actualFps = this.targetFps; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#nextFpsUpdate + * @type {integer} + * @readonly + * @default 0 + * @since 3.0.0 + */ + this.nextFpsUpdate = 0; + + /** + * The number of frames processed this second. + * + * @name Phaser.Boot.TimeStep#framesThisSecond + * @type {integer} + * @readonly + * @default 0 + * @since 3.0.0 + */ + this.framesThisSecond = 0; + + /** + * A callback to be invoked each time the Time Step steps. + * + * @name Phaser.Boot.TimeStep#callback + * @type {TimeStepCallback} + * @default NOOP + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * You can force the Time Step to use Set Timeout instead of Request Animation Frame by setting + * the `forceSetTimeOut` property to `true` in the Game Configuration object. It cannot be changed at run-time. + * + * @name Phaser.Boot.TimeStep#forceSetTimeOut + * @type {boolean} + * @readonly + * @default false + * @since 3.0.0 + */ + this.forceSetTimeOut = GetValue(config, 'forceSetTimeOut', false); + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#time + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.time = 0; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#startTime + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.startTime = 0; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#lastTime + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.lastTime = 0; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#frame + * @type {integer} + * @readonly + * @default 0 + * @since 3.0.0 + */ + this.frame = 0; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#inFocus + * @type {boolean} + * @readonly + * @default true + * @since 3.0.0 + */ + this.inFocus = true; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#_pauseTime + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._pauseTime = 0; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#_coolDown + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._coolDown = 0; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#delta + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.delta = 0; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#deltaIndex + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.deltaIndex = 0; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#deltaHistory + * @type {integer[]} + * @since 3.0.0 + */ + this.deltaHistory = []; + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#deltaSmoothingMax + * @type {integer} + * @default 10 + * @since 3.0.0 + */ + this.deltaSmoothingMax = GetValue(config, 'deltaHistory', 10); + + /** + * [description] + * + * @name Phaser.Boot.TimeStep#panicMax + * @type {integer} + * @default 120 + * @since 3.0.0 + */ + this.panicMax = GetValue(config, 'panicMax', 120); + + /** + * The actual elapsed time in ms between one update and the next. + * Unlike with `delta` no smoothing, capping, or averaging is applied to this value. + * So please be careful when using this value in calculations. + * + * @name Phaser.Boot.TimeStep#rawDelta + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rawDelta = 0; + }, + + /** + * Called when the DOM window.onBlur event triggers. + * + * @method Phaser.Boot.TimeStep#blur + * @since 3.0.0 + */ + blur: function () + { + this.inFocus = false; + }, + + /** + * Called when the DOM window.onFocus event triggers. + * + * @method Phaser.Boot.TimeStep#focus + * @since 3.0.0 + */ + focus: function () + { + this.inFocus = true; + + this.resetDelta(); + }, + + /** + * Called when the visibility API says the game is 'hidden' (tab switch out of view, etc) + * + * @method Phaser.Boot.TimeStep#pause + * @since 3.0.0 + */ + pause: function () + { + this._pauseTime = window.performance.now(); + }, + + /** + * Called when the visibility API says the game is 'visible' again (tab switch back into view, etc) + * + * @method Phaser.Boot.TimeStep#resume + * @since 3.0.0 + */ + resume: function () + { + this.resetDelta(); + + this.startTime += this.time - this._pauseTime; + }, + + /** + * [description] + * + * @method Phaser.Boot.TimeStep#resetDelta + * @since 3.0.0 + */ + resetDelta: function () + { + var now = window.performance.now(); + + this.time = now; + this.lastTime = now; + this.nextFpsUpdate = now + 1000; + this.framesThisSecond = 0; + this.frame = 0; + + // Pre-populate smoothing array + + for (var i = 0; i < this.deltaSmoothingMax; i++) + { + this.deltaHistory[i] = Math.min(this._target, this.deltaHistory[i]); + } + + this.delta = 0; + this.deltaIndex = 0; + + this._coolDown = this.panicMax; + }, + + /** + * Starts the Time Step running, if it is not already doing so. + * Called automatically by the Game Boot process. + * + * @method Phaser.Boot.TimeStep#start + * @since 3.0.0 + * + * @param {TimeStepCallback} callback - The callback to be invoked each time the Time Step steps. + */ + start: function (callback) + { + if (this.started) + { + return this; + } + + this.started = true; + this.running = true; + + for (var i = 0; i < this.deltaSmoothingMax; i++) + { + this.deltaHistory[i] = this._target; + } + + this.resetDelta(); + + this.startTime = window.performance.now(); + + this.callback = callback; + + this.raf.start(this.step.bind(this), this.forceSetTimeOut); + }, + + /** + * The main step method. This is called each time the browser updates, either by Request Animation Frame, + * or by Set Timeout. It is responsible for calculating the delta values, frame totals, cool down history and more. + * You generally should never call this method directly. + * + * @method Phaser.Boot.TimeStep#step + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + */ + step: function (time) + { + this.frame++; + + var before = time - this.lastTime; + + if (before < 0) + { + // Because, Chrome. + before = 0; + } + + this.rawDelta = before; + + var idx = this.deltaIndex; + var history = this.deltaHistory; + var max = this.deltaSmoothingMax; + + // delta time (time is in ms) + var dt = before; + + // When a browser switches tab, then comes back again, it takes around 10 frames before + // the delta time settles down so we employ a 'cooling down' period before we start + // trusting the delta values again, to avoid spikes flooding through our delta average + + if (this._coolDown > 0 || !this.inFocus) + { + this._coolDown--; + + dt = Math.min(dt, this._target); + } + + if (dt > this._min) + { + // Probably super bad start time or browser tab context loss, + // so use the last 'sane' dt value + + dt = history[idx]; + + // Clamp delta to min (in case history has become corrupted somehow) + dt = Math.min(dt, this._min); + } + + // Smooth out the delta over the previous X frames + + // add the delta to the smoothing array + history[idx] = dt; + + // adjusts the delta history array index based on the smoothing count + // this stops the array growing beyond the size of deltaSmoothingMax + this.deltaIndex++; + + if (this.deltaIndex > max) + { + this.deltaIndex = 0; + } + + // Delta Average + var avg = 0; + + // Loop the history array, adding the delta values together + + for (var i = 0; i < max; i++) + { + avg += history[i]; + } + + // Then divide by the array length to get the average delta + avg /= max; + + // Set as the world delta value + this.delta = avg; + + // Real-world timer advance + this.time += this.rawDelta; + + // Update the estimate of the frame rate, `fps`. Every second, the number + // of frames that occurred in that second are included in an exponential + // moving average of all frames per second, with an alpha of 0.25. This + // means that more recent seconds affect the estimated frame rate more than + // older seconds. + // + // When a browser window is NOT minimized, but is covered up (i.e. you're using + // another app which has spawned a window over the top of the browser), then it + // will start to throttle the raf callback time. It waits for a while, and then + // starts to drop the frame rate at 1 frame per second until it's down to just over 1fps. + // So if the game was running at 60fps, and the player opens a new window, then + // after 60 seconds (+ the 'buffer time') it'll be down to 1fps, so rafin'g at 1Hz. + // + // When they make the game visible again, the frame rate is increased at a rate of + // approx. 8fps, back up to 60fps (or the max it can obtain) + // + // There is no easy way to determine if this drop in frame rate is because the + // browser is throttling raf, or because the game is struggling with performance + // because you're asking it to do too much on the device. + + if (time > this.nextFpsUpdate) + { + // Compute the new exponential moving average with an alpha of 0.25. + this.actualFps = 0.25 * this.framesThisSecond + 0.75 * this.actualFps; + this.nextFpsUpdate = time + 1000; + this.framesThisSecond = 0; + } + + this.framesThisSecond++; + + // Interpolation - how far between what is expected and where we are? + var interpolation = avg / this._target; + + this.callback(time, avg, interpolation); + + // Shift time value over + this.lastTime = time; + }, + + /** + * Manually calls TimeStep.step, passing in the performance.now value to it. + * + * @method Phaser.Boot.TimeStep#tick + * @since 3.0.0 + */ + tick: function () + { + this.step(window.performance.now()); + }, + + /** + * Sends the TimeStep to sleep, stopping Request Animation Frame (or SetTimeout) and toggling the `running` flag to false. + * + * @method Phaser.Boot.TimeStep#sleep + * @since 3.0.0 + */ + sleep: function () + { + if (this.running) + { + this.raf.stop(); + + this.running = false; + } + }, + + /** + * Wakes-up the TimeStep, restarting Request Animation Frame (or SetTimeout) and toggling the `running` flag to true. + * The `seamless` argument controls if the wake-up should adjust the start time or not. + * + * @method Phaser.Boot.TimeStep#wake + * @since 3.0.0 + * + * @param {boolean} [seamless=false] - Adjust the startTime based on the lastTime values. + */ + wake: function (seamless) + { + if (this.running) + { + this.sleep(); + } + else if (seamless) + { + this.startTime += -this.lastTime + (this.lastTime = window.performance.now()); + } + + this.raf.start(this.step.bind(this), this.useRAF); + + this.running = true; + + this.step(window.performance.now()); + }, + + /** + * Stops the TimeStep running. + * + * @method Phaser.Boot.TimeStep#stop + * @since 3.0.0 + * + * @return {Phaser.Boot.TimeStep} The TimeStep object. + */ + stop: function () + { + this.running = false; + this.started = false; + + this.raf.stop(); + + return this; + }, + + /** + * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null + * any objects. + * + * @method Phaser.Boot.TimeStep#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.callback = NOOP; + + this.raf = null; + this.game = null; + } + +}); + +module.exports = TimeStep; + + +/***/ }), +/* 951 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var imageHeight = 0; + +/** + * @function addFrame + * @private + * @since 3.0.0 + */ +var addFrame = function (texture, sourceIndex, name, frame) +{ + // The frame values are the exact coordinates to cut the frame out of the atlas from + + var y = imageHeight - frame.y - frame.height; + + texture.add(name, sourceIndex, frame.x, y, frame.width, frame.height); + + // These are the original (non-trimmed) sprite values + /* + if (src.trimmed) + { + newFrame.setTrim( + src.sourceSize.w, + src.sourceSize.h, + src.spriteSourceSize.x, + src.spriteSourceSize.y, + src.spriteSourceSize.w, + src.spriteSourceSize.h + ); + } + */ +}; + +/** + * Parses a Unity YAML File and creates Frames in the Texture. + * For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html + * + * @function Phaser.Textures.Parsers.UnityYAML + * @memberof Phaser.Textures.Parsers + * @private + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {object} yaml - The YAML data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var UnityYAML = function (texture, sourceIndex, yaml) +{ + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + imageHeight = source.height; + + var data = yaml.split('\n'); + + var lineRegExp = /^[ ]*(- )*(\w+)+[: ]+(.*)/; + + var prevSprite = ''; + var currentSprite = ''; + var rect = { x: 0, y: 0, width: 0, height: 0 }; + + // var pivot = { x: 0, y: 0 }; + // var border = { x: 0, y: 0, z: 0, w: 0 }; + + for (var i = 0; i < data.length; i++) + { + var results = data[i].match(lineRegExp); + + if (!results) + { + continue; + } + + var isList = (results[1] === '- '); + var key = results[2]; + var value = results[3]; + + if (isList) + { + if (currentSprite !== prevSprite) + { + addFrame(texture, sourceIndex, currentSprite, rect); + + prevSprite = currentSprite; + } + + rect = { x: 0, y: 0, width: 0, height: 0 }; + } + + if (key === 'name') + { + // Start new list + currentSprite = value; + continue; + } + + switch (key) + { + case 'x': + case 'y': + case 'width': + case 'height': + rect[key] = parseInt(value, 10); + break; + + // case 'pivot': + // pivot = eval('var obj = ' + value); + // break; + + // case 'border': + // border = eval('var obj = ' + value); + // break; + } + } + + if (currentSprite !== prevSprite) + { + addFrame(texture, sourceIndex, currentSprite, rect); + } + + return texture; +}; + +module.exports = UnityYAML; + +/* +Example data: + +TextureImporter: + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + spriteSheet: + sprites: + - name: asteroids_0 + rect: + serializedVersion: 2 + x: 5 + y: 328 + width: 65 + height: 82 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + - name: asteroids_1 + rect: + serializedVersion: 2 + x: 80 + y: 322 + width: 53 + height: 88 + alignment: 0 + pivot: {x: 0, y: 0} + border: {x: 0, y: 0, z: 0, w: 0} + spritePackingTag: Asteroids +*/ + + +/***/ }), +/* 952 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(1); + +/** + * Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @function Phaser.Textures.Parsers.SpriteSheetFromAtlas + * @memberof Phaser.Textures.Parsers + * @private + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {Phaser.Textures.Frame} frame - The Frame that contains the Sprite Sheet. + * @param {object} config - An object describing how to parse the Sprite Sheet. + * @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet. + * @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided. + * @param {number} [config.startFrame=0] - [description] + * @param {number} [config.endFrame=-1] - [description] + * @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. + * @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var SpriteSheetFromAtlas = function (texture, frame, config) +{ + var frameWidth = GetFastValue(config, 'frameWidth', null); + var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); + + // If missing we can't proceed + if (!frameWidth) + { + throw new Error('TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.'); + } + + // Add in a __BASE entry (for the entire atlas) + // var source = texture.source[sourceIndex]; + // texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + var startFrame = GetFastValue(config, 'startFrame', 0); + var endFrame = GetFastValue(config, 'endFrame', -1); + var margin = GetFastValue(config, 'margin', 0); + var spacing = GetFastValue(config, 'spacing', 0); + + var x = frame.cutX; + var y = frame.cutY; + + var cutWidth = frame.cutWidth; + var cutHeight = frame.cutHeight; + var sheetWidth = frame.realWidth; + var sheetHeight = frame.realHeight; + + var row = Math.floor((sheetWidth - margin + spacing) / (frameWidth + spacing)); + var column = Math.floor((sheetHeight - margin + spacing) / (frameHeight + spacing)); + var total = row * column; + + // trim offsets + + var leftPad = frame.x; + var leftWidth = frameWidth - leftPad; + + var rightWidth = frameWidth - ((sheetWidth - cutWidth) - leftPad); + + var topPad = frame.y; + var topHeight = frameHeight - topPad; + + var bottomHeight = frameHeight - ((sheetHeight - cutHeight) - topPad); + + // console.log('x / y', x, y); + // console.log('cutW / H', cutWidth, cutHeight); + // console.log('sheetW / H', sheetWidth, sheetHeight); + // console.log('row', row, 'column', column, 'total', total); + // console.log('LW', leftWidth, 'RW', rightWidth, 'TH', topHeight, 'BH', bottomHeight); + + if (startFrame > total || startFrame < -total) + { + startFrame = 0; + } + + if (startFrame < 0) + { + // Allow negative skipframes. + startFrame = total + startFrame; + } + + if (endFrame !== -1) + { + total = startFrame + (endFrame + 1); + } + + var sheetFrame; + var frameX = margin; + var frameY = margin; + var frameIndex = 0; + var sourceIndex = frame.sourceIndex; + + for (var sheetY = 0; sheetY < column; sheetY++) + { + var topRow = (sheetY === 0); + var bottomRow = (sheetY === column - 1); + + for (var sheetX = 0; sheetX < row; sheetX++) + { + var leftRow = (sheetX === 0); + var rightRow = (sheetX === row - 1); + + sheetFrame = texture.add(frameIndex, sourceIndex, x + frameX, y + frameY, frameWidth, frameHeight); + + if (leftRow || topRow || rightRow || bottomRow) + { + var destX = (leftRow) ? leftPad : 0; + var destY = (topRow) ? topPad : 0; + var destWidth = frameWidth; + var destHeight = frameHeight; + + if (leftRow) + { + destWidth = leftWidth; + } + else if (rightRow) + { + destWidth = rightWidth; + } + + if (topRow) + { + destHeight = topHeight; + } + else if (bottomRow) + { + destHeight = bottomHeight; + } + + sheetFrame.cutWidth = destWidth; + sheetFrame.cutHeight = destHeight; + + sheetFrame.setTrim(frameWidth, frameHeight, destX, destY, destWidth, destHeight); + } + + frameX += spacing; + + if (leftRow) + { + frameX += leftWidth; + } + else if (rightRow) + { + frameX += rightRow; + } + else + { + frameX += frameWidth; + } + + frameIndex++; + } + + frameX = margin; + frameY += spacing; + + if (topRow) + { + frameY += topHeight; + } + else if (bottomRow) + { + frameY += bottomHeight; + } + else + { + frameY += frameHeight; + } + } + + return texture; +}; + +module.exports = SpriteSheetFromAtlas; + + +/***/ }), +/* 953 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(1); + +/** + * Parses a Sprite Sheet and adds the Frames to the Texture. + * + * In Phaser terminology a Sprite Sheet is a texture containing different frames, but each frame is the exact + * same size and cannot be trimmed or rotated. + * + * @function Phaser.Textures.Parsers.SpriteSheet + * @memberof Phaser.Textures.Parsers + * @private + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {object} config - An object describing how to parse the Sprite Sheet. + * @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet. + * @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided. + * @param {number} [config.startFrame=0] - [description] + * @param {number} [config.endFrame=-1] - [description] + * @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. + * @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var SpriteSheet = function (texture, sourceIndex, x, y, width, height, config) +{ + var frameWidth = GetFastValue(config, 'frameWidth', null); + var frameHeight = GetFastValue(config, 'frameHeight', frameWidth); + + // If missing we can't proceed + if (frameWidth === null) + { + throw new Error('TextureManager.SpriteSheet: Invalid frameWidth given.'); + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + var startFrame = GetFastValue(config, 'startFrame', 0); + var endFrame = GetFastValue(config, 'endFrame', -1); + var margin = GetFastValue(config, 'margin', 0); + var spacing = GetFastValue(config, 'spacing', 0); + + var row = Math.floor((width - margin + spacing) / (frameWidth + spacing)); + var column = Math.floor((height - margin + spacing) / (frameHeight + spacing)); + var total = row * column; + + if (total === 0) + { + console.warn('SpriteSheet frame dimensions will result in zero frames.'); + } + + if (startFrame > total || startFrame < -total) + { + startFrame = 0; + } + + if (startFrame < 0) + { + // Allow negative skipframes. + startFrame = total + startFrame; + } + + if (endFrame !== -1) + { + total = startFrame + (endFrame + 1); + } + + var fx = margin; + var fy = margin; + var ax = 0; + var ay = 0; + + for (var i = 0; i < total; i++) + { + ax = 0; + ay = 0; + + var w = fx + frameWidth; + var h = fy + frameHeight; + + if (w > width) + { + ax = w - width; + } + + if (h > height) + { + ay = h - height; + } + + texture.add(i, sourceIndex, x + fx, y + fy, frameWidth - ax, frameHeight - ay); + + fx += frameWidth + spacing; + + if (fx + frameWidth > width) + { + fx = margin; + fy += frameHeight + spacing; + } + } + + return texture; +}; + +module.exports = SpriteSheet; + + +/***/ }), +/* 954 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(69); + +/** + * Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. + * JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames. + * + * @function Phaser.Textures.Parsers.JSONHash + * @memberof Phaser.Textures.Parsers + * @private + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {object} json - The JSON data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var JSONHash = function (texture, sourceIndex, json) +{ + // Malformed? + if (!json['frames']) + { + console.warn('Invalid Texture Atlas JSON Hash given, missing \'frames\' Object'); + return; + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + // By this stage frames is a fully parsed Object + var frames = json['frames']; + var newFrame; + + for (var key in frames) + { + var src = frames[key]; + + // The frame values are the exact coordinates to cut the frame out of the atlas from + newFrame = texture.add(key, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); + + // These are the original (non-trimmed) sprite values + if (src.trimmed) + { + newFrame.setTrim( + src.sourceSize.w, + src.sourceSize.h, + src.spriteSourceSize.x, + src.spriteSourceSize.y, + src.spriteSourceSize.w, + src.spriteSourceSize.h + ); + } + + if (src.rotated) + { + newFrame.rotated = true; + newFrame.updateUVsInverted(); + } + + // Copy over any extra data + newFrame.customData = Clone(src); + } + + // Copy over any additional data that was in the JSON to Texture.customData + for (var dataKey in json) + { + if (dataKey === 'frames') + { + continue; + } + + if (Array.isArray(json[dataKey])) + { + texture.customData[dataKey] = json[dataKey].slice(0); + } + else + { + texture.customData[dataKey] = json[dataKey]; + } + } + + return texture; +}; + +module.exports = JSONHash; + + +/***/ }), +/* 955 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(69); + +/** + * Parses a Texture Atlas JSON Array and adds the Frames to the Texture. + * JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames. + * + * @function Phaser.Textures.Parsers.JSONArray + * @memberof Phaser.Textures.Parsers + * @private + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {object} json - The JSON data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var JSONArray = function (texture, sourceIndex, json) +{ + // Malformed? + if (!json['frames'] && !json['textures']) + { + console.warn('Invalid Texture Atlas JSON Array'); + return; + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + // By this stage frames is a fully parsed array + var frames = (Array.isArray(json.textures)) ? json.textures[sourceIndex].frames : json.frames; + + var newFrame; + + for (var i = 0; i < frames.length; i++) + { + var src = frames[i]; + + // The frame values are the exact coordinates to cut the frame out of the atlas from + newFrame = texture.add(src.filename, sourceIndex, src.frame.x, src.frame.y, src.frame.w, src.frame.h); + + // These are the original (non-trimmed) sprite values + if (src.trimmed) + { + newFrame.setTrim( + src.sourceSize.w, + src.sourceSize.h, + src.spriteSourceSize.x, + src.spriteSourceSize.y, + src.spriteSourceSize.w, + src.spriteSourceSize.h + ); + } + + if (src.rotated) + { + newFrame.rotated = true; + newFrame.updateUVsInverted(); + } + + if (src.anchor) + { + newFrame.customPivot = true; + newFrame.pivotX = src.anchor.x; + newFrame.pivotY = src.anchor.y; + } + + // Copy over any extra data + newFrame.customData = Clone(src); + } + + // Copy over any additional data that was in the JSON to Texture.customData + for (var dataKey in json) + { + if (dataKey === 'frames') + { + continue; + } + + if (Array.isArray(json[dataKey])) + { + texture.customData[dataKey] = json[dataKey].slice(0); + } + else + { + texture.customData[dataKey] = json[dataKey]; + } + } + + return texture; +}; + +module.exports = JSONArray; + + +/***/ }), +/* 956 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds an Image Element to a Texture. + * + * @function Phaser.Textures.Parsers.Image + * @memberof Phaser.Textures.Parsers + * @private + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var Image = function (texture, sourceIndex) +{ + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + return texture; +}; + +module.exports = Image; + + +/***/ }), +/* 957 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Adds a Canvas Element to a Texture. + * + * @function Phaser.Textures.Parsers.Canvas + * @memberof Phaser.Textures.Parsers + * @private + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var Canvas = function (texture, sourceIndex) +{ + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + return texture; +}; + +module.exports = Canvas; + + +/***/ }), +/* 958 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Parses an XML Texture Atlas object and adds all the Frames into a Texture. + * + * @function Phaser.Textures.Parsers.AtlasXML + * @memberof Phaser.Textures.Parsers + * @private + * @since 3.7.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture to add the Frames to. + * @param {integer} sourceIndex - The index of the TextureSource. + * @param {*} xml - The XML data. + * + * @return {Phaser.Textures.Texture} The Texture modified by this parser. + */ +var AtlasXML = function (texture, sourceIndex, xml) +{ + // Malformed? + if (!xml.getElementsByTagName('TextureAtlas')) + { + console.warn('Invalid Texture Atlas XML given'); + return; + } + + // Add in a __BASE entry (for the entire atlas) + var source = texture.source[sourceIndex]; + + texture.add('__BASE', sourceIndex, 0, 0, source.width, source.height); + + // By this stage frames is a fully parsed array + var frames = xml.getElementsByTagName('SubTexture'); + + var newFrame; + + for (var i = 0; i < frames.length; i++) + { + var frame = frames[i].attributes; + + var name = frame.name.value; + var x = parseInt(frame.x.value, 10); + var y = parseInt(frame.y.value, 10); + var width = parseInt(frame.width.value, 10); + var height = parseInt(frame.height.value, 10); + + // The frame values are the exact coordinates to cut the frame out of the atlas from + newFrame = texture.add(name, sourceIndex, x, y, width, height); + + // These are the original (non-trimmed) sprite values + if (frame.frameX) + { + var frameX = Math.abs(parseInt(frame.frameX.value, 10)); + var frameY = Math.abs(parseInt(frame.frameY.value, 10)); + var frameWidth = parseInt(frame.frameWidth.value, 10); + var frameHeight = parseInt(frame.frameHeight.value, 10); + + newFrame.setTrim( + width, + height, + frameX, + frameY, + frameWidth, + frameHeight + ); + } + } + + return texture; +}; + +module.exports = AtlasXML; + + +/***/ }), +/* 959 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Color = __webpack_require__(41); +var IsSizePowerOfTwo = __webpack_require__(127); +var Texture = __webpack_require__(181); + +/** + * @classdesc + * A Canvas Texture is a special kind of Texture that is backed by an HTML Canvas Element as its source. + * + * You can use the properties of this texture to draw to the canvas element directly, using all of the standard + * canvas operations available in the browser. Any Game Object can be given this texture and will render with it. + * + * Note: When running under WebGL the Canvas Texture needs to re-generate its base WebGLTexture and reupload it to + * the GPU every time you modify it, otherwise the changes you make to this texture will not be visible. To do this + * you should call `CanvasTexture.refresh()` once you are finished with your changes to the canvas. Try and keep + * this to a minimum, especially on large canvas sizes, or you may inadvertently thrash the GPU by constantly uploading + * texture data to it. This restriction does not apply if using the Canvas Renderer. + * + * It starts with only one frame that covers the whole of the canvas. You can add further frames, that specify + * sections of the canvas using the `add` method. + * + * Should you need to resize the canvas use the `setSize` method so that it accurately updates all of the underlying + * texture data as well. Forgetting to do this (i.e. by changing the canvas size directly from your code) could cause + * graphical errors. + * + * @class CanvasTexture + * @extends Phaser.Textures.Texture + * @memberof Phaser.Textures + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Textures.CanvasTexture} manager - A reference to the Texture Manager this Texture belongs to. + * @param {string} key - The unique string-based key of this Texture. + * @param {HTMLCanvasElement} source - The canvas element that is used as the base of this texture. + * @param {integer} width - The width of the canvas. + * @param {integer} height - The height of the canvas. + */ +var CanvasTexture = new Class({ + + Extends: Texture, + + initialize: + + function CanvasTexture (manager, key, source, width, height) + { + Texture.call(this, manager, key, source, width, height); + + this.add('__BASE', 0, 0, 0, width, height); + + /** + * A reference to the Texture Source of this Canvas. + * + * @name Phaser.Textures.CanvasTexture#_source + * @type {Phaser.Textures.TextureSource} + * @private + * @since 3.7.0 + */ + this._source = this.frames['__BASE'].source; + + /** + * The source Canvas Element. + * + * @name Phaser.Textures.CanvasTexture#canvas + * @readonly + * @type {HTMLCanvasElement} + * @since 3.7.0 + */ + this.canvas = this._source.image; + + /** + * The 2D Canvas Rendering Context. + * + * @name Phaser.Textures.CanvasTexture#context + * @readonly + * @type {CanvasRenderingContext2D} + * @since 3.7.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * The width of the Canvas. + * This property is read-only, if you wish to change it use the `setSize` method. + * + * @name Phaser.Textures.CanvasTexture#width + * @readonly + * @type {integer} + * @since 3.7.0 + */ + this.width = width; + + /** + * The height of the Canvas. + * This property is read-only, if you wish to change it use the `setSize` method. + * + * @name Phaser.Textures.CanvasTexture#height + * @readonly + * @type {integer} + * @since 3.7.0 + */ + this.height = height; + + /** + * The context image data. + * Use the `update` method to populate this when the canvas changes. + * + * @name Phaser.Textures.CanvasTexture#imageData + * @type {ImageData} + * @since 3.13.0 + */ + this.imageData = this.context.getImageData(0, 0, width, height); + + /** + * A Uint8ClampedArray view into the `buffer`. + * Use the `update` method to populate this when the canvas changes. + * Note that this is unavailable in some browsers, such as Epic Browser, due to their security restrictions. + * + * @name Phaser.Textures.CanvasTexture#data + * @type {Uint8ClampedArray} + * @since 3.13.0 + */ + this.data = null; + + if (this.imageData) + { + this.data = this.imageData.data; + } + + /** + * An Uint32Array view into the `buffer`. + * + * @name Phaser.Textures.CanvasTexture#pixels + * @type {Uint32Array} + * @since 3.13.0 + */ + this.pixels = null; + + /** + * An ArrayBuffer the same size as the context ImageData. + * + * @name Phaser.Textures.CanvasTexture#buffer + * @type {ArrayBuffer} + * @since 3.13.0 + */ + this.buffer; + + if (this.data) + { + if (this.imageData.data.buffer) + { + this.buffer = this.imageData.data.buffer; + this.pixels = new Uint32Array(this.buffer); + } + else if (window.ArrayBuffer) + { + this.buffer = new ArrayBuffer(this.imageData.data.length); + this.pixels = new Uint32Array(this.buffer); + } + else + { + this.pixels = this.imageData.data; + } + } + }, + + /** + * This re-creates the `imageData` from the current context. + * It then re-builds the ArrayBuffer, the `data` Uint8ClampedArray reference and the `pixels` Int32Array. + * + * Warning: This is a very expensive operation, so use it sparingly. + * + * @method Phaser.Textures.CanvasTexture#update + * @since 3.13.0 + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + update: function () + { + this.imageData = this.context.getImageData(0, 0, this.width, this.height); + + this.data = this.imageData.data; + + if (this.imageData.data.buffer) + { + this.buffer = this.imageData.data.buffer; + this.pixels = new Uint32Array(this.buffer); + } + else if (window.ArrayBuffer) + { + this.buffer = new ArrayBuffer(this.imageData.data.length); + this.pixels = new Uint32Array(this.buffer); + } + else + { + this.pixels = this.imageData.data; + } + + return this; + }, + + /** + * Draws the given Image or Canvas element to this CanvasTexture, then updates the internal + * ImageData buffer and arrays. + * + * @method Phaser.Textures.CanvasTexture#draw + * @since 3.13.0 + * + * @param {integer} x - The x coordinate to draw the source at. + * @param {integer} y - The y coordinate to draw the source at. + * @param {(HTMLImageElement|HTMLCanvasElement)} source - The element to draw to this canvas. + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + draw: function (x, y, source) + { + this.context.drawImage(source, x, y); + + return this.update(); + }, + + /** + * Get the color of a specific pixel from this texture and store it in a Color object. + * + * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * + * @method Phaser.Textures.CanvasTexture#getPixel + * @since 3.13.0 + * + * @param {integer} x - The x coordinate of the pixel to be set. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} y - The y coordinate of the pixel to be set. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {Phaser.Display.Color} [out] - An object into which 4 properties will be set: r, g, b and a. If not provided a Color object will be created. + * + * @return {Phaser.Display.Color} An object with the red, green, blue and alpha values set in the r, g, b and a properties. + */ + getPixel: function (x, y, out) + { + if (!out) + { + out = new Color(); + } + + var index = ~~(x + (y * this.width)); + + index *= 4; + + var r = this.data[index]; + var g = this.data[++index]; + var b = this.data[++index]; + var a = this.data[++index]; + + return out.setTo(r, g, b, a); + }, + + /** + * This should be called manually if you are running under WebGL. + * It will refresh the WebGLTexture from the Canvas source. Only call this if you know that the + * canvas has changed, as there is a significant GPU texture allocation cost involved in doing so. + * + * @method Phaser.Textures.CanvasTexture#refresh + * @since 3.7.0 + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + refresh: function () + { + this._source.update(); + + return this; + }, + + /** + * Gets the Canvas Element. + * + * @method Phaser.Textures.CanvasTexture#getCanvas + * @since 3.7.0 + * + * @return {HTMLCanvasElement} The Canvas DOM element this texture is using. + */ + getCanvas: function () + { + return this.canvas; + }, + + /** + * Gets the 2D Canvas Rendering Context. + * + * @method Phaser.Textures.CanvasTexture#getContext + * @since 3.7.0 + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context this texture is using. + */ + getContext: function () + { + return this.context; + }, + + /** + * Clears this Canvas Texture, resetting it back to transparent. + * + * @method Phaser.Textures.CanvasTexture#clear + * @since 3.7.0 + * + * @return {Phaser.Textures.CanvasTexture} The Canvas Texture. + */ + clear: function () + { + this.context.clearRect(0, 0, this.width, this.height); + + return this.update(); + }, + + /** + * Changes the size of this Canvas Texture. + * + * @method Phaser.Textures.CanvasTexture#setSize + * @since 3.7.0 + * + * @param {integer} width - The new width of the Canvas. + * @param {integer} [height] - The new height of the Canvas. If not given it will use the width as the height. + * + * @return {Phaser.Textures.CanvasTexture} The Canvas Texture. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + if (width !== this.width || height !== this.height) + { + // Update the Canvas + this.canvas.width = width; + this.canvas.height = height; + + // Update the Texture Source + this._source.width = width; + this._source.height = height; + this._source.isPowerOf2 = IsSizePowerOfTwo(width, height); + + // Update the Frame + this.frames['__BASE'].setSize(width, height, 0, 0); + + this.refresh(); + } + + return this; + } + +}); + +module.exports = CanvasTexture; + + +/***/ }), +/* 960 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// These properties get injected into the Scene and map to local systems +// The map value is the property that is injected into the Scene, the key is the Scene.Systems reference. +// These defaults can be modified via the Scene config object +// var config = { +// map: { +// add: 'makeStuff', +// load: 'loader' +// } +// }; + +var InjectionMap = { + + game: 'game', + + anims: 'anims', + cache: 'cache', + plugins: 'plugins', + registry: 'registry', + sound: 'sound', + textures: 'textures', + + events: 'events', + cameras: 'cameras', + add: 'add', + make: 'make', + scenePlugin: 'scene', + displayList: 'children', + lights: 'lights', + + data: 'data', + input: 'input', + load: 'load', + time: 'time', + tweens: 'tweens', + + arcadePhysics: 'physics', + impactPhysics: 'impact', + matterPhysics: 'matter' + +}; + +if (false) +{} + +if (true) +{ + InjectionMap.facebook = 'facebook'; +} + +module.exports = InjectionMap; + + +/***/ }), +/* 961 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(1); + +/** + * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. + * + * @function Phaser.Scenes.GetScenePlugins + * @since 3.0.0 + * + * @param {Phaser.Scenes.Systems} sys - [description] + * + * @return {array} [description] + */ +var GetScenePlugins = function (sys) +{ + var defaultPlugins = sys.plugins.getDefaultScenePlugins(); + + var scenePlugins = GetFastValue(sys.settings, 'plugins', false); + + // Scene Plugins always override Default Plugins + if (Array.isArray(scenePlugins)) + { + return scenePlugins; + } + else if (defaultPlugins) + { + return defaultPlugins; + } + else + { + // No default plugins or plugins in this scene + return []; + } +}; + +module.exports = GetScenePlugins; + + +/***/ }), +/* 962 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(1); +var UppercaseFirst = __webpack_require__(356); + +/** + * Builds an array of which physics plugins should be activated for the given Scene. + * + * @function Phaser.Scenes.GetPhysicsPlugins + * @since 3.0.0 + * + * @param {Phaser.Scenes.Systems} sys - The scene system to get the physics systems of. + * + * @return {array} An array of Physics systems to start for this Scene. + */ +var GetPhysicsPlugins = function (sys) +{ + var defaultSystem = sys.game.config.defaultPhysicsSystem; + var sceneSystems = GetFastValue(sys.settings, 'physics', false); + + if (!defaultSystem && !sceneSystems) + { + // No default physics system or systems in this scene + return; + } + + // Let's build the systems array + var output = []; + + if (defaultSystem) + { + output.push(UppercaseFirst(defaultSystem + 'Physics')); + } + + if (sceneSystems) + { + for (var key in sceneSystems) + { + key = UppercaseFirst(key.concat('Physics')); + + if (output.indexOf(key) === -1) + { + output.push(key); + } + } + } + + // An array of Physics systems to start for this Scene + return output; +}; + +module.exports = GetPhysicsPlugins; + + +/***/ }), +/* 963 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(28); + +/** + * Called automatically by Phaser.Game and responsible for creating the console.log debug header. + * + * You can customize or disable the header via the Game Config object. + * + * @function Phaser.Boot.DebugHeader + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. + */ +var DebugHeader = function (game) +{ + var config = game.config; + + if (config.hideBanner) + { + return; + } + + var renderType = 'WebGL'; + + if (config.renderType === CONST.CANVAS) + { + renderType = 'Canvas'; + } + else if (config.renderType === CONST.HEADLESS) + { + renderType = 'Headless'; + } + + var audioConfig = config.audio; + var deviceAudio = game.device.audio; + + var audioType; + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + audioType = 'Web Audio'; + } + else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + audioType = 'No Audio'; + } + else + { + audioType = 'HTML5 Audio'; + } + + if (!game.device.browser.ie) + { + var c = ''; + var args = [ c ]; + + if (Array.isArray(config.bannerBackgroundColor)) + { + var lastColor; + + config.bannerBackgroundColor.forEach(function (color) + { + c = c.concat('%c '); + + args.push('background: ' + color); + + lastColor = color; + + }); + + // inject the text color + args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; + } + else + { + c = c.concat('%c '); + + args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); + } + + // URL link background color (always white) + args.push('background: #fff'); + + if (config.gameTitle) + { + c = c.concat(config.gameTitle); + + if (config.gameVersion) + { + c = c.concat(' v' + config.gameVersion); + } + + if (!config.hidePhaser) + { + c = c.concat(' / '); + } + } + + var fb = ( true) ? '-FB' : undefined; + + if (!config.hidePhaser) + { + c = c.concat('Phaser v' + CONST.VERSION + fb + ' (' + renderType + ' | ' + audioType + ')'); + } + + c = c.concat(' %c ' + config.gameURL); + + // Inject the new string back into the args array + args[0] = c; + + console.log.apply(console, args); + } + else if (window['console']) + { + console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); + } +}; + +module.exports = DebugHeader; + + +/***/ }), +/* 964 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_TEXTURE_TINT_VS', + '', + 'precision mediump float;', + '', + 'uniform mat4 uProjectionMatrix;', + 'uniform mat4 uViewMatrix;', + 'uniform mat4 uModelMatrix;', + '', + 'attribute vec2 inPosition;', + 'attribute vec2 inTexCoord;', + 'attribute float inTintEffect;', + 'attribute vec4 inTint;', + '', + 'varying vec2 outTexCoord;', + 'varying float outTintEffect;', + 'varying vec4 outTint;', + '', + 'void main ()', + '{', + ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', + '', + ' outTexCoord = inTexCoord;', + ' outTint = inTint;', + ' outTintEffect = inTintEffect;', + '}', + '', + '' +].join('\n'); + + +/***/ }), +/* 965 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_TEXTURE_TINT_FS', + '', + 'precision mediump float;', + '', + 'uniform sampler2D uMainSampler;', + '', + 'varying vec2 outTexCoord;', + 'varying float outTintEffect;', + 'varying vec4 outTint;', + '', + 'void main()', + '{', + ' vec4 texture = texture2D(uMainSampler, outTexCoord);', + ' vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);', + ' vec4 color = texture;', + '', + ' if (outTintEffect == 0.0)', + ' {', + ' // Multiply texture tint', + ' color = texture * texel;', + ' }', + ' else if (outTintEffect == 1.0)', + ' {', + ' // Solid color + texture alpha', + ' color.rgb = mix(texture.rgb, outTint.rgb * outTint.a, texture.a);', + ' color.a = texture.a * texel.a;', + ' }', + ' else if (outTintEffect == 2.0)', + ' {', + ' // Solid color, no texture', + ' color = texel;', + ' }', + '', + ' gl_FragColor = color;', + '}', + '' +].join('\n'); + + +/***/ }), +/* 966 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + + +/** + * Implements a model view projection matrices. + * Pipelines can implement this for doing 2D and 3D rendering. + */ + +var ModelViewProjection = { + + /** + * Dirty flag for checking if model matrix needs to be updated on GPU. + */ + modelMatrixDirty: false, + + /** + * Dirty flag for checking if view matrix needs to be updated on GPU. + */ + viewMatrixDirty: false, + + /** + * Dirty flag for checking if projection matrix needs to be updated on GPU. + */ + projectionMatrixDirty: false, + + /** + * Model matrix + */ + modelMatrix: null, + + /** + * View matrix + */ + viewMatrix: null, + + /** + * Projection matrix + */ + projectionMatrix: null, + + /** + * Initializes MVP matrices with an identity matrix + */ + mvpInit: function () + { + this.modelMatrixDirty = true; + this.viewMatrixDirty = true; + this.projectionMatrixDirty = true; + + this.modelMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.viewMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.projectionMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + /** + * If dirty flags are set then the matrices are uploaded to the GPU. + */ + mvpUpdate: function () + { + var program = this.program; + + if (this.modelMatrixDirty) + { + this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); + this.modelMatrixDirty = false; + } + + if (this.viewMatrixDirty) + { + this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); + this.viewMatrixDirty = false; + } + + if (this.projectionMatrixDirty) + { + this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); + this.projectionMatrixDirty = false; + } + + return this; + }, + + /** + * Loads an identity matrix to the model matrix + */ + modelIdentity: function () + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = 1; + modelMatrix[1] = 0; + modelMatrix[2] = 0; + modelMatrix[3] = 0; + modelMatrix[4] = 0; + modelMatrix[5] = 1; + modelMatrix[6] = 0; + modelMatrix[7] = 0; + modelMatrix[8] = 0; + modelMatrix[9] = 0; + modelMatrix[10] = 1; + modelMatrix[11] = 0; + modelMatrix[12] = 0; + modelMatrix[13] = 0; + modelMatrix[14] = 0; + modelMatrix[15] = 1; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Scale model matrix + */ + modelScale: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = modelMatrix[0] * x; + modelMatrix[1] = modelMatrix[1] * x; + modelMatrix[2] = modelMatrix[2] * x; + modelMatrix[3] = modelMatrix[3] * x; + modelMatrix[4] = modelMatrix[4] * y; + modelMatrix[5] = modelMatrix[5] * y; + modelMatrix[6] = modelMatrix[6] * y; + modelMatrix[7] = modelMatrix[7] * y; + modelMatrix[8] = modelMatrix[8] * z; + modelMatrix[9] = modelMatrix[9] * z; + modelMatrix[10] = modelMatrix[10] * z; + modelMatrix[11] = modelMatrix[11] * z; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Translate model matrix + */ + modelTranslate: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; + modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; + modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; + modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; + + this.modelMatrixDirty = true; + + return this; + }, + + + /** + * Rotates the model matrix in the X axis. + */ + modelRotateX: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[4] = a10 * c + a20 * s; + modelMatrix[5] = a11 * c + a21 * s; + modelMatrix[6] = a12 * c + a22 * s; + modelMatrix[7] = a13 * c + a23 * s; + modelMatrix[8] = a20 * c - a10 * s; + modelMatrix[9] = a21 * c - a11 * s; + modelMatrix[10] = a22 * c - a12 * s; + modelMatrix[11] = a23 * c - a13 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Rotates the model matrix in the Y axis. + */ + modelRotateY: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[0] = a00 * c - a20 * s; + modelMatrix[1] = a01 * c - a21 * s; + modelMatrix[2] = a02 * c - a22 * s; + modelMatrix[3] = a03 * c - a23 * s; + modelMatrix[8] = a00 * s + a20 * c; + modelMatrix[9] = a01 * s + a21 * c; + modelMatrix[10] = a02 * s + a22 * c; + modelMatrix[11] = a03 * s + a23 * c; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Rotates the model matrix in the Z axis. + */ + modelRotateZ: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + + modelMatrix[0] = a00 * c + a10 * s; + modelMatrix[1] = a01 * c + a11 * s; + modelMatrix[2] = a02 * c + a12 * s; + modelMatrix[3] = a03 * c + a13 * s; + modelMatrix[4] = a10 * c - a00 * s; + modelMatrix[5] = a11 * c - a01 * s; + modelMatrix[6] = a12 * c - a02 * s; + modelMatrix[7] = a13 * c - a03 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Loads identity matrix into the view matrix + */ + viewIdentity: function () + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = 1; + viewMatrix[1] = 0; + viewMatrix[2] = 0; + viewMatrix[3] = 0; + viewMatrix[4] = 0; + viewMatrix[5] = 1; + viewMatrix[6] = 0; + viewMatrix[7] = 0; + viewMatrix[8] = 0; + viewMatrix[9] = 0; + viewMatrix[10] = 1; + viewMatrix[11] = 0; + viewMatrix[12] = 0; + viewMatrix[13] = 0; + viewMatrix[14] = 0; + viewMatrix[15] = 1; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Scales view matrix + */ + viewScale: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = viewMatrix[0] * x; + viewMatrix[1] = viewMatrix[1] * x; + viewMatrix[2] = viewMatrix[2] * x; + viewMatrix[3] = viewMatrix[3] * x; + viewMatrix[4] = viewMatrix[4] * y; + viewMatrix[5] = viewMatrix[5] * y; + viewMatrix[6] = viewMatrix[6] * y; + viewMatrix[7] = viewMatrix[7] * y; + viewMatrix[8] = viewMatrix[8] * z; + viewMatrix[9] = viewMatrix[9] * z; + viewMatrix[10] = viewMatrix[10] * z; + viewMatrix[11] = viewMatrix[11] * z; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Translates view matrix + */ + viewTranslate: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; + viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; + viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; + viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Rotates view matrix in the X axis. + */ + viewRotateX: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[4] = a10 * c + a20 * s; + viewMatrix[5] = a11 * c + a21 * s; + viewMatrix[6] = a12 * c + a22 * s; + viewMatrix[7] = a13 * c + a23 * s; + viewMatrix[8] = a20 * c - a10 * s; + viewMatrix[9] = a21 * c - a11 * s; + viewMatrix[10] = a22 * c - a12 * s; + viewMatrix[11] = a23 * c - a13 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Rotates view matrix in the Y axis. + */ + viewRotateY: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[0] = a00 * c - a20 * s; + viewMatrix[1] = a01 * c - a21 * s; + viewMatrix[2] = a02 * c - a22 * s; + viewMatrix[3] = a03 * c - a23 * s; + viewMatrix[8] = a00 * s + a20 * c; + viewMatrix[9] = a01 * s + a21 * c; + viewMatrix[10] = a02 * s + a22 * c; + viewMatrix[11] = a03 * s + a23 * c; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Rotates view matrix in the Z axis. + */ + viewRotateZ: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + + viewMatrix[0] = a00 * c + a10 * s; + viewMatrix[1] = a01 * c + a11 * s; + viewMatrix[2] = a02 * c + a12 * s; + viewMatrix[3] = a03 * c + a13 * s; + viewMatrix[4] = a10 * c - a00 * s; + viewMatrix[5] = a11 * c - a01 * s; + viewMatrix[6] = a12 * c - a02 * s; + viewMatrix[7] = a13 * c - a03 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Loads a 2D view matrix (3x2 matrix) into a 4x4 view matrix + */ + viewLoad2D: function (matrix2D) + { + var vm = this.viewMatrix; + + vm[0] = matrix2D[0]; + vm[1] = matrix2D[1]; + vm[2] = 0.0; + vm[3] = 0.0; + vm[4] = matrix2D[2]; + vm[5] = matrix2D[3]; + vm[6] = 0.0; + vm[7] = 0.0; + vm[8] = matrix2D[4]; + vm[9] = matrix2D[5]; + vm[10] = 1.0; + vm[11] = 0.0; + vm[12] = 0.0; + vm[13] = 0.0; + vm[14] = 0.0; + vm[15] = 1.0; + + this.viewMatrixDirty = true; + + return this; + }, + + + /** + * Copies a 4x4 matrix into the view matrix + */ + viewLoad: function (matrix) + { + var vm = this.viewMatrix; + + vm[0] = matrix[0]; + vm[1] = matrix[1]; + vm[2] = matrix[2]; + vm[3] = matrix[3]; + vm[4] = matrix[4]; + vm[5] = matrix[5]; + vm[6] = matrix[6]; + vm[7] = matrix[7]; + vm[8] = matrix[8]; + vm[9] = matrix[9]; + vm[10] = matrix[10]; + vm[11] = matrix[11]; + vm[12] = matrix[12]; + vm[13] = matrix[13]; + vm[14] = matrix[14]; + vm[15] = matrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Loads identity matrix into the projection matrix. + */ + projIdentity: function () + { + var projectionMatrix = this.projectionMatrix; + + projectionMatrix[0] = 1; + projectionMatrix[1] = 0; + projectionMatrix[2] = 0; + projectionMatrix[3] = 0; + projectionMatrix[4] = 0; + projectionMatrix[5] = 1; + projectionMatrix[6] = 0; + projectionMatrix[7] = 0; + projectionMatrix[8] = 0; + projectionMatrix[9] = 0; + projectionMatrix[10] = 1; + projectionMatrix[11] = 0; + projectionMatrix[12] = 0; + projectionMatrix[13] = 0; + projectionMatrix[14] = 0; + projectionMatrix[15] = 1; + + this.projectionMatrixDirty = true; + + return this; + }, + + /** + * Sets up an orthographics projection matrix + */ + projOrtho: function (left, right, bottom, top, near, far) + { + var projectionMatrix = this.projectionMatrix; + var leftRight = 1.0 / (left - right); + var bottomTop = 1.0 / (bottom - top); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = -2.0 * leftRight; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = -2.0 * bottomTop; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = 2.0 * nearFar; + projectionMatrix[11] = 0.0; + projectionMatrix[12] = (left + right) * leftRight; + projectionMatrix[13] = (top + bottom) * bottomTop; + projectionMatrix[14] = (far + near) * nearFar; + projectionMatrix[15] = 1.0; + + this.projectionMatrixDirty = true; + return this; + }, + + /** + * Sets up a perspective projection matrix + */ + projPersp: function (fovy, aspectRatio, near, far) + { + var projectionMatrix = this.projectionMatrix; + var fov = 1.0 / Math.tan(fovy / 2.0); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = fov / aspectRatio; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = fov; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = (far + near) * nearFar; + projectionMatrix[11] = -1.0; + projectionMatrix[12] = 0.0; + projectionMatrix[13] = 0.0; + projectionMatrix[14] = (2.0 * far * near) * nearFar; + projectionMatrix[15] = 0.0; + + this.projectionMatrixDirty = true; + return this; + } +}; + +module.exports = ModelViewProjection; + + +/***/ }), +/* 967 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS', + '', + 'precision mediump float;', + '', + 'struct Light', + '{', + ' vec2 position;', + ' vec3 color;', + ' float intensity;', + ' float radius;', + '};', + '', + 'const int kMaxLights = %LIGHT_COUNT%;', + '', + 'uniform vec4 uCamera; /* x, y, rotation, zoom */', + 'uniform vec2 uResolution;', + 'uniform sampler2D uMainSampler;', + 'uniform sampler2D uNormSampler;', + 'uniform vec3 uAmbientLightColor;', + 'uniform Light uLights[kMaxLights];', + '', + 'varying vec2 outTexCoord;', + 'varying vec4 outTint;', + '', + 'void main()', + '{', + ' vec3 finalColor = vec3(0.0, 0.0, 0.0);', + ' vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);', + ' vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;', + ' vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));', + ' vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;', + '', + ' for (int index = 0; index < kMaxLights; ++index)', + ' {', + ' Light light = uLights[index];', + ' vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);', + ' vec3 lightNormal = normalize(lightDir);', + ' float distToSurf = length(lightDir) * uCamera.w;', + ' float diffuseFactor = max(dot(normal, lightNormal), 0.0);', + ' float radius = (light.radius / res.x * uCamera.w) * uCamera.w;', + ' float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);', + ' vec3 diffuse = light.color * diffuseFactor;', + ' finalColor += (attenuation * diffuse) * light.intensity;', + ' }', + '', + ' vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);', + ' gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);', + '', + '}', + '' +].join('\n'); + + +/***/ }), +/* 968 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_BITMAP_MASK_VS', + '', + 'precision mediump float;', + '', + 'attribute vec2 inPosition;', + '', + 'void main()', + '{', + ' gl_Position = vec4(inPosition, 0.0, 1.0);', + '}', + '' +].join('\n'); + + +/***/ }), +/* 969 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_BITMAP_MASK_FS', + '', + 'precision mediump float;', + '', + 'uniform vec2 uResolution;', + 'uniform sampler2D uMainSampler;', + 'uniform sampler2D uMaskSampler;', + 'uniform bool uInvertMaskAlpha;', + '', + 'void main()', + '{', + ' vec2 uv = gl_FragCoord.xy / uResolution;', + ' vec4 mainColor = texture2D(uMainSampler, uv);', + ' vec4 maskColor = texture2D(uMaskSampler, uv);', + ' float alpha = mainColor.a;', + '', + ' if (!uInvertMaskAlpha)', + ' {', + ' alpha *= (maskColor.a);', + ' }', + ' else', + ' {', + ' alpha *= (1.0 - maskColor.a);', + ' }', + '', + ' gl_FragColor = vec4(mainColor.rgb * alpha, alpha);', + '}', + '' +].join('\n'); + + +/***/ }), +/* 970 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasInterpolation = __webpack_require__(384); +var CanvasPool = __webpack_require__(26); +var CONST = __webpack_require__(28); +var Features = __webpack_require__(186); + +/** + * Called automatically by Phaser.Game and responsible for creating the renderer it will use. + * + * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. + * + * @function Phaser.Boot.CreateRenderer + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. + */ +var CreateRenderer = function (game) +{ + var config = game.config; + + // Game either requested Canvas, + // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas + + if (config.renderType !== CONST.HEADLESS) + { + if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) + { + if (Features.canvas) + { + // They requested Canvas and their browser supports it + config.renderType = CONST.CANVAS; + } + else + { + throw new Error('Cannot create Canvas or WebGL context, aborting.'); + } + } + else + { + // Game requested WebGL and browser says it supports it + config.renderType = CONST.WEBGL; + } + } + + // Pixel Art mode? + if (!config.antialias) + { + CanvasPool.disableSmoothing(); + } + + // Does the game config provide its own canvas element to use? + if (config.canvas) + { + game.canvas = config.canvas; + + game.canvas.width = game.config.width; + game.canvas.height = game.config.height; + } + else + { + game.canvas = CanvasPool.create(game, config.width * config.resolution, config.height * config.resolution, config.renderType); + } + + // Does the game config provide some canvas css styles to use? + if (config.canvasStyle) + { + game.canvas.style = config.canvasStyle; + } + + // Pixel Art mode? + if (!config.antialias) + { + CanvasInterpolation.setCrisp(game.canvas); + } + + // Zoomed? + game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; + game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; + + if (config.renderType === CONST.HEADLESS) + { + // Nothing more to do here + return; + } + + var CanvasRenderer; + var WebGLRenderer; + + if (true) + { + CanvasRenderer = __webpack_require__(374); + WebGLRenderer = __webpack_require__(371); + + // Let the config pick the renderer type, as both are included + if (config.renderType === CONST.WEBGL) + { + game.renderer = new WebGLRenderer(game); + } + else + { + game.renderer = new CanvasRenderer(game); + game.context = game.renderer.gameContext; + } + } + + if (false) + {} + + if (false) + {} +}; + +module.exports = CreateRenderer; + + +/***/ }), +/* 971 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the full screen support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.fullscreen` from within any Scene. + * + * @typedef {object} Phaser.Device.Fullscreen + * @since 3.0.0 + * + * @property {boolean} available - Does the browser support the Full Screen API? + * @property {boolean} keyboard - Does the browser support access to the Keyboard during Full Screen mode? + * @property {string} cancel - If the browser supports the Full Screen API this holds the call you need to use to cancel it. + * @property {string} request - If the browser supports the Full Screen API this holds the call you need to use to activate it. + */ +var Fullscreen = { + + available: false, + cancel: '', + keyboard: false, + request: '' + +}; + +/** +* Checks for support of the Full Screen API. +*/ +function init () +{ + var i; + + var fs = [ + 'requestFullscreen', + 'requestFullScreen', + 'webkitRequestFullscreen', + 'webkitRequestFullScreen', + 'msRequestFullscreen', + 'msRequestFullScreen', + 'mozRequestFullScreen', + 'mozRequestFullscreen' + ]; + + var element = document.createElement('div'); + + for (i = 0; i < fs.length; i++) + { + if (element[fs[i]]) + { + Fullscreen.available = true; + Fullscreen.request = fs[i]; + break; + } + } + + var cfs = [ + 'cancelFullScreen', + 'exitFullscreen', + 'webkitCancelFullScreen', + 'webkitExitFullscreen', + 'msCancelFullScreen', + 'msExitFullscreen', + 'mozCancelFullScreen', + 'mozExitFullscreen' + ]; + + if (Fullscreen.available) + { + for (i = 0; i < cfs.length; i++) + { + if (document[cfs[i]]) + { + Fullscreen.cancel = cfs[i]; + break; + } + } + } + + // Keyboard Input? + if (window['Element'] && Element['ALLOW_KEYBOARD_INPUT']) + { + Fullscreen.keyboard = true; + } + + return Fullscreen; +} + +module.exports = init(); + + +/***/ }), +/* 972 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the video support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.video` from within any Scene. + * + * @typedef {object} Phaser.Device.Video + * @since 3.0.0 + * + * @property {boolean} h264Video - Can this device play h264 mp4 video files? + * @property {boolean} hlsVideo - Can this device play hls video files? + * @property {boolean} mp4Video - Can this device play h264 mp4 video files? + * @property {boolean} oggVideo - Can this device play ogg video files? + * @property {boolean} vp9Video - Can this device play vp9 video files? + * @property {boolean} webmVideo - Can this device play webm video files? + */ +var Video = { + + h264Video: false, + hlsVideo: false, + mp4Video: false, + oggVideo: false, + vp9Video: false, + webmVideo: false + +}; + +function init () +{ + var videoElement = document.createElement('video'); + var result = !!videoElement.canPlayType; + + try + { + if (result) + { + if (videoElement.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '')) + { + Video.oggVideo = true; + } + + if (videoElement.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '')) + { + // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546 + Video.h264Video = true; + Video.mp4Video = true; + } + + if (videoElement.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '')) + { + Video.webmVideo = true; + } + + if (videoElement.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '')) + { + Video.vp9Video = true; + } + + if (videoElement.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '')) + { + Video.hlsVideo = true; + } + } + } + catch (e) + { + // Nothing to do + } + + return Video; +} + +module.exports = init(); + + +/***/ }), +/* 973 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Browser = __webpack_require__(128); + +/** + * Determines the audio playback capabilities of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.audio` from within any Scene. + * + * @typedef {object} Phaser.Device.Audio + * @since 3.0.0 + * + * @property {boolean} audioData - Can this device play HTML Audio tags? + * @property {boolean} dolby - Can this device play EC-3 Dolby Digital Plus files? + * @property {boolean} m4a - Can this device can play m4a files. + * @property {boolean} mp3 - Can this device play mp3 files? + * @property {boolean} ogg - Can this device play ogg files? + * @property {boolean} opus - Can this device play opus files? + * @property {boolean} wav - Can this device play wav files? + * @property {boolean} webAudio - Does this device have the Web Audio API? + * @property {boolean} webm - Can this device play webm files? + */ +var Audio = { + + audioData: false, + dolby: false, + m4a: false, + mp3: false, + ogg: false, + opus: false, + wav: false, + webAudio: false, + webm: false + +}; + +function init () +{ + Audio.audioData = !!(window['Audio']); + + Audio.webAudio = !!(window['AudioContext'] || window['webkitAudioContext']); + + var audioElement = document.createElement('audio'); + + var result = !!audioElement.canPlayType; + + try + { + if (result) + { + if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) + { + Audio.ogg = true; + } + + if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '') || audioElement.canPlayType('audio/opus;').replace(/^no$/, '')) + { + Audio.opus = true; + } + + if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) + { + Audio.mp3 = true; + } + + // Mimetypes accepted: + // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements + // bit.ly/iphoneoscodecs + if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) + { + Audio.wav = true; + } + + if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, '')) + { + Audio.m4a = true; + } + + if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')) + { + Audio.webm = true; + } + + if (audioElement.canPlayType('audio/mp4;codecs="ec-3"') !== '') + { + if (Browser.edge) + { + Audio.dolby = true; + } + else if (Browser.safari && Browser.safariVersion >= 9) + { + if ((/Mac OS X (\d+)_(\d+)/).test(navigator.userAgent)) + { + var major = parseInt(RegExp.$1, 10); + var minor = parseInt(RegExp.$2, 10); + + if ((major === 10 && minor >= 11) || major > 10) + { + Audio.dolby = true; + } + } + } + } + } + } + catch (e) + { + // Nothing to do here + } + + return Audio; +} + +module.exports = init(); + + +/***/ }), +/* 974 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(101); +var Browser = __webpack_require__(128); + +/** + * Determines the input support of the browser running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.input` from within any Scene. + * + * @typedef {object} Phaser.Device.Input + * @since 3.0.0 + * + * @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll' + * @property {boolean} gamepads - Is navigator.getGamepads available? + * @property {boolean} mspointer - Is mspointer available? + * @property {boolean} touch - Is touch available? + */ +var Input = { + + gamepads: false, + mspointer: false, + touch: false, + wheelEvent: null + +}; + +function init () +{ + if ('ontouchstart' in document.documentElement || (navigator.maxTouchPoints && navigator.maxTouchPoints >= 1)) + { + Input.touch = true; + } + + if (navigator.msPointerEnabled || navigator.pointerEnabled) + { + Input.mspointer = true; + } + + if (navigator.getGamepads) + { + Input.gamepads = true; + } + + if (!OS.cocoonJS) + { + // See https://developer.mozilla.org/en-US/docs/Web/Events/wheel + if ('onwheel' in window || (Browser.ie && 'WheelEvent' in window)) + { + // DOM3 Wheel Event: FF 17+, IE 9+, Chrome 31+, Safari 7+ + Input.wheelEvent = 'wheel'; + } + else if ('onmousewheel' in window) + { + // Non-FF legacy: IE 6-9, Chrome 1-31, Safari 5-7. + Input.wheelEvent = 'mousewheel'; + } + else if (Browser.firefox && 'MouseScrollEvent' in window) + { + // FF prior to 17. This should probably be scrubbed. + Input.wheelEvent = 'DOMMouseScroll'; + } + } + + return Input; +} + +module.exports = init(); + + +/***/ }), +/* 975 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(28); +var Device = __webpack_require__(376); +var GetFastValue = __webpack_require__(1); +var GetValue = __webpack_require__(4); +var IsPlainObject = __webpack_require__(8); +var MATH = __webpack_require__(18); +var NOOP = __webpack_require__(2); +var DefaultPlugins = __webpack_require__(185); +var ValueToColor = __webpack_require__(196); + +/** + * This callback type is completely empty, a no-operation. + * + * @callback NOOP + */ + +/** + * @callback BootCallback + * + * @param {Phaser.Game} game - The game. + */ + +/** + * @typedef {object} InputConfig + * + * @property {(boolean|KeyboardInputConfig)} [keyboard=true] - Keyboard input configuration. `true` uses the default configuration and `false` disables keyboard input. + * @property {(boolean|MouseInputConfig)} [mouse=true] - Mouse input configuration. `true` uses the default configuration and `false` disables mouse input. + * @property {(boolean|TouchInputConfig)} [touch=true] - Touch input configuration. `true` uses the default configuration and `false` disables touch input. + * @property {(boolean|GamepadInputConfig)} [gamepad=false] - Gamepad input configuration. `true` enables gamepad input. + * @property {integer} [activePointers=1] - The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}. + */ + +/** + * @typedef {object} MouseInputConfig + * + * @property {*} [target=null] - Where the Mouse Manager listens for mouse input events. The default is the game canvas. + * @property {boolean} [capture=true] - Whether mouse input events have preventDefault() called on them. + */ + +/** + * @typedef {object} KeyboardInputConfig + * + * @property {*} [target=window] - Where the Keyboard Manager listens for keyboard input events. + */ + +/** + * @typedef {object} TouchInputConfig + * + * @property {*} [target=null] - Where the Touch Manager listens for touch input events. The default is the game canvas. + * @property {boolean} [capture=true] - Whether touch input events have preventDefault() called on them. + */ + +/** + * @typedef {object} GamepadInputConfig + * + * @property {*} [target=window] - Where the Gamepad Manager listens for gamepad input events. + */ + +/** + * @typedef {object} BannerConfig + * + * @property {boolean} [hidePhaser=false] - Omit Phaser's name and version from the banner. + * @property {string} [text='#ffffff'] - The color of the banner text. + * @property {string[]} [background] - The background colors of the banner. + */ + +/** + * @typedef {object} FPSConfig + * + * @property {integer} [min=10] - The minimum acceptable rendering rate, in frames per second. + * @property {integer} [target=60] - The optimum rendering rate, in frames per second. + * @property {boolean} [forceSetTimeOut=false] - Use setTimeout instead of requestAnimationFrame to run the game loop. + * @property {integer} [deltaHistory=10] - Calculate the average frame delta from this many consecutive frame intervals. + * @property {integer} [panicMax=120] - [description] + */ + +/** + * @typedef {object} RenderConfig + * + * @property {boolean} [antialias=true] - When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. + * @property {boolean} [pixelArt=false] - Sets `antialias` and `roundPixels` to true. This is the best setting for pixel-art games. + * @property {boolean} [autoResize=true] - Automatically resize the Game Canvas if you resize the renderer. + * @property {boolean} [roundPixels=false] - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. + * @property {boolean} [transparent=false] - Whether the game canvas will be transparent. + * @property {boolean} [clearBeforeRender=true] - Whether the game canvas will be cleared between each rendering frame. + * @property {boolean} [premultipliedAlpha=true] - In WebGL mode, the drawing buffer contains colors with pre-multiplied alpha. + * @property {boolean} [preserveDrawingBuffer=false] - In WebGL mode, the drawing buffer won't be cleared automatically each frame. + * @property {boolean} [failIfMajorPerformanceCaveat=false] - Let the browser abort creating a WebGL context if it judges performance would be unacceptable. + * @property {string} [powerPreference='default'] - "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. + * @property {integer} [batchSize=2000] - The default WebGL batch size. + * @property {integer} [maxLights=10] - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + +/** + * @typedef {object} ScaleConfig + * + * @property {(integer|string)} [width=1024] - The base width of your game. + * @property {(integer|string)} [height=768] - The base height of your game. + * @property {integer} [zoom=1] - The zoom value of the game canvas. + * @property {number} [resolution=1] - The rendering resolution of the canvas. + * @property {(HTMLElement|string)} [parent] - The DOM element that will contain the game canvas, or its `id`. If null (the default) or if the named element doesn't exist, the game canvas is inserted directly into the document body. + * @property {integer} [mode=0] - The scale mode to apply to the canvas. SHOW_ALL, EXACT_FIT, USER_SCALE, or RESIZE. + * @property {integer} [minWidth] - The minimum width the canvas can be scaled down to. + * @property {integer} [minHeight] - The minimum height the canvas can be scaled down to. + * @property {integer} [maxWidth] - The maximum width the canvas can be scaled up to. + * @property {integer} [maxHeight] - The maximum height the canvas can be scaled up to. + */ + +/** + * @typedef {object} CallbacksConfig + * + * @property {BootCallback} [preBoot=NOOP] - A function to run at the start of the boot sequence. + * @property {BootCallback} [postBoot=NOOP] - A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. + */ + +/** + * @typedef {object} LoaderConfig + * + * @property {string} [baseURL] - An URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. + * @property {string} [path] - An URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. + * @property {integer} [maxParallelDownloads=32] - The maximum number of resources the loader will start loading at once. + * @property {(string|undefined)} [crossOrigin=undefined] - 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. + * @property {string} [responseType] - The response type of the XHR request, e.g. `blob`, `text`, etc. + * @property {boolean} [async=true] - Should the XHR request use async or not? + * @property {string} [user] - Optional username for the XHR request. + * @property {string} [password] - Optional password for the XHR request. + * @property {integer} [timeout=0] - Optional XHR timeout value, in ms. + */ + +/** + * @typedef {object} DOMContainerConfig + * + * @property {boolean} [createContainer=false] - Create a div element in which DOM Elements will be contained. You must also provide a parent. + * @property {boolean} [behindCanvas=false] - Place the DOM Container behind the Phaser Canvas. The default is to place it over the Canvas. + */ + +/** + * @typedef {object} ImagesConfig + * + * @property {string} [default] - URL to use for the 'default' texture. + * @property {string} [missing] - URL to use for the 'missing' texture. + */ + +/** + * @typedef {object} PhysicsConfig + * + * @property {string} [default] - The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'. + * @property {ArcadeWorldConfig} [arcade] - Arcade Physics configuration. + * @property {Phaser.Physics.Impact.WorldConfig} [impact] - Impact Physics configuration. + * @property {object} [matter] - Matter Physics configuration. + */ + +/** + * @typedef {object} PluginObjectItem + * + * @property {string} [key] - A key to identify the plugin in the Plugin Manager. + * @property {*} [plugin] - The plugin itself. Usually a class/constructor. + * @property {boolean} [start] - Whether the plugin should be started automatically. + * @property {string} [systemKey] - For a scene plugin, add the plugin to the scene's systems object under this key (`this.sys.KEY`, from the scene). + * @property {string} [sceneKey] - For a scene plugin, add the plugin to the scene object under this key (`this.KEY`, from the scene). + * @property {*} [data] - Arbitrary data passed to the plugin's init() method. + * + * @example + * // Global plugin + * { key: 'BankPlugin', plugin: BankPluginV3, start: true, data: { gold: 5000 } } + * @example + * // Scene plugin + * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } + */ + +/** + * @typedef {object} PluginObject + * + * @property {?PluginObjectItem[]} [global] - Global plugins to install. + * @property {?PluginObjectItem[]} [scene] - Scene plugins to install. + * @property {string[]} [default] - The default set of scene plugins (names). + * @property {string[]} [defaultMerge] - Plugins to *add* to the default set of scene plugins. + */ + +/** + * @typedef {object} GameConfig + * + * @property {(integer|string)} [width=1024] - The width of the game, in game pixels. + * @property {(integer|string)} [height=768] - The height of the game, in game pixels. + * @property {number} [zoom=1] - Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc. + * @property {number} [resolution=1] - The size of each game pixel, in canvas pixels. Values larger than 1 are "high" resolution. + * @property {number} [type=CONST.AUTO] - Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS. + * @property {(HTMLElement|string)} [parent=null] - The DOM element that will contain the game canvas, or its `id`. If null (the default) or if the named element doesn't exist, the game canvas is inserted directly into the document body. + * @property {HTMLCanvasElement} [canvas=null] - Provide your own Canvas element for Phaser to use instead of creating one. + * @property {string} [canvasStyle=null] - CSS styles to apply to the game canvas instead of Phaser's default styles. + * @property {CanvasRenderingContext2D} [context] - Provide your own Canvas Context for Phaser to use, instead of creating one. + * @property {object} [scene=null] - A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have { active: true }. + * @property {string[]} [seed] - Seed for the random number generator. + * @property {string} [title=''] - The title of the game. Shown in the browser console. + * @property {string} [url='http://phaser.io'] - The URL of the game. Shown in the browser console. + * @property {string} [version=''] - The version of the game. Shown in the browser console. + * @property {boolean} [autoFocus=true] - Automatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame. + * @property {(boolean|InputConfig)} [input] - Input configuration, or `false` to disable all game input. + * @property {boolean} [disableContextMenu=false] - Disable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click). + * @property {(boolean|BannerConfig)} [banner=false] - Configuration for the banner printed in the browser console when the game starts. + * @property {DOMContainerConfig} [dom] - The DOM Container configuration object. + * @property {FPSConfig} [fps] - Game loop configuration. + * @property {RenderConfig} [render] - Game renderer configuration. + * @property {(string|number)} [backgroundColor=0x000000] - The background color of the game canvas. The default is black. + * @property {CallbacksConfig} [callbacks] - Optional callbacks to run before or after game boot. + * @property {LoaderConfig} [loader] - Loader configuration. + * @property {ImagesConfig} [images] - Images configuration. + * @property {object} [physics] - Physics configuration. + * @property {PluginObject|PluginObjectItem[]} [plugins] - Plugins to install. + */ + +/** + * @classdesc + * The active game configuration settings, parsed from a {@link GameConfig} object. + * + * @class Config + * @memberof Phaser.Boot + * @constructor + * @since 3.0.0 + * + * @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. + * + * @see Phaser.Game#config + */ +var Config = new Class({ + + initialize: + + function Config (config) + { + if (config === undefined) { config = {}; } + + var defaultBannerColor = [ + '#ff0000', + '#ffff00', + '#00ff00', + '#00ffff', + '#000000' + ]; + + var defaultBannerTextColor = '#ffffff'; + + /** + * @const {(integer|string)} Phaser.Boot.Config#width - [description] + */ + this.width = GetValue(config, 'width', 1024); + + /** + * @const {(integer|string)} Phaser.Boot.Config#height - [description] + */ + this.height = GetValue(config, 'height', 768); + + /** + * @const {number} Phaser.Boot.Config#zoom - [description] + */ + this.zoom = GetValue(config, 'zoom', 1); + + /** + * @const {number} Phaser.Boot.Config#resolution - [description] + */ + this.resolution = GetValue(config, 'resolution', 1); + + /** + * @const {?*} Phaser.Boot.Config#parent - [description] + */ + this.parent = GetValue(config, 'parent', null); + + /** + * @const {integer} Phaser.Boot.Config#scaleMode - [description] + */ + this.scaleMode = GetValue(config, 'scaleMode', 0); + + /** + * @const {boolean} Phaser.Boot.Config#expandParent - [description] + */ + this.expandParent = GetValue(config, 'expandParent', false); + + /** + * @const {integer} Phaser.Boot.Config#minWidth - [description] + */ + this.minWidth = GetValue(config, 'minWidth', 0); + + /** + * @const {integer} Phaser.Boot.Config#maxWidth - [description] + */ + this.maxWidth = GetValue(config, 'maxWidth', 0); + + /** + * @const {integer} Phaser.Boot.Config#minHeight - [description] + */ + this.minHeight = GetValue(config, 'minHeight', 0); + + /** + * @const {integer} Phaser.Boot.Config#maxHeight - [description] + */ + this.maxHeight = GetValue(config, 'maxHeight', 0); + + // Scale Manager - Anything set in here over-rides anything set above + + var scaleConfig = GetValue(config, 'scale', null); + + if (scaleConfig) + { + this.width = GetValue(scaleConfig, 'width', this.width); + this.height = GetValue(scaleConfig, 'height', this.height); + this.zoom = GetValue(scaleConfig, 'zoom', this.zoom); + this.resolution = GetValue(scaleConfig, 'resolution', this.resolution); + this.parent = GetValue(scaleConfig, 'parent', this.parent); + this.scaleMode = GetValue(scaleConfig, 'mode', this.scaleMode); + this.expandParent = GetValue(scaleConfig, 'mode', this.expandParent); + this.minWidth = GetValue(scaleConfig, 'min.width', this.minWidth); + this.maxWidth = GetValue(scaleConfig, 'max.width', this.maxWidth); + this.minHeight = GetValue(scaleConfig, 'min.height', this.minHeight); + this.maxHeight = GetValue(scaleConfig, 'max.height', this.maxHeight); + } + + /** + * @const {number} Phaser.Boot.Config#renderType - Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) + */ + this.renderType = GetValue(config, 'type', CONST.AUTO); + + /** + * @const {?HTMLCanvasElement} Phaser.Boot.Config#canvas - Force Phaser to use your own Canvas element instead of creating one. + */ + this.canvas = GetValue(config, 'canvas', null); + + /** + * @const {?(CanvasRenderingContext2D|WebGLRenderingContext)} Phaser.Boot.Config#context - Force Phaser to use your own Canvas context instead of creating one. + */ + this.context = GetValue(config, 'context', null); + + /** + * @const {?string} Phaser.Boot.Config#canvasStyle - [description] + */ + this.canvasStyle = GetValue(config, 'canvasStyle', null); + + /** + * @const {?object} Phaser.Boot.Config#sceneConfig - [description] + */ + this.sceneConfig = GetValue(config, 'scene', null); + + /** + * @const {string[]} Phaser.Boot.Config#seed - [description] + */ + this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]); + + MATH.RND.init(this.seed); + + /** + * @const {string} Phaser.Boot.Config#gameTitle - The title of the game. + */ + this.gameTitle = GetValue(config, 'title', ''); + + /** + * @const {string} Phaser.Boot.Config#gameURL - The URL of the game. + */ + this.gameURL = GetValue(config, 'url', 'https://phaser.io'); + + /** + * @const {string} Phaser.Boot.Config#gameVersion - The version of the game. + */ + this.gameVersion = GetValue(config, 'version', ''); + + /** + * @const {boolean} Phaser.Boot.Config#autoFocus - [description] + */ + this.autoFocus = GetValue(config, 'autoFocus', true); + + // DOM Element Container + + /** + * @const {?boolean} Phaser.Boot.Config#domCreateContainer - [description] + */ + this.domCreateContainer = GetValue(config, 'dom.createContainer', false); + + /** + * @const {?boolean} Phaser.Boot.Config#domBehindCanvas - [description] + */ + this.domBehindCanvas = GetValue(config, 'dom.behindCanvas', false); + + // Input + + /** + * @const {boolean} Phaser.Boot.Config#inputKeyboard - [description] + */ + this.inputKeyboard = GetValue(config, 'input.keyboard', true); + + /** + * @const {*} Phaser.Boot.Config#inputKeyboardEventTarget - [description] + */ + this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); + + /** + * @const {(boolean|object)} Phaser.Boot.Config#inputMouse - [description] + */ + this.inputMouse = GetValue(config, 'input.mouse', true); + + /** + * @const {?*} Phaser.Boot.Config#inputMouseEventTarget - [description] + */ + this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null); + + /** + * @const {boolean} Phaser.Boot.Config#inputMouseCapture - [description] + */ + this.inputMouseCapture = GetValue(config, 'input.mouse.capture', true); + + /** + * @const {boolean} Phaser.Boot.Config#inputTouch - [description] + */ + this.inputTouch = GetValue(config, 'input.touch', Device.input.touch); + + /** + * @const {?*} Phaser.Boot.Config#inputTouchEventTarget - [description] + */ + this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null); + + /** + * @const {boolean} Phaser.Boot.Config#inputTouchCapture - [description] + */ + this.inputTouchCapture = GetValue(config, 'input.touch.capture', true); + + /** + * @const {integer} Phaser.Boot.Config#inputActivePointers - [description] + */ + this.inputActivePointers = GetValue(config, 'input.activePointers', 1); + + /** + * @const {boolean} Phaser.Boot.Config#inputGamepad - [description] + */ + this.inputGamepad = GetValue(config, 'input.gamepad', false); + + /** + * @const {*} Phaser.Boot.Config#inputGamepadEventTarget - [description] + */ + this.inputGamepadEventTarget = GetValue(config, 'input.gamepad.target', window); + + /** + * @const {boolean} Phaser.Boot.Config#disableContextMenu - Set to `true` to disable context menu. Default value is `false`. + */ + this.disableContextMenu = GetValue(config, 'disableContextMenu', false); + + /** + * @const {any} Phaser.Boot.Config#audio - [description] + */ + this.audio = GetValue(config, 'audio'); + + // If you do: { banner: false } it won't display any banner at all + + /** + * @const {boolean} Phaser.Boot.Config#hideBanner - [description] + */ + this.hideBanner = (GetValue(config, 'banner', null) === false); + + /** + * @const {boolean} Phaser.Boot.Config#hidePhaser - [description] + */ + this.hidePhaser = GetValue(config, 'banner.hidePhaser', false); + + /** + * @const {string} Phaser.Boot.Config#bannerTextColor - [description] + */ + this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); + + /** + * @const {string[]} Phaser.Boot.Config#bannerBackgroundColor - [description] + */ + this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); + + if (this.gameTitle === '' && this.hidePhaser) + { + this.hideBanner = true; + } + + // Frame Rate config + // fps: { + // min: 10, + // target: 60, + // forceSetTimeOut: false, + // deltaHistory: 10 + // } + + /** + * @const {?FPSConfig} Phaser.Boot.Config#fps - [description] + */ + this.fps = GetValue(config, 'fps', null); + + // Renderer Settings + // These can either be in a `render` object within the Config, or specified on their own + + var renderConfig = GetValue(config, 'render', config); + + /** + * @const {boolean} Phaser.Boot.Config#autoResize - Automatically resize the Game Canvas if you resize the renderer. + */ + this.autoResize = GetValue(renderConfig, 'autoResize', true); + + /** + * @const {boolean} Phaser.Boot.Config#antialias - [description] + */ + this.antialias = GetValue(renderConfig, 'antialias', true); + + /** + * @const {boolean} Phaser.Boot.Config#roundPixels - [description] + */ + this.roundPixels = GetValue(renderConfig, 'roundPixels', false); + + /** + * @const {boolean} Phaser.Boot.Config#pixelArt - Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode). + */ + this.pixelArt = GetValue(renderConfig, 'pixelArt', false); + + if (this.pixelArt) + { + this.antialias = false; + this.roundPixels = true; + } + + /** + * @const {boolean} Phaser.Boot.Config#transparent - [description] + */ + this.transparent = GetValue(renderConfig, 'transparent', false); + + /** + * @const {boolean} Phaser.Boot.Config#clearBeforeRender - [description] + */ + this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true); + + /** + * @const {boolean} Phaser.Boot.Config#premultipliedAlpha - [description] + */ + this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true); + + /** + * @const {boolean} Phaser.Boot.Config#preserveDrawingBuffer - [description] + */ + this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false); + + /** + * @const {boolean} Phaser.Boot.Config#failIfMajorPerformanceCaveat - [description] + */ + this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false); + + /** + * @const {string} Phaser.Boot.Config#powerPreference - [description] + */ + this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default'); + + /** + * @const {integer} Phaser.Boot.Config#batchSize - The default WebGL Batch size. + */ + this.batchSize = GetValue(renderConfig, 'batchSize', 2000); + + /** + * @const {integer} Phaser.Boot.Config#maxLights - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + this.maxLights = GetValue(renderConfig, 'maxLights', 10); + + var bgc = GetValue(config, 'backgroundColor', 0); + + /** + * @const {Phaser.Display.Color} Phaser.Boot.Config#backgroundColor - [description] + */ + this.backgroundColor = ValueToColor(bgc); + + if (bgc === 0 && this.transparent) + { + this.backgroundColor.alpha = 0; + } + + // Callbacks + + /** + * @const {BootCallback} Phaser.Boot.Config#preBoot - [description] + */ + this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); + + /** + * @const {BootCallback} Phaser.Boot.Config#postBoot - [description] + */ + this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); + + // Physics + // physics: { + // system: 'impact', + // setBounds: true, + // gravity: 0, + // cellSize: 64 + // } + + /** + * @const {object} Phaser.Boot.Config#physics - [description] + */ + this.physics = GetValue(config, 'physics', {}); + + /** + * @const {boolean} Phaser.Boot.Config#defaultPhysicsSystem - [description] + */ + this.defaultPhysicsSystem = GetValue(this.physics, 'default', false); + + // Loader Defaults + + /** + * @const {string} Phaser.Boot.Config#loaderBaseURL - [description] + */ + this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); + + /** + * @const {string} Phaser.Boot.Config#loaderPath - [description] + */ + this.loaderPath = GetValue(config, 'loader.path', ''); + + /** + * @const {integer} Phaser.Boot.Config#loaderMaxParallelDownloads - Maximum parallel downloads allowed for resources (Default to 32). + */ + this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 32); + + /** + * @const {(string|undefined)} Phaser.Boot.Config#loaderCrossOrigin - [description] + */ + this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); + + /** + * @const {string} Phaser.Boot.Config#loaderResponseType - [description] + */ + this.loaderResponseType = GetValue(config, 'loader.responseType', ''); + + /** + * @const {boolean} Phaser.Boot.Config#loaderAsync - [description] + */ + this.loaderAsync = GetValue(config, 'loader.async', true); + + /** + * @const {string} Phaser.Boot.Config#loaderUser - [description] + */ + this.loaderUser = GetValue(config, 'loader.user', ''); + + /** + * @const {string} Phaser.Boot.Config#loaderPassword - [description] + */ + this.loaderPassword = GetValue(config, 'loader.password', ''); + + /** + * @const {integer} Phaser.Boot.Config#loaderTimeout - [description] + */ + this.loaderTimeout = GetValue(config, 'loader.timeout', 0); + + // Plugins + + /* + * Allows `plugins` property to either be an array, in which case it just replaces + * the default plugins like previously, or a config object. + * + * plugins: { + * global: [ + * { key: 'TestPlugin', plugin: TestPlugin, start: true, data: { msg: 'The plugin is alive' } }, + * ], + * scene: [ + * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } + * ], + * default: [], OR + * defaultMerge: [ + * 'ModPlayer' + * ] + * } + */ + + /** + * @const {any} Phaser.Boot.Config#installGlobalPlugins - [description] + */ + this.installGlobalPlugins = []; + + /** + * @const {any} Phaser.Boot.Config#installScenePlugins - [description] + */ + this.installScenePlugins = []; + + var plugins = GetValue(config, 'plugins', null); + var defaultPlugins = DefaultPlugins.DefaultScene; + + if (plugins) + { + // Old 3.7 array format? + if (Array.isArray(plugins)) + { + this.defaultPlugins = plugins; + } + else if (IsPlainObject(plugins)) + { + this.installGlobalPlugins = GetFastValue(plugins, 'global', []); + this.installScenePlugins = GetFastValue(plugins, 'scene', []); + + if (Array.isArray(plugins.default)) + { + defaultPlugins = plugins.default; + } + else if (Array.isArray(plugins.defaultMerge)) + { + defaultPlugins = defaultPlugins.concat(plugins.defaultMerge); + } + } + } + + /** + * @const {any} Phaser.Boot.Config#defaultPlugins - The plugins installed into every Scene (in addition to CoreScene and Global). + */ + this.defaultPlugins = defaultPlugins; + + // Default / Missing Images + var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; + + /** + * @const {string} Phaser.Boot.Config#defaultImage - [description] + */ + this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); + + /** + * @const {string} Phaser.Boot.Config#missingImage - [description] + */ + this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); + + if (window) + { + if (window.FORCE_WEBGL) + { + this.renderType = CONST.WEBGL; + } + else if (window.FORCE_CANVAS) + { + this.renderType = CONST.CANVAS; + } + } + } + +}); + +module.exports = Config; + + +/***/ }), +/* 976 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AddToDOM = __webpack_require__(187); +var AnimationManager = __webpack_require__(417); +var CacheManager = __webpack_require__(415); +var CanvasPool = __webpack_require__(26); +var Class = __webpack_require__(0); +var Config = __webpack_require__(975); +var CreateRenderer = __webpack_require__(970); +var DataManager = __webpack_require__(102); +var DebugHeader = __webpack_require__(963); +var Device = __webpack_require__(376); +var DOMContentLoaded = __webpack_require__(380); +var EventEmitter = __webpack_require__(11); +var InputManager = __webpack_require__(367); +var PluginCache = __webpack_require__(15); +var PluginManager = __webpack_require__(360); +var SceneManager = __webpack_require__(358); +var SoundManagerCreator = __webpack_require__(354); +var TextureManager = __webpack_require__(347); +var TimeStep = __webpack_require__(950); +var VisibilityHandler = __webpack_require__(949); + +if (false) +{ var CreateDOMContainer; } + +if (true) +{ + var FacebookInstantGamesPlugin = __webpack_require__(344); +} + +/** + * @classdesc + * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible + * for handling the boot process, parsing the configuration values, creating the renderer, + * and setting-up all of the global Phaser systems, such as sound and input. + * Once that is complete it will start the Scene Manager and then begin the main game loop. + * + * You should generally avoid accessing any of the systems created by Game, and instead use those + * made available to you via the Phaser.Scene Systems class instead. + * + * @class Game + * @memberof Phaser + * @constructor + * @since 3.0.0 + * + * @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. + */ +var Game = new Class({ + + initialize: + + function Game (config) + { + /** + * The parsed Game Configuration object. + * + * The values stored within this object are read-only and should not be changed at run-time. + * + * @name Phaser.Game#config + * @type {Phaser.Boot.Config} + * @readonly + * @since 3.0.0 + */ + this.config = new Config(config); + + /** + * A reference to either the Canvas or WebGL Renderer that this Game is using. + * + * @name Phaser.Game#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = null; + + if (false) + {} + + /** + * A reference to the HTML Canvas Element that Phaser uses to render the game. + * This is created automatically by Phaser unless you provide a `canvas` property + * in your Game Config. + * + * @name Phaser.Game#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = null; + + /** + * A reference to the Rendering Context belonging to the Canvas Element this game is rendering to. + * If the game is running under Canvas it will be a 2d Canvas Rendering Context. + * If the game is running under WebGL it will be a WebGL Rendering Context. + * This context is created automatically by Phaser unless you provide a `context` property + * in your Game Config. + * + * @name Phaser.Game#context + * @type {(CanvasRenderingContext2D|WebGLRenderingContext)} + * @since 3.0.0 + */ + this.context = null; + + /** + * A flag indicating when this Game instance has finished its boot process. + * + * @name Phaser.Game#isBooted + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isBooted = false; + + /** + * A flag indicating if this Game is currently running its game step or not. + * + * @name Phaser.Game#isRunning + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * An Event Emitter which is used to broadcast game-level events from the global systems. + * + * @name Phaser.Game#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = new EventEmitter(); + + /** + * An instance of the Animation Manager. + * + * The Animation Manager is a global system responsible for managing all animations used within your game. + * + * @name Phaser.Game#anims + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.anims = new AnimationManager(this); + + /** + * An instance of the Texture Manager. + * + * The Texture Manager is a global system responsible for managing all textures being used by your game. + * + * @name Phaser.Game#textures + * @type {Phaser.Textures.TextureManager} + * @since 3.0.0 + */ + this.textures = new TextureManager(this); + + /** + * An instance of the Cache Manager. + * + * The Cache Manager is a global system responsible for caching, accessing and releasing external game assets. + * + * @name Phaser.Game#cache + * @type {Phaser.Cache.CacheManager} + * @since 3.0.0 + */ + this.cache = new CacheManager(this); + + /** + * An instance of the Data Manager + * + * @name Phaser.Game#registry + * @type {Phaser.Data.DataManager} + * @since 3.0.0 + */ + this.registry = new DataManager(this); + + /** + * An instance of the Input Manager. + * + * The Input Manager is a global system responsible for the capture of browser-level input events. + * + * @name Phaser.Game#input + * @type {Phaser.Input.InputManager} + * @since 3.0.0 + */ + this.input = new InputManager(this, this.config); + + /** + * An instance of the Scene Manager. + * + * The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game. + * + * @name Phaser.Game#scene + * @type {Phaser.Scenes.SceneManager} + * @since 3.0.0 + */ + this.scene = new SceneManager(this, this.config.sceneConfig); + + /** + * A reference to the Device inspector. + * + * Contains information about the device running this game, such as OS, browser vendor and feature support. + * Used by various systems to determine capabilities and code paths. + * + * @name Phaser.Game#device + * @type {Phaser.DeviceConf} + * @since 3.0.0 + */ + this.device = Device; + + /** + * An instance of the base Sound Manager. + * + * The Sound Manager is a global system responsible for the playback and updating of all audio in your game. + * + * @name Phaser.Game#sound + * @type {Phaser.Sound.BaseSoundManager} + * @since 3.0.0 + */ + this.sound = SoundManagerCreator.create(this); + + /** + * An instance of the Time Step. + * + * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing + * them and calculating delta values. It then automatically calls the game step. + * + * @name Phaser.Game#loop + * @type {Phaser.Boot.TimeStep} + * @since 3.0.0 + */ + this.loop = new TimeStep(this, this.config.fps); + + /** + * An instance of the Plugin Manager. + * + * The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install + * those plugins into Scenes as required. + * + * @name Phaser.Game#plugins + * @type {Phaser.Plugins.PluginManager} + * @since 3.0.0 + */ + this.plugins = new PluginManager(this, this.config); + + if (true) + { + /** + * An instance of the Facebook Instant Games Plugin. + * + * This will only be available if the plugin has been built into Phaser, + * or you're using the special Facebook Instant Games custom build. + * + * @name Phaser.Game#facebook + * @type {Phaser.FacebookInstantGamesPlugin} + * @since 3.13.0 + */ + this.facebook = new FacebookInstantGamesPlugin(this); + } + + /** + * Is this Game pending destruction at the start of the next frame? + * + * @name Phaser.Game#pendingDestroy + * @type {boolean} + * @private + * @since 3.5.0 + */ + this.pendingDestroy = false; + + /** + * Remove the Canvas once the destroy is over? + * + * @name Phaser.Game#removeCanvas + * @type {boolean} + * @private + * @since 3.5.0 + */ + this.removeCanvas = false; + + /** + * Remove everything when the game is destroyed. + * You cannot create a new Phaser instance on the same web page after doing this. + * + * @name Phaser.Game#noReturn + * @type {boolean} + * @private + * @since 3.12.0 + */ + this.noReturn = false; + + /** + * Does the window the game is running in currently have focus or not? + * This is modified by the VisibilityHandler. + * + * @name Phaser.Game#hasFocus + * @type {boolean} + * @readonly + * @since 3.9.0 + */ + this.hasFocus = false; + + /** + * Is the mouse pointer currently over the game canvas or not? + * This is modified by the VisibilityHandler. + * + * @name Phaser.Game#isOver + * @type {boolean} + * @readonly + * @since 3.10.0 + */ + this.isOver = true; + + // Wait for the DOM Ready event, then call boot. + DOMContentLoaded(this.boot.bind(this)); + }, + + /** + * Game boot event. + * + * This is an internal event dispatched when the game has finished booting, but before it is ready to start running. + * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. + * + * @event Phaser.Game#boot + */ + + /** + * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, + * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. + * It listens for a 'ready' event from the base systems and once received it will call `Game.start`. + * + * @method Phaser.Game#boot + * @protected + * @fires Phaser.Game#boot + * @since 3.0.0 + */ + boot: function () + { + if (!PluginCache.hasCore('EventEmitter')) + { + console.warn('Aborting. Core Plugins missing.'); + return; + } + + this.isBooted = true; + + this.config.preBoot(this); + + CreateRenderer(this); + + if (false) + {} + + DebugHeader(this); + + AddToDOM(this.canvas, this.config.parent); + + this.events.emit('boot'); + + // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready. + // So it will emit this internal event when done: + this.events.once('texturesready', this.texturesReady, this); + }, + + /** + * Called automatically when the Texture Manager has finished setting up and preparing the + * default textures. + * + * @method Phaser.Game#texturesReady + * @private + * @fires Phaser.Game#ready + * @since 3.12.0 + */ + texturesReady: function () + { + // Start all the other systems + this.events.emit('ready'); + + this.start(); + }, + + /** + * Called automatically by Game.boot once all of the global systems have finished setting themselves up. + * By this point the Game is now ready to start the main loop running. + * It will also enable the Visibility Handler. + * + * @method Phaser.Game#start + * @protected + * @since 3.0.0 + */ + start: function () + { + this.isRunning = true; + + this.config.postBoot(this); + + if (this.renderer) + { + this.loop.start(this.step.bind(this)); + } + else + { + this.loop.start(this.headlessStep.bind(this)); + } + + VisibilityHandler(this); + + var eventEmitter = this.events; + + eventEmitter.on('hidden', this.onHidden, this); + eventEmitter.on('visible', this.onVisible, this); + eventEmitter.on('blur', this.onBlur, this); + eventEmitter.on('focus', this.onFocus, this); + }, + + /** + * Game Pre-Step event. + * + * Listen for it using the event type `prestep`. + * + * This event is dispatched before the main Step starts. + * By this point none of the Scene updates have happened. + * Hook into it from plugins or systems that need to update before the Scene Manager does. + * + * @event Phaser.Game#prestepEvent + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + + /** + * Game Step event. + * + * Listen for it using the event type `step`. + * + * This event is dispatched after Pre-Step and before the Scene Manager steps. + * Hook into it from plugins or systems that need to update before the Scene Manager does, but after core Systems. + * + * @event Phaser.Game#stepEvent + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + + /** + * Game Post-Step event. + * + * Listen for it using the event type `poststep`. + * + * This event is dispatched after the Scene Manager has updated. + * Hook into it from plugins or systems that need to do things before the render starts. + * + * @event Phaser.Game#poststepEvent + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + + /** + * Game Pre-Render event. + * + * Listen for it using the event type `prerender`. + * + * This event is dispatched immediately before any of the Scenes have started to render. + * The renderer will already have been initialized this frame, clearing itself and preparing to receive + * the Scenes for rendering, but it won't have actually drawn anything yet. + * + * @event Phaser.Game#prerenderEvent + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - A reference to the current renderer. + */ + + /** + * Game Post-Render event. + * + * Listen for it using the event type `postrender`. + * + * This event is dispatched right at the end of the render process. + * Every Scene will have rendered and drawn to the canvas. + * + * @event Phaser.Game#postrenderEvent + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - A reference to the current renderer. + */ + + /** + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. + * + * @method Phaser.Game#step + * @fires Phaser.Game#prestepEvent + * @fires Phaser.Game#stepEvent + * @fires Phaser.Game#poststepEvent + * @fires Phaser.Game#prerenderEvent + * @fires Phaser.Game#postrenderEvent + * @since 3.0.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + step: function (time, delta) + { + if (this.pendingDestroy) + { + return this.runDestroy(); + } + + var eventEmitter = this.events; + + // Global Managers like Input and Sound update in the prestep + + eventEmitter.emit('prestep', time, delta); + + // This is mostly meant for user-land code and plugins + + eventEmitter.emit('step', time, delta); + + // Update the Scene Manager and all active Scenes + + this.scene.update(time, delta); + + // Our final event before rendering starts + + eventEmitter.emit('poststep', time, delta); + + var renderer = this.renderer; + + // Run the Pre-render (clearing the canvas, setting background colors, etc) + + renderer.preRender(); + + eventEmitter.emit('prerender', renderer, time, delta); + + // The main render loop. Iterates all Scenes and all Cameras in those scenes, rendering to the renderer instance. + + this.scene.render(renderer); + + // The Post-Render call. Tidies up loose end, takes snapshots, etc. + + renderer.postRender(); + + // The final event before the step repeats. Your last chance to do anything to the canvas before it all starts again. + + eventEmitter.emit('postrender', renderer, time, delta); + }, + + /** + * A special version of the Game Step for the HEADLESS renderer only. + * + * The main Game Step. Called automatically by the Time Step, once per browser frame (typically as a result of + * Request Animation Frame, or Set Timeout on very old browsers.) + * + * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. + * + * This process emits `prerender` and `postrender` events, even though nothing actually displays. + * + * @method Phaser.Game#headlessStep + * @fires Phaser.Game#prerenderEvent + * @fires Phaser.Game#postrenderEvent + * @since 3.2.0 + * + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + headlessStep: function (time, delta) + { + var eventEmitter = this.events; + + // Global Managers + + eventEmitter.emit('prestep', time, delta); + + eventEmitter.emit('step', time, delta); + + // Scenes + + this.scene.update(time, delta); + + eventEmitter.emit('poststep', time, delta); + + // Render + + eventEmitter.emit('prerender'); + + eventEmitter.emit('postrender'); + }, + + /** + * Game Pause event. + * + * Listen for it using the event type `pause`. + * + * This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler. + * + * @event Phaser.Game#pauseEvent + */ + + /** + * Called automatically by the Visibility Handler. + * This will pause the main loop and then emit a pause event. + * + * @method Phaser.Game#onHidden + * @protected + * @fires Phaser.Game#pauseEvent + * @since 3.0.0 + */ + onHidden: function () + { + this.loop.pause(); + + this.events.emit('pause'); + }, + + /** + * Game Resume event. + * + * Listen for it using the event type `resume`. + * + * This event is dispatched when the game loop leaves a paused state and resumes running. + * + * @event Phaser.Game#resumeEvent + */ + + /** + * Called automatically by the Visibility Handler. + * This will resume the main loop and then emit a resume event. + * + * @method Phaser.Game#onVisible + * @protected + * @fires Phaser.Game#resumeEvent + * @since 3.0.0 + */ + onVisible: function () + { + this.loop.resume(); + + this.events.emit('resume'); + }, + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'blurred' state, which pauses it. + * + * @method Phaser.Game#onBlur + * @protected + * @since 3.0.0 + */ + onBlur: function () + { + this.hasFocus = false; + + this.loop.blur(); + }, + + /** + * Called automatically by the Visibility Handler. + * This will set the main loop into a 'focused' state, which resumes it. + * + * @method Phaser.Game#onFocus + * @protected + * @since 3.0.0 + */ + onFocus: function () + { + this.hasFocus = true; + + this.loop.focus(); + }, + + /** + * Game Resize event. + * + * Listen for it using the event type `resize`. + * + * @event Phaser.Game#resizeEvent + * @param {number} width - The new width of the Game. + * @param {number} height - The new height of the Game. + */ + + /** + * Updates the Game Config with the new width and height values given. + * Then resizes the Renderer and Input Manager scale. + * + * @method Phaser.Game#resize + * @fires Phaser.Game#resizeEvent + * @since 3.2.0 + * + * @param {number} width - The new width of the game. + * @param {number} height - The new height of the game. + */ + resize: function (width, height) + { + this.config.width = width; + this.config.height = height; + + if (false) + {} + + this.renderer.resize(width, height); + + this.input.resize(); + + this.scene.resize(width, height); + + this.events.emit('resize', width, height); + }, + + /** + * Game Destroy event. + * + * Listen for it using the event type `destroy`. + * + * @event Phaser.Game#destroyEvent + */ + + /** + * Flags this Game instance as needing to be destroyed on the next frame. + * It will wait until the current frame has completed and then call `runDestroy` internally. + * + * If you **do not** need to run Phaser again on the same web page you can set the `noReturn` argument to `true` and it will free-up + * memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as `false`. + * + * @method Phaser.Game#destroy + * @fires Phaser.Game#destroyEvent + * @since 3.0.0 + * + * @param {boolean} removeCanvas - Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. + * @param {boolean} [noReturn=false] - If `true` all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this. + */ + destroy: function (removeCanvas, noReturn) + { + if (noReturn === undefined) { noReturn = false; } + + this.pendingDestroy = true; + + this.removeCanvas = removeCanvas; + this.noReturn = noReturn; + }, + + /** + * Destroys this Phaser.Game instance, all global systems, all sub-systems and all Scenes. + * + * @method Phaser.Game#runDestroy + * @private + * @since 3.5.0 + */ + runDestroy: function () + { + this.events.emit('destroy'); + + this.events.removeAllListeners(); + + this.scene.destroy(); + + if (this.renderer) + { + this.renderer.destroy(); + } + + if (this.removeCanvas && this.canvas) + { + CanvasPool.remove(this.canvas); + + if (this.canvas.parentNode) + { + this.canvas.parentNode.removeChild(this.canvas); + } + } + + if (false) + {} + + this.loop.destroy(); + + this.pendingDestroy = false; + } + +}); + +module.exports = Game; + + +/***/ }), +/* 977 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EE = __webpack_require__(11); +var PluginCache = __webpack_require__(15); + +/** + * @classdesc + * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. + * + * @class EventEmitter + * @memberof Phaser.Events + * @constructor + * @since 3.0.0 + */ +var EventEmitter = new Class({ + + Extends: EE, + + initialize: + + function EventEmitter () + { + EE.call(this); + }, + + /** + * Removes all listeners. + * + * @method Phaser.Events.EventEmitter#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAllListeners(); + }, + + /** + * Removes all listeners. + * + * @method Phaser.Events.EventEmitter#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + } + +}); + +/** + * Return an array listing the events for which the emitter has registered listeners. + * + * @method Phaser.Events.EventEmitter#eventNames + * @since 3.0.0 + * + * @return {array} + */ + +/** + * Return the listeners registered for a given event. + * + * @method Phaser.Events.EventEmitter#listeners + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {array} The registered listeners. + */ + +/** + * Return the number of listeners listening to a given event. + * + * @method Phaser.Events.EventEmitter#listenerCount + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * + * @return {number} The number of listeners. + */ + +/** + * Calls each of the listeners registered for a given event. + * + * @method Phaser.Events.EventEmitter#emit + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {...*} [args] - Additional arguments that will be passed to the event handler. + * + * @return {boolean} `true` if the event had listeners, else `false`. + */ + +/** + * Add a listener for a given event. + * + * @method Phaser.Events.EventEmitter#on + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Add a listener for a given event. + * + * @method Phaser.Events.EventEmitter#addListener + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Add a one-time listener for a given event. + * + * @method Phaser.Events.EventEmitter#once + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - The listener function. + * @param {*} [context=this] - The context to invoke the listener with. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Remove the listeners of a given event. + * + * @method Phaser.Events.EventEmitter#removeListener + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - Only remove the listeners that match this function. + * @param {*} context - Only remove the listeners that have this context. + * @param {boolean} once - Only remove one-time listeners. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Remove the listeners of a given event. + * + * @method Phaser.Events.EventEmitter#off + * @since 3.0.0 + * + * @param {(string|symbol)} event - The event name. + * @param {function} fn - Only remove the listeners that match this function. + * @param {*} context - Only remove the listeners that have this context. + * @param {boolean} once - Only remove one-time listeners. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +/** + * Remove all listeners, or those of the specified event. + * + * @method Phaser.Events.EventEmitter#removeAllListeners + * @since 3.0.0 + * + * @param {(string|symbol)} [event] - The event name. + * + * @return {Phaser.Events.EventEmitter} `this`. + */ + +PluginCache.register('EventEmitter', EventEmitter, 'events'); + +module.exports = EventEmitter; + + +/***/ }), +/* 978 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Events + */ + +module.exports = { EventEmitter: __webpack_require__(977) }; + + +/***/ }), +/* 979 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 980 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.DOM + */ + +var Dom = { + + AddToDOM: __webpack_require__(187), + DOMContentLoaded: __webpack_require__(380), + ParseXML: __webpack_require__(379), + RemoveFromDOM: __webpack_require__(378), + RequestAnimationFrame: __webpack_require__(377) + +}; + +module.exports = Dom; + + +/***/ }), +/* 981 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Masks + */ + +module.exports = { + + BitmapMask: __webpack_require__(430), + GeometryMask: __webpack_require__(429) + +}; + + +/***/ }), +/* 982 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ComponentToHex = __webpack_require__(382); + +/** + * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. + * + * @function Phaser.Display.Color.RGBToString + * @since 3.0.0 + * + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * @param {integer} [a=255] - The alpha value. A number between 0 and 255. + * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. + * + * @return {string} A string-based representation of the color values. + */ +var RGBToString = function (r, g, b, a, prefix) +{ + if (a === undefined) { a = 255; } + if (prefix === undefined) { prefix = '#'; } + + if (prefix === '#') + { + return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); + } + else + { + return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); + } +}; + +module.exports = RGBToString; + + +/***/ }), +/* 983 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Between = __webpack_require__(188); +var Color = __webpack_require__(41); + +/** + * Creates a new Color object where the r, g, and b values have been set to random values + * based on the given min max values. + * + * @function Phaser.Display.Color.RandomRGB + * @since 3.0.0 + * + * @param {integer} [min=0] - The minimum value to set the random range from (between 0 and 255) + * @param {integer} [max=255] - The maximum value to set the random range from (between 0 and 255) + * + * @return {Phaser.Display.Color} A Color object. + */ +var RandomRGB = function (min, max) +{ + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + return new Color(Between(min, max), Between(min, max), Between(min, max)); +}; + +module.exports = RandomRGB; + + +/***/ }), +/* 984 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Linear = __webpack_require__(129); + +/** + * Interpolates color values + * + * @namespace Phaser.Display.Color.Interpolate + * @since 3.0.0 + */ + +/** + * Interpolates between the two given color ranges over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.RGBWithRGB + * @since 3.0.0 + * + * @param {number} r1 - Red value. + * @param {number} g1 - Blue value. + * @param {number} b1 - Green value. + * @param {number} r2 - Red value. + * @param {number} g2 - Blue value. + * @param {number} b2 - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + var t = index / length; + + return { + r: Linear(r1, r2, t), + g: Linear(g1, g2, t), + b: Linear(b1, b2, t) + }; +}; + +/** + * Interpolates between the two given color objects over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithColor + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {Phaser.Display.Color} color2 - The second Color object. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithColor = function (color1, color2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); +}; + +/** + * Interpolates between the Color object and color values over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithRGB + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {number} r - Red value. + * @param {number} g - Blue value. + * @param {number} b - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithRGB = function (color, r, g, b, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); +}; + +module.exports = { + + RGBWithRGB: RGBWithRGB, + ColorWithRGB: ColorWithRGB, + ColorWithColor: ColorWithColor + +}; + + +/***/ }), +/* 985 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HSVToRGB = __webpack_require__(194); + +/** + * Get HSV color wheel values in an array which will be 360 elements in size. + * + * @function Phaser.Display.Color.HSVColorWheel + * @since 3.0.0 + * + * @param {number} [s=1] - The saturation, in the range 0 - 1. + * @param {number} [v=1] - The value, in the range 0 - 1. + * + * @return {ColorObject[]} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel. + */ +var HSVColorWheel = function (s, v) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var colors = []; + + for (var c = 0; c <= 359; c++) + { + colors.push(HSVToRGB(c / 359, s, v)); + } + + return colors; +}; + +module.exports = HSVColorWheel; + + +/***/ }), +/* 986 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(41); +var HueToComponent = __webpack_require__(381); + +/** + * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. + * + * @function Phaser.Display.Color.HSLToColor + * @since 3.0.0 + * + * @param {number} h - The hue value in the range 0 to 1. + * @param {number} s - The saturation value in the range 0 to 1. + * @param {number} l - The lightness value in the range 0 to 1. + * + * @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values. + */ +var HSLToColor = function (h, s, l) +{ + // achromatic by default + var r = l; + var g = l; + var b = l; + + if (s !== 0) + { + var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + + r = HueToComponent(p, q, h + 1 / 3); + g = HueToComponent(p, q, h); + b = HueToComponent(p, q, h - 1 / 3); + } + + var color = new Color(); + + return color.setGLTo(r, g, b, 1); +}; + +module.exports = HSLToColor; + + +/***/ }), +/* 987 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts the given color value into an Object containing r,g,b and a properties. + * + * @function Phaser.Display.Color.ColorToRGBA + * @since 3.0.0 + * + * @param {number} color - A color value, optionally including the alpha value. + * + * @return {ColorObject} An object containing the parsed color values. + */ +var ColorToRGBA = function (color) +{ + var output = { + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF, + a: 255 + }; + + if (color > 16777215) + { + output.a = color >>> 24; + } + + return output; +}; + +module.exports = ColorToRGBA; + + +/***/ }), +/* 988 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. + * + * @function Phaser.Display.Canvas.UserSelect + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts. + * + * @return {HTMLCanvasElement} The canvas element. + */ +var UserSelect = function (canvas, value) +{ + if (value === undefined) { value = 'none'; } + + var vendors = [ + '-webkit-', + '-khtml-', + '-moz-', + '-ms-', + '' + ]; + + vendors.forEach(function (vendor) + { + canvas.style[vendor + 'user-select'] = value; + }); + + canvas.style['-webkit-touch-callout'] = value; + canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; + + return canvas; +}; + +module.exports = UserSelect; + + +/***/ }), +/* 989 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. + * + * @function Phaser.Display.Canvas.TouchAction + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. + * + * @return {HTMLCanvasElement} The canvas element. + */ +var TouchAction = function (canvas, value) +{ + if (value === undefined) { value = 'none'; } + + canvas.style['msTouchAction'] = value; + canvas.style['ms-touch-action'] = value; + canvas.style['touch-action'] = value; + + return canvas; +}; + +module.exports = TouchAction; + + +/***/ }), +/* 990 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Canvas + */ + +module.exports = { + + CanvasInterpolation: __webpack_require__(384), + CanvasPool: __webpack_require__(26), + Smoothing: __webpack_require__(130), + TouchAction: __webpack_require__(989), + UserSelect: __webpack_require__(988) + +}; + + +/***/ }), +/* 991 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its y coordinate. + * This is the same as `width * origin.y`. + * This value will only be > 0 if `origin.y` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The vertical offset of the Game Object. + */ +var GetOffsetY = function (gameObject) +{ + return gameObject.height * gameObject.originY; +}; + +module.exports = GetOffsetY; + + +/***/ }), +/* 992 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * origin.x`. + * This value will only be > 0 if `origin.x` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The horizontal offset of the Game Object. + */ +var GetOffsetX = function (gameObject) +{ + return gameObject.width * gameObject.originX; +}; + +module.exports = GetOffsetX; + + +/***/ }), +/* 993 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Bounds + */ + +module.exports = { + + CenterOn: __webpack_require__(448), + GetBottom: __webpack_require__(52), + GetCenterX: __webpack_require__(85), + GetCenterY: __webpack_require__(82), + GetLeft: __webpack_require__(50), + GetOffsetX: __webpack_require__(992), + GetOffsetY: __webpack_require__(991), + GetRight: __webpack_require__(48), + GetTop: __webpack_require__(46), + SetBottom: __webpack_require__(51), + SetCenterX: __webpack_require__(84), + SetCenterY: __webpack_require__(83), + SetLeft: __webpack_require__(49), + SetRight: __webpack_require__(47), + SetTop: __webpack_require__(45) + +}; + + +/***/ }), +/* 994 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(48); +var GetTop = __webpack_require__(46); +var SetBottom = __webpack_require__(51); +var SetRight = __webpack_require__(47); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. + * + * @function Phaser.Display.Align.To.TopRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }), +/* 995 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(50); +var GetTop = __webpack_require__(46); +var SetBottom = __webpack_require__(51); +var SetLeft = __webpack_require__(49); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. + * + * @function Phaser.Display.Align.To.TopLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }), +/* 996 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterX = __webpack_require__(85); +var GetTop = __webpack_require__(46); +var SetBottom = __webpack_require__(51); +var SetCenterX = __webpack_require__(84); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. + * + * @function Phaser.Display.Align.To.TopCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }), +/* 997 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(48); +var GetTop = __webpack_require__(46); +var SetLeft = __webpack_require__(49); +var SetTop = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. + * + * @function Phaser.Display.Align.To.RightTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = RightTop; + + +/***/ }), +/* 998 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(82); +var GetRight = __webpack_require__(48); +var SetCenterY = __webpack_require__(83); +var SetLeft = __webpack_require__(49); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. + * + * @function Phaser.Display.Align.To.RightCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }), +/* 999 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(52); +var GetRight = __webpack_require__(48); +var SetBottom = __webpack_require__(51); +var SetLeft = __webpack_require__(49); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. + * + * @function Phaser.Display.Align.To.RightBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightBottom; + + +/***/ }), +/* 1000 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(50); +var GetTop = __webpack_require__(46); +var SetRight = __webpack_require__(47); +var SetTop = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. + * + * @function Phaser.Display.Align.To.LeftTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = LeftTop; + + +/***/ }), +/* 1001 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(82); +var GetLeft = __webpack_require__(50); +var SetCenterY = __webpack_require__(83); +var SetRight = __webpack_require__(47); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. + * + * @function Phaser.Display.Align.To.LeftCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }), +/* 1002 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(52); +var GetLeft = __webpack_require__(50); +var SetBottom = __webpack_require__(51); +var SetRight = __webpack_require__(47); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. + * + * @function Phaser.Display.Align.To.LeftBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftBottom; + + +/***/ }), +/* 1003 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(52); +var GetRight = __webpack_require__(48); +var SetRight = __webpack_require__(47); +var SetTop = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. + * + * @function Phaser.Display.Align.To.BottomRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }), +/* 1004 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(52); +var GetLeft = __webpack_require__(50); +var SetLeft = __webpack_require__(49); +var SetTop = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. + * + * @function Phaser.Display.Align.To.BottomLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }), +/* 1005 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(52); +var GetCenterX = __webpack_require__(85); +var SetCenterX = __webpack_require__(84); +var SetTop = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. + * + * @function Phaser.Display.Align.To.BottomCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }), +/* 1006 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.To + */ + +module.exports = { + + BottomCenter: __webpack_require__(1005), + BottomLeft: __webpack_require__(1004), + BottomRight: __webpack_require__(1003), + LeftBottom: __webpack_require__(1002), + LeftCenter: __webpack_require__(1001), + LeftTop: __webpack_require__(1000), + RightBottom: __webpack_require__(999), + RightCenter: __webpack_require__(998), + RightTop: __webpack_require__(997), + TopCenter: __webpack_require__(996), + TopLeft: __webpack_require__(995), + TopRight: __webpack_require__(994) + +}; + + +/***/ }), +/* 1007 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.In + */ + +module.exports = { + + BottomCenter: __webpack_require__(452), + BottomLeft: __webpack_require__(451), + BottomRight: __webpack_require__(450), + Center: __webpack_require__(449), + LeftCenter: __webpack_require__(447), + QuickSet: __webpack_require__(453), + RightCenter: __webpack_require__(446), + TopCenter: __webpack_require__(445), + TopLeft: __webpack_require__(444), + TopRight: __webpack_require__(443) + +}; + + +/***/ }), +/* 1008 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(212); +var Extend = __webpack_require__(21); + +/** + * @namespace Phaser.Display.Align + */ + +var Align = { + + In: __webpack_require__(1007), + To: __webpack_require__(1006) + +}; + +// Merge in the consts +Align = Extend(false, Align, CONST); + +module.exports = Align; + + +/***/ }), +/* 1009 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display + */ + +module.exports = { + + Align: __webpack_require__(1008), + Bounds: __webpack_require__(993), + Canvas: __webpack_require__(990), + Color: __webpack_require__(383), + Masks: __webpack_require__(981) + +}; + + +/***/ }), +/* 1010 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DataManager = __webpack_require__(102); +var PluginCache = __webpack_require__(15); + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManagerPlugin + * @extends Phaser.Data.DataManager + * @memberof Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that this DataManager belongs to. + */ +var DataManagerPlugin = new Class({ + + Extends: DataManager, + + initialize: + + function DataManagerPlugin (scene) + { + DataManager.call(this, scene, scene.sys.events); + + /** + * A reference to the Scene that this DataManager belongs to. + * + * @name Phaser.Data.DataManagerPlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene's Systems. + * + * @name Phaser.Data.DataManagerPlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Data.DataManagerPlugin#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.events = this.systems.events; + + this.events.once('destroy', this.destroy, 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.Data.DataManagerPlugin#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.events.once('shutdown', this.shutdown, 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 () + { + this.systems.events.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.Data.DataManagerPlugin#destroy + * @since 3.5.0 + */ + destroy: function () + { + DataManager.prototype.destroy.call(this); + + this.events.off('start', this.start, this); + + this.scene = null; + this.systems = null; + } + +}); + +PluginCache.register('DataManagerPlugin', DataManagerPlugin, 'data'); + +module.exports = DataManagerPlugin; + + +/***/ }), +/* 1011 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Data + */ + +module.exports = { + + DataManager: __webpack_require__(102), + DataManagerPlugin: __webpack_require__(1010) + +}; + + +/***/ }), +/* 1012 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * [description] + * + * @class MoveTo + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - [description] + * @param {number} [y] - [description] + */ +var MoveTo = new Class({ + + initialize: + + function MoveTo (x, y) + { + // Skip length calcs in paths + + /** + * [description] + * + * @name Phaser.Curves.MoveTo#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + + /** + * [description] + * + * @name Phaser.Curves.MoveTo#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.MoveTo#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.MoveTo#getPointAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * Gets the resolution of this curve. + * + * @method Phaser.Curves.MoveTo#getResolution + * @since 3.0.0 + * + * @return {number} The resolution of this curve. For a MoveTo the value is always 1. + */ + getResolution: function () + { + return 1; + }, + + /** + * Gets the length of this curve. + * + * @method Phaser.Curves.MoveTo#getLength + * @since 3.0.0 + * + * @return {number} The length of this curve. For a MoveTo the value is always 0. + */ + getLength: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Curves.MoveTo#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} [description] + */ + toJSON: function () + { + return { + type: 'MoveTo', + points: [ + this.p0.x, this.p0.y + ] + }; + } + +}); + +module.exports = MoveTo; + + +/***/ }), +/* 1013 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var CubicBezierCurve = __webpack_require__(391); +var EllipseCurve = __webpack_require__(389); +var GameObjectFactory = __webpack_require__(5); +var LineCurve = __webpack_require__(388); +var MovePathTo = __webpack_require__(1012); +var QuadraticBezierCurve = __webpack_require__(387); +var Rectangle = __webpack_require__(10); +var SplineCurve = __webpack_require__(385); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} JSONPath + * + * @property {string} type - The of the curve. + * @property {number} x - [description] + * @property {number} y - [description] + * @property {boolean} autoClose - The path is auto closed. + * @property {JSONCurve[]} curves - The list of the curves + */ + +/** + * @classdesc + * [description] + * + * @class Path + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + */ +var Path = new Class({ + + initialize: + + function Path (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + /** + * [description] + * + * @name Phaser.Curves.Path#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Curves.Path#curves + * @type {Phaser.Curves.Curve[]} + * @default [] + * @since 3.0.0 + */ + this.curves = []; + + /** + * [description] + * + * @name Phaser.Curves.Path#cacheLengths + * @type {number[]} + * @default [] + * @since 3.0.0 + */ + this.cacheLengths = []; + + /** + * Automatically closes the path. + * + * @name Phaser.Curves.Path#autoClose + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.autoClose = false; + + /** + * [description] + * + * @name Phaser.Curves.Path#startPoint + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.startPoint = new Vector2(); + + /** + * [description] + * + * @name Phaser.Curves.Path#_tmpVec2A + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2A = new Vector2(); + + /** + * [description] + * + * @name Phaser.Curves.Path#_tmpVec2B + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tmpVec2B = new Vector2(); + + if (typeof x === 'object') + { + this.fromJSON(x); + } + else + { + this.startPoint.set(x, y); + } + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#add + * @since 3.0.0 + * + * @param {Phaser.Curves.Curve} curve - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + add: function (curve) + { + this.curves.push(curve); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#circleTo + * @since 3.0.0 + * + * @param {number} radius - [description] + * @param {boolean} [clockwise=false] - [description] + * @param {number} [rotation=0] - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + circleTo: function (radius, clockwise, rotation) + { + if (clockwise === undefined) { clockwise = false; } + + return this.ellipseTo(radius, radius, 0, 360, clockwise, rotation); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#closePath + * @since 3.0.0 + * + * @return {Phaser.Curves.Path} [description] + */ + closePath: function () + { + // Add a line curve if start and end of lines are not connected + var startPoint = this.curves[0].getPoint(0); + var endPoint = this.curves[this.curves.length - 1].getPoint(1); + + if (!startPoint.equals(endPoint)) + { + // This will copy a reference to the vectors, which probably isn't sensible + this.curves.push(new LineCurve(endPoint, startPoint)); + } + + return this; + }, + + /** + * Creates a cubic bezier curve starting at the previous end point and ending at p3, using p1 and p2 as control points. + * + * @method Phaser.Curves.Path#cubicBezierTo + * @since 3.0.0 + * + * @param {(number|Phaser.Math.Vector2)} x - The x coordinate of the end point. Or, if a Vec2, the p1 value. + * @param {(number|Phaser.Math.Vector2)} y - The y coordinate of the end point. Or, if a Vec2, the p2 value. + * @param {(number|Phaser.Math.Vector2)} control1X - The x coordinate of the first control point. Or, if a Vec2, the p3 value. + * @param {number} [control1Y] - The y coordinate of the first control point. Not used if vec2s are provided as the first 3 arguments. + * @param {number} [control2X] - The x coordinate of the second control point. Not used if vec2s are provided as the first 3 arguments. + * @param {number} [control2Y] - The y coordinate of the second control point. Not used if vec2s are provided as the first 3 arguments. + * + * @return {Phaser.Curves.Path} [description] + */ + cubicBezierTo: function (x, y, control1X, control1Y, control2X, control2Y) + { + var p0 = this.getEndPoint(); + var p1; + var p2; + var p3; + + // Assume they're all vec2s + if (x instanceof Vector2) + { + p1 = x; + p2 = y; + p3 = control1X; + } + else + { + p1 = new Vector2(control1X, control1Y); + p2 = new Vector2(control2X, control2Y); + p3 = new Vector2(x, y); + } + + return this.add(new CubicBezierCurve(p0, p1, p2, p3)); + }, + + // Creates a quadratic bezier curve starting at the previous end point and ending at p2, using p1 as a control point + + /** + * [description] + * + * @method Phaser.Curves.Path#quadraticBezierTo + * @since 3.2.0 + * + * @param {(number|Phaser.Math.Vector2[])} x - [description] + * @param {number} [y] - [description] + * @param {number} [controlX] - [description] + * @param {number} [controlY] - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + quadraticBezierTo: function (x, y, controlX, controlY) + { + var p0 = this.getEndPoint(); + var p1; + var p2; + + // Assume they're all vec2s + if (x instanceof Vector2) + { + p1 = x; + p2 = y; + } + else + { + p1 = new Vector2(controlX, controlY); + p2 = new Vector2(x, y); + } + + return this.add(new QuadraticBezierCurve(p0, p1, p2)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [out,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - [description] + * @param {integer} [pointsTotal=32] - [description] + * + * @return {Phaser.GameObjects.Graphics} [description] + */ + draw: function (graphics, pointsTotal) + { + for (var i = 0; i < this.curves.length; i++) + { + var curve = this.curves[i]; + + if (!curve.active) + { + continue; + } + + curve.draw(graphics, pointsTotal); + } + + return graphics; + }, + + /** + * Creates an ellipse curve positioned at the previous end point, using the given parameters. + * + * @method Phaser.Curves.Path#ellipseTo + * @since 3.0.0 + * + * @param {number} xRadius - [description] + * @param {number} yRadius - [description] + * @param {number} startAngle - [description] + * @param {number} endAngle - [description] + * @param {boolean} clockwise - [description] + * @param {number} rotation - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + ellipseTo: function (xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + var ellipse = new EllipseCurve(0, 0, xRadius, yRadius, startAngle, endAngle, clockwise, rotation); + + var end = this.getEndPoint(this._tmpVec2A); + + // Calculate where to center the ellipse + var start = ellipse.getStartPoint(this._tmpVec2B); + + end.subtract(start); + + ellipse.x = end.x; + ellipse.y = end.y; + + return this.add(ellipse); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#fromJSON + * @since 3.0.0 + * + * @param {object} data - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + fromJSON: function (data) + { + // data should be an object matching the Path.toJSON object structure. + + this.curves = []; + this.cacheLengths = []; + + this.startPoint.set(data.x, data.y); + + this.autoClose = data.autoClose; + + for (var i = 0; i < data.curves.length; i++) + { + var curve = data.curves[i]; + + switch (curve.type) + { + case 'LineCurve': + this.add(LineCurve.fromJSON(curve)); + break; + + case 'EllipseCurve': + this.add(EllipseCurve.fromJSON(curve)); + break; + + case 'SplineCurve': + this.add(SplineCurve.fromJSON(curve)); + break; + + case 'CubicBezierCurve': + this.add(CubicBezierCurve.fromJSON(curve)); + break; + + case 'QuadraticBezierCurve': + this.add(QuadraticBezierCurve.fromJSON(curve)); + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} [out] - [description] + * @param {integer} [accuracy=16] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ + getBounds: function (out, accuracy) + { + if (out === undefined) { out = new Rectangle(); } + if (accuracy === undefined) { accuracy = 16; } + + out.x = Number.MAX_VALUE; + out.y = Number.MAX_VALUE; + + var bounds = new Rectangle(); + var maxRight = Number.MIN_SAFE_INTEGER; + var maxBottom = Number.MIN_SAFE_INTEGER; + + for (var i = 0; i < this.curves.length; i++) + { + var curve = this.curves[i]; + + if (!curve.active) + { + continue; + } + + curve.getBounds(bounds, accuracy); + + out.x = Math.min(out.x, bounds.x); + out.y = Math.min(out.y, bounds.y); + + maxRight = Math.max(maxRight, bounds.right); + maxBottom = Math.max(maxBottom, bounds.bottom); + } + + out.right = maxRight; + out.bottom = maxBottom; + + return out; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getCurveLengths + * @since 3.0.0 + * + * @return {number[]} [description] + */ + getCurveLengths: function () + { + // We use cache values if curves and cache array are same length + + if (this.cacheLengths.length === this.curves.length) + { + return this.cacheLengths; + } + + // Get length of sub-curve + // Push sums into cached array + + var lengths = []; + var sums = 0; + + for (var i = 0; i < this.curves.length; i++) + { + sums += this.curves[i].getLength(); + + lengths.push(sums); + } + + this.cacheLengths = lengths; + + return lengths; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getEndPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getEndPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + if (this.curves.length > 0) + { + this.curves[this.curves.length - 1].getPoint(1, out); + } + else + { + out.copy(this.startPoint); + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getLength + * @since 3.0.0 + * + * @return {number} [description] + */ + getLength: function () + { + var lens = this.getCurveLengths(); + + return lens[lens.length - 1]; + }, + + // To get accurate point with reference to + // entire path distance at time t, + // following has to be done: + + // 1. Length of each sub path have to be known + // 2. Locate and identify type of curve + // 3. Get t for the curve + // 4. Return curve.getPointAt(t') + + /** + * [description] + * + * @method Phaser.Curves.Path#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {?Phaser.Math.Vector2} [description] + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var d = t * this.getLength(); + var curveLengths = this.getCurveLengths(); + var i = 0; + + while (i < curveLengths.length) + { + if (curveLengths[i] >= d) + { + var diff = curveLengths[i] - d; + var curve = this.curves[i]; + + var segmentLength = curve.getLength(); + var u = (segmentLength === 0) ? 0 : 1 - diff / segmentLength; + + return curve.getPointAt(u, out); + } + + i++; + } + + // loop where sum != 0, sum > d , sum+1 1 && !points[points.length - 1].equals(points[0])) + { + points.push(points[0]); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. + * + * @return {Phaser.Math.Vector2} [description] + */ + getRandomPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(Math.random(), out); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getSpacedPoints + * @since 3.0.0 + * + * @param {integer} [divisions=40] - [description] + * + * @return {Phaser.Math.Vector2[]} [description] + */ + getSpacedPoints: function (divisions) + { + if (divisions === undefined) { divisions = 40; } + + var points = []; + + for (var i = 0; i <= divisions; i++) + { + points.push(this.getPoint(i / divisions)); + } + + if (this.autoClose) + { + points.push(points[0]); + } + + return points; + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.startPoint); + }, + + // Creates a line curve from the previous end point to x/y + + /** + * [description] + * + * @method Phaser.Curves.Path#lineTo + * @since 3.0.0 + * + * @param {(number|Phaser.Math.Vector2)} x - [description] + * @param {number} [y] - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + lineTo: function (x, y) + { + if (x instanceof Vector2) + { + this._tmpVec2B.copy(x); + } + else + { + this._tmpVec2B.set(x, y); + } + + var end = this.getEndPoint(this._tmpVec2A); + + return this.add(new LineCurve([ end.x, end.y, this._tmpVec2B.x, this._tmpVec2B.y ])); + }, + + // Creates a spline curve starting at the previous end point, using the given parameters + + /** + * [description] + * + * @method Phaser.Curves.Path#splineTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} points - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + splineTo: function (points) + { + points.unshift(this.getEndPoint()); + + return this.add(new SplineCurve(points)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#moveTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Curves.Path} [description] + */ + moveTo: function (x, y) + { + return this.add(new MovePathTo(x, y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#toJSON + * @since 3.0.0 + * + * @return {JSONPath} [description] + */ + toJSON: function () + { + var out = []; + + for (var i = 0; i < this.curves.length; i++) + { + out.push(this.curves[i].toJSON()); + } + + return { + type: 'Path', + x: this.startPoint.x, + y: this.startPoint.y, + autoClose: this.autoClose, + curves: out + }; + }, + + // cacheLengths must be recalculated. + + /** + * [description] + * + * @method Phaser.Curves.Path#updateArcLengths + * @since 3.0.0 + */ + updateArcLengths: function () + { + this.cacheLengths = []; + + this.getCurveLengths(); + }, + + /** + * [description] + * + * @method Phaser.Curves.Path#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.curves.length = 0; + this.cacheLengths.length = 0; + this.startPoint = undefined; + } + +}); + +/** + * Creates a new Path Object. + * + * @method Phaser.GameObjects.GameObjectFactory#path + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Path. + * @param {number} y - The vertical position of this Path. + * + * @return {Phaser.Curves.Path} The Path Object that was created. + */ +GameObjectFactory.register('path', function (x, y) +{ + return new Path(x, y); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +module.exports = Path; + + +/***/ }), +/* 1014 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Curves + */ + +/** + * @typedef {object} JSONCurve + * + * @property {string} type - The of the curve + * @property {number[]} points - The arrays of points like `[x1, y1, x2, y2]` + */ + +module.exports = { + Path: __webpack_require__(1013), + + CubicBezier: __webpack_require__(391), + Curve: __webpack_require__(80), + Ellipse: __webpack_require__(389), + Line: __webpack_require__(388), + QuadraticBezier: __webpack_require__(387), + Spline: __webpack_require__(385) +}; + + +/***/ }), +/* 1015 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette inspired by Japanese computers like the MSX. + * + * @name Phaser.Create.Palettes.MSX + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#191028', + 2: '#46af45', + 3: '#a1d685', + 4: '#453e78', + 5: '#7664fe', + 6: '#833129', + 7: '#9ec2e8', + 8: '#dc534b', + 9: '#e18d79', + A: '#d6b97b', + B: '#e9d8a1', + C: '#216c4b', + D: '#d365c8', + E: '#afaab9', + F: '#fff' +}; + + +/***/ }), +/* 1016 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color JMP palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.JMP + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#191028', + 2: '#46af45', + 3: '#a1d685', + 4: '#453e78', + 5: '#7664fe', + 6: '#833129', + 7: '#9ec2e8', + 8: '#dc534b', + 9: '#e18d79', + A: '#d6b97b', + B: '#e9d8a1', + C: '#216c4b', + D: '#d365c8', + E: '#afaab9', + F: '#f5f4eb' +}; + + +/***/ }), +/* 1017 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color CGA inspired palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.CGA + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#2234d1', + 2: '#0c7e45', + 3: '#44aacc', + 4: '#8a3622', + 5: '#5c2e78', + 6: '#aa5c3d', + 7: '#b5b5b5', + 8: '#5e606e', + 9: '#4c81fb', + A: '#6cd947', + B: '#7be2f9', + C: '#eb8a60', + D: '#e23d69', + E: '#ffd93f', + F: '#fff' +}; + + +/***/ }), +/* 1018 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette inspired by the Commodore 64. + * + * @name Phaser.Create.Palettes.C64 + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#fff', + 2: '#8b4131', + 3: '#7bbdc5', + 4: '#8b41ac', + 5: '#6aac41', + 6: '#3931a4', + 7: '#d5de73', + 8: '#945a20', + 9: '#5a4100', + A: '#bd736a', + B: '#525252', + C: '#838383', + D: '#acee8b', + E: '#7b73de', + F: '#acacac' +}; + + +/***/ }), +/* 1019 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} Palette + * + * @property {string} 0 - Color value 1. + * @property {string} 1 - Color value 2. + * @property {string} 2 - Color value 3. + * @property {string} 3 - Color value 4. + * @property {string} 4 - Color value 5. + * @property {string} 5 - Color value 6. + * @property {string} 6 - Color value 7. + * @property {string} 7 - Color value 8. + * @property {string} 8 - Color value 9. + * @property {string} 9 - Color value 10. + * @property {string} A - Color value 11. + * @property {string} B - Color value 12. + * @property {string} C - Color value 13. + * @property {string} D - Color value 14. + * @property {string} E - Color value 15. + * @property {string} F - Color value 16. + */ + +/** + * @namespace Phaser.Create.Palettes + */ + +module.exports = { + + ARNE16: __webpack_require__(392), + C64: __webpack_require__(1018), + CGA: __webpack_require__(1017), + JMP: __webpack_require__(1016), + MSX: __webpack_require__(1015) + +}; + + +/***/ }), +/* 1020 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Create + */ + +module.exports = { + + GenerateTexture: __webpack_require__(393), + Palettes: __webpack_require__(1019) + +}; + + +/***/ }), +/* 1021 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(414); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(1); +var PluginCache = __webpack_require__(15); +var RectangleContains = __webpack_require__(43); + +/** + * @typedef {object} InputJSONCameraObject + * + * @property {string} [name=''] - The name of the Camera. + * @property {integer} [x=0] - The horizontal position of the Camera viewport. + * @property {integer} [y=0] - The vertical position of the Camera viewport. + * @property {integer} [width] - The width of the Camera viewport. + * @property {integer} [height] - The height of the Camera viewport. + * @property {number} [zoom=1] - The default zoom level of the Camera. + * @property {number} [rotation=0] - The rotation of the Camera, in radians. + * @property {boolean} [roundPixels=false] - Should the Camera round pixels before rendering? + * @property {number} [scrollX=0] - The horizontal scroll position of the Camera. + * @property {number} [scrollY=0] - The vertical scroll position of the Camera. + * @property {(false|string)} [backgroundColor=false] - A CSS color string controlling the Camera background color. + * @property {?object} [bounds] - Defines the Camera bounds. + * @property {number} [bounds.x=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.y=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.width] - The width of the Camera bounds. + * @property {number} [bounds.height] - The height of the Camera bounds. + */ + +/** + * @classdesc + * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. + * + * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed + * in your game config. + * + * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add + * the new Camera in using the `addExisting` method. + * + * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique + * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of + * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore + * Game Objects, make sure it's one of the first 31 created. + * + * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. + * + * @class CameraManager + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. + */ +var CameraManager = new Class({ + + initialize: + + function CameraManager (scene) + { + /** + * The Scene that owns the Camera Manager plugin. + * + * @name Phaser.Cameras.Scene2D.CameraManager#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` + * property set to match this value. By default it is set to match the value set in the + * game configuration, but can be changed at any point. Equally, individual cameras can + * also be changed as needed. + * + * @name Phaser.Cameras.Scene2D.CameraManager#roundPixels + * @type {boolean} + * @since 3.11.0 + */ + this.roundPixels = scene.sys.game.config.roundPixels; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * The Cameras are updated and rendered in the same order in which they appear in this array. + * Do not directly add or remove entries to this array. However, you can move the contents + * around the array should you wish to adjust the display order. + * + * @name Phaser.Cameras.Scene2D.CameraManager#cameras + * @type {Phaser.Cameras.Scene2D.Camera[]} + * @since 3.0.0 + */ + this.cameras = []; + + /** + * A handy reference to the 'main' camera. By default this is the first Camera the + * Camera Manager creates. You can also set it directly, or use the `makeMain` argument + * in the `add` and `addExisting` methods. It allows you to access it from your game: + * + * ```javascript + * var cam = this.cameras.main; + * ``` + * + * Also see the properties `camera1`, `camera2` and so on. + * + * @name Phaser.Cameras.Scene2D.CameraManager#main + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.0.0 + */ + this.main; + + /** + * This scale affects all cameras. It's used by the Scale Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#baseScale + * @type {number} + * @since 3.0.0 + */ + this.baseScale = 1; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Cameras.Scene2D.CameraManager#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + 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]; + + this.systems.events.once('destroy', this.destroy, 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.Cameras.Scene2D.CameraManager#start + * @private + * @since 3.5.0 + */ + start: function () + { + if (!this.main) + { + 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 = this.systems.events; + + eventEmitter.on('update', this.update, this); + eventEmitter.once('shutdown', this.shutdown, this); + }, + + /** + * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. + * + * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. + * + * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the + * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, + * pan and zoom. + * + * By default Cameras are transparent and will render anything that they can see based on their `scrollX` + * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. + * + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after creation if required. + * + * See the Camera class documentation for more details. + * + * @method Phaser.Cameras.Scene2D.CameraManager#add + * @since 3.0.0 + * + * @param {integer} [x=0] - The horizontal position of the Camera viewport. + * @param {integer} [y=0] - The vertical position of the Camera viewport. + * @param {integer} [width] - The width of the Camera viewport. If not given it'll be the game config size. + * @param {integer} [height] - The height of the Camera viewport. If not given it'll be the game config size. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. + * @param {string} [name=''] - The name of the Camera. + * + * @return {Phaser.Cameras.Scene2D.Camera} The newly created Camera. + */ + add: function (x, y, width, height, makeMain, name) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + if (makeMain === undefined) { makeMain = false; } + if (name === undefined) { name = ''; } + + var camera = new Camera(x, y, width, height); + + camera.setName(name); + camera.setScene(this.scene); + camera.setRoundPixels(this.roundPixels); + + camera.id = this.getNextID(); + + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + + return camera; + }, + + /** + * Adds an existing Camera into the Camera Manager. + * + * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after addition if required. + * + * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the + * manager. As long as it doesn't already exist in the manager it will be added then returned. + * + * If this method returns `null` then the Camera already exists in this Camera Manager. + * + * @method Phaser.Cameras.Scene2D.CameraManager#addExisting + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be added to the Camera Manager. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. + * + * @return {?Phaser.Cameras.Scene2D.Camera} The Camera that was added to the Camera Manager, or `null` if it couldn't be added. + */ + addExisting: function (camera, makeMain) + { + if (makeMain === undefined) { makeMain = false; } + + var index = this.cameras.indexOf(camera); + + if (index === -1) + { + camera.id = this.getNextID(); + + camera.setRoundPixels(this.roundPixels); + + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + + return camera; + } + + return null; + }, + + /** + * Gets the next available Camera ID number. + * + * The Camera Manager supports up to 31 unique cameras, after which the ID returned will always be zero. + * You can create additional cameras beyond 31, but they cannot be used for Game Object exclusion. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getNextID + * @private + * @since 3.11.0 + * + * @return {number} The next available Camera ID, or 0 if they're all already in use. + */ + getNextID: function () + { + var cameras = this.cameras; + + var testID = 1; + + // Find the first free camera ID we can use + + for (var t = 0; t < 32; t++) + { + var found = false; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera && camera.id === testID) + { + found = true; + continue; + } + } + + if (found) + { + testID = testID << 1; + } + else + { + return testID; + } + } + + return 0; + }, + + /** + * Gets the total number of Cameras in this Camera Manager. + * + * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getTotal + * @since 3.11.0 + * + * @param {boolean} [isVisible=false] - Set the `true` to only include visible Cameras in the total. + * + * @return {integer} The total number of Cameras in this Camera Manager. + */ + getTotal: function (isVisible) + { + if (isVisible === undefined) { isVisible = false; } + + var total = 0; + + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (!isVisible || (isVisible && camera.visible)) + { + total++; + } + } + + return total; + }, + + /** + * Populates this Camera Manager based on the given configuration object, or an array of config objects. + * + * See the `InputJSONCameraObject` documentation for details of the object structure. + * + * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON + * @since 3.0.0 + * + * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - A Camera configuration object, or an array of them, to be added to this Camera Manager. + * + * @return {Phaser.Cameras.Scene2D.CameraManager} This Camera Manager instance. + */ + fromJSON: function (config) + { + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var gameWidth = this.scene.sys.game.config.width; + var gameHeight = this.scene.sys.game.config.height; + + for (var i = 0; i < config.length; i++) + { + var cameraConfig = config[i]; + + var x = GetFastValue(cameraConfig, 'x', 0); + var y = GetFastValue(cameraConfig, 'y', 0); + var width = GetFastValue(cameraConfig, 'width', gameWidth); + var height = GetFastValue(cameraConfig, 'height', gameHeight); + + var camera = this.add(x, y, width, height); + + // Direct properties + camera.name = GetFastValue(cameraConfig, 'name', ''); + camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); + camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); + camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); + camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); + camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); + camera.visible = GetFastValue(cameraConfig, 'visible', true); + + // Background Color + + var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); + + if (backgroundColor) + { + camera.setBackgroundColor(backgroundColor); + } + + // Bounds + + var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); + + if (boundsConfig) + { + var bx = GetFastValue(boundsConfig, 'x', 0); + var by = GetFastValue(boundsConfig, 'y', 0); + var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); + var bheight = GetFastValue(boundsConfig, 'height', gameHeight); + + camera.setBounds(bx, by, bwidth, bheight); + } + } + + return this; + }, + + /** + * Gets a Camera based on its name. + * + * Camera names are optional and don't have to be set, so this method is only of any use if you + * have given your Cameras unique names. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCamera + * @since 3.0.0 + * + * @param {string} name - The name of the Camera. + * + * @return {?Phaser.Cameras.Scene2D.Camera} The first Camera with a name matching the given string, otherwise `null`. + */ + getCamera: function (name) + { + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) + { + if (cameras[i].name === name) + { + return cameras[i]; + } + } + + return null; + }, + + /** + * Returns an array of all cameras below the given Pointer. + * + * The first camera in the array is the top-most camera in the camera list. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCamerasBelowPointer + * @since 3.10.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check against. + * + * @return {Phaser.Cameras.Scene2D.Camera[]} An array of cameras below the Pointer. + */ + getCamerasBelowPointer: function (pointer) + { + var cameras = this.cameras; + + var x = pointer.x; + var y = pointer.y; + + var output = []; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera.visible && camera.inputEnabled && RectangleContains(camera, x, y)) + { + // So the top-most camera is at the top of the search array + output.unshift(camera); + } + } + + return output; + }, + + /** + * Removes the given Camera, or an array of Cameras, from this Camera Manager. + * + * If found in the Camera Manager it will be immediately removed from the local cameras array. + * If also currently the 'main' camera, 'main' will be reset to be camera 0. + * + * The removed Cameras are automatically destroyed if the `runDestroy` argument is `true`, which is the default. + * If you wish to re-use the cameras then set this to `false`, but know that they will retain their references + * and internal data until destroyed or re-added to a Camera Manager. + * + * @method Phaser.Cameras.Scene2D.CameraManager#remove + * @since 3.0.0 + * + * @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager. + * @param {boolean} [runDestroy=true] - Automatically call `Camera.destroy` on each Camera removed from this Camera Manager. + * + * @return {integer} The total number of Cameras removed. + */ + remove: function (camera, runDestroy) + { + if (runDestroy === undefined) { runDestroy = true; } + + if (!Array.isArray(camera)) + { + camera = [ camera ]; + } + + var total = 0; + var cameras = this.cameras; + + for (var i = 0; i < camera.length; i++) + { + var index = cameras.indexOf(camera[i]); + + if (index !== -1) + { + if (runDestroy) + { + cameras[index].destroy(); + } + + cameras.splice(index, 1); + + total++; + } + } + + if (!this.main && cameras[0]) + { + this.main = cameras[0]; + } + + return total; + }, + + /** + * The internal render method. This is called automatically by the Scene and should not be invoked directly. + * + * It will iterate through all local cameras and render them in turn, as long as they're visible and have + * an alpha level > 0. + * + * @method Phaser.Cameras.Scene2D.CameraManager#render + * @protected + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. + * @param {Phaser.GameObjects.GameObject[]} children - An array of renderable Game Objects. + * @param {number} interpolation - Interpolation value. Reserved for future use. + */ + render: function (renderer, children, interpolation) + { + var scene = this.scene; + var cameras = this.cameras; + var baseScale = this.baseScale; + var resolution = renderer.config.resolution; + + for (var i = 0; i < this.cameras.length; i++) + { + var camera = cameras[i]; + + if (camera.visible && camera.alpha > 0) + { + camera.preRender(baseScale, resolution); + + renderer.render(scene, children, interpolation, camera); + } + } + }, + + /** + * Resets this Camera Manager. + * + * This will iterate through all current Cameras, destroying them all, then it will reset the + * cameras array, reset the ID counter and create 1 new single camera using the default values. + * + * @method Phaser.Cameras.Scene2D.CameraManager#resetAll + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} The freshly created main Camera. + */ + resetAll: function () + { + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].destroy(); + } + + this.cameras = []; + + this.main = this.add(); + + return this.main; + }, + + /** + * The main update loop. Called automatically when the Scene steps. + * + * @method Phaser.Cameras.Scene2D.CameraManager#update + * @protected + * @since 3.0.0 + * + * @param {number} timestep - The timestep value. + * @param {number} delta - The delta value since the last frame. + */ + update: function (timestep, delta) + { + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].update(timestep, delta); + } + }, + + /** + * Resizes all cameras to the given dimensions. + * + * @method Phaser.Cameras.Scene2D.CameraManager#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the camera. + * @param {number} height - The new height of the camera. + */ + resize: function (width, height) + { + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].setSize(width, height); + } + }, + + /** + * 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 () + { + this.main = undefined; + + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].destroy(); + } + + this.cameras = []; + + 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; + } + +}); + +PluginCache.register('CameraManager', CameraManager, 'cameras'); + +module.exports = CameraManager; + + +/***/ }), +/* 1022 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); +var Class = __webpack_require__(0); +var EaseMap = __webpack_require__(192); + +/** + * @classdesc + * A Camera Zoom effect. + * + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * 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 Zoom + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.11.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Zoom = new Class({ + + initialize: + + function Zoom (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.11.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.11.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#duration + * @type {integer} + * @readonly + * @default 0 + * @since 3.11.0 + */ + this.duration = 0; + + /** + * The starting zoom value; + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#source + * @type {number} + * @since 3.11.0 + */ + this.source = 1; + + /** + * The destination zoom value. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#destination + * @type {number} + * @since 3.11.0 + */ + this.destination = 1; + + /** + * The ease function to use during the zoom. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#ease + * @type {function} + * @since 3.11.0 + */ + this.ease; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#progress + * @type {number} + * @since 3.11.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_elapsed + * @type {number} + * @private + * @since 3.11.0 + */ + this._elapsed = 0; + + /** + * @callback CameraZoomCallback + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. + * @param {number} progress - The progress of the effect. A value between 0 and 1. + * @param {number} zoom - The Camera's new zoom value. + */ + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdate + * @type {?CameraZoomCallback} + * @private + * @default null + * @since 3.11.0 + */ + this._onUpdate; + + /** + * On Complete callback scope. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdateScope + * @type {any} + * @private + * @since 3.11.0 + */ + this._onUpdateScope; + }, + + /** + * This event is fired when the Zoom effect begins to run on a camera. + * + * @event CameraZoomStartEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. + * @param {integer} duration - The duration of the effect. + * @param {number} zoom - The destination zoom value. + */ + + /** + * This event is fired when the Zoom effect completes. + * + * @event CameraZoomCompleteEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. + */ + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#start + * @fires CameraZoomStartEvent + * @fires CameraZoomCompleteEvent + * @since 3.11.0 + * + * @param {number} zoom - The target Camera zoom value. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the Zoom. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraZoomCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * and the current camera zoom value. + * @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 (zoom, duration, ease, force, callback, context) + { + if (duration === undefined) { duration = 1000; } + if (ease === undefined) { ease = EaseMap.Linear; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + var cam = this.camera; + + if (!force && this.isRunning) + { + return cam; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + // Starting from + this.source = cam.zoom; + + // Zooming to + this.destination = zoom; + + // Using this ease + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + this.ease = EaseMap[ease]; + } + else if (typeof ease === 'function') + { + this.ease = ease; + } + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit('camerazoomstart', this.camera, this, duration, zoom); + + return cam; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#update + * @since 3.11.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._elapsed < this.duration) + { + this.camera.zoom = this.source + ((this.destination - this.source) * this.ease(this.progress)); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.camera.zoom); + } + } + else + { + this.camera.zoom = this.destination; + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.destination); + } + + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#effectComplete + * @since 3.11.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit('camerazoomcomplete', 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.Zoom#reset + * @since 3.11.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.Zoom#destroy + * @since 3.11.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + } + +}); + +module.exports = Zoom; + + +/***/ }), +/* 1023 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @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 {number} + * @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 {number} 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 {number} 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._cw; + var height = this.camera._ch; + 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; + + +/***/ }), +/* 1024 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Stepped easing. + * + * @function Phaser.Math.Easing.Stepped.Stepped + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [steps=1] - The number of steps in the ease. + * + * @return {number} The tweened value. + */ +var Stepped = function (v, steps) +{ + if (steps === undefined) { steps = 1; } + + if (v <= 0) + { + return 0; + } + else if (v >= 1) + { + return 1; + } + else + { + return (((steps * v) | 0) + 1) * (1 / steps); + } +}; + +module.exports = Stepped; + + +/***/ }), +/* 1025 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sinusoidal ease-in/out. + * + * @function Phaser.Math.Easing.Sine.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 0.5 * (1 - Math.cos(Math.PI * v)); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1026 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sinusoidal ease-out. + * + * @function Phaser.Math.Easing.Sine.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return Math.sin(v * Math.PI / 2); + } +}; + +module.exports = Out; + + +/***/ }), +/* 1027 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sinusoidal ease-in. + * + * @function Phaser.Math.Easing.Sine.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 1 - Math.cos(v * Math.PI / 2); + } +}; + +module.exports = In; + + +/***/ }), +/* 1028 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quintic ease-in/out. + * + * @function Phaser.Math.Easing.Quintic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v * v * v + 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1029 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quintic ease-out. + * + * @function Phaser.Math.Easing.Quintic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return --v * v * v * v * v + 1; +}; + +module.exports = Out; + + +/***/ }), +/* 1030 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quintic ease-in. + * + * @function Phaser.Math.Easing.Quintic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v * v * v * v; +}; + +module.exports = In; + + +/***/ }), +/* 1031 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quartic ease-in/out. + * + * @function Phaser.Math.Easing.Quartic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v * v * v; + } + else + { + return -0.5 * ((v -= 2) * v * v * v - 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1032 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quartic ease-out. + * + * @function Phaser.Math.Easing.Quartic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return 1 - (--v * v * v * v); +}; + +module.exports = Out; + + +/***/ }), +/* 1033 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quartic ease-in. + * + * @function Phaser.Math.Easing.Quartic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v * v * v; +}; + +module.exports = In; + + +/***/ }), +/* 1034 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quadratic ease-in/out. + * + * @function Phaser.Math.Easing.Quadratic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v; + } + else + { + return -0.5 * (--v * (v - 2) - 1); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1035 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quadratic ease-out. + * + * @function Phaser.Math.Easing.Quadratic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return v * (2 - v); +}; + +module.exports = Out; + + +/***/ }), +/* 1036 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quadratic ease-in. + * + * @function Phaser.Math.Easing.Quadratic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v; +}; + +module.exports = In; + + +/***/ }), +/* 1037 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Linear easing (no variation). + * + * @function Phaser.Math.Easing.Linear.Linear + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Linear = function (v) +{ + return v; +}; + +module.exports = Linear; + + +/***/ }), +/* 1038 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Exponential ease-in/out. + * + * @function Phaser.Math.Easing.Expo.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * Math.pow(2, 10 * (v - 1)); + } + else + { + return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1039 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Exponential ease-out. + * + * @function Phaser.Math.Easing.Expo.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return 1 - Math.pow(2, -10 * v); +}; + +module.exports = Out; + + +/***/ }), +/* 1040 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Exponential ease-in. + * + * @function Phaser.Math.Easing.Expo.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return Math.pow(2, 10 * (v - 1)) - 0.001; +}; + +module.exports = In; + + +/***/ }), +/* 1041 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Elastic ease-in/out. + * + * @function Phaser.Math.Easing.Elastic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] + * + * @return {number} The tweened value. + */ +var InOut = function (v, amplitude, period) +{ + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } + + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; + + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + if ((v *= 2) < 1) + { + return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } + else + { + return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; + } + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1042 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Elastic ease-out. + * + * @function Phaser.Math.Easing.Elastic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] + * + * @return {number} The tweened value. + */ +var Out = function (v, amplitude, period) +{ + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } + + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; + + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); + } +}; + +module.exports = Out; + + +/***/ }), +/* 1043 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Elastic ease-in. + * + * @function Phaser.Math.Easing.Elastic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] + * + * @return {number} The tweened value. + */ +var In = function (v, amplitude, period) +{ + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } + + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; + + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } +}; + +module.exports = In; + + +/***/ }), +/* 1044 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Cubic ease-in/out. + * + * @function Phaser.Math.Easing.Cubic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v + 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1045 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Cubic ease-out. + * + * @function Phaser.Math.Easing.Cubic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return --v * v * v + 1; +}; + +module.exports = Out; + + +/***/ }), +/* 1046 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Cubic ease-in. + * + * @function Phaser.Math.Easing.Cubic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v * v; +}; + +module.exports = In; + + +/***/ }), +/* 1047 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Circular ease-in/out. + * + * @function Phaser.Math.Easing.Circular.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return -0.5 * (Math.sqrt(1 - v * v) - 1); + } + else + { + return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1048 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Circular ease-out. + * + * @function Phaser.Math.Easing.Circular.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return Math.sqrt(1 - (--v * v)); +}; + +module.exports = Out; + + +/***/ }), +/* 1049 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Circular ease-in. + * + * @function Phaser.Math.Easing.Circular.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return 1 - Math.sqrt(1 - v * v); +}; + +module.exports = In; + + +/***/ }), +/* 1050 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Bounce ease-in/out. + * + * @function Phaser.Math.Easing.Bounce.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + var reverse = false; + + if (v < 0.5) + { + v = 1 - (v * 2); + reverse = true; + } + else + { + v = (v * 2) - 1; + } + + if (v < 1 / 2.75) + { + v = 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } + + if (reverse) + { + return (1 - v) * 0.5; + } + else + { + return v * 0.5 + 0.5; + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1051 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Bounce ease-out. + * + * @function Phaser.Math.Easing.Bounce.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + if (v < 1 / 2.75) + { + return 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } +}; + +module.exports = Out; + + +/***/ }), +/* 1052 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Bounce ease-in. + * + * @function Phaser.Math.Easing.Bounce.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + v = 1 - v; + + if (v < 1 / 2.75) + { + return 1 - (7.5625 * v * v); + } + else if (v < 2 / 2.75) + { + return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); + } + else if (v < 2.5 / 2.75) + { + return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); + } + else + { + return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); + } +}; + +module.exports = In; + + +/***/ }), +/* 1053 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Back ease-in/out. + * + * @function Phaser.Math.Easing.Back.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [overshoot=1.70158] - The overshoot amount. + * + * @return {number} The tweened value. + */ +var InOut = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } + + var s = overshoot * 1.525; + + if ((v *= 2) < 1) + { + return 0.5 * (v * v * ((s + 1) * v - s)); + } + else + { + return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 1054 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Back ease-out. + * + * @function Phaser.Math.Easing.Back.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [overshoot=1.70158] - The overshoot amount. + * + * @return {number} The tweened value. + */ +var Out = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } + + return --v * v * ((overshoot + 1) * v + overshoot) + 1; +}; + +module.exports = Out; + + +/***/ }), +/* 1055 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Back ease-in. + * + * @function Phaser.Math.Easing.Back.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [overshoot=1.70158] - The overshoot amount. + * + * @return {number} The tweened value. + */ +var In = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } + + return v * v * ((overshoot + 1) * v - overshoot); +}; + +module.exports = In; + + +/***/ }), +/* 1056 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); +var EaseMap = __webpack_require__(192); + +/** + * @classdesc + * A Camera Pan effect. + * + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * Only the camera scroll 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 Pan + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.11.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Pan = new Class({ + + initialize: + + function Pan (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.11.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.11.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#duration + * @type {integer} + * @readonly + * @default 0 + * @since 3.11.0 + */ + this.duration = 0; + + /** + * The starting scroll coordinates to pan the camera from. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#source + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.source = new Vector2(); + + /** + * The constantly updated value based on zoom. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#current + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.current = new Vector2(); + + /** + * The destination scroll coordinates to pan the camera to. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#destination + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.destination = new Vector2(); + + /** + * The ease function to use during the pan. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#ease + * @type {function} + * @since 3.11.0 + */ + this.ease; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#progress + * @type {number} + * @since 3.11.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_elapsed + * @type {number} + * @private + * @since 3.11.0 + */ + this._elapsed = 0; + + /** + * @callback CameraPanCallback + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. + * @param {number} progress - The progress of the effect. A value between 0 and 1. + * @param {number} x - The Camera's new scrollX coordinate. + * @param {number} y - The Camera's new scrollY coordinate. + */ + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdate + * @type {?CameraPanCallback} + * @private + * @default null + * @since 3.11.0 + */ + this._onUpdate; + + /** + * On Complete callback scope. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdateScope + * @type {any} + * @private + * @since 3.11.0 + */ + this._onUpdateScope; + }, + + /** + * This event is fired when the pan effect begins to run on a camera. + * + * @event CameraPanStartEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. + * @param {integer} duration - The duration of the effect. + * @param {number} x - The destination scroll x coordinate. + * @param {number} y - The destination scroll y coordinate. + */ + + /** + * This event is fired when the pan effect completes. + * + * @event CameraPanCompleteEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. + */ + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#start + * @fires CameraPanStartEvent + * @fires CameraPanCompleteEvent + * @since 3.11.0 + * + * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. + * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @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 (x, y, duration, ease, force, callback, context) + { + if (duration === undefined) { duration = 1000; } + if (ease === undefined) { ease = EaseMap.Linear; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + var cam = this.camera; + + if (!force && this.isRunning) + { + return cam; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + // Starting from + this.source.set(cam.scrollX, cam.scrollY); + + // Destination + this.destination.set(x, y); + + // Zoom factored version + cam.getScroll(x, y, this.current); + + // Using this ease + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + this.ease = EaseMap[ease]; + } + else if (typeof ease === 'function') + { + this.ease = ease; + } + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit('camerapanstart', this.camera, this, duration, x, y); + + return cam; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#update + * @since 3.11.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; + + var progress = Clamp(this._elapsed / this.duration, 0, 1); + + this.progress = progress; + + var cam = this.camera; + + if (this._elapsed < this.duration) + { + var v = this.ease(progress); + + cam.getScroll(this.destination.x, this.destination.y, this.current); + + var x = this.source.x + ((this.current.x - this.source.x) * v); + var y = this.source.y + ((this.current.y - this.source.y) * v); + + cam.setScroll(x, y); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, x, y); + } + } + else + { + cam.centerOn(this.destination.x, this.destination.y); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, cam.scrollX, cam.scrollY); + } + + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#effectComplete + * @since 3.11.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit('camerapancomplete', 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.Pan#reset + * @since 3.11.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.Pan#destroy + * @since 3.11.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + this.source = null; + this.destination = null; + } + +}); + +module.exports = Pan; + + +/***/ }), +/* 1057 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); +var Class = __webpack_require__(0); + +/** + * @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 {number} + * @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 {number} + * @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 {number} 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._cx, camera._cy, camera._cw, camera._ch); + + return true; + }, + + /** + * Called internally by the WebGL Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderWebGL + * @since 3.5.0 + * + * @param {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} 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.drawFillRect( + camera._cx, camera._cy, camera._cw, camera._ch, + getTintFunction(red, green, blue, 1), + this.alpha + ); + + 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; + + +/***/ }), +/* 1058 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(24); +var Class = __webpack_require__(0); + +/** + * @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 {number} + * @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 {number} + * @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 {number} 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._cx, camera._cy, camera._cw, camera._ch); + + return true; + }, + + /** + * Called internally by the WebGL Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderWebGL + * @since 3.5.0 + * + * @param {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} 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.drawFillRect( + camera._cx, camera._cy, camera._cw, camera._ch, + getTintFunction(red, green, blue, 1), + this.alpha + ); + + 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; + + +/***/ }), +/* 1059 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Scene2D + */ + +module.exports = { + + Camera: __webpack_require__(414), + CameraManager: __webpack_require__(1021), + Effects: __webpack_require__(406) + +}; + + +/***/ }), +/* 1060 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetValue = __webpack_require__(4); + +// var controlConfig = { +// camera: this.cameras.main, +// left: cursors.left, +// right: cursors.right, +// up: cursors.up, +// down: cursors.down, +// zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), +// zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), +// zoomSpeed: 0.02, +// acceleration: 0.06, +// drag: 0.0005, +// maxSpeed: 1.0 +// }; + +/** + * @typedef {object} SmoothedKeyControlConfig + * + * @property {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera that this Control will update. + * @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left. + * @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right. + * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. + * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. + * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. + * @property {(number|{x:number,y:number})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. + * @property {(number|{x:number,y:number})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. + */ + +/** + * @classdesc + * [description] + * + * @class SmoothedKeyControl + * @memberof Phaser.Cameras.Controls + * @constructor + * @since 3.0.0 + * + * @param {SmoothedKeyControlConfig} config - [description] + */ +var SmoothedKeyControl = new Class({ + + initialize: + + function SmoothedKeyControl (config) + { + /** + * The Camera that this Control will update. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#camera + * @type {?Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = GetValue(config, 'camera', null); + + /** + * The Key to be pressed that will move the Camera left. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#left + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.left = GetValue(config, 'left', null); + + /** + * The Key to be pressed that will move the Camera right. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#right + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.right = GetValue(config, 'right', null); + + /** + * The Key to be pressed that will move the Camera up. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#up + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.up = GetValue(config, 'up', null); + + /** + * The Key to be pressed that will move the Camera down. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#down + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.down = GetValue(config, 'down', null); + + /** + * The Key to be pressed that will zoom the Camera in. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomIn + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomIn = GetValue(config, 'zoomIn', null); + + /** + * The Key to be pressed that will zoom the Camera out. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomOut + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomOut = GetValue(config, 'zoomOut', null); + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed + * @type {number} + * @default 0.01 + * @since 3.0.0 + */ + this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); + + /** + * The horizontal acceleration the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelX = 0; + + /** + * The vertical acceleration the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelY = 0; + + var accel = GetValue(config, 'acceleration', null); + + if (typeof accel === 'number') + { + this.accelX = accel; + this.accelY = accel; + } + else + { + this.accelX = GetValue(config, 'acceleration.x', 0); + this.accelY = GetValue(config, 'acceleration.y', 0); + } + + /** + * The horizontal drag applied to the camera when it is moving. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragX = 0; + + /** + * The vertical drag applied to the camera when it is moving. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.dragY = 0; + + var drag = GetValue(config, 'drag', null); + + if (typeof drag === 'number') + { + this.dragX = drag; + this.dragY = drag; + } + else + { + this.dragX = GetValue(config, 'drag.x', 0); + this.dragY = GetValue(config, 'drag.y', 0); + } + + /** + * The maximum horizontal speed the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.maxSpeedX = 0; + + /** + * The maximum vertical speed the camera will move. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.maxSpeedY = 0; + + var maxSpeed = GetValue(config, 'maxSpeed', null); + + if (typeof maxSpeed === 'number') + { + this.maxSpeedX = maxSpeed; + this.maxSpeedY = maxSpeed; + } + else + { + this.maxSpeedX = GetValue(config, 'maxSpeed.x', 0); + this.maxSpeedY = GetValue(config, 'maxSpeed.y', 0); + } + + /** + * [description] + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedX + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._speedX = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedY + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._speedY = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#_zoom + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._zoom = 0; + + /** + * A flag controlling if the Controls will update the Camera or not. + * + * @name Phaser.Cameras.Controls.SmoothedKeyControl#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = (this.camera !== null); + }, + + /** + * Starts the Key Control running, providing it has been linked to a camera. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#start + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. + */ + start: function () + { + this.active = (this.camera !== null); + + return this; + }, + + /** + * Stops this Key Control from running. Call `start` to start it again. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#stop + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. + */ + stop: function () + { + this.active = false; + + return this; + }, + + /** + * Binds this Key Control to a camera. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#setCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. + * + * @return {Phaser.Cameras.Controls.SmoothedKeyControl} This Key Control instance. + */ + setCamera: function (camera) + { + this.camera = camera; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#update + * @since 3.0.0 + * + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (delta) + { + if (!this.active) + { + return; + } + + if (delta === undefined) { delta = 1; } + + var cam = this.camera; + + // Apply Deceleration + + if (this._speedX > 0) + { + this._speedX -= this.dragX * delta; + + if (this._speedX < 0) + { + this._speedX = 0; + } + } + else if (this._speedX < 0) + { + this._speedX += this.dragX * delta; + + if (this._speedX > 0) + { + this._speedX = 0; + } + } + + if (this._speedY > 0) + { + this._speedY -= this.dragY * delta; + + if (this._speedY < 0) + { + this._speedY = 0; + } + } + else if (this._speedY < 0) + { + this._speedY += this.dragY * delta; + + if (this._speedY > 0) + { + this._speedY = 0; + } + } + + // Check for keys + + if (this.up && this.up.isDown) + { + this._speedY += this.accelY; + + if (this._speedY > this.maxSpeedY) + { + this._speedY = this.maxSpeedY; + } + } + else if (this.down && this.down.isDown) + { + this._speedY -= this.accelY; + + if (this._speedY < -this.maxSpeedY) + { + this._speedY = -this.maxSpeedY; + } + } + + if (this.left && this.left.isDown) + { + this._speedX += this.accelX; + + if (this._speedX > this.maxSpeedX) + { + this._speedX = this.maxSpeedX; + } + } + else if (this.right && this.right.isDown) + { + this._speedX -= this.accelX; + + if (this._speedX < -this.maxSpeedX) + { + this._speedX = -this.maxSpeedX; + } + } + + // Camera zoom + + if (this.zoomIn && this.zoomIn.isDown) + { + this._zoom = -this.zoomSpeed; + } + else if (this.zoomOut && this.zoomOut.isDown) + { + this._zoom = this.zoomSpeed; + } + else + { + this._zoom = 0; + } + + // Apply to Camera + + if (this._speedX !== 0) + { + cam.scrollX -= ((this._speedX * delta) | 0); + } + + if (this._speedY !== 0) + { + cam.scrollY -= ((this._speedY * delta) | 0); + } + + if (this._zoom !== 0) + { + cam.zoom += this._zoom; + + if (cam.zoom < 0.1) + { + cam.zoom = 0.1; + } + } + }, + + /** + * Destroys this Key Control. + * + * @method Phaser.Cameras.Controls.SmoothedKeyControl#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + + this.left = null; + this.right = null; + this.up = null; + this.down = null; + + this.zoomIn = null; + this.zoomOut = null; + } + +}); + +module.exports = SmoothedKeyControl; + + +/***/ }), +/* 1061 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetValue = __webpack_require__(4); + +// var camControl = new CameraControl({ +// camera: this.cameras.main, +// left: cursors.left, +// right: cursors.right, +// speed: float OR { x: 0, y: 0 } +// }) + +/** + * @typedef {object} FixedKeyControlConfig + * + * @property {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera that this Control will update. + * @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left. + * @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right. + * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. + * @property {Phaser.Input.Keyboard.Key} [down] - The Key to be pressed that will move the Camera down. + * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. + * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [speed=0] - The horizontal and vertical speed the camera will move. + */ + +/** + * @classdesc + * [description] + * + * @class FixedKeyControl + * @memberof Phaser.Cameras.Controls + * @constructor + * @since 3.0.0 + * + * @param {FixedKeyControlConfig} config - [description] + */ +var FixedKeyControl = new Class({ + + initialize: + + function FixedKeyControl (config) + { + /** + * The Camera that this Control will update. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#camera + * @type {?Phaser.Cameras.Scene2D.Camera} + * @default null + * @since 3.0.0 + */ + this.camera = GetValue(config, 'camera', null); + + /** + * The Key to be pressed that will move the Camera left. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#left + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.left = GetValue(config, 'left', null); + + /** + * The Key to be pressed that will move the Camera right. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#right + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.right = GetValue(config, 'right', null); + + /** + * The Key to be pressed that will move the Camera up. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#up + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.up = GetValue(config, 'up', null); + + /** + * The Key to be pressed that will move the Camera down. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#down + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.down = GetValue(config, 'down', null); + + /** + * The Key to be pressed that will zoom the Camera in. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomIn + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomIn = GetValue(config, 'zoomIn', null); + + /** + * The Key to be pressed that will zoom the Camera out. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomOut + * @type {?Phaser.Input.Keyboard.Key} + * @default null + * @since 3.0.0 + */ + this.zoomOut = GetValue(config, 'zoomOut', null); + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed + * @type {number} + * @default 0.01 + * @since 3.0.0 + */ + this.zoomSpeed = GetValue(config, 'zoomSpeed', 0.01); + + /** + * The horizontal speed the camera will move. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#speedX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speedX = 0; + + /** + * The vertical speed the camera will move. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#speedY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speedY = 0; + + var speed = GetValue(config, 'speed', null); + + if (typeof speed === 'number') + { + this.speedX = speed; + this.speedY = speed; + } + else + { + this.speedX = GetValue(config, 'speed.x', 0); + this.speedY = GetValue(config, 'speed.y', 0); + } + + /** + * [description] + * + * @name Phaser.Cameras.Controls.FixedKeyControl#_zoom + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._zoom = 0; + + /** + * A flag controlling if the Controls will update the Camera or not. + * + * @name Phaser.Cameras.Controls.FixedKeyControl#active + * @type {boolean} + * @since 3.0.0 + */ + this.active = (this.camera !== null); + }, + + /** + * Starts the Key Control running, providing it has been linked to a camera. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#start + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. + */ + start: function () + { + this.active = (this.camera !== null); + + return this; + }, + + /** + * Stops this Key Control from running. Call `start` to start it again. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#stop + * @since 3.0.0 + * + * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. + */ + stop: function () + { + this.active = false; + + return this; + }, + + /** + * Binds this Key Control to a camera. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#setCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to bind this Key Control to. + * + * @return {Phaser.Cameras.Controls.FixedKeyControl} This Key Control instance. + */ + setCamera: function (camera) + { + this.camera = camera; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Controls.FixedKeyControl#update + * @since 3.0.0 + * + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update: function (delta) + { + if (!this.active) + { + return; + } + + if (delta === undefined) { delta = 1; } + + var cam = this.camera; + + if (this.up && this.up.isDown) + { + cam.scrollY -= ((this.speedY * delta) | 0); + } + else if (this.down && this.down.isDown) + { + cam.scrollY += ((this.speedY * delta) | 0); + } + + if (this.left && this.left.isDown) + { + cam.scrollX -= ((this.speedX * delta) | 0); + } + else if (this.right && this.right.isDown) + { + cam.scrollX += ((this.speedX * delta) | 0); + } + + // Camera zoom + + if (this.zoomIn && this.zoomIn.isDown) + { + cam.zoom -= this.zoomSpeed; + + if (cam.zoom < 0.1) + { + cam.zoom = 0.1; + } + } + else if (this.zoomOut && this.zoomOut.isDown) + { + cam.zoom += this.zoomSpeed; + } + }, + + /** + * Destroys this Key Control. + * + * @method Phaser.Cameras.Controls.FixedKeyControl#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.camera = null; + + this.left = null; + this.right = null; + this.up = null; + this.down = null; + + this.zoomIn = null; + this.zoomOut = null; + } + +}); + +module.exports = FixedKeyControl; + + +/***/ }), +/* 1062 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras.Controls + */ + +module.exports = { + + FixedKeyControl: __webpack_require__(1061), + SmoothedKeyControl: __webpack_require__(1060) + +}; + + +/***/ }), +/* 1063 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cameras + */ + +module.exports = { + + Controls: __webpack_require__(1062), + Scene2D: __webpack_require__(1059) + +}; + + +/***/ }), +/* 1064 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cache + */ + +module.exports = { + + BaseCache: __webpack_require__(416), + CacheManager: __webpack_require__(415) + +}; + + +/***/ }), +/* 1065 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Animations + */ + +module.exports = { + + Animation: __webpack_require__(420), + AnimationFrame: __webpack_require__(418), + AnimationManager: __webpack_require__(417) + +}; + + +/***/ }), +/* 1066 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author samme + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Wrap = __webpack_require__(59); + +/** + * Wrap each item's coordinates within a rectangle's area. + * + * @function Phaser.Actions.WrapInRectangle + * @since 3.0.0 + * @see Phaser.Math.Wrap + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - The rectangle. + * @param {number} [padding=0] - An amount added to each side of the rectangle during the operation. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var WrapInRectangle = function (items, rect, padding) +{ + if (padding === undefined) + { + padding = 0; + } + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + item.x = Wrap(item.x, rect.left - padding, rect.right + padding); + item.y = Wrap(item.y, rect.top - padding, rect.bottom + padding); + } + + return items; +}; + +module.exports = WrapInRectangle; + + +/***/ }), +/* 1067 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects and toggles the visibility of each one. + * Those previously `visible = false` will become `visible = true`, and vice versa. + * + * @function Phaser.Actions.ToggleVisible + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var ToggleVisible = function (items) +{ + for (var i = 0; i < items.length; i++) + { + items[i].visible = !items[i].visible; + } + + return items; +}; + +module.exports = ToggleVisible; + + +/***/ }), +/* 1068 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, the + * calculated spread value. + * + * The spread value is derived from the given `min` and `max` values and the total number of items in the array.//#endregion + * + * For example, to cause an array of Sprites to change in alpha from 0 to 1 you could call: + * + * ```javascript + * Phaser.Actions.Spread(itemsArray, 'alpha', 0, 1); + * ``` + * + * @function Phaser.Actions.Spread + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - The property of the Game Object to spread. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that were passed to this Action. + */ +var Spread = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += i * step; + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = i * step; + } + } + + return items; +}; + +module.exports = Spread; + + +/***/ }), +/* 1069 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathSmoothStep = __webpack_require__(199); + +/** + * Smoothstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. + * + * @function Phaser.Actions.SmoothStep + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The minimum interpolation value. + * @param {number} max - The maximum interpolation value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var SmoothStep = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += MathSmoothStep(i * step, min, max); + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = MathSmoothStep(i * step, min, max); + } + } + + return items; +}; + +module.exports = SmoothStep; + + +/***/ }), +/* 1070 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathSmootherStep = __webpack_require__(200); + +/** + * Smootherstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. + * + * @function Phaser.Actions.SmootherStep + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The minimum interpolation value. + * @param {number} max - The maximum interpolation value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var SmootherStep = function (items, property, min, max, inc) +{ + if (inc === undefined) { inc = false; } + + var step = Math.abs(max - min) / items.length; + var i; + + if (inc) + { + for (i = 0; i < items.length; i++) + { + items[i][property] += MathSmootherStep(i * step, min, max); + } + } + else + { + for (i = 0; i < items.length; i++) + { + items[i][property] = MathSmootherStep(i * step, min, max); + } + } + + return items; +}; + +module.exports = SmootherStep; + + +/***/ }), +/* 1071 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayShuffle = __webpack_require__(132); + +/** + * Shuffles the array in place. The shuffled array is both modified and returned. + * + * @function Phaser.Actions.Shuffle + * @since 3.0.0 + * @see Phaser.Utils.Array.Shuffle + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var Shuffle = function (items) +{ + return ArrayShuffle(items); +}; + +module.exports = Shuffle; + + +/***/ }), +/* 1072 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector2 = __webpack_require__(3); + +/** + * Iterate through the items array changing the position of each element to be that of the element that came before + * it in the array (or after it if direction = 1) + * + * The first items position is set to x/y. + * + * The final x/y coords are returned + * + * @function Phaser.Actions.ShiftPosition + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items] + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {number} x - The x coordinate to place the first item in the array at. + * @param {number} y - The y coordinate to place the first item in the array at. + * @param {integer} [direction=0] - The iteration direction. 0 = first to last and 1 = last to first. + * @param {(Phaser.Math.Vector2|object)} [output] - An optional objec to store the final objects position in. + * + * @return {Phaser.Math.Vector2} The output vector. + */ +var ShiftPosition = function (items, x, y, direction, output) +{ + if (direction === undefined) { direction = 0; } + if (output === undefined) { output = new Vector2(); } + + var px; + var py; + + if (items.length > 1) + { + var i; + var cx; + var cy; + var cur; + + if (direction === 0) + { + // Bottom to Top + + var len = items.length - 1; + + px = items[len].x; + py = items[len].y; + + for (i = len - 1; i >= 0; i--) + { + // Current item + cur = items[i]; + + // Get current item x/y, to be passed to the next item in the list + cx = cur.x; + cy = cur.y; + + // Set current item to the previous items x/y + cur.x = px; + cur.y = py; + + // Set current as previous + px = cx; + py = cy; + } + + // Update the head item to the new x/y coordinates + items[len].x = x; + items[len].y = y; + } + else + { + // Top to Bottom + + px = items[0].x; + py = items[0].y; + + for (i = 1; i < items.length; i++) + { + // Current item + cur = items[i]; + + // Get current item x/y, to be passed to the next item in the list + cx = cur.x; + cy = cur.y; + + // Set current item to the previous items x/y + cur.x = px; + cur.y = py; + + // Set current as previous + px = cx; + py = cy; + } + + // Update the head item to the new x/y coordinates + items[0].x = x; + items[0].y = y; + } + } + else + { + px = items[0].x; + py = items[0].y; + + items[0].x = x; + items[0].y = y; + } + + // Return the final set of coordinates as they're effectively lost from the shift and may be needed + + output.x = px; + output.y = py; + + return output; +}; + +module.exports = ShiftPosition; + + +/***/ }), +/* 1073 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public property `y` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetY = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'y', value, step, index, direction); +}; + +module.exports = SetY; + + +/***/ }), +/* 1074 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `x` and `y` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetXY(group.getChildren(), x, y, stepX, stepY)` + * + * @function Phaser.Actions.SetXY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} x - The amount to set the `x` property to. + * @param {number} [y=x] - The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetXY = function (items, x, y, stepX, stepY, index, direction) +{ + if (y === undefined || y === null) { y = x; } + + PropertyValueSet(items, 'x', x, stepX, index, direction); + + return PropertyValueSet(items, 'y', y, stepY, index, direction); +}; + +module.exports = SetXY; + + +/***/ }), +/* 1075 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public property `x` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetX = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'x', value, step, index, direction); +}; + +module.exports = SetX; + + +/***/ }), +/* 1076 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public property `visible` + * and then sets it to the given value. + * + * To use this with a Group: `SetVisible(group.getChildren(), value)` + * + * @function Phaser.Actions.SetVisible + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {boolean} value - The value to set the property to. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetVisible = function (items, value, index, direction) +{ + return PropertyValueSet(items, 'visible', value, 0, index, direction); +}; + +module.exports = SetVisible; + + +/***/ }), +/* 1077 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have the public method setTint() and then updates it to the given value(s). You can specify tint color per corner or provide only one color value for `topLeft` parameter, in which case whole item will be tinted with that color. + * + * @function Phaser.Actions.SetTint + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {number} topLeft - The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. + * @param {number} [topRight] - The tint to be applied to top-right corner of item. + * @param {number} [bottomLeft] - The tint to be applied to the bottom-left corner of item. + * @param {number} [bottomRight] - The tint to be applied to the bottom-right corner of item. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight) +{ + for (var i = 0; i < items.length; i++) + { + items[i].setTint(topLeft, topRight, bottomLeft, bottomRight); + } + + return items; +}; + +module.exports = SetTint; + + +/***/ }), +/* 1078 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scaleY` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScaleY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScaleY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetScaleY = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scaleY', value, step, index, direction); +}; + +module.exports = SetScaleY; + + +/***/ }), +/* 1079 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public property `scaleX` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScaleX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetScaleX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetScaleX = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'scaleX', value, step, index, direction); +}; + +module.exports = SetScaleX; + + +/***/ }), +/* 1080 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetScale(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * + * @function Phaser.Actions.SetScale + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} scaleX - The amount to set the `scaleX` property to. + * @param {number} [scaleY] - The amount to set the `scaleY` property to. If `undefined` or `null` it uses the `scaleX` value. + * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetScale = function (items, scaleX, scaleY, stepX, stepY, index, direction) +{ + if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } + + PropertyValueSet(items, 'scaleX', scaleX, stepX, index, direction); + + return PropertyValueSet(items, 'scaleY', scaleY, stepY, index, direction); +}; + +module.exports = SetScale; + + +/***/ }), +/* 1081 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public property `rotation` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetRotation(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetRotation + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetRotation = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'rotation', value, step, index, direction); +}; + +module.exports = SetRotation; + + +/***/ }), +/* 1082 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY` + * and then sets them to the given values. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetOrigin(group.getChildren(), originX, originY, stepX, stepY)` + * + * @function Phaser.Actions.SetOrigin + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} originX - The amount to set the `originX` property to. + * @param {number} [originY] - The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. + * @param {number} [stepX=0] - This is added to the `originX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `originY` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetOrigin = function (items, originX, originY, stepX, stepY, index, direction) +{ + if (originY === undefined || originY === null) { originY = originX; } + + PropertyValueSet(items, 'originX', originX, stepX, index, direction); + + return PropertyValueSet(items, 'originY', originY, stepY, index, direction); +}; + +module.exports = SetOrigin; + + +/***/ }), +/* 1083 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. + * + * @see {@link Phaser.GameObjects.GameObject#setInteractive} + * + * @function Phaser.Actions.SetHitArea + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var SetHitArea = function (items, hitArea, hitAreaCallback) +{ + for (var i = 0; i < items.length; i++) + { + items[i].setInteractive(hitArea, hitAreaCallback); + } + + return items; +}; + +module.exports = SetHitArea; + + +/***/ }), +/* 1084 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public property `depth` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetDepth(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetDepth + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetDepth = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'depth', value, step, index, direction); +}; + +module.exports = SetDepth; + + +/***/ }), +/* 1085 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public property `blendMode` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetBlendMode(group.getChildren(), value)` + * + * @function Phaser.Actions.SetBlendMode + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetBlendMode = function (items, value, index, direction) +{ + return PropertyValueSet(items, 'blendMode', value, 0, index, direction); +}; + +module.exports = SetBlendMode; + + +/***/ }), +/* 1086 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueSet = __webpack_require__(27); + +/** + * Takes an array of Game Objects, or any objects that have the public property `alpha` + * and then sets it to the given value. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `SetAlpha(group.getChildren(), value, step)` + * + * @function Phaser.Actions.SetAlpha + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var SetAlpha = function (items, value, step, index, direction) +{ + return PropertyValueSet(items, 'alpha', value, step, index, direction); +}; + +module.exports = SetAlpha; + + +/***/ }), +/* 1087 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(37); + +/** + * Takes an array of Game Objects, or any objects that have a public `scaleY` property, + * and then adds the given value to each of their `scaleY` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.ScaleY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `scaleY` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var ScaleY = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'scaleY', value, step, index, direction); +}; + +module.exports = ScaleY; + + +/***/ }), +/* 1088 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(37); + +/** + * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleXY(group.getChildren(), scaleX, scaleY, stepX, stepY)` + * + * @function Phaser.Actions.ScaleXY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} scaleX - The amount to be added to the `scaleX` property. + * @param {number} [scaleY] - The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value. + * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var ScaleXY = function (items, scaleX, scaleY, stepX, stepY, index, direction) +{ + if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } + + PropertyValueInc(items, 'scaleX', scaleX, stepX, index, direction); + + return PropertyValueInc(items, 'scaleY', scaleY, stepY, index, direction); +}; + +module.exports = ScaleXY; + + +/***/ }), +/* 1089 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(37); + +/** + * Takes an array of Game Objects, or any objects that have a public `scaleX` property, + * and then adds the given value to each of their `scaleX` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `ScaleX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.ScaleX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `scaleX` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var ScaleX = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'scaleX', value, step, index, direction); +}; + +module.exports = ScaleX; + + +/***/ }), +/* 1090 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathRotateAroundDistance = __webpack_require__(201); + +/** + * Rotates an array of Game Objects around a point by the given angle and distance. + * + * @function Phaser.Actions.RotateAroundDistance + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {object} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * @param {number} distance - The distance from the point of rotation in pixels. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RotateAroundDistance = function (items, point, angle, distance) +{ + var x = point.x; + var y = point.y; + + // There's nothing to do + if (distance === 0) + { + return items; + } + + for (var i = 0; i < items.length; i++) + { + MathRotateAroundDistance(items[i], x, y, angle, distance); + } + + return items; +}; + +module.exports = RotateAroundDistance; + + +/***/ }), +/* 1091 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundDistance = __webpack_require__(201); +var DistanceBetween = __webpack_require__(58); + +/** + * Rotates each item around the given point by the given angle. + * + * @function Phaser.Actions.RotateAround + * @since 3.0.0 + * @see Phaser.Math.RotateAroundDistance + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {object} point - Any object with public `x` and `y` properties. + * @param {number} angle - The angle to rotate by, in radians. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RotateAround = function (items, point, angle) +{ + var x = point.x; + var y = point.y; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + RotateAroundDistance(item, x, y, angle, Math.max(1, DistanceBetween(item.x, item.y, x, y))); + } + + return items; +}; + +module.exports = RotateAround; + + +/***/ }), +/* 1092 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(37); + +/** + * Takes an array of Game Objects, or any objects that have a public `rotation` property, + * and then adds the given value to each of their `rotation` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Rotate(group.getChildren(), value, step)` + * + * @function Phaser.Actions.Rotate + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `rotation` property (in radians). + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var Rotate = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'rotation', value, step, index, direction); +}; + +module.exports = Rotate; + + +/***/ }), +/* 1093 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(202); + +/** + * Takes an array of Game Objects and positions them at random locations within the Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.RandomTriangle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects within. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomTriangle = function (items, triangle) +{ + for (var i = 0; i < items.length; i++) + { + Random(triangle, items[i]); + } + + return items; +}; + +module.exports = RandomTriangle; + + +/***/ }), +/* 1094 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(206); + +/** + * Takes an array of Game Objects and positions them at random locations within the Ellipse. + * + * @function Phaser.Actions.RandomRectangle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects within. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomRectangle = function (items, rect) +{ + for (var i = 0; i < items.length; i++) + { + Random(rect, items[i]); + } + + return items; +}; + +module.exports = RandomRectangle; + + +/***/ }), +/* 1095 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(207); + +/** + * Takes an array of Game Objects and positions them at random locations on the Line. + * + * If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.RandomLine + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects randomly on. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomLine = function (items, line) +{ + for (var i = 0; i < items.length; i++) + { + Random(line, items[i]); + } + + return items; +}; + +module.exports = RandomLine; + + +/***/ }), +/* 1096 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(203); + +/** + * Takes an array of Game Objects and positions them at random locations within the Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.RandomEllipse + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects within. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomEllipse = function (items, ellipse) +{ + for (var i = 0; i < items.length; i++) + { + Random(ellipse, items[i]); + } + + return items; +}; + +module.exports = RandomEllipse; + + +/***/ }), +/* 1097 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Random = __webpack_require__(210); + +/** + * Takes an array of Game Objects and positions them at random locations within the Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.RandomCircle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects within. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var RandomCircle = function (items, circle) +{ + for (var i = 0; i < items.length; i++) + { + Random(circle, items[i]); + } + + return items; +}; + +module.exports = RandomCircle; + + +/***/ }), +/* 1098 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Play an animation with the given key, starting at the given startFrame on all Game Objects in items. + * + * @function Phaser.Actions.PlayAnimation + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {string} key - The name of the animation to play. + * @param {(string|integer)} [startFrame] - The starting frame of the animation with the given key. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlayAnimation = function (items, key, startFrame) +{ + for (var i = 0; i < items.length; i++) + { + items[i].anims.play(key, startFrame); + } + + return items; +}; + +module.exports = PlayAnimation; + + +/***/ }), +/* 1099 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BresenhamPoints = __webpack_require__(421); + +/** + * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.PlaceOnTriangle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects on. + * @param {number} [stepRate=1] - An optional step rate, to increase or decrease the packing of the Game Objects on the lines. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnTriangle = function (items, triangle, stepRate) +{ + var p1 = BresenhamPoints({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate); + var p2 = BresenhamPoints({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate); + var p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate); + + // Remove overlaps + p1.pop(); + p2.pop(); + p3.pop(); + + p1 = p1.concat(p2, p3); + + var step = p1.length / items.length; + var p = 0; + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + var point = p1[Math.floor(p)]; + + item.x = point.x; + item.y = point.y; + + p += step; + } + + return items; +}; + +module.exports = PlaceOnTriangle; + + +/***/ }), +/* 1100 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MarchingAnts = __webpack_require__(424); +var RotateLeft = __webpack_require__(423); +var RotateRight = __webpack_require__(422); + +/** + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. + * + * Placement starts from the top-left of the rectangle, and proceeds in a clockwise direction. + * If the `shift` parameter is given you can offset where placement begins. + * + * @function Phaser.Actions.PlaceOnRectangle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects on. + * @param {integer} [shift=1] - An optional positional offset. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnRectangle = function (items, rect, shift) +{ + if (shift === undefined) { shift = 0; } + + var points = MarchingAnts(rect, false, items.length); + + if (shift > 0) + { + RotateLeft(points, shift); + } + else if (shift < 0) + { + RotateRight(points, Math.abs(shift)); + } + + for (var i = 0; i < items.length; i++) + { + items[i].x = points[i].x; + items[i].y = points[i].y; + } + + return items; +}; + +module.exports = PlaceOnRectangle; + + +/***/ }), +/* 1101 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetPoints = __webpack_require__(208); + +/** + * Positions an array of Game Objects on evenly spaced points of a Line. + * + * @function Phaser.Actions.PlaceOnLine + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects on. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnLine = function (items, line) +{ + var points = GetPoints(line, items.length); + + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + var point = points[i]; + + item.x = point.x; + item.y = point.y; + } + + return items; +}; + +module.exports = PlaceOnLine; + + +/***/ }), +/* 1102 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.PlaceOnEllipse + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle) +{ + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 6.28; } + + var angle = startAngle; + var angleStep = (endAngle - startAngle) / items.length; + + var a = ellipse.width / 2; + var b = ellipse.height / 2; + + for (var i = 0; i < items.length; i++) + { + items[i].x = ellipse.x + a * Math.cos(angle); + items[i].y = ellipse.y + b * Math.sin(angle); + + angle += angleStep; + } + + return items; +}; + +module.exports = PlaceOnEllipse; + + +/***/ }), +/* 1103 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. + * + * @function Phaser.Actions.PlaceOnCircle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + */ +var PlaceOnCircle = function (items, circle, startAngle, endAngle) +{ + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 6.28; } + + var angle = startAngle; + var angleStep = (endAngle - startAngle) / items.length; + + for (var i = 0; i < items.length; i++) + { + items[i].x = circle.x + (circle.radius * Math.cos(angle)); + items[i].y = circle.y + (circle.radius * Math.sin(angle)); + + angle += angleStep; + } + + return items; +}; + +module.exports = PlaceOnCircle; + + +/***/ }), +/* 1104 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(37); + +/** + * Takes an array of Game Objects, or any objects that have a public `y` property, + * and then adds the given value to each of their `y` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncY(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `y` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var IncY = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'y', value, step, index, direction); +}; + +module.exports = IncY; + + +/***/ }), +/* 1105 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(37); + +/** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and then adds the given value to each of them. + * + * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncXY(group.getChildren(), x, y, stepX, stepY)` + * + * @function Phaser.Actions.IncXY + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} x - The amount to be added to the `x` property. + * @param {number} [y=x] - The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. + * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. + * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var IncXY = function (items, x, y, stepX, stepY, index, direction) +{ + if (y === undefined || y === null) { y = x; } + + PropertyValueInc(items, 'x', x, stepX, index, direction); + + return PropertyValueInc(items, 'y', y, stepY, index, direction); +}; + +module.exports = IncXY; + + +/***/ }), +/* 1106 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(37); + +/** + * Takes an array of Game Objects, or any objects that have a public `x` property, + * and then adds the given value to each of their `x` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncX(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncX + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `x` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var IncX = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'x', value, step, index, direction); +}; + +module.exports = IncX; + + +/***/ }), +/* 1107 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(37); + +/** + * Takes an array of Game Objects, or any objects that have a public `alpha` property, + * and then adds the given value to each of their `alpha` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `IncAlpha(group.getChildren(), value, step)` + * + * @function Phaser.Actions.IncAlpha + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `alpha` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var IncAlpha = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'alpha', value, step, index, direction); +}; + +module.exports = IncAlpha; + + +/***/ }), +/* 1108 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @function GetColor + * @since 3.0.0 + * @private + */ +var GetColor = function (value) +{ + return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); +}; + +/** + * Provides methods used for setting the tint of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Tint + * @webglOnly + * @since 3.0.0 + */ + +var Tint = { + + /** + * Private internal value. Holds the top-left tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintTL + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintTL: 16777215, + + /** + * Private internal value. Holds the top-right tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintTR + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintTR: 16777215, + + /** + * Private internal value. Holds the bottom-left tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintBL + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintBL: 16777215, + + /** + * Private internal value. Holds the bottom-right tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintBR + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintBR: 16777215, + + /** + * Private internal value. Holds if the Game Object is tinted or not. + * + * @name Phaser.GameObjects.Components.Tint#_isTinted + * @type {boolean} + * @private + * @default false + * @since 3.11.0 + */ + _isTinted: false, + + /** + * Fill or additive? + * + * @name Phaser.GameObjects.Components.Tint#tintFill + * @type {boolean} + * @default false + * @since 3.11.0 + */ + tintFill: false, + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + * + * @method Phaser.GameObjects.Components.Tint#clearTint + * @webglOnly + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearTint: function () + { + this.setTint(0xffffff); + + this._isTinted = false; + + return this; + }, + + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * + * @method Phaser.GameObjects.Components.Tint#setTint + * @webglOnly + * @since 3.0.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTint: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 0xffffff; } + + if (topRight === undefined) + { + topRight = topLeft; + bottomLeft = topLeft; + bottomRight = topLeft; + } + + this._tintTL = GetColor(topLeft); + this._tintTR = GetColor(topRight); + this._tintBL = GetColor(bottomLeft); + this._tintBR = GetColor(bottomRight); + + this._isTinted = true; + + this.tintFill = false; + + return this; + }, + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * + * @method Phaser.GameObjects.Components.Tint#setTintFill + * @webglOnly + * @since 3.11.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTintFill: function (topLeft, topRight, bottomLeft, bottomRight) + { + this.setTint(topLeft, topRight, bottomLeft, bottomRight); + + this.tintFill = true; + + return this; + }, + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopLeft: { + + get: function () + { + return this._tintTL; + }, + + set: function (value) + { + this._tintTL = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopRight: { + + get: function () + { + return this._tintTR; + }, + + set: function (value) + { + this._tintTR = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomLeft: { + + get: function () + { + return this._tintBL; + }, + + set: function (value) + { + this._tintBL = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomRight: { + + get: function () + { + return this._tintBR; + }, + + set: function (value) + { + this._tintBR = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the whole of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tint + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tint: { + + set: function (value) + { + this.setTint(value, value, value, value); + } + }, + + /** + * Does this Game Object have a tint applied to it or not? + * + * @name Phaser.GameObjects.Components.Tint#isTinted + * @type {boolean} + * @webglOnly + * @readonly + * @since 3.11.0 + */ + isTinted: { + + get: function () + { + return this._isTinted; + } + + } + +}; + +module.exports = Tint; + + +/***/ }), +/* 1109 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.TextureCrop + * @since 3.0.0 + */ + +var TextureCrop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.TextureCrop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.TextureCrop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.TextureCrop#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.TextureCrop#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + if (this.isCropped) + { + this.frame.updateCropUVs(this._crop, this.flipX, this.flipY); + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.TextureCrop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = TextureCrop; + + +/***/ }), +/* 1110 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Texture + * @since 3.0.0 + */ + +var Texture = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * Internal flag. Not to be set by this Game Object. + * + * @name Phaser.GameObjects.Components.Texture#isCropped + * @type {boolean} + * @private + * @since 3.11.0 + */ + isCropped: false, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.Texture#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.Texture#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + return this; + } + +}; + +module.exports = Texture; + + +/***/ }), +/* 1111 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the size of a Game Object. + * + * @name Phaser.GameObjects.Components.Size + * @since 3.0.0 + */ + +var Size = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Size#_sizeComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _sizeComponent: true, + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.Size#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.Size#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.frame.realWidth; + }, + + set: function (value) + { + this.scaleX = value / this.frame.realWidth; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.frame.realHeight; + }, + + set: function (value) + { + this.scaleY = value / this.frame.realHeight; + } + + }, + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.Size#setSizeToFrame + * @since 3.0.0 + * + * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. + * + * @return {this} This Game Object instance. + */ + setSizeToFrame: function (frame) + { + if (frame === undefined) { frame = this.frame; } + + this.width = frame.realWidth; + this.height = frame.realHeight; + + return this; + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.Size#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = Size; + + +/***/ }), +/* 1112 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ScaleModes = __webpack_require__(104); + +/** + * Provides methods used for getting and setting the scale of a Game Object. + * + * @name Phaser.GameObjects.Components.ScaleMode + * @since 3.0.0 + */ + +var ScaleMode = { + + _scaleMode: ScaleModes.DEFAULT, + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @name Phaser.GameObjects.Components.ScaleMode#scaleMode + * @type {Phaser.ScaleModes} + * @since 3.0.0 + */ + scaleMode: { + + get: function () + { + return this._scaleMode; + }, + + set: function (value) + { + if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) + { + this._scaleMode = value; + } + } + + }, + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode + * @since 3.0.0 + * + * @param {Phaser.ScaleModes} value - The Scale Mode to be used by this Game Object. + * + * @return {this} This Game Object instance. + */ + setScaleMode: function (value) + { + this.scaleMode = value; + + return this; + } + +}; + +module.exports = ScaleMode; + + +/***/ }), +/* 1113 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the origin of a Game Object. + * Values are normalized, given in the range 0 to 1. + * Display values contain the calculated pixel values. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Origin + * @since 3.0.0 + */ + +var Origin = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Origin#_originComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _originComponent: true, + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originX + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originX: 0.5, + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originY + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originY: 0.5, + + // private + read only + _displayOriginX: 0, + _displayOriginY: 0, + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginX + * @type {number} + * @since 3.0.0 + */ + displayOriginX: { + + get: function () + { + return this._displayOriginX; + }, + + set: function (value) + { + this._displayOriginX = value; + this.originX = value / this.width; + } + + }, + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginY + * @type {number} + * @since 3.0.0 + */ + displayOriginY: { + + get: function () + { + return this._displayOriginY; + }, + + set: function (value) + { + this._displayOriginY = value; + this.originY = value / this.height; + } + + }, + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * + * @method Phaser.GameObjects.Components.Origin#setOrigin + * @since 3.0.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + * + * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + setOriginFromFrame: function () + { + if (!this.frame || !this.frame.customPivot) + { + return this.setOrigin(); + } + else + { + this.originX = this.frame.pivotX; + this.originY = this.frame.pivotY; + } + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * + * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal display origin value. + * @param {number} [y=x] - The vertical display origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setDisplayOrigin: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.displayOriginX = x; + this.displayOriginY = y; + + return this; + }, + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + * + * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + updateDisplayOrigin: function () + { + this._displayOriginX = Math.round(this.originX * this.width); + this._displayOriginY = Math.round(this.originY * this.height); + + return this; + } + +}; + +module.exports = Origin; + + +/***/ }), +/* 1114 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(10); +var RotateAround = __webpack_require__(432); +var Vector2 = __webpack_require__(3); + +/** + * Provides methods used for obtaining the bounds of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.GetBounds + * @since 3.0.0 + */ + +var GetBounds = { + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getCenter + * @since 3.0.0 + * + * @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. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getCenter: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); + output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); + + return output; + }, + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getTopLeft + * @since 3.0.0 + * + * @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, includeParent) + { + 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); + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getTopRight + * @since 3.0.0 + * + * @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, includeParent) + { + 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); + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft + * @since 3.0.0 + * + * @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, includeParent) + { + 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; + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomRight + * @since 3.0.0 + * + * @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, includeParent) + { + 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; + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * + * @method Phaser.GameObjects.Components.GetBounds#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [output,$return] + * + * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + // We can use the output object to temporarily store the x/y coords in: + + var TLx, TLy, TRx, TRy, BLx, BLy, BRx, BRy; + + // Instead of doing a check if parent container is + // defined per corner we only do it once. + if (this.parentContainer) + { + var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); + + this.getTopLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BRx = output.x; + BRy = output.y; + } + else + { + this.getTopLeft(output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + + BRx = output.x; + BRy = output.y; + } + + output.x = Math.min(TLx, TRx, BLx, BRx); + output.y = Math.min(TLy, TRy, BLy, BRy); + output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; + output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; + + return output; + } + +}; + +module.exports = GetBounds; + + +/***/ }), +/* 1115 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for visually flipping a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Flip + * @since 3.0.0 + */ + +var Flip = { + + /** + * The horizontally flipped state of the Game Object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipX: false, + + /** + * The vertically flipped state of the Game Object. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipY: false, + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipX + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipX: function () + { + this.flipX = !this.flipX; + + return this; + }, + + /** + * Toggles the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipY + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipY: function () + { + this.flipY = !this.flipY; + + return this; + }, + + /** + * Sets the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * + * @method Phaser.GameObjects.Components.Flip#resetFlip + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + } + +}; + +module.exports = Flip; + + +/***/ }), +/* 1116 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Crop + * @since 3.12.0 + */ + +var Crop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.Crop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.Crop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.Crop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = Crop; + + +/***/ }), +/* 1117 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for calculating and setting the size of a non-Frame based Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.ComputedSize + * @since 3.0.0 + */ + +var ComputedSize = { + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.ComputedSize#setSize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = ComputedSize; + + +/***/ }), +/* 1118 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AlignIn = __webpack_require__(453); +var CONST = __webpack_require__(212); +var GetFastValue = __webpack_require__(1); +var NOOP = __webpack_require__(2); +var Zone = __webpack_require__(135); + +var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1); + +/** + * @typedef {object} GridAlignConfig + * + * @property {integer} [width=-1] - The width of the grid in items (not pixels). -1 means lay all items out horizontally, regardless of quantity. + * If both this value and height are set to -1 then this value overrides it and the `height` value is ignored. + * @property {integer} [height=-1] - The height of the grid in items (not pixels). -1 means lay all items out vertically, regardless of quantity. + * If both this value and `width` are set to -1 then `width` overrides it and this value is ignored. + * @property {integer} [cellWidth=1] - The width of the cell, in pixels, in which the item is positioned. + * @property {integer} [cellHeight=1] - The height of the cell, in pixels, in which the item is positioned. + * @property {integer} [position=0] - The alignment position. One of the Phaser.Display.Align consts such as `TOP_LEFT` or `RIGHT_CENTER`. + * @property {number} [x=0] - Optionally place the top-left of the final grid at this coordinate. + * @property {number} [y=0] - Optionally place the top-left of the final grid at this coordinate. + */ + +/** + * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, + * and then aligns them based on the grid configuration given to this action. + * + * @function Phaser.Actions.GridAlign + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {GridAlignConfig} options - The GridAlign Configuration object. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var GridAlign = function (items, options) +{ + if (options === undefined) { options = {}; } + + var width = GetFastValue(options, 'width', -1); + var height = GetFastValue(options, 'height', -1); + var cellWidth = GetFastValue(options, 'cellWidth', 1); + var cellHeight = GetFastValue(options, 'cellHeight', cellWidth); + var position = GetFastValue(options, 'position', CONST.TOP_LEFT); + var x = GetFastValue(options, 'x', 0); + var y = GetFastValue(options, 'y', 0); + + var cx = 0; + var cy = 0; + var w = (width * cellWidth); + var h = (height * cellHeight); + + tempZone.setPosition(x, y); + tempZone.setSize(cellWidth, cellHeight); + + for (var i = 0; i < items.length; i++) + { + AlignIn(items[i], tempZone, position); + + if (width === -1) + { + // We keep laying them out horizontally until we've done them all + cy += cellHeight; + tempZone.y += cellHeight; + + if (cy === h) + { + cy = 0; + tempZone.x += cellWidth; + tempZone.y = y; + } + } + else if (height === -1) + { + // We keep laying them out vertically until we've done them all + cx += cellWidth; + tempZone.x += cellWidth; + + if (cx === w) + { + cx = 0; + tempZone.x = x; + tempZone.y += cellHeight; + } + } + else + { + // We keep laying them out until we hit the column limit + cx += cellWidth; + tempZone.x += cellWidth; + + if (cx === w) + { + cx = 0; + cy += cellHeight; + tempZone.x = x; + tempZone.y += cellHeight; + + if (cy === h) + { + // We've hit the column limit, so return, even if there are items left + break; + } + } + } + } + + return items; +}; + +module.exports = GridAlign; + + +/***/ }), +/* 1119 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of objects and returns the last element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the last item which had the property `scaleX` set to 0.5 and `alpha` set to 1. + * + * To use this with a Group: `GetLast(group.getChildren(), compare, index)` + * + * @function Phaser.Actions.GetLast + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. + * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * + * @return {?(object|Phaser.GameObjects.GameObject)} The last object in the array that matches the comparison object, or `null` if no match was found. + */ +var GetLast = function (items, compare, index) +{ + if (index === undefined) { index = 0; } + + for (var i = index; i < items.length; i++) + { + var item = items[i]; + + var match = true; + + for (var property in compare) + { + if (item[property] !== compare[property]) + { + match = false; + } + } + + if (match) + { + return item; + } + } + + return null; +}; + +module.exports = GetLast; + + +/***/ }), +/* 1120 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of objects and returns the first element in the array that has properties which match + * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` + * then it would return the first item which had the property `scaleX` set to 0.5 and `alpha` set to 1. + * + * To use this with a Group: `GetFirst(group.getChildren(), compare, index)` + * + * @function Phaser.Actions.GetFirst + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. + * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * + * @return {?(object|Phaser.GameObjects.GameObject)} The first object in the array that matches the comparison object, or `null` if no match was found. + */ +var GetFirst = function (items, compare, index) +{ + if (index === undefined) { index = 0; } + + for (var i = index; i < items.length; i++) + { + var item = items[i]; + + var match = true; + + for (var property in compare) + { + if (item[property] !== compare[property]) + { + match = false; + } + } + + if (match) + { + return item; + } + } + + return null; +}; + +module.exports = GetFirst; + + +/***/ }), +/* 1121 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @callback CallCallback + * + * @param {Phaser.GameObjects.GameObject} item - The Game Object to run the callback on. + */ + +/** + * Takes an array of objects and passes each of them to the given callback. + * + * @function Phaser.Actions.Call + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {CallCallback} callback - The callback to be invoked. It will be passed just one argument: the item from the array. + * @param {*} context - The scope in which the callback will be invoked. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that was passed to this Action. + */ +var Call = function (items, callback, context) +{ + for (var i = 0; i < items.length; i++) + { + var item = items[i]; + + callback.call(context, item); + } + + return items; +}; + +module.exports = Call; + + +/***/ }), +/* 1122 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PropertyValueInc = __webpack_require__(37); + +/** + * Takes an array of Game Objects, or any objects that have a public `angle` property, + * and then adds the given value to each of their `angle` properties. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `Angle(group.getChildren(), value, step)` + * + * @function Phaser.Actions.Angle + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {number} value - The amount to be added to the `angle` property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var Angle = function (items, value, step, index, direction) +{ + return PropertyValueInc(items, 'angle', value, step, index, direction); +}; + +module.exports = Angle; + + +/***/ }), +/* 1123 */ +/***/ (function(module, exports) { + +/** +* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 +* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ +* Cameron Foale (http://www.kibibu.com) +*/ +if (typeof window.Uint32Array !== 'function' && typeof window.Uint32Array !== 'object') +{ + var CheapArray = function (fakeType) + { + var proto = new Array(); // jshint ignore:line + + window[fakeType] = function(arg) { + + if (typeof(arg) === 'number') + { + Array.call(this, arg); + + this.length = arg; + + for (var i = 0; i < this.length; i++) + { + this[i] = 0; + } + } + else + { + Array.call(this, arg.length); + + this.length = arg.length; + + for (var i = 0; i < this.length; i++) + { + this[i] = arg[i]; + } + } + }; + + window[fakeType].prototype = proto; + window[fakeType].constructor = window[fakeType]; + }; + + CheapArray('Float32Array'); // jshint ignore:line + CheapArray('Uint32Array'); // jshint ignore:line + CheapArray('Uint16Array'); // jshint ignore:line + CheapArray('Int16Array'); // jshint ignore:line + CheapArray('ArrayBuffer'); // jshint ignore:line +} + + +/***/ }), +/* 1124 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {// References: +// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ +// https://gist.github.com/1579671 +// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision +// https://gist.github.com/timhall/4078614 +// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame + +// Expected to be used with Browserfiy +// Browserify automatically detects the use of `global` and passes the +// correct reference of `global`, `self`, and finally `window` + +// Date.now +if (!(Date.now && Date.prototype.getTime)) { + Date.now = function now() { + return new Date().getTime(); + }; +} + +// performance.now +if (!(global.performance && global.performance.now)) { + var startTime = Date.now(); + if (!global.performance) { + global.performance = {}; + } + global.performance.now = function () { + return Date.now() - startTime; + }; +} + +// requestAnimationFrame +var lastTime = Date.now(); +var vendors = ['ms', 'moz', 'webkit', 'o']; + +for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { + global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; + global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || + global[vendors[x] + 'CancelRequestAnimationFrame']; +} + +if (!global.requestAnimationFrame) { + global.requestAnimationFrame = function (callback) { + if (typeof callback !== 'function') { + throw new TypeError(callback + 'is not a function'); + } + + var currentTime = Date.now(), + delay = 16 + lastTime - currentTime; + + if (delay < 0) { + delay = 0; + } + + lastTime = currentTime; + + return setTimeout(function () { + lastTime = Date.now(); + callback(performance.now()); + }, delay); + }; +} + +if (!global.cancelAnimationFrame) { + global.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(213))) + +/***/ }), +/* 1125 */ +/***/ (function(module, exports) { + +/** + * performance.now + */ +(function () { + + if ('performance' in window === false) + { + window.performance = {}; + } + + // Thanks IE8 + Date.now = (Date.now || function () { + return new Date().getTime(); + }); + + if ('now' in window.performance === false) + { + var nowOffset = Date.now(); + + if (performance.timing && performance.timing.navigationStart) + { + nowOffset = performance.timing.navigationStart; + } + + window.performance.now = function now () + { + return Date.now() - nowOffset; + } + } + +})(); + + +/***/ }), +/* 1126 */ +/***/ (function(module, exports) { + +// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc +if (!Math.trunc) { + Math.trunc = function trunc(x) { + return x < 0 ? Math.ceil(x) : Math.floor(x); + }; +} + + +/***/ }), +/* 1127 */ +/***/ (function(module, exports) { + +/** + * Also fix for the absent console in IE9 + */ +if (!window.console) +{ + window.console = {}; + window.console.log = window.console.assert = function(){}; + window.console.warn = window.console.assert = function(){}; +} + + +/***/ }), +/* 1128 */ +/***/ (function(module, exports) { + +/* Copyright 2013 Chris Wilson + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + +This monkeypatch library is intended to be included in projects that are +written to the proper AudioContext spec (instead of webkitAudioContext), +and that use the new naming and proper bits of the Web Audio API (e.g. +using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may +have to run on systems that only support the deprecated bits. + +This library should be harmless to include if the browser supports +unprefixed "AudioContext", and/or if it supports the new names. + +The patches this library handles: +if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). +if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or +noteGrainOn(), depending on parameters. + +The following aliases only take effect if the new names are not already in place: + +AudioBufferSourceNode.stop() is aliased to noteOff() +AudioContext.createGain() is aliased to createGainNode() +AudioContext.createDelay() is aliased to createDelayNode() +AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() +AudioContext.createPeriodicWave() is aliased to createWaveTable() +OscillatorNode.start() is aliased to noteOn() +OscillatorNode.stop() is aliased to noteOff() +OscillatorNode.setPeriodicWave() is aliased to setWaveTable() +AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() + +This library does NOT patch the enumerated type changes, as it is +recommended in the specification that implementations support both integer +and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel +BiquadFilterNode.type and OscillatorNode.type. + +*/ + +(function () { + + function fixSetTarget(param) { + if (!param) // if NYI, just return + return; + if (!param.setTargetAtTime) + param.setTargetAtTime = param.setTargetValueAtTime; + } + + if (window.hasOwnProperty('webkitAudioContext') && + !window.hasOwnProperty('AudioContext')) { + window.AudioContext = webkitAudioContext; + + if (!AudioContext.prototype.hasOwnProperty('createGain')) + AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; + if (!AudioContext.prototype.hasOwnProperty('createDelay')) + AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; + if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) + AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; + if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) + AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; + + + AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; + AudioContext.prototype.createGain = function() { + var node = this.internal_createGain(); + fixSetTarget(node.gain); + return node; + }; + + AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; + AudioContext.prototype.createDelay = function(maxDelayTime) { + var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); + fixSetTarget(node.delayTime); + return node; + }; + + AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; + AudioContext.prototype.createBufferSource = function() { + var node = this.internal_createBufferSource(); + if (!node.start) { + node.start = function ( when, offset, duration ) { + if ( offset || duration ) + this.noteGrainOn( when || 0, offset, duration ); + else + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function( when, offset, duration ) { + if( typeof duration !== 'undefined' ) + node.internal_start( when || 0, offset, duration ); + else + node.internal_start( when || 0, offset || 0 ); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + fixSetTarget(node.playbackRate); + return node; + }; + + AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; + AudioContext.prototype.createDynamicsCompressor = function() { + var node = this.internal_createDynamicsCompressor(); + fixSetTarget(node.threshold); + fixSetTarget(node.knee); + fixSetTarget(node.ratio); + fixSetTarget(node.reduction); + fixSetTarget(node.attack); + fixSetTarget(node.release); + return node; + }; + + AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; + AudioContext.prototype.createBiquadFilter = function() { + var node = this.internal_createBiquadFilter(); + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + fixSetTarget(node.Q); + fixSetTarget(node.gain); + return node; + }; + + if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { + AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; + AudioContext.prototype.createOscillator = function() { + var node = this.internal_createOscillator(); + if (!node.start) { + node.start = function ( when ) { + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function ( when ) { + node.internal_start( when || 0); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + if (!node.setPeriodicWave) + node.setPeriodicWave = node.setWaveTable; + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + return node; + }; + } + } + + if (window.hasOwnProperty('webkitOfflineAudioContext') && + !window.hasOwnProperty('OfflineAudioContext')) { + window.OfflineAudioContext = webkitOfflineAudioContext; + } + +})(); + + +/***/ }), +/* 1129 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.isArray +*/ +if (!Array.isArray) +{ + Array.isArray = function (arg) + { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; +} + + +/***/ }), +/* 1130 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.forEach +* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach +*/ +if (!Array.prototype.forEach) +{ + Array.prototype.forEach = function (fun /*, thisArg */) + { + 'use strict'; + + if (this === void 0 || this === null) + { + throw new TypeError(); + } + + var t = Object(this); + var len = t.length >>> 0; + + if (typeof fun !== 'function') + { + throw new TypeError(); + } + + var thisArg = arguments.length >= 2 ? arguments[1] : void 0; + + for (var i = 0; i < len; i++) + { + if (i in t) + { + fun.call(thisArg, t[i], i, t); + } + } + }; +} + + +/***/ }), +/* 1131 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(1130); +__webpack_require__(1129); +__webpack_require__(1128); +__webpack_require__(1127); +__webpack_require__(1126); +__webpack_require__(1125); +__webpack_require__(1124); +__webpack_require__(1123); + + +/***/ }), +/* 1132 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +__webpack_require__(1131); + +var CONST = __webpack_require__(28); +var Extend = __webpack_require__(21); + +/** + * @namespace Phaser + */ + +var Phaser = { + + Actions: __webpack_require__(454), + Animation: __webpack_require__(1065), + Cache: __webpack_require__(1064), + Cameras: __webpack_require__(1063), + Class: __webpack_require__(0), + Create: __webpack_require__(1020), + Curves: __webpack_require__(1014), + Data: __webpack_require__(1011), + Display: __webpack_require__(1009), + DOM: __webpack_require__(980), + Events: __webpack_require__(978), + Game: __webpack_require__(976), + GameObjects: __webpack_require__(943), + Geom: __webpack_require__(302), + Input: __webpack_require__(683), + Loader: __webpack_require__(660), + Math: __webpack_require__(637), + Physics: __webpack_require__(595), + Plugins: __webpack_require__(530), + Renderer: __webpack_require__(528), + Scene: __webpack_require__(357), + Scenes: __webpack_require__(523), + Sound: __webpack_require__(521), + Structs: __webpack_require__(520), + Textures: __webpack_require__(519), + Tilemaps: __webpack_require__(517), + Time: __webpack_require__(468), + Tweens: __webpack_require__(466), + Utils: __webpack_require__(462) + +}; + +// Merge in the optional plugins + +if (false) +{} + +if (true) +{ + Phaser.FacebookInstantGamesPlugin = __webpack_require__(344); +} + +// 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 + */ + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(213))) + +/***/ }) +/******/ ]); +}); \ No newline at end of file diff --git a/dist/phaser-facebook-instant-games.min.js b/dist/phaser-facebook-instant-games.min.js new file mode 100644 index 000000000..7ed8baff3 --- /dev/null +++ b/dist/phaser-facebook-instant-games.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}(window,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1132)}([function(t,e){function i(t,e,i){var n=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&n.value&&"object"==typeof n.value&&(n=n.value),!(!n||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(n))&&(void 0===n.enumerable&&(n.enumerable=!0),void 0===n.configurable&&(n.configurable=!0),n)}function n(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function s(t,e,s,r){for(var a in e)if(e.hasOwnProperty(a)){var h=i(e,a,s);if(!1!==h){if(n((r||t).prototype,a)){if(o.ignoreFinals)continue;throw new Error("cannot override final property '"+a+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,a,h)}else t.prototype[a]=e[a]}}function r(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},transformMat3:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},transformMat4:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[4]*i+n[12],this.y=n[1]*e+n[5]*i+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,e){t.exports=function(t,e,i){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(e.indexOf(".")){for(var n=e.split("."),s=t,r=i,o=0;o>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,n=0;n=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=l},function(t,e,i){"use strict";var n=Object.prototype.hasOwnProperty,s="~";function r(){}function o(t,e,i,n,r){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new function(t,e,i){this.fn=t,this.context=e,this.once=i||!1}(i,n||t,r),a=s?s+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],o]:t._events[a].push(o):(t._events[a]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function h(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(s=!1)),h.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)n.call(t,e)&&i.push(s?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},h.prototype.listeners=function(t){var e=s?s+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,r=i.length,o=new Array(r);n0;e--){var n=Math.floor(i.random()*(e+1)),s=t[e];t[e]=t[n],t[n]=s}return t},i.choose=function(t){return t[Math.floor(i.random()*t.length)]},i.isElement=function(t){return"undefined"!=typeof HTMLElement?t instanceof HTMLElement:!!(t&&t.nodeType&&t.nodeName)},i.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},i.isFunction=function(t){return"function"==typeof t},i.isPlainObject=function(t){return"object"==typeof t&&t.constructor===Object},i.isString=function(t){return"[object String]"===toString.call(t)},i.clamp=function(t,e,i){return ti?i:t},i.sign=function(t){return t<0?-1:1},i.now=function(){if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-i._nowStartTime},i.random=function(e,i){return e=void 0!==e?e:0,i=void 0!==i?i:1,e+t()*(i-e)};var t=function(){return i._seed=(9301*i._seed+49297)%233280,i._seed/233280};i.colorToNumber=function(t){return 3==(t=t.replace("#","")).length&&(t=t.charAt(0)+t.charAt(0)+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)),parseInt(t,16)},i.logLevel=1,i.log=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.info=function(){console&&i.logLevel>0&&i.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.warn=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.nextId=function(){return i._nextId++},i.indexOf=function(t,e){if(t.indexOf)return t.indexOf(e);for(var i=0;i0&&this.cameraFilter&t.id)},getIndexList:function(){for(var t=this,e=this.parentContainer,i=[];e&&(i.unshift(e.getIndex(t)),t=e,e.parentContainer);)e=e.parentContainer;return i.unshift(this.scene.sys.displayList.getIndex(t)),i},destroy:function(t){if(void 0===t&&(t=!1),this.scene&&!this.ignoreDestroy){this.preDestroy&&this.preDestroy.call(this),this.emit("destroy",this);var e=this.scene.sys;t||(e.displayList.remove(this),e.updateList.remove(this)),this.input&&(e.input.clear(this),this.input=void 0),this.data&&(this.data.destroy(),this.data=void 0),this.body&&(this.body.destroy(),this.body=void 0),t||e.queueDepthSort(),this.active=!1,this.visible=!1,this.scene=void 0,this.parentContainer=void 0,this.removeAllListeners()}}});a.RENDER_MASK=15,t.exports=a},function(t,e,i){var n=i(441),s={PI2:2*Math.PI,TAU:.5*Math.PI,EPSILON:1e-6,DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,RND:new n};t.exports=s},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=o.width),void 0===s&&(s=o.height);var a=n(r,"isNotEmpty",!1),h=n(r,"isColliding",!1),l=n(r,"hasInterestingFace",!1);t<0&&(i+=t,t=0),e<0&&(s+=e,e=0),t+i>o.width&&(i=Math.max(o.width-t,0)),e+s>o.height&&(s=Math.max(o.height-e,0));for(var u=[],c=e;c=400&&t.status<=599&&(i=!1),this.resetXHR(),this.loader.nextFile(this,i)},onError:function(){this.resetXHR(),this.loader.nextFile(this,!1)},onProgress:function(t){t.lengthComputable&&(this.bytesLoaded=t.loaded,this.bytesTotal=t.total,this.percentComplete=Math.min(this.bytesLoaded/this.bytesTotal,1),this.loader.emit("fileprogress",this,this.percentComplete))},onProcess:function(){this.state=s.FILE_PROCESSING,this.onProcessComplete()},onProcessComplete:function(){this.state=s.FILE_COMPLETE,this.multiFile&&this.multiFile.onFileComplete(this),this.loader.fileProcessComplete(this)},onProcessError:function(){this.state=s.FILE_ERRORED,this.multiFile&&this.multiFile.onFileFailed(this),this.loader.fileProcessComplete(this)},hasCacheConflict:function(){return this.cache&&this.cache.exists(this.key)},addToCache:function(){this.cache&&this.cache.add(this.key,this.data),this.pendingDestroy()},pendingDestroy:function(t){void 0===t&&(t=this.data);var e=this.key,i=this.type;this.loader.emit("filecomplete",e,i,t),this.loader.emit("filecomplete-"+i+"-"+e,e,i,t),this.loader.flagForRemoval(this)},destroy:function(){this.loader=null,this.cache=null,this.xhrSettings=null,this.multiFile=null,this.linkFile=null,this.data=null}});u.createObjectURL=function(t,e,i){if("function"==typeof URL)t.src=URL.createObjectURL(e);else{var n=new FileReader;n.onload=function(){t.removeAttribute("crossOrigin"),t.src="data:"+(e.type||i)+";base64,"+n.result.split(",")[1]},n.onerror=t.onerror,n.readAsDataURL(e)}},u.revokeObjectURL=function(t){"function"==typeof URL&&URL.revokeObjectURL(t.src)},t.exports=u},function(t,e){t.exports=function(t,e,i,n,s){var r=n.alpha*i.alpha;if(r<=0)return!1;var o=t._tempMatrix1.copyFromArray(n.matrix.matrix),a=t._tempMatrix2.applyITRS(i.x,i.y,i.rotation,i.scaleX,i.scaleY),h=t._tempMatrix3;return s?(o.multiplyWithOffset(s,-n.scrollX*i.scrollFactorX,-n.scrollY*i.scrollFactorY),a.e=i.x,a.f=i.y,o.multiply(a,h)):(a.e-=n.scrollX*i.scrollFactorX,a.f-=n.scrollY*i.scrollFactorY,o.multiply(a,h)),e.globalCompositeOperation=t.blendModes[i.blendMode],e.globalAlpha=r,e.save(),h.setToContext(e),!0}},function(t,e){t.exports=function(t,e,i){return Math.max(e,Math.min(i,t))}},function(t,e,i){var n={};t.exports=n;var s=i(29),r=i(34),o=i(89),a=i(12),h=i(33),l=i(152);!function(){n._inertiaScale=4,n._nextCollidingGroupId=1,n._nextNonCollidingGroupId=-1,n._nextCategory=1,n.create=function(e){var i={id:a.nextId(),type:"body",label:"Body",gameObject:null,parts:[],plugin:{},angle:0,vertices:s.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},previousPositionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,ignoreGravity:!1,ignorePointer:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:0},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,_original:null},n=a.extend(i,e);return t(n,e),n},n.nextGroup=function(t){return t?n._nextNonCollidingGroupId--:n._nextCollidingGroupId++},n.nextCategory=function(){return n._nextCategory=n._nextCategory<<1,n._nextCategory};var t=function(t,e){e=e||{},n.set(t,{bounds:t.bounds||h.create(t.vertices),positionPrev:t.positionPrev||r.clone(t.position),anglePrev:t.anglePrev||t.angle,vertices:t.vertices,parts:t.parts||[t],isStatic:t.isStatic,isSleeping:t.isSleeping,parent:t.parent||t}),s.rotate(t.vertices,t.angle,t.position),l.rotate(t.axes,t.angle),h.update(t.bounds,t.vertices,t.velocity),n.set(t,{axes:e.axes||t.axes,area:e.area||t.area,mass:e.mass||t.mass,inertia:e.inertia||t.inertia});var i=t.isStatic?"#2e2b44":a.choose(["#006BA6","#0496FF","#FFBC42","#D81159","#8F2D56"]);t.render.fillStyle=t.render.fillStyle||i,t.render.strokeStyle=t.render.strokeStyle||"#000",t.render.sprite.xOffset+=-(t.bounds.min.x-t.position.x)/(t.bounds.max.x-t.bounds.min.x),t.render.sprite.yOffset+=-(t.bounds.min.y-t.position.y)/(t.bounds.max.y-t.bounds.min.y)};n.set=function(t,e,i){var s;for(s in"string"==typeof e&&(s=e,(e={})[s]=i),e)if(e.hasOwnProperty(s))switch(i=e[s],s){case"isStatic":n.setStatic(t,i);break;case"isSleeping":o.set(t,i);break;case"mass":n.setMass(t,i);break;case"density":n.setDensity(t,i);break;case"inertia":n.setInertia(t,i);break;case"vertices":n.setVertices(t,i);break;case"position":n.setPosition(t,i);break;case"angle":n.setAngle(t,i);break;case"velocity":n.setVelocity(t,i);break;case"angularVelocity":n.setAngularVelocity(t,i);break;case"parts":n.setParts(t,i);break;default:t[s]=i}},n.setStatic=function(t,e){for(var i=0;i0&&r.rotateAbout(o.position,i,t.position,o.position)}},n.setVelocity=function(t,e){t.positionPrev.x=t.position.x-e.x,t.positionPrev.y=t.position.y-e.y,t.velocity.x=e.x,t.velocity.y=e.y,t.speed=r.magnitude(t.velocity)},n.setAngularVelocity=function(t,e){t.anglePrev=t.angle-e,t.angularVelocity=e,t.angularSpeed=Math.abs(t.angularVelocity)},n.translate=function(t,e){n.setPosition(t,r.add(t.position,e))},n.rotate=function(t,e,i){if(i){var s=Math.cos(e),r=Math.sin(e),o=t.position.x-i.x,a=t.position.y-i.y;n.setPosition(t,{x:i.x+(o*s-a*r),y:i.y+(o*r+a*s)}),n.setAngle(t,t.angle+e)}else n.setAngle(t,t.angle+e)},n.scale=function(t,e,i,r){var o=0,a=0;r=r||t.position;for(var u=0;u0&&(o+=c.area,a+=c.inertia),c.position.x=r.x+(c.position.x-r.x)*e,c.position.y=r.y+(c.position.y-r.y)*i,h.update(c.bounds,c.vertices,t.velocity)}t.parts.length>1&&(t.area=o,t.isStatic||(n.setMass(t,t.density*o),n.setInertia(t,a))),t.circleRadius&&(e===i?t.circleRadius*=e:t.circleRadius=null)},n.update=function(t,e,i,n){var o=Math.pow(e*i*t.timeScale,2),a=1-t.frictionAir*i*t.timeScale,u=t.position.x-t.positionPrev.x,c=t.position.y-t.positionPrev.y;t.velocity.x=u*a*n+t.force.x/t.mass*o,t.velocity.y=c*a*n+t.force.y/t.mass*o,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.position.x+=t.velocity.x,t.position.y+=t.velocity.y,t.angularVelocity=(t.angle-t.anglePrev)*a*n+t.torque/t.inertia*o,t.anglePrev=t.angle,t.angle+=t.angularVelocity,t.speed=r.magnitude(t.velocity),t.angularSpeed=Math.abs(t.angularVelocity);for(var d=0;d0&&(f.position.x+=t.velocity.x,f.position.y+=t.velocity.y),0!==t.angularVelocity&&(s.rotate(f.vertices,t.angularVelocity,t.position),l.rotate(f.axes,t.angularVelocity),d>0&&r.rotateAbout(f.position,t.angularVelocity,t.position,f.position)),h.update(f.bounds,f.vertices,t.velocity)}},n.applyForce=function(t,e,i){t.force.x+=i.x,t.force.y+=i.y;var n=e.x-t.position.x,s=e.y-t.position.y;t.torque+=n*i.y-s*i.x},n._totalProperties=function(t){for(var e={mass:0,area:0,inertia:0,centre:{x:0,y:0}},i=1===t.parts.length?0:1;i=0;o--)t[o][e]=i+a*n,a++;return t}},function(t,e,i){var n={VERSION:"3.15.1",BlendModes:i(72),ScaleModes:i(104),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=n},function(t,e,i){var n={};t.exports=n;var s=i(34),r=i(12);n.create=function(t,e){for(var i=[],n=0;n0)return!1}return!0},n.scale=function(t,e,i,r){if(1===e&&1===i)return t;var o,a;r=r||n.centre(t);for(var h=0;h=0?h-1:t.length-1],u=t[h],c=t[(h+1)%t.length],d=e[h0&&(r|=2),3===r)return!1;return 0!==r||null},n.hull=function(t){var e,i,n=[],r=[];for((t=t.slice(0)).sort(function(t,e){var i=t.x-e.x;return 0!==i?i:t.y-e.y}),i=0;i=2&&s.cross3(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(i=t.length-1;i>=0;i-=1){for(e=t[i];n.length>=2&&s.cross3(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}return n.pop(),r.pop(),n.concat(r)}},function(t,e){t.exports={CSV:0,TILED_JSON:1,ARRAY_2D:2,WELTMEISTER:3}},function(t,e,i){var n=i(0),s=i(16),r=i(17),o=i(60),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.ComputedSize,s.Depth,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Transform,s.Visible],initialize:function(t,e,i){void 0===e&&(e="Shape"),r.call(this,t,e),this.geom=i,this.pathData=[],this.pathIndexes=[],this.fillColor=16777215,this.fillAlpha=1,this.strokeColor=16777215,this.strokeAlpha=1,this.lineWidth=1,this.isFilled=!1,this.isStroked=!1,this.closePath=!0,this._tempLine=new o,this.initPipeline()},setFillStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.isFilled=!1:(this.fillColor=t,this.fillAlpha=e,this.isFilled=!0),this},setStrokeStyle:function(t,e,i){return void 0===i&&(i=1),void 0===t?this.isStroked=!1:(this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i,this.isStroked=!0),this},setClosePath:function(t){return this.closePath=t,this},preDestroy:function(){this.geom=null,this._tempLine=null,this.pathData=[],this.pathIndexes=[]}});t.exports=a},function(t,e,i){var n=i(72),s=i(13),r=i(104);t.exports=function(t,e,i){e.x=s(i,"x",0),e.y=s(i,"y",0),e.depth=s(i,"depth",0),e.flipX=s(i,"flipX",!1),e.flipY=s(i,"flipY",!1);var o=s(i,"scale",null);"number"==typeof o?e.setScale(o):null!==o&&(e.scaleX=s(o,"x",1),e.scaleY=s(o,"y",1));var a=s(i,"scrollFactor",null);"number"==typeof a?e.setScrollFactor(a):null!==a&&(e.scrollFactorX=s(a,"x",1),e.scrollFactorY=s(a,"y",1)),e.rotation=s(i,"rotation",0);var h=s(i,"angle",null);null!==h&&(e.angle=h),e.alpha=s(i,"alpha",1);var l=s(i,"origin",null);if("number"==typeof l)e.setOrigin(l);else if(null!==l){var u=s(l,"x",.5),c=s(l,"y",.5);e.setOrigin(u,c)}return e.scaleMode=s(i,"scaleMode",r.DEFAULT),e.blendMode=s(i,"blendMode",n.NORMAL),e.visible=s(i,"visible",!0),s(i,"add",!0)&&t.sys.displayList.add(e),e.preUpdate&&t.sys.updateList.add(e),e}},function(t,e){var i={};t.exports=i,i.create=function(t){var e={min:{x:0,y:0},max:{x:0,y:0}};return t&&i.update(e,t),e},i.update=function(t,e,i){t.min.x=1/0,t.max.x=-1/0,t.min.y=1/0,t.max.y=-1/0;for(var n=0;nt.max.x&&(t.max.x=s.x),s.xt.max.y&&(t.max.y=s.y),s.y0?t.max.x+=i.x:t.min.x+=i.x,i.y>0?t.max.y+=i.y:t.min.y+=i.y)},i.contains=function(t,e){return e.x>=t.min.x&&e.x<=t.max.x&&e.y>=t.min.y&&e.y<=t.max.y},i.overlaps=function(t,e){return t.min.x<=e.max.x&&t.max.x>=e.min.x&&t.max.y>=e.min.y&&t.min.y<=e.max.y},i.translate=function(t,e){t.min.x+=e.x,t.max.x+=e.x,t.min.y+=e.y,t.max.y+=e.y},i.shift=function(t,e){var i=t.max.x-t.min.x,n=t.max.y-t.min.y;t.min.x=e.x,t.max.x=e.x+i,t.min.y=e.y,t.max.y=e.y+n}},function(t,e){var i={};t.exports=i,i.create=function(t,e){return{x:t||0,y:e||0}},i.clone=function(t){return{x:t.x,y:t.y}},i.magnitude=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},i.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y},i.rotate=function(t,e,i){var n=Math.cos(e),s=Math.sin(e);i||(i={});var r=t.x*n-t.y*s;return i.y=t.x*s+t.y*n,i.x=r,i},i.rotateAbout=function(t,e,i,n){var s=Math.cos(e),r=Math.sin(e);n||(n={});var o=i.x+((t.x-i.x)*s-(t.y-i.y)*r);return n.y=i.y+((t.x-i.x)*r+(t.y-i.y)*s),n.x=o,n},i.normalise=function(t){var e=i.magnitude(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},i.dot=function(t,e){return t.x*e.x+t.y*e.y},i.cross=function(t,e){return t.x*e.y-t.y*e.x},i.cross3=function(t,e,i){return(e.x-t.x)*(i.y-t.y)-(e.y-t.y)*(i.x-t.x)},i.add=function(t,e,i){return i||(i={}),i.x=t.x+e.x,i.y=t.y+e.y,i},i.sub=function(t,e,i){return i||(i={}),i.x=t.x-e.x,i.y=t.y-e.y,i},i.mult=function(t,e){return{x:t.x*e,y:t.y*e}},i.div=function(t,e){return{x:t.x/e,y:t.y/e}},i.perp=function(t,e){return{x:(e=!0===e?-1:1)*-t.y,y:e*t.x}},i.neg=function(t){return{x:-t.x,y:-t.y}},i.angle=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},i._temp=[i.create(),i.create(),i.create(),i.create(),i.create(),i.create()]},function(t,e){t.exports=function(t,e,i){var n=i||e.fillColor,s=e.fillAlpha,r=(16711680&n)>>>16,o=(65280&n)>>>8,a=255&n;t.fillStyle="rgba("+r+","+o+","+a+","+s+")"}},function(t,e,i){var n=i(18);t.exports=function(t){return t*n.DEG_TO_RAD}},function(t,e){t.exports=function(t,e,i,n,s,r){var o;void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=s;o=0;o--)t[o][e]+=i+a*n,a++;return t}},function(t,e,i){var n=i(110),s=i(19);t.exports=function(t,e,i,r,o){for(var a=null,h=null,l=null,u=null,c=s(t,e,i,r,null,o),d=0;d>>16,r=(65280&i)>>>8,o=255&i;t.strokeStyle="rgba("+s+","+r+","+o+","+n+")",t.lineWidth=e.lineWidth}},function(t,e,i){var n=i(0),s=i(195),r=i(412),o=i(194),a=i(411),h=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=255),this.r=0,this.g=0,this.b=0,this.a=255,this._h=0,this._s=0,this._v=0,this._locked=!1,this.gl=[0,0,0,1],this._color=0,this._color32=0,this._rgba="",this.setTo(t,e,i,n)},transparent:function(){return this._locked=!0,this.red=0,this.green=0,this.blue=0,this.alpha=0,this._locked=!1,this.update(!0)},setTo:function(t,e,i,n,s){return void 0===n&&(n=255),void 0===s&&(s=!0),this._locked=!0,this.red=t,this.green=e,this.blue=i,this.alpha=n,this._locked=!1,this.update(s)},setGLTo:function(t,e,i,n){return void 0===n&&(n=1),this._locked=!0,this.redGL=t,this.greenGL=e,this.blueGL=i,this.alphaGL=n,this._locked=!1,this.update(!0)},setFromRGB:function(t){return this._locked=!0,this.red=t.r,this.green=t.g,this.blue=t.b,t.hasOwnProperty("a")&&(this.alpha=t.a),this._locked=!1,this.update(!0)},setFromHSV:function(t,e,i){return o(t,e,i,this)},update:function(t){if(void 0===t&&(t=!1),this._locked)return this;var e=this.r,i=this.g,n=this.b,o=this.a;return this._color=s(e,i,n),this._color32=r(e,i,n,o),this._rgba="rgba("+e+","+i+","+n+","+o/255+")",t&&a(e,i,n,this),this},updateHSV:function(){var t=this.r,e=this.g,i=this.b;return a(t,e,i,this),this},clone:function(){return new h(this.r,this.g,this.b,this.a)},gray:function(t){return this.setTo(t,t,t)},random:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t)),n=Math.floor(t+Math.random()*(e-t)),s=Math.floor(t+Math.random()*(e-t));return this.setTo(i,n,s)},randomGray:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t));return this.setTo(i,i,i)},saturate:function(t){return this.s+=t/100,this},desaturate:function(t){return this.s-=t/100,this},lighten:function(t){return this.v+=t/100,this},darken:function(t){return this.v-=t/100,this},brighten:function(t){var e=this.r,i=this.g,n=this.b;return e=Math.max(0,Math.min(255,e-Math.round(-t/100*255))),i=Math.max(0,Math.min(255,i-Math.round(-t/100*255))),n=Math.max(0,Math.min(255,n-Math.round(-t/100*255))),this.setTo(e,i,n)},color:{get:function(){return this._color}},color32:{get:function(){return this._color32}},rgba:{get:function(){return this._rgba}},redGL:{get:function(){return this.gl[0]},set:function(t){this.gl[0]=Math.min(Math.abs(t),1),this.r=Math.floor(255*this.gl[0]),this.update(!0)}},greenGL:{get:function(){return this.gl[1]},set:function(t){this.gl[1]=Math.min(Math.abs(t),1),this.g=Math.floor(255*this.gl[1]),this.update(!0)}},blueGL:{get:function(){return this.gl[2]},set:function(t){this.gl[2]=Math.min(Math.abs(t),1),this.b=Math.floor(255*this.gl[2]),this.update(!0)}},alphaGL:{get:function(){return this.gl[3]},set:function(t){this.gl[3]=Math.min(Math.abs(t),1),this.a=Math.floor(255*this.gl[3]),this.update()}},red:{get:function(){return this.r},set:function(t){t=Math.floor(Math.abs(t)),this.r=Math.min(t,255),this.gl[0]=t/255,this.update(!0)}},green:{get:function(){return this.g},set:function(t){t=Math.floor(Math.abs(t)),this.g=Math.min(t,255),this.gl[1]=t/255,this.update(!0)}},blue:{get:function(){return this.b},set:function(t){t=Math.floor(Math.abs(t)),this.b=Math.min(t,255),this.gl[2]=t/255,this.update(!0)}},alpha:{get:function(){return this.a},set:function(t){t=Math.floor(Math.abs(t)),this.a=Math.min(t,255),this.gl[3]=t/255,this.update()}},h:{get:function(){return this._h},set:function(t){this._h=t,o(t,this._s,this._v,this)}},s:{get:function(){return this._s},set:function(t){this._s=t,o(this._h,t,this._v,this)}},v:{get:function(){return this._v},set:function(t){this._v=t,o(this._h,this._s,t,this)}}});t.exports=h},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(t,e,i,n,s,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,n,s,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0}},a:{get:function(){return this.matrix[0]},set:function(t){this.matrix[0]=t}},b:{get:function(){return this.matrix[1]},set:function(t){this.matrix[1]=t}},c:{get:function(){return this.matrix[2]},set:function(t){this.matrix[2]=t}},d:{get:function(){return this.matrix[3]},set:function(t){this.matrix[3]=t}},e:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},f:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},tx:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},ty:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},rotation:{get:function(){return Math.acos(this.a/this.scaleX)*(Math.atan(-this.c/this.a)<0?-1:1)}},scaleX:{get:function(){return Math.sqrt(this.a*this.a+this.c*this.c)}},scaleY:{get:function(){return Math.sqrt(this.b*this.b+this.d*this.d)}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3];return n[0]=s*i+o*e,n[1]=r*i+a*e,n[2]=s*-e+o*i,n[3]=r*-e+a*i,this},multiply:function(t,e){var i=this.matrix,n=t.matrix,s=i[0],r=i[1],o=i[2],a=i[3],h=i[4],l=i[5],u=n[0],c=n[1],d=n[2],f=n[3],p=n[4],g=n[5],v=void 0===e?this:e;return v.a=u*s+c*o,v.b=u*r+c*a,v.c=d*s+f*o,v.d=d*r+f*a,v.e=p*s+g*o+h,v.f=p*r+g*a+l,v},multiplyWithOffset:function(t,e,i){var n=this.matrix,s=t.matrix,r=n[0],o=n[1],a=n[2],h=n[3],l=e*r+i*a+n[4],u=e*o+i*h+n[5],c=s[0],d=s[1],f=s[2],p=s[3],g=s[4],v=s[5];return n[0]=c*r+d*a,n[1]=c*o+d*h,n[2]=f*r+p*a,n[3]=f*o+p*h,n[4]=g*r+v*a+l,n[5]=g*o+v*h+u,this},transform:function(t,e,i,n,s,r){var o=this.matrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=t*a+e*l,o[1]=t*h+e*u,o[2]=i*a+n*l,o[3]=i*h+n*u,o[4]=s*a+r*l+c,o[5]=s*h+r*u+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3],h=n[4],l=n[5];return i.x=t*s+e*o+h,i.y=t*r+e*a+l,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=e*s-i*n;return t[0]=s/a,t[1]=-i/a,t[2]=-n/a,t[3]=e/a,t[4]=(n*o-s*r)/a,t[5]=-(e*o-i*r)/a,this},copyFrom:function(t){var e=this.matrix;return e[0]=t.a,e[1]=t.b,e[2]=t.c,e[3]=t.d,e[4]=t.e,e[5]=t.f,this},copyFromArray:function(t){var e=this.matrix;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],this},copyToContext:function(t){var e=this.matrix;return t.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t},setToContext:function(t){var e=this.matrix;return t.setTransform(e[0],e[1],e[2],e[3],e[4],e[5]),t},copyToArray:function(t){var e=this.matrix;return void 0===t?t=[e[0],e[1],e[2],e[3],e[4],e[5]]:(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5]),t},setTransform:function(t,e,i,n,s,r){var o=this.matrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],n=e[1],s=e[2],r=e[3],o=i*i,a=n*n,h=s*s,l=r*r,u=Math.sqrt(o+h),c=Math.sqrt(a+l);return t.translateX=e[4],t.translateY=e[5],t.scaleX=u,t.scaleY=c,t.rotation=Math.acos(i/u)*(Math.atan(-s/i)<0?-1:1),t},applyITRS:function(t,e,i,n,s){var r=this.matrix,o=Math.sin(i),a=Math.cos(i);return r[4]=t,r[5]=e,r[0]=a*n,r[1]=o*n,r[2]=-o*s,r[3]=a*s,this},applyInverse:function(t,e,i){void 0===i&&(i=new s);var n=this.matrix,r=n[0],o=n[1],a=n[2],h=n[3],l=n[4],u=n[5],c=1/(r*h+a*-o);return i.x=h*c*t+-a*c*e+(u*a-l*h)*c,i.y=r*c*e+-o*c*t+(-u*r+l*o)*c,i},getX:function(t,e){return t*this.a+e*this.c+this.e},getY:function(t,e){return t*this.b+e*this.d+this.f},getCSSMatrix:function(){var t=this.matrix;return"matrix("+t[0]+","+t[1]+","+t[2]+","+t[3]+","+t[4]+","+t[5]+")"},destroy:function(){this.matrix=null,this.decomposedMatrix=null}});t.exports=r},function(t,e){t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i}},function(t,e){t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t,e){return t.y=e+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y-t.height*t.originY}},function(t,e){t.exports=function(t,e){return t.x=e-t.width+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x+t.width-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.x=e+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.y=e-t.height+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y+t.height-t.height*t.originY}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileHeight,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.y+i.scrollY*(1-r.scrollFactorY),s*=r.scaleY),e?Math.floor(t/s):t/s}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileWidth,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.x+i.scrollX*(1-r.scrollFactorX),s*=r.scaleX),e?Math.floor(t/s):t/s}},function(t,e,i){var n={};t.exports=n;var s=i(29),r=i(12),o=i(25),a=i(33),h=i(34),l=i(244);n.rectangle=function(t,e,i,n,a){a=a||{};var h={label:"Rectangle Body",position:{x:t,y:e},vertices:s.fromPath("L 0 0 L "+i+" 0 L "+i+" "+n+" L 0 "+n)};if(a.chamfer){var l=a.chamfer;h.vertices=s.chamfer(h.vertices,l.radius,l.quality,l.qualityMin,l.qualityMax),delete a.chamfer}return o.create(r.extend({},h,a))},n.trapezoid=function(t,e,i,n,a,h){h=h||{};var l,u=i*(a*=.5),c=u+(1-2*a)*i,d=c+u;l=a<.5?"L 0 0 L "+u+" "+-n+" L "+c+" "+-n+" L "+d+" 0":"L 0 0 L "+c+" "+-n+" L "+d+" 0";var f={label:"Trapezoid Body",position:{x:t,y:e},vertices:s.fromPath(l)};if(h.chamfer){var p=h.chamfer;f.vertices=s.chamfer(f.vertices,p.radius,p.quality,p.qualityMin,p.qualityMax),delete h.chamfer}return o.create(r.extend({},f,h))},n.circle=function(t,e,i,s,o){s=s||{};var a={label:"Circle Body",circleRadius:i};o=o||25;var h=Math.ceil(Math.max(10,Math.min(o,i)));return h%2==1&&(h+=1),n.polygon(t,e,h,i,r.extend({},a,s))},n.polygon=function(t,e,i,a,h){if(h=h||{},i<3)return n.circle(t,e,a,h);for(var l=2*Math.PI/i,u="",c=.5*l,d=0;d0&&s.area(A)1?(f=o.create(r.extend({parts:p.slice(0)},n)),o.setPosition(f,{x:t,y:e}),f):p[0]}},function(t,e,i){var n=i(0),s=i(20),r=i(22),o=i(7),a=i(1),h=i(4),l=i(8),u=new n({Extends:r,initialize:function(t,e,i,n,o){var u="json";if(l(e)){var c=e;e=a(c,"key"),i=a(c,"url"),n=a(c,"xhrSettings"),u=a(c,"extension",u),o=a(c,"dataKey",o)}var d={type:"json",cache:t.cacheManager.json,extension:u,responseType:"text",key:e,url:i,xhrSettings:n,config:o};r.call(this,t,d),l(i)&&(this.data=o?h(i,o):i,this.state=s.FILE_POPULATED)},onProcess:function(){if(this.state!==s.FILE_POPULATED){this.state=s.FILE_PROCESSING;var t=JSON.parse(this.xhrLoader.responseText),e=this.config;this.data="string"==typeof e?h(t,e,t):t}this.onProcessComplete()}});o.register("json",function(t,e,i,n){if(Array.isArray(t))for(var s=0;sthis.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=h},function(t,e,i){var n=i(0),s=i(16),r=i(293),o=new n({Mixins:[s.Alpha,s.Flip,s.Visible],initialize:function(t,e,i,n,s,r,o,a){this.layer=t,this.index=e,this.x=i,this.y=n,this.width=s,this.height=r,this.baseWidth=void 0!==o?o:s,this.baseHeight=void 0!==a?a:r,this.pixelX=0,this.pixelY=0,this.updatePixelXY(),this.properties={},this.rotation=0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceLeft=!1,this.faceRight=!1,this.faceTop=!1,this.faceBottom=!1,this.collisionCallback=null,this.collisionCallbackContext=this,this.tint=16777215,this.physics={}},containsPoint:function(t,e){return!(tthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldX(this.x,t):this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldY(this.y,t)-(this.height-this.baseHeight)*e.scaleY:this.y*this.baseHeight-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new r),e.x=this.getLeft(),e.y=this.getTop(),e.width=this.getRight()-e.x,e.height=this.getBottom()-e.y,e},getCenterX:function(t){return this.getLeft(t)+this.width/2},getCenterY:function(t){return this.getTop(t)+this.height/2},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},intersects:function(t,e,i,n){return!(i<=this.pixelX||n<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,n,s){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===n&&(n=t),void 0===s&&(s=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=n,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=n,s)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,n){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==n&&(this.baseHeight=n),this.updatePixelXY(),this},updatePixelXY:function(){return this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight-(this.height-this.baseHeight),this},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.tilemapLayer;return t?t.tileset:null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=o},function(t,e){t.exports=function(t,e){e?t.setCollision(!0,!0,!0,!0,!1):t.resetCollision(!1)}},function(t,e,i){var n={};t.exports=n;var s=i(74),r=i(12),o=i(33),a=i(25);n.create=function(t){return r.extend({id:r.nextId(),type:"composite",parent:null,isModified:!1,bodies:[],constraints:[],composites:[],label:"Composite",plugin:{}},t)},n.setModified=function(t,e,i,s){if(t.isModified=e,i&&t.parent&&n.setModified(t.parent,e,i,s),s)for(var r=0;r=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=l},function(t,e,i){var n=i(9);t.exports=function(t,e,i,s,r){var o=t.strokeTint,a=n.getTintAppendFloatAlphaAndSwap(e.strokeColor,e.strokeAlpha*i);o.TL=a,o.TR=a,o.BL=a,o.BR=a;var h=e.pathData,l=h.length-1,u=e.lineWidth,c=u/2,d=h[0]-s,f=h[1]-r;e.closePath||(l-=2);for(var p=2;ps||e>=i||i>s||e+i>s){if(n)throw new Error("Range Error: Values outside acceptable range");return!1}return!0}},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e,i){"use strict";function n(t,e,i){i=i||2;var n,a,h,l,u,f,g,v=e&&e.length,y=v?e[0]*i:t.length,m=s(t,0,y,i,!0),x=[];if(!m)return x;if(v&&(m=function(t,e,i,n){var o,a,h,l,u,f=[];for(o=0,a=e.length;o80*i){n=h=t[0],a=l=t[1];for(var w=i;wh&&(h=u),f>l&&(l=f);g=Math.max(h-n,l-a)}return o(m,x,i,n,a,g),x}function s(t,e,i,n,s){var r,o;if(s===_(t,e,i,n)>0)for(r=e;r=e;r-=n)o=T(r,t[r],t[r+1],o);return o&&m(o,o.next)&&(S(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!m(n,n.next)&&0!==y(n.prev,n,n.next))n=n.next;else{if(S(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,s,c,d){if(t){!d&&c&&function(t,e,i,n){var s=t;do{null===s.z&&(s.z=f(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,n,s,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,l*=2}while(o>1)}(s)}(t,n,s,c);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,n,s,c):a(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),S(t),t=g.next,v=g.next;else if((t=g)===v){d?1===d?o(t=l(t,e,i),e,i,n,s,c,2):2===d&&u(t,e,i,n,s,c):o(r(t),e,i,n,s,c,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(y(e,i,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(g(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&y(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function h(t,e,i,n){var s=t.prev,r=t,o=t.next;if(y(s,r,o)>=0)return!1;for(var a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,u=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,c=f(a,h,e,i,n),d=f(l,u,e,i,n),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function l(t,e,i){var n=t;do{var s=n.prev,r=n.next.next;!m(s,r)&&x(s,n,n.next,r)&&w(s,r)&&w(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),S(n),S(n.next),n=t=r),n=n.next}while(n!==t);return n}function u(t,e,i,n,s,a){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var u=b(h,l);return h=r(h,h.next),u=r(u,u.next),o(h,e,i,n,s,a),void o(u,e,i,n,s,a)}l=l.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,n=e,s=t.x,r=t.y,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var a=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=s&&a>o){if(o=a,a===s){if(r===n.y)return n;if(r===n.next.y)return n.next}i=n.x=n.x&&n.x>=u&&s!==n.x&&g(ri.x)&&w(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=b(e,t);r(i,i.next)}}function f(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&w(t,e)&&w(e,t)&&function(t,e){var i=t,n=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function y(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,n){return!!(m(t,e)&&m(i,n)||m(t,n)&&m(i,e))||y(t,e,i)>0!=y(t,e,n)>0&&y(i,n,t)>0!=y(i,n,e)>0}function w(t,e){return y(t.prev,t,t.next)<0?y(t,e,t.next)>=0&&y(t,t.prev,e)>=0:y(t,e,t.prev)<0||y(t,t.next,e)<0}function b(t,e){var i=new A(t.i,t.x,t.y),n=new A(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function T(t,e,i,n){var s=new A(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function S(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function _(t,e,i,n){for(var s=0,r=e,o=i-n;r0&&(n+=t[s-1].length,i.holes.push(n))}return i}},function(t,e){t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},function(t,e){t.exports={SKIP_CHECK:-1,NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16}},function(t,e,i){var n={};t.exports=n;var s=i(29),r=i(34),o=i(89),a=i(33),h=i(152),l=i(12);n._warming=.4,n._torqueDampen=1,n._minLength=1e-6,n.create=function(t){var e=t;e.bodyA&&!e.pointA&&(e.pointA={x:0,y:0}),e.bodyB&&!e.pointB&&(e.pointB={x:0,y:0});var i=e.bodyA?r.add(e.bodyA.position,e.pointA):e.pointA,n=e.bodyB?r.add(e.bodyB.position,e.pointB):e.pointB,s=r.magnitude(r.sub(i,n));e.length=void 0!==e.length?e.length:s,e.id=e.id||l.nextId(),e.label=e.label||"Constraint",e.type="constraint",e.stiffness=e.stiffness||(e.length>0?1:.7),e.damping=e.damping||0,e.angularStiffness=e.angularStiffness||0,e.angleA=e.bodyA?e.bodyA.angle:e.angleA,e.angleB=e.bodyB?e.bodyB.angle:e.angleB,e.plugin={};var o={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===e.length&&e.stiffness>.1?(o.type="pin",o.anchors=!1):e.stiffness<.9&&(o.type="spring"),e.render=l.extend(o,e.render),e},n.preSolveAll=function(t){for(var e=0;e0&&(c.position.x+=l.x,c.position.y+=l.y),0!==l.angle&&(s.rotate(c.vertices,l.angle,i.position),h.rotate(c.axes,l.angle),u>0&&r.rotateAbout(c.position,l.angle,i.position,c.position)),a.update(c.bounds,c.vertices,i.velocity)}l.angle*=n._warming,l.x*=n._warming,l.y*=n._warming}}}},function(t,e,i){var n={};t.exports=n;var s=i(12);n.on=function(t,e,i){for(var n,s=e.split(" "),r=0;r0){i||(i={}),n=e.split(" ");for(var l=0;l=0&&y>=0&&v+y<1}},function(t,e){t.exports=function(t,e){return t.hasOwnProperty(e)}},function(t,e,i){var n=i(0),s=i(16),r=i(17),o=i(893),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Size,s.TextureCrop,s.Tint,s.Transform,s.Visible,o],initialize:function(t,e,i,n,s){r.call(this,t,"Image"),this._crop=this.resetCropObject(),this.setTexture(n,s),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline()}});t.exports=a},function(t,e,i){var n=i(69);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)||(i[s]=e[s]);return i}},function(t,e,i){var n=i(0),s=i(191),r=i(10),o=i(3),a=new n({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var n=Math.max(1,Math.round(i/e));return s(this.getSpacedPoints(n),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],n=this.getPoint(0,this._tmpVec2A),s=0;i.push(0);for(var r=1;r<=t;r++)s+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(n),i.push(s),n.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++){var n=this.getUtoTmapping(i/t,null,t);e.push(this.getPoint(n))}return e},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=t-1e-4,n=t+1e-4;return i<0&&(i=0),n>1&&(n=1),this.getPoint(i,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var n,s=this.getLengths(i),r=0,o=s.length;n=e?Math.min(e,s[o-1]):t*s[o-1];for(var a,h=0,l=o-1;h<=l;)if((a=s[r=Math.floor(h+(l-h)/2)]-n)<0)h=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(s[r=l]===n)return r/(o-1);var u=s[r];return(r+(n-u)/(s[r+1]-u))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},function(t,e,i){var n=i(0),s=i(44),r=i(442),o=i(440),a=i(210),h=new n({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=h},function(t,e){t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},function(t,e){t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},function(t,e){t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","map"),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.widthInPixels=s(t,"widthInPixels",this.width*this.tileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.tileHeight),this.format=s(t,"format",null),this.orientation=s(t,"orientation","orthogonal"),this.renderOrder=s(t,"renderOrder","right-down"),this.version=s(t,"version","1"),this.properties=s(t,"properties",{}),this.layers=s(t,"layers",[]),this.images=s(t,"images",[]),this.objects=s(t,"objects",{}),this.collision=s(t,"collision",{}),this.tilesets=s(t,"tilesets",[]),this.imageCollections=s(t,"imageCollections",[]),this.tiles=s(t,"tiles",[])}});t.exports=r},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","layer"),this.x=s(t,"x",0),this.y=s(t,"y",0),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.baseTileWidth=s(t,"baseTileWidth",this.tileWidth),this.baseTileHeight=s(t,"baseTileHeight",this.tileHeight),this.widthInPixels=s(t,"widthInPixels",this.width*this.baseTileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.baseTileHeight),this.alpha=s(t,"alpha",1),this.visible=s(t,"visible",!0),this.properties=s(t,"properties",{}),this.indexes=s(t,"indexes",[]),this.collideIndexes=s(t,"collideIndexes",[]),this.callbacks=s(t,"callbacks",[]),this.bodies=s(t,"bodies",[]),this.data=s(t,"data",[]),this.tilemapLayer=s(t,"tilemapLayer",null)}});t.exports=r},function(t,e){t.exports=function(t,e,i){return t>=0&&t=0&&e0&&r.motion=r.sleepThreshold&&n.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else n.set(r,!1)}},n.afterCollisions=function(t,e){for(var i=e*e*e,s=0;sn._motionWakeThreshold*i&&n.set(l,!1)}}}},n.set=function(t,e){var i=t.isSleeping;e?(t.isSleeping=!0,t.sleepCounter=t.sleepThreshold,t.positionImpulse.x=0,t.positionImpulse.y=0,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.anglePrev=t.angle,t.speed=0,t.angularSpeed=0,t.motion=0,i||s.trigger(t,"sleepStart")):(t.isSleeping=!1,t.sleepCounter=0,i&&s.trigger(t,"sleepEnd"))}},function(t,e){t.exports={NONE:0,A:1,B:2,BOTH:3}},function(t,e){t.exports={NEVER:0,LITE:1,PASSIVE:2,ACTIVE:4,FIXED:8}},function(t,e,i){var n=i(9);t.exports=function(t,e,i,s,r,o){for(var a=n.getTintAppendFloatAlphaAndSwap(i.fillColor,i.fillAlpha*s),h=i.pathData,l=i.pathIndexes,u=0;u-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new n;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return t=0;u--)if((l=d[u]).active===i){if(++c===e)break}else l=null;return l?("number"==typeof s&&(l.x=s),"number"==typeof r&&(l.y=r),l):n?this.create(s,r,o,a,h):null},get:function(t,e,i,n,s){return this.getFirst(!1,!0,t,e,i,n,s)},getFirstAlive:function(t,e,i,n,s,r){return this.getFirst(!0,t,e,i,n,s,r)},getFirstDead:function(t,e,i,n,s,r){return this.getFirst(!1,t,e,i,n,s,r)},playAnimation:function(t,e){return n.PlayAnimation(this.children.entries,t,e),this},isFull:function(){return-1!==this.maxSize&&this.children.size>=this.maxSize},countActive:function(t){void 0===t&&(t=!0);for(var e=0,i=0;i=t.length)){for(var i=t.length-1,n=t[e],s=e;s=this.firstgid&&t=0&&g<=1&&v>=0&&v<=1&&(i.x=s+g*(o-s),i.y=r+g*(a-r),!0)}},function(t,e,i){var n=i(0),s=i(16),r=i(17),o=i(798),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Texture,s.Transform,s.Visible,s.ScrollFactor,o],initialize:function(t,e,i,n,s,o,a,h,l){if(r.call(this,t,"Mesh"),n.length!==s.length)throw new Error("Mesh Vertex count must match UV count");var u,c=n.length/2|0;if(o.length>0&&o.length0&&a.lengthl&&(r=l),o>l&&(o=l),a=s,h=r;;)if(a-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){for(var i=[null],n=2;n0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=a},function(t,e,i){var n=i(0),s=i(24),r=i(21),o=new n({initialize:function(t,e,i,n,s,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.glTexture=this.source.glTexture,this.cutX,this.cutY,this.cutWidth,this.cutHeight,this.x=0,this.y=0,this.width,this.height,this.halfWidth,this.halfHeight,this.centerX,this.centerY,this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.u0=0,this.v0=0,this.u1=0,this.v1=0,this.data={cut:{x:0,y:0,w:0,h:0,r:0,b:0},trim:!1,sourceSize:{w:0,h:0},spriteSourceSize:{x:0,y:0,w:0,h:0,r:0,b:0},radius:0,drawImage:{x:0,y:0,width:0,height:0}},this.setSize(r,o,n,s)},setSize:function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this.cutX=i,this.cutY=n,this.cutWidth=t,this.cutHeight=e,this.width=t,this.height=e,this.halfWidth=Math.floor(.5*t),this.halfHeight=Math.floor(.5*e),this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2);var s=this.data,r=s.cut;r.x=i,r.y=n,r.w=t,r.h=e,r.r=i+t,r.b=n+e,s.sourceSize.w=t,s.sourceSize.h=e,s.spriteSourceSize.w=t,s.spriteSourceSize.h=e,s.radius=.5*Math.sqrt(t*t+e*e);var o=s.drawImage;return o.x=i,o.y=n,o.width=t,o.height=e,this.updateUVs()},setTrim:function(t,e,i,n,s,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=n,a.w=s,a.h=r,a.r=i+s,a.b=n+r,this.x=i,this.y=n,this.width=s,this.height=r,this.halfWidth=.5*s,this.halfHeight=.5*r,this.centerX=Math.floor(s/2),this.centerY=Math.floor(r/2),this.updateUVs()},setCropUVs:function(t,e,i,n,r,o,a){var h=this.cutX,l=this.cutY,u=this.cutWidth,c=this.cutHeight,d=this.realWidth,f=this.realHeight,p=h+(e=s(e,0,d)),g=l+(i=s(i,0,f)),v=n=s(n,0,d-e),y=r=s(r,0,f-i),m=this.data;if(m.trim){var x=m.spriteSourceSize,w=e+(n=s(n,0,u-e)),b=i+(r=s(r,0,c-i));if(!(x.rw||x.y>b)){var T=Math.max(x.x,e),S=Math.max(x.y,i),A=Math.min(x.r,w)-T,_=Math.min(x.b,b)-S;v=A,y=_,p=o?h+(u-(T-x.x)-A):h+(T-x.x),g=a?l+(c-(S-x.y)-_):l+(S-x.y),e=T,i=S,n=A,r=_}else p=0,g=0,v=0,y=0}else o&&(p=h+(u-e-n)),a&&(g=l+(c-i-r));var C=this.source.width,M=this.source.height;return t.u0=Math.max(0,p/C),t.v0=Math.max(0,g/M),t.u1=Math.min(1,(p+v)/C),t.v1=Math.min(1,(g+y)/M),t.x=e,t.y=i,t.cx=p,t.cy=g,t.cw=v,t.ch=y,t.width=n,t.height=r,t.flipX=o,t.flipY=a,t},updateCropUVs:function(t,e,i){return this.setCropUVs(t,t.x,t.y,t.width,t.height,e,i)},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,n=this.cutHeight,s=this.data.drawImage;s.width=i,s.height=n;var r=this.source.width,o=this.source.height;return this.u0=t/r,this.v0=e/o,this.u1=(t+i)/r,this.v1=(e+n)/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height;return this.u0=(this.cutX+this.cutHeight)/t,this.v0=this.cutY/e,this.u1=this.cutX/t,this.v1=(this.cutY+this.cutWidth)/e,this},clone:function(){var t=new o(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=r(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=o},function(t,e,i){var n=i(0),s=i(11),r=i(21),o=i(2),a=new n({Extends:s,initialize:function(t,e,i){s.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=this.duration||0,this.totalDuration=this.totalDuration||0,this.config={mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0},this.currentConfig=this.config,this.config=r(this.config,i),this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(console.error("addMarker "+t.name+" already exists in Sound"),!1):(t=r(!0,{name:"",start:0,duration:this.totalDuration-(t.start||0),config:{mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0}},t),this.markers[t.name]=t,!0))},updateMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(this.markers[t.name]=r(!0,this.markers[t.name],t),!0):(console.warn("Audio Marker: "+t.name+" missing in Sound: "+this.key),!1))},removeMarker:function(t){var e=this.markers[t];return e?(this.markers[t]=null,e):null},play:function(t,e){if(void 0===t&&(t=""),"object"==typeof t&&(e=t,t=""),"string"!=typeof t)return!1;if(t){if(!this.markers[t])return console.warn("Marker: "+t+" missing in Sound: "+this.key),!1;this.currentMarker=this.markers[t],this.currentConfig=this.currentMarker.config,this.duration=this.currentMarker.duration}else this.currentMarker=null,this.currentConfig=this.config,this.duration=this.totalDuration;return this.resetConfig(),this.currentConfig=r(this.currentConfig,e),this.isPlaying=!0,this.isPaused=!1,!0},pause:function(){return!(this.isPaused||!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!0,!0)},resume:function(){return!(!this.isPaused||this.isPlaying)&&(this.isPlaying=!0,this.isPaused=!1,!0)},stop:function(){return!(!this.isPaused&&!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!1,this.resetConfig(),!0)},applyConfig:function(){this.mute=this.currentConfig.mute,this.volume=this.currentConfig.volume,this.rate=this.currentConfig.rate,this.detune=this.currentConfig.detune,this.loop=this.currentConfig.loop},resetConfig:function(){this.currentConfig.seek=0,this.currentConfig.delay=0},update:o,calculateRate:function(){var t=this.currentConfig.detune+this.manager.detune,e=Math.pow(1.0005777895065548,t);this.totalRate=this.currentConfig.rate*this.manager.rate*e},destroy:function(){this.pendingRemove||(this.emit("destroy",this),this.pendingRemove=!0,this.manager=null,this.key="",this.removeAllListeners(),this.isPlaying=!1,this.isPaused=!1,this.config=null,this.currentConfig=null,this.markers=null,this.currentMarker=null)}});t.exports=a},function(t,e,i){var n=i(0),s=i(69),r=i(11),o=i(2),a=new n({Extends:r,initialize:function(t){r.call(this),this.game=t,this.jsonCache=t.cache.json,this.sounds=[],this.mute=!1,this.volume=1,this.pauseOnBlur=!0,this._rate=1,this._detune=0,this.locked=this.locked||!1,this.unlocked=!1,t.events.on("blur",function(){this.pauseOnBlur&&this.onBlur()},this),t.events.on("focus",function(){this.pauseOnBlur&&this.onFocus()},this),t.events.on("prestep",this.update,this),t.events.once("destroy",this.destroy,this)},add:o,addAudioSprite:function(t,e){void 0===e&&(e={});var i=this.add(t,e);for(var n in i.spritemap=this.jsonCache.get(t).spritemap,i.spritemap)if(i.spritemap.hasOwnProperty(n)){var r=s(e),o=i.spritemap[n];r.loop=!!o.hasOwnProperty("loop")&&o.loop,i.addMarker({name:n,start:o.start,duration:o.end-o.start,config:r})}return i},play:function(t,e){var i=this.add(t);return i.once("ended",i.destroy,i),e?e.name?(i.addMarker(e),i.play(e.name)):i.play(e):i.play()},playAudioSprite:function(t,e,i){var n=this.addAudioSprite(t);return n.once("ended",n.destroy,n),n.play(e,i)},remove:function(t){var e=this.sounds.indexOf(t);return-1!==e&&(t.destroy(),this.sounds.splice(e,1),!0)},removeByKey:function(t){for(var e=0,i=this.sounds.length-1;i>=0;i--){var n=this.sounds[i];n.key===t&&(n.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:o,onBlur:o,onFocus:o,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(n,s){n.pendingRemove||t.call(e||i,n,s,i.sounds)})},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("detune",this,t)}}});t.exports=a},function(t,e){t.exports={PENDING:0,INIT:1,START:2,LOADING:3,CREATING:4,RUNNING:5,PAUSED:6,SLEEPING:7,SHUTDOWN:8,DESTROYED:9}},function(t,e){t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},function(t,e,i){var n,s=i(101),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(n=navigator.userAgent,/Edge\/\d+/.test(n)?r.edge=!0:/Chrome\/(\d+)/.test(n)&&!s.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(n)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&s.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(n)?r.opera=!0:/Safari/.test(n)&&!s.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(r.silk=!0),r)},function(t,e){t.exports=function(t,e,i){return(e-t)*i+t}},function(t,e){var i,n="";t.exports={disable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!1),t},enable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!0),t},getPrefix:i=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i-y&&T>-m&&b<_&&T-y&&A>-m&&S<_&&As&&(t=s),t},clampY:function(t){var e=this._bounds,i=this.displayHeight,n=e.y+(i-this.height)/2,s=Math.max(n,n+e.height-i);return ts&&(t=s),t},removeBounds:function(){return this.useBounds=!1,this.dirty=!0,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=r(t),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=l(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,n,s){return this._bounds.setTo(t,e,i,n),this.dirty=!0,this.useBounds=!0,s?this.centerToBounds():(this.scrollX=this.clampX(this.scrollX),this.scrollY=this.clampY(this.scrollY)),this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){this.scene&&this._customViewport&&this.sceneManager.customViewports--,this.scene=t,this.config=t.sys.game.config,this.sceneManager=t.sys.game.scene;var e=this.config.resolution;return this.resolution=e,this._cx=this._x*e,this._cy=this._y*e,this._cw=this._width*e,this._ch=this._height*e,this.updateSystem(),this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setZoom:function(t){return void 0===t&&(t=1),0===t&&(t=.001),this.zoom=t,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},update:function(){},updateSystem:function(){if(this.config){var t=0!==this._x||0!==this._y||this.config.width!==this._width||this.config.height!==this._height,e=this.sceneManager;t&&!this._customViewport?e.customViewports++:!t&&this._customViewport&&e.customViewports--,this.dirty=!0,this._customViewport=t}},destroy:function(){this.emit("cameradestroy",this),this.removeAllListeners(),this.matrix.destroy(),this.culledObjects=[],this._customViewport&&this.sceneManager.customViewports--,this._bounds=null,this.scene=null,this.config=null,this.sceneManager=null},x:{get:function(){return this._x},set:function(t){this._x=t,this._cx=t*this.resolution,this.updateSystem()}},y:{get:function(){return this._y},set:function(t){this._y=t,this._cy=t*this.resolution,this.updateSystem()}},width:{get:function(){return this._width},set:function(t){this._width=t,this._cw=t*this.resolution,this.updateSystem()}},height:{get:function(){return this._height},set:function(t){this._height=t,this._ch=t*this.resolution,this.updateSystem()}},scrollX:{get:function(){return this._scrollX},set:function(t){this._scrollX=t,this.dirty=!0}},scrollY:{get:function(){return this._scrollY},set:function(t){this._scrollY=t,this.dirty=!0}},zoom:{get:function(){return this._zoom},set:function(t){this._zoom=t,this.dirty=!0}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=t,this.dirty=!0}},centerX:{get:function(){return this.x+.5*this.width}},centerY:{get:function(){return this.y+.5*this.height}},displayWidth:{get:function(){return this.width/this.zoom}},displayHeight:{get:function(){return this.height/this.zoom}}});t.exports=c},function(t,e){t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},function(t,e){var i={defaultPipeline:null,pipeline:null,initPipeline:function(t){void 0===t&&(t="TextureTintPipeline");var e=this.scene.sys.game.renderer;return!!(e&&e.gl&&e.hasPipeline(t))&&(this.defaultPipeline=e.getPipeline(t),this.pipeline=this.defaultPipeline,!0)},setPipeline:function(t){var e=this.scene.sys.game.renderer;return e&&e.gl&&e.hasPipeline(t)&&(this.pipeline=e.getPipeline(t)),this},resetPipeline:function(){return this.pipeline=this.defaultPipeline,null!==this.pipeline},getPipelineName:function(){return this.pipeline.name}};t.exports=i},function(t,e){t.exports=function(t){return 2*(t.width+t.height)}},function(t,e,i){var n=i(72),s=i(81),r=i(44),o=i(0),a=i(16),h=i(17),l=i(10),u=i(43),c=new o({Extends:h,Mixins:[a.Depth,a.GetBounds,a.Origin,a.ScaleMode,a.Transform,a.ScrollFactor,a.Visible],initialize:function(t,e,i,s,r){void 0===s&&(s=1),void 0===r&&(r=s),h.call(this,t,"Zone"),this.setPosition(e,i),this.width=s,this.height=r,this.blendMode=n.NORMAL,this.updateDisplayOrigin()},displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e,i){return void 0===i&&(i=!0),this.width=t,this.height=e,i&&this.input&&this.input.hitArea instanceof l&&(this.input.hitArea.width=t,this.input.hitArea.height=e),this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this},setCircleDropZone:function(t){return this.setDropZone(new s(0,0,t),r)},setRectangleDropZone:function(t,e){return this.setDropZone(new l(0,0,t,e),u)},setDropZone:function(t,e){return void 0===t?this.setRectangleDropZone(this.width,this.height):this.input||this.setInteractive(t,e,!0),this},setAlpha:function(){},renderCanvas:function(){},renderWebGL:function(){}});t.exports=c},function(t,e){t.exports=function(t,e,i,n,s,r,o,a,h,l,u,c,d){return{target:t,key:e,getEndValue:i,getStartValue:n,ease:s,duration:0,totalDuration:0,delay:0,yoyo:a,hold:0,repeat:0,repeatDelay:0,flipX:c,flipY:d,progress:0,elapsed:0,repeatCounter:0,start:0,current:0,end:0,t1:0,t2:0,gen:{delay:r,duration:o,hold:h,repeat:l,repeatDelay:u},state:0}}},function(t,e,i){var n=i(0),s=i(14),r=i(5),o=i(93),a=new n({initialize:function(t,e,i){this.parent=t,this.parentIsTimeline=t.hasOwnProperty("isTimeline"),this.data=e,this.totalData=e.length,this.targets=i,this.totalTargets=i.length,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.offset=0,this.calculatedOffset=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onRepeat:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},getValue:function(){return this.data[0].current},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},isPaused:function(){return this.state===o.PAUSED},hasTarget:function(t){return-1!==this.targets.indexOf(t)},updateTo:function(t,e,i){for(var n=0;n0&&(n.totalDuration+=n.t2*n.repeat),n.totalDuration>t&&(t=n.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},pause:function(){if(this.state!==o.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=o.PAUSED,this},play:function(t){if(this.state!==o.ACTIVE){this.state!==o.PENDING_REMOVE&&this.state!==o.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.ACTIVE):(this.countdown=this.calculatedOffset,this.state=o.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=o.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.parent.makeActive(this))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(n.elapsed=n.delay,n.state=o.DELAY):n.state=o.PENDING_RENDER}},resume:function(){return this.state===o.PAUSED?(this.paused=!1,this.state=this._pausedState):this.play(),this},seek:function(t){for(var e=this.data,i=0;i=s.totalDuration?(r=1,o=s.duration):n>s.delay&&n<=s.t1?(r=(n=Math.max(0,n-s.delay))/s.t1,o=s.duration*r):n>s.t1&&ns.repeatDelay&&(r=n/s.t1,o=s.duration*r)),s.progress=r,s.elapsed=o;var a=s.ease(s.progress);s.current=s.start+(s.end-s.start)*a,s.target[s.key]=s.current}},setCallback:function(t,e,i,n){return this.callbacks[t]={func:e,scope:n,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},stop:function(t){this.state===o.ACTIVE&&void 0!==t&&this.seek(t),this.state!==o.REMOVED&&(this.state!==o.PAUSED&&this.state!==o.PENDING_ADD||(this.parent._destroy.push(this),this.parent._toProcess++),this.state=o.PENDING_REMOVE)},update:function(t,e){if(this.state===o.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var i=!1,n=0;n0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case o.PLAYING_FORWARD:case o.PLAYING_BACKWARD:if(!e.target){e.state=o.COMPLETE;break}var n=e.elapsed,s=e.duration,r=0;(n+=i)>s&&(r=n-s,n=s);var a,h=e.state===o.PLAYING_FORWARD,l=n/s;a=h?e.ease(l):e.ease(1-l),e.current=e.start+(e.end-e.start)*a,e.target[e.key]=e.current,e.elapsed=n,e.progress=l;var u=t.callbacks.onUpdate;u&&(u.params[1]=e.target,u.func.apply(u.scope,u.params)),1===l&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=o.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case o.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PENDING_RENDER);break;case o.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PLAYING_FORWARD);break;case o.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case o.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=o.PLAYING_FORWARD):e.state=o.COMPLETE}return e.state!==o.COMPLETE}});a.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),s.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=a},function(t,e){t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1}},function(t,e){function i(t){return!!t.getStart&&"function"==typeof t.getStart}function n(t){return!!t.getEnd&&"function"==typeof t.getEnd}var s=function(t,e){var r,o,a=function(t,e,i){return i},h=function(t,e,i){return i},l=typeof e;if("number"===l)a=function(){return e};else if("string"===l){var u=e[0],c=parseFloat(e.substr(2));switch(u){case"+":a=function(t,e,i){return i+c};break;case"-":a=function(t,e,i){return i-c};break;case"*":a=function(t,e,i){return i*c};break;case"/":a=function(t,e,i){return i/c};break;default:a=function(){return parseFloat(e)}}}else"function"===l?a=e:"object"===l&&(i(o=e)||n(o))?(n(e)&&(a=e.getEnd),i(e)&&(h=e.getStart)):e.hasOwnProperty("value")&&(r=s(t,e.value));return r||(r={getEnd:a,getStart:h}),r};t.exports=s},function(t,e,i){var n=i(4);t.exports=function(t){var e=n(t,"targets",null);return null===e?e:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},function(t,e,i){var n=i(30),s=i(86),r=i(230),o=i(222);t.exports=function(t,e,i,a,h,l,u,c){void 0===i&&(i=32),void 0===a&&(a=32),void 0===h&&(h=10),void 0===l&&(l=10),void 0===c&&(c=!1);var d=null;if(Array.isArray(u))d=r(void 0!==e?e:"map",n.ARRAY_2D,u,i,a,c);else if(void 0!==e){var f=t.cache.tilemap.get(e);f?d=r(e,f.format,f.data,i,a,c):console.warn("No map data found for key "+e)}return null===d&&(d=new s({tileWidth:i,tileHeight:a,width:h,height:l})),new o(t,d)}},function(t,e,i){var n=i(30),s=i(87),r=i(86),o=i(61);t.exports=function(t,e,i,a,h){for(var l=new s({tileWidth:i,tileHeight:a}),u=new r({name:t,tileWidth:i,tileHeight:a,format:n.ARRAY_2D,layers:[l]}),c=[],d=e.length,f=0,p=0;pr?(s.warn("Plugin.register:",n.toString(e),"was upgraded to",n.toString(t)),n._registry[t.name]=t):i-1},n.isFor=function(t,e){var i=t.for&&n.dependencyParse(t.for);return!t.for||e.name===i.name&&n.versionSatisfies(e.version,i.range)},n.use=function(t,e){if(t.uses=(t.uses||[]).concat(e||[]),0!==t.uses.length){for(var i=n.dependencies(t),r=s.topologicalSort(i),o=[],a=0;a0&&!h.silent&&s.info(o.join(" "))}else s.warn("Plugin.use:",n.toString(t),"does not specify any dependencies to install.")},n.dependencies=function(t,e){var i=n.dependencyParse(t),r=i.name;if(!(r in(e=e||{}))){t=n.resolve(t)||t,e[r]=s.map(t.uses||[],function(e){n.isPlugin(e)&&n.register(e);var r=n.dependencyParse(e),o=n.resolve(e);return o&&!n.versionSatisfies(o.version,r.range)?(s.warn("Plugin.dependencies:",n.toString(o),"does not satisfy",n.toString(r),"used by",n.toString(i)+"."),o._warned=!0,t._warned=!0):o||(s.warn("Plugin.dependencies:",n.toString(e),"used by",n.toString(i),"could not be resolved."),t._warned=!0),r.name});for(var o=0;o=s[2];if("^"===i.operator)return s[0]>0?o[0]===s[0]&&r.number>=i.number:s[1]>0?o[1]===s[1]&&o[2]>=s[2]:o[2]===s[2]}return t===e||"*"===t}},function(t,e,i){var n=i(240);n.Body=i(25),n.Composite=i(63),n.World=i(146),n.Detector=i(150),n.Grid=i(239),n.Pairs=i(238),n.Pair=i(112),n.Query=i(536),n.Resolver=i(237),n.SAT=i(149),n.Constraint=i(73),n.Common=i(12),n.Engine=i(236),n.Events=i(74),n.Sleeping=i(89),n.Plugin=i(147),n.Bodies=i(55),n.Composites=i(243),n.Axes=i(152),n.Bounds=i(33),n.Svg=i(534),n.Vector=i(34),n.Vertices=i(29),n.World.add=n.Composite.add,n.World.remove=n.Composite.remove,n.World.addComposite=n.Composite.addComposite,n.World.addBody=n.Composite.addBody,n.World.addConstraint=n.Composite.addConstraint,n.World.clear=n.Composite.clear,t.exports=n},function(t,e,i){var n={};t.exports=n;var s=i(29),r=i(34);n.collides=function(t,e,i){var o,a,h,l,u=!1;if(i){var c=t.parent,d=e.parent,f=c.speed*c.speed+c.angularSpeed*c.angularSpeed+d.speed*d.speed+d.angularSpeed*d.angularSpeed;u=i&&i.collided&&f<.2,l=i}else l={collided:!1,bodyA:t,bodyB:e};if(i&&u){var p=l.axisBody,g=p===t?e:t,v=[p.axes[i.axisNumber]];if(h=n._overlapAxes(p.vertices,g.vertices,v),l.reused=!0,h.overlap<=0)return l.collided=!1,l}else{if((o=n._overlapAxes(t.vertices,e.vertices,t.axes)).overlap<=0)return l.collided=!1,l;if((a=n._overlapAxes(e.vertices,t.vertices,e.axes)).overlap<=0)return l.collided=!1,l;o.overlaps?s=a:a=0?o.index-1:u.length-1],l.x=s.x-c.x,l.y=s.y-c.y,h=-r.dot(i,l),a=s,s=u[(o.index+1)%u.length],l.x=s.x-c.x,l.y=s.y-c.y,(n=-r.dot(i,l))1?1:0;d1?1:0;p0:0!=(t.mask&e.category)&&0!=(e.mask&t.category)}},function(t,e,i){var n=i(55),s=i(25),r=i(0),o=i(113),a=i(1),h=i(77),l=i(29),u=new r({Mixins:[o.Bounce,o.Collision,o.Friction,o.Gravity,o.Mass,o.Sensor,o.Sleep,o.Static],initialize:function(t,e,i){this.tile=e,this.world=t,e.physics.matterBody&&e.physics.matterBody.destroy(),e.physics.matterBody=this;var n=a(i,"body",null),s=a(i,"addToWorld",!0);if(n)this.setBody(n,s);else{var r=e.getCollisionGroup();a(r,"objects",[]).length>0?this.setFromTileCollision(i):this.setFromTileRectangle(i)}},setFromTileRectangle:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);var e=this.tile.getBounds(),i=e.x+e.width/2,s=e.y+e.height/2,r=n.rectangle(i,s,e.width,e.height,t);return this.setBody(r,t.addToWorld),this},setFromTileCollision:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);for(var e=this.tile.tilemapLayer.scaleX,i=this.tile.tilemapLayer.scaleY,r=this.tile.getLeft(),o=this.tile.getTop(),u=this.tile.getCollisionGroup(),c=a(u,"objects",[]),d=[],f=0;f1&&(t.parts=d,this.setBody(s.create(t),t.addToWorld)),this},setBody:function(t,e){return void 0===e&&(e=!0),this.body&&this.removeBody(),this.body=t,this.body.gameObject=this,e&&this.world.add(this.body),this},removeBody:function(){return this.body&&(this.world.remove(this.body),this.body.gameObject=void 0,this.body=void 0),this},destroy:function(){this.removeBody(),this.tile.physics.matterBody=void 0}});t.exports=u},function(t,e,i){var n={};t.exports=n;var s=i(34),r=i(12);n.fromVertices=function(t){for(var e={},i=0;i0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return this.x=i*o-n*r,this.y=n*s-e*o,this.z=e*r-i*s,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this},transformMat3:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=e*s[0]+i*s[3]+n*s[6],this.y=e*s[1]+i*s[4]+n*s[7],this.z=e*s[2]+i*s[5]+n*s[8],this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12],this.y=s[1]*e+s[5]*i+s[9]*n+s[13],this.z=s[2]*e+s[6]*i+s[10]*n+s[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=e*s[0]+i*s[4]+n*s[8]+s[12],o=e*s[1]+i*s[5]+n*s[9]+s[13],a=e*s[2]+i*s[6]+n*s[10]+s[14],h=e*s[3]+i*s[7]+n*s[11]+s[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},project:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=s[0],o=s[1],a=s[2],h=s[3],l=s[4],u=s[5],c=s[6],d=s[7],f=s[8],p=s[9],g=s[10],v=s[11],y=s[12],m=s[13],x=s[14],w=1/(e*h+i*d+n*v+s[15]);return this.x=(e*r+i*l+n*f+y)*w,this.y=(e*o+i*u+n*p+m)*w,this.z=(e*a+i*c+n*g+x)*w,this},unproject:function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,o=this.x-i,a=r-this.y-1-n,h=this.z;return this.x=2*o/s-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,e,i){var n=i(0),s=i(20),r=i(22),o=i(7),a=i(1),h=i(8),l=i(379),u=new n({Extends:r,initialize:function(t,e,i,n){var s="xml";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),n=a(o,"xhrSettings"),s=a(o,"extension",s)}var l={type:"xml",cache:t.cacheManager.xml,extension:s,responseType:"text",key:e,url:i,xhrSettings:n};r.call(this,t,l)},onProcess:function(){this.state=s.FILE_PROCESSING,this.data=l(this.xhrLoader.responseText),this.data?this.onProcessComplete():(console.warn("Invalid XMLFile: "+this.key),this.onProcessError())}});o.register("xml",function(t,e,i){if(Array.isArray(t))for(var n=0;n=0&&r>=0&&s+r<1&&(n.push({x:e[b].x,y:e[b].y}),i)));b++);return n}},function(t,e){t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.righte.right||t.y>e.bottom)}},function(t,e,i){var n=i(0),s=i(118),r=new n({Extends:s,initialize:function(t,e,i,n,r){s.call(this,t,e,i,[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1,1,0],[16777215,16777215,16777215,16777215,16777215,16777215],[1,1,1,1,1,1],n,r),this.resetPosition()},setFrame:function(t){return this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,t=this.frame,this.uv[0]=t.u0,this.uv[1]=t.v0,this.uv[2]=t.u0,this.uv[3]=t.v1,this.uv[4]=t.u1,this.uv[5]=t.v1,this.uv[6]=t.u0,this.uv[7]=t.v0,this.uv[8]=t.u1,this.uv[9]=t.v1,this.uv[10]=t.u1,this.uv[11]=t.v0,this},topLeftX:{get:function(){return this.x+this.vertices[0]},set:function(t){this.vertices[0]=t-this.x,this.vertices[6]=t-this.x}},topLeftY:{get:function(){return this.y+this.vertices[1]},set:function(t){this.vertices[1]=t-this.y,this.vertices[7]=t-this.y}},topRightX:{get:function(){return this.x+this.vertices[10]},set:function(t){this.vertices[10]=t-this.x}},topRightY:{get:function(){return this.y+this.vertices[11]},set:function(t){this.vertices[11]=t-this.y}},bottomLeftX:{get:function(){return this.x+this.vertices[2]},set:function(t){this.vertices[2]=t-this.x}},bottomLeftY:{get:function(){return this.y+this.vertices[3]},set:function(t){this.vertices[3]=t-this.y}},bottomRightX:{get:function(){return this.x+this.vertices[4]},set:function(t){this.vertices[4]=t-this.x,this.vertices[8]=t-this.x}},bottomRightY:{get:function(){return this.y+this.vertices[5]},set:function(t){this.vertices[5]=t-this.y,this.vertices[9]=t-this.y}},topLeftAlpha:{get:function(){return this.alphas[0]},set:function(t){this.alphas[0]=t,this.alphas[3]=t}},topRightAlpha:{get:function(){return this.alphas[5]},set:function(t){this.alphas[5]=t}},bottomLeftAlpha:{get:function(){return this.alphas[1]},set:function(t){this.alphas[1]=t}},bottomRightAlpha:{get:function(){return this.alphas[2]},set:function(t){this.alphas[2]=t,this.alphas[4]=t}},topLeftColor:{get:function(){return this.colors[0]},set:function(t){this.colors[0]=t,this.colors[3]=t}},topRightColor:{get:function(){return this.colors[5]},set:function(t){this.colors[5]=t}},bottomLeftColor:{get:function(){return this.colors[1]},set:function(t){this.colors[1]=t}},bottomRightColor:{get:function(){return this.colors[2]},set:function(t){this.colors[2]=t,this.colors[4]=t}},setTopLeft:function(t,e){return this.topLeftX=t,this.topLeftY=e,this},setTopRight:function(t,e){return this.topRightX=t,this.topRightY=e,this},setBottomLeft:function(t,e){return this.bottomLeftX=t,this.bottomLeftY=e,this},setBottomRight:function(t,e){return this.bottomRightX=t,this.bottomRightY=e,this},resetPosition:function(){var t=this.x,e=this.y,i=Math.floor(this.width/2),n=Math.floor(this.height/2);return this.setTopLeft(t-i,e-n),this.setTopRight(t+i,e-n),this.setBottomLeft(t-i,e+n),this.setBottomRight(t+i,e+n),this},resetAlpha:function(){var t=this.alphas;return t[0]=1,t[1]=1,t[2]=1,t[3]=1,t[4]=1,t[5]=1,this},resetColors:function(){var t=this.colors;return t[0]=16777215,t[1]=16777215,t[2]=16777215,t[3]=16777215,t[4]=16777215,t[5]=16777215,this},reset:function(){return this.resetPosition(),this.resetAlpha(),this.resetColors()}});t.exports=r},function(t,e){t.exports=function(t,e,i){for(var n=!1,s=-1,r=t.points.length-1;++sl){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var v=d.substr(g.length);u[c]=v,h+=g}var y=u[c].length?c:c+1,m=u.slice(y).join(" ").replace(/[ \n]*$/gi,"");s[o+1]=m+" "+(s[o+1]||""),r=s.length;break}h+=f,l-=p}n+=h.replace(/[ \n]*$/gi,"")+"\n"}}return n=n.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var n="",s=t.split(this.splitRegExp),r=0;ro?(h>0&&(n+="\n"),n+=a[h]+" ",o=i-l):(o-=u,n+=a[h],h0&&(a+=u.lineSpacing*p),i.rtl?o=d-o:"right"===i.align?o+=u.width-u.lineWidths[p]:"center"===i.align&&(o+=(u.width-u.lineWidths[p])/2),this.autoRound&&(o=Math.round(o),a=Math.round(a)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],o,a)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],o,a));return e.restore(),this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(t,this.frame.source.glTexture,!0),this.frame.glTexture=this.frame.source.glTexture),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},text:{get:function(){return this._text},set:function(t){this.setText(t)}},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this._text,style:this.style.toJSON(),padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),s.remove(this.canvas),this.texture.destroy()}});t.exports=p},function(t,e,i){var n=i(131),s=i(26),r=i(0),o=i(16),a=i(28),h=i(123),l=i(17),u=i(884),c=i(323),d=new r({Extends:l,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Crop,o.Depth,o.Flip,o.GetBounds,o.Mask,o.Origin,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Tint,o.Transform,o.Visible,u],initialize:function(t,e,i,r,o){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=32),void 0===o&&(o=32),l.call(this,t,"RenderTexture"),this.renderer=t.sys.game.renderer,this.textureManager=t.sys.textures,this.globalTint=16777215,this.globalAlpha=1,this.canvas=s.create2D(this,r,o),this.context=this.canvas.getContext("2d"),this.framebuffer=null,this._crop=this.resetCropObject(),this.texture=t.sys.textures.addCanvas(c(),this.canvas),this.frame=this.texture.get(),this._saved=!1,this.camera=new n(0,0,r,o),this.dirty=!1,this.gl=null;var h=this.renderer;if(h.type===a.WEBGL){var u=h.gl;this.gl=u,this.drawGameObject=this.batchGameObjectWebGL,this.framebuffer=h.createFramebuffer(r,o,this.frame.source.glTexture,!1)}else h.type===a.CANVAS&&(this.drawGameObject=this.batchGameObjectCanvas);this.camera.setScene(t),this.setPosition(e,i),this.setSize(r,o),this.setOrigin(0,0),this.initPipeline()},setSize:function(t,e){return this.resize(t,e)},resize:function(t,e){if(void 0===e&&(e=t),t!==this.width||e!==this.height){if(this.canvas.width=t,this.canvas.height=e,this.gl){var i=this.gl;this.renderer.deleteTexture(this.frame.source.glTexture),this.renderer.deleteFramebuffer(this.framebuffer),this.frame.source.glTexture=this.renderer.createTexture2D(0,i.NEAREST,i.NEAREST,i.CLAMP_TO_EDGE,i.CLAMP_TO_EDGE,i.RGBA,null,t,e,!1),this.framebuffer=this.renderer.createFramebuffer(t,e,this.frame.source.glTexture,!1),this.frame.glTexture=this.frame.source.glTexture}this.frame.source.width=t,this.frame.source.height=e,this.camera.setSize(t,e),this.frame.setSize(t,e),this.width=t,this.height=e}return this},setGlobalTint:function(t){return this.globalTint=t,this},setGlobalAlpha:function(t){return this.globalAlpha=t,this},saveTexture:function(t){return this.textureManager.renameTexture(this.texture.key,t),this._saved=!0,this.texture},fill:function(t,e){void 0===e&&(e=1);var i=255&(t>>16|0),n=255&(t>>8|0),s=255&(0|t);if(this.gl){this.renderer.setFramebuffer(this.framebuffer);var r=this.gl;r.clearColor(i/255,n/255,s/255,e),r.clear(r.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null)}else this.context.fillStyle="rgb("+i+","+n+","+s+")",this.context.fillRect(0,0,this.canvas.width,this.canvas.height);return this},clear:function(){if(this.dirty){if(this.gl){this.renderer.setFramebuffer(this.framebuffer);var t=this.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null)}else{var e=this.context;e.save(),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,this.canvas.width,this.canvas.height),e.restore()}this.dirty=!1}return this},draw:function(t,e,i,n,s){void 0===n&&(n=this.globalAlpha),s=void 0===s?(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16):(s>>16)+(65280&s)+((255&s)<<16),Array.isArray(t)||(t=[t]);var r=this.gl;if(this.camera.preRender(1,1,1),r){this.renderer.setFramebuffer(this.framebuffer);var o=this.pipeline;o.projOrtho(0,this.width,0,this.height,-1e3,1e3),this.batchList(t,e,i,n,s),o.flush(),this.renderer.setFramebuffer(null),o.projOrtho(0,o.width,o.height,0,-1e3,1e3)}else this.renderer.setContext(this.context),this.batchList(t,e,i,n,s),this.renderer.setContext();return this.dirty=!0,this},drawFrame:function(t,e,i,n,s,r){void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=this.globalAlpha),r=void 0===r?(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16):(r>>16)+(65280&r)+((255&r)<<16);var o=this.gl,a=this.textureManager.getFrame(t,e);if(a){if(this.camera.preRender(1,1,1),o){this.renderer.setFramebuffer(this.framebuffer);var h=this.pipeline;h.projOrtho(0,this.width,0,this.height,-1e3,1e3),h.batchTextureFrame(a,i,n,r,s,this.camera.matrix,null),h.flush(),this.renderer.setFramebuffer(null),h.projOrtho(0,h.width,h.height,0,-1e3,1e3)}else this.batchTextureFrame(a,i,n,s,r);this.dirty=!0}return this},batchList:function(t,e,i,n,s){for(var r=0;r0?e.defaultFrame=i[0]:e.defaultFrame=this.defaultFrame,this},addEmitter:function(t){return this.emitters.add(t)},createEmitter:function(t){return this.addEmitter(new h(this,t))},addGravityWell:function(t){return this.wells.add(t)},createGravityWell:function(t){return this.addGravityWell(new o(t))},emitParticle:function(t,e,i){for(var n=this.emitters.list,s=0;s-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var n,s,r=this.scene.sys,o=r.game.renderer;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),w.TargetCamera.setScene(this.scene),w.TargetCamera.setViewport(0,0,e,i),w.TargetCamera.scrollX=this.x,w.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var a=(n=r.textures.get(t)).getSourceImage();a instanceof HTMLCanvasElement&&(s=a.getContext("2d"))}else s=(n=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(s=t.getContext("2d"));return s&&(this.renderCanvas(o,this,0,w.TargetCamera,null,s,!1),n&&n.refresh()),this},preDestroy:function(){this.commandBuffer=[]}});w.TargetCamera=new n,t.exports=w},function(t,e,i){var n=i(119),s=i(0),r=i(901),o=new s({Extends:n,Mixins:[r],initialize:function(t,e,i,s,r,o,a){n.call(this,t,e,i,s,r,o,a),this.type="DynamicBitmapText",this.scrollX=0,this.scrollY=0,this.cropWidth=0,this.cropHeight=0,this.displayCallback,this.callbackData={color:0,tint:{topLeft:0,topRight:0,bottomLeft:0,bottomRight:0},index:0,charCode:0,x:0,y:0,scale:0,rotation:0,data:0}},setSize:function(t,e){return this.cropWidth=t,this.cropHeight=e,this},setDisplayCallback:function(t){return this.displayCallback=t,this},setScrollX:function(t){return this.scrollX=t,this},setScrollY:function(t){return this.scrollY=t,this}});t.exports=o},function(t,e,i){var n=i(180),s=i(72),r=i(0),o=i(16),a=i(17),h=i(10),l=i(904),u=i(337),c=i(3),d=new r({Extends:a,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Depth,o.Mask,o.ScrollFactor,o.Transform,o.Visible,l],initialize:function(t,e,i,n){a.call(this,t,"Container"),this.list=[],this.exclusive=!0,this.maxSize=-1,this.position=0,this.localTransform=new o.TransformMatrix,this.tempTransformMatrix=new o.TransformMatrix,this._displayList=t.sys.displayList,this._sortKey="",this._sysEvents=t.sys.events,this.setPosition(e,i),this.clearAlpha(),this.setBlendMode(s.SKIP_CHECK),n&&this.add(n)},originX:{get:function(){return.5}},originY:{get:function(){return.5}},displayOriginX:{get:function(){return.5*this.width}},displayOriginY:{get:function(){return.5*this.height}},setExclusive:function(t){return void 0===t&&(t=!0),this.exclusive=t,this},getBounds:function(t){if(void 0===t&&(t=new h),t.setTo(this.x,this.y,0,0),this.list.length>0)for(var e=this.list,i=new h,n=0;n-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){var i,n=[null],s=this.list.slice(),r=s.length;for(i=2;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}},preDestroy:function(){this.removeAll(!!this.exclusive),this.localTransform.destroy(),this.tempTransformMatrix.destroy(),this.list=[],this._displayList=null}});t.exports=d},function(t,e,i){var n=i(908),s=i(905),r=i(0),o=i(16),a=i(123),h=i(17),l=i(122),u=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Mask,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,n],initialize:function(t,e,i,n,s){h.call(this,t,"Blitter"),this.setTexture(n,s),this.setPosition(e,i),this.initPipeline(),this.children=new l,this.renderList=[],this.dirty=!1},create:function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new s(this,t,e,i,n);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,n){for(var s=this.createMultiple(e,i,n),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0},preDestroy:function(){this.children.destroy(),this.renderList=[]}});t.exports=u},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var n=e+Math.floor(Math.random()*i);return void 0===t[n]?null:t[n]}},function(t,e){t.exports=function(t){if(!Array.isArray(t)||t.length<2||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i0},isTransitionIn:function(){return this.settings.isTransition},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t,e){return t?this.resume(e):this.pause(e)},start:function(t){t&&(this.settings.data=t),this.settings.status=s.START,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this),this.events.emit("ready",this,t)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(t){this.events.off("transitioninit"),this.events.off("transitionstart"),this.events.off("transitioncomplete"),this.events.off("transitionout"),this.settings.status=s.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this,t)},destroy:function(){this.settings.status=s.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this),this.events.removeAllListeners();for(var t=["scene","game","anims","cache","plugins","registry","sound","textures","add","camera","displayList","events","make","scenePlugin","updateList"],e=0;e0?(n.textures[e-1]&&n.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==n.texture&&n.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,n=this.gl,s=this.vertexCount,r=this.topology,o=this.vertexSize,a=this.renderer,h=this.batches,l=0,u=null;if(0===h.length||0===s)return this.flushLocked=!1,this;n.bufferSubData(n.ARRAY_BUFFER,0,this.bytes.subarray(0,s*o));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(a.setTexture2D(u.texture,0),n.drawArrays(r,u.first,l)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},batchSprite:function(t,e,i){this.renderer.setPipeline(this);var n=this._tempMatrix1,s=this._tempMatrix2,r=this._tempMatrix3,o=t.frame,a=o.glTexture,h=o.u0,l=o.v0,c=o.u1,d=o.v1,f=o.x,p=o.y,g=o.cutWidth,v=o.cutHeight,y=-t.displayOriginX+f,m=-t.displayOriginY+p;if(t.isCropped){var x=t._crop;x.flipX===t.flipX&&x.flipY===t.flipY||o.updateCropUVs(x,t.flipX,t.flipY),h=x.u0,l=x.v0,c=x.u1,d=x.v1,g=x.width,v=x.height,f=x.x,p=x.y,y=-t.displayOriginX+f,m=-t.displayOriginY+p}t.flipX&&(y+=g,g*=-1),t.flipY&&(m+=v,v*=-1);var w=y+g,b=m+v;s.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),n.copyFrom(e.matrix),i?(n.multiplyWithOffset(i,-e.scrollX*t.scrollFactorX,-e.scrollY*t.scrollFactorY),s.e=t.x,s.f=t.y,n.multiply(s,r)):(s.e-=e.scrollX*t.scrollFactorX,s.f-=e.scrollY*t.scrollFactorY,n.multiply(s,r));var T=r.getX(y,m),S=r.getY(y,m),A=r.getX(y,b),_=r.getY(y,b),C=r.getX(w,b),M=r.getY(w,b),P=r.getX(w,m),E=r.getY(w,m),k=u.getTintAppendFloatAlpha(t._tintTL,e.alpha*t._alphaTL),F=u.getTintAppendFloatAlpha(t._tintTR,e.alpha*t._alphaTR),L=u.getTintAppendFloatAlpha(t._tintBL,e.alpha*t._alphaBL),R=u.getTintAppendFloatAlpha(t._tintBR,e.alpha*t._alphaBR);e.roundPixels&&(T|=0,S|=0,A|=0,_|=0,C|=0,M|=0,P|=0,E|=0),this.setTexture2D(a,0);var O=t._isTinted&&t.tintFill;this.batchQuad(T,S,A,_,C,M,P,E,h,l,c,d,k,F,L,R,O)},batchQuad:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f,p,g,v){var y=!1;this.vertexCount+6>this.vertexCapacity&&(this.flush(),y=!0);var m=this.vertexViewF32,x=this.vertexViewU32,w=this.vertexCount*this.vertexComponentCount-1;return m[++w]=t,m[++w]=e,m[++w]=h,m[++w]=l,m[++w]=v,x[++w]=d,m[++w]=i,m[++w]=n,m[++w]=h,m[++w]=c,m[++w]=v,x[++w]=p,m[++w]=s,m[++w]=r,m[++w]=u,m[++w]=c,m[++w]=v,x[++w]=g,m[++w]=t,m[++w]=e,m[++w]=h,m[++w]=l,m[++w]=v,x[++w]=d,m[++w]=s,m[++w]=r,m[++w]=u,m[++w]=c,m[++w]=v,x[++w]=g,m[++w]=o,m[++w]=a,m[++w]=u,m[++w]=l,m[++w]=v,x[++w]=f,this.vertexCount+=6,y},batchTri:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f){var p=!1;this.vertexCount+3>this.vertexCapacity&&(this.flush(),p=!0);var g=this.vertexViewF32,v=this.vertexViewU32,y=this.vertexCount*this.vertexComponentCount-1;return g[++y]=t,g[++y]=e,g[++y]=o,g[++y]=a,g[++y]=f,v[++y]=u,g[++y]=i,g[++y]=n,g[++y]=o,g[++y]=l,g[++y]=f,v[++y]=c,g[++y]=s,g[++y]=r,g[++y]=h,g[++y]=l,g[++y]=f,v[++y]=d,this.vertexCount+=3,p},batchTexture:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f,p,g,v,y,m,x,w,b,T,S,A,_,C,M,P,E,k){this.renderer.setPipeline(this,t);var F=this._tempMatrix1,L=this._tempMatrix2,R=this._tempMatrix3,O=y/i+C,D=m/n+M,I=(y+x)/i+C,B=(m+w)/n+M,Y=o,X=a,z=-g,N=-v;if(t.isCropped){var U=t._crop;Y=U.width,X=U.height,o=U.width,a=U.height;var V=y=U.x,G=m=U.y;c&&(V=x-U.x-U.width),d&&!e.isRenderTexture&&(G=w-U.y-U.height),O=V/i+C,D=G/n+M,I=(V+U.width)/i+C,B=(G+U.height)/n+M,z=-g+y,N=-v+m}d^=!k&&e.isRenderTexture?1:0,c&&(Y*=-1,z+=o),d&&(X*=-1,N+=a);var W=z+Y,H=N+X;L.applyITRS(s,r,u,h,l),F.copyFrom(P.matrix),E?(F.multiplyWithOffset(E,-P.scrollX*f,-P.scrollY*p),L.e=s,L.f=r,F.multiply(L,R)):(L.e-=P.scrollX*f,L.f-=P.scrollY*p,F.multiply(L,R));var j=R.getX(z,N),q=R.getY(z,N),K=R.getX(z,H),J=R.getY(z,H),Z=R.getX(W,H),Q=R.getY(W,H),$=R.getX(W,N),tt=R.getY(W,N);P.roundPixels&&(j|=0,q|=0,K|=0,J|=0,Z|=0,Q|=0,$|=0,tt|=0),this.setTexture2D(e,0),this.batchQuad(j,q,K,J,Z,Q,$,tt,O,D,I,B,b,T,S,A,_)},batchTextureFrame:function(t,e,i,n,s,r,o){this.renderer.setPipeline(this);var a=this._tempMatrix1.copyFrom(r),h=this._tempMatrix2,l=e+t.width,c=i+t.height;o?a.multiply(o,h):h=a;var d=h.getX(e,i),f=h.getY(e,i),p=h.getX(e,c),g=h.getY(e,c),v=h.getX(l,c),y=h.getY(l,c),m=h.getX(l,i),x=h.getY(l,i);this.setTexture2D(t.glTexture,0),n=u.getTintAppendFloatAlpha(n,s),this.batchQuad(d,f,p,g,v,y,m,x,t.u0,t.v0,t.u1,t.v1,n,n,n,n,0)},drawFillRect:function(t,e,i,n,s,r){var o=t+i,a=e+n,h=u.getTintAppendFloatAlphaAndSwap(s,r);this.batchQuad(t,e,t,a,o,a,o,e,0,0,1,1,h,h,h,h,2)},batchFillRect:function(t,e,i,n,s,r){this.renderer.setPipeline(this);var o=this._tempMatrix3;r&&r.multiply(s,o);var a=t+i,h=e+n,l=o.getX(t,e),u=o.getY(t,e),c=o.getX(t,h),d=o.getY(t,h),f=o.getX(a,h),p=o.getY(a,h),g=o.getX(a,e),v=o.getY(a,e),y=this.currentFrame,m=y.u0,x=y.v0,w=y.u1,b=y.v1;this.batchQuad(l,u,c,d,f,p,g,v,m,x,w,b,this.fillTint.TL,this.fillTint.TR,this.fillTint.BL,this.fillTint.BR,this.tintEffect)},batchFillTriangle:function(t,e,i,n,s,r,o,a){this.renderer.setPipeline(this);var h=this._tempMatrix3;a&&a.multiply(o,h);var l=h.getX(t,e),u=h.getY(t,e),c=h.getX(i,n),d=h.getY(i,n),f=h.getX(s,r),p=h.getY(s,r),g=this.currentFrame,v=g.u0,y=g.v0,m=g.u1,x=g.v1;this.batchTri(l,u,c,d,f,p,v,y,m,x,this.fillTint.TL,this.fillTint.TR,this.fillTint.BL,this.tintEffect)},batchStrokeTriangle:function(t,e,i,n,s,r,o,a,h){var l=this.tempTriangle;l[0].x=t,l[0].y=e,l[0].width=o,l[1].x=i,l[1].y=n,l[1].width=o,l[2].x=s,l[2].y=r,l[2].width=o,l[3].x=t,l[3].y=e,l[3].width=o,this.batchStrokePath(l,o,!1,a,h)},batchFillPath:function(t,e,i){this.renderer.setPipeline(this);var n=this._tempMatrix3;i&&i.multiply(e,n);for(var r,o,a=t.length,h=this.polygonCache,l=this.fillTint.TL,u=this.fillTint.TR,c=this.fillTint.BL,d=this.tintEffect,f=0;f0&&H[4]?this.batchQuad(R,O,E,k,H[0],H[1],H[2],H[3],U,V,G,W,B,Y,X,z,I):(j[0]=R,j[1]=O,j[2]=E,j[3]=k,j[4]=1),h&&j[4]?this.batchQuad(M,P,F,L,j[0],j[1],j[2],j[3],U,V,G,W,B,Y,X,z,I):(H[0]=M,H[1]=P,H[2]=F,H[3]=L,H[4]=1)}}});t.exports=d},function(t,e,i){var n=i(0),s=i(9),r=new n({initialize:function(t){this.name="WebGLPipeline",this.game=t.game,this.view=t.game.canvas,this.resolution=t.game.config.resolution,this.width=t.game.config.width*this.resolution,this.height=t.game.config.height*this.resolution,this.gl=t.gl,this.vertexCount=0,this.vertexCapacity=t.vertexCapacity,this.renderer=t.renderer,this.vertexData=t.vertices?t.vertices:new ArrayBuffer(t.vertexCapacity*t.vertexSize),this.vertexBuffer=this.renderer.createVertexBuffer(t.vertices?t.vertices:this.vertexData.byteLength,this.gl.STREAM_DRAW),this.program=this.renderer.createProgram(t.vertShader,t.fragShader),this.attributes=t.attributes,this.vertexSize=t.vertexSize,this.topology=t.topology,this.bytes=new Uint8Array(this.vertexData),this.vertexComponentCount=s.getComponentCount(t.attributes,this.gl),this.flushLocked=!1,this.active=!1},boot:function(){},addAttribute:function(t,e,i,n,s){return this.attributes.push({name:t,size:e,type:this.renderer.glFormats[i],normalized:n,offset:s}),this},shouldFlush:function(){return this.vertexCount>=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,n=this.program,s=this.renderer,r=this.vertexSize;s.setProgram(n),s.setVertexBuffer(e);for(var o=0;o=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,a.size,a.type,a.normalized,r,a.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,n=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*n)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,n){return this.renderer.setFloat3(this.program,t,e,i,n),this},setFloat4:function(t,e,i,n,s){return this.renderer.setFloat4(this.program,t,e,i,n,s),this},setFloat1v:function(t,e){return this.renderer.setFloat1v(this.program,t,e),this},setFloat2v:function(t,e){return this.renderer.setFloat2v(this.program,t,e),this},setFloat3v:function(t,e){return this.renderer.setFloat3v(this.program,t,e),this},setFloat4v:function(t,e){return this.renderer.setFloat4v(this.program,t,e),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,n){return this.renderer.setInt3(this.program,t,e,i,n),this},setInt4:function(t,e,i,n,s){return this.renderer.setInt4(this.program,t,e,i,n,s),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e,i){var n={Global:["game","anims","cache","plugins","registry","scale","sound","textures"],CoreScene:["EventEmitter","CameraManager","GameObjectCreator","GameObjectFactory","ScenePlugin","DisplayList","UpdateList"],DefaultScene:["Clock","DataManagerPlugin","InputPlugin","Loader","TweenManager","LightsPlugin"]};n.Global.push("facebook"),t.exports=n},function(t,e,i){var n=i(101),s=i(128),r=i(26),o={canvas:!1,canvasBitBltShift:null,file:!1,fileSystem:!1,getUserMedia:!0,littleEndian:!1,localStorage:!1,pointerLock:!1,support32bit:!1,vibration:!1,webGL:!1,worker:!1};t.exports=function(){o.canvas=!!window.CanvasRenderingContext2D||n.cocoonJS;try{o.localStorage=!!localStorage.getItem}catch(t){o.localStorage=!1}o.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),o.fileSystem=!!window.requestFileSystem;var t,e,i,a=!1;return o.webGL=function(){if(window.WebGLRenderingContext)try{var t=r.createWebGL(this);n.cocoonJS&&(t.screencanvas=!1);var e=t.getContext("webgl")||t.getContext("experimental-webgl"),i=r.create2D(this),s=i.getContext("2d").createImageData(1,1);return a=s.data instanceof Uint8ClampedArray,r.remove(t),r.remove(i),!!e}catch(t){return!1}return!1}(),o.worker=!!window.Worker,o.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,o.getUserMedia=o.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,s.firefox&&s.firefoxVersion<21&&(o.getUserMedia=!1),!n.iOS&&(s.ie||s.firefox||s.chrome)&&(o.canvasBitBltShift=!0),(s.safari||s.mobileSafari)&&(o.canvasBitBltShift=!1),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(o.vibration=!0),"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(o.littleEndian=(t=new ArrayBuffer(4),e=new Uint8Array(t),i=new Uint32Array(t),e[0]=161,e[1]=178,e[2]=195,e[3]=212,3569595041===i[0]||2712847316!==i[0]&&null)),o.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==o.littleEndian&&a,o}()},function(t,e){t.exports=function(t,e,i){var n;if(void 0===i&&(i=!0),e)"string"==typeof e?n=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(n=e);else if(t.parentElement)return t;return n||(n=document.body),i&&n.style&&(n.style.overflow="hidden"),n.appendChild(t),t}},function(t,e){t.exports=function(t,e){return Math.floor(Math.random()*(e-t+1)+t)}},function(t,e){t.exports=function(t,e,i,n,s){var r=.5*(n-e),o=.5*(s-i),a=t*t;return(2*i-2*n+r+o)*(t*a)+(-3*i+3*n-2*r-o)*a+r*t+i}},function(t,e,i){var n=i(18);t.exports=function(t){return t*n.RAD_TO_DEG}},function(t,e,i){var n=i(10);t.exports=function(t,e){if(void 0===e&&(e=new n),0===t.length)return e;for(var i,s,r,o=Number.MAX_VALUE,a=Number.MAX_VALUE,h=Number.MIN_SAFE_INTEGER,l=Number.MIN_SAFE_INTEGER,u=0;u=(t=t.toString()).length)switch(n){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((s=e-t.length)/2);t=new Array(s-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}},function(t,e){t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)}},function(t,e){t.exports=function(t,e,i,n,s){var r=n+Math.atan2(t.y-i,t.x-e);return t.x=e+s*Math.cos(r),t.y=i+s*Math.sin(r),t}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=t.x2-t.x1,s=t.y2-t.y1,r=t.x3-t.x1,o=t.y3-t.y1,a=Math.random(),h=Math.random();return a+h>=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(s*a+o*h),e}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return e.x=t.x+s*Math.cos(i)*t.width/2,e.y=t.y+s*Math.sin(i)*t.height/2,e}},function(t,e,i){var n=i(59);t.exports=function(t){return n(t,-180,180)}},function(t,e,i){var n=i(59);t.exports=function(t){return n(t,-Math.PI,Math.PI)}},function(t,e,i){var n=i(6);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},function(t,e,i){var n=i(71),s=i(6);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=n(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,l=t.y2,u=0;u=1)return i.x=t.x,i.y=t.y,i;var r=n(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),r=s>1?2-s:s,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},function(t,e,i){var n=i(6);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},function(t,e){t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){var n=i(0),s=i(11),r=i(105),o=i(93),a=new n({Extends:s,initialize:function(t){s.call(this),this.manager=t,this.isTimeline=!0,this.data=[],this.totalData=0,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},add:function(t){return this.queue(r(this,t))},queue:function(t){return this.isPlaying()||(t.parent=this,t.parentIsTimeline=!0,this.data.push(t),this.totalData=this.data.length),this},hasOffset:function(t){return null!==t.offset},isOffsetAbsolute:function(t){return"number"==typeof t},isOffsetRelative:function(t){if("string"===typeof t){var e=t[0];if("-"===e||"+"===e)return!0}return!1},getRelativeOffset:function(t,e){var i=t[0],n=parseFloat(t.substr(2)),s=e;switch(i){case"+":s+=n;break;case"-":s-=n}return Math.max(0,s)},calcDuration:function(){for(var t=0,e=0,i=0,n=0;n0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=o.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=o.PENDING_REMOVE}},update:function(t,e){if(this.state!==o.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var n=this.totalData,s=0;s0?Math.floor(v/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=a(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=o(e,"yoyo",g.yoyo),g.flipX=o(e,"flipX",g.flipX),g.flipY=o(e,"flipY",g.flipY);for(var y=0;y0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var n=i(0),s=i(16),r=i(28),o=i(17),a=i(473),h=i(111),l=i(42),u=i(9),c=new n({Extends:o,Mixins:[s.Alpha,s.BlendMode,s.ComputedSize,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.Transform,s.Visible,s.ScrollFactor,a],initialize:function(t,e,i,n,s,a){o.call(this,t,"StaticTilemapLayer"),this.isTilemap=!0,this.tilemap=e,this.layerIndex=i,this.layer=e.layers[i],this.layer.tilemapLayer=this,this.tileset=[],this.culledTiles=[],this.skipCull=!1,this.tilesDrawn=0,this.tilesTotal=this.layer.width*this.layer.height,this.cullPaddingX=1,this.cullPaddingY=1,this.cullCallback=h.CullTiles,this.renderer=t.sys.game.renderer,this.vertexBuffer=[],this.bufferData=[],this.vertexViewF32=[],this.vertexViewU32=[],this.dirty=[],this.vertexCount=[],this._renderOrder=0,this._tempMatrix=new l,this.gidMap=[],this.setTilesets(n),this.setAlpha(this.layer.alpha),this.setPosition(s,a),this.setOrigin(),this.setSize(this.layer.tileWidth*this.layer.width,this.layer.tileHeight*this.layer.height),this.updateVBOData(),this.initPipeline("TextureTintPipeline"),t.sys.game.config.renderType===r.WEBGL&&t.sys.game.renderer.onContextRestored(function(){this.updateVBOData()},this)},setTilesets:function(t){var e=[],i=[],n=this.tilemap;Array.isArray(t)||(t=[t]);for(var s=0;sv||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));else if(1===p)for(o=0;o=0;a--)!(r=f[o][a])||r.indexv||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));else if(2===p)for(o=u-1;o>=0;o--)for(a=0;av||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));else if(3===p)for(o=u-1;o>=0;o--)for(a=l-1;a>=0;a--)!(r=f[o][a])||r.indexv||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));this.dirty[e]=!1,null===y?(y=i.createVertexBuffer(m,n.STATIC_DRAW),this.vertexBuffer[e]=y):(i.setVertexBuffer(y),n.bufferSubData(n.ARRAY_BUFFER,0,m))}return this},batchTile:function(t,e,i,n,s,r,o){var a=i.getTileTextureCoordinates(e.index);if(!a)return t;var h=a.x/n,l=a.y/s,c=(a.x+e.width)/n,d=(a.y+e.height)/s,f=this._tempMatrix,p=e.width,g=e.height,v=p/2,y=g/2,m=-v,x=-y;e.flipX&&(p*=-1,m+=e.width),e.flipY&&(g*=-1,x+=e.height);var w=m+p,b=x+g;f.applyITRS(v+e.pixelX,y+e.pixelY,e.rotation,1,1);var T=u.getTintAppendFloatAlpha(16777215,r.alpha*this.alpha*e.alpha),S=f.getX(m,x),A=f.getY(m,x),_=f.getX(m,b),C=f.getY(m,b),M=f.getX(w,b),P=f.getY(w,b),E=f.getX(w,x),k=f.getY(w,x);r.roundPixels&&(S|=0,A|=0,_|=0,C|=0,M|=0,P|=0,E|=0,k|=0);var F=this.vertexViewF32[o],L=this.vertexViewU32[o];return F[++t]=S,F[++t]=A,F[++t]=h,F[++t]=l,F[++t]=0,L[++t]=T,F[++t]=_,F[++t]=C,F[++t]=h,F[++t]=d,F[++t]=0,L[++t]=T,F[++t]=M,F[++t]=P,F[++t]=c,F[++t]=d,F[++t]=0,L[++t]=T,F[++t]=S,F[++t]=A,F[++t]=h,F[++t]=l,F[++t]=0,L[++t]=T,F[++t]=M,F[++t]=P,F[++t]=c,F[++t]=d,F[++t]=0,L[++t]=T,F[++t]=E,F[++t]=k,F[++t]=c,F[++t]=l,F[++t]=0,L[++t]=T,this.vertexCount[o]+=6,t},setRenderOrder:function(t){if("string"==typeof t&&(t=["right-down","left-down","right-up","left-up"].indexOf(t)),t>=0&&t<4){this._renderOrder=t;for(var e=0;e=0&&t<4&&(this._renderOrder=t),this},calculateFacesAt:function(t,e){return a.CalculateFacesAt(t,e,this.layer),this},calculateFacesWithin:function(t,e,i,n){return a.CalculateFacesWithin(t,e,i,n,this.layer),this},createFromTiles:function(t,e,i,n,s){return a.CreateFromTiles(t,e,i,n,s,this.layer)},cull:function(t){return this.cullCallback(this.layer,t,this.culledTiles,this._renderOrder)},copy:function(t,e,i,n,s,r,o){return a.Copy(t,e,i,n,s,r,o,this.layer),this},destroy:function(){this.layer.tilemapLayer===this&&(this.layer.tilemapLayer=void 0),this.tilemap=void 0,this.layer=void 0,this.culledTiles.length=0,this.cullCallback=null,this.gidMap=[],this.tileset=[],o.prototype.destroy.call(this)},fill:function(t,e,i,n,s,r){return a.Fill(t,e,i,n,s,r,this.layer),this},filterTiles:function(t,e,i,n,s,r,o){return a.FilterTiles(t,e,i,n,s,r,o,this.layer)},findByIndex:function(t,e,i){return a.FindByIndex(t,e,i,this.layer)},findTile:function(t,e,i,n,s,r,o){return a.FindTile(t,e,i,n,s,r,o,this.layer)},forEachTile:function(t,e,i,n,s,r,o){return a.ForEachTile(t,e,i,n,s,r,o,this.layer),this},getTileAt:function(t,e,i){return a.GetTileAt(t,e,i,this.layer)},getTileAtWorldXY:function(t,e,i,n){return a.GetTileAtWorldXY(t,e,i,n,this.layer)},getTilesWithin:function(t,e,i,n,s){return a.GetTilesWithin(t,e,i,n,s,this.layer)},getTilesWithinShape:function(t,e,i){return a.GetTilesWithinShape(t,e,i,this.layer)},getTilesWithinWorldXY:function(t,e,i,n,s,r){return a.GetTilesWithinWorldXY(t,e,i,n,s,r,this.layer)},hasTileAt:function(t,e){return a.HasTileAt(t,e,this.layer)},hasTileAtWorldXY:function(t,e,i){return a.HasTileAtWorldXY(t,e,i,this.layer)},putTileAt:function(t,e,i,n){return a.PutTileAt(t,e,i,n,this.layer)},putTileAtWorldXY:function(t,e,i,n,s){return a.PutTileAtWorldXY(t,e,i,n,s,this.layer)},putTilesAt:function(t,e,i,n){return a.PutTilesAt(t,e,i,n,this.layer),this},randomize:function(t,e,i,n,s){return a.Randomize(t,e,i,n,s,this.layer),this},removeTileAt:function(t,e,i,n){return a.RemoveTileAt(t,e,i,n,this.layer)},removeTileAtWorldXY:function(t,e,i,n,s){return a.RemoveTileAtWorldXY(t,e,i,n,s,this.layer)},renderDebug:function(t,e){return a.RenderDebug(t,e,this.layer),this},replaceByIndex:function(t,e,i,n,s,r){return a.ReplaceByIndex(t,e,i,n,s,r,this.layer),this},setSkipCull:function(t){return void 0===t&&(t=!0),this.skipCull=t,this},setCullPadding:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=1),this.cullPaddingX=t,this.cullPaddingY=e,this},setCollision:function(t,e,i){return a.SetCollision(t,e,i,this.layer),this},setCollisionBetween:function(t,e,i,n){return a.SetCollisionBetween(t,e,i,n,this.layer),this},setCollisionByProperty:function(t,e,i){return a.SetCollisionByProperty(t,e,i,this.layer),this},setCollisionByExclusion:function(t,e,i){return a.SetCollisionByExclusion(t,e,i,this.layer),this},setCollisionFromCollisionGroup:function(t,e){return a.SetCollisionFromCollisionGroup(t,e,this.layer),this},setTileIndexCallback:function(t,e,i){return a.SetTileIndexCallback(t,e,i,this.layer),this},setTileLocationCallback:function(t,e,i,n,s,r){return a.SetTileLocationCallback(t,e,i,n,s,r,this.layer),this},shuffle:function(t,e,i,n){return a.Shuffle(t,e,i,n,this.layer),this},swapByIndex:function(t,e,i,n,s,r){return a.SwapByIndex(t,e,i,n,s,r,this.layer),this},tileToWorldX:function(t,e){return a.TileToWorldX(t,e,this.layer)},tileToWorldY:function(t,e){return a.TileToWorldY(t,e,this.layer)},tileToWorldXY:function(t,e,i,n){return a.TileToWorldXY(t,e,i,n,this.layer)},weightedRandomize:function(t,e,i,n,s){return a.WeightedRandomize(t,e,i,n,s,this.layer),this},worldToTileX:function(t,e,i){return a.WorldToTileX(t,e,i,this.layer)},worldToTileY:function(t,e,i){return a.WorldToTileY(t,e,i,this.layer)},worldToTileXY:function(t,e,i,n,s){return a.WorldToTileXY(t,e,i,n,s,this.layer)}});t.exports=h},function(t,e,i){var n=i(0),s=i(36),r=i(221),o=i(21),a=i(30),h=i(87),l=i(270),u=i(220),c=i(61),d=i(111),f=i(107),p=new n({initialize:function(t,e){this.scene=t,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.width=e.width,this.height=e.height,this.orientation=e.orientation,this.renderOrder=e.renderOrder,this.format=e.format,this.version=e.version,this.properties=e.properties,this.widthInPixels=e.widthInPixels,this.heightInPixels=e.heightInPixels,this.imageCollections=e.imageCollections,this.images=e.images,this.layers=e.layers,this.tilesets=e.tilesets,this.objects=e.objects,this.currentLayerIndex=0},setRenderOrder:function(t){var e=["right-down","left-down","right-up","left-up"];return"number"==typeof t&&(t=e[t]),e.indexOf(t)>-1&&(this.renderOrder=t),this},addTilesetImage:function(t,e,i,n,s,r,o){if(void 0===t)return null;if(void 0!==e&&null!==e||(e=t),!this.scene.sys.textures.exists(e))return console.warn("Invalid Tileset Image: "+e),null;var h=this.scene.sys.textures.get(e),l=this.getTilesetIndex(t);if(null===l&&this.format===a.TILED_JSON)return console.warn("No data found for Tileset: "+t),null;var u=this.tilesets[l];return u?(u.setTileSize(i,n),u.setSpacing(s,r),u.setImage(h),u):(void 0===i&&(i=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===s&&(s=0),void 0===r&&(r=0),void 0===o&&(o=0),(u=new f(t,o,i,n,s,r)).setImage(h),this.tilesets.push(u),u)},convertLayerToStatic:function(t){if(null===(t=this.getLayer(t)))return null;var e=t.tilemapLayer;if(!(e&&e instanceof r))return null;var i=new u(e.scene,e.tilemap,e.layerIndex,e.tileset,e.x,e.y);return this.scene.sys.displayList.add(i),e.destroy(),i},copy:function(t,e,i,n,s,r,o,a){return a=this.getLayer(a),this._isStaticCall(a,"copy")?this:(null!==a&&d.Copy(t,e,i,n,s,r,o,a),this)},createBlankDynamicLayer:function(t,e,i,n,s,o,a,l){if(void 0===a&&(a=e.tileWidth),void 0===l&&(l=e.tileHeight),void 0===s&&(s=this.width),void 0===o&&(o=this.height),void 0===i&&(i=0),void 0===n&&(n=0),null!==this.getLayerIndex(t))return console.warn("Invalid Tilemap Layer ID: "+t),null;for(var u,d=new h({name:t,tileWidth:a,tileHeight:l,width:s,height:o}),f=0;fa&&(a=e.layer[l].width),e.layer[l].height>h&&(h=e.layer[l].height);var u=new s({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:n.WELTMEISTER});return u.layers=r(e,i),u.tilesets=o(e),u}},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","object layer"),this.opacity=s(t,"opacity",1),this.properties=s(t,"properties",{}),this.propertyTypes=s(t,"propertytypes",{}),this.type=s(t,"type","objectgroup"),this.visible=s(t,"visible",!0),this.objects=s(t,"objects",[])}});t.exports=r},function(t,e,i){var n=i(482),s=i(227),r=function(t){return{x:t.x,y:t.y}},o=["id","name","type","rotation","properties","visible","x","y","width","height"];t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var a=n(t,o);if(a.x+=e,a.y+=i,t.gid){var h=s(t.gid);a.gid=h.gid,a.flippedHorizontal=h.flippedHorizontal,a.flippedVertical=h.flippedVertical,a.flippedAntiDiagonal=h.flippedAntiDiagonal}else t.polyline?a.polyline=t.polyline.map(r):t.polygon?a.polygon=t.polygon.map(r):t.ellipse?(a.ellipse=t.ellipse,a.width=t.width,a.height=t.height):t.text?(a.width=t.width,a.height=t.height,a.text=t.text):(a.rectangle=!0,a.width=t.width,a.height=t.height);return a}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|n,this.imageMargin=0|s,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&t-1}return!1}},function(t,e,i){var n=i(19);t.exports=function(t,e,i,s,r,o,a){for(var h=n(i,s,r,o,null,a),l=0;l0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionstart",e,i,n)}),d.on(e,"collisionActive",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionactive",e,i,n)}),d.on(e,"collisionEnd",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionend",e,i,n)})},setBounds:function(t,e,i,n,s,r,o,a,h){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),void 0===s&&(s=128),void 0===r&&(r=!0),void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),this.updateWall(r,"left",t-s,e,s,n),this.updateWall(o,"right",t+i,e,s,n),this.updateWall(a,"top",t,e-s,i,s),this.updateWall(h,"bottom",t,e+n,i,s),this},updateWall:function(t,e,i,n,s,r){var o=this.walls[e];t?(o&&p.remove(this.localWorld,o),i+=s/2,n+=r/2,this.walls[e]=this.create(i,n,s,r,{isStatic:!0,friction:0,frictionStatic:0})):(o&&p.remove(this.localWorld,o),this.walls[e]=null)},createDebugGraphic:function(){var t=this.scene.sys.add.graphics({x:0,y:0});return t.setDepth(Number.MAX_VALUE),this.debugGraphic=t,this.drawDebug=!0,t},disableGravity:function(){return this.localWorld.gravity.x=0,this.localWorld.gravity.y=0,this.localWorld.gravity.scale=0,this},setGravity:function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=1),this.localWorld.gravity.x=t,this.localWorld.gravity.y=e,void 0!==i&&(this.localWorld.gravity.scale=i),this},create:function(t,e,i,s,r){var o=n.rectangle(t,e,i,s,r);return p.add(this.localWorld,o),o},add:function(t){return p.add(this.localWorld,t),this},remove:function(t,e){var i=t.body?t.body:t;return o.removeBody(this.localWorld,i,e),this},removeConstraint:function(t,e){return o.remove(this.localWorld,t,e),this},convertTilemapLayer:function(t,e){var i=t.layer,n=t.getTilesWithin(0,0,i.width,i.height,{isColliding:!0});return this.convertTiles(n,e),this},convertTiles:function(t,e){if(0===t.length)return this;for(var i=0;i1?1:0;r1?1:0;s0&&u.trigger(t,"collisionStart",{pairs:w.collisionStart}),o.preSolvePosition(w.list),s=0;s0&&u.trigger(t,"collisionActive",{pairs:w.collisionActive}),w.collisionEnd.length>0&&u.trigger(t,"collisionEnd",{pairs:w.collisionEnd}),h.update(t.metrics,t),n._bodiesClearForces(y),u.trigger(t,"afterUpdate",v),t},n.merge=function(t,e){if(f.extend(t,e),e.world){t.world=e.world,n.clear(t);for(var i=c.allBodies(t.world),s=0;sf.friction*f.frictionStatic*O*i&&(I=F,D=o.clamp(f.friction*L*i,-I,I));var B=r.cross(A,y),Y=r.cross(_,y),X=w/(g.inverseMass+v.inverseMass+g.inverseInertia*B*B+v.inverseInertia*Y*Y);if(R*=X,D*=X,E<0&&E*E>n._restingThresh*i)T.normalImpulse=0;else{var z=T.normalImpulse;T.normalImpulse=Math.min(T.normalImpulse+R,0),R=T.normalImpulse-z}if(k*k>n._restingThreshTangent*i)T.tangentImpulse=0;else{var N=T.tangentImpulse;T.tangentImpulse=o.clamp(T.tangentImpulse+D,-I,I),D=T.tangentImpulse-N}s.x=y.x*R+m.x*D,s.y=y.y*R+m.y*D,g.isStatic||g.isSleeping||(g.positionPrev.x+=s.x*g.inverseMass,g.positionPrev.y+=s.y*g.inverseMass,g.anglePrev+=r.cross(A,s)*g.inverseInertia),v.isStatic||v.isSleeping||(v.positionPrev.x-=s.x*v.inverseMass,v.positionPrev.y-=s.y*v.inverseMass,v.anglePrev-=r.cross(_,s)*v.inverseInertia)}}}}},function(t,e,i){var n={};t.exports=n;var s=i(112),r=i(12);n._pairMaxIdleLife=1e3,n.create=function(t){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},t)},n.update=function(t,e,i){var n,r,o,a,h=t.list,l=t.table,u=t.collisionStart,c=t.collisionEnd,d=t.collisionActive;for(u.length=0,c.length=0,d.length=0,a=0;an._pairMaxIdleLife&&l.push(o);for(o=0;ou.bounds.max.x||p.bounds.max.yu.bounds.max.y)){var g=n._getRegion(t,p);if(!p.region||g.id!==p.region.id||s){f.broadphaseTests+=1,p.region&&!s||(p.region=g);var v=n._regionUnion(g,p.region);for(o=v.startCol;o<=v.endCol;o++)for(a=v.startRow;a<=v.endRow;a++){h=c[l=n._getBucketId(o,a)];var y=o>=g.startCol&&o<=g.endCol&&a>=g.startRow&&a<=g.endRow,m=o>=p.region.startCol&&o<=p.region.endCol&&a>=p.region.startRow&&a<=p.region.endRow;!y&&m&&m&&h&&n._bucketRemoveBody(t,h,p),(p.region===g||y&&!m||s)&&(h||(h=n._createBucket(c,l)),n._bucketAddBody(t,h,p))}p.region=g,d=!0}}}d&&(t.pairsList=n._createActivePairsList(t))},n.clear=function(t){t.buckets={},t.pairs={},t.pairsList=[]},n._regionUnion=function(t,e){var i=Math.min(t.startCol,e.startCol),s=Math.max(t.endCol,e.endCol),r=Math.min(t.startRow,e.startRow),o=Math.max(t.endRow,e.endRow);return n._createRegion(i,s,r,o)},n._getRegion=function(t,e){var i=e.bounds,s=Math.floor(i.min.x/t.bucketWidth),r=Math.floor(i.max.x/t.bucketWidth),o=Math.floor(i.min.y/t.bucketHeight),a=Math.floor(i.max.y/t.bucketHeight);return n._createRegion(s,r,o,a)},n._createRegion=function(t,e,i,n){return{id:t+","+e+","+i+","+n,startCol:t,endCol:e,startRow:i,endRow:n}},n._getBucketId=function(t,e){return"C"+t+"R"+e},n._createBucket=function(t,e){return t[e]=[]},n._bucketAddBody=function(t,e,i){for(var n=0;n0?n.push(i):delete t.pairs[e[s]];return n}},function(t,e,i){var n={};t.exports=n;var s=i(147),r=i(12);n.name="matter-js",n.version="0.14.2",n.uses=[],n.used=[],n.use=function(){s.use(n,Array.prototype.slice.call(arguments))},n.before=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathBefore(n,t,e)},n.after=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathAfter(n,t,e)}},function(t,e,i){var n=i(437),s=i(0),r=i(113),o=i(17),a=i(1),h=i(133),l=i(57),u=i(3),c=new s({Extends:l,Mixins:[r.Bounce,r.Collision,r.Force,r.Friction,r.Gravity,r.Mass,r.Sensor,r.SetBody,r.Sleep,r.Static,r.Transform,r.Velocity,h],initialize:function(t,e,i,s,r,h){o.call(this,t.scene,"Image"),this.anims=new n(this),this.setTexture(s,r),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new u(e,i);var l=a(h,"shape",null);l?this.setBody(l,h):this.setRectangle(this.width,this.height,h),this.setPosition(e,i),this.initPipeline("TextureTintPipeline")}});t.exports=c},function(t,e,i){var n=i(0),s=i(113),r=i(17),o=i(1),a=i(78),h=i(133),l=i(3),u=new n({Extends:a,Mixins:[s.Bounce,s.Collision,s.Force,s.Friction,s.Gravity,s.Mass,s.Sensor,s.SetBody,s.Sleep,s.Static,s.Transform,s.Velocity,h],initialize:function(t,e,i,n,s,a){r.call(this,t.scene,"Image"),this.setTexture(n,s),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new l(e,i);var h=o(a,"shape",null);h?this.setBody(h,a):this.setRectangle(this.width,this.height,a),this.setPosition(e,i),this.initPipeline("TextureTintPipeline")}});t.exports=u},function(t,e,i){var n={};t.exports=n;var s=i(63),r=i(73),o=i(12),a=i(25),h=i(55);n.stack=function(t,e,i,n,r,o,h){for(var l,u=s.create({label:"Stack"}),c=t,d=e,f=0,p=0;pg&&(g=m),a.translate(y,{x:.5*x,y:.5*m}),c=y.bounds.max.x+r,s.addBody(u,y),l=y,f+=1}else c+=r}d+=g+o,c=t}return u},n.chain=function(t,e,i,n,a,h){for(var l=t.bodies,u=1;u0)for(l=0;l0&&(d=f[l-1+(h-1)*e],s.addConstraint(t,r.create(o.extend({bodyA:d,bodyB:c},a)))),n&&ld||o<(l=d-l)||o>i-1-l))return 1===c&&a.translate(u,{x:(o+(i%2==1?1:-1))*f,y:0}),h(t+(u?o*f:0)+o*r,n,o,l,u,c)})},n.newtonsCradle=function(t,e,i,n,o){for(var a=s.create({label:"Newtons Cradle"}),l=0;l=0&&h<=1&&l>=0&&l<=1}function s(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])}function r(t,e,i){return s(t,e,i)>0}function o(t,e,i){return s(t,e,i)>=0}function a(t,e,i){return s(t,e,i)<0}function h(t,e,i){return s(t,e,i)<=0}t.exports={decomp:function(t){var e=function t(e){var i=[],n=[],s=[],r=[];var o=Number.MAX_VALUE;for(var a=0;a0?function t(e,i){if(0===i.length)return[e];if(i instanceof Array&&i.length&&i[0]instanceof Array&&2===i[0].length&&i[0][0]instanceof Array){for(var n=[e],s=0;su)return console.warn("quickDecomp: max level ("+u+") reached."),i;for(var L=0;L_&&(_+=e.length),A=Number.MAX_VALUE,_3&&n>=0;--n)c(f(t,n-1),f(t,n),f(t,n+1),e)&&(t.splice(n%t.length,1),i++);return i},removeDuplicatePoints:function(t,e){for(var i=t.length-1;i>=1;--i)for(var n=t[i],s=i-1;s>=0;--s)S(n,t[s],e)&&t.splice(i,1)},makeCCW:function(t){for(var e=0,i=t,n=1;ni[e][0])&&(e=n);return!r(f(t,e-1),f(t,e),f(t,e+1))&&(function(t){for(var e=[],i=t.length,n=0;n!==i;n++)e.push(t.pop());for(var n=0;n!==i;n++)t[n]=e[n]}(t),!0)}};var l=[],u=[];function c(t,e,i,n){if(n){var r=l,o=u;r[0]=e[0]-t[0],r[1]=e[1]-t[1],o[0]=i[0]-e[0],o[1]=i[1]-e[1];var a=r[0]*o[0]+r[1]*o[1],h=Math.sqrt(r[0]*r[0]+r[1]*r[1]),c=Math.sqrt(o[0]*o[0]+o[1]*o[1]);return Math.acos(a/(h*c))r.ACTIVE&&c(this,t,e))},setCollidesNever:function(t){for(var e=0;e1)for(var h=i/a,l=n/a,u=0;u0?r:0,y=n<0?f:0,m=Math.max(Math.floor(i/f),0),x=Math.min(Math.ceil((i+o)/f),g);u=Math.floor((t.pos.x+v)/f);var w=Math.floor((e+v)/f);if((l>0||u===w||w<0||w>=p)&&(w=-1),u>=0&&u1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,w,c));c++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.x=!0,t.tile.x=d,t.pos.x=u*f-v+y,e=t.pos.x,a=0;break}}if(s){var b=s>0?o:0,T=s<0?f:0,S=Math.max(Math.floor(t.pos.x/f),0),A=Math.min(Math.ceil((t.pos.x+r)/f),p);c=Math.floor((t.pos.y+b)/f);var _=Math.floor((i+b)/f);if((l>0||c===_||_<0||_>=g)&&(_=-1),c>=0&&c1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,u,_));u++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.y=!0,t.tile.y=d,t.pos.y=c*f-b+T;break}}},checkDef:function(t,e,i,n,s,r,o,a,h,l){var u=this.tiledef[e];if(!u)return!1;var c=this.tilesize,d=(h+u[0])*c,f=(l+u[1])*c,p=(u[2]-u[0])*c,g=(u[3]-u[1])*c,v=u[4],y=i+s+(g<0?o:0)-d,m=n+r+(p>0?a:0)-f;if(p*m-g*y>0){if(s*-g+r*p<0)return v;var x=Math.sqrt(p*p+g*g),w=g/x,b=-p/x,T=y*w+m*b,S=w*T,A=b*T;return S*S+A*A>=s*s+r*r?v||p*(m-r)-g*(y-s)<.5:(t.pos.x=i+s-S,t.pos.y=n+r-A,t.collision.slope={x:p,y:g,nx:w,ny:b},!0)}return!1}});t.exports=r},function(t,e,i){var n=i(0),s=i(91),r=i(571),o=i(90),a=i(570),h=new n({initialize:function(t,e,i,n,r){void 0===n&&(n=16),void 0===r&&(r=n),this.world=t,this.gameObject=null,this.enabled=!0,this.parent,this.id=t.getNextID(),this.name="",this.size={x:n,y:r},this.offset={x:0,y:0},this.pos={x:e,y:i},this.last={x:e,y:i},this.vel={x:0,y:0},this.accel={x:0,y:0},this.friction={x:0,y:0},this.maxVel={x:t.defaults.maxVelocityX,y:t.defaults.maxVelocityY},this.standing=!1,this.gravityFactor=t.defaults.gravityFactor,this.bounciness=t.defaults.bounciness,this.minBounceVelocity=t.defaults.minBounceVelocity,this.accelGround=0,this.accelAir=0,this.jumpSpeed=0,this.type=o.NONE,this.checkAgainst=o.NONE,this.collides=s.NEVER,this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.updateCallback,this.slopeStanding={min:.767944870877505,max:2.3736477827122884}},reset:function(t,e){this.pos={x:t,y:e},this.last={x:t,y:e},this.vel={x:0,y:0},this.accel={x:0,y:0},this.friction={x:0,y:0},this.maxVel={x:100,y:100},this.standing=!1,this.gravityFactor=1,this.bounciness=0,this.minBounceVelocity=40,this.accelGround=0,this.accelAir=0,this.jumpSpeed=0,this.type=o.NONE,this.checkAgainst=o.NONE,this.collides=s.NEVER},update:function(t){var e=this.pos;this.last.x=e.x,this.last.y=e.y,this.vel.y+=this.world.gravity*t*this.gravityFactor,this.vel.x=r(t,this.vel.x,this.accel.x,this.friction.x,this.maxVel.x),this.vel.y=r(t,this.vel.y,this.accel.y,this.friction.y,this.maxVel.y);var i=this.vel.x*t,n=this.vel.y*t,s=this.world.collisionMap.trace(e.x,e.y,i,n,this.size.x,this.size.y);this.handleMovementTrace(s)&&a(this,s);var o=this.gameObject;o&&(o.x=e.x-this.offset.x+o.displayOriginX*o.scaleX,o.y=e.y-this.offset.y+o.displayOriginY*o.scaleY),this.updateCallback&&this.updateCallback(this)},drawDebug:function(t){var e=this.pos;if(this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.size.x,this.size.y)),this.debugShowVelocity){var i=e.x+this.size.x/2,n=e.y+this.size.y/2;t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.vel.x,n+this.vel.y)}},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},skipHash:function(){return!this.enabled||0===this.type&&0===this.checkAgainst&&0===this.collides},touches:function(t){return!(this.pos.x>=t.pos.x+t.size.x||this.pos.x+this.size.x<=t.pos.x||this.pos.y>=t.pos.y+t.size.y||this.pos.y+this.size.y<=t.pos.y)},resetSize:function(t,e,i,n){return this.pos.x=t,this.pos.y=e,this.size.x=i,this.size.y=n,this},toJSON:function(){return{name:this.name,size:{x:this.size.x,y:this.size.y},pos:{x:this.pos.x,y:this.pos.y},vel:{x:this.vel.x,y:this.vel.y},accel:{x:this.accel.x,y:this.accel.y},friction:{x:this.friction.x,y:this.friction.y},maxVel:{x:this.maxVel.x,y:this.maxVel.y},gravityFactor:this.gravityFactor,bounciness:this.bounciness,minBounceVelocity:this.minBounceVelocity,type:this.type,checkAgainst:this.checkAgainst,collides:this.collides}},fromJSON:function(){},check:function(){},collideWith:function(t,e){this.parent&&this.parent._collideCallback&&this.parent._collideCallback.call(this.parent._callbackScope,this,t,e)},handleMovementTrace:function(){return!0},destroy:function(){this.world.remove(this),this.enabled=!1,this.world=null,this.gameObject=null,this.parent=null}});t.exports=h},function(t,e,i){var n=i(44),s=i(0),r=i(39),o=i(43),a=i(3),h=new s({initialize:function(t,e){var i=e.width?e.width:64,n=e.height?e.height:64;this.world=t,this.gameObject=e,this.debugShowBody=t.defaults.debugShowStaticBody,this.debugBodyColor=t.defaults.staticBodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new a,this.position=new a(e.x-e.displayOriginX,e.y-e.displayOriginY),this.width=i,this.height=n,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center=new a(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=a.ZERO,this.allowGravity=!1,this.gravity=a.ZERO,this.bounce=a.ZERO,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.mass=1,this.immovable=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.physicsType=r.STATIC_BODY,this._dx=0,this._dy=0},setGameObject:function(t,e){return t&&t!==this.gameObject&&(this.gameObject.body=null,t.body=this,this.gameObject=t),e&&this.updateFromGameObject(),this},updateFromGameObject:function(){this.world.staticTree.remove(this);var t=this.gameObject;return t.getTopLeft(this.position),this.width=t.displayWidth,this.height=t.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.world.staticTree.insert(this),this},setOffset:function(t,e){return void 0===e&&(e=t),this.world.staticTree.remove(this),this.position.x-=this.offset.x,this.position.y-=this.offset.y,this.offset.set(t,e),this.position.x+=this.offset.x,this.position.y+=this.offset.y,this.updateCenter(),this.world.staticTree.insert(this),this},setSize:function(t,e,i,n){void 0===i&&(i=this.offset.x),void 0===n&&(n=this.offset.y);var s=this.gameObject;return!t&&s.frame&&(t=s.frame.realWidth),!e&&s.frame&&(e=s.frame.realHeight),this.world.staticTree.remove(this),this.width=t,this.height=e,this.halfWidth=Math.floor(t/2),this.halfHeight=Math.floor(e/2),this.offset.set(i,n),this.updateCenter(),this.isCircle=!1,this.radius=0,this.world.staticTree.insert(this),this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):o(this,t,e)},postUpdate:function(){},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},function(t,e){t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},function(t,e,i){var n=i(341);function s(t){if(!(this instanceof s))return new s(t,[".left",".top",".right",".bottom"]);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}function r(t,e,i){if(!i)return e.indexOf(t);for(var n=0;n=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(t,e,i,s,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=s||(o=e+Math.ceil((i-e)/s/2)*s,n(t,o,e,i,r),a.push(e,o,o,i))}s.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!p(t,e))return i;for(var s,r,o,a,h=[];e;){for(s=0,r=e.children.length;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)},_split:function(t,e){var i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);var r=this._chooseSplitIndex(i,s,n),a=g(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,s,r,o,h,l,u,d,f,p,g,v,y,m;for(l=u=1/0,n=e;n<=i-e;n++)s=a(t,0,n,this.toBBox),r=a(t,n,i,this.toBBox),f=s,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),v=Math.max(f.minY,p.minY),y=Math.min(f.maxX,p.maxX),m=Math.min(f.maxY,p.maxY),o=Math.max(0,y-g)*Math.max(0,m-v),h=c(s)+c(r),o=e;s--)r=t.children[s],h(u,t.leaf?o(r):r),c+=d(u);return c},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)h(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},compareMinX:function(t,e){return t.left-e.left},compareMinY:function(t,e){return t.top-e.top},toBBox:function(t){return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}},t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,n=this._active;for(t=0;te._dy?(r=t.bottom-e.y)>o&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?r=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.down=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.up=!0)):t._dyo&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?r=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.up=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.down=!0))),t.overlapY=r,e.overlapY=r,r}},function(t,e,i){var n=i(39);t.exports=function(t,e,i,s){var r=0,o=t.deltaAbsX()+e.deltaAbsX()+s;return 0===t._dx&&0===e._dx?(t.embedded=!0,e.embedded=!0):t._dx>e._dx?(r=t.right-e.x)>o&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?r=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.right=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.left=!0)):t._dxo&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?r=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.left=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.right=!0))),t.overlapX=r,e.overlapX=r,r}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=n,this.collideCallback=s,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=n},function(t,e,i){var n=i(44),s=i(0),r=i(39),o=i(190),a=i(10),h=i(43),l=i(3),u=new s({initialize:function(t,e){var i=e.width?e.width:64,n=e.height?e.height:64;this.world=t,this.gameObject=e,this.transform={x:e.x,y:e.y,rotation:e.angle,scaleX:e.scaleX,scaleY:e.scaleY,displayOriginX:e.displayOriginX,displayOriginY:e.displayOriginY},this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new l,this.position=new l(e.x,e.y),this.prev=new l(e.x,e.y),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=i,this.height=n,this.sourceWidth=i,this.sourceHeight=n,e.frame&&(this.sourceWidth=e.frame.realWidth,this.sourceHeight=e.frame.realHeight),this.halfWidth=Math.abs(i/2),this.halfHeight=Math.abs(n/2),this.center=new l(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=new l,this.newVelocity=new l,this.deltaMax=new l,this.acceleration=new l,this.allowDrag=!0,this.drag=new l,this.allowGravity=!0,this.gravity=new l,this.bounce=new l,this.worldBounce=null,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.maxVelocity=new l(1e4,1e4),this.friction=new l(1,0),this.useDamping=!1,this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=r.FACING_NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.physicsType=r.DYNAMIC_BODY,this._reset=!0,this._sx=e.scaleX,this._sy=e.scaleY,this._dx=0,this._dy=0,this._bounds=new a},updateBounds:function(){var t=this.gameObject,e=this.transform;if(t.parentContainer){var i=t.getWorldTransformMatrix(this.world._tempMatrix,this.world._tempMatrix2);e.x=i.tx,e.y=i.ty,e.rotation=o(i.rotation),e.scaleX=i.scaleX,e.scaleY=i.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY}else e.x=t.x,e.y=t.y,e.rotation=t.angle,e.scaleX=t.scaleX,e.scaleY=t.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY;var n=!1;if(this.syncBounds){var s=t.getBounds(this._bounds);this.width=s.width,this.height=s.height,n=!0}else{var r=Math.abs(e.scaleX),a=Math.abs(e.scaleY);this._sx===r&&this._sy===a||(this.width=this.sourceWidth*r,this.height=this.sourceHeight*a,this._sx=r,this._sy=a,n=!0)}n&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},update:function(t){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds();var e=this.transform;if(this.position.x=e.x+e.scaleX*(this.offset.x-e.displayOriginX),this.position.y=e.y+e.scaleY*(this.offset.y-e.displayOriginY),this.updateCenter(),this.rotation=e.rotation,this.preRotation=this.rotation,this._reset&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves){this.world.updateMotion(this,t);var i=this.velocity.x,n=this.velocity.y;this.newVelocity.set(i*t,n*t),this.position.add(this.newVelocity),this.updateCenter(),this.angle=Math.atan2(n,i),this.speed=Math.sqrt(i*i+n*n),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.world.emit("worldbounds",this,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)}this._dx=this.position.x-this.prev.x,this._dy=this.position.y-this.prev.y},postUpdate:function(){this._dx=this.position.x-this.prev.x,this._dy=this.position.y-this.prev.y,this.moves&&(0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.gameObject.x+=this._dx,this.gameObject.y+=this._dy,this._reset=!0),this._dx<0?this.facing=r.FACING_LEFT:this._dx>0&&(this.facing=r.FACING_RIGHT),this._dy<0?this.facing=r.FACING_UP:this._dy>0&&(this.facing=r.FACING_DOWN),this.allowRotation&&(this.gameObject.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y},checkWorldBounds:function(){var t=this.position,e=this.world.bounds,i=this.world.checkCollision,n=this.worldBounce?-this.worldBounce.x:-this.bounce.x,s=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=n,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=s,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setSize:function(t,e,i){void 0===i&&(i=!0);var n=this.gameObject;if(!t&&n.frame&&(t=n.frame.realWidth),!e&&n.frame&&(e=n.frame.realHeight),this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&n.getCenter){var s=n.displayWidth/2,r=n.displayHeight/2;this.offset.set(s-this.halfWidth,r-this.halfHeight)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i.setPosition(t,e),i.getTopLeft(this.position),this.prev.copy(this.position),this.rotation=i.angle,this.preRotation=i.angle,this.updateBounds(),this.updateCenter()},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):h(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this._dx>0?this._dx:-this._dx},deltaAbsY:function(){return this._dy>0?this._dy:-this._dy},deltaX:function(){return this._dx},deltaY:function(){return this._dy},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,n=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor),this.isCircle?t.strokeCircle(i,n,this.width/2):t.strokeRect(e.x,e.y,this.width,this.height)),this.debugShowVelocity&&(t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.velocity.x/2,n+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t){return void 0===t&&(t=!0),this.collideWorldBounds=t,this},setVelocity:function(t,e){return this.velocity.set(t,e),this.speed=Math.sqrt(t*t+e*e),this},setVelocityX:function(t){this.velocity.x=t;var e=t,i=this.velocity.y;return this.speed=Math.sqrt(e*e+i*i),this},setVelocityY:function(t){this.velocity.y=t;var e=this.velocity.x,i=t;return this.speed=Math.sqrt(e*e+i*i),this},setMaxVelocity:function(t,e){return this.maxVelocity.set(t,e),this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setAllowDrag:function(t){return void 0===t&&(t=!0),this.allowDrag=t,this},setAllowGravity:function(t){return void 0===t&&(t=!0),this.allowGravity=t,this},setAllowRotation:function(t){return void 0===t&&(t=!0),this.allowRotation=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return void 0===t&&(t=!0),this.immovable=t,this},setEnable:function(t){return void 0===t&&(t=!0),this.enable=t,this},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=u},function(t,e,i){var n=i(260),s=i(24),r=i(0),o=i(259),a=i(39),h=i(58),l=i(11),u=i(276),c=i(275),d=i(274),f=i(258),p=i(257),g=i(4),v=i(256),y=i(580),m=i(10),x=i(255),w=i(579),b=i(574),T=i(573),S=i(96),A=i(253),_=i(254),C=i(42),M=i(3),P=i(59),E=new r({Extends:l,initialize:function(t,e){l.call(this),this.scene=t,this.bodies=new S,this.staticBodies=new S,this.pendingDestroy=new S,this.colliders=new v,this.gravity=new M(g(e,"gravity.x",0),g(e,"gravity.y",0)),this.bounds=new m(g(e,"x",0),g(e,"y",0),g(e,"width",t.sys.game.config.width),g(e,"height",t.sys.game.config.height)),this.checkCollision={up:g(e,"checkCollision.up",!0),down:g(e,"checkCollision.down",!0),left:g(e,"checkCollision.left",!0),right:g(e,"checkCollision.right",!0)},this.fps=g(e,"fps",60),this._elapsed=0,this._frameTime=1/this.fps,this._frameTimeMS=1e3*this._frameTime,this.stepsLastFrame=0,this.timeScale=g(e,"timeScale",1),this.OVERLAP_BIAS=g(e,"overlapBias",4),this.TILE_BIAS=g(e,"tileBias",16),this.forceX=g(e,"forceX",!1),this.isPaused=g(e,"isPaused",!1),this._total=0,this.drawDebug=g(e,"debug",!1),this.debugGraphic,this.defaults={debugShowBody:g(e,"debugShowBody",!0),debugShowStaticBody:g(e,"debugShowStaticBody",!0),debugShowVelocity:g(e,"debugShowVelocity",!0),bodyDebugColor:g(e,"debugBodyColor",16711935),staticBodyDebugColor:g(e,"debugStaticBodyColor",255),velocityDebugColor:g(e,"debugVelocityColor",65280)},this.maxEntries=g(e,"maxEntries",16),this.useTree=g(e,"useTree",!0),this.tree=new x(this.maxEntries),this.staticTree=new x(this.maxEntries),this.treeMinMax={minX:0,minY:0,maxX:0,maxY:0},this._tempMatrix=new C,this._tempMatrix2=new C,this.drawDebug&&this.createDebugGraphic()},enable:function(t,e){void 0===e&&(e=a.DYNAMIC_BODY),Array.isArray(t)||(t=[t]);for(var i=0;i=s;)this._elapsed-=s,i++,this.step(n);this.stepsLastFrame=i}},step:function(t){var e,i,n=this.bodies.entries,s=n.length;for(e=0;e0){var l=this.tree,u=this.staticTree;for(o=(r=s.entries).length,t=0;ta.bottom)&&(h.xa.right))return this.separateCircle(t,e,s)}var l=!1,u=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)l.right&&(a=h(u.x,u.y,l.right,l.y)-u.radius):u.y>l.bottom&&(u.xl.right&&(a=h(u.x,u.y,l.right,l.bottom)-u.radius)),a*=-1}else a=t.halfWidth+e.halfWidth-h(t.center.x,t.center.y,e.center.x,e.center.y);if(i||0===a||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==a&&(t.onOverlap||e.onOverlap)&&this.emit("overlap",t.gameObject,e.gameObject,t,e),0!==a;var c=t.velocity.x,d=t.velocity.y,g=t.mass,v=e.velocity.x,y=e.velocity.y,m=e.mass,x=c*Math.cos(o)+d*Math.sin(o),w=c*Math.sin(o)-d*Math.cos(o),b=v*Math.cos(o)+y*Math.sin(o),T=v*Math.sin(o)-y*Math.cos(o),S=((g-m)*x+2*m*b)/(g+m),A=(2*g*x+(m-g)*b)/(g+m);t.immovable||(t.velocity.x=(S*Math.cos(o)-w*Math.sin(o))*t.bounce.x,t.velocity.y=(w*Math.cos(o)+S*Math.sin(o))*t.bounce.y,c=t.velocity.x,d=t.velocity.y),e.immovable||(e.velocity.x=(A*Math.cos(o)-T*Math.sin(o))*e.bounce.x,e.velocity.y=(T*Math.cos(o)+A*Math.sin(o))*e.bounce.y,v=e.velocity.x,y=e.velocity.y),Math.abs(o)0&&!t.immovable&&v>c?t.velocity.x*=-1:v<0&&!e.immovable&&c0&&!t.immovable&&y>d?t.velocity.y*=-1:y<0&&!e.immovable&&dMath.PI/2&&(c<0&&!t.immovable&&v0&&!e.immovable&&c>v?e.velocity.x*=-1:d<0&&!t.immovable&&y0&&!e.immovable&&c>y&&(e.velocity.y*=-1));var _=this._frameTime;return t.immovable||(t.x+=t.velocity.x*_-a*Math.cos(o),t.y+=t.velocity.y*_-a*Math.sin(o)),e.immovable||(e.x+=e.velocity.x*_+a*Math.cos(o),e.y+=e.velocity.y*_+a*Math.sin(o)),(t.onCollide||e.onCollide)&&this.emit("collide",t.gameObject,e.gameObject,t,e),t.postUpdate(),e.postUpdate(),!0},intersects:function(t,e){return t!==e&&(t.isCircle||e.isCircle?t.isCircle?e.isCircle?h(t.center.x,t.center.y,e.center.x,e.center.y)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):this.circleBodyIntersects(e,t):!(t.right<=e.position.x||t.bottom<=e.position.y||t.position.x>=e.right||t.position.y>=e.bottom))},circleBodyIntersects:function(t,e){var i=s(t.center.x,e.left,e.right),n=s(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!0)},collide:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!1)},collideObjects:function(t,e,i,n,s,r){var o;t.isParent&&void 0===t.physicsType&&(t=t.children.entries),e&&e.isParent&&void 0===e.physicsType&&(e=e.children.entries);var a=Array.isArray(t),h=Array.isArray(e);if(this._total=0,a||h)if(!a&&h)for(o=0;o0},collideHandler:function(t,e,i,n,s,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,n,s,r);if(!t||!e)return!1;if(t.body){if(e.body)return this.collideSpriteVsSprite(t,e,i,n,s,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,n,s,r)}else if(t.isParent){if(e.body)return this.collideSpriteVsGroup(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,n,s,r)}else if(t.isTilemap){if(e.body)return this.collideSpriteVsTilemapLayer(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,n,s,r)}},collideSpriteVsSprite:function(t,e,i,n,s,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,n,s,r)&&(i&&i.call(s,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,n,s,r){var o,h,l,u=t.body;if(0!==e.length&&u&&u.enable)if(this.useTree){var c=this.treeMinMax;c.minX=u.left,c.minY=u.top,c.maxX=u.right,c.maxY=u.bottom;var d=e.physicsType===a.DYNAMIC_BODY?this.tree.search(c):this.staticTree.search(c);for(h=d.length,o=0;oc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,l+=d}c.tileHeight>c.baseTileHeight&&(u+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f,p=e.getTilesWithinWorldXY(a,h,l,u);if(0===p.length)return!1;for(var g={left:0,right:0,top:0,bottom:0},v=0;v0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(u.copy(h).cross(t).length()<1e-6&&u.copy(l).cross(t),u.normalize(),this.setAxisAngle(u,Math.PI)):i>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(u.copy(t).cross(e),this.x=u.x,this.y=u.y,this.z=u.z,this.w=1+i,this.normalize())},setAxes:function(t,e,i){var n=c.val;return n[0]=e.x,n[3]=e.y,n[6]=e.z,n[1]=i.x,n[4]=i.y,n[7]=i.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(c).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=Math.cos(e),this},multiply:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.x=e*h+s*r+i*a-n*o,this.y=i*h+s*o+n*r-e*a,this.z=n*h+s*a+e*o-i*r,this.w=s*h-e*r-i*o-n*a,this},slerp:function(t,e){var i=this.x,n=this.y,s=this.z,r=this.w,o=t.x,a=t.y,h=t.z,l=t.w,u=i*o+n*a+s*h+r*l;u<0&&(u=-u,o=-o,a=-a,h=-h,l=-l);var c=1-e,d=e;if(1-u>1e-6){var f=Math.acos(u),p=Math.sin(f);c=Math.sin((1-e)*f)/p,d=Math.sin(e*f)/p}return this.x=c*i+d*o,this.y=c*n+d*a,this.z=c*s+d*h,this.w=c*r+d*l,this},invert:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-e*r,this.z=-i*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+s*r,this.y=i*o+n*r,this.z=n*o-i*r,this.w=s*o-e*r,this},rotateY:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o-n*r,this.y=i*o+s*r,this.z=n*o+e*r,this.w=s*o-i*r,this},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+i*r,this.y=i*o-e*r,this.z=n*o+s*r,this.w=s*o-n*r,this},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(1-t*t-e*e-i*i),this},fromMat3:function(t){var e,i=t.val,n=i[0]+i[4]+i[8];if(n>0)e=Math.sqrt(n+1),this.w=.5*e,e=.5/e,this.x=(i[7]-i[5])*e,this.y=(i[2]-i[6])*e,this.z=(i[3]-i[1])*e;else{var s=0;i[4]>i[0]&&(s=1),i[8]>i[3*s+s]&&(s=2);var r=o[s],h=o[r];e=Math.sqrt(i[3*s+s]-i[3*r+r]-i[3*h+h]+1),a[s]=.5*e,e=.5/e,a[r]=(i[3*r+s]+i[3*s+r])*e,a[h]=(i[3*h+s]+i[3*s+h])*e,this.x=a[0],this.y=a[1],this.z=a[2],this.w=(i[3*h+r]-i[3*r+h])*e}return this}});t.exports=d},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this},zero:function(){var t=this.val;return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,this},xyz:function(t,e,i){this.identity();var n=this.val;return n[12]=t,n[13]=e,n[14]=i,this},scaling:function(t,e,i){this.zero();var n=this.val;return n[0]=t,n[5]=e,n[10]=i,n[15]=1,this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[3],s=t[6],r=t[7],o=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=s,t[11]=t[14],t[12]=n,t[13]=r,t[14]=o,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15],y=e*o-i*r,m=e*a-n*r,x=e*h-s*r,w=i*a-n*o,b=i*h-s*o,T=n*h-s*a,S=l*p-u*f,A=l*g-c*f,_=l*v-d*f,C=u*g-c*p,M=u*v-d*p,P=c*v-d*g,E=y*P-m*M+x*C+w*_-b*A+T*S;return E?(E=1/E,t[0]=(o*P-a*M+h*C)*E,t[1]=(n*M-i*P-s*C)*E,t[2]=(p*T-g*b+v*w)*E,t[3]=(c*b-u*T-d*w)*E,t[4]=(a*_-r*P-h*A)*E,t[5]=(e*P-n*_+s*A)*E,t[6]=(g*x-f*T-v*m)*E,t[7]=(l*T-c*x+d*m)*E,t[8]=(r*M-o*_+h*S)*E,t[9]=(i*_-e*M-s*S)*E,t[10]=(f*b-p*x+v*y)*E,t[11]=(u*x-l*b-d*y)*E,t[12]=(o*A-r*C-a*S)*E,t[13]=(e*C-i*A+n*S)*E,t[14]=(p*m-f*w-g*y)*E,t[15]=(l*w-u*m+c*y)*E,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return t[0]=o*(c*v-d*g)-u*(a*v-h*g)+p*(a*d-h*c),t[1]=-(i*(c*v-d*g)-u*(n*v-s*g)+p*(n*d-s*c)),t[2]=i*(a*v-h*g)-o*(n*v-s*g)+p*(n*h-s*a),t[3]=-(i*(a*d-h*c)-o*(n*d-s*c)+u*(n*h-s*a)),t[4]=-(r*(c*v-d*g)-l*(a*v-h*g)+f*(a*d-h*c)),t[5]=e*(c*v-d*g)-l*(n*v-s*g)+f*(n*d-s*c),t[6]=-(e*(a*v-h*g)-r*(n*v-s*g)+f*(n*h-s*a)),t[7]=e*(a*d-h*c)-r*(n*d-s*c)+l*(n*h-s*a),t[8]=r*(u*v-d*p)-l*(o*v-h*p)+f*(o*d-h*u),t[9]=-(e*(u*v-d*p)-l*(i*v-s*p)+f*(i*d-s*u)),t[10]=e*(o*v-h*p)-r*(i*v-s*p)+f*(i*h-s*o),t[11]=-(e*(o*d-h*u)-r*(i*d-s*u)+l*(i*h-s*o)),t[12]=-(r*(u*g-c*p)-l*(o*g-a*p)+f*(o*c-a*u)),t[13]=e*(u*g-c*p)-l*(i*g-n*p)+f*(i*c-n*u),t[14]=-(e*(o*g-a*p)-r*(i*g-n*p)+f*(i*a-n*o)),t[15]=e*(o*c-a*u)-r*(i*c-n*u)+l*(i*a-n*o),this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return(e*o-i*r)*(c*v-d*g)-(e*a-n*r)*(u*v-d*p)+(e*h-s*r)*(u*g-c*p)+(i*a-n*o)*(l*v-d*f)-(i*h-s*o)*(l*g-c*f)+(n*h-s*a)*(l*p-u*f)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],y=e[15],m=t.val,x=m[0],w=m[1],b=m[2],T=m[3];return e[0]=x*i+w*o+b*u+T*p,e[1]=x*n+w*a+b*c+T*g,e[2]=x*s+w*h+b*d+T*v,e[3]=x*r+w*l+b*f+T*y,x=m[4],w=m[5],b=m[6],T=m[7],e[4]=x*i+w*o+b*u+T*p,e[5]=x*n+w*a+b*c+T*g,e[6]=x*s+w*h+b*d+T*v,e[7]=x*r+w*l+b*f+T*y,x=m[8],w=m[9],b=m[10],T=m[11],e[8]=x*i+w*o+b*u+T*p,e[9]=x*n+w*a+b*c+T*g,e[10]=x*s+w*h+b*d+T*v,e[11]=x*r+w*l+b*f+T*y,x=m[12],w=m[13],b=m[14],T=m[15],e[12]=x*i+w*o+b*u+T*p,e[13]=x*n+w*a+b*c+T*g,e[14]=x*s+w*h+b*d+T*v,e[15]=x*r+w*l+b*f+T*y,this},multiplyLocal:function(t){var e=[],i=this.val,n=t.val;return e[0]=i[0]*n[0]+i[1]*n[4]+i[2]*n[8]+i[3]*n[12],e[1]=i[0]*n[1]+i[1]*n[5]+i[2]*n[9]+i[3]*n[13],e[2]=i[0]*n[2]+i[1]*n[6]+i[2]*n[10]+i[3]*n[14],e[3]=i[0]*n[3]+i[1]*n[7]+i[2]*n[11]+i[3]*n[15],e[4]=i[4]*n[0]+i[5]*n[4]+i[6]*n[8]+i[7]*n[12],e[5]=i[4]*n[1]+i[5]*n[5]+i[6]*n[9]+i[7]*n[13],e[6]=i[4]*n[2]+i[5]*n[6]+i[6]*n[10]+i[7]*n[14],e[7]=i[4]*n[3]+i[5]*n[7]+i[6]*n[11]+i[7]*n[15],e[8]=i[8]*n[0]+i[9]*n[4]+i[10]*n[8]+i[11]*n[12],e[9]=i[8]*n[1]+i[9]*n[5]+i[10]*n[9]+i[11]*n[13],e[10]=i[8]*n[2]+i[9]*n[6]+i[10]*n[10]+i[11]*n[14],e[11]=i[8]*n[3]+i[9]*n[7]+i[10]*n[11]+i[11]*n[15],e[12]=i[12]*n[0]+i[13]*n[4]+i[14]*n[8]+i[15]*n[12],e[13]=i[12]*n[1]+i[13]*n[5]+i[14]*n[9]+i[15]*n[13],e[14]=i[12]*n[2]+i[13]*n[6]+i[14]*n[10]+i[15]*n[14],e[15]=i[12]*n[3]+i[13]*n[7]+i[14]*n[11]+i[15]*n[15],this.fromArray(e)},translate:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[12]=s[0]*e+s[4]*i+s[8]*n+s[12],s[13]=s[1]*e+s[5]*i+s[9]*n+s[13],s[14]=s[2]*e+s[6]*i+s[10]*n+s[14],s[15]=s[3]*e+s[7]*i+s[11]*n+s[15],this},scale:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[0]=s[0]*e,s[1]=s[1]*e,s[2]=s[2]*e,s[3]=s[3]*e,s[4]=s[4]*i,s[5]=s[5]*i,s[6]=s[6]*i,s[7]=s[7]*i,s[8]=s[8]*n,s[9]=s[9]*n,s[10]=s[10]*n,s[11]=s[11]*n,this},makeRotationAxis:function(t,e){var i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,a=t.z,h=s*r,l=s*o;return this.fromArray([h*r+i,h*o-n*a,h*a+n*o,0,h*o+n*a,l*o+i,l*a-n*r,0,h*a-n*o,l*a+n*r,s*a*a+i,0,0,0,0,1]),this},rotate:function(t,e){var i=this.val,n=e.x,s=e.y,r=e.z,o=Math.sqrt(n*n+s*s+r*r);if(Math.abs(o)<1e-6)return null;n*=o=1/o,s*=o,r*=o;var a=Math.sin(t),h=Math.cos(t),l=1-h,u=i[0],c=i[1],d=i[2],f=i[3],p=i[4],g=i[5],v=i[6],y=i[7],m=i[8],x=i[9],w=i[10],b=i[11],T=n*n*l+h,S=s*n*l+r*a,A=r*n*l-s*a,_=n*s*l-r*a,C=s*s*l+h,M=r*s*l+n*a,P=n*r*l+s*a,E=s*r*l-n*a,k=r*r*l+h;return i[0]=u*T+p*S+m*A,i[1]=c*T+g*S+x*A,i[2]=d*T+v*S+w*A,i[3]=f*T+y*S+b*A,i[4]=u*_+p*C+m*M,i[5]=c*_+g*C+x*M,i[6]=d*_+v*C+w*M,i[7]=f*_+y*C+b*M,i[8]=u*P+p*E+m*k,i[9]=c*P+g*E+x*k,i[10]=d*P+v*E+w*k,i[11]=f*P+y*E+b*k,this},rotateX:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],l=e[9],u=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+l*i,e[6]=o*n+u*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=l*n-r*i,e[10]=u*n-o*i,e[11]=c*n-a*i,this},rotateY:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],l=e[9],u=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-l*i,e[2]=o*n-u*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+l*n,e[10]=o*i+u*n,e[11]=a*i+c*n,this},rotateZ:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],l=e[5],u=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+l*i,e[2]=o*n+u*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=l*n-r*i,e[6]=u*n-o*i,e[7]=c*n-a*i,this},fromRotationTranslation:function(t,e){var i=this.val,n=t.x,s=t.y,r=t.z,o=t.w,a=n+n,h=s+s,l=r+r,u=n*a,c=n*h,d=n*l,f=s*h,p=s*l,g=r*l,v=o*a,y=o*h,m=o*l;return i[0]=1-(f+g),i[1]=c+m,i[2]=d-y,i[3]=0,i[4]=c-m,i[5]=1-(u+g),i[6]=p+v,i[7]=0,i[8]=d+y,i[9]=p-v,i[10]=1-(u+f),i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},fromQuat:function(t){var e=this.val,i=t.x,n=t.y,s=t.z,r=t.w,o=i+i,a=n+n,h=s+s,l=i*o,u=i*a,c=i*h,d=n*a,f=n*h,p=s*h,g=r*o,v=r*a,y=r*h;return e[0]=1-(d+p),e[1]=u+y,e[2]=c-v,e[3]=0,e[4]=u-y,e[5]=1-(l+p),e[6]=f+g,e[7]=0,e[8]=c+v,e[9]=f-g,e[10]=1-(l+d),e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},frustum:function(t,e,i,n,s,r){var o=this.val,a=1/(e-t),h=1/(n-i),l=1/(s-r);return o[0]=2*s*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2*s*h,o[6]=0,o[7]=0,o[8]=(e+t)*a,o[9]=(n+i)*h,o[10]=(r+s)*l,o[11]=-1,o[12]=0,o[13]=0,o[14]=r*s*2*l,o[15]=0,this},perspective:function(t,e,i,n){var s=this.val,r=1/Math.tan(t/2),o=1/(i-n);return s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+i)*o,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*i*o,s[15]=0,this},perspectiveLH:function(t,e,i,n){var s=this.val;return s[0]=2*i/t,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*i/e,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=-n/(i-n),s[11]=1,s[12]=0,s[13]=0,s[14]=i*n/(i-n),s[15]=0,this},ortho:function(t,e,i,n,s,r){var o=this.val,a=t-e,h=i-n,l=s-r;return a=0===a?a:1/a,h=0===h?h:1/h,l=0===l?l:1/l,o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*l,o[11]=0,o[12]=(t+e)*a,o[13]=(n+i)*h,o[14]=(r+s)*l,o[15]=1,this},lookAt:function(t,e,i){var n=this.val,s=t.x,r=t.y,o=t.z,a=i.x,h=i.y,l=i.z,u=e.x,c=e.y,d=e.z;if(Math.abs(s-u)<1e-6&&Math.abs(r-c)<1e-6&&Math.abs(o-d)<1e-6)return this.identity();var f=s-u,p=r-c,g=o-d,v=1/Math.sqrt(f*f+p*p+g*g),y=h*(g*=v)-l*(p*=v),m=l*(f*=v)-a*g,x=a*p-h*f;(v=Math.sqrt(y*y+m*m+x*x))?(y*=v=1/v,m*=v,x*=v):(y=0,m=0,x=0);var w=p*x-g*m,b=g*y-f*x,T=f*m-p*y;return(v=Math.sqrt(w*w+b*b+T*T))?(w*=v=1/v,b*=v,T*=v):(w=0,b=0,T=0),n[0]=y,n[1]=w,n[2]=f,n[3]=0,n[4]=m,n[5]=b,n[6]=p,n[7]=0,n[8]=x,n[9]=T,n[10]=g,n[11]=0,n[12]=-(y*s+m*r+x*o),n[13]=-(w*s+b*r+T*o),n[14]=-(f*s+p*r+g*o),n[15]=1,this},yawPitchRoll:function(t,e,i){this.zero(),s.zero(),r.zero();var n=this.val,o=s.val,a=r.val,h=Math.sin(i),l=Math.cos(i);return n[10]=1,n[15]=1,n[0]=l,n[1]=h,n[4]=-h,n[5]=l,h=Math.sin(e),l=Math.cos(e),o[0]=1,o[15]=1,o[5]=l,o[10]=l,o[9]=-h,o[6]=h,h=Math.sin(t),l=Math.cos(t),a[5]=1,a[15]=1,a[0]=l,a[2]=-h,a[8]=h,a[10]=l,this.multiplyLocal(s),this.multiplyLocal(r),this},setWorldMatrix:function(t,e,i,n,o){return this.yawPitchRoll(t.y,t.x,t.z),s.scaling(i.x,i.y,i.z),r.xyz(e.x,e.y,e.z),this.multiplyLocal(s),this.multiplyLocal(r),void 0!==n&&this.multiplyLocal(n),void 0!==o&&this.multiplyLocal(o),this}}),s=new n,r=new n;t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},fromMat4:function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=n,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=l*r-o*h,c=-l*s+o*a,d=h*s-r*a,f=e*u+i*c+n*d;return f?(f=1/f,t[0]=u*f,t[1]=(-l*i+n*h)*f,t[2]=(o*i-n*r)*f,t[3]=c*f,t[4]=(l*e-n*a)*f,t[5]=(-o*e+n*s)*f,t[6]=d*f,t[7]=(-h*e+i*a)*f,t[8]=(r*e-i*s)*f,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return t[0]=r*l-o*h,t[1]=n*h-i*l,t[2]=i*o-n*r,t[3]=o*a-s*l,t[4]=e*l-n*a,t[5]=n*s-e*o,t[6]=s*h-r*a,t[7]=i*a-e*h,t[8]=e*r-i*s,this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return e*(l*r-o*h)+i*(-l*s+o*a)+n*(h*s-r*a)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=t.val,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=c[6],x=c[7],w=c[8];return e[0]=d*i+f*r+p*h,e[1]=d*n+f*o+p*l,e[2]=d*s+f*a+p*u,e[3]=g*i+v*r+y*h,e[4]=g*n+v*o+y*l,e[5]=g*s+v*a+y*u,e[6]=m*i+x*r+w*h,e[7]=m*n+x*o+w*l,e[8]=m*s+x*a+w*u,this},translate:function(t){var e=this.val,i=t.x,n=t.y;return e[6]=i*e[0]+n*e[3]+e[6],e[7]=i*e[1]+n*e[4]+e[7],e[8]=i*e[2]+n*e[5]+e[8],this},rotate:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=Math.sin(t),l=Math.cos(t);return e[0]=l*i+h*r,e[1]=l*n+h*o,e[2]=l*s+h*a,e[3]=l*r-h*i,e[4]=l*o-h*n,e[5]=l*a-h*s,this},scale:function(t){var e=this.val,i=t.x,n=t.y;return e[0]=i*e[0],e[1]=i*e[1],e[2]=i*e[2],e[3]=n*e[3],e[4]=n*e[4],e[5]=n*e[5],this},fromQuat:function(t){var e=t.x,i=t.y,n=t.z,s=t.w,r=e+e,o=i+i,a=n+n,h=e*r,l=e*o,u=e*a,c=i*o,d=i*a,f=n*a,p=s*r,g=s*o,v=s*a,y=this.val;return y[0]=1-(c+f),y[3]=l+v,y[6]=u-g,y[1]=l-v,y[4]=1-(h+f),y[7]=d+p,y[2]=u+g,y[5]=d-p,y[8]=1-(h+c),this},normalFromMat4:function(t){var e=t.val,i=this.val,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],g=e[12],v=e[13],y=e[14],m=e[15],x=n*h-s*a,w=n*l-r*a,b=n*u-o*a,T=s*l-r*h,S=s*u-o*h,A=r*u-o*l,_=c*v-d*g,C=c*y-f*g,M=c*m-p*g,P=d*y-f*v,E=d*m-p*v,k=f*m-p*y,F=x*k-w*E+b*P+T*M-S*C+A*_;return F?(F=1/F,i[0]=(h*k-l*E+u*P)*F,i[1]=(l*M-a*k-u*C)*F,i[2]=(a*E-h*M+u*_)*F,i[3]=(r*E-s*k-o*P)*F,i[4]=(n*k-r*M+o*C)*F,i[5]=(s*M-n*E-o*_)*F,i[6]=(v*A-y*S+m*T)*F,i[7]=(y*b-g*A-m*w)*F,i[8]=(g*S-v*b+m*x)*F,this):null}});t.exports=n},function(t,e){t.exports=function(t,e){var i=t.x,n=t.y;return t.x=i*Math.cos(e)-n*Math.sin(e),t.y=i*Math.sin(e)+n*Math.cos(e),t}},function(t,e){t.exports=function(t,e,i,n){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.ceil(t/e),n?(i+t)/e:i+t)}},function(t,e){t.exports=function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e}},function(t,e,i){var n=i(272);t.exports=function(t,e){return n(t)/n(e)/n(t-e)}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),te-i}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)=0?t:t+2*Math.PI}},function(t,e,i){var n=i(0),s=i(20),r=i(22),o=i(7),a=i(1),h=i(8),l=new n({Extends:r,initialize:function(t,e,i,n){var s="txt";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),n=a(o,"xhrSettings"),s=a(o,"extension",s)}var l={type:"text",cache:t.cacheManager.text,extension:s,responseType:"text",key:e,url:i,xhrSettings:n};r.call(this,t,l)},onProcess:function(){this.state=s.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()}});o.register("text",function(t,e,i){if(Array.isArray(t))for(var n=0;n=2&&(this.leftStick.set(r[0].getValue(),r[1].getValue()),s>=4&&this.rightStick.set(r[2].getValue(),r[3].getValue()))},destroy:function(){var t;for(this.removeAllListeners(),this.manager=null,this.pad=null,t=0;t=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",e,this,t),this.pad.emit("down",i,t,this)):this.pressed&&(this.pressed=!1,this.events.emit("up",e,this,t),this.pad.emit("up",i,t,this))},destroy:function(){this.pad=null,this.events=null}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.1},update:function(t){this.value=t},getValue:function(){return Math.abs(this.value)t.width*t.height)&&e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottom0){var d=(a*r+h*o)/l;u*=d,c*=d}return i.x=t.x1+u,i.y=t.y1+c,u*u+c*c<=l&&u*r+c*o>=0&&n(e,i.x,i.y)}},function(t,e,i){t.exports={CircleToCircle:i(770),CircleToRectangle:i(769),GetRectangleIntersection:i(768),LineToCircle:i(300),LineToLine:i(117),LineToRectangle:i(767),PointToLine:i(299),PointToLineSegment:i(766),RectangleToRectangle:i(164),RectangleToTriangle:i(765),RectangleToValues:i(764),TriangleToCircle:i(763),TriangleToLine:i(762),TriangleToTriangle:i(761)}},function(t,e,i){t.exports={Circle:i(790),Ellipse:i(780),Intersects:i(301),Line:i(760),Point:i(742),Polygon:i(728),Rectangle:i(293),Triangle:i(698)}},function(t,e,i){var n=i(0),s=i(304),r=i(9),o=new n({initialize:function(){this.lightPool=[],this.lights=[],this.culledLights=[],this.ambientColor={r:.1,g:.1,b:.1},this.active=!1,this.maxLights=-1},enable:function(){return-1===this.maxLights&&(this.maxLights=this.scene.sys.game.renderer.config.maxLights),this.active=!0,this},disable:function(){return this.active=!1,this},cull:function(t){var e=this.lights,i=this.culledLights,n=e.length,s=t.x+t.width/2,r=t.y+t.height/2,o=(t.width+t.height)/2,a={x:0,y:0},h=t.matrix,l=this.systems.game.config.height;i.length=0;for(var u=0;u0?(h=this.lightPool.pop()).set(t,e,i,a[0],a[1],a[2],o):h=new s(t,e,i,a[0],a[1],a[2],o),this.lights.push(h),h},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&(this.lightPool.push(t),this.lights.splice(e,1)),this},shutdown:function(){for(;this.lights.length>0;)this.lightPool.push(this.lights.pop());this.ambientColor={r:.1,g:.1,b:.1},this.culledLights.length=0,this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=o},function(t,e,i){var n=i(0),s=i(9),r=new n({initialize:function(t,e,i,n,s,r,o){this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1},set:function(t,e,i,n,s,r,o){return this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1,this},setScrollFactor:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this},setColor:function(t){var e=s.getFloatsFromUintRGB(t);return this.r=e[0],this.g=e[1],this.b=e[2],this},setIntensity:function(t){return this.intensity=t,this},setPosition:function(t,e){return this.x=t,this.y=e,this},setRadius:function(t){return this.radius=t,this}});t.exports=r},function(t,e,i){var n=i(71),s=i(6);t.exports=function(t,e,i,r){void 0===r&&(r=[]);var o=t.getLineA(),a=t.getLineB(),h=t.getLineC(),l=n(o),u=n(a),c=n(h),d=l+u+c;e||(e=d/i);for(var f=0;fl+u?(g=(p-=l+u)/c,v.x=h.x1+(h.x2-h.x1)*g,v.y=h.y1+(h.y2-h.y1)*g):(g=(p-=l)/u,v.x=a.x1+(a.x2-a.x1)*g,v.y=a.y1+(a.y2-a.y1)*g),r.push(v)}return r}},function(t,e,i){var n=i(6),s=i(71);t.exports=function(t,e,i){void 0===i&&(i=new n);var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=s(r),l=s(o),u=s(a),c=(h+l+u)*e,d=0;return ch+l?(d=(c-=h+l)/u,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/l,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},function(t,e,i){var n=i(0),s=i(31),r=i(66),o=i(839),a=new n({Extends:s,Mixins:[o],initialize:function(t,e,i,n,o,a,h,l,u,c,d){void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=128),void 0===a&&(a=64),void 0===h&&(h=0),void 0===l&&(l=128),void 0===u&&(u=128),s.call(this,t,"Triangle",new r(n,o,a,h,l,u));var f=this.geom.right-this.geom.left,p=this.geom.bottom-this.geom.top;this.setPosition(e,i),this.setSize(f,p),void 0!==c&&this.setFillStyle(c,d),this.updateDisplayOrigin(),this.updateData()},setTo:function(t,e,i,n,s,r){return this.geom.setTo(t,e,i,n,s,r),this.updateData()},updateData:function(){var t=[],e=this.geom,i=this._tempLine;return e.getLineA(i),t.push(i.x1,i.y1,i.x2,i.y2),e.getLineB(i),t.push(i.x2,i.y2),e.getLineC(i),t.push(i.x2,i.y2),this.pathData=t,this}});t.exports=a},function(t,e,i){var n=i(842),s=i(0),r=i(70),o=i(31),a=new s({Extends:o,Mixins:[n],initialize:function(t,e,i,n,s,r,a,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=5),void 0===s&&(s=32),void 0===r&&(r=64),o.call(this,t,"Star",null),this._points=n,this._innerRadius=s,this._outerRadius=r,this.setPosition(e,i),this.setSize(2*r,2*r),void 0!==a&&this.setFillStyle(a,h),this.updateDisplayOrigin(),this.updateData()},setPoints:function(t){return this._points=t,this.updateData()},setInnerRadius:function(t){return this._innerRadius=t,this.updateData()},setOuterRadius:function(t){return this._outerRadius=t,this.updateData()},points:{get:function(){return this._points},set:function(t){this._points=t,this.updateData()}},innerRadius:{get:function(){return this._innerRadius},set:function(t){this._innerRadius=t,this.updateData()}},outerRadius:{get:function(){return this._outerRadius},set:function(t){this._outerRadius=t,this.updateData()}},updateData:function(){var t=[],e=this._points,i=this._innerRadius,n=this._outerRadius,s=Math.PI/2*3,o=Math.PI/e,a=n,h=n;t.push(a,h+-n);for(var l=0;l0&&r.push(i([0,0],n[0])),e=0;e1&&r.push(i([0,0],n[n.length-1])),t.setTo(r)}},function(t,e,i){var n=i(71),s=i(60);t.exports=function(t){for(var e=t.points,i=0,r=0;rc+v)){var y=g.getPoint((u-c)/v);o.push(y);break}c+=v}return o}},function(t,e,i){var n=i(10);t.exports=function(t,e){void 0===e&&(e=new n);for(var i,s=1/0,r=1/0,o=-s,a=-r,h=0;h0&&(s=-h.PI2+s%h.PI2):s>h.PI2?s=h.PI2:s<0&&(s=h.PI2+s%h.PI2);for(var u,c=[a+Math.cos(n)*i,l+Math.sin(n)*i];e<1;)u=s*e+n,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),e+=t;return u=s+n,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),c.push(a+Math.cos(n)*i,l+Math.sin(n)*i),this.pathIndexes=o(c),this.pathData=c,this}});t.exports=u},function(t,e){t.exports=function(t){var e=Math.log(t)/.6931471805599453;return 1<this._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=this.source.contains(t.x,t.y);return e&&this.killOnEnter||!e&&!this.killOnEnter}});t.exports=n},function(t,e,i){var n=i(72),s=i(0),r=i(16),o=i(329),a=i(328),h=i(889),l=i(1),u=i(178),c=i(326),d=i(77),f=i(331),p=i(325),g=i(10),v=i(120),y=i(3),m=i(59),x=new s({Mixins:[r.BlendMode,r.Mask,r.ScrollFactor,r.Visible],initialize:function(t,e){this.manager=t,this.texture=t.texture,this.frames=[t.defaultFrame],this.defaultFrame=t.defaultFrame,this.configFastMap=["active","blendMode","collideBottom","collideLeft","collideRight","collideTop","deathCallback","deathCallbackScope","emitCallback","emitCallbackScope","follow","frequency","gravityX","gravityY","maxParticles","name","on","particleBringToTop","particleClass","radial","timeScale","trackVisible","visible"],this.configOpMap=["accelerationX","accelerationY","angle","alpha","bounce","delay","lifespan","maxVelocityX","maxVelocityY","moveToX","moveToY","quantity","rotate","scaleX","scaleY","speedX","speedY","tint","x","y"],this.name="",this.particleClass=f,this.x=new h(e,"x",0),this.y=new h(e,"y",0),this.radial=!0,this.gravityX=0,this.gravityY=0,this.acceleration=!1,this.accelerationX=new h(e,"accelerationX",0,!0),this.accelerationY=new h(e,"accelerationY",0,!0),this.maxVelocityX=new h(e,"maxVelocityX",1e4,!0),this.maxVelocityY=new h(e,"maxVelocityY",1e4,!0),this.speedX=new h(e,"speedX",0,!0),this.speedY=new h(e,"speedY",0,!0),this.moveTo=!1,this.moveToX=new h(e,"moveToX",0,!0),this.moveToY=new h(e,"moveToY",0,!0),this.bounce=new h(e,"bounce",0,!0),this.scaleX=new h(e,"scaleX",1),this.scaleY=new h(e,"scaleY",1),this.tint=new h(e,"tint",4294967295),this.alpha=new h(e,"alpha",1),this.lifespan=new h(e,"lifespan",1e3),this.angle=new h(e,"angle",{min:0,max:360}),this.rotate=new h(e,"rotate",0),this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.maxParticles=0,this.quantity=new h(e,"quantity",1,!0),this.delay=new h(e,"delay",0,!0),this.frequency=0,this.on=!0,this.particleBringToTop=!0,this.timeScale=1,this.emitZone=null,this.deathZone=null,this.bounds=null,this.collideLeft=!0,this.collideRight=!0,this.collideTop=!0,this.collideBottom=!0,this.active=!0,this.visible=!0,this.blendMode=n.NORMAL,this.follow=null,this.followOffset=new y,this.trackVisible=!1,this.currentFrame=0,this.randomFrame=!0,this.frameQuantity=1,this.dead=[],this.alive=[],this._counter=0,this._frameCounter=0,e&&this.fromJSON(e)},fromJSON:function(t){if(!t)return this;var e=0,i="";for(e=0;e0&&this.getParticleCount()===this.maxParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,n=i.length,s=0;s0?n.pop():new this.particleClass(this)).fire(e,i),this.particleBringToTop?this.alive.push(r):this.alive.unshift(r),this.emitCallback&&this.emitCallback.call(this.emitCallbackScope,r,this),this.atLimit())break}return r}},preUpdate:function(t,e){var i=(e*=this.timeScale)/1e3;this.trackVisible&&(this.visible=this.follow.visible);for(var n=this.manager.getProcessors(),s=this.alive,r=s.length,o=0;o0){var u=s.splice(s.length-l,l),c=this.deathCallback,d=this.deathCallbackScope;if(c)for(var f=0;f0&&(this._counter-=e,this._counter<=0&&(this.emitParticle(),this._counter=this.frequency-Math.abs(this._counter))))},depthSortCallback:function(t,e){return t.y-e.y},indexSortCallback:function(t,e){return t.index-e.index}});t.exports=x},function(t,e,i){var n=i(0),s=i(36),r=i(58),o=new n({initialize:function(t){this.emitter=t,this.frame=null,this.index=0,this.x=0,this.y=0,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.tint=16777215,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215,current:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1}}},isAlive:function(){return this.lifeCurrent>0},fire:function(t,e){var i=this.emitter;this.frame=i.getFrame(),i.emitZone&&i.emitZone.getPoint(this),void 0===t?(i.follow&&(this.x+=i.follow.x+i.followOffset.x),this.x+=i.x.onEmit(this,"x")):this.x+=t,void 0===e?(i.follow&&(this.y+=i.follow.y+i.followOffset.y),this.y+=i.y.onEmit(this,"y")):this.y+=e,this.life=i.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0;var n=i.speedX.onEmit(this,"speedX"),o=i.speedY?i.speedY.onEmit(this,"speedY"):n;if(i.radial){var a=s(i.angle.onEmit(this,"angle"));this.velocityX=Math.cos(a)*Math.abs(n),this.velocityY=Math.sin(a)*Math.abs(o)}else if(i.moveTo){var h=i.moveToX.onEmit(this,"moveToX"),l=i.moveToY?i.moveToY.onEmit(this,"moveToY"):h,u=Math.atan2(l-this.y,h-this.x),c=r(this.x,this.y,h,l)/(this.life/1e3);this.velocityX=Math.cos(u)*c,this.velocityY=Math.sin(u)*c}else this.velocityX=n,this.velocityY=o;i.acceleration&&(this.accelerationX=i.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=i.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=i.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=i.maxVelocityY.onEmit(this,"maxVelocityY"),this.delayCurrent=i.delay.onEmit(this,"delay"),this.scaleX=i.scaleX.onEmit(this,"scaleX"),this.scaleY=i.scaleY?i.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=i.rotate.onEmit(this,"rotate"),this.rotation=s(this.angle),this.bounce=i.bounce.onEmit(this,"bounce"),this.alpha=i.alpha.onEmit(this,"alpha"),this.tint=i.tint.onEmit(this,"tint"),this.index=i.alive.length},computeVelocity:function(t,e,i,n){var s=this.velocityX,r=this.velocityY,o=this.accelerationX,a=this.accelerationY,h=this.maxVelocityX,l=this.maxVelocityY;s+=t.gravityX*i,r+=t.gravityY*i,o&&(s+=o*i),a&&(r+=a*i),s>h?s=h:s<-h&&(s=-h),r>l?r=l:r<-l&&(r=-l),this.velocityX=s,this.velocityY=r;for(var u=0;ue.right&&t.collideRight&&(this.x=e.right,this.velocityX*=i),this.ye.bottom&&t.collideBottom&&(this.y=e.bottom,this.velocityY*=i)},update:function(t,e,i){if(this.delayCurrent>0)return this.delayCurrent-=t,!1;var n=this.emitter,r=1-this.lifeCurrent/this.life;return this.lifeT=r,this.computeVelocity(n,t,e,i),this.x+=this.velocityX*e,this.y+=this.velocityY*e,n.bounds&&this.checkBounds(n),n.deathZone&&n.deathZone.willKill(this)?(this.lifeCurrent=0,!0):(this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),n.scaleY?this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY):this.scaleY=this.scaleX,this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=s(this.angle),this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),this.tint=n.tint.onUpdate(this,"tint",r,this.tint),this.lifeCurrent-=t,this.lifeCurrent<=0)}});t.exports=o},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t,e,i,n,r){if("object"==typeof t){var o=t;t=s(o,"x",0),e=s(o,"y",0),i=s(o,"power",0),n=s(o,"epsilon",100),r=s(o,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=50);this.x=t,this.y=e,this.active=!0,this._gravity=r,this._power=0,this._epsilon=0,this.power=i,this.epsilon=n},update:function(t,e){var i=this.x-t.x,n=this.y-t.y,s=i*i+n*n;if(0!==s){var r=Math.sqrt(s);s>>16,m=(65280&p)>>>8,x=255&p,c.strokeStyle="rgba("+y+","+m+","+x+","+d+")",c.lineWidth=v,w+=3;break;case n.FILL_STYLE:g=l[w+1],f=l[w+2],y=(16711680&g)>>>16,m=(65280&g)>>>8,x=255&g,c.fillStyle="rgba("+y+","+m+","+x+","+f+")",w+=2;break;case n.BEGIN_PATH:c.beginPath();break;case n.CLOSE_PATH:c.closePath();break;case n.FILL_PATH:h||c.fill();break;case n.STROKE_PATH:h||c.stroke();break;case n.FILL_RECT:h?c.rect(l[w+1],l[w+2],l[w+3],l[w+4]):c.fillRect(l[w+1],l[w+2],l[w+3],l[w+4]),w+=4;break;case n.FILL_TRIANGLE:c.beginPath(),c.moveTo(l[w+1],l[w+2]),c.lineTo(l[w+3],l[w+4]),c.lineTo(l[w+5],l[w+6]),c.closePath(),h||c.fill(),w+=6;break;case n.STROKE_TRIANGLE:c.beginPath(),c.moveTo(l[w+1],l[w+2]),c.lineTo(l[w+3],l[w+4]),c.lineTo(l[w+5],l[w+6]),c.closePath(),h||c.stroke(),w+=6;break;case n.LINE_TO:c.lineTo(l[w+1],l[w+2]),w+=2;break;case n.MOVE_TO:c.moveTo(l[w+1],l[w+2]),w+=2;break;case n.LINE_FX_TO:c.lineTo(l[w+1],l[w+2]),w+=5;break;case n.MOVE_FX_TO:c.moveTo(l[w+1],l[w+2]),w+=5;break;case n.SAVE:c.save();break;case n.RESTORE:c.restore();break;case n.TRANSLATE:c.translate(l[w+1],l[w+2]),w+=2;break;case n.SCALE:c.scale(l[w+1],l[w+2]),w+=2;break;case n.ROTATE:c.rotate(l[w+1]),w+=1;break;case n.GRADIENT_FILL_STYLE:w+=5;break;case n.GRADIENT_LINE_STYLE:w+=6;break;case n.SET_TEXTURE:w+=2}c.restore()}}},function(t,e){t.exports=function(t){var e=t.width/2,i=t.height/2,n=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*n/(10+Math.sqrt(4-3*n)))}},function(t,e,i){var n=i(334),s=i(172),r=i(103),o=i(18);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;h0?s.delayedPlay(d,r,o):s.load(r)}return t}},function(t,e,i){var n=i(4),s=i(132),r=function(t,e,i){for(var n=[],s=0;sr;){if(o-r>600){var h=o-r+1,l=e-r+1,u=Math.log(h),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(h-c)/h)*(l-h/2<0?-1:1),f=Math.max(r,Math.floor(e-l*c/h+d)),p=Math.min(o,Math.floor(e+(h-l)*c/h+d));i(t,e,f,p,a)}var g=t[e],v=r,y=o;for(n(t,r,e),a(t[o],g)>0&&n(t,r,o);v0;)y--}0===a(t[r],g)?n(t,r,y):n(t,++y,o),y<=e&&(r=y+1),e<=y&&(o=y-1)}};function n(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function s(t,e){return te?1:0}t.exports=i},function(t,e){t.exports=function(t){return t>0?Math.ceil(t):Math.floor(t)}},function(t,e){t.exports=function(t){for(var e=t.length,i=t[0].length,n=new Array(i),s=0;s-1;r--)n[s][r]=t[r][s]}return n}},function(t,e,i){var n=i(948),s=i(0),r=i(102),o=i(11),a=i(947),h=i(945),l=i(944),u=new s({Extends:o,initialize:function(t){o.call(this),this.game=t,this.data=new r(this),this.on("setdata",this.setDataHandler,this),this.on("changedata",this.changeDataHandler,this),this.hasLoaded=!1,this.dataLocked=!1,this.supportedAPIs=[],this.entryPoint="",this.entryPointData=null,this.contextID=null,this.contextType=null,this.locale=null,this.platform=null,this.version=null,this.playerID=null,this.playerName=null,this.playerPhotoURL=null,this.playerCanSubscribeBot=!1,this.paymentsReady=!1,this.catalog=[],this.purchases=[],this.leaderboards={},this.ads=[]},setDataHandler:function(t,e,i){if(!this.dataLocked){var n={};n[e]=i;var s=this;FBInstant.player.setDataAsync(n).then(function(){s.emit("savedata",n)})}},changeDataHandler:function(t,e,i){if(!this.dataLocked){var n={};n[e]=i;var s=this;FBInstant.player.setDataAsync(n).then(function(){s.emit("savedata",n)})}},showLoadProgress:function(t){return t.load.on("progress",function(t){this.hasLoaded||FBInstant.setLoadingProgress(100*t)},this),t.load.on("complete",function(){this.hasLoaded||(this.hasLoaded=!0,FBInstant.startGameAsync().then(this.gameStarted.bind(this)))},this),this},gameStarted:function(){var t={},e=function(t){return t[1].toUpperCase()};FBInstant.getSupportedAPIs().forEach(function(i){i=i.replace(/\../g,e),t[i]=!0}),this.supportedAPIs=t,this.getID(),this.getType(),this.getLocale(),this.getPlatform(),this.getSDKVersion(),this.getPlayerID(),this.getPlayerName(),this.getPlayerPhotoURL();var i=this;FBInstant.onPause(function(){i.emit("pause")}),FBInstant.getEntryPointAsync().then(function(t){i.entryPoint=t,i.entryPointData=FBInstant.getEntryPointData(),i.emit("startgame")}).catch(function(t){console.warn(t)}),this.supportedAPIs.paymentsPurchaseAsync&&FBInstant.payments.onReady(function(){i.paymentsReady=!0}).catch(function(t){console.warn(t)})},checkAPI:function(t){return!!this.supportedAPIs[t]},getID:function(){return!this.contextID&&this.supportedAPIs.contextGetID&&(this.contextID=FBInstant.context.getID()),this.contextID},getType:function(){return!this.contextType&&this.supportedAPIs.contextGetType&&(this.contextType=FBInstant.context.getType()),this.contextType},getLocale:function(){return!this.locale&&this.supportedAPIs.getLocale&&(this.locale=FBInstant.getLocale()),this.locale},getPlatform:function(){return!this.platform&&this.supportedAPIs.getPlatform&&(this.platform=FBInstant.getPlatform()),this.platform},getSDKVersion:function(){return!this.version&&this.supportedAPIs.getSDKVersion&&(this.version=FBInstant.getSDKVersion()),this.version},getPlayerID:function(){return!this.playerID&&this.supportedAPIs.playerGetID&&(this.playerID=FBInstant.player.getID()),this.playerID},getPlayerName:function(){return!this.playerName&&this.supportedAPIs.playerGetName&&(this.playerName=FBInstant.player.getName()),this.playerName},getPlayerPhotoURL:function(){return!this.playerPhotoURL&&this.supportedAPIs.playerGetPhoto&&(this.playerPhotoURL=FBInstant.player.getPhoto()),this.playerPhotoURL},loadPlayerPhoto:function(t,e){return this.playerPhotoURL&&(t.load.setCORS("anonymous"),t.load.image(e,this.playerPhotoURL),t.load.once("filecomplete_image_"+e,function(){this.emit("photocomplete",e)},this),t.load.start()),this},canSubscribeBot:function(){if(this.supportedAPIs.playerCanSubscribeBotAsync){var t=this;FBInstant.player.canSubscribeBotAsync().then(function(){t.playerCanSubscribeBot=!0,t.emit("cansubscribebot")}).catch(function(e){t.emit("cansubscribebotfail",e)})}else this.emit("cansubscribebotfail");return this},subscribeBot:function(){if(this.playerCanSubscribeBot){var t=this;FBInstant.player.subscribeBotAsync().then(function(){t.emit("subscribebot")}).catch(function(e){t.emit("subscribebotfail",e)})}else this.emit("subscribebotfail");return this},getData:function(t){if(!this.checkAPI("playerGetDataAsync"))return this;Array.isArray(t)||(t=[t]);var e=this;return FBInstant.player.getDataAsync(t).then(function(t){for(var i in e.dataLocked=!0,t)e.data.set(i,t[i]);e.dataLocked=!1,e.emit("getdata",t)}),this},saveData:function(t){if(!this.checkAPI("playerSetDataAsync"))return this;var e=this;return FBInstant.player.setDataAsync(t).then(function(){e.emit("savedata",t)}).catch(function(t){e.emit("savedatafail",t)}),this},flushData:function(){if(!this.checkAPI("playerFlushDataAsync"))return this;var t=this;return FBInstant.player.flushDataAsync().then(function(){t.emit("flushdata")}).catch(function(e){t.emit("flushdatafail",e)}),this},getStats:function(t){if(!this.checkAPI("playerGetStatsAsync"))return this;var e=this;return FBInstant.player.getStatsAsync(t).then(function(t){e.emit("getstats",t)}).catch(function(t){e.emit("getstatsfail",t)}),this},saveStats:function(t){if(!this.checkAPI("playerSetStatsAsync"))return this;var e={};for(var i in t)"number"==typeof t[i]&&(e[i]=t[i]);var n=this;return FBInstant.player.setStatsAsync(e).then(function(){n.emit("savestats",e)}).catch(function(t){n.emit("savestatsfail",t)}),this},incStats:function(t){if(!this.checkAPI("playerIncrementStatsAsync"))return this;var e={};for(var i in t)"number"==typeof t[i]&&(e[i]=t[i]);var n=this;return FBInstant.player.incrementStatsAsync(e).then(function(t){n.emit("incstats",t)}).catch(function(t){n.emit("incstatsfail",t)}),this},saveSession:function(t){return this.checkAPI("setSessionData")?(JSON.stringify(t).length<=1e3?FBInstant.setSessionData(t):console.warn("Session data too long. Max 1000 chars."),this):this},openShare:function(t,e,i,n){return this._share("SHARE",t,e,i,n)},openInvite:function(t,e,i,n){return this._share("INVITE",t,e,i,n)},openRequest:function(t,e,i,n){return this._share("REQUEST",t,e,i,n)},openChallenge:function(t,e,i,n){return this._share("CHALLENGE",t,e,i,n)},_share:function(t,e,i,n,s){if(!this.checkAPI("shareAsync"))return this;if(void 0===s&&(s={}),i)var r=this.game.textures.getBase64(i,n);var o={intent:t,image:r,text:e,data:s},a=this;return FBInstant.shareAsync(o).then(function(){a.emit("resume")}),this},isSizeBetween:function(t,e){return this.checkAPI("contextIsSizeBetween")?FBInstant.context.isSizeBetween(t,e):this},switchContext:function(t){if(!this.checkAPI("contextSwitchAsync"))return this;if(t!==this.contextID){var e=this;FBInstant.context.switchAsync(t).then(function(){e.contextID=FBInstant.context.getID(),e.emit("switch",e.contextID)}).catch(function(t){e.emit("switchfail",t)})}return this},chooseContext:function(t){if(!this.checkAPI("contextChoseAsync"))return this;var e=this;return FBInstant.context.chooseAsync(t).then(function(){e.contextID=FBInstant.context.getID(),e.emit("choose",e.contextID)}).catch(function(t){e.emit("choosefail",t)}),this},createContext:function(t){if(!this.checkAPI("contextCreateAsync"))return this;var e=this;return FBInstant.context.createAsync(t).then(function(){e.contextID=FBInstant.context.getID(),e.emit("create",e.contextID)}).catch(function(t){e.emit("createfail",t)}),this},getPlayers:function(){if(!this.checkAPI("playerGetConnectedPlayersAsync"))return this;var t=this;return FBInstant.player.getConnectedPlayersAsync().then(function(e){t.emit("players",e)}).catch(function(e){t.emit("playersfail",e)}),this},getCatalog:function(){if(!this.paymentsReady)return this;var t=this,e=this.catalog;return FBInstant.payments.getCatalogAsync().then(function(i){e=[],i.forEach(function(t){e.push(h(t))}),t.emit("getcatalog",e)}).catch(function(e){t.emit("getcatalogfail",e)}),this},purchase:function(t,e){if(!this.paymentsReady)return this;var i={productID:t};e&&(i.developerPayload=e);var n=this;return FBInstant.payments.purchaseAsync(i).then(function(t){var e=l(t);n.emit("purchase",e)}).catch(function(t){n.emit("purchasefail",t)}),this},getPurchases:function(){if(!this.paymentsReady)return this;var t=this,e=this.purchases;return FBInstant.payments.getPurchasesAsync().then(function(i){e=[],i.forEach(function(t){e.push(l(t))}),t.emit("getpurchases",e)}).catch(function(e){t.emit("getpurchasesfail",e)}),this},consumePurchases:function(t){if(!this.paymentsReady)return this;var e=this;return FBInstant.payments.consumePurchaseAsync(t).then(function(){e.emit("consumepurchase",t)}).catch(function(t){e.emit("consumepurchasefail",t)}),this},update:function(t,e,i,n,s,r){return this._update("CUSTOM",t,e,i,n,s,r)},updateLeaderboard:function(t,e,i,n,s,r){return this._update("LEADERBOARD",t,e,i,n,s,r)},_update:function(t,e,i,n,s,r,o){if(!this.checkAPI("shareAsync"))return this;if(void 0===e&&(e=""),"string"==typeof i&&(i={default:i}),void 0===o&&(o={}),n)var a=this.game.textures.getBase64(n,s);var h={action:t,cta:e,image:a,text:i,template:r,data:o,strategy:"IMMEDIATE",notification:"NO_PUSH"},l=this;return FBInstant.updateAsync(h).then(function(){l.emit("update")}).catch(function(t){l.emit("updatefail",t)}),this},switchGame:function(t,e){if(!this.checkAPI("switchGameAsync"))return this;if(e&&JSON.stringify(e).length>1e3)return console.warn("Switch Game data too long. Max 1000 chars."),this;var i=this;return FBInstant.switchGameAsync(t,e).then(function(){i.emit("switchgame",t)}).catch(function(t){i.emit("switchgamefail",t)}),this},createShortcut:function(){var t=this;return FBInstant.canCreateShortcutAsync().then(function(e){e&&FBInstant.createShortcutAsync().then(function(){t.emit("shortcutcreated")}).catch(function(e){t.emit("shortcutfailed",e)})}),this},quit:function(){FBInstant.quit()},log:function(t,e,i){return this.checkAPI("logEvent")?(void 0===i&&(i={}),t.length>=2&&t.length<=40&&FBInstant.logEvent(t,parseFloat(e),i),this):this},preloadAds:function(t){if(!this.checkAPI("getInterstitialAdAsync"))return this;var e;Array.isArray(t)||(t=[t]);var i=this,s=0;for(e=0;e=3)return console.warn("Too many AdInstances. Show an ad before loading more"),this;for(e=0;e=3)return console.warn("Too many AdInstances. Show an ad before loading more"),this;for(e=0;e=r.x&&t=r.y&&e=r.x&&t=r.y&&e0)&&(!!n.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!n.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!n.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=n-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,s-n),s=this.audio.currentTime):s=n)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=s}},destroy:function(){n.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},updateMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},updateVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},calculateRate:function(){n.prototype.calculateRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)},mute:{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||this.emit("mute",this,t)}},setMute:function(t){return this.mute=t,this},volume:{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||this.emit("volume",this,t)}},setVolume:function(t){return this.volume=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||(this.calculateRate(),this.emit("rate",this,t))}},setRate:function(t){return this.rate=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||(this.calculateRate(),this.emit("detune",this,t))}},setDetune:function(t){return this.detune=t,this},seek:{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}},setSeek:function(t){return this.seek=t,this},loop:{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}},setLoop:function(t){return this.loop=t,this}});t.exports=s},function(t,e,i){var n=i(125),s=i(0),r=i(352),o=new s({Extends:n,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,n.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){this.locked=!1;var t=this;if(this.game.cache.audio.entries.each(function(e,i){for(var n=0;n-1&&(delete this.keys[n],this.scenes.splice(i,1),this._start.indexOf(n)>-1&&(i=this._start.indexOf(n),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e,i=t.sys,n=i.settings;t.init&&(t.init.call(t,n.data),n.status=s.INIT,n.isTransition&&i.events.emit("transitioninit",n.transitionFrom,n.transitionDuration)),i.load&&(e=i.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(n.status=s.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.game.sound.onBlurPausedSounds&&this.game.sound.unlock(),this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this.isProcessing=!0;for(var i=this.scenes.length-1;i>=0;i--){var n=this.scenes[i].sys;n.settings.status>s.START&&n.settings.status<=s.RUNNING&&n.step(t,e)}},resize:function(t,e){for(var i=0;i=s.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this.isProcessing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,n=this.getScene(t),s=this.getAt(i);this.scenes[e]=s,this.scenes[i]=n}}return this},moveUp:function(t){if(this.isProcessing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e=0;){var a=e[o];-1!==(r=t.indexOf(a))?(n(t,r),i&&i.call(s,a)):e.pop(),o--}return e}},function(t,e,i){var n=i(0),s=i(11),r=i(7),o=i(14),a=i(5),h=i(1),l=i(15),u=i(359),c=new n({Extends:s,initialize:function(t){s.call(this),this.game=t,this.plugins=[],this.scenePlugins=[],this._pendingGlobal=[],this._pendingScene=[],t.isBooted?this.boot():t.events.once("boot",this.boot,this)},boot:function(){var t,e,i,n,s,r,o,a=this.game.config,l=a.installGlobalPlugins;for(l=l.concat(this._pendingGlobal),t=0;t10&&(t=10-this.pointersTotal);for(var i=0;i0},queueTouchStart:function(t){if(this.queue.push(s.TOUCH_START,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueTouchMove:function(t){if(this.queue.push(s.TOUCH_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueTouchEnd:function(t){if(this.queue.push(s.TOUCH_END,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},queueTouchCancel:function(t){this.queue.push(s.TOUCH_CANCEL,t)},queueMouseDown:function(t){if(this.queue.push(s.MOUSE_DOWN,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueMouseMove:function(t){if(this.queue.push(s.MOUSE_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueMouseUp:function(t){if(this.queue.push(s.MOUSE_UP,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},addUpCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.upOnce.push(t):this.domCallbacks.up.push(t),this._hasUpCallback=!0,this},addDownCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.downOnce.push(t):this.domCallbacks.down.push(t),this._hasDownCallback=!0,this},addMoveCallback:function(t,e){return void 0===e&&(e=!1),e?this.domCallbacks.moveOnce.push(t):this.domCallbacks.move.push(t),this._hasMoveCallback=!0,this},inputCandidate:function(t,e){var i=t.input;if(!i||!i.enabled||!t.willRender(e))return!1;var n=!0,s=t.parentContainer;if(s)do{if(!s.willRender(e)){n=!1;break}s=s.parentContainer}while(s);return n},hitTest:function(t,e,i,n){void 0===n&&(n=this._tempHitTest);var s=this._tempPoint,r=i.scrollX,o=i.scrollY;n.length=0;var a=t.x,h=t.y;1!==i.resolution&&(a+=i._x,h+=i._y),i.getWorldPoint(a,h,s),t.worldX=s.x,t.worldY=s.y;for(var l={x:0,y:0},u=this._tempMatrix,d=this._tempMatrix2,f=0;f0&&n>0&&s.scissor(t,this.drawingBufferHeight-e-n,i,n))},popScissor:function(){var t=this.scissorStack;t.pop();var e=t[t.length-1];e&&this.setScissor(e[0],e[1],e[2],e[3]),this.currentScissor=e},setPipeline:function(t,e){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(e),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==r.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t,!0)},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setBlankTexture:function(t){void 0===t&&(t=!1),!t&&0===this.currentActiveTextureUnit&&this.currentTextures[0]||this.setTexture2D(this.blankTexture.glTexture,0)},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl,i=this.width,n=this.height;return t!==this.currentFramebuffer&&(t&&t.renderTexture?(i=t.renderTexture.width,n=t.renderTexture.height):this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),e.viewport(0,0,i,n),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,n){var s=this.gl,a=s.NEAREST,h=s.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,o(e,i)&&(h=s.REPEAT),n===r.ScaleModes.LINEAR&&this.config.antialias&&(a=s.LINEAR),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,a,h,h,s.RGBA,t):this.createTexture2D(0,a,a,h,h,s.RGBA,null,e,i)},createTexture2D:function(t,e,i,n,s,r,o,a,h,l){l=void 0===l||null===l||l;var u=this.gl,c=u.createTexture();return this.setTexture2D(c,0),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,e),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,i),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,s),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,n),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),null===o||void 0===o?u.texImage2D(u.TEXTURE_2D,t,r,a,h,0,r,u.UNSIGNED_BYTE,null):(u.texImage2D(u.TEXTURE_2D,t,r,r,u.UNSIGNED_BYTE,o),a=o.width,h=o.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=l,c.isRenderTexture=!1,c.width=a,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,n){var s,r=this.gl,o=r.createFramebuffer();if(this.setFramebuffer(o),n){var a=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,a),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(s=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[s])}return o.renderTexture=i,this.setFramebuffer(null),o},createProgram:function(t,e){var i=this.gl,n=i.createProgram(),s=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,t),i.shaderSource(r,e),i.compileShader(s),i.compileShader(r),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(s));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(n,s),i.attachShader(n,r),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(n));return n},createVertexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setVertexBuffer(n),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),n},createIndexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setIndexBuffer(n),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),n},deleteTexture:function(t){var e=this.nativeTextures.indexOf(t);return-1!==e&&a(this.nativeTextures,e),this.gl.deleteTexture(t),this.currentTextures[0]===t&&this.setBlankTexture(!0),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=t._cx,i=t._cy,n=t._cw,s=t._ch,r=this.pipelines.TextureTintPipeline,o=t.backgroundColor;if(t.renderToTexture){this.flush(),this.pushScissor(e,i,n,-s),this.setFramebuffer(t.framebuffer);var a=this.gl;a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT),r.projOrtho(e,n+e,i,s+i,-1e3,1e3),o.alphaGL>0&&r.drawFillRect(e,i,n+e,s+i,l.getTintFromFloats(o.redGL,o.greenGL,o.blueGL,1),o.alphaGL),t.emit("prerender",t)}else this.pushScissor(e,i,n,s),o.alphaGL>0&&r.drawFillRect(e,i,n,s,l.getTintFromFloats(o.redGL,o.greenGL,o.blueGL,1),o.alphaGL)},postRenderCamera:function(t){var e=this.pipelines.TextureTintPipeline;if(t.flashEffect.postRenderWebGL(e,l.getTintFromFloats),t.fadeEffect.postRenderWebGL(e,l.getTintFromFloats),t.dirty=!1,this.popScissor(),t.renderToTexture){e.flush(),this.setFramebuffer(null),t.emit("postrender",t),e.projOrtho(0,e.width,e.height,0,-1e3,1e3);var i=l.getTintAppendFloatAlpha;(t.pipeline?t.pipeline:e).batchTexture(t,t.glTexture,t.width,t.height,t.x,t.y,t.width,t.height,t.zoom,t.zoom,t.rotation,t.flipX,!t.flipY,1,1,0,0,0,0,t.width,t.height,i(t._tintTL,t._alphaTL),i(t._tintTR,t._alphaTR),i(t._tintBL,t._alphaBL),i(t._tintBR,t._alphaBR),t._isTinted&&t.tintFill,0,0,this.defaultCamera,null),this.setBlankTexture(!0)}},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var n in this.config.clearBeforeRender&&(t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT)),t.enable(t.SCISSOR_TEST),i)i[n].onPreRender();this.currentScissor=[0,0,this.width,this.height],this.scissorStack=[this.currentScissor],this.game.scene.customViewports&&t.scissor(0,this.drawingBufferHeight-this.height,this.width,this.height),this.setPipeline(this.pipelines.TextureTintPipeline)}},render:function(t,e,i,n){if(!this.contextLost){var s=e.list,o=s.length,a=this.pipelines;for(var h in a)a[h].onRender(t,n);this.preRenderCamera(n);for(var l=0;l=0?g=-(g+d):g<0&&(g=Math.abs(g)-d)),-1===m&&(v>=0?v=-(v+f):v<0&&(v=Math.abs(v)-f))}a.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),o.copyFrom(i.matrix),n?(o.multiplyWithOffset(n,-i.scrollX*t.scrollFactorX,-i.scrollY*t.scrollFactorY),a.e=t.x,a.f=t.y,o.multiply(a,h)):(a.e-=i.scrollX*t.scrollFactorX,a.f-=i.scrollY*t.scrollFactorY,o.multiply(a,h)),r.save(),h.setToContext(r),r.scale(y,m),r.globalCompositeOperation=this.blendModes[t.blendMode],r.globalAlpha=s,r.drawImage(e.source.image,u,c,d,f,g,v,d/p,f/p),r.restore()}},destroy:function(){this.gameCanvas=null,this.gameContext=null,this.game=null}});t.exports=u},function(t,e,i){var n,s,r,o=i(26),a={supportInverseAlpha:!1,supportNewBlendModes:!1};t.exports=(void 0!==document&&(a.supportNewBlendModes=(n="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",s="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",(r=new Image).onload=function(){var t=new Image;t.onload=function(){var e=o.create(t,6,1).getContext("2d");if(e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0),!e.getImageData(2,0,1,1))return!1;var i=e.getImageData(2,0,1,1).data;o.remove(t),a.supportNewBlendModes=255===i[0]&&0===i[1]&&0===i[2]},t.src=n+"/wCKxvRF"+s},r.src=n+"AP804Oa6"+s,!1),a.supportInverseAlpha=function(){var t=o.create(this,2,1).getContext("2d");t.fillStyle="rgba(10, 20, 30, 0.5)",t.fillRect(0,0,1,1);var e=t.getImageData(0,0,1,1);if(null===e)return!1;t.putImageData(e,1,0);var i=t.getImageData(1,0,1,1);return i.data[0]===e.data[0]&&i.data[1]===e.data[1]&&i.data[2]===e.data[2]&&i.data[3]===e.data[3]}()),a)},function(t,e,i){t.exports={os:i(101),browser:i(128),features:i(186),input:i(974),audio:i(973),video:i(972),fullscreen:i(971),canvasFeatures:i(375)}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(){this.isRunning=!1,this.callback=s,this.tick=0,this.isSetTimeOut=!1,this.timeOutID=null,this.lastTime=0;var t=this;this.step=function e(i){t.lastTime=t.tick,t.tick=i,t.timeOutID=window.requestAnimationFrame(e),t.callback(i)},this.stepTimeout=function e(){var i=Date.now(),n=Math.max(16+t.lastTime-i,0);t.lastTime=t.tick,t.tick=i,t.timeOutID=window.setTimeout(e,n),t.callback(i)}},start:function(t,e){this.isRunning||(this.callback=t,this.isSetTimeOut=e,this.isRunning=!0,this.timeOutID=e?window.setTimeout(this.stepTimeout,0):window.requestAnimationFrame(this.step))},stop:function(){this.isRunning=!1,this.isSetTimeOut?clearTimeout(this.timeOutID):window.cancelAnimationFrame(this.timeOutID)},destroy:function(){this.stop(),this.callback=s}});t.exports=r},function(t,e){t.exports=function(t){t.parentNode&&t.parentNode.removeChild(t)}},function(t,e){t.exports=function(t){var e="";try{window.DOMParser?e=(new DOMParser).parseFromString(t,"text/xml"):(e=new ActiveXObject("Microsoft.XMLDOM")).loadXML(t)}catch(t){e=null}return e&&e.documentElement&&!e.getElementsByTagName("parsererror").length?e:null}},function(t,e,i){var n=i(101);t.exports=function(t){if("complete"!==document.readyState&&"interactive"!==document.readyState){var e=function(){document.removeEventListener("deviceready",e,!0),document.removeEventListener("DOMContentLoaded",e,!0),window.removeEventListener("load",e,!0),t()};document.body?n.cordova&&!n.cocoonJS?document.addEventListener("deviceready",e,!1):(document.addEventListener("DOMContentLoaded",e,!0),window.addEventListener("load",e,!0)):window.setTimeout(e,20)}else t()}},function(t,e){t.exports=function(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}},function(t,e){t.exports=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},function(t,e,i){var n=i(41);n.ColorToRGBA=i(987),n.ComponentToHex=i(382),n.GetColor=i(195),n.GetColor32=i(412),n.HexStringToColor=i(413),n.HSLToColor=i(986),n.HSVColorWheel=i(985),n.HSVToRGB=i(194),n.HueToComponent=i(381),n.IntegerToColor=i(410),n.IntegerToRGB=i(409),n.Interpolate=i(984),n.ObjectToColor=i(408),n.RandomRGB=i(983),n.RGBStringToColor=i(407),n.RGBToHSV=i(411),n.RGBToString=i(982),n.ValueToColor=i(196),t.exports=n},function(t,e){t.exports={setCrisp:function(t){return["optimizeSpeed","crisp-edges","-moz-crisp-edges","-webkit-optimize-contrast","optimize-contrast","pixelated"].forEach(function(e){t.style["image-rendering"]=e}),t.style.msInterpolationMode="nearest-neighbor",t},setBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}}},function(t,e,i){var n=i(189),s=i(0),r=i(80),o=i(3),a=new s({Extends:r,initialize:function(t){void 0===t&&(t=[]),r.call(this,"SplineCurve"),this.points=[],this.addPoints(t)},addPoints:function(t){for(var e=0;ei.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(n(a,h.x,l.x,u.x,c.x),n(a,h.y,l.y,u.y,c.y))},toJSON:function(){for(var t=[],e=0;ei;)n-=i;n16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var n=i(41),s=i(409);t.exports=function(t){var e=s(t);return new n(e.r,e.g,e.b,e.a)}},function(t,e){t.exports=function(t,e,i,n){void 0===n&&(n={h:0,s:0,v:0}),t/=255,e/=255,i/=255;var s=Math.min(t,e,i),r=Math.max(t,e,i),o=r-s,a=0,h=0===r?0:o/r,l=r;return r!==s&&(r===t?a=(e-i)/o+(ef.right&&(p=u(p,p+(v-f.right),this.lerp.x)),yf.bottom&&(g=u(g,g+(y-f.bottom),this.lerp.y))):(p=u(p,v-l,this.lerp.x),g=u(g,y-c,this.lerp.y))}this.useBounds&&(p=this.clampX(p),g=this.clampY(g)),this.roundPixels&&(l=Math.round(l),c=Math.round(c)),this.scrollX=p,this.scrollY=g;var m=p+s,x=g+o;this.midPoint.set(m,x);var w=i/a,b=n/a;this.worldView.setTo(m-w/2,x-b/2,w,b),h.loadIdentity(),h.scale(e,e),h.translate(this.x+l,this.y+c),h.rotate(this.rotation),h.scale(a,a),h.translate(-l,-c),this.shakeEffect.preRender()},setLerp:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.lerp.set(t,e),this},setFollowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.followOffset.set(t,e),this},startFollow:function(t,e,i,n,s,r){void 0===e&&(e=!1),void 0===i&&(i=1),void 0===n&&(n=i),void 0===s&&(s=0),void 0===r&&(r=s),this._follow=t,this.roundPixels=e,i=o(i,0,1),n=o(n,0,1),this.lerp.set(i,n),this.followOffset.set(s,r);var a=this.width/2,h=this.height/2,l=t.x-s,u=t.y-r;return this.midPoint.set(l,u),this.scrollX=l-a,this.scrollY=u-h,this},stopFollow:function(){return this._follow=null,this},resetFX:function(){return this.panEffect.reset(),this.shakeEffect.reset(),this.flashEffect.reset(),this.fadeEffect.reset(),this},update:function(t,e){this.visible&&(this.panEffect.update(t,e),this.zoomEffect.update(t,e),this.shakeEffect.update(t,e),this.flashEffect.update(t,e),this.fadeEffect.update(t,e))},destroy:function(){this.clearRenderToTexture(),this.resetFX(),n.prototype.destroy.call(this),this._follow=null,this.deadzone=null}});t.exports=f},function(t,e,i){var n=i(416),s=new(i(0))({initialize:function(t){this.game=t,this.binary=new n,this.bitmapFont=new n,this.json=new n,this.physics=new n,this.shader=new n,this.audio=new n,this.text=new n,this.html=new n,this.obj=new n,this.tilemap=new n,this.xml=new n,this.custom={},this.game.events.once("destroy",this.destroy,this)},addCustom:function(t){return this.custom.hasOwnProperty(t)||(this.custom[t]=new n),this.custom[t]},destroy:function(){for(var t=["binary","bitmapFont","json","physics","shader","audio","text","html","obj","tilemap","xml"],e=0;ee.length&&(r=e.length),i?(n=e[r-1][i],(s=e[r][i])-t<=t-n?e[r]:e[r-1]):(n=e[r-1],(s=e[r])-t<=t-n?s:n)}},function(t,e,i){var n=i(24),s=i(0),r=i(419),o=i(418),a=i(4),h=new s({initialize:function(t,e,i){this.manager=t,this.key=e,this.type="frame",this.frames=this.getFrames(t.textureManager,a(i,"frames",[]),a(i,"defaultTextureKey",null)),this.frameRate=a(i,"frameRate",null),this.duration=a(i,"duration",null),null===this.duration&&null===this.frameRate?(this.frameRate=24,this.duration=this.frameRate/this.frames.length*1e3):this.duration&&null===this.frameRate?this.frameRate=this.frames.length/(this.duration/1e3):this.duration=this.frames.length/this.frameRate*1e3,this.msPerFrame=1e3/this.frameRate,this.skipMissedFrames=a(i,"skipMissedFrames",!0),this.delay=a(i,"delay",0),this.repeat=a(i,"repeat",0),this.repeatDelay=a(i,"repeatDelay",0),this.yoyo=a(i,"yoyo",!1),this.showOnStart=a(i,"showOnStart",!1),this.hideOnComplete=a(i,"hideOnComplete",!1),this.paused=!1,this.manager.on("pauseall",this.pause,this),this.manager.on("resumeall",this.resume,this)},addFrame:function(t){return this.addFrameAt(this.frames.length,t)},addFrameAt:function(t,e){var i=this.getFrames(this.manager.textureManager,e);if(i.length>0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var n=this.frames.slice(0,t),s=this.frames.slice(t);this.frames=n.concat(i,s)}this.updateFrameSequence()}return this},checkFrame:function(t){return t>=0&&t0){s.isLast=!0,s.nextFrame=l[0],l[0].prevFrame=s;var v=1/(l.length-1);for(r=0;r=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo);var i=this.frames[e];0!==e||t.forward||(i=this.getLastFrame()),t.updateFrame(i)},getFrameByProgress:function(t){return t=n(t,0,1),r(t,this.frames,"progress")},nextFrame:function(t){var e=t.currentFrame;e.isLast?t._yoyo?this.handleYoyoFrame(t,!1):t.repeatCounter>0?t._reverse&&t.forward?t.forward=!1:this.repeatAnimation(t):this.completeAnimation(t):this.updateAndGetNextTick(t,e.nextFrame)},handleYoyoFrame:function(t,e){if(e||(e=!1),t._reverse===!e&&t.repeatCounter>0)return t.forward=e,void this.repeatAnimation(t);if(t._reverse===e||0!==t.repeatCounter){t.forward=e;var i=e?t.currentFrame.nextFrame:t.currentFrame.prevFrame;this.updateAndGetNextTick(t,i)}else this.completeAnimation(t)},getLastFrame:function(){return this.frames[this.frames.length-1]},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t._yoyo?this.handleYoyoFrame(t,!0):t.repeatCounter>0?t._reverse&&!t.forward?(t.currentFrame=this.getLastFrame(),this.repeatAnimation(t)):(t.forward=!0,this.repeatAnimation(t)):this.completeAnimation(t):this.updateAndGetNextTick(t,e.prevFrame)},updateAndGetNextTick:function(t,e){t.updateFrame(e),this.getNextTick(t)},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){if(2===t._pendingStop)return this.completeAnimation(t);t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=t._repeatDelay):(t.repeatCounter--,t.updateFrame(t.currentFrame[t.forward?"nextFrame":"prevFrame"]),t.isPlaying&&(this.getNextTick(t),t.pendingRepeat=!1,t.parent.emit("animationrepeat",this,t.currentFrame,t.repeatCounter,t.parent)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(n.prevFrame=this.frames[i-1],n.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){this.manager.off("pauseall",this.pause,this),this.manager.off("resumeall",this.resume,this),this.manager.remove(this.key);for(var t=0;t-h&&(c-=h,n+=l),f=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},function(t,e){var i={_visible:!0,visible:{get:function(){return this._visible},set:function(t){t?(this._visible=!0,this.renderFlags|=1):(this._visible=!1,this.renderFlags&=-2)}},setVisible:function(t){return this.visible=t,this}};t.exports=i},function(t,e,i){var n=i(18),s=i(42),r=i(205),o=i(204),a={_scaleX:1,_scaleY:1,_rotation:0,x:0,y:0,z:0,w:0,scaleX:{get:function(){return this._scaleX},set:function(t){this._scaleX=t,0===this._scaleX?this.renderFlags&=-5:this.renderFlags|=4}},scaleY:{get:function(){return this._scaleY},set:function(t){this._scaleY=t,0===this._scaleY?this.renderFlags&=-5:this.renderFlags|=4}},angle:{get:function(){return o(this._rotation*n.RAD_TO_DEG)},set:function(t){this.rotation=o(t)*n.DEG_TO_RAD}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=r(t)}},setPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=i,this.w=n,this},setRandomPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),this.x=t+Math.random()*i,this.y=e+Math.random()*n,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,this},setScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this},setX:function(t){return void 0===t&&(t=0),this.x=t,this},setY:function(t){return void 0===t&&(t=0),this.y=t,this},setZ:function(t){return void 0===t&&(t=0),this.z=t,this},setW:function(t){return void 0===t&&(t=0),this.w=t,this},getLocalTransformMatrix:function(t){return void 0===t&&(t=new s),t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY)},getWorldTransformMatrix:function(t,e){void 0===t&&(t=new s),void 0===e&&(e=new s);var i=this.parentContainer;if(!i)return this.getLocalTransformMatrix(t);for(t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY);i;)e.applyITRS(i.x,i.y,i._rotation,i._scaleX,i._scaleY),e.multiply(t,t),i=i.parentContainer;return t}};t.exports=a},function(t,e){t.exports=function(t){var e={name:t.name,type:t.type,x:t.x,y:t.y,depth:t.depth,scale:{x:t.scaleX,y:t.scaleY},origin:{x:t.originX,y:t.originY},flipX:t.flipX,flipY:t.flipY,rotation:t.rotation,alpha:t.alpha,visible:t.visible,scaleMode:t.scaleMode,blendMode:t.blendMode,textureKey:"",frameKey:"",data:{}};return t.texture&&(e.textureKey=t.texture.key,e.frameKey=t.frame.name),e}},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.geometryMask=e},setShape:function(t){this.geometryMask=t},preRenderWebGL:function(t,e,i){var n=t.gl,s=this.geometryMask;t.flush(),n.enable(n.STENCIL_TEST),n.clear(n.STENCIL_BUFFER_BIT),n.colorMask(!1,!1,!1,!1),n.stencilFunc(n.NOTEQUAL,1,1),n.stencilOp(n.REPLACE,n.REPLACE,n.REPLACE),s.renderWebGL(t,s,0,i),t.flush(),n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.EQUAL,1,1),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)},postRenderWebGL:function(t){var e=t.gl;t.flush(),e.disable(e.STENCIL_TEST)},preRenderCanvas:function(t,e,i){var n=this.geometryMask;t.currentContext.save(),n.renderCanvas(t,n,0,i,null,null,!0),t.currentContext.clip()},postRenderCanvas:function(t){t.currentContext.restore()},destroy:function(){this.geometryMask=null}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){var i=t.sys.game.renderer;if(this.renderer=i,this.bitmapMask=e,this.maskTexture=null,this.mainTexture=null,this.dirty=!0,this.mainFramebuffer=null,this.maskFramebuffer=null,this.invertAlpha=!1,i&&i.gl){var n=i.width,s=i.height,r=0==(n&n-1)&&0==(s&s-1),o=i.gl,a=r?o.REPEAT:o.CLAMP_TO_EDGE,h=o.LINEAR;this.mainTexture=i.createTexture2D(0,h,h,a,a,o.RGBA,null,n,s),this.maskTexture=i.createTexture2D(0,h,h,a,a,o.RGBA,null,n,s),this.mainFramebuffer=i.createFramebuffer(n,s,this.mainTexture,!1),this.maskFramebuffer=i.createFramebuffer(n,s,this.maskTexture,!1),i.onContextRestored(function(t){var e=t.width,i=t.height,n=0==(e&e-1)&&0==(i&i-1),s=t.gl,r=n?s.REPEAT:s.CLAMP_TO_EDGE,o=s.LINEAR;this.mainTexture=t.createTexture2D(0,o,o,r,r,s.RGBA,null,e,i),this.maskTexture=t.createTexture2D(0,o,o,r,r,s.RGBA,null,e,i),this.mainFramebuffer=t.createFramebuffer(e,i,this.mainTexture,!1),this.maskFramebuffer=t.createFramebuffer(e,i,this.maskTexture,!1)},this)}},setBitmap:function(t){this.bitmapMask=t},preRenderWebGL:function(t,e,i){t.pipelines.BitmapMaskPipeline.beginMask(this,e,i)},postRenderWebGL:function(t){t.pipelines.BitmapMaskPipeline.endMask(this)},preRenderCanvas:function(){},postRenderCanvas:function(){},destroy:function(){this.bitmapMask=null;var t=this.renderer;t&&t.gl&&(t.deleteTexture(this.mainTexture),t.deleteTexture(this.maskTexture),t.deleteFramebuffer(this.mainFramebuffer),t.deleteFramebuffer(this.maskFramebuffer)),this.mainTexture=null,this.maskTexture=null,this.mainFramebuffer=null,this.maskFramebuffer=null,this.renderer=null}});t.exports=n},function(t,e,i){var n=i(430),s=i(429),r={mask:null,setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this},createBitmapMask:function(t){return void 0===t&&this.texture&&(t=this),new n(this.scene,t)},createGeometryMask:function(t){return void 0===t&&"Graphics"===this.type&&(t=this),new s(this.scene,t)}};t.exports=r},function(t,e){t.exports=function(t,e,i,n){var s=Math.cos(n),r=Math.sin(n),o=t.x-e,a=t.y-i;return t.x=o*s-a*r+e,t.y=o*r+a*s+i,t}},function(t,e,i){var n=i(6);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x1+(t.x2-t.x1)*e,i.y=t.y1+(t.y2-t.y1)*e,i}},function(t,e,i){var n=i(209),s=i(134);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=s(t)/i);for(var o=0;o=-1&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.once("remove",this.remove,this),this.isPlaying=!1,this.currentAnim=null,this.currentFrame=null,this._timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this._delay=0,this._repeat=0,this._repeatDelay=0,this._yoyo=!1,this.forward=!0,this._reverse=!1,this.accumulator=0,this.nextTick=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._pendingStop=0,this._pendingStopValue},setDelay:function(t){return void 0===t&&(t=0),this._delay=t,this.parent},getDelay:function(){return this._delay},delayedPlay:function(t,e,i){return this.play(e,!0,i),this.nextTick+=t,this.parent},getCurrentKey:function(){if(this.currentAnim)return this.currentAnim.key},load:function(t,e){return void 0===e&&(e=0),this.isPlaying&&this.stop(),this.animationManager.load(this,t,e),this.parent},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.updateFrame(t),this.parent},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.updateFrame(t),this.parent},isPaused:{get:function(){return this._paused}},play:function(t,e,i){return void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t?this.parent:(this.forward=!0,this._reverse=!1,this._startAnimation(t,i))},playReverse:function(t,e,i){return void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t?this.parent:(this.forward=!1,this._reverse=!0,this._startAnimation(t,i))},_startAnimation:function(t,e){this.load(t,e);var i=this.currentAnim,n=this.parent;return this.repeatCounter=-1===this._repeat?Number.MAX_VALUE:this._repeat,i.getFirstTick(this),this.isPlaying=!0,this.pendingRepeat=!1,i.showOnStart&&(n.visible=!0),n.emit("animationstart",this.currentAnim,this.currentFrame,n),n},reverse:function(t){return this.isPlaying&&this.currentAnim.key===t?(this._reverse=!this._reverse,this.forward=!this.forward,this.parent):this.parent},getProgress:function(){var t=this.currentFrame.progress;return this.forward||(t=1-t),t},setProgress:function(t){return this.forward||(t=1-t),this.setCurrentFrame(this.currentAnim.getFrameByProgress(t)),this.parent},remove:function(t,e){void 0===e&&(e=this.currentAnim),this.isPlaying&&e.key===this.currentAnim.key&&(this.stop(),this.setCurrentFrame(this.currentAnim.frames[0]))},getRepeat:function(){return this._repeat},setRepeat:function(t){return this._repeat=t,this.repeatCounter=0,this.parent},getRepeatDelay:function(){return this._repeatDelay},setRepeatDelay:function(t){return this._repeatDelay=t,this.parent},restart:function(t){void 0===t&&(t=!1),this.currentAnim.getFirstTick(this,t),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,this._paused=!1,this.updateFrame(this.currentAnim.frames[0]);var e=this.parent;return e.emit("animationrestart",this.currentAnim,this.currentFrame,e),this.parent},stop:function(){this._pendingStop=0,this.isPlaying=!1;var t=this.parent;return t.emit("animationcomplete",this.currentAnim,this.currentFrame,t),t},stopAfterDelay:function(t){return this._pendingStop=1,this._pendingStopValue=t,this.parent},stopOnRepeat:function(){return this._pendingStop=2,this.parent},stopOnFrame:function(t){return this._pendingStop=3,this._pendingStopValue=t,this.parent},setTimeScale:function(t){return void 0===t&&(t=1),this._timeScale=t,this.parent},getTimeScale:function(){return this._timeScale},getTotalFrames:function(){return this.currentAnim.frames.length},update:function(t,e){if(this.currentAnim&&this.isPlaying&&!this.currentAnim.paused){if(this.accumulator+=e*this._timeScale,1===this._pendingStop&&(this._pendingStopValue-=e,this._pendingStopValue<=0))return this.currentAnim.completeAnimation(this);this.accumulator>=this.nextTick&&this.currentAnim.setFrame(this)}},setCurrentFrame:function(t){var e=this.parent;return this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,e.isCropped&&e.frame.updateCropUVs(e._crop,e.flipX,e.flipY),e.setSizeToFrame(),t.frame.customPivot?e.setOrigin(t.frame.pivotX,t.frame.pivotY):e.updateDisplayOrigin(),e},updateFrame:function(t){var e=this.setCurrentFrame(t);if(this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;e.emit("animationupdate",i,t,e),3===this._pendingStop&&this._pendingStopValue===t&&this.currentAnim.completeAnimation(this)}},setYoyo:function(t){return void 0===t&&(t=!1),this._yoyo=t,this.parent},getYoyo:function(){return this._yoyo},destroy:function(){this.animationManager.off("remove",this.remove,this),this.animationManager=null,this.parent=null,this.currentAnim=null,this.currentFrame=null}});t.exports=n},function(t,e,i){var n=i(24),s={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,s){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=n(t,0,1),this._alphaTR=n(e,0,1),this._alphaBL=n(i,0,1),this._alphaBR=n(s,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=n(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=n(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=n(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=n(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=n(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=s},function(t,e){t.exports=function(t){return Math.PI*t.radius*2}},function(t,e,i){var n=i(439),s=i(211),r=i(103),o=i(18);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;h>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e0;i--){var n=Math.floor(this.frac()*(e+1)),s=t[n];t[n]=t[i],t[i]=s}return t}});t.exports=n},function(t,e,i){var n=i(211),s=i(103),r=i(18),o=i(6);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=s(e,0,r.PI2);return n(t,a,i)}},function(t,e,i){var n=i(48),s=i(46),r=i(47),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(50),s=i(46),r=i(49),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(85),s=i(46),r=i(84),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(82),s=i(48),r=i(83),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(82),s=i(50),r=i(83),o=i(49);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(84),s=i(83);t.exports=function(t,e,i){return n(t,e),s(t,i)}},function(t,e,i){var n=i(448),s=i(85),r=i(82);t.exports=function(t,e,i,o){return void 0===i&&(i=0),void 0===o&&(o=0),n(t,s(e)+i,r(e)+o),t}},function(t,e,i){var n=i(52),s=i(48),r=i(51),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(52),s=i(50),r=i(51),o=i(49);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(52),s=i(85),r=i(51),o=i(84);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(212),s=[];s[n.BOTTOM_CENTER]=i(452),s[n.BOTTOM_LEFT]=i(451),s[n.BOTTOM_RIGHT]=i(450),s[n.CENTER]=i(449),s[n.LEFT_CENTER]=i(447),s[n.RIGHT_CENTER]=i(446),s[n.TOP_CENTER]=i(445),s[n.TOP_LEFT]=i(444),s[n.TOP_RIGHT]=i(443);t.exports=function(t,e,i,n,r){return s[i](t,e,n,r)}},function(t,e,i){t.exports={Angle:i(1122),Call:i(1121),GetFirst:i(1120),GetLast:i(1119),GridAlign:i(1118),IncAlpha:i(1107),IncX:i(1106),IncXY:i(1105),IncY:i(1104),PlaceOnCircle:i(1103),PlaceOnEllipse:i(1102),PlaceOnLine:i(1101),PlaceOnRectangle:i(1100),PlaceOnTriangle:i(1099),PlayAnimation:i(1098),PropertyValueInc:i(37),PropertyValueSet:i(27),RandomCircle:i(1097),RandomEllipse:i(1096),RandomLine:i(1095),RandomRectangle:i(1094),RandomTriangle:i(1093),Rotate:i(1092),RotateAround:i(1091),RotateAroundDistance:i(1090),ScaleX:i(1089),ScaleXY:i(1088),ScaleY:i(1087),SetAlpha:i(1086),SetBlendMode:i(1085),SetDepth:i(1084),SetHitArea:i(1083),SetOrigin:i(1082),SetRotation:i(1081),SetScale:i(1080),SetScaleX:i(1079),SetScaleY:i(1078),SetTint:i(1077),SetVisible:i(1076),SetX:i(1075),SetXY:i(1074),SetY:i(1073),ShiftPosition:i(1072),Shuffle:i(1071),SmootherStep:i(1070),SmoothStep:i(1069),Spread:i(1068),ToggleVisible:i(1067),WrapInRectangle:i(1066)}},function(t,e){t.exports=function(t){return t.split("").reverse().join("")}},function(t,e){t.exports=function(t,e){return t.replace(/%([0-9]+)/g,function(t,i){return e[Number(i)-1]})}},function(t,e,i){t.exports={Format:i(456),Pad:i(197),Reverse:i(455),UppercaseFirst:i(356),UUID:i(323)}},function(t,e,i){var n=i(69);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)&&(i[s]=e[s]);return i}},function(t,e){t.exports=function(t,e){for(var i=0;i-1&&(e.state=a.REMOVED,s.splice(r,1)):(e.state=a.REMOVED,n.splice(r,1))}for(i.length=0,i=this._add,t=0;t-1&&this._active.splice(s,1),n.destroy()}for(i=0;i=n.delay)){var s=n.elapsed-n.delay;n.elapsed=n.delay,!n.hasDispatched&&n.callback&&(n.hasDispatched=!0,n.callback.apply(n.callbackScope,n.args)),n.repeatCount>0?(n.repeatCount--,n.elapsed=s,n.hasDispatched=!1):this._pendingRemoval.push(n)}}}},shutdown:function(){var t;for(t=0;t0&&(t.currentPipeline&&t.currentPipeline.vertexCount>0&&t.flush(),r.vertexBuffer=e.vertexBuffer[a],t.setPipeline(r),t.setTexture2D(s[a].glTexture,0),t.gl.drawArrays(r.topology,0,e.vertexCount[a]));r.vertexBuffer=o,r.viewIdentity(),r.modelIdentity()}},function(t,e,i){var n=i(2),s=i(2);n=i(472),s=i(471),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e,i,n,s){e.cull(n);var r=e.culledTiles,o=r.length;if(0!==o){var a=t._tempMatrix1,h=t._tempMatrix2,l=t._tempMatrix3;h.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),a.copyFrom(n.matrix);var u=t.currentContext,c=e.gidMap;u.save(),s?(a.multiplyWithOffset(s,-n.scrollX*e.scrollFactorX,-n.scrollY*e.scrollFactorY),h.e=e.x,h.f=e.y,a.multiply(h,l),l.copyToContext(u)):(h.e-=n.scrollX*e.scrollFactorX,h.f-=n.scrollY*e.scrollFactorY,h.copyToContext(u));for(var d=n.alpha*e.alpha,f=0;f-1?new s(a,f,c,u,o.tilesize,o.tilesize):e?null:new s(a,-1,c,u,o.tilesize,o.tilesize),h.push(d)}l.push(h),h=[]}a.data=l,i.push(a)}return i}},function(t,e,i){var n=i(21);t.exports=function(t){for(var e,i,s,r,o,a=0;a1){if(Array.isArray(l.tiles)){for(var c={},d={},f=0;f>>0;return n}},function(t,e,i){var n=i(485),s=i(1),r=i(87),o=i(227),a=i(61);t.exports=function(t,e){for(var i=[],h=0;h0){var y=new a(u,v.gid,c,f.length,t.tilewidth,t.tileheight);y.rotation=v.rotation,y.flipX=v.flipped,d.push(y)}else{var m=e?null:new a(u,-1,c,f.length,t.tilewidth,t.tileheight);d.push(m)}++c===l.width&&(f.push(d),c=0,d=[])}u.data=f,i.push(u)}}return i}},function(t,e,i){t.exports={Parse:i(230),Parse2DArray:i(142),ParseCSV:i(229),Impact:i(223),Tiled:i(228)}},function(t,e,i){var n=i(54),s=i(53),r=i(3);t.exports=function(t,e,i,o,a,h){return void 0===o&&(o=new r(0,0)),o.x=n(t,i,a,h),o.y=s(e,i,a,h),o}},function(t,e,i){var n=i(19);t.exports=function(t,e,i,s,r,o){if(void 0!==r){var a,h=n(t,e,i,s,null,o),l=0;for(a=0;a0&&n(a,t)}}e&&s(0,0,i.width,i.height,i)}},function(t,e,i){var n=i(62),s=i(38),r=i(77);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0);for(var a=0;ae)){for(var h=t;h<=e;h++)r(h,i,a);for(var l=0;l=t&&c.index<=e&&n(c,i)}o&&s(0,0,a.width,a.height,a)}}},function(t,e,i){var n=i(62),s=i(38),r=i(143);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a=0;r--)for(s=n.width-1;s>=0;s--)if((o=n.data[r][s])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;r=v;o--)(h=c[a][o])&&-1!==h.index&&h.visible&&0!==h.alpha&&i.push(h);else if(2===r)for(a=x;a>=m;a--)for(o=v;o=m;a--)for(o=y;o>=v;o--)(h=c[a][o])&&-1!==h.index&&h.visible&&0!==h.alpha&&i.push(h);return u.tilesDrawn=i.length,u.tilesTotal=d*f,i}},function(t,e,i){var n=i(109),s=i(108),r=i(19),o=i(233);t.exports=function(t,e,i,a,h,l){void 0===i&&(i={}),Array.isArray(t)||(t=[t]);var u=l.tilemapLayer;void 0===a&&(a=u.scene),void 0===h&&(h=a.cameras.main);var c,d=r(0,0,l.width,l.height,null,l),f=[];for(c=0;c=0&&p=0&&g=this._duration&&this.transitionComplete()},transitionComplete:function(){var t=this._target.sys,e=this._target.sys.settings;this.systems.events.off("update",this.step,this),t.events.emit("transitioncomplete",this.scene),e.isTransition=!1,e.transitionFrom=null,this._duration=0,this._target=null,this._onUpdate=null,this._onUpdateScope=null,this._willRemove?this.manager.remove(this.key):this._willSleep?this.systems.sleep():this.manager.stop(this.key)},add:function(t,e,i){return this.manager.add(t,e,i),this},launch:function(t,e){return t&&t!==this.key&&this.manager.queueOp("start",t,e),this},run:function(t,e){return t&&t!==this.key&&this.manager.queueOp("run",t,e),this},pause:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("pause",t,e),this},resume:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("resume",t,e),this},sleep:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("sleep",t,e),this},wake:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("wake",t,e),this},switch:function(t){return t!==this.key&&this.manager.queueOp("switch",this.key,t),this},stop:function(t){return void 0===t&&(t=this.key),this.manager.queueOp("stop",t),this},setActive:function(t,e,i){void 0===e&&(e=this.key);var n=this.manager.getScene(e);return n&&n.sys.setActive(t,i),this},setVisible:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setVisible(t),this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},getIndex:function(t){return void 0===t&&(t=this.key),this.manager.getIndex(t)},shutdown:function(){var t=this.systems.events;t.off("shutdown",this.shutdown,this),t.off("postupdate",this.step,this),t.off("transitionout")},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null,this.settings=null,this.manager=null}});o.register("ScenePlugin",a,"scenePlugin"),t.exports=a},function(t,e,i){var n=i(126),s=i(21),r={SceneManager:i(358),ScenePlugin:i(522),Settings:i(355),Systems:i(182)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={BitmapMaskPipeline:i(369),ForwardDiffuseLightPipeline:i(368),TextureTintPipeline:i(183)}},function(t,e,i){t.exports={Utils:i(9),WebGLPipeline:i(184),WebGLRenderer:i(371),Pipelines:i(524),BYTE:0,SHORT:1,UNSIGNED_BYTE:2,UNSIGNED_SHORT:3,FLOAT:4}},function(t,e,i){t.exports={Canvas:i(373),WebGL:i(370)}},function(t,e,i){t.exports={CanvasRenderer:i(374),GetBlendModes:i(372),SetTransform:i(23)}},function(t,e,i){t.exports={Canvas:i(527),Snapshot:i(526),WebGL:i(525)}},function(t,e,i){var n=i(234),s=new(i(0))({Extends:n,initialize:function(t,e){n.call(this,e),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this)},boot:function(){}});t.exports=s},function(t,e,i){t.exports={BasePlugin:i(234),DefaultPlugins:i(185),PluginCache:i(15),PluginManager:i(360),ScenePlugin:i(529)}},function(t,e,i){var n=i(148),s={name:"matter-wrap",version:"0.1.4",for:"matter-js@^0.13.1",silent:!0,install:function(t){t.after("Engine.update",function(){s.Engine.update(this)})},Engine:{update:function(t){for(var e=t.world,i=n.Composite.allBodies(e),r=n.Composite.allComposites(e),o=0;oe.max.x?i=e.min.x-t.max.x:t.max.xe.max.y?n=e.min.y-t.max.y:t.max.y0)for(var a=s+1;a1;if(!d||t!=d.x||e!=d.y){d&&n?(f=d.x,p=d.y):(f=0,p=0);var s={x:f+t,y:p+e};!n&&d||(d=s),g.push(s),y=f+t,m=p+e}},w=function(t){var e=t.pathSegTypeAsLetter.toUpperCase();if("Z"!==e){switch(e){case"M":case"L":case"T":case"C":case"S":case"Q":y=t.x,m=t.y;break;case"H":y=t.x;break;case"V":m=t.y}x(y,m,t.pathSegType)}};for(n._svgPathToAbsolute(t),o=t.getTotalLength(),l=[],i=0;i1?1:0;n0))r=t.collisionMap.trace(e.pos.x,e.pos.y,0,-(e.pos.y+e.size.y-i.pos.y),e.size.x,e.size.y),e.pos.y=r.pos.y,e.bounciness>0&&e.vel.y>e.minBounceVelocity?e.vel.y*=-e.bounciness:(e.standing=!0,e.vel.y=0);else{var l=(e.vel.y-i.vel.y)/2;e.vel.y=-l,i.vel.y=l,s=i.vel.x*t.delta,r=t.collisionMap.trace(e.pos.x,e.pos.y,s,-o/2,e.size.x,e.size.y),e.pos.y=r.pos.y;var u=t.collisionMap.trace(i.pos.x,i.pos.y,0,o/2,i.size.x,i.size.y);i.pos.y=u.pos.y}}},function(t,e){t.exports=function(t,e,i,n){var s=e.pos.x+e.size.x-i.pos.x;if(n){var r=e===n?i:e;n.vel.x=-n.vel.x*n.bounciness+r.vel.x;var o=t.collisionMap.trace(n.pos.x,n.pos.y,n===e?-s:s,0,n.size.x,n.size.y);n.pos.x=o.pos.x}else{var a=(e.vel.x-i.vel.x)/2;e.vel.x=-a,i.vel.x=a;var h=t.collisionMap.trace(e.pos.x,e.pos.y,-s/2,0,e.size.x,e.size.y);e.pos.x=Math.floor(h.pos.x);var l=t.collisionMap.trace(i.pos.x,i.pos.y,s/2,0,i.size.x,i.size.y);i.pos.x=Math.ceil(l.pos.x)}}},function(t,e,i){var n=i(91),s=i(554),r=i(553);t.exports=function(t,e,i){var o=null;e.collides===n.LITE||i.collides===n.FIXED?o=e:i.collides!==n.LITE&&e.collides!==n.FIXED||(o=i),e.last.x+e.size.x>i.last.x&&e.last.xi.last.y&&e.last.y0&&Math.abs(t.vel.y)>t.minBounceVelocity?t.vel.y*=-t.bounciness:(t.vel.y>0&&(t.standing=!0),t.vel.y=0)),e.collision.x&&(t.bounciness>0&&Math.abs(t.vel.x)>t.minBounceVelocity?t.vel.x*=-t.bounciness:t.vel.x=0),e.collision.slope){var i=e.collision.slope;if(t.bounciness>0){var n=t.vel.x*i.nx+t.vel.y*i.ny;t.vel.x=(t.vel.x-i.nx*n*2)*t.bounciness,t.vel.y=(t.vel.y-i.ny*n*2)*t.bounciness}else{var s=i.x*i.x+i.y*i.y,r=(t.vel.x*i.x+t.vel.y*i.y)/s;t.vel.x=i.x*r,t.vel.y=i.y*r;var o=Math.atan2(i.x,i.y);o>t.slopeStanding.min&&o0?e-o:e+o<0?e+o:0}return n(e,-r,r)}},function(t,e,i){t.exports={Body:i(252),COLLIDES:i(91),CollisionMap:i(251),Factory:i(250),Image:i(248),ImpactBody:i(249),ImpactPhysics:i(556),Sprite:i(247),TYPE:i(90),World:i(246)}},function(t,e,i){var n=i(257);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateY||e.customSeparateY)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.y,a=e.velocity.y;if(t.immovable||e.immovable)t.immovable?(e.y+=r,e.velocity.y=o-a*e.bounce.y,t.moves&&(e.x+=(t.x-t.prev.x)*t.friction.x)):(t.y-=r,t.velocity.y=a-o*t.bounce.y,e.moves&&(t.x+=(e.x-e.prev.x)*e.friction.x));else{r*=.5,t.y-=r,e.y+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.y=u+h*t.bounce.y,e.velocity.y=u+l*e.bounce.y}return!0}},function(t,e,i){var n=i(258);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.x,a=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=r,e.velocity.x=o-a*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=r,t.velocity.x=a-o*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{r*=.5,t.x-=r,e.x+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.x=u+h*t.bounce.x,e.velocity.x=u+l*e.bounce.x}return!0}},function(t,e){t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.up=!0):e>0&&(t.blocked.none=!1,t.blocked.down=!0),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},function(t,e,i){var n=i(575);t.exports=function(t,e,i,s,r){var o=0;return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom>i&&(o=t.bottom-i)>r&&(o=0),0!==o&&(t.customSeparateY?t.overlapY=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.left=!0):e>0&&(t.blocked.none=!1,t.blocked.right=!0),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},function(t,e,i){var n=i(577);t.exports=function(t,e,i,s,r){var o=0;return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right>i&&(o=t.right-i)>r&&(o=0),0!==o&&(t.customSeparateX?t.overlapX=o:n(t,o)),o}},function(t,e,i){var n=i(578),s=i(576),r=i(254);t.exports=function(t,e,i,o,a,h){var l=o.left,u=o.top,c=o.right,d=o.bottom,f=i.faceLeft||i.faceRight,p=i.faceTop||i.faceBottom;if(!f&&!p)return!1;var g=0,v=0,y=0,m=1;if(e.deltaAbsX()>e.deltaAbsY()?y=-1:e.deltaAbsX()=0;a--){var h=e[a],l=o(s,r,h.x,h.y);l=0;a--){var h=e[a],l=o(s,r,h.x,h.y);l>i&&(n=h,i=l)}return n},moveTo:function(t,e,i,n,s){void 0===n&&(n=60),void 0===s&&(s=0);var o=Math.atan2(i-t.y,e-t.x);return s>0&&(n=r(t.x,t.y,e,i)/(s/1e3)),t.body.velocity.setToPolar(o,n),o},moveToObject:function(t,e,i,n){return this.moveTo(t,e.x,e.y,i,n)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new c),i.setToPolar(s(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new c),i.setToPolar(t,e)},shutdown:function(){if(this.world){var t=this.systems.events;t.off("update",this.world.update,this.world),t.off("postupdate",this.world.postUpdate,this.world),t.off("shutdown",this.shutdown,this),this.add.destroy(),this.world.destroy(),this.add=null,this.world=null}},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null}});u.register("ArcadePhysics",f,"arcadePhysics"),t.exports=f},function(t,e,i){var n=i(39),s=i(21),r={ArcadePhysics:i(593),Body:i(260),Collider:i(259),Factory:i(266),Group:i(263),Image:i(265),Sprite:i(114),StaticBody:i(253),StaticGroup:i(262),World:i(261)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Arcade:i(594),Impact:i(572),Matter:i(552)}},function(t,e,i){var n=i(154),s=i(268),r=i(267),o=new s,a=new r,h=new n;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n){this.x=0,this.y=0,this.z=0,this.w=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)},clone:function(){return new n(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this.w=t.w||0,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},set:function(t,e,i,n){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this.w+=t.w||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this.w-=t.w||0,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},normalize:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(e*e+i*i+n*n+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return e*e+i*i+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,e){t.exports=function(t,e,i){return Math.abs(t-e)<=i}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),n*=Math.PI/t;for(var s=[],r=[],o=0;o1?void 0!==n?(s=(n-t)/(n-i))<0&&(s=0):s=1:s<0&&(s=0),s}},function(t,e){t.exports=function(t,e,i){return Math.max(t-e,i)}},function(t,e){t.exports=function(t,e,i){return Math.min(t+e,i)}},function(t,e){t.exports=function(t){return t===parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t){return t==parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t,e){return t/e/1e3}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.floor(t*n)/n}},function(t,e){t.exports=function(t,e){return Math.abs(t-e)}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.ceil(t*n)/n}},function(t,e){t.exports=function(t){for(var e=0,i=0;i0&&0==(t&t-1)}},function(t,e,i){t.exports={GetNext:i(322),IsSize:i(127),IsValue:i(616)}},function(t,e,i){var n=i(200);t.exports=function(t,e,i){return e+(i-e)*n(t,0,1)}},function(t,e,i){var n=i(129);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return e<0?n(t[0],t[1],s):e>1?n(t[i],t[i-1],i-s):n(t[r],t[r+1>i?i:r+1],s-r)}},function(t,e,i){var n=i(189);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return t[0]===t[i]?(e<0&&(r=Math.floor(s=i*(1+e))),n(s-r,t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i])):e<0?t[0]-(n(-s,t[0],t[0],t[1],t[1])-t[0]):e>1?t[i]-(n(s-i,t[i],t[i],t[i-1],t[i-1])-t[i]):n(s-r,t[r?r-1:0],t[r],t[i=n.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:e0},isLoading:function(){return this.state===s.LOADER_LOADING||this.state===s.LOADER_PROCESSING},isReady:function(){return this.state===s.LOADER_IDLE||this.state===s.LOADER_COMPLETE},start:function(){this.isReady()&&(this.progress=0,this.totalFailed=0,this.totalComplete=0,this.totalToLoad=this.list.size,this.emit("start",this),0===this.list.size?this.loadComplete():(this.state=s.LOADER_LOADING,this.inflight.clear(),this.queue.clear(),this.updateProgress(),this.checkLoadQueue(),this.systems.events.on("update",this.update,this)))},updateProgress:function(){this.progress=1-(this.list.size+this.inflight.size)/this.totalToLoad,this.emit("progress",this.progress)},update:function(){this.state===s.LOADER_LOADING&&this.list.size>0&&this.inflight.size'),i.push(''),i.push(''),i.push(this.xhrLoader.responseText),i.push(""),i.push(""),i.push("");var n=[i.join("\n")],o=this;try{var a=new window.Blob(n,{type:"image/svg+xml;charset=utf-8"})}catch(t){return o.state=s.FILE_ERRORED,void o.onProcessComplete()}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(o.data),o.onProcessComplete()},this.data.onerror=function(){r.revokeObjectURL(o.data),o.onProcessError()},r.createObjectURL(this.data,a,"image/svg+xml")},addToCache:function(){var t=this.cache.addImage(this.key,this.data);this.pendingDestroy(t)}});o.register("htmlTexture",function(t,e,i,n,s){if(Array.isArray(t))for(var r=0;r0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(s=!0,i=n(t,e))}else s=!0,i=n(t,e);return!s&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e,i){var n=i(0),s=i(11),r=i(4),o=i(116),a=i(284),h=i(159),l=i(283),u=i(669),c=i(668),d=i(667),f=i(158),p=new n({Extends:s,initialize:function(t){s.call(this),this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.enabled=!0,this.target,this.keys=[],this.combos=[],this.queue=[],this.onKeyHandler,this.time=0,t.pluginEvents.once("boot",this.boot,this),t.pluginEvents.on("start",this.start,this)},boot:function(){var t=this.settings.input,e=this.scene.sys.game.config;this.enabled=r(t,"keyboard",e.inputKeyboard),this.target=r(t,"keyboard.target",e.inputKeyboardEventTarget),this.sceneInputPlugin.pluginEvents.once("destroy",this.destroy,this)},start:function(){this.enabled&&this.startListeners(),this.sceneInputPlugin.pluginEvents.once("shutdown",this.shutdown,this)},isActive:function(){return this.enabled&&this.scene.sys.isActive()},startListeners:function(){var t=this,e=function(e){if(!e.defaultPrevented&&t.isActive()){t.queue.push(e);var i=t.keys[e.keyCode];i&&i.preventDefault&&e.preventDefault()}};this.onKeyHandler=e,this.target.addEventListener("keydown",e,!1),this.target.addEventListener("keyup",e,!1),this.sceneInputPlugin.pluginEvents.on("update",this.update,this)},stopListeners:function(){this.target.removeEventListener("keydown",this.onKeyHandler),this.target.removeEventListener("keyup",this.onKeyHandler),this.sceneInputPlugin.pluginEvents.off("update",this.update)},createCursorKeys:function(){return this.addKeys({up:h.UP,down:h.DOWN,left:h.LEFT,right:h.RIGHT,space:h.SPACE,shift:h.SHIFT})},addKeys:function(t){var e={};if("string"==typeof t){t=t.split(",");for(var i=0;i-1?e[i]=t:e[t.keyCode]=t,t}return"string"==typeof t&&(t=h[t.toUpperCase()]),e[t]||(e[t]=new a(t)),e[t]},removeKey:function(t){var e=this.keys;if(t instanceof a){var i=e.indexOf(t);i>-1&&(this.keys[i]=void 0)}else"string"==typeof t&&(t=h[t.toUpperCase()]);e[t]&&(e[t]=void 0)},createCombo:function(t,e){return new l(this,t,e)},checkDown:function(t,e){if(this.enabled&&t.isDown){var i=f(this.time-t.timeDown,e);if(i>t._tick)return t._tick=i,!0}return!1},update:function(t){this.time=t;var e=this.queue.length;if(this.enabled&&0!==e)for(var i=this.queue.splice(0,e),n=this.keys,s=0;s=e}}},function(t,e,i){var n=i(81),s=i(44),r=i(0),o=i(288),a=i(675),h=i(58),l=i(99),u=i(98),c=i(11),d=i(1),f=i(116),p=i(8),g=i(15),v=i(10),y=i(43),m=i(66),x=i(76),w=new r({Extends:c,initialize:function(t){c.call(this),this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.manager=t.sys.game.input,this.pluginEvents=new c,this.enabled=!0,this.displayList,this.cameras,f.install(this),this.mouse=this.manager.mouse,this.topOnly=!0,this.pollRate=-1,this._pollTimer=0;var e={cancelled:!1};this._eventContainer={stopPropagation:function(){e.cancelled=!0}},this._eventData=e,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this._temp=[],this._tempZones=[],this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],this._draggable=[],this._drag={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._over={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._validTypes=["onDown","onUp","onOver","onOut","onMove","onDragStart","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop"],t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.cameras=this.systems.cameras,this.displayList=this.systems.displayList,this.systems.events.once("destroy",this.destroy,this),this.pluginEvents.emit("boot")},start:function(){var t=this.systems.events;t.on("transitionstart",this.transitionIn,this),t.on("transitionout",this.transitionOut,this),t.on("transitioncomplete",this.transitionComplete,this),t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this),this.enabled=!0,this.pluginEvents.emit("start")},preUpdate:function(){this.pluginEvents.emit("preUpdate");var t=this._pendingRemoval,e=this._pendingInsertion,i=t.length,n=e.length;if(0!==i||0!==n){for(var s=this._list,r=0;r-1&&(s.splice(a,1),this.clear(o))}t.length=0,this._pendingRemoval.length=0,this._list=s.concat(e.splice(0))}},isActive:function(){return this.enabled&&this.scene.sys.isActive()},update:function(t,e){if(this.isActive()){this.pluginEvents.emit("update",t,e);var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var n=i.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(n=!0,this._pollTimer=this.pollRate)),n)for(var s=this.manager.pointers,r=0;r0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}}},clear:function(t){var e=t.input;if(e){this.queueForRemoval(t),e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,this.manager.resetCursor(e),t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t}},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,n){return void 0===n&&(n=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input&&n&&!t.input.dropZone&&(t.input.dropZone=n),this},hitTestPointer:function(t){for(var e=this.cameras.getCamerasBelowPointer(t),i=0;i0)return t.camera=n,s}return t.camera=e[0],[]},processDownEvents:function(t){var e=0,i=this._temp,n=this._eventData,s=this._eventContainer;n.cancelled=!1;for(var r=!1,o=0;o0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var a=[];for(i=0;i1&&(this.sortGameObjects(a),this.topOnly&&a.splice(1)),this._drag[t.id]=a,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&h(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(s=this._drag[t.id],i=0;i0?(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),l[0]?(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):r.target=null)}else!r.target&&l[0]&&(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target));var c=t.x-n.input.dragX,d=t.y-n.input.dragY;n.emit("drag",t,c,d),this.emit("drag",t,n,c,d)}return s.length}if(5===t.dragState){for(s=this._drag[t.id],i=0;i0){for(this.sortGameObjects(s),e=0;e0){for(this.sortGameObjects(r),e=0;e-1&&this._draggable.splice(s,1)}return this},makePixelPerfect:function(t){void 0===t&&(t=1);var e=this.systems.textures;return a(e,t)},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);var n=!1,s=!1,r=!1,a=!1;if(p(e)){var h=e;e=d(h,"hitArea",null),i=d(h,"hitAreaCallback",null),n=d(h,"draggable",!1),s=d(h,"dropZone",!1),r=d(h,"cursor",!1),a=d(h,"useHandCursor",!1);var l=d(h,"pixelPerfect",!1),u=d(h,"alphaTolerance",1);l&&(e={},i=this.makePixelPerfect(u)),e&&i||this.setHitAreaFromTexture(t)}else"function"!=typeof e||i||(i=e,e={});for(var c=0;c0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r)e.x&&t.ye.y}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e,i){var n=Math.min(t.x,e),s=Math.max(t.right,e);t.x=n,t.width=s-n;var r=Math.min(t.y,i),o=Math.max(t.bottom,i);return t.y=r,t.height=o-r,t}},function(t,e){t.exports=function(t,e){var i=Math.min(t.x,e.x),n=Math.max(t.right,e.right);t.x=i,t.width=n-i;var s=Math.min(t.y,e.y),r=Math.max(t.bottom,e.bottom);return t.y=s,t.height=r-s,t}},function(t,e){t.exports=function(t,e){for(var i=t.x,n=t.right,s=t.y,r=t.bottom,o=0;on(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},function(t,e,i){var n=i(161);t.exports=function(t,e){var i=n(t);return ii&&(i=h.x),h.xr&&(r=h.y),h.ye.right||t.righte.bottom||t.bottom0||(c=s(e),(d=n(t,c,!0)).length>0)}},function(t,e,i){var n=i(76),s=i(117);t.exports=function(t,e){return!!(n(t,e.getPointA())||n(t,e.getPointB())||s(t.getLineA(),e)||s(t.getLineB(),e)||s(t.getLineC(),e))}},function(t,e,i){var n=i(300),s=i(76);t.exports=function(t,e){return!(t.left>e.right||t.righte.bottom||t.bottomt.right+r||it.bottom+r||st.right||e.rightt.bottom||e.bottom0}},function(t,e,i){var n=i(299);t.exports=function(t,e){if(!n(t,e))return!1;var i=Math.min(e.x1,e.x2),s=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=s&&t.y>=r&&t.y<=o}},function(t,e){t.exports=function(t,e){var i=t.x1,n=t.y1,s=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,l=e.bottom,u=0;if(i>=o&&i<=h&&n>=a&&n<=l||s>=o&&s<=h&&r>=a&&r<=l)return!0;if(i=o){if((u=n+(r-n)*(o-i)/(s-i))>a&&u<=l)return!0}else if(i>h&&s<=h&&(u=n+(r-n)*(h-i)/(s-i))>=a&&u<=l)return!0;if(n=a){if((u=i+(s-i)*(a-n)/(r-n))>=o&&u<=h)return!0}else if(n>l&&r<=l&&(u=i+(s-i)*(l-n)/(r-n))>=o&&u<=h)return!0;return!1}},function(t,e,i){var n=i(10),s=i(164);t.exports=function(t,e,i){return void 0===i&&(i=new n),s(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},function(t,e){t.exports=function(t,e){var i=e.width/2,n=e.height/2,s=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-n),o=i+t.radius,a=n+t.radius;if(s>o||r>a)return!1;if(s<=i||r<=n)return!0;var h=s-i,l=r-n;return h*h+l*l<=t.radius*t.radius}},function(t,e,i){var n=i(58);t.exports=function(t,e){return n(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(10);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e,i){var n=i(98);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(98);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(99);t.exports=function(t){return new n(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},function(t,e,i){var n=i(99);n.Area=i(779),n.Circumference=i(334),n.CircumferencePoint=i(172),n.Clone=i(778),n.Contains=i(98),n.ContainsPoint=i(777),n.ContainsRect=i(776),n.CopyFrom=i(775),n.Equals=i(774),n.GetBounds=i(773),n.GetPoint=i(336),n.GetPoints=i(335),n.Offset=i(772),n.OffsetPoint=i(771),n.Random=i(203),t.exports=n},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(10);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},function(t,e,i){var n=i(44);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(44);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(81);t.exports=function(t){return new n(t.x,t.y,t.radius)}},function(t,e){t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},function(t,e,i){var n=i(81);n.Area=i(789),n.Circumference=i(439),n.CircumferencePoint=i(211),n.Clone=i(788),n.Contains=i(44),n.ContainsPoint=i(787),n.ContainsRect=i(786),n.CopyFrom=i(785),n.Equals=i(784),n.GetBounds=i(783),n.GetPoint=i(442),n.GetPoints=i(440),n.Offset=i(782),n.OffsetPoint=i(781),n.Random=i(210),t.exports=n},function(t,e,i){var n=i(0),s=i(303),r=i(15),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",o,"lights"),t.exports=o},function(t,e,i){var n=i(32),s=i(14),r=i(13),o=i(165);s.register("quad",function(t,e){void 0===t&&(t={});var i=r(t,"x",0),s=r(t,"y",0),a=r(t,"key",null),h=r(t,"frame",null),l=new o(this.scene,i,s,a,h);return void 0!==e&&(t.add=e),n(this.scene,l,t),l})},function(t,e,i){var n=i(32),s=i(14),r=i(13),o=i(4),a=i(118);s.register("mesh",function(t,e){void 0===t&&(t={});var i=r(t,"key",null),s=r(t,"frame",null),h=o(t,"vertices",[]),l=o(t,"colors",[]),u=o(t,"alphas",[]),c=o(t,"uv",[]),d=new a(this.scene,0,0,h,c,l,u,i,s);return void 0!==e&&(t.add=e),n(this.scene,d,t),d})},function(t,e,i){var n=i(165);i(5).register("quad",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(118);i(5).register("mesh",function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))})},function(t,e){t.exports=function(){}},function(t,e,i){var n=i(9);t.exports=function(t,e,i,s,r){var o=this.pipeline;t.setPipeline(o,e);var a=o._tempMatrix1,h=o._tempMatrix2,l=o._tempMatrix3;h.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),a.copyFrom(s.matrix),r?(a.multiplyWithOffset(r,-s.scrollX*e.scrollFactorX,-s.scrollY*e.scrollFactorY),h.e=e.x,h.f=e.y,a.multiply(h,l)):(h.e-=s.scrollX*e.scrollFactorX,h.f-=s.scrollY*e.scrollFactorY,a.multiply(h,l));var u=e.frame.glTexture,c=e.vertices,d=e.uv,f=e.colors,p=e.alphas,g=c.length,v=Math.floor(.5*g);o.vertexCount+v>=o.vertexCapacity&&o.flush(),o.setTexture2D(u,0);for(var y=o.vertexViewF32,m=o.vertexViewU32,x=o.vertexCount*o.vertexComponentCount-1,w=0,b=e.tintFill,T=0;T0)for(u=o.fillTint,c=n.getTintAppendFloatAlphaAndSwap(e.fillColor,e.fillAlpha*d),u.TL=c,u.TR=c,u.BL=c,u.BR=c,M=0;M0)for(u=o.fillTint,c=n.getTintAppendFloatAlphaAndSwap(e.altFillColor,e.altFillAlpha*d),u.TL=c,u.TR=c,u.BL=c,u.BR=c,M=0;M0){var F=o.strokeTint,L=n.getTintAppendFloatAlphaAndSwap(e.outlineFillColor,e.outlineFillAlpha*d);for(F.TL=L,F.TR=L,F.BL=L,F.BR=L,C=1;Cr;h--){for(l=0;l0&&r.maxLines1&&(d+=f*(i.length-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},function(t,e,i){var n=i(4);t.exports=function(t,e){var i=e.width,s=e.height,r=Math.floor(i/2),o=Math.floor(s/2),a=n(e,"chars","");if(""!==a){var h=n(e,"image",""),l=n(e,"offset.x",0),u=n(e,"offset.y",0),c=n(e,"spacing.x",0),d=n(e,"spacing.y",0),f=n(e,"lineSpacing",0),p=n(e,"charsPerRow",null);null===p&&(p=t.sys.textures.getFrame(h).width/i)>a.length&&(p=a.length);for(var g=l,v=u,y={retroFont:!0,font:h,size:i,lineHeight:s+f,chars:{}},m=0,x=0;x?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",TEXT_SET2:" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET3:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",TEXT_SET4:"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",TEXT_SET5:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",TEXT_SET6:"ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",TEXT_SET7:"AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",TEXT_SET8:"0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET9:"ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",TEXT_SET10:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET11:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789"}},function(t,e,i){var n=i(880),s=i(21),r={Parse:i(879)};r=s(!1,r,n),t.exports=r},function(t,e){t.exports=function(t,e,i,n,s){t.batchSprite(e,e.frame,n,s)}},function(t,e,i){var n=i(9);t.exports=function(t,e,i,s,r){var o=e.frame,a=o.width,h=o.height,l=n.getTintAppendFloatAlpha;this.pipeline.batchTexture(e,o.glTexture,a,h,e.x,e.y,a,h,e.scaleX,e.scaleY,e.rotation,e.flipX,!e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,a,h,l(e._tintTL,s.alpha*e._alphaTL),l(e._tintTR,s.alpha*e._alphaTR),l(e._tintBL,s.alpha*e._alphaBL),l(e._tintBR,s.alpha*e._alphaBR),e._isTinted&&e.tintFill,0,0,s,r),t.setBlankTexture(!0)}},function(t,e,i){var n=i(2),s=i(2);n=i(883),s=i(882),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){t.exports={DeathZone:i(329),EdgeZone:i(328),RandomZone:i(325)}},function(t,e){t.exports=function(t,e,i,n,s){var r=e.emitters.list,o=r.length;if(0!==o){var a=t._tempMatrix1.copyFrom(n.matrix),h=t._tempMatrix2,l=t._tempMatrix3,u=t._tempMatrix4.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY);a.multiply(u);var c=n.roundPixels,d=t.currentContext;d.save();for(var f=0;f0&&(X=X%T-T):X>T?X=T:X<0&&(X=T+X%T),null===C&&(C=new o(D+Math.cos(Y)*B,I+Math.sin(Y)*B,v),S.push(C),O+=.01);O<1+N;)b=X*O+Y,x=D+Math.cos(b)*B,w=I+Math.sin(b)*B,C.points.push(new r(x,w,v)),O+=.01;b=X+Y,x=D+Math.cos(b)*B,w=I+Math.sin(b)*B,C.points.push(new r(x,w,v));break;case n.FILL_RECT:u.setTexture2D(P),u.batchFillRect(p[++E],p[++E],p[++E],p[++E],f,c);break;case n.FILL_TRIANGLE:u.setTexture2D(P),u.batchFillTriangle(p[++E],p[++E],p[++E],p[++E],p[++E],p[++E],f,c);break;case n.STROKE_TRIANGLE:u.setTexture2D(P),u.batchStrokeTriangle(p[++E],p[++E],p[++E],p[++E],p[++E],p[++E],v,f,c);break;case n.LINE_TO:null!==C?C.points.push(new r(p[++E],p[++E],v)):(C=new o(p[++E],p[++E],v),S.push(C));break;case n.MOVE_TO:C=new o(p[++E],p[++E],v),S.push(C);break;case n.SAVE:a.push(f.copyToArray());break;case n.RESTORE:f.copyFromArray(a.pop());break;case n.TRANSLATE:D=p[++E],I=p[++E],f.translate(D,I);break;case n.SCALE:D=p[++E],I=p[++E],f.scale(D,I);break;case n.ROTATE:f.rotate(p[++E]);break;case n.SET_TEXTURE:var U=p[++E],V=p[++E];u.currentFrame=U,u.setTexture2D(U.glTexture,0),u.tintEffect=V,P=U.glTexture;break;case n.CLEAR_TEXTURE:u.currentFrame=t.blankTexture,u.tintEffect=2,P=t.blankTexture.glTexture}}}},function(t,e,i){var n=i(2),s=i(2);n=i(897),s=i(333),s=i(333),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(23);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length,h=t.currentContext;if(0!==a&&n(t,h,e,s,r)){var l=e.frame,u=e.displayCallback,c=s.scrollX*e.scrollFactorX,d=s.scrollY*e.scrollFactorY,f=e.fontData.chars,p=e.fontData.lineHeight,g=0,v=0,y=0,m=0,x=null,w=0,b=0,T=0,S=0,A=0,_=0,C=null,M=0,P=e.frame.source.image,E=l.cutX,k=l.cutY,F=0,L=e.fontSize/e.fontData.size;e.cropWidth>0&&e.cropHeight>0&&(h.save(),h.beginPath(),h.rect(0,0,e.cropWidth,e.cropHeight),h.clip());for(var R=0;R0&&e.cropHeight>0&&h.restore(),h.restore()}}},function(t,e,i){var n=i(9);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length;if(0!==a){var h=this.pipeline;t.setPipeline(h,e);var l=e.cropWidth>0||e.cropHeight>0;l&&(h.flush(),t.pushScissor(e.x,e.y,e.cropWidth*e.scaleX,e.cropHeight*e.scaleY));var u=h._tempMatrix1,c=h._tempMatrix2,d=h._tempMatrix3,f=h._tempMatrix4;c.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),u.copyFrom(s.matrix),r?(u.multiplyWithOffset(r,-s.scrollX*e.scrollFactorX,-s.scrollY*e.scrollFactorY),c.e=e.x,c.f=e.y,u.multiply(c,d)):(c.e-=s.scrollX*e.scrollFactorX,c.f-=s.scrollY*e.scrollFactorY,u.multiply(c,d));var p=e.frame,g=p.glTexture,v=p.cutX,y=p.cutY,m=g.width,x=g.height,w=e._isTinted&&e.tintFill,b=n.getTintAppendFloatAlpha(e._tintTL,s.alpha*e._alphaTL),T=n.getTintAppendFloatAlpha(e._tintTR,s.alpha*e._alphaTR),S=n.getTintAppendFloatAlpha(e._tintBL,s.alpha*e._alphaBL),A=n.getTintAppendFloatAlpha(e._tintBR,s.alpha*e._alphaBR);h.setTexture2D(g,0);var _,C,M=0,P=0,E=0,k=0,F=e.letterSpacing,L=0,R=0,O=0,D=0,I=e.scrollX,B=e.scrollY,Y=e.fontData,X=Y.chars,z=Y.lineHeight,N=e.fontSize/Y.size,U=0,V=e._align,G=0,W=0;e.getTextBounds(!1);var H=e._bounds.lines;1===V?W=(H.longest-H.lengths[0])/2:2===V&&(W=H.longest-H.lengths[0]);for(var j=s.roundPixels,q=e.displayCallback,K=e.callbackData,J=0;Jv&&(r=v),o>y&&(o=y);var k=v+g.xAdvance,F=y+u;a_&&(_=M),M_&&(_=M),M-1&&this._list.splice(s,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;i0&&(t.splice(i,1),t.unshift(e)),e}},function(t,e){t.exports=function(t,e,i){var n=t.indexOf(e),s=t.indexOf(i);return-1!==n&&-1===s&&(t[n]=i,!0)}},function(t,e,i){var n=i(100);t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return n(t,s)}},function(t,e,i){var n=i(68);t.exports=function(t,e,i,s,r){if(void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===r&&(r=t),n(t,e,i)){var o=i-e,a=t.splice(e,o);if(s)for(var h=0;ht.length-1)throw new Error("Index out of bounds");var r=n(t,e);return i&&i.call(s,r),r}},function(t,e,i){var n=i(342);t.exports=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=null),void 0===i&&(i=1),null===e&&(e=t,t=0);for(var s=[],r=Math.max(n((e-t)/(i||1)),0),o=0;o=t.length)throw new Error("Supplied index out of bounds");return n!==i&&(t.splice(n,1),t.splice(i,0,e)),e}},function(t,e){t.exports=function(t,e){var i=t.indexOf(e);if(i>0){var n=t[i-1],s=t.indexOf(n);t[i]=n,t[s]=e}return t}},function(t,e,i){var n=i(68);t.exports=function(t,e,i,s,r){if(void 0===s&&(s=0),void 0===r&&(r=t.length),n(t,s,r))for(var o=s;o0){var o=n-t.length;if(o<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.splice(i,0,e),s&&s.call(r,e),e):null;for(var a=e.length-1;a>=0;)-1!==t.indexOf(e[a])&&e.pop(),a--;if(0===(a=e.length))return null;n>0&&a>o&&(e.splice(o),a=o);for(var h=a-1;h>=0;h--){var l=e[h];t.splice(i,0,l),s&&s.call(r,l)}return e}},function(t,e){t.exports=function(t,e,i,n,s){if(void 0===s&&(s=t),i>0){var r=i-t.length;if(r<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.push(e),n&&n.call(s,e),e):null;for(var o=e.length-1;o>=0;)-1!==t.indexOf(e[o])&&e.pop(),o--;if(0===(o=e.length))return null;i>0&&o>r&&(e.splice(r),o=r);for(var a=0;a0||!this.inFocus)&&(this._coolDown--,r=Math.min(r,this._target)),r>this._min&&(r=n[i],r=Math.min(r,this._min)),n[i]=r,this.deltaIndex++,this.deltaIndex>s&&(this.deltaIndex=0);for(var o=0,a=0;athis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var h=o/this._target;this.callback(t,o,h),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=a},function(t,e){var i=0,n=function(t,e,n,s){var r=i-s.y-s.height;t.add(n,e,s.x,r,s.width,s.height)};t.exports=function(t,e,s){var r=t.source[e];t.add("__BASE",e,0,0,r.width,r.height),i=r.height;for(var o=s.split("\n"),a=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",l="",u={x:0,y:0,width:0,height:0},c=0;cx||a<-x)&&(a=0),a<0&&(a=x+a),-1!==h&&(x=a+(h+1));for(var C=l,M=l,P=0,E=e.sourceIndex,k=0;kg||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var v=f,y=f,m=0,x=0,w=0;wr&&(m=b-r),T>o&&(x=T-o),t.add(w,e,i+v,s+y,h-m,l-x),(v+=h+p)+h>r&&(v=f,y+=l+p)}return t}},function(t,e,i){var n=i(69);t.exports=function(t,e,i){if(i.frames){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);var r,o=i.frames;for(var a in o){var h=o[a];r=t.add(a,e,h.frame.x,h.frame.y,h.frame.w,h.frame.h),h.trimmed&&r.setTrim(h.sourceSize.w,h.sourceSize.h,h.spriteSourceSize.x,h.spriteSourceSize.y,h.spriteSourceSize.w,h.spriteSourceSize.h),h.rotated&&(r.rotated=!0,r.updateUVsInverted()),r.customData=n(h)}for(var l in i)"frames"!==l&&(Array.isArray(i[l])?t.customData[l]=i[l].slice(0):t.customData[l]=i[l]);return t}console.warn("Invalid Texture Atlas JSON Hash given, missing 'frames' Object")}},function(t,e,i){var n=i(69);t.exports=function(t,e,i){if(i.frames||i.textures){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);for(var r,o=Array.isArray(i.textures)?i.textures[e].frames:i.frames,a=0;a=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(s.dolby=!0)}}catch(t){}return s}()},function(t,e,i){var n=i(101),s=i(128),r={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),n.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){var n=i(0),s=i(28),r=i(376),o=i(1),a=i(4),h=i(8),l=i(18),u=i(2),c=i(185),d=i(196),f=new n({initialize:function(t){void 0===t&&(t={});this.width=a(t,"width",1024),this.height=a(t,"height",768),this.zoom=a(t,"zoom",1),this.resolution=a(t,"resolution",1),this.parent=a(t,"parent",null),this.scaleMode=a(t,"scaleMode",0),this.expandParent=a(t,"expandParent",!1),this.minWidth=a(t,"minWidth",0),this.maxWidth=a(t,"maxWidth",0),this.minHeight=a(t,"minHeight",0),this.maxHeight=a(t,"maxHeight",0);var e=a(t,"scale",null);e&&(this.width=a(e,"width",this.width),this.height=a(e,"height",this.height),this.zoom=a(e,"zoom",this.zoom),this.resolution=a(e,"resolution",this.resolution),this.parent=a(e,"parent",this.parent),this.scaleMode=a(e,"mode",this.scaleMode),this.expandParent=a(e,"mode",this.expandParent),this.minWidth=a(e,"min.width",this.minWidth),this.maxWidth=a(e,"max.width",this.maxWidth),this.minHeight=a(e,"min.height",this.minHeight),this.maxHeight=a(e,"max.height",this.maxHeight)),this.renderType=a(t,"type",s.AUTO),this.canvas=a(t,"canvas",null),this.context=a(t,"context",null),this.canvasStyle=a(t,"canvasStyle",null),this.sceneConfig=a(t,"scene",null),this.seed=a(t,"seed",[(Date.now()*Math.random()).toString()]),l.RND.init(this.seed),this.gameTitle=a(t,"title",""),this.gameURL=a(t,"url","https://phaser.io"),this.gameVersion=a(t,"version",""),this.autoFocus=a(t,"autoFocus",!0),this.domCreateContainer=a(t,"dom.createContainer",!1),this.domBehindCanvas=a(t,"dom.behindCanvas",!1),this.inputKeyboard=a(t,"input.keyboard",!0),this.inputKeyboardEventTarget=a(t,"input.keyboard.target",window),this.inputMouse=a(t,"input.mouse",!0),this.inputMouseEventTarget=a(t,"input.mouse.target",null),this.inputMouseCapture=a(t,"input.mouse.capture",!0),this.inputTouch=a(t,"input.touch",r.input.touch),this.inputTouchEventTarget=a(t,"input.touch.target",null),this.inputTouchCapture=a(t,"input.touch.capture",!0),this.inputActivePointers=a(t,"input.activePointers",1),this.inputGamepad=a(t,"input.gamepad",!1),this.inputGamepadEventTarget=a(t,"input.gamepad.target",window),this.disableContextMenu=a(t,"disableContextMenu",!1),this.audio=a(t,"audio"),this.hideBanner=!1===a(t,"banner",null),this.hidePhaser=a(t,"banner.hidePhaser",!1),this.bannerTextColor=a(t,"banner.text","#ffffff"),this.bannerBackgroundColor=a(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=a(t,"fps",null);var i=a(t,"render",t);this.autoResize=a(i,"autoResize",!0),this.antialias=a(i,"antialias",!0),this.roundPixels=a(i,"roundPixels",!1),this.pixelArt=a(i,"pixelArt",!1),this.pixelArt&&(this.antialias=!1,this.roundPixels=!0),this.transparent=a(i,"transparent",!1),this.clearBeforeRender=a(i,"clearBeforeRender",!0),this.premultipliedAlpha=a(i,"premultipliedAlpha",!0),this.preserveDrawingBuffer=a(i,"preserveDrawingBuffer",!1),this.failIfMajorPerformanceCaveat=a(i,"failIfMajorPerformanceCaveat",!1),this.powerPreference=a(i,"powerPreference","default"),this.batchSize=a(i,"batchSize",2e3),this.maxLights=a(i,"maxLights",10);var n=a(t,"backgroundColor",0);this.backgroundColor=d(n),0===n&&this.transparent&&(this.backgroundColor.alpha=0),this.preBoot=a(t,"callbacks.preBoot",u),this.postBoot=a(t,"callbacks.postBoot",u),this.physics=a(t,"physics",{}),this.defaultPhysicsSystem=a(this.physics,"default",!1),this.loaderBaseURL=a(t,"loader.baseURL",""),this.loaderPath=a(t,"loader.path",""),this.loaderMaxParallelDownloads=a(t,"loader.maxParallelDownloads",32),this.loaderCrossOrigin=a(t,"loader.crossOrigin",void 0),this.loaderResponseType=a(t,"loader.responseType",""),this.loaderAsync=a(t,"loader.async",!0),this.loaderUser=a(t,"loader.user",""),this.loaderPassword=a(t,"loader.password",""),this.loaderTimeout=a(t,"loader.timeout",0),this.installGlobalPlugins=[],this.installScenePlugins=[];var f=a(t,"plugins",null),p=c.DefaultScene;f&&(Array.isArray(f)?this.defaultPlugins=f:h(f)&&(this.installGlobalPlugins=o(f,"global",[]),this.installScenePlugins=o(f,"scene",[]),Array.isArray(f.default)?p=f.default:Array.isArray(f.defaultMerge)&&(p=p.concat(f.defaultMerge)))),this.defaultPlugins=p;var g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=a(t,"images.default",g+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=a(t,"images.missing",g+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=="),window&&(window.FORCE_WEBGL?this.renderType=s.WEBGL:window.FORCE_CANVAS&&(this.renderType=s.CANVAS))}});t.exports=f},function(t,e,i){var n=i(187),s=i(417),r=i(415),o=i(26),a=i(0),h=i(975),l=i(970),u=i(102),c=i(963),d=i(376),f=i(380),p=i(11),g=i(367),v=i(15),y=i(360),m=i(358),x=i(354),w=i(347),b=i(950),T=i(949),S=i(344),A=new a({initialize:function(t){this.config=new h(t),this.renderer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new p,this.anims=new s(this),this.textures=new w(this),this.cache=new r(this),this.registry=new u(this),this.input=new g(this,this.config),this.scene=new m(this,this.config.sceneConfig),this.device=d,this.sound=x.create(this),this.loop=new b(this,this.config.fps),this.plugins=new y(this,this.config),this.facebook=new S(this),this.pendingDestroy=!1,this.removeCanvas=!1,this.noReturn=!1,this.hasFocus=!1,this.isOver=!0,f(this.boot.bind(this))},boot:function(){v.hasCore("EventEmitter")?(this.isBooted=!0,this.config.preBoot(this),l(this),c(this),n(this.canvas,this.config.parent),this.events.emit("boot"),this.events.once("texturesready",this.texturesReady,this)):console.warn("Aborting. Core Plugins missing.")},texturesReady:function(){this.events.emit("ready"),this.start()},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),T(this);var t=this.events;t.on("hidden",this.onHidden,this),t.on("visible",this.onVisible,this),t.on("blur",this.onBlur,this),t.on("focus",this.onFocus,this)},step:function(t,e){if(this.pendingDestroy)return this.runDestroy();var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e);var n=this.renderer;n.preRender(),i.emit("prerender",n,t,e),this.scene.render(n),n.postRender(),i.emit("postrender",n,t,e)},headlessStep:function(t,e){var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e),i.emit("prerender"),i.emit("postrender")},onHidden:function(){this.loop.pause(),this.events.emit("pause")},onVisible:function(){this.loop.resume(),this.events.emit("resume")},onBlur:function(){this.hasFocus=!1,this.loop.blur()},onFocus:function(){this.hasFocus=!0,this.loop.focus()},resize:function(t,e){this.config.width=t,this.config.height=e,this.renderer.resize(t,e),this.input.resize(),this.scene.resize(t,e),this.events.emit("resize",t,e)},destroy:function(t,e){void 0===e&&(e=!1),this.pendingDestroy=!0,this.removeCanvas=t,this.noReturn=e},runDestroy:function(){this.events.emit("destroy"),this.events.removeAllListeners(),this.scene.destroy(),this.renderer&&this.renderer.destroy(),this.removeCanvas&&this.canvas&&(o.remove(this.canvas),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)),this.loop.destroy(),this.pendingDestroy=!1}});t.exports=A},function(t,e,i){var n=i(0),s=i(11),r=i(15),o=new n({Extends:s,initialize:function(){s.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",o,"events"),t.exports=o},function(t,e,i){t.exports={EventEmitter:i(977)}},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var h,l=[],u=!1,c=-1;function d(){u&&h&&(u=!1,h.length?l=h.concat(l):c=-1,l.length&&f())}function f(){if(!u){var t=a(d);u=!0;for(var e=l.length;e;){for(h=l,l=[];++c1)for(var i=1;i>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},function(t,e){t.exports=function(t,e){void 0===e&&(e="none");return["-webkit-","-khtml-","-moz-","-ms-",""].forEach(function(i){t.style[i+"user-select"]=e}),t.style["-webkit-touch-callout"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}},function(t,e){t.exports=function(t,e){return void 0===e&&(e="none"),t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}},function(t,e,i){t.exports={CanvasInterpolation:i(384),CanvasPool:i(26),Smoothing:i(130),TouchAction:i(989),UserSelect:i(988)}},function(t,e){t.exports=function(t){return t.height*t.originY}},function(t,e){t.exports=function(t){return t.width*t.originX}},function(t,e,i){t.exports={CenterOn:i(448),GetBottom:i(52),GetCenterX:i(85),GetCenterY:i(82),GetLeft:i(50),GetOffsetX:i(992),GetOffsetY:i(991),GetRight:i(48),GetTop:i(46),SetBottom:i(51),SetCenterX:i(84),SetCenterY:i(83),SetLeft:i(49),SetRight:i(47),SetTop:i(45)}},function(t,e,i){var n=i(48),s=i(46),r=i(51),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(50),s=i(46),r=i(51),o=i(49);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)-a),t}},function(t,e,i){var n=i(85),s=i(46),r=i(51),o=i(84);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(48),s=i(46),r=i(49),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(82),s=i(48),r=i(83),o=i(49);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(52),s=i(48),r=i(51),o=i(49);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(46),r=i(47),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(82),s=i(50),r=i(83),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(52),s=i(50),r=i(51),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(52),s=i(48),r=i(47),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){var n=i(52),s=i(50),r=i(49),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)+a),t}},function(t,e,i){var n=i(52),s=i(85),r=i(84),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){t.exports={BottomCenter:i(1005),BottomLeft:i(1004),BottomRight:i(1003),LeftBottom:i(1002),LeftCenter:i(1001),LeftTop:i(1e3),RightBottom:i(999),RightCenter:i(998),RightTop:i(997),TopCenter:i(996),TopLeft:i(995),TopRight:i(994)}},function(t,e,i){t.exports={BottomCenter:i(452),BottomLeft:i(451),BottomRight:i(450),Center:i(449),LeftCenter:i(447),QuickSet:i(453),RightCenter:i(446),TopCenter:i(445),TopLeft:i(444),TopRight:i(443)}},function(t,e,i){var n=i(212),s=i(21),r={In:i(1007),To:i(1006)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Align:i(1008),Bounds:i(993),Canvas:i(990),Color:i(383),Masks:i(981)}},function(t,e,i){var n=i(0),s=i(102),r=i(15),o=new n({Extends:s,initialize:function(t){s.call(this,t,t.sys.events),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.events=this.systems.events,this.events.once("destroy",this.destroy,this)},start:function(){this.events.once("shutdown",this.shutdown,this)},shutdown:function(){this.systems.events.off("shutdown",this.shutdown,this)},destroy:function(){s.prototype.destroy.call(this),this.events.off("start",this.start,this),this.scene=null,this.systems=null}});r.register("DataManagerPlugin",o,"data"),t.exports=o},function(t,e,i){t.exports={DataManager:i(102),DataManagerPlugin:i(1010)}},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(t,e){this.active=!1,this.p0=new s(t,e)},getPoint:function(t,e){return void 0===e&&(e=new s),e.copy(this.p0)},getPointAt:function(t,e){return this.getPoint(t,e)},getResolution:function(){return 1},getLength:function(){return 0},toJSON:function(){return{type:"MoveTo",points:[this.p0.x,this.p0.y]}}});t.exports=r},function(t,e,i){var n=i(0),s=i(391),r=i(389),o=i(5),a=i(388),h=i(1012),l=i(387),u=i(10),c=i(385),d=i(3),f=new n({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.name="",this.curves=[],this.cacheLengths=[],this.autoClose=!1,this.startPoint=new d,this._tmpVec2A=new d,this._tmpVec2B=new d,"object"==typeof t?this.fromJSON(t):this.startPoint.set(t,e)},add:function(t){return this.curves.push(t),this},circleTo:function(t,e,i){return void 0===e&&(e=!1),this.ellipseTo(t,t,0,360,e,i)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return t.equals(e)||this.curves.push(new a(e,t)),this},cubicBezierTo:function(t,e,i,n,r,o){var a,h,l,u=this.getEndPoint();return t instanceof d?(a=t,h=e,l=i):(a=new d(i,n),h=new d(r,o),l=new d(t,e)),this.add(new s(u,a,h,l))},quadraticBezierTo:function(t,e,i,n){var s,r,o=this.getEndPoint();return t instanceof d?(s=t,r=e):(s=new d(i,n),r=new d(t,e)),this.add(new l(o,s,r))},draw:function(t,e){for(var i=0;i0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),n=this.getCurveLengths(),s=0;s=i){var r=n[s]-i,o=this.curves[s],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}s++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],n=0;n1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e0&&(h.preRender(r,o),t.render(n,e,i,h))}},resetAll:function(){for(var t=0;t=1?1:1/e*(1+(e*t|0))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e,i){var n=i(24),s=i(0),r=i(3),o=i(192),a=new s({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.source=new r,this.current=new r,this.destination=new r,this.ease,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,n,s,r,a){void 0===i&&(i=1e3),void 0===n&&(n=o.Linear),void 0===s&&(s=!1),void 0===r&&(r=null),void 0===a&&(a=this.camera.scene);var h=this.camera;return!s&&this.isRunning?h:(this.isRunning=!0,this.duration=i,this.progress=0,this.source.set(h.scrollX,h.scrollY),this.destination.set(t,e),h.getScroll(t,e,this.current),"string"==typeof n&&o.hasOwnProperty(n)?this.ease=o[n]:"function"==typeof n&&(this.ease=n),this._elapsed=0,this._onUpdate=r,this._onUpdateScope=a,this.camera.emit("camerapanstart",this.camera,this,i,t,e),h)},update:function(t,e){if(this.isRunning){this._elapsed+=e;var i=n(this._elapsed/this.duration,0,1);this.progress=i;var s=this.camera;if(this._elapsed0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoom<.1&&(e.zoom=.1))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(4),r=new n({initialize:function(t){this.camera=s(t,"camera",null),this.left=s(t,"left",null),this.right=s(t,"right",null),this.up=s(t,"up",null),this.down=s(t,"down",null),this.zoomIn=s(t,"zoomIn",null),this.zoomOut=s(t,"zoomOut",null),this.zoomSpeed=s(t,"zoomSpeed",.01),this.speedX=0,this.speedY=0;var e=s(t,"speed",null);"number"==typeof e?(this.speedX=e,this.speedY=e):(this.speedX=s(t,"speed.x",0),this.speedY=s(t,"speed.y",0)),this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this.up&&this.up.isDown?e.scrollY-=this.speedY*t|0:this.down&&this.down.isDown&&(e.scrollY+=this.speedY*t|0),this.left&&this.left.isDown?e.scrollX-=this.speedX*t|0:this.right&&this.right.isDown&&(e.scrollX+=this.speedX*t|0),this.zoomIn&&this.zoomIn.isDown?(e.zoom-=this.zoomSpeed,e.zoom<.1&&(e.zoom=.1)):this.zoomOut&&this.zoomOut.isDown&&(e.zoom+=this.zoomSpeed)}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){t.exports={FixedKeyControl:i(1061),SmoothedKeyControl:i(1060)}},function(t,e,i){t.exports={Controls:i(1062),Scene2D:i(1059)}},function(t,e,i){t.exports={BaseCache:i(416),CacheManager:i(415)}},function(t,e,i){t.exports={Animation:i(420),AnimationFrame:i(418),AnimationManager:i(417)}},function(t,e,i){var n=i(59);t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=0;s1)if(0===s){var d=t.length-1;for(o=t[d].x,a=t[d].y,h=d-1;h>=0;h--)l=(c=t[h]).x,u=c.y,c.x=o,c.y=a,o=l,a=u;t[d].x=e,t[d].y=i}else{for(o=t[0].x,a=t[0].y,h=1;h0?s(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,_isTinted:!1,tintFill:!1,clearTint:function(){return this.setTint(16777215),this._isTinted=!1,this},setTint:function(t,e,n,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,n=t,s=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(n),this._tintBR=i(s),this._isTinted=!0,this.tintFill=!1,this},setTintFill:function(t,e,i,n){return this.setTint(t,e,i,n),this.tintFill=!0,this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t),this._isTinted=!0}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t),this._isTinted=!0}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t),this._isTinted=!0}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t),this._isTinted=!0}},tint:{set:function(t){this.setTint(t,t,t,t)}},isTinted:{get:function(){return this._isTinted}}};t.exports=n},function(t,e){var i={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,n){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,n,this.flipX,this.flipY);else{var s=t;this.frame.setCropUVs(this._crop,s.x,s.y,s.width,s.height,this.flipX,this.flipY)}this.isCropped=!0}return this},setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this.isCropped&&this.frame.updateCropUVs(this._crop,this.flipX,this.flipY),this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=i},function(t,e){var i={texture:null,frame:null,isCropped:!1,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e,i){var n=i(104),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e,i){var n=i(10),s=i(432),r=i(3),o={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getTopRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBounds:function(t){var e,i,s,r,o,a,h,l;if(void 0===t&&(t=new n),this.parentContainer){var u=this.parentContainer.getBoundsTransformMatrix();this.getTopLeft(t),u.transformPoint(t.x,t.y,t),e=t.x,i=t.y,this.getTopRight(t),u.transformPoint(t.x,t.y,t),s=t.x,r=t.y,this.getBottomLeft(t),u.transformPoint(t.x,t.y,t),o=t.x,a=t.y,this.getBottomRight(t),u.transformPoint(t.x,t.y,t),h=t.x,l=t.y}else this.getTopLeft(t),e=t.x,i=t.y,this.getTopRight(t),s=t.x,r=t.y,this.getBottomLeft(t),o=t.x,a=t.y,this.getBottomRight(t),h=t.x,l=t.y;return t.x=Math.min(e,s,o,h),t.y=Math.min(i,r,a,l),t.width=Math.max(e,s,o,h)-t.x,t.height=Math.max(i,r,a,l)-t.y,t}};t.exports=o},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e){var i={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,n){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,n,this.flipX,this.flipY);else{var s=t;this.frame.setCropUVs(this._crop,s.x,s.y,s.width,s.height,this.flipX,this.flipY)}this.isCropped=!0}return this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=i},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}}},function(t,e,i){var n=i(453),s=i(212),r=i(1),o=i(2),a=new(i(135))({sys:{queueDepthSort:o,events:{once:o}}},0,0,1,1);t.exports=function(t,e){void 0===e&&(e={});var i=r(e,"width",-1),o=r(e,"height",-1),h=r(e,"cellWidth",1),l=r(e,"cellHeight",h),u=r(e,"position",s.TOP_LEFT),c=r(e,"x",0),d=r(e,"y",0),f=0,p=0,g=i*h,v=o*l;a.setPosition(c,d),a.setSize(h,l);for(var y=0;y>>0;if("function"!=typeof t)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,s=0;s + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A NOOP (No Operation) callback function. + * + * Used internally by Phaser when it's more expensive to determine if a callback exists + * than it is to just invoke an empty function. + * + * @function Phaser.Utils.NOOP + * @since 3.0.0 + */ +var NOOP = function () +{ + // NOOP +}; + +module.exports = NOOP; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -330,7 +357,7 @@ module.exports = Class; /** * Finds the key within the top level of the {@link source} object, or returns {@link defaultValue} * - * @function Phaser.Utils.Object.GetFastValue + * @function Phaser.Utils.Objects.GetFastValue * @since 3.0.0 * * @param {object} source - The object to search @@ -360,762 +387,8 @@ var GetFastValue = function (source, key, defaultValue) module.exports = GetFastValue; -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var DataManager = __webpack_require__(81); -var EventEmitter = __webpack_require__(9); - -/** - * @classdesc - * The base class that all Game Objects extend. - * You don't create GameObjects directly and they cannot be added to the display list. - * Instead, use them as the base for your own custom classes. - * - * @class GameObject - * @memberOf Phaser.GameObjects - * @extends Phaser.Events.EventEmitter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. - * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`. - */ -var GameObject = new Class({ - - Extends: EventEmitter, - - initialize: - - function GameObject (scene, type) - { - EventEmitter.call(this); - - /** - * The Scene to which this Game Object belongs. - * Game Objects can only belong to one Scene. - * - * @name Phaser.GameObjects.GameObject#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A textual representation of this Game Object, i.e. `sprite`. - * Used internally by Phaser but is available for your own custom classes to populate. - * - * @name Phaser.GameObjects.GameObject#type - * @type {string} - * @since 3.0.0 - */ - this.type = type; - - /** - * The parent Container of this Game Object, if it has one. - * - * @name Phaser.GameObjects.GameObject#parentContainer - * @type {Phaser.GameObjects.Container} - * @since 3.4.0 - */ - this.parentContainer = null; - - /** - * The name of this Game Object. - * Empty by default and never populated by Phaser, this is left for developers to use. - * - * @name Phaser.GameObjects.GameObject#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The active state of this Game Object. - * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. - * An active object is one which is having its logic and internal systems updated. - * - * @name Phaser.GameObjects.GameObject#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * The Tab Index of the Game Object. - * Reserved for future use by plugins and the Input Manager. - * - * @name Phaser.GameObjects.GameObject#tabIndex - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.tabIndex = -1; - - /** - * A Data Manager. - * It allows you to store, query and get key/value paired information specific to this Game Object. - * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. - * - * @name Phaser.GameObjects.GameObject#data - * @type {Phaser.Data.DataManager} - * @default null - * @since 3.0.0 - */ - this.data = null; - - /** - * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. - * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. - * If those components are not used by your custom class then you can use this bitmask as you wish. - * - * @name Phaser.GameObjects.GameObject#renderFlags - * @type {integer} - * @default 15 - * @since 3.0.0 - */ - this.renderFlags = 15; - - /** - * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly. Instead call `Camera.ignore`. - * - * @name Phaser.GameObjects.GameObject#cameraFilter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cameraFilter = 0; - - /** - * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. - * Not usually set directly. Instead call `GameObject.setInteractive()`. - * - * @name Phaser.GameObjects.GameObject#input - * @type {?Phaser.Input.InteractiveObject} - * @default null - * @since 3.0.0 - */ - this.input = null; - - /** - * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. - * - * @name Phaser.GameObjects.GameObject#body - * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} - * @default null - * @since 3.0.0 - */ - 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 - scene.sys.queueDepthSort(); - - scene.sys.events.once('shutdown', this.destroy, this); - }, - - /** - * Sets the `active` property of this Game Object and returns this Game Object for further chaining. - * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. - * - * @method Phaser.GameObjects.GameObject#setActive - * @since 3.0.0 - * - * @param {boolean} value - True if this Game Object should be set as active, false if not. - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setActive: function (value) - { - this.active = value; - - return this; - }, - - /** - * Sets the `name` property of this Game Object and returns this Game Object for further chaining. - * The `name` property is not populated by Phaser and is presented for your own use. - * - * @method Phaser.GameObjects.GameObject#setName - * @since 3.0.0 - * - * @param {string} value - The name to be given to this Game Object. - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setName: function (value) - { - this.name = value; - - return this; - }, - - /** - * Adds a Data Manager component to this Game Object. - * - * @method Phaser.GameObjects.GameObject#setDataEnabled - * @since 3.0.0 - * @see Phaser.Data.DataManager - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setDataEnabled: function () - { - if (!this.data) - { - this.data = new DataManager(this); - } - - return this; - }, - - /** - * Allows you to store a key value pair within this Game Objects Data Manager. - * - * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled - * before setting the value. - * - * If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * sprite.setData('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `getData`: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or you can access the value directly via the `values` property, where it works like any other variable: - * - * ```javascript - * sprite.data.values.gold += 50; - * ``` - * - * When the value is first set, a `setdata` event is emitted from this Game Object. - * - * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. - * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. - * - * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * - * @method Phaser.GameObjects.GameObject#setData - * @since 3.0.0 - * - * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. - * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. - * - * @return {this} This GameObject. - */ - setData: function (key, value) - { - if (!this.data) - { - this.data = new DataManager(this); - } - - this.data.set(key, value); - - return this; - }, - - /** - * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. - * - * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * - * ```javascript - * sprite.getData('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * sprite.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: - * - * ```javascript - * sprite.getData([ 'gold', 'armor', 'health' ]); - * ``` - * - * This approach is useful for destructuring arrays in ES6. - * - * @method Phaser.GameObjects.GameObject#getData - * @since 3.0.0 - * - * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. - * - * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. - */ - getData: function (key) - { - if (!this.data) - { - this.data = new DataManager(this); - } - - return this.data.get(key); - }, - - /** - * Pass this Game Object to the Input Manager to enable it for Input. - * - * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area - * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced - * input detection. - * - * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If - * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific - * shape for it to use. - * - * You can also provide an Input Configuration Object as the only argument to this method. - * - * @method Phaser.GameObjects.GameObject#setInteractive - * @since 3.0.0 - * - * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. - * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. - * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - setInteractive: function (shape, callback, dropZone) - { - this.scene.sys.input.enable(this, shape, callback, dropZone); - - return this; - }, - - /** - * If this Game Object has previously been enabled for input, this will disable it. - * - * An object that is disabled for input stops processing or being considered for - * input events, but can be turned back on again at any time by simply calling - * `setInteractive()` with no arguments provided. - * - * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. - * - * @method Phaser.GameObjects.GameObject#disableInteractive - * @since 3.7.0 - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - disableInteractive: function () - { - if (this.input) - { - this.input.enabled = (this.input.enabled) ? false : true; - } - - return this; - }, - - /** - * If this Game Object has previously been enabled for input, this will remove it. - * - * The Interactive Object that was assigned to this Game Object will be destroyed, - * removed from the Input Manager and cleared from this Game Object. - * - * If you wish to re-enable this Game Object at a later date you will need to - * re-create its InteractiveOobject by calling `setInteractive` again. - * - * If you wish to only temporarily stop an object from receiving input then use - * `disableInteractive` instead, as that toggles the interactive state, where-as - * this erases it completely. - * - * @method Phaser.GameObjects.GameObject#removeInteractive - * @since 3.7.0 - * - * @return {Phaser.GameObjects.GameObject} This GameObject. - */ - removeInteractive: function () - { - this.scene.sys.input.clear(this); - - this.input = undefined; - - return this; - }, - - /** - * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. - * - * @method Phaser.GameObjects.GameObject#update - * @since 3.0.0 - */ - update: function () - { - }, - - /** - * Returns a JSON representation of the Game Object. - * - * @method Phaser.GameObjects.GameObject#toJSON - * @since 3.0.0 - * - * @return {JSONGameObject} A JSON representation of the Game Object. - */ - toJSON: function () - { - return Components.ToJSON(this); - }, - - /** - * Compares the renderMask with the renderFlags to see if this Game Object will render or not. - * - * @method Phaser.GameObjects.GameObject#willRender - * @since 3.0.0 - * - * @return {boolean} True if the Game Object should be rendered, otherwise false. - */ - willRender: function () - { - return (GameObject.RENDER_MASK === this.renderFlags); - }, - - /** - * Returns an array containing the display list index of either this Game Object, or if it has one, - * its parent Container. It then iterates up through all of the parent containers until it hits the - * root of the display list (which is index 0 in the returned array). - * - * Used internally by the InputPlugin but also useful if you wish to find out the display depth of - * this Game Object and all of its ancestors. - * - * @method Phaser.GameObjects.GameObject#getIndexList - * @since 3.4.0 - * - * @return {integer[]} An array of display list position indexes. - */ - getIndexList: function () - { - // eslint-disable-next-line consistent-this - var child = this; - var parent = this.parentContainer; - - var indexes = []; - - while (parent) - { - // indexes.unshift([parent.getIndex(child), parent.name]); - indexes.unshift(parent.getIndex(child)); - - child = parent; - - if (!parent.parentContainer) - { - break; - } - else - { - parent = parent.parentContainer; - } - } - - // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']); - indexes.unshift(this.scene.sys.displayList.getIndex(child)); - - return indexes; - }, - - /** - * Destroys this Game Object removing it from the Display List and Update List and - * severing all ties to parent resources. - * - * Also removes itself from the Input Manager and Physics Manager if previously enabled. - * - * Use this to remove a Game Object from your game if you don't ever plan to use it again. - * As long as no reference to it exists within your own code it should become free for - * garbage collection by the browser. - * - * If you just want to temporarily disable an object then look at using the - * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. - * - * @method Phaser.GameObjects.GameObject#destroy - * @since 3.0.0 - */ - destroy: function () - { - // This Game Object had already been destroyed - if (!this.scene || this.ignoreDestroy) - { - return; - } - - if (this.preDestroy) - { - this.preDestroy.call(this); - } - - this.emit('destroy', this); - - var sys = this.scene.sys; - - sys.displayList.remove(this); - sys.updateList.remove(this); - - if (this.input) - { - sys.input.clear(this); - this.input = undefined; - } - - if (this.data) - { - this.data.destroy(); - - this.data = undefined; - } - - if (this.body) - { - this.body.destroy(); - this.body = undefined; - } - - // Tell the Scene to re-sort the children - sys.queueDepthSort(); - - this.active = false; - this.visible = false; - - this.scene = undefined; - - this.parentContainer = undefined; - - this.removeAllListeners(); - } - -}); - -/** - * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. - * - * @constant {integer} RENDER_MASK - * @memberOf Phaser.GameObjects.GameObject - * @default - */ -GameObject.RENDER_MASK = 15; - -module.exports = GameObject; - - /***/ }), /* 3 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A NOOP (No Operation) callback function. - * - * Used internally by Phaser when it's more expensive to determine if a callback exists - * than it is to just invoke an empty function. - * - * @function Phaser.Utils.NOOP - * @since 3.0.0 - */ -var NOOP = function () -{ - // NOOP -}; - -module.exports = NOOP; - - -/***/ }), -/* 4 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Source object -// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' -// The default value to use if the key doesn't exist - -/** - * [description] - * - * @function Phaser.Utils.Object.GetValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {*} [description] - */ -var GetValue = function (source, key, defaultValue) -{ - if (!source || typeof source === 'number') - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else if (key.indexOf('.')) - { - var keys = key.split('.'); - var parent = source; - var value = defaultValue; - - // Use for loop here so we can break early - for (var i = 0; i < keys.length; i++) - { - if (parent.hasOwnProperty(keys[i])) - { - // Yes it has a key property, let's carry on down - value = parent[keys[i]]; - - parent = parent[keys[i]]; - } - else - { - // Can't go any further, so reset to default - value = defaultValue; - break; - } - } - - return value; - } - else - { - return defaultValue; - } -}; - -module.exports = GetValue; - - -/***/ }), -/* 5 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * Defines a Point in 2D space, with an x and y component. - * - * @class Point - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - The x coordinate of this Point. - * @param {number} [y=x] - The y coordinate of this Point. - */ -var Point = new Class({ - - initialize: - - function Point (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - /** - * The x coordinate of this Point. - * - * @name Phaser.Geom.Point#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * The y coordinate of this Point. - * - * @name Phaser.Geom.Point#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - }, - - /** - * Set the x and y coordinates of the point to the given values. - * - * @method Phaser.Geom.Point#setTo - * @since 3.0.0 - * - * @param {number} [x=0] - The x coordinate of this Point. - * @param {number} [y=x] - The y coordinate of this Point. - * - * @return {Phaser.Geom.Point} This Point object. - */ - setTo: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - } - -}); - -module.exports = Point; - - -/***/ }), -/* 6 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -1143,11 +416,11 @@ var Class = __webpack_require__(0); * A two-component vector. * * @class Vector2 - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * - * @param {number} [x] - The x component. + * @param {number|Vector2Like} [x] - The x component, or an object with `x` and `y` properties. * @param {number} [y] - The y component. */ var Vector2 = new Class({ @@ -1282,8 +555,8 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#setToPolar * @since 3.0.0 * - * @param {float} azimuth - The angular coordinate, in radians. - * @param {float} [radius=1] - The radial coordinate (length). + * @param {number} azimuth - The angular coordinate, in radians. + * @param {number} [radius=1] - The radial coordinate (length). * * @return {Phaser.Math.Vector2} This Vector2. */ @@ -1473,7 +746,7 @@ var Vector2 = new Class({ }, /** - * Calculate the distance between this Vector, and the given Vector, squared. + * Calculate the distance between this Vector and the given Vector, squared. * * @method Phaser.Math.Vector2#distanceSq * @since 3.0.0 @@ -1688,7 +961,9 @@ var Vector2 = new Class({ /** * A static zero Vector2 for use by reference. * - * @method Phaser.Math.Vector2.ZERO + * @constant + * @name Phaser.Math.Vector2.ZERO + * @type {Vector2} * @since 3.1.0 */ Vector2.ZERO = new Vector2(); @@ -1696,6 +971,345 @@ Vector2.ZERO = new Vector2(); module.exports = Vector2; +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Source object +// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' +// The default value to use if the key doesn't exist + +/** + * Retrieves a value from an object. + * + * @function Phaser.Utils.Objects.GetValue + * @since 3.0.0 + * + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param {*} defaultValue - The value to return if the `key` isn't found in the `source` object. + * + * @return {*} The value of the requested key. + */ +var GetValue = function (source, key, defaultValue) +{ + if (!source || typeof source === 'number') + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else if (key.indexOf('.')) + { + var keys = key.split('.'); + var parent = source; + var value = defaultValue; + + // Use for loop here so we can break early + for (var i = 0; i < keys.length; i++) + { + if (parent.hasOwnProperty(keys[i])) + { + // Yes it has a key property, let's carry on down + value = parent[keys[i]]; + + parent = parent[keys[i]]; + } + else + { + // Can't go any further, so reset to default + value = defaultValue; + break; + } + } + + return value; + } + else + { + return defaultValue; + } +}; + +module.exports = GetValue; + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var PluginCache = __webpack_require__(15); + +/** + * @classdesc + * The Game Object Factory is a Scene plugin that allows you to quickly create many common + * types of Game Objects and have them automatically registered with the Scene. + * + * Game Objects directly register themselves with the Factory and inject their own creation + * methods into the class. + * + * @class GameObjectFactory + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. + */ +var GameObjectFactory = new Class({ + + initialize: + + function GameObjectFactory (scene) + { + /** + * The Scene to which this Game Object Factory belongs. + * + * @name Phaser.GameObjects.GameObjectFactory#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A reference to the Scene.Systems. + * + * @name Phaser.GameObjects.GameObjectFactory#systems + * @type {Phaser.Scenes.Systems} + * @protected + * @since 3.0.0 + */ + this.systems = scene.sys; + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.GameObjectFactory#displayList + * @type {Phaser.GameObjects.DisplayList} + * @protected + * @since 3.0.0 + */ + this.displayList; + + /** + * A reference to the Scene Update List. + * + * @name Phaser.GameObjects.GameObjectFactory#updateList; + * @type {Phaser.GameObjects.UpdateList} + * @protected + * @since 3.0.0 + */ + this.updateList; + + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.GameObjects.GameObjectFactory#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.displayList = this.systems.displayList; + this.updateList = this.systems.updateList; + + this.systems.events.once('destroy', this.destroy, 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.GameObjects.GameObjectFactory#start + * @private + * @since 3.5.0 + */ + start: function () + { + this.systems.events.once('shutdown', this.shutdown, this); + }, + + /** + * Adds an existing Game Object to this Scene. + * + * If the Game Object renders, it will be added to the Display List. + * If it has a `preUpdate` method, it will be added to the Update List. + * + * @method Phaser.GameObjects.GameObjectFactory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The child to be added to this Scene. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was added. + */ + existing: function (child) + { + if (child.renderCanvas || child.renderWebGL) + { + this.displayList.add(child); + } + + if (child.preUpdate) + { + this.updateList.add(child); + } + + return child; + }, + + /** + * 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 () + { + this.systems.events.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.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; + } + +}); + +// Static method called directly by the Game Object factory functions + +GameObjectFactory.register = function (factoryType, factoryFunction) +{ + if (!GameObjectFactory.prototype.hasOwnProperty(factoryType)) + { + GameObjectFactory.prototype[factoryType] = factoryFunction; + } +}; + +PluginCache.register('GameObjectFactory', GameObjectFactory, 'add'); + +module.exports = GameObjectFactory; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * Defines a Point in 2D space, with an x and y component. + * + * @class Point + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of this Point. + * @param {number} [y=x] - The y coordinate of this Point. + */ +var Point = new Class({ + + initialize: + + function Point (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + /** + * The x coordinate of this Point. + * + * @name Phaser.Geom.Point#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y coordinate of this Point. + * + * @name Phaser.Geom.Point#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + }, + + /** + * Set the x and y coordinates of the point to the given values. + * + * @method Phaser.Geom.Point#setTo + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of this Point. + * @param {number} [y=x] - The y coordinate of this Point. + * + * @return {Phaser.Geom.Point} This Point object. + */ + setTo: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + } + +}); + +module.exports = Point; + + /***/ }), /* 7 */ /***/ (function(module, exports) { @@ -1775,7 +1389,7 @@ module.exports = FileTypesManager; * This is a slightly modified version of jQuery.isPlainObject. * A plain object is an object whose internal class property is [object Object]. * - * @function Phaser.Utils.Object.IsPlainObject + * @function Phaser.Utils.Objects.IsPlainObject * @since 3.0.0 * * @param {object} obj - The object to inspect. @@ -1821,6 +1435,640 @@ module.exports = IsPlainObject; /* 9 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(39); +var GetPoint = __webpack_require__(190); +var GetPoints = __webpack_require__(398); +var Line = __webpack_require__(54); +var Random = __webpack_require__(187); + +/** + * @classdesc + * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) + * + * @class Rectangle + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=0] - The Y coordinate of the top left corner of the Rectangle. + * @param {number} [width=0] - The width of the Rectangle. + * @param {number} [height=0] - The height of the Rectangle. + */ +var Rectangle = new Class({ + + initialize: + + function Rectangle (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * The X coordinate of the top left corner of the Rectangle. + * + * @name Phaser.Geom.Rectangle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The Y coordinate of the top left corner of the Rectangle. + * + * @name Phaser.Geom.Rectangle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. + * + * @name Phaser.Geom.Rectangle#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. + * + * @name Phaser.Geom.Rectangle#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * Checks if the given point is inside the Rectangle's bounds. + * + * @method Phaser.Geom.Rectangle#contains + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is within the Rectangle's bounds, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. + * + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. + * + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. + * + * @method Phaser.Geom.Rectangle#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {number} position - The normalized distance into the Rectangle's perimeter to return. + * @param {(Phaser.Geom.Point|object)} [output] - An object to update with the `x` and `y` coordinates of the point. + * + * @return {(Phaser.Geom.Point|object)} The updated `output` object, or a new Point if no `output` object was given. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. + * + * @method Phaser.Geom.Rectangle#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [output,$return] + * + * @param {integer} quantity - The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. + * @param {number} [stepRate] - If `quantity` is 0, determines the normalized distance between each returned point. + * @param {(array|Phaser.Geom.Point[])} [output] - An array to which to append the points. + * + * @return {(array|Phaser.Geom.Point[])} The modified `output` array, or a new array if none was provided. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Returns a random point within the Rectangle's bounds. + * + * @method Phaser.Geom.Rectangle#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} [point] - The object in which to store the `x` and `y` coordinates of the point. + * + * @return {Phaser.Geom.Point} The updated `point`, or a new Point if none was provided. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Sets the position, width, and height of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setTo + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} y - The Y coordinate of the top left corner of the Rectangle. + * @param {number} width - The width of the Rectangle. + * @param {number} height - The height of the Rectangle. + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Resets the position, width, and height of the Rectangle to 0. + * + * @method Phaser.Geom.Rectangle#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setEmpty: function () + { + return this.setTo(0, 0, 0, 0); + }, + + /** + * Sets the position of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setPosition + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=x] - The Y coordinate of the top left corner of the Rectangle. + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Sets the width and height of the Rectangle. + * + * @method Phaser.Geom.Rectangle#setSize + * @since 3.0.0 + * + * @param {number} width - The width to set the Rectangle to. + * @param {number} [height=width] - The height to set the Rectangle to. + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. + * + * @method Phaser.Geom.Rectangle#isEmpty + * @since 3.0.0 + * + * @return {boolean} `true` if the Rectangle is empty. A Rectangle object is empty if its width or height is less than or equal to 0. + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns a Line object that corresponds to the top of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineA + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.y, this.right, this.y); + + return line; + }, + + /** + * Returns a Line object that corresponds to the right of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.y, this.right, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the bottom of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineC + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.bottom, this.x, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the left of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineD + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. + */ + getLineD: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.bottom, this.x, this.y); + + return line; + }, + + /** + * The x coordinate of the left of the Rectangle. + * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. + * + * @name Phaser.Geom.Rectangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x; + }, + + set: function (value) + { + if (value >= this.right) + { + this.width = 0; + } + else + { + this.width = this.right - value; + } + + this.x = value; + } + + }, + + /** + * The sum of the x and width properties. + * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. + * + * @name Phaser.Geom.Rectangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this.width; + }, + + set: function (value) + { + if (value <= this.x) + { + this.width = 0; + } + else + { + this.width = value - this.x; + } + } + + }, + + /** + * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. + * However it does affect the height property, whereas changing the y value does not affect the height property. + * + * @name Phaser.Geom.Rectangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y; + }, + + set: function (value) + { + if (value >= this.bottom) + { + this.height = 0; + } + else + { + this.height = (this.bottom - value); + } + + this.y = value; + } + + }, + + /** + * The sum of the y and height properties. + * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. + * + * @name Phaser.Geom.Rectangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this.height; + }, + + set: function (value) + { + if (value <= this.y) + { + this.height = 0; + } + else + { + this.height = value - this.y; + } + } + + }, + + /** + * The x coordinate of the center of the Rectangle. + * + * @name Phaser.Geom.Rectangle#centerX + * @type {number} + * @since 3.0.0 + */ + centerX: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * The y coordinate of the center of the Rectangle. + * + * @name Phaser.Geom.Rectangle#centerY + * @type {number} + * @since 3.0.0 + */ + centerY: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + + } + +}); + +module.exports = Rectangle; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL.Utils + * @since 3.0.0 + */ +module.exports = { + + /** + * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 + * + * @function Phaser.Renderer.WebGL.Utils.getTintFromFloats + * @since 3.0.0 + * + * @param {number} r - Red component in a range from 0.0 to 1.0 + * @param {number} g - [description] + * @param {number} b - [description] + * @param {number} a - Alpha component in a range from 0.0 to 1.0 + * + * @return {number} [description] + */ + getTintFromFloats: function (r, g, b, a) + { + var ur = ((r * 255.0)|0) & 0xFF; + var ug = ((g * 255.0)|0) & 0xFF; + var ub = ((b * 255.0)|0) & 0xFF; + var ua = ((a * 255.0)|0) & 0xFF; + + return ((ua << 24) | (ur << 16) | (ug << 8) | ub) >>> 0; + }, + + /** + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 + * + * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha + * @since 3.0.0 + * + * @param {number} rgb - Uint24 representing RGB components + * @param {number} a - Float32 representing Alpha component + * + * @return {number} Packed RGBA as Uint32 + */ + getTintAppendFloatAlpha: function (rgb, a) + { + var ua = ((a * 255.0)|0) & 0xFF; + return ((ua << 24) | rgb) >>> 0; + }, + + /** + * Packs a Uint24, representing RGB components, with a Float32, representing + * the alpha component, with a range between 0.0 and 1.0 and return a + * swizzled Uint32 + * + * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlphaAndSwap + * @since 3.0.0 + * + * @param {number} rgb - Uint24 representing RGB components + * @param {number} a - Float32 representing Alpha component + * + * @return {number} Packed RGBA as Uint32 + */ + getTintAppendFloatAlphaAndSwap: function (rgb, a) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + var ua = ((a * 255.0)|0) & 0xFF; + + return ((ua << 24) | (ub << 16) | (ug << 8) | ur) >>> 0; + }, + + /** + * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 + * + * @function Phaser.Renderer.WebGL.Utils.getFloatsFromUintRGB + * @since 3.0.0 + * + * @param {number} rgb - RGB packed as a Uint24 + * + * @return {array} Array of floats representing each component as a float + */ + getFloatsFromUintRGB: function (rgb) + { + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + return [ ur / 255.0, ug / 255.0, ub / 255.0 ]; + }, + + /** + * Counts how many attributes of 32 bits a vertex has + * + * @function Phaser.Renderer.WebGL.Utils.getComponentCount + * @since 3.0.0 + * + * @param {array} attributes - Array of attributes + * @param {WebGLRenderingContext} glContext - WebGLContext used for check types + * + * @return {number} Count of 32 bit attributes in vertex + */ + getComponentCount: function (attributes, glContext) + { + var count = 0; + + for (var index = 0; index < attributes.length; ++index) + { + var element = attributes[index]; + + if (element.type === glContext.FLOAT) + { + count += element.size; + } + else + { + count += 1; // We'll force any other type to be 32 bit. for now + } + } + + return count; + } + +}; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + "use strict"; @@ -2161,7 +2409,7 @@ if (true) { /***/ }), -/* 10 */ +/* 12 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -2203,7 +2451,7 @@ var GetValue = __webpack_require__(4); /** * [description] * - * @function Phaser.Utils.Object.GetAdvancedValue + * @function Phaser.Utils.Objects.GetAdvancedValue * @since 3.0.0 * * @param {object} source - [description] @@ -2246,376 +2494,6 @@ var GetAdvancedValue = function (source, key, defaultValue) module.exports = GetAdvancedValue; -/***/ }), -/* 11 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * The Game Object Factory is a Scene plugin that allows you to quickly create many common - * types of Game Objects and have them automatically registered with the Scene. - * - * Game Objects directly register themselves with the Factory and inject their own creation - * methods into the class. - * - * @class GameObjectFactory - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object Factory belongs. - */ -var GameObjectFactory = new Class({ - - initialize: - - function GameObjectFactory (scene) - { - /** - * The Scene to which this Game Object Factory belongs. - * - * @name Phaser.GameObjects.GameObjectFactory#scene - * @type {Phaser.Scene} - * @protected - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene.Systems. - * - * @name Phaser.GameObjects.GameObjectFactory#systems - * @type {Phaser.Scenes.Systems} - * @protected - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * A reference to the Scene Display List. - * - * @name Phaser.GameObjects.GameObjectFactory#displayList - * @type {Phaser.GameObjects.DisplayList} - * @protected - * @since 3.0.0 - */ - this.displayList; - - /** - * A reference to the Scene Update List. - * - * @name Phaser.GameObjects.GameObjectFactory#updateList; - * @type {Phaser.GameObjects.UpdateList} - * @protected - * @since 3.0.0 - */ - this.updateList; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.GameObjects.GameObjectFactory#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.displayList = this.systems.displayList; - this.updateList = this.systems.updateList; - - this.systems.events.once('destroy', this.destroy, 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.GameObjects.GameObjectFactory#start - * @private - * @since 3.5.0 - */ - start: function () - { - this.systems.events.once('shutdown', this.shutdown, this); - }, - - /** - * Adds an existing Game Object to this Scene. - * - * If the Game Object renders, it will be added to the Display List. - * If it has a `preUpdate` method, it will be added to the Update List. - * - * @method Phaser.GameObjects.GameObjectFactory#existing - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - The child to be added to this Scene. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was added. - */ - existing: function (child) - { - if (child.renderCanvas || child.renderWebGL) - { - this.displayList.add(child); - } - - if (child.preUpdate) - { - this.updateList.add(child); - } - - return child; - }, - - /** - * 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 () - { - this.systems.events.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.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; - } - -}); - -// Static method called directly by the Game Object factory functions - -GameObjectFactory.register = function (factoryType, factoryFunction) -{ - if (!GameObjectFactory.prototype.hasOwnProperty(factoryType)) - { - GameObjectFactory.prototype[factoryType] = factoryFunction; - } -}; - -PluginCache.register('GameObjectFactory', GameObjectFactory, 'add'); - -module.exports = GameObjectFactory; - - -/***/ }), -/* 12 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Contains the plugins that Phaser uses globally and locally. -// These are the source objects, not instantiated. -var corePlugins = {}; - -// Contains the plugins that the dev has loaded into their game -// These are the source objects, not instantiated. -var customPlugins = {}; - -/** - * @typedef {object} CorePluginContainer - * - * @property {string} key - The unique name of this plugin in the core plugin cache. - * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. - * @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used. - * @property {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? - */ - -/** - * @typedef {object} CustomPluginContainer - * - * @property {string} key - The unique name of this plugin in the custom plugin cache. - * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. - */ - -var PluginCache = {}; - -/** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * - * @method Phaser.Plugins.PluginCache.register - * @since 3.8.0 - * - * @param {string} key - A reference used to get this plugin from the plugin cache. - * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. - * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. - * @param {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? - */ -PluginCache.register = function (key, plugin, mapping, custom) -{ - if (custom === undefined) { custom = false; } - - corePlugins[key] = { plugin: plugin, mapping: mapping, custom: custom }; -}; - -/** - * Stores a custom plugin in the global plugin cache. - * The key must be unique, within the scope of the cache. - * - * @method Phaser.Plugins.PluginCache.registerCustom - * @since 3.8.0 - * - * @param {string} key - A reference used to get this plugin from the plugin cache. - * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. - * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. - */ -PluginCache.registerCustom = function (key, plugin, mapping) -{ - customPlugins[key] = { plugin: plugin, mapping: mapping }; -}; - -/** - * Checks if the given key is already being used in the core plugin cache. - * - * @method Phaser.Plugins.PluginCache.hasCore - * @since 3.8.0 - * - * @param {string} key - The key to check for. - * - * @return {boolean} `true` if the key is already in use in the core cache, otherwise `false`. - */ -PluginCache.hasCore = function (key) -{ - return corePlugins.hasOwnProperty(key); -}; - -/** - * Checks if the given key is already being used in the custom plugin cache. - * - * @method Phaser.Plugins.PluginCache.hasCustom - * @since 3.8.0 - * - * @param {string} key - The key to check for. - * - * @return {boolean} `true` if the key is already in use in the custom cache, otherwise `false`. - */ -PluginCache.hasCustom = function (key) -{ - return customPlugins.hasOwnProperty(key); -}; - -/** - * Returns the core plugin object from the cache based on the given key. - * - * @method Phaser.Plugins.PluginCache.getCore - * @since 3.8.0 - * - * @param {string} key - The key of the core plugin to get. - * - * @return {CorePluginContainer} The core plugin object. - */ -PluginCache.getCore = function (key) -{ - return corePlugins[key]; -}; - -/** - * Returns the custom plugin object from the cache based on the given key. - * - * @method Phaser.Plugins.PluginCache.getCustom - * @since 3.8.0 - * - * @param {string} key - The key of the custom plugin to get. - * - * @return {CustomPluginContainer} The custom plugin object. - */ -PluginCache.getCustom = function (key) -{ - return customPlugins[key]; -}; - -/** - * Returns an object from the custom cache based on the given key that can be instantiated. - * - * @method Phaser.Plugins.PluginCache.getCustomClass - * @since 3.8.0 - * - * @param {string} key - The key of the custom plugin to get. - * - * @return {function} The custom plugin object. - */ -PluginCache.getCustomClass = function (key) -{ - return (customPlugins.hasOwnProperty(key)) ? customPlugins[key].plugin : null; -}; - -/** - * Removes a core plugin based on the given key. - * - * @method Phaser.Plugins.PluginCache.remove - * @since 3.8.0 - * - * @param {string} key - The key of the core plugin to remove. - */ -PluginCache.remove = function (key) -{ - if (corePlugins.hasOwnProperty(key)) - { - delete corePlugins[key]; - } -}; - -/** - * Removes a custom plugin based on the given key. - * - * @method Phaser.Plugins.PluginCache.removeCustom - * @since 3.8.0 - * - * @param {string} key - The key of the custom plugin to remove. - */ -PluginCache.removeCustom = function (key) -{ - if (customPlugins.hasOwnProperty(key)) - { - delete customPlugins[key]; - } -}; - -module.exports = PluginCache; - - /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { @@ -2627,7 +2505,7 @@ module.exports = PluginCache; */ var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); +var PluginCache = __webpack_require__(15); /** * @classdesc @@ -2639,7 +2517,7 @@ var PluginCache = __webpack_require__(12); * methods into the class. * * @class GameObjectCreator - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -2785,490 +2663,40 @@ module.exports = GameObjectCreator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Contains = __webpack_require__(31); -var GetPoint = __webpack_require__(135); -var GetPoints = __webpack_require__(294); -var Line = __webpack_require__(96); -var Random = __webpack_require__(154); - /** - * @classdesc - * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) - * - * @class Rectangle - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width=0] - [description] - * @param {number} [height=0] - [description] + * @namespace Phaser.GameObjects.Components */ -var Rectangle = new Class({ - initialize: +module.exports = { - function Rectangle (x, y, width, height) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = 0; } - if (height === undefined) { height = 0; } + Alpha: __webpack_require__(401), + Animation: __webpack_require__(427), + BlendMode: __webpack_require__(400), + ComputedSize: __webpack_require__(1045), + Crop: __webpack_require__(1044), + Depth: __webpack_require__(399), + Flip: __webpack_require__(1043), + GetBounds: __webpack_require__(1042), + Mask: __webpack_require__(395), + Origin: __webpack_require__(1041), + Pipeline: __webpack_require__(186), + ScaleMode: __webpack_require__(1040), + ScrollFactor: __webpack_require__(392), + Size: __webpack_require__(1039), + Texture: __webpack_require__(1038), + TextureCrop: __webpack_require__(1037), + Tint: __webpack_require__(1036), + ToJSON: __webpack_require__(391), + Transform: __webpack_require__(390), + TransformMatrix: __webpack_require__(38), + Visible: __webpack_require__(389) - /** - * [description] - * - * @name Phaser.Geom.Rectangle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = x; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = y; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#width - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.width = width; - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#height - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.height = height; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#contains - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [output,$return] - * - * @param {integer} quantity - [description] - * @param {number} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#getRandomPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} [point] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setTo - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setTo: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setEmpty - * @since 3.0.0 - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setEmpty: function () - { - return this.setTo(0, 0, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} [height=width] - [description] - * - * @return {Phaser.Geom.Rectangle} This Rectangle object. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Geom.Rectangle#isEmpty - * @since 3.0.0 - * - * @return {boolean} [description] - */ - isEmpty: function () - { - return (this.width <= 0 || this.height <= 0); - }, - - /** - * Returns a Line object that corresponds to the top of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineA - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. - */ - getLineA: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.x, this.y, this.right, this.y); - - return line; - }, - - /** - * Returns a Line object that corresponds to the right of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineB - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. - */ - getLineB: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.right, this.y, this.right, this.bottom); - - return line; - }, - - /** - * Returns a Line object that corresponds to the bottom of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineC - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. - */ - getLineC: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.right, this.bottom, this.x, this.bottom); - - return line; - }, - - /** - * Returns a Line object that corresponds to the left of this Rectangle. - * - * @method Phaser.Geom.Rectangle#getLineD - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. - * - * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. - */ - getLineD: function (line) - { - if (line === undefined) { line = new Line(); } - - line.setTo(this.x, this.bottom, this.x, this.y); - - return line; - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.x; - }, - - set: function (value) - { - if (value >= this.right) - { - this.width = 0; - } - else - { - this.width = this.right - value; - } - - this.x = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.x + this.width; - }, - - set: function (value) - { - if (value <= this.x) - { - this.width = 0; - } - else - { - this.width = value - this.x; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.y; - }, - - set: function (value) - { - if (value >= this.bottom) - { - this.height = 0; - } - else - { - this.height = (this.bottom - value); - } - - this.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.y + this.height; - }, - - set: function (value) - { - if (value <= this.y) - { - this.height = 0; - } - else - { - this.height = value - this.y; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerX - * @type {number} - * @since 3.0.0 - */ - centerX: { - - get: function () - { - return this.x + (this.width / 2); - }, - - set: function (value) - { - this.x = value - (this.width / 2); - } - - }, - - /** - * [description] - * - * @name Phaser.Geom.Rectangle#centerY - * @type {number} - * @since 3.0.0 - */ - centerY: { - - get: function () - { - return this.y + (this.height / 2); - }, - - set: function (value) - { - this.y = value - (this.height / 2); - } - - } - -}); - -module.exports = Rectangle; +}; /***/ }), /* 15 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, exports) { /** * @author Richard Davey @@ -3276,35 +2704,216 @@ module.exports = Rectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// Contains the plugins that Phaser uses globally and locally. +// These are the source objects, not instantiated. +var corePlugins = {}; + +// Contains the plugins that the dev has loaded into their game +// These are the source objects, not instantiated. +var customPlugins = {}; + /** - * @namespace Phaser.GameObjects.Components + * @typedef {object} CorePluginContainer + * + * @property {string} key - The unique name of this plugin in the core plugin cache. + * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. + * @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @property {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? */ -module.exports = { +/** + * @typedef {object} CustomPluginContainer + * + * @property {string} key - The unique name of this plugin in the custom plugin cache. + * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. + */ - Alpha: __webpack_require__(587), - Animation: __webpack_require__(302), - BlendMode: __webpack_require__(586), - ComputedSize: __webpack_require__(585), - Depth: __webpack_require__(584), - Flip: __webpack_require__(583), - GetBounds: __webpack_require__(582), - Mask: __webpack_require__(581), - MatrixStack: __webpack_require__(580), - Origin: __webpack_require__(579), - Pipeline: __webpack_require__(291), - ScaleMode: __webpack_require__(578), - ScrollFactor: __webpack_require__(577), - Size: __webpack_require__(576), - Texture: __webpack_require__(575), - Tint: __webpack_require__(574), - ToJSON: __webpack_require__(573), - Transform: __webpack_require__(572), - TransformMatrix: __webpack_require__(64), - Visible: __webpack_require__(571) +var PluginCache = {}; +/** + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + * + * @method Phaser.Plugins.PluginCache.register + * @since 3.8.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @param {boolean} [custom=false] - Core Scene plugin or a Custom Scene plugin? + */ +PluginCache.register = function (key, plugin, mapping, custom) +{ + if (custom === undefined) { custom = false; } + + corePlugins[key] = { plugin: plugin, mapping: mapping, custom: custom }; }; +/** + * Stores a custom plugin in the global plugin cache. + * The key must be unique, within the scope of the cache. + * + * @method Phaser.Plugins.PluginCache.registerCustom + * @since 3.8.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @param {?any} data - A value to be passed to the plugin's `init` method. + */ +PluginCache.registerCustom = function (key, plugin, mapping, data) +{ + customPlugins[key] = { plugin: plugin, mapping: mapping, data: data }; +}; + +/** + * Checks if the given key is already being used in the core plugin cache. + * + * @method Phaser.Plugins.PluginCache.hasCore + * @since 3.8.0 + * + * @param {string} key - The key to check for. + * + * @return {boolean} `true` if the key is already in use in the core cache, otherwise `false`. + */ +PluginCache.hasCore = function (key) +{ + return corePlugins.hasOwnProperty(key); +}; + +/** + * Checks if the given key is already being used in the custom plugin cache. + * + * @method Phaser.Plugins.PluginCache.hasCustom + * @since 3.8.0 + * + * @param {string} key - The key to check for. + * + * @return {boolean} `true` if the key is already in use in the custom cache, otherwise `false`. + */ +PluginCache.hasCustom = function (key) +{ + return customPlugins.hasOwnProperty(key); +}; + +/** + * Returns the core plugin object from the cache based on the given key. + * + * @method Phaser.Plugins.PluginCache.getCore + * @since 3.8.0 + * + * @param {string} key - The key of the core plugin to get. + * + * @return {CorePluginContainer} The core plugin object. + */ +PluginCache.getCore = function (key) +{ + return corePlugins[key]; +}; + +/** + * Returns the custom plugin object from the cache based on the given key. + * + * @method Phaser.Plugins.PluginCache.getCustom + * @since 3.8.0 + * + * @param {string} key - The key of the custom plugin to get. + * + * @return {CustomPluginContainer} The custom plugin object. + */ +PluginCache.getCustom = function (key) +{ + return customPlugins[key]; +}; + +/** + * Returns an object from the custom cache based on the given key that can be instantiated. + * + * @method Phaser.Plugins.PluginCache.getCustomClass + * @since 3.8.0 + * + * @param {string} key - The key of the custom plugin to get. + * + * @return {function} The custom plugin object. + */ +PluginCache.getCustomClass = function (key) +{ + return (customPlugins.hasOwnProperty(key)) ? customPlugins[key].plugin : null; +}; + +/** + * Removes a core plugin based on the given key. + * + * @method Phaser.Plugins.PluginCache.remove + * @since 3.8.0 + * + * @param {string} key - The key of the core plugin to remove. + */ +PluginCache.remove = function (key) +{ + if (corePlugins.hasOwnProperty(key)) + { + delete corePlugins[key]; + } +}; + +/** + * Removes a custom plugin based on the given key. + * + * @method Phaser.Plugins.PluginCache.removeCustom + * @since 3.8.0 + * + * @param {string} key - The key of the custom plugin to remove. + */ +PluginCache.removeCustom = function (key) +{ + if (customPlugins.hasOwnProperty(key)) + { + delete customPlugins[key]; + } +}; + +/** + * Removes all Core Plugins. + * + * This includes all of the internal system plugins that Phaser needs, like the Input Plugin and Loader Plugin. + * So be sure you only call this if you do not wish to run Phaser again. + * + * @method Phaser.Plugins.PluginCache.destroyCorePlugins + * @since 3.12.0 + */ +PluginCache.destroyCorePlugins = function () +{ + for (var key in corePlugins) + { + if (corePlugins.hasOwnProperty(key)) + { + delete corePlugins[key]; + } + } +}; + +/** + * Removes all Custom Plugins. + * + * @method Phaser.Plugins.PluginCache.destroyCustomPlugins + * @since 3.12.0 + */ +PluginCache.destroyCustomPlugins = function () +{ + for (var key in customPlugins) + { + if (customPlugins.hasOwnProperty(key)) + { + delete customPlugins[key]; + } + } +}; + +module.exports = PluginCache; + /***/ }), /* 16 */ @@ -3316,7 +2925,7 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RND = __webpack_require__(297); +var RND = __webpack_require__(404); var MATH_CONST = { @@ -3389,93 +2998,86 @@ module.exports = MATH_CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var IsPlainObject = __webpack_require__(8); - -// @param {boolean} deep - Perform a deep copy? -// @param {object} target - The target object to copy to. -// @return {object} The extended object. +var GetFastValue = __webpack_require__(2); /** - * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * @typedef {object} GetTilesWithinFilteringOptions * - * @function Phaser.Utils.Object.Extend + * @property {boolean} [isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @property {boolean} [isColliding=false] - If true, only return tiles that collide on at least one side. + * @property {boolean} [hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + */ + +/** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithin + * @private * @since 3.0.0 * - * @return {object} [description] + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {object} GetTilesWithinFilteringOptions - Optional filters to apply when getting the tiles. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. */ -var Extend = function () +var GetTilesWithin = function (tileX, tileY, width, height, filteringOptions, layer) { - var options, name, src, copy, copyIsArray, clone, - target = arguments[0] || {}, - i = 1, - length = arguments.length, - deep = false; + if (tileX === undefined) { tileX = 0; } + if (tileY === undefined) { tileY = 0; } + if (width === undefined) { width = layer.width; } + if (height === undefined) { height = layer.height; } - // Handle a deep copy situation - if (typeof target === 'boolean') + var isNotEmpty = GetFastValue(filteringOptions, 'isNotEmpty', false); + var isColliding = GetFastValue(filteringOptions, 'isColliding', false); + var hasInterestingFace = GetFastValue(filteringOptions, 'hasInterestingFace', false); + + // Clip x, y to top left of map, while shrinking width/height to match. + if (tileX < 0) { - deep = target; - target = arguments[1] || {}; - - // skip the boolean and the target - i = 2; + width += tileX; + tileX = 0; + } + if (tileY < 0) + { + height += tileY; + tileY = 0; } - // extend Phaser if only one argument is passed - if (length === i) + // Clip width and height to bottom right of map. + if (tileX + width > layer.width) { - target = this; - --i; + width = Math.max(layer.width - tileX, 0); + } + if (tileY + height > layer.height) + { + height = Math.max(layer.height - tileY, 0); } - for (; i < length; i++) + var results = []; + + for (var ty = tileY; ty < tileY + height; ty++) { - // Only deal with non-null/undefined values - if ((options = arguments[i]) != null) + for (var tx = tileX; tx < tileX + width; tx++) { - // Extend the base object - for (name in options) + var tile = layer.data[ty][tx]; + if (tile !== null) { - src = target[name]; - copy = options[name]; - - // Prevent never-ending loop - if (target === copy) - { - continue; - } - - // Recurse if we're merging plain objects or arrays - if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) - { - if (copyIsArray) - { - copyIsArray = false; - clone = src && Array.isArray(src) ? src : []; - } - else - { - clone = src && IsPlainObject(src) ? src : {}; - } - - // Never move original objects, clone them - target[name] = Extend(deep, clone, copy); - - // Don't bring in undefined values - } - else if (copy !== undefined) - { - target[name] = copy; - } + if (isNotEmpty && tile.index === -1) { continue; } + if (isColliding && !tile.collides) { continue; } + if (hasInterestingFace && !tile.hasInterestingFace) { continue; } + results.push(tile); } } } - // Return the modified object - return target; + return results; }; -module.exports = Extend; +module.exports = GetTilesWithin; /***/ }), @@ -3634,6 +3236,704 @@ module.exports = FILE_CONST; /* 19 */ /***/ (function(module, exports, __webpack_require__) { +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ComponentsToJSON = __webpack_require__(391); +var DataManager = __webpack_require__(123); +var EventEmitter = __webpack_require__(11); + +/** + * @classdesc + * The base class that all Game Objects extend. + * You don't create GameObjects directly and they cannot be added to the display list. + * Instead, use them as the base for your own custom classes. + * + * @class GameObject + * @memberof Phaser.GameObjects + * @extends Phaser.Events.EventEmitter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`. + */ +var GameObject = new Class({ + + Extends: EventEmitter, + + initialize: + + function GameObject (scene, type) + { + EventEmitter.call(this); + + /** + * The Scene to which this Game Object belongs. + * Game Objects can only belong to one Scene. + * + * @name Phaser.GameObjects.GameObject#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A textual representation of this Game Object, i.e. `sprite`. + * Used internally by Phaser but is available for your own custom classes to populate. + * + * @name Phaser.GameObjects.GameObject#type + * @type {string} + * @since 3.0.0 + */ + this.type = type; + + /** + * The parent Container of this Game Object, if it has one. + * + * @name Phaser.GameObjects.GameObject#parentContainer + * @type {Phaser.GameObjects.Container} + * @since 3.4.0 + */ + this.parentContainer = null; + + /** + * The name of this Game Object. + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.GameObject#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The active state of this Game Object. + * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. + * An active object is one which is having its logic and internal systems updated. + * + * @name Phaser.GameObjects.GameObject#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * The Tab Index of the Game Object. + * Reserved for future use by plugins and the Input Manager. + * + * @name Phaser.GameObjects.GameObject#tabIndex + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.tabIndex = -1; + + /** + * A Data Manager. + * It allows you to store, query and get key/value paired information specific to this Game Object. + * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. + * + * @name Phaser.GameObjects.GameObject#data + * @type {Phaser.Data.DataManager} + * @default null + * @since 3.0.0 + */ + this.data = null; + + /** + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. + * + * @name Phaser.GameObjects.GameObject#renderFlags + * @type {integer} + * @default 15 + * @since 3.0.0 + */ + this.renderFlags = 15; + + /** + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + * + * @example + * this.cameraFilter |= camera.id + * + * @name Phaser.GameObjects.GameObject#cameraFilter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cameraFilter = 0; + + /** + * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. + * Not usually set directly. Instead call `GameObject.setInteractive()`. + * + * @name Phaser.GameObjects.GameObject#input + * @type {?Phaser.Input.InteractiveObject} + * @default null + * @since 3.0.0 + */ + this.input = null; + + /** + * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. + * + * @name Phaser.GameObjects.GameObject#body + * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} + * @default null + * @since 3.0.0 + */ + 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 + scene.sys.queueDepthSort(); + }, + + /** + * Sets the `active` property of this Game Object and returns this Game Object for further chaining. + * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. + * + * @method Phaser.GameObjects.GameObject#setActive + * @since 3.0.0 + * + * @param {boolean} value - True if this Game Object should be set as active, false if not. + * + * @return {this} This GameObject. + */ + setActive: function (value) + { + this.active = value; + + return this; + }, + + /** + * Sets the `name` property of this Game Object and returns this Game Object for further chaining. + * The `name` property is not populated by Phaser and is presented for your own use. + * + * @method Phaser.GameObjects.GameObject#setName + * @since 3.0.0 + * + * @param {string} value - The name to be given to this Game Object. + * + * @return {this} This GameObject. + */ + setName: function (value) + { + this.name = value; + + return this; + }, + + /** + * Adds a Data Manager component to this Game Object. + * + * @method Phaser.GameObjects.GameObject#setDataEnabled + * @since 3.0.0 + * @see Phaser.Data.DataManager + * + * @return {this} This GameObject. + */ + setDataEnabled: function () + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this; + }, + + /** + * Allows you to store a key value pair within this Game Objects Data Manager. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * sprite.setData('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `getData`: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * sprite.data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.GameObjects.GameObject#setData + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {this} This GameObject. + */ + setData: function (key, value) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + this.data.set(key, value); + + return this; + }, + + /** + * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * sprite.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * sprite.getData([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.GameObjects.GameObject#getData + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + getData: function (key) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this.data.get(key); + }, + + /** + * Pass this Game Object to the Input Manager to enable it for Input. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * + * @method Phaser.GameObjects.GameObject#setInteractive + * @since 3.0.0 + * + * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? + * + * @return {this} This GameObject. + */ + setInteractive: function (shape, callback, dropZone) + { + this.scene.sys.input.enable(this, shape, callback, dropZone); + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will disable it. + * + * An object that is disabled for input stops processing or being considered for + * input events, but can be turned back on again at any time by simply calling + * `setInteractive()` with no arguments provided. + * + * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. + * + * @method Phaser.GameObjects.GameObject#disableInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + disableInteractive: function () + { + if (this.input) + { + this.input.enabled = false; + } + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. + * + * The Interactive Object that was assigned to this Game Object will be destroyed, + * removed from the Input Manager and cleared from this Game Object. + * + * If you wish to re-enable this Game Object at a later date you will need to + * re-create its InteractiveObject by calling `setInteractive` again. + * + * If you wish to only temporarily stop an object from receiving input then use + * `disableInteractive` instead, as that toggles the interactive state, where-as + * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) + * + * @method Phaser.GameObjects.GameObject#removeInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + removeInteractive: function () + { + this.scene.sys.input.clear(this); + + this.input = undefined; + + return this; + }, + + /** + * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. + * + * @method Phaser.GameObjects.GameObject#update + * @since 3.0.0 + * + * @param {...*} [args] - args + */ + update: function () + { + }, + + /** + * Returns a JSON representation of the Game Object. + * + * @method Phaser.GameObjects.GameObject#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + return ComponentsToJSON(this); + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * + * @method Phaser.GameObjects.GameObject#willRender + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * + * @return {boolean} True if the Game Object should be rendered, otherwise false. + */ + willRender: function (camera) + { + return !(GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter > 0 && (this.cameraFilter & camera.id))); + }, + + /** + * Returns an array containing the display list index of either this Game Object, or if it has one, + * its parent Container. It then iterates up through all of the parent containers until it hits the + * root of the display list (which is index 0 in the returned array). + * + * Used internally by the InputPlugin but also useful if you wish to find out the display depth of + * this Game Object and all of its ancestors. + * + * @method Phaser.GameObjects.GameObject#getIndexList + * @since 3.4.0 + * + * @return {integer[]} An array of display list position indexes. + */ + getIndexList: function () + { + // eslint-disable-next-line consistent-this + var child = this; + var parent = this.parentContainer; + + var indexes = []; + + while (parent) + { + // indexes.unshift([parent.getIndex(child), parent.name]); + indexes.unshift(parent.getIndex(child)); + + child = parent; + + if (!parent.parentContainer) + { + break; + } + else + { + parent = parent.parentContainer; + } + } + + // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']); + indexes.unshift(this.scene.sys.displayList.getIndex(child)); + + return indexes; + }, + + /** + * Destroys this Game Object removing it from the Display List and Update List and + * severing all ties to parent resources. + * + * Also removes itself from the Input Manager and Physics Manager if previously enabled. + * + * Use this to remove a Game Object from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * + * @method Phaser.GameObjects.GameObject#destroy + * @since 3.0.0 + * + * @param {boolean} [fromScene=false] - Is this Game Object being destroyed as the result of a Scene shutdown? + */ + destroy: function (fromScene) + { + if (fromScene === undefined) { fromScene = false; } + + // This Game Object has already been destroyed + if (!this.scene || this.ignoreDestroy) + { + return; + } + + if (this.preDestroy) + { + this.preDestroy.call(this); + } + + this.emit('destroy', this); + + var sys = this.scene.sys; + + if (!fromScene) + { + sys.displayList.remove(this); + sys.updateList.remove(this); + } + + if (this.input) + { + sys.input.clear(this); + this.input = undefined; + } + + if (this.data) + { + this.data.destroy(); + + this.data = undefined; + } + + if (this.body) + { + this.body.destroy(); + this.body = undefined; + } + + // Tell the Scene to re-sort the children + if (!fromScene) + { + sys.queueDepthSort(); + } + + this.active = false; + this.visible = false; + + this.scene = undefined; + + this.parentContainer = undefined; + + this.removeAllListeners(); + } + +}); + +/** + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + * + * @constant {integer} RENDER_MASK + * @memberof Phaser.GameObjects.GameObject + * @default + */ +GameObject.RENDER_MASK = 15; + +module.exports = GameObject; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsPlainObject = __webpack_require__(8); + +// @param {boolean} deep - Perform a deep copy? +// @param {object} target - The target object to copy to. +// @return {object} The extended object. + +/** + * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * + * @function Phaser.Utils.Objects.Extend + * @since 3.0.0 + * + * @return {object} [description] + */ +var Extend = function () +{ + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') + { + deep = target; + target = arguments[1] || {}; + + // skip the boolean and the target + i = 2; + } + + // extend Phaser if only one argument is passed + if (length === i) + { + target = this; + --i; + } + + for (; i < length; i++) + { + // Only deal with non-null/undefined values + if ((options = arguments[i]) != null) + { + // Extend the base object + for (name in options) + { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target === copy) + { + continue; + } + + // Recurse if we're merging plain objects or arrays + if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) + { + if (copyIsArray) + { + copyIsArray = false; + clone = src && Array.isArray(src) ? src : []; + } + else + { + clone = src && IsPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = Extend(deep, clone, copy); + + // Don't bring in undefined values + } + else if (copy !== undefined) + { + target[name] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +module.exports = Extend; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -3642,11 +3942,11 @@ module.exports = FILE_CONST; var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var GetFastValue = __webpack_require__(1); -var GetURL = __webpack_require__(108); -var MergeXHRSettings = __webpack_require__(107); -var XHRLoader = __webpack_require__(169); -var XHRSettings = __webpack_require__(75); +var GetFastValue = __webpack_require__(2); +var GetURL = __webpack_require__(141); +var MergeXHRSettings = __webpack_require__(140); +var XHRLoader = __webpack_require__(254); +var XHRSettings = __webpack_require__(105); /** * @typedef {object} FileConfig @@ -3667,7 +3967,7 @@ var XHRSettings = __webpack_require__(75); * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. * * @class File - * @memberOf Phaser.Loader + * @memberof Phaser.Loader * @constructor * @since 3.0.0 * @@ -3816,7 +4116,7 @@ var File = new Class({ * Only set if loading via XHR. * * @name Phaser.Loader.File#percentComplete - * @type {float} + * @type {number} * @default -1 * @since 3.0.0 */ @@ -4153,7 +4453,7 @@ var File = new Class({ var type = this.type; this.loader.emit('filecomplete', key, type, data); - this.loader.emit('filecomplete_' + type + '_' + key, key, type, data); + this.loader.emit('filecomplete-' + type + '-' + key, key, type, data); this.loader.flagForRemoval(this); }, @@ -4228,8 +4528,8 @@ module.exports = File; /***/ }), -/* 20 */ -/***/ (function(module, exports, __webpack_require__) { +/* 22 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -4238,136 +4538,83 @@ module.exports = File; */ /** - * Global consts. + * Takes a reference to the Canvas Renderer, a Canvas Rendering Context, a Game Object, a Camera and a parent matrix + * and then performs the following steps: * - * @ignore + * 1) Checks the alpha of the source combined with the Camera alpha. If 0 or less it aborts. + * 2) Takes the Camera and Game Object matrix and multiplies them, combined with the parent matrix if given. + * 3) Sets the blend mode of the context to be that used by the Game Object. + * 4) Sets the alpha value of the context to be that used by the Game Object combined with the Camera. + * 5) Saves the context state. + * 6) Sets the final matrix values into the context via setTransform. + * + * This function is only meant to be used internally. Most of the Canvas Renderer classes use it. + * + * @function Phaser.Renderer.Canvas.SetTransform + * @since 3.12.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {CanvasRenderingContext2D} ctx - The canvas context to set the transform on. + * @param {Phaser.GameObjects.GameObject} src - The Game Object being rendered. Can be any type that extends the base class. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A parent transform matrix to apply to the Game Object before rendering. + * + * @return {boolean} `true` if the Game Object context was set, otherwise `false`. */ +var SetTransform = function (renderer, ctx, src, camera, parentMatrix) +{ + var alpha = camera.alpha * src.alpha; -var CONST = { + if (alpha <= 0) + { + // Nothing to see, so don't waste time calculating stuff + return false; + } - /** - * Phaser Release Version - * - * @name Phaser.VERSION - * @readOnly - * @type {string} - * @since 3.0.0 - */ - VERSION: '3.10.1', + var camMatrix = renderer._tempMatrix1.copyFromArray(camera.matrix.matrix); + var gameObjectMatrix = renderer._tempMatrix2.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + var calcMatrix = renderer._tempMatrix3; - BlendModes: __webpack_require__(51), + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); - ScaleModes: __webpack_require__(59), + // Undo the camera scroll + gameObjectMatrix.e = src.x; + gameObjectMatrix.f = src.y; - /** - * AUTO Detect Renderer. - * - * @name Phaser.AUTO - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - AUTO: 0, + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(gameObjectMatrix, calcMatrix); + } + else + { + gameObjectMatrix.e -= camera.scrollX * src.scrollFactorX; + gameObjectMatrix.f -= camera.scrollY * src.scrollFactorY; - /** - * Canvas Renderer. - * - * @name Phaser.CANVAS - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - CANVAS: 1, + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(gameObjectMatrix, calcMatrix); + } - /** - * WebGL Renderer. - * - * @name Phaser.WEBGL - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - WEBGL: 2, + // Blend Mode + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - /** - * Headless Renderer. - * - * @name Phaser.HEADLESS - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - HEADLESS: 3, + // Alpha + ctx.globalAlpha = alpha; - /** - * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead - * to help you remember what the value is doing in your code. - * - * @name Phaser.FOREVER - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - FOREVER: -1, + ctx.save(); - /** - * Direction constant. - * - * @name Phaser.NONE - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - NONE: 4, - - /** - * Direction constant. - * - * @name Phaser.UP - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - UP: 5, - - /** - * Direction constant. - * - * @name Phaser.DOWN - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - DOWN: 6, - - /** - * Direction constant. - * - * @name Phaser.LEFT - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - LEFT: 7, - - /** - * Direction constant. - * - * @name Phaser.RIGHT - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - RIGHT: 8 + calcMatrix.setToContext(ctx); + return true; }; -module.exports = CONST; +module.exports = SetTransform; /***/ }), -/* 21 */ -/***/ (function(module, exports, __webpack_require__) { +/* 23 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -4375,90 +4622,28 @@ module.exports = CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); - /** - * @typedef {object} GetTilesWithinFilteringOptions + * Force a value within the boundaries by clamping it to the range `min`, `max`. * - * @property {boolean} [isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. - * @property {boolean} [isColliding=false] - If true, only return tiles that collide on at least one side. - * @property {boolean} [hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. - */ - -/** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @function Phaser.Tilemaps.Components.GetTilesWithin - * @private + * @function Phaser.Math.Clamp * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {object} GetTilesWithinFilteringOptions - Optional filters to apply when getting the tiles. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + * @param {number} value - The value to be clamped. + * @param {number} min - The minimum bounds. + * @param {number} max - The maximum bounds. + * + * @return {number} The clamped value. */ -var GetTilesWithin = function (tileX, tileY, width, height, filteringOptions, layer) +var Clamp = function (value, min, max) { - if (tileX === undefined) { tileX = 0; } - if (tileY === undefined) { tileY = 0; } - if (width === undefined) { width = layer.width; } - if (height === undefined) { height = layer.height; } - - var isNotEmpty = GetFastValue(filteringOptions, 'isNotEmpty', false); - var isColliding = GetFastValue(filteringOptions, 'isColliding', false); - var hasInterestingFace = GetFastValue(filteringOptions, 'hasInterestingFace', false); - - // Clip x, y to top left of map, while shrinking width/height to match. - if (tileX < 0) - { - width += tileX; - tileX = 0; - } - if (tileY < 0) - { - height += tileY; - tileY = 0; - } - - // Clip width and height to bottom right of map. - if (tileX + width > layer.width) - { - width = Math.max(layer.width - tileX, 0); - } - if (tileY + height > layer.height) - { - height = Math.max(layer.height - tileY, 0); - } - - var results = []; - - for (var ty = tileY; ty < tileY + height; ty++) - { - for (var tx = tileX; tx < tileX + width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile !== null) - { - if (isNotEmpty && tile.index === -1) { continue; } - if (isColliding && !tile.collides) { continue; } - if (hasInterestingFace && !tile.hasInterestingFace) { continue; } - results.push(tile); - } - } - } - - return results; + return Math.max(min, Math.min(max, value)); }; -module.exports = GetTilesWithin; +module.exports = Clamp; /***/ }), -/* 22 */ +/* 24 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -4467,8 +4652,8 @@ module.exports = GetTilesWithin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(20); -var Smoothing = __webpack_require__(131); +var CONST = __webpack_require__(26); +var Smoothing = __webpack_require__(120); // The pool into which the canvas elements are placed. var pool = []; @@ -4719,7 +4904,7 @@ module.exports = CanvasPool(); /***/ }), -/* 23 */ +/* 25 */ /***/ (function(module, exports) { /** @@ -4729,27 +4914,64 @@ module.exports = CanvasPool(); */ /** - * Force a value within the boundaries by clamping it to the range `min`, `max`. + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then sets it to the given value. * - * @function Phaser.Math.Clamp - * @since 3.0.0 + * The optional `step` property is applied incrementally, multiplied by each item in the array. * - * @param {number} value - The value to be clamped. - * @param {number} min - The minimum bounds. - * @param {number} max - The maximum bounds. + * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` * - * @return {number} The clamped value. + * @function Phaser.Actions.PropertyValueSet + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to set the property to. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. */ -var Clamp = function (value, min, max) +var PropertyValueSet = function (items, key, value, step, index, direction) { - return Math.max(min, Math.min(max, value)); + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] = value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] = value + (t * step); + t++; + } + } + + return items; }; -module.exports = Clamp; +module.exports = PropertyValueSet; /***/ }), -/* 24 */ +/* 26 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -4758,9 +4980,448 @@ module.exports = Clamp; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(51); -var GetAdvancedValue = __webpack_require__(10); -var ScaleModes = __webpack_require__(59); +/** + * Global consts. + * + * @ignore + */ + +var CONST = { + + /** + * Phaser Release Version + * + * @name Phaser.VERSION + * @readonly + * @type {string} + * @since 3.0.0 + */ + VERSION: '3.15.1', + + BlendModes: __webpack_require__(66), + + ScaleModes: __webpack_require__(94), + + /** + * AUTO Detect Renderer. + * + * @name Phaser.AUTO + * @readonly + * @type {integer} + * @since 3.0.0 + */ + AUTO: 0, + + /** + * Canvas Renderer. + * + * @name Phaser.CANVAS + * @readonly + * @type {integer} + * @since 3.0.0 + */ + CANVAS: 1, + + /** + * WebGL Renderer. + * + * @name Phaser.WEBGL + * @readonly + * @type {integer} + * @since 3.0.0 + */ + WEBGL: 2, + + /** + * Headless Renderer. + * + * @name Phaser.HEADLESS + * @readonly + * @type {integer} + * @since 3.0.0 + */ + HEADLESS: 3, + + /** + * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead + * to help you remember what the value is doing in your code. + * + * @name Phaser.FOREVER + * @readonly + * @type {integer} + * @since 3.0.0 + */ + FOREVER: -1, + + /** + * Direction constant. + * + * @name Phaser.NONE + * @readonly + * @type {integer} + * @since 3.0.0 + */ + NONE: 4, + + /** + * Direction constant. + * + * @name Phaser.UP + * @readonly + * @type {integer} + * @since 3.0.0 + */ + UP: 5, + + /** + * Direction constant. + * + * @name Phaser.DOWN + * @readonly + * @type {integer} + * @since 3.0.0 + */ + DOWN: 6, + + /** + * Direction constant. + * + * @name Phaser.LEFT + * @readonly + * @type {integer} + * @since 3.0.0 + */ + LEFT: 7, + + /** + * Direction constant. + * + * @name Phaser.RIGHT + * @readonly + * @type {integer} + * @since 3.0.0 + */ + RIGHT: 8 + +}; + +module.exports = CONST; + + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var Line = __webpack_require__(54); + +/** + * @classdesc + * The Shape Game Object is a base class for the various different shapes, such as the Arc, Star or Polygon. + * You cannot add a Shape directly to your Scene, it is meant as a base for your own custom Shape classes. + * + * @class Shape + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {string} [type] - The internal type of the Shape. + * @param {any} [data] - The data of the source shape geometry, if any. + */ +var Shape = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Transform, + Components.Visible + ], + + initialize: + + function Shape (scene, type, data) + { + if (type === undefined) { type = 'Shape'; } + + GameObject.call(this, scene, type); + + /** + * The source Shape data. Typically a geometry object. + * You should not manipulate this directly. + * + * @name Phaser.GameObjects.Shape#data + * @type {any} + * @readonly + * @since 3.13.0 + */ + this.geom = data; + + /** + * Holds the polygon path data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathData + * @type {number[]} + * @readonly + * @since 3.13.0 + */ + this.pathData = []; + + /** + * Holds the earcut polygon path index data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathIndexes + * @type {integer[]} + * @readonly + * @since 3.13.0 + */ + this.pathIndexes = []; + + /** + * The fill color used by this Shape. + * + * @name Phaser.GameObjects.Shape#fillColor + * @type {number} + * @since 3.13.0 + */ + this.fillColor = 0xffffff; + + /** + * The fill alpha value used by this Shape. + * + * @name Phaser.GameObjects.Shape#fillAlpha + * @type {number} + * @since 3.13.0 + */ + this.fillAlpha = 1; + + /** + * The stroke color used by this Shape. + * + * @name Phaser.GameObjects.Shape#strokeColor + * @type {number} + * @since 3.13.0 + */ + this.strokeColor = 0xffffff; + + /** + * The stroke alpha value used by this Shape. + * + * @name Phaser.GameObjects.Shape#strokeAlpha + * @type {number} + * @since 3.13.0 + */ + this.strokeAlpha = 1; + + /** + * The stroke line width used by this Shape. + * + * @name Phaser.GameObjects.Shape#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Controls if this Shape is filled or not. + * Note that some Shapes do not support being filled (such as Line shapes) + * + * @name Phaser.GameObjects.Shape#isFilled + * @type {boolean} + * @since 3.13.0 + */ + this.isFilled = false; + + /** + * Controls if this Shape is stroked or not. + * Note that some Shapes do not support being stroked (such as Iso Box shapes) + * + * @name Phaser.GameObjects.Shape#isStroked + * @type {boolean} + * @since 3.13.0 + */ + this.isStroked = false; + + /** + * Controls if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * @name Phaser.GameObjects.Shape#closePath + * @type {boolean} + * @since 3.13.0 + */ + this.closePath = true; + + /** + * Private internal value. + * A Line used when parsing internal path data to avoid constant object re-creation. + * + * @name Phaser.GameObjects.Curve#_tempLine + * @type {Phaser.Geom.Line} + * @private + * @since 3.13.0 + */ + this._tempLine = new Line(); + + this.initPipeline(); + }, + + /** + * Sets the fill color and alpha for this Shape. + * + * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. + * + * Note that some Shapes do not support fill colors, such as the Line shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setFillStyle + * @since 3.13.0 + * + * @param {number} [color] - The color used to fill this shape. If not provided the Shape will not be filled. + * @param {number} [alpha=1] - The alpha value used when filling this shape, if a fill color is given. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (color === undefined) + { + this.isFilled = false; + } + else + { + this.fillColor = color; + this.fillAlpha = alpha; + this.isFilled = true; + } + + return this; + }, + + /** + * Sets the stroke color and alpha for this Shape. + * + * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. + * + * Note that some Shapes do not support being stroked, such as the Iso Box shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setStrokeStyle + * @since 3.13.0 + * + * @param {number} [color] - The color used to stroke this shape. If not provided the Shape will not be stroked. + * @param {number} [alpha=1] - The alpha value used when stroking this shape, if a stroke color is given. + * + * @return {this} This Game Object instance. + */ + setStrokeStyle: function (lineWidth, color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (lineWidth === undefined) + { + this.isStroked = false; + } + else + { + this.lineWidth = lineWidth; + this.strokeColor = color; + this.strokeAlpha = alpha; + this.isStroked = true; + } + + return this; + }, + + /** + * Sets if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setClosePath + * @since 3.13.0 + * + * @param {boolean} value - Set to `true` if the Shape should be closed when stroked, otherwise `false`. + * + * @return {this} This Game Object instance. + */ + setClosePath: function (value) + { + this.closePath = value; + + return this; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Shape#preDestroy + * @protected + * @since 3.13.0 + */ + preDestroy: function () + { + this.geom = null; + this._tempLine = null; + this.pathData = []; + this.pathIndexes = []; + } + +}); + +module.exports = Shape; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(66); +var GetAdvancedValue = __webpack_require__(12); +var ScaleModes = __webpack_require__(94); /** * @typedef {object} GameObjectConfig @@ -4902,74 +5563,7 @@ module.exports = BuildGameObject; /***/ }), -/* 25 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, - * and then sets it to the given value. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` - * - * @function Phaser.Actions.PropertyValueSet - * @since 3.3.0 - * - * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] - * - * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. - * @param {string} key - The property to be updated. - * @param {number} value - The amount to set the property to. - * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. - * @param {integer} [index=0] - An optional offset to start searching from within the items array. - * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. - * - * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. - */ -var PropertyValueSet = function (items, key, value, step, index, direction) -{ - if (step === undefined) { step = 0; } - if (index === undefined) { index = 0; } - if (direction === undefined) { direction = 1; } - - var i; - var t = 0; - var end = items.length; - - if (direction === 1) - { - // Start to End - for (i = index; i < end; i++) - { - items[i][key] = value + (t * step); - t++; - } - } - else - { - // End to Start - for (i = index; i >= 0; i--) - { - items[i][key] = value + (t * step); - t++; - } - } - - return items; -}; - -module.exports = PropertyValueSet; - - -/***/ }), -/* 26 */ +/* 29 */ /***/ (function(module, exports) { /** @@ -5024,142 +5618,3126 @@ module.exports = { /***/ }), -/* 27 */ +/* 30 */ /***/ (function(module, exports) { /** * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * @namespace Phaser.Renderer.WebGL.Utils - * @since 3.0.0 + * Sets the fillStyle on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#FillStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the fill style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the fill style from. */ -module.exports = { +var FillStyleCanvas = function (ctx, src, altColor) +{ + var fillColor = (altColor) ? altColor : src.fillColor; + var fillAlpha = src.fillAlpha; - /** - * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 - * - * @function Phaser.Renderer.WebGL.Utils.getTintFromFloats - * @since 3.0.0 - * - * @param {number} r - Red component in a range from 0.0 to 1.0 - * @param {number} g - [description] - * @param {number} b - [description] - * @param {number} a - Alpha component in a range from 0.0 to 1.0 - * - * @return {number} [description] - */ - getTintFromFloats: function (r, g, b, a) - { - var ur = ((r * 255.0)|0) & 0xFF; - var ug = ((g * 255.0)|0) & 0xFF; - var ub = ((b * 255.0)|0) & 0xFF; - var ua = ((a * 255.0)|0) & 0xFF; - - return ((ua << 24) | (ur << 16) | (ug << 8) | ub) >>> 0; - }, - - /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a Uint32 - * - * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlpha - * @since 3.0.0 - * - * @param {number} rgb - Uint24 representing RGB components - * @param {number} a - Float32 representing Alpha component - * - * @return {number} Packed RGBA as Uint32 - */ - getTintAppendFloatAlpha: function (rgb, a) - { - var ua = ((a * 255.0)|0) & 0xFF; - return ((ua << 24) | rgb) >>> 0; - }, - - /** - * Packs a Uint24, representing RGB components, with a Float32, representing - * the alpha component, with a range between 0.0 and 1.0 and return a - * swizzled Uint32 - * - * @function Phaser.Renderer.WebGL.Utils.getTintAppendFloatAlphaAndSwap - * @since 3.0.0 - * - * @param {number} rgb - Uint24 representing RGB components - * @param {number} a - Float32 representing Alpha component - * - * @return {number} Packed RGBA as Uint32 - */ - getTintAppendFloatAlphaAndSwap: function (rgb, a) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - var ua = ((a * 255.0)|0) & 0xFF; - - return ((ua << 24) | (ub << 16) | (ug << 8) | ur) >>> 0; - }, - - /** - * Unpacks a Uint24 RGB into an array of floats of ranges of 0.0 and 1.0 - * - * @function Phaser.Renderer.WebGL.Utils.getFloatsFromUintRGB - * @since 3.0.0 - * - * @param {number} rgb - RGB packed as a Uint24 - * - * @return {array} Array of floats representing each component as a float - */ - getFloatsFromUintRGB: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - return [ ur / 255.0, ug / 255.0, ub / 255.0 ]; - }, - - /** - * Counts how many attributes of 32 bits a vertex has - * - * @function Phaser.Renderer.WebGL.Utils.getComponentCount - * @since 3.0.0 - * - * @param {array} attributes - Array of attributes - * @param {WebGLRenderingContext} glContext - WebGLContext used for check types - * - * @return {number} Count of 32 bit attributes in vertex - */ - getComponentCount: function (attributes, glContext) - { - var count = 0; - - for (var index = 0; index < attributes.length; ++index) - { - var element = attributes[index]; - - if (element.type === glContext.FLOAT) - { - count += element.size; - } - else - { - count += 1; // We'll force any other type to be 32 bit. for now - } - } - - return count; - } + var red = ((fillColor & 0xFF0000) >>> 16); + var green = ((fillColor & 0xFF00) >>> 8); + var blue = (fillColor & 0xFF); + ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; }; +module.exports = FillStyleCanvas; + /***/ }), -/* 28 */ +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(16); + +/** + * Convert the given angle from degrees, to the equivalent angle in radians. + * + * @function Phaser.Math.DegToRad + * @since 3.0.0 + * + * @param {integer} degrees - The angle (in degrees) to convert to radians. + * + * @return {number} The given angle converted to radians. + */ +var DegToRad = function (degrees) +{ + return degrees * CONST.DEG_TO_RAD; +}; + +module.exports = DegToRad; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, + * and then adds the given value to it. + * + * The optional `step` property is applied incrementally, multiplied by each item in the array. + * + * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` + * + * @function Phaser.Actions.PropertyValueInc + * @since 3.3.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] + * + * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. + * @param {string} key - The property to be updated. + * @param {number} value - The amount to be added to the property. + * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. + * @param {integer} [index=0] - An optional offset to start searching from within the items array. + * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. + * + * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. + */ +var PropertyValueInc = function (items, key, value, step, index, direction) +{ + if (step === undefined) { step = 0; } + if (index === undefined) { index = 0; } + if (direction === undefined) { direction = 1; } + + var i; + var t = 0; + var end = items.length; + + if (direction === 1) + { + // Start to End + for (i = index; i < end; i++) + { + items[i][key] += value + (t * step); + t++; + } + } + else + { + // End to Start + for (i = index; i >= 0; i--) + { + items[i][key] += value + (t * step); + t++; + } + } + + return items; +}; + +module.exports = PropertyValueInc; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {/** +* The `Matter.Common` module contains utility functions that are common to all modules. +* +* @class Common +*/ + +var Common = {}; + +module.exports = Common; + +(function() { + + Common._nextId = 0; + Common._seed = 0; + Common._nowStartTime = +(new Date()); + + /** + * Extends the object in the first argument using the object in the second argument. + * @method extend + * @param {} obj + * @param {boolean} deep + * @return {} obj extended + */ + Common.extend = function(obj, deep) { + var argsStart, + args, + deepClone; + + if (typeof deep === 'boolean') { + argsStart = 2; + deepClone = deep; + } else { + argsStart = 1; + deepClone = true; + } + + for (var i = argsStart; i < arguments.length; i++) { + var source = arguments[i]; + + if (source) { + for (var prop in source) { + if (deepClone && source[prop] && source[prop].constructor === Object) { + if (!obj[prop] || obj[prop].constructor === Object) { + obj[prop] = obj[prop] || {}; + Common.extend(obj[prop], deepClone, source[prop]); + } else { + obj[prop] = source[prop]; + } + } else { + obj[prop] = source[prop]; + } + } + } + } + + return obj; + }; + + /** + * Creates a new clone of the object, if deep is true references will also be cloned. + * @method clone + * @param {} obj + * @param {bool} deep + * @return {} obj cloned + */ + Common.clone = function(obj, deep) { + return Common.extend({}, deep, obj); + }; + + /** + * Returns the list of keys for the given object. + * @method keys + * @param {} obj + * @return {string[]} keys + */ + Common.keys = function(obj) { + if (Object.keys) + return Object.keys(obj); + + // avoid hasOwnProperty for performance + var keys = []; + for (var key in obj) + keys.push(key); + return keys; + }; + + /** + * Returns the list of values for the given object. + * @method values + * @param {} obj + * @return {array} Array of the objects property values + */ + Common.values = function(obj) { + var values = []; + + if (Object.keys) { + var keys = Object.keys(obj); + for (var i = 0; i < keys.length; i++) { + values.push(obj[keys[i]]); + } + return values; + } + + // avoid hasOwnProperty for performance + for (var key in obj) + values.push(obj[key]); + return values; + }; + + /** + * Gets a value from `base` relative to the `path` string. + * @method get + * @param {} obj The base object + * @param {string} path The path relative to `base`, e.g. 'Foo.Bar.baz' + * @param {number} [begin] Path slice begin + * @param {number} [end] Path slice end + * @return {} The object at the given path + */ + Common.get = function(obj, path, begin, end) { + path = path.split('.').slice(begin, end); + + for (var i = 0; i < path.length; i += 1) { + obj = obj[path[i]]; + } + + return obj; + }; + + /** + * Sets a value on `base` relative to the given `path` string. + * @method set + * @param {} obj The base object + * @param {string} path The path relative to `base`, e.g. 'Foo.Bar.baz' + * @param {} val The value to set + * @param {number} [begin] Path slice begin + * @param {number} [end] Path slice end + * @return {} Pass through `val` for chaining + */ + Common.set = function(obj, path, val, begin, end) { + var parts = path.split('.').slice(begin, end); + Common.get(obj, path, 0, -1)[parts[parts.length - 1]] = val; + return val; + }; + + /** + * Shuffles the given array in-place. + * The function uses a seeded random generator. + * @method shuffle + * @param {array} array + * @return {array} array shuffled randomly + */ + Common.shuffle = function(array) { + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Common.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + return array; + }; + + /** + * Randomly chooses a value from a list with equal probability. + * The function uses a seeded random generator. + * @method choose + * @param {array} choices + * @return {object} A random choice object from the array + */ + Common.choose = function(choices) { + return choices[Math.floor(Common.random() * choices.length)]; + }; + + /** + * Returns true if the object is a HTMLElement, otherwise false. + * @method isElement + * @param {object} obj + * @return {boolean} True if the object is a HTMLElement, otherwise false + */ + Common.isElement = function(obj) { + if (typeof HTMLElement !== 'undefined') { + return obj instanceof HTMLElement; + } + + return !!(obj && obj.nodeType && obj.nodeName); + }; + + /** + * Returns true if the object is an array. + * @method isArray + * @param {object} obj + * @return {boolean} True if the object is an array, otherwise false + */ + Common.isArray = function(obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; + + /** + * Returns true if the object is a function. + * @method isFunction + * @param {object} obj + * @return {boolean} True if the object is a function, otherwise false + */ + Common.isFunction = function(obj) { + return typeof obj === "function"; + }; + + /** + * Returns true if the object is a plain object. + * @method isPlainObject + * @param {object} obj + * @return {boolean} True if the object is a plain object, otherwise false + */ + Common.isPlainObject = function(obj) { + return typeof obj === 'object' && obj.constructor === Object; + }; + + /** + * Returns true if the object is a string. + * @method isString + * @param {object} obj + * @return {boolean} True if the object is a string, otherwise false + */ + Common.isString = function(obj) { + return toString.call(obj) === '[object String]'; + }; + + /** + * Returns the given value clamped between a minimum and maximum value. + * @method clamp + * @param {number} value + * @param {number} min + * @param {number} max + * @return {number} The value clamped between min and max inclusive + */ + Common.clamp = function(value, min, max) { + if (value < min) + return min; + if (value > max) + return max; + return value; + }; + + /** + * Returns the sign of the given value. + * @method sign + * @param {number} value + * @return {number} -1 if negative, +1 if 0 or positive + */ + Common.sign = function(value) { + return value < 0 ? -1 : 1; + }; + + /** + * Returns the current timestamp since the time origin (e.g. from page load). + * The result will be high-resolution including decimal places if available. + * @method now + * @return {number} the current timestamp + */ + Common.now = function() { + if (window.performance) { + if (window.performance.now) { + return window.performance.now(); + } else if (window.performance.webkitNow) { + return window.performance.webkitNow(); + } + } + + return (new Date()) - Common._nowStartTime; + }; + + /** + * Returns a random value between a minimum and a maximum value inclusive. + * The function uses a seeded random generator. + * @method random + * @param {number} min + * @param {number} max + * @return {number} A random number between min and max inclusive + */ + Common.random = function(min, max) { + min = (typeof min !== "undefined") ? min : 0; + max = (typeof max !== "undefined") ? max : 1; + return min + _seededRandom() * (max - min); + }; + + var _seededRandom = function() { + // https://en.wikipedia.org/wiki/Linear_congruential_generator + Common._seed = (Common._seed * 9301 + 49297) % 233280; + return Common._seed / 233280; + }; + + /** + * Converts a CSS hex colour string into an integer. + * @method colorToNumber + * @param {string} colorString + * @return {number} An integer representing the CSS hex string + */ + Common.colorToNumber = function(colorString) { + colorString = colorString.replace('#',''); + + if (colorString.length == 3) { + colorString = colorString.charAt(0) + colorString.charAt(0) + + colorString.charAt(1) + colorString.charAt(1) + + colorString.charAt(2) + colorString.charAt(2); + } + + return parseInt(colorString, 16); + }; + + /** + * The console logging level to use, where each level includes all levels above and excludes the levels below. + * The default level is 'debug' which shows all console messages. + * + * Possible level values are: + * - 0 = None + * - 1 = Debug + * - 2 = Info + * - 3 = Warn + * - 4 = Error + * @property Common.logLevel + * @type {Number} + * @default 1 + */ + Common.logLevel = 1; + + /** + * Shows a `console.log` message only if the current `Common.logLevel` allows it. + * The message will be prefixed with 'matter-js' to make it easily identifiable. + * @method log + * @param ...objs {} The objects to log. + */ + Common.log = function() { + if (console && Common.logLevel > 0 && Common.logLevel <= 3) { + console.log.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); + } + }; + + /** + * Shows a `console.info` message only if the current `Common.logLevel` allows it. + * The message will be prefixed with 'matter-js' to make it easily identifiable. + * @method info + * @param ...objs {} The objects to log. + */ + Common.info = function() { + if (console && Common.logLevel > 0 && Common.logLevel <= 2) { + console.info.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); + } + }; + + /** + * Shows a `console.warn` message only if the current `Common.logLevel` allows it. + * The message will be prefixed with 'matter-js' to make it easily identifiable. + * @method warn + * @param ...objs {} The objects to log. + */ + Common.warn = function() { + if (console && Common.logLevel > 0 && Common.logLevel <= 3) { + console.warn.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); + } + }; + + /** + * Returns the next unique sequential ID. + * @method nextId + * @return {Number} Unique sequential ID + */ + Common.nextId = function() { + return Common._nextId++; + }; + + /** + * A cross browser compatible indexOf implementation. + * @method indexOf + * @param {array} haystack + * @param {object} needle + * @return {number} The position of needle in haystack, otherwise -1. + */ + Common.indexOf = function(haystack, needle) { + if (haystack.indexOf) + return haystack.indexOf(needle); + + for (var i = 0; i < haystack.length; i++) { + if (haystack[i] === needle) + return i; + } + + return -1; + }; + + /** + * A cross browser compatible array map implementation. + * @method map + * @param {array} list + * @param {function} func + * @return {array} Values from list transformed by func. + */ + Common.map = function(list, func) { + if (list.map) { + return list.map(func); + } + + var mapped = []; + + for (var i = 0; i < list.length; i += 1) { + mapped.push(func(list[i])); + } + + return mapped; + }; + + /** + * Takes a directed graph and returns the partially ordered set of vertices in topological order. + * Circular dependencies are allowed. + * @method topologicalSort + * @param {object} graph + * @return {array} Partially ordered set of vertices in topological order. + */ + Common.topologicalSort = function(graph) { + // https://github.com/mgechev/javascript-algorithms + // Copyright (c) Minko Gechev (MIT license) + // Modifications: tidy formatting and naming + var result = [], + visited = [], + temp = []; + + for (var node in graph) { + if (!visited[node] && !temp[node]) { + Common._topologicalSort(node, visited, temp, graph, result); + } + } + + return result; + }; + + Common._topologicalSort = function(node, visited, temp, graph, result) { + var neighbors = graph[node] || []; + temp[node] = true; + + for (var i = 0; i < neighbors.length; i += 1) { + var neighbor = neighbors[i]; + + if (temp[neighbor]) { + // skip circular dependencies + continue; + } + + if (!visited[neighbor]) { + Common._topologicalSort(neighbor, visited, temp, graph, result); + } + } + + temp[node] = false; + visited[node] = true; + + result.push(node); + }; + + /** + * Takes _n_ functions as arguments and returns a new function that calls them in order. + * The arguments applied when calling the new function will also be applied to every function passed. + * The value of `this` refers to the last value returned in the chain that was not `undefined`. + * Therefore if a passed function does not return a value, the previously returned value is maintained. + * After all passed functions have been called the new function returns the last returned value (if any). + * If any of the passed functions are a chain, then the chain will be flattened. + * @method chain + * @param ...funcs {function} The functions to chain. + * @return {function} A new function that calls the passed functions in order. + */ + Common.chain = function() { + var funcs = []; + + for (var i = 0; i < arguments.length; i += 1) { + var func = arguments[i]; + + if (func._chained) { + // flatten already chained functions + funcs.push.apply(funcs, func._chained); + } else { + funcs.push(func); + } + } + + var chain = function() { + // https://github.com/GoogleChrome/devtools-docs/issues/53#issuecomment-51941358 + var lastResult, + args = new Array(arguments.length); + + for (var i = 0, l = arguments.length; i < l; i++) { + args[i] = arguments[i]; + } + + for (i = 0; i < funcs.length; i += 1) { + var result = funcs[i].apply(lastResult, args); + + if (typeof result !== 'undefined') { + lastResult = result; + } + } + + return lastResult; + }; + + chain._chained = funcs; + + return chain; + }; + + /** + * Chains a function to excute before the original function on the given `path` relative to `base`. + * See also docs for `Common.chain`. + * @method chainPathBefore + * @param {} base The base object + * @param {string} path The path relative to `base` + * @param {function} func The function to chain before the original + * @return {function} The chained function that replaced the original + */ + Common.chainPathBefore = function(base, path, func) { + return Common.set(base, path, Common.chain( + func, + Common.get(base, path) + )); + }; + + /** + * Chains a function to excute after the original function on the given `path` relative to `base`. + * See also docs for `Common.chain`. + * @method chainPathAfter + * @param {} base The base object + * @param {string} path The path relative to `base` + * @param {function} func The function to chain after the original + * @return {function} The chained function that replaced the original + */ + Common.chainPathAfter = function(base, path, func) { + return Common.set(base, path, Common.chain( + Common.get(base, path), + func + )); + }; + + /** + * Used to require external libraries outside of the bundle. + * It first looks for the `globalName` on the environment's global namespace. + * If the global is not found, it will fall back to using the standard `require` using the `moduleName`. + * @private + * @method _requireGlobal + * @param {string} globalName The global module name + * @param {string} moduleName The fallback CommonJS module name + * @return {} The loaded module + */ + Common._requireGlobal = function(globalName, moduleName) { + var obj = (typeof window !== 'undefined' ? window[globalName] : typeof global !== 'undefined' ? global[globalName] : null); + + // Breaks webpack :( + // return obj || require(moduleName); + + return obj; + }; +})(); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(200))) + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(102); +var GetTilesWithin = __webpack_require__(17); + +/** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @function Phaser.Tilemaps.Components.CalculateFacesWithin + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var CalculateFacesWithin = function (tileX, tileY, width, height, layer) +{ + var above = null; + var below = null; + var left = null; + var right = null; + + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + if (tile) + { + if (tile.collides) + { + above = GetTileAt(tile.x, tile.y - 1, true, layer); + below = GetTileAt(tile.x, tile.y + 1, true, layer); + left = GetTileAt(tile.x - 1, tile.y, true, layer); + right = GetTileAt(tile.x + 1, tile.y, true, layer); + + tile.faceTop = (above && above.collides) ? false : true; + tile.faceBottom = (below && below.collides) ? false : true; + tile.faceLeft = (left && left.collides) ? false : true; + tile.faceRight = (right && right.collides) ? false : true; + } + else + { + tile.resetFaces(); + } + } + } +}; + +module.exports = CalculateFacesWithin; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Arcade Physics consts. + * + * @ignore + */ + +var CONST = { + + /** + * Dynamic Body. + * + * @name Phaser.Physics.Arcade.DYNAMIC_BODY + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#physicsType + * @see Phaser.Physics.Arcade.Group#physicsType + */ + DYNAMIC_BODY: 0, + + /** + * Static Body. + * + * @name Phaser.Physics.Arcade.STATIC_BODY + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#physicsType + * @see Phaser.Physics.Arcade.StaticBody#physicsType + */ + STATIC_BODY: 1, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.GROUP + * @readonly + * @type {number} + * @since 3.0.0 + */ + GROUP: 2, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.TILEMAPLAYER + * @readonly + * @type {number} + * @since 3.0.0 + */ + TILEMAPLAYER: 3, + + /** + * Facing no direction (initial value). + * + * @name Phaser.Physics.Arcade.FACING_NONE + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_NONE: 10, + + /** + * Facing up. + * + * @name Phaser.Physics.Arcade.FACING_UP + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_UP: 11, + + /** + * Facing down. + * + * @name Phaser.Physics.Arcade.FACING_DOWN + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_DOWN: 12, + + /** + * Facing left. + * + * @name Phaser.Physics.Arcade.FACING_LEFT + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_LEFT: 13, + + /** + * Facing right. + * + * @name Phaser.Physics.Arcade.FACING_RIGHT + * @readonly + * @type {number} + * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing + */ + FACING_RIGHT: 14 + +}; + +module.exports = CONST; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the strokeStyle and lineWidth on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#LineStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the stroke style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the stroke style from. + */ +var LineStyleCanvas = function (ctx, src) +{ + var strokeColor = src.strokeColor; + var strokeAlpha = src.strokeAlpha; + + var red = ((strokeColor & 0xFF0000) >>> 16); + var green = ((strokeColor & 0xFF00) >>> 8); + var blue = (strokeColor & 0xFF); + + ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + strokeAlpha + ')'; + ctx.lineWidth = src.lineWidth; +}; + +module.exports = LineStyleCanvas; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetColor = __webpack_require__(177); +var GetColor32 = __webpack_require__(376); +var HSVToRGB = __webpack_require__(176); +var RGBToHSV = __webpack_require__(375); + +/** + * @classdesc + * The Color class holds a single color value and allows for easy modification and reading of it. + * + * @class Color + * @memberof Phaser.Display + * @constructor + * @since 3.0.0 + * + * @param {integer} [red=0] - The red color value. A number between 0 and 255. + * @param {integer} [green=0] - The green color value. A number between 0 and 255. + * @param {integer} [blue=0] - The blue color value. A number between 0 and 255. + * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + */ +var Color = new Class({ + + initialize: + + function Color (red, green, blue, alpha) + { + if (red === undefined) { red = 0; } + if (green === undefined) { green = 0; } + if (blue === undefined) { blue = 0; } + if (alpha === undefined) { alpha = 255; } + + /** + * The internal red color value. + * + * @name Phaser.Display.Color#r + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.r = 0; + + /** + * The internal green color value. + * + * @name Phaser.Display.Color#g + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.g = 0; + + /** + * The internal blue color value. + * + * @name Phaser.Display.Color#b + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this.b = 0; + + /** + * The internal alpha color value. + * + * @name Phaser.Display.Color#a + * @type {number} + * @private + * @default 255 + * @since 3.0.0 + */ + this.a = 255; + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#_h + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._h = 0; + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#_s + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._s = 0; + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @name Phaser.Display.Color#_v + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._v = 0; + + /** + * Is this color update locked? + * + * @name Phaser.Display.Color#_locked + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._locked = false; + + /** + * An array containing the calculated color values for WebGL use. + * + * @name Phaser.Display.Color#gl + * @type {number[]} + * @since 3.0.0 + */ + this.gl = [ 0, 0, 0, 1 ]; + + /** + * Pre-calculated internal color value. + * + * @name Phaser.Display.Color#_color + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color = 0; + + /** + * Pre-calculated internal color32 value. + * + * @name Phaser.Display.Color#_color32 + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._color32 = 0; + + /** + * Pre-calculated internal color rgb string value. + * + * @name Phaser.Display.Color#_rgba + * @type {string} + * @private + * @default '' + * @since 3.0.0 + */ + this._rgba = ''; + + this.setTo(red, green, blue, alpha); + }, + + /** + * Sets this color to be transparent. Sets all values to zero. + * + * @method Phaser.Display.Color#transparent + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + transparent: function () + { + this._locked = true; + + this.red = 0; + this.green = 0; + this.blue = 0; + this.alpha = 0; + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color of this Color component. + * + * @method Phaser.Display.Color#setTo + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + * @param {boolean} [updateHSV=true] - Update the HSV values after setting the RGB values? + * + * @return {Phaser.Display.Color} This Color object. + */ + setTo: function (red, green, blue, alpha, updateHSV) + { + if (alpha === undefined) { alpha = 255; } + if (updateHSV === undefined) { updateHSV = true; } + + this._locked = true; + + this.red = red; + this.green = green; + this.blue = blue; + this.alpha = alpha; + + this._locked = false; + + return this.update(updateHSV); + }, + + /** + * Sets the red, green, blue and alpha GL values of this Color component. + * + * @method Phaser.Display.Color#setGLTo + * @since 3.0.0 + * + * @param {number} red - The red color value. A number between 0 and 1. + * @param {number} green - The green color value. A number between 0 and 1. + * @param {number} blue - The blue color value. A number between 0 and 1. + * @param {number} [alpha=1] - The alpha value. A number between 0 and 1. + * + * @return {Phaser.Display.Color} This Color object. + */ + setGLTo: function (red, green, blue, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this._locked = true; + + this.redGL = red; + this.greenGL = green; + this.blueGL = blue; + this.alphaGL = alpha; + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color based on the color object given. + * + * @method Phaser.Display.Color#setFromRGB + * @since 3.0.0 + * + * @param {InputColorObject} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromRGB: function (color) + { + this._locked = true; + + this.red = color.r; + this.green = color.g; + this.blue = color.b; + + if (color.hasOwnProperty('a')) + { + this.alpha = color.a; + } + + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color based on the hue, saturation and lightness values given. + * + * @method Phaser.Display.Color#setFromHSV + * @since 3.13.0 + * + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromHSV: function (h, s, v) + { + return HSVToRGB(h, s, v, this); + }, + + /** + * Updates the internal cache values. + * + * @method Phaser.Display.Color#update + * @private + * @since 3.0.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + update: function (updateHSV) + { + if (updateHSV === undefined) { updateHSV = false; } + + if (this._locked) + { + return this; + } + + var r = this.r; + var g = this.g; + var b = this.b; + var a = this.a; + + this._color = GetColor(r, g, b); + this._color32 = GetColor32(r, g, b, a); + this._rgba = 'rgba(' + r + ',' + g + ',' + b + ',' + (a / 255) + ')'; + + if (updateHSV) + { + RGBToHSV(r, g, b, this); + } + + return this; + }, + + /** + * Updates the internal hsv cache values. + * + * @method Phaser.Display.Color#updateHSV + * @private + * @since 3.13.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + updateHSV: function () + { + var r = this.r; + var g = this.g; + var b = this.b; + + RGBToHSV(r, g, b, this); + + return this; + }, + + /** + * Returns a new Color component using the values from this one. + * + * @method Phaser.Display.Color#clone + * @since 3.0.0 + * + * @return {Phaser.Display.Color} A new Color object. + */ + clone: function () + { + return new Color(this.r, this.g, this.b, this.a); + }, + + /** + * Sets this Color object to be grayscaled based on the shade value given. + * + * @method Phaser.Display.Color#gray + * @since 3.13.0 + * + * @param {integer} shade - A value between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + gray: function (shade) + { + return this.setTo(shade, shade, shade); + }, + + /** + * Sets this Color object to be a random color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#random + * @since 3.13.0 + * + * @param {integer} [min=0] - The minimum random color value. Between 0 and 255. + * @param {integer} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + random: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var r = Math.floor(min + Math.random() * (max - min)); + var g = Math.floor(min + Math.random() * (max - min)); + var b = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(r, g, b); + }, + + /** + * Sets this Color object to be a random grayscale color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#randomGray + * @since 3.13.0 + * + * @param {integer} [min=0] - The minimum random color value. Between 0 and 255. + * @param {integer} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + randomGray: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var s = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(s, s, s); + }, + + /** + * Increase the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#saturate + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + saturate: function (amount) + { + this.s += amount / 100; + + return this; + }, + + /** + * Decrease the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#desaturate + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + desaturate: function (amount) + { + this.s -= amount / 100; + + return this; + }, + + /** + * Increase the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#lighten + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + lighten: function (amount) + { + this.v += amount / 100; + + return this; + }, + + /** + * Decrease the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#darken + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + darken: function (amount) + { + this.v -= amount / 100; + + return this; + }, + + /** + * Brighten this Color by the percentage amount given. + * + * @method Phaser.Display.Color#brighten + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + brighten: function (amount) + { + var r = this.r; + var g = this.g; + var b = this.b; + + r = Math.max(0, Math.min(255, r - Math.round(255 * - (amount / 100)))); + g = Math.max(0, Math.min(255, g - Math.round(255 * - (amount / 100)))); + b = Math.max(0, Math.min(255, b - Math.round(255 * - (amount / 100)))); + + return this.setTo(r, g, b); + }, + + /** + * The color of this Color component, not including the alpha channel. + * + * @name Phaser.Display.Color#color + * @type {number} + * @readonly + * @since 3.0.0 + */ + color: { + + get: function () + { + return this._color; + } + + }, + + /** + * The color of this Color component, including the alpha channel. + * + * @name Phaser.Display.Color#color32 + * @type {number} + * @readonly + * @since 3.0.0 + */ + color32: { + + get: function () + { + return this._color32; + } + + }, + + /** + * The color of this Color component as a string which can be used in CSS color values. + * + * @name Phaser.Display.Color#rgba + * @type {string} + * @readonly + * @since 3.0.0 + */ + rgba: { + + get: function () + { + return this._rgba; + } + + }, + + /** + * The red color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#redGL + * @type {number} + * @since 3.0.0 + */ + redGL: { + + get: function () + { + return this.gl[0]; + }, + + set: function (value) + { + this.gl[0] = Math.min(Math.abs(value), 1); + + this.r = Math.floor(this.gl[0] * 255); + + this.update(true); + } + + }, + + /** + * The green color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#greenGL + * @type {number} + * @since 3.0.0 + */ + greenGL: { + + get: function () + { + return this.gl[1]; + }, + + set: function (value) + { + this.gl[1] = Math.min(Math.abs(value), 1); + + this.g = Math.floor(this.gl[1] * 255); + + this.update(true); + } + + }, + + /** + * The blue color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#blueGL + * @type {number} + * @since 3.0.0 + */ + blueGL: { + + get: function () + { + return this.gl[2]; + }, + + set: function (value) + { + this.gl[2] = Math.min(Math.abs(value), 1); + + this.b = Math.floor(this.gl[2] * 255); + + this.update(true); + } + + }, + + /** + * The alpha color value, normalized to the range 0 to 1. + * + * @name Phaser.Display.Color#alphaGL + * @type {number} + * @since 3.0.0 + */ + alphaGL: { + + get: function () + { + return this.gl[3]; + }, + + set: function (value) + { + this.gl[3] = Math.min(Math.abs(value), 1); + + this.a = Math.floor(this.gl[3] * 255); + + this.update(); + } + + }, + + /** + * The red color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#red + * @type {number} + * @since 3.0.0 + */ + red: { + + get: function () + { + return this.r; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.r = Math.min(value, 255); + + this.gl[0] = value / 255; + + this.update(true); + } + + }, + + /** + * The green color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#green + * @type {number} + * @since 3.0.0 + */ + green: { + + get: function () + { + return this.g; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.g = Math.min(value, 255); + + this.gl[1] = value / 255; + + this.update(true); + } + + }, + + /** + * The blue color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#blue + * @type {number} + * @since 3.0.0 + */ + blue: { + + get: function () + { + return this.b; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.b = Math.min(value, 255); + + this.gl[2] = value / 255; + + this.update(true); + } + + }, + + /** + * The alpha color value, normalized to the range 0 to 255. + * + * @name Phaser.Display.Color#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this.a; + }, + + set: function (value) + { + value = Math.floor(Math.abs(value)); + + this.a = Math.min(value, 255); + + this.gl[3] = value / 255; + + this.update(); + } + + }, + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#h + * @type {number} + * @since 3.13.0 + */ + h: { + + get: function () + { + return this._h; + }, + + set: function (value) + { + this._h = value; + + HSVToRGB(value, this._s, this._v, this); + } + + }, + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#s + * @type {number} + * @since 3.13.0 + */ + s: { + + get: function () + { + return this._s; + }, + + set: function (value) + { + this._s = value; + + HSVToRGB(this._h, value, this._v, this); + } + + }, + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @name Phaser.Display.Color#v + * @type {number} + * @since 3.13.0 + */ + v: { + + get: function () + { + return this._v; + }, + + set: function (value) + { + this._v = value; + + HSVToRGB(this._h, this._s, value, this); + } + + } + +}); + +module.exports = Color; + + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Matrix used for display transformations for rendering. + * + * It is represented like so: + * + * ``` + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * ``` + * + * @class TransformMatrix + * @memberof Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {number} [a=1] - The Scale X value. + * @param {number} [b=0] - The Shear Y value. + * @param {number} [c=0] - The Shear X value. + * @param {number} [d=1] - The Scale Y value. + * @param {number} [tx=0] - The Translate X value. + * @param {number} [ty=0] - The Translate Y value. + */ +var TransformMatrix = new Class({ + + initialize: + + function TransformMatrix (a, b, c, d, tx, ty) + { + if (a === undefined) { a = 1; } + if (b === undefined) { b = 0; } + if (c === undefined) { c = 0; } + if (d === undefined) { d = 1; } + if (tx === undefined) { tx = 0; } + if (ty === undefined) { ty = 0; } + + /** + * The matrix values. + * + * @name Phaser.GameObjects.Components.TransformMatrix#matrix + * @type {Float32Array} + * @since 3.0.0 + */ + this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + + /** + * The decomposed matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * @type {object} + * @since 3.0.0 + */ + this.decomposedMatrix = { + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotation: 0 + }; + }, + + /** + * The Scale X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#a + * @type {number} + * @since 3.4.0 + */ + a: { + + get: function () + { + return this.matrix[0]; + }, + + set: function (value) + { + this.matrix[0] = value; + } + + }, + + /** + * The Shear Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#b + * @type {number} + * @since 3.4.0 + */ + b: { + + get: function () + { + return this.matrix[1]; + }, + + set: function (value) + { + this.matrix[1] = value; + } + + }, + + /** + * The Shear X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#c + * @type {number} + * @since 3.4.0 + */ + c: { + + get: function () + { + return this.matrix[2]; + }, + + set: function (value) + { + this.matrix[2] = value; + } + + }, + + /** + * The Scale Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#d + * @type {number} + * @since 3.4.0 + */ + d: { + + get: function () + { + return this.matrix[3]; + }, + + set: function (value) + { + this.matrix[3] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#e + * @type {number} + * @since 3.11.0 + */ + e: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#f + * @type {number} + * @since 3.11.0 + */ + f: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#tx + * @type {number} + * @since 3.4.0 + */ + tx: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#ty + * @type {number} + * @since 3.4.0 + */ + ty: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The rotation of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#rotation + * @type {number} + * @readonly + * @since 3.4.0 + */ + rotation: { + + get: function () + { + return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1); + } + + }, + + /** + * The horizontal scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleX + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleX: { + + get: function () + { + return Math.sqrt((this.a * this.a) + (this.c * this.c)); + } + + }, + + /** + * The vertical scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleY + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleY: { + + get: function () + { + return Math.sqrt((this.b * this.b) + (this.d * this.d)); + } + + }, + + /** + * Reset the Matrix to an identity matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + loadIdentity: function () + { + var matrix = this.matrix; + + matrix[0] = 1; + matrix[1] = 0; + matrix[2] = 0; + matrix[3] = 1; + matrix[4] = 0; + matrix[5] = 0; + + return this; + }, + + /** + * Translate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @since 3.0.0 + * + * @param {number} x - The horizontal translation value. + * @param {number} y - The vertical translation value. + * + * @return {this} This TransformMatrix. + */ + translate: function (x, y) + { + var matrix = this.matrix; + + matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; + matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; + + return this; + }, + + /** + * Scale the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#scale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale value. + * @param {number} y - The vertical scale value. + * + * @return {this} This TransformMatrix. + */ + scale: function (x, y) + { + var matrix = this.matrix; + + matrix[0] *= x; + matrix[1] *= x; + matrix[2] *= y; + matrix[3] *= y; + + return this; + }, + + /** + * Rotate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#rotate + * @since 3.0.0 + * + * @param {number} angle - The angle of rotation in radians. + * + * @return {this} This TransformMatrix. + */ + rotate: function (angle) + { + var sin = Math.sin(angle); + var cos = Math.cos(angle); + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + matrix[0] = a * cos + c * sin; + matrix[1] = b * cos + d * sin; + matrix[2] = a * -sin + c * cos; + matrix[3] = b * -sin + d * cos; + + return this; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiply + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - The Matrix to multiply by. + * @param {Phaser.GameObjects.Components.TransformMatrix} [out] - An optional Matrix to store the results in. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} Either this TransformMatrix, or the `out` Matrix, if given in the arguments. + */ + multiply: function (rhs, out) + { + var matrix = this.matrix; + var source = rhs.matrix; + + var localA = matrix[0]; + var localB = matrix[1]; + var localC = matrix[2]; + var localD = matrix[3]; + var localE = matrix[4]; + var localF = matrix[5]; + + var sourceA = source[0]; + var sourceB = source[1]; + var sourceC = source[2]; + var sourceD = source[3]; + var sourceE = source[4]; + var sourceF = source[5]; + + var destinationMatrix = (out === undefined) ? this : out; + + destinationMatrix.a = (sourceA * localA) + (sourceB * localC); + destinationMatrix.b = (sourceA * localB) + (sourceB * localD); + destinationMatrix.c = (sourceC * localA) + (sourceD * localC); + destinationMatrix.d = (sourceC * localB) + (sourceD * localD); + destinationMatrix.e = (sourceE * localA) + (sourceF * localC) + localE; + destinationMatrix.f = (sourceE * localB) + (sourceF * localD) + localF; + + return destinationMatrix; + }, + + /** + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiplyWithOffset + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * @param {number} offsetX - Horizontal offset to factor in to the multiplication. + * @param {number} offsetY - Vertical offset to factor in to the multiplication. + * + * @return {this} This TransformMatrix. + */ + multiplyWithOffset: function (src, offsetX, offsetY) + { + var matrix = this.matrix; + var otherMatrix = src.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + var pse = offsetX * a0 + offsetY * c0 + tx0; + var psf = offsetX * b0 + offsetY * d0 + ty0; + + var a1 = otherMatrix[0]; + var b1 = otherMatrix[1]; + var c1 = otherMatrix[2]; + var d1 = otherMatrix[3]; + var tx1 = otherMatrix[4]; + var ty1 = otherMatrix[5]; + + matrix[0] = a1 * a0 + b1 * c0; + matrix[1] = a1 * b0 + b1 * d0; + matrix[2] = c1 * a0 + d1 * c0; + matrix[3] = c1 * b0 + d1 * d0; + matrix[4] = tx1 * a0 + ty1 * c0 + pse; + matrix[5] = tx1 * b0 + ty1 * d0 + psf; + + return this; + }, + + /** + * Transform the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + transform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + matrix[0] = a * a0 + b * c0; + matrix[1] = a * b0 + b * d0; + matrix[2] = c * a0 + d * c0; + matrix[3] = c * b0 + d * d0; + matrix[4] = tx * a0 + ty * c0 + tx0; + matrix[5] = tx * b0 + ty * d0 + ty0; + + return this; + }, + + /** + * Transform a point using this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point to transform. + * @param {number} y - The y coordinate of the point to transform. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - The Point object to store the transformed coordinates. + * + * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} The Point containing the transformed coordinates. + */ + transformPoint: function (x, y, point) + { + if (point === undefined) { point = { x: 0, y: 0 }; } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + point.x = x * a + y * c + tx; + point.y = x * b + y * d + ty; + + return point; + }, + + /** + * Invert the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#invert + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + invert: function () + { + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var n = a * d - b * c; + + matrix[0] = d / n; + matrix[1] = -b / n; + matrix[2] = -c / n; + matrix[3] = a / n; + matrix[4] = (c * ty - d * tx) / n; + matrix[5] = -(a * ty - b * tx) / n; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the matrix given. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFrom + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * + * @return {this} This TransformMatrix. + */ + copyFrom: function (src) + { + var matrix = this.matrix; + + matrix[0] = src.a; + matrix[1] = src.b; + matrix[2] = src.c; + matrix[3] = src.d; + matrix[4] = src.e; + matrix[5] = src.f; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFromArray + * @since 3.11.0 + * + * @param {array} src - The array of values to set into this matrix. + * + * @return {this} This TransformMatrix. + */ + copyFromArray: function (src) + { + var matrix = this.matrix; + + matrix[0] = src[0]; + matrix[1] = src[1]; + matrix[2] = src[2]; + matrix[3] = src[3]; + matrix[4] = src[4]; + matrix[5] = src[5]; + + return this; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + copyToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + setToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToArray + * @since 3.12.0 + * + * @param {array} [out] - The array to copy the matrix values in to. + * + * @return {array} An array where elements 0 to 5 contain the values from this matrix. + */ + copyToArray: function (out) + { + var matrix = this.matrix; + + if (out === undefined) + { + out = [ matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] ]; + } + else + { + out[0] = matrix[0]; + out[1] = matrix[1]; + out[2] = matrix[2]; + out[3] = matrix[3]; + out[4] = matrix[4]; + out[5] = matrix[5]; + } + + return out; + }, + + /** + * Set the values of this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setTransform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + matrix[0] = a; + matrix[1] = b; + matrix[2] = c; + matrix[3] = d; + matrix[4] = tx; + matrix[5] = ty; + + return this; + }, + + /** + * Decompose this Matrix into its translation, scale and rotation values. + * + * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix + * @since 3.0.0 + * + * @return {object} The decomposed Matrix. + */ + decomposeMatrix: function () + { + var decomposedMatrix = this.decomposedMatrix; + + var matrix = this.matrix; + + // a = scale X (1) + // b = shear Y (0) + // c = shear X (0) + // d = scale Y (1) + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + var a2 = a * a; + var b2 = b * b; + var c2 = c * c; + var d2 = d * d; + + var sx = Math.sqrt(a2 + c2); + var sy = Math.sqrt(b2 + d2); + + decomposedMatrix.translateX = matrix[4]; + decomposedMatrix.translateY = matrix[5]; + + decomposedMatrix.scaleX = sx; + decomposedMatrix.scaleY = sy; + + decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); + + return decomposedMatrix; + }, + + /** + * Apply the identity, translate, rotate and scale operations on the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS + * @since 3.0.0 + * + * @param {number} x - The horizontal translation. + * @param {number} y - The vertical translation. + * @param {number} rotation - The angle of rotation in radians. + * @param {number} scaleX - The horizontal scale. + * @param {number} scaleY - The vertical scale. + * + * @return {this} This TransformMatrix. + */ + applyITRS: function (x, y, rotation, scaleX, scaleY) + { + var matrix = this.matrix; + + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); + + // Translate + matrix[4] = x; + matrix[5] = y; + + // Rotate and Scale + matrix[0] = radianCos * scaleX; + matrix[1] = radianSin * scaleX; + matrix[2] = -radianSin * scaleY; + matrix[3] = radianCos * scaleY; + + return this; + }, + + /** + * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of + * the current matrix with its transformation applied. + * + * Can be used to translate points from world to local space. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyInverse + * @since 3.12.0 + * + * @param {number} x - The x position to translate. + * @param {number} y - The y position to translate. + * @param {Phaser.Math.Vector2} [output] - A Vector2, or point-like object, to store the results in. + * + * @return {Phaser.Math.Vector2} The coordinates, inverse-transformed through this matrix. + */ + applyInverse: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var id = 1 / ((a * d) + (c * -b)); + + output.x = (d * id * x) + (-c * id * y) + (((ty * c) - (tx * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-ty * a) + (tx * b)) * id); + + return output; + }, + + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getX + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated x value. + */ + getX: function (x, y) + { + return x * this.a + y * this.c + this.e; + }, + + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getY + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated y value. + */ + getY: function (x, y) + { + return x * this.b + y * this.d + this.f; + }, + + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getCSSMatrix + * @since 3.12.0 + * + * @return {string} A string containing the CSS Transform matrix values. + */ + getCSSMatrix: function () + { + var m = this.matrix; + + return 'matrix(' + m[0] + ',' + m[1] + ',' + m[2] + ',' + m[3] + ',' + m[4] + ',' + m[5] + ')'; + }, + + /** + * Destroys this Transform Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#destroy + * @since 3.4.0 + */ + destroy: function () + { + this.matrix = null; + this.decomposedMatrix = null; + } + +}); + +module.exports = TransformMatrix; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ +var Contains = function (rect, x, y) +{ + if (rect.width <= 0 || rect.height <= 0) + { + return false; + } + + return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); +}; + +module.exports = Contains; + + +/***/ }), +/* 40 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check to see if the Circle contains the given x / y coordinates. + * + * @function Phaser.Geom.Circle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {number} x - The x coordinate to check within the circle. + * @param {number} y - The y coordinate to check within the circle. + * + * @return {boolean} True if the coordinates are within the circle, otherwise false. + */ +var Contains = function (circle, x, y) +{ + // Check if x/y are within the bounds first + if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) + { + var dx = (circle.x - x) * (circle.x - x); + var dy = (circle.y - y) * (circle.y - y); + + return (dx + dy) <= (circle.radius * circle.radius); + } + else + { + return false; + } +}; + +module.exports = Contains; + + +/***/ }), +/* 41 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the top of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetTop = function (gameObject, value) +{ + gameObject.y = value + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetTop; + + +/***/ }), +/* 42 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the top coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetTop + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The top coordinate of the bounds of the Game Object. + */ +var GetTop = function (gameObject) +{ + return gameObject.y - (gameObject.height * gameObject.originY); +}; + +module.exports = GetTop; + + +/***/ }), +/* 43 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetRight = function (gameObject, value) +{ + gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetRight; + + +/***/ }), +/* 44 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the right coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetRight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The right coordinate of the bounds of the Game Object. + */ +var GetRight = function (gameObject) +{ + return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); +}; + +module.exports = GetRight; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the left of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetLeft = function (gameObject, value) +{ + gameObject.x = value + (gameObject.width * gameObject.originX); + + return gameObject; +}; + +module.exports = SetLeft; + + +/***/ }), +/* 46 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the left coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetLeft + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The left coordinate of the bounds of the Game Object. + */ +var GetLeft = function (gameObject) +{ + return gameObject.x - (gameObject.width * gameObject.originX); +}; + +module.exports = GetLeft; + + +/***/ }), +/* 47 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. + * + * @function Phaser.Display.Bounds.SetBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} value - The coordinate to position the Game Object bounds on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var SetBottom = function (gameObject, value) +{ + gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); + + return gameObject; +}; + +module.exports = SetBottom; + + +/***/ }), +/* 48 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the bottom coordinate from the bounds of the Game Object. + * + * @function Phaser.Display.Bounds.GetBottom + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The bottom coordinate of the bounds of the Game Object. + */ +var GetBottom = function (gameObject) +{ + return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); +}; + +module.exports = GetBottom; + + +/***/ }), +/* 49 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.WorldToTileY + * @private + * @since 3.0.0 + * + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The Y location in tile units. + */ +var WorldToTileY = function (worldY, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } + + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's vertical scroll + worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + + tileHeight *= tilemapLayer.scaleY; + } + + return snapToFloor + ? Math.floor(worldY / tileHeight) + : worldY / tileHeight; +}; + +module.exports = WorldToTileY; + + +/***/ }), +/* 50 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.WorldToTileX + * @private + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} The X location in tile units. + */ +var WorldToTileX = function (worldX, snapToFloor, camera, layer) +{ + if (snapToFloor === undefined) { snapToFloor = true; } + + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + // Find the world position relative to the static or dynamic layer's top left origin, + // factoring in the camera's horizontal scroll + worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX)); + + tileWidth *= tilemapLayer.scaleX; + } + + return snapToFloor + ? Math.floor(worldX / tileWidth) + : worldX / tileWidth; +}; + +module.exports = WorldToTileX; + + +/***/ }), +/* 51 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -5170,9 +8748,9 @@ module.exports = { var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var File = __webpack_require__(19); +var File = __webpack_require__(21); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); var IsPlainObject = __webpack_require__(8); @@ -5196,7 +8774,7 @@ var IsPlainObject = __webpack_require__(8); * * @class JSONFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -5398,3084 +8976,10 @@ FileTypesManager.register('json', function (key, url, dataKey, xhrSettings) module.exports = JSONFile; -/***/ }), -/* 29 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Tests if the start and end indexes are a safe range for the given array. - * - * @function Phaser.Utils.Array.SafeRange - * @since 3.4.0 - * - * @param {array} array - The array to check. - * @param {integer} startIndex - The start index. - * @param {integer} endIndex - The end index. - * @param {boolean} [throwError=true] - Throw an error if the range is out of bounds. - * - * @return {boolean} True if the range is safe, otherwise false. - */ -var SafeRange = function (array, startIndex, endIndex, throwError) -{ - var len = array.length; - - if (startIndex < 0 || - startIndex > len || - startIndex >= endIndex || - endIndex > len || - startIndex + endIndex > len) - { - if (throwError) - { - throw new Error('Range Error: Values outside acceptable range'); - } - - return false; - } - else - { - return true; - } -}; - -module.exports = SafeRange; - - -/***/ }), -/* 30 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetColor = __webpack_require__(152); -var GetColor32 = __webpack_require__(284); - -/** - * @classdesc - * The Color class holds a single color value and allows for easy modification and reading of it. - * - * @class Color - * @memberOf Phaser.Display - * @constructor - * @since 3.0.0 - * - * @param {integer} [red=0] - The red color value. A number between 0 and 255. - * @param {integer} [green=0] - The green color value. A number between 0 and 255. - * @param {integer} [blue=0] - The blue color value. A number between 0 and 255. - * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. - */ -var Color = new Class({ - - initialize: - - function Color (red, green, blue, alpha) - { - if (red === undefined) { red = 0; } - if (green === undefined) { green = 0; } - if (blue === undefined) { blue = 0; } - if (alpha === undefined) { alpha = 255; } - - /** - * The internal red color value. - * - * @name Phaser.Display.Color#r - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.r = 0; - - /** - * The internal green color value. - * - * @name Phaser.Display.Color#g - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.g = 0; - - /** - * The internal blue color value. - * - * @name Phaser.Display.Color#b - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this.b = 0; - - /** - * The internal alpha color value. - * - * @name Phaser.Display.Color#a - * @type {number} - * @private - * @default 255 - * @since 3.0.0 - */ - this.a = 255; - - /** - * An array containing the calculated color values for WebGL use. - * - * @name Phaser.Display.Color#gl - * @type {number[]} - * @since 3.0.0 - */ - this.gl = [ 0, 0, 0, 1 ]; - - /** - * Pre-calculated internal color value. - * - * @name Phaser.Display.Color#_color - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._color = 0; - - /** - * Pre-calculated internal color32 value. - * - * @name Phaser.Display.Color#_color32 - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._color32 = 0; - - /** - * Pre-calculated internal color rgb string value. - * - * @name Phaser.Display.Color#_rgba - * @type {string} - * @private - * @default '' - * @since 3.0.0 - */ - this._rgba = ''; - - this.setTo(red, green, blue, alpha); - }, - - /** - * Sets this color to be transparent. Sets all values to zero. - * - * @method Phaser.Display.Color#transparent - * @since 3.0.0 - * - * @return {Phaser.Display.Color} This Color object. - */ - transparent: function () - { - this.red = 0; - this.green = 0; - this.blue = 0; - this.alpha = 0; - - return this.update(); - }, - - /** - * Sets the color of this Color component. - * - * @method Phaser.Display.Color#setTo - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. - * - * @return {Phaser.Display.Color} This Color object. - */ - setTo: function (red, green, blue, alpha) - { - if (alpha === undefined) { alpha = 255; } - - this.red = red; - this.green = green; - this.blue = blue; - this.alpha = alpha; - - return this.update(); - }, - - /** - * Sets the red, green, blue and alpha GL values of this Color component. - * - * @method Phaser.Display.Color#setGLTo - * @since 3.0.0 - * - * @param {float} red - The red color value. A number between 0 and 1. - * @param {float} green - The green color value. A number between 0 and 1. - * @param {float} blue - The blue color value. A number between 0 and 1. - * @param {float} [alpha=1] - The alpha value. A number between 0 and 1. - * - * @return {Phaser.Display.Color} This Color object. - */ - setGLTo: function (red, green, blue, alpha) - { - if (alpha === undefined) { alpha = 1; } - - this.redGL = red; - this.greenGL = green; - this.blueGL = blue; - this.alphaGL = alpha; - - return this.update(); - }, - - /** - * Sets the color based on the color object given. - * - * @method Phaser.Display.Color#setFromRGB - * @since 3.0.0 - * - * @param {InputColorObject} color - An object containing `r`, `g`, `b` and optionally `a` values in the range 0 to 255. - * - * @return {Phaser.Display.Color} This Color object. - */ - setFromRGB: function (color) - { - this.red = color.r; - this.green = color.g; - this.blue = color.b; - - if (color.hasOwnProperty('a')) - { - this.alpha = color.a; - } - - return this.update(); - }, - - /** - * Updates the internal cache values. - * - * @method Phaser.Display.Color#update - * @since 3.0.0 - * - * @return {Phaser.Display.Color} This Color object. - */ - update: function () - { - this._color = GetColor(this.r, this.g, this.b); - this._color32 = GetColor32(this.r, this.g, this.b, this.a); - this._rgba = 'rgba(' + this.r + ',' + this.g + ',' + this.b + ',' + (this.a / 255) + ')'; - - return this; - }, - - /** - * Returns a new Color component using the values from this one. - * - * @method Phaser.Display.Color#clone - * @since 3.0.0 - * - * @return {Phaser.Display.Color} A new Color object. - */ - clone: function () - { - return new Color(this.r, this.g, this.b, this.a); - }, - - /** - * The color of this Color component, not including the alpha channel. - * - * @name Phaser.Display.Color#color - * @type {number} - * @readOnly - * @since 3.0.0 - */ - color: { - - get: function () - { - return this._color; - } - - }, - - /** - * The color of this Color component, including the alpha channel. - * - * @name Phaser.Display.Color#color32 - * @type {number} - * @readOnly - * @since 3.0.0 - */ - color32: { - - get: function () - { - return this._color32; - } - - }, - - /** - * The color of this Color component as a string which can be used in CSS color values. - * - * @name Phaser.Display.Color#rgba - * @type {string} - * @readOnly - * @since 3.0.0 - */ - rgba: { - - get: function () - { - return this._rgba; - } - - }, - - /** - * The red color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#redGL - * @type {float} - * @since 3.0.0 - */ - redGL: { - - get: function () - { - return this.gl[0]; - }, - - set: function (value) - { - this.gl[0] = Math.min(Math.abs(value), 1); - - this.r = Math.floor(this.gl[0] * 255); - - this.update(); - } - - }, - - /** - * The green color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#greenGL - * @type {float} - * @since 3.0.0 - */ - greenGL: { - - get: function () - { - return this.gl[1]; - }, - - set: function (value) - { - this.gl[1] = Math.min(Math.abs(value), 1); - - this.g = Math.floor(this.gl[1] * 255); - - this.update(); - } - - }, - - /** - * The blue color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#blueGL - * @type {float} - * @since 3.0.0 - */ - blueGL: { - - get: function () - { - return this.gl[2]; - }, - - set: function (value) - { - this.gl[2] = Math.min(Math.abs(value), 1); - - this.b = Math.floor(this.gl[2] * 255); - - this.update(); - } - - }, - - /** - * The alpha color value, normalized to the range 0 to 1. - * - * @name Phaser.Display.Color#alphaGL - * @type {float} - * @since 3.0.0 - */ - alphaGL: { - - get: function () - { - return this.gl[3]; - }, - - set: function (value) - { - this.gl[3] = Math.min(Math.abs(value), 1); - - this.a = Math.floor(this.gl[3] * 255); - - this.update(); - } - - }, - - /** - * The red color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#red - * @type {number} - * @since 3.0.0 - */ - red: { - - get: function () - { - return this.r; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.r = Math.min(value, 255); - - this.gl[0] = value / 255; - - this.update(); - } - - }, - - /** - * The green color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#green - * @type {number} - * @since 3.0.0 - */ - green: { - - get: function () - { - return this.g; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.g = Math.min(value, 255); - - this.gl[1] = value / 255; - - this.update(); - } - - }, - - /** - * The blue color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#blue - * @type {number} - * @since 3.0.0 - */ - blue: { - - get: function () - { - return this.b; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.b = Math.min(value, 255); - - this.gl[2] = value / 255; - - this.update(); - } - - }, - - /** - * The alpha color value, normalized to the range 0 to 255. - * - * @name Phaser.Display.Color#alpha - * @type {number} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this.a; - }, - - set: function (value) - { - value = Math.floor(Math.abs(value)); - - this.a = Math.min(value, 255); - - this.gl[3] = value / 255; - - this.update(); - } - - } - -}); - -module.exports = Color; - - -/***/ }), -/* 31 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (rect, x, y) -{ - if (rect.width <= 0 || rect.height <= 0) - { - return false; - } - - return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); -}; - -module.exports = Contains; - - -/***/ }), -/* 32 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Circle contains the given x / y coordinates. - * - * @function Phaser.Geom.Circle.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {number} x - The x coordinate to check within the circle. - * @param {number} y - The y coordinate to check within the circle. - * - * @return {boolean} True if the coordinates are within the circle, otherwise false. - */ -var Contains = function (circle, x, y) -{ - // Check if x/y are within the bounds first - if (circle.radius > 0 && x >= circle.left && x <= circle.right && y >= circle.top && y <= circle.bottom) - { - var dx = (circle.x - x) * (circle.x - x); - var dy = (circle.y - y) * (circle.y - y); - - return (dx + dy) <= (circle.radius * circle.radius); - } - else - { - return false; - } -}; - -module.exports = Contains; - - -/***/ }), -/* 33 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Shallow Object Clone. Will not clone nested objects. - * - * @function Phaser.Utils.Object.Clone - * @since 3.0.0 - * - * @param {object} obj - the object from which to clone - * - * @return {object} a new object with the same properties as the input obj - */ -var Clone = function (obj) -{ - var clone = {}; - - for (var key in obj) - { - if (Array.isArray(obj[key])) - { - clone[key] = obj[key].slice(0); - } - else - { - clone[key] = obj[key]; - } - } - - return clone; -}; - -module.exports = Clone; - - -/***/ }), -/* 34 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var SpriteRender = __webpack_require__(556); - -/** - * @classdesc - * A Sprite Game Object. - * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - * - * @class Sprite - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Sprite = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - SpriteRender - ], - - initialize: - - function Sprite (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Sprite'); - - /** - * The Animation Controller of this Sprite. - * - * @name Phaser.GameObjects.Sprite#anims - * @type {Phaser.GameObjects.Components.Animation} - * @since 3.0.0 - */ - this.anims = new Components.Animation(this); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - }, - - /** - * Update this Sprite's animations. - * - * @method Phaser.GameObjects.Sprite#preUpdate - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp. - * @param {number} delta - The delta time, in ms, elapsed since the last frame. - */ - preUpdate: function (time, delta) - { - this.anims.update(time, delta); - }, - - /** - * Start playing the given animation. - * - * @method Phaser.GameObjects.Sprite#play - * @since 3.0.0 - * - * @param {string} key - The string-based key of the animation to play. - * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. - * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. - * - * @return {Phaser.GameObjects.Sprite} This Game Object. - */ - play: function (key, ignoreIfPlaying, startFrame) - { - this.anims.play(key, ignoreIfPlaying, startFrame); - - return this; - }, - - /** - * Build a JSON representation of this Sprite. - * - * @method Phaser.GameObjects.Sprite#toJSON - * @since 3.0.0 - * - * @return {JSONGameObject} A JSON representation of the Game Object. - */ - toJSON: function () - { - var data = Components.ToJSON(this); - - // Extra Sprite data is added here - - return data; - } - -}); - -module.exports = Sprite; - - -/***/ }), -/* 35 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes an array of Game Objects, or any objects that have a public property as defined in `key`, - * and then adds the given value to it. - * - * The optional `step` property is applied incrementally, multiplied by each item in the array. - * - * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` - * - * @function Phaser.Actions.PropertyValueInc - * @since 3.3.0 - * - * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] - * - * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. - * @param {string} key - The property to be updated. - * @param {number} value - The amount to be added to the property. - * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. - * @param {integer} [index=0] - An optional offset to start searching from within the items array. - * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. - * - * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. - */ -var PropertyValueInc = function (items, key, value, step, index, direction) -{ - if (step === undefined) { step = 0; } - if (index === undefined) { index = 0; } - if (direction === undefined) { direction = 1; } - - var i; - var t = 0; - var end = items.length; - - if (direction === 1) - { - // Start to End - for (i = index; i < end; i++) - { - items[i][key] += value + (t * step); - t++; - } - } - else - { - // End to Start - for (i = index; i >= 0; i--) - { - items[i][key] += value + (t * step); - t++; - } - } - - return items; -}; - -module.exports = PropertyValueInc; - - -/***/ }), -/* 36 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after - * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont. - * - * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. - * - * @class MultiFile - * @memberOf Phaser.Loader - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. - * @param {string} type - The file type string for sorting within the Loader. - * @param {string} key - The key of the file within the loader. - * @param {Phaser.Loader.File[]} files - An array of Files that make-up this MultiFile. - */ -var MultiFile = new Class({ - - initialize: - - function MultiFile (loader, type, key, files) - { - /** - * A reference to the Loader that is going to load this file. - * - * @name Phaser.Loader.MultiFile#loader - * @type {Phaser.Loader.LoaderPlugin} - * @since 3.7.0 - */ - this.loader = loader; - - /** - * The file type string for sorting within the Loader. - * - * @name Phaser.Loader.MultiFile#type - * @type {string} - * @since 3.7.0 - */ - this.type = type; - - /** - * Unique cache key (unique within its file type) - * - * @name Phaser.Loader.MultiFile#key - * @type {string} - * @since 3.7.0 - */ - this.key = key; - - /** - * Array of files that make up this MultiFile. - * - * @name Phaser.Loader.MultiFile#files - * @type {Phaser.Loader.File[]} - * @since 3.7.0 - */ - this.files = files; - - /** - * The completion status of this MultiFile. - * - * @name Phaser.Loader.MultiFile#complete - * @type {boolean} - * @default false - * @since 3.7.0 - */ - this.complete = false; - - /** - * The number of files to load. - * - * @name Phaser.Loader.MultiFile#pending - * @type {integer} - * @since 3.7.0 - */ - - this.pending = files.length; - - /** - * The number of files that failed to load. - * - * @name Phaser.Loader.MultiFile#failed - * @type {integer} - * @default 0 - * @since 3.7.0 - */ - this.failed = 0; - - /** - * A storage container for transient data that the loading files need. - * - * @name Phaser.Loader.MultiFile#config - * @type {any} - * @since 3.7.0 - */ - this.config = {}; - - // Link the files - for (var i = 0; i < files.length; i++) - { - files[i].multiFile = this; - } - }, - - /** - * Checks if this MultiFile is ready to process its children or not. - * - * @method Phaser.Loader.MultiFile#isReadyToProcess - * @since 3.7.0 - * - * @return {boolean} `true` if all children of this MultiFile have loaded, otherwise `false`. - */ - isReadyToProcess: function () - { - return (this.pending === 0 && this.failed === 0 && !this.complete); - }, - - /** - * Adds another child to this MultiFile, increases the pending count and resets the completion status. - * - * @method Phaser.Loader.MultiFile#addToMultiFile - * @since 3.7.0 - * - * @param {Phaser.Loader.File} files - The File to add to this MultiFile. - * - * @return {Phaser.Loader.MultiFile} This MultiFile instance. - */ - addToMultiFile: function (file) - { - this.files.push(file); - - file.multiFile = this; - - this.pending++; - - this.complete = false; - - return this; - }, - - /** - * Called by each File when it finishes loading. - * - * @method Phaser.Loader.MultiFile#onFileComplete - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The File that has completed processing. - */ - onFileComplete: function (file) - { - var index = this.files.indexOf(file); - - if (index !== -1) - { - this.pending--; - } - }, - - /** - * Called by each File that fails to load. - * - * @method Phaser.Loader.MultiFile#onFileFailed - * @since 3.7.0 - * - * @param {Phaser.Loader.File} file - The File that has failed to load. - */ - onFileFailed: function (file) - { - var index = this.files.indexOf(file); - - if (index !== -1) - { - this.failed++; - } - } - -}); - -module.exports = MultiFile; - - -/***/ }), -/* 37 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.ImageFrameConfig - * - * @property {integer} frameWidth - The width of the frame in pixels. - * @property {integer} [frameHeight] - The height of the frame in pixels. Uses the `frameWidth` value if not provided. - * @property {integer} [startFrame=0] - The first frame to start parsing from. - * @property {integer} [endFrame] - The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions. - * @property {integer} [margin=0] - The margin in the image. This is the space around the edge of the frames. - * @property {integer} [spacing=0] - The spacing between each frame in the image. - */ - -/** - * @typedef {object} Phaser.Loader.FileTypes.ImageFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='png'] - The default file extension to use if no url is provided. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image. - * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Image File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. - * - * @class ImageFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. - */ -var ImageFile = new Class({ - - Extends: File, - - initialize: - - function ImageFile (loader, key, url, xhrSettings, frameConfig) - { - var extension = 'png'; - var normalMapURL; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - normalMapURL = GetFastValue(config, 'normalMap'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - frameConfig = GetFastValue(config, 'frameConfig'); - } - - if (Array.isArray(url)) - { - normalMapURL = url[1]; - url = url[0]; - } - - var fileConfig = { - type: 'image', - cache: loader.textureManager, - extension: extension, - responseType: 'blob', - key: key, - url: url, - xhrSettings: xhrSettings, - config: frameConfig - }; - - File.call(this, loader, fileConfig); - - // Do we have a normal map to load as well? - if (normalMapURL) - { - var normalMap = new ImageFile(loader, this.key, normalMapURL, xhrSettings, frameConfig); - - normalMap.type = 'normalMap'; - - this.setLink(normalMap); - - loader.addFile(normalMap); - } - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.ImageFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - var _this = this; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessComplete(); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessError(); - }; - - File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.ImageFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var texture; - var linkFile = this.linkFile; - - if (linkFile && linkFile.state === CONST.FILE_COMPLETE) - { - if (this.type === 'image') - { - texture = this.cache.addImage(this.key, this.data, linkFile.data); - } - else - { - texture = this.cache.addImage(linkFile.key, linkFile.data, this.data); - } - - this.pendingDestroy(texture); - - linkFile.pendingDestroy(texture); - } - else if (!linkFile) - { - texture = this.cache.addImage(this.key, this.data); - - this.pendingDestroy(texture); - } - } - -}); - -/** - * Adds an Image, or array of Images, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.image('logo', 'images/phaserLogo.png'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback - * of animated gifs to Canvas elements. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.image({ - * key: 'logo', - * url: 'images/AtariLogo.png' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.image('logo', 'images/AtariLogo.png'); - * // and later in your game ... - * this.add.image(x, y, 'logo'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.image({ - * key: 'logo', - * url: 'images/AtariLogo.png', - * normalMap: 'images/AtariLogo-n.png' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#image - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('image', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new ImageFile(this, key[i])); - } - } - else - { - this.addFile(new ImageFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = ImageFile; - - -/***/ }), -/* 38 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); - -/** - * Convert the given angle from degrees, to the equivalent angle in radians. - * - * @function Phaser.Math.DegToRad - * @since 3.0.0 - * - * @param {integer} degrees - The angle (in degrees) to convert to radians. - * - * @return {float} The given angle converted to radians. - */ -var DegToRad = function (degrees) -{ - return degrees * CONST.DEG_TO_RAD; -}; - -module.exports = DegToRad; - - -/***/ }), -/* 39 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Wrap the given `value` between `min` and `max. - * - * @function Phaser.Math.Wrap - * @since 3.0.0 - * - * @param {number} value - The value to wrap. - * @param {number} min - The minimum value. - * @param {number} max - The maximum value. - * - * @return {number} The wrapped value. - */ -var Wrap = function (value, min, max) -{ - var range = max - min; - - return (min + ((((value - min) % range) + range) % range)); -}; - -module.exports = Wrap; - - -/***/ }), -/* 40 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTileAt = __webpack_require__(140); -var GetTilesWithin = __webpack_require__(21); - -/** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @function Phaser.Tilemaps.Components.CalculateFacesWithin - * @private - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var CalculateFacesWithin = function (tileX, tileY, width, height, layer) -{ - var above = null; - var below = null; - var left = null; - var right = null; - - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - if (tile) - { - if (tile.collides) - { - above = GetTileAt(tile.x, tile.y - 1, true, layer); - below = GetTileAt(tile.x, tile.y + 1, true, layer); - left = GetTileAt(tile.x - 1, tile.y, true, layer); - right = GetTileAt(tile.x + 1, tile.y, true, layer); - - tile.faceTop = (above && above.collides) ? false : true; - tile.faceBottom = (below && below.collides) ? false : true; - tile.faceLeft = (left && left.collides) ? false : true; - tile.faceRight = (right && right.collides) ? false : true; - } - else - { - tile.resetFaces(); - } - } - } -}; - -module.exports = CalculateFacesWithin; - - -/***/ }), -/* 41 */ -/***/ (function(module, exports) { - -/** -* The `Matter.Common` module contains utility functions that are common to all modules. -* -* @class Common -*/ - -var Common = {}; - -module.exports = Common; - -(function() { - - Common._nextId = 0; - Common._seed = 0; - Common._nowStartTime = +(new Date()); - - /** - * Extends the object in the first argument using the object in the second argument. - * @method extend - * @param {} obj - * @param {boolean} deep - * @return {} obj extended - */ - Common.extend = function(obj, deep) { - var argsStart, - args, - deepClone; - - if (typeof deep === 'boolean') { - argsStart = 2; - deepClone = deep; - } else { - argsStart = 1; - deepClone = true; - } - - for (var i = argsStart; i < arguments.length; i++) { - var source = arguments[i]; - - if (source) { - for (var prop in source) { - if (deepClone && source[prop] && source[prop].constructor === Object) { - if (!obj[prop] || obj[prop].constructor === Object) { - obj[prop] = obj[prop] || {}; - Common.extend(obj[prop], deepClone, source[prop]); - } else { - obj[prop] = source[prop]; - } - } else { - obj[prop] = source[prop]; - } - } - } - } - - return obj; - }; - - /** - * Creates a new clone of the object, if deep is true references will also be cloned. - * @method clone - * @param {} obj - * @param {bool} deep - * @return {} obj cloned - */ - Common.clone = function(obj, deep) { - return Common.extend({}, deep, obj); - }; - - /** - * Returns the list of keys for the given object. - * @method keys - * @param {} obj - * @return {string[]} keys - */ - Common.keys = function(obj) { - if (Object.keys) - return Object.keys(obj); - - // avoid hasOwnProperty for performance - var keys = []; - for (var key in obj) - keys.push(key); - return keys; - }; - - /** - * Returns the list of values for the given object. - * @method values - * @param {} obj - * @return {array} Array of the objects property values - */ - Common.values = function(obj) { - var values = []; - - if (Object.keys) { - var keys = Object.keys(obj); - for (var i = 0; i < keys.length; i++) { - values.push(obj[keys[i]]); - } - return values; - } - - // avoid hasOwnProperty for performance - for (var key in obj) - values.push(obj[key]); - return values; - }; - - /** - * Gets a value from `base` relative to the `path` string. - * @method get - * @param {} obj The base object - * @param {string} path The path relative to `base`, e.g. 'Foo.Bar.baz' - * @param {number} [begin] Path slice begin - * @param {number} [end] Path slice end - * @return {} The object at the given path - */ - Common.get = function(obj, path, begin, end) { - path = path.split('.').slice(begin, end); - - for (var i = 0; i < path.length; i += 1) { - obj = obj[path[i]]; - } - - return obj; - }; - - /** - * Sets a value on `base` relative to the given `path` string. - * @method set - * @param {} obj The base object - * @param {string} path The path relative to `base`, e.g. 'Foo.Bar.baz' - * @param {} val The value to set - * @param {number} [begin] Path slice begin - * @param {number} [end] Path slice end - * @return {} Pass through `val` for chaining - */ - Common.set = function(obj, path, val, begin, end) { - var parts = path.split('.').slice(begin, end); - Common.get(obj, path, 0, -1)[parts[parts.length - 1]] = val; - return val; - }; - - /** - * Shuffles the given array in-place. - * The function uses a seeded random generator. - * @method shuffle - * @param {array} array - * @return {array} array shuffled randomly - */ - Common.shuffle = function(array) { - for (var i = array.length - 1; i > 0; i--) { - var j = Math.floor(Common.random() * (i + 1)); - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - return array; - }; - - /** - * Randomly chooses a value from a list with equal probability. - * The function uses a seeded random generator. - * @method choose - * @param {array} choices - * @return {object} A random choice object from the array - */ - Common.choose = function(choices) { - return choices[Math.floor(Common.random() * choices.length)]; - }; - - /** - * Returns true if the object is a HTMLElement, otherwise false. - * @method isElement - * @param {object} obj - * @return {boolean} True if the object is a HTMLElement, otherwise false - */ - Common.isElement = function(obj) { - return obj instanceof HTMLElement; - }; - - /** - * Returns true if the object is an array. - * @method isArray - * @param {object} obj - * @return {boolean} True if the object is an array, otherwise false - */ - Common.isArray = function(obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; - }; - - /** - * Returns true if the object is a function. - * @method isFunction - * @param {object} obj - * @return {boolean} True if the object is a function, otherwise false - */ - Common.isFunction = function(obj) { - return typeof obj === "function"; - }; - - /** - * Returns true if the object is a plain object. - * @method isPlainObject - * @param {object} obj - * @return {boolean} True if the object is a plain object, otherwise false - */ - Common.isPlainObject = function(obj) { - return typeof obj === 'object' && obj.constructor === Object; - }; - - /** - * Returns true if the object is a string. - * @method isString - * @param {object} obj - * @return {boolean} True if the object is a string, otherwise false - */ - Common.isString = function(obj) { - return Object.prototype.toString.call(obj) === '[object String]'; - }; - - /** - * Returns the given value clamped between a minimum and maximum value. - * @method clamp - * @param {number} value - * @param {number} min - * @param {number} max - * @return {number} The value clamped between min and max inclusive - */ - Common.clamp = function(value, min, max) { - if (value < min) - return min; - if (value > max) - return max; - return value; - }; - - /** - * Returns the sign of the given value. - * @method sign - * @param {number} value - * @return {number} -1 if negative, +1 if 0 or positive - */ - Common.sign = function(value) { - return value < 0 ? -1 : 1; - }; - - /** - * Returns the current timestamp since the time origin (e.g. from page load). - * The result will be high-resolution including decimal places if available. - * @method now - * @return {number} the current timestamp - */ - Common.now = function() { - if (window.performance) { - if (window.performance.now) { - return window.performance.now(); - } else if (window.performance.webkitNow) { - return window.performance.webkitNow(); - } - } - - return (new Date()) - Common._nowStartTime; - }; - - /** - * Returns a random value between a minimum and a maximum value inclusive. - * The function uses a seeded random generator. - * @method random - * @param {number} min - * @param {number} max - * @return {number} A random number between min and max inclusive - */ - Common.random = function(min, max) { - min = (typeof min !== "undefined") ? min : 0; - max = (typeof max !== "undefined") ? max : 1; - return min + _seededRandom() * (max - min); - }; - - var _seededRandom = function() { - // https://en.wikipedia.org/wiki/Linear_congruential_generator - Common._seed = (Common._seed * 9301 + 49297) % 233280; - return Common._seed / 233280; - }; - - /** - * Converts a CSS hex colour string into an integer. - * @method colorToNumber - * @param {string} colorString - * @return {number} An integer representing the CSS hex string - */ - Common.colorToNumber = function(colorString) { - colorString = colorString.replace('#',''); - - if (colorString.length == 3) { - colorString = colorString.charAt(0) + colorString.charAt(0) - + colorString.charAt(1) + colorString.charAt(1) - + colorString.charAt(2) + colorString.charAt(2); - } - - return parseInt(colorString, 16); - }; - - /** - * The console logging level to use, where each level includes all levels above and excludes the levels below. - * The default level is 'debug' which shows all console messages. - * - * Possible level values are: - * - 0 = None - * - 1 = Debug - * - 2 = Info - * - 3 = Warn - * - 4 = Error - * @property Common.logLevel - * @type {Number} - * @default 1 - */ - Common.logLevel = 1; - - /** - * Shows a `console.log` message only if the current `Common.logLevel` allows it. - * The message will be prefixed with 'matter-js' to make it easily identifiable. - * @method log - * @param ...objs {} The objects to log. - */ - Common.log = function() { - if (console && Common.logLevel > 0 && Common.logLevel <= 3) { - console.log.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); - } - }; - - /** - * Shows a `console.info` message only if the current `Common.logLevel` allows it. - * The message will be prefixed with 'matter-js' to make it easily identifiable. - * @method info - * @param ...objs {} The objects to log. - */ - Common.info = function() { - if (console && Common.logLevel > 0 && Common.logLevel <= 2) { - console.info.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); - } - }; - - /** - * Shows a `console.warn` message only if the current `Common.logLevel` allows it. - * The message will be prefixed with 'matter-js' to make it easily identifiable. - * @method warn - * @param ...objs {} The objects to log. - */ - Common.warn = function() { - if (console && Common.logLevel > 0 && Common.logLevel <= 3) { - console.warn.apply(console, ['matter-js:'].concat(Array.prototype.slice.call(arguments))); - } - }; - - /** - * Returns the next unique sequential ID. - * @method nextId - * @return {Number} Unique sequential ID - */ - Common.nextId = function() { - return Common._nextId++; - }; - - /** - * A cross browser compatible indexOf implementation. - * @method indexOf - * @param {array} haystack - * @param {object} needle - * @return {number} The position of needle in haystack, otherwise -1. - Common.indexOf = function(haystack, needle) { - if (haystack.indexOf) - return haystack.indexOf(needle); - - for (var i = 0; i < haystack.length; i++) { - if (haystack[i] === needle) - return i; - } - - return -1; - }; - */ - - /** - * A cross browser compatible array map implementation. - * @method map - * @param {array} list - * @param {function} func - * @return {array} Values from list transformed by func. - */ - Common.map = function(list, func) { - if (list.map) { - return list.map(func); - } - - var mapped = []; - - for (var i = 0; i < list.length; i += 1) { - mapped.push(func(list[i])); - } - - return mapped; - }; - - /** - * Takes a directed graph and returns the partially ordered set of vertices in topological order. - * Circular dependencies are allowed. - * @method topologicalSort - * @param {object} graph - * @return {array} Partially ordered set of vertices in topological order. - */ - Common.topologicalSort = function(graph) { - // https://github.com/mgechev/javascript-algorithms - // Copyright (c) Minko Gechev (MIT license) - // Modifications: tidy formatting and naming - var result = [], - visited = [], - temp = []; - - for (var node in graph) { - if (!visited[node] && !temp[node]) { - _topologicalSort(node, visited, temp, graph, result); - } - } - - return result; - }; - - var _topologicalSort = function(node, visited, temp, graph, result) { - var neighbors = graph[node] || []; - temp[node] = true; - - for (var i = 0; i < neighbors.length; i += 1) { - var neighbor = neighbors[i]; - - if (temp[neighbor]) { - // skip circular dependencies - continue; - } - - if (!visited[neighbor]) { - _topologicalSort(neighbor, visited, temp, graph, result); - } - } - - temp[node] = false; - visited[node] = true; - - result.push(node); - }; - - /** - * Takes _n_ functions as arguments and returns a new function that calls them in order. - * The arguments applied when calling the new function will also be applied to every function passed. - * The value of `this` refers to the last value returned in the chain that was not `undefined`. - * Therefore if a passed function does not return a value, the previously returned value is maintained. - * After all passed functions have been called the new function returns the last returned value (if any). - * If any of the passed functions are a chain, then the chain will be flattened. - * @method chain - * @param ...funcs {function} The functions to chain. - * @return {function} A new function that calls the passed functions in order. - */ - Common.chain = function() { - var funcs = []; - - for (var i = 0; i < arguments.length; i += 1) { - var func = arguments[i]; - - if (func._chained) { - // flatten already chained functions - funcs.push.apply(funcs, func._chained); - } else { - funcs.push(func); - } - } - - var chain = function() { - // https://github.com/GoogleChrome/devtools-docs/issues/53#issuecomment-51941358 - var lastResult, - args = new Array(arguments.length); - - for (var i = 0, l = arguments.length; i < l; i++) { - args[i] = arguments[i]; - } - - for (i = 0; i < funcs.length; i += 1) { - var result = funcs[i].apply(lastResult, args); - - if (typeof result !== 'undefined') { - lastResult = result; - } - } - - return lastResult; - }; - - chain._chained = funcs; - - return chain; - }; - - /** - * Chains a function to excute before the original function on the given `path` relative to `base`. - * See also docs for `Common.chain`. - * @method chainPathBefore - * @param {} base The base object - * @param {string} path The path relative to `base` - * @param {function} func The function to chain before the original - * @return {function} The chained function that replaced the original - */ - Common.chainPathBefore = function(base, path, func) { - return Common.set(base, path, Common.chain( - func, - Common.get(base, path) - )); - }; - - /** - * Chains a function to excute after the original function on the given `path` relative to `base`. - * See also docs for `Common.chain`. - * @method chainPathAfter - * @param {} base The base object - * @param {string} path The path relative to `base` - * @param {function} func The function to chain after the original - * @return {function} The chained function that replaced the original - */ - Common.chainPathAfter = function(base, path, func) { - return Common.set(base, path, Common.chain( - Common.get(base, path), - func - )); - }; - -})(); - - -/***/ }), -/* 42 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Arcade Physics consts. - * - * @ignore - */ - -var CONST = { - - /** - * [description] - * - * @name Phaser.Physics.Arcade.DYNAMIC_BODY - * @readOnly - * @type {number} - * @since 3.0.0 - */ - DYNAMIC_BODY: 0, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.STATIC_BODY - * @readOnly - * @type {number} - * @since 3.0.0 - */ - STATIC_BODY: 1, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.GROUP - * @readOnly - * @type {number} - * @since 3.0.0 - */ - GROUP: 2, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.TILEMAPLAYER - * @readOnly - * @type {number} - * @since 3.0.0 - */ - TILEMAPLAYER: 3, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_NONE - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_NONE: 10, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_UP - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_UP: 11, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_DOWN - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_DOWN: 12, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_LEFT - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_LEFT: 13, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.FACING_RIGHT - * @readOnly - * @type {number} - * @since 3.0.0 - */ - FACING_RIGHT: 14 - -}; - -module.exports = CONST; - - -/***/ }), -/* 43 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the top of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetTop - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetTop = function (gameObject, value) -{ - gameObject.y = value + (gameObject.height * gameObject.originY); - - return gameObject; -}; - -module.exports = SetTop; - - -/***/ }), -/* 44 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the top coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetTop - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The top coordinate of the bounds of the Game Object. - */ -var GetTop = function (gameObject) -{ - return gameObject.y - (gameObject.height * gameObject.originY); -}; - -module.exports = GetTop; - - -/***/ }), -/* 45 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetRight = function (gameObject, value) -{ - gameObject.x = (value - gameObject.width) + (gameObject.width * gameObject.originX); - - return gameObject; -}; - -module.exports = SetRight; - - -/***/ }), -/* 46 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the right coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetRight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The right coordinate of the bounds of the Game Object. - */ -var GetRight = function (gameObject) -{ - return (gameObject.x + gameObject.width) - (gameObject.width * gameObject.originX); -}; - -module.exports = GetRight; - - -/***/ }), -/* 47 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the left of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetLeft = function (gameObject, value) -{ - gameObject.x = value + (gameObject.width * gameObject.originX); - - return gameObject; -}; - -module.exports = SetLeft; - - -/***/ }), -/* 48 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the left coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetLeft - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The left coordinate of the bounds of the Game Object. - */ -var GetLeft = function (gameObject) -{ - return gameObject.x - (gameObject.width * gameObject.originX); -}; - -module.exports = GetLeft; - - -/***/ }), -/* 49 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Positions the Game Object so that the bottom of its bounds aligns with the given coordinate. - * - * @function Phaser.Display.Bounds.SetBottom - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} value - The coordinate to position the Game Object bounds on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var SetBottom = function (gameObject, value) -{ - gameObject.y = (value - gameObject.height) + (gameObject.height * gameObject.originY); - - return gameObject; -}; - -module.exports = SetBottom; - - -/***/ }), -/* 50 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the bottom coordinate from the bounds of the Game Object. - * - * @function Phaser.Display.Bounds.GetBottom - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The bottom coordinate of the bounds of the Game Object. - */ -var GetBottom = function (gameObject) -{ - return (gameObject.y + gameObject.height) - (gameObject.height * gameObject.originY); -}; - -module.exports = GetBottom; - - -/***/ }), -/* 51 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Phaser Blend Modes. - * - * @name Phaser.BlendModes - * @enum {integer} - * @memberOf Phaser - * @readOnly - * @since 3.0.0 - */ - -module.exports = { - - /** - * Skips the Blend Mode check in the renderer. - * - * @name Phaser.BlendModes.SKIP_CHECK - */ - SKIP_CHECK: -1, - - /** - * Normal blend mode. - * - * @name Phaser.BlendModes.NORMAL - */ - NORMAL: 0, - - /** - * Add blend mode. - * - * @name Phaser.BlendModes.ADD - */ - ADD: 1, - - /** - * Multiply blend mode. - * - * @name Phaser.BlendModes.MULTIPLY - */ - MULTIPLY: 2, - - /** - * Screen blend mode. - * - * @name Phaser.BlendModes.SCREEN - */ - SCREEN: 3, - - /** - * Overlay blend mode. - * - * @name Phaser.BlendModes.OVERLAY - */ - OVERLAY: 4, - - /** - * Darken blend mode. - * - * @name Phaser.BlendModes.DARKEN - */ - DARKEN: 5, - - /** - * Lighten blend mode. - * - * @name Phaser.BlendModes.LIGHTEN - */ - LIGHTEN: 6, - - /** - * Color Dodge blend mode. - * - * @name Phaser.BlendModes.COLOR_DODGE - */ - COLOR_DODGE: 7, - - /** - * Color Burn blend mode. - * - * @name Phaser.BlendModes.COLOR_BURN - */ - COLOR_BURN: 8, - - /** - * Hard Light blend mode. - * - * @name Phaser.BlendModes.HARD_LIGHT - */ - HARD_LIGHT: 9, - - /** - * Soft Light blend mode. - * - * @name Phaser.BlendModes.SOFT_LIGHT - */ - SOFT_LIGHT: 10, - - /** - * Difference blend mode. - * - * @name Phaser.BlendModes.DIFFERENCE - */ - DIFFERENCE: 11, - - /** - * Exclusion blend mode. - * - * @name Phaser.BlendModes.EXCLUSION - */ - EXCLUSION: 12, - - /** - * Hue blend mode. - * - * @name Phaser.BlendModes.HUE - */ - HUE: 13, - - /** - * Saturation blend mode. - * - * @name Phaser.BlendModes.SATURATION - */ - SATURATION: 14, - - /** - * Color blend mode. - * - * @name Phaser.BlendModes.COLOR - */ - COLOR: 15, - - /** - * Luminosity blend mode. - * - * @name Phaser.BlendModes.LUMINOSITY - */ - LUMINOSITY: 16 - -}; - - /***/ }), /* 52 */ /***/ (function(module, exports) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.WorldToTileY - * @private - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} The Y location in tile units. - */ -var WorldToTileY = function (worldY, snapToFloor, camera, layer) -{ - if (snapToFloor === undefined) { snapToFloor = true; } - - var tileHeight = layer.baseTileHeight; - var tilemapLayer = layer.tilemapLayer; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - // Find the world position relative to the static or dynamic layer's top left origin, - // factoring in the camera's vertical scroll - worldY = worldY - (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); - - tileHeight *= tilemapLayer.scaleY; - } - - return snapToFloor - ? Math.floor(worldY / tileHeight) - : worldY / tileHeight; -}; - -module.exports = WorldToTileY; - - -/***/ }), -/* 53 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.WorldToTileX - * @private - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} The X location in tile units. - */ -var WorldToTileX = function (worldX, snapToFloor, camera, layer) -{ - if (snapToFloor === undefined) { snapToFloor = true; } - - var tileWidth = layer.baseTileWidth; - var tilemapLayer = layer.tilemapLayer; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - // Find the world position relative to the static or dynamic layer's top left origin, - // factoring in the camera's horizontal scroll - worldX = worldX - (tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX)); - - tileWidth *= tilemapLayer.scaleX; - } - - return snapToFloor - ? Math.floor(worldX / tileWidth) - : worldX / tileWidth; -}; - -module.exports = WorldToTileX; - - -/***/ }), -/* 54 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check to see if the Ellipse contains the given x / y coordinates. - * - * @function Phaser.Geom.Ellipse.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {number} x - The x coordinate to check within the ellipse. - * @param {number} y - The y coordinate to check within the ellipse. - * - * @return {boolean} True if the coordinates are within the ellipse, otherwise false. - */ -var Contains = function (ellipse, x, y) -{ - if (ellipse.width <= 0 || ellipse.height <= 0) - { - return false; - } - - // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 - var normx = ((x - ellipse.x) / ellipse.width); - var normy = ((y - ellipse.y) / ellipse.height); - - normx *= normx; - normy *= normy; - - return (normx + normy < 0.25); -}; - -module.exports = Contains; - - -/***/ }), -/* 55 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Scene consts. - * - * @ignore - */ - -var CONST = { - - /** - * Scene state. - * - * @name Phaser.Scenes.PENDING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - PENDING: 0, - - /** - * Scene state. - * - * @name Phaser.Scenes.INIT - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - INIT: 1, - - /** - * Scene state. - * - * @name Phaser.Scenes.START - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - START: 2, - - /** - * Scene state. - * - * @name Phaser.Scenes.LOADING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - LOADING: 3, - - /** - * Scene state. - * - * @name Phaser.Scenes.CREATING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - CREATING: 4, - - /** - * Scene state. - * - * @name Phaser.Scenes.RUNNING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - RUNNING: 5, - - /** - * Scene state. - * - * @name Phaser.Scenes.PAUSED - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - PAUSED: 6, - - /** - * Scene state. - * - * @name Phaser.Scenes.SLEEPING - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - SLEEPING: 7, - - /** - * Scene state. - * - * @name Phaser.Scenes.SHUTDOWN - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - SHUTDOWN: 8, - - /** - * Scene state. - * - * @name Phaser.Scenes.DESTROYED - * @readOnly - * @type {integer} - * @since 3.0.0 - */ - DESTROYED: 9 - -}; - -module.exports = CONST; - - -/***/ }), -/* 56 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Removes a single item from an array and returns it without creating gc, like the native splice does. - * Based on code by Mike Reinstein. - * - * @function Phaser.Utils.Array.SpliceOne - * @since 3.0.0 - * - * @param {array} array - [description] - * @param {integer} index - [description] - * - * @return {*} [description] - */ -var SpliceOne = function (array, index) -{ - if (index >= array.length) - { - return; - } - - var len = array.length - 1; - - var item = array[index]; - - for (var i = index; i < len; i++) - { - array[i] = array[i + 1]; - } - - array.length = len; - - return item; -}; - -module.exports = SpliceOne; - - -/***/ }), -/* 57 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(process) {/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Determines the operating system of the device running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.os` from within any Scene. - * - * @typedef {object} Phaser.Device.OS - * @since 3.0.0 - * - * @property {boolean} android - Is running on android? - * @property {boolean} chromeOS - Is running on chromeOS? - * @property {boolean} cocoonJS - Is the game running under CocoonJS? - * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? - * @property {boolean} cordova - Is the game running under Apache Cordova? - * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? - * @property {boolean} desktop - Is running on a desktop? - * @property {boolean} ejecta - Is the game running under Ejecta? - * @property {boolean} electron - Is the game running under GitHub Electron? - * @property {boolean} iOS - Is running on iOS? - * @property {boolean} iPad - Is running on iPad? - * @property {boolean} iPhone - Is running on iPhone? - * @property {boolean} kindle - Is running on an Amazon Kindle? - * @property {boolean} linux - Is running on linux? - * @property {boolean} macOS - Is running on macOS? - * @property {boolean} node - Is the game running under Node.js? - * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? - * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView - * @property {boolean} windows - Is running on windows? - * @property {boolean} windowsPhone - Is running on a Windows Phone? - * @property {number} iOSVersion - If running in iOS this will contain the major version number. - * @property {number} pixelRatio - PixelRatio of the host device? - */ -var OS = { - - android: false, - chromeOS: false, - cocoonJS: false, - cocoonJSApp: false, - cordova: false, - crosswalk: false, - desktop: false, - ejecta: false, - electron: false, - iOS: false, - iOSVersion: 0, - iPad: false, - iPhone: false, - kindle: false, - linux: false, - macOS: false, - node: false, - nodeWebkit: false, - pixelRatio: 1, - webApp: false, - windows: false, - windowsPhone: false - -}; - -function init () -{ - var ua = navigator.userAgent; - - if (/Windows/.test(ua)) - { - OS.windows = true; - } - else if (/Mac OS/.test(ua)) - { - OS.macOS = true; - } - else if (/Android/.test(ua)) - { - OS.android = true; - } - else if (/Linux/.test(ua)) - { - OS.linux = true; - } - else if (/iP[ao]d|iPhone/i.test(ua)) - { - OS.iOS = true; - (navigator.appVersion).match(/OS (\d+)/); - OS.iOSVersion = parseInt(RegExp.$1, 10); - } - else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) - { - OS.kindle = true; - - // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... - // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" - } - else if (/CrOS/.test(ua)) - { - OS.chromeOS = true; - } - - if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) - { - OS.android = false; - OS.iOS = false; - OS.macOS = false; - OS.windows = true; - OS.windowsPhone = true; - } - - var silk = (/Silk/).test(ua); - - if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) - { - OS.desktop = true; - } - - // Windows Phone / Table reset - if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) - { - OS.desktop = false; - } - - // WebApp mode in iOS - if (navigator.standalone) - { - OS.webApp = true; - } - - if (window.cordova !== undefined) - { - OS.cordova = true; - } - - if (process && process.versions && process.versions.node) - { - OS.node = true; - } - - if (OS.node && typeof process.versions === 'object') - { - OS.nodeWebkit = !!process.versions['node-webkit']; - - OS.electron = !!process.versions.electron; - } - - if (navigator.isCocoonJS) - { - OS.cocoonJS = true; - - try - { - OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); - } - catch (error) - { - OS.cocoonJSApp = false; - } - } - - if (window.ejecta !== undefined) - { - OS.ejecta = true; - } - - if ((/Crosswalk/).test(ua)) - { - OS.crosswalk = true; - } - - OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; - OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; - - OS.pixelRatio = window['devicePixelRatio'] || 1; - - return OS; -} - -module.exports = init(); - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(537))) - -/***/ }), -/* 58 */ -/***/ (function(module, exports) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -8507,7 +9011,7 @@ module.exports = DistanceBetween; /***/ }), -/* 59 */ +/* 53 */ /***/ (function(module, exports) { /** @@ -8517,371 +9021,29 @@ module.exports = DistanceBetween; */ /** - * Phaser Scale Modes. - * - * @name Phaser.ScaleModes - * @enum {integer} - * @memberOf Phaser - * @readOnly - * @since 3.0.0 - */ - -module.exports = { - - /** - * Default Scale Mode (Linear). - * - * @name Phaser.ScaleModes.DEFAULT - */ - DEFAULT: 0, - - /** - * Linear Scale Mode. - * - * @name Phaser.ScaleModes.LINEAR - */ - LINEAR: 0, - - /** - * Nearest Scale Mode. - * - * @name Phaser.ScaleModes.NEAREST - */ - NEAREST: 1 - -}; - - -/***/ }), -/* 60 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// http://www.blackpawn.com/texts/pointinpoly/ - -/** - * [description] + * Wrap the given `value` between `min` and `max. * - * @function Phaser.Geom.Triangle.Contains + * @function Phaser.Math.Wrap * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} value - The value to wrap. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. * - * @return {boolean} [description] + * @return {number} The wrapped value. */ -var Contains = function (triangle, x, y) +var Wrap = function (value, min, max) { - var v0x = triangle.x3 - triangle.x1; - var v0y = triangle.y3 - triangle.y1; + var range = max - min; - var v1x = triangle.x2 - triangle.x1; - var v1y = triangle.y2 - triangle.y1; - - var v2x = x - triangle.x1; - var v2y = y - triangle.y1; - - var dot00 = (v0x * v0x) + (v0y * v0y); - var dot01 = (v0x * v1x) + (v0y * v1y); - var dot02 = (v0x * v2x) + (v0y * v2y); - var dot11 = (v1x * v1x) + (v1y * v1y); - var dot12 = (v1x * v2x) + (v1y * v2y); - - // Compute barycentric coordinates - var b = ((dot00 * dot11) - (dot01 * dot01)); - var inv = (b === 0) ? 0 : (1 / b); - var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; - var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; - - return (u >= 0 && v >= 0 && (u + v < 1)); + return (min + ((((value - min) % range) + range) % range)); }; -module.exports = Contains; +module.exports = Wrap; /***/ }), -/* 61 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TWEEN_CONST = { - - /** - * TweenData state. - * - * @name Phaser.Tweens.CREATED - * @type {integer} - * @since 3.0.0 - */ - CREATED: 0, - - /** - * TweenData state. - * - * @name Phaser.Tweens.INIT - * @type {integer} - * @since 3.0.0 - */ - INIT: 1, - - /** - * TweenData state. - * - * @name Phaser.Tweens.DELAY - * @type {integer} - * @since 3.0.0 - */ - DELAY: 2, - - /** - * TweenData state. - * - * @name Phaser.Tweens.OFFSET_DELAY - * @type {integer} - * @since 3.0.0 - */ - OFFSET_DELAY: 3, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PENDING_RENDER - * @type {integer} - * @since 3.0.0 - */ - PENDING_RENDER: 4, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PLAYING_FORWARD - * @type {integer} - * @since 3.0.0 - */ - PLAYING_FORWARD: 5, - - /** - * TweenData state. - * - * @name Phaser.Tweens.PLAYING_BACKWARD - * @type {integer} - * @since 3.0.0 - */ - PLAYING_BACKWARD: 6, - - /** - * TweenData state. - * - * @name Phaser.Tweens.HOLD_DELAY - * @type {integer} - * @since 3.0.0 - */ - HOLD_DELAY: 7, - - /** - * TweenData state. - * - * @name Phaser.Tweens.REPEAT_DELAY - * @type {integer} - * @since 3.0.0 - */ - REPEAT_DELAY: 8, - - /** - * TweenData state. - * - * @name Phaser.Tweens.COMPLETE - * @type {integer} - * @since 3.0.0 - */ - COMPLETE: 9, - - // Tween specific (starts from 20 to cleanly allow extra TweenData consts in the future) - - /** - * Tween state. - * - * @name Phaser.Tweens.PENDING_ADD - * @type {integer} - * @since 3.0.0 - */ - PENDING_ADD: 20, - - /** - * Tween state. - * - * @name Phaser.Tweens.PAUSED - * @type {integer} - * @since 3.0.0 - */ - PAUSED: 21, - - /** - * Tween state. - * - * @name Phaser.Tweens.LOOP_DELAY - * @type {integer} - * @since 3.0.0 - */ - LOOP_DELAY: 22, - - /** - * Tween state. - * - * @name Phaser.Tweens.ACTIVE - * @type {integer} - * @since 3.0.0 - */ - ACTIVE: 23, - - /** - * Tween state. - * - * @name Phaser.Tweens.COMPLETE_DELAY - * @type {integer} - * @since 3.0.0 - */ - COMPLETE_DELAY: 24, - - /** - * Tween state. - * - * @name Phaser.Tweens.PENDING_REMOVE - * @type {integer} - * @since 3.0.0 - */ - PENDING_REMOVE: 25, - - /** - * Tween state. - * - * @name Phaser.Tweens.REMOVED - * @type {integer} - * @since 3.0.0 - */ - REMOVED: 26 - -}; - -module.exports = TWEEN_CONST; - - -/***/ }), -/* 62 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetBoolean - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {*} [description] - */ -var GetBoolean = function (source, key, defaultValue) -{ - if (!source) - { - return defaultValue; - } - else if (source.hasOwnProperty(key)) - { - return source[key]; - } - else - { - return defaultValue; - } -}; - -module.exports = GetBoolean; - - -/***/ }), -/* 63 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var EaseMap = __webpack_require__(453); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetEaseFunction - * @since 3.0.0 - * - * @param {(string|function)} ease - [description] - * @param {array} easeParams - [description] - * - * @return {function} [description] - */ -var GetEaseFunction = function (ease, easeParams) -{ - if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) - { - if (easeParams) - { - var cloneParams = easeParams.slice(0); - - cloneParams.unshift(0); - - return function (v) - { - cloneParams[0] = v; - - return EaseMap[ease].apply(this, cloneParams); - }; - } - else - { - // String based look-up - return EaseMap[ease]; - } - } - else if (typeof ease === 'function') - { - // Custom function - return ease; - } - else if (Array.isArray(ease) && ease.length === 4) - { - // Bezier function (TODO) - } - - return EaseMap.Power0; -}; - -module.exports = GetEaseFunction; - - -/***/ }), -/* 64 */ +/* 54 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -8891,628 +9053,322 @@ module.exports = GetEaseFunction; */ var Class = __webpack_require__(0); +var GetPoint = __webpack_require__(397); +var GetPoints = __webpack_require__(189); +var Random = __webpack_require__(188); +var Vector2 = __webpack_require__(3); /** * @classdesc - * [description] + * Defines a Line segment, a part of a line between two endpoints. * - * @class TransformMatrix - * @memberOf Phaser.GameObjects.Components + * @class Line + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * - * @param {number} [a=1] - The Scale X value. - * @param {number} [b=0] - The Shear Y value. - * @param {number} [c=0] - The Shear X value. - * @param {number} [d=1] - The Scale Y value. - * @param {number} [tx=0] - The Translate X value. - * @param {number} [ty=0] - The Translate Y value. + * @param {number} [x1=0] - The x coordinate of the lines starting point. + * @param {number} [y1=0] - The y coordinate of the lines starting point. + * @param {number} [x2=0] - The x coordinate of the lines ending point. + * @param {number} [y2=0] - The y coordinate of the lines ending point. */ -var TransformMatrix = new Class({ +var Line = new Class({ initialize: - function TransformMatrix (a, b, c, d, tx, ty) + function Line (x1, y1, x2, y2) { - if (a === undefined) { a = 1; } - if (b === undefined) { b = 0; } - if (c === undefined) { c = 0; } - if (d === undefined) { d = 1; } - if (tx === undefined) { tx = 0; } - if (ty === undefined) { ty = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } /** - * [description] + * The x coordinate of the lines starting point. * - * @name Phaser.GameObjects.Components.TransformMatrix#matrix - * @type {Float32Array} + * @name Phaser.Geom.Line#x1 + * @type {number} * @since 3.0.0 */ - this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + this.x1 = x1; /** - * [description] + * The y coordinate of the lines starting point. * - * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix - * @type {object} + * @name Phaser.Geom.Line#y1 + * @type {number} * @since 3.0.0 */ - this.decomposedMatrix = { - translateX: 0, - translateY: 0, - scaleX: 1, - scaleY: 1, - rotation: 0 - }; + this.y1 = y1; + + /** + * The x coordinate of the lines ending point. + * + * @name Phaser.Geom.Line#x2 + * @type {number} + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * The y coordinate of the lines ending point. + * + * @name Phaser.Geom.Line#y2 + * @type {number} + * @since 3.0.0 + */ + this.y2 = y2; }, /** - * [description] + * Get a point on a line that's a given percentage along its length. * - * @name Phaser.GameObjects.Components.TransformMatrix#a - * @type {number} - * @since 3.4.0 + * @method Phaser.Geom.Line#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {(Phaser.Geom.Point|object)} [output] - An optional point, or point-like object, to store the coordinates of the point on the line. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point on the line. */ - a: { + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * @method Phaser.Geom.Line#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {integer} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {integer} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param {(array|Phaser.Geom.Point[])} [output] - An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * + * @return {(array|Phaser.Geom.Point[])} An array of Points, or point-like objects, containing the coordinates of the points on the line. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Get a random Point on the Line. + * + * @method Phaser.Geom.Line#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {(Phaser.Geom.Point|object)} [point] - An instance of a Point to be modified. + * + * @return {Phaser.Geom.Point} A random Point on the Line. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Set new coordinates for the line endpoints. + * + * @method Phaser.Geom.Line#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - The x coordinate of the lines starting point. + * @param {number} [y1=0] - The y coordinate of the lines starting point. + * @param {number} [x2=0] - The x coordinate of the lines ending point. + * @param {number} [y2=0] - The y coordinate of the lines ending point. + * + * @return {Phaser.Geom.Line} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + return this; + }, + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * + * @method Phaser.Geom.Line#getPointA + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + */ + getPointA: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x1, this.y1); + + return vec2; + }, + + /** + * Returns a Vector2 object that corresponds to the end of this Line. + * + * @method Phaser.Geom.Line#getPointB + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the end of this Line. + */ + getPointB: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x2, this.y2); + + return vec2; + }, + + /** + * The left position of the Line. + * + * @name Phaser.Geom.Line#left + * @type {number} + * @since 3.0.0 + */ + left: { get: function () { - return this.matrix[0]; + return Math.min(this.x1, this.x2); }, set: function (value) { - this.matrix[0] = value; + if (this.x1 <= this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } } }, /** - * [description] + * The right position of the Line. * - * @name Phaser.GameObjects.Components.TransformMatrix#b + * @name Phaser.Geom.Line#right * @type {number} - * @since 3.4.0 + * @since 3.0.0 */ - b: { + right: { get: function () { - return this.matrix[1]; + return Math.max(this.x1, this.x2); }, set: function (value) { - this.matrix[1] = value; + if (this.x1 > this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } } }, /** - * [description] + * The top position of the Line. * - * @name Phaser.GameObjects.Components.TransformMatrix#c + * @name Phaser.Geom.Line#top * @type {number} - * @since 3.4.0 + * @since 3.0.0 */ - c: { + top: { get: function () { - return this.matrix[2]; + return Math.min(this.y1, this.y2); }, set: function (value) { - this.matrix[2] = value; + if (this.y1 <= this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } } }, /** - * [description] + * The bottom position of the Line. * - * @name Phaser.GameObjects.Components.TransformMatrix#d + * @name Phaser.Geom.Line#bottom * @type {number} - * @since 3.4.0 + * @since 3.0.0 */ - d: { + bottom: { get: function () { - return this.matrix[3]; + return Math.max(this.y1, this.y2); }, set: function (value) { - this.matrix[3] = value; + if (this.y1 > this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } } - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#tx - * @type {number} - * @since 3.4.0 - */ - tx: { - - get: function () - { - return this.matrix[4]; - }, - - set: function (value) - { - this.matrix[4] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#ty - * @type {number} - * @since 3.4.0 - */ - ty: { - - get: function () - { - return this.matrix[5]; - }, - - set: function (value) - { - this.matrix[5] = value; - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#rotation - * @type {number} - * @readOnly - * @since 3.4.0 - */ - rotation: { - - get: function () - { - return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1); - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#scaleX - * @type {number} - * @readOnly - * @since 3.4.0 - */ - scaleX: { - - get: function () - { - return Math.sqrt((this.a * this.a) + (this.c * this.c)); - } - - }, - - /** - * [description] - * - * @name Phaser.GameObjects.Components.TransformMatrix#scaleY - * @type {number} - * @readOnly - * @since 3.4.0 - */ - scaleY: { - - get: function () - { - return Math.sqrt((this.b * this.b) + (this.d * this.d)); - } - - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity - * @since 3.0.0 - * - * @return {this} This TransformMatrix. - */ - loadIdentity: function () - { - var matrix = this.matrix; - - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 1; - matrix[4] = 0; - matrix[5] = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#translate - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {this} This TransformMatrix. - */ - translate: function (x, y) - { - var matrix = this.matrix; - - matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; - matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#scale - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {this} This TransformMatrix. - */ - scale: function (x, y) - { - var matrix = this.matrix; - - matrix[0] *= x; - matrix[1] *= x; - matrix[2] *= y; - matrix[3] *= y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#rotate - * @since 3.0.0 - * - * @param {number} radian - [description] - * - * @return {this} This TransformMatrix. - */ - rotate: function (radian) - { - var radianSin = Math.sin(radian); - var radianCos = Math.cos(radian); - var matrix = this.matrix; - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - - matrix[0] = a * radianCos + c * radianSin; - matrix[1] = b * radianCos + d * radianSin; - matrix[2] = a * -radianSin + c * radianCos; - matrix[3] = b * -radianSin + d * radianCos; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#multiply - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - [description] - * - * @return {this} This TransformMatrix. - */ - multiply: function (rhs) - { - var matrix = this.matrix; - var otherMatrix = rhs.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - var a1 = otherMatrix[0]; - var b1 = otherMatrix[1]; - var c1 = otherMatrix[2]; - var d1 = otherMatrix[3]; - var tx1 = otherMatrix[4]; - var ty1 = otherMatrix[5]; - - matrix[0] = a1 * a0 + b1 * c0; - matrix[1] = a1 * b0 + b1 * d0; - matrix[2] = c1 * a0 + d1 * c0; - matrix[3] = c1 * b0 + d1 * d0; - matrix[4] = tx1 * a0 + ty1 * c0 + tx0; - matrix[5] = tx1 * b0 + ty1 * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transform - * @since 3.0.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This TransformMatrix. - */ - transform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - var a0 = matrix[0]; - var b0 = matrix[1]; - var c0 = matrix[2]; - var d0 = matrix[3]; - var tx0 = matrix[4]; - var ty0 = matrix[5]; - - matrix[0] = a * a0 + b * c0; - matrix[1] = a * b0 + b * d0; - matrix[2] = c * a0 + d * c0; - matrix[3] = c * b0 + d * d0; - matrix[4] = tx * a0 + ty * c0 + tx0; - matrix[5] = tx * b0 + ty * d0 + ty0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - [description] - * - * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} [description] - */ - transformPoint: function (x, y, point) - { - if (point === undefined) { point = { x: 0, y: 0 }; } - - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - point.x = x * a + y * c + tx; - point.y = x * b + y * d + ty; - - return point; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#invert - * @since 3.0.0 - * - * @return {this} This TransformMatrix. - */ - invert: function () - { - var matrix = this.matrix; - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - var tx = matrix[4]; - var ty = matrix[5]; - - var n = a * d - b * c; - - matrix[0] = d / n; - matrix[1] = -b / n; - matrix[2] = -c / n; - matrix[3] = a / n; - matrix[4] = (c * ty - d * tx) / n; - matrix[5] = -(a * ty - b * tx) / n; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#setTransform - * @since 3.0.0 - * - * @param {number} a - [description] - * @param {number} b - [description] - * @param {number} c - [description] - * @param {number} d - [description] - * @param {number} tx - [description] - * @param {number} ty - [description] - * - * @return {this} This TransformMatrix. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var matrix = this.matrix; - - matrix[0] = a; - matrix[1] = b; - matrix[2] = c; - matrix[3] = d; - matrix[4] = tx; - matrix[5] = ty; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix - * @since 3.0.0 - * - * @return {object} [description] - */ - decomposeMatrix: function () - { - var decomposedMatrix = this.decomposedMatrix; - - var matrix = this.matrix; - - // a = scale X (1) - // b = shear Y (0) - // c = shear X (0) - // d = scale Y (1) - - var a = matrix[0]; - var b = matrix[1]; - var c = matrix[2]; - var d = matrix[3]; - - var a2 = a * a; - var b2 = b * b; - var c2 = c * c; - var d2 = d * d; - - var sx = Math.sqrt(a2 + c2); - var sy = Math.sqrt(b2 + d2); - - decomposedMatrix.translateX = matrix[4]; - decomposedMatrix.translateY = matrix[5]; - - decomposedMatrix.scaleX = sx; - decomposedMatrix.scaleY = sy; - - decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); - - return decomposedMatrix; - }, - - /** - * Identity + Translate + Rotate + Scale - * - * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} rotation - [description] - * @param {number} scaleX - [description] - * @param {number} scaleY - [description] - * - * @return {this} This TransformMatrix. - */ - applyITRS: function (x, y, rotation, scaleX, scaleY) - { - var matrix = this.matrix; - - var radianSin = Math.sin(rotation); - var radianCos = Math.cos(rotation); - - // Translate - matrix[4] = x; - matrix[5] = y; - - // Rotate and Scale - matrix[0] = radianCos * scaleX; - matrix[1] = radianSin * scaleX; - matrix[2] = -radianSin * scaleY; - matrix[3] = radianCos * scaleY; - - return this; - }, - - /** - * Destroys this Transform Matrix. - * - * @method Phaser.GameObjects.Components.TransformMatrix#destroy - * @since 3.4.0 - */ - destroy: function () - { - this.matrix = null; - this.decomposedMatrix = null; } }); -module.exports = TransformMatrix; +module.exports = Line; /***/ }), -/* 65 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); - -/** - * Return a value based on the range between `min` and `max` and the percentage given. - * - * @function Phaser.Math.FromPercent - * @since 3.0.0 - * - * @param {float} percent - A value between 0 and 1 representing the percentage. - * @param {number} min - The minimum value. - * @param {number} [max] - The maximum value. - * - * @return {number} The value that is `percent` percent between `min` and `max`. - */ -var FromPercent = function (percent, min, max) -{ - percent = Clamp(percent, 0, 1); - - return (max - min) * percent; -}; - -module.exports = FromPercent; - - -/***/ }), -/* 66 */ +/* 55 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -9522,8 +9378,8 @@ module.exports = FromPercent; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var Rectangle = __webpack_require__(389); +var Components = __webpack_require__(14); +var Rectangle = __webpack_require__(265); /** * @classdesc @@ -9532,7 +9388,7 @@ var Rectangle = __webpack_require__(389); * scale or layer position. * * @class Tile - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -10237,7 +10093,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#canCollide * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ canCollide: { @@ -10252,7 +10108,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#collides * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ collides: { @@ -10267,7 +10123,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#hasInterestingFace * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ hasInterestingFace: { @@ -10283,7 +10139,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#tileset * @type {?Phaser.Tilemaps.Tileset} - * @readOnly + * @readonly * @since 3.0.0 */ tileset: { @@ -10301,7 +10157,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#tilemapLayer * @type {?Phaser.Tilemaps.StaticTilemapLayer|Phaser.Tilemaps.DynamicTilemapLayer} - * @readOnly + * @readonly * @since 3.0.0 */ tilemapLayer: { @@ -10317,7 +10173,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#tilemap * @type {?Phaser.Tilemaps.Tilemap} - * @readOnly + * @readonly * @since 3.0.0 */ tilemap: { @@ -10334,7 +10190,7 @@ module.exports = Tile; /***/ }), -/* 67 */ +/* 56 */ /***/ (function(module, exports) { /** @@ -10351,8 +10207,8 @@ module.exports = Tile; * @private * @since 3.0.0 * - * @param {Phaser.Tilemaps.Tile} tile - [description] - * @param {boolean} [collides=true] - [description] + * @param {Phaser.Tilemaps.Tile} tile - The Tile to set the collision on. + * @param {boolean} [collides=true] - Should the tile index collide or not? */ var SetTileCollision = function (tile, collides) { @@ -10370,7 +10226,7 @@ module.exports = SetTileCollision; /***/ }), -/* 68 */ +/* 57 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -10380,11 +10236,501 @@ module.exports = SetTileCollision; */ var Class = __webpack_require__(0); -var Contains = __webpack_require__(60); -var GetPoint = __webpack_require__(227); -var GetPoints = __webpack_require__(226); -var Line = __webpack_require__(96); -var Random = __webpack_require__(153); + +/** + * @classdesc + * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after + * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont. + * + * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. + * + * @class MultiFile + * @memberof Phaser.Loader + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. + * @param {string} type - The file type string for sorting within the Loader. + * @param {string} key - The key of the file within the loader. + * @param {Phaser.Loader.File[]} files - An array of Files that make-up this MultiFile. + */ +var MultiFile = new Class({ + + initialize: + + function MultiFile (loader, type, key, files) + { + /** + * A reference to the Loader that is going to load this file. + * + * @name Phaser.Loader.MultiFile#loader + * @type {Phaser.Loader.LoaderPlugin} + * @since 3.7.0 + */ + this.loader = loader; + + /** + * The file type string for sorting within the Loader. + * + * @name Phaser.Loader.MultiFile#type + * @type {string} + * @since 3.7.0 + */ + this.type = type; + + /** + * Unique cache key (unique within its file type) + * + * @name Phaser.Loader.MultiFile#key + * @type {string} + * @since 3.7.0 + */ + this.key = key; + + /** + * Array of files that make up this MultiFile. + * + * @name Phaser.Loader.MultiFile#files + * @type {Phaser.Loader.File[]} + * @since 3.7.0 + */ + this.files = files; + + /** + * The completion status of this MultiFile. + * + * @name Phaser.Loader.MultiFile#complete + * @type {boolean} + * @default false + * @since 3.7.0 + */ + this.complete = false; + + /** + * The number of files to load. + * + * @name Phaser.Loader.MultiFile#pending + * @type {integer} + * @since 3.7.0 + */ + + this.pending = files.length; + + /** + * The number of files that failed to load. + * + * @name Phaser.Loader.MultiFile#failed + * @type {integer} + * @default 0 + * @since 3.7.0 + */ + this.failed = 0; + + /** + * A storage container for transient data that the loading files need. + * + * @name Phaser.Loader.MultiFile#config + * @type {any} + * @since 3.7.0 + */ + this.config = {}; + + // Link the files + for (var i = 0; i < files.length; i++) + { + files[i].multiFile = this; + } + }, + + /** + * Checks if this MultiFile is ready to process its children or not. + * + * @method Phaser.Loader.MultiFile#isReadyToProcess + * @since 3.7.0 + * + * @return {boolean} `true` if all children of this MultiFile have loaded, otherwise `false`. + */ + isReadyToProcess: function () + { + return (this.pending === 0 && this.failed === 0 && !this.complete); + }, + + /** + * Adds another child to this MultiFile, increases the pending count and resets the completion status. + * + * @method Phaser.Loader.MultiFile#addToMultiFile + * @since 3.7.0 + * + * @param {Phaser.Loader.File} files - The File to add to this MultiFile. + * + * @return {Phaser.Loader.MultiFile} This MultiFile instance. + */ + addToMultiFile: function (file) + { + this.files.push(file); + + file.multiFile = this; + + this.pending++; + + this.complete = false; + + return this; + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.MultiFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + } + }, + + /** + * Called by each File that fails to load. + * + * @method Phaser.Loader.MultiFile#onFileFailed + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has failed to load. + */ + onFileFailed: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.failed++; + } + } + +}); + +module.exports = MultiFile; + + +/***/ }), +/* 58 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.ImageFrameConfig + * + * @property {integer} frameWidth - The width of the frame in pixels. + * @property {integer} [frameHeight] - The height of the frame in pixels. Uses the `frameWidth` value if not provided. + * @property {integer} [startFrame=0] - The first frame to start parsing from. + * @property {integer} [endFrame] - The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions. + * @property {integer} [margin=0] - The margin in the image. This is the space around the edge of the frames. + * @property {integer} [spacing=0] - The spacing between each frame in the image. + */ + +/** + * @typedef {object} Phaser.Loader.FileTypes.ImageFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='png'] - The default file extension to use if no url is provided. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image. + * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Image File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. + * + * @class ImageFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. + */ +var ImageFile = new Class({ + + Extends: File, + + initialize: + + function ImageFile (loader, key, url, xhrSettings, frameConfig) + { + var extension = 'png'; + var normalMapURL; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + normalMapURL = GetFastValue(config, 'normalMap'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + frameConfig = GetFastValue(config, 'frameConfig'); + } + + if (Array.isArray(url)) + { + normalMapURL = url[1]; + url = url[0]; + } + + var fileConfig = { + type: 'image', + cache: loader.textureManager, + extension: extension, + responseType: 'blob', + key: key, + url: url, + xhrSettings: xhrSettings, + config: frameConfig + }; + + File.call(this, loader, fileConfig); + + // Do we have a normal map to load as well? + if (normalMapURL) + { + var normalMap = new ImageFile(loader, this.key, normalMapURL, xhrSettings, frameConfig); + + normalMap.type = 'normalMap'; + + this.setLink(normalMap); + + loader.addFile(normalMap); + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.ImageFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var _this = this; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessError(); + }; + + File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.ImageFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture; + var linkFile = this.linkFile; + + if (linkFile && linkFile.state === CONST.FILE_COMPLETE) + { + if (this.type === 'image') + { + texture = this.cache.addImage(this.key, this.data, linkFile.data); + } + else + { + texture = this.cache.addImage(linkFile.key, linkFile.data, this.data); + } + + this.pendingDestroy(texture); + + linkFile.pendingDestroy(texture); + } + else if (!linkFile) + { + texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + } + +}); + +/** + * Adds an Image, or array of Images, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.image('logo', 'images/phaserLogo.png'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback + * of animated gifs to Canvas elements. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.image({ + * key: 'logo', + * url: 'images/AtariLogo.png' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.image('logo', 'images/AtariLogo.png'); + * // and later in your game ... + * this.add.image(x, y, 'logo'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.image({ + * key: 'logo', + * url: 'images/AtariLogo.png', + * normalMap: 'images/AtariLogo-n.png' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#image + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('image', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ImageFile(this, key[i])); + } + } + else + { + this.addFile(new ImageFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = ImageFile; + + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(69); +var GetPoint = __webpack_require__(278); +var GetPoints = __webpack_require__(277); +var Line = __webpack_require__(54); +var Random = __webpack_require__(184); /** * @classdesc @@ -10393,16 +10739,16 @@ var Random = __webpack_require__(153); * specify the second point, and the last two arguments specify the third point. * * @class Triangle - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. */ var Triangle = new Class({ @@ -10418,7 +10764,7 @@ var Triangle = new Class({ if (y3 === undefined) { y3 = 0; } /** - * [description] + * `x` coordinate of the first point. * * @name Phaser.Geom.Triangle#x1 * @type {number} @@ -10428,7 +10774,7 @@ var Triangle = new Class({ this.x1 = x1; /** - * [description] + * `y` coordinate of the first point. * * @name Phaser.Geom.Triangle#y1 * @type {number} @@ -10438,7 +10784,7 @@ var Triangle = new Class({ this.y1 = y1; /** - * [description] + * `x` coordinate of the second point. * * @name Phaser.Geom.Triangle#x2 * @type {number} @@ -10448,7 +10794,7 @@ var Triangle = new Class({ this.x2 = x2; /** - * [description] + * `y` coordinate of the second point. * * @name Phaser.Geom.Triangle#y2 * @type {number} @@ -10458,7 +10804,7 @@ var Triangle = new Class({ this.y2 = y2; /** - * [description] + * `x` coordinate of the third point. * * @name Phaser.Geom.Triangle#x3 * @type {number} @@ -10468,7 +10814,7 @@ var Triangle = new Class({ this.x3 = x3; /** - * [description] + * `y` coordinate of the third point. * * @name Phaser.Geom.Triangle#y3 * @type {number} @@ -10479,15 +10825,15 @@ var Triangle = new Class({ }, /** - * [description] + * Checks whether a given points lies within the triangle. * * @method Phaser.Geom.Triangle#contains * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The x coordinate of the point to check. + * @param {number} y - The y coordinate of the point to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the coordinate pair is within the triangle, otherwise `false`. */ contains: function (x, y) { @@ -10495,17 +10841,17 @@ var Triangle = new Class({ }, /** - * [description] + * Returns a specific point on the triangle. * * @method Phaser.Geom.Triangle#getPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [output,$return] * - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] + * @param {number} position - Position as float within `0` and `1`. `0` equals the first point. + * @param {(Phaser.Geom.Point|object)} [output] - Optional Point, or point-like object, that the calculated point will be written to. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} Calculated `Point` that represents the requested position. It is the same as `output` when this parameter has been given. */ getPoint: function (position, output) { @@ -10513,18 +10859,18 @@ var Triangle = new Class({ }, /** - * [description] + * Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (`quantity`) or the distance between two points (`stepRate`). * * @method Phaser.Geom.Triangle#getPoints * @since 3.0.0 * * @generic {Phaser.Geom.Point[]} O - [output,$return] * - * @param {integer} quantity - [description] - * @param {number} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * @param {integer} quantity - Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. + * @param {number} [stepRate] - Distance between two points. Will only be used when `quantity` is falsey. + * @param {(array|Phaser.Geom.Point[])} [output] - Optional Array for writing the calculated points into. Otherwise a new array will be created. * - * @return {(array|Phaser.Geom.Point[])} [description] + * @return {(array|Phaser.Geom.Point[])} Returns a list of calculated `Point` instances or the filled array passed as parameter `output`. */ getPoints: function (quantity, stepRate, output) { @@ -10532,16 +10878,16 @@ var Triangle = new Class({ }, /** - * [description] + * Returns a random point along the triangle. * * @method Phaser.Geom.Triangle#getRandomPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [point,$return] * - * @param {Phaser.Geom.Point} [point] - [description] + * @param {Phaser.Geom.Point} [point] - Optional `Point` that should be modified. Otherwise a new one will be created. * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Point} Random `Point`. When parameter `point` has been provided it will be returned. */ getRandomPoint: function (point) { @@ -10549,17 +10895,17 @@ var Triangle = new Class({ }, /** - * [description] + * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. * * @method Phaser.Geom.Triangle#setTo * @since 3.0.0 * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. * * @return {Phaser.Geom.Triangle} This Triangle object. */ @@ -10648,7 +10994,7 @@ var Triangle = new Class({ }, /** - * [description] + * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. * * @name Phaser.Geom.Triangle#left * @type {number} @@ -10686,7 +11032,7 @@ var Triangle = new Class({ }, /** - * [description] + * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. * * @name Phaser.Geom.Triangle#right * @type {number} @@ -10724,7 +11070,7 @@ var Triangle = new Class({ }, /** - * [description] + * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. * * @name Phaser.Geom.Triangle#top * @type {number} @@ -10762,7 +11108,7 @@ var Triangle = new Class({ }, /** - * [description] + * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. * * @name Phaser.Geom.Triangle#bottom * @type {number} @@ -10805,7 +11151,82 @@ module.exports = Triangle; /***/ }), -/* 69 */ +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders a stroke outline around the given Shape. + * + * @method Phaser.GameObjects.Shape#StrokePathWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The WebGL Pipeline used to render this Shape. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. + */ +var StrokePathWebGL = function (pipeline, src, alpha, dx, dy) +{ + var strokeTint = pipeline.strokeTint; + var strokeTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.strokeColor, src.strokeAlpha * alpha); + + strokeTint.TL = strokeTintColor; + strokeTint.TR = strokeTintColor; + strokeTint.BL = strokeTintColor; + strokeTint.BR = strokeTintColor; + + var path = src.pathData; + var pathLength = path.length - 1; + var lineWidth = src.lineWidth; + var halfLineWidth = lineWidth / 2; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + pipeline.setTexture2D(); + + pipeline.batchLine( + px1, + py1, + px2, + py2, + halfLineWidth, + halfLineWidth, + lineWidth, + i - 2, + (src.closePath) ? (i === pathLength - 1) : false + ); + + px1 = px2; + py1 = py2; + } +}; + +module.exports = StrokePathWebGL; + + +/***/ }), +/* 61 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -10815,22 +11236,25 @@ module.exports = Triangle; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var ImageRender = __webpack_require__(461); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var SpriteRender = __webpack_require__(829); /** * @classdesc - * An Image Game Object. + * A Sprite Game Object. * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. * - * @class Image + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -10845,7 +11269,7 @@ var ImageRender = __webpack_require__(461); * @extends Phaser.GameObjects.Components.ScaleMode * @extends Phaser.GameObjects.Components.ScrollFactor * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.TextureCrop * @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible @@ -10856,7 +11280,7 @@ var ImageRender = __webpack_require__(461); * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. */ -var Image = new Class({ +var Sprite = new Class({ Extends: GameObject, @@ -10872,471 +11296,117 @@ var Image = new Class({ Components.ScaleMode, Components.ScrollFactor, Components.Size, - Components.Texture, + Components.TextureCrop, Components.Tint, Components.Transform, Components.Visible, - ImageRender + SpriteRender ], initialize: - function Image (scene, x, y, texture, frame) + function Sprite (scene, x, y, texture, frame) { - GameObject.call(this, scene, 'Image'); + GameObject.call(this, scene, 'Sprite'); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Sprite#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Animation Controller of this Sprite. + * + * @name Phaser.GameObjects.Sprite#anims + * @type {Phaser.GameObjects.Components.Animation} + * @since 3.0.0 + */ + this.anims = new Components.Animation(this); this.setTexture(texture, frame); this.setPosition(x, y); this.setSizeToFrame(); this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); + this.initPipeline(); + }, + + /** + * Update this Sprite's animations. + * + * @method Phaser.GameObjects.Sprite#preUpdate + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + }, + + /** + * Start playing the given animation. + * + * @method Phaser.GameObjects.Sprite#play + * @since 3.0.0 + * + * @param {string} key - The string-based key of the animation to play. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.Sprite} This Game Object. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + this.anims.play(key, ignoreIfPlaying, startFrame); + + return this; + }, + + /** + * Build a JSON representation of this Sprite. + * + * @method Phaser.GameObjects.Sprite#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + var data = Components.ToJSON(this); + + // Extra Sprite data is added here + + return data; + }, + + /** + * Handles the pre-destroy step for the Sprite, which removes the Animation component. + * + * @method Phaser.GameObjects.Sprite#preDestroy + * @private + * @since 3.14.0 + */ + preDestroy: function () + { + this.anims.destroy(); + + this.anims = undefined; } }); -module.exports = Image; +module.exports = Sprite; /***/ }), -/* 70 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback EachSetCallback - * @generic E - [entry] - * - * @param {*} entry - [description] - * @param {number} index - [description] - * - * @return {?boolean} [description] - */ - -/** - * @classdesc - * A Set is a collection of unique elements. - * - * @class Set - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic T - * @genericUse {T[]} - [elements] - * - * @param {Array.<*>} [elements] - [description] - */ -var Set = new Class({ - - initialize: - - function Set (elements) - { - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.Set#entries - * @type {Array.<*>} - * @default [] - * @since 3.0.0 - */ - this.entries = []; - - if (Array.isArray(elements)) - { - for (var i = 0; i < elements.length; i++) - { - this.set(elements[i]); - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#set - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {*} value - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - set: function (value) - { - if (this.entries.indexOf(value) === -1) - { - this.entries.push(value); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#get - * @since 3.0.0 - * - * @genericUse {T} - [value,$return] - * - * @param {string} property - [description] - * @param {*} value - [description] - * - * @return {*} [description] - */ - get: function (property, value) - { - for (var i = 0; i < this.entries.length; i++) - { - var entry = this.entries[i]; - - if (entry[property] === value) - { - return entry; - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#getArray - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @return {Array.<*>} [description] - */ - getArray: function () - { - return this.entries.slice(0); - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#delete - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {*} value - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - delete: function (value) - { - var index = this.entries.indexOf(value); - - if (index > -1) - { - this.entries.splice(index, 1); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#dump - * @since 3.0.0 - */ - dump: function () - { - // eslint-disable-next-line no-console - console.group('Set'); - - for (var i = 0; i < this.entries.length; i++) - { - var entry = this.entries[i]; - console.log(entry); - } - - // eslint-disable-next-line no-console - console.groupEnd(); - }, - - /** - * For when you know this Set will be modified during the iteration. - * - * @method Phaser.Structs.Set#each - * @since 3.0.0 - * - * @genericUse {EachSetCallback.} - [callback] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {EachSetCallback} callback - [description] - * @param {*} callbackScope - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - each: function (callback, callbackScope) - { - var i; - var temp = this.entries.slice(); - var len = temp.length; - - if (callbackScope) - { - for (i = 0; i < len; i++) - { - if (callback.call(callbackScope, temp[i], i) === false) - { - break; - } - } - } - else - { - for (i = 0; i < len; i++) - { - if (callback(temp[i], i) === false) - { - break; - } - } - } - - return this; - }, - - /** - * For when you absolutely know this Set won't be modified during the iteration. - * - * @method Phaser.Structs.Set#iterate - * @since 3.0.0 - * - * @genericUse {EachSetCallback.} - [callback] - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {EachSetCallback} callback - [description] - * @param {*} callbackScope - [description] - * - * @return {Phaser.Structs.Set} This Set object. - */ - iterate: function (callback, callbackScope) - { - var i; - var len = this.entries.length; - - if (callbackScope) - { - for (i = 0; i < len; i++) - { - if (callback.call(callbackScope, this.entries[i], i) === false) - { - break; - } - } - } - else - { - for (i = 0; i < len; i++) - { - if (callback(this.entries[i], i) === false) - { - break; - } - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#iterateLocal - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @param {string} callbackKey - [description] - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - * - * @return {Phaser.Structs.Set} This Set object. - */ - iterateLocal: function (callbackKey) - { - var i; - var args = []; - - for (i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - var len = this.entries.length; - - for (i = 0; i < len; i++) - { - var entry = this.entries[i]; - - entry[callbackKey].apply(entry, args); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#clear - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [$return] - * - * @return {Phaser.Structs.Set} This Set object. - */ - clear: function () - { - this.entries.length = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#contains - * @since 3.0.0 - * - * @genericUse {T} - [value] - * - * @param {*} value - [description] - * - * @return {boolean} [description] - */ - contains: function (value) - { - return (this.entries.indexOf(value) > -1); - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#union - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [set,$return] - * - * @param {Phaser.Structs.Set} set - [description] - * - * @return {Phaser.Structs.Set} [description] - */ - union: function (set) - { - var newSet = new Set(); - - set.entries.forEach(function (value) - { - newSet.set(value); - }); - - this.entries.forEach(function (value) - { - newSet.set(value); - }); - - return newSet; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#intersect - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [set,$return] - * - * @param {Phaser.Structs.Set} set - [description] - * - * @return {Phaser.Structs.Set} [description] - */ - intersect: function (set) - { - var newSet = new Set(); - - this.entries.forEach(function (value) - { - if (set.contains(value)) - { - newSet.set(value); - } - }); - - return newSet; - }, - - /** - * [description] - * - * @method Phaser.Structs.Set#difference - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Set.} - [set,$return] - * - * @param {Phaser.Structs.Set} set - [description] - * - * @return {Phaser.Structs.Set} [description] - */ - difference: function (set) - { - var newSet = new Set(); - - this.entries.forEach(function (value) - { - if (!set.contains(value)) - { - newSet.set(value); - } - }); - - return newSet; - }, - - /** - * [description] - * - * @name Phaser.Structs.Set#size - * @type {integer} - * @since 3.0.0 - */ - size: { - - get: function () - { - return this.entries.length; - }, - - set: function (value) - { - return this.entries.length = value; - } - - } - -}); - -module.exports = Set; - - -/***/ }), -/* 71 */ +/* 62 */ /***/ (function(module, exports) { /** @@ -11346,14 +11416,780 @@ module.exports = Set; */ /** - * [description] + * Tests if the start and end indexes are a safe range for the given array. + * + * @function Phaser.Utils.Array.SafeRange + * @since 3.4.0 + * + * @param {array} array - The array to check. + * @param {integer} startIndex - The start index. + * @param {integer} endIndex - The end index. + * @param {boolean} [throwError=true] - Throw an error if the range is out of bounds. + * + * @return {boolean} True if the range is safe, otherwise false. + */ +var SafeRange = function (array, startIndex, endIndex, throwError) +{ + var len = array.length; + + if (startIndex < 0 || + startIndex > len || + startIndex >= endIndex || + endIndex > len || + startIndex + endIndex > len) + { + if (throwError) + { + throw new Error('Range Error: Values outside acceptable range'); + } + + return false; + } + else + { + return true; + } +}; + +module.exports = SafeRange; + + +/***/ }), +/* 63 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Shallow Object Clone. Will not clone nested objects. + * + * @function Phaser.Utils.Objects.Clone + * @since 3.0.0 + * + * @param {object} obj - the object from which to clone + * + * @return {object} a new object with the same properties as the input obj + */ +var Clone = function (obj) +{ + var clone = {}; + + for (var key in obj) + { + if (Array.isArray(obj[key])) + { + clone[key] = obj[key].slice(0); + } + else + { + clone[key] = obj[key]; + } + } + + return clone; +}; + +module.exports = Clone; + + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// 2.1.1 (Mar 17, 2016) + +/* +ISC License + +Copyright (c) 2016, Mapbox + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. + */ + + + +module.exports = earcut; + +/* +vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. +holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). +dimensions is the number of coordinates per vertice in the input array (2 by default). +Each group of three vertice indices in the resulting array forms a triangle. + */ + +function earcut(data, holeIndices, dim) { + + dim = dim || 2; + + var hasHoles = holeIndices && holeIndices.length, + outerLen = hasHoles ? holeIndices[0] * dim : data.length, + outerNode = linkedList(data, 0, outerLen, dim, true), + triangles = []; + + if (!outerNode) return triangles; + + var minX, minY, maxX, maxY, x, y, size; + + if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); + + // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox + if (data.length > 80 * dim) { + minX = maxX = data[0]; + minY = maxY = data[1]; + + for (var i = dim; i < outerLen; i += dim) { + x = data[i]; + y = data[i + 1]; + if (x < minX) minX = x; + if (y < minY) minY = y; + if (x > maxX) maxX = x; + if (y > maxY) maxY = y; + } + + // minX, minY and size are later used to transform coords into integers for z-order calculation + size = Math.max(maxX - minX, maxY - minY); + } + + earcutLinked(outerNode, triangles, dim, minX, minY, size); + + return triangles; +} + +// create a circular doubly linked list from polygon points in the specified winding order +function linkedList(data, start, end, dim, clockwise) { + var i, last; + + if (clockwise === (signedArea(data, start, end, dim) > 0)) { + for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); + } else { + for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); + } + + if (last && equals(last, last.next)) { + removeNode(last); + last = last.next; + } + + return last; +} + +// eliminate colinear or duplicate points +function filterPoints(start, end) { + if (!start) return start; + if (!end) end = start; + + var p = start, + again; + do { + again = false; + + if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { + removeNode(p); + p = end = p.prev; + if (p === p.next) return null; + again = true; + + } else { + p = p.next; + } + } while (again || p !== end); + + return end; +} + +// main ear slicing loop which triangulates a polygon (given as a linked list) +function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { + if (!ear) return; + + // interlink polygon nodes in z-order + if (!pass && size) indexCurve(ear, minX, minY, size); + + var stop = ear, + prev, next; + + // iterate through ears, slicing them one by one + while (ear.prev !== ear.next) { + prev = ear.prev; + next = ear.next; + + if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { + // cut off the triangle + triangles.push(prev.i / dim); + triangles.push(ear.i / dim); + triangles.push(next.i / dim); + + removeNode(ear); + + // skipping the next vertice leads to less sliver triangles + ear = next.next; + stop = next.next; + + continue; + } + + ear = next; + + // if we looped through the whole remaining polygon and can't find any more ears + if (ear === stop) { + // try filtering points and slicing again + if (!pass) { + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); + + // if this didn't work, try curing all small self-intersections locally + } else if (pass === 1) { + ear = cureLocalIntersections(ear, triangles, dim); + earcutLinked(ear, triangles, dim, minX, minY, size, 2); + + // as a last resort, try splitting the remaining polygon into two + } else if (pass === 2) { + splitEarcut(ear, triangles, dim, minX, minY, size); + } + + break; + } + } +} + +// check whether a polygon node forms a valid ear with adjacent nodes +function isEar(ear) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // now make sure we don't have other points inside the potential ear + var p = ear.next.next; + + while (p !== ear.prev) { + if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.next; + } + + return true; +} + +function isEarHashed(ear, minX, minY, size) { + var a = ear.prev, + b = ear, + c = ear.next; + + if (area(a, b, c) >= 0) return false; // reflex, can't be an ear + + // triangle bbox; min & max are calculated like this for speed + var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), + minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), + maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), + maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); + + // z-order range for the current triangle bbox; + var minZ = zOrder(minTX, minTY, minX, minY, size), + maxZ = zOrder(maxTX, maxTY, minX, minY, size); + + // first look for points inside the triangle in increasing z-order + var p = ear.nextZ; + + while (p && p.z <= maxZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.nextZ; + } + + // then look for points in decreasing z-order + p = ear.prevZ; + + while (p && p.z >= minZ) { + if (p !== ear.prev && p !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && + area(p.prev, p, p.next) >= 0) return false; + p = p.prevZ; + } + + return true; +} + +// go through all polygon nodes and cure small local self-intersections +function cureLocalIntersections(start, triangles, dim) { + var p = start; + do { + var a = p.prev, + b = p.next.next; + + if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { + + triangles.push(a.i / dim); + triangles.push(p.i / dim); + triangles.push(b.i / dim); + + // remove two nodes involved + removeNode(p); + removeNode(p.next); + + p = start = b; + } + p = p.next; + } while (p !== start); + + return p; +} + +// try splitting polygon into two and triangulate them independently +function splitEarcut(start, triangles, dim, minX, minY, size) { + // look for a valid diagonal that divides the polygon into two + var a = start; + do { + var b = a.next.next; + while (b !== a.prev) { + if (a.i !== b.i && isValidDiagonal(a, b)) { + // split the polygon in two by the diagonal + var c = splitPolygon(a, b); + + // filter colinear points around the cuts + a = filterPoints(a, a.next); + c = filterPoints(c, c.next); + + // run earcut on each half + earcutLinked(a, triangles, dim, minX, minY, size); + earcutLinked(c, triangles, dim, minX, minY, size); + return; + } + b = b.next; + } + a = a.next; + } while (a !== start); +} + +// link every hole into the outer loop, producing a single-ring polygon without holes +function eliminateHoles(data, holeIndices, outerNode, dim) { + var queue = [], + i, len, start, end, list; + + for (i = 0, len = holeIndices.length; i < len; i++) { + start = holeIndices[i] * dim; + end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + list = linkedList(data, start, end, dim, false); + if (list === list.next) list.steiner = true; + queue.push(getLeftmost(list)); + } + + queue.sort(compareX); + + // process holes from left to right + for (i = 0; i < queue.length; i++) { + eliminateHole(queue[i], outerNode); + outerNode = filterPoints(outerNode, outerNode.next); + } + + return outerNode; +} + +function compareX(a, b) { + return a.x - b.x; +} + +// find a bridge between vertices that connects hole with an outer ring and and link it +function eliminateHole(hole, outerNode) { + outerNode = findHoleBridge(hole, outerNode); + if (outerNode) { + var b = splitPolygon(outerNode, hole); + filterPoints(b, b.next); + } +} + +// David Eberly's algorithm for finding a bridge between hole and outer polygon +function findHoleBridge(hole, outerNode) { + var p = outerNode, + hx = hole.x, + hy = hole.y, + qx = -Infinity, + m; + + // find a segment intersected by a ray from the hole's leftmost point to the left; + // segment's endpoint with lesser x will be potential connection point + do { + if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { + var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); + if (x <= hx && x > qx) { + qx = x; + if (x === hx) { + if (hy === p.y) return p; + if (hy === p.next.y) return p.next; + } + m = p.x < p.next.x ? p : p.next; + } + } + p = p.next; + } while (p !== outerNode); + + if (!m) return null; + + if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint + + // look for points inside the triangle of hole point, segment intersection and endpoint; + // if there are no points found, we have a valid connection; + // otherwise choose the point of the minimum angle with the ray as connection point + + var stop = m, + mx = m.x, + my = m.y, + tanMin = Infinity, + tan; + + p = m.next; + + while (p !== stop) { + if (hx >= p.x && p.x >= mx && hx !== p.x && + pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { + + tan = Math.abs(hy - p.y) / (hx - p.x); // tangential + + if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { + m = p; + tanMin = tan; + } + } + + p = p.next; + } + + return m; +} + +// interlink polygon nodes in z-order +function indexCurve(start, minX, minY, size) { + var p = start; + do { + if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); + p.prevZ = p.prev; + p.nextZ = p.next; + p = p.next; + } while (p !== start); + + p.prevZ.nextZ = null; + p.prevZ = null; + + sortLinked(p); +} + +// Simon Tatham's linked list merge sort algorithm +// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html +function sortLinked(list) { + var i, p, q, e, tail, numMerges, pSize, qSize, + inSize = 1; + + do { + p = list; + list = null; + tail = null; + numMerges = 0; + + while (p) { + numMerges++; + q = p; + pSize = 0; + for (i = 0; i < inSize; i++) { + pSize++; + q = q.nextZ; + if (!q) break; + } + qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + + if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { + e = p; + p = p.nextZ; + pSize--; + } else { + e = q; + q = q.nextZ; + qSize--; + } + + if (tail) tail.nextZ = e; + else list = e; + + e.prevZ = tail; + tail = e; + } + + p = q; + } + + tail.nextZ = null; + inSize *= 2; + + } while (numMerges > 1); + + return list; +} + +// z-order of a point given coords and size of the data bounding box +function zOrder(x, y, minX, minY, size) { + // coords are transformed into non-negative 15-bit integer range + x = 32767 * (x - minX) / size; + y = 32767 * (y - minY) / size; + + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; + + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; + + return x | (y << 1); +} + +// find the leftmost node of a polygon ring +function getLeftmost(start) { + var p = start, + leftmost = start; + do { + if (p.x < leftmost.x) leftmost = p; + p = p.next; + } while (p !== start); + + return leftmost; +} + +// check if a point lies within a convex triangle +function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { + return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && + (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && + (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; +} + +// check if a diagonal between two polygon nodes is valid (lies in polygon interior) +function isValidDiagonal(a, b) { + return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && + locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); +} + +// signed area of a triangle +function area(p, q, r) { + return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); +} + +// check if two points are equal +function equals(p1, p2) { + return p1.x === p2.x && p1.y === p2.y; +} + +// check if two segments intersect +function intersects(p1, q1, p2, q2) { + if ((equals(p1, q1) && equals(p2, q2)) || + (equals(p1, q2) && equals(p2, q1))) return true; + return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && + area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; +} + +// check if a polygon diagonal intersects any polygon segments +function intersectsPolygon(a, b) { + var p = a; + do { + if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && + intersects(p, p.next, a, b)) return true; + p = p.next; + } while (p !== a); + + return false; +} + +// check if a polygon diagonal is locally inside the polygon +function locallyInside(a, b) { + return area(a.prev, a, a.next) < 0 ? + area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : + area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; +} + +// check if the middle point of a polygon diagonal is inside the polygon +function middleInside(a, b) { + var p = a, + inside = false, + px = (a.x + b.x) / 2, + py = (a.y + b.y) / 2; + do { + if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && + (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) + inside = !inside; + p = p.next; + } while (p !== a); + + return inside; +} + +// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; +// if one belongs to the outer ring and another to a hole, it merges it into a single ring +function splitPolygon(a, b) { + var a2 = new Node(a.i, a.x, a.y), + b2 = new Node(b.i, b.x, b.y), + an = a.next, + bp = b.prev; + + a.next = b; + b.prev = a; + + a2.next = an; + an.prev = a2; + + b2.next = a2; + a2.prev = b2; + + bp.next = b2; + b2.prev = bp; + + return b2; +} + +// create a node and optionally link it with previous one (in a circular doubly linked list) +function insertNode(i, x, y, last) { + var p = new Node(i, x, y); + + if (!last) { + p.prev = p; + p.next = p; + + } else { + p.next = last.next; + p.prev = last; + last.next.prev = p; + last.next = p; + } + return p; +} + +function removeNode(p) { + p.next.prev = p.prev; + p.prev.next = p.next; + + if (p.prevZ) p.prevZ.nextZ = p.nextZ; + if (p.nextZ) p.nextZ.prevZ = p.prevZ; +} + +function Node(i, x, y) { + // vertice index in coordinates array + this.i = i; + + // vertex coordinates + this.x = x; + this.y = y; + + // previous and next vertice nodes in a polygon ring + this.prev = null; + this.next = null; + + // z-order curve value + this.z = null; + + // previous and next nodes in z-order + this.prevZ = null; + this.nextZ = null; + + // indicates whether this is a steiner point + this.steiner = false; +} + +// return a percentage difference between the polygon area and its triangulation area; +// used to verify correctness of triangulation +earcut.deviation = function (data, holeIndices, dim, triangles) { + var hasHoles = holeIndices && holeIndices.length; + var outerLen = hasHoles ? holeIndices[0] * dim : data.length; + + var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); + if (hasHoles) { + for (var i = 0, len = holeIndices.length; i < len; i++) { + var start = holeIndices[i] * dim; + var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; + polygonArea -= Math.abs(signedArea(data, start, end, dim)); + } + } + + var trianglesArea = 0; + for (i = 0; i < triangles.length; i += 3) { + var a = triangles[i] * dim; + var b = triangles[i + 1] * dim; + var c = triangles[i + 2] * dim; + trianglesArea += Math.abs( + (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - + (data[a] - data[b]) * (data[c + 1] - data[a + 1])); + } + + return polygonArea === 0 && trianglesArea === 0 ? 0 : + Math.abs((trianglesArea - polygonArea) / polygonArea); +}; + +function signedArea(data, start, end, dim) { + var sum = 0; + for (var i = start, j = end - dim; i < end; i += dim) { + sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); + j = i; + } + return sum; +} + +// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts +earcut.flatten = function (data) { + var dim = data[0][0].length, + result = {vertices: [], holes: [], dimensions: dim}, + holeIndex = 0; + + for (var i = 0; i < data.length; i++) { + for (var j = 0; j < data[i].length; j++) { + for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); + } + if (i > 0) { + holeIndex += data[i - 1].length; + result.holes.push(holeIndex); + } + } + return result; +}; + +/***/ }), +/* 65 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the length of the given line. * * @function Phaser.Geom.Line.Length * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The line to calculate the length of. * - * @return {number} [description] + * @return {number} The length of the line. */ var Length = function (line) { @@ -11364,138 +12200,7 @@ module.exports = Length; /***/ }), -/* 72 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Defaults = __webpack_require__(100); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(62); -var GetEaseFunction = __webpack_require__(63); -var GetNewValue = __webpack_require__(73); -var GetProps = __webpack_require__(163); -var GetTargets = __webpack_require__(102); -var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(101); -var Tween = __webpack_require__(99); -var TweenData = __webpack_require__(98); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.TweenBuilder - * @since 3.0.0 - * - * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] - * @param {object} config - [description] - * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] - * - * @return {Phaser.Tweens.Tween} [description] - */ -var TweenBuilder = function (parent, config, defaults) -{ - if (defaults === undefined) - { - defaults = Defaults; - } - - // Create arrays of the Targets and the Properties - var targets = (defaults.targets) ? defaults.targets : GetTargets(config); - - // var props = (defaults.props) ? defaults.props : GetProps(config); - var props = GetProps(config); - - // Default Tween values - var delay = GetNewValue(config, 'delay', defaults.delay); - var duration = GetNewValue(config, 'duration', defaults.duration); - var easeParams = GetValue(config, 'easeParams', defaults.easeParams); - var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); - var hold = GetNewValue(config, 'hold', defaults.hold); - var repeat = GetNewValue(config, 'repeat', defaults.repeat); - var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); - var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); - var flipX = GetBoolean(config, 'flipX', defaults.flipX); - var flipY = GetBoolean(config, 'flipY', defaults.flipY); - - var data = []; - - // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } - for (var p = 0; p < props.length; p++) - { - var key = props[p].key; - var value = props[p].value; - - // Create 1 TweenData per target, per property - for (var t = 0; t < targets.length; t++) - { - var ops = GetValueOp(key, value); - - var tweenData = TweenData( - targets[t], - key, - ops.getEnd, - ops.getStart, - GetEaseFunction(GetValue(value, 'ease', ease), easeParams), - GetNewValue(value, 'delay', delay), - GetNewValue(value, 'duration', duration), - GetBoolean(value, 'yoyo', yoyo), - GetNewValue(value, 'hold', hold), - GetNewValue(value, 'repeat', repeat), - GetNewValue(value, 'repeatDelay', repeatDelay), - GetBoolean(value, 'flipX', flipX), - GetBoolean(value, 'flipY', flipY) - ); - - data.push(tweenData); - } - } - - var tween = new Tween(parent, data, targets); - - tween.offset = GetAdvancedValue(config, 'offset', null); - tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); - tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); - tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); - tween.paused = GetBoolean(config, 'paused', false); - tween.useFrames = GetBoolean(config, 'useFrames', false); - - // Set the Callbacks - var scope = GetValue(config, 'callbackScope', tween); - - // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params - var tweenArray = [ tween, null ]; - - var callbacks = Tween.TYPES; - - for (var i = 0; i < callbacks.length; i++) - { - var type = callbacks[i]; - - var callback = GetValue(config, type, false); - - if (callback) - { - var callbackScope = GetValue(config, type + 'Scope', scope); - var callbackParams = GetValue(config, type + 'Params', []); - - // The null is reset to be the Tween target - tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); - } - } - - return tween; -}; - -module.exports = TweenBuilder; - - -/***/ }), -/* 73 */ +/* 66 */ /***/ (function(module, exports) { /** @@ -11505,60 +12210,148 @@ module.exports = TweenBuilder; */ /** - * [description] - * - * @function Phaser.Tweens.Builders.GetNewValue + * Phaser Blend Modes. + * + * @name Phaser.BlendModes + * @enum {integer} + * @memberof Phaser + * @readonly * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] - * - * @return {function} [description] */ -var GetNewValue = function (source, key, defaultValue) -{ - var valueCallback; - if (source.hasOwnProperty(key)) - { - var t = typeof(source[key]); +module.exports = { - if (t === 'function') - { - valueCallback = function (index, totalTargets, target) - { - return source[key](index, totalTargets, target); - }; - } - else - { - valueCallback = function () - { - return source[key]; - }; - } - } - else if (typeof defaultValue === 'function') - { - valueCallback = defaultValue; - } - else - { - valueCallback = function () - { - return defaultValue; - }; - } + /** + * Skips the Blend Mode check in the renderer. + * + * @name Phaser.BlendModes.SKIP_CHECK + */ + SKIP_CHECK: -1, + + /** + * Normal blend mode. + * + * @name Phaser.BlendModes.NORMAL + */ + NORMAL: 0, + + /** + * Add blend mode. + * + * @name Phaser.BlendModes.ADD + */ + ADD: 1, + + /** + * Multiply blend mode. + * + * @name Phaser.BlendModes.MULTIPLY + */ + MULTIPLY: 2, + + /** + * Screen blend mode. + * + * @name Phaser.BlendModes.SCREEN + */ + SCREEN: 3, + + /** + * Overlay blend mode. + * + * @name Phaser.BlendModes.OVERLAY + */ + OVERLAY: 4, + + /** + * Darken blend mode. + * + * @name Phaser.BlendModes.DARKEN + */ + DARKEN: 5, + + /** + * Lighten blend mode. + * + * @name Phaser.BlendModes.LIGHTEN + */ + LIGHTEN: 6, + + /** + * Color Dodge blend mode. + * + * @name Phaser.BlendModes.COLOR_DODGE + */ + COLOR_DODGE: 7, + + /** + * Color Burn blend mode. + * + * @name Phaser.BlendModes.COLOR_BURN + */ + COLOR_BURN: 8, + + /** + * Hard Light blend mode. + * + * @name Phaser.BlendModes.HARD_LIGHT + */ + HARD_LIGHT: 9, + + /** + * Soft Light blend mode. + * + * @name Phaser.BlendModes.SOFT_LIGHT + */ + SOFT_LIGHT: 10, + + /** + * Difference blend mode. + * + * @name Phaser.BlendModes.DIFFERENCE + */ + DIFFERENCE: 11, + + /** + * Exclusion blend mode. + * + * @name Phaser.BlendModes.EXCLUSION + */ + EXCLUSION: 12, + + /** + * Hue blend mode. + * + * @name Phaser.BlendModes.HUE + */ + HUE: 13, + + /** + * Saturation blend mode. + * + * @name Phaser.BlendModes.SATURATION + */ + SATURATION: 14, + + /** + * Color blend mode. + * + * @name Phaser.BlendModes.COLOR + */ + COLOR: 15, + + /** + * Luminosity blend mode. + * + * @name Phaser.BlendModes.LUMINOSITY + */ + LUMINOSITY: 16 - return valueCallback; }; -module.exports = GetNewValue; - /***/ }), -/* 74 */ +/* 67 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -11575,12 +12368,12 @@ var Body = {}; module.exports = Body; -var Vertices = __webpack_require__(126); -var Vector = __webpack_require__(106); -var Sleeping = __webpack_require__(331); -var Common = __webpack_require__(41); -var Bounds = __webpack_require__(125); -var Axes = __webpack_require__(680); +var Vertices = __webpack_require__(76); +var Vector = __webpack_require__(81); +var Sleeping = __webpack_require__(222); +var Common = __webpack_require__(33); +var Bounds = __webpack_require__(80); +var Axes = __webpack_require__(505); (function() { @@ -11747,11 +12540,11 @@ var Axes = __webpack_require__(680); * Prefer to use the actual setter functions in performance critical situations. * @method set * @param {body} body - * @param {object} settings A map of properties and values to set on the body. + * @param {} settings A property name (or map of properties and values) to set on the body. + * @param {} value The value to set if `settings` is a single property name. */ - Body.set = function(body, settings) { - var property, - value; + Body.set = function(body, settings, value) { + var property; if (typeof settings === 'string') { property = settings; @@ -11980,7 +12773,7 @@ var Axes = __webpack_require__(680); } // sum the properties of all compound parts of the parent body - var total = _totalProperties(body); + var total = Body._totalProperties(body); body.area = total.area; body.parent = body; @@ -12106,35 +12899,50 @@ var Axes = __webpack_require__(680); * @param {vector} [point] */ Body.scale = function(body, scaleX, scaleY, point) { + var totalArea = 0, + totalInertia = 0; + point = point || body.position; for (var i = 0; i < body.parts.length; i++) { var part = body.parts[i]; - // scale position - part.position.x = point.x + (part.position.x - point.x) * scaleX; - part.position.y = point.y + (part.position.y - point.y) * scaleY; - // scale vertices Vertices.scale(part.vertices, scaleX, scaleY, point); // update properties part.axes = Axes.fromVertices(part.vertices); + part.area = Vertices.area(part.vertices); + Body.setMass(part, body.density * part.area); - if (!body.isStatic) { - part.area = Vertices.area(part.vertices); - Body.setMass(part, body.density * part.area); + // update inertia (requires vertices to be at origin) + Vertices.translate(part.vertices, { x: -part.position.x, y: -part.position.y }); + Body.setInertia(part, Body._inertiaScale * Vertices.inertia(part.vertices, part.mass)); + Vertices.translate(part.vertices, { x: part.position.x, y: part.position.y }); - // update inertia (requires vertices to be at origin) - Vertices.translate(part.vertices, { x: -part.position.x, y: -part.position.y }); - Body.setInertia(part, Vertices.inertia(part.vertices, part.mass)); - Vertices.translate(part.vertices, { x: part.position.x, y: part.position.y }); + if (i > 0) { + totalArea += part.area; + totalInertia += part.inertia; } + // scale position + part.position.x = point.x + (part.position.x - point.x) * scaleX; + part.position.y = point.y + (part.position.y - point.y) * scaleY; + // update bounds Bounds.update(part.bounds, part.vertices, body.velocity); } + // handle parent body + if (body.parts.length > 1) { + body.area = totalArea; + + if (!body.isStatic) { + Body.setMass(body, body.density * totalArea); + Body.setInertia(body, totalInertia); + } + } + // handle circles if (body.circleRadius) { if (scaleX === scaleY) { @@ -12144,13 +12952,6 @@ var Axes = __webpack_require__(680); body.circleRadius = null; } } - - if (!body.isStatic) { - var total = _totalProperties(body); - body.area = total.area; - Body.setMass(body, total.mass); - Body.setInertia(body, total.inertia); - } }; /** @@ -12231,7 +13032,7 @@ var Axes = __webpack_require__(680); * @param {body} body * @return {} */ - var _totalProperties = function(body) { + Body._totalProperties = function(body) { // from equations at: // https://ecourses.ou.edu/cgi-bin/ebook.cgi?doc=&topic=st&chap_sec=07.2&page=theory // http://output.to/sideway/default.asp?qno=121100087 @@ -12248,7 +13049,7 @@ var Axes = __webpack_require__(680); var part = body.parts[i], mass = part.mass !== Infinity ? part.mass : 1; - properties.mass += part.mass; + properties.mass += mass; properties.area += part.area; properties.inertia += part.inertia; properties.centre = Vector.add(properties.centre, Vector.mult(part.position, mass)); @@ -12766,7 +13567,7 @@ var Axes = __webpack_require__(680); /***/ }), -/* 75 */ +/* 68 */ /***/ (function(module, exports) { /** @@ -12776,2163 +13577,14 @@ var Axes = __webpack_require__(680); */ /** - * @typedef {object} XHRSettingsObject - * - * @property {XMLHttpRequestResponseType} responseType - The response type of the XHR request, i.e. `blob`, `text`, etc. - * @property {boolean} [async=true] - Should the XHR request use async or not? - * @property {string} [user=''] - Optional username for the XHR request. - * @property {string} [password=''] - Optional password for the XHR request. - * @property {integer} [timeout=0] - Optional XHR timeout value. - * @property {(string|undefined)} [header] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. - * @property {(string|undefined)} [headerValue] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. - * @property {(string|undefined)} [requestedWith] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. - * @property {(string|undefined)} [overrideMimeType] - Provide a custom mime-type to use instead of the default. - */ - -/** - * Creates an XHRSettings Object with default values. - * - * @function Phaser.Loader.XHRSettings - * @since 3.0.0 - * - * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. - * @param {boolean} [async=true] - Should the XHR request use async or not? - * @param {string} [user=''] - Optional username for the XHR request. - * @param {string} [password=''] - Optional password for the XHR request. - * @param {integer} [timeout=0] - Optional XHR timeout value. - * - * @return {XHRSettingsObject} The XHRSettings object as used by the Loader. - */ -var XHRSettings = function (responseType, async, user, password, timeout) -{ - if (responseType === undefined) { responseType = ''; } - if (async === undefined) { async = true; } - if (user === undefined) { user = ''; } - if (password === undefined) { password = ''; } - if (timeout === undefined) { timeout = 0; } - - // Before sending a request, set the xhr.responseType to "text", - // "arraybuffer", "blob", or "document", depending on your data needs. - // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". - - return { - - // Ignored by the Loader, only used by File. - responseType: responseType, - - async: async, - - // credentials - user: user, - password: password, - - // timeout in ms (0 = no timeout) - timeout: timeout, - - // setRequestHeader - header: undefined, - headerValue: undefined, - requestedWith: false, - - // overrideMimeType - overrideMimeType: undefined - - }; -}; - -module.exports = XHRSettings; - - -/***/ }), -/* 76 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -// Contains the plugins that Phaser uses globally and locally. -// These are the source objects, not instantiated. -var inputPlugins = {}; - -/** - * @typedef {object} InputPluginContainer - * - * @property {string} key - The unique name of this plugin in the input plugin cache. - * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. - * @property {string} [mapping] - If this plugin is to be injected into the Input Plugin, this is the property key map used. - */ - -var InputPluginCache = {}; - -/** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * - * @method Phaser.Input.InputPluginCache.register - * @since 3.10.0 - * - * @param {string} key - A reference used to get this plugin from the plugin cache. - * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. - * @param {string} mapping - If this plugin is to be injected into the Input Plugin, this is the property key used. - * @param {string} settingsKey - The key in the Scene Settings to check to see if this plugin should install or not. - * @param {string} configKey - The key in the Game Config to check to see if this plugin should install or not. - */ -InputPluginCache.register = function (key, plugin, mapping, settingsKey, configKey) -{ - inputPlugins[key] = { plugin: plugin, mapping: mapping, settingsKey: settingsKey, configKey: configKey }; -}; - -/** - * Returns the input plugin object from the cache based on the given key. - * - * @method Phaser.Input.InputPluginCache.getCore - * @since 3.10.0 - * - * @param {string} key - The key of the input plugin to get. - * - * @return {InputPluginContainer} The input plugin object. - */ -InputPluginCache.getPlugin = function (key) -{ - return inputPlugins[key]; -}; - -/** - * Installs all of the registered Input Plugins into the given target. - * - * @method Phaser.Input.InputPluginCache.install - * @since 3.10.0 - * - * @param {Phaser.Input.InputPlugin} target - The target InputPlugin to install the plugins into. - */ -InputPluginCache.install = function (target) -{ - var sys = target.scene.sys; - var settings = sys.settings.input; - var config = sys.game.config; - - for (var key in inputPlugins) - { - var source = inputPlugins[key].plugin; - var mapping = inputPlugins[key].mapping; - var settingsKey = inputPlugins[key].settingsKey; - var configKey = inputPlugins[key].configKey; - - if (GetValue(settings, settingsKey, config[configKey])) - { - target[mapping] = new source(target); - } - } -}; - -/** - * Removes an input plugin based on the given key. - * - * @method Phaser.Input.InputPluginCache.remove - * @since 3.10.0 - * - * @param {string} key - The key of the input plugin to remove. - */ -InputPluginCache.remove = function (key) -{ - if (inputPlugins.hasOwnProperty(key)) - { - delete inputPlugins[key]; - } -}; - -module.exports = InputPluginCache; - - -/***/ }), -/* 77 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. - -var CheckMatrix = __webpack_require__(116); -var TransposeMatrix = __webpack_require__(181); - -/** - * [description] - * - * @function Phaser.Utils.Array.Matrix.RotateMatrix - * @since 3.0.0 - * - * @param {array} matrix - The array to rotate. - * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. - * - * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. - */ -var RotateMatrix = function (matrix, direction) -{ - if (direction === undefined) { direction = 90; } - - if (!CheckMatrix(matrix)) - { - return null; - } - - if (typeof direction !== 'string') - { - direction = ((direction % 360) + 360) % 360; - } - - if (direction === 90 || direction === -270 || direction === 'rotateLeft') - { - matrix = TransposeMatrix(matrix); - matrix.reverse(); - } - else if (direction === -90 || direction === 270 || direction === 'rotateRight') - { - matrix.reverse(); - matrix = TransposeMatrix(matrix); - } - else if (Math.abs(direction) === 180 || direction === 'rotate180') - { - for (var i = 0; i < matrix.length; i++) - { - matrix[i].reverse(); - } - - matrix.reverse(); - } - - return matrix; -}; - -module.exports = RotateMatrix; - - -/***/ }), -/* 78 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Extend = __webpack_require__(17); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * Class containing all the shared state and behavior of a sound object, independent of the implementation. - * - * @class BaseSound - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - */ -var BaseSound = new Class({ - - Extends: EventEmitter, - - initialize: - - function BaseSound (manager, key, config) - { - EventEmitter.call(this); - - /** - * Local reference to the sound manager. - * - * @name Phaser.Sound.BaseSound#manager - * @type {Phaser.Sound.BaseSoundManager} - * @private - * @since 3.0.0 - */ - this.manager = manager; - - /** - * Asset key for the sound. - * - * @name Phaser.Sound.BaseSound#key - * @type {string} - * @readOnly - * @since 3.0.0 - */ - this.key = key; - - /** - * Flag indicating if sound is currently playing. - * - * @name Phaser.Sound.BaseSound#isPlaying - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isPlaying = false; - - /** - * Flag indicating if sound is currently paused. - * - * @name Phaser.Sound.BaseSound#isPaused - * @type {boolean} - * @default false - * @readOnly - * @since 3.0.0 - */ - this.isPaused = false; - - /** - * A property that holds the value of sound's actual playback rate, - * after its rate and detune values has been combined with global - * rate and detune values. - * - * @name Phaser.Sound.BaseSound#totalRate - * @type {number} - * @default 1 - * @readOnly - * @since 3.0.0 - */ - this.totalRate = 1; - - /** - * A value representing the duration, in seconds. - * It could be total sound duration or a marker duration. - * - * @name Phaser.Sound.BaseSound#duration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.duration = this.duration || 0; - - /** - * The total duration of the sound in seconds. - * - * @name Phaser.Sound.BaseSound#totalDuration - * @type {number} - * @readOnly - * @since 3.0.0 - */ - this.totalDuration = this.totalDuration || 0; - - /** - * A config object used to store default sound settings' values. - * Default values will be set by properties' setters. - * - * @name Phaser.Sound.BaseSound#config - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.config = { - - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - - }; - - /** - * Reference to the currently used config. - * It could be default config or marker config. - * - * @name Phaser.Sound.BaseSound#currentConfig - * @type {SoundConfig} - * @private - * @since 3.0.0 - */ - this.currentConfig = this.config; - - this.config = Extend(this.config, config); - - /** - * Object containing markers definitions. - * - * @name Phaser.Sound.BaseSound#markers - * @type {Object.} - * @default {} - * @readOnly - * @since 3.0.0 - */ - this.markers = {}; - - /** - * Currently playing marker. - * 'null' if whole sound is playing. - * - * @name Phaser.Sound.BaseSound#currentMarker - * @type {SoundMarker} - * @default null - * @readOnly - * @since 3.0.0 - */ - this.currentMarker = null; - - /** - * Flag indicating if destroy method was called on this sound. - * - * @name Phaser.Sound.BaseSound#pendingRemove - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this.pendingRemove = false; - }, - - /** - * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. - * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. - * - * @method Phaser.Sound.BaseSound#addMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object. - * - * @return {boolean} Whether the marker was added successfully. - */ - addMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - - if (this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.error('addMarker ' + marker.name + ' already exists in Sound'); - - return false; - } - - marker = Extend(true, { - name: '', - start: 0, - duration: this.totalDuration - (marker.start || 0), - config: { - mute: false, - volume: 1, - rate: 1, - detune: 0, - seek: 0, - loop: false, - delay: 0 - } - }, marker); - - this.markers[marker.name] = marker; - - return true; - }, - - /** - * Updates previously added marker. - * - * @method Phaser.Sound.BaseSound#updateMarker - * @since 3.0.0 - * - * @param {SoundMarker} marker - Marker object with updated values. - * - * @return {boolean} Whether the marker was updated successfully. - */ - updateMarker: function (marker) - { - if (!marker || !marker.name || typeof marker.name !== 'string') - { - return false; - } - - if (!this.markers[marker.name]) - { - // eslint-disable-next-line no-console - console.warn('Audio Marker: ' + marker.name + ' missing in Sound: ' + this.key); - - return false; - } - - this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); - - return true; - }, - - /** - * Removes a marker from the sound. - * - * @method Phaser.Sound.BaseSound#removeMarker - * @since 3.0.0 - * - * @param {string} markerName - The name of the marker to remove. - * - * @return {?SoundMarker} Removed marker object or 'null' if there was no marker with provided name. - */ - removeMarker: function (markerName) - { - var marker = this.markers[markerName]; - - if (!marker) - { - return null; - } - - this.markers[markerName] = null; - - return marker; - }, - - /** - * Play this sound, or a marked section of it. - * It always plays the sound from the start. If you want to start playback from a specific time - * you can set 'seek' setting of the config object, provided to this call, to that value. - * - * @method Phaser.Sound.BaseSound#play - * @since 3.0.0 - * - * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (markerName, config) - { - if (markerName === undefined) { markerName = ''; } - - if (typeof markerName === 'object') - { - config = markerName; - markerName = ''; - } - - if (typeof markerName !== 'string') - { - return false; - } - - if (!markerName) - { - this.currentMarker = null; - this.currentConfig = this.config; - this.duration = this.totalDuration; - } - else - { - if (!this.markers[markerName]) - { - // eslint-disable-next-line no-console - console.warn('Marker: ' + markerName + ' missing in Sound: ' + this.key); - - return false; - } - - this.currentMarker = this.markers[markerName]; - this.currentConfig = this.currentMarker.config; - this.duration = this.currentMarker.duration; - } - - this.resetConfig(); - - this.currentConfig = Extend(this.currentConfig, config); - - this.isPlaying = true; - this.isPaused = false; - - return true; - }, - - /** - * Pauses the sound. - * - * @method Phaser.Sound.BaseSound#pause - * @since 3.0.0 - * - * @return {boolean} Whether the sound was paused successfully. - */ - pause: function () - { - if (this.isPaused || !this.isPlaying) - { - return false; - } - - this.isPlaying = false; - this.isPaused = true; - - return true; - }, - - /** - * Resumes the sound. - * - * @method Phaser.Sound.BaseSound#resume - * @since 3.0.0 - * - * @return {boolean} Whether the sound was resumed successfully. - */ - resume: function () - { - if (!this.isPaused || this.isPlaying) - { - return false; - } - - this.isPlaying = true; - this.isPaused = false; - - return true; - }, - - /** - * Stop playing this sound. - * - * @method Phaser.Sound.BaseSound#stop - * @since 3.0.0 - * - * @return {boolean} Whether the sound was stopped successfully. - */ - stop: function () - { - if (!this.isPaused && !this.isPlaying) - { - return false; - } - - this.isPlaying = false; - this.isPaused = false; - - this.resetConfig(); - - return true; - }, - - /** - * Method used internally for applying config values to some of the sound properties. - * - * @method Phaser.Sound.BaseSound#applyConfig - * @protected - * @since 3.0.0 - */ - applyConfig: function () - { - this.mute = this.currentConfig.mute; - this.volume = this.currentConfig.volume; - this.rate = this.currentConfig.rate; - this.detune = this.currentConfig.detune; - this.loop = this.currentConfig.loop; - }, - - /** - * Method used internally for resetting values of some of the config properties. - * - * @method Phaser.Sound.BaseSound#resetConfig - * @protected - * @since 3.0.0 - */ - resetConfig: function () - { - this.currentConfig.seek = 0; - this.currentConfig.delay = 0; - }, - - /** - * Update method called automatically by sound manager on every game step. - * - * @method Phaser.Sound.BaseSound#update - * @override - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: NOOP, - - /** - * Method used internally to calculate total playback rate of the sound. - * - * @method Phaser.Sound.BaseSound#calculateRate - * @protected - * @since 3.0.0 - */ - calculateRate: function () - { - var cent = 1.0005777895065548; // Math.pow(2, 1/1200); - var totalDetune = this.currentConfig.detune + this.manager.detune; - var detuneRate = Math.pow(cent, totalDetune); - - this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; - }, - - /** - * Destroys this sound and all associated events and marks it for removal from the sound manager. - * - * @method Phaser.Sound.BaseSound#destroy - * @since 3.0.0 - */ - destroy: function () - { - if (this.pendingRemove) - { - return; - } - - this.emit('destroy', this); - this.pendingRemove = true; - this.manager = null; - this.key = ''; - this.removeAllListeners(); - this.isPlaying = false; - this.isPaused = false; - this.config = null; - this.currentConfig = null; - this.markers = null; - this.currentMarker = null; - } - -}); - -module.exports = BaseSound; - - -/***/ }), -/* 79 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Pavle Goloskokovic (http://prunegames.com) - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Clone = __webpack_require__(33); -var EventEmitter = __webpack_require__(9); -var NOOP = __webpack_require__(3); - -/** - * @callback EachActiveSoundCallback - * - * @param {Phaser.Sound.BaseSoundManager} manager - The SoundManager - * @param {Phaser.Sound.BaseSound} sound - The current active Sound - * @param {number} index - The index of the current active Sound - * @param {Phaser.Sound.BaseSound[]} sounds - All sounds - */ - -/** - * Audio sprite sound type. - * - * @typedef {Phaser.Sound.BaseSound} Phaser.Sound.BaseSound.AudioSpriteSound - * - * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. - */ - -/** - * @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 - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Sound - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - Reference to the current game instance. - */ -var BaseSoundManager = new Class({ - - Extends: EventEmitter, - - initialize: - - function BaseSoundManager (game) - { - EventEmitter.call(this); - - /** - * Local reference to game. - * - * @name Phaser.Sound.BaseSoundManager#game - * @type {Phaser.Game} - * @readOnly - * @since 3.0.0 - */ - this.game = game; - - /** - * Local reference to the JSON Cache, as used by Audio Sprites. - * - * @name Phaser.Sound.BaseSoundManager#jsonCache - * @type {Phaser.Cache.BaseCache} - * @readOnly - * @since 3.7.0 - */ - this.jsonCache = game.cache.json; - - /** - * An array containing all added sounds. - * - * @name Phaser.Sound.BaseSoundManager#sounds - * @type {Phaser.Sound.BaseSound[]} - * @default [] - * @private - * @since 3.0.0 - */ - this.sounds = []; - - /** - * Global mute setting. - * - * @name Phaser.Sound.BaseSoundManager#mute - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.mute = false; - - /** - * Global volume setting. - * - * @name Phaser.Sound.BaseSoundManager#volume - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.volume = 1; - - /** - * Flag indicating if sounds should be paused when game looses focus, - * for instance when user switches to another tab/program/app. - * - * @name Phaser.Sound.BaseSoundManager#pauseOnBlur - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.pauseOnBlur = true; - - /** - * Property that actually holds the value of global playback rate. - * - * @name Phaser.Sound.BaseSoundManager#_rate - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._rate = 1; - - /** - * Property that actually holds the value of global detune. - * - * @name Phaser.Sound.BaseSoundManager#_detune - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._detune = 0; - - /** - * Mobile devices require sounds to be triggered from an explicit user action, - * such as a tap, before any sound can be loaded/played on a web page. - * Set to true if the audio system is currently locked awaiting user interaction. - * - * @name Phaser.Sound.BaseSoundManager#locked - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.locked = this.locked || false; - - /** - * Flag used internally for handling when the audio system - * has been unlocked, if there ever was a need for it. - * - * @name Phaser.Sound.BaseSoundManager#unlocked - * @type {boolean} - * @default false - * @private - * @since 3.0.0 - */ - this.unlocked = false; - - game.events.on('blur', function () - { - if (this.pauseOnBlur) - { - this.onBlur(); - } - }, this); - - game.events.on('focus', function () - { - if (this.pauseOnBlur) - { - this.onFocus(); - } - }, this); - - game.events.on('prestep', this.update, this); - game.events.once('destroy', this.destroy, this); - }, - - /** - * Adds a new sound into the sound manager. - * - * @method Phaser.Sound.BaseSoundManager#add - * @override - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.BaseSound} The new sound instance. - */ - add: NOOP, - - /** - * Adds a new audio sprite sound into the sound manager. - * Audio Sprites are a combination of audio files and a JSON configuration. - * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite - * - * @method Phaser.Sound.BaseSoundManager#addAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {Phaser.Sound.BaseSound.AudioSpriteSound} The new audio sprite sound instance. - */ - addAudioSprite: function (key, config) - { - if (config === undefined) { config = {}; } - - var sound = this.add(key, config); - - sound.spritemap = this.jsonCache.get(key).spritemap; - - for (var markerName in sound.spritemap) - { - if (!sound.spritemap.hasOwnProperty(markerName)) - { - continue; - } - - var markerConfig = Clone(config); - - var marker = sound.spritemap[markerName]; - - markerConfig.loop = (marker.hasOwnProperty('loop')) ? marker.loop : false; - - sound.addMarker({ - name: markerName, - start: marker.start, - duration: marker.end - marker.start, - config: markerConfig - }); - } - - return sound; - }, - - /** - * Enables playing sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#play - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {(SoundConfig|SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. - * - * @return {boolean} Whether the sound started playing successfully. - */ - play: function (key, extra) - { - var sound = this.add(key); - - sound.once('ended', sound.destroy, sound); - - if (extra) - { - if (extra.name) - { - sound.addMarker(extra); - - return sound.play(extra.name); - } - else - { - return sound.play(extra); - } - } - else - { - return sound.play(); - } - }, - - /** - * Enables playing audio sprite sound on the fly without the need to keep a reference to it. - * Sound will auto destroy once its playback ends. - * - * @method Phaser.Sound.BaseSoundManager#playAudioSprite - * @since 3.0.0 - * - * @param {string} key - Asset key for the sound. - * @param {string} spriteName - The name of the sound sprite to play. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. - * - * @return {boolean} Whether the audio sprite sound started playing successfully. - */ - playAudioSprite: function (key, spriteName, config) - { - var sound = this.addAudioSprite(key); - - sound.once('ended', sound.destroy, sound); - - return sound.play(spriteName, config); - }, - - /** - * Removes a sound from the sound manager. - * The removed sound is destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#remove - * @since 3.0.0 - * - * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. - * - * @return {boolean} True if the sound was removed successfully, otherwise false. - */ - remove: function (sound) - { - var index = this.sounds.indexOf(sound); - - if (index !== -1) - { - sound.destroy(); - - this.sounds.splice(index, 1); - - return true; - } - - return false; - }, - - /** - * Removes all sounds from the sound manager that have an asset key matching the given value. - * The removed sounds are destroyed before removal. - * - * @method Phaser.Sound.BaseSoundManager#removeByKey - * @since 3.0.0 - * - * @param {string} key - The key to match when removing sound objects. - * - * @return {number} The number of matching sound objects that were removed. - */ - removeByKey: function (key) - { - var removed = 0; - - for (var i = this.sounds.length - 1; i >= 0; i--) - { - var sound = this.sounds[i]; - - if (sound.key === key) - { - sound.destroy(); - - this.sounds.splice(i, 1); - - removed++; - } - } - - return removed; - }, - - /** - * @event Phaser.Sound.BaseSoundManager#pauseall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - - /** - * Pauses all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#pauseAll - * @fires Phaser.Sound.BaseSoundManager#pauseall - * @since 3.0.0 - */ - pauseAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.pause(); - }); - - this.emit('pauseall', this); - }, - - /** - * @event Phaser.Sound.BaseSoundManager#resumeall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - - /** - * Resumes all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#resumeAll - * @fires Phaser.Sound.BaseSoundManager#resumeall - * @since 3.0.0 - */ - resumeAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.resume(); - }); - - this.emit('resumeall', this); - }, - - /** - * @event Phaser.Sound.BaseSoundManager#stopall - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - - /** - * Stops all the sounds in the game. - * - * @method Phaser.Sound.BaseSoundManager#stopAll - * @fires Phaser.Sound.BaseSoundManager#stopall - * @since 3.0.0 - */ - stopAll: function () - { - this.forEachActiveSound(function (sound) - { - sound.stop(); - }); - - this.emit('stopall', this); - }, - - /** - * Method used internally for unlocking audio playback on devices that - * require user interaction before any sound can be played on a web page. - * - * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). - * - * @method Phaser.Sound.BaseSoundManager#unlock - * @override - * @protected - * @since 3.0.0 - */ - unlock: NOOP, - - /** - * Method used internally for pausing sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onBlur - * @override - * @protected - * @since 3.0.0 - */ - onBlur: NOOP, - - /** - * Method used internally for resuming sound manager if - * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. - * - * @method Phaser.Sound.BaseSoundManager#onFocus - * @override - * @protected - * @since 3.0.0 - */ - onFocus: NOOP, - - /** - * Update method called on every game step. - * Removes destroyed sounds and updates every active sound in the game. - * - * @method Phaser.Sound.BaseSoundManager#update - * @protected - * @since 3.0.0 - * - * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. - */ - update: function (time, delta) - { - if (this.unlocked) - { - this.unlocked = false; - this.locked = false; - - /** - * @event Phaser.Sound.BaseSoundManager#unlocked - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - */ - this.emit('unlocked', this); - } - - for (var i = this.sounds.length - 1; i >= 0; i--) - { - if (this.sounds[i].pendingRemove) - { - this.sounds.splice(i, 1); - } - } - - this.sounds.forEach(function (sound) - { - sound.update(time, delta); - }); - }, - - /** - * Destroys all the sounds in the game and all associated events. - * - * @method Phaser.Sound.BaseSoundManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllListeners(); - - this.forEachActiveSound(function (sound) - { - sound.destroy(); - }); - - this.sounds.length = 0; - this.sounds = null; - - this.game = null; - }, - - /** - * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. - * - * @method Phaser.Sound.BaseSoundManager#forEachActiveSound - * @private - * @since 3.0.0 - * - * @param {EachActiveSoundCallback} callback - Callback function. (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Manager.BaseSound[]) => void - * @param {*} [scope] - Callback context. - */ - forEachActiveSound: function (callback, scope) - { - var _this = this; - - this.sounds.forEach(function (sound, index) - { - if (!sound.pendingRemove) - { - callback.call(scope || _this, sound, index, _this.sounds); - } - }); - }, - - /** - * @event Phaser.Sound.BaseSoundManager#rate - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. - */ - - /** - * 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. - * - * @method Phaser.Sound.BaseSoundManager#setRate - * @fires Phaser.Sound.BaseSoundManager#rate - * @since 3.3.0 - * - * @param {number} value - Global playback rate at which all the sounds will be played. - * - * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. - */ - setRate: function (value) - { - this.rate = value; - - return this; - }, - - /** - * Global playback rate at which all the sounds will be played. - * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed - * and 2.0 doubles the audio's playback speed. - * - * @name Phaser.Sound.BaseSoundManager#rate - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rate: { - - get: function () - { - return this._rate; - }, - - set: function (value) - { - this._rate = value; - - this.forEachActiveSound(function (sound) - { - sound.calculateRate(); - }); - - this.emit('rate', this, value); - } - - }, - - /** - * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @method Phaser.Sound.BaseSoundManager#setDetune - * @fires Phaser.Sound.BaseSoundManager#detune - * @since 3.3.0 - * - * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. - */ - setDetune: function (value) - { - this.detune = value; - - return this; - }, - - /** - * @event Phaser.Sound.BaseSoundManager#detune - * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. - * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. - */ - - /** - * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). - * - * @name Phaser.Sound.BaseSoundManager#detune - * @type {number} - * @default 0 - * @since 3.0.0 - */ - detune: { - - get: function () - { - return this._detune; - }, - - set: function (value) - { - this._detune = value; - - this.forEachActiveSound(function (sound) - { - sound.calculateRate(); - }); - - this.emit('detune', this, value); - } - - } - -}); - -module.exports = BaseSoundManager; - - -/***/ }), -/* 80 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(57); - -/** - * Determines the browser type and version running this Phaser Game instance. - * These values are read-only and populated during the boot sequence of the game. - * They are then referenced by internal game systems and are available for you to access - * via `this.sys.game.device.browser` from within any Scene. - * - * @typedef {object} Phaser.Device.Browser - * @since 3.0.0 - * - * @property {boolean} chrome - Set to true if running in Chrome. - * @property {boolean} edge - Set to true if running in Microsoft Edge browser. - * @property {boolean} firefox - Set to true if running in Firefox. - * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). - * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. - * @property {boolean} opera - Set to true if running in Opera. - * @property {boolean} safari - Set to true if running in Safari. - * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) - * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) - * @property {number} chromeVersion - If running in Chrome this will contain the major version number. - * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. - * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. - * @property {number} safariVersion - If running in Safari this will contain the major version number. - * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} - */ -var Browser = { - - chrome: false, - chromeVersion: 0, - edge: false, - firefox: false, - firefoxVersion: 0, - ie: false, - ieVersion: 0, - mobileSafari: false, - opera: false, - safari: false, - safariVersion: 0, - silk: false, - trident: false, - tridentVersion: 0 - -}; - -function init () -{ - var ua = navigator.userAgent; - - if (/Edge\/\d+/.test(ua)) - { - Browser.edge = true; - } - else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) - { - Browser.chrome = true; - Browser.chromeVersion = parseInt(RegExp.$1, 10); - } - else if ((/Firefox\D+(\d+)/).test(ua)) - { - Browser.firefox = true; - Browser.firefoxVersion = parseInt(RegExp.$1, 10); - } - else if ((/AppleWebKit/).test(ua) && OS.iOS) - { - Browser.mobileSafari = true; - } - else if ((/MSIE (\d+\.\d+);/).test(ua)) - { - Browser.ie = true; - Browser.ieVersion = parseInt(RegExp.$1, 10); - } - else if ((/Opera/).test(ua)) - { - Browser.opera = true; - } - else if ((/Safari/).test(ua) && !OS.windowsPhone) - { - Browser.safari = true; - } - else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) - { - Browser.ie = true; - Browser.trident = true; - Browser.tridentVersion = parseInt(RegExp.$1, 10); - Browser.ieVersion = parseInt(RegExp.$3, 10); - } - - // Silk gets its own if clause because its ua also contains 'Safari' - if ((/Silk/).test(ua)) - { - Browser.silk = true; - } - - return Browser; -} - -module.exports = init(); - - -/***/ }), -/* 81 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback DataEachCallback - * - * @param {*} parent - The parent object of the DataManager. - * @param {string} key - The key of the value. - * @param {*} value - The value. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. - */ - -/** - * @classdesc - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. - * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, - * or have a property called `events` that is an instance of it. - * - * @class DataManager - * @memberOf Phaser.Data - * @constructor - * @since 3.0.0 - * - * @param {object} parent - The object that this DataManager belongs to. - * @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter. - */ -var DataManager = new Class({ - - initialize: - - function DataManager (parent, eventEmitter) - { - /** - * The object that this DataManager belongs to. - * - * @name Phaser.Data.DataManager#parent - * @type {*} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * The DataManager's event emitter. - * - * @name Phaser.Data.DataManager#events - * @type {Phaser.Events.EventEmitter} - * @since 3.0.0 - */ - this.events = eventEmitter; - - if (!eventEmitter) - { - this.events = (parent.events) ? parent.events : parent; - } - - /** - * The data list. - * - * @name Phaser.Data.DataManager#list - * @type {Object.} - * @default {} - * @since 3.0.0 - */ - this.list = {}; - - /** - * The public values list. You can use this to access anything you have stored - * in this Data Manager. For example, if you set a value called `gold` you can - * access it via: - * - * ```javascript - * this.data.values.gold; - * ``` - * - * You can also modify it directly: - * - * ```javascript - * this.data.values.gold += 1000; - * ``` - * - * Doing so will emit a `setdata` event from the parent of this Data Manager. - * - * @name Phaser.Data.DataManager#values - * @type {Object.} - * @default {} - * @since 3.10.0 - */ - this.values = {}; - - /** - * Whether setting data is frozen for this DataManager. - * - * @name Phaser.Data.DataManager#_frozen - * @type {boolean} - * @private - * @default false - * @since 3.0.0 - */ - this._frozen = false; - - if (!parent.hasOwnProperty('sys') && this.events) - { - this.events.once('destroy', this.destroy, this); - } - }, - - /** - * Retrieves the value for the given key, or undefined if it doesn't exist. - * - * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * - * ```javascript - * this.data.get('gold'); - * ``` - * - * Or access the value directly: - * - * ```javascript - * this.data.values.gold; - * ``` - * - * You can also pass in an array of keys, in which case an array of values will be returned: - * - * ```javascript - * this.data.get([ 'gold', 'armor', 'health' ]); - * ``` - * - * This approach is useful for destructuring arrays in ES6. - * - * @method Phaser.Data.DataManager#get - * @since 3.0.0 - * - * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. - * - * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. - */ - get: function (key) - { - var list = this.list; - - if (Array.isArray(key)) - { - var output = []; - - for (var i = 0; i < key.length; i++) - { - output.push(list[key[i]]); - } - - return output; - } - else - { - return list[key]; - } - }, - - /** - * Retrieves all data values in a new object. - * - * @method Phaser.Data.DataManager#getAll - * @since 3.0.0 - * - * @return {Object.} All data values. - */ - getAll: function () - { - var results = {}; - - for (var key in this.list) - { - if (this.list.hasOwnProperty(key)) - { - results[key] = this.list[key]; - } - } - - return results; - }, - - /** - * Queries the DataManager for the values of keys matching the given regular expression. - * - * @method Phaser.Data.DataManager#query - * @since 3.0.0 - * - * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). - * - * @return {Object.} The values of the keys matching the search string. - */ - query: function (search) - { - var results = {}; - - for (var key in this.list) - { - if (this.list.hasOwnProperty(key) && key.match(search)) - { - results[key] = this.list[key]; - } - } - - return results; - }, - - /** - * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. - * - * ```javascript - * data.set('name', 'Red Gem Stone'); - * ``` - * - * You can also pass in an object of key value pairs as the first argument: - * - * ```javascript - * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); - * ``` - * - * To get a value back again you can call `get`: - * - * ```javascript - * data.get('gold'); - * ``` - * - * Or you can access the value directly via the `values` property, where it works like any other variable: - * - * ```javascript - * data.values.gold += 50; - * ``` - * - * When the value is first set, a `setdata` event is emitted. - * - * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. - * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. - * - * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * - * @method Phaser.Data.DataManager#set - * @since 3.0.0 - * - * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. - * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - set: function (key, data) - { - if (this._frozen) - { - return this; - } - - if (typeof key === 'string') - { - return this.setValue(key, data); - } - else - { - for (var entry in key) - { - this.setValue(entry, key[entry]); - } - } - - return this; - }, - - /** - * Internal value setter, called automatically by the `set` method. - * - * @method Phaser.Data.DataManager#setValue - * @private - * @since 3.10.0 - * - * @param {string} key - The key to set the value for. - * @param {*} data - The value to set. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - setValue: function (key, data) - { - if (this._frozen) - { - return this; - } - - if (this.has(key)) - { - // Hit the key getter, which will in turn emit the events. - this.values[key] = data; - } - else - { - var _this = this; - var list = this.list; - var events = this.events; - var parent = this.parent; - - Object.defineProperty(this.values, key, { - - enumerable: true, - - get: function () - { - return list[key]; - }, - - set: function (value) - { - if (!_this._frozen) - { - list[key] = value; - - events.emit('changedata', parent, key, data); - events.emit('changedata_' + key, parent, data); - } - } - - }); - - list[key] = data; - - events.emit('setdata', parent, key, data); - } - - return this; - }, - - /** - * Passes all data entries to the given callback. - * - * @method Phaser.Data.DataManager#each - * @since 3.0.0 - * - * @param {DataEachCallback} callback - The function to call. - * @param {*} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - each: function (callback, context) - { - var args = [ this.parent, null, undefined ]; - - for (var i = 1; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (var key in this.list) - { - args[1] = key; - args[2] = this.list[key]; - - callback.apply(context, args); - } - - return this; - }, - - /** - * Merge the given object of key value pairs into this DataManager. - * - * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) - * will emit a `changedata` event. - * - * @method Phaser.Data.DataManager#merge - * @since 3.0.0 - * - * @param {Object.} data - The data to merge. - * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - merge: function (data, overwrite) - { - if (overwrite === undefined) { overwrite = true; } - - // Merge data from another component into this one - for (var key in data) - { - if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) - { - this.setValue(key, data[key]); - } - } - - return this; - }, - - /** - * Remove the value for the given key. - * - * If the key is found in this Data Manager it is removed from the internal lists and a - * `removedata` event is emitted. - * - * You can also pass in an array of keys, in which case all keys in the array will be removed: - * - * ```javascript - * this.data.remove([ 'gold', 'armor', 'health' ]); - * ``` - * - * @method Phaser.Data.DataManager#remove - * @since 3.0.0 - * - * @param {(string|string[])} key - The key to remove, or an array of keys to remove. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - remove: function (key) - { - if (this._frozen) - { - return this; - } - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - this.removeValue(key[i]); - } - } - else - { - return this.removeValue(key); - } - - return this; - }, - - /** - * Internal value remover, called automatically by the `remove` method. - * - * @method Phaser.Data.DataManager#removeValue - * @private - * @since 3.10.0 - * - * @param {string} key - The key to set the value for. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - removeValue: function (key) - { - if (this.has(key)) - { - var data = this.list[key]; - - delete this.list[key]; - delete this.values[key]; - - this.events.emit('removedata', this, key, data); - } - - return this; - }, - - /** - * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. - * - * @method Phaser.Data.DataManager#pop - * @since 3.0.0 - * - * @param {string} key - The key of the value to retrieve and delete. - * - * @return {*} The value of the given key. - */ - pop: function (key) - { - var data = undefined; - - if (!this._frozen && this.has(key)) - { - data = this.list[key]; - - delete this.list[key]; - delete this.values[key]; - - this.events.emit('removedata', this, key, data); - } - - return data; - }, - - /** - * Determines whether the given key is set in this Data Manager. - * - * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. - * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. - * - * @method Phaser.Data.DataManager#has - * @since 3.0.0 - * - * @param {string} key - The key to check. - * - * @return {boolean} Returns `true` if the key exists, otherwise `false`. - */ - has: function (key) - { - return this.list.hasOwnProperty(key); - }, - - /** - * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts - * to create new values or update existing ones. - * - * @method Phaser.Data.DataManager#setFreeze - * @since 3.0.0 - * - * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - setFreeze: function (value) - { - this._frozen = value; - - return this; - }, - - /** - * Delete all data in this Data Manager and unfreeze it. - * - * @method Phaser.Data.DataManager#reset - * @since 3.0.0 - * - * @return {Phaser.Data.DataManager} This DataManager object. - */ - reset: function () - { - for (var key in this.list) - { - delete this.list[key]; - delete this.values[key]; - } - - this._frozen = false; - - return this; - }, - - /** - * Destroy this data manager. - * - * @method Phaser.Data.DataManager#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.reset(); - - this.events.off('changedata'); - this.events.off('setdata'); - this.events.off('removedata'); - - this.parent = null; - }, - - /** - * Gets or sets the frozen state of this Data Manager. - * A frozen Data Manager will block all attempts to create new values or update existing ones. - * - * @name Phaser.Data.DataManager#freeze - * @type {boolean} - * @since 3.0.0 - */ - freeze: { - - get: function () - { - return this._frozen; - }, - - set: function (value) - { - this._frozen = (value) ? true : false; - } - - }, - - /** - * Return the total number of entries in this Data Manager. - * - * @name Phaser.Data.DataManager#count - * @type {integer} - * @since 3.0.0 - */ - count: { - - get: function () - { - var i = 0; - - for (var key in this.list) - { - if (this.list[key] !== undefined) - { - i++; - } - } - - return i; - } - - } - -}); - -module.exports = DataManager; - - -/***/ }), -/* 82 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] + * Calculate the angle of the line in radians. * * @function Phaser.Geom.Line.Angle * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The line to calculate the angle of. * - * @return {number} [description] + * @return {number} The angle of the line, in radians. */ var Angle = function (line) { @@ -14943,798 +13595,7 @@ module.exports = Angle; /***/ }), -/* 83 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -//! stable.js 0.1.6, https://github.com/Two-Screen/stable -//! © 2017 Angry Bytes and contributors. MIT licensed. - -(function() { - -// A stable array sort, because `Array#sort()` is not guaranteed stable. -// This is an implementation of merge sort, without recursion. - -var stable = function(arr, comp) { - return exec(arr.slice(), comp); -}; - -stable.inplace = function(arr, comp) { - var result = exec(arr, comp); - - // This simply copies back if the result isn't in the original array, - // which happens on an odd number of passes. - if (result !== arr) { - pass(result, null, arr.length, arr); - } - - return arr; -}; - -// Execute the sort using the input array and a second buffer as work space. -// Returns one of those two, containing the final result. -function exec(arr, comp) { - if (typeof(comp) !== 'function') { - comp = function(a, b) { - return String(a).localeCompare(b); - }; - } - - // Short-circuit when there's nothing to sort. - var len = arr.length; - if (len <= 1) { - return arr; - } - - // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. - // Chunks are the size of the left or right hand in merge sort. - // Stop when the left-hand covers all of the array. - var buffer = new Array(len); - for (var chk = 1; chk < len; chk *= 2) { - pass(arr, comp, chk, buffer); - - var tmp = arr; - arr = buffer; - buffer = tmp; - } - - return arr; -} - -// Run a single pass with the given chunk size. -var pass = function(arr, comp, chk, result) { - var len = arr.length; - var i = 0; - // Step size / double chunk size. - var dbl = chk * 2; - // Bounds of the left and right chunks. - var l, r, e; - // Iterators over the left and right chunk. - var li, ri; - - // Iterate over pairs of chunks. - for (l = 0; l < len; l += dbl) { - r = l + chk; - e = r + chk; - if (r > len) r = len; - if (e > len) e = len; - - // Iterate both chunks in parallel. - li = l; - ri = r; - while (true) { - // Compare the chunks. - if (li < r && ri < e) { - // This works for a regular `sort()` compatible comparator, - // but also for a simple comparator like: `a > b` - if (comp(arr[li], arr[ri]) <= 0) { - result[i++] = arr[li++]; - } - else { - result[i++] = arr[ri++]; - } - } - // Nothing to compare, just flush what's left. - else if (li < r) { - result[i++] = arr[li++]; - } - else if (ri < e) { - result[i++] = arr[ri++]; - } - // Both iterators are at the chunk ends. - else { - break; - } - } - } -}; - -// Export using CommonJS or to the window. -if (true) { - module.exports = stable; -} -else {} - -})(); - -/***/ }), -/* 84 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Utils = __webpack_require__(27); - -/** - * @classdesc - * WebGLPipeline is a class that describes the way elements will be rendererd - * in WebGL, specially focused on batching vertices (batching is not provided). - * Pipelines are mostly used for describing 2D rendering passes but it's - * flexible enough to be used for any type of rendering including 3D. - * Internally WebGLPipeline will handle things like compiling shaders, - * creating vertex buffers, assigning primitive topology and binding - * vertex attributes. - * - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - gl: Current WebGL context. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - vertices: An optional buffer of vertices - * - attributes: An array describing the vertex attributes - * - * The vertex attributes properties are: - * - name : String - Name of the attribute in the vertex shader - * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 - * - type : GLenum - WebGL type (gl.BYTE, gl.SHORT, gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.FLOAT) - * - normalized : boolean - Is the attribute normalized - * - offset : integer - The offset in bytes to the current attribute in the vertex. Equivalent to offsetof(vertex, attrib) in C - * Here you can find more information of how to describe an attribute: - * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer - * - * @class WebGLPipeline - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var WebGLPipeline = new Class({ - - initialize: - - function WebGLPipeline (config) - { - /** - * Name of the Pipeline. Used for identifying - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#name - * @type {string} - * @since 3.0.0 - */ - this.name = 'WebGLPipeline'; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = config.game; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#view - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.view = config.game.canvas; - - /** - * Used to store the current game resolution - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#resolution - * @type {number} - * @since 3.0.0 - */ - this.resolution = config.game.config.resolution; - - /** - * Width of the current viewport - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#width - * @type {number} - * @since 3.0.0 - */ - this.width = config.game.config.width * this.resolution; - - /** - * Height of the current viewport - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#height - * @type {number} - * @since 3.0.0 - */ - this.height = config.game.config.height * this.resolution; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#gl - * @type {WebGLRenderingContext} - * @since 3.0.0 - */ - this.gl = config.gl; - - /** - * How many vertices have been fed to the current pipeline. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.vertexCount = 0; - - /** - * The limit of vertices that the pipeline can hold - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity - * @type {integer} - * @since 3.0.0 - */ - this.vertexCapacity = config.vertexCapacity; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#renderer - * @type {Phaser.Renderer.WebGL.WebGLRenderer} - * @since 3.0.0 - */ - this.renderer = config.renderer; - - /** - * Raw byte buffer of vertices. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexData - * @type {ArrayBuffer} - * @since 3.0.0 - */ - this.vertexData = (config.vertices ? config.vertices : new ArrayBuffer(config.vertexCapacity * config.vertexSize)); - - /** - * The handle to a WebGL vertex buffer object. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer - * @type {WebGLBuffer} - * @since 3.0.0 - */ - this.vertexBuffer = this.renderer.createVertexBuffer((config.vertices ? config.vertices : this.vertexData.byteLength), this.gl.STREAM_DRAW); - - /** - * The handle to a WebGL program - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#program - * @type {WebGLProgram} - * @since 3.0.0 - */ - this.program = this.renderer.createProgram(config.vertShader, config.fragShader); - - /** - * Array of objects that describe the vertex attributes - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#attributes - * @type {object} - * @since 3.0.0 - */ - this.attributes = config.attributes; - - /** - * The size in bytes of the vertex - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexSize - * @type {integer} - * @since 3.0.0 - */ - this.vertexSize = config.vertexSize; - - /** - * The primitive topology which the pipeline will use to submit draw calls - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#topology - * @type {integer} - * @since 3.0.0 - */ - this.topology = config.topology; - - /** - * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources - * to the GPU. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#bytes - * @type {Uint8Array} - * @since 3.0.0 - */ - this.bytes = new Uint8Array(this.vertexData); - - /** - * This will store the amount of components of 32 bit length - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexComponentCount - * @type {integer} - * @since 3.0.0 - */ - this.vertexComponentCount = Utils.getComponentCount(config.attributes, this.gl); - - /** - * Indicates if the current pipeline is flushing the contents to the GPU. - * When the variable is set the flush function will be locked. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#flushLocked - * @type {boolean} - * @since 3.1.0 - */ - this.flushLocked = false; - - /** - * Indicates if the current pipeline is active or not for this frame only. - * Reset in the onRender method. - * - * @name Phaser.Renderer.WebGL.WebGLPipeline#active - * @type {boolean} - * @since 3.10.0 - */ - this.active = false; - }, - - /** - * Adds a description of vertex attribute to the pipeline - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#addAttribute - * @since 3.2.0 - * - * @param {string} name - Name of the vertex attribute - * @param {integer} size - Vertex component size - * @param {integer} type - Type of the attribute - * @param {boolean} normalized - Is the value normalized to a range - * @param {integer} offset - Byte offset to the beginning of the first element in the vertex - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - addAttribute: function (name, size, type, normalized, offset) - { - this.attributes.push({ - name: name, - size: size, - type: this.renderer.glFormats[type], - normalized: normalized, - offset: offset - }); - - return this; - }, - - /** - * Check if the current batch of vertices is full. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush - * @since 3.0.0 - * - * @return {boolean} [description] - */ - shouldFlush: function () - { - return (this.vertexCount >= this.vertexCapacity); - }, - - /** - * Resizes the properties used to describe the viewport - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - resize: function (width, height, resolution) - { - this.width = width * resolution; - this.height = height * resolution; - return this; - }, - - /** - * Binds the pipeline resources, including programs, vertex buffers and binds attributes - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#bind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - bind: function () - { - var gl = this.gl; - var vertexBuffer = this.vertexBuffer; - var attributes = this.attributes; - var program = this.program; - var renderer = this.renderer; - var vertexSize = this.vertexSize; - - renderer.setProgram(program); - renderer.setVertexBuffer(vertexBuffer); - - for (var index = 0; index < attributes.length; ++index) - { - var element = attributes[index]; - var location = gl.getAttribLocation(program, element.name); - - if (location >= 0) - { - gl.enableVertexAttribArray(location); - gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexSize, element.offset); - } - else - { - gl.disableVertexAttribArray(location); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onBind: function () - { - // This is for updating uniform data it's called on each bind attempt. - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onPreRender - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onPreRender: function () - { - // called once every frame - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onRender - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onRender: function () - { - // called for each camera - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#onPostRender - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - onPostRender: function () - { - // called once every frame - return this; - }, - - /** - * Uploads the vertex data and emits a draw call - * for the current batch of vertices. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#flush - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - flush: function () - { - if (this.flushLocked) { return this; } - - this.flushLocked = true; - - var gl = this.gl; - var vertexCount = this.vertexCount; - var topology = this.topology; - var vertexSize = this.vertexSize; - - if (vertexCount === 0) - { - this.flushLocked = false; - return; - } - - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); - gl.drawArrays(topology, 0, vertexCount); - - this.vertexCount = 0; - this.flushLocked = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#destroy - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - destroy: function () - { - var gl = this.gl; - - gl.deleteProgram(this.program); - gl.deleteBuffer(this.vertexBuffer); - - delete this.program; - delete this.vertexBuffer; - delete this.gl; - - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {float} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat1: function (name, x) - { - this.renderer.setFloat1(this.program, name, x); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat2: function (name, x, y) - { - - this.renderer.setFloat2(this.program, name, x, y); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat3: function (name, x, y, z) - { - - this.renderer.setFloat3(this.program, name, x, y, z); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4 - * @since 3.2.0 - * - * @param {string} name - Name of the uniform - * @param {float} x - X component of the uniform - * @param {float} y - Y component of the uniform - * @param {float} z - Z component of the uniform - * @param {float} w - W component of the uniform - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setFloat4: function (name, x, y, z, w) - { - - this.renderer.setFloat4(this.program, name, x, y, z, w); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt1 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {integer} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt1: function (name, x) - { - this.renderer.setInt1(this.program, name, x); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt2 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt2: function (name, x, y) - { - this.renderer.setInt2(this.program, name, x, y); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt3 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt3: function (name, x, y, z) - { - this.renderer.setInt3(this.program, name, x, y, z); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt4 - * @since 3.2.0 - * - * @param {string} name - Name of the uniform - * @param {integer} x - X component of the uniform - * @param {integer} y - Y component of the uniform - * @param {integer} z - Z component of the uniform - * @param {integer} w - W component of the uniform - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setInt4: function (name, x, y, z, w) - { - this.renderer.setInt4(this.program, name, x, y, z, w); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setMatrix2: function (name, transpose, matrix) - { - this.renderer.setMatrix2(this.program, name, transpose, matrix); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * [description] - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3 - * @since 3.2.0 - * - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setMatrix3: function (name, transpose, matrix) - { - this.renderer.setMatrix3(this.program, name, transpose, matrix); - return this; - }, - - /** - * Set a uniform value of the current pipeline program. - * - * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4 - * @since 3.2.0 - * - * @param {string} name - Name of the uniform - * @param {boolean} transpose - Should the matrix be transpose - * @param {Float32Array} matrix - Matrix data - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setMatrix4: function (name, transpose, matrix) - { - this.renderer.setMatrix4(this.program, name, transpose, matrix); - return this; - } - -}); - -module.exports = WebGLPipeline; - - -/***/ }), -/* 85 */ +/* 69 */ /***/ (function(module, exports) { /** @@ -15743,28 +13604,51 @@ module.exports = WebGLPipeline; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// http://www.blackpawn.com/texts/pointinpoly/ + /** - * Checks if the given `width` and `height` are a power of two. - * Useful for checking texture dimensions. + * [description] * - * @function Phaser.Math.Pow2.IsSizePowerOfTwo + * @function Phaser.Geom.Triangle.Contains * @since 3.0.0 * - * @param {number} width - The width. - * @param {number} height - The height. + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] * - * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. + * @return {boolean} [description] */ -var IsSizePowerOfTwo = function (width, height) +var Contains = function (triangle, x, y) { - return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var v2x = x - triangle.x1; + var v2y = y - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot02 = (v0x * v2x) + (v0y * v2y); + var dot11 = (v1x * v1x) + (v1y * v1y); + var dot12 = (v1x * v2x) + (v1y * v2y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + var u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + var v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + return (u >= 0 && v >= 0 && (u + v < 1)); }; -module.exports = IsSizePowerOfTwo; +module.exports = Contains; /***/ }), -/* 86 */ +/* 70 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -15774,9 +13658,9 @@ module.exports = IsSizePowerOfTwo; */ var Class = __webpack_require__(0); -var FromPoints = __webpack_require__(274); -var Rectangle = __webpack_require__(14); -var Vector2 = __webpack_require__(6); +var FromPoints = __webpack_require__(173); +var Rectangle = __webpack_require__(9); +var Vector2 = __webpack_require__(3); /** * @classdesc @@ -15785,7 +13669,7 @@ var Vector2 = __webpack_require__(6); * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) * * @class Curve - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * @@ -15900,7 +13784,7 @@ var Curve = new Class({ // So you can chain graphics calls return graphics.strokePoints(this.getPoints(pointsTotal)); }, - + /** * Returns a Rectangle where the position and dimensions match the bounds of this Curve. * @@ -15961,9 +13845,9 @@ var Curve = new Class({ * @method Phaser.Curves.Curve#getEndPoint * @since 3.0.0 * - * @param {Phaser.Math.Vector2} out - [description] + * @param {Phaser.Math.Vector2} [out] - Optional Vector object to store the result in. * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} Vector2 containing the coordinates of the curves end point. */ getEndPoint: function (out) { @@ -16047,7 +13931,7 @@ var Curve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -16167,7 +14051,7 @@ var Curve = new Class({ * @param {number} t - [description] * @param {Phaser.Math.Vector2} [out] - [description] * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001) */ getTangent: function (t, out) { @@ -16203,7 +14087,7 @@ var Curve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -16225,7 +14109,7 @@ var Curve = new Class({ * @param {integer} distance - [description] * @param {integer} [divisions] - [description] * - * @return {float} [description] + * @return {number} [description] */ getTFromDistance: function (distance, divisions) { @@ -16245,7 +14129,7 @@ var Curve = new Class({ * @method Phaser.Curves.Curve#getUtoTmapping * @since 3.0.0 * - * @param {float} u - [description] + * @param {number} u - [description] * @param {integer} distance - [description] * @param {integer} [divisions] - [description] * @@ -16339,793 +14223,7 @@ module.exports = Curve; /***/ }), -/* 87 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A representation of a vector in 3D space. - * - * A three-component vector. - * - * @class Vector3 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - The x component. - * @param {number} [y] - The y component. - * @param {number} [z] - The z component. - */ -var Vector3 = new Class({ - - initialize: - - function Vector3 (x, y, z) - { - /** - * The x component of this Vector. - * - * @name Phaser.Math.Vector3#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The y component of this Vector. - * - * @name Phaser.Math.Vector3#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The z component of this Vector. - * - * @name Phaser.Math.Vector3#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.z = 0; - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - }, - - /** - * Set this Vector to point up. - * - * Sets the y component of the vector to 1, and the others to 0. - * - * @method Phaser.Math.Vector3#up - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - up: function () - { - this.x = 0; - this.y = 1; - this.z = 0; - - return this; - }, - - /** - * Make a clone of this Vector3. - * - * @method Phaser.Math.Vector3#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} A new Vector3 object containing this Vectors values. - */ - clone: function () - { - return new Vector3(this.x, this.y, this.z); - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#crossVectors - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} a - [description] - * @param {Phaser.Math.Vector3} b - [description] - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - crossVectors: function (a, b) - { - var ax = a.x; - var ay = a.y; - var az = a.z; - var bx = b.x; - var by = b.y; - var bz = b.z; - - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; - - return this; - }, - - /** - * Check whether this Vector is equal to a given Vector. - * - * Performs a strict equality check against each Vector's components. - * - * @method Phaser.Math.Vector3#equals - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} v - The Vector3 to compare against. - * - * @return {boolean} True if the two vectors strictly match, otherwise false. - */ - equals: function (v) - { - return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); - }, - - /** - * Copy the components of a given Vector into this Vector. - * - * @method Phaser.Math.Vector3#copy - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} src - The Vector to copy the components from. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z || 0; - - return this; - }, - - /** - * Set the `x`, `y`, and `z` components of this Vector to the given `x`, `y`, and `z` values. - * - * @method Phaser.Math.Vector3#set - * @since 3.0.0 - * - * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y and z components. - * @param {number} [y] - The y value to set for this Vector. - * @param {number} [z] - The z value to set for this Vector. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - set: function (x, y, z) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - } - - return this; - }, - - /** - * Add a given Vector to this Vector. Addition is component-wise. - * - * @method Phaser.Math.Vector3#add - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to add to this Vector. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z || 0; - - return this; - }, - - /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * - * @method Phaser.Math.Vector3#subtract - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to subtract from this Vector. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z || 0; - - return this; - }, - - /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * - * @method Phaser.Math.Vector3#multiply - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to multiply this Vector by. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - multiply: function (v) - { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z || 1; - - return this; - }, - - /** - * Scale this Vector by the given value. - * - * @method Phaser.Math.Vector3#scale - * @since 3.0.0 - * - * @param {number} scale - The value to scale this Vector by. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - scale: function (scale) - { - if (isFinite(scale)) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - } - else - { - this.x = 0; - this.y = 0; - this.z = 0; - } - - return this; - }, - - /** - * Perform a component-wise division between this Vector and the given Vector. - * - * Divides this Vector by the given Vector. - * - * @method Phaser.Math.Vector3#divide - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to divide this Vector by. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - divide: function (v) - { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z || 1; - - return this; - }, - - /** - * Negate the `x`, `y` and `z` components of this Vector. - * - * @method Phaser.Math.Vector3#negate - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - negate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - - return this; - }, - - /** - * Calculate the distance between this Vector and the given Vector. - * - * @method Phaser.Math.Vector3#distance - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. - * - * @return {number} The distance from this Vector to the given Vector. - */ - distance: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - - return Math.sqrt(dx * dx + dy * dy + dz * dz); - }, - - /** - * Calculate the distance between this Vector, and the given Vector, squared. - * - * @method Phaser.Math.Vector3#distanceSq - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. - * - * @return {number} The distance from this Vector to the given Vector, squared. - */ - distanceSq: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - - return dx * dx + dy * dy + dz * dz; - }, - - /** - * Calculate the length (or magnitude) of this Vector. - * - * @method Phaser.Math.Vector3#length - * @since 3.0.0 - * - * @return {number} The length of this Vector. - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - return Math.sqrt(x * x + y * y + z * z); - }, - - /** - * Calculate the length of this Vector squared. - * - * @method Phaser.Math.Vector3#lengthSq - * @since 3.0.0 - * - * @return {number} The length of this Vector, squared. - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - return x * x + y * y + z * z; - }, - - /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. - * - * @method Phaser.Math.Vector3#normalize - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var len = x * x + y * y + z * z; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - } - - return this; - }, - - /** - * Calculate the dot product of this Vector and the given Vector. - * - * @method Phaser.Math.Vector3#dot - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} v - The Vector3 to dot product with this Vector3. - * - * @return {number} [description] - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#cross - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} v - [description] - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - cross: function (v) - { - var ax = this.x; - var ay = this.y; - var az = this.z; - var bx = v.x; - var by = v.y; - var bz = v.z; - - this.x = ay * bz - az * by; - this.y = az * bx - ax * bz; - this.z = ax * by - ay * bx; - - return this; - }, - - /** - * Linearly interpolate between this Vector and the given Vector. - * - * Interpolates this Vector towards the given Vector. - * - * @method Phaser.Math.Vector3#lerp - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} v - The Vector3 to interpolate towards. - * @param {number} [t=0] - The interpolation percentage, between 0 and 1. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - - return this; - }, - - /** - * Transform this Vector with the given Matrix. - * - * @method Phaser.Math.Vector3#transformMat3 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector3 with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - transformMat3: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - this.x = x * m[0] + y * m[3] + z * m[6]; - this.y = x * m[1] + y * m[4] + z * m[7]; - this.z = x * m[2] + y * m[5] + z * m[8]; - - return this; - }, - - /** - * Transform this Vector with the given Matrix. - * - * @method Phaser.Math.Vector3#transformMat4 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - transformMat4: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; - this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; - this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Vector3#transformCoordinates - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - transformCoordinates: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; - var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; - var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; - var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; - - this.x = tx / tw; - this.y = ty / tw; - this.z = tz / tw; - - return this; - }, - - /** - * Transform this Vector with the given Quaternion. - * - * @method Phaser.Math.Vector3#transformQuat - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - transformQuat: function (q) - { - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations - var x = this.x; - var y = this.y; - var z = this.z; - var qx = q.x; - var qy = q.y; - var qz = q.z; - var qw = q.w; - - // calculate quat * vec - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; - - return this; - }, - - /** - * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, - * e.g. unprojecting a 2D point into 3D space. - * - * @method Phaser.Math.Vector3#project - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat - The Matrix4 to multiply this Vector3 with. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - project: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var m = mat.val; - - var a00 = m[0]; - var a01 = m[1]; - var a02 = m[2]; - var a03 = m[3]; - var a10 = m[4]; - var a11 = m[5]; - var a12 = m[6]; - var a13 = m[7]; - var a20 = m[8]; - var a21 = m[9]; - var a22 = m[10]; - var a23 = m[11]; - var a30 = m[12]; - var a31 = m[13]; - var a32 = m[14]; - var a33 = m[15]; - - var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); - - this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; - this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; - this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; - - return this; - }, - - /** - * Unproject this point from 2D space to 3D space. - * The point should have its x and y properties set to - * 2D screen space, and the z either at 0 (near plane) - * or 1 (far plane). The provided matrix is assumed to already - * be combined, i.e. projection * view * model. - * - * After this operation, this vector's (x, y, z) components will - * represent the unprojected 3D coordinate. - * - * @method Phaser.Math.Vector3#unproject - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} viewport - Screen x, y, width and height in pixels. - * @param {Phaser.Math.Matrix4} invProjectionView - Combined projection and view matrix. - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - unproject: function (viewport, invProjectionView) - { - var viewX = viewport.x; - var viewY = viewport.y; - var viewWidth = viewport.z; - var viewHeight = viewport.w; - - var x = this.x - viewX; - var y = (viewHeight - this.y - 1) - viewY; - var z = this.z; - - this.x = (2 * x) / viewWidth - 1; - this.y = (2 * y) / viewHeight - 1; - this.z = 2 * z - 1; - - return this.project(invProjectionView); - }, - - /** - * Make this Vector the zero vector (0, 0, 0). - * - * @method Phaser.Math.Vector3#reset - * @since 3.0.0 - * - * @return {Phaser.Math.Vector3} This Vector3. - */ - reset: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - - return this; - } - -}); - -/* -Vector3.Zero = function () -{ - return new Vector3(0, 0, 0); -}; - -Vector3.Up = function () -{ - return new Vector3(0, 1.0, 0); -}; - -Vector3.Copy = function (source) -{ - return new Vector3(source.x, source.y, source.z); -}; - -Vector3.TransformCoordinates = function (vector, transformation) -{ - var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; - var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; - var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; - var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; - - return new Vector3(x / w, y / w, z / w); -}; - -Vector3.TransformNormal = function (vector, transformation) -{ - var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); - var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); - var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); - - return new Vector3(x, y, z); -}; - -Vector3.Dot = function (left, right) -{ - return (left.x * right.x + left.y * right.y + left.z * right.z); -}; - -Vector3.Cross = function (left, right) -{ - var x = left.y * right.z - left.z * right.y; - var y = left.z * right.x - left.x * right.z; - var z = left.x * right.y - left.y * right.x; - - return new Vector3(x, y, z); -}; - -Vector3.Normalize = function (vector) -{ - var newVector = Vector3.Copy(vector); - newVector.normalize(); - - return newVector; -}; - -Vector3.Distance = function (value1, value2) -{ - return Math.sqrt(Vector3.DistanceSquared(value1, value2)); -}; - -Vector3.DistanceSquared = function (value1, value2) -{ - var x = value1.x - value2.x; - var y = value1.y - value2.y; - var z = value1.z - value2.z; - - return (x * x) + (y * y) + (z * z); -}; -*/ - -module.exports = Vector3; - - -/***/ }), -/* 88 */ +/* 71 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -17135,10 +14233,10 @@ module.exports = Vector3; */ var Class = __webpack_require__(0); -var Contains = __webpack_require__(32); -var GetPoint = __webpack_require__(298); -var GetPoints = __webpack_require__(296); -var Random = __webpack_require__(157); +var Contains = __webpack_require__(40); +var GetPoint = __webpack_require__(405); +var GetPoints = __webpack_require__(403); +var Random = __webpack_require__(191); /** * @classdesc @@ -17149,7 +14247,7 @@ var Random = __webpack_require__(157); * To render a Circle you should look at the capabilities of the Graphics class. * * @class Circle - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * @@ -17234,7 +14332,7 @@ var Circle = new Class({ * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. @@ -17488,7 +14586,7 @@ module.exports = Circle; /***/ }), -/* 89 */ +/* 72 */ /***/ (function(module, exports) { /** @@ -17516,7 +14614,7 @@ module.exports = GetCenterY; /***/ }), -/* 90 */ +/* 73 */ /***/ (function(module, exports) { /** @@ -17551,7 +14649,7 @@ module.exports = SetCenterY; /***/ }), -/* 91 */ +/* 74 */ /***/ (function(module, exports) { /** @@ -17586,7 +14684,7 @@ module.exports = SetCenterX; /***/ }), -/* 92 */ +/* 75 */ /***/ (function(module, exports) { /** @@ -17614,3063 +14712,467 @@ module.exports = GetCenterX; /***/ }), -/* 93 */ +/* 76 */ /***/ (function(module, exports, __webpack_require__) { /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ +* The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. +* A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. +* A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Vertices +*/ -var ArrayUtils = __webpack_require__(147); -var Class = __webpack_require__(0); -var NOOP = __webpack_require__(3); -var StableSort = __webpack_require__(83); +var Vertices = {}; -/** - * @callback EachListCallback - * @generic I - [item] - * - * @param {*} item - [description] - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ +module.exports = Vertices; -/** - * @classdesc - * [description] - * - * @class List - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic T - * - * @param {*} parent - [description] - */ -var List = new Class({ +var Vector = __webpack_require__(81); +var Common = __webpack_require__(33); - initialize: - - function List (parent) - { - /** - * The parent of this list. - * - * @name Phaser.Structs.List#parent - * @type {*} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * The objects that belong to this collection. - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.List#list - * @type {Array.<*>} - * @default [] - * @since 3.0.0 - */ - this.list = []; - - /** - * [description] - * - * @name Phaser.Structs.List#position - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.position = 0; - - /** - * A callback that is invoked every time a child is added to this list. - * - * @name Phaser.Structs.List#addCallback - * @type {function} - * @since 3.4.0 - */ - this.addCallback = NOOP; - - /** - * A callback that is invoked every time a child is removed from this list. - * - * @name Phaser.Structs.List#removeCallback - * @type {function} - * @since 3.4.0 - */ - this.removeCallback = NOOP; - - /** - * The property key to sort by. - * - * @name Phaser.Structs.List#_sortKey - * @type {string} - * @since 3.4.0 - */ - this._sortKey = ''; - }, +(function() { /** - * [description] + * Creates a new set of `Matter.Body` compatible vertices. + * The `points` argument accepts an array of `Matter.Vector` points orientated around the origin `(0, 0)`, for example: * - * @method Phaser.Structs.List#add - * @since 3.0.0 + * [{ x: 0, y: 0 }, { x: 25, y: 50 }, { x: 50, y: 0 }] * - * @genericUse {T} - [child,$return] + * The `Vertices.create` method returns a new array of vertices, which are similar to Matter.Vector objects, + * but with some additional references required for efficient collision detection routines. * - * @param {*|Array.<*>} child - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. + * Vertices must be specified in clockwise order. * - * @return {*} [description] + * Note that the `body` argument is not optional, a `Matter.Body` reference must be provided. + * + * @method create + * @param {vector[]} points + * @param {body} body */ - add: function (child, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.Add(this.list, child); - } - else - { - return ArrayUtils.Add(this.list, child, 0, this.addCallback, this); - } - }, + Vertices.create = function(points, body) { + var vertices = []; - /** - * [description] - * - * @method Phaser.Structs.List#addAt - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * @param {integer} [index=0] - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. - * - * @return {*} [description] - */ - addAt: function (child, index, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.AddAt(this.list, child, index); - } - else - { - return ArrayUtils.AddAt(this.list, child, index, 0, this.addCallback, this); - } - }, + for (var i = 0; i < points.length; i++) { + var point = points[i], + vertex = { + x: point.x, + y: point.y, + index: i, + body: body, + isInternal: false, + contact: null + }; - /** - * [description] - * - * @method Phaser.Structs.List#getAt - * @since 3.0.0 - * - * @genericUse {T} - [$return] - * - * @param {integer} index - [description] - * - * @return {*} [description] - */ - getAt: function (index) - { - return this.list[index]; - }, + vertex.contact = { + vertex: vertex, + normalImpulse: 0, + tangentImpulse: 0 + }; - /** - * [description] - * - * @method Phaser.Structs.List#getIndex - * @since 3.0.0 - * - * @genericUse {T} - [child] - * - * @param {*} child - [description] - * - * @return {integer} [description] - */ - getIndex: function (child) - { - // Return -1 if given child isn't a child of this display list - return this.list.indexOf(child); - }, - - /** - * Sort the contents of this List so the items are in order based - * on the given property. For example, `sort('alpha')` would sort the List - * contents based on the value of their `alpha` property. - * - * @method Phaser.Structs.List#sort - * @since 3.0.0 - * - * @genericUse {T[]} - [children,$return] - * - * @param {string} property - The property to lexically sort by. - * - * @return {Array.<*>} [description] - */ - sort: function (property) - { - if (property) - { - this._sortKey = property; - - StableSort.inplace(this.list, this.sortHandler); + vertices.push(vertex); } - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#sortHandler - * @private - * @since 3.4.0 - * - * @genericUse {T} - [childA,childB] - * - * @param {*} childA - [description] - * @param {*} childB - [description] - * - * @return {integer} [description] - */ - sortHandler: function (childA, childB) - { - return childA[this._sortKey] - childB[this._sortKey]; - }, - - /** - * Searches for the first instance of a child with its `name` - * property matching the given argument. Should more than one child have - * the same name only the first is returned. - * - * @method Phaser.Structs.List#getByName - * @since 3.0.0 - * - * @genericUse {T | null} - [$return] - * - * @param {string} name - The name to search for. - * - * @return {?*} The first child with a matching name, or null if none were found. - */ - getByName: function (name) - { - return ArrayUtils.GetFirst(this.list, 'name', name); - }, - - /** - * Returns a random child from the group. - * - * @method Phaser.Structs.List#getRandom - * @since 3.0.0 - * - * @genericUse {T | null} - [$return] - * - * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child). - * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from. - * - * @return {?*} A random child of this Group. - */ - getRandom: function (startIndex, length) - { - return ArrayUtils.GetRandom(this.list, startIndex, length); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#getFirst - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {T | null} - [$return] - * - * @param {string} property - [description] - * @param {*} value - [description] - * @param {number} [startIndex=0] - [description] - * @param {number} [endIndex] - [description] - * - * @return {?*} [description] - */ - getFirst: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); - }, - - /** - * Returns all children in this List. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('parent')` would return only children that have a property called `parent`. - * - * You can also specify a value to compare the property to: - * - * `getAll('visible', true)` would return only children that have their visible property set to `true`. - * - * Optionally you can specify a start and end index. For example if this List had 100 children, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 children in the List. - * - * @method Phaser.Structs.List#getAll - * @since 3.0.0 - * - * @genericUse {T} - [value] - * @genericUse {T[]} - [$return] - * - * @param {string} [property] - An optional property to test against the value argument. - * @param {*} [value] - If property is set then Child.property must strictly equal this value to be included in the results. - * @param {integer} [startIndex] - The first child index to start the search from. - * @param {integer} [endIndex] - The last child index to search up until. - * - * @return {Array.<*>} [description] - */ - getAll: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#count - * @since 3.0.0 - * - * @genericUse {T} - [value] - * - * @param {string} property - [description] - * @param {*} value - [description] - * - * @return {integer} [description] - */ - count: function (property, value) - { - return ArrayUtils.CountAllMatching(this.list, property, value); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#swap - * @since 3.0.0 - * - * @genericUse {T} - [child1,child2] - * - * @param {*} child1 - [description] - * @param {*} child2 - [description] - */ - swap: function (child1, child2) - { - ArrayUtils.Swap(this.list, child1, child2); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#moveTo - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * @param {integer} index - [description] - * - * @return {*} [description] - */ - moveTo: function (child, index) - { - return ArrayUtils.MoveTo(this.list, child, index); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#remove - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {*} [description] - */ - remove: function (child, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.Remove(this.list, child); - } - else - { - return ArrayUtils.Remove(this.list, child, this.removeCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#removeAt - * @since 3.0.0 - * - * @genericUse {T} - [$return] - * - * @param {integer} index - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {*} [description] - */ - removeAt: function (index, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.RemoveAt(this.list, index); - } - else - { - return ArrayUtils.RemoveAt(this.list, index, this.removeCallback, this); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#removeBetween - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @param {integer} [startIndex=0] - [description] - * @param {integer} [endIndex] - [description] - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {Array.<*>} [description] - */ - removeBetween: function (startIndex, endIndex, skipCallback) - { - if (skipCallback) - { - return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex); - } - else - { - return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeCallback, this); - } - }, - - /** - * Removes all the items. - * - * @method Phaser.Structs.List#removeAll - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.List.} - [$return] - * - * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. - * - * @return {Phaser.Structs.List} This List object. - */ - removeAll: function (skipCallback) - { - var i = this.list.length; - - while (i--) - { - this.remove(this.list[i], skipCallback); - } - - return this; - }, - - /** - * Brings the given child to the top of this List. - * - * @method Phaser.Structs.List#bringToTop - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - bringToTop: function (child) - { - return ArrayUtils.BringToTop(this.list, child); - }, - - /** - * Sends the given child to the bottom of this List. - * - * @method Phaser.Structs.List#sendToBack - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - sendToBack: function (child) - { - return ArrayUtils.SendToBack(this.list, child); - }, - - /** - * Moves the given child up one place in this group unless it's already at the top. - * - * @method Phaser.Structs.List#moveUp - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - moveUp: function (child) - { - ArrayUtils.MoveUp(this.list, child); - - return child; - }, - - /** - * Moves the given child down one place in this group unless it's already at the bottom. - * - * @method Phaser.Structs.List#moveDown - * @since 3.0.0 - * - * @genericUse {T} - [child,$return] - * - * @param {*} child - [description] - * - * @return {*} [description] - */ - moveDown: function (child) - { - ArrayUtils.MoveDown(this.list, child); - - return child; - }, - - /** - * Reverses the order of all children in this List. - * - * @method Phaser.Structs.List#reverse - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.List.} - [$return] - * - * @return {Phaser.Structs.List} This List object. - */ - reverse: function () - { - this.list.reverse(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#shuffle - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.List.} - [$return] - * - * @return {Phaser.Structs.List} This List object. - */ - shuffle: function () - { - ArrayUtils.Shuffle(this.list); - - return this; - }, - - /** - * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. - * - * @method Phaser.Structs.List#replace - * @since 3.0.0 - * - * @genericUse {T} - [oldChild,newChild,$return] - * - * @param {*} oldChild - The child in this List that will be replaced. - * @param {*} newChild - The child to be inserted into this List. - * - * @return {*} Returns the oldChild that was replaced within this group. - */ - replace: function (oldChild, newChild) - { - return ArrayUtils.Replace(this.list, oldChild, newChild); - }, - - /** - * [description] - * - * @method Phaser.Structs.List#exists - * @since 3.0.0 - * - * @genericUse {T} - [child] - * - * @param {*} child - [description] - * - * @return {boolean} True if the item is found in the list, otherwise false. - */ - exists: function (child) - { - return (this.list.indexOf(child) > -1); - }, - - /** - * Sets the property `key` to the given value on all members of this List. - * - * @method Phaser.Structs.List#setAll - * @since 3.0.0 - * - * @genericUse {T} - [value] - * - * @param {string} property - [description] - * @param {*} value - [description] - * @param {integer} [startIndex] - The first child index to start the search from. - * @param {integer} [endIndex] - The last child index to search up until. - */ - setAll: function (property, value, startIndex, endIndex) - { - ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); - - return this; - }, - - /** - * Passes all children to the given callback. - * - * @method Phaser.Structs.List#each - * @since 3.0.0 - * - * @genericUse {EachListCallback.} - [callback] - * - * @param {EachListCallback} callback - The function to call. - * @param {*} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ - each: function (callback, context) - { - var args = [ null ]; - - for (var i = 2; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = 0; i < this.list.length; i++) - { - args[0] = this.list[i]; - - callback.apply(context, args); - } - }, - - /** - * [description] - * - * @method Phaser.Structs.List#shutdown - * @since 3.0.0 - */ - shutdown: function () - { - this.removeAll(); - - this.list = []; - }, - - /** - * [description] - * - * @method Phaser.Structs.List#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAll(); - - this.parent = null; - this.addCallback = null; - this.removeCallback = null; - }, - - /** - * [description] - * - * @name Phaser.Structs.List#length - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - length: { - - get: function () - { - return this.list.length; - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#first - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - first: { - - get: function () - { - this.position = 0; - - if (this.list.length > 0) - { - return this.list[0]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#last - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - last: { - - get: function () - { - if (this.list.length > 0) - { - this.position = this.list.length - 1; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#next - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - next: { - - get: function () - { - if (this.position < this.list.length) - { - this.position++; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * [description] - * - * @name Phaser.Structs.List#previous - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - previous: { - - get: function () - { - if (this.position > 0) - { - this.position--; - - return this.list[this.position]; - } - else - { - return null; - } - } - - } - -}); - -module.exports = List; - - -/***/ }), -/* 94 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(33); - -/** - * Creates a new Object using all values from obj1 and obj2. - * If a value exists in both obj1 and obj2, the value in obj1 is used. - * - * @function Phaser.Utils.Object.Merge - * @since 3.0.0 - * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] - * - * @return {object} [description] - */ -var Merge = function (obj1, obj2) -{ - var clone = Clone(obj1); - - for (var key in obj2) - { - if (!clone.hasOwnProperty(key)) - { - clone[key] = obj2[key]; - } - } - - return clone; -}; - -module.exports = Merge; - - -/***/ }), -/* 95 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Shuffles the contents of the given array using the Fisher-Yates implementation. - * - * The original array is modified directly and returned. - * - * @function Phaser.Utils.Array.Shuffle - * @since 3.0.0 - * - * @param {array} array - The array to shuffle. This array is modified in place. - * - * @return {array} The shuffled array. - */ -var Shuffle = function (array) -{ - for (var i = array.length - 1; i > 0; i--) - { - var j = Math.floor(Math.random() * (i + 1)); - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - - return array; -}; - -module.exports = Shuffle; - - -/***/ }), -/* 96 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetPoint = __webpack_require__(293); -var GetPoints = __webpack_require__(156); -var Random = __webpack_require__(155); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * Defines a Line segment, a part of a line between two endpoints. - * - * @class Line - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 - * - * @param {number} [x1=0] - The x coordinate of the lines starting point. - * @param {number} [y1=0] - The y coordinate of the lines starting point. - * @param {number} [x2=0] - The x coordinate of the lines ending point. - * @param {number} [y2=0] - The y coordinate of the lines ending point. - */ -var Line = new Class({ - - initialize: - - function Line (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - - /** - * The x coordinate of the lines starting point. - * - * @name Phaser.Geom.Line#x1 - * @type {number} - * @since 3.0.0 - */ - this.x1 = x1; - - /** - * The y coordinate of the lines starting point. - * - * @name Phaser.Geom.Line#y1 - * @type {number} - * @since 3.0.0 - */ - this.y1 = y1; - - /** - * The x coordinate of the lines ending point. - * - * @name Phaser.Geom.Line#x2 - * @type {number} - * @since 3.0.0 - */ - this.x2 = x2; - - /** - * The y coordinate of the lines ending point. - * - * @name Phaser.Geom.Line#y2 - * @type {number} - * @since 3.0.0 - */ - this.y2 = y2; - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] - * - * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point on the line. - */ - getPoint: function (position, output) - { - return GetPoint(this, position, output); - }, - - /** - * [description] - * - * @method Phaser.Geom.Line#getPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [output,$return] - * - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ - getPoints: function (quantity, stepRate, output) - { - return GetPoints(this, quantity, stepRate, output); - }, - - /** - * Get a random Point on the Line. - * - * @method Phaser.Geom.Line#getRandomPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {(Phaser.Geom.Point|object)} [point] - An instance of a Point to be modified. - * - * @return {Phaser.Geom.Point} A random Point on the Line. - */ - getRandomPoint: function (point) - { - return Random(this, point); - }, - - /** - * Set new coordinates for the line endpoints. - * - * @method Phaser.Geom.Line#setTo - * @since 3.0.0 - * - * @param {number} [x1=0] - The x coordinate of the lines starting point. - * @param {number} [y1=0] - The y coordinate of the lines starting point. - * @param {number} [x2=0] - The x coordinate of the lines ending point. - * @param {number} [y2=0] - The y coordinate of the lines ending point. - * - * @return {Phaser.Geom.Line} This Line object. - */ - setTo: function (x1, y1, x2, y2) - { - if (x1 === undefined) { x1 = 0; } - if (y1 === undefined) { y1 = 0; } - if (x2 === undefined) { x2 = 0; } - if (y2 === undefined) { y2 = 0; } - - this.x1 = x1; - this.y1 = y1; - - this.x2 = x2; - this.y2 = y2; - - return this; - }, - - /** - * Returns a Vector2 object that corresponds to the start of this Line. - * - * @method Phaser.Geom.Line#getPointA - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [vec2,$return] - * - * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. - */ - getPointA: function (vec2) - { - if (vec2 === undefined) { vec2 = new Vector2(); } - - vec2.set(this.x1, this.y1); - - return vec2; - }, - - /** - * Returns a Vector2 object that corresponds to the start of this Line. - * - * @method Phaser.Geom.Line#getPointB - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [vec2,$return] - * - * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. - */ - getPointB: function (vec2) - { - if (vec2 === undefined) { vec2 = new Vector2(); } - - vec2.set(this.x2, this.y2); - - return vec2; - }, - - /** - * The left position of the Line. - * - * @name Phaser.Geom.Line#left - * @type {number} - * @since 3.0.0 - */ - left: { - - get: function () - { - return Math.min(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 <= this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The right position of the Line. - * - * @name Phaser.Geom.Line#right - * @type {number} - * @since 3.0.0 - */ - right: { - - get: function () - { - return Math.max(this.x1, this.x2); - }, - - set: function (value) - { - if (this.x1 > this.x2) - { - this.x1 = value; - } - else - { - this.x2 = value; - } - } - - }, - - /** - * The top position of the Line. - * - * @name Phaser.Geom.Line#top - * @type {number} - * @since 3.0.0 - */ - top: { - - get: function () - { - return Math.min(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 <= this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } - } - - }, - - /** - * The bottom position of the Line. - * - * @name Phaser.Geom.Line#bottom - * @type {number} - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return Math.max(this.y1, this.y2); - }, - - set: function (value) - { - if (this.y1 > this.y2) - { - this.y1 = value; - } - else - { - this.y2 = value; - } - } - - } - -}); - -module.exports = Line; - - -/***/ }), -/* 97 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Perimeter - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {number} [description] - */ -var Perimeter = function (rect) -{ - return 2 * (rect.width + rect.height); -}; - -module.exports = Perimeter; - - -/***/ }), -/* 98 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} TweenDataGenConfig - * - * @property {function} delay - [description] - * @property {function} duration - [description] - * @property {function} hold - [description] - * @property {function} repeat - [description] - * @property {function} repeatDelay - [description] - */ - -/** - * @typedef {object} Phaser.Tweens.TweenDataConfig - * - * @property {object} target - The target to tween. - * @property {string} key - The property of the target being tweened. - * @property {function} getEndValue - The returned value sets what the property will be at the END of the Tween. - * @property {function} getStartValue - The returned value sets what the property will be at the START of the Tween. - * @property {function} ease - The ease function this tween uses. - * @property {number} [duration=0] - Duration of the tween in ms/frames, excludes time for yoyo or repeats. - * @property {number} [totalDuration=0] - The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) - * @property {number} [delay=0] - Time in ms/frames before tween will start. - * @property {boolean} [yoyo=false] - Cause the tween to return back to its start value after hold has expired. - * @property {number} [hold=0] - Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - * @property {integer} [repeat=0] - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - * @property {number} [repeatDelay=0] - Time in ms/frames before the repeat will start. - * @property {boolean} [flipX=false] - Automatically call toggleFlipX when the TweenData yoyos or repeats - * @property {boolean} [flipY=false] - Automatically call toggleFlipY when the TweenData yoyos or repeats - * @property {float} [progress=0] - Between 0 and 1 showing completion of this TweenData. - * @property {float} [elapsed=0] - Delta counter - * @property {integer} [repeatCounter=0] - How many repeats are left to run? - * @property {number} [start=0] - Ease value data. - * @property {number} [current=0] - Ease value data. - * @property {number} [end=0] - Ease value data. - * @property {number} [t1=0] - Time duration 1. - * @property {number} [t2=0] - Time duration 2. - * @property {TweenDataGenConfig} [gen] - LoadValue generation functions. - * @property {integer} [state=0] - TWEEN_CONST.CREATED - */ - -/** - * [description] - * - * @function Phaser.Tweens.TweenData - * @since 3.0.0 - * - * @param {object} target - [description] - * @param {string} key - [description] - * @param {function} getEnd - [description] - * @param {function} getStart - [description] - * @param {function} ease - [description] - * @param {number} delay - [description] - * @param {number} duration - [description] - * @param {boolean} yoyo - [description] - * @param {number} hold - [description] - * @param {number} repeat - [description] - * @param {number} repeatDelay - [description] - * @param {boolean} flipX - [description] - * @param {boolean} flipY - [description] - * - * @return {TweenDataConfig} [description] - */ -var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) -{ - return { - - // The target to tween - target: target, - - // The property of the target to tween - key: key, - - // The returned value sets what the property will be at the END of the Tween. - getEndValue: getEnd, - - // The returned value sets what the property will be at the START of the Tween. - getStartValue: getStart, - - // The ease function this tween uses. - ease: ease, - - // Duration of the tween in ms/frames, excludes time for yoyo or repeats. - duration: 0, - - // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) - totalDuration: 0, - - // Time in ms/frames before tween will start. - delay: 0, - - // Cause the tween to return back to its start value after hold has expired. - yoyo: yoyo, - - // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. - hold: 0, - - // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. - repeat: 0, - - // Time in ms/frames before the repeat will start. - repeatDelay: 0, - - // Automatically call toggleFlipX when the TweenData yoyos or repeats - flipX: flipX, - - // Automatically call toggleFlipY when the TweenData yoyos or repeats - flipY: flipY, - - // Between 0 and 1 showing completion of this TweenData. - progress: 0, - - // Delta counter. - elapsed: 0, - - // How many repeats are left to run? - repeatCounter: 0, - - // Ease Value Data: - - start: 0, - current: 0, - end: 0, - - // Time Durations - t1: 0, - t2: 0, - - // LoadValue generation functions - gen: { - delay: delay, - duration: duration, - hold: hold, - repeat: repeat, - repeatDelay: repeatDelay - }, - - // TWEEN_CONST.CREATED - state: 0 + return vertices; }; -}; - -module.exports = TweenData; - - -/***/ }), -/* 99 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GameObjectCreator = __webpack_require__(13); -var GameObjectFactory = __webpack_require__(11); -var TWEEN_CONST = __webpack_require__(61); - -/** - * @classdesc - * [description] - * - * @class Tween - * @memberOf Phaser.Tweens - * @constructor - * @since 3.0.0 - * - * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] - * @param {Phaser.Tweens.TweenDataConfig[]} data - [description] - * @param {array} targets - [description] - */ -var Tween = new Class({ - - initialize: - - function Tween (parent, data, targets) - { - /** - * [description] - * - * @name Phaser.Tweens.Tween#parent - * @type {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} - * @since 3.0.0 - */ - this.parent = parent; - - /** - * Is the parent of this Tween a Timeline? - * - * @name Phaser.Tweens.Tween#parentIsTimeline - * @type {boolean} - * @since 3.0.0 - */ - this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); - - /** - * An array of TweenData objects, each containing a unique property and target being tweened. - * - * @name Phaser.Tweens.Tween#data - * @type {Phaser.Tweens.TweenDataConfig[]} - * @since 3.0.0 - */ - this.data = data; - - /** - * data array doesn't change, so we can cache the length - * - * @name Phaser.Tweens.Tween#totalData - * @type {integer} - * @since 3.0.0 - */ - this.totalData = data.length; - - /** - * An array of references to the target/s this Tween is operating on - * - * @name Phaser.Tweens.Tween#targets - * @type {object[]} - * @since 3.0.0 - */ - this.targets = targets; - - /** - * Cached target total (not necessarily the same as the data total) - * - * @name Phaser.Tweens.Tween#totalTargets - * @type {integer} - * @since 3.0.0 - */ - this.totalTargets = targets.length; - - /** - * If true then duration, delay, etc values are all frame totals. - * - * @name Phaser.Tweens.Tween#useFrames - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useFrames = false; - - /** - * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. - * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. - * - * @name Phaser.Tweens.Tween#timeScale - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) - * - * @name Phaser.Tweens.Tween#loop - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loop = 0; - - /** - * Time in ms/frames before the tween loops. - * - * @name Phaser.Tweens.Tween#loopDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopDelay = 0; - - /** - * How many loops are left to run? - * - * @name Phaser.Tweens.Tween#loopCounter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.loopCounter = 0; - - /** - * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) - * - * @name Phaser.Tweens.Tween#completeDelay - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.completeDelay = 0; - - /** - * Countdown timer (used by timeline offset, loopDelay and completeDelay) - * - * @name Phaser.Tweens.Tween#countdown - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.countdown = 0; - - /** - * Set only if this Tween is part of a Timeline. - * - * @name Phaser.Tweens.Tween#offset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.offset = 0; - - /** - * Set only if this Tween is part of a Timeline. The calculated offset amount. - * - * @name Phaser.Tweens.Tween#calculatedOffset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.calculatedOffset = 0; - - /** - * The current state of the tween - * - * @name Phaser.Tweens.Tween#state - * @type {integer} - * @since 3.0.0 - */ - this.state = TWEEN_CONST.PENDING_ADD; - - /** - * The state of the tween when it was paused (used by Resume) - * - * @name Phaser.Tweens.Tween#_pausedState - * @type {integer} - * @private - * @since 3.0.0 - */ - this._pausedState = TWEEN_CONST.PENDING_ADD; - - /** - * Does the Tween start off paused? (if so it needs to be started with Tween.play) - * - * @name Phaser.Tweens.Tween#paused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.paused = false; - - /** - * Elapsed time in ms/frames of this run through the Tween. - * - * @name Phaser.Tweens.Tween#elapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.elapsed = 0; - - /** - * Total elapsed time in ms/frames of the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalElapsed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalElapsed = 0; - - /** - * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. - * - * @name Phaser.Tweens.Tween#duration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.duration = 0; - - /** - * Value between 0 and 1. The amount through the Tween, excluding loops. - * - * @name Phaser.Tweens.Tween#progress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.progress = 0; - - /** - * Time in ms/frames for the Tween to complete (including looping) - * - * @name Phaser.Tweens.Tween#totalDuration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalDuration = 0; - - /** - * Value between 0 and 1. The amount through the entire Tween, including looping. - * - * @name Phaser.Tweens.Tween#totalProgress - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.totalProgress = 0; - - /** - * An object containing the various Tween callback references. - * - * @name Phaser.Tweens.Tween#callbacks - * @type {object} - * @default 0 - * @since 3.0.0 - */ - this.callbacks = { - onComplete: null, - onLoop: null, - onRepeat: null, - onStart: null, - onUpdate: null, - onYoyo: null - }; - - this.callbackScope; - }, /** - * [description] - * - * @method Phaser.Tweens.Tween#getValue - * @since 3.0.0 - * - * @return {number} [description] + * Parses a string containing ordered x y pairs separated by spaces (and optionally commas), + * into a `Matter.Vertices` object for the given `Matter.Body`. + * For parsing SVG paths, see `Svg.pathToVertices`. + * @method fromPath + * @param {string} path + * @param {body} body + * @return {vertices} vertices */ - getValue: function () - { - return this.data[0].current; - }, + Vertices.fromPath = function(path, body) { + var pathPattern = /L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/ig, + points = []; + + path.replace(pathPattern, function(match, x, y) { + points.push({ x: parseFloat(x), y: parseFloat(y) }); + }); + + return Vertices.create(points, body); + }; /** - * [description] - * - * @method Phaser.Tweens.Tween#setTimeScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. + * Returns the centre (centroid) of the set of vertices. + * @method centre + * @param {vertices} vertices + * @return {vector} The centre point */ - setTimeScale: function (value) - { - this.timeScale = value; + Vertices.centre = function(vertices) { + var area = Vertices.area(vertices, true), + centre = { x: 0, y: 0 }, + cross, + temp, + j; - return this; - }, + for (var i = 0; i < vertices.length; i++) { + j = (i + 1) % vertices.length; + cross = Vector.cross(vertices[i], vertices[j]); + temp = Vector.mult(Vector.add(vertices[i], vertices[j]), cross); + centre = Vector.add(centre, temp); + } + + return Vector.div(centre, 6 * area); + }; /** - * [description] - * - * @method Phaser.Tweens.Tween#getTimeScale - * @since 3.0.0 - * - * @return {number} [description] + * Returns the average (mean) of the set of vertices. + * @method mean + * @param {vertices} vertices + * @return {vector} The average point */ - getTimeScale: function () - { - return this.timeScale; - }, + Vertices.mean = function(vertices) { + var average = { x: 0, y: 0 }; + + for (var i = 0; i < vertices.length; i++) { + average.x += vertices[i].x; + average.y += vertices[i].y; + } + + return Vector.div(average, vertices.length); + }; /** - * [description] - * - * @method Phaser.Tweens.Tween#isPlaying - * @since 3.0.0 - * - * @return {boolean} [description] + * Returns the area of the set of vertices. + * @method area + * @param {vertices} vertices + * @param {bool} signed + * @return {number} The area */ - isPlaying: function () - { - return (this.state === TWEEN_CONST.ACTIVE); - }, + Vertices.area = function(vertices, signed) { + var area = 0, + j = vertices.length - 1; + + for (var i = 0; i < vertices.length; i++) { + area += (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); + j = i; + } + + if (signed) + return area / 2; + + return Math.abs(area) / 2; + }; /** - * [description] - * - * @method Phaser.Tweens.Tween#isPaused - * @since 3.0.0 - * - * @return {boolean} [description] + * Returns the moment of inertia (second moment of area) of the set of vertices given the total mass. + * @method inertia + * @param {vertices} vertices + * @param {number} mass + * @return {number} The polygon's moment of inertia */ - isPaused: function () - { - return (this.state === TWEEN_CONST.PAUSED); - }, + Vertices.inertia = function(vertices, mass) { + var numerator = 0, + denominator = 0, + v = vertices, + cross, + j; + + // find the polygon's moment of inertia, using second moment of area + // from equations at http://www.physicsforums.com/showthread.php?t=25293 + for (var n = 0; n < v.length; n++) { + j = (n + 1) % v.length; + cross = Math.abs(Vector.cross(v[j], v[n])); + numerator += cross * (Vector.dot(v[j], v[j]) + Vector.dot(v[j], v[n]) + Vector.dot(v[n], v[n])); + denominator += cross; + } + + return (mass / 6) * (numerator / denominator); + }; /** - * [description] - * - * @method Phaser.Tweens.Tween#hasTarget - * @since 3.0.0 - * - * @param {object} target - [description] - * - * @return {boolean} [description] + * Translates the set of vertices in-place. + * @method translate + * @param {vertices} vertices + * @param {vector} vector + * @param {number} scalar */ - hasTarget: function (target) - { - return (this.targets.indexOf(target) !== -1); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTo - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {*} value - [description] - * @param {boolean} startToCurrent - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - updateTo: function (key, value, startToCurrent) - { - for (var i = 0; i < this.totalData; i++) - { - var tweenData = this.data[i]; - - if (tweenData.key === key) - { - tweenData.end = value; - - if (startToCurrent) - { - tweenData.start = tweenData.current; - } - - break; + Vertices.translate = function(vertices, vector, scalar) { + var i; + if (scalar) { + for (i = 0; i < vertices.length; i++) { + vertices[i].x += vector.x * scalar; + vertices[i].y += vector.y * scalar; + } + } else { + for (i = 0; i < vertices.length; i++) { + vertices[i].x += vector.x; + vertices[i].y += vector.y; } } - return this; - }, + return vertices; + }; /** - * [description] - * - * @method Phaser.Tweens.Tween#restart - * @since 3.0.0 + * Rotates the set of vertices in-place. + * @method rotate + * @param {vertices} vertices + * @param {number} angle + * @param {vector} point */ - restart: function () - { - if (this.state === TWEEN_CONST.REMOVED) - { - this.seek(0); - this.parent.makeActive(this); + Vertices.rotate = function(vertices, angle, point) { + if (angle === 0) + return; + + var cos = Math.cos(angle), + sin = Math.sin(angle); + + for (var i = 0; i < vertices.length; i++) { + var vertice = vertices[i], + dx = vertice.x - point.x, + dy = vertice.y - point.y; + + vertice.x = point.x + (dx * cos - dy * sin); + vertice.y = point.y + (dx * sin + dy * cos); } - else - { - this.stop(); - this.play(); - } - }, + + return vertices; + }; /** - * [description] - * - * @method Phaser.Tweens.Tween#calcDuration - * @since 3.0.0 + * Returns `true` if the `point` is inside the set of `vertices`. + * @method contains + * @param {vertices} vertices + * @param {vector} point + * @return {boolean} True if the vertices contains point, otherwise false */ - calcDuration: function () - { - var max = 0; - - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - // Set t1 (duration + hold + yoyo) - tweenData.t1 = tweenData.duration + tweenData.hold; - - if (tweenData.yoyo) - { - tweenData.t1 += tweenData.duration; - } - - // Set t2 (repeatDelay + duration + hold + yoyo) - tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; - - // Total Duration - tweenData.totalDuration = tweenData.delay + tweenData.t1; - - if (tweenData.repeat === -1) - { - tweenData.totalDuration += (tweenData.t2 * 999999999999); - } - else if (tweenData.repeat > 0) - { - tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); - } - - if (tweenData.totalDuration > max) - { - // Get the longest TweenData from the Tween, used to calculate the Tween TD - max = tweenData.totalDuration; + Vertices.contains = function(vertices, point) { + for (var i = 0; i < vertices.length; i++) { + var vertice = vertices[i], + nextVertice = vertices[(i + 1) % vertices.length]; + if ((point.x - vertice.x) * (nextVertice.y - vertice.y) + (point.y - vertice.y) * (vertice.x - nextVertice.x) > 0) { + return false; } } - // Excludes loop values - this.duration = max; - - this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; - - if (this.loopCounter > 0) - { - this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); - } - else - { - this.totalDuration = this.duration + this.completeDelay; - } - }, + return true; + }; /** - * Called by TweenManager.preUpdate as part of its loop to check pending and active tweens. - * Should not be called directly. - * - * @method Phaser.Tweens.Tween#init - * @since 3.0.0 - * - * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. + * Scales the vertices from a point (default is centre) in-place. + * @method scale + * @param {vertices} vertices + * @param {number} scaleX + * @param {number} scaleY + * @param {vector} point */ - init: function () - { - var data = this.data; - var totalTargets = this.totalTargets; + Vertices.scale = function(vertices, scaleX, scaleY, point) { + if (scaleX === 1 && scaleY === 1) + return vertices; - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - var target = tweenData.target; - var gen = tweenData.gen; + point = point || Vertices.centre(vertices); - tweenData.delay = gen.delay(i, totalTargets, target); - tweenData.duration = gen.duration(i, totalTargets, target); - tweenData.hold = gen.hold(i, totalTargets, target); - tweenData.repeat = gen.repeat(i, totalTargets, target); - tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); + var vertex, + delta; + + for (var i = 0; i < vertices.length; i++) { + vertex = vertices[i]; + delta = Vector.sub(vertex, point); + vertices[i].x = point.x + delta.x * scaleX; + vertices[i].y = point.y + delta.y * scaleY; } - this.calcDuration(); + return vertices; + }; - this.progress = 0; - this.totalProgress = 0; - this.elapsed = 0; - this.totalElapsed = 0; - - // You can't have a paused Tween if it's part of a Timeline - if (this.paused && !this.parentIsTimeline) - { - this.state = TWEEN_CONST.PENDING_ADD; - this._pausedState = TWEEN_CONST.INIT; - - return false; + /** + * Chamfers a set of vertices by giving them rounded corners, returns a new set of vertices. + * The radius parameter is a single number or an array to specify the radius for each vertex. + * @method chamfer + * @param {vertices} vertices + * @param {number[]} radius + * @param {number} quality + * @param {number} qualityMin + * @param {number} qualityMax + */ + Vertices.chamfer = function(vertices, radius, quality, qualityMin, qualityMax) { + if (typeof radius === 'number') { + radius = [radius]; + } else { + radius = radius || [8]; } - else - { - this.state = TWEEN_CONST.INIT; + // quality defaults to -1, which is auto + quality = (typeof quality !== 'undefined') ? quality : -1; + qualityMin = qualityMin || 2; + qualityMax = qualityMax || 14; + + var newVertices = []; + + for (var i = 0; i < vertices.length; i++) { + var prevVertex = vertices[i - 1 >= 0 ? i - 1 : vertices.length - 1], + vertex = vertices[i], + nextVertex = vertices[(i + 1) % vertices.length], + currentRadius = radius[i < radius.length ? i : radius.length - 1]; + + if (currentRadius === 0) { + newVertices.push(vertex); + continue; + } + + var prevNormal = Vector.normalise({ + x: vertex.y - prevVertex.y, + y: prevVertex.x - vertex.x + }); + + var nextNormal = Vector.normalise({ + x: nextVertex.y - vertex.y, + y: vertex.x - nextVertex.x + }); + + var diagonalRadius = Math.sqrt(2 * Math.pow(currentRadius, 2)), + radiusVector = Vector.mult(Common.clone(prevNormal), currentRadius), + midNormal = Vector.normalise(Vector.mult(Vector.add(prevNormal, nextNormal), 0.5)), + scaledVertex = Vector.sub(vertex, Vector.mult(midNormal, diagonalRadius)); + + var precision = quality; + + if (quality === -1) { + // automatically decide precision + precision = Math.pow(currentRadius, 0.32) * 1.75; + } + + precision = Common.clamp(precision, qualityMin, qualityMax); + + // use an even value for precision, more likely to reduce axes by using symmetry + if (precision % 2 === 1) + precision += 1; + + var alpha = Math.acos(Vector.dot(prevNormal, nextNormal)), + theta = alpha / precision; + + for (var j = 0; j < precision; j++) { + newVertices.push(Vector.add(Vector.rotate(radiusVector, theta * j), scaledVertex)); + } + } + + return newVertices; + }; + + /** + * Sorts the input vertices into clockwise order in place. + * @method clockwiseSort + * @param {vertices} vertices + * @return {vertices} vertices + */ + Vertices.clockwiseSort = function(vertices) { + var centre = Vertices.mean(vertices); + + vertices.sort(function(vertexA, vertexB) { + return Vector.angle(centre, vertexA) - Vector.angle(centre, vertexB); + }); + + return vertices; + }; + + /** + * Returns true if the vertices form a convex shape (vertices must be in clockwise order). + * @method isConvex + * @param {vertices} vertices + * @return {bool} `true` if the `vertices` are convex, `false` if not (or `null` if not computable). + */ + Vertices.isConvex = function(vertices) { + // http://paulbourke.net/geometry/polygonmesh/ + // Copyright (c) Paul Bourke (use permitted) + + var flag = 0, + n = vertices.length, + i, + j, + k, + z; + + if (n < 3) + return null; + + for (i = 0; i < n; i++) { + j = (i + 1) % n; + k = (i + 2) % n; + z = (vertices[j].x - vertices[i].x) * (vertices[k].y - vertices[j].y); + z -= (vertices[j].y - vertices[i].y) * (vertices[k].x - vertices[j].x); + + if (z < 0) { + flag |= 1; + } else if (z > 0) { + flag |= 2; + } + + if (flag === 3) { + return false; + } + } + + if (flag !== 0){ return true; + } else { + return null; } - }, + }; /** - * [description] - * - * @method Phaser.Tweens.Tween#nextState - * @since 3.0.0 + * Returns the convex hull of the input vertices as a new array of points. + * @method hull + * @param {vertices} vertices + * @return [vertex] vertices */ - nextState: function () - { - if (this.loopCounter > 0) - { - this.elapsed = 0; - this.progress = 0; - this.loopCounter--; + Vertices.hull = function(vertices) { + // http://geomalgorithms.com/a10-_hull-1.html - var onLoop = this.callbacks.onLoop; + var upper = [], + lower = [], + vertex, + i; - if (onLoop) - { - onLoop.params[1] = this.targets; + // sort vertices on x-axis (y-axis for ties) + vertices = vertices.slice(0); + vertices.sort(function(vertexA, vertexB) { + var dx = vertexA.x - vertexB.x; + return dx !== 0 ? dx : vertexA.y - vertexB.y; + }); - onLoop.func.apply(onLoop.scope, onLoop.params); + // build lower hull + for (i = 0; i < vertices.length; i += 1) { + vertex = vertices[i]; + + while (lower.length >= 2 + && Vector.cross3(lower[lower.length - 2], lower[lower.length - 1], vertex) <= 0) { + lower.pop(); } - this.resetTweenData(true); - - if (this.loopDelay > 0) - { - this.countdown = this.loopDelay; - this.state = TWEEN_CONST.LOOP_DELAY; - } - else - { - this.state = TWEEN_CONST.ACTIVE; - } - } - else if (this.completeDelay > 0) - { - this.countdown = this.completeDelay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#pause - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - pause: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - return; + lower.push(vertex); } - this.paused = true; + // build upper hull + for (i = vertices.length - 1; i >= 0; i -= 1) { + vertex = vertices[i]; - this._pausedState = this.state; + while (upper.length >= 2 + && Vector.cross3(upper[upper.length - 2], upper[upper.length - 1], vertex) <= 0) { + upper.pop(); + } - this.state = TWEEN_CONST.PAUSED; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#play - * @since 3.0.0 - * - * @param {boolean} resetFromTimeline - [description] - */ - play: function (resetFromTimeline) - { - if (this.state === TWEEN_CONST.ACTIVE) - { - return; - } - else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) - { - this.init(); - this.parent.makeActive(this); - resetFromTimeline = true; + upper.push(vertex); } - var onStart = this.callbacks.onStart; + // concatenation of the lower and upper hulls gives the convex hull + // omit last points because they are repeated at the beginning of the other list + upper.pop(); + lower.pop(); - if (this.parentIsTimeline) - { - this.resetTweenData(resetFromTimeline); + return upper.concat(lower); + }; - if (this.calculatedOffset === 0) - { - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - else - { - this.countdown = this.calculatedOffset; - - this.state = TWEEN_CONST.OFFSET_DELAY; - } - } - else if (this.paused) - { - this.paused = false; - - this.parent.makeActive(this); - } - else - { - this.resetTweenData(resetFromTimeline); - - this.state = TWEEN_CONST.ACTIVE; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resetTweenData - * @since 3.0.0 - * - * @param {boolean} resetFromLoop - [description] - */ - resetTweenData: function (resetFromLoop) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - var tweenData = data[i]; - - tweenData.progress = 0; - tweenData.elapsed = 0; - - tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; - - if (resetFromLoop) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); - - tweenData.current = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else if (tweenData.delay > 0) - { - tweenData.elapsed = tweenData.delay; - tweenData.state = TWEEN_CONST.DELAY; - } - else - { - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#resume - * @since 3.0.0 - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - resume: function () - { - if (this.state === TWEEN_CONST.PAUSED) - { - this.paused = false; - - this.state = this._pausedState; - } - else - { - this.play(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#seek - * @since 3.0.0 - * - * @param {float} toPosition - A value between 0 and 1. - */ - seek: function (toPosition) - { - var data = this.data; - - for (var i = 0; i < this.totalData; i++) - { - // This won't work with loop > 0 yet - var ms = this.totalDuration * toPosition; - - var tweenData = data[i]; - var progress = 0; - var elapsed = 0; - - if (ms <= tweenData.delay) - { - progress = 0; - elapsed = 0; - } - else if (ms >= tweenData.totalDuration) - { - progress = 1; - elapsed = tweenData.duration; - } - else if (ms > tweenData.delay && ms <= tweenData.t1) - { - // Keep it zero bound - ms = Math.max(0, ms - tweenData.delay); - - // Somewhere in the first playthru range - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - else if (ms > tweenData.t1 && ms < tweenData.totalDuration) - { - // Somewhere in repeat land - ms -= tweenData.delay; - ms -= tweenData.t1; - - // var repeats = Math.floor(ms / tweenData.t2); - - // remainder - ms = ((ms / tweenData.t2) % 1) * tweenData.t2; - - if (ms > tweenData.repeatDelay) - { - progress = ms / tweenData.t1; - elapsed = tweenData.duration * progress; - } - } - - tweenData.progress = progress; - tweenData.elapsed = elapsed; - - var v = tweenData.ease(tweenData.progress); - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); - - // if (tweenData.current === 0) - // { - // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); - // } - - tweenData.target[tweenData.key] = tweenData.current; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setCallback - * @since 3.0.0 - * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] - * @param {object} [scope] - [description] - * - * @return {Phaser.Tweens.Tween} This Tween object. - */ - setCallback: function (type, callback, params, scope) - { - this.callbacks[type] = { func: callback, scope: scope, params: params }; - - return this; - }, - - /** - * Flags the Tween as being complete, whatever stage of progress it is at. - * - * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` - * argument is provided, in which case the Tween will delay for that period of time before calling the callback. - * - * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. - * - * @method Phaser.Tweens.Tween#complete - * @since 3.2.0 - * - * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. - */ - complete: function (delay) - { - if (delay === undefined) { delay = 0; } - - if (delay) - { - this.countdown = delay; - this.state = TWEEN_CONST.COMPLETE_DELAY; - } - else - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.params[1] = this.targets; - - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. - * - * @method Phaser.Tweens.Tween#stop - * @since 3.0.0 - * - * @param {float} [resetTo] - A value between 0 and 1. - */ - stop: function (resetTo) - { - if (this.state === TWEEN_CONST.ACTIVE) - { - if (resetTo !== undefined) - { - this.seek(resetTo); - } - } - - if (this.state !== TWEEN_CONST.REMOVED) - { - this.state = TWEEN_CONST.PENDING_REMOVE; - } - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#update - * @since 3.0.0 - * - * @param {number} timestamp - [description] - * @param {number} delta - [description] - * - * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. - */ - update: function (timestamp, delta) - { - if (this.state === TWEEN_CONST.PAUSED) - { - return false; - } - - if (this.useFrames) - { - delta = 1 * this.parent.timeScale; - } - - delta *= this.timeScale; - - this.elapsed += delta; - this.progress = Math.min(this.elapsed / this.duration, 1); - - this.totalElapsed += delta; - this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); - - switch (this.state) - { - case TWEEN_CONST.ACTIVE: - - var stillRunning = false; - - for (var i = 0; i < this.totalData; i++) - { - if (this.updateTweenData(this, this.data[i], delta)) - { - stillRunning = true; - } - } - - // Anything still running? If not, we're done - if (!stillRunning) - { - this.nextState(); - } - - break; - - case TWEEN_CONST.LOOP_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.OFFSET_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onStart = this.callbacks.onStart; - - if (onStart) - { - onStart.params[1] = this.targets; - - onStart.func.apply(onStart.scope, onStart.params); - } - - this.state = TWEEN_CONST.ACTIVE; - } - - break; - - case TWEEN_CONST.COMPLETE_DELAY: - - this.countdown -= delta; - - if (this.countdown <= 0) - { - var onComplete = this.callbacks.onComplete; - - if (onComplete) - { - onComplete.func.apply(onComplete.scope, onComplete.params); - } - - this.state = TWEEN_CONST.PENDING_REMOVE; - } - - break; - } - - return (this.state === TWEEN_CONST.PENDING_REMOVE); - }, - - /** - * [description] - * - * @method Phaser.Tweens.Tween#setStateFromEnd - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromEnd: function (tween, tweenData, diff) - { - if (tweenData.yoyo) - { - // We've hit the end of a Playing Forward TweenData and we have a yoyo - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. - // If you're tweening several properties it can fire for all of them, at once. - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onYoyo = tween.callbacks.onYoyo; - - if (onYoyo) - { - // Element 1 is reserved for the target of the yoyo (and needs setting here) - onYoyo.params[1] = tweenData.target; - - onYoyo.func.apply(onYoyo.scope, onYoyo.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - return TWEEN_CONST.PLAYING_BACKWARD; - } - else if (tweenData.repeatCounter > 0) - { - // We've hit the end of a Playing Forward TweenData and we have a Repeat. - // So we're going to go right back to the start to repeat it again. - - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - /** - * Was PLAYING_BACKWARD and has hit the start. - * - * @method Phaser.Tweens.Tween#setStateFromStart - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] - * @param {number} diff - [description] - * - * @return {integer} The state of this Tween. - */ - setStateFromStart: function (tween, tweenData, diff) - { - if (tweenData.repeatCounter > 0) - { - tweenData.repeatCounter--; - - // Account for any extra time we got from the previous frame - tweenData.elapsed = diff; - tweenData.progress = diff / tweenData.duration; - - if (tweenData.flipX) - { - tweenData.target.toggleFlipX(); - } - - if (tweenData.flipY) - { - tweenData.target.toggleFlipY(); - } - - var onRepeat = tween.callbacks.onRepeat; - - if (onRepeat) - { - // Element 1 is reserved for the target of the repeat (and needs setting here) - onRepeat.params[1] = tweenData.target; - - onRepeat.func.apply(onRepeat.scope, onRepeat.params); - } - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - // Delay? - if (tweenData.repeatDelay > 0) - { - tweenData.elapsed = tweenData.repeatDelay - diff; - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.current; - - return TWEEN_CONST.REPEAT_DELAY; - } - else - { - return TWEEN_CONST.PLAYING_FORWARD; - } - } - - return TWEEN_CONST.COMPLETE; - }, - - // - /** - * [description] - * - * @method Phaser.Tweens.Tween#updateTweenData - * @since 3.0.0 - * - * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] - * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true - * - * @return {boolean} [description] - */ - updateTweenData: function (tween, tweenData, delta) - { - switch (tweenData.state) - { - case TWEEN_CONST.PLAYING_FORWARD: - case TWEEN_CONST.PLAYING_BACKWARD: - - if (!tweenData.target) - { - tweenData.state = TWEEN_CONST.COMPLETE; - break; - } - - var elapsed = tweenData.elapsed; - var duration = tweenData.duration; - var diff = 0; - - elapsed += delta; - - if (elapsed > duration) - { - diff = elapsed - duration; - elapsed = duration; - } - - var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); - var progress = elapsed / duration; - - var v; - - if (forward) - { - v = tweenData.ease(progress); - } - else - { - v = tweenData.ease(1 - progress); - } - - tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); - - tweenData.target[tweenData.key] = tweenData.current; - - tweenData.elapsed = elapsed; - tweenData.progress = progress; - - var onUpdate = tween.callbacks.onUpdate; - - if (onUpdate) - { - onUpdate.params[1] = tweenData.target; - - onUpdate.func.apply(onUpdate.scope, onUpdate.params); - } - - if (progress === 1) - { - if (forward) - { - if (tweenData.hold > 0) - { - tweenData.elapsed = tweenData.hold - diff; - - tweenData.state = TWEEN_CONST.HOLD_DELAY; - } - else - { - tweenData.state = this.setStateFromEnd(tween, tweenData, diff); - } - } - else - { - tweenData.state = this.setStateFromStart(tween, tweenData, diff); - } - } - - break; - - case TWEEN_CONST.DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PENDING_RENDER; - } - - break; - - case TWEEN_CONST.REPEAT_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.elapsed = Math.abs(tweenData.elapsed); - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - - break; - - case TWEEN_CONST.HOLD_DELAY: - - tweenData.elapsed -= delta; - - if (tweenData.elapsed <= 0) - { - tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); - } - - break; - - case TWEEN_CONST.PENDING_RENDER: - - if (tweenData.target) - { - tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); - - tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); - - tweenData.current = tweenData.start; - - tweenData.target[tweenData.key] = tweenData.start; - - tweenData.state = TWEEN_CONST.PLAYING_FORWARD; - } - else - { - tweenData.state = TWEEN_CONST.COMPLETE; - } - - break; - } - - // Return TRUE if this TweenData still playing, otherwise return FALSE - return (tweenData.state !== TWEEN_CONST.COMPLETE); - } - -}); - -Tween.TYPES = [ - 'onComplete', - 'onLoop', - 'onRepeat', - 'onStart', - 'onUpdate', - 'onYoyo' -]; - -/** - * Creates a new Tween object. - * - * Note: This method will only be available Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectFactory.register('tween', function (config) -{ - return this.scene.sys.tweens.add(config); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - -/** - * Creates a new Tween object and returns it. - * - * Note: This method will only be available if Tweens have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#tween - * @since 3.0.0 - * - * @param {object} config - The Tween configuration. - * - * @return {Phaser.Tweens.Tween} The Tween that was created. - */ -GameObjectCreator.register('tween', function (config) -{ - return this.scene.sys.tweens.create(config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - -module.exports = Tween; +})(); /***/ }), -/* 100 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} Phaser.Tweens.TweenConfigDefaults - * - * @property {(object|object[])} targets - [description] - * @property {number} [delay=0] - [description] - * @property {number} [duration=1000] - [description] - * @property {string} [ease='Power0'] - [description] - * @property {array} [easeParams] - [description] - * @property {number} [hold=0] - [description] - * @property {number} [repeat=0] - [description] - * @property {number} [repeatDelay=0] - [description] - * @property {boolean} [yoyo=false] - [description] - * @property {boolean} [flipX=false] - [description] - * @property {boolean} [flipY=false] - [description] - */ - -var TWEEN_DEFAULTS = { - targets: null, - delay: 0, - duration: 1000, - ease: 'Power0', - easeParams: null, - hold: 0, - repeat: 0, - repeatDelay: 0, - yoyo: false, - flipX: false, - flipY: false -}; - -module.exports = TWEEN_DEFAULTS; - - -/***/ }), -/* 101 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function hasGetStart (def) -{ - return (!!def.getStart && typeof def.getStart === 'function'); -} - -function hasGetEnd (def) -{ - return (!!def.getEnd && typeof def.getEnd === 'function'); -} - -function hasGetters (def) -{ - return hasGetStart(def) || hasGetEnd(def); -} - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetValueOp - * @since 3.0.0 - * - * @param {string} key - [description] - * @param {*} propertyValue - [description] - * - * @return {function} [description] - */ -var GetValueOp = function (key, propertyValue) -{ - var callbacks; - - // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) - var getEnd = function (target, key, value) { return value; }; - - // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) - var getStart = function (target, key, value) { return value; }; - - var t = typeof(propertyValue); - - if (t === 'number') - { - // props: { - // x: 400, - // y: 300 - // } - - getEnd = function () - { - return propertyValue; - }; - } - else if (t === 'string') - { - // props: { - // x: '+=400', - // y: '-=300', - // z: '*=2', - // w: '/=2' - // } - - var op = propertyValue[0]; - var num = parseFloat(propertyValue.substr(2)); - - switch (op) - { - case '+': - getEnd = function (target, key, value) - { - return value + num; - }; - break; - - case '-': - getEnd = function (target, key, value) - { - return value - num; - }; - break; - - case '*': - getEnd = function (target, key, value) - { - return value * num; - }; - break; - - case '/': - getEnd = function (target, key, value) - { - return value / num; - }; - break; - - default: - getEnd = function () - { - return parseFloat(propertyValue); - }; - } - } - else if (t === 'function') - { - // The same as setting just the getEnd function and no getStart - - // props: { - // x: function (target, key, value) { return value + 50); }, - // } - - getEnd = propertyValue; - } - else if (t === 'object' && hasGetters(propertyValue)) - { - /* - x: { - // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. - getEnd: function (target, key, value) - { - return value; - }, - - // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. - getStart: function (target, key, value) - { - return value; - } - } - */ - - if (hasGetEnd(propertyValue)) - { - getEnd = propertyValue.getEnd; - } - - if (hasGetStart(propertyValue)) - { - getStart = propertyValue.getStart; - } - } - else if (propertyValue.hasOwnProperty('value')) - { - // Value may still be a string, function or a number - // props: { - // x: { value: 400, ... }, - // y: { value: 300, ... } - // } - - callbacks = GetValueOp(key, propertyValue.value); - } - - // If callback not set by the else if block above then set it here and return it - if (!callbacks) - { - callbacks = { - getEnd: getEnd, - getStart: getStart - }; - } - - return callbacks; -}; - -module.exports = GetValueOp; - - -/***/ }), -/* 102 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -/** - * [description] - * - * @function Phaser.Tweens.Builders.GetTargets - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {array} [description] - */ -var GetTargets = function (config) -{ - var targets = GetValue(config, 'targets', null); - - if (targets === null) - { - return targets; - } - - if (typeof targets === 'function') - { - targets = targets.call(); - } - - if (!Array.isArray(targets)) - { - targets = [ targets ]; - } - - return targets; -}; - -module.exports = GetTargets; - - -/***/ }), -/* 103 */ +/* 77 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -20680,7 +15182,7 @@ module.exports = GetTargets; */ var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * @classdesc @@ -20689,7 +15191,7 @@ var GetFastValue = __webpack_require__(1); * itself. * * @class MapData - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -20784,6 +15286,15 @@ var MapData = new Class({ */ this.orientation = GetFastValue(config, 'orientation', 'orthogonal'); + /** + * [description] + * + * @name Phaser.Tilemaps.MapData#renderOrder + * @type {string} + * @since 3.12.0 + */ + this.renderOrder = GetFastValue(config, 'renderOrder', 'right-down'); + /** * [description] * @@ -20872,7 +15383,7 @@ module.exports = MapData; /***/ }), -/* 104 */ +/* 78 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -20882,7 +15393,7 @@ module.exports = MapData; */ var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * @classdesc @@ -20891,7 +15402,7 @@ var GetFastValue = __webpack_require__(1); * to this data and use it to look up and perform operations on tiles. * * @class LayerData - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -21008,7 +15519,7 @@ var LayerData = new Class({ * [description] * * @name Phaser.Tilemaps.LayerData#alpha - * @type {float} + * @type {number} * @since 3.0.0 */ this.alpha = GetFastValue(config, 'alpha', 1); @@ -21092,7 +15603,7 @@ module.exports = LayerData; /***/ }), -/* 105 */ +/* 79 */ /***/ (function(module, exports) { /** @@ -21108,11 +15619,11 @@ module.exports = LayerData; * @private * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * - * @return {boolean} + * @return {boolean} `true` if the tile coordinates are within the bounds of the layer, otherwise `false`. */ var IsInLayerBounds = function (tileX, tileY, layer) { @@ -21123,7 +15634,133 @@ module.exports = IsInLayerBounds; /***/ }), -/* 106 */ +/* 80 */ +/***/ (function(module, exports) { + +/** +* The `Matter.Bounds` module contains methods for creating and manipulating axis-aligned bounding boxes (AABB). +* +* @class Bounds +*/ + +var Bounds = {}; + +module.exports = Bounds; + +(function() { + + /** + * Creates a new axis-aligned bounding box (AABB) for the given vertices. + * @method create + * @param {vertices} vertices + * @return {bounds} A new bounds object + */ + Bounds.create = function(vertices) { + var bounds = { + min: { x: 0, y: 0 }, + max: { x: 0, y: 0 } + }; + + if (vertices) + Bounds.update(bounds, vertices); + + return bounds; + }; + + /** + * Updates bounds using the given vertices and extends the bounds given a velocity. + * @method update + * @param {bounds} bounds + * @param {vertices} vertices + * @param {vector} velocity + */ + Bounds.update = function(bounds, vertices, velocity) { + bounds.min.x = Infinity; + bounds.max.x = -Infinity; + bounds.min.y = Infinity; + bounds.max.y = -Infinity; + + for (var i = 0; i < vertices.length; i++) { + var vertex = vertices[i]; + if (vertex.x > bounds.max.x) bounds.max.x = vertex.x; + if (vertex.x < bounds.min.x) bounds.min.x = vertex.x; + if (vertex.y > bounds.max.y) bounds.max.y = vertex.y; + if (vertex.y < bounds.min.y) bounds.min.y = vertex.y; + } + + if (velocity) { + if (velocity.x > 0) { + bounds.max.x += velocity.x; + } else { + bounds.min.x += velocity.x; + } + + if (velocity.y > 0) { + bounds.max.y += velocity.y; + } else { + bounds.min.y += velocity.y; + } + } + }; + + /** + * Returns true if the bounds contains the given point. + * @method contains + * @param {bounds} bounds + * @param {vector} point + * @return {boolean} True if the bounds contain the point, otherwise false + */ + Bounds.contains = function(bounds, point) { + return point.x >= bounds.min.x && point.x <= bounds.max.x + && point.y >= bounds.min.y && point.y <= bounds.max.y; + }; + + /** + * Returns true if the two bounds intersect. + * @method overlaps + * @param {bounds} boundsA + * @param {bounds} boundsB + * @return {boolean} True if the bounds overlap, otherwise false + */ + Bounds.overlaps = function(boundsA, boundsB) { + return (boundsA.min.x <= boundsB.max.x && boundsA.max.x >= boundsB.min.x + && boundsA.max.y >= boundsB.min.y && boundsA.min.y <= boundsB.max.y); + }; + + /** + * Translates the bounds by the given vector. + * @method translate + * @param {bounds} bounds + * @param {vector} vector + */ + Bounds.translate = function(bounds, vector) { + bounds.min.x += vector.x; + bounds.max.x += vector.x; + bounds.min.y += vector.y; + bounds.max.y += vector.y; + }; + + /** + * Shifts the bounds to the given position. + * @method shift + * @param {bounds} bounds + * @param {vector} position + */ + Bounds.shift = function(bounds, position) { + var deltaX = bounds.max.x - bounds.min.x, + deltaY = bounds.max.y - bounds.min.y; + + bounds.min.x = position.x; + bounds.max.x = position.x + deltaX; + bounds.min.y = position.y; + bounds.max.y = position.y + deltaY; + }; + +})(); + + +/***/ }), +/* 81 */ /***/ (function(module, exports) { /** @@ -21342,7 +15979,7 @@ module.exports = Vector; }; /** - * Returns the angle in radians between the two vectors relative to the x-axis. + * Returns the angle between the vector `vectorB - vectorA` and the x-axis in radians. * @method angle * @param {vector} vectorA * @param {vector} vectorB @@ -21367,7 +16004,7 @@ module.exports = Vector; })(); /***/ }), -/* 107 */ +/* 82 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -21376,46 +16013,234 @@ module.exports = Vector; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Extend = __webpack_require__(17); -var XHRSettings = __webpack_require__(75); +var Utils = __webpack_require__(10); /** - * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * Renders a filled path for the given Shape. * - * The new object is seeded by the values given in the global settings, but any setting in - * the local object overrides the global ones. + * @method Phaser.GameObjects.Shape#FillPathWebGL + * @since 3.13.0 + * @private * - * @function Phaser.Loader.MergeXHRSettings - * @since 3.0.0 - * - * @param {XHRSettingsObject} global - The global XHRSettings object. - * @param {XHRSettingsObject} local - The local XHRSettings object. - * - * @return {XHRSettingsObject} A newly formed XHRSettings object. + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The WebGL Pipeline used to render this Shape. + * @param {Phaser.GameObjects.Components.TransformMatrix} calcMatrix - The transform matrix used to get the position values. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. */ -var MergeXHRSettings = function (global, local) +var FillPathWebGL = function (pipeline, calcMatrix, src, alpha, dx, dy) { - var output = (global === undefined) ? XHRSettings() : Extend({}, global); + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); - if (local) + var path = src.pathData; + var pathIndexes = src.pathIndexes; + + for (var i = 0; i < pathIndexes.length; i += 3) { - for (var setting in local) - { - if (local[setting] !== undefined) - { - output[setting] = local[setting]; - } - } - } + var p0 = pathIndexes[i] * 2; + var p1 = pathIndexes[i + 1] * 2; + var p2 = pathIndexes[i + 2] * 2; - return output; + var x0 = path[p0 + 0] - dx; + var y0 = path[p0 + 1] - dy; + var x1 = path[p1 + 0] - dx; + var y1 = path[p1 + 1] - dy; + var x2 = path[p2 + 0] - dx; + var y2 = path[p2 + 1] - dy; + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + pipeline.setTexture2D(); + + pipeline.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, 0, 0, 1, 1, fillTintColor, fillTintColor, fillTintColor, pipeline.tintEffect); + } }; -module.exports = MergeXHRSettings; +module.exports = FillPathWebGL; /***/ }), -/* 108 */ +/* 83 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TWEEN_CONST = { + + /** + * TweenData state. + * + * @name Phaser.Tweens.CREATED + * @type {integer} + * @since 3.0.0 + */ + CREATED: 0, + + /** + * TweenData state. + * + * @name Phaser.Tweens.INIT + * @type {integer} + * @since 3.0.0 + */ + INIT: 1, + + /** + * TweenData state. + * + * @name Phaser.Tweens.DELAY + * @type {integer} + * @since 3.0.0 + */ + DELAY: 2, + + /** + * TweenData state. + * + * @name Phaser.Tweens.OFFSET_DELAY + * @type {integer} + * @since 3.0.0 + */ + OFFSET_DELAY: 3, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PENDING_RENDER + * @type {integer} + * @since 3.0.0 + */ + PENDING_RENDER: 4, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PLAYING_FORWARD + * @type {integer} + * @since 3.0.0 + */ + PLAYING_FORWARD: 5, + + /** + * TweenData state. + * + * @name Phaser.Tweens.PLAYING_BACKWARD + * @type {integer} + * @since 3.0.0 + */ + PLAYING_BACKWARD: 6, + + /** + * TweenData state. + * + * @name Phaser.Tweens.HOLD_DELAY + * @type {integer} + * @since 3.0.0 + */ + HOLD_DELAY: 7, + + /** + * TweenData state. + * + * @name Phaser.Tweens.REPEAT_DELAY + * @type {integer} + * @since 3.0.0 + */ + REPEAT_DELAY: 8, + + /** + * TweenData state. + * + * @name Phaser.Tweens.COMPLETE + * @type {integer} + * @since 3.0.0 + */ + COMPLETE: 9, + + // Tween specific (starts from 20 to cleanly allow extra TweenData consts in the future) + + /** + * Tween state. + * + * @name Phaser.Tweens.PENDING_ADD + * @type {integer} + * @since 3.0.0 + */ + PENDING_ADD: 20, + + /** + * Tween state. + * + * @name Phaser.Tweens.PAUSED + * @type {integer} + * @since 3.0.0 + */ + PAUSED: 21, + + /** + * Tween state. + * + * @name Phaser.Tweens.LOOP_DELAY + * @type {integer} + * @since 3.0.0 + */ + LOOP_DELAY: 22, + + /** + * Tween state. + * + * @name Phaser.Tweens.ACTIVE + * @type {integer} + * @since 3.0.0 + */ + ACTIVE: 23, + + /** + * Tween state. + * + * @name Phaser.Tweens.COMPLETE_DELAY + * @type {integer} + * @since 3.0.0 + */ + COMPLETE_DELAY: 24, + + /** + * Tween state. + * + * @name Phaser.Tweens.PENDING_REMOVE + * @type {integer} + * @since 3.0.0 + */ + PENDING_REMOVE: 25, + + /** + * Tween state. + * + * @name Phaser.Tweens.REMOVED + * @type {integer} + * @since 3.0.0 + */ + REMOVED: 26 + +}; + +module.exports = TWEEN_CONST; + + +/***/ }), +/* 84 */ /***/ (function(module, exports) { /** @@ -21425,1637 +16250,38 @@ module.exports = MergeXHRSettings; */ /** - * Given a File and a baseURL value this returns the URL the File will use to download from. + * Retrieves the value of the given key from an object. * - * @function Phaser.Loader.GetURL + * @function Phaser.Tweens.Builders.GetBoolean * @since 3.0.0 * - * @param {Phaser.Loader.File} file - The File object. - * @param {string} baseURL - A default base URL. + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The key to look for in the `source` object. + * @param {*} defaultValue - The default value to return if the `key` doesn't exist or if no `source` object is provided. * - * @return {string} The URL the File will use. + * @return {*} The retrieved value. */ -var GetURL = function (file, baseURL) +var GetBoolean = function (source, key, defaultValue) { - if (!file.url) + if (!source) { - return false; + return defaultValue; } - - if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) + else if (source.hasOwnProperty(key)) { - return file.url; + return source[key]; } else { - return baseURL + file.url; + return defaultValue; } }; -module.exports = GetURL; +module.exports = GetBoolean; /***/ }), -/* 109 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Keyboard Codes. - * - * @name Phaser.Input.Keyboard.KeyCodes - * @enum {integer} - * @memberOf Phaser.Input.Keyboard - * @readOnly - * @since 3.0.0 - */ - -var KeyCodes = { - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACKSPACE - */ - BACKSPACE: 8, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.TAB - */ - TAB: 9, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ENTER - */ - ENTER: 13, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SHIFT - */ - SHIFT: 16, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CTRL - */ - CTRL: 17, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ALT - */ - ALT: 18, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAUSE - */ - PAUSE: 19, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CAPS_LOCK - */ - CAPS_LOCK: 20, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ESC - */ - ESC: 27, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SPACE - */ - SPACE: 32, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAGE_UP - */ - PAGE_UP: 33, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PAGE_DOWN - */ - PAGE_DOWN: 34, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.END - */ - END: 35, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.HOME - */ - HOME: 36, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.LEFT - */ - LEFT: 37, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.UP - */ - UP: 38, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.RIGHT - */ - RIGHT: 39, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.DOWN - */ - DOWN: 40, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PRINT_SCREEN - */ - PRINT_SCREEN: 42, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.INSERT - */ - INSERT: 45, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.DELETE - */ - DELETE: 46, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ZERO - */ - ZERO: 48, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.ONE - */ - ONE: 49, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.TWO - */ - TWO: 50, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.THREE - */ - THREE: 51, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FOUR - */ - FOUR: 52, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FIVE - */ - FIVE: 53, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SIX - */ - SIX: 54, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SEVEN - */ - SEVEN: 55, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.EIGHT - */ - EIGHT: 56, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NINE - */ - NINE: 57, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ZERO - */ - NUMPAD_ZERO: 96, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ONE - */ - NUMPAD_ONE: 97, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_TWO - */ - NUMPAD_TWO: 98, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_THREE - */ - NUMPAD_THREE: 99, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FOUR - */ - NUMPAD_FOUR: 100, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FIVE - */ - NUMPAD_FIVE: 101, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SIX - */ - NUMPAD_SIX: 102, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SEVEN - */ - NUMPAD_SEVEN: 103, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_EIGHT - */ - NUMPAD_EIGHT: 104, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_NINE - */ - NUMPAD_NINE: 105, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.A - */ - A: 65, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.B - */ - B: 66, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.C - */ - C: 67, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.D - */ - D: 68, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.E - */ - E: 69, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F - */ - F: 70, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.G - */ - G: 71, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.H - */ - H: 72, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.I - */ - I: 73, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.J - */ - J: 74, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.K - */ - K: 75, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.L - */ - L: 76, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.M - */ - M: 77, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.N - */ - N: 78, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.O - */ - O: 79, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.P - */ - P: 80, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Q - */ - Q: 81, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.R - */ - R: 82, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.S - */ - S: 83, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.T - */ - T: 84, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.U - */ - U: 85, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.V - */ - V: 86, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.W - */ - W: 87, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.X - */ - X: 88, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Y - */ - Y: 89, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.Z - */ - Z: 90, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F1 - */ - F1: 112, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F2 - */ - F2: 113, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F3 - */ - F3: 114, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F4 - */ - F4: 115, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F5 - */ - F5: 116, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F6 - */ - F6: 117, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F7 - */ - F7: 118, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F8 - */ - F8: 119, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F9 - */ - F9: 120, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F10 - */ - F10: 121, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F11 - */ - F11: 122, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.F12 - */ - F12: 123, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON - */ - SEMICOLON: 186, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PLUS - */ - PLUS: 187, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.COMMA - */ - COMMA: 188, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.MINUS - */ - MINUS: 189, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.PERIOD - */ - PERIOD: 190, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.FORWARD_SLASH - */ - FORWARD_SLASH: 191, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACK_SLASH - */ - BACK_SLASH: 220, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.QUOTES - */ - QUOTES: 222, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.BACKTICK - */ - BACKTICK: 192, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.OPEN_BRACKET - */ - OPEN_BRACKET: 219, - - /** - * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET - */ - CLOSED_BRACKET: 221 - -}; - -module.exports = KeyCodes; - - -/***/ }), -/* 110 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var AddToDOM = __webpack_require__(130); -var CanvasPool = __webpack_require__(22); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var CONST = __webpack_require__(20); -var GameObject = __webpack_require__(2); -var GetTextSize = __webpack_require__(417); -var GetValue = __webpack_require__(4); -var RemoveFromDOM = __webpack_require__(269); -var TextRender = __webpack_require__(416); -var TextStyle = __webpack_require__(413); - -/** - * @classdesc - * [description] - * - * @class Text - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {(string|string[])} text - The text this Text object will display. - * @param {object} style - The text style configuration object. - */ -var Text = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Tint, - Components.Transform, - Components.Visible, - TextRender - ], - - initialize: - - function Text (scene, x, y, text, style) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - GameObject.call(this, scene, 'Text'); - - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * The canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = CanvasPool.create(this); - - /** - * The context of the canvas element that the text is rendered to. - * - * @name Phaser.GameObjects.Text#context - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.context = this.canvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#style - * @type {Phaser.GameObjects.Text.TextStyle} - * @since 3.0.0 - */ - this.style = new TextStyle(this, style); - - /** - * [description] - * - * @name Phaser.GameObjects.Text#autoRound - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.autoRound = true; - - /** - * The Regular Expression that is used to split the text up into lines, in - * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. - * You can change this RegExp to be anything else that you may need. - * - * @name Phaser.GameObjects.Text#splitRegExp - * @type {object} - * @since 3.0.0 - */ - this.splitRegExp = /(?:\r\n|\r|\n)/; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#resolution - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.resolution = 1; - - /** - * Specify a padding value which is added to the line width and height when calculating the Text size. - * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. - * - * @name Phaser.GameObjects.Text#padding - * @type {{left:number,right:number,top:number,bottom:number}} - * @since 3.0.0 - */ - this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#width - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.width = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#height - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.height = 1; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#canvasTexture - * @type {HTMLCanvasElement} - * @default null - * @since 3.0.0 - */ - this.canvasTexture = null; - - /** - * [description] - * - * @name Phaser.GameObjects.Text#dirty - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.dirty = false; - - this.initRTL(); - - if (style && style.padding) - { - this.setPadding(style.padding); - } - - if (style && style.lineSpacing) - { - this._lineSpacing = style.lineSpacing; - } - - this.setText(text); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function () - { - this.canvasTexture = null; - this.dirty = true; - }, this); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#initRTL - * @since 3.0.0 - */ - initRTL: function () - { - if (!this.style.rtl) - { - return; - } - - // Here is where the crazy starts. - // - // Due to browser implementation issues, you cannot fillText BiDi text to a canvas - // that is not part of the DOM. It just completely ignores the direction property. - - this.canvas.dir = 'rtl'; - - // Experimental atm, but one day ... - this.context.direction = 'rtl'; - - // Add it to the DOM, but hidden within the parent canvas. - this.canvas.style.display = 'none'; - - AddToDOM(this.canvas, this.scene.sys.canvas); - - // And finally we set the x origin - this.originX = 1; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. - * - * @method Phaser.GameObjects.Text#runWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * - * @return {string} The text after wrapping has been applied. - */ - runWordWrap: function (text) - { - var style = this.style; - - if (style.wordWrapCallback) - { - var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); - - if (Array.isArray(wrappedLines)) - { - wrappedLines = wrappedLines.join('\n'); - } - - return wrappedLines; - } - else if (style.wordWrapWidth) - { - if (style.wordWrapUseAdvanced) - { - return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); - } - else - { - return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); - } - } - else - { - return text; - } - }, - - /** - * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be - * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a - * single character. - * - * @method Phaser.GameObjects.Text#advancedWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - advancedWordWrap: function (text, context, wordWrapWidth) - { - var output = ''; - - // Condense consecutive spaces and split into lines - var lines = text - .replace(/ +/gi, ' ') - .split(this.splitRegExp); - - var linesCount = lines.length; - - for (var i = 0; i < linesCount; i++) - { - var line = lines[i]; - var out = ''; - - // Trim whitespace - line = line.replace(/^ *|\s*$/gi, ''); - - // If entire line is less than wordWrapWidth append the entire line and exit early - var lineWidth = context.measureText(line).width; - - if (lineWidth < wordWrapWidth) - { - output += line + '\n'; - continue; - } - - // Otherwise, calculate new lines - var currentLineWidth = wordWrapWidth; - - // Split into words - var words = line.split(' '); - - for (var j = 0; j < words.length; j++) - { - var word = words[j]; - var wordWithSpace = word + ' '; - var wordWidth = context.measureText(wordWithSpace).width; - - if (wordWidth > currentLineWidth) - { - // Break word - if (j === 0) - { - // Shave off letters from word until it's small enough - var newWord = wordWithSpace; - - while (newWord.length) - { - newWord = newWord.slice(0, -1); - wordWidth = context.measureText(newWord).width; - - if (wordWidth <= currentLineWidth) - { - break; - } - } - - // If wordWrapWidth is too small for even a single letter, shame user - // failure with a fatal error - if (!newWord.length) - { - throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); - } - - // Replace current word in array with remainder - var secondPart = word.substr(newWord.length); - - words[j] = secondPart; - - // Append first piece to output - out += newWord; - } - - // If existing word length is 0, don't include it - var offset = (words[j].length) ? j : j + 1; - - // Collapse rest of sentence and remove any trailing white space - var remainder = words.slice(offset).join(' ') - .replace(/[ \n]*$/gi, ''); - - // Prepend remainder to next line - lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); - linesCount = lines.length; - - break; // Processing on this line - - // Append word with space to output - } - else - { - out += wordWithSpace; - currentLineWidth -= wordWidth; - } - } - - // Append processed line to output - output += out.replace(/[ \n]*$/gi, '') + '\n'; - } - - // Trim the end of the string - output = output.replace(/[\s|\n]*$/gi, ''); - - return output; - }, - - /** - * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal - * bounds. Spaces are not collapsed and whitespace is not trimmed. - * - * @method Phaser.GameObjects.Text#basicWordWrap - * @since 3.0.0 - * - * @param {string} text - The text to perform word wrap detection against. - * @param {CanvasRenderingContext2D} context - [description] - * @param {number} wordWrapWidth - [description] - * - * @return {string} The wrapped text. - */ - basicWordWrap: function (text, context, wordWrapWidth) - { - var result = ''; - var lines = text.split(this.splitRegExp); - - for (var i = 0; i < lines.length; i++) - { - var spaceLeft = wordWrapWidth; - var words = lines[i].split(' '); - - for (var j = 0; j < words.length; j++) - { - var wordWidth = context.measureText(words[j]).width; - var wordWidthWithSpace = wordWidth + context.measureText(' ').width; - - if (wordWidthWithSpace > spaceLeft) - { - // Skip printing the newline if it's the first word of the line that is greater - // than the word wrap width. - if (j > 0) - { - result += '\n'; - } - - result += words[j] + ' '; - spaceLeft = wordWrapWidth - wordWidth; - } - else - { - spaceLeft -= wordWidthWithSpace; - result += words[j]; - - if (j < (words.length - 1)) - { - result += ' '; - } - } - } - - if (i < lines.length - 1) - { - result += '\n'; - } - } - - return result; - }, - - /** - * Runs the given text through this Text objects word wrapping and returns the results as an - * array, where each element of the array corresponds to a wrapped line of text. - * - * @method Phaser.GameObjects.Text#getWrappedText - * @since 3.0.0 - * - * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. - * - * @return {string[]} An array of strings with the pieces of wrapped text. - */ - getWrappedText: function (text) - { - if (text === undefined) { text = this.text; } - - this.style.syncFont(this.canvas, this.context); - - var wrappedLines = this.runWordWrap(text); - - return wrappedLines.split(this.splitRegExp); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setText - * @since 3.0.0 - * - * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this Text object. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateText(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStyle - * @since 3.0.0 - * - * @param {object} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStyle: function (style) - { - return this.style.setStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFont - * @since 3.0.0 - * - * @param {string} font - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFont: function (font) - { - return this.style.setFont(font); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontFamily - * @since 3.0.0 - * - * @param {string} family - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontFamily: function (family) - { - return this.style.setFontFamily(family); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontSize - * @since 3.0.0 - * - * @param {number} size - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontSize: function (size) - { - return this.style.setFontSize(size); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFontStyle - * @since 3.0.0 - * - * @param {string} style - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFontStyle: function (style) - { - return this.style.setFontStyle(style); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFixedSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFixedSize: function (width, height) - { - return this.style.setFixedSize(width, height); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setBackgroundColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setBackgroundColor: function (color) - { - return this.style.setBackgroundColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setFill - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setFill: function (color) - { - return this.style.setFill(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setColor: function (color) - { - return this.style.setColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setStroke - * @since 3.0.0 - * - * @param {string} color - [description] - * @param {number} thickness - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setStroke: function (color, thickness) - { - return this.style.setStroke(color, thickness); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadow - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {string} color - [description] - * @param {number} blur - [description] - * @param {boolean} shadowStroke - [description] - * @param {boolean} shadowFill - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadow: function (x, y, color, blur, shadowStroke, shadowFill) - { - return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowOffset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowOffset: function (x, y) - { - return this.style.setShadowOffset(x, y); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowColor - * @since 3.0.0 - * - * @param {string} color - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowColor: function (color) - { - return this.style.setShadowColor(color); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowBlur - * @since 3.0.0 - * - * @param {number} blur - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowBlur: function (blur) - { - return this.style.setShadowBlur(blur); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowStroke - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowStroke: function (enabled) - { - return this.style.setShadowStroke(enabled); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setShadowFill - * @since 3.0.0 - * - * @param {boolean} enabled - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setShadowFill: function (enabled) - { - return this.style.setShadowFill(enabled); - }, - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * - * @method Phaser.GameObjects.Text#setWordWrapWidth - * @since 3.0.0 - * - * @param {?number} width - The maximum width of a line in pixels. Set to null to remove wrapping. - * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapWidth: function (width, useAdvancedWrap) - { - return this.style.setWordWrapWidth(width, useAdvancedWrap); - }, - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * - * @method Phaser.GameObjects.Text#setWordWrapCallback - * @since 3.0.0 - * - * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setWordWrapCallback: function (callback, scope) - { - return this.style.setWordWrapCallback(callback, scope); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setAlign - * @since 3.0.0 - * - * @param {string} align - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setAlign: function (align) - { - return this.style.setAlign(align); - }, - - /** - * 'left' can be an object. - * If only 'left' and 'top' are given they are treated as 'x' and 'y' - * - * @method Phaser.GameObjects.Text#setPadding - * @since 3.0.0 - * - * @param {(number|object)} left - [description] - * @param {number} top - [description] - * @param {number} right - [description] - * @param {number} bottom - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setPadding: function (left, top, right, bottom) - { - if (typeof left === 'object') - { - var config = left; - - // If they specify x and/or y this applies to all - var x = GetValue(config, 'x', null); - - if (x !== null) - { - left = x; - right = x; - } - else - { - left = GetValue(config, 'left', 0); - right = GetValue(config, 'right', left); - } - - var y = GetValue(config, 'y', null); - - if (y !== null) - { - top = y; - bottom = y; - } - else - { - top = GetValue(config, 'top', 0); - bottom = GetValue(config, 'bottom', top); - } - } - else - { - if (left === undefined) { left = 0; } - if (top === undefined) { top = left; } - if (right === undefined) { right = left; } - if (bottom === undefined) { bottom = top; } - } - - this.padding.left = left; - this.padding.top = top; - this.padding.right = right; - this.padding.bottom = bottom; - - return this.updateText(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#setMaxLines - * @since 3.0.0 - * - * @param {integer} [max=0] - [description] - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - setMaxLines: function (max) - { - return this.style.setMaxLines(max); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#updateText - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Text} This Text object. - */ - updateText: function () - { - var canvas = this.canvas; - var context = this.context; - var style = this.style; - var resolution = this.resolution; - var size = style.metrics; - - style.syncFont(canvas, context); - - var outputText = this.text; - - if (style.wordWrapWidth || style.wordWrapCallback) - { - outputText = this.runWordWrap(this.text); - } - - // Split text into lines - var lines = outputText.split(this.splitRegExp); - - var textSize = GetTextSize(this, size, lines); - - var padding = this.padding; - - var w = textSize.width + padding.left + padding.right; - var h = textSize.height + padding.top + padding.bottom; - - if (style.fixedWidth === 0) - { - this.width = w; - } - - if (style.fixedHeight === 0) - { - this.height = h; - } - - this.updateDisplayOrigin(); - - w *= resolution; - h *= resolution; - - w = Math.max(w, 1); - h = Math.max(h, 1); - - if (canvas.width !== w || canvas.height !== h) - { - canvas.width = w; - canvas.height = h; - style.syncFont(canvas, context); // Resizing resets the context - } - else - { - context.clearRect(0, 0, w, h); - } - - context.save(); - - // context.scale(resolution, resolution); - - if (style.backgroundColor) - { - context.fillStyle = style.backgroundColor; - context.fillRect(0, 0, w, h); - } - - style.syncStyle(canvas, context); - - context.textBaseline = 'alphabetic'; - - // Apply padding - context.translate(padding.left, padding.top); - - var linePositionX; - var linePositionY; - - // Draw text line by line - for (var i = 0; i < textSize.lines; i++) - { - linePositionX = style.strokeThickness / 2; - linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; - - if (i > 0) - { - linePositionY += (textSize.lineSpacing * i); - } - - if (style.rtl) - { - linePositionX = w - linePositionX; - } - else if (style.align === 'right') - { - linePositionX += textSize.width - textSize.lineWidths[i]; - } - else if (style.align === 'center') - { - linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; - } - - if (this.autoRound) - { - linePositionX = Math.round(linePositionX); - linePositionY = Math.round(linePositionY); - } - - if (style.strokeThickness) - { - this.style.syncShadow(context, style.shadowStroke); - - context.strokeText(lines[i], linePositionX, linePositionY); - } - - if (style.color) - { - this.style.syncShadow(context, style.shadowFill); - - context.fillText(lines[i], linePositionX, linePositionY); - } - } - - context.restore(); - - this.dirty = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#getTextMetrics - * @since 3.0.0 - * - * @return {object} [description] - */ - getTextMetrics: function () - { - return this.style.getTextMetrics(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Text#toJSON - * @since 3.0.0 - * - * @return {JSONGameObject} A JSON representation of the Game Object. - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra Text data is added here - - var data = { - autoRound: this.autoRound, - text: this.text, - style: this.style.toJSON(), - resolution: this.resolution, - padding: { - left: this.padding.left, - right: this.padding.right, - top: this.padding.top, - bottom: this.padding.bottom - } - }; - - out.data = data; - - return out; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.Text#preDestroy - * @protected - * @since 3.0.0 - */ - preDestroy: function () - { - if (this.style.rtl) - { - RemoveFromDOM(this.canvas); - } - - CanvasPool.remove(this.canvas); - } - -}); - -module.exports = Text; - - -/***/ }), -/* 111 */ +/* 85 */ /***/ (function(module, exports) { /** @@ -23067,7 +16293,7 @@ module.exports = Text; /** * [description] * - * @function Phaser.Utils.Object.HasValue + * @function Phaser.Utils.Objects.HasValue * @since 3.0.0 * * @param {object} source - [description] @@ -23084,7 +16310,69 @@ module.exports = HasValue; /***/ }), -/* 112 */ +/* 86 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var EaseMap = __webpack_require__(174); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetEaseFunction + * @since 3.0.0 + * + * @param {(string|function)} ease - [description] + * @param {array} easeParams - [description] + * + * @return {function} [description] + */ +var GetEaseFunction = function (ease, easeParams) +{ + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + if (easeParams) + { + var cloneParams = easeParams.slice(0); + + cloneParams.unshift(0); + + return function (v) + { + cloneParams[0] = v; + + return EaseMap[ease].apply(this, cloneParams); + }; + } + else + { + // String based look-up + return EaseMap[ease]; + } + } + else if (typeof ease === 'function') + { + // Custom function + return ease; + } + else if (Array.isArray(ease) && ease.length === 4) + { + // Bezier function (TODO) + } + + return EaseMap.Power0; +}; + +module.exports = GetEaseFunction; + + +/***/ }), +/* 87 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -23093,13 +16381,117 @@ module.exports = HasValue; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Actions = __webpack_require__(599); var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var ImageRender = __webpack_require__(826); + +/** + * @classdesc + * An Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Image = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.TextureCrop, + Components.Tint, + Components.Transform, + Components.Visible, + ImageRender + ], + + initialize: + + function Image (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Image'); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Image#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initPipeline(); + } + +}); + +module.exports = Image; + + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Actions = __webpack_require__(417); +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); -var Range = __webpack_require__(254); -var Set = __webpack_require__(70); -var Sprite = __webpack_require__(34); +var IsPlainObject = __webpack_require__(8); +var Range = __webpack_require__(312); +var Set = __webpack_require__(95); +var Sprite = __webpack_require__(61); /** * @callback GroupCallback @@ -23189,11 +16581,11 @@ var Sprite = __webpack_require__(34); * Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden. * * @class Group - * @memberOf Phaser.GameObjects + * @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 {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [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. * * @see Phaser.Physics.Arcade.Group @@ -23205,8 +16597,38 @@ var Group = new Class({ function Group (scene, children, config) { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') + // They can pass in any of the following as the first argument: + + // 1) A single child + // 2) An array of children + // 3) A config object + // 4) An array of config objects + + // Or they can pass in a child, or array of children AND a config object + + if (config) { + // config has been set, are the children an array? + + if (children && !Array.isArray(children)) + { + children = [ children ]; + } + } + else if (Array.isArray(children)) + { + // No config, so let's check the children argument + + if (IsPlainObject(children[0])) + { + // It's an array of plain config objects + config = children; + children = null; + } + } + else if (IsPlainObject(children)) + { + // Children isn't an array. Is it a config object though? config = children; children = null; } @@ -23409,18 +16831,16 @@ var Group = new Class({ config = [ config ]; } - if (config[0].key === undefined) - { - return []; - } - var output = []; - for (var i = 0; i < config.length; i++) + if (config[0].key) { - var entries = this.createFromConfig(config[i]); - - output = output.concat(entries); + for (var i = 0; i < config.length; i++) + { + var entries = this.createFromConfig(config[i]); + + output = output.concat(entries); + } } return output; @@ -24277,8 +17697,8 @@ module.exports = Group; /***/ }), -/* 113 */ -/***/ (function(module, exports, __webpack_require__) { +/* 89 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -24286,40 +17706,40 @@ module.exports = Group; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - /** - * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * Check to see if the Ellipse contains the given x / y coordinates. * - * @function Phaser.Geom.Ellipse.CircumferencePoint + * @function Phaser.Geom.Ellipse.Contains * @since 3.0.0 * - * @generic {Phaser.Geom.Point} O - [out,$return] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {number} x - The x coordinate to check within the ellipse. + * @param {number} y - The y coordinate to check within the ellipse. * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. - * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + * @return {boolean} True if the coordinates are within the ellipse, otherwise false. */ -var CircumferencePoint = function (ellipse, angle, out) +var Contains = function (ellipse, x, y) { - if (out === undefined) { out = new Point(); } + if (ellipse.width <= 0 || ellipse.height <= 0) + { + return false; + } - var halfWidth = ellipse.width / 2; - var halfHeight = ellipse.height / 2; + // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 + var normx = ((x - ellipse.x) / ellipse.width); + var normy = ((y - ellipse.y) / ellipse.height); - out.x = ellipse.x + halfWidth * Math.cos(angle); - out.y = ellipse.y + halfHeight * Math.sin(angle); + normx *= normx; + normy *= normy; - return out; + return (normx + normy < 0.25); }; -module.exports = CircumferencePoint; +module.exports = Contains; /***/ }), -/* 114 */ +/* 90 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -24329,10 +17749,10 @@ module.exports = CircumferencePoint; */ var Class = __webpack_require__(0); -var Contains = __webpack_require__(54); -var GetPoint = __webpack_require__(179); -var GetPoints = __webpack_require__(178); -var Random = __webpack_require__(134); +var Contains = __webpack_require__(89); +var GetPoint = __webpack_require__(308); +var GetPoints = __webpack_require__(307); +var Random = __webpack_require__(185); /** * @classdesc @@ -24343,7 +17763,7 @@ var Random = __webpack_require__(134); * To render an Ellipse you should look at the capabilities of the Graphics class. * * @class Ellipse - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * @@ -24430,7 +17850,7 @@ var Ellipse = new Class({ * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. @@ -24687,7 +18107,323 @@ module.exports = Ellipse; /***/ }), -/* 115 */ +/* 91 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Removes a single item from an array and returns it without creating gc, like the native splice does. + * Based on code by Mike Reinstein. + * + * @function Phaser.Utils.Array.SpliceOne + * @since 3.0.0 + * + * @param {array} array - [description] + * @param {integer} index - [description] + * + * @return {*} [description] + */ +var SpliceOne = function (array, index) +{ + if (index >= array.length) + { + return; + } + + var len = array.length - 1; + + var item = array[index]; + + for (var i = index; i < len; i++) + { + array[i] = array[i + 1]; + } + + array.length = len; + + return item; +}; + +module.exports = SpliceOne; + + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(process) {/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines the operating system of the device running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.os` from within any Scene. + * + * @typedef {object} Phaser.Device.OS + * @since 3.0.0 + * + * @property {boolean} android - Is running on android? + * @property {boolean} chromeOS - Is running on chromeOS? + * @property {boolean} cocoonJS - Is the game running under CocoonJS? + * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? + * @property {boolean} cordova - Is the game running under Apache Cordova? + * @property {boolean} crosswalk - Is the game running under the Intel Crosswalk XDK? + * @property {boolean} desktop - Is running on a desktop? + * @property {boolean} ejecta - Is the game running under Ejecta? + * @property {boolean} electron - Is the game running under GitHub Electron? + * @property {boolean} iOS - Is running on iOS? + * @property {boolean} iPad - Is running on iPad? + * @property {boolean} iPhone - Is running on iPhone? + * @property {boolean} kindle - Is running on an Amazon Kindle? + * @property {boolean} linux - Is running on linux? + * @property {boolean} macOS - Is running on macOS? + * @property {boolean} node - Is the game running under Node.js? + * @property {boolean} nodeWebkit - Is the game running under Node-Webkit? + * @property {boolean} webApp - Set to true if running as a WebApp, i.e. within a WebView + * @property {boolean} windows - Is running on windows? + * @property {boolean} windowsPhone - Is running on a Windows Phone? + * @property {number} iOSVersion - If running in iOS this will contain the major version number. + * @property {number} pixelRatio - PixelRatio of the host device? + */ +var OS = { + + android: false, + chromeOS: false, + cocoonJS: false, + cocoonJSApp: false, + cordova: false, + crosswalk: false, + desktop: false, + ejecta: false, + electron: false, + iOS: false, + iOSVersion: 0, + iPad: false, + iPhone: false, + kindle: false, + linux: false, + macOS: false, + node: false, + nodeWebkit: false, + pixelRatio: 1, + webApp: false, + windows: false, + windowsPhone: false + +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Windows/.test(ua)) + { + OS.windows = true; + } + else if (/Mac OS/.test(ua) && !(/like Mac OS/.test(ua))) + { + OS.macOS = true; + } + else if (/Android/.test(ua)) + { + OS.android = true; + } + else if (/Linux/.test(ua)) + { + OS.linux = true; + } + else if (/iP[ao]d|iPhone/i.test(ua)) + { + OS.iOS = true; + + (navigator.appVersion).match(/OS (\d+)/); + + OS.iOSVersion = parseInt(RegExp.$1, 10); + + OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; + OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; + } + else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) + { + OS.kindle = true; + + // This will NOT detect early generations of Kindle Fire, I think there is no reliable way... + // E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true" + } + else if (/CrOS/.test(ua)) + { + OS.chromeOS = true; + } + + if (/Windows Phone/i.test(ua) || (/IEMobile/i).test(ua)) + { + OS.android = false; + OS.iOS = false; + OS.macOS = false; + OS.windows = true; + OS.windowsPhone = true; + } + + var silk = (/Silk/).test(ua); + + if (OS.windows || OS.macOS || (OS.linux && !silk) || OS.chromeOS) + { + OS.desktop = true; + } + + // Windows Phone / Table reset + if (OS.windowsPhone || ((/Windows NT/i.test(ua)) && (/Touch/i.test(ua)))) + { + OS.desktop = false; + } + + // WebApp mode in iOS + if (navigator.standalone) + { + OS.webApp = true; + } + + if (window.cordova !== undefined) + { + OS.cordova = true; + } + + if (typeof process !== 'undefined' && process.versions && process.versions.node) + { + OS.node = true; + } + + if (OS.node && typeof process.versions === 'object') + { + OS.nodeWebkit = !!process.versions['node-webkit']; + + OS.electron = !!process.versions.electron; + } + + if (navigator.isCocoonJS) + { + OS.cocoonJS = true; + + try + { + OS.cocoonJSApp = (typeof CocoonJS !== 'undefined'); + } + catch (error) + { + OS.cocoonJSApp = false; + } + } + + if (window.ejecta !== undefined) + { + OS.ejecta = true; + } + + if ((/Crosswalk/).test(ua)) + { + OS.crosswalk = true; + } + + OS.pixelRatio = window['devicePixelRatio'] || 1; + + return OS; +} + +module.exports = init(); + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(907))) + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); + +/** + * Return a value based on the range between `min` and `max` and the percentage given. + * + * @function Phaser.Math.FromPercent + * @since 3.0.0 + * + * @param {number} percent - A value between 0 and 1 representing the percentage. + * @param {number} min - The minimum value. + * @param {number} [max] - The maximum value. + * + * @return {number} The value that is `percent` percent between `min` and `max`. + */ +var FromPercent = function (percent, min, max) +{ + percent = Clamp(percent, 0, 1); + + return (max - min) * percent; +}; + +module.exports = FromPercent; + + +/***/ }), +/* 94 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser Scale Modes. + * + * @name Phaser.ScaleModes + * @enum {integer} + * @memberof Phaser + * @readonly + * @since 3.0.0 + */ + +module.exports = { + + /** + * Default Scale Mode (Linear). + * + * @name Phaser.ScaleModes.DEFAULT + */ + DEFAULT: 0, + + /** + * Linear Scale Mode. + * + * @name Phaser.ScaleModes.LINEAR + */ + LINEAR: 0, + + /** + * Nearest Scale Mode. + * + * @name Phaser.ScaleModes.NEAREST + */ + NEAREST: 1 + +}; + + +/***/ }), +/* 95 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -24696,24 +18432,18057 @@ module.exports = Ellipse; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Camera = __webpack_require__(123); var Class = __webpack_require__(0); -var Commands = __webpack_require__(119); -var Components = __webpack_require__(15); -var Ellipse = __webpack_require__(249); -var GameObject = __webpack_require__(2); + +/** + * @callback EachSetCallback + * @generic E - [entry] + * + * @param {*} entry - [description] + * @param {number} index - [description] + * + * @return {?boolean} [description] + */ + +/** + * @classdesc + * A Set is a collection of unique elements. + * + * @class Set + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + * @genericUse {T[]} - [elements] + * + * @param {Array.<*>} [elements] - An optional array of elements to insert into this Set. + */ +var Set = new Class({ + + initialize: + + function Set (elements) + { + /** + * The entries of this Set. Stored internally as an array. + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.Set#entries + * @type {Array.<*>} + * @default [] + * @since 3.0.0 + */ + this.entries = []; + + if (Array.isArray(elements)) + { + for (var i = 0; i < elements.length; i++) + { + this.set(elements[i]); + } + } + }, + + /** + * Inserts the provided value into this Set. If the value is already contained in this Set this method will have no effect. + * + * @method Phaser.Structs.Set#set + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {*} value - The value to insert into this Set. + * + * @return {Phaser.Structs.Set} This Set object. + */ + set: function (value) + { + if (this.entries.indexOf(value) === -1) + { + this.entries.push(value); + } + + return this; + }, + + /** + * Get an element of this Set which has a property of the specified name, if that property is equal to the specified value. + * If no elements of this Set satisfy the condition then this method will return `null`. + * + * @method Phaser.Structs.Set#get + * @since 3.0.0 + * + * @genericUse {T} - [value,$return] + * + * @param {string} property - The property name to check on the elements of this Set. + * @param {*} value - The value to check for. + * + * @return {*} The first element of this Set that meets the required condition, or `null` if this Set contains no elements that meet the condition. + */ + get: function (property, value) + { + for (var i = 0; i < this.entries.length; i++) + { + var entry = this.entries[i]; + + if (entry[property] === value) + { + return entry; + } + } + }, + + /** + * Returns an array containing all the values in this Set. + * + * @method Phaser.Structs.Set#getArray + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} An array containing all the values in this Set. + */ + getArray: function () + { + return this.entries.slice(0); + }, + + /** + * Removes the given value from this Set if this Set contains that value. + * + * @method Phaser.Structs.Set#delete + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {*} value - The value to remove from the Set. + * + * @return {Phaser.Structs.Set} This Set object. + */ + delete: function (value) + { + var index = this.entries.indexOf(value); + + if (index > -1) + { + this.entries.splice(index, 1); + } + + return this; + }, + + /** + * Dumps the contents of this Set to the console via `console.group`. + * + * @method Phaser.Structs.Set#dump + * @since 3.0.0 + */ + dump: function () + { + // eslint-disable-next-line no-console + console.group('Set'); + + for (var i = 0; i < this.entries.length; i++) + { + var entry = this.entries[i]; + console.log(entry); + } + + // eslint-disable-next-line no-console + console.groupEnd(); + }, + + /** + * Passes each value in this Set to the given callback. + * Use this function when you know this Set will be modified during the iteration, otherwise use `iterate`. + * + * @method Phaser.Structs.Set#each + * @since 3.0.0 + * + * @genericUse {EachSetCallback.} - [callback] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {EachSetCallback} callback - The callback to be invoked and passed each value this Set contains. + * @param {*} callbackScope - The scope of the callback. + * + * @return {Phaser.Structs.Set} This Set object. + */ + each: function (callback, callbackScope) + { + var i; + var temp = this.entries.slice(); + var len = temp.length; + + if (callbackScope) + { + for (i = 0; i < len; i++) + { + if (callback.call(callbackScope, temp[i], i) === false) + { + break; + } + } + } + else + { + for (i = 0; i < len; i++) + { + if (callback(temp[i], i) === false) + { + break; + } + } + } + + return this; + }, + + /** + * Passes each value in this Set to the given callback. + * For when you absolutely know this Set won't be modified during the iteration. + * + * @method Phaser.Structs.Set#iterate + * @since 3.0.0 + * + * @genericUse {EachSetCallback.} - [callback] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {EachSetCallback} callback - The callback to be invoked and passed each value this Set contains. + * @param {*} callbackScope - The scope of the callback. + * + * @return {Phaser.Structs.Set} This Set object. + */ + iterate: function (callback, callbackScope) + { + var i; + var len = this.entries.length; + + if (callbackScope) + { + for (i = 0; i < len; i++) + { + if (callback.call(callbackScope, this.entries[i], i) === false) + { + break; + } + } + } + else + { + for (i = 0; i < len; i++) + { + if (callback(this.entries[i], i) === false) + { + break; + } + } + } + + return this; + }, + + /** + * Goes through each entry in this Set and invokes the given function on them, passing in the arguments. + * + * @method Phaser.Structs.Set#iterateLocal + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {string} callbackKey - The key of the function to be invoked on each Set entry. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.Structs.Set} This Set object. + */ + iterateLocal: function (callbackKey) + { + var i; + var args = []; + + for (i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + var len = this.entries.length; + + for (i = 0; i < len; i++) + { + var entry = this.entries[i]; + + entry[callbackKey].apply(entry, args); + } + + return this; + }, + + /** + * Clears this Set so that it no longer contains any values. + * + * @method Phaser.Structs.Set#clear + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @return {Phaser.Structs.Set} This Set object. + */ + clear: function () + { + this.entries.length = 0; + + return this; + }, + + /** + * Returns `true` if this Set contains the given value, otherwise returns `false`. + * + * @method Phaser.Structs.Set#contains + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {*} value - The value to check for in this Set. + * + * @return {boolean} `true` if the given value was found in this Set, otherwise `false`. + */ + contains: function (value) + { + return (this.entries.indexOf(value) > -1); + }, + + /** + * Returns a new Set containing all values that are either in this Set or in the Set provided as an argument. + * + * @method Phaser.Structs.Set#union + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - The Set to perform the union with. + * + * @return {Phaser.Structs.Set} A new Set containing all the values in this Set and the Set provided as an argument. + */ + union: function (set) + { + var newSet = new Set(); + + set.entries.forEach(function (value) + { + newSet.set(value); + }); + + this.entries.forEach(function (value) + { + newSet.set(value); + }); + + return newSet; + }, + + /** + * Returns a new Set that contains only the values which are in this Set and that are also in the given Set. + * + * @method Phaser.Structs.Set#intersect + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - The Set to intersect this set with. + * + * @return {Phaser.Structs.Set} The result of the intersection, as a new Set. + */ + intersect: function (set) + { + var newSet = new Set(); + + this.entries.forEach(function (value) + { + if (set.contains(value)) + { + newSet.set(value); + } + }); + + return newSet; + }, + + /** + * Returns a new Set containing all the values in this Set which are *not* also in the given Set. + * + * @method Phaser.Structs.Set#difference + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - The Set to perform the difference with. + * + * @return {Phaser.Structs.Set} A new Set containing all the values in this Set that are not also in the Set provided as an argument to this method. + */ + difference: function (set) + { + var newSet = new Set(); + + this.entries.forEach(function (value) + { + if (!set.contains(value)) + { + newSet.set(value); + } + }); + + return newSet; + }, + + /** + * The size of this Set. This is the number of entries within it. + * Changing the size will truncate the Set if the given value is smaller than the current size. + * Increasing the size larger than the current size has no effect. + * + * @name Phaser.Structs.Set#size + * @type {integer} + * @since 3.0.0 + */ + size: { + + get: function () + { + return this.entries.length; + }, + + set: function (value) + { + if (value < this.entries.length) + { + return this.entries.length = value; + } + else + { + return this.entries.length; + } + } + + } + +}); + +module.exports = Set; + + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(63); + +/** + * Creates a new Object using all values from obj1 and obj2. + * If a value exists in both obj1 and obj2, the value in obj1 is used. + * + * @function Phaser.Utils.Objects.Merge + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var Merge = function (obj1, obj2) +{ + var clone = Clone(obj1); + + for (var key in obj2) + { + if (!clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } + + return clone; +}; + +module.exports = Merge; + + +/***/ }), +/* 97 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Defaults = __webpack_require__(129); +var GetAdvancedValue = __webpack_require__(12); +var GetBoolean = __webpack_require__(84); +var GetEaseFunction = __webpack_require__(86); +var GetNewValue = __webpack_require__(98); +var GetProps = __webpack_require__(205); +var GetTargets = __webpack_require__(131); +var GetValue = __webpack_require__(4); +var GetValueOp = __webpack_require__(130); +var Tween = __webpack_require__(128); +var TweenData = __webpack_require__(127); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.TweenBuilder + * @since 3.0.0 + * + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {object} config - [description] + * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] + * + * @return {Phaser.Tweens.Tween} [description] + */ +var TweenBuilder = function (parent, config, defaults) +{ + if (defaults === undefined) + { + defaults = Defaults; + } + + // Create arrays of the Targets and the Properties + var targets = (defaults.targets) ? defaults.targets : GetTargets(config); + + // var props = (defaults.props) ? defaults.props : GetProps(config); + var props = GetProps(config); + + // Default Tween values + var delay = GetNewValue(config, 'delay', defaults.delay); + var duration = GetNewValue(config, 'duration', defaults.duration); + var easeParams = GetValue(config, 'easeParams', defaults.easeParams); + var ease = GetEaseFunction(GetValue(config, 'ease', defaults.ease), easeParams); + var hold = GetNewValue(config, 'hold', defaults.hold); + var repeat = GetNewValue(config, 'repeat', defaults.repeat); + var repeatDelay = GetNewValue(config, 'repeatDelay', defaults.repeatDelay); + var yoyo = GetBoolean(config, 'yoyo', defaults.yoyo); + var flipX = GetBoolean(config, 'flipX', defaults.flipX); + var flipY = GetBoolean(config, 'flipY', defaults.flipY); + + var data = []; + + // Loop through every property defined in the Tween, i.e.: props { x, y, alpha } + for (var p = 0; p < props.length; p++) + { + var key = props[p].key; + var value = props[p].value; + + // Create 1 TweenData per target, per property + for (var t = 0; t < targets.length; t++) + { + var ops = GetValueOp(key, value); + + var tweenData = TweenData( + targets[t], + key, + ops.getEnd, + ops.getStart, + GetEaseFunction(GetValue(value, 'ease', ease), easeParams), + GetNewValue(value, 'delay', delay), + GetNewValue(value, 'duration', duration), + GetBoolean(value, 'yoyo', yoyo), + GetNewValue(value, 'hold', hold), + GetNewValue(value, 'repeat', repeat), + GetNewValue(value, 'repeatDelay', repeatDelay), + GetBoolean(value, 'flipX', flipX), + GetBoolean(value, 'flipY', flipY) + ); + + data.push(tweenData); + } + } + + var tween = new Tween(parent, data, targets); + + tween.offset = GetAdvancedValue(config, 'offset', null); + tween.completeDelay = GetAdvancedValue(config, 'completeDelay', 0); + tween.loop = Math.round(GetAdvancedValue(config, 'loop', 0)); + tween.loopDelay = Math.round(GetAdvancedValue(config, 'loopDelay', 0)); + tween.paused = GetBoolean(config, 'paused', false); + tween.useFrames = GetBoolean(config, 'useFrames', false); + + // Set the Callbacks + var scope = GetValue(config, 'callbackScope', tween); + + // Callback parameters: 0 = a reference to the Tween itself, 1 = the target/s of the Tween, ... your own params + var tweenArray = [ tween, null ]; + + var callbacks = Tween.TYPES; + + for (var i = 0; i < callbacks.length; i++) + { + var type = callbacks[i]; + + var callback = GetValue(config, type, false); + + if (callback) + { + var callbackScope = GetValue(config, type + 'Scope', scope); + var callbackParams = GetValue(config, type + 'Params', []); + + // The null is reset to be the Tween target + tween.setCallback(type, callback, tweenArray.concat(callbackParams), callbackScope); + } + } + + return tween; +}; + +module.exports = TweenBuilder; + + +/***/ }), +/* 98 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetNewValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {function} [description] + */ +var GetNewValue = function (source, key, defaultValue) +{ + var valueCallback; + + if (source.hasOwnProperty(key)) + { + var t = typeof(source[key]); + + if (t === 'function') + { + valueCallback = function (index, totalTargets, target) + { + return source[key](index, totalTargets, target); + }; + } + else + { + valueCallback = function () + { + return source[key]; + }; + } + } + else if (typeof defaultValue === 'function') + { + valueCallback = defaultValue; + } + else + { + valueCallback = function () + { + return defaultValue; + }; + } + + return valueCallback; +}; + +module.exports = GetNewValue; + + +/***/ }), +/* 99 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Tileset is a combination of an image containing the tiles and a container for data about + * each tile. + * + * @class Tileset + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {string} name - The name of the tileset in the map data. + * @param {integer} firstgid - The first tile index this tileset contains. + * @param {integer} [tileWidth=32] - Width of each tile (in pixels). + * @param {integer} [tileHeight=32] - Height of each tile (in pixels). + * @param {integer} [tileMargin=0] - The margin around all tiles in the sheet (in pixels). + * @param {integer} [tileSpacing=0] - The spacing between each tile in the sheet (in pixels). + * @param {object} [tileProperties={}] - Custom properties defined per tile in the Tileset. + * These typically are custom properties created in Tiled when editing a tileset. + * @param {object} [tileData={}] - Data stored per tile. These typically are created in Tiled + * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. + */ +var Tileset = new Class({ + + initialize: + + function Tileset (name, firstgid, tileWidth, tileHeight, tileMargin, tileSpacing, tileProperties, tileData) + { + if (tileWidth === undefined || tileWidth <= 0) { tileWidth = 32; } + if (tileHeight === undefined || tileHeight <= 0) { tileHeight = 32; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (tileProperties === undefined) { tileProperties = {}; } + if (tileData === undefined) { tileData = {}; } + + /** + * The name of the Tileset. + * + * @name Phaser.Tilemaps.Tileset#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The starting index of the first tile index this Tileset contains. + * + * @name Phaser.Tilemaps.Tileset#firstgid + * @type {integer} + * @since 3.0.0 + */ + this.firstgid = firstgid; + + /** + * The width of each tile (in pixels). Use setTileSize to change. + * + * @name Phaser.Tilemaps.Tileset#tileWidth + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileWidth = tileWidth; + + /** + * The height of each tile (in pixels). Use setTileSize to change. + * + * @name Phaser.Tilemaps.Tileset#tileHeight + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileHeight = tileHeight; + + /** + * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.Tileset#tileMargin + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileMargin = tileMargin; + + /** + * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.Tileset#tileSpacing + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.tileSpacing = tileSpacing; + + /** + * Tileset-specific properties per tile that are typically defined in the Tiled editor in the + * Tileset editor. + * + * @name Phaser.Tilemaps.Tileset#tileProperties + * @type {object} + * @since 3.0.0 + */ + this.tileProperties = tileProperties; + + /** + * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within + * the Tileset collision editor. This is where collision objects and terrain are stored. + * + * @name Phaser.Tilemaps.Tileset#tileData + * @type {object} + * @since 3.0.0 + */ + this.tileData = tileData; + + /** + * The cached image that contains the individual tiles. Use setImage to set. + * + * @name Phaser.Tilemaps.Tileset#image + * @type {?Phaser.Textures.Texture} + * @readonly + * @since 3.0.0 + */ + this.image = null; + + /** + * The gl texture used by the WebGL renderer. + * + * @name Phaser.Tilemaps.Tileset#glTexture + * @type {?WebGLTexture} + * @readonly + * @since 3.11.0 + */ + this.glTexture = null; + + /** + * The number of tile rows in the the tileset. + * + * @name Phaser.Tilemaps.Tileset#rows + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.rows = 0; + + /** + * The number of tile columns in the tileset. + * + * @name Phaser.Tilemaps.Tileset#columns + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.columns = 0; + + /** + * The total number of tiles in the tileset. + * + * @name Phaser.Tilemaps.Tileset#total + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.total = 0; + + /** + * The look-up table to specific tile image texture coordinates (UV in pixels). Each element + * contains the coordinates for a tile in an object of the form {x, y}. + * + * @name Phaser.Tilemaps.Tileset#texCoordinates + * @type {object[]} + * @readonly + * @since 3.0.0 + */ + this.texCoordinates = []; + }, + + /** + * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. + * + * @method Phaser.Tilemaps.Tileset#getTileProperties + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?(object|undefined)} + */ + getTileProperties: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.tileProperties[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained + * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision + * info and terrain mapping. + * + * @method Phaser.Tilemaps.Tileset#getTileData + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object|undefined} + */ + getTileData: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.tileData[tileIndex - this.firstgid]; + }, + + /** + * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not + * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. + * + * @method Phaser.Tilemaps.Tileset#getTileCollisionGroup + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} + */ + getTileCollisionGroup: function (tileIndex) + { + var data = this.getTileData(tileIndex); + + return (data && data.objectgroup) ? data.objectgroup : null; + }, + + /** + * Returns true if and only if this Tileset contains the given tile index. + * + * @method Phaser.Tilemaps.Tileset#containsTileIndex + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {boolean} + */ + containsTileIndex: function (tileIndex) + { + return ( + tileIndex >= this.firstgid && + tileIndex < (this.firstgid + this.total) + ); + }, + + /** + * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. + * Returns null if tile index is not contained in this Tileset. + * + * @method Phaser.Tilemaps.Tileset#getTileTextureCoordinates + * @since 3.0.0 + * + * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. + * + * @return {?object} Object in the form { x, y } representing the top-left UV coordinate + * within the Tileset image. + */ + getTileTextureCoordinates: function (tileIndex) + { + if (!this.containsTileIndex(tileIndex)) { return null; } + + return this.texCoordinates[tileIndex - this.firstgid]; + }, + + /** + * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setImage + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The image that contains the tiles. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setImage: function (texture) + { + this.image = texture; + + this.glTexture = texture.get().source.glTexture; + + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + + return this; + }, + + /** + * Sets the tile width & height and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setTileSize + * @since 3.0.0 + * + * @param {integer} [tileWidth] - The width of a tile in pixels. + * @param {integer} [tileHeight] - The height of a tile in pixels. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setTileSize: function (tileWidth, tileHeight) + { + if (tileWidth !== undefined) { this.tileWidth = tileWidth; } + if (tileHeight !== undefined) { this.tileHeight = tileHeight; } + + if (this.image) + { + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). + * + * @method Phaser.Tilemaps.Tileset#setSpacing + * @since 3.0.0 + * + * @param {integer} [margin] - The margin around the tiles in the sheet (in pixels). + * @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels). + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + setSpacing: function (margin, spacing) + { + if (margin !== undefined) { this.tileMargin = margin; } + if (spacing !== undefined) { this.tileSpacing = spacing; } + + if (this.image) + { + this.updateTileData(this.image.source[0].width, this.image.source[0].height); + } + + return this; + }, + + /** + * Updates tile texture coordinates and tileset data. + * + * @method Phaser.Tilemaps.Tileset#updateTileData + * @since 3.0.0 + * + * @param {integer} imageWidth - The (expected) width of the image to slice. + * @param {integer} imageHeight - The (expected) height of the image to slice. + * + * @return {Phaser.Tilemaps.Tileset} This Tileset object. + */ + updateTileData: function (imageWidth, imageHeight) + { + var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); + var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); + + if (rowCount % 1 !== 0 || colCount % 1 !== 0) + { + console.warn('Image tile area not tile size multiple in: ' + this.name); + } + + // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated + // - hence the floor when calculating the rows/columns. + rowCount = Math.floor(rowCount); + colCount = Math.floor(colCount); + + this.rows = rowCount; + this.columns = colCount; + + // In Tiled, "empty" spaces in a tileset count as tiles and hence count towards the gid + this.total = rowCount * colCount; + + this.texCoordinates.length = 0; + + var tx = this.tileMargin; + var ty = this.tileMargin; + + for (var y = 0; y < this.rows; y++) + { + for (var x = 0; x < this.columns; x++) + { + this.texCoordinates.push({ x: tx, y: ty }); + tx += this.tileWidth + this.tileSpacing; + } + + tx = this.tileMargin; + ty += this.tileHeight + this.tileSpacing; + } + + return this; + } + +}); + +module.exports = Tileset; + + +/***/ }), +/* 100 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.TileToWorldY + * @private + * @since 3.0.0 + * + * @param {integer} tileY - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} + */ +var TileToWorldY = function (tileY, camera, layer) +{ + var tileHeight = layer.baseTileHeight; + var tilemapLayer = layer.tilemapLayer; + var layerWorldY = 0; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); + + tileHeight *= tilemapLayer.scaleY; + } + + return layerWorldY + tileY * tileHeight; +}; + +module.exports = TileToWorldY; + + +/***/ }), +/* 101 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layer's position, scale and scroll. + * + * @function Phaser.Tilemaps.Components.TileToWorldX + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {number} + */ +var TileToWorldX = function (tileX, camera, layer) +{ + var tileWidth = layer.baseTileWidth; + var tilemapLayer = layer.tilemapLayer; + var layerWorldX = 0; + + if (tilemapLayer) + { + if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } + + layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX); + + tileWidth *= tilemapLayer.scaleX; + } + + return layerWorldX + tileX * tileWidth; +}; + +module.exports = TileToWorldX; + + +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsInLayerBounds = __webpack_require__(79); + +/** + * Gets a tile at the given tile coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAt = function (tileX, tileY, nonNull, layer) +{ + if (nonNull === undefined) { nonNull = false; } + + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else if (tile.index === -1) + { + return nonNull ? tile : null; + } + else + { + return tile; + } + } + else + { + return null; + } +}; + +module.exports = GetTileAt; + + +/***/ }), +/* 103 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Components + */ + +module.exports = { + + CalculateFacesAt: __webpack_require__(136), + CalculateFacesWithin: __webpack_require__(34), + Copy: __webpack_require__(489), + CreateFromTiles: __webpack_require__(488), + CullTiles: __webpack_require__(487), + Fill: __webpack_require__(486), + FilterTiles: __webpack_require__(485), + FindByIndex: __webpack_require__(484), + FindTile: __webpack_require__(483), + ForEachTile: __webpack_require__(482), + GetTileAt: __webpack_require__(102), + GetTileAtWorldXY: __webpack_require__(481), + GetTilesWithin: __webpack_require__(17), + GetTilesWithinShape: __webpack_require__(480), + GetTilesWithinWorldXY: __webpack_require__(479), + HasTileAt: __webpack_require__(219), + HasTileAtWorldXY: __webpack_require__(478), + IsInLayerBounds: __webpack_require__(79), + PutTileAt: __webpack_require__(135), + PutTileAtWorldXY: __webpack_require__(477), + PutTilesAt: __webpack_require__(476), + Randomize: __webpack_require__(475), + RemoveTileAt: __webpack_require__(218), + RemoveTileAtWorldXY: __webpack_require__(474), + RenderDebug: __webpack_require__(473), + ReplaceByIndex: __webpack_require__(220), + SetCollision: __webpack_require__(472), + SetCollisionBetween: __webpack_require__(471), + SetCollisionByExclusion: __webpack_require__(470), + SetCollisionByProperty: __webpack_require__(469), + SetCollisionFromCollisionGroup: __webpack_require__(468), + SetTileIndexCallback: __webpack_require__(467), + SetTileLocationCallback: __webpack_require__(466), + Shuffle: __webpack_require__(465), + SwapByIndex: __webpack_require__(464), + TileToWorldX: __webpack_require__(101), + TileToWorldXY: __webpack_require__(463), + TileToWorldY: __webpack_require__(100), + WeightedRandomize: __webpack_require__(462), + WorldToTileX: __webpack_require__(50), + WorldToTileXY: __webpack_require__(461), + WorldToTileY: __webpack_require__(49) + +}; + + +/***/ }), +/* 104 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(236); +var Sprite = __webpack_require__(61); + +/** + * @classdesc + * An Arcade Physics Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.Sprite + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeSprite = new Class({ + + Extends: Sprite, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeSprite (scene, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + + /** + * This Game Object's Physics Body. + * + * @name Phaser.Physics.Arcade.Sprite#body + * @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} + * @default null + * @since 3.0.0 + */ + this.body = null; + } + +}); + +module.exports = ArcadeSprite; + + +/***/ }), +/* 105 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} XHRSettingsObject + * + * @property {XMLHttpRequestResponseType} responseType - The response type of the XHR request, i.e. `blob`, `text`, etc. + * @property {boolean} [async=true] - Should the XHR request use async or not? + * @property {string} [user=''] - Optional username for the XHR request. + * @property {string} [password=''] - Optional password for the XHR request. + * @property {integer} [timeout=0] - Optional XHR timeout value. + * @property {(string|undefined)} [header] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [headerValue] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [requestedWith] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [overrideMimeType] - Provide a custom mime-type to use instead of the default. + */ + +/** + * Creates an XHRSettings Object with default values. + * + * @function Phaser.Loader.XHRSettings + * @since 3.0.0 + * + * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. + * @param {boolean} [async=true] - Should the XHR request use async or not? + * @param {string} [user=''] - Optional username for the XHR request. + * @param {string} [password=''] - Optional password for the XHR request. + * @param {integer} [timeout=0] - Optional XHR timeout value. + * + * @return {XHRSettingsObject} The XHRSettings object as used by the Loader. + */ +var XHRSettings = function (responseType, async, user, password, timeout) +{ + if (responseType === undefined) { responseType = ''; } + if (async === undefined) { async = true; } + if (user === undefined) { user = ''; } + if (password === undefined) { password = ''; } + if (timeout === undefined) { timeout = 0; } + + // Before sending a request, set the xhr.responseType to "text", + // "arraybuffer", "blob", or "document", depending on your data needs. + // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". + + return { + + // Ignored by the Loader, only used by File. + responseType: responseType, + + async: async, + + // credentials + user: user, + password: password, + + // timeout in ms (0 = no timeout) + timeout: timeout, + + // setRequestHeader + header: undefined, + headerValue: undefined, + requestedWith: false, + + // overrideMimeType + overrideMimeType: undefined + + }; +}; + +module.exports = XHRSettings; + + +/***/ }), +/* 106 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); + +// Contains the plugins that Phaser uses globally and locally. +// These are the source objects, not instantiated. +var inputPlugins = {}; + +/** + * @typedef {object} InputPluginContainer + * + * @property {string} key - The unique name of this plugin in the input plugin cache. + * @property {function} plugin - The plugin to be stored. Should be the source object, not instantiated. + * @property {string} [mapping] - If this plugin is to be injected into the Input Plugin, this is the property key map used. + */ + +var InputPluginCache = {}; + +/** + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + * + * @method Phaser.Input.InputPluginCache.register + * @since 3.10.0 + * + * @param {string} key - A reference used to get this plugin from the plugin cache. + * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. + * @param {string} mapping - If this plugin is to be injected into the Input Plugin, this is the property key used. + * @param {string} settingsKey - The key in the Scene Settings to check to see if this plugin should install or not. + * @param {string} configKey - The key in the Game Config to check to see if this plugin should install or not. + */ +InputPluginCache.register = function (key, plugin, mapping, settingsKey, configKey) +{ + inputPlugins[key] = { plugin: plugin, mapping: mapping, settingsKey: settingsKey, configKey: configKey }; +}; + +/** + * Returns the input plugin object from the cache based on the given key. + * + * @method Phaser.Input.InputPluginCache.getCore + * @since 3.10.0 + * + * @param {string} key - The key of the input plugin to get. + * + * @return {InputPluginContainer} The input plugin object. + */ +InputPluginCache.getPlugin = function (key) +{ + return inputPlugins[key]; +}; + +/** + * Installs all of the registered Input Plugins into the given target. + * + * @method Phaser.Input.InputPluginCache.install + * @since 3.10.0 + * + * @param {Phaser.Input.InputPlugin} target - The target InputPlugin to install the plugins into. + */ +InputPluginCache.install = function (target) +{ + var sys = target.scene.sys; + var settings = sys.settings.input; + var config = sys.game.config; + + for (var key in inputPlugins) + { + var source = inputPlugins[key].plugin; + var mapping = inputPlugins[key].mapping; + var settingsKey = inputPlugins[key].settingsKey; + var configKey = inputPlugins[key].configKey; + + if (GetValue(settings, settingsKey, config[configKey])) + { + target[mapping] = new source(target); + } + } +}; + +/** + * Removes an input plugin based on the given key. + * + * @method Phaser.Input.InputPluginCache.remove + * @since 3.10.0 + * + * @param {string} key - The key of the input plugin to remove. + */ +InputPluginCache.remove = function (key) +{ + if (inputPlugins.hasOwnProperty(key)) + { + delete inputPlugins[key]; + } +}; + +module.exports = InputPluginCache; + + +/***/ }), +/* 107 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// This is based off an explanation and expanded math presented by Paul Bourke: +// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ + +/** + * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. + * + * @function Phaser.Geom.Intersects.LineToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line1 - The first Line to check. + * @param {Phaser.Geom.Line} line2 - The second Line to check. + * @param {Phaser.Geom.Point} [out] - A Point in which to optionally store the point of intersection. + * + * @return {boolean} `true` if the two Lines intersect, and the `out` object will be populated, if given. Otherwise, `false`. + */ +var LineToLine = function (line1, line2, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = line1.x1; + var y1 = line1.y1; + var x2 = line1.x2; + var y2 = line1.y2; + + var x3 = line2.x1; + var y3 = line2.y1; + var x4 = line2.x2; + var y4 = line2.y2; + + var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); + var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); + var deNom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); + + // Make sure there is not a division by zero - this also indicates that the lines are parallel. + // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). + // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). + + if (deNom === 0) + { + return false; + } + + // Calculate the intermediate fractional point that the lines potentially intersect. + + var uA = numA / deNom; + var uB = numB / deNom; + + // The fractional point will be between 0 and 1 inclusive if the lines intersect. + // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. + + if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) + { + out.x = x1 + (uA * (x2 - x1)); + out.y = y1 + (uA * (y2 - y1)); + + return true; + } + + return false; +}; + +module.exports = LineToLine; + + +/***/ }), +/* 108 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var MeshRender = __webpack_require__(731); + +/** + * @classdesc + * A Mesh Game Object. + * + * @class Mesh + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number[]} vertices - An array containing the vertices data for this Mesh. + * @param {number[]} uv - An array containing the uv data for this Mesh. + * @param {number[]} colors - An array containing the color data for this Mesh. + * @param {number[]} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Mesh = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + MeshRender + ], + + initialize: + + function Mesh (scene, x, y, vertices, uv, colors, alphas, texture, frame) + { + GameObject.call(this, scene, 'Mesh'); + + if (vertices.length !== uv.length) + { + throw new Error('Mesh Vertex count must match UV count'); + } + + var verticesUB = (vertices.length / 2) | 0; + + if (colors.length > 0 && colors.length < verticesUB) + { + throw new Error('Mesh Color count must match Vertex count'); + } + + if (alphas.length > 0 && alphas.length < verticesUB) + { + throw new Error('Mesh Alpha count must match Vertex count'); + } + + var i; + + if (colors.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + colors[i] = 0xFFFFFF; + } + } + + if (alphas.length === 0) + { + for (i = 0; i < verticesUB; ++i) + { + alphas[i] = 1.0; + } + } + + /** + * An array containing the vertices data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#vertices + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertices = new Float32Array(vertices); + + /** + * An array containing the uv data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#uv + * @type {Float32Array} + * @since 3.0.0 + */ + this.uv = new Float32Array(uv); + + /** + * An array containing the color data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#colors + * @type {Uint32Array} + * @since 3.0.0 + */ + this.colors = new Uint32Array(colors); + + /** + * An array containing the alpha data for this Mesh. + * + * @name Phaser.GameObjects.Mesh#alphas + * @type {Float32Array} + * @since 3.0.0 + */ + this.alphas = new Float32Array(alphas); + + /** + * Fill or additive mode used when blending the color values? + * + * @name Phaser.GameObjects.Mesh#tintFill + * @type {boolean} + * @default false + * @since 3.11.0 + */ + this.tintFill = false; + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOrigin(); + this.initPipeline(); + } + +}); + +module.exports = Mesh; + + +/***/ }), +/* 109 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var GetBitmapTextSize = __webpack_require__(846); +var ParseFromAtlas = __webpack_require__(845); +var Render = __webpack_require__(844); + +/** + * The font data for an individual character of a Bitmap Font. + * + * Describes the character's position, size, offset and kerning. + * + * @typedef {object} BitmapFontCharacterData + * + * @property {number} x - The x position of the character. + * @property {number} y - The y position of the character. + * @property {number} width - The width of the character. + * @property {number} height - The height of the character. + * @property {number} centerX - The center x position of the character. + * @property {number} centerY - The center y position of the character. + * @property {number} xOffset - The x offset of the character. + * @property {number} yOffset - The y offset of the character. + * @property {object} data - Extra data for the character. + * @property {Object.} kerning - Kerning values, keyed by character code. + */ + +/** + * Bitmap Font data that can be used by a BitmapText Game Object. + * + * @typedef {object} BitmapFontData + * + * @property {string} font - The name of the font. + * @property {number} size - The size of the font. + * @property {number} lineHeight - The line height of the font. + * @property {boolean} retroFont - Whether this font is a retro font (monospace). + * @property {Object.} chars - The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more. + */ + +/** + * @typedef {object} JSONBitmapText + * @extends {JSONGameObject} + * + * @property {string} font - The name of the font. + * @property {string} text - The text that this Bitmap Text displays. + * @property {number} fontSize - The size of the font. + * @property {number} letterSpacing - Adds / Removes spacing between characters. + * @property {integer} align - The alignment of the text in a multi-line BitmapText object. + */ + +/** + * @classdesc + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * @class BitmapText + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} x - The x coordinate of this Game Object in world space. + * @param {number} y - The y coordinate of this Game Object in world space. + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size of this Bitmap Text. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. + */ +var BitmapText = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function BitmapText (scene, x, y, font, text, size, align) + { + if (text === undefined) { text = ''; } + if (align === undefined) { align = 0; } + + GameObject.call(this, scene, 'BitmapText'); + + /** + * The key of the Bitmap Font used by this Bitmap Text. + * To change the font after creation please use `setFont`. + * + * @name Phaser.GameObjects.BitmapText#font + * @type {string} + * @readonly + * @since 3.0.0 + */ + this.font = font; + + var entry = this.scene.sys.cache.bitmapFont.get(font); + + /** + * The data of the Bitmap Font used by this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#fontData + * @type {BitmapFontData} + * @readonly + * @since 3.0.0 + */ + this.fontData = entry.data; + + /** + * The text that this Bitmap Text object displays. + * + * @name Phaser.GameObjects.BitmapText#_text + * @type {string} + * @private + * @since 3.0.0 + */ + this._text = ''; + + /** + * The font size of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#_fontSize + * @type {number} + * @private + * @since 3.0.0 + */ + this._fontSize = size || this.fontData.size; + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * @name Phaser.GameObjects.BitmapText#_letterSpacing + * @type {number} + * @private + * @since 3.4.0 + */ + this._letterSpacing = 0; + + /** + * Controls the alignment of each line of text in this BitmapText object. + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#_align + * @type {integer} + * @private + * @since 3.11.0 + */ + this._align = align; + + /** + * An object that describes the size of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#_bounds + * @type {BitmapTextSize} + * @private + * @since 3.0.0 + */ + this._bounds = GetBitmapTextSize(this, false, this._bounds); + + /** + * An internal dirty flag for bounds calculation. + * + * @name Phaser.GameObjects.BitmapText#_dirty + * @type {boolean} + * @private + * @since 3.11.0 + */ + this._dirty = false; + + this.setTexture(entry.texture, entry.frame); + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline(); + + this.setText(text); + }, + + /** + * Set the lines of text in this BitmapText to be left-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setLeftAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setLeftAlign: function () + { + this._align = BitmapText.ALIGN_LEFT; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be center-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setCenterAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setCenterAlign: function () + { + this._align = BitmapText.ALIGN_CENTER; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be right-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setRightAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setRightAlign: function () + { + this._align = BitmapText.ALIGN_RIGHT; + + this._dirty = true; + + return this; + }, + + /** + * Set the font size of this Bitmap Text. + * + * @method Phaser.GameObjects.BitmapText#setFontSize + * @since 3.0.0 + * + * @param {number} size - The font size to set. + * + * @return {this} This BitmapText Object. + */ + setFontSize: function (size) + { + this._fontSize = size; + + this._dirty = true; + + return this; + }, + + /** + * Sets the letter spacing between each character of this Bitmap Text. + * Can be a positive value to increase the space, or negative to reduce it. + * Spacing is applied after the kerning values have been set. + * + * @method Phaser.GameObjects.BitmapText#setLetterSpacing + * @since 3.4.0 + * + * @param {number} [spacing=0] - The amount of horizontal space to add between each character. + * + * @return {this} This BitmapText Object. + */ + setLetterSpacing: function (spacing) + { + if (spacing === undefined) { spacing = 0; } + + this._letterSpacing = spacing; + + this._dirty = true; + + return this; + }, + + /** + * Set the textual content of this BitmapText. + * + * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. + * + * @method Phaser.GameObjects.BitmapText#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. + * + * @return {this} This BitmapText Object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this.text) + { + this._text = value.toString(); + + this._dirty = true; + + this.updateDisplayOrigin(); + } + + return this; + }, + + /** + * Calculate the bounds of this Bitmap Text. + * + * An object is returned that contains the position, width and height of the Bitmap Text in local and global + * contexts. + * + * Local size is based on just the font size and a [0, 0] position. + * + * Global size takes into account the Game Object's scale, world position and display origin. + * + * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. + * + * @method Phaser.GameObjects.BitmapText#getTextBounds + * @since 3.0.0 + * + * @param {boolean} [round] - Whether to round the results to the nearest integer. + * + * @return {BitmapTextSize} An object that describes the size of this Bitmap Text. + */ + getTextBounds: function (round) + { + // local = The BitmapText based on fontSize and 0x0 coords + // global = The BitmapText, taking into account scale and world position + // lines = The BitmapText line data + + if (this._dirty) + { + GetBitmapTextSize(this, round, this._bounds); + } + + return this._bounds; + }, + + /** + * Changes the font this BitmapText is using to render. + * + * The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved, + * unless overridden via the arguments. + * + * @method Phaser.GameObjects.BitmapText#setFont + * @since 3.11.0 + * + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {number} [size] - The font size of this Bitmap Text. If not specified the current size will be used. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. + * + * @return {this} This BitmapText Object. + */ + setFont: function (key, size, align) + { + if (size === undefined) { size = this._fontSize; } + if (align === undefined) { align = this._align; } + + if (key !== this.font) + { + var entry = this.scene.sys.cache.bitmapFont.get(key); + + if (entry) + { + this.font = key; + this.fontData = entry.data; + this._fontSize = size; + this._align = align; + + this.setTexture(entry.texture, entry.frame); + + GetBitmapTextSize(this, false, this._bounds); + } + } + + return this; + }, + + /** + * Controls the alignment of each line of text in this BitmapText object. + * + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#align + * @type {integer} + * @since 3.11.0 + */ + align: { + + set: function (value) + { + this._align = value; + this._dirty = true; + }, + + get: function () + { + return this._align; + } + + }, + + /** + * The text that this Bitmap Text object displays. + * + * You can also use the method `setText` if you want a chainable way to change the text content. + * + * @name Phaser.GameObjects.BitmapText#text + * @type {string} + * @since 3.0.0 + */ + text: { + + set: function (value) + { + this.setText(value); + }, + + get: function () + { + return this._text; + } + + }, + + /** + * The font size of this Bitmap Text. + * + * You can also use the method `setFontSize` if you want a chainable way to change the font size. + * + * @name Phaser.GameObjects.BitmapText#fontSize + * @type {number} + * @since 3.0.0 + */ + fontSize: { + + set: function (value) + { + this._fontSize = value; + this._dirty = true; + }, + + get: function () + { + return this._fontSize; + } + + }, + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. + * + * @name Phaser.GameObjects.BitmapText#letterSpacing + * @type {number} + * @since 3.0.0 + */ + letterSpacing: { + + set: function (value) + { + this._letterSpacing = value; + this._dirty = true; + }, + + get: function () + { + return this._letterSpacing; + } + + }, + + /** + * The width of this Bitmap Text. + * + * @name Phaser.GameObjects.BitmapText#width + * @type {number} + * @readonly + * @since 3.0.0 + */ + width: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.width; + } + + }, + + /** + * The height of this bitmap text. + * + * @name Phaser.GameObjects.BitmapText#height + * @type {number} + * @readonly + * @since 3.0.0 + */ + height: { + + get: function () + { + this.getTextBounds(false); + + return this._bounds.global.height; + } + + }, + + /** + * Build a JSON representation of this Bitmap Text. + * + * @method Phaser.GameObjects.BitmapText#toJSON + * @since 3.0.0 + * + * @return {JSONBitmapText} A JSON representation of this Bitmap Text. + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra data is added here + + var data = { + font: this.font, + text: this.text, + fontSize: this.fontSize, + letterSpacing: this.letterSpacing, + align: this.align + }; + + out.data = data; + + return out; + } + +}); + +/** + * Left align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_LEFT + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_LEFT = 0; + +/** + * Center align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_CENTER + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_CENTER = 1; + +/** + * Right align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_RIGHT + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_RIGHT = 2; + +BitmapText.ParseFromAtlas = ParseFromAtlas; + +module.exports = BitmapText; + + +/***/ }), +/* 110 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +//! stable.js 0.1.6, https://github.com/Two-Screen/stable +//! © 2017 Angry Bytes and contributors. MIT licensed. + +(function() { + +// A stable array sort, because `Array#sort()` is not guaranteed stable. +// This is an implementation of merge sort, without recursion. + +var stable = function(arr, comp) { + return exec(arr.slice(), comp); +}; + +stable.inplace = function(arr, comp) { + var result = exec(arr, comp); + + // This simply copies back if the result isn't in the original array, + // which happens on an odd number of passes. + if (result !== arr) { + pass(result, null, arr.length, arr); + } + + return arr; +}; + +// Execute the sort using the input array and a second buffer as work space. +// Returns one of those two, containing the final result. +function exec(arr, comp) { + if (typeof(comp) !== 'function') { + comp = function(a, b) { + return String(a).localeCompare(b); + }; + } + + // Short-circuit when there's nothing to sort. + var len = arr.length; + if (len <= 1) { + return arr; + } + + // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc. + // Chunks are the size of the left or right hand in merge sort. + // Stop when the left-hand covers all of the array. + var buffer = new Array(len); + for (var chk = 1; chk < len; chk *= 2) { + pass(arr, comp, chk, buffer); + + var tmp = arr; + arr = buffer; + buffer = tmp; + } + + return arr; +} + +// Run a single pass with the given chunk size. +var pass = function(arr, comp, chk, result) { + var len = arr.length; + var i = 0; + // Step size / double chunk size. + var dbl = chk * 2; + // Bounds of the left and right chunks. + var l, r, e; + // Iterators over the left and right chunk. + var li, ri; + + // Iterate over pairs of chunks. + for (l = 0; l < len; l += dbl) { + r = l + chk; + e = r + chk; + if (r > len) r = len; + if (e > len) e = len; + + // Iterate both chunks in parallel. + li = l; + ri = r; + while (true) { + // Compare the chunks. + if (li < r && ri < e) { + // This works for a regular `sort()` compatible comparator, + // but also for a simple comparator like: `a > b` + if (comp(arr[li], arr[ri]) <= 0) { + result[i++] = arr[li++]; + } + else { + result[i++] = arr[ri++]; + } + } + // Nothing to compare, just flush what's left. + else if (li < r) { + result[i++] = arr[li++]; + } + else if (ri < e) { + result[i++] = arr[ri++]; + } + // Both iterators are at the chunk ends. + else { + break; + } + } + } +}; + +// Export using CommonJS or to the window. +if (true) { + module.exports = stable; +} +else {} + +})(); + +/***/ }), +/* 111 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. + +var CheckMatrix = __webpack_require__(163); +var TransposeMatrix = __webpack_require__(315); + +/** + * [description] + * + * @function Phaser.Utils.Array.Matrix.RotateMatrix + * @since 3.0.0 + * + * @param {array} matrix - The array to rotate. + * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. + * + * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. + */ +var RotateMatrix = function (matrix, direction) +{ + if (direction === undefined) { direction = 90; } + + if (!CheckMatrix(matrix)) + { + return null; + } + + if (typeof direction !== 'string') + { + direction = ((direction % 360) + 360) % 360; + } + + if (direction === 90 || direction === -270 || direction === 'rotateLeft') + { + matrix = TransposeMatrix(matrix); + matrix.reverse(); + } + else if (direction === -90 || direction === 270 || direction === 'rotateRight') + { + matrix.reverse(); + matrix = TransposeMatrix(matrix); + } + else if (Math.abs(direction) === 180 || direction === 'rotate180') + { + for (var i = 0; i < matrix.length; i++) + { + matrix[i].reverse(); + } + + matrix.reverse(); + } + + return matrix; +}; + +module.exports = RotateMatrix; + + +/***/ }), +/* 112 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayUtils = __webpack_require__(164); +var Class = __webpack_require__(0); +var NOOP = __webpack_require__(1); +var StableSort = __webpack_require__(110); + +/** + * @callback EachListCallback + * @generic I - [item] + * + * @param {*} item - The item which is currently being processed. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + +/** + * @classdesc + * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. + * + * @class List + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + * + * @param {*} parent - The parent of this list. + */ +var List = new Class({ + + initialize: + + function List (parent) + { + /** + * The parent of this list. + * + * @name Phaser.Structs.List#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The objects that belong to this collection. + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.List#list + * @type {Array.<*>} + * @default [] + * @since 3.0.0 + */ + this.list = []; + + /** + * The index of the current element. + * + * This is used internally when iterating through the list with the {@link #first}, {@link #last}, {@link #get}, and {@link #previous} properties. + * + * @name Phaser.Structs.List#position + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.position = 0; + + /** + * A callback that is invoked every time a child is added to this list. + * + * @name Phaser.Structs.List#addCallback + * @type {function} + * @since 3.4.0 + */ + this.addCallback = NOOP; + + /** + * A callback that is invoked every time a child is removed from this list. + * + * @name Phaser.Structs.List#removeCallback + * @type {function} + * @since 3.4.0 + */ + this.removeCallback = NOOP; + + /** + * The property key to sort by. + * + * @name Phaser.Structs.List#_sortKey + * @type {string} + * @since 3.4.0 + */ + this._sortKey = ''; + }, + + /** + * Adds the given item to the end of the list. Each item must be unique. + * + * @method Phaser.Structs.List#add + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*|Array.<*>} child - The item, or array of items, to add to the list. + * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. + * + * @return {*} The list's underlying array. + */ + add: function (child, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.Add(this.list, child); + } + else + { + return ArrayUtils.Add(this.list, child, 0, this.addCallback, this); + } + }, + + /** + * Adds an item to list, starting at a specified index. Each item must be unique within the list. + * + * @method Phaser.Structs.List#addAt + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item, or array of items, to add to the list. + * @param {integer} [index=0] - The index in the list at which the element(s) will be inserted. + * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. + * + * @return {*} The List's underlying array. + */ + addAt: function (child, index, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.AddAt(this.list, child, index); + } + else + { + return ArrayUtils.AddAt(this.list, child, index, 0, this.addCallback, this); + } + }, + + /** + * Retrieves the item at a given position inside the List. + * + * @method Phaser.Structs.List#getAt + * @since 3.0.0 + * + * @genericUse {T} - [$return] + * + * @param {integer} index - The index of the item. + * + * @return {*} The retrieved item, or `undefined` if it's outside the List's bounds. + */ + getAt: function (index) + { + return this.list[index]; + }, + + /** + * Locates an item within the List and returns its index. + * + * @method Phaser.Structs.List#getIndex + * @since 3.0.0 + * + * @genericUse {T} - [child] + * + * @param {*} child - The item to locate. + * + * @return {integer} The index of the item within the List, or -1 if it's not in the List. + */ + getIndex: function (child) + { + // Return -1 if given child isn't a child of this display list + return this.list.indexOf(child); + }, + + /** + * Sort the contents of this List so the items are in order based + * on the given property. For example, `sort('alpha')` would sort the List + * contents based on the value of their `alpha` property. + * + * @method Phaser.Structs.List#sort + * @since 3.0.0 + * + * @genericUse {T[]} - [children,$return] + * + * @param {string} property - The property to lexically sort by. + * + * @return {Phaser.Structs.List} This List object. + */ + sort: function (property) + { + if (property) + { + this._sortKey = property; + + StableSort.inplace(this.list, this.sortHandler); + } + + return this; + }, + + /** + * Internal handler for the {@link #sort} method which compares two items. + * + * @method Phaser.Structs.List#sortHandler + * @private + * @since 3.4.0 + * + * @genericUse {T} - [childA,childB] + * + * @param {*} childA - The first item to compare. + * @param {*} childB - The second item to compare. + * + * @return {integer} The result of the comparison, which will be negative if the first item is smaller then second, positive if the first item is larger than the second, or 0 if they're equal. + */ + sortHandler: function (childA, childB) + { + return childA[this._sortKey] - childB[this._sortKey]; + }, + + /** + * Searches for the first instance of a child with its `name` + * property matching the given argument. Should more than one child have + * the same name only the first is returned. + * + * @method Phaser.Structs.List#getByName + * @since 3.0.0 + * + * @genericUse {T | null} - [$return] + * + * @param {string} name - The name to search for. + * + * @return {?*} The first child with a matching name, or null if none were found. + */ + getByName: function (name) + { + return ArrayUtils.GetFirst(this.list, 'name', name); + }, + + /** + * Returns a random child from the group. + * + * @method Phaser.Structs.List#getRandom + * @since 3.0.0 + * + * @genericUse {T | null} - [$return] + * + * @param {integer} [startIndex=0] - Offset from the front of the group (lowest child). + * @param {integer} [length=(to top)] - Restriction on the number of values you want to randomly select from. + * + * @return {?*} A random child of this Group. + */ + getRandom: function (startIndex, length) + { + return ArrayUtils.GetRandom(this.list, startIndex, length); + }, + + /** + * Returns the first element in a given part of the List which matches a specific criterion. + * + * @method Phaser.Structs.List#getFirst + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {T | null} - [$return] + * + * @param {string} property - The name of the property to test or a falsey value to have no criterion. + * @param {*} value - The value to test the `property` against, or `undefined` to allow any value and only check for existence. + * @param {number} [startIndex=0] - The position in the List to start the search at. + * @param {number} [endIndex] - The position in the List to optionally stop the search at. It won't be checked. + * + * @return {?*} The first item which matches the given criterion, or `null` if no such item exists. + */ + getFirst: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns all children in this List. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('parent')` would return only children that have a property called `parent`. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only children that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this List had 100 children, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 children in the List. + * + * @method Phaser.Structs.List#getAll + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {T[]} - [$return] + * + * @param {string} [property] - An optional property to test against the value argument. + * @param {*} [value] - If property is set then Child.property must strictly equal this value to be included in the results. + * @param {integer} [startIndex] - The first child index to start the search from. + * @param {integer} [endIndex] - The last child index to search up until. + * + * @return {Array.<*>} All items of the List which match the given criterion, if any. + */ + getAll: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns the total number of items in the List which have a property matching the given value. + * + * @method Phaser.Structs.List#count + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {string} property - The property to test on each item. + * @param {*} value - The value to test the property against. + * + * @return {integer} The total number of matching elements. + */ + count: function (property, value) + { + return ArrayUtils.CountAllMatching(this.list, property, value); + }, + + /** + * Swaps the positions of two items in the list. + * + * @method Phaser.Structs.List#swap + * @since 3.0.0 + * + * @genericUse {T} - [child1,child2] + * + * @param {*} child1 - The first item to swap. + * @param {*} child2 - The second item to swap. + */ + swap: function (child1, child2) + { + ArrayUtils.Swap(this.list, child1, child2); + }, + + /** + * Moves an item in the List to a new position. + * + * @method Phaser.Structs.List#moveTo + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to move. + * @param {integer} index - Moves an item in the List to a new position. + * + * @return {*} The item that was moved. + */ + moveTo: function (child, index) + { + return ArrayUtils.MoveTo(this.list, child, index); + }, + + /** + * Removes one or many items from the List. + * + * @method Phaser.Structs.List#remove + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item, or array of items, to remove. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {*} The item, or array of items, which were successfully removed from the List. + */ + remove: function (child, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.Remove(this.list, child); + } + else + { + return ArrayUtils.Remove(this.list, child, this.removeCallback, this); + } + }, + + /** + * Removes the item at the given position in the List. + * + * @method Phaser.Structs.List#removeAt + * @since 3.0.0 + * + * @genericUse {T} - [$return] + * + * @param {integer} index - The position to remove the item from. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {*} The item that was removed. + */ + removeAt: function (index, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.RemoveAt(this.list, index); + } + else + { + return ArrayUtils.RemoveAt(this.list, index, this.removeCallback, this); + } + }, + + /** + * Removes the items within the given range in the List. + * + * @method Phaser.Structs.List#removeBetween + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @param {integer} [startIndex=0] - The index to start removing from. + * @param {integer} [endIndex] - The position to stop removing at. The item at this position won't be removed. + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {Array.<*>} An array of the items which were removed.[description] + */ + removeBetween: function (startIndex, endIndex, skipCallback) + { + if (skipCallback) + { + return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex); + } + else + { + return ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeCallback, this); + } + }, + + /** + * Removes all the items. + * + * @method Phaser.Structs.List#removeAll + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.List.} - [$return] + * + * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. + * + * @return {Phaser.Structs.List} This List object. + */ + removeAll: function (skipCallback) + { + var i = this.list.length; + + while (i--) + { + this.remove(this.list[i], skipCallback); + } + + return this; + }, + + /** + * Brings the given child to the top of this List. + * + * @method Phaser.Structs.List#bringToTop + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to bring to the top of the List. + * + * @return {*} The item which was moved. + */ + bringToTop: function (child) + { + return ArrayUtils.BringToTop(this.list, child); + }, + + /** + * Sends the given child to the bottom of this List. + * + * @method Phaser.Structs.List#sendToBack + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to send to the back of the list. + * + * @return {*} The item which was moved. + */ + sendToBack: function (child) + { + return ArrayUtils.SendToBack(this.list, child); + }, + + /** + * Moves the given child up one place in this group unless it's already at the top. + * + * @method Phaser.Structs.List#moveUp + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to move up. + * + * @return {*} The item which was moved. + */ + moveUp: function (child) + { + ArrayUtils.MoveUp(this.list, child); + + return child; + }, + + /** + * Moves the given child down one place in this group unless it's already at the bottom. + * + * @method Phaser.Structs.List#moveDown + * @since 3.0.0 + * + * @genericUse {T} - [child,$return] + * + * @param {*} child - The item to move down. + * + * @return {*} The item which was moved. + */ + moveDown: function (child) + { + ArrayUtils.MoveDown(this.list, child); + + return child; + }, + + /** + * Reverses the order of all children in this List. + * + * @method Phaser.Structs.List#reverse + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.List.} - [$return] + * + * @return {Phaser.Structs.List} This List object. + */ + reverse: function () + { + this.list.reverse(); + + return this; + }, + + /** + * Shuffles the items in the list. + * + * @method Phaser.Structs.List#shuffle + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.List.} - [$return] + * + * @return {Phaser.Structs.List} This List object. + */ + shuffle: function () + { + ArrayUtils.Shuffle(this.list); + + return this; + }, + + /** + * Replaces a child of this List with the given newChild. The newChild cannot be a member of this List. + * + * @method Phaser.Structs.List#replace + * @since 3.0.0 + * + * @genericUse {T} - [oldChild,newChild,$return] + * + * @param {*} oldChild - The child in this List that will be replaced. + * @param {*} newChild - The child to be inserted into this List. + * + * @return {*} Returns the oldChild that was replaced within this group. + */ + replace: function (oldChild, newChild) + { + return ArrayUtils.Replace(this.list, oldChild, newChild); + }, + + /** + * Checks if an item exists within the List. + * + * @method Phaser.Structs.List#exists + * @since 3.0.0 + * + * @genericUse {T} - [child] + * + * @param {*} child - The item to check for the existence of. + * + * @return {boolean} `true` if the item is found in the list, otherwise `false`. + */ + exists: function (child) + { + return (this.list.indexOf(child) > -1); + }, + + /** + * Sets the property `key` to the given value on all members of this List. + * + * @method Phaser.Structs.List#setAll + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {string} property - The name of the property to set. + * @param {*} value - The value to set the property to. + * @param {integer} [startIndex] - The first child index to start the search from. + * @param {integer} [endIndex] - The last child index to search up until. + */ + setAll: function (property, value, startIndex, endIndex) + { + ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); + + return this; + }, + + /** + * Passes all children to the given callback. + * + * @method Phaser.Structs.List#each + * @since 3.0.0 + * + * @genericUse {EachListCallback.} - [callback] + * + * @param {EachListCallback} callback - The function to call. + * @param {*} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + each: function (callback, context) + { + var args = [ null ]; + + for (var i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < this.list.length; i++) + { + args[0] = this.list[i]; + + callback.apply(context, args); + } + }, + + /** + * Clears the List and recreates its internal array. + * + * @method Phaser.Structs.List#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.removeAll(); + + this.list = []; + }, + + /** + * Destroys this List. + * + * @method Phaser.Structs.List#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAll(); + + this.parent = null; + this.addCallback = null; + this.removeCallback = null; + }, + + /** + * The number of items inside the List. + * + * @name Phaser.Structs.List#length + * @type {integer} + * @readonly + * @since 3.0.0 + */ + length: { + + get: function () + { + return this.list.length; + } + + }, + + /** + * The first item in the List or `null` for an empty List. + * + * @name Phaser.Structs.List#first + * @type {integer} + * @readonly + * @since 3.0.0 + */ + first: { + + get: function () + { + this.position = 0; + + if (this.list.length > 0) + { + return this.list[0]; + } + else + { + return null; + } + } + + }, + + /** + * The last item in the List, or `null` for an empty List. + * + * @name Phaser.Structs.List#last + * @type {integer} + * @readonly + * @since 3.0.0 + */ + last: { + + get: function () + { + if (this.list.length > 0) + { + this.position = this.list.length - 1; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * The next item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #first} or manually setting the {@link #position} to iterate the List. + * + * @name Phaser.Structs.List#next + * @type {integer} + * @readonly + * @since 3.0.0 + */ + next: { + + get: function () + { + if (this.position < this.list.length) + { + this.position++; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * The previous item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #last} or manually setting the {@link #position} to iterate the List backwards. + * + * @name Phaser.Structs.List#previous + * @type {integer} + * @readonly + * @since 3.0.0 + */ + previous: { + + get: function () + { + if (this.position > 0) + { + this.position--; + + return this.list[this.position]; + } + else + { + return null; + } + } + + } + +}); + +module.exports = List; + + +/***/ }), +/* 113 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Clamp = __webpack_require__(23); +var Extend = __webpack_require__(20); + +/** + * @classdesc + * A Frame is a section of a Texture. + * + * @class Frame + * @memberof Phaser.Textures + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. + * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. + * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. + * @param {number} x - The x coordinate of the top-left of this Frame. + * @param {number} y - The y coordinate of the top-left of this Frame. + * @param {number} width - The width of this Frame. + * @param {number} height - The height of this Frame. + */ +var Frame = new Class({ + + initialize: + + function Frame (texture, name, sourceIndex, x, y, width, height) + { + /** + * The Texture this Frame is a part of. + * + * @name Phaser.Textures.Frame#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = texture; + + /** + * The name of this Frame. + * The name is unique within the Texture. + * + * @name Phaser.Textures.Frame#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The TextureSource this Frame is part of. + * + * @name Phaser.Textures.Frame#source + * @type {Phaser.Textures.TextureSource} + * @since 3.0.0 + */ + this.source = texture.source[sourceIndex]; + + /** + * The index of the TextureSource in the Texture sources array. + * + * @name Phaser.Textures.Frame#sourceIndex + * @type {integer} + * @since 3.0.0 + */ + this.sourceIndex = sourceIndex; + + /** + * A reference to the Texture Source WebGL Texture that this Frame is using. + * + * @name Phaser.Textures.Frame#glTexture + * @type {?WebGLTexture} + * @default null + * @since 3.11.0 + */ + this.glTexture = this.source.glTexture; + + /** + * X position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutX + * @type {integer} + * @since 3.0.0 + */ + this.cutX; + + /** + * Y position within the source image to cut from. + * + * @name Phaser.Textures.Frame#cutY + * @type {integer} + * @since 3.0.0 + */ + this.cutY; + + /** + * The width of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutWidth + * @type {integer} + * @since 3.0.0 + */ + this.cutWidth; + + /** + * The height of the area in the source image to cut. + * + * @name Phaser.Textures.Frame#cutHeight + * @type {integer} + * @since 3.0.0 + */ + this.cutHeight; + + /** + * The X rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#x + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The Y rendering offset of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#y + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The rendering width of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#width + * @type {integer} + * @since 3.0.0 + */ + this.width; + + /** + * The rendering height of this Frame, taking trim into account. + * + * @name Phaser.Textures.Frame#height + * @type {integer} + * @since 3.0.0 + */ + this.height; + + /** + * Half the width, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfWidth + * @type {integer} + * @since 3.0.0 + */ + this.halfWidth; + + /** + * Half the height, floored. + * Precalculated for the renderer. + * + * @name Phaser.Textures.Frame#halfHeight + * @type {integer} + * @since 3.0.0 + */ + this.halfHeight; + + /** + * The x center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerX + * @type {integer} + * @since 3.0.0 + */ + this.centerX; + + /** + * The y center of this frame, floored. + * + * @name Phaser.Textures.Frame#centerY + * @type {integer} + * @since 3.0.0 + */ + this.centerY; + + /** + * The horizontal pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotX = 0; + + /** + * The vertical pivot point of this Frame. + * + * @name Phaser.Textures.Frame#pivotY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pivotY = 0; + + /** + * Does this Frame have a custom pivot point? + * + * @name Phaser.Textures.Frame#customPivot + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customPivot = false; + + /** + * **CURRENTLY UNSUPPORTED** + * + * Is this frame is rotated or not in the Texture? + * Rotation allows you to use rotated frames in texture atlas packing. + * It has nothing to do with Sprite rotation. + * + * @name Phaser.Textures.Frame#rotated + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotated = false; + + /** + * Over-rides the Renderer setting. + * -1 = use Renderer Setting + * 0 = No rounding + * 1 = Round + * + * @name Phaser.Textures.Frame#autoRound + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.autoRound = -1; + + /** + * Any Frame specific custom data can be stored here. + * + * @name Phaser.Textures.Frame#customData + * @type {object} + * @since 3.0.0 + */ + this.customData = {}; + + /** + * WebGL UV u0 value. + * + * @name Phaser.Textures.Frame#u0 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.u0 = 0; + + /** + * WebGL UV v0 value. + * + * @name Phaser.Textures.Frame#v0 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.v0 = 0; + + /** + * WebGL UV u1 value. + * + * @name Phaser.Textures.Frame#u1 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.u1 = 0; + + /** + * WebGL UV v1 value. + * + * @name Phaser.Textures.Frame#v1 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.v1 = 0; + + /** + * The un-modified source frame, trim and UV data. + * + * @name Phaser.Textures.Frame#data + * @type {object} + * @private + * @since 3.0.0 + */ + this.data = { + cut: { + x: 0, + y: 0, + w: 0, + h: 0, + r: 0, + b: 0 + }, + trim: false, + sourceSize: { + w: 0, + h: 0 + }, + spriteSourceSize: { + x: 0, + y: 0, + w: 0, + h: 0, + r: 0, + b: 0 + }, + radius: 0, + drawImage: { + x: 0, + y: 0, + width: 0, + height: 0 + } + }; + + this.setSize(width, height, x, y); + }, + + /** + * Sets the width, height, x and y of this Frame. + * + * This is called automatically by the constructor + * and should rarely be changed on-the-fly. + * + * @method Phaser.Textures.Frame#setSize + * @since 3.7.0 + * + * @param {integer} width - The width of the frame before being trimmed. + * @param {integer} height - The height of the frame before being trimmed. + * @param {integer} [x=0] - The x coordinate of the top-left of this Frame. + * @param {integer} [y=0] - The y coordinate of the top-left of this Frame. + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + setSize: function (width, height, x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + this.cutX = x; + this.cutY = y; + this.cutWidth = width; + this.cutHeight = height; + + this.width = width; + this.height = height; + + this.halfWidth = Math.floor(width * 0.5); + this.halfHeight = Math.floor(height * 0.5); + + this.centerX = Math.floor(width / 2); + this.centerY = Math.floor(height / 2); + + var data = this.data; + var cut = data.cut; + + cut.x = x; + cut.y = y; + cut.w = width; + cut.h = height; + cut.r = x + width; + cut.b = y + height; + + data.sourceSize.w = width; + data.sourceSize.h = height; + + data.spriteSourceSize.w = width; + data.spriteSourceSize.h = height; + + data.radius = 0.5 * Math.sqrt(width * width + height * height); + + var drawImage = data.drawImage; + + drawImage.x = x; + drawImage.y = y; + drawImage.width = width; + drawImage.height = height; + + return this.updateUVs(); + }, + + /** + * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. + * + * @method Phaser.Textures.Frame#setTrim + * @since 3.0.0 + * + * @param {number} actualWidth - The width of the frame before being trimmed. + * @param {number} actualHeight - The height of the frame before being trimmed. + * @param {number} destX - The destination X position of the trimmed frame for display. + * @param {number} destY - The destination Y position of the trimmed frame for display. + * @param {number} destWidth - The destination width of the trimmed frame for display. + * @param {number} destHeight - The destination height of the trimmed frame for display. + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) + { + var data = this.data; + var ss = data.spriteSourceSize; + + // Store actual values + + data.trim = true; + + data.sourceSize.w = actualWidth; + data.sourceSize.h = actualHeight; + + ss.x = destX; + ss.y = destY; + ss.w = destWidth; + ss.h = destHeight; + ss.r = destX + destWidth; + ss.b = destY + destHeight; + + // Adjust properties + this.x = destX; + this.y = destY; + + this.width = destWidth; + this.height = destHeight; + + this.halfWidth = destWidth * 0.5; + this.halfHeight = destHeight * 0.5; + + this.centerX = Math.floor(destWidth / 2); + this.centerY = Math.floor(destHeight / 2); + + return this.updateUVs(); + }, + + /** + * Takes a crop data object and, based on the rectangular region given, calculates the + * required UV coordinates in order to crop this Frame for WebGL and Canvas rendering. + * + * This is called directly by the Game Object Texture Components `setCrop` method. + * Please use that method to crop a Game Object. + * + * @method Phaser.Textures.Frame#setCropUVs + * @since 3.11.0 + * + * @param {object} crop - The crop data object. This is the `GameObject._crop` property. + * @param {number} x - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. + * @param {number} y - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param {number} width - The width of the crop rectangle. Cannot exceed the Frame width. + * @param {number} height - The height of the crop rectangle. Cannot exceed the Frame height. + * @param {boolean} flipX - Does the parent Game Object have flipX set? + * @param {boolean} flipY - Does the parent Game Object have flipY set? + * + * @return {object} The updated crop data object. + */ + setCropUVs: function (crop, x, y, width, height, flipX, flipY) + { + // Clamp the input values + + var cx = this.cutX; + var cy = this.cutY; + var cw = this.cutWidth; + var ch = this.cutHeight; + var rw = this.realWidth; + var rh = this.realHeight; + + x = Clamp(x, 0, rw); + y = Clamp(y, 0, rh); + + width = Clamp(width, 0, rw - x); + height = Clamp(height, 0, rh - y); + + var ox = cx + x; + var oy = cy + y; + var ow = width; + var oh = height; + + var data = this.data; + + if (data.trim) + { + var ss = data.spriteSourceSize; + + // Need to check for intersection between the cut area and the crop area + // If there is none, we set UV to be empty, otherwise set it to be the intersection area + + width = Clamp(width, 0, cw - x); + height = Clamp(height, 0, ch - y); + + var cropRight = x + width; + var cropBottom = y + height; + + var intersects = !(ss.r < x || ss.b < y || ss.x > cropRight || ss.y > cropBottom); + + if (intersects) + { + var ix = Math.max(ss.x, x); + var iy = Math.max(ss.y, y); + var iw = Math.min(ss.r, cropRight) - ix; + var ih = Math.min(ss.b, cropBottom) - iy; + + ow = iw; + oh = ih; + + if (flipX) + { + ox = cx + (cw - (ix - ss.x) - iw); + } + else + { + ox = cx + (ix - ss.x); + } + + if (flipY) + { + oy = cy + (ch - (iy - ss.y) - ih); + } + else + { + oy = cy + (iy - ss.y); + } + + x = ix; + y = iy; + + width = iw; + height = ih; + } + else + { + ox = 0; + oy = 0; + ow = 0; + oh = 0; + } + } + else + { + if (flipX) + { + ox = cx + (cw - x - width); + } + + if (flipY) + { + oy = cy + (ch - y - height); + } + } + + var tw = this.source.width; + var th = this.source.height; + + // Map the given coordinates into UV space, clamping to the 0-1 range. + + crop.u0 = Math.max(0, ox / tw); + crop.v0 = Math.max(0, oy / th); + crop.u1 = Math.min(1, (ox + ow) / tw); + crop.v1 = Math.min(1, (oy + oh) / th); + + crop.x = x; + crop.y = y; + + crop.cx = ox; + crop.cy = oy; + crop.cw = ow; + crop.ch = oh; + + crop.width = width; + crop.height = height; + + crop.flipX = flipX; + crop.flipY = flipY; + + return crop; + }, + + /** + * Takes a crop data object and recalculates the UVs based on the dimensions inside the crop object. + * Called automatically by `setFrame`. + * + * @method Phaser.Textures.Frame#updateCropUVs + * @since 3.11.0 + * + * @param {object} crop - The crop data object. This is the `GameObject._crop` property. + * @param {boolean} flipX - Does the parent Game Object have flipX set? + * @param {boolean} flipY - Does the parent Game Object have flipY set? + * + * @return {object} The updated crop data object. + */ + updateCropUVs: function (crop, flipX, flipY) + { + return this.setCropUVs(crop, crop.x, crop.y, crop.width, crop.height, flipX, flipY); + }, + + /** + * Updates the internal WebGL UV cache and the drawImage cache. + * + * @method Phaser.Textures.Frame#updateUVs + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVs: function () + { + var cx = this.cutX; + var cy = this.cutY; + var cw = this.cutWidth; + var ch = this.cutHeight; + + // Canvas data + + var cd = this.data.drawImage; + + cd.width = cw; + cd.height = ch; + + // WebGL data + + var tw = this.source.width; + var th = this.source.height; + + this.u0 = cx / tw; + this.v0 = cy / th; + + this.u1 = (cx + cw) / tw; + this.v1 = (cy + ch) / th; + + return this; + }, + + /** + * Updates the internal WebGL UV cache. + * + * @method Phaser.Textures.Frame#updateUVsInverted + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} This Frame object. + */ + updateUVsInverted: function () + { + var tw = this.source.width; + var th = this.source.height; + + this.u0 = (this.cutX + this.cutHeight) / tw; + this.v0 = this.cutY / th; + + this.u1 = this.cutX / tw; + this.v1 = (this.cutY + this.cutWidth) / th; + + return this; + }, + + /** + * Clones this Frame into a new Frame object. + * + * @method Phaser.Textures.Frame#clone + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} A clone of this Frame. + */ + clone: function () + { + var clone = new Frame(this.texture, this.name, this.sourceIndex); + + clone.cutX = this.cutX; + clone.cutY = this.cutY; + clone.cutWidth = this.cutWidth; + clone.cutHeight = this.cutHeight; + + clone.x = this.x; + clone.y = this.y; + + clone.width = this.width; + clone.height = this.height; + + clone.halfWidth = this.halfWidth; + clone.halfHeight = this.halfHeight; + + clone.centerX = this.centerX; + clone.centerY = this.centerY; + + clone.rotated = this.rotated; + + clone.data = Extend(true, clone.data, this.data); + + clone.updateUVs(); + + return clone; + }, + + /** + * Destroys this Frames references. + * + * @method Phaser.Textures.Frame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.texture = null; + + this.source = null; + }, + + /** + * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realWidth + * @type {number} + * @readonly + * @since 3.0.0 + */ + realWidth: { + + get: function () + { + return this.data.sourceSize.w; + } + + }, + + /** + * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, + * before being packed. + * + * @name Phaser.Textures.Frame#realHeight + * @type {number} + * @readonly + * @since 3.0.0 + */ + realHeight: { + + get: function () + { + return this.data.sourceSize.h; + } + + }, + + /** + * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) + * + * @name Phaser.Textures.Frame#radius + * @type {number} + * @readonly + * @since 3.0.0 + */ + radius: { + + get: function () + { + return this.data.radius; + } + + }, + + /** + * Is the Frame trimmed or not? + * + * @name Phaser.Textures.Frame#trimmed + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + trimmed: { + + get: function () + { + return this.data.trim; + } + + }, + + /** + * The Canvas drawImage data object. + * + * @name Phaser.Textures.Frame#canvasData + * @type {object} + * @readonly + * @since 3.0.0 + */ + canvasData: { + + get: function () + { + return this.data.drawImage; + } + + } + +}); + +module.exports = Frame; + + +/***/ }), +/* 114 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var EventEmitter = __webpack_require__(11); +var Extend = __webpack_require__(20); +var NOOP = __webpack_require__(1); + +/** + * @classdesc + * Class containing all the shared state and behavior of a sound object, independent of the implementation. + * + * @class BaseSound + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + */ +var BaseSound = new Class({ + + Extends: EventEmitter, + + initialize: + + function BaseSound (manager, key, config) + { + EventEmitter.call(this); + + /** + * Local reference to the sound manager. + * + * @name Phaser.Sound.BaseSound#manager + * @type {Phaser.Sound.BaseSoundManager} + * @private + * @since 3.0.0 + */ + this.manager = manager; + + /** + * Asset key for the sound. + * + * @name Phaser.Sound.BaseSound#key + * @type {string} + * @readonly + * @since 3.0.0 + */ + this.key = key; + + /** + * Flag indicating if sound is currently playing. + * + * @name Phaser.Sound.BaseSound#isPlaying + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isPlaying = false; + + /** + * Flag indicating if sound is currently paused. + * + * @name Phaser.Sound.BaseSound#isPaused + * @type {boolean} + * @default false + * @readonly + * @since 3.0.0 + */ + this.isPaused = false; + + /** + * A property that holds the value of sound's actual playback rate, + * after its rate and detune values has been combined with global + * rate and detune values. + * + * @name Phaser.Sound.BaseSound#totalRate + * @type {number} + * @default 1 + * @readonly + * @since 3.0.0 + */ + this.totalRate = 1; + + /** + * A value representing the duration, in seconds. + * It could be total sound duration or a marker duration. + * + * @name Phaser.Sound.BaseSound#duration + * @type {number} + * @readonly + * @since 3.0.0 + */ + this.duration = this.duration || 0; + + /** + * The total duration of the sound in seconds. + * + * @name Phaser.Sound.BaseSound#totalDuration + * @type {number} + * @readonly + * @since 3.0.0 + */ + this.totalDuration = this.totalDuration || 0; + + /** + * A config object used to store default sound settings' values. + * Default values will be set by properties' setters. + * + * @name Phaser.Sound.BaseSound#config + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.config = { + + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + + }; + + /** + * Reference to the currently used config. + * It could be default config or marker config. + * + * @name Phaser.Sound.BaseSound#currentConfig + * @type {SoundConfig} + * @private + * @since 3.0.0 + */ + this.currentConfig = this.config; + + this.config = Extend(this.config, config); + + /** + * Object containing markers definitions. + * + * @name Phaser.Sound.BaseSound#markers + * @type {Object.} + * @default {} + * @readonly + * @since 3.0.0 + */ + this.markers = {}; + + /** + * Currently playing marker. + * 'null' if whole sound is playing. + * + * @name Phaser.Sound.BaseSound#currentMarker + * @type {SoundMarker} + * @default null + * @readonly + * @since 3.0.0 + */ + this.currentMarker = null; + + /** + * Flag indicating if destroy method was called on this sound. + * + * @name Phaser.Sound.BaseSound#pendingRemove + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this.pendingRemove = false; + }, + + /** + * Adds a marker into the current sound. A marker is represented by name, start time, duration, and optionally config object. + * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. + * + * @method Phaser.Sound.BaseSound#addMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object. + * + * @return {boolean} Whether the marker was added successfully. + */ + addMarker: function (marker) + { + if (!marker || !marker.name || typeof marker.name !== 'string') + { + return false; + } + + if (this.markers[marker.name]) + { + // eslint-disable-next-line no-console + console.error('addMarker ' + marker.name + ' already exists in Sound'); + + return false; + } + + marker = Extend(true, { + name: '', + start: 0, + duration: this.totalDuration - (marker.start || 0), + config: { + mute: false, + volume: 1, + rate: 1, + detune: 0, + seek: 0, + loop: false, + delay: 0 + } + }, marker); + + this.markers[marker.name] = marker; + + return true; + }, + + /** + * Updates previously added marker. + * + * @method Phaser.Sound.BaseSound#updateMarker + * @since 3.0.0 + * + * @param {SoundMarker} marker - Marker object with updated values. + * + * @return {boolean} Whether the marker was updated successfully. + */ + updateMarker: function (marker) + { + if (!marker || !marker.name || typeof marker.name !== 'string') + { + return false; + } + + if (!this.markers[marker.name]) + { + // eslint-disable-next-line no-console + console.warn('Audio Marker: ' + marker.name + ' missing in Sound: ' + this.key); + + return false; + } + + this.markers[marker.name] = Extend(true, this.markers[marker.name], marker); + + return true; + }, + + /** + * Removes a marker from the sound. + * + * @method Phaser.Sound.BaseSound#removeMarker + * @since 3.0.0 + * + * @param {string} markerName - The name of the marker to remove. + * + * @return {?SoundMarker} Removed marker object or 'null' if there was no marker with provided name. + */ + removeMarker: function (markerName) + { + var marker = this.markers[markerName]; + + if (!marker) + { + return null; + } + + this.markers[markerName] = null; + + return marker; + }, + + /** + * Play this sound, or a marked section of it. + * It always plays the sound from the start. If you want to start playback from a specific time + * you can set 'seek' setting of the config object, provided to this call, to that value. + * + * @method Phaser.Sound.BaseSound#play + * @since 3.0.0 + * + * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. + * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (markerName, config) + { + if (markerName === undefined) { markerName = ''; } + + if (typeof markerName === 'object') + { + config = markerName; + markerName = ''; + } + + if (typeof markerName !== 'string') + { + return false; + } + + if (!markerName) + { + this.currentMarker = null; + this.currentConfig = this.config; + this.duration = this.totalDuration; + } + else + { + if (!this.markers[markerName]) + { + // eslint-disable-next-line no-console + console.warn('Marker: ' + markerName + ' missing in Sound: ' + this.key); + + return false; + } + + this.currentMarker = this.markers[markerName]; + this.currentConfig = this.currentMarker.config; + this.duration = this.currentMarker.duration; + } + + this.resetConfig(); + + this.currentConfig = Extend(this.currentConfig, config); + + this.isPlaying = true; + this.isPaused = false; + + return true; + }, + + /** + * Pauses the sound. + * + * @method Phaser.Sound.BaseSound#pause + * @since 3.0.0 + * + * @return {boolean} Whether the sound was paused successfully. + */ + pause: function () + { + if (this.isPaused || !this.isPlaying) + { + return false; + } + + this.isPlaying = false; + this.isPaused = true; + + return true; + }, + + /** + * Resumes the sound. + * + * @method Phaser.Sound.BaseSound#resume + * @since 3.0.0 + * + * @return {boolean} Whether the sound was resumed successfully. + */ + resume: function () + { + if (!this.isPaused || this.isPlaying) + { + return false; + } + + this.isPlaying = true; + this.isPaused = false; + + return true; + }, + + /** + * Stop playing this sound. + * + * @method Phaser.Sound.BaseSound#stop + * @since 3.0.0 + * + * @return {boolean} Whether the sound was stopped successfully. + */ + stop: function () + { + if (!this.isPaused && !this.isPlaying) + { + return false; + } + + this.isPlaying = false; + this.isPaused = false; + + this.resetConfig(); + + return true; + }, + + /** + * Method used internally for applying config values to some of the sound properties. + * + * @method Phaser.Sound.BaseSound#applyConfig + * @protected + * @since 3.0.0 + */ + applyConfig: function () + { + this.mute = this.currentConfig.mute; + this.volume = this.currentConfig.volume; + this.rate = this.currentConfig.rate; + this.detune = this.currentConfig.detune; + this.loop = this.currentConfig.loop; + }, + + /** + * Method used internally for resetting values of some of the config properties. + * + * @method Phaser.Sound.BaseSound#resetConfig + * @protected + * @since 3.0.0 + */ + resetConfig: function () + { + this.currentConfig.seek = 0; + this.currentConfig.delay = 0; + }, + + /** + * Update method called automatically by sound manager on every game step. + * + * @method Phaser.Sound.BaseSound#update + * @override + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: NOOP, + + /** + * Method used internally to calculate total playback rate of the sound. + * + * @method Phaser.Sound.BaseSound#calculateRate + * @protected + * @since 3.0.0 + */ + calculateRate: function () + { + var cent = 1.0005777895065548; // Math.pow(2, 1/1200); + var totalDetune = this.currentConfig.detune + this.manager.detune; + var detuneRate = Math.pow(cent, totalDetune); + + this.totalRate = this.currentConfig.rate * this.manager.rate * detuneRate; + }, + + /** + * Destroys this sound and all associated events and marks it for removal from the sound manager. + * + * @method Phaser.Sound.BaseSound#destroy + * @since 3.0.0 + */ + destroy: function () + { + if (this.pendingRemove) + { + return; + } + + this.emit('destroy', this); + this.pendingRemove = true; + this.manager = null; + this.key = ''; + this.removeAllListeners(); + this.isPlaying = false; + this.isPaused = false; + this.config = null; + this.currentConfig = null; + this.markers = null; + this.currentMarker = null; + } + +}); + +module.exports = BaseSound; + + +/***/ }), +/* 115 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Pavle Goloskokovic (http://prunegames.com) + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Clone = __webpack_require__(63); +var EventEmitter = __webpack_require__(11); +var NOOP = __webpack_require__(1); + +/** + * @callback EachActiveSoundCallback + * + * @param {Phaser.Sound.BaseSoundManager} manager - The SoundManager + * @param {Phaser.Sound.BaseSound} sound - The current active Sound + * @param {number} index - The index of the current active Sound + * @param {Phaser.Sound.BaseSound[]} sounds - All sounds + */ + +/** + * Audio sprite sound type. + * + * @typedef {Phaser.Sound.BaseSound} Phaser.Sound.BaseSound.AudioSpriteSound + * + * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. + */ + +/** + * @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 + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Sound + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - Reference to the current game instance. + */ +var BaseSoundManager = new Class({ + + Extends: EventEmitter, + + initialize: + + function BaseSoundManager (game) + { + EventEmitter.call(this); + + /** + * Local reference to game. + * + * @name Phaser.Sound.BaseSoundManager#game + * @type {Phaser.Game} + * @readonly + * @since 3.0.0 + */ + this.game = game; + + /** + * Local reference to the JSON Cache, as used by Audio Sprites. + * + * @name Phaser.Sound.BaseSoundManager#jsonCache + * @type {Phaser.Cache.BaseCache} + * @readonly + * @since 3.7.0 + */ + this.jsonCache = game.cache.json; + + /** + * An array containing all added sounds. + * + * @name Phaser.Sound.BaseSoundManager#sounds + * @type {Phaser.Sound.BaseSound[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.sounds = []; + + /** + * Global mute setting. + * + * @name Phaser.Sound.BaseSoundManager#mute + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.mute = false; + + /** + * Global volume setting. + * + * @name Phaser.Sound.BaseSoundManager#volume + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.volume = 1; + + /** + * Flag indicating if sounds should be paused when game looses focus, + * for instance when user switches to another tab/program/app. + * + * @name Phaser.Sound.BaseSoundManager#pauseOnBlur + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.pauseOnBlur = true; + + /** + * Property that actually holds the value of global playback rate. + * + * @name Phaser.Sound.BaseSoundManager#_rate + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._rate = 1; + + /** + * Property that actually holds the value of global detune. + * + * @name Phaser.Sound.BaseSoundManager#_detune + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._detune = 0; + + /** + * Mobile devices require sounds to be triggered from an explicit user action, + * such as a tap, before any sound can be loaded/played on a web page. + * Set to true if the audio system is currently locked awaiting user interaction. + * + * @name Phaser.Sound.BaseSoundManager#locked + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.locked = this.locked || false; + + /** + * Flag used internally for handling when the audio system + * has been unlocked, if there ever was a need for it. + * + * @name Phaser.Sound.BaseSoundManager#unlocked + * @type {boolean} + * @default false + * @private + * @since 3.0.0 + */ + this.unlocked = false; + + game.events.on('blur', function () + { + if (this.pauseOnBlur) + { + this.onBlur(); + } + }, this); + + game.events.on('focus', function () + { + if (this.pauseOnBlur) + { + this.onFocus(); + } + }, this); + + game.events.on('prestep', this.update, this); + game.events.once('destroy', this.destroy, this); + }, + + /** + * Adds a new sound into the sound manager. + * + * @method Phaser.Sound.BaseSoundManager#add + * @override + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.BaseSound} The new sound instance. + */ + add: NOOP, + + /** + * Adds a new audio sprite sound into the sound manager. + * Audio Sprites are a combination of audio files and a JSON configuration. + * The JSON follows the format of that created by https://github.com/tonistiigi/audiosprite + * + * @method Phaser.Sound.BaseSoundManager#addAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {Phaser.Sound.BaseSound.AudioSpriteSound} The new audio sprite sound instance. + */ + addAudioSprite: function (key, config) + { + if (config === undefined) { config = {}; } + + var sound = this.add(key, config); + + sound.spritemap = this.jsonCache.get(key).spritemap; + + for (var markerName in sound.spritemap) + { + if (!sound.spritemap.hasOwnProperty(markerName)) + { + continue; + } + + var markerConfig = Clone(config); + + var marker = sound.spritemap[markerName]; + + markerConfig.loop = (marker.hasOwnProperty('loop')) ? marker.loop : false; + + sound.addMarker({ + name: markerName, + start: marker.start, + duration: marker.end - marker.start, + config: markerConfig + }); + } + + return sound; + }, + + /** + * Enables playing sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#play + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {(SoundConfig|SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. + * + * @return {boolean} Whether the sound started playing successfully. + */ + play: function (key, extra) + { + var sound = this.add(key); + + sound.once('ended', sound.destroy, sound); + + if (extra) + { + if (extra.name) + { + sound.addMarker(extra); + + return sound.play(extra.name); + } + else + { + return sound.play(extra); + } + } + else + { + return sound.play(); + } + }, + + /** + * Enables playing audio sprite sound on the fly without the need to keep a reference to it. + * Sound will auto destroy once its playback ends. + * + * @method Phaser.Sound.BaseSoundManager#playAudioSprite + * @since 3.0.0 + * + * @param {string} key - Asset key for the sound. + * @param {string} spriteName - The name of the sound sprite to play. + * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * + * @return {boolean} Whether the audio sprite sound started playing successfully. + */ + playAudioSprite: function (key, spriteName, config) + { + var sound = this.addAudioSprite(key); + + sound.once('ended', sound.destroy, sound); + + return sound.play(spriteName, config); + }, + + /** + * Removes a sound from the sound manager. + * The removed sound is destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#remove + * @since 3.0.0 + * + * @param {Phaser.Sound.BaseSound} sound - The sound object to remove. + * + * @return {boolean} True if the sound was removed successfully, otherwise false. + */ + remove: function (sound) + { + var index = this.sounds.indexOf(sound); + + if (index !== -1) + { + sound.destroy(); + + this.sounds.splice(index, 1); + + return true; + } + + return false; + }, + + /** + * Removes all sounds from the sound manager that have an asset key matching the given value. + * The removed sounds are destroyed before removal. + * + * @method Phaser.Sound.BaseSoundManager#removeByKey + * @since 3.0.0 + * + * @param {string} key - The key to match when removing sound objects. + * + * @return {number} The number of matching sound objects that were removed. + */ + removeByKey: function (key) + { + var removed = 0; + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + var sound = this.sounds[i]; + + if (sound.key === key) + { + sound.destroy(); + + this.sounds.splice(i, 1); + + removed++; + } + } + + return removed; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#pauseall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Pauses all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#pauseAll + * @fires Phaser.Sound.BaseSoundManager#pauseall + * @since 3.0.0 + */ + pauseAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.pause(); + }); + + this.emit('pauseall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#resumeall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Resumes all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#resumeAll + * @fires Phaser.Sound.BaseSoundManager#resumeall + * @since 3.0.0 + */ + resumeAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.resume(); + }); + + this.emit('resumeall', this); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#stopall + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + + /** + * Stops all the sounds in the game. + * + * @method Phaser.Sound.BaseSoundManager#stopAll + * @fires Phaser.Sound.BaseSoundManager#stopall + * @since 3.0.0 + */ + stopAll: function () + { + this.forEachActiveSound(function (sound) + { + sound.stop(); + }); + + this.emit('stopall', this); + }, + + /** + * Method used internally for unlocking audio playback on devices that + * require user interaction before any sound can be played on a web page. + * + * Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09). + * + * @method Phaser.Sound.BaseSoundManager#unlock + * @override + * @protected + * @since 3.0.0 + */ + unlock: NOOP, + + /** + * Method used internally for pausing sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onBlur + * @override + * @protected + * @since 3.0.0 + */ + onBlur: NOOP, + + /** + * Method used internally for resuming sound manager if + * Phaser.Sound.BaseSoundManager#pauseOnBlur is set to true. + * + * @method Phaser.Sound.BaseSoundManager#onFocus + * @override + * @protected + * @since 3.0.0 + */ + onFocus: NOOP, + + /** + * Update method called on every game step. + * Removes destroyed sounds and updates every active sound in the game. + * + * @method Phaser.Sound.BaseSoundManager#update + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param {number} delta - The delta time elapsed since the last frame. + */ + update: function (time, delta) + { + if (this.unlocked) + { + this.unlocked = false; + this.locked = false; + + /** + * @event Phaser.Sound.BaseSoundManager#unlocked + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + */ + this.emit('unlocked', this); + } + + for (var i = this.sounds.length - 1; i >= 0; i--) + { + if (this.sounds[i].pendingRemove) + { + this.sounds.splice(i, 1); + } + } + + this.sounds.forEach(function (sound) + { + sound.update(time, delta); + }); + }, + + /** + * Destroys all the sounds in the game and all associated events. + * + * @method Phaser.Sound.BaseSoundManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.forEachActiveSound(function (sound) + { + sound.destroy(); + }); + + this.sounds.length = 0; + this.sounds = null; + + this.game = null; + }, + + /** + * Method used internally for iterating only over active sounds and skipping sounds that are marked for removal. + * + * @method Phaser.Sound.BaseSoundManager#forEachActiveSound + * @private + * @since 3.0.0 + * + * @param {EachActiveSoundCallback} callback - Callback function. (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Manager.BaseSound[]) => void + * @param {*} [scope] - Callback context. + */ + forEachActiveSound: function (callback, scope) + { + var _this = this; + + this.sounds.forEach(function (sound, index) + { + if (!sound.pendingRemove) + { + callback.call(scope || _this, sound, index, _this.sounds); + } + }); + }, + + /** + * @event Phaser.Sound.BaseSoundManager#rate + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#rate property. + */ + + /** + * 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. + * + * @method Phaser.Sound.BaseSoundManager#setRate + * @fires Phaser.Sound.BaseSoundManager#rate + * @since 3.3.0 + * + * @param {number} value - Global playback rate at which all the sounds will be played. + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setRate: function (value) + { + this.rate = value; + + return this; + }, + + /** + * Global playback rate at which all the sounds will be played. + * Value of 1.0 plays the audio at full speed, 0.5 plays the audio at half speed + * and 2.0 doubles the audio's playback speed. + * + * @name Phaser.Sound.BaseSoundManager#rate + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rate: { + + get: function () + { + return this._rate; + }, + + set: function (value) + { + this._rate = value; + + this.forEachActiveSound(function (sound) + { + sound.calculateRate(); + }); + + this.emit('rate', this, value); + } + + }, + + /** + * Sets the global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @method Phaser.Sound.BaseSoundManager#setDetune + * @fires Phaser.Sound.BaseSoundManager#detune + * @since 3.3.0 + * + * @param {number} value - The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @return {Phaser.Sound.BaseSoundManager} This Sound Manager. + */ + setDetune: function (value) + { + this.detune = value; + + return this; + }, + + /** + * @event Phaser.Sound.BaseSoundManager#detune + * @param {Phaser.Sound.BaseSoundManager} soundManager - Reference to the sound manager that emitted event. + * @param {number} value - An updated value of Phaser.Sound.BaseSoundManager#detune property. + */ + + /** + * Global detuning of all sounds in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * The range of the value is -1200 to 1200, but we recommend setting it to [50](https://en.wikipedia.org/wiki/50_Cent). + * + * @name Phaser.Sound.BaseSoundManager#detune + * @type {number} + * @default 0 + * @since 3.0.0 + */ + detune: { + + get: function () + { + return this._detune; + }, + + set: function (value) + { + this._detune = value; + + this.forEachActiveSound(function (sound) + { + sound.calculateRate(); + }); + + this.emit('detune', this, value); + } + + } + +}); + +module.exports = BaseSoundManager; + + +/***/ }), +/* 116 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Scene consts. + * + * @ignore + */ + +var CONST = { + + /** + * Scene state. + * + * @name Phaser.Scenes.PENDING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + PENDING: 0, + + /** + * Scene state. + * + * @name Phaser.Scenes.INIT + * @readonly + * @type {integer} + * @since 3.0.0 + */ + INIT: 1, + + /** + * Scene state. + * + * @name Phaser.Scenes.START + * @readonly + * @type {integer} + * @since 3.0.0 + */ + START: 2, + + /** + * Scene state. + * + * @name Phaser.Scenes.LOADING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + LOADING: 3, + + /** + * Scene state. + * + * @name Phaser.Scenes.CREATING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + CREATING: 4, + + /** + * Scene state. + * + * @name Phaser.Scenes.RUNNING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + RUNNING: 5, + + /** + * Scene state. + * + * @name Phaser.Scenes.PAUSED + * @readonly + * @type {integer} + * @since 3.0.0 + */ + PAUSED: 6, + + /** + * Scene state. + * + * @name Phaser.Scenes.SLEEPING + * @readonly + * @type {integer} + * @since 3.0.0 + */ + SLEEPING: 7, + + /** + * Scene state. + * + * @name Phaser.Scenes.SHUTDOWN + * @readonly + * @type {integer} + * @since 3.0.0 + */ + SHUTDOWN: 8, + + /** + * Scene state. + * + * @name Phaser.Scenes.DESTROYED + * @readonly + * @type {integer} + * @since 3.0.0 + */ + DESTROYED: 9 + +}; + +module.exports = CONST; + + +/***/ }), +/* 117 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks if the given `width` and `height` are a power of two. + * Useful for checking texture dimensions. + * + * @function Phaser.Math.Pow2.IsSizePowerOfTwo + * @since 3.0.0 + * + * @param {number} width - The width. + * @param {number} height - The height. + * + * @return {boolean} `true` if `width` and `height` are a power of two, otherwise `false`. + */ +var IsSizePowerOfTwo = function (width, height) +{ + return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0); +}; + +module.exports = IsSizePowerOfTwo; + + +/***/ }), +/* 118 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(92); + +/** + * Determines the browser type and version running this Phaser Game instance. + * These values are read-only and populated during the boot sequence of the game. + * They are then referenced by internal game systems and are available for you to access + * via `this.sys.game.device.browser` from within any Scene. + * + * @typedef {object} Phaser.Device.Browser + * @since 3.0.0 + * + * @property {boolean} chrome - Set to true if running in Chrome. + * @property {boolean} edge - Set to true if running in Microsoft Edge browser. + * @property {boolean} firefox - Set to true if running in Firefox. + * @property {boolean} ie - Set to true if running in Internet Explorer 11 or less (not Edge). + * @property {boolean} mobileSafari - Set to true if running in Mobile Safari. + * @property {boolean} opera - Set to true if running in Opera. + * @property {boolean} safari - Set to true if running in Safari. + * @property {boolean} silk - Set to true if running in the Silk browser (as used on the Amazon Kindle) + * @property {boolean} trident - Set to true if running a Trident version of Internet Explorer (IE11+) + * @property {number} chromeVersion - If running in Chrome this will contain the major version number. + * @property {number} firefoxVersion - If running in Firefox this will contain the major version number. + * @property {number} ieVersion - If running in Internet Explorer this will contain the major version number. Beyond IE10 you should use Browser.trident and Browser.tridentVersion. + * @property {number} safariVersion - If running in Safari this will contain the major version number. + * @property {number} tridentVersion - If running in Internet Explorer 11 this will contain the major version number. See {@link http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx} + */ +var Browser = { + + chrome: false, + chromeVersion: 0, + edge: false, + firefox: false, + firefoxVersion: 0, + ie: false, + ieVersion: 0, + mobileSafari: false, + opera: false, + safari: false, + safariVersion: 0, + silk: false, + trident: false, + tridentVersion: 0 + +}; + +function init () +{ + var ua = navigator.userAgent; + + if (/Edge\/\d+/.test(ua)) + { + Browser.edge = true; + } + else if ((/Chrome\/(\d+)/).test(ua) && !OS.windowsPhone) + { + Browser.chrome = true; + Browser.chromeVersion = parseInt(RegExp.$1, 10); + } + else if ((/Firefox\D+(\d+)/).test(ua)) + { + Browser.firefox = true; + Browser.firefoxVersion = parseInt(RegExp.$1, 10); + } + else if ((/AppleWebKit/).test(ua) && OS.iOS) + { + Browser.mobileSafari = true; + } + else if ((/MSIE (\d+\.\d+);/).test(ua)) + { + Browser.ie = true; + Browser.ieVersion = parseInt(RegExp.$1, 10); + } + else if ((/Opera/).test(ua)) + { + Browser.opera = true; + } + else if ((/Safari/).test(ua) && !OS.windowsPhone) + { + Browser.safari = true; + } + else if ((/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/).test(ua)) + { + Browser.ie = true; + Browser.trident = true; + Browser.tridentVersion = parseInt(RegExp.$1, 10); + Browser.ieVersion = parseInt(RegExp.$3, 10); + } + + // Silk gets its own if clause because its ua also contains 'Safari' + if ((/Silk/).test(ua)) + { + Browser.silk = true; + } + + return Browser; +} + +module.exports = init(); + + +/***/ }), +/* 119 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates a linear (interpolation) value over t. + * + * @function Phaser.Math.Linear + * @since 3.0.0 + * + * @param {number} p0 - The first point. + * @param {number} p1 - The second point. + * @param {number} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. + * + * @return {number} The step t% of the way between p0 and p1. + */ +var Linear = function (p0, p1, t) +{ + return (p1 - p0) * t + p0; +}; + +module.exports = Linear; + + +/***/ }), +/* 120 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Browser specific prefix, so not going to change between contexts, only between browsers +var prefix = ''; + +/** + * @namespace Phaser.Display.Canvas.Smoothing + * @since 3.0.0 + */ +var Smoothing = function () +{ + /** + * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. + * + * @function Phaser.Display.Canvas.Smoothing.getPrefix + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {string} [description] + */ + var getPrefix = function (context) + { + var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; + + for (var i = 0; i < vendors.length; i++) + { + var s = vendors[i] + 'mageSmoothingEnabled'; + + if (s in context) + { + return s; + } + } + + return null; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.enable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var enable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = true; + } + + return context; + }; + + /** + * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. + * By default browsers have image smoothing enabled, which isn't always what you visually want, especially + * when using pixel art in a game. Note that this sets the property on the context itself, so that any image + * drawn to the context will be affected. This sets the property across all current browsers but support is + * patchy on earlier browsers, especially on mobile. + * + * @function Phaser.Display.Canvas.Smoothing.disable + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + */ + var disable = function (context) + { + if (prefix === '') + { + prefix = getPrefix(context); + } + + if (prefix) + { + context[prefix] = false; + } + + return context; + }; + + /** + * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. + * Returns null if no smoothing prefix is available. + * + * @function Phaser.Display.Canvas.Smoothing.isEnabled + * @since 3.0.0 + * + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * + * @return {?boolean} [description] + */ + var isEnabled = function (context) + { + return (prefix !== null) ? context[prefix] : null; + }; + + return { + disable: disable, + enable: enable, + getPrefix: getPrefix, + isEnabled: isEnabled + }; + +}; + +module.exports = Smoothing(); + + +/***/ }), +/* 121 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var DegToRad = __webpack_require__(31); +var EventEmitter = __webpack_require__(11); +var Rectangle = __webpack_require__(9); +var TransformMatrix = __webpack_require__(38); +var ValueToColor = __webpack_require__(178); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} JSONCameraBounds + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + */ + +/** + * @typedef {object} JSONCamera + * + * @property {string} name - The name of the camera + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + * @property {number} zoom - The zoom of camera + * @property {number} rotation - The rotation of camera + * @property {boolean} roundPixels - The round pixels st status of camera + * @property {number} scrollX - The horizontal scroll of camera + * @property {number} scrollY - The vertical scroll of camera + * @property {string} backgroundColor - The background color of camera + * @property {(JSONCameraBounds|undefined)} [bounds] - The bounds of camera + */ + +/** + * @classdesc + * A Base Camera class. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * The Base Camera is extended by the Camera class, which adds in special effects including Fade, + * Flash and Camera Shake, as well as the ability to follow Game Objects. + * + * The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow + * you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate + * to when they were added to the Camera class. + * + * @class BaseCamera + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.12.0 + * + * @extends Phaser.Events.EventEmitter + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.Visible + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var BaseCamera = new Class({ + + Extends: EventEmitter, + + Mixins: [ + Components.Alpha, + Components.Visible + ], + + initialize: + + function BaseCamera (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + EventEmitter.call(this); + + /** + * A reference to the Scene this camera belongs to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene; + + /** + * A reference to the Game Scene Manager. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#sceneManager + * @type {Phaser.Scenes.SceneManager} + * @since 3.12.0 + */ + this.sceneManager; + + /** + * A reference to the Game Config. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#config + * @type {object} + * @readonly + * @since 3.12.0 + */ + this.config; + + /** + * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * This value is a bitmask. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#id + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.id = 0; + + /** + * The name of the Camera. This is left empty for your own use. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The resolution of the Game, used in most Camera calculations. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#resolution + * @type {number} + * @readonly + * @since 3.12.0 + */ + this.resolution = 1; + + /** + * Should this camera round its pixel values to integers? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#roundPixels + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.roundPixels = false; + + /** + * Is this Camera visible or not? + * + * A visible camera will render and perform input tests. + * An invisible camera will not render anything and will skip input tests. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#visible + * @type {boolean} + * @default true + * @since 3.10.0 + */ + + /** + * Is this Camera using a bounds to restrict scrolling movement? + * + * Set this property along with the bounds via `Camera.setBounds`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#useBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useBounds = false; + + /** + * The World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. + * This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. + * If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. + * You can use it for culling or intersection checks. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#worldView + * @type {Phaser.Geom.Rectangle} + * @readonly + * @since 3.11.0 + */ + this.worldView = new Rectangle(); + + /** + * Is this Camera dirty? + * + * A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. + * + * This flag is cleared during the `postRenderCamera` method of the renderer. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#dirty + * @type {boolean} + * @default true + * @since 3.11.0 + */ + this.dirty = true; + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#x + * @type {number} + * @private + * @since 3.0.0 + */ + this._x = x; + + /** + * The y position of the Camera, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#y + * @type {number} + * @private + * @since 3.0.0 + */ + this._y = y; + + /** + * Internal Camera X value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cx + * @type {number} + * @private + * @since 3.12.0 + */ + this._cx = 0; + + /** + * Internal Camera Y value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cy + * @type {number} + * @private + * @since 3.12.0 + */ + this._cy = 0; + + /** + * Internal Camera Width value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cw + * @type {number} + * @private + * @since 3.12.0 + */ + this._cw = 0; + + /** + * Internal Camera Height value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_ch + * @type {number} + * @private + * @since 3.12.0 + */ + this._ch = 0; + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_width + * @type {number} + * @private + * @since 3.11.0 + */ + this._width = width; + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_height + * @type {number} + * @private + * @since 3.11.0 + */ + this._height = height; + + /** + * The bounds the camera is restrained to during scrolling. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollX + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollX = 0; + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollY + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollY = 0; + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_zoom + * @type {number} + * @private + * @default 1 + * @since 3.11.0 + */ + this._zoom = 1; + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._rotation = 0; + + /** + * A local transform matrix used for internal calculations. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#matrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.0.0 + */ + this.matrix = new TransformMatrix(); + + /** + * Does this Camera have a transparent background? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#transparent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.transparent = true; + + /** + * The background color of this Camera. Only used if `transparent` is `false`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#backgroundColor + * @type {Phaser.Display.Color} + * @since 3.0.0 + */ + this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); + + /** + * The Camera alpha value. Setting this property impacts every single object that this Camera + * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, + * or via the chainable `setAlpha` method instead. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#alpha + * @type {number} + * @default 1 + * @since 3.11.0 + */ + + /** + * Should the camera cull Game Objects before checking them for input hit tests? + * In some special cases it may be beneficial to disable this. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#disableCull + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.disableCull = false; + + /** + * A temporary array of culled objects. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#culledObjects + * @type {Phaser.GameObjects.GameObject[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.culledObjects = []; + + /** + * The mid-point of the Camera in 'world' coordinates. + * + * Use it to obtain exactly where in the world the center of the camera is currently looking. + * + * This value is updated in the preRender method, after the scroll values and follower + * have been processed. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#midPoint + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.11.0 + */ + this.midPoint = new Vector2(width / 2, height / 2); + + /** + * The horizontal origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originX + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originX = 0.5; + + /** + * The vertical origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originY + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originY = 0.5; + + /** + * Does this Camera have a custom viewport? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_customViewport + * @type {boolean} + * @private + * @default false + * @since 3.12.0 + */ + this._customViewport = false; + }, + + /** + * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAlpha + * @since 3.11.0 + * + * @param {number} [value=1] - The Camera alpha value. + * + * @return {this} This Camera instance. + */ + + /** + * Sets the rotation origin of this Camera. + * + * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setOrigin + * @since 3.11.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Camera instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this; + }, + + /** + * Calculates what the Camera.scrollX and scrollY values would need to be in order to move + * the Camera so it is centered on the given x and y coordinates, without actually moving + * the Camera there. The results are clamped based on the Camera bounds, if set. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getScroll + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {Phaser.Math.Vector2} [out] - A Vec2 to store the values in. If not given a new Vec2 is created. + * + * @return {Phaser.Math.Vector2} The scroll coordinates stored in the `x` abd `y` properties. + */ + getScroll: function (x, y, out) + { + if (out === undefined) { out = new Vector2(); } + + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + out.x = x - originX; + out.y = y - originY; + + if (this.useBounds) + { + out.x = this.clampX(out.x); + out.y = this.clampY(out.y); + } + + return out; + }, + + /** + * Moves the Camera so that it is centered on the given coordinates, bounds allowing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerOn + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerOn: function (x, y) + { + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + this.midPoint.set(x, y); + + this.scrollX = x - originX; + this.scrollY = y - originY; + + if (this.useBounds) + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerToBounds: function () + { + if (this.useBounds) + { + var bounds = this._bounds; + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + this.midPoint.set(bounds.centerX, bounds.centerY); + + this.scrollX = bounds.centerX - originX; + this.scrollY = bounds.centerY - originY; + } + + return this; + }, + + /** + * Moves the Camera so that it is re-centered based on its viewport size. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToSize + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerToSize: function () + { + this.scrollX = this.width * 0.5; + this.scrollY = this.height * 0.5; + + return this; + }, + + /** + * Takes an array of Game Objects and returns a new array featuring only those objects + * visible by this camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#cull + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] + * + * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. + * + * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. + */ + cull: function (renderableObjects) + { + if (this.disableCull) + { + return renderableObjects; + } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return renderableObjects; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var culledObjects = this.culledObjects; + var length = renderableObjects.length; + + determinant = 1 / determinant; + + culledObjects.length = 0; + + for (var index = 0; index < length; ++index) + { + var object = renderableObjects[index]; + + if (!object.hasOwnProperty('width') || object.parentContainer) + { + culledObjects.push(object); + continue; + } + + var objectW = object.width; + var objectH = object.height; + var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); + var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); + var tx = (objectX * mva + objectY * mvc + mve); + var ty = (objectX * mvb + objectY * mvd + mvf); + var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); + var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); + var cullW = cameraW + objectW; + var cullH = cameraH + objectH; + + if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH && + tw > -objectW && th > -objectH && tw < cullW && th < cullH) + { + culledObjects.push(object); + } + } + + return culledObjects; + }, + + /** + * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. + * You can optionally provide a Vector2, or similar object, to store the results in. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getWorldPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {number} x - The x position to convert to world space. + * @param {number} y - The y position to convert to world space. + * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. + */ + getWorldPoint: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + // Invert Matrix + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + output.x = x; + output.y = y; + + return output; + } + + determinant = 1 / determinant; + + var ima = mvd * determinant; + var imb = -mvb * determinant; + var imc = -mvc * determinant; + var imd = mva * determinant; + var ime = (mvc * mvf - mvd * mve) * determinant; + var imf = (mvb * mve - mva * mvf) * determinant; + + var c = Math.cos(this.rotation); + var s = Math.sin(this.rotation); + + var zoom = this.zoom; + var res = this.resolution; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + + // Works for zoom of 1 with any resolution, but resolution > 1 and zoom !== 1 breaks + var sx = x + ((scrollX * c - scrollY * s) * zoom); + var sy = y + ((scrollX * s + scrollY * c) * zoom); + + // Apply transform to point + output.x = (sx * ima + sy * imc) * res + ime; + output.y = (sx * imb + sy * imd) * res + imf; + + return output; + }, + + /** + * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings + * so that they are ignored by this Camera. This means they will not be rendered by this Camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#ignore + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group)} entries - The Game Object, or array of Game Objects, to be ignored by this Camera. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + ignore: function (entries) + { + var id = this.id; + + if (!Array.isArray(entries)) + { + entries = [ entries ]; + } + + for (var i = 0; i < entries.length; i++) + { + var entry = entries[i]; + + if (Array.isArray(entry)) + { + this.ignore(entry); + } + else if (entry.isParent) + { + this.ignore(entry.getChildren()); + } + else + { + entry.cameraFilter |= id; + } + } + + return this; + }, + + /** + * Internal preRender step. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#preRender + * @protected + * @since 3.0.0 + * + * @param {number} baseScale - The base scale, as set in the Camera Manager. + * @param {number} resolution - The game resolution. + */ + preRender: function (baseScale, resolution) + { + var width = this.width; + var height = this.height; + + var halfWidth = width * 0.5; + var halfHeight = height * 0.5; + + var zoom = this.zoom * baseScale; + var matrix = this.matrix; + + var originX = width * this.originX; + var originY = height * this.originY; + + var sx = this.scrollX; + var sy = this.scrollY; + + if (this.useBounds) + { + sx = this.clampX(sx); + sy = this.clampY(sy); + } + + if (this.roundPixels) + { + originX = Math.round(originX); + originY = Math.round(originY); + } + + // Values are in pixels and not impacted by zooming the Camera + this.scrollX = sx; + this.scrollY = sy; + + var midX = sx + halfWidth; + var midY = sy + halfHeight; + + // The center of the camera, in world space, so taking zoom into account + // Basically the pixel value of what it's looking at in the middle of the cam + this.midPoint.set(midX, midY); + + var displayWidth = width / zoom; + var displayHeight = height / zoom; + + this.worldView.setTo( + midX - (displayWidth / 2), + midY - (displayHeight / 2), + displayWidth, + displayHeight + ); + + matrix.loadIdentity(); + matrix.scale(resolution, resolution); + matrix.translate(this.x + originX, this.y + originY); + matrix.rotate(this.rotation); + matrix.scale(zoom, zoom); + matrix.translate(-originX, -originY); + }, + + /** + * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampX + * @since 3.11.0 + * + * @param {number} x - The value to horizontally scroll clamp. + * + * @return {number} The adjusted value to use as scrollX. + */ + clampX: function (x) + { + var bounds = this._bounds; + + var dw = this.displayWidth; + + var bx = bounds.x + ((dw - this.width) / 2); + var bw = Math.max(bx, bx + bounds.width - dw); + + if (x < bx) + { + x = bx; + } + else if (x > bw) + { + x = bw; + } + + return x; + }, + + /** + * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampY + * @since 3.11.0 + * + * @param {number} y - The value to vertically scroll clamp. + * + * @return {number} The adjusted value to use as scrollY. + */ + clampY: function (y) + { + var bounds = this._bounds; + + var dh = this.displayHeight; + + var by = bounds.y + ((dh - this.height) / 2); + var bh = Math.max(by, by + bounds.height - dh); + + if (y < by) + { + y = by; + } + else if (y > bh) + { + y = bh; + } + + return y; + }, + + /* + var gap = this._zoomInversed; + return gap * Math.round((src.x - this.scrollX * src.scrollFactorX) / gap); + */ + + /** + * If this Camera has previously had movement bounds set on it, this will remove them. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#removeBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + removeBounds: function () + { + this.useBounds = false; + + this.dirty = true; + + this._bounds.setEmpty(); + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAngle + * @since 3.0.0 + * + * @param {number} [value=0] - The cameras angle of rotation, given in degrees. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setAngle: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = DegToRad(value); + + return this; + }, + + /** + * Sets the background color for this Camera. + * + * By default a Camera has a transparent background but it can be given a solid color, with any level + * of transparency, via this method. + * + * The color value can be specified using CSS color notation, hex or numbers. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBackgroundColor + * @since 3.0.0 + * + * @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setBackgroundColor: function (color) + { + if (color === undefined) { color = 'rgba(0,0,0,0)'; } + + this.backgroundColor = ValueToColor(color); + + this.transparent = (this.backgroundColor.alpha === 0); + + return this; + }, + + /** + * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. + * + * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the + * edges and into blank space. It does not limit the placement of Game Objects, or where + * the Camera viewport can be positioned. + * + * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. + * + * Clear the bounds entirely by calling `Camera.removeBounds`. + * + * If you set bounds that are smaller than the viewport it will stop the Camera from being + * able to scroll. The bounds can be positioned where-ever you wish. By default they are from + * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of + * the Camera bounds. However, you can position them anywhere. So if you wanted a game world + * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y + * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find + * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBounds + * @since 3.0.0 + * + * @param {integer} x - The top-left x coordinate of the bounds. + * @param {integer} y - The top-left y coordinate of the bounds. + * @param {integer} width - The width of the bounds, in pixels. + * @param {integer} height - The height of the bounds, in pixels. + * @param {boolean} [centerOn] - If `true` the Camera will automatically be centered on the new bounds. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setBounds: function (x, y, width, height, centerOn) + { + this._bounds.setTo(x, y, width, height); + + this.dirty = true; + this.useBounds = true; + + if (centerOn) + { + this.centerToBounds(); + } + else + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Sets the name of this Camera. + * This value is for your own use and isn't used internally. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setName + * @since 3.0.0 + * + * @param {string} [value=''] - The name of the Camera. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setName: function (value) + { + if (value === undefined) { value = ''; } + + this.name = value; + + return this; + }, + + /** + * Set the position of the Camera viewport within the game. + * + * This does not change where the camera is 'looking'. See `setScroll` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setPosition + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRotation + * @since 3.0.0 + * + * @param {number} [value=0] - The rotation of the Camera, in radians. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setRotation: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = value; + + return this; + }, + + /** + * Should the Camera round pixel values to whole integers when rendering Game Objects? + * + * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRoundPixels + * @since 3.0.0 + * + * @param {boolean} value - `true` to round Camera pixels, `false` to not. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setRoundPixels: function (value) + { + this.roundPixels = value; + + return this; + }, + + /** + * Sets the Scene the Camera is bound to. + * + * Also populates the `resolution` property and updates the internal size values. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene the camera is bound to. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setScene: function (scene) + { + if (this.scene && this._customViewport) + { + this.sceneManager.customViewports--; + } + + this.scene = scene; + + this.config = scene.sys.game.config; + this.sceneManager = scene.sys.game.scene; + + var res = this.config.resolution; + + this.resolution = res; + + this._cx = this._x * res; + this._cy = this._y * res; + this._cw = this._width * res; + this._ch = this._height * res; + + this.updateSystem(); + + return this; + }, + + /** + * Set the position of where the Camera is looking within the game. + * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. + * Use this method, or the scroll properties, to move your camera around the game world. + * + * This does not change where the camera viewport is placed. See `setPosition` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScroll + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the Camera in the game world. + * @param {number} [y=x] - The y coordinate of the Camera in the game world. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setScroll: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollX = x; + this.scrollY = y; + + return this; + }, + + /** + * Set the size of the Camera viewport. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setSize + * @since 3.0.0 + * + * @param {integer} width - The width of the Camera viewport. + * @param {integer} [height=width] - The height of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * This method sets the position and size of the Camera viewport in a single call. + * + * If you're trying to change where the Camera is looking at in your game, then see + * the method `Camera.setScroll` instead. This method is for changing the viewport + * itself, not what the camera can see. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setViewport + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} y - The top-left y coordinate of the Camera viewport. + * @param {integer} width - The width of the Camera viewport. + * @param {integer} [height=width] - The height of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setViewport: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Set the zoom value of the Camera. + * + * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. + * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. + * + * A value of 1 means 'no zoom' and is the default. + * + * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setZoom + * @since 3.0.0 + * + * @param {number} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setZoom: function (value) + { + if (value === undefined) { value = 1; } + + if (value === 0) + { + value = 0.001; + } + + this.zoom = value; + + return this; + }, + + /** + * Sets the visibility of this Camera. + * + * An invisible Camera will skip rendering and input tests of everything it can see. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setVisible + * @since 3.10.0 + * + * @param {boolean} value - The visible state of the Camera. + * + * @return {this} This Camera instance. + */ + + /** + * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#toJSON + * @since 3.0.0 + * + * @return {JSONCamera} A well-formed object suitable for conversion to JSON. + */ + toJSON: function () + { + var output = { + name: this.name, + x: this.x, + y: this.y, + width: this.width, + height: this.height, + zoom: this.zoom, + rotation: this.rotation, + roundPixels: this.roundPixels, + scrollX: this.scrollX, + scrollY: this.scrollY, + backgroundColor: this.backgroundColor.rgba + }; + + if (this.useBounds) + { + output['bounds'] = { + x: this._bounds.x, + y: this._bounds.y, + width: this._bounds.width, + height: this._bounds.height + }; + } + + return output; + }, + + /** + * Internal method called automatically by the Camera Manager. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#update + * @protected + * @since 3.0.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 () + { + // NOOP + }, + + /** + * Internal method called automatically when the viewport changes. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#updateSystem + * @private + * @since 3.12.0 + */ + updateSystem: function () + { + if (!this.config) + { + return; + } + + var custom = (this._x !== 0 || this._y !== 0 || this.config.width !== this._width || this.config.height !== this._height); + + var sceneManager = this.sceneManager; + + if (custom && !this._customViewport) + { + // We need a custom viewport for this Camera + sceneManager.customViewports++; + } + else if (!custom && this._customViewport) + { + // We're turning off a custom viewport for this Camera + sceneManager.customViewports--; + } + + this.dirty = true; + this._customViewport = custom; + }, + + /** + * This event is fired when a camera is destroyed by the Camera Manager. + * + * @event CameraDestroyEvent + * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that was destroyed. + */ + + /** + * Destroys this Camera instance and its internal properties and references. + * Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager. + * + * This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default. + * + * Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction, + * rather than calling this method directly. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#destroy + * @fires CameraDestroyEvent + * @since 3.0.0 + */ + destroy: function () + { + this.emit('cameradestroy', this); + + this.removeAllListeners(); + + this.matrix.destroy(); + + this.culledObjects = []; + + if (this._customViewport) + { + // We're turning off a custom viewport for this Camera + this.sceneManager.customViewports--; + } + + this._bounds = null; + + this.scene = null; + this.config = null; + this.sceneManager = null; + }, + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this._x; + }, + + set: function (value) + { + this._x = value; + this._cx = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The y position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this._y; + }, + + set: function (value) + { + this._y = value; + this._cy = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#width + * @type {number} + * @since 3.0.0 + */ + width: { + + get: function () + { + return this._width; + }, + + set: function (value) + { + this._width = value; + this._cw = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#height + * @type {number} + * @since 3.0.0 + */ + height: { + + get: function () + { + return this._height; + }, + + set: function (value) + { + this._height = value; + this._ch = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollX: { + + get: function () + { + return this._scrollX; + }, + + set: function (value) + { + this._scrollX = value; + this.dirty = true; + } + + }, + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollY: { + + get: function () + { + return this._scrollY; + }, + + set: function (value) + { + this._scrollY = value; + this.dirty = true; + } + + }, + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#zoom + * @type {number} + * @default 1 + * @since 3.0.0 + */ + zoom: { + + get: function () + { + return this._zoom; + }, + + set: function (value) + { + this._zoom = value; + this.dirty = true; + } + + }, + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = value; + this.dirty = true; + } + + }, + + /** + * The x position of the center of the Camera's viewport, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerX + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerX: { + + get: function () + { + return this.x + (0.5 * this.width); + } + + }, + + /** + * The y position of the center of the Camera's viewport, relative to the top-left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerY + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerY: { + + get: function () + { + return this.y + (0.5 * this.height); + } + + }, + + /** + * The displayed width of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width + * would be 1600, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a width of 800 and zoom of 2 would have a display width + * of 400 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayWidth + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayWidth: { + + get: function () + { + return this.width / this.zoom; + } + + }, + + /** + * The displayed height of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height + * would be 1200, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a height of 600 and zoom of 2 would have a display height + * of 300 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayHeight + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayHeight: { + + get: function () + { + return this.height / this.zoom; + } + + } + +}); + +module.exports = BaseCamera; + + +/***/ }), +/* 122 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Shuffles the contents of the given array using the Fisher-Yates implementation. + * + * The original array is modified directly and returned. + * + * @function Phaser.Utils.Array.Shuffle + * @since 3.0.0 + * + * @param {array} array - The array to shuffle. This array is modified in place. + * + * @return {array} The shuffled array. + */ +var Shuffle = function (array) +{ + for (var i = array.length - 1; i > 0; i--) + { + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + + return array; +}; + +module.exports = Shuffle; + + +/***/ }), +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback DataEachCallback + * + * @param {*} parent - The parent object of the DataManager. + * @param {string} key - The key of the value. + * @param {*} value - The value. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + */ + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManager + * @memberof Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {object} parent - The object that this DataManager belongs to. + * @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter. + */ +var DataManager = new Class({ + + initialize: + + function DataManager (parent, eventEmitter) + { + /** + * The object that this DataManager belongs to. + * + * @name Phaser.Data.DataManager#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The DataManager's event emitter. + * + * @name Phaser.Data.DataManager#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = eventEmitter; + + if (!eventEmitter) + { + this.events = (parent.events) ? parent.events : parent; + } + + /** + * The data list. + * + * @name Phaser.Data.DataManager#list + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * The public values list. You can use this to access anything you have stored + * in this Data Manager. For example, if you set a value called `gold` you can + * access it via: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also modify it directly: + * + * ```javascript + * this.data.values.gold += 1000; + * ``` + * + * Doing so will emit a `setdata` event from the parent of this Data Manager. + * + * Do not modify this object directly. Adding properties directly to this object will not + * emit any events. Always use `DataManager.set` to create new items the first time around. + * + * @name Phaser.Data.DataManager#values + * @type {Object.} + * @default {} + * @since 3.10.0 + */ + this.values = {}; + + /** + * Whether setting data is frozen for this DataManager. + * + * @name Phaser.Data.DataManager#_frozen + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._frozen = false; + + if (!parent.hasOwnProperty('sys') && this.events) + { + this.events.once('destroy', this.destroy, this); + } + }, + + /** + * Retrieves the value for the given key, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * this.data.get('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * this.data.get([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.Data.DataManager#get + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + get: function (key) + { + var list = this.list; + + if (Array.isArray(key)) + { + var output = []; + + for (var i = 0; i < key.length; i++) + { + output.push(list[key[i]]); + } + + return output; + } + else + { + return list[key]; + } + }, + + /** + * Retrieves all data values in a new object. + * + * @method Phaser.Data.DataManager#getAll + * @since 3.0.0 + * + * @return {Object.} All data values. + */ + getAll: function () + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Queries the DataManager for the values of keys matching the given regular expression. + * + * @method Phaser.Data.DataManager#query + * @since 3.0.0 + * + * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). + * + * @return {Object.} The values of the keys matching the search string. + */ + query: function (search) + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key) && key.match(search)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * data.set('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `get`: + * + * ```javascript + * data.get('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#set + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + set: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (typeof key === 'string') + { + return this.setValue(key, data); + } + else + { + for (var entry in key) + { + this.setValue(entry, key[entry]); + } + } + + return this; + }, + + /** + * Internal value setter, called automatically by the `set` method. + * + * @method Phaser.Data.DataManager#setValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * @param {*} data - The value to set. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setValue: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (this.has(key)) + { + // Hit the key getter, which will in turn emit the events. + this.values[key] = data; + } + else + { + var _this = this; + var list = this.list; + var events = this.events; + var parent = this.parent; + + Object.defineProperty(this.values, key, { + + enumerable: true, + + configurable: true, + + get: function () + { + return list[key]; + }, + + set: function (value) + { + if (!_this._frozen) + { + var previousValue = list[key]; + list[key] = value; + + events.emit('changedata', parent, key, value, previousValue); + events.emit('changedata_' + key, parent, value, previousValue); + } + } + + }); + + list[key] = data; + + events.emit('setdata', parent, key, data); + } + + return this; + }, + + /** + * Passes all data entries to the given callback. + * + * @method Phaser.Data.DataManager#each + * @since 3.0.0 + * + * @param {DataEachCallback} callback - The function to call. + * @param {*} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + each: function (callback, context) + { + var args = [ this.parent, null, undefined ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var key in this.list) + { + args[1] = key; + args[2] = this.list[key]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Merge the given object of key value pairs into this DataManager. + * + * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) + * will emit a `changedata` event. + * + * @method Phaser.Data.DataManager#merge + * @since 3.0.0 + * + * @param {Object.} data - The data to merge. + * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + merge: function (data, overwrite) + { + if (overwrite === undefined) { overwrite = true; } + + // Merge data from another component into this one + for (var key in data) + { + if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) + { + this.setValue(key, data[key]); + } + } + + return this; + }, + + /** + * Remove the value for the given key. + * + * If the key is found in this Data Manager it is removed from the internal lists and a + * `removedata` event is emitted. + * + * You can also pass in an array of keys, in which case all keys in the array will be removed: + * + * ```javascript + * this.data.remove([ 'gold', 'armor', 'health' ]); + * ``` + * + * @method Phaser.Data.DataManager#remove + * @since 3.0.0 + * + * @param {(string|string[])} key - The key to remove, or an array of keys to remove. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + remove: function (key) + { + if (this._frozen) + { + return this; + } + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.removeValue(key[i]); + } + } + else + { + return this.removeValue(key); + } + + return this; + }, + + /** + * Internal value remover, called automatically by the `remove` method. + * + * @method Phaser.Data.DataManager#removeValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + removeValue: function (key) + { + if (this.has(key)) + { + var data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this.parent, key, data); + } + + return this; + }, + + /** + * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. + * + * @method Phaser.Data.DataManager#pop + * @since 3.0.0 + * + * @param {string} key - The key of the value to retrieve and delete. + * + * @return {*} The value of the given key. + */ + pop: function (key) + { + var data = undefined; + + if (!this._frozen && this.has(key)) + { + data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this, key, data); + } + + return data; + }, + + /** + * Determines whether the given key is set in this Data Manager. + * + * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#has + * @since 3.0.0 + * + * @param {string} key - The key to check. + * + * @return {boolean} Returns `true` if the key exists, otherwise `false`. + */ + has: function (key) + { + return this.list.hasOwnProperty(key); + }, + + /** + * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts + * to create new values or update existing ones. + * + * @method Phaser.Data.DataManager#setFreeze + * @since 3.0.0 + * + * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setFreeze: function (value) + { + this._frozen = value; + + return this; + }, + + /** + * Delete all data in this Data Manager and unfreeze it. + * + * @method Phaser.Data.DataManager#reset + * @since 3.0.0 + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + reset: function () + { + for (var key in this.list) + { + delete this.list[key]; + delete this.values[key]; + } + + this._frozen = false; + + return this; + }, + + /** + * Destroy this data manager. + * + * @method Phaser.Data.DataManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + + this.events.off('changedata'); + this.events.off('setdata'); + this.events.off('removedata'); + + this.parent = null; + }, + + /** + * Gets or sets the frozen state of this Data Manager. + * A frozen Data Manager will block all attempts to create new values or update existing ones. + * + * @name Phaser.Data.DataManager#freeze + * @type {boolean} + * @since 3.0.0 + */ + freeze: { + + get: function () + { + return this._frozen; + }, + + set: function (value) + { + this._frozen = (value) ? true : false; + } + + }, + + /** + * Return the total number of entries in this Data Manager. + * + * @name Phaser.Data.DataManager#count + * @type {integer} + * @since 3.0.0 + */ + count: { + + get: function () + { + var i = 0; + + for (var key in this.list) + { + if (this.list[key] !== undefined) + { + i++; + } + } + + return i; + } + + } + +}); + +module.exports = DataManager; + + +/***/ }), +/* 124 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var Perimeter = function (rect) +{ + return 2 * (rect.width + rect.height); +}; + +module.exports = Perimeter; + + +/***/ }), +/* 125 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(66); +var Circle = __webpack_require__(71); +var CircleContains = __webpack_require__(40); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var Rectangle = __webpack_require__(9); +var RectangleContains = __webpack_require__(39); + +/** + * @classdesc + * A Zone Game Object. + * + * A Zone is a non-rendering rectangular Game Object that has a position and size. + * It has no texture and never displays, but does live on the display list and + * can be moved, scaled and rotated like any other Game Object. + * + * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods + * specifically for this. It is also useful for object overlap checks, or as a base for your own + * non-displaying Game Objects. + + * The default origin is 0.5, the center of the Zone, the same as with Game Objects. + * + * @class Zone + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @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 {number} [width=1] - The width of the Game Object. + * @param {number} [height=1] - The height of the Game Object. + */ +var Zone = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.GetBounds, + Components.Origin, + Components.ScaleMode, + Components.Transform, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function Zone (scene, x, y, width, height) + { + if (width === undefined) { width = 1; } + if (height === undefined) { height = width; } + + GameObject.call(this, scene, 'Zone'); + + this.setPosition(x, y); + + /** + * The native (un-scaled) width of this Game Object. + * + * @name Phaser.GameObjects.Zone#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * The native (un-scaled) height of this Game Object. + * + * @name Phaser.GameObjects.Zone#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * The Blend Mode of the Game Object. + * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into + * display lists without causing a batch flush. + * + * @name Phaser.GameObjects.Zone#blendMode + * @type {integer} + * @since 3.0.0 + */ + this.blendMode = BlendModes.NORMAL; + + this.updateDisplayOrigin(); + }, + + /** + * The displayed width of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * This value takes into account the scale factor. + * + * @name Phaser.GameObjects.Zone#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Zone#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setSize: function (width, height, resizeInput) + { + if (resizeInput === undefined) { resizeInput = true; } + + this.width = width; + this.height = height; + + if (resizeInput && this.input && this.input.hitArea instanceof Rectangle) + { + this.input.hitArea.width = width; + this.input.hitArea.height = height; + } + + return this; + }, + + /** + * Sets the display size of this Game Object. + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Zone#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + }, + + /** + * Sets this Zone to be a Circular Drop Zone. + * The circle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setCircleDropZone + * @since 3.0.0 + * + * @param {number} radius - The radius of the Circle that will form the Drop Zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setCircleDropZone: function (radius) + { + return this.setDropZone(new Circle(0, 0, radius), CircleContains); + }, + + /** + * Sets this Zone to be a Rectangle Drop Zone. + * The rectangle is centered on this Zones `x` and `y` coordinates. + * + * @method Phaser.GameObjects.Zone#setRectangleDropZone + * @since 3.0.0 + * + * @param {number} width - The width of the rectangle drop zone. + * @param {number} height - The height of the rectangle drop zone. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setRectangleDropZone: function (width, height) + { + return this.setDropZone(new Rectangle(0, 0, width, height), RectangleContains); + }, + + /** + * Allows you to define your own Geometry shape to be used as a Drop Zone. + * + * @method Phaser.GameObjects.Zone#setDropZone + * @since 3.0.0 + * + * @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. + * @param {HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape. + * + * @return {Phaser.GameObjects.Zone} This Game Object. + */ + setDropZone: function (shape, callback) + { + if (shape === undefined) + { + this.setRectangleDropZone(this.width, this.height); + } + else if (!this.input) + { + this.setInteractive(shape, callback, true); + } + + return this; + }, + + /** + * A NOOP method so you can pass a Zone to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Zone#setAlpha + * @private + * @since 3.11.0 + */ + setAlpha: function () + { + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderCanvas + * @private + * @since 3.0.0 + */ + renderCanvas: function () + { + }, + + /** + * A Zone does not render. + * + * @method Phaser.GameObjects.Zone#renderWebGL + * @private + * @since 3.0.0 + */ + renderWebGL: function () + { + } + +}); + +module.exports = Zone; + + +/***/ }), +/* 126 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Bodies` module contains factory methods for creating rigid body models +* with commonly used body configurations (such as rectangles, circles and other polygons). +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Bodies +*/ + +// TODO: true circle bodies + +var Bodies = {}; + +module.exports = Bodies; + +var Vertices = __webpack_require__(76); +var Common = __webpack_require__(33); +var Body = __webpack_require__(67); +var Bounds = __webpack_require__(80); +var Vector = __webpack_require__(81); +var decomp = __webpack_require__(1069); + +(function() { + + /** + * Creates a new rigid body model with a rectangle hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method rectangle + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {object} [options] + * @return {body} A new rectangle body + */ + Bodies.rectangle = function(x, y, width, height, options) { + options = options || {}; + + var rectangle = { + label: 'Rectangle Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath('L 0 0 L ' + width + ' 0 L ' + width + ' ' + height + ' L 0 ' + height) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + rectangle.vertices = Vertices.chamfer(rectangle.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, rectangle, options)); + }; + + /** + * Creates a new rigid body model with a trapezoid hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method trapezoid + * @param {number} x + * @param {number} y + * @param {number} width + * @param {number} height + * @param {number} slope + * @param {object} [options] + * @return {body} A new trapezoid body + */ + Bodies.trapezoid = function(x, y, width, height, slope, options) { + options = options || {}; + + slope *= 0.5; + var roof = (1 - (slope * 2)) * width; + + var x1 = width * slope, + x2 = x1 + roof, + x3 = x2 + x1, + verticesPath; + + if (slope < 0.5) { + verticesPath = 'L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } else { + verticesPath = 'L 0 0 L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + } + + var trapezoid = { + label: 'Trapezoid Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath(verticesPath) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + trapezoid.vertices = Vertices.chamfer(trapezoid.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, trapezoid, options)); + }; + + /** + * Creates a new rigid body model with a circle hull. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method circle + * @param {number} x + * @param {number} y + * @param {number} radius + * @param {object} [options] + * @param {number} [maxSides] + * @return {body} A new circle body + */ + Bodies.circle = function(x, y, radius, options, maxSides) { + options = options || {}; + + var circle = { + label: 'Circle Body', + circleRadius: radius + }; + + // approximate circles with polygons until true circles implemented in SAT + maxSides = maxSides || 25; + var sides = Math.ceil(Math.max(10, Math.min(maxSides, radius))); + + // optimisation: always use even number of sides (half the number of unique axes) + if (sides % 2 === 1) + sides += 1; + + return Bodies.polygon(x, y, sides, radius, Common.extend({}, circle, options)); + }; + + /** + * Creates a new rigid body model with a regular polygon hull with the given number of sides. + * The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method polygon + * @param {number} x + * @param {number} y + * @param {number} sides + * @param {number} radius + * @param {object} [options] + * @return {body} A new regular polygon body + */ + Bodies.polygon = function(x, y, sides, radius, options) { + options = options || {}; + + if (sides < 3) + return Bodies.circle(x, y, radius, options); + + var theta = 2 * Math.PI / sides, + path = '', + offset = theta * 0.5; + + for (var i = 0; i < sides; i += 1) { + var angle = offset + (i * theta), + xx = Math.cos(angle) * radius, + yy = Math.sin(angle) * radius; + + path += 'L ' + xx.toFixed(3) + ' ' + yy.toFixed(3) + ' '; + } + + var polygon = { + label: 'Polygon Body', + position: { x: x, y: y }, + vertices: Vertices.fromPath(path) + }; + + if (options.chamfer) { + var chamfer = options.chamfer; + polygon.vertices = Vertices.chamfer(polygon.vertices, chamfer.radius, + chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); + delete options.chamfer; + } + + return Body.create(Common.extend({}, polygon, options)); + }; + + /** + * Creates a body using the supplied vertices (or an array containing multiple sets of vertices). + * If the vertices are convex, they will pass through as supplied. + * Otherwise if the vertices are concave, they will be decomposed if [poly-decomp.js](https://github.com/schteppe/poly-decomp.js) is available. + * Note that this process is not guaranteed to support complex sets of vertices (e.g. those with holes may fail). + * By default the decomposition will discard collinear edges (to improve performance). + * It can also optionally discard any parts that have an area less than `minimumArea`. + * If the vertices can not be decomposed, the result will fall back to using the convex hull. + * The options parameter is an object that specifies any `Matter.Body` properties you wish to override the defaults. + * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. + * @method fromVertices + * @param {number} x + * @param {number} y + * @param [[vector]] vertexSets + * @param {object} [options] + * @param {bool} [flagInternal=false] + * @param {number} [removeCollinear=0.01] + * @param {number} [minimumArea=10] + * @return {body} + */ + Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) { + var body, + parts, + isConvex, + vertices, + i, + j, + k, + v, + z; + + options = options || {}; + parts = []; + + flagInternal = typeof flagInternal !== 'undefined' ? flagInternal : false; + removeCollinear = typeof removeCollinear !== 'undefined' ? removeCollinear : 0.01; + minimumArea = typeof minimumArea !== 'undefined' ? minimumArea : 10; + + if (!decomp) { + Common.warn('Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.'); + } + + // ensure vertexSets is an array of arrays + if (!Common.isArray(vertexSets[0])) { + vertexSets = [vertexSets]; + } + + for (v = 0; v < vertexSets.length; v += 1) { + vertices = vertexSets[v]; + isConvex = Vertices.isConvex(vertices); + + if (isConvex || !decomp) { + if (isConvex) { + vertices = Vertices.clockwiseSort(vertices); + } else { + // fallback to convex hull when decomposition is not possible + vertices = Vertices.hull(vertices); + } + + parts.push({ + position: { x: x, y: y }, + vertices: vertices + }); + } else { + // initialise a decomposition + var concave = vertices.map(function(vertex) { + return [vertex.x, vertex.y]; + }); + + // vertices are concave and simple, we can decompose into parts + decomp.makeCCW(concave); + if (removeCollinear !== false) + decomp.removeCollinearPoints(concave, removeCollinear); + + // use the quick decomposition algorithm (Bayazit) + var decomposed = decomp.quickDecomp(concave); + + // for each decomposed chunk + for (i = 0; i < decomposed.length; i++) { + var chunk = decomposed[i]; + + // convert vertices into the correct structure + var chunkVertices = chunk.map(function(vertices) { + return { + x: vertices[0], + y: vertices[1] + }; + }); + + // skip small chunks + if (minimumArea > 0 && Vertices.area(chunkVertices) < minimumArea) + continue; + + // create a compound part + parts.push({ + position: Vertices.centre(chunkVertices), + vertices: chunkVertices + }); + } + } + } + + // create body parts + for (i = 0; i < parts.length; i++) { + parts[i] = Body.create(Common.extend(parts[i], options)); + } + + // flag internal edges (coincident part edges) + if (flagInternal) { + var coincident_max_dist = 5; + + for (i = 0; i < parts.length; i++) { + var partA = parts[i]; + + for (j = i + 1; j < parts.length; j++) { + var partB = parts[j]; + + if (Bounds.overlaps(partA.bounds, partB.bounds)) { + var pav = partA.vertices, + pbv = partB.vertices; + + // iterate vertices of both parts + for (k = 0; k < partA.vertices.length; k++) { + for (z = 0; z < partB.vertices.length; z++) { + // find distances between the vertices + var da = Vector.magnitudeSquared(Vector.sub(pav[(k + 1) % pav.length], pbv[z])), + db = Vector.magnitudeSquared(Vector.sub(pav[k], pbv[(z + 1) % pbv.length])); + + // if both vertices are very close, consider the edge concident (internal) + if (da < coincident_max_dist && db < coincident_max_dist) { + pav[k].isInternal = true; + pbv[z].isInternal = true; + } + } + } + + } + } + } + } + + if (parts.length > 1) { + // create the parent body to be returned, that contains generated compound parts + body = Body.create(Common.extend({ parts: parts.slice(0) }, options)); + Body.setPosition(body, { x: x, y: y }); + + return body; + } else { + return parts[0]; + } + }; + +})(); + + +/***/ }), +/* 127 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} TweenDataGenConfig + * + * @property {function} delay - [description] + * @property {function} duration - [description] + * @property {function} hold - [description] + * @property {function} repeat - [description] + * @property {function} repeatDelay - [description] + */ + +/** + * @typedef {object} Phaser.Tweens.TweenDataConfig + * + * @property {object} target - The target to tween. + * @property {string} key - The property of the target being tweened. + * @property {function} getEndValue - The returned value sets what the property will be at the END of the Tween. + * @property {function} getStartValue - The returned value sets what the property will be at the START of the Tween. + * @property {function} ease - The ease function this tween uses. + * @property {number} [duration=0] - Duration of the tween in ms/frames, excludes time for yoyo or repeats. + * @property {number} [totalDuration=0] - The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + * @property {number} [delay=0] - Time in ms/frames before tween will start. + * @property {boolean} [yoyo=false] - Cause the tween to return back to its start value after hold has expired. + * @property {number} [hold=0] - Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + * @property {integer} [repeat=0] - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + * @property {number} [repeatDelay=0] - Time in ms/frames before the repeat will start. + * @property {boolean} [flipX=false] - Automatically call toggleFlipX when the TweenData yoyos or repeats + * @property {boolean} [flipY=false] - Automatically call toggleFlipY when the TweenData yoyos or repeats + * @property {number} [progress=0] - Between 0 and 1 showing completion of this TweenData. + * @property {number} [elapsed=0] - Delta counter + * @property {integer} [repeatCounter=0] - How many repeats are left to run? + * @property {number} [start=0] - Ease value data. + * @property {number} [current=0] - Ease value data. + * @property {number} [end=0] - Ease value data. + * @property {number} [t1=0] - Time duration 1. + * @property {number} [t2=0] - Time duration 2. + * @property {TweenDataGenConfig} [gen] - LoadValue generation functions. + * @property {integer} [state=0] - TWEEN_CONST.CREATED + */ + +/** + * [description] + * + * @function Phaser.Tweens.TweenData + * @since 3.0.0 + * + * @param {object} target - [description] + * @param {string} key - [description] + * @param {function} getEnd - [description] + * @param {function} getStart - [description] + * @param {function} ease - [description] + * @param {number} delay - [description] + * @param {number} duration - [description] + * @param {boolean} yoyo - [description] + * @param {number} hold - [description] + * @param {number} repeat - [description] + * @param {number} repeatDelay - [description] + * @param {boolean} flipX - [description] + * @param {boolean} flipY - [description] + * + * @return {TweenDataConfig} [description] + */ +var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) +{ + return { + + // The target to tween + target: target, + + // The property of the target to tween + key: key, + + // The returned value sets what the property will be at the END of the Tween. + getEndValue: getEnd, + + // The returned value sets what the property will be at the START of the Tween. + getStartValue: getStart, + + // The ease function this tween uses. + ease: ease, + + // Duration of the tween in ms/frames, excludes time for yoyo or repeats. + duration: 0, + + // The total calculated duration of this TweenData (based on duration, repeat, delay and yoyo) + totalDuration: 0, + + // Time in ms/frames before tween will start. + delay: 0, + + // Cause the tween to return back to its start value after hold has expired. + yoyo: yoyo, + + // Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + hold: 0, + + // Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + repeat: 0, + + // Time in ms/frames before the repeat will start. + repeatDelay: 0, + + // Automatically call toggleFlipX when the TweenData yoyos or repeats + flipX: flipX, + + // Automatically call toggleFlipY when the TweenData yoyos or repeats + flipY: flipY, + + // Between 0 and 1 showing completion of this TweenData. + progress: 0, + + // Delta counter. + elapsed: 0, + + // How many repeats are left to run? + repeatCounter: 0, + + // Ease Value Data: + + start: 0, + current: 0, + end: 0, + + // Time Durations + t1: 0, + t2: 0, + + // LoadValue generation functions + gen: { + delay: delay, + duration: duration, + hold: hold, + repeat: repeat, + repeatDelay: repeatDelay + }, + + // TWEEN_CONST.CREATED + state: 0 + }; +}; + +module.exports = TweenData; + + +/***/ }), +/* 128 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GameObjectCreator = __webpack_require__(13); +var GameObjectFactory = __webpack_require__(5); +var TWEEN_CONST = __webpack_require__(83); + +/** + * @classdesc + * [description] + * + * @class Tween + * @memberof Phaser.Tweens + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] + * @param {Phaser.Tweens.TweenDataConfig[]} data - [description] + * @param {array} targets - [description] + */ +var Tween = new Class({ + + initialize: + + function Tween (parent, data, targets) + { + /** + * [description] + * + * @name Phaser.Tweens.Tween#parent + * @type {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * Is the parent of this Tween a Timeline? + * + * @name Phaser.Tweens.Tween#parentIsTimeline + * @type {boolean} + * @since 3.0.0 + */ + this.parentIsTimeline = parent.hasOwnProperty('isTimeline'); + + /** + * An array of TweenData objects, each containing a unique property and target being tweened. + * + * @name Phaser.Tweens.Tween#data + * @type {Phaser.Tweens.TweenDataConfig[]} + * @since 3.0.0 + */ + this.data = data; + + /** + * data array doesn't change, so we can cache the length + * + * @name Phaser.Tweens.Tween#totalData + * @type {integer} + * @since 3.0.0 + */ + this.totalData = data.length; + + /** + * An array of references to the target/s this Tween is operating on + * + * @name Phaser.Tweens.Tween#targets + * @type {object[]} + * @since 3.0.0 + */ + this.targets = targets; + + /** + * Cached target total (not necessarily the same as the data total) + * + * @name Phaser.Tweens.Tween#totalTargets + * @type {integer} + * @since 3.0.0 + */ + this.totalTargets = targets.length; + + /** + * If true then duration, delay, etc values are all frame totals. + * + * @name Phaser.Tweens.Tween#useFrames + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useFrames = false; + + /** + * Scales the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * + * @name Phaser.Tweens.Tween#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * Loop this tween? Can be -1 for an infinite loop, or an integer. + * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + * + * @name Phaser.Tweens.Tween#loop + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loop = 0; + + /** + * Time in ms/frames before the tween loops. + * + * @name Phaser.Tweens.Tween#loopDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopDelay = 0; + + /** + * How many loops are left to run? + * + * @name Phaser.Tweens.Tween#loopCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.loopCounter = 0; + + /** + * Time in ms/frames before the 'onComplete' event fires. This never fires if loop = -1 (as it never completes) + * + * @name Phaser.Tweens.Tween#completeDelay + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.completeDelay = 0; + + /** + * Countdown timer (used by timeline offset, loopDelay and completeDelay) + * + * @name Phaser.Tweens.Tween#countdown + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.countdown = 0; + + /** + * Set only if this Tween is part of a Timeline. + * + * @name Phaser.Tweens.Tween#offset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.offset = 0; + + /** + * Set only if this Tween is part of a Timeline. The calculated offset amount. + * + * @name Phaser.Tweens.Tween#calculatedOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.calculatedOffset = 0; + + /** + * The current state of the tween + * + * @name Phaser.Tweens.Tween#state + * @type {integer} + * @since 3.0.0 + */ + this.state = TWEEN_CONST.PENDING_ADD; + + /** + * The state of the tween when it was paused (used by Resume) + * + * @name Phaser.Tweens.Tween#_pausedState + * @type {integer} + * @private + * @since 3.0.0 + */ + this._pausedState = TWEEN_CONST.PENDING_ADD; + + /** + * Does the Tween start off paused? (if so it needs to be started with Tween.play) + * + * @name Phaser.Tweens.Tween#paused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.paused = false; + + /** + * Elapsed time in ms/frames of this run through the Tween. + * + * @name Phaser.Tweens.Tween#elapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.elapsed = 0; + + /** + * Total elapsed time in ms/frames of the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalElapsed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalElapsed = 0; + + /** + * Time in ms/frames for the whole Tween to play through once, excluding loop amounts and loop delays. + * + * @name Phaser.Tweens.Tween#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * Value between 0 and 1. The amount through the Tween, excluding loops. + * + * @name Phaser.Tweens.Tween#progress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.progress = 0; + + /** + * Time in ms/frames for the Tween to complete (including looping) + * + * @name Phaser.Tweens.Tween#totalDuration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalDuration = 0; + + /** + * Value between 0 and 1. The amount through the entire Tween, including looping. + * + * @name Phaser.Tweens.Tween#totalProgress + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.totalProgress = 0; + + /** + * An object containing the various Tween callback references. + * + * @name Phaser.Tweens.Tween#callbacks + * @type {object} + * @default 0 + * @since 3.0.0 + */ + this.callbacks = { + onComplete: null, + onLoop: null, + onRepeat: null, + onStart: null, + onUpdate: null, + onYoyo: null + }; + + this.callbackScope; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getValue + * @since 3.0.0 + * + * @return {number} [description] + */ + getValue: function () + { + return this.data[0].current; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setTimeScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setTimeScale: function (value) + { + this.timeScale = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#getTimeScale + * @since 3.0.0 + * + * @return {number} [description] + */ + getTimeScale: function () + { + return this.timeScale; + }, + + /** + * Checks if the Tween is currently active. + * + * @method Phaser.Tweens.Tween#isPlaying + * @since 3.0.0 + * + * @return {boolean} `true` if the Tween is active, otherwise `false`. + */ + isPlaying: function () + { + return (this.state === TWEEN_CONST.ACTIVE); + }, + + /** + * Checks if the Tween is currently paused. + * + * @method Phaser.Tweens.Tween#isPaused + * @since 3.0.0 + * + * @return {boolean} `true` if the Tween is paused, otherwise `false`. + */ + isPaused: function () + { + return (this.state === TWEEN_CONST.PAUSED); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#hasTarget + * @since 3.0.0 + * + * @param {object} target - [description] + * + * @return {boolean} [description] + */ + hasTarget: function (target) + { + return (this.targets.indexOf(target) !== -1); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTo + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} value - [description] + * @param {boolean} startToCurrent - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + updateTo: function (key, value, startToCurrent) + { + for (var i = 0; i < this.totalData; i++) + { + var tweenData = this.data[i]; + + if (tweenData.key === key) + { + tweenData.end = value; + + if (startToCurrent) + { + tweenData.start = tweenData.current; + } + + break; + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#restart + * @since 3.0.0 + */ + restart: function () + { + if (this.state === TWEEN_CONST.REMOVED) + { + this.seek(0); + this.parent.makeActive(this); + } + else + { + this.stop(); + this.play(); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#calcDuration + * @since 3.0.0 + */ + calcDuration: function () + { + var max = 0; + + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + // Set t1 (duration + hold + yoyo) + tweenData.t1 = tweenData.duration + tweenData.hold; + + if (tweenData.yoyo) + { + tweenData.t1 += tweenData.duration; + } + + // Set t2 (repeatDelay + duration + hold + yoyo) + tweenData.t2 = tweenData.t1 + tweenData.repeatDelay; + + // Total Duration + tweenData.totalDuration = tweenData.delay + tweenData.t1; + + if (tweenData.repeat === -1) + { + tweenData.totalDuration += (tweenData.t2 * 999999999999); + } + else if (tweenData.repeat > 0) + { + tweenData.totalDuration += (tweenData.t2 * tweenData.repeat); + } + + if (tweenData.totalDuration > max) + { + // Get the longest TweenData from the Tween, used to calculate the Tween TD + max = tweenData.totalDuration; + } + } + + // Excludes loop values + this.duration = max; + + this.loopCounter = (this.loop === -1) ? 999999999999 : this.loop; + + if (this.loopCounter > 0) + { + this.totalDuration = this.duration + this.completeDelay + ((this.duration + this.loopDelay) * this.loopCounter); + } + else + { + this.totalDuration = this.duration + this.completeDelay; + } + }, + + /** + * Called by TweenManager.preUpdate as part of its loop to check pending and active tweens. + * Should not be called directly. + * + * @method Phaser.Tweens.Tween#init + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Tween should be moved from the pending list to the active list by the Tween Manager. + */ + init: function () + { + var data = this.data; + var totalTargets = this.totalTargets; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + var target = tweenData.target; + var gen = tweenData.gen; + + tweenData.delay = gen.delay(i, totalTargets, target); + tweenData.duration = gen.duration(i, totalTargets, target); + tweenData.hold = gen.hold(i, totalTargets, target); + tweenData.repeat = gen.repeat(i, totalTargets, target); + tweenData.repeatDelay = gen.repeatDelay(i, totalTargets, target); + } + + this.calcDuration(); + + this.progress = 0; + this.totalProgress = 0; + this.elapsed = 0; + this.totalElapsed = 0; + + // You can't have a paused Tween if it's part of a Timeline + if (this.paused && !this.parentIsTimeline) + { + this.state = TWEEN_CONST.PENDING_ADD; + this._pausedState = TWEEN_CONST.INIT; + + return false; + } + else + { + this.state = TWEEN_CONST.INIT; + + return true; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#nextState + * @since 3.0.0 + */ + nextState: function () + { + if (this.loopCounter > 0) + { + this.elapsed = 0; + this.progress = 0; + this.loopCounter--; + + var onLoop = this.callbacks.onLoop; + + if (onLoop) + { + onLoop.params[1] = this.targets; + + onLoop.func.apply(onLoop.scope, onLoop.params); + } + + this.resetTweenData(true); + + if (this.loopDelay > 0) + { + this.countdown = this.loopDelay; + this.state = TWEEN_CONST.LOOP_DELAY; + } + else + { + this.state = TWEEN_CONST.ACTIVE; + } + } + else if (this.completeDelay > 0) + { + this.countdown = this.completeDelay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#pause + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + pause: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + return; + } + + this.paused = true; + + this._pausedState = this.state; + + this.state = TWEEN_CONST.PAUSED; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#play + * @since 3.0.0 + * + * @param {boolean} resetFromTimeline - [description] + */ + play: function (resetFromTimeline) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + return; + } + else if (this.state === TWEEN_CONST.PENDING_REMOVE || this.state === TWEEN_CONST.REMOVED) + { + this.init(); + this.parent.makeActive(this); + resetFromTimeline = true; + } + + var onStart = this.callbacks.onStart; + + if (this.parentIsTimeline) + { + this.resetTweenData(resetFromTimeline); + + if (this.calculatedOffset === 0) + { + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + else + { + this.countdown = this.calculatedOffset; + + this.state = TWEEN_CONST.OFFSET_DELAY; + } + } + else if (this.paused) + { + this.paused = false; + + this.parent.makeActive(this); + } + else + { + this.resetTweenData(resetFromTimeline); + + this.state = TWEEN_CONST.ACTIVE; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.parent.makeActive(this); + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#resetTweenData + * @since 3.0.0 + * + * @param {boolean} resetFromLoop - [description] + */ + resetTweenData: function (resetFromLoop) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + var tweenData = data[i]; + + tweenData.progress = 0; + tweenData.elapsed = 0; + + tweenData.repeatCounter = (tweenData.repeat === -1) ? 999999999999 : tweenData.repeat; + + if (resetFromLoop) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.end); + + tweenData.current = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else if (tweenData.delay > 0) + { + tweenData.elapsed = tweenData.delay; + tweenData.state = TWEEN_CONST.DELAY; + } + else + { + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + } + }, + + /** + * Resumes the playback of a previously paused Tween. + * + * @method Phaser.Tweens.Tween#resume + * @since 3.0.0 + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + resume: function () + { + if (this.state === TWEEN_CONST.PAUSED) + { + this.paused = false; + + this.state = this._pausedState; + } + else + { + this.play(); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#seek + * @since 3.0.0 + * + * @param {number} toPosition - A value between 0 and 1. + */ + seek: function (toPosition) + { + var data = this.data; + + for (var i = 0; i < this.totalData; i++) + { + // This won't work with loop > 0 yet + var ms = this.totalDuration * toPosition; + + var tweenData = data[i]; + var progress = 0; + var elapsed = 0; + + if (ms <= tweenData.delay) + { + progress = 0; + elapsed = 0; + } + else if (ms >= tweenData.totalDuration) + { + progress = 1; + elapsed = tweenData.duration; + } + else if (ms > tweenData.delay && ms <= tweenData.t1) + { + // Keep it zero bound + ms = Math.max(0, ms - tweenData.delay); + + // Somewhere in the first playthru range + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + else if (ms > tweenData.t1 && ms < tweenData.totalDuration) + { + // Somewhere in repeat land + ms -= tweenData.delay; + ms -= tweenData.t1; + + // var repeats = Math.floor(ms / tweenData.t2); + + // remainder + ms = ((ms / tweenData.t2) % 1) * tweenData.t2; + + if (ms > tweenData.repeatDelay) + { + progress = ms / tweenData.t1; + elapsed = tweenData.duration * progress; + } + } + + tweenData.progress = progress; + tweenData.elapsed = elapsed; + + var v = tweenData.ease(tweenData.progress); + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + // console.log(tweenData.key, 'Seek', tweenData.target[tweenData.key], 'to', tweenData.current, 'pro', tweenData.progress, 'marker', toPosition, progress); + + // if (tweenData.current === 0) + // { + // console.log('zero', tweenData.start, tweenData.end, v, 'progress', progress); + // } + + tweenData.target[tweenData.key] = tweenData.current; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setCallback + * @since 3.0.0 + * + * @param {string} type - [description] + * @param {function} callback - [description] + * @param {array} [params] - [description] + * @param {object} [scope] - [description] + * + * @return {Phaser.Tweens.Tween} This Tween object. + */ + setCallback: function (type, callback, params, scope) + { + this.callbacks[type] = { func: callback, scope: scope, params: params }; + + return this; + }, + + /** + * Flags the Tween as being complete, whatever stage of progress it is at. + * + * If an onComplete callback has been defined it will automatically invoke it, unless a `delay` + * argument is provided, in which case the Tween will delay for that period of time before calling the callback. + * + * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. + * + * @method Phaser.Tweens.Tween#complete + * @since 3.2.0 + * + * @param {number} [delay=0] - The time to wait before invoking the complete callback. If zero it will fire immediately. + */ + complete: function (delay) + { + if (delay === undefined) { delay = 0; } + + if (delay) + { + this.countdown = delay; + this.state = TWEEN_CONST.COMPLETE_DELAY; + } + else + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.params[1] = this.targets; + + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. + * + * @method Phaser.Tweens.Tween#stop + * @since 3.0.0 + * + * @param {number} [resetTo] - A value between 0 and 1. + */ + stop: function (resetTo) + { + if (this.state === TWEEN_CONST.ACTIVE) + { + if (resetTo !== undefined) + { + this.seek(resetTo); + } + } + + if (this.state !== TWEEN_CONST.REMOVED) + { + if (this.state === TWEEN_CONST.PAUSED || this.state === TWEEN_CONST.PENDING_ADD) + { + this.parent._destroy.push(this); + this.parent._toProcess++; + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#update + * @since 3.0.0 + * + * @param {number} timestamp - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + * + * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. + */ + update: function (timestamp, delta) + { + if (this.state === TWEEN_CONST.PAUSED) + { + return false; + } + + if (this.useFrames) + { + delta = 1 * this.parent.timeScale; + } + + delta *= this.timeScale; + + this.elapsed += delta; + this.progress = Math.min(this.elapsed / this.duration, 1); + + this.totalElapsed += delta; + this.totalProgress = Math.min(this.totalElapsed / this.totalDuration, 1); + + switch (this.state) + { + case TWEEN_CONST.ACTIVE: + + var stillRunning = false; + + for (var i = 0; i < this.totalData; i++) + { + if (this.updateTweenData(this, this.data[i], delta)) + { + stillRunning = true; + } + } + + // Anything still running? If not, we're done + if (!stillRunning) + { + this.nextState(); + } + + break; + + case TWEEN_CONST.LOOP_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.OFFSET_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onStart = this.callbacks.onStart; + + if (onStart) + { + onStart.params[1] = this.targets; + + onStart.func.apply(onStart.scope, onStart.params); + } + + this.state = TWEEN_CONST.ACTIVE; + } + + break; + + case TWEEN_CONST.COMPLETE_DELAY: + + this.countdown -= delta; + + if (this.countdown <= 0) + { + var onComplete = this.callbacks.onComplete; + + if (onComplete) + { + onComplete.func.apply(onComplete.scope, onComplete.params); + } + + this.state = TWEEN_CONST.PENDING_REMOVE; + } + + break; + } + + return (this.state === TWEEN_CONST.PENDING_REMOVE); + }, + + /** + * [description] + * + * @method Phaser.Tweens.Tween#setStateFromEnd + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromEnd: function (tween, tweenData, diff) + { + if (tweenData.yoyo) + { + // We've hit the end of a Playing Forward TweenData and we have a yoyo + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + // Problem: The flip and callback and so on gets called for every TweenData that triggers it at the same time. + // If you're tweening several properties it can fire for all of them, at once. + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onYoyo = tween.callbacks.onYoyo; + + if (onYoyo) + { + // Element 1 is reserved for the target of the yoyo (and needs setting here) + onYoyo.params[1] = tweenData.target; + + onYoyo.func.apply(onYoyo.scope, onYoyo.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + return TWEEN_CONST.PLAYING_BACKWARD; + } + else if (tweenData.repeatCounter > 0) + { + // We've hit the end of a Playing Forward TweenData and we have a Repeat. + // So we're going to go right back to the start to repeat it again. + + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + /** + * Was PLAYING_BACKWARD and has hit the start. + * + * @method Phaser.Tweens.Tween#setStateFromStart + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} diff - [description] + * + * @return {integer} The state of this Tween. + */ + setStateFromStart: function (tween, tweenData, diff) + { + if (tweenData.repeatCounter > 0) + { + tweenData.repeatCounter--; + + // Account for any extra time we got from the previous frame + tweenData.elapsed = diff; + tweenData.progress = diff / tweenData.duration; + + if (tweenData.flipX) + { + tweenData.target.toggleFlipX(); + } + + if (tweenData.flipY) + { + tweenData.target.toggleFlipY(); + } + + var onRepeat = tween.callbacks.onRepeat; + + if (onRepeat) + { + // Element 1 is reserved for the target of the repeat (and needs setting here) + onRepeat.params[1] = tweenData.target; + + onRepeat.func.apply(onRepeat.scope, onRepeat.params); + } + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + // Delay? + if (tweenData.repeatDelay > 0) + { + tweenData.elapsed = tweenData.repeatDelay - diff; + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.current; + + return TWEEN_CONST.REPEAT_DELAY; + } + else + { + return TWEEN_CONST.PLAYING_FORWARD; + } + } + + return TWEEN_CONST.COMPLETE; + }, + + // + /** + * [description] + * + * @method Phaser.Tweens.Tween#updateTweenData + * @since 3.0.0 + * + * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {number} delta - Either a value in ms, or 1 if Tween.useFrames is true + * + * @return {boolean} [description] + */ + updateTweenData: function (tween, tweenData, delta) + { + switch (tweenData.state) + { + case TWEEN_CONST.PLAYING_FORWARD: + case TWEEN_CONST.PLAYING_BACKWARD: + + if (!tweenData.target) + { + tweenData.state = TWEEN_CONST.COMPLETE; + break; + } + + var elapsed = tweenData.elapsed; + var duration = tweenData.duration; + var diff = 0; + + elapsed += delta; + + if (elapsed > duration) + { + diff = elapsed - duration; + elapsed = duration; + } + + var forward = (tweenData.state === TWEEN_CONST.PLAYING_FORWARD); + var progress = elapsed / duration; + + var v; + + if (forward) + { + v = tweenData.ease(progress); + } + else + { + v = tweenData.ease(1 - progress); + } + + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + + tweenData.target[tweenData.key] = tweenData.current; + + tweenData.elapsed = elapsed; + tweenData.progress = progress; + + var onUpdate = tween.callbacks.onUpdate; + + if (onUpdate) + { + onUpdate.params[1] = tweenData.target; + + onUpdate.func.apply(onUpdate.scope, onUpdate.params); + } + + if (progress === 1) + { + if (forward) + { + if (tweenData.hold > 0) + { + tweenData.elapsed = tweenData.hold - diff; + + tweenData.state = TWEEN_CONST.HOLD_DELAY; + } + else + { + tweenData.state = this.setStateFromEnd(tween, tweenData, diff); + } + } + else + { + tweenData.state = this.setStateFromStart(tween, tweenData, diff); + } + } + + break; + + case TWEEN_CONST.DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PENDING_RENDER; + } + + break; + + case TWEEN_CONST.REPEAT_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.elapsed = Math.abs(tweenData.elapsed); + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + + break; + + case TWEEN_CONST.HOLD_DELAY: + + tweenData.elapsed -= delta; + + if (tweenData.elapsed <= 0) + { + tweenData.state = this.setStateFromEnd(tween, tweenData, Math.abs(tweenData.elapsed)); + } + + break; + + case TWEEN_CONST.PENDING_RENDER: + + if (tweenData.target) + { + tweenData.start = tweenData.getStartValue(tweenData.target, tweenData.key, tweenData.target[tweenData.key]); + + tweenData.end = tweenData.getEndValue(tweenData.target, tweenData.key, tweenData.start); + + tweenData.current = tweenData.start; + + tweenData.target[tweenData.key] = tweenData.start; + + tweenData.state = TWEEN_CONST.PLAYING_FORWARD; + } + else + { + tweenData.state = TWEEN_CONST.COMPLETE; + } + + break; + } + + // Return TRUE if this TweenData still playing, otherwise return FALSE + return (tweenData.state !== TWEEN_CONST.COMPLETE); + } + +}); + +Tween.TYPES = [ + 'onComplete', + 'onLoop', + 'onRepeat', + 'onStart', + 'onUpdate', + 'onYoyo' +]; + +/** + * Creates a new Tween object. + * + * Note: This method will only be available Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectFactory.register('tween', function (config) +{ + return this.scene.sys.tweens.add(config); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + +/** + * Creates a new Tween object and returns it. + * + * Note: This method will only be available if Tweens have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tween + * @since 3.0.0 + * + * @param {object} config - The Tween configuration. + * + * @return {Phaser.Tweens.Tween} The Tween that was created. + */ +GameObjectCreator.register('tween', function (config) +{ + return this.scene.sys.tweens.create(config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + +module.exports = Tween; + + +/***/ }), +/* 129 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} Phaser.Tweens.TweenConfigDefaults + * + * @property {(object|object[])} targets - The object, or an array of objects, to run the tween on. + * @property {number} [delay=0] - The number of milliseconds to delay before the tween will start. + * @property {number} [duration=1000] - The duration of the tween in milliseconds. + * @property {string} [ease='Power0'] - The easing equation to use for the tween. + * @property {array} [easeParams] - Optional easing parameters. + * @property {number} [hold=0] - The number of milliseconds to hold the tween for before yoyo'ing. + * @property {number} [repeat=0] - The number of times to repeat the tween. + * @property {number} [repeatDelay=0] - The number of milliseconds to pause before a tween will repeat. + * @property {boolean} [yoyo=false] - Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete. + * @property {boolean} [flipX=false] - Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property. + * @property {boolean} [flipY=false] - Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property. + */ + +var TWEEN_DEFAULTS = { + targets: null, + delay: 0, + duration: 1000, + ease: 'Power0', + easeParams: null, + hold: 0, + repeat: 0, + repeatDelay: 0, + yoyo: false, + flipX: false, + flipY: false +}; + +module.exports = TWEEN_DEFAULTS; + + +/***/ }), +/* 130 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function hasGetStart (def) +{ + return (!!def.getStart && typeof def.getStart === 'function'); +} + +function hasGetEnd (def) +{ + return (!!def.getEnd && typeof def.getEnd === 'function'); +} + +function hasGetters (def) +{ + return hasGetStart(def) || hasGetEnd(def); +} + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetValueOp + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {*} propertyValue - [description] + * + * @return {function} [description] + */ +var GetValueOp = function (key, propertyValue) +{ + var callbacks; + + // The returned value sets what the property will be at the END of the Tween (usually called at the start of the Tween) + var getEnd = function (target, key, value) { return value; }; + + // The returned value sets what the property will be at the START of the Tween (usually called at the end of the Tween) + var getStart = function (target, key, value) { return value; }; + + var t = typeof(propertyValue); + + if (t === 'number') + { + // props: { + // x: 400, + // y: 300 + // } + + getEnd = function () + { + return propertyValue; + }; + } + else if (t === 'string') + { + // props: { + // x: '+=400', + // y: '-=300', + // z: '*=2', + // w: '/=2' + // } + + var op = propertyValue[0]; + var num = parseFloat(propertyValue.substr(2)); + + switch (op) + { + case '+': + getEnd = function (target, key, value) + { + return value + num; + }; + break; + + case '-': + getEnd = function (target, key, value) + { + return value - num; + }; + break; + + case '*': + getEnd = function (target, key, value) + { + return value * num; + }; + break; + + case '/': + getEnd = function (target, key, value) + { + return value / num; + }; + break; + + default: + getEnd = function () + { + return parseFloat(propertyValue); + }; + } + } + else if (t === 'function') + { + // The same as setting just the getEnd function and no getStart + + // props: { + // x: function (target, key, value) { return value + 50); }, + // } + + getEnd = propertyValue; + } + else if (t === 'object' && hasGetters(propertyValue)) + { + /* + x: { + // Called at the start of the Tween. The returned value sets what the property will be at the END of the Tween. + getEnd: function (target, key, value) + { + return value; + }, + + // Called at the end of the Tween. The returned value sets what the property will be at the START of the Tween. + getStart: function (target, key, value) + { + return value; + } + } + */ + + if (hasGetEnd(propertyValue)) + { + getEnd = propertyValue.getEnd; + } + + if (hasGetStart(propertyValue)) + { + getStart = propertyValue.getStart; + } + } + else if (propertyValue.hasOwnProperty('value')) + { + // Value may still be a string, function or a number + // props: { + // x: { value: 400, ... }, + // y: { value: 300, ... } + // } + + callbacks = GetValueOp(key, propertyValue.value); + } + + // If callback not set by the else if block above then set it here and return it + if (!callbacks) + { + callbacks = { + getEnd: getEnd, + getStart: getStart + }; + } + + return callbacks; +}; + +module.exports = GetValueOp; + + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); + +/** + * [description] + * + * @function Phaser.Tweens.Builders.GetTargets + * @since 3.0.0 + * + * @param {object} config - [description] + * + * @return {array} [description] + */ +var GetTargets = function (config) +{ + var targets = GetValue(config, 'targets', null); + + if (targets === null) + { + return targets; + } + + if (typeof targets === 'function') + { + targets = targets.call(); + } + + if (!Array.isArray(targets)) + { + targets = [ targets ]; + } + + return targets; +}; + +module.exports = GetTargets; + + +/***/ }), +/* 132 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var MapData = __webpack_require__(77); +var Parse = __webpack_require__(217); +var Tilemap = __webpack_require__(209); + +/** + * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When + * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from + * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For + * an empty map, you should specify tileWidth, tileHeight, width & height. + * + * @function Phaser.Tilemaps.ParseToTilemap + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. + * @param {integer} [width=10] - The width of the map in tiles. + * @param {integer} [height=10] - The height of the map in tiles. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.Tilemap} + */ +var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull) +{ + if (tileWidth === undefined) { tileWidth = 32; } + if (tileHeight === undefined) { tileHeight = 32; } + if (width === undefined) { width = 10; } + if (height === undefined) { height = 10; } + if (insertNull === undefined) { insertNull = false; } + + var mapData = null; + + if (Array.isArray(data)) + { + var name = key !== undefined ? key : 'map'; + mapData = Parse(name, Formats.ARRAY_2D, data, tileWidth, tileHeight, insertNull); + } + else if (key !== undefined) + { + var tilemapData = scene.cache.tilemap.get(key); + + if (!tilemapData) + { + console.warn('No map data found for key ' + key); + } + else + { + mapData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull); + } + } + + if (mapData === null) + { + mapData = new MapData({ + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + } + + return new Tilemap(scene, mapData); +}; + +module.exports = ParseToTilemap; + + +/***/ }), +/* 133 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var LayerData = __webpack_require__(78); +var MapData = __webpack_require__(77); +var Tile = __webpack_require__(55); + +/** + * Parses a 2D array of tile indexes into a new MapData object with a single layer. + * + * @function Phaser.Tilemaps.Parsers.Parse2DArray + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer[][]} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.MapData} [description] + */ +var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull) +{ + var layerData = new LayerData({ + tileWidth: tileWidth, + tileHeight: tileHeight + }); + + var mapData = new MapData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + format: Formats.ARRAY_2D, + layers: [ layerData ] + }); + + var tiles = []; + var height = data.length; + var width = 0; + + for (var y = 0; y < data.length; y++) + { + tiles[y] = []; + var row = data[y]; + + for (var x = 0; x < row.length; x++) + { + var tileIndex = parseInt(row[x], 10); + + if (isNaN(tileIndex) || tileIndex === -1) + { + tiles[y][x] = insertNull + ? null + : new Tile(layerData, -1, x, y, tileWidth, tileHeight); + } + else + { + tiles[y][x] = new Tile(layerData, tileIndex, x, y, tileWidth, tileHeight); + } + } + + if (width === 0) + { + width = row.length; + } + } + + mapData.width = layerData.width = width; + mapData.height = layerData.height = height; + mapData.widthInPixels = layerData.widthInPixels = width * tileWidth; + mapData.heightInPixels = layerData.heightInPixels = height * tileHeight; + layerData.data = tiles; + + return mapData; +}; + +module.exports = Parse2DArray; + + +/***/ }), +/* 134 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internally used method to keep track of the tile indexes that collide within a layer. This + * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. + * + * @function Phaser.Tilemaps.Components.SetLayerCollisionIndex + * @private + * @since 3.0.0 + * + * @param {integer} tileIndex - The tile index to set the collision boolean for. + * @param {boolean} [collides=true] - Should the tile index collide or not? + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetLayerCollisionIndex = function (tileIndex, collides, layer) +{ + var loc = layer.collideIndexes.indexOf(tileIndex); + + if (collides && loc === -1) + { + layer.collideIndexes.push(tileIndex); + } + else if (!collides && loc !== -1) + { + layer.collideIndexes.splice(loc, 1); + } +}; + +module.exports = SetLayerCollisionIndex; + + +/***/ }), +/* 135 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tile = __webpack_require__(55); +var IsInLayerBounds = __webpack_require__(79); +var CalculateFacesAt = __webpack_require__(136); +var SetTileCollision = __webpack_require__(56); + +/** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * @function Phaser.Tilemaps.Components.PutTileAt + * @private + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + */ +var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) +{ + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var oldTile = layer.data[tileY][tileX]; + var oldTileCollides = oldTile && oldTile.collides; + + if (tile instanceof Tile) + { + if (layer.data[tileY][tileX] === null) + { + layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); + } + layer.data[tileY][tileX].copy(tile); + } + else + { + var index = tile; + if (layer.data[tileY][tileX] === null) + { + layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight); + } + else + { + layer.data[tileY][tileX].index = index; + } + } + + // Updating colliding flag on the new tile + var newTile = layer.data[tileY][tileX]; + var collides = layer.collideIndexes.indexOf(newTile.index) !== -1; + SetTileCollision(newTile, collides); + + // Recalculate faces only if the colliding flag at (tileX, tileY) has changed + if (recalculateFaces && (oldTileCollides !== newTile.collides)) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return newTile; +}; + +module.exports = PutTileAt; + + + +/***/ }), +/* 136 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(102); + +/** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @function Phaser.Tilemaps.Components.CalculateFacesAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var CalculateFacesAt = function (tileX, tileY, layer) +{ + var tile = GetTileAt(tileX, tileY, true, layer); + var above = GetTileAt(tileX, tileY - 1, true, layer); + var below = GetTileAt(tileX, tileY + 1, true, layer); + var left = GetTileAt(tileX - 1, tileY, true, layer); + var right = GetTileAt(tileX + 1, tileY, true, layer); + var tileCollides = tile && tile.collides; + + // Assume the changed tile has all interesting edges + if (tileCollides) + { + tile.faceTop = true; + tile.faceBottom = true; + tile.faceLeft = true; + tile.faceRight = true; + } + + // Reset edges that are shared between tile and its neighbors + if (above && above.collides) + { + if (tileCollides) { tile.faceTop = false; } + above.faceBottom = !tileCollides; + } + + if (below && below.collides) + { + if (tileCollides) { tile.faceBottom = false; } + below.faceTop = !tileCollides; + } + + if (left && left.collides) + { + if (tileCollides) { tile.faceLeft = false; } + left.faceRight = !tileCollides; + } + + if (right && right.collides) + { + if (tileCollides) { tile.faceRight = false; } + right.faceLeft = !tileCollides; + } + + if (tile && !tile.collides) { tile.resetFaces(); } + + return tile; +}; + +module.exports = CalculateFacesAt; + + +/***/ }), +/* 137 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Composite` module contains methods for creating and manipulating composite bodies. +* A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. +* It is important to use the functions in this module to modify composites, rather than directly modifying their properties. +* Note that the `Matter.World` object is also a type of `Matter.Composite` and as such all composite methods here can also operate on a `Matter.World`. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Composite +*/ + +var Composite = {}; + +module.exports = Composite; + +var Events = __webpack_require__(195); +var Common = __webpack_require__(33); +var Bounds = __webpack_require__(80); +var Body = __webpack_require__(67); + +(function() { + + /** + * Creates a new composite. The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properites section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {} [options] + * @return {composite} A new composite + */ + Composite.create = function(options) { + return Common.extend({ + id: Common.nextId(), + type: 'composite', + parent: null, + isModified: false, + bodies: [], + constraints: [], + composites: [], + label: 'Composite', + plugin: {} + }, options); + }; + + /** + * Sets the composite's `isModified` flag. + * If `updateParents` is true, all parents will be set (default: false). + * If `updateChildren` is true, all children will be set (default: false). + * @method setModified + * @param {composite} composite + * @param {boolean} isModified + * @param {boolean} [updateParents=false] + * @param {boolean} [updateChildren=false] + */ + Composite.setModified = function(composite, isModified, updateParents, updateChildren) { + composite.isModified = isModified; + + if (updateParents && composite.parent) { + Composite.setModified(composite.parent, isModified, updateParents, updateChildren); + } + + if (updateChildren) { + for(var i = 0; i < composite.composites.length; i++) { + var childComposite = composite.composites[i]; + Composite.setModified(childComposite, isModified, updateParents, updateChildren); + } + } + }; + + /** + * Generic add function. Adds one or many body(s), constraint(s) or a composite(s) to the given composite. + * Triggers `beforeAdd` and `afterAdd` events on the `composite`. + * @method add + * @param {composite} composite + * @param {} object + * @return {composite} The original composite with the objects added + */ + Composite.add = function(composite, object) { + var objects = [].concat(object); + + Events.trigger(composite, 'beforeAdd', { object: object }); + + for (var i = 0; i < objects.length; i++) { + var obj = objects[i]; + + switch (obj.type) { + + case 'body': + // skip adding compound parts + if (obj.parent !== obj) { + Common.warn('Composite.add: skipped adding a compound body part (you must add its parent instead)'); + break; + } + + Composite.addBody(composite, obj); + break; + case 'constraint': + Composite.addConstraint(composite, obj); + break; + case 'composite': + Composite.addComposite(composite, obj); + break; + case 'mouseConstraint': + Composite.addConstraint(composite, obj.constraint); + break; + + } + } + + Events.trigger(composite, 'afterAdd', { object: object }); + + return composite; + }; + + /** + * Generic remove function. Removes one or many body(s), constraint(s) or a composite(s) to the given composite. + * Optionally searching its children recursively. + * Triggers `beforeRemove` and `afterRemove` events on the `composite`. + * @method remove + * @param {composite} composite + * @param {} object + * @param {boolean} [deep=false] + * @return {composite} The original composite with the objects removed + */ + Composite.remove = function(composite, object, deep) { + var objects = [].concat(object); + + Events.trigger(composite, 'beforeRemove', { object: object }); + + for (var i = 0; i < objects.length; i++) { + var obj = objects[i]; + + switch (obj.type) { + + case 'body': + Composite.removeBody(composite, obj, deep); + break; + case 'constraint': + Composite.removeConstraint(composite, obj, deep); + break; + case 'composite': + Composite.removeComposite(composite, obj, deep); + break; + case 'mouseConstraint': + Composite.removeConstraint(composite, obj.constraint); + break; + + } + } + + Events.trigger(composite, 'afterRemove', { object: object }); + + return composite; + }; + + /** + * Adds a composite to the given composite. + * @private + * @method addComposite + * @param {composite} compositeA + * @param {composite} compositeB + * @return {composite} The original compositeA with the objects from compositeB added + */ + Composite.addComposite = function(compositeA, compositeB) { + compositeA.composites.push(compositeB); + compositeB.parent = compositeA; + Composite.setModified(compositeA, true, true, false); + return compositeA; + }; + + /** + * Removes a composite from the given composite, and optionally searching its children recursively. + * @private + * @method removeComposite + * @param {composite} compositeA + * @param {composite} compositeB + * @param {boolean} [deep=false] + * @return {composite} The original compositeA with the composite removed + */ + Composite.removeComposite = function(compositeA, compositeB, deep) { + var position = compositeA.composites.indexOf(compositeB); + if (position !== -1) { + Composite.removeCompositeAt(compositeA, position); + Composite.setModified(compositeA, true, true, false); + } + + if (deep) { + for (var i = 0; i < compositeA.composites.length; i++){ + Composite.removeComposite(compositeA.composites[i], compositeB, true); + } + } + + return compositeA; + }; + + /** + * Removes a composite from the given composite. + * @private + * @method removeCompositeAt + * @param {composite} composite + * @param {number} position + * @return {composite} The original composite with the composite removed + */ + Composite.removeCompositeAt = function(composite, position) { + composite.composites.splice(position, 1); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Adds a body to the given composite. + * @private + * @method addBody + * @param {composite} composite + * @param {body} body + * @return {composite} The original composite with the body added + */ + Composite.addBody = function(composite, body) { + composite.bodies.push(body); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Removes a body from the given composite, and optionally searching its children recursively. + * @private + * @method removeBody + * @param {composite} composite + * @param {body} body + * @param {boolean} [deep=false] + * @return {composite} The original composite with the body removed + */ + Composite.removeBody = function(composite, body, deep) { + var position = composite.bodies.indexOf(body); + if (position !== -1) { + Composite.removeBodyAt(composite, position); + Composite.setModified(composite, true, true, false); + } + + if (deep) { + for (var i = 0; i < composite.composites.length; i++){ + Composite.removeBody(composite.composites[i], body, true); + } + } + + return composite; + }; + + /** + * Removes a body from the given composite. + * @private + * @method removeBodyAt + * @param {composite} composite + * @param {number} position + * @return {composite} The original composite with the body removed + */ + Composite.removeBodyAt = function(composite, position) { + composite.bodies.splice(position, 1); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Adds a constraint to the given composite. + * @private + * @method addConstraint + * @param {composite} composite + * @param {constraint} constraint + * @return {composite} The original composite with the constraint added + */ + Composite.addConstraint = function(composite, constraint) { + composite.constraints.push(constraint); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Removes a constraint from the given composite, and optionally searching its children recursively. + * @private + * @method removeConstraint + * @param {composite} composite + * @param {constraint} constraint + * @param {boolean} [deep=false] + * @return {composite} The original composite with the constraint removed + */ + Composite.removeConstraint = function(composite, constraint, deep) { + var position = composite.constraints.indexOf(constraint); + if (position !== -1) { + Composite.removeConstraintAt(composite, position); + } + + if (deep) { + for (var i = 0; i < composite.composites.length; i++){ + Composite.removeConstraint(composite.composites[i], constraint, true); + } + } + + return composite; + }; + + /** + * Removes a body from the given composite. + * @private + * @method removeConstraintAt + * @param {composite} composite + * @param {number} position + * @return {composite} The original composite with the constraint removed + */ + Composite.removeConstraintAt = function(composite, position) { + composite.constraints.splice(position, 1); + Composite.setModified(composite, true, true, false); + return composite; + }; + + /** + * Removes all bodies, constraints and composites from the given composite. + * Optionally clearing its children recursively. + * @method clear + * @param {composite} composite + * @param {boolean} keepStatic + * @param {boolean} [deep=false] + */ + Composite.clear = function(composite, keepStatic, deep) { + if (deep) { + for (var i = 0; i < composite.composites.length; i++){ + Composite.clear(composite.composites[i], keepStatic, true); + } + } + + if (keepStatic) { + composite.bodies = composite.bodies.filter(function(body) { return body.isStatic; }); + } else { + composite.bodies.length = 0; + } + + composite.constraints.length = 0; + composite.composites.length = 0; + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Returns all bodies in the given composite, including all bodies in its children, recursively. + * @method allBodies + * @param {composite} composite + * @return {body[]} All the bodies + */ + Composite.allBodies = function(composite) { + var bodies = [].concat(composite.bodies); + + for (var i = 0; i < composite.composites.length; i++) + bodies = bodies.concat(Composite.allBodies(composite.composites[i])); + + return bodies; + }; + + /** + * Returns all constraints in the given composite, including all constraints in its children, recursively. + * @method allConstraints + * @param {composite} composite + * @return {constraint[]} All the constraints + */ + Composite.allConstraints = function(composite) { + var constraints = [].concat(composite.constraints); + + for (var i = 0; i < composite.composites.length; i++) + constraints = constraints.concat(Composite.allConstraints(composite.composites[i])); + + return constraints; + }; + + /** + * Returns all composites in the given composite, including all composites in its children, recursively. + * @method allComposites + * @param {composite} composite + * @return {composite[]} All the composites + */ + Composite.allComposites = function(composite) { + var composites = [].concat(composite.composites); + + for (var i = 0; i < composite.composites.length; i++) + composites = composites.concat(Composite.allComposites(composite.composites[i])); + + return composites; + }; + + /** + * Searches the composite recursively for an object matching the type and id supplied, null if not found. + * @method get + * @param {composite} composite + * @param {number} id + * @param {string} type + * @return {object} The requested object, if found + */ + Composite.get = function(composite, id, type) { + var objects, + object; + + switch (type) { + case 'body': + objects = Composite.allBodies(composite); + break; + case 'constraint': + objects = Composite.allConstraints(composite); + break; + case 'composite': + objects = Composite.allComposites(composite).concat(composite); + break; + } + + if (!objects) + return null; + + object = objects.filter(function(object) { + return object.id.toString() === id.toString(); + }); + + return object.length === 0 ? null : object[0]; + }; + + /** + * Moves the given object(s) from compositeA to compositeB (equal to a remove followed by an add). + * @method move + * @param {compositeA} compositeA + * @param {object[]} objects + * @param {compositeB} compositeB + * @return {composite} Returns compositeA + */ + Composite.move = function(compositeA, objects, compositeB) { + Composite.remove(compositeA, objects); + Composite.add(compositeB, objects); + return compositeA; + }; + + /** + * Assigns new ids for all objects in the composite, recursively. + * @method rebase + * @param {composite} composite + * @return {composite} Returns composite + */ + Composite.rebase = function(composite) { + var objects = Composite.allBodies(composite) + .concat(Composite.allConstraints(composite)) + .concat(Composite.allComposites(composite)); + + for (var i = 0; i < objects.length; i++) { + objects[i].id = Common.nextId(); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Translates all children in the composite by a given vector relative to their current positions, + * without imparting any velocity. + * @method translate + * @param {composite} composite + * @param {vector} translation + * @param {bool} [recursive=true] + */ + Composite.translate = function(composite, translation, recursive) { + var bodies = recursive ? Composite.allBodies(composite) : composite.bodies; + + for (var i = 0; i < bodies.length; i++) { + Body.translate(bodies[i], translation); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Rotates all children in the composite by a given angle about the given point, without imparting any angular velocity. + * @method rotate + * @param {composite} composite + * @param {number} rotation + * @param {vector} point + * @param {bool} [recursive=true] + */ + Composite.rotate = function(composite, rotation, point, recursive) { + var cos = Math.cos(rotation), + sin = Math.sin(rotation), + bodies = recursive ? Composite.allBodies(composite) : composite.bodies; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + dx = body.position.x - point.x, + dy = body.position.y - point.y; + + Body.setPosition(body, { + x: point.x + (dx * cos - dy * sin), + y: point.y + (dx * sin + dy * cos) + }); + + Body.rotate(body, rotation); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Scales all children in the composite, including updating physical properties (mass, area, axes, inertia), from a world-space point. + * @method scale + * @param {composite} composite + * @param {number} scaleX + * @param {number} scaleY + * @param {vector} point + * @param {bool} [recursive=true] + */ + Composite.scale = function(composite, scaleX, scaleY, point, recursive) { + var bodies = recursive ? Composite.allBodies(composite) : composite.bodies; + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + dx = body.position.x - point.x, + dy = body.position.y - point.y; + + Body.setPosition(body, { + x: point.x + dx * scaleX, + y: point.y + dy * scaleY + }); + + Body.scale(body, scaleX, scaleY); + } + + Composite.setModified(composite, true, true, false); + + return composite; + }; + + /** + * Returns the union of the bounds of all of the composite's bodies. + * @method bounds + * @param {composite} composite The composite. + * @returns {bounds} The composite bounds. + */ + Composite.bounds = function(composite) { + var bodies = Composite.allBodies(composite), + vertices = []; + + for (var i = 0; i < bodies.length; i += 1) { + var body = bodies[i]; + vertices.push(body.bounds.min, body.bounds.max); + } + + return Bounds.create(vertices); + }; + + /* + * + * Events Documentation + * + */ + + /** + * Fired when a call to `Composite.add` is made, before objects have been added. + * + * @event beforeAdd + * @param {} event An event object + * @param {} event.object The object(s) to be added (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a call to `Composite.add` is made, after objects have been added. + * + * @event afterAdd + * @param {} event An event object + * @param {} event.object The object(s) that have been added (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a call to `Composite.remove` is made, before objects have been removed. + * + * @event beforeRemove + * @param {} event An event object + * @param {} event.object The object(s) to be removed (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /** + * Fired when a call to `Composite.remove` is made, after objects have been removed. + * + * @event afterRemove + * @param {} event An event object + * @param {} event.object The object(s) that have been removed (may be a single body, constraint, composite or a mixed array of these) + * @param {} event.source The source object of the event + * @param {} event.name The name of the event + */ + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. + * + * @property id + * @type number + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "composite" + * @readOnly + */ + + /** + * An arbitrary `String` name to help the user identify and manage composites. + * + * @property label + * @type string + * @default "Composite" + */ + + /** + * A flag that specifies whether the composite has been modified during the current step. + * Most `Matter.Composite` methods will automatically set this flag to `true` to inform the engine of changes to be handled. + * If you need to change it manually, you should use the `Composite.setModified` method. + * + * @property isModified + * @type boolean + * @default false + */ + + /** + * The `Composite` that is the parent of this composite. It is automatically managed by the `Matter.Composite` methods. + * + * @property parent + * @type composite + * @default null + */ + + /** + * An array of `Body` that are _direct_ children of this composite. + * To add or remove bodies you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. + * If you wish to recursively find all descendants, you should use the `Composite.allBodies` method. + * + * @property bodies + * @type body[] + * @default [] + */ + + /** + * An array of `Constraint` that are _direct_ children of this composite. + * To add or remove constraints you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. + * If you wish to recursively find all descendants, you should use the `Composite.allConstraints` method. + * + * @property constraints + * @type constraint[] + * @default [] + */ + + /** + * An array of `Composite` that are _direct_ children of this composite. + * To add or remove composites you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. + * If you wish to recursively find all descendants, you should use the `Composite.allComposites` method. + * + * @property composites + * @type composite[] + * @default [] + */ + + /** + * An object reserved for storing plugin-specific properties. + * + * @property plugin + * @type {} + */ + +})(); + + +/***/ }), +/* 138 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A representation of a vector in 3D space. + * + * A three-component vector. + * + * @class Vector3 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + */ +var Vector3 = new Class({ + + initialize: + + function Vector3 (x, y, z) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector3#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector3#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector3#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.z = 0; + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + }, + + /** + * Set this Vector to point up. + * + * Sets the y component of the vector to 1, and the others to 0. + * + * @method Phaser.Math.Vector3#up + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + up: function () + { + this.x = 0; + this.y = 1; + this.z = 0; + + return this; + }, + + /** + * Make a clone of this Vector3. + * + * @method Phaser.Math.Vector3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} A new Vector3 object containing this Vectors values. + */ + clone: function () + { + return new Vector3(this.x, this.y, this.z); + }, + + /** + * Calculate the cross (vector) product of two given Vectors. + * + * @method Phaser.Math.Vector3#crossVectors + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - The first Vector to multiply. + * @param {Phaser.Math.Vector3} b - The second Vector to multiply. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + crossVectors: function (a, b) + { + var ax = a.x; + var ay = a.y; + var az = a.z; + var bx = b.x; + var by = b.y; + var bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict equality check against each Vector's components. + * + * @method Phaser.Math.Vector3#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to compare against. + * + * @return {boolean} True if the two vectors strictly match, otherwise false. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); + }, + + /** + * Copy the components of a given Vector into this Vector. + * + * @method Phaser.Math.Vector3#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + + return this; + }, + + /** + * Set the `x`, `y`, and `z` components of this Vector to the given `x`, `y`, and `z` values. + * + * @method Phaser.Math.Vector3#set + * @since 3.0.0 + * + * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y and z components. + * @param {number} [y] - The y value to set for this Vector. + * @param {number} [z] - The z value to set for this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + set: function (x, y, z) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + + return this; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector3#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector3#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector3#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector3#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + scale: function (scale) + { + if (isFinite(scale)) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + } + else + { + this.x = 0; + this.y = 0; + this.z = 0; + } + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector3#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + + return this; + }, + + /** + * Negate the `x`, `y` and `z` components of this Vector. + * + * @method Phaser.Math.Vector3#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector3#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector3#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return dx * dx + dy * dy + dz * dz; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector3#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return Math.sqrt(x * x + y * y + z * z); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector3#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return x * x + y * y + z * z; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector3#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var len = x * x + y * y + z * z; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector3#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to dot product with this Vector3. + * + * @return {number} The dot product of this Vector and `v`. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z; + }, + + /** + * Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector. + * + * @method Phaser.Math.Vector3#cross + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector to cross product with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + cross: function (v) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var bx = v.x; + var by = v.y; + var bz = v.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector3#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector3#transformMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformMat3: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = x * m[0] + y * m[3] + z * m[6]; + this.y = x * m[1] + y * m[4] + z * m[7]; + this.z = x * m[2] + y * m[5] + z * m[8]; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector3#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformCoordinates + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformCoordinates: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; + var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; + var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; + var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; + + this.x = tx / tw; + this.y = ty / tw; + this.z = tz / tw; + + return this; + }, + + /** + * Transform this Vector with the given Quaternion. + * + * @method Phaser.Math.Vector3#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformQuat: function (q) + { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, + * e.g. unprojecting a 2D point into 3D space. + * + * @method Phaser.Math.Vector3#project + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to multiply this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + project: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var a00 = m[0]; + var a01 = m[1]; + var a02 = m[2]; + var a03 = m[3]; + var a10 = m[4]; + var a11 = m[5]; + var a12 = m[6]; + var a13 = m[7]; + var a20 = m[8]; + var a21 = m[9]; + var a22 = m[10]; + var a23 = m[11]; + var a30 = m[12]; + var a31 = m[13]; + var a32 = m[14]; + var a33 = m[15]; + + var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); + + this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; + this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; + this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; + + return this; + }, + + /** + * Unproject this point from 2D space to 3D space. + * The point should have its x and y properties set to + * 2D screen space, and the z either at 0 (near plane) + * or 1 (far plane). The provided matrix is assumed to already + * be combined, i.e. projection * view * model. + * + * After this operation, this vector's (x, y, z) components will + * represent the unprojected 3D coordinate. + * + * @method Phaser.Math.Vector3#unproject + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} viewport - Screen x, y, width and height in pixels. + * @param {Phaser.Math.Matrix4} invProjectionView - Combined projection and view matrix. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + unproject: function (viewport, invProjectionView) + { + var viewX = viewport.x; + var viewY = viewport.y; + var viewWidth = viewport.z; + var viewHeight = viewport.w; + + var x = this.x - viewX; + var y = (viewHeight - this.y - 1) - viewY; + var z = this.z; + + this.x = (2 * x) / viewWidth - 1; + this.y = (2 * y) / viewHeight - 1; + this.z = 2 * z - 1; + + return this.project(invProjectionView); + }, + + /** + * Make this Vector the zero vector (0, 0, 0). + * + * @method Phaser.Math.Vector3#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + + return this; + } + +}); + +/* +Vector3.Zero = function () +{ + return new Vector3(0, 0, 0); +}; + +Vector3.Up = function () +{ + return new Vector3(0, 1.0, 0); +}; + +Vector3.Copy = function (source) +{ + return new Vector3(source.x, source.y, source.z); +}; + +Vector3.TransformCoordinates = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; + var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; + + return new Vector3(x / w, y / w, z / w); +}; + +Vector3.TransformNormal = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); + + return new Vector3(x, y, z); +}; + +Vector3.Dot = function (left, right) +{ + return (left.x * right.x + left.y * right.y + left.z * right.z); +}; + +Vector3.Cross = function (left, right) +{ + var x = left.y * right.z - left.z * right.y; + var y = left.z * right.x - left.x * right.z; + var z = left.x * right.y - left.y * right.x; + + return new Vector3(x, y, z); +}; + +Vector3.Normalize = function (vector) +{ + var newVector = Vector3.Copy(vector); + newVector.normalize(); + + return newVector; +}; + +Vector3.Distance = function (value1, value2) +{ + return Math.sqrt(Vector3.DistanceSquared(value1, value2)); +}; + +Vector3.DistanceSquared = function (value1, value2) +{ + var x = value1.x - value2.x; + var y = value1.y - value2.y; + var z = value1.z - value2.z; + + return (x * x) + (y * y) + (z * z); +}; +*/ + +module.exports = Vector3; + + +/***/ }), +/* 139 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); +var ParseXML = __webpack_require__(343); + +/** + * @typedef {object} Phaser.Loader.FileTypes.XMLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='xml'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single XML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. + * + * @class XMLFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var XMLFile = new Class({ + + Extends: File, + + initialize: + + function XMLFile (loader, key, url, xhrSettings) + { + var extension = 'xml'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'xml', + cache: loader.cacheManager.xml, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.XMLFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = ParseXML(this.xhrLoader.responseText); + + if (this.data) + { + this.onProcessComplete(); + } + else + { + console.warn('Invalid XMLFile: ' + this.key); + + this.onProcessError(); + } + } + +}); + +/** + * Adds an XML file, or array of XML files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.xml('wavedata', 'files/AlienWaveData.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global XML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the XML Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the XML Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.xml({ + * key: 'wavedata', + * url: 'files/AlienWaveData.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.XMLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.xml('wavedata', 'files/AlienWaveData.xml'); + * // and later in your game ... + * var data = this.cache.xml.get('wavedata'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the XML Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the XML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#xml + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig|Phaser.Loader.FileTypes.XMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('xml', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new XMLFile(this, key[i])); + } + } + else + { + this.addFile(new XMLFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = XMLFile; + + +/***/ }), +/* 140 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(20); +var XHRSettings = __webpack_require__(105); + +/** + * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * + * The new object is seeded by the values given in the global settings, but any setting in + * the local object overrides the global ones. + * + * @function Phaser.Loader.MergeXHRSettings + * @since 3.0.0 + * + * @param {XHRSettingsObject} global - The global XHRSettings object. + * @param {XHRSettingsObject} local - The local XHRSettings object. + * + * @return {XHRSettingsObject} A newly formed XHRSettings object. + */ +var MergeXHRSettings = function (global, local) +{ + var output = (global === undefined) ? XHRSettings() : Extend({}, global); + + if (local) + { + for (var setting in local) + { + if (local[setting] !== undefined) + { + output[setting] = local[setting]; + } + } + } + + return output; +}; + +module.exports = MergeXHRSettings; + + +/***/ }), +/* 141 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given a File and a baseURL value this returns the URL the File will use to download from. + * + * @function Phaser.Loader.GetURL + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File object. + * @param {string} baseURL - A default base URL. + * + * @return {string} The URL the File will use. + */ +var GetURL = function (file, baseURL) +{ + if (!file.url) + { + return false; + } + + if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) + { + return file.url; + } + else + { + return baseURL + file.url; + } +}; + +module.exports = GetURL; + + +/***/ }), +/* 142 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Snap a value to nearest grid slice, using floor. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10`. + * As will `14` snap to `10`... but `16` will snap to `15`. + * + * @function Phaser.Math.Snap.Floor + * @since 3.0.0 + * + * @param {number} value - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. + * + * @return {number} The snapped value. + */ +var SnapFloor = function (value, gap, start, divide) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.floor(value / gap); + + return (divide) ? (start + value) / gap : start + value; +}; + +module.exports = SnapFloor; + + +/***/ }), +/* 143 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Keyboard Codes. + * + * @name Phaser.Input.Keyboard.KeyCodes + * @enum {integer} + * @memberof Phaser.Input.Keyboard + * @readonly + * @since 3.0.0 + */ + +var KeyCodes = { + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACKSPACE + */ + BACKSPACE: 8, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.TAB + */ + TAB: 9, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ENTER + */ + ENTER: 13, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SHIFT + */ + SHIFT: 16, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CTRL + */ + CTRL: 17, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ALT + */ + ALT: 18, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAUSE + */ + PAUSE: 19, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CAPS_LOCK + */ + CAPS_LOCK: 20, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ESC + */ + ESC: 27, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SPACE + */ + SPACE: 32, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_UP + */ + PAGE_UP: 33, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PAGE_DOWN + */ + PAGE_DOWN: 34, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.END + */ + END: 35, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.HOME + */ + HOME: 36, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.LEFT + */ + LEFT: 37, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.UP + */ + UP: 38, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.RIGHT + */ + RIGHT: 39, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.DOWN + */ + DOWN: 40, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PRINT_SCREEN + */ + PRINT_SCREEN: 42, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.INSERT + */ + INSERT: 45, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.DELETE + */ + DELETE: 46, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ZERO + */ + ZERO: 48, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.ONE + */ + ONE: 49, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.TWO + */ + TWO: 50, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.THREE + */ + THREE: 51, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FOUR + */ + FOUR: 52, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FIVE + */ + FIVE: 53, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SIX + */ + SIX: 54, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SEVEN + */ + SEVEN: 55, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.EIGHT + */ + EIGHT: 56, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NINE + */ + NINE: 57, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ZERO + */ + NUMPAD_ZERO: 96, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_ONE + */ + NUMPAD_ONE: 97, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_TWO + */ + NUMPAD_TWO: 98, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_THREE + */ + NUMPAD_THREE: 99, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FOUR + */ + NUMPAD_FOUR: 100, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_FIVE + */ + NUMPAD_FIVE: 101, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SIX + */ + NUMPAD_SIX: 102, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_SEVEN + */ + NUMPAD_SEVEN: 103, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_EIGHT + */ + NUMPAD_EIGHT: 104, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.NUMPAD_NINE + */ + NUMPAD_NINE: 105, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.A + */ + A: 65, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.B + */ + B: 66, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.C + */ + C: 67, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.D + */ + D: 68, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.E + */ + E: 69, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F + */ + F: 70, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.G + */ + G: 71, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.H + */ + H: 72, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.I + */ + I: 73, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.J + */ + J: 74, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.K + */ + K: 75, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.L + */ + L: 76, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.M + */ + M: 77, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.N + */ + N: 78, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.O + */ + O: 79, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.P + */ + P: 80, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Q + */ + Q: 81, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.R + */ + R: 82, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.S + */ + S: 83, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.T + */ + T: 84, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.U + */ + U: 85, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.V + */ + V: 86, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.W + */ + W: 87, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.X + */ + X: 88, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Y + */ + Y: 89, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.Z + */ + Z: 90, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F1 + */ + F1: 112, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F2 + */ + F2: 113, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F3 + */ + F3: 114, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F4 + */ + F4: 115, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F5 + */ + F5: 116, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F6 + */ + F6: 117, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F7 + */ + F7: 118, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F8 + */ + F8: 119, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F9 + */ + F9: 120, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F10 + */ + F10: 121, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F11 + */ + F11: 122, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.F12 + */ + F12: 123, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON + */ + SEMICOLON: 186, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PLUS + */ + PLUS: 187, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.COMMA + */ + COMMA: 188, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.MINUS + */ + MINUS: 189, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.PERIOD + */ + PERIOD: 190, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.FORWARD_SLASH + */ + FORWARD_SLASH: 191, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACK_SLASH + */ + BACK_SLASH: 220, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.QUOTES + */ + QUOTES: 222, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BACKTICK + */ + BACKTICK: 192, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.OPEN_BRACKET + */ + OPEN_BRACKET: 219, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET + */ + CLOSED_BRACKET: 221 + +}; + +module.exports = KeyCodes; + + +/***/ }), +/* 144 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.RotateAroundXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var RotateAroundXY = function (triangle, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = triangle.x1 - x; + var ty = triangle.y1 - y; + + triangle.x1 = tx * c - ty * s + x; + triangle.y1 = tx * s + ty * c + y; + + tx = triangle.x2 - x; + ty = triangle.y2 - y; + + triangle.x2 = tx * c - ty * s + x; + triangle.y2 = tx * s + ty * c + y; + + tx = triangle.x3 - x; + ty = triangle.y3 - y; + + triangle.x3 = tx * c - ty * s + x; + triangle.y3 = tx * s + ty * c + y; + + return triangle; +}; + +module.exports = RotateAroundXY; + + +/***/ }), +/* 145 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.GetAspectRatio + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var GetAspectRatio = function (rect) +{ + return (rect.height === 0) ? NaN : rect.width / rect.height; +}; + +module.exports = GetAspectRatio; + + +/***/ }), +/* 146 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rotate a line around the given coordinates by the given angle in radians. + * + * @function Phaser.Geom.Line.RotateAroundXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {number} x - The horizontal coordinate to rotate the line around. + * @param {number} y - The vertical coordinate to rotate the line around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var RotateAroundXY = function (line, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = line.x1 - x; + var ty = line.y1 - y; + + line.x1 = tx * c - ty * s + x; + line.y1 = tx * s + ty * c + y; + + tx = line.x2 - x; + ty = line.y2 - y; + + line.x2 = tx * c - ty * s + x; + line.y2 = tx * s + ty * c + y; + + return line; +}; + +module.exports = RotateAroundXY; + + +/***/ }), +/* 147 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// http://www.blackpawn.com/texts/pointinpoly/ + +// points is an array of Point-like objects with public x/y properties +// returns an array containing all points that are within the triangle, or an empty array if none +// if 'returnFirst' is true it will return after the first point within the triangle is found + +/** + * Filters an array of point-like objects to only those contained within a triangle. + * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). + * + * @function Phaser.Geom.Triangle.ContainsArray + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The triangle that the points are being checked in. + * @param {Phaser.Geom.Point[]} points - An array of point-like objects (objects that have an `x` and `y` property) + * @param {boolean} [returnFirst=false] - If `true`, return an array containing only the first point found that is within the triangle. + * @param {array} [out] - If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. + * + * @return {Phaser.Geom.Point[]} An array containing all the points from `points` that are within the triangle, if an array was provided as `out`, points will be appended to that array and it will also be returned here. + */ +var ContainsArray = function (triangle, points, returnFirst, out) +{ + if (returnFirst === undefined) { returnFirst = false; } + if (out === undefined) { out = []; } + + var v0x = triangle.x3 - triangle.x1; + var v0y = triangle.y3 - triangle.y1; + + var v1x = triangle.x2 - triangle.x1; + var v1y = triangle.y2 - triangle.y1; + + var dot00 = (v0x * v0x) + (v0y * v0y); + var dot01 = (v0x * v1x) + (v0y * v1y); + var dot11 = (v1x * v1x) + (v1y * v1y); + + // Compute barycentric coordinates + var b = ((dot00 * dot11) - (dot01 * dot01)); + var inv = (b === 0) ? 0 : (1 / b); + + var u; + var v; + var v2x; + var v2y; + var dot02; + var dot12; + + var x1 = triangle.x1; + var y1 = triangle.y1; + + for (var i = 0; i < points.length; i++) + { + v2x = points[i].x - x1; + v2y = points[i].y - y1; + + dot02 = (v0x * v2x) + (v0y * v2y); + dot12 = (v1x * v2x) + (v1y * v2y); + + u = ((dot11 * dot02) - (dot01 * dot12)) * inv; + v = ((dot00 * dot12) - (dot01 * dot02)) * inv; + + if (u >= 0 && v >= 0 && (u + v < 1)) + { + out.push({ x: points[i].x, y: points[i].y }); + + if (returnFirst) + { + break; + } + } + } + + return out; +}; + +module.exports = ContainsArray; + + +/***/ }), +/* 148 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.RectangleToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var RectangleToRectangle = function (rectA, rectB) +{ + if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) + { + return false; + } + + return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); +}; + +module.exports = RectangleToRectangle; + + +/***/ }), +/* 149 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Mesh = __webpack_require__(108); + +/** + * @classdesc + * A Quad Game Object. + * + * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single + * texture spread across them. + * + * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also + * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. + * + * @class Quad + * @extends Phaser.GameObjects.Mesh + * @memberof Phaser.GameObjects + * @constructor + * @webglOnly + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Quad belongs. + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Quad = new Class({ + + Extends: Mesh, + + initialize: + + function Quad (scene, x, y, texture, frame) + { + // 0----3 + // |\ B| + // | \ | + // | \ | + // | A \| + // | \ + // 1----2 + + var vertices = [ + 0, 0, // tl + 0, 0, // bl + 0, 0, // br + 0, 0, // tl + 0, 0, // br + 0, 0 // tr + ]; + + var uv = [ + 0, 0, // tl + 0, 1, // bl + 1, 1, // br + 0, 0, // tl + 1, 1, // br + 1, 0 // tr + ]; + + var colors = [ + 0xffffff, // tl + 0xffffff, // bl + 0xffffff, // br + 0xffffff, // tl + 0xffffff, // br + 0xffffff // tr + ]; + + var alphas = [ + 1, // tl + 1, // bl + 1, // br + 1, // tl + 1, // br + 1 // tr + ]; + + Mesh.call(this, scene, x, y, vertices, uv, colors, alphas, texture, frame); + + this.resetPosition(); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Quad#setFrame + * @since 3.11.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame) + { + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~8; + } + else + { + this.renderFlags |= 8; + } + + frame = this.frame; + + // TL + this.uv[0] = frame.u0; + this.uv[1] = frame.v0; + + // BL + this.uv[2] = frame.u0; + this.uv[3] = frame.v1; + + // BR + this.uv[4] = frame.u1; + this.uv[5] = frame.v1; + + // TL + this.uv[6] = frame.u0; + this.uv[7] = frame.v0; + + // BR + this.uv[8] = frame.u1; + this.uv[9] = frame.v1; + + // TR + this.uv[10] = frame.u1; + this.uv[11] = frame.v0; + + return this; + }, + + /** + * The top-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftX + * @type {number} + * @since 3.0.0 + */ + topLeftX: { + + get: function () + { + return this.x + this.vertices[0]; + }, + + set: function (value) + { + this.vertices[0] = value - this.x; + this.vertices[6] = value - this.x; + } + + }, + + /** + * The top-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftY + * @type {number} + * @since 3.0.0 + */ + topLeftY: { + + get: function () + { + return this.y + this.vertices[1]; + }, + + set: function (value) + { + this.vertices[1] = value - this.y; + this.vertices[7] = value - this.y; + } + + }, + + /** + * The top-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightX + * @type {number} + * @since 3.0.0 + */ + topRightX: { + + get: function () + { + return this.x + this.vertices[10]; + }, + + set: function (value) + { + this.vertices[10] = value - this.x; + } + + }, + + /** + * The top-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightY + * @type {number} + * @since 3.0.0 + */ + topRightY: { + + get: function () + { + return this.y + this.vertices[11]; + }, + + set: function (value) + { + this.vertices[11] = value - this.y; + } + + }, + + /** + * The bottom-left x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftX + * @type {number} + * @since 3.0.0 + */ + bottomLeftX: { + + get: function () + { + return this.x + this.vertices[2]; + }, + + set: function (value) + { + this.vertices[2] = value - this.x; + } + + }, + + /** + * The bottom-left y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftY + * @type {number} + * @since 3.0.0 + */ + bottomLeftY: { + + get: function () + { + return this.y + this.vertices[3]; + }, + + set: function (value) + { + this.vertices[3] = value - this.y; + } + + }, + + /** + * The bottom-right x vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightX + * @type {number} + * @since 3.0.0 + */ + bottomRightX: { + + get: function () + { + return this.x + this.vertices[4]; + }, + + set: function (value) + { + this.vertices[4] = value - this.x; + this.vertices[8] = value - this.x; + } + + }, + + /** + * The bottom-right y vertex of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightY + * @type {number} + * @since 3.0.0 + */ + bottomRightY: { + + get: function () + { + return this.y + this.vertices[5]; + }, + + set: function (value) + { + this.vertices[5] = value - this.y; + this.vertices[9] = value - this.y; + } + + }, + + /** + * The top-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftAlpha + * @type {number} + * @since 3.0.0 + */ + topLeftAlpha: { + + get: function () + { + return this.alphas[0]; + }, + + set: function (value) + { + this.alphas[0] = value; + this.alphas[3] = value; + } + + }, + + /** + * The top-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightAlpha + * @type {number} + * @since 3.0.0 + */ + topRightAlpha: { + + get: function () + { + return this.alphas[5]; + }, + + set: function (value) + { + this.alphas[5] = value; + } + + }, + + /** + * The bottom-left alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftAlpha + * @type {number} + * @since 3.0.0 + */ + bottomLeftAlpha: { + + get: function () + { + return this.alphas[1]; + }, + + set: function (value) + { + this.alphas[1] = value; + } + + }, + + /** + * The bottom-right alpha value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightAlpha + * @type {number} + * @since 3.0.0 + */ + bottomRightAlpha: { + + get: function () + { + return this.alphas[2]; + }, + + set: function (value) + { + this.alphas[2] = value; + this.alphas[4] = value; + } + + }, + + /** + * The top-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topLeftColor + * @type {number} + * @since 3.0.0 + */ + topLeftColor: { + + get: function () + { + return this.colors[0]; + }, + + set: function (value) + { + this.colors[0] = value; + this.colors[3] = value; + } + + }, + + /** + * The top-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#topRightColor + * @type {number} + * @since 3.0.0 + */ + topRightColor: { + + get: function () + { + return this.colors[5]; + }, + + set: function (value) + { + this.colors[5] = value; + } + + }, + + /** + * The bottom-left color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomLeftColor + * @type {number} + * @since 3.0.0 + */ + bottomLeftColor: { + + get: function () + { + return this.colors[1]; + }, + + set: function (value) + { + this.colors[1] = value; + } + + }, + + /** + * The bottom-right color value of this Quad. + * + * @name Phaser.GameObjects.Quad#bottomRightColor + * @type {number} + * @since 3.0.0 + */ + bottomRightColor: { + + get: function () + { + return this.colors[2]; + }, + + set: function (value) + { + this.colors[2] = value; + this.colors[4] = value; + } + + }, + + /** + * Sets the top-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopLeft: function (x, y) + { + this.topLeftX = x; + this.topLeftY = y; + + return this; + }, + + /** + * Sets the top-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setTopRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setTopRight: function (x, y) + { + this.topRightX = x; + this.topRightY = y; + + return this; + }, + + /** + * Sets the bottom-left vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomLeft + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomLeft: function (x, y) + { + this.bottomLeftX = x; + this.bottomLeftY = y; + + return this; + }, + + /** + * Sets the bottom-right vertex position of this Quad. + * + * @method Phaser.GameObjects.Quad#setBottomRight + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate of the vertex. + * @param {number} y - The vertical coordinate of the vertex. + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + setBottomRight: function (x, y) + { + this.bottomRightX = x; + this.bottomRightY = y; + + return this; + }, + + /** + * Resets the positions of the four corner vertices of this Quad. + * + * @method Phaser.GameObjects.Quad#resetPosition + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetPosition: function () + { + var x = this.x; + var y = this.y; + var halfWidth = Math.floor(this.width / 2); + var halfHeight = Math.floor(this.height / 2); + + this.setTopLeft(x - halfWidth, y - halfHeight); + this.setTopRight(x + halfWidth, y - halfHeight); + this.setBottomLeft(x - halfWidth, y + halfHeight); + this.setBottomRight(x + halfWidth, y + halfHeight); + + return this; + }, + + /** + * Resets the alpha values used by this Quad back to 1. + * + * @method Phaser.GameObjects.Quad#resetAlpha + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetAlpha: function () + { + var alphas = this.alphas; + + alphas[0] = 1; + alphas[1] = 1; + alphas[2] = 1; + alphas[3] = 1; + alphas[4] = 1; + alphas[5] = 1; + + return this; + }, + + /** + * Resets the color values used by this Quad back to 0xffffff. + * + * @method Phaser.GameObjects.Quad#resetColors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + resetColors: function () + { + var colors = this.colors; + + colors[0] = 0xffffff; + colors[1] = 0xffffff; + colors[2] = 0xffffff; + colors[3] = 0xffffff; + colors[4] = 0xffffff; + colors[5] = 0xffffff; + + return this; + }, + + /** + * Resets the position, alpha and color values used by this Quad. + * + * @method Phaser.GameObjects.Quad#reset + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Quad} This Game Object. + */ + reset: function () + { + this.resetPosition(); + + this.resetAlpha(); + + return this.resetColors(); + } + +}); + +module.exports = Quad; + + +/***/ }), +/* 150 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Checks whether the x and y coordinates are contained within this polygon. +// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva + +/** + * Checks if a point is within the bounds of a Polygon. + * + * @function Phaser.Geom.Polygon.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to check against. + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. + * + * @return {boolean} `true` if the point is within the bounds of the Polygon, otherwise `false`. + */ +var Contains = function (polygon, x, y) +{ + var inside = false; + + for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) + { + var ix = polygon.points[i].x; + var iy = polygon.points[i].y; + + var jx = polygon.points[j].x; + var jy = polygon.points[j].y; + + if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) + { + inside = !inside; + } + } + + return inside; +}; + +module.exports = Contains; + + +/***/ }), +/* 151 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(150); +var GetPoints = __webpack_require__(284); + +/** + * @classdesc + * [description] + * + * @class Polygon + * @memberof Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Geom.Point[]} [points] - [description] + */ +var Polygon = new Class({ + + initialize: + + function Polygon (points) + { + /** + * The area of this Polygon. + * + * @name Phaser.Geom.Polygon#area + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.area = 0; + + /** + * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] + * + * @name Phaser.Geom.Polygon#points + * @type {Phaser.Geom.Point[]} + * @since 3.0.0 + */ + this.points = []; + + if (points) + { + this.setTo(points); + } + }, + + /** + * Check to see if the Polygon contains the given x / y coordinates. + * + * @method Phaser.Geom.Polygon#contains + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check within the polygon. + * @param {number} y - The y coordinate to check within the polygon. + * + * @return {boolean} `true` if the coordinates are within the polygon, otherwise `false`. + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * Sets this Polygon to the given points. + * + * The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * `setTo` may also be called without any arguments to remove all points. + * + * @method Phaser.Geom.Polygon#setTo + * @since 3.0.0 + * + * @param {array} points - [description] + * + * @return {Phaser.Geom.Polygon} This Polygon object. + */ + setTo: function (points) + { + this.area = 0; + this.points = []; + + if (typeof points === 'string') + { + points = points.split(' '); + } + + if (!Array.isArray(points)) + { + return this; + } + + var p; + var y0 = Number.MAX_VALUE; + + // The points argument is an array, so iterate through it + for (var i = 0; i < points.length; i++) + { + p = { x: 0, y: 0 }; + + if (typeof points[i] === 'number' || typeof points[i] === 'string') + { + p.x = parseFloat(points[i]); + p.y = parseFloat(points[i + 1]); + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + + // Lowest boundary + if (p.y < y0) + { + y0 = p.y; + } + } + + this.calculateArea(y0); + + return this; + }, + + /** + * Calculates the area of the Polygon. This is available in the property Polygon.area + * + * @method Phaser.Geom.Polygon#calculateArea + * @since 3.0.0 + * + * @return {number} The area of the polygon. + */ + calculateArea: function () + { + if (this.points.length < 3) + { + this.area = 0; + + return this.area; + } + + var sum = 0; + var p1; + var p2; + + for (var i = 0; i < this.points.length - 1; i++) + { + p1 = this.points[i]; + p2 = this.points[i + 1]; + + sum += (p2.x - p1.x) * (p1.y + p2.y); + } + + p1 = this.points[0]; + p2 = this.points[this.points.length - 1]; + + sum += (p1.x - p2.x) * (p2.y + p1.y); + + this.area = -sum * 0.5; + + return this.area; + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Polygon#getPoints + * @since 3.12.0 + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the perimeter of the Polygon. + */ + getPoints: function (quantity, step, output) + { + return GetPoints(this, quantity, step, output); + } + +}); + +module.exports = Polygon; + + +/***/ }), +/* 152 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(24); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var CONST = __webpack_require__(26); +var GameObject = __webpack_require__(19); +var GetPowerOfTwo = __webpack_require__(294); +var Smoothing = __webpack_require__(120); +var TileSpriteRender = __webpack_require__(805); +var Vector2 = __webpack_require__(3); + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * @classdesc + * A TileSprite is a Sprite that has a repeating texture. + * + * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and + * are designed so that you can create game backdrops using seamless textures as a source. + * + * You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide + * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means + * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a + * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then + * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use + * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, + * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in + * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you + * provide POT textures for Tile Sprites. + * + * @class TileSprite + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Crop + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {integer} height - The height of the Game Object. If zero it will use the size of the texture frame. + * @param {string} textureKey - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frameKey] - An optional frame from the Texture this Game Object is rendering with. + */ +var TileSprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + TileSpriteRender + ], + + initialize: + + function TileSprite (scene, x, y, width, height, textureKey, frameKey) + { + var renderer = scene.sys.game.renderer; + + GameObject.call(this, scene, 'TileSprite'); + + var displayTexture = scene.sys.textures.get(textureKey); + var displayFrame = displayTexture.get(frameKey); + + if (!width || !height) + { + width = displayFrame.width; + height = displayFrame.height; + } + else + { + width = Math.floor(width); + height = Math.floor(height); + } + + /** + * Internal tile position vector. + * + * @name Phaser.GameObjects.TileSprite#_tilePosition + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 + */ + this._tilePosition = new Vector2(); + + /** + * Internal tile scale vector. + * + * @name Phaser.GameObjects.TileSprite#_tileScale + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 + */ + this._tileScale = new Vector2(1, 1); + + /** + * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. + * + * Such changes include the texture frame and scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + /** + * The renderer in use by this Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.0.0 + */ + this.renderer = renderer; + + /** + * The Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#canvas + * @type {?HTMLCanvasElement} + * @since 3.12.0 + */ + this.canvas = CanvasPool.create(this, width, height); + + /** + * The Context of the Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#context + * @type {CanvasRenderingContext2D} + * @since 3.12.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * The Texture the TileSprite is using as its fill pattern. + * + * @name Phaser.GameObjects.TileSprite#displayTexture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @private + * @since 3.12.0 + */ + this.displayTexture = displayTexture; + + /** + * The Frame the TileSprite is using as its fill pattern. + * + * @name Phaser.GameObjects.TileSprite#displayFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.12.0 + */ + this.displayFrame = displayFrame; + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.TileSprite#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.TileSprite#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.TileSprite#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.frame = this.texture.get(); + + /** + * The next power of two value from the width of the Fill Pattern frame. + * + * @name Phaser.GameObjects.TileSprite#potWidth + * @type {integer} + * @since 3.0.0 + */ + this.potWidth = GetPowerOfTwo(displayFrame.width); + + /** + * The next power of two value from the height of the Fill Pattern frame. + * + * @name Phaser.GameObjects.TileSprite#potHeight + * @type {integer} + * @since 3.0.0 + */ + this.potHeight = GetPowerOfTwo(displayFrame.height); + + /** + * The Canvas that the TileSprites texture is rendered to. + * This is used to create a WebGL texture from. + * + * @name Phaser.GameObjects.TileSprite#fillCanvas + * @type {HTMLCanvasElement} + * @since 3.12.0 + */ + this.fillCanvas = CanvasPool.create2D(this, this.potWidth, this.potHeight); + + /** + * The Canvas Context used to render the TileSprites texture. + * + * @name Phaser.GameObjects.TileSprite#fillContext + * @type {CanvasRenderingContext2D} + * @since 3.12.0 + */ + this.fillContext = this.fillCanvas.getContext('2d'); + + /** + * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. + * + * @name Phaser.GameObjects.TileSprite#fillPattern + * @type {?(WebGLTexture|CanvasPattern)} + * @since 3.12.0 + */ + this.fillPattern = null; + + this.setPosition(x, y); + this.setSize(width, height); + this.setFrame(frameKey); + this.setOriginFromFrame(); + this.initPipeline(); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function (renderer) + { + var gl = renderer.gl; + + this.dirty = true; + this.fillPattern = null; + this.fillPattern = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.fillCanvas, this.potWidth, this.potHeight); + }, this); + } + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.TileSprite#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.displayTexture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.TileSprite#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame) + { + this.displayFrame = this.displayTexture.get(frame); + + if (!this.displayFrame.cutWidth || !this.displayFrame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + this.dirty = true; + + this.updateTileTexture(); + + return this; + }, + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. + * + * @method Phaser.GameObjects.TileSprite#setTilePosition + * @since 3.3.0 + * + * @param {number} [x] - The x position of this sprite's tiling texture. + * @param {number} [y] - The y position of this sprite's tiling texture. + * + * @return {this} This Tile Sprite instance. + */ + setTilePosition: function (x, y) + { + if (x !== undefined) + { + this.tilePositionX = x; + } + + if (y !== undefined) + { + this.tilePositionY = y; + } + + return this; + }, + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. + * + * @method Phaser.GameObjects.TileSprite#setTileScale + * @since 3.12.0 + * + * @param {number} [x] - The horizontal scale of the tiling texture. + * @param {number} [y] - The vertical scale of the tiling texture. + * + * @return {this} This Tile Sprite instance. + */ + setTileScale: function (x, y) + { + if (x !== undefined) + { + this.tileScaleX = x; + } + + if (y !== undefined) + { + this.tileScaleY = y; + } + + return this; + }, + + /** + * Render the tile texture if it is dirty, or if the frame has changed. + * + * @method Phaser.GameObjects.TileSprite#updateTileTexture + * @private + * @since 3.0.0 + */ + updateTileTexture: function () + { + if (!this.dirty) + { + return; + } + + // Draw the displayTexture to our fillCanvas + + var frame = this.displayFrame; + + var ctx = this.fillContext; + var canvas = this.fillCanvas; + + var fw = this.potWidth; + var fh = this.potHeight; + + if (!this.renderer.gl) + { + fw = frame.cutWidth; + fh = frame.cutHeight; + } + + ctx.clearRect(0, 0, fw, fh); + + canvas.width = fw; + canvas.height = fh; + + ctx.drawImage( + frame.source.image, + frame.cutX, frame.cutY, + frame.cutWidth, frame.cutHeight, + 0, 0, + fw, fh + ); + + if (this.renderer.gl) + { + this.fillPattern = this.renderer.canvasToTexture(canvas, this.fillPattern); + } + else + { + this.fillPattern = ctx.createPattern(canvas, 'repeat'); + } + + this.updateCanvas(); + + this.dirty = false; + }, + + /** + * Draw the fill pattern to the internal canvas. + * + * @method Phaser.GameObjects.TileSprite#updateCanvas + * @private + * @since 3.12.0 + */ + updateCanvas: function () + { + var canvas = this.canvas; + + if (canvas.width !== this.width || canvas.height !== this.height) + { + canvas.width = this.width; + canvas.height = this.height; + + this.frame.setSize(this.width, this.height); + } + + if (!this.dirty || this.renderer && this.renderer.gl) + { + this.dirty = false; + return; + } + + var ctx = this.context; + + if (!this.scene.sys.game.config.antialias) + { + Smoothing.disable(ctx); + } + + var scaleX = this._tileScale.x; + var scaleY = this._tileScale.y; + + var positionX = this._tilePosition.x; + var positionY = this._tilePosition.y; + + ctx.clearRect(0, 0, this.width, this.height); + + ctx.save(); + + ctx.scale(scaleX, scaleY); + + ctx.translate(-positionX, -positionY); + + ctx.fillStyle = this.fillPattern; + + ctx.fillRect(positionX, positionY, this.width / scaleX, this.height / scaleY); + + ctx.restore(); + + this.dirty = false; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.TileSprite#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + if (this.renderer && this.renderer.gl) + { + this.renderer.deleteTexture(this.fillPattern); + } + + CanvasPool.remove(this.canvas); + CanvasPool.remove(this.fillCanvas); + + this.fillPattern = null; + this.fillContext = null; + this.fillCanvas = null; + + this.displayTexture = null; + this.displayFrame = null; + + this.texture.destroy(); + + this.renderer = null; + }, + + /** + * The horizontal scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionX: { + + get: function () + { + return this._tilePosition.x; + }, + + set: function (value) + { + this._tilePosition.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionY: { + + get: function () + { + return this._tilePosition.y; + }, + + set: function (value) + { + this._tilePosition.y = value; + this.dirty = true; + } + + }, + + /** + * The horizontal scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleX + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleX: { + + get: function () + { + return this._tileScale.x; + }, + + set: function (value) + { + this._tileScale.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleY + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleY: { + + get: function () + { + return this._tileScale.y; + }, + + set: function (value) + { + this._tileScale.y = value; + this.dirty = true; + } + + } + +}); + +module.exports = TileSprite; + + +/***/ }), +/* 153 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AddToDOM = __webpack_require__(169); +var CanvasPool = __webpack_require__(24); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var CONST = __webpack_require__(26); +var GameObject = __webpack_require__(19); +var GetTextSize = __webpack_require__(811); +var GetValue = __webpack_require__(4); +var RemoveFromDOM = __webpack_require__(342); +var TextRender = __webpack_require__(810); +var TextStyle = __webpack_require__(807); + +/** + * @classdesc + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + * + * @class Text + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Crop + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|string[])} text - The text this Text object will display. + * @param {object} style - The text style configuration object. + */ +var Text = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + TextRender + ], + + initialize: + + function Text (scene, x, y, text, style) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + GameObject.call(this, scene, 'Text'); + + /** + * The renderer in use by this Text object. + * + * @name Phaser.GameObjects.Text#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.12.0 + */ + this.renderer = scene.sys.game.renderer; + + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline(); + + /** + * The canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = CanvasPool.create(this); + + /** + * The context of the canvas element that the text is rendered to. + * + * @name Phaser.GameObjects.Text#context + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * The Text Style object. + * + * Manages the style of this Text object. + * + * @name Phaser.GameObjects.Text#style + * @type {Phaser.GameObjects.Text.TextStyle} + * @since 3.0.0 + */ + this.style = new TextStyle(this, style); + + /** + * Whether to automatically round line positions. + * + * @name Phaser.GameObjects.Text#autoRound + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.autoRound = true; + + /** + * The Regular Expression that is used to split the text up into lines, in + * multi-line text. By default this is `/(?:\r\n|\r|\n)/`. + * You can change this RegExp to be anything else that you may need. + * + * @name Phaser.GameObjects.Text#splitRegExp + * @type {object} + * @since 3.0.0 + */ + this.splitRegExp = /(?:\r\n|\r|\n)/; + + /** + * The text to display. + * + * @name Phaser.GameObjects.Text#_text + * @type {string} + * @private + * @since 3.12.0 + */ + this._text = ''; + + /** + * Specify a padding value which is added to the line width and height when calculating the Text size. + * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. + * + * @name Phaser.GameObjects.Text#padding + * @type {{left:number,right:number,top:number,bottom:number}} + * @since 3.0.0 + */ + this.padding = { left: 0, right: 0, top: 0, bottom: 0 }; + + /** + * The width of this Text object. + * + * @name Phaser.GameObjects.Text#width + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.width = 1; + + /** + * The height of this Text object. + * + * @name Phaser.GameObjects.Text#height + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.height = 1; + + /** + * The line spacing value. + * This value is added to the font height to calculate the overall line height. + * Only has an effect if this Text object contains multiple lines of text. + * + * If you update this property directly, instead of using the `setLineSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. + * + * @name Phaser.GameObjects.Text#lineSpacing + * @type {number} + * @since 3.13.0 + */ + this.lineSpacing = 0; + + /** + * Whether the text or its settings have changed and need updating. + * + * @name Phaser.GameObjects.Text#dirty + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.dirty = false; + + // If resolution wasn't set, then we get it from the game config + if (this.style.resolution === 0) + { + this.style.resolution = scene.sys.game.config.resolution; + } + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Text#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + // Create a Texture for this Text object + this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + + // Get the frame + this.frame = this.texture.get(); + + // Set the resolution + this.frame.source.resolution = this.style.resolution; + + if (this.renderer && this.renderer.gl) + { + // Clear the default 1x1 glTexture, as we override it later + this.renderer.deleteTexture(this.frame.source.glTexture); + + this.frame.source.glTexture = null; + } + + this.initRTL(); + + if (style && style.padding) + { + this.setPadding(style.padding); + } + + if (style && style.lineSpacing) + { + this.lineSpacing = style.lineSpacing; + } + + this.setText(text); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.dirty = true; + }, this); + } + }, + + /** + * Initialize right to left text. + * + * @method Phaser.GameObjects.Text#initRTL + * @since 3.0.0 + */ + initRTL: function () + { + if (!this.style.rtl) + { + return; + } + + // Here is where the crazy starts. + // + // Due to browser implementation issues, you cannot fillText BiDi text to a canvas + // that is not part of the DOM. It just completely ignores the direction property. + + this.canvas.dir = 'rtl'; + + // Experimental atm, but one day ... + this.context.direction = 'rtl'; + + // Add it to the DOM, but hidden within the parent canvas. + this.canvas.style.display = 'none'; + + AddToDOM(this.canvas, this.scene.sys.canvas); + + // And finally we set the x origin + this.originX = 1; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. + * + * @method Phaser.GameObjects.Text#runWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * + * @return {string} The text after wrapping has been applied. + */ + runWordWrap: function (text) + { + var style = this.style; + + if (style.wordWrapCallback) + { + var wrappedLines = style.wordWrapCallback.call(style.wordWrapCallbackScope, text, this); + + if (Array.isArray(wrappedLines)) + { + wrappedLines = wrappedLines.join('\n'); + } + + return wrappedLines; + } + else if (style.wordWrapWidth) + { + if (style.wordWrapUseAdvanced) + { + return this.advancedWordWrap(text, this.context, this.style.wordWrapWidth); + } + else + { + return this.basicWordWrap(text, this.context, this.style.wordWrapWidth); + } + } + else + { + return text; + } + }, + + /** + * Advanced wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Consecutive spaces will be collapsed and replaced with a single space. Lines will be + * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a + * single character. + * + * @method Phaser.GameObjects.Text#advancedWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {number} wordWrapWidth - The word wrap width. + * + * @return {string} The wrapped text. + */ + advancedWordWrap: function (text, context, wordWrapWidth) + { + var output = ''; + + // Condense consecutive spaces and split into lines + var lines = text + .replace(/ +/gi, ' ') + .split(this.splitRegExp); + + var linesCount = lines.length; + + for (var i = 0; i < linesCount; i++) + { + var line = lines[i]; + var out = ''; + + // Trim whitespace + line = line.replace(/^ *|\s*$/gi, ''); + + // If entire line is less than wordWrapWidth append the entire line and exit early + var lineWidth = context.measureText(line).width; + + if (lineWidth < wordWrapWidth) + { + output += line + '\n'; + continue; + } + + // Otherwise, calculate new lines + var currentLineWidth = wordWrapWidth; + + // Split into words + var words = line.split(' '); + + for (var j = 0; j < words.length; j++) + { + var word = words[j]; + var wordWithSpace = word + ' '; + var wordWidth = context.measureText(wordWithSpace).width; + + if (wordWidth > currentLineWidth) + { + // Break word + if (j === 0) + { + // Shave off letters from word until it's small enough + var newWord = wordWithSpace; + + while (newWord.length) + { + newWord = newWord.slice(0, -1); + wordWidth = context.measureText(newWord).width; + + if (wordWidth <= currentLineWidth) + { + break; + } + } + + // If wordWrapWidth is too small for even a single letter, shame user + // failure with a fatal error + if (!newWord.length) + { + throw new Error('This text\'s wordWrapWidth setting is less than a single character!'); + } + + // Replace current word in array with remainder + var secondPart = word.substr(newWord.length); + + words[j] = secondPart; + + // Append first piece to output + out += newWord; + } + + // If existing word length is 0, don't include it + var offset = (words[j].length) ? j : j + 1; + + // Collapse rest of sentence and remove any trailing white space + var remainder = words.slice(offset).join(' ') + .replace(/[ \n]*$/gi, ''); + + // Prepend remainder to next line + lines[i + 1] = remainder + ' ' + (lines[i + 1] || ''); + linesCount = lines.length; + + break; // Processing on this line + + // Append word with space to output + } + else + { + out += wordWithSpace; + currentLineWidth -= wordWidth; + } + } + + // Append processed line to output + output += out.replace(/[ \n]*$/gi, '') + '\n'; + } + + // Trim the end of the string + output = output.replace(/[\s|\n]*$/gi, ''); + + return output; + }, + + /** + * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal + * bounds. Spaces are not collapsed and whitespace is not trimmed. + * + * @method Phaser.GameObjects.Text#basicWordWrap + * @since 3.0.0 + * + * @param {string} text - The text to perform word wrap detection against. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {number} wordWrapWidth - The word wrap width. + * + * @return {string} The wrapped text. + */ + basicWordWrap: function (text, context, wordWrapWidth) + { + var result = ''; + var lines = text.split(this.splitRegExp); + + for (var i = 0; i < lines.length; i++) + { + var spaceLeft = wordWrapWidth; + var words = lines[i].split(' '); + + for (var j = 0; j < words.length; j++) + { + var wordWidth = context.measureText(words[j]).width; + var wordWidthWithSpace = wordWidth + context.measureText(' ').width; + + if (wordWidthWithSpace > spaceLeft) + { + // Skip printing the newline if it's the first word of the line that is greater + // than the word wrap width. + if (j > 0) + { + result += '\n'; + } + + result += words[j] + ' '; + spaceLeft = wordWrapWidth - wordWidth; + } + else + { + spaceLeft -= wordWidthWithSpace; + result += words[j]; + + if (j < (words.length - 1)) + { + result += ' '; + } + } + } + + if (i < lines.length - 1) + { + result += '\n'; + } + } + + return result; + }, + + /** + * Runs the given text through this Text objects word wrapping and returns the results as an + * array, where each element of the array corresponds to a wrapped line of text. + * + * @method Phaser.GameObjects.Text#getWrappedText + * @since 3.0.0 + * + * @param {string} text - The text for which the wrapping will be calculated. If unspecified, the Text objects current text will be used. + * + * @return {string[]} An array of strings with the pieces of wrapped text. + */ + getWrappedText: function (text) + { + if (text === undefined) { text = this._text; } + + this.style.syncFont(this.canvas, this.context); + + var wrappedLines = this.runWordWrap(text); + + return wrappedLines.split(this.splitRegExp); + }, + + /** + * Set the text to display. + * + * An array of strings will be joined with `\n` line breaks. + * + * @method Phaser.GameObjects.Text#setText + * @since 3.0.0 + * + * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this Text object. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setText: function (value) + { + if (!value && value !== 0) + { + value = ''; + } + + if (Array.isArray(value)) + { + value = value.join('\n'); + } + + if (value !== this._text) + { + this._text = value.toString(); + + this.updateText(); + } + + return this; + }, + + /** + * Set the text style. + * + * @example + * text.setStyle({ + * fontSize: '64px', + * fontFamily: 'Arial', + * color: '#ffffff', + * align: 'center', + * backgroundColor: '#ff00ff' + * }); + * + * @method Phaser.GameObjects.Text#setStyle + * @since 3.0.0 + * + * @param {object} style - The style settings to set. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStyle: function (style) + { + return this.style.setStyle(style); + }, + + /** + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * + * @method Phaser.GameObjects.Text#setFont + * @since 3.0.0 + * + * @param {string} font - The font family or font settings to set. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFont: function (font) + { + return this.style.setFont(font); + }, + + /** + * Set the font family. + * + * @method Phaser.GameObjects.Text#setFontFamily + * @since 3.0.0 + * + * @param {string} family - The font family. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontFamily: function (family) + { + return this.style.setFontFamily(family); + }, + + /** + * Set the font size. + * + * @method Phaser.GameObjects.Text#setFontSize + * @since 3.0.0 + * + * @param {number} size - The font size. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontSize: function (size) + { + return this.style.setFontSize(size); + }, + + /** + * Set the font style. + * + * @method Phaser.GameObjects.Text#setFontStyle + * @since 3.0.0 + * + * @param {string} style - The font style. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFontStyle: function (style) + { + return this.style.setFontStyle(style); + }, + + /** + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * + * @method Phaser.GameObjects.Text#setFixedSize + * @since 3.0.0 + * + * @param {number} width - The fixed width to set. `0` disables fixed width. + * @param {number} height - The fixed height to set. `0` disables fixed height. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFixedSize: function (width, height) + { + return this.style.setFixedSize(width, height); + }, + + /** + * Set the background color. + * + * @method Phaser.GameObjects.Text#setBackgroundColor + * @since 3.0.0 + * + * @param {string} color - The background color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setBackgroundColor: function (color) + { + return this.style.setBackgroundColor(color); + }, + + /** + * Set the text fill color. + * + * @method Phaser.GameObjects.Text#setFill + * @since 3.0.0 + * + * @param {string} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setFill: function (color) + { + return this.style.setFill(color); + }, + + /** + * Set the text fill color. + * + * @method Phaser.GameObjects.Text#setColor + * @since 3.0.0 + * + * @param {string} color - The text fill color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setColor: function (color) + { + return this.style.setColor(color); + }, + + /** + * Set the stroke settings. + * + * @method Phaser.GameObjects.Text#setStroke + * @since 3.0.0 + * + * @param {string} color - The stroke color. + * @param {number} thickness - The stroke thickness. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setStroke: function (color, thickness) + { + return this.style.setStroke(color, thickness); + }, + + /** + * Set the shadow settings. + * + * @method Phaser.GameObjects.Text#setShadow + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * @param {string} [color='#000'] - The shadow color. + * @param {number} [blur=0] - The shadow blur radius. + * @param {boolean} [shadowStroke=false] - Whether to stroke the shadow. + * @param {boolean} [shadowFill=true] - Whether to fill the shadow. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadow: function (x, y, color, blur, shadowStroke, shadowFill) + { + return this.style.setShadow(x, y, color, blur, shadowStroke, shadowFill); + }, + + /** + * Set the shadow offset. + * + * @method Phaser.GameObjects.Text#setShadowOffset + * @since 3.0.0 + * + * @param {number} x - The horizontal shadow offset. + * @param {number} y - The vertical shadow offset. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowOffset: function (x, y) + { + return this.style.setShadowOffset(x, y); + }, + + /** + * Set the shadow color. + * + * @method Phaser.GameObjects.Text#setShadowColor + * @since 3.0.0 + * + * @param {string} color - The shadow color. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowColor: function (color) + { + return this.style.setShadowColor(color); + }, + + /** + * Set the shadow blur radius. + * + * @method Phaser.GameObjects.Text#setShadowBlur + * @since 3.0.0 + * + * @param {number} blur - The shadow blur radius. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowBlur: function (blur) + { + return this.style.setShadowBlur(blur); + }, + + /** + * Enable or disable shadow stroke. + * + * @method Phaser.GameObjects.Text#setShadowStroke + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow stroke is enabled or not. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowStroke: function (enabled) + { + return this.style.setShadowStroke(enabled); + }, + + /** + * Enable or disable shadow fill. + * + * @method Phaser.GameObjects.Text#setShadowFill + * @since 3.0.0 + * + * @param {boolean} enabled - Whether shadow fill is enabled or not. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setShadowFill: function (enabled) + { + return this.style.setShadowFill(enabled); + }, + + /** + * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * + * @method Phaser.GameObjects.Text#setWordWrapWidth + * @since 3.0.0 + * + * @param {?number} width - The maximum width of a line in pixels. Set to null to remove wrapping. + * @param {boolean} [useAdvancedWrap=false] - Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapWidth: function (width, useAdvancedWrap) + { + return this.style.setWordWrapWidth(width, useAdvancedWrap); + }, + + /** + * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * + * @method Phaser.GameObjects.Text#setWordWrapCallback + * @since 3.0.0 + * + * @param {TextStyleWordWrapCallback} callback - A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param {object} [scope=null] - The scope that will be applied when the callback is invoked. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setWordWrapCallback: function (callback, scope) + { + return this.style.setWordWrapCallback(callback, scope); + }, + + /** + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. + * + * @method Phaser.GameObjects.Text#setAlign + * @since 3.0.0 + * + * @param {string} align - The text alignment. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setAlign: function (align) + { + return this.style.setAlign(align); + }, + + /** + * Set the resolution used by this Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method, or by specifying it in the Text style configuration object. + * + * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger + * internal Canvas textures for the Text. + * + * Therefore, please use with caution, as the more high res Text you have, the more memory it uses. + * + * @method Phaser.GameObjects.Text#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setResolution: function (value) + { + return this.style.setResolution(value); + }, + + /** + * Sets the line spacing value. + * + * This value is _added_ to the height of the font when calculating the overall line height. + * This only has an effect if this Text object consists of multiple lines of text. + * + * @method Phaser.GameObjects.Text#setLineSpacing + * @since 3.13.0 + * + * @param {number} value - The amount to add to the font height to achieve the overall line height. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setLineSpacing: function (value) + { + this.lineSpacing = value; + + return this.updateText(); + }, + + /** + * Set the text padding. + * + * 'left' can be an object. + * + * If only 'left' and 'top' are given they are treated as 'x' and 'y'. + * + * @method Phaser.GameObjects.Text#setPadding + * @since 3.0.0 + * + * @param {(number|object)} left - The left padding value, or a padding config object. + * @param {number} top - The top padding value. + * @param {number} right - The right padding value. + * @param {number} bottom - The bottom padding value. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setPadding: function (left, top, right, bottom) + { + if (typeof left === 'object') + { + var config = left; + + // If they specify x and/or y this applies to all + var x = GetValue(config, 'x', null); + + if (x !== null) + { + left = x; + right = x; + } + else + { + left = GetValue(config, 'left', 0); + right = GetValue(config, 'right', left); + } + + var y = GetValue(config, 'y', null); + + if (y !== null) + { + top = y; + bottom = y; + } + else + { + top = GetValue(config, 'top', 0); + bottom = GetValue(config, 'bottom', top); + } + } + else + { + if (left === undefined) { left = 0; } + if (top === undefined) { top = left; } + if (right === undefined) { right = left; } + if (bottom === undefined) { bottom = top; } + } + + this.padding.left = left; + this.padding.top = top; + this.padding.right = right; + this.padding.bottom = bottom; + + return this.updateText(); + }, + + /** + * Set the maximum number of lines to draw. + * + * @method Phaser.GameObjects.Text#setMaxLines + * @since 3.0.0 + * + * @param {integer} [max=0] - The maximum number of lines to draw. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setMaxLines: function (max) + { + return this.style.setMaxLines(max); + }, + + /** + * Update the displayed text. + * + * @method Phaser.GameObjects.Text#updateText + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + updateText: function () + { + var canvas = this.canvas; + var context = this.context; + var style = this.style; + var resolution = style.resolution; + var size = style.metrics; + + style.syncFont(canvas, context); + + var outputText = this._text; + + if (style.wordWrapWidth || style.wordWrapCallback) + { + outputText = this.runWordWrap(this._text); + } + + // Split text into lines + var lines = outputText.split(this.splitRegExp); + + var textSize = GetTextSize(this, size, lines); + + var padding = this.padding; + + var w = textSize.width + padding.left + padding.right; + var h = textSize.height + padding.top + padding.bottom; + + if (style.fixedWidth === 0) + { + this.width = w; + } + + if (style.fixedHeight === 0) + { + this.height = h; + } + + this.updateDisplayOrigin(); + + w *= resolution; + h *= resolution; + + w = Math.max(w, 1); + h = Math.max(h, 1); + + if (canvas.width !== w || canvas.height !== h) + { + canvas.width = w; + canvas.height = h; + + this.frame.setSize(w, h); + + style.syncFont(canvas, context); // Resizing resets the context + } + else + { + context.clearRect(0, 0, w, h); + } + + context.save(); + + context.scale(resolution, resolution); + + if (style.backgroundColor) + { + context.fillStyle = style.backgroundColor; + context.fillRect(0, 0, w, h); + } + + style.syncStyle(canvas, context); + + context.textBaseline = 'alphabetic'; + + // Apply padding + context.translate(padding.left, padding.top); + + var linePositionX; + var linePositionY; + + // Draw text line by line + for (var i = 0; i < textSize.lines; i++) + { + linePositionX = style.strokeThickness / 2; + linePositionY = (style.strokeThickness / 2 + i * textSize.lineHeight) + size.ascent; + + if (i > 0) + { + linePositionY += (textSize.lineSpacing * i); + } + + if (style.rtl) + { + linePositionX = w - linePositionX; + } + else if (style.align === 'right') + { + linePositionX += textSize.width - textSize.lineWidths[i]; + } + else if (style.align === 'center') + { + linePositionX += (textSize.width - textSize.lineWidths[i]) / 2; + } + + if (this.autoRound) + { + linePositionX = Math.round(linePositionX); + linePositionY = Math.round(linePositionY); + } + + if (style.strokeThickness) + { + this.style.syncShadow(context, style.shadowStroke); + + context.strokeText(lines[i], linePositionX, linePositionY); + } + + if (style.color) + { + this.style.syncShadow(context, style.shadowFill); + + context.fillText(lines[i], linePositionX, linePositionY); + } + } + + context.restore(); + + if (this.renderer.gl) + { + this.frame.source.glTexture = this.renderer.canvasToTexture(canvas, this.frame.source.glTexture, true); + + this.frame.glTexture = this.frame.source.glTexture; + } + + this.dirty = true; + + return this; + }, + + /** + * Get the current text metrics. + * + * @method Phaser.GameObjects.Text#getTextMetrics + * @since 3.0.0 + * + * @return {object} The text metrics. + */ + getTextMetrics: function () + { + return this.style.getTextMetrics(); + }, + + /** + * The text string being rendered by this Text Game Object. + * + * @name Phaser.GameObjects.Text#text + * @type {string} + * @since 3.0.0 + */ + text: { + + get: function () + { + return this._text; + }, + + set: function (value) + { + this.setText(value); + } + + }, + + /** + * Build a JSON representation of the Text object. + * + * @method Phaser.GameObjects.Text#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Text object. + */ + toJSON: function () + { + var out = Components.ToJSON(this); + + // Extra Text data is added here + + var data = { + autoRound: this.autoRound, + text: this._text, + style: this.style.toJSON(), + padding: { + left: this.padding.left, + right: this.padding.right, + top: this.padding.top, + bottom: this.padding.bottom + } + }; + + out.data = data; + + return out; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Text#preDestroy + * @protected + * @since 3.0.0 + */ + preDestroy: function () + { + if (this.style.rtl) + { + RemoveFromDOM(this.canvas); + } + + CanvasPool.remove(this.canvas); + + this.texture.destroy(); + } + +}); + +module.exports = Text; + + +/***/ }), +/* 154 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(121); +var CanvasPool = __webpack_require__(24); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var CONST = __webpack_require__(26); +var Frame = __webpack_require__(113); +var GameObject = __webpack_require__(19); +var Render = __webpack_require__(817); +var UUID = __webpack_require__(295); + +/** + * @classdesc + * A Render Texture. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. + * + * @class RenderTexture + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.2.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + */ +var RenderTexture = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Crop, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Tint, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function RenderTexture (scene, x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 32; } + if (height === undefined) { height = 32; } + + GameObject.call(this, scene, 'RenderTexture'); + + /** + * A reference to either the Canvas or WebGL Renderer that the Game instance is using. + * + * @name Phaser.GameObjects.RenderTexture#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.2.0 + */ + this.renderer = scene.sys.game.renderer; + + /** + * A reference to the Texture Manager. + * + * @name Phaser.GameObjects.RenderTexture#textureManager + * @type {Phaser.Textures.TextureManager} + * @since 3.12.0 + */ + this.textureManager = scene.sys.textures; + + /** + * The tint of the Render Texture when rendered. + * + * @name Phaser.GameObjects.RenderTexture#globalTint + * @type {number} + * @default 0xffffff + * @since 3.2.0 + */ + this.globalTint = 0xffffff; + + /** + * The alpha of the Render Texture when rendered. + * + * @name Phaser.GameObjects.RenderTexture#globalAlpha + * @type {number} + * @default 1 + * @since 3.2.0 + */ + this.globalAlpha = 1; + + /** + * The HTML Canvas Element that the Render Texture is drawing to. + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.GameObjects.RenderTexture#canvas + * @type {HTMLCanvasElement} + * @since 3.2.0 + */ + this.canvas = CanvasPool.create2D(this, width, height); + + /** + * A reference to the Rendering Context belonging to the Canvas Element this Render Texture is drawing to. + * + * @name Phaser.GameObjects.RenderTexture#context + * @type {CanvasRenderingContext2D} + * @since 3.2.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * A reference to the GL Frame Buffer this Render Texture is drawing to. + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.GameObjects.RenderTexture#framebuffer + * @type {?WebGLFramebuffer} + * @since 3.2.0 + */ + this.framebuffer = null; + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.RenderTexture#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Texture corresponding to this Render Texture. + * + * @name Phaser.GameObjects.RenderTexture#texture + * @type {Phaser.Textures.Texture} + * @since 3.12.0 + */ + this.texture = scene.sys.textures.addCanvas(UUID(), this.canvas); + + /** + * The Frame corresponding to this Render Texture. + * + * @name Phaser.GameObjects.RenderTexture#frame + * @type {Phaser.Textures.Frame} + * @since 3.12.0 + */ + this.frame = this.texture.get(); + + /** + * Internal saved texture flag. + * + * @name Phaser.GameObjects.RenderTexture#_saved + * @type {boolean} + * @private + * @since 3.12.0 + */ + this._saved = false; + + /** + * An internal Camera that can be used to move around the Render Texture. + * Control it just like you would any Scene Camera. The difference is that it only impacts the placement of what + * is drawn to the Render Texture. You can scroll, zoom and rotate this Camera. + * + * @name Phaser.GameObjects.RenderTexture#camera + * @type {Phaser.Cameras.Scene2D.BaseCamera} + * @since 3.12.0 + */ + this.camera = new Camera(0, 0, width, height); + + /** + * Is this Render Texture dirty or not? If not it won't spend time clearing or filling itself. + * + * @name Phaser.GameObjects.RenderTexture#dirty + * @type {boolean} + * @since 3.12.0 + */ + this.dirty = false; + + /** + * A reference to the WebGL Rendering Context. + * + * @name Phaser.GameObjects.RenderTexture#gl + * @type {WebGLRenderingContext} + * @default null + * @since 3.0.0 + */ + this.gl = null; + + var renderer = this.renderer; + + if (renderer.type === CONST.WEBGL) + { + var gl = renderer.gl; + + this.gl = gl; + this.drawGameObject = this.batchGameObjectWebGL; + this.framebuffer = renderer.createFramebuffer(width, height, this.frame.source.glTexture, false); + } + else if (renderer.type === CONST.CANVAS) + { + this.drawGameObject = this.batchGameObjectCanvas; + } + + this.camera.setScene(scene); + + this.setPosition(x, y); + this.setSize(width, height); + this.setOrigin(0, 0); + this.initPipeline(); + }, + + /** + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + return this.resize(width, height); + }, + + /** + * Resizes the Render Texture to the new dimensions given. + * + * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. + * In Canvas it will resize the underlying canvas element. + * Both approaches will erase everything currently drawn to the Render Texture. + * + * If the dimensions given are the same as those already being used, calling this method will do nothing. + * + * @method Phaser.GameObjects.RenderTexture#resize + * @since 3.10.0 + * + * @param {number} width - The new width of the Render Texture. + * @param {number} [height] - The new height of the Render Texture. If not specified, will be set the same as the `width`. + * + * @return {this} This Render Texture. + */ + resize: function (width, height) + { + if (height === undefined) { height = width; } + + if (width !== this.width || height !== this.height) + { + this.canvas.width = width; + this.canvas.height = height; + + if (this.gl) + { + var gl = this.gl; + + this.renderer.deleteTexture(this.frame.source.glTexture); + this.renderer.deleteFramebuffer(this.framebuffer); + + this.frame.source.glTexture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); + this.framebuffer = this.renderer.createFramebuffer(width, height, this.frame.source.glTexture, false); + + this.frame.glTexture = this.frame.source.glTexture; + } + + this.frame.source.width = width; + this.frame.source.height = height; + + this.camera.setSize(width, height); + + this.frame.setSize(width, height); + + this.width = width; + this.height = height; + } + + return this; + }, + + /** + * Set the tint to use when rendering this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#setGlobalTint + * @since 3.2.0 + * + * @param {integer} tint - The tint value. + * + * @return {this} This Render Texture. + */ + setGlobalTint: function (tint) + { + this.globalTint = tint; + + return this; + }, + + /** + * Set the alpha to use when rendering this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#setGlobalAlpha + * @since 3.2.0 + * + * @param {number} alpha - The alpha value. + * + * @return {this} This Render Texture. + */ + setGlobalAlpha: function (alpha) + { + this.globalAlpha = alpha; + + return this; + }, + + /** + * Stores a copy of this Render Texture in the Texture Manager using the given key. + * + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this + * Render Texture by using the texture key: + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 128, 128); + * + * // Draw something to the Render Texture + * + * rt.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Updating the contents of this Render Texture will automatically update _any_ Game Object + * that is using it as a texture. Calling `saveTexture` again will not save another copy + * of the same texture, it will just rename the key of the existing copy. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#saveTexture + * @since 3.12.0 + * + * @param {string} key - The unique key to store the texture as within the global Texture Manager. + * + * @return {Phaser.Textures.Texture} The Texture that was saved. + */ + saveTexture: function (key) + { + this.textureManager.renameTexture(this.texture.key, key); + + this._saved = true; + + return this.texture; + }, + + /** + * Fills the Render Texture with the given color. + * + * @method Phaser.GameObjects.RenderTexture#fill + * @since 3.2.0 + * + * @param {number} rgb - The color to fill the Render Texture with. + * @param {number} [alpha=1] - The alpha value used by the fill. + * + * @return {this} This Render Texture instance. + */ + fill: function (rgb, alpha) + { + if (alpha === undefined) { alpha = 1; } + + var ur = ((rgb >> 16)|0) & 0xff; + var ug = ((rgb >> 8)|0) & 0xff; + var ub = (rgb|0) & 0xff; + + if (this.gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var gl = this.gl; + + gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, alpha); + + gl.clear(gl.COLOR_BUFFER_BIT); + + this.renderer.setFramebuffer(null); + } + else + { + this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; + this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); + } + + return this; + }, + + /** + * Clears the Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#clear + * @since 3.2.0 + * + * @return {this} This Render Texture instance. + */ + clear: function () + { + if (this.dirty) + { + if (this.gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var gl = this.gl; + + gl.clearColor(0, 0, 0, 0); + + gl.clear(gl.COLOR_BUFFER_BIT); + + this.renderer.setFramebuffer(null); + } + else + { + var ctx = this.context; + + ctx.save(); + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + ctx.restore(); + } + + this.dirty = false; + } + + return this; + }, + + /** + * Draws the given object, or an array of objects, to this Render Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Dynamic and Static Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. + * * Another Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot draw a Render Texture to itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * + * @method Phaser.GameObjects.RenderTexture#draw + * @since 3.2.0 + * + * @param {any} entries - Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param {number} [x] - The x position to draw the Frame at, or the offset applied to the object. + * @param {number} [y] - The y position to draw the Frame at, or the offset applied to the object. + * @param {number} [alpha] - The alpha value. Only used for Texture Frames and if not specified defaults to the `globalAlpha` property. Game Objects use their own current alpha value. + * @param {number} [tint] - WebGL only. The tint color value. Only used for Texture Frames and if not specified defaults to the `globalTint` property. Game Objects use their own current tint value. + * + * @return {this} This Render Texture instance. + */ + draw: function (entries, x, y, alpha, tint) + { + if (alpha === undefined) { alpha = this.globalAlpha; } + + if (tint === undefined) + { + tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + } + else + { + tint = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16); + } + + if (!Array.isArray(entries)) + { + entries = [ entries ]; + } + + var gl = this.gl; + + this.camera.preRender(1, 1, 1); + + if (gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var pipeline = this.pipeline; + + pipeline.projOrtho(0, this.width, 0, this.height, -1000.0, 1000.0); + + this.batchList(entries, x, y, alpha, tint); + + pipeline.flush(); + + this.renderer.setFramebuffer(null); + + pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000.0, 1000.0); + } + else + { + this.renderer.setContext(this.context); + + this.batchList(entries, x, y, alpha, tint); + + this.renderer.setContext(); + } + + this.dirty = true; + + return this; + }, + + /** + * Draws the Texture Frame to the Render Texture at the given position. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 800, 600); + * rt.drawFrame(key, frame); + * ``` + * + * You can optionally provide a position, alpha and tint value to apply to the frame + * before it is drawn. + * + * Calling this method will cause a batch flush, so if you've got a stack of things to draw + * in a tight loop, try using the `draw` method instead. + * + * If you need to draw a Sprite to this Render Texture, use the `draw` method instead. + * + * @method Phaser.GameObjects.RenderTexture#drawFrame + * @since 3.12.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} [x=0] - The x position to draw the frame at. + * @param {number} [y=0] - The y position to draw the frame at. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - WebGL only. The tint color to use. If not specified it uses the `globalTint` property. + * + * @return {this} This Render Texture instance. + */ + drawFrame: function (key, frame, x, y, alpha, tint) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (alpha === undefined) { alpha = this.globalAlpha; } + + if (tint === undefined) + { + tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + } + else + { + tint = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16); + } + + var gl = this.gl; + var textureFrame = this.textureManager.getFrame(key, frame); + + if (textureFrame) + { + this.camera.preRender(1, 1, 1); + + if (gl) + { + this.renderer.setFramebuffer(this.framebuffer); + + var pipeline = this.pipeline; + + pipeline.projOrtho(0, this.width, 0, this.height, -1000.0, 1000.0); + + pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null); + + pipeline.flush(); + + this.renderer.setFramebuffer(null); + + pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000.0, 1000.0); + } + else + { + this.batchTextureFrame(textureFrame, x, y, alpha, tint); + } + + this.dirty = true; + } + + return this; + }, + + /** + * Internal method that handles the drawing of an array of children. + * + * @method Phaser.GameObjects.RenderTexture#batchList + * @private + * @since 3.12.0 + * + * @param {array} children - The array of Game Objects to draw. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - The tint color to use. If not specified it uses the `globalTint` property. + */ + batchList: function (children, x, y, alpha, tint) + { + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (!entry || entry === this) + { + continue; + } + + if (entry.renderWebGL || entry.renderCanvas) + { + // Game Objects + this.drawGameObject(entry, x, y); + } + else if (entry.isParent || entry.list) + { + // Groups / Display Lists + this.batchGroup(entry.getChildren(), x, y); + } + else if (typeof entry === 'string') + { + // Texture key + this.batchTextureFrameKey(entry, null, x, y, alpha, tint); + } + else if (entry instanceof Frame) + { + // Texture Frame instance + this.batchTextureFrame(entry, x, y, alpha, tint); + } + else if (Array.isArray(entry)) + { + // Another Array + this.batchList(entry, x, y, alpha, tint); + } + } + }, + + /** + * Internal method that handles the drawing a Phaser Group contents. + * + * @method Phaser.GameObjects.RenderTexture#batchGroup + * @private + * @since 3.12.0 + * + * @param {array} children - The array of Game Objects to draw. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + */ + batchGroup: function (children, x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (entry.willRender()) + { + var tx = entry.x + x; + var ty = entry.y + y; + + this.drawGameObject(entry, tx, ty); + } + } + }, + + /** + * Internal method that handles drawing a single Phaser Game Object to this Render Texture using WebGL. + * + * @method Phaser.GameObjects.RenderTexture#batchGameObjectWebGL + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to draw. + * @param {number} x - The x position to draw the Game Object at. + * @param {number} y - The y position to draw the Game Object at. + */ + batchGameObjectWebGL: function (gameObject, x, y) + { + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + var prevX = gameObject.x; + var prevY = gameObject.y; + + this.renderer.setBlendMode(gameObject.blendMode); + + gameObject.setPosition(x, y); + + gameObject.renderWebGL(this.renderer, gameObject, 0, this.camera, null); + + gameObject.setPosition(prevX, prevY); + }, + + /** + * Internal method that handles drawing a single Phaser Game Object to this Render Texture using Canvas. + * + * @method Phaser.GameObjects.RenderTexture#batchGameObjectCanvas + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to draw. + * @param {number} x - The x position to draw the Game Object at. + * @param {number} y - The y position to draw the Game Object at. + */ + batchGameObjectCanvas: function (gameObject, x, y) + { + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + var prevX = gameObject.x; + var prevY = gameObject.y; + + gameObject.setPosition(x, y); + + gameObject.renderCanvas(this.renderer, gameObject, 0, this.camera, null); + + gameObject.setPosition(prevX, prevY); + }, + + /** + * Internal method that handles the drawing of an array of children. + * + * @method Phaser.GameObjects.RenderTexture#batchTextureFrameKey + * @private + * @since 3.12.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - The tint color to use. If not specified it uses the `globalTint` property. + * + * @return {boolean} `true` if the frame was found and drawn, otherwise `false`. + */ + batchTextureFrameKey: function (key, frame, x, y, alpha, tint) + { + var textureFrame = this.textureManager.getFrame(key, frame); + + if (textureFrame) + { + this.batchTextureFrame(textureFrame, x, y, alpha, tint); + } + }, + + /** + * Internal method that handles the drawing of a Texture Frame to this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#batchTextureFrame + * @private + * @since 3.12.0 + * + * @param {Phaser.Textures.Frame} textureFrame - The Texture Frame to draw. + * @param {number} x - The x position to draw the Frame at. + * @param {number} y - The y position to draw the Frame at. + * @param {number} [tint] - A tint color to be applied to the frame drawn to the Render Texture. + */ + batchTextureFrame: function (textureFrame, x, y, alpha, tint) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + if (this.gl) + { + this.pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null); + } + else + { + var ctx = this.context; + var cd = textureFrame.canvasData; + var source = textureFrame.source.image; + + var matrix = this.camera.matrix; + + ctx.globalAlpha = this.globalAlpha; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + ctx.drawImage(source, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height); + } + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.RenderTexture#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + if (!this._saved) + { + CanvasPool.remove(this.canvas); + + if (this.gl) + { + this.renderer.deleteFramebuffer(this.framebuffer); + } + + this.texture.destroy(); + } + } + +}); + +module.exports = RenderTexture; + + +/***/ }), +/* 155 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var GravityWell = __webpack_require__(304); +var List = __webpack_require__(112); +var ParticleEmitter = __webpack_require__(302); +var Render = __webpack_require__(821); + +/** + * @classdesc + * A Particle Emitter Manager creates and controls {@link Phaser.GameObjects.Particles.ParticleEmitter Particle Emitters} and {@link Phaser.GameObjects.Particles.GravityWell Gravity Wells}. + * + * @class ParticleEmitterManager + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Emitter Manager belongs. + * @param {string} texture - The key of the Texture this Emitter Manager will use to render particles, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Emitter Manager will use to render particles. + * @param {ParticleEmitterConfig|ParticleEmitterConfig[]} [emitters] - Configuration settings for one or more emitters to create. + */ +var ParticleEmitterManager = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Depth, + Components.Pipeline, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + // frame is optional and can contain the emitters array or object if skipped + function ParticleEmitterManager (scene, texture, frame, emitters) + { + GameObject.call(this, scene, 'ParticleEmitterManager'); + + /** + * The blend mode applied to all emitters and particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode + * @type {integer} + * @default -1 + * @private + * @since 3.0.0 + */ + this.blendMode = -1; + + /** + * The time scale applied to all emitters and particles, affecting flow rate, lifespan, and movement. + * Values larger than 1 are faster than normal. + * This is multiplied with any timeScale set on each individual emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * The texture used to render this Emitter Manager's particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture + * @type {Phaser.Textures.Texture} + * @default null + * @since 3.0.0 + */ + this.texture = null; + + /** + * The texture frame used to render this Emitter Manager's particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame + * @type {Phaser.Textures.Frame} + * @default null + * @since 3.0.0 + */ + this.frame = null; + + /** + * Names of this Emitter Manager's texture frames. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames + * @type {string[]} + * @since 3.0.0 + */ + this.frameNames = []; + + // frame is optional and can contain the emitters array or object if skipped + if (frame !== null && (typeof frame === 'object' || Array.isArray(frame))) + { + emitters = frame; + frame = null; + } + + this.setTexture(texture, frame); + + this.initPipeline(); + + /** + * A list of Emitters being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.emitters = new List(this); + + /** + * A list of Gravity Wells being managed by this Emitter Manager. + * + * @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.wells = new List(this); + + if (emitters) + { + // An array of emitter configs? + if (!Array.isArray(emitters)) + { + emitters = [ emitters ]; + } + + for (var i = 0; i < emitters.length; i++) + { + this.createEmitter(emitters[i]); + } + } + }, + + /** + * Sets the texture and frame this Emitter Manager will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Emitter Manager will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + setFrame: function (frame) + { + this.frame = this.texture.get(frame); + + var frames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); + + var names = []; + + frames.forEach(function (sourceFrame) + { + names.push(sourceFrame.name); + }); + + this.frameNames = names; + + this.defaultFrame = this.frame; + + return this; + }, + + /** + * Assigns texture frames to an emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames + * @since 3.0.0 + * + * @param {(Phaser.Textures.Frame|Phaser.Textures.Frame[])} frames - The texture frames. + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The particle emitter to modify. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + setEmitterFrames: function (frames, emitter) + { + if (!Array.isArray(frames)) + { + frames = [ frames ]; + } + + var out = emitter.frames; + + out.length = 0; + + for (var i = 0; i < frames.length; i++) + { + var frame = frames[i]; + + if (this.frameNames.indexOf(frame) !== -1) + { + out.push(this.texture.get(frame)); + } + } + + if (out.length > 0) + { + emitter.defaultFrame = out[0]; + } + else + { + emitter.defaultFrame = this.defaultFrame; + } + + return this; + }, + + /** + * Adds an existing Particle Emitter to this Emitter Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager. + */ + addEmitter: function (emitter) + { + return this.emitters.add(emitter); + }, + + /** + * Creates a new Particle Emitter object, adds it to this Emitter Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter + * @since 3.0.0 + * + * @param {ParticleEmitterConfig} config - Configuration settings for the Particle Emitter to create. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created. + */ + createEmitter: function (config) + { + return this.addEmitter(new ParticleEmitter(this, config)); + }, + + /** + * Adds an existing Gravity Well object to this Emitter Manager. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager. + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager. + */ + addGravityWell: function (well) + { + return this.wells.add(well); + }, + + /** + * Creates a new Gravity Well, adds it to this Emitter Manager and returns a reference to it. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell + * @since 3.0.0 + * + * @param {GravityWellConfig} config - Configuration settings for the Gravity Well to create. + * + * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. + */ + createGravityWell: function (config) + { + return this.addGravityWell(new GravityWell(config)); + }, + + /** + * Emits particles from each active emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle + * @since 3.0.0 + * + * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * @param {number} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. + * @param {number} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + emitParticle: function (count, x, y) + { + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.emitParticle(count, x, y); + } + } + + return this; + }, + + /** + * Emits particles from each active emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt + * @since 3.0.0 + * + * @param {number} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. + * @param {number} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. + * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * Pauses this Emitter Manager. + * + * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. + * + * The particles will still render, but they will not have any of their logic updated. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * Resumes this Emitter Manager, should it have been previously paused. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * Gets all active particle processors (gravity wells). + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.GravityWell[]} - The active gravity wells. + */ + getProcessors: function () + { + return this.wells.getAll('active', true); + }, + + /** + * Updates all active emitters. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate + * @since 3.0.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. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var emitters = this.emitters.list; + + for (var i = 0; i < emitters.length; i++) + { + var emitter = emitters[i]; + + if (emitter.active) + { + emitter.preUpdate(time, delta); + } + } + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setAlpha + * @private + * @since 3.10.0 + */ + setAlpha: function () + { + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setScrollFactor + * @private + * @since 3.10.0 + */ + setScrollFactor: function () + { + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setBlendMode + * @private + * @since 3.15.0 + */ + setBlendMode: function () + { + } + +}); + +module.exports = ParticleEmitterManager; + + +/***/ }), +/* 156 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse based on the given angle. + * + * @function Phaser.Geom.Ellipse.CircumferencePoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. + * @param {number} angle - The angle from the center of the Ellipse to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (ellipse, angle, out) +{ + if (out === undefined) { out = new Point(); } + + var halfWidth = ellipse.width / 2; + var halfHeight = ellipse.height / 2; + + out.x = ellipse.x + halfWidth * Math.cos(angle); + out.y = ellipse.y + halfHeight * Math.sin(angle); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 157 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Graphics.Commands + */ + +module.exports = { + + ARC: 0, + BEGIN_PATH: 1, + CLOSE_PATH: 2, + FILL_RECT: 3, + LINE_TO: 4, + MOVE_TO: 5, + LINE_STYLE: 6, + FILL_STYLE: 7, + FILL_PATH: 8, + STROKE_PATH: 9, + FILL_TRIANGLE: 10, + STROKE_TRIANGLE: 11, + LINE_FX_TO: 12, + MOVE_FX_TO: 13, + SAVE: 14, + RESTORE: 15, + TRANSLATE: 16, + SCALE: 17, + ROTATE: 18, + SET_TEXTURE: 19, + CLEAR_TEXTURE: 20, + GRADIENT_FILL_STYLE: 21, + GRADIENT_LINE_STYLE: 22 + +}; + + +/***/ }), +/* 158 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCamera = __webpack_require__(121); +var Class = __webpack_require__(0); +var Commands = __webpack_require__(157); +var ComponentsAlpha = __webpack_require__(401); +var ComponentsBlendMode = __webpack_require__(400); +var ComponentsDepth = __webpack_require__(399); +var ComponentsMask = __webpack_require__(395); +var ComponentsPipeline = __webpack_require__(186); +var ComponentsTransform = __webpack_require__(390); +var ComponentsVisible = __webpack_require__(389); +var ComponentsScrollFactor = __webpack_require__(392); + +var Ellipse = __webpack_require__(90); +var GameObject = __webpack_require__(19); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); var MATH_CONST = __webpack_require__(16); -var Render = __webpack_require__(463); +var Render = __webpack_require__(831); /** * Graphics line style (or stroke style) settings. * * @typedef {object} GraphicsLineStyle * - * @property {number} width - The stroke width. - * @property {number} color - The stroke color. - * @property {number} alpha - The stroke alpha. + * @property {number} [width] - The stroke width. + * @property {number} [color] - The stroke color. + * @property {number} [alpha] - The stroke alpha. */ /** @@ -24721,8 +36490,8 @@ var Render = __webpack_require__(463); * * @typedef {object} GraphicsFillStyle * - * @property {number} color - The fill color. - * @property {number} alpha - The fill alpha. + * @property {number} [color] - The fill color. + * @property {number} [alpha] - The fill alpha. */ /** @@ -24730,8 +36499,8 @@ var Render = __webpack_require__(463); * * @typedef {object} GraphicsStyles * - * @property {GraphicsLineStyle} lineStyle - The style applied to shape outlines. - * @property {GraphicsFillStyle} fillStyle - The style applied to shape areas. + * @property {GraphicsLineStyle} [lineStyle] - The style applied to shape outlines. + * @property {GraphicsFillStyle} [fillStyle] - The style applied to shape areas. */ /** @@ -24740,13 +36509,13 @@ var Render = __webpack_require__(463); * @typedef {object} GraphicsOptions * @extends GraphicsStyles * - * @property {number} x - The x coordinate of the Graphics. - * @property {number} y - The y coordinate of the Graphics. + * @property {number} [x] - The x coordinate of the Graphics. + * @property {number} [y] - The y coordinate of the Graphics. */ /** * @classdesc - * A Graphics object is a way to draw primitive shapes to you game. Primitives include forms of geometry, such as + * A Graphics object is a way to draw primitive shapes to your game. Primitives include forms of geometry, such as * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics * object it will be empty. * @@ -24787,7 +36556,7 @@ var Render = __webpack_require__(463); * * @class Graphics * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -24801,21 +36570,21 @@ var Render = __webpack_require__(463); * @extends Phaser.GameObjects.Components.ScrollFactor * * @param {Phaser.Scene} scene - The Scene to which this Graphics object belongs. - * @param {GraphicsOptions} options - Options that set the position and default style of this Graphics object. + * @param {GraphicsOptions} [options] - Options that set the position and default style of this Graphics object. */ var Graphics = new Class({ Extends: GameObject, Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Pipeline, - Components.Transform, - Components.Visible, - Components.ScrollFactor, + ComponentsAlpha, + ComponentsBlendMode, + ComponentsDepth, + ComponentsMask, + ComponentsPipeline, + ComponentsTransform, + ComponentsVisible, + ComponentsScrollFactor, Render ], @@ -24829,7 +36598,7 @@ var Graphics = new Class({ GameObject.call(this, scene, 'Graphics'); this.setPosition(x, y); - this.initPipeline('FlatTintPipeline'); + this.initPipeline(); /** * The horizontal display origin of the Graphics. @@ -25005,6 +36774,139 @@ var Graphics = new Class({ return this; }, + /** + * Sets a gradient fill style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all filled shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. + * + * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. + * + * This feature is best used only on rectangles and triangles. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#fillGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {integer} topLeft - The tint being applied to the top-left of the Game Object. + * @param {integer} topRight - The tint being applied to the top-right of the Game Object. + * @param {integer} bottomLeft - The tint being applied to the bottom-left of the Game Object. + * @param {integer} bottomRight - The tint being applied to the bottom-right of the Game Object. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillGradientStyle: function (topLeft, topRight, bottomLeft, bottomRight, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.GRADIENT_FILL_STYLE, + alpha, topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Sets a gradient line style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all stroked shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. + * + * This feature is best used only on single lines. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#lineGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {number} lineWidth - The stroke width. + * @param {integer} topLeft - The tint being applied to the top-left of the Game Object. + * @param {integer} topRight - The tint being applied to the top-right of the Game Object. + * @param {integer} bottomLeft - The tint being applied to the bottom-left of the Game Object. + * @param {integer} bottomRight - The tint being applied to the bottom-right of the Game Object. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineGradientStyle: function (lineWidth, topLeft, topRight, bottomLeft, bottomRight, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.GRADIENT_LINE_STYLE, + lineWidth, alpha, topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Sets the texture frame this Graphics Object will use when drawing all shapes defined after calling this. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Once set, all shapes will use this texture. Call this method with no arguments to clear it. + * + * The textures are not tiled. They are stretched to the dimensions of the shapes being rendered. For this reason, + * it works best with seamless / tileable textures. + * + * The mode argument controls how the textures are combined with the fill colors. The default value (0) will + * multiply the texture by the fill color. A value of 1 will use just the fill color, but the alpha data from the texture, + * and a value of 2 will use just the texture and no fill color at all. + * + * @method Phaser.GameObjects.Graphics#setTexture + * @since 3.12.0 + * @webglOnly + * + * @param {string} [key] - The key of the texture to be used, as stored in the Texture Manager. Leave blank to clear a previously set texture. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} [mode=0] - The texture tint mode. 0 is multiply, 1 is alpha only and 2 is texture only. + * + * @return {this} This Game Object. + */ + setTexture: function (key, frame, mode) + { + if (mode === undefined) { mode = 0; } + + if (key === undefined) + { + this.commandBuffer.push( + Commands.CLEAR_TEXTURE + ); + } + else + { + var textureFrame = this.scene.sys.textures.getFrame(key, frame); + + if (textureFrame) + { + if (mode === 2) + { + mode = 3; + } + + this.commandBuffer.push( + Commands.SET_TEXTURE, + textureFrame, + mode + ); + } + } + + return this; + }, + /** * Start a new shape path. * @@ -25240,6 +37142,106 @@ var Graphics = new Class({ return this; }, + /** + * Fill a rounded rectangle with the given position, size and radius. + * + * @method Phaser.GameObjects.Graphics#fillRoundedRect + * @since 3.11.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {number} [radius = 20] - The corner radius; It can also be an object to specify different radii for corners + * @param {number} [radius.tl = 20] Top left + * @param {number} [radius.tr = 20] Top right + * @param {number} [radius.br = 20] Bottom right + * @param {number} [radius.bl = 20] Bottom left + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillRoundedRect: function (x, y, width, height, radius) + { + if (radius === undefined) { radius = 20; } + + var tl = radius; + var tr = radius; + var bl = radius; + var br = radius; + + if (typeof radius !== 'number') + { + tl = GetFastValue(radius, 'tl', 20); + tr = GetFastValue(radius, 'tr', 20); + bl = GetFastValue(radius, 'bl', 20); + br = GetFastValue(radius, 'br', 20); + } + + this.beginPath(); + this.moveTo(x + tl, y); + this.lineTo(x + width - tr, y); + this.arc(x + width - tr, y + tr, tr, -MATH_CONST.TAU, 0); + this.lineTo(x + width, y + height - br); + this.arc(x + width - br, y + height - br, br, 0, MATH_CONST.TAU); + this.lineTo(x + bl, y + height); + this.arc(x + bl, y + height - bl, bl, MATH_CONST.TAU, Math.PI); + this.lineTo(x, y + tl); + this.arc(x + tl, y + tl, tl, -Math.PI, -MATH_CONST.TAU); + this.fillPath(); + + return this; + }, + + /** + * Stroke a rounded rectangle with the given position, size and radius. + * + * @method Phaser.GameObjects.Graphics#strokeRoundedRect + * @since 3.11.0 + * + * @param {number} x - The x coordinate of the top-left of the rectangle. + * @param {number} y - The y coordinate of the top-left of the rectangle. + * @param {number} width - The width of the rectangle. + * @param {number} height - The height of the rectangle. + * @param {number} [radius = 20] - The corner radius; It can also be an object to specify different radii for corners + * @param {number} [radius.tl = 20] Top left + * @param {number} [radius.tr = 20] Top right + * @param {number} [radius.br = 20] Bottom right + * @param {number} [radius.bl = 20] Bottom left + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + strokeRoundedRect: function (x, y, width, height, radius) + { + if (radius === undefined) { radius = 20; } + + var tl = radius; + var tr = radius; + var bl = radius; + var br = radius; + + if (typeof radius !== 'number') + { + tl = GetFastValue(radius, 'tl', 20); + tr = GetFastValue(radius, 'tr', 20); + bl = GetFastValue(radius, 'bl', 20); + br = GetFastValue(radius, 'br', 20); + } + + this.beginPath(); + this.moveTo(x + tl, y); + this.lineTo(x + width - tr, y); + this.arc(x + width - tr, y + tr, tr, -MATH_CONST.TAU, 0); + this.lineTo(x + width, y + height - br); + this.arc(x + width - br, y + height - br, br, 0, MATH_CONST.TAU); + this.lineTo(x + bl, y + height); + this.arc(x + bl, y + height - bl, bl, MATH_CONST.TAU, Math.PI); + this.lineTo(x, y + tl); + this.arc(x + tl, y + tl, tl, -Math.PI, -MATH_CONST.TAU); + this.strokePath(); + + return this; + }, + /** * Fill the given point. * @@ -25670,6 +37672,13 @@ var Graphics = new Class({ * Draw an arc. * * This method can be used to create circles, or parts of circles. + * + * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically + * close when filled or stroked. + * + * Use the optional `overshoot` argument increase the number of iterations that take place when + * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, + * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. * * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling * this method to draw the arc. @@ -25683,14 +37692,18 @@ var Graphics = new Class({ * @param {number} startAngle - The starting angle, in radians. * @param {number} endAngle - The ending angle, in radians. * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. * * @return {Phaser.GameObjects.Graphics} This Game Object. */ - arc: function (x, y, radius, startAngle, endAngle, anticlockwise) + arc: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) { + if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } + this.commandBuffer.push( Commands.ARC, - x, y, radius, startAngle, endAngle, anticlockwise + x, y, radius, startAngle, endAngle, anticlockwise, overshoot ); return this; @@ -25714,19 +37727,21 @@ var Graphics = new Class({ * @param {number} radius - The radius of the slice. * @param {number} startAngle - The start angle of the slice, given in radians. * @param {number} endAngle - The end angle of the slice, given in radians. - * @param {boolean} [anticlockwise=false] - Draw the slice piece anticlockwise or clockwise? + * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. * * @return {Phaser.GameObjects.Graphics} This Game Object. */ - slice: function (x, y, radius, startAngle, endAngle, anticlockwise) + slice: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) { if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } this.commandBuffer.push(Commands.BEGIN_PATH); this.commandBuffer.push(Commands.MOVE_TO, x, y); - this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise); + this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise, overshoot); this.commandBuffer.push(Commands.CLOSE_PATH); @@ -25734,7 +37749,9 @@ var Graphics = new Class({ }, /** - * [description] + * Saves the state of the Graphics by pushing the current state onto a stack. + * + * The most recently saved state can then be restored with {@link Phaser.GameObjects.Graphics#restore}. * * @method Phaser.GameObjects.Graphics#save * @since 3.0.0 @@ -25751,7 +37768,11 @@ var Graphics = new Class({ }, /** - * [description] + * Restores the most recently saved state of the Graphics by popping from the state stack. + * + * Use {@link Phaser.GameObjects.Graphics#save} to save the current state, and call this afterwards to restore that state. + * + * If there is no saved state, this command does nothing. * * @method Phaser.GameObjects.Graphics#restore * @since 3.0.0 @@ -25875,10 +37896,12 @@ var Graphics = new Class({ generateTexture: function (key, width, height) { var sys = this.scene.sys; + var renderer = sys.game.renderer; if (width === undefined) { width = sys.game.config.width; } if (height === undefined) { height = sys.game.config.height; } + Graphics.TargetCamera.setScene(this.scene); Graphics.TargetCamera.setViewport(0, 0, width, height); Graphics.TargetCamera.scrollX = this.x; Graphics.TargetCamera.scrollY = this.y; @@ -25919,11 +37942,12 @@ var Graphics = new Class({ if (ctx) { - this.renderCanvas(sys.game.renderer, this, 0.0, Graphics.TargetCamera, null, ctx); + // var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) + this.renderCanvas(renderer, this, 0, Graphics.TargetCamera, null, ctx, false); - if (sys.game.renderer.gl && texture) + if (texture) { - texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture); + texture.refresh(); } } @@ -25951,13 +37975,1839 @@ var Graphics = new Class({ * @type {Phaser.Cameras.Scene2D.Camera} * @since 3.1.0 */ -Graphics.TargetCamera = new Camera(0, 0, 0, 0); +Graphics.TargetCamera = new BaseCamera(); module.exports = Graphics; /***/ }), -/* 116 */ +/* 159 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapText = __webpack_require__(109); +var Class = __webpack_require__(0); +var Render = __webpack_require__(834); + +/** + * @typedef {object} DisplayCallbackConfig + * + * @property {{topLeft:number, topRight:number, bottomLeft:number, bottomRight:number}} tint - The tint of the character being rendered. + * @property {number} index - The index of the character being rendered. + * @property {number} charCode - The character code of the character being rendered. + * @property {number} x - The x position of the character being rendered. + * @property {number} y - The y position of the character being rendered. + * @property {number} scale - The scale of the character being rendered. + * @property {number} rotation - The rotation of the character being rendered. + * @property {any} data - Custom data stored with the character being rendered. + */ + +/** + * @callback DisplayCallback + * + * @param {DisplayCallbackConfig} display - Settings of the character that is about to be rendered. + * + * @return {{x:number, y:number, scale:number, rotation:number}} Altered position, scale and rotation values for the character that is about to be rendered. + */ + +/** + * @classdesc + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * @class DynamicBitmapText + * @extends Phaser.GameObjects.BitmapText + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} x - The x coordinate of this Game Object in world space. + * @param {number} y - The y coordinate of this Game Object in world space. + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size of this Bitmap Text. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. + */ +var DynamicBitmapText = new Class({ + + Extends: BitmapText, + + Mixins: [ + Render + ], + + initialize: + + function DynamicBitmapText (scene, x, y, font, text, size, align) + { + BitmapText.call(this, scene, x, y, font, text, size, align); + + this.type = 'DynamicBitmapText'; + + /** + * The horizontal scroll position of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollX = 0; + + /** + * The vertical scroll position of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.scrollY = 0; + + /** + * The crop width of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#cropWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropWidth = 0; + + /** + * The crop height of the Bitmap Text. + * + * @name Phaser.GameObjects.DynamicBitmapText#cropHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cropHeight = 0; + + /** + * A callback that alters how each character of the Bitmap Text is rendered. + * + * @name Phaser.GameObjects.DynamicBitmapText#displayCallback + * @type {DisplayCallback} + * @since 3.0.0 + */ + this.displayCallback; + + /** + * The data object that is populated during rendering, then passed to the displayCallback. + * You should modify this object then return it back from the callback. It's updated values + * will be used to render the specific glyph. + * + * Please note that if you need a reference to this object locally in your game code then you + * should shallow copy it, as it's updated and re-used for every glyph in the text. + * + * @name Phaser.GameObjects.DynamicBitmapText#callbackData + * @type {DisplayCallbackConfig} + * @since 3.11.0 + */ + this.callbackData = { + color: 0, + tint: { + topLeft: 0, + topRight: 0, + bottomLeft: 0, + bottomRight: 0 + }, + index: 0, + charCode: 0, + x: 0, + y: 0, + scale: 0, + rotation: 0, + data: 0 + }; + }, + + /** + * Set the crop size of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setSize + * @since 3.0.0 + * + * @param {number} width - The width of the crop. + * @param {number} height - The height of the crop. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setSize: function (width, height) + { + this.cropWidth = width; + this.cropHeight = height; + + return this; + }, + + /** + * Set a callback that alters how each character of the Bitmap Text is rendered. + * + * The callback receives a {@link DisplayCallbackConfig} object that contains information about the character that's + * about to be rendered. + * + * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the + * usual values when rendering. + * + * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback + * @since 3.0.0 + * + * @param {DisplayCallback} callback - The display callback to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setDisplayCallback: function (callback) + { + this.displayCallback = callback; + + return this; + }, + + /** + * Set the horizontal scroll position of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollX + * @since 3.0.0 + * + * @param {number} value - The horizontal scroll position to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollX: function (value) + { + this.scrollX = value; + + return this; + }, + + /** + * Set the vertical scroll position of this Bitmap Text. + * + * @method Phaser.GameObjects.DynamicBitmapText#setScrollY + * @since 3.0.0 + * + * @param {number} value - The vertical scroll position to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. + */ + setScrollY: function (value) + { + this.scrollY = value; + + return this; + } + +}); + +module.exports = DynamicBitmapText; + + +/***/ }), +/* 160 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayUtils = __webpack_require__(164); +var BlendModes = __webpack_require__(66); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var GameObject = __webpack_require__(19); +var Rectangle = __webpack_require__(9); +var Render = __webpack_require__(837); +var Union = __webpack_require__(309); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Container Game Object. + * + * 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. + * + * The position of the Game Object automatically becomes relative to the position of the Container. + * + * When the Container is rendered, all of its children are rendered as well, in the order in which they exist + * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. + * + * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will + * automatically influence all children as well. + * + * Containers can include other Containers for deeply nested transforms. + * + * Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked. + * The masks do not 'stack up'. Only a Container on the root of the display list will use its mask. + * + * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them + * to use as their hit area. Container children can also be enabled for input, independent of the Container. + * + * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, + * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, + * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children + * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure + * your game to work around this. + * + * It's important to understand the impact of using Containers. They add additional processing overhead into + * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true + * for input events. You also loose the ability to set the display depth of Container children in the same + * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost + * every time you create one, try to structure your game around avoiding that where possible. + * + * @class Container + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.4.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. + */ +var Container = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Mask, + Components.ScrollFactor, + Components.Transform, + Components.Visible, + Render + ], + + initialize: + + function Container (scene, x, y, children) + { + GameObject.call(this, scene, 'Container'); + + /** + * An array holding the children of this Container. + * + * @name Phaser.GameObjects.Container#list + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.4.0 + */ + this.list = []; + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * + * @name Phaser.GameObjects.Container#exclusive + * @type {boolean} + * @default true + * @since 3.4.0 + */ + this.exclusive = true; + + /** + * Containers can have an optional maximum size. If set to anything above 0 it + * will constrict the addition of new Game Objects into the Container, capping off + * the maximum limit the Container can grow in size to. + * + * @name Phaser.GameObjects.Container#maxSize + * @type {integer} + * @default -1 + * @since 3.4.0 + */ + this.maxSize = -1; + + /** + * The cursor position. + * + * @name Phaser.GameObjects.Container#position + * @type {integer} + * @since 3.4.0 + */ + this.position = 0; + + /** + * Internal Transform Matrix used for local space conversion. + * + * @name Phaser.GameObjects.Container#localTransform + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.4.0 + */ + this.localTransform = new Components.TransformMatrix(); + + /** + * Internal temporary Transform Matrix used to avoid object creation. + * + * @name Phaser.GameObjects.Container#tempTransformMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.4.0 + */ + this.tempTransformMatrix = new Components.TransformMatrix(); + + /** + * A reference to the Scene Display List. + * + * @name Phaser.GameObjects.Container#_displayList + * @type {Phaser.GameObjects.DisplayList} + * @private + * @since 3.4.0 + */ + this._displayList = scene.sys.displayList; + + /** + * The property key to sort by. + * + * @name Phaser.GameObjects.Container#_sortKey + * @type {string} + * @private + * @since 3.4.0 + */ + this._sortKey = ''; + + /** + * A reference to the Scene Systems Event Emitter. + * + * @name Phaser.GameObjects.Container#_sysEvents + * @type {Phaser.Events.EventEmitter} + * @private + * @since 3.9.0 + */ + this._sysEvents = scene.sys.events; + + this.setPosition(x, y); + + this.clearAlpha(); + + this.setBlendMode(BlendModes.SKIP_CHECK); + + if (children) + { + this.add(children); + } + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#originX + * @type {number} + * @readonly + * @since 3.4.0 + */ + originX: { + + get: function () + { + return 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#originY + * @type {number} + * @readonly + * @since 3.4.0 + */ + originY: { + + get: function () + { + return 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#displayOriginX + * @type {number} + * @readonly + * @since 3.4.0 + */ + displayOriginX: { + + get: function () + { + return this.width * 0.5; + } + + }, + + /** + * Internal value to allow Containers to be used for input and physics. + * Do not change this value. It has no effect other than to break things. + * + * @name Phaser.GameObjects.Container#displayOriginY + * @type {number} + * @readonly + * @since 3.4.0 + */ + displayOriginY: { + + get: function () + { + return this.height * 0.5; + } + + }, + + /** + * Does this Container exclusively manage its children? + * + * The default is `true` which means a child added to this Container cannot + * belong in another Container, which includes the Scene display list. + * + * If you disable this then this Container will no longer exclusively manage its children. + * This allows you to create all kinds of interesting graphical effects, such as replicating + * Game Objects without reparenting them all over the Scene. + * However, doing so will prevent children from receiving any kind of input event or have + * their physics bodies work by default, as they're no longer a single entity on the + * display list, but are being replicated where-ever this Container is. + * + * @method Phaser.GameObjects.Container#setExclusive + * @since 3.4.0 + * + * @param {boolean} [value=true] - The exclusive state of this Container. + * + * @return {Phaser.GameObjects.Container} This Container. + */ + setExclusive: function (value) + { + if (value === undefined) { value = true; } + + this.exclusive = value; + + return this; + }, + + /** + * Gets the bounds of this Container. It works by iterating all children of the Container, + * getting their respective bounds, and then working out a min-max rectangle from that. + * It does not factor in if the children render or not, all are included. + * + * Some children are unable to return their bounds, such as Graphics objects, in which case + * they are skipped. + * + * Depending on the quantity of children in this Container it could be a really expensive call, + * so cache it and only poll it as needed. + * + * The values are stored and returned in a Rectangle object. + * + * @method Phaser.GameObjects.Container#getBounds + * @since 3.4.0 + * + * @param {Phaser.Geom.Rectangle} [output] - A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + output.setTo(this.x, this.y, 0, 0); + + if (this.list.length > 0) + { + var children = this.list; + var tempRect = new Rectangle(); + + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (entry.getBounds) + { + entry.getBounds(tempRect); + + Union(tempRect, output, output); + } + } + } + + return output; + }, + + /** + * Internal add handler. + * + * @method Phaser.GameObjects.Container#addHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just added to this Container. + */ + addHandler: function (gameObject) + { + gameObject.once('destroy', this.remove, this); + + if (this.exclusive) + { + this._displayList.remove(gameObject); + + if (gameObject.parentContainer) + { + gameObject.parentContainer.remove(gameObject); + } + + gameObject.parentContainer = this; + } + }, + + /** + * Internal remove handler. + * + * @method Phaser.GameObjects.Container#removeHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just removed from this Container. + */ + removeHandler: function (gameObject) + { + gameObject.off('destroy', this.remove); + + if (this.exclusive) + { + gameObject.parentContainer = null; + } + }, + + /** + * Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties, + * and transforms it into the space of this Container, then returns it in the output object. + * + * @method Phaser.GameObjects.Container#pointToContainer + * @since 3.4.0 + * + * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} source - The Source Point to be transformed. + * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} [output] - A destination object to store the transformed point in. If none given a Vector2 will be created and returned. + * + * @return {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} The transformed point. + */ + pointToContainer: function (source, output) + { + if (output === undefined) { output = new Vector2(); } + + if (this.parentContainer) + { + return this.parentContainer.pointToContainer(source, output); + } + + var tempMatrix = this.tempTransformMatrix; + + // No need to loadIdentity because applyITRS overwrites every value anyway + tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY); + + tempMatrix.invert(); + + tempMatrix.transformPoint(source.x, source.y, output); + + return output; + }, + + /** + * Returns the world transform matrix as used for Bounds checks. + * + * The returned matrix is temporal and shouldn't be stored. + * + * @method Phaser.GameObjects.Container#getBoundsTransformMatrix + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The world transform matrix. + */ + getBoundsTransformMatrix: function () + { + return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform); + }, + + /** + * Adds the given Game Object, or array of Game Objects, to this Container. + * + * Each Game Object must be unique within the Container. + * + * @method Phaser.GameObjects.Container#add + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + add: function (child) + { + ArrayUtils.Add(this.list, child, this.maxSize, this.addHandler, this); + + return this; + }, + + /** + * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. + * + * Existing Game Objects in the Container are shifted up. + * + * Each Game Object must be unique within the Container. + * + * @method Phaser.GameObjects.Container#addAt + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. + * @param {integer} [index=0] - The position to insert the Game Object/s at. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + addAt: function (child, index) + { + ArrayUtils.AddAt(this.list, child, index, this.maxSize, this.addHandler, this); + + return this; + }, + + /** + * Returns the Game Object at the given position in this Container. + * + * @method Phaser.GameObjects.Container#getAt + * @since 3.4.0 + * + * @param {integer} index - The position to get the Game Object from. + * + * @return {?Phaser.GameObjects.GameObject} The Game Object at the specified index, or `null` if none found. + */ + getAt: function (index) + { + return this.list[index]; + }, + + /** + * Returns the index of the given Game Object in this Container. + * + * @method Phaser.GameObjects.Container#getIndex + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to search for in this Container. + * + * @return {integer} The index of the Game Object in this Container, or -1 if not found. + */ + getIndex: function (child) + { + return this.list.indexOf(child); + }, + + /** + * Sort the contents of this Container so the items are in order based on the given property. + * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. + * + * @method Phaser.GameObjects.Container#sort + * @since 3.4.0 + * + * @param {string} property - The property to lexically sort by. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + sort: function (property) + { + if (property) + { + this._sortKey = property; + + ArrayUtils.StableSort.inplace(this.list, this.sortHandler); + } + + return this; + }, + + /** + * Internal sort handler method. + * + * @method Phaser.GameObjects.Container#sortHandler + * @private + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} childA - The first child to sort. + * @param {Phaser.GameObjects.GameObject} childB - The second child to sort. + * + * @return {integer} The sort results. + */ + sortHandler: function (childA, childB) + { + return childA[this._sortKey] - childB[this._sortKey]; + }, + + /** + * Searches for the first instance of a child with its `name` property matching the given argument. + * Should more than one child have the same name only the first is returned. + * + * @method Phaser.GameObjects.Container#getByName + * @since 3.4.0 + * + * @param {string} name - The name to search for. + * + * @return {?Phaser.GameObjects.GameObject} The first child with a matching name, or `null` if none were found. + */ + getByName: function (name) + { + return ArrayUtils.GetFirst(this.list, 'name', name); + }, + + /** + * Returns a random Game Object from this Container. + * + * @method Phaser.GameObjects.Container#getRandom + * @since 3.4.0 + * + * @param {integer} [startIndex=0] - An optional start index. + * @param {integer} [length] - An optional length, the total number of elements (from the startIndex) to choose from. + * + * @return {?Phaser.GameObjects.GameObject} A random child from the Container, or `null` if the Container is empty. + */ + getRandom: function (startIndex, length) + { + return ArrayUtils.GetRandom(this.list, startIndex, length); + }, + + /** + * Gets the first Game Object in this Container. + * + * You can also specify a property and value to search for, in which case it will return the first + * Game Object in this Container with a matching property and / or value. + * + * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. + * + * You can limit the search to the `startIndex` - `endIndex` range. + * + * @method Phaser.GameObjects.Container#getFirst + * @since 3.4.0 + * + * @param {string} [property] - The property to test on each Game Object in the Container. + * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {?Phaser.GameObjects.GameObject} The first matching Game Object, or `null` if none was found. + */ + getFirst: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns all Game Objects in this Container. + * + * You can optionally specify a matching criteria using the `property` and `value` arguments. + * + * For example: `getAll('body')` would return only Game Objects that have a body property. + * + * You can also specify a value to compare the property to: + * + * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * + * @method Phaser.GameObjects.Container#getAll + * @since 3.4.0 + * + * @param {string} [property] - The property to test on each Game Object in the Container. + * @param {any} [value] - If property is set then the `property` must strictly equal this value to be included in the results. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {Phaser.GameObjects.GameObject[]} An array of matching Game Objects from this Container. + */ + getAll: function (property, value, startIndex, endIndex) + { + return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); + }, + + /** + * Returns the total number of Game Objects in this Container that have a property + * matching the given value. + * + * For example: `count('visible', true)` would count all the elements that have their visible property set. + * + * You can optionally limit the operation to the `startIndex` - `endIndex` range. + * + * @method Phaser.GameObjects.Container#count + * @since 3.4.0 + * + * @param {string} property - The property to check. + * @param {any} value - The value to check. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {integer} The total number of Game Objects in this Container with a property matching the given value. + */ + count: function (property, value, startIndex, endIndex) + { + return ArrayUtils.CountAllMatching(this.list, property, value, startIndex, endIndex); + }, + + /** + * Swaps the position of two Game Objects in this Container. + * Both Game Objects must belong to this Container. + * + * @method Phaser.GameObjects.Container#swap + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child1 - The first Game Object to swap. + * @param {Phaser.GameObjects.GameObject} child2 - The second Game Object to swap. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + swap: function (child1, child2) + { + ArrayUtils.Swap(this.list, child1, child2); + + return this; + }, + + /** + * Moves a Game Object to a new position within this Container. + * + * The Game Object must already be a child of this Container. + * + * The Game Object is removed from its old position and inserted into the new one. + * Therefore the Container size does not change. Other children will change position accordingly. + * + * @method Phaser.GameObjects.Container#moveTo + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to move. + * @param {integer} index - The new position of the Game Object in this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + moveTo: function (child, index) + { + ArrayUtils.MoveTo(this.list, child, index); + + return this; + }, + + /** + * Removes the given Game Object, or array of Game Objects, from this Container. + * + * The Game Objects must already be children of this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#remove + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to be removed from the Container. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each child successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + remove: function (child, destroyChild) + { + var removed = ArrayUtils.Remove(this.list, child, this.removeHandler, this); + + if (destroyChild && removed) + { + if (!Array.isArray(removed)) + { + removed = [ removed ]; + } + + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Removes the Game Object at the given position in this Container. + * + * You can also optionally call `destroy` on the Game Object, if one is found. + * + * @method Phaser.GameObjects.Container#removeAt + * @since 3.4.0 + * + * @param {integer} index - The index of the Game Object to be removed. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + removeAt: function (index, destroyChild) + { + var removed = ArrayUtils.RemoveAt(this.list, index, this.removeHandler, this); + + if (destroyChild && removed) + { + removed.destroy(); + } + + return this; + }, + + /** + * Removes the Game Objects between the given positions in this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#removeBetween + * @since 3.4.0 + * + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + removeBetween: function (startIndex, endIndex, destroyChild) + { + var removed = ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeHandler, this); + + if (destroyChild) + { + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Removes all Game Objects from this Container. + * + * You can also optionally call `destroy` on each Game Object that is removed from the Container. + * + * @method Phaser.GameObjects.Container#removeAll + * @since 3.4.0 + * + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + removeAll: function (destroyChild) + { + var removed = ArrayUtils.RemoveBetween(this.list, 0, this.list.length, this.removeHandler, this); + + if (destroyChild) + { + for (var i = 0; i < removed.length; i++) + { + removed[i].destroy(); + } + } + + return this; + }, + + /** + * Brings the given Game Object to the top of this Container. + * This will cause it to render on-top of any other objects in the Container. + * + * @method Phaser.GameObjects.Container#bringToTop + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to bring to the top of the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + bringToTop: function (child) + { + ArrayUtils.BringToTop(this.list, child); + + return this; + }, + + /** + * Sends the given Game Object to the bottom of this Container. + * This will cause it to render below any other objects in the Container. + * + * @method Phaser.GameObjects.Container#sendToBack + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to send to the bottom of the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + sendToBack: function (child) + { + ArrayUtils.SendToBack(this.list, child); + + return this; + }, + + /** + * Moves the given Game Object up one place in this Container, unless it's already at the top. + * + * @method Phaser.GameObjects.Container#moveUp + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + moveUp: function (child) + { + ArrayUtils.MoveUp(this.list, child); + + return this; + }, + + /** + * Moves the given Game Object down one place in this Container, unless it's already at the bottom. + * + * @method Phaser.GameObjects.Container#moveDown + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + moveDown: function (child) + { + ArrayUtils.MoveDown(this.list, child); + + return this; + }, + + /** + * Reverses the order of all Game Objects in this Container. + * + * @method Phaser.GameObjects.Container#reverse + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + reverse: function () + { + this.list.reverse(); + + return this; + }, + + /** + * Shuffles the all Game Objects in this Container using the Fisher-Yates implementation. + * + * @method Phaser.GameObjects.Container#shuffle + * @since 3.4.0 + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + shuffle: function () + { + ArrayUtils.Shuffle(this.list); + + return this; + }, + + /** + * Replaces a Game Object in this Container with the new Game Object. + * The new Game Object cannot already be a child of this Container. + * + * @method Phaser.GameObjects.Container#replace + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} oldChild - The Game Object in this Container that will be replaced. + * @param {Phaser.GameObjects.GameObject} newChild - The Game Object to be added to this Container. + * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + replace: function (oldChild, newChild, destroyChild) + { + var moved = ArrayUtils.Replace(this.list, oldChild, newChild); + + if (moved) + { + this.addHandler(newChild); + this.removeHandler(oldChild); + + if (destroyChild) + { + oldChild.destroy(); + } + } + + return this; + }, + + /** + * Returns `true` if the given Game Object is a direct child of this Container. + * + * This check does not scan nested Containers. + * + * @method Phaser.GameObjects.Container#exists + * @since 3.4.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object to check for within this Container. + * + * @return {boolean} True if the Game Object is an immediate child of this Container, otherwise false. + */ + exists: function (child) + { + return (this.list.indexOf(child) > -1); + }, + + /** + * Sets the property to the given value on all Game Objects in this Container. + * + * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, + * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only + * the first 50 Game Objects. + * + * @method Phaser.GameObjects.Container#setAll + * @since 3.4.0 + * + * @param {string} property - The property that must exist on the Game Object. + * @param {any} value - The value to get the property to. + * @param {integer} [startIndex=0] - An optional start index to search from. + * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + setAll: function (property, value, startIndex, endIndex) + { + ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); + + return this; + }, + + /** + * @callback EachContainerCallback + * @generic I - [item] + * + * @param {*} item - The child Game Object of the Container. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + */ + + /** + * Passes all Game Objects in this Container to the given callback. + * + * A copy of the Container is made before passing each entry to your callback. + * This protects against the callback itself modifying the Container. + * + * If you know for sure that the callback will not change the size of this Container + * then you can use the more performant `Container.iterate` method instead. + * + * @method Phaser.GameObjects.Container#each + * @since 3.4.0 + * + * @param {function} callback - The function to call. + * @param {object} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + each: function (callback, context) + { + var args = [ null ]; + var i; + var temp = this.list.slice(); + var len = temp.length; + + for (i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < len; i++) + { + args[0] = temp[i]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Passes all Game Objects in this Container to the given callback. + * + * Only use this method when you absolutely know that the Container will not be modified during + * the iteration, i.e. by removing or adding to its contents. + * + * @method Phaser.GameObjects.Container#iterate + * @since 3.4.0 + * + * @param {function} callback - The function to call. + * @param {object} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.GameObjects.Container} This Container instance. + */ + iterate: function (callback, context) + { + var args = [ null ]; + var i; + + for (i = 2; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (i = 0; i < this.list.length; i++) + { + args[0] = this.list[i]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * The number of Game Objects inside this Container. + * + * @name Phaser.GameObjects.Container#length + * @type {integer} + * @readonly + * @since 3.4.0 + */ + length: { + + get: function () + { + return this.list.length; + } + + }, + + /** + * Returns the first Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#first + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + first: { + + get: function () + { + this.position = 0; + + if (this.list.length > 0) + { + return this.list[0]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the last Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#last + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + last: { + + get: function () + { + if (this.list.length > 0) + { + this.position = this.list.length - 1; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the next Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#next + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + next: { + + get: function () + { + if (this.position < this.list.length) + { + this.position++; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Returns the previous Game Object within the Container, or `null` if it is empty. + * + * You can move the cursor by calling `Container.next` and `Container.previous`. + * + * @name Phaser.GameObjects.Container#previous + * @type {?Phaser.GameObjects.GameObject} + * @readonly + * @since 3.4.0 + */ + previous: { + + get: function () + { + if (this.position > 0) + { + this.position--; + + return this.list[this.position]; + } + else + { + return null; + } + } + + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Container#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.removeAll(!!this.exclusive); + + this.localTransform.destroy(); + this.tempTransformMatrix.destroy(); + + this.list = []; + this._displayList = null; + } + +}); + +module.exports = Container; + + +/***/ }), +/* 161 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlitterRender = __webpack_require__(841); +var Bob = __webpack_require__(838); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var Frame = __webpack_require__(113); +var GameObject = __webpack_require__(19); +var List = __webpack_require__(112); + +/** + * @callback Phaser.GameObjects.Blitter.CreateCallback + * + * @param {Phaser.GameObjects.Blitter.Bob} bob - The Bob that was created by the Blitter. + * @param {integer} index - The position of the Bob within the Blitter display list. + */ + +/** + * @classdesc + * A Blitter Game Object. + * + * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. + * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, + * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed + * during rendering. + * + * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this + * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows + * them their speed. + * + * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth + * investigating. They are especially useful for using as a base for your own special effects systems. + * + * @class Blitter + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. + * @param {number} [x=0] - The x coordinate of this Game Object in world space. + * @param {number} [y=0] - The y coordinate of this Game Object in world space. + * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. + * @param {(string|integer)} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. + */ +var Blitter = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Mask, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Transform, + Components.Visible, + BlitterRender + ], + + initialize: + + function Blitter (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Blitter'); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.initPipeline(); + + /** + * The children of this Blitter. + * This List contains all of the Bob objects created by the Blitter. + * + * @name Phaser.GameObjects.Blitter#children + * @type {Phaser.Structs.List.} + * @since 3.0.0 + */ + this.children = new List(); + + /** + * A transient array that holds all of the Bobs that will be rendered this frame. + * The array is re-populated whenever the dirty flag is set. + * + * @name Phaser.GameObjects.Blitter#renderList + * @type {Phaser.GameObjects.Blitter.Bob[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.renderList = []; + + /** + * Is the Blitter considered dirty? + * A 'dirty' Blitter has had its child count changed since the last frame. + * + * @name Phaser.GameObjects.Blitter#dirty + * @type {boolean} + * @since 3.0.0 + */ + this.dirty = false; + }, + + /** + * Creates a new Bob in this Blitter. + * + * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. + * A Bob can use any frame belonging to the texture bound to the Blitter. + * + * @method Phaser.GameObjects.Blitter#create + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. + * + * @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object. + */ + create: function (x, y, frame, visible, index) + { + if (visible === undefined) { visible = true; } + if (index === undefined) { index = this.children.length; } + + if (frame === undefined) + { + frame = this.frame; + } + else if (!(frame instanceof Frame)) + { + frame = this.texture.get(frame); + } + + var bob = new Bob(this, x, y, frame, visible); + + this.children.addAt(bob, index, false); + + this.dirty = true; + + return bob; + }, + + /** + * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. + * + * @method Phaser.GameObjects.Blitter#createFromCallback + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter.CreateCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createFromCallback: function (callback, quantity, frame, visible) + { + var bobs = this.createMultiple(quantity, frame, visible); + + for (var i = 0; i < bobs.length; i++) + { + var bob = bobs[i]; + + callback.call(this, bob, i); + } + + return bobs; + }, + + /** + * Creates multiple Bobs in one call. + * + * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. + * + * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first + * frame and 10 with the second. + * + * @method Phaser.GameObjects.Blitter#createMultiple + * @since 3.0.0 + * + * @param {integer} quantity - The quantity of Bob objects to create. + * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. + * @param {boolean} [visible=true] - Should the created Bob render or not? + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. + */ + createMultiple: function (quantity, frame, visible) + { + if (frame === undefined) { frame = this.frame.name; } + if (visible === undefined) { visible = true; } + + if (!Array.isArray(frame)) + { + frame = [ frame ]; + } + + var bobs = []; + var _this = this; + + frame.forEach(function (singleFrame) + { + for (var i = 0; i < quantity; i++) + { + bobs.push(_this.create(0, 0, singleFrame, visible)); + } + }); + + return bobs; + }, + + /** + * Checks if the given child can render or not, by checking its `visible` and `alpha` values. + * + * @method Phaser.GameObjects.Blitter#childCanRender + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter.Bob} child - The Bob to check for rendering. + * + * @return {boolean} Returns `true` if the given child can render, otherwise `false`. + */ + childCanRender: function (child) + { + return (child.visible && child.alpha > 0); + }, + + /** + * Returns an array of Bobs to be rendered. + * If the Blitter is dirty then a new list is generated and stored in `renderList`. + * + * @method Phaser.GameObjects.Blitter#getRenderList + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that will be rendered this frame. + */ + getRenderList: function () + { + if (this.dirty) + { + this.renderList = this.children.list.filter(this.childCanRender, this); + this.dirty = false; + } + + return this.renderList; + }, + + /** + * Removes all Bobs from the children List and clears the dirty flag. + * + * @method Phaser.GameObjects.Blitter#clear + * @since 3.0.0 + */ + clear: function () + { + this.children.removeAll(); + this.dirty = true; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Blitter#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + this.children.destroy(); + + this.renderList = []; + } + +}); + +module.exports = Blitter; + + +/***/ }), +/* 162 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns a Random element from the array. + * + * @function Phaser.Utils.Array.GetRandom + * @since 3.0.0 + * + * @param {array} array - The array to select the random entry from. + * @param {integer} [startIndex=0] - An optional start index. + * @param {integer} [length=array.length] - An optional length, the total number of elements (from the startIndex) to choose from. + * + * @return {*} A random element from the array, or `null` if no element could be found in the range given. + */ +var GetRandom = function (array, startIndex, length) +{ + if (startIndex === undefined) { startIndex = 0; } + if (length === undefined) { length = array.length; } + + var randomIndex = startIndex + Math.floor(Math.random() * length); + + return (array[randomIndex] === undefined) ? null : array[randomIndex]; +}; + +module.exports = GetRandom; + + +/***/ }), +/* 163 */ /***/ (function(module, exports) { /** @@ -26015,7 +39865,60 @@ module.exports = CheckMatrix; /***/ }), -/* 117 */ +/* 164 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.Array + */ + +module.exports = { + + Matrix: __webpack_require__(874), + + Add: __webpack_require__(867), + AddAt: __webpack_require__(866), + BringToTop: __webpack_require__(865), + CountAllMatching: __webpack_require__(864), + Each: __webpack_require__(863), + EachInRange: __webpack_require__(862), + FindClosestInSorted: __webpack_require__(383), + GetAll: __webpack_require__(861), + GetFirst: __webpack_require__(860), + GetRandom: __webpack_require__(162), + MoveDown: __webpack_require__(859), + MoveTo: __webpack_require__(858), + MoveUp: __webpack_require__(857), + NumberArray: __webpack_require__(856), + NumberArrayStep: __webpack_require__(855), + QuickSelect: __webpack_require__(313), + Range: __webpack_require__(312), + Remove: __webpack_require__(330), + RemoveAt: __webpack_require__(854), + RemoveBetween: __webpack_require__(853), + RemoveRandomElement: __webpack_require__(852), + Replace: __webpack_require__(851), + RotateLeft: __webpack_require__(387), + RotateRight: __webpack_require__(386), + SafeRange: __webpack_require__(62), + SendToBack: __webpack_require__(850), + SetAll: __webpack_require__(849), + Shuffle: __webpack_require__(122), + SpliceOne: __webpack_require__(91), + StableSort: __webpack_require__(110), + Swap: __webpack_require__(848) + +}; + + +/***/ }), +/* 165 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -26025,8 +39928,10 @@ module.exports = CheckMatrix; */ var Class = __webpack_require__(0); -var Frame = __webpack_require__(128); -var TextureSource = __webpack_require__(183); +var Frame = __webpack_require__(113); +var TextureSource = __webpack_require__(317); + +var TEXTURE_MISSING_ERROR = 'Texture.frame missing: '; /** * @classdesc @@ -26041,7 +39946,7 @@ var TextureSource = __webpack_require__(183); * Sprites and other Game Objects get the texture data they need from the TextureManager. * * @class Texture - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * @@ -26223,7 +40128,7 @@ var Texture = new Class({ if (!frame) { - console.warn('No Texture.frame found with name ' + name); + console.warn(TEXTURE_MISSING_ERROR + name); frame = this.frames[this.firstFrame]; } @@ -26264,16 +40169,19 @@ var Texture = new Class({ * @since 3.0.0 * * @param {integer} sourceIndex - The index of the TextureSource to get the Frames from. + * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? * * @return {Phaser.Textures.Frame[]} An array of Texture Frames. */ - getFramesFromTextureSource: function (sourceIndex) + getFramesFromTextureSource: function (sourceIndex, includeBase) { + if (includeBase === undefined) { includeBase = false; } + var out = []; for (var frameName in this.frames) { - if (frameName === '__BASE') + if (frameName === '__BASE' && !includeBase) { continue; } @@ -26282,7 +40190,7 @@ var Texture = new Class({ if (frame.sourceIndex === sourceIndex) { - out.push(frame.name); + out.push(frame); } } @@ -26331,7 +40239,7 @@ var Texture = new Class({ * * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. * - * @return {(HTMLImageElement|HTMLCanvasElement)} The DOM Image or Canvas Element. + * @return {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)} The DOM Image, Canvas Element or Render Texture. */ getSourceImage: function (name) { @@ -26342,15 +40250,15 @@ var Texture = new Class({ var frame = this.frames[name]; - if (!frame) + if (frame) { - console.warn('No Texture.frame found with name ' + name); - - return this.frames['__BASE'].source.image; + return frame.source.image; } else { - return frame.source.image; + console.warn(TEXTURE_MISSING_ERROR + name); + + return this.frames['__BASE'].source.image; } }, @@ -26379,7 +40287,7 @@ var Texture = new Class({ if (!frame) { - console.warn('No Texture.frame found with name ' + name); + console.warn(TEXTURE_MISSING_ERROR + name); idx = this.frames['__BASE'].sourceIndex; } @@ -26408,7 +40316,7 @@ var Texture = new Class({ { data = [ data ]; } - + for (var i = 0; i < data.length; i++) { var source = this.source[i]; @@ -26485,7 +40393,7 @@ module.exports = Texture; /***/ }), -/* 118 */ +/* 166 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -26495,12 +40403,12 @@ module.exports = Texture; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(55); -var DefaultPlugins = __webpack_require__(121); -var GetPhysicsPlugins = __webpack_require__(518); -var GetScenePlugins = __webpack_require__(517); -var NOOP = __webpack_require__(3); -var Settings = __webpack_require__(192); +var CONST = __webpack_require__(116); +var DefaultPlugins = __webpack_require__(167); +var GetPhysicsPlugins = __webpack_require__(890); +var GetScenePlugins = __webpack_require__(889); +var NOOP = __webpack_require__(1); +var Settings = __webpack_require__(326); /** * @classdesc @@ -26511,7 +40419,7 @@ var Settings = __webpack_require__(192); * handling the update step and renderer. It also contains references to global systems belonging to Game. * * @class Systems - * @memberOf Phaser.Scenes + * @memberof Phaser.Scenes * @constructor * @since 3.0.0 * @@ -26525,7 +40433,7 @@ var Systems = new Class({ function Systems (scene, config) { /** - * [description] + * A reference to the Scene that these Systems belong to. * * @name Phaser.Scenes.Systems#scene * @type {Phaser.Scene} @@ -26534,7 +40442,7 @@ var Systems = new Class({ this.scene = scene; /** - * [description] + * A reference to the Phaser Game instance. * * @name Phaser.Scenes.Systems#game * @type {Phaser.Game} @@ -26542,8 +40450,11 @@ var Systems = new Class({ */ this.game; + if (false) + {} + /** - * [description] + * The Scene Configuration object, as passed in when creating the Scene. * * @name Phaser.Scenes.Systems#config * @type {(string|Phaser.Scenes.Settings.Config)} @@ -26552,7 +40463,7 @@ var Systems = new Class({ this.config = config; /** - * [description] + * The Scene Settings. This is the parsed output based on the Scene configuration. * * @name Phaser.Scenes.Systems#settings * @type {Phaser.Scenes.Settings.Object} @@ -26570,7 +40481,7 @@ var Systems = new Class({ this.canvas; /** - * [description] + * A reference to the Canvas Rendering Context being used by the renderer. * * @name Phaser.Scenes.Systems#context * @type {CanvasRenderingContext2D} @@ -26581,7 +40492,9 @@ var Systems = new Class({ // Global Systems - these are single-instance global managers that belong to Game /** - * [description] + * A reference to the global Animations Manager. + * + * In the default set-up you can access this from within a Scene via the `this.anims` property. * * @name Phaser.Scenes.Systems#anims * @type {Phaser.Animations.AnimationManager} @@ -26590,7 +40503,10 @@ var Systems = new Class({ this.anims; /** - * [description] + * A reference to the global Cache. The Cache stores all files bought in to Phaser via + * the Loader, with the exception of images. Images are stored in the Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.cache` property. * * @name Phaser.Scenes.Systems#cache * @type {Phaser.Cache.CacheManager} @@ -26599,7 +40515,9 @@ var Systems = new Class({ this.cache; /** - * [description] + * A reference to the global Plugins Manager. + * + * In the default set-up you can access this from within a Scene via the `this.plugins` property. * * @name Phaser.Scenes.Systems#plugins * @type {Phaser.Plugins.PluginManager} @@ -26608,7 +40526,10 @@ var Systems = new Class({ this.plugins; /** - * [description] + * A reference to the global registry. This is a game-wide instance of the Data Manager, allowing + * you to exchange data between Scenes via a universal and shared point. + * + * In the default set-up you can access this from within a Scene via the `this.registry` property. * * @name Phaser.Scenes.Systems#registry * @type {Phaser.Data.DataManager} @@ -26617,7 +40538,9 @@ var Systems = new Class({ this.registry; /** - * [description] + * A reference to the global Sound Manager. + * + * In the default set-up you can access this from within a Scene via the `this.sound` property. * * @name Phaser.Scenes.Systems#sound * @type {Phaser.Sound.BaseSoundManager} @@ -26626,7 +40549,9 @@ var Systems = new Class({ this.sound; /** - * [description] + * A reference to the global Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.textures` property. * * @name Phaser.Scenes.Systems#textures * @type {Phaser.Textures.TextureManager} @@ -26637,7 +40562,11 @@ var Systems = new Class({ // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems /** - * [description] + * A reference to the Scene's Game Object Factory. + * + * Use this to quickly and easily create new Game Object's. + * + * In the default set-up you can access this from within a Scene via the `this.add` property. * * @name Phaser.Scenes.Systems#add * @type {Phaser.GameObjects.GameObjectFactory} @@ -26646,7 +40575,11 @@ var Systems = new Class({ this.add; /** - * [description] + * A reference to the Scene's Camera Manager. + * + * Use this to manipulate and create Cameras for this specific Scene. + * + * In the default set-up you can access this from within a Scene via the `this.cameras` property. * * @name Phaser.Scenes.Systems#cameras * @type {Phaser.Cameras.Scene2D.CameraManager} @@ -26655,7 +40588,11 @@ var Systems = new Class({ this.cameras; /** - * [description] + * A reference to the Scene's Display List. + * + * Use this to organize the children contained in the display list. + * + * In the default set-up you can access this from within a Scene via the `this.children` property. * * @name Phaser.Scenes.Systems#displayList * @type {Phaser.GameObjects.DisplayList} @@ -26664,7 +40601,11 @@ var Systems = new Class({ this.displayList; /** - * [description] + * A reference to the Scene's Event Manager. + * + * Use this to listen for Scene specific events, such as `pause` and `shutdown`. + * + * In the default set-up you can access this from within a Scene via the `this.events` property. * * @name Phaser.Scenes.Systems#events * @type {Phaser.Events.EventEmitter} @@ -26673,7 +40614,13 @@ var Systems = new Class({ this.events; /** - * [description] + * A reference to the Scene's Game Object Creator. + * + * Use this to quickly and easily create new Game Object's. The difference between this and the + * Game Object Factory, is that the Creator just creates and returns Game Object instances, it + * doesn't then add them to the Display List or Update List. + * + * In the default set-up you can access this from within a Scene via the `this.make` property. * * @name Phaser.Scenes.Systems#make * @type {Phaser.GameObjects.GameObjectCreator} @@ -26682,7 +40629,12 @@ var Systems = new Class({ this.make; /** - * [description] + * A reference to the Scene Manager Plugin. + * + * Use this to manipulate both this and other Scene's in your game, for example to launch a parallel Scene, + * or pause or resume a Scene, or switch from this Scene to another. + * + * In the default set-up you can access this from within a Scene via the `this.scene` property. * * @name Phaser.Scenes.Systems#scenePlugin * @type {Phaser.Scenes.ScenePlugin} @@ -26691,7 +40643,14 @@ var Systems = new Class({ this.scenePlugin; /** - * [description] + * A reference to the Scene's Update List. + * + * Use this to organize the children contained in the update list. + * + * The Update List is responsible for managing children that need their `preUpdate` methods called, + * in order to process so internal components, such as Sprites with Animations. + * + * In the default set-up there is no reference to this from within the Scene itself. * * @name Phaser.Scenes.Systems#updateList * @type {Phaser.GameObjects.UpdateList} @@ -26701,7 +40660,7 @@ var Systems = new Class({ /** * The Scene Update function. - * + * * This starts out as NOOP during init, preload and create, and at the end of create * it swaps to be whatever the Scene.update function is. * @@ -26788,13 +40747,13 @@ var Systems = new Class({ }, /** - * Called automatically by the Scene Manager. Instructs the Scene to render itself via - * its Camera Manager to the renderer given. + * 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 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The renderer that invoked the render call. */ render: function (renderer) { @@ -26835,10 +40794,12 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#pause * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'pause' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ - pause: function () + pause: function (data) { if (this.settings.active) { @@ -26846,7 +40807,7 @@ var Systems = new Class({ this.settings.active = false; - this.events.emit('pause', this); + this.events.emit('pause', this, data); } return this; @@ -26858,9 +40819,11 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#resume * @since 3.0.0 * + * @param {object} [data] - A data object that will be passed in the 'resume' event. + * * @return {Phaser.Scenes.Systems} This Systems object. */ - resume: function () + resume: function (data) { if (!this.settings.active) { @@ -26868,7 +40831,7 @@ var Systems = new Class({ this.settings.active = true; - this.events.emit('resume', this); + this.events.emit('resume', this, data); } return this; @@ -26884,17 +40847,19 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#sleep * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'sleep' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ - sleep: function () + sleep: function (data) { this.settings.status = CONST.SLEEPING; this.settings.active = false; this.settings.visible = false; - this.events.emit('sleep', this); + this.events.emit('sleep', this, data); return this; }, @@ -26905,9 +40870,11 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#wake * @since 3.0.0 * + * @param {object} [data] - A data object that will be passed in the 'wake' event. + * * @return {Phaser.Scenes.Systems} This Systems object. */ - wake: function () + wake: function (data) { var settings = this.settings; @@ -26916,7 +40883,7 @@ var Systems = new Class({ settings.active = true; settings.visible = true; - this.events.emit('wake', this); + this.events.emit('wake', this, data); if (settings.isTransition) { @@ -26932,7 +40899,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#isSleeping * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Scene is asleep, otherwise `false`. */ isSleeping: function () { @@ -26945,13 +40912,26 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#isActive * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Scene is active, otherwise `false`. */ isActive: function () { return (this.settings.status === CONST.RUNNING); }, + /** + * Is this Scene paused? + * + * @method Phaser.Scenes.Systems#isPaused + * @since 3.13.0 + * + * @return {boolean} `true` if this Scene is paused, otherwise `false`. + */ + isPaused: function () + { + return (this.settings.status === CONST.PAUSED); + }, + /** * Is this Scene currently transitioning out to, or in from another Scene? * @@ -26997,7 +40977,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#isVisible * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Scene is visible, otherwise `false`. */ isVisible: function () { @@ -27011,7 +40991,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#setVisible * @since 3.0.0 * - * @param {boolean} value - [description] + * @param {boolean} value - `true` to render this Scene, otherwise `false`. * * @return {Phaser.Scenes.Systems} This Systems object. */ @@ -27024,24 +41004,26 @@ var Systems = new Class({ /** * 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 - If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. + * @param {object} [data] - A data object that will be passed in the 'resume' or 'pause' events. * * @return {Phaser.Scenes.Systems} This Systems object. */ - setActive: function (value) + setActive: function (value, data) { if (value) { - return this.resume(); + return this.resume(data); } else { - return this.pause(); + return this.pause(data); } }, @@ -27070,7 +41052,7 @@ var Systems = new Class({ this.events.emit('start', this); // For user-land code to listen out for - this.events.emit('ready', this); + this.events.emit('ready', this, data); }, /** @@ -27097,8 +41079,10 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#shutdown * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'shutdown' event. */ - shutdown: function () + shutdown: function (data) { this.events.off('transitioninit'); this.events.off('transitionstart'); @@ -27110,7 +41094,7 @@ var Systems = new Class({ this.settings.active = false; this.settings.visible = false; - this.events.emit('shutdown', this); + this.events.emit('shutdown', this, data); }, /** @@ -27147,46 +41131,7 @@ module.exports = Systems; /***/ }), -/* 119 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects.Graphics.Commands - */ - -module.exports = { - - ARC: 0, - BEGIN_PATH: 1, - CLOSE_PATH: 2, - FILL_RECT: 3, - LINE_TO: 4, - MOVE_TO: 5, - LINE_STYLE: 6, - FILL_STYLE: 7, - FILL_PATH: 8, - STROKE_PATH: 9, - FILL_TRIANGLE: 10, - STROKE_TRIANGLE: 11, - LINE_FX_TO: 12, - MOVE_FX_TO: 13, - SAVE: 14, - RESTORE: 15, - TRANSLATE: 16, - SCALE: 17, - ROTATE: 18 - -}; - - -/***/ }), -/* 120 */ +/* 167 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -27195,9 +41140,110 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var OS = __webpack_require__(57); -var Browser = __webpack_require__(80); -var CanvasPool = __webpack_require__(22); +/** + * @typedef {object} Phaser.Plugins.DefaultPlugins + * + * @property {array} Global - These are the Global Managers that are created by the Phaser.Game instance. + * @property {array} CoreScene - These are the core plugins that are installed into every Scene.Systems instance, no matter what. + * @property {array} DefaultScene - These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + */ + +var DefaultPlugins = { + + /** + * These are the Global Managers that are created by the Phaser.Game instance. + * They are referenced from Scene.Systems so that plugins can use them. + * + * @name Phaser.Plugins.Global + * @type {array} + * @since 3.0.0 + */ + Global: [ + + 'game', + 'anims', + 'cache', + 'plugins', + 'registry', + 'scale', + 'sound', + 'textures' + + ], + + /** + * These are the core plugins that are installed into every Scene.Systems instance, no matter what. + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are created in the order in which they appear in this array and EventEmitter is always first. + * + * @name Phaser.Plugins.CoreScene + * @type {array} + * @since 3.0.0 + */ + CoreScene: [ + + 'EventEmitter', + + 'CameraManager', + 'GameObjectCreator', + 'GameObjectFactory', + 'ScenePlugin', + 'DisplayList', + 'UpdateList' + + ], + + /** + * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. + * + * You can elect not to have these plugins by either creating a DefaultPlugins object as part + * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array + * and building your own bundle. + * + * They are optionally exposed in the Scene as well (see the InjectionMap for details) + * + * They are always created in the order in which they appear in the array. + * + * @name Phaser.Plugins.DefaultScene + * @type {array} + * @since 3.0.0 + */ + DefaultScene: [ + + 'Clock', + 'DataManagerPlugin', + 'InputPlugin', + 'Loader', + 'TweenManager', + 'LightsPlugin' + + ] + +}; + +if (false) +{} + +if (false) +{} + +module.exports = DefaultPlugins; + + +/***/ }), +/* 168 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(92); +var Browser = __webpack_require__(118); +var CanvasPool = __webpack_require__(24); /** * Determines the features of the browser running this Phaser Game instance. @@ -27383,5399 +41429,7 @@ module.exports = init(); /***/ }), -/* 121 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} Phaser.Plugins.DefaultPlugins - * - * @property {array} Global - These are the Global Managers that are created by the Phaser.Game instance. - * @property {array} CoreScene - These are the core plugins that are installed into every Scene.Systems instance, no matter what. - * @property {array} DefaultScene - These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - */ - -var DefaultPlugins = { - - /** - * These are the Global Managers that are created by the Phaser.Game instance. - * They are referenced from Scene.Systems so that plugins can use them. - * - * @name Phaser.Plugins.Global - * @type {array} - * @since 3.0.0 - */ - Global: [ - - 'anims', - 'cache', - 'plugins', - 'registry', - 'sound', - 'textures' - - ], - - /** - * These are the core plugins that are installed into every Scene.Systems instance, no matter what. - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are created in the order in which they appear in this array and EventEmitter is always first. - * - * @name Phaser.Plugins.CoreScene - * @type {array} - * @since 3.0.0 - */ - CoreScene: [ - - 'EventEmitter', - - 'CameraManager', - 'GameObjectCreator', - 'GameObjectFactory', - 'ScenePlugin', - 'DisplayList', - 'UpdateList' - - ], - - /** - * These plugins are created in Scene.Systems in addition to the CoreScenePlugins. - * - * You can elect not to have these plugins by either creating a DefaultPlugins object as part - * of the Game Config, by creating a Plugins object as part of a Scene Config, or by modifying this array - * and building your own bundle. - * - * They are optionally exposed in the Scene as well (see the InjectionMap for details) - * - * They are always created in the order in which they appear in the array. - * - * @name Phaser.Plugins.DefaultScene - * @type {array} - * @since 3.0.0 - */ - DefaultScene: [ - - 'CameraManager3D', - 'Clock', - 'DataManagerPlugin', - 'InputPlugin', - 'Loader', - 'TweenManager', - 'LightsPlugin' - - ] - -}; - -module.exports = DefaultPlugins; - - -/***/ }), -/* 122 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates a linear (interpolation) value over t. - * - * @function Phaser.Math.Linear - * @since 3.0.0 - * - * @param {number} p0 - The first point. - * @param {number} p1 - The second point. - * @param {float} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. - * - * @return {number} The step t% of the way between p0 and p1. - */ -var Linear = function (p0, p1, t) -{ - return (p1 - p0) * t + p0; -}; - -module.exports = Linear; - - -/***/ }), -/* 123 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var Effects = __webpack_require__(204); -var EventEmitter = __webpack_require__(9); -var Linear = __webpack_require__(122); -var Rectangle = __webpack_require__(14); -var TransformMatrix = __webpack_require__(64); -var ValueToColor = __webpack_require__(132); -var Vector2 = __webpack_require__(6); - -/** - * @typedef {object} JSONCameraBounds - * @property {number} x - The horizontal position of camera - * @property {number} y - The vertical position of camera - * @property {number} width - The width size of camera - * @property {number} height - The height size of camera - */ - -/** - * @typedef {object} JSONCamera - * - * @property {string} name - The name of the camera - * @property {number} x - The horizontal position of camera - * @property {number} y - The vertical position of camera - * @property {number} width - The width size of camera - * @property {number} height - The height size of camera - * @property {number} zoom - The zoom of camera - * @property {number} rotation - The rotation of camera - * @property {boolean} roundPixels - The round pixels st status of camera - * @property {number} scrollX - The horizontal scroll of camera - * @property {number} scrollY - The vertical scroll of camera - * @property {string} backgroundColor - The background color of camera - * @property {(JSONCameraBounds|undefined)} [bounds] - The bounds of camera - */ - -/** - * @classdesc - * A Camera. - * - * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, - * and can be positioned, rotated, zoomed and scrolled accordingly. - * - * A Camera consists of two elements: The viewport and the scroll values. - * - * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are - * created the same size as your game, but their position and size can be set to anything. This means if you - * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, - * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). - * - * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this - * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the - * viewport, and changing the viewport has no impact on the scrolling. - * - * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, - * allowing you to filter Game Objects out on a per-Camera basis. - * - * A Camera also has built-in special effects including Fade, Flash and Camera Shake. - * - * @class Camera - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Cameras.Scene2D - * @constructor - * @since 3.0.0 - * - * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. - * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. - * @param {number} width - The width of the Camera, in pixels. - * @param {number} height - The height of the Camera, in pixels. - */ -var Camera = new Class({ - - Extends: EventEmitter, - - initialize: - - function Camera (x, y, width, height) - { - EventEmitter.call(this); - - /** - * A reference to the Scene this camera belongs to. - * - * @name Phaser.Cameras.Scene2D.Camera#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene; - - /** - * The name of the Camera. This is left empty for your own use. - * - * @name Phaser.Cameras.Scene2D.Camera#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The x position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the Camera, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The width of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#width - * @type {number} - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the Camera, in pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#height - * @type {number} - * @since 3.0.0 - */ - this.height = height; - - /** - * Should this camera round its pixel values to integers? - * - * @name Phaser.Cameras.Scene2D.Camera#roundPixels - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.roundPixels = false; - - /** - * Is this Camera visible or not? - * - * A visible camera will render and perform input tests. - * An invisible camera will not render anything and will skip input tests. - * - * @name Phaser.Cameras.Scene2D.Camera#visible - * @type {boolean} - * @default true - * @since 3.10.0 - */ - this.visible = true; - - /** - * Is this Camera using a bounds to restrict scrolling movement? - * Set this property along with the bounds via `Camera.setBounds`. - * - * @name Phaser.Cameras.Scene2D.Camera#useBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useBounds = false; - - /** - * The bounds the camera is restrained to during scrolling. - * - * @name Phaser.Cameras.Scene2D.Camera#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); - - /** - * Does this Camera allow the Game Objects it renders to receive input events? - * - * @name Phaser.Cameras.Scene2D.Camera#inputEnabled - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.inputEnabled = true; - - /** - * The horizontal scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * The vertical scroll position of this camera. - * Optionally restricted via the Camera bounds. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * The Camera zoom value. Change this value to zoom in, or out of, a Scene. - * Set to 1 to return to the default zoom level. - * - * @name Phaser.Cameras.Scene2D.Camera#zoom - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.zoom = 1; - - /** - * The rotation of the Camera. This influences the rendering of all Game Objects visible by this camera. - * - * @name Phaser.Cameras.Scene2D.Camera#rotation - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotation = 0; - - /** - * A local transform matrix used for internal calculations. - * - * @name Phaser.Cameras.Scene2D.Camera#matrix - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @since 3.0.0 - */ - this.matrix = new TransformMatrix(1, 0, 0, 1, 0, 0); - - /** - * Does this Camera have a transparent background? - * - * @name Phaser.Cameras.Scene2D.Camera#transparent - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.transparent = true; - - /** - * The background color of this Camera. Only used if `transparent` is `false`. - * - * @name Phaser.Cameras.Scene2D.Camera#backgroundColor - * @type {Phaser.Display.Color} - * @since 3.0.0 - */ - this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); - - /** - * The Camera Fade effect handler. - * To fade this camera see the `Camera.fade` methods. - * - * @name Phaser.Cameras.Scene2D.Camera#fadeEffect - * @type {Phaser.Cameras.Scene2D.Effects.Fade} - * @since 3.5.0 - */ - this.fadeEffect = new Effects.Fade(this); - - /** - * The Camera Flash effect handler. - * To flash this camera see the `Camera.flash` method. - * - * @name Phaser.Cameras.Scene2D.Camera#flashEffect - * @type {Phaser.Cameras.Scene2D.Effects.Flash} - * @since 3.5.0 - */ - this.flashEffect = new Effects.Flash(this); - - /** - * The Camera Shake effect handler. - * To shake this camera see the `Camera.shake` method. - * - * @name Phaser.Cameras.Scene2D.Camera#shakeEffect - * @type {Phaser.Cameras.Scene2D.Effects.Shake} - * @since 3.5.0 - */ - this.shakeEffect = new Effects.Shake(this); - - /** - * Should the camera cull Game Objects before checking them for input hit tests? - * In some special cases it may be beneficial to disable this. - * - * @name Phaser.Cameras.Scene2D.Camera#disableCull - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.disableCull = false; - - /** - * A temporary array of culled objects. - * - * @name Phaser.Cameras.Scene2D.Camera#culledObjects - * @type {Phaser.GameObjects.GameObject[]} - * @default [] - * @since 3.0.0 - */ - this.culledObjects = []; - - /** - * The linear interpolation value to use when following a target. - * - * Can also be set via `setLerp` or as part of the `startFollow` call. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - * - * @name Phaser.Cameras.Scene2D.Camera#lerp - * @type {Phaser.Math.Vector2} - * @since 3.9.0 - */ - this.lerp = new Vector2(1, 1); - - /** - * The values stored in this property are subtracted from the Camera targets position, allowing you to - * offset the camera from the actual target x/y coordinates by this amount. - * Can also be set via `setFollowOffset` or as part of the `startFollow` call. - * - * @name Phaser.Cameras.Scene2D.Camera#followOffset - * @type {Phaser.Math.Vector2} - * @since 3.9.0 - */ - this.followOffset = new Vector2(); - - /** - * Internal follow target reference. - * - * @name Phaser.Cameras.Scene2D.Camera#_follow - * @type {?any} - * @private - * @default null - * @since 3.0.0 - */ - this._follow = null; - - /** - * Internal camera ID. Assigned by the Camera Manager and used in the camera pool. - * - * @name Phaser.Cameras.Scene2D.Camera#_id - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._id = 0; - }, - - /** - * Scrolls the Camera so that it is looking at the center of the Camera Bounds (if previously enabled) - * - * @method Phaser.Cameras.Scene2D.Camera#centerToBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToBounds: function () - { - if (this.useBounds) - { - this.scrollX = (this._bounds.width * 0.5) - (this.width * 0.5); - this.scrollY = (this._bounds.height * 0.5) - (this.height * 0.5); - } - - return this; - }, - - /** - * Scrolls the Camera so that it is re-centered based on its viewport size. - * - * @method Phaser.Cameras.Scene2D.Camera#centerToSize - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToSize: function () - { - this.scrollX = this.width * 0.5; - this.scrollY = this.height * 0.5; - - return this; - }, - - /** - * Takes an array of Game Objects and returns a new array featuring only those objects - * visible by this camera. - * - * @method Phaser.Cameras.Scene2D.Camera#cull - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] - * - * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. - * - * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. - */ - cull: function (renderableObjects) - { - if (this.disableCull) - { - return renderableObjects; - } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return renderableObjects; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var culledObjects = this.culledObjects; - var length = renderableObjects.length; - - determinant = 1 / determinant; - - culledObjects.length = 0; - - for (var index = 0; index < length; ++index) - { - var object = renderableObjects[index]; - - if (!object.hasOwnProperty('width') || object.parentContainer) - { - culledObjects.push(object); - continue; - } - - var objectW = object.width; - var objectH = object.height; - var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); - var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); - var tx = (objectX * mva + objectY * mvc + mve); - var ty = (objectX * mvb + objectY * mvd + mvf); - var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); - var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); - var cullW = cameraW + objectW; - var cullH = cameraH + objectH; - - if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH && - tw > -objectW && th > -objectH && tw < cullW && th < cullH) - { - culledObjects.push(object); - } - } - - return culledObjects; - }, - - /** - * Fades the Camera in from the given color over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#fadeIn - * @since 3.3.0 - * - * @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 {function} [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} This Camera instance. - */ - fadeIn: function (duration, red, green, blue, callback, context) - { - return this.fadeEffect.start(false, duration, red, green, blue, true, callback, context); - }, - - /** - * Fades the Camera out to the given color over the duration specified. - * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. - * - * @method Phaser.Cameras.Scene2D.Camera#fadeOut - * @since 3.3.0 - * - * @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 {function} [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} This Camera instance. - */ - fadeOut: function (duration, red, green, blue, callback, context) - { - return this.fadeEffect.start(true, duration, red, green, blue, true, callback, context); - }, - - /** - * Fades the Camera from the given color to transparent over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#fadeFrom - * @since 3.5.0 - * - * @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 {function} [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} This Camera instance. - */ - fadeFrom: function (duration, red, green, blue, force, callback, context) - { - return this.fadeEffect.start(false, duration, red, green, blue, force, callback, context); - }, - - /** - * Fades the Camera from transparent to the given color over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#fade - * @since 3.0.0 - * - * @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 {function} [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} This Camera instance. - */ - fade: function (duration, red, green, blue, force, callback, context) - { - return this.fadeEffect.start(true, duration, red, green, blue, force, callback, context); - }, - - /** - * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#flash - * @since 3.0.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 {function} [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} This Camera instance. - */ - flash: function (duration, red, green, blue, force, callback, context) - { - return this.flashEffect.start(duration, red, green, blue, force, callback, context); - }, - - /** - * Shakes the Camera by the given intensity over the duration specified. - * - * @method Phaser.Cameras.Scene2D.Camera#shake - * @since 3.0.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 {function} [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} This Camera instance. - */ - shake: function (duration, intensity, force, callback, context) - { - return this.shakeEffect.start(duration, intensity, force, callback, context); - }, - - /** - * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. - * You can optionally provide a Vector2, or similar object, to store the results in. - * - * @method Phaser.Cameras.Scene2D.Camera#getWorldPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [output,$return] - * - * @param {number} x - The x position to convert to world space. - * @param {number} y - The y position to convert to world space. - * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. - */ - getWorldPoint: function (x, y, output) - { - if (output === undefined) { output = new Vector2(); } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - output.x = x; - output.y = y; - - return output; - } - - determinant = 1 / determinant; - - var ima = mvd * determinant; - var imb = -mvb * determinant; - var imc = -mvc * determinant; - var imd = mva * determinant; - var ime = (mvc * mvf - mvd * mve) * determinant; - var imf = (mvb * mve - mva * mvf) * determinant; - - var c = Math.cos(this.rotation); - var s = Math.sin(this.rotation); - - var zoom = this.zoom; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - - var sx = x + ((scrollX * c - scrollY * s) * zoom); - var sy = y + ((scrollX * s + scrollY * c) * zoom); - - /* Apply transform to point */ - output.x = (sx * ima + sy * imc + ime); - output.y = (sx * imb + sy * imd + imf); - - return output; - }, - - /** - * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings - * so that they are ignored by this Camera. This means they will not be rendered by this Camera. - * - * @method Phaser.Cameras.Scene2D.Camera#ignore - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObject - The Game Object, or array of Game Objects, to be ignored by this Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - ignore: function (gameObject) - { - var id = this._id; - - if (Array.isArray(gameObject)) - { - for (var i = 0; i < gameObject.length; i++) - { - gameObject[i].cameraFilter |= id; - } - } - else - { - gameObject.cameraFilter |= id; - } - - return this; - }, - - /** - * Internal preRender step. - * - * @method Phaser.Cameras.Scene2D.Camera#preRender - * @protected - * @since 3.0.0 - * - * @param {number} baseScale - The base scale, as set in the Camera Manager. - * @param {number} resolution - The game resolution. - */ - preRender: function (baseScale, resolution) - { - var width = this.width; - var height = this.height; - var zoom = this.zoom * baseScale; - var matrix = this.matrix; - var originX = width / 2; - var originY = height / 2; - var follow = this._follow; - - if (follow) - { - this.scrollX = Linear(this.scrollX, (follow.x - this.followOffset.x) - originX, this.lerp.x) / zoom; - this.scrollY = Linear(this.scrollY, (follow.y - this.followOffset.y) - originY, this.lerp.y) / zoom; - } - - if (this.useBounds) - { - var bounds = this._bounds; - - var bw = Math.max(0, bounds.right - width); - var bh = Math.max(0, bounds.bottom - height); - - if (this.scrollX < bounds.x) - { - this.scrollX = bounds.x; - } - else if (this.scrollX > bw) - { - this.scrollX = bw; - } - - if (this.scrollY < bounds.y) - { - this.scrollY = bounds.y; - } - else if (this.scrollY > bh) - { - this.scrollY = bh; - } - } - - if (this.roundPixels) - { - this.scrollX = Math.round(this.scrollX); - this.scrollY = Math.round(this.scrollY); - } - - matrix.loadIdentity(); - matrix.scale(resolution, resolution); - matrix.translate(this.x + originX, this.y + originY); - matrix.rotate(this.rotation); - matrix.scale(zoom, zoom); - matrix.translate(-originX, -originY); - - this.shakeEffect.preRender(); - }, - - /** - * If this Camera has previously had movement bounds set on it, this will remove them. - * - * @method Phaser.Cameras.Scene2D.Camera#removeBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - removeBounds: function () - { - this.useBounds = false; - - this._bounds.setEmpty(); - - return this; - }, - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setAngle - * @since 3.0.0 - * - * @param {number} [value=0] - The cameras angle of rotation, given in degrees. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setAngle: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = DegToRad(value); - - return this; - }, - - /** - * Sets the linear interpolation value to use when following a target. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - * - * @method Phaser.Cameras.Scene2D.Camera#setLerp - * @since 3.9.0 - * - * @param {number} [x=1] - The amount added to the horizontal linear interpolation of the follow target. - * @param {number} [y=1] - The amount added to the vertical linear interpolation of the follow target. - * - * @return {this} This Camera instance. - */ - setLerp: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.lerp.set(x, y); - - return this; - }, - - /** - * Sets the horizontal and vertical offset of the camera from its follow target. - * The values are subtracted from the targets position during the Cameras update step. - * - * @method Phaser.Cameras.Scene2D.Camera#setFollowOffset - * @since 3.9.0 - * - * @param {number} [x=0] - The horizontal offset from the camera follow target.x position. - * @param {number} [y=0] - The vertical offset from the camera follow target.y position. - * - * @return {this} This Camera instance. - */ - setFollowOffset: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - this.followOffset.set(x, y); - - return this; - }, - - /** - * Sets the background color for this Camera. - * - * By default a Camera has a transparent background but it can be given a solid color, with any level - * of transparency, via this method. - * - * The color value can be specified using CSS color notation, hex or numbers. - * - * @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor - * @since 3.0.0 - * - * @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBackgroundColor: function (color) - { - if (color === undefined) { color = 'rgba(0,0,0,0)'; } - - this.backgroundColor = ValueToColor(color); - - this.transparent = (this.backgroundColor.alpha === 0); - - return this; - }, - - /** - * Set the world bounds for this Camera. - * - * A Camera bounds controls where the camera can scroll to within the world. It does not limit - * rendering of the camera, or placement of the viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setBounds - * @since 3.0.0 - * - * @param {integer} x - The top-left x coordinate of the bounds. - * @param {integer} y - The top-left y coordinate of the bounds. - * @param {integer} width - The width of the bounds, in pixels. - * @param {integer} height - The height of the bounds, in pixels. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBounds: function (x, y, width, height) - { - this._bounds.setTo(x, y, width, height); - - this.useBounds = true; - - return this; - }, - - /** - * Sets the name of this Camera. - * This value is for your own use and isn't used internally. - * - * @method Phaser.Cameras.Scene2D.Camera#setName - * @since 3.0.0 - * - * @param {string} [value=''] - The name of the Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setName: function (value) - { - if (value === undefined) { value = ''; } - - this.name = value; - - return this; - }, - - /** - * Set the position of the Camera viewport within the game. - * - * This does not change where the camera is 'looking'. See `setScroll` to control that. - * - * @method Phaser.Cameras.Scene2D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the Camera viewport. - * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setRotation - * @since 3.0.0 - * - * @param {number} [value=0] - The rotation of the Camera, in radians. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRotation: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = value; - - return this; - }, - - /** - * Should the Camera round pixel values to whole integers when scrolling? - * In some types of game this is required to prevent sub-pixel aliasing. - * - * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels - * @since 3.0.0 - * - * @param {boolean} value - `true` to round Camera pixels, `false` to not. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRoundPixels: function (value) - { - this.roundPixels = value; - - return this; - }, - - /** - * Sets the Scene the Camera is bound to. - * - * @method Phaser.Cameras.Scene2D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene the camera is bound to. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * Set the position of where the Camera is looking within the game. - * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. - * Use this method, or the scroll properties, to move your camera around the game world. - * - * This does not change where the camera viewport is placed. See `setPosition` to control that. - * - * @method Phaser.Cameras.Scene2D.Camera#setScroll - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the Camera in the game world. - * @param {number} [y=x] - The y coordinate of the Camera in the game world. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScroll: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollX = x; - this.scrollY = y; - - return this; - }, - - /** - * Set the size of the Camera viewport. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setSize - * @since 3.0.0 - * - * @param {integer} width - The width of the Camera viewport. - * @param {integer} [height=width] - The height of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * This method sets the position and size of the Camera viewport in a single call. - * - * If you're trying to change where the Camera is looking at in your game, then see - * the method `Camera.setScroll` instead. This method is for changing the viewport - * itself, not what the camera can see. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the Camera viewport. - * @param {number} y - The top-left y coordinate of the Camera viewport. - * @param {integer} width - The width of the Camera viewport. - * @param {integer} [height=width] - The height of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setViewport: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * Set the zoom value of the Camera. - * - * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. - * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. - * - * A value of 1 means 'no zoom' and is the default. - * - * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setZoom - * @since 3.0.0 - * - * @param {float} [value=1] - The zoom value of the Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setZoom: function (value) - { - if (value === undefined) { value = 1; } - - this.zoom = value; - - return this; - }, - - /** - * Sets the visibility of this Camera. - * - * An invisible Camera will skip rendering and input tests of everything it can see. - * - * @method Phaser.Cameras.Scene2D.Camera#setVisible - * @since 3.10.0 - * - * @param {boolean} value - The visible state of the Camera. - * - * @return {this} This Camera instance. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * Sets the Camera to follow a Game Object. - * - * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object - * in its center. - * - * You can set the linear interpolation value used in the follow code. - * Use low lerp values (such as 0.1) to automatically smooth the camera motion. - * - * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel - * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to - * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom - * value on the camera. So be sure to keep the camera zoom to integers. - * - * @method Phaser.Cameras.Scene2D.Camera#startFollow - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. - * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? - * @param {float} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. - * @param {float} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. - * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. - * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. - * - * @return {this} This Camera instance. - */ - startFollow: function (target, roundPixels, lerpX, lerpY, offsetX, offsetY) - { - if (roundPixels === undefined) { roundPixels = false; } - if (lerpX === undefined) { lerpX = 1; } - if (lerpY === undefined) { lerpY = lerpX; } - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = offsetX; } - - this._follow = target; - - this.roundPixels = roundPixels; - - lerpX = Clamp(lerpX, 0, 1); - lerpY = Clamp(lerpY, 0, 1); - - this.lerp.set(lerpX, lerpY); - - this.followOffset.set(offsetX, offsetY); - - // Move the camera there immediately, to avoid a large lerp during preUpdate - var zoom = this.zoom; - var originX = this.width / 2; - var originY = this.height / 2; - - this.scrollX = (target.x - offsetX - originX) / zoom; - this.scrollY = (target.y - offsetY - originY) / zoom; - - return this; - }, - - /** - * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. - * - * @method Phaser.Cameras.Scene2D.Camera#stopFollow - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - stopFollow: function () - { - this._follow = null; - - return this; - }, - - /** - * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. - * - * @method Phaser.Cameras.Scene2D.Camera#toJSON - * @since 3.0.0 - * - * @return {JSONCamera} A well-formed object suitable for conversion to JSON. - */ - toJSON: function () - { - var output = { - name: this.name, - x: this.x, - y: this.y, - width: this.width, - height: this.height, - zoom: this.zoom, - rotation: this.rotation, - roundPixels: this.roundPixels, - scrollX: this.scrollX, - scrollY: this.scrollY, - backgroundColor: this.backgroundColor.rgba - }; - - if (this.useBounds) - { - output['bounds'] = { - x: this._bounds.x, - y: this._bounds.y, - width: this._bounds.width, - height: this._bounds.height - }; - } - - return output; - }, - - /** - * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to - * remove the fade. - * - * @method Phaser.Cameras.Scene2D.Camera#resetFX - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - resetFX: function () - { - this.shakeEffect.reset(); - this.flashEffect.reset(); - this.fadeEffect.reset(); - - return this; - }, - - /** - * Internal method called automatically by the Camera Manager. - * - * @method Phaser.Cameras.Scene2D.Camera#update - * @protected - * @since 3.0.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.visible) - { - this.shakeEffect.update(time, delta); - this.flashEffect.update(time, delta); - this.fadeEffect.update(time, delta); - } - }, - - /** - * This event is fired when a camera is destroyed by the Camera Manager. - * - * @event CameraDestroyEvent - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that was destroyed. - */ - - /** - * Destroys this Camera instance. You rarely need to call this directly. - * - * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as - * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. - * - * @method Phaser.Cameras.Scene2D.Camera#destroy - * @fires CameraDestroyEvent - * @since 3.0.0 - */ - destroy: function () - { - this.emit('cameradestroy', this); - - this.removeAllListeners(); - - this.resetFX(); - - this.matrix.destroy(); - - this.culledObjects = []; - - this._follow = null; - - this._bounds = null; - - this.scene = null; - }, - - /** - * The x position of the center of the Camera's viewport, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#centerX - * @type {number} - * @readOnly - * @since 3.10.0 - */ - centerX: { - - get: function () - { - return this.x + (0.5 * this.width); - } - - }, - - /** - * The y position of the center of the Camera's viewport, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#centerY - * @type {number} - * @readOnly - * @since 3.10.0 - */ - centerY: { - - get: function () - { - return this.y + (0.5 * this.height); - } - - } - -}); - -module.exports = Camera; - - -/***/ }), -/* 124 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback EachMapCallback - * @generic E - [entry] - * - * @param {string} key - [description] - * @param {*} entry - [description] - * - * @return {?boolean} [description] - */ - -/** - * @classdesc - * The keys of a Map can be arbitrary values. - * var map = new Map([ - * [ 1, 'one' ], - * [ 2, 'two' ], - * [ 3, 'three' ] - * ]); - * - * @class Map - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic K - * @generic V - * @genericUse {V[]} - [elements] - * - * @param {Array.<*>} elements - [description] - */ -var Map = new Class({ - - initialize: - - function Map (elements) - { - /** - * [description] - * - * @genericUse {Object.} - [$type] - * - * @name Phaser.Structs.Map#entries - * @type {Object.} - * @default {} - * @since 3.0.0 - */ - this.entries = {}; - - /** - * [description] - * - * @name Phaser.Structs.Map#size - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.size = 0; - - if (Array.isArray(elements)) - { - for (var i = 0; i < elements.length; i++) - { - this.set(elements[i][0], elements[i][1]); - } - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#set - * @since 3.0.0 - * - * @genericUse {K} - [key] - * @genericUse {V} - [value] - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @param {string} key - [description] - * @param {*} value - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - set: function (key, value) - { - if (!this.has(key)) - { - this.entries[key] = value; - this.size++; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#get - * @since 3.0.0 - * - * @genericUse {K} - [key] - * @genericUse {V} - [$return] - * - * @param {string} key - [description] - * - * @return {*} [description] - */ - get: function (key) - { - if (this.has(key)) - { - return this.entries[key]; - } - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#getArray - * @since 3.0.0 - * - * @genericUse {V[]} - [$return] - * - * @return {Array.<*>} [description] - */ - getArray: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#has - * @since 3.0.0 - * - * @genericUse {K} - [key] - * - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (key) - { - return (this.entries.hasOwnProperty(key)); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#delete - * @since 3.0.0 - * - * @genericUse {K} - [key] - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @param {string} key - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - delete: function (key) - { - if (this.has(key)) - { - delete this.entries[key]; - this.size--; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#clear - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @return {Phaser.Structs.Map} This Map object. - */ - clear: function () - { - Object.keys(this.entries).forEach(function (prop) - { - delete this.entries[prop]; - - }, this); - - this.size = 0; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#keys - * @since 3.0.0 - * - * @genericUse {K[]} - [$return] - * - * @return {string[]} [description] - */ - keys: function () - { - return Object.keys(this.entries); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#values - * @since 3.0.0 - * - * @genericUse {V[]} - [$return] - * - * @return {Array.<*>} [description] - */ - values: function () - { - var output = []; - var entries = this.entries; - - for (var key in entries) - { - output.push(entries[key]); - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#dump - * @since 3.0.0 - */ - dump: function () - { - var entries = this.entries; - - // eslint-disable-next-line no-console - console.group('Map'); - - for (var key in entries) - { - console.log(key, entries[key]); - } - - // eslint-disable-next-line no-console - console.groupEnd(); - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#each - * @since 3.0.0 - * - * @genericUse {EachMapCallback.} - [callback] - * @genericUse {Phaser.Structs.Map.} - [$return] - * - * @param {EachMapCallback} callback - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - each: function (callback) - { - var entries = this.entries; - - for (var key in entries) - { - if (callback(key, entries[key]) === false) - { - break; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.Map#contains - * @since 3.0.0 - * - * @genericUse {V} - [value] - * - * @param {*} value - [description] - * - * @return {boolean} [description] - */ - contains: function (value) - { - var entries = this.entries; - - for (var key in entries) - { - if (entries[key] === value) - { - return true; - } - } - - return false; - }, - - /** - * Merges all new keys from the given Map into this one - * If it encounters a key that already exists it will be skipped - * unless override = true. - * - * @method Phaser.Structs.Map#merge - * @since 3.0.0 - * - * @genericUse {Phaser.Structs.Map.} - [map,$return] - * - * @param {Phaser.Structs.Map} map - [description] - * @param {boolean} [override=false] - [description] - * - * @return {Phaser.Structs.Map} This Map object. - */ - merge: function (map, override) - { - if (override === undefined) { override = false; } - - var local = this.entries; - var source = map.entries; - - for (var key in source) - { - if (local.hasOwnProperty(key) && override) - { - local[key] = source[key]; - } - else - { - this.set(key, source[key]); - } - } - - return this; - } - -}); - -module.exports = Map; - - -/***/ }), -/* 125 */ -/***/ (function(module, exports) { - -/** -* The `Matter.Bounds` module contains methods for creating and manipulating axis-aligned bounding boxes (AABB). -* -* @class Bounds -*/ - -var Bounds = {}; - -module.exports = Bounds; - -(function() { - - /** - * Creates a new axis-aligned bounding box (AABB) for the given vertices. - * @method create - * @param {vertices} vertices - * @return {bounds} A new bounds object - */ - Bounds.create = function(vertices) { - var bounds = { - min: { x: 0, y: 0 }, - max: { x: 0, y: 0 } - }; - - if (vertices) - Bounds.update(bounds, vertices); - - return bounds; - }; - - /** - * Updates bounds using the given vertices and extends the bounds given a velocity. - * @method update - * @param {bounds} bounds - * @param {vertices} vertices - * @param {vector} velocity - */ - Bounds.update = function(bounds, vertices, velocity) { - bounds.min.x = Infinity; - bounds.max.x = -Infinity; - bounds.min.y = Infinity; - bounds.max.y = -Infinity; - - for (var i = 0; i < vertices.length; i++) { - var vertex = vertices[i]; - if (vertex.x > bounds.max.x) bounds.max.x = vertex.x; - if (vertex.x < bounds.min.x) bounds.min.x = vertex.x; - if (vertex.y > bounds.max.y) bounds.max.y = vertex.y; - if (vertex.y < bounds.min.y) bounds.min.y = vertex.y; - } - - if (velocity) { - if (velocity.x > 0) { - bounds.max.x += velocity.x; - } else { - bounds.min.x += velocity.x; - } - - if (velocity.y > 0) { - bounds.max.y += velocity.y; - } else { - bounds.min.y += velocity.y; - } - } - }; - - /** - * Returns true if the bounds contains the given point. - * @method contains - * @param {bounds} bounds - * @param {vector} point - * @return {boolean} True if the bounds contain the point, otherwise false - */ - Bounds.contains = function(bounds, point) { - return point.x >= bounds.min.x && point.x <= bounds.max.x - && point.y >= bounds.min.y && point.y <= bounds.max.y; - }; - - /** - * Returns true if the two bounds intersect. - * @method overlaps - * @param {bounds} boundsA - * @param {bounds} boundsB - * @return {boolean} True if the bounds overlap, otherwise false - */ - Bounds.overlaps = function(boundsA, boundsB) { - return (boundsA.min.x <= boundsB.max.x && boundsA.max.x >= boundsB.min.x - && boundsA.max.y >= boundsB.min.y && boundsA.min.y <= boundsB.max.y); - }; - - /** - * Translates the bounds by the given vector. - * @method translate - * @param {bounds} bounds - * @param {vector} vector - */ - Bounds.translate = function(bounds, vector) { - bounds.min.x += vector.x; - bounds.max.x += vector.x; - bounds.min.y += vector.y; - bounds.max.y += vector.y; - }; - - /** - * Shifts the bounds to the given position. - * @method shift - * @param {bounds} bounds - * @param {vector} position - */ - Bounds.shift = function(bounds, position) { - var deltaX = bounds.max.x - bounds.min.x, - deltaY = bounds.max.y - bounds.min.y; - - bounds.min.x = position.x; - bounds.max.x = position.x + deltaX; - bounds.min.y = position.y; - bounds.max.y = position.y + deltaY; - }; - -})(); - - -/***/ }), -/* 126 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. -* A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. -* A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Vertices -*/ - -var Vertices = {}; - -module.exports = Vertices; - -var Vector = __webpack_require__(106); -var Common = __webpack_require__(41); - -(function() { - - /** - * Creates a new set of `Matter.Body` compatible vertices. - * The `points` argument accepts an array of `Matter.Vector` points orientated around the origin `(0, 0)`, for example: - * - * [{ x: 0, y: 0 }, { x: 25, y: 50 }, { x: 50, y: 0 }] - * - * The `Vertices.create` method returns a new array of vertices, which are similar to Matter.Vector objects, - * but with some additional references required for efficient collision detection routines. - * - * Vertices must be specified in clockwise order. - * - * Note that the `body` argument is not optional, a `Matter.Body` reference must be provided. - * - * @method create - * @param {vector[]} points - * @param {body} body - */ - Vertices.create = function(points, body) { - var vertices = []; - - for (var i = 0; i < points.length; i++) { - var point = points[i], - vertex = { - x: point.x, - y: point.y, - index: i, - body: body, - isInternal: false, - contact: null - }; - - vertex.contact = { - vertex: vertex, - normalImpulse: 0, - tangentImpulse: 0 - }; - - vertices.push(vertex); - } - - return vertices; - }; - - /** - * Parses a string containing ordered x y pairs separated by spaces (and optionally commas), - * into a `Matter.Vertices` object for the given `Matter.Body`. - * For parsing SVG paths, see `Svg.pathToVertices`. - * @method fromPath - * @param {string} path - * @param {body} body - * @return {vertices} vertices - */ - Vertices.fromPath = function(path, body) { - var pathPattern = /L?\s*([\-\d\.e]+)[\s,]*([\-\d\.e]+)*/ig, - points = []; - - path.replace(pathPattern, function(match, x, y) { - points.push({ x: parseFloat(x), y: parseFloat(y) }); - }); - - return Vertices.create(points, body); - }; - - /** - * Returns the centre (centroid) of the set of vertices. - * @method centre - * @param {vertices} vertices - * @return {vector} The centre point - */ - Vertices.centre = function(vertices) { - var area = Vertices.area(vertices, true), - centre = { x: 0, y: 0 }, - cross, - temp, - j; - - for (var i = 0; i < vertices.length; i++) { - j = (i + 1) % vertices.length; - cross = Vector.cross(vertices[i], vertices[j]); - temp = Vector.mult(Vector.add(vertices[i], vertices[j]), cross); - centre = Vector.add(centre, temp); - } - - return Vector.div(centre, 6 * area); - }; - - /** - * Returns the average (mean) of the set of vertices. - * @method mean - * @param {vertices} vertices - * @return {vector} The average point - */ - Vertices.mean = function(vertices) { - var average = { x: 0, y: 0 }; - - for (var i = 0; i < vertices.length; i++) { - average.x += vertices[i].x; - average.y += vertices[i].y; - } - - return Vector.div(average, vertices.length); - }; - - /** - * Returns the area of the set of vertices. - * @method area - * @param {vertices} vertices - * @param {bool} signed - * @return {number} The area - */ - Vertices.area = function(vertices, signed) { - var area = 0, - j = vertices.length - 1; - - for (var i = 0; i < vertices.length; i++) { - area += (vertices[j].x - vertices[i].x) * (vertices[j].y + vertices[i].y); - j = i; - } - - if (signed) - return area / 2; - - return Math.abs(area) / 2; - }; - - /** - * Returns the moment of inertia (second moment of area) of the set of vertices given the total mass. - * @method inertia - * @param {vertices} vertices - * @param {number} mass - * @return {number} The polygon's moment of inertia - */ - Vertices.inertia = function(vertices, mass) { - var numerator = 0, - denominator = 0, - v = vertices, - cross, - j; - - // find the polygon's moment of inertia, using second moment of area - // from equations at http://www.physicsforums.com/showthread.php?t=25293 - for (var n = 0; n < v.length; n++) { - j = (n + 1) % v.length; - cross = Math.abs(Vector.cross(v[j], v[n])); - numerator += cross * (Vector.dot(v[j], v[j]) + Vector.dot(v[j], v[n]) + Vector.dot(v[n], v[n])); - denominator += cross; - } - - return (mass / 6) * (numerator / denominator); - }; - - /** - * Translates the set of vertices in-place. - * @method translate - * @param {vertices} vertices - * @param {vector} vector - * @param {number} scalar - */ - Vertices.translate = function(vertices, vector, scalar) { - var i; - if (scalar) { - for (i = 0; i < vertices.length; i++) { - vertices[i].x += vector.x * scalar; - vertices[i].y += vector.y * scalar; - } - } else { - for (i = 0; i < vertices.length; i++) { - vertices[i].x += vector.x; - vertices[i].y += vector.y; - } - } - - return vertices; - }; - - /** - * Rotates the set of vertices in-place. - * @method rotate - * @param {vertices} vertices - * @param {number} angle - * @param {vector} point - */ - Vertices.rotate = function(vertices, angle, point) { - if (angle === 0) - return; - - var cos = Math.cos(angle), - sin = Math.sin(angle); - - for (var i = 0; i < vertices.length; i++) { - var vertice = vertices[i], - dx = vertice.x - point.x, - dy = vertice.y - point.y; - - vertice.x = point.x + (dx * cos - dy * sin); - vertice.y = point.y + (dx * sin + dy * cos); - } - - return vertices; - }; - - /** - * Returns `true` if the `point` is inside the set of `vertices`. - * @method contains - * @param {vertices} vertices - * @param {vector} point - * @return {boolean} True if the vertices contains point, otherwise false - */ - Vertices.contains = function(vertices, point) { - for (var i = 0; i < vertices.length; i++) { - var vertice = vertices[i], - nextVertice = vertices[(i + 1) % vertices.length]; - if ((point.x - vertice.x) * (nextVertice.y - vertice.y) + (point.y - vertice.y) * (vertice.x - nextVertice.x) > 0) { - return false; - } - } - - return true; - }; - - /** - * Scales the vertices from a point (default is centre) in-place. - * @method scale - * @param {vertices} vertices - * @param {number} scaleX - * @param {number} scaleY - * @param {vector} point - */ - Vertices.scale = function(vertices, scaleX, scaleY, point) { - if (scaleX === 1 && scaleY === 1) - return vertices; - - point = point || Vertices.centre(vertices); - - var vertex, - delta; - - for (var i = 0; i < vertices.length; i++) { - vertex = vertices[i]; - delta = Vector.sub(vertex, point); - vertices[i].x = point.x + delta.x * scaleX; - vertices[i].y = point.y + delta.y * scaleY; - } - - return vertices; - }; - - /** - * Chamfers a set of vertices by giving them rounded corners, returns a new set of vertices. - * The radius parameter is a single number or an array to specify the radius for each vertex. - * @method chamfer - * @param {vertices} vertices - * @param {number[]} radius - * @param {number} quality - * @param {number} qualityMin - * @param {number} qualityMax - */ - Vertices.chamfer = function(vertices, radius, quality, qualityMin, qualityMax) { - - if (typeof radius === 'number') { - radius = [radius]; - } else { - radius = radius || [8]; - } - - if (!radius.length) - radius = [radius]; - - // quality defaults to -1, which is auto - quality = (typeof quality !== 'undefined') ? quality : -1; - qualityMin = qualityMin || 2; - qualityMax = qualityMax || 14; - - var newVertices = []; - - for (var i = 0; i < vertices.length; i++) { - var prevVertex = vertices[i - 1 >= 0 ? i - 1 : vertices.length - 1], - vertex = vertices[i], - nextVertex = vertices[(i + 1) % vertices.length], - currentRadius = radius[i < radius.length ? i : radius.length - 1]; - - if (currentRadius === 0) { - newVertices.push(vertex); - continue; - } - - var prevNormal = Vector.normalise({ - x: vertex.y - prevVertex.y, - y: prevVertex.x - vertex.x - }); - - var nextNormal = Vector.normalise({ - x: nextVertex.y - vertex.y, - y: vertex.x - nextVertex.x - }); - - var diagonalRadius = Math.sqrt(2 * Math.pow(currentRadius, 2)), - radiusVector = Vector.mult(Common.clone(prevNormal), currentRadius), - midNormal = Vector.normalise(Vector.mult(Vector.add(prevNormal, nextNormal), 0.5)), - scaledVertex = Vector.sub(vertex, Vector.mult(midNormal, diagonalRadius)); - - var precision = quality; - - if (quality === -1) { - // automatically decide precision - precision = Math.pow(currentRadius, 0.32) * 1.75; - } - - precision = Common.clamp(precision, qualityMin, qualityMax); - - // use an even value for precision, more likely to reduce axes by using symmetry - if (precision % 2 === 1) - precision += 1; - - var alpha = Math.acos(Vector.dot(prevNormal, nextNormal)), - theta = alpha / precision; - - for (var j = 0; j < precision; j++) { - newVertices.push(Vector.add(Vector.rotate(radiusVector, theta * j), scaledVertex)); - } - } - - return newVertices; - }; - - /** - * Sorts the input vertices into clockwise order in place. - * @method clockwiseSort - * @param {vertices} vertices - * @return {vertices} vertices - */ - Vertices.clockwiseSort = function(vertices) { - var centre = Vertices.mean(vertices); - - vertices.sort(function(vertexA, vertexB) { - return Vector.angle(centre, vertexA) - Vector.angle(centre, vertexB); - }); - - return vertices; - }; - - /** - * Returns true if the vertices form a convex shape (vertices must be in clockwise order). - * @method isConvex - * @param {vertices} vertices - * @return {bool} `true` if the `vertices` are convex, `false` if not (or `null` if not computable). - */ - Vertices.isConvex = function(vertices) { - // http://paulbourke.net/geometry/polygonmesh/ - // Copyright (c) Paul Bourke (use permitted) - - var flag = 0, - n = vertices.length, - i, - j, - k, - z; - - if (n < 3) - return null; - - for (i = 0; i < n; i++) { - j = (i + 1) % n; - k = (i + 2) % n; - z = (vertices[j].x - vertices[i].x) * (vertices[k].y - vertices[j].y); - z -= (vertices[j].y - vertices[i].y) * (vertices[k].x - vertices[j].x); - - if (z < 0) { - flag |= 1; - } else if (z > 0) { - flag |= 2; - } - - if (flag === 3) { - return false; - } - } - - if (flag !== 0){ - return true; - } else { - return null; - } - }; - - /** - * Returns the convex hull of the input vertices as a new array of points. - * @method hull - * @param {vertices} vertices - * @return [vertex] vertices - */ - Vertices.hull = function(vertices) { - // http://geomalgorithms.com/a10-_hull-1.html - - var upper = [], - lower = [], - vertex, - i; - - // sort vertices on x-axis (y-axis for ties) - vertices = vertices.slice(0); - vertices.sort(function(vertexA, vertexB) { - var dx = vertexA.x - vertexB.x; - return dx !== 0 ? dx : vertexA.y - vertexB.y; - }); - - // build lower hull - for (i = 0; i < vertices.length; i += 1) { - vertex = vertices[i]; - - while (lower.length >= 2 - && Vector.cross3(lower[lower.length - 2], lower[lower.length - 1], vertex) <= 0) { - lower.pop(); - } - - lower.push(vertex); - } - - // build upper hull - for (i = vertices.length - 1; i >= 0; i -= 1) { - vertex = vertices[i]; - - while (upper.length >= 2 - && Vector.cross3(upper[upper.length - 2], upper[upper.length - 1], vertex) <= 0) { - upper.pop(); - } - - upper.push(vertex); - } - - // concatenation of the lower and upper hulls gives the convex hull - // omit last points because they are repeated at the beginning of the other list - upper.pop(); - lower.pop(); - - return upper.concat(lower); - }; - -})(); - - -/***/ }), -/* 127 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetAdvancedValue = __webpack_require__(10); - -/** - * Adds an Animation component to a Sprite and populates it based on the given config. - * - * @function Phaser.GameObjects.BuildGameObjectAnimation - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - The sprite to add an Animation component to. - * @param {object} config - The animation config. - * - * @return {Phaser.GameObjects.Sprite} The updated Sprite. - */ -var BuildGameObjectAnimation = function (sprite, config) -{ - var animConfig = GetAdvancedValue(config, 'anims', null); - - if (animConfig === null) - { - return sprite; - } - - if (typeof animConfig === 'string') - { - // { anims: 'key' } - sprite.anims.play(animConfig); - } - else if (typeof animConfig === 'object') - { - // { anims: { - // key: string - // startFrame: [string|integer] - // delay: [float] - // repeat: [integer] - // repeatDelay: [float] - // yoyo: [boolean] - // play: [boolean] - // delayedPlay: [boolean] - // } - // } - - var anims = sprite.anims; - - var key = GetAdvancedValue(animConfig, 'key', undefined); - var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); - - var delay = GetAdvancedValue(animConfig, 'delay', 0); - var repeat = GetAdvancedValue(animConfig, 'repeat', 0); - var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); - var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); - - var play = GetAdvancedValue(animConfig, 'play', false); - var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); - - anims.delay(delay); - anims.repeat(repeat); - anims.repeatDelay(repeatDelay); - anims.yoyo(yoyo); - - if (play) - { - anims.play(key, startFrame); - } - else if (delayedPlay > 0) - { - anims.delayedPlay(delayedPlay, key, startFrame); - } - else - { - anims.load(key); - } - } - - return sprite; -}; - -module.exports = BuildGameObjectAnimation; - - -/***/ }), -/* 128 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Extend = __webpack_require__(17); - -/** - * @classdesc - * A Frame is a section of a Texture. - * - * @class Frame - * @memberOf Phaser.Textures - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The Texture this Frame is a part of. - * @param {(integer|string)} name - The name of this Frame. The name is unique within the Texture. - * @param {integer} sourceIndex - The index of the TextureSource that this Frame is a part of. - * @param {number} x - The x coordinate of the top-left of this Frame. - * @param {number} y - The y coordinate of the top-left of this Frame. - * @param {number} width - The width of this Frame. - * @param {number} height - The height of this Frame. - */ -var Frame = new Class({ - - initialize: - - function Frame (texture, name, sourceIndex, x, y, width, height) - { - /** - * The Texture this Frame is a part of. - * - * @name Phaser.Textures.Frame#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - this.texture = texture; - - /** - * The name of this Frame. - * The name is unique within the Texture. - * - * @name Phaser.Textures.Frame#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The TextureSource this Frame is part of. - * - * @name Phaser.Textures.Frame#source - * @type {Phaser.Textures.TextureSource} - * @since 3.0.0 - */ - this.source = texture.source[sourceIndex]; - - /** - * The index of the TextureSource in the Texture sources array. - * - * @name Phaser.Textures.Frame#sourceIndex - * @type {integer} - * @since 3.0.0 - */ - this.sourceIndex = sourceIndex; - - /** - * X position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutX - * @type {integer} - * @since 3.0.0 - */ - this.cutX; - - /** - * Y position within the source image to cut from. - * - * @name Phaser.Textures.Frame#cutY - * @type {integer} - * @since 3.0.0 - */ - this.cutY; - - /** - * The width of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutWidth - * @type {integer} - * @since 3.0.0 - */ - this.cutWidth; - - /** - * The height of the area in the source image to cut. - * - * @name Phaser.Textures.Frame#cutHeight - * @type {integer} - * @since 3.0.0 - */ - this.cutHeight; - - /** - * The X rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#x - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The Y rendering offset of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#y - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The rendering width of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#width - * @type {integer} - * @since 3.0.0 - */ - this.width; - - /** - * The rendering height of this Frame, taking trim into account. - * - * @name Phaser.Textures.Frame#height - * @type {integer} - * @since 3.0.0 - */ - this.height; - - /** - * Half the width, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfWidth - * @type {integer} - * @since 3.0.0 - */ - this.halfWidth; - - /** - * Half the height, floored. - * Precalculated for the renderer. - * - * @name Phaser.Textures.Frame#halfHeight - * @type {integer} - * @since 3.0.0 - */ - this.halfHeight; - - /** - * The x center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerX - * @type {integer} - * @since 3.0.0 - */ - this.centerX; - - /** - * The y center of this frame, floored. - * - * @name Phaser.Textures.Frame#centerY - * @type {integer} - * @since 3.0.0 - */ - this.centerY; - - /** - * The horizontal pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotX = 0; - - /** - * The vertical pivot point of this Frame. - * - * @name Phaser.Textures.Frame#pivotY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pivotY = 0; - - /** - * Does this Frame have a custom pivot point? - * - * @name Phaser.Textures.Frame#customPivot - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customPivot = false; - - /** - * **CURRENTLY UNSUPPORTED** - * - * Is this frame is rotated or not in the Texture? - * Rotation allows you to use rotated frames in texture atlas packing. - * It has nothing to do with Sprite rotation. - * - * @name Phaser.Textures.Frame#rotated - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rotated = false; - - /** - * Over-rides the Renderer setting. - * -1 = use Renderer Setting - * 0 = No rounding - * 1 = Round - * - * @name Phaser.Textures.Frame#autoRound - * @type {integer} - * @default -1 - * @since 3.0.0 - */ - this.autoRound = -1; - - /** - * Any Frame specific custom data can be stored here. - * - * @name Phaser.Textures.Frame#customData - * @type {object} - * @since 3.0.0 - */ - this.customData = {}; - - /** - * The un-modified source frame, trim and UV data. - * - * @name Phaser.Textures.Frame#data - * @type {object} - * @private - * @since 3.0.0 - */ - this.data = { - cut: { - x: 0, - y: 0, - w: 0, - h: 0, - r: 0, - b: 0 - }, - trim: false, - sourceSize: { - w: 0, - h: 0 - }, - spriteSourceSize: { - x: 0, - y: 0, - w: 0, - h: 0 - }, - uvs: { - x0: 0, - y0: 0, - x1: 0, - y1: 0, - x2: 0, - y2: 0, - x3: 0, - y3: 0 - }, - radius: 0, - drawImage: { - sx: 0, - sy: 0, - sWidth: 0, - sHeight: 0, - dWidth: 0, - dHeight: 0 - } - }; - - this.setSize(width, height, x, y); - }, - - /** - * Sets the width, height, x and y of this Frame. - * - * This is called automatically by the constructor - * and should rarely be changed on-the-fly. - * - * @method Phaser.Textures.Frame#setSize - * @since 3.7.0 - * - * @param {integer} width - The width of the frame before being trimmed. - * @param {integer} height - The height of the frame before being trimmed. - * @param {integer} [x=0] - The x coordinate of the top-left of this Frame. - * @param {integer} [y=0] - The y coordinate of the top-left of this Frame. - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - setSize: function (width, height, x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - this.cutX = x; - this.cutY = y; - this.cutWidth = width; - this.cutHeight = height; - - this.width = width; - this.height = height; - - this.halfWidth = Math.floor(width * 0.5); - this.halfHeight = Math.floor(height * 0.5); - - this.centerX = Math.floor(width / 2); - this.centerY = Math.floor(height / 2); - - var data = this.data; - var cut = data.cut; - - cut.x = x; - cut.y = y; - cut.w = width; - cut.h = height; - cut.r = x + width; - cut.b = y + height; - - data.sourceSize.w = width; - data.sourceSize.h = height; - - data.spriteSourceSize.w = width; - data.spriteSourceSize.h = height; - - data.radius = 0.5 * Math.sqrt(width * width + height * height); - - var drawImage = data.drawImage; - - drawImage.sx = x; - drawImage.sy = y; - drawImage.sWidth = width; - drawImage.sHeight = height; - drawImage.dWidth = width; - drawImage.dHeight = height; - - return this.updateUVs(); - }, - - /** - * If the frame was trimmed when added to the Texture Atlas, this records the trim and source data. - * - * @method Phaser.Textures.Frame#setTrim - * @since 3.0.0 - * - * @param {number} actualWidth - The width of the frame before being trimmed. - * @param {number} actualHeight - The height of the frame before being trimmed. - * @param {number} destX - The destination X position of the trimmed frame for display. - * @param {number} destY - The destination Y position of the trimmed frame for display. - * @param {number} destWidth - The destination width of the trimmed frame for display. - * @param {number} destHeight - The destination height of the trimmed frame for display. - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight) - { - var data = this.data; - var ss = data.spriteSourceSize; - - // Store actual values - - data.trim = true; - - data.sourceSize.w = actualWidth; - data.sourceSize.h = actualHeight; - - ss.x = destX; - ss.y = destY; - ss.w = destWidth; - ss.h = destHeight; - - // Adjust properties - this.x = destX; - this.y = destY; - - this.width = destWidth; - this.height = destHeight; - - this.halfWidth = destWidth * 0.5; - this.halfHeight = destHeight * 0.5; - - this.centerX = Math.floor(destWidth / 2); - this.centerY = Math.floor(destHeight / 2); - - return this.updateUVs(); - }, - - /** - * Updates the internal WebGL UV cache and the drawImage cache. - * - * @method Phaser.Textures.Frame#updateUVs - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVs: function () - { - var cx = this.cutX; - var cy = this.cutY; - var cw = this.cutWidth; - var ch = this.cutHeight; - - // Canvas data - - var cd = this.data.drawImage; - - cd.sWidth = cw; - cd.sHeight = ch; - cd.dWidth = cw; - cd.dHeight = ch; - - // WebGL data - - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x0 = cx / tw; - uvs.y0 = cy / th; - - uvs.x1 = cx / tw; - uvs.y1 = (cy + ch) / th; - - uvs.x2 = (cx + cw) / tw; - uvs.y2 = (cy + ch) / th; - - uvs.x3 = (cx + cw) / tw; - uvs.y3 = cy / th; - - return this; - }, - - /** - * Updates the internal WebGL UV cache. - * - * @method Phaser.Textures.Frame#updateUVsInverted - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} This Frame object. - */ - updateUVsInverted: function () - { - var tw = this.source.width; - var th = this.source.height; - var uvs = this.data.uvs; - - uvs.x3 = (this.cutX + this.cutHeight) / tw; - uvs.y3 = (this.cutY + this.cutWidth) / th; - - uvs.x2 = this.cutX / tw; - uvs.y2 = (this.cutY + this.cutWidth) / th; - - uvs.x1 = this.cutX / tw; - uvs.y1 = this.cutY / th; - - uvs.x0 = (this.cutX + this.cutHeight) / tw; - uvs.y0 = this.cutY / th; - - return this; - }, - - /** - * Clones this Frame into a new Frame object. - * - * @method Phaser.Textures.Frame#clone - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} A clone of this Frame. - */ - clone: function () - { - var clone = new Frame(this.texture, this.name, this.sourceIndex); - - clone.cutX = this.cutX; - clone.cutY = this.cutY; - clone.cutWidth = this.cutWidth; - clone.cutHeight = this.cutHeight; - - clone.x = this.x; - clone.y = this.y; - - clone.width = this.width; - clone.height = this.height; - - clone.halfWidth = this.halfWidth; - clone.halfHeight = this.halfHeight; - - clone.centerX = this.centerX; - clone.centerY = this.centerY; - - clone.rotated = this.rotated; - - clone.data = Extend(true, clone.data, this.data); - - clone.updateUVs(); - - return clone; - }, - - /** - * Destroys this Frames references. - * - * @method Phaser.Textures.Frame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.texture = null; - - this.source = null; - }, - - /** - * The width of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realWidth - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realWidth: { - - get: function () - { - return this.data.sourceSize.w; - } - - }, - - /** - * The height of the Frame in its un-trimmed, un-padded state, as prepared in the art package, - * before being packed. - * - * @name Phaser.Textures.Frame#realHeight - * @type {number} - * @readOnly - * @since 3.0.0 - */ - realHeight: { - - get: function () - { - return this.data.sourceSize.h; - } - - }, - - /** - * The UV data for this Frame. - * - * @name Phaser.Textures.Frame#uvs - * @type {object} - * @readOnly - * @since 3.0.0 - */ - uvs: { - - get: function () - { - return this.data.uvs; - } - - }, - - /** - * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) - * - * @name Phaser.Textures.Frame#radius - * @type {number} - * @readOnly - * @since 3.0.0 - */ - radius: { - - get: function () - { - return this.data.radius; - } - - }, - - /** - * Is the Frame trimmed or not? - * - * @name Phaser.Textures.Frame#trimmed - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - trimmed: { - - get: function () - { - return this.data.trim; - } - - }, - - /** - * The Canvas drawImage data object. - * - * @name Phaser.Textures.Frame#canvasData - * @type {object} - * @readOnly - * @since 3.0.0 - */ - canvasData: { - - get: function () - { - return this.data.drawImage; - } - - } - -}); - -module.exports = Frame; - - -/***/ }), -/* 129 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var ModelViewProjection = __webpack_require__(202); -var ShaderSourceFS = __webpack_require__(526); -var ShaderSourceVS = __webpack_require__(525); -var Utils = __webpack_require__(27); -var WebGLPipeline = __webpack_require__(84); - -/** - * @classdesc - * TextureTintPipeline implements the rendering infrastructure - * for displaying textured objects - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class TextureTintPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var TextureTintPipeline = new Class({ - - Extends: WebGLPipeline, - - Mixins: [ - ModelViewProjection - ], - - initialize: - - function TextureTintPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 6 * 2000), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2 + - Float32Array.BYTES_PER_ELEMENT * 2 + - Uint8Array.BYTES_PER_ELEMENT * 4), - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - }, - { - name: 'inTexCoord', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: Float32Array.BYTES_PER_ELEMENT * 2 - }, - { - name: 'inTint', - size: 4, - type: config.renderer.gl.UNSIGNED_BYTE, - normalized: true, - offset: Float32Array.BYTES_PER_ELEMENT * 4 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewU32 - * @type {Uint32Array} - * @since 3.0.0 - */ - this.vertexViewU32 = new Uint32Array(this.vertexData); - - /** - * Size of the batch. - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#maxQuads - * @type {integer} - * @default 2000 - * @since 3.0.0 - */ - this.maxQuads = 2000; - - /** - * Collection of batch information - * - * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batches - * @type {array} - * @since 3.1.0 - */ - this.batches = []; - - this.mvpInit(); - }, - - /** - * Assigns a texture to the current batch. If a texture is already set it creates - * a new batch object. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#setTexture2D - * @since 3.1.0 - * - * @param {WebGLTexture} texture - WebGLTexture that will be assigned to the current batch. - * @param {integer} textureUnit - Texture unit to which the texture needs to be bound. - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - setTexture2D: function (texture, unit) - { - if (!texture) - { - return this; - } - - var batches = this.batches; - - if (batches.length === 0) - { - this.pushBatch(); - } - - var batch = batches[batches.length - 1]; - - if (unit > 0) - { - if (batch.textures[unit - 1] && - batch.textures[unit - 1] !== texture) - { - this.pushBatch(); - } - - batches[batches.length - 1].textures[unit - 1] = texture; - } - else - { - if (batch.texture !== null && - batch.texture !== texture) - { - this.pushBatch(); - } - - batches[batches.length - 1].texture = texture; - } - - return this; - }, - - /** - * Creates a new batch object and pushes it to a batch array. - * The batch object contains information relevant to the current - * vertex batch like the offset in the vertex buffer, vertex count and - * the textures used by that batch. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#pushBatch - * @since 3.1.0 - */ - pushBatch: function () - { - var batch = { - first: this.vertexCount, - texture: null, - textures: [] - }; - - this.batches.push(batch); - }, - - /** - * Binds, uploads resources and processes all batches generating draw calls. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#flush - * @since 3.1.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This Pipeline. - */ - flush: function () - { - if (this.flushLocked) - { - return this; - } - - this.flushLocked = true; - - var gl = this.gl; - var renderer = this.renderer; - var vertexCount = this.vertexCount; - var topology = this.topology; - var vertexSize = this.vertexSize; - var batches = this.batches; - var batchCount = batches.length; - var batchVertexCount = 0; - var batch = null; - var batchNext; - var textureIndex; - var nTexture; - - if (batchCount === 0 || vertexCount === 0) - { - this.flushLocked = false; - return this; - } - - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); - - for (var index = 0; index < batches.length - 1; ++index) - { - batch = batches[index]; - batchNext = batches[index + 1]; - - if (batch.textures.length > 0) - { - for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) - { - nTexture = batch.textures[textureIndex]; - - if (nTexture) - { - renderer.setTexture2D(nTexture, 1 + textureIndex); - } - } - - gl.activeTexture(gl.TEXTURE0); - } - - batchVertexCount = batchNext.first - batch.first; - - if (batch.texture === null || batchVertexCount <= 0) { continue; } - - renderer.setTexture2D(batch.texture, 0); - gl.drawArrays(topology, batch.first, batchVertexCount); - } - - // Left over data - batch = batches[batches.length - 1]; - - if (batch.textures.length > 0) - { - for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) - { - nTexture = batch.textures[textureIndex]; - - if (nTexture) - { - renderer.setTexture2D(nTexture, 1 + textureIndex); - } - } - - gl.activeTexture(gl.TEXTURE0); - } - - batchVertexCount = vertexCount - batch.first; - - if (batch.texture && batchVertexCount > 0) - { - renderer.setTexture2D(batch.texture, 0); - gl.drawArrays(topology, batch.first, batchVertexCount); - } - - this.vertexCount = 0; - batches.length = 0; - this.pushBatch(); - this.flushLocked = false; - - return this; - }, - - /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - - this.mvpUpdate(); - - if (this.batches.length === 0) - { - this.pushBatch(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); - return this; - }, - - /** - * Renders immediately a static tilemap. This function won't use - * the batching functionality of the pipeline. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawStaticTilemapLayer: function (tilemap) - { - if (tilemap.vertexCount > 0) - { - var pipelineVertexBuffer = this.vertexBuffer; - var gl = this.gl; - var renderer = this.renderer; - var frame = tilemap.tileset.image.get(); - - if (renderer.currentPipeline && - renderer.currentPipeline.vertexCount > 0) - { - renderer.flush(); - } - - this.vertexBuffer = tilemap.vertexBuffer; - renderer.setPipeline(this); - renderer.setTexture2D(frame.source.glTexture, 0); - gl.drawArrays(this.topology, 0, tilemap.vertexCount); - this.vertexBuffer = pipelineVertexBuffer; - } - - this.viewIdentity(); - this.modelIdentity(); - }, - - /** - * Renders contents of a ParticleEmitterManager. It'll batch all particles if possible. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawEmitterManager: function (emitterManager, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var roundPixels = this.renderer.config.roundPixels; - var emitters = emitterManager.emitters.list; - var emitterCount = emitters.length; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var renderer = this.renderer; - var maxQuads = this.maxQuads; - var cameraScrollX = camera.scrollX; - var cameraScrollY = camera.scrollY; - var cameraMatrix = camera.matrix.matrix; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var sin = Math.sin; - var cos = Math.cos; - var vertexComponentCount = this.vertexComponentCount; - var vertexCapacity = this.vertexCapacity; - var texture = emitterManager.defaultFrame.source.glTexture; - var pca, pcb, pcc, pcd, pce, pcf; - var pma, pmb, pmc, pmd, pme, pmf; - - if (parentMatrix) - { - pma = parentMatrix[0]; - pmb = parentMatrix[1]; - pmc = parentMatrix[2]; - pmd = parentMatrix[3]; - pme = parentMatrix[4]; - pmf = parentMatrix[5]; - } - - this.setTexture2D(texture, 0); - - for (var emitterIndex = 0; emitterIndex < emitterCount; ++emitterIndex) - { - var emitter = emitters[emitterIndex]; - var particles = emitter.alive; - var aliveLength = particles.length; - var batchCount = Math.ceil(aliveLength / maxQuads); - var particleOffset = 0; - var scrollX = cameraScrollX * emitter.scrollFactorX; - var scrollY = cameraScrollY * emitter.scrollFactorY; - - if (parentMatrix) - { - var cse = -scrollX; - var csf = -scrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - pca = pma * cma + pmb * cmc; - pcb = pma * cmb + pmb * cmd; - pcc = pmc * cma + pmd * cmc; - pcd = pmc * cmb + pmd * cmd; - pce = pme * cma + pmf * cmc + pse; - pcf = pme * cmb + pmf * cmd + psf; - - cma = pca; - cmb = pcb; - cmc = pcc; - cmd = pcd; - cme = pce; - cmf = pcf; - - scrollX = 0.0; - scrollY = 0.0; - } - - if (!emitter.visible || aliveLength === 0) - { - continue; - } - - renderer.setBlendMode(emitter.blendMode); - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - - for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) - { - var batchSize = Math.min(aliveLength, maxQuads); - - for (var index = 0; index < batchSize; ++index) - { - var particle = particles[particleOffset + index]; - - if (particle.alpha <= 0) - { - continue; - } - - var frame = particle.frame; - var uvs = frame.uvs; - var x = -(frame.halfWidth); - var y = -(frame.halfHeight); - var color = particle.color; - var xw = x + frame.width; - var yh = y + frame.height; - var sr = sin(particle.rotation); - var cr = cos(particle.rotation); - var sra = cr * particle.scaleX; - var srb = sr * particle.scaleX; - var src = -sr * particle.scaleY; - var srd = cr * particle.scaleY; - var sre = particle.x - scrollX; - var srf = particle.y - scrollY; - var mva = sra * cma + srb * cmc; - var mvb = sra * cmb + srb * cmd; - var mvc = src * cma + srd * cmc; - var mvd = src * cmb + srd * cmd; - var mve = sre * cma + srf * cmc + cme; - var mvf = sre * cmb + srf * cmd + cmf; - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = this.vertexCount * vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = color; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = color; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = color; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = color; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = color; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = color; - - this.vertexCount += 6; - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - - } - - particleOffset += batchSize; - aliveLength -= batchSize; - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - } - } - - this.setTexture2D(texture, 0); - }, - - /** - * Batches blitter game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawBlitter: function (blitter, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var list = blitter.getRenderList(); - var length = list.length; - var cameraMatrix = camera.matrix.matrix; - var a = cameraMatrix[0]; - var b = cameraMatrix[1]; - var c = cameraMatrix[2]; - var d = cameraMatrix[3]; - var e = cameraMatrix[4]; - var f = cameraMatrix[5]; - var cameraScrollX = camera.scrollX * blitter.scrollFactorX; - var cameraScrollY = camera.scrollY * blitter.scrollFactorY; - var batchCount = Math.ceil(length / this.maxQuads); - var batchOffset = 0; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * a + csf * c + e; - var psf = cse * b + csf * d + f; - var pca = pma * a + pmb * c; - var pcb = pma * b + pmb * d; - var pcc = pmc * a + pmd * c; - var pcd = pmc * b + pmd * d; - var pce = pme * a + pmf * c + pse; - var pcf = pme * b + pmf * d + psf; - - a = pca; - b = pcb; - c = pcc; - d = pcd; - e = pce; - f = pcf; - - cameraScrollX = 0.0; - cameraScrollY = 0.0; - } - - var blitterX = blitter.x - cameraScrollX; - var blitterY = blitter.y - cameraScrollY; - - var prevTextureSourceIndex; - - for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) - { - var batchSize = Math.min(length, this.maxQuads); - - for (var index = 0; index < batchSize; ++index) - { - var bob = list[batchOffset + index]; - var frame = bob.frame; - var alpha = bob.alpha; - - if (alpha === 0) - { - // Nothing to see here, moving on ... - continue; - } - - var tint = getTint(0xffffff, alpha); - var uvs = frame.uvs; - var flipX = bob.flipX; - var flipY = bob.flipY; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = blitterX + bob.x + frame.x + (frame.width * ((flipX) ? 1.0 : 0.0)); - var y = blitterY + bob.y + frame.y + (frame.height * ((flipY) ? 1.0 : 0.0)); - var xw = x + width; - var yh = y + height; - var tx0 = x * a + y * c + e; - var ty0 = x * b + y * d + f; - var tx1 = xw * a + yh * c + e; - var ty1 = xw * b + yh * d + f; - - // Bind texture only if the Texture Source is different from before - if (frame.sourceIndex !== prevTextureSourceIndex) - { - this.setTexture2D(frame.texture.source[frame.sourceIndex].glTexture, 0); - - prevTextureSourceIndex = frame.sourceIndex; - } - - var vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = tint; - vertexViewF32[vertexOffset + 5] = tx0; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = tint; - vertexViewF32[vertexOffset + 10] = tx1; - vertexViewF32[vertexOffset + 11] = ty1; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = tint; - vertexViewF32[vertexOffset + 20] = tx1; - vertexViewF32[vertexOffset + 21] = ty1; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = tint; - vertexViewF32[vertexOffset + 25] = tx1; - vertexViewF32[vertexOffset + 26] = ty0; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = tint; - - this.vertexCount += 6; - - if (this.vertexCount >= this.vertexCapacity) - { - this.flush(); - - prevTextureSourceIndex = -1; - } - } - - batchOffset += batchSize; - length -= batchSize; - - if (this.vertexCount >= this.vertexCapacity) - { - this.flush(); - } - } - }, - - /** - * Batches Sprite game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchSprite: function (sprite, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var frame = sprite.frame; - var texture = frame.texture.source[frame.sourceIndex].glTexture; - var forceFlipY = (texture.isRenderTexture ? true : false); - var flipX = sprite.flipX; - var flipY = sprite.flipY ^ forceFlipY; - var uvs = frame.uvs; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = -sprite.displayOriginX + frame.x + ((frame.width) * (flipX ? 1.0 : 0.0)); - var y = -sprite.displayOriginY + frame.y + ((frame.height) * (flipY ? 1.0 : 0.0)); - var xw = (roundPixels ? (x|0) : x) + width; - var yh = (roundPixels ? (y|0) : y) + height; - var scaleX = sprite.scaleX; - var scaleY = sprite.scaleY; - var rotation = sprite.rotation; - var alphaTL = sprite._alphaTL; - var alphaTR = sprite._alphaTR; - var alphaBL = sprite._alphaBL; - var alphaBR = sprite._alphaBR; - var tintTL = sprite._tintTL; - var tintTR = sprite._tintTR; - var tintBL = sprite._tintBL; - var tintBR = sprite._tintBR; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = sprite.x; - var srf = sprite.y; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * sprite.scrollFactorX; - var csf = -camera.scrollY * sprite.scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * sprite.scrollFactorX; - srf -= camera.scrollY * sprite.scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vTintTL = getTint(tintTL, alphaTL); - var vTintTR = getTint(tintTR, alphaTR); - var vTintBL = getTint(tintBL, alphaBL); - var vTintBR = getTint(tintBR, alphaBR); - var vertexOffset = 0; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - }, - - /** - * Batches Mesh game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchMesh: function (mesh, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - var vertices = mesh.vertices; - var length = vertices.length; - var vertexCount = (length / 2)|0; - - this.renderer.setPipeline(this); - - if (this.vertexCount + vertexCount > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var uvs = mesh.uv; - var colors = mesh.colors; - var alphas = mesh.alphas; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var frame = mesh.frame; - var texture = mesh.texture.source[frame.sourceIndex].glTexture; - var translateX = mesh.x; - var translateY = mesh.y; - var scaleX = mesh.scaleX; - var scaleY = mesh.scaleY; - var rotation = mesh.rotation; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * mesh.scrollFactorX; - var csf = -camera.scrollY * mesh.scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * mesh.scrollFactorX; - srf -= camera.scrollY * mesh.scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - for (var index = 0, index0 = 0; index < length; index += 2) - { - var x = vertices[index + 0]; - var y = vertices[index + 1]; - var tx = x * mva + y * mvc + mve; - var ty = x * mvb + y * mvd + mvf; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx; - vertexViewF32[vertexOffset + 1] = ty; - vertexViewF32[vertexOffset + 2] = uvs[index + 0]; - vertexViewF32[vertexOffset + 3] = uvs[index + 1]; - vertexViewU32[vertexOffset + 4] = getTint(colors[index0], alphas[index0]); - - vertexOffset += 5; - index0 += 1; - } - - this.vertexCount += vertexCount; - }, - - /** - * Batches BitmapText game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var text = bitmapText.text; - var textLength = text.length; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var cameraWidth = camera.width + 50; - var cameraHeight = camera.height + 50; - var cameraX = -50; - var cameraY = -50; - var frame = bitmapText.frame; - var textureSource = bitmapText.texture.source[frame.sourceIndex]; - var cameraScrollX = camera.scrollX * bitmapText.scrollFactorX; - var cameraScrollY = camera.scrollY * bitmapText.scrollFactorY; - var fontData = bitmapText.fontData; - var lineHeight = fontData.lineHeight; - var scale = (bitmapText.fontSize / fontData.size); - var chars = fontData.chars; - var alpha = bitmapText.alpha; - var vTintTL = getTint(bitmapText._tintTL, alpha); - var vTintTR = getTint(bitmapText._tintTR, alpha); - var vTintBL = getTint(bitmapText._tintBL, alpha); - var vTintBR = getTint(bitmapText._tintBR, alpha); - var srcX = bitmapText.x; - var srcY = bitmapText.y; - var textureX = frame.cutX; - var textureY = frame.cutY; - var textureWidth = textureSource.width; - var textureHeight = textureSource.height; - var texture = textureSource.glTexture; - var xAdvance = 0; - var yAdvance = 0; - var indexCount = 0; - var charCode = 0; - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - var x = 0; - var y = 0; - var xw = 0; - var yh = 0; - - var tx0; - var ty0; - var tx1; - var ty1; - var tx2; - var ty2; - var tx3; - var ty3; - - var umin = 0; - var umax = 0; - var vmin = 0; - var vmax = 0; - var lastGlyph = null; - var lastCharCode = 0; - var translateX = srcX + frame.x; - var translateY = srcY + frame.y; - var rotation = bitmapText.rotation; - var scaleX = bitmapText.scaleX; - var scaleY = bitmapText.scaleY; - var letterSpacing = bitmapText.letterSpacing; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) * scale; - y = (glyph.yOffset + yAdvance) * scale; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - x -= bitmapText.displayOriginX; - y -= bitmapText.displayOriginY; - - xw = x + glyphW * scale; - yh = y + glyphH * scale; - tx0 = x * mva + y * mvc + mve; - ty0 = x * mvb + y * mvd + mvf; - tx1 = x * mva + yh * mvc + mve; - ty1 = x * mvb + yh * mvd + mvf; - tx2 = xw * mva + yh * mvc + mve; - ty2 = xw * mvb + yh * mvd + mvf; - tx3 = xw * mva + y * mvc + mve; - ty3 = xw * mvb + y * mvd + mvf; - - umin = glyphX / textureWidth; - umax = (glyphX + glyphW) / textureWidth; - vmin = glyphY / textureHeight; - vmax = (glyphY + glyphH) / textureHeight; - - if ((tx0 < cameraX || tx0 > cameraWidth || ty0 < cameraY || ty0 > cameraHeight) && - (tx1 < cameraX || tx1 > cameraWidth || ty1 < cameraY || ty1 > cameraHeight) && - (tx2 < cameraX || tx2 > cameraWidth || ty2 < cameraY || ty2 > cameraHeight) && - (tx3 < cameraX || tx3 > cameraWidth || ty3 < cameraY || ty3 > cameraHeight)) - { - continue; - } - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = umin; - vertexViewF32[vertexOffset + 3] = vmin; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = umin; - vertexViewF32[vertexOffset + 8] = vmax; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = umax; - vertexViewF32[vertexOffset + 13] = vmax; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = umin; - vertexViewF32[vertexOffset + 18] = vmin; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = umax; - vertexViewF32[vertexOffset + 23] = vmax; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = umax; - vertexViewF32[vertexOffset + 28] = vmin; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - } - }, - - /** - * Batches DynamicBitmapText game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var displayCallback = bitmapText.displayCallback; - var text = bitmapText.text; - var textLength = text.length; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var renderer = this.renderer; - var cameraMatrix = camera.matrix.matrix; - var frame = bitmapText.frame; - var textureSource = bitmapText.texture.source[frame.sourceIndex]; - var cameraScrollX = camera.scrollX * bitmapText.scrollFactorX; - var cameraScrollY = camera.scrollY * bitmapText.scrollFactorY; - var scrollX = bitmapText.scrollX; - var scrollY = bitmapText.scrollY; - var fontData = bitmapText.fontData; - var lineHeight = fontData.lineHeight; - var scale = (bitmapText.fontSize / fontData.size); - var chars = fontData.chars; - var alpha = bitmapText.alpha; - var vTintTL = getTint(bitmapText._tintTL, alpha); - var vTintTR = getTint(bitmapText._tintTR, alpha); - var vTintBL = getTint(bitmapText._tintBL, alpha); - var vTintBR = getTint(bitmapText._tintBR, alpha); - var srcX = bitmapText.x; - var srcY = bitmapText.y; - var textureX = frame.cutX; - var textureY = frame.cutY; - var textureWidth = textureSource.width; - var textureHeight = textureSource.height; - var texture = textureSource.glTexture; - var xAdvance = 0; - var yAdvance = 0; - var indexCount = 0; - var charCode = 0; - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - var x = 0; - var y = 0; - var xw = 0; - var tx0; - var ty0; - var tx1; - var ty1; - var tx2; - var ty2; - var tx3; - var ty3; - var yh = 0; - var umin = 0; - var umax = 0; - var vmin = 0; - var vmax = 0; - var lastGlyph = null; - var lastCharCode = 0; - var translateX = srcX + frame.x; - var translateY = srcY + frame.y; - var rotation = bitmapText.rotation; - var scaleX = bitmapText.scaleX; - var scaleY = bitmapText.scaleY; - var letterSpacing = bitmapText.letterSpacing; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var crop = (bitmapText.cropWidth > 0 || bitmapText.cropHeight > 0); - var uta, utb, utc, utd, ute, utf; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - if (crop) - { - renderer.pushScissor( - bitmapText.x, - bitmapText.y, - bitmapText.cropWidth * bitmapText.scaleX, - bitmapText.cropHeight * bitmapText.scaleY - ); - } - - for (var index = 0; index < textLength; ++index) - { - scale = (bitmapText.fontSize / bitmapText.fontData.size); - rotation = 0; - - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) - scrollX; - y = (glyph.yOffset + yAdvance) - scrollY; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - if (displayCallback) - { - var output = displayCallback({ - color: 0, - tint: { - topLeft: vTintTL, - topRight: vTintTR, - bottomLeft: vTintBL, - bottomRight: vTintBR - }, - index: index, - charCode: charCode, - x: x, - y: y, - scale: scale, - rotation: 0, - data: glyph.data - }); - - x = output.x; - y = output.y; - scale = output.scale; - rotation = output.rotation; - - if (output.color) - { - vTintTL = output.color; - vTintTR = output.color; - vTintBL = output.color; - vTintBR = output.color; - } - else - { - vTintTL = output.tint.topLeft; - vTintTR = output.tint.topRight; - vTintBL = output.tint.bottomLeft; - vTintBR = output.tint.bottomRight; - } - - vTintTL = getTint(vTintTL, alpha); - vTintTR = getTint(vTintTR, alpha); - vTintBL = getTint(vTintBL, alpha); - vTintBR = getTint(vTintBR, alpha); - } - - x -= bitmapText.displayOriginX; - y -= bitmapText.displayOriginY; - x *= scale; - y *= scale; - - sr = Math.sin(rotation); - cr = Math.cos(rotation); - uta = cr * scale; - utb = sr * scale; - utc = -sr * scale; - utd = cr * scale; - ute = x; - utf = y; - - sra = uta * mva + utb * mvc; - srb = uta * mvb + utb * mvd; - src = utc * mva + utd * mvc; - srd = utc * mvb + utd * mvd; - sre = ute * mva + utf * mvc + mve; - srf = ute * mvb + utf * mvd + mvf; - - xw = glyphW; - yh = glyphH; - tx0 = sre; - ty0 = srf; - tx1 = yh * src + sre; - ty1 = yh * srd + srf; - tx2 = xw * sra + yh * src + sre; - ty2 = xw * srb + yh * srd + srf; - tx3 = xw * sra + sre; - ty3 = xw * srb + srf; - - umin = glyphX / textureWidth; - umax = (glyphX + glyphW) / textureWidth; - vmin = glyphY / textureHeight; - vmax = (glyphY + glyphH) / textureHeight; - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = umin; - vertexViewF32[vertexOffset + 3] = vmin; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = umin; - vertexViewF32[vertexOffset + 8] = vmax; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = umax; - vertexViewF32[vertexOffset + 13] = vmax; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = umin; - vertexViewF32[vertexOffset + 18] = vmin; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = umax; - vertexViewF32[vertexOffset + 23] = vmax; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = umax; - vertexViewF32[vertexOffset + 28] = vmin; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - } - - if (crop) - { - renderer.popScissor(); - } - }, - - /** - * Batches Text game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchText: function (text, camera, parentTransformMatrix) - { - var getTint = Utils.getTintAppendFloatAlpha; - - this.batchTexture( - text, - text.canvasTexture, - text.canvasTexture.width, text.canvasTexture.height, - text.x, text.y, - text.canvasTexture.width, text.canvasTexture.height, - text.scaleX, text.scaleY, - text.rotation, - text.flipX, text.flipY, - text.scrollFactorX, text.scrollFactorY, - text.displayOriginX, text.displayOriginY, - 0, 0, text.canvasTexture.width, text.canvasTexture.height, - getTint(text._tintTL, text._alphaTL), - getTint(text._tintTR, text._alphaTR), - getTint(text._tintBL, text._alphaBL), - getTint(text._tintBR, text._alphaBR), - 0, 0, - camera, - parentTransformMatrix - ); - }, - - /** - * Batches DynamicTilemapLayer game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix) - { - var renderTiles = tilemapLayer.culledTiles; - var length = renderTiles.length; - var texture = tilemapLayer.tileset.image.get().source.glTexture; - var tileset = tilemapLayer.tileset; - var scrollFactorX = tilemapLayer.scrollFactorX; - var scrollFactorY = tilemapLayer.scrollFactorY; - var alpha = tilemapLayer.alpha; - var x = tilemapLayer.x; - var y = tilemapLayer.y; - var sx = tilemapLayer.scaleX; - var sy = tilemapLayer.scaleY; - var getTint = Utils.getTintAppendFloatAlpha; - - for (var index = 0; index < length; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } - - var frameWidth = tile.width; - var frameHeight = tile.height; - var frameX = tileTexCoords.x; - var frameY = tileTexCoords.y; - var tint = getTint(tile.tint, alpha * tile.alpha); - - this.batchTexture( - tilemapLayer, - texture, - texture.width, texture.height, - (tile.width / 2) + x + tile.pixelX * sx, (tile.height / 2) + y + tile.pixelY * sy, - tile.width * sx, tile.height * sy, - 1, 1, - tile.rotation, - tile.flipX, tile.flipY, - scrollFactorX, scrollFactorY, - (tile.width / 2), (tile.height / 2), - frameX, frameY, frameWidth, frameHeight, - tint, tint, tint, tint, - 0, 0, - camera, - parentTransformMatrix - ); - } - }, - - /** - * Batches TileSprite game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchTileSprite: function (tileSprite, camera, parentTransformMatrix) - { - var getTint = Utils.getTintAppendFloatAlpha; - - this.batchTexture( - tileSprite, - tileSprite.tileTexture, - tileSprite.frame.width, tileSprite.frame.height, - tileSprite.x, tileSprite.y, - tileSprite.width, tileSprite.height, - tileSprite.scaleX, tileSprite.scaleY, - tileSprite.rotation, - tileSprite.flipX, tileSprite.flipY, - tileSprite.scrollFactorX, tileSprite.scrollFactorY, - tileSprite.originX * tileSprite.width, tileSprite.originY * tileSprite.height, - 0, 0, tileSprite.width, tileSprite.height, - getTint(tileSprite._tintTL, tileSprite._alphaTL), - getTint(tileSprite._tintTR, tileSprite._alphaTR), - getTint(tileSprite._tintBL, tileSprite._alphaBL), - getTint(tileSprite._tintBR, tileSprite._alphaBR), - (tileSprite.tilePositionX % tileSprite.frame.width) / tileSprite.frame.width, - (tileSprite.tilePositionY % tileSprite.frame.height) / tileSprite.frame.height, - camera, - parentTransformMatrix - ); - }, - - /** - * Generic function for batching a textured quad - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject - * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad - * @param {integer} textureWidth - Real texture width - * @param {integer} textureHeight - Real texture height - * @param {float} srcX - X coordinate of the quad - * @param {float} srcY - Y coordinate of the quad - * @param {float} srcWidth - Width of the quad - * @param {float} srcHeight - Height of the quad - * @param {float} scaleX - X component of scale - * @param {float} scaleY - Y component of scale - * @param {float} rotation - Rotation of the quad - * @param {boolean} flipX - Indicates if the quad is horizontally flipped - * @param {boolean} flipY - Indicates if the quad is vertically flipped - * @param {float} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll - * @param {float} scrollFactorY - By which factor is the quad effected by the camera vertical scroll - * @param {float} displayOriginX - Horizontal origin in pixels - * @param {float} displayOriginY - Vertical origin in pixels - * @param {float} frameX - X coordinate of the texture frame - * @param {float} frameY - Y coordinate of the texture frame - * @param {float} frameWidth - Width of the texture frame - * @param {float} frameHeight - Height of the texture frame - * @param {integer} tintTL - Tint for top left - * @param {integer} tintTR - Tint for top right - * @param {integer} tintBL - Tint for bottom left - * @param {integer} tintBR - Tint for bottom right - * @param {float} uOffset - Horizontal offset on texture coordinate - * @param {float} vOffset - Vertical offset on texture coordinate - * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container - */ - batchTexture: function ( - gameObject, - texture, - textureWidth, textureHeight, - srcX, srcY, - srcWidth, srcHeight, - scaleX, scaleY, - rotation, - flipX, flipY, - scrollFactorX, scrollFactorY, - displayOriginX, displayOriginY, - frameX, frameY, frameWidth, frameHeight, - tintTL, tintTR, tintBL, tintBR, - uOffset, vOffset, - camera, - parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); - - var roundPixels = this.renderer.config.roundPixels; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var width = srcWidth * (flipX ? -1.0 : 1.0); - var height = srcHeight * (flipY ? -1.0 : 1.0); - var x = -displayOriginX + ((srcWidth) * (flipX ? 1.0 : 0.0)); - var y = -displayOriginY + ((srcHeight) * (flipY ? 1.0 : 0.0)); - var xw = x + width; - var yh = y + height; - var translateX = srcX; - var translateY = srcY; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * scrollFactorX; - var csf = -camera.scrollY * scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * scrollFactorX; - srf -= camera.scrollY * scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = 0; - var u0 = (frameX / textureWidth) + uOffset; - var v0 = (frameY / textureHeight) + vOffset; - var u1 = (frameX + frameWidth) / textureWidth + uOffset; - var v1 = (frameY + frameHeight) / textureHeight + vOffset; - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = u0; - vertexViewF32[vertexOffset + 3] = v0; - vertexViewU32[vertexOffset + 4] = tintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = u0; - vertexViewF32[vertexOffset + 8] = v1; - vertexViewU32[vertexOffset + 9] = tintTR; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = u1; - vertexViewF32[vertexOffset + 13] = v1; - vertexViewU32[vertexOffset + 14] = tintBL; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = u0; - vertexViewF32[vertexOffset + 18] = v0; - vertexViewU32[vertexOffset + 19] = tintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = u1; - vertexViewF32[vertexOffset + 23] = v1; - vertexViewU32[vertexOffset + 24] = tintBL; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = u1; - vertexViewF32[vertexOffset + 28] = v0; - vertexViewU32[vertexOffset + 29] = tintBR; - - this.vertexCount += 6; - }, - - /** - * Immediately draws a texture with no batching. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawTexture - * @since 3.2.0 - * - * @param {WebGLTexture} texture [description] - * @param {number} srcX - [description] - * @param {number} srcY - [description] - * @param {number} tint - [description] - * @param {number} alpha - [description] - * @param {number} frameX - [description] - * @param {number} frameY - [description] - * @param {number} frameWidth - [description] - * @param {number} frameHeight - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} transformMatrix - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This Pipeline. - */ - drawTexture: function ( - texture, - srcX, srcY, - tint, alpha, - frameX, frameY, frameWidth, frameHeight, - transformMatrix, - parentTransformMatrix - ) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = this.renderer.config.roundPixels; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var width = frameWidth; - var height = frameHeight; - var x = srcX; - var y = srcY; - var xw = x + width; - var yh = y + height; - var mva = transformMatrix[0]; - var mvb = transformMatrix[1]; - var mvc = transformMatrix[2]; - var mvd = transformMatrix[3]; - var mve = transformMatrix[4]; - var mvf = transformMatrix[5]; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var pca = mva * pma + mvb * pmc; - var pcb = mva * pmb + mvb * pmd; - var pcc = mvc * pma + mvd * pmc; - var pcd = mvc * pmb + mvd * pmd; - var pce = mve * pma + mvf * pmc + pme; - var pcf = mve * pmb + mvf * pmd + pmf; - mva = pca; - mvb = pcb; - mvc = pcc; - mvd = pcd; - mve = pce; - mvf = pcf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = 0; - var textureWidth = texture.width; - var textureHeight = texture.height; - var u0 = (frameX / textureWidth); - var v0 = (frameY / textureHeight); - var u1 = (frameX + frameWidth) / textureWidth; - var v1 = (frameY + frameHeight) / textureHeight; - tint = Utils.getTintAppendFloatAlpha(tint, alpha); - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = u0; - vertexViewF32[vertexOffset + 3] = v0; - vertexViewU32[vertexOffset + 4] = tint; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = u0; - vertexViewF32[vertexOffset + 8] = v1; - vertexViewU32[vertexOffset + 9] = tint; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = u1; - vertexViewF32[vertexOffset + 13] = v1; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = u0; - vertexViewF32[vertexOffset + 18] = v0; - vertexViewU32[vertexOffset + 19] = tint; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = u1; - vertexViewF32[vertexOffset + 23] = v1; - vertexViewU32[vertexOffset + 24] = tint; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = u1; - vertexViewF32[vertexOffset + 28] = v0; - vertexViewU32[vertexOffset + 29] = tint; - - this.vertexCount += 6; - - // Force an immediate draw - this.flush(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchGraphics - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchGraphics: function () - { - // Stub - } - -}); - -module.exports = TextureTintPipeline; - - -/***/ }), -/* 130 */ +/* 169 */ /***/ (function(module, exports) { /** @@ -32786,7 +41440,7 @@ module.exports = TextureTintPipeline; /** * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. - * If no parent was given or falls back to using `document.body`. + * If no parent was given it falls back to using `document.body`. * * @function Phaser.DOM.AddToDOM * @since 3.0.0 @@ -32812,7 +41466,7 @@ var AddToDOM = function (element, parent, overflowHidden) } else if (typeof parent === 'object' && parent.nodeType === 1) { - // Quick test for a HTMLelement + // Quick test for a HTMLElement target = parent; } } @@ -32821,7 +41475,7 @@ var AddToDOM = function (element, parent, overflowHidden) return element; } - // Fallback, covers an invalid ID and a non HTMLelement object + // Fallback, covers an invalid ID and a non HTMLElement object if (!target) { target = document.body; @@ -32841,7 +41495,7 @@ module.exports = AddToDOM; /***/ }), -/* 131 */ +/* 170 */ /***/ (function(module, exports) { /** @@ -32850,130 +41504,64 @@ module.exports = AddToDOM; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Browser specific prefix, so not going to change between contexts, only between browsers -var prefix = ''; - /** - * @namespace Phaser.Display.Canvas.Smoothing + * Compute a random integer between the `min` and `max` values, inclusive. + * + * @function Phaser.Math.Between * @since 3.0.0 + * + * @param {integer} min - The minimum value. + * @param {integer} max - The maximum value. + * + * @return {integer} The random integer. */ -var Smoothing = function () +var Between = function (min, max) { - /** - * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. - * - * @function Phaser.Display.Canvas.Smoothing.getPrefix - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {string} [description] - */ - var getPrefix = function (context) - { - var vendors = [ 'i', 'webkitI', 'msI', 'mozI', 'oI' ]; - - for (var i = 0; i < vendors.length; i++) - { - var s = vendors[i] + 'mageSmoothingEnabled'; - - if (s in context) - { - return s; - } - } - - return null; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.enable - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] - */ - var enable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = true; - } - - return context; - }; - - /** - * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. - * By default browsers have image smoothing enabled, which isn't always what you visually want, especially - * when using pixel art in a game. Note that this sets the property on the context itself, so that any image - * drawn to the context will be affected. This sets the property across all current browsers but support is - * patchy on earlier browsers, especially on mobile. - * - * @function Phaser.Display.Canvas.Smoothing.disable - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] - */ - var disable = function (context) - { - if (prefix === '') - { - prefix = getPrefix(context); - } - - if (prefix) - { - context[prefix] = false; - } - - return context; - }; - - /** - * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. - * Returns null if no smoothing prefix is available. - * - * @function Phaser.Display.Canvas.Smoothing.isEnabled - * @since 3.0.0 - * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] - * - * @return {?boolean} [description] - */ - var isEnabled = function (context) - { - return (prefix !== null) ? context[prefix] : null; - }; - - return { - disable: disable, - enable: enable, - getPrefix: getPrefix, - isEnabled: isEnabled - }; - + return Math.floor(Math.random() * (max - min + 1) + min); }; -module.exports = Smoothing(); +module.exports = Between; /***/ }), -/* 132 */ +/* 171 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates a Catmull-Rom value. + * + * @function Phaser.Math.CatmullRom + * @since 3.0.0 + * + * @param {number} t - [description] + * @param {number} p0 - [description] + * @param {number} p1 - [description] + * @param {number} p2 - [description] + * @param {number} p3 - [description] + * + * @return {number} The Catmull-Rom value. + */ +var CatmullRom = function (t, p0, p1, p2, p3) +{ + var v0 = (p2 - p0) * 0.5; + var v1 = (p3 - p1) * 0.5; + var t2 = t * t; + var t3 = t * t2; + + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; +}; + +module.exports = CatmullRom; + + +/***/ }), +/* 172 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -32982,10 +41570,374 @@ module.exports = Smoothing(); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var HexStringToColor = __webpack_require__(285); -var IntegerToColor = __webpack_require__(283); -var ObjectToColor = __webpack_require__(281); -var RGBStringToColor = __webpack_require__(280); +var CONST = __webpack_require__(16); + +/** + * Convert the given angle in radians, to the equivalent angle in degrees. + * + * @function Phaser.Math.RadToDeg + * @since 3.0.0 + * + * @param {number} radians - The angle in radians to convert ot degrees. + * + * @return {integer} The given angle converted to degrees. + */ +var RadToDeg = function (radians) +{ + return radians * CONST.RAD_TO_DEG; +}; + +module.exports = RadToDeg; + + +/***/ }), +/* 173 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +// points is an array of Point-like objects, +// either 2 dimensional arrays, or objects with public x/y properties: +// var points = [ +// [100, 200], +// [200, 400], +// { x: 30, y: 60 } +// ] + +/** + * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. + * + * @function Phaser.Geom.Rectangle.FromPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {array} points - An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. + * @param {Phaser.Geom.Rectangle} [out] - Optional Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted `out` Rectangle, or a new Rectangle if none was provided. + */ +var FromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (points.length === 0) + { + return out; + } + + var minX = Number.MAX_VALUE; + var minY = Number.MAX_VALUE; + + var maxX = Number.MIN_SAFE_INTEGER; + var maxY = Number.MIN_SAFE_INTEGER; + + var p; + var px; + var py; + + for (var i = 0; i < points.length; i++) + { + p = points[i]; + + if (Array.isArray(p)) + { + px = p[0]; + py = p[1]; + } + else + { + px = p.x; + py = p.y; + } + + minX = Math.min(minX, px); + minY = Math.min(minY, py); + + maxX = Math.max(maxX, px); + maxY = Math.max(maxY, py); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; +}; + +module.exports = FromPoints; + + +/***/ }), +/* 174 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Back = __webpack_require__(369); +var Bounce = __webpack_require__(368); +var Circular = __webpack_require__(367); +var Cubic = __webpack_require__(366); +var Elastic = __webpack_require__(365); +var Expo = __webpack_require__(364); +var Linear = __webpack_require__(363); +var Quadratic = __webpack_require__(362); +var Quartic = __webpack_require__(361); +var Quintic = __webpack_require__(360); +var Sine = __webpack_require__(359); +var Stepped = __webpack_require__(358); + +// EaseMap +module.exports = { + + Power0: Linear, + Power1: Quadratic.Out, + Power2: Cubic.Out, + Power3: Quartic.Out, + Power4: Quintic.Out, + + Linear: Linear, + Quad: Quadratic.Out, + Cubic: Cubic.Out, + Quart: Quartic.Out, + Quint: Quintic.Out, + Sine: Sine.Out, + Expo: Expo.Out, + Circ: Circular.Out, + Elastic: Elastic.Out, + Back: Back.Out, + Bounce: Bounce.Out, + Stepped: Stepped, + + 'Quad.easeIn': Quadratic.In, + 'Cubic.easeIn': Cubic.In, + 'Quart.easeIn': Quartic.In, + 'Quint.easeIn': Quintic.In, + 'Sine.easeIn': Sine.In, + 'Expo.easeIn': Expo.In, + 'Circ.easeIn': Circular.In, + 'Elastic.easeIn': Elastic.In, + 'Back.easeIn': Back.In, + 'Bounce.easeIn': Bounce.In, + + 'Quad.easeOut': Quadratic.Out, + 'Cubic.easeOut': Cubic.Out, + 'Quart.easeOut': Quartic.Out, + 'Quint.easeOut': Quintic.Out, + 'Sine.easeOut': Sine.Out, + 'Expo.easeOut': Expo.Out, + 'Circ.easeOut': Circular.Out, + 'Elastic.easeOut': Elastic.Out, + 'Back.easeOut': Back.Out, + 'Bounce.easeOut': Bounce.Out, + + 'Quad.easeInOut': Quadratic.InOut, + 'Cubic.easeInOut': Cubic.InOut, + 'Quart.easeInOut': Quartic.InOut, + 'Quint.easeInOut': Quintic.InOut, + 'Sine.easeInOut': Sine.InOut, + 'Expo.easeInOut': Expo.InOut, + 'Circ.easeInOut': Circular.InOut, + 'Elastic.easeInOut': Elastic.InOut, + 'Back.easeInOut': Back.InOut, + 'Bounce.easeInOut': Bounce.InOut + +}; + + +/***/ }), +/* 175 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Centers this Rectangle so that the center coordinates match the given x and y values. + +/** + * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. + * + * @function Phaser.Geom.Rectangle.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to be centered. + * @param {number} x - The X coordinate of the Rectangle's center. + * @param {number} y - The Y coordinate of the Rectangle's center. + * + * @return {Phaser.Geom.Rectangle} The centered rectangle. + */ +var CenterOn = function (rect, x, y) +{ + rect.x = x - (rect.width / 2); + rect.y = y - (rect.height / 2); + + return rect; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 176 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetColor = __webpack_require__(177); + +/** + * Converts an HSV (hue, saturation and value) color value to RGB. + * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes HSV values are contained in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HSVToRGB + * @since 3.0.0 + * + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * @param {(ColorObject|Phaser.Display.Color)} [out] - A Color object to store the results in. If not given a new ColorObject will be created. + * + * @return {(ColorObject|Phaser.Display.Color)} An object with the red, green and blue values set in the r, g and b properties. + */ +var HSVToRGB = function (h, s, v, out) +{ + if (s === undefined) { s = 1; } + if (v === undefined) { v = 1; } + + var i = Math.floor(h * 6); + var f = h * 6 - i; + + var p = Math.floor((v * (1 - s)) * 255); + var q = Math.floor((v * (1 - f * s)) * 255); + var t = Math.floor((v * (1 - (1 - f) * s)) * 255); + + v = Math.floor(v *= 255); + + var r = v; + var g = v; + var b = v; + + var c = i % 6; + + if (c === 0) + { + g = t; + b = p; + } + else if (c === 1) + { + r = q; + b = p; + } + else if (c === 2) + { + r = p; + b = t; + } + else if (c === 3) + { + r = p; + g = q; + } + else if (c === 4) + { + r = t; + g = p; + } + else if (c === 5) + { + g = p; + b = q; + } + + if (!out) + { + return { r: r, g: g, b: b, color: GetColor(r, g, b) }; + } + else if (out.setTo) + { + return out.setTo(r, g, b, out.alpha, false); + } + else + { + out.r = r; + out.g = g; + out.b = b; + out.color = GetColor(r, g, b); + + return out; + } +}; + +module.exports = HSVToRGB; + + +/***/ }), +/* 177 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given 3 separate color values this will return an integer representation of it. + * + * @function Phaser.Display.Color.GetColor + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * + * @return {number} The combined color value. + */ +var GetColor = function (red, green, blue) +{ + return red << 16 | green << 8 | blue; +}; + +module.exports = GetColor; + + +/***/ }), +/* 178 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HexStringToColor = __webpack_require__(377); +var IntegerToColor = __webpack_require__(374); +var ObjectToColor = __webpack_require__(372); +var RGBStringToColor = __webpack_require__(371); /** * Converts the given source color value into an instance of a Color class. @@ -33029,7 +41981,7 @@ module.exports = ValueToColor; /***/ }), -/* 133 */ +/* 179 */ /***/ (function(module, exports) { /** @@ -33105,7 +42057,7 @@ module.exports = Pad; /***/ }), -/* 134 */ +/* 180 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -33114,7 +42066,558 @@ module.exports = Pad; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +var Class = __webpack_require__(0); + +/** + * @callback EachMapCallback + * @generic E - [entry] + * + * @param {string} key - [description] + * @param {*} entry - [description] + * + * @return {?boolean} [description] + */ + +/** + * @classdesc + * The keys of a Map can be arbitrary values. + * + * ```javascript + * var map = new Map([ + * [ 1, 'one' ], + * [ 2, 'two' ], + * [ 3, 'three' ] + * ]); + * ``` + * + * @class Map + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic K + * @generic V + * @genericUse {V[]} - [elements] + * + * @param {Array.<*>} elements - An optional array of key-value pairs to populate this Map with. + */ +var Map = new Class({ + + initialize: + + function Map (elements) + { + /** + * The entries in this Map. + * + * @genericUse {Object.} - [$type] + * + * @name Phaser.Structs.Map#entries + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.entries = {}; + + /** + * The number of key / value pairs in this Map. + * + * @name Phaser.Structs.Map#size + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.size = 0; + + if (Array.isArray(elements)) + { + for (var i = 0; i < elements.length; i++) + { + this.set(elements[i][0], elements[i][1]); + } + } + }, + + /** + * Adds an element with a specified `key` and `value` to this Map. + * + * @method Phaser.Structs.Map#set + * @since 3.0.0 + * + * @genericUse {K} - [key] + * @genericUse {V} - [value] + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @param {string} key - The key of the element to be added to this Map. + * @param {*} value - The value of the element to be added to this Map. + * + * @return {Phaser.Structs.Map} This Map object. + */ + set: function (key, value) + { + if (!this.has(key)) + { + this.entries[key] = value; + this.size++; + } + + return this; + }, + + /** + * Returns the value associated to the `key`, or `undefined` if there is none. + * + * @method Phaser.Structs.Map#get + * @since 3.0.0 + * + * @genericUse {K} - [key] + * @genericUse {V} - [$return] + * + * @param {string} key - The key of the element to return from the `Map` object. + * + * @return {*} The element associated with the specified key or `undefined` if the key can't be found in this Map object. + */ + get: function (key) + { + if (this.has(key)) + { + return this.entries[key]; + } + }, + + /** + * Returns an `Array` of all the values stored in this Map. + * + * @method Phaser.Structs.Map#getArray + * @since 3.0.0 + * + * @genericUse {V[]} - [$return] + * + * @return {Array.<*>} An array of the values stored in this Map. + */ + getArray: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * Returns a boolean indicating whether an element with the specified key exists or not. + * + * @method Phaser.Structs.Map#has + * @since 3.0.0 + * + * @genericUse {K} - [key] + * + * @param {string} key - The key of the element to test for presence of in this Map. + * + * @return {boolean} Returns `true` if an element with the specified key exists in this Map, otherwise `false`. + */ + has: function (key) + { + return (this.entries.hasOwnProperty(key)); + }, + + /** + * Delete the specified element from this Map. + * + * @method Phaser.Structs.Map#delete + * @since 3.0.0 + * + * @genericUse {K} - [key] + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @param {string} key - The key of the element to delete from this Map. + * + * @return {Phaser.Structs.Map} This Map object. + */ + delete: function (key) + { + if (this.has(key)) + { + delete this.entries[key]; + this.size--; + } + + return this; + }, + + /** + * Delete all entries from this Map. + * + * @method Phaser.Structs.Map#clear + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @return {Phaser.Structs.Map} This Map object. + */ + clear: function () + { + Object.keys(this.entries).forEach(function (prop) + { + delete this.entries[prop]; + + }, this); + + this.size = 0; + + return this; + }, + + /** + * Returns all entries keys in this Map. + * + * @method Phaser.Structs.Map#keys + * @since 3.0.0 + * + * @genericUse {K[]} - [$return] + * + * @return {string[]} Array containing entries' keys. + */ + keys: function () + { + return Object.keys(this.entries); + }, + + /** + * Returns an `Array` of all entries. + * + * @method Phaser.Structs.Map#values + * @since 3.0.0 + * + * @genericUse {V[]} - [$return] + * + * @return {Array.<*>} An `Array` of entries. + */ + values: function () + { + var output = []; + var entries = this.entries; + + for (var key in entries) + { + output.push(entries[key]); + } + + return output; + }, + + /** + * Dumps the contents of this Map to the console via `console.group`. + * + * @method Phaser.Structs.Map#dump + * @since 3.0.0 + */ + dump: function () + { + var entries = this.entries; + + // eslint-disable-next-line no-console + console.group('Map'); + + for (var key in entries) + { + console.log(key, entries[key]); + } + + // eslint-disable-next-line no-console + console.groupEnd(); + }, + + /** + * Passes all entries in this Map to the given callback. + * + * @method Phaser.Structs.Map#each + * @since 3.0.0 + * + * @genericUse {EachMapCallback.} - [callback] + * @genericUse {Phaser.Structs.Map.} - [$return] + * + * @param {EachMapCallback} callback - The callback which will receive the keys and entries held in this Map. + * + * @return {Phaser.Structs.Map} This Map object. + */ + each: function (callback) + { + var entries = this.entries; + + for (var key in entries) + { + if (callback(key, entries[key]) === false) + { + break; + } + } + + return this; + }, + + /** + * Returns `true` if the value exists within this Map. Otherwise, returns `false`. + * + * @method Phaser.Structs.Map#contains + * @since 3.0.0 + * + * @genericUse {V} - [value] + * + * @param {*} value - The value to search for. + * + * @return {boolean} `true` if the value is found, otherwise `false`. + */ + contains: function (value) + { + var entries = this.entries; + + for (var key in entries) + { + if (entries[key] === value) + { + return true; + } + } + + return false; + }, + + /** + * Merges all new keys from the given Map into this one. + * If it encounters a key that already exists it will be skipped unless override is set to `true`. + * + * @method Phaser.Structs.Map#merge + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Map.} - [map,$return] + * + * @param {Phaser.Structs.Map} map - The Map to merge in to this Map. + * @param {boolean} [override=false] - Set to `true` to replace values in this Map with those from the source map, or `false` to skip them. + * + * @return {Phaser.Structs.Map} This Map object. + */ + merge: function (map, override) + { + if (override === undefined) { override = false; } + + var local = this.entries; + var source = map.entries; + + for (var key in source) + { + if (local.hasOwnProperty(key) && override) + { + local[key] = source[key]; + } + else + { + this.set(key, source[key]); + } + } + + return this; + } + +}); + +module.exports = Map; + + +/***/ }), +/* 181 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate a smooth interpolation percentage of `x` between `min` and `max`. + * + * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, + * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, + * between 0 and 1 otherwise. + * + * @function Phaser.Math.SmoothStep + * @since 3.0.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep} + * + * @param {number} x - The input value. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The percentage of interpolation, between 0 and 1. + */ +var SmoothStep = function (x, min, max) +{ + if (x <= min) + { + return 0; + } + + if (x >= max) + { + return 1; + } + + x = (x - min) / (max - min); + + return x * x * (3 - 2 * x); +}; + +module.exports = SmoothStep; + + +/***/ }), +/* 182 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate a smoother interpolation percentage of `x` between `min` and `max`. + * + * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, + * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, + * between 0 and 1 otherwise. + * + * Produces an even smoother interpolation than {@link Phaser.Math.SmoothStep}. + * + * @function Phaser.Math.SmootherStep + * @since 3.0.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} + * + * @param {number} x - The input value. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The percentage of interpolation, between 0 and 1. + */ +var SmootherStep = function (x, min, max) +{ + x = Math.max(0, Math.min(1, (x - min) / (max - min))); + + return x * x * x * (x * (x * 6 - 15) + 10); +}; + +module.exports = SmootherStep; + + +/***/ }), +/* 183 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Math.RotateAroundDistance + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. + * @param {number} x - The horizontal coordinate to rotate around. + * @param {number} y - The vertical coordinate to rotate around. + * @param {number} angle - The angle of rotation in radians. + * @param {number} distance - [description] + * + * @return {Phaser.Geom.Point} The given point. + */ +var RotateAroundDistance = function (point, x, y, angle, distance) +{ + var t = angle + Math.atan2(point.y - y, point.x - x); + + point.x = x + (distance * Math.cos(t)); + point.y = y + (distance * Math.sin(t)); + + return point; +}; + +module.exports = RotateAroundDistance; + + +/***/ }), +/* 184 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Random = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + // Basis vectors + var ux = triangle.x2 - triangle.x1; + var uy = triangle.y2 - triangle.y1; + + var vx = triangle.x3 - triangle.x1; + var vy = triangle.y3 - triangle.y1; + + // Random point within the unit square + var r = Math.random(); + var s = Math.random(); + + // Point outside the triangle? Remap it. + if (r + s >= 1) + { + r = 1 - r; + s = 1 - s; + } + + out.x = triangle.x1 + ((ux * r) + (vx * s)); + out.y = triangle.y1 + ((uy * r) + (vy * s)); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 185 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); /** * Returns a uniformly distributed random point from anywhere within the given Ellipse. @@ -33146,7 +42649,136 @@ module.exports = Random; /***/ }), -/* 135 */ +/* 186 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the WebGL rendering pipeline of a Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline + * @webglOnly + * @since 3.0.0 + */ + +var Pipeline = { + + /** + * The initial WebGL pipeline of this Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + defaultPipeline: null, + + /** + * The current WebGL pipeline of this Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline#pipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + pipeline: null, + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#initPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} [pipelineName=TextureTintPipeline] - The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + initPipeline: function (pipelineName) + { + if (pipelineName === undefined) { pipelineName = 'TextureTintPipeline'; } + + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.defaultPipeline = renderer.getPipeline(pipelineName); + this.pipeline = this.defaultPipeline; + + return true; + } + + return false; + }, + + /** + * Sets the active WebGL Pipeline of this Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#setPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * + * @return {this} This Game Object instance. + */ + setPipeline: function (pipelineName) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.pipeline = renderer.getPipeline(pipelineName); + } + + return this; + }, + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * + * @method Phaser.GameObjects.Components.Pipeline#resetPipeline + * @webglOnly + * @since 3.0.0 + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + resetPipeline: function () + { + this.pipeline = this.defaultPipeline; + + return (this.pipeline !== null); + }, + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + * + * @method Phaser.GameObjects.Components.Pipeline#getPipelineName + * @webglOnly + * @since 3.0.0 + * + * @return {string} The string-based name of the pipeline being used by this Game Object. + */ + getPipelineName: function () + { + return this.pipeline.name; + } + +}; + +module.exports = Pipeline; + + +/***/ }), +/* 187 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -33155,8 +42787,151 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Perimeter = __webpack_require__(97); -var Point = __webpack_require__(5); +var Point = __webpack_require__(6); + +/** + * Returns a random point within a Rectangle. + * + * @function Phaser.Geom.Rectangle.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to return a point from. + * @param {Phaser.Geom.Point} out - The object to update with the point's coordinates. + * + * @return {Phaser.Geom.Point} The modified `out` object, or a new Point if none was provided. + */ +var Random = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.x + (Math.random() * rect.width); + out.y = rect.y + (Math.random() * rect.height); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 188 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns a random point on a given Line. + * + * @function Phaser.Geom.Line.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The Line to calculate the random Point on. + * @param {(Phaser.Geom.Point|object)} [out] - An instance of a Point to be modified. + * + * @return {(Phaser.Geom.Point|object)} A random Point on the Line. + */ +var Random = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + var t = Math.random(); + + out.x = line.x1 + t * (line.x2 - line.x1); + out.y = line.y1 + t * (line.y2 - line.y1); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 189 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); +var Point = __webpack_require__(6); + +/** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * @function Phaser.Geom.Line.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line. + * @param {integer} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {number} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param {(array|Phaser.Geom.Point[])} [out] - An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * + * @return {(array|Phaser.Geom.Point[])} An array of Points, or point-like objects, containing the coordinates of the points on the line. + */ +var GetPoints = function (line, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Length(line) / stepRate; + } + + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + var x = x1 + (x2 - x1) * position; + var y = y1 + (y2 - y1) * position; + + out.push(new Point(x, y)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 190 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Perimeter = __webpack_require__(124); +var Point = __webpack_require__(6); /** * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. @@ -33167,7 +42942,7 @@ var Point = __webpack_require__(5); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [out] - [description] * * @return {Phaser.Geom.Point} [description] @@ -33223,7 +42998,7 @@ module.exports = GetPoint; /***/ }), -/* 136 */ +/* 191 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -33232,2288 +43007,7 @@ module.exports = GetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -/** - * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * - * @function Phaser.Geom.Circle.CircumferencePoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. - * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. - * - * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. - */ -var CircumferencePoint = function (circle, angle, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = circle.x + (circle.radius * Math.cos(angle)); - out.y = circle.y + (circle.radius * Math.sin(angle)); - - return out; -}; - -module.exports = CircumferencePoint; - - -/***/ }), -/* 137 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A Tileset is a combination of an image containing the tiles and a container for data about - * each tile. - * - * @class Tileset - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {string} name - The name of the tileset in the map data. - * @param {integer} firstgid - The first tile index this tileset contains. - * @param {integer} [tileWidth=32] - Width of each tile (in pixels). - * @param {integer} [tileHeight=32] - Height of each tile (in pixels). - * @param {integer} [tileMargin=0] - The margin around all tiles in the sheet (in pixels). - * @param {integer} [tileSpacing=0] - The spacing between each tile in the sheet (in pixels). - * @param {object} [tileProperties={}] - Custom properties defined per tile in the Tileset. - * These typically are custom properties created in Tiled when editing a tileset. - * @param {object} [tileData={}] - Data stored per tile. These typically are created in Tiled - * when editing a tileset, e.g. from Tiled's tile collision editor or terrain editor. - */ -var Tileset = new Class({ - - initialize: - - function Tileset (name, firstgid, tileWidth, tileHeight, tileMargin, tileSpacing, tileProperties, tileData) - { - if (tileWidth === undefined || tileWidth <= 0) { tileWidth = 32; } - if (tileHeight === undefined || tileHeight <= 0) { tileHeight = 32; } - if (tileMargin === undefined) { tileMargin = 0; } - if (tileSpacing === undefined) { tileSpacing = 0; } - if (tileProperties === undefined) { tileProperties = {}; } - if (tileData === undefined) { tileData = {}; } - - /** - * The name of the Tileset. - * - * @name Phaser.Tilemaps.Tileset#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The starting index of the first tile index this Tileset contains. - * - * @name Phaser.Tilemaps.Tileset#firstgid - * @type {integer} - * @since 3.0.0 - */ - this.firstgid = firstgid; - - /** - * The width of each tile (in pixels). Use setTileSize to change. - * - * @name Phaser.Tilemaps.Tileset#tileWidth - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileWidth = tileWidth; - - /** - * The height of each tile (in pixels). Use setTileSize to change. - * - * @name Phaser.Tilemaps.Tileset#tileHeight - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileHeight = tileHeight; - - /** - * The margin around the tiles in the sheet (in pixels). Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.Tileset#tileMargin - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileMargin = tileMargin; - - /** - * The spacing between each the tile in the sheet (in pixels). Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.Tileset#tileSpacing - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.tileSpacing = tileSpacing; - - /** - * Tileset-specific properties per tile that are typically defined in the Tiled editor in the - * Tileset editor. - * - * @name Phaser.Tilemaps.Tileset#tileProperties - * @type {object} - * @since 3.0.0 - */ - this.tileProperties = tileProperties; - - /** - * Tileset-specific data per tile that are typically defined in the Tiled editor, e.g. within - * the Tileset collision editor. This is where collision objects and terrain are stored. - * - * @name Phaser.Tilemaps.Tileset#tileData - * @type {object} - * @since 3.0.0 - */ - this.tileData = tileData; - - /** - * The cached image that contains the individual tiles. Use setImage to set. - * - * @name Phaser.Tilemaps.Tileset#image - * @type {?Phaser.Textures.Texture} - * @readOnly - * @since 3.0.0 - */ - this.image = null; - - /** - * The number of tile rows in the the tileset. - * - * @name Phaser.Tilemaps.Tileset#rows - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.rows = 0; - - /** - * The number of tile columns in the tileset. - * - * @name Phaser.Tilemaps.Tileset#columns - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.columns = 0; - - /** - * The total number of tiles in the tileset. - * - * @name Phaser.Tilemaps.Tileset#total - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.total = 0; - - /** - * The look-up table to specific tile image texture coordinates (UV in pixels). Each element - * contains the coordinates for a tile in an object of the form {x, y}. - * - * @name Phaser.Tilemaps.Tileset#texCoordinates - * @type {object[]} - * @readOnly - * @since 3.0.0 - */ - this.texCoordinates = []; - }, - - /** - * Get a tiles properties that are stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined in Tiled under the Tileset editor. - * - * @method Phaser.Tilemaps.Tileset#getTileProperties - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {?(object|undefined)} - */ - getTileProperties: function (tileIndex) - { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.tileProperties[tileIndex - this.firstgid]; - }, - - /** - * Get a tile's data that is stored in the Tileset. Returns null if tile index is not contained - * in this Tileset. This is typically defined in Tiled and will contain both Tileset collision - * info and terrain mapping. - * - * @method Phaser.Tilemaps.Tileset#getTileData - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {?object|undefined} - */ - getTileData: function (tileIndex) - { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.tileData[tileIndex - this.firstgid]; - }, - - /** - * Get a tile's collision group that is stored in the Tileset. Returns null if tile index is not - * contained in this Tileset. This is typically defined within Tiled's tileset collision editor. - * - * @method Phaser.Tilemaps.Tileset#getTileCollisionGroup - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {?object} - */ - getTileCollisionGroup: function (tileIndex) - { - var data = this.getTileData(tileIndex); - - return (data && data.objectgroup) ? data.objectgroup : null; - }, - - /** - * Returns true if and only if this Tileset contains the given tile index. - * - * @method Phaser.Tilemaps.Tileset#containsTileIndex - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {boolean} - */ - containsTileIndex: function (tileIndex) - { - return ( - tileIndex >= this.firstgid && - tileIndex < (this.firstgid + this.total) - ); - }, - - /** - * Returns the texture coordinates (UV in pixels) in the Tileset image for the given tile index. - * Returns null if tile index is not contained in this Tileset. - * - * @method Phaser.Tilemaps.Tileset#getTileTextureCoordinates - * @since 3.0.0 - * - * @param {integer} tileIndex - The unique id of the tile across all tilesets in the map. - * - * @return {?object} Object in the form { x, y } representing the top-left UV coordinate - * within the Tileset image. - */ - getTileTextureCoordinates: function (tileIndex) - { - if (!this.containsTileIndex(tileIndex)) { return null; } - - return this.texCoordinates[tileIndex - this.firstgid]; - }, - - /** - * Sets the image associated with this Tileset and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setImage - * @since 3.0.0 - * - * @param {Phaser.Textures.Texture} texture - The image that contains the tiles. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setImage: function (texture) - { - this.image = texture; - - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - - return this; - }, - - /** - * Sets the tile width & height and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setTileSize - * @since 3.0.0 - * - * @param {integer} [tileWidth] - The width of a tile in pixels. - * @param {integer} [tileHeight] - The height of a tile in pixels. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setTileSize: function (tileWidth, tileHeight) - { - if (tileWidth !== undefined) { this.tileWidth = tileWidth; } - if (tileHeight !== undefined) { this.tileHeight = tileHeight; } - - if (this.image) - { - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - } - - return this; - }, - - /** - * Sets the tile margin & spacing and updates the tile data (rows, columns, etc.). - * - * @method Phaser.Tilemaps.Tileset#setSpacing - * @since 3.0.0 - * - * @param {integer} [margin] - The margin around the tiles in the sheet (in pixels). - * @param {integer} [spacing] - The spacing between the tiles in the sheet (in pixels). - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - setSpacing: function (margin, spacing) - { - if (margin !== undefined) { this.tileMargin = margin; } - if (spacing !== undefined) { this.tileSpacing = spacing; } - - if (this.image) - { - this.updateTileData(this.image.source[0].width, this.image.source[0].height); - } - - return this; - }, - - /** - * Updates tile texture coordinates and tileset data. - * - * @method Phaser.Tilemaps.Tileset#updateTileData - * @since 3.0.0 - * - * @param {integer} imageWidth - The (expected) width of the image to slice. - * @param {integer} imageHeight - The (expected) height of the image to slice. - * - * @return {Phaser.Tilemaps.Tileset} This Tileset object. - */ - updateTileData: function (imageWidth, imageHeight) - { - var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing); - var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing); - - if (rowCount % 1 !== 0 || colCount % 1 !== 0) - { - console.warn('Tileset ' + this.name + ' image tile area is not an even multiple of tile size'); - } - - // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated - // - hence the floor when calculating the rows/columns. - rowCount = Math.floor(rowCount); - colCount = Math.floor(colCount); - - this.rows = rowCount; - this.columns = colCount; - - // In Tiled, "empty" spaces in a tileset count as tiles and hence count towards the gid - this.total = rowCount * colCount; - - this.texCoordinates.length = 0; - - var tx = this.tileMargin; - var ty = this.tileMargin; - - for (var y = 0; y < this.rows; y++) - { - for (var x = 0; x < this.columns; x++) - { - this.texCoordinates.push({ x: tx, y: ty }); - tx += this.tileWidth + this.tileSpacing; - } - - tx = this.tileMargin; - ty += this.tileHeight + this.tileSpacing; - } - - return this; - } - -}); - -module.exports = Tileset; - - -/***/ }), -/* 138 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.TileToWorldY - * @private - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} - */ -var TileToWorldY = function (tileY, camera, layer) -{ - var tileHeight = layer.baseTileHeight; - var tilemapLayer = layer.tilemapLayer; - var layerWorldY = 0; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - layerWorldY = (tilemapLayer.y + camera.scrollY * (1 - tilemapLayer.scrollFactorY)); - - tileHeight *= tilemapLayer.scaleY; - } - - return layerWorldY + tileY * tileHeight; -}; - -module.exports = TileToWorldY; - - -/***/ }), -/* 139 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layer's position, scale and scroll. - * - * @function Phaser.Tilemaps.Components.TileToWorldX - * @private - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {number} - */ -var TileToWorldX = function (tileX, camera, layer) -{ - var tileWidth = layer.baseTileWidth; - var tilemapLayer = layer.tilemapLayer; - var layerWorldX = 0; - - if (tilemapLayer) - { - if (camera === undefined) { camera = tilemapLayer.scene.cameras.main; } - - layerWorldX = tilemapLayer.x + camera.scrollX * (1 - tilemapLayer.scrollFactorX); - - tileWidth *= tilemapLayer.scaleX; - } - - return layerWorldX + tileX * tileWidth; -}; - -module.exports = TileToWorldX; - - -/***/ }), -/* 140 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsInLayerBounds = __webpack_require__(105); - -/** - * Gets a tile at the given tile coordinates from the given layer. - * - * @function Phaser.Tilemaps.Components.GetTileAt - * @private - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ -var GetTileAt = function (tileX, tileY, nonNull, layer) -{ - if (nonNull === undefined) { nonNull = false; } - - if (IsInLayerBounds(tileX, tileY, layer)) - { - var tile = layer.data[tileY][tileX]; - if (tile === null) - { - return null; - } - else if (tile.index === -1) - { - return nonNull ? tile : null; - } - else - { - return tile; - } - } - else - { - return null; - } -}; - -module.exports = GetTileAt; - - -/***/ }), -/* 141 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps.Components - */ - -module.exports = { - - CalculateFacesAt: __webpack_require__(220), - CalculateFacesWithin: __webpack_require__(40), - Copy: __webpack_require__(667), - CreateFromTiles: __webpack_require__(666), - CullTiles: __webpack_require__(665), - Fill: __webpack_require__(664), - FilterTiles: __webpack_require__(663), - FindByIndex: __webpack_require__(662), - FindTile: __webpack_require__(661), - ForEachTile: __webpack_require__(660), - GetTileAt: __webpack_require__(140), - GetTileAtWorldXY: __webpack_require__(659), - GetTilesWithin: __webpack_require__(21), - GetTilesWithinShape: __webpack_require__(658), - GetTilesWithinWorldXY: __webpack_require__(657), - HasTileAt: __webpack_require__(321), - HasTileAtWorldXY: __webpack_require__(656), - IsInLayerBounds: __webpack_require__(105), - PutTileAt: __webpack_require__(219), - PutTileAtWorldXY: __webpack_require__(655), - PutTilesAt: __webpack_require__(654), - Randomize: __webpack_require__(653), - RemoveTileAt: __webpack_require__(320), - RemoveTileAtWorldXY: __webpack_require__(652), - RenderDebug: __webpack_require__(651), - ReplaceByIndex: __webpack_require__(322), - SetCollision: __webpack_require__(650), - SetCollisionBetween: __webpack_require__(649), - SetCollisionByExclusion: __webpack_require__(648), - SetCollisionByProperty: __webpack_require__(647), - SetCollisionFromCollisionGroup: __webpack_require__(646), - SetTileIndexCallback: __webpack_require__(645), - SetTileLocationCallback: __webpack_require__(644), - Shuffle: __webpack_require__(643), - SwapByIndex: __webpack_require__(642), - TileToWorldX: __webpack_require__(139), - TileToWorldXY: __webpack_require__(641), - TileToWorldY: __webpack_require__(138), - WeightedRandomize: __webpack_require__(640), - WorldToTileX: __webpack_require__(53), - WorldToTileXY: __webpack_require__(639), - WorldToTileY: __webpack_require__(52) - -}; - - -/***/ }), -/* 142 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(343); -var Sprite = __webpack_require__(34); - -/** - * @classdesc - * An Arcade Physics Sprite Game Object. - * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. - * - * @class Sprite - * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Arcade.Components.Acceleration - * @extends Phaser.Physics.Arcade.Components.Angular - * @extends Phaser.Physics.Arcade.Components.Bounce - * @extends Phaser.Physics.Arcade.Components.Debug - * @extends Phaser.Physics.Arcade.Components.Drag - * @extends Phaser.Physics.Arcade.Components.Enable - * @extends Phaser.Physics.Arcade.Components.Friction - * @extends Phaser.Physics.Arcade.Components.Gravity - * @extends Phaser.Physics.Arcade.Components.Immovable - * @extends Phaser.Physics.Arcade.Components.Mass - * @extends Phaser.Physics.Arcade.Components.Size - * @extends Phaser.Physics.Arcade.Components.Velocity - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var ArcadeSprite = new Class({ - - Extends: Sprite, - - Mixins: [ - Components.Acceleration, - Components.Angular, - Components.Bounce, - Components.Debug, - Components.Drag, - Components.Enable, - Components.Friction, - Components.Gravity, - Components.Immovable, - Components.Mass, - Components.Size, - Components.Velocity - ], - - initialize: - - function ArcadeSprite (scene, x, y, texture, frame) - { - Sprite.call(this, scene, x, y, texture, frame); - - /** - * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. - * - * @name Phaser.Physics.Arcade.Sprite#body - * @type {?Phaser.Physics.Arcade.Body} - * @default null - * @since 3.0.0 - */ - this.body = null; - } - -}); - -module.exports = ArcadeSprite; - - -/***/ }), -/* 143 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); -var ParseXML = __webpack_require__(270); - -/** - * @typedef {object} Phaser.Loader.FileTypes.XMLFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='xml'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single XML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#xml method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#xml. - * - * @class XMLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var XMLFile = new Class({ - - Extends: File, - - initialize: - - function XMLFile (loader, key, url, xhrSettings) - { - var extension = 'xml'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'xml', - cache: loader.cacheManager.xml, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.XMLFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = ParseXML(this.xhrLoader.responseText); - - if (this.data) - { - this.onProcessComplete(); - } - else - { - console.warn('Invalid XMLFile: ' + this.key); - - this.onProcessError(); - } - } - -}); - -/** - * Adds an XML file, or array of XML files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.xml('wavedata', 'files/AlienWaveData.xml'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global XML Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the XML Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the XML Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.xml({ - * key: 'wavedata', - * url: 'files/AlienWaveData.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.XMLFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.xml('wavedata', 'files/AlienWaveData.xml'); - * // and later in your game ... - * var data = this.cache.xml.get('wavedata'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the XML Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" - * and no URL is given then the Loader will set the URL to be "data.xml". It will always add `.xml` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the XML File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#xml - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.XMLFileConfig|Phaser.Loader.FileTypes.XMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('xml', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new XMLFile(this, key[i])); - } - } - else - { - this.addFile(new XMLFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = XMLFile; - - -/***/ }), -/* 144 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// This is based off an explanation and expanded math presented by Paul Bourke: -// See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.LineToLine - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line1 - [description] - * @param {Phaser.Geom.Line} line2 - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {boolean} [description] - */ -var LineToLine = function (line1, line2, out) -{ - if (out === undefined) { out = new Point(); } - - var x1 = line1.x1; - var y1 = line1.y1; - var x2 = line1.x2; - var y2 = line1.y2; - - var x3 = line2.x1; - var y3 = line2.y1; - var x4 = line2.x2; - var y4 = line2.y2; - - var numA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3); - var numB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3); - var deNom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1); - - // Make sure there is not a division by zero - this also indicates that the lines are parallel. - // If numA and numB were both equal to zero the lines would be on top of each other (coincidental). - // This check is not done because it is not necessary for this implementation (the parallel check accounts for this). - - if (deNom === 0) - { - return false; - } - - // Calculate the intermediate fractional point that the lines potentially intersect. - - var uA = numA / deNom; - var uB = numB / deNom; - - // The fractional point will be between 0 and 1 inclusive if the lines intersect. - // If the fractional calculation is larger than 1 or smaller than 0 the lines would need to be longer to intersect. - - if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) - { - out.x = x1 + (uA * (x2 - x1)); - out.y = y1 + (uA * (y2 - y1)); - - return true; - } - - return false; -}; - -module.exports = LineToLine; - - -/***/ }), -/* 145 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var MeshRender = __webpack_require__(862); - -/** - * @classdesc - * A Mesh Game Object. - * - * @class Mesh - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @webglOnly - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number[]} vertices - An array containing the vertices data for this Mesh. - * @param {number[]} uv - An array containing the uv data for this Mesh. - * @param {number[]} colors - An array containing the color data for this Mesh. - * @param {number[]} alphas - An array containing the alpha data for this Mesh. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Mesh = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Size, - Components.Texture, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - MeshRender - ], - - initialize: - - function Mesh (scene, x, y, vertices, uv, colors, alphas, texture, frame) - { - GameObject.call(this, scene, 'Mesh'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOrigin(); - this.initPipeline('TextureTintPipeline'); - - if (vertices.length !== uv.length) - { - throw new Error('Mesh Vertex count must match UV count'); - } - - var verticesUB = (vertices.length / 2) | 0; - - if (colors.length > 0 && colors.length < verticesUB) - { - throw new Error('Mesh Color count must match Vertex count'); - } - - if (alphas.length > 0 && alphas.length < verticesUB) - { - throw new Error('Mesh Alpha count must match Vertex count'); - } - - var i; - - if (colors.length === 0) - { - for (i = 0; i < verticesUB; ++i) - { - colors[i] = 0xFFFFFF; - } - } - - if (alphas.length === 0) - { - for (i = 0; i < verticesUB; ++i) - { - alphas[i] = 1.0; - } - } - - /** - * An array containing the vertices data for this Mesh. - * - * @name Phaser.GameObjects.Mesh#vertices - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertices = new Float32Array(vertices); - - /** - * An array containing the uv data for this Mesh. - * - * @name Phaser.GameObjects.Mesh#uv - * @type {Float32Array} - * @since 3.0.0 - */ - this.uv = new Float32Array(uv); - - /** - * An array containing the color data for this Mesh. - * - * @name Phaser.GameObjects.Mesh#colors - * @type {Uint32Array} - * @since 3.0.0 - */ - this.colors = new Uint32Array(colors); - - /** - * An array containing the alpha data for this Mesh. - * - * @name Phaser.GameObjects.Mesh#alphas - * @type {Float32Array} - * @since 3.0.0 - */ - this.alphas = new Float32Array(alphas); - } - -}); - -module.exports = Mesh; - - -/***/ }), -/* 146 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns a Random element from the array. - * - * @function Phaser.Utils.Array.GetRandom - * @since 3.0.0 - * - * @param {array} array - The array to select the random entry from. - * @param {integer} [startIndex=0] - An optional start index. - * @param {integer} [length=array.length] - An optional length, the total number of elements (from the startIndex) to choose from. - * - * @return {object} A random element from the array, or `null` if no element could be found in the range given. - */ -var GetRandom = function (array, startIndex, length) -{ - if (startIndex === undefined) { startIndex = 0; } - if (length === undefined) { length = array.length; } - - var randomIndex = startIndex + Math.floor(Math.random() * length); - - return (array[randomIndex] === undefined) ? null : array[randomIndex]; -}; - -module.exports = GetRandom; - - -/***/ }), -/* 147 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils.Array - */ - -module.exports = { - - Matrix: __webpack_require__(503), - - Add: __webpack_require__(496), - AddAt: __webpack_require__(495), - BringToTop: __webpack_require__(494), - CountAllMatching: __webpack_require__(493), - Each: __webpack_require__(492), - EachInRange: __webpack_require__(491), - FindClosestInSorted: __webpack_require__(209), - GetAll: __webpack_require__(490), - GetFirst: __webpack_require__(489), - GetRandom: __webpack_require__(146), - MoveDown: __webpack_require__(488), - MoveTo: __webpack_require__(487), - MoveUp: __webpack_require__(486), - NumberArray: __webpack_require__(485), - NumberArrayStep: __webpack_require__(484), - QuickSelect: __webpack_require__(180), - Range: __webpack_require__(254), - Remove: __webpack_require__(195), - RemoveAt: __webpack_require__(483), - RemoveBetween: __webpack_require__(482), - RemoveRandomElement: __webpack_require__(481), - Replace: __webpack_require__(480), - RotateLeft: __webpack_require__(290), - RotateRight: __webpack_require__(289), - SafeRange: __webpack_require__(29), - SendToBack: __webpack_require__(479), - SetAll: __webpack_require__(478), - Shuffle: __webpack_require__(95), - SpliceOne: __webpack_require__(56), - StableSort: __webpack_require__(83), - Swap: __webpack_require__(477) - -}; - - -/***/ }), -/* 148 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(527); -var TextureTintPipeline = __webpack_require__(129); - -var LIGHT_COUNT = 10; - -/** - * @classdesc - * ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights. - * This pipeline extends TextureTintPipeline so it implements all it's rendering functions - * and batching system. - * - * @class ForwardDiffuseLightPipeline - * @extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - */ -var ForwardDiffuseLightPipeline = new Class({ - - Extends: TextureTintPipeline, - - initialize: - - function ForwardDiffuseLightPipeline (config) - { - config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); - - TextureTintPipeline.call(this, config); - }, - - /** - * This function binds it's base class resources and this lights 2D resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onBind - * @override - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline} [description] - */ - onBind: function () - { - TextureTintPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - this.mvpUpdate(); - - renderer.setInt1(program, 'uNormSampler', 1); - renderer.setFloat2(program, 'uResolution', this.width, this.height); - - return this; - }, - - /** - * This function sets all the needed resources for each camera pass. - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onRender - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline} [description] - */ - onRender: function (scene, camera) - { - this.active = false; - - var lightManager = scene.sys.lights; - - if (!lightManager || lightManager.lights.length <= 0 || !lightManager.active) - { - // Passthru - return this; - } - - var lights = lightManager.cull(camera); - var lightCount = Math.min(lights.length, LIGHT_COUNT); - - if (lightCount === 0) - { - return this; - } - - this.active = true; - - var renderer = this.renderer; - var program = this.program; - var cameraMatrix = camera.matrix; - var point = {x: 0, y: 0}; - var height = renderer.height; - var index; - - for (index = 0; index < LIGHT_COUNT; ++index) - { - // Reset lights - renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); - } - - renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); - renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); - - for (index = 0; index < lightCount; ++index) - { - var light = lights[index]; - var lightName = 'uLights[' + index + '].'; - - cameraMatrix.transformPoint(light.x, light.y, point); - - renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); - renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); - renderer.setFloat1(program, lightName + 'intensity', light.intensity); - renderer.setFloat1(program, lightName + 'radius', light.radius); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawStaticTilemapLayer - * @override - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawStaticTilemapLayer: function (tilemap, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tilemap.tileset.image.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. StaticTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - drawEmitterManager: function (emitterManager, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = emitterManager.texture.dataSource[emitterManager.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. EmitterManager rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - drawBlitter: function (blitter, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = blitter.texture.dataSource[blitter.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Blitter rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchSprite: function (sprite, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = sprite.texture.dataSource[sprite.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Sprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchMesh: function (mesh, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = mesh.texture.dataSource[mesh.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Mesh rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera, parentTransformMatrix); - - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = bitmapText.texture.dataSource[bitmapText.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. BitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var normalTexture = bitmapText.texture.dataSource[bitmapText.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicBitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchText: function (text, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = text.texture.dataSource[text.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchText.call(this, text, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Text rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchText(text, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tilemapLayer.tileset.image.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchTileSprite: function (tileSprite, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tileSprite.texture.dataSource[tileSprite.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. TileSprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera, parentTransformMatrix); - } - } - -}); - -ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; - -module.exports = ForwardDiffuseLightPipeline; - - -/***/ }), -/* 149 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compute a random integer between the `min` and `max` values, inclusive. - * - * @function Phaser.Math.Between - * @since 3.0.0 - * - * @param {integer} min - The minimum value. - * @param {integer} max - The maximum value. - * - * @return {integer} The random integer. - */ -var Between = function (min, max) -{ - return Math.floor(Math.random() * (max - min + 1) + min); -}; - -module.exports = Between; - - -/***/ }), -/* 150 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); - -/** - * Convert the given angle in radians, to the equivalent angle in degrees. - * - * @function Phaser.Math.RadToDeg - * @since 3.0.0 - * - * @param {float} radians - The angle in radians to convert ot degrees. - * - * @return {integer} The given angle converted to degrees. - */ -var RadToDeg = function (radians) -{ - return radians * CONST.RAD_TO_DEG; -}; - -module.exports = RadToDeg; - - -/***/ }), -/* 151 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GameObject = __webpack_require__(2); -var Sprite = __webpack_require__(34); -var Vector2 = __webpack_require__(6); -var Vector4 = __webpack_require__(277); - -/** - * @classdesc - * A Sprite 3D Game Object. - * - * The Sprite 3D object is an encapsulation of a standard Sprite object, with additional methods to allow - * it to be rendered by a 3D Camera. The Sprite can be positioned anywhere within 3D space. - * - * @class Sprite3D - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The x position of this Game Object. - * @param {number} y - The y position of this Game Object. - * @param {number} z - The z position of this Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Sprite3D = new Class({ - - Extends: GameObject, - - initialize: - - function Sprite3D (scene, x, y, z, texture, frame) - { - GameObject.call(this, scene, 'Sprite3D'); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = new Sprite(scene, 0, 0, texture, frame); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#position - * @type {Phaser.Math.Vector4} - * @since 3.0.0 - */ - this.position = new Vector4(x, y, z); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#size - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.size = new Vector2(this.gameObject.width, this.gameObject.height); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#scale - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.scale = new Vector2(1, 1); - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#adjustScaleX - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.adjustScaleX = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#adjustScaleY - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.adjustScaleY = true; - - /** - * [description] - * - * @name Phaser.GameObjects.Sprite3D#_visible - * @type {boolean} - * @default true - * @private - * @since 3.0.0 - */ - this._visible = true; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite3D#project - * @since 3.0.0 - * - * @param {Phaser.Cameras.Sprite3D.Camera} camera - The 3D Camera onto which to project this Sprite. - */ - project: function (camera) - { - var pos = this.position; - - var gameObject = this.gameObject; - - camera.project(pos, gameObject); - - camera.getPointSize(pos, this.size, this.scale); - - if (this.scale.x <= 0 || this.scale.y <= 0) - { - gameObject.setVisible(false); - } - else - { - if (!gameObject.visible) - { - gameObject.setVisible(true); - } - - if (this.adjustScaleX) - { - gameObject.scaleX = this.scale.x; - } - - if (this.adjustScaleY) - { - gameObject.scaleY = this.scale.y; - } - - gameObject.setDepth(gameObject.z * -1); - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Sprite3D#setVisible - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {Phaser.GameObjects.Sprite3D} This Sprite3D Object. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @name Phaser.GameObjects.Sprite3D#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - this._visible = value; - this.gameObject.visible = value; - } - - }, - - /** - * The x position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - } - - }, - - /** - * The y position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - } - - }, - - /** - * The z position of this Game Object. - * - * @name Phaser.GameObjects.Sprite3D#z - * @type {number} - * @since 3.0.0 - */ - z: { - - get: function () - { - return this.position.z; - }, - - set: function (value) - { - this.position.z = value; - } - - } - -}); - -module.exports = Sprite3D; - - -/***/ }), -/* 152 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Given 3 separate color values this will return an integer representation of it. - * - * @function Phaser.Display.Color.GetColor - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * - * @return {number} The combined color value. - */ -var GetColor = function (red, green, blue) -{ - return red << 16 | green << 8 | blue; -}; - -module.exports = GetColor; - - -/***/ }), -/* 153 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Random = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - - // Basis vectors - var ux = triangle.x2 - triangle.x1; - var uy = triangle.y2 - triangle.y1; - - var vx = triangle.x3 - triangle.x1; - var vy = triangle.y3 - triangle.y1; - - // Random point within the unit square - var r = Math.random(); - var s = Math.random(); - - // Point outside the triangle? Remap it. - if (r + s >= 1) - { - r = 1 - r; - s = 1 - s; - } - - out.x = triangle.x1 + ((ux * r) + (vx * s)); - out.y = triangle.y1 + ((uy * r) + (vy * s)); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 154 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} out - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Random = function (rect, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = rect.x + (Math.random() * rect.width); - out.y = rect.y + (Math.random() * rect.height); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 155 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * Returns a random point on a given Line. - * - * @function Phaser.Geom.Line.Random - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - The Line to calculate the random Point on. - * @param {(Phaser.Geom.Point|object)} [out] - An instance of a Point to be modified. - * - * @return {(Phaser.Geom.Point|object)} A random Point on the Line. - */ -var Random = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - var t = Math.random(); - - out.x = line.x1 + t * (line.x2 - line.x1); - out.y = line.y1 + t * (line.y2 - line.y1); - - return out; -}; - -module.exports = Random; - - -/***/ }), -/* 156 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(71); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ -var GetPoints = function (line, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = Length(line) / stepRate; - } - - var x1 = line.x1; - var y1 = line.y1; - - var x2 = line.x2; - var y2 = line.y2; - - for (var i = 0; i < quantity; i++) - { - var position = i / quantity; - - var x = x1 + (x2 - x1) * position; - var y = y1 + (y2 - y1) * position; - - out.push(new Point(x, y)); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 157 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); +var Point = __webpack_require__(6); /** * Returns a uniformly distributed random point from anywhere within the given Circle. @@ -35548,7 +43042,7 @@ module.exports = Random; /***/ }), -/* 158 */ +/* 192 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -35557,287 +43051,3068 @@ module.exports = Random; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlendModes = __webpack_require__(51); -var Circle = __webpack_require__(88); -var CircleContains = __webpack_require__(32); +var Point = __webpack_require__(6); + +/** + * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. + * + * @function Phaser.Geom.Circle.CircumferencePoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. + * @param {number} angle - The angle from the center of the Circle to the circumference to return the point from. Given in radians. + * @param {(Phaser.Geom.Point|object)} [out] - A Point, or point-like object, to store the results in. If not given a Point will be created. + * + * @return {(Phaser.Geom.Point|object)} A Point object where the `x` and `y` properties are the point on the circumference. + */ +var CircumferencePoint = function (circle, angle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = circle.x + (circle.radius * Math.cos(angle)); + out.y = circle.y + (circle.radius * Math.sin(angle)); + + return out; +}; + +module.exports = CircumferencePoint; + + +/***/ }), +/* 193 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ALIGN_CONST = { + + /** + * A constant representing a top-left alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_LEFT + * @since 3.0.0 + * @type {integer} + */ + TOP_LEFT: 0, + + /** + * A constant representing a top-center alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_CENTER + * @since 3.0.0 + * @type {integer} + */ + TOP_CENTER: 1, + + /** + * A constant representing a top-right alignment or position. + * @constant + * @name Phaser.Display.Align.TOP_RIGHT + * @since 3.0.0 + * @type {integer} + */ + TOP_RIGHT: 2, + + /** + * A constant representing a left-top alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_TOP + * @since 3.0.0 + * @type {integer} + */ + LEFT_TOP: 3, + + /** + * A constant representing a left-center alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_CENTER + * @since 3.0.0 + * @type {integer} + */ + LEFT_CENTER: 4, + + /** + * A constant representing a left-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.LEFT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + LEFT_BOTTOM: 5, + + /** + * A constant representing a center alignment or position. + * @constant + * @name Phaser.Display.Align.CENTER + * @since 3.0.0 + * @type {integer} + */ + CENTER: 6, + + /** + * A constant representing a right-top alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_TOP + * @since 3.0.0 + * @type {integer} + */ + RIGHT_TOP: 7, + + /** + * A constant representing a right-center alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_CENTER + * @since 3.0.0 + * @type {integer} + */ + RIGHT_CENTER: 8, + + /** + * A constant representing a right-bottom alignment or position. + * @constant + * @name Phaser.Display.Align.RIGHT_BOTTOM + * @since 3.0.0 + * @type {integer} + */ + RIGHT_BOTTOM: 9, + + /** + * A constant representing a bottom-left alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_LEFT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_LEFT: 10, + + /** + * A constant representing a bottom-center alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_CENTER + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_CENTER: 11, + + /** + * A constant representing a bottom-right alignment or position. + * @constant + * @name Phaser.Display.Align.BOTTOM_RIGHT + * @since 3.0.0 + * @type {integer} + */ + BOTTOM_RIGHT: 12 + +}; + +module.exports = ALIGN_CONST; + + +/***/ }), +/* 194 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Constraint` module contains methods for creating and manipulating constraints. +* Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). +* The stiffness of constraints can be modified to create springs or elastic. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Constraint +*/ + +var Constraint = {}; + +module.exports = Constraint; + +var Vertices = __webpack_require__(76); +var Vector = __webpack_require__(81); +var Sleeping = __webpack_require__(222); +var Bounds = __webpack_require__(80); +var Axes = __webpack_require__(505); +var Common = __webpack_require__(33); + +(function() { + + Constraint._warming = 0.4; + Constraint._torqueDampen = 1; + Constraint._minLength = 0.000001; + + /** + * Creates a new constraint. + * All properties have default values, and many are pre-calculated automatically based on other properties. + * To simulate a revolute constraint (or pin joint) set `length: 0` and a high `stiffness` value (e.g. `0.7` or above). + * If the constraint is unstable, try lowering the `stiffness` value and / or increasing `engine.constraintIterations`. + * For compound bodies, constraints must be applied to the parent body (not one of its parts). + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @param {} options + * @return {constraint} constraint + */ + Constraint.create = function(options) { + var constraint = options; + + // if bodies defined but no points, use body centre + if (constraint.bodyA && !constraint.pointA) + constraint.pointA = { x: 0, y: 0 }; + if (constraint.bodyB && !constraint.pointB) + constraint.pointB = { x: 0, y: 0 }; + + // calculate static length using initial world space points + var initialPointA = constraint.bodyA ? Vector.add(constraint.bodyA.position, constraint.pointA) : constraint.pointA, + initialPointB = constraint.bodyB ? Vector.add(constraint.bodyB.position, constraint.pointB) : constraint.pointB, + length = Vector.magnitude(Vector.sub(initialPointA, initialPointB)); + + constraint.length = typeof constraint.length !== 'undefined' ? constraint.length : length; + + // option defaults + constraint.id = constraint.id || Common.nextId(); + constraint.label = constraint.label || 'Constraint'; + constraint.type = 'constraint'; + constraint.stiffness = constraint.stiffness || (constraint.length > 0 ? 1 : 0.7); + constraint.damping = constraint.damping || 0; + constraint.angularStiffness = constraint.angularStiffness || 0; + constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA; + constraint.angleB = constraint.bodyB ? constraint.bodyB.angle : constraint.angleB; + constraint.plugin = {}; + + // render + var render = { + visible: true, + lineWidth: 2, + strokeStyle: '#ffffff', + type: 'line', + anchors: true + }; + + if (constraint.length === 0 && constraint.stiffness > 0.1) { + render.type = 'pin'; + render.anchors = false; + } else if (constraint.stiffness < 0.9) { + render.type = 'spring'; + } + + constraint.render = Common.extend(render, constraint.render); + + return constraint; + }; + + /** + * Prepares for solving by constraint warming. + * @private + * @method preSolveAll + * @param {body[]} bodies + */ + Constraint.preSolveAll = function(bodies) { + for (var i = 0; i < bodies.length; i += 1) { + var body = bodies[i], + impulse = body.constraintImpulse; + + if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { + continue; + } + + body.position.x += impulse.x; + body.position.y += impulse.y; + body.angle += impulse.angle; + } + }; + + /** + * Solves all constraints in a list of collisions. + * @private + * @method solveAll + * @param {constraint[]} constraints + * @param {number} timeScale + */ + Constraint.solveAll = function(constraints, timeScale) { + // Solve fixed constraints first. + for (var i = 0; i < constraints.length; i += 1) { + var constraint = constraints[i], + fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic), + fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); + + if (fixedA || fixedB) { + Constraint.solve(constraints[i], timeScale); + } + } + + // Solve free constraints last. + for (i = 0; i < constraints.length; i += 1) { + constraint = constraints[i]; + fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic); + fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); + + if (!fixedA && !fixedB) { + Constraint.solve(constraints[i], timeScale); + } + } + }; + + /** + * Solves a distance constraint with Gauss-Siedel method. + * @private + * @method solve + * @param {constraint} constraint + * @param {number} timeScale + */ + Constraint.solve = function(constraint, timeScale) { + var bodyA = constraint.bodyA, + bodyB = constraint.bodyB, + pointA = constraint.pointA, + pointB = constraint.pointB; + + if (!bodyA && !bodyB) + return; + + // update reference angle + if (bodyA && !bodyA.isStatic) { + Vector.rotate(pointA, bodyA.angle - constraint.angleA, pointA); + constraint.angleA = bodyA.angle; + } + + // update reference angle + if (bodyB && !bodyB.isStatic) { + Vector.rotate(pointB, bodyB.angle - constraint.angleB, pointB); + constraint.angleB = bodyB.angle; + } + + var pointAWorld = pointA, + pointBWorld = pointB; + + if (bodyA) pointAWorld = Vector.add(bodyA.position, pointA); + if (bodyB) pointBWorld = Vector.add(bodyB.position, pointB); + + if (!pointAWorld || !pointBWorld) + return; + + var delta = Vector.sub(pointAWorld, pointBWorld), + currentLength = Vector.magnitude(delta); + + // prevent singularity + if (currentLength < Constraint._minLength) { + currentLength = Constraint._minLength; + } + + // solve distance constraint with Gauss-Siedel method + var difference = (currentLength - constraint.length) / currentLength, + stiffness = constraint.stiffness < 1 ? constraint.stiffness * timeScale : constraint.stiffness, + force = Vector.mult(delta, difference * stiffness), + massTotal = (bodyA ? bodyA.inverseMass : 0) + (bodyB ? bodyB.inverseMass : 0), + inertiaTotal = (bodyA ? bodyA.inverseInertia : 0) + (bodyB ? bodyB.inverseInertia : 0), + resistanceTotal = massTotal + inertiaTotal, + torque, + share, + normal, + normalVelocity, + relativeVelocity; + + if (constraint.damping) { + var zero = Vector.create(); + normal = Vector.div(delta, currentLength); + + relativeVelocity = Vector.sub( + bodyB && Vector.sub(bodyB.position, bodyB.positionPrev) || zero, + bodyA && Vector.sub(bodyA.position, bodyA.positionPrev) || zero + ); + + normalVelocity = Vector.dot(normal, relativeVelocity); + } + + if (bodyA && !bodyA.isStatic) { + share = bodyA.inverseMass / massTotal; + + // keep track of applied impulses for post solving + bodyA.constraintImpulse.x -= force.x * share; + bodyA.constraintImpulse.y -= force.y * share; + + // apply forces + bodyA.position.x -= force.x * share; + bodyA.position.y -= force.y * share; + + // apply damping + if (constraint.damping) { + bodyA.positionPrev.x -= constraint.damping * normal.x * normalVelocity * share; + bodyA.positionPrev.y -= constraint.damping * normal.y * normalVelocity * share; + } + + // apply torque + torque = (Vector.cross(pointA, force) / resistanceTotal) * Constraint._torqueDampen * bodyA.inverseInertia * (1 - constraint.angularStiffness); + bodyA.constraintImpulse.angle -= torque; + bodyA.angle -= torque; + } + + if (bodyB && !bodyB.isStatic) { + share = bodyB.inverseMass / massTotal; + + // keep track of applied impulses for post solving + bodyB.constraintImpulse.x += force.x * share; + bodyB.constraintImpulse.y += force.y * share; + + // apply forces + bodyB.position.x += force.x * share; + bodyB.position.y += force.y * share; + + // apply damping + if (constraint.damping) { + bodyB.positionPrev.x += constraint.damping * normal.x * normalVelocity * share; + bodyB.positionPrev.y += constraint.damping * normal.y * normalVelocity * share; + } + + // apply torque + torque = (Vector.cross(pointB, force) / resistanceTotal) * Constraint._torqueDampen * bodyB.inverseInertia * (1 - constraint.angularStiffness); + bodyB.constraintImpulse.angle += torque; + bodyB.angle += torque; + } + + }; + + /** + * Performs body updates required after solving constraints. + * @private + * @method postSolveAll + * @param {body[]} bodies + */ + Constraint.postSolveAll = function(bodies) { + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + impulse = body.constraintImpulse; + + if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { + continue; + } + + Sleeping.set(body, false); + + // update geometry and reset + for (var j = 0; j < body.parts.length; j++) { + var part = body.parts[j]; + + Vertices.translate(part.vertices, impulse); + + if (j > 0) { + part.position.x += impulse.x; + part.position.y += impulse.y; + } + + if (impulse.angle !== 0) { + Vertices.rotate(part.vertices, impulse.angle, body.position); + Axes.rotate(part.axes, impulse.angle); + if (j > 0) { + Vector.rotateAbout(part.position, impulse.angle, body.position, part.position); + } + } + + Bounds.update(part.bounds, part.vertices, body.velocity); + } + + // dampen the cached impulse for warming next step + impulse.angle *= Constraint._warming; + impulse.x *= Constraint._warming; + impulse.y *= Constraint._warming; + } + }; + + /* + * + * Properties Documentation + * + */ + + /** + * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. + * + * @property id + * @type number + */ + + /** + * A `String` denoting the type of object. + * + * @property type + * @type string + * @default "constraint" + * @readOnly + */ + + /** + * An arbitrary `String` name to help the user identify and manage bodies. + * + * @property label + * @type string + * @default "Constraint" + */ + + /** + * An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`. + * + * @property render + * @type object + */ + + /** + * A flag that indicates if the constraint should be rendered. + * + * @property render.visible + * @type boolean + * @default true + */ + + /** + * A `Number` that defines the line width to use when rendering the constraint outline. + * A value of `0` means no outline will be rendered. + * + * @property render.lineWidth + * @type number + * @default 2 + */ + + /** + * A `String` that defines the stroke style to use when rendering the constraint outline. + * It is the same as when using a canvas, so it accepts CSS style property values. + * + * @property render.strokeStyle + * @type string + * @default a random colour + */ + + /** + * A `String` that defines the constraint rendering type. + * The possible values are 'line', 'pin', 'spring'. + * An appropriate render type will be automatically chosen unless one is given in options. + * + * @property render.type + * @type string + * @default 'line' + */ + + /** + * A `Boolean` that defines if the constraint's anchor points should be rendered. + * + * @property render.anchors + * @type boolean + * @default true + */ + + /** + * The first possible `Body` that this constraint is attached to. + * + * @property bodyA + * @type body + * @default null + */ + + /** + * The second possible `Body` that this constraint is attached to. + * + * @property bodyB + * @type body + * @default null + */ + + /** + * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. + * + * @property pointA + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyB` if defined, otherwise a world-space position. + * + * @property pointB + * @type vector + * @default { x: 0, y: 0 } + */ + + /** + * A `Number` that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. + * A value of `1` means the constraint should be very stiff. + * A value of `0.2` means the constraint acts like a soft spring. + * + * @property stiffness + * @type number + * @default 1 + */ + + /** + * A `Number` that specifies the damping of the constraint, + * i.e. the amount of resistance applied to each body based on their velocities to limit the amount of oscillation. + * Damping will only be apparent when the constraint also has a very low `stiffness`. + * A value of `0.1` means the constraint will apply heavy damping, resulting in little to no oscillation. + * A value of `0` means the constraint will apply no damping. + * + * @property damping + * @type number + * @default 0 + */ + + /** + * A `Number` that specifies the target resting length of the constraint. + * It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB`. + * + * @property length + * @type number + */ + + /** + * An object reserved for storing plugin-specific properties. + * + * @property plugin + * @type {} + */ + +})(); + + +/***/ }), +/* 195 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Events` module contains methods to fire and listen to events on other objects. +* +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class Events +*/ + +var Events = {}; + +module.exports = Events; + +var Common = __webpack_require__(33); + +(function() { + + /** + * Subscribes a callback function to the given object's `eventName`. + * @method on + * @param {} object + * @param {string} eventNames + * @param {function} callback + */ + Events.on = function(object, eventNames, callback) { + var names = eventNames.split(' '), + name; + + for (var i = 0; i < names.length; i++) { + name = names[i]; + object.events = object.events || {}; + object.events[name] = object.events[name] || []; + object.events[name].push(callback); + } + + return callback; + }; + + /** + * Removes the given event callback. If no callback, clears all callbacks in `eventNames`. If no `eventNames`, clears all events. + * @method off + * @param {} object + * @param {string} eventNames + * @param {function} callback + */ + Events.off = function(object, eventNames, callback) { + if (!eventNames) { + object.events = {}; + return; + } + + // handle Events.off(object, callback) + if (typeof eventNames === 'function') { + callback = eventNames; + eventNames = Common.keys(object.events).join(' '); + } + + var names = eventNames.split(' '); + + for (var i = 0; i < names.length; i++) { + var callbacks = object.events[names[i]], + newCallbacks = []; + + if (callback && callbacks) { + for (var j = 0; j < callbacks.length; j++) { + if (callbacks[j] !== callback) + newCallbacks.push(callbacks[j]); + } + } + + object.events[names[i]] = newCallbacks; + } + }; + + /** + * Fires all the callbacks subscribed to the given object's `eventName`, in the order they subscribed, if any. + * @method trigger + * @param {} object + * @param {string} eventNames + * @param {} event + */ + Events.trigger = function(object, eventNames, event) { + var names, + name, + callbacks, + eventClone; + + var events = object.events; + + if (events && Common.keys(events).length > 0) { + if (!event) + event = {}; + + names = eventNames.split(' '); + + for (var i = 0; i < names.length; i++) { + name = names[i]; + callbacks = events[name]; + + if (callbacks) { + eventClone = Common.clone(event, false); + eventClone.name = name; + eventClone.source = object; + + for (var j = 0; j < callbacks.length; j++) { + callbacks[j].apply(object, [eventClone]); + } + } + } + } + }; + +})(); + + +/***/ }), +/* 196 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var Rectangle = __webpack_require__(14); -var RectangleContains = __webpack_require__(31); +var Earcut = __webpack_require__(64); +var GetFastValue = __webpack_require__(2); +var ModelViewProjection = __webpack_require__(894); +var ShaderSourceFS = __webpack_require__(893); +var ShaderSourceVS = __webpack_require__(892); +var TransformMatrix = __webpack_require__(38); +var Utils = __webpack_require__(10); +var WebGLPipeline = __webpack_require__(197); /** * @classdesc - * A Zone Game Object. + * TextureTintPipeline implements the rendering infrastructure + * for displaying textured objects + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. * - * A Zone is a non-rendering rectangular Game Object that has a position and size. - * It has no texture and never displays, but does live on the display list and - * can be moved, scaled and rotated like any other Game Object. - * - * Its primary use is for creating Drop Zones and Input Hit Areas and it has a couple of helper methods - * specifically for this. It is also useful for object overlap checks, or as a base for your own - * non-displaying Game Objects. - - * The default origin is 0.5, the center of the Zone, the same as with Game Objects. - * - * @class Zone - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @class TextureTintPipeline + * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @memberof Phaser.Renderer.WebGL.Pipelines * @constructor * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - [description] - * @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 {number} [width=1] - The width of the Game Object. - * @param {number} [height=1] - The height of the Game Object. + * @param {object} config - [description] */ -var Zone = new Class({ +var TextureTintPipeline = new Class({ - Extends: GameObject, + Extends: WebGLPipeline, Mixins: [ - Components.Depth, - Components.GetBounds, - Components.Origin, - Components.ScaleMode, - Components.Transform, - Components.ScrollFactor, - Components.Visible + ModelViewProjection ], initialize: - function Zone (scene, x, y, width, height) + function TextureTintPipeline (config) { - if (width === undefined) { width = 1; } - if (height === undefined) { height = width; } + var rendererConfig = config.renderer.config; - GameObject.call(this, scene, 'Zone'); + // Vertex Size = attribute size added together (2 + 2 + 1 + 4) - this.setPosition(x, y); + WebGLPipeline.call(this, { + game: config.game, + renderer: config.renderer, + gl: config.renderer.gl, + topology: GetFastValue(config, 'topology', config.renderer.gl.TRIANGLES), + vertShader: GetFastValue(config, 'vertShader', ShaderSourceVS), + fragShader: GetFastValue(config, 'fragShader', ShaderSourceFS), + vertexCapacity: GetFastValue(config, 'vertexCapacity', 6 * rendererConfig.batchSize), + vertexSize: GetFastValue(config, 'vertexSize', Float32Array.BYTES_PER_ELEMENT * 5 + Uint8Array.BYTES_PER_ELEMENT * 4), + attributes: [ + { + name: 'inPosition', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: 0 + }, + { + name: 'inTexCoord', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: Float32Array.BYTES_PER_ELEMENT * 2 + }, + { + name: 'inTintEffect', + size: 1, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: Float32Array.BYTES_PER_ELEMENT * 4 + }, + { + name: 'inTint', + size: 4, + type: config.renderer.gl.UNSIGNED_BYTE, + normalized: true, + offset: Float32Array.BYTES_PER_ELEMENT * 5 + } + ] + }); /** - * The native (un-scaled) width of this Game Object. + * Float32 view of the array buffer containing the pipeline's vertices. * - * @name Phaser.GameObjects.Zone#width - * @type {number} + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewF32 + * @type {Float32Array} * @since 3.0.0 */ - this.width = width; + this.vertexViewF32 = new Float32Array(this.vertexData); /** - * The native (un-scaled) height of this Game Object. + * Uint32 view of the array buffer containing the pipeline's vertices. * - * @name Phaser.GameObjects.Zone#height - * @type {number} + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewU32 + * @type {Uint32Array} * @since 3.0.0 */ - this.height = height; + this.vertexViewU32 = new Uint32Array(this.vertexData); /** - * The Blend Mode of the Game Object. - * Although a Zone never renders, it still has a blend mode to allow it to fit seamlessly into - * display lists without causing a batch flush. + * Size of the batch. * - * @name Phaser.GameObjects.Zone#blendMode + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#maxQuads * @type {integer} * @since 3.0.0 */ - this.blendMode = BlendModes.NORMAL; + this.maxQuads = rendererConfig.batchSize; + + /** + * Collection of batch information + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batches + * @type {array} + * @since 3.1.0 + */ + this.batches = []; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + /** + * Used internally to draw stroked triangles. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tempTriangle + * @type {array} + * @private + * @since 3.12.0 + */ + this.tempTriangle = [ + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 } + ]; + + /** + * The tint effect to be applied by the shader in the next geometry draw: + * + * 0 = texture multiplied by color + * 1 = solid color + texture alpha + * 2 = solid color, no texture + * 3 = solid texture, no color + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tintEffect + * @type {number} + * @private + * @since 3.12.0 + */ + this.tintEffect = 2; + + /** + * Cached stroke tint. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#strokeTint + * @type {object} + * @private + * @since 3.12.0 + */ + this.strokeTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; + + /** + * Cached fill tint. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#fillTint + * @type {object} + * @private + * @since 3.12.0 + */ + this.fillTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; + + /** + * Internal texture frame reference. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#currentFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.12.0 + */ + this.currentFrame = { u0: 0, v0: 0, u1: 1, v1: 1 }; + + /** + * Internal path quad cache. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#firstQuad + * @type {array} + * @private + * @since 3.12.0 + */ + this.firstQuad = [ 0, 0, 0, 0, 0 ]; + + /** + * Internal path quad cache. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#prevQuad + * @type {array} + * @private + * @since 3.12.0 + */ + this.prevQuad = [ 0, 0, 0, 0, 0 ]; + + /** + * Used internally for triangulating a polygon. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#polygonCache + * @type {array} + * @private + * @since 3.12.0 + */ + this.polygonCache = []; + + this.mvpInit(); }, /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. + * Called every time the pipeline needs to be used. + * It binds all necessary resources. * - * @name Phaser.GameObjects.Zone#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.width; - }, - - set: function (value) - { - this.scaleX = value / this.width; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Zone#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.height; - }, - - set: function (value) - { - this.scaleY = value / this.height; - } - - }, - - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Zone#setSize + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#onBind * @since 3.0.0 * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * @param {boolean} [resizeInput=true] - If this Zone has a Rectangle for a hit area this argument will resize the hit area as well. - * - * @return {Phaser.GameObjects.Zone} This Game Object. + * @return {this} This WebGLPipeline instance. */ - setSize: function (width, height, resizeInput) + onBind: function () { - if (resizeInput === undefined) { resizeInput = true; } + WebGLPipeline.prototype.onBind.call(this); - this.width = width; - this.height = height; + this.mvpUpdate(); - if (resizeInput && this.input && this.input.hitArea instanceof Rectangle) + if (this.batches.length === 0) { - this.input.hitArea.width = width; - this.input.hitArea.height = height; + this.pushBatch(); } return this; }, /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. + * Resizes this pipeline and updates the projection. * - * @method Phaser.GameObjects.Zone#setDisplaySize + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#resize * @since 3.0.0 * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. + * @param {number} width - The new width. + * @param {number} height - The new height. + * @param {number} resolution - The resolution. * - * @return {Phaser.GameObjects.Zone} This Game Object. + * @return {this} This WebGLPipeline instance. */ - setDisplaySize: function (width, height) + resize: function (width, height, resolution) { - this.displayWidth = width; - this.displayHeight = height; + WebGLPipeline.prototype.resize.call(this, width, height, resolution); + + this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); return this; }, /** - * Sets this Zone to be a Circular Drop Zone. - * The circle is centered on this Zones `x` and `y` coordinates. + * Assigns a texture to the current batch. If a texture is already set it creates + * a new batch object. * - * @method Phaser.GameObjects.Zone#setCircleDropZone - * @since 3.0.0 + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#setTexture2D + * @since 3.1.0 * - * @param {number} radius - The radius of the Circle that will form the Drop Zone. + * @param {WebGLTexture} texture - WebGLTexture that will be assigned to the current batch. + * @param {integer} textureUnit - Texture unit to which the texture needs to be bound. * - * @return {Phaser.GameObjects.Zone} This Game Object. + * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This pipeline instance. */ - setCircleDropZone: function (radius) + setTexture2D: function (texture, unit) { - return this.setDropZone(new Circle(0, 0, radius), CircleContains); - }, - - /** - * Sets this Zone to be a Rectangle Drop Zone. - * The rectangle is centered on this Zones `x` and `y` coordinates. - * - * @method Phaser.GameObjects.Zone#setRectangleDropZone - * @since 3.0.0 - * - * @param {number} width - The width of the rectangle drop zone. - * @param {number} height - The height of the rectangle drop zone. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setRectangleDropZone: function (width, height) - { - var x = -(width / 2); - var y = -(height / 2); - - return this.setDropZone(new Rectangle(x, y, width, height), RectangleContains); - }, - - /** - * Allows you to define your own Geometry shape to be used as a Drop Zone. - * - * @method Phaser.GameObjects.Zone#setDropZone - * @since 3.0.0 - * - * @param {object} shape - A Geometry shape instance, such as Phaser.Geom.Ellipse, or your own custom shape. - * @param {HitAreaCallback} callback - A function that will return `true` if the given x/y coords it is sent are within the shape. - * - * @return {Phaser.GameObjects.Zone} This Game Object. - */ - setDropZone: function (shape, callback) - { - if (shape === undefined) + if (!texture) { - this.setRectangleDropZone(this.width, this.height); + texture = this.renderer.blankTexture.glTexture; + unit = 0; + } + + var batches = this.batches; + + if (batches.length === 0) + { + this.pushBatch(); + } + + var batch = batches[batches.length - 1]; + + if (unit > 0) + { + if (batch.textures[unit - 1] && + batch.textures[unit - 1] !== texture) + { + this.pushBatch(); + } + + batches[batches.length - 1].textures[unit - 1] = texture; } else - if (!this.input) { - this.setInteractive(shape, callback, true); + if (batch.texture !== null && + batch.texture !== texture) + { + this.pushBatch(); + } + + batches[batches.length - 1].texture = texture; } return this; }, /** - * A Zone does not render. + * Creates a new batch object and pushes it to a batch array. + * The batch object contains information relevant to the current + * vertex batch like the offset in the vertex buffer, vertex count and + * the textures used by that batch. * - * @method Phaser.GameObjects.Zone#renderCanvas - * @private - * @since 3.0.0 + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#pushBatch + * @since 3.1.0 */ - renderCanvas: function () + pushBatch: function () { + var batch = { + first: this.vertexCount, + texture: null, + textures: [] + }; + + this.batches.push(batch); }, /** - * A Zone does not render. + * Uploads the vertex data and emits a draw call for the current batch of vertices. * - * @method Phaser.GameObjects.Zone#renderWebGL - * @private + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#flush * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. */ - renderWebGL: function () + flush: function () { + if (this.flushLocked) + { + return this; + } + + this.flushLocked = true; + + var gl = this.gl; + var vertexCount = this.vertexCount; + var topology = this.topology; + var vertexSize = this.vertexSize; + var renderer = this.renderer; + + var batches = this.batches; + var batchCount = batches.length; + var batchVertexCount = 0; + var batch = null; + var batchNext; + var textureIndex; + var nTexture; + + if (batchCount === 0 || vertexCount === 0) + { + this.flushLocked = false; + + return this; + } + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); + + for (var index = 0; index < batches.length - 1; index++) + { + batch = batches[index]; + batchNext = batches[index + 1]; + + if (batch.textures.length > 0) + { + for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) + { + nTexture = batch.textures[textureIndex]; + + if (nTexture) + { + renderer.setTexture2D(nTexture, 1 + textureIndex); + } + } + + gl.activeTexture(gl.TEXTURE0); + } + + batchVertexCount = batchNext.first - batch.first; + + if (batch.texture === null || batchVertexCount <= 0) + { + continue; + } + + renderer.setTexture2D(batch.texture, 0); + + gl.drawArrays(topology, batch.first, batchVertexCount); + } + + // Left over data + batch = batches[batches.length - 1]; + + if (batch.textures.length > 0) + { + for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) + { + nTexture = batch.textures[textureIndex]; + + if (nTexture) + { + renderer.setTexture2D(nTexture, 1 + textureIndex); + } + } + + gl.activeTexture(gl.TEXTURE0); + } + + batchVertexCount = vertexCount - batch.first; + + if (batch.texture && batchVertexCount > 0) + { + renderer.setTexture2D(batch.texture, 0); + + gl.drawArrays(topology, batch.first, batchVertexCount); + } + + this.vertexCount = 0; + + batches.length = 0; + + this.pushBatch(); + + this.flushLocked = false; + + return this; + }, + + /** + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchSprite + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.Image|Phaser.GameObjects.Sprite)} sprite - The texture based Game Object to add to the batch. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the rendering transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - The transform matrix of the parent container, if set. + */ + batchSprite: function (sprite, camera, parentTransformMatrix) + { + this.renderer.setPipeline(this); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var frame = sprite.frame; + var texture = frame.glTexture; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + var frameX = frame.x; + var frameY = frame.y; + var frameWidth = frame.cutWidth; + var frameHeight = frame.cutHeight; + + var x = -sprite.displayOriginX + frameX; + var y = -sprite.displayOriginY + frameY; + + if (sprite.isCropped) + { + var crop = sprite._crop; + + if (crop.flipX !== sprite.flipX || crop.flipY !== sprite.flipY) + { + frame.updateCropUVs(crop, sprite.flipX, sprite.flipY); + } + + u0 = crop.u0; + v0 = crop.v0; + u1 = crop.u1; + v1 = crop.v1; + + frameWidth = crop.width; + frameHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + x = -sprite.displayOriginX + frameX; + y = -sprite.displayOriginY + frameY; + } + + if (sprite.flipX) + { + x += frameWidth; + frameWidth *= -1; + } + + if (sprite.flipY) + { + y += frameHeight; + frameHeight *= -1; + } + + var xw = x + frameWidth; + var yh = y + frameHeight; + + spriteMatrix.applyITRS(sprite.x, sprite.y, sprite.rotation, sprite.scaleX, sprite.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * sprite.scrollFactorX, -camera.scrollY * sprite.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = sprite.x; + spriteMatrix.f = sprite.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * sprite.scrollFactorX; + spriteMatrix.f -= camera.scrollY * sprite.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + var tintTL = Utils.getTintAppendFloatAlpha(sprite._tintTL, camera.alpha * sprite._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(sprite._tintTR, camera.alpha * sprite._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(sprite._tintBL, camera.alpha * sprite._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(sprite._tintBR, camera.alpha * sprite._alphaBR); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + this.setTexture2D(texture, 0); + + var tintEffect = (sprite._isTinted && sprite.tintFill); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + }, + + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 6 vertices in the following arrangement: + * + * ``` + * 0----3 + * |\ B| + * | \ | + * | \ | + * | A \| + * | \ + * 1----2 + * ``` + * + * Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3 + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchQuad + * @since 3.12.0 + * + * @param {number} x0 - The top-left x position. + * @param {number} y0 - The top-left y position. + * @param {number} x1 - The bottom-left x position. + * @param {number} y1 - The bottom-left y position. + * @param {number} x2 - The bottom-right x position. + * @param {number} y2 - The bottom-right y position. + * @param {number} x3 - The top-right x position. + * @param {number} y3 - The top-right y position. + * @param {number} u0 - UV u0 value. + * @param {number} v0 - UV v0 value. + * @param {number} u1 - UV u1 value. + * @param {number} v1 - UV v1 value. + * @param {number} tintTL - The top-left tint color value. + * @param {number} tintTR - The top-right tint color value. + * @param {number} tintBL - The bottom-left tint color value. + * @param {number} tintBR - The bottom-right tint color value. + * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. + * + * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. + */ + batchQuad: function (x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect) + { + var hasFlushed = false; + + if (this.vertexCount + 6 > this.vertexCapacity) + { + this.flush(); + + hasFlushed = true; + } + + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + + var vertexOffset = (this.vertexCount * this.vertexComponentCount) - 1; + + vertexViewF32[++vertexOffset] = x0; + vertexViewF32[++vertexOffset] = y0; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x1; + vertexViewF32[++vertexOffset] = y1; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBR; + + vertexViewF32[++vertexOffset] = x0; + vertexViewF32[++vertexOffset] = y0; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBR; + + vertexViewF32[++vertexOffset] = x3; + vertexViewF32[++vertexOffset] = y3; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTR; + + this.vertexCount += 6; + + return hasFlushed; + }, + + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 3 vertices in the following arrangement: + * + * ``` + * 0 + * |\ + * | \ + * | \ + * | \ + * | \ + * 1-----2 + * ``` + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTri + * @since 3.12.0 + * + * @param {number} x1 - The bottom-left x position. + * @param {number} y1 - The bottom-left y position. + * @param {number} x2 - The bottom-right x position. + * @param {number} y2 - The bottom-right y position. + * @param {number} x3 - The top-right x position. + * @param {number} y3 - The top-right y position. + * @param {number} u0 - UV u0 value. + * @param {number} v0 - UV v0 value. + * @param {number} u1 - UV u1 value. + * @param {number} v1 - UV v1 value. + * @param {number} tintTL - The top-left tint color value. + * @param {number} tintTR - The top-right tint color value. + * @param {number} tintBL - The bottom-left tint color value. + * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. + * + * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. + */ + batchTri: function (x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect) + { + var hasFlushed = false; + + if (this.vertexCount + 3 > this.vertexCapacity) + { + this.flush(); + + hasFlushed = true; + } + + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + + var vertexOffset = (this.vertexCount * this.vertexComponentCount) - 1; + + vertexViewF32[++vertexOffset] = x1; + vertexViewF32[++vertexOffset] = y1; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTR; + + vertexViewF32[++vertexOffset] = x3; + vertexViewF32[++vertexOffset] = y3; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBL; + + this.vertexCount += 3; + + return hasFlushed; + }, + + /** + * Generic function for batching a textured quad using argument values instead of a Game Object. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject. + * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad. + * @param {integer} textureWidth - Real texture width. + * @param {integer} textureHeight - Real texture height. + * @param {number} srcX - X coordinate of the quad. + * @param {number} srcY - Y coordinate of the quad. + * @param {number} srcWidth - Width of the quad. + * @param {number} srcHeight - Height of the quad. + * @param {number} scaleX - X component of scale. + * @param {number} scaleY - Y component of scale. + * @param {number} rotation - Rotation of the quad. + * @param {boolean} flipX - Indicates if the quad is horizontally flipped. + * @param {boolean} flipY - Indicates if the quad is vertically flipped. + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll. + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll. + * @param {number} displayOriginX - Horizontal origin in pixels. + * @param {number} displayOriginY - Vertical origin in pixels. + * @param {number} frameX - X coordinate of the texture frame. + * @param {number} frameY - Y coordinate of the texture frame. + * @param {number} frameWidth - Width of the texture frame. + * @param {number} frameHeight - Height of the texture frame. + * @param {integer} tintTL - Tint for top left. + * @param {integer} tintTR - Tint for top right. + * @param {integer} tintBL - Tint for bottom left. + * @param {integer} tintBR - Tint for bottom right. + * @param {number} tintEffect - The tint effect. + * @param {number} uOffset - Horizontal offset on texture coordinate. + * @param {number} vOffset - Vertical offset on texture coordinate. + * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container. + * @param {boolean} [skipFlip=false] - Skip the renderTexture check. + */ + batchTexture: function ( + gameObject, + texture, + textureWidth, textureHeight, + srcX, srcY, + srcWidth, srcHeight, + scaleX, scaleY, + rotation, + flipX, flipY, + scrollFactorX, scrollFactorY, + displayOriginX, displayOriginY, + frameX, frameY, frameWidth, frameHeight, + tintTL, tintTR, tintBL, tintBR, tintEffect, + uOffset, vOffset, + camera, + parentTransformMatrix, + skipFlip) + { + this.renderer.setPipeline(this, gameObject); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var u0 = (frameX / textureWidth) + uOffset; + var v0 = (frameY / textureHeight) + vOffset; + var u1 = (frameX + frameWidth) / textureWidth + uOffset; + var v1 = (frameY + frameHeight) / textureHeight + vOffset; + + var width = srcWidth; + var height = srcHeight; + + var x = -displayOriginX; + var y = -displayOriginY; + + if (gameObject.isCropped) + { + var crop = gameObject._crop; + + width = crop.width; + height = crop.height; + + srcWidth = crop.width; + srcHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + var ox = frameX; + var oy = frameY; + + if (flipX) + { + ox = (frameWidth - crop.x - crop.width); + } + + if (flipY && !texture.isRenderTexture) + { + oy = (frameHeight - crop.y - crop.height); + } + + u0 = (ox / textureWidth) + uOffset; + v0 = (oy / textureHeight) + vOffset; + u1 = (ox + crop.width) / textureWidth + uOffset; + v1 = (oy + crop.height) / textureHeight + vOffset; + + x = -displayOriginX + frameX; + y = -displayOriginY + frameY; + } + + // Invert the flipY if this is a RenderTexture + flipY = flipY ^ (!skipFlip && texture.isRenderTexture ? 1 : 0); + + if (flipX) + { + width *= -1; + x += srcWidth; + } + + if (flipY) + { + height *= -1; + y += srcHeight; + } + + var xw = x + width; + var yh = y + height; + + spriteMatrix.applyITRS(srcX, srcY, rotation, scaleX, scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * scrollFactorX, -camera.scrollY * scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = srcX; + spriteMatrix.f = srcY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * scrollFactorX; + spriteMatrix.f -= camera.scrollY * scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + this.setTexture2D(texture, 0); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + }, + + /** + * Adds a Texture Frame into the batch for rendering. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTextureFrame + * @since 3.12.0 + * + * @param {Phaser.Textures.Frame} frame - The Texture Frame to be rendered. + * @param {number} x - The horizontal position to render the texture at. + * @param {number} y - The vertical position to render the texture at. + * @param {number} tint - The tint color. + * @param {number} alpha - The alpha value. + * @param {Phaser.GameObjects.Components.TransformMatrix} transformMatrix - The Transform Matrix to use for the texture. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - A parent Transform Matrix. + */ + batchTextureFrame: function ( + frame, + x, y, + tint, alpha, + transformMatrix, + parentTransformMatrix + ) + { + this.renderer.setPipeline(this); + + var spriteMatrix = this._tempMatrix1.copyFrom(transformMatrix); + var calcMatrix = this._tempMatrix2; + + var xw = x + frame.width; + var yh = y + frame.height; + + if (parentTransformMatrix) + { + spriteMatrix.multiply(parentTransformMatrix, calcMatrix); + } + else + { + calcMatrix = spriteMatrix; + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + this.setTexture2D(frame.glTexture, 0); + + tint = Utils.getTintAppendFloatAlpha(tint, alpha); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, 0); + }, + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle has no transform values and isn't transformed into the local space. + * Used for directly batching untransformed rectangles, such as Camera background colors. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawFillRect + * @since 3.12.0 + * + * @param {number} x - Horizontal top left coordinate of the rectangle. + * @param {number} y - Vertical top left coordinate of the rectangle. + * @param {number} width - Width of the rectangle. + * @param {number} height - Height of the rectangle. + * @param {number} color - Color of the rectangle to draw. + * @param {number} alpha - Alpha value of the rectangle to draw. + */ + drawFillRect: function (x, y, width, height, color, alpha) + { + var xw = x + width; + var yh = y + height; + + var tint = Utils.getTintAppendFloatAlphaAndSwap(color, alpha); + + this.batchQuad(x, y, x, yh, xw, yh, xw, y, 0, 0, 1, 1, tint, tint, tint, tint, 2); + }, + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle factors in the given transform matrices before adding to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillRect + * @since 3.12.0 + * + * @param {number} x - Horizontal top left coordinate of the rectangle. + * @param {number} y - Vertical top left coordinate of the rectangle. + * @param {number} width - Width of the rectangle. + * @param {number} height - Height of the rectangle. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillRect: function (x, y, width, height, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var xw = x + width; + var yh = y + height; + + var x0 = calcMatrix.getX(x, y); + var y0 = calcMatrix.getY(x, y); + + var x1 = calcMatrix.getX(x, yh); + var y1 = calcMatrix.getY(x, yh); + + var x2 = calcMatrix.getX(xw, yh); + var y2 = calcMatrix.getY(xw, yh); + + var x3 = calcMatrix.getX(xw, y); + var y3 = calcMatrix.getY(xw, y); + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.fillTint.BR, this.tintEffect); + }, + + /** + * Pushes a filled triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillTriangle + * @since 3.12.0 + * + * @param {number} x0 - Point 0 x coordinate. + * @param {number} y0 - Point 0 y coordinate. + * @param {number} x1 - Point 1 x coordinate. + * @param {number} y1 - Point 1 y coordinate. + * @param {number} x2 - Point 2 x coordinate. + * @param {number} y2 - Point 2 y coordinate. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillTriangle: function (x0, y0, x1, y1, x2, y2, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.tintEffect); + }, + + /** + * Pushes a stroked triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * The triangle is created from 3 lines and drawn using the `batchStrokePath` method. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokeTriangle + * @since 3.12.0 + * + * @param {number} x0 - Point 0 x coordinate. + * @param {number} y0 - Point 0 y coordinate. + * @param {number} x1 - Point 1 x coordinate. + * @param {number} y1 - Point 1 y coordinate. + * @param {number} x2 - Point 2 x coordinate. + * @param {number} y2 - Point 2 y coordinate. + * @param {number} lineWidth - The width of the line in pixels. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchStrokeTriangle: function (x0, y0, x1, y1, x2, y2, lineWidth, currentMatrix, parentMatrix) + { + var tempTriangle = this.tempTriangle; + + tempTriangle[0].x = x0; + tempTriangle[0].y = y0; + tempTriangle[0].width = lineWidth; + + tempTriangle[1].x = x1; + tempTriangle[1].y = y1; + tempTriangle[1].width = lineWidth; + + tempTriangle[2].x = x2; + tempTriangle[2].y = y2; + tempTriangle[2].width = lineWidth; + + tempTriangle[3].x = x0; + tempTriangle[3].y = y0; + tempTriangle[3].width = lineWidth; + + this.batchStrokePath(tempTriangle, lineWidth, false, currentMatrix, parentMatrix); + }, + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and then passing it through Earcut, which + * creates a list of polygons. Each polygon is then added to the batch. + * + * The path is always automatically closed because it's filled. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillPath + * @since 3.12.0 + * + * @param {array} path - Collection of points that represent the path. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillPath: function (path, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var length = path.length; + var polygonCache = this.polygonCache; + var polygonIndexArray; + var point; + + var tintTL = this.fillTint.TL; + var tintTR = this.fillTint.TR; + var tintBL = this.fillTint.BL; + var tintEffect = this.tintEffect; + + for (var pathIndex = 0; pathIndex < length; ++pathIndex) + { + point = path[pathIndex]; + polygonCache.push(point.x, point.y); + } + + polygonIndexArray = Earcut(polygonCache); + length = polygonIndexArray.length; + + var frame = this.currentFrame; + + for (var index = 0; index < length; index += 3) + { + var p0 = polygonIndexArray[index + 0] * 2; + var p1 = polygonIndexArray[index + 1] * 2; + var p2 = polygonIndexArray[index + 2] * 2; + + var x0 = polygonCache[p0 + 0]; + var y0 = polygonCache[p0 + 1]; + var x1 = polygonCache[p1 + 0]; + var y1 = polygonCache[p1 + 1]; + var x2 = polygonCache[p2 + 0]; + var y2 = polygonCache[p2 + 1]; + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect); + } + + polygonCache.length = 0; + }, + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and calling `batchLine` for each section + * of the path. + * + * The path is optionally closed at the end. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokePath + * @since 3.12.0 + * + * @param {array} path - Collection of points that represent the path. + * @param {number} lineWidth - The width of the line segments in pixels. + * @param {boolean} pathOpen - Indicates if the path should be closed or left open. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchStrokePath: function (path, lineWidth, pathOpen, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + // Reset the closePath booleans + this.prevQuad[4] = 0; + this.firstQuad[4] = 0; + + var pathLength = path.length - 1; + + for (var pathIndex = 0; pathIndex < pathLength; pathIndex++) + { + var point0 = path[pathIndex]; + var point1 = path[pathIndex + 1]; + + this.batchLine( + point0.x, + point0.y, + point1.x, + point1.y, + point0.width / 2, + point1.width / 2, + lineWidth, + pathIndex, + !pathOpen && (pathIndex === pathLength - 1), + currentMatrix, + parentMatrix + ); + } + }, + + /** + * Creates a quad and adds it to the vertex batch based on the given line values. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchLine + * @since 3.12.0 + * + * @param {number} ax - X coordinate to the start of the line + * @param {number} ay - Y coordinate to the start of the line + * @param {number} bx - X coordinate to the end of the line + * @param {number} by - Y coordinate to the end of the line + * @param {number} aLineWidth - Width of the start of the line + * @param {number} bLineWidth - Width of the end of the line + * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers + */ + batchLine: function (ax, ay, bx, by, aLineWidth, bLineWidth, lineWidth, index, closePath, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var dx = bx - ax; + var dy = by - ay; + + var len = Math.sqrt(dx * dx + dy * dy); + var al0 = aLineWidth * (by - ay) / len; + var al1 = aLineWidth * (ax - bx) / len; + var bl0 = bLineWidth * (by - ay) / len; + var bl1 = bLineWidth * (ax - bx) / len; + + var lx0 = bx - bl0; + var ly0 = by - bl1; + var lx1 = ax - al0; + var ly1 = ay - al1; + var lx2 = bx + bl0; + var ly2 = by + bl1; + var lx3 = ax + al0; + var ly3 = ay + al1; + + // tx0 = bottom right + var brX = calcMatrix.getX(lx0, ly0); + var brY = calcMatrix.getY(lx0, ly0); + + // tx1 = bottom left + var blX = calcMatrix.getX(lx1, ly1); + var blY = calcMatrix.getY(lx1, ly1); + + // tx2 = top right + var trX = calcMatrix.getX(lx2, ly2); + var trY = calcMatrix.getY(lx2, ly2); + + // tx3 = top left + var tlX = calcMatrix.getX(lx3, ly3); + var tlY = calcMatrix.getY(lx3, ly3); + + var tint = this.strokeTint; + var tintEffect = this.tintEffect; + + var tintTL = tint.TL; + var tintTR = tint.TR; + var tintBL = tint.BL; + var tintBR = tint.BR; + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + // TL, BL, BR, TR + this.batchQuad(tlX, tlY, blX, blY, brX, brY, trX, trY, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + + if (lineWidth <= 2) + { + // No point doing a linejoin if the line isn't thick enough + return; + } + + var prev = this.prevQuad; + var first = this.firstQuad; + + if (index > 0 && prev[4]) + { + this.batchQuad(tlX, tlY, blX, blY, prev[0], prev[1], prev[2], prev[3], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + else + { + first[0] = tlX; + first[1] = tlY; + first[2] = blX; + first[3] = blY; + first[4] = 1; + } + + if (closePath && first[4]) + { + // Add a join for the final path segment + this.batchQuad(brX, brY, trX, trY, first[0], first[1], first[2], first[3], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + else + { + // Store it + + prev[0] = brX; + prev[1] = brY; + prev[2] = trX; + prev[3] = trY; + prev[4] = 1; + } } }); -module.exports = Zone; +module.exports = TextureTintPipeline; /***/ }), -/* 159 */ +/* 197 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(10); + +/** + * @classdesc + * WebGLPipeline is a class that describes the way elements will be rendererd + * in WebGL, specially focused on batching vertices (batching is not provided). + * Pipelines are mostly used for describing 2D rendering passes but it's + * flexible enough to be used for any type of rendering including 3D. + * Internally WebGLPipeline will handle things like compiling shaders, + * creating vertex buffers, assigning primitive topology and binding + * vertex attributes. + * + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - gl: Current WebGL context. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + * - vertices: An optional buffer of vertices + * - attributes: An array describing the vertex attributes + * + * The vertex attributes properties are: + * - name : String - Name of the attribute in the vertex shader + * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 + * - type : GLenum - WebGL type (gl.BYTE, gl.SHORT, gl.UNSIGNED_BYTE, gl.UNSIGNED_SHORT, gl.FLOAT) + * - normalized : boolean - Is the attribute normalized + * - offset : integer - The offset in bytes to the current attribute in the vertex. Equivalent to offsetof(vertex, attrib) in C + * Here you can find more information of how to describe an attribute: + * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer + * + * @class WebGLPipeline + * @memberof Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var WebGLPipeline = new Class({ + + initialize: + + function WebGLPipeline (config) + { + /** + * Name of the Pipeline. Used for identifying + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#name + * @type {string} + * @since 3.0.0 + */ + this.name = 'WebGLPipeline'; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = config.game; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#view + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.view = config.game.canvas; + + /** + * Used to store the current game resolution + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#resolution + * @type {number} + * @since 3.0.0 + */ + this.resolution = config.game.config.resolution; + + /** + * Width of the current viewport + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#width + * @type {number} + * @since 3.0.0 + */ + this.width = config.game.config.width * this.resolution; + + /** + * Height of the current viewport + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#height + * @type {number} + * @since 3.0.0 + */ + this.height = config.game.config.height * this.resolution; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#gl + * @type {WebGLRenderingContext} + * @since 3.0.0 + */ + this.gl = config.gl; + + /** + * How many vertices have been fed to the current pipeline. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.vertexCount = 0; + + /** + * The limit of vertices that the pipeline can hold + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity + * @type {integer} + * @since 3.0.0 + */ + this.vertexCapacity = config.vertexCapacity; + + /** + * [description] + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#renderer + * @type {Phaser.Renderer.WebGL.WebGLRenderer} + * @since 3.0.0 + */ + this.renderer = config.renderer; + + /** + * Raw byte buffer of vertices. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexData + * @type {ArrayBuffer} + * @since 3.0.0 + */ + this.vertexData = (config.vertices ? config.vertices : new ArrayBuffer(config.vertexCapacity * config.vertexSize)); + + /** + * The handle to a WebGL vertex buffer object. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer + * @type {WebGLBuffer} + * @since 3.0.0 + */ + this.vertexBuffer = this.renderer.createVertexBuffer((config.vertices ? config.vertices : this.vertexData.byteLength), this.gl.STREAM_DRAW); + + /** + * The handle to a WebGL program + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#program + * @type {WebGLProgram} + * @since 3.0.0 + */ + this.program = this.renderer.createProgram(config.vertShader, config.fragShader); + + /** + * Array of objects that describe the vertex attributes + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#attributes + * @type {object} + * @since 3.0.0 + */ + this.attributes = config.attributes; + + /** + * The size in bytes of the vertex + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexSize + * @type {integer} + * @since 3.0.0 + */ + this.vertexSize = config.vertexSize; + + /** + * The primitive topology which the pipeline will use to submit draw calls + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#topology + * @type {integer} + * @since 3.0.0 + */ + this.topology = config.topology; + + /** + * Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources + * to the GPU. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#bytes + * @type {Uint8Array} + * @since 3.0.0 + */ + this.bytes = new Uint8Array(this.vertexData); + + /** + * This will store the amount of components of 32 bit length + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#vertexComponentCount + * @type {integer} + * @since 3.0.0 + */ + this.vertexComponentCount = Utils.getComponentCount(config.attributes, this.gl); + + /** + * Indicates if the current pipeline is flushing the contents to the GPU. + * When the variable is set the flush function will be locked. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#flushLocked + * @type {boolean} + * @since 3.1.0 + */ + this.flushLocked = false; + + /** + * Indicates if the current pipeline is active or not for this frame only. + * Reset in the onRender method. + * + * @name Phaser.Renderer.WebGL.WebGLPipeline#active + * @type {boolean} + * @since 3.10.0 + */ + this.active = false; + }, + + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#boot + * @since 3.11.0 + */ + boot: function () + { + }, + + /** + * Adds a description of vertex attribute to the pipeline + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#addAttribute + * @since 3.2.0 + * + * @param {string} name - Name of the vertex attribute + * @param {integer} size - Vertex component size + * @param {integer} type - Type of the attribute + * @param {boolean} normalized - Is the value normalized to a range + * @param {integer} offset - Byte offset to the beginning of the first element in the vertex + * + * @return {this} This WebGLPipeline instance. + */ + addAttribute: function (name, size, type, normalized, offset) + { + this.attributes.push({ + name: name, + size: size, + type: this.renderer.glFormats[type], + normalized: normalized, + offset: offset + }); + + return this; + }, + + /** + * Check if the current batch of vertices is full. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush + * @since 3.0.0 + * + * @return {boolean} [description] + */ + shouldFlush: function () + { + return (this.vertexCount >= this.vertexCapacity); + }, + + /** + * Resizes the properties used to describe the viewport + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} resolution - [description] + * + * @return {this} This WebGLPipeline instance. + */ + resize: function (width, height, resolution) + { + this.width = width * resolution; + this.height = height * resolution; + + return this; + }, + + /** + * Binds the pipeline resources, including programs, vertex buffers and binds attributes + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#bind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + bind: function () + { + var gl = this.gl; + var vertexBuffer = this.vertexBuffer; + var attributes = this.attributes; + var program = this.program; + var renderer = this.renderer; + var vertexSize = this.vertexSize; + + renderer.setProgram(program); + renderer.setVertexBuffer(vertexBuffer); + + for (var index = 0; index < attributes.length; ++index) + { + var element = attributes[index]; + var location = gl.getAttribLocation(program, element.name); + + if (location >= 0) + { + gl.enableVertexAttribArray(location); + gl.vertexAttribPointer(location, element.size, element.type, element.normalized, vertexSize, element.offset); + } + else + { + gl.disableVertexAttribArray(location); + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onBind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function () + { + // This is for updating uniform data it's called on each bind attempt. + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onPreRender + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onPreRender: function () + { + // called once every frame + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onRender + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {this} This WebGLPipeline instance. + */ + onRender: function () + { + // called for each camera + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#onPostRender + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onPostRender: function () + { + // called once every frame + return this; + }, + + /** + * Uploads the vertex data and emits a draw call + * for the current batch of vertices. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#flush + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + flush: function () + { + if (this.flushLocked) { return this; } + + this.flushLocked = true; + + var gl = this.gl; + var vertexCount = this.vertexCount; + var topology = this.topology; + var vertexSize = this.vertexSize; + + if (vertexCount === 0) + { + this.flushLocked = false; + return; + } + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); + gl.drawArrays(topology, 0, vertexCount); + + this.vertexCount = 0; + this.flushLocked = false; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#destroy + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + destroy: function () + { + var gl = this.gl; + + gl.deleteProgram(this.program); + gl.deleteBuffer(this.vertexBuffer); + + delete this.program; + delete this.vertexBuffer; + delete this.gl; + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setFloat1: function (name, x) + { + this.renderer.setFloat1(this.program, name, x); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setFloat2: function (name, x, y) + { + this.renderer.setFloat2(this.program, name, x, y); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setFloat3: function (name, x, y, z) + { + this.renderer.setFloat3(this.program, name, x, y, z); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - X component of the uniform + * @param {number} y - Y component of the uniform + * @param {number} z - Z component of the uniform + * @param {number} w - W component of the uniform + * + * @return {this} This WebGLPipeline instance. + */ + setFloat4: function (name, x, y, z, w) + { + this.renderer.setFloat4(this.program, name, x, y, z, w); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat1v: function (name, arr) + { + this.renderer.setFloat1v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat2v: function (name, arr) + { + this.renderer.setFloat2v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat3v: function (name, arr) + { + this.renderer.setFloat3v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat4v: function (name, arr) + { + this.renderer.setFloat4v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt1 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setInt1: function (name, x) + { + this.renderer.setInt1(this.program, name, x); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt2 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setInt2: function (name, x, y) + { + this.renderer.setInt2(this.program, name, x, y); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt3 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setInt3: function (name, x, y, z) + { + this.renderer.setInt3(this.program, name, x, y, z); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt4 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - X component of the uniform + * @param {integer} y - Y component of the uniform + * @param {integer} z - Z component of the uniform + * @param {integer} w - W component of the uniform + * + * @return {this} This WebGLPipeline instance. + */ + setInt4: function (name, x, y, z, w) + { + this.renderer.setInt4(this.program, name, x, y, z, w); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setMatrix2: function (name, transpose, matrix) + { + this.renderer.setMatrix2(this.program, name, transpose, matrix); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGLPipeline instance. + */ + setMatrix3: function (name, transpose, matrix) + { + this.renderer.setMatrix3(this.program, name, transpose, matrix); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4 + * @since 3.2.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - Should the matrix be transpose + * @param {Float32Array} matrix - Matrix data + * + * @return {this} This WebGLPipeline instance. + */ + setMatrix4: function (name, transpose, matrix) + { + this.renderer.setMatrix4(this.program, name, transpose, matrix); + + return this; + } + +}); + +module.exports = WebGLPipeline; + + +/***/ }), +/* 198 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Wrap = __webpack_require__(53); + +/** + * Wrap an angle in degrees. + * + * Wraps the angle to a value in the range of -180 to 180. + * + * @function Phaser.Math.Angle.WrapDegrees + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in degrees. + * + * @return {number} The wrapped angle, in degrees. + */ +var WrapDegrees = function (angle) +{ + return Wrap(angle, -180, 180); +}; + +module.exports = WrapDegrees; + + +/***/ }), +/* 199 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathWrap = __webpack_require__(53); + +/** + * Wrap an angle. + * + * Wraps the angle to a value in the range of -PI to PI. + * + * @function Phaser.Math.Angle.Wrap + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in radians. + * + * @return {number} The wrapped angle, in radians. + */ +var Wrap = function (angle) +{ + return MathWrap(angle, -Math.PI, Math.PI); +}; + +module.exports = Wrap; + + +/***/ }), +/* 200 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1, eval)("this"); +} catch (e) { + // This works if the window reference is available + if (typeof window === "object") g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 201 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -35847,16 +46122,16 @@ module.exports = Zone; */ var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var TweenBuilder = __webpack_require__(72); -var TWEEN_CONST = __webpack_require__(61); +var EventEmitter = __webpack_require__(11); +var TweenBuilder = __webpack_require__(97); +var TWEEN_CONST = __webpack_require__(83); /** * @classdesc * [description] * * @class Timeline - * @memberOf Phaser.Tweens + * @memberof Phaser.Tweens * @extends Phaser.Events.EventEmitter * @constructor * @since 3.0.0 @@ -36085,12 +46360,13 @@ var Timeline = new Class({ }, /** - * [description] + * Sets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. * * @method Phaser.Tweens.Timeline#setTimeScale * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The time scale value to set. * * @return {Phaser.Tweens.Timeline} This Timeline object. */ @@ -36102,12 +46378,12 @@ var Timeline = new Class({ }, /** - * [description] + * Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. * * @method Phaser.Tweens.Timeline#getTimeScale * @since 3.0.0 * - * @return {number} [description] + * @return {number} The value of the time scale applied to this Tween. */ getTimeScale: function () { @@ -36115,12 +46391,12 @@ var Timeline = new Class({ }, /** - * [description] + * Check whether or not the Timeline is playing. * * @method Phaser.Tweens.Timeline#isPlaying * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Timeline is active, otherwise `false`. */ isPlaying: function () { @@ -36365,7 +46641,7 @@ var Timeline = new Class({ }, /** - * [description] + * Sets a callback for the Tween Manager. * * @method Phaser.Tweens.Timeline#setCallback * @since 3.0.0 @@ -36508,7 +46784,7 @@ var Timeline = new Class({ * @since 3.0.0 * * @param {number} timestamp - [description] - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. * * @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager. */ @@ -36685,7 +46961,7 @@ var Timeline = new Class({ }, /** - * [description] + * Stops all the Tweens in the Timeline immediately, whatever stage of progress they are at and flags them for removal by the TweenManager. * * @method Phaser.Tweens.Timeline#destroy * @since 3.0.0 @@ -36706,7 +46982,7 @@ module.exports = Timeline; /***/ }), -/* 160 */ +/* 202 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -36715,17 +46991,17 @@ module.exports = Timeline; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(33); -var Defaults = __webpack_require__(100); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(62); -var GetEaseFunction = __webpack_require__(63); -var GetNewValue = __webpack_require__(73); -var GetTargets = __webpack_require__(102); -var GetTweens = __webpack_require__(162); +var Clone = __webpack_require__(63); +var Defaults = __webpack_require__(129); +var GetAdvancedValue = __webpack_require__(12); +var GetBoolean = __webpack_require__(84); +var GetEaseFunction = __webpack_require__(86); +var GetNewValue = __webpack_require__(98); +var GetTargets = __webpack_require__(131); +var GetTweens = __webpack_require__(204); var GetValue = __webpack_require__(4); -var Timeline = __webpack_require__(159); -var TweenBuilder = __webpack_require__(72); +var Timeline = __webpack_require__(201); +var TweenBuilder = __webpack_require__(97); /** * [description] @@ -36858,7 +47134,7 @@ module.exports = TimelineBuilder; /***/ }), -/* 161 */ +/* 203 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -36867,15 +47143,15 @@ module.exports = TimelineBuilder; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Defaults = __webpack_require__(100); -var GetAdvancedValue = __webpack_require__(10); -var GetBoolean = __webpack_require__(62); -var GetEaseFunction = __webpack_require__(63); -var GetNewValue = __webpack_require__(73); +var Defaults = __webpack_require__(129); +var GetAdvancedValue = __webpack_require__(12); +var GetBoolean = __webpack_require__(84); +var GetEaseFunction = __webpack_require__(86); +var GetNewValue = __webpack_require__(98); var GetValue = __webpack_require__(4); -var GetValueOp = __webpack_require__(101); -var Tween = __webpack_require__(99); -var TweenData = __webpack_require__(98); +var GetValueOp = __webpack_require__(130); +var Tween = __webpack_require__(128); +var TweenData = __webpack_require__(127); /** * [description] @@ -36986,7 +47262,7 @@ module.exports = NumberTweenBuilder; /***/ }), -/* 162 */ +/* 204 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37032,7 +47308,7 @@ module.exports = GetTweens; /***/ }), -/* 163 */ +/* 205 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37041,7 +47317,7 @@ module.exports = GetTweens; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RESERVED = __webpack_require__(304); +var RESERVED = __webpack_require__(437); /** * [description] @@ -37049,9 +47325,9 @@ var RESERVED = __webpack_require__(304); * @function Phaser.Tweens.Builders.GetProps * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object of the tween to get the target(s) from. * - * @return {array} [description] + * @return {array} An array of all the targets the tween is operating on. */ var GetProps = function (config) { @@ -37090,7 +47366,7 @@ module.exports = GetProps; /***/ }), -/* 164 */ +/* 206 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37100,7 +47376,7 @@ module.exports = GetProps; */ var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * @typedef {object} TimerEventConfig @@ -37121,7 +47397,7 @@ var GetFastValue = __webpack_require__(1); * [description] * * @class TimerEvent - * @memberOf Phaser.Time + * @memberof Phaser.Time * @constructor * @since 3.0.0 * @@ -37139,7 +47415,7 @@ var TimerEvent = new Class({ * @name Phaser.Time.TimerEvent#delay * @type {number} * @default 0 - * @readOnly + * @readonly * @since 3.0.0 */ this.delay = 0; @@ -37150,7 +47426,7 @@ var TimerEvent = new Class({ * @name Phaser.Time.TimerEvent#repeat * @type {number} * @default 0 - * @readOnly + * @readonly * @since 3.0.0 */ this.repeat = 0; @@ -37171,7 +47447,7 @@ var TimerEvent = new Class({ * @name Phaser.Time.TimerEvent#loop * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.loop = false; @@ -37407,7 +47683,6067 @@ module.exports = TimerEvent; /***/ }), -/* 165 */ +/* 207 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var CONST = __webpack_require__(26); +var GameObject = __webpack_require__(19); +var StaticTilemapLayerRender = __webpack_require__(446); +var TilemapComponents = __webpack_require__(103); +var TransformMatrix = __webpack_require__(38); +var Utils = __webpack_require__(10); + +/** + * @classdesc + * A Static Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. + * + * A Static Tilemap Layer is optimized for rendering speed over flexibility. You cannot apply per-tile + * effects like tint or alpha, or change the tiles or tilesets the layer uses. + * + * Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features. + * + * @class StaticTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * @extends Phaser.GameObjects.Components.ScrollFactor + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + */ +var StaticTilemapLayer = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + StaticTilemapLayerRender + ], + + initialize: + + function StaticTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) + { + GameObject.call(this, scene, 'StaticTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + // Link the LayerData with this static tilemap layer + this.layer.tilemapLayer = this; + + /** + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tileset = []; + + /** + * Used internally by the Canvas renderer. + * This holds the tiles that are visible within the camera in the last frame. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + /** + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#skipCull + * @type {boolean} + * @since 3.12.0 + */ + this.skipCull = false; + + /** + * Canvas only. + * + * The total number of tiles drawn by the renderer in the last frame. + * + * This only works when rending with Canvas. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilesDrawn + * @type {integer} + * @readonly + * @since 3.12.0 + */ + this.tilesDrawn = 0; + + /** + * Canvas only. + * + * The total number of tiles in this layer. Updated every frame. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilesTotal + * @type {integer} + * @readonly + * @since 3.12.0 + */ + this.tilesTotal = this.layer.width * this.layer.height; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullPaddingX + * @type {integer} + * @default 1 + * @since 3.12.0 + */ + this.cullPaddingX = 1; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullPaddingY + * @type {integer} + * @default 1 + * @since 3.12.0 + */ + this.cullPaddingY = 1; + + /** + * Canvas only. + * + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1) The Phaser.Tilemaps.LayerData object for this Layer + * 2) The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3) A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullCallback + * @type {function} + * @since 3.12.0 + */ + this.cullCallback = TilemapComponents.CullTiles; + + /** + * A reference to the renderer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @private + * @since 3.0.0 + */ + this.renderer = scene.sys.game.renderer; + + /** + * An array of vertex buffer objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer + * @type {WebGLBuffer[]} + * @private + * @since 3.0.0 + */ + this.vertexBuffer = []; + + /** + * An array of ArrayBuffer objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData + * @type {ArrayBuffer[]} + * @private + * @since 3.0.0 + */ + this.bufferData = []; + + /** + * An array of Float32 Array objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 + * @type {Float32Array[]} + * @private + * @since 3.0.0 + */ + this.vertexViewF32 = []; + + /** + * An array of Uint32 Array objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 + * @type {Uint32Array[]} + * @private + * @since 3.0.0 + */ + this.vertexViewU32 = []; + + /** + * An array of booleans, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single boolean. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#dirty + * @type {boolean[]} + * @private + * @since 3.0.0 + */ + this.dirty = []; + + /** + * An array of integers, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single integer. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount + * @type {integer[]} + * @private + * @since 3.0.0 + */ + this.vertexCount = []; + + /** + * The rendering (draw) order of the tiles in this layer. + * + * The default is 0 which is 'right-down', meaning it will draw the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#_renderOrder + * @type {integer} + * @default 0 + * @private + * @since 3.12.0 + */ + this._renderOrder = 0; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#_tempMatrix + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.14.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#gidMap + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.14.0 + */ + this.gidMap = []; + + this.setTilesets(tileset); + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.updateVBOData(); + + this.initPipeline('TextureTintPipeline'); + + if (scene.sys.game.config.renderType === CONST.WEBGL) + { + scene.sys.game.renderer.onContextRestored(function () + { + this.updateVBOData(); + }, this); + } + }, + + /** + * Populates the internal `tileset` array with the Tileset references this Layer requires for rendering. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTilesets + * @private + * @since 3.14.0 + * + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + */ + setTilesets: function (tilesets) + { + var gidMap = []; + var setList = []; + var map = this.tilemap; + + if (!Array.isArray(tilesets)) + { + tilesets = [ tilesets ]; + } + + for (var i = 0; i < tilesets.length; i++) + { + var tileset = tilesets[i]; + + if (typeof tileset === 'string') + { + tileset = map.getTileset(tileset); + } + + if (tileset) + { + setList.push(tileset); + + var s = tileset.firstgid; + + for (var t = 0; t < tileset.total; t++) + { + gidMap[s + t] = tileset; + } + } + } + + this.gidMap = gidMap; + this.tileset = setList; + }, + + /** + * Prepares the VBO data arrays for population by the `upload` method. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#updateVBOData + * @private + * @since 3.14.0 + * + * @return {this} This Tilemap Layer object. + */ + updateVBOData: function () + { + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + this.vertexCount[i] = 0; + this.vertexBuffer[i] = null; + this.bufferData[i] = null; + this.vertexViewF32[i] = null; + this.vertexViewU32[i] = null; + } + + return this; + }, + + /** + * Upload the tile data to a VBO. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#upload + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. + * @param {integer} tilesetIndex - The tileset index. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + upload: function (camera, tilesetIndex) + { + var renderer = this.renderer; + var gl = renderer.gl; + + var pipeline = renderer.pipelines.TextureTintPipeline; + + if (this.dirty[tilesetIndex]) + { + var tileset = this.tileset[tilesetIndex]; + var mapWidth = this.layer.width; + var mapHeight = this.layer.height; + var width = tileset.image.source[0].width; + var height = tileset.image.source[0].height; + var mapData = this.layer.data; + var tile; + var row; + var col; + var renderOrder = this._renderOrder; + var minTileIndex = tileset.firstgid; + var maxTileIndex = tileset.firstgid + tileset.total; + + var vertexBuffer = this.vertexBuffer[tilesetIndex]; + var bufferData = this.bufferData[tilesetIndex]; + var vOffset = -1; + var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; + + this.vertexCount[tilesetIndex] = 0; + + if (bufferData === null) + { + bufferData = new ArrayBuffer(bufferSize); + + this.bufferData[tilesetIndex] = bufferData; + + this.vertexViewF32[tilesetIndex] = new Float32Array(bufferData); + this.vertexViewU32[tilesetIndex] = new Uint32Array(bufferData); + } + + if (renderOrder === 0) + { + // right-down + + for (row = 0; row < mapHeight; row++) + { + for (col = 0; col < mapWidth; col++) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 1) + { + // left-down + + for (row = 0; row < mapHeight; row++) + { + for (col = mapWidth - 1; col >= 0; col--) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 2) + { + // right-up + + for (row = mapHeight - 1; row >= 0; row--) + { + for (col = 0; col < mapWidth; col++) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 3) + { + // left-up + + for (row = mapHeight - 1; row >= 0; row--) + { + for (col = mapWidth - 1; col >= 0; col--) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + + this.dirty[tilesetIndex] = false; + + if (vertexBuffer === null) + { + vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); + + this.vertexBuffer[tilesetIndex] = vertexBuffer; + } + else + { + renderer.setVertexBuffer(vertexBuffer); + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); + } + } + + return this; + }, + + /** + * Add a single tile into the batch. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#batchTile + * @private + * @since 3.12.0 + * + * @param {integer} vOffset - The vertex offset. + * @param {any} tile - The tile being rendered. + * @param {any} tileset - The tileset being used for rendering. + * @param {integer} width - The width of the layer. + * @param {integer} height - The height of the layer. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the layer is being rendered with. + * @param {integer} tilesetIndex - The tileset index. + * + * @return {integer} The new vOffset value. + */ + batchTile: function (vOffset, tile, tileset, width, height, camera, tilesetIndex) + { + var texCoords = tileset.getTileTextureCoordinates(tile.index); + + if (!texCoords) + { + return vOffset; + } + + var u0 = texCoords.x / width; + var v0 = texCoords.y / height; + var u1 = (texCoords.x + tile.width) / width; + var v1 = (texCoords.y + tile.height) / height; + + var matrix = this._tempMatrix; + + var tileWidth = tile.width; + var tileHeight = tile.height; + + var halfTileWidth = tileWidth / 2; + var halfTileHeight = tileHeight / 2; + + var x = -halfTileWidth; + var y = -halfTileHeight; + + if (tile.flipX) + { + tileWidth *= -1; + x += tile.width; + } + + if (tile.flipY) + { + tileHeight *= -1; + y += tile.height; + } + + var xw = x + tileWidth; + var yh = y + tileHeight; + + matrix.applyITRS(halfTileWidth + tile.pixelX, halfTileHeight + tile.pixelY, tile.rotation, 1, 1); + + var tint = Utils.getTintAppendFloatAlpha(0xffffff, camera.alpha * this.alpha * tile.alpha); + + var tx0 = matrix.getX(x, y); + var ty0 = matrix.getY(x, y); + + var tx1 = matrix.getX(x, yh); + var ty1 = matrix.getY(x, yh); + + var tx2 = matrix.getX(xw, yh); + var ty2 = matrix.getY(xw, yh); + + var tx3 = matrix.getX(xw, y); + var ty3 = matrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + var vertexViewF32 = this.vertexViewF32[tilesetIndex]; + var vertexViewU32 = this.vertexViewU32[tilesetIndex]; + + vertexViewF32[++vOffset] = tx0; + vertexViewF32[++vOffset] = ty0; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx1; + vertexViewF32[++vOffset] = ty1; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx2; + vertexViewF32[++vOffset] = ty2; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx0; + vertexViewF32[++vOffset] = ty0; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx2; + vertexViewF32[++vOffset] = ty2; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx3; + vertexViewF32[++vOffset] = ty3; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + this.vertexCount[tilesetIndex] += 6; + + return vOffset; + }, + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap Layer object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'string') + { + renderOrder = orders.indexOf(renderOrder); + } + + if (renderOrder >= 0 && renderOrder < 4) + { + this._renderOrder = renderOrder; + + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + } + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return this.cullCallback(this.layer, camera, this.culledTiles); + }, + + /** + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setSkipCull + * @since 3.12.0 + * + * @param {boolean} [value=true] - Set to `true` to stop culling tiles. Set to `false` to enable culling again. + * + * @return {this} This Tilemap Layer object. + */ + setSkipCull: function (value) + { + if (value === undefined) { value = true; } + + this.skipCull = value; + + return this; + }, + + /** + * Canvas only. + * + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCullPadding + * @since 3.12.0 + * + * @param {integer} [paddingX=1] - The amount of extra horizontal tiles to add to the cull check padding. + * @param {integer} [paddingY=1] - The amount of extra vertical tiles to add to the cull check padding. + * + * @return {this} This Tilemap Layer object. + */ + setCullPadding: function (paddingX, paddingY) + { + if (paddingX === undefined) { paddingX = 1; } + if (paddingY === undefined) { paddingY = 1; } + + this.cullPaddingX = paddingX; + this.cullPaddingY = paddingY; + + return this; + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#findTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide + * on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile + * object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile + * object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - [description] + * @param {integer} [tileY=0] - [description] + * @param {integer} [width=max width based on tileX] - [description] + * @param {integer} [height=max height based on tileY] - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have + * -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on + * at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that + * have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * + * @return {boolean} + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {boolean} + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {integer} width - [description] + * @param {integer} height - [description] + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} [callbackContext] - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - [description] + * @param {integer} tileY - [description] + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - [description] + * @param {number} worldY - [description] + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the + * nearest integer. + * @param {Phaser.Math.Vector2} [point] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); + }, + + /** + * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.culledTiles.length = 0; + this.cullCallback = null; + + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + this.vertexCount[i] = 0; + this.vertexBuffer[i] = null; + this.bufferData[i] = null; + this.vertexViewF32[i] = null; + this.vertexViewU32[i] = null; + } + + this.gidMap = []; + this.tileset = []; + + GameObject.prototype.destroy.call(this); + } + +}); + +module.exports = StaticTilemapLayer; + + +/***/ }), +/* 208 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var DynamicTilemapLayerRender = __webpack_require__(449); +var GameObject = __webpack_require__(19); +var TilemapComponents = __webpack_require__(103); + +/** + * @classdesc + * A Dynamic Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. + * + * A Dynamic Tilemap Layer trades some speed for being able to apply powerful effects. Unlike a + * Static Tilemap Layer, you can apply per-tile effects like tint or alpha, and you can change the + * tiles in a DynamicTilemapLayer. + * + * Use this over a Static Tilemap Layer when you need those features. + * + * @class DynamicTilemapLayer + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. + * @param {integer} layerIndex - The index of the LayerData associated with this layer. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + */ +var DynamicTilemapLayer = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.Transform, + Components.Visible, + Components.ScrollFactor, + DynamicTilemapLayerRender + ], + + initialize: + + function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) + { + GameObject.call(this, scene, 'DynamicTilemapLayer'); + + /** + * Used internally by physics system to perform fast type checks. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap + * @type {boolean} + * @readonly + * @since 3.0.0 + */ + this.isTilemap = true; + + /** + * The Tilemap that this layer is a part of. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilemap + * @type {Phaser.Tilemaps.Tilemap} + * @since 3.0.0 + */ + this.tilemap = tilemap; + + /** + * The index of the LayerData associated with this layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layerIndex + * @type {integer} + * @since 3.0.0 + */ + this.layerIndex = layerIndex; + + /** + * The LayerData associated with this layer. LayerData can only be associated with one + * tilemap layer. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + this.layer = tilemap.layers[layerIndex]; + + // Link the LayerData with this static tilemap layer + this.layer.tilemapLayer = this; + + /** + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tileset = []; + + /** + * Used internally with the canvas render. This holds the tiles that are visible within the + * camera. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#culledTiles + * @type {array} + * @since 3.0.0 + */ + this.culledTiles = []; + + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#skipCull + * @type {boolean} + * @since 3.11.0 + */ + this.skipCull = false; + + /** + * The total number of tiles drawn by the renderer in the last frame. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilesDrawn + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.tilesDrawn = 0; + + /** + * The total number of tiles in this layer. Updated every frame. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilesTotal + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.tilesTotal = this.layer.width * this.layer.height; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingX + * @type {integer} + * @default 1 + * @since 3.11.0 + */ + this.cullPaddingX = 1; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingY + * @type {integer} + * @default 1 + * @since 3.11.0 + */ + this.cullPaddingY = 1; + + /** + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1) The Phaser.Tilemaps.LayerData object for this Layer + * 2) The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3) A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullCallback + * @type {function} + * @since 3.11.0 + */ + this.cullCallback = TilemapComponents.CullTiles; + + /** + * The rendering (draw) order of the tiles in this layer. + * + * The default is 0 which is 'right-down', meaning it will draw the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#_renderOrder + * @type {integer} + * @default 0 + * @private + * @since 3.12.0 + */ + this._renderOrder = 0; + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#gidMap + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.14.0 + */ + this.gidMap = []; + + this.setTilesets(tileset); + this.setAlpha(this.layer.alpha); + this.setPosition(x, y); + this.setOrigin(); + this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + + this.initPipeline('TextureTintPipeline'); + }, + + /** + * Populates the internal `tileset` array with the Tileset references this Layer requires for rendering. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTilesets + * @private + * @since 3.14.0 + * + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + */ + setTilesets: function (tilesets) + { + var gidMap = []; + var setList = []; + var map = this.tilemap; + + if (!Array.isArray(tilesets)) + { + tilesets = [ tilesets ]; + } + + for (var i = 0; i < tilesets.length; i++) + { + var tileset = tilesets[i]; + + if (typeof tileset === 'string') + { + tileset = map.getTileset(tileset); + } + + if (tileset) + { + setList.push(tileset); + + var s = tileset.firstgid; + + for (var t = 0; t < tileset.total; t++) + { + gidMap[s + t] = tileset; + } + } + } + + this.gidMap = gidMap; + this.tileset = setList; + }, + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap Layer object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'string') + { + renderOrder = orders.indexOf(renderOrder); + } + + if (renderOrder >= 0 && renderOrder < 4) + { + this._renderOrder = renderOrder; + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesAt: function (tileX, tileY) + { + TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + calculateFacesWithin: function (tileX, tileY, width, height) + { + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) + { + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); + }, + + /** + * Returns the tiles in the given layer that are within the cameras viewport. + * This is used internally. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + cull: function (camera) + { + return this.cullCallback(this.layer, camera, this.culledTiles, this._renderOrder); + }, + + /** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#copy + * @since 3.0.0 + * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces) + { + TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.culledTiles.length = 0; + this.cullCallback = null; + + this.gidMap = []; + this.tileset = []; + + GameObject.prototype.destroy.call(this); + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#fill + * @since 3.0.0 + * + * @param {integer} index - The tile index to fill the area with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer); + + return this; + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + findByIndex: function (findIndex, skip, reverse) + { + return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {?Phaser.Tilemaps.Tile} + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); + + return this; + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. + */ + getTileAt: function (tileX, tileY, nonNull) + { + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera) + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions) + { + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinShape: function (shape, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) + { + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * + * @return {boolean} `true` if a tile was found at the given location, otherwise `false`. + */ + hasTileAt: function (tileX, tileY) + { + return TilemapComponents.HasTileAt(tileX, tileY, this.layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * + * @return {boolean} `true` if a tile was found at the given location, otherwise `false`. + */ + hasTileAtWorldXY: function (worldX, worldY, camera) + { + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces) + { + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera) + { + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + randomize: function (tileX, tileY, width, height, indexes) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer); + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces) + { + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Tilemaps.Tile} A Tile object. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera) + { + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + renderDebug: function (graphics, styleConfig) + { + TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setSkipCull + * @since 3.11.0 + * + * @param {boolean} [value=true] - Set to `true` to stop culling tiles. Set to `false` to enable culling again. + * + * @return {this} This Tilemap Layer object. + */ + setSkipCull: function (value) + { + if (value === undefined) { value = true; } + + this.skipCull = value; + + return this; + }, + + /** + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCullPadding + * @since 3.11.0 + * + * @param {integer} [paddingX=1] - The amount of extra horizontal tiles to add to the cull check padding. + * @param {integer} [paddingY=1] - The amount of extra vertical tiles to add to the cull check padding. + * + * @return {this} This Tilemap Layer object. + */ + setCullPadding: function (paddingX, paddingY) + { + if (paddingX === undefined) { paddingX = 1; } + if (paddingY === undefined) { paddingY = 1; } + + this.cullPaddingX = paddingX; + this.cullPaddingY = paddingY; + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollision: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces) + { + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should + * be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces) + { + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tiles collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tiles collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear + * collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the + * update. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces) + { + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a + * collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileIndexCallback: function (indexes, callback, callbackContext) + { + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} [callbackContext] - The context under which the callback is called. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) + { + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + shuffle: function (tileX, tileY, width, height) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer); + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + tileToWorldX: function (tileX, camera) + { + return TilemapComponents.TileToWorldX(tileX, camera, this.layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + tileToWorldY: function (tileY, camera) + { + return TilemapComponents.TileToWorldY(tileY, camera, this.layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Math.Vector2} + */ + tileToWorldXY: function (tileX, tileY, point, camera) + { + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * + * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer); + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + worldToTileX: function (worldX, snapToFloor, camera) + { + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {number} + */ + worldToTileY: function (worldY, snapToFloor, camera) + { + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * + * @return {Phaser.Math.Vector2} + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) + { + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); + } + +}); + +module.exports = DynamicTilemapLayer; + + +/***/ }), +/* 209 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(31); +var DynamicTilemapLayer = __webpack_require__(208); +var Extend = __webpack_require__(20); +var Formats = __webpack_require__(29); +var LayerData = __webpack_require__(78); +var Rotate = __webpack_require__(242); +var StaticTilemapLayer = __webpack_require__(207); +var Tile = __webpack_require__(55); +var TilemapComponents = __webpack_require__(103); +var Tileset = __webpack_require__(99); + +/** + * @callback TilemapFilterCallback + * + * @param {Phaser.GameObjects.GameObject} value - An object found in the filtered area. + * @param {number} index - The index of the object within the array. + * @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found. + * + * @return {Phaser.GameObjects.GameObject} The object. + */ + +/** + * @callback TilemapFindCallback + * + * @param {Phaser.GameObjects.GameObject} value - An object found. + * @param {number} index - The index of the object within the array. + * @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found. + * + * @return {boolean} `true` if the callback should be invoked, otherwise `false`. + */ + +/** + * @classdesc + * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data + * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or + * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display + * objects that actually render tiles. + * + * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free + * software package specifically for creating tile maps, and is available from: + * http://www.mapeditor.org + * + * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only + * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. + * + * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a + * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides + * it. + * + * @class Tilemap + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. + * @param {Phaser.Tilemaps.MapData} mapData - A MapData instance containing Tilemap data. + */ +var Tilemap = new Class({ + + initialize: + + function Tilemap (scene, mapData) + { + /** + * @name Phaser.Tilemaps.Tilemap#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * The base width of a tile in pixels. Note that individual layers may have a different tile + * width. + * + * @name Phaser.Tilemaps.Tilemap#tileWidth + * @type {integer} + * @since 3.0.0 + */ + this.tileWidth = mapData.tileWidth; + + /** + * The base height of a tile in pixels. Note that individual layers may have a different + * tile height. + * + * @name Phaser.Tilemaps.Tilemap#tileHeight + * @type {integer} + * @since 3.0.0 + */ + this.tileHeight = mapData.tileHeight; + + /** + * The width of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#width + * @type {number} + * @since 3.0.0 + */ + this.width = mapData.width; + + /** + * The height of the map (in tiles). + * + * @name Phaser.Tilemaps.Tilemap#height + * @type {number} + * @since 3.0.0 + */ + this.height = mapData.height; + + /** + * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. + * + * @name Phaser.Tilemaps.Tilemap#orientation + * @type {string} + * @since 3.0.0 + */ + this.orientation = mapData.orientation; + + /** + * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. + * + * The draw orders are: + * + * right-down + * left-down + * right-up + * left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.Tilemap#renderOrder + * @type {string} + * @since 3.12.0 + */ + this.renderOrder = mapData.renderOrder; + + /** + * The format of the map data. + * + * @name Phaser.Tilemaps.Tilemap#format + * @type {number} + * @since 3.0.0 + */ + this.format = mapData.format; + + /** + * The version of the map data (as specified in Tiled, usually 1). + * + * @name Phaser.Tilemaps.Tilemap#version + * @type {number} + * @since 3.0.0 + */ + this.version = mapData.version; + + /** + * Map specific properties as specified in Tiled. + * + * @name Phaser.Tilemaps.Tilemap#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = mapData.properties; + + /** + * The width of the map in pixels based on width * tileWidth. + * + * @name Phaser.Tilemaps.Tilemap#widthInPixels + * @type {number} + * @since 3.0.0 + */ + this.widthInPixels = mapData.widthInPixels; + + /** + * The height of the map in pixels based on height * tileHeight. + * + * @name Phaser.Tilemaps.Tilemap#heightInPixels + * @type {number} + * @since 3.0.0 + */ + this.heightInPixels = mapData.heightInPixels; + + /** + * + * @name Phaser.Tilemaps.Tilemap#imageCollections + * @type {Phaser.Tilemaps.ImageCollection[]} + * @since 3.0.0 + */ + this.imageCollections = mapData.imageCollections; + + /** + * An array of Tiled Image Layers. + * + * @name Phaser.Tilemaps.Tilemap#images + * @type {array} + * @since 3.0.0 + */ + this.images = mapData.images; + + /** + * An array of Tilemap layer data. + * + * @name Phaser.Tilemaps.Tilemap#layers + * @type {Phaser.Tilemaps.LayerData[]} + * @since 3.0.0 + */ + this.layers = mapData.layers; + + /** + * An array of Tilesets used in the map. + * + * @name Phaser.Tilemaps.Tilemap#tilesets + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.0.0 + */ + this.tilesets = mapData.tilesets; + + /** + * An array of ObjectLayer instances parsed from Tiled object layers. + * + * @name Phaser.Tilemaps.Tilemap#objects + * @type {Phaser.Tilemaps.ObjectLayer[]} + * @since 3.0.0 + */ + this.objects = mapData.objects; + + /** + * The index of the currently selected LayerData object. + * + * @name Phaser.Tilemaps.Tilemap#currentLayerIndex + * @type {integer} + * @since 3.0.0 + */ + this.currentLayerIndex = 0; + }, + + /** + * Sets the rendering (draw) order of the tiles in this map. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * Calling this method _after_ creating Static or Dynamic Tilemap Layers will **not** automatically + * update them to use the new render order. If you call this method after creating layers, use their + * own `setRenderOrder` methods to change them as needed. + * + * @method Phaser.Tilemaps.Tilemap#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'number') + { + renderOrder = orders[renderOrder]; + } + + if (orders.indexOf(renderOrder) > -1) + { + this.renderOrder = renderOrder; + } + + return this; + }, + + /** + * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. + * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled + * editor. + * + * @method Phaser.Tilemaps.Tilemap#addTilesetImage + * @since 3.0.0 + * + * @param {string} tilesetName - The name of the tileset as specified in the map data. + * @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If + * `undefined` or `null` it will look for an image with a key matching the tilesetName parameter. + * @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not + * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled + * JSON file. + * @param {integer} [tileHeight] - The height of the tiles (in pixels) in the Tileset Image. If + * not given it will default to the map's tileHeight value, or the tileHeight specified in the + * Tiled JSON file. + * @param {integer} [tileMargin] - The margin around the tiles in the sheet (in pixels). If not + * specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [tileSpacing] - The spacing between each the tile in the sheet (in pixels). + * If not specified, it will default to 0 or the value specified in the Tiled JSON file. + * @param {integer} [gid=0] - If adding multiple tilesets to a blank map, specify the starting + * GID this set will use here. + * + * @return {?Phaser.Tilemaps.Tileset} Returns the Tileset object that was created or updated, or null if it + * failed. + */ + addTilesetImage: function (tilesetName, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) + { + if (tilesetName === undefined) { return null; } + if (key === undefined || key === null) { key = tilesetName; } + + if (!this.scene.sys.textures.exists(key)) + { + console.warn('Invalid Tileset Image: ' + key); + return null; + } + + var texture = this.scene.sys.textures.get(key); + + var index = this.getTilesetIndex(tilesetName); + + if (index === null && this.format === Formats.TILED_JSON) + { + console.warn('No data found for Tileset: ' + tilesetName); + return null; + } + + var tileset = this.tilesets[index]; + + if (tileset) + { + tileset.setTileSize(tileWidth, tileHeight); + tileset.setSpacing(tileMargin, tileSpacing); + tileset.setImage(texture); + + return tileset; + } + + if (tileWidth === undefined) { tileWidth = this.tileWidth; } + if (tileHeight === undefined) { tileHeight = this.tileHeight; } + if (tileMargin === undefined) { tileMargin = 0; } + if (tileSpacing === undefined) { tileSpacing = 0; } + if (gid === undefined) { gid = 0; } + + tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); + + tileset.setImage(texture); + + this.tilesets.push(tileset); + + return tileset; + }, + + /** + * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If + * no layer specified, the map's current layer is used. This is useful if you want to manipulate + * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. + * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value + * returned from this method if you want to manipulate the new StaticTilemapLayer. + * + * @method Phaser.Tilemaps.Tilemap#convertLayerToStatic + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer)} [layer] - The name of the layer from Tiled, the + * index of the layer in the map, or a DynamicTilemapLayer. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer that was created, or null if it + * failed. + */ + convertLayerToStatic: function (layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + var dynamicLayer = layer.tilemapLayer; + + if (!dynamicLayer || !(dynamicLayer instanceof DynamicTilemapLayer)) + { + return null; + } + + var staticLayer = new StaticTilemapLayer( + dynamicLayer.scene, + dynamicLayer.tilemap, + dynamicLayer.layerIndex, + dynamicLayer.tileset, + dynamicLayer.x, + dynamicLayer.y + ); + + this.scene.sys.displayList.add(staticLayer); + + dynamicLayer.destroy(); + + return staticLayer; + }, + + /** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#copy + * @since 3.0.0 + * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'copy')) { return this; } + + if (layer !== null) + { + TilemapComponents.Copy( + srcTileX, srcTileY, + width, height, + destTileX, destTileY, + recalculateFaces, layer + ); + } + + return this; + }, + + /** + * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set to this new layer. + * + * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer + * @since 3.0.0 + * + * @param {string} name - The name of this layer. Must be unique within the map. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + * @param {integer} [width] - The width of the layer in tiles. If not specified, it will default to the map's width. + * @param {integer} [height] - The height of the layer in tiles. If not specified, it will default to the map's height. + * @param {integer} [tileWidth] - The width of the tiles the layer uses for calculations. If not specified, it will default to the map's tileWidth. + * @param {integer} [tileHeight] - The height of the tiles the layer uses for calculations. If not specified, it will default to the map's tileHeight. + * + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) + { + if (tileWidth === undefined) { tileWidth = tileset.tileWidth; } + if (tileHeight === undefined) { tileHeight = tileset.tileHeight; } + if (width === undefined) { width = this.width; } + if (height === undefined) { height = this.height; } + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + var index = this.getLayerIndex(name); + + if (index !== null) + { + console.warn('Invalid Tilemap Layer ID: ' + name); + return null; + } + + var layerData = new LayerData({ + name: name, + tileWidth: tileWidth, + tileHeight: tileHeight, + width: width, + height: height + }); + + var row; + + for (var tileY = 0; tileY < height; tileY++) + { + row = []; + + for (var tileX = 0; tileX < width; tileX++) + { + row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight)); + } + + layerData.data.push(row); + } + + this.layers.push(layerData); + + this.currentLayerIndex = this.layers.length - 1; + + var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); + + dynamicLayer.setRenderOrder(this.renderOrder); + + this.scene.sys.displayList.add(dynamicLayer); + + return dynamicLayer; + }, + + /** + * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more + * information. + * + * @method Phaser.Tilemaps.Tilemap#createDynamicLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createDynamicLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Invalid Tilemap Layer ID: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Tilemap Layer ID already exists:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); + + layer.setRenderOrder(this.renderOrder); + + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Creates a Sprite for every object matching the given gid in the map data. All properties from + * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy + * way to configure Sprite properties from within the map editor. For example giving an object a + * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. + * + * Custom object properties not sharing names with the Sprite's own properties are copied to the + * Sprite's {@link Phaser.GameObjects.Sprite#data data store}. + * + * @method Phaser.Tilemaps.Tilemap#createFromObjects + * @since 3.0.0 + * + * @param {string} name - The name of the object layer (from Tiled) to create Sprites from. + * @param {(integer|string)} id - Either the id (object), gid (tile object) or name (object or + * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects + * with the same graphic. The same name can be used on multiple objects. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. + * scene.make.sprite). + * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ + createFromObjects: function (name, id, spriteConfig, scene) + { + if (spriteConfig === undefined) { spriteConfig = {}; } + if (scene === undefined) { scene = this.scene; } + + var objectLayer = this.getObjectLayer(name); + if (!objectLayer) + { + console.warn('Cannot create from object. Invalid objectgroup name given: ' + name); + return; + } + + var objects = objectLayer.objects; + var sprites = []; + + for (var i = 0; i < objects.length; i++) + { + var found = false; + var obj = objects[i]; + + if (obj.gid !== undefined && typeof id === 'number' && obj.gid === id || + obj.id !== undefined && typeof id === 'number' && obj.id === id || + obj.name !== undefined && typeof id === 'string' && obj.name === id) + { + found = true; + } + + if (found) + { + var config = Extend({}, spriteConfig, obj.properties); + + config.x = obj.x; + config.y = obj.y; + + var sprite = this.scene.make.sprite(config); + + sprite.name = obj.name; + + if (obj.width) { sprite.displayWidth = obj.width; } + if (obj.height) { sprite.displayHeight = obj.height; } + + // Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin. + var offset = { + x: sprite.originX * sprite.displayWidth, + y: (sprite.originY - 1) * sprite.displayHeight + }; + + // If the object is rotated, then the origin offset also needs to be rotated. + if (obj.rotation) + { + var angle = DegToRad(obj.rotation); + Rotate(offset, angle); + sprite.rotation = angle; + } + + sprite.x += offset.x; + sprite.y += offset.y; + + if (obj.flippedHorizontal !== undefined || obj.flippedVertical !== undefined) + { + sprite.setFlip(obj.flippedHorizontal, obj.flippedVertical); + } + + if (!obj.visible) { sprite.visible = false; } + + for (var key in obj.properties) + { + if (sprite.hasOwnProperty(key)) + { + continue; + } + + sprite.setData(key, obj.properties[key]); + } + + sprites.push(sprite); + } + } + + return sprites; + }, + + /** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @method Phaser.Tilemaps.Tilemap#createFromTiles + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted + * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a + * one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.GameObjects.Sprite[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + createFromTiles: function (indexes, replacements, spriteConfig, scene, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, layer); + }, + + /** + * Creates a new StaticTilemapLayer that renders the LayerData associated with the given + * `layerID`. The currently selected layer in the map is set to this new layer. + * + * The `layerID` is important. If you've created your map in Tiled then you can get this by + * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and + * look at the layers[].name value. Either way it must match. + * + * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for + * more information. + * + * @method Phaser.Tilemaps.Tilemap#createStaticLayer + * @since 3.0.0 + * + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * + * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed. + */ + createStaticLayer: function (layerID, tileset, x, y) + { + var index = this.getLayerIndex(layerID); + + if (index === null) + { + console.warn('Invalid Tilemap Layer ID: ' + layerID); + return null; + } + + var layerData = this.layers[index]; + + // Check for an associated static or dynamic tilemap layer + if (layerData.tilemapLayer) + { + console.warn('Tilemap Layer ID already exists:' + layerID); + return null; + } + + this.currentLayerIndex = index; + + // Default the x/y position to match Tiled layer offset, if it exists. + if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } + if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } + + var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); + + layer.setRenderOrder(this.renderOrder); + + this.scene.sys.displayList.add(layer); + + return layer; + }, + + /** + * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any + * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. + * + * @method Phaser.Tilemaps.Tilemap#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.removeAllLayers(); + this.tilesets.length = 0; + this.objects.length = 0; + this.scene = undefined; + }, + + /** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * If no layer specified, the map's current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#fill + * @since 3.0.0 + * + * @param {integer} index - The tile index to fill the area with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + fill: function (index, tileX, tileY, width, height, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'fill')) { return this; } + + if (layer !== null) + { + TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, layer); + } + + return this; + }, + + /** + * For each object in the given object layer, run the given filter callback function. Any + * objects that pass the filter test (i.e. where the callback returns true) will returned as a + * new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#filterObjects + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param {TilemapFilterCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject[]} An array of object that match the search, or null if the objectLayer given was invalid. + */ + filterObjects: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.filter(callback, context); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#filterTiles + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to apply the filter on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findByIndex + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to run the search on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findByIndex: function (findIndex, skip, reverse, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindByIndex(findIndex, skip, reverse, layer); + }, + + /** + * Find the first object in the given object layer that satisfies the provided testing function. + * I.e. finds the first object for which `callback` returns true. Similar to + * Array.prototype.find in vanilla JS. + * + * @method Phaser.Tilemaps.Tilemap#findObject + * @since 3.0.0 + * + * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. + * @param {TilemapFindCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * + * @return {?Phaser.GameObjects.GameObject} An object that matches the search, or null if no object found. + */ + findObject: function (objectLayer, callback, context) + { + if (typeof objectLayer === 'string') + { + var name = objectLayer; + + objectLayer = this.getObjectLayer(objectLayer); + + if (!objectLayer) + { + console.warn('No object layer found with the name: ' + name); + return null; + } + } + + return objectLayer.objects.find(callback, context) || null; + }, + + /** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#findTile + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to run the search on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. + */ + findTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#forEachTile + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The Tile layer to run the search on. If not provided will use the current layer. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer !== null) + { + TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); + } + + return this; + }, + + /** + * Gets the image layer index based on its name. + * + * @method Phaser.Tilemaps.Tilemap#getImageIndex + * @since 3.0.0 + * + * @param {string} name - The name of the image to get. + * + * @return {integer} The index of the image in this tilemap, or null if not found. + */ + getImageIndex: function (name) + { + return this.getIndex(this.images, name); + }, + + /** + * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name + * property matches the given `name`. + * + * @method Phaser.Tilemaps.Tilemap#getIndex + * @since 3.0.0 + * + * @param {array} location - The Tilemap array to search. + * @param {string} name - The name of the array element to get. + * + * @return {number} The index of the element in the array, or null if not found. + */ + getIndex: function (location, name) + { + for (var i = 0; i < location.length; i++) + { + if (location[i].name === name) + { + return i; + } + } + + return null; + }, + + /** + * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the maps current layer index. + * + * @return {Phaser.Tilemaps.LayerData} The corresponding LayerData within this.layers. + */ + getLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + return index !== null ? this.layers[index] : null; + }, + + /** + * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer + * is found with that name. + * + * @method Phaser.Tilemaps.Tilemap#getObjectLayer + * @since 3.0.0 + * + * @param {string} [name] - The name of the object layer from Tiled. + * + * @return {?Phaser.Tilemaps.ObjectLayer} The corresponding ObjectLayer within this.objects or null. + */ + getObjectLayer: function (name) + { + var index = this.getIndex(this.objects, name); + + return index !== null ? this.objects[index] : null; + }, + + /** + * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid + * `layer` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndex + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndex: function (layer) + { + if (layer === undefined) + { + return this.currentLayerIndex; + } + else if (typeof layer === 'string') + { + return this.getLayerIndexByName(layer); + } + else if (typeof layer === 'number' && layer < this.layers.length) + { + return layer; + } + else if (layer instanceof StaticTilemapLayer || layer instanceof DynamicTilemapLayer) + { + return layer.layerIndex; + } + else + { + return null; + } + }, + + /** + * Gets the index of the LayerData within this.layers that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getLayerIndexByName + * @since 3.0.0 + * + * @param {string} name - The name of the layer to get. + * + * @return {integer} The LayerData index within this.layers. + */ + getLayerIndexByName: function (name) + { + return this.getIndex(this.layers, name); + }, + + /** + * Gets a tile at the given tile coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAt + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAt: function (tileX, tileY, nonNull, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTileAt(tileX, tileY, nonNull, layer); + }, + + /** + * Gets a tile at the given world coordinates from the given layer. + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + getTileAtWorldXY: function (worldX, worldY, nonNull, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) + { + return null; + } + else + { + return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, layer); + } + }, + + /** + * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithin: function (tileX, tileY, width, height, filteringOptions, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + }, + + /** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinShape + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinShape: function (shape, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, layer); + }, + + /** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. + */ + getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); + }, + + /** + * Gets the Tileset that has the given `name`, or null if an invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getTileset + * @since 3.14.0 + * + * @param {string} name - The name of the Tileset to get. + * + * @return {?Phaser.Tilemaps.Tileset} The Tileset, or `null` if no matching named tileset was found. + */ + getTileset: function (name) + { + var index = this.getIndex(this.tilesets, name); + + return (index !== null) ? this.tilesets[index] : null; + }, + + /** + * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an + * invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getTilesetIndex + * @since 3.0.0 + * + * @param {string} name - The name of the Tileset to get. + * + * @return {integer} The Tileset index within this.tilesets. + */ + getTilesetIndex: function (name) + { + return this.getIndex(this.tilesets, name); + }, + + /** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAt(tileX, tileY, layer); + }, + + /** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ + hasTileAtWorldXY: function (worldX, worldY, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, layer); + }, + + /** + * The LayerData object that is currently selected in the map. You can set this property using + * any type supported by setLayer. + * + * @name Phaser.Tilemaps.Tilemap#layer + * @type {Phaser.Tilemaps.LayerData} + * @since 3.0.0 + */ + layer: { + get: function () + { + return this.layers[this.currentLayerIndex]; + }, + + set: function (layer) + { + this.setLayer(layer); + } + }, + + /** + * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index + * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified + * location. If you pass in an index, only the index at the specified location will be changed. + * Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. + * + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAt + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid or the coordinates were out of bounds. + */ + putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, layer); + }, + + /** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * If no layer specified, the maps current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTileAtWorldXY + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, layer); + }, + + /** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#putTilesAt + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'putTilesAt')) { return this; } + + if (layer !== null) + { + TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, layer); + } + + return this; + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will recieve a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#randomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + randomize: function (tileX, tileY, width, height, indexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'randomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.Randomize(tileX, tileY, width, height, indexes, layer); + } + + return this; + }, + + /** + * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting + * faces are used internally for optimizing collisions against tiles. This method is mostly used + * internally to optimize recalculating faces when only one tile has been changed. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesAt: function (tileX, tileY, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesAt(tileX, tileY, layer); + + return this; + }, + + /** + * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the + * layer. Interesting faces are used internally for optimizing collisions against tiles. This method + * is mostly used internally. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. + */ + calculateFacesWithin: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, layer); + + return this; + }, + + /** + * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or + * DynamicTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeAllLayers + * @since 3.0.0 + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + removeAllLayers: function () + { + // Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData + for (var i = 0; i < this.layers.length; i++) + { + if (this.layers[i].tilemapLayer) + { + this.layers[i].tilemapLayer.destroy(); + } + } + + this.layers.length = 0; + this.currentLayerIndex = 0; + + return this; + }, + + /** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAt + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAt')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); + }, + + /** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + */ + removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'removeTileAtWorldXY')) { return null; } + + if (layer === null) { return null; } + + return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, layer); + }, + + /** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#renderDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to search. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + renderDebug: function (graphics, styleConfig, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.RenderDebug(graphics, styleConfig, layer); + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#replaceByIndex + * @since 3.0.0 + * + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'replaceByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollision + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollision: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollision(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionBetween + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionBetween: function (start, stop, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByProperty: function (properties, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionByExclusion + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionByExclusion: function (indexes, collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setCollisionFromCollisionGroup: function (collides, recalculateFaces, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, layer); + + return this; + }, + + /** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileIndexCallback: function (indexes, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * If no layer specified, the map's current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback + * @since 3.0.0 + * + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} [callbackContext] - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, layer); + + return this; + }, + + /** + * Sets the current layer to the LayerData associated with `layer`. + * + * @method Phaser.Tilemaps.Tilemap#setLayer + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayer: function (layer) + { + var index = this.getLayerIndex(layer); + + if (index !== null) + { + this.currentLayerIndex = index; + } + + return this; + }, + + /** + * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and + * tileHeight for all layers. This also updates the base size on all tiles across all layers. + * + * @method Phaser.Tilemaps.Tilemap#setBaseTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles the map uses for calculations. + * @param {integer} tileHeight - The height of the tiles the map uses for calculations. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setBaseTileSize: function (tileWidth, tileHeight) + { + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.widthInPixels = this.width * tileWidth; + this.heightInPixels = this.height * tileHeight; + + // Update the base tile size on all layers & tiles + for (var i = 0; i < this.layers.length; i++) + { + this.layers[i].baseTileWidth = tileWidth; + this.layers[i].baseTileHeight = tileHeight; + + var mapData = this.layers[i].data; + var mapWidth = this.layers[i].width; + var mapHeight = this.layers[i].height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) + { + tile.setSize(undefined, undefined, tileWidth, tileHeight); + } + } + } + } + + return this; + }, + + /** + * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's + * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any + * tiles the layer has. + * + * @method Phaser.Tilemaps.Tilemap#setLayerTileSize + * @since 3.0.0 + * + * @param {integer} tileWidth - The width of the tiles (in pixels) in the layer. + * @param {integer} tileHeight - The height of the tiles (in pixels) in the layer. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the + * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a + * StaticTilemapLayer. If not given will default to the map's current layer index. + * + * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. + */ + setLayerTileSize: function (tileWidth, tileHeight, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return this; } + + layer.tileWidth = tileWidth; + layer.tileHeight = tileHeight; + + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + + for (var row = 0; row < mapHeight; ++row) + { + for (var col = 0; col < mapWidth; ++col) + { + var tile = mapData[row][col]; + + if (tile !== null) { tile.setSize(tileWidth, tileHeight); } + } + } + + return this; + }, + + /** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#shuffle + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + shuffle: function (tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'shuffle')) { return this; } + + if (layer !== null) + { + TilemapComponents.Shuffle(tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * If no layer specified, the maps current layer is used. + * This cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#swapByIndex + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + swapByIndex: function (indexA, indexB, tileX, tileY, width, height, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'swapByIndex')) { return this; } + + if (layer !== null) + { + TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, layer); + } + + return this; + }, + + /** + * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldX + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldX: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldX(tileX, camera, layer); + }, + + /** + * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldY + * @since 3.0.0 + * + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + tileToWorldY: function (tileX, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldY(tileX, camera, layer); + }, + + /** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#tileToWorldXY + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + tileToWorldXY: function (tileX, tileY, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer); + }, + + /** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * If no layer specified, the map's current layer is used. This + * cannot be applied to StaticTilemapLayers. + * + * @method Phaser.Tilemaps.Tilemap#weightedRandomize + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. + */ + weightedRandomize: function (tileX, tileY, width, height, weightedIndexes, layer) + { + layer = this.getLayer(layer); + + if (this._isStaticCall(layer, 'weightedRandomize')) { return this; } + + if (layer !== null) + { + TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, layer); + } + + return this; + }, + + /** + * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileX + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileX: function (worldX, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer); + }, + + /** + * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the + * layers position, scale and scroll. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileY + * @since 3.0.0 + * + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?number} Returns a number, or null if the layer given was invalid. + */ + worldToTileY: function (worldY, snapToFloor, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer); + }, + + /** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layers position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * If no layer specified, the maps current layer is used. + * + * @method Phaser.Tilemaps.Tilemap#worldToTileXY + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} [layer] - The tile layer to use. If not given the current layer is used. + * + * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. + */ + worldToTileXY: function (worldX, worldY, snapToFloor, point, camera, layer) + { + layer = this.getLayer(layer); + + if (layer === null) { return null; } + + return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer); + }, + + /** + * Used internally to check if a layer is static and prints out a warning. + * + * @method Phaser.Tilemaps.Tilemap#_isStaticCall + * @private + * @since 3.0.0 + * + * @return {boolean} + */ + _isStaticCall: function (layer, functionName) + { + if (layer.tilemapLayer instanceof StaticTilemapLayer) + { + console.warn(functionName + ': You cannot change the tiles in a static tilemap layer'); + return true; + } + else + { + return false; + } + } + +}); + +module.exports = Tilemap; + + +/***/ }), +/* 210 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var MapData = __webpack_require__(77); +var ParseTileLayers = __webpack_require__(451); +var ParseTilesets = __webpack_require__(450); + +/** + * @namespace Phaser.Tilemaps.Parsers.Impact + */ + +/** + * Parses a Weltmeister JSON object into a new MapData object. + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Weltmeister JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {?object} [description] + */ +var ParseWeltmeister = function (name, json, insertNull) +{ + if (json.layer.length === 0) + { + console.warn('No layers found in the Weltmeister map: ' + name); + return null; + } + + var width = 0; + var height = 0; + + for (var i = 0; i < json.layer.length; i++) + { + if (json.layer[i].width > width) { width = json.layer[i].width; } + if (json.layer[i].height > height) { height = json.layer[i].height; } + } + + var mapData = new MapData({ + width: width, + height: height, + name: name, + tileWidth: json.layer[0].tilesize, + tileHeight: json.layer[0].tilesize, + format: Formats.WELTMEISTER + }); + + mapData.layers = ParseTileLayers(json, insertNull); + mapData.tilesets = ParseTilesets(json); + + return mapData; +}; + +module.exports = ParseWeltmeister; + + +/***/ }), +/* 211 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); + +/** + * @classdesc + * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled + * object layer, except: + * - "x" & "y" properties are ignored since these cannot be changed in Tiled. + * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they + * are ignored as well. + * - "draworder" is ignored. + * + * @class ObjectLayer + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {object} [config] - [description] + */ +var ObjectLayer = new Class({ + + initialize: + + function ObjectLayer (config) + { + if (config === undefined) { config = {}; } + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#name + * @type {string} + * @since 3.0.0 + */ + this.name = GetFastValue(config, 'name', 'object layer'); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#opacity + * @type {number} + * @since 3.0.0 + */ + this.opacity = GetFastValue(config, 'opacity', 1); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = GetFastValue(config, 'properties', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#propertyTypes + * @type {object} + * @since 3.0.0 + */ + this.propertyTypes = GetFastValue(config, 'propertytypes', {}); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#type + * @type {string} + * @since 3.0.0 + */ + this.type = GetFastValue(config, 'type', 'objectgroup'); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#visible + * @type {boolean} + * @since 3.0.0 + */ + this.visible = GetFastValue(config, 'visible', true); + + /** + * [description] + * + * @name Phaser.Tilemaps.ObjectLayer#objects + * @type {Phaser.GameObjects.GameObject[]} + * @since 3.0.0 + */ + this.objects = GetFastValue(config, 'objects', []); + } + +}); + +module.exports = ObjectLayer; + + +/***/ }), +/* 212 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Pick = __webpack_require__(455); +var ParseGID = __webpack_require__(214); + +var copyPoints = function (p) { return { x: p.x, y: p.y }; }; + +var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject + * @since 3.0.0 + * + * @param {object} tiledObject - [description] + * @param {number} [offsetX=0] - [description] + * @param {number} [offsetY=0] - [description] + * + * @return {object} [description] + */ +var ParseObject = function (tiledObject, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + var parsedObject = Pick(tiledObject, commonObjectProps); + + parsedObject.x += offsetX; + parsedObject.y += offsetY; + + if (tiledObject.gid) + { + // Object tiles + var gidInfo = ParseGID(tiledObject.gid); + parsedObject.gid = gidInfo.gid; + parsedObject.flippedHorizontal = gidInfo.flippedHorizontal; + parsedObject.flippedVertical = gidInfo.flippedVertical; + parsedObject.flippedAntiDiagonal = gidInfo.flippedAntiDiagonal; + } + else if (tiledObject.polyline) + { + parsedObject.polyline = tiledObject.polyline.map(copyPoints); + } + else if (tiledObject.polygon) + { + parsedObject.polygon = tiledObject.polygon.map(copyPoints); + } + else if (tiledObject.ellipse) + { + parsedObject.ellipse = tiledObject.ellipse; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + } + else if (tiledObject.text) + { + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + parsedObject.text = tiledObject.text; + } + else + { + // Otherwise, assume it is a rectangle + parsedObject.rectangle = true; + parsedObject.width = tiledObject.width; + parsedObject.height = tiledObject.height; + } + + return parsedObject; +}; + +module.exports = ParseObject; + + +/***/ }), +/* 213 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. + * + * Image Collections are normally created automatically when Tiled data is loaded. + * + * @class ImageCollection + * @memberof Phaser.Tilemaps + * @constructor + * @since 3.0.0 + * + * @param {string} name - The name of the image collection in the map data. + * @param {integer} firstgid - The first image index this image collection contains. + * @param {integer} [width=32] - Width of widest image (in pixels). + * @param {integer} [height=32] - Height of tallest image (in pixels). + * @param {integer} [margin=0] - The margin around all images in the collection (in pixels). + * @param {integer} [spacing=0] - The spacing between each image in the collection (in pixels). + * @param {object} [properties={}] - Custom Image Collection properties. + */ +var ImageCollection = new Class({ + + initialize: + + function ImageCollection (name, firstgid, width, height, margin, spacing, properties) + { + if (width === undefined || width <= 0) { width = 32; } + if (height === undefined || height <= 0) { height = 32; } + if (margin === undefined) { margin = 0; } + if (spacing === undefined) { spacing = 0; } + + /** + * The name of the Image Collection. + * + * @name Phaser.Tilemaps.ImageCollection#name + * @type {string} + * @since 3.0.0 + */ + this.name = name; + + /** + * The Tiled firstgid value. + * This is the starting index of the first image index this Image Collection contains. + * + * @name Phaser.Tilemaps.ImageCollection#firstgid + * @type {integer} + * @since 3.0.0 + */ + this.firstgid = firstgid | 0; + + /** + * The width of the widest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageWidth + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageWidth = width | 0; + + /** + * The height of the tallest image (in pixels). + * + * @name Phaser.Tilemaps.ImageCollection#imageHeight + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageHeight = height | 0; + + /** + * The margin around the images in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageMarge + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageMargin = margin | 0; + + /** + * The spacing between each image in the collection (in pixels). + * Use `setSpacing` to change. + * + * @name Phaser.Tilemaps.ImageCollection#imageSpacing + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.imageSpacing = spacing | 0; + + /** + * Image Collection-specific properties that are typically defined in the Tiled editor. + * + * @name Phaser.Tilemaps.ImageCollection#properties + * @type {object} + * @since 3.0.0 + */ + this.properties = properties || {}; + + /** + * The cached images that are a part of this collection. + * + * @name Phaser.Tilemaps.ImageCollection#images + * @type {array} + * @readonly + * @since 3.0.0 + */ + this.images = []; + + /** + * The total number of images in the image collection. + * + * @name Phaser.Tilemaps.ImageCollection#total + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.total = 0; + }, + + /** + * Returns true if and only if this image collection contains the given image index. + * + * @method Phaser.Tilemaps.ImageCollection#containsImageIndex + * @since 3.0.0 + * + * @param {integer} imageIndex - The image index to search for. + * + * @return {boolean} True if this Image Collection contains the given index. + */ + containsImageIndex: function (imageIndex) + { + return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)); + }, + + /** + * Add an image to this Image Collection. + * + * @method Phaser.Tilemaps.ImageCollection#addImage + * @since 3.0.0 + * + * @param {integer} gid - The gid of the image in the Image Collection. + * @param {string} image - The the key of the image in the Image Collection and in the cache. + * + * @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object. + */ + addImage: function (gid, image) + { + this.images.push({ gid: gid, image: image }); + this.total++; + + return this; + } + +}); + +module.exports = ImageCollection; + + +/***/ }), +/* 214 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FLIPPED_HORIZONTAL = 0x80000000; +var FLIPPED_VERTICAL = 0x40000000; +var FLIPPED_ANTI_DIAGONAL = 0x20000000; // Top-right is swapped with bottom-left corners + +/** + * See Tiled documentation on tile flipping: + * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseGID + * @since 3.0.0 + * + * @param {number} gid - [description] + * + * @return {object} [description] + */ +var ParseGID = function (gid) +{ + var flippedHorizontal = Boolean(gid & FLIPPED_HORIZONTAL); + var flippedVertical = Boolean(gid & FLIPPED_VERTICAL); + var flippedAntiDiagonal = Boolean(gid & FLIPPED_ANTI_DIAGONAL); + gid = gid & ~(FLIPPED_HORIZONTAL | FLIPPED_VERTICAL | FLIPPED_ANTI_DIAGONAL); + + // Parse the flip flags into something Phaser can use + var rotation = 0; + var flipped = false; + + if (flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = true; + } + else if (flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = Math.PI / 2; + flipped = false; + } + else if (flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = true; + } + else if (!flippedHorizontal && flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = false; + } + else if (!flippedHorizontal && flippedVertical && !flippedAntiDiagonal) + { + rotation = Math.PI; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && flippedAntiDiagonal) + { + rotation = 3 * Math.PI / 2; + flipped = true; + } + else if (!flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) + { + rotation = 0; + flipped = false; + } + + return { + gid: gid, + flippedHorizontal: flippedHorizontal, + flippedVertical: flippedVertical, + flippedAntiDiagonal: flippedAntiDiagonal, + rotation: rotation, + flipped: flipped + }; +}; + +module.exports = ParseGID; + + +/***/ }), +/* 215 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var MapData = __webpack_require__(77); +var ParseTileLayers = __webpack_require__(459); +var ParseImageLayers = __webpack_require__(457); +var ParseTilesets = __webpack_require__(456); +var ParseObjectLayers = __webpack_require__(454); +var BuildTilesetIndex = __webpack_require__(453); +var AssignTileProperties = __webpack_require__(452); + +/** + * @namespace Phaser.Tilemaps.Parsers.Tiled + */ + +/** + * Parses a Tiled JSON object into a new MapData object. + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {object} json - The Tiled JSON object. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {?Phaser.Tilemaps.MapData} The created MapData object, or `null` if the data can't be parsed. + */ +var ParseJSONTiled = function (name, json, insertNull) +{ + if (json.orientation !== 'orthogonal') + { + console.warn('Only orthogonal map types are supported in this version of Phaser'); + return null; + } + + // Map data will consist of: layers, objects, images, tilesets, sizes + var mapData = new MapData({ + width: json.width, + height: json.height, + name: name, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + orientation: json.orientation, + format: Formats.TILED_JSON, + version: json.version, + properties: json.properties, + renderOrder: json.renderorder + }); + + mapData.layers = ParseTileLayers(json, insertNull); + mapData.images = ParseImageLayers(json); + + var sets = ParseTilesets(json); + mapData.tilesets = sets.tilesets; + mapData.imageCollections = sets.imageCollections; + + mapData.objects = ParseObjectLayers(json); + + mapData.tiles = BuildTilesetIndex(mapData); + + AssignTileProperties(mapData); + + return mapData; +}; + +module.exports = ParseJSONTiled; + + +/***/ }), +/* 216 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var Parse2DArray = __webpack_require__(133); + +/** + * Parses a CSV string of tile indexes into a new MapData object with a single layer. + * + * @function Phaser.Tilemaps.Parsers.ParseCSV + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {string} data - CSV string of tile indexes. + * @param {integer} tileWidth - The width of a tile in pixels. + * @param {integer} tileHeight - The height of a tile in pixels. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.MapData} The resulting MapData object. + */ +var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) +{ + var array2D = data + .trim() + .split('\n') + .map(function (row) { return row.split(','); }); + + var map = Parse2DArray(name, array2D, tileWidth, tileHeight, insertNull); + map.format = Formats.CSV; + + return map; +}; + +module.exports = ParseCSV; + + +/***/ }), +/* 217 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Formats = __webpack_require__(29); +var Parse2DArray = __webpack_require__(133); +var ParseCSV = __webpack_require__(216); +var ParseJSONTiled = __webpack_require__(215); +var ParseWeltmeister = __webpack_require__(210); + +/** + * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format + * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & + * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from + * the map data. + * + * @function Phaser.Tilemaps.Parsers.Parse + * @since 3.0.0 + * + * @param {string} name - The name of the tilemap, used to set the name on the MapData. + * @param {integer} mapFormat - See ../Formats.js. + * @param {(integer[][]|string|object)} data - 2D array, CSV string or Tiled JSON object. + * @param {integer} tileWidth - The width of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {integer} tileHeight - The height of a tile in pixels. Required for 2D array and CSV, but + * ignored for Tiled JSON. + * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map + * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * location will get a Tile object with an index of -1. If you've a large sparsely populated map and + * the tile data doesn't need to change then setting this value to `true` will help with memory + * consumption. However if your map is small or you need to update the tiles dynamically, then leave + * the default value set. + * + * @return {Phaser.Tilemaps.MapData} The created `MapData` object. + */ +var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) +{ + var newMap; + + switch (mapFormat) + { + case (Formats.ARRAY_2D): + newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.CSV): + newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull); + break; + case (Formats.TILED_JSON): + newMap = ParseJSONTiled(name, data, insertNull); + break; + case (Formats.WELTMEISTER): + newMap = ParseWeltmeister(name, data, insertNull); + break; + default: + console.warn('Unrecognized tilemap data format: ' + mapFormat); + newMap = null; + } + + return newMap; +}; + +module.exports = Parse; + + +/***/ }), +/* 218 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tile = __webpack_require__(55); +var IsInLayerBounds = __webpack_require__(79); +var CalculateFacesAt = __webpack_require__(136); + +/** + * Removes the tile at the given tile coordinates in the specified layer and updates the layer's + * collision information. + * + * @function Phaser.Tilemaps.Components.RemoveTileAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + */ +var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer) +{ + if (replaceWithNull === undefined) { replaceWithNull = false; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + + var tile = layer.data[tileY][tileX]; + if (tile === null) + { + return null; + } + else + { + layer.data[tileY][tileX] = replaceWithNull + ? null + : new Tile(layer, -1, tileX, tileY, tile.width, tile.height); + } + + // Recalculate faces only if the removed tile was a colliding tile + if (recalculateFaces && tile && tile.collides) + { + CalculateFacesAt(tileX, tileY, layer); + } + + return tile; +}; + +module.exports = RemoveTileAt; + + +/***/ }), +/* 219 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsInLayerBounds = __webpack_require__(79); + +/** + * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @function Phaser.Tilemaps.Components.HasTileAt + * @private + * @since 3.0.0 + * + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ +var HasTileAt = function (tileX, tileY, layer) +{ + if (IsInLayerBounds(tileX, tileY, layer)) + { + var tile = layer.data[tileY][tileX]; + return (tile !== null && tile.index > -1); + } + else + { + return false; + } + +}; + +module.exports = HasTileAt; + + +/***/ }), +/* 220 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does + * not change collision information. + * + * @function Phaser.Tilemaps.Components.ReplaceByIndex + * @private + * @since 3.0.0 + * + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + if (tiles[i] && tiles[i].index === findIndex) + { + tiles[i].index = newIndex; + } + } +}; + +module.exports = ReplaceByIndex; + + +/***/ }), +/* 221 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37424,7 +53760,7 @@ var Class = __webpack_require__(0); * It can listen for Game events and respond to them. * * @class BasePlugin - * @memberOf Phaser.Plugins + * @memberof Phaser.Plugins * @constructor * @since 3.8.0 * @@ -37492,6 +53828,8 @@ var BasePlugin = new Class({ * * @method Phaser.Plugins.BasePlugin#init * @since 3.8.0 + * + * @param {?any} [data] - A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually). */ init: function () { @@ -37586,336 +53924,134 @@ module.exports = BasePlugin; /***/ }), -/* 166 */ +/* 222 */ /***/ (function(module, exports, __webpack_require__) { /** -* The `Matter.Bodies` module contains factory methods for creating rigid body models -* with commonly used body configurations (such as rectangles, circles and other polygons). +* The `Matter.Sleeping` module contains methods to manage the sleeping state of bodies. * -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Bodies +* @class Sleeping */ -// TODO: true circle bodies +var Sleeping = {}; -var Bodies = {}; +module.exports = Sleeping; -module.exports = Bodies; - -var Vertices = __webpack_require__(126); -var Common = __webpack_require__(41); -var Body = __webpack_require__(74); -var Bounds = __webpack_require__(125); -var Vector = __webpack_require__(106); -var decomp = __webpack_require__(1017); +var Events = __webpack_require__(195); (function() { + Sleeping._motionWakeThreshold = 0.18; + Sleeping._motionSleepThreshold = 0.08; + Sleeping._minBias = 0.9; + /** - * Creates a new rigid body model with a rectangle hull. - * The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method rectangle - * @param {number} x - * @param {number} y - * @param {number} width - * @param {number} height - * @param {object} [options] - * @return {body} A new rectangle body + * Puts bodies to sleep or wakes them up depending on their motion. + * @method update + * @param {body[]} bodies + * @param {number} timeScale */ - Bodies.rectangle = function(x, y, width, height, options) { - options = options || {}; + Sleeping.update = function(bodies, timeScale) { + var timeFactor = timeScale * timeScale * timeScale; - var rectangle = { - label: 'Rectangle Body', - position: { x: x, y: y }, - vertices: Vertices.fromPath('L 0 0 L ' + width + ' 0 L ' + width + ' ' + height + ' L 0 ' + height) - }; + // update bodies sleeping status + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + motion = body.speed * body.speed + body.angularSpeed * body.angularSpeed; - if (options.chamfer) { - var chamfer = options.chamfer; - rectangle.vertices = Vertices.chamfer(rectangle.vertices, chamfer.radius, - chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); - delete options.chamfer; - } + // wake up bodies if they have a force applied + if (body.force.x !== 0 || body.force.y !== 0) { + Sleeping.set(body, false); + continue; + } - return Body.create(Common.extend({}, rectangle, options)); - }; - - /** - * Creates a new rigid body model with a trapezoid hull. - * The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method trapezoid - * @param {number} x - * @param {number} y - * @param {number} width - * @param {number} height - * @param {number} slope - * @param {object} [options] - * @return {body} A new trapezoid body - */ - Bodies.trapezoid = function(x, y, width, height, slope, options) { - options = options || {}; - - slope *= 0.5; - var roof = (1 - (slope * 2)) * width; + var minMotion = Math.min(body.motion, motion), + maxMotion = Math.max(body.motion, motion); - var x1 = width * slope, - x2 = x1 + roof, - x3 = x2 + x1, - verticesPath; - - if (slope < 0.5) { - verticesPath = 'L 0 0 L ' + x1 + ' ' + (-height) + ' L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; - } else { - verticesPath = 'L 0 0 L ' + x2 + ' ' + (-height) + ' L ' + x3 + ' 0'; + // biased average motion estimation between frames + body.motion = Sleeping._minBias * minMotion + (1 - Sleeping._minBias) * maxMotion; + + if (body.sleepThreshold > 0 && body.motion < Sleeping._motionSleepThreshold * timeFactor) { + body.sleepCounter += 1; + + if (body.sleepCounter >= body.sleepThreshold) + Sleeping.set(body, true); + } else if (body.sleepCounter > 0) { + body.sleepCounter -= 1; + } } - - var trapezoid = { - label: 'Trapezoid Body', - position: { x: x, y: y }, - vertices: Vertices.fromPath(verticesPath) - }; - - if (options.chamfer) { - var chamfer = options.chamfer; - trapezoid.vertices = Vertices.chamfer(trapezoid.vertices, chamfer.radius, - chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); - delete options.chamfer; - } - - return Body.create(Common.extend({}, trapezoid, options)); }; /** - * Creates a new rigid body model with a circle hull. - * The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method circle - * @param {number} x - * @param {number} y - * @param {number} radius - * @param {object} [options] - * @param {number} [maxSides] - * @return {body} A new circle body + * Given a set of colliding pairs, wakes the sleeping bodies involved. + * @method afterCollisions + * @param {pair[]} pairs + * @param {number} timeScale */ - Bodies.circle = function(x, y, radius, options, maxSides) { - options = options || {}; + Sleeping.afterCollisions = function(pairs, timeScale) { + var timeFactor = timeScale * timeScale * timeScale; - var circle = { - label: 'Circle Body', - circleRadius: radius - }; + // wake up bodies involved in collisions + for (var i = 0; i < pairs.length; i++) { + var pair = pairs[i]; + + // don't wake inactive pairs + if (!pair.isActive) + continue; + + var collision = pair.collision, + bodyA = collision.bodyA.parent, + bodyB = collision.bodyB.parent; - // approximate circles with polygons until true circles implemented in SAT - maxSides = maxSides || 25; - var sides = Math.ceil(Math.max(10, Math.min(maxSides, radius))); + // don't wake if at least one body is static + if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic) + continue; + + if (bodyA.isSleeping || bodyB.isSleeping) { + var sleepingBody = (bodyA.isSleeping && !bodyA.isStatic) ? bodyA : bodyB, + movingBody = sleepingBody === bodyA ? bodyB : bodyA; - // optimisation: always use even number of sides (half the number of unique axes) - if (sides % 2 === 1) - sides += 1; - - return Bodies.polygon(x, y, sides, radius, Common.extend({}, circle, options)); - }; - - /** - * Creates a new rigid body model with a regular polygon hull with the given number of sides. - * The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method polygon - * @param {number} x - * @param {number} y - * @param {number} sides - * @param {number} radius - * @param {object} [options] - * @return {body} A new regular polygon body - */ - Bodies.polygon = function(x, y, sides, radius, options) { - options = options || {}; - - if (sides < 3) - return Bodies.circle(x, y, radius, options); - - var theta = 2 * Math.PI / sides, - path = '', - offset = theta * 0.5; - - for (var i = 0; i < sides; i += 1) { - var angle = offset + (i * theta), - xx = Math.cos(angle) * radius, - yy = Math.sin(angle) * radius; - - path += 'L ' + xx.toFixed(3) + ' ' + yy.toFixed(3) + ' '; - } - - var polygon = { - label: 'Polygon Body', - position: { x: x, y: y }, - vertices: Vertices.fromPath(path) - }; - - if (options.chamfer) { - var chamfer = options.chamfer; - polygon.vertices = Vertices.chamfer(polygon.vertices, chamfer.radius, - chamfer.quality, chamfer.qualityMin, chamfer.qualityMax); - delete options.chamfer; - } - - return Body.create(Common.extend({}, polygon, options)); - }; - - /** - * Creates a body using the supplied vertices (or an array containing multiple sets of vertices). - * If the vertices are convex, they will pass through as supplied. - * Otherwise if the vertices are concave, they will be decomposed if [poly-decomp.js](https://github.com/schteppe/poly-decomp.js) is available. - * Note that this process is not guaranteed to support complex sets of vertices (e.g. those with holes may fail). - * By default the decomposition will discard collinear edges (to improve performance). - * It can also optionally discard any parts that have an area less than `minimumArea`. - * If the vertices can not be decomposed, the result will fall back to using the convex hull. - * The options parameter is an object that specifies any `Matter.Body` properties you wish to override the defaults. - * See the properties section of the `Matter.Body` module for detailed information on what you can pass via the `options` object. - * @method fromVertices - * @param {number} x - * @param {number} y - * @param [[vector]] vertexSets - * @param {object} [options] - * @param {bool} [flagInternal=false] - * @param {number} [removeCollinear=0.01] - * @param {number} [minimumArea=10] - * @return {body} - */ - Bodies.fromVertices = function(x, y, vertexSets, options, flagInternal, removeCollinear, minimumArea) { - var body, - parts, - isConvex, - vertices, - i, - j, - k, - v, - z; - - options = options || {}; - parts = []; - - flagInternal = typeof flagInternal !== 'undefined' ? flagInternal : false; - removeCollinear = typeof removeCollinear !== 'undefined' ? removeCollinear : 0.01; - minimumArea = typeof minimumArea !== 'undefined' ? minimumArea : 10; - - if (!decomp) { - Common.warn('Bodies.fromVertices: poly-decomp.js required. Could not decompose vertices. Fallback to convex hull.'); - } - - // ensure vertexSets is an array of arrays - if (!Common.isArray(vertexSets[0])) { - vertexSets = [vertexSets]; - } - - for (v = 0; v < vertexSets.length; v += 1) { - vertices = vertexSets[v]; - isConvex = Vertices.isConvex(vertices); - - if (isConvex || !decomp) { - if (isConvex) { - vertices = Vertices.clockwiseSort(vertices); - } else { - // fallback to convex hull when decomposition is not possible - vertices = Vertices.hull(vertices); - } - - parts.push({ - position: { x: x, y: y }, - vertices: vertices - }); - } else { - // initialise a decomposition - var concave = vertices.map(function(vertex) { - return [vertex.x, vertex.y]; - }); - - // vertices are concave and simple, we can decompose into parts - decomp.makeCCW(concave); - if (removeCollinear !== false) - decomp.removeCollinearPoints(concave, removeCollinear); - - // use the quick decomposition algorithm (Bayazit) - var decomposed = decomp.quickDecomp(concave); - - // for each decomposed chunk - for (i = 0; i < decomposed.length; i++) { - var chunk = decomposed[i]; - - // convert vertices into the correct structure - var chunkVertices = chunk.map(function(vertices) { - return { - x: vertices[0], - y: vertices[1] - }; - }); - - // skip small chunks - if (minimumArea > 0 && Vertices.area(chunkVertices) < minimumArea) - continue; - - // create a compound part - parts.push({ - position: Vertices.centre(chunkVertices), - vertices: chunkVertices - }); + if (!sleepingBody.isStatic && movingBody.motion > Sleeping._motionWakeThreshold * timeFactor) { + Sleeping.set(sleepingBody, false); } } } + }; + + /** + * Set a body as sleeping or awake. + * @method set + * @param {body} body + * @param {boolean} isSleeping + */ + Sleeping.set = function(body, isSleeping) { + var wasSleeping = body.isSleeping; - // create body parts - for (i = 0; i < parts.length; i++) { - parts[i] = Body.create(Common.extend(parts[i], options)); - } + if (isSleeping) { + body.isSleeping = true; + body.sleepCounter = body.sleepThreshold; - // flag internal edges (coincident part edges) - if (flagInternal) { - var coincident_max_dist = 5; + body.positionImpulse.x = 0; + body.positionImpulse.y = 0; - for (i = 0; i < parts.length; i++) { - var partA = parts[i]; + body.positionPrev.x = body.position.x; + body.positionPrev.y = body.position.y; - for (j = i + 1; j < parts.length; j++) { - var partB = parts[j]; + body.anglePrev = body.angle; + body.speed = 0; + body.angularSpeed = 0; + body.motion = 0; - if (Bounds.overlaps(partA.bounds, partB.bounds)) { - var pav = partA.vertices, - pbv = partB.vertices; - - // iterate vertices of both parts - for (k = 0; k < partA.vertices.length; k++) { - for (z = 0; z < partB.vertices.length; z++) { - // find distances between the vertices - var da = Vector.magnitudeSquared(Vector.sub(pav[(k + 1) % pav.length], pbv[z])), - db = Vector.magnitudeSquared(Vector.sub(pav[k], pbv[(z + 1) % pbv.length])); - - // if both vertices are very close, consider the edge concident (internal) - if (da < coincident_max_dist && db < coincident_max_dist) { - pav[k].isInternal = true; - pbv[z].isInternal = true; - } - } - } - - } - } + if (!wasSleeping) { + Events.trigger(body, 'sleepStart'); } - } - - if (parts.length > 1) { - // create the parent body to be returned, that contains generated compound parts - body = Body.create(Common.extend({ parts: parts.slice(0) }, options)); - Body.setPosition(body, { x: x, y: y }); - - return body; } else { - return parts[0]; + body.isSleeping = false; + body.sleepCounter = 0; + + if (wasSleeping) { + Events.trigger(body, 'sleepEnd'); + } } }; @@ -37923,7 +54059,1727 @@ var decomp = __webpack_require__(1017); /***/ }), -/* 167 */ +/* 223 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Collision Types - Determine if and how entities collide with each other. + * + * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, + * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE + * collisions, both entities are moved. LITE or PASSIVE entities don't collide + * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. + * FIXED collisions is undefined. + * + * @name Phaser.Physics.Impact.TYPE + * @enum {integer} + * @memberof Phaser.Physics.Impact + * @readonly + * @since 3.0.0 + */ +module.exports = { + + /** + * Collides with nothing. + * + * @name Phaser.Physics.Impact.TYPE.NONE + */ + NONE: 0, + + /** + * Type A. Collides with Type B. + * + * @name Phaser.Physics.Impact.TYPE.A + */ + A: 1, + + /** + * Type B. Collides with Type A. + * + * @name Phaser.Physics.Impact.TYPE.B + */ + B: 2, + + /** + * Collides with both types A and B. + * + * @name Phaser.Physics.Impact.TYPE.BOTH + */ + BOTH: 3 + +}; + + +/***/ }), +/* 224 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Collision Types - Determine if and how entities collide with each other. + * + * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, + * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE + * collisions, both entities are moved. LITE or PASSIVE entities don't collide + * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. + * FIXED collisions is undefined. + * + * @name Phaser.Physics.Impact.COLLIDES + * @enum {integer} + * @memberof Phaser.Physics.Impact + * @readonly + * @since 3.0.0 + */ +module.exports = { + + /** + * Never collides. + * + * @name Phaser.Physics.Impact.COLLIDES.NEVER + */ + NEVER: 0, + + /** + * Lite collision. + * + * @name Phaser.Physics.Impact.COLLIDES.LITE + */ + LITE: 1, + + /** + * Passive collision. + * + * @name Phaser.Physics.Impact.COLLIDES.PASSIVE + */ + PASSIVE: 2, + + /** + * Active collision. + * + * @name Phaser.Physics.Impact.COLLIDES.ACTIVE + */ + ACTIVE: 4, + + /** + * Fixed collision. + * + * @name Phaser.Physics.Impact.COLLIDES.FIXED + */ + FIXED: 8 + +}; + + +/***/ }), +/* 225 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircleContains = __webpack_require__(40); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var RectangleContains = __webpack_require__(39); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Static Arcade Physics Body. + * + * A Static Body never moves, and isn't automatically synchronized with its parent Game Object. + * That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually. + * + * A Static Body can collide with other Bodies, but is never moved by collisions. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Body}. + * + * @class StaticBody + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ +var StaticBody = new Class({ + + initialize: + + function StaticBody (world, gameObject) + { + var width = (gameObject.width) ? gameObject.width : 64; + var height = (gameObject.height) ? gameObject.height : 64; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#gameObject + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.gameObject = gameObject; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowStaticBody; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.staticBodyDebugColor; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#enable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enable = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#isCircle + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isCircle = false; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#radius + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.radius = 0; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#offset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.offset = new Vector2(); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#width + * @type {number} + * @since 3.0.0 + */ + this.width = width; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#height + * @type {number} + * @since 3.0.0 + */ + this.height = height; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(this.width / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(this.height / 2); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#velocity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.velocity = Vector2.ZERO; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.StaticBody#allowGravity + * @type {boolean} + * @readonly + * @default false + * @since 3.0.0 + */ + this.allowGravity = false; + + /** + * Gravitational force applied specifically to this Body. Values are in pixels per second squared. Always zero for a Static Body. + * + * @name Phaser.Physics.Arcade.StaticBody#gravity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.gravity = Vector2.ZERO; + + /** + * Rebound, or restitution, following a collision, relative to 1. Always zero for a Static Body. + * + * @name Phaser.Physics.Arcade.StaticBody#bounce + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.bounce = Vector2.ZERO; + + // If true this Body will dispatch events + + /** + * Whether the simulation emits a `worldbounds` event when this StaticBody collides with the world boundary (and `collideWorldBounds` is also true). + * + * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onWorldBounds = false; + + /** + * Whether the simulation emits a `collide` event when this StaticBody collides with another. + * + * @name Phaser.Physics.Arcade.StaticBody#onCollide + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onCollide = false; + + /** + * Whether the simulation emits an `overlap` event when this StaticBody overlaps with another. + * + * @name Phaser.Physics.Arcade.StaticBody#onOverlap + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.onOverlap = false; + + /** + * The StaticBody's inertia, relative to a default unit (1). With `bounce`, this affects the exchange of momentum (velocities) during collisions. + * + * @name Phaser.Physics.Arcade.StaticBody#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * Whether this object can be moved by collisions with another body. + * + * @name Phaser.Physics.Arcade.StaticBody#immovable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.immovable = true; + + /** + * A flag disabling the default horizontal separation of colliding bodies. Pass your own `processHandler` to the collider. + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * A flag disabling the default vertical separation of colliding bodies. Pass your own `processHandler` to the collider. + * + * @name Phaser.Physics.Arcade.StaticBody#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * The amount of horizontal overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.StaticBody#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * The amount of vertical overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.StaticBody#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * The amount of overlap (before separation), if this StaticBody is circular and colliding with another circular body. + * + * @name Phaser.Physics.Arcade.StaticBody#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * Whether this StaticBody is overlapped with another and both have zero velocity. + * + * @name Phaser.Physics.Arcade.StaticBody#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * Whether this StaticBody interacts with the world boundary. + * + * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * Whether this StaticBody is checked for collisions and for which directions. You can set `checkCollision.none = false` to disable collision checks. + * + * @name Phaser.Physics.Arcade.StaticBody#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * Whether this StaticBody is colliding with another and in which direction. + * + * @name Phaser.Physics.Arcade.StaticBody#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this StaticBody was colliding with another during the last step, and in which direction. + * + * @name Phaser.Physics.Arcade.StaticBody#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this StaticBody is colliding with a tile or the world boundary. + * + * @name Phaser.Physics.Arcade.StaticBody#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * The StaticBody's physics type (static by default). + * + * @name Phaser.Physics.Arcade.StaticBody#physicsType + * @type {integer} + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; + + /** + * The calculated change in the Body's horizontal position during the current step. + * For a static body this is always zero. + * + * @name Phaser.Physics.Arcade.StaticBody#_dx + * @type {number} + * @private + * @default 0 + * @since 3.10.0 + */ + this._dx = 0; + + /** + * The calculated change in the Body's vertical position during the current step. + * For a static body this is always zero. + * + * @name Phaser.Physics.Arcade.StaticBody#_dy + * @type {number} + * @private + * @default 0 + * @since 3.10.0 + */ + this._dy = 0; + }, + + /** + * Changes the Game Object this Body is bound to. + * First it removes its reference from the old Game Object, then sets the new one. + * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. + * + * @method Phaser.Physics.Arcade.StaticBody#setGameObject + * @since 3.1.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The new Game Object that will own this Body. + * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + * + * @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject + */ + setGameObject: function (gameObject, update) + { + if (gameObject && gameObject !== this.gameObject) + { + // Remove this body from the old game object + this.gameObject.body = null; + + gameObject.body = this; + + // Update our reference + this.gameObject = gameObject; + } + + if (update) + { + this.updateFromGameObject(); + } + + return this; + }, + + /** + * Updates this Static Body so that its position and dimensions are updated + * based on the current Game Object it is bound to. + * + * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject + * @since 3.1.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + updateFromGameObject: function () + { + this.world.staticTree.remove(this); + + var gameObject = this.gameObject; + + gameObject.getTopLeft(this.position); + + this.width = gameObject.displayWidth; + this.height = gameObject.displayHeight; + + this.halfWidth = Math.abs(this.width / 2); + this.halfHeight = Math.abs(this.height / 2); + + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * Sets the offset of the body. + * + * @method Phaser.Physics.Arcade.StaticBody#setOffset + * @since 3.4.0 + * + * @param {number} x - The horizontal offset of the Body from the Game Object's center. + * @param {number} y - The vertical offset of the Body from the Game Object's center. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setOffset: function (x, y) + { + if (y === undefined) { y = x; } + + this.world.staticTree.remove(this); + + this.position.x -= this.offset.x; + this.position.y -= this.offset.y; + + this.offset.set(x, y); + + this.position.x += this.offset.x; + this.position.y += this.offset.y; + + this.updateCenter(); + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * Sets the size of the body. + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * + * @method Phaser.Physics.Arcade.StaticBody#setSize + * @since 3.0.0 + * + * @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param {number} [offsetX] - The horizontal offset of the Body from the Game Object's center. + * @param {number} [offsetY] - The vertical offset of the Body from the Game Object's center. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setSize: function (width, height, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + var gameObject = this.gameObject; + + if (!width && gameObject.frame) + { + width = gameObject.frame.realWidth; + } + + if (!height && gameObject.frame) + { + height = gameObject.frame.realHeight; + } + + this.world.staticTree.remove(this); + + this.width = width; + this.height = height; + + this.halfWidth = Math.floor(width / 2); + this.halfHeight = Math.floor(height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.isCircle = false; + this.radius = 0; + + this.world.staticTree.insert(this); + + return this; + }, + + /** + * Sets this Static Body to have a circular body and sets its sizes and position. + * + * @method Phaser.Physics.Arcade.StaticBody#setCircle + * @since 3.0.0 + * + * @param {number} radius - The radius of the StaticBody, in pixels. + * @param {number} [offsetX] - The horizontal offset of the StaticBody from its Game Object, in pixels. + * @param {number} [offsetY] - The vertical offset of the StaticBody from its Game Object, in pixels. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.world.staticTree.remove(this); + + this.isCircle = true; + + this.radius = radius; + + this.width = radius * 2; + this.height = radius * 2; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + + this.world.staticTree.insert(this); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * Updates the StaticBody's `center` from its `position` and dimensions. + * + * @method Phaser.Physics.Arcade.StaticBody#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * Updates this Static Body's position based on the current Game Object it is bound to. + * Similar to `updateFromGameObject`, but doesn't modify the Body's dimensions. + * + * @method Phaser.Physics.Arcade.StaticBody#reset + * @since 3.0.0 + * + * @param {number} x - The x coordinate to reset the body to. + * @param {number} y - The y coordinate to reset the body to. + */ + reset: function (x, y) + { + var gameObject = this.gameObject; + + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + this.world.staticTree.remove(this); + + gameObject.getTopLeft(this.position); + + this.updateCenter(); + + this.world.staticTree.insert(this); + }, + + /** + * NOOP function. A Static Body cannot be stopped. + * + * @method Phaser.Physics.Arcade.StaticBody#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + stop: function () + { + return this; + }, + + /** + * Returns the x and y coordinates of the top left and bottom right points of the StaticBody. + * + * @method Phaser.Physics.Arcade.StaticBody#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - The object which will hold the coordinates of the bounds. + * + * @return {ArcadeBodyBounds} The same object that was passed with `x`, `y`, `right` and `bottom` values matching the respective values of the StaticBody. + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * Checks to see if a given x,y coordinate is colliding with this Static Body. + * + * @method Phaser.Physics.Arcade.StaticBody#hitTest + * @since 3.0.0 + * + * @param {number} x - The x coordinate to check against this body. + * @param {number} y - The y coordinate to check against this body. + * + * @return {boolean} `true` if the given coordinate lies within this body, otherwise `false`. + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * NOOP + * + * @method Phaser.Physics.Arcade.StaticBody#postUpdate + * @since 3.12.0 + */ + postUpdate: function () + { + }, + + /** + * The absolute (non-negative) change in this StaticBody's horizontal position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX + * @since 3.0.0 + * + * @return {number} Always zero for a Static Body. + */ + deltaAbsX: function () + { + return 0; + }, + + /** + * The absolute (non-negative) change in this StaticBody's vertical position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY + * @since 3.0.0 + * + * @return {number} Always zero for a Static Body. + */ + deltaAbsY: function () + { + return 0; + }, + + /** + * The change in this StaticBody's horizontal position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaX + * @since 3.0.0 + * + * @return {number} Always zero for a Static Body. + */ + deltaX: function () + { + return 0; + }, + + /** + * The change in this StaticBody's vertical position from the previous step. Always zero. + * + * @method Phaser.Physics.Arcade.StaticBody#deltaY + * @since 3.0.0 + * + * @return {number} 0 + */ + deltaY: function () + { + return 0; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.StaticBody#deltaZ + * @since 3.0.0 + * + * @return {number} 0 + */ + deltaZ: function () + { + return 0; + }, + + /** + * Disables this Body and marks it for destruction during the next step. + * + * @method Phaser.Physics.Arcade.StaticBody#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * Draws a graphical representation of the StaticBody for visual debugging purposes. + * + * @method Phaser.Physics.Arcade.StaticBody#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - The Graphics object to use for the debug drawing of the StaticBody. + */ + drawDebug: function (graphic) + { + var pos = this.position; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor, 1); + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + }, + + /** + * Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate. + * + * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} Whether or not the StaticBody is going to show the debug visualization during postUpdate. + */ + willDrawDebug: function () + { + return this.debugShowBody; + }, + + /** + * Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero. + * + * @method Phaser.Physics.Arcade.StaticBody#setMass + * @since 3.0.0 + * + * @param {number} value - The value to set the Mass to. Values of zero or less are changed to 0.1. + * + * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + */ + setMass: function (value) + { + if (value <= 0) + { + // Causes havoc otherwise + value = 0.1; + } + + this.mass = value; + + return this; + }, + + /** + * The x coordinate of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.x = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * The y coordinate of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.world.staticTree.remove(this); + + this.position.y = value; + + this.world.staticTree.insert(this); + } + + }, + + /** + * Returns the left-most x coordinate of the area of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#left + * @type {number} + * @readonly + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.position.x; + } + + }, + + /** + * The right-most x coordinate of the area of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#right + * @type {number} + * @readonly + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.position.x + this.width; + } + + }, + + /** + * The highest y coordinate of the area of the StaticBody. + * + * @name Phaser.Physics.Arcade.StaticBody#top + * @type {number} + * @readonly + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.position.y; + } + + }, + + /** + * The lowest y coordinate of the area of the StaticBody. (y + height) + * + * @name Phaser.Physics.Arcade.StaticBody#bottom + * @type {number} + * @readonly + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.position.y + this.height; + } + + } + +}); + +module.exports = StaticBody; + + +/***/ }), +/* 226 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody + * @since 3.0.0 + * + * @param {{ left: number, right: number, top: number, bottom: number }} tileWorldRect - [description] + * @param {Phaser.Physics.Arcade.Body} body - [description] + * + * @return {boolean} [description] + */ +var TileIntersectsBody = function (tileWorldRect, body) +{ + // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this + // should support circle bodies when those are less buggy in v3. + + return !( + body.right <= tileWorldRect.left || + body.bottom <= tileWorldRect.top || + body.position.x >= tileWorldRect.right || + body.position.y >= tileWorldRect.bottom + ); +}; + +module.exports = TileIntersectsBody; + + +/***/ }), +/* 227 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var quickselect = __webpack_require__(313); + +/** + * @classdesc + * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. + * It's based on an optimized R-tree data structure with bulk insertion support. + * + * Spatial index is a special data structure for points and rectangles that allows you to perform queries like + * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). + * + * This version of RBush uses a fixed min/max accessor structure of `[ '.left', '.top', '.right', '.bottom' ]`. + * This is to avoid the eval like function creation that the original library used, which caused CSP policy violations. + * + * @class RTree + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + */ + +function rbush (maxEntries) +{ + var format = [ '.left', '.top', '.right', '.bottom' ]; + + if (!(this instanceof rbush)) return new rbush(maxEntries, format); + + // max entries in a node is 9 by default; min node fill is 40% for best performance + this._maxEntries = Math.max(4, maxEntries || 9); + this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); + + this.clear(); +} + +rbush.prototype = { + + all: function () + { + return this._all(this.data, []); + }, + + search: function (bbox) + { + var node = this.data, + result = [], + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return result; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf) result.push(child); + else if (contains(bbox, childBBox)) this._all(child, result); + else nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return result; + }, + + collides: function (bbox) + { + var node = this.data, + toBBox = this.toBBox; + + if (!intersects(bbox, node)) return false; + + var nodesToSearch = [], + i, len, child, childBBox; + + while (node) { + for (i = 0, len = node.children.length; i < len; i++) { + + child = node.children[i]; + childBBox = node.leaf ? toBBox(child) : child; + + if (intersects(bbox, childBBox)) { + if (node.leaf || contains(bbox, childBBox)) return true; + nodesToSearch.push(child); + } + } + node = nodesToSearch.pop(); + } + + return false; + }, + + load: function (data) + { + if (!(data && data.length)) return this; + + if (data.length < this._minEntries) { + for (var i = 0, len = data.length; i < len; i++) { + this.insert(data[i]); + } + return this; + } + + // recursively build the tree with the given data from scratch using OMT algorithm + var node = this._build(data.slice(), 0, data.length - 1, 0); + + if (!this.data.children.length) { + // save as is if tree is empty + this.data = node; + + } else if (this.data.height === node.height) { + // split root if trees have the same height + this._splitRoot(this.data, node); + + } else { + if (this.data.height < node.height) { + // swap trees if inserted one is bigger + var tmpNode = this.data; + this.data = node; + node = tmpNode; + } + + // insert the small tree into the large tree at appropriate level + this._insert(node, this.data.height - node.height - 1, true); + } + + return this; + }, + + insert: function (item) + { + if (item) this._insert(item, this.data.height - 1); + return this; + }, + + clear: function () + { + this.data = createNode([]); + return this; + }, + + remove: function (item, equalsFn) + { + if (!item) return this; + + var node = this.data, + bbox = this.toBBox(item), + path = [], + indexes = [], + i, parent, index, goingUp; + + // depth-first iterative tree traversal + while (node || path.length) { + + if (!node) { // go up + node = path.pop(); + parent = path[path.length - 1]; + i = indexes.pop(); + goingUp = true; + } + + if (node.leaf) { // check current node + index = findItem(item, node.children, equalsFn); + + if (index !== -1) { + // item found, remove the item and condense tree upwards + node.children.splice(index, 1); + path.push(node); + this._condense(path); + return this; + } + } + + if (!goingUp && !node.leaf && contains(node, bbox)) { // go down + path.push(node); + indexes.push(i); + i = 0; + parent = node; + node = node.children[0]; + + } else if (parent) { // go right + i++; + node = parent.children[i]; + goingUp = false; + + } else node = null; // nothing found + } + + return this; + }, + + toBBox: function (item) { return item; }, + + compareMinX: compareNodeMinX, + compareMinY: compareNodeMinY, + + toJSON: function () { return this.data; }, + + fromJSON: function (data) + { + this.data = data; + return this; + }, + + _all: function (node, result) + { + var nodesToSearch = []; + while (node) { + if (node.leaf) result.push.apply(result, node.children); + else nodesToSearch.push.apply(nodesToSearch, node.children); + + node = nodesToSearch.pop(); + } + return result; + }, + + _build: function (items, left, right, height) + { + var N = right - left + 1, + M = this._maxEntries, + node; + + if (N <= M) { + // reached leaf level; return leaf + node = createNode(items.slice(left, right + 1)); + calcBBox(node, this.toBBox); + return node; + } + + if (!height) { + // target height of the bulk-loaded tree + height = Math.ceil(Math.log(N) / Math.log(M)); + + // target number of root entries to maximize storage utilization + M = Math.ceil(N / Math.pow(M, height - 1)); + } + + node = createNode([]); + node.leaf = false; + node.height = height; + + // split the items into M mostly square tiles + + var N2 = Math.ceil(N / M), + N1 = N2 * Math.ceil(Math.sqrt(M)), + i, j, right2, right3; + + multiSelect(items, left, right, N1, this.compareMinX); + + for (i = left; i <= right; i += N1) { + + right2 = Math.min(i + N1 - 1, right); + + multiSelect(items, i, right2, N2, this.compareMinY); + + for (j = i; j <= right2; j += N2) { + + right3 = Math.min(j + N2 - 1, right2); + + // pack each entry recursively + node.children.push(this._build(items, j, right3, height - 1)); + } + } + + calcBBox(node, this.toBBox); + + return node; + }, + + _chooseSubtree: function (bbox, node, level, path) + { + var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; + + while (true) { + path.push(node); + + if (node.leaf || path.length - 1 === level) break; + + minArea = minEnlargement = Infinity; + + for (i = 0, len = node.children.length; i < len; i++) { + child = node.children[i]; + area = bboxArea(child); + enlargement = enlargedArea(bbox, child) - area; + + // choose entry with the least area enlargement + if (enlargement < minEnlargement) { + minEnlargement = enlargement; + minArea = area < minArea ? area : minArea; + targetNode = child; + + } else if (enlargement === minEnlargement) { + // otherwise choose one with the smallest area + if (area < minArea) { + minArea = area; + targetNode = child; + } + } + } + + node = targetNode || node.children[0]; + } + + return node; + }, + + _insert: function (item, level, isNode) + { + var toBBox = this.toBBox, + bbox = isNode ? item : toBBox(item), + insertPath = []; + + // find the best node for accommodating the item, saving all nodes along the path too + var node = this._chooseSubtree(bbox, this.data, level, insertPath); + + // put the item into the node + node.children.push(item); + extend(node, bbox); + + // split on node overflow; propagate upwards if necessary + while (level >= 0) { + if (insertPath[level].children.length > this._maxEntries) { + this._split(insertPath, level); + level--; + } else break; + } + + // adjust bboxes along the insertion path + this._adjustParentBBoxes(bbox, insertPath, level); + }, + + // split overflowed node into two + _split: function (insertPath, level) + { + var node = insertPath[level], + M = node.children.length, + m = this._minEntries; + + this._chooseSplitAxis(node, m, M); + + var splitIndex = this._chooseSplitIndex(node, m, M); + + var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); + newNode.height = node.height; + newNode.leaf = node.leaf; + + calcBBox(node, this.toBBox); + calcBBox(newNode, this.toBBox); + + if (level) insertPath[level - 1].children.push(newNode); + else this._splitRoot(node, newNode); + }, + + _splitRoot: function (node, newNode) + { + // split root node + this.data = createNode([node, newNode]); + this.data.height = node.height + 1; + this.data.leaf = false; + calcBBox(this.data, this.toBBox); + }, + + _chooseSplitIndex: function (node, m, M) + { + var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; + + minOverlap = minArea = Infinity; + + for (i = m; i <= M - m; i++) { + bbox1 = distBBox(node, 0, i, this.toBBox); + bbox2 = distBBox(node, i, M, this.toBBox); + + overlap = intersectionArea(bbox1, bbox2); + area = bboxArea(bbox1) + bboxArea(bbox2); + + // choose distribution with minimum overlap + if (overlap < minOverlap) { + minOverlap = overlap; + index = i; + + minArea = area < minArea ? area : minArea; + + } else if (overlap === minOverlap) { + // otherwise choose distribution with minimum area + if (area < minArea) { + minArea = area; + index = i; + } + } + } + + return index; + }, + + // sorts node children by the best axis for split + _chooseSplitAxis: function (node, m, M) + { + var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, + compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, + xMargin = this._allDistMargin(node, m, M, compareMinX), + yMargin = this._allDistMargin(node, m, M, compareMinY); + + // if total distributions margin value is minimal for x, sort by minX, + // otherwise it's already sorted by minY + if (xMargin < yMargin) node.children.sort(compareMinX); + }, + + // total margin of all possible split distributions where each node is at least m full + _allDistMargin: function (node, m, M, compare) + { + node.children.sort(compare); + + var toBBox = this.toBBox, + leftBBox = distBBox(node, 0, m, toBBox), + rightBBox = distBBox(node, M - m, M, toBBox), + margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), + i, child; + + for (i = m; i < M - m; i++) { + child = node.children[i]; + extend(leftBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(leftBBox); + } + + for (i = M - m - 1; i >= m; i--) { + child = node.children[i]; + extend(rightBBox, node.leaf ? toBBox(child) : child); + margin += bboxMargin(rightBBox); + } + + return margin; + }, + + _adjustParentBBoxes: function (bbox, path, level) + { + // adjust bboxes along the given tree path + for (var i = level; i >= 0; i--) { + extend(path[i], bbox); + } + }, + + _condense: function (path) + { + // go through the path, removing empty nodes and updating bboxes + for (var i = path.length - 1, siblings; i >= 0; i--) { + if (path[i].children.length === 0) { + if (i > 0) { + siblings = path[i - 1].children; + siblings.splice(siblings.indexOf(path[i]), 1); + + } else this.clear(); + + } else calcBBox(path[i], this.toBBox); + } + }, + + compareMinX: function (a, b) + { + return a.left - b.left; + }, + + compareMinY: function (a, b) + { + return a.top - b.top; + }, + + toBBox: function (a) + { + return { + minX: a.left, + minY: a.top, + maxX: a.right, + maxY: a.bottom + }; + } +}; + +function findItem (item, items, equalsFn) +{ + if (!equalsFn) return items.indexOf(item); + + for (var i = 0; i < items.length; i++) { + if (equalsFn(item, items[i])) return i; + } + return -1; +} + +// calculate node's bbox from bboxes of its children +function calcBBox (node, toBBox) +{ + distBBox(node, 0, node.children.length, toBBox, node); +} + +// min bounding rectangle of node children from k to p-1 +function distBBox (node, k, p, toBBox, destNode) +{ + if (!destNode) destNode = createNode(null); + destNode.minX = Infinity; + destNode.minY = Infinity; + destNode.maxX = -Infinity; + destNode.maxY = -Infinity; + + for (var i = k, child; i < p; i++) { + child = node.children[i]; + extend(destNode, node.leaf ? toBBox(child) : child); + } + + return destNode; +} + +function extend (a, b) +{ + a.minX = Math.min(a.minX, b.minX); + a.minY = Math.min(a.minY, b.minY); + a.maxX = Math.max(a.maxX, b.maxX); + a.maxY = Math.max(a.maxY, b.maxY); + return a; +} + +function compareNodeMinX (a, b) { return a.minX - b.minX; } +function compareNodeMinY (a, b) { return a.minY - b.minY; } + +function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } +function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } + +function enlargedArea (a, b) +{ + return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * + (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); +} + +function intersectionArea (a, b) +{ + var minX = Math.max(a.minX, b.minX), + minY = Math.max(a.minY, b.minY), + maxX = Math.min(a.maxX, b.maxX), + maxY = Math.min(a.maxY, b.maxY); + + return Math.max(0, maxX - minX) * + Math.max(0, maxY - minY); +} + +function contains (a, b) +{ + return a.minX <= b.minX && + a.minY <= b.minY && + b.maxX <= a.maxX && + b.maxY <= a.maxY; +} + +function intersects (a, b) +{ + return b.minX <= a.maxX && + b.minY <= a.maxY && + b.maxX >= a.minX && + b.maxY >= a.minY; +} + +function createNode (children) +{ + return { + children: children, + height: 1, + leaf: true, + minX: Infinity, + minY: Infinity, + maxX: -Infinity, + maxY: -Infinity + }; +} + +// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; +// combines selection algorithm with binary divide & conquer approach + +function multiSelect (arr, left, right, n, compare) +{ + var stack = [left, right], + mid; + + while (stack.length) + { + right = stack.pop(); + left = stack.pop(); + + if (right - left <= n) continue; + + mid = left + Math.ceil((right - left) / n / 2) * n; + quickselect(arr, mid, left, right, compare); + + stack.push(left, mid, mid, right); + } +} + +module.exports = rbush; + +/***/ }), +/* 228 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -37933,9 +55789,9247 @@ var decomp = __webpack_require__(1017); */ var Class = __webpack_require__(0); -var File = __webpack_require__(19); -var GetFastValue = __webpack_require__(1); -var GetURL = __webpack_require__(108); + +/** + * @classdesc + * [description] + * + * @class ProcessQueue + * @memberof Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + */ +var ProcessQueue = new Class({ + + initialize: + + function ProcessQueue () + { + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.ProcessQueue#_pending + * @type {Array.<*>} + * @private + * @default [] + * @since 3.0.0 + */ + this._pending = []; + + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.ProcessQueue#_active + * @type {Array.<*>} + * @private + * @default [] + * @since 3.0.0 + */ + this._active = []; + + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.ProcessQueue#_destroy + * @type {Array.<*>} + * @private + * @default [] + * @since 3.0.0 + */ + this._destroy = []; + + /** + * [description] + * + * @name Phaser.Structs.ProcessQueue#_toProcess + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._toProcess = 0; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#add + * @since 3.0.0 + * + * @genericUse {T} - [item] + * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + add: function (item) + { + this._pending.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#remove + * @since 3.0.0 + * + * @genericUse {T} - [item] + * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] + * + * @param {*} item - [description] + * + * @return {Phaser.Structs.ProcessQueue} This Process Queue object. + */ + remove: function (item) + { + this._destroy.push(item); + + this._toProcess++; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#update + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} [description] + */ + update: function () + { + if (this._toProcess === 0) + { + // Quick bail + return this._active; + } + + var list = this._destroy; + var active = this._active; + var i; + var item; + + // Clear the 'destroy' list + for (i = 0; i < list.length; i++) + { + item = list[i]; + + // Remove from the 'active' array + var idx = active.indexOf(item); + + if (idx !== -1) + { + active.splice(idx, 1); + } + } + + list.length = 0; + + // Process the pending addition list + // This stops callbacks and out of sync events from populating the active array mid-way during an update + + list = this._pending; + + for (i = 0; i < list.length; i++) + { + item = list[i]; + + this._active.push(item); + } + + list.length = 0; + + this._toProcess = 0; + + // The owner of this queue can now safely do whatever it needs to with the active list + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#getActive + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} [description] + */ + getActive: function () + { + return this._active; + }, + + /** + * [description] + * + * @method Phaser.Structs.ProcessQueue#destroy + * @since 3.0.0 + */ + destroy: function () + { + this._pending = []; + this._active = []; + this._destroy = []; + } + +}); + +module.exports = ProcessQueue; + + +/***/ }), +/* 229 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(35); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.GetOverlapY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {number} [description] + */ +var GetOverlapY = function (body1, body2, overlapOnly, bias) +{ + var overlap = 0; + var maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + bias; + + if (body1._dy === 0 && body2._dy === 0) + { + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1._dy > body2._dy) + { + // Body1 is moving down and/or Body2 is moving up + overlap = body1.bottom - body2.y; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.down === false || body2.checkCollision.up === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.down = true; + + body2.touching.none = false; + body2.touching.up = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.down = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.up = true; + } + } + } + else if (body1._dy < body2._dy) + { + // Body1 is moving up and/or Body2 is moving down + overlap = body1.y - body2.bottom; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.up === false || body2.checkCollision.down === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.up = true; + + body2.touching.none = false; + body2.touching.down = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.up = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.down = true; + } + } + } + + // Resets the overlapY to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapY = overlap; + body2.overlapY = overlap; + + return overlap; +}; + +module.exports = GetOverlapY; + + +/***/ }), +/* 230 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(35); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.GetOverlapX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {number} [description] + */ +var GetOverlapX = function (body1, body2, overlapOnly, bias) +{ + var overlap = 0; + var maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + bias; + + if (body1._dx === 0 && body2._dx === 0) + { + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1._dx > body2._dx) + { + // Body1 is moving right and / or Body2 is moving left + overlap = body1.right - body2.x; + + if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.right === false || body2.checkCollision.left === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.right = true; + + body2.touching.none = false; + body2.touching.left = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.right = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.left = true; + } + } + } + else if (body1._dx < body2._dx) + { + // Body1 is moving left and/or Body2 is moving right + overlap = body1.x - body2.width - body2.x; + + if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.left === false || body2.checkCollision.right === false) + { + overlap = 0; + } + else + { + body1.touching.none = false; + body1.touching.left = true; + + body2.touching.none = false; + body2.touching.right = true; + + if (body2.physicsType === CONST.STATIC_BODY) + { + body1.blocked.none = false; + body1.blocked.left = true; + } + + if (body1.physicsType === CONST.STATIC_BODY) + { + body2.blocked.none = false; + body2.blocked.right = true; + } + } + } + + // Resets the overlapX to zero if there is no overlap, or to the actual pixel value if there is + body1.overlapX = overlap; + body2.overlapX = overlap; + + return overlap; +}; + +module.exports = GetOverlapX; + + +/***/ }), +/* 231 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class Collider + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - [description] + * @param {boolean} overlapOnly - [description] + * @param {ArcadeColliderType} object1 - The first object to check for collision. + * @param {ArcadeColliderType} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {any} callbackContext - The scope in which to call the callbacks. + */ +var Collider = new Class({ + + initialize: + + function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) + { + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#name + * @type {string} + * @since 3.1.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#overlapOnly + * @type {boolean} + * @since 3.0.0 + */ + this.overlapOnly = overlapOnly; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object1 + * @type {ArcadeColliderType} + * @since 3.0.0 + */ + this.object1 = object1; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#object2 + * @type {ArcadeColliderType} + * @since 3.0.0 + */ + this.object2 = object2; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#collideCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.collideCallback = collideCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#processCallback + * @type {ArcadePhysicsCallback} + * @since 3.0.0 + */ + this.processCallback = processCallback; + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Collider#callbackContext + * @type {object} + * @since 3.0.0 + */ + this.callbackContext = callbackContext; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#setName + * @since 3.1.0 + * + * @param {string} name - [description] + * + * @return {Phaser.Physics.Arcade.Collider} [description] + */ + setName: function (name) + { + this.name = name; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#update + * @since 3.0.0 + */ + update: function () + { + this.world.collideObjects( + this.object1, + this.object2, + this.collideCallback, + this.processCallback, + this.callbackContext, + this.overlapOnly + ); + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Collider#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.world.removeCollider(this); + + this.active = false; + + this.world = null; + + this.object1 = null; + this.object2 = null; + + this.collideCallback = null; + this.processCallback = null; + this.callbackContext = null; + } + +}); + +module.exports = Collider; + + +/***/ }), +/* 232 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CircleContains = __webpack_require__(40); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var RadToDeg = __webpack_require__(172); +var Rectangle = __webpack_require__(9); +var RectangleContains = __webpack_require__(39); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} ArcadeBodyBounds + * + * @property {number} x - The left edge. + * @property {number} y - The upper edge. + * @property {number} right - The right edge. + * @property {number} bottom - The lower edge. + */ + +/** + * @typedef {object} ArcadeBodyCollision + * + * @property {boolean} none - True if the Body is not colliding. + * @property {boolean} up - True if the Body is colliding on its upper edge. + * @property {boolean} down - True if the Body is colliding on its lower edge. + * @property {boolean} left - True if the Body is colliding on its left edge. + * @property {boolean} right - True if the Body is colliding on its right edge. + */ + +/** + * @classdesc + * A Dynamic Arcade Body. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticBody}. + * + * @class Body + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics simulation this Body belongs to. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object this Body belongs to. + */ +var Body = new Class({ + + initialize: + + function Body (world, gameObject) + { + var width = (gameObject.width) ? gameObject.width : 64; + var height = (gameObject.height) ? gameObject.height : 64; + + /** + * The Arcade Physics simulation this Body belongs to. + * + * @name Phaser.Physics.Arcade.Body#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * The Game Object this Body belongs to. + * + * @name Phaser.Physics.Arcade.Body#gameObject + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.gameObject = gameObject; + + /** + * Transformations applied to this Body. + * + * @name Phaser.Physics.Arcade.Body#transform + * @type {object} + * @since 3.4.0 + */ + this.transform = { + x: gameObject.x, + y: gameObject.y, + rotation: gameObject.angle, + scaleX: gameObject.scaleX, + scaleY: gameObject.scaleY, + displayOriginX: gameObject.displayOriginX, + displayOriginY: gameObject.displayOriginY + }; + + /** + * Whether the Body's boundary is drawn to the debug display. + * + * @name Phaser.Physics.Arcade.Body#debugShowBody + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowBody = world.defaults.debugShowBody; + + /** + * Whether the Body's velocity is drawn to the debug display. + * + * @name Phaser.Physics.Arcade.Body#debugShowVelocity + * @type {boolean} + * @since 3.0.0 + */ + this.debugShowVelocity = world.defaults.debugShowVelocity; + + /** + * The color of this Body on the debug display. + * + * @name Phaser.Physics.Arcade.Body#debugBodyColor + * @type {integer} + * @since 3.0.0 + */ + this.debugBodyColor = world.defaults.bodyDebugColor; + + /** + * Whether this Body is updated by the physics simulation. + * + * @name Phaser.Physics.Arcade.Body#enable + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.enable = true; + + /** + * Whether this Body's boundary is circular (true) or rectangular (false). + * + * @name Phaser.Physics.Arcade.Body#isCircle + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setCircle + */ + this.isCircle = false; + + /** + * If this Body is circular, this is the unscaled radius of the Body's boundary, as set by setCircle(), in source pixels. + * The true radius is equal to `halfWidth`. + * + * @name Phaser.Physics.Arcade.Body#radius + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setCircle + */ + this.radius = 0; + + /** + * The offset of this Body's position from its Game Object's position, in source pixels. + * + * @name Phaser.Physics.Arcade.Body#offset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setOffset + */ + this.offset = new Vector2(); + + /** + * The position of this Body within the simulation. + * + * @name Phaser.Physics.Arcade.Body#position + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.position = new Vector2(gameObject.x, gameObject.y); + + /** + * The position of this Body during the previous step. + * + * @name Phaser.Physics.Arcade.Body#prev + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.prev = new Vector2(gameObject.x, gameObject.y); + + /** + * Whether this Body's `rotation` is affected by its angular acceleration and angular velocity. + * + * @name Phaser.Physics.Arcade.Body#allowRotation + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowRotation = true; + + /** + * This body's rotation, in degrees, based on its angular acceleration and angular velocity. + * The Body's rotation controls the `angle` of its Game Object. + * It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle. + * + * @name Phaser.Physics.Arcade.Body#rotation + * @type {number} + * @since 3.0.0 + */ + this.rotation = gameObject.angle; + + /** + * The Body's rotation, in degrees, during the previous step. + * + * @name Phaser.Physics.Arcade.Body#preRotation + * @type {number} + * @since 3.0.0 + */ + this.preRotation = gameObject.angle; + + /** + * The width of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. + * + * @name Phaser.Physics.Arcade.Body#width + * @type {number} + * @default 64 + * @since 3.0.0 + */ + this.width = width; + + /** + * The height of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. + * + * @name Phaser.Physics.Arcade.Body#height + * @type {number} + * @default 64 + * @since 3.0.0 + */ + this.height = height; + + /** + * The unscaled width of the Body, in source pixels, as set by setSize(). + * The default is the width of the Body's Game Object's texture frame. + * + * @name Phaser.Physics.Arcade.Body#sourceWidth + * @type {number} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setSize + */ + this.sourceWidth = width; + + /** + * The unscaled height of the Body, in source pixels, as set by setSize(). + * The default is the height of the Body's Game Object's texture frame. + * + * @name Phaser.Physics.Arcade.Body#sourceHeight + * @type {number} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#setSize + */ + this.sourceHeight = height; + + if (gameObject.frame) + { + this.sourceWidth = gameObject.frame.realWidth; + this.sourceHeight = gameObject.frame.realHeight; + } + + /** + * Half the Body's width, in pixels. + * + * @name Phaser.Physics.Arcade.Body#halfWidth + * @type {number} + * @since 3.0.0 + */ + this.halfWidth = Math.abs(width / 2); + + /** + * Half the Body's height, in pixels. + * + * @name Phaser.Physics.Arcade.Body#halfHeight + * @type {number} + * @since 3.0.0 + */ + this.halfHeight = Math.abs(height / 2); + + /** + * The center of the Body's boundary. + * The midpoint of its `position` (top-left corner) and its bottom-right corner. + * + * @name Phaser.Physics.Arcade.Body#center + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); + + /** + * The Body's velocity, in pixels per second. + * + * @name Phaser.Physics.Arcade.Body#velocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.velocity = new Vector2(); + + /** + * The Body's calculated velocity, in pixels per second, at the last step. + * + * @name Phaser.Physics.Arcade.Body#newVelocity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.0.0 + */ + this.newVelocity = new Vector2(); + + /** + * The Body's absolute maximum change in position, in pixels per step. + * + * @name Phaser.Physics.Arcade.Body#deltaMax + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.deltaMax = new Vector2(); + + /** + * The Body's change in velocity, in pixels per second squared. + * + * @name Phaser.Physics.Arcade.Body#acceleration + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.acceleration = new Vector2(); + + /** + * Whether this Body's velocity is affected by its `drag`. + * + * @name Phaser.Physics.Arcade.Body#allowDrag + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.allowDrag = true; + + /** + * Absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * + * @name Phaser.Physics.Arcade.Body#drag + * @type {(Phaser.Math.Vector2|number)} + * @since 3.0.0 + */ + this.drag = new Vector2(); + + /** + * Whether this Body's position is affected by gravity (local or world). + * + * @name Phaser.Physics.Arcade.Body#allowGravity + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#gravity + * @see Phaser.Physics.Arcade.World#gravity + */ + this.allowGravity = true; + + /** + * Acceleration due to gravity (specific to this Body), in pixels per second squared. + * Total gravity is the sum of this vector and the simulation's `gravity`. + * + * @name Phaser.Physics.Arcade.Body#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#gravity + */ + this.gravity = new Vector2(); + + /** + * Rebound following a collision, relative to 1. + * + * @name Phaser.Physics.Arcade.Body#bounce + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.bounce = new Vector2(); + + /** + * Rebound following a collision with the world boundary, relative to 1. + * If null, `bounce` is used instead. + * + * @name Phaser.Physics.Arcade.Body#worldBounce + * @type {?Phaser.Math.Vector2} + * @default null + * @since 3.0.0 + */ + this.worldBounce = null; + + // If true this Body will dispatch events + + /** + * Whether the simulation emits a `worldbounds` event when this Body collides with the world boundary (and `collideWorldBounds` is also true). + * + * @name Phaser.Physics.Arcade.Body#onWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#event:worldbounds + */ + this.onWorldBounds = false; + + /** + * Whether the simulation emits a `collide` event when this Body collides with another. + * + * @name Phaser.Physics.Arcade.Body#onCollide + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#event:collide + */ + this.onCollide = false; + + /** + * Whether the simulation emits an `overlap` event when this Body overlaps with another. + * + * @name Phaser.Physics.Arcade.Body#onOverlap + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#event:overlap + */ + this.onOverlap = false; + + /** + * The Body's absolute maximum velocity, in pixels per second. + * The horizontal and vertical components are applied separately. + * + * @name Phaser.Physics.Arcade.Body#maxVelocity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.maxVelocity = new Vector2(10000, 10000); + + /** + * If this Body is `immovable` and in motion, `friction` is the proportion of this Body's motion received by the riding Body on each axis, relative to 1. + * The default value (1, 0) moves the riding Body horizontally in equal proportion to this Body and vertically not at all. + * The horizontal component (x) is applied only when two colliding Bodies are separated vertically. + * The vertical component (y) is applied only when two colliding Bodies are separated horizontally. + * + * @name Phaser.Physics.Arcade.Body#friction + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.friction = new Vector2(1, 0); + + /** + * If this Body is using `drag` for deceleration this property controls how the drag is applied. + * If set to `true` drag will use a damping effect rather than a linear approach. If you are + * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in + * the game Asteroids) then you will get a far smoother and more visually correct deceleration + * by using damping, avoiding the axis-drift that is prone with linear deceleration. + * + * If you enable this property then you should use far smaller `drag` values than with linear, as + * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow + * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. + * + * @name Phaser.Physics.Arcade.Body#useDamping + * @type {boolean} + * @default false + * @since 3.10.0 + */ + this.useDamping = false; + + /** + * The rate of change of this Body's `rotation`, in degrees per second. + * + * @name Phaser.Physics.Arcade.Body#angularVelocity + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularVelocity = 0; + + /** + * The Body's angular acceleration (change in angular velocity), in degrees per second squared. + * + * @name Phaser.Physics.Arcade.Body#angularAcceleration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularAcceleration = 0; + + /** + * Loss of angular velocity due to angular movement, in degrees per second. + * + * Angular drag is applied only when angular acceleration is zero. + * + * @name Phaser.Physics.Arcade.Body#angularDrag + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angularDrag = 0; + + /** + * The Body's maximum angular velocity, in degrees per second. + * + * @name Phaser.Physics.Arcade.Body#maxAngular + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.maxAngular = 1000; + + /** + * The Body's inertia, relative to a default unit (1). + * With `bounce`, this affects the exchange of momentum (velocities) during collisions. + * + * @name Phaser.Physics.Arcade.Body#mass + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.mass = 1; + + /** + * The calculated angle of this Body's velocity vector, in degrees, during the last step. + * + * @name Phaser.Physics.Arcade.Body#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angle = 0; + + /** + * The calculated magnitude of the Body's velocity, in pixels per second, during the last step. + * + * @name Phaser.Physics.Arcade.Body#speed + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.speed = 0; + + /** + * The direction of the Body's velocity, as calculated during the last step. + * If the Body is moving on both axes (diagonally), this describes motion on the vertical axis only. + * + * @name Phaser.Physics.Arcade.Body#facing + * @type {integer} + * @since 3.0.0 + */ + this.facing = CONST.FACING_NONE; + + /** + * Whether this Body can be moved by collisions with another Body. + * + * @name Phaser.Physics.Arcade.Body#immovable + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.immovable = false; + + /** + * Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity. + * + * @name Phaser.Physics.Arcade.Body#moves + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.moves = true; + + /** + * A flag disabling the default horizontal separation of colliding bodies. + * Pass your own `collideCallback` to the collider. + * + * @name Phaser.Physics.Arcade.Body#customSeparateX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateX = false; + + /** + * A flag disabling the default vertical separation of colliding bodies. + * Pass your own `collideCallback` to the collider. + * + * @name Phaser.Physics.Arcade.Body#customSeparateY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.customSeparateY = false; + + /** + * The amount of horizontal overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.Body#overlapX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapX = 0; + + /** + * The amount of vertical overlap (before separation), if this Body is colliding with another. + * + * @name Phaser.Physics.Arcade.Body#overlapY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapY = 0; + + /** + * The amount of overlap (before separation), if this Body is circular and colliding with another circular body. + * + * @name Phaser.Physics.Arcade.Body#overlapR + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.overlapR = 0; + + /** + * Whether this Body is overlapped with another and both have zero velocity. + * + * @name Phaser.Physics.Arcade.Body#embedded + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.embedded = false; + + /** + * Whether this Body interacts with the world boundary. + * + * @name Phaser.Physics.Arcade.Body#collideWorldBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.collideWorldBounds = false; + + /** + * Whether this Body is checked for collisions and for which directions. + * You can set `checkCollision.none = false` to disable collision checks. + * + * @name Phaser.Physics.Arcade.Body#checkCollision + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; + + /** + * Whether this Body is colliding with another and in which direction. + * + * @name Phaser.Physics.Arcade.Body#touching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this Body was colliding with another during the last step, and in which direction. + * + * @name Phaser.Physics.Arcade.Body#wasTouching + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether this Body is colliding with a tile or the world boundary. + * + * @name Phaser.Physics.Arcade.Body#blocked + * @type {ArcadeBodyCollision} + * @since 3.0.0 + */ + this.blocked = { none: true, up: false, down: false, left: false, right: false }; + + /** + * Whether to automatically synchronize this Body's dimensions to the dimensions of its Game Object's visual bounds. + * + * @name Phaser.Physics.Arcade.Body#syncBounds + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.GameObjects.Components.GetBounds#getBounds + */ + this.syncBounds = false; + + /** + * Whether this Body is being moved by the `moveTo` or `moveFrom` methods. + * + * @name Phaser.Physics.Arcade.Body#isMoving + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isMoving = false; + + /** + * Whether this Body's movement by `moveTo` or `moveFrom` will be stopped by collisions with other bodies. + * + * @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.stopVelocityOnCollide = true; + + // read-only + + /** + * The Body's physics type (dynamic or static). + * + * @name Phaser.Physics.Arcade.Body#physicsType + * @type {integer} + * @readonly + * @since 3.0.0 + */ + this.physicsType = CONST.DYNAMIC_BODY; + + /** + * Whether the Body's position needs updating from its Game Object. + * + * @name Phaser.Physics.Arcade.Body#_reset + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + this._reset = true; + + /** + * Cached horizontal scale of the Body's Game Object. + * + * @name Phaser.Physics.Arcade.Body#_sx + * @type {number} + * @private + * @since 3.0.0 + */ + this._sx = gameObject.scaleX; + + /** + * Cached vertical scale of the Body's Game Object. + * + * @name Phaser.Physics.Arcade.Body#_sy + * @type {number} + * @private + * @since 3.0.0 + */ + this._sy = gameObject.scaleY; + + /** + * The calculated change in the Body's horizontal position during the last step. + * + * @name Phaser.Physics.Arcade.Body#_dx + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._dx = 0; + + /** + * The calculated change in the Body's vertical position during the last step. + * + * @name Phaser.Physics.Arcade.Body#_dy + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._dy = 0; + + /** + * Stores the Game Object's bounds. + * + * @name Phaser.Physics.Arcade.Body#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + }, + + /** + * Updates this Body's transform, dimensions, and position from its Game Object. + * + * @method Phaser.Physics.Arcade.Body#updateBounds + * @since 3.0.0 + */ + updateBounds: function () + { + var sprite = this.gameObject; + + // Container? + + var transform = this.transform; + + if (sprite.parentContainer) + { + var matrix = sprite.getWorldTransformMatrix(this.world._tempMatrix, this.world._tempMatrix2); + + transform.x = matrix.tx; + transform.y = matrix.ty; + transform.rotation = RadToDeg(matrix.rotation); + transform.scaleX = matrix.scaleX; + transform.scaleY = matrix.scaleY; + transform.displayOriginX = sprite.displayOriginX; + transform.displayOriginY = sprite.displayOriginY; + } + else + { + transform.x = sprite.x; + transform.y = sprite.y; + transform.rotation = sprite.angle; + transform.scaleX = sprite.scaleX; + transform.scaleY = sprite.scaleY; + transform.displayOriginX = sprite.displayOriginX; + transform.displayOriginY = sprite.displayOriginY; + } + + var recalc = false; + + if (this.syncBounds) + { + var b = sprite.getBounds(this._bounds); + + this.width = b.width; + this.height = b.height; + recalc = true; + } + else + { + var asx = Math.abs(transform.scaleX); + var asy = Math.abs(transform.scaleY); + + if (this._sx !== asx || this._sy !== asy) + { + this.width = this.sourceWidth * asx; + this.height = this.sourceHeight * asy; + this._sx = asx; + this._sy = asy; + recalc = true; + } + } + + if (recalc) + { + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + this.updateCenter(); + } + }, + + /** + * Updates the Body's `center` from its `position`, `width`, and `height`. + * + * @method Phaser.Physics.Arcade.Body#updateCenter + * @since 3.0.0 + */ + updateCenter: function () + { + this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); + }, + + /** + * Updates the Body. + * + * @method Phaser.Physics.Arcade.Body#update + * @fires Phaser.Physics.Arcade.World#worldbounds + * @since 3.0.0 + * + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (delta) + { + // Store and reset collision flags + this.wasTouching.none = this.touching.none; + this.wasTouching.up = this.touching.up; + this.wasTouching.down = this.touching.down; + this.wasTouching.left = this.touching.left; + this.wasTouching.right = this.touching.right; + + this.touching.none = true; + this.touching.up = false; + this.touching.down = false; + this.touching.left = false; + this.touching.right = false; + + this.blocked.none = true; + this.blocked.up = false; + this.blocked.down = false; + this.blocked.left = false; + this.blocked.right = false; + + this.overlapR = 0; + this.overlapX = 0; + this.overlapY = 0; + + this.embedded = false; + + // Updates the transform values + this.updateBounds(); + + var sprite = this.transform; + + this.position.x = sprite.x + sprite.scaleX * (this.offset.x - sprite.displayOriginX); + this.position.y = sprite.y + sprite.scaleY * (this.offset.y - sprite.displayOriginY); + + this.updateCenter(); + + this.rotation = sprite.rotation; + + this.preRotation = this.rotation; + + if (this._reset) + { + this.prev.x = this.position.x; + this.prev.y = this.position.y; + } + + if (this.moves) + { + this.world.updateMotion(this, delta); + + var vx = this.velocity.x; + var vy = this.velocity.y; + + this.newVelocity.set(vx * delta, vy * delta); + + this.position.add(this.newVelocity); + + this.updateCenter(); + + this.angle = Math.atan2(vy, vx); + this.speed = Math.sqrt(vx * vx + vy * vy); + + // Now the State update will throw collision checks at the Body + // And finally we'll integrate the new position back to the Sprite in postUpdate + + if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) + { + this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); + } + } + + this._dx = this.position.x - this.prev.x; + this._dy = this.position.y - this.prev.y; + }, + + /** + * Feeds the Body results back into the parent Game Object. + * + * @method Phaser.Physics.Arcade.Body#postUpdate + * @since 3.0.0 + * + * @param {boolean} resetDelta - Reset the delta properties? + */ + postUpdate: function () + { + this._dx = this.position.x - this.prev.x; + this._dy = this.position.y - this.prev.y; + + if (this.moves) + { + if (this.deltaMax.x !== 0 && this._dx !== 0) + { + if (this._dx < 0 && this._dx < -this.deltaMax.x) + { + this._dx = -this.deltaMax.x; + } + else if (this._dx > 0 && this._dx > this.deltaMax.x) + { + this._dx = this.deltaMax.x; + } + } + + if (this.deltaMax.y !== 0 && this._dy !== 0) + { + if (this._dy < 0 && this._dy < -this.deltaMax.y) + { + this._dy = -this.deltaMax.y; + } + else if (this._dy > 0 && this._dy > this.deltaMax.y) + { + this._dy = this.deltaMax.y; + } + } + + this.gameObject.x += this._dx; + this.gameObject.y += this._dy; + + this._reset = true; + } + + if (this._dx < 0) + { + this.facing = CONST.FACING_LEFT; + } + else if (this._dx > 0) + { + this.facing = CONST.FACING_RIGHT; + } + + if (this._dy < 0) + { + this.facing = CONST.FACING_UP; + } + else if (this._dy > 0) + { + this.facing = CONST.FACING_DOWN; + } + + if (this.allowRotation) + { + this.gameObject.angle += this.deltaZ(); + } + + this.prev.x = this.position.x; + this.prev.y = this.position.y; + }, + + /** + * Checks for collisions between this Body and the world boundary and separates them. + * + * @method Phaser.Physics.Arcade.Body#checkWorldBounds + * @since 3.0.0 + * + * @return {boolean} True if this Body is colliding with the world boundary. + */ + checkWorldBounds: function () + { + var pos = this.position; + var bounds = this.world.bounds; + var check = this.world.checkCollision; + + var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x; + var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y; + + if (pos.x < bounds.x && check.left) + { + pos.x = bounds.x; + this.velocity.x *= bx; + this.blocked.left = true; + this.blocked.none = false; + } + else if (this.right > bounds.right && check.right) + { + pos.x = bounds.right - this.width; + this.velocity.x *= bx; + this.blocked.right = true; + this.blocked.none = false; + } + + if (pos.y < bounds.y && check.up) + { + pos.y = bounds.y; + this.velocity.y *= by; + this.blocked.up = true; + this.blocked.none = false; + } + else if (this.bottom > bounds.bottom && check.down) + { + pos.y = bounds.bottom - this.height; + this.velocity.y *= by; + this.blocked.down = true; + this.blocked.none = false; + } + + return !this.blocked.none; + }, + + /** + * Sets the offset of the Body's position from its Game Object's position. + * + * @method Phaser.Physics.Arcade.Body#setOffset + * @since 3.0.0 + * + * @param {number} x - The horizontal offset, in source pixels. + * @param {number} [y=x] - The vertical offset, in source pixels. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setOffset: function (x, y) + { + if (y === undefined) { y = x; } + + this.offset.set(x, y); + + return this; + }, + + /** + * Sizes and positions this Body's boundary, as a rectangle. + * Modifies the Body `offset` if `center` is true (the default). + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * + * @method Phaser.Physics.Arcade.Body#setSize + * @since 3.0.0 + * + * @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param {boolean} [center=true] - Modify the Body's `offset`, placing the Body's center on its Game Object's center. Only works if the Game Object has the `getCenter` method. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setSize: function (width, height, center) + { + if (center === undefined) { center = true; } + + var gameObject = this.gameObject; + + if (!width && gameObject.frame) + { + width = gameObject.frame.realWidth; + } + + if (!height && gameObject.frame) + { + height = gameObject.frame.realHeight; + } + + this.sourceWidth = width; + this.sourceHeight = height; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.updateCenter(); + + if (center && gameObject.getCenter) + { + var ox = gameObject.displayWidth / 2; + var oy = gameObject.displayHeight / 2; + + this.offset.set(ox - this.halfWidth, oy - this.halfHeight); + } + + this.isCircle = false; + this.radius = 0; + + return this; + }, + + /** + * Sizes and positions this Body's boundary, as a circle. + * + * @method Phaser.Physics.Arcade.Body#setCircle + * @since 3.0.0 + * + * @param {number} radius - The radius of the Body, in source pixels. + * @param {number} [offsetX] - The horizontal offset of the Body from its Game Object, in source pixels. + * @param {number} [offsetY] - The vertical offset of the Body from its Game Object, in source pixels. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCircle: function (radius, offsetX, offsetY) + { + if (offsetX === undefined) { offsetX = this.offset.x; } + if (offsetY === undefined) { offsetY = this.offset.y; } + + if (radius > 0) + { + this.isCircle = true; + this.radius = radius; + + this.sourceWidth = radius * 2; + this.sourceHeight = radius * 2; + + this.width = this.sourceWidth * this._sx; + this.height = this.sourceHeight * this._sy; + + this.halfWidth = Math.floor(this.width / 2); + this.halfHeight = Math.floor(this.height / 2); + + this.offset.set(offsetX, offsetY); + + this.updateCenter(); + } + else + { + this.isCircle = false; + } + + return this; + }, + + /** + * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * If the Body had any velocity or acceleration it is lost as a result of calling this. + * + * @method Phaser.Physics.Arcade.Body#reset + * @since 3.0.0 + * + * @param {number} x - The horizontal position to place the Game Object and Body. + * @param {number} y - The vertical position to place the Game Object and Body. + */ + reset: function (x, y) + { + this.stop(); + + var gameObject = this.gameObject; + + gameObject.setPosition(x, y); + + gameObject.getTopLeft(this.position); + + this.prev.copy(this.position); + + this.rotation = gameObject.angle; + this.preRotation = gameObject.angle; + + this.updateBounds(); + this.updateCenter(); + }, + + /** + * Sets acceleration, velocity, and speed to zero. + * + * @method Phaser.Physics.Arcade.Body#stop + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + stop: function () + { + this.velocity.set(0); + this.acceleration.set(0); + this.speed = 0; + this.angularVelocity = 0; + this.angularAcceleration = 0; + + return this; + }, + + /** + * Copies the coordinates of this Body's edges into an object. + * + * @method Phaser.Physics.Arcade.Body#getBounds + * @since 3.0.0 + * + * @param {ArcadeBodyBounds} obj - An object to copy the values into. + * + * @return {ArcadeBodyBounds} - An object with {x, y, right, bottom}. + */ + getBounds: function (obj) + { + obj.x = this.x; + obj.y = this.y; + obj.right = this.right; + obj.bottom = this.bottom; + + return obj; + }, + + /** + * Tests if the coordinates are within this Body's boundary. + * + * @method Phaser.Physics.Arcade.Body#hitTest + * @since 3.0.0 + * + * @param {number} x - The horizontal coordinate. + * @param {number} y - The vertical coordinate. + * + * @return {boolean} True if (x, y) is within this Body. + */ + hitTest: function (x, y) + { + return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); + }, + + /** + * Whether this Body is touching a tile or the world boundary while moving down. + * + * @method Phaser.Physics.Arcade.Body#onFloor + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#blocked + * + * @return {boolean} True if touching. + */ + onFloor: function () + { + return this.blocked.down; + }, + + /** + * Whether this Body is touching a tile or the world boundary while moving up. + * + * @method Phaser.Physics.Arcade.Body#onCeiling + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#blocked + * + * @return {boolean} True if touching. + */ + onCeiling: function () + { + return this.blocked.up; + }, + + /** + * Whether this Body is touching a tile or the world boundary while moving left or right. + * + * @method Phaser.Physics.Arcade.Body#onWall + * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#blocked + * + * @return {boolean} True if touching. + */ + onWall: function () + { + return (this.blocked.left || this.blocked.right); + }, + + /** + * The absolute (non-negative) change in this Body's horizontal position from the previous step. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsX + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaAbsX: function () + { + return (this._dx > 0) ? this._dx : -this._dx; + }, + + /** + * The absolute (non-negative) change in this Body's vertical position from the previous step. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsY + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaAbsY: function () + { + return (this._dy > 0) ? this._dy : -this._dy; + }, + + /** + * The change in this Body's horizontal position from the previous step. + * This value is set during the Body's update phase. + * + * @method Phaser.Physics.Arcade.Body#deltaX + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaX: function () + { + return this._dx; + }, + + /** + * The change in this Body's vertical position from the previous step. + * This value is set during the Body's update phase. + * + * @method Phaser.Physics.Arcade.Body#deltaY + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaY: function () + { + return this._dy; + }, + + /** + * The change in this Body's rotation from the previous step, in degrees. + * + * @method Phaser.Physics.Arcade.Body#deltaZ + * @since 3.0.0 + * + * @return {number} The delta value. + */ + deltaZ: function () + { + return this.rotation - this.preRotation; + }, + + /** + * Disables this Body and marks it for deletion by the simulation. + * + * @method Phaser.Physics.Arcade.Body#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.enable = false; + + this.world.pendingDestroy.set(this); + }, + + /** + * Draws this Body's boundary and velocity, if enabled. + * + * @method Phaser.Physics.Arcade.Body#drawDebug + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphic - The Graphics object to draw on. + */ + drawDebug: function (graphic) + { + var pos = this.position; + + var x = pos.x + this.halfWidth; + var y = pos.y + this.halfHeight; + + if (this.debugShowBody) + { + graphic.lineStyle(1, this.debugBodyColor); + + if (this.isCircle) + { + graphic.strokeCircle(x, y, this.width / 2); + } + else + { + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + } + + if (this.debugShowVelocity) + { + graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); + graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); + } + }, + + /** + * Whether this Body will be drawn to the debug display. + * + * @method Phaser.Physics.Arcade.Body#willDrawDebug + * @since 3.0.0 + * + * @return {boolean} True if either `debugShowBody` or `debugShowVelocity` are enabled. + */ + willDrawDebug: function () + { + return (this.debugShowBody || this.debugShowVelocity); + }, + + /** + * Sets whether this Body collides with the world boundary. + * + * @method Phaser.Physics.Arcade.Body#setCollideWorldBounds + * @since 3.0.0 + * + * @param {boolean} [value=true] - True (collisions) or false (no collisions). + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setCollideWorldBounds: function (value) + { + if (value === undefined) { value = true; } + + this.collideWorldBounds = value; + + return this; + }, + + /** + * Sets the Body's velocity. + * + * @method Phaser.Physics.Arcade.Body#setVelocity + * @since 3.0.0 + * + * @param {number} x - The horizontal velocity, in pixels per second. + * @param {number} [y=x] - The vertical velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocity: function (x, y) + { + this.velocity.set(x, y); + + this.speed = Math.sqrt(x * x + y * y); + + return this; + }, + + /** + * Sets the Body's horizontal velocity. + * + * @method Phaser.Physics.Arcade.Body#setVelocityX + * @since 3.0.0 + * + * @param {number} value - The velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityX: function (value) + { + this.velocity.x = value; + + var vx = value; + var vy = this.velocity.y; + + this.speed = Math.sqrt(vx * vx + vy * vy); + + return this; + }, + + /** + * Sets the Body's vertical velocity. + * + * @method Phaser.Physics.Arcade.Body#setVelocityY + * @since 3.0.0 + * + * @param {number} value - The velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setVelocityY: function (value) + { + this.velocity.y = value; + + var vx = this.velocity.x; + var vy = value; + + this.speed = Math.sqrt(vx * vx + vy * vy); + + return this; + }, + + /** + * Sets the Body's maximum velocity. + * + * @method Phaser.Physics.Arcade.Body#setMaxVelocity + * @since 3.10.0 + * + * @param {number} x - The horizontal velocity, in pixels per second. + * @param {number} [y=x] - The vertical velocity, in pixels per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setMaxVelocity: function (x, y) + { + this.maxVelocity.set(x, y); + + return this; + }, + + /** + * Sets the Body's bounce. + * + * @method Phaser.Physics.Arcade.Body#setBounce + * @since 3.0.0 + * + * @param {number} x - The horizontal bounce, relative to 1. + * @param {number} y - The vertical bounce, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounce: function (x, y) + { + this.bounce.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal bounce. + * + * @method Phaser.Physics.Arcade.Body#setBounceX + * @since 3.0.0 + * + * @param {number} value - The bounce, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceX: function (value) + { + this.bounce.x = value; + + return this; + }, + + /** + * Sets the Body's vertical bounce. + * + * @method Phaser.Physics.Arcade.Body#setBounceY + * @since 3.0.0 + * + * @param {number} value - The bounce, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setBounceY: function (value) + { + this.bounce.y = value; + + return this; + }, + + /** + * Sets the Body's acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAcceleration + * @since 3.0.0 + * + * @param {number} x - The horizontal component, in pixels per second squared. + * @param {number} y - The vertical component, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAcceleration: function (x, y) + { + this.acceleration.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - The acceleration, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationX: function (value) + { + this.acceleration.x = value; + + return this; + }, + + /** + * Sets the Body's vertical acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - The acceleration, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAccelerationY: function (value) + { + this.acceleration.y = value; + + return this; + }, + + /** + * Enables or disables drag. + * + * @method Phaser.Physics.Arcade.Body#setAllowDrag + * @since 3.9.0 + * @see Phaser.Physics.Arcade.Body#allowDrag + * + * @param {boolean} [value=true] - `true` to allow drag on this body, or `false` to disable it. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAllowDrag: function (value) + { + if (value === undefined) { value = true; } + + this.allowDrag = value; + + return this; + }, + + /** + * Enables or disables gravity's effect on this Body. + * + * @method Phaser.Physics.Arcade.Body#setAllowGravity + * @since 3.9.0 + * @see Phaser.Physics.Arcade.Body#allowGravity + * + * @param {boolean} [value=true] - `true` to allow gravity on this body, or `false` to disable it. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAllowGravity: function (value) + { + if (value === undefined) { value = true; } + + this.allowGravity = value; + + return this; + }, + + /** + * Enables or disables rotation. + * + * @method Phaser.Physics.Arcade.Body#setAllowRotation + * @since 3.9.0 + * @see Phaser.Physics.Arcade.Body#allowRotation + * + * @param {boolean} [value=true] - `true` to allow rotation on this body, or `false` to disable it. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAllowRotation: function (value) + { + if (value === undefined) { value = true; } + + this.allowRotation = value; + + return this; + }, + + /** + * Sets the Body's drag. + * + * @method Phaser.Physics.Arcade.Body#setDrag + * @since 3.0.0 + * + * @param {number} x - The horizontal component, in pixels per second squared. + * @param {number} y - The vertical component, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDrag: function (x, y) + { + this.drag.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal drag. + * + * @method Phaser.Physics.Arcade.Body#setDragX + * @since 3.0.0 + * + * @param {number} value - The drag, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragX: function (value) + { + this.drag.x = value; + + return this; + }, + + /** + * Sets the Body's vertical drag. + * + * @method Phaser.Physics.Arcade.Body#setDragY + * @since 3.0.0 + * + * @param {number} value - The drag, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setDragY: function (value) + { + this.drag.y = value; + + return this; + }, + + /** + * Sets the Body's gravity. + * + * @method Phaser.Physics.Arcade.Body#setGravity + * @since 3.0.0 + * + * @param {number} x - The horizontal component, in pixels per second squared. + * @param {number} y - The vertical component, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravity: function (x, y) + { + this.gravity.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal gravity. + * + * @method Phaser.Physics.Arcade.Body#setGravityX + * @since 3.0.0 + * + * @param {number} value - The gravity, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityX: function (value) + { + this.gravity.x = value; + + return this; + }, + + /** + * Sets the Body's vertical gravity. + * + * @method Phaser.Physics.Arcade.Body#setGravityY + * @since 3.0.0 + * + * @param {number} value - The gravity, in pixels per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setGravityY: function (value) + { + this.gravity.y = value; + + return this; + }, + + /** + * Sets the Body's friction. + * + * @method Phaser.Physics.Arcade.Body#setFriction + * @since 3.0.0 + * + * @param {number} x - The horizontal component, relative to 1. + * @param {number} y - The vertical component, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFriction: function (x, y) + { + this.friction.set(x, y); + + return this; + }, + + /** + * Sets the Body's horizontal friction. + * + * @method Phaser.Physics.Arcade.Body#setFrictionX + * @since 3.0.0 + * + * @param {number} value - The friction value, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionX: function (value) + { + this.friction.x = value; + + return this; + }, + + /** + * Sets the Body's vertical friction. + * + * @method Phaser.Physics.Arcade.Body#setFrictionY + * @since 3.0.0 + * + * @param {number} value - The friction value, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setFrictionY: function (value) + { + this.friction.y = value; + + return this; + }, + + /** + * Sets the Body's angular velocity. + * + * @method Phaser.Physics.Arcade.Body#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - The velocity, in degrees per second. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularVelocity: function (value) + { + this.angularVelocity = value; + + return this; + }, + + /** + * Sets the Body's angular acceleration. + * + * @method Phaser.Physics.Arcade.Body#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - The acceleration, in degrees per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularAcceleration: function (value) + { + this.angularAcceleration = value; + + return this; + }, + + /** + * Sets the Body's angular drag. + * + * @method Phaser.Physics.Arcade.Body#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - The drag, in degrees per second squared. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setAngularDrag: function (value) + { + this.angularDrag = value; + + return this; + }, + + /** + * Sets the Body's mass. + * + * @method Phaser.Physics.Arcade.Body#setMass + * @since 3.0.0 + * + * @param {number} value - The mass value, relative to 1. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setMass: function (value) + { + this.mass = value; + + return this; + }, + + /** + * Sets the Body's `immovable` property. + * + * @method Phaser.Physics.Arcade.Body#setImmovable + * @since 3.0.0 + * + * @param {boolean} [value=true] - The value to assign to `immovable`. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setImmovable: function (value) + { + if (value === undefined) { value = true; } + + this.immovable = value; + + return this; + }, + + /** + * Sets the Body's `enable` property. + * + * @method Phaser.Physics.Arcade.Body#setEnable + * @since 3.15.0 + * + * @param {boolean} [value=true] - The value to assign to `enable`. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setEnable: function (value) + { + if (value === undefined) { value = true; } + + this.enable = value; + + return this; + }, + + /** + * The Body's horizontal position (left edge). + * + * @name Phaser.Physics.Arcade.Body#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + } + + }, + + /** + * The Body's vertical position (top edge). + * + * @name Phaser.Physics.Arcade.Body#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } + + }, + + /** + * The left edge of the Body's boundary. Identical to x. + * + * @name Phaser.Physics.Arcade.Body#left + * @type {number} + * @readonly + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.position.x; + } + + }, + + /** + * The right edge of the Body's boundary. + * + * @name Phaser.Physics.Arcade.Body#right + * @type {number} + * @readonly + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.position.x + this.width; + } + + }, + + /** + * The top edge of the Body's boundary. Identical to y. + * + * @name Phaser.Physics.Arcade.Body#top + * @type {number} + * @readonly + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.position.y; + } + + }, + + /** + * The bottom edge of this Body's boundary. + * + * @name Phaser.Physics.Arcade.Body#bottom + * @type {number} + * @readonly + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.position.y + this.height; + } + + } + +}); + +module.exports = Body; + + +/***/ }), +/* 233 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Body = __webpack_require__(232); +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var Collider = __webpack_require__(231); +var CONST = __webpack_require__(35); +var DistanceBetween = __webpack_require__(52); +var EventEmitter = __webpack_require__(11); +var FuzzyEqual = __webpack_require__(248); +var FuzzyGreaterThan = __webpack_require__(247); +var FuzzyLessThan = __webpack_require__(246); +var GetOverlapX = __webpack_require__(230); +var GetOverlapY = __webpack_require__(229); +var GetValue = __webpack_require__(4); +var ProcessQueue = __webpack_require__(228); +var ProcessTileCallbacks = __webpack_require__(514); +var Rectangle = __webpack_require__(9); +var RTree = __webpack_require__(227); +var SeparateTile = __webpack_require__(513); +var SeparateX = __webpack_require__(508); +var SeparateY = __webpack_require__(507); +var Set = __webpack_require__(95); +var StaticBody = __webpack_require__(225); +var TileIntersectsBody = __webpack_require__(226); +var TransformMatrix = __webpack_require__(38); +var Vector2 = __webpack_require__(3); +var Wrap = __webpack_require__(53); + +/** + * @event Phaser.Physics.Arcade.World#pause + */ + +/** + * @event Phaser.Physics.Arcade.World#resume + */ + +/** + * @event Phaser.Physics.Arcade.World#collide + * @param {Phaser.GameObjects.GameObject} gameObject1 + * @param {Phaser.GameObjects.GameObject} gameObject2 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 + */ + +/** + * @event Phaser.Physics.Arcade.World#overlap + * @param {Phaser.GameObjects.GameObject} gameObject1 + * @param {Phaser.GameObjects.GameObject} gameObject2 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 + */ + +/** + * @event Phaser.Physics.Arcade.World#worldbounds + * @param {Phaser.Physics.Arcade.Body} body + * @param {boolean} up + * @param {boolean} down + * @param {boolean} left + * @param {boolean} right + */ + +/** + * @typedef {object} ArcadeWorldConfig + * + * @property {number} [fps=60] - Sets {@link Phaser.Physics.Arcade.World#fps}. + * @property {number} [timeScale=1] - Sets {@link Phaser.Physics.Arcade.World#timeScale}. + * @property {object} [gravity] - Sets {@link Phaser.Physics.Arcade.World#gravity}. + * @property {number} [gravity.x=0] - The horizontal world gravity value. + * @property {number} [gravity.y=0] - The vertical world gravity value. + * @property {number} [x=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.x}. + * @property {number} [y=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.y}. + * @property {number} [width=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.width}. + * @property {number} [height=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.height}. + * @property {object} [checkCollision] - Sets {@link Phaser.Physics.Arcade.World#checkCollision}. + * @property {boolean} [checkCollision.up=true] - Should bodies collide with the top of the world bounds? + * @property {boolean} [checkCollision.down=true] - Should bodies collide with the bottom of the world bounds? + * @property {boolean} [checkCollision.left=true] - Should bodies collide with the left of the world bounds? + * @property {boolean} [checkCollision.right=true] - Should bodies collide with the right of the world bounds? + * @property {number} [overlapBias=4] - Sets {@link Phaser.Physics.Arcade.World#OVERLAP_BIAS}. + * @property {number} [tileBias=16] - Sets {@link Phaser.Physics.Arcade.World#TILE_BIAS}. + * @property {boolean} [forceX=false] - Sets {@link Phaser.Physics.Arcade.World#forceX}. + * @property {boolean} [isPaused=false] - Sets {@link Phaser.Physics.Arcade.World#isPaused}. + * @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Arcade.World#debug}. + * @property {boolean} [debugShowBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowBody}. + * @property {boolean} [debugShowStaticBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. + * @property {boolean} [debugShowVelocity=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. + * @property {number} [debugBodyColor=0xff00ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugBodyColor}. + * @property {number} [debugStaticBodyColor=0x0000ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugStaticBodyColor}. + * @property {number} [debugVelocityColor=0x00ff00] - Sets {@link Phaser.Physics.Arcade.World#defaults debugVelocityColor}. + * @property {number} [maxEntries=16] - Sets {@link Phaser.Physics.Arcade.World#maxEntries}. + * @property {boolean} [useTree=true] - Sets {@link Phaser.Physics.Arcade.World#useTree}. + */ + +/** + * @typedef {object} CheckCollisionObject + * + * @property {boolean} up - [description] + * @property {boolean} down - [description] + * @property {boolean} left - [description] + * @property {boolean} right - [description] + */ + +/** + * @typedef {object} ArcadeWorldDefaults + * + * @property {boolean} debugShowBody - [description] + * @property {boolean} debugShowStaticBody - [description] + * @property {boolean} debugShowVelocity - [description] + * @property {number} bodyDebugColor - [description] + * @property {number} staticBodyDebugColor - [description] + * @property {number} velocityDebugColor - [description] + */ + +/** + * @typedef {object} ArcadeWorldTreeMinMax + * + * @property {number} minX - [description] + * @property {number} minY - [description] + * @property {number} maxX - [description] + * @property {number} maxY - [description] + */ + +/** + * An Arcade Physics Collider Type. + * + * @typedef {( + * Phaser.GameObjects.GameObject| + * Phaser.GameObjects.Group| + * Phaser.Physics.Arcade.Sprite| + * Phaser.Physics.Arcade.Image| + * Phaser.Physics.Arcade.StaticGroup| + * Phaser.Physics.Arcade.Group| + * Phaser.Tilemaps.DynamicTilemapLayer| + * Phaser.Tilemaps.StaticTilemapLayer| + * Phaser.GameObjects.GameObject[]| + * Phaser.Physics.Arcade.Sprite[]| + * Phaser.Physics.Arcade.Image[]| + * Phaser.Physics.Arcade.StaticGroup[]| + * Phaser.Physics.Arcade.Group[]| + * Phaser.Tilemaps.DynamicTilemapLayer[]| + * Phaser.Tilemaps.StaticTilemapLayer[] + * )} ArcadeColliderType + */ + +/** + * @classdesc + * The Arcade Physics World. + * + * The World is responsible for creating, managing, colliding and updating all of the bodies within it. + * + * An instance of the World belongs to a Phaser.Scene and is accessed via the property `physics.world`. + * + * @class World + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this World instance belongs. + * @param {ArcadeWorldConfig} config - An Arcade Physics Configuration object. + */ +var World = new Class({ + + Extends: EventEmitter, + + initialize: + + function World (scene, config) + { + EventEmitter.call(this); + + /** + * The Scene this simulation belongs to. + * + * @name Phaser.Physics.Arcade.World#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * Dynamic Bodies in this simulation. + * + * @name Phaser.Physics.Arcade.World#bodies + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.bodies = new Set(); + + /** + * Static Bodies in this simulation. + * + * @name Phaser.Physics.Arcade.World#staticBodies + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.staticBodies = new Set(); + + /** + * Static Bodies marked for deletion. + * + * @name Phaser.Physics.Arcade.World#pendingDestroy + * @type {Phaser.Structs.Set.<(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)>} + * @since 3.1.0 + */ + this.pendingDestroy = new Set(); + + /** + * This simulation's collision processors. + * + * @name Phaser.Physics.Arcade.World#colliders + * @type {Phaser.Structs.ProcessQueue.} + * @since 3.0.0 + */ + this.colliders = new ProcessQueue(); + + /** + * Acceleration of Bodies due to gravity, in pixels per second. + * + * @name Phaser.Physics.Arcade.World#gravity + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.gravity = new Vector2(GetValue(config, 'gravity.x', 0), GetValue(config, 'gravity.y', 0)); + + /** + * A boundary constraining Bodies. + * + * @name Phaser.Physics.Arcade.World#bounds + * @type {Phaser.Geom.Rectangle} + * @since 3.0.0 + */ + this.bounds = new Rectangle( + GetValue(config, 'x', 0), + GetValue(config, 'y', 0), + GetValue(config, 'width', scene.sys.game.config.width), + GetValue(config, 'height', scene.sys.game.config.height) + ); + + /** + * The boundary edges that Bodies can collide with. + * + * @name Phaser.Physics.Arcade.World#checkCollision + * @type {CheckCollisionObject} + * @since 3.0.0 + */ + this.checkCollision = { + up: GetValue(config, 'checkCollision.up', true), + down: GetValue(config, 'checkCollision.down', true), + left: GetValue(config, 'checkCollision.left', true), + right: GetValue(config, 'checkCollision.right', true) + }; + + /** + * The number of physics steps to be taken per second. + * + * This property is read-only. Use the `setFPS` method to modify it at run-time. + * + * @name Phaser.Physics.Arcade.World#fps + * @readonly + * @type {number} + * @default 60 + * @since 3.10.0 + */ + this.fps = GetValue(config, 'fps', 60); + + /** + * The amount of elapsed ms since the last frame. + * + * @name Phaser.Physics.Arcade.World#_elapsed + * @private + * @type {number} + * @since 3.10.0 + */ + this._elapsed = 0; + + /** + * Internal frame time value. + * + * @name Phaser.Physics.Arcade.World#_frameTime + * @private + * @type {number} + * @since 3.10.0 + */ + this._frameTime = 1 / this.fps; + + /** + * Internal frame time ms value. + * + * @name Phaser.Physics.Arcade.World#_frameTimeMS + * @private + * @type {number} + * @since 3.10.0 + */ + this._frameTimeMS = 1000 * this._frameTime; + + /** + * The number of steps that took place in the last frame. + * + * @name Phaser.Physics.Arcade.World#stepsLastFrame + * @readonly + * @type {number} + * @since 3.10.0 + */ + this.stepsLastFrame = 0; + + /** + * Scaling factor applied to the frame rate. + * + * - 1.0 = normal speed + * - 2.0 = half speed + * - 0.5 = double speed + * + * @name Phaser.Physics.Arcade.World#timeScale + * @property {number} + * @default 1 + * @since 3.10.0 + */ + this.timeScale = GetValue(config, 'timeScale', 1); + + /** + * The maximum absolute difference of a Body's per-step velocity and its overlap with another Body that will result in separation on *each axis*. + * Larger values favor separation. + * Smaller values favor no separation. + * + * @name Phaser.Physics.Arcade.World#OVERLAP_BIAS + * @type {number} + * @default 4 + * @since 3.0.0 + */ + this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4); + + /** + * The maximum absolute value of a Body's overlap with a tile that will result in separation on *each axis*. + * Larger values favor separation. + * Smaller values favor no separation. + * The optimum value may be similar to the tile size. + * + * @name Phaser.Physics.Arcade.World#TILE_BIAS + * @type {number} + * @default 16 + * @since 3.0.0 + */ + this.TILE_BIAS = GetValue(config, 'tileBias', 16); + + /** + * Always separate overlapping Bodies horizontally before vertically. + * False (the default) means Bodies are first separated on the axis of greater gravity, or the vertical axis if neither is greater. + * + * @name Phaser.Physics.Arcade.World#forceX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.forceX = GetValue(config, 'forceX', false); + + /** + * Whether the simulation advances with the game loop. + * + * @name Phaser.Physics.Arcade.World#isPaused + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPaused = GetValue(config, 'isPaused', false); + + /** + * Temporary total of colliding Bodies. + * + * @name Phaser.Physics.Arcade.World#_total + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._total = 0; + + /** + * Enables the debug display. + * + * @name Phaser.Physics.Arcade.World#drawDebug + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.drawDebug = GetValue(config, 'debug', false); + + /** + * The graphics object drawing the debug display. + * + * @name Phaser.Physics.Arcade.World#debugGraphic + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.debugGraphic; + + /** + * Default debug display settings for new Bodies. + * + * @name Phaser.Physics.Arcade.World#defaults + * @type {ArcadeWorldDefaults} + * @since 3.0.0 + */ + this.defaults = { + debugShowBody: GetValue(config, 'debugShowBody', true), + debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), + debugShowVelocity: GetValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), + staticBodyDebugColor: GetValue(config, 'debugStaticBodyColor', 0x0000ff), + velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) + }; + + /** + * The maximum number of items per node on the RTree. + * + * This is ignored if `useTree` is `false`. If you have a large number of bodies in + * your world then you may find search performance improves by increasing this value, + * to allow more items per node and less node division. + * + * @name Phaser.Physics.Arcade.World#maxEntries + * @type {integer} + * @default 16 + * @since 3.0.0 + */ + this.maxEntries = GetValue(config, 'maxEntries', 16); + + /** + * Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not? + * + * An RTree is a fast way of spatially sorting of all the moving bodies in the world. + * However, at certain limits, the cost of clearing and inserting the bodies into the + * tree every frame becomes more expensive than the search speed gains it provides. + * + * If you have a large number of dynamic bodies in your world then it may be best to + * disable the use of the RTree by setting this property to `true`. + * The number it can cope with depends on browser and device, but a conservative estimate + * of around 5,000 bodies should be considered the max before disabling it. + * + * Note this only applies to dynamic bodies. Static bodies are always kept in an RTree, + * because they don't have to be cleared every frame, so you benefit from the + * massive search speeds all the time. + * + * @name Phaser.Physics.Arcade.World#useTree + * @type {boolean} + * @default true + * @since 3.10.0 + */ + this.useTree = GetValue(config, 'useTree', true); + + /** + * The spatial index of Dynamic Bodies. + * + * @name Phaser.Physics.Arcade.World#tree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.tree = new RTree(this.maxEntries); + + /** + * The spatial index of Static Bodies. + * + * @name Phaser.Physics.Arcade.World#staticTree + * @type {Phaser.Structs.RTree} + * @since 3.0.0 + */ + this.staticTree = new RTree(this.maxEntries); + + /** + * Recycled input for tree searches. + * + * @name Phaser.Physics.Arcade.World#treeMinMax + * @type {ArcadeWorldTreeMinMax} + * @since 3.0.0 + */ + this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; + + /** + * A temporary Transform Matrix used by bodies for calculations without them needing their own local copy. + * + * @name Phaser.Physics.Arcade.World#_tempMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * A temporary Transform Matrix used by bodies for calculations without them needing their own local copy. + * + * @name Phaser.Physics.Arcade.World#_tempMatrix2 + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + if (this.drawDebug) + { + this.createDebugGraphic(); + } + }, + + /** + * Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group. + * + * The difference between this and the `enableBody` method is that you can pass arrays or Groups + * to this method. + * + * You can specify if the bodies are to be Dynamic or Static. A dynamic body can move via velocity and + * acceleration. A static body remains fixed in place and as such is able to use an optimized search + * tree, making it ideal for static elements such as level objects. You can still collide and overlap + * with static bodies. + * + * Normally, rather than calling this method directly, you'd use the helper methods available in the + * Arcade Physics Factory, such as: + * + * ```javascript + * this.physics.add.image(x, y, textureKey); + * this.physics.add.sprite(x, y, textureKey); + * ``` + * + * Calling factory methods encapsulates the creation of a Game Object and the creation of its + * body at the same time. If you are creating custom classes then you can pass them to this + * method to have their bodies created. + * + * @method Phaser.Physics.Arcade.World#enable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to create the bodies. + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + */ + enable: function (object, bodyType) + { + if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } + + if (!Array.isArray(object)) + { + object = [ object ]; + } + + for (var i = 0; i < object.length; i++) + { + var entry = object[i]; + + if (entry.isParent) + { + var children = entry.getChildren(); + + for (var c = 0; c < children.length; c++) + { + var child = children[c]; + + if (child.isParent) + { + // Handle Groups nested inside of Groups + this.enable(child, bodyType); + } + else + { + this.enableBody(child, bodyType); + } + } + } + else + { + this.enableBody(entry, bodyType); + } + } + }, + + /** + * Creates an Arcade Physics Body on a single Game Object. + * + * If the Game Object already has a body, this method will simply add it back into the simulation. + * + * You can specify if the body is Dynamic or Static. A dynamic body can move via velocity and + * acceleration. A static body remains fixed in place and as such is able to use an optimized search + * tree, making it ideal for static elements such as level objects. You can still collide and overlap + * with static bodies. + * + * Normally, rather than calling this method directly, you'd use the helper methods available in the + * Arcade Physics Factory, such as: + * + * ```javascript + * this.physics.add.image(x, y, textureKey); + * this.physics.add.sprite(x, y, textureKey); + * ``` + * + * Calling factory methods encapsulates the creation of a Game Object and the creation of its + * body at the same time. If you are creating custom classes then you can pass them to this + * method to have their bodies created. + * + * @method Phaser.Physics.Arcade.World#enableBody + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} object - The Game Object on which to create the body. + * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. + * + * @return {Phaser.GameObjects.GameObject} The Game Object on which the body was created. + */ + enableBody: function (object, bodyType) + { + if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } + + if (!object.body) + { + if (bodyType === CONST.DYNAMIC_BODY) + { + object.body = new Body(this, object); + } + else if (bodyType === CONST.STATIC_BODY) + { + object.body = new StaticBody(this, object); + } + } + + this.add(object.body); + + return object; + }, + + /** + * Adds an existing Arcade Physics Body or StaticBody to the simulation. + * + * The body is enabled and added to the local search trees. + * + * @method Phaser.Physics.Arcade.World#add + * @since 3.10.0 + * + * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be added to the simulation. + * + * @return {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} The Body that was added to the simulation. + */ + add: function (body) + { + if (body.physicsType === CONST.DYNAMIC_BODY) + { + this.bodies.set(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.set(body); + + this.staticTree.insert(body); + } + + body.enable = true; + + return body; + }, + + /** + * Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group. + * + * The difference between this and the `disableBody` method is that you can pass arrays or Groups + * to this method. + * + * The body itself is not deleted, it just has its `enable` property set to false, which + * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. + * + * @method Phaser.Physics.Arcade.World#disable + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to disable the bodies. + */ + disable: function (object) + { + if (!Array.isArray(object)) + { + object = [ object ]; + } + + for (var i = 0; i < object.length; i++) + { + var entry = object[i]; + + if (entry.isParent) + { + var children = entry.getChildren(); + + for (var c = 0; c < children.length; c++) + { + var child = children[c]; + + if (child.isParent) + { + // Handle Groups nested inside of Groups + this.disable(child); + } + else + { + this.disableBody(child.body); + } + } + } + else + { + this.disableBody(entry.body); + } + } + }, + + /** + * Disables an existing Arcade Physics Body or StaticBody and removes it from the simulation. + * + * The body is disabled and removed from the local search trees. + * + * The body itself is not deleted, it just has its `enable` property set to false, which + * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. + * + * @method Phaser.Physics.Arcade.World#disableBody + * @since 3.0.0 + * + * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be disabled. + */ + disableBody: function (body) + { + this.remove(body); + + body.enable = false; + }, + + /** + * Removes an existing Arcade Physics Body or StaticBody from the simulation. + * + * The body is disabled and removed from the local search trees. + * + * The body itself is not deleted, it just has its `enabled` property set to false, which + * means you can re-enable it again at any point by passing it to enable `enable` or `add`. + * + * @method Phaser.Physics.Arcade.World#remove + * @since 3.0.0 + * + * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The body to be removed from the simulation. + */ + remove: function (body) + { + if (body.physicsType === CONST.DYNAMIC_BODY) + { + this.tree.remove(body); + this.bodies.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + this.staticBodies.delete(body); + this.staticTree.remove(body); + } + }, + + /** + * Creates a Graphics Game Object that the world will use to render the debug display to. + * + * This is called automatically when the World is instantiated if the `debug` config property + * was set to `true`. However, you can call it at any point should you need to display the + * debug Graphic from a fixed point. + * + * You can control which objects are drawn to the Graphics object, and the colors they use, + * by setting the debug properties in the physics config. + * + * You should not typically use this in a production game. Use it to aid during debugging. + * + * @method Phaser.Physics.Arcade.World#createDebugGraphic + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Graphics} The Graphics object that was created for use by the World. + */ + createDebugGraphic: function () + { + var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); + + graphic.setDepth(Number.MAX_VALUE); + + this.debugGraphic = graphic; + + this.drawDebug = true; + + return graphic; + }, + + /** + * Sets the position, size and properties of the World boundary. + * + * The World boundary is an invisible rectangle that defines the edges of the World. + * If a Body is set to collide with the world bounds then it will automatically stop + * when it reaches any of the edges. You can optionally set which edges of the boundary + * should be checked against. + * + * @method Phaser.Physics.Arcade.World#setBounds + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the boundary. + * @param {number} y - The top-left y coordinate of the boundary. + * @param {number} width - The width of the boundary. + * @param {number} height - The height of the boundary. + * @param {boolean} [checkLeft] - Should bodies check against the left edge of the boundary? + * @param {boolean} [checkRight] - Should bodies check against the right edge of the boundary? + * @param {boolean} [checkUp] - Should bodies check against the top edge of the boundary? + * @param {boolean} [checkDown] - Should bodies check against the bottom edge of the boundary? + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBounds: function (x, y, width, height, checkLeft, checkRight, checkUp, checkDown) + { + this.bounds.setTo(x, y, width, height); + + if (checkLeft !== undefined) + { + this.setBoundsCollision(checkLeft, checkRight, checkUp, checkDown); + } + + return this; + }, + + /** + * Enables or disables collisions on each edge of the World boundary. + * + * @method Phaser.Physics.Arcade.World#setBoundsCollision + * @since 3.0.0 + * + * @param {boolean} [left=true] - Should bodies check against the left edge of the boundary? + * @param {boolean} [right=true] - Should bodies check against the right edge of the boundary? + * @param {boolean} [up=true] - Should bodies check against the top edge of the boundary? + * @param {boolean} [down=true] - Should bodies check against the bottom edge of the boundary? + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + setBoundsCollision: function (left, right, up, down) + { + if (left === undefined) { left = true; } + if (right === undefined) { right = true; } + if (up === undefined) { up = true; } + if (down === undefined) { down = true; } + + this.checkCollision.left = left; + this.checkCollision.right = right; + this.checkCollision.up = up; + this.checkCollision.down = down; + + return this; + }, + + /** + * Pauses the simulation. + * + * A paused simulation does not update any existing bodies, or run any Colliders. + * + * However, you can still enable and disable bodies within it, or manually run collide or overlap + * checks. + * + * @method Phaser.Physics.Arcade.World#pause + * @fires Phaser.Physics.Arcade.World#pause + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + pause: function () + { + this.isPaused = true; + + this.emit('pause'); + + return this; + }, + + /** + * Resumes the simulation, if paused. + * + * @method Phaser.Physics.Arcade.World#resume + * @fires Phaser.Physics.Arcade.World#resume + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + resume: function () + { + this.isPaused = false; + + this.emit('resume'); + + return this; + }, + + /** + * Creates a new Collider object and adds it to the simulation. + * + * A Collider is a way to automatically perform collision checks between two objects, + * calling the collide and process callbacks if they occur. + * + * Colliders are run as part of the World update, after all of the Bodies have updated. + * + * By creating a Collider you don't need then call `World.collide` in your `update` loop, + * as it will be handled for you automatically. + * + * @method Phaser.Physics.Arcade.World#addCollider + * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#collide + * + * @param {ArcadeColliderType} object1 - The first object to check for collision. + * @param {ArcadeColliderType} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addCollider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, false, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * Creates a new Overlap Collider object and adds it to the simulation. + * + * A Collider is a way to automatically perform overlap checks between two objects, + * calling the collide and process callbacks if they occur. + * + * Colliders are run as part of the World update, after all of the Bodies have updated. + * + * By creating a Collider you don't need then call `World.overlap` in your `update` loop, + * as it will be handled for you automatically. + * + * @method Phaser.Physics.Arcade.World#addOverlap + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object to check for overlap. + * @param {ArcadeColliderType} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects overlap. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects overlap. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + addOverlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + var collider = new Collider(this, true, object1, object2, collideCallback, processCallback, callbackContext); + + this.colliders.add(collider); + + return collider; + }, + + /** + * Removes a Collider from the simulation so it is no longer processed. + * + * This method does not destroy the Collider. If you wish to add it back at a later stage you can call + * `World.colliders.add(Collider)`. + * + * If you no longer need the Collider you can call the `Collider.destroy` method instead, which will + * automatically clear all of its references and then remove it from the World. If you call destroy on + * a Collider you _don't_ need to pass it to this method too. + * + * @method Phaser.Physics.Arcade.World#removeCollider + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Collider} collider - The Collider to remove from the simulation. + * + * @return {Phaser.Physics.Arcade.World} This World object. + */ + removeCollider: function (collider) + { + this.colliders.remove(collider); + + return this; + }, + + /** + * Sets the frame rate to run the simulation at. + * + * The frame rate value is used to simulate a fixed update time step. This fixed + * time step allows for a straightforward implementation of a deterministic game state. + * + * This frame rate is independent of the frequency at which the game is rendering. The + * higher you set the fps, the more physics simulation steps will occur per game step. + * Conversely, the lower you set it, the less will take place. + * + * You can optionally advance the simulation directly yourself by calling the `step` method. + * + * @method Phaser.Physics.Arcade.World#setFPS + * @since 3.10.0 + * + * @param {integer} framerate - The frame rate to advance the simulation at. + * + * @return {this} This World object. + */ + setFPS: function (framerate) + { + this.fps = framerate; + this._frameTime = 1 / this.fps; + this._frameTimeMS = 1000 * this._frameTime; + + return this; + }, + + /** + * Advances the simulation based on the elapsed time and fps rate. + * + * This is called automatically by your Scene and does not need to be invoked directly. + * + * @method Phaser.Physics.Arcade.World#update + * @protected + * @since 3.0.0 + * + * @param {number} 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.isPaused || this.bodies.size === 0) + { + return; + } + + var stepsThisFrame = 0; + var fixedDelta = this._frameTime; + var msPerFrame = this._frameTimeMS * this.timeScale; + + this._elapsed += delta; + + while (this._elapsed >= msPerFrame) + { + this._elapsed -= msPerFrame; + + stepsThisFrame++; + + this.step(fixedDelta); + } + + this.stepsLastFrame = stepsThisFrame; + }, + + /** + * Advances the simulation by one step. + * + * @method Phaser.Physics.Arcade.World#step + * @since 3.10.0 + * + * @param {number} delta - The delta time amount, in ms, by which to advance the simulation. + */ + step: function (delta) + { + // Update all active bodies + var i; + var body; + var bodies = this.bodies.entries; + var len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.update(delta); + } + } + + // Optionally populate our dynamic collision tree + if (this.useTree) + { + this.tree.clear(); + this.tree.load(bodies); + } + + // Process any colliders + var colliders = this.colliders.update(); + + for (i = 0; i < colliders.length; i++) + { + var collider = colliders[i]; + + if (collider.active) + { + collider.update(); + } + } + + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.enable) + { + body.postUpdate(); + } + } + }, + + /** + * Updates bodies, draws the debug display, and handles pending queue operations. + * + * @method Phaser.Physics.Arcade.World#postUpdate + * @since 3.0.0 + */ + postUpdate: function () + { + var i; + var body; + + var dynamic = this.bodies; + var staticBodies = this.staticBodies; + var pending = this.pendingDestroy; + + var bodies = dynamic.entries; + var len = bodies.length; + + if (this.drawDebug) + { + var graphics = this.debugGraphic; + + graphics.clear(); + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + + bodies = staticBodies.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.willDrawDebug()) + { + body.drawDebug(graphics); + } + } + } + + if (pending.size > 0) + { + var dynamicTree = this.tree; + var staticTree = this.staticTree; + + bodies = pending.entries; + len = bodies.length; + + for (i = 0; i < len; i++) + { + body = bodies[i]; + + if (body.physicsType === CONST.DYNAMIC_BODY) + { + dynamicTree.remove(body); + dynamic.delete(body); + } + else if (body.physicsType === CONST.STATIC_BODY) + { + staticTree.remove(body); + staticBodies.delete(body); + } + + body.world = undefined; + body.gameObject = undefined; + } + + pending.clear(); + } + }, + + /** + * Calculates a Body's velocity and updates its position. + * + * @method Phaser.Physics.Arcade.World#updateMotion + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body to be updated. + * @param {number} delta - The delta value to be used in the motion calculations. + */ + updateMotion: function (body, delta) + { + if (body.allowRotation) + { + this.computeAngularVelocity(body, delta); + } + + this.computeVelocity(body, delta); + }, + + /** + * Calculates a Body's angular velocity. + * + * @method Phaser.Physics.Arcade.World#computeAngularVelocity + * @since 3.10.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. + * @param {number} delta - The delta value to be used in the calculation. + */ + computeAngularVelocity: function (body, delta) + { + var velocity = body.angularVelocity; + var acceleration = body.angularAcceleration; + var drag = body.angularDrag; + var max = body.maxAngular; + + if (acceleration) + { + velocity += acceleration * delta; + } + else if (body.allowDrag && drag) + { + drag *= delta; + + if (FuzzyGreaterThan(velocity - drag, 0, 0.1)) + { + velocity -= drag; + } + else if (FuzzyLessThan(velocity + drag, 0, 0.1)) + { + velocity += drag; + } + else + { + velocity = 0; + } + } + + velocity = Clamp(velocity, -max, max); + + var velocityDelta = velocity - body.angularVelocity; + + body.angularVelocity += velocityDelta; + body.rotation += (body.angularVelocity * delta); + }, + + /** + * Calculates a Body's per-axis velocity. + * + * @method Phaser.Physics.Arcade.World#computeVelocity + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. + * @param {number} delta - The delta value to be used in the calculation. + */ + computeVelocity: function (body, delta) + { + var velocityX = body.velocity.x; + var accelerationX = body.acceleration.x; + var dragX = body.drag.x; + var maxX = body.maxVelocity.x; + + var velocityY = body.velocity.y; + var accelerationY = body.acceleration.y; + var dragY = body.drag.y; + var maxY = body.maxVelocity.y; + + var speed = body.speed; + var allowDrag = body.allowDrag; + var useDamping = body.useDamping; + + if (body.allowGravity) + { + velocityX += (this.gravity.x + body.gravity.x) * delta; + velocityY += (this.gravity.y + body.gravity.y) * delta; + } + + if (accelerationX) + { + velocityX += accelerationX * delta; + } + else if (allowDrag && dragX) + { + if (useDamping) + { + // Damping based deceleration + velocityX *= dragX; + + if (FuzzyEqual(speed, 0, 0.001)) + { + velocityX = 0; + } + } + else + { + // Linear deceleration + dragX *= delta; + + if (FuzzyGreaterThan(velocityX - dragX, 0, 0.01)) + { + velocityX -= dragX; + } + else if (FuzzyLessThan(velocityX + dragX, 0, 0.01)) + { + velocityX += dragX; + } + else + { + velocityX = 0; + } + } + } + + if (accelerationY) + { + velocityY += accelerationY * delta; + } + else if (allowDrag && dragY) + { + if (useDamping) + { + // Damping based deceleration + velocityY *= dragY; + + if (FuzzyEqual(speed, 0, 0.001)) + { + velocityY = 0; + } + } + else + { + // Linear deceleration + dragY *= delta; + + if (FuzzyGreaterThan(velocityY - dragY, 0, 0.01)) + { + velocityY -= dragY; + } + else if (FuzzyLessThan(velocityY + dragY, 0, 0.01)) + { + velocityY += dragY; + } + else + { + velocityY = 0; + } + } + } + + velocityX = Clamp(velocityX, -maxX, maxX); + velocityY = Clamp(velocityY, -maxY, maxY); + + body.velocity.set(velocityX, velocityY); + }, + + /** + * Separates two Bodies. + * + * @method Phaser.Physics.Arcade.World#separate + * @fires Phaser.Physics.Arcade.World#collide + * @fires Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. + * @param {ArcadePhysicsCallback} [processCallback] - The process callback. + * @param {*} [callbackContext] - The context in which to invoke the callback. + * @param {boolean} [overlapOnly] - If this a collide or overlap check? + * + * @return {boolean} True if separation occurred, otherwise false. + */ + separate: function (body1, body2, processCallback, callbackContext, overlapOnly) + { + if ( + !body1.enable || + !body2.enable || + body1.checkCollision.none || + body2.checkCollision.none || + !this.intersects(body1, body2)) + { + return false; + } + + // They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort. + if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false) + { + return false; + } + + // Circle vs. Circle quick bail out + if (body1.isCircle && body2.isCircle) + { + return this.separateCircle(body1, body2, overlapOnly); + } + + // We define the behavior of bodies in a collision circle and rectangle + // If a collision occurs in the corner points of the rectangle, the body behave like circles + + // Either body1 or body2 is a circle + if (body1.isCircle !== body2.isCircle) + { + var bodyRect = (body1.isCircle) ? body2 : body1; + var bodyCircle = (body1.isCircle) ? body1 : body2; + + var rect = { + x: bodyRect.x, + y: bodyRect.y, + right: bodyRect.right, + bottom: bodyRect.bottom + }; + + var circle = bodyCircle.center; + + if (circle.y < rect.y || circle.y > rect.bottom) + { + if (circle.x < rect.x || circle.x > rect.right) + { + return this.separateCircle(body1, body2, overlapOnly); + } + } + } + + var resultX = false; + var resultY = false; + + // Do we separate on x or y first? + if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + else + { + resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); + + // Are they still intersecting? Let's do the other axis then + if (this.intersects(body1, body2)) + { + resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); + } + } + + var result = (resultX || resultY); + + if (result) + { + if (overlapOnly && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + else + { + body1.postUpdate(); + body2.postUpdate(); + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + } + } + + return result; + }, + + /** + * Separates two Bodies, when both are circular. + * + * @method Phaser.Physics.Arcade.World#separateCircle + * @fires Phaser.Physics.Arcade.World#collide + * @fires Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. + * @param {boolean} [overlapOnly] - If this a collide or overlap check? + * @param {number} bias - A small value added to the calculations. + * + * @return {boolean} True if separation occurred, otherwise false. + */ + separateCircle: function (body1, body2, overlapOnly, bias) + { + // Set the bounding box overlap values into the bodies themselves (hence we don't use the return values here) + GetOverlapX(body1, body2, false, bias); + GetOverlapY(body1, body2, false, bias); + + var dx = body2.center.x - body1.center.x; + var dy = body2.center.y - body1.center.y; + + var angleCollision = Math.atan2(dy, dx); + + var overlap = 0; + + if (body1.isCircle !== body2.isCircle) + { + var rect = { + x: (body2.isCircle) ? body1.position.x : body2.position.x, + y: (body2.isCircle) ? body1.position.y : body2.position.y, + right: (body2.isCircle) ? body1.right : body2.right, + bottom: (body2.isCircle) ? body1.bottom : body2.bottom + }; + + var circle = { + x: (body1.isCircle) ? body1.center.x : body2.center.x, + y: (body1.isCircle) ? body1.center.y : body2.center.y, + radius: (body1.isCircle) ? body1.halfWidth : body2.halfWidth + }; + + if (circle.y < rect.y) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.y) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.y) - circle.radius; + } + } + else if (circle.y > rect.bottom) + { + if (circle.x < rect.x) + { + overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.bottom) - circle.radius; + } + else if (circle.x > rect.right) + { + overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.bottom) - circle.radius; + } + } + + overlap *= -1; + } + else + { + overlap = (body1.halfWidth + body2.halfWidth) - DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y); + } + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) + { + if (overlap !== 0 && (body1.onOverlap || body2.onOverlap)) + { + this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); + } + + // return true if there was some overlap, otherwise false + return (overlap !== 0); + } + + // Transform the velocity vector to the coordinate system oriented along the direction of impact. + // This is done to eliminate the vertical component of the velocity + + var b1vx = body1.velocity.x; + var b1vy = body1.velocity.y; + var b1mass = body1.mass; + + var b2vx = body2.velocity.x; + var b2vy = body2.velocity.y; + var b2mass = body2.mass; + + var v1 = { + x: b1vx * Math.cos(angleCollision) + b1vy * Math.sin(angleCollision), + y: b1vx * Math.sin(angleCollision) - b1vy * Math.cos(angleCollision) + }; + + var v2 = { + x: b2vx * Math.cos(angleCollision) + b2vy * Math.sin(angleCollision), + y: b2vx * Math.sin(angleCollision) - b2vy * Math.cos(angleCollision) + }; + + // We expect the new velocity after impact + var tempVel1 = ((b1mass - b2mass) * v1.x + 2 * b2mass * v2.x) / (b1mass + b2mass); + var tempVel2 = (2 * b1mass * v1.x + (b2mass - b1mass) * v2.x) / (b1mass + b2mass); + + // We convert the vector to the original coordinate system and multiplied by factor of rebound + if (!body1.immovable) + { + body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x; + body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y; + + // Reset local var + b1vx = body1.velocity.x; + b1vy = body1.velocity.y; + } + + if (!body2.immovable) + { + body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x; + body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y; + + // Reset local var + b2vx = body2.velocity.x; + b2vy = body2.velocity.y; + } + + // When the collision angle is almost perpendicular to the total initial velocity vector + // (collision on a tangent) vector direction can be determined incorrectly. + // This code fixes the problem + + if (Math.abs(angleCollision) < Math.PI / 2) + { + if ((b1vx > 0) && !body1.immovable && (b2vx > b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx < 0) && !body2.immovable && (b1vx < b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy > 0) && !body1.immovable && (b2vy > b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy < 0) && !body2.immovable && (b1vy < b2vy)) + { + body2.velocity.y *= -1; + } + } + else if (Math.abs(angleCollision) > Math.PI / 2) + { + if ((b1vx < 0) && !body1.immovable && (b2vx < b1vx)) + { + body1.velocity.x *= -1; + } + else if ((b2vx > 0) && !body2.immovable && (b1vx > b2vx)) + { + body2.velocity.x *= -1; + } + else if ((b1vy < 0) && !body1.immovable && (b2vy < b1vy)) + { + body1.velocity.y *= -1; + } + else if ((b2vy > 0) && !body2.immovable && (b1vx > b2vy)) + { + body2.velocity.y *= -1; + } + } + + var delta = this._frameTime; + + if (!body1.immovable) + { + body1.x += (body1.velocity.x * delta) - overlap * Math.cos(angleCollision); + body1.y += (body1.velocity.y * delta) - overlap * Math.sin(angleCollision); + } + + if (!body2.immovable) + { + body2.x += (body2.velocity.x * delta) + overlap * Math.cos(angleCollision); + body2.y += (body2.velocity.y * delta) + overlap * Math.sin(angleCollision); + } + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } + + // sync changes back to the bodies + body1.postUpdate(); + body2.postUpdate(); + + return true; + }, + + /** + * Checks to see if two Bodies intersect at all. + * + * @method Phaser.Physics.Arcade.World#intersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - The first body to check. + * @param {Phaser.Physics.Arcade.Body} body2 - The second body to check. + * + * @return {boolean} True if the two bodies intersect, otherwise false. + */ + intersects: function (body1, body2) + { + if (body1 === body2) + { + return false; + } + + if (!body1.isCircle && !body2.isCircle) + { + // Rect vs. Rect + return !( + body1.right <= body2.position.x || + body1.bottom <= body2.position.y || + body1.position.x >= body2.right || + body1.position.y >= body2.bottom + ); + } + else if (body1.isCircle) + { + if (body2.isCircle) + { + // Circle vs. Circle + return DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.halfWidth + body2.halfWidth); + } + else + { + // Circle vs. Rect + return this.circleBodyIntersects(body1, body2); + } + } + else + { + // Rect vs. Circle + return this.circleBodyIntersects(body2, body1); + } + }, + + /** + * Tests if a circular Body intersects with another Body. + * + * @method Phaser.Physics.Arcade.World#circleBodyIntersects + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} circle - The circular body to test. + * @param {Phaser.Physics.Arcade.Body} body - The rectangular body to test. + * + * @return {boolean} True if the two bodies intersect, otherwise false. + */ + circleBodyIntersects: function (circle, body) + { + var x = Clamp(circle.center.x, body.left, body.right); + var y = Clamp(circle.center.y, body.top, body.bottom); + + var dx = (circle.center.x - x) * (circle.center.x - x); + var dy = (circle.center.y - y) * (circle.center.y - y); + + return (dx + dy) <= (circle.halfWidth * circle.halfWidth); + }, + + /** + * Tests if Game Objects overlap. + * + * @method Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [overlapCallback] - An optional callback function that is called if the objects overlap. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if at least one Game Object overlaps another. + */ + overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) + { + if (overlapCallback === undefined) { overlapCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = overlapCallback; } + + return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + }, + + /** + * Performs a collision check and separation between the two physics enabled objects given, which can be single + * Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups. + * + * If you don't require separation then use {@link #overlap} instead. + * + * If two Groups or arrays are passed, each member of one will be tested against each member of the other. + * + * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. + * + * Two callbacks can be provided. The `collideCallback` is invoked if a collision occurs and the two colliding + * objects are passed to it. + * + * Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable + * for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other. + * The separation that stops two objects penetrating may create a new penetration against a different object. If you + * require a high level of stability please consider using an alternative physics system, such as Matter.js. + * + * @method Phaser.Physics.Arcade.World#collide + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. + * + * @return {boolean} True if any overlapping Game Objects were separated, otherwise false. + */ + collide: function (object1, object2, collideCallback, processCallback, callbackContext) + { + if (collideCallback === undefined) { collideCallback = null; } + if (processCallback === undefined) { processCallback = null; } + if (callbackContext === undefined) { callbackContext = collideCallback; } + + return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + }, + + /** + * Helper for Phaser.Physics.Arcade.World#collide. + * + * @method Phaser.Physics.Arcade.World#collideObjects + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - [description] + * @param {ArcadeColliderType} [object2] - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. + */ + collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + var i; + + if (object1.isParent && object1.physicsType === undefined) + { + object1 = object1.children.entries; + } + + if (object2 && object2.isParent && object2.physicsType === undefined) + { + object2 = object2.children.entries; + } + + var object1isArray = Array.isArray(object1); + var object2isArray = Array.isArray(object2); + + this._total = 0; + + if (!object1isArray && !object2isArray) + { + // Neither of them are arrays - do this first as it's the most common use-case + this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (!object1isArray && object2isArray) + { + // Object 2 is an Array + for (i = 0; i < object2.length; i++) + { + this.collideHandler(object1, object2[i], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else if (object1isArray && !object2isArray) + { + // Object 1 is an Array + for (i = 0; i < object1.length; i++) + { + this.collideHandler(object1[i], object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + else + { + // They're both arrays + for (i = 0; i < object1.length; i++) + { + for (var j = 0; j < object2.length; j++) + { + this.collideHandler(object1[i], object2[j], collideCallback, processCallback, callbackContext, overlapOnly); + } + } + } + + return (this._total > 0); + }, + + /** + * Helper for Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap. + * + * @method Phaser.Physics.Arcade.World#collideHandler + * @since 3.0.0 + * + * @param {ArcadeColliderType} object1 - [description] + * @param {ArcadeColliderType} [object2] - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. + */ + collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + { + // Collide Group with Self + // Only collide valid objects + if (object2 === undefined && object1.isParent) + { + return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + + // If neither of the objects are set then bail out + if (!object1 || !object2) + { + return false; + } + + // A Body + if (object1.body) + { + if (object2.body) + { + return this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // GROUPS + else if (object1.isParent) + { + if (object2.body) + { + return this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isTilemap) + { + return this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + + // TILEMAP LAYERS + else if (object1.isTilemap) + { + if (object2.body) + { + return this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + else if (object2.isParent) + { + return this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); + } + } + }, + + /** + * Handler for Sprite vs. Sprite collisions. + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite1 - [description] + * @param {Phaser.GameObjects.GameObject} sprite2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (!sprite1.body || !sprite2.body) + { + return false; + } + + if (this.separate(sprite1.body, sprite2.body, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, sprite1, sprite2); + } + + this._total++; + } + + return true; + }, + + /** + * Handler for Sprite vs. Group collisions. + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {Phaser.GameObjects.Group} group - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) + { + var bodyA = sprite.body; + + if (group.length === 0 || !bodyA || !bodyA.enable) + { + return; + } + + // Does sprite collide with anything? + + var i; + var len; + var bodyB; + + if (this.useTree) + { + var minMax = this.treeMinMax; + + minMax.minX = bodyA.left; + minMax.minY = bodyA.top; + minMax.maxX = bodyA.right; + minMax.maxY = bodyA.bottom; + + var results = (group.physicsType === CONST.DYNAMIC_BODY) ? this.tree.search(minMax) : this.staticTree.search(minMax); + + len = results.length; + + for (i = 0; i < len; i++) + { + bodyB = results[i]; + + if (bodyA === bodyB || !group.contains(bodyB.gameObject)) + { + // Skip if comparing against itself, or if bodyB isn't actually part of the Group + continue; + } + + if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); + } + + this._total++; + } + } + } + else + { + var children = group.getChildren(); + var skipIndex = group.children.entries.indexOf(sprite); + + len = children.length; + + for (i = 0; i < len; i++) + { + bodyB = children[i].body; + + if (!bodyB || i === skipIndex || !bodyB.enable) + { + continue; + } + + if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) + { + if (collideCallback) + { + collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); + } + + this._total++; + } + } + } + }, + + /** + * Helper for Group vs. Tilemap collisions. + * + * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var children = group.getChildren(); + + if (children.length === 0) + { + return false; + } + + var didCollide = false; + + for (var i = 0; i < children.length; i++) + { + if (children[i].body) + { + if (this.collideSpriteVsTilemapLayer(children[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)) + { + didCollide = true; + } + } + } + + return didCollide; + }, + + /** + * Helper for Sprite vs. Tilemap collisions. + * + * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer + * @fires Phaser.Physics.Arcade.World#collide + * @fires Phaser.Physics.Arcade.World#overlap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + { + var body = sprite.body; + + if (!body.enable) + { + return false; + } + + var x = body.position.x; + var y = body.position.y; + var w = body.width; + var h = body.height; + + // TODO: this logic should be encapsulated within the Tilemap API at some point. + // If the maps base tile size differs from the layer's tile size, we need to adjust the + // selection area by the difference between the two. + var layerData = tilemapLayer.layer; + + if (layerData.tileWidth > layerData.baseTileWidth) + { + // The x origin of a tile is the left side, so x and width need to be adjusted. + var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; + x -= xDiff; + w += xDiff; + } + + if (layerData.tileHeight > layerData.baseTileHeight) + { + // The y origin of a tile is the bottom side, so just the height needs to be adjusted. + var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; + h += yDiff; + } + + var mapData = tilemapLayer.getTilesWithinWorldXY(x, y, w, h); + + if (mapData.length === 0) + { + return false; + } + + var tile; + var tileWorldRect = { left: 0, right: 0, top: 0, bottom: 0 }; + + for (var i = 0; i < mapData.length; i++) + { + tile = mapData[i]; + tileWorldRect.left = tilemapLayer.tileToWorldX(tile.x); + tileWorldRect.top = tilemapLayer.tileToWorldY(tile.y); + + // If the map's base tile size differs from the layer's tile size, only the top of the rect + // needs to be adjusted since its origin is (0, 1). + if (tile.baseHeight !== tile.height) + { + tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; + } + + tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; + tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; + + if (TileIntersectsBody(tileWorldRect, body) + && (!processCallback || processCallback.call(callbackContext, sprite, tile)) + && ProcessTileCallbacks(tile, sprite) + && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) + { + this._total++; + + if (collideCallback) + { + collideCallback.call(callbackContext, sprite, tile); + } + + if (overlapOnly && body.onOverlap) + { + sprite.emit('overlap', body.gameObject, tile, body, null); + } + else if (body.onCollide) + { + sprite.emit('collide', body.gameObject, tile, body, null); + } + + // sync changes back to the body + body.postUpdate(); + } + } + }, + + /** + * Helper for Group vs. Group collisions. + * + * @method Phaser.Physics.Arcade.World#collideGroupVsGroup + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Group} group1 - [description] + * @param {Phaser.GameObjects.Group} group2 - [description] + * @param {ArcadePhysicsCallback} collideCallback - [description] + * @param {ArcadePhysicsCallback} processCallback - [description] + * @param {*} callbackContext - [description] + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. + * + * @return {boolean} [description] + */ + collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) + { + if (group1.length === 0 || group2.length === 0) + { + return; + } + + var children = group1.getChildren(); + + for (var i = 0; i < children.length; i++) + { + this.collideSpriteVsGroup(children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly); + } + }, + + /** + * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. + * + * If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior). + * + * @method Phaser.Physics.Arcade.World#wrap + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects. + * @param {number} [padding=0] - An amount added to each boundary edge during the operation. + */ + wrap: function (object, padding) + { + if (object.body) + { + this.wrapObject(object, padding); + } + else if (object.getChildren) + { + this.wrapArray(object.getChildren(), padding); + } + else if (Array.isArray(object)) + { + this.wrapArray(object, padding); + } + else + { + this.wrapObject(object, padding); + } + }, + + + /** + * Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapArray + * @since 3.3.0 + * + * @param {Array.<*>} objects - An array of objects to be wrapped. + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapArray: function (objects, padding) + { + for (var i = 0; i < objects.length; i++) + { + this.wrapObject(objects[i], padding); + } + }, + + /** + * Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * + * @method Phaser.Physics.Arcade.World#wrapObject + * @since 3.3.0 + * + * @param {*} object - A Game Object, a Physics Body, or any object with `x` and `y` coordinates + * @param {number} [padding=0] - An amount added to the boundary. + */ + wrapObject: function (object, padding) + { + if (padding === undefined) { padding = 0; } + + object.x = Wrap(object.x, this.bounds.left - padding, this.bounds.right + padding); + object.y = Wrap(object.y, this.bounds.top - padding, this.bounds.bottom + padding); + }, + + /** + * Shuts down the simulation, clearing physics data and removing listeners. + * + * @method Phaser.Physics.Arcade.World#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + this.tree.clear(); + this.staticTree.clear(); + this.bodies.clear(); + this.staticBodies.clear(); + this.colliders.destroy(); + + this.removeAllListeners(); + }, + + /** + * Shuts down the simulation and disconnects it from the current scene. + * + * @method Phaser.Physics.Arcade.World#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.scene = null; + } + +}); + +module.exports = World; + + +/***/ }), +/* 234 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeSprite = __webpack_require__(104); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var Group = __webpack_require__(88); +var IsPlainObject = __webpack_require__(8); + +/** + * @classdesc + * An Arcade Physics Static Group object. + * + * All Game Objects created by this Group will automatically be given static Arcade Physics bodies. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Group}. + * + * @class StaticGroup + * @extends Phaser.GameObjects.Group + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The physics simulation. + * @param {Phaser.Scene} scene - The scene this group belongs to. + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. + */ +var StaticPhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function StaticPhysicsGroup (world, scene, children, config) + { + if (!children && !config) + { + config = { + createCallback: this.createCallbackHandler, + removeCallback: this.removeCallbackHandler, + createMultipleCallback: this.createMultipleCallbackHandler, + classType: ArcadeSprite + }; + } + else if (IsPlainObject(children)) + { + // children is a plain object, so swizzle them: + config = children; + children = null; + + config.createCallback = this.createCallbackHandler; + config.removeCallback = this.removeCallbackHandler; + config.createMultipleCallback = this.createMultipleCallbackHandler; + config.classType = ArcadeSprite; + } + else if (Array.isArray(children) && IsPlainObject(children[0])) + { + // children is an array of plain objects + config = children; + children = null; + + config.forEach(function (singleConfig) + { + singleConfig.createCallback = this.createCallbackHandler; + singleConfig.removeCallback = this.removeCallbackHandler; + singleConfig.createMultipleCallback = this.createMultipleCallbackHandler; + singleConfig.classType = ArcadeSprite; + }); + } + + /** + * The physics simulation. + * + * @name Phaser.Physics.Arcade.StaticGroup#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * The scene this group belongs to. + * + * @name Phaser.Physics.Arcade.StaticGroup#physicsType + * @type {integer} + * @default STATIC_BODY + * @since 3.0.0 + */ + this.physicsType = CONST.STATIC_BODY; + + Group.call(this, scene, children, config); + }, + + /** + * Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation. + * + * @method Phaser.Physics.Arcade.StaticGroup#createCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The new group member. + * + * @see Phaser.Physics.Arcade.World#enableBody + */ + createCallbackHandler: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.STATIC_BODY); + } + }, + + /** + * Disables the group member's physics body, removing it from the simulation. + * + * @method Phaser.Physics.Arcade.StaticGroup#removeCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The group member being removed. + * + * @see Phaser.Physics.Arcade.World#disableBody + */ + removeCallbackHandler: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * Refreshes the group. + * + * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject[]} entries - The newly created group members. + * + * @see Phaser.Physics.Arcade.StaticGroup#refresh + */ + createMultipleCallbackHandler: function () + { + this.refresh(); + }, + + /** + * Resets each Body to the position of its parent Game Object. + * Body sizes aren't changed (use {@link Phaser.Physics.Arcade.Components.Enable#refreshBody} for that). + * + * @method Phaser.Physics.Arcade.StaticGroup#refresh + * @since 3.0.0 + * + * @return {Phaser.Physics.Arcade.StaticGroup} This group. + * + * @see Phaser.Physics.Arcade.StaticBody#reset + */ + refresh: function () + { + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + children[i].body.reset(); + } + + return this; + } + +}); + +module.exports = StaticPhysicsGroup; + + +/***/ }), +/* 235 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeSprite = __webpack_require__(104); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var GetFastValue = __webpack_require__(2); +var Group = __webpack_require__(88); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} PhysicsGroupConfig + * @extends GroupConfig + * + * @property {boolean} [collideWorldBounds=false] - Sets {@link Phaser.Physics.Arcade.Body#collideWorldBounds}. + * @property {number} [accelerationX=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.x}. + * @property {number} [accelerationY=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.y}. + * @property {boolean} [allowDrag=true] - Sets {@link Phaser.Physics.Arcade.Body#allowDrag}. + * @property {boolean} [allowGravity=true] - Sets {@link Phaser.Physics.Arcade.Body#allowGravity}. + * @property {boolean} [allowRotation=true] - Sets {@link Phaser.Physics.Arcade.Body#allowRotation}. + * @property {number} [bounceX=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.x}. + * @property {number} [bounceY=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.y}. + * @property {number} [dragX=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.x}. + * @property {number} [dragY=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.y}. + * @property {boolean} [enable=true] - Sets {@link Phaser.Physics.Arcade.Body#enable enable}. + * @property {number} [gravityX=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.x}. + * @property {number} [gravityY=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.y}. + * @property {number} [frictionX=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.x}. + * @property {number} [frictionY=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.y}. + * @property {number} [velocityX=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.x}. + * @property {number} [velocityY=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.y}. + * @property {number} [angularVelocity=0] - Sets {@link Phaser.Physics.Arcade.Body#angularVelocity}. + * @property {number} [angularAcceleration=0] - Sets {@link Phaser.Physics.Arcade.Body#angularAcceleration}. + * @property {number} [angularDrag=0] - Sets {@link Phaser.Physics.Arcade.Body#angularDrag}. + * @property {number} [mass=0] - Sets {@link Phaser.Physics.Arcade.Body#mass}. + * @property {boolean} [immovable=false] - Sets {@link Phaser.Physics.Arcade.Body#immovable}. + */ + +/** + * @typedef {object} PhysicsGroupDefaults + * + * @property {boolean} setCollideWorldBounds - As {@link Phaser.Physics.Arcade.Body#setCollideWorldBounds}. + * @property {number} setAccelerationX - As {@link Phaser.Physics.Arcade.Body#setAccelerationX}. + * @property {number} setAccelerationY - As {@link Phaser.Physics.Arcade.Body#setAccelerationY}. + * @property {boolean} setAllowDrag - As {@link Phaser.Physics.Arcade.Body#setAllowDrag}. + * @property {boolean} setAllowGravity - As {@link Phaser.Physics.Arcade.Body#setAllowGravity}. + * @property {boolean} setAllowRotation - As {@link Phaser.Physics.Arcade.Body#setAllowRotation}. + * @property {number} setBounceX - As {@link Phaser.Physics.Arcade.Body#setBounceX}. + * @property {number} setBounceY - As {@link Phaser.Physics.Arcade.Body#setBounceY}. + * @property {number} setDragX - As {@link Phaser.Physics.Arcade.Body#setDragX}. + * @property {number} setDragY - As {@link Phaser.Physics.Arcade.Body#setDragY}. + * @property {boolean} setEnable - As {@link Phaser.Physics.Arcade.Body#setEnable}. + * @property {number} setGravityX - As {@link Phaser.Physics.Arcade.Body#setGravityX}. + * @property {number} setGravityY - As {@link Phaser.Physics.Arcade.Body#setGravityY}. + * @property {number} setFrictionX - As {@link Phaser.Physics.Arcade.Body#setFrictionX}. + * @property {number} setFrictionY - As {@link Phaser.Physics.Arcade.Body#setFrictionY}. + * @property {number} setVelocityX - As {@link Phaser.Physics.Arcade.Body#setVelocityX}. + * @property {number} setVelocityY - As {@link Phaser.Physics.Arcade.Body#setVelocityY}. + * @property {number} setAngularVelocity - As {@link Phaser.Physics.Arcade.Body#setAngularVelocity}. + * @property {number} setAngularAcceleration - As {@link Phaser.Physics.Arcade.Body#setAngularAcceleration}. + * @property {number} setAngularDrag - As {@link Phaser.Physics.Arcade.Body#setAngularDrag}. + * @property {number} setMass - As {@link Phaser.Physics.Arcade.Body#setMass}. + * @property {boolean} setImmovable - As {@link Phaser.Physics.Arcade.Body#setImmovable}. + */ + +/** + * @classdesc + * An Arcade Physics Group object. + * + * All Game Objects created by this Group will automatically be given dynamic Arcade Physics bodies. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticGroup}. + * + * @class Group + * @extends Phaser.GameObjects.Group + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The physics simulation. + * @param {Phaser.Scene} scene - The scene this group belongs to. + * @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group. + */ +var PhysicsGroup = new Class({ + + Extends: Group, + + initialize: + + function PhysicsGroup (world, scene, children, config) + { + if (!children && !config) + { + config = { + createCallback: this.createCallbackHandler, + removeCallback: this.removeCallbackHandler + }; + } + else if (IsPlainObject(children)) + { + // children is a plain object, so swizzle them: + config = children; + children = null; + + config.createCallback = this.createCallbackHandler; + config.removeCallback = this.removeCallbackHandler; + } + else if (Array.isArray(children) && IsPlainObject(children[0])) + { + // children is an array of plain objects + config = children; + children = null; + + config.forEach(function (singleConfig) + { + singleConfig.createCallback = this.createCallbackHandler; + singleConfig.removeCallback = this.removeCallbackHandler; + }); + } + + /** + * The physics simulation. + * + * @name Phaser.Physics.Arcade.Group#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * The class to create new group members from. + * This should be ArcadeImage, ArcadeSprite, or a class extending one of those. + * + * @name Phaser.Physics.Arcade.Group#classType + * @type {(Phaser.Physics.Arcade.Image|Phaser.Physics.Arcade.Sprite)} + * @default ArcadeSprite + */ + config.classType = GetFastValue(config, 'classType', ArcadeSprite); + + /** + * The physics type of the Group's members. + * + * @name Phaser.Physics.Arcade.Group#physicsType + * @type {integer} + * @default DYNAMIC_BODY + * @since 3.0.0 + */ + this.physicsType = CONST.DYNAMIC_BODY; + + /** + * Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument. + * + * @name Phaser.Physics.Arcade.Group#defaults + * @type {PhysicsGroupDefaults} + * @since 3.0.0 + */ + this.defaults = { + setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false), + setAccelerationX: GetFastValue(config, 'accelerationX', 0), + setAccelerationY: GetFastValue(config, 'accelerationY', 0), + setAllowDrag: GetFastValue(config, 'allowDrag', true), + setAllowGravity: GetFastValue(config, 'allowGravity', true), + setAllowRotation: GetFastValue(config, 'allowRotation', true), + setBounceX: GetFastValue(config, 'bounceX', 0), + setBounceY: GetFastValue(config, 'bounceY', 0), + setDragX: GetFastValue(config, 'dragX', 0), + setDragY: GetFastValue(config, 'dragY', 0), + setEnable: GetFastValue(config, 'enable', true), + setGravityX: GetFastValue(config, 'gravityX', 0), + setGravityY: GetFastValue(config, 'gravityY', 0), + setFrictionX: GetFastValue(config, 'frictionX', 0), + setFrictionY: GetFastValue(config, 'frictionY', 0), + setVelocityX: GetFastValue(config, 'velocityX', 0), + setVelocityY: GetFastValue(config, 'velocityY', 0), + setAngularVelocity: GetFastValue(config, 'angularVelocity', 0), + setAngularAcceleration: GetFastValue(config, 'angularAcceleration', 0), + setAngularDrag: GetFastValue(config, 'angularDrag', 0), + setMass: GetFastValue(config, 'mass', 1), + setImmovable: GetFastValue(config, 'immovable', false) + }; + + Group.call(this, scene, children, config); + }, + + /** + * Enables a Game Object's Body and assigns `defaults`. Called when a Group member is added or created. + * + * @method Phaser.Physics.Arcade.Group#createCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object being added. + */ + createCallbackHandler: function (child) + { + if (!child.body) + { + this.world.enableBody(child, CONST.DYNAMIC_BODY); + } + + var body = child.body; + + for (var key in this.defaults) + { + body[key](this.defaults[key]); + } + }, + + /** + * Disables a Game Object's Body. Called when a Group member is removed. + * + * @method Phaser.Physics.Arcade.Group#removeCallbackHandler + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object being removed. + */ + removeCallbackHandler: function (child) + { + if (child.body) + { + this.world.disableBody(child); + } + }, + + /** + * Sets the velocity of each Group member. + * + * @method Phaser.Physics.Arcade.Group#setVelocity + * @since 3.0.0 + * + * @param {number} x - The horizontal velocity. + * @param {number} y - The vertical velocity. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x, y), the second (x + step, y + step), and so on. + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocity: function (x, y, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.set(x + (i * step), y + (i * step)); + } + + return this; + }, + + /** + * Sets the horizontal velocity of each Group member. + * + * @method Phaser.Physics.Arcade.Group#setVelocityX + * @since 3.0.0 + * + * @param {number} value - The velocity value. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x), the second (x + step), and so on. + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityX: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.x = value + (i * step); + } + + return this; + }, + + /** + * Sets the vertical velocity of each Group member. + * + * @method Phaser.Physics.Arcade.Group#setVelocityY + * @since 3.0.0 + * + * @param {number} value - The velocity value. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (y), the second (y + step), and so on. + * + * @return {Phaser.Physics.Arcade.Group} This Physics Group object. + */ + setVelocityY: function (value, step) + { + if (step === undefined) { step = 0; } + + var items = this.getChildren(); + + for (var i = 0; i < items.length; i++) + { + items[i].body.velocity.y = value + (i * step); + } + + return this; + } + +}); + +module.exports = PhysicsGroup; + + +/***/ }), +/* 236 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Arcade.Components + */ + +module.exports = { + + Acceleration: __webpack_require__(526), + Angular: __webpack_require__(525), + Bounce: __webpack_require__(524), + Debug: __webpack_require__(523), + Drag: __webpack_require__(522), + Enable: __webpack_require__(521), + Friction: __webpack_require__(520), + Gravity: __webpack_require__(519), + Immovable: __webpack_require__(518), + Mass: __webpack_require__(517), + Size: __webpack_require__(516), + Velocity: __webpack_require__(515) + +}; + + +/***/ }), +/* 237 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(236); +var Image = __webpack_require__(87); + +/** + * @classdesc + * An Arcade Physics Image Game Object. + * + * An Image is a light-weight Game Object useful for the display of static images in your game, + * such as logos, backgrounds, scenery or other non-animated elements. Images can have input + * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an + * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * + * @class Image + * @extends Phaser.GameObjects.Image + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Arcade.Components.Acceleration + * @extends Phaser.Physics.Arcade.Components.Angular + * @extends Phaser.Physics.Arcade.Components.Bounce + * @extends Phaser.Physics.Arcade.Components.Debug + * @extends Phaser.Physics.Arcade.Components.Drag + * @extends Phaser.Physics.Arcade.Components.Enable + * @extends Phaser.Physics.Arcade.Components.Friction + * @extends Phaser.Physics.Arcade.Components.Gravity + * @extends Phaser.Physics.Arcade.Components.Immovable + * @extends Phaser.Physics.Arcade.Components.Mass + * @extends Phaser.Physics.Arcade.Components.Size + * @extends Phaser.Physics.Arcade.Components.Velocity + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var ArcadeImage = new Class({ + + Extends: Image, + + Mixins: [ + Components.Acceleration, + Components.Angular, + Components.Bounce, + Components.Debug, + Components.Drag, + Components.Enable, + Components.Friction, + Components.Gravity, + Components.Immovable, + Components.Mass, + Components.Size, + Components.Velocity + ], + + initialize: + + function ArcadeImage (scene, x, y, texture, frame) + { + Image.call(this, scene, x, y, texture, frame); + + /** + * This Game Object's Physics Body. + * + * @name Phaser.Physics.Arcade.Image#body + * @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} + * @default null + * @since 3.0.0 + */ + this.body = null; + } + +}); + +module.exports = ArcadeImage; + + +/***/ }), +/* 238 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcadeImage = __webpack_require__(237); +var ArcadeSprite = __webpack_require__(104); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(35); +var PhysicsGroup = __webpack_require__(235); +var StaticPhysicsGroup = __webpack_require__(234); + +/** + * @classdesc + * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. + * Objects that are created by this Factory are automatically added to the physics world. + * + * @class Factory + * @memberof Phaser.Physics.Arcade + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics World instance. + */ +var Factory = new Class({ + + initialize: + + function Factory (world) + { + /** + * A reference to the Arcade Physics World. + * + * @name Phaser.Physics.Arcade.Factory#world + * @type {Phaser.Physics.Arcade.World} + * @since 3.0.0 + */ + this.world = world; + + /** + * A reference to the Scene this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = world.scene; + + /** + * A reference to the Scene.Systems this Arcade Physics instance belongs to. + * + * @name Phaser.Physics.Arcade.Factory#sys + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ + this.sys = world.scene.sys; + }, + + /** + * Create a new Arcade Physics Collider object. + * + * @method Phaser.Physics.Arcade.Factory#collider + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for collision. + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + collider: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addCollider(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Create a new Arcade Physics Collider Overlap object. + * + * @method Phaser.Physics.Arcade.Factory#overlap + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for overlap. + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for overlap. + * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. + * @param {*} [callbackContext] - The scope in which to call the callbacks. + * + * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. + */ + overlap: function (object1, object2, collideCallback, processCallback, callbackContext) + { + return this.world.addOverlap(object1, object2, collideCallback, processCallback, callbackContext); + }, + + /** + * Adds an Arcade Physics Body to the given Game Object. + * + * @method Phaser.Physics.Arcade.Factory#existing + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - A Game Object. + * @param {boolean} [isStatic=false] - Create a Static body (true) or Dynamic body (false). + * + * @return {Phaser.GameObjects.GameObject} The Game Object. + */ + existing: function (gameObject, isStatic) + { + var type = (isStatic) ? CONST.STATIC_BODY : CONST.DYNAMIC_BODY; + + this.world.enableBody(gameObject, type); + + return gameObject; + }, + + /** + * Creates a new Arcade Image object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticImage + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + staticImage: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.STATIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Image object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#image + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Image} The Image object that was created. + */ + image: function (x, y, key, frame) + { + var image = new ArcadeImage(this.scene, x, y, key, frame); + + this.sys.displayList.add(image); + + this.world.enableBody(image, CONST.DYNAMIC_BODY); + + return image; + }, + + /** + * Creates a new Arcade Sprite object with a Static body. + * + * @method Phaser.Physics.Arcade.Factory#staticSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + staticSprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.STATIC_BODY); + + return sprite; + }, + + /** + * Creates a new Arcade Sprite object with a Dynamic body. + * + * @method Phaser.Physics.Arcade.Factory#sprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. + */ + sprite: function (x, y, key, frame) + { + var sprite = new ArcadeSprite(this.scene, x, y, key, frame); + + this.sys.displayList.add(sprite); + this.sys.updateList.add(sprite); + + this.world.enableBody(sprite, CONST.DYNAMIC_BODY); + + return sprite; + }, + + /** + * Creates a Static Physics Group object. + * All Game Objects created by this Group will automatically be static Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#staticGroup + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. + * + * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. + */ + staticGroup: function (children, config) + { + return this.sys.updateList.add(new StaticPhysicsGroup(this.world, this.world.scene, children, config)); + }, + + /** + * Creates a Physics Group object. + * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * + * @method Phaser.Physics.Arcade.Factory#group + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group. + * + * @return {Phaser.Physics.Arcade.Group} The Group object that was created. + */ + 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; + } + +}); + +module.exports = Factory; + + +/***/ }), +/* 239 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(138); +var Matrix3 = __webpack_require__(241); + +var EPSILON = 0.000001; + +// Some shared 'private' arrays +var siNext = new Int8Array([ 1, 2, 0 ]); +var tmp = new Float32Array([ 0, 0, 0 ]); + +var xUnitVec3 = new Vector3(1, 0, 0); +var yUnitVec3 = new Vector3(0, 1, 0); + +var tmpvec = new Vector3(); +var tmpMat3 = new Matrix3(); + +/** + * @classdesc + * A quaternion. + * + * @class Quaternion + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + * @param {number} [w] - The w component. + */ +var Quaternion = new Class({ + + initialize: + + function Quaternion (x, y, z, w) + { + /** + * The x component of this Quaternion. + * + * @name Phaser.Math.Quaternion#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The y component of this Quaternion. + * + * @name Phaser.Math.Quaternion#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The z component of this Quaternion. + * + * @name Phaser.Math.Quaternion#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The w component of this Quaternion. + * + * @name Phaser.Math.Quaternion#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * Copy the components of a given Quaternion or Vector into this Quaternion. + * + * @method Phaser.Math.Quaternion#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} src - The Quaternion or Vector to copy the components from. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z; + this.w = src.w; + + return this; + }, + + /** + * Set the components of this Quaternion. + * + * @method Phaser.Math.Quaternion#set + * @since 3.0.0 + * + * @param {(number|object)} [x=0] - The x component, or an object containing x, y, z, and w components. + * @param {number} [y=0] - The y component. + * @param {number} [z=0] - The z component. + * @param {number} [w=0] - The w component. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * Add a given Quaternion or Vector to this Quaternion. Addition is component-wise. + * + * @method Phaser.Math.Quaternion#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to add to this Quaternion. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z; + this.w += v.w; + + return this; + }, + + /** + * Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise. + * + * @method Phaser.Math.Quaternion#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to subtract from this Quaternion. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + this.w -= v.w; + + return this; + }, + + /** + * Scale this Quaternion by the given value. + * + * @method Phaser.Math.Quaternion#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Quaternion by. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * Calculate the length of this Quaternion. + * + * @method Phaser.Math.Quaternion#length + * @since 3.0.0 + * + * @return {number} The length of this Quaternion. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * Calculate the length of this Quaternion squared. + * + * @method Phaser.Math.Quaternion#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Quaternion, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * Normalize this Quaternion. + * + * @method Phaser.Math.Quaternion#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Quaternion and the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#dot + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to dot product with this Quaternion. + * + * @return {number} The dot product of this Quaternion and the given Quaternion or Vector. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * Linearly interpolate this Quaternion towards the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#lerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to interpolate towards. + * @param {number} [t=0] - The percentage of interpolation. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotationTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - [description] + * @param {Phaser.Math.Vector3} b - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotationTo: function (a, b) + { + var dot = a.x * b.x + a.y * b.y + a.z * b.z; + + if (dot < -0.999999) + { + if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) + { + tmpvec.copy(yUnitVec3).cross(a); + } + + tmpvec.normalize(); + + return this.setAxisAngle(tmpvec, Math.PI); + + } + else if (dot > 0.999999) + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + } + else + { + tmpvec.copy(a).cross(b); + + this.x = tmpvec.x; + this.y = tmpvec.y; + this.z = tmpvec.z; + this.w = 1 + dot; + + return this.normalize(); + } + }, + + /** + * Set the axes of this Quaternion. + * + * @method Phaser.Math.Quaternion#setAxes + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} view - The view axis. + * @param {Phaser.Math.Vector3} right - The right axis. + * @param {Phaser.Math.Vector3} up - The upwards axis. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + setAxes: function (view, right, up) + { + var m = tmpMat3.val; + + m[0] = right.x; + m[3] = right.y; + m[6] = right.z; + + m[1] = up.x; + m[4] = up.y; + m[7] = up.z; + + m[2] = -view.x; + m[5] = -view.y; + m[8] = -view.z; + + return this.fromMat3(tmpMat3).normalize(); + }, + + /** + * Reset this Matrix to an identity (default) Quaternion. + * + * @method Phaser.Math.Quaternion#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + identity: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + }, + + /** + * Set the axis angle of this Quaternion. + * + * @method Phaser.Math.Quaternion#setAxisAngle + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} axis - The axis. + * @param {number} rad - The angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + setAxisAngle: function (axis, rad) + { + rad = rad * 0.5; + + var s = Math.sin(rad); + + this.x = s * axis.x; + this.y = s * axis.y; + this.z = s * axis.z; + this.w = Math.cos(rad); + + return this; + }, + + /** + * Multiply this Quaternion by the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to multiply this Quaternion by. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + multiply: function (b) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + this.x = ax * bw + aw * bx + ay * bz - az * by; + this.y = ay * bw + aw * by + az * bx - ax * bz; + this.z = az * bw + aw * bz + ax * by - ay * bx; + this.w = aw * bw - ax * bx - ay * by - az * bz; + + return this; + }, + + /** + * Smoothly linearly interpolate this Quaternion towards the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#slerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to interpolate towards. + * @param {number} t - The percentage of interpolation. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + slerp: function (b, t) + { + // benchmarks: http://jsperf.com/quaternion-slerp-implementations + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + // calc cosine + var cosom = ax * bx + ay * by + az * bz + aw * bw; + + // adjust signs (if necessary) + if (cosom < 0) + { + cosom = -cosom; + bx = - bx; + by = - by; + bz = - bz; + bw = - bw; + } + + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + var scale0 = 1 - t; + var scale1 = t; + + // calculate coefficients + if ((1 - cosom) > EPSILON) + { + // standard case (slerp) + var omega = Math.acos(cosom); + var sinom = Math.sin(omega); + + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } + + // calculate final values + this.x = scale0 * ax + scale1 * bx; + this.y = scale0 * ay + scale1 * by; + this.z = scale0 * az + scale1 * bz; + this.w = scale0 * aw + scale1 * bw; + + return this; + }, + + /** + * Invert this Quaternion. + * + * @method Phaser.Math.Quaternion#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + invert: function () + { + var a0 = this.x; + var a1 = this.y; + var a2 = this.z; + var a3 = this.w; + + var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + var invDot = (dot) ? 1 / dot : 0; + + // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + + this.x = -a0 * invDot; + this.y = -a1 * invDot; + this.z = -a2 * invDot; + this.w = a3 * invDot; + + return this; + }, + + /** + * Convert this Quaternion into its conjugate. + * + * Sets the x, y and z components. + * + * @method Phaser.Math.Quaternion#conjugate + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + conjugate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * Rotate this Quaternion on the X axis. + * + * @method Phaser.Math.Quaternion#rotateX + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateX: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + aw * bx; + this.y = ay * bw + az * bx; + this.z = az * bw - ay * bx; + this.w = aw * bw - ax * bx; + + return this; + }, + + /** + * Rotate this Quaternion on the Y axis. + * + * @method Phaser.Math.Quaternion#rotateY + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateY: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var by = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw - az * by; + this.y = ay * bw + aw * by; + this.z = az * bw + ax * by; + this.w = aw * bw - ay * by; + + return this; + }, + + /** + * Rotate this Quaternion on the Z axis. + * + * @method Phaser.Math.Quaternion#rotateZ + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateZ: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bz = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + ay * bz; + this.y = ay * bw - ax * bz; + this.z = az * bw + aw * bz; + this.w = aw * bw - az * bz; + + return this; + }, + + /** + * Create a unit (or rotation) Quaternion from its x, y, and z components. + * + * Sets the w component. + * + * @method Phaser.Math.Quaternion#calculateW + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + calculateW: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + this.w = -Math.sqrt(1.0 - x * x - y * y - z * z); + + return this; + }, + + /** + * Convert the given Matrix into this Quaternion. + * + * @method Phaser.Math.Quaternion#fromMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix to convert from. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + fromMat3: function (mat) + { + // benchmarks: + // http://jsperf.com/typed-array-access-speed + // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion + + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + var m = mat.val; + var fTrace = m[0] + m[4] + m[8]; + var fRoot; + + if (fTrace > 0) + { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + + this.w = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; // 1/(4w) + + this.x = (m[7] - m[5]) * fRoot; + this.y = (m[2] - m[6]) * fRoot; + this.z = (m[3] - m[1]) * fRoot; + } + else + { + // |w| <= 1/2 + var i = 0; + + if (m[4] > m[0]) + { + i = 1; + } + + if (m[8] > m[i * 3 + i]) + { + i = 2; + } + + var j = siNext[i]; + var k = siNext[j]; + + // This isn't quite as clean without array access + fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); + tmp[i] = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; + + tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; + tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; + + this.x = tmp[0]; + this.y = tmp[1]; + this.z = tmp[2]; + this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; + } + + return this; + } + +}); + +module.exports = Quaternion; + + +/***/ }), +/* 240 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +var EPSILON = 0.000001; + +/** + * @classdesc + * A four-dimensional matrix. + * + * @class Matrix4 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} [m] - Optional Matrix4 to copy values from. + */ +var Matrix4 = new Class({ + + initialize: + + function Matrix4 (m) + { + /** + * The matrix values. + * + * @name Phaser.Math.Matrix4#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(16); + + if (m) + { + // Assume Matrix4 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * Make a clone of this Matrix4. + * + * @method Phaser.Math.Matrix4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} A clone of this Matrix4. + */ + clone: function () + { + return new Matrix4(this); + }, + + // TODO - Should work with basic values + + /** + * This method is an alias for `Matrix4.copy`. + * + * @method Phaser.Math.Matrix4#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to set the values of this Matrix's from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * Copy the values of a given Matrix into this Matrix. + * + * @method Phaser.Math.Matrix4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Set the values of this Matrix from the given array. + * + * @method Phaser.Math.Matrix4#fromArray + * @since 3.0.0 + * + * @param {array} a - The array to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Reset this Matrix. + * + * Sets all values to `0`. + * + * @method Phaser.Math.Matrix4#zero + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + zero: function () + { + var out = this.val; + + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 0; + + return this; + }, + + /** + * Set the `x`, `y` and `z` values of this Matrix. + * + * @method Phaser.Math.Matrix4#xyz + * @since 3.0.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * @param {number} z - The z value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + xyz: function (x, y, z) + { + this.identity(); + + var out = this.val; + + out[12] = x; + out[13] = y; + out[14] = z; + + return this; + }, + + /** + * Set the scaling values of this Matrix. + * + * @method Phaser.Math.Matrix4#scaling + * @since 3.0.0 + * + * @param {number} x - The x scaling value. + * @param {number} y - The y scaling value. + * @param {number} z - The z scaling value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scaling: function (x, y, z) + { + this.zero(); + + var out = this.val; + + out[0] = x; + out[5] = y; + out[10] = z; + out[15] = 1; + + return this; + }, + + /** + * Reset this Matrix to an identity (default) matrix. + * + * @method Phaser.Math.Matrix4#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Transpose this Matrix. + * + * @method Phaser.Math.Matrix4#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + transpose: function () + { + var a = this.val; + + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a12 = a[6]; + var a13 = a[7]; + var a23 = a[11]; + + a[1] = a[4]; + a[2] = a[8]; + a[3] = a[12]; + a[4] = a01; + a[6] = a[9]; + a[7] = a[13]; + a[8] = a02; + a[9] = a12; + a[11] = a[14]; + a[12] = a03; + a[13] = a13; + a[14] = a23; + + return this; + }, + + /** + * Invert this Matrix. + * + * @method Phaser.Math.Matrix4#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return this; + }, + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + * + * @method Phaser.Math.Matrix4#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); + a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); + a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); + a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); + a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); + a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); + a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); + a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); + + return this; + }, + + /** + * Calculate the determinant of this Matrix. + * + * @method Phaser.Math.Matrix4#determinant + * @since 3.0.0 + * + * @return {number} The determinant of this Matrix. + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * @method Phaser.Math.Matrix4#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to multiply this Matrix by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b = src.val; + + // Cache only the current line of the second matrix + var b0 = b[0]; + var b1 = b[1]; + var b2 = b[2]; + var b3 = b[3]; + + a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + + a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + + a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + + a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#multiplyLocal + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiplyLocal: function (src) + { + var a = []; + var m1 = this.val; + var m2 = src.val; + + a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; + a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; + a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; + a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; + + a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; + a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; + a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; + a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; + + a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; + a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; + a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; + a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; + + a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; + a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; + a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; + a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; + + return this.fromArray(a); + }, + + /** + * Translate this Matrix using the given Vector. + * + * @method Phaser.Math.Matrix4#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + translate: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix. + * + * @method Phaser.Math.Matrix4#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scale: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[0] = a[0] * x; + a[1] = a[1] * x; + a[2] = a[2] * x; + a[3] = a[3] * x; + + a[4] = a[4] * y; + a[5] = a[5] * y; + a[6] = a[6] * y; + a[7] = a[7] * y; + + a[8] = a[8] * z; + a[9] = a[9] * z; + a[10] = a[10] * z; + a[11] = a[11] * z; + + return this; + }, + + /** + * Derive a rotation matrix around the given axis. + * + * @method Phaser.Math.Matrix4#makeRotationAxis + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis. + * @param {number} angle - The rotation angle in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + makeRotationAxis: function (axis, angle) + { + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + var c = Math.cos(angle); + var s = Math.sin(angle); + var t = 1 - c; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var tx = t * x; + var ty = t * y; + + this.fromArray([ + tx * x + c, tx * y - s * z, tx * z + s * y, 0, + tx * y + s * z, ty * y + c, ty * z - s * x, 0, + tx * z - s * y, ty * z + s * x, t * z * z + c, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + /** + * Apply a rotation transformation to this Matrix. + * + * @method Phaser.Math.Matrix4#rotate + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * @param {Phaser.Math.Vector3} axis - The axis to rotate upon. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotate: function (rad, axis) + { + var a = this.val; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var len = Math.sqrt(x * x + y * y + z * z); + + if (Math.abs(len) < EPSILON) + { + return null; + } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + var s = Math.sin(rad); + var c = Math.cos(rad); + var t = 1 - c; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Construct the elements of the rotation matrix + var b00 = x * x * t + c; + var b01 = y * x * t + z * s; + var b02 = z * x * t - y * s; + + var b10 = x * y * t - z * s; + var b11 = y * y * t + c; + var b12 = z * y * t + x * s; + + var b20 = x * z * t + y * s; + var b21 = y * z * t - x * s; + var b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + a[0] = a00 * b00 + a10 * b01 + a20 * b02; + a[1] = a01 * b00 + a11 * b01 + a21 * b02; + a[2] = a02 * b00 + a12 * b01 + a22 * b02; + a[3] = a03 * b00 + a13 * b01 + a23 * b02; + a[4] = a00 * b10 + a10 * b11 + a20 * b12; + a[5] = a01 * b10 + a11 * b11 + a21 * b12; + a[6] = a02 * b10 + a12 * b11 + a22 * b12; + a[7] = a03 * b10 + a13 * b11 + a23 * b12; + a[8] = a00 * b20 + a10 * b21 + a20 * b22; + a[9] = a01 * b20 + a11 * b21 + a21 * b22; + a[10] = a02 * b20 + a12 * b21 + a22 * b22; + a[11] = a03 * b20 + a13 * b21 + a23 * b22; + + return this; + }, + + /** + * Rotate this matrix on its X axis. + * + * @method Phaser.Math.Matrix4#rotateX + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateX: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[4] = a10 * c + a20 * s; + a[5] = a11 * c + a21 * s; + a[6] = a12 * c + a22 * s; + a[7] = a13 * c + a23 * s; + a[8] = a20 * c - a10 * s; + a[9] = a21 * c - a11 * s; + a[10] = a22 * c - a12 * s; + a[11] = a23 * c - a13 * s; + + return this; + }, + + /** + * Rotate this matrix on its Y axis. + * + * @method Phaser.Math.Matrix4#rotateY + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateY: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c - a20 * s; + a[1] = a01 * c - a21 * s; + a[2] = a02 * c - a22 * s; + a[3] = a03 * c - a23 * s; + a[8] = a00 * s + a20 * c; + a[9] = a01 * s + a21 * c; + a[10] = a02 * s + a22 * c; + a[11] = a03 * s + a23 * c; + + return this; + }, + + /** + * Rotate this matrix on its Z axis. + * + * @method Phaser.Math.Matrix4#rotateZ + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateZ: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c + a10 * s; + a[1] = a01 * c + a11 * s; + a[2] = a02 * c + a12 * s; + a[3] = a03 * c + a13 * s; + a[4] = a10 * c - a00 * s; + a[5] = a11 * c - a01 * s; + a[6] = a12 * c - a02 * s; + a[7] = a13 * c - a03 * s; + + return this; + }, + + /** + * Set the values of this Matrix from the given rotation Quaternion and translation Vector. + * + * @method Phaser.Math.Matrix4#fromRotationTranslation + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set rotation from. + * @param {Phaser.Math.Vector3} v - The Vector to set translation from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromRotationTranslation: function (q, v) + { + // Quaternion math + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = v.x; + out[13] = v.y; + out[14] = v.z; + out[15] = 1; + + return this; + }, + + /** + * Set the values of this Matrix from the given Quaternion. + * + * @method Phaser.Math.Matrix4#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromQuat: function (q) + { + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Generate a frustum matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#frustum + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + frustum: function (left, right, bottom, top, near, far) + { + var out = this.val; + + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + + out[0] = (near * 2) * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (near * 2) * tb; + out[6] = 0; + out[7] = 0; + + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (far * near * 2) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspective + * @since 3.0.0 + * + * @param {number} fovy - Vertical field of view in radians + * @param {number} aspect - Aspect ratio. Typically viewport width /height. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspective: function (fovy, aspect, near, far) + { + var out = this.val; + var f = 1.0 / Math.tan(fovy / 2); + var nf = 1 / (near - far); + + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspectiveLH + * @since 3.0.0 + * + * @param {number} width - The width of the frustum. + * @param {number} height - The height of the frustum. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspectiveLH: function (width, height, near, far) + { + var out = this.val; + + out[0] = (2 * near) / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (2 * near) / height; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = -far / (near - far); + out[11] = 1; + + out[12] = 0; + out[13] = 0; + out[14] = (near * far) / (near - far); + out[15] = 0; + + return this; + }, + + /** + * Generate an orthogonal projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#ortho + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + ortho: function (left, right, bottom, top, near, far) + { + var out = this.val; + var lr = left - right; + var bt = bottom - top; + var nf = near - far; + + // Avoid division by zero + lr = (lr === 0) ? lr : 1 / lr; + bt = (bt === 0) ? bt : 1 / bt; + nf = (nf === 0) ? nf : 1 / nf; + + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; + + return this; + }, + + /** + * Generate a look-at matrix with the given eye position, focal point, and up axis. + * + * @method Phaser.Math.Matrix4#lookAt + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} eye - Position of the viewer + * @param {Phaser.Math.Vector3} center - Point the viewer is looking at + * @param {Phaser.Math.Vector3} up - vec3 pointing up. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + lookAt: function (eye, center, up) + { + var out = this.val; + + var eyex = eye.x; + var eyey = eye.y; + var eyez = eye.z; + + var upx = up.x; + var upy = up.y; + var upz = up.z; + + var centerx = center.x; + var centery = center.y; + var centerz = center.z; + + if (Math.abs(eyex - centerx) < EPSILON && + Math.abs(eyey - centery) < EPSILON && + Math.abs(eyez - centerz) < EPSILON) + { + return this.identity(); + } + + var z0 = eyex - centerx; + var z1 = eyey - centery; + var z2 = eyez - centerz; + + var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + + z0 *= len; + z1 *= len; + z2 *= len; + + var x0 = upy * z2 - upz * z1; + var x1 = upz * z0 - upx * z2; + var x2 = upx * z1 - upy * z0; + + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + + if (!len) + { + x0 = 0; + x1 = 0; + x2 = 0; + } + else + { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + var y0 = z1 * x2 - z2 * x1; + var y1 = z2 * x0 - z0 * x2; + var y2 = z0 * x1 - z1 * x0; + + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + + if (!len) + { + y0 = 0; + y1 = 0; + y2 = 0; + } + else + { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + + return this; + }, + + /** + * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values. + * + * @method Phaser.Math.Matrix4#yawPitchRoll + * @since 3.0.0 + * + * @param {number} yaw - [description] + * @param {number} pitch - [description] + * @param {number} roll - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + yawPitchRoll: function (yaw, pitch, roll) + { + this.zero(); + _tempMat1.zero(); + _tempMat2.zero(); + + var m0 = this.val; + var m1 = _tempMat1.val; + var m2 = _tempMat2.val; + + // Rotate Z + var s = Math.sin(roll); + var c = Math.cos(roll); + + m0[10] = 1; + m0[15] = 1; + m0[0] = c; + m0[1] = s; + m0[4] = -s; + m0[5] = c; + + // Rotate X + s = Math.sin(pitch); + c = Math.cos(pitch); + + m1[0] = 1; + m1[15] = 1; + m1[5] = c; + m1[10] = c; + m1[9] = -s; + m1[6] = s; + + // Rotate Y + s = Math.sin(yaw); + c = Math.cos(yaw); + + m2[5] = 1; + m2[15] = 1; + m2[0] = c; + m2[2] = -s; + m2[8] = s; + m2[10] = c; + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + return this; + }, + + /** + * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix. + * + * @method Phaser.Math.Matrix4#setWorldMatrix + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} rotation - The rotation of the world matrix. + * @param {Phaser.Math.Vector3} position - The position of the world matrix. + * @param {Phaser.Math.Vector3} scale - The scale of the world matrix. + * @param {Phaser.Math.Matrix4} [viewMatrix] - The view matrix. + * @param {Phaser.Math.Matrix4} [projectionMatrix] - The projection matrix. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) + { + this.yawPitchRoll(rotation.y, rotation.x, rotation.z); + + _tempMat1.scaling(scale.x, scale.y, scale.z); + _tempMat2.xyz(position.x, position.y, position.z); + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + if (viewMatrix !== undefined) + { + this.multiplyLocal(viewMatrix); + } + + if (projectionMatrix !== undefined) + { + this.multiplyLocal(projectionMatrix); + } + + return this; + } + +}); + +var _tempMat1 = new Matrix4(); +var _tempMat2 = new Matrix4(); + +module.exports = Matrix4; + + +/***/ }), +/* 241 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A three-dimensional matrix. + * + * Defaults to the identity matrix when instantiated. + * + * @class Matrix3 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} [m] - Optional Matrix3 to copy values from. + */ +var Matrix3 = new Class({ + + initialize: + + function Matrix3 (m) + { + /** + * The matrix values. + * + * @name Phaser.Math.Matrix3#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(9); + + if (m) + { + // Assume Matrix3 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * Make a clone of this Matrix3. + * + * @method Phaser.Math.Matrix3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} A clone of this Matrix3. + */ + clone: function () + { + return new Matrix3(this); + }, + + /** + * This method is an alias for `Matrix3.copy`. + * + * @method Phaser.Math.Matrix3#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to set the values of this Matrix's from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * Copy the values of a given Matrix into this Matrix. + * + * @method Phaser.Math.Matrix3#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * Copy the values of a given Matrix4 into this Matrix3. + * + * @method Phaser.Math.Matrix3#fromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - The Matrix4 to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromMat4: function (m) + { + var a = m.val; + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; + + return this; + }, + + /** + * Set the values of this Matrix from the given array. + * + * @method Phaser.Math.Matrix3#fromArray + * @since 3.0.0 + * + * @param {array} a - The array to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * Reset this Matrix to an identity (default) matrix. + * + * @method Phaser.Math.Matrix3#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + + return this; + }, + + /** + * Transpose this Matrix. + * + * @method Phaser.Math.Matrix3#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + transpose: function () + { + var a = this.val; + var a01 = a[1]; + var a02 = a[2]; + var a12 = a[5]; + + a[1] = a[3]; + a[2] = a[6]; + a[3] = a01; + a[5] = a[7]; + a[6] = a02; + a[7] = a12; + + return this; + }, + + /** + * Invert this Matrix. + * + * @method Phaser.Math.Matrix3#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b01 = a22 * a11 - a12 * a21; + var b11 = -a22 * a10 + a12 * a20; + var b21 = a21 * a10 - a11 * a20; + + // Calculate the determinant + var det = a00 * b01 + a01 * b11 + a02 * b21; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = b01 * det; + a[1] = (-a22 * a01 + a02 * a21) * det; + a[2] = (a12 * a01 - a02 * a11) * det; + a[3] = b11 * det; + a[4] = (a22 * a00 - a02 * a20) * det; + a[5] = (-a12 * a00 + a02 * a10) * det; + a[6] = b21 * det; + a[7] = (-a21 * a00 + a01 * a20) * det; + a[8] = (a11 * a00 - a01 * a10) * det; + + return this; + }, + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + * + * @method Phaser.Math.Matrix3#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + a[0] = (a11 * a22 - a12 * a21); + a[1] = (a02 * a21 - a01 * a22); + a[2] = (a01 * a12 - a02 * a11); + a[3] = (a12 * a20 - a10 * a22); + a[4] = (a00 * a22 - a02 * a20); + a[5] = (a02 * a10 - a00 * a12); + a[6] = (a10 * a21 - a11 * a20); + a[7] = (a01 * a20 - a00 * a21); + a[8] = (a00 * a11 - a01 * a10); + + return this; + }, + + /** + * Calculate the determinant of this Matrix. + * + * @method Phaser.Math.Matrix3#determinant + * @since 3.0.0 + * + * @return {number} The determinant of this Matrix. + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * @method Phaser.Math.Matrix3#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to multiply this Matrix by. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b = src.val; + + var b00 = b[0]; + var b01 = b[1]; + var b02 = b[2]; + var b10 = b[3]; + var b11 = b[4]; + var b12 = b[5]; + var b20 = b[6]; + var b21 = b[7]; + var b22 = b[8]; + + a[0] = b00 * a00 + b01 * a10 + b02 * a20; + a[1] = b00 * a01 + b01 * a11 + b02 * a21; + a[2] = b00 * a02 + b01 * a12 + b02 * a22; + + a[3] = b10 * a00 + b11 * a10 + b12 * a20; + a[4] = b10 * a01 + b11 * a11 + b12 * a21; + a[5] = b10 * a02 + b11 * a12 + b12 * a22; + + a[6] = b20 * a00 + b21 * a10 + b22 * a20; + a[7] = b20 * a01 + b21 * a11 + b22 * a21; + a[8] = b20 * a02 + b21 * a12 + b22 * a22; + + return this; + }, + + /** + * Translate this Matrix using the given Vector. + * + * @method Phaser.Math.Matrix3#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + translate: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[6] = x * a[0] + y * a[3] + a[6]; + a[7] = x * a[1] + y * a[4] + a[7]; + a[8] = x * a[2] + y * a[5] + a[8]; + + return this; + }, + + /** + * Apply a rotation transformation to this Matrix. + * + * @method Phaser.Math.Matrix3#rotate + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + rotate: function (rad) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + + var s = Math.sin(rad); + var c = Math.cos(rad); + + a[0] = c * a00 + s * a10; + a[1] = c * a01 + s * a11; + a[2] = c * a02 + s * a12; + + a[3] = c * a10 - s * a00; + a[4] = c * a11 - s * a01; + a[5] = c * a12 - s * a02; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x` and `y` components of the given Vector to scale the Matrix. + * + * @method Phaser.Math.Matrix3#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + scale: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[0] = x * a[0]; + a[1] = x * a[1]; + a[2] = x * a[2]; + + a[3] = y * a[3]; + a[4] = y * a[4]; + a[5] = y * a[5]; + + return this; + }, + + /** + * Set the values of this Matrix from the given Quaternion. + * + * @method Phaser.Math.Matrix3#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromQuat: function (q) + { + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + var out = this.val; + + out[0] = 1 - (yy + zz); + out[3] = xy + wz; + out[6] = xz - wy; + + out[1] = xy - wz; + out[4] = 1 - (xx + zz); + out[7] = yz + wx; + + out[2] = xz + wy; + out[5] = yz - wx; + out[8] = 1 - (xx + yy); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#normalFromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + normalFromMat4: function (m) + { + var a = m.val; + var out = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + + return this; + } + +}); + +module.exports = Matrix3; + + +/***/ }), +/* 242 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rotate a given point by a given angle around the origin (0, 0), in an anti-clockwise direction. + * + * @function Phaser.Math.Rotate + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. + * @param {number} angle - The angle to be rotated by in an anticlockwise direction. + * + * @return {Phaser.Geom.Point} The given point, rotated by the given angle in an anticlockwise direction. + */ +var Rotate = function (point, angle) +{ + var x = point.x; + var y = point.y; + + point.x = (x * Math.cos(angle)) - (y * Math.sin(angle)); + point.y = (x * Math.sin(angle)) + (y * Math.cos(angle)); + + return point; +}; + +module.exports = Rotate; + + +/***/ }), +/* 243 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Snap a value to nearest grid slice, using ceil. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `15`. + * As will `14` snap to `15`... but `16` will snap to `20`. + * + * @function Phaser.Math.Snap.Ceil + * @since 3.0.0 + * + * @param {number} value - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. + * + * @return {number} The snapped value. + */ +var SnapCeil = function (value, gap, start, divide) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.ceil(value / gap); + + return (divide) ? (start + value) / gap : start + value; +}; + +module.exports = SnapCeil; + + +/***/ }), +/* 244 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the factorial of a given number for integer values greater than 0. + * + * @function Phaser.Math.Factorial + * @since 3.0.0 + * + * @param {number} value - A positive integer to calculate the factorial of. + * + * @return {number} The factorial of the given number. + */ +var Factorial = function (value) +{ + if (value === 0) + { + return 1; + } + + var res = value; + + while (--value) + { + res *= value; + } + + return res; +}; + +module.exports = Factorial; + + +/***/ }), +/* 245 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Factorial = __webpack_require__(244); + +/** + * [description] + * + * @function Phaser.Math.Bernstein + * @since 3.0.0 + * + * @param {number} n - [description] + * @param {number} i - [description] + * + * @return {number} [description] + */ +var Bernstein = function (n, i) +{ + return Factorial(n) / Factorial(i) / Factorial(n - i); +}; + +module.exports = Bernstein; + + +/***/ }), +/* 246 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check whether `a` is fuzzily less than `b`. + * + * `a` is fuzzily less than `b` if it is less than `b + epsilon`. + * + * @function Phaser.Math.Fuzzy.LessThan + * @since 3.0.0 + * + * @param {number} a - The first value. + * @param {number} b - The second value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {boolean} `true` if `a` is fuzzily less than `b`, otherwise `false`. + */ +var LessThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a < b + epsilon; +}; + +module.exports = LessThan; + + +/***/ }), +/* 247 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check whether `a` is fuzzily greater than `b`. + * + * `a` is fuzzily greater than `b` if it is more than `b - epsilon`. + * + * @function Phaser.Math.Fuzzy.GreaterThan + * @since 3.0.0 + * + * @param {number} a - The first value. + * @param {number} b - The second value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {boolean} `true` if `a` is fuzzily greater than than `b`, otherwise `false`. + */ +var GreaterThan = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return a > b - epsilon; +}; + +module.exports = GreaterThan; + + +/***/ }), +/* 248 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check whether the given values are fuzzily equal. + * + * Two numbers are fuzzily equal if their difference is less than `epsilon`. + * + * @function Phaser.Math.Fuzzy.Equal + * @since 3.0.0 + * + * @param {number} a - The first value. + * @param {number} b - The second value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {boolean} `true` if the values are fuzzily equal, otherwise `false`. + */ +var Equal = function (a, b, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.abs(a - b) < epsilon; +}; + +module.exports = Equal; + + +/***/ }), +/* 249 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the distance between two sets of coordinates (points), squared. + * + * @function Phaser.Math.Distance.Squared + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The distance between each point, squared. + */ +var DistanceSquared = function (x1, y1, x2, y2) +{ + var dx = x1 - x2; + var dy = y1 - y2; + + return dx * dx + dy * dy; +}; + +module.exports = DistanceSquared; + + +/***/ }), +/* 250 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Normalize an angle to the [0, 2pi] range. + * + * @function Phaser.Math.Angle.Normalize + * @since 3.0.0 + * + * @param {number} angle - The angle to normalize, in radians. + * + * @return {number} The normalized angle, in radians. + */ +var Normalize = function (angle) +{ + angle = angle % (2 * Math.PI); + + if (angle >= 0) + { + return angle; + } + else + { + return angle + 2 * Math.PI; + } +}; + +module.exports = Normalize; + + +/***/ }), +/* 251 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TextFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='txt'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Text File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. + * + * @class TextFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TextFile = new Class({ + + Extends: File, + + initialize: + + function TextFile (loader, key, url, xhrSettings) + { + var extension = 'txt'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'text', + cache: loader.cacheManager.text, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.TextFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Text file, or array of Text files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.text('story', 'files/IntroStory.txt'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Text Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Text Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.text({ + * key: 'story', + * url: 'files/IntroStory.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.text('story', 'files/IntroStory.txt'); + * // and later in your game ... + * var data = this.cache.text.get('story'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Text Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.txt". It will always add `.txt` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Text File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#text + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig|Phaser.Loader.FileTypes.TextFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('text', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TextFile(this, key[i])); + } + } + else + { + this.addFile(new TextFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TextFile; + + +/***/ }), +/* 252 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var File = __webpack_require__(21); +var GetFastValue = __webpack_require__(2); +var GetURL = __webpack_require__(141); var IsPlainObject = __webpack_require__(8); /** @@ -37948,7 +65042,7 @@ var IsPlainObject = __webpack_require__(8); * * @class HTML5AudioFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -38119,7 +65213,7 @@ module.exports = HTML5AudioFile; /***/ }), -/* 168 */ +/* 253 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -38129,11 +65223,11 @@ module.exports = HTML5AudioFile; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var File = __webpack_require__(19); +var CONST = __webpack_require__(26); +var File = __webpack_require__(21); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var HTML5AudioFile = __webpack_require__(167); +var GetFastValue = __webpack_require__(2); +var HTML5AudioFile = __webpack_require__(252); var IsPlainObject = __webpack_require__(8); /** @@ -38155,7 +65249,7 @@ var IsPlainObject = __webpack_require__(8); * * @class AudioFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -38221,7 +65315,7 @@ var AudioFile = new Class({ function (e) { // eslint-disable-next-line no-console - console.error('Error decoding audio: ' + this.key + ' - ', e.message); + console.error('Error decoding audio: ' + this.key + ' - ', e ? e.message : null); _this.onProcessError(); } @@ -38399,7 +65493,7 @@ module.exports = AudioFile; /***/ }), -/* 169 */ +/* 254 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -38408,7 +65502,7 @@ module.exports = AudioFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MergeXHRSettings = __webpack_require__(107); +var MergeXHRSettings = __webpack_require__(140); /** * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings @@ -38467,7 +65561,7 @@ module.exports = XHRLoader; /***/ }), -/* 170 */ +/* 255 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -38477,9 +65571,9 @@ module.exports = XHRLoader; */ var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); -var ProcessKeyCombo = __webpack_require__(372); -var ResetKeyCombo = __webpack_require__(370); +var GetFastValue = __webpack_require__(2); +var ProcessKeyCombo = __webpack_require__(605); +var ResetKeyCombo = __webpack_require__(603); /** * @callback KeyboardKeydownCallback @@ -38507,11 +65601,11 @@ var ResetKeyCombo = __webpack_require__(370); * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); @@ -38525,7 +65619,7 @@ var ResetKeyCombo = __webpack_require__(370); * ``` * * @class KeyCombo - * @memberOf Phaser.Input.Keyboard + * @memberof Phaser.Input.Keyboard * @constructor * @since 3.0.0 * @@ -38738,7 +65832,7 @@ var KeyCombo = new Class({ * * @name Phaser.Input.Keyboard.KeyCombo#progress * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ progress: { @@ -38772,7 +65866,7 @@ module.exports = KeyCombo; /***/ }), -/* 171 */ +/* 256 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -38789,7 +65883,7 @@ var Class = __webpack_require__(0); * keycode must be an integer * * @class Key - * @memberOf Phaser.Input.Keyboard + * @memberof Phaser.Input.Keyboard * @constructor * @since 3.0.0 * @@ -38910,9 +66004,7 @@ var Key = new Class({ this.timeDown = 0; /** - * The number of milliseconds this key has been held down for. - * If the key is down this value holds the duration of that key press and is constantly updated. - * If the key is up it holds the duration of the previous down session. + * The number of milliseconds this key was held down for in the previous down - up sequence. * * @name Phaser.Input.Keyboard.Key#duration * @type {number} @@ -38962,6 +66054,16 @@ var Key = new Class({ * @since 3.0.0 */ this._justUp = false; + + /** + * Internal tick counter. + * + * @name Phaser.Input.Keyboard.Key#_tick + * @type {number} + * @private + * @since 3.11.0 + */ + this._tick = -1; }, /** @@ -38987,6 +66089,7 @@ var Key = new Class({ this.repeats = 0; this._justDown = false; this._justUp = false; + this._tick = -1; return this; } @@ -38997,7 +66100,7 @@ module.exports = Key; /***/ }), -/* 172 */ +/* 257 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -39006,11 +66109,11 @@ module.exports = Key; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Axis = __webpack_require__(174); -var Button = __webpack_require__(173); +var Axis = __webpack_require__(259); +var Button = __webpack_require__(258); var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Vector2 = __webpack_require__(6); +var EventEmitter = __webpack_require__(11); +var Vector2 = __webpack_require__(3); /** * @classdesc @@ -39020,7 +66123,7 @@ var Vector2 = __webpack_require__(6); * * @class Gamepad * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.0.0 * @@ -39755,7 +66858,7 @@ module.exports = Gamepad; /***/ }), -/* 173 */ +/* 258 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -39772,7 +66875,7 @@ var Class = __webpack_require__(0); * Button objects are created automatically by the Gamepad as they are needed. * * @class Button - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.0.0 * @@ -39816,7 +66919,7 @@ var Button = new Class({ * Between 0 and 1. * * @name Phaser.Input.Gamepad.Button#value - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -39827,7 +66930,7 @@ var Button = new Class({ * before a button is considered as being 'pressed'. * * @name Phaser.Input.Gamepad.Button#threshold - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -39896,7 +66999,7 @@ module.exports = Button; /***/ }), -/* 174 */ +/* 259 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -39913,7 +67016,7 @@ var Class = __webpack_require__(0); * Axis objects are created automatically by the Gamepad as they are needed. * * @class Axis - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.0.0 * @@ -39958,7 +67061,7 @@ var Axis = new Class({ * Use the method `getValue` to get a normalized value with the threshold applied. * * @name Phaser.Input.Gamepad.Axis#value - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -39968,7 +67071,7 @@ var Axis = new Class({ * Movement tolerance threshold below which axis values are ignored in `getValue`. * * @name Phaser.Input.Gamepad.Axis#threshold - * @type {float} + * @type {number} * @default 0.1 * @since 3.0.0 */ @@ -39983,7 +67086,7 @@ var Axis = new Class({ * @private * @since 3.0.0 * - * @param {float} value - The value of the axis movement. + * @param {number} value - The value of the axis movement. */ update: function (value) { @@ -39996,7 +67099,7 @@ var Axis = new Class({ * @method Phaser.Input.Gamepad.Axis#getValue * @since 3.0.0 * - * @return {float} The axis value, adjusted for the movement threshold. + * @return {number} The axis value, adjusted for the movement threshold. */ getValue: function () { @@ -40021,7 +67124,7 @@ module.exports = Axis; /***/ }), -/* 175 */ +/* 260 */ /***/ (function(module, exports) { /** @@ -40117,7 +67220,7 @@ module.exports = CreateInteractiveObject; /***/ }), -/* 176 */ +/* 261 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40126,8 +67229,8019 @@ module.exports = CreateInteractiveObject; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Commands = __webpack_require__(119); -var GameObject = __webpack_require__(2); +var Point = __webpack_require__(6); + +// The three angle bisectors of a triangle meet in one point called the incenter. +// It is the center of the incircle, the circle inscribed in the triangle. + +function getLength (x1, y1, x2, y2) +{ + var x = x1 - x2; + var y = y1 - y2; + var magnitude = (x * x) + (y * y); + + return Math.sqrt(magnitude); +} + +/** + * [description] + * + * @function Phaser.Geom.Triangle.InCenter + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var InCenter = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = triangle.x1; + var y1 = triangle.y1; + + var x2 = triangle.x2; + var y2 = triangle.y2; + + var x3 = triangle.x3; + var y3 = triangle.y3; + + var d1 = getLength(x3, y3, x2, y2); + var d2 = getLength(x1, y1, x3, y3); + var d3 = getLength(x2, y2, x1, y1); + + var p = d1 + d2 + d3; + + out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; + out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; + + return out; +}; + +module.exports = InCenter; + + +/***/ }), +/* 262 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Offset = function (triangle, x, y) +{ + triangle.x1 += x; + triangle.y1 += y; + + triangle.x2 += x; + triangle.y2 += y; + + triangle.x3 += x; + triangle.y3 += y; + + return triangle; +}; + +module.exports = Offset; + + +/***/ }), +/* 263 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) +// meet in the centroid or center of mass (center of gravity). +// The centroid divides each median in a ratio of 2:1 + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Centroid + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Centroid = function (triangle, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; + out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; + + return out; +}; + +module.exports = Centroid; + + +/***/ }), +/* 264 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Checks if rectB is fully contained within rectA + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var ContainsRect = function (rectA, rectB) +{ + // Volume check (if rectB volume > rectA then rectA cannot contain it) + if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) + { + return false; + } + + return ( + (rectB.x > rectA.x && rectB.x < rectA.right) && + (rectB.right > rectA.x && rectB.right < rectA.right) && + (rectB.y > rectA.y && rectB.y < rectA.bottom) && + (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 265 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +Rectangle.Area = __webpack_require__(656); +Rectangle.Ceil = __webpack_require__(655); +Rectangle.CeilAll = __webpack_require__(654); +Rectangle.CenterOn = __webpack_require__(175); +Rectangle.Clone = __webpack_require__(653); +Rectangle.Contains = __webpack_require__(39); +Rectangle.ContainsPoint = __webpack_require__(652); +Rectangle.ContainsRect = __webpack_require__(264); +Rectangle.CopyFrom = __webpack_require__(651); +Rectangle.Decompose = __webpack_require__(270); +Rectangle.Equals = __webpack_require__(650); +Rectangle.FitInside = __webpack_require__(649); +Rectangle.FitOutside = __webpack_require__(648); +Rectangle.Floor = __webpack_require__(647); +Rectangle.FloorAll = __webpack_require__(646); +Rectangle.FromPoints = __webpack_require__(173); +Rectangle.GetAspectRatio = __webpack_require__(145); +Rectangle.GetCenter = __webpack_require__(645); +Rectangle.GetPoint = __webpack_require__(190); +Rectangle.GetPoints = __webpack_require__(398); +Rectangle.GetSize = __webpack_require__(644); +Rectangle.Inflate = __webpack_require__(643); +Rectangle.Intersection = __webpack_require__(642); +Rectangle.MarchingAnts = __webpack_require__(388); +Rectangle.MergePoints = __webpack_require__(641); +Rectangle.MergeRect = __webpack_require__(640); +Rectangle.MergeXY = __webpack_require__(639); +Rectangle.Offset = __webpack_require__(638); +Rectangle.OffsetPoint = __webpack_require__(637); +Rectangle.Overlaps = __webpack_require__(636); +Rectangle.Perimeter = __webpack_require__(124); +Rectangle.PerimeterPoint = __webpack_require__(635); +Rectangle.Random = __webpack_require__(187); +Rectangle.RandomOutside = __webpack_require__(634); +Rectangle.SameDimensions = __webpack_require__(633); +Rectangle.Scale = __webpack_require__(632); +Rectangle.Union = __webpack_require__(309); + +module.exports = Rectangle; + + +/***/ }), +/* 266 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitudeSq + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitudeSq = function (point) +{ + return (point.x * point.x) + (point.y * point.y); +}; + +module.exports = GetMagnitudeSq; + + +/***/ }), +/* 267 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Point.GetMagnitude + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * + * @return {number} [description] + */ +var GetMagnitude = function (point) +{ + return Math.sqrt((point.x * point.x) + (point.y * point.y)); +}; + +module.exports = GetMagnitude; + + +/***/ }), +/* 268 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Wrap = __webpack_require__(53); +var Angle = __webpack_require__(68); + +/** + * Get the angle of the normal of the given line in radians. + * + * @function Phaser.Geom.Line.NormalAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the angle of the normal of. + * + * @return {number} The angle of the normal of the line in radians. + */ +var NormalAngle = function (line) +{ + var angle = Angle(line) - MATH_CONST.TAU; + + return Wrap(angle, -Math.PI, Math.PI); +}; + +module.exports = NormalAngle; + + +/***/ }), +/* 269 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {array} [out] - [description] + * + * @return {array} [description] + */ +var Decompose = function (triangle, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: triangle.x1, y: triangle.y1 }); + out.push({ x: triangle.x2, y: triangle.y2 }); + out.push({ x: triangle.x3, y: triangle.y3 }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 270 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Create an array of points for each corner of a Rectangle + * If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created. + * + * @function Phaser.Geom.Rectangle.Decompose + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object to be decomposed. + * @param {array} [out] - If provided, each point will be added to this array. + * + * @return {array} Will return the array you specified or a new array containing the points of the Rectangle. + */ +var Decompose = function (rect, out) +{ + if (out === undefined) { out = []; } + + out.push({ x: rect.x, y: rect.y }); + out.push({ x: rect.right, y: rect.y }); + out.push({ x: rect.right, y: rect.bottom }); + out.push({ x: rect.x, y: rect.bottom }); + + return out; +}; + +module.exports = Decompose; + + +/***/ }), +/* 271 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Intersects.PointToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Line} line - [description] + * + * @return {boolean} [description] + */ +var PointToLine = function (point, line) +{ + return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); +}; + +module.exports = PointToLine; + + +/***/ }), +/* 272 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on code by Matt DesLauriers +// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md + +var Contains = __webpack_require__(40); +var Point = __webpack_require__(6); + +var tmp = new Point(); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.LineToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Point} [nearest] - [description] + * + * @return {boolean} [description] + */ +var LineToCircle = function (line, circle, nearest) +{ + if (nearest === undefined) { nearest = tmp; } + + if (Contains(circle, line.x1, line.y1)) + { + nearest.x = line.x1; + nearest.y = line.y1; + + return true; + } + + if (Contains(circle, line.x2, line.y2)) + { + nearest.x = line.x2; + nearest.y = line.y2; + + return true; + } + + var dx = line.x2 - line.x1; + var dy = line.y2 - line.y1; + + var lcx = circle.x - line.x1; + var lcy = circle.y - line.y1; + + // project lc onto d, resulting in vector p + var dLen2 = (dx * dx) + (dy * dy); + var px = dx; + var py = dy; + + if (dLen2 > 0) + { + var dp = ((lcx * dx) + (lcy * dy)) / dLen2; + + px *= dp; + py *= dp; + } + + nearest.x = line.x1 + px; + nearest.y = line.y1 + py; + + // len2 of p + var pLen2 = (px * px) + (py * py); + + return ( + pLen2 <= dLen2 && + ((px * dx) + (py * dy)) >= 0 && + Contains(circle, nearest.x, nearest.y) + ); +}; + +module.exports = LineToCircle; + + +/***/ }), +/* 273 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom.Intersects + */ + +module.exports = { + + CircleToCircle: __webpack_require__(703), + CircleToRectangle: __webpack_require__(702), + GetRectangleIntersection: __webpack_require__(701), + LineToCircle: __webpack_require__(272), + LineToLine: __webpack_require__(107), + LineToRectangle: __webpack_require__(700), + PointToLine: __webpack_require__(271), + PointToLineSegment: __webpack_require__(699), + RectangleToRectangle: __webpack_require__(148), + RectangleToTriangle: __webpack_require__(698), + RectangleToValues: __webpack_require__(697), + TriangleToCircle: __webpack_require__(696), + TriangleToLine: __webpack_require__(695), + TriangleToTriangle: __webpack_require__(694) + +}; + + +/***/ }), +/* 274 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Geom + */ + +module.exports = { + + Circle: __webpack_require__(723), + Ellipse: __webpack_require__(713), + Intersects: __webpack_require__(273), + Line: __webpack_require__(693), + Point: __webpack_require__(675), + Polygon: __webpack_require__(661), + Rectangle: __webpack_require__(265), + Triangle: __webpack_require__(631) + +}; + + +/***/ }), +/* 275 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Light = __webpack_require__(276); +var Utils = __webpack_require__(10); + +/** + * @callback LightForEach + * + * @param {Phaser.GameObjects.Light} light - The Light. + */ + +/** + * @classdesc + * Manages Lights for a Scene. + * + * Affects the rendering of Game Objects using the `Light2D` pipeline. + * + * @class LightsManager + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + */ +var LightsManager = new Class({ + + initialize: + + function LightsManager () + { + /** + * The pool of Lights. + * + * Used to recycle removed Lights for a more efficient use of memory. + * + * @name Phaser.GameObjects.LightsManager#lightPool + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lightPool = []; + + /** + * The Lights in the Scene. + * + * @name Phaser.GameObjects.LightsManager#lights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.lights = []; + + /** + * Lights that have been culled from a Camera's viewport. + * + * Lights in this list will not be rendered. + * + * @name Phaser.GameObjects.LightsManager#culledLights + * @type {Phaser.GameObjects.Light[]} + * @default [] + * @since 3.0.0 + */ + this.culledLights = []; + + /** + * The ambient color. + * + * @name Phaser.GameObjects.LightsManager#ambientColor + * @type {{ r: number, g: number, b: number }} + * @since 3.0.0 + */ + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + + /** + * Whether the Lights Manager is enabled. + * + * @name Phaser.GameObjects.LightsManager#active + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.active = false; + + /** + * The maximum number of lights that a single Camera and the lights shader can process. + * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. + * + * @name Phaser.GameObjects.LightsManager#maxLights + * @type {integer} + * @readonly + * @since 3.15.0 + */ + this.maxLights = -1; + }, + + /** + * Enable the Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#enable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + enable: function () + { + if (this.maxLights === -1) + { + this.maxLights = this.scene.sys.game.renderer.config.maxLights; + } + + this.active = true; + + return this; + }, + + /** + * Disable the Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#disable + * @since 3.0.0 + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + disable: function () + { + this.active = false; + + return this; + }, + + /** + * Cull any Lights that aren't visible to the given Camera. + * + * Culling Lights improves performance by ensuring that only Lights within a Camera's viewport are rendered. + * + * @method Phaser.GameObjects.LightsManager#cull + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to cull Lights for. + * + * @return {Phaser.GameObjects.Light[]} The culled Lights. + */ + cull: function (camera) + { + var lights = this.lights; + var culledLights = this.culledLights; + var length = lights.length; + var cameraCenterX = camera.x + camera.width / 2.0; + var cameraCenterY = camera.y + camera.height / 2.0; + var cameraRadius = (camera.width + camera.height) / 2.0; + var point = { x: 0, y: 0 }; + var cameraMatrix = camera.matrix; + var viewportHeight = this.systems.game.config.height; + + culledLights.length = 0; + + for (var index = 0; index < length && culledLights.length < this.maxLights; index++) + { + var light = lights[index]; + + cameraMatrix.transformPoint(light.x, light.y, point); + + // We'll just use bounding spheres to test if lights should be rendered + var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); + var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + var distance = Math.sqrt(dx * dx + dy * dy); + + if (distance < light.radius + cameraRadius) + { + culledLights.push(lights[index]); + } + } + + return culledLights; + }, + + /** + * Iterate over each Light with a callback. + * + * @method Phaser.GameObjects.LightsManager#forEachLight + * @since 3.0.0 + * + * @param {LightForEach} callback - The callback that is called with each Light. + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + forEachLight: function (callback) + { + if (!callback) + { + return; + } + + var lights = this.lights; + var length = lights.length; + + for (var index = 0; index < length; ++index) + { + callback(lights[index]); + } + + return this; + }, + + /** + * Set the ambient light color. + * + * @method Phaser.GameObjects.LightsManager#setAmbientColor + * @since 3.0.0 + * + * @param {number} rgb - The integer RGB color of the ambient light. + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + setAmbientColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.ambientColor.r = color[0]; + this.ambientColor.g = color[1]; + this.ambientColor.b = color[2]; + + return this; + }, + + /** + * Returns the maximum number of Lights allowed to appear at once. + * + * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights + * @since 3.0.0 + * + * @return {integer} The maximum number of Lights allowed to appear at once. + */ + getMaxVisibleLights: function () + { + return 10; + }, + + /** + * Get the number of Lights managed by this Lights Manager. + * + * @method Phaser.GameObjects.LightsManager#getLightCount + * @since 3.0.0 + * + * @return {integer} The number of Lights managed by this Lights Manager. + */ + getLightCount: function () + { + return this.lights.length; + }, + + /** + * Add a Light. + * + * @method Phaser.GameObjects.LightsManager#addLight + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal position of the Light. + * @param {number} [y=0] - The vertical position of the Light. + * @param {number} [radius=100] - The radius of the Light. + * @param {number} [rgb=0xffffff] - The integer RGB color of the light. + * @param {number} [intensity=1] - The intensity of the Light. + * + * @return {Phaser.GameObjects.Light} The Light that was added. + */ + addLight: function (x, y, radius, rgb, intensity) + { + var color = null; + var light = null; + + x = (x === undefined) ? 0.0 : x; + y = (y === undefined) ? 0.0 : y; + rgb = (rgb === undefined) ? 0xffffff : rgb; + radius = (radius === undefined) ? 100.0 : radius; + intensity = (intensity === undefined) ? 1.0 : intensity; + + color = Utils.getFloatsFromUintRGB(rgb); + light = null; + + if (this.lightPool.length > 0) + { + light = this.lightPool.pop(); + light.set(x, y, radius, color[0], color[1], color[2], intensity); + } + else + { + light = new Light(x, y, radius, color[0], color[1], color[2], intensity); + } + + this.lights.push(light); + + return light; + }, + + /** + * Remove a Light. + * + * @method Phaser.GameObjects.LightsManager#removeLight + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Light} light - The Light to remove. + * + * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. + */ + removeLight: function (light) + { + var index = this.lights.indexOf(light); + + if (index >= 0) + { + this.lightPool.push(light); + this.lights.splice(index, 1); + } + + return this; + }, + + /** + * Shut down the Lights Manager. + * + * Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and + * culled Lights. + * + * @method Phaser.GameObjects.LightsManager#shutdown + * @since 3.0.0 + */ + shutdown: function () + { + while (this.lights.length > 0) + { + this.lightPool.push(this.lights.pop()); + } + + this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; + this.culledLights.length = 0; + this.lights.length = 0; + }, + + /** + * Destroy the Lights Manager. + * + * Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}. + * + * @method Phaser.GameObjects.LightsManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + } + +}); + +module.exports = LightsManager; + + +/***/ }), +/* 276 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Utils = __webpack_require__(10); + +/** + * @classdesc + * A 2D point light. + * + * These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`. + * + * Any Game Objects using the Light2D pipeline will then be affected by these Lights. + * + * They can also simply be used to represent a point light for your own purposes. + * + * @class Light + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color of the light. A value between 0 and 1. + * @param {number} g - The green color of the light. A value between 0 and 1. + * @param {number} b - The blue color of the light. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + */ +var Light = new Class({ + + initialize: + + function Light (x, y, radius, r, g, b, intensity) + { + /** + * The horizontal position of the light. + * + * @name Phaser.GameObjects.Light#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The vertical position of the light. + * + * @name Phaser.GameObjects.Light#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The radius of the light. + * + * @name Phaser.GameObjects.Light#radius + * @type {number} + * @since 3.0.0 + */ + this.radius = radius; + + /** + * The red color of the light. A value between 0 and 1. + * + * @name Phaser.GameObjects.Light#r + * @type {number} + * @since 3.0.0 + */ + this.r = r; + + /** + * The green color of the light. A value between 0 and 1. + * + * @name Phaser.GameObjects.Light#g + * @type {number} + * @since 3.0.0 + */ + this.g = g; + + /** + * The blue color of the light. A value between 0 and 1. + * + * @name Phaser.GameObjects.Light#b + * @type {number} + * @since 3.0.0 + */ + this.b = b; + + /** + * The intensity of the light. + * + * @name Phaser.GameObjects.Light#intensity + * @type {number} + * @since 3.0.0 + */ + this.intensity = intensity; + + /** + * The horizontal scroll factor of the light. + * + * @name Phaser.GameObjects.Light#scrollFactorX + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorX = 1.0; + + /** + * The vertical scroll factor of the light. + * + * @name Phaser.GameObjects.Light#scrollFactorY + * @type {number} + * @since 3.0.0 + */ + this.scrollFactorY = 1.0; + }, + + /** + * Set the properties of the light. + * + * Sets both horizontal and vertical scroll factor to 1. Use {@link Phaser.GameObjects.Light#setScrollFactor} to set + * the scroll factor. + * + * @method Phaser.GameObjects.Light#set + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * @param {number} radius - The radius of the light. + * @param {number} r - The red color. A value between 0 and 1. + * @param {number} g - The green color. A value between 0 and 1. + * @param {number} b - The blue color. A value between 0 and 1. + * @param {number} intensity - The intensity of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + set: function (x, y, radius, r, g, b, intensity) + { + this.x = x; + this.y = y; + + this.radius = radius; + + this.r = r; + this.g = g; + this.b = b; + + this.intensity = intensity; + + this.scrollFactorX = 1; + this.scrollFactorY = 1; + + return this; + }, + + /** + * Set the scroll factor of the light. + * + * @method Phaser.GameObjects.Light#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of the light. + * @param {number} y - The vertical scroll factor of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setScrollFactor: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + }, + + /** + * Set the color of the light from a single integer RGB value. + * + * @method Phaser.GameObjects.Light#setColor + * @since 3.0.0 + * + * @param {number} rgb - The integer RGB color of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setColor: function (rgb) + { + var color = Utils.getFloatsFromUintRGB(rgb); + + this.r = color[0]; + this.g = color[1]; + this.b = color[2]; + + return this; + }, + + /** + * Set the intensity of the light. + * + * @method Phaser.GameObjects.Light#setIntensity + * @since 3.0.0 + * + * @param {number} intensity - The intensity of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setIntensity: function (intensity) + { + this.intensity = intensity; + + return this; + }, + + /** + * Set the position of the light. + * + * @method Phaser.GameObjects.Light#setPosition + * @since 3.0.0 + * + * @param {number} x - The horizontal position of the light. + * @param {number} y - The vertical position of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setPosition: function (x, y) + { + this.x = x; + this.y = y; + + return this; + }, + + /** + * Set the radius of the light. + * + * @method Phaser.GameObjects.Light#setRadius + * @since 3.0.0 + * + * @param {number} radius - The radius of the light. + * + * @return {Phaser.GameObjects.Light} This Light object. + */ + setRadius: function (radius) + { + this.radius = radius; + + return this; + } + +}); + +module.exports = Light; + + +/***/ }), +/* 277 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); +var Point = __webpack_require__(6); + +/** + * Returns an array of evenly spaced points on the perimeter of a Triangle. + * + * @function Phaser.Geom.Triangle.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the points from. + * @param {integer} quantity - The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. + * @param {number} stepRate - If `quantity` is 0, the distance between each returned point. + * @param {(array|Phaser.Geom.Point[])} [out] - An array to which the points should be appended. + * + * @return {(array|Phaser.Geom.Point[])} The modified `out` array, or a new array if none was provided. + */ +var GetPoints = function (triangle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var p = perimeter * (i / quantity); + var localPosition = 0; + + var point = new Point(); + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + out.push(point); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 278 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); +var Length = __webpack_require__(65); + +// Position is a value between 0 and 1 +/** + * [description] + * + * @function Phaser.Geom.Triangle.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} position - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetPoint = function (triangle, position, out) +{ + if (out === undefined) { out = new Point(); } + + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + if (position <= 0 || position >= 1) + { + out.x = line1.x1; + out.y = line1.y1; + + return out; + } + + var length1 = Length(line1); + var length2 = Length(line2); + var length3 = Length(line3); + + var perimeter = length1 + length2 + length3; + + var p = perimeter * position; + var localPosition = 0; + + // Which line is it on? + + if (p < length1) + { + // Line 1 + localPosition = p / length1; + + out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; + out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; + } + else if (p > length1 + length2) + { + // Line 3 + p -= length1 + length2; + localPosition = p / length3; + + out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; + out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; + } + else + { + // Line 2 + p -= length1; + localPosition = p / length2; + + out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; + out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 279 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Shape = __webpack_require__(27); +var GeomTriangle = __webpack_require__(59); +var TriangleRender = __webpack_require__(772); + +/** + * @classdesc + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @class Triangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Triangle = new Class({ + + Extends: Shape, + + Mixins: [ + TriangleRender + ], + + initialize: + + function Triangle (scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 128; } + if (x2 === undefined) { x2 = 64; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 128; } + if (y3 === undefined) { y3 = 128; } + + Shape.call(this, scene, 'Triangle', new GeomTriangle(x1, y1, x2, y2, x3, y3)); + + var width = this.geom.right - this.geom.left; + var height = this.geom.bottom - this.geom.top; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the data for the lines that make up this Triangle shape. + * + * @method Phaser.GameObjects.Triangle#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=0] - The vertical position of the first point in the triangle. + * @param {number} [x2=0] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=0] - The horizontal position of the third point in the triangle. + * @param {number} [y3=0] - The vertical position of the third point in the triangle. + * + * @return {this} This Game Object instance. + */ + setTo: function (x1, y1, x2, y2, x3, y3) + { + this.geom.setTo(x1, y1, x2, y2, x3, y3); + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Triangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var rect = this.geom; + var line = this._tempLine; + + rect.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + rect.getLineB(line); + + path.push(line.x2, line.y2); + + rect.getLineC(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + } + +}); + +module.exports = Triangle; + + +/***/ }), +/* 280 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StarRender = __webpack_require__(775); +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(64); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @class Star + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star. + * @param {number} [outerRadius=64] - The outer radius of the star. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Star = new Class({ + + Extends: Shape, + + Mixins: [ + StarRender + ], + + initialize: + + function Star (scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (points === undefined) { points = 5; } + if (innerRadius === undefined) { innerRadius = 32; } + if (outerRadius === undefined) { outerRadius = 64; } + + Shape.call(this, scene, 'Star', null); + + /** + * Private internal value. + * The number of points in the star. + * + * @name Phaser.GameObjects.Star#_points + * @type {integer} + * @private + * @since 3.13.0 + */ + this._points = points; + + /** + * Private internal value. + * The inner radius of the star. + * + * @name Phaser.GameObjects.Star#_innerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._innerRadius = innerRadius; + + /** + * Private internal value. + * The outer radius of the star. + * + * @name Phaser.GameObjects.Star#_outerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._outerRadius = outerRadius; + + this.setPosition(x, y); + this.setSize(outerRadius * 2, outerRadius * 2); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the number of points that make up the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setPoints + * @since 3.13.0 + * + * @param {integer} value - The amount of points the Star will have. + * + * @return {this} This Game Object instance. + */ + setPoints: function (value) + { + this._points = value; + + return this.updateData(); + }, + + /** + * Sets the inner radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setInnerRadius + * @since 3.13.0 + * + * @param {number} value - The amount to set the inner radius to. + * + * @return {this} This Game Object instance. + */ + setInnerRadius: function (value) + { + this._innerRadius = value; + + return this.updateData(); + }, + + /** + * Sets the outer radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setOuterRadius + * @since 3.13.0 + * + * @param {number} value - The amount to set the outer radius to. + * + * @return {this} This Game Object instance. + */ + setOuterRadius: function (value) + { + this._outerRadius = value; + + return this.updateData(); + }, + + /** + * The number of points that make up the Star shape. + * + * @name Phaser.GameObjects.Star#points + * @type {integer} + * @default 5 + * @since 3.13.0 + */ + points: { + + get: function () + { + return this._points; + }, + + set: function (value) + { + this._points = value; + + this.updateData(); + } + + }, + + /** + * The inner radius of the Star shape. + * + * @name Phaser.GameObjects.Star#innerRadius + * @type {number} + * @default 32 + * @since 3.13.0 + */ + innerRadius: { + + get: function () + { + return this._innerRadius; + }, + + set: function (value) + { + this._innerRadius = value; + + this.updateData(); + } + + }, + + /** + * The outer radius of the Star shape. + * + * @name Phaser.GameObjects.Star#outerRadius + * @type {number} + * @default 64 + * @since 3.13.0 + */ + outerRadius: { + + get: function () + { + return this._outerRadius; + }, + + set: function (value) + { + this._outerRadius = value; + + this.updateData(); + } + + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Star#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + + var points = this._points; + var innerRadius = this._innerRadius; + var outerRadius = this._outerRadius; + + var rot = Math.PI / 2 * 3; + var step = Math.PI / points; + + // So origin 0.5 = the center of the star + var x = outerRadius; + var y = outerRadius; + + path.push(x, y + -outerRadius); + + for (var i = 0; i < points; i++) + { + path.push(x + Math.cos(rot) * outerRadius, y + Math.sin(rot) * outerRadius); + + rot += step; + + path.push(x + Math.cos(rot) * innerRadius, y + Math.sin(rot) * innerRadius); + + rot += step; + } + + path.push(x, y + -outerRadius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Star; + + +/***/ }), +/* 281 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GeomRectangle = __webpack_require__(9); +var Shape = __webpack_require__(27); +var RectangleRender = __webpack_require__(778); + +/** + * @classdesc + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @class Rectangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Rectangle = new Class({ + + Extends: Shape, + + Mixins: [ + RectangleRender + ], + + initialize: + + function Rectangle (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Rectangle', new GeomRectangle(0, 0, width, height)); + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Rectangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var rect = this.geom; + var line = this._tempLine; + + rect.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + rect.getLineB(line); + + path.push(line.x2, line.y2); + + rect.getLineC(line); + + path.push(line.x2, line.y2); + + rect.getLineD(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + } + +}); + +module.exports = Rectangle; + + +/***/ }), +/* 282 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Igor Ognichenko + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var copy = function (out, a) +{ + out[0] = a[0]; + out[1] = a[1]; + + return out; +}; + +/** + * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. + * + * @function Phaser.Geom.Polygon.Smooth + * @since 3.13.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The polygon to be smoothed. The polygon will be modified in-place and returned. + * + * @return {Phaser.Geom.Polygon} The input polygon. + */ +var Smooth = function (polygon) +{ + var i; + var points = []; + var data = polygon.points; + + for (i = 0; i < data.length; i++) + { + points.push([ data[i].x, data[i].y ]); + } + + var output = []; + + if (points.length > 0) + { + output.push(copy([ 0, 0 ], points[0])); + } + + for (i = 0; i < points.length - 1; i++) + { + var p0 = points[i]; + var p1 = points[i + 1]; + var p0x = p0[0]; + var p0y = p0[1]; + var p1x = p1[0]; + var p1y = p1[1]; + + output.push([ 0.85 * p0x + 0.15 * p1x, 0.85 * p0y + 0.15 * p1y ]); + output.push([ 0.15 * p0x + 0.85 * p1x, 0.15 * p0y + 0.85 * p1y ]); + } + + if (points.length > 1) + { + output.push(copy([ 0, 0 ], points[points.length - 1])); + } + + return polygon.setTo(output); +}; + +module.exports = Smooth; + + +/***/ }), +/* 283 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); +var Line = __webpack_require__(54); + +/** + * Returns the perimeter of the given Polygon. + * + * @function Phaser.Geom.Polygon.Perimeter + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the perimeter of. + * + * @return {number} The perimeter of the Polygon. + */ +var Perimeter = function (polygon) +{ + var points = polygon.points; + var perimeter = 0; + + for (var i = 0; i < points.length; i++) + { + var pointA = points[i]; + var pointB = points[(i + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + + perimeter += Length(line); + } + + return perimeter; +}; + +module.exports = Perimeter; + + +/***/ }), +/* 284 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); +var Line = __webpack_require__(54); +var Perimeter = __webpack_require__(283); + +/** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Polygon.GetPoints + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the perimeter of the Polygon. + */ +var GetPoints = function (polygon, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var points = polygon.points; + var perimeter = Perimeter(polygon); + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var position = perimeter * (i / quantity); + var accumulatedPerimeter = 0; + + for (var j = 0; j < points.length; j++) + { + var pointA = points[j]; + var pointB = points[(j + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + var length = Length(line); + + if (position < accumulatedPerimeter || position > accumulatedPerimeter + length) + { + accumulatedPerimeter += length; + continue; + } + + var point = line.getPoint((position - accumulatedPerimeter) / length); + out.push(point); + + break; + } + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 285 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * [description] + * + * @function Phaser.Geom.Polygon.GetAABB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {(Phaser.Geom.Rectangle|object)} [out] - [description] + * + * @return {(Phaser.Geom.Rectangle|object)} [description] + */ +var GetAABB = function (polygon, out) +{ + if (out === undefined) { out = new Rectangle(); } + + var minX = Infinity; + var minY = Infinity; + var maxX = -minX; + var maxY = -minY; + var p; + + for (var i = 0; i < polygon.points.length; i++) + { + p = polygon.points[i]; + + minX = Math.min(minX, p.x); + minY = Math.min(minY, p.y); + maxX = Math.max(maxX, p.x); + maxY = Math.max(maxY, p.y); + } + + out.x = minX; + out.y = minY; + out.width = maxX - minX; + out.height = maxY - minY; + + return out; +}; + +module.exports = GetAABB; + + +/***/ }), +/* 286 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PolygonRender = __webpack_require__(781); +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(64); +var GetAABB = __webpack_require__(285); +var GeomPolygon = __webpack_require__(151); +var Shape = __webpack_require__(27); +var Smooth = __webpack_require__(282); + +/** + * @classdesc + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * @class Polygon + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Polygon = new Class({ + + Extends: Shape, + + Mixins: [ + PolygonRender + ], + + initialize: + + function Polygon (scene, x, y, points, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Polygon', new GeomPolygon(points)); + + var bounds = GetAABB(this.geom); + + this.setPosition(x, y); + this.setSize(bounds.width, bounds.height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Smooths the polygon over the number of iterations specified. + * The base polygon data will be updated and replaced with the smoothed values. + * This call can be chained. + * + * @method Phaser.GameObjects.Polygon#smooth + * @since 3.13.0 + * + * @param {integer} [iterations=1] - The number of times to apply the polygon smoothing. + * + * @return {this} This Game Object instance. + */ + smooth: function (iterations) + { + if (iterations === undefined) { iterations = 1; } + + for (var i = 0; i < iterations; i++) + { + Smooth(this.geom); + } + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Polygon#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.points; + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Polygon; + + +/***/ }), +/* 287 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Shape = __webpack_require__(27); +var GeomLine = __webpack_require__(54); +var LineRender = __webpack_require__(784); + +/** + * @classdesc + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * @class Line + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Line = new Class({ + + Extends: Shape, + + Mixins: [ + LineRender + ], + + initialize: + + function Line (scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 128; } + if (y2 === undefined) { y2 = 0; } + + Shape.call(this, scene, 'Line', new GeomLine(x1, y1, x2, y2)); + + var width = this.geom.right - this.geom.left; + var height = this.geom.bottom - this.geom.top; + + /** + * The width (or thickness) of the line. + * See the setLineWidth method for extra details on changing this on WebGL. + * + * @name Phaser.GameObjects.Line#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Private internal value. Holds the start width of the line. + * + * @name Phaser.GameObjects.Line#_startWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._startWidth = 1; + + /** + * Private internal value. Holds the end width of the line. + * + * @name Phaser.GameObjects.Line#_endWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._endWidth = 1; + + this.setPosition(x, y); + this.setSize(width, height); + + if (strokeColor !== undefined) + { + this.setStrokeStyle(1, strokeColor, strokeAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the width of the line. + * + * When using the WebGL renderer you can have different start and end widths. + * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Line#setLineWidth + * @since 3.13.0 + * + * @param {number} startWidth - The start width of the line. + * @param {number} [endWidth] - The end width of the line. Only used in WebGL. + * + * @return {this} This Game Object instance. + */ + setLineWidth: function (startWidth, endWidth) + { + if (endWidth === undefined) { endWidth = startWidth; } + + this._startWidth = startWidth; + this._endWidth = endWidth; + + this.lineWidth = startWidth; + + return this; + }, + + /** + * Sets the start and end coordinates of this Line. + * + * @method Phaser.GameObjects.Line#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=0] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * + * @return {this} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + this.geom.setTo(x1, y1, x2, y2); + + return this; + } + +}); + +module.exports = Line; + + +/***/ }), +/* 288 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var IsoTriangleRender = __webpack_require__(787); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @class IsoTriangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + */ +var IsoTriangle = new Class({ + + Extends: Shape, + + Mixins: [ + IsoTriangleRender + ], + + initialize: + + function IsoTriangle (scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (reversed === undefined) { reversed = false; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoTriangle', null); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * + * @name Phaser.GameObjects.IsoTriangle#projection + * @type {integer} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. + * + * @name Phaser.GameObjects.IsoTriangle#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls if the top-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls if the left-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls if the right-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + /** + * Sets if the iso triangle will be rendered upside down or not. + * + * @name Phaser.GameObjects.IsoTriangle#isReversed + * @type {boolean} + * @default false + * @since 3.13.0 + */ + this.isReversed = reversed; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setProjection + * @since 3.13.0 + * + * @param {integer} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets if the iso triangle will be rendered upside down or not. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setReversed + * @since 3.13.0 + * + * @param {boolean} reversed - Sets if the iso triangle will be rendered upside down or not. + * + * @return {this} This Game Object instance. + */ + setReversed: function (reversed) + { + this.isReversed = reversed; + + return this; + }, + + /** + * Sets which faces of the iso triangle will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso triangle (only if `reversed` is true) + * @param {boolean} [showLeft=true] - Show the left-face of the iso triangle. + * @param {boolean} [showRight=true] - Show the right-face of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso triangle. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso triangle. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso triangle. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoTriangle; + + +/***/ }), +/* 289 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsoBoxRender = __webpack_require__(790); +var Class = __webpack_require__(0); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * + * @class IsoBox + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + */ +var IsoBox = new Class({ + + Extends: Shape, + + Mixins: [ + IsoBoxRender + ], + + initialize: + + function IsoBox (scene, x, y, size, height, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoBox', null); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * + * @name Phaser.GameObjects.IsoBox#projection + * @type {integer} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls if the top-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls if the left-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls if the right-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setProjection + * @since 3.13.0 + * + * @param {integer} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets which faces of the iso box will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso box. + * @param {boolean} [showLeft=true] - Show the left-face of the iso box. + * @param {boolean} [showRight=true] - Show the right-face of the iso box. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso box. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso box. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso box. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoBox; + + +/***/ }), +/* 290 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Shape = __webpack_require__(27); +var GridRender = __webpack_require__(793); + +/** + * @classdesc + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @class Grid + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [outlineFillColor] - The color of the lines between the grid cells. See the `setOutline` method. + * @param {number} [outlineFillAlpha] - The alpha of the lines between the grid cells. + */ +var Grid = new Class({ + + Extends: Shape, + + Mixins: [ + GridRender + ], + + initialize: + + function Grid (scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + if (cellWidth === undefined) { cellWidth = 32; } + if (cellHeight === undefined) { cellHeight = 32; } + + Shape.call(this, scene, 'Grid', null); + + /** + * The width of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellWidth + * @type {number} + * @since 3.13.0 + */ + this.cellWidth = cellWidth; + + /** + * The height of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellHeight + * @type {number} + * @since 3.13.0 + */ + this.cellHeight = cellHeight; + + /** + * Will the grid render its cells in the `fillColor`? + * + * @name Phaser.GameObjects.Grid#showCells + * @type {boolean} + * @since 3.13.0 + */ + this.showCells = true; + + /** + * The color of the lines between each grid cell. + * + * @name Phaser.GameObjects.Grid#outlineFillColor + * @type {number} + * @since 3.13.0 + */ + this.outlineFillColor = 0; + + /** + * The alpha value for the color of the lines between each grid cell. + * + * @name Phaser.GameObjects.Grid#outlineFillAlpha + * @type {number} + * @since 3.13.0 + */ + this.outlineFillAlpha = 0; + + /** + * Will the grid display the lines between each cell when it renders? + * + * @name Phaser.GameObjects.Grid#showOutline + * @type {boolean} + * @since 3.13.0 + */ + this.showOutline = true; + + /** + * Will the grid render the alternating cells in the `altFillColor`? + * + * @name Phaser.GameObjects.Grid#showAltCells + * @type {boolean} + * @since 3.13.0 + */ + this.showAltCells = false; + + /** + * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * + * @name Phaser.GameObjects.Grid#altFillColor + * @type {number} + * @since 3.13.0 + */ + this.altFillColor; + + /** + * The alpha the alternating grid cells will be filled with. + * You can also set the alpha of the overall Shape using its `alpha` property. + * + * @name Phaser.GameObjects.Grid#altFillAlpha + * @type {number} + * @since 3.13.0 + */ + this.altFillAlpha; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + if (outlineFillColor !== undefined) + { + this.setOutlineStyle(outlineFillColor, outlineFillAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the fill color and alpha level the grid cells will use when rendering. + * + * If this method is called with no values then the grid cells will not be rendered, + * however the grid lines and alternating cells may still be. + * + * Also see the `setOutlineStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showCells = false; + } + else + { + this.fillColor = fillColor; + this.fillAlpha = fillAlpha; + this.showCells = true; + } + + return this; + }, + + /** + * Sets the fill color and alpha level that the alternating grid cells will use. + * + * If this method is called with no values then alternating grid cells will not be rendered in a different color. + * + * Also see the `setOutlineStyle` and `setFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setAltFillStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setAltFillStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showAltCells = false; + } + else + { + this.altFillColor = fillColor; + this.altFillAlpha = fillAlpha; + this.showAltCells = true; + } + + return this; + }, + + /** + * Sets the fill color and alpha level that the lines between each grid cell will use. + * + * If this method is called with no values then the grid lines will not be rendered at all, however + * the cells themselves may still be if they have colors set. + * + * Also see the `setFillStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setOutlineStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setOutlineStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showOutline = false; + } + else + { + this.outlineFillColor = fillColor; + this.outlineFillAlpha = fillAlpha; + this.showOutline = true; + } + + return this; + } + +}); + +module.exports = Grid; + + +/***/ }), +/* 291 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Earcut = __webpack_require__(64); +var EllipseRender = __webpack_require__(796); +var GeomEllipse = __webpack_require__(90); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @class Ellipse + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Ellipse = new Class({ + + Extends: Shape, + + Mixins: [ + EllipseRender + ], + + initialize: + + function Ellipse (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Ellipse', new GeomEllipse(width / 2, height / 2, width, height)); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Ellipse#_smoothness + * @type {integer} + * @private + * @since 3.13.0 + */ + this._smoothness = 64; + + this.setPosition(x, y); + + this.width = width; + this.height = height; + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Ellipse#smoothness + * @type {integer} + * @default 64 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSize + * @since 3.13.0 + * + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.geom.setSize(width, height); + + return this.updateData(); + }, + + /** + * Sets the smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSmoothness + * @since 3.13.0 + * + * @param {integer} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Ellipse#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.getPoints(this._smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Ellipse; + + +/***/ }), +/* 292 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CurveRender = __webpack_require__(799); +var Earcut = __webpack_require__(64); +var Rectangle = __webpack_require__(9); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @class Curve + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Curve = new Class({ + + Extends: Shape, + + Mixins: [ + CurveRender + ], + + initialize: + + function Curve (scene, x, y, curve, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Curve', curve); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Curve#_smoothness + * @type {integer} + * @private + * @since 3.13.0 + */ + this._smoothness = 32; + + /** + * Private internal value. + * The Curve bounds rectangle. + * + * @name Phaser.GameObjects.Curve#_curveBounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.13.0 + */ + this._curveBounds = new Rectangle(); + + this.closePath = false; + + this.setPosition(x, y); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateData(); + }, + + /** + * The smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Curve#smoothness + * @type {integer} + * @default 32 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Curve#setSmoothness + * @since 3.13.0 + * + * @param {integer} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Curve#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var bounds = this._curveBounds; + var smoothness = this._smoothness; + + // Update the bounds in case the underlying data has changed + this.geom.getBounds(bounds, smoothness); + + this.setSize(bounds.width, bounds.height); + this.updateDisplayOrigin(); + + var path = []; + var points = this.geom.getPoints(smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Curve; + + +/***/ }), +/* 293 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcRender = __webpack_require__(802); +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(31); +var Earcut = __webpack_require__(64); +var GeomCircle = __webpack_require__(71); +var MATH_CONST = __webpack_require__(16); +var Shape = __webpack_require__(27); + +/** + * @classdesc + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows + * you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. + * + * @class Arc + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [radius=128] - The radius of the arc. + * @param {integer} [startAngle=0] - The start angle of the arc, in degrees. + * @param {integer} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - The winding order of the start and end angles. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Arc = new Class({ + + Extends: Shape, + + Mixins: [ + ArcRender + ], + + initialize: + + function Arc (scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 128; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (anticlockwise === undefined) { anticlockwise = false; } + + Shape.call(this, scene, 'Arc', new GeomCircle(0, 0, radius)); + + /** + * Private internal value. Holds the start angle in degrees. + * + * @name Phaser.GameObjects.Arc#_startAngle + * @type {integer} + * @private + * @since 3.13.0 + */ + this._startAngle = startAngle; + + /** + * Private internal value. Holds the end angle in degrees. + * + * @name Phaser.GameObjects.Arc#_endAngle + * @type {integer} + * @private + * @since 3.13.0 + */ + this._endAngle = endAngle; + + /** + * Private internal value. Holds the winding order of the start and end angles. + * + * @name Phaser.GameObjects.Arc#_anticlockwise + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._anticlockwise = anticlockwise; + + /** + * Private internal value. Holds the number of iterations used when drawing the arc. + * + * @name Phaser.GameObjects.Arc#_iterations + * @type {number} + * @default 0.01 + * @private + * @since 3.13.0 + */ + this._iterations = 0.01; + + this.setPosition(x, y); + this.setSize(this.geom.radius, this.geom.radius); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * + * @name Phaser.GameObjects.Arc#iterations + * @type {number} + * @default 0.01 + * @since 3.13.0 + */ + iterations: { + + get: function () + { + return this._iterations; + }, + + set: function (value) + { + this._iterations = value; + + this.updateData(); + } + + }, + + /** + * The radius of the arc. + * + * @name Phaser.GameObjects.Arc#radius + * @type {number} + * @since 3.13.0 + */ + radius: { + + get: function () + { + return this.geom.radius; + }, + + set: function (value) + { + this.geom.radius = value; + + this.updateData(); + } + + }, + + /** + * The start angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#startAngle + * @type {integer} + * @since 3.13.0 + */ + startAngle: { + + get: function () + { + return this._startAngle; + }, + + set: function (value) + { + this._startAngle = value; + + this.updateData(); + } + + }, + + /** + * The end angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#endAngle + * @type {integer} + * @since 3.13.0 + */ + endAngle: { + + get: function () + { + return this._endAngle; + }, + + set: function (value) + { + this._endAngle = value; + + this.updateData(); + } + + }, + + /** + * The winding order of the start and end angles. + * + * @name Phaser.GameObjects.Arc#anticlockwise + * @type {boolean} + * @since 3.13.0 + */ + anticlockwise: { + + get: function () + { + return this._anticlockwise; + }, + + set: function (value) + { + this._anticlockwise = value; + + this.updateData(); + } + + }, + + /** + * Sets the radius of the arc. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setRadius + * @since 3.13.0 + * + * @param {number} value - The value to set the radius to. + * + * @return {this} This Game Object instance. + */ + setRadius: function (value) + { + this.radius = value; + + return this; + }, + + /** + * Sets the number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setIterations + * @since 3.13.0 + * + * @param {number} value - The value to set the iterations to. + * + * @return {this} This Game Object instance. + */ + setIterations: function (value) + { + if (value === undefined) { value = 0.01; } + + this.iterations = value; + + return this; + }, + + /** + * Sets the starting angle of the arc, in degrees. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setStartAngle + * @since 3.13.0 + * + * @param {integer} value - The value to set the starting angle to. + * + * @return {this} This Game Object instance. + */ + setStartAngle: function (angle, anticlockwise) + { + this._startAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Sets the ending angle of the arc, in degrees. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setEndAngle + * @since 3.13.0 + * + * @param {integer} value - The value to set the ending angle to. + * + * @return {this} This Game Object instance. + */ + setEndAngle: function (angle, anticlockwise) + { + this._endAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Arc#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var step = this._iterations; + var iteration = step; + + var radius = this.geom.radius; + var startAngle = DegToRad(this._startAngle); + var endAngle = DegToRad(this._endAngle); + var anticlockwise = this._anticlockwise; + + var x = radius / 2; + var y = radius / 2; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -MATH_CONST.PI2) + { + endAngle = -MATH_CONST.PI2; + } + else if (endAngle > 0) + { + endAngle = -MATH_CONST.PI2 + endAngle % MATH_CONST.PI2; + } + } + else if (endAngle > MATH_CONST.PI2) + { + endAngle = MATH_CONST.PI2; + } + else if (endAngle < 0) + { + endAngle = MATH_CONST.PI2 + endAngle % MATH_CONST.PI2; + } + + var path = [ x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius ]; + + var ta; + + while (iteration < 1) + { + ta = endAngle * iteration + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + iteration += step; + } + + ta = endAngle + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + path.push(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Arc; + + +/***/ }), +/* 294 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the nearest power of 2 to the given `value`. + * + * @function Phaser.Math.Pow2.GetPowerOfTwo + * @since 3.0.0 + * + * @param {number} value - The value. + * + * @return {integer} The nearest power of 2 to `value`. + */ +var GetPowerOfTwo = function (value) +{ + var index = Math.log(value) / 0.6931471805599453; + + return (1 << Math.ceil(index)); +}; + +module.exports = GetPowerOfTwo; + + +/***/ }), +/* 295 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Creates and returns an RFC4122 version 4 compliant UUID. + * + * The string is in the form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` where each `x` is replaced with a random + * hexadecimal digit from 0 to f, and `y` is replaced with a random hexadecimal digit from 8 to b. + * + * @function Phaser.Utils.String.UUID + * @since 3.12.0 + * + * @return {string} The UUID string. + */ +var UUID = function () +{ + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) + { + var r = Math.random() * 16 | 0; + var v = (c === 'x') ? r : (r & 0x3 | 0x8); + + return v.toString(16); + }); +}; + +module.exports = UUID; + + +/***/ }), +/* 296 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(31); +var GetBoolean = __webpack_require__(84); +var GetValue = __webpack_require__(4); +var Sprite = __webpack_require__(61); +var TWEEN_CONST = __webpack_require__(83); +var Vector2 = __webpack_require__(3); + +/** + * Settings for a PathFollower. + * + * @typedef {object} PathConfig + * + * @property {number} duration - The duration of the path follow. + * @property {number} from - The start position of the path follow, between 0 and 1. + * @property {number} to - The end position of the path follow, between 0 and 1. + * @property {boolean} [positionOnPath=false] - Whether to position the PathFollower on the Path using its path offset. + * @property {boolean} [rotateToPath=false] - Should the PathFollower automatically rotate to point in the direction of the Path? + * @property {number} [rotationOffset=0] - If the PathFollower is rotating to match the Path, this value is added to the rotation value. This allows you to rotate objects to a path but control the angle of the rotation as well. + * @property {boolean} [verticalAdjust=false] - [description] + */ + +/** + * @classdesc + * A PathFollower Game Object. + * + * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. + * + * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, + * scale it and so on. + * + * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start + * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate + * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. + * + * @class PathFollower + * @extends Phaser.GameObjects.Sprite + * @memberof Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this PathFollower belongs. + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var PathFollower = new Class({ + + Extends: Sprite, + + initialize: + + function PathFollower (scene, path, x, y, texture, frame) + { + Sprite.call(this, scene, x, y, texture, frame); + + /** + * The Path this PathFollower is following. It can only follow one Path at a time. + * + * @name Phaser.GameObjects.PathFollower#path + * @type {Phaser.Curves.Path} + * @since 3.0.0 + */ + this.path = path; + + /** + * Should the PathFollower automatically rotate to point in the direction of the Path? + * + * @name Phaser.GameObjects.PathFollower#rotateToPath + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.rotateToPath = false; + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pathRotationVerticalAdjust = false; + + /** + * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) + * this value is added to the rotation value. This allows you to rotate objects to a path but control + * the angle of the rotation as well. + * + * @name Phaser.GameObjects.PathFollower#pathRotationOffset + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.pathRotationOffset = 0; + + /** + * An additional vector to add to the PathFollowers position, allowing you to offset it from the + * Path coordinates. + * + * @name Phaser.GameObjects.PathFollower#pathOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathOffset = new Vector2(x, y); + + /** + * [description] + * + * @name Phaser.GameObjects.PathFollower#pathVector + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.pathVector = new Vector2(); + + /** + * The Tween used for following the Path. + * + * @name Phaser.GameObjects.PathFollower#pathTween + * @type {Phaser.Tweens.Tween} + * @since 3.0.0 + */ + this.pathTween; + + /** + * Settings for the PathFollower. + * + * @name Phaser.GameObjects.PathFollower#pathConfig + * @type {?PathConfig} + * @default null + * @since 3.0.0 + */ + this.pathConfig = null; + + /** + * Records the direction of the follower so it can change direction. + * + * @name Phaser.GameObjects.PathFollower#_prevDirection + * @type {integer} + * @private + * @since 3.0.0 + */ + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + }, + + /** + * Set the Path that this PathFollower should follow. + * + * Optionally accepts {@link PathConfig} settings. + * + * @method Phaser.GameObjects.PathFollower#setPath + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. + * @param {PathConfig} [config] - Settings for the PathFollower. + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setPath: function (path, config) + { + if (config === undefined) { config = this.pathConfig; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + this.path = path; + + if (config) + { + this.startFollow(config); + } + + return this; + }, + + /** + * Set whether the PathFollower should automatically rotate to point in the direction of the Path. + * + * @method Phaser.GameObjects.PathFollower#setRotateToPath + * @since 3.0.0 + * + * @param {boolean} value - Whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param {number} [offset=0] - Rotation offset in degrees. + * @param {boolean} [verticalAdjust=false] - [description] + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + setRotateToPath: function (value, offset, verticalAdjust) + { + if (offset === undefined) { offset = 0; } + if (verticalAdjust === undefined) { verticalAdjust = false; } + + this.rotateToPath = value; + + this.pathRotationOffset = offset; + this.pathRotationVerticalAdjust = verticalAdjust; + + return this; + }, + + /** + * Is this PathFollower actively following a Path or not? + * + * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. + * + * @method Phaser.GameObjects.PathFollower#isFollowing + * @since 3.0.0 + * + * @return {boolean} `true` is this PathFollower is actively following a Path, otherwise `false`. + */ + isFollowing: function () + { + var tween = this.pathTween; + + return (tween && tween.isPlaying()); + }, + + /** + * Starts this PathFollower following its given Path. + * + * @method Phaser.GameObjects.PathFollower#startFollow + * @since 3.3.0 + * + * @param {(number|PathConfig)} [config={}] - The duration of the follow, or a PathFollower config object. + * @param {number} [startAt=0] - Optional start position of the follow, between 0 and 1. + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + startFollow: function (config, startAt) + { + if (config === undefined) { config = {}; } + if (startAt === undefined) { startAt = 0; } + + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + if (typeof config === 'number') + { + config = { duration: config }; + } + + // Override in case they've been specified in the config + config.from = 0; + config.to = 1; + + // Can also read extra values out of the config: + + var positionOnPath = GetBoolean(config, 'positionOnPath', false); + + this.rotateToPath = GetBoolean(config, 'rotateToPath', false); + this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); + this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); + + this.pathTween = this.scene.sys.tweens.addCounter(config); + + // The starting point of the path, relative to this follower + this.path.getStartPoint(this.pathOffset); + + if (positionOnPath) + { + this.x = this.pathOffset.x; + this.y = this.pathOffset.y; + } + + this.pathOffset.x = this.x - this.pathOffset.x; + this.pathOffset.y = this.y - this.pathOffset.y; + + this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; + + if (this.rotateToPath) + { + // Set the rotation now (in case the tween has a delay on it, etc) + var nextPoint = this.path.getPoint(0.1); + + this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); + } + + this.pathConfig = config; + + return this; + }, + + /** + * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the + * point on the Path at which you paused it. + * + * @method Phaser.GameObjects.PathFollower#pauseFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + pauseFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.pause(); + } + + return this; + }, + + /** + * Resumes a previously paused PathFollower. + * + * If the PathFollower was not paused this has no effect. + * + * @method Phaser.GameObjects.PathFollower#resumeFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + resumeFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPaused()) + { + tween.resume(); + } + + return this; + }, + + /** + * Stops this PathFollower from following the path any longer. + * + * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. + * + * @method Phaser.GameObjects.PathFollower#stopFollow + * @since 3.3.0 + * + * @return {Phaser.GameObjects.PathFollower} This Game Object. + */ + stopFollow: function () + { + var tween = this.pathTween; + + if (tween && tween.isPlaying()) + { + tween.stop(); + } + + return this; + }, + + /** + * Internal update handler that advances this PathFollower along the path. + * + * Called automatically by the Scene step, should not typically be called directly. + * + * @method Phaser.GameObjects.PathFollower#preUpdate + * @protected + * @since 3.0.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. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + + var tween = this.pathTween; + + if (tween) + { + var tweenData = tween.data[0]; + + if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) + { + // If delayed, etc then bail out + return; + } + + var pathVector = this.pathVector; + + this.path.getPoint(tween.getValue(), pathVector); + + pathVector.add(this.pathOffset); + + var oldX = this.x; + var oldY = this.y; + + this.setPosition(pathVector.x, pathVector.y); + + var speedX = this.x - oldX; + var speedY = this.y - oldY; + + if (speedX === 0 && speedY === 0) + { + // Bail out early + return; + } + + if (tweenData.state !== this._prevDirection) + { + // We've changed direction, so don't do a rotate this frame + this._prevDirection = tweenData.state; + + return; + } + + if (this.rotateToPath) + { + this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); + + if (this.pathRotationVerticalAdjust) + { + this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); + } + } + } + } + +}); + +module.exports = PathFollower; + + +/***/ }), +/* 297 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @callback RandomZoneSourceCallback + * + * @param {Phaser.Math.Vector2} point - A point to modify. + */ + +/** + * @typedef {object} RandomZoneSource + * + * @property {RandomZoneSourceCallback} getRandomPoint - A function modifying its point argument. + * + * @see Phaser.Geom.Circle + * @see Phaser.Geom.Ellipse + * @see Phaser.Geom.Line + * @see Phaser.Geom.Polygon + * @see Phaser.Geom.Rectangle + * @see Phaser.Geom.Triangle + */ + +/** + * @classdesc + * A zone that places particles randomly within a shape's area. + * + * @class RandomZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {RandomZoneSource} source - An object instance with a `getRandomPoint(point)` method. + */ +var RandomZone = new Class({ + + initialize: + + function RandomZone (source) + { + /** + * An object instance with a `getRandomPoint(point)` method. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#source + * @type {RandomZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * Internal calculation vector. + * + * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec + * @type {Phaser.Math.Vector2} + * @private + * @since 3.0.0 + */ + this._tempVec = new Vector2(); + }, + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * + * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle. + */ + getPoint: function (particle) + { + var vec = this._tempVec; + + this.source.getRandomPoint(vec); + + particle.x = vec.x; + particle.y = vec.y; + } + +}); + +module.exports = RandomZone; + + +/***/ }), +/* 298 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Verifies that an object contains at least one of the requested keys + * + * @function Phaser.Utils.Objects.HasAny + * @since 3.0.0 + * + * @param {object} source - an object on which to check for key existence + * @param {string[]} keys - an array of keys to search the object for + * + * @return {boolean} true if the source object contains at least one of the keys, false otherwise + */ +var HasAny = function (source, keys) +{ + for (var i = 0; i < keys.length; i++) + { + if (source.hasOwnProperty(keys[i])) + { + return true; + } + } + + return false; +}; + +module.exports = HasAny; + + +/***/ }), +/* 299 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Generate a random floating point number between the two given bounds, minimum inclusive, maximum exclusive. + * + * @function Phaser.Math.FloatBetween + * @since 3.0.0 + * + * @param {number} min - The lower bound for the float, inclusive. + * @param {number} max - The upper bound for the float exclusive. + * + * @return {number} A random float within the given range. + */ +var FloatBetween = function (min, max) +{ + return Math.random() * (max - min) + min; +}; + +module.exports = FloatBetween; + + +/***/ }), +/* 300 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback EdgeZoneSourceCallback + * + * @param {integer} quantity - The number of particles to place on the source edge. If 0, `stepRate` should be used instead. + * @param {number} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to `0`. + * + * @return {Phaser.Geom.Point[]} - The points placed on the source edge. + */ + +/** + * @typedef {object} EdgeZoneSource + * + * @property {EdgeZoneSourceCallback} getPoints - A function placing points on the source's edge or edges. + * + * @see Phaser.Curves.Curve + * @see Phaser.Curves.Path + * @see Phaser.Geom.Circle + * @see Phaser.Geom.Ellipse + * @see Phaser.Geom.Line + * @see Phaser.Geom.Polygon + * @see Phaser.Geom.Rectangle + * @see Phaser.Geom.Triangle + */ + +/** + * @classdesc + * A zone that places particles on a shape's edges. + * + * @class EdgeZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * @param {integer} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @param {number} stepRate - The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @param {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. + * @param {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. + */ +var EdgeZone = new Class({ + + initialize: + + function EdgeZone (source, quantity, stepRate, yoyo, seamless) + { + if (yoyo === undefined) { yoyo = false; } + if (seamless === undefined) { seamless = true; } + + /** + * An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source + * @type {EdgeZoneSource|RandomZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * The points placed on the source edge. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points + * @type {Phaser.Geom.Point[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + /** + * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity + * @type {integer} + * @since 3.0.0 + */ + this.quantity = quantity; + + /** + * The distance between each particle. When set, `quantity` is implied and should be set to 0. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate + * @type {number} + * @since 3.0.0 + */ + this.stepRate = stepRate; + + /** + * Whether particles are placed from start to end and then end to start. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo + * @type {boolean} + * @since 3.0.0 + */ + this.yoyo = yoyo; + + /** + * The counter used for iterating the EdgeZone's points. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.counter = -1; + + /** + * Whether one endpoint will be removed if it's identical to the other. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless + * @type {boolean} + * @since 3.0.0 + */ + this.seamless = seamless; + + /** + * An internal count of the points belonging to this EdgeZone. + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._length = 0; + + /** + * An internal value used to keep track of the current iteration direction for the EdgeZone's points. + * + * 0 = forwards, 1 = backwards + * + * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._direction = 0; + + this.updateSource(); + }, + + /** + * Update the {@link Phaser.GameObjects.Particles.Zones.EdgeZone#points} from the EdgeZone's + * {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * + * Also updates internal properties. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + updateSource: function () + { + this.points = this.source.getPoints(this.quantity, this.stepRate); + + // Remove ends? + if (this.seamless) + { + var a = this.points[0]; + var b = this.points[this.points.length - 1]; + + if (a.x === b.x && a.y === b.y) + { + this.points.pop(); + } + } + + var oldLength = this._length; + + this._length = this.points.length; + + // Adjust counter if we now have less points than before + if (this._length < oldLength && this.counter > this._length) + { + this.counter = this._length - 1; + } + + return this; + }, + + /** + * Change the EdgeZone's source. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource + * @since 3.0.0 + * + * @param {EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. + * + * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. + */ + changeSource: function (source) + { + this.source = source; + + return this.updateSource(); + }, + + /** + * Get the next point in the Zone and set its coordinates on the given Particle. + * + * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle. + */ + getPoint: function (particle) + { + if (this._direction === 0) + { + this.counter++; + + if (this.counter >= this._length) + { + if (this.yoyo) + { + this._direction = 1; + this.counter = this._length - 1; + } + else + { + this.counter = 0; + } + } + } + else + { + this.counter--; + + if (this.counter === -1) + { + if (this.yoyo) + { + this._direction = 0; + this.counter = 0; + } + else + { + this.counter = this._length - 1; + } + } + } + + var point = this.points[this.counter]; + + if (point) + { + particle.x = point.x; + particle.y = point.y; + } + } + +}); + +module.exports = EdgeZone; + + +/***/ }), +/* 301 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback DeathZoneSourceCallback + * + * @param {number} x - The x coordinate of the particle to check against this source area. + * @param {number} y - The y coordinate of the particle to check against this source area. + * + * @return {boolean} - True if the coordinates are within the source area. + */ + +/** + * @typedef {object} DeathZoneSource + * + * @property {DeathZoneSourceCallback} contains + * + * @see Phaser.Geom.Circle + * @see Phaser.Geom.Ellipse + * @see Phaser.Geom.Polygon + * @see Phaser.Geom.Rectangle + * @see Phaser.Geom.Triangle + */ + +/** + * @classdesc + * A Death Zone. + * + * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. + * + * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own + * object as long as it includes a `contains` method for which the Particles can be tested against. + * + * @class DeathZone + * @memberof Phaser.GameObjects.Particles.Zones + * @constructor + * @since 3.0.0 + * + * @param {DeathZoneSource} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` + */ +var DeathZone = new Class({ + + initialize: + + function DeathZone (source, killOnEnter) + { + /** + * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. + * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#source + * @type {DeathZoneSource} + * @since 3.0.0 + */ + this.source = source; + + /** + * Set to `true` if the Particle should be killed if it enters this zone. + * Set to `false` to kill the Particle if it leaves this zone. + * + * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter + * @type {boolean} + * @since 3.0.0 + */ + this.killOnEnter = killOnEnter; + }, + + /** + * Checks if the given Particle will be killed or not by this zone. + * + * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to be checked against this zone. + * + * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. + */ + willKill: function (particle) + { + var withinZone = this.source.contains(particle.x, particle.y); + + return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); + } + +}); + +module.exports = DeathZone; + + +/***/ }), +/* 302 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(66); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var DeathZone = __webpack_require__(301); +var EdgeZone = __webpack_require__(300); +var EmitterOp = __webpack_require__(822); +var GetFastValue = __webpack_require__(2); +var GetRandom = __webpack_require__(162); +var HasAny = __webpack_require__(298); +var HasValue = __webpack_require__(85); +var Particle = __webpack_require__(303); +var RandomZone = __webpack_require__(297); +var Rectangle = __webpack_require__(9); +var StableSort = __webpack_require__(110); +var Vector2 = __webpack_require__(3); +var Wrap = __webpack_require__(53); + +/** + * @callback ParticleEmitterCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle associated with the call. + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - This particle emitter associated with the call. + */ + +/** + * @callback ParticleDeathCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle that died. +*/ + +/** + * @typedef {object} ParticleEmitterBounds + * + * @property {number} x - The left edge of the rectangle. + * @property {number} y - The top edge of the rectangle. + * @property {number} width - The width of the rectangle. + * @property {number} height - The height of the rectangle. + * + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + */ + +/** + * @typedef {object} ParticleEmitterBoundsAlt + * + * @property {number} x - The left edge of the rectangle. + * @property {number} y - The top edge of the rectangle. + * @property {number} w - The width of the rectangle. + * @property {number} h - The height of the rectangle. + * + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + */ + +/** + * @typedef {object} ParticleEmitterDeathZoneConfig + * + * @property {DeathZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.DeathZone#source}. + * @property {string} [type='onEnter'] - 'onEnter' or 'onLeave'. + */ + +/** + * @typedef {object} ParticleEmitterEdgeZoneConfig + * + * @property {EdgeZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * @property {string} type - 'edge'. + * @property {integer} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @property {number} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @property {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. + * @property {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. + */ + +/** + * @typedef {object} ParticleEmitterRandomZoneConfig + * + * @property {RandomZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.RandomZone#source}. + * @property {string} [type] - 'random'. + */ + +/** + * @typedef {object} ParticleEmitterConfig + * + * @property {boolean} [active] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#active}. + * @property {integer} [blendMode] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#blendMode}. + * @property {*} [callbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope} and {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. + * @property {boolean} [collideBottom] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideBottom}. + * @property {boolean} [collideLeft] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideLeft}. + * @property {boolean} [collideRight] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideRight}. + * @property {boolean} [collideTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideTop}. + * @property {boolean} [deathCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + * @property {*} [deathCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope}. + * @property {function} [emitCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + * @property {*} [emitCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. + * @property {Phaser.GameObjects.GameObject} [follow] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#follow}. + * @property {number} [frequency] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency}. + * @property {number} [gravityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityX}. + * @property {number} [gravityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityY}. + * @property {integer} [maxParticles] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxParticles}. + * @property {string} [name] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#name}. + * @property {boolean} [on] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#on}. + * @property {boolean} [particleBringToTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop}. + * @property {Phaser.GameObjects.Particles.Particle} [particleClass] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleClass}. + * @property {boolean} [radial] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#radial}. + * @property {number} [timeScale] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#timeScale}. + * @property {boolean} [trackVisible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#trackVisible}. + * @property {boolean} [visible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#visible}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [accelerationX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [accelerationY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationY} (emit only). + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [alpha] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#alpha}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [angle] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#angle} (emit only) + * @property {number|number[]|EmitterOpOnEmitCallback|object} [bounce] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#bounce} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [delay] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#delay} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [lifespan] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#lifespan} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [maxVelocityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [maxVelocityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [moveToX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [moveToY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToY} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [quantity] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity} (emit only). + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [rotate] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#rotate}. + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [scale] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setScale}. + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [scaleX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleX}. + * @property {number|number[]|EmitterOpOnUpdateCallback|object} [scaleY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleY}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [speed] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setSpeed} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [speedX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedX} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [speedY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedY} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [tint] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#tint}. + * @property {number|number[]|EmitterOpOnEmitCallback|object} [x] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#x} (emit only). + * @property {number|number[]|EmitterOpOnEmitCallback|object} [y] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#y} (emit only). + * @property {object} [emitZone] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone}. + * @property {ParticleEmitterBounds|ParticleEmitterBoundsAlt} [bounds] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setBounds}. + * @property {object} [followOffset] - Assigns to {@link Phaser.GameObjects.Particles.ParticleEmitter#followOffset}. + * @property {number} [followOffset.x] - x-coordinate of the offset. + * @property {number} [followOffset.y] - y-coordinate of the offset. + * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]|ParticleEmitterFrameConfig} [frames] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + */ + +/** + * @typedef {object} ParticleEmitterFrameConfig + * + * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]} [frames] - One or more texture frames. + * @property {boolean} [cycle] - Whether texture frames will be assigned consecutively (true) or at random (false). + * @property {integer} [quantity] - The number of consecutive particles receiving each texture frame, when `cycle` is true. + */ + +/** + * @classdesc + * A particle emitter represents a single particle stream. + * It controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles} and is controlled by a {@link Phaser.GameObjects.Particles.ParticleEmitterManager Particle Emitter Manager}. + * + * @class ParticleEmitter + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} manager - The Emitter Manager this Emitter belongs to. + * @param {ParticleEmitterConfig} config - Settings for this emitter. + */ +var ParticleEmitter = new Class({ + + Mixins: [ + Components.BlendMode, + Components.Mask, + Components.ScrollFactor, + Components.Visible + ], + + initialize: + + function ParticleEmitter (manager, config) + { + /** + * The Emitter Manager this Emitter belongs to. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#manager + * @type {Phaser.GameObjects.Particles.ParticleEmitterManager} + * @since 3.0.0 + */ + this.manager = manager; + + /** + * The texture assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#texture + * @type {Phaser.Textures.Texture} + * @since 3.0.0 + */ + this.texture = manager.texture; + + /** + * The texture frames assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frames + * @type {Phaser.Textures.Frame[]} + * @since 3.0.0 + */ + this.frames = [ manager.defaultFrame ]; + + /** + * The default texture frame assigned to particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#defaultFrame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.defaultFrame = manager.defaultFrame; + + /** + * Names of simple configuration properties. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configFastMap + * @type {object} + * @since 3.0.0 + */ + this.configFastMap = [ + 'active', + 'blendMode', + 'collideBottom', + 'collideLeft', + 'collideRight', + 'collideTop', + 'deathCallback', + 'deathCallbackScope', + 'emitCallback', + 'emitCallbackScope', + 'follow', + 'frequency', + 'gravityX', + 'gravityY', + 'maxParticles', + 'name', + 'on', + 'particleBringToTop', + 'particleClass', + 'radial', + 'timeScale', + 'trackVisible', + 'visible' + ]; + + /** + * Names of complex configuration properties. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#configOpMap + * @type {object} + * @since 3.0.0 + */ + this.configOpMap = [ + 'accelerationX', + 'accelerationY', + 'angle', + 'alpha', + 'bounce', + 'delay', + 'lifespan', + 'maxVelocityX', + 'maxVelocityY', + 'moveToX', + 'moveToY', + 'quantity', + 'rotate', + 'scaleX', + 'scaleY', + 'speedX', + 'speedY', + 'tint', + 'x', + 'y' + ]; + + /** + * The name of this Particle Emitter. + * + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The Particle Class which will be emitted by this Emitter. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass + * @type {Phaser.GameObjects.Particles.Particle} + * @default Phaser.GameObjects.Particles.Particle + * @since 3.0.0 + */ + this.particleClass = Particle; + + /** + * The x-coordinate of the particle origin (where particles will be emitted). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#x + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition + */ + this.x = new EmitterOp(config, 'x', 0); + + /** + * The y-coordinate of the particle origin (where particles will be emitted). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#y + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition + */ + this.y = new EmitterOp(config, 'y', 0); + + /** + * A radial emitter will emit particles in all directions between angle min and max, + * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. + * A point emitter will emit particles only in the direction derived from the speedX and speedY values. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#radial + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setRadial + */ + this.radial = true; + + /** + * Horizontal acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity + */ + this.gravityX = 0; + + /** + * Vertical acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity + */ + this.gravityY = 0; + + /** + * Whether accelerationX and accelerationY are non-zero. Set automatically during configuration. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.acceleration = false; + + /** + * Horizontal acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.accelerationX = new EmitterOp(config, 'accelerationX', 0, true); + + /** + * Vertical acceleration applied to emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.accelerationY = new EmitterOp(config, 'accelerationY', 0, true); + + /** + * The maximum horizontal velocity of emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityX = new EmitterOp(config, 'maxVelocityX', 10000, true); + + /** + * The maximum vertical velocity of emitted particles, in pixels per second squared. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityY = new EmitterOp(config, 'maxVelocityY', 10000, true); + + /** + * The initial horizontal speed of emitted particles, in pixels per second. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX + */ + this.speedX = new EmitterOp(config, 'speedX', 0, true); + + /** + * The initial vertical speed of emitted particles, in pixels per second. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY + */ + this.speedY = new EmitterOp(config, 'speedY', 0, true); + + /** + * Whether moveToX and moveToY are nonzero. Set automatically during configuration. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.moveTo = false; + + /** + * The x-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.moveToX = new EmitterOp(config, 'moveToX', 0, true); + + /** + * The y-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.moveToY = new EmitterOp(config, 'moveToY', 0, true); + + /** + * Whether particles will rebound when they meet the emitter bounds. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.bounce = new EmitterOp(config, 'bounce', 0, true); + + /** + * The horizontal scale of emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleX + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleX + */ + this.scaleX = new EmitterOp(config, 'scaleX', 1); + + /** + * The vertical scale of emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleY + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleY + */ + this.scaleY = new EmitterOp(config, 'scaleY', 1); + + /** + * Color tint applied to emitted particles. Any alpha component (0xAA000000) is ignored. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#tint + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0xffffffff + * @since 3.0.0 + */ + this.tint = new EmitterOp(config, 'tint', 0xffffffff); + + /** + * The alpha (transparency) of emitted particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alpha + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setAlpha + */ + this.alpha = new EmitterOp(config, 'alpha', 1); + + /** + * The lifespan of emitted particles, in ms. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1000 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setLifespan + */ + this.lifespan = new EmitterOp(config, 'lifespan', 1000); + + /** + * The angle of the initial velocity of emitted particles, in degrees. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#angle + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default { min: 0, max: 360 } + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setAngle + */ + this.angle = new EmitterOp(config, 'angle', { min: 0, max: 360 }); + + /** + * The rotation of emitted particles, in degrees. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#rotate + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.rotate = new EmitterOp(config, 'rotate', 0); + + /** + * A function to call when a particle is emitted. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback + * @type {?ParticleEmitterCallback} + * @default null + * @since 3.0.0 + */ + this.emitCallback = null; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.emitCallbackScope = null; + + /** + * A function to call when a particle dies. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback + * @type {?ParticleDeathCallback} + * @default null + * @since 3.0.0 + */ + this.deathCallback = null; + + /** + * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope + * @type {?*} + * @default null + * @since 3.0.0 + */ + this.deathCallbackScope = null; + + /** + * Set to hard limit the amount of particle objects this emitter is allowed to create. + * 0 means unlimited. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.maxParticles = 0; + + /** + * How many particles are emitted each time particles are emitted (one explosion or one flow cycle). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @see Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + */ + this.quantity = new EmitterOp(config, 'quantity', 1, true); + + /** + * How many ms to wait after emission before the particles start updating. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#delay + * @type {Phaser.GameObjects.Particles.EmitterOp} + * @default 0 + * @since 3.0.0 + */ + this.delay = new EmitterOp(config, 'delay', 0, true); + + /** + * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. + * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. + * For an exploding emitter, this value will be -1. + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). + * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency + * @type {number} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + */ + this.frequency = 0; + + /** + * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). + * Already alive particles will continue to update until they expire. + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#on + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.on = true; + + /** + * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. + * Set to false to send them to the back. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.particleBringToTop = true; + + /** + * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.timeScale = 1; + + /** + * An object describing a shape to emit particles from. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZone + * @type {?Phaser.GameObjects.Particles.Zones.EdgeZone|Phaser.GameObjects.Particles.Zones.RandomZone} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + */ + this.emitZone = null; + + /** + * An object describing a shape that deactivates particles when they interact with it. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZone + * @type {?Phaser.GameObjects.Particles.Zones.DeathZone} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone + */ + this.deathZone = null; + + /** + * A rectangular boundary constraining particle movement. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#bounds + * @type {?Phaser.Geom.Rectangle} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + */ + this.bounds = null; + + /** + * Whether particles interact with the left edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideLeft + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideLeft = true; + + /** + * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideRight + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideRight = true; + + /** + * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideTop + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideTop = true; + + /** + * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#collideBottom + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.collideBottom = true; + + /** + * Whether this emitter updates itself and its particles. + * + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#pause} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#resume}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * Set this to false to hide any active particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#visible + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setVisible + */ + this.visible = true; + + /** + * The blend mode of this emitter's particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#blendMode + * @type {integer} + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setBlendMode + */ + this.blendMode = BlendModes.NORMAL; + + /** + * A Game Object whose position is used as the particle origin. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#follow + * @type {?Phaser.GameObjects.GameObject} + * @default null + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @see Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + */ + this.follow = null; + + /** + * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + */ + this.followOffset = new Vector2(); + + /** + * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track + * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible + * @type {boolean} + * @default false + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow + */ + this.trackVisible = false; + + /** + * The current texture frame, as an index of {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame + * @type {integer} + * @default 0 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame + */ + this.currentFrame = 0; + + /** + * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame + * @type {boolean} + * @default true + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame + */ + this.randomFrame = true; + + /** + * The number of consecutive particles that receive a single texture frame (per frame cycle). + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity + * @type {integer} + * @default 1 + * @since 3.0.0 + * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame + */ + this.frameQuantity = 1; + + /** + * Inactive particles. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#dead + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.dead = []; + + /** + * Active particles + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#alive + * @type {Phaser.GameObjects.Particles.Particle[]} + * @private + * @since 3.0.0 + */ + this.alive = []; + + /** + * The time until the next flow cycle. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_counter + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._counter = 0; + + /** + * Counts up to {@link Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity}. + * + * @name Phaser.GameObjects.Particles.ParticleEmitter#_frameCounter + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + this._frameCounter = 0; + + if (config) + { + this.fromJSON(config); + } + }, + + /** + * Merges configuration settings into the emitter's current settings. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#fromJSON + * @since 3.0.0 + * + * @param {ParticleEmitterConfig} config - Settings for this emitter. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + fromJSON: function (config) + { + if (!config) + { + return this; + } + + // Only update properties from their current state if they exist in the given config + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + if (HasValue(config, key)) + { + this[key] = GetFastValue(config, key); + } + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (HasValue(config, key)) + { + this[key].loadConfig(config); + } + } + + this.acceleration = (this.accelerationX.propertyValue !== 0 || this.accelerationY.propertyValue !== 0); + + this.moveTo = (this.moveToX.propertyValue !== 0 || this.moveToY.propertyValue !== 0); + + // Special 'speed' override + + if (HasValue(config, 'speed')) + { + this.speedX.loadConfig(config, 'speed'); + this.speedY = null; + } + + // If you specify speedX, speedY or moveTo then it changes the emitter from radial to a point emitter + if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) + { + this.radial = false; + } + + // Special 'scale' override + + if (HasValue(config, 'scale')) + { + this.scaleX.loadConfig(config, 'scale'); + this.scaleY = null; + } + + if (HasValue(config, 'callbackScope')) + { + var callbackScope = GetFastValue(config, 'callbackScope', null); + + this.emitCallbackScope = callbackScope; + this.deathCallbackScope = callbackScope; + } + + if (HasValue(config, 'emitZone')) + { + this.setEmitZone(config.emitZone); + } + + if (HasValue(config, 'deathZone')) + { + this.setDeathZone(config.deathZone); + } + + if (HasValue(config, 'bounds')) + { + this.setBounds(config.bounds); + } + + if (HasValue(config, 'followOffset')) + { + this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); + } + + if (HasValue(config, 'frame')) + { + this.setFrame(config.frame); + } + + return this; + }, + + /** + * Creates a description of this emitter suitable for JSON serialization. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON + * @since 3.0.0 + * + * @param {object} [output] - An object to copy output into. + * + * @return {object} - The output object. + */ + toJSON: function (output) + { + if (output === undefined) { output = {}; } + + var i = 0; + var key = ''; + + for (i = 0; i < this.configFastMap.length; i++) + { + key = this.configFastMap[i]; + + output[key] = this[key]; + } + + for (i = 0; i < this.configOpMap.length; i++) + { + key = this.configOpMap[i]; + + if (this[key]) + { + output[key] = this[key].toJSON(); + } + } + + // special handlers + if (!this.speedY) + { + delete output.speedX; + output.speed = this.speedX.toJSON(); + } + + if (!this.scaleY) + { + delete output.scaleX; + output.scale = this.scaleX.toJSON(); + } + + return output; + }, + + /** + * Continuously moves the particle origin to follow a Game Object's position. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} target - The Game Object to follow. + * @param {number} [offsetX=0] - Horizontal offset of the particle origin from the Game Object. + * @param {number} [offsetY=0] - Vertical offset of the particle origin from the Game Object. + * @param {boolean} [trackVisible=false] - Whether the emitter's visible state will track the target's visible state. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + startFollow: function (target, offsetX, offsetY, trackVisible) + { + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + if (trackVisible === undefined) { trackVisible = false; } + + this.follow = target; + this.followOffset.set(offsetX, offsetY); + this.trackVisible = trackVisible; + + return this; + }, + + /** + * Stops following a Game Object. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stopFollow: function () + { + this.follow = null; + this.followOffset.set(0, 0); + this.trackVisible = false; + + return this; + }, + + /** + * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame + * @since 3.0.0 + * + * @return {Phaser.Textures.Frame} The texture frame. + */ + getFrame: function () + { + if (this.frames.length === 1) + { + return this.defaultFrame; + } + else if (this.randomFrame) + { + return GetRandom(this.frames); + } + else + { + var frame = this.frames[this.currentFrame]; + + this._frameCounter++; + + if (this._frameCounter === this.frameQuantity) + { + this._frameCounter = 0; + this.currentFrame = Wrap(this.currentFrame + 1, 0, this._frameLength); + } + + return frame; + } + }, + + // frame: 0 + // frame: 'red' + // frame: [ 0, 1, 2, 3 ] + // frame: [ 'red', 'green', 'blue', 'pink', 'white' ] + // frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } + + /** + * Sets a pattern for assigning texture frames to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrame + * @since 3.0.0 + * + * @param {(array|string|integer|ParticleEmitterFrameConfig)} frames - One or more texture frames, or a configuration object. + * @param {boolean} [pickRandom=true] - Whether frames should be assigned at random from `frames`. + * @param {integer} [quantity=1] - The number of consecutive particles that will receive each frame. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrame: function (frames, pickRandom, quantity) + { + if (pickRandom === undefined) { pickRandom = true; } + if (quantity === undefined) { quantity = 1; } + + this.randomFrame = pickRandom; + this.frameQuantity = quantity; + this.currentFrame = 0; + this._frameCounter = 0; + + var t = typeof (frames); + + if (Array.isArray(frames) || t === 'string' || t === 'number') + { + this.manager.setEmitterFrames(frames, this); + } + else if (t === 'object') + { + var frameConfig = frames; + + frames = GetFastValue(frameConfig, 'frames', null); + + if (frames) + { + this.manager.setEmitterFrames(frames, this); + } + + var isCycle = GetFastValue(frameConfig, 'cycle', false); + + this.randomFrame = (isCycle) ? false : true; + + this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); + } + + this._frameLength = this.frames.length; + + if (this._frameLength === 1) + { + this.frameQuantity = 1; + this.randomFrame = false; + } + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial + * @since 3.0.0 + * + * @param {boolean} [value=true] - Radial mode (true) or point mode (true). + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setRadial: function (value) + { + if (value === undefined) { value = true; } + + this.radial = value; + + return this; + }, + + /** + * Sets the position of the emitter's particle origin. + * New particles will be emitted here. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} x - The x-coordinate of the particle origin. + * @param {number|float[]|EmitterOpOnEmitCallback|object} y - The y-coordinate of the particle origin. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setPosition: function (x, y) + { + this.x.onChange(x); + this.y.onChange(y); + + return this; + }, + + /** + * Sets or modifies a rectangular boundary constraining the particles. + * + * To remove the boundary, set {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds} to null. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setBounds + * @since 3.0.0 + * + * @param {(number|ParticleEmitterBounds|ParticleEmitterBoundsAlt)} x - The x-coordinate of the left edge of the boundary, or an object representing a rectangle. + * @param {number} y - The y-coordinate of the top edge of the boundary. + * @param {number} width - The width of the boundary. + * @param {number} height - The height of the boundary. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setBounds: function (x, y, width, height) + { + if (typeof x === 'object') + { + var obj = x; + + x = obj.x; + y = obj.y; + width = (HasValue(obj, 'w')) ? obj.w : obj.width; + height = (HasValue(obj, 'h')) ? obj.h : obj.height; + } + + if (this.bounds) + { + this.bounds.setTo(x, y, width, height); + } + else + { + this.bounds = new Rectangle(x, y, width, height); + } + + return this; + }, + + /** + * Sets the initial horizontal speed of emitted particles. + * Changes the emitter to point mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedX: function (value) + { + this.speedX.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + + return this; + }, + + /** + * Sets the initial vertical speed of emitted particles. + * Changes the emitter to point mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeedY: function (value) + { + if (this.speedY) + { + this.speedY.onChange(value); + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = false; + } + + return this; + }, + + /** + * Sets the initial radial speed of emitted particles. + * Changes the emitter to radial mode. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setSpeed: function (value) + { + this.speedX.onChange(value); + this.speedY = null; + + // If you specify speedX and Y then it changes the emitter from radial to a point emitter + this.radial = true; + + return this; + }, + + /** + * Sets the horizontal scale of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleX: function (value) + { + this.scaleX.onChange(value); + + return this; + }, + + /** + * Sets the vertical scale of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScaleY: function (value) + { + this.scaleY.onChange(value); + + return this; + }, + + /** + * Sets the scale of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setScale: function (value) + { + this.scaleX.onChange(value); + this.scaleY = null; + + return this; + }, + + /** + * Sets the horizontal gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX + * @since 3.0.0 + * + * @param {number} value - Acceleration due to gravity, in pixels per second squared. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityX: function (value) + { + this.gravityX = value; + + return this; + }, + + /** + * Sets the vertical gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY + * @since 3.0.0 + * + * @param {number} value - Acceleration due to gravity, in pixels per second squared. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravityY: function (value) + { + this.gravityY = value; + + return this; + }, + + /** + * Sets the gravity applied to emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity + * @since 3.0.0 + * + * @param {number} x - Horizontal acceleration due to gravity, in pixels per second squared. + * @param {number} y - Vertical acceleration due to gravity, in pixels per second squared. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setGravity: function (x, y) + { + this.gravityX = x; + this.gravityY = y; + + return this; + }, + + /** + * Sets the opacity of emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - A value between 0 (transparent) and 1 (opaque). + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAlpha: function (value) + { + this.alpha.onChange(value); + + return this; + }, + + /** + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitterAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setAngle: function (value) + { + this.angle.onChange(value); + + return this; + }, + + /** + * Sets the lifespan of newly emitted particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The particle lifespan, in ms. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setLifespan: function (value) + { + this.lifespan.onChange(value); + + return this; + }, + + /** + * Sets the number of particles released at each flow cycle or explosion. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity + * @since 3.0.0 + * + * @param {number|float[]|EmitterOpOnEmitCallback|object} quantity - The number of particles to release at each flow cycle or explosion. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setQuantity: function (quantity) + { + this.quantity.onChange(quantity); + + return this; + }, + + /** + * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} + * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency + * @since 3.0.0 + * + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [quantity] - The number of particles to release at each flow cycle or explosion. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setFrequency: function (frequency, quantity) + { + this.frequency = frequency; + + this._counter = 0; + + if (quantity) + { + this.quantity.onChange(quantity); + } + + return this; + }, + + /** + * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#emitZone}. + * + * An {@link ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. Its {@link EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link EdgeZoneSourceCallback getPoints} method. + * + * A {@link ParticleEmitterRandomZoneConfig RandomZone} places randomly within its interior. Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link RandomZoneSourceCallback getRandomPoint} method. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone + * @since 3.0.0 + * + * @param {ParticleEmitterEdgeZoneConfig|ParticleEmitterRandomZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current emit zone. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setEmitZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.emitZone = null; + } + else + { + // Where source = Geom like Circle, or a Path or Curve + // emitZone: { type: 'random', source: X } + // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] } + + var type = GetFastValue(zoneConfig, 'type', 'random'); + var source = GetFastValue(zoneConfig, 'source', null); + + switch (type) + { + case 'random': + + this.emitZone = new RandomZone(source); + + break; + + case 'edge': + + var quantity = GetFastValue(zoneConfig, 'quantity', 1); + var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); + var yoyo = GetFastValue(zoneConfig, 'yoyo', false); + var seamless = GetFastValue(zoneConfig, 'seamless', true); + + this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); + + break; + } + } + + return this; + }, + + /** + * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#deathZone}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone + * @since 3.0.0 + * + * @param {ParticleEmitterDeathZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current death zone. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + setDeathZone: function (zoneConfig) + { + if (zoneConfig === undefined) + { + this.deathZone = null; + } + else + { + // Where source = Geom like Circle or Rect that supports a 'contains' function + // deathZone: { type: 'onEnter', source: X } + // deathZone: { type: 'onLeave', source: X } + + var type = GetFastValue(zoneConfig, 'type', 'onEnter'); + var source = GetFastValue(zoneConfig, 'source', null); + + if (source && typeof source.contains === 'function') + { + var killOnEnter = (type === 'onEnter') ? true : false; + + this.deathZone = new DeathZone(source, killOnEnter); + } + } + + return this; + }, + + /** + * Creates inactive particles and adds them to this emitter's pool. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve + * @since 3.0.0 + * + * @param {integer} particleCount - The number of particles to create. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + reserve: function (particleCount) + { + var dead = this.dead; + + for (var i = 0; i < particleCount; i++) + { + dead.push(new this.particleClass(this)); + } + + return this; + }, + + /** + * Gets the number of active (in-use) particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount + * @since 3.0.0 + * + * @return {integer} The number of particles with `active=true`. + */ + getAliveParticleCount: function () + { + return this.alive.length; + }, + + /** + * Gets the number of inactive (available) particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount + * @since 3.0.0 + * + * @return {integer} The number of particles with `active=false`. + */ + getDeadParticleCount: function () + { + return this.dead.length; + }, + + /** + * Gets the total number of particles in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount + * @since 3.0.0 + * + * @return {integer} The number of particles, including both alive and dead. + */ + getParticleCount: function () + { + return this.getAliveParticleCount() + this.getDeadParticleCount(); + }, + + /** + * Whether this emitter is at its limit (if set). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit + * @since 3.0.0 + * + * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. + */ + atLimit: function () + { + return (this.maxParticles > 0 && this.getParticleCount() === this.maxParticles); + }, + + /** + * Sets a function to call for each newly emitted particle. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - The function. + * @param {*} [context] - The calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleEmit: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.emitCallback = null; + this.emitCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.emitCallback = callback; + + if (context) + { + this.emitCallbackScope = context; + } + } + + return this; + }, + + /** + * Sets a function to call for each particle death. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath + * @since 3.0.0 + * + * @param {ParticleDeathCallback} callback - The function. + * @param {*} [context] - The function's calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + onParticleDeath: function (callback, context) + { + if (callback === undefined) + { + // Clear any previously set callback + this.deathCallback = null; + this.deathCallbackScope = null; + } + else if (typeof callback === 'function') + { + this.deathCallback = callback; + + if (context) + { + this.deathCallbackScope = context; + } + } + + return this; + }, + + /** + * Deactivates every particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + killAll: function () + { + var dead = this.dead; + var alive = this.alive; + + while (alive.length > 0) + { + dead.push(alive.pop()); + } + + return this; + }, + + /** + * Calls a function for each active particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - The function. + * @param {*} context - The function's calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachAlive: function (callback, context) + { + var alive = this.alive; + var length = alive.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(context, alive[index], this); + } + + return this; + }, + + /** + * Calls a function for each inactive particle in this emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead + * @since 3.0.0 + * + * @param {ParticleEmitterCallback} callback - The function. + * @param {*} context - The function's calling context. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + forEachDead: function (callback, context) + { + var dead = this.dead; + var length = dead.length; + + for (var index = 0; index < length; ++index) + { + // Sends the Particle and the Emitter + callback.call(context, dead[index], this); + } + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. + * + * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). + * + * If this emitter is in explode mode (frequency = -1), nothing will happen. + * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#start + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + start: function () + { + this.on = true; + + this._counter = 0; + + return this; + }, + + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on off} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stop + * @since 3.11.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stop: function () + { + this.on = false; + + return this; + }, + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#pause + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + pause: function () + { + this.active = false; + + return this; + }, + + /** + * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#resume + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + resume: function () + { + this.active = true; + + return this; + }, + + /** + * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + depthSort: function () + { + StableSort.inplace(this.alive, this.depthSortCallback); + + return this; + }, + + /** + * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. + * + * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#flow + * @since 3.0.0 + * + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [count=1] - The number of particles to emit at each flow cycle. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + flow: function (frequency, count) + { + if (count === undefined) { count = 1; } + + this.frequency = frequency; + + this.quantity.onChange(count); + + return this.start(); + }, + + /** + * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#explode + * @since 3.0.0 + * + * @param {integer} count - The amount of Particles to emit. + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + explode: function (count, x, y) + { + this.frequency = -1; + + return this.emitParticle(count, x, y); + }, + + /** + * Emits particles at a given position (or the emitter's current position). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt + * @since 3.0.0 + * + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. + * @param {integer} [count=this.quantity] - The number of Particles to emit. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + */ + emitParticleAt: function (x, y, count) + { + return this.emitParticle(count, x, y); + }, + + /** + * Emits particles at a given position (or the emitter's current position). + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle + * @since 3.0.0 + * + * @param {integer} [count=this.quantity] - The number of Particles to emit. + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. + * + * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. + * + * @see Phaser.GameObjects.Particles.Particle#fire + */ + emitParticle: function (count, x, y) + { + if (this.atLimit()) + { + return; + } + + if (count === undefined) + { + count = this.quantity.onEmit(); + } + + var dead = this.dead; + + for (var i = 0; i < count; i++) + { + var particle; + + if (dead.length > 0) + { + particle = dead.pop(); + } + else + { + particle = new this.particleClass(this); + } + + particle.fire(x, y); + + if (this.particleBringToTop) + { + this.alive.push(particle); + } + else + { + this.alive.unshift(particle); + } + + if (this.emitCallback) + { + this.emitCallback.call(this.emitCallbackScope, particle, this); + } + + if (this.atLimit()) + { + break; + } + } + + return particle; + }, + + /** + * Updates this emitter and its particles. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate + * @since 3.0.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. + */ + preUpdate: function (time, delta) + { + // Scale the delta + delta *= this.timeScale; + + var step = (delta / 1000); + + if (this.trackVisible) + { + this.visible = this.follow.visible; + } + + // Any particle processors? + var processors = this.manager.getProcessors(); + + var particles = this.alive; + var length = particles.length; + + for (var index = 0; index < length; index++) + { + var particle = particles[index]; + + // update returns `true` if the particle is now dead (lifeStep < 0) + if (particle.update(delta, step, processors)) + { + // Moves the dead particle to the end of the particles array (ready for splicing out later) + var last = particles[length - 1]; + + particles[length - 1] = particle; + particles[index] = last; + + index -= 1; + length -= 1; + } + } + + // Move dead particles to the dead array + var deadLength = particles.length - length; + + if (deadLength > 0) + { + var rip = particles.splice(particles.length - deadLength, deadLength); + + var deathCallback = this.deathCallback; + var deathCallbackScope = this.deathCallbackScope; + + if (deathCallback) + { + for (var i = 0; i < rip.length; i++) + { + deathCallback.call(deathCallbackScope, rip[i]); + } + } + + this.dead.concat(rip); + + StableSort.inplace(particles, this.indexSortCallback); + } + + if (!this.on) + { + return; + } + + if (this.frequency === 0) + { + this.emitParticle(); + } + else if (this.frequency > 0) + { + this._counter -= delta; + + if (this._counter <= 0) + { + this.emitParticle(); + + // counter = frequency - remained from previous delta + this._counter = (this.frequency - Math.abs(this._counter)); + } + } + }, + + /** + * Calculates the difference of two particles, for sorting them by depth. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback + * @since 3.0.0 + * + * @param {object} a - The first particle. + * @param {object} b - The second particle. + * + * @return {integer} The difference of a and b's y coordinates. + */ + depthSortCallback: function (a, b) + { + return a.y - b.y; + }, + + /** + * Calculates the difference of two particles, for sorting them by index. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback + * @since 3.0.0 + * + * @param {object} a - The first particle. + * @param {object} b - The second particle. + * + * @return {integer} The difference of a and b's `index` properties. + */ + indexSortCallback: function (a, b) + { + return a.index - b.index; + } + +}); + +module.exports = ParticleEmitter; + + +/***/ }), +/* 303 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var DegToRad = __webpack_require__(31); +var DistanceBetween = __webpack_require__(52); + +/** + * @classdesc + * A Particle is a simple Game Object controlled by a Particle Emitter and Manager, and rendered by the Manager. + * It uses its own lightweight physics system, and can interact only with its Emitter's bounds and zones. + * + * @class Particle + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to which this Particle belongs. + */ +var Particle = new Class({ + + initialize: + + function Particle (emitter) + { + /** + * The Emitter to which this Particle belongs. + * + * A Particle can only belong to a single Emitter and is created, updated and destroyed via it. + * + * @name Phaser.GameObjects.Particles.Particle#emitter + * @type {Phaser.GameObjects.Particles.ParticleEmitter} + * @since 3.0.0 + */ + this.emitter = emitter; + + /** + * The texture frame used to render this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#frame + * @type {Phaser.Textures.Frame} + * @default null + * @since 3.0.0 + */ + this.frame = null; + + /** + * The position of this Particle within its Emitter's particle pool. + * + * @name Phaser.GameObjects.Particles.Particle#index + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.index = 0; + + /** + * The x coordinate of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y coordinate of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The x velocity of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#velocityX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.velocityX = 0; + + /** + * The y velocity of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#velocityY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.velocityY = 0; + + /** + * The x acceleration of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#accelerationX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationX = 0; + + /** + * The y acceleration of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#accelerationY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accelerationY = 0; + + /** + * The maximum horizontal velocity this Particle can travel at. + * + * @name Phaser.GameObjects.Particles.Particle#maxVelocityX + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityX = 10000; + + /** + * The maximum vertical velocity this Particle can travel at. + * + * @name Phaser.GameObjects.Particles.Particle#maxVelocityY + * @type {number} + * @default 10000 + * @since 3.0.0 + */ + this.maxVelocityY = 10000; + + /** + * The bounciness, or restitution, of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#bounce + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.bounce = 0; + + /** + * The horizontal scale of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.scaleX = 1; + + /** + * The vertical scale of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.scaleY = 1; + + /** + * The alpha value of this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#alpha + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.alpha = 1; + + /** + * The angle of this Particle in degrees. + * + * @name Phaser.GameObjects.Particles.Particle#angle + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.angle = 0; + + /** + * The angle of this Particle in radians. + * + * @name Phaser.GameObjects.Particles.Particle#rotation + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.rotation = 0; + + /** + * The tint applied to this Particle. + * + * @name Phaser.GameObjects.Particles.Particle#tint + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + this.tint = 0xffffff; + + /** + * The lifespan of this Particle in ms. + * + * @name Phaser.GameObjects.Particles.Particle#life + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.life = 1000; + + /** + * The current life of this Particle in ms. + * + * @name Phaser.GameObjects.Particles.Particle#lifeCurrent + * @type {number} + * @default 1000 + * @since 3.0.0 + */ + this.lifeCurrent = 1000; + + /** + * The delay applied to this Particle upon emission, in ms. + * + * @name Phaser.GameObjects.Particles.Particle#delayCurrent + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.delayCurrent = 0; + + /** + * The normalized lifespan T value, where 0 is the start and 1 is the end. + * + * @name Phaser.GameObjects.Particles.Particle#lifeT + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lifeT = 0; + + /** + * The data used by the ease equation. + * + * @name Phaser.GameObjects.Particles.Particle#data + * @type {object} + * @since 3.0.0 + */ + this.data = { + tint: { min: 0xffffff, max: 0xffffff, current: 0xffffff }, + alpha: { min: 1, max: 1 }, + rotate: { min: 0, max: 0 }, + scaleX: { min: 1, max: 1 }, + scaleY: { min: 1, max: 1 } + }; + }, + + /** + * Checks to see if this Particle is alive and updating. + * + * @method Phaser.GameObjects.Particles.Particle#isAlive + * @since 3.0.0 + * + * @return {boolean} `true` if this Particle is alive and updating, otherwise `false`. + */ + isAlive: function () + { + return (this.lifeCurrent > 0); + }, + + /** + * Starts this Particle from the given coordinates. + * + * @method Phaser.GameObjects.Particles.Particle#fire + * @since 3.0.0 + * + * @param {number} x - The x coordinate to launch this Particle from. + * @param {number} y - The y coordinate to launch this Particle from. + */ + fire: function (x, y) + { + var emitter = this.emitter; + + this.frame = emitter.getFrame(); + + if (emitter.emitZone) + { + // Updates particle.x and particle.y during this call + emitter.emitZone.getPoint(this); + } + + if (x === undefined) + { + if (emitter.follow) + { + this.x += emitter.follow.x + emitter.followOffset.x; + } + + this.x += emitter.x.onEmit(this, 'x'); + } + else + { + this.x += x; + } + + if (y === undefined) + { + if (emitter.follow) + { + this.y += emitter.follow.y + emitter.followOffset.y; + } + + this.y += emitter.y.onEmit(this, 'y'); + } + else + { + this.y += y; + } + + this.life = emitter.lifespan.onEmit(this, 'lifespan'); + this.lifeCurrent = this.life; + this.lifeT = 0; + + var sx = emitter.speedX.onEmit(this, 'speedX'); + var sy = (emitter.speedY) ? emitter.speedY.onEmit(this, 'speedY') : sx; + + if (emitter.radial) + { + var rad = DegToRad(emitter.angle.onEmit(this, 'angle')); + + this.velocityX = Math.cos(rad) * Math.abs(sx); + this.velocityY = Math.sin(rad) * Math.abs(sy); + } + else if (emitter.moveTo) + { + var mx = emitter.moveToX.onEmit(this, 'moveToX'); + var my = (emitter.moveToY) ? emitter.moveToY.onEmit(this, 'moveToY') : mx; + + var angle = Math.atan2(my - this.y, mx - this.x); + + var speed = DistanceBetween(this.x, this.y, mx, my) / (this.life / 1000); + + // We know how many pixels we need to move, but how fast? + // var speed = this.distanceToXY(displayObject, x, y) / (maxTime / 1000); + + this.velocityX = Math.cos(angle) * speed; + this.velocityY = Math.sin(angle) * speed; + } + else + { + this.velocityX = sx; + this.velocityY = sy; + } + + if (emitter.acceleration) + { + this.accelerationX = emitter.accelerationX.onEmit(this, 'accelerationX'); + this.accelerationY = emitter.accelerationY.onEmit(this, 'accelerationY'); + } + + this.maxVelocityX = emitter.maxVelocityX.onEmit(this, 'maxVelocityX'); + this.maxVelocityY = emitter.maxVelocityY.onEmit(this, 'maxVelocityY'); + + this.delayCurrent = emitter.delay.onEmit(this, 'delay'); + + this.scaleX = emitter.scaleX.onEmit(this, 'scaleX'); + this.scaleY = (emitter.scaleY) ? emitter.scaleY.onEmit(this, 'scaleY') : this.scaleX; + + this.angle = emitter.rotate.onEmit(this, 'rotate'); + this.rotation = DegToRad(this.angle); + + this.bounce = emitter.bounce.onEmit(this, 'bounce'); + + this.alpha = emitter.alpha.onEmit(this, 'alpha'); + + this.tint = emitter.tint.onEmit(this, 'tint'); + + this.index = emitter.alive.length; + }, + + /** + * An internal method that calculates the velocity of the Particle. + * + * @method Phaser.GameObjects.Particles.Particle#computeVelocity + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter that is updating this Particle. + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + * @param {array} processors - Particle processors (gravity wells). + */ + computeVelocity: function (emitter, delta, step, processors) + { + var vx = this.velocityX; + var vy = this.velocityY; + + var ax = this.accelerationX; + var ay = this.accelerationY; + + var mx = this.maxVelocityX; + var my = this.maxVelocityY; + + vx += (emitter.gravityX * step); + vy += (emitter.gravityY * step); + + if (ax) + { + vx += (ax * step); + } + + if (ay) + { + vy += (ay * step); + } + + if (vx > mx) + { + vx = mx; + } + else if (vx < -mx) + { + vx = -mx; + } + + if (vy > my) + { + vy = my; + } + else if (vy < -my) + { + vy = -my; + } + + this.velocityX = vx; + this.velocityY = vy; + + // Apply any additional processors + for (var i = 0; i < processors.length; i++) + { + processors[i].update(this, delta, step); + } + }, + + /** + * Checks if this Particle is still within the bounds defined by the given Emitter. + * + * If not, and depending on the Emitter collision flags, the Particle may either stop or rebound. + * + * @method Phaser.GameObjects.Particles.Particle#checkBounds + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to check the bounds against. + */ + checkBounds: function (emitter) + { + var bounds = emitter.bounds; + var bounce = -this.bounce; + + if (this.x < bounds.x && emitter.collideLeft) + { + this.x = bounds.x; + this.velocityX *= bounce; + } + else if (this.x > bounds.right && emitter.collideRight) + { + this.x = bounds.right; + this.velocityX *= bounce; + } + + if (this.y < bounds.y && emitter.collideTop) + { + this.y = bounds.y; + this.velocityY *= bounce; + } + else if (this.y > bounds.bottom && emitter.collideBottom) + { + this.y = bounds.bottom; + this.velocityY *= bounce; + } + }, + + /** + * The main update method for this Particle. + * + * Updates its life values, computes the velocity and repositions the Particle. + * + * @method Phaser.GameObjects.Particles.Particle#update + * @since 3.0.0 + * + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + * @param {array} processors - An optional array of update processors. + * + * @return {boolean} Returns `true` if this Particle has now expired and should be removed, otherwise `false` if still active. + */ + update: function (delta, step, processors) + { + if (this.delayCurrent > 0) + { + this.delayCurrent -= delta; + + return false; + } + + var emitter = this.emitter; + + // How far along in life is this particle? (t = 0 to 1) + var t = 1 - (this.lifeCurrent / this.life); + + this.lifeT = t; + + this.computeVelocity(emitter, delta, step, processors); + + this.x += this.velocityX * step; + this.y += this.velocityY * step; + + if (emitter.bounds) + { + this.checkBounds(emitter); + } + + if (emitter.deathZone && emitter.deathZone.willKill(this)) + { + this.lifeCurrent = 0; + + // No need to go any further, particle has been killed + return true; + } + + this.scaleX = emitter.scaleX.onUpdate(this, 'scaleX', t, this.scaleX); + + if (emitter.scaleY) + { + this.scaleY = emitter.scaleY.onUpdate(this, 'scaleY', t, this.scaleY); + } + else + { + this.scaleY = this.scaleX; + } + + this.angle = emitter.rotate.onUpdate(this, 'rotate', t, this.angle); + this.rotation = DegToRad(this.angle); + + this.alpha = emitter.alpha.onUpdate(this, 'alpha', t, this.alpha); + + this.tint = emitter.tint.onUpdate(this, 'tint', t, this.tint); + + this.lifeCurrent -= delta; + + return (this.lifeCurrent <= 0); + } + +}); + +module.exports = Particle; + + +/***/ }), +/* 304 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetFastValue = __webpack_require__(2); + +/** + * @typedef {object} GravityWellConfig + * + * @property {number} [x=0] - The x coordinate of the Gravity Well, in world space. + * @property {number} [y=0] - The y coordinate of the Gravity Well, in world space. + * @property {number} [power=0] - The power of the Gravity Well. + * @property {number} [epsilon=100] - [description] + * @property {number} [gravity=50] - The gravitational force of this Gravity Well. + */ + +/** + * @classdesc + * [description] + * + * @class GravityWell + * @memberof Phaser.GameObjects.Particles + * @constructor + * @since 3.0.0 + * + * @param {(number|GravityWellConfig)} [x=0] - The x coordinate of the Gravity Well, in world space. + * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. + * @param {number} [power=0] - The power of the Gravity Well. + * @param {number} [epsilon=100] - [description] + * @param {number} [gravity=50] - The gravitational force of this Gravity Well. + */ +var GravityWell = new Class({ + + initialize: + + function GravityWell (x, y, power, epsilon, gravity) + { + if (typeof x === 'object') + { + var config = x; + + x = GetFastValue(config, 'x', 0); + y = GetFastValue(config, 'y', 0); + power = GetFastValue(config, 'power', 0); + epsilon = GetFastValue(config, 'epsilon', 100); + gravity = GetFastValue(config, 'gravity', 50); + } + else + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (power === undefined) { power = 0; } + if (epsilon === undefined) { epsilon = 100; } + if (gravity === undefined) { gravity = 50; } + } + + /** + * The x coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y coordinate of the Gravity Well, in world space. + * + * @name Phaser.GameObjects.Particles.GravityWell#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. + * + * @name Phaser.GameObjects.Particles.GravityWell#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * Internal gravity value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_gravity + * @type {number} + * @private + * @since 3.0.0 + */ + this._gravity = gravity; + + /** + * Internal power value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_power + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._power = 0; + + /** + * Internal epsilon value. + * + * @name Phaser.GameObjects.Particles.GravityWell#_epsilon + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._epsilon = 0; + + /** + * The power of the Gravity Well. + * + * @name Phaser.GameObjects.Particles.GravityWell#power + * @type {number} + * @since 3.0.0 + */ + this.power = power; + + /** + * [description] + * + * @name Phaser.GameObjects.Particles.GravityWell#epsilon + * @type {number} + * @since 3.0.0 + */ + this.epsilon = epsilon; + }, + + /** + * Takes a Particle and updates it based on the properties of this Gravity Well. + * + * @method Phaser.GameObjects.Particles.GravityWell#update + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. + * @param {number} delta - The delta time in ms. + * @param {number} step - The delta value divided by 1000. + */ + update: function (particle, delta) + { + var x = this.x - particle.x; + var y = this.y - particle.y; + var dSq = x * x + y * y; + + if (dSq === 0) + { + return; + } + + var d = Math.sqrt(dSq); + + if (dSq < this._epsilon) + { + dSq = this._epsilon; + } + + var factor = ((this._power * delta) / (dSq * d)) * 100; + + particle.velocityX += x * factor; + particle.velocityY += y * factor; + }, + + epsilon: { + + get: function () + { + return Math.sqrt(this._epsilon); + }, + + set: function (value) + { + this._epsilon = value * value; + } + + }, + + power: { + + get: function () + { + return this._power / this._gravity; + }, + + set: function (value) + { + this._power = value * this._gravity; + } + + }, + + gravity: { + + get: function () + { + return this._gravity; + }, + + set: function (value) + { + var pwr = this.power; + this._gravity = value; + this.power = pwr; + } + + } + +}); + +module.exports = GravityWell; + + +/***/ }), +/* 305 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Commands = __webpack_require__(157); +var SetTransform = __webpack_require__(22); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -40144,66 +75258,35 @@ var GameObject = __webpack_require__(2); * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested * @param {CanvasRenderingContext2D} [renderTargetCtx] - The target rendering context. - * @param {boolean} allowClip - [description] + * @param {boolean} allowClip - If `true` then path operations will be used instead of fill operations. */ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + var commandBuffer = src.commandBuffer; + var commandBufferLength = commandBuffer.length; + + var ctx = renderTargetCtx || renderer.currentContext; + + if (commandBufferLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) { return; } - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - var srcX = src.x; - var srcY = src.y; - var srcScaleX = src.scaleX; - var srcScaleY = src.scaleY; - var srcRotation = src.rotation; - var commandBuffer = src.commandBuffer; - var ctx = renderTargetCtx || renderer.currentContext; - var lineAlpha = 1.0; - var fillAlpha = 1.0; + var lineAlpha = 1; + var fillAlpha = 1; var lineColor = 0; var fillColor = 0; - var lineWidth = 1.0; + var lineWidth = 1; var red = 0; var green = 0; var blue = 0; - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - ctx.save(); - if (parentMatrix) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); - ctx.rotate(srcRotation); - ctx.scale(srcScaleX, srcScaleY); - ctx.fillStyle = '#fff'; - ctx.globalAlpha = src.alpha; - for (var index = 0, length = commandBuffer.length; index < length; ++index) + // Reset any currently active paths + ctx.beginPath(); + + for (var index = 0; index < commandBufferLength; ++index) { var commandID = commandBuffer[index]; @@ -40218,7 +75301,9 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c commandBuffer[index + 5], commandBuffer[index + 6] ); - index += 6; + + // +7 because overshoot is the 7th value, not used in Canvas + index += 7; break; case Commands.LINE_STYLE: @@ -40376,8 +75461,16 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c index += 1; break; - default: - // console.error('Phaser: Invalid Graphics Command ID ' + commandID); + case Commands.GRADIENT_FILL_STYLE: + index += 5; + break; + + case Commands.GRADIENT_LINE_STYLE: + index += 6; + break; + + case Commands.SET_TEXTURE: + index += 2; break; } } @@ -40389,7 +75482,7 @@ module.exports = GraphicsCanvasRenderer; /***/ }), -/* 177 */ +/* 306 */ /***/ (function(module, exports) { /** @@ -40421,7 +75514,7 @@ module.exports = Circumference; /***/ }), -/* 178 */ +/* 307 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40430,9 +75523,9 @@ module.exports = Circumference; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circumference = __webpack_require__(177); -var CircumferencePoint = __webpack_require__(113); -var FromPercent = __webpack_require__(65); +var Circumference = __webpack_require__(306); +var CircumferencePoint = __webpack_require__(156); +var FromPercent = __webpack_require__(93); var MATH_CONST = __webpack_require__(16); /** @@ -40475,7 +75568,7 @@ module.exports = GetPoints; /***/ }), -/* 179 */ +/* 308 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40484,10 +75577,10 @@ module.exports = GetPoints; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CircumferencePoint = __webpack_require__(113); -var FromPercent = __webpack_require__(65); +var CircumferencePoint = __webpack_require__(156); +var FromPercent = __webpack_require__(93); var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); +var Point = __webpack_require__(6); /** * Returns a Point object containing the coordinates of a point on the circumference of the Ellipse @@ -40500,7 +75593,7 @@ var Point = __webpack_require__(5); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. @@ -40518,7 +75611,419 @@ module.exports = GetPoint; /***/ }), -/* 180 */ +/* 309 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. + * + * @function Phaser.Geom.Rectangle.Union + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to use. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to use. + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the union in. + * + * @return {Phaser.Geom.Rectangle} The modified `out` Rectangle, or a new Rectangle if none was provided. + */ +var Union = function (rectA, rectB, out) +{ + if (out === undefined) { out = new Rectangle(); } + + // Cache vars so we can use one of the input rects as the output rect + var x = Math.min(rectA.x, rectB.x); + var y = Math.min(rectA.y, rectB.y); + var w = Math.max(rectA.right, rectB.right) - x; + var h = Math.max(rectA.bottom, rectB.bottom) - y; + + return out.setTo(x, y, w, h); +}; + +module.exports = Union; + + +/***/ }), +/* 310 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Read an integer value from an XML Node. + * + * @function getValue + * @since 3.0.0 + * @private + * + * @param {Node} node - The XML Node. + * @param {string} attribute - The attribute to read. + * + * @return {integer} The parsed value. + */ +function getValue (node, attribute) +{ + return parseInt(node.getAttribute(attribute), 10); +} + +/** + * Parse an XML font to Bitmap Font data for the Bitmap Font cache. + * + * @function ParseXMLBitmapFont + * @since 3.0.0 + * @private + * + * @param {XMLDocument} xml - The XML Document to parse the font from. + * @param {integer} [xSpacing=0] - The x-axis spacing to add between each letter. + * @param {integer} [ySpacing=0] - The y-axis spacing to add to the line height. + * @param {Phaser.Textures.Frame} [frame] - The texture frame to take into account while parsing. + * + * @return {BitmapFontData} The parsed Bitmap Font data. + */ +var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame) +{ + if (xSpacing === undefined) { xSpacing = 0; } + if (ySpacing === undefined) { ySpacing = 0; } + + var data = {}; + var info = xml.getElementsByTagName('info')[0]; + var common = xml.getElementsByTagName('common')[0]; + + data.font = info.getAttribute('face'); + data.size = getValue(info, 'size'); + data.lineHeight = getValue(common, 'lineHeight') + ySpacing; + data.chars = {}; + + var letters = xml.getElementsByTagName('char'); + + var adjustForTrim = (frame !== undefined && frame.trimmed); + + if (adjustForTrim) + { + var top = frame.height; + var left = frame.width; + } + + for (var i = 0; i < letters.length; i++) + { + var node = letters[i]; + + var charCode = getValue(node, 'id'); + var gx = getValue(node, 'x'); + var gy = getValue(node, 'y'); + var gw = getValue(node, 'width'); + var gh = getValue(node, 'height'); + + // Handle frame trim issues + + if (adjustForTrim) + { + if (gx < left) + { + left = gx; + } + + if (gy < top) + { + top = gy; + } + } + + data.chars[charCode] = + { + x: gx, + y: gy, + width: gw, + height: gh, + centerX: Math.floor(gw / 2), + centerY: Math.floor(gh / 2), + xOffset: getValue(node, 'xoffset'), + yOffset: getValue(node, 'yoffset'), + xAdvance: getValue(node, 'xadvance') + xSpacing, + data: {}, + kerning: {} + }; + } + + if (adjustForTrim && top !== 0 && left !== 0) + { + // console.log('top and left', top, left, frame.x, frame.y); + + // Now we know the top and left coordinates of the glyphs in the original data + // so we can work out how much to adjust the glyphs by + + for (var code in data.chars) + { + var glyph = data.chars[code]; + + glyph.x -= frame.x; + glyph.y -= frame.y; + } + } + + var kernings = xml.getElementsByTagName('kerning'); + + for (i = 0; i < kernings.length; i++) + { + var kern = kernings[i]; + + var first = getValue(kern, 'first'); + var second = getValue(kern, 'second'); + var amount = getValue(kern, 'amount'); + + data.chars[second].kerning[first] = amount; + } + + return data; +}; + +module.exports = ParseXMLBitmapFont; + + +/***/ }), +/* 311 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAdvancedValue = __webpack_require__(12); + +/** + * Adds an Animation component to a Sprite and populates it based on the given config. + * + * @function Phaser.GameObjects.BuildGameObjectAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - The sprite to add an Animation component to. + * @param {object} config - The animation config. + * + * @return {Phaser.GameObjects.Sprite} The updated Sprite. + */ +var BuildGameObjectAnimation = function (sprite, config) +{ + var animConfig = GetAdvancedValue(config, 'anims', null); + + if (animConfig === null) + { + return sprite; + } + + if (typeof animConfig === 'string') + { + // { anims: 'key' } + sprite.anims.play(animConfig); + } + else if (typeof animConfig === 'object') + { + // { anims: { + // key: string + // startFrame: [string|integer] + // delay: [float] + // repeat: [integer] + // repeatDelay: [float] + // yoyo: [boolean] + // play: [boolean] + // delayedPlay: [boolean] + // } + // } + + var anims = sprite.anims; + + var key = GetAdvancedValue(animConfig, 'key', undefined); + var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); + + var delay = GetAdvancedValue(animConfig, 'delay', 0); + var repeat = GetAdvancedValue(animConfig, 'repeat', 0); + var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); + var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); + + var play = GetAdvancedValue(animConfig, 'play', false); + var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); + + anims.setDelay(delay); + anims.setRepeat(repeat); + anims.setRepeatDelay(repeatDelay); + anims.setYoyo(yoyo); + + if (play) + { + anims.play(key, startFrame); + } + else if (delayedPlay > 0) + { + anims.delayedPlay(delayedPlay, key, startFrame); + } + else + { + anims.load(key); + } + } + + return sprite; +}; + +module.exports = BuildGameObjectAnimation; + + +/***/ }), +/* 312 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); +var Shuffle = __webpack_require__(122); + +var BuildChunk = function (a, b, qty) +{ + var out = []; + + for (var aIndex = 0; aIndex < a.length; aIndex++) + { + for (var bIndex = 0; bIndex < b.length; bIndex++) + { + for (var i = 0; i < qty; i++) + { + out.push({ a: a[aIndex], b: b[bIndex] }); + } + } + } + + return out; +}; + +// options = repeat, random, randomB, yoyo, max, qty + +// Range ([a,b,c], [1,2,3]) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2,3], qty = 3) = +// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 + +// Range ([a,b,c], [1,2,3], repeat x1) = +// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 + +// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = +// Maybe if max is set then repeat goes to -1 automatically? +// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) + +// Range ([a], [1,2,3,4,5], random = true) = +// a4, a1, a5, a2, a3 + +// Range ([a, b], [1,2,3], random = true) = +// b3, a2, a1, b1, a3, b2 + +// Range ([a, b, c], [1,2,3], randomB = true) = +// a3, a1, a2, b2, b3, b1, c1, c3, c2 + +// Range ([a], [1,2,3,4,5], yoyo = true) = +// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 + +// Range ([a, b], [1,2,3], yoyo = true) = +// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 + +/** + * [description] + * + * @function Phaser.Utils.Array.Range + * @since 3.0.0 + * + * @param {array} a - [description] + * @param {array} b - [description] + * @param {object} options - [description] + * + * @return {array} [description] + */ +var Range = function (a, b, options) +{ + var max = GetValue(options, 'max', 0); + var qty = GetValue(options, 'qty', 1); + var random = GetValue(options, 'random', false); + var randomB = GetValue(options, 'randomB', false); + var repeat = GetValue(options, 'repeat', 0); + var yoyo = GetValue(options, 'yoyo', false); + + var out = []; + + if (randomB) + { + Shuffle(b); + } + + // Endless repeat, so limit by max + if (repeat === -1) + { + if (max === 0) + { + repeat = 0; + } + else + { + // Work out how many repeats we need + var total = (a.length * b.length) * qty; + + if (yoyo) + { + total *= 2; + } + + repeat = Math.ceil(max / total); + } + } + + for (var i = 0; i <= repeat; i++) + { + var chunk = BuildChunk(a, b, qty); + + if (random) + { + Shuffle(chunk); + } + + out = out.concat(chunk); + + if (yoyo) + { + chunk.reverse(); + + out = out.concat(chunk); + } + } + + if (max) + { + out.splice(max); + } + + return out; +}; + +module.exports = Range; + + +/***/ }), +/* 313 */ /***/ (function(module, exports) { /** @@ -40636,7 +76141,36 @@ module.exports = QuickSelect; /***/ }), -/* 181 */ +/* 314 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Round a given number so it is further away from zero. That is, positive numbers are rounded up, and negative numbers are rounded down. + * + * @function Phaser.Math.RoundAwayFromZero + * @since 3.0.0 + * + * @param {number} value - The number to round. + * + * @return {number} The rounded number, rounded away from zero. + */ +var RoundAwayFromZero = function (value) +{ + // "Opposite" of truncate. + return (value > 0) ? Math.ceil(value) : Math.floor(value); +}; + +module.exports = RoundAwayFromZero; + + +/***/ }), +/* 315 */ /***/ (function(module, exports) { /** @@ -40682,7 +76216,7 @@ module.exports = TransposeMatrix; /***/ }), -/* 182 */ +/* 316 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40697,20 +76231,20 @@ module.exports = TransposeMatrix; module.exports = { - AtlasXML: __webpack_require__(514), - Canvas: __webpack_require__(513), - Image: __webpack_require__(512), - JSONArray: __webpack_require__(511), - JSONHash: __webpack_require__(510), - SpriteSheet: __webpack_require__(509), - SpriteSheetFromAtlas: __webpack_require__(508), - UnityYAML: __webpack_require__(507) + AtlasXML: __webpack_require__(886), + Canvas: __webpack_require__(885), + Image: __webpack_require__(884), + JSONArray: __webpack_require__(883), + JSONHash: __webpack_require__(882), + SpriteSheet: __webpack_require__(881), + SpriteSheetFromAtlas: __webpack_require__(880), + UnityYAML: __webpack_require__(879) }; /***/ }), -/* 183 */ +/* 317 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40719,10 +76253,10 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CanvasPool = __webpack_require__(22); +var CanvasPool = __webpack_require__(24); var Class = __webpack_require__(0); -var IsSizePowerOfTwo = __webpack_require__(85); -var ScaleModes = __webpack_require__(59); +var IsSizePowerOfTwo = __webpack_require__(117); +var ScaleModes = __webpack_require__(94); /** * @classdesc @@ -40732,7 +76266,7 @@ var ScaleModes = __webpack_require__(59); * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. * * @class TextureSource - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * @@ -40762,13 +76296,24 @@ var TextureSource = new Class({ * The Texture this TextureSource belongs to. * * @name Phaser.Textures.TextureSource#texture - * @type {string} + * @type {Phaser.Textures.Texture} * @since 3.0.0 */ this.texture = texture; /** - * The source image data. This is either an Image Element, or a Canvas Element. + * The source of the image data. + * This is either an Image Element, a Canvas Element or a RenderTexture. + * + * @name Phaser.Textures.TextureSource#source + * @type {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)} + * @since 3.12.0 + */ + this.source = source; + + /** + * The image data. + * This is either an Image element or a Canvas element. * * @name Phaser.Textures.TextureSource#image * @type {(HTMLImageElement|HTMLCanvasElement)} @@ -40835,6 +76380,15 @@ var TextureSource = new Class({ */ this.isCanvas = (source instanceof HTMLCanvasElement); + /** + * Is the source image a Render Texture? + * + * @name Phaser.Textures.TextureSource#isRenderTexture + * @type {boolean} + * @since 3.12.0 + */ + this.isRenderTexture = (source.type === 'RenderTexture'); + /** * Are the source image dimensions a power of two? * @@ -40867,19 +76421,32 @@ var TextureSource = new Class({ */ init: function (game) { - if (this.renderer && this.renderer.gl) + if (this.renderer) { - if (this.isCanvas) + if (this.renderer.gl) { - this.glTexture = this.renderer.canvasToTexture(this.image); + if (this.isCanvas) + { + this.glTexture = this.renderer.canvasToTexture(this.image); + } + else if (this.isRenderTexture) + { + this.image = this.source.canvas; + + this.glTexture = this.renderer.createTextureFromSource(null, this.width, this.height, this.scaleMode); + } + else + { + this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + } } - else + else if (this.isRenderTexture) { - this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + this.image = this.source.canvas; } } - if (game.config.pixelArt) + if (!game.config.antialias) { this.setFilter(1); } @@ -40916,7 +76483,20 @@ var TextureSource = new Class({ { if (this.renderer.gl && this.isCanvas) { - this.renderer.canvasToTexture(this.image, this.glTexture); + this.glTexture = this.renderer.canvasToTexture(this.image, this.glTexture); + + // Update all the Frames using this TextureSource + + /* + var index = this.texture.getTextureSourceIndex(this); + + var frames = this.texture.getFramesFromTextureSource(index, true); + + for (var i = 0; i < frames.length; i++) + { + frames[i].glTexture = this.glTexture; + } + */ } }, @@ -40940,7 +76520,9 @@ var TextureSource = new Class({ this.renderer = null; this.texture = null; + this.source = null; this.image = null; + this.glTexture = null; } }); @@ -40949,7 +76531,7 @@ module.exports = TextureSource; /***/ }), -/* 184 */ +/* 318 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -40958,21 +76540,21 @@ module.exports = TextureSource; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CanvasPool = __webpack_require__(22); -var CanvasTexture = __webpack_require__(515); +var CanvasPool = __webpack_require__(24); +var CanvasTexture = __webpack_require__(887); var Class = __webpack_require__(0); -var Color = __webpack_require__(30); -var CONST = __webpack_require__(20); -var EventEmitter = __webpack_require__(9); -var GenerateTexture = __webpack_require__(276); +var Color = __webpack_require__(37); +var CONST = __webpack_require__(26); +var EventEmitter = __webpack_require__(11); +var GenerateTexture = __webpack_require__(357); var GetValue = __webpack_require__(4); -var Parser = __webpack_require__(182); -var Texture = __webpack_require__(117); +var Parser = __webpack_require__(316); +var Texture = __webpack_require__(165); /** * @callback EachTextureCallback * - * @param {Phaser.Textures.Texture} texture - [description] + * @param {Phaser.Textures.Texture} texture - Each texture in Texture Manager. * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. */ @@ -40987,11 +76569,11 @@ var Texture = __webpack_require__(117); * * @class TextureManager * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - The Phaser.Game instance this Texture Manager belongs to. */ var TextureManager = new Class({ @@ -41004,7 +76586,7 @@ var TextureManager = new Class({ EventEmitter.call(this); /** - * [description] + * The Game that this TextureManager belongs to. * * @name Phaser.Textures.TextureManager#game * @type {Phaser.Game} @@ -41013,7 +76595,7 @@ var TextureManager = new Class({ this.game = game; /** - * [description] + * The name of this manager. * * @name Phaser.Textures.TextureManager#name * @type {string} @@ -41022,7 +76604,8 @@ var TextureManager = new Class({ this.name = 'TextureManager'; /** - * [description] + * An object that has all of textures that Texture Manager creates. + * Textures are assigned to keys so we can access to any texture that this object has directly by key value without iteration. * * @name Phaser.Textures.TextureManager#list * @type {object} @@ -41032,7 +76615,7 @@ var TextureManager = new Class({ this.list = {}; /** - * [description] + * The temporary canvas element to save an pixel data of an arbitrary texture in getPixel() and getPixelAlpha() method. * * @name Phaser.Textures.TextureManager#_tempCanvas * @type {HTMLCanvasElement} @@ -41042,7 +76625,7 @@ var TextureManager = new Class({ this._tempCanvas = CanvasPool.create2D(this, 1, 1); /** - * [description] + * The context of the temporary canvas element made to save an pixel data in getPixel() and getPixelAlpha() method. * * @name Phaser.Textures.TextureManager#_tempContext * @type {CanvasRenderingContext2D} @@ -41052,7 +76635,7 @@ var TextureManager = new Class({ this._tempContext = this._tempCanvas.getContext('2d'); /** - * [description] + * An counting value used for emitting 'ready' event after all of managers in game is loaded. * * @name Phaser.Textures.TextureManager#_pending * @type {integer} @@ -41066,9 +76649,10 @@ var TextureManager = new Class({ }, /** - * [description] + * The Boot Handler called by Phaser.Game when it first starts up. * * @method Phaser.Textures.TextureManager#boot + * @private * @since 3.0.0 */ boot: function () @@ -41085,9 +76669,10 @@ var TextureManager = new Class({ }, /** - * [description] + * After 'onload' or 'onerror' invoked twice, emit 'ready' event. * * @method Phaser.Textures.TextureManager#updatePending + * @private * @since 3.0.0 */ updatePending: function () @@ -41099,7 +76684,7 @@ var TextureManager = new Class({ this.off('onload'); this.off('onerror'); - this.game.events.emit('ready'); + this.game.events.emit('texturesready'); } }, @@ -41179,6 +76764,8 @@ var TextureManager = new Class({ * * @param {string} key - The unique string-based key of the Texture. * @param {*} data - The Base64 encoded data. + * + * @return {this} This Texture Manager instance. */ addBase64: function (key, data) { @@ -41206,6 +76793,59 @@ var TextureManager = new Class({ image.src = data; } + + return this; + }, + + /** + * Gets an existing texture frame and converts it into a base64 encoded image and returns the base64 data. + * + * You can also provide the image type and encoder options. + * + * @method Phaser.Textures.TextureManager#getBase64 + * @since 3.12.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. + * @param {string} [type='image/png'] - [description] + * @param {number} [encoderOptions=0.92] - [description] + * + * @return {string} The base64 encoded data, or an empty string if the texture frame could not be found. + */ + getBase64: function (key, frame, type, encoderOptions) + { + if (type === undefined) { type = 'image/png'; } + if (encoderOptions === undefined) { encoderOptions = 0.92; } + + var data = ''; + + var textureFrame = this.getFrame(key, frame); + + if (textureFrame) + { + var cd = textureFrame.canvasData; + + var canvas = CanvasPool.create2D(this, cd.width, cd.height); + var ctx = canvas.getContext('2d'); + + ctx.drawImage( + textureFrame.source.image, + cd.x, + cd.y, + cd.width, + cd.height, + 0, + 0, + cd.width, + cd.height + ); + + data = canvas.toDataURL(type, encoderOptions); + + CanvasPool.remove(canvas); + } + + return data; }, /** @@ -41241,6 +76881,34 @@ var TextureManager = new Class({ return texture; }, + /** + * Adds a Render Texture to the Texture Manager using the given key. + * This allows you to then use the Render Texture as a normal texture for texture based Game Objects like Sprites. + * + * @method Phaser.Textures.TextureManager#addRenderTexture + * @since 3.12.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {Phaser.GameObjects.RenderTexture} renderTexture - The source Render Texture. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addRenderTexture: function (key, renderTexture) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, renderTexture); + + texture.add('__BASE', 0, 0, 0, renderTexture.width, renderTexture.height); + + this.emit('addtexture', key, texture); + } + + return texture; + }, + /** * Creates a new Texture using the given config values. * Generated textures consist of a Canvas element to which the texture data is drawn. @@ -41250,7 +76918,7 @@ var TextureManager = new Class({ * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. - * @param {object} config - [description] + * @param {object} config - The configuration object needed to generate the texture. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -41303,22 +76971,29 @@ var TextureManager = new Class({ }, /** - * Creates a new Canvas Texture object from an existing Canvas element and adds - * it to this Texture Manager. + * Creates a new Canvas Texture object from an existing Canvas element + * and adds it to this Texture Manager, unless `skipCache` is true. * * @method Phaser.Textures.TextureManager#addCanvas * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. * @param {HTMLCanvasElement} source - The Canvas element to form the base of the new Texture. + * @param {boolean} [skipCache=false] - Skip adding this Texture into the Cache? * * @return {?Phaser.Textures.CanvasTexture} The Canvas Texture that was created, or `null` if the key is already in use. */ - addCanvas: function (key, source) + addCanvas: function (key, source, skipCache) { + if (skipCache === undefined) { skipCache = false; } + var texture = null; - if (this.checkKey(key)) + if (skipCache) + { + texture = new CanvasTexture(this, key, source, source.width, source.height); + } + else if (this.checkKey(key)) { texture = new CanvasTexture(this, key, source, source.width, source.height); @@ -41729,7 +77404,7 @@ var TextureManager = new Class({ * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. - * @param {(string|integer)} frame - The string or index of the Frame. + * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. * * @return {Phaser.Textures.Frame} A Texture Frame object. */ @@ -41787,25 +77462,23 @@ var TextureManager = new Class({ if (textureFrame) { - var source = textureFrame.source.image; + // Adjust for trim (if not trimmed x and y are just zero) + x -= textureFrame.x; + y -= textureFrame.y; - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) + var data = textureFrame.data.cut; + + x += data.x; + y += data.y; + + if (x >= data.x && x < data.r && y >= data.y && y < data.b) { - x += textureFrame.cutX; - y += textureFrame.cutY; + var ctx = this._tempContext; - // if (textureFrame.trimmed) - // { - // x -= this.sprite.texture.trim.x; - // y -= this.sprite.texture.trim.y; - // } + ctx.clearRect(0, 0, 1, 1); + ctx.drawImage(textureFrame.source.image, x, y, 1, 1, 0, 0, 1, 1); - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); + var rgb = ctx.getImageData(0, 0, 1, 1); return new Color(rgb.data[0], rgb.data[1], rgb.data[2], rgb.data[3]); } @@ -41835,20 +77508,24 @@ var TextureManager = new Class({ if (textureFrame) { - var source = textureFrame.source.image; + // Adjust for trim (if not trimmed x and y are just zero) + x -= textureFrame.x; + y -= textureFrame.y; - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) + var data = textureFrame.data.cut; + + x += data.x; + y += data.y; + + if (x >= data.x && x < data.r && y >= data.y && y < data.b) { - x += textureFrame.cutX; - y += textureFrame.cutY; - - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); + var ctx = this._tempContext; + ctx.clearRect(0, 0, 1, 1); + ctx.drawImage(textureFrame.source.image, x, y, 1, 1, 0, 0, 1, 1); + + var rgb = ctx.getImageData(0, 0, 1, 1); + return rgb.data[3]; } } @@ -41863,7 +77540,7 @@ var TextureManager = new Class({ * @method Phaser.Textures.TextureManager#setTexture * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the texture would be set on. * @param {string} key - The unique string-based key of the Texture. * @param {(string|integer)} frame - The string or index of the Frame. * @@ -41880,6 +77557,40 @@ var TextureManager = new Class({ return gameObject; }, + /** + * Changes the key being used by a Texture to the new key provided. + * + * The old key is removed, allowing it to be re-used. + * + * Game Objects are linked to Textures by a reference to the Texture object, so + * all existing references will be retained. + * + * @method Phaser.Textures.TextureManager#renameTexture + * @since 3.12.0 + * + * @param {string} currentKey - The current string-based key of the Texture you wish to rename. + * @param {string} newKey - The new unique string-based key to use for the Texture. + * + * @return {boolean} `true` if the Texture key was successfully renamed, otherwise `false`. + */ + renameTexture: function (currentKey, newKey) + { + var texture = this.get(currentKey); + + if (texture && currentKey !== newKey) + { + texture.key = newKey; + + this.list[newKey] = texture; + + delete this.list[currentKey]; + + return true; + } + + return false; + }, + /** * Passes all Textures to the given callback. * @@ -41933,7 +77644,7 @@ module.exports = TextureManager; /***/ }), -/* 185 */ +/* 319 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -41943,7 +77654,7 @@ module.exports = TextureManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSound = __webpack_require__(78); +var BaseSound = __webpack_require__(114); var Class = __webpack_require__(0); /** @@ -41952,7 +77663,7 @@ var Class = __webpack_require__(0); * * @class WebAudioSound * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -42900,7 +78611,7 @@ module.exports = WebAudioSound; /***/ }), -/* 186 */ +/* 320 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -42910,9 +78621,9 @@ module.exports = WebAudioSound; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSoundManager = __webpack_require__(79); +var BaseSoundManager = __webpack_require__(115); var Class = __webpack_require__(0); -var WebAudioSound = __webpack_require__(185); +var WebAudioSound = __webpack_require__(319); /** * @classdesc @@ -42920,7 +78631,7 @@ var WebAudioSound = __webpack_require__(185); * * @class WebAudioSoundManager * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -43227,7 +78938,7 @@ module.exports = WebAudioSoundManager; /***/ }), -/* 187 */ +/* 321 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -43237,10 +78948,10 @@ module.exports = WebAudioSoundManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSound = __webpack_require__(78); +var BaseSound = __webpack_require__(114); var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Extend = __webpack_require__(17); +var EventEmitter = __webpack_require__(11); +var Extend = __webpack_require__(20); /** * @classdesc @@ -43253,7 +78964,7 @@ var Extend = __webpack_require__(17); * * @class NoAudioSound * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -43354,7 +79065,7 @@ module.exports = NoAudioSound; /***/ }), -/* 188 */ +/* 322 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -43364,11 +79075,11 @@ module.exports = NoAudioSound; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSoundManager = __webpack_require__(79); +var BaseSoundManager = __webpack_require__(115); var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var NoAudioSound = __webpack_require__(187); -var NOOP = __webpack_require__(3); +var EventEmitter = __webpack_require__(11); +var NoAudioSound = __webpack_require__(321); +var NOOP = __webpack_require__(1); /** * @classdesc @@ -43381,7 +79092,7 @@ var NOOP = __webpack_require__(3); * * @class NoAudioSoundManager * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -43472,7 +79183,7 @@ module.exports = NoAudioSoundManager; /***/ }), -/* 189 */ +/* 323 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -43482,7 +79193,7 @@ module.exports = NoAudioSoundManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSound = __webpack_require__(78); +var BaseSound = __webpack_require__(114); var Class = __webpack_require__(0); /** @@ -43491,7 +79202,7 @@ var Class = __webpack_require__(0); * * @class HTML5AudioSound * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -44454,7 +80165,7 @@ module.exports = HTML5AudioSound; /***/ }), -/* 190 */ +/* 324 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -44464,16 +80175,16 @@ module.exports = HTML5AudioSound; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseSoundManager = __webpack_require__(79); +var BaseSoundManager = __webpack_require__(115); var Class = __webpack_require__(0); -var HTML5AudioSound = __webpack_require__(189); +var HTML5AudioSound = __webpack_require__(323); /** * HTML5 Audio implementation of the Sound Manager. * * @class HTML5AudioSoundManager * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -44921,7 +80632,7 @@ module.exports = HTML5AudioSoundManager; /***/ }), -/* 191 */ +/* 325 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -44931,9 +80642,9 @@ module.exports = HTML5AudioSoundManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var HTML5AudioSoundManager = __webpack_require__(190); -var NoAudioSoundManager = __webpack_require__(188); -var WebAudioSoundManager = __webpack_require__(186); +var HTML5AudioSoundManager = __webpack_require__(324); +var NoAudioSoundManager = __webpack_require__(322); +var WebAudioSoundManager = __webpack_require__(320); /** * Creates a Web Audio, HTML5 Audio or No Audio Sound Manager based on config and device settings. @@ -44971,7 +80682,7 @@ module.exports = SoundManagerCreator; /***/ }), -/* 192 */ +/* 326 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -44980,10 +80691,10 @@ module.exports = SoundManagerCreator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(55); +var CONST = __webpack_require__(116); var GetValue = __webpack_require__(4); -var Merge = __webpack_require__(94); -var InjectionMap = __webpack_require__(516); +var Merge = __webpack_require__(96); +var InjectionMap = __webpack_require__(888); /** * @namespace Phaser.Scenes.Settings @@ -45103,7 +80814,44 @@ module.exports = Settings; /***/ }), -/* 193 */ +/* 327 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Capitalizes the first letter of a string if there is one. + * @example + * UppercaseFirst('abc'); + * // returns 'Abc' + * @example + * UppercaseFirst('the happy family'); + * // returns 'The happy family' + * @example + * UppercaseFirst(''); + * // returns '' + * + * @function Phaser.Utils.String.UppercaseFirst + * @since 3.0.0 + * + * @param {string} str - The string to capitalize. + * + * @return {string} A new string, same as the first, but with the first letter capitalized. + */ +var UppercaseFirst = function (str) +{ + return str && str[0].toUpperCase() + str.slice(1); +}; + +module.exports = UppercaseFirst; + + +/***/ }), +/* 328 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -45113,14 +80861,14 @@ module.exports = Settings; */ var Class = __webpack_require__(0); -var Systems = __webpack_require__(118); +var Systems = __webpack_require__(166); /** * @classdesc * [description] * * @class Scene - * @memberOf Phaser + * @memberof Phaser * @constructor * @since 3.0.0 * @@ -45221,16 +80969,6 @@ var Scene = new Class({ */ this.cameras; - /** - * A scene level 3D Camera System. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#cameras3d - * @type {Phaser.Cameras.Sprite3D.CameraManager} - * @since 3.0.0 - */ - this.cameras3d; - /** * A scene level Game Object Factory. * This property will only be available if defined in the Scene Injection Map. @@ -45369,8 +81107,8 @@ var Scene = new Class({ * @override * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function () { @@ -45382,7 +81120,7 @@ module.exports = Scene; /***/ }), -/* 194 */ +/* 329 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -45392,11 +81130,11 @@ module.exports = Scene; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(55); +var CONST = __webpack_require__(116); var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var Scene = __webpack_require__(193); -var Systems = __webpack_require__(118); +var NOOP = __webpack_require__(1); +var Scene = __webpack_require__(328); +var Systems = __webpack_require__(166); /** * @classdesc @@ -45407,7 +81145,7 @@ var Systems = __webpack_require__(118); * * * @class SceneManager - * @memberOf Phaser.Scenes + * @memberof Phaser.Scenes * @constructor * @since 3.0.0 * @@ -45493,7 +81231,7 @@ var SceneManager = new Class({ * @name Phaser.Scenes.SceneManager#isProcessing * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isProcessing = false; @@ -45504,11 +81242,22 @@ var SceneManager = new Class({ * @name Phaser.Scenes.SceneManager#isBooted * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.4.0 */ this.isBooted = false; + /** + * Do any of the Cameras in any of the Scenes require a custom viewport? + * If not we can skip scissor tests. + * + * @name Phaser.Scenes.SceneManager#customViewports + * @type {number} + * @default 0 + * @since 3.12.0 + */ + this.customViewports = 0; + if (sceneConfig) { if (!Array.isArray(sceneConfig)) @@ -45527,7 +81276,7 @@ var SceneManager = new Class({ }); } } - + game.events.once('ready', this.bootQueue, this); }, @@ -45764,7 +81513,7 @@ var SceneManager = new Class({ * The Scene is removed from the local scenes array, it's key is cleared from the keys * cache and Scene.Systems.destroy is then called on it. * - * If the SceneManager is processing the Scenes when this method is called it wil + * If the SceneManager is processing the Scenes when this method is called it will * queue the operation for the next update sequence. * * @method Phaser.Scenes.SceneManager#remove @@ -45828,6 +81577,8 @@ var SceneManager = new Class({ { scene.init.call(scene, settings.data); + settings.status = CONST.INIT; + if (settings.isTransition) { sys.events.emit('transitioninit', settings.transitionFrom, settings.transitionDuration); @@ -45994,9 +81745,9 @@ var SceneManager = new Class({ if (scene.create) { - scene.sys.settings.status = CONST.CREATING; + settings.status = CONST.CREATING; - scene.create.call(scene, scene.sys.settings.data); + scene.create.call(scene, settings.data); if (settings.isTransition) { @@ -46312,16 +82063,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its pause event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - pause: function (key) + pause: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.pause(); + scene.sys.pause(data); } return this; @@ -46334,16 +82086,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its resume event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - resume: function (key) + resume: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.resume(); + scene.sys.resume(data); } return this; @@ -46356,16 +82109,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its sleep event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - sleep: function (key) + sleep: function (key, data) { var scene = this.getScene(key); if (scene && !scene.sys.isTransitioning()) { - scene.sys.sleep(); + scene.sys.sleep(data); } return this; @@ -46378,16 +82132,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its wake event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - wake: function (key) + wake: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.wake(); + scene.sys.wake(data); } return this; @@ -46395,7 +82150,7 @@ var SceneManager = new Class({ /** * Runs the given Scene, but does not change the state of this Scene. - * + * * If the given Scene is paused, it will resume it. If sleeping, it will wake it. * If not running at all, it will be started. * @@ -46406,7 +82161,7 @@ var SceneManager = new Class({ * @since 3.10.0 * * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param {object} [data] - A data object that will be passed to the Scene on start, wake, or resume. * * @return {Phaser.Scenes.SceneManager} This Scene Manager. */ @@ -46416,18 +82171,26 @@ var SceneManager = new Class({ if (!scene) { + for (var i = 0; i < this._pending.length; i++) + { + if (this._pending[i].key === key) + { + this.queueOp('start', key, data); + break; + } + } return this; } if (scene.sys.isSleeping()) { // Sleeping? - scene.sys.wake(); + scene.sys.wake(data); } else if (scene.sys.isBooted && !scene.sys.isActive()) { // Paused? - scene.sys.resume(); + scene.sys.resume(data); } else { @@ -46464,29 +82227,40 @@ var SceneManager = new Class({ if (scene) { - scene.sys.start(data); - - var loader; - - if (scene.sys.load) + // If the Scene is already running (perhaps they called start from a launched sub-Scene?) + // then we close it down before starting it again. + if (scene.sys.isActive() || scene.sys.isPaused()) { - loader = scene.sys.load; + scene.sys.shutdown(); + + scene.sys.start(data); } - - // Files payload? - if (loader && scene.sys.settings.hasOwnProperty('pack')) + else { - loader.reset(); + scene.sys.start(data); - if (loader.addPack({ payload: scene.sys.settings.pack })) + var loader; + + if (scene.sys.load) { - scene.sys.settings.status = CONST.LOADING; - - loader.once('complete', this.payloadComplete, this); - - loader.start(); - - return this; + loader = scene.sys.load; + } + + // Files payload? + if (loader && scene.sys.settings.hasOwnProperty('pack')) + { + loader.reset(); + + if (loader.addPack({ payload: scene.sys.settings.pack })) + { + scene.sys.settings.status = CONST.LOADING; + + loader.once('complete', this.payloadComplete, this); + + loader.start(); + + return this; + } } } @@ -46905,7 +82679,7 @@ var SceneManager = new Class({ */ destroy: function () { - for (var i = this.scenes.length - 1; i >= 0; i--) + for (var i = 0; i < this.scenes.length; i++) { var sys = this.scenes[i].sys; @@ -46929,7 +82703,7 @@ module.exports = SceneManager; /***/ }), -/* 195 */ +/* 330 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -46938,7 +82712,7 @@ module.exports = SceneManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SpliceOne = __webpack_require__(56); +var SpliceOne = __webpack_require__(91); /** * Removes the given item, or array of items, from the array. @@ -47020,7 +82794,7 @@ module.exports = Remove; /***/ }), -/* 196 */ +/* 331 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -47030,13 +82804,13 @@ module.exports = Remove; */ var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); +var EventEmitter = __webpack_require__(11); var FileTypesManager = __webpack_require__(7); var GameObjectCreator = __webpack_require__(13); -var GameObjectFactory = __webpack_require__(11); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); -var Remove = __webpack_require__(195); +var GameObjectFactory = __webpack_require__(5); +var GetFastValue = __webpack_require__(2); +var PluginCache = __webpack_require__(15); +var Remove = __webpack_require__(330); /** * @typedef {object} GlobalPlugin @@ -47082,7 +82856,7 @@ var Remove = __webpack_require__(195); * For information on creating your own plugin please see the Phaser 3 Plugin Template. * * @class PluginManager - * @memberOf Phaser.Plugins + * @memberof Phaser.Plugins * @constructor * @since 3.0.0 * @@ -47171,6 +82945,7 @@ var PluginManager = new Class({ var plugin; var start; var mapping; + var data; var config = this.game.config; // Any plugins to install? @@ -47183,16 +82958,17 @@ var PluginManager = new Class({ { entry = list[i]; - // { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test' } + // { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test', data: { msg: 'The plugin is alive' } } key = GetFastValue(entry, 'key', null); plugin = GetFastValue(entry, 'plugin', null); start = GetFastValue(entry, 'start', false); mapping = GetFastValue(entry, 'mapping', null); + data = GetFastValue(entry, 'data', null); if (key && plugin) { - this.install(key, plugin, start, mapping); + this.install(key, plugin, start, mapping, data); } } @@ -47264,6 +83040,10 @@ var PluginManager = new Class({ scene[map[pluginKey]] = sys[pluginKey]; } } + else if (pluginKey === 'game' && map.hasOwnProperty(pluginKey)) + { + scene[map[pluginKey]] = game; + } } for (var s = 0; s < scenePlugins.length; s++) @@ -47424,11 +83204,13 @@ var PluginManager = new Class({ * @param {function} plugin - The plugin code. This should be the non-instantiated version. * @param {boolean} [start=false] - Automatically start the plugin running? This is always `true` if you provide a mapping value. * @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use. + * @param {any} [data] - A value passed to the plugin's `init` method. */ - install: function (key, plugin, start, mapping) + install: function (key, plugin, start, mapping, data) { if (start === undefined) { start = false; } if (mapping === undefined) { mapping = null; } + if (data === undefined) { data = null; } if (typeof plugin !== 'function') { @@ -47449,12 +83231,12 @@ var PluginManager = new Class({ if (!this.game.isBooted) { - this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping }); + this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping, data: data }); } else { // Add it to the plugin store - PluginCache.registerCustom(key, plugin, mapping); + PluginCache.registerCustom(key, plugin, mapping, data); if (start) { @@ -47593,12 +83375,13 @@ var PluginManager = new Class({ key: runAs, plugin: instance, active: true, - mapping: entry.mapping + mapping: entry.mapping, + data: entry.data }; this.plugins.push(entry); - instance.init(); + instance.init(entry.data); instance.start(); } @@ -47829,7 +83612,8 @@ var PluginManager = new Class({ /** * Destroys this Plugin Manager and all associated plugins. * It will iterate all plugins found and call their `destroy` methods. - * Note that the PluginCache is NOT cleared by this as it doesn't hold any plugin instances. + * + * The PluginCache will remove all custom plugins. * * @method Phaser.Plugins.PluginManager#destroy * @since 3.8.0 @@ -47841,6 +83625,13 @@ var PluginManager = new Class({ this.plugins[i].plugin.destroy(); } + PluginCache.destroyCustomPlugins(); + + if (this.game.noReturn) + { + PluginCache.destroyCorePlugins(); + } + this.game = null; this.plugins = []; this.scenePlugins = []; @@ -47858,7 +83649,62 @@ module.exports = PluginManager; /***/ }), -/* 197 */ +/* 332 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector2 = __webpack_require__(3); + +/** + * Takes the `x` and `y` coordinates and transforms them into the same space as + * defined by the position, rotation and scale values. + * + * @function Phaser.Math.TransformXY + * @since 3.0.0 + * + * @param {number} x - The x coordinate to be transformed. + * @param {number} y - The y coordinate to be transformed. + * @param {number} positionX - Horizontal position of the transform point. + * @param {number} positionY - Vertical position of the transform point. + * @param {number} rotation - Rotation of the transform point, in radians. + * @param {number} scaleX - Horizontal scale of the transform point. + * @param {number} scaleY - Vertical scale of the transform point. + * @param {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} [output] - The output vector, point or object for the translated coordinates. + * + * @return {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} The translated point. + */ +var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) +{ + if (output === undefined) { output = new Vector2(); } + + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); + + // Rotate and Scale + var a = radianCos * scaleX; + var b = radianSin * scaleX; + var c = -radianSin * scaleY; + var d = radianCos * scaleY; + + // Invert + var id = 1 / ((a * d) + (c * -b)); + + output.x = (d * id * x) + (-c * id * y) + (((positionY * c) - (positionX * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-positionY * a) + (positionX * b)) * id); + + return output; +}; + +module.exports = TransformXY; + + +/***/ }), +/* 333 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -47868,6 +83714,7 @@ module.exports = PluginManager; */ var Class = __webpack_require__(0); +var NOOP = __webpack_require__(1); // https://developer.mozilla.org/en-US/docs/Web/API/Touch_events // https://patrickhlauke.github.io/touch/tests/results/ @@ -47882,7 +83729,7 @@ var Class = __webpack_require__(0); * You do not need to create this class directly, the Input Manager will create an instance of it automatically. * * @class TouchManager - * @memberOf Phaser.Input.Touch + * @memberof Phaser.Input.Touch * @constructor * @since 3.0.0 * @@ -47934,6 +83781,46 @@ var TouchManager = new Class({ */ this.target; + /** + * The Touch Start event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchStart + * @type {function} + * @since 3.0.0 + */ + this.onTouchStart = NOOP; + + /** + * The Touch Move event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchMove + * @type {function} + * @since 3.0.0 + */ + this.onTouchMove = NOOP; + + /** + * The Touch End event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchEnd + * @type {function} + * @since 3.0.0 + */ + this.onTouchEnd = NOOP; + + /** + * The Touch Cancel event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchCancel + * @type {function} + * @since 3.15.0 + */ + this.onTouchCancel = NOOP; + inputManager.events.once('boot', this.boot, this); }, @@ -47957,110 +83844,115 @@ var TouchManager = new Class({ this.target = this.manager.game.canvas; } - if (this.enabled) + if (this.enabled && this.target) { this.startListeners(); } }, /** - * The Touch Start Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchStart - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch Start Event. - */ - onTouchStart: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchStart(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Touch Move Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchMove - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch Move Event. - */ - onTouchMove: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchMove(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Touch End Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchEnd - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch End Event. - */ - onTouchEnd: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchEnd(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * Starts the Touch Event listeners running. - * This is called automatically and does not need to be manually invoked. + * Starts the Touch Event listeners running as long as an input target is set. + * + * This method is called automatically if Touch Input is enabled in the game config, + * which it is by default. However, you can call it manually should you need to + * delay input capturing until later in the game. * * @method Phaser.Input.Touch.TouchManager#startListeners * @since 3.0.0 */ startListeners: function () { + var _this = this; + + this.onTouchStart = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchStart(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchMove = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchMove(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchEnd = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchEnd(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchCancel = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchCancel(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + var target = this.target; + if (!target) + { + return; + } + var passive = { passive: true }; var nonPassive = { passive: false }; if (this.capture) { - target.addEventListener('touchstart', this.onTouchStart.bind(this), nonPassive); - target.addEventListener('touchmove', this.onTouchMove.bind(this), nonPassive); - target.addEventListener('touchend', this.onTouchEnd.bind(this), nonPassive); + target.addEventListener('touchstart', this.onTouchStart, nonPassive); + target.addEventListener('touchmove', this.onTouchMove, nonPassive); + target.addEventListener('touchend', this.onTouchEnd, nonPassive); + target.addEventListener('touchcancel', this.onTouchCancel, nonPassive); } else { - target.addEventListener('touchstart', this.onTouchStart.bind(this), passive); - target.addEventListener('touchmove', this.onTouchMove.bind(this), passive); - target.addEventListener('touchend', this.onTouchEnd.bind(this), passive); + target.addEventListener('touchstart', this.onTouchStart, passive); + target.addEventListener('touchmove', this.onTouchMove, passive); + target.addEventListener('touchend', this.onTouchEnd, passive); } + + this.enabled = true; }, /** @@ -48077,6 +83969,7 @@ var TouchManager = new Class({ target.removeEventListener('touchstart', this.onTouchStart); target.removeEventListener('touchmove', this.onTouchMove); target.removeEventListener('touchend', this.onTouchEnd); + target.removeEventListener('touchcancel', this.onTouchCancel); }, /** @@ -48090,6 +83983,7 @@ var TouchManager = new Class({ this.stopListeners(); this.target = null; + this.enabled = false; this.manager = null; } @@ -48099,7 +83993,40 @@ module.exports = TouchManager; /***/ }), -/* 198 */ +/* 334 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SmoothStep = __webpack_require__(181); + +/** + * A Smooth Step interpolation method. + * + * @function Phaser.Math.Interpolation.SmoothStep + * @since 3.9.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep} + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The interpolated value. + */ +var SmoothStepInterpolation = function (t, min, max) +{ + return min + (max - min) * SmoothStep(t, 0, 1); +}; + +module.exports = SmoothStepInterpolation; + + +/***/ }), +/* 335 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -48109,7 +84036,9 @@ module.exports = TouchManager; */ var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); +var Distance = __webpack_require__(52); +var SmoothStepInterpolation = __webpack_require__(334); +var Vector2 = __webpack_require__(3); /** * @classdesc @@ -48127,7 +84056,7 @@ var Vector2 = __webpack_require__(6); * callbacks. * * @class Pointer - * @memberOf Phaser.Input + * @memberof Phaser.Input * @constructor * @since 3.0.0 * @@ -48154,7 +84083,7 @@ var Pointer = new Class({ * * @name Phaser.Input.Pointer#id * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.id = id; @@ -48208,6 +84137,20 @@ var Pointer = new Class({ */ this.position = new Vector2(); + /** + * The previous position of the Pointer in screen space. + * + * The old x and y values are stored in here during the InputManager.transformPointer call. + * + * You can use it to track how fast the pointer is moving, or to smoothly interpolate between the old and current position. + * See the `Pointer.getInterpolatedPosition` method to assist in this. + * + * @name Phaser.Input.Pointer#prevPosition + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.prevPosition = new Vector2(); + /** * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. * @@ -48372,6 +84315,18 @@ var Pointer = new Class({ */ this.wasTouch = false; + /** + * Did this Pointer get canceled by a touchcancel event? + * + * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! + * + * @name Phaser.Input.Pointer#wasCanceled + * @type {boolean} + * @default false + * @since 3.15.0 + */ + this.wasCanceled = false; + /** * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. * @@ -48612,6 +84567,7 @@ var Pointer = new Class({ this.dirty = true; this.wasTouch = true; + this.wasCanceled = false; }, /** @@ -48668,6 +84624,35 @@ var Pointer = new Class({ this.dirty = true; this.wasTouch = true; + this.wasCanceled = false; + + this.active = false; + }, + + /** + * Internal method to handle a Touch Cancel Event. + * + * @method Phaser.Input.Pointer#touchcancel + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The Touch Event to process. + */ + touchcancel: function (event) + { + this.buttons = 0; + + this.event = event; + + this.primaryDown = false; + + this.justUp = false; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = true; + this.wasCanceled = true; this.active = false; }, @@ -48750,6 +84735,71 @@ var Pointer = new Class({ return (this.buttons & 16); }, + /** + * Returns the distance between the Pointer's current position and where it was + * first pressed down (the `downX` and `downY` properties) + * + * @method Phaser.Input.Pointer#getDistance + * @since 3.13.0 + * + * @return {number} The distance the Pointer has moved since being pressed down. + */ + getDistance: function () + { + return Distance(this.downX, this.downY, this.x, this.y); + }, + + /** + * Takes the previous and current Pointer positions and then generates an array of interpolated values between + * the two. The array will be populated up to the size of the `steps` argument. + * + * ```javaScript + * var points = pointer.getInterpolatedPosition(4); + * + * // points[0] = { x: 0, y: 0 } + * // points[1] = { x: 2, y: 1 } + * // points[2] = { x: 3, y: 2 } + * // points[3] = { x: 6, y: 3 } + * ``` + * + * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer + * events can often fire faster than the main browser loop, and this will help you avoid janky movement + * especially if you have an object following a Pointer. + * + * Note that if you provide an output array it will only be populated up to the number of steps provided. + * It will not clear any previous data that may have existed beyond the range of the steps count. + * + * Internally it uses the Smooth Step interpolation calculation. + * + * @method Phaser.Input.Pointer#getInterpolatedPosition + * @since 3.11.0 + * + * @param {integer} [steps=10] - The number of interpolation steps to use. + * @param {array} [out] - An array to store the results in. If not provided a new one will be created. + * + * @return {array} An array of interpolated values. + */ + getInterpolatedPosition: function (steps, out) + { + if (steps === undefined) { steps = 10; } + if (out === undefined) { out = []; } + + var prevX = this.prevPosition.x; + var prevY = this.prevPosition.y; + + var curX = this.position.x; + var curY = this.position.y; + + for (var i = 0; i < steps; i++) + { + var t = (1 / steps) * i; + + out[i] = { x: SmoothStepInterpolation(t, prevX, curX), y: SmoothStepInterpolation(t, prevY, curY) }; + } + + return out; + }, + /** * Destroys this Pointer instance and resets its external references. * @@ -48815,7 +84865,7 @@ module.exports = Pointer; /***/ }), -/* 199 */ +/* 336 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -48825,7 +84875,7 @@ module.exports = Pointer; */ var Class = __webpack_require__(0); -var Features = __webpack_require__(120); +var Features = __webpack_require__(168); // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md @@ -48839,7 +84889,7 @@ var Features = __webpack_require__(120); * You do not need to create this class directly, the Input Manager will create an instance of it automatically. * * @class MouseManager - * @memberOf Phaser.Input.Mouse + * @memberof Phaser.Input.Mouse * @constructor * @since 3.0.0 * @@ -48992,6 +85042,8 @@ var MouseManager = new Class({ * * @param {MouseEvent} event - The native event from the browser. */ + + /* pointerLockChange: function (event) { var element = this.target; @@ -49000,6 +85052,7 @@ var MouseManager = new Class({ this.manager.queue.push(event); }, + */ /** * If the browser supports pointer lock, this will request that the pointer lock is released. If @@ -49026,9 +85079,11 @@ var MouseManager = new Class({ * * @param {MouseEvent} event - The native DOM Mouse Move Event. */ + + /* onMouseMove: function (event) { - if (event.defaultPrevented || !this.enabled) + if (event.defaultPrevented || !this.enabled || !this.manager) { // Do nothing if event already handled return; @@ -49041,6 +85096,7 @@ var MouseManager = new Class({ event.preventDefault(); } }, + */ /** * The Mouse Down Event Handler. @@ -49050,6 +85106,8 @@ var MouseManager = new Class({ * * @param {MouseEvent} event - The native DOM Mouse Down Event. */ + + /* onMouseDown: function (event) { if (event.defaultPrevented || !this.enabled) @@ -49065,6 +85123,7 @@ var MouseManager = new Class({ event.preventDefault(); } }, + */ /** * The Mouse Up Event Handler. @@ -49074,6 +85133,8 @@ var MouseManager = new Class({ * * @param {MouseEvent} event - The native DOM Mouse Up Event. */ + + /* onMouseUp: function (event) { if (event.defaultPrevented || !this.enabled) @@ -49089,6 +85150,7 @@ var MouseManager = new Class({ event.preventDefault(); } }, + */ /** * Starts the Mouse Event listeners running. @@ -49099,31 +85161,84 @@ var MouseManager = new Class({ */ startListeners: function () { - var target = this.target; + var _this = this; + var onMouseMove = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseMove(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + var onMouseDown = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseDown(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + var onMouseUp = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseUp(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onMouseMove = onMouseMove; + this.onMouseDown = onMouseDown; + this.onMouseUp = onMouseUp; + + var target = this.target; var passive = { passive: true }; var nonPassive = { passive: false }; - if (this.capture) - { - target.addEventListener('mousemove', this.onMouseMove.bind(this), nonPassive); - target.addEventListener('mousedown', this.onMouseDown.bind(this), nonPassive); - target.addEventListener('mouseup', this.onMouseUp.bind(this), nonPassive); - } - else - { - target.addEventListener('mousemove', this.onMouseMove.bind(this), passive); - target.addEventListener('mousedown', this.onMouseDown.bind(this), passive); - target.addEventListener('mouseup', this.onMouseUp.bind(this), passive); - } + target.addEventListener('mousemove', onMouseMove, (this.capture) ? nonPassive : passive); + target.addEventListener('mousedown', onMouseDown, (this.capture) ? nonPassive : passive); + target.addEventListener('mouseup', onMouseUp, (this.capture) ? nonPassive : passive); if (Features.pointerLock) { - this.pointerLockChange = this.pointerLockChange.bind(this); + var onPointerLockChange = function (event) + { + var element = _this.target; - document.addEventListener('pointerlockchange', this.pointerLockChange, true); - document.addEventListener('mozpointerlockchange', this.pointerLockChange, true); - document.addEventListener('webkitpointerlockchange', this.pointerLockChange, true); + _this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; + + _this.manager.queue.push(event); + }; + + this.pointerLockChange = onPointerLockChange; + + document.addEventListener('pointerlockchange', onPointerLockChange, true); + document.addEventListener('mozpointerlockchange', onPointerLockChange, true); + document.addEventListener('webkitpointerlockchange', onPointerLockChange, true); } }, @@ -49170,7 +85285,7 @@ module.exports = MouseManager; /***/ }), -/* 200 */ +/* 337 */ /***/ (function(module, exports) { /** @@ -49235,6 +85350,15 @@ var INPUT_CONST = { */ TOUCH_END: 5, + /** + * A touch pointer has been been cancelled by the browser. + * + * @name Phaser.Input.TOUCH_CANCEL + * @type {integer} + * @since 3.15.0 + */ + TOUCH_CANCEL: 7, + /** * The pointer lock has changed. * @@ -49250,7 +85374,7 @@ module.exports = INPUT_CONST; /***/ }), -/* 201 */ +/* 338 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -49260,14 +85384,14 @@ module.exports = INPUT_CONST; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(200); -var EventEmitter = __webpack_require__(9); -var Mouse = __webpack_require__(199); -var Pointer = __webpack_require__(198); -var Rectangle = __webpack_require__(14); -var Touch = __webpack_require__(197); -var TransformMatrix = __webpack_require__(64); -var TransformXY = __webpack_require__(257); +var CONST = __webpack_require__(337); +var EventEmitter = __webpack_require__(11); +var Mouse = __webpack_require__(336); +var Pointer = __webpack_require__(335); +var Rectangle = __webpack_require__(9); +var Touch = __webpack_require__(333); +var TransformMatrix = __webpack_require__(38); +var TransformXY = __webpack_require__(332); /** * @classdesc @@ -49284,7 +85408,7 @@ var TransformXY = __webpack_require__(257); * for dealing with all input events for a Scene. * * @class InputManager - * @memberOf Phaser.Input + * @memberof Phaser.Input * @constructor * @since 3.0.0 * @@ -49303,7 +85427,7 @@ var InputManager = new Class({ * * @name Phaser.Input.InputManager#game * @type {Phaser.Game} - * @readOnly + * @readonly * @since 3.0.0 */ this.game = game; @@ -49469,7 +85593,7 @@ var InputManager = new Class({ * * @name Phaser.Input.InputManager#pointersTotal * @type {integer} - * @readOnly + * @readonly * @since 3.10.0 */ this.pointersTotal = config.inputActivePointers; @@ -49591,6 +85715,16 @@ var InputManager = new Class({ */ this._tempMatrix = new TransformMatrix(); + /** + * A re-cycled matrix used in hit test calculations. + * + * @name Phaser.Input.InputManager#_tempMatrix2 + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + game.events.once('boot', this.boot, this); }, @@ -49736,6 +85870,10 @@ var InputManager = new Class({ this.stopPointer(event, time); break; + case CONST.TOUCH_CANCEL: + this.cancelPointer(event, time); + break; + case CONST.POINTER_LOCK_CHANGE: this.events.emit('pointerlockchange', event, this.mouse.locked); break; @@ -49941,6 +86079,37 @@ var InputManager = new Class({ } }, + /** + * Called by the main update loop when a Touch Cancel Event is received. + * + * @method Phaser.Input.InputManager#cancelPointer + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The native DOM event to be processed. + * @param {number} time - The time stamp value of this game step. + */ + cancelPointer: function (event, time) + { + var pointers = this.pointers; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < this.pointersTotal; i++) + { + var pointer = pointers[i]; + + if (pointer.active && pointer.identifier === changedTouch.identifier) + { + pointer.touchend(changedTouch, time); + break; + } + } + } + }, + /** * Adds new Pointer objects to the Input Manager. * @@ -50084,6 +86253,21 @@ var InputManager = new Class({ } }, + /** + * Queues a touch cancel event, as passed in by the TouchManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueTouchCancel + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + queueTouchCancel: function (event) + { + this.queue.push(CONST.TOUCH_CANCEL, event); + }, + /** * Queues a mouse down event, as passed in by the MouseManager. * Also dispatches any DOM callbacks for this event. @@ -50305,14 +86489,15 @@ var InputManager = new Class({ * @since 3.10.0 * * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to test. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against. * * @return {boolean} `true` if the Game Object should be considered for input, otherwise `false`. */ - inputCandidate: function (gameObject) + inputCandidate: function (gameObject, camera) { var input = gameObject.input; - if (!input || !input.enabled || !gameObject.willRender()) + if (!input || !input.enabled || !gameObject.willRender(camera)) { return false; } @@ -50324,7 +86509,7 @@ var InputManager = new Class({ { do { - if (!parent.visible) + if (!parent.willRender(camera)) { visible = false; break; @@ -50363,17 +86548,19 @@ var InputManager = new Class({ if (output === undefined) { output = this._tempHitTest; } var tempPoint = this._tempPoint; - var cameraW = camera.width; - var cameraH = camera.height; + + var csx = camera.scrollX; + var csy = camera.scrollY; output.length = 0; var x = pointer.x; var y = pointer.y; - if (!(x >= camera.x && y >= camera.y && x <= camera.x + cameraW && y <= camera.y + cameraH)) + if (camera.resolution !== 1) { - return output; + x += camera._x; + y += camera._y; } // Stores the world point inside of tempPoint @@ -50382,38 +86569,36 @@ var InputManager = new Class({ pointer.worldX = tempPoint.x; pointer.worldY = tempPoint.y; - // Disable until fixed. - // var culledGameObjects = camera.cull(gameObjects); - var point = { x: 0, y: 0 }; - var res = this.game.config.resolution; - var matrix = this._tempMatrix; + var parentMatrix = this._tempMatrix2; for (var i = 0; i < gameObjects.length; i++) { var gameObject = gameObjects[i]; - if (!this.inputCandidate(gameObject)) + // Checks if the Game Object can receive input (isn't being ignored by the camera, invisible, etc) + // and also checks all of its parents, if any + if (!this.inputCandidate(gameObject, camera)) { continue; } - var px = tempPoint.x * res + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX; - var py = tempPoint.y * res + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY; + var px = tempPoint.x + (csx * gameObject.scrollFactorX) - csx; + var py = tempPoint.y + (csy * gameObject.scrollFactorY) - csy; if (gameObject.parentContainer) { - gameObject.getWorldTransformMatrix(matrix); + gameObject.getWorldTransformMatrix(matrix, parentMatrix); - TransformXY(px, py, matrix.tx, matrix.ty, matrix.rotation, matrix.scaleX, matrix.scaleY, point); + matrix.applyInverse(px, py, point); } else { TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); } - + if (this.pointWithinHitArea(gameObject, point.x, point.y)) { output.push(gameObject); @@ -50500,11 +86685,15 @@ var InputManager = new Class({ * @since 3.10.0 * * @param {Phaser.Input.Pointer} pointer - The Pointer to transform the values for. - * - * @return {number} The translated value. + * @param {number} pageX - The Page X value. + * @param {number} pageY - The Page Y value. */ transformPointer: function (pointer, pageX, pageY) { + // Store the previous position + pointer.prevPosition.x = pointer.x; + pointer.prevPosition.y = pointer.y; + pointer.x = (pageX - this.bounds.left) * this.scale.x; pointer.y = (pageY - this.bounds.top) * this.scale.y; }, @@ -50633,598 +86822,7 @@ module.exports = InputManager; /***/ }), -/* 202 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -/** - * Implements a model view projection matrices. - * Pipelines can implement this for doing 2D and 3D rendering. - */ - -var ModelViewProjection = { - - /** - * Dirty flag for checking if model matrix needs to be updated on GPU. - */ - modelMatrixDirty: false, - - /** - * Dirty flag for checking if view matrix needs to be updated on GPU. - */ - viewMatrixDirty: false, - - /** - * Dirty flag for checking if projection matrix needs to be updated on GPU. - */ - projectionMatrixDirty: false, - - /** - * Model matrix - */ - modelMatrix: null, - - /** - * View matrix - */ - viewMatrix: null, - - /** - * Projection matrix - */ - projectionMatrix: null, - - /** - * Initializes MVP matrices with an identity matrix - */ - mvpInit: function () - { - this.modelMatrixDirty = true; - this.viewMatrixDirty = true; - this.projectionMatrixDirty = true; - - this.modelMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.viewMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - this.projectionMatrix = new Float32Array([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - ]); - - return this; - }, - - /** - * If dirty flags are set then the matrices are uploaded to the GPU. - */ - mvpUpdate: function () - { - var program = this.program; - - if (this.modelMatrixDirty) - { - this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); - this.modelMatrixDirty = false; - } - - if (this.viewMatrixDirty) - { - this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); - this.viewMatrixDirty = false; - } - - if (this.projectionMatrixDirty) - { - this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); - this.projectionMatrixDirty = false; - } - - return this; - }, - - /** - * Loads an identity matrix to the model matrix - */ - modelIdentity: function () - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = 1; - modelMatrix[1] = 0; - modelMatrix[2] = 0; - modelMatrix[3] = 0; - modelMatrix[4] = 0; - modelMatrix[5] = 1; - modelMatrix[6] = 0; - modelMatrix[7] = 0; - modelMatrix[8] = 0; - modelMatrix[9] = 0; - modelMatrix[10] = 1; - modelMatrix[11] = 0; - modelMatrix[12] = 0; - modelMatrix[13] = 0; - modelMatrix[14] = 0; - modelMatrix[15] = 1; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Scale model matrix - */ - modelScale: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[0] = modelMatrix[0] * x; - modelMatrix[1] = modelMatrix[1] * x; - modelMatrix[2] = modelMatrix[2] * x; - modelMatrix[3] = modelMatrix[3] * x; - modelMatrix[4] = modelMatrix[4] * y; - modelMatrix[5] = modelMatrix[5] * y; - modelMatrix[6] = modelMatrix[6] * y; - modelMatrix[7] = modelMatrix[7] * y; - modelMatrix[8] = modelMatrix[8] * z; - modelMatrix[9] = modelMatrix[9] * z; - modelMatrix[10] = modelMatrix[10] * z; - modelMatrix[11] = modelMatrix[11] * z; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Translate model matrix - */ - modelTranslate: function (x, y, z) - { - var modelMatrix = this.modelMatrix; - - modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; - modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; - modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; - modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; - - this.modelMatrixDirty = true; - - return this; - }, - - - /** - * Rotates the model matrix in the X axis. - */ - modelRotateX: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[4] = a10 * c + a20 * s; - modelMatrix[5] = a11 * c + a21 * s; - modelMatrix[6] = a12 * c + a22 * s; - modelMatrix[7] = a13 * c + a23 * s; - modelMatrix[8] = a20 * c - a10 * s; - modelMatrix[9] = a21 * c - a11 * s; - modelMatrix[10] = a22 * c - a12 * s; - modelMatrix[11] = a23 * c - a13 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Rotates the model matrix in the Y axis. - */ - modelRotateY: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a20 = modelMatrix[8]; - var a21 = modelMatrix[9]; - var a22 = modelMatrix[10]; - var a23 = modelMatrix[11]; - - modelMatrix[0] = a00 * c - a20 * s; - modelMatrix[1] = a01 * c - a21 * s; - modelMatrix[2] = a02 * c - a22 * s; - modelMatrix[3] = a03 * c - a23 * s; - modelMatrix[8] = a00 * s + a20 * c; - modelMatrix[9] = a01 * s + a21 * c; - modelMatrix[10] = a02 * s + a22 * c; - modelMatrix[11] = a03 * s + a23 * c; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Rotates the model matrix in the Z axis. - */ - modelRotateZ: function (radians) - { - var modelMatrix = this.modelMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = modelMatrix[0]; - var a01 = modelMatrix[1]; - var a02 = modelMatrix[2]; - var a03 = modelMatrix[3]; - var a10 = modelMatrix[4]; - var a11 = modelMatrix[5]; - var a12 = modelMatrix[6]; - var a13 = modelMatrix[7]; - - modelMatrix[0] = a00 * c + a10 * s; - modelMatrix[1] = a01 * c + a11 * s; - modelMatrix[2] = a02 * c + a12 * s; - modelMatrix[3] = a03 * c + a13 * s; - modelMatrix[4] = a10 * c - a00 * s; - modelMatrix[5] = a11 * c - a01 * s; - modelMatrix[6] = a12 * c - a02 * s; - modelMatrix[7] = a13 * c - a03 * s; - - this.modelMatrixDirty = true; - - return this; - }, - - /** - * Loads identity matrix into the view matrix - */ - viewIdentity: function () - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = 1; - viewMatrix[1] = 0; - viewMatrix[2] = 0; - viewMatrix[3] = 0; - viewMatrix[4] = 0; - viewMatrix[5] = 1; - viewMatrix[6] = 0; - viewMatrix[7] = 0; - viewMatrix[8] = 0; - viewMatrix[9] = 0; - viewMatrix[10] = 1; - viewMatrix[11] = 0; - viewMatrix[12] = 0; - viewMatrix[13] = 0; - viewMatrix[14] = 0; - viewMatrix[15] = 1; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Scales view matrix - */ - viewScale: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[0] = viewMatrix[0] * x; - viewMatrix[1] = viewMatrix[1] * x; - viewMatrix[2] = viewMatrix[2] * x; - viewMatrix[3] = viewMatrix[3] * x; - viewMatrix[4] = viewMatrix[4] * y; - viewMatrix[5] = viewMatrix[5] * y; - viewMatrix[6] = viewMatrix[6] * y; - viewMatrix[7] = viewMatrix[7] * y; - viewMatrix[8] = viewMatrix[8] * z; - viewMatrix[9] = viewMatrix[9] * z; - viewMatrix[10] = viewMatrix[10] * z; - viewMatrix[11] = viewMatrix[11] * z; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Translates view matrix - */ - viewTranslate: function (x, y, z) - { - var viewMatrix = this.viewMatrix; - - viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; - viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; - viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; - viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Rotates view matrix in the X axis. - */ - viewRotateX: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[4] = a10 * c + a20 * s; - viewMatrix[5] = a11 * c + a21 * s; - viewMatrix[6] = a12 * c + a22 * s; - viewMatrix[7] = a13 * c + a23 * s; - viewMatrix[8] = a20 * c - a10 * s; - viewMatrix[9] = a21 * c - a11 * s; - viewMatrix[10] = a22 * c - a12 * s; - viewMatrix[11] = a23 * c - a13 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Rotates view matrix in the Y axis. - */ - viewRotateY: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a20 = viewMatrix[8]; - var a21 = viewMatrix[9]; - var a22 = viewMatrix[10]; - var a23 = viewMatrix[11]; - - viewMatrix[0] = a00 * c - a20 * s; - viewMatrix[1] = a01 * c - a21 * s; - viewMatrix[2] = a02 * c - a22 * s; - viewMatrix[3] = a03 * c - a23 * s; - viewMatrix[8] = a00 * s + a20 * c; - viewMatrix[9] = a01 * s + a21 * c; - viewMatrix[10] = a02 * s + a22 * c; - viewMatrix[11] = a03 * s + a23 * c; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Rotates view matrix in the Z axis. - */ - viewRotateZ: function (radians) - { - var viewMatrix = this.viewMatrix; - var s = Math.sin(radians); - var c = Math.cos(radians); - var a00 = viewMatrix[0]; - var a01 = viewMatrix[1]; - var a02 = viewMatrix[2]; - var a03 = viewMatrix[3]; - var a10 = viewMatrix[4]; - var a11 = viewMatrix[5]; - var a12 = viewMatrix[6]; - var a13 = viewMatrix[7]; - - viewMatrix[0] = a00 * c + a10 * s; - viewMatrix[1] = a01 * c + a11 * s; - viewMatrix[2] = a02 * c + a12 * s; - viewMatrix[3] = a03 * c + a13 * s; - viewMatrix[4] = a10 * c - a00 * s; - viewMatrix[5] = a11 * c - a01 * s; - viewMatrix[6] = a12 * c - a02 * s; - viewMatrix[7] = a13 * c - a03 * s; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Loads a 2D view matrix (3x2 matrix) into a 4x4 view matrix - */ - viewLoad2D: function (matrix2D) - { - var vm = this.viewMatrix; - - vm[0] = matrix2D[0]; - vm[1] = matrix2D[1]; - vm[2] = 0.0; - vm[3] = 0.0; - vm[4] = matrix2D[2]; - vm[5] = matrix2D[3]; - vm[6] = 0.0; - vm[7] = 0.0; - vm[8] = matrix2D[4]; - vm[9] = matrix2D[5]; - vm[10] = 1.0; - vm[11] = 0.0; - vm[12] = 0.0; - vm[13] = 0.0; - vm[14] = 0.0; - vm[15] = 1.0; - - this.viewMatrixDirty = true; - - return this; - }, - - - /** - * Copies a 4x4 matrix into the view matrix - */ - viewLoad: function (matrix) - { - var vm = this.viewMatrix; - - vm[0] = matrix[0]; - vm[1] = matrix[1]; - vm[2] = matrix[2]; - vm[3] = matrix[3]; - vm[4] = matrix[4]; - vm[5] = matrix[5]; - vm[6] = matrix[6]; - vm[7] = matrix[7]; - vm[8] = matrix[8]; - vm[9] = matrix[9]; - vm[10] = matrix[10]; - vm[11] = matrix[11]; - vm[12] = matrix[12]; - vm[13] = matrix[13]; - vm[14] = matrix[14]; - vm[15] = matrix[15]; - - this.viewMatrixDirty = true; - - return this; - }, - - /** - * Loads identity matrix into the projection matrix. - */ - projIdentity: function () - { - var projectionMatrix = this.projectionMatrix; - - projectionMatrix[0] = 1; - projectionMatrix[1] = 0; - projectionMatrix[2] = 0; - projectionMatrix[3] = 0; - projectionMatrix[4] = 0; - projectionMatrix[5] = 1; - projectionMatrix[6] = 0; - projectionMatrix[7] = 0; - projectionMatrix[8] = 0; - projectionMatrix[9] = 0; - projectionMatrix[10] = 1; - projectionMatrix[11] = 0; - projectionMatrix[12] = 0; - projectionMatrix[13] = 0; - projectionMatrix[14] = 0; - projectionMatrix[15] = 1; - - this.projectionMatrixDirty = true; - - return this; - }, - - /** - * Sets up an orthographics projection matrix - */ - projOrtho: function (left, right, bottom, top, near, far) - { - var projectionMatrix = this.projectionMatrix; - var leftRight = 1.0 / (left - right); - var bottomTop = 1.0 / (bottom - top); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = -2.0 * leftRight; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = -2.0 * bottomTop; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = 2.0 * nearFar; - projectionMatrix[11] = 0.0; - projectionMatrix[12] = (left + right) * leftRight; - projectionMatrix[13] = (top + bottom) * bottomTop; - projectionMatrix[14] = (far + near) * nearFar; - projectionMatrix[15] = 1.0; - - this.projectionMatrixDirty = true; - return this; - }, - - /** - * Sets up a perspective projection matrix - */ - projPersp: function (fovy, aspectRatio, near, far) - { - var projectionMatrix = this.projectionMatrix; - var fov = 1.0 / Math.tan(fovy / 2.0); - var nearFar = 1.0 / (near - far); - - projectionMatrix[0] = fov / aspectRatio; - projectionMatrix[1] = 0.0; - projectionMatrix[2] = 0.0; - projectionMatrix[3] = 0.0; - projectionMatrix[4] = 0.0; - projectionMatrix[5] = fov; - projectionMatrix[6] = 0.0; - projectionMatrix[7] = 0.0; - projectionMatrix[8] = 0.0; - projectionMatrix[9] = 0.0; - projectionMatrix[10] = (far + near) * nearFar; - projectionMatrix[11] = -1.0; - projectionMatrix[12] = 0.0; - projectionMatrix[13] = 0.0; - projectionMatrix[14] = (2.0 * far * near) * nearFar; - projectionMatrix[15] = 0.0; - - this.projectionMatrixDirty = true; - return this; - } -}; - -module.exports = ModelViewProjection; - - -/***/ }), -/* 203 */ +/* 339 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -51233,7 +86831,7 @@ module.exports = ModelViewProjection; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CanvasPool = __webpack_require__(22); +var CanvasPool = __webpack_require__(24); /** * Determines the canvas features of the browser running this Phaser Game instance. @@ -51338,7 +86936,2708 @@ module.exports = init(); /***/ }), -/* 204 */ +/* 340 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// This singleton is instantiated as soon as Phaser loads, +// before a Phaser.Game instance has even been created. +// Which means all instances of Phaser Games can share it, +// without having to re-poll the device all over again + +/** + * @namespace Phaser.Device + * @since 3.0.0 + */ + +/** + * @typedef {object} Phaser.DeviceConf + * + * @property {Phaser.Device.OS} os - The OS Device functions. + * @property {Phaser.Device.Browser} browser - The Browser Device functions. + * @property {Phaser.Device.Features} features - The Features Device functions. + * @property {Phaser.Device.Input} input - The Input Device functions. + * @property {Phaser.Device.Audio} audio - The Audio Device functions. + * @property {Phaser.Device.Video} video - The Video Device functions. + * @property {Phaser.Device.Fullscreen} fullscreen - The Fullscreen Device functions. + * @property {Phaser.Device.CanvasFeatures} canvasFeatures - The Canvas Device functions. + */ + +module.exports = { + + os: __webpack_require__(92), + browser: __webpack_require__(118), + features: __webpack_require__(168), + input: __webpack_require__(902), + audio: __webpack_require__(901), + video: __webpack_require__(900), + fullscreen: __webpack_require__(899), + canvasFeatures: __webpack_require__(339) + +}; + + +/***/ }), +/* 341 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var NOOP = __webpack_require__(1); + +/** + * @classdesc + * Abstracts away the use of RAF or setTimeOut for the core game update loop. + * This is invoked automatically by the Phaser.Game instance. + * + * @class RequestAnimationFrame + * @memberof Phaser.DOM + * @constructor + * @since 3.0.0 + */ +var RequestAnimationFrame = new Class({ + + initialize: + + function RequestAnimationFrame () + { + /** + * True if RequestAnimationFrame is running, otherwise false. + * + * @name Phaser.DOM.RequestAnimationFrame#isRunning + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isRunning = false; + + /** + * The callback to be invoked each step. + * + * @name Phaser.DOM.RequestAnimationFrame#callback + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.callback = NOOP; + + /** + * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#tick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.tick = 0; + + /** + * True if the step is using setTimeout instead of RAF. + * + * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isSetTimeOut = false; + + /** + * The setTimeout or RAF callback ID used when canceling them. + * + * @name Phaser.DOM.RequestAnimationFrame#timeOutID + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.timeOutID = null; + + /** + * The previous time the step was called. + * + * @name Phaser.DOM.RequestAnimationFrame#lastTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.lastTime = 0; + + var _this = this; + + /** + * The RAF step function. + * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. + * + * @name Phaser.DOM.RequestAnimationFrame#step + * @type {FrameRequestCallback} + * @since 3.0.0 + */ + this.step = function step (timestamp) + { + // DOMHighResTimeStamp + _this.lastTime = _this.tick; + + _this.tick = timestamp; + + _this.timeOutID = window.requestAnimationFrame(step); + + _this.callback(timestamp); + }; + + /** + * The SetTimeout step function. + * Updates the local tick value, invokes the callback and schedules another call to setTimeout. + * + * @name Phaser.DOM.RequestAnimationFrame#stepTimeout + * @type {function} + * @since 3.0.0 + */ + this.stepTimeout = function stepTimeout () + { + var d = Date.now(); + + var delay = Math.max(16 + _this.lastTime - d, 0); + + _this.lastTime = _this.tick; + + _this.tick = d; + + _this.timeOutID = window.setTimeout(stepTimeout, delay); + + _this.callback(d); + }; + }, + + /** + * Starts the requestAnimationFrame or setTimeout process running. + * + * @method Phaser.DOM.RequestAnimationFrame#start + * @since 3.0.0 + * + * @param {FrameRequestCallback} callback - The callback to invoke each step. + * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? + */ + start: function (callback, forceSetTimeOut) + { + if (this.isRunning) + { + return; + } + + this.callback = callback; + + this.isSetTimeOut = forceSetTimeOut; + + this.isRunning = true; + + this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); + }, + + /** + * Stops the requestAnimationFrame or setTimeout from running. + * + * @method Phaser.DOM.RequestAnimationFrame#stop + * @since 3.0.0 + */ + stop: function () + { + this.isRunning = false; + + if (this.isSetTimeOut) + { + clearTimeout(this.timeOutID); + } + else + { + window.cancelAnimationFrame(this.timeOutID); + } + }, + + /** + * Stops the step from running and clears the callback reference. + * + * @method Phaser.DOM.RequestAnimationFrame#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.stop(); + + this.callback = NOOP; + } + +}); + +module.exports = RequestAnimationFrame; + + +/***/ }), +/* 342 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Attempts to remove the element from its parentNode in the DOM. + * + * @function Phaser.DOM.RemoveFromDOM + * @since 3.0.0 + * + * @param {HTMLElement} element - The DOM element to remove from its parent node. + */ +var RemoveFromDOM = function (element) +{ + if (element.parentNode) + { + element.parentNode.removeChild(element); + } +}; + +module.exports = RemoveFromDOM; + + +/***/ }), +/* 343 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given data string and parses it as XML. + * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. + * The parsed XML object is returned, or `null` if there was an error while parsing the data. + * + * @function Phaser.DOM.ParseXML + * @since 3.0.0 + * + * @param {string} data - The XML source stored in a string. + * + * @return {?(DOMParser|ActiveXObject)} The parsed XML data, or `null` if the data could not be parsed. + */ +var ParseXML = function (data) +{ + var xml = ''; + + try + { + if (window['DOMParser']) + { + var domparser = new DOMParser(); + xml = domparser.parseFromString(data, 'text/xml'); + } + else + { + xml = new ActiveXObject('Microsoft.XMLDOM'); + xml.loadXML(data); + } + } + catch (e) + { + xml = null; + } + + if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) + { + return null; + } + else + { + return xml; + } +}; + +module.exports = ParseXML; + + +/***/ }), +/* 344 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var OS = __webpack_require__(92); + +/** + * @callback ContentLoadedCallback + */ + +/** + * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. + * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. + * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. + * + * @function Phaser.DOM.DOMContentLoaded + * @since 3.0.0 + * + * @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded. + */ +var DOMContentLoaded = function (callback) +{ + if (document.readyState === 'complete' || document.readyState === 'interactive') + { + callback(); + + return; + } + + var check = function () + { + document.removeEventListener('deviceready', check, true); + document.removeEventListener('DOMContentLoaded', check, true); + window.removeEventListener('load', check, true); + + callback(); + }; + + if (!document.body) + { + window.setTimeout(check, 20); + } + else if (OS.cordova && !OS.cocoonJS) + { + // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready + document.addEventListener('deviceready', check, false); + } + else + { + document.addEventListener('DOMContentLoaded', check, true); + window.addEventListener('load', check, true); + } +}; + +module.exports = DOMContentLoaded; + + +/***/ }), +/* 345 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts a hue to an RGB color. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.HueToComponent + * @since 3.0.0 + * + * @param {number} p + * @param {number} q + * @param {number} t + * + * @return {number} The combined color value. + */ +var HueToComponent = function (p, q, t) +{ + if (t < 0) + { + t += 1; + } + + if (t > 1) + { + t -= 1; + } + + if (t < 1 / 6) + { + return p + (q - p) * 6 * t; + } + + if (t < 1 / 2) + { + return q; + } + + if (t < 2 / 3) + { + return p + (q - p) * (2 / 3 - t) * 6; + } + + return p; +}; + +module.exports = HueToComponent; + + +/***/ }), +/* 346 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns a string containing a hex representation of the given color component. + * + * @function Phaser.Display.Color.ComponentToHex + * @since 3.0.0 + * + * @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255. + * + * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. + */ +var ComponentToHex = function (color) +{ + var hex = color.toString(16); + + return (hex.length === 1) ? '0' + hex : hex; +}; + +module.exports = ComponentToHex; + + +/***/ }), +/* 347 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} InputColorObject + * + * @property {number} [r] - The red color value in the range 0 to 255. + * @property {number} [g] - The green color value in the range 0 to 255. + * @property {number} [b] - The blue color value in the range 0 to 255. + * @property {number} [a] - The alpha color value in the range 0 to 255. + */ + +/** + * @typedef {Object} ColorObject + * @property {number} r - The red color value in the range 0 to 255. + * @property {number} g - The green color value in the range 0 to 255. + * @property {number} b - The blue color value in the range 0 to 255. + * @property {number} a - The alpha color value in the range 0 to 255. + */ + +var Color = __webpack_require__(37); + +Color.ColorToRGBA = __webpack_require__(915); +Color.ComponentToHex = __webpack_require__(346); +Color.GetColor = __webpack_require__(177); +Color.GetColor32 = __webpack_require__(376); +Color.HexStringToColor = __webpack_require__(377); +Color.HSLToColor = __webpack_require__(914); +Color.HSVColorWheel = __webpack_require__(913); +Color.HSVToRGB = __webpack_require__(176); +Color.HueToComponent = __webpack_require__(345); +Color.IntegerToColor = __webpack_require__(374); +Color.IntegerToRGB = __webpack_require__(373); +Color.Interpolate = __webpack_require__(912); +Color.ObjectToColor = __webpack_require__(372); +Color.RandomRGB = __webpack_require__(911); +Color.RGBStringToColor = __webpack_require__(371); +Color.RGBToHSV = __webpack_require__(375); +Color.RGBToString = __webpack_require__(910); +Color.ValueToColor = __webpack_require__(178); + +module.exports = Color; + + +/***/ }), +/* 348 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Canvas.CanvasInterpolation + * @since 3.0.0 + */ +var CanvasInterpolation = { + + /** + * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setCrisp: function (canvas) + { + var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; + + types.forEach(function (type) + { + canvas.style['image-rendering'] = type; + }); + + canvas.style.msInterpolationMode = 'nearest-neighbor'; + + return canvas; + }, + + /** + * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). + * + * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * + * @return {HTMLCanvasElement} The canvas. + */ + setBicubic: function (canvas) + { + canvas.style['image-rendering'] = 'auto'; + canvas.style.msInterpolationMode = 'bicubic'; + + return canvas; + } + +}; + +module.exports = CanvasInterpolation; + + +/***/ }), +/* 349 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var CatmullRom = __webpack_require__(171); +var Class = __webpack_require__(0); +var Curve = __webpack_require__(70); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * [description] + * + * @class Spline + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2[]} [points] - [description] + */ +var SplineCurve = new Class({ + + Extends: Curve, + + initialize: + + function SplineCurve (points) + { + if (points === undefined) { points = []; } + + Curve.call(this, 'SplineCurve'); + + /** + * [description] + * + * @name Phaser.Curves.Spline#points + * @type {Phaser.Math.Vector2[]} + * @default [] + * @since 3.0.0 + */ + this.points = []; + + this.addPoints(points); + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#addPoints + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - [description] + * + * @return {Phaser.Curves.Spline} This curve object. + */ + addPoints: function (points) + { + for (var i = 0; i < points.length; i++) + { + var p = new Vector2(); + + if (typeof points[i] === 'number') + { + p.x = points[i]; + p.y = points[i + 1]; + i++; + } + else if (Array.isArray(points[i])) + { + // An array of arrays? + p.x = points[i][0]; + p.y = points[i][1]; + } + else + { + p.x = points[i].x; + p.y = points[i].y; + } + + this.points.push(p); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#addPoint + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + addPoint: function (x, y) + { + var vec = new Vector2(x, y); + + this.points.push(vec); + + return vec; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Spline#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.points[0]); + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * this.points.length; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Spline#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var points = this.points; + + var point = (points.length - 1) * t; + + var intPoint = Math.floor(point); + + var weight = point - intPoint; + + var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; + var p1 = points[intPoint]; + var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; + var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; + + return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * [description] + * + * @method Phaser.Curves.Spline#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + var points = []; + + for (var i = 0; i < this.points.length; i++) + { + points.push(this.points[i].x); + points.push(this.points[i].y); + } + + return { + type: this.type, + points: points + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.Spline.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Spline} [description] + */ +SplineCurve.fromJSON = function (data) +{ + return new SplineCurve(data.points); +}; + +module.exports = SplineCurve; + + +/***/ }), +/* 350 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * p; +} + +function P1 (t, p) +{ + return 2 * (1 - t) * t * p; +} + +function P2 (t, p) +{ + return t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = end point + +// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js + +/** + * A quadratic bezier interpolation method. + * + * @function Phaser.Math.Interpolation.QuadraticBezier + * @since 3.2.0 + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} p0 - The start point. + * @param {number} p1 - The control point. + * @param {number} p2 - The end point. + * + * @return {number} The interpolated value. + */ +var QuadraticBezierInterpolation = function (t, p0, p1, p2) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2); +}; + +module.exports = QuadraticBezierInterpolation; + + +/***/ }), +/* 351 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(70); +var QuadraticBezierInterpolation = __webpack_require__(350); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * [description] + * + * @class QuadraticBezier + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.2.0 + * + * @param {(Phaser.Math.Vector2|number[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + */ +var QuadraticBezier = new Class({ + + Extends: Curve, + + initialize: + + function QuadraticBezier (p0, p1, p2) + { + Curve.call(this, 'QuadraticBezier'); + + if (Array.isArray(p0)) + { + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p1 = p1; + + /** + * [description] + * + * @name Phaser.Curves.QuadraticBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.2.0 + */ + this.p2 = p2; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.QuadraticBezier#getStartPoint + * @since 3.2.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#getResolution + * @since 3.2.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.QuadraticBezier#getPoint + * @since 3.2.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + + return out.set( + QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), + QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) + ); + }, + + /** + * [description] + * + * @method Phaser.Curves.QuadraticBezier#draw + * @since 3.2.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - `Graphics` object to draw onto. + * @param {integer} [pointsTotal=32] - Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. + * + * @return {Phaser.GameObjects.Graphics} `Graphics` object that was drawn to. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * Converts the curve into a JSON compatible object. + * + * @method Phaser.Curves.QuadraticBezier#toJSON + * @since 3.2.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y + ] + }; + } + +}); + +/** + * Creates a curve from a JSON object, e. g. created by `toJSON`. + * + * @function Phaser.Curves.QuadraticBezier.fromJSON + * @since 3.2.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.QuadraticBezier} The created curve instance. + */ +QuadraticBezier.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + + return new QuadraticBezier(p0, p1, p2); +}; + +module.exports = QuadraticBezier; + + +/***/ }), +/* 352 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(70); +var FromPoints = __webpack_require__(173); +var Rectangle = __webpack_require__(9); +var Vector2 = __webpack_require__(3); + +var tmpVec2 = new Vector2(); + +/** + * @classdesc + * [description] + * + * @class Line + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|number[])} p0 - [description] + * @param {Phaser.Math.Vector2} [p1] - [description] + */ +var LineCurve = new Class({ + + Extends: Curve, + + initialize: + + // vec2s or array + function LineCurve (p0, p1) + { + Curve.call(this, 'LineCurve'); + + if (Array.isArray(p0)) + { + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * [description] + * + * @name Phaser.Curves.Line#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * [description] + * + * @name Phaser.Curves.Line#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + }, + + /** + * Returns a Rectangle where the position and dimensions match the bounds of this Curve. + * + * @method Phaser.Curves.Line#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the bounds in. If not given a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. + */ + getBounds: function (out) + { + if (out === undefined) { out = new Rectangle(); } + + return FromPoints([ this.p0, this.p1 ], out); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Line#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * [description] + * + * @method Phaser.Curves.Line#getResolution + * @since 3.0.0 + * + * @param {number} [divisions=1] - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + if (divisions === undefined) { divisions = 1; } + + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Line#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + if (t === 1) + { + return out.copy(this.p1); + } + + out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); + + return out; + }, + + // Line curve is linear, so we can overwrite default getPointAt + + /** + * [description] + * + * @method Phaser.Curves.Line#getPointAt + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} u - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPointAt: function (u, out) + { + return this.getPoint(u, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.Line#getTangent + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @return {Phaser.Math.Vector2} [description] + */ + getTangent: function () + { + var tangent = tmpVec2.copy(this.p1).subtract(this.p0); + + return tangent.normalize(); + }, + + // Override default Curve.draw because this is better than calling getPoints on a line! + + /** + * Draws this curve on the given Graphics object. + * + * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line color is. + * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. + * + * @method Phaser.Curves.Line#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. + * + * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. + */ + draw: function (graphics) + { + graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); + + // So you can chain graphics calls + return graphics; + }, + + /** + * [description] + * + * @method Phaser.Curves.Line#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y + ] + }; + } + +}); + +/** + * [description] + * + * @function Phaser.Curves.Line.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Line} [description] + */ +LineCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + + return new LineCurve(p0, p1); +}; + +module.exports = LineCurve; + + +/***/ }), +/* 353 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var Curve = __webpack_require__(70); +var DegToRad = __webpack_require__(31); +var GetValue = __webpack_require__(4); +var RadToDeg = __webpack_require__(172); +var Vector2 = __webpack_require__(3); + +/** + * @typedef {object} JSONEllipseCurve + * + * @property {string} type - The of the curve. + * @property {number} x - The x coordinate of the ellipse. + * @property {number} y - The y coordinate of the ellipse. + * @property {number} xRadius - The horizontal radius of ellipse. + * @property {number} yRadius - The vertical radius of ellipse. + * @property {integer} startAngle - The start angle of the ellipse, in degrees. + * @property {integer} endAngle - The end angle of the ellipse, in degrees. + * @property {boolean} clockwise - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @property {integer} rotation - The rotation of ellipse, in degrees. + */ + +/** + * @typedef {object} EllipseCurveConfig + * + * @property {number} [x=0] - The x coordinate of the ellipse. + * @property {number} [y=0] - The y coordinate of the ellipse. + * @property {number} [xRadius=0] - The horizontal radius of the ellipse. + * @property {number} [yRadius=0] - The vertical radius of the ellipse. + * @property {integer} [startAngle=0] - The start angle of the ellipse, in degrees. + * @property {integer} [endAngle=360] - The end angle of the ellipse, in degrees. + * @property {boolean} [clockwise=false] - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @property {integer} [rotation=0] - The rotation of the ellipse, in degrees. + */ + +/** + * @classdesc + * An Elliptical Curve derived from the Base Curve class. + * + * See https://en.wikipedia.org/wiki/Elliptic_curve for more details. + * + * @class Ellipse + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(number|EllipseCurveConfig)} [x=0] - The x coordinate of the ellipse, or an Ellipse Curve configuration object. + * @param {number} [y=0] - The y coordinate of the ellipse. + * @param {number} [xRadius=0] - The horizontal radius of ellipse. + * @param {number} [yRadius=0] - The vertical radius of ellipse. + * @param {integer} [startAngle=0] - The start angle of the ellipse, in degrees. + * @param {integer} [endAngle=360] - The end angle of the ellipse, in degrees. + * @param {boolean} [clockwise=false] - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @param {integer} [rotation=0] - The rotation of the ellipse, in degrees. + */ +var EllipseCurve = new Class({ + + Extends: Curve, + + initialize: + + function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) + { + if (typeof x === 'object') + { + var config = x; + + x = GetValue(config, 'x', 0); + y = GetValue(config, 'y', 0); + xRadius = GetValue(config, 'xRadius', 0); + yRadius = GetValue(config, 'yRadius', xRadius); + startAngle = GetValue(config, 'startAngle', 0); + endAngle = GetValue(config, 'endAngle', 360); + clockwise = GetValue(config, 'clockwise', false); + rotation = GetValue(config, 'rotation', 0); + } + else + { + if (yRadius === undefined) { yRadius = xRadius; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (clockwise === undefined) { clockwise = false; } + if (rotation === undefined) { rotation = 0; } + } + + Curve.call(this, 'EllipseCurve'); + + // Center point + + /** + * The center point of the ellipse. Used for calculating rotation. + * + * @name Phaser.Curves.Ellipse#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = new Vector2(x, y); + + /** + * The horizontal radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#_xRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._xRadius = xRadius; + + /** + * The vertical radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#_yRadius + * @type {number} + * @private + * @since 3.0.0 + */ + this._yRadius = yRadius; + + // Radians + + /** + * The starting angle of the ellipse in radians. + * + * @name Phaser.Curves.Ellipse#_startAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._startAngle = DegToRad(startAngle); + + /** + * The end angle of the ellipse in radians. + * + * @name Phaser.Curves.Ellipse#_endAngle + * @type {number} + * @private + * @since 3.0.0 + */ + this._endAngle = DegToRad(endAngle); + + /** + * Anti-clockwise direction. + * + * @name Phaser.Curves.Ellipse#_clockwise + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._clockwise = clockwise; + + /** + * The rotation of the arc. + * + * @name Phaser.Curves.Ellipse#_rotation + * @type {number} + * @private + * @since 3.0.0 + */ + this._rotation = DegToRad(rotation); + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.Ellipse#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return this.getPoint(0, out); + }, + + /** + * [description] + * + * @method Phaser.Curves.Ellipse#getResolution + * @since 3.0.0 + * + * @param {number} divisions - [description] + * + * @return {number} [description] + */ + getResolution: function (divisions) + { + return divisions * 2; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.Ellipse#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var twoPi = Math.PI * 2; + var deltaAngle = this._endAngle - this._startAngle; + var samePoints = Math.abs(deltaAngle) < Number.EPSILON; + + // ensures that deltaAngle is 0 .. 2 PI + while (deltaAngle < 0) + { + deltaAngle += twoPi; + } + + while (deltaAngle > twoPi) + { + deltaAngle -= twoPi; + } + + if (deltaAngle < Number.EPSILON) + { + if (samePoints) + { + deltaAngle = 0; + } + else + { + deltaAngle = twoPi; + } + } + + if (this._clockwise && !samePoints) + { + if (deltaAngle === twoPi) + { + deltaAngle = - twoPi; + } + else + { + deltaAngle = deltaAngle - twoPi; + } + } + + var angle = this._startAngle + t * deltaAngle; + var x = this.p0.x + this._xRadius * Math.cos(angle); + var y = this.p0.y + this._yRadius * Math.sin(angle); + + if (this._rotation !== 0) + { + var cos = Math.cos(this._rotation); + var sin = Math.sin(this._rotation); + + var tx = x - this.p0.x; + var ty = y - this.p0.y; + + // Rotate the point about the center of the ellipse. + x = tx * cos - ty * sin + this.p0.x; + y = tx * sin + ty * cos + this.p0.y; + } + + return out.set(x, y); + }, + + /** + * Sets the horizontal radius of this curve. + * + * @method Phaser.Curves.Ellipse#setXRadius + * @since 3.0.0 + * + * @param {number} value - The horizontal radius of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setXRadius: function (value) + { + this.xRadius = value; + + return this; + }, + + /** + * Sets the vertical radius of this curve. + * + * @method Phaser.Curves.Ellipse#setYRadius + * @since 3.0.0 + * + * @param {number} value - The vertical radius of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setYRadius: function (value) + { + this.yRadius = value; + + return this; + }, + + /** + * Sets the width of this curve. + * + * @method Phaser.Curves.Ellipse#setWidth + * @since 3.0.0 + * + * @param {number} value - The width of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setWidth: function (value) + { + this.xRadius = value * 2; + + return this; + }, + + /** + * Sets the height of this curve. + * + * @method Phaser.Curves.Ellipse#setHeight + * @since 3.0.0 + * + * @param {number} value - The height of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setHeight: function (value) + { + this.yRadius = value * 2; + + return this; + }, + + /** + * Sets the start angle of this curve. + * + * @method Phaser.Curves.Ellipse#setStartAngle + * @since 3.0.0 + * + * @param {number} value - The start angle of this curve, in radians. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setStartAngle: function (value) + { + this.startAngle = value; + + return this; + }, + + /** + * Sets the end angle of this curve. + * + * @method Phaser.Curves.Ellipse#setEndAngle + * @since 3.0.0 + * + * @param {number} value - The end angle of this curve, in radians. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setEndAngle: function (value) + { + this.endAngle = value; + + return this; + }, + + /** + * Sets if this curve extends clockwise or anti-clockwise. + * + * @method Phaser.Curves.Ellipse#setClockwise + * @since 3.0.0 + * + * @param {boolean} value - The clockwise state of this curve. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setClockwise: function (value) + { + this.clockwise = value; + + return this; + }, + + /** + * Sets the rotation of this curve. + * + * @method Phaser.Curves.Ellipse#setRotation + * @since 3.0.0 + * + * @param {number} value - The rotation of this curve, in radians. + * + * @return {Phaser.Curves.Ellipse} This curve object. + */ + setRotation: function (value) + { + this.rotation = value; + + return this; + }, + + /** + * The x coordinate of the center of the ellipse. + * + * @name Phaser.Curves.Ellipse#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.p0.x; + }, + + set: function (value) + { + this.p0.x = value; + } + + }, + + /** + * The y coordinate of the center of the ellipse. + * + * @name Phaser.Curves.Ellipse#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.p0.y; + }, + + set: function (value) + { + this.p0.y = value; + } + + }, + + /** + * The horizontal radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#xRadius + * @type {number} + * @since 3.0.0 + */ + xRadius: { + + get: function () + { + return this._xRadius; + }, + + set: function (value) + { + this._xRadius = value; + } + + }, + + /** + * The vertical radius of the ellipse. + * + * @name Phaser.Curves.Ellipse#yRadius + * @type {number} + * @since 3.0.0 + */ + yRadius: { + + get: function () + { + return this._yRadius; + }, + + set: function (value) + { + this._yRadius = value; + } + + }, + + /** + * The start angle of the ellipse in degrees. + * + * @name Phaser.Curves.Ellipse#startAngle + * @type {number} + * @since 3.0.0 + */ + startAngle: { + + get: function () + { + return RadToDeg(this._startAngle); + }, + + set: function (value) + { + this._startAngle = DegToRad(value); + } + + }, + + /** + * The end angle of the ellipse in degrees. + * + * @name Phaser.Curves.Ellipse#endAngle + * @type {number} + * @since 3.0.0 + */ + endAngle: { + + get: function () + { + return RadToDeg(this._endAngle); + }, + + set: function (value) + { + this._endAngle = DegToRad(value); + } + + }, + + /** + * `true` if the ellipse rotation is clockwise or `false` if anti-clockwise. + * + * @name Phaser.Curves.Ellipse#clockwise + * @type {boolean} + * @since 3.0.0 + */ + clockwise: { + + get: function () + { + return this._clockwise; + }, + + set: function (value) + { + this._clockwise = value; + } + + }, + + /** + * The rotation of the ellipse, relative to the center, in degrees. + * + * @name Phaser.Curves.Ellipse#angle + * @type {number} + * @since 3.14.0 + */ + angle: { + + get: function () + { + return RadToDeg(this._rotation); + }, + + set: function (value) + { + this._rotation = DegToRad(value); + } + + }, + + /** + * The rotation of the ellipse, relative to the center, in radians. + * + * @name Phaser.Curves.Ellipse#rotation + * @type {number} + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = value; + } + + }, + + /** + * JSON serialization of the curve. + * + * @method Phaser.Curves.Ellipse#toJSON + * @since 3.0.0 + * + * @return {JSONEllipseCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + x: this.p0.x, + y: this.p0.y, + xRadius: this._xRadius, + yRadius: this._yRadius, + startAngle: RadToDeg(this._startAngle), + endAngle: RadToDeg(this._endAngle), + clockwise: this._clockwise, + rotation: RadToDeg(this._rotation) + }; + } + +}); + +/** + * Creates a curve from the provided Ellipse Curve Configuration object. + * + * @function Phaser.Curves.Ellipse.fromJSON + * @since 3.0.0 + * + * @param {JSONEllipseCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.Ellipse} The ellipse curve constructed from the configuration object. + */ +EllipseCurve.fromJSON = function (data) +{ + return new EllipseCurve(data); +}; + +module.exports = EllipseCurve; + + +/***/ }), +/* 354 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +function P0 (t, p) +{ + var k = 1 - t; + + return k * k * k * p; +} + +function P1 (t, p) +{ + var k = 1 - t; + + return 3 * k * k * t * p; +} + +function P2 (t, p) +{ + return 3 * (1 - t) * t * t * p; +} + +function P3 (t, p) +{ + return t * t * t * p; +} + +// p0 = start point +// p1 = control point 1 +// p2 = control point 2 +// p3 = end point + +// https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a + +/** + * A cubic bezier interpolation method. + * + * @function Phaser.Math.Interpolation.CubicBezier + * @since 3.0.0 + * + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} p0 - The start point. + * @param {number} p1 - The first control point. + * @param {number} p2 - The second control point. + * @param {number} p3 - The end point. + * + * @return {number} The interpolated value. + */ +var CubicBezierInterpolation = function (t, p0, p1, p2, p3) +{ + return P0(t, p0) + P1(t, p1) + P2(t, p2) + P3(t, p3); +}; + +module.exports = CubicBezierInterpolation; + + +/***/ }), +/* 355 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) + +var Class = __webpack_require__(0); +var CubicBezier = __webpack_require__(354); +var Curve = __webpack_require__(70); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A higher-order Bézier curve constructed of four points. + * + * @class CubicBezier + * @extends Phaser.Curves.Curve + * @memberof Phaser.Curves + * @constructor + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. + * @param {Phaser.Math.Vector2} p1 - Control Point 1. + * @param {Phaser.Math.Vector2} p2 - Control Point 2. + * @param {Phaser.Math.Vector2} p3 - End Point. + */ +var CubicBezierCurve = new Class({ + + Extends: Curve, + + initialize: + + function CubicBezierCurve (p0, p1, p2, p3) + { + Curve.call(this, 'CubicBezierCurve'); + + if (Array.isArray(p0)) + { + p3 = new Vector2(p0[6], p0[7]); + p2 = new Vector2(p0[4], p0[5]); + p1 = new Vector2(p0[2], p0[3]); + p0 = new Vector2(p0[0], p0[1]); + } + + /** + * The start point of this curve. + * + * @name Phaser.Curves.CubicBezier#p0 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p0 = p0; + + /** + * The first control point of this curve. + * + * @name Phaser.Curves.CubicBezier#p1 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p1 = p1; + + /** + * The second control point of this curve. + * + * @name Phaser.Curves.CubicBezier#p2 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p2 = p2; + + /** + * The end point of this curve. + * + * @name Phaser.Curves.CubicBezier#p3 + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.p3 = p3; + }, + + /** + * Gets the starting point on the curve. + * + * @method Phaser.Curves.CubicBezier#getStartPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getStartPoint: function (out) + { + if (out === undefined) { out = new Vector2(); } + + return out.copy(this.p0); + }, + + /** + * Returns the resolution of this curve. + * + * @method Phaser.Curves.CubicBezier#getResolution + * @since 3.0.0 + * + * @param {number} divisions - The amount of divisions used by this curve. + * + * @return {number} The resolution of the curve. + */ + getResolution: function (divisions) + { + return divisions; + }, + + /** + * Get point at relative position in curve according to length. + * + * @method Phaser.Curves.CubicBezier#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. + * + * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. + */ + getPoint: function (t, out) + { + if (out === undefined) { out = new Vector2(); } + + var p0 = this.p0; + var p1 = this.p1; + var p2 = this.p2; + var p3 = this.p3; + + return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); + }, + + /** + * Draws this curve to the specified graphics object. + * + * @method Phaser.Curves.CubicBezier#draw + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] + * + * @param {Phaser.GameObjects.Graphics} graphics - The graphics object this curve should be drawn to. + * @param {integer} [pointsTotal=32] - The number of intermediary points that make up this curve. A higher number of points will result in a smoother curve. + * + * @return {Phaser.GameObjects.Graphics} The graphics object this curve was drawn to. Useful for method chaining. + */ + draw: function (graphics, pointsTotal) + { + if (pointsTotal === undefined) { pointsTotal = 32; } + + var points = this.getPoints(pointsTotal); + + graphics.beginPath(); + graphics.moveTo(this.p0.x, this.p0.y); + + for (var i = 1; i < points.length; i++) + { + graphics.lineTo(points[i].x, points[i].y); + } + + graphics.strokePath(); + + // So you can chain graphics calls + return graphics; + }, + + /** + * Returns a JSON object that describes this curve. + * + * @method Phaser.Curves.CubicBezier#toJSON + * @since 3.0.0 + * + * @return {JSONCurve} The JSON object containing this curve data. + */ + toJSON: function () + { + return { + type: this.type, + points: [ + this.p0.x, this.p0.y, + this.p1.x, this.p1.y, + this.p2.x, this.p2.y, + this.p3.x, this.p3.y + ] + }; + } + +}); + +/** + * Generates a curve from a JSON object. + * + * @function Phaser.Curves.CubicBezier.fromJSON + * @since 3.0.0 + * + * @param {JSONCurve} data - The JSON object containing this curve data. + * + * @return {Phaser.Curves.CubicBezier} The curve generated from the JSON object. + */ +CubicBezierCurve.fromJSON = function (data) +{ + var points = data.points; + + var p0 = new Vector2(points[0], points[1]); + var p1 = new Vector2(points[2], points[3]); + var p2 = new Vector2(points[4], points[5]); + var p3 = new Vector2(points[6], points[7]); + + return new CubicBezierCurve(p0, p1, p2, p3); +}; + +module.exports = CubicBezierCurve; + + +/***/ }), +/* 356 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) + * + * @name Phaser.Create.Palettes.ARNE16 + * @since 3.0.0 + * + * @type {Palette} + */ +module.exports = { + 0: '#000', + 1: '#9D9D9D', + 2: '#FFF', + 3: '#BE2633', + 4: '#E06F8B', + 5: '#493C2B', + 6: '#A46422', + 7: '#EB8931', + 8: '#F7E26B', + 9: '#2F484E', + A: '#44891A', + B: '#A3CE27', + C: '#1B2632', + D: '#005784', + E: '#31A2F2', + F: '#B2DCEF' +}; + + +/***/ }), +/* 357 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Arne16 = __webpack_require__(356); +var CanvasPool = __webpack_require__(24); +var GetValue = __webpack_require__(4); + +/** + * @callback GenerateTextureRendererCallback + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {CanvasRenderingContext2D} context - [description] + */ + +/** + * @typedef {object} GenerateTextureConfig + * + * @property {array} [data=[]] - [description] + * @property {HTMLCanvasElement} [canvas=null] - [description] + * @property {Palette} [palette=Arne16] - [description] + * @property {number} [pixelWidth=1] - The width of each 'pixel' in the generated texture. + * @property {number} [pixelHeight=1] - The height of each 'pixel' in the generated texture. + * @property {boolean} [resizeCanvas=true] - [description] + * @property {boolean} [clearCanvas=true] - [description] + * @property {GenerateTextureRendererCallback} [preRender] - [description] + * @property {GenerateTextureRendererCallback} [postRender] - [description] + */ + +/** + * [description] + * + * @function Phaser.Create.GenerateTexture + * @since 3.0.0 + * + * @param {GenerateTextureConfig} config - [description] + * + * @return {HTMLCanvasElement} [description] + */ +var GenerateTexture = function (config) +{ + var data = GetValue(config, 'data', []); + var canvas = GetValue(config, 'canvas', null); + var palette = GetValue(config, 'palette', Arne16); + var pixelWidth = GetValue(config, 'pixelWidth', 1); + var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); + var resizeCanvas = GetValue(config, 'resizeCanvas', true); + var clearCanvas = GetValue(config, 'clearCanvas', true); + var preRender = GetValue(config, 'preRender', null); + var postRender = GetValue(config, 'postRender', null); + + var width = Math.floor(Math.abs(data[0].length * pixelWidth)); + var height = Math.floor(Math.abs(data.length * pixelHeight)); + + if (!canvas) + { + canvas = CanvasPool.create2D(this, width, height); + resizeCanvas = false; + clearCanvas = false; + } + + if (resizeCanvas) + { + canvas.width = width; + canvas.height = height; + } + + var ctx = canvas.getContext('2d'); + + if (clearCanvas) + { + ctx.clearRect(0, 0, width, height); + } + + // preRender Callback? + if (preRender) + { + preRender(canvas, ctx); + } + + // Draw it + for (var y = 0; y < data.length; y++) + { + var row = data[y]; + + for (var x = 0; x < row.length; x++) + { + var d = row[x]; + + if (d !== '.' && d !== ' ') + { + ctx.fillStyle = palette[d]; + ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); + } + } + } + + // postRender Callback? + if (postRender) + { + postRender(canvas, ctx); + } + + return canvas; +}; + +module.exports = GenerateTexture; + + +/***/ }), +/* 358 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Stepped + */ + +module.exports = __webpack_require__(952); + + +/***/ }), +/* 359 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Sine + */ + +module.exports = { + + In: __webpack_require__(955), + Out: __webpack_require__(954), + InOut: __webpack_require__(953) + +}; + + +/***/ }), +/* 360 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Quintic + */ + +module.exports = { + + In: __webpack_require__(958), + Out: __webpack_require__(957), + InOut: __webpack_require__(956) + +}; + + +/***/ }), +/* 361 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Quartic + */ + +module.exports = { + + In: __webpack_require__(961), + Out: __webpack_require__(960), + InOut: __webpack_require__(959) + +}; + + +/***/ }), +/* 362 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Quadratic + */ + +module.exports = { + + In: __webpack_require__(964), + Out: __webpack_require__(963), + InOut: __webpack_require__(962) + +}; + + +/***/ }), +/* 363 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Linear + */ + +module.exports = __webpack_require__(965); + + +/***/ }), +/* 364 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Expo + */ + +module.exports = { + + In: __webpack_require__(968), + Out: __webpack_require__(967), + InOut: __webpack_require__(966) + +}; + + +/***/ }), +/* 365 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Elastic + */ + +module.exports = { + + In: __webpack_require__(971), + Out: __webpack_require__(970), + InOut: __webpack_require__(969) + +}; + + +/***/ }), +/* 366 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Cubic + */ + +module.exports = { + + In: __webpack_require__(974), + Out: __webpack_require__(973), + InOut: __webpack_require__(972) + +}; + + +/***/ }), +/* 367 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Circular + */ + +module.exports = { + + In: __webpack_require__(977), + Out: __webpack_require__(976), + InOut: __webpack_require__(975) + +}; + + +/***/ }), +/* 368 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Bounce + */ + +module.exports = { + + In: __webpack_require__(980), + Out: __webpack_require__(979), + InOut: __webpack_require__(978) + +}; + + +/***/ }), +/* 369 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing.Back + */ + +module.exports = { + + In: __webpack_require__(983), + Out: __webpack_require__(982), + InOut: __webpack_require__(981) + +}; + + +/***/ }), +/* 370 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -51353,15 +89652,17 @@ module.exports = init(); module.exports = { - Fade: __webpack_require__(565), - Flash: __webpack_require__(564), - Shake: __webpack_require__(563) + Fade: __webpack_require__(986), + Flash: __webpack_require__(985), + Pan: __webpack_require__(984), + Shake: __webpack_require__(951), + Zoom: __webpack_require__(950) }; /***/ }), -/* 205 */ +/* 371 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -51370,7 +89671,1302 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BaseCache = __webpack_require__(206); +var Color = __webpack_require__(37); + +/** + * Converts a CSS 'web' string into a Phaser Color object. + * + * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. + * + * @function Phaser.Display.Color.RGBStringToColor + * @since 3.0.0 + * + * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. + * + * @return {Phaser.Display.Color} A Color object. + */ +var RGBStringToColor = function (rgb) +{ + var color = new Color(); + + var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); + + if (result) + { + var r = parseInt(result[1], 10); + var g = parseInt(result[2], 10); + var b = parseInt(result[3], 10); + var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; + + color.setTo(r, g, b, a * 255); + } + + return color; +}; + +module.exports = RGBStringToColor; + + +/***/ }), +/* 372 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(37); + +/** + * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. + * + * @function Phaser.Display.Color.ObjectToColor + * @since 3.0.0 + * + * @param {InputColorObject} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. + * + * @return {Phaser.Display.Color} A Color object. + */ +var ObjectToColor = function (input) +{ + return new Color(input.r, input.g, input.b, input.a); +}; + +module.exports = ObjectToColor; + + +/***/ }), +/* 373 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Return the component parts of a color as an Object with the properties alpha, red, green, blue. + * + * Alpha will only be set if it exists in the given color (0xAARRGGBB) + * + * @function Phaser.Display.Color.IntegerToRGB + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + */ +var IntegerToRGB = function (color) +{ + if (color > 16777215) + { + // The color value has an alpha component + return { + a: color >>> 24, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } + else + { + return { + a: 255, + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF + }; + } +}; + +module.exports = IntegerToRGB; + + +/***/ }), +/* 374 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(37); +var IntegerToRGB = __webpack_require__(373); + +/** + * Converts the given color value into an instance of a Color object. + * + * @function Phaser.Display.Color.IntegerToColor + * @since 3.0.0 + * + * @param {integer} input - The color value to convert into a Color object. + * + * @return {Phaser.Display.Color} A Color object. + */ +var IntegerToColor = function (input) +{ + var rgb = IntegerToRGB(input); + + return new Color(rgb.r, rgb.g, rgb.b, rgb.a); +}; + +module.exports = IntegerToColor; + + +/***/ }), +/* 375 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} HSVColorObject + * + * @property {number} h - The hue color value. A number between 0 and 1 + * @property {number} s - The saturation color value. A number between 0 and 1 + * @property {number} v - The lightness color value. A number between 0 and 1 + */ + +/** + * Converts an RGB color value to HSV (hue, saturation and value). + * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. + * Based on code by Michael Jackson (https://github.com/mjijackson) + * + * @function Phaser.Display.Color.RGBToHSV + * @since 3.0.0 + * + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * @param {(HSVColorObject|Phaser.Display.Color)} [out] - An object to store the color values in. If not given an HSV Color Object will be created. + * + * @return {(HSVColorObject|Phaser.Display.Color)} An object with the properties `h`, `s` and `v` set. + */ +var RGBToHSV = function (r, g, b, out) +{ + if (out === undefined) { out = { h: 0, s: 0, v: 0 }; } + + r /= 255; + g /= 255; + b /= 255; + + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var d = max - min; + + // achromatic by default + var h = 0; + var s = (max === 0) ? 0 : d / max; + var v = max; + + if (max !== min) + { + if (max === r) + { + h = (g - b) / d + ((g < b) ? 6 : 0); + } + else if (max === g) + { + h = (b - r) / d + 2; + } + else if (max === b) + { + h = (r - g) / d + 4; + } + + h /= 6; + } + + if (out.hasOwnProperty('_h')) + { + out._h = h; + out._s = s; + out._v = v; + } + else + { + out.h = h; + out.s = s; + out.v = v; + } + + return out; +}; + +module.exports = RGBToHSV; + + +/***/ }), +/* 376 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given an alpha and 3 color values this will return an integer representation of it. + * + * @function Phaser.Display.Color.GetColor32 + * @since 3.0.0 + * + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} alpha - The alpha color value. A number between 0 and 255. + * + * @return {number} The combined color value. + */ +var GetColor32 = function (red, green, blue, alpha) +{ + return alpha << 24 | red << 16 | green << 8 | blue; +}; + +module.exports = GetColor32; + + +/***/ }), +/* 377 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(37); + +/** + * Converts a hex string into a Phaser Color object. + * + * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. + * + * An alpha channel is _not_ supported. + * + * @function Phaser.Display.Color.HexStringToColor + * @since 3.0.0 + * + * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. + * + * @return {Phaser.Display.Color} A Color object populated by the values of the given string. + */ +var HexStringToColor = function (hex) +{ + var color = new Color(); + + // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") + hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) + { + return r + r + g + g + b + b; + }); + + var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); + + if (result) + { + var r = parseInt(result[1], 16); + var g = parseInt(result[2], 16); + var b = parseInt(result[3], 16); + + color.setTo(r, g, b); + } + + return color; +}; + +module.exports = HexStringToColor; + + +/***/ }), +/* 378 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCamera = __webpack_require__(121); +var CanvasPool = __webpack_require__(24); +var CenterOn = __webpack_require__(175); +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var Components = __webpack_require__(14); +var Effects = __webpack_require__(370); +var Linear = __webpack_require__(119); +var Rectangle = __webpack_require__(9); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * A Camera. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * A Camera also has built-in special effects including Fade, Flash and Camera Shake. + * + * @class Camera + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Cameras.Scene2D.BaseCamera + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.Tint + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var Camera = new Class({ + + Extends: BaseCamera, + + Mixins: [ + Components.Flip, + Components.Tint + ], + + initialize: + + function Camera (x, y, width, height) + { + BaseCamera.call(this, x, y, width, height); + + /** + * Does this Camera allow the Game Objects it renders to receive input events? + * + * @name Phaser.Cameras.Scene2D.Camera#inputEnabled + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.inputEnabled = true; + + /** + * The Camera Fade effect handler. + * To fade this camera see the `Camera.fade` methods. + * + * @name Phaser.Cameras.Scene2D.Camera#fadeEffect + * @type {Phaser.Cameras.Scene2D.Effects.Fade} + * @since 3.5.0 + */ + this.fadeEffect = new Effects.Fade(this); + + /** + * The Camera Flash effect handler. + * To flash this camera see the `Camera.flash` method. + * + * @name Phaser.Cameras.Scene2D.Camera#flashEffect + * @type {Phaser.Cameras.Scene2D.Effects.Flash} + * @since 3.5.0 + */ + this.flashEffect = new Effects.Flash(this); + + /** + * The Camera Shake effect handler. + * To shake this camera see the `Camera.shake` method. + * + * @name Phaser.Cameras.Scene2D.Camera#shakeEffect + * @type {Phaser.Cameras.Scene2D.Effects.Shake} + * @since 3.5.0 + */ + this.shakeEffect = new Effects.Shake(this); + + /** + * The Camera Pan effect handler. + * To pan this camera see the `Camera.pan` method. + * + * @name Phaser.Cameras.Scene2D.Camera#panEffect + * @type {Phaser.Cameras.Scene2D.Effects.Pan} + * @since 3.11.0 + */ + this.panEffect = new Effects.Pan(this); + + /** + * The Camera Zoom effect handler. + * To zoom this camera see the `Camera.zoom` method. + * + * @name Phaser.Cameras.Scene2D.Camera#zoomEffect + * @type {Phaser.Cameras.Scene2D.Effects.Zoom} + * @since 3.11.0 + */ + this.zoomEffect = new Effects.Zoom(this); + + /** + * The linear interpolation value to use when following a target. + * + * Can also be set via `setLerp` or as part of the `startFollow` call. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * + * @name Phaser.Cameras.Scene2D.Camera#lerp + * @type {Phaser.Math.Vector2} + * @since 3.9.0 + */ + this.lerp = new Vector2(1, 1); + + /** + * The values stored in this property are subtracted from the Camera targets position, allowing you to + * offset the camera from the actual target x/y coordinates by this amount. + * Can also be set via `setFollowOffset` or as part of the `startFollow` call. + * + * @name Phaser.Cameras.Scene2D.Camera#followOffset + * @type {Phaser.Math.Vector2} + * @since 3.9.0 + */ + this.followOffset = new Vector2(); + + /** + * The Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * You can directly set this property to be an instance of a Rectangle. Or, you can use the + * `setDeadzone` method for a chainable approach. + * + * The rectangle you provide can have its dimensions adjusted dynamically, however, please + * note that its position is updated every frame, as it is constantly re-centered on the cameras mid point. + * + * Calling `setDeadzone` with no arguments will reset an active deadzone, as will setting this property + * to `null`. + * + * @name Phaser.Cameras.Scene2D.Camera#deadzone + * @type {?Phaser.Geom.Rectangle} + * @since 3.11.0 + */ + this.deadzone = null; + + /** + * Internal follow target reference. + * + * @name Phaser.Cameras.Scene2D.Camera#_follow + * @type {?any} + * @private + * @default null + * @since 3.0.0 + */ + this._follow = null; + + /** + * Is this Camera rendering directly to the canvas or to a texture? + * + * Enable rendering to texture with the method `setRenderToTexture` (just enabling this boolean won't be enough) + * + * Once enabled you can toggle it by switching this property. + * + * To properly remove a render texture you should call the `clearRenderToTexture()` method. + * + * @name Phaser.Cameras.Scene2D.Camera#renderToTexture + * @type {boolean} + * @default false + * @since 3.13.0 + */ + this.renderToTexture = false; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the HTML Canvas Element that the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#canvas + * @type {HTMLCanvasElement} + * @since 3.13.0 + */ + this.canvas = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the Rendering Context belonging to the Canvas element the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#context + * @type {CanvasRenderingContext2D} + * @since 3.13.0 + */ + this.context = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Texture belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#framebuffer + * @type {?WebGLTexture} + * @since 3.13.0 + */ + this.glTexture = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Frame Buffer belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#framebuffer + * @type {?WebGLFramebuffer} + * @since 3.13.0 + */ + this.framebuffer = null; + + /** + * If this Camera has been set to render to a texture and to use a custom pipeline, + * then this holds a reference to the pipeline the Camera is drawing with. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#pipeline + * @type {any} + * @since 3.13.0 + */ + this.pipeline = null; + }, + + /** + * Sets the Camera to render to a texture instead of to the main canvas. + * + * The Camera will redirect all Game Objects it's asked to render to this texture. + * + * During the render sequence, the texture itself will then be rendered to the main canvas. + * + * Doing this gives you the ability to modify the texture before this happens, + * allowing for special effects such as Camera specific shaders, or post-processing + * on the texture. + * + * If running under Canvas the Camera will render to its `canvas` property. + * + * If running under WebGL the Camera will create a frame buffer, which is stored in its `framebuffer` and `glTexture` properties. + * + * If you set a camera to render to a texture then it will emit 2 events during the render loop: + * + * First, it will emit the event `prerender`. This happens right before any Game Object's are drawn to the Camera texture. + * + * Then, it will emit the event `postrender`. This happens after all Game Object's have been drawn, but right before the + * Camera texture is rendered to the main game canvas. It's the final point at which you can manipulate the texture before + * it appears in-game. + * + * You should not enable this unless you plan on actually using the texture it creates + * somehow, otherwise you're just doubling the work required to render your game. + * + * To temporarily disable rendering to a texture, toggle the `renderToTexture` boolean. + * + * If you no longer require the Camera to render to a texture, call the `clearRenderToTexture` method, + * which will delete the respective textures and free-up resources. + * + * @method Phaser.Cameras.Scene2D.Camera#setRenderToTexture + * @since 3.13.0 + * + * @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} [pipeline] - An optional WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setRenderToTexture: function (pipeline) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl) + { + this.glTexture = renderer.createTextureFromSource(null, this.width, this.height, 0); + this.framebuffer = renderer.createFramebuffer(this.width, this.height, this.glTexture, false); + } + else + { + this.canvas = CanvasPool.create2D(this, this.width, this.height); + this.context = this.canvas.getContext('2d'); + } + + this.renderToTexture = true; + + if (pipeline) + { + this.setPipeline(pipeline); + } + + return this; + }, + + /** + * Sets the WebGL pipeline this Camera is using when rendering to a texture. + * + * You can pass either the string-based name of the pipeline, or a reference to the pipeline itself. + * + * Call this method with no arguments to clear any previously set pipeline. + * + * @method Phaser.Cameras.Scene2D.Camera#setPipeline + * @since 3.13.0 + * + * @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} [pipeline] - The WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. Or if left empty it will clear the pipeline. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setPipeline: function (pipeline) + { + if (typeof pipeline === 'string') + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl && renderer.hasPipeline(pipeline)) + { + this.pipeline = renderer.getPipeline(pipeline); + } + } + else + { + this.pipeline = pipeline; + } + + return this; + }, + + /** + * If this Camera was set to render to a texture, this will clear the resources it was using and + * redirect it to render back to the primary Canvas again. + * + * If you only wish to temporarily disable rendering to a texture then you can toggle the + * property `renderToTexture` instead. + * + * @method Phaser.Cameras.Scene2D.Camera#clearRenderToTexture + * @since 3.13.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + clearRenderToTexture: function () + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl) + { + if (this.framebuffer) + { + renderer.deleteFramebuffer(this.framebuffer); + } + + if (this.glTexture) + { + renderer.deleteTexture(this.glTexture); + } + + this.framebuffer = null; + this.glTexture = null; + this.pipeline = null; + } + else + { + CanvasPool.remove(this); + + this.canvas = null; + this.context = null; + } + + this.renderToTexture = false; + + return this; + }, + + /** + * Sets the Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point + * of the camera. This allows you to use the object for additional game related checks, such as + * testing if an object is within it or not via a Rectangle.contains call. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * Calling this method with no arguments will reset an active deadzone. + * + * @method Phaser.Cameras.Scene2D.Camera#setDeadzone + * @since 3.11.0 + * + * @param {number} [width] - The width of the deadzone rectangle in pixels. If not specified the deadzone is removed. + * @param {number} [height] - The height of the deadzone rectangle in pixels. + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + setDeadzone: function (width, height) + { + if (width === undefined) + { + this.deadzone = null; + } + else + { + if (this.deadzone) + { + this.deadzone.width = width; + this.deadzone.height = height; + } + else + { + this.deadzone = new Rectangle(0, 0, width, height); + } + + if (this._follow) + { + var originX = this.width / 2; + var originY = this.height / 2; + + var fx = this._follow.x - this.followOffset.x; + var fy = this._follow.y - this.followOffset.y; + + this.midPoint.set(fx, fy); + + this.scrollX = fx - originX; + this.scrollY = fy - originY; + } + + CenterOn(this.deadzone, this.midPoint.x, this.midPoint.y); + } + + return this; + }, + + /** + * Fades the Camera in from the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeIn + * @since 3.3.0 + * + * @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 {function} [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} This Camera instance. + */ + fadeIn: function (duration, red, green, blue, callback, context) + { + return this.fadeEffect.start(false, duration, red, green, blue, true, callback, context); + }, + + /** + * Fades the Camera out to the given color over the duration specified. + * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeOut + * @since 3.3.0 + * + * @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 {function} [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} This Camera instance. + */ + fadeOut: function (duration, red, green, blue, callback, context) + { + return this.fadeEffect.start(true, duration, red, green, blue, true, callback, context); + }, + + /** + * Fades the Camera from the given color to transparent over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fadeFrom + * @since 3.5.0 + * + * @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 {function} [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} This Camera instance. + */ + fadeFrom: function (duration, red, green, blue, force, callback, context) + { + return this.fadeEffect.start(false, duration, red, green, blue, force, callback, context); + }, + + /** + * Fades the Camera from transparent to the given color over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#fade + * @since 3.0.0 + * + * @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 {function} [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} This Camera instance. + */ + fade: function (duration, red, green, blue, force, callback, context) + { + return this.fadeEffect.start(true, duration, red, green, blue, force, callback, context); + }, + + /** + * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#flash + * @since 3.0.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 {function} [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} This Camera instance. + */ + flash: function (duration, red, green, blue, force, callback, context) + { + return this.flashEffect.start(duration, red, green, blue, force, callback, context); + }, + + /** + * Shakes the Camera by the given intensity over the duration specified. + * + * @method Phaser.Cameras.Scene2D.Camera#shake + * @since 3.0.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 {function} [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} This Camera instance. + */ + shake: function (duration, intensity, force, callback, context) + { + return this.shakeEffect.start(duration, intensity, force, callback, context); + }, + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Camera#pan + * @since 3.11.0 + * + * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. + * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @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} This Camera instance. + */ + pan: function (x, y, duration, ease, force, callback, context) + { + return this.panEffect.start(x, y, duration, ease, force, callback, context); + }, + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Camera#zoomTo + * @since 3.11.0 + * + * @param {number} zoom - The target Camera zoom value. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @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} This Camera instance. + */ + zoomTo: function (zoom, duration, ease, force, callback, context) + { + return this.zoomEffect.start(zoom, duration, ease, force, callback, context); + }, + + /** + * Internal preRender step. + * + * @method Phaser.Cameras.Scene2D.Camera#preRender + * @protected + * @since 3.0.0 + * + * @param {number} baseScale - The base scale, as set in the Camera Manager. + * @param {number} resolution - The game resolution. + */ + preRender: function (baseScale, resolution) + { + var width = this.width; + var height = this.height; + + var halfWidth = width * 0.5; + var halfHeight = height * 0.5; + + var zoom = this.zoom * baseScale; + var matrix = this.matrix; + + var originX = width * this.originX; + var originY = height * this.originY; + + var follow = this._follow; + var deadzone = this.deadzone; + + var sx = this.scrollX; + var sy = this.scrollY; + + if (deadzone) + { + CenterOn(deadzone, this.midPoint.x, this.midPoint.y); + } + + if (follow) + { + var fx = (follow.x - this.followOffset.x); + var fy = (follow.y - this.followOffset.y); + + if (deadzone) + { + if (fx < deadzone.x) + { + sx = Linear(sx, sx - (deadzone.x - fx), this.lerp.x); + } + else if (fx > deadzone.right) + { + sx = Linear(sx, sx + (fx - deadzone.right), this.lerp.x); + } + + if (fy < deadzone.y) + { + sy = Linear(sy, sy - (deadzone.y - fy), this.lerp.y); + } + else if (fy > deadzone.bottom) + { + sy = Linear(sy, sy + (fy - deadzone.bottom), this.lerp.y); + } + } + else + { + sx = Linear(sx, fx - originX, this.lerp.x); + sy = Linear(sy, fy - originY, this.lerp.y); + } + } + + if (this.useBounds) + { + sx = this.clampX(sx); + sy = this.clampY(sy); + } + + if (this.roundPixels) + { + originX = Math.round(originX); + originY = Math.round(originY); + } + + // Values are in pixels and not impacted by zooming the Camera + this.scrollX = sx; + this.scrollY = sy; + + var midX = sx + halfWidth; + var midY = sy + halfHeight; + + // The center of the camera, in world space, so taking zoom into account + // Basically the pixel value of what it's looking at in the middle of the cam + this.midPoint.set(midX, midY); + + var displayWidth = width / zoom; + var displayHeight = height / zoom; + + this.worldView.setTo( + midX - (displayWidth / 2), + midY - (displayHeight / 2), + displayWidth, + displayHeight + ); + + matrix.loadIdentity(); + matrix.scale(resolution, resolution); + matrix.translate(this.x + originX, this.y + originY); + matrix.rotate(this.rotation); + matrix.scale(zoom, zoom); + matrix.translate(-originX, -originY); + + this.shakeEffect.preRender(); + }, + + /** + * Sets the linear interpolation value to use when following a target. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * + * @method Phaser.Cameras.Scene2D.Camera#setLerp + * @since 3.9.0 + * + * @param {number} [x=1] - The amount added to the horizontal linear interpolation of the follow target. + * @param {number} [y=1] - The amount added to the vertical linear interpolation of the follow target. + * + * @return {this} This Camera instance. + */ + setLerp: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.lerp.set(x, y); + + return this; + }, + + /** + * Sets the horizontal and vertical offset of the camera from its follow target. + * The values are subtracted from the targets position during the Cameras update step. + * + * @method Phaser.Cameras.Scene2D.Camera#setFollowOffset + * @since 3.9.0 + * + * @param {number} [x=0] - The horizontal offset from the camera follow target.x position. + * @param {number} [y=0] - The vertical offset from the camera follow target.y position. + * + * @return {this} This Camera instance. + */ + setFollowOffset: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + this.followOffset.set(x, y); + + return this; + }, + + /** + * Sets the Camera to follow a Game Object. + * + * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object + * in its center. + * + * You can set the linear interpolation value used in the follow code. + * Use low lerp values (such as 0.1) to automatically smooth the camera motion. + * + * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel + * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to + * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom + * value on the camera. So be sure to keep the camera zoom to integers. + * + * @method Phaser.Cameras.Scene2D.Camera#startFollow + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. + * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? + * @param {number} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. + * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. + * + * @return {this} This Camera instance. + */ + startFollow: function (target, roundPixels, lerpX, lerpY, offsetX, offsetY) + { + if (roundPixels === undefined) { roundPixels = false; } + if (lerpX === undefined) { lerpX = 1; } + if (lerpY === undefined) { lerpY = lerpX; } + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = offsetX; } + + this._follow = target; + + this.roundPixels = roundPixels; + + lerpX = Clamp(lerpX, 0, 1); + lerpY = Clamp(lerpY, 0, 1); + + this.lerp.set(lerpX, lerpY); + + this.followOffset.set(offsetX, offsetY); + + var originX = this.width / 2; + var originY = this.height / 2; + + var fx = target.x - offsetX; + var fy = target.y - offsetY; + + this.midPoint.set(fx, fy); + + this.scrollX = fx - originX; + this.scrollY = fy - originY; + + return this; + }, + + /** + * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. + * + * @method Phaser.Cameras.Scene2D.Camera#stopFollow + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + stopFollow: function () + { + this._follow = null; + + return this; + }, + + /** + * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to + * remove the fade. + * + * @method Phaser.Cameras.Scene2D.Camera#resetFX + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + resetFX: function () + { + this.panEffect.reset(); + this.shakeEffect.reset(); + this.flashEffect.reset(); + this.fadeEffect.reset(); + + return this; + }, + + /** + * Internal method called automatically by the Camera Manager. + * + * @method Phaser.Cameras.Scene2D.Camera#update + * @protected + * @since 3.0.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.visible) + { + this.panEffect.update(time, delta); + this.zoomEffect.update(time, delta); + this.shakeEffect.update(time, delta); + this.flashEffect.update(time, delta); + this.fadeEffect.update(time, delta); + } + }, + + /** + * Destroys this Camera instance. You rarely need to call this directly. + * + * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as + * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. + * + * @method Phaser.Cameras.Scene2D.Camera#destroy + * @fires CameraDestroyEvent + * @since 3.0.0 + */ + destroy: function () + { + this.clearRenderToTexture(); + + this.resetFX(); + + BaseCamera.prototype.destroy.call(this); + + this._follow = null; + + this.deadzone = null; + } + +}); + +module.exports = Camera; + + +/***/ }), +/* 379 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BaseCache = __webpack_require__(380); var Class = __webpack_require__(0); /** @@ -51382,7 +90978,7 @@ var Class = __webpack_require__(0); * instances, one per type of file. You can also add your own custom caches. * * @class CacheManager - * @memberOf Phaser.Cache + * @memberof Phaser.Cache * @constructor * @since 3.0.0 * @@ -51468,6 +91064,15 @@ var CacheManager = new Class({ */ this.text = new BaseCache(); + /** + * A Cache storing all html files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#html + * @type {Phaser.Cache.BaseCache} + * @since 3.12.0 + */ + this.html = new BaseCache(); + /** * A Cache storing all WaveFront OBJ files, typically added via the Loader. * @@ -51547,6 +91152,7 @@ var CacheManager = new Class({ 'shader', 'audio', 'text', + 'html', 'obj', 'tilemap', 'xml' @@ -51574,7 +91180,7 @@ module.exports = CacheManager; /***/ }), -/* 206 */ +/* 380 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -51584,8 +91190,8 @@ module.exports = CacheManager; */ var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(124); -var EventEmitter = __webpack_require__(9); +var CustomMap = __webpack_require__(180); +var EventEmitter = __webpack_require__(11); /** * @classdesc @@ -51596,7 +91202,7 @@ var EventEmitter = __webpack_require__(9); * Keys are string-based. * * @class BaseCache - * @memberOf Phaser.Cache + * @memberof Phaser.Cache * @constructor * @since 3.0.0 */ @@ -51768,7 +91374,7 @@ module.exports = BaseCache; /***/ }), -/* 207 */ +/* 381 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -51777,12 +91383,12 @@ module.exports = BaseCache; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Animation = __webpack_require__(210); +var Animation = __webpack_require__(384); var Class = __webpack_require__(0); -var CustomMap = __webpack_require__(124); -var EventEmitter = __webpack_require__(9); +var CustomMap = __webpack_require__(180); +var EventEmitter = __webpack_require__(11); var GetValue = __webpack_require__(4); -var Pad = __webpack_require__(133); +var Pad = __webpack_require__(179); /** * @typedef {object} JSONAnimationManager @@ -51803,11 +91409,11 @@ var Pad = __webpack_require__(133); * * @class AnimationManager * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Animations + * @memberof Phaser.Animations * @constructor * @since 3.0.0 * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - A reference to the Phaser.Game instance. */ var AnimationManager = new Class({ @@ -51820,7 +91426,7 @@ var AnimationManager = new Class({ EventEmitter.call(this); /** - * [description] + * A reference to the Phaser.Game instance. * * @name Phaser.Animations.AnimationManager#game * @type {Phaser.Game} @@ -51830,7 +91436,7 @@ var AnimationManager = new Class({ this.game = game; /** - * [description] + * A reference to the Texture Manager. * * @name Phaser.Animations.AnimationManager#textureManager * @type {Phaser.Textures.TextureManager} @@ -51960,7 +91566,7 @@ var AnimationManager = new Class({ * @since 3.0.0 * * @param {(string|JSONAnimationManager|JSONAnimation)} data - [description] - * @param {boolean} [clearCurrentAnimations=false] - [description] + * @param {boolean} [clearCurrentAnimations=false] - If set to `true`, the current animations will be removed (`anims.clear()`). If set to `false` (default), the animations in `data` will be added. * * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. */ @@ -52015,15 +91621,17 @@ var AnimationManager = new Class({ */ /** - * [description] + * Generate an array of {@link AnimationFrameConfig} objects from a texture key and configuration object. + * + * Generates objects with string frame names, as configured by the given {@link AnimationFrameConfig}. * * @method Phaser.Animations.AnimationManager#generateFrameNames * @since 3.0.0 * - * @param {string} key - [description] - * @param {GenerateFrameNamesConfig} [config] - [description] + * @param {string} key - The key for the texture containing the animation frames. + * @param {GenerateFrameNamesConfig} [config] - The configuration object for the animation frame names. * - * @return {AnimationFrameConfig[]} [description] + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects. */ generateFrameNames: function (key, config) { @@ -52092,23 +91700,25 @@ var AnimationManager = new Class({ /** * @typedef {object} GenerateFrameNumbersConfig * - * @property {integer} [start=0] - [description] - * @property {integer} [end=-1] - [description] - * @property {boolean} [first=false] - [description] - * @property {AnimationFrameConfig[]} [outputArray=[]] - [description] - * @property {boolean} [frames=false] - [description] + * @property {integer} [start=0] - The starting frame of the animation. + * @property {integer} [end=-1] - The ending frame of the animation. + * @property {(boolean|integer)} [first=false] - A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. + * @property {AnimationFrameConfig[]} [outputArray=[]] - An array to concatenate the output onto. + * @property {(boolean|integer[])} [frames=false] - A custom sequence of frames. */ /** - * [description] + * Generate an array of {@link AnimationFrameConfig} objects from a texture key and configuration object. + * + * Generates objects with numbered frame names, as configured by the given {@link GenerateFrameNumbersConfig}. * * @method Phaser.Animations.AnimationManager#generateFrameNumbers * @since 3.0.0 * - * @param {string} key - [description] - * @param {GenerateFrameNumbersConfig} config - [description] + * @param {string} key - The key for the texture containing the animation frames. + * @param {GenerateFrameNumbersConfig} config - The configuration object for the animation frames. * - * @return {AnimationFrameConfig[]} [description] + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects. */ generateFrameNumbers: function (key, config) { @@ -52164,14 +91774,14 @@ var AnimationManager = new Class({ }, /** - * [description] + * Get an Animation. * * @method Phaser.Animations.AnimationManager#get * @since 3.0.0 * - * @param {string} key - [description] + * @param {string} key - The key of the Animation to retrieve. * - * @return {Phaser.Animations.Animation} [description] + * @return {Phaser.Animations.Animation} The Animation. */ get: function (key) { @@ -52179,14 +91789,14 @@ var AnimationManager = new Class({ }, /** - * Load an Animation into a Game Objects Animation Component. + * Load an Animation into a Game Object's Animation Component. * * @method Phaser.Animations.AnimationManager#load * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {string} key - [description] - * @param {(string|integer)} [startFrame] - [description] + * @param {Phaser.GameObjects.GameObject} child - The Game Object to load the animation into. + * @param {string} key - The key of the animation to load. + * @param {(string|integer)} [startFrame] - The name of a start frame to set on the loaded animation. * * @return {Phaser.GameObjects.GameObject} [description] */ @@ -52203,7 +91813,7 @@ var AnimationManager = new Class({ }, /** - * [description] + * Pause all animations. * * @method Phaser.Animations.AnimationManager#pauseAll * @fires PauseAllAnimationEvent @@ -52224,13 +91834,13 @@ var AnimationManager = new Class({ }, /** - * [description] + * Play an animation on the given Game Objects that have an Animation Component. * * @method Phaser.Animations.AnimationManager#play * @since 3.0.0 * - * @param {string} key - [description] - * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {string} key - The key of the animation to play on the Game Object. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Objects to play the animation on. * * @return {Phaser.Animations.AnimationManager} This Animation Manager. */ @@ -52257,13 +91867,13 @@ var AnimationManager = new Class({ }, /** - * [description] + * Remove an animation. * * @method Phaser.Animations.AnimationManager#remove * @fires RemoveAnimationEvent * @since 3.0.0 * - * @param {string} key - [description] + * @param {string} key - The key of the animation to remove. * * @return {Phaser.Animations.Animation} [description] */ @@ -52282,7 +91892,7 @@ var AnimationManager = new Class({ }, /** - * [description] + * Resume all paused animations. * * @method Phaser.Animations.AnimationManager#resumeAll * @fires ResumeAllAnimationEvent @@ -52303,17 +91913,17 @@ var AnimationManager = new Class({ }, /** - * Takes an array of Game Objects that have the Animation Component and then + * Takes an array of Game Objects that have an Animation Component and then * starts the given animation playing on them, each one offset by the * `stagger` amount given to this method. * * @method Phaser.Animations.AnimationManager#staggerPlay * @since 3.0.0 - * + * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {string} key - The key of the animation to play on the Game Objects. - * @param {Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have the Animation Component. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have an Animation Component. * @param {number} [stagger=0] - The amount of time, in milliseconds, to offset each play time by. * * @return {Phaser.Animations.AnimationManager} This Animation Manager. @@ -52395,7 +92005,7 @@ module.exports = AnimationManager; /***/ }), -/* 208 */ +/* 382 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -52425,7 +92035,7 @@ var Class = __webpack_require__(0); * AnimationFrames are generated automatically by the Animation class. * * @class AnimationFrame - * @memberOf Phaser.Animations + * @memberof Phaser.Animations * @constructor * @since 3.0.0 * @@ -52482,7 +92092,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#isFirst * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isFirst = false; @@ -52493,7 +92103,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#isLast * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isLast = false; @@ -52504,7 +92114,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#prevFrame * @type {?Phaser.Animations.AnimationFrame} * @default null - * @readOnly + * @readonly * @since 3.0.0 */ this.prevFrame = null; @@ -52515,7 +92125,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#nextFrame * @type {?Phaser.Animations.AnimationFrame} * @default null - * @readOnly + * @readonly * @since 3.0.0 */ this.nextFrame = null; @@ -52538,7 +92148,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#progress * @type {number} * @default 0 - * @readOnly + * @readonly * @since 3.0.0 */ this.progress = 0; @@ -52578,7 +92188,7 @@ module.exports = AnimationFrame; /***/ }), -/* 209 */ +/* 383 */ /***/ (function(module, exports) { /** @@ -52659,7 +92269,7 @@ module.exports = FindClosestInSorted; /***/ }), -/* 210 */ +/* 384 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -52670,8 +92280,8 @@ module.exports = FindClosestInSorted; var Clamp = __webpack_require__(23); var Class = __webpack_require__(0); -var FindClosestInSorted = __webpack_require__(209); -var Frame = __webpack_require__(208); +var FindClosestInSorted = __webpack_require__(383); +var Frame = __webpack_require__(382); var GetValue = __webpack_require__(4); /** @@ -52696,7 +92306,7 @@ var GetValue = __webpack_require__(4); * * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) * @property {(string|number)} frame - [description] - * @property {float} [duration=0] - [description] + * @property {number} [duration=0] - [description] * @property {boolean} [visible] - [description] */ @@ -52728,7 +92338,7 @@ var GetValue = __webpack_require__(4); * So multiple Game Objects can have playheads all pointing to this one Animation instance. * * @class Animation - * @memberOf Phaser.Animations + * @memberof Phaser.Animations * @constructor * @since 3.0.0 * @@ -53193,14 +92803,20 @@ var Animation = new Class({ component.msPerFrame = this.msPerFrame; component.skipMissedFrames = this.skipMissedFrames; - component._timeScale = 1; component._delay = this.delay; component._repeat = this.repeat; component._repeatDelay = this.repeatDelay; component._yoyo = this.yoyo; } - component.updateFrame(this.frames[startFrame]); + var frame = this.frames[startFrame]; + + if (startFrame === 0 && !component.forward) + { + frame = this.getLastFrame(); + } + + component.updateFrame(frame); }, /** @@ -53209,7 +92825,7 @@ var Animation = new Class({ * @method Phaser.Animations.Animation#getFrameByProgress * @since 3.4.0 * - * @param {float} value - A value between 0 and 1. + * @param {number} value - A value between 0 and 1. * * @return {Phaser.Animations.AnimationFrame} The frame closest to the given progress value. */ @@ -53241,17 +92857,20 @@ var Animation = new Class({ // Yoyo? (happens before repeat) if (component._yoyo) { - component.forward = false; - - component.updateFrame(frame.prevFrame); - - // Delay for the current frame - this.getNextTick(component); + this.handleYoyoFrame(component, false); } else if (component.repeatCounter > 0) { // Repeat (happens before complete) - this.repeatAnimation(component); + + if (component._reverse && component.forward) + { + component.forward = false; + } + else + { + this.repeatAnimation(component); + } } else { @@ -53260,12 +92879,60 @@ var Animation = new Class({ } else { - component.updateFrame(frame.nextFrame); - - this.getNextTick(component); + this.updateAndGetNextTick(component, frame.nextFrame); } }, + /** + * Handle the yoyo functionality in nextFrame and previousFrame methods. + * + * @method Phaser.Animations.Animation#handleYoyoFrame + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component to advance. + * @param {boolean} isReverse - Is animation in reverse mode? (Default: false) + */ + handleYoyoFrame: function (component, isReverse) + { + if (!isReverse) { isReverse = false; } + + if (component._reverse === !isReverse && component.repeatCounter > 0) + { + component.forward = isReverse; + + this.repeatAnimation(component); + + return; + } + + if (component._reverse !== isReverse && component.repeatCounter === 0) + { + this.completeAnimation(component); + + return; + } + + component.forward = isReverse; + + var frame = (isReverse) ? component.currentFrame.nextFrame : component.currentFrame.prevFrame; + + this.updateAndGetNextTick(component, frame); + }, + + /** + * Returns the animation last frame. + * + * @method Phaser.Animations.Animation#getLastFrame + * @since 3.12.0 + * + * @return {Phaser.Animations.AnimationFrame} component - The Animation Last Frame. + */ + getLastFrame: function () + { + return this.frames[this.frames.length - 1]; + }, + /** * [description] * @@ -53284,10 +92951,23 @@ var Animation = new Class({ { // We're at the start of the animation - if (component.repeatCounter > 0) + if (component._yoyo) { - // Repeat (happens before complete) - this.repeatAnimation(component); + this.handleYoyoFrame(component, true); + } + else if (component.repeatCounter > 0) + { + if (component._reverse && !component.forward) + { + component.currentFrame = this.getLastFrame(); + this.repeatAnimation(component); + } + else + { + // Repeat (happens before complete) + component.forward = true; + this.repeatAnimation(component); + } } else { @@ -53296,12 +92976,26 @@ var Animation = new Class({ } else { - component.updateFrame(frame.prevFrame); - - this.getNextTick(component); + this.updateAndGetNextTick(component, frame.prevFrame); } }, + /** + * Update Frame and Wait next tick. + * + * @method Phaser.Animations.Animation#updateAndGetNextTick + * @private + * @since 3.12.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - An Animation frame. + */ + updateAndGetNextTick: function (component, frame) + { + component.updateFrame(frame); + + this.getNextTick(component); + }, + /** * [description] * @@ -53369,9 +93063,7 @@ var Animation = new Class({ { component.repeatCounter--; - component.forward = true; - - component.updateFrame(component.currentFrame.nextFrame); + component.updateFrame(component.currentFrame[(component.forward) ? 'nextFrame' : 'prevFrame']); if (component.isPlaying) { @@ -53379,7 +93071,7 @@ var Animation = new Class({ component.pendingRepeat = false; - component.parent.emit('animationrepeat', this, component.currentFrame, component.repeatCounter); + component.parent.emit('animationrepeat', this, component.currentFrame, component.repeatCounter, component.parent); } } }, @@ -53542,7 +93234,161 @@ module.exports = Animation; /***/ }), -/* 211 */ +/* 385 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Using Bresenham's line algorithm this will return an array of all coordinates on this line. + * + * The `start` and `end` points are rounded before this runs as the algorithm works on integers. + * + * @function Phaser.Geom.Line.BresenhamPoints + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line. + * @param {integer} [stepRate=1] - The optional step rate for the points on the line. + * @param {array} [results] - An optional array to push the resulting coordinates into. + * + * @return {object[]} The array of coordinates on the line. + */ +var BresenhamPoints = function (line, stepRate, results) +{ + if (stepRate === undefined) { stepRate = 1; } + if (results === undefined) { results = []; } + + var x1 = Math.round(line.x1); + var y1 = Math.round(line.y1); + var x2 = Math.round(line.x2); + var y2 = Math.round(line.y2); + + var dx = Math.abs(x2 - x1); + var dy = Math.abs(y2 - y1); + var sx = (x1 < x2) ? 1 : -1; + var sy = (y1 < y2) ? 1 : -1; + var err = dx - dy; + + results.push({ x: x1, y: y1 }); + + var i = 1; + + while (!((x1 === x2) && (y1 === y2))) + { + var e2 = err << 1; + + if (e2 > -dy) + { + err -= dy; + x1 += sx; + } + + if (e2 < dx) + { + err += dx; + y1 += sy; + } + + if (i % stepRate === 0) + { + results.push({ x: x1, y: y1 }); + } + + i++; + } + + return results; +}; + +module.exports = BresenhamPoints; + + +/***/ }), +/* 386 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the end of the array to the start, shifting all items in the process. + * The "rotation" happens to the right. + * + * @function Phaser.Utils.Array.RotateRight + * @since 3.0.0 + * + * @param {array} array - The array to shift to the right. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateRight = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.pop(); + array.unshift(element); + } + + return element; +}; + +module.exports = RotateRight; + + +/***/ }), +/* 387 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Moves the element at the start of the array to the end, shifting all items in the process. + * The "rotation" happens to the left. + * + * @function Phaser.Utils.Array.RotateLeft + * @since 3.0.0 + * + * @param {array} array - The array to shift to the left. This array is modified in place. + * @param {integer} [total=1] - The number of times to shift the array. + * + * @return {*} The most recently shifted element. + */ +var RotateLeft = function (array, total) +{ + if (total === undefined) { total = 1; } + + var element = null; + + for (var i = 0; i < total; i++) + { + element = array.shift(); + array.push(element); + } + + return element; +}; + +module.exports = RotateLeft; + + +/***/ }), +/* 388 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -53551,30 +93397,207 @@ module.exports = Animation; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Wrap = __webpack_require__(39); +var Perimeter = __webpack_require__(124); +var Point = __webpack_require__(6); + +// Return an array of points from the perimeter of the rectangle +// each spaced out based on the quantity or step required /** - * Wrap an angle in degrees. + * [description] * - * Wraps the angle to a value in the range of -180 to 180. - * - * @function Phaser.Math.Angle.WrapDegrees + * @function Phaser.Geom.Rectangle.MarchingAnts * @since 3.0.0 * - * @param {number} angle - The angle to wrap, in degrees. + * @generic {Phaser.Geom.Point[]} O - [out,$return] * - * @return {number} The wrapped angle, in degrees. + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} step - [description] + * @param {integer} quantity - [description] + * @param {(array|Phaser.Geom.Point[])} [out] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] */ -var WrapDegrees = function (angle) +var MarchingAnts = function (rect, step, quantity, out) { - return Wrap(angle, -180, 180); + if (out === undefined) { out = []; } + + if (!step && !quantity) + { + // Bail out + return out; + } + + // If step is a falsey value (false, null, 0, undefined, etc) then we calculate + // it based on the quantity instead, otherwise we always use the step value + if (!step) + { + step = Perimeter(rect) / quantity; + } + else + { + quantity = Math.round(Perimeter(rect) / step); + } + + var x = rect.x; + var y = rect.y; + var face = 0; + + // Loop across each face of the rectangle + + for (var i = 0; i < quantity; i++) + { + out.push(new Point(x, y)); + + switch (face) + { + + // Top face + case 0: + x += step; + + if (x >= rect.right) + { + face = 1; + y += (x - rect.right); + x = rect.right; + } + break; + + // Right face + case 1: + y += step; + + if (y >= rect.bottom) + { + face = 2; + x -= (y - rect.bottom); + y = rect.bottom; + } + break; + + // Bottom face + case 2: + x -= step; + + if (x <= rect.left) + { + face = 3; + y -= (rect.left - x); + x = rect.left; + } + break; + + // Left face + case 3: + y -= step; + + if (y <= rect.top) + { + face = 0; + y = rect.top; + } + break; + } + } + + return out; }; -module.exports = WrapDegrees; +module.exports = MarchingAnts; /***/ }), -/* 212 */ +/* 389 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 1; // 0001 + +/** + * Provides methods used for setting the visibility of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Visible + * @since 3.0.0 + */ + +var Visible = { + + /** + * Private internal value. Holds the visible value. + * + * @name Phaser.GameObjects.Components.Visible#_visible + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + _visible: true, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Components.Visible#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + if (value) + { + this._visible = true; + this.renderFlags |= _FLAG; + } + else + { + this._visible = false; + this.renderFlags &= ~_FLAG; + } + } + + }, + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @method Phaser.GameObjects.Components.Visible#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {this} This Game Object instance. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + } +}; + +module.exports = Visible; + + +/***/ }), +/* 390 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -53583,30 +93606,660 @@ module.exports = WrapDegrees; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathWrap = __webpack_require__(39); +var MATH_CONST = __webpack_require__(16); +var TransformMatrix = __webpack_require__(38); +var WrapAngle = __webpack_require__(199); +var WrapAngleDegrees = __webpack_require__(198); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 /** - * Wrap an angle. + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. * - * Wraps the angle to a value in the range of -PI to PI. - * - * @function Phaser.Math.Angle.Wrap + * @name Phaser.GameObjects.Components.Transform * @since 3.0.0 - * - * @param {number} angle - The angle to wrap, in radians. - * - * @return {number} The wrapped angle, in radians. */ -var Wrap = function (angle) -{ - return MathWrap(angle, -Math.PI, Math.PI); + +var Transform = { + + /** + * Private internal value. Holds the horizontal scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleX + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleX: 1, + + /** + * Private internal value. Holds the vertical scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleY + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleY: 1, + + /** + * Private internal value. Holds the rotation value in radians. + * + * @name Phaser.GameObjects.Components.Transform#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + _rotation: 0, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + x: 0, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + y: 0, + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + * + * @name Phaser.GameObjects.Components.Transform#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + z: 0, + + /** + * The w position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + w: 0, + + /** + * The horizontal scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + this._scaleX = value; + + if (this._scaleX === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The vertical scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + this._scaleY = value; + + if (this._scaleY === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + * + * @name Phaser.GameObjects.Components.Transform#angle + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + * + * @name Phaser.GameObjects.Components.Transform#rotation + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + } + }, + + /** + * Sets the position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of this Game Object. + * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value. + * @param {number} [z=0] - The z position of this Game Object. + * @param {number} [w=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setPosition: function (x, y, z, w) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + if (z === undefined) { z = 0; } + if (w === undefined) { w = 0; } + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + }, + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * + * @method Phaser.GameObjects.Components.Transform#setRandomPosition + * @since 3.8.0 + * + * @param {number} [x=0] - The x position of the top-left of the random area. + * @param {number} [y=0] - The y position of the top-left of the random area. + * @param {number} [width] - The width of the random area. + * @param {number} [height] - The height of the random area. + * + * @return {this} This Game Object instance. + */ + setRandomPosition: function (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + + this.x = x + (Math.random() * width); + this.y = y + (Math.random() * height); + + return this; + }, + + /** + * Sets the rotation of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - The rotation of this Game Object, in radians. + * + * @return {this} This Game Object instance. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this.rotation = radians; + + return this; + }, + + /** + * Sets the angle of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. + * + * @return {this} This Game Object instance. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + return this; + }, + + /** + * Sets the scale of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScale: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scaleX = x; + this.scaleY = y; + + return this; + }, + + /** + * Sets the x position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setX + * @since 3.0.0 + * + * @param {number} [value=0] - The x position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setX: function (value) + { + if (value === undefined) { value = 0; } + + this.x = value; + + return this; + }, + + /** + * Sets the y position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setY + * @since 3.0.0 + * + * @param {number} [value=0] - The y position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setY: function (value) + { + if (value === undefined) { value = 0; } + + this.y = value; + + return this; + }, + + /** + * Sets the z position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setZ + * @since 3.0.0 + * + * @param {number} [value=0] - The z position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setZ: function (value) + { + if (value === undefined) { value = 0; } + + this.z = value; + + return this; + }, + + /** + * Sets the w position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setW + * @since 3.0.0 + * + * @param {number} [value=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setW: function (value) + { + if (value === undefined) { value = 0; } + + this.w = value; + + return this; + }, + + /** + * Gets the local transform matrix for this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getLocalTransformMatrix: function (tempMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + + return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + }, + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * + * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A temporary matrix to hold parent values during the calculations. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getWorldTransformMatrix: function (tempMatrix, parentMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + if (parentMatrix === undefined) { parentMatrix = new TransformMatrix(); } + + var parent = this.parentContainer; + + if (!parent) + { + return this.getLocalTransformMatrix(tempMatrix); + } + + tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + + while (parent) + { + parentMatrix.applyITRS(parent.x, parent.y, parent._rotation, parent._scaleX, parent._scaleY); + + parentMatrix.multiply(tempMatrix, tempMatrix); + + parent = parent.parentContainer; + } + + return tempMatrix; + } + }; -module.exports = Wrap; +module.exports = Transform; /***/ }), -/* 213 */ +/* 391 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} JSONGameObject + * + * @property {string} name - The name of this Game Object. + * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. + * @property {number} x - The x position of this Game Object. + * @property {number} y - The y position of this Game Object. + * @property {object} scale - The scale of this Game Object + * @property {number} scale.x - The horizontal scale of this Game Object. + * @property {number} scale.y - The vertical scale of this Game Object. + * @property {object} origin - The origin of this Game Object. + * @property {number} origin.x - The horizontal origin of this Game Object. + * @property {number} origin.y - The vertical origin of this Game Object. + * @property {boolean} flipX - The horizontally flipped state of the Game Object. + * @property {boolean} flipY - The vertically flipped state of the Game Object. + * @property {number} rotation - The angle of this Game Object in radians. + * @property {number} alpha - The alpha value of the Game Object. + * @property {boolean} visible - The visible state of the Game Object. + * @property {integer} scaleMode - The Scale Mode being used by this Game Object. + * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. + * @property {string} textureKey - The texture key of this Game Object. + * @property {string} frameKey - The frame key of this Game Object. + * @property {object} data - The data of this Game Object. + */ + +/** + * Build a JSON representation of the given Game Object. + * + * This is typically extended further by Game Object specific implementations. + * + * @method Phaser.GameObjects.Components.ToJSON + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON. + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ +var ToJSON = function (gameObject) +{ + var out = { + name: gameObject.name, + type: gameObject.type, + x: gameObject.x, + y: gameObject.y, + depth: gameObject.depth, + scale: { + x: gameObject.scaleX, + y: gameObject.scaleY + }, + origin: { + x: gameObject.originX, + y: gameObject.originY + }, + flipX: gameObject.flipX, + flipY: gameObject.flipY, + rotation: gameObject.rotation, + alpha: gameObject.alpha, + visible: gameObject.visible, + scaleMode: gameObject.scaleMode, + blendMode: gameObject.blendMode, + textureKey: '', + frameKey: '', + data: {} + }; + + if (gameObject.texture) + { + out.textureKey = gameObject.texture.key; + out.frameKey = gameObject.frame.name; + } + + return out; +}; + +module.exports = ToJSON; + + +/***/ }), +/* 392 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the Scroll Factor of a Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor + * @since 3.0.0 + */ + +var ScrollFactor = { + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorX: 1, + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorY: 1, + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of this Game Object. + * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScrollFactor: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + } + +}; + +module.exports = ScrollFactor; + + +/***/ }), +/* 393 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -53619,15 +94272,19 @@ var Class = __webpack_require__(0); /** * @classdesc - * [description] + * A Geometry Mask can be applied to a Game Object to hide any pixels of it which don't intersect a visible pixel from the geometry mask. The mask is essentially a clipping path which can only make a masked pixel fully visible or fully invisible without changing its alpha (opacity). + * + * A Geometry Mask uses a Graphics Game Object to determine which pixels of the masked Game Object(s) should be clipped. For any given point of a masked Game Object's texture, the pixel will only be displayed if the Graphics Game Object of the Geometry Mask has a visible pixel at the same position. The color and alpha of the pixel from the Geometry Mask do not matter. + * + * The Geometry Mask's location matches the location of its Graphics object, not the location of the masked objects. Moving or transforming the underlying Graphics object will change the mask (and affect the visibility of any masked objects), whereas moving or transforming a masked object will not affect the mask. You can think of the Geometry Mask (or rather, of the its Graphics object) as an invisible curtain placed in front of all masked objects which has its own visual properties and, naturally, respects the camera's visual properties, but isn't affected by and doesn't follow the masked objects by itself. * * @class GeometryMask - * @memberOf Phaser.Display.Masks + * @memberof Phaser.Display.Masks * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + * @param {Phaser.Scene} scene - This parameter is not used. + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics Game Object to use for the Geometry Mask. Doesn't have to be in the Display List. */ var GeometryMask = new Class({ @@ -53636,7 +94293,7 @@ var GeometryMask = new Class({ function GeometryMask (scene, graphicsGeometry) { /** - * [description] + * The Graphics object which describes the Geometry Mask. * * @name Phaser.Display.Masks.GeometryMask#geometryMask * @type {Phaser.GameObjects.Graphics} @@ -53646,12 +94303,12 @@ var GeometryMask = new Class({ }, /** - * [description] + * Sets a new Graphics object for the Geometry Mask. * * @method Phaser.Display.Masks.GeometryMask#setShape * @since 3.0.0 * - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics object which will be used for the Geometry Mask. */ setShape: function (graphicsGeometry) { @@ -53659,14 +94316,14 @@ var GeometryMask = new Class({ }, /** - * [description] + * Renders the Geometry Mask's underlying Graphics object to the OpenGL stencil buffer and enables the stencil test, which clips rendered pixels according to the mask. * * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to draw to. + * @param {Phaser.GameObjects.GameObject} mask - The Game Object being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the Game Object is being rendered through. */ preRenderWebGL: function (renderer, mask, camera) { @@ -53690,16 +94347,16 @@ var GeometryMask = new Class({ // Use stencil buffer to affect next rendering object gl.colorMask(true, true, true, true); gl.stencilFunc(gl.EQUAL, 1, 1); - gl.stencilOp(gl.INVERT, gl.INVERT, gl.INVERT); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); }, /** - * [description] + * Flushes all rendered pixels and disables the stencil test of a WebGL context, thus disabling the mask for it. * * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to draw flush. */ postRenderWebGL: function (renderer) { @@ -53707,18 +94364,19 @@ var GeometryMask = new Class({ // Force flush before disabling stencil test renderer.flush(); + gl.disable(gl.STENCIL_TEST); }, /** - * [description] + * Sets the clipping path of a 2D canvas context to the Geometry Mask's underlying Graphics object. * * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance to set the clipping path on. + * @param {Phaser.GameObjects.GameObject} mask - The Game Object being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the Game Object is being rendered through. */ preRenderCanvas: function (renderer, mask, camera) { @@ -53726,18 +94384,18 @@ var GeometryMask = new Class({ renderer.currentContext.save(); - geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, undefined, null, true); + geometryMask.renderCanvas(renderer, geometryMask, 0, camera, null, null, true); renderer.currentContext.clip(); }, /** - * [description] + * Restore the canvas context's previous clipping path, thus turning off the mask for it. * * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance being restored. */ postRenderCanvas: function (renderer) { @@ -53764,7 +94422,7 @@ module.exports = GeometryMask; /***/ }), -/* 214 */ +/* 394 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -53780,7 +94438,7 @@ var Class = __webpack_require__(0); * [description] * * @class BitmapMask - * @memberOf Phaser.Display.Masks + * @memberof Phaser.Display.Masks * @constructor * @since 3.0.0 * @@ -53795,6 +94453,15 @@ var BitmapMask = new Class({ { var renderer = scene.sys.game.renderer; + /** + * A reference to either the Canvas or WebGL Renderer that this Mask is using. + * + * @name Phaser.Display.Masks.BitmapMask#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.11.0 + */ + this.renderer = renderer; + /** * A renderable Game Object that uses a texture, such as a Sprite. * @@ -53974,10 +94641,22 @@ var BitmapMask = new Class({ destroy: function () { this.bitmapMask = null; + + var renderer = this.renderer; + + if (renderer && renderer.gl) + { + renderer.deleteTexture(this.mainTexture); + renderer.deleteTexture(this.maskTexture); + renderer.deleteFramebuffer(this.mainFramebuffer); + renderer.deleteFramebuffer(this.maskFramebuffer); + } + this.mainTexture = null; this.maskTexture = null; this.mainFramebuffer = null; this.maskFramebuffer = null; + this.renderer = null; } }); @@ -53986,33 +94665,7 @@ module.exports = BitmapMask; /***/ }), -/* 215 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1, eval)("this"); -} catch (e) { - // This works if the window reference is available - if (typeof window === "object") g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - -/***/ }), -/* 216 */ +/* 395 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -54021,16410 +94674,145 @@ module.exports = g; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Formats = __webpack_require__(26); -var MapData = __webpack_require__(103); -var Parse = __webpack_require__(319); -var Tilemap = __webpack_require__(311); +var BitmapMask = __webpack_require__(394); +var GeometryMask = __webpack_require__(393); /** - * Create a Tilemap from the given key or data. If neither is given, make a blank Tilemap. When - * loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing from - * a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map data. For - * an empty map, you should specify tileWidth, tileHeight, width & height. + * Provides methods used for getting and setting the mask of a Game Object. * - * @function Phaser.Tilemaps.ParseToTilemap - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. - * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param {integer} [tileWidth=32] - The width of a tile in pixels. - * @param {integer} [tileHeight=32] - The height of a tile in pixels. - * @param {integer} [width=10] - The width of the map in tiles. - * @param {integer} [height=10] - The height of the map in tiles. - * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. - * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -var ParseToTilemap = function (scene, key, tileWidth, tileHeight, width, height, data, insertNull) -{ - if (tileWidth === undefined) { tileWidth = 32; } - if (tileHeight === undefined) { tileHeight = 32; } - if (width === undefined) { width = 10; } - if (height === undefined) { height = 10; } - if (insertNull === undefined) { insertNull = false; } - - var mapData = null; - - if (Array.isArray(data)) - { - var name = key !== undefined ? key : 'map'; - mapData = Parse(name, Formats.ARRAY_2D, data, tileWidth, tileHeight, insertNull); - } - else if (key !== undefined) - { - var tilemapData = scene.cache.tilemap.get(key); - - if (!tilemapData) - { - console.warn('No map data found for key ' + key); - } - else - { - mapData = Parse(key, tilemapData.format, tilemapData.data, tileWidth, tileHeight, insertNull); - } - } - - if (mapData === null) - { - mapData = new MapData({ - tileWidth: tileWidth, - tileHeight: tileHeight, - width: width, - height: height - }); - } - - return new Tilemap(scene, mapData); -}; - -module.exports = ParseToTilemap; - - -/***/ }), -/* 217 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var LayerData = __webpack_require__(104); -var MapData = __webpack_require__(103); -var Tile = __webpack_require__(66); - -/** - * Parses a 2D array of tile indexes into a new MapData object with a single layer. - * - * @function Phaser.Tilemaps.Parsers.Parse2DArray - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {integer[][]} data - 2D array, CSV string or Tiled JSON object. - * @param {integer} tileWidth - The width of a tile in pixels. - * @param {integer} tileHeight - The height of a tile in pixels. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.MapData} [description] - */ -var Parse2DArray = function (name, data, tileWidth, tileHeight, insertNull) -{ - var layerData = new LayerData({ - tileWidth: tileWidth, - tileHeight: tileHeight - }); - - var mapData = new MapData({ - name: name, - tileWidth: tileWidth, - tileHeight: tileHeight, - format: Formats.ARRAY_2D, - layers: [ layerData ] - }); - - var tiles = []; - var height = data.length; - var width = 0; - - for (var y = 0; y < data.length; y++) - { - tiles[y] = []; - var row = data[y]; - - for (var x = 0; x < row.length; x++) - { - var tileIndex = parseInt(row[x], 10); - - if (isNaN(tileIndex) || tileIndex === -1) - { - tiles[y][x] = insertNull - ? null - : new Tile(layerData, -1, x, y, tileWidth, tileHeight); - } - else - { - tiles[y][x] = new Tile(layerData, tileIndex, x, y, tileWidth, tileHeight); - } - } - - if (width === 0) - { - width = row.length; - } - } - - mapData.width = layerData.width = width; - mapData.height = layerData.height = height; - mapData.widthInPixels = layerData.widthInPixels = width * tileWidth; - mapData.heightInPixels = layerData.heightInPixels = height * tileHeight; - layerData.data = tiles; - - return mapData; -}; - -module.exports = Parse2DArray; - - -/***/ }), -/* 218 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internally used method to keep track of the tile indexes that collide within a layer. This - * updates LayerData.collideIndexes to either contain or not contain the given `tileIndex`. - * - * @function Phaser.Tilemaps.Components.SetLayerCollisionIndex - * @private - * @since 3.0.0 - * - * @param {integer} tileIndex - [description] - * @param {boolean} [collides=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetLayerCollisionIndex = function (tileIndex, collides, layer) -{ - var loc = layer.collideIndexes.indexOf(tileIndex); - - if (collides && loc === -1) - { - layer.collideIndexes.push(tileIndex); - } - else if (!collides && loc !== -1) - { - layer.collideIndexes.splice(loc, 1); - } -}; - -module.exports = SetLayerCollisionIndex; - - -/***/ }), -/* 219 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tile = __webpack_require__(66); -var IsInLayerBounds = __webpack_require__(105); -var CalculateFacesAt = __webpack_require__(220); -var SetTileCollision = __webpack_require__(67); - -/** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * @function Phaser.Tilemaps.Components.PutTileAt - * @private - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. - */ -var PutTileAt = function (tile, tileX, tileY, recalculateFaces, layer) -{ - if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var oldTile = layer.data[tileY][tileX]; - var oldTileCollides = oldTile && oldTile.collides; - - if (tile instanceof Tile) - { - if (layer.data[tileY][tileX] === null) - { - layer.data[tileY][tileX] = new Tile(layer, tile.index, tileX, tileY, tile.width, tile.height); - } - layer.data[tileY][tileX].copy(tile); - } - else - { - var index = tile; - if (layer.data[tileY][tileX] === null) - { - layer.data[tileY][tileX] = new Tile(layer, index, tileX, tileY, layer.tileWidth, layer.tileHeight); - } - else - { - layer.data[tileY][tileX].index = index; - } - } - - // Updating colliding flag on the new tile - var newTile = layer.data[tileY][tileX]; - var collides = layer.collideIndexes.indexOf(newTile.index) !== -1; - SetTileCollision(newTile, collides); - - // Recalculate faces only if the colliding flag at (tileX, tileY) has changed - if (recalculateFaces && (oldTileCollides !== newTile.collides)) - { - CalculateFacesAt(tileX, tileY, layer); - } - - return newTile; -}; - -module.exports = PutTileAt; - - - -/***/ }), -/* 220 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTileAt = __webpack_require__(140); - -/** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @function Phaser.Tilemaps.Components.CalculateFacesAt - * @private - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var CalculateFacesAt = function (tileX, tileY, layer) -{ - var tile = GetTileAt(tileX, tileY, true, layer); - var above = GetTileAt(tileX, tileY - 1, true, layer); - var below = GetTileAt(tileX, tileY + 1, true, layer); - var left = GetTileAt(tileX - 1, tileY, true, layer); - var right = GetTileAt(tileX + 1, tileY, true, layer); - var tileCollides = tile && tile.collides; - - // Assume the changed tile has all interesting edges - if (tileCollides) - { - tile.faceTop = true; - tile.faceBottom = true; - tile.faceLeft = true; - tile.faceRight = true; - } - - // Reset edges that are shared between tile and its neighbors - if (above && above.collides) - { - if (tileCollides) { tile.faceTop = false; } - above.faceBottom = !tileCollides; - } - - if (below && below.collides) - { - if (tileCollides) { tile.faceBottom = false; } - below.faceTop = !tileCollides; - } - - if (left && left.collides) - { - if (tileCollides) { tile.faceLeft = false; } - left.faceRight = !tileCollides; - } - - if (right && right.collides) - { - if (tileCollides) { tile.faceRight = false; } - right.faceLeft = !tileCollides; - } - - if (tile && !tile.collides) { tile.resetFaces(); } - - return tile; -}; - -module.exports = CalculateFacesAt; - - -/***/ }), -/* 221 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Composite` module contains methods for creating and manipulating composite bodies. -* A composite body is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`, therefore composites form a tree structure. -* It is important to use the functions in this module to modify composites, rather than directly modifying their properties. -* Note that the `Matter.World` object is also a type of `Matter.Composite` and as such all composite methods here can also operate on a `Matter.World`. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Composite -*/ - -var Composite = {}; - -module.exports = Composite; - -var Events = __webpack_require__(301); -var Common = __webpack_require__(41); -var Body = __webpack_require__(74); - -(function() { - - /** - * Creates a new composite. The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properites section below for detailed information on what you can pass via the `options` object. - * @method create - * @param {} [options] - * @return {composite} A new composite - */ - Composite.create = function(options) { - return Common.extend({ - id: Common.nextId(), - type: 'composite', - parent: null, - isModified: false, - bodies: [], - constraints: [], - composites: [], - label: 'Composite', - plugin: {} - }, options); - }; - - /** - * Sets the composite's `isModified` flag. - * If `updateParents` is true, all parents will be set (default: false). - * If `updateChildren` is true, all children will be set (default: false). - * @method setModified - * @param {composite} composite - * @param {boolean} isModified - * @param {boolean} [updateParents=false] - * @param {boolean} [updateChildren=false] - */ - Composite.setModified = function(composite, isModified, updateParents, updateChildren) { - composite.isModified = isModified; - - if (updateParents && composite.parent) { - Composite.setModified(composite.parent, isModified, updateParents, updateChildren); - } - - if (updateChildren) { - for(var i = 0; i < composite.composites.length; i++) { - var childComposite = composite.composites[i]; - Composite.setModified(childComposite, isModified, updateParents, updateChildren); - } - } - }; - - /** - * Generic add function. Adds one or many body(s), constraint(s) or a composite(s) to the given composite. - * Triggers `beforeAdd` and `afterAdd` events on the `composite`. - * @method add - * @param {composite} composite - * @param {} object - * @return {composite} The original composite with the objects added - */ - Composite.add = function(composite, object) { - var objects = [].concat(object); - - Events.trigger(composite, 'beforeAdd', { object: object }); - - for (var i = 0; i < objects.length; i++) { - var obj = objects[i]; - - switch (obj.type) { - - case 'body': - // skip adding compound parts - if (obj.parent !== obj) { - Common.warn('Composite.add: skipped adding a compound body part (you must add its parent instead)'); - break; - } - - Composite.addBody(composite, obj); - break; - case 'constraint': - Composite.addConstraint(composite, obj); - break; - case 'composite': - Composite.addComposite(composite, obj); - break; - case 'mouseConstraint': - Composite.addConstraint(composite, obj.constraint); - break; - - } - } - - Events.trigger(composite, 'afterAdd', { object: object }); - - return composite; - }; - - /** - * Generic remove function. Removes one or many body(s), constraint(s) or a composite(s) to the given composite. - * Optionally searching its children recursively. - * Triggers `beforeRemove` and `afterRemove` events on the `composite`. - * @method remove - * @param {composite} composite - * @param {} object - * @param {boolean} [deep=false] - * @return {composite} The original composite with the objects removed - */ - Composite.remove = function(composite, object, deep) { - var objects = [].concat(object); - - Events.trigger(composite, 'beforeRemove', { object: object }); - - for (var i = 0; i < objects.length; i++) { - var obj = objects[i]; - - switch (obj.type) { - - case 'body': - Composite.removeBody(composite, obj, deep); - break; - case 'constraint': - Composite.removeConstraint(composite, obj, deep); - break; - case 'composite': - Composite.removeComposite(composite, obj, deep); - break; - case 'mouseConstraint': - Composite.removeConstraint(composite, obj.constraint); - break; - - } - } - - Events.trigger(composite, 'afterRemove', { object: object }); - - return composite; - }; - - /** - * Adds a composite to the given composite. - * @private - * @method addComposite - * @param {composite} compositeA - * @param {composite} compositeB - * @return {composite} The original compositeA with the objects from compositeB added - */ - Composite.addComposite = function(compositeA, compositeB) { - compositeA.composites.push(compositeB); - compositeB.parent = compositeA; - Composite.setModified(compositeA, true, true, false); - return compositeA; - }; - - /** - * Removes a composite from the given composite, and optionally searching its children recursively. - * @private - * @method removeComposite - * @param {composite} compositeA - * @param {composite} compositeB - * @param {boolean} [deep=false] - * @return {composite} The original compositeA with the composite removed - */ - Composite.removeComposite = function(compositeA, compositeB, deep) { - var position = compositeA.composites.indexOf(compositeB); - if (position !== -1) { - Composite.removeCompositeAt(compositeA, position); - Composite.setModified(compositeA, true, true, false); - } - - if (deep) { - for (var i = 0; i < compositeA.composites.length; i++){ - Composite.removeComposite(compositeA.composites[i], compositeB, true); - } - } - - return compositeA; - }; - - /** - * Removes a composite from the given composite. - * @private - * @method removeCompositeAt - * @param {composite} composite - * @param {number} position - * @return {composite} The original composite with the composite removed - */ - Composite.removeCompositeAt = function(composite, position) { - composite.composites.splice(position, 1); - Composite.setModified(composite, true, true, false); - return composite; - }; - - /** - * Adds a body to the given composite. - * @private - * @method addBody - * @param {composite} composite - * @param {body} body - * @return {composite} The original composite with the body added - */ - Composite.addBody = function(composite, body) { - composite.bodies.push(body); - Composite.setModified(composite, true, true, false); - return composite; - }; - - /** - * Removes a body from the given composite, and optionally searching its children recursively. - * @private - * @method removeBody - * @param {composite} composite - * @param {body} body - * @param {boolean} [deep=false] - * @return {composite} The original composite with the body removed - */ - Composite.removeBody = function(composite, body, deep) { - var position = composite.bodies.indexOf(body); - if (position !== -1) { - Composite.removeBodyAt(composite, position); - Composite.setModified(composite, true, true, false); - } - - if (deep) { - for (var i = 0; i < composite.composites.length; i++){ - Composite.removeBody(composite.composites[i], body, true); - } - } - - return composite; - }; - - /** - * Removes a body from the given composite. - * @private - * @method removeBodyAt - * @param {composite} composite - * @param {number} position - * @return {composite} The original composite with the body removed - */ - Composite.removeBodyAt = function(composite, position) { - composite.bodies.splice(position, 1); - Composite.setModified(composite, true, true, false); - return composite; - }; - - /** - * Adds a constraint to the given composite. - * @private - * @method addConstraint - * @param {composite} composite - * @param {constraint} constraint - * @return {composite} The original composite with the constraint added - */ - Composite.addConstraint = function(composite, constraint) { - composite.constraints.push(constraint); - Composite.setModified(composite, true, true, false); - return composite; - }; - - /** - * Removes a constraint from the given composite, and optionally searching its children recursively. - * @private - * @method removeConstraint - * @param {composite} composite - * @param {constraint} constraint - * @param {boolean} [deep=false] - * @return {composite} The original composite with the constraint removed - */ - Composite.removeConstraint = function(composite, constraint, deep) { - var position = composite.constraints.indexOf(constraint); - if (position !== -1) { - Composite.removeConstraintAt(composite, position); - } - - if (deep) { - for (var i = 0; i < composite.composites.length; i++){ - Composite.removeConstraint(composite.composites[i], constraint, true); - } - } - - return composite; - }; - - /** - * Removes a body from the given composite. - * @private - * @method removeConstraintAt - * @param {composite} composite - * @param {number} position - * @return {composite} The original composite with the constraint removed - */ - Composite.removeConstraintAt = function(composite, position) { - composite.constraints.splice(position, 1); - Composite.setModified(composite, true, true, false); - return composite; - }; - - /** - * Removes all bodies, constraints and composites from the given composite. - * Optionally clearing its children recursively. - * @method clear - * @param {composite} composite - * @param {boolean} keepStatic - * @param {boolean} [deep=false] - */ - Composite.clear = function(composite, keepStatic, deep) { - if (deep) { - for (var i = 0; i < composite.composites.length; i++){ - Composite.clear(composite.composites[i], keepStatic, true); - } - } - - if (keepStatic) { - composite.bodies = composite.bodies.filter(function(body) { return body.isStatic; }); - } else { - composite.bodies.length = 0; - } - - composite.constraints.length = 0; - composite.composites.length = 0; - Composite.setModified(composite, true, true, false); - - return composite; - }; - - /** - * Returns all bodies in the given composite, including all bodies in its children, recursively. - * @method allBodies - * @param {composite} composite - * @return {body[]} All the bodies - */ - Composite.allBodies = function(composite) { - var bodies = [].concat(composite.bodies); - - for (var i = 0; i < composite.composites.length; i++) - bodies = bodies.concat(Composite.allBodies(composite.composites[i])); - - return bodies; - }; - - /** - * Returns all constraints in the given composite, including all constraints in its children, recursively. - * @method allConstraints - * @param {composite} composite - * @return {constraint[]} All the constraints - */ - Composite.allConstraints = function(composite) { - var constraints = [].concat(composite.constraints); - - for (var i = 0; i < composite.composites.length; i++) - constraints = constraints.concat(Composite.allConstraints(composite.composites[i])); - - return constraints; - }; - - /** - * Returns all composites in the given composite, including all composites in its children, recursively. - * @method allComposites - * @param {composite} composite - * @return {composite[]} All the composites - */ - Composite.allComposites = function(composite) { - var composites = [].concat(composite.composites); - - for (var i = 0; i < composite.composites.length; i++) - composites = composites.concat(Composite.allComposites(composite.composites[i])); - - return composites; - }; - - /** - * Searches the composite recursively for an object matching the type and id supplied, null if not found. - * @method get - * @param {composite} composite - * @param {number} id - * @param {string} type - * @return {object} The requested object, if found - */ - Composite.get = function(composite, id, type) { - var objects, - object; - - switch (type) { - case 'body': - objects = Composite.allBodies(composite); - break; - case 'constraint': - objects = Composite.allConstraints(composite); - break; - case 'composite': - objects = Composite.allComposites(composite).concat(composite); - break; - } - - if (!objects) - return null; - - object = objects.filter(function(object) { - return object.id.toString() === id.toString(); - }); - - return object.length === 0 ? null : object[0]; - }; - - /** - * Moves the given object(s) from compositeA to compositeB (equal to a remove followed by an add). - * @method move - * @param {compositeA} compositeA - * @param {object[]} objects - * @param {compositeB} compositeB - * @return {composite} Returns compositeA - */ - Composite.move = function(compositeA, objects, compositeB) { - Composite.remove(compositeA, objects); - Composite.add(compositeB, objects); - return compositeA; - }; - - /** - * Assigns new ids for all objects in the composite, recursively. - * @method rebase - * @param {composite} composite - * @return {composite} Returns composite - */ - Composite.rebase = function(composite) { - var objects = Composite.allBodies(composite) - .concat(Composite.allConstraints(composite)) - .concat(Composite.allComposites(composite)); - - for (var i = 0; i < objects.length; i++) { - objects[i].id = Common.nextId(); - } - - Composite.setModified(composite, true, true, false); - - return composite; - }; - - /** - * Translates all children in the composite by a given vector relative to their current positions, - * without imparting any velocity. - * @method translate - * @param {composite} composite - * @param {vector} translation - * @param {bool} [recursive=true] - */ - Composite.translate = function(composite, translation, recursive) { - var bodies = recursive ? Composite.allBodies(composite) : composite.bodies; - - for (var i = 0; i < bodies.length; i++) { - Body.translate(bodies[i], translation); - } - - Composite.setModified(composite, true, true, false); - - return composite; - }; - - /** - * Rotates all children in the composite by a given angle about the given point, without imparting any angular velocity. - * @method rotate - * @param {composite} composite - * @param {number} rotation - * @param {vector} point - * @param {bool} [recursive=true] - */ - Composite.rotate = function(composite, rotation, point, recursive) { - var cos = Math.cos(rotation), - sin = Math.sin(rotation), - bodies = recursive ? Composite.allBodies(composite) : composite.bodies; - - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i], - dx = body.position.x - point.x, - dy = body.position.y - point.y; - - Body.setPosition(body, { - x: point.x + (dx * cos - dy * sin), - y: point.y + (dx * sin + dy * cos) - }); - - Body.rotate(body, rotation); - } - - Composite.setModified(composite, true, true, false); - - return composite; - }; - - /** - * Scales all children in the composite, including updating physical properties (mass, area, axes, inertia), from a world-space point. - * @method scale - * @param {composite} composite - * @param {number} scaleX - * @param {number} scaleY - * @param {vector} point - * @param {bool} [recursive=true] - */ - Composite.scale = function(composite, scaleX, scaleY, point, recursive) { - var bodies = recursive ? Composite.allBodies(composite) : composite.bodies; - - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i], - dx = body.position.x - point.x, - dy = body.position.y - point.y; - - Body.setPosition(body, { - x: point.x + dx * scaleX, - y: point.y + dy * scaleY - }); - - Body.scale(body, scaleX, scaleY); - } - - Composite.setModified(composite, true, true, false); - - return composite; - }; - - /** - * Returns the union of the bounds of all of the composite's bodies. - * @method bounds - * @param {composite} composite The composite. - * @returns {bounds} The composite bounds. - */ - Composite.bounds = function(composite) { - var bodies = Matter.Composite.allBodies(composite), - vertices = []; - - for (var i = 0; i < bodies.length; i += 1) { - var body = bodies[i]; - vertices.push(body.bounds.min, body.bounds.max); - } - - return Matter.Bounds.create(vertices); - }; - - /* - * - * Events Documentation - * - */ - - /** - * Fired when a call to `Composite.add` is made, before objects have been added. - * - * @event beforeAdd - * @param {} event An event object - * @param {} event.object The object(s) to be added (may be a single body, constraint, composite or a mixed array of these) - * @param {} event.source The source object of the event - * @param {} event.name The name of the event - */ - - /** - * Fired when a call to `Composite.add` is made, after objects have been added. - * - * @event afterAdd - * @param {} event An event object - * @param {} event.object The object(s) that have been added (may be a single body, constraint, composite or a mixed array of these) - * @param {} event.source The source object of the event - * @param {} event.name The name of the event - */ - - /** - * Fired when a call to `Composite.remove` is made, before objects have been removed. - * - * @event beforeRemove - * @param {} event An event object - * @param {} event.object The object(s) to be removed (may be a single body, constraint, composite or a mixed array of these) - * @param {} event.source The source object of the event - * @param {} event.name The name of the event - */ - - /** - * Fired when a call to `Composite.remove` is made, after objects have been removed. - * - * @event afterRemove - * @param {} event An event object - * @param {} event.object The object(s) that have been removed (may be a single body, constraint, composite or a mixed array of these) - * @param {} event.source The source object of the event - * @param {} event.name The name of the event - */ - - /* - * - * Properties Documentation - * - */ - - /** - * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. - * - * @property id - * @type number - */ - - /** - * A `String` denoting the type of object. - * - * @property type - * @type string - * @default "composite" - * @readOnly - */ - - /** - * An arbitrary `String` name to help the user identify and manage composites. - * - * @property label - * @type string - * @default "Composite" - */ - - /** - * A flag that specifies whether the composite has been modified during the current step. - * Most `Matter.Composite` methods will automatically set this flag to `true` to inform the engine of changes to be handled. - * If you need to change it manually, you should use the `Composite.setModified` method. - * - * @property isModified - * @type boolean - * @default false - */ - - /** - * The `Composite` that is the parent of this composite. It is automatically managed by the `Matter.Composite` methods. - * - * @property parent - * @type composite - * @default null - */ - - /** - * An array of `Body` that are _direct_ children of this composite. - * To add or remove bodies you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. - * If you wish to recursively find all descendants, you should use the `Composite.allBodies` method. - * - * @property bodies - * @type body[] - * @default [] - */ - - /** - * An array of `Constraint` that are _direct_ children of this composite. - * To add or remove constraints you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. - * If you wish to recursively find all descendants, you should use the `Composite.allConstraints` method. - * - * @property constraints - * @type constraint[] - * @default [] - */ - - /** - * An array of `Composite` that are _direct_ children of this composite. - * To add or remove composites you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property. - * If you wish to recursively find all descendants, you should use the `Composite.allComposites` method. - * - * @property composites - * @type composite[] - * @default [] - */ - - /** - * An object reserved for storing plugin-specific properties. - * - * @property plugin - * @type {} - */ - -})(); - - -/***/ }), -/* 222 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var quickselect = __webpack_require__(180); - -/** - * @classdesc - * RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. - * It's based on an optimized R-tree data structure with bulk insertion support. - * - * Spatial index is a special data structure for points and rectangles that allows you to perform queries like - * "all items within this bounding box" very efficiently (e.g. hundreds of times faster than looping over all items). - * - * This version of RBush uses a fixed min/max accessor structure of `[ '.left', '.top', '.right', '.bottom' ]`. - * This is to avoid the eval like function creation that the original library used, which caused CSP policy violations. - * - * @class RTree - * @memberOf Phaser.Structs - * @constructor + * @name Phaser.GameObjects.Components.Mask * @since 3.0.0 */ -function rbush (maxEntries) -{ - var format = [ '.left', '.top', '.right', '.bottom' ]; - - if (!(this instanceof rbush)) return new rbush(maxEntries, format); - - // max entries in a node is 9 by default; min node fill is 40% for best performance - this._maxEntries = Math.max(4, maxEntries || 9); - this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)); - - this.clear(); -} - -rbush.prototype = { - - all: function () - { - return this._all(this.data, []); - }, - - search: function (bbox) - { - var node = this.data, - result = [], - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return result; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf) result.push(child); - else if (contains(bbox, childBBox)) this._all(child, result); - else nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return result; - }, - - collides: function (bbox) - { - var node = this.data, - toBBox = this.toBBox; - - if (!intersects(bbox, node)) return false; - - var nodesToSearch = [], - i, len, child, childBBox; - - while (node) { - for (i = 0, len = node.children.length; i < len; i++) { - - child = node.children[i]; - childBBox = node.leaf ? toBBox(child) : child; - - if (intersects(bbox, childBBox)) { - if (node.leaf || contains(bbox, childBBox)) return true; - nodesToSearch.push(child); - } - } - node = nodesToSearch.pop(); - } - - return false; - }, - - load: function (data) - { - if (!(data && data.length)) return this; - - if (data.length < this._minEntries) { - for (var i = 0, len = data.length; i < len; i++) { - this.insert(data[i]); - } - return this; - } - - // recursively build the tree with the given data from scratch using OMT algorithm - var node = this._build(data.slice(), 0, data.length - 1, 0); - - if (!this.data.children.length) { - // save as is if tree is empty - this.data = node; - - } else if (this.data.height === node.height) { - // split root if trees have the same height - this._splitRoot(this.data, node); - - } else { - if (this.data.height < node.height) { - // swap trees if inserted one is bigger - var tmpNode = this.data; - this.data = node; - node = tmpNode; - } - - // insert the small tree into the large tree at appropriate level - this._insert(node, this.data.height - node.height - 1, true); - } - - return this; - }, - - insert: function (item) - { - if (item) this._insert(item, this.data.height - 1); - return this; - }, - - clear: function () - { - this.data = createNode([]); - return this; - }, - - remove: function (item, equalsFn) - { - if (!item) return this; - - var node = this.data, - bbox = this.toBBox(item), - path = [], - indexes = [], - i, parent, index, goingUp; - - // depth-first iterative tree traversal - while (node || path.length) { - - if (!node) { // go up - node = path.pop(); - parent = path[path.length - 1]; - i = indexes.pop(); - goingUp = true; - } - - if (node.leaf) { // check current node - index = findItem(item, node.children, equalsFn); - - if (index !== -1) { - // item found, remove the item and condense tree upwards - node.children.splice(index, 1); - path.push(node); - this._condense(path); - return this; - } - } - - if (!goingUp && !node.leaf && contains(node, bbox)) { // go down - path.push(node); - indexes.push(i); - i = 0; - parent = node; - node = node.children[0]; - - } else if (parent) { // go right - i++; - node = parent.children[i]; - goingUp = false; - - } else node = null; // nothing found - } - - return this; - }, - - toBBox: function (item) { return item; }, - - compareMinX: compareNodeMinX, - compareMinY: compareNodeMinY, - - toJSON: function () { return this.data; }, - - fromJSON: function (data) - { - this.data = data; - return this; - }, - - _all: function (node, result) - { - var nodesToSearch = []; - while (node) { - if (node.leaf) result.push.apply(result, node.children); - else nodesToSearch.push.apply(nodesToSearch, node.children); - - node = nodesToSearch.pop(); - } - return result; - }, - - _build: function (items, left, right, height) - { - var N = right - left + 1, - M = this._maxEntries, - node; - - if (N <= M) { - // reached leaf level; return leaf - node = createNode(items.slice(left, right + 1)); - calcBBox(node, this.toBBox); - return node; - } - - if (!height) { - // target height of the bulk-loaded tree - height = Math.ceil(Math.log(N) / Math.log(M)); - - // target number of root entries to maximize storage utilization - M = Math.ceil(N / Math.pow(M, height - 1)); - } - - node = createNode([]); - node.leaf = false; - node.height = height; - - // split the items into M mostly square tiles - - var N2 = Math.ceil(N / M), - N1 = N2 * Math.ceil(Math.sqrt(M)), - i, j, right2, right3; - - multiSelect(items, left, right, N1, this.compareMinX); - - for (i = left; i <= right; i += N1) { - - right2 = Math.min(i + N1 - 1, right); - - multiSelect(items, i, right2, N2, this.compareMinY); - - for (j = i; j <= right2; j += N2) { - - right3 = Math.min(j + N2 - 1, right2); - - // pack each entry recursively - node.children.push(this._build(items, j, right3, height - 1)); - } - } - - calcBBox(node, this.toBBox); - - return node; - }, - - _chooseSubtree: function (bbox, node, level, path) - { - var i, len, child, targetNode, area, enlargement, minArea, minEnlargement; - - while (true) { - path.push(node); - - if (node.leaf || path.length - 1 === level) break; - - minArea = minEnlargement = Infinity; - - for (i = 0, len = node.children.length; i < len; i++) { - child = node.children[i]; - area = bboxArea(child); - enlargement = enlargedArea(bbox, child) - area; - - // choose entry with the least area enlargement - if (enlargement < minEnlargement) { - minEnlargement = enlargement; - minArea = area < minArea ? area : minArea; - targetNode = child; - - } else if (enlargement === minEnlargement) { - // otherwise choose one with the smallest area - if (area < minArea) { - minArea = area; - targetNode = child; - } - } - } - - node = targetNode || node.children[0]; - } - - return node; - }, - - _insert: function (item, level, isNode) - { - var toBBox = this.toBBox, - bbox = isNode ? item : toBBox(item), - insertPath = []; - - // find the best node for accommodating the item, saving all nodes along the path too - var node = this._chooseSubtree(bbox, this.data, level, insertPath); - - // put the item into the node - node.children.push(item); - extend(node, bbox); - - // split on node overflow; propagate upwards if necessary - while (level >= 0) { - if (insertPath[level].children.length > this._maxEntries) { - this._split(insertPath, level); - level--; - } else break; - } - - // adjust bboxes along the insertion path - this._adjustParentBBoxes(bbox, insertPath, level); - }, - - // split overflowed node into two - _split: function (insertPath, level) - { - var node = insertPath[level], - M = node.children.length, - m = this._minEntries; - - this._chooseSplitAxis(node, m, M); - - var splitIndex = this._chooseSplitIndex(node, m, M); - - var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex)); - newNode.height = node.height; - newNode.leaf = node.leaf; - - calcBBox(node, this.toBBox); - calcBBox(newNode, this.toBBox); - - if (level) insertPath[level - 1].children.push(newNode); - else this._splitRoot(node, newNode); - }, - - _splitRoot: function (node, newNode) - { - // split root node - this.data = createNode([node, newNode]); - this.data.height = node.height + 1; - this.data.leaf = false; - calcBBox(this.data, this.toBBox); - }, - - _chooseSplitIndex: function (node, m, M) - { - var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index; - - minOverlap = minArea = Infinity; - - for (i = m; i <= M - m; i++) { - bbox1 = distBBox(node, 0, i, this.toBBox); - bbox2 = distBBox(node, i, M, this.toBBox); - - overlap = intersectionArea(bbox1, bbox2); - area = bboxArea(bbox1) + bboxArea(bbox2); - - // choose distribution with minimum overlap - if (overlap < minOverlap) { - minOverlap = overlap; - index = i; - - minArea = area < minArea ? area : minArea; - - } else if (overlap === minOverlap) { - // otherwise choose distribution with minimum area - if (area < minArea) { - minArea = area; - index = i; - } - } - } - - return index; - }, - - // sorts node children by the best axis for split - _chooseSplitAxis: function (node, m, M) - { - var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, - compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, - xMargin = this._allDistMargin(node, m, M, compareMinX), - yMargin = this._allDistMargin(node, m, M, compareMinY); - - // if total distributions margin value is minimal for x, sort by minX, - // otherwise it's already sorted by minY - if (xMargin < yMargin) node.children.sort(compareMinX); - }, - - // total margin of all possible split distributions where each node is at least m full - _allDistMargin: function (node, m, M, compare) - { - node.children.sort(compare); - - var toBBox = this.toBBox, - leftBBox = distBBox(node, 0, m, toBBox), - rightBBox = distBBox(node, M - m, M, toBBox), - margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), - i, child; - - for (i = m; i < M - m; i++) { - child = node.children[i]; - extend(leftBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(leftBBox); - } - - for (i = M - m - 1; i >= m; i--) { - child = node.children[i]; - extend(rightBBox, node.leaf ? toBBox(child) : child); - margin += bboxMargin(rightBBox); - } - - return margin; - }, - - _adjustParentBBoxes: function (bbox, path, level) - { - // adjust bboxes along the given tree path - for (var i = level; i >= 0; i--) { - extend(path[i], bbox); - } - }, - - _condense: function (path) - { - // go through the path, removing empty nodes and updating bboxes - for (var i = path.length - 1, siblings; i >= 0; i--) { - if (path[i].children.length === 0) { - if (i > 0) { - siblings = path[i - 1].children; - siblings.splice(siblings.indexOf(path[i]), 1); - - } else this.clear(); - - } else calcBBox(path[i], this.toBBox); - } - }, - - compareMinX: function (a, b) - { - return a.left - b.left; - }, - - compareMinY: function (a, b) - { - return a.top - b.top; - }, - - toBBox: function (a) - { - return { - minX: a.left, - minY: a.top, - maxX: a.right, - maxY: a.bottom - }; - } -}; - -function findItem (item, items, equalsFn) -{ - if (!equalsFn) return items.indexOf(item); - - for (var i = 0; i < items.length; i++) { - if (equalsFn(item, items[i])) return i; - } - return -1; -} - -// calculate node's bbox from bboxes of its children -function calcBBox (node, toBBox) -{ - distBBox(node, 0, node.children.length, toBBox, node); -} - -// min bounding rectangle of node children from k to p-1 -function distBBox (node, k, p, toBBox, destNode) -{ - if (!destNode) destNode = createNode(null); - destNode.minX = Infinity; - destNode.minY = Infinity; - destNode.maxX = -Infinity; - destNode.maxY = -Infinity; - - for (var i = k, child; i < p; i++) { - child = node.children[i]; - extend(destNode, node.leaf ? toBBox(child) : child); - } - - return destNode; -} - -function extend (a, b) -{ - a.minX = Math.min(a.minX, b.minX); - a.minY = Math.min(a.minY, b.minY); - a.maxX = Math.max(a.maxX, b.maxX); - a.maxY = Math.max(a.maxY, b.maxY); - return a; -} - -function compareNodeMinX (a, b) { return a.minX - b.minX; } -function compareNodeMinY (a, b) { return a.minY - b.minY; } - -function bboxArea (a) { return (a.maxX - a.minX) * (a.maxY - a.minY); } -function bboxMargin (a) { return (a.maxX - a.minX) + (a.maxY - a.minY); } - -function enlargedArea (a, b) -{ - return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * - (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY)); -} - -function intersectionArea (a, b) -{ - var minX = Math.max(a.minX, b.minX), - minY = Math.max(a.minY, b.minY), - maxX = Math.min(a.maxX, b.maxX), - maxY = Math.min(a.maxY, b.maxY); - - return Math.max(0, maxX - minX) * - Math.max(0, maxY - minY); -} - -function contains (a, b) -{ - return a.minX <= b.minX && - a.minY <= b.minY && - b.maxX <= a.maxX && - b.maxY <= a.maxY; -} - -function intersects (a, b) -{ - return b.minX <= a.maxX && - b.minY <= a.maxY && - b.maxX >= a.minX && - b.maxY >= a.minY; -} - -function createNode (children) -{ - return { - children: children, - height: 1, - leaf: true, - minX: Infinity, - minY: Infinity, - maxX: -Infinity, - maxY: -Infinity - }; -} - -// sort an array so that items come in groups of n unsorted items, with groups sorted between each other; -// combines selection algorithm with binary divide & conquer approach - -function multiSelect (arr, left, right, n, compare) -{ - var stack = [left, right], - mid; - - while (stack.length) - { - right = stack.pop(); - left = stack.pop(); - - if (right - left <= n) continue; - - mid = left + Math.ceil((right - left) / n / 2) * n; - quickselect(arr, mid, left, right, compare); - - stack.push(left, mid, mid, right); - } -} - -module.exports = rbush; - -/***/ }), -/* 223 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class ProcessQueue - * @memberOf Phaser.Structs - * @constructor - * @since 3.0.0 - * - * @generic T - */ -var ProcessQueue = new Class({ - - initialize: - - function ProcessQueue () - { - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.ProcessQueue#_pending - * @type {Array.<*>} - * @private - * @default [] - * @since 3.0.0 - */ - this._pending = []; - - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.ProcessQueue#_active - * @type {Array.<*>} - * @private - * @default [] - * @since 3.0.0 - */ - this._active = []; - - /** - * [description] - * - * @genericUse {T[]} - [$type] - * - * @name Phaser.Structs.ProcessQueue#_destroy - * @type {Array.<*>} - * @private - * @default [] - * @since 3.0.0 - */ - this._destroy = []; - - /** - * [description] - * - * @name Phaser.Structs.ProcessQueue#_toProcess - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._toProcess = 0; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#add - * @since 3.0.0 - * - * @genericUse {T} - [item] - * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] - * - * @param {*} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - add: function (item) - { - this._pending.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#remove - * @since 3.0.0 - * - * @genericUse {T} - [item] - * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] - * - * @param {*} item - [description] - * - * @return {Phaser.Structs.ProcessQueue} This Process Queue object. - */ - remove: function (item) - { - this._destroy.push(item); - - this._toProcess++; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#update - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @return {Array.<*>} [description] - */ - update: function () - { - if (this._toProcess === 0) - { - // Quick bail - return this._active; - } - - var list = this._destroy; - var active = this._active; - var i; - var item; - - // Clear the 'destroy' list - for (i = 0; i < list.length; i++) - { - item = list[i]; - - // Remove from the 'active' array - var idx = active.indexOf(item); - - if (idx !== -1) - { - active.splice(idx, 1); - } - } - - list.length = 0; - - // Process the pending addition list - // This stops callbacks and out of sync events from populating the active array mid-way during an update - - list = this._pending; - - for (i = 0; i < list.length; i++) - { - item = list[i]; - - this._active.push(item); - } - - list.length = 0; - - this._toProcess = 0; - - // The owner of this queue can now safely do whatever it needs to with the active list - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#getActive - * @since 3.0.0 - * - * @genericUse {T[]} - [$return] - * - * @return {Array.<*>} [description] - */ - getActive: function () - { - return this._active; - }, - - /** - * [description] - * - * @method Phaser.Structs.ProcessQueue#destroy - * @since 3.0.0 - */ - destroy: function () - { - this._pending = []; - this._active = []; - this._destroy = []; - } - -}); - -module.exports = ProcessQueue; - - -/***/ }), -/* 224 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.TextFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='txt'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Text File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. - * - * @class TextFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var TextFile = new Class({ - - Extends: File, - - initialize: - - function TextFile (loader, key, url, xhrSettings) - { - var extension = 'txt'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'text', - cache: loader.cacheManager.text, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.TextFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onProcessComplete(); - } - -}); - -/** - * Adds a Text file, or array of Text files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.text('story', files/IntroStory.txt'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Text Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Text Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.text({ - * key: 'story', - * url: 'files/IntroStory.txt' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.image('story', 'files/IntroStory.txt'); - * // and later in your game ... - * var data = this.cache.text.get('story'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Text Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" - * and no URL is given then the Loader will set the URL to be "story.txt". It will always add `.txt` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Text File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#text - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.TextFileConfig|Phaser.Loader.FileTypes.TextFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('text', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TextFile(this, key[i])); - } - } - else - { - this.addFile(new TextFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = TextFile; - - -/***/ }), -/* 225 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.RotateAroundXY - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var RotateAroundXY = function (triangle, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); - - var tx = triangle.x1 - x; - var ty = triangle.y1 - y; - - triangle.x1 = tx * c - ty * s + x; - triangle.y1 = tx * s + ty * c + y; - - tx = triangle.x2 - x; - ty = triangle.y2 - y; - - triangle.x2 = tx * c - ty * s + x; - triangle.y2 = tx * s + ty * c + y; - - tx = triangle.x3 - x; - ty = triangle.y3 - y; - - triangle.x3 = tx * c - ty * s + x; - triangle.y3 = tx * s + ty * c + y; - - return triangle; -}; - -module.exports = RotateAroundXY; - - -/***/ }), -/* 226 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(71); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {integer} quantity - [description] - * @param {number} stepRate - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ -var GetPoints = function (triangle, quantity, stepRate, out) -{ - if (out === undefined) { out = []; } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. - if (!quantity) - { - quantity = perimeter / stepRate; - } - - for (var i = 0; i < quantity; i++) - { - var p = perimeter * (i / quantity); - var localPosition = 0; - - var point = new Point(); - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - point.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - point.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - point.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - point.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - point.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - point.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - out.push(point); - } - - return out; -}; - -module.exports = GetPoints; - - -/***/ }), -/* 227 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var Length = __webpack_require__(71); - -// Position is a value between 0 and 1 -/** - * [description] - * - * @function Phaser.Geom.Triangle.GetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {float} position - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetPoint = function (triangle, position, out) -{ - if (out === undefined) { out = new Point(); } - - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - if (position <= 0 || position >= 1) - { - out.x = line1.x1; - out.y = line1.y1; - - return out; - } - - var length1 = Length(line1); - var length2 = Length(line2); - var length3 = Length(line3); - - var perimeter = length1 + length2 + length3; - - var p = perimeter * position; - var localPosition = 0; - - // Which line is it on? - - if (p < length1) - { - // Line 1 - localPosition = p / length1; - - out.x = line1.x1 + (line1.x2 - line1.x1) * localPosition; - out.y = line1.y1 + (line1.y2 - line1.y1) * localPosition; - } - else if (p > length1 + length2) - { - // Line 3 - p -= length1 + length2; - localPosition = p / length3; - - out.x = line3.x1 + (line3.x2 - line3.x1) * localPosition; - out.y = line3.y1 + (line3.y2 - line3.y1) * localPosition; - } - else - { - // Line 2 - p -= length1; - localPosition = p / length2; - - out.x = line2.x1 + (line2.x2 - line2.x1) * localPosition; - out.y = line2.y1 + (line2.y2 - line2.y1) * localPosition; - } - - return out; -}; - -module.exports = GetPoint; - - -/***/ }), -/* 228 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.GetAspectRatio - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {number} [description] - */ -var GetAspectRatio = function (rect) -{ - return (rect.height === 0) ? NaN : rect.width / rect.height; -}; - -module.exports = GetAspectRatio; - - -/***/ }), -/* 229 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Checks whether the x and y coordinates are contained within this polygon. -// Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva - -/** - * [description] - * - * @function Phaser.Geom.Polygon.Contains - * @since 3.0.0 - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ -var Contains = function (polygon, x, y) -{ - var inside = false; - - for (var i = -1, j = polygon.points.length - 1; ++i < polygon.points.length; j = i) - { - var ix = polygon.points[i].x; - var iy = polygon.points[i].y; - - var jx = polygon.points[j].x; - var jy = polygon.points[j].y; - - if (((iy <= y && y < jy) || (jy <= y && y < iy)) && (x < (jx - ix) * (y - iy) / (jy - iy) + ix)) - { - inside = !inside; - } - } - - return inside; -}; - -module.exports = Contains; - - -/***/ }), -/* 230 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.RotateAroundXY - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var RotateAroundXY = function (line, x, y, angle) -{ - var c = Math.cos(angle); - var s = Math.sin(angle); - - var tx = line.x1 - x; - var ty = line.y1 - y; - - line.x1 = tx * c - ty * s + x; - line.y1 = tx * s + ty * c + y; - - tx = line.x2 - x; - ty = line.y2 - y; - - line.x2 = tx * c - ty * s + x; - line.y2 = tx * s + ty * c + y; - - return line; -}; - -module.exports = RotateAroundXY; - - -/***/ }), -/* 231 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// http://www.blackpawn.com/texts/pointinpoly/ - -// points is an array of Point-like objects with public x/y properties -// returns an array containing all points that are within the triangle, or an empty array if none -// if 'returnFirst' is true it will return after the first point within the triangle is found - -/** - * [description] - * - * @function Phaser.Geom.Triangle.ContainsArray - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point[]} points - [description] - * @param {boolean} [returnFirst] - [description] - * @param {array} [out] - [description] - * - * @return {Phaser.Geom.Point[]} [description] - */ -var ContainsArray = function (triangle, points, returnFirst, out) -{ - if (returnFirst === undefined) { returnFirst = false; } - if (out === undefined) { out = []; } - - var v0x = triangle.x3 - triangle.x1; - var v0y = triangle.y3 - triangle.y1; - - var v1x = triangle.x2 - triangle.x1; - var v1y = triangle.y2 - triangle.y1; - - var dot00 = (v0x * v0x) + (v0y * v0y); - var dot01 = (v0x * v1x) + (v0y * v1y); - var dot11 = (v1x * v1x) + (v1y * v1y); - - // Compute barycentric coordinates - var b = ((dot00 * dot11) - (dot01 * dot01)); - var inv = (b === 0) ? 0 : (1 / b); - - var u; - var v; - var v2x; - var v2y; - var dot02; - var dot12; - - var x1 = triangle.x1; - var y1 = triangle.y1; - - for (var i = 0; i < points.length; i++) - { - v2x = points[i].x - x1; - v2y = points[i].y - y1; - - dot02 = (v0x * v2x) + (v0y * v2y); - dot12 = (v1x * v2x) + (v1y * v2y); - - u = ((dot11 * dot02) - (dot01 * dot12)) * inv; - v = ((dot00 * dot12) - (dot01 * dot02)) * inv; - - if (u >= 0 && v >= 0 && (u + v < 1)) - { - out.push({ x: points[i].x, y: points[i].y }); - - if (returnFirst) - { - break; - } - } - } - - return out; -}; - -module.exports = ContainsArray; - - -/***/ }), -/* 232 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Mesh = __webpack_require__(145); - -/** - * @classdesc - * A Quad Game Object. - * - * A Quad is a Mesh Game Object pre-configured with two triangles arranged into a rectangle, with a single - * texture spread across them. - * - * You can manipulate the corner points of the quad via the getters and setters such as `topLeftX`, and also - * change their alpha and color values. The quad itself can be moved by adjusting the `x` and `y` properties. - * - * @class Quad - * @extends Phaser.GameObjects.Mesh - * @memberOf Phaser.GameObjects - * @constructor - * @webglOnly - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Quad belongs. - * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var Quad = new Class({ - - Extends: Mesh, - - initialize: - - function Quad (scene, x, y, texture, frame) - { - // 0----3 - // |\ B| - // | \ | - // | \ | - // | A \| - // | \ - // 1----2 - - var vertices = [ - 0, 0, // tl - 0, 0, // bl - 0, 0, // br - 0, 0, // tl - 0, 0, // br - 0, 0 // tr - ]; - var uv = [ - 0, 0, // tl - 0, 1, // bl - 1, 1, // br - 0, 0, // tl - 1, 1, // br - 1, 0 // tr - ]; - var colors = [ - 0xffffff, // tl - 0xffffff, // bl - 0xffffff, // br - 0xffffff, // tl - 0xffffff, // br - 0xffffff // tr - ]; - var alphas = [ - 1, // tl - 1, // bl - 1, // br - 1, // tl - 1, // br - 1 // tr - ]; - - Mesh.call(this, scene, x, y, vertices, uv, colors, alphas, texture, frame); - - this.resetPosition(); - }, - - /** - * The top-left x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftX - * @type {number} - * @since 3.0.0 - */ - topLeftX: { - - get: function () - { - return this.x + this.vertices[0]; - }, - - set: function (value) - { - this.vertices[0] = value - this.x; - this.vertices[6] = value - this.x; - } - - }, - - /** - * The top-left y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftY - * @type {number} - * @since 3.0.0 - */ - topLeftY: { - - get: function () - { - return this.y + this.vertices[1]; - }, - - set: function (value) - { - this.vertices[1] = value - this.y; - this.vertices[7] = value - this.y; - } - - }, - - /** - * The top-right x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightX - * @type {number} - * @since 3.0.0 - */ - topRightX: { - - get: function () - { - return this.x + this.vertices[10]; - }, - - set: function (value) - { - this.vertices[10] = value - this.x; - } - - }, - - /** - * The top-right y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightY - * @type {number} - * @since 3.0.0 - */ - topRightY: { - - get: function () - { - return this.y + this.vertices[11]; - }, - - set: function (value) - { - this.vertices[11] = value - this.y; - } - - }, - - /** - * The bottom-left x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftX - * @type {number} - * @since 3.0.0 - */ - bottomLeftX: { - - get: function () - { - return this.x + this.vertices[2]; - }, - - set: function (value) - { - this.vertices[2] = value - this.x; - } - - }, - - /** - * The bottom-left y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftY - * @type {number} - * @since 3.0.0 - */ - bottomLeftY: { - - get: function () - { - return this.y + this.vertices[3]; - }, - - set: function (value) - { - this.vertices[3] = value - this.y; - } - - }, - - /** - * The bottom-right x vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightX - * @type {number} - * @since 3.0.0 - */ - bottomRightX: { - - get: function () - { - return this.x + this.vertices[4]; - }, - - set: function (value) - { - this.vertices[4] = value - this.x; - this.vertices[8] = value - this.x; - } - - }, - - /** - * The bottom-right y vertex of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightY - * @type {number} - * @since 3.0.0 - */ - bottomRightY: { - - get: function () - { - return this.y + this.vertices[5]; - }, - - set: function (value) - { - this.vertices[5] = value - this.y; - this.vertices[9] = value - this.y; - } - - }, - - /** - * The top-left alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftAlpha - * @type {float} - * @since 3.0.0 - */ - topLeftAlpha: { - - get: function () - { - return this.alphas[0]; - }, - - set: function (value) - { - this.alphas[0] = value; - this.alphas[3] = value; - } - - }, - - /** - * The top-right alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightAlpha - * @type {float} - * @since 3.0.0 - */ - topRightAlpha: { - - get: function () - { - return this.alphas[5]; - }, - - set: function (value) - { - this.alphas[5] = value; - } - - }, - - /** - * The bottom-left alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftAlpha - * @type {float} - * @since 3.0.0 - */ - bottomLeftAlpha: { - - get: function () - { - return this.alphas[1]; - }, - - set: function (value) - { - this.alphas[1] = value; - } - - }, - - /** - * The bottom-right alpha value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightAlpha - * @type {float} - * @since 3.0.0 - */ - bottomRightAlpha: { - - get: function () - { - return this.alphas[2]; - }, - - set: function (value) - { - this.alphas[2] = value; - this.alphas[4] = value; - } - - }, - - /** - * The top-left color value of this Quad. - * - * @name Phaser.GameObjects.Quad#topLeftColor - * @type {number} - * @since 3.0.0 - */ - topLeftColor: { - - get: function () - { - return this.colors[0]; - }, - - set: function (value) - { - this.colors[0] = value; - this.colors[3] = value; - } - - }, - - /** - * The top-right color value of this Quad. - * - * @name Phaser.GameObjects.Quad#topRightColor - * @type {number} - * @since 3.0.0 - */ - topRightColor: { - - get: function () - { - return this.colors[5]; - }, - - set: function (value) - { - this.colors[5] = value; - } - - }, - - /** - * The bottom-left color value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomLeftColor - * @type {number} - * @since 3.0.0 - */ - bottomLeftColor: { - - get: function () - { - return this.colors[1]; - }, - - set: function (value) - { - this.colors[1] = value; - } - - }, - - /** - * The bottom-right color value of this Quad. - * - * @name Phaser.GameObjects.Quad#bottomRightColor - * @type {number} - * @since 3.0.0 - */ - bottomRightColor: { - - get: function () - { - return this.colors[2]; - }, - - set: function (value) - { - this.colors[2] = value; - this.colors[4] = value; - } - - }, - - /** - * Sets the top-left vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setTopLeft - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setTopLeft: function (x, y) - { - this.topLeftX = x; - this.topLeftY = y; - - return this; - }, - - /** - * Sets the top-right vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setTopRight - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setTopRight: function (x, y) - { - this.topRightX = x; - this.topRightY = y; - - return this; - }, - - /** - * Sets the bottom-left vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setBottomLeft - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setBottomLeft: function (x, y) - { - this.bottomLeftX = x; - this.bottomLeftY = y; - - return this; - }, - - /** - * Sets the bottom-right vertex position of this Quad. - * - * @method Phaser.GameObjects.Quad#setBottomRight - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate of the vertex. - * @param {number} y - The vertical coordinate of the vertex. - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - setBottomRight: function (x, y) - { - this.bottomRightX = x; - this.bottomRightY = y; - - return this; - }, - - /** - * Resets the positions of the four corner vertices of this Quad. - * - * @method Phaser.GameObjects.Quad#resetPosition - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetPosition: function () - { - var x = this.x; - var y = this.y; - var halfWidth = Math.floor(this.width / 2); - var halfHeight = Math.floor(this.height / 2); - - this.setTopLeft(x - halfWidth, y - halfHeight); - this.setTopRight(x + halfWidth, y - halfHeight); - this.setBottomLeft(x - halfWidth, y + halfHeight); - this.setBottomRight(x + halfWidth, y + halfHeight); - - return this; - }, - - /** - * Resets the alpha values used by this Quad back to 1. - * - * @method Phaser.GameObjects.Quad#resetAlpha - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetAlpha: function () - { - var alphas = this.alphas; - - alphas[0] = 1; - alphas[1] = 1; - alphas[2] = 1; - alphas[3] = 1; - alphas[4] = 1; - alphas[5] = 1; - - return this; - }, - - /** - * Resets the color values used by this Quad back to 0xffffff. - * - * @method Phaser.GameObjects.Quad#resetColors - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - resetColors: function () - { - var colors = this.colors; - - colors[0] = 0xffffff; - colors[1] = 0xffffff; - colors[2] = 0xffffff; - colors[3] = 0xffffff; - colors[4] = 0xffffff; - colors[5] = 0xffffff; - - return this; - }, - - /** - * Resets the position, alpha and color values used by this Quad. - * - * @method Phaser.GameObjects.Quad#reset - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Quad} This Game Object. - */ - reset: function () - { - this.resetPosition(); - - this.resetAlpha(); - - return this.resetColors(); - } - -}); - -module.exports = Quad; - - -/***/ }), -/* 233 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(22); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var CONST = __webpack_require__(20); -var GameObject = __webpack_require__(2); -var GetPowerOfTwo = __webpack_require__(411); -var TileSpriteRender = __webpack_require__(886); - -/** - * @classdesc - * [description] - * - * @class TileSprite - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - */ -var TileSprite = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - TileSpriteRender - ], - - initialize: - - function TileSprite (scene, x, y, width, height, texture, frame) - { - var renderer = scene.sys.game.renderer; - - GameObject.call(this, scene, 'TileSprite'); - - /** - * The horizontal scroll position of the Tile Sprite. - * - * @name Phaser.GameObjects.TileSprite#tilePositionX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tilePositionX = 0; - - /** - * The vertical scroll position of the Tile Sprite. - * - * @name Phaser.GameObjects.TileSprite#tilePositionY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tilePositionY = 0; - - /** - * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. - * - * Such changes include the texture frame and scroll position of the Tile Sprite. - * - * @name Phaser.GameObjects.TileSprite#dirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.dirty = true; - - /** - * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. - * - * @name Phaser.GameObjects.TileSprite#tileTexture - * @type {?WebGLTexture} - * @default null - * @since 3.0.0 - */ - this.tileTexture = null; - - /** - * The renderer in use by this Tile Sprite. - * - * @name Phaser.GameObjects.TileSprite#renderer - * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} - * @since 3.0.0 - */ - this.renderer = renderer; - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSize(width, height); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); - - /** - * The next power of two value from the width of the Frame. - * - * @name Phaser.GameObjects.TileSprite#potWidth - * @type {integer} - * @since 3.0.0 - */ - this.potWidth = GetPowerOfTwo(this.frame.width); - - /** - * The next power of two value from the height of the Frame. - * - * @name Phaser.GameObjects.TileSprite#potHeight - * @type {integer} - * @since 3.0.0 - */ - this.potHeight = GetPowerOfTwo(this.frame.height); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasPattern - * @type {?CanvasPattern} - * @default null - * @since 3.0.0 - */ - this.canvasPattern = null; - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasBuffer - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvasBuffer = CanvasPool.create2D(this, this.potWidth, this.potHeight); - - /** - * [description] - * - * @name Phaser.GameObjects.TileSprite#canvasBufferCtx - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.canvasBufferCtx = this.canvasBuffer.getContext('2d'); - - this.oldFrame = null; - - this.updateTileTexture(); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function (renderer) - { - var gl = renderer.gl; - - this.tileTexture = null; - this.dirty = true; - this.tileTexture = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.canvasBuffer, this.potWidth, this.potHeight); - }, this); - } - }, - - /** - * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. - * - * @method Phaser.GameObjects.TileSprite#setTilePosition - * @since 3.3.0 - * - * @param {number} [x] - The x position of this sprite's tiling texture. - * @param {number} [y] - The y position of this sprite's tiling texture. - * - * @return {Phaser.GameObjects.TileSprite} This Tile Sprite instance. - */ - setTilePosition: function (x, y) - { - if (x !== undefined) - { - this.tilePositionX = x; - } - - if (y !== undefined) - { - this.tilePositionY = y; - } - - return this; - }, - - /** - * Render the tile texture if it is dirty, or if the frame has changed. - * - * @method Phaser.GameObjects.TileSprite#updateTileTexture - * @since 3.0.0 - */ - updateTileTexture: function () - { - if (!this.dirty && this.oldFrame === this.frame) - { - return; - } - - this.oldFrame = this.frame; - - this.canvasBufferCtx.clearRect(0, 0, this.canvasBuffer.width, this.canvasBuffer.height); - - if (this.renderer.gl) - { - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.potWidth, this.potHeight - ); - - this.tileTexture = this.renderer.canvasToTexture(this.canvasBuffer, this.tileTexture); - } - else - { - this.canvasBuffer.width = this.frame.cutWidth; - this.canvasBuffer.height = this.frame.cutHeight; - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.frame.cutWidth, this.frame.cutHeight - ); - - this.canvasPattern = this.canvasBufferCtx.createPattern(this.canvasBuffer, 'repeat'); - } - - this.dirty = false; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.TileSprite#preDestroy - * @protected - * @since 3.9.0 - */ - preDestroy: function () - { - if (this.renderer && this.renderer.gl) - { - this.renderer.deleteTexture(this.tileTexture); - } - - CanvasPool.remove(this.canvasBuffer); - - this.canvasPattern = null; - this.canvasBufferCtx = null; - this.canvasBuffer = null; - - this.renderer = null; - } - -}); - -module.exports = TileSprite; - - -/***/ }), -/* 234 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasPool = __webpack_require__(22); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var CONST = __webpack_require__(20); -var GameObject = __webpack_require__(2); -var Render = __webpack_require__(894); -var RenderTextureCanvas = __webpack_require__(891); -var RenderTextureWebGL = __webpack_require__(890); - -/** - * @classdesc - * A Render Texture. - * - * @class RenderTexture - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.2.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.MatrixStack - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {integer} [width=32] - The width of the Render Texture. - * @param {integer} [height=32] - The height of the Render Texture. - */ -var RenderTexture = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Mask, - Components.MatrixStack, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Tint, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function RenderTexture (scene, x, y, width, height) - { - if (width === undefined) { width = 32; } - if (height === undefined) { height = 32; } - - GameObject.call(this, scene, 'RenderTexture'); - - this.initMatrixStack(); - - /** - * A reference to either the Canvas or WebGL Renderer that the Game instance is using. - * - * @name Phaser.GameObjects.RenderTexture#renderer - * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} - * @since 3.2.0 - */ - this.renderer = scene.sys.game.renderer; - - /** - * The tint of the Render Texture when rendered. - * - * @name Phaser.GameObjects.RenderTexture#globalTint - * @type {number} - * @default 0xffffff - * @since 3.2.0 - */ - this.globalTint = 0xffffff; - - /** - * The alpha of the Render Texture when rendered. - * - * @name Phaser.GameObjects.RenderTexture#globalAlpha - * @type {number} - * @default 1 - * @since 3.2.0 - */ - this.globalAlpha = 1; - - /** - * The HTML Canvas Element that the Render Texture is drawing to. - * This is only set if Phaser is running with the Canvas Renderer. - * - * @name Phaser.GameObjects.RenderTexture#canvas - * @type {?HTMLCanvasElement} - * @since 3.2.0 - */ - this.canvas = null; - - /** - * A reference to the Rendering Context belonging to the Canvas Element this Render Texture is drawing to. - * This is only set if Phaser is running with the Canvas Renderer. - * - * @name Phaser.GameObjects.RenderTexture#context - * @type {?CanvasRenderingContext2D} - * @since 3.2.0 - */ - this.context = null; - - /** - * A reference to the GL Frame Buffer this Render Texture is drawing to. - * This is only set if Phaser is running with the WebGL Renderer. - * - * @name Phaser.GameObjects.RenderTexture#framebuffer - * @type {?WebGLFramebuffer} - * @since 3.2.0 - */ - this.framebuffer = null; - - if (this.renderer.type === CONST.WEBGL) - { - var gl = this.renderer.gl; - - this.gl = gl; - this.fill = RenderTextureWebGL.fill; - this.clear = RenderTextureWebGL.clear; - this.draw = RenderTextureWebGL.draw; - this.drawFrame = RenderTextureWebGL.drawFrame; - this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); - this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); - } - else if (this.renderer.type === CONST.CANVAS) - { - this.fill = RenderTextureCanvas.fill; - this.clear = RenderTextureCanvas.clear; - this.draw = RenderTextureCanvas.draw; - this.drawFrame = RenderTextureCanvas.drawFrame; - this.canvas = CanvasPool.create2D(this, width, height); - this.context = this.canvas.getContext('2d'); - } - - this.setPosition(x, y); - this.setSize(width, height); - this.initPipeline('TextureTintPipeline'); - }, - - /** - * Resizes the Render Texture to the new dimensions given. - * - * In WebGL it will destroy and then re-create the frame buffer being used by the Render Texture. - * In Canvas it will resize the underlying canvas element. - * Both approaches will erase everything currently drawn to the Render Texture. - * - * If the dimensions given are the same as those already being used, calling this method will do nothing. - * - * @method Phaser.GameObjects.RenderTexture#resize - * @since 3.10.0 - * - * @param {number} width - The new width of the Render Texture. - * @param {number} [height] - The new height of the Render Texture. If not specified, will be set the same as the `width`. - * - * @return {this} This Render Texture. - */ - resize: function (width, height) - { - if (height === undefined) { height = width; } - - if (width !== this.width || height !== this.height) - { - if (this.canvas) - { - this.canvas.width = width; - this.canvas.height = height; - } - else - { - this.renderer.deleteTexture(this.texture); - this.renderer.deleteFramebuffer(this.framebuffer); - - var gl = this.renderer.gl; - - this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); - this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); - } - - this.setSize(width, height); - } - - return this; - }, - - /** - * Set the tint to use when rendering this Render Texture. - * - * @method Phaser.GameObjects.RenderTexture#setGlobalTint - * @since 3.2.0 - * - * @param {integer} tint - The tint value. - * - * @return {this} This Render Texture. - */ - setGlobalTint: function (tint) - { - this.globalTint = tint; - - return this; - }, - - /** - * Set the alpha to use when rendering this Render Texture. - * - * @method Phaser.GameObjects.RenderTexture#setGlobalAlpha - * @since 3.2.0 - * - * @param {number} alpha - The alpha value. - * - * @return {this} This Render Texture. - */ - setGlobalAlpha: function (alpha) - { - this.globalAlpha = alpha; - - return this; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.RenderTexture#preDestroy - * @protected - * @since 3.9.0 - */ - preDestroy: function () - { - if (this.renderer && this.renderer.gl) - { - this.renderer.deleteTexture(this.texture); - this.renderer.deleteFramebuffer(this.framebuffer); - } - } - - /** - * Fills the Render Texture with the given color. - * - * @method Phaser.GameObjects.RenderTexture#fill - * @since 3.2.0 - * - * @param {number} rgb - The color to fill the Render Texture with. - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - - /** - * Clears the Render Texture. - * - * @method Phaser.GameObjects.RenderTexture#clear - * @since 3.2.0 - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - - /** - * Draws a texture frame to the Render Texture at the given position. - * - * @method Phaser.GameObjects.RenderTexture#draw - * @since 3.2.0 - * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {number} x - The x position to draw the frame at. - * @param {number} y - The y position to draw the frame at. - * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. - */ - -}); - -module.exports = RenderTexture; - - -/***/ }), -/* 235 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var GravityWell = __webpack_require__(458); -var List = __webpack_require__(93); -var ParticleEmitter = __webpack_require__(456); -var Render = __webpack_require__(898); - -/** - * @classdesc - * A Particle Emitter Manager creates and controls {@link Phaser.GameObjects.Particles.ParticleEmitter Particle Emitters} and {@link Phaser.GameObjects.Particles.GravityWell Gravity Wells}. - * - * @class ParticleEmitterManager - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects.Particles - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Particles.Components.Depth - * @extends Phaser.GameObjects.Particles.Components.Pipeline - * @extends Phaser.GameObjects.Particles.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Emitter Manager belongs. - * @param {string} texture - The key of the Texture this Emitter Manager will use to render particles, as stored in the Texture Manager. - * @param {(string|integer)} frame - An optional frame from the Texture this Emitter Manager will use to render particles. - * @param {ParticleEmitterConfig|ParticleEmitterConfig[]} emitters - Configuration settings for one or more emitters to create. - */ -var ParticleEmitterManager = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Depth, - Components.Pipeline, - Components.Visible, - Render - ], - - initialize: - - // frame is optional and can contain the emitters array or object if skipped - function ParticleEmitterManager (scene, texture, frame, emitters) - { - GameObject.call(this, scene, 'ParticleEmitterManager'); - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#blendMode - * @type {integer} - * @default -1 - * @private - * @since 3.0.0 - */ - this.blendMode = -1; - - /** - * The time scale applied to all emitters and particles, affecting flow rate, lifespan, and movement. - * Values larger than 1 are faster than normal. - * This is multiplied with any timeScale set on each individual emitter. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#timeScale - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * The texture used to render this Emitter Manager's particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#texture - * @type {Phaser.Textures.Texture} - * @default null - * @since 3.0.0 - */ - this.texture = null; - - /** - * The texture frame used to render this Emitter Manager's particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frame - * @type {Phaser.Textures.Frame} - * @default null - * @since 3.0.0 - */ - this.frame = null; - - /** - * Names of this Emitter Manager's texture frames. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#frameNames - * @type {string[]} - * @since 3.0.0 - */ - this.frameNames = []; - - // frame is optional and can contain the emitters array or object if skipped - if (frame !== null && (typeof frame === 'object' || Array.isArray(frame))) - { - emitters = frame; - frame = null; - } - - this.setTexture(texture, frame); - - this.initPipeline('TextureTintPipeline'); - - /** - * A list of Emitters being managed by this Emitter Manager. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#emitters - * @type {Phaser.Structs.List.} - * @since 3.0.0 - */ - this.emitters = new List(this); - - /** - * A list of Gravity Wells being managed by this Emitter Manager. - * - * @name Phaser.GameObjects.Particles.ParticleEmitterManager#wells - * @type {Phaser.Structs.List.} - * @since 3.0.0 - */ - this.wells = new List(this); - - if (emitters) - { - // An array of emitter configs? - if (!Array.isArray(emitters)) - { - emitters = [ emitters ]; - } - - for (var i = 0; i < emitters.length; i++) - { - this.createEmitter(emitters[i]); - } - } - }, - - /** - * Sets the texture and frame this Emitter Manager will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setTexture - * @since 3.0.0 - * - * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - setTexture: function (key, frame) - { - this.texture = this.scene.sys.textures.get(key); - - return this.setFrame(frame); - }, - - /** - * Sets the frame this Emitter Manager will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setFrame - * @since 3.0.0 - * - * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - setFrame: function (frame) - { - this.frame = this.texture.get(frame); - - this.frameNames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); - - this.defaultFrame = this.frame; - - return this; - }, - - /** - * Assigns texture frames to an emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setEmitterFrames - * @since 3.0.0 - * - * @param {(Phaser.Textures.Frame|Phaser.Textures.Frame[])} frames - The texture frames. - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The particle emitter to modify. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - setEmitterFrames: function (frames, emitter) - { - if (!Array.isArray(frames)) - { - frames = [ frames ]; - } - - var out = emitter.frames; - - out.length = 0; - - for (var i = 0; i < frames.length; i++) - { - var frame = frames[i]; - - if (this.frameNames.indexOf(frame) !== -1) - { - out.push(this.texture.get(frame)); - } - } - - if (out.length > 0) - { - emitter.defaultFrame = out[0]; - } - else - { - emitter.defaultFrame = this.defaultFrame; - } - - return this; - }, - - /** - * Adds an existing Particle Emitter to this Emitter Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addEmitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Particle Emitter to add to this Emitter Manager. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was added to this Emitter Manager. - */ - addEmitter: function (emitter) - { - return this.emitters.add(emitter); - }, - - /** - * Creates a new Particle Emitter object, adds it to this Emitter Manager and returns a reference to it. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createEmitter - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} The Particle Emitter that was created. - */ - createEmitter: function (config) - { - return this.addEmitter(new ParticleEmitter(this, config)); - }, - - /** - * Adds an existing Gravity Well object to this Emitter Manager. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#addGravityWell - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.GravityWell} well - The Gravity Well to add to this Emitter Manager. - * - * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was added to this Emitter Manager. - */ - addGravityWell: function (well) - { - return this.wells.add(well); - }, - - /** - * Creates a new Gravity Well, adds it to this Emitter Manager and returns a reference to it. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#createGravityWell - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Particles.GravityWell} The Gravity Well that was created. - */ - createGravityWell: function (config) - { - return this.addGravityWell(new GravityWell(config)); - }, - - /** - * Emits particles from each active emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticle - * @since 3.0.0 - * - * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - * @param {float} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. - * @param {float} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - emitParticle: function (count, x, y) - { - var emitters = this.emitters.list; - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - if (emitter.active) - { - emitter.emitParticle(count, x, y); - } - } - - return this; - }, - - /** - * Emits particles from each active emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#emitParticleAt - * @since 3.0.0 - * - * @param {float} [x] - The x-coordinate to to emit particles from. The default is the x-coordinate of the emitter's current location. - * @param {float} [y] - The y-coordinate to to emit particles from. The default is the y-coordinate of the emitter's current location. - * @param {integer} [count] - The number of particles to release from each emitter. The default is the emitter's own {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - emitParticleAt: function (x, y, count) - { - return this.emitParticle(count, x, y); - }, - - /** - * Pauses this Emitter Manager. - * - * This has the effect of pausing all emitters, and all particles of those emitters, currently under its control. - * - * The particles will still render, but they will not have any of their logic updated. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#pause - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - pause: function () - { - this.active = false; - - return this; - }, - - /** - * Resumes this Emitter Manager, should it have been previously paused. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#resume - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} This Emitter Manager. - */ - resume: function () - { - this.active = true; - - return this; - }, - - /** - * Gets all active particle processors (gravity wells). - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#getProcessors - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.GravityWell[]} - The active gravity wells. - */ - getProcessors: function () - { - return this.wells.getAll('active', true); - }, - - /** - * Updates all active emitters. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#preUpdate - * @since 3.0.0 - * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {float} delta - The delta time, in ms, elapsed since the last frame. - */ - preUpdate: function (time, delta) - { - // Scale the delta - delta *= this.timeScale; - - var emitters = this.emitters.list; - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - if (emitter.active) - { - emitter.preUpdate(time, delta); - } - } - }, - - /** - * A NOOP method so you can pass an EmitterManager to a Container. - * Calling this method will do nothing. It is intentionally empty. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setAlpha - * @private - * @since 3.10.0 - */ - setAlpha: function () - { - }, - - /** - * A NOOP method so you can pass an EmitterManager to a Container. - * Calling this method will do nothing. It is intentionally empty. - * - * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setScrollFactor - * @private - * @since 3.10.0 - */ - setScrollFactor: function () - { - } - -}); - -module.exports = ParticleEmitterManager; - - -/***/ }), -/* 236 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Stepped - */ - -module.exports = __webpack_require__(421); - - -/***/ }), -/* 237 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Sine - */ - -module.exports = { - - In: __webpack_require__(424), - Out: __webpack_require__(423), - InOut: __webpack_require__(422) - -}; - - -/***/ }), -/* 238 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Quintic - */ - -module.exports = { - - In: __webpack_require__(427), - Out: __webpack_require__(426), - InOut: __webpack_require__(425) - -}; - - -/***/ }), -/* 239 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Quartic - */ - -module.exports = { - - In: __webpack_require__(430), - Out: __webpack_require__(429), - InOut: __webpack_require__(428) - -}; - - -/***/ }), -/* 240 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Quadratic - */ - -module.exports = { - - In: __webpack_require__(433), - Out: __webpack_require__(432), - InOut: __webpack_require__(431) - -}; - - -/***/ }), -/* 241 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Linear - */ - -module.exports = __webpack_require__(434); - - -/***/ }), -/* 242 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Expo - */ - -module.exports = { - - In: __webpack_require__(437), - Out: __webpack_require__(436), - InOut: __webpack_require__(435) - -}; - - -/***/ }), -/* 243 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Elastic - */ - -module.exports = { - - In: __webpack_require__(440), - Out: __webpack_require__(439), - InOut: __webpack_require__(438) - -}; - - -/***/ }), -/* 244 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Cubic - */ - -module.exports = { - - In: __webpack_require__(443), - Out: __webpack_require__(442), - InOut: __webpack_require__(441) - -}; - - -/***/ }), -/* 245 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Circular - */ - -module.exports = { - - In: __webpack_require__(446), - Out: __webpack_require__(445), - InOut: __webpack_require__(444) - -}; - - -/***/ }), -/* 246 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Bounce - */ - -module.exports = { - - In: __webpack_require__(449), - Out: __webpack_require__(448), - InOut: __webpack_require__(447) - -}; - - -/***/ }), -/* 247 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing.Back - */ - -module.exports = { - - In: __webpack_require__(452), - Out: __webpack_require__(451), - InOut: __webpack_require__(450) - -}; - - -/***/ }), -/* 248 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Generate a random floating point number between the two given bounds, minimum inclusive, maximum exclusive. - * - * @function Phaser.Math.FloatBetween - * @since 3.0.0 - * - * @param {float} min - The lower bound for the float, inclusive. - * @param {float} max - The upper bound for the float exclusive. - * - * @return {float} A random float within the given range. - */ -var FloatBetween = function (min, max) -{ - return Math.random() * (max - min) + min; -}; - -module.exports = FloatBetween; - - -/***/ }), -/* 249 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Ellipse = __webpack_require__(114); - -Ellipse.Area = __webpack_require__(472); -Ellipse.Circumference = __webpack_require__(177); -Ellipse.CircumferencePoint = __webpack_require__(113); -Ellipse.Clone = __webpack_require__(471); -Ellipse.Contains = __webpack_require__(54); -Ellipse.ContainsPoint = __webpack_require__(470); -Ellipse.ContainsRect = __webpack_require__(469); -Ellipse.CopyFrom = __webpack_require__(468); -Ellipse.Equals = __webpack_require__(467); -Ellipse.GetBounds = __webpack_require__(466); -Ellipse.GetPoint = __webpack_require__(179); -Ellipse.GetPoints = __webpack_require__(178); -Ellipse.Offset = __webpack_require__(465); -Ellipse.OffsetPoint = __webpack_require__(464); -Ellipse.Random = __webpack_require__(134); - -module.exports = Ellipse; - - -/***/ }), -/* 250 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var GetBitmapTextSize = __webpack_require__(475); -var Render = __webpack_require__(903); - -/** - * @typedef {object} DisplayCallbackConfig - * @property {{topLeft:number,topRight:number,bottomLeft:number,bottomRight:number}} tint - The tint of the character being rendered. - * @property {number} index - The index of the character being rendered. - * @property {number} charCode - The character code of the character being rendered. - * @property {number} x - The x position of the character being rendered. - * @property {number} y - The y position of the character being rendered. - * @property {number} scale - The scale of the character being rendered. - * @property {number} rotation - The rotation of the character being rendered. - * @property {any} data - Custom data stored with the character being rendered. - */ - -/** - * @callback DisplayCallback - * - * @param {DisplayCallbackConfig} display - Settings of the character that is about to be rendered. - * - * @return {{x:number, y:number, scale:number, rotation:number}} Altered position, scale and rotation values for the character that is about to be rendered. - */ - -/** - * @classdesc - * [description] - * - * @class DynamicBitmapText - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} x - The x coordinate of this Game Object in world space. - * @param {number} y - The y coordinate of this Game Object in world space. - * @param {string} font - The key of the font to use from the Bitmap Font cache. - * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @param {number} [size] - The font size of this Bitmap Text. - */ -var DynamicBitmapText = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScrollFactor, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function DynamicBitmapText (scene, x, y, font, text, size) - { - if (text === undefined) { text = ''; } - - GameObject.call(this, scene, 'DynamicBitmapText'); - - /** - * The key of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#font - * @type {string} - * @since 3.0.0 - */ - this.font = font; - - var entry = this.scene.sys.cache.bitmapFont.get(font); - - /** - * The data of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#fontData - * @type {BitmapFontData} - * @since 3.0.0 - */ - this.fontData = entry.data; - - /** - * The text that this Bitmap Text object displays. - * - * @name Phaser.GameObjects.DynamicBitmapText#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * The font size of this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#fontSize - * @type {number} - * @since 3.0.0 - */ - 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.setText(text); - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * An object that describes the size of this BitmapText. - * - * @name Phaser.GameObjects.DynamicBitmapText#_bounds - * @type {BitmapTextSize} - * @private - * @since 3.0.0 - */ - this._bounds = this.getTextBounds(); - - /** - * The horizontal scroll position of the Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * The vertical scroll position of the Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * The crop width of the Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#cropWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cropWidth = 0; - - /** - * The crop height of the Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#cropHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.cropHeight = 0; - - /** - * A callback that alters how each character of the Bitmap Text is rendered. - * - * @name Phaser.GameObjects.DynamicBitmapText#displayCallback; - * @type {DisplayCallback} - * @since 3.0.0 - */ - this.displayCallback; - }, - - /** - * Set the crop size of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setSize - * @since 3.0.0 - * - * @param {number} width - The width of the crop. - * @param {number} height - The height of the crop. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setSize: function (width, height) - { - this.cropWidth = width; - this.cropHeight = height; - - return this; - }, - - /** - * Set a callback that alters how each character of the Bitmap Text is rendered. - * - * The callback receives a {@link DisplayCallbackConfig} object that contains information about the character that's - * about to be rendered. - * - * It should return an object with `x`, `y`, `scale` and `rotation` properties that will be used instead of the - * usual values when rendering. - * - * @method Phaser.GameObjects.DynamicBitmapText#setDisplayCallback - * @since 3.0.0 - * - * @param {DisplayCallback} callback - The display callback to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setDisplayCallback: function (callback) - { - this.displayCallback = callback; - - return this; - }, - - /** - * Set the font size of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setFontSize - * @since 3.0.0 - * - * @param {number} size - The font size to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setFontSize: function (size) - { - this.fontSize = size; - - return this; - }, - - /** - * Set the content of this BitmapText. - * - * An array of strings will be converted multi-line text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setText - * @since 3.0.0 - * - * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateDisplayOrigin(); - } - - return this; - }, - - /** - * Set the horizontal scroll position of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setScrollX - * @since 3.0.0 - * - * @param {number} value - The horizontal scroll position to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setScrollX: function (value) - { - this.scrollX = value; - - return this; - }, - - /** - * Set the vertical scroll position of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setScrollY - * @since 3.0.0 - * - * @param {number} value - The vertical scroll position to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setScrollY: function (value) - { - this.scrollY = value; - - return this; - }, - - /** - * Calculate the bounds of this Bitmap Text. - * - * An object is returned that contains the position, width and height of the Bitmap Text in local and global - * contexts. - * - * Local size is based on just the font size and a [0, 0] position. - * - * Global size takes into account the Game Object's scale and world position. - * - * @method Phaser.GameObjects.DynamicBitmapText#getTextBounds - * @since 3.0.0 - * - * @param {boolean} [round] - Whether to round the results to the nearest integer. - * - * @return {BitmapTextSize} An object that describes the size of this Bitmap Text. - */ - getTextBounds: function (round) - { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position - - this._bounds = GetBitmapTextSize(this, round); - - return this._bounds; - }, - - /** - * The width of this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#width - * @type {number} - * @readOnly - * @since 3.0.0 - */ - width: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.width; - } - - }, - - /** - * The height of this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#height - * @type {number} - * @readOnly - * @since 3.0.0 - */ - height: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.height; - } - - }, - - /** - * Build a JSON representation of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#toJSON - * @since 3.0.0 - * - * @return {JSONBitmapText} The JSON representation of this Bitmap Text. - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra data is added here - - var data = { - font: this.font, - text: this.text, - fontSize: this.fontSize - }; - - out.data = data; - - return out; - } - -}); - -module.exports = DynamicBitmapText; - - -/***/ }), -/* 251 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ArrayUtils = __webpack_require__(147); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var Rectangle = __webpack_require__(14); -var Render = __webpack_require__(906); -var Union = __webpack_require__(473); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * A Container Game Object. - * - * 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. - * - * The position of the Game Object automatically becomes relative to the position of the Container. - * - * When the Container is rendered, all of its children are rendered as well, in the order in which they exist - * within the Container. Container children can be repositioned using methods such as `MoveUp`, `MoveDown` and `SendToBack`. - * - * If you modify a transform property of the Container, such as `Container.x` or `Container.rotation` then it will - * automatically influence all children as well. - * - * Containers can include other Containers for deeply nested transforms. - * - * Containers can have masks set on them and can be used as a mask too. However, Container children cannot be masked. - * The masks do not 'stack up'. Only a Container on the root of the display list will use its mask. - * - * Containers can be enabled for input. Because they do not have a texture you need to provide a shape for them - * to use as their hit area. Container children can also be enabled for input, independent of the Container. - * - * Containers can be given a physics body for either Arcade Physics, Impact Physics or Matter Physics. However, - * if Container _children_ are enabled for physics you may get unexpected results, such as offset bodies, - * if the Container itself, or any of its ancestors, is positioned anywhere other than at 0 x 0. Container children - * with physics do not factor in the Container due to the excessive extra calculations needed. Please structure - * your game to work around this. - * - * It's important to understand the impact of using Containers. They add additional processing overhead into - * every one of their children. The deeper you nest them, the more the cost escalates. This is especially true - * for input events. You also loose the ability to set the display depth of Container children in the same - * flexible manner as those not within them. In short, don't use them for the sake of it. You pay a small cost - * every time you create one, try to structure your game around avoiding that where possible. - * - * @class Container - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.4.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} [x=0] - The horizontal position of this Game Object in the world. - * @param {number} [y=0] - The vertical position of this Game Object in the world. - * @param {Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. - */ -var Container = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.ScrollFactor, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function Container (scene, x, y, children) - { - GameObject.call(this, scene, 'Container'); - - /** - * An array holding the children of this Container. - * - * @name Phaser.GameObjects.Container#list - * @type {Phaser.GameObjects.GameObject[]} - * @since 3.4.0 - */ - this.list = []; - - /** - * Does this Container exclusively manage its children? - * - * The default is `true` which means a child added to this Container cannot - * belong in another Container, which includes the Scene display list. - * - * If you disable this then this Container will no longer exclusively manage its children. - * This allows you to create all kinds of interesting graphical effects, such as replicating - * Game Objects without reparenting them all over the Scene. - * However, doing so will prevent children from receiving any kind of input event or have - * their physics bodies work by default, as they're no longer a single entity on the - * display list, but are being replicated where-ever this Container is. - * - * @name Phaser.GameObjects.Container#exclusive - * @type {boolean} - * @default true - * @since 3.4.0 - */ - this.exclusive = true; - - /** - * Containers can have an optional maximum size. If set to anything above 0 it - * will constrict the addition of new Game Objects into the Container, capping off - * the maximum limit the Container can grow in size to. - * - * @name Phaser.GameObjects.Container#maxSize - * @type {integer} - * @default -1 - * @since 3.4.0 - */ - this.maxSize = -1; - - /** - * The cursor position. - * - * @name Phaser.GameObjects.Container#position - * @type {integer} - * @since 3.4.0 - */ - this.position = 0; - - /** - * Internal Transform Matrix used for local space conversion. - * - * @name Phaser.GameObjects.Container#localTransform - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @since 3.4.0 - */ - this.localTransform = new Components.TransformMatrix(); - - /** - * Internal temporary Transform Matrix used to avoid object creation. - * - * @name Phaser.GameObjects.Container#tempTransformMatrix - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @private - * @since 3.4.0 - */ - this.tempTransformMatrix = new Components.TransformMatrix(); - - /** - * A reference to the Scene Display List. - * - * @name Phaser.GameObjects.Container#_displayList - * @type {Phaser.GameObjects.DisplayList} - * @private - * @since 3.4.0 - */ - this._displayList = scene.sys.displayList; - - /** - * The property key to sort by. - * - * @name Phaser.GameObjects.Container#_sortKey - * @type {string} - * @private - * @since 3.4.0 - */ - this._sortKey = ''; - - /** - * A reference to the Scene Systems Event Emitter. - * - * @name Phaser.GameObjects.Container#_sysEvents - * @type {Phaser.Events.EventEmitter} - * @private - * @since 3.9.0 - */ - this._sysEvents = scene.sys.events; - - this.setPosition(x, y); - - this.clearAlpha(); - - if (children) - { - this.add(children); - } - }, - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - * - * @name Phaser.GameObjects.Container#originX - * @type {number} - * @readOnly - * @since 3.4.0 - */ - originX: { - - get: function () - { - return 0.5; - } - - }, - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - * - * @name Phaser.GameObjects.Container#originY - * @type {number} - * @readOnly - * @since 3.4.0 - */ - originY: { - - get: function () - { - return 0.5; - } - - }, - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - * - * @name Phaser.GameObjects.Container#displayOriginX - * @type {number} - * @readOnly - * @since 3.4.0 - */ - displayOriginX: { - - get: function () - { - return this.width * 0.5; - } - - }, - - /** - * Internal value to allow Containers to be used for input and physics. - * Do not change this value. It has no effect other than to break things. - * - * @name Phaser.GameObjects.Container#displayOriginY - * @type {number} - * @readOnly - * @since 3.4.0 - */ - displayOriginY: { - - get: function () - { - return this.height * 0.5; - } - - }, - - /** - * Does this Container exclusively manage its children? - * - * The default is `true` which means a child added to this Container cannot - * belong in another Container, which includes the Scene display list. - * - * If you disable this then this Container will no longer exclusively manage its children. - * This allows you to create all kinds of interesting graphical effects, such as replicating - * Game Objects without reparenting them all over the Scene. - * However, doing so will prevent children from receiving any kind of input event or have - * their physics bodies work by default, as they're no longer a single entity on the - * display list, but are being replicated where-ever this Container is. - * - * @method Phaser.GameObjects.Container#setExclusive - * @since 3.4.0 - * - * @param {boolean} [value=true] - The exclusive state of this Container. - * - * @return {Phaser.GameObjects.Container} This Container. - */ - setExclusive: function (value) - { - if (value === undefined) { value = true; } - - this.exclusive = value; - - return this; - }, - - /** - * Gets the bounds of this Container. It works by iterating all children of the Container, - * getting their respective bounds, and then working out a min-max rectangle from that. - * It does not factor in if the children render or not, all are included. - * - * Some children are unable to return their bounds, such as Graphics objects, in which case - * they are skipped. - * - * Depending on the quantity of children in this Container it could be a really expensive call, - * so cache it and only poll it as needed. - * - * The values are stored and returned in a Rectangle object. - * - * @method Phaser.GameObjects.Container#getBounds - * @since 3.4.0 - * - * @param {Phaser.Geom.Rectangle} [output] - A Geom.Rectangle object to store the values in. If not provided a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle} The values stored in the output object. - */ - getBounds: function (output) - { - if (output === undefined) { output = new Rectangle(); } - - output.setTo(this.x, this.y, 0, 0); - - if (this.list.length > 0) - { - var children = this.list; - var tempRect = new Rectangle(); - - for (var i = 0; i < children.length; i++) - { - var entry = children[i]; - - if (entry.getBounds) - { - entry.getBounds(tempRect); - - Union(tempRect, output, output); - } - } - } - - return output; - }, - - /** - * Internal add handler. - * - * @method Phaser.GameObjects.Container#addHandler - * @private - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just added to this Container. - */ - addHandler: function (gameObject) - { - gameObject.once('destroy', this.remove, this); - - if (this.exclusive) - { - this._displayList.remove(gameObject); - - if (gameObject.parentContainer) - { - gameObject.parentContainer.remove(gameObject); - } - - gameObject.parentContainer = this; - } - - // Game Objects automatically listen to the Scene shutdown event, but - // we don't need this if they're in a Container - this._sysEvents.off('shutdown', gameObject.destroy, gameObject); - }, - - /** - * Internal remove handler. - * - * @method Phaser.GameObjects.Container#removeHandler - * @private - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that was just removed from this Container. - */ - removeHandler: function (gameObject) - { - gameObject.off('destroy', this.remove); - - if (this.exclusive) - { - gameObject.parentContainer = null; - - this._sysEvents.once('shutdown', gameObject.destroy, gameObject); - } - }, - - /** - * Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties, - * and transforms it into the space of this Container, then returns it in the output object. - * - * @method Phaser.GameObjects.Container#pointToContainer - * @since 3.4.0 - * - * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} source - The Source Point to be transformed. - * @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} [output] - A destination object to store the transformed point in. If none given a Vector2 will be created and returned. - * - * @return {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} The transformed point. - */ - pointToContainer: function (source, output) - { - if (output === undefined) { output = new Vector2(); } - - if (this.parentContainer) - { - return this.parentContainer.pointToContainer(source, output); - } - - var tempMatrix = this.tempTransformMatrix; - - // No need to loadIdentity because applyITRS overwrites every value anyway - tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY); - - tempMatrix.invert(); - - tempMatrix.transformPoint(source.x, source.y, output); - - return output; - }, - - /** - * Returns the world transform matrix as used for Bounds checks. - * The returned matrix is temporal and shouldn't be stored. - * - * @method Phaser.GameObjects.Container#getBoundsTransformMatrix - * @since 3.4.0 - * - * @return {Phaser.GameObjects.Components.TransformMatrix} The world transform matrix. - */ - getBoundsTransformMatrix: function () - { - return this.getWorldTransformMatrix(this.tempTransformMatrix); - }, - - /** - * Adds the given Game Object, or array of Game Objects, to this Container. - * - * Each Game Object must be unique within the Container. - * - * @method Phaser.GameObjects.Container#add - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - add: function (child) - { - ArrayUtils.Add(this.list, child, this.maxSize, this.addHandler, this); - - return this; - }, - - /** - * Adds the given Game Object, or array of Game Objects, to this Container at the specified position. - * - * Existing Game Objects in the Container are shifted up. - * - * Each Game Object must be unique within the Container. - * - * @method Phaser.GameObjects.Container#addAt - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to add to the Container. - * @param {integer} [index=0] - The position to insert the Game Object/s at. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - addAt: function (child, index) - { - ArrayUtils.AddAt(this.list, child, index, this.maxSize, this.addHandler, this); - - return this; - }, - - /** - * Returns the Game Object at the given position in this Container. - * - * @method Phaser.GameObjects.Container#getAt - * @since 3.4.0 - * - * @param {integer} index - The position to get the Game Object from. - * - * @return {?Phaser.GameObjects.GameObject} The Game Object at the specified index, or `null` if none found. - */ - getAt: function (index) - { - return this.list[index]; - }, - - /** - * Returns the index of the given Game Object in this Container. - * - * @method Phaser.GameObjects.Container#getIndex - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to search for in this Container. - * - * @return {integer} The index of the Game Object in this Container, or -1 if not found. - */ - getIndex: function (child) - { - return this.list.indexOf(child); - }, - - /** - * Sort the contents of this Container so the items are in order based on the given property. - * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. - * - * @method Phaser.GameObjects.Container#sort - * @since 3.4.0 - * - * @param {string} property - The property to lexically sort by. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - sort: function (property) - { - if (property) - { - this._sortKey = property; - - ArrayUtils.StableSort.inplace(this.list, this.sortHandler); - } - - return this; - }, - - /** - * Internal sort handler method. - * - * @method Phaser.GameObjects.Container#sortHandler - * @private - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} childA - The first child to sort. - * @param {Phaser.GameObjects.GameObject} childB - The second child to sort. - * - * @return {integer} The sort results. - */ - sortHandler: function (childA, childB) - { - return childA[this._sortKey] - childB[this._sortKey]; - }, - - /** - * Searches for the first instance of a child with its `name` property matching the given argument. - * Should more than one child have the same name only the first is returned. - * - * @method Phaser.GameObjects.Container#getByName - * @since 3.4.0 - * - * @param {string} name - The name to search for. - * - * @return {?Phaser.GameObjects.GameObject} The first child with a matching name, or `null` if none were found. - */ - getByName: function (name) - { - return ArrayUtils.GetFirst(this.list, 'name', name); - }, - - /** - * Returns a random Game Object from this Container. - * - * @method Phaser.GameObjects.Container#getRandom - * @since 3.4.0 - * - * @param {integer} [startIndex=0] - An optional start index. - * @param {integer} [length] - An optional length, the total number of elements (from the startIndex) to choose from. - * - * @return {?Phaser.GameObjects.GameObject} A random child from the Container, or `null` if the Container is empty. - */ - getRandom: function (startIndex, length) - { - return ArrayUtils.GetRandom(this.list, startIndex, length); - }, - - /** - * Gets the first Game Object in this Container. - * - * You can also specify a property and value to search for, in which case it will return the first - * Game Object in this Container with a matching property and / or value. - * - * For example: `getFirst('visible', true)` would return the first Game Object that had its `visible` property set. - * - * You can limit the search to the `startIndex` - `endIndex` range. - * - * @method Phaser.GameObjects.Container#getFirst - * @since 3.4.0 - * - * @param {string} [property] - The property to test on each Game Object in the Container. - * @param {*} [value] - The value to test the property against. Must pass a strict (`===`) comparison check. - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * - * @return {?Phaser.GameObjects.GameObject} The first matching Game Object, or `null` if none was found. - */ - getFirst: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); - }, - - /** - * Returns all Game Objects in this Container. - * - * You can optionally specify a matching criteria using the `property` and `value` arguments. - * - * For example: `getAll('body')` would return only Game Objects that have a body property. - * - * You can also specify a value to compare the property to: - * - * `getAll('visible', true)` would return only Game Objects that have their visible property set to `true`. - * - * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 Game Objects. - * - * @method Phaser.GameObjects.Container#getAll - * @since 3.4.0 - * - * @param {string} [property] - The property to test on each Game Object in the Container. - * @param {any} [value] - If property is set then the `property` must strictly equal this value to be included in the results. - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * - * @return {Phaser.GameObjects.GameObject[]} An array of matching Game Objects from this Container. - */ - getAll: function (property, value, startIndex, endIndex) - { - return ArrayUtils.GetAll(this.list, property, value, startIndex, endIndex); - }, - - /** - * Returns the total number of Game Objects in this Container that have a property - * matching the given value. - * - * For example: `count('visible', true)` would count all the elements that have their visible property set. - * - * You can optionally limit the operation to the `startIndex` - `endIndex` range. - * - * @method Phaser.GameObjects.Container#count - * @since 3.4.0 - * - * @param {string} property - The property to check. - * @param {any} value - The value to check. - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * - * @return {integer} The total number of Game Objects in this Container with a property matching the given value. - */ - count: function (property, value, startIndex, endIndex) - { - return ArrayUtils.CountAllMatching(this.list, property, value, startIndex, endIndex); - }, - - /** - * Swaps the position of two Game Objects in this Container. - * Both Game Objects must belong to this Container. - * - * @method Phaser.GameObjects.Container#swap - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child1 - The first Game Object to swap. - * @param {Phaser.GameObjects.GameObject} child2 - The second Game Object to swap. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - swap: function (child1, child2) - { - ArrayUtils.Swap(this.list, child1, child2); - - return this; - }, - - /** - * Moves a Game Object to a new position within this Container. - * - * The Game Object must already be a child of this Container. - * - * The Game Object is removed from its old position and inserted into the new one. - * Therefore the Container size does not change. Other children will change position accordingly. - * - * @method Phaser.GameObjects.Container#moveTo - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to move. - * @param {integer} index - The new position of the Game Object in this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - moveTo: function (child, index) - { - ArrayUtils.MoveTo(this.list, child, index); - - return this; - }, - - /** - * Removes the given Game Object, or array of Game Objects, from this Container. - * - * The Game Objects must already be children of this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * - * @method Phaser.GameObjects.Container#remove - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Object, or array of Game Objects, to be removed from the Container. - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each child successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - remove: function (child, destroyChild) - { - var removed = ArrayUtils.Remove(this.list, child, this.removeHandler, this); - - if (destroyChild && removed) - { - if (!Array.isArray(removed)) - { - removed = [ removed ]; - } - - for (var i = 0; i < removed.length; i++) - { - removed[i].destroy(); - } - } - - return this; - }, - - /** - * Removes the Game Object at the given position in this Container. - * - * You can also optionally call `destroy` on the Game Object, if one is found. - * - * @method Phaser.GameObjects.Container#removeAt - * @since 3.4.0 - * - * @param {integer} index - The index of the Game Object to be removed. - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - removeAt: function (index, destroyChild) - { - var removed = ArrayUtils.RemoveAt(this.list, index, this.removeHandler, this); - - if (destroyChild && removed) - { - removed.destroy(); - } - - return this; - }, - - /** - * Removes the Game Objects between the given positions in this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * - * @method Phaser.GameObjects.Container#removeBetween - * @since 3.4.0 - * - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - removeBetween: function (startIndex, endIndex, destroyChild) - { - var removed = ArrayUtils.RemoveBetween(this.list, startIndex, endIndex, this.removeHandler, this); - - if (destroyChild) - { - for (var i = 0; i < removed.length; i++) - { - removed[i].destroy(); - } - } - - return this; - }, - - /** - * Removes all Game Objects from this Container. - * - * You can also optionally call `destroy` on each Game Object that is removed from the Container. - * - * @method Phaser.GameObjects.Container#removeAll - * @since 3.4.0 - * - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on each Game Object successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - removeAll: function (destroyChild) - { - var removed = ArrayUtils.RemoveBetween(this.list, 0, this.list.length, this.removeHandler, this); - - if (destroyChild) - { - for (var i = 0; i < removed.length; i++) - { - removed[i].destroy(); - } - } - - return this; - }, - - /** - * Brings the given Game Object to the top of this Container. - * This will cause it to render on-top of any other objects in the Container. - * - * @method Phaser.GameObjects.Container#bringToTop - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to bring to the top of the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - bringToTop: function (child) - { - ArrayUtils.BringToTop(this.list, child); - - return this; - }, - - /** - * Sends the given Game Object to the bottom of this Container. - * This will cause it to render below any other objects in the Container. - * - * @method Phaser.GameObjects.Container#sendToBack - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to send to the bottom of the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - sendToBack: function (child) - { - ArrayUtils.SendToBack(this.list, child); - - return this; - }, - - /** - * Moves the given Game Object up one place in this Container, unless it's already at the top. - * - * @method Phaser.GameObjects.Container#moveUp - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - moveUp: function (child) - { - ArrayUtils.MoveUp(this.list, child); - - return this; - }, - - /** - * Moves the given Game Object down one place in this Container, unless it's already at the bottom. - * - * @method Phaser.GameObjects.Container#moveDown - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to be moved in the Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - moveDown: function (child) - { - ArrayUtils.MoveDown(this.list, child); - - return this; - }, - - /** - * Reverses the order of all Game Objects in this Container. - * - * @method Phaser.GameObjects.Container#reverse - * @since 3.4.0 - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - reverse: function () - { - this.list.reverse(); - - return this; - }, - - /** - * Shuffles the all Game Objects in this Container using the Fisher-Yates implementation. - * - * @method Phaser.GameObjects.Container#shuffle - * @since 3.4.0 - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - shuffle: function () - { - ArrayUtils.Shuffle(this.list); - - return this; - }, - - /** - * Replaces a Game Object in this Container with the new Game Object. - * The new Game Object cannot already be a child of this Container. - * - * @method Phaser.GameObjects.Container#replace - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} oldChild - The Game Object in this Container that will be replaced. - * @param {Phaser.GameObjects.GameObject} newChild - The Game Object to be added to this Container. - * @param {boolean} [destroyChild=false] - Optionally call `destroy` on the Game Object if successfully removed from this Container. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - replace: function (oldChild, newChild, destroyChild) - { - var moved = ArrayUtils.Replace(this.list, oldChild, newChild); - - if (moved) - { - this.addHandler(newChild); - this.removeHandler(oldChild); - - if (destroyChild) - { - oldChild.destroy(); - } - } - - return this; - }, - - /** - * Returns `true` if the given Game Object is a direct child of this Container. - * - * This check does not scan nested Containers. - * - * @method Phaser.GameObjects.Container#exists - * @since 3.4.0 - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object to check for within this Container. - * - * @return {boolean} True if the Game Object is an immediate child of this Container, otherwise false. - */ - exists: function (child) - { - return (this.list.indexOf(child) > -1); - }, - - /** - * Sets the property to the given value on all Game Objects in this Container. - * - * Optionally you can specify a start and end index. For example if this Container had 100 Game Objects, - * and you set `startIndex` to 0 and `endIndex` to 50, it would return matches from only - * the first 50 Game Objects. - * - * @method Phaser.GameObjects.Container#setAll - * @since 3.4.0 - * - * @param {string} property - The property that must exist on the Game Object. - * @param {any} value - The value to get the property to. - * @param {integer} [startIndex=0] - An optional start index to search from. - * @param {integer} [endIndex=Container.length] - An optional end index to search up to (but not included) - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - setAll: function (property, value, startIndex, endIndex) - { - ArrayUtils.SetAll(this.list, property, value, startIndex, endIndex); - - return this; - }, - - /** - * @callback EachContainerCallback - * @generic I - [item] - * - * @param {*} item - [description] - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - */ - - /** - * Passes all Game Objects in this Container to the given callback. - * - * A copy of the Container is made before passing each entry to your callback. - * This protects against the callback itself modifying the Container. - * - * If you know for sure that the callback will not change the size of this Container - * then you can use the more performant `Container.iterate` method instead. - * - * @method Phaser.GameObjects.Container#each - * @since 3.4.0 - * - * @param {function} callback - The function to call. - * @param {object} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - each: function (callback, context) - { - var args = [ null ]; - var i; - var temp = this.list.slice(); - var len = temp.length; - - for (i = 2; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = 0; i < len; i++) - { - args[0] = temp[i]; - - callback.apply(context, args); - } - - return this; - }, - - /** - * Passes all Game Objects in this Container to the given callback. - * - * Only use this method when you absolutely know that the Container will not be modified during - * the iteration, i.e. by removing or adding to its contents. - * - * @method Phaser.GameObjects.Container#iterate - * @since 3.4.0 - * - * @param {function} callback - The function to call. - * @param {object} [context] - Value to use as `this` when executing callback. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. - * - * @return {Phaser.GameObjects.Container} This Container instance. - */ - iterate: function (callback, context) - { - var args = [ null ]; - var i; - - for (i = 2; i < arguments.length; i++) - { - args.push(arguments[i]); - } - - for (i = 0; i < this.list.length; i++) - { - args[0] = this.list[i]; - - callback.apply(context, args); - } - - return this; - }, - - /** - * The number of Game Objects inside this Container. - * - * @name Phaser.GameObjects.Container#length - * @type {integer} - * @readOnly - * @since 3.4.0 - */ - length: { - - get: function () - { - return this.list.length; - } - - }, - - /** - * Returns the first Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - * - * @name Phaser.GameObjects.Container#first - * @type {?Phaser.GameObjects.GameObject} - * @readOnly - * @since 3.4.0 - */ - first: { - - get: function () - { - this.position = 0; - - if (this.list.length > 0) - { - return this.list[0]; - } - else - { - return null; - } - } - - }, - - /** - * Returns the last Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - * - * @name Phaser.GameObjects.Container#last - * @type {?Phaser.GameObjects.GameObject} - * @readOnly - * @since 3.4.0 - */ - last: { - - get: function () - { - if (this.list.length > 0) - { - this.position = this.list.length - 1; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * Returns the next Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - * - * @name Phaser.GameObjects.Container#next - * @type {?Phaser.GameObjects.GameObject} - * @readOnly - * @since 3.4.0 - */ - next: { - - get: function () - { - if (this.position < this.list.length) - { - this.position++; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * Returns the previous Game Object within the Container, or `null` if it is empty. - * - * You can move the cursor by calling `Container.next` and `Container.previous`. - * - * @name Phaser.GameObjects.Container#previous - * @type {?Phaser.GameObjects.GameObject} - * @readOnly - * @since 3.4.0 - */ - previous: { - - get: function () - { - if (this.position > 0) - { - this.position--; - - return this.list[this.position]; - } - else - { - return null; - } - } - - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.Container#preDestroy - * @protected - * @since 3.9.0 - */ - preDestroy: function () - { - this.removeAll(!!this.exclusive); - - this.localTransform.destroy(); - this.tempTransformMatrix.destroy(); - - this.list = []; - this._displayList = null; - } - -}); - -module.exports = Container; - - -/***/ }), -/* 252 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlitterRender = __webpack_require__(910); -var Bob = __webpack_require__(907); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var Frame = __webpack_require__(128); -var GameObject = __webpack_require__(2); -var List = __webpack_require__(93); - -/** - * @callback Phaser.GameObjects.Blitter.CreateCallback - * - * @param {Phaser.GameObjects.Blitter.Bob} bob - The Bob that was created by the Blitter. - * @param {integer} index - The position of the Bob within the Blitter display list. - */ - -/** - * @classdesc - * A Blitter Game Object. - * - * The Blitter Game Object is a special kind of container that creates, updates and manages Bob objects. - * Bobs are designed for rendering speed rather than flexibility. They consist of a texture, or frame from a texture, - * a position and an alpha value. You cannot scale or rotate them. They use a batched drawing method for speed - * during rendering. - * - * A Blitter Game Object has one texture bound to it. Bobs created by the Blitter can use any Frame from this - * Texture to render with, but they cannot use any other Texture. It is this single texture-bind that allows - * them their speed. - * - * If you have a need to blast a large volume of frames around the screen then Blitter objects are well worth - * investigating. They are especially useful for using as a base for your own special effects systems. - * - * @class Blitter - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} [x=0] - The x coordinate of this Game Object in world space. - * @param {number} [y=0] - The y coordinate of this Game Object in world space. - * @param {string} [texture='__DEFAULT'] - The key of the texture this Game Object will use for rendering. The Texture must already exist in the Texture Manager. - * @param {(string|integer)} [frame=0] - The Frame of the Texture that this Game Object will use. Only set if the Texture has multiple frames, such as a Texture Atlas or Sprite Sheet. - */ -var Blitter = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Size, - Components.Texture, - Components.Transform, - Components.Visible, - BlitterRender - ], - - initialize: - - function Blitter (scene, x, y, texture, frame) - { - GameObject.call(this, scene, 'Blitter'); - - this.setTexture(texture, frame); - this.setPosition(x, y); - this.initPipeline('TextureTintPipeline'); - - /** - * The children of this Blitter. - * This List contains all of the Bob objects created by the Blitter. - * - * @name Phaser.GameObjects.Blitter#children - * @type {Phaser.Structs.List.} - * @since 3.0.0 - */ - this.children = new List(); - - /** - * A transient array that holds all of the Bobs that will be rendered this frame. - * The array is re-populated whenever the dirty flag is set. - * - * @name Phaser.GameObjects.Blitter#renderList - * @type {Phaser.GameObjects.Blitter.Bob[]} - * @default [] - * @private - * @since 3.0.0 - */ - this.renderList = []; - - /** - * Is the Blitter considered dirty? - * A 'dirty' Blitter has had its child count changed since the last frame. - * - * @name Phaser.GameObjects.Blitter#dirty - * @type {boolean} - * @since 3.0.0 - */ - this.dirty = false; - }, - - /** - * Creates a new Bob in this Blitter. - * - * The Bob is created at the given coordinates, relative to the Blitter and uses the given frame. - * A Bob can use any frame belonging to the texture bound to the Blitter. - * - * @method Phaser.GameObjects.Blitter#create - * @since 3.0.0 - * - * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - * @param {boolean} [visible=true] - Should the created Bob render or not? - * @param {integer} [index] - The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. - * - * @return {Phaser.GameObjects.Blitter.Bob} The newly created Bob object. - */ - create: function (x, y, frame, visible, index) - { - if (visible === undefined) { visible = true; } - if (index === undefined) { index = this.children.length; } - - if (frame === undefined) - { - frame = this.frame; - } - else if (!(frame instanceof Frame)) - { - frame = this.texture.get(frame); - } - - var bob = new Bob(this, x, y, frame, visible); - - this.children.addAt(bob, index, false); - - this.dirty = true; - - return bob; - }, - - /** - * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. - * - * @method Phaser.GameObjects.Blitter#createFromCallback - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter.CreateCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob. - * @param {integer} quantity - The quantity of Bob objects to create. - * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param {boolean} [visible=true] - Should the created Bob render or not? - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. - */ - createFromCallback: function (callback, quantity, frame, visible) - { - var bobs = this.createMultiple(quantity, frame, visible); - - for (var i = 0; i < bobs.length; i++) - { - var bob = bobs[i]; - - callback.call(this, bob, i); - } - - return bobs; - }, - - /** - * Creates multiple Bobs in one call. - * - * The amount created is controlled by a combination of the `quantity` argument and the number of frames provided. - * - * If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first - * frame and 10 with the second. - * - * @method Phaser.GameObjects.Blitter#createMultiple - * @since 3.0.0 - * - * @param {integer} quantity - The quantity of Bob objects to create. - * @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture. - * @param {boolean} [visible=true] - Should the created Bob render or not? - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created. - */ - createMultiple: function (quantity, frame, visible) - { - if (frame === undefined) { frame = this.frame.name; } - if (visible === undefined) { visible = true; } - - if (!Array.isArray(frame)) - { - frame = [ frame ]; - } - - var bobs = []; - var _this = this; - - frame.forEach(function (singleFrame) - { - for (var i = 0; i < quantity; i++) - { - bobs.push(_this.create(0, 0, singleFrame, visible)); - } - }); - - return bobs; - }, - - /** - * Checks if the given child can render or not, by checking its `visible` and `alpha` values. - * - * @method Phaser.GameObjects.Blitter#childCanRender - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter.Bob} child - The Bob to check for rendering. - * - * @return {boolean} Returns `true` if the given child can render, otherwise `false`. - */ - childCanRender: function (child) - { - return (child.visible && child.alpha > 0); - }, - - /** - * Returns an array of Bobs to be rendered. - * If the Blitter is dirty then a new list is generated and stored in `renderList`. - * - * @method Phaser.GameObjects.Blitter#getRenderList - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that will be rendered this frame. - */ - getRenderList: function () - { - if (this.dirty) - { - this.renderList = this.children.list.filter(this.childCanRender, this); - this.dirty = false; - } - - return this.renderList; - }, - - /** - * Removes all Bobs from the children List and clears the dirty flag. - * - * @method Phaser.GameObjects.Blitter#clear - * @since 3.0.0 - */ - clear: function () - { - this.children.removeAll(); - this.dirty = true; - }, - - /** - * Internal destroy handler, called as part of the destroy process. - * - * @method Phaser.GameObjects.Blitter#preDestroy - * @protected - * @since 3.9.0 - */ - preDestroy: function () - { - this.children.destroy(); - - this.renderList = []; - } - -}); - -module.exports = Blitter; - - -/***/ }), -/* 253 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var GameObject = __webpack_require__(2); -var GetBitmapTextSize = __webpack_require__(475); -var ParseFromAtlas = __webpack_require__(914); -var Render = __webpack_require__(913); - -/** - * The font data for an individual character of a Bitmap Font. - * - * Describes the character's position, size, offset and kerning. - * - * @typedef {object} BitmapFontCharacterData - * - * @property {number} x - The x position of the character. - * @property {number} y - The y position of the character. - * @property {number} width - The width of the character. - * @property {number} height - The height of the character. - * @property {number} centerX - The center x position of the character. - * @property {number} centerY - The center y position of the character. - * @property {number} xOffset - The x offset of the character. - * @property {number} yOffset - The y offset of the character. - * @property {object} data - Extra data for the character. - * @property {Object.} kerning - Kerning values, keyed by character code. - */ - -/** - * Bitmap Font data that can be used by a BitmapText Game Object. - * - * @typedef {object} BitmapFontData - * - * @property {string} font - The name of the font. - * @property {number} size - The size of the font. - * @property {number} lineHeight - The line height of the font. - * @property {boolean} retroFont - Whether this font is a retro font (monospace). - * @property {Object.} chars - The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more. - */ - -/** - * @typedef {object} JSONBitmapText - * @extends {JSONGameObject} - * - * @property {string} font - The name of the font. - * @property {string} text - The text that this Bitmap Text displays. - * @property {number} fontSize - The size of the font. - * @property {number} letterSpacing - Adds/Removes spacing between characters - */ - -/** - * @classdesc - * [description] - * - * @class BitmapText - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. - * @param {number} x - The x coordinate of this Game Object in world space. - * @param {number} y - The y coordinate of this Game Object in world space. - * @param {string} font - The key of the font to use from the Bitmap Font cache. - * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @param {number} [size] - The font size of this Bitmap Text. - */ -var BitmapText = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.ScrollFactor, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, - Render - ], - - initialize: - - function BitmapText (scene, x, y, font, text, size) - { - if (text === undefined) { text = ''; } - - GameObject.call(this, scene, 'BitmapText'); - - /** - * The key of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#font - * @type {string} - * @since 3.0.0 - */ - this.font = font; - - var entry = this.scene.sys.cache.bitmapFont.get(font); - - /** - * The data of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#fontData - * @type {BitmapFontData} - * @since 3.0.0 - */ - this.fontData = entry.data; - - /** - * The text that this Bitmap Text object displays. - * - * @name Phaser.GameObjects.BitmapText#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * The font size of this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#fontSize - * @type {number} - * @since 3.0.0 - */ - this.fontSize = size || this.fontData.size; - - /** - * Adds/Removes spacing between characters. - * - * Can be a negative or positive number. - * - * @name Phaser.GameObjects.BitmapText#letterSpacing - * @type {number} - * @since 3.4.0 - */ - this.letterSpacing = 0; - - this.setText(text); - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * An object that describes the size of this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#_bounds - * @type {BitmapTextSize} - * @private - * @since 3.0.0 - */ - this._bounds = this.getTextBounds(); - }, - - /** - * Set the font size of this Bitmap Text. - * - * @method Phaser.GameObjects.BitmapText#setFontSize - * @since 3.0.0 - * - * @param {number} size - The font size to set. - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setFontSize: function (size) - { - this.fontSize = size; - - return this; - }, - - /** - * Sets the letter spacing between each character of this Bitmap Text. - * Can be a positive value to increase the space, or negative to reduce it. - * Spacing is applied after the kerning values have been set. - * - * @method Phaser.GameObjects.BitmapText#setLetterSpacing - * @since 3.4.0 - * - * @param {number} [spacing=0] - The amount of horizontal space to add between each character. - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setLetterSpacing: function (spacing) - { - if (spacing === undefined) { spacing = 0; } - - this.letterSpacing = spacing; - - return this; - }, - - /** - * Set the content of this BitmapText. - * - * An array of strings will be converted multi-line text. - * - * @method Phaser.GameObjects.BitmapText#setText - * @since 3.0.0 - * - * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. - * - * @return {Phaser.GameObjects.BitmapText} This Game Object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateDisplayOrigin(); - } - - return this; - }, - - /** - * Calculate the bounds of this Bitmap Text. - * - * An object is returned that contains the position, width and height of the Bitmap Text in local and global - * contexts. - * - * Local size is based on just the font size and a [0, 0] position. - * - * Global size takes into account the Game Object's scale and world position. - * - * @method Phaser.GameObjects.BitmapText#getTextBounds - * @since 3.0.0 - * - * @param {boolean} [round] - Whether to round the results to the nearest integer. - * - * @return {BitmapTextSize} An object that describes the size of this Bitmap Text. - */ - getTextBounds: function (round) - { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position - - this._bounds = GetBitmapTextSize(this, round); - - return this._bounds; - }, - - /** - * The width of this Bitmap Text. - * - * @name Phaser.GameObjects.BitmapText#width - * @type {number} - * @readOnly - * @since 3.0.0 - */ - width: { - - get: function () - { - this.getTextBounds(false); - - return this._bounds.global.width; - } - - }, - - /** - * The height of this bitmap text. - * - * @name Phaser.GameObjects.BitmapText#height - * @type {number} - * @readOnly - * @since 3.0.0 - */ - height: { - - get: function () - { - this.getTextBounds(false); - - return this._bounds.global.height; - } - - }, - - /** - * Build a JSON representation of this Bitmap Text. - * - * @method Phaser.GameObjects.BitmapText#toJSON - * @since 3.0.0 - * - * @return {JSONBitmapText} The JSON representation of this Bitmap Text. - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra data is added here - - var data = { - font: this.font, - text: this.text, - fontSize: this.fontSize, - letterSpacing: this.letterSpacing - }; - - out.data = data; - - return out; - } - -}); - -BitmapText.ParseFromAtlas = ParseFromAtlas; - -module.exports = BitmapText; - - -/***/ }), -/* 254 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); -var Shuffle = __webpack_require__(95); - -var BuildChunk = function (a, b, qty) -{ - var out = []; - - for (var aIndex = 0; aIndex < a.length; aIndex++) - { - for (var bIndex = 0; bIndex < b.length; bIndex++) - { - for (var i = 0; i < qty; i++) - { - out.push({ a: a[aIndex], b: b[bIndex] }); - } - } - } - - return out; -}; - -// options = repeat, random, randomB, yoyo, max, qty - -// Range ([a,b,c], [1,2,3]) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2,3], qty = 3) = -// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 - -// Range ([a,b,c], [1,2,3], repeat x1) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = -// Maybe if max is set then repeat goes to -1 automatically? -// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) - -// Range ([a], [1,2,3,4,5], random = true) = -// a4, a1, a5, a2, a3 - -// Range ([a, b], [1,2,3], random = true) = -// b3, a2, a1, b1, a3, b2 - -// Range ([a, b, c], [1,2,3], randomB = true) = -// a3, a1, a2, b2, b3, b1, c1, c3, c2 - -// Range ([a], [1,2,3,4,5], yoyo = true) = -// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 - -// Range ([a, b], [1,2,3], yoyo = true) = -// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 - -/** - * [description] - * - * @function Phaser.Utils.Array.Range - * @since 3.0.0 - * - * @param {array} a - [description] - * @param {array} b - [description] - * @param {object} options - [description] - * - * @return {array} [description] - */ -var Range = function (a, b, options) -{ - var max = GetValue(options, 'max', 0); - var qty = GetValue(options, 'qty', 1); - var random = GetValue(options, 'random', false); - var randomB = GetValue(options, 'randomB', false); - var repeat = GetValue(options, 'repeat', 0); - var yoyo = GetValue(options, 'yoyo', false); - - var out = []; - - if (randomB) - { - Shuffle(b); - } - - // Endless repeat, so limit by max - if (repeat === -1) - { - if (max === 0) - { - repeat = 0; - } - else - { - // Work out how many repeats we need - var total = (a.length * b.length) * qty; - - if (yoyo) - { - total *= 2; - } - - repeat = Math.ceil(max / total); - } - } - - for (var i = 0; i <= repeat; i++) - { - var chunk = BuildChunk(a, b, qty); - - if (random) - { - Shuffle(chunk); - } - - out = out.concat(chunk); - - if (yoyo) - { - chunk.reverse(); - - out = out.concat(chunk); - } - } - - if (max) - { - out.splice(max); - } - - return out; -}; - -module.exports = Range; - - -/***/ }), -/* 255 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Round a given number so it is further away from zero. That is, positive numbers are rounded up, and negative numbers are rounded down. - * - * @function Phaser.Math.RoundAwayFromZero - * @since 3.0.0 - * - * @param {number} value - The number to round. - * - * @return {number} The rounded number, rounded away from zero. - */ -var RoundAwayFromZero = function (value) -{ - // "Opposite" of truncate. - return (value > 0) ? Math.ceil(value) : Math.floor(value); -}; - -module.exports = RoundAwayFromZero; - - -/***/ }), -/* 256 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Capitalizes the first letter of a string if there is one. - * @example - * UppercaseFirst('abc'); - * // returns 'Abc' - * @example - * UppercaseFirst('the happy family'); - * // returns 'The happy family' - * @example - * UppercaseFirst(''); - * // returns '' - * - * @function Phaser.Utils.String.UppercaseFirst - * @since 3.0.0 - * - * @param {string} str - The string to capitalize. - * - * @return {string} A new string, same as the first, but with the first letter capitalized. - */ -var UppercaseFirst = function (str) -{ - return str && str[0].toUpperCase() + str.slice(1); -}; - -module.exports = UppercaseFirst; - - -/***/ }), -/* 257 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Vector2 = __webpack_require__(6); - -/** - * Takes the `x` and `y` coordinates and transforms them into the same space as - * defined by the position, rotation and scale values. - * - * @function Phaser.Math.TransformXY - * @since 3.0.0 - * - * @param {number} x - The x coordinate to be transformed. - * @param {number} y - The y coordinate to be transformed. - * @param {number} positionX - Horizontal position of the transform point. - * @param {number} positionY - Vertical position of the transform point. - * @param {number} rotation - Rotation of the transform point, in radians. - * @param {number} scaleX - Horizontal scale of the transform point. - * @param {number} scaleY - Vertical scale of the transform point. - * @param {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} [output] - The output vector, point or object for the translated coordinates. - * - * @return {(Phaser.Math.Vector2|Phaser.Geom.Point|object)} The translated point. - */ -var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY, output) -{ - if (output === undefined) { output = new Vector2(); } - - // ITRS - - var sr = Math.sin(-rotation); - var cr = Math.cos(-rotation); - - var a = cr * scaleX; - var b = -sr * scaleX; - var c = sr * scaleY; - var d = cr * scaleY; - - // Invert - - var n = a * d - b * c; - - var m0 = d / n; - var m1 = -b / n; - var m2 = -c / n; - var m3 = a / n; - var m4 = (c * positionY - d * positionX) / n; - var m5 = -(a * positionY - b * positionX) / n; - - // Transform - - output.x = x * m0 + y * m2 + m4; - output.y = x * m1 + y * m3 + m5; - - return output; -}; - -module.exports = TransformXY; - - -/***/ }), -/* 258 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// 2.1.1 (Mar 17, 2016) - -/* -ISC License - -Copyright (c) 2016, Mapbox - -Permission to use, copy, modify, and/or distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright notice -and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - */ - - - -module.exports = earcut; - -/* -vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. -holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). -dimensions is the number of coordinates per vertice in the input array (2 by default). -Each group of three vertice indices in the resulting array forms a triangle. - */ - -function earcut(data, holeIndices, dim) { - - dim = dim || 2; - - var hasHoles = holeIndices && holeIndices.length, - outerLen = hasHoles ? holeIndices[0] * dim : data.length, - outerNode = linkedList(data, 0, outerLen, dim, true), - triangles = []; - - if (!outerNode) return triangles; - - var minX, minY, maxX, maxY, x, y, size; - - if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); - - // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox - if (data.length > 80 * dim) { - minX = maxX = data[0]; - minY = maxY = data[1]; - - for (var i = dim; i < outerLen; i += dim) { - x = data[i]; - y = data[i + 1]; - if (x < minX) minX = x; - if (y < minY) minY = y; - if (x > maxX) maxX = x; - if (y > maxY) maxY = y; - } - - // minX, minY and size are later used to transform coords into integers for z-order calculation - size = Math.max(maxX - minX, maxY - minY); - } - - earcutLinked(outerNode, triangles, dim, minX, minY, size); - - return triangles; -} - -// create a circular doubly linked list from polygon points in the specified winding order -function linkedList(data, start, end, dim, clockwise) { - var i, last; - - if (clockwise === (signedArea(data, start, end, dim) > 0)) { - for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last); - } else { - for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last); - } - - if (last && equals(last, last.next)) { - removeNode(last); - last = last.next; - } - - return last; -} - -// eliminate colinear or duplicate points -function filterPoints(start, end) { - if (!start) return start; - if (!end) end = start; - - var p = start, - again; - do { - again = false; - - if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { - removeNode(p); - p = end = p.prev; - if (p === p.next) return null; - again = true; - - } else { - p = p.next; - } - } while (again || p !== end); - - return end; -} - -// main ear slicing loop which triangulates a polygon (given as a linked list) -function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { - if (!ear) return; - - // interlink polygon nodes in z-order - if (!pass && size) indexCurve(ear, minX, minY, size); - - var stop = ear, - prev, next; - - // iterate through ears, slicing them one by one - while (ear.prev !== ear.next) { - prev = ear.prev; - next = ear.next; - - if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { - // cut off the triangle - triangles.push(prev.i / dim); - triangles.push(ear.i / dim); - triangles.push(next.i / dim); - - removeNode(ear); - - // skipping the next vertice leads to less sliver triangles - ear = next.next; - stop = next.next; - - continue; - } - - ear = next; - - // if we looped through the whole remaining polygon and can't find any more ears - if (ear === stop) { - // try filtering points and slicing again - if (!pass) { - earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); - - // if this didn't work, try curing all small self-intersections locally - } else if (pass === 1) { - ear = cureLocalIntersections(ear, triangles, dim); - earcutLinked(ear, triangles, dim, minX, minY, size, 2); - - // as a last resort, try splitting the remaining polygon into two - } else if (pass === 2) { - splitEarcut(ear, triangles, dim, minX, minY, size); - } - - break; - } - } -} - -// check whether a polygon node forms a valid ear with adjacent nodes -function isEar(ear) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // now make sure we don't have other points inside the potential ear - var p = ear.next.next; - - while (p !== ear.prev) { - if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.next; - } - - return true; -} - -function isEarHashed(ear, minX, minY, size) { - var a = ear.prev, - b = ear, - c = ear.next; - - if (area(a, b, c) >= 0) return false; // reflex, can't be an ear - - // triangle bbox; min & max are calculated like this for speed - var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x), - minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y), - maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x), - maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); - - // z-order range for the current triangle bbox; - var minZ = zOrder(minTX, minTY, minX, minY, size), - maxZ = zOrder(maxTX, maxTY, minX, minY, size); - - // first look for points inside the triangle in increasing z-order - var p = ear.nextZ; - - while (p && p.z <= maxZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.nextZ; - } - - // then look for points in decreasing z-order - p = ear.prevZ; - - while (p && p.z >= minZ) { - if (p !== ear.prev && p !== ear.next && - pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && - area(p.prev, p, p.next) >= 0) return false; - p = p.prevZ; - } - - return true; -} - -// go through all polygon nodes and cure small local self-intersections -function cureLocalIntersections(start, triangles, dim) { - var p = start; - do { - var a = p.prev, - b = p.next.next; - - if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) { - - triangles.push(a.i / dim); - triangles.push(p.i / dim); - triangles.push(b.i / dim); - - // remove two nodes involved - removeNode(p); - removeNode(p.next); - - p = start = b; - } - p = p.next; - } while (p !== start); - - return p; -} - -// try splitting polygon into two and triangulate them independently -function splitEarcut(start, triangles, dim, minX, minY, size) { - // look for a valid diagonal that divides the polygon into two - var a = start; - do { - var b = a.next.next; - while (b !== a.prev) { - if (a.i !== b.i && isValidDiagonal(a, b)) { - // split the polygon in two by the diagonal - var c = splitPolygon(a, b); - - // filter colinear points around the cuts - a = filterPoints(a, a.next); - c = filterPoints(c, c.next); - - // run earcut on each half - earcutLinked(a, triangles, dim, minX, minY, size); - earcutLinked(c, triangles, dim, minX, minY, size); - return; - } - b = b.next; - } - a = a.next; - } while (a !== start); -} - -// link every hole into the outer loop, producing a single-ring polygon without holes -function eliminateHoles(data, holeIndices, outerNode, dim) { - var queue = [], - i, len, start, end, list; - - for (i = 0, len = holeIndices.length; i < len; i++) { - start = holeIndices[i] * dim; - end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - list = linkedList(data, start, end, dim, false); - if (list === list.next) list.steiner = true; - queue.push(getLeftmost(list)); - } - - queue.sort(compareX); - - // process holes from left to right - for (i = 0; i < queue.length; i++) { - eliminateHole(queue[i], outerNode); - outerNode = filterPoints(outerNode, outerNode.next); - } - - return outerNode; -} - -function compareX(a, b) { - return a.x - b.x; -} - -// find a bridge between vertices that connects hole with an outer ring and and link it -function eliminateHole(hole, outerNode) { - outerNode = findHoleBridge(hole, outerNode); - if (outerNode) { - var b = splitPolygon(outerNode, hole); - filterPoints(b, b.next); - } -} - -// David Eberly's algorithm for finding a bridge between hole and outer polygon -function findHoleBridge(hole, outerNode) { - var p = outerNode, - hx = hole.x, - hy = hole.y, - qx = -Infinity, - m; - - // find a segment intersected by a ray from the hole's leftmost point to the left; - // segment's endpoint with lesser x will be potential connection point - do { - if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) { - var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y); - if (x <= hx && x > qx) { - qx = x; - if (x === hx) { - if (hy === p.y) return p; - if (hy === p.next.y) return p.next; - } - m = p.x < p.next.x ? p : p.next; - } - } - p = p.next; - } while (p !== outerNode); - - if (!m) return null; - - if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint - - // look for points inside the triangle of hole point, segment intersection and endpoint; - // if there are no points found, we have a valid connection; - // otherwise choose the point of the minimum angle with the ray as connection point - - var stop = m, - mx = m.x, - my = m.y, - tanMin = Infinity, - tan; - - p = m.next; - - while (p !== stop) { - if (hx >= p.x && p.x >= mx && hx !== p.x && - pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) { - - tan = Math.abs(hy - p.y) / (hx - p.x); // tangential - - if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) { - m = p; - tanMin = tan; - } - } - - p = p.next; - } - - return m; -} - -// interlink polygon nodes in z-order -function indexCurve(start, minX, minY, size) { - var p = start; - do { - if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); - p.prevZ = p.prev; - p.nextZ = p.next; - p = p.next; - } while (p !== start); - - p.prevZ.nextZ = null; - p.prevZ = null; - - sortLinked(p); -} - -// Simon Tatham's linked list merge sort algorithm -// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html -function sortLinked(list) { - var i, p, q, e, tail, numMerges, pSize, qSize, - inSize = 1; - - do { - p = list; - list = null; - tail = null; - numMerges = 0; - - while (p) { - numMerges++; - q = p; - pSize = 0; - for (i = 0; i < inSize; i++) { - pSize++; - q = q.nextZ; - if (!q) break; - } - qSize = inSize; - - while (pSize > 0 || (qSize > 0 && q)) { - - if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) { - e = p; - p = p.nextZ; - pSize--; - } else { - e = q; - q = q.nextZ; - qSize--; - } - - if (tail) tail.nextZ = e; - else list = e; - - e.prevZ = tail; - tail = e; - } - - p = q; - } - - tail.nextZ = null; - inSize *= 2; - - } while (numMerges > 1); - - return list; -} - -// z-order of a point given coords and size of the data bounding box -function zOrder(x, y, minX, minY, size) { - // coords are transformed into non-negative 15-bit integer range - x = 32767 * (x - minX) / size; - y = 32767 * (y - minY) / size; - - x = (x | (x << 8)) & 0x00FF00FF; - x = (x | (x << 4)) & 0x0F0F0F0F; - x = (x | (x << 2)) & 0x33333333; - x = (x | (x << 1)) & 0x55555555; - - y = (y | (y << 8)) & 0x00FF00FF; - y = (y | (y << 4)) & 0x0F0F0F0F; - y = (y | (y << 2)) & 0x33333333; - y = (y | (y << 1)) & 0x55555555; - - return x | (y << 1); -} - -// find the leftmost node of a polygon ring -function getLeftmost(start) { - var p = start, - leftmost = start; - do { - if (p.x < leftmost.x) leftmost = p; - p = p.next; - } while (p !== start); - - return leftmost; -} - -// check if a point lies within a convex triangle -function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) { - return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && - (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && - (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0; -} - -// check if a diagonal between two polygon nodes is valid (lies in polygon interior) -function isValidDiagonal(a, b) { - return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && - locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b); -} - -// signed area of a triangle -function area(p, q, r) { - return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); -} - -// check if two points are equal -function equals(p1, p2) { - return p1.x === p2.x && p1.y === p2.y; -} - -// check if two segments intersect -function intersects(p1, q1, p2, q2) { - if ((equals(p1, q1) && equals(p2, q2)) || - (equals(p1, q2) && equals(p2, q1))) return true; - return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 && - area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0; -} - -// check if a polygon diagonal intersects any polygon segments -function intersectsPolygon(a, b) { - var p = a; - do { - if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && - intersects(p, p.next, a, b)) return true; - p = p.next; - } while (p !== a); - - return false; -} - -// check if a polygon diagonal is locally inside the polygon -function locallyInside(a, b) { - return area(a.prev, a, a.next) < 0 ? - area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : - area(a, b, a.prev) < 0 || area(a, a.next, b) < 0; -} - -// check if the middle point of a polygon diagonal is inside the polygon -function middleInside(a, b) { - var p = a, - inside = false, - px = (a.x + b.x) / 2, - py = (a.y + b.y) / 2; - do { - if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && - (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) - inside = !inside; - p = p.next; - } while (p !== a); - - return inside; -} - -// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two; -// if one belongs to the outer ring and another to a hole, it merges it into a single ring -function splitPolygon(a, b) { - var a2 = new Node(a.i, a.x, a.y), - b2 = new Node(b.i, b.x, b.y), - an = a.next, - bp = b.prev; - - a.next = b; - b.prev = a; - - a2.next = an; - an.prev = a2; - - b2.next = a2; - a2.prev = b2; - - bp.next = b2; - b2.prev = bp; - - return b2; -} - -// create a node and optionally link it with previous one (in a circular doubly linked list) -function insertNode(i, x, y, last) { - var p = new Node(i, x, y); - - if (!last) { - p.prev = p; - p.next = p; - - } else { - p.next = last.next; - p.prev = last; - last.next.prev = p; - last.next = p; - } - return p; -} - -function removeNode(p) { - p.next.prev = p.prev; - p.prev.next = p.next; - - if (p.prevZ) p.prevZ.nextZ = p.nextZ; - if (p.nextZ) p.nextZ.prevZ = p.prevZ; -} - -function Node(i, x, y) { - // vertice index in coordinates array - this.i = i; - - // vertex coordinates - this.x = x; - this.y = y; - - // previous and next vertice nodes in a polygon ring - this.prev = null; - this.next = null; - - // z-order curve value - this.z = null; - - // previous and next nodes in z-order - this.prevZ = null; - this.nextZ = null; - - // indicates whether this is a steiner point - this.steiner = false; -} - -// return a percentage difference between the polygon area and its triangulation area; -// used to verify correctness of triangulation -earcut.deviation = function (data, holeIndices, dim, triangles) { - var hasHoles = holeIndices && holeIndices.length; - var outerLen = hasHoles ? holeIndices[0] * dim : data.length; - - var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim)); - if (hasHoles) { - for (var i = 0, len = holeIndices.length; i < len; i++) { - var start = holeIndices[i] * dim; - var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length; - polygonArea -= Math.abs(signedArea(data, start, end, dim)); - } - } - - var trianglesArea = 0; - for (i = 0; i < triangles.length; i += 3) { - var a = triangles[i] * dim; - var b = triangles[i + 1] * dim; - var c = triangles[i + 2] * dim; - trianglesArea += Math.abs( - (data[a] - data[c]) * (data[b + 1] - data[a + 1]) - - (data[a] - data[b]) * (data[c + 1] - data[a + 1])); - } - - return polygonArea === 0 && trianglesArea === 0 ? 0 : - Math.abs((trianglesArea - polygonArea) / polygonArea); -}; - -function signedArea(data, start, end, dim) { - var sum = 0; - for (var i = start, j = end - dim; i < end; i += dim) { - sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]); - j = i; - } - return sum; -} - -// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts -earcut.flatten = function (data) { - var dim = data[0][0].length, - result = {vertices: [], holes: [], dimensions: dim}, - holeIndex = 0; - - for (var i = 0; i < data.length; i++) { - for (var j = 0; j < data[i].length; j++) { - for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]); - } - if (i > 0) { - holeIndex += data[i - 1].length; - result.holes.push(holeIndex); - } - } - return result; -}; - -/***/ }), -/* 259 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Commands = __webpack_require__(119); -var Earcut = __webpack_require__(258); -var ModelViewProjection = __webpack_require__(202); -var ShaderSourceFS = __webpack_require__(529); -var ShaderSourceVS = __webpack_require__(528); -var Utils = __webpack_require__(27); -var WebGLPipeline = __webpack_require__(84); - -var Point = function (x, y, width, rgb, alpha) -{ - this.x = x; - this.y = y; - this.width = width; - this.rgb = rgb; - this.alpha = alpha; -}; - -var Path = function (x, y, width, rgb, alpha) -{ - this.points = []; - this.pointsLength = 1; - this.points[0] = new Point(x, y, width, rgb, alpha); -}; - -var currentMatrix = new Float32Array([ 1, 0, 0, 1, 0, 0 ]); -var matrixStack = new Float32Array(6 * 1000); -var matrixStackLength = 0; -var pathArray = []; - -/** - * @classdesc - * The FlatTintPipeline is used for rendering flat colored shapes. - * Mostly used by the Graphics game object. - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class FlatTintPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. - */ -var FlatTintPipeline = new Class({ - - Extends: WebGLPipeline, - - Mixins: [ - ModelViewProjection - ], - - initialize: - - function FlatTintPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapcity ? config.vertexCapacity : 12000), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2 + - Uint8Array.BYTES_PER_ELEMENT * 4), - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - }, - { - name: 'inTint', - size: 4, - type: config.renderer.gl.UNSIGNED_BYTE, - normalized: true, - offset: Float32Array.BYTES_PER_ELEMENT * 2 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#vertexViewU32 - * @type {Uint32Array} - * @since 3.0.0 - */ - this.vertexViewU32 = new Uint32Array(this.vertexData); - - /** - * Used internally to draw triangles - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#tempTriangle - * @type {array} - * @since 3.0.0 - */ - this.tempTriangle = [ - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0} - ]; - - /** - * Used internally by for triangulating a polyong - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#polygonCache - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.polygonCache = []; - - this.mvpInit(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - this.mvpUpdate(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); - - return this; - }, - - /** - * Pushes a rectangle into the vertex batch - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillRect - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x - Horiztonal top left coordinate of the rectangle - * @param {float} y - Vertical top left coordinate of the rectangle - * @param {float} width - Width of the rectangle - * @param {float} height - Height of the rectangle - * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillRect: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x, y, width, height, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = this.vertexCount * this.vertexComponentCount; - var xw = x + width; - var yh = y + height; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tx0 = x * a + y * c + e; - var ty0 = x * b + y * d + f; - var tx1 = x * a + yh * c + e; - var ty1 = x * b + yh * d + f; - var tx2 = xw * a + yh * c + e; - var ty2 = xw * b + yh * d + f; - var tx3 = xw * a + y * c + e; - var ty3 = xw * b + y * d + f; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - vertexViewF32[vertexOffset + 9] = tx0; - vertexViewF32[vertexOffset + 10] = ty0; - vertexViewU32[vertexOffset + 11] = tint; - vertexViewF32[vertexOffset + 12] = tx2; - vertexViewF32[vertexOffset + 13] = ty2; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx3; - vertexViewF32[vertexOffset + 16] = ty3; - vertexViewU32[vertexOffset + 17] = tint; - - this.vertexCount += 6; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillTriangle - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - Point 0 x coordinate - * @param {float} y0 - Point 0 y coordinate - * @param {float} x1 - Point 1 x coordinate - * @param {float} y1 - Point 1 y coordinate - * @param {float} x2 - Point 2 x coordinate - * @param {float} y2 - Point 2 y coordinate - * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 3 > this.vertexCapacity) - { - this.flush(); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = this.vertexCount * this.vertexComponentCount; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tx0 = x0 * a + y0 * c + e; - var ty0 = x0 * b + y0 * d + f; - var tx1 = x1 * a + y1 * c + e; - var ty1 = x1 * b + y1 * d + f; - var tx2 = x2 * a + y2 * c + e; - var ty2 = x2 * b + y2 * d + f; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - - this.vertexCount += 3; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokeTriangle - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - [description] - * @param {float} y0 - [description] - * @param {float} x1 - [description] - * @param {float} y1 - [description] - * @param {float} x2 - [description] - * @param {float} y2 - [description] - * @param {float} lineWidth - Size of the line as a float value - * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchStrokeTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, currentMatrix) - { - var tempTriangle = this.tempTriangle; - - tempTriangle[0].x = x0; - tempTriangle[0].y = y0; - tempTriangle[0].width = lineWidth; - tempTriangle[0].rgb = lineColor; - tempTriangle[0].alpha = lineAlpha; - tempTriangle[1].x = x1; - tempTriangle[1].y = y1; - tempTriangle[1].width = lineWidth; - tempTriangle[1].rgb = lineColor; - tempTriangle[1].alpha = lineAlpha; - tempTriangle[2].x = x2; - tempTriangle[2].y = y2; - tempTriangle[2].width = lineWidth; - tempTriangle[2].rgb = lineColor; - tempTriangle[2].alpha = lineAlpha; - tempTriangle[3].x = x0; - tempTriangle[3].y = y0; - tempTriangle[3].width = lineWidth; - tempTriangle[3].rgb = lineColor; - tempTriangle[3].alpha = lineAlpha; - - this.batchStrokePath( - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - tempTriangle, lineWidth, lineColor, lineAlpha, - a, b, c, d, e, f, - false, - currentMatrix - ); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillPath - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} path - Collection of points that represent the path - * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillPath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - var length = path.length; - var polygonCache = this.polygonCache; - var polygonIndexArray; - var point; - var v0, v1, v2; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = 0; - var x0, y0, x1, y1, x2, y2; - var tx0, ty0, tx1, ty1, tx2, ty2; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - for (var pathIndex = 0; pathIndex < length; ++pathIndex) - { - point = path[pathIndex]; - polygonCache.push(point.x, point.y); - } - - polygonIndexArray = Earcut(polygonCache); - length = polygonIndexArray.length; - - for (var index = 0; index < length; index += 3) - { - v0 = polygonIndexArray[index + 0] * 2; - v1 = polygonIndexArray[index + 1] * 2; - v2 = polygonIndexArray[index + 2] * 2; - - if (this.vertexCount + 3 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - x0 = polygonCache[v0 + 0]; - y0 = polygonCache[v0 + 1]; - x1 = polygonCache[v1 + 0]; - y1 = polygonCache[v1 + 1]; - x2 = polygonCache[v2 + 0]; - y2 = polygonCache[v2 + 1]; - - tx0 = x0 * a + y0 * c + e; - ty0 = x0 * b + y0 * d + f; - tx1 = x1 * a + y1 * c + e; - ty1 = x1 * b + y1 * d + f; - tx2 = x2 * a + y2 * c + e; - ty2 = x2 * b + y2 * d + f; - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - - this.vertexCount += 3; - } - - polygonCache.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokePath - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {array} path - [description] - * @param {float} lineWidth - [description] - * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component - * @param {boolean} isLastPath - Indicates if the path should be closed - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchStrokePath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, isLastPath, currentMatrix) - { - this.renderer.setPipeline(this); - - var point0, point1; - var pathLength = path.length; - var polylines = this.polygonCache; - var last, curr; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset; - var line; - var getTint = Utils.getTintAppendFloatAlphaAndSwap; - - for (var pathIndex = 0; pathIndex + 1 < pathLength; pathIndex += 1) - { - point0 = path[pathIndex]; - point1 = path[pathIndex + 1]; - - line = this.batchLine( - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - point0.x, point0.y, - point1.x, point1.y, - point0.width / 2, point1.width / 2, - point0.rgb, point1.rgb, lineAlpha, - a, b, c, d, e, f, - currentMatrix - ); - - polylines.push(line); - } - - /* Render joints */ - for (var index = 1, polylinesLength = polylines.length; index < polylinesLength; ++index) - { - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - last = polylines[index - 1] || polylines[polylinesLength - 1]; - curr = polylines[index]; - vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = last[3 * 2 + 0]; - vertexViewF32[vertexOffset + 1] = last[3 * 2 + 1]; - vertexViewU32[vertexOffset + 2] = getTint(last[3 * 2 + 2], lineAlpha); - vertexViewF32[vertexOffset + 3] = last[3 * 0 + 0]; - vertexViewF32[vertexOffset + 4] = last[3 * 0 + 1]; - vertexViewU32[vertexOffset + 5] = getTint(last[3 * 0 + 2], lineAlpha); - vertexViewF32[vertexOffset + 6] = curr[3 * 3 + 0]; - vertexViewF32[vertexOffset + 7] = curr[3 * 3 + 1]; - vertexViewU32[vertexOffset + 8] = getTint(curr[3 * 3 + 2], lineAlpha); - vertexViewF32[vertexOffset + 9] = last[3 * 0 + 0]; - vertexViewF32[vertexOffset + 10] = last[3 * 0 + 1]; - vertexViewU32[vertexOffset + 11] = getTint(last[3 * 0 + 2], lineAlpha); - vertexViewF32[vertexOffset + 12] = last[3 * 2 + 0]; - vertexViewF32[vertexOffset + 13] = last[3 * 2 + 1]; - vertexViewU32[vertexOffset + 14] = getTint(last[3 * 2 + 2], lineAlpha); - vertexViewF32[vertexOffset + 15] = curr[3 * 1 + 0]; - vertexViewF32[vertexOffset + 16] = curr[3 * 1 + 1]; - vertexViewU32[vertexOffset + 17] = getTint(curr[3 * 1 + 2], lineAlpha); - - this.vertexCount += 6; - } - - polylines.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchLine - * @since 3.0.0 - * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} ax - X coordinate to the start of the line - * @param {float} ay - Y coordinate to the start of the line - * @param {float} bx - X coordinate to the end of the line - * @param {float} by - Y coordinate to the end of the line - * @param {float} aLineWidth - Width of the start of the line - * @param {float} bLineWidth - Width of the end of the line - * @param {integer} aLineColor - RGB color packed as a uint - * @param {integer} bLineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchLine: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, ax, ay, bx, by, aLineWidth, bLineWidth, aLineColor, bLineColor, lineAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var dx = bx - ax; - var dy = by - ay; - var len = Math.sqrt(dx * dx + dy * dy); - var al0 = aLineWidth * (by - ay) / len; - var al1 = aLineWidth * (ax - bx) / len; - var bl0 = bLineWidth * (by - ay) / len; - var bl1 = bLineWidth * (ax - bx) / len; - var lx0 = bx - bl0; - var ly0 = by - bl1; - var lx1 = ax - al0; - var ly1 = ay - al1; - var lx2 = bx + bl0; - var ly2 = by + bl1; - var lx3 = ax + al0; - var ly3 = ay + al1; - var x0 = lx0 * a + ly0 * c + e; - var y0 = lx0 * b + ly0 * d + f; - var x1 = lx1 * a + ly1 * c + e; - var y1 = lx1 * b + ly1 * d + f; - var x2 = lx2 * a + ly2 * c + e; - var y2 = lx2 * b + ly2 * d + f; - var x3 = lx3 * a + ly3 * c + e; - var y3 = lx3 * b + ly3 * d + f; - var getTint = Utils.getTintAppendFloatAlphaAndSwap; - var aTint = getTint(aLineColor, lineAlpha); - var bTint = getTint(bLineColor, lineAlpha); - var vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = x0; - vertexViewF32[vertexOffset + 1] = y0; - vertexViewU32[vertexOffset + 2] = bTint; - vertexViewF32[vertexOffset + 3] = x1; - vertexViewF32[vertexOffset + 4] = y1; - vertexViewU32[vertexOffset + 5] = aTint; - vertexViewF32[vertexOffset + 6] = x2; - vertexViewF32[vertexOffset + 7] = y2; - vertexViewU32[vertexOffset + 8] = bTint; - vertexViewF32[vertexOffset + 9] = x1; - vertexViewF32[vertexOffset + 10] = y1; - vertexViewU32[vertexOffset + 11] = aTint; - vertexViewF32[vertexOffset + 12] = x3; - vertexViewF32[vertexOffset + 13] = y3; - vertexViewU32[vertexOffset + 14] = aTint; - vertexViewF32[vertexOffset + 15] = x2; - vertexViewF32[vertexOffset + 16] = y2; - vertexViewU32[vertexOffset + 17] = bTint; - - this.vertexCount += 6; - - return [ - x0, y0, bLineColor, - x1, y1, aLineColor, - x2, y2, bLineColor, - x3, y3, aLineColor - ]; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchGraphics - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchGraphics: function (graphics, camera, parentTransformMatrix) - { - if (graphics.commandBuffer.length <= 0) { return; } - - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var cameraScrollX = camera.scrollX * graphics.scrollFactorX; - var cameraScrollY = camera.scrollY * graphics.scrollFactorY; - var srcX = graphics.x; - var srcY = graphics.y; - var srcScaleX = graphics.scaleX; - var srcScaleY = graphics.scaleY; - var srcRotation = graphics.rotation; - var commands = graphics.commandBuffer; - var alpha = graphics.alpha; - var lineAlpha = 1.0; - var fillAlpha = 1.0; - var lineColor = 0; - var fillColor = 0; - var lineWidth = 1.0; - var cameraMatrix = camera.matrix.matrix; - var lastPath = null; - var iteration = 0; - var iterStep = 0.01; - var tx = 0; - var ty = 0; - var ta = 0; - var x = 0; - var y = 0; - var radius = 0; - var startAngle = 0; - var endAngle = 0; - var anticlockwise = 0; - var path = null; - var sin = Math.sin; - var cos = Math.cos; - var PI2 = Math.PI * 2; - var sr = sin(srcRotation); - var cr = cos(srcRotation); - var sra = cr * srcScaleX; - var srb = sr * srcScaleX; - var src = -sr * srcScaleY; - var srd = cr * srcScaleY; - var sre = srcX; - var srf = srcY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var pathArrayIndex; - var pathArrayLength; - - pathArray.length = 0; - - for (var cmdIndex = 0, cmdLength = commands.length; cmdIndex < cmdLength; ++cmdIndex) - { - cmd = commands[cmdIndex]; - - switch (cmd) - { - case Commands.ARC: - iteration = 0; - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - radius = commands[cmdIndex + 3]; - startAngle = commands[cmdIndex + 4]; - endAngle = commands[cmdIndex + 5]; - anticlockwise = commands[cmdIndex + 6]; - - if (lastPath === null) - { - lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - iteration += iterStep; - } - - endAngle -= startAngle; - - if (anticlockwise) - { - if (endAngle < -PI2) - { - endAngle = -PI2; - } - else if (endAngle > 0) - { - endAngle = -PI2 + endAngle % PI2; - } - } - else if (endAngle > PI2) - { - endAngle = PI2; - } - else if (endAngle < 0) - { - endAngle = PI2 + endAngle % PI2; - } - - while (iteration < 1) - { - ta = endAngle * iteration + startAngle; - tx = x + cos(ta) * radius; - ty = y + sin(ta) * radius; - - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); - - iteration += iterStep; - } - - ta = endAngle + startAngle; - tx = x + cos(ta) * radius; - ty = y + sin(ta) * radius; - - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); - - cmdIndex += 6; - break; - - case Commands.LINE_STYLE: - lineWidth = commands[cmdIndex + 1]; - lineColor = commands[cmdIndex + 2]; - lineAlpha = commands[cmdIndex + 3]; - cmdIndex += 3; - break; - - case Commands.FILL_STYLE: - fillColor = commands[cmdIndex + 1]; - fillAlpha = commands[cmdIndex + 2]; - cmdIndex += 2; - break; - - case Commands.BEGIN_PATH: - pathArray.length = 0; - lastPath = null; - break; - - case Commands.CLOSE_PATH: - if (lastPath && lastPath.points.length) - { - lastPath.points.push(lastPath.points[0]); - } - break; - - case Commands.FILL_PATH: - for (pathArrayIndex = 0, pathArrayLength = pathArray.length; - pathArrayIndex < pathArrayLength; - ++pathArrayIndex) - { - this.batchFillPath( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - pathArray[pathArrayIndex].points, - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - } - break; - - case Commands.STROKE_PATH: - for (pathArrayIndex = 0, pathArrayLength = pathArray.length; - pathArrayIndex < pathArrayLength; - ++pathArrayIndex) - { - path = pathArray[pathArrayIndex]; - this.batchStrokePath( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - path.points, - lineWidth, - lineColor, - lineAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - path === this._lastPath, - currentMatrix - ); - } - break; - - case Commands.FILL_RECT: - this.batchFillRect( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 4; - break; - - case Commands.FILL_TRIANGLE: - this.batchFillTriangle( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Triangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5], - commands[cmdIndex + 6], - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 6; - break; - - case Commands.STROKE_TRIANGLE: - this.batchStrokeTriangle( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Triangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5], - commands[cmdIndex + 6], - lineWidth, - lineColor, - lineAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 6; - break; - - case Commands.LINE_TO: - if (lastPath !== null) - { - lastPath.points.push(new Point(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha)); - } - else - { - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - } - cmdIndex += 2; - break; - - case Commands.MOVE_TO: - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - cmdIndex += 2; - break; - - case Commands.LINE_FX_TO: - if (lastPath !== null) - { - lastPath.points.push(new Point( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - )); - } - else - { - lastPath = new Path( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - ); - pathArray.push(lastPath); - } - cmdIndex += 5; - break; - - case Commands.MOVE_FX_TO: - lastPath = new Path( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - ); - pathArray.push(lastPath); - cmdIndex += 5; - break; - - case Commands.SAVE: - matrixStack[matrixStackLength + 0] = currentMatrix[0]; - matrixStack[matrixStackLength + 1] = currentMatrix[1]; - matrixStack[matrixStackLength + 2] = currentMatrix[2]; - matrixStack[matrixStackLength + 3] = currentMatrix[3]; - matrixStack[matrixStackLength + 4] = currentMatrix[4]; - matrixStack[matrixStackLength + 5] = currentMatrix[5]; - matrixStackLength += 6; - break; - - case Commands.RESTORE: - matrixStackLength -= 6; - currentMatrix[0] = matrixStack[matrixStackLength + 0]; - currentMatrix[1] = matrixStack[matrixStackLength + 1]; - currentMatrix[2] = matrixStack[matrixStackLength + 2]; - currentMatrix[3] = matrixStack[matrixStackLength + 3]; - currentMatrix[4] = matrixStack[matrixStackLength + 4]; - currentMatrix[5] = matrixStack[matrixStackLength + 5]; - break; - - case Commands.TRANSLATE: - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - currentMatrix[4] = currentMatrix[0] * x + currentMatrix[2] * y + currentMatrix[4]; - currentMatrix[5] = currentMatrix[1] * x + currentMatrix[3] * y + currentMatrix[5]; - cmdIndex += 2; - break; - - case Commands.SCALE: - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - currentMatrix[0] *= x; - currentMatrix[1] *= x; - currentMatrix[2] *= y; - currentMatrix[3] *= y; - cmdIndex += 2; - break; - - case Commands.ROTATE: - y = commands[cmdIndex + 1]; - x = sin(y); - y = cos(y); - sra = currentMatrix[0]; - srb = currentMatrix[1]; - src = currentMatrix[2]; - srd = currentMatrix[3]; - currentMatrix[0] = y * sra + x * src; - currentMatrix[1] = y * srb + x * srd; - currentMatrix[2] = -x * sra + y * src; - currentMatrix[3] = -x * srb + y * srd; - cmdIndex += 1; - break; - - default: - // eslint-disable-next-line no-console - console.error('Phaser: Invalid Graphics Command ID ' + cmd); - break; - } - } - }, - - // Stubs - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawStaticTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawEmitterManager: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawBlitter: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchSprite: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchMesh: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchTileSprite: function () - { - } - -}); - -module.exports = FlatTintPipeline; - - -/***/ }), -/* 260 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var ShaderSourceFS = __webpack_require__(531); -var ShaderSourceVS = __webpack_require__(530); -var WebGLPipeline = __webpack_require__(84); - -/** - * @classdesc - * BitmapMaskPipeline handles all bitmap masking rendering in WebGL. It works by using - * sampling two texture on the fragment shader and using the fragment's alpha to clip the region. - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class BitmapMaskPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. - */ -var BitmapMaskPipeline = new Class({ - - Extends: WebGLPipeline, - - initialize: - - function BitmapMaskPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2), - - vertices: new Float32Array([ - -1, +1, -1, -7, +7, +1 - ]).buffer, - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Size of the batch. - * - * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#maxQuads - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.maxQuads = 1; - - /** - * Dirty flag to check if resolution properties need to be updated on the - * masking shader. - * - * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resolutionDirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.resolutionDirty = true; - }, - - /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - - var renderer = this.renderer; - var program = this.program; - - if (this.resolutionDirty) - { - renderer.setFloat2(program, 'uResolution', this.width, this.height); - renderer.setInt1(program, 'uMainSampler', 0); - renderer.setInt1(program, 'uMaskSampler', 1); - this.resolutionDirty = false; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.resolutionDirty = true; - return this; - }, - - /** - * Binds necessary resources and renders the mask to a separated framebuffer. - * The framebuffer for the masked object is also bound for further use. - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#beginMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - GameObject used as mask. - * @param {Phaser.GameObjects.GameObject} maskedObject - GameObject masked by the mask GameObject. - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - beginMask: function (mask, maskedObject, camera) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - var visible = bitmapMask.visible; - - if (bitmapMask && gl) - { - // First we clear the mask framebuffer - renderer.setFramebuffer(mask.maskFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - - // We render out mask source - bitmapMask.visible = true; - bitmapMask.renderWebGL(renderer, bitmapMask, 0.0, camera); - bitmapMask.visible = visible; - renderer.flush(); - - // Bind and clear our main source (masked object) - renderer.setFramebuffer(mask.mainFramebuffer); - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - } - }, - - /** - * The masked game object's framebuffer is unbound and it's texture - * is bound together with the mask texture and the mask shader and - * a draw call with a single quad is processed. Here is where the - * masking effect is applied. - * - * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#endMask - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} mask - GameObject used as a mask. - */ - endMask: function (mask) - { - var bitmapMask = mask.bitmapMask; - var renderer = this.renderer; - var gl = this.gl; - - if (bitmapMask) - { - // Return to default framebuffer - renderer.setFramebuffer(null); - - // Bind bitmap mask pipeline and draw - renderer.setPipeline(this); - - renderer.setTexture2D(mask.maskTexture, 1); - renderer.setTexture2D(mask.mainTexture, 0); - renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); - - // Finally draw a triangle filling the whole screen - gl.drawArrays(this.topology, 0, 3); - } - } - -}); - -module.exports = BitmapMaskPipeline; - - -/***/ }), -/* 261 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Renderer.Snapshot.WebGL - * @since 3.0.0 - * - * @param {HTMLCanvasElement} sourceCanvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] - * - * @return {HTMLImageElement} [description] - */ -var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) -{ - if (!type) { type = 'image/png'; } - if (!encoderOptions) { encoderOptions = 0.92; } - - var gl = sourceCanvas.getContext('experimental-webgl'); - var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); - gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); - - // CanvasPool? - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - var imageData; - - canvas.width = gl.drawingBufferWidth; - canvas.height = gl.drawingBufferHeight; - - imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - - var data = imageData.data; - - for (var y = 0; y < canvas.height; y += 1) - { - for (var x = 0; x < canvas.width; x += 1) - { - var si = ((canvas.height - y) * canvas.width + x) * 4; - var di = (y * canvas.width + x) * 4; - data[di + 0] = pixels[si + 0]; - data[di + 1] = pixels[si + 1]; - data[di + 2] = pixels[si + 2]; - data[di + 3] = pixels[si + 3]; - } - } - - ctx.putImageData(imageData, 0, 0); - - var src = canvas.toDataURL(type, encoderOptions); - var image = new Image(); - - image.src = src; - - return image; -}; - -module.exports = WebGLSnapshot; - - -/***/ }), -/* 262 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var IsSizePowerOfTwo = __webpack_require__(85); -var SpliceOne = __webpack_require__(56); -var Utils = __webpack_require__(27); -var WebGLSnapshot = __webpack_require__(261); - -// Default Pipelines -var BitmapMaskPipeline = __webpack_require__(260); -var FlatTintPipeline = __webpack_require__(259); -var ForwardDiffuseLightPipeline = __webpack_require__(148); -var TextureTintPipeline = __webpack_require__(129); - -/** - * @callback WebGLContextCallback - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] - */ - -/** - * @typedef {object} SnapshotState - * - * @property {SnapshotCallback} callback - [description] - * @property {string} type - [description] - * @property {float} encoder - [description] - */ - -/** - * @classdesc - * WebGLRenderer is a class that contains the needed functionality to keep the - * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of - * any context change that happens for WebGL rendering inside of Phaser. This means - * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL - * rendering ecosystem they might pollute the current WebGLRenderingContext state producing - * unexpected behaviour. It's recommended that WebGL interaction is done through - * WebGLRenderer and/or WebGLPipeline. - * - * @class WebGLRenderer - * @memberOf Phaser.Renderer.WebGL - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - [description] - */ -var WebGLRenderer = new Class({ - - initialize: - - function WebGLRenderer (game) - { - // eslint-disable-next-line consistent-this - var renderer = this; - - var gameConfig = game.config; - - var contextCreationConfig = { - alpha: gameConfig.transparent, - depth: false, // enable when 3D is added in the future - antialias: gameConfig.antialias, - premultipliedAlpha: gameConfig.premultipliedAlpha, - stencil: true, - preserveDrawingBuffer: gameConfig.preserveDrawingBuffer, - failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat, - powerPreference: gameConfig.powerPreference - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#config - * @type {RendererConfig} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: gameConfig.clearBeforeRender, - pixelArt: gameConfig.pixelArt, - backgroundColor: gameConfig.backgroundColor, - contextCreation: contextCreationConfig, - resolution: gameConfig.resolution, - autoResize: gameConfig.autoResize, - roundPixels: gameConfig.roundPixels, - maxTextures: gameConfig.maxTextures, - maxTextureSize: gameConfig.maxTextureSize - }; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.WEBGL; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.canvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks - * @type {WebGLContextCallback[]} - * @since 3.0.0 - */ - this.lostContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks - * @type {WebGLContextCallback[]} - * @since 3.0.0 - */ - this.restoredContextCallbacks = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.blendModes = []; - - /** - * Keeps track of any WebGLTexture created with the current WebGLRenderingContext - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.nativeTextures = []; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.contextLost = false; - - /** - * This object will store all pipelines created through addPipeline - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines - * @type {object} - * @default null - * @since 3.0.0 - */ - this.pipelines = null; - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState - * @type {SnapshotState} - * @since 3.0.0 - */ - this.snapshotState = { - callback: null, - type: null, - encoder: null - }; - - // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) - - /** - * Cached value for the last texture unit that was used - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit - * @type {integer} - * @since 3.1.0 - */ - this.currentActiveTextureUnit = 0; - - /** - * An array of the last texture handles that were bound to the WebGLRenderingContext - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures - * @type {array} - * @since 3.0.0 - */ - this.currentTextures = new Array(16); - - /** - * Current framebuffer in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer - * @type {WebGLFramebuffer} - * @default null - * @since 3.0.0 - */ - this.currentFramebuffer = null; - - /** - * Current WebGLPipeline in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @since 3.0.0 - */ - this.currentPipeline = null; - - /** - * Current WebGLProgram in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram - * @type {WebGLProgram} - * @default null - * @since 3.0.0 - */ - this.currentProgram = null; - - /** - * Current WebGLBuffer (Vertex buffer) in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentVertexBuffer = null; - - /** - * Current WebGLBuffer (Index buffer) in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer - * @type {WebGLBuffer} - * @default null - * @since 3.0.0 - */ - this.currentIndexBuffer = null; - - /** - * Current blend mode in use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode - * @type {integer} - * @since 3.0.0 - */ - this.currentBlendMode = Infinity; - - /** - * Indicates if the the scissor state is enabled in WebGLRenderingContext - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.currentScissorEnabled = false; - - /** - * Stores the current scissor data - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor - * @type {Uint32Array} - * @since 3.0.0 - */ - this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); - - /** - * Index to the scissor stack top - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorIdx - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScissorIdx = 0; - - /** - * Stack of scissor data - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack - * @type {Uint32Array} - * @since 3.0.0 - */ - this.scissorStack = new Uint32Array(4 * 1000); - - // Setup context lost and restore event listeners - - this.canvas.addEventListener('webglcontextlost', function (event) - { - renderer.contextLost = true; - event.preventDefault(); - - for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) - { - var callback = renderer.lostContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - this.canvas.addEventListener('webglcontextrestored', function () - { - renderer.contextLost = false; - renderer.init(renderer.config); - for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) - { - var callback = renderer.restoredContextCallbacks[index]; - callback[0].call(callback[1], renderer); - } - }, false); - - // These are initialized post context creation - - /** - * [description] - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#gl - * @type {WebGLRenderingContext} - * @default null - * @since 3.0.0 - */ - this.gl = null; - - /** - * Array of strings that indicate which WebGL extensions are supported by the browser - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions - * @type {object} - * @default null - * @since 3.0.0 - */ - this.supportedExtensions = null; - - /** - * Extensions loaded into the current context - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.extensions = {}; - - /** - * Stores the current WebGL component formats for further use - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats - * @type {array} - * @default [] - * @since 3.2.0 - */ - this.glFormats = []; - - /** - * Stores the supported WebGL texture compression formats. - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#compression - * @type {array} - * @since 3.8.0 - */ - this.compression = { - ETC1: false, - PVRTC: false, - S3TC: false - }; - - this.init(this.config); - }, - - /** - * Creates a new WebGLRenderingContext and initializes all internal - * state. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#init - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - init: function (config) - { - var gl; - var canvas = this.canvas; - var clearColor = config.backgroundColor; - - // Did they provide their own context? - if (this.game.config.context) - { - gl = this.game.config.context; - } - else - { - gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); - } - - if (!gl || gl.isContextLost()) - { - this.contextLost = true; - - throw new Error('This browser does not support WebGL. Try using the Canvas pipeline.'); - } - - this.gl = gl; - - // Set it back into the Game, so devs can access it from there too - this.game.context = gl; - - for (var i = 0; i <= 16; i++) - { - this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); - } - - this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; - this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; - this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; - - this.glFormats[0] = gl.BYTE; - this.glFormats[1] = gl.SHORT; - this.glFormats[2] = gl.UNSIGNED_BYTE; - this.glFormats[3] = gl.UNSIGNED_SHORT; - this.glFormats[4] = gl.FLOAT; - - // Load supported extensions - var exts = gl.getSupportedExtensions(); - - if (!config.maxTextures) - { - config.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); - } - - if (!config.maxTextureSize) - { - config.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); - } - - var extString = 'WEBGL_compressed_texture_'; - var wkExtString = 'WEBKIT_' + extString; - - this.compression.ETC1 = gl.getExtension(extString + 'etc1') || gl.getExtension(wkExtString + 'etc1'); - this.compression.PVRTC = gl.getExtension(extString + 'pvrtc') || gl.getExtension(wkExtString + 'pvrtc'); - this.compression.S3TC = gl.getExtension(extString + 's3tc') || gl.getExtension(wkExtString + 's3tc'); - - this.supportedExtensions = exts; - - // Setup initial WebGL state - gl.disable(gl.DEPTH_TEST); - gl.disable(gl.CULL_FACE); - gl.disable(gl.SCISSOR_TEST); - gl.enable(gl.BLEND); - gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); - - // Initialize all textures to null - for (var index = 0; index < this.currentTextures.length; ++index) - { - this.currentTextures[index] = null; - } - - // Clear previous pipelines and reload default ones - this.pipelines = {}; - - this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('FlatTintPipeline', new FlatTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); - this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this })); - - this.setBlendMode(CONST.BlendModes.NORMAL); - this.resize(this.width, this.height); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - resize: function (width, height) - { - var gl = this.gl; - var pipelines = this.pipelines; - var resolution = this.config.resolution; - - this.width = Math.floor(width * resolution); - this.height = Math.floor(height * resolution); - - this.canvas.width = this.width; - this.canvas.height = this.height; - - if (this.config.autoResize) - { - this.canvas.style.width = (this.width / resolution) + 'px'; - this.canvas.style.height = (this.height / resolution) + 'px'; - } - - gl.viewport(0, 0, this.width, this.height); - - // Update all registered pipelines - for (var pipelineName in pipelines) - { - pipelines[pipelineName].resize(width, height, resolution); - } - - this.currentScissor.set([ 0, 0, this.width, this.height ]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored - * @since 3.0.0 - * - * @param {WebGLContextCallback} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextRestored: function (callback, target) - { - this.restoredContextCallbacks.push([ callback, target ]); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost - * @since 3.0.0 - * - * @param {WebGLContextCallback} callback - [description] - * @param {object} target - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - onContextLost: function (callback, target) - { - this.lostContextCallbacks.push([ callback, target ]); - - return this; - }, - - /** - * Checks if a WebGL extension is supported - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension - * @since 3.0.0 - * - * @param {string} extensionName - Name of the WebGL extension - * - * @return {boolean} [description] - */ - hasExtension: function (extensionName) - { - return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; - }, - - /** - * Loads a WebGL extension - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension - * @since 3.0.0 - * - * @param {string} extensionName - [description] - * - * @return {object} WebGL extension if the extension is supported - */ - getExtension: function (extensionName) - { - if (!this.hasExtension(extensionName)) { return null; } - - if (!(extensionName in this.extensions)) - { - this.extensions[extensionName] = this.gl.getExtension(extensionName); - } - - return this.extensions[extensionName]; - }, - - /** - * Flushes the current pipeline if the pipeline is bound - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#flush - * @since 3.0.0 - */ - flush: function () - { - if (this.currentPipeline) - { - this.currentPipeline.flush(); - } - }, - - /* Renderer State Manipulation Functions */ - - /** - * Checks if a pipeline is present in the current WebGLRenderer - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - Name of the pipeline - * - * @return {boolean} [description] - */ - hasPipeline: function (pipelineName) - { - return (pipelineName in this.pipelines); - }, - - /** - * Returns the pipeline by name if the pipeline exists - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - getPipeline: function (pipelineName) - { - return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; - }, - - /** - * Removes a pipeline by name - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - removePipeline: function (pipelineName) - { - delete this.pipelines[pipelineName]; - - return this; - }, - - /** - * Adds a pipeline instance into the collection of pipelines - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline - * @since 3.0.0 - * - * @param {string} pipelineName - [description] - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - Pipeline instance must extend WebGLPipeline - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} The instance that was passed. - */ - addPipeline: function (pipelineName, pipelineInstance) - { - if (!this.hasPipeline(pipelineName)) - { - this.pipelines[pipelineName] = pipelineInstance; - } - else - { - console.warn('Pipeline', pipelineName, ' already exists.'); - } - - pipelineInstance.name = pipelineName; - - this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); - - return pipelineInstance; - }, - - /** - * Sets the current scissor state - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setScissor: function (x, y, w, h) - { - var gl = this.gl; - var currentScissor = this.currentScissor; - var enabled = (x === 0 && y === 0 && w === gl.canvas.width && h === gl.canvas.height && w >= 0 && h >= 0); - - if (currentScissor[0] !== x || - currentScissor[1] !== y || - currentScissor[2] !== w || - currentScissor[3] !== h) - { - this.flush(); - } - - currentScissor[0] = x; - currentScissor[1] = y; - currentScissor[2] = w; - currentScissor[3] = h; - - this.currentScissorEnabled = enabled; - - if (enabled) - { - gl.disable(gl.SCISSOR_TEST); - - return this; - } - - gl.enable(gl.SCISSOR_TEST); - gl.scissor(x, (gl.drawingBufferHeight - y - h), w, h); - - return this; - }, - - /** - * Pushes a new scissor state. This is used to set nested scissor states. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - pushScissor: function (x, y, w, h) - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx; - var currentScissor = this.currentScissor; - - scissorStack[stackIndex + 0] = currentScissor[0]; - scissorStack[stackIndex + 1] = currentScissor[1]; - scissorStack[stackIndex + 2] = currentScissor[2]; - scissorStack[stackIndex + 3] = currentScissor[3]; - - this.currentScissorIdx += 4; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * Pops the last scissor state and sets it. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - popScissor: function () - { - var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx - 4; - - var x = scissorStack[stackIndex + 0]; - var y = scissorStack[stackIndex + 1]; - var w = scissorStack[stackIndex + 2]; - var h = scissorStack[stackIndex + 3]; - - this.currentScissorIdx = stackIndex; - this.setScissor(x, y, w, h); - - return this; - }, - - /** - * Binds a WebGLPipeline and sets it as the current pipeline to be used. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline - * @since 3.0.0 - * - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] - */ - setPipeline: function (pipelineInstance) - { - if (this.currentPipeline !== pipelineInstance || - this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || - this.currentPipeline.program !== this.currentProgram) - { - this.flush(); - this.currentPipeline = pipelineInstance; - this.currentPipeline.bind(); - } - - this.currentPipeline.onBind(); - - return this.currentPipeline; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode - * @since 3.0.0 - * - * @param {integer} blendModeId - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setBlendMode: function (blendModeId) - { - var gl = this.gl; - var blendMode = this.blendModes[blendModeId]; - - if (blendModeId !== CONST.BlendModes.SKIP_CHECK && - this.currentBlendMode !== blendModeId) - { - this.flush(); - - gl.enable(gl.BLEND); - gl.blendEquation(blendMode.equation); - - if (blendMode.func.length > 2) - { - gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); - } - else - { - gl.blendFunc(blendMode.func[0], blendMode.func[1]); - } - - this.currentBlendMode = blendModeId; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#addBlendMode - * @since 3.0.0 - * - * @param {function} func - [description] - * @param {function} equation - [description] - * - * @return {integer} [description] - */ - addBlendMode: function (func, equation) - { - var index = this.blendModes.push({ func: func, equation: equation }); - - return index - 1; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#updateBlendMode - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {function} func - [description] - * @param {function} equation - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - updateBlendMode: function (index, func, equation) - { - if (this.blendModes[index]) - { - this.blendModes[index].func = func; - - if (equation) - { - this.blendModes[index].equation = equation; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#removeBlendMode - * @since 3.0.0 - * - * @param {integer} index - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - removeBlendMode: function (index) - { - if (index > 16 && this.blendModes[index]) - { - this.blendModes.splice(index, 1); - } - - return this; - }, - - /** - * Binds a texture at a texture unit. If a texture is already - * bound to that unit it will force a flush on the current pipeline. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D - * @since 3.0.0 - * - * @param {WebGLTexture} texture - The WebGL texture that needs to be bound - * @param {integer} textureUnit - The texture unit to which the texture will be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setTexture2D: function (texture, textureUnit) - { - var gl = this.gl; - - if (texture !== this.currentTextures[textureUnit]) - { - this.flush(); - - if (this.currentActiveTextureUnit !== textureUnit) - { - gl.activeTexture(gl.TEXTURE0 + textureUnit); - - this.currentActiveTextureUnit = textureUnit; - } - - gl.bindTexture(gl.TEXTURE_2D, texture); - - this.currentTextures[textureUnit] = texture; - } - - return this; - }, - - /** - * Binds a framebuffer. If there was another framebuffer already bound - * it will force a pipeline flush. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setFramebuffer: function (framebuffer) - { - var gl = this.gl; - - if (framebuffer !== this.currentFramebuffer) - { - this.flush(); - - gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); - - this.currentFramebuffer = framebuffer; - } - - return this; - }, - - /** - * Binds a program. If there was another program already bound - * it will force a pipeline flush - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - The program that needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setProgram: function (program) - { - var gl = this.gl; - - if (program !== this.currentProgram) - { - this.flush(); - - gl.useProgram(program); - - this.currentProgram = program; - } - - return this; - }, - - /** - * Bounds a vertex buffer. If there is a vertex buffer already bound - * it'll force a pipeline flush. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - The buffer that needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setVertexBuffer: function (vertexBuffer) - { - var gl = this.gl; - - if (vertexBuffer !== this.currentVertexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); - - this.currentVertexBuffer = vertexBuffer; - } - - return this; - }, - - /** - * Bounds a index buffer. If there is a index buffer already bound - * it'll force a pipeline flush. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} indexBuffer - The buffer the needs to be bound - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - setIndexBuffer: function (indexBuffer) - { - var gl = this.gl; - - if (indexBuffer !== this.currentIndexBuffer) - { - this.flush(); - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); - - this.currentIndexBuffer = indexBuffer; - } - - return this; - }, - - /* Renderer Resource Creation Functions */ - - /** - * Creates a texture from an image source. If the source is not valid - * it creates an empty texture - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} scaleMode - [description] - * - * @return {WebGLTexture} [description] - */ - createTextureFromSource: function (source, width, height, scaleMode) - { - var gl = this.gl; - var filter = gl.NEAREST; - var wrap = gl.CLAMP_TO_EDGE; - var texture = null; - - width = source ? source.width : width; - height = source ? source.height : height; - - if (IsSizePowerOfTwo(width, height)) - { - wrap = gl.REPEAT; - } - - if (scaleMode === CONST.ScaleModes.LINEAR) - { - filter = gl.LINEAR; - } - else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt) - { - filter = gl.NEAREST; - } - - if (!source && typeof width === 'number' && typeof height === 'number') - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); - } - else - { - texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); - } - - return texture; - }, - - /** - * A wrapper for creating a WebGLTexture. If not pixel data is passed - * it will create an empty texture. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D - * @since 3.0.0 - * - * @param {integer} mipLevel - Mip level of the texture - * @param {integer} minFilter - Filtering of the texture - * @param {integer} magFilter - Filtering of the texture - * @param {integer} wrapT - Wrapping mode of the texture - * @param {integer} wrapS - Wrapping mode of the texture - * @param {integer} format - Which format does the texture use - * @param {object} pixels - pixel data - * @param {integer} width - Width of the texture in pixels - * @param {integer} height - Height of the texture in pixels - * @param {boolean} pma - Does the texture hace premultiplied alpha. - * - * @return {WebGLTexture} Raw WebGLTexture - */ - createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) - { - var gl = this.gl; - var texture = gl.createTexture(); - - pma = (pma === undefined || pma === null) ? true : pma; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); - - if (pixels === null || pixels === undefined) - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); - } - else - { - gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); - width = pixels.width; - height = pixels.height; - } - - this.setTexture2D(null, 0); - - texture.isAlphaPremultiplied = pma; - texture.isRenderTexture = false; - texture.width = width; - texture.height = height; - - this.nativeTextures.push(texture); - - return texture; - }, - - /** - * Wrapper for creating WebGLFramebuffer. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer - * @since 3.0.0 - * - * @param {integer} width - Width in pixels of the framebuffer - * @param {integer} height - Height in pixels of the framebuffer - * @param {WebGLTexture} renderTexture - The color texture to where the color pixels are written - * @param {boolean} addDepthStencilBuffer - Indicates if the current framebuffer support depth and stencil buffers - * - * @return {WebGLFramebuffer} Raw WebGLFramebuffer - */ - createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) - { - var gl = this.gl; - var framebuffer = gl.createFramebuffer(); - var complete = 0; - - this.setFramebuffer(framebuffer); - - if (addDepthStencilBuffer) - { - var depthStencilBuffer = gl.createRenderbuffer(); - gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); - gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); - gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); - } - - renderTexture.isRenderTexture = true; - renderTexture.isAlphaPremultiplied = false; - - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); - - complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); - - if (complete !== gl.FRAMEBUFFER_COMPLETE) - { - var errors = { - 36054: 'Incomplete Attachment', - 36055: 'Missing Attachment', - 36057: 'Incomplete Dimensions', - 36061: 'Framebuffer Unsupported' - }; - - throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); - } - - framebuffer.renderTexture = renderTexture; - - this.setFramebuffer(null); - - return framebuffer; - }, - - /** - * Wrapper for creating a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram - * @since 3.0.0 - * - * @param {string} vertexShader - Source to the vertex shader - * @param {string} fragmentShader - Source to the fragment shader - * - * @return {WebGLProgram} Raw WebGLProgram - */ - createProgram: function (vertexShader, fragmentShader) - { - var gl = this.gl; - var program = gl.createProgram(); - var vs = gl.createShader(gl.VERTEX_SHADER); - var fs = gl.createShader(gl.FRAGMENT_SHADER); - - gl.shaderSource(vs, vertexShader); - gl.shaderSource(fs, fragmentShader); - gl.compileShader(vs); - gl.compileShader(fs); - - if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); - } - if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) - { - throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); - } - - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.linkProgram(program); - - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) - { - throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); - } - - return program; - }, - - /** - * Wrapper for creating a vertex buffer. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo - * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW - * - * @return {WebGLBuffer} Raw vertex buffer - */ - createVertexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var vertexBuffer = gl.createBuffer(); - - this.setVertexBuffer(vertexBuffer); - - gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); - - this.setVertexBuffer(null); - - return vertexBuffer; - }, - - /** - * Wrapper for creating a vertex buffer. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer - * @since 3.0.0 - * - * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo - * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW - * - * @return {WebGLBuffer} Raw index buffer - */ - createIndexBuffer: function (initialDataOrSize, bufferUsage) - { - var gl = this.gl; - var indexBuffer = gl.createBuffer(); - - this.setIndexBuffer(indexBuffer); - - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); - - this.setIndexBuffer(null); - - return indexBuffer; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture - * @since 3.0.0 - * - * @param {WebGLTexture} texture - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteTexture: function (texture) - { - var index = this.nativeTextures.indexOf(texture); - - if (index !== -1) - { - SpliceOne(this.nativeTextures, index); - } - - this.gl.deleteTexture(texture); - - return this; - }, - - /** - * Wrapper for deleting a raw WebGLFramebuffer - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer - * @since 3.0.0 - * - * @param {WebGLFramebuffer} framebuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteFramebuffer: function (framebuffer) - { - this.gl.deleteFramebuffer(framebuffer); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteProgram: function (program) - { - this.gl.deleteProgram(program); - - return this; - }, - - /** - * Wrapper for deleting a vertex or index buffer - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer - * @since 3.0.0 - * - * @param {WebGLBuffer} vertexBuffer - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. - */ - deleteBuffer: function (buffer) - { - this.gl.deleteBuffer(buffer); - - return this; - }, - - /* Rendering Functions */ - - /** - * Handles any clipping needed by the camera and renders the background - * color if a color is visible. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - preRenderCamera: function (camera) - { - var resolution = this.config.resolution; - - var cx = Math.floor(camera.x * resolution); - var cy = Math.floor(camera.y * resolution); - var cw = Math.floor(camera.width * resolution); - var ch = Math.floor(camera.height * resolution); - - this.pushScissor(cx, cy, cw, ch); - - if (camera.backgroundColor.alphaGL > 0) - { - var color = camera.backgroundColor; - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1.0), - color.alphaGL, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); - - FlatTintPipeline.flush(); - } - }, - - /** - * Renders the foreground camera effects like flash and fading. - * It resets the current scissor state. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - postRenderCamera: function (camera) - { - var FlatTintPipeline = this.pipelines.FlatTintPipeline; - - var isFlashing = camera.flashEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); - var isFading = camera.fadeEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); - - if (isFading || isFlashing) - { - FlatTintPipeline.flush(); - } - - this.popScissor(); - }, - - /** - * Clears the current vertex buffer and updates pipelines. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - if (this.contextLost) { return; } - - var gl = this.gl; - var color = this.config.backgroundColor; - var pipelines = this.pipelines; - - // Bind custom framebuffer here - gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); - - if (this.config.clearBeforeRender) - { - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); - } - - for (var key in pipelines) - { - pipelines[key].onPreRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.GameObject} children - [description] - * @param {number} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - if (this.contextLost) { return; } - - var list = children.list; - var childCount = list.length; - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onRender(scene, camera); - } - - this.preRenderCamera(camera); - - for (var index = 0; index < childCount; ++index) - { - var child = list[index]; - - if (!child.willRender()) - { - continue; - } - - if (child.blendMode !== this.currentBlendMode) - { - this.setBlendMode(child.blendMode); - } - - if (child.mask) - { - child.mask.preRenderWebGL(this, child, camera); - } - - child.renderWebGL(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderWebGL(this, child); - } - } - - this.flush(); - this.setBlendMode(CONST.BlendModes.NORMAL); - this.postRenderCamera(camera); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - if (this.contextLost) { return; } - - // Unbind custom framebuffer here - - if (this.snapshotState.callback) - { - this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); - this.snapshotState.callback = null; - } - - var pipelines = this.pipelines; - - for (var key in pipelines) - { - pipelines[key].onPostRender(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot - * @since 3.0.0 - * - * @param {SnapshotCallback} callback - [description] - * @param {string} type - [description] - * @param {float} encoderOptions - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotState.callback = callback; - this.snapshotState.type = type; - this.snapshotState.encoder = encoderOptions; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture - * @since 3.0.0 - * - * @param {HTMLCanvasElement} srcCanvas - [description] - * @param {WebGLTexture} [dstTexture] - [description] - * - * @return {WebGLTexture} [description] - */ - canvasToTexture: function (srcCanvas, dstTexture) - { - var gl = this.gl; - - if (!dstTexture) - { - var wrapping = gl.CLAMP_TO_EDGE; - - if (IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) - { - wrapping = gl.REPEAT; - } - - dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); - } - else - { - this.setTexture2D(dstTexture, 0); - - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); - - dstTexture.width = srcCanvas.width; - dstTexture.height = srcCanvas.height; - - this.setTexture2D(null, 0); - } - - return dstTexture; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter - * @since 3.0.0 - * - * @param {integer} texture - [description] - * @param {integer} filter - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setTextureFilter: function (texture, filter) - { - var gl = this.gl; - var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; - - this.setTexture2D(texture, 0); - - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); - - this.setTexture2D(null, 0); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat1: function (program, name, x) - { - this.setProgram(program); - - this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat2: function (program, name, x, y) - { - this.setProgram(program); - - this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat3: function (program, name, x, y, z) - { - this.setProgram(program); - - this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); - - return this; - }, - - /** - * Sets uniform of a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - Target program - * @param {string} name - Name of the uniform - * @param {float} x - X component - * @param {float} y - Y component - * @param {float} z - Z component - * @param {float} w - W component - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setFloat4: function (program, name, x, y, z, w) - { - this.setProgram(program); - - this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt1: function (program, name, x) - { - this.setProgram(program); - - this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt2: function (program, name, x, y) - { - this.setProgram(program); - - this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt3: function (program, name, x, y, z) - { - this.setProgram(program); - - this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); - - return this; - }, - - /** - * Sets uniform of a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - Target Program - * @param {string} name - Name of the uniform - * @param {integer} x - X component - * @param {integer} y - Y component - * @param {integer} z - Z component - * @param {integer} w - W component - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setInt4: function (program, name, x, y, z, w) - { - this.setProgram(program); - - this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix2: function (program, name, transpose, matrix) - { - this.setProgram(program); - - this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 - * @since 3.0.0 - * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix3: function (program, name, transpose, matrix) - { - this.setProgram(program); - - this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); - - return this; - }, - - /** - * Sets uniform of a WebGLProgram - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 - * @since 3.0.0 - * - * @param {WebGLProgram} program - Target program - * @param {string} name - Name of the uniform - * @param {boolean} transpose - Is the matrix transposed - * @param {Float32Array} matrix - Matrix data - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setMatrix4: function (program, name, transpose, matrix) - { - this.setProgram(program); - - this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); - - return this; - }, - - /** - * Returns the maximum number of texture units that can be used in a fragment shader. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextures - * @since 3.8.0 - * - * @return {integer} The maximum number of textures WebGL supports. - */ - getMaxTextures: function () - { - return this.config.maxTextures; - }, - - /** - * Returns the largest texture size (either width or height) that can be created. - * Note that VRAM may not allow a texture of any given size, it just expresses - * hardware / driver support for a given size. - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextureSize - * @since 3.8.0 - * - * @return {integer} ... - */ - getMaxTextureSize: function () - { - return this.config.maxTextureSize; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Clear-up anything that should be cleared :) - for (var key in this.pipelines) - { - this.pipelines[key].destroy(); - - delete this.pipelines[key]; - } - - for (var index = 0; index < this.nativeTextures.length; ++index) - { - this.deleteTexture(this.nativeTextures[index]); - - delete this.nativeTextures[index]; - } - - delete this.gl; - delete this.game; - - this.contextLost = true; - this.extensions = {}; - this.nativeTextures.length = 0; - } - -}); - -module.exports = WebGLRenderer; - - -/***/ }), -/* 263 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var modes = __webpack_require__(51); -var CanvasFeatures = __webpack_require__(203); - -/** - * [description] - * - * @function Phaser.Renderer.Canvas.GetBlendModes - * @since 3.0.0 - * - * @return {array} [description] - */ -var GetBlendModes = function () -{ - var output = []; - var useNew = CanvasFeatures.supportNewBlendModes; - - output[modes.NORMAL] = 'source-over'; - output[modes.ADD] = 'lighter'; - output[modes.MULTIPLY] = (useNew) ? 'multiply' : 'source-over'; - output[modes.SCREEN] = (useNew) ? 'screen' : 'source-over'; - output[modes.OVERLAY] = (useNew) ? 'overlay' : 'source-over'; - output[modes.DARKEN] = (useNew) ? 'darken' : 'source-over'; - output[modes.LIGHTEN] = (useNew) ? 'lighten' : 'source-over'; - output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : 'source-over'; - output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : 'source-over'; - output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : 'source-over'; - output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : 'source-over'; - output[modes.DIFFERENCE] = (useNew) ? 'difference' : 'source-over'; - output[modes.EXCLUSION] = (useNew) ? 'exclusion' : 'source-over'; - output[modes.HUE] = (useNew) ? 'hue' : 'source-over'; - output[modes.SATURATION] = (useNew) ? 'saturation' : 'source-over'; - output[modes.COLOR] = (useNew) ? 'color' : 'source-over'; - output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : 'source-over'; - - return output; -}; - -module.exports = GetBlendModes; - - -/***/ }), -/* 264 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var roundPixels = false; - -/** - * [description] - * - * @function Phaser.Renderer.Canvas.DrawImage - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} src - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - [description] - */ -var DrawImage = function (src, camera, parentMatrix) -{ - var ctx = this.currentContext; - var frame = src.frame; - var cd = frame.canvasData; - - // Blend Mode - - if (this.currentBlendMode !== src.blendMode) - { - this.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = this.blendModes[src.blendMode]; - } - - // Alpha - - if (this.currentAlpha !== src.alpha) - { - this.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - - if (this.currentScaleMode !== src.scaleMode) - { - this.currentScaleMode = src.scaleMode; - - // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); - } - - var dx = frame.x; - var dy = frame.y; - - var fx = 1; - var fy = 1; - - if (src.flipX) - { - fx = -1; - dx -= cd.dWidth - src.displayOriginX; - } - else - { - dx -= src.displayOriginX; - } - - if (src.flipY) - { - fy = -1; - dy -= cd.dHeight - src.displayOriginY; - } - else - { - dy -= src.displayOriginY; - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - dx |= 0; - dy |= 0; - } - - // Perform Matrix ITRS - - ctx.save(); - - if (parentMatrix) - { - var matrix = parentMatrix.matrix; - - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(fx, fy); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - - ctx.restore(); -}; - -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return DrawImage; -}; - - -/***/ }), -/* 265 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Renderer.Snapshot.Canvas - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] - * - * @return {HTMLImageElement} [description] - */ -var CanvasSnapshot = function (canvas, type, encoderOptions) -{ - if (type === undefined) { type = 'image/png'; } - if (encoderOptions === undefined) { encoderOptions = 0.92; } - - var src = canvas.toDataURL(type, encoderOptions); - - var image = new Image(); - - image.src = src; - - return image; -}; - -module.exports = CanvasSnapshot; - - -/***/ }), -/* 266 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var roundPixels = false; - -/** - * No scaling, anchor, rotation or effects, literally draws the frame directly to the canvas. - * - * @function Phaser.Renderer.Canvas.BlitImage - * @since 3.0.0 - * - * @param {number} dx - The x coordinate to render the Frame to. - * @param {number} dy - The y coordinate to render the Frame to. - * @param {Phaser.Textures.Frame} frame - The Frame to render. - */ -var BlitImage = function (dx, dy, frame) -{ - var ctx = this.currentContext; - var cd = frame.canvasData; - - if (roundPixels) - { - dx |= 0; - dy |= 0; - } - - ctx.drawImage( - frame.source.image, - cd.sx, - cd.sy, - cd.sWidth, - cd.sHeight, - dx, - dy, - cd.dWidth, - cd.dHeight - ); -}; - -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return BlitImage; -}; - - -/***/ }), -/* 267 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlitImage = __webpack_require__(266); -var CanvasSnapshot = __webpack_require__(265); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var DrawImage = __webpack_require__(264); -var GetBlendModes = __webpack_require__(263); -var ScaleModes = __webpack_require__(59); -var Smoothing = __webpack_require__(131); - -/** - * @classdesc - * [description] - * - * @class CanvasRenderer - * @memberOf Phaser.Renderer.Canvas - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. - */ -var CanvasRenderer = new Class({ - - initialize: - - function CanvasRenderer (game) - { - /** - * The Phaser Game instance that owns this renderer. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#game - * @type {Phaser.Game} - * @since 3.0.0 - */ - this.game = game; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#type - * @type {integer} - * @since 3.0.0 - */ - this.type = CONST.CANVAS; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.drawCount = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#width - * @type {number} - * @since 3.0.0 - */ - this.width = game.config.width; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#height - * @type {number} - * @since 3.0.0 - */ - this.height = game.config.height; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#config - * @type {RendererConfig} - * @since 3.0.0 - */ - this.config = { - clearBeforeRender: game.config.clearBeforeRender, - pixelArt: game.config.pixelArt, - backgroundColor: game.config.backgroundColor, - resolution: game.config.resolution, - autoResize: game.config.autoResize, - roundPixels: game.config.roundPixels - }; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode - * @type {integer} - * @since 3.0.0 - */ - this.scaleMode = (game.config.pixelArt) ? ScaleModes.NEAREST : ScaleModes.LINEAR; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas - * @type {HTMLCanvasElement} - * @since 3.0.0 - */ - this.gameCanvas = game.canvas; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.gameContext = (this.game.config.context) ? this.game.config.context : this.gameCanvas.getContext('2d'); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext - * @type {CanvasRenderingContext2D} - * @since 3.0.0 - */ - this.currentContext = this.gameContext; - - /** - * Map to the required function. - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawImage - * @type {function} - * @since 3.0.0 - */ - this.drawImage = DrawImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blitImage - * @type {function} - * @since 3.0.0 - */ - this.blitImage = BlitImage(this.config.roundPixels); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes - * @type {array} - * @since 3.0.0 - */ - this.blendModes = GetBlendModes(); - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.currentAlpha = 1; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentBlendMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentBlendMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScaleMode = 0; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback - * @type {?SnapshotCallback} - * @default null - * @since 3.0.0 - */ - this.snapshotCallback = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType - * @type {?string} - * @default null - * @since 3.0.0 - */ - this.snapshotType = null; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder - * @type {?number} - * @default null - * @since 3.0.0 - */ - this.snapshotEncoder = null; - - this.init(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#init - * @since 3.0.0 - */ - init: function () - { - this.resize(this.width, this.height); - }, - - /** - * Resize the main game canvas. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resize - * @since 3.0.0 - * - * @param {integer} width - [description] - * @param {integer} height - [description] - */ - resize: function (width, height) - { - var resolution = this.config.resolution; - - this.width = width * resolution; - this.height = height * resolution; - - this.gameCanvas.width = this.width; - this.gameCanvas.height = this.height; - - if (this.config.autoResize) - { - this.gameCanvas.style.width = (this.width / resolution) + 'px'; - this.gameCanvas.style.height = (this.height / resolution) + 'px'; - } - - // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) - if (this.scaleMode === ScaleModes.NEAREST) - { - Smoothing.disable(this.gameContext); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextLost: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored - * @since 3.0.0 - * - * @param {function} callback - [description] - */ - onContextRestored: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform - * @since 3.0.0 - */ - resetTransform: function () - { - this.currentContext.setTransform(1, 0, 0, 1, 0, 0); - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode - * @since 3.0.0 - * - * @param {number} blendMode - [description] - * - * @return {number} [description] - */ - setBlendMode: function (blendMode) - { - if (this.currentBlendMode !== blendMode) - { - this.currentContext.globalCompositeOperation = blendMode; - this.currentBlendMode = blendMode; - } - - return this.currentBlendMode; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha - * @since 3.0.0 - * - * @param {float} alpha - [description] - * - * @return {float} [description] - */ - setAlpha: function (alpha) - { - if (this.currentAlpha !== alpha) - { - this.currentContext.globalAlpha = alpha; - this.currentAlpha = alpha; - } - - return this.currentAlpha; - }, - - /** - * Called at the start of the render loop. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender - * @since 3.0.0 - */ - preRender: function () - { - var ctx = this.gameContext; - var config = this.config; - - var width = this.width; - var height = this.height; - - if (config.clearBeforeRender) - { - ctx.clearRect(0, 0, width, height); - } - - if (!config.transparent) - { - ctx.fillStyle = config.backgroundColor.rgba; - ctx.fillRect(0, 0, width, height); - } - - this.drawCount = 0; - }, - - /** - * Renders the Scene to the given Camera. - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#render - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.DisplayList} children - [description] - * @param {float} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - render: function (scene, children, interpolationPercentage, camera) - { - var ctx = scene.sys.context; - var scissor = (camera.x !== 0 || camera.y !== 0 || camera.width !== ctx.canvas.width || camera.height !== ctx.canvas.height); - var list = children.list; - var resolution = this.config.resolution; - - this.currentContext = ctx; - - // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) - - if (!camera.transparent) - { - ctx.fillStyle = camera.backgroundColor.rgba; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); - } - - if (this.currentAlpha !== 1) - { - ctx.globalAlpha = 1; - this.currentAlpha = 1; - } - - if (this.currentBlendMode !== 0) - { - ctx.globalCompositeOperation = 'source-over'; - this.currentBlendMode = 0; - } - - this.currentScaleMode = 0; - - this.drawCount += list.length; - - if (scissor) - { - ctx.save(); - ctx.beginPath(); - ctx.rect(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); - ctx.clip(); - } - - var matrix = camera.matrix.matrix; - - ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - - for (var c = 0; c < list.length; c++) - { - var child = list[c]; - - if (child.mask) - { - child.mask.preRenderCanvas(this, child, camera); - } - - child.renderCanvas(this, child, interpolationPercentage, camera); - - if (child.mask) - { - child.mask.postRenderCanvas(this, child, camera); - } - } - - ctx.setTransform(1, 0, 0, 1, 0, 0); - ctx.globalCompositeOperation = 'source-over'; - - camera.flashEffect.postRenderCanvas(ctx); - camera.fadeEffect.postRenderCanvas(ctx); - - // Reset the camera scissor - if (scissor) - { - ctx.restore(); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender - * @since 3.0.0 - */ - postRender: function () - { - var ctx = this.gameContext; - - ctx.globalAlpha = 1; - ctx.globalCompositeOperation = 'source-over'; - - this.currentAlpha = 1; - this.currentBlendMode = 0; - - if (this.snapshotCallback) - { - this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); - this.snapshotCallback = null; - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot - * @since 3.0.0 - * - * @param {SnapshotCallback} callback - [description] - * @param {string} type - [description] - * @param {number} encoderOptions - [description] - */ - snapshot: function (callback, type, encoderOptions) - { - this.snapshotCallback = callback; - this.snapshotType = type; - this.snapshotEncoder = encoderOptions; - }, - - /** - * [description] - * - * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.gameCanvas = null; - this.gameContext = null; - - this.game = null; - } - -}); - -module.exports = CanvasRenderer; - - -/***/ }), -/* 268 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var NOOP = __webpack_require__(3); - -/** - * @classdesc - * Abstracts away the use of RAF or setTimeOut for the core game update loop. - * This is invoked automatically by the Phaser.Game instance. - * - * @class RequestAnimationFrame - * @memberOf Phaser.DOM - * @constructor - * @since 3.0.0 - */ -var RequestAnimationFrame = new Class({ - - initialize: - - function RequestAnimationFrame () - { - /** - * True if RequestAnimationFrame is running, otherwise false. - * - * @name Phaser.DOM.RequestAnimationFrame#isRunning - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isRunning = false; - - /** - * The callback to be invoked each step. - * - * @name Phaser.DOM.RequestAnimationFrame#callback - * @type {FrameRequestCallback} - * @since 3.0.0 - */ - this.callback = NOOP; - - /** - * The most recent timestamp. Either a DOMHighResTimeStamp under RAF or `Date.now` under SetTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#tick - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tick = 0; - - /** - * True if the step is using setTimeout instead of RAF. - * - * @name Phaser.DOM.RequestAnimationFrame#isSetTimeOut - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isSetTimeOut = false; - - /** - * The setTimeout or RAF callback ID used when canceling them. - * - * @name Phaser.DOM.RequestAnimationFrame#timeOutID - * @type {?number} - * @default null - * @since 3.0.0 - */ - this.timeOutID = null; - - /** - * The previous time the step was called. - * - * @name Phaser.DOM.RequestAnimationFrame#lastTime - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.lastTime = 0; - - var _this = this; - - /** - * The RAF step function. - * Updates the local tick value, invokes the callback and schedules another call to requestAnimationFrame. - * - * @name Phaser.DOM.RequestAnimationFrame#step - * @type {FrameRequestCallback} - * @since 3.0.0 - */ - this.step = function step (timestamp) - { - // DOMHighResTimeStamp - _this.lastTime = _this.tick; - - _this.tick = timestamp; - - _this.callback(timestamp); - - _this.timeOutID = window.requestAnimationFrame(step); - }; - - /** - * The SetTimeout step function. - * Updates the local tick value, invokes the callback and schedules another call to setTimeout. - * - * @name Phaser.DOM.RequestAnimationFrame#stepTimeout - * @type {function} - * @since 3.0.0 - */ - this.stepTimeout = function stepTimeout () - { - var d = Date.now(); - - var delay = Math.max(16 + _this.lastTime - d, 0); - - _this.lastTime = _this.tick; - - _this.tick = d; - - _this.callback(d); - - _this.timeOutID = window.setTimeout(stepTimeout, delay); - }; - }, - - /** - * Starts the requestAnimationFrame or setTimeout process running. - * - * @method Phaser.DOM.RequestAnimationFrame#start - * @since 3.0.0 - * - * @param {FrameRequestCallback} callback - The callback to invoke each step. - * @param {boolean} forceSetTimeOut - Should it use SetTimeout, even if RAF is available? - */ - start: function (callback, forceSetTimeOut) - { - if (this.isRunning) - { - return; - } - - this.callback = callback; - - this.isSetTimeOut = forceSetTimeOut; - - this.isRunning = true; - - this.timeOutID = (forceSetTimeOut) ? window.setTimeout(this.stepTimeout, 0) : window.requestAnimationFrame(this.step); - }, +var Mask = { /** - * Stops the requestAnimationFrame or setTimeout from running. + * The Mask this Game Object is using during render. * - * @method Phaser.DOM.RequestAnimationFrame#stop + * @name Phaser.GameObjects.Components.Mask#mask + * @type {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} * @since 3.0.0 */ - stop: function () - { - this.isRunning = false; - - if (this.isSetTimeOut) - { - clearTimeout(this.timeOutID); - } - else - { - window.cancelAnimationFrame(this.timeOutID); - } - }, + mask: null, /** - * Stops the step from running and clears the callback reference. + * Sets the mask that this Game Object will use to render with. * - * @method Phaser.DOM.RequestAnimationFrame#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.stop(); - - this.callback = NOOP; - } - -}); - -module.exports = RequestAnimationFrame; - - -/***/ }), -/* 269 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Attempts to remove the element from its parentNode in the DOM. - * - * @function Phaser.DOM.RemoveFromDOM - * @since 3.0.0 - * - * @param {HTMLElement} element - The DOM element to remove from its parent node. - */ -var RemoveFromDOM = function (element) -{ - if (element.parentNode) - { - element.parentNode.removeChild(element); - } -}; - -module.exports = RemoveFromDOM; - - -/***/ }), -/* 270 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes the given data string and parses it as XML. - * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. - * The parsed XML object is returned, or `null` if there was an error while parsing the data. - * - * @function Phaser.DOM.ParseXML - * @since 3.0.0 - * - * @param {string} data - The XML source stored in a string. - * - * @return {?(DOMParser|ActiveXObject)} The parsed XML data, or `null` if the data could not be parsed. - */ -var ParseXML = function (data) -{ - var xml = ''; - - try - { - if (window['DOMParser']) - { - var domparser = new DOMParser(); - xml = domparser.parseFromString(data, 'text/xml'); - } - else - { - xml = new ActiveXObject('Microsoft.XMLDOM'); - xml.loadXML(data); - } - } - catch (e) - { - xml = null; - } - - if (!xml || !xml.documentElement || xml.getElementsByTagName('parsererror').length) - { - return null; - } - else - { - return xml; - } -}; - -module.exports = ParseXML; - - -/***/ }), -/* 271 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var OS = __webpack_require__(57); - -/** - * @callback ContentLoadedCallback - */ - -/** - * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. - * If not complete it sets up several event listeners such as `deviceready`, and once those fire, it invokes the callback. - * Called automatically by the Phaser.Game instance. Should not usually be accessed directly. - * - * @function Phaser.DOM.DOMContentLoaded - * @since 3.0.0 - * - * @param {ContentLoadedCallback} callback - The callback to be invoked when the device is ready and the DOM content is loaded. - */ -var DOMContentLoaded = function (callback) -{ - if (document.readyState === 'complete' || document.readyState === 'interactive') - { - callback(); - - return; - } - - var check = function () - { - document.removeEventListener('deviceready', check, true); - document.removeEventListener('DOMContentLoaded', check, true); - window.removeEventListener('load', check, true); - - callback(); - }; - - if (!document.body) - { - window.setTimeout(check, 20); - } - else if (OS.cordova && !OS.cocoonJS) - { - // Ref. http://docs.phonegap.com/en/3.5.0/cordova_events_events.md.html#deviceready - document.addEventListener('deviceready', check, false); - } - else - { - document.addEventListener('DOMContentLoaded', check, true); - window.addEventListener('load', check, true); - } -}; - -module.exports = DOMContentLoaded; - - -/***/ }), -/* 272 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Canvas.CanvasInterpolation - * @since 3.0.0 - */ -var CanvasInterpolation = { - - /** - * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast' on webkit). + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * - * @function Phaser.Display.Canvas.CanvasInterpolation.setCrisp - * @since 3.0.0 + * If a mask is already set on this Game Object it will be immediately replaced. * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. * - * @return {HTMLCanvasElement} The canvas. + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * + * @method Phaser.GameObjects.Components.Mask#setMask + * @since 3.6.2 + * + * @param {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} mask - The mask this Game Object will use when rendering. + * + * @return {this} This Game Object instance. */ - setCrisp: function (canvas) + setMask: function (mask) { - var types = [ 'optimizeSpeed', 'crisp-edges', '-moz-crisp-edges', '-webkit-optimize-contrast', 'optimize-contrast', 'pixelated' ]; + this.mask = mask; - types.forEach(function (type) - { - canvas.style['image-rendering'] = type; - }); - - canvas.style.msInterpolationMode = 'nearest-neighbor'; - - return canvas; + return this; }, /** - * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). + * Clears the mask that this Game Object was using. * - * @function Phaser.Display.Canvas.CanvasInterpolation.setBicubic - * @since 3.0.0 + * @method Phaser.GameObjects.Components.Mask#clearMask + * @since 3.6.2 + * + * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? + * + * @return {this} This Game Object instance. + */ + clearMask: function (destroyMask) + { + if (destroyMask === undefined) { destroyMask = false; } + + if (destroyMask && this.mask) + { + this.mask.destroy(); + } + + this.mask = null; + + return this; + }, + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * + * @method Phaser.GameObjects.Components.Mask#createBitmapMask + * @since 3.6.2 * - * @param {HTMLCanvasElement} canvas - The canvas object to have the style set on. + * @param {Phaser.GameObjects.GameObject} [renderable] - A renderable Game Object that uses a texture, such as a Sprite. + * + * @return {Phaser.Display.Masks.BitmapMask} This Bitmap Mask that was created. + */ + createBitmapMask: function (renderable) + { + if (renderable === undefined && this.texture) + { + // eslint-disable-next-line consistent-this + renderable = this; + } + + return new BitmapMask(this.scene, renderable); + }, + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. * - * @return {HTMLCanvasElement} The canvas. + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * + * @method Phaser.GameObjects.Components.Mask#createGeometryMask + * @since 3.6.2 + * + * @param {Phaser.GameObjects.Graphics} [graphics] - A Graphics Game Object. The geometry within it will be used as the mask. + * + * @return {Phaser.Display.Masks.GeometryMask} This Geometry Mask that was created. */ - setBicubic: function (canvas) + createGeometryMask: function (graphics) { - canvas.style['image-rendering'] = 'auto'; - canvas.style.msInterpolationMode = 'bicubic'; + if (graphics === undefined && this.type === 'Graphics') + { + // eslint-disable-next-line consistent-this + graphics = this; + } - return canvas; + return new GeometryMask(this.scene, graphics); } }; -module.exports = CanvasInterpolation; +module.exports = Mask; /***/ }), -/* 273 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates a Catmull-Rom value. - * - * @function Phaser.Math.CatmullRom - * @since 3.0.0 - * - * @param {number} t - [description] - * @param {number} p0 - [description] - * @param {number} p1 - [description] - * @param {number} p2 - [description] - * @param {number} p3 - [description] - * - * @return {number} The Catmull-Rom value. - */ -var CatmullRom = function (t, p0, p1, p2, p3) -{ - var v0 = (p2 - p0) * 0.5; - var v1 = (p3 - p1) * 0.5; - var t2 = t * t; - var t3 = t * t2; - - return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; -}; - -module.exports = CatmullRom; - - -/***/ }), -/* 274 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -// points is an array of Point-like objects, -// either 2 dimensional arrays, or objects with public x/y properties: -// var points = [ -// [100, 200], -// [200, 400], -// { x: 30, y: 60 } -// ] - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.FromPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {array} points - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var FromPoints = function (points, out) -{ - if (out === undefined) { out = new Rectangle(); } - - if (points.length === 0) - { - return out; - } - - var minX = Number.MAX_VALUE; - var minY = Number.MAX_VALUE; - - var maxX = Number.MIN_SAFE_INTEGER; - var maxY = Number.MIN_SAFE_INTEGER; - - var p; - var px; - var py; - - for (var i = 0; i < points.length; i++) - { - p = points[i]; - - if (Array.isArray(p)) - { - px = p[0]; - py = p[1]; - } - else - { - px = p.x; - py = p.y; - } - - minX = Math.min(minX, px); - minY = Math.min(minY, py); - - maxX = Math.max(maxX, px); - maxY = Math.max(maxY, py); - } - - out.x = minX; - out.y = minY; - out.width = maxX - minX; - out.height = maxY - minY; - - return out; -}; - -module.exports = FromPoints; - - -/***/ }), -/* 275 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * A 16 color palette by [Arne](http://androidarts.com/palette/16pal.htm) - * - * @name Phaser.Create.Palettes.ARNE16 - * @since 3.0.0 - * - * @type {Palette} - */ -module.exports = { - 0: '#000', - 1: '#9D9D9D', - 2: '#FFF', - 3: '#BE2633', - 4: '#E06F8B', - 5: '#493C2B', - 6: '#A46422', - 7: '#EB8931', - 8: '#F7E26B', - 9: '#2F484E', - A: '#44891A', - B: '#A3CE27', - C: '#1B2632', - D: '#005784', - E: '#31A2F2', - F: '#B2DCEF' -}; - - -/***/ }), -/* 276 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Arne16 = __webpack_require__(275); -var CanvasPool = __webpack_require__(22); -var GetValue = __webpack_require__(4); - -/** - * @callback GenerateTextureRendererCallback - * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] - */ - -/** - * @typedef {object} GenerateTextureConfig - * - * @property {array} [data=[]] - [description] - * @property {HTMLCanvasElement} [canvas=null] - [description] - * @property {Palette} [palette=Arne16] - [description] - * @property {number} [pixelWidth=1] - [description] - * @property {number} [pixelHeight=1] - [description] - * @property {boolean} [resizeCanvas=true] - [description] - * @property {boolean} [clearCanvas=true] - [description] - * @property {GenerateTextureRendererCallback} [preRender] - [description] - * @property {GenerateTextureRendererCallback} [postRender] - [description] - */ - -/** - * [description] - * - * @function Phaser.Create.GenerateTexture - * @since 3.0.0 - * - * @param {GenerateTextureConfig} config - [description] - * - * @return {HTMLCanvasElement} [description] - */ -var GenerateTexture = function (config) -{ - var data = GetValue(config, 'data', []); - var canvas = GetValue(config, 'canvas', null); - var palette = GetValue(config, 'palette', Arne16); - var pixelWidth = GetValue(config, 'pixelWidth', 1); - var pixelHeight = GetValue(config, 'pixelHeight', pixelWidth); - var resizeCanvas = GetValue(config, 'resizeCanvas', true); - var clearCanvas = GetValue(config, 'clearCanvas', true); - var preRender = GetValue(config, 'preRender', null); - var postRender = GetValue(config, 'postRender', null); - - var width = Math.floor(Math.abs(data[0].length * pixelWidth)); - var height = Math.floor(Math.abs(data.length * pixelHeight)); - - if (!canvas) - { - canvas = CanvasPool.create2D(this, width, height); - resizeCanvas = false; - clearCanvas = false; - } - - if (resizeCanvas) - { - canvas.width = width; - canvas.height = height; - } - - var ctx = canvas.getContext('2d'); - - if (clearCanvas) - { - ctx.clearRect(0, 0, width, height); - } - - // preRender Callback? - if (preRender) - { - preRender(canvas, ctx); - } - - // Draw it - for (var y = 0; y < data.length; y++) - { - var row = data[y]; - - for (var x = 0; x < row.length; x++) - { - var d = row[x]; - - if (d !== '.' && d !== ' ') - { - ctx.fillStyle = palette[d]; - ctx.fillRect(x * pixelWidth, y * pixelHeight, pixelWidth, pixelHeight); - } - } - } - - // postRender Callback? - if (postRender) - { - postRender(canvas, ctx); - } - - return canvas; -}; - -module.exports = GenerateTexture; - - -/***/ }), -/* 277 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A representation of a vector in 4D space. - * - * A four-component vector. - * - * @class Vector4 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - The x component. - * @param {number} [y] - The y component. - * @param {number} [z] - The z component. - * @param {number} [w] - The w component. - */ -var Vector4 = new Class({ - - initialize: - - function Vector4 (x, y, z, w) - { - /** - * The x component of this Vector. - * - * @name Phaser.Math.Vector4#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The y component of this Vector. - * - * @name Phaser.Math.Vector4#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The z component of this Vector. - * - * @name Phaser.Math.Vector4#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.z = 0; - - /** - * The w component of this Vector. - * - * @name Phaser.Math.Vector4#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.w = 0; - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - }, - - /** - * Make a clone of this Vector4. - * - * @method Phaser.Math.Vector4#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} A clone of this Vector4. - */ - clone: function () - { - return new Vector4(this.x, this.y, this.z, this.w); - }, - - /** - * Copy the components of a given Vector into this Vector. - * - * @method Phaser.Math.Vector4#copy - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} src - The Vector to copy the components from. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z || 0; - this.w = src.w || 0; - - return this; - }, - - /** - * Check whether this Vector is equal to a given Vector. - * - * Performs a strict quality check against each Vector's components. - * - * @method Phaser.Math.Vector4#equals - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} v - [description] - * - * @return {boolean} [description] - */ - equals: function (v) - { - return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); - }, - - /** - * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. - * - * @method Phaser.Math.Vector4#set - * @since 3.0.0 - * - * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y, z and w components. - * @param {number} y - The y value to set for this Vector. - * @param {number} z - The z value to set for this Vector. - * @param {number} w - The z value to set for this Vector. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - set: function (x, y, z, w) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - - return this; - }, - - /** - * Add a given Vector to this Vector. Addition is component-wise. - * - * @method Phaser.Math.Vector4#add - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to add to this Vector. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z || 0; - this.w += v.w || 0; - - return this; - }, - - /** - * Subtract the given Vector from this Vector. Subtraction is component-wise. - * - * @method Phaser.Math.Vector4#subtract - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to subtract from this Vector. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z || 0; - this.w -= v.w || 0; - - return this; - }, - - /** - * Scale this Vector by the given value. - * - * @method Phaser.Math.Vector4#scale - * @since 3.0.0 - * - * @param {number} scale - The value to scale this Vector by. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - scale: function (scale) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - this.w *= scale; - - return this; - }, - - /** - * Calculate the length (or magnitude) of this Vector. - * - * @method Phaser.Math.Vector4#length - * @since 3.0.0 - * - * @return {number} The length of this Vector. - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return Math.sqrt(x * x + y * y + z * z + w * w); - }, - - /** - * Calculate the length of this Vector squared. - * - * @method Phaser.Math.Vector4#lengthSq - * @since 3.0.0 - * - * @return {number} The length of this Vector, squared. - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return x * x + y * y + z * z + w * w; - }, - - /** - * Normalize this Vector. - * - * Makes the vector a unit length vector (magnitude of 1) in the same direction. - * - * @method Phaser.Math.Vector4#normalize - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var len = x * x + y * y + z * z + w * w; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - this.w = w * len; - } - - return this; - }, - - /** - * Calculate the dot product of this Vector and the given Vector. - * - * @method Phaser.Math.Vector4#dot - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} v - The Vector4 to dot product with this Vector4. - * - * @return {number} The dot product of this Vector and the given Vector. - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; - }, - - /** - * Linearly interpolate between this Vector and the given Vector. - * - * Interpolates this Vector towards the given Vector. - * - * @method Phaser.Math.Vector4#lerp - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} v - The Vector4 to interpolate towards. - * @param {number} [t=0] - The interpolation percentage, between 0 and 1. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - this.w = aw + t * (v.w - aw); - - return this; - }, - - /** - * Perform a component-wise multiplication between this Vector and the given Vector. - * - * Multiplies this Vector by the given Vector. - * - * @method Phaser.Math.Vector4#multiply - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to multiply this Vector by. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - multiply: function (v) - { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z || 1; - this.w *= v.w || 1; - - return this; - }, - - /** - * Perform a component-wise division between this Vector and the given Vector. - * - * Divides this Vector by the given Vector. - * - * @method Phaser.Math.Vector4#divide - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to divide this Vector by. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - divide: function (v) - { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z || 1; - this.w /= v.w || 1; - - return this; - }, - - /** - * Calculate the distance between this Vector and the given Vector. - * - * @method Phaser.Math.Vector4#distance - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] - * - * @return {number} The distance from this Vector to the given Vector. - */ - distance: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - var dw = v.w - this.w || 0; - - return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); - }, - - /** - * Calculate the distance between this Vector, and the given Vector, squared. - * - * @method Phaser.Math.Vector4#distanceSq - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. - * - * @return {number} The distance from this Vector to the given Vector, squared. - */ - distanceSq: function (v) - { - var dx = v.x - this.x; - var dy = v.y - this.y; - var dz = v.z - this.z || 0; - var dw = v.w - this.w || 0; - - return dx * dx + dy * dy + dz * dz + dw * dw; - }, - - /** - * Negate the `x`, `y`, `z` and `w` components of this Vector. - * - * @method Phaser.Math.Vector4#negate - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - negate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - this.w = -this.w; - - return this; - }, - - /** - * Transform this Vector with the given Matrix. - * - * @method Phaser.Math.Vector4#transformMat4 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector4 with. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - transformMat4: function (mat) - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var m = mat.val; - - this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; - this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; - this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; - this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; - - return this; - }, - - /** - * Transform this Vector with the given Quaternion. - * - * @method Phaser.Math.Vector4#transformQuat - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - transformQuat: function (q) - { - // TODO: is this really the same as Vector3? - // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ - // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations - var x = this.x; - var y = this.y; - var z = this.z; - var qx = q.x; - var qy = q.y; - var qz = q.z; - var qw = q.w; - - // calculate quat * vec - var ix = qw * x + qy * z - qz * y; - var iy = qw * y + qz * x - qx * z; - var iz = qw * z + qx * y - qy * x; - var iw = -qx * x - qy * y - qz * z; - - // calculate result * inverse quat - this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; - this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; - this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; - - return this; - }, - - /** - * Make this Vector the zero vector (0, 0, 0, 0). - * - * @method Phaser.Math.Vector4#reset - * @since 3.0.0 - * - * @return {Phaser.Math.Vector4} This Vector4. - */ - reset: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 0; - - return this; - } - -}); - -// TODO: Check if these are required internally, if not, remove. -Vector4.prototype.sub = Vector4.prototype.subtract; -Vector4.prototype.mul = Vector4.prototype.multiply; -Vector4.prototype.div = Vector4.prototype.divide; -Vector4.prototype.dist = Vector4.prototype.distance; -Vector4.prototype.distSq = Vector4.prototype.distanceSq; -Vector4.prototype.len = Vector4.prototype.length; -Vector4.prototype.lenSq = Vector4.prototype.lengthSq; - -module.exports = Vector4; - - -/***/ }), -/* 278 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -var EPSILON = 0.000001; - -/** - * @classdesc - * A four-dimensional matrix. - * - * @class Matrix4 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} [m] - Optional Matrix4 to copy values from. - */ -var Matrix4 = new Class({ - - initialize: - - function Matrix4 (m) - { - /** - * The matrix values. - * - * @name Phaser.Math.Matrix4#val - * @type {Float32Array} - * @since 3.0.0 - */ - this.val = new Float32Array(16); - - if (m) - { - // Assume Matrix4 with val: - this.copy(m); - } - else - { - // Default to identity - this.identity(); - } - }, - - /** - * Make a clone of this Matrix4. - * - * @method Phaser.Math.Matrix4#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} A clone of this Matrix4. - */ - clone: function () - { - return new Matrix4(this); - }, - - // TODO - Should work with basic values - - /** - * This method is an alias for `Matrix4.copy`. - * - * @method Phaser.Math.Matrix4#set - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} src - The Matrix to set the values of this Matrix's from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - set: function (src) - { - return this.copy(src); - }, - - /** - * Copy the values of a given Matrix into this Matrix. - * - * @method Phaser.Math.Matrix4#copy - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} src - The Matrix to copy the values from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - copy: function (src) - { - var out = this.val; - var a = src.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - - return this; - }, - - /** - * Set the values of this Matrix from the given array. - * - * @method Phaser.Math.Matrix4#fromArray - * @since 3.0.0 - * - * @param {array} a - The array to copy the values from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - fromArray: function (a) - { - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - out[9] = a[9]; - out[10] = a[10]; - out[11] = a[11]; - out[12] = a[12]; - out[13] = a[13]; - out[14] = a[14]; - out[15] = a[15]; - - return this; - }, - - /** - * Reset this Matrix. - * - * Sets all values to `0`. - * - * @method Phaser.Math.Matrix4#zero - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - zero: function () - { - var out = this.val; - - out[0] = 0; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 0; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 0; - - return this; - }, - - /** - * Set the `x`, `y` and `z` values of this Matrix. - * - * @method Phaser.Math.Matrix4#xyz - * @since 3.0.0 - * - * @param {number} x - The x value. - * @param {number} y - The y value. - * @param {number} z - The z value. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - xyz: function (x, y, z) - { - this.identity(); - - var out = this.val; - - out[12] = x; - out[13] = y; - out[14] = z; - - return this; - }, - - /** - * Set the scaling values of this Matrix. - * - * @method Phaser.Math.Matrix4#scaling - * @since 3.0.0 - * - * @param {number} x - The x scaling value. - * @param {number} y - The y scaling value. - * @param {number} z - The z scaling value. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - scaling: function (x, y, z) - { - this.zero(); - - var out = this.val; - - out[0] = x; - out[5] = y; - out[10] = z; - out[15] = 1; - - return this; - }, - - /** - * Reset this Matrix to an identity (default) matrix. - * - * @method Phaser.Math.Matrix4#identity - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - identity: function () - { - var out = this.val; - - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 0; - out[5] = 1; - out[6] = 0; - out[7] = 0; - out[8] = 0; - out[9] = 0; - out[10] = 1; - out[11] = 0; - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - return this; - }, - - /** - * Transpose this Matrix. - * - * @method Phaser.Math.Matrix4#transpose - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - transpose: function () - { - var a = this.val; - - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - var a12 = a[6]; - var a13 = a[7]; - var a23 = a[11]; - - a[1] = a[4]; - a[2] = a[8]; - a[3] = a[12]; - a[4] = a01; - a[6] = a[9]; - a[7] = a[13]; - a[8] = a02; - a[9] = a12; - a[11] = a[14]; - a[12] = a03; - a[13] = a13; - a[14] = a23; - - return this; - }, - - /** - * Invert this Matrix. - * - * @method Phaser.Math.Matrix4#invert - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - invert: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) - { - return null; - } - - det = 1 / det; - - a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; - a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; - a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; - a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; - a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; - a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; - a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; - - return this; - }, - - /** - * Calculate the adjoint, or adjugate, of this Matrix. - * - * @method Phaser.Math.Matrix4#adjoint - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - adjoint: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); - a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); - a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); - a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); - a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); - a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); - a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); - a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); - a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); - a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); - a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); - a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); - a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); - a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); - a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); - a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); - - return this; - }, - - /** - * Calculate the determinant of this Matrix. - * - * @method Phaser.Math.Matrix4#determinant - * @since 3.0.0 - * - * @return {number} The determinant of this Matrix. - */ - determinant: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - }, - - /** - * Multiply this Matrix by the given Matrix. - * - * @method Phaser.Math.Matrix4#multiply - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} src - The Matrix to multiply this Matrix by. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - multiply: function (src) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b = src.val; - - // Cache only the current line of the second matrix - var b0 = b[0]; - var b1 = b[1]; - var b2 = b[2]; - var b3 = b[3]; - - a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[4]; - b1 = b[5]; - b2 = b[6]; - b3 = b[7]; - - a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[8]; - b1 = b[9]; - b2 = b[10]; - b3 = b[11]; - - a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - b0 = b[12]; - b1 = b[13]; - b2 = b[14]; - b3 = b[15]; - - a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; - a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; - a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; - a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix4#multiplyLocal - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} src - [description] - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - multiplyLocal: function (src) - { - var a = []; - var m1 = this.val; - var m2 = src.val; - - a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; - a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; - a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; - a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; - - a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; - a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; - a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; - a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; - - a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; - a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; - a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; - a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; - - a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; - a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; - a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; - a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; - - return this.fromArray(a); - }, - - /** - * Translate this Matrix using the given Vector. - * - * @method Phaser.Math.Matrix4#translate - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - translate: function (v) - { - var x = v.x; - var y = v.y; - var z = v.z; - var a = this.val; - - a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; - a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; - a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; - a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; - - return this; - }, - - /** - * Apply a scale transformation to this Matrix. - * - * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix. - * - * @method Phaser.Math.Matrix4#scale - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - scale: function (v) - { - var x = v.x; - var y = v.y; - var z = v.z; - var a = this.val; - - a[0] = a[0] * x; - a[1] = a[1] * x; - a[2] = a[2] * x; - a[3] = a[3] * x; - - a[4] = a[4] * y; - a[5] = a[5] * y; - a[6] = a[6] * y; - a[7] = a[7] * y; - - a[8] = a[8] * z; - a[9] = a[9] * z; - a[10] = a[10] * z; - a[11] = a[11] * z; - - return this; - }, - - /** - * Derive a rotation matrix around the given axis. - * - * @method Phaser.Math.Matrix4#makeRotationAxis - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis. - * @param {float} angle - The rotation angle in radians. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - makeRotationAxis: function (axis, angle) - { - // Based on http://www.gamedev.net/reference/articles/article1199.asp - - var c = Math.cos(angle); - var s = Math.sin(angle); - var t = 1 - c; - var x = axis.x; - var y = axis.y; - var z = axis.z; - var tx = t * x; - var ty = t * y; - - this.fromArray([ - tx * x + c, tx * y - s * z, tx * z + s * y, 0, - tx * y + s * z, ty * y + c, ty * z - s * x, 0, - tx * z - s * y, ty * z + s * x, t * z * z + c, 0, - 0, 0, 0, 1 - ]); - - return this; - }, - - /** - * Apply a rotation transformation to this Matrix. - * - * @method Phaser.Math.Matrix4#rotate - * @since 3.0.0 - * - * @param {float} rad - The angle in radians to rotate by. - * @param {Phaser.Math.Vector3} axis - The axis to rotate upon. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - rotate: function (rad, axis) - { - var a = this.val; - var x = axis.x; - var y = axis.y; - var z = axis.z; - var len = Math.sqrt(x * x + y * y + z * z); - - if (Math.abs(len) < EPSILON) - { - return null; - } - - len = 1 / len; - x *= len; - y *= len; - z *= len; - - var s = Math.sin(rad); - var c = Math.cos(rad); - var t = 1 - c; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Construct the elements of the rotation matrix - var b00 = x * x * t + c; - var b01 = y * x * t + z * s; - var b02 = z * x * t - y * s; - - var b10 = x * y * t - z * s; - var b11 = y * y * t + c; - var b12 = z * y * t + x * s; - - var b20 = x * z * t + y * s; - var b21 = y * z * t - x * s; - var b22 = z * z * t + c; - - // Perform rotation-specific matrix multiplication - a[0] = a00 * b00 + a10 * b01 + a20 * b02; - a[1] = a01 * b00 + a11 * b01 + a21 * b02; - a[2] = a02 * b00 + a12 * b01 + a22 * b02; - a[3] = a03 * b00 + a13 * b01 + a23 * b02; - a[4] = a00 * b10 + a10 * b11 + a20 * b12; - a[5] = a01 * b10 + a11 * b11 + a21 * b12; - a[6] = a02 * b10 + a12 * b11 + a22 * b12; - a[7] = a03 * b10 + a13 * b11 + a23 * b12; - a[8] = a00 * b20 + a10 * b21 + a20 * b22; - a[9] = a01 * b20 + a11 * b21 + a21 * b22; - a[10] = a02 * b20 + a12 * b21 + a22 * b22; - a[11] = a03 * b20 + a13 * b21 + a23 * b22; - - return this; - }, - - /** - * Rotate this matrix on its X axis. - * - * @method Phaser.Math.Matrix4#rotateX - * @since 3.0.0 - * - * @param {float} rad - The angle in radians to rotate by. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - rotateX: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Perform axis-specific matrix multiplication - a[4] = a10 * c + a20 * s; - a[5] = a11 * c + a21 * s; - a[6] = a12 * c + a22 * s; - a[7] = a13 * c + a23 * s; - a[8] = a20 * c - a10 * s; - a[9] = a21 * c - a11 * s; - a[10] = a22 * c - a12 * s; - a[11] = a23 * c - a13 * s; - - return this; - }, - - /** - * Rotate this matrix on its Y axis. - * - * @method Phaser.Math.Matrix4#rotateY - * @since 3.0.0 - * - * @param {float} rad - The angle to rotate by, in radians. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - rotateY: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - // Perform axis-specific matrix multiplication - a[0] = a00 * c - a20 * s; - a[1] = a01 * c - a21 * s; - a[2] = a02 * c - a22 * s; - a[3] = a03 * c - a23 * s; - a[8] = a00 * s + a20 * c; - a[9] = a01 * s + a21 * c; - a[10] = a02 * s + a22 * c; - a[11] = a03 * s + a23 * c; - - return this; - }, - - /** - * Rotate this matrix on its Z axis. - * - * @method Phaser.Math.Matrix4#rotateZ - * @since 3.0.0 - * - * @param {float} rad - The angle to rotate by, in radians. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - rotateZ: function (rad) - { - var a = this.val; - var s = Math.sin(rad); - var c = Math.cos(rad); - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - // Perform axis-specific matrix multiplication - a[0] = a00 * c + a10 * s; - a[1] = a01 * c + a11 * s; - a[2] = a02 * c + a12 * s; - a[3] = a03 * c + a13 * s; - a[4] = a10 * c - a00 * s; - a[5] = a11 * c - a01 * s; - a[6] = a12 * c - a02 * s; - a[7] = a13 * c - a03 * s; - - return this; - }, - - /** - * Set the values of this Matrix from the given rotation Quaternion and translation Vector. - * - * @method Phaser.Math.Matrix4#fromRotationTranslation - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to set rotation from. - * @param {Phaser.Math.Vector3} v - The Vector to set translation from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - fromRotationTranslation: function (q, v) - { - // Quaternion math - var out = this.val; - - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - - out[12] = v.x; - out[13] = v.y; - out[14] = v.z; - out[15] = 1; - - return this; - }, - - /** - * Set the values of this Matrix from the given Quaternion. - * - * @method Phaser.Math.Matrix4#fromQuat - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - fromQuat: function (q) - { - var out = this.val; - - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - out[0] = 1 - (yy + zz); - out[1] = xy + wz; - out[2] = xz - wy; - out[3] = 0; - - out[4] = xy - wz; - out[5] = 1 - (xx + zz); - out[6] = yz + wx; - out[7] = 0; - - out[8] = xz + wy; - out[9] = yz - wx; - out[10] = 1 - (xx + yy); - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - return this; - }, - - /** - * Generate a frustum matrix with the given bounds. - * - * @method Phaser.Math.Matrix4#frustum - * @since 3.0.0 - * - * @param {number} left - The left bound of the frustum. - * @param {number} right - The right bound of the frustum. - * @param {number} bottom - The bottom bound of the frustum. - * @param {number} top - The top bound of the frustum. - * @param {number} near - The near bound of the frustum. - * @param {number} far - The far bound of the frustum. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - frustum: function (left, right, bottom, top, near, far) - { - var out = this.val; - - var rl = 1 / (right - left); - var tb = 1 / (top - bottom); - var nf = 1 / (near - far); - - out[0] = (near * 2) * rl; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = (near * 2) * tb; - out[6] = 0; - out[7] = 0; - - out[8] = (right + left) * rl; - out[9] = (top + bottom) * tb; - out[10] = (far + near) * nf; - out[11] = -1; - - out[12] = 0; - out[13] = 0; - out[14] = (far * near * 2) * nf; - out[15] = 0; - - return this; - }, - - /** - * Generate a perspective projection matrix with the given bounds. - * - * @method Phaser.Math.Matrix4#perspective - * @since 3.0.0 - * - * @param {number} fovy - Vertical field of view in radians - * @param {number} aspect - Aspect ratio. Typically viewport width /height. - * @param {number} near - Near bound of the frustum. - * @param {number} far - Far bound of the frustum. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - perspective: function (fovy, aspect, near, far) - { - var out = this.val; - var f = 1.0 / Math.tan(fovy / 2); - var nf = 1 / (near - far); - - out[0] = f / aspect; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = f; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = (far + near) * nf; - out[11] = -1; - - out[12] = 0; - out[13] = 0; - out[14] = (2 * far * near) * nf; - out[15] = 0; - - return this; - }, - - /** - * Generate a perspective projection matrix with the given bounds. - * - * @method Phaser.Math.Matrix4#perspectiveLH - * @since 3.0.0 - * - * @param {number} width - The width of the frustum. - * @param {number} height - The height of the frustum. - * @param {number} near - Near bound of the frustum. - * @param {number} far - Far bound of the frustum. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - perspectiveLH: function (width, height, near, far) - { - var out = this.val; - - out[0] = (2 * near) / width; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = (2 * near) / height; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = -far / (near - far); - out[11] = 1; - - out[12] = 0; - out[13] = 0; - out[14] = (near * far) / (near - far); - out[15] = 0; - - return this; - }, - - /** - * Generate an orthogonal projection matrix with the given bounds. - * - * @method Phaser.Math.Matrix4#ortho - * @since 3.0.0 - * - * @param {number} left - The left bound of the frustum. - * @param {number} right - The right bound of the frustum. - * @param {number} bottom - The bottom bound of the frustum. - * @param {number} top - The top bound of the frustum. - * @param {number} near - The near bound of the frustum. - * @param {number} far - The far bound of the frustum. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - ortho: function (left, right, bottom, top, near, far) - { - var out = this.val; - var lr = left - right; - var bt = bottom - top; - var nf = near - far; - - // Avoid division by zero - lr = (lr === 0) ? lr : 1 / lr; - bt = (bt === 0) ? bt : 1 / bt; - nf = (nf === 0) ? nf : 1 / nf; - - out[0] = -2 * lr; - out[1] = 0; - out[2] = 0; - out[3] = 0; - - out[4] = 0; - out[5] = -2 * bt; - out[6] = 0; - out[7] = 0; - - out[8] = 0; - out[9] = 0; - out[10] = 2 * nf; - out[11] = 0; - - out[12] = (left + right) * lr; - out[13] = (top + bottom) * bt; - out[14] = (far + near) * nf; - out[15] = 1; - - return this; - }, - - /** - * Generate a look-at matrix with the given eye position, focal point, and up axis. - * - * @method Phaser.Math.Matrix4#lookAt - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} eye - Position of the viewer - * @param {Phaser.Math.Vector3} center - Point the viewer is looking at - * @param {Phaser.Math.Vector3} up - vec3 pointing up. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - lookAt: function (eye, center, up) - { - var out = this.val; - - var eyex = eye.x; - var eyey = eye.y; - var eyez = eye.z; - - var upx = up.x; - var upy = up.y; - var upz = up.z; - - var centerx = center.x; - var centery = center.y; - var centerz = center.z; - - if (Math.abs(eyex - centerx) < EPSILON && - Math.abs(eyey - centery) < EPSILON && - Math.abs(eyez - centerz) < EPSILON) - { - return this.identity(); - } - - var z0 = eyex - centerx; - var z1 = eyey - centery; - var z2 = eyez - centerz; - - var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); - - z0 *= len; - z1 *= len; - z2 *= len; - - var x0 = upy * z2 - upz * z1; - var x1 = upz * z0 - upx * z2; - var x2 = upx * z1 - upy * z0; - - len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); - - if (!len) - { - x0 = 0; - x1 = 0; - x2 = 0; - } - else - { - len = 1 / len; - x0 *= len; - x1 *= len; - x2 *= len; - } - - var y0 = z1 * x2 - z2 * x1; - var y1 = z2 * x0 - z0 * x2; - var y2 = z0 * x1 - z1 * x0; - - len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); - - if (!len) - { - y0 = 0; - y1 = 0; - y2 = 0; - } - else - { - len = 1 / len; - y0 *= len; - y1 *= len; - y2 *= len; - } - - out[0] = x0; - out[1] = y0; - out[2] = z0; - out[3] = 0; - - out[4] = x1; - out[5] = y1; - out[6] = z1; - out[7] = 0; - - out[8] = x2; - out[9] = y2; - out[10] = z2; - out[11] = 0; - - out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); - out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); - out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); - out[15] = 1; - - return this; - }, - - /** - * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values. - * - * @method Phaser.Math.Matrix4#yawPitchRoll - * @since 3.0.0 - * - * @param {number} yaw - [description] - * @param {number} pitch - [description] - * @param {number} roll - [description] - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - yawPitchRoll: function (yaw, pitch, roll) - { - this.zero(); - _tempMat1.zero(); - _tempMat2.zero(); - - var m0 = this.val; - var m1 = _tempMat1.val; - var m2 = _tempMat2.val; - - // Rotate Z - var s = Math.sin(roll); - var c = Math.cos(roll); - - m0[10] = 1; - m0[15] = 1; - m0[0] = c; - m0[1] = s; - m0[4] = -s; - m0[5] = c; - - // Rotate X - s = Math.sin(pitch); - c = Math.cos(pitch); - - m1[0] = 1; - m1[15] = 1; - m1[5] = c; - m1[10] = c; - m1[9] = -s; - m1[6] = s; - - // Rotate Y - s = Math.sin(yaw); - c = Math.cos(yaw); - - m2[5] = 1; - m2[15] = 1; - m2[0] = c; - m2[2] = -s; - m2[8] = s; - m2[10] = c; - - this.multiplyLocal(_tempMat1); - this.multiplyLocal(_tempMat2); - - return this; - }, - - /** - * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix. - * - * @method Phaser.Math.Matrix4#setWorldMatrix - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} rotation - The rotation of the world matrix. - * @param {Phaser.Math.Vector3} position - The position of the world matrix. - * @param {Phaser.Math.Vector3} scale - The scale of the world matrix. - * @param {Phaser.Math.Matrix4} [viewMatrix] - The view matrix. - * @param {Phaser.Math.Matrix4} [projectionMatrix] - The projection matrix. - * - * @return {Phaser.Math.Matrix4} This Matrix4. - */ - setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) - { - this.yawPitchRoll(rotation.y, rotation.x, rotation.z); - - _tempMat1.scaling(scale.x, scale.y, scale.z); - _tempMat2.xyz(position.x, position.y, position.z); - - this.multiplyLocal(_tempMat1); - this.multiplyLocal(_tempMat2); - - if (viewMatrix !== undefined) - { - this.multiplyLocal(viewMatrix); - } - - if (projectionMatrix !== undefined) - { - this.multiplyLocal(projectionMatrix); - } - - return this; - } - -}); - -var _tempMat1 = new Matrix4(); -var _tempMat2 = new Matrix4(); - -module.exports = Matrix4; - - -/***/ }), -/* 279 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Matrix4 = __webpack_require__(278); -var RandomXYZ = __webpack_require__(561); -var RandomXYZW = __webpack_require__(560); -var RotateVec3 = __webpack_require__(559); -var Set = __webpack_require__(70); -var Sprite3D = __webpack_require__(151); -var Vector2 = __webpack_require__(6); -var Vector3 = __webpack_require__(87); -var Vector4 = __webpack_require__(277); - -// Local cache vars -var tmpVec3 = new Vector3(); -var tmpVec4 = new Vector4(); -var dirvec = new Vector3(); -var rightvec = new Vector3(); -var billboardMatrix = new Matrix4(); - -// @author attribute https://github.com/mattdesl/cam3d/wiki - -/** - * @typedef {object} RayDef - * - * @property {Phaser.Math.Vector3} origin - [description] - * @property {Phaser.Math.Vector3} direction - [description] - */ - -/** - * @classdesc - * [description] - * - * @class Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var Camera = new Class({ - - initialize: - - function Camera (scene) - { - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#displayList - * @type {Phaser.GameObjects.DisplayList} - * @since 3.0.0 - */ - this.displayList = scene.sys.displayList; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#updateList - * @type {Phaser.GameObjects.UpdateList} - * @since 3.0.0 - */ - this.updateList = scene.sys.updateList; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#direction - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.direction = new Vector3(0, 0, -1); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#up - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.up = new Vector3(0, 1, 0); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#position - * @type {Phaser.Math.Vector3} - * @since 3.0.0 - */ - this.position = new Vector3(); - - // The mapping from 3D size units to pixels. - // In the default case 1 3D unit = 128 pixels. So a sprite that is - // 256 x 128 px in size will be 2 x 1 units. - // Change to whatever best fits your game assets. - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#pixelScale - * @type {number} - * @since 3.0.0 - */ - this.pixelScale = 128; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#projection - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.projection = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#view - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.view = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#combined - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.combined = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#invProjectionView - * @type {Phaser.Math.Matrix4} - * @since 3.0.0 - */ - this.invProjectionView = new Matrix4(); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#near - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.near = 1; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#far - * @type {number} - * @since 3.0.0 - */ - this.far = 100; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#ray - * @type {RayDef} - * @since 3.0.0 - */ - this.ray = { - origin: new Vector3(), - direction: new Vector3() - }; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#viewportWidth - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.viewportWidth = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#viewportHeight - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.viewportHeight = 0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#billboardMatrixDirty - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.billboardMatrixDirty = true; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D#children - * @type {Phaser.Structs.Set.} - * @since 3.0.0 - */ - this.children = new Set(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setPosition: function (x, y, z) - { - this.position.set(x, y, z); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setPixelScale - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setPixelScale: function (value) - { - this.pixelScale = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#add - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite3D} sprite3D - [description] - * - * @return {Phaser.GameObjects.Sprite3D} [description] - */ - add: function (sprite3D) - { - this.children.set(sprite3D); - - this.updateChildren(); - - return sprite3D; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#remove - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - remove: function (child) - { - this.displayList.remove(child.gameObject); - this.updateList.remove(child.gameObject); - - this.children.delete(child); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#clear - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - clear: function () - { - var children = this.getChildren(); - - for (var i = 0; i < children.length; i++) - { - this.remove(children[i]); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#getChildren - * @since 3.0.0 - * - * @return {array} [description] - */ - getChildren: function () - { - return this.children.entries; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#create - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] - * @param {string} key - [description] - * @param {(string|number)} frame - [description] - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.Sprite3D} [description] - */ - create: function (x, y, z, key, frame, visible) - { - if (visible === undefined) { visible = true; } - - var child = new Sprite3D(this.scene, x, y, z, key, frame); - - this.displayList.add(child.gameObject); - this.updateList.add(child.gameObject); - - child.visible = visible; - - this.children.set(child); - - this.updateChildren(); - - return child; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#createMultiple - * @since 3.0.0 - * - * @param {number} quantity - [description] - * @param {string} key - [description] - * @param {(string|number)} frame - [description] - * @param {boolean} [visible=true] - [description] - * - * @return {Phaser.GameObjects.Sprite3D[]} [description] - */ - createMultiple: function (quantity, key, frame, visible) - { - if (visible === undefined) { visible = true; } - - var output = []; - - for (var i = 0; i < quantity; i++) - { - var child = new Sprite3D(this.scene, 0, 0, 0, key, frame); - - this.displayList.add(child.gameObject); - this.updateList.add(child.gameObject); - - child.visible = visible; - - this.children.set(child); - - output.push(child); - } - - return output; - }, - - // Create a bunch of Sprite3D objects in a rectangle - // size and spacing are Vec3s (or if integers are converted to vec3s) - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#createRect - * @since 3.0.0 - * - * @param {(number|{x:number,y:number})} size - [description] - * @param {(number|{x:number,y:number,z:number})} spacing - [description] - * @param {string} key - [description] - * @param {(string|number)} [frame] - [description] - * - * @return {Phaser.GameObjects.Sprite3D[]} [description] - */ - createRect: function (size, spacing, key, frame) - { - if (typeof size === 'number') { size = { x: size, y: size, z: size }; } - if (typeof spacing === 'number') { spacing = { x: spacing, y: spacing, z: spacing }; } - - var quantity = size.x * size.y * size.z; - - var sprites = this.createMultiple(quantity, key, frame); - - var i = 0; - - for (var z = 0.5 - (size.z / 2); z < (size.z / 2); z++) - { - for (var y = 0.5 - (size.y / 2); y < (size.y / 2); y++) - { - for (var x = 0.5 - (size.x / 2); x < (size.x / 2); x++) - { - var bx = (x * spacing.x); - var by = (y * spacing.y); - var bz = (z * spacing.z); - - sprites[i].position.set(bx, by, bz); - - i++; - } - } - } - - this.update(); - - return sprites; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#randomSphere - * @since 3.0.0 - * - * @param {number} [radius=1] - [description] - * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - randomSphere: function (radius, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - RandomXYZ(sprites[i].position, radius); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#randomCube - * @since 3.0.0 - * - * @param {float} [scale=1] - [description] - * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - randomCube: function (scale, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - RandomXYZW(sprites[i].position, scale); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#translateChildren - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec3 - [description] - * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - translateChildren: function (vec3, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - sprites[i].position.add(vec3); - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#transformChildren - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} mat4 - [description] - * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - transformChildren: function (mat4, sprites) - { - if (sprites === undefined) { sprites = this.getChildren(); } - - for (var i = 0; i < sprites.length; i++) - { - sprites[i].position.transformMat4(mat4); - } - - return this.update(); - }, - - /** - * Sets the width and height of the viewport. Does not update any matrices. - * - * @method Phaser.Cameras.Sprite3D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setViewport: function (width, height) - { - this.viewportWidth = width; - this.viewportHeight = height; - - return this.update(); - }, - - /** - * Translates this camera by a specified Vector3 object - * or x, y, z parameters. Any undefined x y z values will - * default to zero, leaving that component unaffected. - * If you wish to set the camera position directly call setPosition instead. - * - * @method Phaser.Cameras.Sprite3D.Camera#translate - * @since 3.0.0 - * - * @param {(number|object)} x - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - translate: function (x, y, z) - { - if (typeof x === 'object') - { - this.position.x += x.x || 0; - this.position.y += x.y || 0; - this.position.z += x.z || 0; - } - else - { - this.position.x += x || 0; - this.position.y += y || 0; - this.position.z += z || 0; - } - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#lookAt - * @since 3.0.0 - * - * @param {(number|object)} x - [description] - * @param {number} [y] - [description] - * @param {number} [z] - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - lookAt: function (x, y, z) - { - var dir = this.direction; - var up = this.up; - - if (typeof x === 'object') - { - dir.copy(x); - } - else - { - dir.set(x, y, z); - } - - dir.subtract(this.position).normalize(); - - // Calculate right vector - tmpVec3.copy(dir).cross(up).normalize(); - - // Calculate up vector - up.copy(tmpVec3).cross(dir).normalize(); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#rotate - * @since 3.0.0 - * - * @param {float} radians - [description] - * @param {Phaser.Math.Vector3} axis - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - rotate: function (radians, axis) - { - RotateVec3(this.direction, axis, radians); - RotateVec3(this.up, axis, radians); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#rotateAround - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} point - [description] - * @param {float} radians - [description] - * @param {Phaser.Math.Vector3} axis - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - rotateAround: function (point, radians, axis) - { - tmpVec3.copy(point).subtract(this.position); - - this.translate(tmpVec3); - this.rotate(radians, axis); - this.translate(tmpVec3.negate()); - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#project - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec - [description] - * @param {Phaser.Math.Vector4} out - [description] - * - * @return {Phaser.Math.Vector4} [description] - */ - project: function (vec, out) - { - if (out === undefined) { out = new Vector4(); } - - // TODO: support viewport XY - var viewportWidth = this.viewportWidth; - var viewportHeight = this.viewportHeight; - var n = Camera.NEAR_RANGE; - var f = Camera.FAR_RANGE; - - // For useful Z and W values we should do the usual steps: clip space -> NDC -> window coords - - // Implicit 1.0 for w component - tmpVec4.set(vec.x, vec.y, vec.z, 1.0); - - // Transform into clip space - tmpVec4.transformMat4(this.combined); - - // Avoid divide by zero when 0x0x0 camera projects to a 0x0x0 vec3 - if (tmpVec4.w === 0) - { - tmpVec4.w = 1; - } - - // Now into NDC - tmpVec4.x = tmpVec4.x / tmpVec4.w; - tmpVec4.y = tmpVec4.y / tmpVec4.w; - tmpVec4.z = tmpVec4.z / tmpVec4.w; - - // And finally into window coordinates - out.x = viewportWidth / 2 * tmpVec4.x + (0 + viewportWidth / 2); - out.y = viewportHeight / 2 * tmpVec4.y + (0 + viewportHeight / 2); - out.z = (f - n) / 2 * tmpVec4.z + (f + n) / 2; - - // If the out vector has a fourth component, we also store (1/clip.w), same idea as gl_FragCoord.w - if (out.w === 0 || out.w) - { - out.w = 1 / tmpVec4.w; - } - - return out; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#unproject - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} vec - [description] - * @param {Phaser.Math.Vector3} out - [description] - * - * @return {Phaser.Math.Vector3} [description] - */ - unproject: function (vec, out) - { - if (out === undefined) { out = new Vector3(); } - - var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); - - return out.copy(vec).unproject(viewport, this.invProjectionView); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#getPickRay - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y] - [description] - * - * @return {RayDef} [description] - */ - getPickRay: function (x, y) - { - var origin = this.ray.origin.set(x, y, 0); - var direction = this.ray.direction.set(x, y, 1); - var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); - var mtx = this.invProjectionView; - - origin.unproject(viewport, mtx); - - direction.unproject(viewport, mtx); - - direction.subtract(origin).normalize(); - - return this.ray; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#updateChildren - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - updateChildren: function () - { - var children = this.children.entries; - - for (var i = 0; i < children.length; i++) - { - children[i].project(this); - } - - return this; - }, - - // Overriden by subclasses - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#update - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - update: function () - { - return this.updateChildren(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#updateBillboardMatrix - * @since 3.0.0 - */ - updateBillboardMatrix: function () - { - var dir = dirvec.set(this.direction).negate(); - - // Better view-aligned billboards might use this: - // var dir = tmp.set(camera.position).subtract(p).normalize(); - - var right = rightvec.set(this.up).cross(dir).normalize(); - var up = tmpVec3.set(dir).cross(right).normalize(); - - var out = billboardMatrix.val; - - out[0] = right.x; - out[1] = right.y; - out[2] = right.z; - out[3] = 0; - - out[4] = up.x; - out[5] = up.y; - out[6] = up.z; - out[7] = 0; - - out[8] = dir.x; - out[9] = dir.y; - out[10] = dir.z; - out[11] = 0; - - out[12] = 0; - out[13] = 0; - out[14] = 0; - out[15] = 1; - - this.billboardMatrixDirty = false; - }, - - /** - * This is a utility function for canvas 3D rendering, - * which determines the "point size" of a camera-facing - * sprite billboard given its 3D world position - * (origin at center of sprite) and its world width - * and height in x/y. - * - * We place into the output Vector2 the scaled width - * and height. If no `out` is specified, a new Vector2 - * will be created for convenience (this should be avoided - * in tight loops). - * - * @method Phaser.Cameras.Sprite3D.Camera#getPointSize - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} vec - The position of the 3D Sprite. - * @param {Phaser.Math.Vector2} size - The x and y dimensions. - * @param {Phaser.Math.Vector2} out - The result, scaled x and y dimensions. - * - * @return {Phaser.Math.Vector2} [description] - */ - getPointSize: function (vec, size, out) - { - if (out === undefined) { out = new Vector2(); } - - // TODO: optimize this with a simple distance calculation: - // https://developer.valvesoftware.com/wiki/Field_of_View - - if (this.billboardMatrixDirty) - { - this.updateBillboardMatrix(); - } - - var tmp = tmpVec3; - - var dx = (size.x / this.pixelScale) / 2; - var dy = (size.y / this.pixelScale) / 2; - - tmp.set(-dx, -dy, 0).transformMat4(billboardMatrix).add(vec); - - this.project(tmp, tmp); - - var tlx = tmp.x; - var tly = tmp.y; - - tmp.set(dx, dy, 0).transformMat4(billboardMatrix).add(vec); - - this.project(tmp, tmp); - - var brx = tmp.x; - var bry = tmp.y; - - // var w = Math.abs(brx - tlx); - // var h = Math.abs(bry - tly); - - // Allow the projection to get negative ... - var w = brx - tlx; - var h = bry - tly; - - return out.set(w, h); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.children.clear(); - - this.scene = undefined; - this.children = undefined; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setX: function (value) - { - this.position.x = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setY: function (value) - { - this.position.y = value; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.Camera#setZ - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. - */ - setZ: function (value) - { - this.position.z = value; - - return this.update(); - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#x - * @type {number} - * @since 3.0.0 - */ - x: { - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.position.x = value; - this.update(); - } - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#y - * @type {number} - * @since 3.0.0 - */ - y: { - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.position.y = value; - this.update(); - } - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.Camera#z - * @type {number} - * @since 3.0.0 - */ - z: { - get: function () - { - return this.position.z; - }, - - set: function (value) - { - this.position.z = value; - this.update(); - } - } - -}); - -Camera.FAR_RANGE = 1.0; -Camera.NEAR_RANGE = 0.0; - -module.exports = Camera; - - -/***/ }), -/* 280 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); - -/** - * Converts a CSS 'web' string into a Phaser Color object. - * - * The web string can be in the format `'rgb(r,g,b)'` or `'rgba(r,g,b,a)'` where r/g/b are in the range [0..255] and a is in the range [0..1]. - * - * @function Phaser.Display.Color.RGBStringToColor - * @since 3.0.0 - * - * @param {string} rgb - The CSS format color string, using the `rgb` or `rgba` format. - * - * @return {Phaser.Display.Color} A Color object. - */ -var RGBStringToColor = function (rgb) -{ - var color = new Color(); - - var result = (/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/).exec(rgb.toLowerCase()); - - if (result) - { - var r = parseInt(result[1], 10); - var g = parseInt(result[2], 10); - var b = parseInt(result[3], 10); - var a = (result[4] !== undefined) ? parseFloat(result[4]) : 1; - - color.setTo(r, g, b, a * 255); - } - - return color; -}; - -module.exports = RGBStringToColor; - - -/***/ }), -/* 281 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); - -/** - * Converts an object containing `r`, `g`, `b` and `a` properties into a Color class instance. - * - * @function Phaser.Display.Color.ObjectToColor - * @since 3.0.0 - * - * @param {InputColorObject} input - An object containing `r`, `g`, `b` and `a` properties in the range 0 to 255. - * - * @return {Phaser.Display.Color} A Color object. - */ -var ObjectToColor = function (input) -{ - return new Color(input.r, input.g, input.b, input.a); -}; - -module.exports = ObjectToColor; - - -/***/ }), -/* 282 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Return the component parts of a color as an Object with the properties alpha, red, green, blue. - * - * Alpha will only be set if it exists in the given color (0xAARRGGBB) - * - * @function Phaser.Display.Color.IntegerToRGB - * @since 3.0.0 - * - * @param {integer} input - The color value to convert into a Color object. - * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. - */ -var IntegerToRGB = function (color) -{ - if (color > 16777215) - { - // The color value has an alpha component - return { - a: color >>> 24, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; - } - else - { - return { - a: 255, - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF - }; - } -}; - -module.exports = IntegerToRGB; - - -/***/ }), -/* 283 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); -var IntegerToRGB = __webpack_require__(282); - -/** - * Converts the given color value into an instance of a Color object. - * - * @function Phaser.Display.Color.IntegerToColor - * @since 3.0.0 - * - * @param {integer} input - The color value to convert into a Color object. - * - * @return {Phaser.Display.Color} A Color object. - */ -var IntegerToColor = function (input) -{ - var rgb = IntegerToRGB(input); - - return new Color(rgb.r, rgb.g, rgb.b, rgb.a); -}; - -module.exports = IntegerToColor; - - -/***/ }), -/* 284 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Given an alpha and 3 color values this will return an integer representation of it. - * - * @function Phaser.Display.Color.GetColor32 - * @since 3.0.0 - * - * @param {integer} red - The red color value. A number between 0 and 255. - * @param {integer} green - The green color value. A number between 0 and 255. - * @param {integer} blue - The blue color value. A number between 0 and 255. - * @param {integer} alpha - The alpha color value. A number between 0 and 255. - * - * @return {number} The combined color value. - */ -var GetColor32 = function (red, green, blue, alpha) -{ - return alpha << 24 | red << 16 | green << 8 | blue; -}; - -module.exports = GetColor32; - - -/***/ }), -/* 285 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); - -/** - * Converts a hex string into a Phaser Color object. - * - * The hex string can supplied as `'#0033ff'` or the short-hand format of `'#03f'`; it can begin with an optional "#" or "0x", or be unprefixed. - * - * An alpha channel is _not_ supported. - * - * @function Phaser.Display.Color.HexStringToColor - * @since 3.0.0 - * - * @param {string} hex - The hex color value to convert, such as `#0033ff` or the short-hand format: `#03f`. - * - * @return {Phaser.Display.Color} A Color object populated by the values of the given string. - */ -var HexStringToColor = function (hex) -{ - var color = new Color(); - - // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") - hex = hex.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) - { - return r + r + g + g + b + b; - }); - - var result = (/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i).exec(hex); - - if (result) - { - var r = parseInt(result[1], 16); - var g = parseInt(result[2], 16); - var b = parseInt(result[3], 16); - - color.setTo(r, g, b); - } - - return color; -}; - -module.exports = HexStringToColor; - - -/***/ }), -/* 286 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate a smooth interpolation percentage of `x` between `min` and `max`. - * - * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, - * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, - * between 0 and 1 otherwise. - * - * @function Phaser.Math.SmoothStep - * @since 3.0.0 - * @see {@link https://en.wikipedia.org/wiki/Smoothstep} - * - * @param {number} x - The input value. - * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - * - * @return {number} The percentage of interpolation, between 0 and 1. - */ -var SmoothStep = function (x, min, max) -{ - if (x <= min) - { - return 0; - } - - if (x >= max) - { - return 1; - } - - x = (x - min) / (max - min); - - return x * x * (3 - 2 * x); -}; - -module.exports = SmoothStep; - - -/***/ }), -/* 287 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate a smoother interpolation percentage of `x` between `min` and `max`. - * - * The function receives the number `x` as an argument and returns 0 if `x` is less than or equal to the left edge, - * 1 if `x` is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, - * between 0 and 1 otherwise. - * - * Produces an even smoother interpolation than {@link Phaser.Math.SmoothStep}. - * - * @function Phaser.Math.SmootherStep - * @since 3.0.0 - * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} - * - * @param {number} x - The input value. - * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - * - * @return {number} The percentage of interpolation, between 0 and 1. - */ -var SmootherStep = function (x, min, max) -{ - x = Math.max(0, Math.min(1, (x - min) / (max - min))); - - return x * x * x * (x * (x * 6 - 15) + 10); -}; - -module.exports = SmootherStep; - - -/***/ }), -/* 288 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Math.RotateAroundDistance - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. - * @param {number} x - The horizontal coordinate to rotate around. - * @param {number} y - The vertical coordinate to rotate around. - * @param {number} angle - The angle of rotation in radians. - * @param {number} distance - [description] - * - * @return {Phaser.Geom.Point} The given point. - */ -var RotateAroundDistance = function (point, x, y, angle, distance) -{ - var t = angle + Math.atan2(point.y - y, point.x - x); - - point.x = x + (distance * Math.cos(t)); - point.y = y + (distance * Math.sin(t)); - - return point; -}; - -module.exports = RotateAroundDistance; - - -/***/ }), -/* 289 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the element at the end of the array to the start, shifting all items in the process. - * The "rotation" happens to the right. - * - * @function Phaser.Utils.Array.RotateRight - * @since 3.0.0 - * - * @param {array} array - The array to shift to the right. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. - * - * @return {*} The most recently shifted element. - */ -var RotateRight = function (array, total) -{ - if (total === undefined) { total = 1; } - - var element = null; - - for (var i = 0; i < total; i++) - { - element = array.pop(); - array.unshift(element); - } - - return element; -}; - -module.exports = RotateRight; - - -/***/ }), -/* 290 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Moves the element at the start of the array to the end, shifting all items in the process. - * The "rotation" happens to the left. - * - * @function Phaser.Utils.Array.RotateLeft - * @since 3.0.0 - * - * @param {array} array - The array to shift to the left. This array is modified in place. - * @param {integer} [total=1] - The number of times to shift the array. - * - * @return {*} The most recently shifted element. - */ -var RotateLeft = function (array, total) -{ - if (total === undefined) { total = 1; } - - var element = null; - - for (var i = 0; i < total; i++) - { - element = array.shift(); - array.push(element); - } - - return element; -}; - -module.exports = RotateLeft; - - -/***/ }), -/* 291 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for setting the WebGL rendering pipeline of a Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline - * @webglOnly - * @since 3.0.0 - */ - -var Pipeline = { - - /** - * The initial WebGL pipeline of this Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - defaultPipeline: null, - - /** - * The current WebGL pipeline of this Game Object. - * - * @name Phaser.GameObjects.Components.Pipeline#pipeline - * @type {Phaser.Renderer.WebGL.WebGLPipeline} - * @default null - * @webglOnly - * @since 3.0.0 - */ - pipeline: null, - - /** - * Sets the initial WebGL Pipeline of this Game Object. - * This should only be called during the instantiation of the Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#initPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - initPipeline: function (pipelineName) - { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.defaultPipeline = renderer.getPipeline(pipelineName); - this.pipeline = this.defaultPipeline; - - return true; - } - - return false; - }, - - /** - * Sets the active WebGL Pipeline of this Game Object. - * - * @method Phaser.GameObjects.Components.Pipeline#setPipeline - * @webglOnly - * @since 3.0.0 - * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - setPipeline: function (pipelineName) - { - var renderer = this.scene.sys.game.renderer; - - if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) - { - this.pipeline = renderer.getPipeline(pipelineName); - - return true; - } - - return false; - }, - - /** - * Resets the WebGL Pipeline of this Game Object back to the default it was created with. - * - * @method Phaser.GameObjects.Components.Pipeline#resetPipeline - * @webglOnly - * @since 3.0.0 - * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. - */ - resetPipeline: function () - { - this.pipeline = this.defaultPipeline; - - return (this.pipeline !== null); - }, - - /** - * Gets the name of the WebGL Pipeline this Game Object is currently using. - * - * @method Phaser.GameObjects.Components.Pipeline#getPipelineName - * @webglOnly - * @since 3.0.0 - * - * @return {string} The string-based name of the pipeline being used by this Game Object. - */ - getPipelineName: function () - { - return this.pipeline.name; - } - -}; - -module.exports = Pipeline; - - -/***/ }), -/* 292 */ +/* 396 */ /***/ (function(module, exports) { /** @@ -70464,7 +94852,7 @@ module.exports = RotateAround; /***/ }), -/* 293 */ +/* 397 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -70473,24 +94861,21 @@ module.exports = RotateAround; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -// Get a point on the given line 'progress' percentage along its length. -// progress is a value between 0 and 1. +var Point = __webpack_require__(6); /** - * [description] + * Get a point on a line that's a given percentage along its length. * * @function Phaser.Geom.Line.GetPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Line} line - [description] - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param {(Phaser.Geom.Point|object)} [out] - [description] + * @param {Phaser.Geom.Line} line - The line. + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point, or point-like object, to store the coordinates of the point on the line. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} The point on the line. */ var GetPoint = function (line, position, out) { @@ -70506,7 +94891,7 @@ module.exports = GetPoint; /***/ }), -/* 294 */ +/* 398 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -70515,26 +94900,26 @@ module.exports = GetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetPoint = __webpack_require__(135); -var Perimeter = __webpack_require__(97); +var GetPoint = __webpack_require__(190); +var Perimeter = __webpack_require__(124); // Return an array of points from the perimeter of the rectangle // each spaced out based on the quantity or step required /** - * [description] + * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. * * @function Phaser.Geom.Rectangle.GetPoints * @since 3.0.0 * * @generic {Phaser.Geom.Point[]} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle object to get the points from. * @param {number} step - [description] * @param {integer} quantity - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] + * @param {(array|Phaser.Geom.Point[])} [out] - An optional array to store the points in. * - * @return {(array|Phaser.Geom.Point[])} [description] + * @return {(array|Phaser.Geom.Point[])} An array of Points from the perimeter of the rectangle. */ var GetPoints = function (rectangle, quantity, stepRate, out) { @@ -70560,7 +94945,515 @@ module.exports = GetPoints; /***/ }), -/* 295 */ +/* 399 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Depth + * @since 3.0.0 + */ + +var Depth = { + + /** + * Private internal value. Holds the depth of the Game Object. + * + * @name Phaser.GameObjects.Components.Depth#_depth + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _depth: 0, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @name Phaser.GameObjects.Components.Depth#depth + * @type {number} + * @since 3.0.0 + */ + depth: { + + get: function () + { + return this._depth; + }, + + set: function (value) + { + this.scene.sys.queueDepthSort(); + this._depth = value; + } + + }, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @method Phaser.GameObjects.Components.Depth#setDepth + * @since 3.0.0 + * + * @param {integer} value - The depth of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDepth: function (value) + { + if (value === undefined) { value = 0; } + + this.depth = value; + + return this; + } + +}; + +module.exports = Depth; + + +/***/ }), +/* 400 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(66); + +/** + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.BlendMode + * @since 3.0.0 + */ + +var BlendMode = { + + /** + * Private internal value. Holds the current blend mode. + * + * @name Phaser.GameObjects.Components.BlendMode#_blendMode + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _blendMode: BlendModes.NORMAL, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @name Phaser.GameObjects.Components.BlendMode#blendMode + * @type {(Phaser.BlendModes|string)} + * @since 3.0.0 + */ + blendMode: { + + get: function () + { + return this._blendMode; + }, + + set: function (value) + { + if (typeof value === 'string') + { + value = BlendModes[value]; + } + + value |= 0; + + if (value >= -1) + { + this._blendMode = value; + } + } + + }, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @method Phaser.GameObjects.Components.BlendMode#setBlendMode + * @since 3.0.0 + * + * @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST. + * + * @return {this} This Game Object instance. + */ + setBlendMode: function (value) + { + this.blendMode = value; + + return this; + } + +}; + +module.exports = BlendMode; + + +/***/ }), +/* 401 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); + +// bitmask flag for GameObject.renderMask +var _FLAG = 2; // 0010 + +/** + * Provides methods used for setting the alpha properties of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Alpha + * @since 3.0.0 + */ + +var Alpha = { + + /** + * Private internal value. Holds the global alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alpha: 1, + + /** + * Private internal value. Holds the top-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTL: 1, + + /** + * Private internal value. Holds the top-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTR: 1, + + /** + * Private internal value. Holds the bottom-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBL: 1, + + /** + * Private internal value. Holds the bottom-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBR: 1, + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + * + * @method Phaser.GameObjects.Components.Alpha#clearAlpha + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearAlpha: function () + { + return this.setAlpha(1); + }, + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * + * @method Phaser.GameObjects.Components.Alpha#setAlpha + * @since 3.0.0 + * + * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * + * @return {this} This Game Object instance. + */ + setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 1; } + + // Treat as if there is only one alpha value for the whole Game Object + if (topRight === undefined) + { + this.alpha = topLeft; + } + else + { + this._alphaTL = Clamp(topLeft, 0, 1); + this._alphaTR = Clamp(topRight, 0, 1); + this._alphaBL = Clamp(bottomLeft, 0, 1); + this._alphaBR = Clamp(bottomRight, 0, 1); + } + + return this; + }, + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + * + * @name Phaser.GameObjects.Components.Alpha#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alpha = v; + this._alphaTL = v; + this._alphaTR = v; + this._alphaBL = v; + this._alphaBR = v; + + if (v === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopLeft: { + + get: function () + { + return this._alphaTL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopRight: { + + get: function () + { + return this._alphaTR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomLeft: { + + get: function () + { + return this._alphaBL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomRight: { + + get: function () + { + return this._alphaBR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + } + +}; + +module.exports = Alpha; + + +/***/ }), +/* 402 */ /***/ (function(module, exports) { /** @@ -70588,7 +95481,7 @@ module.exports = Circumference; /***/ }), -/* 296 */ +/* 403 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -70597,9 +95490,9 @@ module.exports = Circumference; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circumference = __webpack_require__(295); -var CircumferencePoint = __webpack_require__(136); -var FromPercent = __webpack_require__(65); +var Circumference = __webpack_require__(402); +var CircumferencePoint = __webpack_require__(192); +var FromPercent = __webpack_require__(93); var MATH_CONST = __webpack_require__(16); /** @@ -70640,7 +95533,7 @@ module.exports = GetPoints; /***/ }), -/* 297 */ +/* 404 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -70653,14 +95546,23 @@ var Class = __webpack_require__(0); /** * @classdesc - * A seeded random data generator. + * A seeded Random Data Generator. + * + * Access via `Phaser.Math.RND` which is an instance of this class pre-defined + * by Phaser. Or, create your own instance to use as you require. + * + * The `Math.RND` generator is seeded by the Game Config property value `seed`. + * If no such config property exists, a random number is used. + * + * If you create your own instance of this class you should provide a seed for it. + * If no seed is given it will use a 'random' one based on Date.now. * * @class RandomDataGenerator - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * - * @param {string[]} [seeds] - The seeds. + * @param {(string|string[])} [seeds] - The seeds to use for the random number generator. */ var RandomDataGenerator = new Class({ @@ -70668,6 +95570,8 @@ var RandomDataGenerator = new Class({ function RandomDataGenerator (seeds) { + if (seeds === undefined) { seeds = [ (Date.now() * Math.random()).toString() ]; } + /** * Internal var. * @@ -71128,7 +96032,7 @@ module.exports = RandomDataGenerator; /***/ }), -/* 298 */ +/* 405 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -71137,10 +96041,10 @@ module.exports = RandomDataGenerator; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CircumferencePoint = __webpack_require__(136); -var FromPercent = __webpack_require__(65); +var CircumferencePoint = __webpack_require__(192); +var FromPercent = __webpack_require__(93); var MATH_CONST = __webpack_require__(16); -var Point = __webpack_require__(5); +var Point = __webpack_require__(6); /** * Returns a Point object containing the coordinates of a point on the circumference of the Circle @@ -71153,7 +96057,7 @@ var Point = __webpack_require__(5); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. @@ -71171,7 +96075,1400 @@ module.exports = GetPoint; /***/ }), -/* 299 */ +/* 406 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(44); +var GetTop = __webpack_require__(42); +var SetRight = __webpack_require__(43); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned in the top right of the other. + * + * @function Phaser.Display.Align.In.TopRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }), +/* 407 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(46); +var GetTop = __webpack_require__(42); +var SetLeft = __webpack_require__(45); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned in the top left of the other. + * + * @function Phaser.Display.Align.In.TopLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }), +/* 408 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterX = __webpack_require__(75); +var GetTop = __webpack_require__(42); +var SetCenterX = __webpack_require__(74); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned in the top center of the other. + * + * @function Phaser.Display.Align.In.TopCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetTop(gameObject, GetTop(alignIn) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }), +/* 409 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(72); +var GetRight = __webpack_require__(44); +var SetCenterY = __webpack_require__(73); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned in the right center of the other. + * + * @function Phaser.Display.Align.In.RightCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }), +/* 410 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(72); +var GetLeft = __webpack_require__(46); +var SetCenterY = __webpack_require__(73); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned in the left center of the other. + * + * @function Phaser.Display.Align.In.LeftCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }), +/* 411 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetCenterX = __webpack_require__(74); +var SetCenterY = __webpack_require__(73); + +/** + * Positions the Game Object so that it is centered on the given coordinates. + * + * @function Phaser.Display.Bounds.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. + * @param {number} x - The horizontal coordinate to position the Game Object on. + * @param {number} y - The vertical coordinate to position the Game Object on. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. + */ +var CenterOn = function (gameObject, x, y) +{ + SetCenterX(gameObject, x); + + return SetCenterY(gameObject, y); +}; + +module.exports = CenterOn; + + +/***/ }), +/* 412 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CenterOn = __webpack_require__(411); +var GetCenterX = __webpack_require__(75); +var GetCenterY = __webpack_require__(72); + +/** + * Takes given Game Object and aligns it so that it is positioned in the center of the other. + * + * @function Phaser.Display.Align.In.Center + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var Center = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = Center; + + +/***/ }), +/* 413 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetRight = __webpack_require__(44); +var SetBottom = __webpack_require__(47); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. + * + * @function Phaser.Display.Align.In.BottomRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }), +/* 414 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetLeft = __webpack_require__(46); +var SetBottom = __webpack_require__(47); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. + * + * @function Phaser.Display.Align.In.BottomLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignIn) - offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }), +/* 415 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetCenterX = __webpack_require__(75); +var SetBottom = __webpack_require__(47); +var SetCenterX = __webpack_require__(74); + +/** + * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. + * + * @function Phaser.Display.Align.In.BottomCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); + SetBottom(gameObject, GetBottom(alignIn) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }), +/* 416 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ALIGN_CONST = __webpack_require__(193); + +var AlignInMap = []; + +AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(415); +AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(414); +AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(413); +AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(412); +AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(410); +AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(409); +AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(408); +AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(407); +AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(406); + +/** + * Takes given Game Object and aligns it so that it is positioned relative to the other. + * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. + * + * @function Phaser.Display.Align.In.QuickSet + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [child,$return] + * + * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. + * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var QuickSet = function (child, alignIn, position, offsetX, offsetY) +{ + return AlignInMap[position](child, alignIn, offsetX, offsetY); +}; + +module.exports = QuickSet; + + +/***/ }), +/* 417 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Actions + */ + +module.exports = { + + Angle: __webpack_require__(1050), + Call: __webpack_require__(1049), + GetFirst: __webpack_require__(1048), + GetLast: __webpack_require__(1047), + GridAlign: __webpack_require__(1046), + IncAlpha: __webpack_require__(1035), + IncX: __webpack_require__(1034), + IncXY: __webpack_require__(1033), + IncY: __webpack_require__(1032), + PlaceOnCircle: __webpack_require__(1031), + PlaceOnEllipse: __webpack_require__(1030), + PlaceOnLine: __webpack_require__(1029), + PlaceOnRectangle: __webpack_require__(1028), + PlaceOnTriangle: __webpack_require__(1027), + PlayAnimation: __webpack_require__(1026), + PropertyValueInc: __webpack_require__(32), + PropertyValueSet: __webpack_require__(25), + RandomCircle: __webpack_require__(1025), + RandomEllipse: __webpack_require__(1024), + RandomLine: __webpack_require__(1023), + RandomRectangle: __webpack_require__(1022), + RandomTriangle: __webpack_require__(1021), + Rotate: __webpack_require__(1020), + RotateAround: __webpack_require__(1019), + RotateAroundDistance: __webpack_require__(1018), + ScaleX: __webpack_require__(1017), + ScaleXY: __webpack_require__(1016), + ScaleY: __webpack_require__(1015), + SetAlpha: __webpack_require__(1014), + SetBlendMode: __webpack_require__(1013), + SetDepth: __webpack_require__(1012), + SetHitArea: __webpack_require__(1011), + SetOrigin: __webpack_require__(1010), + SetRotation: __webpack_require__(1009), + SetScale: __webpack_require__(1008), + SetScaleX: __webpack_require__(1007), + SetScaleY: __webpack_require__(1006), + SetTint: __webpack_require__(1005), + SetVisible: __webpack_require__(1004), + SetX: __webpack_require__(1003), + SetXY: __webpack_require__(1002), + SetY: __webpack_require__(1001), + ShiftPosition: __webpack_require__(1000), + Shuffle: __webpack_require__(999), + SmootherStep: __webpack_require__(998), + SmoothStep: __webpack_require__(997), + Spread: __webpack_require__(996), + ToggleVisible: __webpack_require__(995), + WrapInRectangle: __webpack_require__(994) + +}; + + +/***/ }), +/* 418 */ +/***/ (function(module, exports) { + +/** +* The `Matter.Pair` module contains methods for creating and manipulating collision pairs. +* +* @class Pair +*/ + +var Pair = {}; + +module.exports = Pair; + +(function() { + + /** + * Creates a pair. + * @method create + * @param {collision} collision + * @param {number} timestamp + * @return {pair} A new pair + */ + Pair.create = function(collision, timestamp) { + var bodyA = collision.bodyA, + bodyB = collision.bodyB; + + var pair = { + id: Pair.id(bodyA, bodyB), + bodyA: bodyA, + bodyB: bodyB, + activeContacts: [], + separation: 0, + isActive: true, + confirmedActive: true, + isSensor: bodyA.isSensor || bodyB.isSensor, + timeCreated: timestamp, + timeUpdated: timestamp, + collision: null, + inverseMass: 0, + friction: 0, + frictionStatic: 0, + restitution: 0, + slop: 0 + }; + + Pair.update(pair, collision, timestamp); + + return pair; + }; + + /** + * Updates a pair given a collision. + * @method update + * @param {pair} pair + * @param {collision} collision + * @param {number} timestamp + */ + Pair.update = function(pair, collision, timestamp) { + pair.collision = collision; + + if (collision.collided) { + var supports = collision.supports, + activeContacts = pair.activeContacts, + parentA = collision.parentA, + parentB = collision.parentB; + + pair.inverseMass = parentA.inverseMass + parentB.inverseMass; + pair.friction = Math.min(parentA.friction, parentB.friction); + pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); + pair.restitution = Math.max(parentA.restitution, parentB.restitution); + pair.slop = Math.max(parentA.slop, parentB.slop); + + for (var i = 0; i < supports.length; i++) { + activeContacts[i] = supports[i].contact; + } + + // optimise array size + var supportCount = supports.length; + if (supportCount < activeContacts.length) { + activeContacts.length = supportCount; + } + + pair.separation = collision.depth; + Pair.setActive(pair, true, timestamp); + } else { + if (pair.isActive === true) + Pair.setActive(pair, false, timestamp); + } + }; + + /** + * Set a pair as active or inactive. + * @method setActive + * @param {pair} pair + * @param {bool} isActive + * @param {number} timestamp + */ + Pair.setActive = function(pair, isActive, timestamp) { + if (isActive) { + pair.isActive = true; + pair.timeUpdated = timestamp; + } else { + pair.isActive = false; + pair.activeContacts.length = 0; + } + }; + + /** + * Get the id for the given pair. + * @method id + * @param {body} bodyA + * @param {body} bodyB + * @return {string} Unique pairId + */ + Pair.id = function(bodyA, bodyB) { + if (bodyA.id < bodyB.id) { + return 'A' + bodyA.id + 'B' + bodyB.id; + } else { + return 'A' + bodyB.id + 'B' + bodyA.id; + } + }; + +})(); + + +/***/ }), +/* 419 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Physics.Matter.Components + */ + +module.exports = { + + Bounce: __webpack_require__(1103), + Collision: __webpack_require__(1102), + Force: __webpack_require__(1101), + Friction: __webpack_require__(1100), + Gravity: __webpack_require__(1099), + Mass: __webpack_require__(1098), + Static: __webpack_require__(1097), + Sensor: __webpack_require__(1096), + SetBody: __webpack_require__(1095), + Sleep: __webpack_require__(1093), + Transform: __webpack_require__(1092), + Velocity: __webpack_require__(1091) + +}; + + +/***/ }), +/* 420 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(895); +var TextureTintPipeline = __webpack_require__(196); + +var LIGHT_COUNT = 10; + +/** + * @classdesc + * ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights. + * This pipeline extends TextureTintPipeline so it implements all it's rendering functions + * and batching system. + * + * @class ForwardDiffuseLightPipeline + * @extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline + * @memberof Phaser.Renderer.WebGL.Pipelines + * @constructor + * @since 3.0.0 + * + * @param {object} config - [description] + */ +var ForwardDiffuseLightPipeline = new Class({ + + Extends: TextureTintPipeline, + + initialize: + + function ForwardDiffuseLightPipeline (config) + { + LIGHT_COUNT = config.maxLights; + + config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); + + TextureTintPipeline.call(this, config); + + /** + * Default normal map texture to use. + * + * @name Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#defaultNormalMap + * @type {Phaser.Texture.Frame} + * @private + * @since 3.11.0 + */ + this.defaultNormalMap; + }, + + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#boot + * @override + * @since 3.11.0 + */ + boot: function () + { + this.defaultNormalMap = this.game.textures.getFrame('__DEFAULT'); + }, + + /** + * This function binds its base class resources and this lights 2D resources. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onBind + * @override + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any. + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function (gameObject) + { + TextureTintPipeline.prototype.onBind.call(this); + + var renderer = this.renderer; + var program = this.program; + + this.mvpUpdate(); + + renderer.setInt1(program, 'uNormSampler', 1); + renderer.setFloat2(program, 'uResolution', this.width, this.height); + + if (gameObject) + { + this.setNormalMap(gameObject); + } + + return this; + }, + + /** + * This function sets all the needed resources for each camera pass. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onRender + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * + * @return {this} This WebGLPipeline instance. + */ + onRender: function (scene, camera) + { + this.active = false; + + var lightManager = scene.sys.lights; + + if (!lightManager || lightManager.lights.length <= 0 || !lightManager.active) + { + // Passthru + return this; + } + + var lights = lightManager.cull(camera); + var lightCount = Math.min(lights.length, LIGHT_COUNT); + + if (lightCount === 0) + { + return this; + } + + this.active = true; + + var renderer = this.renderer; + var program = this.program; + var cameraMatrix = camera.matrix; + var point = {x: 0, y: 0}; + var height = renderer.height; + var index; + + for (index = 0; index < LIGHT_COUNT; ++index) + { + // Reset lights + renderer.setFloat1(program, 'uLights[' + index + '].radius', 0); + } + + renderer.setFloat4(program, 'uCamera', camera.x, camera.y, camera.rotation, camera.zoom); + renderer.setFloat3(program, 'uAmbientLightColor', lightManager.ambientColor.r, lightManager.ambientColor.g, lightManager.ambientColor.b); + + for (index = 0; index < lightCount; ++index) + { + var light = lights[index]; + var lightName = 'uLights[' + index + '].'; + + cameraMatrix.transformPoint(light.x, light.y, point); + + renderer.setFloat2(program, lightName + 'position', point.x - (camera.scrollX * light.scrollFactorX * camera.zoom), height - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); + renderer.setFloat3(program, lightName + 'color', light.r, light.g, light.b); + renderer.setFloat1(program, lightName + 'intensity', light.intensity); + renderer.setFloat1(program, lightName + 'radius', light.radius); + } + + return this; + }, + + /** + * Generic function for batching a textured quad + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject + * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad + * @param {integer} textureWidth - Real texture width + * @param {integer} textureHeight - Real texture height + * @param {number} srcX - X coordinate of the quad + * @param {number} srcY - Y coordinate of the quad + * @param {number} srcWidth - Width of the quad + * @param {number} srcHeight - Height of the quad + * @param {number} scaleX - X component of scale + * @param {number} scaleY - Y component of scale + * @param {number} rotation - Rotation of the quad + * @param {boolean} flipX - Indicates if the quad is horizontally flipped + * @param {boolean} flipY - Indicates if the quad is vertically flipped + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll + * @param {number} displayOriginX - Horizontal origin in pixels + * @param {number} displayOriginY - Vertical origin in pixels + * @param {number} frameX - X coordinate of the texture frame + * @param {number} frameY - Y coordinate of the texture frame + * @param {number} frameWidth - Width of the texture frame + * @param {number} frameHeight - Height of the texture frame + * @param {integer} tintTL - Tint for top left + * @param {integer} tintTR - Tint for top right + * @param {integer} tintBL - Tint for bottom left + * @param {integer} tintBR - Tint for bottom right + * @param {number} tintEffect - The tint effect (0 for additive, 1 for replacement) + * @param {number} uOffset - Horizontal offset on texture coordinate + * @param {number} vOffset - Vertical offset on texture coordinate + * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container + */ + batchTexture: function ( + gameObject, + texture, + textureWidth, textureHeight, + srcX, srcY, + srcWidth, srcHeight, + scaleX, scaleY, + rotation, + flipX, flipY, + scrollFactorX, scrollFactorY, + displayOriginX, displayOriginY, + frameX, frameY, frameWidth, frameHeight, + tintTL, tintTR, tintBL, tintBR, tintEffect, + uOffset, vOffset, + camera, + parentTransformMatrix) + { + if (!this.active) + { + return; + } + + this.renderer.setPipeline(this); + + var normalTexture; + + if (gameObject.displayTexture) + { + normalTexture = gameObject.displayTexture.dataSource[gameObject.displayFrame.sourceIndex]; + } + else if (gameObject.texture) + { + normalTexture = gameObject.texture.dataSource[gameObject.frame.sourceIndex]; + } + else if (gameObject.tileset) + { + normalTexture = gameObject.tileset.image.dataSource[0]; + } + + if (!normalTexture) + { + console.warn('Normal map missing or invalid'); + return; + } + + this.setTexture2D(normalTexture.glTexture, 1); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var u0 = (frameX / textureWidth) + uOffset; + var v0 = (frameY / textureHeight) + vOffset; + var u1 = (frameX + frameWidth) / textureWidth + uOffset; + var v1 = (frameY + frameHeight) / textureHeight + vOffset; + + var width = srcWidth; + var height = srcHeight; + + // var x = -displayOriginX + frameX; + // var y = -displayOriginY + frameY; + + var x = -displayOriginX; + var y = -displayOriginY; + + if (gameObject.isCropped) + { + var crop = gameObject._crop; + + width = crop.width; + height = crop.height; + + srcWidth = crop.width; + srcHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + var ox = frameX; + var oy = frameY; + + if (flipX) + { + ox = (frameWidth - crop.x - crop.width); + } + + if (flipY && !texture.isRenderTexture) + { + oy = (frameHeight - crop.y - crop.height); + } + + u0 = (ox / textureWidth) + uOffset; + v0 = (oy / textureHeight) + vOffset; + u1 = (ox + crop.width) / textureWidth + uOffset; + v1 = (oy + crop.height) / textureHeight + vOffset; + + x = -displayOriginX + frameX; + y = -displayOriginY + frameY; + } + + // Invert the flipY if this is a RenderTexture + flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); + + if (flipX) + { + width *= -1; + x += srcWidth; + } + + if (flipY) + { + height *= -1; + y += srcHeight; + } + + // Do we need this? (doubt it) + // if (camera.roundPixels) + // { + // x |= 0; + // y |= 0; + // } + + var xw = x + width; + var yh = y + height; + + spriteMatrix.applyITRS(srcX, srcY, rotation, scaleX, scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * scrollFactorX, -camera.scrollY * scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = srcX; + spriteMatrix.f = srcY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * scrollFactorX; + spriteMatrix.f -= camera.scrollY * scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + this.setTexture2D(texture, 0); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + }, + + /** + * Sets the Game Objects normal map as the active texture. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#setNormalMap + * @since 3.11.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - [description] + */ + setNormalMap: function (gameObject) + { + if (!this.active || !gameObject) + { + return; + } + + var normalTexture; + + if (gameObject.texture) + { + normalTexture = gameObject.texture.dataSource[gameObject.frame.sourceIndex]; + } + + if (!normalTexture) + { + normalTexture = this.defaultNormalMap; + } + + this.setTexture2D(normalTexture.glTexture, 1); + + this.renderer.setPipeline(gameObject.defaultPipeline); + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchSprite + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] + * + */ + batchSprite: function (sprite, camera, parentTransformMatrix) + { + if (!this.active) + { + return; + } + + var normalTexture = sprite.texture.dataSource[sprite.frame.sourceIndex]; + + if (normalTexture) + { + this.renderer.setPipeline(this); + + this.setTexture2D(normalTexture.glTexture, 1); + + TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera, parentTransformMatrix); + } + } + +}); + +ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT; + +module.exports = ForwardDiffuseLightPipeline; + + +/***/ }), +/* 421 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var ShaderSourceFS = __webpack_require__(897); +var ShaderSourceVS = __webpack_require__(896); +var WebGLPipeline = __webpack_require__(197); + +/** + * @classdesc + * BitmapMaskPipeline handles all bitmap masking rendering in WebGL. It works by using + * sampling two texture on the fragment shader and using the fragment's alpha to clip the region. + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + * + * @class BitmapMaskPipeline + * @extends Phaser.Renderer.WebGL.WebGLPipeline + * @memberof Phaser.Renderer.WebGL.Pipelines + * @constructor + * @since 3.0.0 + * + * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. + */ +var BitmapMaskPipeline = new Class({ + + Extends: WebGLPipeline, + + initialize: + + function BitmapMaskPipeline (config) + { + WebGLPipeline.call(this, { + game: config.game, + renderer: config.renderer, + gl: config.renderer.gl, + topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), + vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), + fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), + vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 3), + + vertexSize: (config.vertexSize ? config.vertexSize : + Float32Array.BYTES_PER_ELEMENT * 2), + + vertices: new Float32Array([ + -1, +1, -1, -7, +7, +1 + ]).buffer, + + attributes: [ + { + name: 'inPosition', + size: 2, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: 0 + } + ] + }); + + /** + * Float32 view of the array buffer containing the pipeline's vertices. + * + * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#vertexViewF32 + * @type {Float32Array} + * @since 3.0.0 + */ + this.vertexViewF32 = new Float32Array(this.vertexData); + + /** + * Size of the batch. + * + * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#maxQuads + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.maxQuads = 1; + + /** + * Dirty flag to check if resolution properties need to be updated on the + * masking shader. + * + * @name Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resolutionDirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.resolutionDirty = true; + }, + + /** + * Called every time the pipeline needs to be used. + * It binds all necessary resources. + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#onBind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function () + { + WebGLPipeline.prototype.onBind.call(this); + + var renderer = this.renderer; + var program = this.program; + + if (this.resolutionDirty) + { + renderer.setFloat2(program, 'uResolution', this.width, this.height); + renderer.setInt1(program, 'uMainSampler', 0); + renderer.setInt1(program, 'uMaskSampler', 1); + this.resolutionDirty = false; + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#resize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * @param {number} resolution - [description] + * + * @return {this} This WebGLPipeline instance. + */ + resize: function (width, height, resolution) + { + WebGLPipeline.prototype.resize.call(this, width, height, resolution); + this.resolutionDirty = true; + return this; + }, + + /** + * Binds necessary resources and renders the mask to a separated framebuffer. + * The framebuffer for the masked object is also bound for further use. + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#beginMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - GameObject used as mask. + * @param {Phaser.GameObjects.GameObject} maskedObject - GameObject masked by the mask GameObject. + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + beginMask: function (mask, maskedObject, camera) + { + var renderer = this.renderer; + var gl = this.gl; + + // The renderable Game Object that is being used for the bitmap mask + var bitmapMask = mask.bitmapMask; + + if (bitmapMask && gl) + { + renderer.flush(); + + // First we clear the mask framebuffer + renderer.setFramebuffer(mask.maskFramebuffer); + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + + // We render our mask source + bitmapMask.renderWebGL(renderer, bitmapMask, 0, camera); + renderer.flush(); + + // Bind and clear our main source (masked object) + renderer.setFramebuffer(mask.mainFramebuffer); + + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + } + }, + + /** + * The masked game object's framebuffer is unbound and it's texture + * is bound together with the mask texture and the mask shader and + * a draw call with a single quad is processed. Here is where the + * masking effect is applied. + * + * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#endMask + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} mask - GameObject used as a mask. + */ + endMask: function (mask) + { + var renderer = this.renderer; + var gl = this.gl; + + // The renderable Game Object that is being used for the bitmap mask + var bitmapMask = mask.bitmapMask; + + if (bitmapMask && gl) + { + // Return to default framebuffer + renderer.setFramebuffer(null); + + // Bind bitmap mask pipeline and draw + renderer.setPipeline(this); + + renderer.setTexture2D(mask.maskTexture, 1); + renderer.setTexture2D(mask.mainTexture, 0); + renderer.setInt1(this.program, 'uInvertMaskAlpha', mask.invertAlpha); + + // Finally draw a triangle filling the whole screen + gl.drawArrays(this.topology, 0, 3); + } + } + +}); + +module.exports = BitmapMaskPipeline; + + +/***/ }), +/* 422 */ /***/ (function(module, exports) { /** @@ -71180,706 +97477,3103 @@ module.exports = GetPoint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ALIGN_CONST = { +/** + * Takes a snapshot of the current frame displayed by a WebGL canvas. + * + * @function Phaser.Renderer.Snapshot.WebGL + * @since 3.0.0 + * + * @param {HTMLCanvasElement} sourceCanvas - The canvas to take a snapshot of. + * @param {string} [type='image/png'] - The format of the returned image. + * @param {number} [encoderOptions=0.92] - The image quality, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). + * + * @return {HTMLImageElement} A new image which contains a snapshot of the canvas's contents. + */ +var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) +{ + if (!type) { type = 'image/png'; } + if (!encoderOptions) { encoderOptions = 0.92; } - /** - * A constant representing a top-left alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_LEFT - * @since 3.0.0 - * @type {integer} - */ - TOP_LEFT: 0, + var gl = sourceCanvas.getContext('experimental-webgl'); + var pixels = new Uint8Array(gl.drawingBufferWidth * gl.drawingBufferHeight * 4); + gl.readPixels(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight, gl.RGBA, gl.UNSIGNED_BYTE, pixels); - /** - * A constant representing a top-center alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_CENTER - * @since 3.0.0 - * @type {integer} - */ - TOP_CENTER: 1, + // CanvasPool? + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + var imageData; - /** - * A constant representing a top-right alignment or position. - * @constant - * @name Phaser.Display.Align.TOP_RIGHT - * @since 3.0.0 - * @type {integer} - */ - TOP_RIGHT: 2, + canvas.width = gl.drawingBufferWidth; + canvas.height = gl.drawingBufferHeight; - /** - * A constant representing a left-top alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_TOP - * @since 3.0.0 - * @type {integer} - */ - LEFT_TOP: 3, + imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - /** - * A constant representing a left-center alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_CENTER - * @since 3.0.0 - * @type {integer} - */ - LEFT_CENTER: 4, + var data = imageData.data; - /** - * A constant representing a left-bottom alignment or position. - * @constant - * @name Phaser.Display.Align.LEFT_BOTTOM - * @since 3.0.0 - * @type {integer} - */ - LEFT_BOTTOM: 5, + for (var y = 0; y < canvas.height; y += 1) + { + for (var x = 0; x < canvas.width; x += 1) + { + var si = ((canvas.height - y) * canvas.width + x) * 4; + var di = (y * canvas.width + x) * 4; + data[di + 0] = pixels[si + 0]; + data[di + 1] = pixels[si + 1]; + data[di + 2] = pixels[si + 2]; + data[di + 3] = pixels[si + 3]; + } + } - /** - * A constant representing a center alignment or position. - * @constant - * @name Phaser.Display.Align.CENTER - * @since 3.0.0 - * @type {integer} - */ - CENTER: 6, + ctx.putImageData(imageData, 0, 0); - /** - * A constant representing a right-top alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_TOP - * @since 3.0.0 - * @type {integer} - */ - RIGHT_TOP: 7, + var src = canvas.toDataURL(type, encoderOptions); + var image = new Image(); - /** - * A constant representing a right-center alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_CENTER - * @since 3.0.0 - * @type {integer} - */ - RIGHT_CENTER: 8, - - /** - * A constant representing a right-bottom alignment or position. - * @constant - * @name Phaser.Display.Align.RIGHT_BOTTOM - * @since 3.0.0 - * @type {integer} - */ - RIGHT_BOTTOM: 9, - - /** - * A constant representing a bottom-left alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_LEFT - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_LEFT: 10, - - /** - * A constant representing a bottom-center alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_CENTER - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_CENTER: 11, - - /** - * A constant representing a bottom-right alignment or position. - * @constant - * @name Phaser.Display.Align.BOTTOM_RIGHT - * @since 3.0.0 - * @type {integer} - */ - BOTTOM_RIGHT: 12 + image.src = src; + return image; }; -module.exports = ALIGN_CONST; +module.exports = WebGLSnapshot; /***/ }), -/* 300 */ +/* 423 */ /***/ (function(module, exports, __webpack_require__) { /** -* The `Matter.Constraint` module contains methods for creating and manipulating constraints. -* Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). -* The stiffness of constraints can be modified to create springs or elastic. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Constraint -*/ + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ -var Constraint = {}; +var BaseCamera = __webpack_require__(121); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(26); +var IsSizePowerOfTwo = __webpack_require__(117); +var SpliceOne = __webpack_require__(91); +var TransformMatrix = __webpack_require__(38); +var Utils = __webpack_require__(10); +var WebGLSnapshot = __webpack_require__(422); -module.exports = Constraint; +// Default Pipelines +var BitmapMaskPipeline = __webpack_require__(421); +var ForwardDiffuseLightPipeline = __webpack_require__(420); +var TextureTintPipeline = __webpack_require__(196); -var Vertices = __webpack_require__(126); -var Vector = __webpack_require__(106); -var Sleeping = __webpack_require__(331); -var Bounds = __webpack_require__(125); -var Axes = __webpack_require__(680); -var Common = __webpack_require__(41); +/** + * @callback WebGLContextCallback + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer which owns the context. + */ -(function() { +/** + * @typedef {object} SnapshotState + * + * @property {SnapshotCallback} callback - The function to call after the snapshot is taken. + * @property {string} type - The type of the image to create. + * @property {number} encoder - The image quality, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). + */ - Constraint._warming = 0.4; - Constraint._torqueDampen = 1; - Constraint._minLength = 0.000001; +/** + * @classdesc + * WebGLRenderer is a class that contains the needed functionality to keep the + * WebGLRenderingContext state clean. The main idea of the WebGLRenderer is to keep track of + * any context change that happens for WebGL rendering inside of Phaser. This means + * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL + * rendering ecosystem they might pollute the current WebGLRenderingContext state producing + * unexpected behavior. It's recommended that WebGL interaction is done through + * WebGLRenderer and/or WebGLPipeline. + * + * @class WebGLRenderer + * @memberof Phaser.Renderer.WebGL + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Game instance which owns this WebGL Renderer. + */ +var WebGLRenderer = new Class({ - /** - * Creates a new constraint. - * All properties have default values, and many are pre-calculated automatically based on other properties. - * To simulate a revolute constraint (or pin joint) set `length: 0` and a high `stiffness` value (e.g. `0.7` or above). - * If the constraint is unstable, try lowering the `stiffness` value and / or increasing `engine.constraintIterations`. - * See the properties section below for detailed information on what you can pass via the `options` object. - * @method create - * @param {} options - * @return {constraint} constraint - */ - Constraint.create = function(options) { - var constraint = options; + initialize: - // if bodies defined but no points, use body centre - if (constraint.bodyA && !constraint.pointA) - constraint.pointA = { x: 0, y: 0 }; - if (constraint.bodyB && !constraint.pointB) - constraint.pointB = { x: 0, y: 0 }; + function WebGLRenderer (game) + { + // eslint-disable-next-line consistent-this + var renderer = this; - // calculate static length using initial world space points - var initialPointA = constraint.bodyA ? Vector.add(constraint.bodyA.position, constraint.pointA) : constraint.pointA, - initialPointB = constraint.bodyB ? Vector.add(constraint.bodyB.position, constraint.pointB) : constraint.pointB, - length = Vector.magnitude(Vector.sub(initialPointA, initialPointB)); - - constraint.length = typeof constraint.length !== 'undefined' ? constraint.length : length; + var gameConfig = game.config; - // option defaults - constraint.id = constraint.id || Common.nextId(); - constraint.label = constraint.label || 'Constraint'; - constraint.type = 'constraint'; - constraint.stiffness = constraint.stiffness || (constraint.length > 0 ? 1 : 0.7); - constraint.damping = constraint.damping || 0; - constraint.angularStiffness = constraint.angularStiffness || 0; - constraint.angleA = constraint.bodyA ? constraint.bodyA.angle : constraint.angleA; - constraint.angleB = constraint.bodyB ? constraint.bodyB.angle : constraint.angleB; - constraint.plugin = {}; - - // render - var render = { - visible: true, - lineWidth: 2, - strokeStyle: '#ffffff', - type: 'line', - anchors: true + var contextCreationConfig = { + alpha: gameConfig.transparent, + depth: false, // enable when 3D is added in the future + antialias: gameConfig.antialias, + premultipliedAlpha: gameConfig.premultipliedAlpha, + stencil: true, + preserveDrawingBuffer: gameConfig.preserveDrawingBuffer, + failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat, + powerPreference: gameConfig.powerPreference }; - if (constraint.length === 0 && constraint.stiffness > 0.1) { - render.type = 'pin'; - render.anchors = false; - } else if (constraint.stiffness < 0.9) { - render.type = 'spring'; - } + /** + * The local configuration settings of this WebGL Renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: gameConfig.clearBeforeRender, + antialias: gameConfig.antialias, + backgroundColor: gameConfig.backgroundColor, + contextCreation: contextCreationConfig, + resolution: gameConfig.resolution, + autoResize: gameConfig.autoResize, + roundPixels: gameConfig.roundPixels, + maxTextures: gameConfig.maxTextures, + maxTextureSize: gameConfig.maxTextureSize, + batchSize: gameConfig.batchSize, + maxLights: gameConfig.maxLights + }; - constraint.render = Common.extend(render, constraint.render); + /** + * The Game instance which owns this WebGL Renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; - return constraint; - }; + /** + * A constant which allows the renderer to be easily identified as a WebGL Renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.WEBGL; + + /** + * The width of the canvas being rendered to. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#width + * @type {integer} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * The height of the canvas being rendered to. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#height + * @type {integer} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * The canvas which this WebGL Renderer draws to. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.canvas = game.canvas; + + /** + * An array of functions to invoke if the WebGL context is lost. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.lostContextCallbacks = []; + + /** + * An array of functions to invoke if the WebGL context is restored. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks + * @type {WebGLContextCallback[]} + * @since 3.0.0 + */ + this.restoredContextCallbacks = []; + + /** + * An array of blend modes supported by the WebGL Renderer. + * + * This array includes the default blend modes as well as any custom blend modes added through {@link #addBlendMode}. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.blendModes = []; + + /** + * Keeps track of any WebGLTexture created with the current WebGLRenderingContext + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#nativeTextures + * @type {array} + * @default [] + * @since 3.0.0 + */ + this.nativeTextures = []; + + /** + * Set to `true` if the WebGL context of the renderer is lost. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.contextLost = false; + + /** + * This object will store all pipelines created through addPipeline + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#pipelines + * @type {object} + * @default null + * @since 3.0.0 + */ + this.pipelines = null; + + /** + * Details about the currently scheduled snapshot. + * + * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState + * @type {SnapshotState} + * @since 3.0.0 + */ + this.snapshotState = { + callback: null, + type: null, + encoder: null + }; + + // Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc) + + /** + * Cached value for the last texture unit that was used + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentActiveTextureUnit + * @type {integer} + * @since 3.1.0 + */ + this.currentActiveTextureUnit = 0; + + /** + * An array of the last texture handles that were bound to the WebGLRenderingContext + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentTextures + * @type {array} + * @since 3.0.0 + */ + this.currentTextures = new Array(16); + + /** + * Current framebuffer in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentFramebuffer + * @type {WebGLFramebuffer} + * @default null + * @since 3.0.0 + */ + this.currentFramebuffer = null; + + /** + * Current WebGLPipeline in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @since 3.0.0 + */ + this.currentPipeline = null; + + /** + * Current WebGLProgram in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentProgram + * @type {WebGLProgram} + * @default null + * @since 3.0.0 + */ + this.currentProgram = null; + + /** + * Current WebGLBuffer (Vertex buffer) in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentVertexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentVertexBuffer = null; + + /** + * Current WebGLBuffer (Index buffer) in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentIndexBuffer + * @type {WebGLBuffer} + * @default null + * @since 3.0.0 + */ + this.currentIndexBuffer = null; + + /** + * Current blend mode in use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentBlendMode + * @type {integer} + * @since 3.0.0 + */ + this.currentBlendMode = Infinity; + + /** + * Indicates if the the scissor state is enabled in WebGLRenderingContext + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorEnabled + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.currentScissorEnabled = false; + + /** + * Stores the current scissor data + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissor + * @type {Uint32Array} + * @since 3.0.0 + */ + // this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); + this.currentScissor = null; + + /** + * Stack of scissor data + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#scissorStack + * @type {Uint32Array} + * @since 3.0.0 + */ + this.scissorStack = []; + + // Setup context lost and restore event listeners + + this.canvas.addEventListener('webglcontextlost', function (event) + { + renderer.contextLost = true; + event.preventDefault(); + + for (var index = 0; index < renderer.lostContextCallbacks.length; ++index) + { + var callback = renderer.lostContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + this.canvas.addEventListener('webglcontextrestored', function () + { + renderer.contextLost = false; + renderer.init(renderer.config); + for (var index = 0; index < renderer.restoredContextCallbacks.length; ++index) + { + var callback = renderer.restoredContextCallbacks[index]; + callback[0].call(callback[1], renderer); + } + }, false); + + // These are initialized post context creation + + /** + * The underlying WebGL context of the renderer. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#gl + * @type {WebGLRenderingContext} + * @default null + * @since 3.0.0 + */ + this.gl = null; + + /** + * Array of strings that indicate which WebGL extensions are supported by the browser + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#supportedExtensions + * @type {object} + * @default null + * @since 3.0.0 + */ + this.supportedExtensions = null; + + /** + * Extensions loaded into the current context + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#extensions + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.extensions = {}; + + /** + * Stores the current WebGL component formats for further use + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#glFormats + * @type {array} + * @default [] + * @since 3.2.0 + */ + this.glFormats = []; + + /** + * Stores the supported WebGL texture compression formats. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#compression + * @type {array} + * @since 3.8.0 + */ + this.compression = { + ETC1: false, + PVRTC: false, + S3TC: false + }; + + /** + * Cached drawing buffer height to reduce gl calls. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#drawingBufferHeight + * @type {number} + * @readonly + * @since 3.11.0 + */ + this.drawingBufferHeight = 0; + + /** + * A blank 32x32 transparent texture, as used by the Graphics system where needed. + * This is set in the `boot` method. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#blankTexture + * @type {WebGLTexture} + * @readonly + * @since 3.12.0 + */ + this.blankTexture = null; + + this.defaultCamera = new BaseCamera(0, 0, 0, 0); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + this.init(this.config); + }, /** - * Prepares for solving by constraint warming. - * @private - * @method preSolveAll - * @param {body[]} bodies + * Creates a new WebGLRenderingContext and initializes all internal + * state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#init + * @since 3.0.0 + * + * @param {object} config - The configuration object for the renderer. + * + * @return {this} This WebGLRenderer instance. */ - Constraint.preSolveAll = function(bodies) { - for (var i = 0; i < bodies.length; i += 1) { - var body = bodies[i], - impulse = body.constraintImpulse; + init: function (config) + { + var gl; + var canvas = this.canvas; + var clearColor = config.backgroundColor; - if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { - continue; + // Did they provide their own context? + if (this.game.config.context) + { + gl = this.game.config.context; + } + else + { + gl = canvas.getContext('webgl', config.contextCreation) || canvas.getContext('experimental-webgl', config.contextCreation); + } + + if (!gl || gl.isContextLost()) + { + this.contextLost = true; + + throw new Error('WebGL unsupported'); + } + + this.gl = gl; + + // Set it back into the Game, so developers can access it from there too + this.game.context = gl; + + for (var i = 0; i <= 16; i++) + { + this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); + } + + this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; + this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; + this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; + + this.glFormats[0] = gl.BYTE; + this.glFormats[1] = gl.SHORT; + this.glFormats[2] = gl.UNSIGNED_BYTE; + this.glFormats[3] = gl.UNSIGNED_SHORT; + this.glFormats[4] = gl.FLOAT; + + // Load supported extensions + var exts = gl.getSupportedExtensions(); + + if (!config.maxTextures) + { + config.maxTextures = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); + } + + if (!config.maxTextureSize) + { + config.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); + } + + var extString = 'WEBGL_compressed_texture_'; + var wkExtString = 'WEBKIT_' + extString; + + this.compression.ETC1 = gl.getExtension(extString + 'etc1') || gl.getExtension(wkExtString + 'etc1'); + this.compression.PVRTC = gl.getExtension(extString + 'pvrtc') || gl.getExtension(wkExtString + 'pvrtc'); + this.compression.S3TC = gl.getExtension(extString + 's3tc') || gl.getExtension(wkExtString + 's3tc'); + + this.supportedExtensions = exts; + + // Setup initial WebGL state + gl.disable(gl.DEPTH_TEST); + gl.disable(gl.CULL_FACE); + + // gl.disable(gl.SCISSOR_TEST); + + gl.enable(gl.BLEND); + gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); + + // Initialize all textures to null + for (var index = 0; index < this.currentTextures.length; ++index) + { + this.currentTextures[index] = null; + } + + // Clear previous pipelines and reload default ones + this.pipelines = {}; + + this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); + this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); + this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this, maxLights: config.maxLights })); + + this.setBlendMode(CONST.BlendModes.NORMAL); + + this.resize(this.width, this.height); + + this.game.events.once('texturesready', this.boot, this); + + return this; + }, + + /** + * Internal boot handler. Calls 'boot' on each pipeline. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#boot + * @private + * @since 3.11.0 + */ + boot: function () + { + for (var pipelineName in this.pipelines) + { + this.pipelines[pipelineName].boot(); + } + + var blank = this.game.textures.getFrame('__DEFAULT'); + + this.pipelines.TextureTintPipeline.currentFrame = blank; + + this.blankTexture = blank; + }, + + /** + * Resizes the drawing buffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#resize + * @since 3.0.0 + * + * @param {number} width - The width of the renderer. + * @param {number} height - The height of the renderer. + * + * @return {this} This WebGLRenderer instance. + */ + resize: function (width, height) + { + var gl = this.gl; + var pipelines = this.pipelines; + var resolution = this.config.resolution; + + this.width = Math.floor(width * resolution); + this.height = Math.floor(height * resolution); + + this.canvas.width = this.width; + this.canvas.height = this.height; + + if (this.config.autoResize) + { + this.canvas.style.width = (this.width / resolution) + 'px'; + this.canvas.style.height = (this.height / resolution) + 'px'; + } + + gl.viewport(0, 0, this.width, this.height); + + // Update all registered pipelines + for (var pipelineName in pipelines) + { + pipelines[pipelineName].resize(width, height, resolution); + } + + this.drawingBufferHeight = gl.drawingBufferHeight; + + this.defaultCamera.setSize(width, height); + + gl.scissor(0, (this.drawingBufferHeight - this.height), this.width, this.height); + + return this; + }, + + /** + * Adds a callback to be invoked when the WebGL context has been restored by the browser. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - The callback to be invoked on context restoration. + * @param {object} target - The context of the callback. + * + * @return {this} This WebGLRenderer instance. + */ + onContextRestored: function (callback, target) + { + this.restoredContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * Adds a callback to be invoked when the WebGL context has been lost by the browser. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost + * @since 3.0.0 + * + * @param {WebGLContextCallback} callback - The callback to be invoked on context loss. + * @param {object} target - The context of the callback. + * + * @return {this} This WebGLRenderer instance. + */ + onContextLost: function (callback, target) + { + this.lostContextCallbacks.push([ callback, target ]); + + return this; + }, + + /** + * Checks if a WebGL extension is supported + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasExtension + * @since 3.0.0 + * + * @param {string} extensionName - Name of the WebGL extension + * + * @return {boolean} `true` if the extension is supported, otherwise `false`. + */ + hasExtension: function (extensionName) + { + return this.supportedExtensions ? this.supportedExtensions.indexOf(extensionName) : false; + }, + + /** + * Loads a WebGL extension + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension + * @since 3.0.0 + * + * @param {string} extensionName - The name of the extension to load. + * + * @return {object} WebGL extension if the extension is supported + */ + getExtension: function (extensionName) + { + if (!this.hasExtension(extensionName)) { return null; } + + if (!(extensionName in this.extensions)) + { + this.extensions[extensionName] = this.gl.getExtension(extensionName); + } + + return this.extensions[extensionName]; + }, + + /** + * Flushes the current pipeline if the pipeline is bound + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#flush + * @since 3.0.0 + */ + flush: function () + { + if (this.currentPipeline) + { + this.currentPipeline.flush(); + } + }, + + /** + * Checks if a pipeline is present in the current WebGLRenderer + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline. + * + * @return {boolean} `true` if the given pipeline is loaded, otherwise `false`. + */ + hasPipeline: function (pipelineName) + { + return (pipelineName in this.pipelines); + }, + + /** + * Returns the pipeline by name if the pipeline exists + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline. + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline instance, or `null` if not found. + */ + getPipeline: function (pipelineName) + { + return (this.hasPipeline(pipelineName)) ? this.pipelines[pipelineName] : null; + }, + + /** + * Removes a pipeline by name. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to be removed. + * + * @return {this} This WebGLRenderer instance. + */ + removePipeline: function (pipelineName) + { + delete this.pipelines[pipelineName]; + + return this; + }, + + /** + * Adds a pipeline instance into the collection of pipelines + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline + * @since 3.0.0 + * + * @param {string} pipelineName - A unique string-based key for the pipeline. + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - A pipeline instance which must extend WebGLPipeline. + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipline instance that was passed. + */ + addPipeline: function (pipelineName, pipelineInstance) + { + if (!this.hasPipeline(pipelineName)) + { + this.pipelines[pipelineName] = pipelineInstance; + } + else + { + console.warn('Pipeline exists: ' + pipelineName); + } + + pipelineInstance.name = pipelineName; + + this.pipelines[pipelineName].resize(this.width, this.height, this.config.resolution); + + return pipelineInstance; + }, + + /** + * Pushes a new scissor state. This is used to set nested scissor states. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor + * @since 3.0.0 + * + * @param {integer} x - The x position of the scissor. + * @param {integer} y - The y position of the scissor. + * @param {integer} width - The width of the scissor. + * @param {integer} height - The height of the scissor. + * + * @return {integer[]} An array containing the scissor values. + */ + pushScissor: function (x, y, width, height) + { + var scissorStack = this.scissorStack; + + var scissor = [ x, y, width, height ]; + + scissorStack.push(scissor); + + this.setScissor(x, y, width, height); + + this.currentScissor = scissor; + + return scissor; + }, + + /** + * Sets the current scissor state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor + * @since 3.0.0 + * + * @param {integer} x - The x position of the scissor. + * @param {integer} y - The y position of the scissor. + * @param {integer} width - The width of the scissor. + * @param {integer} height - The height of the scissor. + */ + setScissor: function (x, y, width, height) + { + var gl = this.gl; + + var current = this.currentScissor; + + var cx = current[0]; + var cy = current[1]; + var cw = current[2]; + var ch = current[3]; + + if (cx !== x || cy !== y || cw !== width || ch !== height) + { + this.flush(); + + // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/scissor + + if (width > 0 && height > 0) + { + gl.scissor(x, (this.drawingBufferHeight - y - height), width, height); + + } + } + }, + + /** + * Pops the last scissor state and sets it. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor + * @since 3.0.0 + */ + popScissor: function () + { + var scissorStack = this.scissorStack; + + // Remove the current scissor + scissorStack.pop(); + + // Reset the previous scissor + var scissor = scissorStack[scissorStack.length - 1]; + + if (scissor) + { + this.setScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + } + + this.currentScissor = scissor; + }, + + /** + * Binds a WebGLPipeline and sets it as the current pipeline to be used. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline + * @since 3.0.0 + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - The pipeline instance to be activated. + * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any. + * + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline that was activated. + */ + setPipeline: function (pipelineInstance, gameObject) + { + if (this.currentPipeline !== pipelineInstance || + this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || + this.currentPipeline.program !== this.currentProgram) + { + this.flush(); + this.currentPipeline = pipelineInstance; + this.currentPipeline.bind(); + } + + this.currentPipeline.onBind(gameObject); + + return this.currentPipeline; + }, + + /** + * Sets the blend mode to the value given. + * + * If the current blend mode is different from the one given, the pipeline is flushed and the new + * blend mode is enabled. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode + * @since 3.0.0 + * + * @param {integer} blendModeId - The blend mode to be set. Can be a `BlendModes` const or an integer value. + * + * @return {boolean} `true` if the blend mode was changed as a result of this call, forcing a flush, otherwise `false`. + */ + setBlendMode: function (blendModeId) + { + var gl = this.gl; + var blendMode = this.blendModes[blendModeId]; + + if (blendModeId !== CONST.BlendModes.SKIP_CHECK && this.currentBlendMode !== blendModeId) + { + this.flush(); + + gl.enable(gl.BLEND); + gl.blendEquation(blendMode.equation); + + if (blendMode.func.length > 2) + { + gl.blendFuncSeparate(blendMode.func[0], blendMode.func[1], blendMode.func[2], blendMode.func[3]); + } + else + { + gl.blendFunc(blendMode.func[0], blendMode.func[1]); } - body.position.x += impulse.x; - body.position.y += impulse.y; - body.angle += impulse.angle; + this.currentBlendMode = blendModeId; + + return true; } - }; + + return false; + }, /** - * Solves all constraints in a list of collisions. - * @private - * @method solveAll - * @param {constraint[]} constraints - * @param {number} timeScale + * Creates a new custom blend mode for the renderer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#addBlendMode + * @since 3.0.0 + * + * @param {function} func - An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for {@link WebGLRenderingContext#blendFunc()}. + * @param {function} equation - The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for {@link WebGLRenderingContext#blendEquation()}. + * + * @return {integer} The index of the new blend mode, used for referencing it in the future. */ - Constraint.solveAll = function(constraints, timeScale) { - // Solve fixed constraints first. - for (var i = 0; i < constraints.length; i += 1) { - var constraint = constraints[i], - fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic), - fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); + addBlendMode: function (func, equation) + { + var index = this.blendModes.push({ func: func, equation: equation }); - if (fixedA || fixedB) { - Constraint.solve(constraints[i], timeScale); + return index - 1; + }, + + /** + * Updates the function bound to a given custom blend mode. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#updateBlendMode + * @since 3.0.0 + * + * @param {integer} index - The index of the custom blend mode. + * @param {function} func - The function to use for the blend mode. + * @param {function} equation - The equation to use for the blend mode. + * + * @return {this} This WebGLRenderer instance. + */ + updateBlendMode: function (index, func, equation) + { + if (this.blendModes[index]) + { + this.blendModes[index].func = func; + + if (equation) + { + this.blendModes[index].equation = equation; } } - // Solve free constraints last. - for (i = 0; i < constraints.length; i += 1) { - constraint = constraints[i]; - fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic); - fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic); - - if (!fixedA && !fixedB) { - Constraint.solve(constraints[i], timeScale); - } - } - }; + return this; + }, /** - * Solves a distance constraint with Gauss-Siedel method. - * @private - * @method solve - * @param {constraint} constraint - * @param {number} timeScale + * Removes a custom blend mode from the renderer. + * Any Game Objects still using this blend mode will error, so be sure to clear them first. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#removeBlendMode + * @since 3.0.0 + * + * @param {integer} index - The index of the custom blend mode to be removed. + * + * @return {this} This WebGLRenderer instance. */ - Constraint.solve = function(constraint, timeScale) { - var bodyA = constraint.bodyA, - bodyB = constraint.bodyB, - pointA = constraint.pointA, - pointB = constraint.pointB; - - if (!bodyA && !bodyB) - return; - - // update reference angle - if (bodyA && !bodyA.isStatic) { - Vector.rotate(pointA, bodyA.angle - constraint.angleA, pointA); - constraint.angleA = bodyA.angle; - } - - // update reference angle - if (bodyB && !bodyB.isStatic) { - Vector.rotate(pointB, bodyB.angle - constraint.angleB, pointB); - constraint.angleB = bodyB.angle; + removeBlendMode: function (index) + { + if (index > 16 && this.blendModes[index]) + { + this.blendModes.splice(index, 1); } - var pointAWorld = pointA, - pointBWorld = pointB; + return this; + }, - if (bodyA) pointAWorld = Vector.add(bodyA.position, pointA); - if (bodyB) pointBWorld = Vector.add(bodyB.position, pointB); + /** + * Sets the current active texture for texture unit zero to be a blank texture. + * This only happens if there isn't a texture already in use by texture unit zero. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlankTexture + * @private + * @since 3.12.0 + * + * @param {boolean} [force=false] - Force a blank texture set, regardless of what's already bound? + */ + setBlankTexture: function (force) + { + if (force === undefined) { force = false; } - if (!pointAWorld || !pointBWorld) - return; + if (force || this.currentActiveTextureUnit !== 0 || !this.currentTextures[0]) + { + this.setTexture2D(this.blankTexture.glTexture, 0); + } + }, - var delta = Vector.sub(pointAWorld, pointBWorld), - currentLength = Vector.magnitude(delta); + /** + * Binds a texture at a texture unit. If a texture is already + * bound to that unit it will force a flush on the current pipeline. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D + * @since 3.0.0 + * + * @param {WebGLTexture} texture - The WebGL texture that needs to be bound. + * @param {integer} textureUnit - The texture unit to which the texture will be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setTexture2D: function (texture, textureUnit) + { + var gl = this.gl; - // prevent singularity - if (currentLength < Constraint._minLength) { - currentLength = Constraint._minLength; + if (texture !== this.currentTextures[textureUnit]) + { + this.flush(); + + if (this.currentActiveTextureUnit !== textureUnit) + { + gl.activeTexture(gl.TEXTURE0 + textureUnit); + + this.currentActiveTextureUnit = textureUnit; + } + + gl.bindTexture(gl.TEXTURE_2D, texture); + + this.currentTextures[textureUnit] = texture; } - // solve distance constraint with Gauss-Siedel method - var difference = (currentLength - constraint.length) / currentLength, - stiffness = constraint.stiffness < 1 ? constraint.stiffness * timeScale : constraint.stiffness, - force = Vector.mult(delta, difference * stiffness), - massTotal = (bodyA ? bodyA.inverseMass : 0) + (bodyB ? bodyB.inverseMass : 0), - inertiaTotal = (bodyA ? bodyA.inverseInertia : 0) + (bodyB ? bodyB.inverseInertia : 0), - resistanceTotal = massTotal + inertiaTotal, - torque, - share, - normal, - normalVelocity, - relativeVelocity; + return this; + }, - if (constraint.damping) { - var zero = Vector.create(); - normal = Vector.div(delta, currentLength); + /** + * Binds a framebuffer. If there was another framebuffer already bound it will force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setFramebuffer: function (framebuffer) + { + var gl = this.gl; - relativeVelocity = Vector.sub( - bodyB && Vector.sub(bodyB.position, bodyB.positionPrev) || zero, - bodyA && Vector.sub(bodyA.position, bodyA.positionPrev) || zero + var width = this.width; + var height = this.height; + + if (framebuffer !== this.currentFramebuffer) + { + if (framebuffer && framebuffer.renderTexture) + { + width = framebuffer.renderTexture.width; + height = framebuffer.renderTexture.height; + } + else + { + this.flush(); + } + + gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + + gl.viewport(0, 0, width, height); + + this.currentFramebuffer = framebuffer; + } + + return this; + }, + + /** + * Binds a program. If there was another program already bound it will force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - The program that needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setProgram: function (program) + { + var gl = this.gl; + + if (program !== this.currentProgram) + { + this.flush(); + + gl.useProgram(program); + + this.currentProgram = program; + } + + return this; + }, + + /** + * Bounds a vertex buffer. If there is a vertex buffer already bound it'll force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - The buffer that needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setVertexBuffer: function (vertexBuffer) + { + var gl = this.gl; + + if (vertexBuffer !== this.currentVertexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer); + + this.currentVertexBuffer = vertexBuffer; + } + + return this; + }, + + /** + * Bounds a index buffer. If there is a index buffer already bound it'll force a pipeline flush. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} indexBuffer - The buffer the needs to be bound. + * + * @return {this} This WebGLRenderer instance. + */ + setIndexBuffer: function (indexBuffer) + { + var gl = this.gl; + + if (indexBuffer !== this.currentIndexBuffer) + { + this.flush(); + + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer); + + this.currentIndexBuffer = indexBuffer; + } + + return this; + }, + + /** + * Creates a texture from an image source. If the source is not valid it creates an empty texture. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource + * @since 3.0.0 + * + * @param {object} source - The source of the texture. + * @param {integer} width - The width of the texture. + * @param {integer} height - The height of the texture. + * @param {integer} scaleMode - The scale mode to be used by the texture. + * + * @return {?WebGLTexture} The WebGL Texture that was created, or `null` if it couldn't be created. + */ + createTextureFromSource: function (source, width, height, scaleMode) + { + var gl = this.gl; + var filter = gl.NEAREST; + var wrap = gl.CLAMP_TO_EDGE; + var texture = null; + + width = source ? source.width : width; + height = source ? source.height : height; + + if (IsSizePowerOfTwo(width, height)) + { + wrap = gl.REPEAT; + } + + if (scaleMode === CONST.ScaleModes.LINEAR && this.config.antialias) + { + filter = gl.LINEAR; + } + + if (!source && typeof width === 'number' && typeof height === 'number') + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + } + else + { + texture = this.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, source); + } + + return texture; + }, + + /** + * A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D + * @since 3.0.0 + * + * @param {integer} mipLevel - Mip level of the texture. + * @param {integer} minFilter - Filtering of the texture. + * @param {integer} magFilter - Filtering of the texture. + * @param {integer} wrapT - Wrapping mode of the texture. + * @param {integer} wrapS - Wrapping mode of the texture. + * @param {integer} format - Which format does the texture use. + * @param {object} pixels - pixel data. + * @param {integer} width - Width of the texture in pixels. + * @param {integer} height - Height of the texture in pixels. + * @param {boolean} pma - Does the texture have premultiplied alpha? + * + * @return {WebGLTexture} The WebGLTexture that was created. + */ + createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) + { + pma = (pma === undefined || pma === null) ? true : pma; + + var gl = this.gl; + var texture = gl.createTexture(); + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, wrapS); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, wrapT); + gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, pma); + + if (pixels === null || pixels === undefined) + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, width, height, 0, format, gl.UNSIGNED_BYTE, null); + } + else + { + gl.texImage2D(gl.TEXTURE_2D, mipLevel, format, format, gl.UNSIGNED_BYTE, pixels); + width = pixels.width; + height = pixels.height; + } + + this.setTexture2D(null, 0); + + texture.isAlphaPremultiplied = pma; + texture.isRenderTexture = false; + texture.width = width; + texture.height = height; + + this.nativeTextures.push(texture); + + return texture; + }, + + /** + * Wrapper for creating WebGLFramebuffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createFramebuffer + * @since 3.0.0 + * + * @param {integer} width - Width in pixels of the framebuffer + * @param {integer} height - Height in pixels of the framebuffer + * @param {WebGLTexture} renderTexture - The color texture to where the color pixels are written + * @param {boolean} addDepthStencilBuffer - Indicates if the current framebuffer support depth and stencil buffers + * + * @return {WebGLFramebuffer} Raw WebGLFramebuffer + */ + createFramebuffer: function (width, height, renderTexture, addDepthStencilBuffer) + { + var gl = this.gl; + var framebuffer = gl.createFramebuffer(); + var complete = 0; + + this.setFramebuffer(framebuffer); + + if (addDepthStencilBuffer) + { + var depthStencilBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer); + gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height); + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer); + } + + renderTexture.isRenderTexture = true; + renderTexture.isAlphaPremultiplied = false; + + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, renderTexture, 0); + + complete = gl.checkFramebufferStatus(gl.FRAMEBUFFER); + + if (complete !== gl.FRAMEBUFFER_COMPLETE) + { + var errors = { + 36054: 'Incomplete Attachment', + 36055: 'Missing Attachment', + 36057: 'Incomplete Dimensions', + 36061: 'Framebuffer Unsupported' + }; + + throw new Error('Framebuffer incomplete. Framebuffer status: ' + errors[complete]); + } + + framebuffer.renderTexture = renderTexture; + + this.setFramebuffer(null); + + return framebuffer; + }, + + /** + * Wrapper for creating a WebGLProgram + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createProgram + * @since 3.0.0 + * + * @param {string} vertexShader - Source to the vertex shader + * @param {string} fragmentShader - Source to the fragment shader + * + * @return {WebGLProgram} Raw WebGLProgram + */ + createProgram: function (vertexShader, fragmentShader) + { + var gl = this.gl; + var program = gl.createProgram(); + var vs = gl.createShader(gl.VERTEX_SHADER); + var fs = gl.createShader(gl.FRAGMENT_SHADER); + + gl.shaderSource(vs, vertexShader); + gl.shaderSource(fs, fragmentShader); + gl.compileShader(vs); + gl.compileShader(fs); + + if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Vertex Shader:\n' + gl.getShaderInfoLog(vs)); + } + if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) + { + throw new Error('Failed to compile Fragment Shader:\n' + gl.getShaderInfoLog(fs)); + } + + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.linkProgram(program); + + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) + { + throw new Error('Failed to link program:\n' + gl.getProgramInfoLog(program)); + } + + return program; + }, + + /** + * Wrapper for creating a vertex buffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createVertexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo + * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW + * + * @return {WebGLBuffer} Raw vertex buffer + */ + createVertexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var vertexBuffer = gl.createBuffer(); + + this.setVertexBuffer(vertexBuffer); + + gl.bufferData(gl.ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setVertexBuffer(null); + + return vertexBuffer; + }, + + /** + * Wrapper for creating a vertex buffer. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer + * @since 3.0.0 + * + * @param {ArrayBuffer} initialDataOrSize - Either ArrayBuffer or an integer indicating the size of the vbo. + * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. + * + * @return {WebGLBuffer} Raw index buffer + */ + createIndexBuffer: function (initialDataOrSize, bufferUsage) + { + var gl = this.gl; + var indexBuffer = gl.createBuffer(); + + this.setIndexBuffer(indexBuffer); + + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, initialDataOrSize, bufferUsage); + + this.setIndexBuffer(null); + + return indexBuffer; + }, + + /** + * Removes the given texture from the nativeTextures array and then deletes it from the GPU. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture + * @since 3.0.0 + * + * @param {WebGLTexture} texture - The WebGL Texture to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteTexture: function (texture) + { + var index = this.nativeTextures.indexOf(texture); + + if (index !== -1) + { + SpliceOne(this.nativeTextures, index); + } + + this.gl.deleteTexture(texture); + + if (this.currentTextures[0] === texture) + { + // texture we just deleted is in use, so bind a blank texture + this.setBlankTexture(true); + } + + return this; + }, + + /** + * Deletes a WebGLFramebuffer from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer + * @since 3.0.0 + * + * @param {WebGLFramebuffer} framebuffer - The Framebuffer to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteFramebuffer: function (framebuffer) + { + this.gl.deleteFramebuffer(framebuffer); + + return this; + }, + + /** + * Deletes a WebGLProgram from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram + * @since 3.0.0 + * + * @param {WebGLProgram} program - The shader program to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteProgram: function (program) + { + this.gl.deleteProgram(program); + + return this; + }, + + /** + * Deletes a WebGLBuffer from the GL instance. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer + * @since 3.0.0 + * + * @param {WebGLBuffer} vertexBuffer - The WebGLBuffer to be deleted. + * + * @return {this} This WebGLRenderer instance. + */ + deleteBuffer: function (buffer) + { + this.gl.deleteBuffer(buffer); + + return this; + }, + + /** + * Controls the pre-render operations for the given camera. + * Handles any clipping needed by the camera and renders the background color if a color is visible. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to pre-render. + */ + preRenderCamera: function (camera) + { + var cx = camera._cx; + var cy = camera._cy; + var cw = camera._cw; + var ch = camera._ch; + + var TextureTintPipeline = this.pipelines.TextureTintPipeline; + + var color = camera.backgroundColor; + + if (camera.renderToTexture) + { + this.flush(); + + this.pushScissor(cx, cy, cw, -ch); + + this.setFramebuffer(camera.framebuffer); + + var gl = this.gl; + + gl.clearColor(0, 0, 0, 0); + + gl.clear(gl.COLOR_BUFFER_BIT); + + TextureTintPipeline.projOrtho(cx, cw + cx, cy, ch + cy, -1000, 1000); + + if (color.alphaGL > 0) + { + TextureTintPipeline.drawFillRect( + cx, cy, cw + cx, ch + cy, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1), + color.alphaGL + ); + } + + camera.emit('prerender', camera); + } + else + { + this.pushScissor(cx, cy, cw, ch); + + if (color.alphaGL > 0) + { + TextureTintPipeline.drawFillRect( + cx, cy, cw , ch, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1), + color.alphaGL + ); + } + } + }, + + /** + * Controls the post-render operations for the given camera. + * Renders the foreground camera effects like flash and fading. It resets the current scissor state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to post-render. + */ + postRenderCamera: function (camera) + { + var TextureTintPipeline = this.pipelines.TextureTintPipeline; + + camera.flashEffect.postRenderWebGL(TextureTintPipeline, Utils.getTintFromFloats); + camera.fadeEffect.postRenderWebGL(TextureTintPipeline, Utils.getTintFromFloats); + + camera.dirty = false; + + this.popScissor(); + + if (camera.renderToTexture) + { + TextureTintPipeline.flush(); + + this.setFramebuffer(null); + + camera.emit('postrender', camera); + + TextureTintPipeline.projOrtho(0, TextureTintPipeline.width, TextureTintPipeline.height, 0, -1000.0, 1000.0); + + var getTint = Utils.getTintAppendFloatAlpha; + + var pipeline = (camera.pipeline) ? camera.pipeline : TextureTintPipeline; + + pipeline.batchTexture( + camera, + camera.glTexture, + camera.width, camera.height, + camera.x, camera.y, + camera.width, camera.height, + camera.zoom, camera.zoom, + camera.rotation, + camera.flipX, !camera.flipY, + 1, 1, + 0, 0, + 0, 0, camera.width, camera.height, + getTint(camera._tintTL, camera._alphaTL), + getTint(camera._tintTR, camera._alphaTR), + getTint(camera._tintBL, camera._alphaBL), + getTint(camera._tintBR, camera._alphaBR), + (camera._isTinted && camera.tintFill), + 0, 0, + this.defaultCamera, + null ); - normalVelocity = Vector.dot(normal, relativeVelocity); + // Force clear the current texture so that items next in the batch (like Graphics) don't try and use it + this.setBlankTexture(true); } - - if (bodyA && !bodyA.isStatic) { - share = bodyA.inverseMass / massTotal; - - // keep track of applied impulses for post solving - bodyA.constraintImpulse.x -= force.x * share; - bodyA.constraintImpulse.y -= force.y * share; - - // apply forces - bodyA.position.x -= force.x * share; - bodyA.position.y -= force.y * share; - - // apply damping - if (constraint.damping) { - bodyA.positionPrev.x -= constraint.damping * normal.x * normalVelocity * share; - bodyA.positionPrev.y -= constraint.damping * normal.y * normalVelocity * share; - } - - // apply torque - torque = (Vector.cross(pointA, force) / resistanceTotal) * Constraint._torqueDampen * bodyA.inverseInertia * (1 - constraint.angularStiffness); - bodyA.constraintImpulse.angle -= torque; - bodyA.angle -= torque; - } - - if (bodyB && !bodyB.isStatic) { - share = bodyB.inverseMass / massTotal; - - // keep track of applied impulses for post solving - bodyB.constraintImpulse.x += force.x * share; - bodyB.constraintImpulse.y += force.y * share; - - // apply forces - bodyB.position.x += force.x * share; - bodyB.position.y += force.y * share; - - // apply damping - if (constraint.damping) { - bodyB.positionPrev.x += constraint.damping * normal.x * normalVelocity * share; - bodyB.positionPrev.y += constraint.damping * normal.y * normalVelocity * share; - } - - // apply torque - torque = (Vector.cross(pointB, force) / resistanceTotal) * Constraint._torqueDampen * bodyB.inverseInertia * (1 - constraint.angularStiffness); - bodyB.constraintImpulse.angle += torque; - bodyB.angle += torque; - } - - }; + }, /** - * Performs body updates required after solving constraints. - * @private - * @method postSolveAll - * @param {body[]} bodies + * Clears the current vertex buffer and updates pipelines. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#preRender + * @since 3.0.0 */ - Constraint.postSolveAll = function(bodies) { - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i], - impulse = body.constraintImpulse; + preRender: function () + { + if (this.contextLost) { return; } - if (body.isStatic || (impulse.x === 0 && impulse.y === 0 && impulse.angle === 0)) { + var gl = this.gl; + var color = this.config.backgroundColor; + var pipelines = this.pipelines; + + if (this.config.clearBeforeRender) + { + gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + } + + gl.enable(gl.SCISSOR_TEST); + + for (var key in pipelines) + { + pipelines[key].onPreRender(); + } + + // TODO - Find a way to stop needing to create these arrays every frame + // and equally not need a huge array buffer created to hold them + + this.currentScissor = [ 0, 0, this.width, this.height ]; + this.scissorStack = [ this.currentScissor ]; + + if (this.game.scene.customViewports) + { + gl.scissor(0, (this.drawingBufferHeight - this.height), this.width, this.height); + } + + this.setPipeline(this.pipelines.TextureTintPipeline); + }, + + /** + * The core render step for a Scene. + * Iterates through the given Game Object's array and renders them with the given Camera. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to render. + * @param {Phaser.GameObjects.GameObject} children - The Game Object's within the Scene to be rendered. + * @param {number} interpolationPercentage - The interpolation percentage to apply. Currently un-used. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Scene Camera to render with. + */ + render: function (scene, children, interpolationPercentage, camera) + { + if (this.contextLost) { return; } + + var list = children.list; + var childCount = list.length; + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onRender(scene, camera); + } + + // Apply scissor for cam region + render background color, if not transparent + this.preRenderCamera(camera); + + for (var i = 0; i < childCount; i++) + { + var child = list[i]; + + if (!child.willRender(camera)) + { continue; } - Sleeping.set(body, false); - - // update geometry and reset - for (var j = 0; j < body.parts.length; j++) { - var part = body.parts[j]; - - Vertices.translate(part.vertices, impulse); - - if (j > 0) { - part.position.x += impulse.x; - part.position.y += impulse.y; - } - - if (impulse.angle !== 0) { - Vertices.rotate(part.vertices, impulse.angle, body.position); - Axes.rotate(part.axes, impulse.angle); - if (j > 0) { - Vector.rotateAbout(part.position, impulse.angle, body.position, part.position); - } - } - - Bounds.update(part.bounds, part.vertices, body.velocity); + if (child.blendMode !== this.currentBlendMode) + { + this.setBlendMode(child.blendMode); } - // dampen the cached impulse for warming next step - impulse.angle *= Constraint._warming; - impulse.x *= Constraint._warming; - impulse.y *= Constraint._warming; + var mask = child.mask; + + if (mask) + { + mask.preRenderWebGL(this, child, camera); + + child.renderWebGL(this, child, interpolationPercentage, camera); + + mask.postRenderWebGL(this, child); + } + else + { + child.renderWebGL(this, child, interpolationPercentage, camera); + } } - }; - /* - * - * Properties Documentation - * - */ + this.setBlendMode(CONST.BlendModes.NORMAL); + + // Applies camera effects and pops the scissor, if set + this.postRenderCamera(camera); + }, /** - * An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`. + * The post-render step happens after all Cameras in all Scenes have been rendered. * - * @property id - * @type number + * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender + * @since 3.0.0 */ + postRender: function () + { + if (this.contextLost) { return; } + + this.flush(); + + // Unbind custom framebuffer here + + if (this.snapshotState.callback) + { + this.snapshotState.callback(WebGLSnapshot(this.canvas, this.snapshotState.type, this.snapshotState.encoder)); + this.snapshotState.callback = null; + } + + var pipelines = this.pipelines; + + for (var key in pipelines) + { + pipelines[key].onPostRender(); + } + }, /** - * A `String` denoting the type of object. + * Schedules a snapshot to be taken after the current frame is rendered. * - * @property type - * @type string - * @default "constraint" - * @readOnly + * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - Function to invoke after the snapshot is created. + * @param {string} type - The format of the image to create, usually `image/png`. + * @param {number} encoderOptions - The image quality, between 0 and 1, to use for image formats with lossy compression (such as `image/jpeg`). + * + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotState.callback = callback; + this.snapshotState.type = type; + this.snapshotState.encoder = encoderOptions; + + return this; + }, /** - * An arbitrary `String` name to help the user identify and manage bodies. + * Creates a WebGL Texture based on the given canvas element. * - * @property label - * @type string - * @default "Constraint" + * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture + * @since 3.0.0 + * + * @param {HTMLCanvasElement} srcCanvas - The Canvas element that will be used to populate the texture. + * @param {WebGLTexture} [dstTexture] - Is this going to replace an existing texture? If so, pass it here. + * @param {boolean} [noRepeat=false] - Should this canvas never be allowed to set REPEAT? (such as for Text objects) + * + * @return {WebGLTexture} The newly created WebGL Texture. */ + canvasToTexture: function (srcCanvas, dstTexture, noRepeat) + { + if (noRepeat === undefined) { noRepeat = false; } + + var gl = this.gl; + + if (!dstTexture) + { + var wrapping = gl.CLAMP_TO_EDGE; + + if (!noRepeat && IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) + { + wrapping = gl.REPEAT; + } + + dstTexture = this.createTexture2D(0, gl.NEAREST, gl.NEAREST, wrapping, wrapping, gl.RGBA, srcCanvas, srcCanvas.width, srcCanvas.height, true); + } + else + { + this.setTexture2D(dstTexture, 0); + + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, srcCanvas); + + dstTexture.width = srcCanvas.width; + dstTexture.height = srcCanvas.height; + + this.setTexture2D(null, 0); + } + + return dstTexture; + }, /** - * An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`. + * Sets the minification and magnification filter for a texture. * - * @property render - * @type object + * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter + * @since 3.0.0 + * + * @param {integer} texture - The texture to set the filter for. + * @param {integer} filter - The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. + * + * @return {this} This WebGL Renderer instance. */ + setTextureFilter: function (texture, filter) + { + var gl = this.gl; + var glFilter = [ gl.LINEAR, gl.NEAREST ][filter]; + + this.setTexture2D(texture, 0); + + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glFilter); + + this.setTexture2D(null, 0); + + return this; + }, /** - * A flag that indicates if the constraint should be rendered. + * [description] * - * @property render.visible - * @type boolean - * @default true + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * + * @return {this} This WebGL Renderer instance. */ + setFloat1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1f(this.gl.getUniformLocation(program, name), x); + + return this; + }, /** - * A `Number` that defines the line width to use when rendering the constraint outline. - * A value of `0` means no outline will be rendered. + * [description] * - * @property render.lineWidth - * @type number - * @default 2 + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {this} This WebGL Renderer instance. */ + setFloat2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2f(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, /** - * A `String` that defines the stroke style to use when rendering the constraint outline. - * It is the same as when using a canvas, so it accepts CSS style property values. + * [description] * - * @property render.strokeStyle - * @type string - * @default a random colour + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {this} This WebGL Renderer instance. */ + setFloat3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3f(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, /** - * A `String` that defines the constraint rendering type. - * The possible values are 'line', 'pin', 'spring'. - * An appropriate render type will be automatically chosen unless one is given in options. + * Sets uniform of a WebGLProgram * - * @property render.type - * @type string - * @default 'line' + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - X component + * @param {number} y - Y component + * @param {number} z - Z component + * @param {number} w - W component + * + * @return {this} This WebGL Renderer instance. */ + setFloat4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4f(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, /** - * A `Boolean` that defines if the constraint's anchor points should be rendered. + * Sets the value of a uniform variable in the given WebGLProgram. * - * @property render.anchors - * @type boolean - * @default true + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. */ + setFloat1v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform1fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, /** - * The first possible `Body` that this constraint is attached to. + * Sets the value of a uniform variable in the given WebGLProgram. * - * @property bodyA - * @type body - * @default null + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. */ + setFloat2v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform2fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, /** - * The second possible `Body` that this constraint is attached to. + * Sets the value of a uniform variable in the given WebGLProgram. * - * @property bodyB - * @type body - * @default null + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. */ + setFloat3v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform3fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, /** - * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. + * Sets the value of a uniform variable in the given WebGLProgram. * - * @property pointA - * @type vector - * @default { x: 0, y: 0 } + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. */ + setFloat4v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform4fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + /** - * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. + * Sets the value of a uniform variable in the given WebGLProgram. * - * @property pointB - * @type vector - * @default { x: 0, y: 0 } + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * + * @return {this} This WebGL Renderer instance. */ + setInt1: function (program, name, x) + { + this.setProgram(program); + + this.gl.uniform1i(this.gl.getUniformLocation(program, name), x); + + return this; + }, /** - * A `Number` that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. - * A value of `1` means the constraint should be very stiff. - * A value of `0.2` means the constraint acts like a soft spring. + * Sets the value of a uniform variable in the given WebGLProgram. * - * @property stiffness - * @type number - * @default 1 + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * + * @return {this} This WebGL Renderer instance. */ + setInt2: function (program, name, x, y) + { + this.setProgram(program); + + this.gl.uniform2i(this.gl.getUniformLocation(program, name), x, y); + + return this; + }, /** - * A `Number` that specifies the damping of the constraint, - * i.e. the amount of resistance applied to each body based on their velocities to limit the amount of oscillation. - * Damping will only be apparent when the constraint also has a very low `stiffness`. - * A value of `0.1` means the constraint will apply heavy damping, resulting in little to no oscillation. - * A value of `0` means the constraint will apply no damping. + * Sets the value of a uniform variable in the given WebGLProgram. * - * @property damping - * @type number - * @default 0 + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - [description] + * @param {integer} y - [description] + * @param {integer} z - [description] + * + * @return {this} This WebGL Renderer instance. */ + setInt3: function (program, name, x, y, z) + { + this.setProgram(program); + + this.gl.uniform3i(this.gl.getUniformLocation(program, name), x, y, z); + + return this; + }, /** - * A `Number` that specifies the target resting length of the constraint. - * It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB`. + * Sets the value of a uniform variable in the given WebGLProgram. * - * @property length - * @type number + * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - X component + * @param {integer} y - Y component + * @param {integer} z - Z component + * @param {integer} w - W component + * + * @return {this} This WebGL Renderer instance. */ + setInt4: function (program, name, x, y, z, w) + { + this.setProgram(program); + + this.gl.uniform4i(this.gl.getUniformLocation(program, name), x, y, z, w); + + return this; + }, /** - * An object reserved for storing plugin-specific properties. + * [description] * - * @property plugin - * @type {} + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGL Renderer instance. */ + setMatrix2: function (program, name, transpose, matrix) + { + this.setProgram(program); -})(); + this.gl.uniformMatrix2fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - [description] + * @param {Float32Array} matrix - [description] + * + * @return {this} This WebGL Renderer instance. + */ + setMatrix3: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix3fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * Sets uniform of a WebGLProgram + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 + * @since 3.0.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - Is the matrix transposed + * @param {Float32Array} matrix - Matrix data + * + * @return {this} This WebGL Renderer instance. + */ + setMatrix4: function (program, name, transpose, matrix) + { + this.setProgram(program); + + this.gl.uniformMatrix4fv(this.gl.getUniformLocation(program, name), transpose, matrix); + + return this; + }, + + /** + * Returns the maximum number of texture units that can be used in a fragment shader. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextures + * @since 3.8.0 + * + * @return {integer} The maximum number of textures WebGL supports. + */ + getMaxTextures: function () + { + return this.config.maxTextures; + }, + + /** + * Returns the largest texture size (either width or height) that can be created. + * Note that VRAM may not allow a texture of any given size, it just expresses + * hardware / driver support for a given size. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextureSize + * @since 3.8.0 + * + * @return {integer} The maximum supported texture size. + */ + getMaxTextureSize: function () + { + return this.config.maxTextureSize; + }, + + /** + * [description] + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Clear-up anything that should be cleared :) + for (var key in this.pipelines) + { + this.pipelines[key].destroy(); + + delete this.pipelines[key]; + } + + for (var index = 0; index < this.nativeTextures.length; ++index) + { + this.deleteTexture(this.nativeTextures[index]); + + delete this.nativeTextures[index]; + } + + delete this.gl; + delete this.game; + + this.contextLost = true; + this.extensions = {}; + this.nativeTextures.length = 0; + } + +}); + +module.exports = WebGLRenderer; /***/ }), -/* 301 */ +/* 424 */ /***/ (function(module, exports, __webpack_require__) { /** -* The `Matter.Events` module contains methods to fire and listen to events on other objects. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class Events -*/ + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ -var Events = {}; +var modes = __webpack_require__(66); +var CanvasFeatures = __webpack_require__(339); -module.exports = Events; +/** + * [description] + * + * @function Phaser.Renderer.Canvas.GetBlendModes + * @since 3.0.0 + * + * @return {array} [description] + */ +var GetBlendModes = function () +{ + var output = []; + var useNew = CanvasFeatures.supportNewBlendModes; + var so = 'source-over'; -var Common = __webpack_require__(41); + output[modes.NORMAL] = so; + output[modes.ADD] = 'lighter'; + output[modes.MULTIPLY] = (useNew) ? 'multiply' : so; + output[modes.SCREEN] = (useNew) ? 'screen' : so; + output[modes.OVERLAY] = (useNew) ? 'overlay' : so; + output[modes.DARKEN] = (useNew) ? 'darken' : so; + output[modes.LIGHTEN] = (useNew) ? 'lighten' : so; + output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : so; + output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : so; + output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : so; + output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : so; + output[modes.DIFFERENCE] = (useNew) ? 'difference' : so; + output[modes.EXCLUSION] = (useNew) ? 'exclusion' : so; + output[modes.HUE] = (useNew) ? 'hue' : so; + output[modes.SATURATION] = (useNew) ? 'saturation' : so; + output[modes.COLOR] = (useNew) ? 'color' : so; + output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : so; -(function() { + return output; +}; - /** - * Subscribes a callback function to the given object's `eventName`. - * @method on - * @param {} object - * @param {string} eventNames - * @param {function} callback - */ - Events.on = function(object, eventNames, callback) { - var names = eventNames.split(' '), - name; - - for (var i = 0; i < names.length; i++) { - name = names[i]; - object.events = object.events || {}; - object.events[name] = object.events[name] || []; - object.events[name].push(callback); - } - - return callback; - }; - - /** - * Removes the given event callback. If no callback, clears all callbacks in `eventNames`. If no `eventNames`, clears all events. - * @method off - * @param {} object - * @param {string} eventNames - * @param {function} callback - */ - Events.off = function(object, eventNames, callback) { - if (!eventNames) { - object.events = {}; - return; - } - - // handle Events.off(object, callback) - if (typeof eventNames === 'function') { - callback = eventNames; - eventNames = Common.keys(object.events).join(' '); - } - - var names = eventNames.split(' '); - - for (var i = 0; i < names.length; i++) { - var callbacks = object.events[names[i]], - newCallbacks = []; - - if (callback && callbacks) { - for (var j = 0; j < callbacks.length; j++) { - if (callbacks[j] !== callback) - newCallbacks.push(callbacks[j]); - } - } - - object.events[names[i]] = newCallbacks; - } - }; - - /** - * Fires all the callbacks subscribed to the given object's `eventName`, in the order they subscribed, if any. - * @method trigger - * @param {} object - * @param {string} eventNames - * @param {} event - */ - Events.trigger = function(object, eventNames, event) { - var names, - name, - callbacks, - eventClone; - - if (object.events) { - if (!event) - event = {}; - - names = eventNames.split(' '); - - for (var i = 0; i < names.length; i++) { - name = names[i]; - callbacks = object.events[name]; - - if (callbacks) { - eventClone = Common.clone(event, false); - eventClone.name = name; - eventClone.source = object; - - for (var j = 0; j < callbacks.length; j++) { - callbacks[j].apply(object, [eventClone]); - } - } - } - } - }; - -})(); +module.exports = GetBlendModes; /***/ }), -/* 302 */ +/* 425 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Renderer.Snapshot.Canvas + * @since 3.0.0 + * + * @param {HTMLCanvasElement} canvas - [description] + * @param {string} [type='image/png'] - [description] + * @param {number} [encoderOptions=0.92] - [description] + * + * @return {HTMLImageElement} [description] + */ +var CanvasSnapshot = function (canvas, type, encoderOptions) +{ + if (type === undefined) { type = 'image/png'; } + if (encoderOptions === undefined) { encoderOptions = 0.92; } + + var src = canvas.toDataURL(type, encoderOptions); + + var image = new Image(); + + image.src = src; + + return image; +}; + +module.exports = CanvasSnapshot; + + +/***/ }), +/* 426 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasSnapshot = __webpack_require__(425); +var Class = __webpack_require__(0); +var CONST = __webpack_require__(26); +var GetBlendModes = __webpack_require__(424); +var ScaleModes = __webpack_require__(94); +var Smoothing = __webpack_require__(120); +var TransformMatrix = __webpack_require__(38); + +/** + * @classdesc + * [description] + * + * @class CanvasRenderer + * @memberof Phaser.Renderer.Canvas + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser Game instance that owns this renderer. + */ +var CanvasRenderer = new Class({ + + initialize: + + function CanvasRenderer (game) + { + /** + * The Phaser Game instance that owns this renderer. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#game + * @type {Phaser.Game} + * @since 3.0.0 + */ + this.game = game; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#type + * @type {integer} + * @since 3.0.0 + */ + this.type = CONST.CANVAS; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.drawCount = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#width + * @type {number} + * @since 3.0.0 + */ + this.width = game.config.width; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#height + * @type {number} + * @since 3.0.0 + */ + this.height = game.config.height; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#config + * @type {RendererConfig} + * @since 3.0.0 + */ + this.config = { + clearBeforeRender: game.config.clearBeforeRender, + backgroundColor: game.config.backgroundColor, + resolution: game.config.resolution, + autoResize: game.config.autoResize, + antialias: game.config.antialias, + roundPixels: game.config.roundPixels + }; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode + * @type {integer} + * @since 3.0.0 + */ + this.scaleMode = (game.config.antialias) ? ScaleModes.LINEAR : ScaleModes.NEAREST; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas + * @type {HTMLCanvasElement} + * @since 3.0.0 + */ + this.gameCanvas = game.canvas; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.gameContext = (this.game.config.context) ? this.game.config.context : this.gameCanvas.getContext('2d'); + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext + * @type {CanvasRenderingContext2D} + * @since 3.0.0 + */ + this.currentContext = this.gameContext; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes + * @type {array} + * @since 3.0.0 + */ + this.blendModes = GetBlendModes(); + + // image-rendering: optimizeSpeed; + // image-rendering: pixelated; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.currentScaleMode = 0; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback + * @type {?SnapshotCallback} + * @default null + * @since 3.0.0 + */ + this.snapshotCallback = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType + * @type {?string} + * @default null + * @since 3.0.0 + */ + this.snapshotType = null; + + /** + * [description] + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder + * @type {?number} + * @default null + * @since 3.0.0 + */ + this.snapshotEncoder = null; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + this.init(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#init + * @since 3.0.0 + */ + init: function () + { + this.resize(this.width, this.height); + }, + + /** + * Resize the main game canvas. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resize + * @since 3.0.0 + * + * @param {integer} width - [description] + * @param {integer} height - [description] + */ + resize: function (width, height) + { + var resolution = this.config.resolution; + + this.width = width * resolution; + this.height = height * resolution; + + this.gameCanvas.width = this.width; + this.gameCanvas.height = this.height; + + if (this.config.autoResize) + { + this.gameCanvas.style.width = (this.width / resolution) + 'px'; + this.gameCanvas.style.height = (this.height / resolution) + 'px'; + } + + // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) + if (this.scaleMode === ScaleModes.NEAREST) + { + Smoothing.disable(this.gameContext); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextLost: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored + * @since 3.0.0 + * + * @param {function} callback - [description] + */ + onContextRestored: function () + { + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform + * @since 3.0.0 + */ + resetTransform: function () + { + this.currentContext.setTransform(1, 0, 0, 1, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode + * @since 3.0.0 + * + * @param {number} blendMode - [description] + * + * @return {this} [description] + */ + setBlendMode: function (blendMode) + { + this.currentContext.globalCompositeOperation = blendMode; + + return this; + }, + + /** + * Changes the Canvas Rendering Context that all draw operations are performed against. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setContext + * @since 3.12.0 + * + * @param {?CanvasRenderingContext2D} [ctx] - The new Canvas Rendering Context to draw everything to. Leave empty to reset to the Game Canvas. + * + * @return {this} The Canvas Renderer instance. + */ + setContext: function (ctx) + { + this.currentContext = (ctx) ? ctx : this.gameContext; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha + * @since 3.0.0 + * + * @param {number} alpha - [description] + * + * @return {this} [description] + */ + setAlpha: function (alpha) + { + this.currentContext.globalAlpha = alpha; + + return this; + }, + + /** + * Called at the start of the render loop. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#preRender + * @since 3.0.0 + */ + preRender: function () + { + var ctx = this.gameContext; + var config = this.config; + + var width = this.width; + var height = this.height; + + if (config.clearBeforeRender) + { + ctx.clearRect(0, 0, width, height); + } + + if (!config.transparent) + { + ctx.fillStyle = config.backgroundColor.rgba; + ctx.fillRect(0, 0, width, height); + } + + this.drawCount = 0; + }, + + /** + * Renders the Scene to the given Camera. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#render + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.DisplayList} children - [description] + * @param {number} interpolationPercentage - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + render: function (scene, children, interpolationPercentage, camera) + { + var list = children.list; + var childCount = list.length; + + var cx = camera._cx; + var cy = camera._cy; + var cw = camera._cw; + var ch = camera._ch; + + var ctx = (camera.renderToTexture) ? camera.context : scene.sys.context; + + var scissor = (cx !== 0 || cy !== 0 || cw !== ctx.canvas.width || ch !== ctx.canvas.height); + + this.currentContext = ctx; + + // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) + + if (!camera.transparent) + { + ctx.fillStyle = camera.backgroundColor.rgba; + ctx.fillRect(cx, cy, cw, ch); + } + + ctx.globalAlpha = camera.alpha; + + ctx.globalCompositeOperation = 'source-over'; + + this.drawCount += list.length; + + if (scissor) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(cx, cy, cw, ch); + ctx.clip(); + } + + if (camera.renderToTexture) + { + camera.emit('prerender', camera); + } + + camera.matrix.copyToContext(ctx); + + for (var i = 0; i < childCount; i++) + { + var child = list[i]; + + if (!child.willRender(camera)) + { + continue; + } + + if (child.mask) + { + child.mask.preRenderCanvas(this, child, camera); + } + + child.renderCanvas(this, child, interpolationPercentage, camera); + + if (child.mask) + { + child.mask.postRenderCanvas(this, child, camera); + } + } + + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; + + camera.flashEffect.postRenderCanvas(ctx); + camera.fadeEffect.postRenderCanvas(ctx); + + camera.dirty = false; + + // Reset the camera scissor + if (scissor) + { + ctx.restore(); + } + + if (camera.renderToTexture) + { + camera.emit('postrender', camera); + + scene.sys.context.drawImage(camera.canvas, cx, cy); + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender + * @since 3.0.0 + */ + postRender: function () + { + var ctx = this.gameContext; + + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + + if (this.snapshotCallback) + { + this.snapshotCallback(CanvasSnapshot(this.gameCanvas, this.snapshotType, this.snapshotEncoder)); + this.snapshotCallback = null; + } + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot + * @since 3.0.0 + * + * @param {SnapshotCallback} callback - [description] + * @param {string} type - [description] + * @param {number} encoderOptions - [description] + */ + snapshot: function (callback, type, encoderOptions) + { + this.snapshotCallback = callback; + this.snapshotType = type; + this.snapshotEncoder = encoderOptions; + }, + + /** + * Takes a Sprite Game Object, or any object that extends it, and draws it to the current context. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#batchSprite + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - The texture based Game Object to draw. + * @param {Phaser.Textures.Frame} frame - The frame to draw, doesn't have to be that owned by the Game Object. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the rendering transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - The transform matrix of the parent container, if set. + */ + batchSprite: function (sprite, frame, camera, parentTransformMatrix) + { + var alpha = camera.alpha * sprite.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + + var ctx = this.currentContext; + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var cd = frame.canvasData; + + var frameX = cd.x; + var frameY = cd.y; + var frameWidth = frame.cutWidth; + var frameHeight = frame.cutHeight; + var res = frame.source.resolution; + + var x = -sprite.displayOriginX + frame.x; + var y = -sprite.displayOriginY + frame.y; + + var fx = (sprite.flipX) ? -1 : 1; + var fy = (sprite.flipY) ? -1 : 1; + + if (sprite.isCropped) + { + var crop = sprite._crop; + + if (crop.flipX !== sprite.flipX || crop.flipY !== sprite.flipY) + { + frame.updateCropUVs(crop, sprite.flipX, sprite.flipY); + } + + frameWidth = crop.cw; + frameHeight = crop.ch; + + frameX = crop.cx; + frameY = crop.cy; + + x = -sprite.displayOriginX + crop.x; + y = -sprite.displayOriginY + crop.y; + + if (fx === -1) + { + if (x >= 0) + { + x = -(x + frameWidth); + } + else if (x < 0) + { + x = (Math.abs(x) - frameWidth); + } + } + + if (fy === -1) + { + if (y >= 0) + { + y = -(y + frameHeight); + } + else if (y < 0) + { + y = (Math.abs(y) - frameHeight); + } + } + } + + spriteMatrix.applyITRS(sprite.x, sprite.y, sprite.rotation, sprite.scaleX, sprite.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * sprite.scrollFactorX, -camera.scrollY * sprite.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = sprite.x; + spriteMatrix.f = sprite.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * sprite.scrollFactorX; + spriteMatrix.f -= camera.scrollY * sprite.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + ctx.save(); + + calcMatrix.setToContext(ctx); + + ctx.scale(fx, fy); + + ctx.globalCompositeOperation = this.blendModes[sprite.blendMode]; + + ctx.globalAlpha = alpha; + + ctx.drawImage(frame.source.image, frameX, frameY, frameWidth, frameHeight, x, y, frameWidth / res, frameHeight / res); + + ctx.restore(); + }, + + /** + * [description] + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.gameCanvas = null; + this.gameContext = null; + + this.game = null; + } + +}); + +module.exports = CanvasRenderer; + + +/***/ }), +/* 427 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -71892,36 +100586,59 @@ var Class = __webpack_require__(0); /** * This event is dispatched when an animation starts playing. + * + * Listen for it on the Game Object: `sprite.on('animationstart', listener)` * * @event Phaser.GameObjects.Components.Animation#onStartEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. + */ + +/** + * This event is dispatched when an animation restarts. + * + * Listen for it on the Game Object: `sprite.on('animationrestart', listener)` + * + * @event Phaser.GameObjects.Components.Animation#onRestartEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** * This event is dispatched when an animation repeats. + * + * Listen for it on the Game Object: `sprite.on('animationrepeat', listener)` * * @event Phaser.GameObjects.Components.Animation#onRepeatEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. * @param {integer} repeatCount - The number of times this animation has repeated. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** * This event is dispatched when an animation updates. This happens when the animation frame changes, * based on the animation frame rate and other factors like timeScale and delay. + * + * Listen for it on the Game Object: `sprite.on('animationupdate', listener)` * * @event Phaser.GameObjects.Components.Animation#onUpdateEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** * This event is dispatched when an animation completes playing, either naturally or via Animation.stop. + * + * Listen for it on the Game Object: `sprite.on('animationcomplete', listener)` * * @event Phaser.GameObjects.Components.Animation#onCompleteEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** @@ -71931,7 +100648,7 @@ var Class = __webpack_require__(0); * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. * * @class Animation - * @memberOf Phaser.GameObjects.Components + * @memberof Phaser.GameObjects.Components * @constructor * @since 3.0.0 * @@ -72092,7 +100809,7 @@ var Animation = new Class({ this._yoyo = false; /** - * Will the playhead move forwards (`true`) or in reverse (`false`) + * Will the playhead move forwards (`true`) or in reverse (`false`). * * @name Phaser.GameObjects.Components.Animation#forward * @type {boolean} @@ -72101,6 +100818,17 @@ var Animation = new Class({ */ this.forward = true; + /** + * An Internal trigger that's play the animation in reverse mode ('true') or not ('false'), + * needed because forward can be changed by yoyo feature. + * + * @name Phaser.GameObjects.Components.Animation#forward + * @type {boolean} + * @default false + * @since 3.12.0 + */ + this._reverse = false; + /** * Internal time overflow accumulator. * @@ -72344,7 +101072,7 @@ var Animation = new Class({ * `true` if the current animation is paused, otherwise `false`. * * @name Phaser.GameObjects.Components.Animation#isPaused - * @readOnly + * @readonly * @type {boolean} * @since 3.4.0 */ @@ -72380,6 +101108,56 @@ var Animation = new Class({ return this.parent; } + this.forward = true; + this._reverse = false; + + return this._startAnimation(key, startFrame); + }, + + /** + * Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component. + * + * @method Phaser.GameObjects.Components.Animation#playReverse + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + playReverse: function (key, ignoreIfPlaying, startFrame) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + if (startFrame === undefined) { startFrame = 0; } + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) + { + return this.parent; + } + + this.forward = false; + this._reverse = true; + + return this._startAnimation(key, startFrame); + }, + + /** + * Load an Animation and fires 'onStartEvent' event, + * extracted from 'play' method + * + * @method Phaser.GameObjects.Components.Animation#_startAnimation + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + _startAnimation: function (key, startFrame) + { this.load(key, startFrame); var anim = this.currentAnim; @@ -72390,7 +101168,6 @@ var Animation = new Class({ anim.getFirstTick(this); - this.forward = true; this.isPlaying = true; this.pendingRepeat = false; @@ -72399,11 +101176,30 @@ var Animation = new Class({ gameObject.visible = true; } - gameObject.emit('animationstart', this.currentAnim, this.currentFrame); + gameObject.emit('animationstart', this.currentAnim, this.currentFrame, gameObject); return gameObject; }, + /** + * Reverse an Animation that is already playing on the Game Object. + * + * @method Phaser.GameObjects.Components.Animation#reverse + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + reverse: function (key) + { + if (!this.isPlaying || this.currentAnim.key !== key) { return this.parent; } + this._reverse = !this._reverse; + this.forward = !this.forward; + + return this.parent; + }, + /** * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. * If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different @@ -72412,7 +101208,7 @@ var Animation = new Class({ * @method Phaser.GameObjects.Components.Animation#getProgress * @since 3.4.0 * - * @return {float} The progress of the current animation, between 0 and 1. + * @return {number} The progress of the current animation, between 0 and 1. */ getProgress: function () { @@ -72433,7 +101229,7 @@ var Animation = new Class({ * @method Phaser.GameObjects.Components.Animation#setProgress * @since 3.4.0 * - * @param {float} [value=0] - The progress value, between 0 and 1. + * @param {number} [value=0] - The progress value, between 0 and 1. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ @@ -72545,6 +101341,7 @@ var Animation = new Class({ * Restarts the current animation from its beginning, optionally including its delay value. * * @method Phaser.GameObjects.Components.Animation#restart + * @fires Phaser.GameObjects.Components.Animation#onRestartEvent * @since 3.0.0 * * @param {boolean} [includeDelay=false] - Whether to include the delay value of the animation when restarting. @@ -72565,6 +101362,10 @@ var Animation = new Class({ // Set frame this.updateFrame(this.currentAnim.frames[0]); + var gameObject = this.parent; + + gameObject.emit('animationrestart', this.currentAnim, this.currentFrame, gameObject); + return this.parent; }, @@ -72585,7 +101386,7 @@ var Animation = new Class({ var gameObject = this.parent; - gameObject.emit('animationcomplete', this.currentAnim, this.currentFrame); + gameObject.emit('animationcomplete', this.currentAnim, this.currentFrame, gameObject); return gameObject; }, @@ -72745,6 +101546,11 @@ var Animation = new Class({ gameObject.texture = animationFrame.frame.texture; gameObject.frame = animationFrame.frame; + if (gameObject.isCropped) + { + gameObject.frame.updateCropUVs(gameObject._crop, gameObject.flipX, gameObject.flipY); + } + gameObject.setSizeToFrame(); if (animationFrame.frame.customPivot) @@ -72782,7 +101588,7 @@ var Animation = new Class({ var anim = this.currentAnim; - gameObject.emit('animationupdate', anim, animationFrame); + gameObject.emit('animationupdate', anim, animationFrame, gameObject); if (this._pendingStop === 3 && this._pendingStopValue === animationFrame) { @@ -72850,7 +101656,270 @@ module.exports = Animation; /***/ }), -/* 303 */ +/* 428 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes the given string and reverses it, returning the reversed string. + * For example if given the string `Atari 520ST` it would return `TS025 iratA`. + * + * @function Phaser.Utils.String.ReverseString + * @since 3.0.0 + * + * @param {string} string - The string to be reversed. + * + * @return {string} The reversed string. + */ +var ReverseString = function (string) +{ + return string.split('').reverse().join(''); +}; + +module.exports = ReverseString; + + +/***/ }), +/* 429 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes a string and replaces instances of markers with values in the given array. + * The markers take the form of `%1`, `%2`, etc. I.e.: + * + * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` + * + * @function Phaser.Utils.String.Format + * @since 3.0.0 + * + * @param {string} string - The string containing the replacement markers. + * @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead. + * + * @return {string} The string containing replaced values. + */ +var Format = function (string, values) +{ + return string.replace(/%([0-9]+)/g, function (s, n) + { + return values[Number(n) - 1]; + }); +}; + +module.exports = Format; + + +/***/ }), +/* 430 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.String + */ + +module.exports = { + + Format: __webpack_require__(429), + Pad: __webpack_require__(179), + Reverse: __webpack_require__(428), + UppercaseFirst: __webpack_require__(327), + UUID: __webpack_require__(295) + +}; + + +/***/ }), +/* 431 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clone = __webpack_require__(63); + +/** + * Creates a new Object using all values from obj1. + * + * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. + * + * @function Phaser.Utils.Objects.MergeRight + * @since 3.0.0 + * + * @param {object} obj1 - [description] + * @param {object} obj2 - [description] + * + * @return {object} [description] + */ +var MergeRight = function (obj1, obj2) +{ + var clone = Clone(obj1); + + for (var key in obj2) + { + if (clone.hasOwnProperty(key)) + { + clone[key] = obj2[key]; + } + } + + return clone; +}; + +module.exports = MergeRight; + + +/***/ }), +/* 432 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Verifies that an object contains all requested keys + * + * @function Phaser.Utils.Objects.HasAll + * @since 3.0.0 + * + * @param {object} source - an object on which to check for key existence + * @param {string[]} keys - an array of keys to ensure the source object contains + * + * @return {boolean} true if the source object contains all keys, false otherwise. + */ +var HasAll = function (source, keys) +{ + for (var i = 0; i < keys.length; i++) + { + if (!source.hasOwnProperty(keys[i])) + { + return false; + } + } + + return true; +}; + +module.exports = HasAll; + + +/***/ }), +/* 433 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetValue = __webpack_require__(4); +var Clamp = __webpack_require__(23); + +/** + * Retrieves and clamps a numerical value from an object. + * + * @function Phaser.Utils.Objects.GetMinMaxValue + * @since 3.0.0 + * + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`). + * @param {number} min - The minimum value which can be returned. + * @param {number} max - The maximum value which can be returned. + * @param {number} defaultValue - The value to return if the property doesn't exist. It's also constrained to the given bounds. + * + * @return {number} The clamped value from the `source` object. + */ +var GetMinMaxValue = function (source, key, min, max, defaultValue) +{ + if (defaultValue === undefined) { defaultValue = min; } + + var value = GetValue(source, key, defaultValue); + + return Clamp(value, min, max); +}; + +module.exports = GetMinMaxValue; + + +/***/ }), +/* 434 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils.Object + */ + +module.exports = { + + Clone: __webpack_require__(63), + Extend: __webpack_require__(20), + GetAdvancedValue: __webpack_require__(12), + GetFastValue: __webpack_require__(2), + GetMinMaxValue: __webpack_require__(433), + GetValue: __webpack_require__(4), + HasAll: __webpack_require__(432), + HasAny: __webpack_require__(298), + HasValue: __webpack_require__(85), + IsPlainObject: __webpack_require__(8), + Merge: __webpack_require__(96), + MergeRight: __webpack_require__(431) + +}; + + +/***/ }), +/* 435 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Utils + */ + +module.exports = { + + Array: __webpack_require__(164), + Objects: __webpack_require__(434), + String: __webpack_require__(430) + +}; + + +/***/ }), +/* 436 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -72860,18 +101929,18 @@ module.exports = Animation; */ var Class = __webpack_require__(0); -var NumberTweenBuilder = __webpack_require__(161); -var PluginCache = __webpack_require__(12); -var TimelineBuilder = __webpack_require__(160); -var TWEEN_CONST = __webpack_require__(61); -var TweenBuilder = __webpack_require__(72); +var NumberTweenBuilder = __webpack_require__(203); +var PluginCache = __webpack_require__(15); +var TimelineBuilder = __webpack_require__(202); +var TWEEN_CONST = __webpack_require__(83); +var TweenBuilder = __webpack_require__(97); /** * @classdesc * [description] * * @class TweenManager - * @memberOf Phaser.Tweens + * @memberof Phaser.Tweens * @constructor * @since 3.0.0 * @@ -73130,6 +102199,7 @@ var TweenManager = new Class({ var list = this._destroy; var active = this._active; + var pending = this._pending; var i; var tween; @@ -73141,7 +102211,18 @@ var TweenManager = new Class({ // Remove from the 'active' array var idx = active.indexOf(tween); - if (idx !== -1) + if (idx === -1) + { + // Not in the active array, is it in pending instead? + idx = pending.indexOf(tween); + + if (idx > -1) + { + tween.state = TWEEN_CONST.REMOVED; + pending.splice(idx, 1); + } + } + else { tween.state = TWEEN_CONST.REMOVED; active.splice(idx, 1); @@ -73187,7 +102268,7 @@ var TweenManager = new Class({ * @since 3.0.0 * * @param {number} timestamp - [description] - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (timestamp, delta) { @@ -73470,7 +102551,7 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#setGlobalTimeScale * @since 3.0.0 * - * @param {float} value - [description] + * @param {number} value - [description] * * @return {Phaser.Tweens.TweenManager} [description] */ @@ -73531,7 +102612,7 @@ module.exports = TweenManager; /***/ }), -/* 304 */ +/* 437 */ /***/ (function(module, exports) { /** @@ -73603,7 +102684,7 @@ module.exports = [ /***/ }), -/* 305 */ +/* 438 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -73618,22 +102699,22 @@ module.exports = [ module.exports = { - GetBoolean: __webpack_require__(62), - GetEaseFunction: __webpack_require__(63), - GetNewValue: __webpack_require__(73), - GetProps: __webpack_require__(163), - GetTargets: __webpack_require__(102), - GetTweens: __webpack_require__(162), - GetValueOp: __webpack_require__(101), - NumberTweenBuilder: __webpack_require__(161), - TimelineBuilder: __webpack_require__(160), - TweenBuilder: __webpack_require__(72) + GetBoolean: __webpack_require__(84), + GetEaseFunction: __webpack_require__(86), + GetNewValue: __webpack_require__(98), + GetProps: __webpack_require__(205), + GetTargets: __webpack_require__(131), + GetTweens: __webpack_require__(204), + GetValueOp: __webpack_require__(130), + NumberTweenBuilder: __webpack_require__(203), + TimelineBuilder: __webpack_require__(202), + TweenBuilder: __webpack_require__(97) }; /***/ }), -/* 306 */ +/* 439 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -73642,8 +102723,8 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(61); -var Extend = __webpack_require__(17); +var CONST = __webpack_require__(83); +var Extend = __webpack_require__(20); /** * @namespace Phaser.Tweens @@ -73651,12 +102732,12 @@ var Extend = __webpack_require__(17); var Tweens = { - Builders: __webpack_require__(305), + Builders: __webpack_require__(438), - TweenManager: __webpack_require__(303), - Tween: __webpack_require__(99), - TweenData: __webpack_require__(98), - Timeline: __webpack_require__(159) + TweenManager: __webpack_require__(436), + Tween: __webpack_require__(128), + TweenData: __webpack_require__(127), + Timeline: __webpack_require__(201) }; @@ -73667,7 +102748,7 @@ module.exports = Tweens; /***/ }), -/* 307 */ +/* 440 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -73677,15 +102758,15 @@ module.exports = Tweens; */ var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); -var TimerEvent = __webpack_require__(164); +var PluginCache = __webpack_require__(15); +var TimerEvent = __webpack_require__(206); /** * @classdesc * [description] * * @class Clock - * @memberOf Phaser.Time + * @memberof Phaser.Time * @constructor * @since 3.0.0 * @@ -73731,7 +102812,7 @@ var Clock = new Class({ * [description] * * @name Phaser.Time.Clock#timeScale - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -73888,8 +102969,8 @@ var Clock = new Class({ * @method Phaser.Time.Clock#preUpdate * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ preUpdate: function () { @@ -73939,8 +103020,8 @@ var Clock = new Class({ * @method Phaser.Time.Clock#update * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (time, delta) { @@ -74061,7 +103142,7 @@ module.exports = Clock; /***/ }), -/* 308 */ +/* 441 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -74076,14 +103157,14 @@ module.exports = Clock; module.exports = { - Clock: __webpack_require__(307), - TimerEvent: __webpack_require__(164) + Clock: __webpack_require__(440), + TimerEvent: __webpack_require__(206) }; /***/ }), -/* 309 */ +/* 442 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -74092,4600 +103173,64 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var CONST = __webpack_require__(20); -var GameObject = __webpack_require__(2); -var StaticTilemapLayerRender = __webpack_require__(624); -var TilemapComponents = __webpack_require__(141); -var Utils = __webpack_require__(27); +var GameObjectFactory = __webpack_require__(5); +var ParseToTilemap = __webpack_require__(132); /** - * @classdesc - * A StaticTilemapLayer is a game object that renders LayerData from a Tilemap. A - * StaticTilemapLayer can only render tiles from a single tileset. + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. * - * A StaticTilemapLayer is optimized for speed over flexibility. You cannot apply per-tile - * effects like tint or alpha. You cannot change the tiles in a StaticTilemapLayer. Use this - * over a DynamicTilemapLayer when you don't need either of those features. - * - * @class StaticTilemapLayer - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps - * @constructor + * @method Phaser.GameObjects.GameObjectFactory#tilemap * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * @extends Phaser.GameObjects.Components.ScrollFactor - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. - * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. - * @param {number} [x=0] - The world x position where the top left of this layer will be placed. - * @param {number} [y=0] - The world y position where the top left of this layer will be placed. - */ -var StaticTilemapLayer = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - StaticTilemapLayerRender - ], - - initialize: - - function StaticTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) - { - GameObject.call(this, scene, 'StaticTilemapLayer'); - - /** - * Used internally by physics system to perform fast type checks. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isTilemap = true; - - /** - * The Tilemap that this layer is a part of. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#tilemap - * @type {Phaser.Tilemaps.Tilemap} - * @since 3.0.0 - */ - this.tilemap = tilemap; - - /** - * The index of the LayerData associated with this layer. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#layerIndex - * @type {integer} - * @since 3.0.0 - */ - this.layerIndex = layerIndex; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - this.layer = tilemap.layers[layerIndex]; - - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer - - /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} - * @since 3.0.0 - */ - this.tileset = tileset; - - /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. - * - * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles - * @type {array} - * @since 3.0.0 - */ - this.culledTiles = []; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer - * @type {array} - * @private - * @since 3.0.0 - */ - this.vertexBuffer = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#renderer - * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} - * @private - * @since 3.0.0 - */ - this.renderer = scene.sys.game.renderer; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData - * @type {ArrayBuffer} - * @private - * @since 3.0.0 - */ - this.bufferData = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 - * @type {Float32Array} - * @private - * @since 3.0.0 - */ - this.vertexViewF32 = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 - * @type {Uint32Array} - * @private - * @since 3.0.0 - */ - this.vertexViewU32 = null; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#dirty - * @type {boolean} - * @private - * @since 3.0.0 - */ - this.dirty = true; - - /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount - * @type {integer} - * @private - * @since 3.0.0 - */ - this.vertexCount = 0; - - this.setAlpha(this.layer.alpha); - this.setPosition(x, y); - this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); - - this.initPipeline('TextureTintPipeline'); - - if (scene.sys.game.config.renderType === CONST.WEBGL) - { - scene.sys.game.renderer.onContextRestored(function () - { - this.dirty = true; - this.vertexBuffer = null; - }, this); - } - }, - - /** - * Upload the tile data to a VBO. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#upload - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - upload: function (camera) - { - var tileset = this.tileset; - var mapWidth = this.layer.width; - var mapHeight = this.layer.height; - var width = tileset.image.source[0].width; - var height = tileset.image.source[0].height; - var mapData = this.layer.data; - var renderer = this.renderer; - var tile; - var row; - var col; - var texCoords; - - if (renderer.gl) - { - var pipeline = renderer.pipelines.TextureTintPipeline; - - if (this.dirty) - { - var gl = renderer.gl; - var vertexBuffer = this.vertexBuffer; - var bufferData = this.bufferData; - var voffset = 0; - var vertexCount = 0; - var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; - - if (bufferData === null) - { - bufferData = new ArrayBuffer(bufferSize); - this.bufferData = bufferData; - this.vertexViewF32 = new Float32Array(bufferData); - this.vertexViewU32 = new Uint32Array(bufferData); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - - for (row = 0; row < mapHeight; ++row) - { - for (col = 0; col < mapWidth; ++col) - { - tile = mapData[row][col]; - if (tile === null || tile.index === -1) { continue; } - - var tx = tile.pixelX; - var ty = tile.pixelY; - var txw = tx + tile.width; - var tyh = ty + tile.height; - - texCoords = tileset.getTileTextureCoordinates(tile.index); - if (texCoords === null) { continue; } - - var u0 = texCoords.x / width; - var v0 = texCoords.y / height; - var u1 = (texCoords.x + tile.width) / width; - var v1 = (texCoords.y + tile.height) / height; - - var tx0 = tx; - var ty0 = ty; - var tx1 = tx; - var ty1 = tyh; - var tx2 = txw; - var ty2 = tyh; - var tx3 = txw; - var ty3 = ty; - var tint = Utils.getTintAppendFloatAlpha(0xffffff, this.alpha * tile.alpha); - - vertexViewF32[voffset + 0] = tx0; - vertexViewF32[voffset + 1] = ty0; - vertexViewF32[voffset + 2] = u0; - vertexViewF32[voffset + 3] = v0; - vertexViewU32[voffset + 4] = tint; - vertexViewF32[voffset + 5] = tx1; - vertexViewF32[voffset + 6] = ty1; - vertexViewF32[voffset + 7] = u0; - vertexViewF32[voffset + 8] = v1; - vertexViewU32[voffset + 9] = tint; - vertexViewF32[voffset + 10] = tx2; - vertexViewF32[voffset + 11] = ty2; - vertexViewF32[voffset + 12] = u1; - vertexViewF32[voffset + 13] = v1; - vertexViewU32[voffset + 14] = tint; - vertexViewF32[voffset + 15] = tx0; - vertexViewF32[voffset + 16] = ty0; - vertexViewF32[voffset + 17] = u0; - vertexViewF32[voffset + 18] = v0; - vertexViewU32[voffset + 19] = tint; - vertexViewF32[voffset + 20] = tx2; - vertexViewF32[voffset + 21] = ty2; - vertexViewF32[voffset + 22] = u1; - vertexViewF32[voffset + 23] = v1; - vertexViewU32[voffset + 24] = tint; - vertexViewF32[voffset + 25] = tx3; - vertexViewF32[voffset + 26] = ty3; - vertexViewF32[voffset + 27] = u1; - vertexViewF32[voffset + 28] = v0; - vertexViewU32[voffset + 29] = tint; - - voffset += 30; - vertexCount += 6; - } - } - - this.vertexCount = vertexCount; - this.dirty = false; - if (vertexBuffer === null) - { - vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); - this.vertexBuffer = vertexBuffer; - } - else - { - renderer.setVertexBuffer(vertexBuffer); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); - } - } - - pipeline.modelIdentity(); - pipeline.modelTranslate(this.x - (camera.scrollX * this.scrollFactorX), this.y - (camera.scrollY * this.scrollFactorY), 0.0); - pipeline.modelScale(this.scaleX, this.scaleY, 1.0); - pipeline.viewLoad2D(camera.matrix.matrix); - } - - return this; - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - calculateFacesAt: function (tileX, tileY) - { - TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - calculateFacesWithin: function (tileX, tileY, width, height) - { - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#createFromTiles - * @since 3.0.0 - * - * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) - { - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); - }, - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - cull: function (camera) - { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); - }, - - /** - * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Uninstall this layer only if it is still installed on the LayerData object - if (this.layer.tilemapLayer === this) - { - this.layer.tilemapLayer = undefined; - } - - this.tilemap = undefined; - this.layer = undefined; - this.tileset = undefined; - - GameObject.prototype.destroy.call(this); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - findByIndex: function (findIndex, skip, reverse) - { - return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {?Phaser.Tilemaps.Tile} - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - - return this; - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. - */ - getTileAt: function (tileX, tileY, nonNull) - { - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera) - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinShape - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinShape: function (shape, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * - * @return {boolean} - */ - hasTileAt: function (tileX, tileY) - { - return TilemapComponents.HasTileAt(tileX, tileY, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {boolean} - */ - hasTileAtWorldXY: function (worldX, worldY, camera) - { - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - renderDebug: function (graphics, styleConfig) - { - TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollision - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollision: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces) - { - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setTileIndexCallback - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setTileIndexCallback: function (indexes, callback, callbackContext) - { - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces) - { - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} [callbackContext] - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) - { - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldX: function (tileX, camera) - { - return TilemapComponents.TileToWorldX(tileX, camera, this.layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldY: function (tileY, camera) - { - return TilemapComponents.TileToWorldY(tileY, camera, this.layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - tileToWorldXY: function (tileX, tileY, point, camera) - { - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileX: function (worldX, snapToFloor, camera) - { - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileY: function (worldY, snapToFloor, camera) - { - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) - { - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); - } - -}); - -module.exports = StaticTilemapLayer; - - -/***/ }), -/* 310 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var DynamicTilemapLayerRender = __webpack_require__(627); -var GameObject = __webpack_require__(2); -var TilemapComponents = __webpack_require__(141); - -/** - * @classdesc - * A DynamicTilemapLayer is a game object that renders LayerData from a Tilemap. A - * DynamicTilemapLayer can only render tiles from a single tileset. - * - * A DynamicTilemapLayer trades some speed for being able to apply powerful effects. Unlike a - * StaticTilemapLayer, you can apply per-tile effects like tint or alpha, and you can change the - * tiles in a DynamicTilemapLayer. Use this over a StaticTilemapLayer when you need those - * features. - * - * @class DynamicTilemapLayer - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.ComputedSize - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. - * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. - * @param {number} [x=0] - The world x position where the top left of this layer will be placed. - * @param {number} [y=0] - The world y position where the top left of this layer will be placed. - */ -var DynamicTilemapLayer = new Class({ - - Extends: GameObject, - - Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.ComputedSize, - Components.Depth, - Components.Flip, - Components.GetBounds, - Components.Origin, - Components.Pipeline, - Components.ScaleMode, - Components.Transform, - Components.Visible, - Components.ScrollFactor, - DynamicTilemapLayerRender - ], - - initialize: - - function DynamicTilemapLayer (scene, tilemap, layerIndex, tileset, x, y) - { - GameObject.call(this, scene, 'DynamicTilemapLayer'); - - /** - * Used internally by physics system to perform fast type checks. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap - * @type {boolean} - * @readOnly - * @since 3.0.0 - */ - this.isTilemap = true; - - /** - * The Tilemap that this layer is a part of. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#tilemap - * @type {Phaser.Tilemaps.Tilemap} - * @since 3.0.0 - */ - this.tilemap = tilemap; - - /** - * The index of the LayerData associated with this layer. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#layerIndex - * @type {integer} - * @since 3.0.0 - */ - this.layerIndex = layerIndex; - - /** - * The LayerData associated with this layer. LayerData can only be associated with one - * tilemap layer. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - this.layer = tilemap.layers[layerIndex]; - - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer - - /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} - * @since 3.0.0 - */ - this.tileset = tileset; - - /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. - * - * @name Phaser.Tilemaps.DynamicTilemapLayer#culledTiles - * @type {array} - * @since 3.0.0 - */ - this.culledTiles = []; - - this.setAlpha(this.layer.alpha); - this.setPosition(x, y); - this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); - - this.initPipeline('TextureTintPipeline'); - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - The x coordinate. - * @param {integer} tileY - The y coordinate. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - calculateFacesAt: function (tileX, tileY) - { - TilemapComponents.CalculateFacesAt(tileX, tileY, this.layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - calculateFacesWithin: function (tileX, tileY, width, height) - { - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#createFromTiles - * @since 3.0.0 - * - * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera) - { - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, this.layer); - }, - - /** - * Returns the tiles in the given layer that are within the cameras viewport. - * This is used internally. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - cull: function (camera) - { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); - }, - - /** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#copy - * @since 3.0.0 - * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces) - { - TilemapComponents.Copy(srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, this.layer); - - return this; - }, - - /** - * Destroys this DynamicTilemapLayer and removes its link to the associated LayerData. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#destroy - * @since 3.0.0 - */ - destroy: function () - { - // Uninstall this layer only if it is still installed on the LayerData object - if (this.layer.tilemapLayer === this) - { - this.layer.tilemapLayer = undefined; - } - - this.tilemap = undefined; - this.layer = undefined; - this.tileset = undefined; - this.culledTiles.length = 0; - - GameObject.prototype.destroy.call(this); - }, - - /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - fill: function (index, tileX, tileY, width, height, recalculateFaces) - { - TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, this.layer); - - return this; - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - findByIndex: function (findIndex, skip, reverse) - { - return TilemapComponents.FindByIndex(findIndex, skip, reverse, this.layer); - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {?Phaser.Tilemaps.Tile} - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, this.layer); - - return this; - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. - */ - getTileAt: function (tileX, tileY, nonNull) - { - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, this.layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera) - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions) - { - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, this.layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinShape - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinShape: function (shape, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, this.layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera) - { - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * - * @return {boolean} - */ - hasTileAt: function (tileX, tileY) - { - return TilemapComponents.HasTileAt(tileX, tileY, this.layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {boolean} - */ - hasTileAtWorldXY: function (worldX, worldY, camera) - { - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, this.layer); - }, - - /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAt - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - putTileAt: function (tile, tileX, tileY, recalculateFaces) - { - return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, this.layer); - }, - - /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTileAtWorldXY - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera) - { - return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, this.layer); - }, - - /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt - * @since 3.0.0 - * - * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces) - { - TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, this.layer); - - return this; - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - randomize: function (tileX, tileY, width, height, indexes) - { - TilemapComponents.Randomize(tileX, tileY, width, height, indexes, this.layer); - - return this; - }, - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces) - { - return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, this.layer); - }, - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Tilemaps.Tile} A Tile object. - */ - removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera) - { - return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, this.layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - renderDebug: function (graphics, styleConfig) - { - TilemapComponents.RenderDebug(graphics, styleConfig, this.layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height) - { - TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollision - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollision: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces) - { - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces) - { - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tiles collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tiles collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces) - { - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, this.layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setTileIndexCallback: function (indexes, callback, callbackContext) - { - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} [callbackContext] - The context under which the callback is called. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext) - { - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, this.layer); - - return this; - }, - - /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - shuffle: function (tileX, tileY, width, height) - { - TilemapComponents.Shuffle(tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#swapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - swapByIndex: function (indexA, indexB, tileX, tileY, width, height) - { - TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, this.layer); - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldX: function (tileX, camera) - { - return TilemapComponents.TileToWorldX(tileX, camera, this.layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - tileToWorldY: function (tileY, camera) - { - return TilemapComponents.TileToWorldY(tileY, camera, this.layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - tileToWorldXY: function (tileX, tileY, point, camera) - { - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, this.layer); - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * - * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. - */ - weightedRandomize: function (tileX, tileY, width, height, weightedIndexes) - { - TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, this.layer); - - return this; - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileX: function (worldX, snapToFloor, camera) - { - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {number} - */ - worldToTileY: function (worldY, snapToFloor, camera) - { - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, this.layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * - * @return {Phaser.Math.Vector2} - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) - { - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); - } - -}); - -module.exports = DynamicTilemapLayer; - - -/***/ }), -/* 311 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var DynamicTilemapLayer = __webpack_require__(310); -var Extend = __webpack_require__(17); -var Formats = __webpack_require__(26); -var LayerData = __webpack_require__(104); -var Rotate = __webpack_require__(346); -var StaticTilemapLayer = __webpack_require__(309); -var Tile = __webpack_require__(66); -var TilemapComponents = __webpack_require__(141); -var Tileset = __webpack_require__(137); - -/** - * @callback TilemapFilterCallback - * - * @param {Phaser.GameObjects.GameObject} value - [description] - * @param {number} index - [description] - * @param {Phaser.GameObjects.GameObject[]} array - [description] - * - * @return {Phaser.GameObjects.GameObject} [description] - */ - -/** - * @callback TilemapFindCallback - * - * @param {Phaser.GameObjects.GameObject} value - [description] - * @param {number} index - [description] - * @param {Phaser.GameObjects.GameObject[]} array - [description] - * - * @return {boolean} [description] - */ - -/** - * @classdesc - * A Tilemap is a container for Tilemap data. This isn't a display object, rather, it holds data - * about the map and allows you to add tilesets and tilemap layers to it. A map can have one or - * more tilemap layers (StaticTilemapLayer or DynamicTilemapLayer), which are the display - * objects that actually render tiles. - * - * The Tilemap data be parsed from a Tiled JSON file, a CSV file or a 2D array. Tiled is a free - * software package specifically for creating tile maps, and is available from: - * http://www.mapeditor.org - * - * A Tilemap has handy methods for getting & manipulating the tiles within a layer. You can only - * use the methods that change tiles (e.g. removeTileAt) on a DynamicTilemapLayer. - * - * Note that all Tilemaps use a base tile size to calculate dimensions from, but that a - * StaticTilemapLayer or DynamicTilemapLayer may have its own unique tile size that overrides - * it. - * - * @class Tilemap - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene to which this Tilemap belongs. - * @param {Phaser.Tilemaps.MapData} mapData - A MapData instance containing Tilemap data. - */ -var Tilemap = new Class({ - - initialize: - - function Tilemap (scene, mapData) - { - /** - * @name Phaser.Tilemaps.Tilemap#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * The base width of a tile in pixels. Note that individual layers may have a different tile - * width. - * - * @name Phaser.Tilemaps.Tilemap#tileWidth - * @type {integer} - * @since 3.0.0 - */ - this.tileWidth = mapData.tileWidth; - - /** - * The base height of a tile in pixels. Note that individual layers may have a different - * tile height. - * - * @name Phaser.Tilemaps.Tilemap#tileHeight - * @type {integer} - * @since 3.0.0 - */ - this.tileHeight = mapData.tileHeight; - - /** - * The width of the map (in tiles). - * - * @name Phaser.Tilemaps.Tilemap#width - * @type {number} - * @since 3.0.0 - */ - this.width = mapData.width; - - /** - * The height of the map (in tiles). - * - * @name Phaser.Tilemaps.Tilemap#height - * @type {number} - * @since 3.0.0 - */ - this.height = mapData.height; - - /** - * The orientation of the map data (as specified in Tiled), usually 'orthogonal'. - * - * @name Phaser.Tilemaps.Tilemap#orientation - * @type {string} - * @since 3.0.0 - */ - this.orientation = mapData.orientation; - - /** - * The format of the map data. - * - * @name Phaser.Tilemaps.Tilemap#format - * @type {number} - * @since 3.0.0 - */ - this.format = mapData.format; - - /** - * The version of the map data (as specified in Tiled, usually 1). - * - * @name Phaser.Tilemaps.Tilemap#version - * @type {number} - * @since 3.0.0 - */ - this.version = mapData.version; - - /** - * Map specific properties as specified in Tiled. - * - * @name Phaser.Tilemaps.Tilemap#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = mapData.properties; - - /** - * The width of the map in pixels based on width * tileWidth. - * - * @name Phaser.Tilemaps.Tilemap#widthInPixels - * @type {number} - * @since 3.0.0 - */ - this.widthInPixels = mapData.widthInPixels; - - /** - * The height of the map in pixels based on height * tileHeight. - * - * @name Phaser.Tilemaps.Tilemap#heightInPixels - * @type {number} - * @since 3.0.0 - */ - this.heightInPixels = mapData.heightInPixels; - - /** - * - * @name Phaser.Tilemaps.Tilemap#imageCollections - * @type {Phaser.Tilemaps.ImageCollection[]} - * @since 3.0.0 - */ - this.imageCollections = mapData.imageCollections; - - /** - * An array of Tiled Image Layers. - * - * @name Phaser.Tilemaps.Tilemap#images - * @type {array} - * @since 3.0.0 - */ - this.images = mapData.images; - - /** - * An array of Tilemap layer data. - * - * @name Phaser.Tilemaps.Tilemap#layers - * @type {Phaser.Tilemaps.LayerData[]} - * @since 3.0.0 - */ - this.layers = mapData.layers; - - /** - * An array of Tilesets used in the map. - * - * @name Phaser.Tilemaps.Tilemap#tilesets - * @type {Phaser.Tilemaps.Tileset[]} - * @since 3.0.0 - */ - this.tilesets = mapData.tilesets; - - /** - * An array of ObjectLayer instances parsed from Tiled object layers. - * - * @name Phaser.Tilemaps.Tilemap#objects - * @type {Phaser.Tilemaps.ObjectLayer[]} - * @since 3.0.0 - */ - this.objects = mapData.objects; - - /** - * The index of the currently selected LayerData object. - * - * @name Phaser.Tilemaps.Tilemap#currentLayerIndex - * @type {integer} - * @since 3.0.0 - */ - this.currentLayerIndex = 0; - }, - - /** - * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. - * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled - * editor. - * - * @method Phaser.Tilemaps.Tilemap#addTilesetImage - * @since 3.0.0 - * - * @param {string} tilesetName - The name of the tileset as specified in the map data. - * @param {string} [key] - The key of the Phaser.Cache image used for this tileset. If - * `undefined` or `null` it will look for an image with a key matching the tilesetName parameter. - * @param {integer} [tileWidth] - The width of the tile (in pixels) in the Tileset Image. If not - * given it will default to the map's tileWidth value, or the tileWidth specified in the Tiled - * JSON file. - * @param {integer} [tileHeight] - The height of the tiles (in pixels) in the Tileset Image. If - * not given it will default to the map's tileHeight value, or the tileHeight specified in the - * Tiled JSON file. - * @param {integer} [tileMargin] - The margin around the tiles in the sheet (in pixels). If not - * specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param {integer} [tileSpacing] - The spacing between each the tile in the sheet (in pixels). - * If not specified, it will default to 0 or the value specified in the Tiled JSON file. - * @param {integer} [gid=0] - If adding multiple tilesets to a blank map, specify the starting - * GID this set will use here. - * - * @return {?Phaser.Tilemaps.Tileset} Returns the Tileset object that was created or updated, or null if it - * failed. - */ - addTilesetImage: function (tilesetName, key, tileWidth, tileHeight, tileMargin, tileSpacing, gid) - { - if (tilesetName === undefined) { return null; } - if (key === undefined || key === null) { key = tilesetName; } - - if (!this.scene.sys.textures.exists(key)) - { - console.warn('Invalid image key given for tileset: "' + key + '"'); - return null; - } - - var texture = this.scene.sys.textures.get(key); - - var index = this.getTilesetIndex(tilesetName); - - if (index === null && this.format === Formats.TILED_JSON) - { - console.warn('No data found in the JSON tilemap from Tiled matching the tileset name: "' + tilesetName + '"'); - return null; - } - - if (this.tilesets[index]) - { - this.tilesets[index].setTileSize(tileWidth, tileHeight); - this.tilesets[index].setSpacing(tileMargin, tileSpacing); - this.tilesets[index].setImage(texture); - return this.tilesets[index]; - } - - if (tileWidth === undefined) { tileWidth = this.tileWidth; } - if (tileHeight === undefined) { tileHeight = this.tileHeight; } - if (tileMargin === undefined) { tileMargin = 0; } - if (tileSpacing === undefined) { tileSpacing = 0; } - if (gid === undefined) { gid = 0; } - - var tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); - tileset.setImage(texture); - this.tilesets.push(tileset); - - return tileset; - }, - - /** - * Turns the StaticTilemapLayer associated with the given layer into a DynamicTilemapLayer. If - * no layer specified, the map's current layer is used. This is useful if you want to manipulate - * a map at the start of a scene, but then make it non-manipulable and optimize it for speed. - * Note: the DynamicTilemapLayer passed in is destroyed, so make sure to store the value - * returned from this method if you want to manipulate the new StaticTilemapLayer. - * - * @method Phaser.Tilemaps.Tilemap#convertLayerToStatic - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer)} [layer] - The name of the layer from Tiled, the - * index of the layer in the map, or a DynamicTilemapLayer. - * - * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer that was created, or null if it - * failed. - */ - convertLayerToStatic: function (layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - var dynamicLayer = layer.tilemapLayer; - - if (!dynamicLayer || !(dynamicLayer instanceof DynamicTilemapLayer)) - { - return null; - } - - var staticLayer = new StaticTilemapLayer( - dynamicLayer.scene, - dynamicLayer.tilemap, - dynamicLayer.layerIndex, - dynamicLayer.tileset, - dynamicLayer.x, - dynamicLayer.y - ); - - this.scene.sys.displayList.add(staticLayer); - - dynamicLayer.destroy(); - - return staticLayer; - }, - - /** - * See component documentation. If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#copy - * @since 3.0.0 - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'copy')) { return this; } - - if (layer !== null) - { - TilemapComponents.Copy( - srcTileX, srcTileY, - width, height, - destTileX, destTileY, - recalculateFaces, layer - ); - } - - return this; - }, - - /** - * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set - * to this new layer. - * - * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer - * @since 3.0.0 - * - * @param {string} name - The name of this layer. Must be unique within the map. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {integer} width - The width of the layer in tiles. If not specified, it will default - * to the map's width. - * @param {integer} height - The height of the layer in tiles. If not specified, it will default - * to the map's height. - * @param {integer} tileWidth - The width of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileWidth. - * @param {integer} tileHeight - The height of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileHeight. - * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. - */ - createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) - { - if (tileWidth === undefined) { tileWidth = tileset.tileWidth; } - if (tileHeight === undefined) { tileHeight = tileset.tileHeight; } - if (width === undefined) { width = this.width; } - if (height === undefined) { height = this.height; } - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - - var index = this.getLayerIndex(name); - - if (index !== null) - { - console.warn('Cannot create blank layer: layer with matching name already exists ' + name); - return null; - } - - var layerData = new LayerData({ - name: name, - tileWidth: tileWidth, - tileHeight: tileHeight, - width: width, - height: height - }); - - var row; - - for (var tileY = 0; tileY < height; tileY++) - { - row = []; - - for (var tileX = 0; tileX < width; tileX++) - { - row.push(new Tile(layerData, -1, tileX, tileY, tileWidth, tileHeight, this.tileWidth, this.tileHeight)); - } - - layerData.data.push(row); - } - - this.layers.push(layerData); - this.currentLayerIndex = this.layers.length - 1; - - var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); - this.scene.sys.displayList.add(dynamicLayer); - - return dynamicLayer; - }, - - /** - * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more - * information. - * - * @method Phaser.Tilemaps.Tilemap#createDynamicLayer - * @since 3.0.0 - * - * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * - * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. - */ - createDynamicLayer: function (layerID, tileset, x, y) - { - var index = this.getLayerIndex(layerID); - - if (index === null) - { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); - return null; - } - - var layerData = this.layers[index]; - - // Check for an associated static or dynamic tilemap layer - if (layerData.tilemapLayer) - { - console.warn('Cannot create dynamic tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); - return null; - } - - this.currentLayerIndex = index; - - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. - if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } - if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } - - var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); - this.scene.sys.displayList.add(layer); - - return layer; - }, - - /** - * Creates a Sprite for every object matching the given gid in the map data. All properties from - * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy - * way to configure Sprite properties from within the map editor. For example giving an object a - * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. - * - * @method Phaser.Tilemaps.Tilemap#createFromObjects - * @since 3.0.0 - * - * @param {string} name - The name of the object layer (from Tiled) to create Sprites from. - * @param {(integer|string)} id - Either the id (object), gid (tile object) or name (object or - * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects - * with the same graphic. The same name can be used on multiple objects. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ - createFromObjects: function (name, id, spriteConfig, scene) - { - if (spriteConfig === undefined) { spriteConfig = {}; } - if (scene === undefined) { scene = this.scene; } - - var objectLayer = this.getObjectLayer(name); - if (!objectLayer) - { - console.warn('Cannot create from object. Invalid objectgroup name given: ' + name); - return; - } - - var objects = objectLayer.objects; - var sprites = []; - - for (var i = 0; i < objects.length; i++) - { - var found = false; - var obj = objects[i]; - - if (obj.gid !== undefined && typeof id === 'number' && obj.gid === id || - obj.id !== undefined && typeof id === 'number' && obj.id === id || - obj.name !== undefined && typeof id === 'string' && obj.name === id) - { - found = true; - } - - if (found) - { - var config = Extend({}, spriteConfig, obj.properties); - - config.x = obj.x; - config.y = obj.y; - - var sprite = this.scene.make.sprite(config); - - sprite.name = obj.name; - - if (obj.width) { sprite.displayWidth = obj.width; } - if (obj.height) { sprite.displayHeight = obj.height; } - - // Origin is (0, 1) in Tiled, so find the offset that matches the Sprite's origin. - var offset = { - x: sprite.originX * sprite.displayWidth, - y: (sprite.originY - 1) * sprite.displayHeight - }; - - // If the object is rotated, then the origin offset also needs to be rotated. - if (obj.rotation) - { - var angle = DegToRad(obj.rotation); - Rotate(offset, angle); - sprite.rotation = angle; - } - - sprite.x += offset.x; - sprite.y += offset.y; - - if (obj.flippedHorizontal !== undefined || obj.flippedVertical !== undefined) - { - sprite.setFlip(obj.flippedHorizontal, obj.flippedVertical); - } - - if (!obj.visible) { sprite.visible = false; } - - sprites.push(sprite); - } - } - - return sprites; - }, - - /** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @method Phaser.Tilemaps.Tilemap#createFromTiles - * @since 3.0.0 - * - * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.GameObjects.Sprite[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - createFromTiles: function (indexes, replacements, spriteConfig, scene, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.CreateFromTiles(indexes, replacements, spriteConfig, scene, camera, layer); - }, - - /** - * Creates a new StaticTilemapLayer that renders the LayerData associated with the given - * `layerID`. The currently selected layer in the map is set to this new layer. - * - * The `layerID` is important. If you've created your map in Tiled then you can get this by - * looking in Tiled and looking at the layer name. Or you can open the JSON file it exports and - * look at the layers[].name value. Either way it must match. - * - * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for - * more information. - * - * @method Phaser.Tilemaps.Tilemap#createStaticLayer - * @since 3.0.0 - * - * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * - * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed. - */ - createStaticLayer: function (layerID, tileset, x, y) - { - var index = this.getLayerIndex(layerID); - - if (index === null) - { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); - return null; - } - - var layerData = this.layers[index]; - - // Check for an associated static or dynamic tilemap layer - if (layerData.tilemapLayer) - { - console.warn('Cannot create static tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); - return null; - } - - this.currentLayerIndex = index; - - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. - if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } - if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } - - var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); - this.scene.sys.displayList.add(layer); - - return layer; - }, - - /** - * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any - * StaticTilemapLayers or DynamicTilemapLayers that have been linked to LayerData. - * - * @method Phaser.Tilemaps.Tilemap#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.removeAllLayers(); - this.tilesets.length = 0; - this.objects.length = 0; - this.scene = undefined; - }, - - /** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * If no layer specified, the map's current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#fill - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - fill: function (index, tileX, tileY, width, height, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'fill')) { return this; } - - if (layer !== null) - { - TilemapComponents.Fill(index, tileX, tileY, width, height, recalculateFaces, layer); - } - - return this; - }, - - /** - * For each object in the given object layer, run the given filter callback function. Any - * objects that pass the filter test (i.e. where the callback returns true) will returned as a - * new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @method Phaser.Tilemaps.Tilemap#filterObjects - * @since 3.0.0 - * - * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. - * @param {TilemapFilterCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * - * @return {?Phaser.GameObjects.GameObject[]} An array of object that match the search, or null if the objectLayer given was invalid. - */ - filterObjects: function (objectLayer, callback, context) - { - if (typeof objectLayer === 'string') - { - var name = objectLayer; - - objectLayer = this.getObjectLayer(objectLayer); - - if (!objectLayer) - { - console.warn('No object layer found with the name: ' + name); - return null; - } - } - - return objectLayer.objects.filter(callback, context); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#filterTiles - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - filterTiles: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FilterTiles(callback, context, tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#findByIndex - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. - */ - findByIndex: function (findIndex, skip, reverse, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FindByIndex(findIndex, skip, reverse, layer); - }, - - /** - * Find the first object in the given object layer that satisfies the provided testing function. - * I.e. finds the first object for which `callback` returns true. Similar to - * Array.prototype.find in vanilla JS. - * - * @method Phaser.Tilemaps.Tilemap#findObject - * @since 3.0.0 - * - * @param {(Phaser.Tilemaps.ObjectLayer|string)} objectLayer - The name of an object layer (from Tiled) or an ObjectLayer instance. - * @param {TilemapFindCallback} callback - The callback. Each object in the given area will be passed to this callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * - * @return {?Phaser.GameObjects.GameObject} An object that matches the search, or null if no object found. - */ - findObject: function (objectLayer, callback, context) - { - if (typeof objectLayer === 'string') - { - var name = objectLayer; - - objectLayer = this.getObjectLayer(objectLayer); - - if (!objectLayer) - { - console.warn('No object layer found with the name: ' + name); - return null; - } - } - - return objectLayer.objects.find(callback, context) || null; - }, - - /** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#findTile - * @since 3.0.0 - * - * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. - */ - findTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.FindTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#forEachTile - * @since 3.0.0 - * - * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - forEachTile: function (callback, context, tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer !== null) - { - TilemapComponents.ForEachTile(callback, context, tileX, tileY, width, height, filteringOptions, layer); - } - - return this; - }, - - /** - * Gets the image layer index based on its name. - * - * @method Phaser.Tilemaps.Tilemap#getImageIndex - * @since 3.0.0 - * - * @param {string} name - The name of the image to get. - * - * @return {integer} The index of the image in this tilemap, or null if not found. - */ - getImageIndex: function (name) - { - return this.getIndex(this.images, name); - }, - - /** - * Internally used. Returns the index of the object in one of the Tilemaps arrays whose name - * property matches the given `name`. - * - * @method Phaser.Tilemaps.Tilemap#getIndex - * @since 3.0.0 - * - * @param {array} location - The Tilemap array to search. - * @param {string} name - The name of the array element to get. - * - * @return {number} The index of the element in the array, or null if not found. - */ - getIndex: function (location, name) - { - for (var i = 0; i < location.length; i++) - { - if (location[i].name === name) - { - return i; - } - } - - return null; - }, - - /** - * Gets the LayerData from this.layers that is associated with `layer`, or null if an invalid - * `layer` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayer - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the maps current layer index. - * - * @return {Phaser.Tilemaps.LayerData} The corresponding LayerData within this.layers. - */ - getLayer: function (layer) - { - var index = this.getLayerIndex(layer); - - return index !== null ? this.layers[index] : null; - }, - - /** - * Gets the ObjectLayer from this.objects that has the given `name`, or null if no ObjectLayer - * is found with that name. - * - * @method Phaser.Tilemaps.Tilemap#getObjectLayer - * @since 3.0.0 - * - * @param {string} [name] - The name of the object layer from Tiled. - * - * @return {?Phaser.Tilemaps.ObjectLayer} The corresponding ObjectLayer within this.objects or null. - */ - getObjectLayer: function (name) - { - var index = this.getIndex(this.objects, name); - - return index !== null ? this.objects[index] : null; - }, - - /** - * Gets the LayerData index of the given `layer` within this.layers, or null if an invalid - * `layer` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayerIndex - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {integer} The LayerData index within this.layers. - */ - getLayerIndex: function (layer) - { - if (layer === undefined) - { - return this.currentLayerIndex; - } - else if (typeof layer === 'string') - { - return this.getLayerIndexByName(layer); - } - else if (typeof layer === 'number' && layer < this.layers.length) - { - return layer; - } - else if (layer instanceof StaticTilemapLayer || layer instanceof DynamicTilemapLayer) - { - return layer.layerIndex; - } - else - { - return null; - } - }, - - /** - * Gets the index of the LayerData within this.layers that has the given `name`, or null if an - * invalid `name` is given. - * - * @method Phaser.Tilemaps.Tilemap#getLayerIndexByName - * @since 3.0.0 - * - * @param {string} name - The name of the layer to get. - * - * @return {integer} The LayerData index within this.layers. - */ - getLayerIndexByName: function (name) - { - return this.getIndex(this.layers, name); - }, - - /** - * Gets a tile at the given tile coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTileAt - * @since 3.0.0 - * - * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). - * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - getTileAt: function (tileX, tileY, nonNull, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTileAt(tileX, tileY, nonNull, layer); - }, - - /** - * Gets a tile at the given world coordinates from the given layer. - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - getTileAtWorldXY: function (worldX, worldY, nonNull, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) - { - return null; - } - else - { - return TilemapComponents.GetTileAtWorldXY(worldX, worldY, nonNull, camera, layer); - } - }, - - /** - * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithin: function (tileX, tileY, width, height, filteringOptions, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - }, - - /** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithinShape - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithinShape: function (shape, filteringOptions, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithinShape(shape, filteringOptions, camera, layer); - }, - - /** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. - */ - getTilesWithinWorldXY: function (worldX, worldY, width, height, filteringOptions, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); - }, - - /** - * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an - * invalid `name` is given. - * - * @method Phaser.Tilemaps.Tilemap#getTilesetIndex - * @since 3.0.0 - * - * @param {string} name - The name of the Tileset to get. - * - * @return {integer} The Tileset index within this.tilesets. - */ - getTilesetIndex: function (name) - { - return this.getIndex(this.tilesets, name); - }, - - /** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#hasTileAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?boolean} Returns a boolean, or null if the layer given was invalid. - */ - hasTileAt: function (tileX, tileY, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.HasTileAt(tileX, tileY, layer); - }, - - /** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?boolean} Returns a boolean, or null if the layer given was invalid. - */ - hasTileAtWorldXY: function (worldX, worldY, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.HasTileAtWorldXY(worldX, worldY, camera, layer); - }, - - /** - * The LayerData object that is currently selected in the map. You can set this property using - * any type supported by setLayer. - * - * @name Phaser.Tilemaps.Tilemap#layer - * @type {Phaser.Tilemaps.LayerData} - * @since 3.0.0 - */ - layer: { - get: function () - { - return this.layers[this.currentLayerIndex]; - }, - - set: function (layer) - { - this.setLayer(layer); - } - }, - - /** - * Puts a tile at the given tile coordinates in the specified layer. You can pass in either an index - * or a Tile object. If you pass in a Tile, all attributes will be copied over to the specified - * location. If you pass in an index, only the index at the specified location will be changed. - * Collision information will be recalculated at the specified location. - * - * If no layer specified, the maps current layer is used. - * - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTileAt - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTileAt')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.PutTileAt(tile, tileX, tileY, recalculateFaces, layer); - }, - - /** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * If no layer specified, the maps current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTileAtWorldXY - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - putTileAtWorldXY: function (tile, worldX, worldY, recalculateFaces, camera, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTileAtWorldXY')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.PutTileAtWorldXY(tile, worldX, worldY, recalculateFaces, camera, layer); - }, - - /** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#putTilesAt - * @since 3.0.0 - * - * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - putTilesAt: function (tilesArray, tileX, tileY, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'putTilesAt')) { return this; } - - if (layer !== null) - { - TilemapComponents.PutTilesAt(tilesArray, tileX, tileY, recalculateFaces, layer); - } - - return this; - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will recieve a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#randomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - randomize: function (tileX, tileY, width, height, indexes, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'randomize')) { return this; } - - if (layer !== null) - { - TilemapComponents.Randomize(tileX, tileY, width, height, indexes, layer); - } - - return this; - }, - - /** - * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting - * faces are used internally for optimizing collisions against tiles. This method is mostly used - * internally to optimize recalculating faces when only one tile has been changed. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#calculateFacesAt - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - calculateFacesAt: function (tileX, tileY, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.CalculateFacesAt(tileX, tileY, layer); - - return this; - }, - - /** - * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the - * layer. Interesting faces are used internally for optimizing collisions against tiles. This method - * is mostly used internally. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. - */ - calculateFacesWithin: function (tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.CalculateFacesWithin(tileX, tileY, width, height, layer); - - return this; - }, - - /** - * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or - * DynamicTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeAllLayers - * @since 3.0.0 - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - removeAllLayers: function () - { - // Destroy any StaticTilemapLayers or DynamicTilemapLayers that are stored in LayerData - for (var i = 0; i < this.layers.length; i++) - { - if (this.layers[i].tilemapLayer) - { - this.layers[i].tilemapLayer.destroy(); - } - } - - this.layers.length = 0; - this.currentLayerIndex = 0; - - return this; - }, - - /** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeTileAt - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - removeTileAt: function (tileX, tileY, replaceWithNull, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'removeTileAt')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); - }, - - /** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. - */ - removeTileAtWorldXY: function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'removeTileAtWorldXY')) { return null; } - - if (layer === null) { return null; } - - return TilemapComponents.RemoveTileAtWorldXY(worldX, worldY, replaceWithNull, recalculateFaces, camera, layer); - }, - - /** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#renderDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - renderDebug: function (graphics, styleConfig, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.RenderDebug(graphics, styleConfig, layer); - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#replaceByIndex - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - replaceByIndex: function (findIndex, newIndex, tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'replaceByIndex')) { return this; } - - if (layer !== null) - { - TilemapComponents.ReplaceByIndex(findIndex, newIndex, tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollision - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollision: function (indexes, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollision(indexes, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionBetween - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionBetween: function (start, stop, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionBetween(start, stop, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionByProperty: function (properties, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionByProperty(properties, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionByExclusion - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionByExclusion: function (indexes, collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionByExclusion(indexes, collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setCollisionFromCollisionGroup: function (collides, recalculateFaces, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetCollisionFromCollisionGroup(collides, recalculateFaces, layer); - - return this; - }, - - /** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setTileIndexCallback: function (indexes, callback, callbackContext, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetTileIndexCallback(indexes, callback, callbackContext, layer); - - return this; - }, - - /** - * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * If no layer specified, the map's current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} [callbackContext] - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - setTileLocationCallback: function (tileX, tileY, width, height, callback, callbackContext, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - TilemapComponents.SetTileLocationCallback(tileX, tileY, width, height, callback, callbackContext, layer); - - return this; - }, - - /** - * Sets the current layer to the LayerData associated with `layer`. - * - * @method Phaser.Tilemaps.Tilemap#setLayer - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setLayer: function (layer) - { - var index = this.getLayerIndex(layer); - - if (index !== null) - { - this.currentLayerIndex = index; - } - - return this; - }, - - /** - * Sets the base tile size for the map. Note: this does not necessarily match the tileWidth and - * tileHeight for all layers. This also updates the base size on all tiles across all layers. - * - * @method Phaser.Tilemaps.Tilemap#setBaseTileSize - * @since 3.0.0 - * - * @param {integer} tileWidth - The width of the tiles the map uses for calculations. - * @param {integer} tileHeight - The height of the tiles the map uses for calculations. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setBaseTileSize: function (tileWidth, tileHeight) - { - this.tileWidth = tileWidth; - this.tileHeight = tileHeight; - this.widthInPixels = this.width * tileWidth; - this.heightInPixels = this.height * tileHeight; - - // Update the base tile size on all layers & tiles - for (var i = 0; i < this.layers.length; i++) - { - this.layers[i].baseWidth = tileWidth; - this.layers[i].baseHeight = tileHeight; - - var mapData = this.layers[i].data; - var mapWidth = this.layers[i].width; - var mapHeight = this.layers[i].height; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile !== null) - { - tile.setSize(undefined, undefined, tileWidth, tileHeight); - } - } - } - } - - return this; - }, - - /** - * Sets the tile size for a specific `layer`. Note: this does not necessarily match the map's - * tileWidth and tileHeight for all layers. This will set the tile size for the layer and any - * tiles the layer has. - * - * @method Phaser.Tilemaps.Tilemap#setLayerTileSize - * @since 3.0.0 - * - * @param {integer} tileWidth - The width of the tiles (in pixels) in the layer. - * @param {integer} tileHeight - The height of the tiles (in pixels) in the layer. - * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The name of the - * layer from Tiled, the index of the layer in the map, a DynamicTilemapLayer or a - * StaticTilemapLayer. If not given will default to the map's current layer index. - * - * @return {Phaser.Tilemaps.Tilemap} This Tilemap object. - */ - setLayerTileSize: function (tileWidth, tileHeight, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return this; } - - layer.tileWidth = tileWidth; - layer.tileHeight = tileHeight; - - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile !== null) { tile.setSize(tileWidth, tileHeight); } - } - } - - return this; - }, - - /** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#shuffle - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - shuffle: function (tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'shuffle')) { return this; } - - if (layer !== null) - { - TilemapComponents.Shuffle(tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * If no layer specified, the maps current layer is used. - * This cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#swapByIndex - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - swapByIndex: function (indexA, indexB, tileX, tileY, width, height, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'swapByIndex')) { return this; } - - if (layer !== null) - { - TilemapComponents.SwapByIndex(indexA, indexB, tileX, tileY, width, height, layer); - } - - return this; - }, - - /** - * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldX - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?number} Returns a number, or null if the layer given was invalid. - */ - tileToWorldX: function (tileX, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldX(tileX, camera, layer); - }, - - /** - * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldY - * @since 3.0.0 - * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?number} Returns a number, or null if the layer given was invalid. - */ - tileToWorldY: function (tileX, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldY(tileX, camera, layer); - }, - - /** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#tileToWorldXY - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. - */ - tileToWorldXY: function (tileX, tileY, point, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.TileToWorldXY(tileX, tileY, point, camera, layer); - }, - - /** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. - * - * @method Phaser.Tilemaps.Tilemap#weightedRandomize - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. - */ - weightedRandomize: function (tileX, tileY, width, height, weightedIndexes, layer) - { - layer = this.getLayer(layer); - - if (this._isStaticCall(layer, 'weightedRandomize')) { return this; } - - if (layer !== null) - { - TilemapComponents.WeightedRandomize(tileX, tileY, width, height, weightedIndexes, layer); - } - - return this; - }, - - /** - * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileX - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?number} Returns a number, or null if the layer given was invalid. - */ - worldToTileX: function (worldX, snapToFloor, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileX(worldX, snapToFloor, camera, layer); - }, - - /** - * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the - * layers position, scale and scroll. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileY - * @since 3.0.0 - * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?number} Returns a number, or null if the layer given was invalid. - */ - worldToTileY: function (worldY, snapToFloor, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileY(worldY, snapToFloor, camera, layer); - }, - - /** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layers position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * If no layer specified, the maps current layer is used. - * - * @method Phaser.Tilemaps.Tilemap#worldToTileXY - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] - * - * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. - */ - worldToTileXY: function (worldX, worldY, snapToFloor, point, camera, layer) - { - layer = this.getLayer(layer); - - if (layer === null) { return null; } - - return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, layer); - }, - - /** - * Used internally to check if a layer is static and prints out a warning. - * - * @method Phaser.Tilemaps.Tilemap#_isStaticCall - * @private - * @since 3.0.0 - * - * @return {boolean} - */ - _isStaticCall: function (layer, functionName) - { - if (layer.tilemapLayer instanceof StaticTilemapLayer) - { - console.warn(functionName + ': You cannot change the tiles in a static tilemap layer'); - return true; - } - else - { - return false; - } - } - -}); - -module.exports = Tilemap; - - -/***/ }), -/* 312 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var MapData = __webpack_require__(103); -var ParseTileLayers = __webpack_require__(629); -var ParseTilesets = __webpack_require__(628); - -/** - * @namespace Phaser.Tilemaps.Parsers.Impact - */ - -/** - * Parses a Weltmeister JSON object into a new MapData object. - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseWeltmeister - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {object} json - The Weltmeister JSON object. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty + * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @param {integer} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [tileHeight=32] - The height of a tile in pixels. Pass in `null` to leave as the + * default. + * @param {integer} [width=10] - The width of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer} [height=10] - The height of the map in tiles. Pass in `null` to leave as the + * default. + * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from + * a 2D array of tile indexes. Pass in `null` for no data. + * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the + * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty * location will get a Tile object with an index of -1. If you've a large sparsely populated map and * the tile data doesn't need to change then setting this value to `true` will help with memory * consumption. However if your map is small or you need to update the tiles dynamically, then leave * the default value set. - * - * @return {?object} [description] + * + * @return {Phaser.Tilemaps.Tilemap} */ -var ParseWeltmeister = function (name, json, insertNull) +GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, width, height, data, insertNull) { - if (json.layer.length === 0) - { - console.warn('No layers found in the Weltmeister map: ' + name); - return null; - } + // Allow users to specify null to indicate that they want the default value, since null is + // shorter & more legible than undefined. Convert null to undefined to allow ParseToTilemap + // defaults to take effect. - var width = 0; - var height = 0; - - for (var i = 0; i < json.layer.length; i++) - { - if (json.layer[i].width > width) { width = json.layer[i].width; } - if (json.layer[i].height > height) { height = json.layer[i].height; } - } - - var mapData = new MapData({ - width: width, - height: height, - name: name, - tileWidth: json.layer[0].tilesize, - tileHeight: json.layer[0].tilesize, - format: Formats.WELTMEISTER - }); - - mapData.layers = ParseTileLayers(json, insertNull); - mapData.tilesets = ParseTilesets(json); - - return mapData; -}; - -module.exports = ParseWeltmeister; - - -/***/ }), -/* 313 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); - -/** - * @classdesc - * A class for representing a Tiled object layer in a map. This mirrors the structure of a Tiled - * object layer, except: - * - "x" & "y" properties are ignored since these cannot be changed in Tiled. - * - "offsetx" & "offsety" are applied to the individual object coordinates directly, so they - * are ignored as well. - * - "draworder" is ignored. - * - * @class ObjectLayer - * @memberOf Phaser.Tilemaps - * @constructor - * @since 3.0.0 - * - * @param {object} [config] - [description] - */ -var ObjectLayer = new Class({ - - initialize: - - function ObjectLayer (config) - { - if (config === undefined) { config = {}; } - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#name - * @type {string} - * @since 3.0.0 - */ - this.name = GetFastValue(config, 'name', 'object layer'); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#opacity - * @type {number} - * @since 3.0.0 - */ - this.opacity = GetFastValue(config, 'opacity', 1); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = GetFastValue(config, 'properties', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#propertyTypes - * @type {object} - * @since 3.0.0 - */ - this.propertyTypes = GetFastValue(config, 'propertytypes', {}); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#type - * @type {string} - * @since 3.0.0 - */ - this.type = GetFastValue(config, 'type', 'objectgroup'); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#visible - * @type {boolean} - * @since 3.0.0 - */ - this.visible = GetFastValue(config, 'visible', true); - - /** - * [description] - * - * @name Phaser.Tilemaps.ObjectLayer#objects - * @type {Phaser.GameObjects.GameObject[]} - * @since 3.0.0 - */ - this.objects = GetFastValue(config, 'objects', []); - } + if (key === null) { key = undefined; } + if (tileWidth === null) { tileWidth = undefined; } + if (tileHeight === null) { tileHeight = undefined; } + if (width === null) { width = undefined; } + if (height === null) { height = undefined; } + return ParseToTilemap(this.scene, key, tileWidth, tileHeight, width, height, data, insertNull); }); -module.exports = ObjectLayer; +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns /***/ }), -/* 314 */ +/* 443 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -78694,252 +103239,59 @@ module.exports = ObjectLayer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Pick = __webpack_require__(633); -var ParseGID = __webpack_require__(316); - -var copyPoints = function (p) { return { x: p.x, y: p.y }; }; - -var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; +var GameObjectCreator = __webpack_require__(13); +var ParseToTilemap = __webpack_require__(132); /** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject - * @since 3.0.0 - * - * @param {object} tiledObject - [description] - * @param {number} [offsetX=0] - [description] - * @param {number} [offsetY=0] - [description] - * - * @return {object} [description] - */ -var ParseObject = function (tiledObject, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - var parsedObject = Pick(tiledObject, commonObjectProps); - - parsedObject.x += offsetX; - parsedObject.y += offsetY; - - if (tiledObject.gid) - { - // Object tiles - var gidInfo = ParseGID(tiledObject.gid); - parsedObject.gid = gidInfo.gid; - parsedObject.flippedHorizontal = gidInfo.flippedHorizontal; - parsedObject.flippedVertical = gidInfo.flippedVertical; - parsedObject.flippedAntiDiagonal = gidInfo.flippedAntiDiagonal; - } - else if (tiledObject.polyline) - { - parsedObject.polyline = tiledObject.polyline.map(copyPoints); - } - else if (tiledObject.polygon) - { - parsedObject.polygon = tiledObject.polygon.map(copyPoints); - } - else if (tiledObject.ellipse) - { - parsedObject.ellipse = tiledObject.ellipse; - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - } - else if (tiledObject.text) - { - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - parsedObject.text = tiledObject.text; - } - else - { - // Otherwise, assume it is a rectangle - parsedObject.rectangle = true; - parsedObject.width = tiledObject.width; - parsedObject.height = tiledObject.height; - } - - return parsedObject; -}; - -module.exports = ParseObject; - - -/***/ }), -/* 315 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + * @typedef {object} TilemapConfig + * + * @property {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. + * @property {integer[][]} [data] - Instead of loading from the cache, you can also load directly from a 2D array of tile indexes. + * @property {integer} [tileWidth=32] - The width of a tile in pixels. + * @property {integer} [tileHeight=32] - The height of a tile in pixels. + * @property {integer} [width=10] - The width of the map in tiles. + * @property {integer} [height=10] - The height of the map in tiles. + * @property {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, + * in the map data are handled. If `true`, empty locations will get a value of `null`. If `false`, + * empty location will get a Tile object with an index of -1. If you've a large sparsely populated + * map and the tile data doesn't need to change then setting this value to `true` will help with + * memory consumption. However if your map is small or you need to update the tiles dynamically, + * then leave the default value set. */ -var Class = __webpack_require__(0); - /** - * @classdesc - * An Image Collection is a special Tile Set containing multiple images, with no slicing into each image. + * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. + * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing + * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map + * data. For an empty map, you should specify tileWidth, tileHeight, width & height. * - * Image Collections are normally created automatically when Tiled data is loaded. - * - * @class ImageCollection - * @memberOf Phaser.Tilemaps - * @constructor + * @method Phaser.GameObjects.GameObjectCreator#tilemap * @since 3.0.0 * - * @param {string} name - The name of the image collection in the map data. - * @param {integer} firstgid - The first image index this image collection contains. - * @param {integer} [width=32] - Width of widest image (in pixels). - * @param {integer} [height=32] - Height of tallest image (in pixels). - * @param {integer} [margin=0] - The margin around all images in the collection (in pixels). - * @param {integer} [spacing=0] - The spacing between each image in the collection (in pixels). - * @param {object} [properties={}] - Custom Image Collection properties. + * @param {TilemapConfig} [config] - The config options for the Tilemap. + * + * @return {Phaser.Tilemaps.Tilemap} */ -var ImageCollection = new Class({ - - initialize: - - function ImageCollection (name, firstgid, width, height, margin, spacing, properties) - { - if (width === undefined || width <= 0) { width = 32; } - if (height === undefined || height <= 0) { height = 32; } - if (margin === undefined) { margin = 0; } - if (spacing === undefined) { spacing = 0; } - - /** - * The name of the Image Collection. - * - * @name Phaser.Tilemaps.ImageCollection#name - * @type {string} - * @since 3.0.0 - */ - this.name = name; - - /** - * The Tiled firstgid value. - * This is the starting index of the first image index this Image Collection contains. - * - * @name Phaser.Tilemaps.ImageCollection#firstgid - * @type {integer} - * @since 3.0.0 - */ - this.firstgid = firstgid | 0; - - /** - * The width of the widest image (in pixels). - * - * @name Phaser.Tilemaps.ImageCollection#imageWidth - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageWidth = width | 0; - - /** - * The height of the tallest image (in pixels). - * - * @name Phaser.Tilemaps.ImageCollection#imageHeight - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageHeight = height | 0; - - /** - * The margin around the images in the collection (in pixels). - * Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.ImageCollection#imageMarge - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageMargin = margin | 0; - - /** - * The spacing between each image in the collection (in pixels). - * Use `setSpacing` to change. - * - * @name Phaser.Tilemaps.ImageCollection#imageSpacing - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.imageSpacing = spacing | 0; - - /** - * Image Collection-specific properties that are typically defined in the Tiled editor. - * - * @name Phaser.Tilemaps.ImageCollection#properties - * @type {object} - * @since 3.0.0 - */ - this.properties = properties || {}; - - /** - * The cached images that are a part of this collection. - * - * @name Phaser.Tilemaps.ImageCollection#images - * @type {array} - * @readOnly - * @since 3.0.0 - */ - this.images = []; - - /** - * The total number of images in the image collection. - * - * @name Phaser.Tilemaps.ImageCollection#total - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.total = 0; - }, - - /** - * Returns true if and only if this image collection contains the given image index. - * - * @method Phaser.Tilemaps.ImageCollection#containsImageIndex - * @since 3.0.0 - * - * @param {integer} imageIndex - The image index to search for. - * - * @return {boolean} True if this Image Collection contains the given index. - */ - containsImageIndex: function (imageIndex) - { - return (imageIndex >= this.firstgid && imageIndex < (this.firstgid + this.total)); - }, - - /** - * Add an image to this Image Collection. - * - * @method Phaser.Tilemaps.ImageCollection#addImage - * @since 3.0.0 - * - * @param {integer} gid - The gid of the image in the Image Collection. - * @param {string} image - The the key of the image in the Image Collection and in the cache. - * - * @return {Phaser.Tilemaps.ImageCollection} This ImageCollection object. - */ - addImage: function (gid, image) - { - this.images.push({ gid: gid, image: image }); - this.total++; - - return this; - } +GameObjectCreator.register('tilemap', function (config) +{ + // Defaults are applied in ParseToTilemap + var c = (config !== undefined) ? config : {}; + return ParseToTilemap( + this.scene, + c.key, + c.tileWidth, + c.tileHeight, + c.width, + c.height, + c.data, + c.insertNull + ); }); -module.exports = ImageCollection; - /***/ }), -/* 316 */ +/* 444 */ /***/ (function(module, exports) { /** @@ -78948,435 +103300,3131 @@ module.exports = ImageCollection; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var FLIPPED_HORIZONTAL = 0x80000000; -var FLIPPED_VERTICAL = 0x40000000; -var FLIPPED_ANTI_DIAGONAL = 0x20000000; // Top-right is swapped with bottom-left corners - /** - * See Tiled documentation on tile flipping: - * http://docs.mapeditor.org/en/latest/reference/tmx-map-format/ + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseGID + * @method Phaser.Tilemaps.StaticTilemapLayer#renderCanvas * @since 3.0.0 - * - * @param {number} gid - [description] - * - * @return {object} [description] - */ -var ParseGID = function (gid) -{ - var flippedHorizontal = Boolean(gid & FLIPPED_HORIZONTAL); - var flippedVertical = Boolean(gid & FLIPPED_VERTICAL); - var flippedAntiDiagonal = Boolean(gid & FLIPPED_ANTI_DIAGONAL); - gid = gid & ~(FLIPPED_HORIZONTAL | FLIPPED_VERTICAL | FLIPPED_ANTI_DIAGONAL); - - // Parse the flip flags into something Phaser can use - var rotation = 0; - var flipped = false; - - if (flippedHorizontal && flippedVertical && flippedAntiDiagonal) - { - rotation = Math.PI / 2; - flipped = true; - } - else if (flippedHorizontal && flippedVertical && !flippedAntiDiagonal) - { - rotation = Math.PI; - flipped = false; - } - else if (flippedHorizontal && !flippedVertical && flippedAntiDiagonal) - { - rotation = Math.PI / 2; - flipped = false; - } - else if (flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) - { - rotation = 0; - flipped = true; - } - else if (!flippedHorizontal && flippedVertical && flippedAntiDiagonal) - { - rotation = 3 * Math.PI / 2; - flipped = false; - } - else if (!flippedHorizontal && flippedVertical && !flippedAntiDiagonal) - { - rotation = Math.PI; - flipped = true; - } - else if (!flippedHorizontal && !flippedVertical && flippedAntiDiagonal) - { - rotation = 3 * Math.PI / 2; - flipped = true; - } - else if (!flippedHorizontal && !flippedVertical && !flippedAntiDiagonal) - { - rotation = 0; - flipped = false; - } - - return { - gid: gid, - flippedHorizontal: flippedHorizontal, - flippedVertical: flippedVertical, - flippedAntiDiagonal: flippedAntiDiagonal, - rotation: rotation, - flipped: flipped - }; -}; - -module.exports = ParseGID; - - -/***/ }), -/* 317 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var MapData = __webpack_require__(103); -var ParseTileLayers = __webpack_require__(637); -var ParseImageLayers = __webpack_require__(635); -var ParseTilesets = __webpack_require__(634); -var ParseObjectLayers = __webpack_require__(632); -var BuildTilesetIndex = __webpack_require__(631); -var AssignTileProperties = __webpack_require__(630); - -/** - * @namespace Phaser.Tilemaps.Parsers.Tiled - */ - -/** - * Parses a Tiled JSON object into a new MapData object. - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseJSONTiled - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {object} json - The Tiled JSON object. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {?Phaser.Tilemaps.MapData} [description] - */ -var ParseJSONTiled = function (name, json, insertNull) -{ - if (json.orientation !== 'orthogonal') - { - console.warn('Only orthogonal map types are supported in this version of Phaser'); - return null; - } - - // Map data will consist of: layers, objects, images, tilesets, sizes - var mapData = new MapData({ - width: json.width, - height: json.height, - name: name, - tileWidth: json.tilewidth, - tileHeight: json.tileheight, - orientation: json.orientation, - format: Formats.TILED_JSON, - version: json.version, - properties: json.properties - }); - - mapData.layers = ParseTileLayers(json, insertNull); - mapData.images = ParseImageLayers(json); - - var sets = ParseTilesets(json); - mapData.tilesets = sets.tilesets; - mapData.imageCollections = sets.imageCollections; - - mapData.objects = ParseObjectLayers(json); - - mapData.tiles = BuildTilesetIndex(mapData); - - AssignTileProperties(mapData); - - return mapData; -}; - -module.exports = ParseJSONTiled; - - -/***/ }), -/* 318 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var Parse2DArray = __webpack_require__(217); - -/** - * Parses a CSV string of tile indexes into a new MapData object with a single layer. - * - * @function Phaser.Tilemaps.Parsers.ParseCSV - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {string} data - CSV string of tile indexes. - * @param {integer} tileWidth - The width of a tile in pixels. - * @param {integer} tileHeight - The height of a tile in pixels. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.MapData} [description] - */ -var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) -{ - var array2D = data - .trim() - .split('\n') - .map(function (row) { return row.split(','); }); - - var map = Parse2DArray(name, array2D, tileWidth, tileHeight, insertNull); - map.format = Formats.CSV; - - return map; -}; - -module.exports = ParseCSV; - - -/***/ }), -/* 319 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Formats = __webpack_require__(26); -var Parse2DArray = __webpack_require__(217); -var ParseCSV = __webpack_require__(318); -var ParseJSONTiled = __webpack_require__(317); -var ParseWeltmeister = __webpack_require__(312); - -/** - * Parses raw data of a given Tilemap format into a new MapData object. If no recognized data format - * is found, returns `null`. When loading from CSV or a 2D array, you should specify the tileWidth & - * tileHeight. When parsing from a map from Tiled, the tileWidth & tileHeight will be pulled from - * the map data. - * - * @function Phaser.Tilemaps.Parsers.Parse - * @since 3.0.0 - * - * @param {string} name - The name of the tilemap, used to set the name on the MapData. - * @param {integer} mapFormat - See ../Formats.js. - * @param {(integer[][]|string|object)} data - 2D array, CSV string or Tiled JSON object. - * @param {integer} tileWidth - The width of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param {integer} tileHeight - The height of a tile in pixels. Required for 2D array and CSV, but - * ignored for Tiled JSON. - * @param {boolean} insertNull - Controls how empty tiles, tiles with an index of -1, in the map - * data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.MapData} [description] - */ -var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) -{ - var newMap; - - switch (mapFormat) - { - case (Formats.ARRAY_2D): - newMap = Parse2DArray(name, data, tileWidth, tileHeight, insertNull); - break; - case (Formats.CSV): - newMap = ParseCSV(name, data, tileWidth, tileHeight, insertNull); - break; - case (Formats.TILED_JSON): - newMap = ParseJSONTiled(name, data, insertNull); - break; - case (Formats.WELTMEISTER): - newMap = ParseWeltmeister(name, data, insertNull); - break; - default: - console.warn('Unrecognized tilemap data format: ' + mapFormat); - newMap = null; - } - - return newMap; -}; - -module.exports = Parse; - - -/***/ }), -/* 320 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tile = __webpack_require__(66); -var IsInLayerBounds = __webpack_require__(105); -var CalculateFacesAt = __webpack_require__(220); - -/** - * Removes the tile at the given tile coordinates in the specified layer and updates the layer's - * collision information. - * - * @function Phaser.Tilemaps.Components.RemoveTileAt * @private - * @since 3.0.0 * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, layer) +var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (replaceWithNull === undefined) { replaceWithNull = false; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } + src.cull(camera); - var tile = layer.data[tileY][tileX]; - if (tile === null) + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + + if (tileCount === 0) { - return null; + return; + } + + var camMatrix = renderer._tempMatrix1; + var layerMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + var ctx = renderer.currentContext; + var gidMap = src.gidMap; + + ctx.save(); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + layerMatrix.e = src.x; + layerMatrix.f = src.y; + + camMatrix.multiply(layerMatrix, calcMatrix); + + calcMatrix.copyToContext(ctx); } else { - layer.data[tileY][tileX] = replaceWithNull - ? null - : new Tile(layer, -1, tileX, tileY, tile.width, tile.height); + // Undo the camera scroll + layerMatrix.e -= camera.scrollX * src.scrollFactorX; + layerMatrix.f -= camera.scrollY * src.scrollFactorY; + + layerMatrix.copyToContext(ctx); } - // Recalculate faces only if the removed tile was a colliding tile - if (recalculateFaces && tile && tile.collides) + var alpha = camera.alpha * src.alpha; + + ctx.globalAlpha = camera.alpha * src.alpha; + + for (var i = 0; i < tileCount; i++) { - CalculateFacesAt(tileX, tileY, layer); - } + var tile = renderTiles[i]; - return tile; -}; + var tileset = gidMap[tile.index]; -module.exports = RemoveTileAt; - - -/***/ }), -/* 321 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var IsInLayerBounds = __webpack_require__(105); - -/** - * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @function Phaser.Tilemaps.Components.HasTileAt - * @private - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var HasTileAt = function (tileX, tileY, layer) -{ - if (IsInLayerBounds(tileX, tileY, layer)) - { - var tile = layer.data[tileY][tileX]; - return (tile !== null && tile.index > -1); - } - else - { - return false; - } - -}; - -module.exports = HasTileAt; - - -/***/ }), -/* 322 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does - * not change collision information. - * - * @function Phaser.Tilemaps.Components.ReplaceByIndex - * @private - * @since 3.0.0 - * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - if (tiles[i] && tiles[i].index === findIndex) + if (!tileset) { - tiles[i].index = newIndex; + continue; + } + + var image = tileset.image.getSourceImage(); + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords) + { + var halfWidth = tile.width / 2; + var halfHeight = tile.height / 2; + + ctx.save(); + + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale((tile.flipX) ? -1 : 1, (tile.flipY) ? -1 : 1); + } + + ctx.globalAlpha = alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + -halfWidth, -halfHeight, + tile.width, tile.height + ); + + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = StaticTilemapLayerCanvasRenderer; + + +/***/ }), +/* 445 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * A Static Tilemap Layer renders immediately and does not use any batching. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + var tilesets = src.tileset; + + var pipeline = src.pipeline; + var pipelineVertexBuffer = pipeline.vertexBuffer; + + renderer.setPipeline(pipeline); + + pipeline.modelIdentity(); + pipeline.modelTranslate(src.x - (camera.scrollX * src.scrollFactorX), src.y - (camera.scrollY * src.scrollFactorY), 0); + pipeline.modelScale(src.scaleX, src.scaleY, 1); + pipeline.viewLoad2D(camera.matrix.matrix); + + for (var i = 0; i < tilesets.length; i++) + { + src.upload(camera, i); + + if (src.vertexCount[i] > 0) + { + if (renderer.currentPipeline && renderer.currentPipeline.vertexCount > 0) + { + renderer.flush(); + } + + pipeline.vertexBuffer = src.vertexBuffer[i]; + + renderer.setPipeline(pipeline); + + renderer.setTexture2D(tilesets[i].glTexture, 0); + + renderer.gl.drawArrays(pipeline.topology, 0, src.vertexCount[i]); + } + } + + // Restore the pipeline + pipeline.vertexBuffer = pipelineVertexBuffer; + + pipeline.viewIdentity(); + pipeline.modelIdentity(); +}; + +module.exports = StaticTilemapLayerWebGLRenderer; + + +/***/ }), +/* 446 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(445); +} + +if (true) +{ + renderCanvas = __webpack_require__(444); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 447 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + + if (tileCount === 0) + { + return; + } + + var camMatrix = renderer._tempMatrix1; + var layerMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + var ctx = renderer.currentContext; + var gidMap = src.gidMap; + + ctx.save(); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + layerMatrix.e = src.x; + layerMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(layerMatrix, calcMatrix); + + calcMatrix.copyToContext(ctx); + } + else + { + layerMatrix.e -= camera.scrollX * src.scrollFactorX; + layerMatrix.f -= camera.scrollY * src.scrollFactorY; + + layerMatrix.copyToContext(ctx); + } + + var alpha = camera.alpha * src.alpha; + + for (var i = 0; i < tileCount; i++) + { + var tile = renderTiles[i]; + + var tileset = gidMap[tile.index]; + + if (!tileset) + { + continue; + } + + var image = tileset.image.getSourceImage(); + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords) + { + var halfWidth = tile.width / 2; + var halfHeight = tile.height / 2; + + ctx.save(); + + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale((tile.flipX) ? -1 : 1, (tile.flipY) ? -1 : 1); + } + + ctx.globalAlpha = alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + -halfWidth, -halfHeight, + tile.width, tile.height + ); + + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = DynamicTilemapLayerCanvasRenderer; + + +/***/ }), +/* 448 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) +{ + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + var alpha = camera.alpha * src.alpha; + + if (tileCount === 0 || alpha <= 0) + { + return; + } + + var gidMap = src.gidMap; + var pipeline = src.pipeline; + + var getTint = Utils.getTintAppendFloatAlpha; + + var scrollFactorX = src.scrollFactorX; + var scrollFactorY = src.scrollFactorY; + + var x = src.x; + var y = src.y; + + var sx = src.scaleX; + var sy = src.scaleY; + + var tilesets = src.tileset; + + // Loop through each tileset in this layer, drawing just the tiles that are in that set each time + // Doing it this way around allows us to batch tiles using the same tileset + for (var c = 0; c < tilesets.length; c++) + { + var currentSet = tilesets[c]; + var texture = currentSet.glTexture; + + for (var i = 0; i < tileCount; i++) + { + var tile = renderTiles[i]; + + var tileset = gidMap[tile.index]; + + if (tileset !== currentSet) + { + // Skip tiles that aren't in this set + continue; + } + + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords === null) + { + continue; + } + + var frameWidth = tile.width; + var frameHeight = tile.height; + + var frameX = tileTexCoords.x; + var frameY = tileTexCoords.y; + + var tw = tile.width * 0.5; + var th = tile.height * 0.5; + + var tint = getTint(tile.tint, alpha * tile.alpha); + + pipeline.batchTexture( + src, + texture, + texture.width, texture.height, + (tw + x + tile.pixelX) * sx, (th + y + tile.pixelY) * sy, + tile.width, tile.height, + sx, sy, + tile.rotation, + tile.flipX, tile.flipY, + scrollFactorX, scrollFactorY, + tw, th, + frameX, frameY, frameWidth, frameHeight, + tint, tint, tint, tint, false, + 0, 0, + camera, + null, + true + ); } } }; -module.exports = ReplaceByIndex; +module.exports = DynamicTilemapLayerWebGLRenderer; /***/ }), -/* 323 */ +/* 449 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(448); +} + +if (true) +{ + renderCanvas = __webpack_require__(447); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 450 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(99); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var tilesetsNames = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + // A relative filepath to the source image (within Weltmeister) is used for the name + var tilesetName = layer.tilesetName; + + // Only add unique tilesets that have a valid name. Collision layers will have a blank name. + if (tilesetName !== '' && tilesetsNames.indexOf(tilesetName) === -1) + { + tilesetsNames.push(tilesetName); + + // Tiles are stored with an ID relative to the tileset, rather than a globally unique ID + // across all tilesets. Also, tilesets in Weltmeister have no margin or padding. + tilesets.push(new Tileset(tilesetName, 0, layer.tilesize, layer.tilesize, 0, 0)); + } + } + + return tilesets; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 451 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LayerData = __webpack_require__(78); +var Tile = __webpack_require__(55); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layer.length; i++) + { + var layer = json.layer[i]; + + var layerData = new LayerData({ + name: layer.name, + width: layer.width, + height: layer.height, + tileWidth: layer.tilesize, + tileHeight: layer.tilesize, + visible: layer.visible === 1 + }); + + var row = []; + var tileGrid = []; + + // Loop through the data field in the JSON. This is a 2D array containing the tile indexes, + // one after the other. The indexes are relative to the tileset that contains the tile. + for (var y = 0; y < layer.data.length; y++) + { + for (var x = 0; x < layer.data[y].length; x++) + { + // In Weltmeister, 0 = no tile, but the Tilemap API expects -1 = no tile. + var index = layer.data[y][x] - 1; + + var tile; + + if (index > -1) + { + tile = new Tile(layerData, index, x, y, layer.tilesize, layer.tilesize); + } + else + { + tile = insertNull + ? null + : new Tile(layerData, -1, x, y, layer.tilesize, layer.tilesize); + } + + row.push(tile); + } + + tileGrid.push(row); + row = []; + } + + layerData.data = tileGrid; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 452 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(20); + +/** + * Copy properties from tileset to tiles. + * + * @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + */ +var AssignTileProperties = function (mapData) +{ + var layerData; + var tile; + var sid; + var set; + var row; + + // go through each of the map data layers + for (var i = 0; i < mapData.layers.length; i++) + { + layerData = mapData.layers[i]; + + set = null; + + // rows of tiles + for (var j = 0; j < layerData.data.length; j++) + { + row = layerData.data[j]; + + // individual tiles + for (var k = 0; k < row.length; k++) + { + tile = row[k]; + + if (tile === null || tile.index < 0) + { + continue; + } + + // find the relevant tileset + sid = mapData.tiles[tile.index][2]; + set = mapData.tilesets[sid]; + + // Ensure that a tile's size matches its tileset + tile.width = set.tileWidth; + tile.height = set.tileHeight; + + // if that tile type has any properties, add them to the tile object + if (set.tileProperties && set.tileProperties[tile.index - set.firstgid]) + { + tile.properties = Extend( + tile.properties, set.tileProperties[tile.index - set.firstgid] + ); + } + } + } + } +}; + +module.exports = AssignTileProperties; + + +/***/ }), +/* 453 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Master list of tiles -> x, y, index in tileset. + * + * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.MapData} mapData - [description] + * + * @return {array} [description] + */ +var BuildTilesetIndex = function (mapData) +{ + var tiles = []; + + for (var i = 0; i < mapData.tilesets.length; i++) + { + var set = mapData.tilesets[i]; + + var x = set.tileMargin; + var y = set.tileMargin; + + var count = 0; + var countX = 0; + var countY = 0; + + for (var t = set.firstgid; t < set.firstgid + set.total; t++) + { + // Can add extra properties here as needed + tiles[t] = [ x, y, i ]; + + x += set.tileWidth + set.tileSpacing; + + count++; + + if (count === set.total) + { + break; + } + + countX++; + + if (countX === set.columns) + { + x = set.tileMargin; + y += set.tileHeight + set.tileSpacing; + + countX = 0; + countY++; + + if (countY === set.rows) + { + break; + } + } + } + } + + return tiles; +}; + +module.exports = BuildTilesetIndex; + + +/***/ }), +/* 454 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); +var ParseObject = __webpack_require__(212); +var ObjectLayer = __webpack_require__(211); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseObjectLayers = function (json) +{ + var objectLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'objectgroup') + { + continue; + } + + var curo = json.layers[i]; + var offsetX = GetFastValue(curo, 'offsetx', 0); + var offsetY = GetFastValue(curo, 'offsety', 0); + var objects = []; + + for (var j = 0; j < curo.objects.length; j++) + { + var parsedObject = ParseObject(curo.objects[j], offsetX, offsetY); + + objects.push(parsedObject); + } + + var objectLayer = new ObjectLayer(curo); + objectLayer.objects = objects; + + objectLayers.push(objectLayer); + } + + return objectLayers; +}; + +module.exports = ParseObjectLayers; + + +/***/ }), +/* 455 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasValue = __webpack_require__(85); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.Pick + * @since 3.0.0 + * + * @param {object} object - [description] + * @param {array} keys - [description] + * + * @return {object} [description] + */ +var Pick = function (object, keys) +{ + var obj = {}; + + for (var i = 0; i < keys.length; i++) + { + var key = keys[i]; + + if (HasValue(object, key)) + { + obj[key] = object[key]; + } + } + + return obj; +}; + +module.exports = Pick; + + +/***/ }), +/* 456 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Tileset = __webpack_require__(99); +var ImageCollection = __webpack_require__(213); +var ParseObject = __webpack_require__(212); + +/** + * Tilesets & Image Collections + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {object} [description] + */ +var ParseTilesets = function (json) +{ + var tilesets = []; + var imageCollections = []; + var lastSet = null; + var stringID; + + for (var i = 0; i < json.tilesets.length; i++) + { + // name, firstgid, width, height, margin, spacing, properties + var set = json.tilesets[i]; + + if (set.source) + { + console.warn('Phaser can\'t load external tilesets. Use the Embed Tileset button and then export the map again.'); + } + else if (set.image) + { + var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); + + if (json.version > 1) + { + // Tiled 1.2+ + + if (Array.isArray(set.tiles)) + { + var tiles = {}; + var props = {}; + + for (var t = 0; t < set.tiles.length; t++) + { + var tile = set.tiles[t]; + + // Convert tileproperties + if (tile.properties) + { + var newPropData = {}; + + tile.properties.forEach(function (propData) + { + newPropData[propData['name']] = propData['value']; + }); + + props[tile.id] = newPropData; + } + + // Convert objectgroup + if (tile.objectgroup) + { + tiles[tile.id] = { objectgroup: tile.objectgroup }; + + if (tile.objectgroup.objects) + { + var parsedObjects2 = tile.objectgroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + + tiles[tile.id].objectgroup.objects = parsedObjects2; + } + } + } + + newSet.tileData = tiles; + newSet.tileProperties = props; + } + } + else + { + // Tiled 1 + + // Properties stored per-tile in object with string indexes starting at "0" + if (set.tileproperties) + { + newSet.tileProperties = set.tileproperties; + } + + // Object & terrain shapes stored per-tile in object with string indexes starting at "0" + if (set.tiles) + { + newSet.tileData = set.tiles; + + // Parse the objects into Phaser format to match handling of other Tiled objects + for (stringID in newSet.tileData) + { + var objectGroup = newSet.tileData[stringID].objectgroup; + if (objectGroup && objectGroup.objects) + { + var parsedObjects1 = objectGroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + newSet.tileData[stringID].objectgroup.objects = parsedObjects1; + } + } + } + } + + // For a normal sliced tileset the row/count/size information is computed when updated. + // This is done (again) after the image is set. + newSet.updateTileData(set.imagewidth, set.imageheight); + + tilesets.push(newSet); + } + else + { + var newCollection = new ImageCollection(set.name, set.firstgid, set.tilewidth, + set.tileheight, set.margin, set.spacing, set.properties); + + for (stringID in set.tiles) + { + var image = set.tiles[stringID].image; + var gid = set.firstgid + parseInt(stringID, 10); + newCollection.addImage(gid, image); + } + + imageCollections.push(newCollection); + } + + // We've got a new Tileset, so set the lastgid into the previous one + if (lastSet) + { + lastSet.lastgid = set.firstgid - 1; + } + + lastSet = set; + } + + return { tilesets: tilesets, imageCollections: imageCollections }; +}; + +module.exports = ParseTilesets; + + +/***/ }), +/* 457 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = __webpack_require__(2); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * + * @return {array} [description] + */ +var ParseImageLayers = function (json) +{ + var images = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'imagelayer') + { + continue; + } + + var curi = json.layers[i]; + + images.push({ + name: curi.name, + image: curi.image, + x: GetFastValue(curi, 'offsetx', 0) + curi.x, + y: GetFastValue(curi, 'offsety', 0) + curi.y, + alpha: curi.opacity, + visible: curi.visible, + properties: GetFastValue(curi, 'properties', {}) + }); + } + + return images; +}; + +module.exports = ParseImageLayers; + + +/***/ }), +/* 458 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Decode base-64 encoded data, for example as exported by Tiled. + * + * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode + * @since 3.0.0 + * + * @param {object} data - Base-64 encoded data to decode. + * + * @return {array} Array containing the decoded bytes. + */ +var Base64Decode = function (data) +{ + var binaryString = window.atob(data); + var len = binaryString.length; + var bytes = new Array(len / 4); + + // Interpret binaryString as an array of bytes representing little-endian encoded uint32 values. + for (var i = 0; i < len; i += 4) + { + bytes[i / 4] = ( + binaryString.charCodeAt(i) | + binaryString.charCodeAt(i + 1) << 8 | + binaryString.charCodeAt(i + 2) << 16 | + binaryString.charCodeAt(i + 3) << 24 + ) >>> 0; + } + + return bytes; +}; + +module.exports = Base64Decode; + + +/***/ }), +/* 459 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Base64Decode = __webpack_require__(458); +var GetFastValue = __webpack_require__(2); +var LayerData = __webpack_require__(78); +var ParseGID = __webpack_require__(214); +var Tile = __webpack_require__(55); + +/** + * [description] + * + * @function Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers + * @since 3.0.0 + * + * @param {object} json - [description] + * @param {boolean} insertNull - [description] + * + * @return {array} [description] + */ +var ParseTileLayers = function (json, insertNull) +{ + var tileLayers = []; + + for (var i = 0; i < json.layers.length; i++) + { + if (json.layers[i].type !== 'tilelayer') + { + continue; + } + + var curl = json.layers[i]; + + // Base64 decode data if necessary. NOTE: uncompressed base64 only. + if (curl.compression) + { + console.warn( + 'TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' + + curl.name + '\'' + ); + continue; + } + else if (curl.encoding && curl.encoding === 'base64') + { + curl.data = Base64Decode(curl.data); + delete curl.encoding; // Allow the same map to be parsed multiple times + } + + var layerData = new LayerData({ + name: curl.name, + x: GetFastValue(curl, 'offsetx', 0) + curl.x, + y: GetFastValue(curl, 'offsety', 0) + curl.y, + width: curl.width, + height: curl.height, + tileWidth: json.tilewidth, + tileHeight: json.tileheight, + alpha: curl.opacity, + visible: curl.visible, + properties: GetFastValue(curl, 'properties', {}) + }); + + var x = 0; + var row = []; + var output = []; + + // Loop through the data field in the JSON. + + // This is an array containing the tile indexes, one after the other. -1 = no tile, + // everything else = the tile index (starting at 1 for Tiled, 0 for CSV) If the map + // contains multiple tilesets then the indexes are relative to that which the set starts + // from. Need to set which tileset in the cache = which tileset in the JSON, if you do this + // manually it means you can use the same map data but a new tileset. + + for (var t = 0, len = curl.data.length; t < len; t++) + { + var gidInfo = ParseGID(curl.data[t]); + + // index, x, y, width, height + if (gidInfo.gid > 0) + { + var tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, + json.tileheight); + + // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal + // propeties into flipX, flipY and rotation + tile.rotation = gidInfo.rotation; + tile.flipX = gidInfo.flipped; + + row.push(tile); + } + else + { + var blankTile = insertNull + ? null + : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); + row.push(blankTile); + } + + x++; + + if (x === curl.width) + { + output.push(row); + x = 0; + row = []; + } + } + + layerData.data = output; + + tileLayers.push(layerData); + } + + return tileLayers; +}; + +module.exports = ParseTileLayers; + + +/***/ }), +/* 460 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps.Parsers + */ + +module.exports = { + + Parse: __webpack_require__(217), + Parse2DArray: __webpack_require__(133), + ParseCSV: __webpack_require__(216), + + Impact: __webpack_require__(210), + Tiled: __webpack_require__(215) + +}; + + +/***/ }), +/* 461 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); +var Vector2 = __webpack_require__(3); + +/** + * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.WorldToTileXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in tile units. + */ +var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = WorldToTileX(worldX, snapToFloor, camera, layer); + point.y = WorldToTileY(worldY, snapToFloor, camera, layer); + + return point; +}; + +module.exports = WorldToTileXY; + + +/***/ }), +/* 462 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. New indexes are drawn from the given + * weightedIndexes array. An example weighted array: + * + * [ + * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 + * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 + * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 + * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 + * ] + * + * The probability of any index being choose is (the index's weight) / (sum of all weights). This + * method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.WeightedRandomize + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) +{ + if (weightedIndexes === undefined) { return; } + + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var weightTotal = 0; + for (i = 0; i < weightedIndexes.length; i++) + { + weightTotal += weightedIndexes[i].weight; + } + + if (weightTotal <= 0) { return; } + + for (i = 0; i < tiles.length; i++) + { + var rand = Math.random() * weightTotal; + var sum = 0; + var randomIndex = -1; + for (var j = 0; j < weightedIndexes.length; j++) + { + sum += weightedIndexes[j].weight; + if (rand <= sum) + { + var chosen = weightedIndexes[j].index; + randomIndex = Array.isArray(chosen) + ? chosen[Math.floor(Math.random() * chosen.length)] + : chosen; + break; + } + } + + tiles[i].index = randomIndex; + } +}; + +module.exports = WeightedRandomize; + + +/***/ }), +/* 463 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(101); +var TileToWorldY = __webpack_require__(100); +var Vector2 = __webpack_require__(3); + +/** + * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the + * layer's position, scale and scroll. This will return a new Vector2 object or update the given + * `point` object. + * + * @function Phaser.Tilemaps.Components.TileToWorldXY + * @private + * @since 3.0.0 + * + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Math.Vector2} The XY location in world coordinates. + */ +var TileToWorldXY = function (tileX, tileY, point, camera, layer) +{ + if (point === undefined) { point = new Vector2(0, 0); } + + point.x = TileToWorldX(tileX, camera, layer); + point.y = TileToWorldY(tileY, camera, layer); + + return point; +}; + +module.exports = TileToWorldXY; + + +/***/ }), +/* 464 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching + * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.SwapByIndex + * @private + * @since 3.0.0 + * + * @param {integer} tileA - First tile index. + * @param {integer} tileB - Second tile index. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) + { + if (tiles[i]) + { + if (tiles[i].index === indexA) + { + tiles[i].index = indexB; + } + else if (tiles[i].index === indexB) + { + tiles[i].index = indexA; + } + } + } +}; + +module.exports = SwapByIndex; + + +/***/ }), +/* 465 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var ShuffleArray = __webpack_require__(122); + +/** + * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given + * layer. It will only randomize the tiles in that area, so if they're all the same nothing will + * appear to have changed! This method only modifies tile indexes and does not change collision + * information. + * + * @function Phaser.Tilemaps.Components.Shuffle + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Shuffle = function (tileX, tileY, width, height, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + var indexes = tiles.map(function (tile) { return tile.index; }); + ShuffleArray(indexes); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = indexes[i]; + } +}; + +module.exports = Shuffle; + + +/***/ }), +/* 466 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. + * If a callback is already set for the tile index it will be replaced. Set the callback to null to + * remove it. + * + * @function Phaser.Tilemaps.Components.SetTileLocationCallback + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].setCollisionCallback(callback, callbackContext); + } + +}; + +module.exports = SetTileLocationCallback; + + +/***/ }), +/* 467 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets a global collision callback for the given tile index within the layer. This will affect all + * tiles on this layer that have the same index. If a callback is already set for the tile index it + * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile + * at a specific location on the map then see setTileLocationCallback. + * + * @function Phaser.Tilemaps.Components.SetTileIndexCallback + * @private + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for. + * @param {function} callback - The callback that will be invoked when the tile is collided with. + * @param {object} callbackContext - The context under which the callback is called. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetTileIndexCallback = function (indexes, callback, callbackContext, layer) +{ + if (typeof indexes === 'number') + { + layer.callbacks[indexes] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + else + { + for (var i = 0, len = indexes.length; i < len; i++) + { + layer.callbacks[indexes[i]] = (callback !== null) + ? { callback: callback, callbackContext: callbackContext } + : undefined; + } + } +}; + +module.exports = SetTileIndexCallback; + + +/***/ }), +/* 468 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); + +/** + * Sets collision on the tiles within a layer by checking each tile's collision group data + * (typically defined in Tiled within the tileset collision editor). If any objects are found within + * a tile's collision group, the tile's colliding information will be set. The `collides` parameter + * controls if collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup + * @private + * @since 3.0.0 + * + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + var collisionGroup = tile.getCollisionGroup(); + + // It's possible in Tiled to have a collision group without any shapes, e.g. create a + // shape and then delete the shape. + if (collisionGroup && collisionGroup.objects && collisionGroup.objects.length > 0) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionFromCollisionGroup; + + +/***/ }), +/* 469 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); +var HasValue = __webpack_require__(85); + +/** + * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property + * that matches the given properties object, its collision flag will be set. The `collides` + * parameter controls if collision will be enabled (true) or disabled (false). Passing in + * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that + * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can + * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a + * "types" property that matches any of those values, its collision flag will be updated. + * + * @function Phaser.Tilemaps.Components.SetCollisionByProperty + * @private + * @since 3.0.0 + * + * @param {object} properties - An object with tile properties and corresponding values that should be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (!tile) { continue; } + + for (var property in properties) + { + if (!HasValue(tile.properties, property)) { continue; } + + var values = properties[property]; + if (!Array.isArray(values)) + { + values = [ values ]; + } + + for (var i = 0; i < values.length; i++) + { + if (tile.properties[property] === values[i]) + { + SetTileCollision(tile, collides); + } + } + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionByProperty; + + +/***/ }), +/* 470 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); +var SetLayerCollisionIndex = __webpack_require__(134); + +/** + * Sets collision on all tiles in the given layer, except for tiles that have an index specified in + * the given array. The `collides` parameter controls if collision will be enabled (true) or + * disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionByExclusion + * @private + * @since 3.0.0 + * + * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Note: this only updates layer.collideIndexes for tile indexes found currently in the layer + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile && indexes.indexOf(tile.index) === -1) + { + SetTileCollision(tile, collides); + SetLayerCollisionIndex(tile.index, collides, layer); + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionByExclusion; + + +/***/ }), +/* 471 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); +var SetLayerCollisionIndex = __webpack_require__(134); + +/** + * Sets collision on a range of tiles in a layer whose index is between the specified `start` and + * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set + * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be + * enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollisionBetween + * @private + * @since 3.0.0 + * + * @param {integer} start - The first index of the tile to be set for collision. + * @param {integer} stop - The last index of the tile to be set for collision. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + if (start > stop) { return; } + + // Update the array of colliding indexes + for (var index = start; index <= stop; index++) + { + SetLayerCollisionIndex(index, collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + if (tile) + { + if (tile.index >= start && tile.index <= stop) + { + SetTileCollision(tile, collides); + } + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollisionBetween; + + +/***/ }), +/* 472 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTileCollision = __webpack_require__(56); +var CalculateFacesWithin = __webpack_require__(34); +var SetLayerCollisionIndex = __webpack_require__(134); + +/** + * Sets collision on the given tile or tiles within a layer by index. You can pass in either a + * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if + * collision will be enabled (true) or disabled (false). + * + * @function Phaser.Tilemaps.Components.SetCollision + * @private + * @since 3.0.0 + * + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var SetCollision = function (indexes, collides, recalculateFaces, layer) +{ + if (collides === undefined) { collides = true; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + // Update the array of colliding indexes + for (var i = 0; i < indexes.length; i++) + { + SetLayerCollisionIndex(indexes[i], collides, layer); + } + + // Update the tiles + for (var ty = 0; ty < layer.height; ty++) + { + for (var tx = 0; tx < layer.width; tx++) + { + var tile = layer.data[ty][tx]; + + if (tile && indexes.indexOf(tile.index) !== -1) + { + SetTileCollision(tile, collides); + } + } + } + + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } +}; + +module.exports = SetCollision; + + +/***/ }), +/* 473 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var Color = __webpack_require__(347); + +var defaultTileColor = new Color(105, 210, 231, 150); +var defaultCollidingTileColor = new Color(243, 134, 48, 200); +var defaultFaceColor = new Color(40, 39, 37, 150); + +/** + * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to + * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles + * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation + * wherever you want on the screen. + * + * @function Phaser.Tilemaps.Components.RenderDebug + * @private + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. + * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. + * @param {?Phaser.Display.Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at + * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled + * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Phaser.Display.Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting + * tile faces. If set to null, interesting tile faces will not be drawn. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var RenderDebug = function (graphics, styleConfig, layer) +{ + if (styleConfig === undefined) { styleConfig = {}; } + + // Default colors without needlessly creating Color objects + var tileColor = (styleConfig.tileColor !== undefined) ? styleConfig.tileColor : defaultTileColor; + var collidingTileColor = (styleConfig.collidingTileColor !== undefined) ? styleConfig.collidingTileColor : defaultCollidingTileColor; + var faceColor = (styleConfig.faceColor !== undefined) ? styleConfig.faceColor : defaultFaceColor; + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + + graphics.translate(layer.tilemapLayer.x, layer.tilemapLayer.y); + graphics.scale(layer.tilemapLayer.scaleX, layer.tilemapLayer.scaleY); + + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + var tw = tile.width; + var th = tile.height; + var x = tile.pixelX; + var y = tile.pixelY; + + var color = tile.collides ? collidingTileColor : tileColor; + + if (color !== null) + { + graphics.fillStyle(color.color, color.alpha / 255); + graphics.fillRect(x, y, tw, th); + } + + // Inset the face line to prevent neighboring tile's lines from overlapping + x += 1; + y += 1; + tw -= 2; + th -= 2; + + if (faceColor !== null) + { + graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); + + if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } + if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } + if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } + if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } + } + } +}; + +module.exports = RenderDebug; + + +/***/ }), +/* 474 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RemoveTileAt = __webpack_require__(218); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Removes the tile at the given world coordinates in the specified layer and updates the layer's + * collision information. + * + * @function Phaser.Tilemaps.Components.RemoveTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. + */ +var RemoveTileAtWorldXY = function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); +}; + +module.exports = RemoveTileAtWorldXY; + + +/***/ }), +/* 475 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var GetRandom = __webpack_require__(162); + +/** + * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the + * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then + * those will be used for randomly assigning new tile indexes. If an array is not provided, the + * indexes found within the region (excluding -1) will be used for randomly assigning new tile + * indexes. This method only modifies tile indexes and does not change collision information. + * + * @function Phaser.Tilemaps.Components.Randomize + * @private + * @since 3.0.0 + * + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Randomize = function (tileX, tileY, width, height, indexes, layer) +{ + var i; + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + // If no indicies are given, then find all the unique indexes within the specified region + if (indexes === undefined) + { + indexes = []; + for (i = 0; i < tiles.length; i++) + { + if (indexes.indexOf(tiles[i].index) === -1) + { + indexes.push(tiles[i].index); + } + } + } + + for (i = 0; i < tiles.length; i++) + { + tiles[i].index = GetRandom(indexes); + } +}; + +module.exports = Randomize; + + +/***/ }), +/* 476 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CalculateFacesWithin = __webpack_require__(34); +var PutTileAt = __webpack_require__(135); + +/** + * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified + * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, + * all attributes will be copied over to the specified location. If you pass in an index, only the + * index at the specified location will be changed. Collision information will be recalculated + * within the region tiles were changed. + * + * @function Phaser.Tilemaps.Components.PutTilesAt + * @private + * @since 3.0.0 + * + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) +{ + if (!Array.isArray(tilesArray)) { return null; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + // Force the input array to be a 2D array + if (!Array.isArray(tilesArray[0])) + { + tilesArray = [ tilesArray ]; + } + + var height = tilesArray.length; + var width = tilesArray[0].length; + + for (var ty = 0; ty < height; ty++) + { + for (var tx = 0; tx < width; tx++) + { + var tile = tilesArray[ty][tx]; + PutTileAt(tile, tileX + tx, tileY + ty, false, layer); + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = PutTilesAt; + + + +/***/ }), +/* 477 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PutTileAt = __webpack_require__(135); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either + * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the + * specified location. If you pass in an index, only the index at the specified location will be + * changed. Collision information will be recalculated at the specified location. + * + * @function Phaser.Tilemaps.Components.PutTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. + */ +var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + return PutTileAt(tile, tileX, tileY, recalculateFaces, layer); +}; + +module.exports = PutTileAtWorldXY; + + +/***/ }), +/* 478 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HasTileAt = __webpack_require__(219); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns + * false if there is no tile or if the tile at that location has an index of -1. + * + * @function Phaser.Tilemaps.Components.HasTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The X coordinate of the world position. + * @param {number} worldY - The Y coordinate of the world position. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. + */ +var HasTileAtWorldXY = function (worldX, worldY, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return HasTileAt(tileX, tileY, layer); +}; + +module.exports = HasTileAtWorldXY; + + +/***/ }), +/* 479 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Gets the tiles in the given rectangular area (in world coordinates) of the layer. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer) +{ + // Top left corner of the rect, rounded down to include partial tiles + var xStart = WorldToTileX(worldX, true, camera, layer); + var yStart = WorldToTileY(worldY, true, camera, layer); + + // Bottom right corner of the rect, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer)); + + return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer); +}; + +module.exports = GetTilesWithinWorldXY; + + +/***/ }), +/* 480 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Geom = __webpack_require__(274); +var GetTilesWithin = __webpack_require__(17); +var Intersects = __webpack_require__(273); +var NOOP = __webpack_require__(1); +var TileToWorldX = __webpack_require__(101); +var TileToWorldY = __webpack_require__(100); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +var TriangleToRectangle = function (triangle, rect) +{ + return Intersects.RectangleToTriangle(rect, triangle); +}; + +// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer +// coordinates instead of shifting the tiles. + +/** + * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, + * Line, Rectangle or Triangle. The shape should be in world coordinates. + * + * @function Phaser.Tilemaps.Components.GetTilesWithinShape + * @private + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. + */ +var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) +{ + if (shape === undefined) { return []; } + + // intersectTest is a function with parameters: shape, rect + var intersectTest = NOOP; + if (shape instanceof Geom.Circle) { intersectTest = Intersects.CircleToRectangle; } + else if (shape instanceof Geom.Rectangle) { intersectTest = Intersects.RectangleToRectangle; } + else if (shape instanceof Geom.Triangle) { intersectTest = TriangleToRectangle; } + else if (shape instanceof Geom.Line) { intersectTest = Intersects.LineToRectangle; } + + // Top left corner of the shapes's bounding box, rounded down to include partial tiles + var xStart = WorldToTileX(shape.left, true, camera, layer); + var yStart = WorldToTileY(shape.top, true, camera, layer); + + // Bottom right corner of the shapes's bounding box, rounded up to include partial tiles + var xEnd = Math.ceil(WorldToTileX(shape.right, false, camera, layer)); + var yEnd = Math.ceil(WorldToTileY(shape.bottom, false, camera, layer)); + + // Tiles within bounding rectangle of shape. Bounds are forced to be at least 1 x 1 tile in size + // to grab tiles for shapes that don't have a height or width (e.g. a horizontal line). + var width = Math.max(xEnd - xStart, 1); + var height = Math.max(yEnd - yStart, 1); + var tiles = GetTilesWithin(xStart, yStart, width, height, filteringOptions, layer); + + var tileWidth = layer.tileWidth; + var tileHeight = layer.tileHeight; + if (layer.tilemapLayer) + { + tileWidth *= layer.tilemapLayer.scaleX; + tileHeight *= layer.tilemapLayer.scaleY; + } + + var results = []; + var tileRect = new Geom.Rectangle(0, 0, tileWidth, tileHeight); + for (var i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + tileRect.x = TileToWorldX(tile.x, camera, layer); + tileRect.y = TileToWorldY(tile.y, camera, layer); + if (intersectTest(shape, tileRect)) + { + results.push(tile); + } + } + + return results; +}; + +module.exports = GetTilesWithinShape; + + +/***/ }), +/* 481 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTileAt = __webpack_require__(102); +var WorldToTileX = __webpack_require__(50); +var WorldToTileY = __webpack_require__(49); + +/** + * Gets a tile at the given world coordinates from the given layer. + * + * @function Phaser.Tilemaps.Components.GetTileAtWorldXY + * @private + * @since 3.0.0 + * + * @param {number} worldX - X position to get the tile from (given in pixels) + * @param {number} worldY - Y position to get the tile from (given in pixels) + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates + * were invalid. + */ +var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer) +{ + var tileX = WorldToTileX(worldX, true, camera, layer); + var tileY = WorldToTileY(worldY, true, camera, layer); + + return GetTileAt(tileX, tileY, nonNull, layer); +}; + +module.exports = GetTileAtWorldXY; + + +/***/ }), +/* 482 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * @callback EachTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - The Tile. + * @param {integer} index - The index of the tile. + * @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects. + */ + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * callback. Similar to Array.prototype.forEach in vanilla JS. + * + * @function Phaser.Tilemaps.Components.ForEachTile + * @private + * @since 3.0.0 + * + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + + tiles.forEach(callback, context); +}; + +module.exports = ForEachTile; + + +/***/ }), +/* 483 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * @callback FindTileCallback + * + * @param {Phaser.Tilemaps.Tile} value - The Tile. + * @param {integer} index - The index of the tile. + * @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects. + * + * @return {boolean} Return `true` if the callback should run, otherwise `false`. + */ + +/** + * Find the first tile in the given rectangular area (in tile coordinates) of the layer that + * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns + * true. Similar to Array.prototype.find in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FindTile + * @private + * @since 3.0.0 + * + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found + */ +var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + return tiles.find(callback, context) || null; +}; + +module.exports = FindTile; + + +/***/ }), +/* 484 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Searches the entire map layer for the first tile matching the given index, then returns that Tile + * object. If no match is found, it returns null. The search starts from the top-left tile and + * continues horizontally until it hits the end of the row, then it drops down to the next column. + * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to + * the top-left. + * + * @function Phaser.Tilemaps.Components.FindByIndex + * @private + * @since 3.0.0 + * + * @param {integer} index - The tile index value to search for. + * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the + * bottom-right. Otherwise it scans from the top-left. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {?Phaser.Tilemaps.Tile} The first (or n skipped) tile with the matching index. + */ +var FindByIndex = function (findIndex, skip, reverse, layer) +{ + if (skip === undefined) { skip = 0; } + if (reverse === undefined) { reverse = false; } + + var count = 0; + var tx; + var ty; + var tile; + + if (reverse) + { + for (ty = layer.height - 1; ty >= 0; ty--) + { + for (tx = layer.width - 1; tx >= 0; tx--) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + else + { + for (ty = 0; ty < layer.height; ty++) + { + for (tx = 0; tx < layer.width; tx++) + { + tile = layer.data[ty][tx]; + if (tile && tile.index === findIndex) + { + if (count === skip) + { + return tile; + } + else + { + count += 1; + } + } + } + } + } + + return null; +}; + +module.exports = FindByIndex; + + +/***/ }), +/* 485 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); + +/** + * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given + * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns + * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. + * + * @function Phaser.Tilemaps.Components.FilterTiles + * @private + * @since 3.0.0 + * + * @param {function} callback - The callback. Each tile in the given area will be passed to this + * callback as the first and only parameter. The callback should return true for tiles that pass the + * filter. + * @param {object} [context] - The context under which the callback should be run. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. + */ +var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) +{ + var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + + return tiles.filter(callback, context); +}; + +module.exports = FilterTiles; + + + +/***/ }), +/* 486 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var CalculateFacesWithin = __webpack_require__(34); +var SetTileCollision = __webpack_require__(56); + +/** + * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the + * specified index. Tiles will be set to collide if the given index is a colliding index. + * Collision information in the region will be recalculated. + * + * @function Phaser.Tilemaps.Components.Fill + * @private + * @since 3.0.0 + * + * @param {integer} index - The tile index to fill the area with. + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} recalculateFaces - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The tile layer to use. If not given the current layer is used. + */ +var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) +{ + var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); + + var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + + for (var i = 0; i < tiles.length; i++) + { + tiles[i].index = index; + + SetTileCollision(tiles[i], doesIndexCollide); + } + + if (recalculateFaces) + { + // Recalculate the faces within the area and neighboring tiles + CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Fill; + + +/***/ }), +/* 487 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SnapFloor = __webpack_require__(142); +var SnapCeil = __webpack_require__(243); + +/** + * Returns the tiles in the given layer that are within the camera's viewport. This is used internally. + * + * @function Phaser.Tilemaps.Components.CullTiles + * @private + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. + * @param {array} [outputArray] - An optional array to store the Tile objects within. + * + * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. + */ +var CullTiles = function (layer, camera, outputArray, renderOrder) +{ + if (outputArray === undefined) { outputArray = []; } + if (renderOrder === undefined) { renderOrder = 0; } + + outputArray.length = 0; + + var tilemap = layer.tilemapLayer.tilemap; + var tilemapLayer = layer.tilemapLayer; + + var mapData = layer.data; + var mapWidth = layer.width; + var mapHeight = layer.height; + + // We need to use the tile sizes defined for the map as a whole, not the layer, + // in order to calculate the bounds correctly. As different sized tiles may be + // placed on the grid and we cannot trust layer.baseTileWidth to give us the true size. + var tileW = Math.floor(tilemap.tileWidth * tilemapLayer.scaleX); + var tileH = Math.floor(tilemap.tileHeight * tilemapLayer.scaleY); + + var drawLeft = 0; + var drawRight = mapWidth; + var drawTop = 0; + var drawBottom = mapHeight; + + if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1) + { + // Camera world view bounds, snapped for scaled tile size + // Cull Padding values are given in tiles, not pixels + + var boundsLeft = SnapFloor(camera.worldView.x - tilemapLayer.x, tileW, 0, true) - tilemapLayer.cullPaddingX; + var boundsRight = SnapCeil(camera.worldView.right - tilemapLayer.x, tileW, 0, true) + tilemapLayer.cullPaddingX; + var boundsTop = SnapFloor(camera.worldView.y - tilemapLayer.y, tileH, 0, true) - tilemapLayer.cullPaddingY; + var boundsBottom = SnapCeil(camera.worldView.bottom - tilemapLayer.y, tileH, 0, true) + tilemapLayer.cullPaddingY; + + drawLeft = Math.max(0, boundsLeft); + drawRight = Math.min(mapWidth, boundsRight); + drawTop = Math.max(0, boundsTop); + drawBottom = Math.min(mapHeight, boundsBottom); + } + + var x; + var y; + var tile; + + if (renderOrder === 0) + { + // right-down + + for (y = drawTop; y < drawBottom; y++) + { + for (x = drawLeft; x < drawRight; x++) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 1) + { + // left-down + + for (y = drawTop; y < drawBottom; y++) + { + for (x = drawRight; x >= drawLeft; x--) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 2) + { + // right-up + + for (y = drawBottom; y >= drawTop; y--) + { + for (x = drawLeft; x < drawRight; x++) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 3) + { + // left-up + + for (y = drawBottom; y >= drawTop; y--) + { + for (x = drawRight; x >= drawLeft; x--) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + + tilemapLayer.tilesDrawn = outputArray.length; + tilemapLayer.tilesTotal = mapWidth * mapHeight; + + return outputArray; +}; + +module.exports = CullTiles; + + +/***/ }), +/* 488 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileToWorldX = __webpack_require__(101); +var TileToWorldY = __webpack_require__(100); +var GetTilesWithin = __webpack_require__(17); +var ReplaceByIndex = __webpack_require__(220); + +/** + * Creates a Sprite for every object matching the given tile indexes in the layer. You can + * optionally specify if each tile will be replaced with a new tile after the Sprite has been + * created. This is useful if you want to lay down special tiles in a level that are converted to + * Sprites, but want to replace the tile itself with a floor tile or similar once converted. + * + * @function Phaser.Tilemaps.Components.CreateFromTiles + * @private + * @since 3.0.0 + * + * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite). + * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * + * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. + */ +var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, camera, layer) +{ + if (spriteConfig === undefined) { spriteConfig = {}; } + + if (!Array.isArray(indexes)) { indexes = [ indexes ]; } + + var tilemapLayer = layer.tilemapLayer; + if (scene === undefined) { scene = tilemapLayer.scene; } + if (camera === undefined) { camera = scene.cameras.main; } + + var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + var sprites = []; + var i; + + for (i = 0; i < tiles.length; i++) + { + var tile = tiles[i]; + + if (indexes.indexOf(tile.index) !== -1) + { + spriteConfig.x = TileToWorldX(tile.x, camera, layer); + spriteConfig.y = TileToWorldY(tile.y, camera, layer); + + var sprite = scene.make.sprite(spriteConfig); + sprites.push(sprite); + } + } + + if (typeof replacements === 'number') + { + // Assume 1 replacement for all types of tile given + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); + } + } + else if (Array.isArray(replacements)) + { + // Assume 1 to 1 mapping with indexes array + for (i = 0; i < indexes.length; i++) + { + ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); + } + } + + return sprites; +}; + +module.exports = CreateFromTiles; + + +/***/ }), +/* 489 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetTilesWithin = __webpack_require__(17); +var CalculateFacesWithin = __webpack_require__(34); + +/** + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * @function Phaser.Tilemaps.Components.Copy + * @private + * @since 3.0.0 + * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + */ +var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) +{ + if (srcTileX < 0) { srcTileX = 0; } + if (srcTileY < 0) { srcTileY = 0; } + if (recalculateFaces === undefined) { recalculateFaces = true; } + + var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer); + + var offsetX = destTileX - srcTileX; + var offsetY = destTileY - srcTileY; + + for (var i = 0; i < srcTiles.length; i++) + { + var tileX = srcTiles[i].x + offsetX; + var tileY = srcTiles[i].y + offsetY; + if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height) + { + if (layer.data[tileY][tileX]) + { + layer.data[tileY][tileX].copy(srcTiles[i]); + } + } + } + + if (recalculateFaces) + { + // Recalculate the faces within the destination area and neighboring tiles + CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer); + } +}; + +module.exports = Copy; + + +/***/ }), +/* 490 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Tilemaps + */ + +module.exports = { + + Components: __webpack_require__(103), + Parsers: __webpack_require__(460), + + Formats: __webpack_require__(29), + ImageCollection: __webpack_require__(213), + ParseToTilemap: __webpack_require__(132), + Tile: __webpack_require__(55), + Tilemap: __webpack_require__(209), + TilemapCreator: __webpack_require__(443), + TilemapFactory: __webpack_require__(442), + Tileset: __webpack_require__(99), + + LayerData: __webpack_require__(78), + MapData: __webpack_require__(77), + ObjectLayer: __webpack_require__(211), + + DynamicTilemapLayer: __webpack_require__(208), + StaticTilemapLayer: __webpack_require__(207) + +}; + + +/***/ }), +/* 491 */ /***/ (function(module, exports) { /** @@ -79390,8 +106438,8 @@ module.exports = ReplaceByIndex; * * @name Phaser.Textures.FilterMode * @enum {integer} - * @memberOf Phaser.Textures - * @readOnly + * @memberof Phaser.Textures + * @readonly * @since 3.0.0 */ var CONST = { @@ -79416,7 +106464,7 @@ module.exports = CONST; /***/ }), -/* 324 */ +/* 492 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -79425,8 +106473,8 @@ module.exports = CONST; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Extend = __webpack_require__(17); -var FilterMode = __webpack_require__(323); +var Extend = __webpack_require__(20); +var FilterMode = __webpack_require__(491); /** * @namespace Phaser.Textures @@ -79449,11 +106497,11 @@ var FilterMode = __webpack_require__(323); var Textures = { FilterMode: FilterMode, - Frame: __webpack_require__(128), - Parsers: __webpack_require__(182), - Texture: __webpack_require__(117), - TextureManager: __webpack_require__(184), - TextureSource: __webpack_require__(183) + Frame: __webpack_require__(113), + Parsers: __webpack_require__(316), + Texture: __webpack_require__(165), + TextureManager: __webpack_require__(318), + TextureSource: __webpack_require__(317) }; @@ -79463,7 +106511,7 @@ module.exports = Textures; /***/ }), -/* 325 */ +/* 493 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -79478,17 +106526,17 @@ module.exports = Textures; module.exports = { - List: __webpack_require__(93), - Map: __webpack_require__(124), - ProcessQueue: __webpack_require__(223), - RTree: __webpack_require__(222), - Set: __webpack_require__(70) + List: __webpack_require__(112), + Map: __webpack_require__(180), + ProcessQueue: __webpack_require__(228), + RTree: __webpack_require__(227), + Set: __webpack_require__(95) }; /***/ }), -/* 326 */ +/* 494 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -79529,25 +106577,25 @@ module.exports = { module.exports = { - SoundManagerCreator: __webpack_require__(191), + SoundManagerCreator: __webpack_require__(325), - BaseSound: __webpack_require__(78), - BaseSoundManager: __webpack_require__(79), + BaseSound: __webpack_require__(114), + BaseSoundManager: __webpack_require__(115), - WebAudioSound: __webpack_require__(185), - WebAudioSoundManager: __webpack_require__(186), + WebAudioSound: __webpack_require__(319), + WebAudioSoundManager: __webpack_require__(320), - HTML5AudioSound: __webpack_require__(189), - HTML5AudioSoundManager: __webpack_require__(190), + HTML5AudioSound: __webpack_require__(323), + HTML5AudioSoundManager: __webpack_require__(324), - NoAudioSound: __webpack_require__(187), - NoAudioSoundManager: __webpack_require__(188) + NoAudioSound: __webpack_require__(321), + NoAudioSoundManager: __webpack_require__(322) }; /***/ }), -/* 327 */ +/* 495 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -79558,16 +106606,15 @@ module.exports = { var Clamp = __webpack_require__(23); var Class = __webpack_require__(0); -var CONST = __webpack_require__(55); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); +var GetFastValue = __webpack_require__(2); +var PluginCache = __webpack_require__(15); /** * @classdesc * A proxy class to the Global Scene Manager. * * @class ScenePlugin - * @memberOf Phaser.Scenes + * @memberof Phaser.Scenes * @constructor * @since 3.0.0 * @@ -79629,7 +106676,7 @@ var ScenePlugin = new Class({ * the current percentage of the transition progress, between 0 and 1. * * @name Phaser.Scenes.ScenePlugin#transitionProgress - * @type {float} + * @type {number} * @since 3.5.0 */ this.transitionProgress = 0; @@ -79743,7 +106790,7 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#start * @since 3.0.0 * - * @param {string} key - The Scene to start. + * @param {string} [key] - The Scene to start. * @param {object} [data] - The Scene data. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. @@ -79752,16 +106799,8 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', this.key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(this.key); - this.manager.start(key, data); - } + this.manager.queueOp('stop', this.key); + this.manager.queueOp('start', key, data); return this; }, @@ -79780,16 +106819,8 @@ var ScenePlugin = new Class({ { var key = this.key; - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(key); - this.manager.start(key, data); - } + this.manager.queueOp('stop', key); + this.manager.queueOp('start', key, data); return this; }, @@ -79826,10 +106857,10 @@ var ScenePlugin = new Class({ * 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. + * as the Scenes `init` and `create` methods are not invoked when a Scene 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. + * These events are cleared of all 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 @@ -79940,8 +106971,8 @@ var ScenePlugin = new Class({ * @private * @since 3.5.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ step: function (time, delta) { @@ -80037,14 +107068,7 @@ var ScenePlugin = new Class({ { if (key && key !== this.key) { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('start', key, data); - } - else - { - this.manager.start(key, data); - } + this.manager.queueOp('start', key, data); } return this; @@ -80063,20 +107087,16 @@ var ScenePlugin = new Class({ * @since 3.10.0 * * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param {object} [data] - A data object that will be passed to the Scene and emitted in its ready, wake, or resume events. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ run: function (key, data) { - if (this.settings.status !== CONST.RUNNING) + if (key && key !== this.key) { this.manager.queueOp('run', key, data); } - else - { - this.manager.run(key, data); - } return this; }, @@ -80087,15 +107107,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#pause * @since 3.0.0 * - * @param {string} key - The Scene to pause. + * @param {string} [key] - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its pause event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - pause: function (key) + pause: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.pause(key); + this.manager.queueOp('pause', key, data); return this; }, @@ -80106,15 +107127,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#resume * @since 3.0.0 * - * @param {string} key - The Scene to resume. + * @param {string} [key] - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its resume event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - resume: function (key) + resume: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.resume(key); + this.manager.queueOp('resume', key, data); return this; }, @@ -80125,15 +107147,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#sleep * @since 3.0.0 * - * @param {string} key - The Scene to put to sleep. + * @param {string} [key] - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its sleep event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - sleep: function (key) + sleep: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.sleep(key); + this.manager.queueOp('sleep', key, data); return this; }, @@ -80144,15 +107167,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#wake * @since 3.0.0 * - * @param {string} key - The Scene to wake up. + * @param {string} [key] - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its wake event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - wake: function (key) + wake: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.wake(key); + this.manager.queueOp('wake', key, data); return this; }, @@ -80171,14 +107195,7 @@ var ScenePlugin = new Class({ { if (key !== this.key) { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('switch', this.key, key); - } - else - { - this.manager.switch(this.key, key); - } + this.manager.queueOp('switch', this.key, key); } return this; @@ -80198,7 +107215,7 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - this.manager.stop(key); + this.manager.queueOp('stop', key); return this; }, @@ -80209,12 +107226,13 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#setActive * @since 3.0.0 * - * @param {boolean} value - The active value. - * @param {string} [key] - The Scene to set the active state for. + * @param {boolean} value - If `true` the Scene will be resumed. If `false` it will be paused. + * @param {string} [key] - The Scene to set the active state of. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted with its events. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - setActive: function (value, key) + setActive: function (value, key, data) { if (key === undefined) { key = this.key; } @@ -80222,7 +107240,7 @@ var ScenePlugin = new Class({ if (scene) { - scene.sys.setActive(value); + scene.sys.setActive(value, data); } return this; @@ -80561,7 +107579,7 @@ module.exports = ScenePlugin; /***/ }), -/* 328 */ +/* 496 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -80570,8 +107588,8 @@ module.exports = ScenePlugin; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(55); -var Extend = __webpack_require__(17); +var CONST = __webpack_require__(116); +var Extend = __webpack_require__(20); /** * @namespace Phaser.Scenes @@ -80579,10 +107597,10 @@ var Extend = __webpack_require__(17); var Scene = { - SceneManager: __webpack_require__(194), - ScenePlugin: __webpack_require__(327), - Settings: __webpack_require__(192), - Systems: __webpack_require__(118) + SceneManager: __webpack_require__(329), + ScenePlugin: __webpack_require__(495), + Settings: __webpack_require__(326), + Systems: __webpack_require__(166) }; @@ -80593,7 +107611,7 @@ module.exports = Scene; /***/ }), -/* 329 */ +/* 497 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -80602,7 +107620,7 @@ module.exports = Scene; * @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} */ -var BasePlugin = __webpack_require__(165); +var BasePlugin = __webpack_require__(221); var Class = __webpack_require__(0); /** @@ -80612,7 +107630,7 @@ var Class = __webpack_require__(0); * It can map itself to a Scene property, or into the Scene Systems, or both. * * @class ScenePlugin - * @memberOf Phaser.Plugins + * @memberof Phaser.Plugins * @extends Phaser.Plugins.BasePlugin * @constructor * @since 3.8.0 @@ -80630,26 +107648,7 @@ var ScenePlugin = new Class({ { BasePlugin.call(this, pluginManager); - /** - * A reference to the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * - * @name Phaser.Plugins.ScenePlugin#scene - * @type {?Phaser.Scene} - * @protected - * @since 3.8.0 - */ this.scene = scene; - - /** - * A reference to the Scene Systems of the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * - * @name Phaser.Plugins.ScenePlugin#systems - * @type {?Phaser.Scenes.Systems} - * @protected - * @since 3.8.0 - */ this.systems = scene.sys; scene.sys.events.once('boot', this.boot, this); @@ -80700,7 +107699,7 @@ module.exports = ScenePlugin; /***/ }), -/* 330 */ +/* 498 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -80715,275 +107714,1358 @@ module.exports = ScenePlugin; module.exports = { - BasePlugin: __webpack_require__(165), - DefaultPlugins: __webpack_require__(121), - PluginCache: __webpack_require__(12), - PluginManager: __webpack_require__(196), - ScenePlugin: __webpack_require__(329) + BasePlugin: __webpack_require__(221), + DefaultPlugins: __webpack_require__(167), + PluginCache: __webpack_require__(15), + PluginManager: __webpack_require__(331), + ScenePlugin: __webpack_require__(497) }; /***/ }), -/* 331 */ +/* 499 */ /***/ (function(module, exports, __webpack_require__) { /** -* The `Matter.Sleeping` module contains methods to manage the sleeping state of bodies. +* The `Matter.World` module contains methods for creating and manipulating the world composite. +* A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. +* A `Matter.World` has a few additional properties including `gravity` and `bounds`. +* It is important to use the functions in the `Matter.Composite` module to modify the world composite, rather than directly modifying its properties. +* There are also a few methods here that alias those in `Matter.Composite` for easier readability. * -* @class Sleeping +* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). +* +* @class World +* @extends Composite */ -var Sleeping = {}; +var World = {}; -module.exports = Sleeping; +module.exports = World; -var Events = __webpack_require__(301); +var Composite = __webpack_require__(137); +var Constraint = __webpack_require__(194); +var Common = __webpack_require__(33); (function() { - Sleeping._motionWakeThreshold = 0.18; - Sleeping._motionSleepThreshold = 0.08; - Sleeping._minBias = 0.9; + /** + * Creates a new world composite. The options parameter is an object that specifies any properties you wish to override the defaults. + * See the properties section below for detailed information on what you can pass via the `options` object. + * @method create + * @constructor + * @param {} options + * @return {world} A new world + */ + World.create = function(options) { + var composite = Composite.create(); + + var defaults = { + label: 'World', + gravity: { + x: 0, + y: 1, + scale: 0.001 + }, + bounds: { + min: { x: -Infinity, y: -Infinity }, + max: { x: Infinity, y: Infinity } + } + }; + + return Common.extend(composite, defaults, options); + }; + + /* + * + * Properties Documentation + * + */ /** - * Puts bodies to sleep or wakes them up depending on their motion. - * @method update - * @param {body[]} bodies - * @param {number} timeScale + * The gravity to apply on the world. + * + * @property gravity + * @type object */ - Sleeping.update = function(bodies, timeScale) { - var timeFactor = timeScale * timeScale * timeScale; - // update bodies sleeping status - for (var i = 0; i < bodies.length; i++) { - var body = bodies[i], - motion = body.speed * body.speed + body.angularSpeed * body.angularSpeed; + /** + * The gravity x component. + * + * @property gravity.x + * @type object + * @default 0 + */ - // wake up bodies if they have a force applied - if (body.force.x !== 0 || body.force.y !== 0) { - Sleeping.set(body, false); + /** + * The gravity y component. + * + * @property gravity.y + * @type object + * @default 1 + */ + + /** + * The gravity scale factor. + * + * @property gravity.scale + * @type object + * @default 0.001 + */ + + /** + * A `Bounds` object that defines the world bounds for collision detection. + * + * @property bounds + * @type bounds + * @default { min: { x: -Infinity, y: -Infinity }, max: { x: Infinity, y: Infinity } } + */ + + // World is a Composite body + // see src/module/Outro.js for these aliases: + + /** + * An alias for Composite.add + * @method add + * @param {world} world + * @param {} object + * @return {composite} The original world with the objects added + */ + + /** + * An alias for Composite.remove + * @method remove + * @param {world} world + * @param {} object + * @param {boolean} [deep=false] + * @return {composite} The original world with the objects removed + */ + + /** + * An alias for Composite.clear + * @method clear + * @param {world} world + * @param {boolean} keepStatic + */ + + /** + * An alias for Composite.addComposite + * @method addComposite + * @param {world} world + * @param {composite} composite + * @return {world} The original world with the objects from composite added + */ + + /** + * An alias for Composite.addBody + * @method addBody + * @param {world} world + * @param {body} body + * @return {world} The original world with the body added + */ + + /** + * An alias for Composite.addConstraint + * @method addConstraint + * @param {world} world + * @param {constraint} constraint + * @return {world} The original world with the constraint added + */ + +})(); + + +/***/ }), +/* 500 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Plugin` module contains functions for registering and installing plugins on modules. +* +* @class Plugin +*/ + +var Plugin = {}; + +module.exports = Plugin; + +var Common = __webpack_require__(33); + +(function() { + + Plugin._registry = {}; + + /** + * Registers a plugin object so it can be resolved later by name. + * @method register + * @param plugin {} The plugin to register. + * @return {object} The plugin. + */ + Plugin.register = function(plugin) { + if (!Plugin.isPlugin(plugin)) { + Common.warn('Plugin.register:', Plugin.toString(plugin), 'does not implement all required fields.'); + } + + if (plugin.name in Plugin._registry) { + var registered = Plugin._registry[plugin.name], + pluginVersion = Plugin.versionParse(plugin.version).number, + registeredVersion = Plugin.versionParse(registered.version).number; + + if (pluginVersion > registeredVersion) { + Common.warn('Plugin.register:', Plugin.toString(registered), 'was upgraded to', Plugin.toString(plugin)); + Plugin._registry[plugin.name] = plugin; + } else if (pluginVersion < registeredVersion) { + Common.warn('Plugin.register:', Plugin.toString(registered), 'can not be downgraded to', Plugin.toString(plugin)); + } else if (plugin !== registered) { + Common.warn('Plugin.register:', Plugin.toString(plugin), 'is already registered to different plugin object'); + } + } else { + Plugin._registry[plugin.name] = plugin; + } + + return plugin; + }; + + /** + * Resolves a dependency to a plugin object from the registry if it exists. + * The `dependency` may contain a version, but only the name matters when resolving. + * @method resolve + * @param dependency {string} The dependency. + * @return {object} The plugin if resolved, otherwise `undefined`. + */ + Plugin.resolve = function(dependency) { + return Plugin._registry[Plugin.dependencyParse(dependency).name]; + }; + + /** + * Returns a pretty printed plugin name and version. + * @method toString + * @param plugin {} The plugin. + * @return {string} Pretty printed plugin name and version. + */ + Plugin.toString = function(plugin) { + return typeof plugin === 'string' ? plugin : (plugin.name || 'anonymous') + '@' + (plugin.version || plugin.range || '0.0.0'); + }; + + /** + * Returns `true` if the object meets the minimum standard to be considered a plugin. + * This means it must define the following properties: + * - `name` + * - `version` + * - `install` + * @method isPlugin + * @param obj {} The obj to test. + * @return {boolean} `true` if the object can be considered a plugin otherwise `false`. + */ + Plugin.isPlugin = function(obj) { + return obj && obj.name && obj.version && obj.install; + }; + + /** + * Returns `true` if a plugin with the given `name` been installed on `module`. + * @method isUsed + * @param module {} The module. + * @param name {string} The plugin name. + * @return {boolean} `true` if a plugin with the given `name` been installed on `module`, otherwise `false`. + */ + Plugin.isUsed = function(module, name) { + return module.used.indexOf(name) > -1; + }; + + /** + * Returns `true` if `plugin.for` is applicable to `module` by comparing against `module.name` and `module.version`. + * If `plugin.for` is not specified then it is assumed to be applicable. + * The value of `plugin.for` is a string of the format `'module-name'` or `'module-name@version'`. + * @method isFor + * @param plugin {} The plugin. + * @param module {} The module. + * @return {boolean} `true` if `plugin.for` is applicable to `module`, otherwise `false`. + */ + Plugin.isFor = function(plugin, module) { + var parsed = plugin.for && Plugin.dependencyParse(plugin.for); + return !plugin.for || (module.name === parsed.name && Plugin.versionSatisfies(module.version, parsed.range)); + }; + + /** + * Installs the plugins by calling `plugin.install` on each plugin specified in `plugins` if passed, otherwise `module.uses`. + * For installing plugins on `Matter` see the convenience function `Matter.use`. + * Plugins may be specified either by their name or a reference to the plugin object. + * Plugins themselves may specify further dependencies, but each plugin is installed only once. + * Order is important, a topological sort is performed to find the best resulting order of installation. + * This sorting attempts to satisfy every dependency's requested ordering, but may not be exact in all cases. + * This function logs the resulting status of each dependency in the console, along with any warnings. + * - A green tick ✅ indicates a dependency was resolved and installed. + * - An orange diamond 🔶 indicates a dependency was resolved but a warning was thrown for it or one if its dependencies. + * - A red cross ❌ indicates a dependency could not be resolved. + * Avoid calling this function multiple times on the same module unless you intend to manually control installation order. + * @method use + * @param module {} The module install plugins on. + * @param [plugins=module.uses] {} The plugins to install on module (optional, defaults to `module.uses`). + */ + Plugin.use = function(module, plugins) { + module.uses = (module.uses || []).concat(plugins || []); + + if (module.uses.length === 0) { + Common.warn('Plugin.use:', Plugin.toString(module), 'does not specify any dependencies to install.'); + return; + } + + var dependencies = Plugin.dependencies(module), + sortedDependencies = Common.topologicalSort(dependencies), + status = []; + + for (var i = 0; i < sortedDependencies.length; i += 1) { + if (sortedDependencies[i] === module.name) { continue; } - var minMotion = Math.min(body.motion, motion), - maxMotion = Math.max(body.motion, motion); - - // biased average motion estimation between frames - body.motion = Sleeping._minBias * minMotion + (1 - Sleeping._minBias) * maxMotion; - - if (body.sleepThreshold > 0 && body.motion < Sleeping._motionSleepThreshold * timeFactor) { - body.sleepCounter += 1; - - if (body.sleepCounter >= body.sleepThreshold) - Sleeping.set(body, true); - } else if (body.sleepCounter > 0) { - body.sleepCounter -= 1; + var plugin = Plugin.resolve(sortedDependencies[i]); + + if (!plugin) { + status.push('❌ ' + sortedDependencies[i]); + continue; } + + if (Plugin.isUsed(module, plugin.name)) { + continue; + } + + if (!Plugin.isFor(plugin, module)) { + Common.warn('Plugin.use:', Plugin.toString(plugin), 'is for', plugin.for, 'but installed on', Plugin.toString(module) + '.'); + plugin._warned = true; + } + + if (plugin.install) { + plugin.install(module); + } else { + Common.warn('Plugin.use:', Plugin.toString(plugin), 'does not specify an install function.'); + plugin._warned = true; + } + + if (plugin._warned) { + status.push('🔶 ' + Plugin.toString(plugin)); + delete plugin._warned; + } else { + status.push('✅ ' + Plugin.toString(plugin)); + } + + module.used.push(plugin.name); + } + + if (status.length > 0 && !plugin.silent) { + Common.info(status.join(' ')); } }; /** - * Given a set of colliding pairs, wakes the sleeping bodies involved. - * @method afterCollisions - * @param {pair[]} pairs - * @param {number} timeScale + * Recursively finds all of a module's dependencies and returns a flat dependency graph. + * @method dependencies + * @param module {} The module. + * @return {object} A dependency graph. */ - Sleeping.afterCollisions = function(pairs, timeScale) { - var timeFactor = timeScale * timeScale * timeScale; + Plugin.dependencies = function(module, tracked) { + var parsedBase = Plugin.dependencyParse(module), + name = parsedBase.name; - // wake up bodies involved in collisions - for (var i = 0; i < pairs.length; i++) { - var pair = pairs[i]; + tracked = tracked || {}; + + if (name in tracked) { + return; + } + + module = Plugin.resolve(module) || module; + + tracked[name] = Common.map(module.uses || [], function(dependency) { + if (Plugin.isPlugin(dependency)) { + Plugin.register(dependency); + } + + var parsed = Plugin.dependencyParse(dependency), + resolved = Plugin.resolve(dependency); + + if (resolved && !Plugin.versionSatisfies(resolved.version, parsed.range)) { + Common.warn( + 'Plugin.dependencies:', Plugin.toString(resolved), 'does not satisfy', + Plugin.toString(parsed), 'used by', Plugin.toString(parsedBase) + '.' + ); + + resolved._warned = true; + module._warned = true; + } else if (!resolved) { + Common.warn( + 'Plugin.dependencies:', Plugin.toString(dependency), 'used by', + Plugin.toString(parsedBase), 'could not be resolved.' + ); + + module._warned = true; + } + + return parsed.name; + }); + + for (var i = 0; i < tracked[name].length; i += 1) { + Plugin.dependencies(tracked[name][i], tracked); + } + + return tracked; + }; + + /** + * Parses a dependency string into its components. + * The `dependency` is a string of the format `'module-name'` or `'module-name@version'`. + * See documentation for `Plugin.versionParse` for a description of the format. + * This function can also handle dependencies that are already resolved (e.g. a module object). + * @method dependencyParse + * @param dependency {string} The dependency of the format `'module-name'` or `'module-name@version'`. + * @return {object} The dependency parsed into its components. + */ + Plugin.dependencyParse = function(dependency) { + if (Common.isString(dependency)) { + var pattern = /^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/; + + if (!pattern.test(dependency)) { + Common.warn('Plugin.dependencyParse:', dependency, 'is not a valid dependency string.'); + } + + return { + name: dependency.split('@')[0], + range: dependency.split('@')[1] || '*' + }; + } + + return { + name: dependency.name, + range: dependency.range || dependency.version + }; + }; + + /** + * Parses a version string into its components. + * Versions are strictly of the format `x.y.z` (as in [semver](http://semver.org/)). + * Versions may optionally have a prerelease tag in the format `x.y.z-alpha`. + * Ranges are a strict subset of [npm ranges](https://docs.npmjs.com/misc/semver#advanced-range-syntax). + * Only the following range types are supported: + * - Tilde ranges e.g. `~1.2.3` + * - Caret ranges e.g. `^1.2.3` + * - Exact version e.g. `1.2.3` + * - Any version `*` + * @method versionParse + * @param range {string} The version string. + * @return {object} The version range parsed into its components. + */ + Plugin.versionParse = function(range) { + var pattern = /^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/; + + if (!pattern.test(range)) { + Common.warn('Plugin.versionParse:', range, 'is not a valid version or range.'); + } + + var identifiers = range.split('-'); + range = identifiers[0]; + + var isRange = isNaN(Number(range[0])), + version = isRange ? range.substr(1) : range, + parts = Common.map(version.split('.'), function(part) { + return Number(part); + }); + + return { + isRange: isRange, + version: version, + range: range, + operator: isRange ? range[0] : '', + parts: parts, + prerelease: identifiers[1], + number: parts[0] * 1e8 + parts[1] * 1e4 + parts[2] + }; + }; + + /** + * Returns `true` if `version` satisfies the given `range`. + * See documentation for `Plugin.versionParse` for a description of the format. + * If a version or range is not specified, then any version (`*`) is assumed to satisfy. + * @method versionSatisfies + * @param version {string} The version string. + * @param range {string} The range string. + * @return {boolean} `true` if `version` satisfies `range`, otherwise `false`. + */ + Plugin.versionSatisfies = function(version, range) { + range = range || '*'; + + var rangeParsed = Plugin.versionParse(range), + rangeParts = rangeParsed.parts, + versionParsed = Plugin.versionParse(version), + versionParts = versionParsed.parts; + + if (rangeParsed.isRange) { + if (rangeParsed.operator === '*' || version === '*') { + return true; + } + + if (rangeParsed.operator === '~') { + return versionParts[0] === rangeParts[0] && versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; + } + + if (rangeParsed.operator === '^') { + if (rangeParts[0] > 0) { + return versionParts[0] === rangeParts[0] && versionParsed.number >= rangeParsed.number; + } + + if (rangeParts[1] > 0) { + return versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; + } + + return versionParts[2] === rangeParts[2]; + } + } + + return version === range || version === '*'; + }; + +})(); + + +/***/ }), +/* 501 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Matter = __webpack_require__(1065); + +Matter.Body = __webpack_require__(67); +Matter.Composite = __webpack_require__(137); +Matter.World = __webpack_require__(499); + +Matter.Detector = __webpack_require__(503); +Matter.Grid = __webpack_require__(1064); +Matter.Pairs = __webpack_require__(1063); +Matter.Pair = __webpack_require__(418); +Matter.Query = __webpack_require__(1089); +Matter.Resolver = __webpack_require__(1062); +Matter.SAT = __webpack_require__(502); + +Matter.Constraint = __webpack_require__(194); + +Matter.Common = __webpack_require__(33); +Matter.Engine = __webpack_require__(1061); +Matter.Events = __webpack_require__(195); +Matter.Sleeping = __webpack_require__(222); +Matter.Plugin = __webpack_require__(500); + +Matter.Bodies = __webpack_require__(126); +Matter.Composites = __webpack_require__(1068); + +Matter.Axes = __webpack_require__(505); +Matter.Bounds = __webpack_require__(80); +Matter.Svg = __webpack_require__(1087); +Matter.Vector = __webpack_require__(81); +Matter.Vertices = __webpack_require__(76); + +// aliases + +Matter.World.add = Matter.Composite.add; +Matter.World.remove = Matter.Composite.remove; +Matter.World.addComposite = Matter.Composite.addComposite; +Matter.World.addBody = Matter.Composite.addBody; +Matter.World.addConstraint = Matter.Composite.addConstraint; +Matter.World.clear = Matter.Composite.clear; + +module.exports = Matter; + + +/***/ }), +/* 502 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.SAT` module contains methods for detecting collisions using the Separating Axis Theorem. +* +* @class SAT +*/ + +// TODO: true circles and curves + +var SAT = {}; + +module.exports = SAT; + +var Vertices = __webpack_require__(76); +var Vector = __webpack_require__(81); + +(function() { + + /** + * Detect collision between two bodies using the Separating Axis Theorem. + * @method collides + * @param {body} bodyA + * @param {body} bodyB + * @param {collision} previousCollision + * @return {collision} collision + */ + SAT.collides = function(bodyA, bodyB, previousCollision) { + var overlapAB, + overlapBA, + minOverlap, + collision, + canReusePrevCol = false; + + if (previousCollision) { + // estimate total motion + var parentA = bodyA.parent, + parentB = bodyB.parent, + motion = parentA.speed * parentA.speed + parentA.angularSpeed * parentA.angularSpeed + + parentB.speed * parentB.speed + parentB.angularSpeed * parentB.angularSpeed; + + // we may be able to (partially) reuse collision result + // but only safe if collision was resting + canReusePrevCol = previousCollision && previousCollision.collided && motion < 0.2; + + // reuse collision object + collision = previousCollision; + } else { + collision = { collided: false, bodyA: bodyA, bodyB: bodyB }; + } + + if (previousCollision && canReusePrevCol) { + // if we can reuse the collision result + // we only need to test the previously found axis + var axisBodyA = collision.axisBody, + axisBodyB = axisBodyA === bodyA ? bodyB : bodyA, + axes = [axisBodyA.axes[previousCollision.axisNumber]]; + + minOverlap = SAT._overlapAxes(axisBodyA.vertices, axisBodyB.vertices, axes); + collision.reused = true; + + if (minOverlap.overlap <= 0) { + collision.collided = false; + return collision; + } + } else { + // if we can't reuse a result, perform a full SAT test + + overlapAB = SAT._overlapAxes(bodyA.vertices, bodyB.vertices, bodyA.axes); + + if (overlapAB.overlap <= 0) { + collision.collided = false; + return collision; + } + + overlapBA = SAT._overlapAxes(bodyB.vertices, bodyA.vertices, bodyB.axes); + + if (overlapBA.overlap <= 0) { + collision.collided = false; + return collision; + } + + if (overlapAB.overlap < overlapBA.overlap) { + minOverlap = overlapAB; + collision.axisBody = bodyA; + } else { + minOverlap = overlapBA; + collision.axisBody = bodyB; + } + + // important for reuse later + collision.axisNumber = minOverlap.axisNumber; + } + + collision.bodyA = bodyA.id < bodyB.id ? bodyA : bodyB; + collision.bodyB = bodyA.id < bodyB.id ? bodyB : bodyA; + collision.collided = true; + collision.depth = minOverlap.overlap; + collision.parentA = collision.bodyA.parent; + collision.parentB = collision.bodyB.parent; + + bodyA = collision.bodyA; + bodyB = collision.bodyB; + + // ensure normal is facing away from bodyA + if (Vector.dot(minOverlap.axis, Vector.sub(bodyB.position, bodyA.position)) < 0) { + collision.normal = { + x: minOverlap.axis.x, + y: minOverlap.axis.y + }; + } else { + collision.normal = { + x: -minOverlap.axis.x, + y: -minOverlap.axis.y + }; + } + + collision.tangent = Vector.perp(collision.normal); + + collision.penetration = collision.penetration || {}; + collision.penetration.x = collision.normal.x * collision.depth; + collision.penetration.y = collision.normal.y * collision.depth; + + // find support points, there is always either exactly one or two + var verticesB = SAT._findSupports(bodyA, bodyB, collision.normal), + supports = []; + + // find the supports from bodyB that are inside bodyA + if (Vertices.contains(bodyA.vertices, verticesB[0])) + supports.push(verticesB[0]); + + if (Vertices.contains(bodyA.vertices, verticesB[1])) + supports.push(verticesB[1]); + + // find the supports from bodyA that are inside bodyB + if (supports.length < 2) { + var verticesA = SAT._findSupports(bodyB, bodyA, Vector.neg(collision.normal)); + + if (Vertices.contains(bodyB.vertices, verticesA[0])) + supports.push(verticesA[0]); + + if (supports.length < 2 && Vertices.contains(bodyB.vertices, verticesA[1])) + supports.push(verticesA[1]); + } + + // account for the edge case of overlapping but no vertex containment + if (supports.length < 1) + supports = [verticesB[0]]; + + collision.supports = supports; + + return collision; + }; + + /** + * Find the overlap between two sets of vertices. + * @method _overlapAxes + * @private + * @param {} verticesA + * @param {} verticesB + * @param {} axes + * @return result + */ + SAT._overlapAxes = function(verticesA, verticesB, axes) { + var projectionA = Vector._temp[0], + projectionB = Vector._temp[1], + result = { overlap: Number.MAX_VALUE }, + overlap, + axis; + + for (var i = 0; i < axes.length; i++) { + axis = axes[i]; + + SAT._projectToAxis(projectionA, verticesA, axis); + SAT._projectToAxis(projectionB, verticesB, axis); + + overlap = Math.min(projectionA.max - projectionB.min, projectionB.max - projectionA.min); + + if (overlap <= 0) { + result.overlap = overlap; + return result; + } + + if (overlap < result.overlap) { + result.overlap = overlap; + result.axis = axis; + result.axisNumber = i; + } + } + + return result; + }; + + /** + * Projects vertices on an axis and returns an interval. + * @method _projectToAxis + * @private + * @param {} projection + * @param {} vertices + * @param {} axis + */ + SAT._projectToAxis = function(projection, vertices, axis) { + var min = Vector.dot(vertices[0], axis), + max = min; + + for (var i = 1; i < vertices.length; i += 1) { + var dot = Vector.dot(vertices[i], axis); + + if (dot > max) { + max = dot; + } else if (dot < min) { + min = dot; + } + } + + projection.min = min; + projection.max = max; + }; + + /** + * Finds supporting vertices given two bodies along a given direction using hill-climbing. + * @method _findSupports + * @private + * @param {} bodyA + * @param {} bodyB + * @param {} normal + * @return [vector] + */ + SAT._findSupports = function(bodyA, bodyB, normal) { + var nearestDistance = Number.MAX_VALUE, + vertexToBody = Vector._temp[0], + vertices = bodyB.vertices, + bodyAPosition = bodyA.position, + distance, + vertex, + vertexA, + vertexB; + + // find closest vertex on bodyB + for (var i = 0; i < vertices.length; i++) { + vertex = vertices[i]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + distance = -Vector.dot(normal, vertexToBody); + + if (distance < nearestDistance) { + nearestDistance = distance; + vertexA = vertex; + } + } + + // find next closest vertex using the two connected to it + var prevIndex = vertexA.index - 1 >= 0 ? vertexA.index - 1 : vertices.length - 1; + vertex = vertices[prevIndex]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + nearestDistance = -Vector.dot(normal, vertexToBody); + vertexB = vertex; + + var nextIndex = (vertexA.index + 1) % vertices.length; + vertex = vertices[nextIndex]; + vertexToBody.x = vertex.x - bodyAPosition.x; + vertexToBody.y = vertex.y - bodyAPosition.y; + distance = -Vector.dot(normal, vertexToBody); + if (distance < nearestDistance) { + vertexB = vertex; + } + + return [vertexA, vertexB]; + }; + +})(); + + +/***/ }), +/* 503 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Detector` module contains methods for detecting collisions given a set of pairs. +* +* @class Detector +*/ + +// TODO: speculative contacts + +var Detector = {}; + +module.exports = Detector; + +var SAT = __webpack_require__(502); +var Pair = __webpack_require__(418); +var Bounds = __webpack_require__(80); + +(function() { + + /** + * Finds all collisions given a list of pairs. + * @method collisions + * @param {pair[]} broadphasePairs + * @param {engine} engine + * @return {array} collisions + */ + Detector.collisions = function(broadphasePairs, engine) { + var collisions = [], + pairsTable = engine.pairs.table; + + // @if DEBUG + var metrics = engine.metrics; + // @endif + + for (var i = 0; i < broadphasePairs.length; i++) { + var bodyA = broadphasePairs[i][0], + bodyB = broadphasePairs[i][1]; + + if ((bodyA.isStatic || bodyA.isSleeping) && (bodyB.isStatic || bodyB.isSleeping)) + continue; - // don't wake inactive pairs - if (!pair.isActive) + if (!Detector.canCollide(bodyA.collisionFilter, bodyB.collisionFilter)) continue; - var collision = pair.collision, - bodyA = collision.bodyA.parent, - bodyB = collision.bodyB.parent; - - // don't wake if at least one body is static - if ((bodyA.isSleeping && bodyB.isSleeping) || bodyA.isStatic || bodyB.isStatic) - continue; - - if (bodyA.isSleeping || bodyB.isSleeping) { - var sleepingBody = (bodyA.isSleeping && !bodyA.isStatic) ? bodyA : bodyB, - movingBody = sleepingBody === bodyA ? bodyB : bodyA; + // @if DEBUG + metrics.midphaseTests += 1; + // @endif - if (!sleepingBody.isStatic && movingBody.motion > Sleeping._motionWakeThreshold * timeFactor) { - Sleeping.set(sleepingBody, false); + // mid phase + if (Bounds.overlaps(bodyA.bounds, bodyB.bounds)) { + for (var j = bodyA.parts.length > 1 ? 1 : 0; j < bodyA.parts.length; j++) { + var partA = bodyA.parts[j]; + + for (var k = bodyB.parts.length > 1 ? 1 : 0; k < bodyB.parts.length; k++) { + var partB = bodyB.parts[k]; + + if ((partA === bodyA && partB === bodyB) || Bounds.overlaps(partA.bounds, partB.bounds)) { + // find a previous collision we could reuse + var pairId = Pair.id(partA, partB), + pair = pairsTable[pairId], + previousCollision; + + if (pair && pair.isActive) { + previousCollision = pair.collision; + } else { + previousCollision = null; + } + + // narrow phase + var collision = SAT.collides(partA, partB, previousCollision); + + // @if DEBUG + metrics.narrowphaseTests += 1; + if (collision.reused) + metrics.narrowReuseCount += 1; + // @endif + + if (collision.collided) { + collisions.push(collision); + // @if DEBUG + metrics.narrowDetections += 1; + // @endif + } + } + } } } } + + return collisions; }; - + /** - * Set a body as sleeping or awake. - * @method set - * @param {body} body - * @param {boolean} isSleeping + * Returns `true` if both supplied collision filters will allow a collision to occur. + * See `body.collisionFilter` for more information. + * @method canCollide + * @param {} filterA + * @param {} filterB + * @return {bool} `true` if collision can occur */ - Sleeping.set = function(body, isSleeping) { - var wasSleeping = body.isSleeping; + Detector.canCollide = function(filterA, filterB) { + if (filterA.group === filterB.group && filterA.group !== 0) + return filterA.group > 0; - if (isSleeping) { - body.isSleeping = true; - body.sleepCounter = body.sleepThreshold; + return (filterA.mask & filterB.category) !== 0 && (filterB.mask & filterA.category) !== 0; + }; - body.positionImpulse.x = 0; - body.positionImpulse.y = 0; +})(); - body.positionPrev.x = body.position.x; - body.positionPrev.y = body.position.y; - body.anglePrev = body.angle; - body.speed = 0; - body.angularSpeed = 0; - body.motion = 0; +/***/ }), +/* 504 */ +/***/ (function(module, exports, __webpack_require__) { - if (!wasSleeping) { - Events.trigger(body, 'sleepStart'); +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bodies = __webpack_require__(126); +var Body = __webpack_require__(67); +var Class = __webpack_require__(0); +var Components = __webpack_require__(419); +var GetFastValue = __webpack_require__(2); +var HasValue = __webpack_require__(85); +var Vertices = __webpack_require__(76); + +/** + * @classdesc + * A wrapper around a Tile that provides access to a corresponding Matter body. A tile can only + * have one Matter body associated with it. You can either pass in an existing Matter body for + * the tile or allow the constructor to create the corresponding body for you. If the Tile has a + * collision group (defined in Tiled), those shapes will be used to create the body. If not, the + * tile's rectangle bounding box will be used. + * + * The corresponding body will be accessible on the Tile itself via Tile.physics.matterBody. + * + * Note: not all Tiled collision shapes are supported. See + * Phaser.Physics.Matter.TileBody#setFromTileCollision for more information. + * + * @class TileBody + * @memberof Phaser.Physics.Matter + * @constructor + * @since 3.0.0 + * + * @extends Phaser.Physics.Matter.Components.Bounce + * @extends Phaser.Physics.Matter.Components.Collision + * @extends Phaser.Physics.Matter.Components.Friction + * @extends Phaser.Physics.Matter.Components.Gravity + * @extends Phaser.Physics.Matter.Components.Mass + * @extends Phaser.Physics.Matter.Components.Sensor + * @extends Phaser.Physics.Matter.Components.Sleep + * @extends Phaser.Physics.Matter.Components.Static + * + * @param {Phaser.Physics.Matter.World} world - [description] + * @param {Phaser.Tilemaps.Tile} tile - The target tile that should have a Matter body. + * @param {object} [options] - Options to be used when creating the Matter body. See + * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. + * @param {Phaser.Physics.Matter.Matter.Body} [options.body=null] - An existing Matter body to + * be used instead of creating a new one. + * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be + * made static. This defaults to true since typically tiles should not be moved. + * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or + * existing body if options.body is used) to the Matter world. + */ +var MatterTileBody = new Class({ + + Mixins: [ + Components.Bounce, + Components.Collision, + Components.Friction, + Components.Gravity, + Components.Mass, + Components.Sensor, + Components.Sleep, + Components.Static + ], + + initialize: + + function MatterTileBody (world, tile, options) + { + /** + * The tile object the body is associated with. + * + * @name Phaser.Physics.Matter.TileBody#tile + * @type {Phaser.Tilemaps.Tile} + * @since 3.0.0 + */ + this.tile = tile; + + /** + * The Matter world the body exists within. + * + * @name Phaser.Physics.Matter.TileBody#world + * @type {Phaser.Physics.Matter.World} + * @since 3.0.0 + */ + this.world = world; + + // Install a reference to 'this' on the tile and ensure there can only be one matter body + // associated with the tile + if (tile.physics.matterBody) + { + tile.physics.matterBody.destroy(); + } + + tile.physics.matterBody = this; + + // Set the body either from an existing body (if provided), the shapes in the tileset + // collision layer (if it exists) or a rectangle matching the tile. + var body = GetFastValue(options, 'body', null); + + var addToWorld = GetFastValue(options, 'addToWorld', true); + + if (!body) + { + var collisionGroup = tile.getCollisionGroup(); + var collisionObjects = GetFastValue(collisionGroup, 'objects', []); + + if (collisionObjects.length > 0) + { + this.setFromTileCollision(options); } - } else { - body.isSleeping = false; - body.sleepCounter = 0; - - if (wasSleeping) { - Events.trigger(body, 'sleepEnd'); + else + { + this.setFromTileRectangle(options); } } + else + { + this.setBody(body, addToWorld); + } + }, + + /** + * Sets the current body to a rectangle that matches the bounds of the tile. + * + * @method Phaser.Physics.Matter.TileBody#setFromTileRectangle + * @since 3.0.0 + * + * @param {object} [options] - Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. + * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be + * made static. This defaults to true since typically tiles should not be moved. + * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or + * existing body if options.body is used) to the Matter world. + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + setFromTileRectangle: function (options) + { + if (options === undefined) { options = {}; } + if (!HasValue(options, 'isStatic')) { options.isStatic = true; } + if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } + + var bounds = this.tile.getBounds(); + var cx = bounds.x + (bounds.width / 2); + var cy = bounds.y + (bounds.height / 2); + var body = Bodies.rectangle(cx, cy, bounds.width, bounds.height, options); + + this.setBody(body, options.addToWorld); + + return this; + }, + + /** + * Sets the current body from the collision group associated with the Tile. This is typically + * set up in Tiled's collision editor. + * + * Note: Matter doesn't support all shapes from Tiled. Rectangles and polygons are directly + * supported. Ellipses are converted into circle bodies. Polylines are treated as if they are + * closed polygons. If a tile has multiple shapes, a multi-part body will be created. Concave + * shapes are supported if poly-decomp library is included. Decomposition is not guaranteed to + * work for complex shapes (e.g. holes), so it's often best to manually decompose a concave + * polygon into multiple convex polygons yourself. + * + * @method Phaser.Physics.Matter.TileBody#setFromTileCollision + * @since 3.0.0 + * + * @param {object} [options] - Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. + * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be + * made static. This defaults to true since typically tiles should not be moved. + * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or + * existing body if options.body is used) to the Matter world. + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + setFromTileCollision: function (options) + { + if (options === undefined) { options = {}; } + if (!HasValue(options, 'isStatic')) { options.isStatic = true; } + if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } + + var sx = this.tile.tilemapLayer.scaleX; + var sy = this.tile.tilemapLayer.scaleY; + var tileX = this.tile.getLeft(); + var tileY = this.tile.getTop(); + var collisionGroup = this.tile.getCollisionGroup(); + var collisionObjects = GetFastValue(collisionGroup, 'objects', []); + + var parts = []; + + for (var i = 0; i < collisionObjects.length; i++) + { + var object = collisionObjects[i]; + var ox = tileX + (object.x * sx); + var oy = tileY + (object.y * sy); + var ow = object.width * sx; + var oh = object.height * sy; + var body = null; + + if (object.rectangle) + { + body = Bodies.rectangle(ox + ow / 2, oy + oh / 2, ow, oh, options); + } + else if (object.ellipse) + { + body = Bodies.circle(ox + ow / 2, oy + oh / 2, ow / 2, options); + } + else if (object.polygon || object.polyline) + { + // Polygons and polylines are both treated as closed polygons + var originalPoints = object.polygon ? object.polygon : object.polyline; + + var points = originalPoints.map(function (p) + { + return { x: p.x * sx, y: p.y * sy }; + }); + + var vertices = Vertices.create(points); + + // Points are relative to the object's origin (first point placed in Tiled), but + // matter expects points to be relative to the center of mass. This only applies to + // convex shapes. When a concave shape is decomposed, multiple parts are created and + // the individual parts are positioned relative to (ox, oy). + if (Vertices.isConvex(points)) + { + var center = Vertices.centre(vertices); + ox += center.x; + oy += center.y; + } + + body = Bodies.fromVertices(ox, oy, vertices, options); + } + + if (body) + { + parts.push(body); + } + } + + if (parts.length === 1) + { + this.setBody(parts[0], options.addToWorld); + } + else if (parts.length > 1) + { + options.parts = parts; + this.setBody(Body.create(options), options.addToWorld); + } + + return this; + }, + + /** + * Sets the current body to the given body. This will remove the previous body, if one already + * exists. + * + * @method Phaser.Physics.Matter.TileBody#setBody + * @since 3.0.0 + * + * @param {MatterJS.Body} body - The new Matter body to use. + * @param {boolean} [addToWorld=true] - Whether or not to add the body to the Matter world. + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + setBody: function (body, addToWorld) + { + if (addToWorld === undefined) { addToWorld = true; } + + if (this.body) + { + this.removeBody(); + } + + this.body = body; + this.body.gameObject = this; + + if (addToWorld) + { + this.world.add(this.body); + } + + return this; + }, + + /** + * Removes the current body from the TileBody and from the Matter world + * + * @method Phaser.Physics.Matter.TileBody#removeBody + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + removeBody: function () + { + if (this.body) + { + this.world.remove(this.body); + this.body.gameObject = undefined; + this.body = undefined; + } + + return this; + }, + + /** + * Removes the current body from the tile and the world. + * + * @method Phaser.Physics.Matter.TileBody#destroy + * @since 3.0.0 + * + * @return {Phaser.Physics.Matter.TileBody} This TileBody object. + */ + destroy: function () + { + this.removeBody(); + this.tile.physics.matterBody = undefined; + } + +}); + +module.exports = MatterTileBody; + + +/***/ }), +/* 505 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* The `Matter.Axes` module contains methods for creating and manipulating sets of axes. +* +* @class Axes +*/ + +var Axes = {}; + +module.exports = Axes; + +var Vector = __webpack_require__(81); +var Common = __webpack_require__(33); + +(function() { + + /** + * Creates a new set of axes from the given vertices. + * @method fromVertices + * @param {vertices} vertices + * @return {axes} A new axes from the given vertices + */ + Axes.fromVertices = function(vertices) { + var axes = {}; + + // find the unique axes, using edge normal gradients + for (var i = 0; i < vertices.length; i++) { + var j = (i + 1) % vertices.length, + normal = Vector.normalise({ + x: vertices[j].y - vertices[i].y, + y: vertices[i].x - vertices[j].x + }), + gradient = (normal.y === 0) ? Infinity : (normal.x / normal.y); + + // limit precision + gradient = gradient.toFixed(3).toString(); + axes[gradient] = normal; + } + + return Common.values(axes); + }; + + /** + * Rotates a set of axes by the given angle. + * @method rotate + * @param {axes} axes + * @param {number} angle + */ + Axes.rotate = function(axes, angle) { + if (angle === 0) + return; + + var cos = Math.cos(angle), + sin = Math.sin(angle); + + for (var i = 0; i < axes.length; i++) { + var axis = axes[i], + xx; + xx = axis.x * cos - axis.y * sin; + axis.y = axis.x * sin + axis.y * cos; + axis.x = xx; + } }; })(); /***/ }), -/* 332 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Collision Types - Determine if and how entities collide with each other. - * - * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, - * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE - * collisions, both entities are moved. LITE or PASSIVE entities don't collide - * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. - * FIXED collisions is undefined. - * - * @name Phaser.Physics.Impact.TYPE - * @enum {integer} - * @memberOf Phaser.Physics.Impact - * @readOnly - * @since 3.0.0 - */ -module.exports = { - - /** - * Collides with nothing. - * - * @name Phaser.Physics.Impact.TYPE.NONE - */ - NONE: 0, - - /** - * Type A. Collides with Type B. - * - * @name Phaser.Physics.Impact.TYPE.A - */ - A: 1, - - /** - * Type B. Collides with Type A. - * - * @name Phaser.Physics.Impact.TYPE.B - */ - B: 2, - - /** - * Collides with both types A and B. - * - * @name Phaser.Physics.Impact.TYPE.BOTH - */ - BOTH: 3 - -}; - - -/***/ }), -/* 333 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Collision Types - Determine if and how entities collide with each other. - * - * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, - * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE - * collisions, both entities are moved. LITE or PASSIVE entities don't collide - * with other LITE or PASSIVE entities at all. The behavior for FIXED vs. - * FIXED collisions is undefined. - * - * @name Phaser.Physics.Impact.COLLIDES - * @enum {integer} - * @memberOf Phaser.Physics.Impact - * @readOnly - * @since 3.0.0 - */ -module.exports = { - - /** - * Never collides. - * - * @name Phaser.Physics.Impact.COLLIDES.NEVER - */ - NEVER: 0, - - /** - * Lite collision. - * - * @name Phaser.Physics.Impact.COLLIDES.LITE - */ - LITE: 1, - - /** - * Passive collision. - * - * @name Phaser.Physics.Impact.COLLIDES.PASSIVE - */ - PASSIVE: 2, - - /** - * Active collision. - * - * @name Phaser.Physics.Impact.COLLIDES.ACTIVE - */ - ACTIVE: 4, - - /** - * Fixed collision. - * - * @name Phaser.Physics.Impact.COLLIDES.FIXED - */ - FIXED: 8 - -}; - - -/***/ }), -/* 334 */ +/* 506 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -80992,913 +109074,817 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var RectangleContains = __webpack_require__(31); -var Vector2 = __webpack_require__(6); +/** + * @namespace Phaser.Physics.Impact.Components + */ + +module.exports = { + + Acceleration: __webpack_require__(1121), + BodyScale: __webpack_require__(1120), + BodyType: __webpack_require__(1119), + Bounce: __webpack_require__(1118), + CheckAgainst: __webpack_require__(1117), + Collides: __webpack_require__(1116), + Debug: __webpack_require__(1115), + Friction: __webpack_require__(1114), + Gravity: __webpack_require__(1113), + Offset: __webpack_require__(1112), + SetGameObject: __webpack_require__(1111), + Velocity: __webpack_require__(1110) + +}; + + +/***/ }), +/* 507 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetOverlapY = __webpack_require__(229); /** - * @classdesc * [description] * - * @class StaticBody - * @memberOf Phaser.Physics.Arcade - * @constructor + * @function Phaser.Physics.Arcade.SeparateY * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] */ -var StaticBody = new Class({ +var SeparateY = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapY(body1, body2, overlapOnly, bias); - initialize: - - function StaticBody (world, gameObject) + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateY || body2.customSeparateY) { - var width = (gameObject.width) ? gameObject.width : 64; - var height = (gameObject.height) ? gameObject.height : 64; + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); + } - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.y; + var v2 = body2.velocity.y; - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = gameObject; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowBody = world.defaults.debugShowStaticBody; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor - * @type {integer} - * @since 3.0.0 - */ - this.debugBodyColor = world.defaults.staticBodyDebugColor; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#enable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#isCircle - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isCircle = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#radius - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.radius = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#offset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.offset = new Vector2(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#width - * @type {number} - * @since 3.0.0 - */ - this.width = width; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#height - * @type {number} - * @since 3.0.0 - */ - this.height = height; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#halfWidth - * @type {number} - * @since 3.0.0 - */ - this.halfWidth = Math.abs(this.width / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#halfHeight - * @type {number} - * @since 3.0.0 - */ - this.halfHeight = Math.abs(this.height / 2); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#center - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#velocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.velocity = Vector2.ZERO; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#allowGravity - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.allowGravity = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = Vector2.ZERO; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#bounce - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.bounce = Vector2.ZERO; - - // If true this Body will dispatch events - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onCollide - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onCollide = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#onOverlap - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.onOverlap = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#mass - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.mass = 1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#immovable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.immovable = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#customSeparateX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateX = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#customSeparateY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateY = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapX = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapY = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#overlapR - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapR = 0; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#embedded - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.embedded = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.collideWorldBounds = false; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#checkCollision - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#touching - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#wasTouching - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#blocked - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.STATIC_BODY; - - /** - * The calculated change in the Body's horizontal position during the current step. - * For a static body this is always zero. - * - * @name Phaser.Physics.Arcade.StaticBody#_dx - * @type {number} - * @private - * @default 0 - * @since 3.10.0 - */ - this._dx = 0; - - /** - * The calculated change in the Body's vertical position during the current step. - * For a static body this is always zero. - * - * @name Phaser.Physics.Arcade.StaticBody#_dy - * @type {number} - * @private - * @default 0 - * @since 3.10.0 - */ - this._dy = 0; - }, - - /** - * Changes the Game Object this Body is bound to. - * First it removes its reference from the old Game Object, then sets the new one. - * You can optionally update the position and dimensions of this Body to reflect that of the new Game Object. - * - * @method Phaser.Physics.Arcade.StaticBody#setGameObject - * @since 3.1.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The new Game Object that will own this Body. - * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setGameObject: function (gameObject, update) + if (!body1.immovable && !body2.immovable) { - if (gameObject && gameObject !== this.gameObject) + overlap *= 0.5; + + body1.y -= overlap; + body2.y += overlap; + + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; + + nv1 -= avg; + nv2 -= avg; + + body1.velocity.y = avg + nv1 * body1.bounce.y; + body2.velocity.y = avg + nv2 * body2.bounce.y; + } + else if (!body1.immovable) + { + body1.y -= overlap; + body1.velocity.y = v2 - v1 * body1.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body2.moves) { - // Remove this body from the old game object - this.gameObject.body = null; - - gameObject.body = this; - - // Update our reference - this.gameObject = gameObject; + body1.x += (body2.x - body2.prev.x) * body2.friction.x; } + } + else + { + body2.y += overlap; + body2.velocity.y = v1 - v2 * body2.bounce.y; - if (update) + // This is special case code that handles things like horizontal moving platforms you can ride + if (body1.moves) { - this.updateFromGameObject(); + body2.x += (body1.x - body1.prev.x) * body1.friction.x; } + } - return this; - }, + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; - /** - * Updates this Static Body so that its position and dimensions are updated - * based on the current Game Object it is bound to. - * - * @method Phaser.Physics.Arcade.StaticBody#updateFromGameObject - * @since 3.1.0 - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - updateFromGameObject: function () +module.exports = SeparateY; + + +/***/ }), +/* 508 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetOverlapX = __webpack_require__(230); + +/** + * [description] + * + * @function Phaser.Physics.Arcade.SeparateX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body1 - [description] + * @param {Phaser.Physics.Arcade.Body} body2 - [description] + * @param {boolean} overlapOnly - [description] + * @param {number} bias - [description] + * + * @return {boolean} [description] + */ +var SeparateX = function (body1, body2, overlapOnly, bias) +{ + var overlap = GetOverlapX(body1, body2, overlapOnly, bias); + + // Can't separate two immovable bodies, or a body with its own custom separation logic + if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) { - this.world.staticTree.remove(this); + // return true if there was some overlap, otherwise false + return (overlap !== 0) || (body1.embedded && body2.embedded); + } - var gameObject = this.gameObject; + // Adjust their positions and velocities accordingly (if there was any overlap) + var v1 = body1.velocity.x; + var v2 = body2.velocity.x; - gameObject.getTopLeft(this.position); - - this.width = gameObject.displayWidth; - this.height = gameObject.displayHeight; - - this.halfWidth = Math.abs(this.width / 2); - this.halfHeight = Math.abs(this.height / 2); - - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setOffset - * @since 3.4.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setOffset: function (x, y) + if (!body1.immovable && !body2.immovable) { - if (y === undefined) { y = x; } + overlap *= 0.5; - this.world.staticTree.remove(this); + body1.x -= overlap; + body2.x += overlap; - this.position.x -= this.offset.x; - this.position.y -= this.offset.y; + var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); + var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); + var avg = (nv1 + nv2) * 0.5; - this.offset.set(x, y); + nv1 -= avg; + nv2 -= avg; - this.position.x += this.offset.x; - this.position.y += this.offset.y; - - this.updateCenter(); - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setSize: function (width, height, offsetX, offsetY) + body1.velocity.x = avg + nv1 * body1.bounce.x; + body2.velocity.x = avg + nv2 * body2.bounce.x; + } + else if (!body1.immovable) { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } + body1.x -= overlap; + body1.velocity.x = v2 - v1 * body1.bounce.x; - this.world.staticTree.remove(this); - - this.width = width; - this.height = height; - - this.halfWidth = Math.floor(width / 2); - this.halfHeight = Math.floor(height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - - this.isCircle = false; - this.radius = 0; - - this.world.staticTree.insert(this); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#setCircle - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - setCircle: function (radius, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - if (radius > 0) + // This is special case code that handles things like vertically moving platforms you can ride + if (body2.moves) { - this.world.staticTree.remove(this); + body1.y += (body2.y - body2.prev.y) * body2.friction.y; + } + } + else + { + body2.x += overlap; + body2.velocity.x = v1 - v2 * body2.bounce.x; - this.isCircle = true; + // This is special case code that handles things like vertically moving platforms you can ride + if (body1.moves) + { + body2.y += (body1.y - body1.prev.y) * body1.friction.y; + } + } - this.radius = radius; + // If we got this far then there WAS overlap, and separation is complete, so return true + return true; +}; - this.width = radius * 2; - this.height = radius * 2; +module.exports = SeparateX; - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - this.offset.set(offsetX, offsetY); +/***/ }), +/* 509 */ +/***/ (function(module, exports) { - this.updateCenter(); +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ - this.world.staticTree.insert(this); +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} y - The y separation amount. + */ +var ProcessTileSeparationY = function (body, y) +{ + if (y < 0) + { + body.blocked.none = false; + body.blocked.up = true; + } + else if (y > 0) + { + body.blocked.none = false; + body.blocked.down = true; + } + + body.position.y -= y; + + if (body.bounce.y === 0) + { + body.velocity.y = 0; + } + else + { + body.velocity.y = -body.velocity.y * body.bounce.y; + } +}; + +module.exports = ProcessTileSeparationY; + + +/***/ }), +/* 510 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationY = __webpack_require__(509); + +/** + * Check the body against the given tile on the Y axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckY + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileTop - [description] + * @param {number} tileBottom - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) +{ + var oy = 0; + + if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) + { + // Body is moving UP + if (tile.faceBottom && body.y < tileBottom) + { + oy = body.y - tileBottom; + + if (oy < -tileBias) + { + oy = 0; + } + } + } + else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) + { + // Body is moving DOWN + if (tile.faceTop && body.bottom > tileTop) + { + oy = body.bottom - tileTop; + + if (oy > tileBias) + { + oy = 0; + } + } + } + + if (oy !== 0) + { + if (body.customSeparateY) + { + body.overlapY = oy; } else { - this.isCircle = false; + ProcessTileSeparationY(body, oy); } + } - return this; - }, + return oy; +}; - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#updateCenter - * @since 3.0.0 - */ - updateCenter: function () +module.exports = TileCheckY; + + +/***/ }), +/* 511 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Internal function to process the separation of a physics body from a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {number} x - The x separation amount. + */ +var ProcessTileSeparationX = function (body, x) +{ + if (x < 0) { - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#reset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - */ - reset: function (x, y) + body.blocked.none = false; + body.blocked.left = true; + } + else if (x > 0) { - var gameObject = this.gameObject; + body.blocked.none = false; + body.blocked.right = true; + } - if (x === undefined) { x = gameObject.x; } - if (y === undefined) { y = gameObject.y; } + body.position.x -= x; - this.world.staticTree.remove(this); - - gameObject.getTopLeft(this.position); - - this.updateCenter(); - - this.world.staticTree.insert(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#stop - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. - */ - stop: function () + if (body.bounce.x === 0) { - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#getBounds - * @since 3.0.0 - * - * @param {ArcadeBodyBounds} obj - [description] - * - * @return {ArcadeBodyBounds} [description] - */ - getBounds: function (obj) + body.velocity.x = 0; + } + else { - obj.x = this.x; - obj.y = this.y; - obj.right = this.right; - obj.bottom = this.bottom; + body.velocity.x = -body.velocity.x * body.bounce.x; + } +}; - return obj; - }, +module.exports = ProcessTileSeparationX; - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#hitTest - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - hitTest: function (x, y) + +/***/ }), +/* 512 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ProcessTileSeparationX = __webpack_require__(511); + +/** + * Check the body against the given tile on the X axis. + * + * @function Phaser.Physics.Arcade.Tilemap.TileCheckX + * @since 3.0.0 + * + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to check. + * @param {number} tileLeft - [description] + * @param {number} tileRight - [description] + * @param {number} tileBias - [description] + * + * @return {number} The amount of separation that occurred. + */ +var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) +{ + var ox = 0; + + if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) { - return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsX: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaAbsY: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaX - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaX: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaY - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaY: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#deltaZ - * @since 3.0.0 - * - * @return {number} [description] - */ - deltaZ: function () - { - return 0; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enable = false; - - this.world.pendingDestroy.set(this); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticBody#drawDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphic - [description] - */ - drawDebug: function (graphic) - { - var pos = this.position; - - if (this.debugShowBody) + // Body is moving LEFT + if (tile.faceRight && body.x < tileRight) { - graphic.lineStyle(1, this.debugBodyColor, 1); - graphic.strokeRect(pos.x, pos.y, this.width, this.height); + ox = body.x - tileRight; + + if (ox < -tileBias) + { + ox = 0; + } } - }, + } + else if (body.deltaX() > 0 && !body.blocked.right && tile.collideLeft && body.checkCollision.right) + { + // Body is moving RIGHT + if (tile.faceLeft && body.right > tileLeft) + { + ox = body.right - tileLeft; + + if (ox > tileBias) + { + ox = 0; + } + } + } + + if (ox !== 0) + { + if (body.customSeparateX) + { + body.overlapX = ox; + } + else + { + ProcessTileSeparationX(body, ox); + } + } + + return ox; +}; + +module.exports = TileCheckX; + + +/***/ }), +/* 513 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileCheckX = __webpack_require__(512); +var TileCheckY = __webpack_require__(510); +var TileIntersectsBody = __webpack_require__(226); + +/** + * The core separation function to separate a physics body and a tile. + * + * @function Phaser.Physics.Arcade.Tilemap.SeparateTile + * @since 3.0.0 + * + * @param {number} i - [description] + * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. + * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. + * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemapLayer to collide against. + * @param {number} tileBias - [description] + * + * @return {boolean} Returns true if the body was separated, otherwise false. + */ +var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) +{ + var tileLeft = tileWorldRect.left; + var tileTop = tileWorldRect.top; + var tileRight = tileWorldRect.right; + var tileBottom = tileWorldRect.bottom; + var faceHorizontal = tile.faceLeft || tile.faceRight; + var faceVertical = tile.faceTop || tile.faceBottom; + + // We don't need to go any further if this tile doesn't actually have any colliding faces. This + // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't + // needed for separation. + if (!faceHorizontal && !faceVertical) + { + return false; + } + + var ox = 0; + var oy = 0; + var minX = 0; + var minY = 1; + + if (body.deltaAbsX() > body.deltaAbsY()) + { + // Moving faster horizontally, check X axis first + minX = -1; + } + else if (body.deltaAbsX() < body.deltaAbsY()) + { + // Moving faster vertically, check Y axis first + minY = -1; + } + + if (body.deltaX() !== 0 && body.deltaY() !== 0 && faceHorizontal && faceVertical) + { + // We only need do this if both axes have colliding faces AND we're moving in both + // directions + minX = Math.min(Math.abs(body.position.x - tileRight), Math.abs(body.right - tileLeft)); + minY = Math.min(Math.abs(body.position.y - tileBottom), Math.abs(body.bottom - tileTop)); + } + + if (minX < minY) + { + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + + // That's horizontal done, check if we still intersects? If not then we can return now + if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + } + } + else + { + if (faceVertical) + { + oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); + + // That's vertical done, check if we still intersects? If not then we can return now + if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) + { + return true; + } + } + + if (faceHorizontal) + { + ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); + } + } + + return (ox !== 0 || oy !== 0); +}; + +module.exports = SeparateTile; + + +/***/ }), +/* 514 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks + * @since 3.0.0 + * + * @param {Phaser.Tilemaps.Tilemap} tile - [description] + * @param {Phaser.GameObjects.Sprite} sprite - [description] + * + * @return {boolean} [description] + */ +var ProcessTileCallbacks = function (tile, sprite) +{ + // Tile callbacks take priority over layer level callbacks + if (tile.collisionCallback) + { + return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); + } + else if (tile.layer.callbacks[tile.index]) + { + return !tile.layer.callbacks[tile.index].callback.call( + tile.layer.callbacks[tile.index].callbackContext, sprite, tile + ); + } + + return true; +}; + +module.exports = ProcessTileCallbacks; + + +/***/ }), +/* 515 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Velocity + * @since 3.0.0 + */ +var Velocity = { /** * [description] * - * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity * @since 3.0.0 * - * @return {boolean} [description] + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. */ - willDrawDebug: function () + setVelocity: function (x, y) { - return this.debugShowBody; + this.body.setVelocity(x, y); + + return this; }, /** * [description] * - * @method Phaser.Physics.Arcade.StaticBody#setMass + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX + * @since 3.0.0 + * + * @param {number} x - [description] + * + * @return {this} This Game Object. + */ + setVelocityX: function (x) + { + this.body.setVelocityX(x); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY + * @since 3.0.0 + * + * @param {number} y - [description] + * + * @return {this} This Game Object. + */ + setVelocityY: function (y) + { + this.body.setVelocityY(y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. + */ + setMaxVelocity: function (x, y) + { + this.body.maxVelocity.set(x, y); + + return this; + } + +}; + +module.exports = Velocity; + + +/***/ }), +/* 516 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods for setting the size of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.Physics.Arcade.Components.Size + * @since 3.0.0 + */ +var Size = { + + /** + * Sets the body offset. This allows you to adjust the difference between the center of the body + * and the x and y coordinates of the parent Game Object. + * + * @method Phaser.Physics.Arcade.Components.Size#setOffset + * @since 3.0.0 + * + * @param {number} x - The amount to offset the body from the parent Game Object along the x-axis. + * @param {number} [y=x] - The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. + * + * @return {this} This Game Object. + */ + setOffset: function (x, y) + { + this.body.setOffset(x, y); + + return this; + }, + + /** + * Sets the size of this physics body. Setting the size does not adjust the dimensions + * of the parent Game Object. + * + * @method Phaser.Physics.Arcade.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The new width of the physics body, in pixels. + * @param {number} height - The new height of the physics body, in pixels. + * @param {boolean} [center=true] - Should the body be re-positioned so its center aligns with the parent Game Object? + * + * @return {this} This Game Object. + */ + setSize: function (width, height, center) + { + this.body.setSize(width, height, center); + + return this; + }, + + /** + * Sets this physics body to use a circle for collision instead of a rectangle. + * + * @method Phaser.Physics.Arcade.Components.Size#setCircle + * @since 3.0.0 + * + * @param {number} radius - The radius of the physics body, in pixels. + * @param {number} [offsetX] - The amount to offset the body from the parent Game Object along the x-axis. + * @param {number} [offsetY] - The amount to offset the body from the parent Game Object along the y-axis. + * + * @return {this} This Game Object. + */ + setCircle: function (radius, offsetX, offsetY) + { + this.body.setCircle(radius, offsetX, offsetY); + + return this; + } + +}; + +module.exports = Size; + + +/***/ }), +/* 517 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Mass + * @since 3.0.0 + */ +var Mass = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Mass#setMass * @since 3.0.0 * * @param {number} value - [description] * - * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + * @return {this} This Game Object. */ setMass: function (value) { - if (value <= 0) - { - // Causes havoc otherwise - value = 0.1; - } - - this.mass = value; + this.body.mass = value; return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.position.x; - }, - - set: function (value) - { - this.world.staticTree.remove(this); - - this.position.x = value; - - this.world.staticTree.insert(this); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.position.y; - }, - - set: function (value) - { - this.world.staticTree.remove(this); - - this.position.y = value; - - this.world.staticTree.insert(this); - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#left - * @type {number} - * @readOnly - * @since 3.0.0 - */ - left: { - - get: function () - { - return this.position.x; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#right - * @type {number} - * @readOnly - * @since 3.0.0 - */ - right: { - - get: function () - { - return this.position.x + this.width; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#top - * @type {number} - * @readOnly - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.position.y; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.StaticBody#bottom - * @type {number} - * @readOnly - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.position.y + this.height; - } - } -}); +}; -module.exports = StaticBody; +module.exports = Mass; /***/ }), -/* 335 */ +/* 518 */ /***/ (function(module, exports) { /** @@ -81910,2445 +109896,774 @@ module.exports = StaticBody; /** * [description] * - * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody + * @name Phaser.Physics.Arcade.Components.Immovable * @since 3.0.0 - * - * @param {{ left: number, right: number, top: number, bottom: number }} tileWorldRect - [description] - * @param {Phaser.Physics.Arcade.Body} body - [description] - * - * @return {boolean} [description] */ -var TileIntersectsBody = function (tileWorldRect, body) -{ - // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this - // should support circle bodies when those are less buggy in v3. - - return !( - body.right <= tileWorldRect.left || - body.bottom <= tileWorldRect.top || - body.position.x >= tileWorldRect.right || - body.position.y >= tileWorldRect.bottom - ); -}; - -module.exports = TileIntersectsBody; - - -/***/ }), -/* 336 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(42); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.GetOverlapY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {number} [description] - */ -var GetOverlapY = function (body1, body2, overlapOnly, bias) -{ - var overlap = 0; - var maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + bias; - - if (body1._dy === 0 && body2._dy === 0) - { - // They overlap but neither of them are moving - body1.embedded = true; - body2.embedded = true; - } - else if (body1._dy > body2._dy) - { - // Body1 is moving down and/or Body2 is moving up - overlap = body1.bottom - body2.y; - - if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.down === false || body2.checkCollision.up === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.down = true; - - body2.touching.none = false; - body2.touching.up = true; - - if (body2.physicsType === CONST.STATIC_BODY) - { - body1.blocked.down = true; - } - - if (body1.physicsType === CONST.STATIC_BODY) - { - body2.blocked.up = true; - } - } - } - else if (body1._dy < body2._dy) - { - // Body1 is moving up and/or Body2 is moving down - overlap = body1.y - body2.bottom; - - if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.up === false || body2.checkCollision.down === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.up = true; - - body2.touching.none = false; - body2.touching.down = true; - - if (body2.physicsType === CONST.STATIC_BODY) - { - body1.blocked.up = true; - } - - if (body1.physicsType === CONST.STATIC_BODY) - { - body2.blocked.down = true; - } - } - } - - // Resets the overlapY to zero if there is no overlap, or to the actual pixel value if there is - body1.overlapY = overlap; - body2.overlapY = overlap; - - return overlap; -}; - -module.exports = GetOverlapY; - - -/***/ }), -/* 337 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(42); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.GetOverlapX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {number} [description] - */ -var GetOverlapX = function (body1, body2, overlapOnly, bias) -{ - var overlap = 0; - var maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + bias; - - if (body1._dx === 0 && body2._dx === 0) - { - // They overlap but neither of them are moving - body1.embedded = true; - body2.embedded = true; - } - else if (body1._dx > body2._dx) - { - // Body1 is moving right and / or Body2 is moving left - overlap = body1.right - body2.x; - - if ((overlap > maxOverlap && !overlapOnly) || body1.checkCollision.right === false || body2.checkCollision.left === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.right = true; - - body2.touching.none = false; - body2.touching.left = true; - - if (body2.physicsType === CONST.STATIC_BODY) - { - body1.blocked.right = true; - } - - if (body1.physicsType === CONST.STATIC_BODY) - { - body2.blocked.left = true; - } - } - } - else if (body1._dx < body2._dx) - { - // Body1 is moving left and/or Body2 is moving right - overlap = body1.x - body2.width - body2.x; - - if ((-overlap > maxOverlap && !overlapOnly) || body1.checkCollision.left === false || body2.checkCollision.right === false) - { - overlap = 0; - } - else - { - body1.touching.none = false; - body1.touching.left = true; - - body2.touching.none = false; - body2.touching.right = true; - - if (body2.physicsType === CONST.STATIC_BODY) - { - body1.blocked.left = true; - } - - if (body1.physicsType === CONST.STATIC_BODY) - { - body2.blocked.right = true; - } - } - } - - // Resets the overlapX to zero if there is no overlap, or to the actual pixel value if there is - body1.overlapX = overlap; - body2.overlapX = overlap; - - return overlap; -}; - -module.exports = GetOverlapX; - - -/***/ }), -/* 338 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * [description] - * - * @class Collider - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {boolean} overlapOnly - [description] - * @param {ArcadeColliderType} object1 - The first object to check for collision. - * @param {ArcadeColliderType} object2 - The second object to check for collision. - * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. - * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. - * @param {any} callbackContext - The scope in which to call the callbacks. - */ -var Collider = new Class({ - - initialize: - - function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#name - * @type {string} - * @since 3.1.0 - */ - this.name = ''; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#overlapOnly - * @type {boolean} - * @since 3.0.0 - */ - this.overlapOnly = overlapOnly; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#object1 - * @type {ArcadeColliderType} - * @since 3.0.0 - */ - this.object1 = object1; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#object2 - * @type {ArcadeColliderType} - * @since 3.0.0 - */ - this.object2 = object2; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#collideCallback - * @type {ArcadePhysicsCallback} - * @since 3.0.0 - */ - this.collideCallback = collideCallback; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#processCallback - * @type {ArcadePhysicsCallback} - * @since 3.0.0 - */ - this.processCallback = processCallback; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Collider#callbackContext - * @type {object} - * @since 3.0.0 - */ - this.callbackContext = callbackContext; - }, +var Immovable = { /** * [description] * - * @method Phaser.Physics.Arcade.Collider#setName - * @since 3.1.0 - * - * @param {string} name - [description] - * - * @return {Phaser.Physics.Arcade.Collider} [description] - */ - setName: function (name) - { - this.name = name; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#update - * @since 3.0.0 - */ - update: function () - { - this.world.collideObjects( - this.object1, - this.object2, - this.collideCallback, - this.processCallback, - this.callbackContext, - this.overlapOnly - ); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Collider#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.world.removeCollider(this); - - this.active = false; - - this.world = null; - - this.object1 = null; - this.object2 = null; - - this.collideCallback = null; - this.processCallback = null; - this.callbackContext = null; - } - -}); - -module.exports = Collider; - - -/***/ }), -/* 339 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CircleContains = __webpack_require__(32); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var RadToDeg = __webpack_require__(150); -var Rectangle = __webpack_require__(14); -var RectangleContains = __webpack_require__(31); -var TransformMatrix = __webpack_require__(64); -var Vector2 = __webpack_require__(6); - -/** - * @typedef {object} ArcadeBodyBounds - * - * @property {number} x - The left edge. - * @property {number} y - The upper edge. - * @property {number} right - The right edge. - * @property {number} bottom - The lower edge. - */ - -/** - * @typedef {object} ArcadeBodyCollision - * - * @property {boolean} none - True if the Body is not colliding. - * @property {boolean} up - True if the Body is colliding on its upper edge. - * @property {boolean} down - True if the Body is colliding on its lower edge. - * @property {boolean} left - True if the Body is colliding on its left edge. - * @property {boolean} right - True if the Body is colliding on its right edge. - */ - -/** - * @classdesc - * A Dynamic Arcade Body. - * - * @class Body - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics simulation this Body belongs to. - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object this Body belongs to. - */ -var Body = new Class({ - - initialize: - - function Body (world, gameObject) - { - var width = (gameObject.width) ? gameObject.width : 64; - var height = (gameObject.height) ? gameObject.height : 64; - - /** - * The Arcade Physics simulation this Body belongs to. - * - * @name Phaser.Physics.Arcade.Body#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * The Game Object this Body belongs to. - * - * @name Phaser.Physics.Arcade.Body#gameObject - * @type {Phaser.GameObjects.GameObject} - * @since 3.0.0 - */ - this.gameObject = gameObject; - - /** - * Transformations applied to this Body. - * - * @name Phaser.Physics.Arcade.Body#transform - * @type {object} - * @since 3.4.0 - */ - this.transform = { - x: gameObject.x, - y: gameObject.y, - rotation: gameObject.angle, - scaleX: gameObject.scaleX, - scaleY: gameObject.scaleY, - displayOriginX: gameObject.displayOriginX, - displayOriginY: gameObject.displayOriginY - }; - - /** - * Whether the Body's boundary is drawn to the debug display. - * - * @name Phaser.Physics.Arcade.Body#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowBody = world.defaults.debugShowBody; - - /** - * Whether the Body's velocity is drawn to the debug display. - * - * @name Phaser.Physics.Arcade.Body#debugShowVelocity - * @type {boolean} - * @since 3.0.0 - */ - this.debugShowVelocity = world.defaults.debugShowVelocity; - - /** - * The color of this Body on the debug display. - * - * @name Phaser.Physics.Arcade.Body#debugBodyColor - * @type {integer} - * @since 3.0.0 - */ - this.debugBodyColor = world.defaults.bodyDebugColor; - - /** - * Whether this Body is updated by the physics simulation. - * - * @name Phaser.Physics.Arcade.Body#enable - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.enable = true; - - /** - * Whether this Body's boundary is circular (true) or rectangular (false). - * - * @name Phaser.Physics.Arcade.Body#isCircle - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setCircle - */ - this.isCircle = false; - - /** - * The unscaled radius of this Body's boundary (if circular), as set by setCircle, in source pixels. - * The true radius (if circular) is equal to halfWidth. - * - * @name Phaser.Physics.Arcade.Body#radius - * @type {number} - * @default 0 - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setCircle - */ - this.radius = 0; - - /** - * The offset of this Body's position from its Game Object's position, in source pixels. - * - * @name Phaser.Physics.Arcade.Body#offset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setOffset - */ - this.offset = new Vector2(); - - /** - * The position of this Body within the simulation. - * - * @name Phaser.Physics.Arcade.Body#position - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.position = new Vector2(gameObject.x, gameObject.y); - - /** - * The position of this Body during the previous step. - * - * @name Phaser.Physics.Arcade.Body#prev - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.prev = new Vector2(gameObject.x, gameObject.y); - - /** - * Whether this Body's rotation is affected by its angular acceleration and velocity. - * - * @name Phaser.Physics.Arcade.Body#allowRotation - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowRotation = true; - - /** - * This body's rotation, in degrees, based on its angular acceleration and velocity. - * The Body's rotation controls the `angle` of its Game Object. - * It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle. - * - * @name Phaser.Physics.Arcade.Body#rotation - * @type {number} - * @since 3.0.0 - */ - this.rotation = gameObject.angle; - - /** - * The Body's rotation, in degrees, during the previous step. - * - * @name Phaser.Physics.Arcade.Body#preRotation - * @type {number} - * @since 3.0.0 - */ - this.preRotation = gameObject.angle; - - /** - * The width of the Body's boundary. If circular, this is also the Body's diameter. - * - * @name Phaser.Physics.Arcade.Body#width - * @type {number} - * @default 64 - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the Body's boundary. If circular, this is also the Body's diameter. - * - * @name Phaser.Physics.Arcade.Body#height - * @type {number} - * @default 64 - * @since 3.0.0 - */ - this.height = height; - - /** - * The unscaled width of the Body, in source pixels. The default is the width of the Body's Game Object's texture frame. - * - * @name Phaser.Physics.Arcade.Body#sourceWidth - * @type {number} - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setSize - */ - this.sourceWidth = width; - - /** - * The unscaled height of the Body, in source pixels. The default is the height of the Body's Game Object's texture frame. - * - * @name Phaser.Physics.Arcade.Body#sourceHeight - * @type {number} - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#setSize - */ - this.sourceHeight = height; - - if (gameObject.frame) - { - this.sourceWidth = gameObject.frame.realWidth; - this.sourceHeight = gameObject.frame.realHeight; - } - - /** - * Half the Body's width. - * - * @name Phaser.Physics.Arcade.Body#halfWidth - * @type {number} - * @since 3.0.0 - */ - this.halfWidth = Math.abs(width / 2); - - /** - * Half the Body's height. - * - * @name Phaser.Physics.Arcade.Body#halfHeight - * @type {number} - * @since 3.0.0 - */ - this.halfHeight = Math.abs(height / 2); - - /** - * The center of the Body's boundary. The midpoint of its `position` (top-left corner) and its bottom-right corner. - * - * @name Phaser.Physics.Arcade.Body#center - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); - - /** - * The Body's change in position, in pixels per second. - * - * @name Phaser.Physics.Arcade.Body#velocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.velocity = new Vector2(); - - /** - * The Body's calculated change in position, in pixels, at the last step. - * - * @name Phaser.Physics.Arcade.Body#newVelocity - * @type {Phaser.Math.Vector2} - * @readOnly - * @since 3.0.0 - */ - this.newVelocity = new Vector2(); - - /** - * The Body's absolute maximum change in position, in pixels per step. - * - * @name Phaser.Physics.Arcade.Body#deltaMax - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.deltaMax = new Vector2(); - - /** - * The Body's change in velocity, in pixels per second squared. - * - * @name Phaser.Physics.Arcade.Body#acceleration - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.acceleration = new Vector2(); - - /** - * Whether this Body's velocity is affected by its drag vector. - * - * @name Phaser.Physics.Arcade.Body#allowDrag - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowDrag = true; - - /** - * Absolute loss of velocity due to movement, in pixels per second squared. - * - * @name Phaser.Physics.Arcade.Body#drag - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.drag = new Vector2(); - - /** - * Whether this Body's position is affected by its gravity vector. - * - * @name Phaser.Physics.Arcade.Body#allowGravity - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.allowGravity = true; - - /** - * Acceleration due to gravity (specific to this Body), in pixels per second squared. - * Total gravity is the sum of this vector and the simulation's `gravity`. - * - * @name Phaser.Physics.Arcade.Body#gravity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.gravity = new Vector2(); - - /** - * Rebound following a collision, relative to 1. - * - * @name Phaser.Physics.Arcade.Body#bounce - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.bounce = new Vector2(); - - /** - * Rebound following a collision with the world boundary, relative to 1. - * If empty, `bounce` is used instead. - * - * @name Phaser.Physics.Arcade.Body#worldBounce - * @type {?Phaser.Math.Vector2} - * @default null - * @since 3.0.0 - */ - this.worldBounce = null; - - // If true this Body will dispatch events - - /** - * Whether the simulation emits a `worldbounds` event when this Body collides with the world boundary (and `collideWorldBounds` is also true). - * - * @name Phaser.Physics.Arcade.Body#onWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#event:worldbounds - */ - this.onWorldBounds = false; - - /** - * Whether the simulation emits a `collide` event when this Body collides with another. - * - * @name Phaser.Physics.Arcade.Body#onCollide - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#event:collide - */ - this.onCollide = false; - - /** - * Whether the simulation emits an `overlap` event when this Body overlaps with another. - * - * @name Phaser.Physics.Arcade.Body#onOverlap - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#event:overlap - */ - this.onOverlap = false; - - /** - * The Body's absolute maximum velocity. - * - * This limits the Body's rate of movement but not its `velocity` values (which can still exceed `maxVelocity`). - * - * @name Phaser.Physics.Arcade.Body#maxVelocity - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.maxVelocity = new Vector2(10000, 10000); - - /** - * If this Body is `immovable` and in motion, this the proportion of this Body's movement received by the riding body on each axis, relative to 1. - * The default value (1, 0) moves the riding body horizontally in equal proportion and vertically not at all. - * - * @name Phaser.Physics.Arcade.Body#friction - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.friction = new Vector2(1, 0); - - /** - * If this Body is using `drag` for deceleration this property controls how the drag is applied. - * If set to `true` drag will use a damping effect rather than a linear approach. If you are - * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in - * the game Asteroids) then you will get a far smoother and more visually correct deceleration - * by using damping, avoiding the axis-drift that is prone with linear deceleration. - * - * If you enable this property then you should use far smaller `drag` values than with linear, as - * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow - * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. - * - * @name Phaser.Physics.Arcade.Body#useDamping - * @type {boolean} - * @default false - * @since 3.10.0 - */ - this.useDamping = false; - - /** - * The rate of change of this Body's rotation, in degrees per second. - * - * @name Phaser.Physics.Arcade.Body#angularVelocity - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularVelocity = 0; - - /** - * The rate of change of this Body's angular velocity, in degrees per second squared. - * - * @name Phaser.Physics.Arcade.Body#angularAcceleration - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularAcceleration = 0; - - /** - * Loss of angular velocity due to angular movement, in degrees per second. - * - * @name Phaser.Physics.Arcade.Body#angularDrag - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angularDrag = 0; - - /** - * The Body's maximum angular velocity, in degrees per second. - * - * @name Phaser.Physics.Arcade.Body#maxAngular - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.maxAngular = 1000; - - /** - * The Body's inertia, relative to a default unit (1). - * With `bounce`, this affects the exchange of momentum (velocities) during collisions. - * - * @name Phaser.Physics.Arcade.Body#mass - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.mass = 1; - - /** - * The angle of this Body's velocity vector, in degrees. - * - * @name Phaser.Physics.Arcade.Body#angle - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angle = 0; - - /** - * The magnitude of the Body's velocity, as calculated during the last update. - * - * @name Phaser.Physics.Arcade.Body#speed - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.speed = 0; - - /** - * The calculated direction of the Body's velocity. - * - * @name Phaser.Physics.Arcade.Body#facing - * @type {integer} - * @since 3.0.0 - */ - this.facing = CONST.FACING_NONE; - - /** - * Whether this object can be moved by collisions with another body. - * - * @name Phaser.Physics.Arcade.Body#immovable - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.immovable = false; - - /** - * Whether the Body's position and rotation are affected by its velocity, acceleration, drag, and gravity. - * - * @name Phaser.Physics.Arcade.Body#moves - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.moves = true; - - /** - * A flag disabling the default horizontal separation of colliding bodies. Pass your own `processHandler` to the collider. - * - * @name Phaser.Physics.Arcade.Body#customSeparateX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateX = false; - - /** - * A flag disabling the default vertical separation of colliding bodies. Pass your own `processHandler` to the collider. - * - * @name Phaser.Physics.Arcade.Body#customSeparateY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.customSeparateY = false; - - /** - * The amount of horizontal overlap (before separation), if this Body is colliding with another. - * - * @name Phaser.Physics.Arcade.Body#overlapX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapX = 0; - - /** - * The amount of vertical overlap (before separation), if this Body is colliding with another. - * - * @name Phaser.Physics.Arcade.Body#overlapY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapY = 0; - - /** - * The amount of overlap (before separation), if this Body is circular and colliding with another circular body. - * - * @name Phaser.Physics.Arcade.Body#overlapR - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.overlapR = 0; - - /** - * Whether this Body is overlapped with another and both have zero velocity. - * - * @name Phaser.Physics.Arcade.Body#embedded - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.embedded = false; - - /** - * Whether this Body interacts with the world boundary. - * - * @name Phaser.Physics.Arcade.Body#collideWorldBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.collideWorldBounds = false; - - /** - * Whether this Body is checked for collisions and for which directions. - * You can set `checkCollision.none = false` to disable collision checks. - * - * @name Phaser.Physics.Arcade.Body#checkCollision - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; - - /** - * Whether this Body is colliding with another and in which direction. - * - * @name Phaser.Physics.Arcade.Body#touching - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.touching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * Whether this Body was colliding with another during the last step, and in which direction. - * - * @name Phaser.Physics.Arcade.Body#wasTouching - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; - - /** - * Whether this Body is colliding with a tile or the world boundary. - * - * @name Phaser.Physics.Arcade.Body#blocked - * @type {ArcadeBodyCollision} - * @since 3.0.0 - */ - this.blocked = { none: true, up: false, down: false, left: false, right: false }; - - /** - * Whether to automatically synchronize this Body's dimensions to the dimensions of its Game Object's visual bounds. - * - * @name Phaser.Physics.Arcade.Body#syncBounds - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.GameObjects.Components.GetBounds#getBounds - */ - this.syncBounds = false; - - /** - * Whether this Body is being moved by the `moveTo` or `moveFrom` methods. - * - * @name Phaser.Physics.Arcade.Body#isMoving - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isMoving = false; - - /** - * Whether this Body's movement by `moveTo` or `moveFrom` will be stopped by collisions with other bodies. - * - * @name Phaser.Physics.Arcade.Body#stopVelocityOnCollide - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.stopVelocityOnCollide = true; - - // read-only - - /** - * The Body's physics type (dynamic or static). - * - * @name Phaser.Physics.Arcade.Body#physicsType - * @type {integer} - * @readOnly - * @since 3.0.0 - */ - this.physicsType = CONST.DYNAMIC_BODY; - - /** - * Whether the Body's position needs updating from its Game Object. - * - * @name Phaser.Physics.Arcade.Body#_reset - * @type {boolean} - * @private - * @default true - * @since 3.0.0 - */ - this._reset = true; - - /** - * Cached horizontal scale of the Body's Game Object. - * - * @name Phaser.Physics.Arcade.Body#_sx - * @type {number} - * @private - * @since 3.0.0 - */ - this._sx = gameObject.scaleX; - - /** - * Cached vertical scale of the Body's Game Object. - * - * @name Phaser.Physics.Arcade.Body#_sy - * @type {number} - * @private - * @since 3.0.0 - */ - this._sy = gameObject.scaleY; - - /** - * The calculated change in the Body's horizontal position during the current step. - * - * @name Phaser.Physics.Arcade.Body#_dx - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._dx = 0; - - /** - * The calculated change in the Body's vertical position during the current step. - * - * @name Phaser.Physics.Arcade.Body#_dy - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._dy = 0; - - /** - * Stores the Game Object's bounds. - * - * @name Phaser.Physics.Arcade.Body#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); - - this._tempMatrix = new TransformMatrix(); - }, - - /** - * Updates this Body's transform, dimensions, and position from its Game Object. - * - * @method Phaser.Physics.Arcade.Body#updateBounds - * @since 3.0.0 - */ - updateBounds: function () - { - var sprite = this.gameObject; - - // Container? - - var transform = this.transform; - - if (sprite.parentContainer) - { - var matrix = sprite.getWorldTransformMatrix(this._tempMatrix); - - transform.x = matrix.tx; - transform.y = matrix.ty; - transform.rotation = RadToDeg(matrix.rotation); - transform.scaleX = matrix.scaleX; - transform.scaleY = matrix.scaleY; - } - else - { - transform.x = sprite.x; - transform.y = sprite.y; - transform.rotation = sprite.angle; - transform.scaleX = sprite.scaleX; - transform.scaleY = sprite.scaleY; - } - - var recalc = false; - - if (this.syncBounds) - { - var b = sprite.getBounds(this._bounds); - - this.width = b.width; - this.height = b.height; - recalc = true; - } - else - { - var asx = Math.abs(transform.scaleX); - var asy = Math.abs(transform.scaleY); - - if (this._sx !== asx || this._sy !== asy) - { - this.width = this.sourceWidth * asx; - this.height = this.sourceHeight * asy; - this._sx = asx; - this._sy = asy; - recalc = true; - } - } - - if (recalc) - { - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - this.updateCenter(); - } - }, - - /** - * Updates the Body's `center` from its `position` and dimensions. - * - * @method Phaser.Physics.Arcade.Body#updateCenter - * @since 3.0.0 - */ - updateCenter: function () - { - this.center.set(this.position.x + this.halfWidth, this.position.y + this.halfHeight); - }, - - /** - * Updates the Body. - * - * @method Phaser.Physics.Arcade.Body#update - * @fires Phaser.Physics.Arcade.World#worldbounds + * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable * @since 3.0.0 * - * @param {number} delta - The delta time, in ms, elapsed since the last frame. - */ - update: function (delta) - { - // Store and reset collision flags - this.wasTouching.none = this.touching.none; - this.wasTouching.up = this.touching.up; - this.wasTouching.down = this.touching.down; - this.wasTouching.left = this.touching.left; - this.wasTouching.right = this.touching.right; - - this.touching.none = true; - this.touching.up = false; - this.touching.down = false; - this.touching.left = false; - this.touching.right = false; - - this.blocked.none = true; - this.blocked.up = false; - this.blocked.down = false; - this.blocked.left = false; - this.blocked.right = false; - - this.overlapR = 0; - this.overlapX = 0; - this.overlapY = 0; - - this.embedded = false; - - // Updates the transform values - this.updateBounds(); - - var sprite = this.transform; - - this.position.x = sprite.x + sprite.scaleX * (this.offset.x - sprite.displayOriginX); - this.position.y = sprite.y + sprite.scaleY * (this.offset.y - sprite.displayOriginY); - - this.updateCenter(); - - this.rotation = sprite.rotation; - - this.preRotation = this.rotation; - - if (this._reset) - { - this.prev.x = this.position.x; - this.prev.y = this.position.y; - } - - if (this.moves) - { - this.world.updateMotion(this, delta); - - var vx = this.velocity.x; - var vy = this.velocity.y; - - this.newVelocity.set(vx * delta, vy * delta); - - this.position.add(this.newVelocity); - - this.updateCenter(); - - this.angle = Math.atan2(vy, vx); - this.speed = Math.sqrt(vx * vx + vy * vy); - - // Now the State update will throw collision checks at the Body - // And finally we'll integrate the new position back to the Sprite in postUpdate - - if (this.collideWorldBounds && this.checkWorldBounds() && this.onWorldBounds) - { - this.world.emit('worldbounds', this, this.blocked.up, this.blocked.down, this.blocked.left, this.blocked.right); - } - } - - this._dx = this.deltaX(); - this._dy = this.deltaY(); - }, - - /** - * Feeds the Body results back into the parent Game Object. + * @param {boolean} [value=true] - [description] * - * @method Phaser.Physics.Arcade.Body#postUpdate - * @since 3.0.0 - * - * @param {boolean} resetDelta - Reset the delta properties? - */ - postUpdate: function () - { - this._dx = this.deltaX(); - this._dy = this.deltaY(); - - if (this.moves) - { - if (this.deltaMax.x !== 0 && this._dx !== 0) - { - if (this._dx < 0 && this._dx < -this.deltaMax.x) - { - this._dx = -this.deltaMax.x; - } - else if (this._dx > 0 && this._dx > this.deltaMax.x) - { - this._dx = this.deltaMax.x; - } - } - - if (this.deltaMax.y !== 0 && this._dy !== 0) - { - if (this._dy < 0 && this._dy < -this.deltaMax.y) - { - this._dy = -this.deltaMax.y; - } - else if (this._dy > 0 && this._dy > this.deltaMax.y) - { - this._dy = this.deltaMax.y; - } - } - - this.gameObject.x += this._dx; - this.gameObject.y += this._dy; - - this._reset = true; - } - - if (this._dx < 0) - { - this.facing = CONST.FACING_LEFT; - } - else if (this._dx > 0) - { - this.facing = CONST.FACING_RIGHT; - } - - if (this._dy < 0) - { - this.facing = CONST.FACING_UP; - } - else if (this._dy > 0) - { - this.facing = CONST.FACING_DOWN; - } - - if (this.allowRotation) - { - this.gameObject.angle += this.deltaZ(); - } - - this.prev.x = this.position.x; - this.prev.y = this.position.y; - }, - - /** - * Checks for collisions between this Body and the world boundary and separates them. - * - * @method Phaser.Physics.Arcade.Body#checkWorldBounds - * @since 3.0.0 - * - * @return {boolean} True if this Body is colliding with the world boundary. - */ - checkWorldBounds: function () - { - var pos = this.position; - var bounds = this.world.bounds; - var check = this.world.checkCollision; - - var bx = (this.worldBounce) ? -this.worldBounce.x : -this.bounce.x; - var by = (this.worldBounce) ? -this.worldBounce.y : -this.bounce.y; - - if (pos.x < bounds.x && check.left) - { - pos.x = bounds.x; - this.velocity.x *= bx; - this.blocked.left = true; - this.blocked.none = false; - } - else if (this.right > bounds.right && check.right) - { - pos.x = bounds.right - this.width; - this.velocity.x *= bx; - this.blocked.right = true; - this.blocked.none = false; - } - - if (pos.y < bounds.y && check.up) - { - pos.y = bounds.y; - this.velocity.y *= by; - this.blocked.up = true; - this.blocked.none = false; - } - else if (this.bottom > bounds.bottom && check.down) - { - pos.y = bounds.bottom - this.height; - this.velocity.y *= by; - this.blocked.down = true; - this.blocked.none = false; - } - - return !this.blocked.none; - }, - - /** - * Sets the offset of the Body's position from its Game Object's position. - * - * @method Phaser.Physics.Arcade.Body#setOffset - * @since 3.0.0 - * - * @param {number} x - The horizontal offset, in source pixels. - * @param {number} [y=x] - The vertical offset, in source pixels. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setOffset: function (x, y) - { - if (y === undefined) { y = x; } - - this.offset.set(x, y); - - return this; - }, - - /** - * Sizes and positions this Body's boundary, as a rectangle. - * Modifies the Body's `offset` if `center` is true (the default). - * - * @method Phaser.Physics.Arcade.Body#setSize - * @since 3.0.0 - * - * @param {number} width - The width of the Body, in source pixels. - * @param {number} height - The height of the Body, in source pixels. - * @param {boolean} [center=true] - Modify the Body's `offset`, placing the Body's center on its Game Object's center. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setSize: function (width, height, center) - { - if (center === undefined) { center = true; } - - var gameObject = this.gameObject; - - this.sourceWidth = width; - this.sourceHeight = height; - - this.width = this.sourceWidth * this._sx; - this.height = this.sourceHeight * this._sy; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.updateCenter(); - - if (center && gameObject.getCenter) - { - var ox = gameObject.displayWidth / 2; - var oy = gameObject.displayHeight / 2; - - this.offset.set(ox - this.halfWidth, oy - this.halfHeight); - } - - this.isCircle = false; - this.radius = 0; - - return this; - }, - - /** - * Sizes and positions this Body's boundary, as a circle. - * - * @method Phaser.Physics.Arcade.Body#setCircle - * @since 3.0.0 - * - * @param {number} radius - The radius of the Body, in source pixels. - * @param {number} [offsetX] - The horizontal offset of the Body from its Game Object, in source pixels. - * @param {number} [offsetY] - The vertical offset of the Body from its Game Object, in source pixels. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setCircle: function (radius, offsetX, offsetY) - { - if (offsetX === undefined) { offsetX = this.offset.x; } - if (offsetY === undefined) { offsetY = this.offset.y; } - - if (radius > 0) - { - this.isCircle = true; - this.radius = radius; - - this.sourceWidth = radius * 2; - this.sourceHeight = radius * 2; - - this.width = this.sourceWidth * this._sx; - this.height = this.sourceHeight * this._sy; - - this.halfWidth = Math.floor(this.width / 2); - this.halfHeight = Math.floor(this.height / 2); - - this.offset.set(offsetX, offsetY); - - this.updateCenter(); - } - else - { - this.isCircle = false; - } - - return this; - }, - - /** - * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. - * If the Body had any velocity or acceleration it is lost as a result of calling this. - * - * @method Phaser.Physics.Arcade.Body#reset - * @since 3.0.0 - * - * @param {number} x - The horizontal position to place the Game Object and Body. - * @param {number} y - The vertical position to place the Game Object and Body. - */ - reset: function (x, y) - { - this.stop(); - - var gameObject = this.gameObject; - - gameObject.setPosition(x, y); - - gameObject.getTopLeft(this.position); - - this.prev.copy(this.position); - - this.rotation = gameObject.angle; - this.preRotation = gameObject.angle; - - this.updateBounds(); - this.updateCenter(); - }, - - /** - * Sets acceleration, velocity, and speed to zero. - * - * @method Phaser.Physics.Arcade.Body#stop - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - stop: function () - { - this.velocity.set(0); - this.acceleration.set(0); - this.speed = 0; - this.angularVelocity = 0; - this.angularAcceleration = 0; - - return this; - }, - - /** - * Copies the coordinates of this Body's edges into an object. - * - * @method Phaser.Physics.Arcade.Body#getBounds - * @since 3.0.0 - * - * @param {ArcadeBodyBounds} obj - An object to copy the values into. - * - * @return {ArcadeBodyBounds} - An object with {x, y, right, bottom}. - */ - getBounds: function (obj) - { - obj.x = this.x; - obj.y = this.y; - obj.right = this.right; - obj.bottom = this.bottom; - - return obj; - }, - - /** - * Tests if the coordinates are within this Body's boundary. - * - * @method Phaser.Physics.Arcade.Body#hitTest - * @since 3.0.0 - * - * @param {number} x - The horizontal coordinate. - * @param {number} y - The vertical coordinate. - * - * @return {boolean} True if (x, y) is within this Body. - */ - hitTest: function (x, y) - { - return (this.isCircle) ? CircleContains(this, x, y) : RectangleContains(this, x, y); - }, - - /** - * Whether this Body is touching a tile or the world boundary while moving down. - * - * @method Phaser.Physics.Arcade.Body#onFloor - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#blocked - * - * @return {boolean} True if touching. - */ - onFloor: function () - { - return this.blocked.down; - }, - - /** - * Whether this Body is touching a tile or the world boundary while moving up. - * - * @method Phaser.Physics.Arcade.Body#onCeiling - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#blocked - * - * @return {boolean} True if touching. - */ - onCeiling: function () - { - return this.blocked.up; - }, - - /** - * Whether this Body is touching a tile or the world boundary while moving left or right. - * - * @method Phaser.Physics.Arcade.Body#onWall - * @since 3.0.0 - * @see Phaser.Physics.Arcade.Body#blocked - * - * @return {boolean} True if touching. - */ - onWall: function () - { - return (this.blocked.left || this.blocked.right); - }, - - /** - * The absolute (non-negative) change in this Body's horizontal position from the previous step. - * - * @method Phaser.Physics.Arcade.Body#deltaAbsX - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaAbsX: function () - { - return (this._dx > 0) ? this._dx : -this._dx; - }, - - /** - * The absolute (non-negative) change in this Body's vertical position from the previous step. - * - * @method Phaser.Physics.Arcade.Body#deltaAbsY - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaAbsY: function () - { - return (this._dy > 0) ? this._dy : -this._dy; - }, - - /** - * The change in this Body's horizontal position from the previous step. - * This value is set during the Body's update phase. - * - * @method Phaser.Physics.Arcade.Body#deltaX - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaX: function () - { - return this.position.x - this.prev.x; - }, - - /** - * The change in this Body's vertical position from the previous step. - * This value is set during the Body's update phase. - * - * @method Phaser.Physics.Arcade.Body#deltaY - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaY: function () - { - return this.position.y - this.prev.y; - }, - - /** - * The change in this Body's rotation from the previous step, in degrees. - * - * @method Phaser.Physics.Arcade.Body#deltaZ - * @since 3.0.0 - * - * @return {number} The delta value. - */ - deltaZ: function () - { - return this.rotation - this.preRotation; - }, - - /** - * Disables this Body and marks it for deletion by the simulation. - * - * @method Phaser.Physics.Arcade.Body#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.enable = false; - - this.world.pendingDestroy.set(this); - }, - - /** - * Draws this Body's boundary and velocity, if enabled. - * - * @method Phaser.Physics.Arcade.Body#drawDebug - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphic - The Graphics object to draw on. - */ - drawDebug: function (graphic) - { - var pos = this.position; - var x = pos.x + this.halfWidth; - var y = pos.y + this.halfHeight; - - if (this.debugShowBody) - { - graphic.lineStyle(1, this.debugBodyColor); - - if (this.isCircle) - { - graphic.strokeCircle(x, y, this.width / 2); - } - else - { - graphic.strokeRect(pos.x, pos.y, this.width, this.height); - } - } - - if (this.debugShowVelocity) - { - graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); - graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); - } - }, - - /** - * Whether this Body will be drawn to the debug display. - * - * @method Phaser.Physics.Arcade.Body#willDrawDebug - * @since 3.0.0 - * - * @return {boolean} True if either `debugShowBody` or `debugShowVelocity` are enabled. - */ - willDrawDebug: function () - { - return (this.debugShowBody || this.debugShowVelocity); - }, - - /** - * Sets whether this Body collides with the world boundary. - * - * @method Phaser.Physics.Arcade.Body#setCollideWorldBounds - * @since 3.0.0 - * - * @param {boolean} [value=true] - True (collisions) or false (no collisions). - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setCollideWorldBounds: function (value) - { - if (value === undefined) { value = true; } - - this.collideWorldBounds = value; - - return this; - }, - - /** - * Sets the Body's velocity. - * - * @method Phaser.Physics.Arcade.Body#setVelocity - * @since 3.0.0 - * - * @param {number} x - The horizontal velocity, in pixels per second. - * @param {number} [y=x] - The vertical velocity, in pixels per second. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setVelocity: function (x, y) - { - this.velocity.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal velocity. - * - * @method Phaser.Physics.Arcade.Body#setVelocityX - * @since 3.0.0 - * - * @param {number} value - The velocity, in pixels per second. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setVelocityX: function (value) - { - this.velocity.x = value; - - return this; - }, - - /** - * Sets the Body's vertical velocity. - * - * @method Phaser.Physics.Arcade.Body#setVelocityY - * @since 3.0.0 - * - * @param {number} value - The velocity, in pixels per second. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setVelocityY: function (value) - { - this.velocity.y = value; - - return this; - }, - - /** - * Sets the Body's maximum velocity. - * - * @method Phaser.Physics.Arcade.Body#setMaxVelocity - * @since 3.10.0 - * - * @param {number} x - The horizontal velocity, in pixels per second. - * @param {number} [y=x] - The vertical velocity, in pixels per second. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setMaxVelocity: function (x, y) - { - this.maxVelocity.set(x, y); - - return this; - }, - - /** - * Sets the Body's bounce. - * - * @method Phaser.Physics.Arcade.Body#setBounce - * @since 3.0.0 - * - * @param {number} x - The horizontal bounce, relative to 1. - * @param {number} y - The vertical bounce, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setBounce: function (x, y) - { - this.bounce.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal bounce. - * - * @method Phaser.Physics.Arcade.Body#setBounceX - * @since 3.0.0 - * - * @param {number} value - The bounce, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setBounceX: function (value) - { - this.bounce.x = value; - - return this; - }, - - /** - * Sets the Body's vertical bounce. - * - * @method Phaser.Physics.Arcade.Body#setBounceY - * @since 3.0.0 - * - * @param {number} value - The bounce, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setBounceY: function (value) - { - this.bounce.y = value; - - return this; - }, - - /** - * Sets the Body's acceleration. - * - * @method Phaser.Physics.Arcade.Body#setAcceleration - * @since 3.0.0 - * - * @param {number} x - The horizontal component, in pixels per second squared. - * @param {number} y - The vertical component, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAcceleration: function (x, y) - { - this.acceleration.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal acceleration. - * - * @method Phaser.Physics.Arcade.Body#setAccelerationX - * @since 3.0.0 - * - * @param {number} value - The acceleration, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAccelerationX: function (value) - { - this.acceleration.x = value; - - return this; - }, - - /** - * Sets the Body's vertical acceleration. - * - * @method Phaser.Physics.Arcade.Body#setAccelerationY - * @since 3.0.0 - * - * @param {number} value - The acceleration, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAccelerationY: function (value) - { - this.acceleration.y = value; - - return this; - }, - - /** - * Enables or disables drag. - * - * @method Phaser.Physics.Arcade.Body#setAllowDrag - * @since 3.9.0 - * @see Phaser.Physics.Arcade.Body#allowDrag - * - * @param {boolean} [value=true] - `true` to allow drag on this body, or `false` to disable it. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAllowDrag: function (value) - { - if (value === undefined) { value = true; } - - this.allowDrag = value; - - return this; - }, - - /** - * Enables or disables gravity's effect on this Body. - * - * @method Phaser.Physics.Arcade.Body#setAllowGravity - * @since 3.9.0 - * @see Phaser.Physics.Arcade.Body#allowGravity - * - * @param {boolean} [value=true] - `true` to allow gravity on this body, or `false` to disable it. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAllowGravity: function (value) - { - if (value === undefined) { value = true; } - - this.allowGravity = value; - - return this; - }, - - /** - * Enables or disables rotation. - * - * @method Phaser.Physics.Arcade.Body#setAllowRotation - * @since 3.9.0 - * @see Phaser.Physics.Arcade.Body#allowRotation - * - * @param {boolean} [value=true] - `true` to allow rotation on this body, or `false` to disable it. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAllowRotation: function (value) - { - if (value === undefined) { value = true; } - - this.allowRotation = value; - - return this; - }, - - /** - * Sets the Body's drag. - * - * @method Phaser.Physics.Arcade.Body#setDrag - * @since 3.0.0 - * - * @param {number} x - The horizontal component, in pixels per second squared. - * @param {number} y - The vertical component, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDrag: function (x, y) - { - this.drag.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal drag. - * - * @method Phaser.Physics.Arcade.Body#setDragX - * @since 3.0.0 - * - * @param {number} value - The drag, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDragX: function (value) - { - this.drag.x = value; - - return this; - }, - - /** - * Sets the Body's vertical drag. - * - * @method Phaser.Physics.Arcade.Body#setDragY - * @since 3.0.0 - * - * @param {number} value - The drag, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setDragY: function (value) - { - this.drag.y = value; - - return this; - }, - - /** - * Sets the Body's gravity. - * - * @method Phaser.Physics.Arcade.Body#setGravity - * @since 3.0.0 - * - * @param {number} x - The horizontal component, in pixels per second squared. - * @param {number} y - The vertical component, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravity: function (x, y) - { - this.gravity.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal gravity. - * - * @method Phaser.Physics.Arcade.Body#setGravityX - * @since 3.0.0 - * - * @param {number} value - The gravity, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravityX: function (value) - { - this.gravity.x = value; - - return this; - }, - - /** - * Sets the Body's vertical gravity. - * - * @method Phaser.Physics.Arcade.Body#setGravityY - * @since 3.0.0 - * - * @param {number} value - The gravity, in pixels per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setGravityY: function (value) - { - this.gravity.y = value; - - return this; - }, - - /** - * Sets the Body's friction. - * - * @method Phaser.Physics.Arcade.Body#setFriction - * @since 3.0.0 - * - * @param {number} x - The horizontal component, relative to 1. - * @param {number} y - The vertical component, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFriction: function (x, y) - { - this.friction.set(x, y); - - return this; - }, - - /** - * Sets the Body's horizontal friction. - * - * @method Phaser.Physics.Arcade.Body#setFrictionX - * @since 3.0.0 - * - * @param {number} value - The friction value, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFrictionX: function (value) - { - this.friction.x = value; - - return this; - }, - - /** - * Sets the Body's vertical friction. - * - * @method Phaser.Physics.Arcade.Body#setFrictionY - * @since 3.0.0 - * - * @param {number} value - The friction value, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setFrictionY: function (value) - { - this.friction.y = value; - - return this; - }, - - /** - * Sets the Body's angular velocity. - * - * @method Phaser.Physics.Arcade.Body#setAngularVelocity - * @since 3.0.0 - * - * @param {number} value - The velocity, in degrees per second. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularVelocity: function (value) - { - this.angularVelocity = value; - - return this; - }, - - /** - * Sets the Body's angular acceleration. - * - * @method Phaser.Physics.Arcade.Body#setAngularAcceleration - * @since 3.0.0 - * - * @param {number} value - The acceleration, in degrees per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularAcceleration: function (value) - { - this.angularAcceleration = value; - - return this; - }, - - /** - * Sets the Body's angular drag. - * - * @method Phaser.Physics.Arcade.Body#setAngularDrag - * @since 3.0.0 - * - * @param {number} value - The drag, in degrees per second squared. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setAngularDrag: function (value) - { - this.angularDrag = value; - - return this; - }, - - /** - * Sets the Body's mass. - * - * @method Phaser.Physics.Arcade.Body#setMass - * @since 3.0.0 - * - * @param {number} value - The mass value, relative to 1. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. - */ - setMass: function (value) - { - this.mass = value; - - return this; - }, - - /** - * Sets the Body's `immovable` property. - * - * @method Phaser.Physics.Arcade.Body#setImmovable - * @since 3.0.0 - * - * @param {boolean} [value=true] - The value to assign to `immovable`. - * - * @return {Phaser.Physics.Arcade.Body} This Body object. + * @return {this} This Game Object. */ setImmovable: function (value) { if (value === undefined) { value = true; } - this.immovable = value; + this.body.immovable = value; + + return this; + } + +}; + +module.exports = Immovable; + + +/***/ }), +/* 519 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods for setting the gravity properties of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.Physics.Arcade.Components.Gravity + * @since 3.0.0 + */ +var Gravity = { + + /** + * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. + * + * If only one value is provided, this value will be used for both the X and Y axis. + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravity + * @since 3.0.0 + * + * @param {number} x - The gravitational force to be applied to the X-axis. + * @param {number} [y=x] - The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. + * + * @return {this} This Game Object. + */ + setGravity: function (x, y) + { + this.body.gravity.set(x, y); return this; }, /** - * The Body's horizontal position (left edge). + * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. * - * @name Phaser.Physics.Arcade.Body#x - * @type {number} + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX + * @since 3.0.0 + * + * @param {number} x - The gravitational force to be applied to the X-axis. + * + * @return {this} This Game Object. + */ + setGravityX: function (x) + { + this.body.gravity.x = x; + + return this; + }, + + /** + * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. + * + * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY + * @since 3.0.0 + * + * @param {number} y - The gravitational force to be applied to the Y-axis. + * + * @return {this} This Game Object. + */ + setGravityY: function (y) + { + this.body.gravity.y = y; + + return this; + } + +}; + +module.exports = Gravity; + + +/***/ }), +/* 520 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @name Phaser.Physics.Arcade.Components.Friction + * @since 3.0.0 + */ +var Friction = { + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @method Phaser.Physics.Arcade.Components.Friction#setFriction + * @since 3.0.0 + * + * @param {number} x - The amount of horizontal friction to apply. + * @param {number} [y=x] - The amount of vertical friction to apply. + * + * @return {this} This Game Object. + */ + setFriction: function (x, y) + { + this.body.friction.set(x, y); + + return this; + }, + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX + * @since 3.0.0 + * + * @param {number} x - The amount of friction to apply. + * + * @return {this} This Game Object. + */ + setFrictionX: function (x) + { + this.body.friction.x = x; + + return this; + }, + + /** + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * + * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY + * @since 3.0.0 + * + * @param {number} x - The amount of friction to apply. + * + * @return {this} This Game Object. + */ + setFrictionY: function (y) + { + this.body.friction.y = y; + + return this; + } + +}; + +module.exports = Friction; + + +/***/ }), +/* 521 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Enable + * @since 3.0.0 + */ +var Enable = { + + /** + * Enables this Game Object's Body. + * + * @method Phaser.Physics.Arcade.Components.Enable#enableBody + * @since 3.0.0 + * + * @param {boolean} reset - Also reset the Body and place it at (x, y). + * @param {number} x - The horizontal position to place the Game Object and Body. + * @param {number} y - The horizontal position to place the Game Object and Body. + * @param {boolean} enableGameObject - Also activate this Game Object. + * @param {boolean} showGameObject - Also show this Game Object. + * + * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.Body#enable + * @see Phaser.Physics.Arcade.StaticBody#enable + * @see Phaser.Physics.Arcade.Body#reset + * @see Phaser.Physics.Arcade.StaticBody#reset + * @see Phaser.GameObjects.GameObject#active + * @see Phaser.GameObjects.GameObject#visible + */ + enableBody: function (reset, x, y, enableGameObject, showGameObject) + { + if (reset) + { + this.body.reset(x, y); + } + + if (enableGameObject) + { + this.body.gameObject.active = true; + } + + if (showGameObject) + { + this.body.gameObject.visible = true; + } + + this.body.enable = true; + + return this; + }, + + /** + * Stops and disables this Game Object's Body. + * + * @method Phaser.Physics.Arcade.Components.Enable#disableBody + * @since 3.0.0 + * + * @param {boolean} [disableGameObject=false] - Also deactivate this Game Object. + * @param {boolean} [hideGameObject=false] - Also hide this Game Object. + * + * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.Body#enable + * @see Phaser.Physics.Arcade.StaticBody#enable + * @see Phaser.GameObjects.GameObject#active + * @see Phaser.GameObjects.GameObject#visible + */ + disableBody: function (disableGameObject, hideGameObject) + { + if (disableGameObject === undefined) { disableGameObject = false; } + if (hideGameObject === undefined) { hideGameObject = false; } + + this.body.stop(); + + this.body.enable = false; + + if (disableGameObject) + { + this.body.gameObject.active = false; + } + + if (hideGameObject) + { + this.body.gameObject.visible = false; + } + + return this; + }, + + /** + * Syncs the Body's position and size with its parent Game Object. + * You don't need to call this for Dynamic Bodies, as it happens automatically. + * But for Static bodies it's a useful way of modifying the position of a Static Body + * in the Physics World, based on its Game Object. + * + * @method Phaser.Physics.Arcade.Components.Enable#refreshBody + * @since 3.1.0 + * + * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject + */ + refreshBody: function () + { + this.body.updateFromGameObject(); + + return this; + } + +}; + +module.exports = Enable; + + +/***/ }), +/* 522 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Drag + * @since 3.0.0 + */ +var Drag = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDrag + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. + */ + setDrag: function (x, y) + { + this.body.drag.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setDragX: function (value) + { + this.body.drag.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDragY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setDragY: function (value) + { + this.body.drag.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Drag#setDamping + * @since 3.10.0 + * + * @param {boolean} value - `true` to use damping for deceleration, or `false` to use linear deceleration. + * + * @return {this} This Game Object. + */ + setDamping: function (value) + { + this.body.useDamping = value; + + return this; + } + +}; + +module.exports = Drag; + + +/***/ }), +/* 523 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug + * @since 3.0.0 + */ +var Debug = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebug + * @since 3.0.0 + * + * @param {boolean} showBody - [description] + * @param {boolean} showVelocity - [description] + * @param {number} bodyColor - [description] + * + * @return {this} This Game Object. + */ + setDebug: function (showBody, showVelocity, bodyColor) + { + this.debugShowBody = showBody; + this.debugShowVelocity = showVelocity; + this.debugBodyColor = bodyColor; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setDebugBodyColor: function (value) + { + this.body.debugBodyColor = value; + + return this; + }, + + /** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody + * @type {boolean} * @since 3.0.0 */ - x: { + debugShowBody: { get: function () { - return this.position.x; + return this.body.debugShowBody; }, set: function (value) { - this.position.x = value; + this.body.debugShowBody = value; } }, /** - * The Body's vertical position (top edge). + * [description] * - * @name Phaser.Physics.Arcade.Body#y - * @type {number} + * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity + * @type {boolean} * @since 3.0.0 */ - y: { + debugShowVelocity: { get: function () { - return this.position.y; + return this.body.debugShowVelocity; }, set: function (value) { - this.position.y = value; + this.body.debugShowVelocity = value; } }, /** - * The left edge of the Body's boundary. Identical to x. + * [description] * - * @name Phaser.Physics.Arcade.Body#left + * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor * @type {number} - * @readOnly * @since 3.0.0 */ - left: { + debugBodyColor: { get: function () { - return this.position.x; - } + return this.body.debugBodyColor; + }, - }, - - /** - * The right edge of the Body's boundary. - * - * @name Phaser.Physics.Arcade.Body#right - * @type {number} - * @readOnly - * @since 3.0.0 - */ - right: { - - get: function () + set: function (value) { - return this.position.x + this.width; - } - - }, - - /** - * The top edge of the Body's boundary. Identical to y. - * - * @name Phaser.Physics.Arcade.Body#top - * @type {number} - * @readOnly - * @since 3.0.0 - */ - top: { - - get: function () - { - return this.position.y; - } - - }, - - /** - * The bottom edge of this Body's boundary. - * - * @name Phaser.Physics.Arcade.Body#bottom - * @type {number} - * @readOnly - * @since 3.0.0 - */ - bottom: { - - get: function () - { - return this.position.y + this.height; + this.body.debugBodyColor = value; } } -}); +}; -module.exports = Body; +module.exports = Debug; /***/ }), -/* 340 */ +/* 524 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Bounce + * @since 3.0.0 + */ +var Bounce = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounce + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {this} This Game Object. + */ + setBounce: function (x, y) + { + this.body.bounce.set(x, y); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setBounceX: function (value) + { + this.body.bounce.x = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setBounceY: function (value) + { + this.body.bounce.y = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {this} This Game Object. + */ + setCollideWorldBounds: function (value) + { + this.body.collideWorldBounds = value; + + return this; + } + +}; + +module.exports = Bounce; + + +/***/ }), +/* 525 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @name Phaser.Physics.Arcade.Components.Angular + * @since 3.0.0 + */ +var Angular = { + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setAngularVelocity: function (value) + { + this.body.angularVelocity = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setAngularAcceleration: function (value) + { + this.body.angularAcceleration = value; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {this} This Game Object. + */ + setAngularDrag: function (value) + { + this.body.angularDrag = value; + + return this; + } + +}; + +module.exports = Angular; + + +/***/ }), +/* 526 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the acceleration properties of an Arcade Body. + * + * @name Phaser.Physics.Arcade.Components.Acceleration + * @since 3.0.0 + */ +var Acceleration = { + + /** + * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration + * @since 3.0.0 + * + * @param {number} x - The horizontal acceleration + * @param {number} [y=x] - The vertical acceleration + * + * @return {this} This Game Object. + */ + setAcceleration: function (x, y) + { + this.body.acceleration.set(x, y); + + return this; + }, + + /** + * Sets the body's horizontal acceleration. + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX + * @since 3.0.0 + * + * @param {number} value - The horizontal acceleration + * + * @return {this} This Game Object. + */ + setAccelerationX: function (value) + { + this.body.acceleration.x = value; + + return this; + }, + + /** + * Sets the body's vertical acceleration. + * + * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY + * @since 3.0.0 + * + * @param {number} value - The vertical acceleration + * + * @return {this} This Game Object. + */ + setAccelerationY: function (value) + { + this.body.acceleration.y = value; + + return this; + } + +}; + +module.exports = Acceleration; + + +/***/ }), +/* 527 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -84357,1726 +110672,162 @@ module.exports = Body; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Body = __webpack_require__(339); -var Clamp = __webpack_require__(23); var Class = __webpack_require__(0); -var Collider = __webpack_require__(338); -var CONST = __webpack_require__(42); -var DistanceBetween = __webpack_require__(58); -var EventEmitter = __webpack_require__(9); -var FuzzyEqual = __webpack_require__(351); -var FuzzyGreaterThan = __webpack_require__(350); -var FuzzyLessThan = __webpack_require__(349); -var GetOverlapX = __webpack_require__(337); -var GetOverlapY = __webpack_require__(336); -var GetValue = __webpack_require__(4); -var ProcessQueue = __webpack_require__(223); -var ProcessTileCallbacks = __webpack_require__(689); -var Rectangle = __webpack_require__(14); -var RTree = __webpack_require__(222); -var SeparateTile = __webpack_require__(688); -var SeparateX = __webpack_require__(683); -var SeparateY = __webpack_require__(682); -var Set = __webpack_require__(70); -var StaticBody = __webpack_require__(334); -var TileIntersectsBody = __webpack_require__(335); -var Vector2 = __webpack_require__(6); -var Wrap = __webpack_require__(39); - -/** - * @event Phaser.Physics.Arcade.World#pause - */ - -/** - * @event Phaser.Physics.Arcade.World#resume - */ - -/** - * @event Phaser.Physics.Arcade.World#collide - * @param {Phaser.GameObjects.GameObject} gameObject1 - * @param {Phaser.GameObjects.GameObject} gameObject2 - * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 - * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 - */ - -/** - * @event Phaser.Physics.Arcade.World#overlap - * @param {Phaser.GameObjects.GameObject} gameObject1 - * @param {Phaser.GameObjects.GameObject} gameObject2 - * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 - * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 - */ - -/** - * @event Phaser.Physics.Arcade.World#worldbounds - * @param {Phaser.Physics.Arcade.Body} body - * @param {boolean} up - * @param {boolean} down - * @param {boolean} left - * @param {boolean} right - */ - -/** - * @typedef {object} ArcadeWorldConfig - * - * @property {number} [fps=60] - Sets {@link Phaser.Physics.Arcade.World#fps}. - * @property {number} [timeScale=1] - Sets {@link Phaser.Physics.Arcade.World#timeScale}. - * @property {object} [gravity] - Sets {@link Phaser.Physics.Arcade.World#gravity}. - * @property {number} [gravity.x=0] - The horizontal world gravity value. - * @property {number} [gravity.y=0] - The vertical world gravity value. - * @property {number} [x=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.x}. - * @property {number} [y=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.y}. - * @property {number} [width=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.width}. - * @property {number} [height=0] - Sets {@link Phaser.Physics.Arcade.World#bounds bounds.height}. - * @property {object} [checkCollision] - Sets {@link Phaser.Physics.Arcade.World#checkCollision}. - * @property {boolean} [checkCollision.up=true] - Should bodies collide with the top of the world bounds? - * @property {boolean} [checkCollision.down=true] - Should bodies collide with the bottom of the world bounds? - * @property {boolean} [checkCollision.left=true] - Should bodies collide with the left of the world bounds? - * @property {boolean} [checkCollision.right=true] - Should bodies collide with the right of the world bounds? - * @property {number} [overlapBias=4] - Sets {@link Phaser.Physics.Arcade.World#OVERLAP_BIAS}. - * @property {number} [tileBias=16] - Sets {@link Phaser.Physics.Arcade.World#TILE_BIAS}. - * @property {boolean} [forceX=false] - Sets {@link Phaser.Physics.Arcade.World#forceX}. - * @property {boolean} [isPaused=false] - Sets {@link Phaser.Physics.Arcade.World#isPaused}. - * @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Arcade.World#debug}. - * @property {boolean} [debugShowBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowBody}. - * @property {boolean} [debugShowStaticBody=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. - * @property {boolean} [debugShowVelocity=true] - Sets {@link Phaser.Physics.Arcade.World#defaults debugShowStaticBody}. - * @property {number} [debugBodyColor=0xff00ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugBodyColor}. - * @property {number} [debugStaticBodyColor=0x0000ff] - Sets {@link Phaser.Physics.Arcade.World#defaults debugStaticBodyColor}. - * @property {number} [debugVelocityColor=0x00ff00] - Sets {@link Phaser.Physics.Arcade.World#defaults debugVelocityColor}. - * @property {number} [maxEntries=16] - Sets {@link Phaser.Physics.Arcade.World#maxEntries}. - * @property {boolean} [useTree=true] - Sets {@link Phaser.Physics.Arcade.World#useTree}. - */ - -/** - * @typedef {object} CheckCollisionObject - * - * @property {boolean} up - [description] - * @property {boolean} down - [description] - * @property {boolean} left - [description] - * @property {boolean} right - [description] - */ - -/** - * @typedef {object} ArcadeWorldDefaults - * - * @property {boolean} debugShowBody - [description] - * @property {boolean} debugShowStaticBody - [description] - * @property {boolean} debugShowVelocity - [description] - * @property {number} bodyDebugColor - [description] - * @property {number} staticBodyDebugColor - [description] - * @property {number} velocityDebugColor - [description] - */ - -/** - * @typedef {object} ArcadeWorldTreeMinMax - * - * @property {number} minX - [description] - * @property {number} minY - [description] - * @property {number} maxX - [description] - * @property {number} maxY - [description] - */ - -/** - * An Arcade Physics Collider Type. - * - * @typedef {( - * Phaser.GameObjects.GameObject| - * Phaser.GameObjects.Group| - * Phaser.Physics.Arcade.Sprite| - * Phaser.Physics.Arcade.Image| - * Phaser.Physics.Arcade.StaticGroup| - * Phaser.Physics.Arcade.Group| - * Phaser.Tilemaps.DynamicTilemapLayer| - * Phaser.Tilemaps.StaticTilemapLayer| - * Phaser.GameObjects.GameObject[]| - * Phaser.Physics.Arcade.Sprite[]| - * Phaser.Physics.Arcade.Image[]| - * Phaser.Physics.Arcade.StaticGroup[]| - * Phaser.Physics.Arcade.Group[]| - * Phaser.Tilemaps.DynamicTilemapLayer[]| - * Phaser.Tilemaps.StaticTilemapLayer[] - * )} ArcadeColliderType - */ +var DegToRad = __webpack_require__(31); +var DistanceBetween = __webpack_require__(52); +var DistanceSquared = __webpack_require__(249); +var Factory = __webpack_require__(238); +var GetFastValue = __webpack_require__(2); +var Merge = __webpack_require__(96); +var PluginCache = __webpack_require__(15); +var Vector2 = __webpack_require__(3); +var World = __webpack_require__(233); /** * @classdesc - * The Arcade Physics World. + * The Arcade Physics Plugin belongs to a Scene and sets up and manages the Scene's physics simulation. + * It also holds some useful methods for moving and rotating Arcade Physics Bodies. * - * The World is responsible for creating, managing, colliding and updating all of the bodies within it. + * You can access it from within a Scene using `this.physics`. * - * An instance of the World belongs to a Phaser.Scene and is accessed via the property `physics.world`. - * - * @class World - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Physics.Arcade + * @class ArcadePhysics + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - The Scene to which this World instance belongs. - * @param {ArcadeWorldConfig} config - An Arcade Physics Configuration object. + * @param {Phaser.Scene} scene - The Scene that this Plugin belongs to. */ -var World = new Class({ - - Extends: EventEmitter, +var ArcadePhysics = new Class({ initialize: - function World (scene, config) + function ArcadePhysics (scene) { - EventEmitter.call(this); - /** - * The Scene this simulation belongs to. + * The Scene that this Plugin belongs to. * - * @name Phaser.Physics.Arcade.World#scene + * @name Phaser.Physics.Arcade.ArcadePhysics#scene * @type {Phaser.Scene} * @since 3.0.0 */ this.scene = scene; /** - * Dynamic Bodies in this simulation. + * The Scene's Systems. * - * @name Phaser.Physics.Arcade.World#bodies - * @type {Phaser.Structs.Set.} + * @name Phaser.Physics.Arcade.ArcadePhysics#systems + * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ - this.bodies = new Set(); + this.systems = scene.sys; /** - * Static Bodies in this simulation. + * A configuration object. Union of the `physics.arcade.*` properties of the GameConfig and SceneConfig objects. * - * @name Phaser.Physics.Arcade.World#staticBodies - * @type {Phaser.Structs.Set.} + * @name Phaser.Physics.Arcade.ArcadePhysics#config + * @type {object} * @since 3.0.0 */ - this.staticBodies = new Set(); + this.config = this.getConfig(); /** - * Static Bodies marked for deletion. + * The physics simulation. * - * @name Phaser.Physics.Arcade.World#pendingDestroy - * @type {Phaser.Structs.Set.<(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)>} - * @since 3.1.0 - */ - this.pendingDestroy = new Set(); - - /** - * This simulation's collision processors. - * - * @name Phaser.Physics.Arcade.World#colliders - * @type {Phaser.Structs.ProcessQueue.} + * @name Phaser.Physics.Arcade.ArcadePhysics#world + * @type {Phaser.Physics.Arcade.World} * @since 3.0.0 */ - this.colliders = new ProcessQueue(); + this.world; /** - * Acceleration of Bodies due to gravity, in pixels per second. + * An object holding the Arcade Physics factory methods. * - * @name Phaser.Physics.Arcade.World#gravity - * @type {Phaser.Math.Vector2} + * @name Phaser.Physics.Arcade.ArcadePhysics#add + * @type {Phaser.Physics.Arcade.Factory} * @since 3.0.0 */ - this.gravity = new Vector2(GetValue(config, 'gravity.x', 0), GetValue(config, 'gravity.y', 0)); + this.add; - /** - * A boundary constraining Bodies. - * - * @name Phaser.Physics.Arcade.World#bounds - * @type {Phaser.Geom.Rectangle} - * @since 3.0.0 - */ - this.bounds = new Rectangle( - GetValue(config, 'x', 0), - GetValue(config, 'y', 0), - GetValue(config, 'width', scene.sys.game.config.width), - GetValue(config, 'height', scene.sys.game.config.height) + scene.sys.events.once('boot', this.boot, this); + scene.sys.events.on('start', this.start, this); + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.world = new World(this.scene, this.config); + this.add = new Factory(this.world); + + this.systems.events.once('destroy', this.destroy, 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 () + { + if (!this.world) + { + 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); + }, + + /** + * Creates the physics configuration for the current Scene. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig + * @since 3.0.0 + * + * @return {object} The physics configuration. + */ + getConfig: function () + { + var gameConfig = this.systems.game.config.physics; + var sceneConfig = this.systems.settings.physics; + + var config = Merge( + GetFastValue(sceneConfig, 'arcade', {}), + GetFastValue(gameConfig, 'arcade', {}) ); - /** - * The boundary edges that Bodies can collide with. - * - * @name Phaser.Physics.Arcade.World#checkCollision - * @type {CheckCollisionObject} - * @since 3.0.0 - */ - this.checkCollision = { - up: GetValue(config, 'checkCollision.up', true), - down: GetValue(config, 'checkCollision.down', true), - left: GetValue(config, 'checkCollision.left', true), - right: GetValue(config, 'checkCollision.right', true) - }; - - /** - * The number of physics steps to be taken per second. - * - * This property is read-only. Use the `setFPS` method to modify it at run-time. - * - * @name Phaser.Physics.Arcade.World#fps - * @readOnly - * @type {number} - * @default 60 - * @since 3.10.0 - */ - this.fps = GetValue(config, 'fps', 60); - - /** - * The amount of elapsed ms since the last frame. - * - * @name Phaser.Physics.Arcade.World#_elapsed - * @private - * @type {number} - * @since 3.10.0 - */ - this._elapsed = 0; - - /** - * Internal frame time value. - * - * @name Phaser.Physics.Arcade.World#_frameTime - * @private - * @type {number} - * @since 3.10.0 - */ - this._frameTime = 1 / this.fps; - - /** - * Internal frame time ms value. - * - * @name Phaser.Physics.Arcade.World#_frameTimeMS - * @private - * @type {number} - * @since 3.10.0 - */ - this._frameTimeMS = 1000 * this._frameTime; - - /** - * The number of steps that took place in the last frame. - * - * @name Phaser.Physics.Arcade.World#stepsLastFrame - * @readOnly - * @type {number} - * @since 3.10.0 - */ - this.stepsLastFrame = 0; - - /** - * Scaling factor applied to the frame rate. - * - * - 1.0 = normal speed - * - 2.0 = half speed - * - 0.5 = double speed - * - * @name Phaser.Physics.Arcade.World#timeScale - * @property {number} - * @default 1 - * @since 3.10.0 - */ - this.timeScale = GetValue(config, 'timeScale', 1); - - /** - * The maximum absolute difference of a Body's per-step velocity and its overlap with another Body that will result in separation on *each axis*. - * Larger values favor separation. - * Smaller values favor no separation. - * - * @name Phaser.Physics.Arcade.World#OVERLAP_BIAS - * @type {number} - * @default 4 - * @since 3.0.0 - */ - this.OVERLAP_BIAS = GetValue(config, 'overlapBias', 4); - - /** - * The maximum absolute value of a Body's overlap with a tile that will result in separation on *each axis*. - * Larger values favor separation. - * Smaller values favor no separation. - * The optimum value may be similar to the tile size. - * - * @name Phaser.Physics.Arcade.World#TILE_BIAS - * @type {number} - * @default 16 - * @since 3.0.0 - */ - this.TILE_BIAS = GetValue(config, 'tileBias', 16); - - /** - * Always separate overlapping Bodies horizontally before vertically. - * False (the default) means Bodies are first separated on the axis of greater gravity, or the vertical axis if neither is greater. - * - * @name Phaser.Physics.Arcade.World#forceX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.forceX = GetValue(config, 'forceX', false); - - /** - * Whether the simulation advances with the game loop. - * - * @name Phaser.Physics.Arcade.World#isPaused - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.isPaused = GetValue(config, 'isPaused', false); - - /** - * Temporary total of colliding Bodies. - * - * @name Phaser.Physics.Arcade.World#_total - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._total = 0; - - /** - * Enables the debug display. - * - * @name Phaser.Physics.Arcade.World#drawDebug - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.drawDebug = GetValue(config, 'debug', false); - - /** - * The graphics object drawing the debug display. - * - * @name Phaser.Physics.Arcade.World#debugGraphic - * @type {Phaser.GameObjects.Graphics} - * @since 3.0.0 - */ - this.debugGraphic; - - /** - * Default debug display settings for new Bodies. - * - * @name Phaser.Physics.Arcade.World#defaults - * @type {ArcadeWorldDefaults} - * @since 3.0.0 - */ - this.defaults = { - debugShowBody: GetValue(config, 'debugShowBody', true), - debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), - debugShowVelocity: GetValue(config, 'debugShowVelocity', true), - bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), - staticBodyDebugColor: GetValue(config, 'debugStaticBodyColor', 0x0000ff), - velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00) - }; - - /** - * The maximum number of items per node on the RTree. - * - * This is ignored if `useTree` is `false`. If you have a large number of bodies in - * your world then you may find search performance improves by increasing this value, - * to allow more items per node and less node division. - * - * @name Phaser.Physics.Arcade.World#maxEntries - * @type {integer} - * @default 16 - * @since 3.0.0 - */ - this.maxEntries = GetValue(config, 'maxEntries', 16); - - /** - * Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not? - * - * An RTree is a fast way of spatially sorting of all the moving bodies in the world. - * However, at certain limits, the cost of clearing and inserting the bodies into the - * tree every frame becomes more expensive than the search speed gains it provides. - * - * If you have a large number of dynamic bodies in your world then it may be best to - * disable the use of the RTree by setting this property to `true`. - * The number it can cope with depends on browser and device, but a conservative estimate - * of around 5,000 bodies should be considered the max before disabling it. - * - * Note this only applies to dynamic bodies. Static bodies are always kept in an RTree, - * because they don't have to be cleared every frame, so you benefit from the - * massive search speeds all the time. - * - * @name Phaser.Physics.Arcade.World#useTree - * @type {boolean} - * @default true - * @since 3.10.0 - */ - this.useTree = GetValue(config, 'useTree', true); - - /** - * The spatial index of Dynamic Bodies. - * - * @name Phaser.Physics.Arcade.World#tree - * @type {Phaser.Structs.RTree} - * @since 3.0.0 - */ - this.tree = new RTree(this.maxEntries); - - /** - * The spatial index of Static Bodies. - * - * @name Phaser.Physics.Arcade.World#staticTree - * @type {Phaser.Structs.RTree} - * @since 3.0.0 - */ - this.staticTree = new RTree(this.maxEntries); - - /** - * Recycled input for tree searches. - * - * @name Phaser.Physics.Arcade.World#treeMinMax - * @type {ArcadeWorldTreeMinMax} - * @since 3.0.0 - */ - this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; - - if (this.drawDebug) - { - this.createDebugGraphic(); - } + return config; }, /** - * Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group. - * - * The difference between this and the `enableBody` method is that you can pass arrays or Groups - * to this method. + * Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap} * - * You can specify if the bodies are to be Dynamic or Static. A dynamic body can move via velocity and - * acceleration. A static body remains fixed in place and as such is able to use an optimized search - * tree, making it ideal for static elements such as level objects. You can still collide and overlap - * with static bodies. - * - * Normally, rather than calling this method directly, you'd use the helper methods available in the - * Arcade Physics Factory, such as: - * - * ```javascript - * this.physics.add.image(x, y, textureKey); - * this.physics.add.sprite(x, y, textureKey); - * ``` - * - * Calling factory methods encapsulates the creation of a Game Object and the creation of its - * body at the same time. If you are creating custom classes then you can pass them to this - * method to have their bodies created. - * - * @method Phaser.Physics.Arcade.World#enable + * @method Phaser.Physics.Arcade.ArcadePhysics#overlap * @since 3.0.0 * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to create the bodies. - * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. - */ - enable: function (object, bodyType) - { - if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } - - if (!Array.isArray(object)) - { - object = [ object ]; - } - - for (var i = 0; i < object.length; i++) - { - var entry = object[i]; - - if (entry.isParent) - { - var children = entry.getChildren(); - - for (var c = 0; c < children.length; c++) - { - var child = children[c]; - - if (child.isParent) - { - // Handle Groups nested inside of Groups - this.enable(child, bodyType); - } - else - { - this.enableBody(child, bodyType); - } - } - } - else - { - this.enableBody(entry, bodyType); - } - } - }, - - /** - * Creates an Arcade Physics Body on a single Game Object. - * - * If the Game Object already has a body, this method will simply add it back into the simulation. - * - * You can specify if the body is Dynamic or Static. A dynamic body can move via velocity and - * acceleration. A static body remains fixed in place and as such is able to use an optimized search - * tree, making it ideal for static elements such as level objects. You can still collide and overlap - * with static bodies. - * - * Normally, rather than calling this method directly, you'd use the helper methods available in the - * Arcade Physics Factory, such as: - * - * ```javascript - * this.physics.add.image(x, y, textureKey); - * this.physics.add.sprite(x, y, textureKey); - * ``` - * - * Calling factory methods encapsulates the creation of a Game Object and the creation of its - * body at the same time. If you are creating custom classes then you can pass them to this - * method to have their bodies created. - * - * @method Phaser.Physics.Arcade.World#enableBody - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} object - The Game Object on which to create the body. - * @param {integer} [bodyType] - The type of Body to create. Either `DYNAMIC_BODY` or `STATIC_BODY`. - * - * @return {Phaser.GameObjects.GameObject} The Game Object on which the body was created. - */ - enableBody: function (object, bodyType) - { - if (bodyType === undefined) { bodyType = CONST.DYNAMIC_BODY; } - - if (!object.body) - { - if (bodyType === CONST.DYNAMIC_BODY) - { - object.body = new Body(this, object); - } - else if (bodyType === CONST.STATIC_BODY) - { - object.body = new StaticBody(this, object); - } - } - - this.add(object.body); - - return object; - }, - - /** - * Adds an existing Arcade Physics Body or StaticBody to the simulation. - * - * The body is enabled and added to the local search trees. - * - * @method Phaser.Physics.Arcade.World#add - * @since 3.10.0 - * - * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be added to the simulation. - * - * @return {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} The Body that was added to the simulation. - */ - add: function (body) - { - if (body.physicsType === CONST.DYNAMIC_BODY) - { - this.bodies.set(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - this.staticBodies.set(body); - - this.staticTree.insert(body); - } - - body.enable = true; - - return body; - }, - - /** - * Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group. - * - * The difference between this and the `disableBody` method is that you can pass arrays or Groups - * to this method. - * - * The body itself is not deleted, it just has its `enable` property set to false, which - * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. - * - * @method Phaser.Physics.Arcade.World#disable - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object - The object, or objects, on which to disable the bodies. - */ - disable: function (object) - { - if (!Array.isArray(object)) - { - object = [ object ]; - } - - for (var i = 0; i < object.length; i++) - { - var entry = object[i]; - - if (entry.isParent) - { - var children = entry.getChildren(); - - for (var c = 0; c < children.length; c++) - { - var child = children[c]; - - if (child.isParent) - { - // Handle Groups nested inside of Groups - this.disable(child); - } - else - { - this.disableBody(child); - } - } - } - else - { - this.disableBody(entry); - } - } - }, - - /** - * Disables an existing Arcade Physics Body or StaticBody and removes it from the simulation. - * - * The body is disabled and removed from the local search trees. - * - * The body itself is not deleted, it just has its `enable` property set to false, which - * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. - * - * @method Phaser.Physics.Arcade.World#disableBody - * @since 3.0.0 - * - * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be disabled. - */ - disableBody: function (body) - { - this.remove(body); - - body.enable = false; - }, - - /** - * Removes an existing Arcade Physics Body or StaticBody from the simulation. - * - * The body is disabled and removed from the local search trees. - * - * The body itself is not deleted, it just has its `enabled` property set to false, which - * means you can re-enable it again at any point by passing it to enable `enable` or `add`. - * - * @method Phaser.Physics.Arcade.World#remove - * @since 3.0.0 - * - * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The body to be removed from the simulation. - */ - remove: function (body) - { - if (body.physicsType === CONST.DYNAMIC_BODY) - { - this.tree.remove(body); - this.bodies.delete(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - this.staticBodies.delete(body); - this.staticTree.remove(body); - } - }, - - /** - * Creates a Graphics Game Object that the world will use to render the debug display to. - * - * This is called automatically when the World is instantiated if the `debug` config property - * was set to `true`. However, you can call it at any point should you need to display the - * debug Graphic from a fixed point. - * - * You can control which objects are drawn to the Graphics object, and the colors they use, - * by setting the debug properties in the physics config. - * - * You should not typically use this in a production game. Use it to aid during debugging. - * - * @method Phaser.Physics.Arcade.World#createDebugGraphic - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Graphics} The Graphics object that was created for use by the World. - */ - createDebugGraphic: function () - { - var graphic = this.scene.sys.add.graphics({ x: 0, y: 0 }); - - graphic.setDepth(Number.MAX_VALUE); - - this.debugGraphic = graphic; - - this.drawDebug = true; - - return graphic; - }, - - /** - * Sets the position, size and properties of the World boundary. - * - * The World boundary is an invisible rectangle that defines the edges of the World. - * If a Body is set to collide with the world bounds then it will automatically stop - * when it reaches any of the edges. You can optionally set which edges of the boundary - * should be checked against. - * - * @method Phaser.Physics.Arcade.World#setBounds - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the boundary. - * @param {number} y - The top-left y coordinate of the boundary. - * @param {number} width - The width of the boundary. - * @param {number} height - The height of the boundary. - * @param {boolean} [checkLeft] - Should bodies check against the left edge of the boundary? - * @param {boolean} [checkRight] - Should bodies check against the right edge of the boundary? - * @param {boolean} [checkUp] - Should bodies check against the top edge of the boundary? - * @param {boolean} [checkDown] - Should bodies check against the bottom edge of the boundary? - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - setBounds: function (x, y, width, height, checkLeft, checkRight, checkUp, checkDown) - { - this.bounds.setTo(x, y, width, height); - - if (checkLeft !== undefined) - { - this.setBoundsCollision(checkLeft, checkRight, checkUp, checkDown); - } - - return this; - }, - - /** - * Enables or disables collisions on each edge of the World boundary. - * - * @method Phaser.Physics.Arcade.World#setBoundsCollision - * @since 3.0.0 - * - * @param {boolean} [left=true] - Should bodies check against the left edge of the boundary? - * @param {boolean} [right=true] - Should bodies check against the right edge of the boundary? - * @param {boolean} [up=true] - Should bodies check against the top edge of the boundary? - * @param {boolean} [down=true] - Should bodies check against the bottom edge of the boundary? - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - setBoundsCollision: function (left, right, up, down) - { - if (left === undefined) { left = true; } - if (right === undefined) { right = true; } - if (up === undefined) { up = true; } - if (down === undefined) { down = true; } - - this.checkCollision.left = left; - this.checkCollision.right = right; - this.checkCollision.up = up; - this.checkCollision.down = down; - - return this; - }, - - /** - * Pauses the simulation. - * - * A paused simulation does not update any existing bodies, or run any Colliders. - * - * However, you can still enable and disable bodies within it, or manually run collide or overlap - * checks. - * - * @method Phaser.Physics.Arcade.World#pause - * @fires Phaser.Physics.Arcade.World#pause - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - pause: function () - { - this.isPaused = true; - - this.emit('pause'); - - return this; - }, - - /** - * Resumes the simulation, if paused. - * - * @method Phaser.Physics.Arcade.World#resume - * @fires Phaser.Physics.Arcade.World#resume - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - resume: function () - { - this.isPaused = false; - - this.emit('resume'); - - return this; - }, - - /** - * Creates a new Collider object and adds it to the simulation. - * - * A Collider is a way to automatically perform collision checks between two objects, - * calling the collide and process callbacks if they occur. - * - * Colliders are run as part of the World update, after all of the Bodies have updated. - * - * By creating a Collider you don't need then call `World.collide` in your `update` loop, - * as it will be handled for you automatically. - * - * @method Phaser.Physics.Arcade.World#addCollider - * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#collide - * - * @param {ArcadeColliderType} object1 - The first object to check for collision. - * @param {ArcadeColliderType} object2 - The second object to check for collision. - * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. - * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. - * @param {*} [callbackContext] - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - addCollider: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - var collider = new Collider(this, false, object1, object2, collideCallback, processCallback, callbackContext); - - this.colliders.add(collider); - - return collider; - }, - - /** - * Creates a new Overlap Collider object and adds it to the simulation. - * - * A Collider is a way to automatically perform overlap checks between two objects, - * calling the collide and process callbacks if they occur. - * - * Colliders are run as part of the World update, after all of the Bodies have updated. - * - * By creating a Collider you don't need then call `World.overlap` in your `update` loop, - * as it will be handled for you automatically. - * - * @method Phaser.Physics.Arcade.World#addOverlap - * @since 3.0.0 - * - * @param {ArcadeColliderType} object1 - The first object to check for overlap. - * @param {ArcadeColliderType} object2 - The second object to check for overlap. - * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects overlap. - * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects overlap. Must return a boolean. - * @param {*} [callbackContext] - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - addOverlap: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - var collider = new Collider(this, true, object1, object2, collideCallback, processCallback, callbackContext); - - this.colliders.add(collider); - - return collider; - }, - - /** - * Removes a Collider from the simulation so it is no longer processed. - * - * This method does not destroy the Collider. If you wish to add it back at a later stage you can call - * `World.colliders.add(Collider)`. - * - * If you no longer need the Collider you can call the `Collider.destroy` method instead, which will - * automatically clear all of its references and then remove it from the World. If you call destroy on - * a Collider you _don't_ need to pass it to this method too. - * - * @method Phaser.Physics.Arcade.World#removeCollider - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Collider} collider - The Collider to remove from the simulation. - * - * @return {Phaser.Physics.Arcade.World} This World object. - */ - removeCollider: function (collider) - { - this.colliders.remove(collider); - - return this; - }, - - /** - * Sets the frame rate to run the simulation at. - * - * The frame rate value is used to simulate a fixed update time step. This fixed - * time step allows for a straightforward implementation of a deterministic game state. - * - * This frame rate is independent of the frequency at which the game is rendering. The - * higher you set the fps, the more physics simulation steps will occur per game step. - * Conversely, the lower you set it, the less will take place. - * - * You can optionally advance the simulation directly yourself by calling the `step` method. - * - * @method Phaser.Physics.Arcade.World#setFPS - * @since 3.10.0 - * - * @param {integer} framerate - The frame rate to advance the simulation at. - * - * @return {this} This World object. - */ - setFPS: function (framerate) - { - this.fps = framerate; - this._frameTime = 1 / this.fps; - this._frameTimeMS = 1000 * this._frameTime; - - return this; - }, - - /** - * Advances the simulation based on the elapsed time and fps rate. - * - * This is called automatically by your Scene and does not need to be invoked directly. - * - * @method Phaser.Physics.Arcade.World#update - * @protected - * @since 3.0.0 - * - * @param {number} 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.isPaused || this.bodies.size === 0) - { - return; - } - - var stepsThisFrame = 0; - var fixedDelta = this._frameTime; - var msPerFrame = this._frameTimeMS * this.timeScale; - - this._elapsed += delta; - - while (this._elapsed >= msPerFrame) - { - this._elapsed -= msPerFrame; - - stepsThisFrame++; - - this.step(fixedDelta); - } - - this.stepsLastFrame = stepsThisFrame; - }, - - /** - * Advances the simulation by one step. - * - * @method Phaser.Physics.Arcade.World#step - * @since 3.10.0 - * - * @param {number} delta - The delta time amount, in ms, by which to advance the simulation. - */ - step: function (delta) - { - // Update all active bodies - var i; - var body; - var bodies = this.bodies.entries; - var len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.enable) - { - body.update(delta); - } - } - - // Optionally populate our dynamic collision tree - if (this.useTree) - { - this.tree.clear(); - this.tree.load(bodies); - } - - // Process any colliders - var colliders = this.colliders.update(); - - for (i = 0; i < colliders.length; i++) - { - var collider = colliders[i]; - - if (collider.active) - { - collider.update(); - } - } - - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.enable) - { - body.postUpdate(); - } - } - }, - - /** - * Updates bodies, draws the debug display, and handles pending queue operations. - * - * @method Phaser.Physics.Arcade.World#postUpdate - * @since 3.0.0 - */ - postUpdate: function () - { - var i; - var body; - - var dynamic = this.bodies; - var staticBodies = this.staticBodies; - var pending = this.pendingDestroy; - - var bodies = dynamic.entries; - var len = bodies.length; - - if (this.drawDebug) - { - var graphics = this.debugGraphic; - - graphics.clear(); - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.willDrawDebug()) - { - body.drawDebug(graphics); - } - } - - bodies = staticBodies.entries; - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.willDrawDebug()) - { - body.drawDebug(graphics); - } - } - } - - if (pending.size > 0) - { - var dynamicTree = this.tree; - var staticTree = this.staticTree; - - bodies = pending.entries; - len = bodies.length; - - for (i = 0; i < len; i++) - { - body = bodies[i]; - - if (body.physicsType === CONST.DYNAMIC_BODY) - { - dynamicTree.remove(body); - dynamic.delete(body); - } - else if (body.physicsType === CONST.STATIC_BODY) - { - staticTree.remove(body); - staticBodies.delete(body); - } - - body.world = undefined; - body.gameObject = undefined; - } - - pending.clear(); - } - }, - - /** - * Calculates a Body's velocity and updates its position. - * - * @method Phaser.Physics.Arcade.World#updateMotion - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body to be updated. - * @param {number} delta - The delta value to be used in the motion calculations. - */ - updateMotion: function (body, delta) - { - if (body.allowRotation) - { - this.computeAngularVelocity(body, delta); - } - - this.computeVelocity(body, delta); - }, - - /** - * Calculates a Body's angular velocity. - * - * @method Phaser.Physics.Arcade.World#computeAngularVelocity - * @since 3.10.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. - * @param {number} delta - The delta value to be used in the calculation. - */ - computeAngularVelocity: function (body, delta) - { - var velocity = body.angularVelocity; - var acceleration = body.angularAcceleration; - var drag = body.angularDrag; - var max = body.maxAngular; - - if (acceleration) - { - velocity += acceleration * delta; - } - else if (body.allowDrag && drag) - { - drag *= delta; - - if (FuzzyGreaterThan(velocity - drag, 0, 0.1)) - { - velocity -= drag; - } - else if (FuzzyLessThan(velocity + drag, 0, 0.1)) - { - velocity += drag; - } - else - { - velocity = 0; - } - } - - velocity = Clamp(velocity, -max, max); - - var velocityDelta = velocity - body.angularVelocity; - - body.angularVelocity += velocityDelta; - body.rotation += (body.angularVelocity * delta); - }, - - /** - * Calculates a Body's per-axis velocity. - * - * @method Phaser.Physics.Arcade.World#computeVelocity - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. - * @param {number} delta - The delta value to be used in the calculation. - */ - computeVelocity: function (body, delta) - { - var velocityX = body.velocity.x; - var accelerationX = body.acceleration.x; - var dragX = body.drag.x; - var maxX = body.maxVelocity.x; - - var velocityY = body.velocity.y; - var accelerationY = body.acceleration.y; - var dragY = body.drag.y; - var maxY = body.maxVelocity.y; - - var speed = body.speed; - var allowDrag = body.allowDrag; - var useDamping = body.useDamping; - - if (body.allowGravity) - { - velocityX += (this.gravity.x + body.gravity.x) * delta; - velocityY += (this.gravity.y + body.gravity.y) * delta; - } - - if (accelerationX) - { - velocityX += accelerationX * delta; - } - else if (allowDrag && dragX) - { - if (useDamping) - { - // Damping based deceleration - velocityX *= dragX; - - if (FuzzyEqual(speed, 0, 0.001)) - { - velocityX = 0; - } - } - else - { - // Linear deceleration - dragX *= delta; - - if (FuzzyGreaterThan(velocityX - dragX, 0, 0.01)) - { - velocityX -= dragX; - } - else if (FuzzyLessThan(velocityX + dragX, 0, 0.01)) - { - velocityX += dragX; - } - else - { - velocityX = 0; - } - } - } - - if (accelerationY) - { - velocityY += accelerationY * delta; - } - else if (allowDrag && dragY) - { - if (useDamping) - { - // Damping based deceleration - velocityY *= dragY; - - if (FuzzyEqual(speed, 0, 0.001)) - { - velocityY = 0; - } - } - else - { - // Linear deceleration - dragY *= delta; - - if (FuzzyGreaterThan(velocityY - dragY, 0, 0.01)) - { - velocityY -= dragY; - } - else if (FuzzyLessThan(velocityY + dragY, 0, 0.01)) - { - velocityY += dragY; - } - else - { - velocityY = 0; - } - } - } - - velocityX = Clamp(velocityX, -maxX, maxX); - velocityY = Clamp(velocityY, -maxY, maxY); - - body.velocity.set(velocityX, velocityY); - }, - - /** - * Separates two Bodies. - * - * @method Phaser.Physics.Arcade.World#separate - * @fires Phaser.Physics.Arcade.World#collide - * @fires Phaser.Physics.Arcade.World#overlap - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. - * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. - * @param {ArcadePhysicsCallback} [processCallback] - The process callback. - * @param {*} [callbackContext] - The context in which to invoke the callback. - * @param {boolean} [overlapOnly] - If this a collide or overlap check? - * - * @return {boolean} True if separation occurred, otherwise false. - */ - separate: function (body1, body2, processCallback, callbackContext, overlapOnly) - { - if ( - !body1.enable || - !body2.enable || - body1.checkCollision.none || - body2.checkCollision.none || - !this.intersects(body1, body2)) - { - return false; - } - - // They overlap. Is there a custom process callback? If it returns true then we can carry on, otherwise we should abort. - if (processCallback && processCallback.call(callbackContext, body1.gameObject, body2.gameObject) === false) - { - return false; - } - - // Circle vs. Circle quick bail out - if (body1.isCircle && body2.isCircle) - { - return this.separateCircle(body1, body2, overlapOnly); - } - - // We define the behavior of bodies in a collision circle and rectangle - // If a collision occurs in the corner points of the rectangle, the body behave like circles - - // Either body1 or body2 is a circle - if (body1.isCircle !== body2.isCircle) - { - var bodyRect = (body1.isCircle) ? body2 : body1; - var bodyCircle = (body1.isCircle) ? body1 : body2; - - var rect = { - x: bodyRect.x, - y: bodyRect.y, - right: bodyRect.right, - bottom: bodyRect.bottom - }; - - var circle = bodyCircle.center; - - if (circle.y < rect.y || circle.y > rect.bottom) - { - if (circle.x < rect.x || circle.x > rect.right) - { - return this.separateCircle(body1, body2, overlapOnly); - } - } - } - - var resultX = false; - var resultY = false; - - // Do we separate on x or y first? - if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x)) - { - resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); - - // Are they still intersecting? Let's do the other axis then - if (this.intersects(body1, body2)) - { - resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); - } - } - else - { - resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS); - - // Are they still intersecting? Let's do the other axis then - if (this.intersects(body1, body2)) - { - resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS); - } - } - - var result = (resultX || resultY); - - if (result) - { - if (overlapOnly && (body1.onOverlap || body2.onOverlap)) - { - this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); - } - else if (body1.onCollide || body2.onCollide) - { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); - } - } - - return result; - }, - - /** - * Separates two Bodies, when both are circular. - * - * @method Phaser.Physics.Arcade.World#separateCircle - * @fires Phaser.Physics.Arcade.World#collide - * @fires Phaser.Physics.Arcade.World#overlap - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. - * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to be separated. - * @param {boolean} [overlapOnly] - If this a collide or overlap check? - * @param {number} bias - A small value added to the calculations. - * - * @return {boolean} True if separation occurred, otherwise false. - */ - separateCircle: function (body1, body2, overlapOnly, bias) - { - // Set the bounding box overlap values into the bodies themselves (hence we don't use the return values here) - GetOverlapX(body1, body2, false, bias); - GetOverlapY(body1, body2, false, bias); - - var dx = body2.center.x - body1.center.x; - var dy = body2.center.y - body1.center.y; - - var angleCollision = Math.atan2(dy, dx); - - var overlap = 0; - - if (body1.isCircle !== body2.isCircle) - { - var rect = { - x: (body2.isCircle) ? body1.position.x : body2.position.x, - y: (body2.isCircle) ? body1.position.y : body2.position.y, - right: (body2.isCircle) ? body1.right : body2.right, - bottom: (body2.isCircle) ? body1.bottom : body2.bottom - }; - - var circle = { - x: (body1.isCircle) ? body1.center.x : body2.center.x, - y: (body1.isCircle) ? body1.center.y : body2.center.y, - radius: (body1.isCircle) ? body1.halfWidth : body2.halfWidth - }; - - if (circle.y < rect.y) - { - if (circle.x < rect.x) - { - overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.y) - circle.radius; - } - else if (circle.x > rect.right) - { - overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.y) - circle.radius; - } - } - else if (circle.y > rect.bottom) - { - if (circle.x < rect.x) - { - overlap = DistanceBetween(circle.x, circle.y, rect.x, rect.bottom) - circle.radius; - } - else if (circle.x > rect.right) - { - overlap = DistanceBetween(circle.x, circle.y, rect.right, rect.bottom) - circle.radius; - } - } - - overlap *= -1; - } - else - { - overlap = (body1.halfWidth + body2.halfWidth) - DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y); - } - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) - { - if (overlap !== 0 && (body1.onOverlap || body2.onOverlap)) - { - this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); - } - - // return true if there was some overlap, otherwise false - return (overlap !== 0); - } - - // Transform the velocity vector to the coordinate system oriented along the direction of impact. - // This is done to eliminate the vertical component of the velocity - - var b1vx = body1.velocity.x; - var b1vy = body1.velocity.y; - var b1mass = body1.mass; - - var b2vx = body2.velocity.x; - var b2vy = body2.velocity.y; - var b2mass = body2.mass; - - var v1 = { - x: b1vx * Math.cos(angleCollision) + b1vy * Math.sin(angleCollision), - y: b1vx * Math.sin(angleCollision) - b1vy * Math.cos(angleCollision) - }; - - var v2 = { - x: b2vx * Math.cos(angleCollision) + b2vy * Math.sin(angleCollision), - y: b2vx * Math.sin(angleCollision) - b2vy * Math.cos(angleCollision) - }; - - // We expect the new velocity after impact - var tempVel1 = ((b1mass - b2mass) * v1.x + 2 * b2mass * v2.x) / (b1mass + b2mass); - var tempVel2 = (2 * b1mass * v1.x + (b2mass - b1mass) * v2.x) / (b1mass + b2mass); - - // We convert the vector to the original coordinate system and multiplied by factor of rebound - if (!body1.immovable) - { - body1.velocity.x = (tempVel1 * Math.cos(angleCollision) - v1.y * Math.sin(angleCollision)) * body1.bounce.x; - body1.velocity.y = (v1.y * Math.cos(angleCollision) + tempVel1 * Math.sin(angleCollision)) * body1.bounce.y; - - // Reset local var - b1vx = body1.velocity.x; - b1vy = body1.velocity.y; - } - - if (!body2.immovable) - { - body2.velocity.x = (tempVel2 * Math.cos(angleCollision) - v2.y * Math.sin(angleCollision)) * body2.bounce.x; - body2.velocity.y = (v2.y * Math.cos(angleCollision) + tempVel2 * Math.sin(angleCollision)) * body2.bounce.y; - - // Reset local var - b2vx = body2.velocity.x; - b2vy = body2.velocity.y; - } - - // When the collision angle is almost perpendicular to the total initial velocity vector - // (collision on a tangent) vector direction can be determined incorrectly. - // This code fixes the problem - - if (Math.abs(angleCollision) < Math.PI / 2) - { - if ((b1vx > 0) && !body1.immovable && (b2vx > b1vx)) - { - body1.velocity.x *= -1; - } - else if ((b2vx < 0) && !body2.immovable && (b1vx < b2vx)) - { - body2.velocity.x *= -1; - } - else if ((b1vy > 0) && !body1.immovable && (b2vy > b1vy)) - { - body1.velocity.y *= -1; - } - else if ((b2vy < 0) && !body2.immovable && (b1vy < b2vy)) - { - body2.velocity.y *= -1; - } - } - else if (Math.abs(angleCollision) > Math.PI / 2) - { - if ((b1vx < 0) && !body1.immovable && (b2vx < b1vx)) - { - body1.velocity.x *= -1; - } - else if ((b2vx > 0) && !body2.immovable && (b1vx > b2vx)) - { - body2.velocity.x *= -1; - } - else if ((b1vy < 0) && !body1.immovable && (b2vy < b1vy)) - { - body1.velocity.y *= -1; - } - else if ((b2vy > 0) && !body2.immovable && (b1vx > b2vy)) - { - body2.velocity.y *= -1; - } - } - - var delta = this._frameTime; - - if (!body1.immovable) - { - body1.x += (body1.velocity.x * delta) - overlap * Math.cos(angleCollision); - body1.y += (body1.velocity.y * delta) - overlap * Math.sin(angleCollision); - } - - if (!body2.immovable) - { - body2.x += (body2.velocity.x * delta) + overlap * Math.cos(angleCollision); - body2.y += (body2.velocity.y * delta) + overlap * Math.sin(angleCollision); - } - - if (body1.onCollide || body2.onCollide) - { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); - } - - return true; - }, - - /** - * Checks to see if two Bodies intersect at all. - * - * @method Phaser.Physics.Arcade.World#intersects - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - The first body to check. - * @param {Phaser.Physics.Arcade.Body} body2 - The second body to check. - * - * @return {boolean} True if the two bodies intersect, otherwise false. - */ - intersects: function (body1, body2) - { - if (body1 === body2) - { - return false; - } - - if (!body1.isCircle && !body2.isCircle) - { - // Rect vs. Rect - return !( - body1.right <= body2.position.x || - body1.bottom <= body2.position.y || - body1.position.x >= body2.right || - body1.position.y >= body2.bottom - ); - } - else if (body1.isCircle) - { - if (body2.isCircle) - { - // Circle vs. Circle - return DistanceBetween(body1.center.x, body1.center.y, body2.center.x, body2.center.y) <= (body1.halfWidth + body2.halfWidth); - } - else - { - // Circle vs. Rect - return this.circleBodyIntersects(body1, body2); - } - } - else - { - // Rect vs. Circle - return this.circleBodyIntersects(body2, body1); - } - }, - - /** - * Tests if a circular Body intersects with another Body. - * - * @method Phaser.Physics.Arcade.World#circleBodyIntersects - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} circle - The circular body to test. - * @param {Phaser.Physics.Arcade.Body} body - The rectangular body to test. - * - * @return {boolean} True if the two bodies intersect, otherwise false. - */ - circleBodyIntersects: function (circle, body) - { - var x = Clamp(circle.center.x, body.left, body.right); - var y = Clamp(circle.center.y, body.top, body.bottom); - - var dx = (circle.center.x - x) * (circle.center.x - x); - var dy = (circle.center.y - y) * (circle.center.y - y); - - return (dx + dy) <= (circle.halfWidth * circle.halfWidth); - }, - - /** - * Tests if Game Objects overlap. - * - * @method Phaser.Physics.Arcade.World#overlap - * @since 3.0.0 - * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} [overlapCallback] - [description] - * @param {ArcadePhysicsCallback} [processCallback] - [description] - * @param {*} [callbackContext] - [description] + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. * * @return {boolean} True if at least one Game Object overlaps another. + * + * @see Phaser.Physics.Arcade.World#overlap */ overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) { @@ -86084,37 +110835,24 @@ var World = new Class({ if (processCallback === undefined) { processCallback = null; } if (callbackContext === undefined) { callbackContext = overlapCallback; } - return this.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); + return this.world.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); }, /** - * Performs a collision check and separation between the two physics enabled objects given, which can be single - * Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups. + * Tests if Game Objects overlap and separates them (if possible). See {@link Phaser.Physics.Arcade.World#collide}. * - * If you don't require separation then use {@link #overlap} instead. - * - * If two Groups or arrays are passed, each member of one will be tested against each member of the other. - * - * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. - * - * Two callbacks can be provided. The `collideCallback` is invoked if a collision occurs and the two colliding - * objects are passed to it. - * - * Arcade Physics uses the Projection Method of collision resolution and separation. While it's fast and suitable - * for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other. - * The separation that stops two objects penetrating may create a new penetration against a different object. If you - * require a high level of stability please consider using an alternative physics system, such as Matter.js. - * - * @method Phaser.Physics.Arcade.World#collide + * @method Phaser.Physics.Arcade.ArcadePhysics#collide * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} [collideCallback] - [description] - * @param {ArcadePhysicsCallback} [processCallback] - [description] - * @param {*} [callbackContext] - [description] + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. * - * @return {boolean} True if any overlapping Game Objects were separated. + * @return {boolean} True if any overlapping Game Objects were separated, otherwise false. + * + * @see Phaser.Physics.Arcade.World#collide */ collide: function (object1, object2, collideCallback, processCallback, callbackContext) { @@ -86122,559 +110860,319 @@ var World = new Class({ if (processCallback === undefined) { processCallback = null; } if (callbackContext === undefined) { callbackContext = collideCallback; } - return this.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); + return this.world.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); }, /** - * Helper for Phaser.Physics.Arcade.World#collide. + * Pauses the simulation. * - * @method Phaser.Physics.Arcade.World#collideObjects + * @method Phaser.Physics.Arcade.ArcadePhysics#pause * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} True if any overlapping objects were separated. + * @return {Phaser.Physics.Arcade.World} The simulation. */ - collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + pause: function () { - var i; - - if (object1.isParent && object1.physicsType === undefined) - { - object1 = object1.children.entries; - } - - if (object2 && object2.isParent && object2.physicsType === undefined) - { - object2 = object2.children.entries; - } - - var object1isArray = Array.isArray(object1); - var object2isArray = Array.isArray(object2); - - this._total = 0; - - if (!object1isArray && !object2isArray) - { - // Neither of them are arrays - do this first as it's the most common use-case - this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (!object1isArray && object2isArray) - { - // Object 2 is an Array - for (i = 0; i < object2.length; i++) - { - this.collideHandler(object1, object2[i], collideCallback, processCallback, callbackContext, overlapOnly); - } - } - else if (object1isArray && !object2isArray) - { - // Object 1 is an Array - for (i = 0; i < object1.length; i++) - { - this.collideHandler(object1[i], object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - else - { - // They're both arrays - for (i = 0; i < object1.length; i++) - { - for (var j = 0; j < object2.length; j++) - { - this.collideHandler(object1[i], object2[j], collideCallback, processCallback, callbackContext, overlapOnly); - } - } - } - - return (this._total > 0); + return this.world.pause(); }, /** - * Helper for Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap. + * Resumes the simulation (if paused). * - * @method Phaser.Physics.Arcade.World#collideHandler + * @method Phaser.Physics.Arcade.ArcadePhysics#resume * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] - * - * @return {boolean} [description] + * @return {Phaser.Physics.Arcade.World} The simulation. */ - collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) + resume: function () { - // Collide Group with Self - // Only collide valid objects - if (object2 === undefined && object1.isParent) - { - return this.collideGroupVsGroup(object1, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - - // If neither of the objects are set then bail out - if (!object1 || !object2) - { - return false; - } - - // A Body - if (object1.body) - { - if (object2.body) - { - return this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isTilemap) - { - return this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - - // GROUPS - else if (object1.isParent) - { - if (object2.body) - { - return this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isTilemap) - { - return this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext, overlapOnly); - } - } - - // TILEMAP LAYERS - else if (object1.isTilemap) - { - if (object2.body) - { - return this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - else if (object2.isParent) - { - return this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext, overlapOnly); - } - } + return this.world.resume(); }, /** - * Handler for Sprite vs. Sprite collisions. + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) * - * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateTo * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} sprite1 - [description] - * @param {Phaser.GameObjects.GameObject} sprite2 - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to accelerate towards. + * @param {number} y - The y coordinate to accelerate towards. + * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. * - * @return {boolean} [description] + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. */ - collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) + accelerateTo: function (gameObject, x, y, speed, xSpeedMax, ySpeedMax) { - if (!sprite1.body || !sprite2.body) + if (speed === undefined) { speed = 60; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + gameObject.body.acceleration.setToPolar(angle, speed); + + if (xSpeedMax !== undefined && ySpeedMax !== undefined) { - return false; + gameObject.body.maxVelocity.set(xSpeedMax, ySpeedMax); } - if (this.separate(sprite1.body, sprite2.body, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, sprite1, sprite2); - } - - this._total++; - } - - return true; + return angle; }, /** - * Handler for Sprite vs. Group collisions. + * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) * - * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup + * You must give a maximum speed value, beyond which the game object won't go any faster. + * + * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. + * Note: The game object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateToObject * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {Phaser.GameObjects.Group} group - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {Phaser.GameObjects.GameObject} destination - The Game Object to move towards. Can be any object but must have visible x/y properties. + * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. + * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. * - * @return {boolean} [description] + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. */ - collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) + accelerateToObject: function (gameObject, destination, speed, xSpeedMax, ySpeedMax) { - var bodyA = sprite.body; - - if (group.length === 0 || !bodyA || !bodyA.enable) - { - return; - } - - // Does sprite collide with anything? - - var i; - var len; - var bodyB; - - if (this.useTree) - { - var minMax = this.treeMinMax; - - minMax.minX = bodyA.left; - minMax.minY = bodyA.top; - minMax.maxX = bodyA.right; - minMax.maxY = bodyA.bottom; - - var results = (group.physicsType === CONST.DYNAMIC_BODY) ? this.tree.search(minMax) : this.staticTree.search(minMax); - - len = results.length; - - for (i = 0; i < len; i++) - { - bodyB = results[i]; - - if (bodyA === bodyB || !group.contains(bodyB.gameObject)) - { - // Skip if comparing against itself, or if bodyB isn't actually part of the Group - continue; - } - - if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); - } - - this._total++; - } - } - } - else - { - var children = group.getChildren(); - var skipIndex = group.children.entries.indexOf(sprite); - - len = children.length; - - for (i = 0; i < len; i++) - { - bodyB = children[i].body; - - if (!bodyB || i === skipIndex || !bodyB.enable) - { - continue; - } - - if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly)) - { - if (collideCallback) - { - collideCallback.call(callbackContext, bodyA.gameObject, bodyB.gameObject); - } - - this._total++; - } - } - } + return this.accelerateTo(gameObject, destination.x, destination.y, speed, xSpeedMax, ySpeedMax); }, /** - * Helper for Group vs. Tilemap collisions. + * Finds the Body closest to a source point or object. * - * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer + * @method Phaser.Physics.Arcade.ArcadePhysics#closest * @since 3.0.0 * - * @param {Phaser.GameObjects.Group} group - [description] - * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. * - * @return {boolean} [description] + * @return {Phaser.Physics.Arcade.Body} The closest Body to the given source point. */ - collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + closest: function (source) { - var children = group.getChildren(); + var bodies = this.world.tree.all(); - if (children.length === 0) + var min = Number.MAX_VALUE; + var closest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) { - return false; - } + var target = bodies[i]; + var distance = DistanceSquared(x, y, target.x, target.y); - var didCollide = false; - - for (var i = 0; i < children.length; i++) - { - if (children[i].body) + if (distance < min) { - if (this.collideSpriteVsTilemapLayer(children[i], tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly)) - { - didCollide = true; - } + closest = target; + min = distance; } } - return didCollide; + return closest; }, /** - * Helper for Sprite vs. Tilemap collisions. + * Finds the Body farthest from a source point or object. * - * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer - * @fires Phaser.Physics.Arcade.World#collide - * @fires Phaser.Physics.Arcade.World#overlap + * @method Phaser.Physics.Arcade.ArcadePhysics#furthest * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. * - * @return {boolean} [description] + * @return {Phaser.Physics.Arcade.Body} The Body furthest from the given source point. */ - collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) + furthest: function (source) { - var body = sprite.body; + var bodies = this.world.tree.all(); - if (!body.enable) + var max = -1; + var farthest = null; + var x = source.x; + var y = source.y; + + for (var i = bodies.length - 1; i >= 0; i--) { - return false; - } + var target = bodies[i]; + var distance = DistanceSquared(x, y, target.x, target.y); - var x = body.position.x; - var y = body.position.y; - var w = body.width; - var h = body.height; - - // TODO: this logic should be encapsulated within the Tilemap API at some point. - // If the maps base tile size differs from the layer's tile size, we need to adjust the - // selection area by the difference between the two. - var layerData = tilemapLayer.layer; - - if (layerData.tileWidth > layerData.baseTileWidth) - { - // The x origin of a tile is the left side, so x and width need to be adjusted. - var xDiff = (layerData.tileWidth - layerData.baseTileWidth) * tilemapLayer.scaleX; - x -= xDiff; - w += xDiff; - } - - if (layerData.tileHeight > layerData.baseTileHeight) - { - // The y origin of a tile is the bottom side, so just the height needs to be adjusted. - var yDiff = (layerData.tileHeight - layerData.baseTileHeight) * tilemapLayer.scaleY; - h += yDiff; - } - - var mapData = tilemapLayer.getTilesWithinWorldXY(x, y, w, h); - - if (mapData.length === 0) - { - return false; - } - - var tile; - var tileWorldRect = { left: 0, right: 0, top: 0, bottom: 0 }; - - for (var i = 0; i < mapData.length; i++) - { - tile = mapData[i]; - tileWorldRect.left = tilemapLayer.tileToWorldX(tile.x); - tileWorldRect.top = tilemapLayer.tileToWorldY(tile.y); - - // If the map's base tile size differs from the layer's tile size, only the top of the rect - // needs to be adjusted since its origin is (0, 1). - if (tile.baseHeight !== tile.height) + if (distance > max) { - tileWorldRect.top -= (tile.height - tile.baseHeight) * tilemapLayer.scaleY; - } - - tileWorldRect.right = tileWorldRect.left + tile.width * tilemapLayer.scaleX; - tileWorldRect.bottom = tileWorldRect.top + tile.height * tilemapLayer.scaleY; - - if (TileIntersectsBody(tileWorldRect, body) - && (!processCallback || processCallback.call(callbackContext, sprite, tile)) - && ProcessTileCallbacks(tile, sprite) - && (overlapOnly || SeparateTile(i, body, tile, tileWorldRect, tilemapLayer, this.TILE_BIAS))) - { - this._total++; - - if (collideCallback) - { - collideCallback.call(callbackContext, sprite, tile); - } - - if (overlapOnly && body.onOverlap) - { - sprite.emit('overlap', body.gameObject, tile, body, null); - } - else if (body.onCollide) - { - sprite.emit('collide', body.gameObject, tile, body, null); - } + farthest = target; + max = distance; } } + + return farthest; }, /** - * Helper for Group vs. Group collisions. + * Move the given display object towards the x/y coordinates at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) * - * @method Phaser.Physics.Arcade.World#collideGroupVsGroup + * @method Phaser.Physics.Arcade.ArcadePhysics#moveTo * @since 3.0.0 * - * @param {Phaser.GameObjects.Group} group1 - [description] - * @param {Phaser.GameObjects.Group} group2 - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {number} x - The x coordinate to move towards. + * @param {number} y - The y coordinate to move towards. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. * - * @return {boolean} [description] + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. */ - collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) + moveTo: function (gameObject, x, y, speed, maxTime) { - if (group1.length === 0 || group2.length === 0) + if (speed === undefined) { speed = 60; } + if (maxTime === undefined) { maxTime = 0; } + + var angle = Math.atan2(y - gameObject.y, x - gameObject.x); + + if (maxTime > 0) { - return; + // We know how many pixels we need to move, but how fast? + speed = DistanceBetween(gameObject.x, gameObject.y, x, y) / (maxTime / 1000); } - var children = group1.getChildren(); + gameObject.body.velocity.setToPolar(angle, speed); - for (var i = 0; i < children.length; i++) - { - this.collideSpriteVsGroup(children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly); - } + return angle; }, /** - * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. + * Move the given display object towards the destination object at a steady velocity. + * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) * - * If the object is outside any boundary edge (left, top, right, bottom), it will be moved to the same offset from the opposite edge (the interior). + * @method Phaser.Physics.Arcade.ArcadePhysics#moveToObject + * @since 3.0.0 * - * @method Phaser.Physics.Arcade.World#wrap - * @since 3.3.0 + * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. + * @param {object} destination - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. * - * @param {*} object - A Game Object, a Group, an object with `x` and `y` coordinates, or an array of such objects. - * @param {number} [padding=0] - An amount added to each boundary edge during the operation. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. */ - wrap: function (object, padding) + moveToObject: function (gameObject, destination, speed, maxTime) { - if (object.body) - { - this.wrapObject(object, padding); - } - else if (object.getChildren) - { - this.wrapArray(object.getChildren(), padding); - } - else if (Array.isArray(object)) - { - this.wrapArray(object, padding); - } - else - { - this.wrapObject(object, padding); - } - }, - - - /** - * Wrap each object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. - * - * @method Phaser.Physics.Arcade.World#wrapArray - * @since 3.3.0 - * - * @param {Array.<*>} objects - An array of objects to be wrapped. - * @param {number} [padding=0] - An amount added to the boundary. - */ - wrapArray: function (objects, padding) - { - for (var i = 0; i < objects.length; i++) - { - this.wrapObject(objects[i], padding); - } + return this.moveTo(gameObject, destination.x, destination.y, speed, maxTime); }, /** - * Wrap an object's coordinates within {@link Phaser.Physics.Arcade.World#bounds}. + * Given the angle (in degrees) and speed calculate the velocity and return it as a vector, or set it to the given vector object. + * One way to use this is: velocityFromAngle(angle, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. * - * @method Phaser.Physics.Arcade.World#wrapObject - * @since 3.3.0 + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromAngle + * @since 3.0.0 * - * @param {*} object - A Game Object, a Physics Body, or any object with `x` and `y` coordinates - * @param {number} [padding=0] - An amount added to the boundary. + * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param {number} [speed=60] - The speed it will move, in pixels per second squared. + * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. */ - wrapObject: function (object, padding) + velocityFromAngle: function (angle, speed, vec2) { - if (padding === undefined) { padding = 0; } + if (speed === undefined) { speed = 60; } + if (vec2 === undefined) { vec2 = new Vector2(); } - object.x = Wrap(object.x, this.bounds.left - padding, this.bounds.right + padding); - object.y = Wrap(object.y, this.bounds.top - padding, this.bounds.bottom + padding); + return vec2.setToPolar(DegToRad(angle), speed); }, /** - * Shuts down the simulation, clearing physics data and removing listeners. + * Given the rotation (in radians) and speed calculate the velocity and return it as a vector, or set it to the given vector object. + * One way to use this is: velocityFromRotation(rotation, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. * - * @method Phaser.Physics.Arcade.World#shutdown + * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromRotation + * @since 3.0.0 + * + * @param {number} rotation - The angle in radians. + * @param {number} [speed=60] - The speed it will move, in pixels per second squared + * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. + * + * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. + */ + velocityFromRotation: function (rotation, speed, vec2) + { + if (speed === undefined) { speed = 60; } + if (vec2 === undefined) { vec2 = new Vector2(); } + + return vec2.setToPolar(rotation, speed); + }, + + /** + * 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 () { - this.tree.clear(); - this.staticTree.clear(); - this.bodies.clear(); - this.staticBodies.clear(); - this.colliders.destroy(); + if (!this.world) + { + // Already destroyed + return; + } - this.removeAllListeners(); + 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.add.destroy(); + this.world.destroy(); + + this.add = null; + this.world = null; }, /** - * Shuts down the simulation and disconnects it from the current scene. + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. * - * @method Phaser.Physics.Arcade.World#destroy + * @method Phaser.Physics.Arcade.ArcadePhysics#destroy * @since 3.0.0 */ destroy: function () { this.shutdown(); + this.scene.sys.events.off('start', this.start, this); + this.scene = null; + this.systems = null; } }); -module.exports = World; +PluginCache.register('ArcadePhysics', ArcadePhysics, 'arcadePhysics'); + +module.exports = ArcadePhysics; /***/ }), -/* 341 */ +/* 528 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -86683,146 +111181,637 @@ module.exports = World; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Physics.Arcade.StaticGroup +var CONST = __webpack_require__(35); +var Extend = __webpack_require__(20); + +/** + * @callback ArcadePhysicsCallback + * + * @param {Phaser.GameObjects.GameObject} object1 - [description] + * @param {Phaser.GameObjects.GameObject} object2 - [description] + */ + +/** + * @namespace Phaser.Physics.Arcade + */ + +var Arcade = { + + ArcadePhysics: __webpack_require__(527), + Body: __webpack_require__(232), + Collider: __webpack_require__(231), + Factory: __webpack_require__(238), + Group: __webpack_require__(235), + Image: __webpack_require__(237), + Sprite: __webpack_require__(104), + StaticBody: __webpack_require__(225), + StaticGroup: __webpack_require__(234), + World: __webpack_require__(233) + +}; + +// Merge in the consts +Arcade = Extend(false, Arcade, CONST); + +module.exports = Arcade; + + +/***/ }), +/* 529 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector3 = __webpack_require__(138); +var Matrix4 = __webpack_require__(240); +var Quaternion = __webpack_require__(239); + +var tmpMat4 = new Matrix4(); +var tmpQuat = new Quaternion(); +var tmpVec3 = new Vector3(); + +/** + * Rotates a vector in place by axis angle. + * + * This is the same as transforming a point by an + * axis-angle quaternion, but it has higher precision. + * + * @function Phaser.Math.RotateVec3 + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec - The vector to be rotated. + * @param {Phaser.Math.Vector3} axis - The axis to rotate around. + * @param {number} radians - The angle of rotation in radians. + * + * @return {Phaser.Math.Vector3} The given vector. + */ +var RotateVec3 = function (vec, axis, radians) +{ + // Set the quaternion to our axis angle + tmpQuat.setAxisAngle(axis, radians); + + // Create a rotation matrix from the axis angle + tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); + + // Multiply our vector by the rotation matrix + return vec.transformMat4(tmpMat4); +}; + +module.exports = RotateVec3; + + +/***/ }), +/* 530 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl -var ArcadeSprite = __webpack_require__(142); var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var Group = __webpack_require__(112); /** * @classdesc - * [description] + * A representation of a vector in 4D space. * - * @class StaticGroup - * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade + * A four-component vector. + * + * @class Vector4 + * @memberof Phaser.Math * @constructor * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {GroupConfig} config - [description] + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + * @param {number} [w] - The w component. */ -var StaticPhysicsGroup = new Class({ - - Extends: Group, +var Vector4 = new Class({ initialize: - function StaticPhysicsGroup (world, scene, children, config) + function Vector4 (x, y, z, w) { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - else if (config === undefined) - { - config = {}; - } - /** - * [description] + * The x component of this Vector. * - * @name Phaser.Physics.Arcade.StaticGroup#world - * @type {Phaser.Physics.Arcade.World} + * @name Phaser.Math.Vector4#x + * @type {number} + * @default 0 * @since 3.0.0 */ - this.world = world; - - config.createCallback = this.createCallbackHandler; - config.removeCallback = this.removeCallbackHandler; - config.createMultipleCallback = this.createMultipleCallbackHandler; - - config.classType = ArcadeSprite; + this.x = 0; /** - * [description] + * The y component of this Vector. * - * @name Phaser.Physics.Arcade.StaticGroup#physicsType - * @type {integer} + * @name Phaser.Math.Vector4#y + * @type {number} + * @default 0 * @since 3.0.0 */ - this.physicsType = CONST.STATIC_BODY; + this.y = 0; - Group.call(this, scene, children, config); - }, + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector4#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.z = 0; - /** - * [description] - * - * @method Phaser.Physics.Arcade.StaticGroup#createCallbackHandler - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - createCallbackHandler: function (child) - { - if (!child.body) + /** + * The w component of this Vector. + * + * @name Phaser.Math.Vector4#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.w = 0; + + if (typeof x === 'object') { - this.world.enableBody(child, CONST.STATIC_BODY); + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; } }, /** - * [description] + * Make a clone of this Vector4. * - * @method Phaser.Physics.Arcade.StaticGroup#removeCallbackHandler + * @method Phaser.Math.Vector4#clone * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] + * @return {Phaser.Math.Vector4} A clone of this Vector4. */ - removeCallbackHandler: function (child) + clone: function () { - if (child.body) - { - this.world.disableBody(child); - } + return new Vector4(this.x, this.y, this.z, this.w); }, /** - * [description] + * Copy the components of a given Vector into this Vector. * - * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallbackHandler + * @method Phaser.Math.Vector4#copy * @since 3.0.0 * - * @param {object} entries - [description] + * @param {Phaser.Math.Vector4} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector4} This Vector4. */ - createMultipleCallbackHandler: function () + copy: function (src) { - this.refresh(); + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + this.w = src.w || 0; + + return this; }, /** - * [description] + * Check whether this Vector is equal to a given Vector. * - * @method Phaser.Physics.Arcade.StaticGroup#refresh + * Performs a strict quality check against each Vector's components. + * + * @method Phaser.Math.Vector4#equals * @since 3.0.0 * - * @return {Phaser.Physics.Arcade.StaticGroup} [description] + * @param {Phaser.Math.Vector4} v - The vector to check equality with. + * + * @return {boolean} A boolean indicating whether the two Vectors are equal or not. */ - refresh: function () + equals: function (v) { - var children = this.children.entries; + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); + }, - for (var i = 0; i < children.length; i++) + /** + * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. + * + * @method Phaser.Math.Vector4#set + * @since 3.0.0 + * + * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y, z and w components. + * @param {number} y - The y value to set for this Vector. + * @param {number} z - The z value to set for this Vector. + * @param {number} w - The z value to set for this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') { - children[i].body.reset(); + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector4#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + this.w += v.w || 0; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector4#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + this.w -= v.w || 0; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector4#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector4#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector4#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector4#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector4#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - The Vector4 to dot product with this Vector4. + * + * @return {number} The dot product of this Vector and the given Vector. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector4#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - The Vector4 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector4#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + this.w *= v.w || 1; + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector4#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + this.w /= v.w || 1; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector4#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector4#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return dx * dx + dy * dy + dz * dz + dw * dw; + }, + + /** + * Negate the `x`, `y`, `z` and `w` components of this Vector. + * + * @method Phaser.Math.Vector4#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector4#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector4 with. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + + return this; + }, + + /** + * Transform this Vector with the given Quaternion. + * + * @method Phaser.Math.Vector4#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + transformQuat: function (q) + { + // TODO: is this really the same as Vector3? + // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Make this Vector the zero vector (0, 0, 0, 0). + * + * @method Phaser.Math.Vector4#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 0; return this; } }); -module.exports = StaticPhysicsGroup; +// TODO: Check if these are required internally, if not, remove. +Vector4.prototype.sub = Vector4.prototype.subtract; +Vector4.prototype.mul = Vector4.prototype.multiply; +Vector4.prototype.div = Vector4.prototype.divide; +Vector4.prototype.dist = Vector4.prototype.distance; +Vector4.prototype.distSq = Vector4.prototype.distanceSq; +Vector4.prototype.len = Vector4.prototype.length; +Vector4.prototype.lenSq = Vector4.prototype.lengthSq; + +module.exports = Vector4; /***/ }), -/* 342 */ -/***/ (function(module, exports, __webpack_require__) { +/* 531 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -86830,286 +111819,629 @@ module.exports = StaticPhysicsGroup; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ArcadeSprite = __webpack_require__(142); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var GetFastValue = __webpack_require__(1); -var Group = __webpack_require__(112); - /** - * @typedef {object} PhysicsGroupConfig - * @extends GroupConfig + * Checks if the two values are within the given `tolerance` of each other. * - * @property {boolean} [collideWorldBounds=false] - Sets {@link Phaser.Physics.Arcade.Body#collideWorldBounds}. - * @property {number} [accelerationX=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.x}. - * @property {number} [accelerationY=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.y}. - * @property {boolean} [allowDrag=true] - Sets {@link Phaser.Physics.Arcade.Body#allowDrag}. - * @property {boolean} [allowGravity=true] - Sets {@link Phaser.Physics.Arcade.Body#allowGravity}. - * @property {boolean} [allowRotation=true] - Sets {@link Phaser.Physics.Arcade.Body#allowRotation}. - * @property {number} [bounceX=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.x}. - * @property {number} [bounceY=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.y}. - * @property {number} [dragX=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.x}. - * @property {number} [dragY=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.y}. - * @property {number} [gravityX=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.x}. - * @property {number} [gravityY=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.y}. - * @property {number} [frictionX=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.x}. - * @property {number} [frictionY=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.y}. - * @property {number} [velocityX=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.x}. - * @property {number} [velocityY=0] - Sets {@link Phaser.Physics.Arcade.Body#velocity velocity.y}. - * @property {number} [angularVelocity=0] - Sets {@link Phaser.Physics.Arcade.Body#angularVelocity}. - * @property {number} [angularAcceleration=0] - Sets {@link Phaser.Physics.Arcade.Body#angularAcceleration}. - * @property {number} [angularDrag=0] - Sets {@link Phaser.Physics.Arcade.Body#angularDrag}. - * @property {number} [mass=0] - Sets {@link Phaser.Physics.Arcade.Body#mass}. - * @property {boolean} [immovable=false] - Sets {@link Phaser.Physics.Arcade.Body#immovable}. - */ - -/** - * @typedef {object} PhysicsGroupDefaults - * - * @property {boolean} setCollideWorldBounds - [description] - * @property {number} setAccelerationX - [description] - * @property {number} setAccelerationY - [description] - * @property {boolean} setAllowDrag - [description] - * @property {boolean} setAllowGravity - [description] - * @property {boolean} setAllowRotation - [description] - * @property {number} setBounceX - [description] - * @property {number} setBounceY - [description] - * @property {number} setDragX - [description] - * @property {number} setDragY - [description] - * @property {number} setGravityX - [description] - * @property {number} setGravityY - [description] - * @property {number} setFrictionX - [description] - * @property {number} setFrictionY - [description] - * @property {number} setVelocityX - [description] - * @property {number} setVelocityY - [description] - * @property {number} setAngularVelocity - [description] - * @property {number} setAngularAcceleration - [description] - * @property {number} setAngularDrag - [description] - * @property {number} setMass - [description] - * @property {boolean} setImmovable - [description] - */ - -/** - * @classdesc - * An Arcade Physics Group object. - * - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * - * @class Group - * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade - * @constructor + * @function Phaser.Math.Within * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {PhysicsGroupConfig} [config] - [description] + * @param {number} a - The first value to use in the calculation. + * @param {number} b - The second value to use in the calculation. + * @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range. + * + * @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`. */ -var PhysicsGroup = new Class({ +var Within = function (a, b, tolerance) +{ + return (Math.abs(a - b) <= tolerance); +}; - Extends: Group, - - initialize: - - function PhysicsGroup (world, scene, children, config) - { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') - { - config = children; - children = null; - } - else if (config === undefined) - { - config = {}; - } - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - config.createCallback = this.createCallbackHandler; - config.removeCallback = this.removeCallbackHandler; - - /** - * The class to create new group members from. - * - * @name Phaser.Physics.Arcade.Group#classType - * @type {Phaser.Physics.Arcade.Sprite} - * @default ArcadeSprite - */ - config.classType = GetFastValue(config, 'classType', ArcadeSprite); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#physicsType - * @type {integer} - * @since 3.0.0 - */ - this.physicsType = CONST.DYNAMIC_BODY; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Group#defaults - * @type {PhysicsGroupDefaults} - * @since 3.0.0 - */ - this.defaults = { - setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false), - setAccelerationX: GetFastValue(config, 'accelerationX', 0), - setAccelerationY: GetFastValue(config, 'accelerationY', 0), - setAllowDrag: GetFastValue(config, 'allowDrag', true), - setAllowGravity: GetFastValue(config, 'allowGravity', true), - setAllowRotation: GetFastValue(config, 'allowRotation', true), - setBounceX: GetFastValue(config, 'bounceX', 0), - setBounceY: GetFastValue(config, 'bounceY', 0), - setDragX: GetFastValue(config, 'dragX', 0), - setDragY: GetFastValue(config, 'dragY', 0), - setGravityX: GetFastValue(config, 'gravityX', 0), - setGravityY: GetFastValue(config, 'gravityY', 0), - setFrictionX: GetFastValue(config, 'frictionX', 0), - setFrictionY: GetFastValue(config, 'frictionY', 0), - setVelocityX: GetFastValue(config, 'velocityX', 0), - setVelocityY: GetFastValue(config, 'velocityY', 0), - setAngularVelocity: GetFastValue(config, 'angularVelocity', 0), - setAngularAcceleration: GetFastValue(config, 'angularAcceleration', 0), - setAngularDrag: GetFastValue(config, 'angularDrag', 0), - setMass: GetFastValue(config, 'mass', 1), - setImmovable: GetFastValue(config, 'immovable', false) - }; - - Group.call(this, scene, children, config); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#createCallbackHandler - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - createCallbackHandler: function (child) - { - if (!child.body) - { - this.world.enableBody(child, CONST.DYNAMIC_BODY); - } - - var body = child.body; - - for (var key in this.defaults) - { - body[key](this.defaults[key]); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#removeCallbackHandler - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} child - [description] - */ - removeCallbackHandler: function (child) - { - if (child.body) - { - this.world.disableBody(child); - } - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocity: function (x, y, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.set(x + (i * step), y + (i * step)); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocityX - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocityX: function (value, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.x = value + (i * step); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Group#setVelocityY - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} step - [description] - * - * @return {Phaser.Physics.Arcade.Group} This Physics Group object. - */ - setVelocityY: function (value, step) - { - if (step === undefined) { step = 0; } - - var items = this.getChildren(); - - for (var i = 0; i < items.length; i++) - { - items[i].body.velocity.y = value + (i * step); - } - - return this; - } - -}); - -module.exports = PhysicsGroup; +module.exports = Within; /***/ }), -/* 343 */ +/* 532 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} SinCosTable + * + * @property {number} sin - The sine value. + * @property {number} cos - The cosine value. + * @property {number} length - The length. + */ + +/** + * Generate a series of sine and cosine values. + * + * @function Phaser.Math.SinCosTableGenerator + * @since 3.0.0 + * + * @param {number} length - The number of values to generate. + * @param {number} [sinAmp=1] - The sine value amplitude. + * @param {number} [cosAmp=1] - The cosine value amplitude. + * @param {number} [frequency=1] - The frequency of the values. + * + * @return {SinCosTable} The generated values. + */ +var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency) +{ + if (sinAmp === undefined) { sinAmp = 1; } + if (cosAmp === undefined) { cosAmp = 1; } + if (frequency === undefined) { frequency = 1; } + + frequency *= Math.PI / length; + + var cos = []; + var sin = []; + + for (var c = 0; c < length; c++) + { + cosAmp -= sinAmp * frequency; + sinAmp += cosAmp * frequency; + + cos[c] = cosAmp; + sin[c] = sinAmp; + } + + return { + sin: sin, + cos: cos, + length: length + }; +}; + +module.exports = SinCosTableGenerator; + + +/***/ }), +/* 533 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Round a value to a given decimal place. + * + * @function Phaser.Math.RoundTo + * @since 3.0.0 + * + * @param {number} value - The value to round. + * @param {integer} [place=0] - The place to round to. + * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. + * + * @return {number} The rounded value. + */ +var RoundTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.round(value * p) / p; +}; + +module.exports = RoundTo; + + +/***/ }), +/* 534 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random four-dimensional vector. + * + * @function Phaser.Math.RandomXYZW + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} vec4 - The Vector to compute random values for. + * @param {number} [scale=1] - The scale of the random values. + * + * @return {Phaser.Math.Vector4} The given Vector. + */ +var RandomXYZW = function (vec4, scale) +{ + if (scale === undefined) { scale = 1; } + + // TODO: Not spherical; should fix this for more uniform distribution + vec4.x = (Math.random() * 2 - 1) * scale; + vec4.y = (Math.random() * 2 - 1) * scale; + vec4.z = (Math.random() * 2 - 1) * scale; + vec4.w = (Math.random() * 2 - 1) * scale; + + return vec4; +}; + +module.exports = RandomXYZW; + + +/***/ }), +/* 535 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random position vector in a spherical area, optionally defined by the given radius. + * + * @function Phaser.Math.RandomXYZ + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec3 - The Vector to compute random values for. + * @param {number} [radius=1] - The radius. + * + * @return {Phaser.Math.Vector3} The given Vector. + */ +var RandomXYZ = function (vec3, radius) +{ + if (radius === undefined) { radius = 1; } + + var r = Math.random() * 2 * Math.PI; + var z = (Math.random() * 2) - 1; + var zScale = Math.sqrt(1 - z * z) * radius; + + vec3.x = Math.cos(r) * zScale; + vec3.y = Math.sin(r) * zScale; + vec3.z = z * radius; + + return vec3; +}; + +module.exports = RandomXYZ; + + +/***/ }), +/* 536 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random unit vector. + * + * Computes random values for the given vector between -1 and 1 that can be used to represent a direction. + * + * Optionally accepts a scale value to scale the resulting vector by. + * + * @function Phaser.Math.RandomXY + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} vector - The Vector to compute random values for. + * @param {number} [scale=1] - The scale of the random values. + * + * @return {Phaser.Math.Vector2} The given Vector. + */ +var RandomXY = function (vector, scale) +{ + if (scale === undefined) { scale = 1; } + + var r = Math.random() * 2 * Math.PI; + + vector.x = Math.cos(r) * scale; + vector.y = Math.sin(r) * scale; + + return vector; +}; + +module.exports = RandomXY; + + +/***/ }), +/* 537 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Work out what percentage `value` is of the range between `min` and `max`. + * If `max` isn't given then it will return the percentage of `value` to `min`. + * + * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. + * + * @function Phaser.Math.Percent + * @since 3.0.0 + * + * @param {number} value - The value to determine the percentage of. + * @param {number} min - The minimum value. + * @param {number} [max] - The maximum value. + * @param {number} [upperMax] - The mid-way point in the range that represents 100%. + * + * @return {number} A value between 0 and 1 representing the percentage. + */ +var Percent = function (value, min, max, upperMax) +{ + if (max === undefined) { max = min + 1; } + + var percentage = (value - min) / (max - min); + + if (percentage > 1) + { + if (upperMax !== undefined) + { + percentage = ((upperMax - value)) / (upperMax - max); + + if (percentage < 0) + { + percentage = 0; + } + } + else + { + percentage = 1; + } + } + else if (percentage < 0) + { + percentage = 0; + } + + return percentage; +}; + +module.exports = Percent; + + +/***/ }), +/* 538 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Subtract an `amount` from `value`, limiting the minimum result to `min`. + * + * @function Phaser.Math.MinSub + * @since 3.0.0 + * + * @param {number} value - The value to subtract from. + * @param {number} amount - The amount to subtract. + * @param {number} min - The minimum value to return. + * + * @return {number} The resulting value. + */ +var MinSub = function (value, amount, min) +{ + return Math.max(value - amount, min); +}; + +module.exports = MinSub; + + +/***/ }), +/* 539 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Add an `amount` to a `value`, limiting the maximum result to `max`. + * + * @function Phaser.Math.MaxAdd + * @since 3.0.0 + * + * @param {number} value - The value to add to. + * @param {number} amount - The amount to add. + * @param {number} max - The maximum value to return. + * + * @return {number} The resulting value. + */ +var MaxAdd = function (value, amount, max) +{ + return Math.min(value + amount, max); +}; + +module.exports = MaxAdd; + + +/***/ }), +/* 540 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check if a given value is an even number using a strict type check. + * + * @function Phaser.Math.IsEvenStrict + * @since 3.0.0 + * + * @param {number} value - The number to perform the check with. + * + * @return {boolean} Whether the number is even or not. + */ +var IsEvenStrict = function (value) +{ + // Use strict equality === for "is number" test + return (value === parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEvenStrict; + + +/***/ }), +/* 541 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Check if a given value is an even number. + * + * @function Phaser.Math.IsEven + * @since 3.0.0 + * + * @param {number} value - The number to perform the check with. + * + * @return {boolean} Whether the number is even or not. + */ +var IsEven = function (value) +{ + // Use abstract equality == for "is number" test + + // eslint-disable-next-line eqeqeq + return (value == parseFloat(value)) ? !(value % 2) : void 0; +}; + +module.exports = IsEven; + + +/***/ }), +/* 542 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the speed required to cover a distance in the time given. + * + * @function Phaser.Math.GetSpeed + * @since 3.0.0 + * + * @param {number} distance - The distance to travel in pixels. + * @param {integer} time - The time, in ms, to cover the distance in. + * + * @return {number} The amount you will need to increment the position by each step in order to cover the distance in the time given. + */ +var GetSpeed = function (distance, time) +{ + return (distance / time) / 1000; +}; + +module.exports = GetSpeed; + + +/***/ }), +/* 543 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Floors to some place comparative to a `base`, default is 10 for decimal place. + * + * The `place` is represented by the power applied to `base` to get that place. + * + * @function Phaser.Math.FloorTo + * @since 3.0.0 + * + * @param {number} value - The value to round. + * @param {integer} [place=0] - The place to round to. + * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. + * + * @return {number} The rounded value. + */ +var FloorTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.floor(value * p) / p; +}; + +module.exports = FloorTo; + + +/***/ }), +/* 544 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the positive difference of two given numbers. + * + * @function Phaser.Math.Difference + * @since 3.0.0 + * + * @param {number} a - The first number in the calculation. + * @param {number} b - The second number in the calculation. + * + * @return {number} The positive difference of the two given numbers. + */ +var Difference = function (a, b) +{ + return Math.abs(a - b); +}; + +module.exports = Difference; + + +/***/ }), +/* 545 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Ceils to some place comparative to a `base`, default is 10 for decimal place. + * + * The `place` is represented by the power applied to `base` to get that place. + * + * @function Phaser.Math.CeilTo + * @since 3.0.0 + * + * @param {number} value - The value to round. + * @param {number} [place=0] - The place to round to. + * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. + * + * @return {number} The rounded value. + */ +var CeilTo = function (value, place, base) +{ + if (place === undefined) { place = 0; } + if (base === undefined) { base = 10; } + + var p = Math.pow(base, -place); + + return Math.ceil(value * p) / p; +}; + +module.exports = CeilTo; + + +/***/ }), +/* 546 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the mean average of the given values. + * + * @function Phaser.Math.Average + * @since 3.0.0 + * + * @param {number[]} values - The values to average. + * + * @return {number} The average value. + */ +var Average = function (values) +{ + var sum = 0; + + for (var i = 0; i < values.length; i++) + { + sum += (+values[i]); + } + + return sum / values.length; +}; + +module.exports = Average; + + +/***/ }), +/* 547 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Snap a value to nearest grid slice, using rounding. + * + * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10` whereas `14` will snap to `15`. + * + * @function Phaser.Math.Snap.To + * @since 3.0.0 + * + * @param {number} value - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. + * + * @return {number} The snapped value. + */ +var SnapTo = function (value, gap, start, divide) +{ + if (start === undefined) { start = 0; } + + if (gap === 0) + { + return value; + } + + value -= start; + value = gap * Math.round(value / gap); + + return (divide) ? (start + value) / gap : start + value; +}; + +module.exports = SnapTo; + + +/***/ }), +/* 548 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -87119,29 +112451,48 @@ module.exports = PhysicsGroup; */ /** - * @namespace Phaser.Physics.Arcade.Components + * @namespace Phaser.Math.Snap */ module.exports = { - Acceleration: __webpack_require__(701), - Angular: __webpack_require__(700), - Bounce: __webpack_require__(699), - Debug: __webpack_require__(698), - Drag: __webpack_require__(697), - Enable: __webpack_require__(696), - Friction: __webpack_require__(695), - Gravity: __webpack_require__(694), - Immovable: __webpack_require__(693), - Mass: __webpack_require__(692), - Size: __webpack_require__(691), - Velocity: __webpack_require__(690) + Ceil: __webpack_require__(243), + Floor: __webpack_require__(142), + To: __webpack_require__(547) }; /***/ }), -/* 344 */ +/* 549 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Tests the value and returns `true` if it is a power of two. + * + * @function Phaser.Math.Pow2.IsValuePowerOfTwo + * @since 3.0.0 + * + * @param {number} value - The value to check if it's a power of two. + * + * @return {boolean} Returns `true` if `value` is a power of two, otherwise `false`. + */ +var IsValuePowerOfTwo = function (value) +{ + return (value > 0 && (value & (value - 1)) === 0); +}; + +module.exports = IsValuePowerOfTwo; + + +/***/ }), +/* 550 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -87150,91 +112501,21 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Components = __webpack_require__(343); -var Image = __webpack_require__(69); - /** - * @classdesc - * An Arcade Physics Image Game Object. - * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. - * - * @class Image - * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Arcade.Components.Acceleration - * @extends Phaser.Physics.Arcade.Components.Angular - * @extends Phaser.Physics.Arcade.Components.Bounce - * @extends Phaser.Physics.Arcade.Components.Debug - * @extends Phaser.Physics.Arcade.Components.Drag - * @extends Phaser.Physics.Arcade.Components.Enable - * @extends Phaser.Physics.Arcade.Components.Friction - * @extends Phaser.Physics.Arcade.Components.Gravity - * @extends Phaser.Physics.Arcade.Components.Immovable - * @extends Phaser.Physics.Arcade.Components.Mass - * @extends Phaser.Physics.Arcade.Components.Size - * @extends Phaser.Physics.Arcade.Components.Velocity - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip - * @extends Phaser.GameObjects.Components.GetBounds - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScaleMode - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @namespace Phaser.Math.Pow2 */ -var ArcadeImage = new Class({ - Extends: Image, +module.exports = { - Mixins: [ - Components.Acceleration, - Components.Angular, - Components.Bounce, - Components.Debug, - Components.Drag, - Components.Enable, - Components.Friction, - Components.Gravity, - Components.Immovable, - Components.Mass, - Components.Size, - Components.Velocity - ], + GetNext: __webpack_require__(294), + IsSize: __webpack_require__(117), + IsValue: __webpack_require__(549) - initialize: - - function ArcadeImage (scene, x, y, texture, frame) - { - Image.call(this, scene, x, y, texture, frame); - } - -}); - -module.exports = ArcadeImage; +}; /***/ }), -/* 345 */ +/* 551 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -87243,344 +112524,31 @@ module.exports = ArcadeImage; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ArcadeImage = __webpack_require__(344); -var ArcadeSprite = __webpack_require__(142); -var Class = __webpack_require__(0); -var CONST = __webpack_require__(42); -var PhysicsGroup = __webpack_require__(342); -var StaticPhysicsGroup = __webpack_require__(341); +var SmootherStep = __webpack_require__(182); /** - * @classdesc - * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. - * Objects that are created by this Factory are automatically added to the physics world. + * A Smoother Step interpolation method. * - * @class Factory - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 + * @function Phaser.Math.Interpolation.SmootherStep + * @since 3.9.0 + * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} * - * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics World instance. + * @param {number} t - The percentage of interpolation, between 0 and 1. + * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. + * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. + * + * @return {number} The interpolated value. */ -var Factory = new Class({ - - initialize: - - function Factory (world) - { - /** - * A reference to the Arcade Physics World. - * - * @name Phaser.Physics.Arcade.Factory#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world = world; - - /** - * A reference to the Scene this Arcade Physics instance belongs to. - * - * @name Phaser.Physics.Arcade.Factory#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = world.scene; - - /** - * A reference to the Scene.Systems this Arcade Physics instance belongs to. - * - * @name Phaser.Physics.Arcade.Factory#sys - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.sys = world.scene.sys; - }, - - /** - * Create a new Arcade Physics Collider object. - * - * @method Phaser.Physics.Arcade.Factory#collider - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for collision. - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for collision. - * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. - * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. - * @param {*} [callbackContext] - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - collider: function (object1, object2, collideCallback, processCallback, callbackContext) - { - return this.world.addCollider(object1, object2, collideCallback, processCallback, callbackContext); - }, - - /** - * Create a new Arcade Physics Collider Overlap object. - * - * @method Phaser.Physics.Arcade.Factory#overlap - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object1 - The first object to check for overlap. - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group|Phaser.GameObjects.Group[])} object2 - The second object to check for overlap. - * @param {ArcadePhysicsCallback} [collideCallback] - The callback to invoke when the two objects collide. - * @param {ArcadePhysicsCallback} [processCallback] - The callback to invoke when the two objects collide. Must return a boolean. - * @param {*} [callbackContext] - The scope in which to call the callbacks. - * - * @return {Phaser.Physics.Arcade.Collider} The Collider that was created. - */ - overlap: function (object1, object2, collideCallback, processCallback, callbackContext) - { - return this.world.addOverlap(object1, object2, collideCallback, processCallback, callbackContext); - }, - - /** - * Adds an Arcade Physics Body to the given Game Object. - * - * @method Phaser.Physics.Arcade.Factory#existing - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {boolean} [isStatic=false] - Set to true to create a Static body, otherwise it will create a Dynamic body. - * - * @return {Phaser.GameObjects.GameObject} The Game Object. - */ - existing: function (gameObject, isStatic) - { - var type = (isStatic) ? CONST.STATIC_BODY : CONST.DYNAMIC_BODY; - - this.world.enableBody(gameObject, type); - - return gameObject; - }, - - /** - * Creates a new Arcade Image object with a Static body. - * - * @method Phaser.Physics.Arcade.Factory#staticImage - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Image} The Image object that was created. - */ - staticImage: function (x, y, key, frame) - { - var image = new ArcadeImage(this.scene, x, y, key, frame); - - this.sys.displayList.add(image); - - this.world.enableBody(image, CONST.STATIC_BODY); - - return image; - }, - - /** - * Creates a new Arcade Image object with a Dynamic body. - * - * @method Phaser.Physics.Arcade.Factory#image - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Image} The Image object that was created. - */ - image: function (x, y, key, frame) - { - var image = new ArcadeImage(this.scene, x, y, key, frame); - - this.sys.displayList.add(image); - - this.world.enableBody(image, CONST.DYNAMIC_BODY); - - return image; - }, - - /** - * Creates a new Arcade Sprite object with a Static body. - * - * @method Phaser.Physics.Arcade.Factory#staticSprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. - */ - staticSprite: function (x, y, key, frame) - { - var sprite = new ArcadeSprite(this.scene, x, y, key, frame); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - this.world.enableBody(sprite, CONST.STATIC_BODY); - - return sprite; - }, - - /** - * Creates a new Arcade Sprite object with a Dynamic body. - * - * @method Phaser.Physics.Arcade.Factory#sprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.Physics.Arcade.Sprite} The Sprite object that was created. - */ - sprite: function (x, y, key, frame) - { - var sprite = new ArcadeSprite(this.scene, x, y, key, frame); - - this.sys.displayList.add(sprite); - this.sys.updateList.add(sprite); - - this.world.enableBody(sprite, CONST.DYNAMIC_BODY); - - return sprite; - }, - - /** - * Creates a Static Physics Group object. - * All Game Objects created by this Group will automatically be static Arcade Physics objects. - * - * @method Phaser.Physics.Arcade.Factory#staticGroup - * @since 3.0.0 - * - * @param {object|object[]} [children] - [description] - * @param {GroupConfig} [config] - [description] - * - * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. - */ - staticGroup: function (children, config) - { - return this.sys.updateList.add(new StaticPhysicsGroup(this.world, this.world.scene, children, config)); - }, - - /** - * Creates a Physics Group object. - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * - * @method Phaser.Physics.Arcade.Factory#group - * @since 3.0.0 - * - * @param {object|object[]} [children] - [description] - * @param {PhysicsGroupConfig} [config] - [description] - * - * @return {Phaser.Physics.Arcade.Group} The Group object that was created. - */ - 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; - } - -}); - -module.exports = Factory; - - -/***/ }), -/* 346 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Rotate a given point by a given angle around the origin (0, 0), in an anti-clockwise direction. - * - * @function Phaser.Math.Rotate - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. - * @param {number} angle - The angle to be rotated by in an anticlockwise direction. - * - * @return {Phaser.Geom.Point} The given point, rotated by the given angle in an anticlockwise direction. - */ -var Rotate = function (point, angle) +var SmootherStepInterpolation = function (t, min, max) { - var x = point.x; - var y = point.y; - - point.x = (x * Math.cos(angle)) - (y * Math.sin(angle)); - point.y = (x * Math.sin(angle)) + (y * Math.cos(angle)); - - return point; + return min + (max - min) * SmootherStep(t, 0, 1); }; -module.exports = Rotate; +module.exports = SmootherStepInterpolation; /***/ }), -/* 347 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the factorial of a given number for integer values greater than 0. - * - * @function Phaser.Math.Factorial - * @since 3.0.0 - * - * @param {number} value - A positive integer to calculate the factorial of. - * - * @return {number} The factorial of the given number. - */ -var Factorial = function (value) -{ - if (value === 0) - { - return 1; - } - - var res = value; - - while (--value) - { - res *= value; - } - - return res; -}; - -module.exports = Factorial; - - -/***/ }), -/* 348 */ +/* 552 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -87589,168 +112557,734 @@ module.exports = Factorial; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Factorial = __webpack_require__(347); +var Linear = __webpack_require__(119); /** - * [description] + * A linear interpolation method. * - * @function Phaser.Math.Bernstein + * @function Phaser.Math.Interpolation.Linear * @since 3.0.0 + * @see {@link https://en.wikipedia.org/wiki/Linear_interpolation} * - * @param {number} n - [description] - * @param {number} i - [description] + * @param {number[]} v - The input array of values to interpolate between. + * @param {!number} k - The percentage of interpolation, between 0 and 1. * - * @return {number} [description] + * @return {!number} The interpolated value. */ -var Bernstein = function (n, i) +var LinearInterpolation = function (v, k) { - return Factorial(n) / Factorial(i) / Factorial(n - i); -}; + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); -module.exports = Bernstein; - - -/***/ }), -/* 349 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check whether `a` is fuzzily less than `b`. - * - * `a` is fuzzily less than `b` if it is less than `b + epsilon`. - * - * @function Phaser.Math.Fuzzy.LessThan - * @since 3.0.0 - * - * @param {number} a - The first value. - * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {boolean} `true` if `a` is fuzzily less than `b`, otherwise `false`. - */ -var LessThan = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return a < b + epsilon; -}; - -module.exports = LessThan; - - -/***/ }), -/* 350 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check whether `a` is fuzzily greater than `b`. - * - * `a` is fuzzily greater than `b` if it is more than `b - epsilon`. - * - * @function Phaser.Math.Fuzzy.GreaterThan - * @since 3.0.0 - * - * @param {number} a - The first value. - * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {boolean} `true` if `a` is fuzzily greater than than `b`, otherwise `false`. - */ -var GreaterThan = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return a > b - epsilon; -}; - -module.exports = GreaterThan; - - -/***/ }), -/* 351 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check whether the given values are fuzzily equal. - * - * Two numbers are fuzzily equal if their difference is less than `epsilon`. - * - * @function Phaser.Math.Fuzzy.Equal - * @since 3.0.0 - * - * @param {number} a - The first value. - * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {boolean} `true` if the values are fuzzily equal, otherwise `false`. - */ -var Equal = function (a, b, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.abs(a - b) < epsilon; -}; - -module.exports = Equal; - - -/***/ }), -/* 352 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Normalize an angle to the [0, 2pi] range. - * - * @function Phaser.Math.Angle.Normalize - * @since 3.0.0 - * - * @param {number} angle - The angle to normalize, in radians. - * - * @return {number} The normalized angle, in radians. - */ -var Normalize = function (angle) -{ - angle = angle % (2 * Math.PI); - - if (angle >= 0) + if (k < 0) { - return angle; + return Linear(v[0], v[1], f); + } + + if (k > 1) + { + return Linear(v[m], v[m - 1], m - f); + } + + return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); +}; + +module.exports = LinearInterpolation; + + +/***/ }), +/* 553 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CatmullRom = __webpack_require__(171); + +/** + * A Catmull-Rom interpolation method. + * + * @function Phaser.Math.Interpolation.CatmullRom + * @since 3.0.0 + * + * @param {number[]} v - The input array of values to interpolate between. + * @param {number} k - The percentage of interpolation, between 0 and 1. + * + * @return {number} The interpolated value. + */ +var CatmullRomInterpolation = function (v, k) +{ + var m = v.length - 1; + var f = m * k; + var i = Math.floor(f); + + if (v[0] === v[m]) + { + if (k < 0) + { + i = Math.floor(f = m * (1 + k)); + } + + return CatmullRom(f - i, v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m]); } else { - return angle + 2 * Math.PI; + if (k < 0) + { + return v[0] - (CatmullRom(-f, v[0], v[0], v[1], v[1]) - v[0]); + } + + if (k > 1) + { + return v[m] - (CatmullRom(f - m, v[m], v[m], v[m - 1], v[m - 1]) - v[m]); + } + + return CatmullRom(f - i, v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2]); } }; -module.exports = Normalize; +module.exports = CatmullRomInterpolation; /***/ }), -/* 353 */ +/* 554 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Bernstein = __webpack_require__(245); + +/** + * A bezier interpolation method. + * + * @function Phaser.Math.Interpolation.Bezier + * @since 3.0.0 + * + * @param {number[]} v - The input array of values to interpolate between. + * @param {number} k - The percentage of interpolation, between 0 and 1. + * + * @return {number} The interpolated value. + */ +var BezierInterpolation = function (v, k) +{ + var b = 0; + var n = v.length - 1; + + for (var i = 0; i <= n; i++) + { + b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * Bernstein(n, i); + } + + return b; +}; + +module.exports = BezierInterpolation; + + +/***/ }), +/* 555 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Interpolation + */ + +module.exports = { + + Bezier: __webpack_require__(554), + CatmullRom: __webpack_require__(553), + CubicBezier: __webpack_require__(354), + Linear: __webpack_require__(552), + QuadraticBezier: __webpack_require__(350), + SmoothStep: __webpack_require__(334), + SmootherStep: __webpack_require__(551) + +}; + + +/***/ }), +/* 556 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the fuzzy floor of the given value. + * + * @function Phaser.Math.Fuzzy.Floor + * @since 3.0.0 + * + * @param {number} value - The value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {number} The floor of the value. + */ +var Floor = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.floor(value + epsilon); +}; + +module.exports = Floor; + + +/***/ }), +/* 557 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the fuzzy ceiling of the given value. + * + * @function Phaser.Math.Fuzzy.Ceil + * @since 3.0.0 + * + * @param {number} value - The value. + * @param {number} [epsilon=0.0001] - The epsilon. + * + * @return {number} The fuzzy ceiling of the value. + */ +var Ceil = function (value, epsilon) +{ + if (epsilon === undefined) { epsilon = 0.0001; } + + return Math.ceil(value - epsilon); +}; + +module.exports = Ceil; + + +/***/ }), +/* 558 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Fuzzy + */ + +module.exports = { + + Ceil: __webpack_require__(557), + Equal: __webpack_require__(248), + Floor: __webpack_require__(556), + GreaterThan: __webpack_require__(247), + LessThan: __webpack_require__(246) + +}; + + +/***/ }), +/* 559 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Easing + */ + +module.exports = { + + Back: __webpack_require__(369), + Bounce: __webpack_require__(368), + Circular: __webpack_require__(367), + Cubic: __webpack_require__(366), + Elastic: __webpack_require__(365), + Expo: __webpack_require__(364), + Linear: __webpack_require__(363), + Quadratic: __webpack_require__(362), + Quartic: __webpack_require__(361), + Quintic: __webpack_require__(360), + Sine: __webpack_require__(359), + Stepped: __webpack_require__(358) + +}; + + +/***/ }), +/* 560 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the distance between two sets of coordinates (points) to the power of `pow`. + * + * @function Phaser.Math.Distance.Power + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * @param {number} pow - The exponent. + * + * @return {number} The distance between each point. + */ +var DistancePower = function (x1, y1, x2, y2, pow) +{ + if (pow === undefined) { pow = 2; } + + return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow)); +}; + +module.exports = DistancePower; + + +/***/ }), +/* 561 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Distance + */ + +module.exports = { + + Between: __webpack_require__(52), + Power: __webpack_require__(560), + Squared: __webpack_require__(249) + +}; + + +/***/ }), +/* 562 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Gets the shortest angle between `angle1` and `angle2`. + * + * Both angles must be in the range -180 to 180, which is the same clamped + * range that `sprite.angle` uses, so you can pass in two sprite angles to + * this method and get the shortest angle back between the two of them. + * + * The angle returned will be in the same range. If the returned angle is + * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's + * a clockwise rotation. + * + * TODO: Wrap the angles in this function? + * + * @function Phaser.Math.Angle.ShortestBetween + * @since 3.0.0 + * + * @param {number} angle1 - The first angle in the range -180 to 180. + * @param {number} angle2 - The second angle in the range -180 to 180. + * + * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. + */ +var ShortestBetween = function (angle1, angle2) +{ + var difference = angle2 - angle1; + + if (difference === 0) + { + return 0; + } + + var times = Math.floor((difference - (-180)) / 360); + + return difference - (times * 360); + +}; + +module.exports = ShortestBetween; + + +/***/ }), +/* 563 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); + +/** + * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. + * + * @function Phaser.Math.Angle.RotateTo + * @since 3.0.0 + * + * @param {number} currentAngle - The current angle, in radians. + * @param {number} targetAngle - The target angle to rotate to, in radians. + * @param {number} [lerp=0.05] - The lerp value to add to the current angle. + * + * @return {number} The adjusted angle. + */ +var RotateTo = function (currentAngle, targetAngle, lerp) +{ + if (lerp === undefined) { lerp = 0.05; } + + if (currentAngle === targetAngle) + { + return currentAngle; + } + + if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp)) + { + currentAngle = targetAngle; + } + else + { + if (Math.abs(targetAngle - currentAngle) > Math.PI) + { + if (targetAngle < currentAngle) + { + targetAngle += MATH_CONST.PI2; + } + else + { + targetAngle -= MATH_CONST.PI2; + } + } + + if (targetAngle > currentAngle) + { + currentAngle += lerp; + } + else if (targetAngle < currentAngle) + { + currentAngle -= lerp; + } + } + + return currentAngle; +}; + +module.exports = RotateTo; + + +/***/ }), +/* 564 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Normalize = __webpack_require__(250); + +/** + * Reverse the given angle. + * + * @function Phaser.Math.Angle.Reverse + * @since 3.0.0 + * + * @param {number} angle - The angle to reverse, in radians. + * + * @return {number} The reversed angle, in radians. + */ +var Reverse = function (angle) +{ + return Normalize(angle + Math.PI); +}; + +module.exports = Reverse; + + +/***/ }), +/* 565 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * The difference between this method and {@link Phaser.Math.Angle.BetweenPoints} is that this assumes the y coordinate + * travels down the screen. + * + * @function Phaser.Math.Angle.BetweenPointsY + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - The first point. + * @param {(Phaser.Geom.Point|object)} point2 - The second point. + * + * @return {number} The angle in radians. + */ +var BetweenPointsY = function (point1, point2) +{ + return Math.atan2(point2.x - point1.x, point2.y - point1.y); +}; + +module.exports = BetweenPointsY; + + +/***/ }), +/* 566 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). + * + * Calculates the angle of the vector from the first point to the second point. + * + * @function Phaser.Math.Angle.BetweenPoints + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point1 - The first point. + * @param {(Phaser.Geom.Point|object)} point2 - The second point. + * + * @return {number} The angle in radians. + */ +var BetweenPoints = function (point1, point2) +{ + return Math.atan2(point2.y - point1.y, point2.x - point1.x); +}; + +module.exports = BetweenPoints; + + +/***/ }), +/* 567 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * + * The difference between this method and {@link Phaser.Math.Angle.Between} is that this assumes the y coordinate + * travels down the screen. + * + * @function Phaser.Math.Angle.BetweenY + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The angle in radians. + */ +var BetweenY = function (x1, y1, x2, y2) +{ + return Math.atan2(x2 - x1, y2 - y1); +}; + +module.exports = BetweenY; + + +/***/ }), +/* 568 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Find the angle of a segment from (x1, y1) -> (x2, y2). + * + * @function Phaser.Math.Angle.Between + * @since 3.0.0 + * + * @param {number} x1 - The x coordinate of the first point. + * @param {number} y1 - The y coordinate of the first point. + * @param {number} x2 - The x coordinate of the second point. + * @param {number} y2 - The y coordinate of the second point. + * + * @return {number} The angle in radians. + */ +var Between = function (x1, y1, x2, y2) +{ + return Math.atan2(y2 - y1, x2 - x1); +}; + +module.exports = Between; + + +/***/ }), +/* 569 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Math.Angle + */ + +module.exports = { + + Between: __webpack_require__(568), + BetweenY: __webpack_require__(567), + BetweenPoints: __webpack_require__(566), + BetweenPointsY: __webpack_require__(565), + Reverse: __webpack_require__(564), + RotateTo: __webpack_require__(563), + ShortestBetween: __webpack_require__(562), + Normalize: __webpack_require__(250), + Wrap: __webpack_require__(199), + WrapDegrees: __webpack_require__(198) + +}; + + +/***/ }), +/* 570 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(16); +var Extend = __webpack_require__(20); + +/** + * @namespace Phaser.Math + */ + +var PhaserMath = { + + // Collections of functions + Angle: __webpack_require__(569), + Distance: __webpack_require__(561), + Easing: __webpack_require__(559), + Fuzzy: __webpack_require__(558), + Interpolation: __webpack_require__(555), + Pow2: __webpack_require__(550), + Snap: __webpack_require__(548), + + // Expose the RNG Class + RandomDataGenerator: __webpack_require__(404), + + // Single functions + Average: __webpack_require__(546), + Bernstein: __webpack_require__(245), + Between: __webpack_require__(170), + CatmullRom: __webpack_require__(171), + CeilTo: __webpack_require__(545), + Clamp: __webpack_require__(23), + DegToRad: __webpack_require__(31), + Difference: __webpack_require__(544), + Factorial: __webpack_require__(244), + FloatBetween: __webpack_require__(299), + FloorTo: __webpack_require__(543), + FromPercent: __webpack_require__(93), + GetSpeed: __webpack_require__(542), + IsEven: __webpack_require__(541), + IsEvenStrict: __webpack_require__(540), + Linear: __webpack_require__(119), + MaxAdd: __webpack_require__(539), + MinSub: __webpack_require__(538), + Percent: __webpack_require__(537), + RadToDeg: __webpack_require__(172), + RandomXY: __webpack_require__(536), + RandomXYZ: __webpack_require__(535), + RandomXYZW: __webpack_require__(534), + Rotate: __webpack_require__(242), + RotateAround: __webpack_require__(396), + RotateAroundDistance: __webpack_require__(183), + RoundAwayFromZero: __webpack_require__(314), + RoundTo: __webpack_require__(533), + SinCosTableGenerator: __webpack_require__(532), + SmootherStep: __webpack_require__(182), + SmoothStep: __webpack_require__(181), + TransformXY: __webpack_require__(332), + Within: __webpack_require__(531), + Wrap: __webpack_require__(53), + + // Vector classes + Vector2: __webpack_require__(3), + Vector3: __webpack_require__(138), + Vector4: __webpack_require__(530), + Matrix3: __webpack_require__(241), + Matrix4: __webpack_require__(240), + Quaternion: __webpack_require__(239), + RotateVec3: __webpack_require__(529) + +}; + +// Merge in the consts + +PhaserMath = Extend(false, PhaserMath, CONST); + +// Export it + +module.exports = PhaserMath; + + +/***/ }), +/* 571 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -87761,12 +113295,12 @@ module.exports = Normalize; var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var CustomSet = __webpack_require__(70); -var EventEmitter = __webpack_require__(9); +var CustomSet = __webpack_require__(95); +var EventEmitter = __webpack_require__(11); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); -var XHRSettings = __webpack_require__(75); +var GetFastValue = __webpack_require__(2); +var PluginCache = __webpack_require__(15); +var XHRSettings = __webpack_require__(105); /** * @classdesc @@ -87796,7 +113330,7 @@ var XHRSettings = __webpack_require__(75); * * @class LoaderPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Loader + * @memberof Phaser.Loader * @constructor * @since 3.0.0 * @@ -87970,7 +113504,7 @@ var LoaderPlugin = new Class({ * Note that it is possible for this value to go down again if you add content to the current load queue during a load. * * @name Phaser.Loader.LoaderPlugin#progress - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -88055,7 +113589,7 @@ var LoaderPlugin = new Class({ * * @name Phaser.Loader.LoaderPlugin#state * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.state = CONST.LOADER_IDLE; @@ -88479,7 +114013,7 @@ var LoaderPlugin = new Class({ * a file having completed loading. * * @event Phaser.Loader.LoaderPlugin#progressEvent - * @param {float} progress - The current progress of the load. A value between 0 and 1. + * @param {number} progress - The current progress of the load. A value between 0 and 1. */ /** @@ -88582,6 +114116,12 @@ var LoaderPlugin = new Class({ */ nextFile: function (file, success) { + // Has the game been destroyed during load? If so, bail out now. + if (!this.inflight) + { + return; + } + this.inflight.delete(file); this.updateProgress(); @@ -88603,6 +114143,8 @@ var LoaderPlugin = new Class({ this._deleteQueue.set(file); this.emit('loaderror', file); + + this.fileProcessComplete(file); } }, @@ -88620,6 +114162,12 @@ var LoaderPlugin = new Class({ */ fileProcessComplete: function (file) { + // Has the game been destroyed during load? If so, bail out now. + if (!this.scene || !this.systems || !this.systems.game || this.systems.game.pendingDestroy) + { + return; + } + // This file has failed, so move it to the failed Set if (file.state === CONST.FILE_ERRORED) { @@ -88649,6 +114197,7 @@ var LoaderPlugin = new Class({ this.queue.delete(file); // Nothing left to do? + if (this.list.size === 0 && this.inflight.size === 0 && this.queue.size === 0) { this.loadComplete(); @@ -88839,7 +114388,7 @@ module.exports = LoaderPlugin; /***/ }), -/* 354 */ +/* 572 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -88850,7 +114399,1150 @@ module.exports = LoaderPlugin; var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var ImageFile = __webpack_require__(37); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); +var IsPlainObject = __webpack_require__(8); +var MultiFile = __webpack_require__(57); +var TextFile = __webpack_require__(251); + +/** + * @typedef {object} Phaser.Loader.FileTypes.UnityAtlasFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [atlasURL] - The absolute or relative URL to load the atlas data file from. + * @property {string} [atlasExtension='txt'] - The default file extension to use for the atlas data if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas data file. + */ + +/** + * @classdesc + * A single text file based Unity Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#unityAtlas method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#unityAtlas. + * + * @class UnityAtlasFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + */ +var UnityAtlasFile = new Class({ + + Extends: MultiFile, + + initialize: + + function UnityAtlasFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new TextFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'txt'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new TextFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'unityatlas', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'unityatlas', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.UnityAtlasFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.failed === 0 && !this.complete) + { + var image = this.files[0]; + var text = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addUnityAtlas(image.key, image.data, text.data, normalMap); + + text.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Adds a Unity YAML based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.UnityAtlasFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Unity Atlas File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#unityAtlas + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig|Phaser.Loader.FileTypes.UnityAtlasFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new UnityAtlasFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new UnityAtlasFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = UnityAtlasFile; + + +/***/ }), +/* 573 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); +var TILEMAP_FORMATS = __webpack_require__(29); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TilemapJSONFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Tiled Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. + * + * @class TilemapJSONFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TilemapJSONFile = new Class({ + + Extends: JSONFile, + + initialize: + + function TilemapJSONFile (loader, key, url, xhrSettings) + { + JSONFile.call(this, loader, key, url, xhrSettings); + + this.type = 'tilemapJSON'; + + this.cache = loader.cacheManager.tilemap; + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.TilemapJSONFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var tiledata = { format: TILEMAP_FORMATS.TILED_JSON, data: this.data }; + + this.cache.add(this.key, tiledata); + + this.pendingDestroy(tiledata); + } + +}); + +/** + * Adds a Tiled JSON Tilemap file, or array of map files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); + * } + * ``` + * + * The Tilemap data is created using the Tiled Map Editor and selecting JSON as the export format. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapTiledJSON({ + * key: 'level1', + * url: 'maps/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapJSONFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" + * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Tilemap JSON File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig|Phaser.Loader.FileTypes.TilemapJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapJSONFile(this, key[i])); + } + } + else + { + this.addFile(new TilemapJSONFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TilemapJSONFile; + + +/***/ }), +/* 574 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); +var TILEMAP_FORMATS = __webpack_require__(29); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TilemapImpactFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Impact.js Tilemap JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. + * + * @class TilemapImpactFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TilemapImpactFile = new Class({ + + Extends: JSONFile, + + initialize: + + function TilemapImpactFile (loader, key, url, xhrSettings) + { + JSONFile.call(this, loader, key, url, xhrSettings); + + this.type = 'tilemapJSON'; + + this.cache = loader.cacheManager.tilemap; + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.TilemapImpactFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var tiledata = { format: TILEMAP_FORMATS.WELTMEISTER, data: this.data }; + + this.cache.add(this.key, tiledata); + + this.pendingDestroy(tiledata); + } + +}); + +/** + * Adds an Impact.js Tilemap file, or array of map files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.tilemapImpact('level1', 'maps/Level1.json'); + * } + * ``` + * + * Impact Tilemap data is created the Impact.js Map Editor called Weltmeister. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapImpact({ + * key: 'level1', + * url: 'maps/Level1.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapImpactFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapImpact('level1', 'maps/Level1.json'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" + * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Tilemap Impact File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#tilemapImpact + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig|Phaser.Loader.FileTypes.TilemapImpactFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('tilemapImpact', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapImpactFile(this, key[i])); + } + } + else + { + this.addFile(new TilemapImpactFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TilemapImpactFile; + + +/***/ }), +/* 575 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); +var TILEMAP_FORMATS = __webpack_require__(29); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TilemapCSVFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='csv'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Tilemap CSV File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. + * + * @class TilemapCSVFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TilemapCSVFile = new Class({ + + Extends: File, + + initialize: + + function TilemapCSVFile (loader, key, url, xhrSettings) + { + var extension = 'csv'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'tilemapCSV', + cache: loader.cacheManager.tilemap, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + + this.tilemapFormat = TILEMAP_FORMATS.CSV; + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.TilemapCSVFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.TilemapCSVFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var tiledata = { format: this.tilemapFormat, data: this.data }; + + this.cache.add(this.key, tiledata); + + this.pendingDestroy(tiledata); + } + +}); + +/** + * Adds a CSV Tilemap file, or array of CSV files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.tilemapCSV('level1', 'maps/Level1.csv'); + * } + * ``` + * + * Tilemap CSV data can be created in a text editor, or a 3rd party app that exports as CSV. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.tilemapCSV({ + * key: 'level1', + * url: 'maps/Level1.csv' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TilemapCSVFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.tilemapCSV('level1', 'maps/Level1.csv'); + * // and later in your game ... + * var map = this.make.tilemap({ key: 'level1' }); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Tilemap Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" + * and no URL is given then the Loader will set the URL to be "level.csv". It will always add `.csv` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Tilemap CSV File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#tilemapCSV + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig|Phaser.Loader.FileTypes.TilemapCSVFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TilemapCSVFile(this, key[i])); + } + } + else + { + this.addFile(new TilemapCSVFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TilemapCSVFile; + + +/***/ }), +/* 576 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.SVGSizeConfig + * + * @property {integer} [width] - An optional width. The SVG will be resized to this size before being rendered to a texture. + * @property {integer} [height] - An optional height. The SVG will be resized to this size before being rendered to a texture. + * @property {number} [scale] - An optional scale. If given it overrides the width / height properties. The SVG is scaled by the scale factor before being rendered to a texture. + */ + +/** + * @typedef {object} Phaser.Loader.FileTypes.SVGFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='svg'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. + */ + +/** + * @classdesc + * A single SVG File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. + * + * @class SVGFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var SVGFile = new Class({ + + Extends: File, + + initialize: + + function SVGFile (loader, key, url, svgConfig, xhrSettings) + { + var extension = 'svg'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + svgConfig = GetFastValue(config, 'svgConfig', {}); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'svg', + cache: loader.textureManager, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + width: GetFastValue(svgConfig, 'width'), + height: GetFastValue(svgConfig, 'height'), + scale: GetFastValue(svgConfig, 'scale') + } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.SVGFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var text = this.xhrLoader.responseText; + var svg = [ text ]; + var width = this.config.width; + var height = this.config.height; + var scale = this.config.scale; + + resize: if (width && height || scale) + { + var xml = null; + var parser = new DOMParser(); + xml = parser.parseFromString(text, 'text/xml'); + var svgXML = xml.getElementsByTagName('svg')[0]; + + var hasViewBox = svgXML.hasAttribute('viewBox'); + var svgWidth = parseFloat(svgXML.getAttribute('width')); + var svgHeight = parseFloat(svgXML.getAttribute('height')); + + if (!hasViewBox && svgWidth && svgHeight) + { + // If there's no viewBox attribute, set one + svgXML.setAttribute('viewBox', '0 0 ' + svgWidth + ' ' + svgHeight); + } + else if (hasViewBox && !svgWidth && !svgHeight) + { + // Get the w/h from the viewbox + var viewBox = svgXML.getAttribute('viewBox').split(/\s+|,/); + + svgWidth = viewBox[2]; + svgHeight = viewBox[3]; + } + + if (scale) + { + if (svgWidth && svgHeight) + { + width = svgWidth * scale; + height = svgHeight * scale; + } + else + { + break resize; + } + } + + svgXML.setAttribute('width', width.toString() + 'px'); + svgXML.setAttribute('height', height.toString() + 'px'); + + svg = [ (new XMLSerializer()).serializeToString(svgXML) ]; + } + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + this.onProcessError(); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var _this = this; + var retry = false; + + this.data.onload = function () + { + if (!retry) + { + File.revokeObjectURL(_this.data); + } + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + // Safari 8 re-try + if (!retry) + { + retry = true; + + File.revokeObjectURL(_this.data); + + _this.data.src = 'data:image/svg+xml,' + encodeURIComponent(svg.join('')); + } + else + { + _this.onProcessError(); + } + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.SVGFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + +}); + +/** + * Adds an SVG File, or array of SVG Files, to the current load queue. When the files are loaded they + * will be rendered to bitmap textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SVGFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.svg('morty', 'images/Morty.svg'); + * // and later in your game ... + * this.add.image(x, y, 'morty'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can optionally pass an SVG Resize Configuration object when you load an SVG file. By default the SVG will be rendered to a texture + * at the same size defined in the SVG file attributes. However, this isn't always desirable. You may wish to resize the SVG (either down + * or up) to improve texture clarity, or reduce texture memory consumption. You can either specify an exact width and height to resize + * the SVG to: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { width: 300, height: 600 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * width: 300, + * height: 600 + * } + * }); + * ``` + * + * Alternatively, you can just provide a scale factor instead: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { scale: 2.5 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * scale: 2.5 + * } + * }); + * ``` + * + * If scale, width and height values are all given, the scale has priority and the width and height values are ignored. + * + * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#svg + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig|Phaser.Loader.FileTypes.SVGFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('svg', function (key, url, svgConfig, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new SVGFile(this, key[i])); + } + } + else + { + this.addFile(new SVGFile(this, key, url, svgConfig, xhrSettings)); + } + + return this; +}); + +module.exports = SVGFile; + + + +/***/ }), +/* 577 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var ImageFile = __webpack_require__(58); /** * @typedef {object} Phaser.Loader.FileTypes.SpriteSheetFileConfig @@ -88873,7 +115565,7 @@ var ImageFile = __webpack_require__(37); * * @class SpriteSheetFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -89041,7 +115733,7 @@ module.exports = SpriteSheetFile; /***/ }), -/* 355 */ +/* 578 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -89052,9 +115744,9 @@ module.exports = SpriteSheetFile; var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var File = __webpack_require__(19); +var File = __webpack_require__(21); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); var IsPlainObject = __webpack_require__(8); /** @@ -89076,7 +115768,7 @@ var IsPlainObject = __webpack_require__(8); * * @class ScriptFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -89221,7 +115913,7 @@ module.exports = ScriptFile; /***/ }), -/* 356 */ +/* 579 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -89232,9 +115924,226 @@ module.exports = ScriptFile; var Class = __webpack_require__(0); var CONST = __webpack_require__(18); -var File = __webpack_require__(19); +var File = __webpack_require__(21); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.ScenePluginFileConfig + * + * @property {string} key - The key of the file. Must be unique within the Loader. + * @property {(string|function)} [url] - The absolute or relative URL to load the file from. Or, a Scene Plugin. + * @property {string} [extension='js'] - The default file extension to use if no url is provided. + * @property {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. + * @property {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Scene Plugin Script File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#scenePlugin method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scenePlugin. + * + * @class ScenePluginFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.8.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. + * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var ScenePluginFile = new Class({ + + Extends: File, + + initialize: + + function ScenePluginFile (loader, key, url, systemKey, sceneKey, xhrSettings) + { + var extension = 'js'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + systemKey = GetFastValue(config, 'systemKey'); + sceneKey = GetFastValue(config, 'sceneKey'); + } + + var fileConfig = { + type: 'scenePlugin', + cache: false, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + systemKey: systemKey, + sceneKey: sceneKey + } + }; + + File.call(this, loader, fileConfig); + + // If the url variable refers to a class, add the plugin directly + if (typeof url === 'function') + { + this.data = url; + + this.state = CONST.FILE_POPULATED; + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.ScenePluginFile#onProcess + * @since 3.8.0 + */ + onProcess: function () + { + var pluginManager = this.loader.systems.plugins; + var config = this.config; + + var key = this.key; + var systemKey = GetFastValue(config, 'systemKey', key); + var sceneKey = GetFastValue(config, 'sceneKey', key); + + if (this.state === CONST.FILE_POPULATED) + { + pluginManager.installScenePlugin(systemKey, this.data, sceneKey, this.loader.scene); + } + else + { + // Plugin added via a js file + this.state = CONST.FILE_PROCESSING; + + this.data = document.createElement('script'); + this.data.language = 'javascript'; + this.data.type = 'text/javascript'; + this.data.defer = false; + this.data.text = this.xhrLoader.responseText; + + document.head.appendChild(this.data); + + pluginManager.installScenePlugin(systemKey, window[this.key], sceneKey, this.loader.scene); + } + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Scene Plugin Script file, or array of plugin files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.scenePlugin('ModPlayer', 'plugins/ModPlayer.js', 'modPlayer', 'mods'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String and not already in-use by another file in the Loader. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.scenePlugin({ + * key: 'modplayer', + * url: 'plugins/ModPlayer.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ScenePluginFileConfig` for more details. + * + * Once the file has finished loading it will automatically be converted into a script element + * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to + * false and then the resulting element will be appended to `document.head`. Any code then in the + * script will be executed. It will then be passed to the Phaser PluginCache.register method. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Script File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#scenePlugin + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.8.0 + * + * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig|Phaser.Loader.FileTypes.ScenePluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {(string|function)} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, set to a plugin function. + * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. + * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('scenePlugin', function (key, url, systemKey, sceneKey, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ScenePluginFile(this, key[i])); + } + } + else + { + this.addFile(new ScenePluginFile(this, key, url, systemKey, sceneKey, xhrSettings)); + } + + return this; +}); + +module.exports = ScenePluginFile; + + +/***/ }), +/* 580 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); var IsPlainObject = __webpack_require__(8); /** @@ -89258,7 +116167,7 @@ var IsPlainObject = __webpack_require__(8); * * @class PluginFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -89437,7 +116346,235 @@ module.exports = PluginFile; /***/ }), -/* 357 */ +/* 581 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var FileTypesManager = __webpack_require__(7); +var JSONFile = __webpack_require__(51); + +/** + * @typedef {object} Phaser.Loader.FileTypes.PackFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the JSON Cache. + * @property {string|any} [url] - The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly processed. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {string} [dataKey] - If specified instead of the whole JSON file being parsed, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single JSON Pack File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#pack method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#pack. + * + * @class PackFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + */ +var PackFile = new Class({ + + Extends: JSONFile, + + initialize: + + // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object + // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing + + function PackFile (loader, key, url, xhrSettings, dataKey) + { + JSONFile.call(this, loader, key, url, xhrSettings, dataKey); + + this.type = 'packfile'; + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.PackFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + if (this.state !== CONST.FILE_POPULATED) + { + this.state = CONST.FILE_PROCESSING; + + this.data = JSON.parse(this.xhrLoader.responseText); + } + + // Let's pass the pack file data over to the Loader ... + this.loader.addPack(this.data, this.config); + + this.onProcessComplete(); + } + +}); + +/** + * Adds a JSON File Pack, or array of packs, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.pack('level1', 'data/Level1Files.json'); + * } + * ``` + * + * A File Pack is a JSON file (or object) that contains details about other files that should be added into the Loader. + * Here is a small example: + * + * ```json + * { + * "test1": { + * "files": [ + * { + * "type": "image", + * "key": "taikodrummaster", + * "url": "assets/pics/taikodrummaster.jpg" + * }, + * { + * "type": "image", + * "key": "sukasuka-chtholly", + * "url": "assets/pics/sukasuka-chtholly.png" + * } + * ] + * }, + * "meta": { + * "generated": "1401380327373", + * "app": "Phaser 3 Asset Packer", + * "url": "https://phaser.io", + * "version": "1.0", + * "copyright": "Photon Storm Ltd. 2018" + * } + * } + * ``` + * + * The pack can be split into sections. In the example above you'll see a section called `test1. You can tell + * the `load.pack` method to parse only a particular section of a pack. The pack is stored in the JSON Cache, + * so you can pass it to the Loader to process additional sections as needed in your game, or you can just load + * them all at once without specifying anything. + * + * The pack file can contain an entry for any type of file that Phaser can load. The object structures exactly + * match that of the file type configs, and all properties available within the file type configs can be used + * in the pack file too. + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.pack({ + * key: 'level1', + * url: 'data/Level1Files.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.PackFileConfig` for more details. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the Pack File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#pack + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.PackFileConfig|Phaser.Loader.FileTypes.PackFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('pack', function (key, url, packKey, xhrSettings) +{ + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.addFile(new PackFile(this, key[i])); + } + } + else + { + this.addFile(new PackFile(this, key, url, xhrSettings, packKey)); + } + + return this; +}); + +module.exports = PackFile; + + +/***/ }), +/* 582 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -89448,11 +116585,11 @@ module.exports = PluginFile; var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); var IsPlainObject = __webpack_require__(8); -var JSONFile = __webpack_require__(28); -var MultiFile = __webpack_require__(36); +var JSONFile = __webpack_require__(51); +var MultiFile = __webpack_require__(57); /** * @typedef {object} Phaser.Loader.FileTypes.MultiAtlasFileConfig @@ -89476,7 +116613,7 @@ var MultiFile = __webpack_require__(36); * * @class MultiAtlasFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.7.0 * @@ -89773,7 +116910,645 @@ module.exports = MultiAtlasFile; /***/ }), -/* 358 */ +/* 583 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.HTMLTextureFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='html'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {integer} [width=512] - The width of the texture the HTML will be rendered to. + * @property {integer} [height=512] - The height of the texture the HTML will be rendered to. + */ + +/** + * @classdesc + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#htmlTexture method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#htmlTexture. + * + * @class HTMLTextureFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.12.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.HTMLTextureFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {integer} [width] - The width of the texture the HTML will be rendered to. + * @param {integer} [height] - The height of the texture the HTML will be rendered to. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var HTMLTextureFile = new Class({ + + Extends: File, + + initialize: + + function HTMLTextureFile (loader, key, url, width, height, xhrSettings) + { + if (width === undefined) { width = 512; } + if (height === undefined) { height = 512; } + + var extension = 'html'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + width = GetFastValue(config, 'width', width); + height = GetFastValue(config, 'height', height); + } + + var fileConfig = { + type: 'html', + cache: loader.textureManager, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + width: width, + height: height + } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.HTMLTextureFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var w = this.config.width; + var h = this.config.height; + + var data = []; + + data.push(''); + data.push(''); + data.push(''); + data.push(this.xhrLoader.responseText); + data.push(''); + data.push(''); + data.push(''); + + var svg = [ data.join('\n') ]; + var _this = this; + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + _this.state = CONST.FILE_ERRORED; + + _this.onProcessComplete(); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessError(); + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.HTMLTextureFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + +}); + +/** + * Adds an HTML File, or array of HTML Files, to the current load queue. When the files are loaded they + * will be rendered to textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.htmlTexture({ + * key: 'instructions', + * url: 'content/intro.html', + * width: 256, + * height: 512 + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLTextureFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); + * // and later in your game ... + * this.add.image(x, y, 'instructions'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * The width and height are the size of the texture to which the HTML will be rendered. It's not possible to determine these + * automatically, so you will need to provide them, either as arguments or in the file config object. + * When the HTML file has loaded a new SVG element is created with a size and viewbox set to the width and height given. + * The SVG file has a body tag added to it, with the HTML file contents included. It then calls `window.Blob` on the SVG, + * and if successful is added to the Texture Manager, otherwise it fails processing. The overall quality of the rendered + * HTML depends on your browser, and some of them may not even support the svg / blob process used. Be aware that there are + * limitations on what HTML can be inside an SVG. You can find out more details in this + * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). + * + * Note: The ability to load this type of file will only be available if the HTMLTextureFile File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#htmlTexture + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.12.0 + * + * @param {(string|Phaser.Loader.FileTypes.HTMLTextureFileConfig|Phaser.Loader.FileTypes.HTMLTextureFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {integer} [width=512] - The width of the texture the HTML will be rendered to. + * @param {integer} [height=512] - The height of the texture the HTML will be rendered to. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('htmlTexture', function (key, url, width, height, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new HTMLTextureFile(this, key[i])); + } + } + else + { + this.addFile(new HTMLTextureFile(this, key, url, width, height, xhrSettings)); + } + + return this; +}); + +module.exports = HTMLTextureFile; + + +/***/ }), +/* 584 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.HTMLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='html'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. + * + * @class HTMLFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.12.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var HTMLFile = new Class({ + + Extends: File, + + initialize: + + function HTMLFile (loader, key, url, xhrSettings) + { + var extension = 'html'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'text', + cache: loader.cacheManager.html, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.HTMLFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds an HTML file, or array of HTML files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.html('story', 'files/LoginForm.html'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global HTML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the HTML Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the HTML Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.html({ + * key: 'login', + * url: 'files/LoginForm.html' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.html('login', 'files/LoginForm.html'); + * // and later in your game ... + * var data = this.cache.html.get('login'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the html from the HTML Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the HTML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#html + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.12.0 + * + * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig|Phaser.Loader.FileTypes.HTMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('html', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new HTMLFile(this, key[i])); + } + } + else + { + this.addFile(new HTMLFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = HTMLFile; + + +/***/ }), +/* 585 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.GLSLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='glsl'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single GLSL File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl. + * + * @class GLSLFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var GLSLFile = new Class({ + + Extends: File, + + initialize: + + function GLSLFile (loader, key, url, xhrSettings) + { + var extension = 'glsl'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'glsl', + cache: loader.cacheManager.shader, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.GLSLFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a GLSL file, or array of GLSL files, to the current load queue. + * In Phaser 3 GLSL files are just plain Text files at the current moment in time. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.glsl('plasma', 'shaders/Plasma.glsl'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Shader Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Shader Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Shader Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.glsl({ + * key: 'plasma', + * url: 'shaders/Plasma.glsl' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.GLSLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.glsl('plasma', 'shaders/Plasma.glsl'); + * // and later in your game ... + * var data = this.cache.shader.get('plasma'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `FX.` and the key was `Plasma` the final key will be `FX.Plasma` and + * this is what you would use to retrieve the text from the Shader Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "plasma" + * and no URL is given then the Loader will set the URL to be "plasma.glsl". It will always add `.glsl` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the GLSL File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#glsl + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.GLSLFileConfig|Phaser.Loader.FileTypes.GLSLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.glsl`, i.e. if `key` was "alien" then the URL will be "alien.glsl". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('glsl', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new GLSLFile(this, key[i])); + } + } + else + { + this.addFile(new GLSLFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = GLSLFile; + + +/***/ }), +/* 586 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -89782,13 +117557,461 @@ module.exports = MultiAtlasFile; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AudioFile = __webpack_require__(168); var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); var IsPlainObject = __webpack_require__(8); -var JSONFile = __webpack_require__(28); -var MultiFile = __webpack_require__(36); +var MultiFile = __webpack_require__(57); +var ParseXMLBitmapFont = __webpack_require__(310); +var XMLFile = __webpack_require__(139); + +/** + * @typedef {object} Phaser.Loader.FileTypes.BitmapFontFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [fontDataURL] - The absolute or relative URL to load the font data xml file from. + * @property {string} [fontDataExtension='xml'] - The default file extension to use for the font data xml if no url is provided. + * @property {XHRSettingsObject} [fontDataXhrSettings] - Extra XHR Settings specifically for the font data xml file. + */ + +/** + * @classdesc + * A single Bitmap Font based File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. + * + * @class BitmapFontFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + */ +var BitmapFontFile = new Class({ + + Extends: MultiFile, + + initialize: + + function BitmapFontFile (loader, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new XMLFile(loader, { + key: key, + url: GetFastValue(config, 'fontDataURL'), + extension: GetFastValue(config, 'fontDataExtension', 'xml'), + xhrSettings: GetFastValue(config, 'fontDataXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new XMLFile(loader, key, fontDataURL, fontDataXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'bitmapfont', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'bitmapfont', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.BitmapFontFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var xml = this.files[1]; + + image.addToCache(); + xml.addToCache(); + + this.loader.cacheManager.bitmapFont.add(image.key, { data: ParseXMLBitmapFont(xml.data), texture: image.key, frame: null }); + + this.complete = true; + } + } + +}); + +/** + * Adds an XML based Bitmap Font, or array of fonts, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + + * ```javascript + * function preload () + * { + * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the font data to be provided in an XML file format. + * These files are created by software such as the [Angelcode Bitmap Font Generator](http://www.angelcode.com/products/bmfont/), + * [Littera](http://kvazars.com/littera/) or [Glyph Designer](https://71squared.com/glyphdesigner) + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.BitmapFontFileConfig` for more details. + * + * Once the atlas has finished loading you can use key of it when creating a Bitmap Text Game Object: + * + * ```javascript + * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); + * // and later in your game ... + * this.add.bitmapText(x, y, 'goldenFont', 'Hello World'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use when creating a Bitmap Text object. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.bitmapFont('goldenFont', [ 'images/GoldFont.png', 'images/GoldFont-n.png' ], 'images/GoldFont.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.bitmapFont({ + * key: 'goldenFont', + * textureURL: 'images/GoldFont.png', + * normalMap: 'images/GoldFont-n.png', + * fontDataURL: 'images/GoldFont.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Bitmap Font File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#bitmapFont + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig|Phaser.Loader.FileTypes.BitmapFontFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('bitmapFont', function (key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new BitmapFontFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new BitmapFontFile(this, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = BitmapFontFile; + + +/***/ }), +/* 587 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var CONST = __webpack_require__(18); +var File = __webpack_require__(21); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); + +/** + * @typedef {object} Phaser.Loader.FileTypes.BinaryFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Binary Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='bin'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ + +/** + * @classdesc + * A single Binary File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. + * + * @class BinaryFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + */ +var BinaryFile = new Class({ + + Extends: File, + + initialize: + + function BinaryFile (loader, key, url, xhrSettings, dataType) + { + var extension = 'bin'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + dataType = GetFastValue(config, 'dataType', dataType); + } + + var fileConfig = { + type: 'binary', + cache: loader.cacheManager.binary, + extension: extension, + responseType: 'arraybuffer', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { dataType: dataType } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.BinaryFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var ctor = this.config.dataType; + + this.data = (ctor) ? new ctor(this.xhrLoader.response) : this.xhrLoader.response; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Binary file, or array of Binary files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.binary('doom', 'files/Doom.wad'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Binary Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Binary Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Binary Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.binary({ + * key: 'doom', + * url: 'files/Doom.wad', + * dataType: Uint8Array + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.BinaryFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.binary('doom', 'files/Doom.wad'); + * // and later in your game ... + * var data = this.cache.binary.get('doom'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Data` the final key will be `LEVEL1.Data` and + * this is what you would use to retrieve the text from the Binary Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "doom" + * and no URL is given then the Loader will set the URL to be "doom.bin". It will always add `.bin` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Binary File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#binary + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig|Phaser.Loader.FileTypes.BinaryFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". + * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('binary', function (key, url, dataType, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new BinaryFile(this, key[i])); + } + } + else + { + this.addFile(new BinaryFile(this, key, url, xhrSettings, dataType)); + } + + return this; +}); + +module.exports = BinaryFile; + + +/***/ }), +/* 588 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AudioFile = __webpack_require__(253); +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var IsPlainObject = __webpack_require__(8); +var JSONFile = __webpack_require__(51); +var MultiFile = __webpack_require__(57); /** * @typedef {object} Phaser.Loader.FileTypes.AudioSpriteFileConfig @@ -89796,7 +118019,7 @@ var MultiFile = __webpack_require__(36); * @property {string} key - The key of the file. Must be unique within both the Loader and the Audio Cache. * @property {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. * @property {XHRSettingsObject} [jsonXhrSettings] - Extra XHR Settings specifically for the json file. - * @property {string} [audioURL] - The absolute or relative URL to load the audio file from. + * @property {{(string|string[])}} [audioURL] - The absolute or relative URL to load the audio file from. * @property {any} [audioConfig] - The audio configuration options. * @property {XHRSettingsObject} [audioXhrSettings] - Extra XHR Settings specifically for the audio file. */ @@ -89811,14 +118034,14 @@ var MultiFile = __webpack_require__(36); * * @class AudioSpriteFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.7.0 * * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig)} key - The key to use for this file, or a file configuration object. * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param {string} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {{(string|string[])}} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. * @param {any} [audioConfig] - The audio configuration options. * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. @@ -90022,7 +118245,7 @@ var AudioSpriteFile = new Class({ * * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig|Phaser.Loader.FileTypes.AudioSpriteFileConfig[])} key - The key to use for this file, or a file configuration object, or an array of objects. * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param {string} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {(string|string[])} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. * @param {any} [audioConfig] - The audio configuration options. * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. @@ -90074,7 +118297,7 @@ FileTypesManager.register('audioSprite', function (key, jsonURL, audioURL, audio /***/ }), -/* 359 */ +/* 589 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90085,11 +118308,266 @@ FileTypesManager.register('audioSprite', function (key, jsonURL, audioURL, audio var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); var IsPlainObject = __webpack_require__(8); -var JSONFile = __webpack_require__(28); -var MultiFile = __webpack_require__(36); +var MultiFile = __webpack_require__(57); +var XMLFile = __webpack_require__(139); + +/** + * @typedef {object} Phaser.Loader.FileTypes.AtlasXMLFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [atlasURL] - The absolute or relative URL to load the atlas xml file from. + * @property {string} [atlasExtension='xml'] - The default file extension to use for the atlas xml if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas xml file. + */ + +/** + * @classdesc + * A single XML based Texture Atlas File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. + * + * @class AtlasXMLFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + */ +var AtlasXMLFile = new Class({ + + Extends: MultiFile, + + initialize: + + function AtlasXMLFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) + { + var image; + var data; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + image = new ImageFile(loader, { + key: key, + url: GetFastValue(config, 'textureURL'), + extension: GetFastValue(config, 'textureExtension', 'png'), + normalMap: GetFastValue(config, 'normalMap'), + xhrSettings: GetFastValue(config, 'textureXhrSettings') + }); + + data = new XMLFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'xml'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + image = new ImageFile(loader, key, textureURL, textureXhrSettings); + data = new XMLFile(loader, key, atlasURL, atlasXhrSettings); + } + + if (image.linkFile) + { + // Image has a normal map + MultiFile.call(this, loader, 'atlasxml', key, [ image, data, image.linkFile ]); + } + else + { + MultiFile.call(this, loader, 'atlasxml', key, [ image, data ]); + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.AtlasXMLFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var image = this.files[0]; + var xml = this.files[1]; + var normalMap = (this.files[2]) ? this.files[2].data : null; + + this.loader.textureManager.addAtlasXML(image.key, image.data, xml.data, normalMap); + + xml.addToCache(); + + this.complete = true; + } + } + +}); + +/** + * Adds an XML based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in an XML file format. + * These files are created by software such as Shoebox and Adobe Flash / Animate. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.AtlasXMLFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.atlasXML('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.xml'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.atlasXML({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.xml' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Atlas XML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#atlasXML + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.7.0 + * + * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig|Phaser.Loader.FileTypes.AtlasXMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('atlasXML', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new AtlasXMLFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new AtlasXMLFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + +module.exports = AtlasXMLFile; + + +/***/ }), +/* 590 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var FileTypesManager = __webpack_require__(7); +var GetFastValue = __webpack_require__(2); +var ImageFile = __webpack_require__(58); +var IsPlainObject = __webpack_require__(8); +var JSONFile = __webpack_require__(51); +var MultiFile = __webpack_require__(57); /** * @typedef {object} Phaser.Loader.FileTypes.AtlasJSONFileConfig @@ -90116,7 +118594,7 @@ var MultiFile = __webpack_require__(36); * * @class AtlasJSONFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -90336,7 +118814,7 @@ module.exports = AtlasJSONFile; /***/ }), -/* 360 */ +/* 591 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90347,7 +118825,7 @@ module.exports = AtlasJSONFile; var Class = __webpack_require__(0); var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(28); +var JSONFile = __webpack_require__(51); /** * @classdesc @@ -90359,7 +118837,7 @@ var JSONFile = __webpack_require__(28); * * @class AnimationJSONFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -90538,7 +119016,91 @@ module.exports = AnimationJSONFile; /***/ }), -/* 361 */ +/* 592 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Loader.FileTypes + */ + +module.exports = { + + AnimationJSONFile: __webpack_require__(591), + AtlasJSONFile: __webpack_require__(590), + AtlasXMLFile: __webpack_require__(589), + AudioFile: __webpack_require__(253), + AudioSpriteFile: __webpack_require__(588), + BinaryFile: __webpack_require__(587), + BitmapFontFile: __webpack_require__(586), + GLSLFile: __webpack_require__(585), + HTML5AudioFile: __webpack_require__(252), + HTMLFile: __webpack_require__(584), + HTMLTextureFile: __webpack_require__(583), + ImageFile: __webpack_require__(58), + JSONFile: __webpack_require__(51), + MultiAtlasFile: __webpack_require__(582), + PackFile: __webpack_require__(581), + PluginFile: __webpack_require__(580), + ScenePluginFile: __webpack_require__(579), + ScriptFile: __webpack_require__(578), + SpriteSheetFile: __webpack_require__(577), + SVGFile: __webpack_require__(576), + TextFile: __webpack_require__(251), + TilemapCSVFile: __webpack_require__(575), + TilemapImpactFile: __webpack_require__(574), + TilemapJSONFile: __webpack_require__(573), + UnityAtlasFile: __webpack_require__(572), + XMLFile: __webpack_require__(139) + +}; + + +/***/ }), +/* 593 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(18); +var Extend = __webpack_require__(20); + +/** + * @namespace Phaser.Loader + */ + +var Loader = { + + FileTypes: __webpack_require__(592), + + File: __webpack_require__(21), + FileTypesManager: __webpack_require__(7), + GetURL: __webpack_require__(141), + LoaderPlugin: __webpack_require__(571), + MergeXHRSettings: __webpack_require__(140), + MultiFile: __webpack_require__(57), + XHRLoader: __webpack_require__(254), + XHRSettings: __webpack_require__(105) + +}; + +// Merge in the consts +Loader = Extend(false, Loader, CONST); + +module.exports = Loader; + + +/***/ }), +/* 594 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90554,14 +119116,14 @@ module.exports = AnimationJSONFile; /* eslint-disable */ module.exports = { - TouchManager: __webpack_require__(197) + TouchManager: __webpack_require__(333) }; /* eslint-enable */ /***/ }), -/* 362 */ +/* 595 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90577,14 +119139,14 @@ module.exports = { /* eslint-disable */ module.exports = { - MouseManager: __webpack_require__(199) + MouseManager: __webpack_require__(336) }; /* eslint-enable */ /***/ }), -/* 363 */ +/* 596 */ /***/ (function(module, exports) { /** @@ -90616,7 +119178,7 @@ module.exports = UpDuration; /***/ }), -/* 364 */ +/* 597 */ /***/ (function(module, exports) { /** @@ -90648,7 +119210,7 @@ module.exports = DownDuration; /***/ }), -/* 365 */ +/* 598 */ /***/ (function(module, exports) { /** @@ -90690,7 +119252,7 @@ module.exports = JustUp; /***/ }), -/* 366 */ +/* 599 */ /***/ (function(module, exports) { /** @@ -90732,7 +119294,7 @@ module.exports = JustDown; /***/ }), -/* 367 */ +/* 600 */ /***/ (function(module, exports) { /** @@ -90775,6 +119337,7 @@ var ProcessKeyUp = function (key, event) key._justDown = false; key._justUp = true; + key._tick = -1; return key; }; @@ -90783,7 +119346,7 @@ module.exports = ProcessKeyUp; /***/ }), -/* 368 */ +/* 601 */ /***/ (function(module, exports) { /** @@ -90842,7 +119405,7 @@ module.exports = ProcessKeyDown; /***/ }), -/* 369 */ +/* 602 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90851,7 +119414,7 @@ module.exports = ProcessKeyDown; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var KeyCodes = __webpack_require__(109); +var KeyCodes = __webpack_require__(143); var KeyMap = {}; @@ -90864,7 +119427,7 @@ module.exports = KeyMap; /***/ }), -/* 370 */ +/* 603 */ /***/ (function(module, exports) { /** @@ -90899,7 +119462,7 @@ module.exports = ResetKeyCombo; /***/ }), -/* 371 */ +/* 604 */ /***/ (function(module, exports) { /** @@ -90941,7 +119504,7 @@ module.exports = AdvanceKeyCombo; /***/ }), -/* 372 */ +/* 605 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -90950,7 +119513,7 @@ module.exports = AdvanceKeyCombo; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AdvanceKeyCombo = __webpack_require__(371); +var AdvanceKeyCombo = __webpack_require__(604); /** * Used internally by the KeyCombo class. @@ -91022,7 +119585,7 @@ module.exports = ProcessKeyCombo; /***/ }), -/* 373 */ +/* 606 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91032,15 +119595,16 @@ module.exports = ProcessKeyCombo; */ var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); +var EventEmitter = __webpack_require__(11); var GetValue = __webpack_require__(4); -var InputPluginCache = __webpack_require__(76); -var Key = __webpack_require__(171); -var KeyCodes = __webpack_require__(109); -var KeyCombo = __webpack_require__(170); -var KeyMap = __webpack_require__(369); -var ProcessKeyDown = __webpack_require__(368); -var ProcessKeyUp = __webpack_require__(367); +var InputPluginCache = __webpack_require__(106); +var Key = __webpack_require__(256); +var KeyCodes = __webpack_require__(143); +var KeyCombo = __webpack_require__(255); +var KeyMap = __webpack_require__(602); +var ProcessKeyDown = __webpack_require__(601); +var ProcessKeyUp = __webpack_require__(600); +var SnapFloor = __webpack_require__(142); /** * @classdesc @@ -91077,7 +119641,7 @@ var ProcessKeyUp = __webpack_require__(367); * * @class KeyboardPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Keyboard + * @memberof Phaser.Input.Keyboard * @constructor * @since 3.10.0 * @@ -91179,6 +119743,16 @@ var KeyboardPlugin = new Class({ */ this.onKeyHandler; + /** + * Internal time value. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#time + * @type {number} + * @private + * @since 3.11.0 + */ + this.time = 0; + sceneInputPlugin.pluginEvents.once('boot', this.boot, this); sceneInputPlugin.pluginEvents.on('start', this.start, this); }, @@ -91292,7 +119866,8 @@ var KeyboardPlugin = new Class({ /** * @typedef {object} CursorKeys - * + * @memberof Phaser.Input.Keyboard + * * @property {Phaser.Input.Keyboard.Key} [up] - A Key object mapping to the UP arrow key. * @property {Phaser.Input.Keyboard.Key} [down] - A Key object mapping to the DOWN arrow key. * @property {Phaser.Input.Keyboard.Key} [left] - A Key object mapping to the LEFT arrow key. @@ -91359,7 +119934,12 @@ var KeyboardPlugin = new Class({ for (var i = 0; i < keys.length; i++) { - output[keys[i]] = this.addKey(keys[i]); + var currentKey = keys[i].trim(); + + if (currentKey) + { + output[currentKey] = this.addKey(currentKey); + } } } else @@ -91466,11 +120046,11 @@ var KeyboardPlugin = new Class({ * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); @@ -91496,15 +120076,54 @@ var KeyboardPlugin = new Class({ return new KeyCombo(this, keys, config); }, + /** + * Checks if the given Key object is currently being held down. + * + * The difference between this method and checking the `Key.isDown` property directly is that you can provide + * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted + * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it + * will only return `true` every 100ms. + * + * If the Keyboard Plugin has been disabled, this method will always return `false`. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#checkDown + * @since 3.11.0 + * + * @param {Phaser.Input.Keyboard.Key} key - A Key object. + * @param {number} [duration=0] - The duration which must have elapsed before this Key is considered as being down. + * + * @return {boolean} `True` if the Key is down within the duration specified, otherwise `false`. + */ + checkDown: function (key, duration) + { + if (this.enabled && key.isDown) + { + var t = SnapFloor(this.time - key.timeDown, duration); + + if (t > key._tick) + { + key._tick = t; + + return true; + } + } + + return false; + }, + /** * Internal update handler called by the Input Manager, which is in turn invoked by the Game step. * * @method Phaser.Input.Keyboard.KeyboardPlugin#update * @private * @since 3.10.0 + * + * @param {number} time - The game loop time value. */ - update: function () + update: function (time) { + this.time = time; + var len = this.queue.length; if (!this.enabled || len === 0) @@ -91555,8 +120174,38 @@ var KeyboardPlugin = new Class({ }, /** - * Shuts the Keyboard Plugin down. - * All this does is remove any listeners bound to it. + * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. + * This can only reset keys created via the `addKey`, `addKeys` or `createCursors` methods. + * If you have created a Key object directly you'll need to reset it yourself. + * + * This method is called automatically when the Keyboard Plugin shuts down, but can be + * invoked directly at any time you require. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#resetKeys + * @since 3.15.0 + */ + resetKeys: function () + { + var keys = this.keys; + + for (var i = 0; i < keys.length; i++) + { + // Because it's a sparsely populated array + if (keys[i]) + { + keys[i].reset(); + } + } + + return this; + }, + + /** + * Shuts this Keyboard Plugin down. This performs the following tasks: + * + * 1 - Resets all keys created by this Keyboard plugin. + * 2 - Stops and removes the keyboard event listeners. + * 3 - Clears out any pending requests in the queue, without processing them. * * @method Phaser.Input.Keyboard.KeyboardPlugin#shutdown * @private @@ -91564,9 +120213,13 @@ var KeyboardPlugin = new Class({ */ shutdown: function () { + this.resetKeys(); + this.stopListeners(); this.removeAllListeners(); + + this.queue = []; }, /** @@ -91606,7 +120259,7 @@ module.exports = KeyboardPlugin; /***/ }), -/* 374 */ +/* 607 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91621,23 +120274,23 @@ module.exports = KeyboardPlugin; module.exports = { - KeyboardPlugin: __webpack_require__(373), + KeyboardPlugin: __webpack_require__(606), - Key: __webpack_require__(171), - KeyCodes: __webpack_require__(109), + Key: __webpack_require__(256), + KeyCodes: __webpack_require__(143), - KeyCombo: __webpack_require__(170), + KeyCombo: __webpack_require__(255), - JustDown: __webpack_require__(366), - JustUp: __webpack_require__(365), - DownDuration: __webpack_require__(364), - UpDuration: __webpack_require__(363) + JustDown: __webpack_require__(599), + JustUp: __webpack_require__(598), + DownDuration: __webpack_require__(597), + UpDuration: __webpack_require__(596) }; /***/ }), -/* 375 */ +/* 608 */ /***/ (function(module, exports) { /** @@ -91663,7 +120316,7 @@ var CreatePixelPerfectHandler = function (textureManager, alphaTolerance) { return function (hitArea, x, y, gameObject) { - var alpha = textureManager.getPixelAlpha(x, y, gameObject.texture.key, gameObject.frame.key); + var alpha = textureManager.getPixelAlpha(x, y, gameObject.texture.key, gameObject.frame.name); return (alpha && alpha >= alphaTolerance); }; @@ -91673,7 +120326,7 @@ module.exports = CreatePixelPerfectHandler; /***/ }), -/* 376 */ +/* 609 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -91682,23 +120335,23 @@ module.exports = CreatePixelPerfectHandler; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Circle = __webpack_require__(88); -var CircleContains = __webpack_require__(32); +var Circle = __webpack_require__(71); +var CircleContains = __webpack_require__(40); var Class = __webpack_require__(0); -var CreateInteractiveObject = __webpack_require__(175); -var CreatePixelPerfectHandler = __webpack_require__(375); -var DistanceBetween = __webpack_require__(58); -var Ellipse = __webpack_require__(114); -var EllipseContains = __webpack_require__(54); -var EventEmitter = __webpack_require__(9); -var GetFastValue = __webpack_require__(1); -var InputPluginCache = __webpack_require__(76); +var CreateInteractiveObject = __webpack_require__(260); +var CreatePixelPerfectHandler = __webpack_require__(608); +var DistanceBetween = __webpack_require__(52); +var Ellipse = __webpack_require__(90); +var EllipseContains = __webpack_require__(89); +var EventEmitter = __webpack_require__(11); +var GetFastValue = __webpack_require__(2); +var InputPluginCache = __webpack_require__(106); var IsPlainObject = __webpack_require__(8); -var PluginCache = __webpack_require__(12); -var Rectangle = __webpack_require__(14); -var RectangleContains = __webpack_require__(31); -var Triangle = __webpack_require__(68); -var TriangleContains = __webpack_require__(60); +var PluginCache = __webpack_require__(15); +var Rectangle = __webpack_require__(9); +var RectangleContains = __webpack_require__(39); +var Triangle = __webpack_require__(59); +var TriangleContains = __webpack_require__(69); /** * @classdesc @@ -91727,7 +120380,7 @@ var TriangleContains = __webpack_require__(60); * * @class InputPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input + * @memberof Phaser.Input * @constructor * @since 3.0.0 * @@ -91879,6 +120532,33 @@ var InputPlugin = new Class({ */ this._pollTimer = 0; + var _eventData = { cancelled: false }; + + /** + * Internal event propagation callback container. + * + * @name Phaser.Input.InputPlugin#_eventContainer + * @type {object} + * @private + * @since 3.13.0 + */ + this._eventContainer = { + stopPropagation: function () + { + _eventData.cancelled = true; + } + }; + + /** + * Internal event propagation data object. + * + * @name Phaser.Input.InputPlugin#_eventData + * @type {object} + * @private + * @since 3.13.0 + */ + this._eventData = _eventData; + /** * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. * @@ -92246,6 +120926,8 @@ var InputPlugin = new Class({ input.hitAreaCallback = undefined; input.callbackContext = undefined; + this.manager.resetCursor(input); + gameObject.input = null; // Clear from _draggable, _drag and _over @@ -92361,7 +121043,7 @@ var InputPlugin = new Class({ { var camera = cameras[c]; - // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array. + // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'over' array. // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. var over = this.manager.hitTest(pointer, this._list, camera); @@ -92384,6 +121066,11 @@ var InputPlugin = new Class({ } } + // If we got this far then there were no Game Objects below the pointer, but it was still over + // a camera, so set that the top-most one into the pointer + + pointer.camera = cameras[0]; + return []; }, @@ -92400,12 +121087,15 @@ var InputPlugin = new Class({ */ processDownEvents: function (pointer) { + var total = 0; var currentlyOver = this._temp; - // Contains ALL Game Objects currently over in the array - this.emit('pointerdown', pointer, currentlyOver); + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; - var total = 0; + _eventData.cancelled = false; + + var aborted = false; // Go through all objects the pointer was over and fire their events / callbacks for (var i = 0; i < currentlyOver.length; i++) @@ -92419,9 +121109,27 @@ var InputPlugin = new Class({ total++; - gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, pointer.camera); + gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); - this.emit('gameobjectdown', pointer, gameObject); + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectdown', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + // Contains ALL Game Objects currently over in the array + if (!aborted) + { + this.emit('pointerdown', pointer, currentlyOver); } return total; @@ -92481,7 +121189,7 @@ var InputPlugin = new Class({ { gameObject = currentlyOver[i]; - if (gameObject.input.draggable) + if (gameObject.input.draggable && (gameObject.input.dragState === 0)) { draglist.push(gameObject); } @@ -92708,11 +121416,15 @@ var InputPlugin = new Class({ */ processMoveEvents: function (pointer) { + var total = 0; var currentlyOver = this._temp; - this.emit('pointermove', pointer, currentlyOver); + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; - var total = 0; + _eventData.cancelled = false; + + var aborted = false; // Go through all objects the pointer was over and fire their events / callbacks for (var i = 0; i < currentlyOver.length; i++) @@ -92726,9 +121438,21 @@ var InputPlugin = new Class({ total++; - gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY); + gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); - this.emit('gameobjectmove', pointer, gameObject); + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectmove', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } if (this.topOnly) { @@ -92736,6 +121460,11 @@ var InputPlugin = new Class({ } } + if (!aborted) + { + this.emit('pointermove', pointer, currentlyOver); + } + return total; }, @@ -92804,12 +121533,17 @@ var InputPlugin = new Class({ var totalInteracted = 0; + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; + if (total > 0) { this.sortGameObjects(justOut); - this.emit('pointerout', pointer, justOut); - // Call onOut for everything in the justOut array for (i = 0; i < total; i++) { @@ -92820,25 +121554,44 @@ var InputPlugin = new Class({ continue; } - this.emit('gameobjectout', pointer, gameObject); - - gameObject.emit('pointerout', pointer); + gameObject.emit('pointerout', pointer, _eventContainer); manager.resetCursor(gameObject.input); totalInteracted++; + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectout', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + this.emit('pointerout', pointer, justOut); } } // Process the Just Over objects total = justOver.length; + _eventData.cancelled = false; + + aborted = false; + if (total > 0) { this.sortGameObjects(justOver); - this.emit('pointerover', pointer, justOver); - // Call onOver for everything in the justOver array for (i = 0; i < total; i++) { @@ -92849,13 +121602,30 @@ var InputPlugin = new Class({ continue; } - this.emit('gameobjectover', pointer, gameObject); - - gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY); + gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); manager.setCursor(gameObject.input); totalInteracted++; + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectover', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + this.emit('pointerover', pointer, justOver); } } @@ -92883,8 +121653,12 @@ var InputPlugin = new Class({ { var currentlyOver = this._temp; - // Contains ALL Game Objects currently up in the array - this.emit('pointerup', pointer, currentlyOver); + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; // Go through all objects the pointer was over and fire their events / callbacks for (var i = 0; i < currentlyOver.length; i++) @@ -92898,9 +121672,27 @@ var InputPlugin = new Class({ // pointerupoutside - gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY); + gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); - this.emit('gameobjectup', pointer, gameObject); + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectup', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + // Contains ALL Game Objects currently up in the array + this.emit('pointerup', pointer, currentlyOver); } return currentlyOver.length; @@ -93781,7 +122573,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#x * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ x: { @@ -93799,7 +122591,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#y * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ y: { @@ -93818,7 +122610,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#mousePointer * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ mousePointer: { @@ -93835,7 +122627,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#activePointer * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.0.0 */ activePointer: { @@ -93853,7 +122645,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer1 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer1: { @@ -93871,7 +122663,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer2 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer2: { @@ -93889,7 +122681,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer3 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer3: { @@ -93907,7 +122699,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer4 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer4: { @@ -93925,7 +122717,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer5 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer5: { @@ -93943,7 +122735,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer6 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer6: { @@ -93961,7 +122753,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer7 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer7: { @@ -93979,7 +122771,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer8 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer8: { @@ -93997,7 +122789,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer9 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer9: { @@ -94015,7 +122807,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer10 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer10: { @@ -94035,7 +122827,7 @@ module.exports = InputPlugin; /***/ }), -/* 377 */ +/* 610 */ /***/ (function(module, exports) { /** @@ -94086,7 +122878,7 @@ module.exports = { /***/ }), -/* 378 */ +/* 611 */ /***/ (function(module, exports) { /** @@ -94125,7 +122917,7 @@ module.exports = { /***/ }), -/* 379 */ +/* 612 */ /***/ (function(module, exports) { /** @@ -94175,7 +122967,7 @@ module.exports = { /***/ }), -/* 380 */ +/* 613 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -94190,15 +122982,15 @@ module.exports = { module.exports = { - DUALSHOCK_4: __webpack_require__(379), - SNES_USB: __webpack_require__(378), - XBOX_360: __webpack_require__(377) + DUALSHOCK_4: __webpack_require__(612), + SNES_USB: __webpack_require__(611), + XBOX_360: __webpack_require__(610) }; /***/ }), -/* 381 */ +/* 614 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -94208,10 +123000,10 @@ module.exports = { */ var Class = __webpack_require__(0); -var EventEmitter = __webpack_require__(9); -var Gamepad = __webpack_require__(172); +var EventEmitter = __webpack_require__(11); +var Gamepad = __webpack_require__(257); var GetValue = __webpack_require__(4); -var InputPluginCache = __webpack_require__(76); +var InputPluginCache = __webpack_require__(106); /** * @typedef {object} Pad @@ -94257,7 +123049,7 @@ var InputPluginCache = __webpack_require__(76); * * @class GamepadPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.10.0 * @@ -94841,7 +123633,7 @@ module.exports = GamepadPlugin; /***/ }), -/* 382 */ +/* 615 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -94856,17 +123648,17 @@ module.exports = GamepadPlugin; module.exports = { - Axis: __webpack_require__(174), - Button: __webpack_require__(173), - Gamepad: __webpack_require__(172), - GamepadPlugin: __webpack_require__(381), + Axis: __webpack_require__(259), + Button: __webpack_require__(258), + Gamepad: __webpack_require__(257), + GamepadPlugin: __webpack_require__(614), - Configs: __webpack_require__(380) + Configs: __webpack_require__(613) }; /***/ }), -/* 383 */ +/* 616 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -94875,8 +123667,8 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CONST = __webpack_require__(200); -var Extend = __webpack_require__(17); +var CONST = __webpack_require__(337); +var Extend = __webpack_require__(20); /** * @namespace Phaser.Input @@ -94884,15 +123676,15 @@ var Extend = __webpack_require__(17); var Input = { - CreateInteractiveObject: __webpack_require__(175), - Gamepad: __webpack_require__(382), - InputManager: __webpack_require__(201), - InputPlugin: __webpack_require__(376), - InputPluginCache: __webpack_require__(76), - Keyboard: __webpack_require__(374), - Mouse: __webpack_require__(362), - Pointer: __webpack_require__(198), - Touch: __webpack_require__(361) + CreateInteractiveObject: __webpack_require__(260), + Gamepad: __webpack_require__(615), + InputManager: __webpack_require__(338), + InputPlugin: __webpack_require__(609), + InputPluginCache: __webpack_require__(106), + Keyboard: __webpack_require__(607), + Mouse: __webpack_require__(595), + Pointer: __webpack_require__(335), + Touch: __webpack_require__(594) }; @@ -94903,7 +123695,7 @@ module.exports = Input; /***/ }), -/* 384 */ +/* 617 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -94912,37 +123704,634 @@ module.exports = Input; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); - -// The three angle bisectors of a triangle meet in one point called the incenter. -// It is the center of the incircle, the circle inscribed in the triangle. - -function getLength (x1, y1, x2, y2) -{ - var x = x1 - x2; - var y = y1 - y2; - var magnitude = (x * x) + (y * y); - - return Math.sqrt(magnitude); -} +var RotateAroundXY = __webpack_require__(144); /** * [description] * - * @function Phaser.Geom.Triangle.InCenter + * @function Phaser.Geom.Triangle.RotateAroundPoint * @since 3.0.0 * - * @generic {Phaser.Geom.Point} O - [out,$return] + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] * * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {Phaser.Geom.Point} point - [description] + * @param {number} angle - [description] * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Triangle} [description] */ -var InCenter = function (triangle, out) +var RotateAroundPoint = function (triangle, point, angle) { - if (out === undefined) { out = new Point(); } + return RotateAroundXY(triangle, point.x, point.y, angle); +}; +module.exports = RotateAroundPoint; + + +/***/ }), +/* 618 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(144); +var InCenter = __webpack_require__(261); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Rotate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {number} angle - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Rotate = function (triangle, angle) +{ + var point = InCenter(triangle); + + return RotateAroundXY(triangle, point.x, point.y, angle); +}; + +module.exports = Rotate; + + +/***/ }), +/* 619 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(65); + +// The 2D area of a triangle. The area value is always non-negative. + +/** + * Gets the length of the perimeter of the given triangle. + * + * @function Phaser.Geom.Triangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {number} [description] + */ +var Perimeter = function (triangle) +{ + var line1 = triangle.getLineA(); + var line2 = triangle.getLineB(); + var line3 = triangle.getLineC(); + + return (Length(line1) + Length(line2) + Length(line3)); +}; + +module.exports = Perimeter; + + +/***/ }), +/* 620 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns true if two triangles have the same coordinates. + * + * @function Phaser.Geom.Triangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The first triangle to check. + * @param {Phaser.Geom.Triangle} toCompare - The second triangle to check. + * + * @return {boolean} `true` if the two given triangles have the exact same coordinates, otherwise `false`. + */ +var Equals = function (triangle, toCompare) +{ + return ( + triangle.x1 === toCompare.x1 && + triangle.y1 === toCompare.y1 && + triangle.x2 === toCompare.x2 && + triangle.y2 === toCompare.y2 && + triangle.x3 === toCompare.x3 && + triangle.y3 === toCompare.y3 + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 621 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one Triangle to a destination Triangle. + * + * @function Phaser.Geom.Triangle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [dest,$return] + * + * @param {Phaser.Geom.Triangle} source - The source Triangle to copy the values from. + * @param {Phaser.Geom.Triangle} dest - The destination Triangle to copy the values to. + * + * @return {Phaser.Geom.Triangle} The destination Triangle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 622 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(69); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Point} point - [description] + * + * @return {boolean} [description] + */ +var ContainsPoint = function (triangle, point) +{ + return Contains(triangle, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 623 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(59); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} source - [description] + * + * @return {Phaser.Geom.Triangle} [description] + */ +var Clone = function (source) +{ + return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); +}; + +module.exports = Clone; + + +/***/ }), +/* 624 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(71); + +// Adapted from https://gist.github.com/mutoo/5617691 + +/** + * [description] + * + * @function Phaser.Geom.Triangle.CircumCircle + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Circle} [out] - [description] + * + * @return {Phaser.Geom.Circle} [description] + */ +var CircumCircle = function (triangle, out) +{ + if (out === undefined) { out = new Circle(); } + + // A + var x1 = triangle.x1; + var y1 = triangle.y1; + + // B + var x2 = triangle.x2; + var y2 = triangle.y2; + + // C + var x3 = triangle.x3; + var y3 = triangle.y3; + + var A = x2 - x1; + var B = y2 - y1; + var C = x3 - x1; + var D = y3 - y1; + var E = A * (x1 + x2) + B * (y1 + y2); + var F = C * (x1 + x3) + D * (y1 + y3); + var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); + + var dx; + var dy; + + // If the points of the triangle are collinear, then just find the + // extremes and use the midpoint as the center of the circumcircle. + + if (Math.abs(G) < 0.000001) + { + var minX = Math.min(x1, x2, x3); + var minY = Math.min(y1, y2, y3); + dx = (Math.max(x1, x2, x3) - minX) * 0.5; + dy = (Math.max(y1, y2, y3) - minY) * 0.5; + + out.x = minX + dx; + out.y = minY + dy; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + else + { + out.x = (D * E - B * F) / G; + out.y = (A * F - C * E) / G; + dx = out.x - x1; + dy = out.y - y1; + out.radius = Math.sqrt(dx * dx + dy * dy); + } + + return out; +}; + +module.exports = CircumCircle; + + +/***/ }), +/* 625 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector2 = __webpack_require__(3); + +// Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html + +/** + * Computes the determinant of a 2x2 matrix. Uses standard double-precision arithmetic, so is susceptible to round-off error. + * + * @function det + * @private + * @since 3.0.0 + * + * @param {number} m00 - The [0,0] entry of the matrix. + * @param {number} m01 - The [0,1] entry of the matrix. + * @param {number} m10 - The [1,0] entry of the matrix. + * @param {number} m11 - The [1,1] entry of the matrix. + * + * @return {number} the determinant. + */ +function det (m00, m01, m10, m11) +{ + return (m00 * m11) - (m01 * m10); +} + +/** + * Computes the circumcentre of a triangle. The circumcentre is the centre of + * the circumcircle, the smallest circle which encloses the triangle. It is also + * the common intersection point of the perpendicular bisectors of the sides of + * the triangle, and is the only point which has equal distance to all three + * vertices of the triangle. + * + * @function Phaser.Geom.Triangle.CircumCenter + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [out,$return] + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Math.Vector2} [out] - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ +var CircumCenter = function (triangle, out) +{ + if (out === undefined) { out = new Vector2(); } + + var cx = triangle.x3; + var cy = triangle.y3; + + var ax = triangle.x1 - cx; + var ay = triangle.y1 - cy; + + var bx = triangle.x2 - cx; + var by = triangle.y2 - cy; + + var denom = 2 * det(ax, ay, bx, by); + var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); + var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); + + out.x = cx - numx / denom; + out.y = cy + numy / denom; + + return out; +}; + +module.exports = CircumCenter; + + +/***/ }), +/* 626 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Centroid = __webpack_require__(263); +var Offset = __webpack_require__(262); + +/** + * @callback CenterFunction + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {Phaser.Math.Vector2} [description] + */ + +/** + * Positions the Triangle so that it is centered on the given coordinates. + * + * @function Phaser.Geom.Triangle.CenterOn + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle} O - [triangle,$return] + * + * @param {Phaser.Geom.Triangle} triangle - The triangle to be positioned. + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {CenterFunction} [centerFunc] - The function used to center the triangle. Defaults to Centroid centering. + * + * @return {Phaser.Geom.Triangle} The Triangle that was centered. + */ +var CenterOn = function (triangle, x, y, centerFunc) +{ + if (centerFunc === undefined) { centerFunc = Centroid; } + + // Get the center of the triangle + var center = centerFunc(triangle); + + // Difference + var diffX = x - center.x; + var diffY = y - center.y; + + return Offset(triangle, diffX, diffY); +}; + +module.exports = CenterOn; + + +/***/ }), +/* 627 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(59); + +// Builds a right triangle, with one 90 degree angle and two acute angles +// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) +// w/h can be positive or negative and represent the length of each side + +/** + * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. + * + * @function Phaser.Geom.Triangle.BuildRight + * @since 3.0.0 + * + * @param {number} x - The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. + * @param {number} y - The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. + * @param {number} width - The length of the side which is to the left or to the right of the right angle. + * @param {number} height - The length of the side which is above or below the right angle. + * + * @return {Phaser.Geom.Triangle} The constructed right Triangle. + */ +var BuildRight = function (x, y, width, height) +{ + if (height === undefined) { height = width; } + + // 90 degree angle + var x1 = x; + var y1 = y; + + var x2 = x; + var y2 = y - height; + + var x3 = x + width; + var y3 = y; + + return new Triangle(x1, y1, x2, y2, x3, y3); +}; + +module.exports = BuildRight; + + +/***/ }), +/* 628 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var EarCut = __webpack_require__(64); +var Triangle = __webpack_require__(59); + +/** + * [description] + * + * @function Phaser.Geom.Triangle.BuildFromPolygon + * @since 3.0.0 + * + * @generic {Phaser.Geom.Triangle[]} O - [out,$return] + * + * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] + * @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). + * @param {number} [scaleX=1] - [description] + * @param {number} [scaleY=1] - [description] + * @param {(array|Phaser.Geom.Triangle[])} [out] - [description] + * + * @return {(array|Phaser.Geom.Triangle[])} [description] + */ +var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) +{ + if (holes === undefined) { holes = null; } + if (scaleX === undefined) { scaleX = 1; } + if (scaleY === undefined) { scaleY = 1; } + if (out === undefined) { out = []; } + + var tris = EarCut(data, holes); + + var a; + var b; + var c; + + var x1; + var y1; + + var x2; + var y2; + + var x3; + var y3; + + for (var i = 0; i < tris.length; i += 3) + { + a = tris[i]; + b = tris[i + 1]; + c = tris[i + 2]; + + x1 = data[a * 2] * scaleX; + y1 = data[(a * 2) + 1] * scaleY; + + x2 = data[b * 2] * scaleX; + y2 = data[(b * 2) + 1] * scaleY; + + x3 = data[c * 2] * scaleX; + y3 = data[(c * 2) + 1] * scaleY; + + out.push(new Triangle(x1, y1, x2, y2, x3, y3)); + } + + return out; +}; + +module.exports = BuildFromPolygon; + + +/***/ }), +/* 629 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Triangle = __webpack_require__(59); + +/** + * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). + * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. + * + * @function Phaser.Geom.Triangle.BuildEquilateral + * @since 3.0.0 + * + * @param {number} x - x coordinate of the top point of the triangle. + * @param {number} y - y coordinate of the top point of the triangle. + * @param {number} length - Length of each side of the triangle. + * + * @return {Phaser.Geom.Triangle} The Triangle object of the given size. + */ +var BuildEquilateral = function (x, y, length) +{ + var height = length * (Math.sqrt(3) / 2); + + var x1 = x; + var y1 = y; + + var x2 = x + (length / 2); + var y2 = y + height; + + var x3 = x - (length / 2); + var y3 = y + height; + + return new Triangle(x1, y1, x2, y2, x3, y3); +}; + +module.exports = BuildEquilateral; + + +/***/ }), +/* 630 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// The 2D area of a triangle. The area value is always non-negative. + +/** + * [description] + * + * @function Phaser.Geom.Triangle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - [description] + * + * @return {number} [description] + */ +var Area = function (triangle) +{ var x1 = triangle.x1; var y1 = triangle.y1; @@ -94952,64 +124341,14 @@ var InCenter = function (triangle, out) var x3 = triangle.x3; var y3 = triangle.y3; - var d1 = getLength(x3, y3, x2, y2); - var d2 = getLength(x1, y1, x3, y3); - var d3 = getLength(x2, y2, x1, y1); - - var p = d1 + d2 + d3; - - out.x = (x1 * d1 + x2 * d2 + x3 * d3) / p; - out.y = (y1 * d1 + y2 * d2 + y3 * d3) / p; - - return out; + return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); }; -module.exports = InCenter; +module.exports = Area; /***/ }), -/* 385 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Offset = function (triangle, x, y) -{ - triangle.x1 += x; - triangle.y1 += y; - - triangle.x2 += x; - triangle.y2 += y; - - triangle.x3 += x; - triangle.y3 += y; - - return triangle; -}; - -module.exports = Offset; - - -/***/ }), -/* 386 */ +/* 631 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -95018,40 +124357,38 @@ module.exports = Offset; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Point = __webpack_require__(5); +var Triangle = __webpack_require__(59); -// The three medians (the lines drawn from the vertices to the bisectors of the opposite sides) -// meet in the centroid or center of mass (center of gravity). -// The centroid divides each median in a ratio of 2:1 +Triangle.Area = __webpack_require__(630); +Triangle.BuildEquilateral = __webpack_require__(629); +Triangle.BuildFromPolygon = __webpack_require__(628); +Triangle.BuildRight = __webpack_require__(627); +Triangle.CenterOn = __webpack_require__(626); +Triangle.Centroid = __webpack_require__(263); +Triangle.CircumCenter = __webpack_require__(625); +Triangle.CircumCircle = __webpack_require__(624); +Triangle.Clone = __webpack_require__(623); +Triangle.Contains = __webpack_require__(69); +Triangle.ContainsArray = __webpack_require__(147); +Triangle.ContainsPoint = __webpack_require__(622); +Triangle.CopyFrom = __webpack_require__(621); +Triangle.Decompose = __webpack_require__(269); +Triangle.Equals = __webpack_require__(620); +Triangle.GetPoint = __webpack_require__(278); +Triangle.GetPoints = __webpack_require__(277); +Triangle.InCenter = __webpack_require__(261); +Triangle.Perimeter = __webpack_require__(619); +Triangle.Offset = __webpack_require__(262); +Triangle.Random = __webpack_require__(184); +Triangle.Rotate = __webpack_require__(618); +Triangle.RotateAroundPoint = __webpack_require__(617); +Triangle.RotateAroundXY = __webpack_require__(144); -/** - * [description] - * - * @function Phaser.Geom.Triangle.Centroid - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var Centroid = function (triangle, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = (triangle.x1 + triangle.x2 + triangle.x3) / 3; - out.y = (triangle.y1 + triangle.y2 + triangle.y3) / 3; - - return out; -}; - -module.exports = Centroid; +module.exports = Triangle; /***/ }), -/* 387 */ +/* 632 */ /***/ (function(module, exports) { /** @@ -95060,54 +124397,12 @@ module.exports = Centroid; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Checks if rectB is fully contained within rectA +// Scales the width and height of this Rectangle by the given amounts. /** * [description] * - * @function Phaser.Geom.Rectangle.ContainsRect - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * - * @return {boolean} [description] - */ -var ContainsRect = function (rectA, rectB) -{ - // Volume check (if rectB volume > rectA then rectA cannot contain it) - if ((rectB.width * rectB.height) > (rectA.width * rectA.height)) - { - return false; - } - - return ( - (rectB.x > rectA.x && rectB.x < rectA.right) && - (rectB.right > rectA.x && rectB.right < rectA.right) && - (rectB.y > rectA.y && rectB.y < rectA.bottom) && - (rectB.bottom > rectA.y && rectB.bottom < rectA.bottom) - ); -}; - -module.exports = ContainsRect; - - -/***/ }), -/* 388 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Centers this Rectangle so that the center coordinates match the given x and y values. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.CenterOn + * @function Phaser.Geom.Rectangle.Scale * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] @@ -95118,19 +124413,50 @@ module.exports = ContainsRect; * * @return {Phaser.Geom.Rectangle} [description] */ -var CenterOn = function (rect, x, y) +var Scale = function (rect, x, y) { - rect.x = x - (rect.width / 2); - rect.y = y - (rect.height / 2); + if (y === undefined) { y = x; } + + rect.width *= x; + rect.height *= y; return rect; }; -module.exports = CenterOn; +module.exports = Scale; /***/ }), -/* 389 */ +/* 633 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. + * + * @function Phaser.Geom.Rectangle.SameDimensions + * @since 3.15.0 + * + * @param {Phaser.Geom.Rectangle} rect - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} toCompare - The second Rectangle object. + * + * @return {boolean} `true` if the objects have equivalent values for the `width` and `height` properties, otherwise `false`. + */ +var SameDimensions = function (rect, toCompare) +{ + return (rect.width === toCompare.width && rect.height === toCompare.height); +}; + +module.exports = SameDimensions; + + +/***/ }), +/* 634 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -95139,233 +124465,1268 @@ module.exports = CenterOn; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(14); - -Rectangle.Area = __webpack_require__(797); -Rectangle.Ceil = __webpack_require__(796); -Rectangle.CeilAll = __webpack_require__(795); -Rectangle.CenterOn = __webpack_require__(388); -Rectangle.Clone = __webpack_require__(794); -Rectangle.Contains = __webpack_require__(31); -Rectangle.ContainsPoint = __webpack_require__(793); -Rectangle.ContainsRect = __webpack_require__(387); -Rectangle.CopyFrom = __webpack_require__(792); -Rectangle.Decompose = __webpack_require__(395); -Rectangle.Equals = __webpack_require__(791); -Rectangle.FitInside = __webpack_require__(790); -Rectangle.FitOutside = __webpack_require__(789); -Rectangle.Floor = __webpack_require__(788); -Rectangle.FloorAll = __webpack_require__(787); -Rectangle.FromPoints = __webpack_require__(274); -Rectangle.GetAspectRatio = __webpack_require__(228); -Rectangle.GetCenter = __webpack_require__(786); -Rectangle.GetPoint = __webpack_require__(135); -Rectangle.GetPoints = __webpack_require__(294); -Rectangle.GetSize = __webpack_require__(785); -Rectangle.Inflate = __webpack_require__(784); -Rectangle.MarchingAnts = __webpack_require__(570); -Rectangle.MergePoints = __webpack_require__(783); -Rectangle.MergeRect = __webpack_require__(782); -Rectangle.MergeXY = __webpack_require__(781); -Rectangle.Offset = __webpack_require__(780); -Rectangle.OffsetPoint = __webpack_require__(779); -Rectangle.Overlaps = __webpack_require__(778); -Rectangle.Perimeter = __webpack_require__(97); -Rectangle.PerimeterPoint = __webpack_require__(777); -Rectangle.Random = __webpack_require__(154); -Rectangle.RandomOutside = __webpack_require__(776); -Rectangle.Scale = __webpack_require__(775); -Rectangle.Union = __webpack_require__(473); - -module.exports = Rectangle; - - -/***/ }), -/* 390 */ -/***/ (function(module, exports, __webpack_require__) { +var Between = __webpack_require__(170); +var ContainsRect = __webpack_require__(264); +var Point = __webpack_require__(6); /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Contains = __webpack_require__(229); - -/** - * @classdesc - * [description] + * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. + * The inner Rectangle must be fully contained within the outer rectangle. * - * @class Polygon - * @memberOf Phaser.Geom - * @constructor - * @since 3.0.0 + * @function Phaser.Geom.Rectangle.RandomOutside + * @since 3.10.0 * - * @param {Phaser.Geom.Point[]} [points] - [description] + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} outer - The outer Rectangle to get the random point within. + * @param {Phaser.Geom.Rectangle} inner - The inner Rectangle to exclude from the returned point. + * @param {Phaser.Geom.Point} [out] - A Point, or Point-like object to store the result in. If not specified, a new Point will be created. + * + * @return {Phaser.Geom.Point} A Point object containing the random values in its `x` and `y` properties. */ -var Polygon = new Class({ +var RandomOutside = function (outer, inner, out) +{ + if (out === undefined) { out = new Point(); } - initialize: - - function Polygon (points) + if (ContainsRect(outer, inner)) { - /** - * The area of this Polygon. - * - * @name Phaser.Geom.Polygon#area - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.area = 0; + // Pick a random quadrant + // + // The quadrants don't extend the full widths / heights of the outer rect to give + // us a better uniformed distribution, otherwise you get clumping in the corners where + // the 4 quads would overlap - /** - * An array of number pair objects that make up this polygon. I.e. [ {x,y}, {x,y}, {x,y} ] - * - * @name Phaser.Geom.Polygon#points - * @type {Phaser.Geom.Point[]} - * @since 3.0.0 - */ - this.points = []; - - if (points) + switch (Between(0, 3)) { - this.setTo(points); + case 0: // Top + out.x = outer.x + (Math.random() * (inner.right - outer.x)); + out.y = outer.y + (Math.random() * (inner.top - outer.y)); + break; + + case 1: // Bottom + out.x = inner.x + (Math.random() * (outer.right - inner.x)); + out.y = inner.bottom + (Math.random() * (outer.bottom - inner.bottom)); + break; + + case 2: // Left + out.x = outer.x + (Math.random() * (inner.x - outer.x)); + out.y = inner.y + (Math.random() * (outer.bottom - inner.y)); + break; + + case 3: // Right + out.x = inner.right + (Math.random() * (outer.right - inner.right)); + out.y = outer.y + (Math.random() * (inner.bottom - outer.y)); + break; } - }, - - /** - * [description] - * - * @method Phaser.Geom.Polygon#contains - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {boolean} [description] - */ - contains: function (x, y) - { - return Contains(this, x, y); - }, - - /** - * Sets this Polygon to the given points. - * - * The points can be set from a variety of formats: - * - * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` - * - An array of objects with public x/y properties: `[obj1, obj2, ...]` - * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` - * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` - * - * `setTo` may also be called without any arguments to remove all points. - * - * @method Phaser.Geom.Polygon#setTo - * @since 3.0.0 - * - * @param {array} points - [description] - * - * @return {Phaser.Geom.Polygon} This Polygon object. - */ - setTo: function (points) - { - this.area = 0; - this.points = []; - - if (!Array.isArray(points)) - { - return this; - } - - var p; - var y0 = Number.MAX_VALUE; - - // The points argument is an array, so iterate through it - for (var i = 0; i < points.length; i++) - { - p = { x: 0, y: 0 }; - - if (typeof points[i] === 'number') - { - p.x = points[i]; - p.y = points[i + 1]; - i++; - } - else if (Array.isArray(points[i])) - { - // An array of arrays? - p.x = points[i][0]; - p.y = points[i][1]; - } - else - { - p.x = points[i].x; - p.y = points[i].y; - } - - this.points.push(p); - - // Lowest boundary - if (p.y < y0) - { - y0 = p.y; - } - } - - this.calculateArea(y0); - - return this; - }, - - /** - * Calculates the area of the Polygon. This is available in the property Polygon.area - * - * @method Phaser.Geom.Polygon#calculateArea - * @since 3.0.0 - * - * @return {number} [description] - */ - calculateArea: function () - { - if (this.points.length < 3) - { - this.area = 0; - - return this.area; - } - - var sum = 0; - var p1; - var p2; - - for (var i = 0; i < this.points.length - 1; i++) - { - p1 = this.points[i]; - p2 = this.points[i + 1]; - - sum += (p2.x - p1.x) * (p1.y + p2.y); - } - - p1 = this.points[0]; - p2 = this.points[this.points.length - 1]; - - sum += (p1.x - p2.x) * (p2.y + p1.y); - - this.area = -sum * 0.5; - - return this.area; } -}); + return out; +}; + +module.exports = RandomOutside; + + +/***/ }), +/* 635 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); +var DegToRad = __webpack_require__(31); + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.PerimeterPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {integer} angle - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var PerimeterPoint = function (rectangle, angle, out) +{ + if (out === undefined) { out = new Point(); } + + angle = DegToRad(angle); + + var s = Math.sin(angle); + var c = Math.cos(angle); + + var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; + var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; + + if (Math.abs(dx * s) < Math.abs(dy * c)) + { + dy = (dx * s) / c; + } + else + { + dx = (dy * c) / s; + } + + out.x = dx + rectangle.centerX; + out.y = dy + rectangle.centerY; + + return out; +}; + +module.exports = PerimeterPoint; + + +/***/ }), +/* 636 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Overlaps + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rectA - [description] + * @param {Phaser.Geom.Rectangle} rectB - [description] + * + * @return {boolean} [description] + */ +var Overlaps = function (rectA, rectB) +{ + return ( + rectA.x < rectB.right && + rectA.right > rectB.x && + rectA.y < rectB.bottom && + rectA.bottom > rectB.y + ); +}; + +module.exports = Overlaps; + + +/***/ }), +/* 637 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector). + * + * @function Phaser.Geom.Rectangle.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2)} point - The point whose coordinates should be used as an offset. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var OffsetPoint = function (rect, point) +{ + rect.x += point.x; + rect.y += point.y; + + return rect; +}; + +module.exports = OffsetPoint; + + +/***/ }), +/* 638 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Nudges (translates) the top left corner of a Rectangle by a given offset. + * + * @function Phaser.Geom.Rectangle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {number} x - The distance to move the Rectangle horizontally. + * @param {number} y - The distance to move the Rectangle vertically. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var Offset = function (rect, x, y) +{ + rect.x += x; + rect.y += y; + + return rect; +}; + +module.exports = Offset; + + +/***/ }), +/* 639 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. + * + * @function Phaser.Geom.Rectangle.MergeXY + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged and modified. + * @param {number} x - The X coordinate of the point which should be merged. + * @param {number} y - The Y coordinate of the point which should be merged. + * + * @return {Phaser.Geom.Rectangle} The modified `target` Rectangle. + */ +var MergeXY = function (target, x, y) +{ + var minX = Math.min(target.x, x); + var maxX = Math.max(target.right, x); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, y); + var maxY = Math.max(target.bottom, y); + + target.y = minY; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergeXY; + + +/***/ }), +/* 640 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Merges source rectangle into target rectangle and returns target +// Neither rect should have negative widths or heights + +/** + * Merges the source rectangle into the target rectangle and returns the target. + * Neither rectangle should have a negative width or height. + * + * @function Phaser.Geom.Rectangle.MergeRect + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - Target rectangle. Will be modified to include source rectangle. + * @param {Phaser.Geom.Rectangle} source - Rectangle that will be merged into target rectangle. + * + * @return {Phaser.Geom.Rectangle} Modified target rectangle that contains source rectangle. + */ +var MergeRect = function (target, source) +{ + var minX = Math.min(target.x, source.x); + var maxX = Math.max(target.right, source.right); + + target.x = minX; + target.width = maxX - minX; + + var minY = Math.min(target.y, source.y); + var maxY = Math.max(target.bottom, source.bottom); + + target.y = minY; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergeRect; + + +/***/ }), +/* 641 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. + * + * @function Phaser.Geom.Rectangle.MergePoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged. + * @param {Phaser.Geom.Point[]} points - An array of Points (or any object with public `x` and `y` properties) which should be merged with the Rectangle. + * + * @return {Phaser.Geom.Rectangle} The modified Rectangle. + */ +var MergePoints = function (target, points) +{ + var minX = target.x; + var maxX = target.right; + var minY = target.y; + var maxY = target.bottom; + + for (var i = 0; i < points.length; i++) + { + minX = Math.min(minX, points[i].x); + maxX = Math.max(maxX, points[i].x); + minY = Math.min(minY, points[i].y); + maxY = Math.max(maxY, points[i].y); + } + + target.x = minX; + target.y = minY; + target.width = maxX - minX; + target.height = maxY - minY; + + return target; +}; + +module.exports = MergePoints; + + +/***/ }), +/* 642 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); +var Intersects = __webpack_require__(148); + +/** + * Takes two Rectangles and first checks to see if they intersect. + * If they intersect it will return the area of intersection in the `out` Rectangle. + * If they do not intersect, the `out` Rectangle will have a width and height of zero. + * + * @function Phaser.Geom.Rectangle.Intersection + * @since 3.11.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle to store the intersection results in. + * + * @return {Phaser.Geom.Rectangle} The intersection result. If the width and height are zero, no intersection occurred. + */ +var Intersection = function (rectA, rectB, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (Intersects(rectA, rectB)) + { + out.x = Math.max(rectA.x, rectB.x); + out.y = Math.max(rectA.y, rectB.y); + out.width = Math.min(rectA.right, rectB.right) - out.x; + out.height = Math.min(rectA.bottom, rectB.bottom) - out.y; + } + else + { + out.setEmpty(); + } + + return out; +}; + +module.exports = Intersection; + + +/***/ }), +/* 643 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CenterOn = __webpack_require__(175); + +// Increases the size of the Rectangle object by the specified amounts. +// The center point of the Rectangle object stays the same, and its size increases +// to the left and right by the x value, and to the top and the bottom by the y value. + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Inflate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var Inflate = function (rect, x, y) +{ + var cx = rect.centerX; + var cy = rect.centerY; + + rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); + + return CenterOn(rect, cx, cy); +}; + +module.exports = Inflate; + + +/***/ }), +/* 644 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +// The size of the Rectangle object, expressed as a Point object +// with the values of the width and height properties. + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.GetSize + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var GetSize = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.width; + out.y = rect.height; + + return out; +}; + +module.exports = GetSize; + + +/***/ }), +/* 645 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Returns the center of a Rectangle as a Point. + * + * @function Phaser.Geom.Rectangle.GetCenter + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the center of. + * @param {(Phaser.Geom.Point|object)} [out] - Optional point-like object to update with the center coordinates. + * + * @return {(Phaser.Geom.Point|object)} The modified `out` object, or a new Point if none was provided. + */ +var GetCenter = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.centerX; + out.y = rect.centerY; + + return out; +}; + +module.exports = GetCenter; + + +/***/ }), +/* 646 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. + * + * @function Phaser.Geom.Rectangle.FloorAll + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var FloorAll = function (rect) +{ + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + rect.width = Math.floor(rect.width); + rect.height = Math.floor(rect.height); + + return rect; +}; + +module.exports = FloorAll; + + +/***/ }), +/* 647 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Floor + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var Floor = function (rect) +{ + rect.x = Math.floor(rect.x); + rect.y = Math.floor(rect.y); + + return rect; +}; + +module.exports = Floor; + + +/***/ }), +/* 648 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAspectRatio = __webpack_require__(145); + +// Fits the target rectangle around the source rectangle. +// Preserves aspect ration. +// Scales and centers the target rectangle to the source rectangle + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.FitOutside + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var FitOutside = function (target, source) +{ + var ratio = GetAspectRatio(target); + + if (ratio > GetAspectRatio(source)) + { + // Wider than Tall + target.setSize(source.height * ratio, source.height); + } + else + { + // Taller than Wide + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - target.width / 2, + source.centerY - target.height / 2 + ); +}; + +module.exports = FitOutside; + + +/***/ }), +/* 649 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAspectRatio = __webpack_require__(145); + +// Fits the target rectangle into the source rectangle. +// Preserves aspect ratio. +// Scales and centers the target rectangle to the source rectangle + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.FitInside + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [target,$return] + * + * @param {Phaser.Geom.Rectangle} target - [description] + * @param {Phaser.Geom.Rectangle} source - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var FitInside = function (target, source) +{ + var ratio = GetAspectRatio(target); + + if (ratio < GetAspectRatio(source)) + { + // Taller than Wide + target.setSize(source.height * ratio, source.height); + } + else + { + // Wider than Tall + target.setSize(source.width, source.width / ratio); + } + + return target.setPosition( + source.centerX - (target.width / 2), + source.centerY - (target.height / 2) + ); +}; + +module.exports = FitInside; + + +/***/ }), +/* 650 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} toCompare - [description] + * + * @return {boolean} [description] + */ +var Equals = function (rect, toCompare) +{ + return ( + rect.x === toCompare.x && + rect.y === toCompare.y && + rect.width === toCompare.width && + rect.height === toCompare.height + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 651 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one Rectangle to a destination Rectangle. + * + * @function Phaser.Geom.Rectangle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [dest,$return] + * + * @param {Phaser.Geom.Rectangle} source - The source Rectangle to copy the values from. + * @param {Phaser.Geom.Rectangle} dest - The destination Rectangle to copy the values to. + * + * @return {Phaser.Geom.Rectangle} The destination Rectangle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 652 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(39); + +/** + * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. + * + * @function Phaser.Geom.Rectangle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object. + * @param {Phaser.Geom.Point} point - The point object to be checked. Can be a Phaser Point object or any object with x and y values. + * + * @return {boolean} A value of true if the Rectangle object contains the specified point, otherwise false. + */ +var ContainsPoint = function (rect, point) +{ + return Contains(rect, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 653 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Creates a new Rectangle which is identical to the given one. + * + * @function Phaser.Geom.Rectangle.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} source - The Rectangle to clone. + * + * @return {Phaser.Geom.Rectangle} The newly created Rectangle, which is separate from the given one. + */ +var Clone = function (source) +{ + return new Rectangle(source.x, source.y, source.width, source.height); +}; + +module.exports = Clone; + + +/***/ }), +/* 654 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.CeilAll + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var CeilAll = function (rect) +{ + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + rect.width = Math.ceil(rect.width); + rect.height = Math.ceil(rect.height); + + return rect; +}; + +module.exports = CeilAll; + + +/***/ }), +/* 655 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. + * + * @function Phaser.Geom.Rectangle.Ceil + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. + */ +var Ceil = function (rect) +{ + rect.x = Math.ceil(rect.x); + rect.y = Math.ceil(rect.y); + + return rect; +}; + +module.exports = Ceil; + + +/***/ }), +/* 656 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var Area = function (rect) +{ + return rect.width * rect.height; +}; + +module.exports = Area; + + +/***/ }), +/* 657 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Polygon.Reverse + * @since 3.0.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * + * @return {Phaser.Geom.Polygon} [description] + */ +var Reverse = function (polygon) +{ + polygon.points.reverse(); + + return polygon; +}; + +module.exports = Reverse; + + +/***/ }), +/* 658 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] + +/** + * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], + * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant + * array for the point's X and Y coordinate. + * + * @function Phaser.Geom.Polygon.GetNumberArray + * @since 3.0.0 + * + * @generic {number[]} O - [output,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon whose points to export. + * @param {(array|number[])} [output] - An array to which the points' coordinates should be appended. + * + * @return {(array|number[])} The modified `output` array, or a new array if none was given. + */ +var GetNumberArray = function (polygon, output) +{ + if (output === undefined) { output = []; } + + for (var i = 0; i < polygon.points.length; i++) + { + output.push(polygon.points[i].x); + output.push(polygon.points[i].y); + } + + return output; +}; + +module.exports = GetNumberArray; + + +/***/ }), +/* 659 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(150); + +/** + * [description] + * + * @function Phaser.Geom.Polygon.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {Phaser.Geom.Point} point - [description] + * + * @return {boolean} [description] + */ +var ContainsPoint = function (polygon, point) +{ + return Contains(polygon, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 660 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Polygon = __webpack_require__(151); + +/** + * [description] + * + * @function Phaser.Geom.Polygon.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Polygon} polygon - [description] + * + * @return {Phaser.Geom.Polygon} [description] + */ +var Clone = function (polygon) +{ + return new Polygon(polygon.points); +}; + +module.exports = Clone; + + +/***/ }), +/* 661 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Polygon = __webpack_require__(151); + +Polygon.Clone = __webpack_require__(660); +Polygon.Contains = __webpack_require__(150); +Polygon.ContainsPoint = __webpack_require__(659); +Polygon.GetAABB = __webpack_require__(285); +Polygon.GetNumberArray = __webpack_require__(658); +Polygon.GetPoints = __webpack_require__(284); +Polygon.Perimeter = __webpack_require__(283); +Polygon.Reverse = __webpack_require__(657); +Polygon.Smooth = __webpack_require__(282); module.exports = Polygon; /***/ }), -/* 391 */ +/* 662 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetMagnitude = __webpack_require__(267); + +/** + * [description] + * + * @function Phaser.Geom.Point.SetMagnitude + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} point - [description] + * @param {number} magnitude - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var SetMagnitude = function (point, magnitude) +{ + if (point.x !== 0 || point.y !== 0) + { + var m = GetMagnitude(point); + + point.x /= m; + point.y /= m; + } + + point.x *= magnitude; + point.y *= magnitude; + + return point; +}; + +module.exports = SetMagnitude; + + +/***/ }), +/* 663 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Point.ProjectUnit + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var ProjectUnit = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var amt = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = ProjectUnit; + + +/***/ }), +/* 664 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); +var GetMagnitudeSq = __webpack_require__(266); + +/** + * [description] + * + * @function Phaser.Geom.Point.Project + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Project = function (pointA, pointB, out) +{ + if (out === undefined) { out = new Point(); } + + var dot = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); + var amt = dot / GetMagnitudeSq(pointB); + + if (amt !== 0) + { + out.x = amt * pointB.x; + out.y = amt * pointB.y; + } + + return out; +}; + +module.exports = Project; + + +/***/ }), +/* 665 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Point.Negative + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Negative = function (point, out) +{ + if (out === undefined) { out = new Point(); } + + return out.setTo(-point.x, -point.y); +}; + +module.exports = Negative; + + +/***/ }), +/* 666 */ /***/ (function(module, exports) { /** @@ -95375,25 +125736,201 @@ module.exports = Polygon; */ /** - * [description] + * Swaps the X and the Y coordinate of a point. * - * @function Phaser.Geom.Point.GetMagnitudeSq + * @function Phaser.Geom.Point.Invert * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] + * @generic {Phaser.Geom.Point} O - [point,$return] * - * @return {number} [description] + * @param {Phaser.Geom.Point} point - The Point to modify. + * + * @return {Phaser.Geom.Point} The modified `point`. */ -var GetMagnitudeSq = function (point) +var Invert = function (point) { - return (point.x * point.x) + (point.y * point.y); + return point.setTo(point.y, point.x); }; -module.exports = GetMagnitudeSq; +module.exports = Invert; /***/ }), -/* 392 */ +/* 667 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Interpolate two given Point objects, based on `t` value. Return result either as new Point if `out` parameter is omitted or load result into Point passed as `out` parameter and return it. For `out` parameter you can also use any object with public x/y properties. + * + * @function Phaser.Geom.Point.Interpolate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point} pointA - [description] + * @param {Phaser.Geom.Point} pointB - [description] + * @param {number} [t=0] - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ +var Interpolate = function (pointA, pointB, t, out) +{ + if (t === undefined) { t = 0; } + if (out === undefined) { out = new Point(); } + + out.x = pointA.x + ((pointB.x - pointA.x) * t); + out.y = pointA.y + ((pointB.y - pointA.y) * t); + + return out; +}; + +module.exports = Interpolate; + + +/***/ }), +/* 668 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. + * + * @function Phaser.Geom.Point.GetRectangleFromPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Rectangle} [out] - [description] + * + * @return {Phaser.Geom.Rectangle} [description] + */ +var GetRectangleFromPoints = function (points, out) +{ + if (out === undefined) { out = new Rectangle(); } + + var xMax = Number.NEGATIVE_INFINITY; + var xMin = Number.POSITIVE_INFINITY; + var yMax = Number.NEGATIVE_INFINITY; + var yMin = Number.POSITIVE_INFINITY; + + for (var i = 0; i < points.length; i++) + { + var point = points[i]; + + if (point.x > xMax) + { + xMax = point.x; + } + + if (point.x < xMin) + { + xMin = point.x; + } + + if (point.y > yMax) + { + yMax = point.y; + } + + if (point.y < yMin) + { + yMin = point.y; + } + } + + out.x = xMin; + out.y = yMin; + out.width = xMax - xMin; + out.height = yMax - yMin; + + return out; +}; + +module.exports = GetRectangleFromPoints; + + +/***/ }), +/* 669 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * [description] + * + * @function Phaser.Geom.Point.GetCentroid + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Point} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var GetCentroid = function (points, out) +{ + if (out === undefined) { out = new Point(); } + + if (!Array.isArray(points)) + { + throw new Error('GetCentroid points argument must be an array'); + } + + var len = points.length; + + if (len < 1) + { + throw new Error('GetCentroid points array must not be empty'); + } + else if (len === 1) + { + out.x = points[0].x; + out.y = points[0].y; + } + else + { + for (var i = 0; i < len; i++) + { + out.x += points[i].x; + out.y += points[i].y; + } + + out.x /= len; + out.y /= len; + } + + return out; +}; + +module.exports = GetCentroid; + + +/***/ }), +/* 670 */ /***/ (function(module, exports) { /** @@ -95403,25 +125940,444 @@ module.exports = GetMagnitudeSq; */ /** - * [description] + * Apply `Math.ceil()` to each coordinate of the given Point. * - * @function Phaser.Geom.Point.GetMagnitude + * @function Phaser.Geom.Point.Floor * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] + * @generic {Phaser.Geom.Point} O - [point,$return] * - * @return {number} [description] + * @param {Phaser.Geom.Point} point - The Point to floor. + * + * @return {Phaser.Geom.Point} The Point with `Math.floor()` applied to its coordinates. */ -var GetMagnitude = function (point) +var Floor = function (point) { - return Math.sqrt((point.x * point.x) + (point.y * point.y)); + return point.setTo(Math.floor(point.x), Math.floor(point.y)); }; -module.exports = GetMagnitude; +module.exports = Floor; /***/ }), -/* 393 */ +/* 671 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A comparison of two `Point` objects to see if they are equal. + * + * @function Phaser.Geom.Point.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} point - The original `Point` to compare against. + * @param {Phaser.Geom.Point} toCompare - The second `Point` to compare. + * + * @return {boolean} Returns true if the both `Point` objects are equal. + */ +var Equals = function (point, toCompare) +{ + return (point.x === toCompare.x && point.y === toCompare.y); +}; + +module.exports = Equals; + + +/***/ }), +/* 672 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one Point to a destination Point. + * + * @function Phaser.Geom.Point.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [dest,$return] + * + * @param {Phaser.Geom.Point} source - The source Point to copy the values from. + * @param {Phaser.Geom.Point} dest - The destination Point to copy the values to. + * + * @return {Phaser.Geom.Point} The destination Point. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 673 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Clone the given Point. + * + * @function Phaser.Geom.Point.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Point} source - The source Point to clone. + * + * @return {Phaser.Geom.Point} The cloned Point. + */ +var Clone = function (source) +{ + return new Point(source.x, source.y); +}; + +module.exports = Clone; + + +/***/ }), +/* 674 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Apply `Math.ceil()` to each coordinate of the given Point. + * + * @function Phaser.Geom.Point.Ceil + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} point - The Point to ceil. + * + * @return {Phaser.Geom.Point} The Point with `Math.ceil()` applied to its coordinates. + */ +var Ceil = function (point) +{ + return point.setTo(Math.ceil(point.x), Math.ceil(point.y)); +}; + +module.exports = Ceil; + + +/***/ }), +/* 675 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +Point.Ceil = __webpack_require__(674); +Point.Clone = __webpack_require__(673); +Point.CopyFrom = __webpack_require__(672); +Point.Equals = __webpack_require__(671); +Point.Floor = __webpack_require__(670); +Point.GetCentroid = __webpack_require__(669); +Point.GetMagnitude = __webpack_require__(267); +Point.GetMagnitudeSq = __webpack_require__(266); +Point.GetRectangleFromPoints = __webpack_require__(668); +Point.Interpolate = __webpack_require__(667); +Point.Invert = __webpack_require__(666); +Point.Negative = __webpack_require__(665); +Point.Project = __webpack_require__(664); +Point.ProjectUnit = __webpack_require__(663); +Point.SetMagnitude = __webpack_require__(662); + +module.exports = Point; + + +/***/ }), +/* 676 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the width of the given line. + * + * @function Phaser.Geom.Line.Width + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the width of. + * + * @return {number} The width of the line. + */ +var Width = function (line) +{ + return Math.abs(line.x1 - line.x2); +}; + +module.exports = Width; + + +/***/ }), +/* 677 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the slope of the given line. + * + * @function Phaser.Geom.Line.Slope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the slope of. + * + * @return {number} The slope of the line. + */ +var Slope = function (line) +{ + return (line.y2 - line.y1) / (line.x2 - line.x1); +}; + +module.exports = Slope; + + +/***/ }), +/* 678 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Set a line to a given position, angle and length. + * + * @function Phaser.Geom.Line.SetToAngle + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to set. + * @param {number} x - The horizontal start position of the line. + * @param {number} y - The vertical start position of the line. + * @param {number} angle - The angle of the line in radians. + * @param {number} length - The length of the line. + * + * @return {Phaser.Geom.Line} The updated line. + */ +var SetToAngle = function (line, x, y, angle, length) +{ + line.x1 = x; + line.y1 = y; + + line.x2 = x + (Math.cos(angle) * length); + line.y2 = y + (Math.sin(angle) * length); + + return line; +}; + +module.exports = SetToAngle; + + +/***/ }), +/* 679 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(146); + +/** + * Rotate a line around a point by the given angle in radians. + * + * @function Phaser.Geom.Line.RotateAroundPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {(Phaser.Geom.Point|object)} point - The point to rotate the line around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var RotateAroundPoint = function (line, point, angle) +{ + return RotateAroundXY(line, point.x, point.y, angle); +}; + +module.exports = RotateAroundPoint; + + +/***/ }), +/* 680 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RotateAroundXY = __webpack_require__(146); + +/** + * Rotate a line around its midpoint by the given angle in radians. + * + * @function Phaser.Geom.Line.Rotate + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to rotate. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Line} The rotated line. + */ +var Rotate = function (line, angle) +{ + var x = (line.x1 + line.x2) / 2; + var y = (line.y1 + line.y2) / 2; + + return RotateAroundXY(line, x, y, angle); +}; + +module.exports = Rotate; + + +/***/ }), +/* 681 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Angle = __webpack_require__(68); +var NormalAngle = __webpack_require__(268); + +/** + * Calculate the reflected angle between two lines. + * + * This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. + * + * @function Phaser.Geom.Line.ReflectAngle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} lineA - The first line. + * @param {Phaser.Geom.Line} lineB - The second line. + * + * @return {number} The reflected angle between each line. + */ +var ReflectAngle = function (lineA, lineB) +{ + return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); +}; + +module.exports = ReflectAngle; + + +/***/ }), +/* 682 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the perpendicular slope of the given line. + * + * @function Phaser.Geom.Line.PerpSlope + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the perpendicular slope of. + * + * @return {number} The perpendicular slope of the line. + */ +var PerpSlope = function (line) +{ + return -((line.x2 - line.x1) / (line.y2 - line.y1)); +}; + +module.exports = PerpSlope; + + +/***/ }), +/* 683 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offset a line by the given amount. + * + * @function Phaser.Geom.Line.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} line - The line to offset. + * @param {number} x - The horizontal offset to add to the line. + * @param {number} y - The vertical offset to add to the line. + * + * @return {Phaser.Geom.Line} The offset line. + */ +var Offset = function (line, x, y) +{ + line.x1 += x; + line.y1 += y; + + line.x2 += x; + line.y2 += y; + + return line; +}; + +module.exports = Offset; + + +/***/ }), +/* 684 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -95431,31 +126387,59 @@ module.exports = GetMagnitude; */ var MATH_CONST = __webpack_require__(16); -var Wrap = __webpack_require__(39); -var Angle = __webpack_require__(82); +var Angle = __webpack_require__(68); /** * [description] * - * @function Phaser.Geom.Line.NormalAngle + * @function Phaser.Geom.Line.NormalY * @since 3.0.0 * * @param {Phaser.Geom.Line} line - [description] * * @return {number} [description] */ -var NormalAngle = function (line) +var NormalY = function (line) { - var angle = Angle(line) - MATH_CONST.TAU; - - return Wrap(angle, -Math.PI, Math.PI); + return Math.sin(Angle(line) - MATH_CONST.TAU); }; -module.exports = NormalAngle; +module.exports = NormalY; /***/ }), -/* 394 */ +/* 685 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(68); + +/** + * [description] + * + * @function Phaser.Geom.Line.NormalX + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The Line object to get the normal value from. + * + * @return {number} [description] + */ +var NormalX = function (line) +{ + return Math.cos(Angle(line) - MATH_CONST.TAU); +}; + +module.exports = NormalX; + + +/***/ }), +/* 686 */ /***/ (function(module, exports) { /** @@ -95464,33 +126448,491 @@ module.exports = NormalAngle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** + * Calculate the height of the given line. + * + * @function Phaser.Geom.Line.Height + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the height of. + * + * @return {number} The height of the line. + */ +var Height = function (line) +{ + return Math.abs(line.y1 - line.y2); +}; + +module.exports = Height; + + +/***/ }), +/* 687 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(16); +var Angle = __webpack_require__(68); +var Point = __webpack_require__(6); + +/** + * Calculate the normal of the given line. + * + * The normal of a line is a vector that points perpendicular from it. + * + * @function Phaser.Geom.Line.GetNormal + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to calculate the normal of. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point object to store the normal in. + * + * @return {(Phaser.Geom.Point|object)} The normal of the Line. + */ +var GetNormal = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + var a = Angle(line) - MATH_CONST.TAU; + + out.x = Math.cos(a); + out.y = Math.sin(a); + + return out; +}; + +module.exports = GetNormal; + + +/***/ }), +/* 688 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(6); + +/** + * Get the midpoint of the given line. + * + * @function Phaser.Geom.Line.GetMidPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to get the midpoint of. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point object to store the midpoint in. + * + * @return {(Phaser.Geom.Point|object)} The midpoint of the Line. + */ +var GetMidPoint = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = (line.x1 + line.x2) / 2; + out.y = (line.y1 + line.y2) / 2; + + return out; +}; + +module.exports = GetMidPoint; + + +/***/ }), +/* 689 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compare two lines for strict equality. + * + * @function Phaser.Geom.Line.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The first line to compare. + * @param {Phaser.Geom.Line} toCompare - The second line to compare. + * + * @return {boolean} Whether the two lines are equal. + */ +var Equals = function (line, toCompare) +{ + return ( + line.x1 === toCompare.x1 && + line.y1 === toCompare.y1 && + line.x2 === toCompare.x2 && + line.y2 === toCompare.y2 + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 690 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copy the values of one line to a destination line. + * + * @function Phaser.Geom.Line.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [dest,$return] + * + * @param {Phaser.Geom.Line} source - The source line to copy the values from. + * @param {Phaser.Geom.Line} dest - The destination line to copy the values to. + * + * @return {Phaser.Geom.Line} The destination line. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 691 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(54); + +/** + * Clone the given line. + * + * @function Phaser.Geom.Line.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} source - The source line to clone. + * + * @return {Phaser.Geom.Line} The cloned line. + */ +var Clone = function (source) +{ + return new Line(source.x1, source.y1, source.x2, source.y2); +}; + +module.exports = Clone; + + +/***/ }), +/* 692 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + + +/** + * Center a line on the given coordinates. + * + * @function Phaser.Geom.Line.CenterOn + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to center. + * @param {number} x - The horizontal coordinate to center the line on. + * @param {number} y - The vertical coordinate to center the line on. + * + * @return {Phaser.Geom.Line} The centered line. + */ +var CenterOn = function (line, x, y) +{ + var tx = x - ((line.x1 + line.x2) / 2); + var ty = y - ((line.y1 + line.y2) / 2); + + line.x1 += tx; + line.y1 += ty; + + line.x2 += tx; + line.y2 += ty; + + return line; +}; + +module.exports = CenterOn; + + +/***/ }), +/* 693 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Line = __webpack_require__(54); + +Line.Angle = __webpack_require__(68); +Line.BresenhamPoints = __webpack_require__(385); +Line.CenterOn = __webpack_require__(692); +Line.Clone = __webpack_require__(691); +Line.CopyFrom = __webpack_require__(690); +Line.Equals = __webpack_require__(689); +Line.GetMidPoint = __webpack_require__(688); +Line.GetNormal = __webpack_require__(687); +Line.GetPoint = __webpack_require__(397); +Line.GetPoints = __webpack_require__(189); +Line.Height = __webpack_require__(686); +Line.Length = __webpack_require__(65); +Line.NormalAngle = __webpack_require__(268); +Line.NormalX = __webpack_require__(685); +Line.NormalY = __webpack_require__(684); +Line.Offset = __webpack_require__(683); +Line.PerpSlope = __webpack_require__(682); +Line.Random = __webpack_require__(188); +Line.ReflectAngle = __webpack_require__(681); +Line.Rotate = __webpack_require__(680); +Line.RotateAroundPoint = __webpack_require__(679); +Line.RotateAroundXY = __webpack_require__(146); +Line.SetToAngle = __webpack_require__(678); +Line.Slope = __webpack_require__(677); +Line.Width = __webpack_require__(676); + +module.exports = Line; + + +/***/ }), +/* 694 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ContainsArray = __webpack_require__(147); +var Decompose = __webpack_require__(269); +var LineToLine = __webpack_require__(107); + /** * [description] * - * @function Phaser.Geom.Triangle.Decompose + * @function Phaser.Geom.Intersects.TriangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangleA - [description] + * @param {Phaser.Geom.Triangle} triangleB - [description] + * + * @return {boolean} [description] + */ +var TriangleToTriangle = function (triangleA, triangleB) +{ + // First the cheapest ones: + + if ( + triangleA.left > triangleB.right || + triangleA.right < triangleB.left || + triangleA.top > triangleB.bottom || + triangleA.bottom < triangleB.top) + { + return false; + } + + var lineAA = triangleA.getLineA(); + var lineAB = triangleA.getLineB(); + var lineAC = triangleA.getLineC(); + + var lineBA = triangleB.getLineA(); + var lineBB = triangleB.getLineB(); + var lineBC = triangleB.getLineC(); + + // Now check the lines against each line of TriangleB + if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) + { + return true; + } + + if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) + { + return true; + } + + if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) + { + return true; + } + + // Nope, so check to see if any of the points of triangleA are within triangleB + + var points = Decompose(triangleA); + var within = ContainsArray(triangleB, points, true); + + if (within.length > 0) + { + return true; + } + + // Finally check to see if any of the points of triangleB are within triangleA + + points = Decompose(triangleB); + within = ContainsArray(triangleA, points, true); + + if (within.length > 0) + { + return true; + } + + return false; +}; + +module.exports = TriangleToTriangle; + + +/***/ }), +/* 695 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(69); +var LineToLine = __webpack_require__(107); + +/** + * Checks if a Triangle and a Line intersect. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". + * + * @function Phaser.Geom.Intersects.TriangleToLine + * @since 3.0.0 + * + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check with. + * @param {Phaser.Geom.Line} line - The Line to check with. + * + * @return {boolean} `true` if the Triangle and the Line intersect, otherwise `false`. + */ +var TriangleToLine = function (triangle, line) +{ + // If the Triangle contains either the start or end point of the line, it intersects + if (Contains(triangle, line.getPointA()) || Contains(triangle, line.getPointB())) + { + return true; + } + + // Now check the line against each line of the Triangle + if (LineToLine(triangle.getLineA(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineB(), line)) + { + return true; + } + + if (LineToLine(triangle.getLineC(), line)) + { + return true; + } + + return false; +}; + +module.exports = TriangleToLine; + + +/***/ }), +/* 696 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineToCircle = __webpack_require__(272); +var Contains = __webpack_require__(69); + +/** + * [description] + * + * @function Phaser.Geom.Intersects.TriangleToCircle * @since 3.0.0 * * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {array} [out] - [description] + * @param {Phaser.Geom.Circle} circle - [description] * - * @return {array} [description] + * @return {boolean} [description] */ -var Decompose = function (triangle, out) +var TriangleToCircle = function (triangle, circle) { - if (out === undefined) { out = []; } + // First the cheapest ones: - out.push({ x: triangle.x1, y: triangle.y1 }); - out.push({ x: triangle.x2, y: triangle.y2 }); - out.push({ x: triangle.x3, y: triangle.y3 }); + if ( + triangle.left > circle.right || + triangle.right < circle.left || + triangle.top > circle.bottom || + triangle.bottom < circle.top) + { + return false; + } - return out; + if (Contains(triangle, circle.x, circle.y)) + { + return true; + } + + if (LineToCircle(triangle.getLineA(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineB(), circle)) + { + return true; + } + + if (LineToCircle(triangle.getLineC(), circle)) + { + return true; + } + + return false; }; -module.exports = Decompose; +module.exports = TriangleToCircle; /***/ }), -/* 395 */ +/* 697 */ /***/ (function(module, exports) { /** @@ -95502,32 +126944,36 @@ module.exports = Decompose; /** * [description] * - * @function Phaser.Geom.Rectangle.Decompose + * @function Phaser.Geom.Intersects.RectangleToValues * @since 3.0.0 * * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {array} [out] - [description] + * @param {number} left - [description] + * @param {number} right - [description] + * @param {number} top - [description] + * @param {number} bottom - [description] + * @param {number} [tolerance=0] - [description] * - * @return {array} [description] + * @return {boolean} [description] */ -var Decompose = function (rect, out) +var RectangleToValues = function (rect, left, right, top, bottom, tolerance) { - if (out === undefined) { out = []; } + if (tolerance === undefined) { tolerance = 0; } - out.push({ x: rect.x, y: rect.y }); - out.push({ x: rect.right, y: rect.y }); - out.push({ x: rect.right, y: rect.bottom }); - out.push({ x: rect.x, y: rect.bottom }); - - return out; + return !( + left > rect.right + tolerance || + right < rect.left - tolerance || + top > rect.bottom + tolerance || + bottom < rect.top - tolerance + ); }; -module.exports = Decompose; +module.exports = RectangleToValues; /***/ }), -/* 396 */ -/***/ (function(module, exports) { +/* 698 */ +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -95535,10 +126981,105 @@ module.exports = Decompose; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var LineToLine = __webpack_require__(107); +var Contains = __webpack_require__(39); +var ContainsArray = __webpack_require__(147); +var Decompose = __webpack_require__(270); + +/** + * Checks for intersection between Rectangle shape and Triangle shape. + * + * @function Phaser.Geom.Intersects.RectangleToTriangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - Rectangle object to test. + * @param {Phaser.Geom.Triangle} triangle - Triangle object to test. + * + * @return {boolean} A value of `true` if objects intersect; otherwise `false`. + */ +var RectangleToTriangle = function (rect, triangle) +{ + // First the cheapest ones: + + if ( + triangle.left > rect.right || + triangle.right < rect.left || + triangle.top > rect.bottom || + triangle.bottom < rect.top) + { + return false; + } + + var triA = triangle.getLineA(); + var triB = triangle.getLineB(); + var triC = triangle.getLineC(); + + // Are any of the triangle points within the rectangle? + + if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) + { + return true; + } + + if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) + { + return true; + } + + if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) + { + return true; + } + + // Cheap tests over, now to see if any of the lines intersect ... + + var rectA = rect.getLineA(); + var rectB = rect.getLineB(); + var rectC = rect.getLineC(); + var rectD = rect.getLineD(); + + if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) + { + return true; + } + + if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) + { + return true; + } + + if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) + { + return true; + } + + // None of the lines intersect, so are any rectangle points within the triangle? + + var points = Decompose(rect); + var within = ContainsArray(triangle, points, true); + + return (within.length > 0); +}; + +module.exports = RectangleToTriangle; + + +/***/ }), +/* 699 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PointToLine = __webpack_require__(271); + /** * [description] * - * @function Phaser.Geom.Intersects.PointToLine + * @function Phaser.Geom.Intersects.PointToLineSegment * @since 3.0.0 * * @param {Phaser.Geom.Point} point - [description] @@ -95546,16 +127087,127 @@ module.exports = Decompose; * * @return {boolean} [description] */ -var PointToLine = function (point, line) +var PointToLineSegment = function (point, line) { - return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); + if (!PointToLine(point, line)) + { + return false; + } + + var xMin = Math.min(line.x1, line.x2); + var xMax = Math.max(line.x1, line.x2); + var yMin = Math.min(line.y1, line.y2); + var yMax = Math.max(line.y1, line.y2); + + return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); }; -module.exports = PointToLine; +module.exports = PointToLineSegment; /***/ }), -/* 397 */ +/* 700 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like + * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. + * + * An intersection is considered valid if: + * + * The line starts within, or ends within, the Rectangle. + * The line segment intersects one of the 4 rectangle edges. + * + * The for the purposes of this function rectangles are considered 'solid'. + * + * @function Phaser.Geom.Intersects.LineToRectangle + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Rectangle|object)} rect - [description] + * + * @return {boolean} [description] + */ +var LineToRectangle = function (line, rect) +{ + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var bx1 = rect.x; + var by1 = rect.y; + var bx2 = rect.right; + var by2 = rect.bottom; + + var t = 0; + + // If the start or end of the line is inside the rect then we assume + // collision, as rects are solid for our use-case. + + if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || + (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) + { + return true; + } + + if (x1 < bx1 && x2 >= bx1) + { + // Left edge + t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); + + if (t > by1 && t <= by2) + { + return true; + } + } + else if (x1 > bx2 && x2 <= bx2) + { + // Right edge + t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); + + if (t >= by1 && t <= by2) + { + return true; + } + } + + if (y1 < by1 && y2 >= by1) + { + // Top edge + t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + else if (y1 > by2 && y2 <= by2) + { + // Bottom edge + t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); + + if (t >= bx1 && t <= bx2) + { + return true; + } + } + + return false; +}; + +module.exports = LineToRectangle; + + +/***/ }), +/* 701 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -95564,83 +127216,47 @@ module.exports = PointToLine; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Based on code by Matt DesLauriers -// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md - -var Contains = __webpack_require__(32); -var Point = __webpack_require__(5); - -var tmp = new Point(); +var Rectangle = __webpack_require__(9); +var RectangleToRectangle = __webpack_require__(148); /** - * [description] + * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. + * + * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it wil be empty Rectangle (all values set to zero). + * + * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersetion, it will be returned without any change. * - * @function Phaser.Geom.Intersects.LineToCircle + * @function Phaser.Geom.Intersects.GetRectangleIntersection * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Point} [nearest] - [description] + * @generic {Phaser.Geom.Rectangle} O - [output,$return] * - * @return {boolean} [description] + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle object. + * @param {Phaser.Geom.Rectangle} [output] - Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. + * + * @return {Phaser.Geom.Rectangle} A rectangle object with intersection data. */ -var LineToCircle = function (line, circle, nearest) +var GetRectangleIntersection = function (rectA, rectB, output) { - if (nearest === undefined) { nearest = tmp; } + if (output === undefined) { output = new Rectangle(); } - if (Contains(circle, line.x1, line.y1)) + if (RectangleToRectangle(rectA, rectB)) { - nearest.x = line.x1; - nearest.y = line.y1; - - return true; + output.x = Math.max(rectA.x, rectB.x); + output.y = Math.max(rectA.y, rectB.y); + output.width = Math.min(rectA.right, rectB.right) - output.x; + output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; } - if (Contains(circle, line.x2, line.y2)) - { - nearest.x = line.x2; - nearest.y = line.y2; - - return true; - } - - var dx = line.x2 - line.x1; - var dy = line.y2 - line.y1; - - var lcx = circle.x - line.x1; - var lcy = circle.y - line.y1; - - // project lc onto d, resulting in vector p - var dLen2 = (dx * dx) + (dy * dy); - var px = dx; - var py = dy; - - if (dLen2 > 0) - { - var dp = ((lcx * dx) + (lcy * dy)) / dLen2; - - px *= dp; - py *= dp; - } - - nearest.x = line.x1 + px; - nearest.y = line.y1 + py; - - // len2 of p - var pLen2 = (px * px) + (py * py); - - return ( - pLen2 <= dLen2 && - ((px * dx) + (py * dy)) >= 0 && - Contains(circle, nearest.x, nearest.y) - ); + return output; }; -module.exports = LineToCircle; +module.exports = GetRectangleIntersection; /***/ }), -/* 398 */ +/* 702 */ /***/ (function(module, exports) { /** @@ -95652,29 +127268,49 @@ module.exports = LineToCircle; /** * [description] * - * @function Phaser.Geom.Intersects.RectangleToRectangle + * @function Phaser.Geom.Intersects.CircleToRectangle * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Rectangle} rect - [description] * * @return {boolean} [description] */ -var RectangleToRectangle = function (rectA, rectB) +var CircleToRectangle = function (circle, rect) { - if (rectA.width <= 0 || rectA.height <= 0 || rectB.width <= 0 || rectB.height <= 0) + var halfWidth = rect.width / 2; + var halfHeight = rect.height / 2; + + var cx = Math.abs(circle.x - rect.x - halfWidth); + var cy = Math.abs(circle.y - rect.y - halfHeight); + var xDist = halfWidth + circle.radius; + var yDist = halfHeight + circle.radius; + + if (cx > xDist || cy > yDist) { return false; } + else if (cx <= halfWidth || cy <= halfHeight) + { + return true; + } + else + { + var xCornerDist = cx - halfWidth; + var yCornerDist = cy - halfHeight; + var xCornerDistSq = xCornerDist * xCornerDist; + var yCornerDistSq = yCornerDist * yCornerDist; + var maxCornerDistSq = circle.radius * circle.radius; - return !(rectA.right < rectB.x || rectA.bottom < rectB.y || rectA.x > rectB.right || rectA.y > rectB.bottom); + return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); + } }; -module.exports = RectangleToRectangle; +module.exports = CircleToRectangle; /***/ }), -/* 399 */ +/* 703 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -95683,33 +127319,30 @@ module.exports = RectangleToRectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var DistanceBetween = __webpack_require__(52); + /** - * @namespace Phaser.Geom.Intersects + * Checks if two Circles intersect. + * + * @function Phaser.Geom.Intersects.CircleToCircle + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circleA - The first Circle to check for intersection. + * @param {Phaser.Geom.Circle} circleB - The second Circle to check for intersection. + * + * @return {boolean} `true` if the two Circles intersect, otherwise `false`. */ - -module.exports = { - - CircleToCircle: __webpack_require__(844), - CircleToRectangle: __webpack_require__(843), - GetRectangleIntersection: __webpack_require__(842), - LineToCircle: __webpack_require__(397), - LineToLine: __webpack_require__(144), - LineToRectangle: __webpack_require__(841), - PointToLine: __webpack_require__(396), - PointToLineSegment: __webpack_require__(840), - RectangleToRectangle: __webpack_require__(398), - RectangleToTriangle: __webpack_require__(839), - RectangleToValues: __webpack_require__(838), - TriangleToCircle: __webpack_require__(837), - TriangleToLine: __webpack_require__(836), - TriangleToTriangle: __webpack_require__(835) - +var CircleToCircle = function (circleA, circleB) +{ + return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); }; +module.exports = CircleToCircle; + /***/ }), -/* 400 */ -/***/ (function(module, exports, __webpack_require__) { +/* 704 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -95718,25 +127351,666 @@ module.exports = { */ /** - * @namespace Phaser.Geom + * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. + * + * @function Phaser.Geom.Ellipse.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. */ +var OffsetPoint = function (ellipse, point) +{ + ellipse.x += point.x; + ellipse.y += point.y; -module.exports = { - - Circle: __webpack_require__(854), - Ellipse: __webpack_require__(249), - Intersects: __webpack_require__(399), - Line: __webpack_require__(834), - Point: __webpack_require__(816), - Polygon: __webpack_require__(802), - Rectangle: __webpack_require__(389), - Triangle: __webpack_require__(774) - + return ellipse; }; +module.exports = OffsetPoint; + /***/ }), -/* 401 */ +/* 705 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Ellipse by the values given. + * + * @function Phaser.Geom.Ellipse.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Ellipse by. + * @param {number} y - The amount to vertically offset the Ellipse by. + * + * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. + */ +var Offset = function (ellipse, x, y) +{ + ellipse.x += x; + ellipse.y += y; + + return ellipse; +}; + +module.exports = Offset; + + +/***/ }), +/* 706 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Returns the bounds of the Ellipse object. + * + * @function Phaser.Geom.Ellipse.GetBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Ellipse bounds. + */ +var GetBounds = function (ellipse, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = ellipse.left; + out.y = ellipse.top; + out.width = ellipse.width; + out.height = ellipse.height; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }), +/* 707 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Ellipse.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. + * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. + * + * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. + */ +var Equals = function (ellipse, toCompare) +{ + return ( + ellipse.x === toCompare.x && + ellipse.y === toCompare.y && + ellipse.width === toCompare.width && + ellipse.height === toCompare.height + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 708 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse + * into the given `dest` Ellipse, then returns the `dest` Ellipse. + * + * @function Phaser.Geom.Ellipse.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Ellipse} O - [dest,$return] + * + * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. + * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. + * + * @return {Phaser.Geom.Ellipse} The destination Ellipse. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.width, source.height); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 709 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(89); + +/** + * Check to see if the Ellipse contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Ellipse.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. + */ +var ContainsRect = function (ellipse, rect) +{ + return ( + Contains(ellipse, rect.x, rect.y) && + Contains(ellipse, rect.right, rect.y) && + Contains(ellipse, rect.x, rect.bottom) && + Contains(ellipse, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 710 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(89); + +/** + * Check to see if the Ellipse contains the given Point object. + * + * @function Phaser.Geom.Ellipse.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. + */ +var ContainsPoint = function (ellipse, point) +{ + return Contains(ellipse, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 711 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(90); + +/** + * Creates a new Ellipse instance based on the values contained in the given source. + * + * @function Phaser.Geom.Ellipse.Clone + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. + * + * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. + */ +var Clone = function (source) +{ + return new Ellipse(source.x, source.y, source.width, source.height); +}; + +module.exports = Clone; + + +/***/ }), +/* 712 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the Ellipse. + * + * @function Phaser.Geom.Ellipse.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. + * + * @return {number} The area of the Ellipse. + */ +var Area = function (ellipse) +{ + if (ellipse.isEmpty()) + { + return 0; + } + + // units squared + return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); +}; + +module.exports = Area; + + +/***/ }), +/* 713 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(90); + +Ellipse.Area = __webpack_require__(712); +Ellipse.Circumference = __webpack_require__(306); +Ellipse.CircumferencePoint = __webpack_require__(156); +Ellipse.Clone = __webpack_require__(711); +Ellipse.Contains = __webpack_require__(89); +Ellipse.ContainsPoint = __webpack_require__(710); +Ellipse.ContainsRect = __webpack_require__(709); +Ellipse.CopyFrom = __webpack_require__(708); +Ellipse.Equals = __webpack_require__(707); +Ellipse.GetBounds = __webpack_require__(706); +Ellipse.GetPoint = __webpack_require__(308); +Ellipse.GetPoints = __webpack_require__(307); +Ellipse.Offset = __webpack_require__(705); +Ellipse.OffsetPoint = __webpack_require__(704); +Ellipse.Random = __webpack_require__(185); + +module.exports = Ellipse; + + +/***/ }), +/* 714 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. + * + * @function Phaser.Geom.Circle.OffsetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [circle,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var OffsetPoint = function (circle, point) +{ + circle.x += point.x; + circle.y += point.y; + + return circle; +}; + +module.exports = OffsetPoint; + + +/***/ }), +/* 715 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Offsets the Circle by the values given. + * + * @function Phaser.Geom.Circle.Offset + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [circle,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) + * @param {number} x - The amount to horizontally offset the Circle by. + * @param {number} y - The amount to vertically offset the Circle by. + * + * @return {Phaser.Geom.Circle} The Circle that was offset. + */ +var Offset = function (circle, x, y) +{ + circle.x += x; + circle.y += y; + + return circle; +}; + +module.exports = Offset; + + +/***/ }), +/* 716 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); + +/** + * Returns the bounds of the Circle object. + * + * @function Phaser.Geom.Circle.GetBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [out,$return] + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. + * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Circles bounds. + */ +var GetBounds = function (circle, out) +{ + if (out === undefined) { out = new Rectangle(); } + + out.x = circle.left; + out.y = circle.top; + out.width = circle.diameter; + out.height = circle.diameter; + + return out; +}; + +module.exports = GetBounds; + + +/***/ }), +/* 717 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compares the `x`, `y` and `radius` properties of the two given Circles. + * Returns `true` if they all match, otherwise returns `false`. + * + * @function Phaser.Geom.Circle.Equals + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The first Circle to compare. + * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. + * + * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. + */ +var Equals = function (circle, toCompare) +{ + return ( + circle.x === toCompare.x && + circle.y === toCompare.y && + circle.radius === toCompare.radius + ); +}; + +module.exports = Equals; + + +/***/ }), +/* 718 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Copies the `x`, `y` and `radius` properties from the `source` Circle + * into the given `dest` Circle, then returns the `dest` Circle. + * + * @function Phaser.Geom.Circle.CopyFrom + * @since 3.0.0 + * + * @generic {Phaser.Geom.Circle} O - [dest,$return] + * + * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. + * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. + * + * @return {Phaser.Geom.Circle} The destination Circle. + */ +var CopyFrom = function (source, dest) +{ + return dest.setTo(source.x, source.y, source.radius); +}; + +module.exports = CopyFrom; + + +/***/ }), +/* 719 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(40); + +/** + * Check to see if the Circle contains all four points of the given Rectangle object. + * + * @function Phaser.Geom.Circle.ContainsRect + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Circle or not. + * + * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. + */ +var ContainsRect = function (circle, rect) +{ + return ( + Contains(circle, rect.x, rect.y) && + Contains(circle, rect.right, rect.y) && + Contains(circle, rect.x, rect.bottom) && + Contains(circle, rect.right, rect.bottom) + ); +}; + +module.exports = ContainsRect; + + +/***/ }), +/* 720 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Contains = __webpack_require__(40); + +/** + * Check to see if the Circle contains the given Point object. + * + * @function Phaser.Geom.Circle.ContainsPoint + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to check. + * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. + * + * @return {boolean} True if the Point coordinates are within the circle, otherwise false. + */ +var ContainsPoint = function (circle, point) +{ + return Contains(circle, point.x, point.y); +}; + +module.exports = ContainsPoint; + + +/***/ }), +/* 721 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(71); + +/** + * Creates a new Circle instance based on the values contained in the given source. + * + * @function Phaser.Geom.Circle.Clone + * @since 3.0.0 + * + * @param {(Phaser.Geom.Circle|object)} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. + * + * @return {Phaser.Geom.Circle} A clone of the source Circle. + */ +var Clone = function (source) +{ + return new Circle(source.x, source.y, source.radius); +}; + +module.exports = Clone; + + +/***/ }), +/* 722 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculates the area of the circle. + * + * @function Phaser.Geom.Circle.Area + * @since 3.0.0 + * + * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. + * + * @return {number} The area of the Circle. + */ +var Area = function (circle) +{ + return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; +}; + +module.exports = Area; + + +/***/ }), +/* 723 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Circle = __webpack_require__(71); + +Circle.Area = __webpack_require__(722); +Circle.Circumference = __webpack_require__(402); +Circle.CircumferencePoint = __webpack_require__(192); +Circle.Clone = __webpack_require__(721); +Circle.Contains = __webpack_require__(40); +Circle.ContainsPoint = __webpack_require__(720); +Circle.ContainsRect = __webpack_require__(719); +Circle.CopyFrom = __webpack_require__(718); +Circle.Equals = __webpack_require__(717); +Circle.GetBounds = __webpack_require__(716); +Circle.GetPoint = __webpack_require__(405); +Circle.GetPoints = __webpack_require__(403); +Circle.Offset = __webpack_require__(715); +Circle.OffsetPoint = __webpack_require__(714); +Circle.Random = __webpack_require__(191); + +module.exports = Circle; + + +/***/ }), +/* 724 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -95746,333 +128020,112 @@ module.exports = { */ var Class = __webpack_require__(0); -var Light = __webpack_require__(402); -var LightPipeline = __webpack_require__(148); -var Utils = __webpack_require__(27); - -/** - * @callback LightForEach - * - * @param {Phaser.GameObjects.Light} light - [description] - */ +var LightsManager = __webpack_require__(275); +var PluginCache = __webpack_require__(15); /** * @classdesc - * [description] + * A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for the Light2D pipeline. * - * @class LightsManager - * @memberOf Phaser.GameObjects + * Available from within a Scene via `this.lights`. + * + * Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method: + * + * ```javascript + * // Enable the Lights Manager because it is disabled by default + * this.lights.enable(); + * + * // Create a Light at [400, 300] with a radius of 200 + * this.lights.addLight(400, 300, 200); + * ``` + * + * For Game Objects to be affected by the Lights when rendered, you will need to set them to use the `Light2D` pipeline like so: + * + * ```javascript + * sprite.setPipeline('Light2D'); + * ``` + * + * @class LightsPlugin + * @extends Phaser.GameObjects.LightsManager + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene that this Lights Plugin belongs to. */ -var LightsManager = new Class({ +var LightsPlugin = new Class({ + + Extends: LightsManager, initialize: - function LightsManager () + function LightsPlugin (scene) { /** - * [description] + * A reference to the Scene that this Lights Plugin belongs to. * - * @name Phaser.GameObjects.LightsManager#lightPool - * @type {Phaser.GameObjects.Light[]} - * @default [] + * @name Phaser.GameObjects.LightsPlugin#scene + * @type {Phaser.Scene} * @since 3.0.0 */ - this.lightPool = []; + this.scene = scene; /** - * [description] + * A reference to the Scene's systems. * - * @name Phaser.GameObjects.LightsManager#lights - * @type {Phaser.GameObjects.Light[]} - * @default [] + * @name Phaser.GameObjects.LightsPlugin#systems + * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ - this.lights = []; + this.systems = scene.sys; - /** - * [description] - * - * @name Phaser.GameObjects.LightsManager#culledLights - * @type {Phaser.GameObjects.Light[]} - * @default [] - * @since 3.0.0 - */ - this.culledLights = []; - - /** - * [description] - * - * @name Phaser.GameObjects.LightsManager#ambientColor - * @type {{ r: float, g: float, b: float }} - * @since 3.0.0 - */ - this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; - - /** - * [description] - * - * @name Phaser.GameObjects.LightsManager#active - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.active = false; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#enable - * @since 3.0.0 - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - enable: function () - { - this.active = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#disable - * @since 3.0.0 - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - disable: function () - { - this.active = false; - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#cull - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.GameObjects.Light[]} [description] - */ - cull: function (camera) - { - var lights = this.lights; - var culledLights = this.culledLights; - var length = lights.length; - var cameraCenterX = camera.x + camera.width / 2.0; - var cameraCenterY = camera.y + camera.height / 2.0; - var cameraRadius = (camera.width + camera.height) / 2.0; - var point = { x: 0, y: 0 }; - var cameraMatrix = camera.matrix; - var viewportHeight = this.systems.game.config.height; - - culledLights.length = 0; - - for (var index = 0; index < length && culledLights.length < LightPipeline.LIGHT_COUNT; ++index) + if (!scene.sys.settings.isBooted) { - var light = lights[index]; - - cameraMatrix.transformPoint(light.x, light.y, point); - - // We'll just use bounding spheres to test - // if lights should be rendered - var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); - var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); - var distance = Math.sqrt(dx * dx + dy * dy); - - if (distance < light.radius + cameraRadius) - { - culledLights.push(lights[index]); - } + scene.sys.events.once('boot', this.boot, this); } - return culledLights; + LightsManager.call(this); }, /** - * [description] + * Boot the Lights Plugin. * - * @method Phaser.GameObjects.LightsManager#forEachLight - * @since 3.0.0 - * - * @param {LightForEach} callback - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - forEachLight: function (callback) - { - if (!callback) - { - return; - } - - var lights = this.lights; - var length = lights.length; - - for (var index = 0; index < length; ++index) - { - callback(lights[index]); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#setAmbientColor - * @since 3.0.0 - * - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - setAmbientColor: function (rgb) - { - var color = Utils.getFloatsFromUintRGB(rgb); - - this.ambientColor.r = color[0]; - this.ambientColor.g = color[1]; - this.ambientColor.b = color[2]; - - return this; - }, - - /** - * Returns the maximum number of Lights allowed to appear at once. - * - * @method Phaser.GameObjects.LightsManager#getMaxVisibleLights - * @since 3.0.0 - * - * @return {integer} [description] - */ - getMaxVisibleLights: function () - { - return 10; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#getLightCount - * @since 3.0.0 - * - * @return {integer} [description] - */ - getLightCount: function () - { - return this.lights.length; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#addLight - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * @param {number} rgb - [description] - * @param {number} intensity - [description] - * - * @return {Phaser.GameObjects.Light} [description] - */ - addLight: function (x, y, radius, rgb, intensity) - { - var color = null; - var light = null; - - x = (x === undefined) ? 0.0 : x; - y = (y === undefined) ? 0.0 : y; - rgb = (rgb === undefined) ? 0xffffff : rgb; - radius = (radius === undefined) ? 100.0 : radius; - intensity = (intensity === undefined) ? 1.0 : intensity; - - color = Utils.getFloatsFromUintRGB(rgb); - light = null; - - if (this.lightPool.length > 0) - { - light = this.lightPool.pop(); - light.set(x, y, radius, color[0], color[1], color[2], intensity); - } - else - { - light = new Light(x, y, radius, color[0], color[1], color[2], intensity); - } - - this.lights.push(light); - - return light; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#removeLight - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Light} light - [description] - * - * @return {Phaser.GameObjects.LightsManager} This Lights Manager object. - */ - removeLight: function (light) - { - var index = this.lights.indexOf(light); - - if (index >= 0) - { - this.lightPool.push(light); - this.lights.splice(index, 1); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsManager#shutdown + * @method Phaser.GameObjects.LightsPlugin#boot * @since 3.0.0 */ - shutdown: function () + boot: function () { - while (this.lights.length > 0) - { - this.lightPool.push(this.lights.pop()); - } + var eventEmitter = this.systems.events; - this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; - this.culledLights.length = 0; - this.lights.length = 0; + eventEmitter.on('shutdown', this.shutdown, this); + eventEmitter.on('destroy', this.destroy, this); }, /** - * [description] + * Destroy the Lights Plugin. * - * @method Phaser.GameObjects.LightsManager#destroy + * Cleans up all references. + * + * @method Phaser.GameObjects.LightsPlugin#destroy * @since 3.0.0 */ destroy: function () { this.shutdown(); + + this.scene = undefined; + this.systems = undefined; } }); -module.exports = LightsManager; +PluginCache.register('LightsPlugin', LightsPlugin, 'lights'); + +module.exports = LightsPlugin; /***/ }), -/* 402 */ +/* 725 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96081,257 +128134,48 @@ module.exports = LightsManager; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Utils = __webpack_require__(27); +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Quad = __webpack_require__(149); /** - * @classdesc - * A 2D point light. + * Creates a new Quad Game Object and returns it. * - * Add these to a scene using the ForwardDiffuseLightPipeline for lighting effects, or just to represent a point light. + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. * - * @class Light - * @memberOf Phaser.GameObjects - * @constructor + * @method Phaser.GameObjects.GameObjectCreator#quad * @since 3.0.0 * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * @param {number} radius - The radius of the light. - * @param {number} r - The red color of the light. A value between 0 and 1. - * @param {number} g - The green color of the light. A value between 0 and 1. - * @param {number} b - The blue color of the light. A value between 0 and 1. - * @param {number} intensity - The intensity of the light. + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. */ -var Light = new Class({ +GameObjectCreator.register('quad', function (config, addToScene) +{ + if (config === undefined) { config = {}; } - initialize: + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); - function Light (x, y, radius, r, g, b, intensity) + var quad = new Quad(this.scene, x, y, key, frame); + + if (addToScene !== undefined) { - /** - * The horizontal position of the light. - * - * @name Phaser.GameObjects.Light#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The vertical position of the light. - * - * @name Phaser.GameObjects.Light#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The radius of the light. - * - * @name Phaser.GameObjects.Light#radius - * @type {number} - * @since 3.0.0 - */ - this.radius = radius; - - /** - * The red color of the light. A value between 0 and 1. - * - * @name Phaser.GameObjects.Light#r - * @type {number} - * @since 3.0.0 - */ - this.r = r; - - /** - * The green color of the light. A value between 0 and 1. - * - * @name Phaser.GameObjects.Light#g - * @type {number} - * @since 3.0.0 - */ - this.g = g; - - /** - * The blue color of the light. A value between 0 and 1. - * - * @name Phaser.GameObjects.Light#b - * @type {number} - * @since 3.0.0 - */ - this.b = b; - - /** - * The intensity of the light. - * - * @name Phaser.GameObjects.Light#intensity - * @type {number} - * @since 3.0.0 - */ - this.intensity = intensity; - - /** - * The horizontal scroll factor of the light. - * - * @name Phaser.GameObjects.Light#scrollFactorX - * @type {number} - * @since 3.0.0 - */ - this.scrollFactorX = 1.0; - - /** - * The vertical scroll factor of the light. - * - * @name Phaser.GameObjects.Light#scrollFactorY - * @type {number} - * @since 3.0.0 - */ - this.scrollFactorY = 1.0; - }, - - /** - * Set the properties of the light. - * - * Sets both horizontal and vertical scroll factor to 1. Use {@link Phaser.GameObjects.Light#setScrollFactor} to set - * the scroll factor. - * - * @method Phaser.GameObjects.Light#set - * @since 3.0.0 - * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * @param {number} radius - The radius of the light. - * @param {number} r - The red color. A value between 0 and 1. - * @param {number} g - The green color. A value between 0 and 1. - * @param {number} b - The blue color. A value between 0 and 1. - * @param {number} intensity - The intensity of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - set: function (x, y, radius, r, g, b, intensity) - { - this.x = x; - this.y = y; - - this.radius = radius; - - this.r = r; - this.g = g; - this.b = b; - - this.intensity = intensity; - - this.scrollFactorX = 1; - this.scrollFactorY = 1; - - return this; - }, - - /** - * Set the scroll factor of the light. - * - * @method Phaser.GameObjects.Light#setScrollFactor - * @since 3.0.0 - * - * @param {number} x - The horizontal scroll factor of the light. - * @param {number} y - The vertical scroll factor of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setScrollFactor: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.scrollFactorX = x; - this.scrollFactorY = y; - - return this; - }, - - /** - * Set the color of the light from a single integer RGB value. - * - * @method Phaser.GameObjects.Light#setColor - * @since 3.0.0 - * - * @param {number} rgb - [description] - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setColor: function (rgb) - { - var color = Utils.getFloatsFromUintRGB(rgb); - - this.r = color[0]; - this.g = color[1]; - this.b = color[2]; - - return this; - }, - - /** - * Set the intensity of the light. - * - * @method Phaser.GameObjects.Light#setIntensity - * @since 3.0.0 - * - * @param {number} intensity - The intensity of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setIntensity: function (intensity) - { - this.intensity = intensity; - - return this; - }, - - /** - * Set the position of the light. - * - * @method Phaser.GameObjects.Light#setPosition - * @since 3.0.0 - * - * @param {number} x - The horizontal position of the light. - * @param {number} y - The vertical position of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setPosition: function (x, y) - { - this.x = x; - this.y = y; - - return this; - }, - - /** - * Set the radius of the light. - * - * @method Phaser.GameObjects.Light#setRadius - * @since 3.0.0 - * - * @param {number} radius - The radius of the light. - * - * @return {Phaser.GameObjects.Light} This Light object. - */ - setRadius: function (radius) - { - this.radius = radius; - - return this; + config.add = addToScene; } -}); + BuildGameObject(this.scene, quad, config); -module.exports = Light; + return quad; +}); /***/ }), -/* 403 */ +/* 726 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96340,10 +128184,444 @@ module.exports = Light; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BuildGameObject = __webpack_require__(24); +var BuildGameObject = __webpack_require__(28); var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Text = __webpack_require__(110); +var GetAdvancedValue = __webpack_require__(12); +var GetValue = __webpack_require__(4); +var Mesh = __webpack_require__(108); + +/** + * Creates a new Mesh Game Object and returns it. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#mesh + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +GameObjectCreator.register('mesh', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var vertices = GetValue(config, 'vertices', []); + var colors = GetValue(config, 'colors', []); + var alphas = GetValue(config, 'alphas', []); + var uv = GetValue(config, 'uv', []); + + var mesh = new Mesh(this.scene, 0, 0, vertices, uv, colors, alphas, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, mesh, config); + + return mesh; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 727 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Quad = __webpack_require__(149); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Quad Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#quad + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Quad} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('quad', function (x, y, key, frame) + { + return this.displayList.add(new Quad(this.scene, x, y, key, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 728 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Mesh = __webpack_require__(108); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Mesh Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#mesh + * @webglOnly + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number[]} vertices - An array containing the vertices data for this Mesh. + * @param {number[]} uv - An array containing the uv data for this Mesh. + * @param {number[]} colors - An array containing the color data for this Mesh. + * @param {number[]} alphas - An array containing the alpha data for this Mesh. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Mesh} The Game Object that was created. + */ +if (true) +{ + GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame) + { + return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, colors, alphas, texture, frame)); + }); +} + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 729 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects. + * + * @method Phaser.GameObjects.Mesh#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var MeshCanvasRenderer = function () +{ +}; + +module.exports = MeshCanvasRenderer; + + +/***/ }), +/* 730 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Mesh#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + + var vertices = src.vertices; + var uvs = src.uv; + var colors = src.colors; + var alphas = src.alphas; + + var meshVerticesLength = vertices.length; + var vertexCount = Math.floor(meshVerticesLength * 0.5); + + if (pipeline.vertexCount + vertexCount >= pipeline.vertexCapacity) + { + pipeline.flush(); + } + + pipeline.setTexture2D(texture, 0); + + var vertexViewF32 = pipeline.vertexViewF32; + var vertexViewU32 = pipeline.vertexViewU32; + + var vertexOffset = (pipeline.vertexCount * pipeline.vertexComponentCount) - 1; + + var colorIndex = 0; + var tintEffect = src.tintFill; + + for (var i = 0; i < meshVerticesLength; i += 2) + { + var x = vertices[i + 0]; + var y = vertices[i + 1]; + + var tx = x * calcMatrix.a + y * calcMatrix.c + calcMatrix.e; + var ty = x * calcMatrix.b + y * calcMatrix.d + calcMatrix.f; + + if (camera.roundPixels) + { + tx |= 0; + ty |= 0; + } + + vertexViewF32[++vertexOffset] = tx; + vertexViewF32[++vertexOffset] = ty; + vertexViewF32[++vertexOffset] = uvs[i + 0]; + vertexViewF32[++vertexOffset] = uvs[i + 1]; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = Utils.getTintAppendFloatAlpha(colors[colorIndex], camera.alpha * alphas[colorIndex]); + + colorIndex++; + } + + pipeline.vertexCount += vertexCount; +}; + +module.exports = MeshWebGLRenderer; + + +/***/ }), +/* 731 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(730); +} + +if (true) +{ + renderCanvas = __webpack_require__(729); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 732 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Zone = __webpack_require__(125); + +/** + * Creates a new Zone Game Object and returns it. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#zone + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectCreator.register('zone', function (config) +{ + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 1); + var height = GetAdvancedValue(config, 'height', width); + + return new Zone(this.scene, x, y, width, height); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 733 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var TileSprite = __webpack_require__(152); + +/** + * @typedef {object} TileSprite + * @extends GameObjectConfig + * + * @property {number} [x=0] - The x coordinate of the Tile Sprite. + * @property {number} [y=0] - The y coordinate of the Tile Sprite. + * @property {integer} [width=512] - The width of the Tile Sprite. If zero it will use the size of the texture frame. + * @property {integer} [height=512] - The height of the Tile Sprite. If zero it will use the size of the texture frame. + * @property {string} [key=''] - The key of the Texture this Tile Sprite will use to render with, as stored in the Texture Manager. + * @property {string} [frame=''] - An optional frame from the Texture this Tile Sprite is rendering with. + */ + +/** + * Creates a new TileSprite Game Object and returns it. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#tileSprite + * @since 3.0.0 + * + * @param {TileSprite} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectCreator.register('tileSprite', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 512); + var height = GetAdvancedValue(config, 'height', 512); + var key = GetAdvancedValue(config, 'key', ''); + var frame = GetAdvancedValue(config, 'frame', ''); + + var tile = new TileSprite(this.scene, x, y, width, height, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, tile, config); + + return tile; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 734 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Text = __webpack_require__(153); /** * Creates a new Text Game Object and returns it. @@ -96418,7 +128696,7 @@ GameObjectCreator.register('text', function (config, addToScene) /***/ }), -/* 404 */ +/* 735 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96427,11 +128705,72 @@ GameObjectCreator.register('text', function (config, addToScene) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BuildGameObject = __webpack_require__(24); -var BuildGameObjectAnimation = __webpack_require__(127); +var BitmapText = __webpack_require__(109); +var BuildGameObject = __webpack_require__(28); var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Sprite = __webpack_require__(34); +var GetAdvancedValue = __webpack_require__(12); +var GetValue = __webpack_require__(4); + +/** + * Creates a new Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#bitmapText + * @since 3.0.0 + * + * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectCreator.register('bitmapText', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var font = GetValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + var align = GetValue(config, 'align', 0); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 736 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var BuildGameObjectAnimation = __webpack_require__(311); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Sprite = __webpack_require__(61); + +/** + * @typedef {object} SpriteConfig + * @extends GameObjectConfig + * + * @property {string} [key] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @property {(number|string)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ /** * Creates a new Sprite Game Object and returns it. @@ -96441,7 +128780,7 @@ var Sprite = __webpack_require__(34); * @method Phaser.GameObjects.GameObjectCreator#sprite * @since 3.0.0 * - * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {SpriteConfig} config - The configuration object this Game Object will use to create itself. * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. * * @return {Phaser.GameObjects.Sprite} The Game Object that was created. @@ -96471,7 +128810,7 @@ GameObjectCreator.register('sprite', function (config, addToScene) /***/ }), -/* 405 */ +/* 737 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96480,10 +128819,126 @@ GameObjectCreator.register('sprite', function (config, addToScene) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BuildGameObject = __webpack_require__(24); +var BuildGameObject = __webpack_require__(28); var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Image = __webpack_require__(69); +var GetAdvancedValue = __webpack_require__(12); +var RenderTexture = __webpack_require__(154); + +/** + * @typedef {object} RenderTextureConfig + * + * @property {number} [x=0] - The x coordinate of the RenderTexture's position. + * @property {number} [y=0] - The y coordinate of the RenderTexture's position. + * @property {number} [width=32] - The width of the RenderTexture. + * @property {number} [height=32] - The height of the RenderTexture. + */ + +/** + * Creates a new Render Texture Game Object and returns it. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#renderTexture + * @since 3.2.0 + * + * @param {RenderTextureConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectCreator.register('renderTexture', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + var width = GetAdvancedValue(config, 'width', 32); + var height = GetAdvancedValue(config, 'height', 32); + + var renderTexture = new RenderTexture(this.scene, x, y, width, height); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, renderTexture, config); + + return renderTexture; +}); + + +/***/ }), +/* 738 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var GetFastValue = __webpack_require__(2); +var ParticleEmitterManager = __webpack_require__(155); + +/** + * Creates a new Particle Emitter Manager Game Object and returns it. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#particles + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectCreator.register('particles', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + var emitters = GetFastValue(config, 'emitters', null); + + // frame is optional and can contain the emitters array or object if skipped + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + var add = GetFastValue(config, 'add', false); + + if (add) + { + this.displayList.add(manager); + } + + this.updateList.add(manager); + + return manager; +}); + + +/***/ }), +/* 739 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); +var Image = __webpack_require__(87); /** * Creates a new Image Game Object and returns it. @@ -96521,7 +128976,7 @@ GameObjectCreator.register('image', function (config, addToScene) /***/ }), -/* 406 */ +/* 740 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96531,7 +128986,40 @@ GameObjectCreator.register('image', function (config, addToScene) */ var GameObjectCreator = __webpack_require__(13); -var Graphics = __webpack_require__(115); +var Group = __webpack_require__(88); + +/** + * Creates a new Group Game Object and returns it. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#group + * @since 3.0.0 + * + * @param {GroupConfig} config - The configuration object this Game Object will use to create itself. + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectCreator.register('group', function (config) +{ + return new Group(this.scene, null, config); +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 741 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectCreator = __webpack_require__(13); +var Graphics = __webpack_require__(158); /** * Creates a new Graphics Game Object and returns it. @@ -96569,7 +129057,7 @@ GameObjectCreator.register('graphics', function (config, addToScene) /***/ }), -/* 407 */ +/* 742 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96578,11 +129066,865 @@ GameObjectCreator.register('graphics', function (config, addToScene) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Text = __webpack_require__(110); -var GameObjectFactory = __webpack_require__(11); +var BitmapText = __webpack_require__(159); +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); + +/** + * @typedef {object} BitmapTextConfig + * @extends GameObjectConfig + * + * @property {string} [font=''] - The key of the font to use from the BitmapFont cache. + * @property {string} [text=''] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @property {(number|false)} [size=false] - The font size to set. + */ + +/** + * Creates a new Dynamic Bitmap Text Game Object and returns it. + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText + * @since 3.0.0 + *² + * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectCreator.register('dynamicBitmapText', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var font = GetAdvancedValue(config, 'font', ''); + var text = GetAdvancedValue(config, 'text', ''); + var size = GetAdvancedValue(config, 'size', false); + + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, bitmapText, config); + + return bitmapText; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 743 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(28); +var Container = __webpack_require__(160); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); + +/** + * Creates a new Container Game Object and returns it. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#container + * @since 3.4.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Container} The Game Object that was created. + */ +GameObjectCreator.register('container', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var x = GetAdvancedValue(config, 'x', 0); + var y = GetAdvancedValue(config, 'y', 0); + + var container = new Container(this.scene, x, y); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, container, config); + + return container; +}); + + +/***/ }), +/* 744 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(161); +var BuildGameObject = __webpack_require__(28); +var GameObjectCreator = __webpack_require__(13); +var GetAdvancedValue = __webpack_require__(12); + +/** + * Creates a new Blitter Game Object and returns it. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectCreator#blitter + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectCreator.register('blitter', function (config, addToScene) +{ + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var blitter = new Blitter(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, blitter, config); + + return blitter; +}); + +// When registering a factory function 'this' refers to the GameObjectCreator context. + + +/***/ }), +/* 745 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Triangle = __webpack_require__(279); + +/** + * Creates a new Triangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Triangle Game Object has been built into Phaser. + * + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @method Phaser.GameObjects.GameObjectFactory#triangle + * @since 3.13.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 {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Triangle} The Game Object that was created. + */ +GameObjectFactory.register('triangle', function (x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) +{ + return this.displayList.add(new Triangle(this.scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 746 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Star = __webpack_require__(280); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Star Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Star Game Object has been built into Phaser. + * + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#star + * @since 3.13.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 {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star. + * @param {number} [outerRadius=64] - The outer radius of the star. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Star} The Game Object that was created. + */ +GameObjectFactory.register('star', function (x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) +{ + return this.displayList.add(new Star(this.scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 747 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Rectangle = __webpack_require__(281); + +/** + * Creates a new Rectangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. + * + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @method Phaser.GameObjects.GameObjectFactory#rectangle + * @since 3.13.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 {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Rectangle} The Game Object that was created. + */ +GameObjectFactory.register('rectangle', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Rectangle(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 748 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Polygon = __webpack_require__(286); + +/** + * Creates a new Polygon Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Polygon Game Object has been built into Phaser. + * + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * @method Phaser.GameObjects.GameObjectFactory#polygon + * @since 3.13.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 {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Polygon} The Game Object that was created. + */ +GameObjectFactory.register('polygon', function (x, y, points, fillColor, fillAlpha) +{ + return this.displayList.add(new Polygon(this.scene, x, y, points, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 749 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Line = __webpack_require__(287); + +/** + * Creates a new Line Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Line Game Object has been built into Phaser. + * + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * @method Phaser.GameObjects.GameObjectFactory#line + * @since 3.13.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 {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Line} The Game Object that was created. + */ +GameObjectFactory.register('line', function (x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) +{ + return this.displayList.add(new Line(this.scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha)); +}); + + +/***/ }), +/* 750 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var IsoTriangle = __webpack_require__(288); + +/** + * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. + * + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @method Phaser.GameObjects.GameObjectFactory#isotriangle + * @since 3.13.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 {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + * + * @return {Phaser.GameObjects.IsoTriangle} The Game Object that was created. + */ +GameObjectFactory.register('isotriangle', function (x, y, size, height, reversed, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoTriangle(this.scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight)); +}); + + +/***/ }), +/* 751 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var IsoBox = __webpack_require__(289); + +/** + * Creates a new IsoBox Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. + * + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * + * @method Phaser.GameObjects.GameObjectFactory#isobox + * @since 3.13.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 {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + * + * @return {Phaser.GameObjects.IsoBox} The Game Object that was created. + */ +GameObjectFactory.register('isobox', function (x, y, size, height, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoBox(this.scene, x, y, size, height, fillTop, fillLeft, fillRight)); +}); + + +/***/ }), +/* 752 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Grid = __webpack_require__(290); + +/** + * Creates a new Grid Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Grid Game Object has been built into Phaser. + * + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @method Phaser.GameObjects.GameObjectFactory#grid + * @since 3.13.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 {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [outlineFillColor] - The color of the lines between the grid cells. + * @param {number} [outlineFillAlpha] - The alpha of the lines between the grid cells. + * + * @return {Phaser.GameObjects.Grid} The Game Object that was created. + */ +GameObjectFactory.register('grid', function (x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha) +{ + return this.displayList.add(new Grid(this.scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha)); +}); + + +/***/ }), +/* 753 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = __webpack_require__(291); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Ellipse Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. + * + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#ellipse + * @since 3.13.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 {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Ellipse} The Game Object that was created. + */ +GameObjectFactory.register('ellipse', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Ellipse(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 754 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Curve = __webpack_require__(292); + +/** + * Creates a new Curve Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Curve Game Object has been built into Phaser. + * + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#curve + * @since 3.13.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 {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Curve} The Game Object that was created. + */ +GameObjectFactory.register('curve', function (x, y, curve, fillColor, fillAlpha) +{ + return this.displayList.add(new Curve(this.scene, x, y, curve, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 755 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Arc = __webpack_require__(293); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Arc Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * @method Phaser.GameObjects.GameObjectFactory#arc + * @since 3.13.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 {number} [radius=128] - The radius of the arc. + * @param {integer} [startAngle=0] - The start angle of the arc, in degrees. + * @param {integer} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - The winding order of the start and end angles. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('arc', function (x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha)); +}); + +/** + * Creates a new Circle Shape Game Object and adds it to the Scene. + * + * A Circle is an Arc with no defined start and end angle, making it render as a complete circle. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#circle + * @since 3.13.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 {number} [radius=128] - The radius of the circle. + * @param {number} [fillColor] - The color the circle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('circle', function (x, y, radius, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, 0, 360, false, fillColor, fillAlpha)); +}); + + +/***/ }), +/* 756 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Zone = __webpack_require__(125); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Zone Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Zone Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#zone + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} width - The width of the Game Object. + * @param {number} height - The height of the Game Object. + * + * @return {Phaser.GameObjects.Zone} The Game Object that was created. + */ +GameObjectFactory.register('zone', function (x, y, width, height) +{ + return this.displayList.add(new Zone(this.scene, x, y, width, height)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 757 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var TileSprite = __webpack_require__(152); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new TileSprite Game Object and adds it to the Scene. + * + * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#tileSprite + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {integer} height - The height of the Game Object. If zero it will use the size of the texture frame. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. + */ +GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) +{ + return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 758 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Text = __webpack_require__(153); +var GameObjectFactory = __webpack_require__(5); /** * Creates a new Text Game Object and adds it to the Scene. + * + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. * * Note: This method will only be available if the Text Game Object has been built into Phaser. * @@ -96611,7 +129953,7 @@ GameObjectFactory.register('text', function (x, y, text, style) /***/ }), -/* 408 */ +/* 759 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96620,8 +129962,72 @@ GameObjectFactory.register('text', function (x, y, text, style) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObjectFactory = __webpack_require__(11); -var Sprite = __webpack_require__(34); +var BitmapText = __webpack_require__(109); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#bitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. + * + * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. + */ +GameObjectFactory.register('bitmapText', function (x, y, font, text, size, align) +{ + return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size, align)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 760 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var Sprite = __webpack_require__(61); /** * Creates a new Sprite Game Object and adds it to the Scene. @@ -96658,7 +130064,7 @@ GameObjectFactory.register('sprite', function (x, y, key, frame) /***/ }), -/* 409 */ +/* 761 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96667,8 +130073,140 @@ GameObjectFactory.register('sprite', function (x, y, key, frame) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Image = __webpack_require__(69); -var GameObjectFactory = __webpack_require__(11); +var GameObjectFactory = __webpack_require__(5); +var RenderTexture = __webpack_require__(154); + +/** + * Creates a new Render Texture Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. + * + * @method Phaser.GameObjects.GameObjectFactory#renderTexture + * @since 3.2.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {integer} [width=32] - The width of the Render Texture. + * @param {integer} [height=32] - The height of the Render Texture. + * + * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. + */ +GameObjectFactory.register('renderTexture', function (x, y, width, height) +{ + return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); +}); + + +/***/ }), +/* 762 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var PathFollower = __webpack_require__(296); + +/** + * Creates a new PathFollower Game Object and adds it to the Scene. + * + * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#follower + * @since 3.0.0 + * + * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. + * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. + */ +GameObjectFactory.register('follower', function (path, x, y, key, frame) +{ + var sprite = new PathFollower(this.scene, path, x, y, key, frame); + + this.displayList.add(sprite); + this.updateList.add(sprite); + + return sprite; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 763 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = __webpack_require__(5); +var ParticleEmitterManager = __webpack_require__(155); + +/** + * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Particles Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#particles + * @since 3.0.0 + * + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer|object)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {ParticleEmitterConfig|ParticleEmitterConfig[]} [emitters] - Configuration settings for one or more emitters to create. + * + * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. + */ +GameObjectFactory.register('particles', function (key, frame, emitters) +{ + var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); + + this.displayList.add(manager); + this.updateList.add(manager); + + return manager; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 764 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Image = __webpack_require__(87); +var GameObjectFactory = __webpack_require__(5); /** * Creates a new Image Game Object and adds it to the Scene. @@ -96700,7 +130238,7 @@ GameObjectFactory.register('image', function (x, y, key, frame) /***/ }), -/* 410 */ +/* 765 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96709,8 +130247,40 @@ GameObjectFactory.register('image', function (x, y, key, frame) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Graphics = __webpack_require__(115); -var GameObjectFactory = __webpack_require__(11); +var Group = __webpack_require__(88); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Group Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Group Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#group + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupConfig[])} [children] - Game Objects to add to this Group; or the `config` argument. + * @param {GroupConfig} [config] - A Group Configuration object. + * + * @return {Phaser.GameObjects.Group} The Game Object that was created. + */ +GameObjectFactory.register('group', function (children, config) +{ + return this.updateList.add(new Group(this.scene, children, config)); +}); + + +/***/ }), +/* 766 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Graphics = __webpack_require__(158); +var GameObjectFactory = __webpack_require__(5); /** * Creates a new Graphics Game Object and adds it to the Scene. @@ -96739,7 +130309,2611 @@ GameObjectFactory.register('graphics', function (config) /***/ }), -/* 411 */ +/* 767 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DynamicBitmapText = __webpack_require__(159); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * + * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} font - The key of the font to use from the BitmapFont cache. + * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. + * @param {number} [size] - The font size to set. + * + * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. + */ +GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) +{ + return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 768 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Container = __webpack_require__(160); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Container Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Container Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#container + * @since 3.4.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. + * + * @return {Phaser.GameObjects.Container} The Game Object that was created. + */ +GameObjectFactory.register('container', function (x, y, children) +{ + return this.displayList.add(new Container(this.scene, x, y, children)); +}); + + +/***/ }), +/* 769 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Blitter = __webpack_require__(161); +var GameObjectFactory = __webpack_require__(5); + +/** + * Creates a new Blitter Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Blitter Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#blitter + * @since 3.0.0 + * + * @param {number} x - The x position of the Game Object. + * @param {number} y - The y position of the Game Object. + * @param {string} key - The key of the Texture the Blitter object will use. + * @param {(string|integer)} [frame] - The default Frame children of the Blitter will use. + * + * @return {Phaser.GameObjects.Blitter} The Game Object that was created. + */ +GameObjectFactory.register('blitter', function (x, y, key, frame) +{ + return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns + + +/***/ }), +/* 770 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + ctx.beginPath(); + + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.lineTo(x3, y3); + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = TriangleCanvasRenderer; + + +/***/ }), +/* 771 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StrokePathWebGL = __webpack_require__(60); +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + var fillTint = pipeline.fillTint; + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + pipeline.setTexture2D(); + + pipeline.batchFillTriangle( + x1, + y1, + x2, + y2, + x3, + y3, + shapeMatrix, + camMatrix + ); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = TriangleWebGLRenderer; + + +/***/ }), +/* 772 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(771); +} + +if (true) +{ + renderCanvas = __webpack_require__(770); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 773 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = StarCanvasRenderer; + + +/***/ }), +/* 774 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = StarWebGLRenderer; + + +/***/ }), +/* 775 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(774); +} + +if (true) +{ + renderCanvas = __webpack_require__(773); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 776 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.rect( + -dx, + -dy, + src.width, + src.height + ); + + ctx.stroke(); + } + } +}; + +module.exports = RectangleCanvasRenderer; + + +/***/ }), +/* 777 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StrokePathWebGL = __webpack_require__(60); +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + var fillTint = pipeline.fillTint; + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + pipeline.batchFillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = RectangleWebGLRenderer; + + +/***/ }), +/* 778 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(777); +} + +if (true) +{ + renderCanvas = __webpack_require__(776); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 779 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = PolygonCanvasRenderer; + + +/***/ }), +/* 780 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = PolygonWebGLRenderer; + + +/***/ }), +/* 781 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(780); +} + +if (true) +{ + renderCanvas = __webpack_require__(779); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 782 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.moveTo(src.geom.x1 - dx, src.geom.y1 - dy); + ctx.lineTo(src.geom.x2 - dx, src.geom.y2 - dy); + + ctx.stroke(); + } + } +}; + +module.exports = LineCanvasRenderer; + + +/***/ }), +/* 783 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isStroked) + { + var strokeTint = pipeline.strokeTint; + var color = Utils.getTintAppendFloatAlphaAndSwap(src.strokeColor, src.strokeAlpha * alpha); + + strokeTint.TL = color; + strokeTint.TR = color; + strokeTint.BL = color; + strokeTint.BR = color; + + var startWidth = src._startWidth; + var endWidth = src._endWidth; + + pipeline.setTexture2D(); + + pipeline.batchLine( + src.geom.x1 - dx, + src.geom.y1 - dy, + src.geom.x2 - dx, + src.geom.y2 - dy, + startWidth, + endWidth, + 1, + 0, + false, + shapeMatrix, + camMatrix + ); + } +}; + +module.exports = LineWebGLRenderer; + + +/***/ }), +/* 784 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(783); +} + +if (true) +{ + renderCanvas = __webpack_require__(782); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 785 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + // Top Face + + if (src.showTop && reversed) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(0, sizeB - height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + } +}; + +module.exports = IsoTriangleCanvasRenderer; + + +/***/ }), +/* 786 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + var alpha = camera.alpha * src.alpha; + + if (!src.isFilled) + { + return; + } + + var tint; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + // Top Face + + if (src.showTop && reversed) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillTop, alpha); + + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, -sizeB - height); + y1 = calcMatrix.getY(0, -sizeB - height); + + x2 = calcMatrix.getX(sizeA, -height); + y2 = calcMatrix.getY(sizeA, -height); + + var x3 = calcMatrix.getX(0, sizeB - height); + var y3 = calcMatrix.getY(0, sizeB - height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillLeft, alpha); + + if (reversed) + { + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + else + { + x0 = calcMatrix.getX(-sizeA, 0); + y0 = calcMatrix.getY(-sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + + pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillRight, alpha); + + if (reversed) + { + x0 = calcMatrix.getX(sizeA, -height); + y0 = calcMatrix.getY(sizeA, -height); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + else + { + x0 = calcMatrix.getX(sizeA, 0); + y0 = calcMatrix.getY(sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + + pipeline.setTexture2D(); + + pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2); + } +}; + +module.exports = IsoTriangleWebGLRenderer; + + +/***/ }), +/* 787 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(786); +} + +if (true) +{ + renderCanvas = __webpack_require__(785); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 788 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + // Top Face + + if (src.showTop) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, -1); + ctx.lineTo(0, sizeB - 1); + ctx.lineTo(-sizeA, -1); + ctx.lineTo(-sizeA, -height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(-sizeA, -height); + ctx.lineTo(-sizeA, 0); + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, 0); + + ctx.fill(); + } + } +}; + +module.exports = IsoBoxCanvasRenderer; + + +/***/ }), +/* 789 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var alpha = camera.alpha * src.alpha; + + if (!src.isFilled) + { + return; + } + + var tint; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + var x3; + var y3; + + // Top Face + + if (src.showTop) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillTop, alpha); + + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, -sizeB - height); + y1 = calcMatrix.getY(0, -sizeB - height); + + x2 = calcMatrix.getX(sizeA, -height); + y2 = calcMatrix.getY(sizeA, -height); + + x3 = calcMatrix.getX(0, sizeB - height); + y3 = calcMatrix.getY(0, sizeB - height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillLeft, alpha); + + x0 = calcMatrix.getX(-sizeA, 0); + y0 = calcMatrix.getY(-sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + + x3 = calcMatrix.getX(-sizeA, -height); + y3 = calcMatrix.getY(-sizeA, -height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillRight, alpha); + + x0 = calcMatrix.getX(sizeA, 0); + y0 = calcMatrix.getY(sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + + x3 = calcMatrix.getX(sizeA, -height); + y3 = calcMatrix.getY(sizeA, -height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } +}; + +module.exports = IsoBoxWebGLRenderer; + + +/***/ }), +/* 790 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(789); +} + +if (true) +{ + renderCanvas = __webpack_require__(788); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 791 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.rect( + -dx, + -dy, + src.width, + src.height + ); + + ctx.stroke(); + } + } +}; + +module.exports = RectangleCanvasRenderer; + + +/***/ }), +/* 792 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Grid#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Grid} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + calcMatrix.translate(-src._displayOriginX, -src._displayOriginY); + + var alpha = camera.alpha * src.alpha; + + // Work out the grid size + + var width = src.width; + var height = src.height; + + var cellWidth = src.cellWidth; + var cellHeight = src.cellHeight; + + var gridWidth = Math.ceil(width / cellWidth); + var gridHeight = Math.ceil(height / cellHeight); + + var cellWidthA = cellWidth; + var cellHeightA = cellHeight; + + var cellWidthB = cellWidth - ((gridWidth * cellWidth) - width); + var cellHeightB = cellHeight - ((gridHeight * cellHeight) - height); + + var fillTint; + var fillTintColor; + + var showCells = src.showCells; + var showAltCells = src.showAltCells; + var showOutline = src.showOutline; + + var x = 0; + var y = 0; + var r = 0; + var cw = 0; + var ch = 0; + + if (showOutline) + { + // To make room for the grid lines (in case alpha < 1) + cellWidthA--; + cellHeightA--; + + if (cellWidthB === cellWidth) + { + cellWidthB--; + } + + if (cellHeightB === cellHeight) + { + cellHeightB--; + } + } + + if (showCells && src.fillAlpha > 0) + { + fillTint = pipeline.fillTint; + fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && r) + { + r = 0; + continue; + } + + r++; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + pipeline.setTexture2D(); + + pipeline.batchFillRect( + x * cellWidth, + y * cellHeight, + cw, + ch + ); + } + } + } + + if (showAltCells && src.altFillAlpha > 0) + { + fillTint = pipeline.fillTint; + fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.altFillColor, src.altFillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && !r) + { + r = 1; + continue; + } + + r = 0; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + pipeline.setTexture2D(); + + pipeline.batchFillRect( + x * cellWidth, + y * cellHeight, + cw, + ch + ); + } + } + } + + if (showOutline && src.outlineFillAlpha > 0) + { + var strokeTint = pipeline.strokeTint; + var color = Utils.getTintAppendFloatAlphaAndSwap(src.outlineFillColor, src.outlineFillAlpha * alpha); + + strokeTint.TL = color; + strokeTint.TR = color; + strokeTint.BL = color; + strokeTint.BR = color; + + for (x = 1; x < gridWidth; x++) + { + var x1 = x * cellWidth; + + pipeline.setTexture2D(); + + pipeline.batchLine(x1, 0, x1, height, 1, 1, 1, 0, false); + } + + for (y = 1; y < gridHeight; y++) + { + var y1 = y * cellHeight; + + pipeline.setTexture2D(); + + pipeline.batchLine(0, y1, width, y1, 1, 1, 1, 0, false); + } + } +}; + +module.exports = GridWebGLRenderer; + + +/***/ }), +/* 793 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(792); +} + +if (true) +{ + renderCanvas = __webpack_require__(791); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 794 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = EllipseCanvasRenderer; + + +/***/ }), +/* 795 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = EllipseWebGLRenderer; + + +/***/ }), +/* 796 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(795); +} + +if (true) +{ + renderCanvas = __webpack_require__(794); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 797 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = CurveCanvasRenderer; + + +/***/ }), +/* 798 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = CurveWebGLRenderer; + + +/***/ }), +/* 799 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(798); +} + +if (true) +{ + renderCanvas = __webpack_require__(797); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 800 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DegToRad = __webpack_require__(31); +var FillStyleCanvas = __webpack_require__(30); +var LineStyleCanvas = __webpack_require__(36); +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var radius = src.radius; + + ctx.beginPath(); + + ctx.arc( + (radius) - src.originX * (radius * 2), + (radius) - src.originY * (radius * 2), + radius, + DegToRad(src._startAngle), + DegToRad(src._endAngle), + src.anticlockwise + ); + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + } +}; + +module.exports = ArcCanvasRenderer; + + +/***/ }), +/* 801 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = __webpack_require__(82); +var StrokePathWebGL = __webpack_require__(60); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = ArcWebGLRenderer; + + +/***/ }), +/* 802 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(801); +} + +if (true) +{ + renderCanvas = __webpack_require__(800); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 803 */ /***/ (function(module, exports) { /** @@ -96749,27 +132923,32 @@ GameObjectFactory.register('graphics', function (config) */ /** - * Returns the nearest power of 2 to the given `value`. + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Math.Pow2.GetPowerOfTwo + * @method Phaser.GameObjects.TileSprite#renderCanvas * @since 3.0.0 + * @private * - * @param {number} value - The value. - * - * @return {integer} The nearest power of 2 to `value`. + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var GetPowerOfTwo = function (value) +var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - var index = Math.log(value) / 0.6931471805599453; + src.updateCanvas(); - return (1 << Math.ceil(index)); + renderer.batchSprite(src, src.frame, camera, parentMatrix); }; -module.exports = GetPowerOfTwo; +module.exports = TileSpriteCanvasRenderer; /***/ }), -/* 412 */ +/* 804 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96778,7 +132957,98 @@ module.exports = GetPowerOfTwo; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var CanvasPool = __webpack_require__(22); +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.TileSprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + src.updateCanvas(); + + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + src.fillPattern, + src.displayFrame.width * src.tileScaleX, src.displayFrame.height * src.tileScaleY, + src.x, src.y, + src.width, src.height, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.originX * src.width, src.originY * src.height, + 0, 0, src.width, src.height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + (src.tilePositionX % src.displayFrame.width) / src.displayFrame.width, + (src.tilePositionY % src.displayFrame.height) / src.displayFrame.height, + camera, + parentMatrix + ); +}; + +module.exports = TileSpriteWebGLRenderer; + + +/***/ }), +/* 805 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(804); +} + +if (true) +{ + renderCanvas = __webpack_require__(803); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 806 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasPool = __webpack_require__(24); /** * Calculates the ascent, descent and fontSize of a given font style. @@ -96904,7 +133174,7 @@ module.exports = MeasureText; /***/ }), -/* 413 */ +/* 807 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -96914,9 +133184,9 @@ module.exports = MeasureText; */ var Class = __webpack_require__(0); -var GetAdvancedValue = __webpack_require__(10); +var GetAdvancedValue = __webpack_require__(12); var GetValue = __webpack_require__(4); -var MeasureText = __webpack_require__(412); +var MeasureText = __webpack_require__(806); // Key: [ Object Key, Default Value ] @@ -96949,6 +133219,7 @@ var propertyMap = { maxLines: [ 'maxLines', 0 ], fixedWidth: [ 'fixedWidth', 0 ], fixedHeight: [ 'fixedHeight', 0 ], + resolution: [ 'resolution', 0 ], rtl: [ 'rtl', false ], testString: [ 'testString', '|MÉqgy' ], baselineX: [ 'baselineX', 1.2 ], @@ -96959,17 +133230,27 @@ var propertyMap = { wordWrapUseAdvanced: [ 'wordWrap.useAdvancedWrap', false ] }; +/** + * Font metrics for a Text Style object. + * + * @typedef {object} BitmapTextMetrics + * + * @property {number} ascent - The ascent of the font. + * @property {number} descent - The descent of the font. + * @property {number} fontSize - The size of the font. + */ + /** * @classdesc - * [description] + * Style settings for a Text object. * * @class TextStyle - * @memberOf Phaser.GameObjects.Text + * @memberof Phaser.GameObjects.Text * @constructor * @since 3.0.0 * * @param {Phaser.GameObjects.Text} text - The Text object that this TextStyle is styling. - * @param {object} style - [description] + * @param {object} style - The style settings to set. */ var TextStyle = new Class({ @@ -96987,7 +133268,7 @@ var TextStyle = new Class({ this.parent = text; /** - * [description] + * The font family. * * @name Phaser.GameObjects.Text.TextStyle#fontFamily * @type {string} @@ -96997,7 +133278,7 @@ var TextStyle = new Class({ this.fontFamily; /** - * [description] + * The font size. * * @name Phaser.GameObjects.Text.TextStyle#fontSize * @type {string} @@ -97007,7 +133288,7 @@ var TextStyle = new Class({ this.fontSize; /** - * [description] + * The font style. * * @name Phaser.GameObjects.Text.TextStyle#fontStyle * @type {string} @@ -97016,7 +133297,7 @@ var TextStyle = new Class({ this.fontStyle; /** - * [description] + * The background color. * * @name Phaser.GameObjects.Text.TextStyle#backgroundColor * @type {string} @@ -97025,7 +133306,7 @@ var TextStyle = new Class({ this.backgroundColor; /** - * [description] + * The text fill color. * * @name Phaser.GameObjects.Text.TextStyle#color * @type {string} @@ -97035,7 +133316,7 @@ var TextStyle = new Class({ this.color; /** - * [description] + * The text stroke color. * * @name Phaser.GameObjects.Text.TextStyle#stroke * @type {string} @@ -97045,7 +133326,7 @@ var TextStyle = new Class({ this.stroke; /** - * [description] + * The text stroke thickness. * * @name Phaser.GameObjects.Text.TextStyle#strokeThickness * @type {number} @@ -97055,7 +133336,7 @@ var TextStyle = new Class({ this.strokeThickness; /** - * [description] + * The horizontal shadow offset. * * @name Phaser.GameObjects.Text.TextStyle#shadowOffsetX * @type {number} @@ -97065,7 +133346,7 @@ var TextStyle = new Class({ this.shadowOffsetX; /** - * [description] + * The vertical shadow offset. * * @name Phaser.GameObjects.Text.TextStyle#shadowOffsetY * @type {number} @@ -97075,7 +133356,7 @@ var TextStyle = new Class({ this.shadowOffsetY; /** - * [description] + * The shadow color. * * @name Phaser.GameObjects.Text.TextStyle#shadowColor * @type {string} @@ -97085,7 +133366,7 @@ var TextStyle = new Class({ this.shadowColor; /** - * [description] + * The shadow blur radius. * * @name Phaser.GameObjects.Text.TextStyle#shadowBlur * @type {number} @@ -97095,7 +133376,7 @@ var TextStyle = new Class({ this.shadowBlur; /** - * [description] + * Whether shadow stroke is enabled or not. * * @name Phaser.GameObjects.Text.TextStyle#shadowStroke * @type {boolean} @@ -97105,7 +133386,7 @@ var TextStyle = new Class({ this.shadowStroke; /** - * [description] + * Whether shadow fill is enabled or not. * * @name Phaser.GameObjects.Text.TextStyle#shadowFill * @type {boolean} @@ -97115,7 +133396,7 @@ var TextStyle = new Class({ this.shadowFill; /** - * [description] + * The text alignment. * * @name Phaser.GameObjects.Text.TextStyle#align * @type {string} @@ -97125,7 +133406,7 @@ var TextStyle = new Class({ this.align; /** - * [description] + * The maximum number of lines to draw. * * @name Phaser.GameObjects.Text.TextStyle#maxLines * @type {integer} @@ -97135,7 +133416,9 @@ var TextStyle = new Class({ this.maxLines; /** - * [description] + * The fixed width of the text. + * + * `0` means no fixed with. * * @name Phaser.GameObjects.Text.TextStyle#fixedWidth * @type {number} @@ -97145,7 +133428,9 @@ var TextStyle = new Class({ this.fixedWidth; /** - * [description] + * The fixed height of the text. + * + * `0` means no fixed height. * * @name Phaser.GameObjects.Text.TextStyle#fixedHeight * @type {number} @@ -97155,7 +133440,18 @@ var TextStyle = new Class({ this.fixedHeight; /** - * [description] + * The resolution the text is rendered to its internal canvas at. + * The default is 0, which means it will use the resolution set in the Game Config. + * + * @name Phaser.GameObjects.Text.TextStyle#resolution + * @type {number} + * @default 0 + * @since 3.12.0 + */ + this.resolution; + + /** + * Whether the text should render right to left. * * @name Phaser.GameObjects.Text.TextStyle#rtl * @type {boolean} @@ -97165,7 +133461,7 @@ var TextStyle = new Class({ this.rtl; /** - * [description] + * The test string to use when measuring the font. * * @name Phaser.GameObjects.Text.TextStyle#testString * @type {string} @@ -97195,7 +133491,7 @@ var TextStyle = new Class({ this.baselineY; /** - * [description] + * The font style, size and family. * * @name Phaser.GameObjects.Text.TextStyle#_font * @type {string} @@ -97205,7 +133501,7 @@ var TextStyle = new Class({ this._font; // Set to defaults + user style - this.setStyle(style, false); + this.setStyle(style, false, true); var metrics = GetValue(style, 'metrics', false); @@ -97226,19 +133522,30 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the text style. + * + * @example + * text.setStyle({ + * fontSize: '64px', + * fontFamily: 'Arial', + * color: '#ffffff', + * align: 'center', + * backgroundColor: '#ff00ff' + * }); * * @method Phaser.GameObjects.Text.TextStyle#setStyle * @since 3.0.0 * - * @param {CSSStyleRule} style - [description] - * @param {boolean} [updateText=true] - [description] + * @param {object} style - The style settings to set. + * @param {boolean} [updateText=true] - Whether to update the text immediately. + * @param {boolean} [setDefaults=false] - Use the default values is not set, or the local values. * * @return {Phaser.GameObjects.Text} The parent Text object. */ - setStyle: function (style, updateText) + setStyle: function (style, updateText, setDefaults) { if (updateText === undefined) { updateText = true; } + if (setDefaults === undefined) { setDefaults = false; } // Avoid type mutation if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number') @@ -97248,14 +133555,16 @@ var TextStyle = new Class({ for (var key in propertyMap) { + var value = (setDefaults) ? propertyMap[key][1] : this[key]; + if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') { // Callback & scope should be set without processing the values - this[key] = GetValue(style, propertyMap[key][0], propertyMap[key][1]); + this[key] = GetValue(style, propertyMap[key][0], value); } else { - this[key] = GetAdvancedValue(style, propertyMap[key][0], propertyMap[key][1]); + this[key] = GetAdvancedValue(style, propertyMap[key][0], value); } } @@ -97264,7 +133573,7 @@ var TextStyle = new Class({ if (font === null) { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); } else { @@ -97290,13 +133599,13 @@ var TextStyle = new Class({ }, /** - * [description] + * Synchronize the font settings to the given Canvas Rendering Context. * * @method Phaser.GameObjects.Text.TextStyle#syncFont * @since 3.0.0 * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] + * @param {HTMLCanvasElement} canvas - The Canvas Element. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. */ syncFont: function (canvas, context) { @@ -97304,13 +133613,13 @@ var TextStyle = new Class({ }, /** - * [description] + * Synchronize the text style settings to the given Canvas Rendering Context. * * @method Phaser.GameObjects.Text.TextStyle#syncStyle * @since 3.0.0 * - * @param {HTMLCanvasElement} canvas - [description] - * @param {CanvasRenderingContext2D} context - [description] + * @param {HTMLCanvasElement} canvas - The Canvas Element. + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. */ syncStyle: function (canvas, context) { @@ -97325,13 +133634,13 @@ var TextStyle = new Class({ }, /** - * [description] + * Synchronize the shadow settings to the given Canvas Rendering Context. * * @method Phaser.GameObjects.Text.TextStyle#syncShadow * @since 3.0.0 * - * @param {CanvasRenderingContext2D} context - [description] - * @param {boolean} enabled - [description] + * @param {CanvasRenderingContext2D} context - The Canvas Rendering Context. + * @param {boolean} enabled - Whether shadows are enabled or not. */ syncShadow: function (context, enabled) { @@ -97352,12 +133661,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Update the style settings for the parent Text object. * * @method Phaser.GameObjects.Text.TextStyle#update * @since 3.0.0 * - * @param {boolean} recalculateMetrics - [description] + * @param {boolean} recalculateMetrics - Whether to recalculate font and text metrics. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97365,7 +133674,7 @@ var TextStyle = new Class({ { if (recalculateMetrics) { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); this.metrics = MeasureText(this); } @@ -97374,74 +133683,96 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. * * @method Phaser.GameObjects.Text.TextStyle#setFont * @since 3.0.0 * - * @param {(string|object)} font - [description] + * @param {(string|object)} font - The font family or font settings to set. * * @return {Phaser.GameObjects.Text} The parent Text object. */ setFont: function (font) { - if (typeof font === 'string') + var fontFamily = font; + var fontSize = ''; + var fontStyle = ''; + + if (typeof font !== 'string') { - this.fontFamily = font; - this.fontSize = ''; - this.fontStyle = ''; - } - else - { - this.fontFamily = GetValue(font, 'fontFamily', 'Courier'); - this.fontSize = GetValue(font, 'fontSize', '16px'); - this.fontStyle = GetValue(font, 'fontStyle', ''); + fontFamily = GetValue(font, 'fontFamily', 'Courier'); + fontSize = GetValue(font, 'fontSize', '16px'); + fontStyle = GetValue(font, 'fontStyle', ''); } - return this.update(true); + if (fontFamily !== this.fontFamily || fontSize !== this.fontSize || fontStyle !== this.fontStyle) + { + this.fontFamily = fontFamily; + this.fontSize = fontSize; + this.fontStyle = fontStyle; + + this.update(true); + } + + return this.parent; }, /** - * [description] + * Set the font family. * * @method Phaser.GameObjects.Text.TextStyle#setFontFamily * @since 3.0.0 * - * @param {string} family - [description] + * @param {string} family - The font family. * * @return {Phaser.GameObjects.Text} The parent Text object. */ setFontFamily: function (family) { - this.fontFamily = family; + if (this.fontFamily !== family) + { + this.fontFamily = family; - return this.update(true); + this.update(true); + } + + return this.parent; }, /** - * [description] + * Set the font style. * * @method Phaser.GameObjects.Text.TextStyle#setFontStyle * @since 3.0.0 * - * @param {string} style - [description] + * @param {string} style - The font style. * * @return {Phaser.GameObjects.Text} The parent Text object. */ setFontStyle: function (style) { - this.fontStyle = style; + if (this.fontStyle !== style) + { + this.fontStyle = style; - return this.update(true); + this.update(true); + } + + return this.parent; }, /** - * [description] + * Set the font size. * * @method Phaser.GameObjects.Text.TextStyle#setFontSize * @since 3.0.0 * - * @param {(number|string)} size - [description] + * @param {(number|string)} size - The font size. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97452,18 +133783,23 @@ var TextStyle = new Class({ size = size.toString() + 'px'; } - this.fontSize = size; + if (this.fontSize !== size) + { + this.fontSize = size; - return this.update(true); + this.update(true); + } + + return this.parent; }, /** - * [description] + * Set the test string to use when measuring the font. * * @method Phaser.GameObjects.Text.TextStyle#setTestString * @since 3.0.0 * - * @param {string} string - [description] + * @param {string} string - The test string to use when measuring the font. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97475,13 +133811,15 @@ var TextStyle = new Class({ }, /** - * [description] + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. * * @method Phaser.GameObjects.Text.TextStyle#setFixedSize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} width - The fixed width to set. + * @param {number} height - The fixed height to set. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97504,12 +133842,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the background color. * * @method Phaser.GameObjects.Text.TextStyle#setBackgroundColor * @since 3.0.0 * - * @param {string} color - [description] + * @param {string} color - The background color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97521,12 +133859,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the text fill color. * * @method Phaser.GameObjects.Text.TextStyle#setFill * @since 3.0.0 * - * @param {string} color - [description] + * @param {string} color - The text fill color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97538,12 +133876,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the text fill color. * * @method Phaser.GameObjects.Text.TextStyle#setColor * @since 3.0.0 * - * @param {string} color - [description] + * @param {string} color - The text fill color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97555,46 +133893,76 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the resolution used by the Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method. It allows for much clearer text on High DPI devices, + * at the cost of memory because it uses larger internal Canvas textures for the Text. + * + * Please use with caution, as the more high res Text you have, the more memory it uses up. + * + * @method Phaser.GameObjects.Text.TextStyle#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setResolution: function (value) + { + this.resolution = value; + + return this.update(false); + }, + + /** + * Set the stroke settings. * * @method Phaser.GameObjects.Text.TextStyle#setStroke * @since 3.0.0 * - * @param {string} color - [description] - * @param {number} thickness - [description] + * @param {string} color - The stroke color. + * @param {number} thickness - The stroke thickness. * * @return {Phaser.GameObjects.Text} The parent Text object. */ setStroke: function (color, thickness) { - if (color === undefined) + if (thickness === undefined) { thickness = this.strokeThickness; } + + if (color === undefined && this.strokeThickness !== 0) { // Reset the stroke to zero (disabling it) this.strokeThickness = 0; - } - else - { - if (thickness === undefined) { thickness = this.strokeThickness; } + this.update(true); + } + else if (this.stroke !== color || this.strokeThickness !== thickness) + { this.stroke = color; this.strokeThickness = thickness; + + this.update(true); } - return this.update(true); + return this.parent; }, /** - * [description] + * Set the shadow settings. + * + * Calling this method always re-measures the parent Text object, + * so only call it when you actually change the shadow settings. * * @method Phaser.GameObjects.Text.TextStyle#setShadow * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {string} [color='#000'] - [description] - * @param {number} [blur=0] - [description] - * @param {boolean} [shadowStroke=false] - [description] - * @param {boolean} [shadowFill=true] - [description] + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. + * @param {string} [color='#000'] - The shadow color. + * @param {number} [blur=0] - The shadow blur radius. + * @param {boolean} [shadowStroke=false] - Whether to stroke the shadow. + * @param {boolean} [shadowFill=true] - Whether to fill the shadow. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97618,13 +133986,13 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the shadow offset. * * @method Phaser.GameObjects.Text.TextStyle#setShadowOffset * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] + * @param {number} [x=0] - The horizontal shadow offset. + * @param {number} [y=0] - The vertical shadow offset. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97640,12 +134008,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the shadow color. * * @method Phaser.GameObjects.Text.TextStyle#setShadowColor * @since 3.0.0 * - * @param {string} [color='#000'] - [description] + * @param {string} [color='#000'] - The shadow color. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97659,12 +134027,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the shadow blur radius. * * @method Phaser.GameObjects.Text.TextStyle#setShadowBlur * @since 3.0.0 * - * @param {number} [blur=0] - [description] + * @param {number} [blur=0] - The shadow blur radius. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97678,12 +134046,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Enable or disable shadow stroke. * * @method Phaser.GameObjects.Text.TextStyle#setShadowStroke * @since 3.0.0 * - * @param {boolean} enabled - [description] + * @param {boolean} enabled - Whether shadow stroke is enabled or not. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97695,12 +134063,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Enable or disable shadow fill. * * @method Phaser.GameObjects.Text.TextStyle#setShadowFill * @since 3.0.0 * - * @param {boolean} enabled - [description] + * @param {boolean} enabled - Whether shadow fill is enabled or not. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97712,7 +134080,9 @@ var TextStyle = new Class({ }, /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. + * Set the width (in pixels) to use for wrapping lines. + * + * Pass in null to remove wrapping by width. * * @method Phaser.GameObjects.Text.TextStyle#setWordWrapWidth * @since 3.0.0 @@ -97735,7 +134105,9 @@ var TextStyle = new Class({ }, /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. + * Set a custom callback for wrapping lines. + * + * Pass in null to remove wrapping by callback. * * @method Phaser.GameObjects.Text.TextStyle#setWordWrapCallback * @since 3.0.0 @@ -97759,12 +134131,14 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. * * @method Phaser.GameObjects.Text.TextStyle#setAlign * @since 3.0.0 * - * @param {string} align - [description] + * @param {string} align - The text alignment. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97778,12 +134152,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Set the maximum number of lines to draw. * * @method Phaser.GameObjects.Text.TextStyle#setMaxLines * @since 3.0.0 * - * @param {integer} [max=0] - [description] + * @param {integer} [max=0] - The maximum number of lines to draw. * * @return {Phaser.GameObjects.Text} The parent Text object. */ @@ -97797,12 +134171,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Get the current text metrics. * * @method Phaser.GameObjects.Text.TextStyle#getTextMetrics * @since 3.0.0 * - * @return {object} [description] + * @return {BitmapTextMetrics} The text metrics. */ getTextMetrics: function () { @@ -97816,12 +134190,12 @@ var TextStyle = new Class({ }, /** - * [description] + * Build a JSON representation of this Text Style. * * @method Phaser.GameObjects.Text.TextStyle#toJSON * @since 3.0.0 * - * @return {object} [description] + * @return {object} A JSON representation of this Text Style. */ toJSON: function () { @@ -97838,7 +134212,7 @@ var TextStyle = new Class({ }, /** - * [description] + * Destroy this Text Style. * * @method Phaser.GameObjects.Text.TextStyle#destroy * @since 3.0.0 @@ -97854,8 +134228,8 @@ module.exports = TextStyle; /***/ }), -/* 414 */ -/***/ (function(module, exports, __webpack_require__) { +/* 808 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -97863,8 +134237,6 @@ module.exports = TextStyle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -97882,74 +134254,17 @@ var GameObject = __webpack_require__(2); */ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + if (src.text !== '') { - return; + renderer.batchSprite(src, src.frame, camera, parentMatrix); } - - var ctx = renderer.currentContext; - - // var resolution = src.resolution; - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var canvas = src.canvas; - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (renderer.config.roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - - ctx.translate(canvas.width * (src.flipX ? 1 : 0), canvas.height * (src.flipY ? 1 : 0)); - - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, -src.displayOriginX, -src.displayOriginY, canvas.width, canvas.height); - - ctx.restore(); }; module.exports = TextCanvasRenderer; /***/ }), -/* 415 */ +/* 809 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -97958,7 +134273,7 @@ module.exports = TextCanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); +var Utils = __webpack_require__(10); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -97977,25 +134292,44 @@ var GameObject = __webpack_require__(2); */ var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + if (src.text === '') { return; } - - if (src.dirty) - { - src.canvasTexture = renderer.canvasToTexture(src.canvas, src.canvasTexture); - src.dirty = false; - } - this.pipeline.batchText(this, camera, parentMatrix); + var frame = src.frame; + var width = frame.width; + var height = frame.height; + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + frame.glTexture, + width, height, + src.x, src.y, + width / src.style.resolution, height / src.style.resolution, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.displayOriginX, src.displayOriginY, + 0, 0, width, height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + 0, 0, + camera, + parentMatrix + ); }; module.exports = TextWebGLRenderer; /***/ }), -/* 416 */ +/* 810 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -98004,17 +134338,17 @@ module.exports = TextWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); if (true) { - renderWebGL = __webpack_require__(415); + renderWebGL = __webpack_require__(809); } if (true) { - renderCanvas = __webpack_require__(414); + renderCanvas = __webpack_require__(808); } module.exports = { @@ -98026,7 +134360,7 @@ module.exports = { /***/ }), -/* 417 */ +/* 811 */ /***/ (function(module, exports) { /** @@ -98041,9 +134375,9 @@ module.exports = { * @function Phaser.GameObjects.Text.GetTextSize * @since 3.0.0 * - * @param {Phaser.GameObjects.Text} text - The Text object to get the size from. - * @param {number} size - [description] - * @param {array} lines - [description] + * @param {Phaser.GameObjects.Text} text - The Text object to calculate the size from. + * @param {BitmapTextMetrics} size - The Text metrics to use when calculating the size. + * @param {array} lines - The lines of text to calculate the size from. * * @return {object} An object containing dimensions of the Text object. */ @@ -98056,7 +134390,7 @@ var GetTextSize = function (text, size, lines) var lineWidths = []; var maxLineWidth = 0; var drawnLines = lines.length; - + if (style.maxLines > 0 && style.maxLines < lines.length) { drawnLines = style.maxLines; @@ -98086,17 +134420,12 @@ var GetTextSize = function (text, size, lines) var lineHeight = size.fontSize + style.strokeThickness; var height = lineHeight * drawnLines; - var lineSpacing = text._lineSpacing || 0; - - if (lineSpacing < 0 && Math.abs(lineSpacing) > lineHeight) - { - lineSpacing = -lineHeight; - } + var lineSpacing = text.lineSpacing; // Adjust for line spacing - if (lineSpacing !== 0) + if (lines.length > 1) { - height += (lineSpacing > 0) ? lineSpacing * lines.length : lineSpacing * (lines.length - 1); + height += lineSpacing * (lines.length - 1); } return { @@ -98113,7 +134442,7 @@ module.exports = GetTextSize; /***/ }), -/* 418 */ +/* 812 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -98122,431 +134451,230 @@ module.exports = GetTextSize; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var GetBoolean = __webpack_require__(62); var GetValue = __webpack_require__(4); -var Sprite = __webpack_require__(34); -var TWEEN_CONST = __webpack_require__(61); -var Vector2 = __webpack_require__(6); /** - * @typedef {object} PathConfig + * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor + * and create a BitmapText object using a fixed-width retro font. * - * @property {number} duration - [description] - * @property {number} from - [description] - * @property {number} to - [description] - * @property {boolean} [positionOnPath=false] - [description] - * @property {boolean} [rotateToPath=false] - [description] - * @property {number} [rotationOffset=0] - [description] - * @property {boolean} [verticalAdjust=false] - [description] - */ - -/** - * @classdesc - * A PathFollower Game Object. - * - * A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically. - * - * Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it, - * scale it and so on. - * - * PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start - * to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate - * to face the direction of the path, be offset from the path coordinates or rotate independently of the Path. - * - * @class PathFollower - * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.GameObjects - * @constructor + * @function Phaser.GameObjects.RetroFont.Parse * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. - * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {Phaser.Scene} scene - A reference to the Phaser Scene. + * @param {Phaser.GameObjects.RetroFont.Config} config - The font configuration object. + * + * @return {object} A parsed Bitmap Font data entry for the Bitmap Font cache. */ -var PathFollower = new Class({ +var ParseRetroFont = function (scene, config) +{ + var w = config.width; + var h = config.height; + var cx = Math.floor(w / 2); + var cy = Math.floor(h / 2); + var letters = GetValue(config, 'chars', ''); - Extends: Sprite, - - initialize: - - function PathFollower (scene, path, x, y, texture, frame) + if (letters === '') { - Sprite.call(this, scene, x, y, texture, frame); + return; + } - /** - * The Path this PathFollower is following. It can only follow one Path at a time. - * - * @name Phaser.GameObjects.PathFollower#path - * @type {Phaser.Curves.Path} - * @since 3.0.0 - */ - this.path = path; + var key = GetValue(config, 'image', ''); + var offsetX = GetValue(config, 'offset.x', 0); + var offsetY = GetValue(config, 'offset.y', 0); + var spacingX = GetValue(config, 'spacing.x', 0); + var spacingY = GetValue(config, 'spacing.y', 0); + var lineSpacing = GetValue(config, 'lineSpacing', 0); - /** - * Should the PathFollower automatically rotate to point in the direction of the Path? - * - * @name Phaser.GameObjects.PathFollower#rotateToPath - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.rotateToPath = false; + var charsPerRow = GetValue(config, 'charsPerRow', null); - /** - * [description] - * - * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.pathRotationVerticalAdjust = false; - - /** - * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) - * this value is added to the rotation value. This allows you to rotate objects to a path but control - * the angle of the rotation as well. - * - * @name Phaser.GameObjects.PathFollower#pathRotationOffset - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.pathRotationOffset = 0; - - /** - * An additional vector to add to the PathFollowers position, allowing you to offset it from the - * Path coordinates. - * - * @name Phaser.GameObjects.PathFollower#pathOffset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.pathOffset = new Vector2(x, y); - - /** - * [description] - * - * @name Phaser.GameObjects.PathFollower#pathVector - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.pathVector = new Vector2(); - - /** - * [description] - * - * @name Phaser.GameObjects.PathFollower#pathTween - * @type {Phaser.Tweens.Tween} - * @since 3.0.0 - */ - this.pathTween; - - /** - * [description] - * - * @name Phaser.GameObjects.PathFollower#pathConfig - * @type {?PathConfig} - * @default null - * @since 3.0.0 - */ - this.pathConfig = null; - - /** - * Records the direction of the follower so it can change direction. - * - * @name Phaser.GameObjects.PathFollower#_prevDirection - * @type {integer} - * @private - * @since 3.0.0 - */ - this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.PathFollower#setPath - * @since 3.0.0 - * - * @param {Phaser.Curves.Path} path - The Path this PathFollower is following. It can only follow one Path at a time. - * @param {PathConfig} [config] - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - setPath: function (path, config) + if (charsPerRow === null) { - if (config === undefined) { config = this.pathConfig; } + charsPerRow = scene.sys.textures.getFrame(key).width / w; - var tween = this.pathTween; - - if (tween && tween.isPlaying()) + if (charsPerRow > letters.length) { - tween.stop(); - } - - this.path = path; - - if (config) - { - this.startFollow(config); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.PathFollower#setRotateToPath - * @since 3.0.0 - * - * @param {number} value - [description] - * @param {number} [offset=0] - Rotation offset in degrees. - * @param {boolean} [verticalAdjust=false] - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - setRotateToPath: function (value, offset, verticalAdjust) - { - if (offset === undefined) { offset = 0; } - if (verticalAdjust === undefined) { verticalAdjust = false; } - - this.rotateToPath = value; - - this.pathRotationOffset = offset; - this.pathRotationVerticalAdjust = verticalAdjust; - - return this; - }, - - /** - * Is this PathFollower actively following a Path or not? - * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. - * - * @method Phaser.GameObjects.PathFollower#isFollowing - * @since 3.0.0 - * - * @return {boolean} `true` is this PathFollower is actively following a Path, otherwise `false`. - */ - isFollowing: function () - { - var tween = this.pathTween; - - return (tween && tween.isPlaying()); - }, - - /** - * Starts this PathFollower following its given Path. - * - * @method Phaser.GameObjects.PathFollower#startFollow - * @since 3.3.0 - * - * @param {(number|PathConfig)} [config={}] - [description] - * @param {number} [startAt=0] - [description] - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - startFollow: function (config, startAt) - { - if (config === undefined) { config = {}; } - if (startAt === undefined) { startAt = 0; } - - var tween = this.pathTween; - - if (tween && tween.isPlaying()) - { - tween.stop(); - } - - if (typeof config === 'number') - { - config = { duration: config }; - } - - // Override in case they've been specified in the config - config.from = 0; - config.to = 1; - - // Can also read extra values out of the config: - - var positionOnPath = GetBoolean(config, 'positionOnPath', false); - - this.rotateToPath = GetBoolean(config, 'rotateToPath', false); - this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); - this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); - - this.pathTween = this.scene.sys.tweens.addCounter(config); - - // The starting point of the path, relative to this follower - this.path.getStartPoint(this.pathOffset); - - if (positionOnPath) - { - this.x = this.pathOffset.x; - this.y = this.pathOffset.y; - } - - this.pathOffset.x = this.x - this.pathOffset.x; - this.pathOffset.y = this.y - this.pathOffset.y; - - this._prevDirection = TWEEN_CONST.PLAYING_FORWARD; - - if (this.rotateToPath) - { - // Set the rotation now (in case the tween has a delay on it, etc) - var nextPoint = this.path.getPoint(0.1); - - this.rotation = Math.atan2(nextPoint.y - this.y, nextPoint.x - this.x) + DegToRad(this.pathRotationOffset); - } - - this.pathConfig = config; - - return this; - }, - - /** - * Pauses this PathFollower. It will still continue to render, but it will remain motionless at the - * point on the Path at which you paused it. - * - * @method Phaser.GameObjects.PathFollower#pauseFollow - * @since 3.3.0 - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - pauseFollow: function () - { - var tween = this.pathTween; - - if (tween && tween.isPlaying()) - { - tween.pause(); - } - - return this; - }, - - /** - * Resumes a previously paused PathFollower. - * If the PathFollower was not paused this has no effect. - * - * @method Phaser.GameObjects.PathFollower#resumeFollow - * @since 3.3.0 - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - resumeFollow: function () - { - var tween = this.pathTween; - - if (tween && tween.isPaused()) - { - tween.resume(); - } - - return this; - }, - - /** - * Stops this PathFollower from following the path any longer. - * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. - * - * @method Phaser.GameObjects.PathFollower#stopFollow - * @since 3.3.0 - * - * @return {Phaser.GameObjects.PathFollower} This Game Object. - */ - stopFollow: function () - { - var tween = this.pathTween; - - if (tween && tween.isPlaying()) - { - tween.stop(); - } - - return this; - }, - - /** - * Internal update handler that advances this PathFollower along the path. - * Called automatically by the Scene step, should not typically be called directly. - * - * @method Phaser.GameObjects.PathFollower#preUpdate - * @protected - * @since 3.0.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. - */ - preUpdate: function (time, delta) - { - this.anims.update(time, delta); - - var tween = this.pathTween; - - if (tween) - { - var tweenData = tween.data[0]; - - if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD) - { - // If delayed, etc then bail out - return; - } - - var pathVector = this.pathVector; - - this.path.getPoint(tween.getValue(), pathVector); - - pathVector.add(this.pathOffset); - - var oldX = this.x; - var oldY = this.y; - - this.setPosition(pathVector.x, pathVector.y); - - var speedX = this.x - oldX; - var speedY = this.y - oldY; - - if (speedX === 0 && speedY === 0) - { - // Bail out early - return; - } - - if (tweenData.state !== this._prevDirection) - { - // We've changed direction, so don't do a rotate this frame - this._prevDirection = tweenData.state; - - return; - } - - if (this.rotateToPath) - { - this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); - - if (this.pathRotationVerticalAdjust) - { - this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); - } - } + charsPerRow = letters.length; } } -}); + var x = offsetX; + var y = offsetY; -module.exports = PathFollower; + var data = { + retroFont: true, + font: key, + size: w, + lineHeight: h + lineSpacing, + chars: {} + }; + + var r = 0; + + for (var i = 0; i < letters.length; i++) + { + // var node = letters[i]; + + var charCode = letters.charCodeAt(i); + + data.chars[charCode] = + { + x: x, + y: y, + width: w, + height: h, + centerX: cx, + centerY: cy, + xOffset: 0, + yOffset: 0, + xAdvance: w, + data: {}, + kerning: {} + }; + + r++; + + if (r === charsPerRow) + { + r = 0; + x = offsetX; + y += h + spacingY; + } + else + { + x += w + spacingX; + } + } + + var entry = { + data: data, + frame: null, + texture: key + }; + + return entry; +}; + +module.exports = ParseRetroFont; /***/ }), -/* 419 */ +/* 813 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RETRO_FONT_CONST = { + + /** + * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET1 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET1: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', + + /** + * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET2 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET2: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET3 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET3: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ', + + /** + * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET4 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET4: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789', + + /** + * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET5 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET5: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789', + + /** + * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET6 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET6: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' ', + + /** + * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET7 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET7: 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39', + + /** + * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET8 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET8: '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET9 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET9: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!', + + /** + * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET10 + * @type {string} + * @since 3.6.0 + */ + TEXT_SET10: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + + /** + * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 + * + * @name Phaser.GameObjects.RetroFont.TEXT_SET11 + * @since 3.6.0 + * @type {string} + */ + TEXT_SET11: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789' + +}; + +module.exports = RETRO_FONT_CONST; + + +/***/ }), +/* 814 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -98555,4487 +134683,491 @@ module.exports = PathFollower; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @callback RandomZoneSourceCallback - * - * @param {Phaser.Math.Vector2} point - A point to modify. - */ - -/** - * @typedef {object} RandomZoneSource - * - * @property {RandomZoneSourceCallback} getRandomPoint - A function modifying its point argument. - * - * @see Phaser.Geom.Circle - * @see Phaser.Geom.Ellipse - * @see Phaser.Geom.Line - * @see Phaser.Geom.Polygon - * @see Phaser.Geom.Rectangle - * @see Phaser.Geom.Triangle - */ - -/** - * @classdesc - * A zone that places particles randomly within a shape's area. - * - * @class RandomZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor - * @since 3.0.0 - * - * @param {RandomZoneSource} source - An object instance with a `getRandomPoint(point)` method. - */ -var RandomZone = new Class({ - - initialize: - - function RandomZone (source) - { - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.RandomZone#source - * @type {RandomZoneSource} - * @since 3.0.0 - */ - this.source = source; - - /** - * Internal calculation vector. - * - * @name Phaser.GameObjects.Particles.Zones.RandomZone#_tempVec - * @type {Phaser.Math.Vector2} - * @private - * @since 3.0.0 - */ - this._tempVec = new Vector2(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.RandomZone#getPoint - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - */ - getPoint: function (particle) - { - var vec = this._tempVec; - - this.source.getRandomPoint(vec); - - particle.x = vec.x; - particle.y = vec.y; - } - -}); - -module.exports = RandomZone; - - -/***/ }), -/* 420 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Verifies that an object contains at least one of the requested keys - * - * @function Phaser.Utils.Object.HasAny - * @since 3.0.0 - * - * @param {object} source - an object on which to check for key existence - * @param {string[]} keys - an array of keys to search the object for - * - * @return {boolean} true if the source object contains at least one of the keys, false otherwise - */ -var HasAny = function (source, keys) -{ - for (var i = 0; i < keys.length; i++) - { - if (source.hasOwnProperty(keys[i])) - { - return true; - } - } - - return false; -}; - -module.exports = HasAny; - - -/***/ }), -/* 421 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Stepped easing. - * - * @function Phaser.Math.Easing.Stepped.Stepped - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [steps=1] - The number of steps in the ease. - * - * @return {number} The tweened value. - */ -var Stepped = function (v, steps) -{ - if (steps === undefined) { steps = 1; } - - if (v <= 0) - { - return 0; - } - else if (v >= 1) - { - return 1; - } - else - { - return (((steps * v) | 0) + 1) * (1 / steps); - } -}; - -module.exports = Stepped; - - -/***/ }), -/* 422 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sinusoidal ease-in/out. - * - * @function Phaser.Math.Easing.Sine.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 0.5 * (1 - Math.cos(Math.PI * v)); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 423 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sinusoidal ease-out. - * - * @function Phaser.Math.Easing.Sine.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return Math.sin(v * Math.PI / 2); - } -}; - -module.exports = Out; - - -/***/ }), -/* 424 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sinusoidal ease-in. - * - * @function Phaser.Math.Easing.Sine.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - return 1 - Math.cos(v * Math.PI / 2); - } -}; - -module.exports = In; - - -/***/ }), -/* 425 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quintic ease-in/out. - * - * @function Phaser.Math.Easing.Quintic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v * v * v + 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 426 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quintic ease-out. - * - * @function Phaser.Math.Easing.Quintic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return --v * v * v * v * v + 1; -}; - -module.exports = Out; - - -/***/ }), -/* 427 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quintic ease-in. - * - * @function Phaser.Math.Easing.Quintic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v * v * v * v; -}; - -module.exports = In; - - -/***/ }), -/* 428 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quartic ease-in/out. - * - * @function Phaser.Math.Easing.Quartic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v * v * v; - } - else - { - return -0.5 * ((v -= 2) * v * v * v - 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 429 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quartic ease-out. - * - * @function Phaser.Math.Easing.Quartic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return 1 - (--v * v * v * v); -}; - -module.exports = Out; - - -/***/ }), -/* 430 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quartic ease-in. - * - * @function Phaser.Math.Easing.Quartic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v * v * v; -}; - -module.exports = In; - - -/***/ }), -/* 431 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quadratic ease-in/out. - * - * @function Phaser.Math.Easing.Quadratic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v; - } - else - { - return -0.5 * (--v * (v - 2) - 1); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 432 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quadratic ease-out. - * - * @function Phaser.Math.Easing.Quadratic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return v * (2 - v); -}; - -module.exports = Out; - - -/***/ }), -/* 433 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Quadratic ease-in. - * - * @function Phaser.Math.Easing.Quadratic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v; -}; - -module.exports = In; - - -/***/ }), -/* 434 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Linear easing (no variation). - * - * @function Phaser.Math.Easing.Linear.Linear - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Linear = function (v) -{ - return v; -}; - -module.exports = Linear; - - -/***/ }), -/* 435 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Exponential ease-in/out. - * - * @function Phaser.Math.Easing.Expo.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * Math.pow(2, 10 * (v - 1)); - } - else - { - return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 436 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Exponential ease-out. - * - * @function Phaser.Math.Easing.Expo.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return 1 - Math.pow(2, -10 * v); -}; - -module.exports = Out; - - -/***/ }), -/* 437 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Exponential ease-in. - * - * @function Phaser.Math.Easing.Expo.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return Math.pow(2, 10 * (v - 1)) - 0.001; -}; - -module.exports = In; - - -/***/ }), -/* 438 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Elastic ease-in/out. - * - * @function Phaser.Math.Easing.Elastic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] - * - * @return {number} The tweened value. - */ -var InOut = function (v, amplitude, period) -{ - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } - - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; - - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - if ((v *= 2) < 1) - { - return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } - else - { - return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; - } - } -}; - -module.exports = InOut; - - -/***/ }), -/* 439 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Elastic ease-out. - * - * @function Phaser.Math.Easing.Elastic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] - * - * @return {number} The tweened value. - */ -var Out = function (v, amplitude, period) -{ - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } - - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; - - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); - } -}; - -module.exports = Out; - - -/***/ }), -/* 440 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Elastic ease-in. - * - * @function Phaser.Math.Easing.Elastic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] - * - * @return {number} The tweened value. - */ -var In = function (v, amplitude, period) -{ - if (amplitude === undefined) { amplitude = 0.1; } - if (period === undefined) { period = 0.1; } - - if (v === 0) - { - return 0; - } - else if (v === 1) - { - return 1; - } - else - { - var s = period / 4; - - if (amplitude < 1) - { - amplitude = 1; - } - else - { - s = period * Math.asin(1 / amplitude) / (2 * Math.PI); - } - - return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); - } -}; - -module.exports = In; - - -/***/ }), -/* 441 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Cubic ease-in/out. - * - * @function Phaser.Math.Easing.Cubic.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return 0.5 * v * v * v; - } - else - { - return 0.5 * ((v -= 2) * v * v + 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 442 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Cubic ease-out. - * - * @function Phaser.Math.Easing.Cubic.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return --v * v * v + 1; -}; - -module.exports = Out; - - -/***/ }), -/* 443 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Cubic ease-in. - * - * @function Phaser.Math.Easing.Cubic.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return v * v * v; -}; - -module.exports = In; - - -/***/ }), -/* 444 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Circular ease-in/out. - * - * @function Phaser.Math.Easing.Circular.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - if ((v *= 2) < 1) - { - return -0.5 * (Math.sqrt(1 - v * v) - 1); - } - else - { - return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 445 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Circular ease-out. - * - * @function Phaser.Math.Easing.Circular.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - return Math.sqrt(1 - (--v * v)); -}; - -module.exports = Out; - - -/***/ }), -/* 446 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Circular ease-in. - * - * @function Phaser.Math.Easing.Circular.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - return 1 - Math.sqrt(1 - v * v); -}; - -module.exports = In; - - -/***/ }), -/* 447 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Bounce ease-in/out. - * - * @function Phaser.Math.Easing.Bounce.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var InOut = function (v) -{ - var reverse = false; - - if (v < 0.5) - { - v = 1 - (v * 2); - reverse = true; - } - else - { - v = (v * 2) - 1; - } - - if (v < 1 / 2.75) - { - v = 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } - - if (reverse) - { - return (1 - v) * 0.5; - } - else - { - return v * 0.5 + 0.5; - } -}; - -module.exports = InOut; - - -/***/ }), -/* 448 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Bounce ease-out. - * - * @function Phaser.Math.Easing.Bounce.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var Out = function (v) -{ - if (v < 1 / 2.75) - { - return 7.5625 * v * v; - } - else if (v < 2 / 2.75) - { - return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; - } - else if (v < 2.5 / 2.75) - { - return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; - } - else - { - return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; - } -}; - -module.exports = Out; - - -/***/ }), -/* 449 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Bounce ease-in. - * - * @function Phaser.Math.Easing.Bounce.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * - * @return {number} The tweened value. - */ -var In = function (v) -{ - v = 1 - v; - - if (v < 1 / 2.75) - { - return 1 - (7.5625 * v * v); - } - else if (v < 2 / 2.75) - { - return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); - } - else if (v < 2.5 / 2.75) - { - return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); - } - else - { - return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); - } -}; - -module.exports = In; - - -/***/ }), -/* 450 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Back ease-in/out. - * - * @function Phaser.Math.Easing.Back.InOut - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [overshoot=1.70158] - The overshoot amount. - * - * @return {number} The tweened value. - */ -var InOut = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } - - var s = overshoot * 1.525; - - if ((v *= 2) < 1) - { - return 0.5 * (v * v * ((s + 1) * v - s)); - } - else - { - return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); - } -}; - -module.exports = InOut; - - -/***/ }), -/* 451 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Back ease-out. - * - * @function Phaser.Math.Easing.Back.Out - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [overshoot=1.70158] - The overshoot amount. - * - * @return {number} The tweened value. - */ -var Out = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } - - return --v * v * ((overshoot + 1) * v + overshoot) + 1; -}; - -module.exports = Out; - - -/***/ }), -/* 452 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Back ease-in. - * - * @function Phaser.Math.Easing.Back.In - * @since 3.0.0 - * - * @param {number} v - The value to be tweened. - * @param {number} [overshoot=1.70158] - The overshoot amount. - * - * @return {number} The tweened value. - */ -var In = function (v, overshoot) -{ - if (overshoot === undefined) { overshoot = 1.70158; } - - return v * v * ((overshoot + 1) * v - overshoot); -}; - -module.exports = In; - - -/***/ }), -/* 453 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Back = __webpack_require__(247); -var Bounce = __webpack_require__(246); -var Circular = __webpack_require__(245); -var Cubic = __webpack_require__(244); -var Elastic = __webpack_require__(243); -var Expo = __webpack_require__(242); -var Linear = __webpack_require__(241); -var Quadratic = __webpack_require__(240); -var Quartic = __webpack_require__(239); -var Quintic = __webpack_require__(238); -var Sine = __webpack_require__(237); -var Stepped = __webpack_require__(236); - -// EaseMap -module.exports = { - - Power0: Linear, - Power1: Quadratic.Out, - Power2: Cubic.Out, - Power3: Quartic.Out, - Power4: Quintic.Out, - - Linear: Linear, - Quad: Quadratic.Out, - Cubic: Cubic.Out, - Quart: Quartic.Out, - Quint: Quintic.Out, - Sine: Sine.Out, - Expo: Expo.Out, - Circ: Circular.Out, - Elastic: Elastic.Out, - Back: Back.Out, - Bounce: Bounce.Out, - Stepped: Stepped, - - 'Quad.easeIn': Quadratic.In, - 'Cubic.easeIn': Cubic.In, - 'Quart.easeIn': Quartic.In, - 'Quint.easeIn': Quintic.In, - 'Sine.easeIn': Sine.In, - 'Expo.easeIn': Expo.In, - 'Circ.easeIn': Circular.In, - 'Elastic.easeIn': Elastic.In, - 'Back.easeIn': Back.In, - 'Bounce.easeIn': Bounce.In, - - 'Quad.easeOut': Quadratic.Out, - 'Cubic.easeOut': Cubic.Out, - 'Quart.easeOut': Quartic.Out, - 'Quint.easeOut': Quintic.Out, - 'Sine.easeOut': Sine.Out, - 'Expo.easeOut': Expo.Out, - 'Circ.easeOut': Circular.Out, - 'Elastic.easeOut': Elastic.Out, - 'Back.easeOut': Back.Out, - 'Bounce.easeOut': Bounce.Out, - - 'Quad.easeInOut': Quadratic.InOut, - 'Cubic.easeInOut': Cubic.InOut, - 'Quart.easeInOut': Quartic.InOut, - 'Quint.easeInOut': Quintic.InOut, - 'Sine.easeInOut': Sine.InOut, - 'Expo.easeInOut': Expo.InOut, - 'Circ.easeInOut': Circular.InOut, - 'Elastic.easeInOut': Elastic.InOut, - 'Back.easeInOut': Back.InOut, - 'Bounce.easeInOut': Bounce.InOut - -}; - - -/***/ }), -/* 454 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback EdgeZoneSourceCallback - * - * @param {integer} quantity - [description] - * @param {integer} [stepRate] - [description] - * - * @return {Phaser.Geom.Point[]} - [description] - */ - -/** - * @typedef {object} EdgeZoneSource - * - * @property {EdgeZoneSourceCallback} getPoints - A function placing points on the source's edge or edges. - * - * @see Phaser.Curves.Curve - * @see Phaser.Curves.Path - * @see Phaser.Geom.Circle - * @see Phaser.Geom.Ellipse - * @see Phaser.Geom.Line - * @see Phaser.Geom.Polygon - * @see Phaser.Geom.Rectangle - * @see Phaser.Geom.Triangle - */ - -/** - * @classdesc - * A zone that places particles on a shape's edges. - * - * @class EdgeZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor - * @since 3.0.0 - * - * @param {EdgeZoneSource} source - An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. - * @param {number} quantity - [description] - * @param {number} stepRate - [description] - * @param {boolean} [yoyo=false] - [description] - * @param {boolean} [seamless=true] - [description] - */ -var EdgeZone = new Class({ - - initialize: - - function EdgeZone (source, quantity, stepRate, yoyo, seamless) - { - if (yoyo === undefined) { yoyo = false; } - if (seamless === undefined) { seamless = true; } - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#source - * @type {EdgeZoneSource|RandomZoneSource} - * @since 3.0.0 - */ - this.source = source; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#points - * @type {Phaser.Geom.Point[]} - * @default [] - * @since 3.0.0 - */ - this.points = []; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#quantity - * @type {number} - * @since 3.0.0 - */ - this.quantity = quantity; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#stepRate - * @type {number} - * @since 3.0.0 - */ - this.stepRate = stepRate; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#yoyo - * @type {boolean} - * @since 3.0.0 - */ - this.yoyo = yoyo; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#counter - * @type {number} - * @default -1 - * @since 3.0.0 - */ - this.counter = -1; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#seamless - * @type {boolean} - * @since 3.0.0 - */ - this.seamless = seamless; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_length - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._length = 0; - - /** - * 0 = forwards, 1 = backwards - * - * @name Phaser.GameObjects.Particles.Zones.EdgeZone#_direction - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._direction = 0; - - this.updateSource(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#updateSource - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. - */ - updateSource: function () - { - this.points = this.source.getPoints(this.quantity, this.stepRate); - - // Remove ends? - if (this.seamless) - { - var a = this.points[0]; - var b = this.points[this.points.length - 1]; - - if (a.x === b.x && a.y === b.y) - { - this.points.pop(); - } - } - - var oldLength = this._length; - - this._length = this.points.length; - - // Adjust counter if we now have less points than before - if (this._length < oldLength && this.counter > this._length) - { - this.counter = this._length - 1; - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#changeSource - * @since 3.0.0 - * - * @param {object} source - [description] - * - * @return {Phaser.GameObjects.Particles.Zones.EdgeZone} This Edge Zone. - */ - changeSource: function (source) - { - this.source = source; - - return this.updateSource(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.Zones.EdgeZone#getPoint - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - */ - getPoint: function (particle) - { - if (this._direction === 0) - { - this.counter++; - - if (this.counter >= this._length) - { - if (this.yoyo) - { - this._direction = 1; - this.counter = this._length - 1; - } - else - { - this.counter = 0; - } - } - } - else - { - this.counter--; - - if (this.counter === -1) - { - if (this.yoyo) - { - this._direction = 0; - this.counter = 0; - } - else - { - this.counter = this._length - 1; - } - } - } - - var point = this.points[this.counter]; - - if (point) - { - particle.x = point.x; - particle.y = point.y; - } - } - -}); - -module.exports = EdgeZone; - - -/***/ }), -/* 455 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @callback DeathZoneSourceCallback - * - * @param {float} x - [description] - * @param {float} y - [description] - * - * @return {boolean} - True if the coordinates are within the source area. - */ - -/** - * @typedef {object} DeathZoneSource - * - * @property {DeathZoneSourceCallback} contains - * - * @see Phaser.Geom.Circle - * @see Phaser.Geom.Ellipse - * @see Phaser.Geom.Polygon - * @see Phaser.Geom.Rectangle - * @see Phaser.Geom.Triangle - */ - -/** - * @classdesc - * A Death Zone. - * - * A Death Zone is a special type of zone that will kill a Particle as soon as it either enters, or leaves, the zone. - * - * The zone consists of a `source` which could be a Geometric shape, such as a Rectangle or Ellipse, or your own - * object as long as it includes a `contains` method for which the Particles can be tested against. - * - * @class DeathZone - * @memberOf Phaser.GameObjects.Particles.Zones - * @constructor - * @since 3.0.0 - * - * @param {DeathZoneSource} source - An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * @param {boolean} killOnEnter - Should the Particle be killed when it enters the zone? `true` or leaves it? `false` - */ -var DeathZone = new Class({ - - initialize: - - function DeathZone (source, killOnEnter) - { - /** - * An object instance that has a `contains` method that returns a boolean when given `x` and `y` arguments. - * This could be a Geometry shape, such as `Phaser.Geom.Circle`, or your own custom object. - * - * @name Phaser.GameObjects.Particles.Zones.DeathZone#source - * @type {DeathZoneSource} - * @since 3.0.0 - */ - this.source = source; - - /** - * Set to `true` if the Particle should be killed if it enters this zone. - * Set to `false` to kill the Particle if it leaves this zone. - * - * @name Phaser.GameObjects.Particles.Zones.DeathZone#killOnEnter - * @type {boolean} - * @since 3.0.0 - */ - this.killOnEnter = killOnEnter; - }, - - /** - * Checks if the given Particle will be killed or not by this zone. - * - * @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to be checked against this zone. - * - * @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`. - */ - willKill: function (particle) - { - var withinZone = this.source.contains(particle.x, particle.y); - - return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter); - } - -}); - -module.exports = DeathZone; - - -/***/ }), -/* 456 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlendModes = __webpack_require__(51); -var Class = __webpack_require__(0); -var Components = __webpack_require__(15); -var DeathZone = __webpack_require__(455); -var EdgeZone = __webpack_require__(454); -var EmitterOp = __webpack_require__(899); -var GetFastValue = __webpack_require__(1); -var GetRandom = __webpack_require__(146); -var HasAny = __webpack_require__(420); -var HasValue = __webpack_require__(111); -var Particle = __webpack_require__(457); -var RandomZone = __webpack_require__(419); -var Rectangle = __webpack_require__(14); -var StableSort = __webpack_require__(83); -var Vector2 = __webpack_require__(6); -var Wrap = __webpack_require__(39); - -/** - * @callback ParticleEmitterCallback - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The particle associated with the call. - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - This particle emitter associated with the call. - */ - -/** - * @callback ParticleDeathCallback - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The particle that died. +var RETRO_FONT_CONST = __webpack_require__(813); +var Extend = __webpack_require__(20); + +/** + * @typedef {object} Phaser.GameObjects.RetroFont.Config + * + * @property {string} image - The key of the image containing the font. + * @property {number} offset.x - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. + * @property {number} offset.y - If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. + * @property {number} width - The width of each character in the font set. + * @property {number} height - The height of each character in the font set. + * @property {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. + * @property {number} charsPerRow - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. + * @property {number} spacing.x - If the characters in the font set have horizontal spacing between them set the required amount here. + * @property {number} spacing.y - If the characters in the font set have vertical spacing between them set the required amount here. + * @property {number} lineSpacing - The amount of vertical space to add to the line height of the font. */ /** - * @typedef {object} ParticleEmitterBounds - * - * @property {float} x - The left edge of the rectangle. - * @property {float} y - The top edge of the rectangle. - * @property {float} width - The width of the rectangle. - * @property {float} height - The height of the rectangle. - * - * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + * @namespace Phaser.GameObjects.RetroFont + * @since 3.6.0 + */ + +var RetroFont = { Parse: __webpack_require__(812) }; + +// Merge in the consts +RetroFont = Extend(false, RetroFont, RETRO_FONT_CONST); + +module.exports = RetroFont; + + +/***/ }), +/* 815 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * @typedef {object} ParticleEmitterBoundsAlt + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @property {float} x - The left edge of the rectangle. - * @property {float} y - The top edge of the rectangle. - * @property {float} w - The width of the rectangle. - * @property {float} h - The height of the rectangle. + * @method Phaser.GameObjects.RenderTexture#renderCanvas + * @since 3.2.0 + * @private * - * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RenderTextureCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = RenderTextureCanvasRenderer; + + +/***/ }), +/* 816 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.RenderTexture#renderWebGL + * @since 3.2.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RenderTextureWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var frame = src.frame; + var width = frame.width; + var height = frame.height; + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + frame.glTexture, + width, height, + src.x, src.y, + width, height, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, !src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.displayOriginX, src.displayOriginY, + 0, 0, width, height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + 0, 0, + camera, + parentMatrix + ); + + // Force clear the current texture so that items next in the batch (like Graphics) don't try and use it + renderer.setBlankTexture(true); +}; + +module.exports = RenderTextureWebGLRenderer; + + +/***/ }), +/* 817 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(816); +} + +if (true) +{ + renderCanvas = __webpack_require__(815); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 818 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * @typedef {object} ParticleEmitterDeathZoneConfig - * - * @property {DeathZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.DeathZone#source}. - * @property {string} [type='onEnter'] - 'onEnter' or 'onLeave'. + * @namespace Phaser.GameObjects.Particles.Zones + */ + +module.exports = { + + DeathZone: __webpack_require__(301), + EdgeZone: __webpack_require__(300), + RandomZone: __webpack_require__(297) + +}; + + +/***/ }), +/* 819 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * @typedef {object} ParticleEmitterEdgeZoneConfig + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @property {EdgeZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. - * @property {string} type - 'edge'. - * @property {integer} quantity - The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. - * @property {float} [stepRate] - The distance between each particle. When set, `quantity` is implied and should be set to 0. - * @property {boolean} [yoyo=false] - Whether particles are placed from start to end and then end to start. - * @property {boolean} [seamless=true] - Whether one endpoint will be removed if it's identical to the other. - */ - -/** - * @typedef {object} ParticleEmitterRandomZoneConfig - * - * @property {RandomZoneSource} source - A shape representing the zone. See {@link Phaser.GameObjects.Particles.Zones.RandomZone#source}. - * @property {string} [type] - 'random'. - */ - -/** - * @typedef {object} ParticleEmitterConfig - * - * @property {boolean} [active] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#active}. - * @property {integer} [blendMode] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#blendMode}. - * @property {*} [callbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope} and {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. - * @property {boolean} [collideBottom] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideBottom}. - * @property {boolean} [collideLeft] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideLeft}. - * @property {boolean} [collideRight] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideRight}. - * @property {boolean} [collideTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#collideTop}. - * @property {boolean} [deathCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. - * @property {*} [deathCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope}. - * @property {function} [emitCallback] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. - * @property {*} [emitCallbackScope] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. - * @property {Phaser.GameObjects.GameObject} [follow] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#follow}. - * @property {float} [frequency] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency}. - * @property {float} [gravityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityX}. - * @property {float} [gravityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#gravityY}. - * @property {integer} [maxParticles] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxParticles}. - * @property {string} [name] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#name}. - * @property {boolean} [on] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#on}. - * @property {boolean} [particleBringToTop] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop}. - * @property {Phaser.GameObjects.Particles.Particle} [particleClass] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleClass}. - * @property {boolean} [radial] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#radial}. - * @property {float} [timeScale] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#timeScale}. - * @property {boolean} [trackVisible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#trackVisible}. - * @property {boolean} [visible] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#visible}. - * @property {float|float[]|EmitterOpOnEmitCallback|object} [accelerationX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationX} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [accelerationY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#accelerationY} (emit only). - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [alpha] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#alpha}. - * @property {float|float[]|EmitterOpOnEmitCallback|object} [angle] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#angle} (emit only) - * @property {float|float[]|EmitterOpOnEmitCallback|object} [bounce] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#bounce} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [delay] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#delay} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [lifespan] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#lifespan} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [maxVelocityX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [maxVelocityY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [moveToX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToX} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [moveToY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#moveToY} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [quantity] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity} (emit only). - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [rotate] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#rotate}. - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [scale] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setScale}. - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [scaleX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleX}. - * @property {float|float[]|EmitterOpOnUpdateCallback|object} [scaleY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#scaleY}. - * @property {float|float[]|EmitterOpOnEmitCallback|object} [speed] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setSpeed} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [speedX] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedX} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [speedY] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#speedY} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [tint] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#tint}. - * @property {float|float[]|EmitterOpOnEmitCallback|object} [x] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#x} (emit only). - * @property {float|float[]|EmitterOpOnEmitCallback|object} [y] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#y} (emit only). - * @property {object} [emitZone] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone}. - * @property {ParticleEmitterBounds|ParticleEmitterBoundsAlt} [bounds] - As {@link Phaser.GameObjects.Particles.ParticleEmitter#setBounds}. - * @property {object} [followOffset] - Assigns to {@link Phaser.GameObjects.Particles.ParticleEmitter#followOffset}. - * @property {float} [followOffset.x] - x-coordinate of the offset. - * @property {float} [followOffset.y] - y-coordinate of the offset. - * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]|ParticleEmitterFrameConfig} [frames] - Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. - */ - -/** - * @typedef {object} ParticleEmitterFrameConfig - * - * @property {number|number[]|string|string[]|Phaser.Textures.Frame|Phaser.Textures.Frame[]} [frames] - One or more texture frames. - * @property {boolean} [cycle] - Whether texture frames will be assigned consecutively (true) or at random (false). - * @property {integer} [quantity] - The number of consecutive particles receiving each texture frame, when `cycle` is true. - */ - -/** - * @classdesc - * A particle emitter represents a single particle stream. - * It controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles} and is controlled by a {@link Phaser.GameObjects.Particles.ParticleEmitterManager Particle Emitter Manager}. - * - * @class ParticleEmitter - * @memberOf Phaser.GameObjects.Particles - * @constructor + * @method Phaser.GameObjects.Particles.EmitterManager#renderCanvas * @since 3.0.0 + * @private * - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Visible - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} manager - The Emitter Manager this Emitter belongs to. - * @param {ParticleEmitterConfig} config - Settings for this emitter. + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var ParticleEmitter = new Class({ +var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) +{ + var emitters = emitterManager.emitters.list; + var emittersLength = emitters.length; - Mixins: [ - Components.BlendMode, - Components.Mask, - Components.ScrollFactor, - Components.Visible - ], - - initialize: - - function ParticleEmitter (manager, config) + if (emittersLength === 0) { - /** - * The Emitter Manager this Emitter belongs to. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#manager - * @type {Phaser.GameObjects.Particles.ParticleEmitterManager} - * @since 3.0.0 - */ - this.manager = manager; + return; + } - /** - * The texture assigned to particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#texture - * @type {Phaser.Textures.Texture} - * @since 3.0.0 - */ - this.texture = manager.texture; + var camMatrix = renderer._tempMatrix1.copyFrom(camera.matrix); + var calcMatrix = renderer._tempMatrix2; + var particleMatrix = renderer._tempMatrix3; + var managerMatrix = renderer._tempMatrix4.applyITRS(emitterManager.x, emitterManager.y, emitterManager.rotation, emitterManager.scaleX, emitterManager.scaleY); - /** - * The texture frames assigned to particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frames - * @type {Phaser.Textures.Frame[]} - * @since 3.0.0 - */ - this.frames = [ manager.defaultFrame ]; + camMatrix.multiply(managerMatrix); - /** - * The default texture frame assigned to particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#defaultFrame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - this.defaultFrame = manager.defaultFrame; + var roundPixels = camera.roundPixels; - /** - * Names of simple configuration properties. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#configFastMap - * @type {object} - * @since 3.0.0 - */ - this.configFastMap = [ - 'active', - 'blendMode', - 'collideBottom', - 'collideLeft', - 'collideRight', - 'collideTop', - 'deathCallback', - 'deathCallbackScope', - 'emitCallback', - 'emitCallbackScope', - 'follow', - 'frequency', - 'gravityX', - 'gravityY', - 'maxParticles', - 'name', - 'on', - 'particleBringToTop', - 'particleClass', - 'radial', - 'timeScale', - 'trackVisible', - 'visible' - ]; + var ctx = renderer.currentContext; - /** - * Names of complex configuration properties. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#configOpMap - * @type {object} - * @since 3.0.0 - */ - this.configOpMap = [ - 'accelerationX', - 'accelerationY', - 'angle', - 'alpha', - 'bounce', - 'delay', - 'lifespan', - 'maxVelocityX', - 'maxVelocityY', - 'moveToX', - 'moveToY', - 'quantity', - 'rotate', - 'scaleX', - 'scaleY', - 'speedX', - 'speedY', - 'tint', - 'x', - 'y' - ]; + ctx.save(); - /** - * The name of this Particle Emitter. - * - * Empty by default and never populated by Phaser, this is left for developers to use. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The Particle Class which will be emitted by this Emitter. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#particleClass - * @type {Phaser.GameObjects.Particles.Particle} - * @default Phaser.GameObjects.Particles.Particle - * @since 3.0.0 - */ - this.particleClass = Particle; - - /** - * The x-coordinate of the particle origin (where particles will be emitted). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#x - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition - */ - this.x = new EmitterOp(config, 'x', 0); - - /** - * The y-coordinate of the particle origin (where particles will be emitted). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#y - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setPosition - */ - this.y = new EmitterOp(config, 'y', 0); - - /** - * A radial emitter will emit particles in all directions between angle min and max, - * using {@link Phaser.GameObjects.Particles.ParticleEmitter#speed} as the value. If set to false then this acts as a point Emitter. - * A point emitter will emit particles only in the direction derived from the speedX and speedY values. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#radial - * @type {boolean} - * @default true - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setRadial - */ - this.radial = true; - - /** - * Horizontal acceleration applied to emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityX - * @type {float} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity - */ - this.gravityX = 0; - - /** - * Vertical acceleration applied to emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#gravityY - * @type {float} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setGravity - */ - this.gravityY = 0; - - /** - * Whether accelerationX and accelerationY are nonzero. Set automatically during configuration. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#acceleration - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.acceleration = false; - - /** - * Horizontal acceleration applied to emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.accelerationX = new EmitterOp(config, 'accelerationX', 0, true); - - /** - * Vertical acceleration applied to emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#accelerationY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.accelerationY = new EmitterOp(config, 'accelerationY', 0, true); - - /** - * The maximum horizontal velocity of emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityX = new EmitterOp(config, 'maxVelocityX', 10000, true); - - /** - * The maximum vertical velocity of emitted particles, in pixels per second squared. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxVelocityY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityY = new EmitterOp(config, 'maxVelocityY', 10000, true); - - /** - * The initial horizontal speed of emitted particles, in pixels per second. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#speedX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX - */ - this.speedX = new EmitterOp(config, 'speedX', 0, true); - - /** - * The initial vertical speed of emitted particles, in pixels per second. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#speedY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY - */ - this.speedY = new EmitterOp(config, 'speedY', 0, true); - - /** - * Whether moveToX and moveToY are nonzero. Set automatically during configuration. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveTo - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.moveTo = false; - - /** - * The x-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.moveToX = new EmitterOp(config, 'moveToX', 0, true); - - /** - * The y-coordinate emitted particles move toward, when {@link Phaser.GameObjects.Particles.ParticleEmitter#moveTo} is true. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#moveToY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.moveToY = new EmitterOp(config, 'moveToY', 0, true); - - /** - * Whether particles will rebound when they meet the emitter bounds. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#bounce - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.bounce = new EmitterOp(config, 'bounce', 0, true); - - /** - * The horizontal scale of emitted particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleX - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale - * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleX - */ - this.scaleX = new EmitterOp(config, 'scaleX', 1); - - /** - * The vertical scale of emitted particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#scaleY - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setScale - * @see Phaser.GameObjects.Particles.ParticleEmitter#setScaleY - */ - this.scaleY = new EmitterOp(config, 'scaleY', 1); - - /** - * Color tint applied to emitted particles. Any alpha component (0xAA000000) is ignored. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#tint - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0xffffffff - * @since 3.0.0 - */ - this.tint = new EmitterOp(config, 'tint', 0xffffffff); - - /** - * The alpha (transparency) of emitted particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#alpha - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setAlpha - */ - this.alpha = new EmitterOp(config, 'alpha', 1); - - /** - * The lifespan of emitted particles, in ms. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#lifespan - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1000 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setLifespan - */ - this.lifespan = new EmitterOp(config, 'lifespan', 1000); - - /** - * The angle of the initial velocity of emitted particles, in degrees. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#angle - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default { min: 0, max: 360 } - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setAngle - */ - this.angle = new EmitterOp(config, 'angle', { min: 0, max: 360 }); - - /** - * The rotation of emitted particles, in degrees. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#rotate - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.rotate = new EmitterOp(config, 'rotate', 0); - - /** - * A function to call when a particle is emitted. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallback - * @type {?ParticleEmitterCallback} - * @default null - * @since 3.0.0 - */ - this.emitCallback = null; - - /** - * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallback}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope - * @type {?*} - * @default null - * @since 3.0.0 - */ - this.emitCallbackScope = null; - - /** - * A function to call when a particle dies. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallback - * @type {?ParticleDeathCallback} - * @default null - * @since 3.0.0 - */ - this.deathCallback = null; - - /** - * The calling context for {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallback}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope - * @type {?*} - * @default null - * @since 3.0.0 - */ - this.deathCallbackScope = null; - - /** - * Set to hard limit the amount of particle objects this emitter is allowed to create. - * 0 means unlimited. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#maxParticles - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.maxParticles = 0; - - /** - * How many particles are emitted each time particles are emitted (one explosion or one flow cycle). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#quantity - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency - * @see Phaser.GameObjects.Particles.ParticleEmitter#setQuantity - */ - this.quantity = new EmitterOp(config, 'quantity', 1, true); - - /** - * How many ms to wait after emission before the particles start updating. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#delay - * @type {Phaser.GameObjects.Particles.EmitterOp} - * @default 0 - * @since 3.0.0 - */ - this.delay = new EmitterOp(config, 'delay', 0, true); - - /** - * For a flow emitter, the time interval (>= 0) between particle flow cycles in ms. - * A value of 0 means there is one particle flow cycle for each logic update (the maximum flow frequency). This is the default setting. - * For an exploding emitter, this value will be -1. - * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} also puts the emitter in flow mode (frequency >= 0). - * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency - * @type {float} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency - */ - this.frequency = 0; - - /** - * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). - * Already alive particles will continue to update until they expire. - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#on - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.on = true; - - /** - * Newly emitted particles are added to the top of the particle list, i.e. rendered above those already alive. - * Set to false to send them to the back. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#particleBringToTop - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.particleBringToTop = true; - - /** - * The time rate applied to active particles, affecting lifespan, movement, and tweens. Values larger than 1 are faster than normal. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#timeScale - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.timeScale = 1; - - /** - * An object describing a shape to emit particles from. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#emitZone - * @type {?Phaser.GameObjects.Particles.Zones.EdgeZone|Phaser.GameObjects.Particles.Zones.RandomZone} - * @default null - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone - */ - this.emitZone = null; - - /** - * An object describing a shape that deactivates particles when they interact with it. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#deathZone - * @type {?Phaser.GameObjects.Particles.Zones.DeathZone} - * @default null - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone - */ - this.deathZone = null; - - /** - * A rectangular boundary constraining particle movement. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#bounds - * @type {?Phaser.Geom.Rectangle} - * @default null - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setBounds - */ - this.bounds = null; - - /** - * Whether particles interact with the left edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideLeft - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideLeft = true; - - /** - * Whether particles interact with the right edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideRight - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideRight = true; - - /** - * Whether particles interact with the top edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideTop - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideTop = true; - - /** - * Whether particles interact with the bottom edge of the emitter {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#collideBottom - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.collideBottom = true; - - /** - * Whether this emitter updates itself and its particles. - * - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#pause} - * and {@link Phaser.GameObjects.Particles.ParticleEmitter#resume}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#active - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.active = true; - - /** - * Set this to false to hide any active particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#visible - * @type {boolean} - * @default true - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setVisible - */ - this.visible = true; - - /** - * The blend mode of this emitter's particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#blendMode - * @type {integer} - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setBlendMode - */ - this.blendMode = BlendModes.NORMAL; - - /** - * A Game Object whose position is used as the particle origin. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#follow - * @type {?Phaser.GameObjects.GameObject} - * @default null - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow - * @see Phaser.GameObjects.Particles.ParticleEmitter#stopFollow - */ - this.follow = null; - - /** - * The offset of the particle origin from the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#followOffset - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow - */ - this.followOffset = new Vector2(); - - /** - * Whether the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#visible} state will track - * the {@link Phaser.GameObjects.Particles.ParticleEmitter#follow} target's visibility state. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#trackVisible - * @type {boolean} - * @default false - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#startFollow - */ - this.trackVisible = false; - - /** - * The current texture frame, as an index of {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#currentFrame - * @type {integer} - * @default 0 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame - */ - this.currentFrame = 0; - - /** - * Whether texture {@link Phaser.GameObjects.Particles.ParticleEmitter#frames} are selected at random. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#randomFrame - * @type {boolean} - * @default true - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame - */ - this.randomFrame = true; - - /** - * The number of consecutive particles that receive a single texture frame (per frame cycle). - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity - * @type {integer} - * @default 1 - * @since 3.0.0 - * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrame - */ - this.frameQuantity = 1; - - /** - * Inactive particles. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#dead - * @type {Phaser.GameObjects.Particles.Particle[]} - * @private - * @since 3.0.0 - */ - this.dead = []; - - /** - * Active particles - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#alive - * @type {Phaser.GameObjects.Particles.Particle[]} - * @private - * @since 3.0.0 - */ - this.alive = []; - - /** - * The time until the next flow cycle. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#_counter - * @type {float} - * @private - * @default 0 - * @since 3.0.0 - */ - this._counter = 0; - - /** - * Counts up to {@link Phaser.GameObjects.Particles.ParticleEmitter#frameQuantity}. - * - * @name Phaser.GameObjects.Particles.ParticleEmitter#_frameCounter - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._frameCounter = 0; - - if (config) - { - this.fromJSON(config); - } - }, - - /** - * Merges configuration settings into the emitter's current settings. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#fromJSON - * @since 3.0.0 - * - * @param {ParticleEmitterConfig} config - Settings for this emitter. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - fromJSON: function (config) + for (var e = 0; e < emittersLength; e++) { - if (!config) + var emitter = emitters[e]; + var particles = emitter.alive; + var particleCount = particles.length; + + if (!emitter.visible || particleCount === 0) { - return this; + continue; } - // Only update properties from their current state if they exist in the given config + var scrollX = camera.scrollX * emitter.scrollFactorX; + var scrollY = camera.scrollY * emitter.scrollFactorY; - var i = 0; - var key = ''; - - for (i = 0; i < this.configFastMap.length; i++) + if (parentMatrix) { - key = this.configFastMap[i]; + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -scrollX, -scrollY); - if (HasValue(config, key)) - { - this[key] = GetFastValue(config, key); - } + scrollX = 0; + scrollY = 0; } - for (i = 0; i < this.configOpMap.length; i++) - { - key = this.configOpMap[i]; - - if (HasValue(config, key)) - { - this[key].loadConfig(config); - } - } - - this.acceleration = (this.accelerationX.propertyValue !== 0 || this.accelerationY.propertyValue !== 0); - - this.moveTo = (this.moveToX.propertyValue !== 0 || this.moveToY.propertyValue !== 0); - - // Special 'speed' override - - if (HasValue(config, 'speed')) - { - this.speedX.loadConfig(config, 'speed'); - this.speedY = null; - } - - // If you specify speedX, speedY or moveTo then it changes the emitter from radial to a point emitter - if (HasAny(config, [ 'speedX', 'speedY' ]) || this.moveTo) - { - this.radial = false; - } - - // Special 'scale' override - - if (HasValue(config, 'scale')) - { - this.scaleX.loadConfig(config, 'scale'); - this.scaleY = null; - } - - if (HasValue(config, 'callbackScope')) - { - var callbackScope = GetFastValue(config, 'callbackScope', null); - - this.emitCallbackScope = callbackScope; - this.deathCallbackScope = callbackScope; - } - - if (HasValue(config, 'emitZone')) - { - this.setEmitZone(config.emitZone); - } - - if (HasValue(config, 'deathZone')) - { - this.setDeathZone(config.deathZone); - } - - if (HasValue(config, 'bounds')) - { - this.setBounds(config.bounds); - } - - if (HasValue(config, 'followOffset')) - { - this.followOffset.setFromObject(GetFastValue(config, 'followOffset', 0)); - } - - if (HasValue(config, 'frame')) - { - this.setFrame(config.frame); - } - - return this; - }, - - /** - * Creates a description of this emitter suitable for JSON serialization. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#toJSON - * @since 3.0.0 - * - * @param {object} [output] - An object to copy output into. - * - * @return {object} - The output object. - */ - toJSON: function (output) - { - if (output === undefined) { output = {}; } - - var i = 0; - var key = ''; - - for (i = 0; i < this.configFastMap.length; i++) - { - key = this.configFastMap[i]; - - output[key] = this[key]; - } - - for (i = 0; i < this.configOpMap.length; i++) - { - key = this.configOpMap[i]; - - if (this[key]) - { - output[key] = this[key].toJSON(); - } - } - - // special handlers - if (!this.speedY) - { - delete output.speedX; - output.speed = this.speedX.toJSON(); - } - - if (!this.scaleY) - { - delete output.scaleX; - output.scale = this.scaleX.toJSON(); - } - - return output; - }, - - /** - * Continuously moves the particle origin to follow a Game Object's position. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#startFollow - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} target - The Game Object to follow. - * @param {float} [offsetX=0] - Horizontal offset of the particle origin from the Game Object. - * @param {float} [offsetY=0] - Vertical offset of the particle origin from the Game Object. - * @param {boolean} [trackVisible=false] - Whether the emitter's visible state will track the target's visible state. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - startFollow: function (target, offsetX, offsetY, trackVisible) - { - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - if (trackVisible === undefined) { trackVisible = false; } - - this.follow = target; - this.followOffset.set(offsetX, offsetY); - this.trackVisible = trackVisible; - - return this; - }, - - /** - * Stops following a Game Object. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#stopFollow - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - stopFollow: function () - { - this.follow = null; - this.followOffset.set(0, 0); - this.trackVisible = false; - - return this; - }, - - /** - * Chooses a texture frame from {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getFrame - * @since 3.0.0 - * - * @return {Phaser.Textures.Frame} The texture frame. - */ - getFrame: function () - { - if (this.frames.length === 1) - { - return this.defaultFrame; - } - else if (this.randomFrame) - { - return GetRandom(this.frames); - } - else - { - var frame = this.frames[this.currentFrame]; - - this._frameCounter++; - - if (this._frameCounter === this.frameQuantity) - { - this._frameCounter = 0; - this.currentFrame = Wrap(this.currentFrame + 1, 0, this._frameLength); - } - - return frame; - } - }, - - // frame: 0 - // frame: 'red' - // frame: [ 0, 1, 2, 3 ] - // frame: [ 'red', 'green', 'blue', 'pink', 'white' ] - // frame: { frames: [ 'red', 'green', 'blue', 'pink', 'white' ], [cycle: bool], [quantity: int] } - - /** - * Sets a pattern for assigning texture frames to emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrame - * @since 3.0.0 - * - * @param {(array|string|integer|ParticleEmitterFrameConfig)} frames - One or more texture frames, or a configuration object. - * @param {boolean} [pickRandom=true] - Whether frames should be assigned at random from `frames`. - * @param {integer} [quantity=1] - The number of consecutive particles that will receive each frame. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setFrame: function (frames, pickRandom, quantity) - { - if (pickRandom === undefined) { pickRandom = true; } - if (quantity === undefined) { quantity = 1; } - - this.randomFrame = pickRandom; - this.frameQuantity = quantity; - this.currentFrame = 0; - this._frameCounter = 0; - - var t = typeof (frames); - - if (Array.isArray(frames) || t === 'string' || t === 'number') - { - this.manager.setEmitterFrames(frames, this); - } - else if (t === 'object') - { - var frameConfig = frames; - - frames = GetFastValue(frameConfig, 'frames', null); - - if (frames) - { - this.manager.setEmitterFrames(frames, this); - } - - var isCycle = GetFastValue(frameConfig, 'cycle', false); - - this.randomFrame = (isCycle) ? false : true; - - this.frameQuantity = GetFastValue(frameConfig, 'quantity', quantity); - } - - this._frameLength = this.frames.length; - - if (this._frameLength === 1) - { - this.frameQuantity = 1; - this.randomFrame = false; - } - - return this; - }, - - /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle movement on or off. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setRadial - * @since 3.0.0 - * - * @param {boolean} [value=true] - Radial mode (true) or point mode (true). - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setRadial: function (value) - { - if (value === undefined) { value = true; } - - this.radial = value; - - return this; - }, - - /** - * Sets the position of the emitter's particle origin. - * New particles will be emitted here. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} x - The x-coordinate of the particle origin. - * @param {float|float[]|EmitterOpOnEmitCallback|object} y - The y-coordinate of the particle origin. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setPosition: function (x, y) - { - this.x.onChange(x); - this.y.onChange(y); - - return this; - }, - - /** - * Sets or modifies a rectangular boundary constraining the particles. - * - * To remove the boundary, set {@link Phaser.GameObjects.Particles.ParticleEmitter#bounds} to null. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setBounds - * @since 3.0.0 - * - * @param {(number|ParticleEmitterBounds|ParticleEmitterBoundsAlt)} x - The x-coordinate of the left edge of the boundary, or an object representing a rectangle. - * @param {float} y - The y-coordinate of the top edge of the boundary. - * @param {float} width - The width of the boundary. - * @param {float} height - The height of the boundary. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setBounds: function (x, y, width, height) - { - if (typeof x === 'object') - { - var obj = x; - - x = obj.x; - y = obj.y; - width = (HasValue(obj, 'w')) ? obj.w : obj.width; - height = (HasValue(obj, 'h')) ? obj.h : obj.height; - } - - if (this.bounds) - { - this.bounds.setTo(x, y, width, height); - } - else - { - this.bounds = new Rectangle(x, y, width, height); - } - - return this; - }, - - /** - * Sets the initial horizontal speed of emitted particles. - * Changes the emitter to point mode. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeedX: function (value) - { - this.speedX.onChange(value); - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = false; - - return this; - }, - - /** - * Sets the initial vertical speed of emitted particles. - * Changes the emitter to point mode. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeedY: function (value) - { - if (this.speedY) - { - this.speedY.onChange(value); - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = false; - } - - return this; - }, - - /** - * Sets the initial radial speed of emitted particles. - * Changes the emitter to radial mode. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setSpeed: function (value) - { - this.speedX.onChange(value); - this.speedY = null; - - // If you specify speedX and Y then it changes the emitter from radial to a point emitter - this.radial = true; - - return this; - }, - - /** - * Sets the horizontal scale of emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScaleX: function (value) - { - this.scaleX.onChange(value); - - return this; - }, - - /** - * Sets the vertical scale of emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScaleY: function (value) - { - this.scaleY.onChange(value); - - return this; - }, - - /** - * Sets the scale of emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setScale: function (value) - { - this.scaleX.onChange(value); - this.scaleY = null; - - return this; - }, - - /** - * Sets the horizontal gravity applied to emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX - * @since 3.0.0 - * - * @param {float} value - Acceleration due to gravity, in pixels per second squared. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravityX: function (value) - { - this.gravityX = value; - - return this; - }, - - /** - * Sets the vertical gravity applied to emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY - * @since 3.0.0 - * - * @param {float} value - Acceleration due to gravity, in pixels per second squared. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravityY: function (value) - { - this.gravityY = value; - - return this; - }, - - /** - * Sets the gravity applied to emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity - * @since 3.0.0 - * - * @param {float} x - Horizontal acceleration due to gravity, in pixels per second squared. - * @param {float} y - Vertical acceleration due to gravity, in pixels per second squared. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setGravity: function (x, y) - { - this.gravityX = x; - this.gravityY = y; - - return this; - }, - - /** - * Sets the opacity of emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - A value between 0 (transparent) and 1 (opaque). - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setAlpha: function (value) - { - this.alpha.onChange(value); - - return this; - }, - - /** - * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setEmitterAngle: function (value) - { - this.angle.onChange(value); - - return this; - }, - - /** - * Sets the angle of a {@link Phaser.GameObjects.Particles.ParticleEmitter#radial} particle stream. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setAngle: function (value) - { - this.angle.onChange(value); - - return this; - }, - - /** - * Sets the lifespan of newly emitted particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The particle lifespan, in ms. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setLifespan: function (value) - { - this.lifespan.onChange(value); - - return this; - }, - - /** - * Sets the number of particles released at each flow cycle or explosion. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity - * @since 3.0.0 - * - * @param {float|float[]|EmitterOpOnEmitCallback|object} quantity - The number of particles to release at each flow cycle or explosion. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setQuantity: function (quantity) - { - this.quantity.onChange(quantity); - - return this; - }, - - /** - * Sets the emitter's {@link Phaser.GameObjects.Particles.ParticleEmitter#frequency} - * and {@link Phaser.GameObjects.Particles.ParticleEmitter#quantity}. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency - * @since 3.0.0 - * - * @param {float} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. - * @param {float|float[]|EmitterOpOnEmitCallback|object} [quantity] - The number of particles to release at each flow cycle or explosion. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setFrequency: function (frequency, quantity) - { - this.frequency = frequency; - - this._counter = 0; - - if (quantity) - { - this.quantity.onChange(quantity); - } - - return this; - }, - - /** - * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#emitZone}. - * - * An {@link ParticleEmitterEdgeZoneConfig EdgeZone} places particles on its edges. Its {@link EdgeZoneSource source} can be a Curve, Path, Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link EdgeZoneSourceCallback getPoints} method. - * - * A {@link ParticleEmitterRandomZoneConfig RandomZone} places randomly within its interior. Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link RandomZoneSourceCallback getRandomPoint} method. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitZone - * @since 3.0.0 - * - * @param {ParticleEmitterEdgeZoneConfig|ParticleEmitterRandomZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current emit zone. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setEmitZone: function (zoneConfig) - { - if (zoneConfig === undefined) - { - this.emitZone = null; - } - else - { - // Where source = Geom like Circle, or a Path or Curve - // emitZone: { type: 'random', source: X } - // emitZone: { type: 'edge', source: X, quantity: 32, [stepRate=0], [yoyo=false], [seamless=true] } - - var type = GetFastValue(zoneConfig, 'type', 'random'); - var source = GetFastValue(zoneConfig, 'source', null); - - switch (type) - { - case 'random': - - this.emitZone = new RandomZone(source); - - break; - - case 'edge': - - var quantity = GetFastValue(zoneConfig, 'quantity', 1); - var stepRate = GetFastValue(zoneConfig, 'stepRate', 0); - var yoyo = GetFastValue(zoneConfig, 'yoyo', false); - var seamless = GetFastValue(zoneConfig, 'seamless', true); - - this.emitZone = new EdgeZone(source, quantity, stepRate, yoyo, seamless); - - break; - } - } - - return this; - }, - - /** - * Sets or removes the {@link Phaser.GameObjects.Particles.ParticleEmitter#deathZone}. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#setDeathZone - * @since 3.0.0 - * - * @param {ParticleEmitterDeathZoneConfig} [zoneConfig] - An object describing the zone, or `undefined` to remove any current death zone. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - setDeathZone: function (zoneConfig) - { - if (zoneConfig === undefined) - { - this.deathZone = null; - } - else - { - // Where source = Geom like Circle or Rect that supports a 'contains' function - // deathZone: { type: 'onEnter', source: X } - // deathZone: { type: 'onLeave', source: X } - - var type = GetFastValue(zoneConfig, 'type', 'onEnter'); - var source = GetFastValue(zoneConfig, 'source', null); - - if (source && typeof source.contains === 'function') - { - var killOnEnter = (type === 'onEnter') ? true : false; - - this.deathZone = new DeathZone(source, killOnEnter); - } - } - - return this; - }, - - /** - * Creates inactive particles and adds them to this emitter's pool. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#reserve - * @since 3.0.0 - * - * @param {integer} particleCount - The number of particles to create. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - reserve: function (particleCount) - { - var dead = this.dead; + ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; for (var i = 0; i < particleCount; i++) { - dead.push(new this.particleClass(this)); - } + var particle = particles[i]; - return this; - }, + var alpha = particle.alpha * camera.alpha; - /** - * Gets the number of active (in-use) particles in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getAliveParticleCount - * @since 3.0.0 - * - * @return {integer} The number of particles with `active=true`. - */ - getAliveParticleCount: function () - { - return this.alive.length; - }, - - /** - * Gets the number of inactive (available) particles in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getDeadParticleCount - * @since 3.0.0 - * - * @return {integer} The number of particles with `active=false`. - */ - getDeadParticleCount: function () - { - return this.dead.length; - }, - - /** - * Gets the total number of particles in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#getParticleCount - * @since 3.0.0 - * - * @return {integer} The number of particles, including both alive and dead. - */ - getParticleCount: function () - { - return this.getAliveParticleCount() + this.getDeadParticleCount(); - }, - - /** - * Whether this emitter is at its limit (if set). - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#atLimit - * @since 3.0.0 - * - * @return {boolean} Returns `true` if this Emitter is at its limit, or `false` if no limit, or below the `maxParticles` level. - */ - atLimit: function () - { - return (this.maxParticles > 0 && this.getParticleCount() === this.maxParticles); - }, - - /** - * Sets a function to call for each newly emitted particle. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleEmit - * @since 3.0.0 - * - * @param {ParticleEmitterCallback} callback - The function. - * @param {*} [context] - The calling context. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - onParticleEmit: function (callback, context) - { - if (callback === undefined) - { - // Clear any previously set callback - this.emitCallback = null; - this.emitCallbackScope = null; - } - else if (typeof callback === 'function') - { - this.emitCallback = callback; - - if (context) + if (alpha <= 0) { - this.emitCallbackScope = context; - } - } - - return this; - }, - - /** - * Sets a function to call for each particle death. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#onParticleDeath - * @since 3.0.0 - * - * @param {ParticleDeathCallback} callback - The function. - * @param {*} [context] - The function's calling context. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - onParticleDeath: function (callback, context) - { - if (callback === undefined) - { - // Clear any previously set callback - this.deathCallback = null; - this.deathCallbackScope = null; - } - else if (typeof callback === 'function') - { - this.deathCallback = callback; - - if (context) - { - this.deathCallbackScope = context; - } - } - - return this; - }, - - /** - * Deactivates every particle in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#killAll - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - killAll: function () - { - var dead = this.dead; - var alive = this.alive; - - while (alive.length > 0) - { - dead.push(alive.pop()); - } - - return this; - }, - - /** - * Calls a function for each active particle in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachAlive - * @since 3.0.0 - * - * @param {ParticleEmitterCallback} callback - The function. - * @param {*} context - The function's calling context. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - forEachAlive: function (callback, context) - { - var alive = this.alive; - var length = alive.length; - - for (var index = 0; index < length; ++index) - { - // Sends the Particle and the Emitter - callback.call(context, alive[index], this); - } - - return this; - }, - - /** - * Calls a function for each inactive particle in this emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#forEachDead - * @since 3.0.0 - * - * @param {ParticleEmitterCallback} callback - The function. - * @param {*} context - The function's calling context. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - forEachDead: function (callback, context) - { - var dead = this.dead; - var length = dead.length; - - for (var index = 0; index < length; ++index) - { - // Sends the Particle and the Emitter - callback.call(context, dead[index], this); - } - - return this; - }, - - /** - * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. - * - * If this emitter is in flow mode (frequency >= 0; the default), the particle flow will start (or restart). - * - * If this emitter is in explode mode (frequency = -1), nothing will happen. - * Use {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} or {@link Phaser.GameObjects.Particles.ParticleEmitter#flow} instead. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#start - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - start: function () - { - this.on = true; - - this._counter = 0; - - return this; - }, - - /** - * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#pause - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - pause: function () - { - this.active = false; - - return this; - }, - - /** - * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Activates} the emitter. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#resume - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - resume: function () - { - this.active = true; - - return this; - }, - - /** - * Sorts active particles with {@link Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback}. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSort - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - depthSort: function () - { - StableSort.inplace(this.alive, this.depthSortCallback); - - return this; - }, - - /** - * Puts the emitter in flow mode (frequency >= 0) and starts (or restarts) a particle flow. - * - * To resume a flow at the current frequency and quantity, use {@link Phaser.GameObjects.Particles.ParticleEmitter#start} instead. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#flow - * @since 3.0.0 - * - * @param {float} frequency - The time interval (>= 0) of each flow cycle, in ms. - * @param {float|float[]|EmitterOpOnEmitCallback|object} [count=1] - The number of particles to emit at each flow cycle. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. - */ - flow: function (frequency, count) - { - if (count === undefined) { count = 1; } - - this.frequency = frequency; - - this.quantity.onChange(count); - - return this.start(); - }, - - /** - * Puts the emitter in explode mode (frequency = -1), stopping any current particle flow, and emits several particles all at once. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#explode - * @since 3.0.0 - * - * @param {integer} count - The amount of Particles to emit. - * @param {float} x - The x coordinate to emit the Particles from. - * @param {float} y - The y coordinate to emit the Particles from. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - explode: function (count, x, y) - { - this.frequency = -1; - - return this.emitParticle(count, x, y); - }, - - /** - * Emits particles at a given position (or the emitter's current position). - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt - * @since 3.0.0 - * - * @param {float} [x=this.x] - The x coordinate to emit the Particles from. - * @param {float} [y=this.x] - The y coordinate to emit the Particles from. - * @param {integer} [count=this.quantity] - The number of Particles to emit. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - */ - emitParticleAt: function (x, y, count) - { - return this.emitParticle(count, x, y); - }, - - /** - * Emits particles at a given position (or the emitter's current position). - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticle - * @since 3.0.0 - * - * @param {integer} [count=this.quantity] - The number of Particles to emit. - * @param {float} [x=this.x] - The x coordinate to emit the Particles from. - * @param {float} [y=this.x] - The y coordinate to emit the Particles from. - * - * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. - * - * @see Phaser.GameObjects.Particles.Particle#fire - */ - emitParticle: function (count, x, y) - { - if (this.atLimit()) - { - return; - } - - if (count === undefined) - { - count = this.quantity.onEmit(); - } - - var dead = this.dead; - - for (var i = 0; i < count; i++) - { - var particle; - - if (dead.length > 0) - { - particle = dead.pop(); - } - else - { - particle = new this.particleClass(this); + continue; } - particle.fire(x, y); + var frame = particle.frame; + var cd = frame.canvasData; - if (this.particleBringToTop) + var x = -(frame.halfWidth); + var y = -(frame.halfHeight); + + particleMatrix.applyITRS(0, 0, particle.rotation, particle.scaleX, particle.scaleY); + + particleMatrix.e = particle.x - scrollX; + particleMatrix.f = particle.y - scrollY; + + camMatrix.multiply(particleMatrix, calcMatrix); + + ctx.globalAlpha = alpha; + + ctx.save(); + + calcMatrix.copyToContext(ctx); + + if (roundPixels) { - this.alive.push(particle); - } - else - { - this.alive.unshift(particle); + x |= 0; + y |= 0; } - if (this.emitCallback) - { - this.emitCallback.call(this.emitCallbackScope, particle, this); - } + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height); - if (this.atLimit()) - { - break; - } + ctx.restore(); } - - return particle; - }, - - /** - * Updates this emitter and its particles. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#preUpdate - * @since 3.0.0 - * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {float} delta - The delta time, in ms, elapsed since the last frame. - */ - preUpdate: function (time, delta) - { - // Scale the delta - delta *= this.timeScale; - - var step = (delta / 1000); - - if (this.trackVisible) - { - this.visible = this.follow.visible; - } - - // Any particle processors? - var processors = this.manager.getProcessors(); - - var particles = this.alive; - var length = particles.length; - - for (var index = 0; index < length; index++) - { - var particle = particles[index]; - - // update returns `true` if the particle is now dead (lifeStep < 0) - if (particle.update(delta, step, processors)) - { - // Moves the dead particle to the end of the particles array (ready for splicing out later) - var last = particles[length - 1]; - - particles[length - 1] = particle; - particles[index] = last; - - index -= 1; - length -= 1; - } - } - - // Move dead particles to the dead array - var deadLength = particles.length - length; - - if (deadLength > 0) - { - var rip = particles.splice(particles.length - deadLength, deadLength); - - var deathCallback = this.deathCallback; - var deathCallbackScope = this.deathCallbackScope; - - if (deathCallback) - { - for (var i = 0; i < rip.length; i++) - { - deathCallback.call(deathCallbackScope, rip[i]); - } - } - - this.dead.concat(rip); - - StableSort.inplace(particles, this.indexSortCallback); - } - - if (!this.on) - { - return; - } - - if (this.frequency === 0) - { - this.emitParticle(); - } - else if (this.frequency > 0) - { - this._counter -= delta; - - if (this._counter <= 0) - { - this.emitParticle(); - - // counter = frequency - remained from previous delta - this._counter = (this.frequency - Math.abs(this._counter)); - } - } - }, - - /** - * Calculates the difference of two particles, for sorting them by depth. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#depthSortCallback - * @since 3.0.0 - * - * @param {object} a - The first particle. - * @param {object} b - The second particle. - * - * @return {integer} The difference of a and b's y coordinates. - */ - depthSortCallback: function (a, b) - { - return a.y - b.y; - }, - - /** - * Calculates the difference of two particles, for sorting them by index. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback - * @since 3.0.0 - * - * @param {object} a - The first particle. - * @param {object} b - The second particle. - * - * @return {integer} The difference of a and b's `index` properties. - */ - indexSortCallback: function (a, b) - { - return a.index - b.index; } -}); - -module.exports = ParticleEmitter; - - -/***/ }), -/* 457 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var DistanceBetween = __webpack_require__(58); - -var GetColor = function (value) -{ - return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); + ctx.restore(); }; -/** - * @classdesc - * A Particle is a simple Game Object controlled by a Particle Emitter and Manager, and rendered by the Manager. - * It uses its own lightweight physics system, and can interact only with its Emitter's bounds and zones. - * - * @class Particle - * @memberOf Phaser.GameObjects.Particles - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to which this Particle belongs. - */ -var Particle = new Class({ - - initialize: - - function Particle (emitter) - { - /** - * The Emitter to which this Particle belongs. - * - * A Particle can only belong to a single Emitter and is created, updated and destroyed via it. - * - * @name Phaser.GameObjects.Particles.Particle#emitter - * @type {Phaser.GameObjects.Particles.ParticleEmitter} - * @since 3.0.0 - */ - this.emitter = emitter; - - /** - * The texture frame used to render this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#frame - * @type {Phaser.Textures.Frame} - * @default null - * @since 3.0.0 - */ - this.frame = null; - - /** - * The position of this Particle within its Emitter's particle pool. - * - * @name Phaser.GameObjects.Particles.Particle#index - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.index = 0; - - /** - * The x coordinate of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.x = 0; - - /** - * The y coordinate of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.y = 0; - - /** - * The x velocity of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#velocityX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.velocityX = 0; - - /** - * The y velocity of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#velocityY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.velocityY = 0; - - /** - * The x acceleration of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#accelerationX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelerationX = 0; - - /** - * The y acceleration of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#accelerationY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.accelerationY = 0; - - /** - * The maximum horizontal velocity this Particle can travel at. - * - * @name Phaser.GameObjects.Particles.Particle#maxVelocityX - * @type {number} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityX = 10000; - - /** - * The maximum vertical velocity this Particle can travel at. - * - * @name Phaser.GameObjects.Particles.Particle#maxVelocityY - * @type {number} - * @default 10000 - * @since 3.0.0 - */ - this.maxVelocityY = 10000; - - /** - * The bounciness, or restitution, of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#bounce - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.bounce = 0; - - /** - * The horizontal scale of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#scaleX - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.scaleX = 1; - - /** - * The vertical scale of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#scaleY - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.scaleY = 1; - - /** - * The alpha value of this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#alpha - * @type {float} - * @default 1 - * @since 3.0.0 - */ - this.alpha = 1; - - /** - * The angle of this Particle in degrees. - * - * @name Phaser.GameObjects.Particles.Particle#angle - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.angle = 0; - - /** - * The angle of this Particle in radians. - * - * @name Phaser.GameObjects.Particles.Particle#rotation - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotation = 0; - - /** - * The tint applied to this Particle. - * - * @name Phaser.GameObjects.Particles.Particle#tint - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - this.tint = 0xffffff; - - /** - * The full color of this Particle, computed from its alpha and tint. - * - * @name Phaser.GameObjects.Particles.Particle#color - * @type {integer} - * @since 3.0.0 - */ - this.color = 16777215; - - /** - * The lifespan of this Particle in ms. - * - * @name Phaser.GameObjects.Particles.Particle#life - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.life = 1000; - - /** - * The current life of this Particle in ms. - * - * @name Phaser.GameObjects.Particles.Particle#lifeCurrent - * @type {number} - * @default 1000 - * @since 3.0.0 - */ - this.lifeCurrent = 1000; - - /** - * The delay applied to this Particle upon emission, in ms. - * - * @name Phaser.GameObjects.Particles.Particle#delayCurrent - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.delayCurrent = 0; - - /** - * The normalized lifespan T value, where 0 is the start and 1 is the end. - * - * @name Phaser.GameObjects.Particles.Particle#lifeT - * @type {float} - * @default 0 - * @since 3.0.0 - */ - this.lifeT = 0; - - /** - * The data used by the ease equation. - * - * @name Phaser.GameObjects.Particles.Particle#data - * @type {object} - * @since 3.0.0 - */ - this.data = { - tint: { min: 0xffffff, max: 0xffffff, current: 0xffffff }, - alpha: { min: 1, max: 1 }, - rotate: { min: 0, max: 0 }, - scaleX: { min: 1, max: 1 }, - scaleY: { min: 1, max: 1 } - }; - }, - - /** - * Checks to see if this Particle is alive and updating. - * - * @method Phaser.GameObjects.Particles.Particle#isAlive - * @since 3.0.0 - * - * @return {boolean} `true` if this Particle is alive and updating, otherwise `false`. - */ - isAlive: function () - { - return (this.lifeCurrent > 0); - }, - - /** - * Starts this Particle from the given coordinates. - * - * @method Phaser.GameObjects.Particles.Particle#fire - * @since 3.0.0 - * - * @param {number} x - The x coordinate to launch this Particle from. - * @param {number} y - The y coordinate to launch this Particle from. - */ - fire: function (x, y) - { - var emitter = this.emitter; - - this.frame = emitter.getFrame(); - - if (emitter.emitZone) - { - // Updates particle.x and particle.y during this call - emitter.emitZone.getPoint(this); - } - - if (x === undefined) - { - if (emitter.follow) - { - this.x += emitter.follow.x + emitter.followOffset.x; - } - - this.x += emitter.x.onEmit(this, 'x'); - } - else - { - this.x += x; - } - - if (y === undefined) - { - if (emitter.follow) - { - this.y += emitter.follow.y + emitter.followOffset.y; - } - - this.y += emitter.y.onEmit(this, 'y'); - } - else - { - this.y += y; - } - - this.life = emitter.lifespan.onEmit(this, 'lifespan'); - this.lifeCurrent = this.life; - this.lifeT = 0; - - var sx = emitter.speedX.onEmit(this, 'speedX'); - var sy = (emitter.speedY) ? emitter.speedY.onEmit(this, 'speedY') : sx; - - if (emitter.radial) - { - var rad = DegToRad(emitter.angle.onEmit(this, 'angle')); - - this.velocityX = Math.cos(rad) * Math.abs(sx); - this.velocityY = Math.sin(rad) * Math.abs(sy); - } - else if (emitter.moveTo) - { - var mx = emitter.moveToX.onEmit(this, 'moveToX'); - var my = (emitter.moveToY) ? emitter.moveToY.onEmit(this, 'moveToY') : mx; - - var angle = Math.atan2(my - this.y, mx - this.x); - - var speed = DistanceBetween(this.x, this.y, mx, my) / (this.life / 1000); - - // We know how many pixels we need to move, but how fast? - // var speed = this.distanceToXY(displayObject, x, y) / (maxTime / 1000); - - this.velocityX = Math.cos(angle) * speed; - this.velocityY = Math.sin(angle) * speed; - } - else - { - this.velocityX = sx; - this.velocityY = sy; - } - - if (emitter.acceleration) - { - this.accelerationX = emitter.accelerationX.onEmit(this, 'accelerationX'); - this.accelerationY = emitter.accelerationY.onEmit(this, 'accelerationY'); - } - - this.maxVelocityX = emitter.maxVelocityX.onEmit(this, 'maxVelocityX'); - this.maxVelocityY = emitter.maxVelocityY.onEmit(this, 'maxVelocityY'); - - this.delayCurrent = emitter.delay.onEmit(this, 'delay'); - - this.scaleX = emitter.scaleX.onEmit(this, 'scaleX'); - this.scaleY = (emitter.scaleY) ? emitter.scaleY.onEmit(this, 'scaleY') : this.scaleX; - - this.angle = emitter.rotate.onEmit(this, 'rotate'); - this.rotation = DegToRad(this.angle); - - this.bounce = emitter.bounce.onEmit(this, 'bounce'); - - this.alpha = emitter.alpha.onEmit(this, 'alpha'); - - this.tint = emitter.tint.onEmit(this, 'tint'); - - var ua = ((this.alpha * 255) | 0) & 0xFF; - - this.color = ((ua << 24) | GetColor(this.tint)) >>> 0; - - this.index = emitter.alive.length; - }, - - /** - * An internal method that calculates the velocity of the Particle. - * - * @method Phaser.GameObjects.Particles.Particle#computeVelocity - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter that is updating this Particle. - * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. - * @param {array} processors - Particle processors (gravity wells). - */ - computeVelocity: function (emitter, delta, step, processors) - { - var vx = this.velocityX; - var vy = this.velocityY; - - var ax = this.accelerationX; - var ay = this.accelerationY; - - var mx = this.maxVelocityX; - var my = this.maxVelocityY; - - vx += (emitter.gravityX * step); - vy += (emitter.gravityY * step); - - if (ax) - { - vx += (ax * step); - } - - if (ay) - { - vy += (ay * step); - } - - if (vx > mx) - { - vx = mx; - } - else if (vx < -mx) - { - vx = -mx; - } - - if (vy > my) - { - vy = my; - } - else if (vy < -my) - { - vy = -my; - } - - this.velocityX = vx; - this.velocityY = vy; - - // Apply any additional processors - for (var i = 0; i < processors.length; i++) - { - processors[i].update(this, delta, step); - } - }, - - /** - * Checks if this Particle is still within the bounds defined by the given Emitter. - * - * If not, and depending on the Emitter collision flags, the Particle may either stop or rebound. - * - * @method Phaser.GameObjects.Particles.Particle#checkBounds - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter to check the bounds against. - */ - checkBounds: function (emitter) - { - var bounds = emitter.bounds; - var bounce = -this.bounce; - - if (this.x < bounds.x && emitter.collideLeft) - { - this.x = bounds.x; - this.velocityX *= bounce; - } - else if (this.x > bounds.right && emitter.collideRight) - { - this.x = bounds.right; - this.velocityX *= bounce; - } - - if (this.y < bounds.y && emitter.collideTop) - { - this.y = bounds.y; - this.velocityY *= bounce; - } - else if (this.y > bounds.bottom && emitter.collideBottom) - { - this.y = bounds.bottom; - this.velocityY *= bounce; - } - }, - - /** - * The main update method for this Particle. - * - * Updates its life values, computes the velocity and repositions the Particle. - * - * @method Phaser.GameObjects.Particles.Particle#update - * @since 3.0.0 - * - * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. - * @param {array} processors - An optional array of update processors. - * - * @return {boolean} Returns `true` if this Particle has now expired and should be removed, otherwise `false` if still active. - */ - update: function (delta, step, processors) - { - if (this.delayCurrent > 0) - { - this.delayCurrent -= delta; - - return false; - } - - var emitter = this.emitter; - - // How far along in life is this particle? (t = 0 to 1) - var t = 1 - (this.lifeCurrent / this.life); - - this.lifeT = t; - - this.computeVelocity(emitter, delta, step, processors); - - this.x += this.velocityX * step; - this.y += this.velocityY * step; - - if (emitter.bounds) - { - this.checkBounds(emitter); - } - - if (emitter.deathZone && emitter.deathZone.willKill(this)) - { - this.lifeCurrent = 0; - - // No need to go any further, particle has been killed - return true; - } - - this.scaleX = emitter.scaleX.onUpdate(this, 'scaleX', t, this.scaleX); - - if (emitter.scaleY) - { - this.scaleY = emitter.scaleY.onUpdate(this, 'scaleY', t, this.scaleY); - } - else - { - this.scaleY = this.scaleX; - } - - this.angle = emitter.rotate.onUpdate(this, 'rotate', t, this.angle); - this.rotation = DegToRad(this.angle); - - this.alpha = emitter.alpha.onUpdate(this, 'alpha', t, this.alpha); - - this.tint = emitter.tint.onUpdate(this, 'tint', t, this.tint); - - var ua = ((this.alpha * 255) | 0) & 0xFF; - - this.color = ((ua << 24) | GetColor(this.tint)) >>> 0; - - this.lifeCurrent -= delta; - - return (this.lifeCurrent <= 0); - } - -}); - -module.exports = Particle; +module.exports = ParticleManagerCanvasRenderer; /***/ }), -/* 458 */ +/* 820 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Particles.EmitterManager#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) +{ + var emitters = emitterManager.emitters.list; + var emittersLength = emitters.length; + + if (emittersLength === 0) + { + return; + } + + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1.copyFrom(camera.matrix); + var calcMatrix = pipeline._tempMatrix2; + var particleMatrix = pipeline._tempMatrix3; + var managerMatrix = pipeline._tempMatrix4.applyITRS(emitterManager.x, emitterManager.y, emitterManager.rotation, emitterManager.scaleX, emitterManager.scaleY); + + camMatrix.multiply(managerMatrix); + + renderer.setPipeline(pipeline); + + var roundPixels = camera.roundPixels; + var texture = emitterManager.defaultFrame.glTexture; + var getTint = Utils.getTintAppendFloatAlphaAndSwap; + + pipeline.setTexture2D(texture, 0); + + for (var e = 0; e < emittersLength; e++) + { + var emitter = emitters[e]; + var particles = emitter.alive; + var particleCount = particles.length; + + if (!emitter.visible || particleCount === 0) + { + continue; + } + + var scrollX = camera.scrollX * emitter.scrollFactorX; + var scrollY = camera.scrollY * emitter.scrollFactorY; + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -scrollX, -scrollY); + + scrollX = 0; + scrollY = 0; + } + + if (renderer.setBlendMode(emitter.blendMode)) + { + // Rebind the texture if we've flushed + pipeline.setTexture2D(texture, 0); + } + + var tintEffect = 0; + + for (var i = 0; i < particleCount; i++) + { + var particle = particles[i]; + + var alpha = particle.alpha * camera.alpha; + + if (alpha <= 0) + { + continue; + } + + var frame = particle.frame; + + var x = -(frame.halfWidth); + var y = -(frame.halfHeight); + var xw = x + frame.width; + var yh = y + frame.height; + + particleMatrix.applyITRS(0, 0, particle.rotation, particle.scaleX, particle.scaleY); + + particleMatrix.e = particle.x - scrollX; + particleMatrix.f = particle.y - scrollY; + + camMatrix.multiply(particleMatrix, calcMatrix); + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + var tint = getTint(particle.tint, alpha); + + if (pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect)) + { + pipeline.setTexture2D(texture, 0); + } + } + } +}; + +module.exports = ParticleManagerWebGLRenderer; + + +/***/ }), +/* 821 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(820); +} + +if (true) +{ + renderCanvas = __webpack_require__(819); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 822 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103045,222 +135177,666 @@ module.exports = Particle; */ var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); +var FloatBetween = __webpack_require__(299); +var GetEaseFunction = __webpack_require__(86); +var GetFastValue = __webpack_require__(2); +var Wrap = __webpack_require__(53); /** - * @typedef {object} GravityWellConfig + * The returned value sets what the property will be at the START of the particle's life, on emit. + * @callback EmitterOpOnEmitCallback * - * @property {number} [x=0] - The x coordinate of the Gravity Well, in world space. - * @property {number} [y=0] - The y coordinate of the Gravity Well, in world space. - * @property {number} [power=0] - The power of the Gravity Well. - * @property {number} [epsilon=100] - [description] - * @property {number} [gravity=50] - The gravitational force of this Gravity Well. + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + +/** + * The returned value updates the property for the duration of the particle's life. + * @callback EmitterOpOnUpdateCallback + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The normalized lifetime of the particle, between 0 (start) and 1 (end). + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + +/** + * Defines an operation yielding a random value within a range. + * @typedef {object} EmitterOpRandomConfig + * + * @property {number[]} random - The minimum and maximum values, as [min, max]. + */ + +/** + * Defines an operation yielding a random value within a range. + * @typedef {object} EmitterOpRandomMinMaxConfig + * + * @property {number} min - The minimum value. + * @property {number} max - The maximum value. + */ + +/** + * Defines an operation yielding a random value within a range. + * @typedef {object} EmitterOpRandomStartEndConfig + * + * @property {number} start - The starting value. + * @property {number} end - The ending value. + * @property {boolean} random - If false, this becomes {@link EmitterOpEaseConfig}. + */ + +/** + * Defines an operation yielding a value incremented continuously across a range. + * @typedef {object} EmitterOpEaseConfig + * + * @property {number} start - The starting value. + * @property {number} end - The ending value. + * @property {string} [ease='Linear'] - The name of the easing function. + */ + +/** + * Defines an operation yielding a value incremented by steps across a range. + * @typedef {object} EmitterOpSteppedConfig + * + * @property {number} start - The starting value. + * @property {number} end - The ending value. + * @property {number} steps - The number of steps between start and end. + */ + +/** + * @typedef {object} EmitterOpCustomEmitConfig + * + * @property {EmitterOpOnEmitCallback} onEmit - [description] + */ + +/** + * @typedef {object} EmitterOpCustomUpdateConfig + * + * @property {EmitterOpOnEmitCallback} [onEmit] - [description] + * @property {EmitterOpOnUpdateCallback} onUpdate - [description] */ /** * @classdesc - * [description] + * A Particle Emitter property. * - * @class GravityWell - * @memberOf Phaser.GameObjects.Particles + * Facilitates changing Particle properties as they are emitted and throughout their lifetime. + * + * @class EmitterOp + * @memberof Phaser.GameObjects.Particles * @constructor * @since 3.0.0 * - * @param {(number|GravityWellConfig)} [x=0] - The x coordinate of the Gravity Well, in world space. - * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. - * @param {number} [power=0] - The power of the Gravity Well. - * @param {number} [epsilon=100] - [description] - * @param {number} [gravity=50] - The gravitational force of this Gravity Well. + * @param {ParticleEmitterConfig} config - Settings for the Particle Emitter that owns this property. + * @param {string} key - The name of the property. + * @param {number} defaultValue - The default value of the property. + * @param {boolean} [emitOnly=false] - Whether the property can only be modified when a Particle is emitted. */ -var GravityWell = new Class({ +var EmitterOp = new Class({ initialize: - function GravityWell (x, y, power, epsilon, gravity) + function EmitterOp (config, key, defaultValue, emitOnly) { - if (typeof x === 'object') + if (emitOnly === undefined) { - var config = x; - - x = GetFastValue(config, 'x', 0); - y = GetFastValue(config, 'y', 0); - power = GetFastValue(config, 'power', 0); - epsilon = GetFastValue(config, 'epsilon', 100); - gravity = GetFastValue(config, 'gravity', 50); - } - else - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (power === undefined) { power = 0; } - if (epsilon === undefined) { epsilon = 100; } - if (gravity === undefined) { gravity = 50; } + emitOnly = false; } /** - * The x coordinate of the Gravity Well, in world space. + * The name of this property. * - * @name Phaser.GameObjects.Particles.GravityWell#x + * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey + * @type {string} + * @since 3.0.0 + */ + this.propertyKey = key; + + /** + * The value of this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue * @type {number} * @since 3.0.0 */ - this.x = x; + this.propertyValue = defaultValue; /** - * The y coordinate of the Gravity Well, in world space. + * The default value of this property. * - * @name Phaser.GameObjects.Particles.GravityWell#y + * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue * @type {number} * @since 3.0.0 */ - this.y = y; + this.defaultValue = defaultValue; /** - * The active state of the Gravity Well. An inactive Gravity Well will not influence any particles. + * The number of steps for stepped easing between {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} values, per emit. * - * @name Phaser.GameObjects.Particles.GravityWell#active + * @name Phaser.GameObjects.Particles.EmitterOp#steps + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.steps = 0; + + /** + * The step counter for stepped easing, per emit. + * + * @name Phaser.GameObjects.Particles.EmitterOp#counter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.counter = 0; + + /** + * The start value for this property to ease between. + * + * @name Phaser.GameObjects.Particles.EmitterOp#start + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.start = 0; + + /** + * The end value for this property to ease between. + * + * @name Phaser.GameObjects.Particles.EmitterOp#end + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.end = 0; + + /** + * The easing function to use for updating this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#ease + * @type {?function} + * @since 3.0.0 + */ + this.ease; + + /** + * Whether this property can only be modified when a Particle is emitted. + * + * Set to `true` to allow only {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} callbacks to be set and + * affect this property. + * + * Set to `false` to allow both {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks to be set and affect this property. + * + * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly * @type {boolean} - * @default true * @since 3.0.0 */ - this.active = true; + this.emitOnly = emitOnly; /** - * Internal gravity value. + * The callback to run for Particles when they are emitted from the Particle Emitter. * - * @name Phaser.GameObjects.Particles.GravityWell#_gravity - * @type {number} - * @private + * @name Phaser.GameObjects.Particles.EmitterOp#onEmit + * @type {EmitterOpOnEmitCallback} * @since 3.0.0 */ - this._gravity = gravity; + this.onEmit = this.defaultEmit; /** - * Internal power value. + * The callback to run for Particles when they are updated. * - * @name Phaser.GameObjects.Particles.GravityWell#_power - * @type {number} - * @private - * @default 0 + * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate + * @type {EmitterOpOnUpdateCallback} * @since 3.0.0 */ - this._power = 0; + this.onUpdate = this.defaultUpdate; - /** - * Internal epsilon value. - * - * @name Phaser.GameObjects.Particles.GravityWell#_epsilon - * @type {number} - * @private - * @default 0 - * @since 3.0.0 - */ - this._epsilon = 0; - - /** - * The power of the Gravity Well. - * - * @name Phaser.GameObjects.Particles.GravityWell#power - * @type {number} - * @since 3.0.0 - */ - this.power = power; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.GravityWell#epsilon - * @type {number} - * @since 3.0.0 - */ - this.epsilon = epsilon; + this.loadConfig(config); }, /** - * Takes a Particle and updates it based on the properties of this Gravity Well. + * Load the property from a Particle Emitter configuration object. * - * @method Phaser.GameObjects.Particles.GravityWell#update + * Optionally accepts a new property key to use, replacing the current one. + * + * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig * @since 3.0.0 * - * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. - * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. + * @param {ParticleEmitterConfig} [config] - Settings for the Particle Emitter that owns this property. + * @param {string} [newKey] - The new key to use for this property, if any. */ - update: function (particle, delta) + loadConfig: function (config, newKey) { - var x = this.x - particle.x; - var y = this.y - particle.y; - var dSq = x * x + y * y; - - if (dSq === 0) + if (config === undefined) { - return; + config = {}; } - var d = Math.sqrt(dSq); - - if (dSq < this._epsilon) + if (newKey) { - dSq = this._epsilon; + this.propertyKey = newKey; } - var factor = ((this._power * delta) / (dSq * d)) * 100; + this.propertyValue = GetFastValue( + config, + this.propertyKey, + this.defaultValue + ); - particle.velocityX += x * factor; - particle.velocityY += y * factor; + this.setMethods(); + + if (this.emitOnly) + { + // Reset it back again + this.onUpdate = this.defaultUpdate; + } }, - epsilon: { - - get: function () - { - return Math.sqrt(this._epsilon); - }, - - set: function (value) - { - this._epsilon = value * value; - } - + /** + * Build a JSON representation of this Particle Emitter property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#toJSON + * @since 3.0.0 + * + * @return {object} A JSON representation of this Particle Emitter property. + */ + toJSON: function () + { + return this.propertyValue; }, - power: { - - get: function () - { - return this._power / this._gravity; - }, - - set: function (value) - { - this._power = value * this._gravity; - } + /** + * Change the current value of the property and update its callback methods. + * + * @method Phaser.GameObjects.Particles.EmitterOp#onChange + * @since 3.0.0 + * + * @param {number} value - The value of the property. + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + onChange: function (value) + { + this.propertyValue = value; + return this.setMethods(); }, - gravity: { + /** + * Update the {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks based on the type of the current + * {@link Phaser.GameObjects.Particles.EmitterOp#propertyValue}. + * + * @method Phaser.GameObjects.Particles.EmitterOp#setMethods + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. + */ + setMethods: function () + { + var value = this.propertyValue; - get: function () - { - return this._gravity; - }, + var t = typeof value; - set: function (value) + if (t === 'number') { - var pwr = this.power; - this._gravity = value; - this.power = pwr; + // Explicit static value: + // x: 400 + + this.onEmit = this.staticValueEmit; + this.onUpdate = this.staticValueUpdate; // How? + } + else if (Array.isArray(value)) + { + // Picks a random element from the array: + // x: [ 100, 200, 300, 400 ] + + this.onEmit = this.randomStaticValueEmit; + } + else if (t === 'function') + { + // The same as setting just the onUpdate function and no onEmit (unless this op is an emitOnly one) + // Custom callback, must return a value: + + /* + x: function (particle, key, t, value) + { + return value + 50; + } + */ + + if (this.emitOnly) + { + this.onEmit = value; + } + else + { + this.onUpdate = value; + } + } + else if (t === 'object' && (this.has(value, 'random') || this.hasBoth(value, 'start', 'end') || this.hasBoth(value, 'min', 'max'))) + { + this.start = this.has(value, 'start') ? value.start : value.min; + this.end = this.has(value, 'end') ? value.end : value.max; + + var isRandom = (this.hasBoth(value, 'min', 'max') || this.has(value, 'random')); + + // A random starting value (using 'min | max' instead of 'start | end' automatically implies a random value) + + // x: { start: 100, end: 400, random: true } OR { min: 100, max: 400 } OR { random: [ 100, 400 ] } + + if (isRandom) + { + var rnd = value.random; + + // x: { random: [ 100, 400 ] } = the same as doing: x: { start: 100, end: 400, random: true } + if (Array.isArray(rnd)) + { + this.start = rnd[0]; + this.end = rnd[1]; + } + + this.onEmit = this.randomRangedValueEmit; + } + + if (this.has(value, 'steps')) + { + // A stepped (per emit) range + + // x: { start: 100, end: 400, steps: 64 } + + // Increments a value stored in the emitter + + this.steps = value.steps; + this.counter = this.start; + + this.onEmit = this.steppedEmit; + } + else + { + // An eased range (defaults to Linear if not specified) + + // x: { start: 100, end: 400, [ ease: 'Linear' ] } + + var easeType = this.has(value, 'ease') ? value.ease : 'Linear'; + + this.ease = GetEaseFunction(easeType); + + if (!isRandom) + { + this.onEmit = this.easedValueEmit; + } + + // BUG: alpha, rotate, scaleX, scaleY, or tint are eased here if {min, max} is given. + // Probably this branch should exclude isRandom entirely. + + this.onUpdate = this.easeValueUpdate; + } + } + else if (t === 'object' && this.hasEither(value, 'onEmit', 'onUpdate')) + { + // Custom onEmit and onUpdate callbacks + + /* + x: { + // Called at the start of the particles life, when it is being created + onEmit: function (particle, key, t, value) + { + return value; + }, + + // Called during the particles life on each update + onUpdate: function (particle, key, t, value) + { + return value; + } + } + */ + + if (this.has(value, 'onEmit')) + { + this.onEmit = value.onEmit; + } + + if (this.has(value, 'onUpdate')) + { + this.onUpdate = value.onUpdate; + } } + return this; + }, + + /** + * Check whether an object has the given property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#has + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key - The key of the property to look for in the object. + * + * @return {boolean} `true` if the property exists in the object, `false` otherwise. + */ + has: function (object, key) + { + return object.hasOwnProperty(key); + }, + + /** + * Check whether an object has both of the given properties. + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key1 - The key of the first property to check the object for. + * @param {string} key2 - The key of the second property to check the object for. + * + * @return {boolean} `true` if both properties exist in the object, `false` otherwise. + */ + hasBoth: function (object, key1, key2) + { + return object.hasOwnProperty(key1) && object.hasOwnProperty(key2); + }, + + /** + * Check whether an object has at least one of the given properties. + * + * @method Phaser.GameObjects.Particles.EmitterOp#hasEither + * @since 3.0.0 + * + * @param {object} object - The object to check. + * @param {string} key1 - The key of the first property to check the object for. + * @param {string} key2 - The key of the second property to check the object for. + * + * @return {boolean} `true` if at least one of the properties exists in the object, `false` if neither exist. + */ + hasEither: function (object, key1, key2) + { + return object.hasOwnProperty(key1) || object.hasOwnProperty(key2); + }, + + /** + * The returned value sets what the property will be at the START of the particles life, on emit. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} [value] - The current value of the property. + * + * @return {number} The new value of hte property. + */ + defaultEmit: function (particle, key, value) + { + return value; + }, + + /** + * The returned value updates the property for the duration of the particles life. + * + * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The T value (between 0 and 1) + * @param {number} value - The current value of the property. + * + * @return {number} The new value of the property. + */ + defaultUpdate: function (particle, key, t, value) + { + return value; + }, + + /** + * An `onEmit` callback that returns the current value of the property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit + * @since 3.0.0 + * + * @return {number} The current value of the property. + */ + staticValueEmit: function () + { + return this.propertyValue; + }, + + /** + * An `onUpdate` callback that returns the current value of the property. + * + * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate + * @since 3.0.0 + * + * @return {number} The current value of the property. + */ + staticValueUpdate: function () + { + return this.propertyValue; + }, + + /** + * An `onEmit` callback that returns a random value from the current value array. + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit + * @since 3.0.0 + * + * @return {number} The new value of the property. + */ + randomStaticValueEmit: function () + { + var randomIndex = Math.floor(Math.random() * this.propertyValue.length); + + return this.propertyValue[randomIndex]; + }, + + /** + * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The key of the property. + * + * @return {number} The new value of the property. + */ + randomRangedValueEmit: function (particle, key) + { + var value = FloatBetween(this.start, this.end); + + if (particle && particle.data[key]) + { + particle.data[key].min = value; + } + + return value; + }, + + /** + * An `onEmit` callback that returns a stepped value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit + * @since 3.0.0 + * + * @return {number} The new value of the property. + */ + steppedEmit: function () + { + var current = this.counter; + + var next = this.counter + (this.end - this.start) / this.steps; + + this.counter = Wrap(next, this.start, this.end); + + return current; + }, + + /** + * An `onEmit` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * + * @return {number} The new value of the property. + */ + easedValueEmit: function (particle, key) + { + if (particle && particle.data[key]) + { + var data = particle.data[key]; + + data.min = this.start; + data.max = this.end; + } + + return this.start; + }, + + /** + * An `onUpdate` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * + * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. + * @param {string} key - The name of the property. + * @param {number} t - The T value (between 0 and 1) + * + * @return {number} The new value of the property. + */ + easeValueUpdate: function (particle, key, t) + { + var data = particle.data[key]; + + return (data.max - data.min) * this.ease(t) + data.min; } - }); -module.exports = GravityWell; +module.exports = EmitterOp; /***/ }), -/* 459 */ +/* 823 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103269,7 +135845,30 @@ module.exports = GravityWell; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); +/** + * @namespace Phaser.GameObjects.Particles + */ + +module.exports = { + + GravityWell: __webpack_require__(304), + Particle: __webpack_require__(303), + ParticleEmitter: __webpack_require__(302), + ParticleEmitterManager: __webpack_require__(155), + Zones: __webpack_require__(818) + +}; + + +/***/ }), +/* 824 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -103288,20 +135887,15 @@ var GameObject = __webpack_require__(2); */ var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera, parentMatrix); + renderer.batchSprite(src, src.frame, camera, parentMatrix); }; module.exports = ImageCanvasRenderer; /***/ }), -/* 460 */ -/***/ (function(module, exports, __webpack_require__) { +/* 825 */ +/***/ (function(module, exports) { /** * @author Richard Davey @@ -103309,8 +135903,6 @@ module.exports = ImageCanvasRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); - /** * Renders this Game Object with the WebGL Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -103328,11 +135920,6 @@ var GameObject = __webpack_require__(2); */ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - this.pipeline.batchSprite(src, camera, parentMatrix); }; @@ -103340,7 +135927,7 @@ module.exports = ImageWebGLRenderer; /***/ }), -/* 461 */ +/* 826 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103349,17 +135936,17 @@ module.exports = ImageWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); if (true) { - renderWebGL = __webpack_require__(460); + renderWebGL = __webpack_require__(825); } if (true) { - renderCanvas = __webpack_require__(459); + renderCanvas = __webpack_require__(824); } module.exports = { @@ -103371,7 +135958,73 @@ module.exports = { /***/ }), -/* 462 */ +/* 827 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = SpriteCanvasRenderer; + + +/***/ }), +/* 828 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + this.pipeline.batchSprite(src, camera, parentMatrix); +}; + +module.exports = SpriteWebGLRenderer; + + +/***/ }), +/* 829 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103380,7 +136033,57 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = __webpack_require__(2); +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(828); +} + +if (true) +{ + renderCanvas = __webpack_require__(827); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 830 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Commands = __webpack_require__(157); +var Utils = __webpack_require__(10); + +// TODO: Remove the use of this +var Point = function (x, y, width) +{ + this.x = x; + this.y = y; + this.width = width; +}; + +// TODO: Remove the use of this +var Path = function (x, y, width) +{ + this.points = []; + this.pointsLength = 1; + this.points[0] = new Point(x, y, width); +}; + +var matrixStack = []; /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -103392,26 +136095,332 @@ var GameObject = __webpack_require__(2); * @private * * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Graphics} graphics - The Game Object being rendered in this call. + * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera, parentMatrix) +var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== graphics.renderFlags || (graphics.cameraFilter > 0 && (graphics.cameraFilter & camera._id))) + if (src.commandBuffer.length === 0) { return; } - this.pipeline.batchGraphics(this, camera, parentMatrix); + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var graphicsMatrix = pipeline._tempMatrix2; + var currentMatrix = pipeline._tempMatrix4; + + renderer.setPipeline(pipeline); + + currentMatrix.loadIdentity(); + + graphicsMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + graphicsMatrix.e = src.x; + graphicsMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(graphicsMatrix); + } + else + { + graphicsMatrix.e -= camera.scrollX * src.scrollFactorX; + graphicsMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(graphicsMatrix); + } + + var commands = src.commandBuffer; + var alpha = camera.alpha * src.alpha; + + var lineWidth = 1; + var fillTint = pipeline.fillTint; + var strokeTint = pipeline.strokeTint; + + var tx = 0; + var ty = 0; + var ta = 0; + var iterStep = 0.01; + var PI2 = Math.PI * 2; + + var cmd; + + var path = []; + var pathIndex = 0; + var pathOpen = false; + var lastPath = null; + + var getTint = Utils.getTintAppendFloatAlphaAndSwap; + + var currentTexture = renderer.blankTexture.glTexture; + + for (var cmdIndex = 0; cmdIndex < commands.length; cmdIndex++) + { + cmd = commands[cmdIndex]; + + switch (cmd) + { + case Commands.BEGIN_PATH: + + path.length = 0; + lastPath = null; + pathOpen = true; + break; + + case Commands.CLOSE_PATH: + + pathOpen = false; + + if (lastPath && lastPath.points.length) + { + lastPath.points.push(lastPath.points[0]); + } + break; + + case Commands.FILL_PATH: + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + pipeline.setTexture2D(currentTexture); + + pipeline.batchFillPath( + path[pathIndex].points, + currentMatrix, + camMatrix + ); + } + break; + + case Commands.STROKE_PATH: + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + pipeline.setTexture2D(currentTexture); + + pipeline.batchStrokePath( + path[pathIndex].points, + lineWidth, + pathOpen, + currentMatrix, + camMatrix + ); + } + break; + + case Commands.LINE_STYLE: + lineWidth = commands[++cmdIndex]; + var strokeColor = commands[++cmdIndex]; + var strokeAlpha = commands[++cmdIndex] * alpha; + var strokeTintColor = getTint(strokeColor, strokeAlpha); + strokeTint.TL = strokeTintColor; + strokeTint.TR = strokeTintColor; + strokeTint.BL = strokeTintColor; + strokeTint.BR = strokeTintColor; + break; + + case Commands.FILL_STYLE: + var fillColor = commands[++cmdIndex]; + var fillAlpha = commands[++cmdIndex] * alpha; + var fillTintColor = getTint(fillColor, fillAlpha); + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + break; + + case Commands.GRADIENT_FILL_STYLE: + var gradientFillAlpha = commands[++cmdIndex] * alpha; + fillTint.TL = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.TR = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.BL = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.BR = getTint(commands[++cmdIndex], gradientFillAlpha); + break; + + case Commands.GRADIENT_LINE_STYLE: + lineWidth = commands[++cmdIndex]; + var gradientLineAlpha = commands[++cmdIndex] * alpha; + strokeTint.TL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.TR = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BR = getTint(commands[++cmdIndex], gradientLineAlpha); + break; + + case Commands.ARC: + var iteration = 0; + var x = commands[++cmdIndex]; + var y = commands[++cmdIndex]; + var radius = commands[++cmdIndex]; + var startAngle = commands[++cmdIndex]; + var endAngle = commands[++cmdIndex]; + var anticlockwise = commands[++cmdIndex]; + var overshoot = commands[++cmdIndex]; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -PI2) + { + endAngle = -PI2; + } + else if (endAngle > 0) + { + endAngle = -PI2 + endAngle % PI2; + } + } + else if (endAngle > PI2) + { + endAngle = PI2; + } + else if (endAngle < 0) + { + endAngle = PI2 + endAngle % PI2; + } + + if (lastPath === null) + { + lastPath = new Path(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius, lineWidth); + path.push(lastPath); + iteration += iterStep; + } + + while (iteration < 1 + overshoot) + { + ta = endAngle * iteration + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.points.push(new Point(tx, ty, lineWidth)); + + iteration += iterStep; + } + + ta = endAngle + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.points.push(new Point(tx, ty, lineWidth)); + + break; + + case Commands.FILL_RECT: + pipeline.setTexture2D(currentTexture); + pipeline.batchFillRect( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + currentMatrix, + camMatrix + ); + break; + + case Commands.FILL_TRIANGLE: + pipeline.setTexture2D(currentTexture); + pipeline.batchFillTriangle( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + currentMatrix, + camMatrix + ); + break; + + case Commands.STROKE_TRIANGLE: + pipeline.setTexture2D(currentTexture); + pipeline.batchStrokeTriangle( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + lineWidth, + currentMatrix, + camMatrix + ); + break; + + case Commands.LINE_TO: + if (lastPath !== null) + { + lastPath.points.push(new Point(commands[++cmdIndex], commands[++cmdIndex], lineWidth)); + } + else + { + lastPath = new Path(commands[++cmdIndex], commands[++cmdIndex], lineWidth); + path.push(lastPath); + } + break; + + case Commands.MOVE_TO: + lastPath = new Path(commands[++cmdIndex], commands[++cmdIndex], lineWidth); + path.push(lastPath); + break; + + case Commands.SAVE: + matrixStack.push(currentMatrix.copyToArray()); + break; + + case Commands.RESTORE: + currentMatrix.copyFromArray(matrixStack.pop()); + break; + + case Commands.TRANSLATE: + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.translate(x, y); + break; + + case Commands.SCALE: + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.scale(x, y); + break; + + case Commands.ROTATE: + currentMatrix.rotate(commands[++cmdIndex]); + break; + + case Commands.SET_TEXTURE: + var frame = commands[++cmdIndex]; + var mode = commands[++cmdIndex]; + + pipeline.currentFrame = frame; + pipeline.setTexture2D(frame.glTexture, 0); + pipeline.tintEffect = mode; + + currentTexture = frame.glTexture; + + break; + + case Commands.CLEAR_TEXTURE: + pipeline.currentFrame = renderer.blankTexture; + pipeline.tintEffect = 2; + currentTexture = renderer.blankTexture.glTexture; + break; + } + } }; module.exports = GraphicsWebGLRenderer; /***/ }), -/* 463 */ +/* 831 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103420,20 +136429,20 @@ module.exports = GraphicsWebGLRenderer; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); if (true) { - renderWebGL = __webpack_require__(462); + renderWebGL = __webpack_require__(830); // Needed for Graphics.generateTexture - renderCanvas = __webpack_require__(176); + renderCanvas = __webpack_require__(305); } if (true) { - renderCanvas = __webpack_require__(176); + renderCanvas = __webpack_require__(305); } module.exports = { @@ -103445,76 +136454,7 @@ module.exports = { /***/ }), -/* 464 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Ellipse by the values given in the `x` and `y` properties of the Point object. - * - * @function Phaser.Geom.Ellipse.OffsetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Ellipse by. - * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. - */ -var OffsetPoint = function (ellipse, point) -{ - ellipse.x += point.x; - ellipse.y += point.y; - - return ellipse; -}; - -module.exports = OffsetPoint; - - -/***/ }), -/* 465 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Ellipse by the values given. - * - * @function Phaser.Geom.Ellipse.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Ellipse} O - [ellipse,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to be offset (translated.) - * @param {number} x - The amount to horizontally offset the Ellipse by. - * @param {number} y - The amount to vertically offset the Ellipse by. - * - * @return {Phaser.Geom.Ellipse} The Ellipse that was offset. - */ -var Offset = function (ellipse, x, y) -{ - ellipse.x += x; - ellipse.y += y; - - return ellipse; -}; - -module.exports = Offset; - - -/***/ }), -/* 466 */ +/* 832 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -103523,419 +136463,1894 @@ module.exports = Offset; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Rectangle = __webpack_require__(14); +var SetTransform = __webpack_require__(22); /** - * Returns the bounds of the Ellipse object. + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. * - * @function Phaser.Geom.Ellipse.GetBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the bounds from. - * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the ellipse bounds in. If not given a new Rectangle will be created. - * - * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Ellipse bounds. - */ -var GetBounds = function (ellipse, out) -{ - if (out === undefined) { out = new Rectangle(); } - - out.x = ellipse.left; - out.y = ellipse.top; - out.width = ellipse.width; - out.height = ellipse.height; - - return out; -}; - -module.exports = GetBounds; - - -/***/ }), -/* 467 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compares the `x`, `y`, `width` and `height` properties of the two given Ellipses. - * Returns `true` if they all match, otherwise returns `false`. - * - * @function Phaser.Geom.Ellipse.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The first Ellipse to compare. - * @param {Phaser.Geom.Ellipse} toCompare - The second Ellipse to compare. - * - * @return {boolean} `true` if the two Ellipse equal each other, otherwise `false`. - */ -var Equals = function (ellipse, toCompare) -{ - return ( - ellipse.x === toCompare.x && - ellipse.y === toCompare.y && - ellipse.width === toCompare.width && - ellipse.height === toCompare.height - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 468 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Copies the `x`, `y`, `width` and `height` properties from the `source` Ellipse - * into the given `dest` Ellipse, then returns the `dest` Ellipse. - * - * @function Phaser.Geom.Ellipse.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Ellipse} O - [dest,$return] - * - * @param {Phaser.Geom.Ellipse} source - The source Ellipse to copy the values from. - * @param {Phaser.Geom.Ellipse} dest - The destination Ellipse to copy the values to. - * - * @return {Phaser.Geom.Ellipse} The dest Ellipse. - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.width, source.height); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 469 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(54); - -/** - * Check to see if the Ellipse contains all four points of the given Rectangle object. - * - * @function Phaser.Geom.Ellipse.ContainsRect - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Ellipse or not. - * - * @return {boolean} True if all of the Rectangle coordinates are within the ellipse, otherwise false. - */ -var ContainsRect = function (ellipse, rect) -{ - return ( - Contains(ellipse, rect.x, rect.y) && - Contains(ellipse, rect.right, rect.y) && - Contains(ellipse, rect.x, rect.bottom) && - Contains(ellipse, rect.right, rect.bottom) - ); -}; - -module.exports = ContainsRect; - - -/***/ }), -/* 470 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(54); - -/** - * Check to see if the Ellipse contains the given Point object. - * - * @function Phaser.Geom.Ellipse.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to check. - * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. - * - * @return {boolean} True if the Point coordinates are within the circle, otherwise false. - */ -var ContainsPoint = function (ellipse, point) -{ - return Contains(ellipse, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 471 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Ellipse = __webpack_require__(114); - -/** - * Creates a new Ellipse instance based on the values contained in the given source. - * - * @function Phaser.Geom.Ellipse.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} source - The Ellipse to be cloned. Can be an instance of an Ellipse or a ellipse-like object, with x, y, width and height properties. - * - * @return {Phaser.Geom.Ellipse} A clone of the source Ellipse. - */ -var Clone = function (source) -{ - return new Ellipse(source.x, source.y, source.width, source.height); -}; - -module.exports = Clone; - - -/***/ }), -/* 472 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the area of the Ellipse. - * - * @function Phaser.Geom.Ellipse.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the area of. - * - * @return {number} The area of the Ellipse. - */ -var Area = function (ellipse) -{ - if (ellipse.isEmpty()) - { - return 0; - } - - // units squared - return (ellipse.getMajorRadius() * ellipse.getMinorRadius() * Math.PI); -}; - -module.exports = Area; - - -/***/ }), -/* 473 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Union - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Union = function (rectA, rectB, out) -{ - if (out === undefined) { out = new Rectangle(); } - - // Cache vars so we can use one of the input rects as the output rect - var x = Math.min(rectA.x, rectB.x); - var y = Math.min(rectA.y, rectB.y); - var w = Math.max(rectA.right, rectB.right) - x; - var h = Math.max(rectA.bottom, rectB.bottom) - y; - - return out.setTo(x, y, w, h); -}; - -module.exports = Union; - - -/***/ }), -/* 474 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Read an integer value from an XML Node. - * - * @function getValue + * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas * @since 3.0.0 * @private * - * @param {Node} node - The XML Node. - * @param {string} attribute - The attribute to read. - * - * @return {integer} The parsed value. + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -function getValue (node, attribute) +var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - return parseInt(node.getAttribute(attribute), 10); + var text = src.text; + var textLength = text.length; + + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + var textureFrame = src.frame; + + var displayCallback = src.displayCallback; + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + + var xAdvance = 0; + var yAdvance = 0; + + var indexCount = 0; + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + // var ctx = renderer.currentContext; + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var rotation = 0; + var scale = (src.fontSize / src.fontData.size); + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.save(); + ctx.beginPath(); + ctx.rect(0, 0, src.cropWidth, src.cropHeight); + ctx.clip(); + } + + for (var index = 0; index < textLength; ++index) + { + // Reset the scale (in case the callback changed it) + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + charCode = text.charCodeAt(index); + + if (charCode === 10) + { + xAdvance = 0; + indexCount = 0; + yAdvance += lineHeight; + lastGlyph = null; + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = (indexCount + glyph.xOffset + xAdvance) - src.scrollX; + y = (glyph.yOffset + yAdvance) - src.scrollY; + + // This could be optimized so that it doesn't even bother drawing it if the x/y is out of range + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + if (displayCallback) + { + var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + } + + x *= scale; + y *= scale; + + x -= cameraScrollX; + y -= cameraScrollY; + + if (camera.roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.rotate(rotation); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + + xAdvance += glyph.xAdvance; + indexCount += 1; + lastGlyph = glyph; + lastCharCode = charCode; + } + + if (src.cropWidth > 0 && src.cropHeight > 0) + { + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = DynamicBitmapTextCanvasRenderer; + + +/***/ }), +/* 833 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var DynamicBitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src.text; + var textLength = text.length; + + if (textLength === 0) + { + return; + } + + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var crop = (src.cropWidth > 0 || src.cropHeight > 0); + + if (crop) + { + pipeline.flush(); + + renderer.pushScissor( + src.x, + src.y, + src.cropWidth * src.scaleX, + src.cropHeight * src.scaleY + ); + } + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + var fontMatrix = pipeline._tempMatrix4; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = texture.width; + var textureHeight = texture.height; + + var tintEffect = (src._isTinted && src.tintFill); + var tintTL = Utils.getTintAppendFloatAlpha(src._tintTL, camera.alpha * src._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(src._tintTR, camera.alpha * src._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, camera.alpha * src._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, camera.alpha * src._alphaBR); + + pipeline.setTexture2D(texture, 0); + + var xAdvance = 0; + var yAdvance = 0; + var charCode = 0; + var lastCharCode = 0; + var letterSpacing = src.letterSpacing; + var glyph; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + var lastGlyph; + var scrollX = src.scrollX; + var scrollY = src.scrollY; + + var fontData = src.fontData; + var chars = fontData.chars; + var lineHeight = fontData.lineHeight; + var scale = (src.fontSize / fontData.size); + var rotation = 0; + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + var roundPixels = camera.roundPixels; + var displayCallback = src.displayCallback; + var callbackData = src.callbackData; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + // Carriage-return + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + var x = (glyph.xOffset + xAdvance) - scrollX; + var y = (glyph.yOffset + yAdvance) - scrollY; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + if (displayCallback) + { + callbackData.color = 0; + callbackData.tint.topLeft = tintTL; + callbackData.tint.topRight = tintTR; + callbackData.tint.bottomLeft = tintBL; + callbackData.tint.bottomRight = tintBR; + callbackData.index = i; + callbackData.charCode = charCode; + callbackData.x = x; + callbackData.y = y; + callbackData.scale = scale; + callbackData.rotation = rotation; + callbackData.data = glyph.data; + + var output = displayCallback(callbackData); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + + if (output.color) + { + tintTL = output.color; + tintTR = output.color; + tintBL = output.color; + tintBR = output.color; + } + else + { + tintTL = output.tint.topLeft; + tintTR = output.tint.topRight; + tintBL = output.tint.bottomLeft; + tintBR = output.tint.bottomRight; + } + + tintTL = Utils.getTintAppendFloatAlpha(tintTL, camera.alpha * src._alphaTL); + tintTR = Utils.getTintAppendFloatAlpha(tintTR, camera.alpha * src._alphaTR); + tintBL = Utils.getTintAppendFloatAlpha(tintBL, camera.alpha * src._alphaBL); + tintBR = Utils.getTintAppendFloatAlpha(tintBR, camera.alpha * src._alphaBR); + } + + x *= scale; + y *= scale; + + x -= src.displayOriginX; + y -= src.displayOriginY; + + x += lineOffsetX; + + fontMatrix.applyITRS(x, y, rotation, scale, scale); + + calcMatrix.multiply(fontMatrix, spriteMatrix); + + var u0 = glyphX / textureWidth; + var v0 = glyphY / textureHeight; + var u1 = (glyphX + glyphW) / textureWidth; + var v1 = (glyphY + glyphH) / textureHeight; + + var xw = glyphW; + var yh = glyphH; + + var tx0 = spriteMatrix.e; + var ty0 = spriteMatrix.f; + + var tx1 = yh * spriteMatrix.c + spriteMatrix.e; + var ty1 = yh * spriteMatrix.d + spriteMatrix.f; + + var tx2 = xw * spriteMatrix.a + yh * spriteMatrix.c + spriteMatrix.e; + var ty2 = xw * spriteMatrix.b + yh * spriteMatrix.d + spriteMatrix.f; + + var tx3 = xw * spriteMatrix.a + spriteMatrix.e; + var ty3 = xw * spriteMatrix.b + spriteMatrix.f; + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + + if (crop) + { + pipeline.flush(); + + renderer.popScissor(); + } +}; + +module.exports = DynamicBitmapTextWebGLRenderer; + + +/***/ }), +/* 834 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(833); } -/** - * Parse an XML font to Bitmap Font data for the Bitmap Font cache. - * - * @function ParseXMLBitmapFont - * @since 3.0.0 - * @private - * - * @param {XMLDocument} xml - The XML Document to parse the font from. - * @param {integer} [xSpacing=0] - The x-axis spacing to add between each letter. - * @param {integer} [ySpacing=0] - The y-axis spacing to add to the line height. - * @param {Phaser.Textures.Frame} [frame] - The texture frame to take into account while parsing. - * - * @return {BitmapFontData} The parsed Bitmap Font data. - */ -var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame) +if (true) { - if (xSpacing === undefined) { xSpacing = 0; } - if (ySpacing === undefined) { ySpacing = 0; } + renderCanvas = __webpack_require__(832); +} - var data = {}; - var info = xml.getElementsByTagName('info')[0]; - var common = xml.getElementsByTagName('common')[0]; +module.exports = { - data.font = info.getAttribute('face'); - data.size = getValue(info, 'size'); - data.lineHeight = getValue(common, 'lineHeight') + ySpacing; - data.chars = {}; + renderWebGL: renderWebGL, + renderCanvas: renderCanvas - var letters = xml.getElementsByTagName('char'); - - var adjustForTrim = (frame !== undefined && frame.trimmed); - - if (adjustForTrim) - { - var top = frame.height; - var left = frame.width; - } - - for (var i = 0; i < letters.length; i++) - { - var node = letters[i]; - - var charCode = getValue(node, 'id'); - var gx = getValue(node, 'x'); - var gy = getValue(node, 'y'); - var gw = getValue(node, 'width'); - var gh = getValue(node, 'height'); - - // Handle frame trim issues - - if (adjustForTrim) - { - if (gx < left) - { - left = gx; - } - - if (gy < top) - { - top = gy; - } - } - - data.chars[charCode] = - { - x: gx, - y: gy, - width: gw, - height: gh, - centerX: Math.floor(gw / 2), - centerY: Math.floor(gh / 2), - xOffset: getValue(node, 'xoffset'), - yOffset: getValue(node, 'yoffset'), - xAdvance: getValue(node, 'xadvance') + xSpacing, - data: {}, - kerning: {} - }; - } - - if (adjustForTrim && top !== 0 && left !== 0) - { - // console.log('top and left', top, left, frame.x, frame.y); - - // Now we know the top and left coordinates of the glyphs in the original data - // so we can work out how much to adjust the glyphs by - - for (var code in data.chars) - { - var glyph = data.chars[code]; - - glyph.x -= frame.x; - glyph.y -= frame.y; - } - } - - var kernings = xml.getElementsByTagName('kerning'); - - for (i = 0; i < kernings.length; i++) - { - var kern = kernings[i]; - - var first = getValue(kern, 'first'); - var second = getValue(kern, 'second'); - var amount = getValue(kern, 'amount'); - - data.chars[second].kerning[first] = amount; - } - - return data; }; -module.exports = ParseXMLBitmapFont; - /***/ }), -/* 475 */ +/* 835 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Container#renderCanvas + * @since 3.4.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ContainerCanvasRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) +{ + var children = container.list; + + if (children.length === 0) + { + return; + } + + var transformMatrix = container.localTransform; + + if (parentMatrix) + { + transformMatrix.loadIdentity(); + transformMatrix.multiply(parentMatrix); + transformMatrix.translate(container.x, container.y); + transformMatrix.rotate(container.rotation); + transformMatrix.scale(container.scaleX, container.scaleY); + } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode) + { + // If Container is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } + + var alpha = container._alpha; + var scrollFactorX = container.scrollFactorX; + var scrollFactorY = container.scrollFactorY; + + for (var i = 0; i < children.length; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlpha = child._alpha; + var childBlendMode = child._blendMode; + var childScrollFactorX = child.scrollFactorX; + var childScrollFactorY = child.scrollFactorY; + + // Set parent values + child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); + child.setAlpha(childAlpha * alpha); + + if (containerHasBlendMode) + { + child.setBlendMode(container._blendMode); + } + + // Render + child.renderCanvas(renderer, child, interpolationPercentage, camera, transformMatrix); + + // Restore original values + child.setAlpha(childAlpha); + child.setScrollFactor(childScrollFactorX, childScrollFactorY); + child.setBlendMode(childBlendMode); + } +}; + +module.exports = ContainerCanvasRenderer; + + +/***/ }), +/* 836 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Container#renderWebGL + * @since 3.4.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ContainerWebGLRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) +{ + var children = container.list; + + if (children.length === 0) + { + return; + } + + var transformMatrix = container.localTransform; + + if (parentMatrix) + { + transformMatrix.loadIdentity(); + transformMatrix.multiply(parentMatrix); + transformMatrix.translate(container.x, container.y); + transformMatrix.rotate(container.rotation); + transformMatrix.scale(container.scaleX, container.scaleY); + } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode) + { + // If Container is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } + + var alpha = container._alpha; + var scrollFactorX = container.scrollFactorX; + var scrollFactorY = container.scrollFactorY; + + for (var i = 0; i < children.length; i++) + { + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + + var childAlpha = child._alpha; + var childScrollFactorX = child.scrollFactorX; + var childScrollFactorY = child.scrollFactorY; + + if (!containerHasBlendMode && child.blendMode !== renderer.currentBlendMode) + { + // If Container doesn't have its own blend mode, then a child can have one + renderer.setBlendMode(child.blendMode); + } + + // Set parent values + child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); + child.setAlpha(childAlpha * alpha); + + // Render + child.renderWebGL(renderer, child, interpolationPercentage, camera, transformMatrix); + + // Restore original values + child.setAlpha(childAlpha); + child.setScrollFactor(childScrollFactorX, childScrollFactorY); + } +}; + +module.exports = ContainerWebGLRenderer; + + +/***/ }), +/* 837 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @author Felipe Alfonso <@bitnenfer> + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(836); +} + +if (true) +{ + renderCanvas = __webpack_require__(835); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 838 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Bob Game Object. + * + * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * + * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle + * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it + * must be a Frame within the Texture used by the parent Blitter. + * + * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will + * have their positions impacted by this change as well. + * + * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be + * handled via the Blitter parent. + * + * @class Bob + * @memberof Phaser.GameObjects.Blitter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. + * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. + * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. + * @param {(string|integer)} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. + * @param {boolean} visible - Should the Bob render visible or not to start with? + */ +var Bob = new Class({ + + initialize: + + function Bob (blitter, x, y, frame, visible) + { + /** + * The Blitter object that this Bob belongs to. + * + * @name Phaser.GameObjects.Blitter.Bob#parent + * @type {Phaser.GameObjects.Blitter} + * @since 3.0.0 + */ + this.parent = blitter; + + /** + * The x position of this Bob, relative to the x position of the Blitter. + * + * @name Phaser.GameObjects.Blitter.Bob#x + * @type {number} + * @since 3.0.0 + */ + this.x = x; + + /** + * The y position of this Bob, relative to the y position of the Blitter. + * + * @name Phaser.GameObjects.Blitter.Bob#y + * @type {number} + * @since 3.0.0 + */ + this.y = y; + + /** + * The frame that the Bob uses to render with. + * To change the frame use the `Bob.setFrame` method. + * + * @name Phaser.GameObjects.Blitter.Bob#frame + * @type {Phaser.Textures.Frame} + * @protected + * @since 3.0.0 + */ + this.frame = frame; + + /** + * A blank object which can be used to store data related to this Bob in. + * + * @name Phaser.GameObjects.Blitter.Bob#data + * @type {object} + * @default {} + * @since 3.0.0 + */ + this.data = {}; + + /** + * The visible state of this Bob. + * + * @name Phaser.GameObjects.Blitter.Bob#_visible + * @type {boolean} + * @private + * @since 3.0.0 + */ + this._visible = visible; + + /** + * The alpha value of this Bob. + * + * @name Phaser.GameObjects.Blitter.Bob#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._alpha = 1; + + /** + * The horizontally flipped state of the Bob. + * A Bob that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture. + * + * @name Phaser.GameObjects.Blitter.Bob#flipX + * @type {boolean} + * @since 3.0.0 + */ + this.flipX = false; + + /** + * The vertically flipped state of the Bob. + * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture. + * + * @name Phaser.GameObjects.Blitter.Bob#flipY + * @type {boolean} + * @since 3.0.0 + */ + this.flipY = false; + }, + + /** + * Changes the Texture Frame being used by this Bob. + * The frame must be part of the Texture the parent Blitter is using. + * If no value is given it will use the default frame of the Blitter parent. + * + * @method Phaser.GameObjects.Blitter.Bob#setFrame + * @since 3.0.0 + * + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The frame to be used during rendering. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFrame: function (frame) + { + if (frame === undefined) + { + this.frame = this.parent.frame; + } + else + { + this.frame = this.parent.texture.get(frame); + } + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. + * + * @method Phaser.GameObjects.Blitter.Bob#resetFlip + * @since 3.0.0 + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + }, + + /** + * Resets this Bob. + * + * Changes the position to the values given, and optionally changes the frame. + * + * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. + * + * @method Phaser.GameObjects.Blitter.Bob#reset + * @since 3.0.0 + * + * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + reset: function (x, y, frame) + { + this.x = x; + this.y = y; + + this.flipX = false; + this.flipY = false; + + this._alpha = 1; + this._visible = true; + + this.parent.dirty = true; + + if (frame) + { + this.setFrame(frame); + } + + return this; + }, + + /** + * Sets the horizontal flipped state of this Bob. + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Bob. + * + * @method Phaser.GameObjects.Blitter.Bob#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Bob. + * + * @method Phaser.GameObjects.Blitter.Bob#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Sets the visibility of this Bob. + * + * An invisible Bob will skip rendering. + * + * @method Phaser.GameObjects.Blitter.Bob#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + }, + + /** + * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * A Bob with alpha 0 will skip rendering. + * + * @method Phaser.GameObjects.Blitter.Bob#setAlpha + * @since 3.0.0 + * + * @param {number} value - The alpha value used for this Bob. Between 0 and 1. + * + * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. + */ + setAlpha: function (value) + { + this.alpha = value; + + return this; + }, + + /** + * Destroys this Bob instance. + * Removes itself from the Blitter and clears the parent, frame and data properties. + * + * @method Phaser.GameObjects.Blitter.Bob#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.parent.dirty = true; + + this.parent.children.remove(this); + + this.parent = undefined; + this.frame = undefined; + this.data = undefined; + }, + + /** + * The visible state of the Bob. + * + * An invisible Bob will skip rendering. + * + * @name Phaser.GameObjects.Blitter.Bob#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + this._visible = value; + this.parent.dirty = true; + } + + }, + + /** + * The alpha value of the Bob, between 0 and 1. + * + * A Bob with alpha 0 will skip rendering. + * + * @name Phaser.GameObjects.Blitter.Bob#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + this._alpha = value; + this.parent.dirty = true; + } + + } + +}); + +module.exports = Bob; + + +/***/ }), +/* 839 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var list = src.getRenderList(); + + if (list.length === 0) + { + return; + } + + var ctx = renderer.currentContext; + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + + // Blend Mode + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + + var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; + var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; + + ctx.save(); + + if (parentMatrix) + { + parentMatrix.copyToContext(ctx); + } + + var roundPixels = camera.roundPixels; + + // Render bobs + for (var i = 0; i < list.length; i++) + { + var bob = list[i]; + var flip = (bob.flipX || bob.flipY); + var frame = bob.frame; + var cd = frame.canvasData; + var dx = frame.x; + var dy = frame.y; + var fx = 1; + var fy = 1; + + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + + ctx.globalAlpha = bobAlpha; + + if (!flip) + { + if (roundPixels) + { + dx |= 0; + dy |= 0; + } + + ctx.drawImage( + frame.source.image, + cd.x, + cd.y, + cd.width, + cd.height, + dx + bob.x + cameraScrollX, + dy + bob.y + cameraScrollY, + cd.width, + cd.height + ); + } + else + { + if (bob.flipX) + { + fx = -1; + dx -= cd.width; + } + + if (bob.flipY) + { + fy = -1; + dy -= cd.height; + } + + ctx.save(); + ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); + ctx.scale(fx, fy); + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, dx, dy, cd.width, cd.height); + ctx.restore(); + } + } + + ctx.restore(); +}; + +module.exports = BlitterCanvasRenderer; + + +/***/ }), +/* 840 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Blitter#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var list = src.getRenderList(); + + if (list.length === 0) + { + return; + } + + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + + var calcMatrix = pipeline._tempMatrix1; + + calcMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + calcMatrix.multiplyWithOffset(parentMatrix, -cameraScrollX, -cameraScrollY); + + cameraScrollX = 0; + cameraScrollY = 0; + } + + var blitterX = src.x - cameraScrollX; + var blitterY = src.y - cameraScrollY; + var prevTextureSourceIndex = -1; + var tintEffect = false; + var alpha = camera.alpha * src.alpha; + var roundPixels = camera.roundPixels; + + for (var index = 0; index < list.length; index++) + { + var bob = list[index]; + var frame = bob.frame; + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + + var width = frame.width; + var height = frame.height; + + var x = blitterX + bob.x + frame.x; + var y = blitterY + bob.y + frame.y; + + if (bob.flipX) + { + width *= -1; + x += frame.width; + } + + if (bob.flipY) + { + height *= -1; + y += frame.height; + } + + var xw = x + width; + var yh = y + height; + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(xw, yh); + var ty1 = calcMatrix.getY(xw, yh); + + var tint = Utils.getTintAppendFloatAlpha(0xffffff, bobAlpha); + + // Bind texture only if the Texture Source is different from before + if (frame.sourceIndex !== prevTextureSourceIndex) + { + pipeline.setTexture2D(frame.glTexture, 0); + + prevTextureSourceIndex = frame.sourceIndex; + } + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + } + + // TL x/y, BL x/y, BR x/y, TR x/y + if (pipeline.batchQuad(tx0, ty0, tx0, ty1, tx1, ty1, tx1, ty0, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect)) + { + prevTextureSourceIndex = -1; + } + } +}; + +module.exports = BlitterWebGLRenderer; + + +/***/ }), +/* 841 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(840); +} + +if (true) +{ + renderCanvas = __webpack_require__(839); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 842 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTransform = __webpack_require__(22); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.BitmapText#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src._text; + var textLength = text.length; + + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + return; + } + + var textureFrame = src.frame; + + var chars = src.fontData.chars; + var lineHeight = src.fontData.lineHeight; + var letterSpacing = src._letterSpacing; + + var xAdvance = 0; + var yAdvance = 0; + + var charCode = 0; + + var glyph = null; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + + var x = 0; + var y = 0; + + var lastGlyph = null; + var lastCharCode = 0; + + var image = src.frame.source.image; + + var textureX = textureFrame.cutX; + var textureY = textureFrame.cutY; + + var scale = (src._fontSize / src.fontData.size); + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + ctx.translate(-src.displayOriginX, -src.displayOriginY); + + var roundPixels = camera.roundPixels; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + x = glyph.xOffset + xAdvance; + y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + x *= scale; + y *= scale; + + x += lineOffsetX; + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + if (roundPixels) + { + x |= 0; + y |= 0; + } + + ctx.save(); + + ctx.translate(x, y); + + ctx.scale(scale, scale); + + ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); + + ctx.restore(); + } + + ctx.restore(); +}; + +module.exports = BitmapTextCanvasRenderer; + + +/***/ }), +/* 843 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = __webpack_require__(10); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.BitmapText#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var BitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var text = src._text; + var textLength = text.length; + + if (textLength === 0) + { + return; + } + + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = texture.width; + var textureHeight = texture.height; + + var tintEffect = (src._isTinted && src.tintFill); + var tintTL = Utils.getTintAppendFloatAlpha(src._tintTL, camera.alpha * src._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(src._tintTR, camera.alpha * src._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, camera.alpha * src._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, camera.alpha * src._alphaBR); + + pipeline.setTexture2D(texture, 0); + + var xAdvance = 0; + var yAdvance = 0; + var charCode = 0; + var lastCharCode = 0; + var letterSpacing = src._letterSpacing; + var glyph; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + var lastGlyph; + + var fontData = src.fontData; + var chars = fontData.chars; + var lineHeight = fontData.lineHeight; + var scale = (src._fontSize / fontData.size); + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + var roundPixels = camera.roundPixels; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + // Carriage-return + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + var x = glyph.xOffset + xAdvance; + var y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + x *= scale; + y *= scale; + + x -= src.displayOriginX; + y -= src.displayOriginY; + + x += lineOffsetX; + + var u0 = glyphX / textureWidth; + var v0 = glyphY / textureHeight; + var u1 = (glyphX + glyphW) / textureWidth; + var v1 = (glyphY + glyphH) / textureHeight; + + var xw = x + (glyphW * scale); + var yh = y + (glyphH * scale); + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (roundPixels) + { + tx0 |= 0; + ty0 |= 0; + + tx1 |= 0; + ty1 |= 0; + + tx2 |= 0; + ty2 |= 0; + + tx3 |= 0; + ty3 |= 0; + } + + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } +}; + +module.exports = BitmapTextWebGLRenderer; + + +/***/ }), +/* 844 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(1); +var renderCanvas = __webpack_require__(1); + +if (true) +{ + renderWebGL = __webpack_require__(843); +} + +if (true) +{ + renderCanvas = __webpack_require__(842); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 845 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ParseXMLBitmapFont = __webpack_require__(310); + +/** + * Parse an XML Bitmap Font from an Atlas. + * + * Adds the parsed Bitmap Font data to the cache with the `fontName` key. + * + * @function ParseFromAtlas + * @since 3.0.0 + * @private + * + * @param {Phaser.Scene} scene - The Scene to parse the Bitmap Font for. + * @param {string} fontName - The key of the font to add to the Bitmap Font cache. + * @param {string} textureKey - The key of the BitmapFont's texture. + * @param {string} frameKey - The key of the BitmapFont texture's frame. + * @param {string} xmlKey - The key of the XML data of the font to parse. + * @param {integer} xSpacing - The x-axis spacing to add between each letter. + * @param {integer} ySpacing - The y-axis spacing to add to the line height. + * + * @return {boolean} Whether the parsing was successful or not. + */ +var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) +{ + var frame = scene.sys.textures.getFrame(textureKey, frameKey); + var xml = scene.sys.cache.xml.get(xmlKey); + + if (frame && xml) + { + var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame); + + scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey }); + + return true; + } + else + { + return false; + } +}; + +module.exports = ParseFromAtlas; + + +/***/ }), +/* 846 */ /***/ (function(module, exports) { /** @@ -103989,11 +138404,35 @@ module.exports = ParseXMLBitmapFont; * * @param {(Phaser.GameObjects.DynamicBitmapText|Phaser.GameObjects.BitmapText)} src - The BitmapText to calculate the position, width and height of. * @param {boolean} [round] - Whether to round the results to the nearest integer. + * @param {object} [out] - Optional object to store the results in, to save constant object creation. * * @return {BitmapTextSize} The calculated position, width and height of the BitmapText. */ -var GetBitmapTextSize = function (src, round) +var GetBitmapTextSize = function (src, round, out) { + if (out === undefined) + { + out = { + local: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + global: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + lines: { + shortest: 0, + longest: 0, + lengths: null + } + }; + } + var text = src.text; var textLength = text.length; @@ -104009,29 +138448,49 @@ var GetBitmapTextSize = function (src, round) var xAdvance = 0; var yAdvance = 0; - var indexCount = 0; var charCode = 0; var glyph = null; - var glyphW = 0; - var glyphH = 0; var x = 0; var y = 0; + var scale = (src.fontSize / src.fontData.size); + var sx = scale * src.scaleX; + var sy = scale * src.scaleY; + var lastGlyph = null; var lastCharCode = 0; + var lineWidths = []; + var shortestLine = Number.MAX_VALUE; + var longestLine = 0; + var currentLine = 0; + var currentLineWidth = 0; - for (var index = 0; index < textLength; ++index) + for (var i = 0; i < textLength; i++) { - charCode = text.charCodeAt(index); + charCode = text.charCodeAt(i); if (charCode === 10) { xAdvance = 0; - indexCount = 0; yAdvance += lineHeight; lastGlyph = null; + + lineWidths[currentLine] = currentLineWidth; + + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + currentLine++; + currentLineWidth = 0; continue; } @@ -104042,11 +138501,8 @@ var GetBitmapTextSize = function (src, round) continue; } - glyphW = glyph.width; - glyphH = glyph.height; - - x = indexCount + glyph.xOffset + xAdvance; - y = glyph.yOffset + yAdvance; + x = xAdvance; + y = yAdvance; if (lastGlyph !== null) { @@ -104064,8 +138520,8 @@ var GetBitmapTextSize = function (src, round) by = y; } - var gw = x + glyphW - bx; - var gh = y + glyphH - by; + var gw = x + glyph.xAdvance; + var gh = y + lineHeight; if (bw < gw) { @@ -104078,41 +138534,55 @@ var GetBitmapTextSize = function (src, round) } xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; lastGlyph = glyph; lastCharCode = charCode; + currentLineWidth = gw * scale; } - var scale = (src.fontSize / src.fontData.size); - var sx = scale * src.scaleX; - var sy = scale * src.scaleY; + lineWidths[currentLine] = currentLineWidth; - var out = { - local: { - x: bx * scale, - y: by * scale, - width: bw * scale, - height: bh * scale - }, - global: { - x: src.x + (bx * sx), - y: src.y + (by * sy), - width: bw * sx, - height: bh * sy - } - }; + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + var local = out.local; + var global = out.global; + var lines = out.lines; + + local.x = bx * scale; + local.y = by * scale; + local.width = bw * scale; + local.height = bh * scale; + + global.x = (src.x - src.displayOriginX) + (bx * sx); + global.y = (src.y - src.displayOriginY) + (by * sy); + global.width = bw * sx; + global.height = bh * sy; + + lines.shortest = shortestLine; + lines.longest = longestLine; + lines.lengths = lineWidths; if (round) { - out.local.x = Math.round(out.local.x); - out.local.y = Math.round(out.local.y); - out.local.width = Math.round(out.local.width); - out.local.height = Math.round(out.local.height); + local.x = Math.round(local.x); + local.y = Math.round(local.y); + local.width = Math.round(local.width); + local.height = Math.round(local.height); - out.global.x = Math.round(out.global.x); - out.global.y = Math.round(out.global.y); - out.global.width = Math.round(out.global.width); - out.global.height = Math.round(out.global.height); + global.x = Math.round(global.x); + global.y = Math.round(global.y); + global.width = Math.round(global.width); + global.height = Math.round(global.height); + + lines.shortest = Math.round(shortestLine); + lines.longest = Math.round(longestLine); } return out; @@ -104122,7 +138592,7 @@ module.exports = GetBitmapTextSize; /***/ }), -/* 476 */ +/* 847 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -104132,7 +138602,7 @@ module.exports = GetBitmapTextSize; */ var Class = __webpack_require__(0); -var PluginCache = __webpack_require__(12); +var PluginCache = __webpack_require__(15); /** * @classdesc @@ -104143,7 +138613,7 @@ var PluginCache = __webpack_require__(12); * Some or all of these Game Objects may also be part of the Scene's [Display List]{@link Phaser.GameObjects.DisplayList}, for Rendering. * * @class UpdateList - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -104381,7 +138851,26 @@ var UpdateList = new Class({ */ shutdown: function () { - this.removeAll(); + var i = this._list.length; + + while (i--) + { + this._list[i].destroy(true); + } + + i = this._pendingRemoval.length; + + while (i--) + { + this._pendingRemoval[i].destroy(true); + } + + i = this._pendingInsertion.length; + + while (i--) + { + this._pendingInsertion[i].destroy(true); + } this._list.length = 0; this._pendingRemoval.length = 0; @@ -104416,7 +138905,7 @@ var UpdateList = new Class({ * * @name Phaser.GameObjects.UpdateList#length * @type {integer} - * @readOnly + * @readonly * @since 3.10.0 */ length: { @@ -104436,7 +138925,7 @@ module.exports = UpdateList; /***/ }), -/* 477 */ +/* 848 */ /***/ (function(module, exports) { /** @@ -104484,7 +138973,7 @@ module.exports = Swap; /***/ }), -/* 478 */ +/* 849 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -104493,7 +138982,7 @@ module.exports = Swap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Scans the array for elements with the given property. If found, the property is set to the `value`. @@ -104539,7 +139028,7 @@ module.exports = SetAll; /***/ }), -/* 479 */ +/* 850 */ /***/ (function(module, exports) { /** @@ -104577,7 +139066,7 @@ module.exports = SendToBack; /***/ }), -/* 480 */ +/* 851 */ /***/ (function(module, exports) { /** @@ -104620,7 +139109,7 @@ module.exports = Replace; /***/ }), -/* 481 */ +/* 852 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -104629,7 +139118,7 @@ module.exports = Replace; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SpliceOne = __webpack_require__(56); +var SpliceOne = __webpack_require__(91); /** * Removes a random object from the given array and returns it. @@ -104658,7 +139147,7 @@ module.exports = RemoveRandomElement; /***/ }), -/* 482 */ +/* 853 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -104667,7 +139156,7 @@ module.exports = RemoveRandomElement; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Removes the item within the given range in the array. @@ -104721,7 +139210,7 @@ module.exports = RemoveBetween; /***/ }), -/* 483 */ +/* 854 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -104730,7 +139219,7 @@ module.exports = RemoveBetween; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SpliceOne = __webpack_require__(56); +var SpliceOne = __webpack_require__(91); /** * Removes the item from the given position in the array. @@ -104772,7 +139261,7 @@ module.exports = RemoveAt; /***/ }), -/* 484 */ +/* 855 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -104781,7 +139270,7 @@ module.exports = RemoveAt; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RoundAwayFromZero = __webpack_require__(255); +var RoundAwayFromZero = __webpack_require__(314); /** * Create an array of numbers (positive and/or negative) progressing from `start` @@ -104849,7 +139338,7 @@ module.exports = NumberArrayStep; /***/ }), -/* 485 */ +/* 856 */ /***/ (function(module, exports) { /** @@ -104913,7 +139402,7 @@ module.exports = NumberArray; /***/ }), -/* 486 */ +/* 857 */ /***/ (function(module, exports) { /** @@ -104955,7 +139444,7 @@ module.exports = MoveUp; /***/ }), -/* 487 */ +/* 858 */ /***/ (function(module, exports) { /** @@ -105002,7 +139491,7 @@ module.exports = MoveTo; /***/ }), -/* 488 */ +/* 859 */ /***/ (function(module, exports) { /** @@ -105044,7 +139533,7 @@ module.exports = MoveDown; /***/ }), -/* 489 */ +/* 860 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105053,7 +139542,7 @@ module.exports = MoveDown; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Returns the first element in the array. @@ -105103,7 +139592,7 @@ module.exports = GetFirst; /***/ }), -/* 490 */ +/* 861 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105112,7 +139601,7 @@ module.exports = GetFirst; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Returns all elements in the array. @@ -105165,7 +139654,7 @@ module.exports = GetAll; /***/ }), -/* 491 */ +/* 862 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105174,7 +139663,7 @@ module.exports = GetAll; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Passes each element in the array, between the start and end indexes, to the given callback. @@ -105221,7 +139710,7 @@ module.exports = EachInRange; /***/ }), -/* 492 */ +/* 863 */ /***/ (function(module, exports) { /** @@ -105239,7 +139728,7 @@ module.exports = EachInRange; * @param {array} array - The array to search. * @param {function} callback - A callback to be invoked for each item in the array. * @param {object} context - The context in which the callback is invoked. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the current array item. * * @return {array} The input array. */ @@ -105248,7 +139737,7 @@ var Each = function (array, callback, context) var i; var args = [ null ]; - for (i = 2; i < arguments.length; i++) + for (i = 3; i < arguments.length; i++) { args.push(arguments[i]); } @@ -105267,7 +139756,7 @@ module.exports = Each; /***/ }), -/* 493 */ +/* 864 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105276,7 +139765,7 @@ module.exports = Each; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var SafeRange = __webpack_require__(29); +var SafeRange = __webpack_require__(62); /** * Returns the total number of elements in the array which have a property matching the given value. @@ -105319,7 +139808,7 @@ module.exports = CountAllMatching; /***/ }), -/* 494 */ +/* 865 */ /***/ (function(module, exports) { /** @@ -105357,7 +139846,7 @@ module.exports = BringToTop; /***/ }), -/* 495 */ +/* 866 */ /***/ (function(module, exports) { /** @@ -105460,7 +139949,7 @@ var AddAt = function (array, item, index, limit, callback, context) itemLength = remaining; } - for (var i = itemLength; i > 0; i--) + for (var i = itemLength - 1; i >= 0; i--) { var entry = item[i]; @@ -105479,7 +139968,7 @@ module.exports = AddAt; /***/ }), -/* 496 */ +/* 867 */ /***/ (function(module, exports) { /** @@ -105596,7 +140085,7 @@ module.exports = Add; /***/ }), -/* 497 */ +/* 868 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105605,7 +140094,7 @@ module.exports = Add; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateMatrix = __webpack_require__(77); +var RotateMatrix = __webpack_require__(111); /** * [description] @@ -105626,7 +140115,7 @@ module.exports = RotateRight; /***/ }), -/* 498 */ +/* 869 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105635,7 +140124,7 @@ module.exports = RotateRight; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateMatrix = __webpack_require__(77); +var RotateMatrix = __webpack_require__(111); /** * [description] @@ -105656,7 +140145,7 @@ module.exports = RotateLeft; /***/ }), -/* 499 */ +/* 870 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105665,7 +140154,7 @@ module.exports = RotateLeft; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateMatrix = __webpack_require__(77); +var RotateMatrix = __webpack_require__(111); /** * [description] @@ -105686,7 +140175,7 @@ module.exports = Rotate180; /***/ }), -/* 500 */ +/* 871 */ /***/ (function(module, exports) { /** @@ -105714,7 +140203,7 @@ module.exports = ReverseRows; /***/ }), -/* 501 */ +/* 872 */ /***/ (function(module, exports) { /** @@ -105724,14 +140213,14 @@ module.exports = ReverseRows; */ /** - * [description] + * Reverses the columns in the given Array Matrix. * * @function Phaser.Utils.Array.Matrix.ReverseColumns * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - The array matrix to reverse the columns for. * - * @return {array} [description] + * @return {array} The column reversed matrix. */ var ReverseColumns = function (matrix) { @@ -105747,7 +140236,7 @@ module.exports = ReverseColumns; /***/ }), -/* 502 */ +/* 873 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105756,21 +140245,21 @@ module.exports = ReverseColumns; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Pad = __webpack_require__(133); -var CheckMatrix = __webpack_require__(116); +var Pad = __webpack_require__(179); +var CheckMatrix = __webpack_require__(163); // Generates a string (which you can pass to console.log) from the given // Array Matrix. /** - * [description] + * Generates a string (which you can pass to console.log) from the given Array Matrix. * * @function Phaser.Utils.Array.Matrix.MatrixToString * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - A 2-dimensional array. * - * @return {string} [description] + * @return {string} A string representing the matrix. */ var MatrixToString = function (matrix) { @@ -105828,7 +140317,7 @@ module.exports = MatrixToString; /***/ }), -/* 503 */ +/* 874 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105843,21 +140332,21 @@ module.exports = MatrixToString; module.exports = { - CheckMatrix: __webpack_require__(116), - MatrixToString: __webpack_require__(502), - ReverseColumns: __webpack_require__(501), - ReverseRows: __webpack_require__(500), - Rotate180: __webpack_require__(499), - RotateLeft: __webpack_require__(498), - RotateMatrix: __webpack_require__(77), - RotateRight: __webpack_require__(497), - TransposeMatrix: __webpack_require__(181) + CheckMatrix: __webpack_require__(163), + MatrixToString: __webpack_require__(873), + ReverseColumns: __webpack_require__(872), + ReverseRows: __webpack_require__(871), + Rotate180: __webpack_require__(870), + RotateLeft: __webpack_require__(869), + RotateMatrix: __webpack_require__(111), + RotateRight: __webpack_require__(868), + TransposeMatrix: __webpack_require__(315) }; /***/ }), -/* 504 */ +/* 875 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -105867,9 +140356,9 @@ module.exports = { */ var Class = __webpack_require__(0); -var List = __webpack_require__(93); -var PluginCache = __webpack_require__(12); -var StableSort = __webpack_require__(83); +var List = __webpack_require__(112); +var PluginCache = __webpack_require__(15); +var StableSort = __webpack_require__(110); /** * @classdesc @@ -105881,7 +140370,7 @@ var StableSort = __webpack_require__(83); * * @class DisplayList * @extends Phaser.Structs.List. - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -106038,6 +140527,19 @@ var DisplayList = new Class({ return gameObjects[gameObjects.length - 1]; }, + /** + * All members of the group. + * + * @method Phaser.GameObjects.DisplayList#getChildren + * @since 3.12.0 + * + * @return {Phaser.GameObjects.GameObject[]} The group members. + */ + getChildren: function () + { + return this.list; + }, + /** * 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. @@ -106048,7 +140550,14 @@ var DisplayList = new Class({ */ shutdown: function () { - this.removeAll(); + var i = this.list.length; + + while (i--) + { + this.list[i].destroy(true); + } + + this.list.length = 0; this.systems.events.off('shutdown', this.shutdown, this); }, @@ -106079,7 +140588,138 @@ module.exports = DisplayList; /***/ }), -/* 505 */ +/* 876 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects + */ + +var GameObjects = { + + DisplayList: __webpack_require__(875), + GameObjectCreator: __webpack_require__(13), + GameObjectFactory: __webpack_require__(5), + UpdateList: __webpack_require__(847), + + Components: __webpack_require__(14), + + BuildGameObject: __webpack_require__(28), + BuildGameObjectAnimation: __webpack_require__(311), + GameObject: __webpack_require__(19), + BitmapText: __webpack_require__(109), + Blitter: __webpack_require__(161), + Container: __webpack_require__(160), + DynamicBitmapText: __webpack_require__(159), + Graphics: __webpack_require__(158), + Group: __webpack_require__(88), + Image: __webpack_require__(87), + Particles: __webpack_require__(823), + PathFollower: __webpack_require__(296), + RenderTexture: __webpack_require__(154), + RetroFont: __webpack_require__(814), + Sprite: __webpack_require__(61), + Text: __webpack_require__(153), + TileSprite: __webpack_require__(152), + Zone: __webpack_require__(125), + + // Shapes + + Shape: __webpack_require__(27), + Arc: __webpack_require__(293), + Curve: __webpack_require__(292), + Ellipse: __webpack_require__(291), + Grid: __webpack_require__(290), + IsoBox: __webpack_require__(289), + IsoTriangle: __webpack_require__(288), + Line: __webpack_require__(287), + Polygon: __webpack_require__(286), + Rectangle: __webpack_require__(281), + Star: __webpack_require__(280), + Triangle: __webpack_require__(279), + + // Game Object Factories + + Factories: { + Blitter: __webpack_require__(769), + Container: __webpack_require__(768), + DynamicBitmapText: __webpack_require__(767), + Graphics: __webpack_require__(766), + Group: __webpack_require__(765), + Image: __webpack_require__(764), + Particles: __webpack_require__(763), + PathFollower: __webpack_require__(762), + RenderTexture: __webpack_require__(761), + Sprite: __webpack_require__(760), + StaticBitmapText: __webpack_require__(759), + Text: __webpack_require__(758), + TileSprite: __webpack_require__(757), + Zone: __webpack_require__(756), + + // Shapes + Arc: __webpack_require__(755), + Curve: __webpack_require__(754), + Ellipse: __webpack_require__(753), + Grid: __webpack_require__(752), + IsoBox: __webpack_require__(751), + IsoTriangle: __webpack_require__(750), + Line: __webpack_require__(749), + Polygon: __webpack_require__(748), + Rectangle: __webpack_require__(747), + Star: __webpack_require__(746), + Triangle: __webpack_require__(745) + }, + + Creators: { + Blitter: __webpack_require__(744), + Container: __webpack_require__(743), + DynamicBitmapText: __webpack_require__(742), + Graphics: __webpack_require__(741), + Group: __webpack_require__(740), + Image: __webpack_require__(739), + Particles: __webpack_require__(738), + RenderTexture: __webpack_require__(737), + Sprite: __webpack_require__(736), + StaticBitmapText: __webpack_require__(735), + Text: __webpack_require__(734), + TileSprite: __webpack_require__(733), + Zone: __webpack_require__(732) + } + +}; + +if (false) +{} + +if (true) +{ + // WebGL only Game Objects + GameObjects.Mesh = __webpack_require__(108); + GameObjects.Quad = __webpack_require__(149); + + GameObjects.Factories.Mesh = __webpack_require__(728); + GameObjects.Factories.Quad = __webpack_require__(727); + + GameObjects.Creators.Mesh = __webpack_require__(726); + GameObjects.Creators.Quad = __webpack_require__(725); + + GameObjects.Light = __webpack_require__(276); + + __webpack_require__(275); + __webpack_require__(724); +} + +module.exports = GameObjects; + + +/***/ }), +/* 877 */ /***/ (function(module, exports) { /** @@ -106220,7 +140860,7 @@ module.exports = VisibilityHandler; /***/ }), -/* 506 */ +/* 878 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -106231,8 +140871,8 @@ module.exports = VisibilityHandler; var Class = __webpack_require__(0); var GetValue = __webpack_require__(4); -var NOOP = __webpack_require__(3); -var RequestAnimationFrame = __webpack_require__(268); +var NOOP = __webpack_require__(1); +var RequestAnimationFrame = __webpack_require__(341); // Frame Rate config // fps: { @@ -106258,7 +140898,7 @@ var RequestAnimationFrame = __webpack_require__(268); * [description] * * @class TimeStep - * @memberOf Phaser.Boot + * @memberof Phaser.Boot * @constructor * @since 3.0.0 * @@ -106276,7 +140916,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#game * @type {Phaser.Game} - * @readOnly + * @readonly * @since 3.0.0 */ this.game = game; @@ -106286,7 +140926,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#raf * @type {Phaser.DOM.RequestAnimationFrame} - * @readOnly + * @readonly * @since 3.0.0 */ this.raf = new RequestAnimationFrame(); @@ -106296,7 +140936,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#started * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.0.0 */ @@ -106310,7 +140950,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#running * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.0.0 */ @@ -106367,7 +141007,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#actualFps * @type {integer} - * @readOnly + * @readonly * @default 60 * @since 3.0.0 */ @@ -106378,7 +141018,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#nextFpsUpdate * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.0.0 */ @@ -106389,7 +141029,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#framesThisSecond * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.0.0 */ @@ -106411,7 +141051,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#forceSetTimeOut * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.0.0 */ @@ -106452,7 +141092,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#frame * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.0.0 */ @@ -106463,7 +141103,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#inFocus * @type {boolean} - * @readOnly + * @readonly * @default true * @since 3.0.0 */ @@ -106883,7 +141523,7 @@ module.exports = TimeStep; /***/ }), -/* 507 */ +/* 879 */ /***/ (function(module, exports) { /** @@ -106928,7 +141568,7 @@ var addFrame = function (texture, sourceIndex, name, frame) * For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html * * @function Phaser.Textures.Parsers.UnityYAML - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -107053,7 +141693,7 @@ TextureImporter: /***/ }), -/* 508 */ +/* 880 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -107062,7 +141702,7 @@ TextureImporter: * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * Parses a Sprite Sheet and adds the Frames to the Texture, where the Sprite Sheet is stored as a frame within an Atlas. @@ -107071,7 +141711,7 @@ var GetFastValue = __webpack_require__(1); * same size and cannot be trimmed or rotated. * * @function Phaser.Textures.Parsers.SpriteSheetFromAtlas - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -107244,7 +141884,7 @@ module.exports = SpriteSheetFromAtlas; /***/ }), -/* 509 */ +/* 881 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -107253,7 +141893,7 @@ module.exports = SpriteSheetFromAtlas; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * Parses a Sprite Sheet and adds the Frames to the Texture. @@ -107262,7 +141902,7 @@ var GetFastValue = __webpack_require__(1); * same size and cannot be trimmed or rotated. * * @function Phaser.Textures.Parsers.SpriteSheet - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -107307,6 +141947,11 @@ var SpriteSheet = function (texture, sourceIndex, x, y, width, height, config) var column = Math.floor((height - margin + spacing) / (frameHeight + spacing)); var total = row * column; + if (total === 0) + { + console.warn('SpriteSheet frame dimensions will result in zero frames.'); + } + if (startFrame > total || startFrame < -total) { startFrame = 0; @@ -107364,7 +142009,7 @@ module.exports = SpriteSheet; /***/ }), -/* 510 */ +/* 882 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -107373,14 +142018,14 @@ module.exports = SpriteSheet; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(33); +var Clone = __webpack_require__(63); /** * Parses a Texture Atlas JSON Hash and adds the Frames to the Texture. * JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames. * * @function Phaser.Textures.Parsers.JSONHash - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -107463,7 +142108,7 @@ module.exports = JSONHash; /***/ }), -/* 511 */ +/* 883 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -107472,14 +142117,14 @@ module.exports = JSONHash; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Clone = __webpack_require__(33); +var Clone = __webpack_require__(63); /** * Parses a Texture Atlas JSON Array and adds the Frames to the Texture. * JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames. * * @function Phaser.Textures.Parsers.JSONArray - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -107570,7 +142215,7 @@ module.exports = JSONArray; /***/ }), -/* 512 */ +/* 884 */ /***/ (function(module, exports) { /** @@ -107583,7 +142228,7 @@ module.exports = JSONArray; * Adds an Image Element to a Texture. * * @function Phaser.Textures.Parsers.Image - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -107605,7 +142250,7 @@ module.exports = Image; /***/ }), -/* 513 */ +/* 885 */ /***/ (function(module, exports) { /** @@ -107618,7 +142263,7 @@ module.exports = Image; * Adds a Canvas Element to a Texture. * * @function Phaser.Textures.Parsers.Canvas - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -107640,7 +142285,7 @@ module.exports = Canvas; /***/ }), -/* 514 */ +/* 886 */ /***/ (function(module, exports) { /** @@ -107653,7 +142298,7 @@ module.exports = Canvas; * Parses an XML Texture Atlas object and adds all the Frames into a Texture. * * @function Phaser.Textures.Parsers.AtlasXML - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.7.0 * @@ -107721,7 +142366,7 @@ module.exports = AtlasXML; /***/ }), -/* 515 */ +/* 887 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -107731,8 +142376,9 @@ module.exports = AtlasXML; */ var Class = __webpack_require__(0); -var IsSizePowerOfTwo = __webpack_require__(85); -var Texture = __webpack_require__(117); +var Color = __webpack_require__(37); +var IsSizePowerOfTwo = __webpack_require__(117); +var Texture = __webpack_require__(165); /** * @classdesc @@ -107756,11 +142402,11 @@ var Texture = __webpack_require__(117); * * @class CanvasTexture * @extends Phaser.Textures.Texture - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.7.0 * - * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. + * @param {Phaser.Textures.CanvasTexture} manager - A reference to the Texture Manager this Texture belongs to. * @param {string} key - The unique string-based key of this Texture. * @param {HTMLCanvasElement} source - The canvas element that is used as the base of this texture. * @param {integer} width - The width of the canvas. @@ -107781,7 +142427,7 @@ var CanvasTexture = new Class({ /** * A reference to the Texture Source of this Canvas. * - * @name Phaser.Textures.TextureManager#_source + * @name Phaser.Textures.CanvasTexture#_source * @type {Phaser.Textures.TextureSource} * @private * @since 3.7.0 @@ -107791,8 +142437,8 @@ var CanvasTexture = new Class({ /** * The source Canvas Element. * - * @name Phaser.Textures.TextureManager#canvas - * @readOnly + * @name Phaser.Textures.CanvasTexture#canvas + * @readonly * @type {HTMLCanvasElement} * @since 3.7.0 */ @@ -107801,8 +142447,8 @@ var CanvasTexture = new Class({ /** * The 2D Canvas Rendering Context. * - * @name Phaser.Textures.TextureManager#canvas - * @readOnly + * @name Phaser.Textures.CanvasTexture#context + * @readonly * @type {CanvasRenderingContext2D} * @since 3.7.0 */ @@ -107810,10 +142456,10 @@ var CanvasTexture = new Class({ /** * The width of the Canvas. - * This property is read-only, if you wish to change use `setSize`. + * This property is read-only, if you wish to change it use the `setSize` method. * - * @name Phaser.Textures.TextureManager#width - * @readOnly + * @name Phaser.Textures.CanvasTexture#width + * @readonly * @type {integer} * @since 3.7.0 */ @@ -107821,14 +142467,165 @@ var CanvasTexture = new Class({ /** * The height of the Canvas. - * This property is read-only, if you wish to change use `setSize`. + * This property is read-only, if you wish to change it use the `setSize` method. * - * @name Phaser.Textures.TextureManager#height - * @readOnly + * @name Phaser.Textures.CanvasTexture#height + * @readonly * @type {integer} * @since 3.7.0 */ this.height = height; + + /** + * The context image data. + * Use the `update` method to populate this when the canvas changes. + * + * @name Phaser.Textures.CanvasTexture#imageData + * @type {ImageData} + * @since 3.13.0 + */ + this.imageData = this.context.getImageData(0, 0, width, height); + + /** + * A Uint8ClampedArray view into the `buffer`. + * Use the `update` method to populate this when the canvas changes. + * Note that this is unavailable in some browsers, such as Epic Browser, due to their security restrictions. + * + * @name Phaser.Textures.CanvasTexture#data + * @type {Uint8ClampedArray} + * @since 3.13.0 + */ + this.data = null; + + if (this.imageData) + { + this.data = this.imageData.data; + } + + /** + * An Uint32Array view into the `buffer`. + * + * @name Phaser.Textures.CanvasTexture#pixels + * @type {Uint32Array} + * @since 3.13.0 + */ + this.pixels = null; + + /** + * An ArrayBuffer the same size as the context ImageData. + * + * @name Phaser.Textures.CanvasTexture#buffer + * @type {ArrayBuffer} + * @since 3.13.0 + */ + this.buffer; + + if (this.data) + { + if (this.imageData.data.buffer) + { + this.buffer = this.imageData.data.buffer; + this.pixels = new Uint32Array(this.buffer); + } + else if (window.ArrayBuffer) + { + this.buffer = new ArrayBuffer(this.imageData.data.length); + this.pixels = new Uint32Array(this.buffer); + } + else + { + this.pixels = this.imageData.data; + } + } + }, + + /** + * This re-creates the `imageData` from the current context. + * It then re-builds the ArrayBuffer, the `data` Uint8ClampedArray reference and the `pixels` Int32Array. + * + * Warning: This is a very expensive operation, so use it sparingly. + * + * @method Phaser.Textures.CanvasTexture#update + * @since 3.13.0 + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + update: function () + { + this.imageData = this.context.getImageData(0, 0, this.width, this.height); + + this.data = this.imageData.data; + + if (this.imageData.data.buffer) + { + this.buffer = this.imageData.data.buffer; + this.pixels = new Uint32Array(this.buffer); + } + else if (window.ArrayBuffer) + { + this.buffer = new ArrayBuffer(this.imageData.data.length); + this.pixels = new Uint32Array(this.buffer); + } + else + { + this.pixels = this.imageData.data; + } + + return this; + }, + + /** + * Draws the given Image or Canvas element to this CanvasTexture, then updates the internal + * ImageData buffer and arrays. + * + * @method Phaser.Textures.CanvasTexture#draw + * @since 3.13.0 + * + * @param {integer} x - The x coordinate to draw the source at. + * @param {integer} y - The y coordinate to draw the source at. + * @param {(HTMLImageElement|HTMLCanvasElement)} source - The element to draw to this canvas. + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + draw: function (x, y, source) + { + this.context.drawImage(source, x, y); + + return this.update(); + }, + + /** + * Get the color of a specific pixel from this texture and store it in a Color object. + * + * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * + * @method Phaser.Textures.CanvasTexture#getPixel + * @since 3.13.0 + * + * @param {integer} x - The x coordinate of the pixel to be set. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} y - The y coordinate of the pixel to be set. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {Phaser.Display.Color} [out] - An object into which 4 properties will be set: r, g, b and a. If not provided a Color object will be created. + * + * @return {Phaser.Display.Color} An object with the red, green, blue and alpha values set in the r, g, b and a properties. + */ + getPixel: function (x, y, out) + { + if (!out) + { + out = new Color(); + } + + var index = ~~(x + (y * this.width)); + + index *= 4; + + var r = this.data[index]; + var g = this.data[++index]; + var b = this.data[++index]; + var a = this.data[++index]; + + return out.setTo(r, g, b, a); }, /** @@ -107886,7 +142683,7 @@ var CanvasTexture = new Class({ { this.context.clearRect(0, 0, this.width, this.height); - return this; + return this.update(); }, /** @@ -107930,8 +142727,8 @@ module.exports = CanvasTexture; /***/ }), -/* 516 */ -/***/ (function(module, exports) { +/* 888 */ +/***/ (function(module, exports, __webpack_require__) { /** * @author Richard Davey @@ -107962,7 +142759,6 @@ var InjectionMap = { events: 'events', cameras: 'cameras', - cameras3d: 'cameras3d', add: 'add', make: 'make', scenePlugin: 'scene', @@ -107981,11 +142777,17 @@ var InjectionMap = { }; +if (false) +{} + +if (false) +{} + module.exports = InjectionMap; /***/ }), -/* 517 */ +/* 889 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -107994,7 +142796,7 @@ module.exports = InjectionMap; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); +var GetFastValue = __webpack_require__(2); /** * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. @@ -108032,7 +142834,7 @@ module.exports = GetScenePlugins; /***/ }), -/* 518 */ +/* 890 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -108041,8 +142843,8 @@ module.exports = GetScenePlugins; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetFastValue = __webpack_require__(1); -var UppercaseFirst = __webpack_require__(256); +var GetFastValue = __webpack_require__(2); +var UppercaseFirst = __webpack_require__(327); /** * Builds an array of which physics plugins should be activated for the given Scene. @@ -108094,7 +142896,1044 @@ module.exports = GetPhysicsPlugins; /***/ }), -/* 519 */ +/* 891 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(26); + +/** + * Called automatically by Phaser.Game and responsible for creating the console.log debug header. + * + * You can customize or disable the header via the Game Config object. + * + * @function Phaser.Boot.DebugHeader + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. + */ +var DebugHeader = function (game) +{ + var config = game.config; + + if (config.hideBanner) + { + return; + } + + var renderType = 'WebGL'; + + if (config.renderType === CONST.CANVAS) + { + renderType = 'Canvas'; + } + else if (config.renderType === CONST.HEADLESS) + { + renderType = 'Headless'; + } + + var audioConfig = config.audio; + var deviceAudio = game.device.audio; + + var audioType; + + if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + audioType = 'Web Audio'; + } + else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + audioType = 'No Audio'; + } + else + { + audioType = 'HTML5 Audio'; + } + + if (!game.device.browser.ie) + { + var c = ''; + var args = [ c ]; + + if (Array.isArray(config.bannerBackgroundColor)) + { + var lastColor; + + config.bannerBackgroundColor.forEach(function (color) + { + c = c.concat('%c '); + + args.push('background: ' + color); + + lastColor = color; + + }); + + // inject the text color + args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; + } + else + { + c = c.concat('%c '); + + args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); + } + + // URL link background color (always white) + args.push('background: #fff'); + + if (config.gameTitle) + { + c = c.concat(config.gameTitle); + + if (config.gameVersion) + { + c = c.concat(' v' + config.gameVersion); + } + + if (!config.hidePhaser) + { + c = c.concat(' / '); + } + } + + var fb = ( false) ? undefined : ''; + + if (!config.hidePhaser) + { + c = c.concat('Phaser v' + CONST.VERSION + fb + ' (' + renderType + ' | ' + audioType + ')'); + } + + c = c.concat(' %c ' + config.gameURL); + + // Inject the new string back into the args array + args[0] = c; + + console.log.apply(console, args); + } + else if (window['console']) + { + console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); + } +}; + +module.exports = DebugHeader; + + +/***/ }), +/* 892 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_TEXTURE_TINT_VS', + '', + 'precision mediump float;', + '', + 'uniform mat4 uProjectionMatrix;', + 'uniform mat4 uViewMatrix;', + 'uniform mat4 uModelMatrix;', + '', + 'attribute vec2 inPosition;', + 'attribute vec2 inTexCoord;', + 'attribute float inTintEffect;', + 'attribute vec4 inTint;', + '', + 'varying vec2 outTexCoord;', + 'varying float outTintEffect;', + 'varying vec4 outTint;', + '', + 'void main ()', + '{', + ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', + '', + ' outTexCoord = inTexCoord;', + ' outTint = inTint;', + ' outTintEffect = inTintEffect;', + '}', + '', + '' +].join('\n'); + + +/***/ }), +/* 893 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_TEXTURE_TINT_FS', + '', + 'precision mediump float;', + '', + 'uniform sampler2D uMainSampler;', + '', + 'varying vec2 outTexCoord;', + 'varying float outTintEffect;', + 'varying vec4 outTint;', + '', + 'void main()', + '{', + ' vec4 texture = texture2D(uMainSampler, outTexCoord);', + ' vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);', + ' vec4 color = texture;', + '', + ' if (outTintEffect == 0.0)', + ' {', + ' // Multiply texture tint', + ' color = texture * texel;', + ' }', + ' else if (outTintEffect == 1.0)', + ' {', + ' // Solid color + texture alpha', + ' color.rgb = mix(texture.rgb, outTint.rgb * outTint.a, texture.a);', + ' color.a = texture.a * texel.a;', + ' }', + ' else if (outTintEffect == 2.0)', + ' {', + ' // Solid color, no texture', + ' color = texel;', + ' }', + '', + ' gl_FragColor = color;', + '}', + '' +].join('\n'); + + +/***/ }), +/* 894 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + + +/** + * Implements a model view projection matrices. + * Pipelines can implement this for doing 2D and 3D rendering. + */ + +var ModelViewProjection = { + + /** + * Dirty flag for checking if model matrix needs to be updated on GPU. + */ + modelMatrixDirty: false, + + /** + * Dirty flag for checking if view matrix needs to be updated on GPU. + */ + viewMatrixDirty: false, + + /** + * Dirty flag for checking if projection matrix needs to be updated on GPU. + */ + projectionMatrixDirty: false, + + /** + * Model matrix + */ + modelMatrix: null, + + /** + * View matrix + */ + viewMatrix: null, + + /** + * Projection matrix + */ + projectionMatrix: null, + + /** + * Initializes MVP matrices with an identity matrix + */ + mvpInit: function () + { + this.modelMatrixDirty = true; + this.viewMatrixDirty = true; + this.projectionMatrixDirty = true; + + this.modelMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.viewMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + this.projectionMatrix = new Float32Array([ + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + /** + * If dirty flags are set then the matrices are uploaded to the GPU. + */ + mvpUpdate: function () + { + var program = this.program; + + if (this.modelMatrixDirty) + { + this.renderer.setMatrix4(program, 'uModelMatrix', false, this.modelMatrix); + this.modelMatrixDirty = false; + } + + if (this.viewMatrixDirty) + { + this.renderer.setMatrix4(program, 'uViewMatrix', false, this.viewMatrix); + this.viewMatrixDirty = false; + } + + if (this.projectionMatrixDirty) + { + this.renderer.setMatrix4(program, 'uProjectionMatrix', false, this.projectionMatrix); + this.projectionMatrixDirty = false; + } + + return this; + }, + + /** + * Loads an identity matrix to the model matrix + */ + modelIdentity: function () + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = 1; + modelMatrix[1] = 0; + modelMatrix[2] = 0; + modelMatrix[3] = 0; + modelMatrix[4] = 0; + modelMatrix[5] = 1; + modelMatrix[6] = 0; + modelMatrix[7] = 0; + modelMatrix[8] = 0; + modelMatrix[9] = 0; + modelMatrix[10] = 1; + modelMatrix[11] = 0; + modelMatrix[12] = 0; + modelMatrix[13] = 0; + modelMatrix[14] = 0; + modelMatrix[15] = 1; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Scale model matrix + */ + modelScale: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[0] = modelMatrix[0] * x; + modelMatrix[1] = modelMatrix[1] * x; + modelMatrix[2] = modelMatrix[2] * x; + modelMatrix[3] = modelMatrix[3] * x; + modelMatrix[4] = modelMatrix[4] * y; + modelMatrix[5] = modelMatrix[5] * y; + modelMatrix[6] = modelMatrix[6] * y; + modelMatrix[7] = modelMatrix[7] * y; + modelMatrix[8] = modelMatrix[8] * z; + modelMatrix[9] = modelMatrix[9] * z; + modelMatrix[10] = modelMatrix[10] * z; + modelMatrix[11] = modelMatrix[11] * z; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Translate model matrix + */ + modelTranslate: function (x, y, z) + { + var modelMatrix = this.modelMatrix; + + modelMatrix[12] = modelMatrix[0] * x + modelMatrix[4] * y + modelMatrix[8] * z + modelMatrix[12]; + modelMatrix[13] = modelMatrix[1] * x + modelMatrix[5] * y + modelMatrix[9] * z + modelMatrix[13]; + modelMatrix[14] = modelMatrix[2] * x + modelMatrix[6] * y + modelMatrix[10] * z + modelMatrix[14]; + modelMatrix[15] = modelMatrix[3] * x + modelMatrix[7] * y + modelMatrix[11] * z + modelMatrix[15]; + + this.modelMatrixDirty = true; + + return this; + }, + + + /** + * Rotates the model matrix in the X axis. + */ + modelRotateX: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[4] = a10 * c + a20 * s; + modelMatrix[5] = a11 * c + a21 * s; + modelMatrix[6] = a12 * c + a22 * s; + modelMatrix[7] = a13 * c + a23 * s; + modelMatrix[8] = a20 * c - a10 * s; + modelMatrix[9] = a21 * c - a11 * s; + modelMatrix[10] = a22 * c - a12 * s; + modelMatrix[11] = a23 * c - a13 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Rotates the model matrix in the Y axis. + */ + modelRotateY: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a20 = modelMatrix[8]; + var a21 = modelMatrix[9]; + var a22 = modelMatrix[10]; + var a23 = modelMatrix[11]; + + modelMatrix[0] = a00 * c - a20 * s; + modelMatrix[1] = a01 * c - a21 * s; + modelMatrix[2] = a02 * c - a22 * s; + modelMatrix[3] = a03 * c - a23 * s; + modelMatrix[8] = a00 * s + a20 * c; + modelMatrix[9] = a01 * s + a21 * c; + modelMatrix[10] = a02 * s + a22 * c; + modelMatrix[11] = a03 * s + a23 * c; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Rotates the model matrix in the Z axis. + */ + modelRotateZ: function (radians) + { + var modelMatrix = this.modelMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = modelMatrix[0]; + var a01 = modelMatrix[1]; + var a02 = modelMatrix[2]; + var a03 = modelMatrix[3]; + var a10 = modelMatrix[4]; + var a11 = modelMatrix[5]; + var a12 = modelMatrix[6]; + var a13 = modelMatrix[7]; + + modelMatrix[0] = a00 * c + a10 * s; + modelMatrix[1] = a01 * c + a11 * s; + modelMatrix[2] = a02 * c + a12 * s; + modelMatrix[3] = a03 * c + a13 * s; + modelMatrix[4] = a10 * c - a00 * s; + modelMatrix[5] = a11 * c - a01 * s; + modelMatrix[6] = a12 * c - a02 * s; + modelMatrix[7] = a13 * c - a03 * s; + + this.modelMatrixDirty = true; + + return this; + }, + + /** + * Loads identity matrix into the view matrix + */ + viewIdentity: function () + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = 1; + viewMatrix[1] = 0; + viewMatrix[2] = 0; + viewMatrix[3] = 0; + viewMatrix[4] = 0; + viewMatrix[5] = 1; + viewMatrix[6] = 0; + viewMatrix[7] = 0; + viewMatrix[8] = 0; + viewMatrix[9] = 0; + viewMatrix[10] = 1; + viewMatrix[11] = 0; + viewMatrix[12] = 0; + viewMatrix[13] = 0; + viewMatrix[14] = 0; + viewMatrix[15] = 1; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Scales view matrix + */ + viewScale: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[0] = viewMatrix[0] * x; + viewMatrix[1] = viewMatrix[1] * x; + viewMatrix[2] = viewMatrix[2] * x; + viewMatrix[3] = viewMatrix[3] * x; + viewMatrix[4] = viewMatrix[4] * y; + viewMatrix[5] = viewMatrix[5] * y; + viewMatrix[6] = viewMatrix[6] * y; + viewMatrix[7] = viewMatrix[7] * y; + viewMatrix[8] = viewMatrix[8] * z; + viewMatrix[9] = viewMatrix[9] * z; + viewMatrix[10] = viewMatrix[10] * z; + viewMatrix[11] = viewMatrix[11] * z; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Translates view matrix + */ + viewTranslate: function (x, y, z) + { + var viewMatrix = this.viewMatrix; + + viewMatrix[12] = viewMatrix[0] * x + viewMatrix[4] * y + viewMatrix[8] * z + viewMatrix[12]; + viewMatrix[13] = viewMatrix[1] * x + viewMatrix[5] * y + viewMatrix[9] * z + viewMatrix[13]; + viewMatrix[14] = viewMatrix[2] * x + viewMatrix[6] * y + viewMatrix[10] * z + viewMatrix[14]; + viewMatrix[15] = viewMatrix[3] * x + viewMatrix[7] * y + viewMatrix[11] * z + viewMatrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Rotates view matrix in the X axis. + */ + viewRotateX: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[4] = a10 * c + a20 * s; + viewMatrix[5] = a11 * c + a21 * s; + viewMatrix[6] = a12 * c + a22 * s; + viewMatrix[7] = a13 * c + a23 * s; + viewMatrix[8] = a20 * c - a10 * s; + viewMatrix[9] = a21 * c - a11 * s; + viewMatrix[10] = a22 * c - a12 * s; + viewMatrix[11] = a23 * c - a13 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Rotates view matrix in the Y axis. + */ + viewRotateY: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a20 = viewMatrix[8]; + var a21 = viewMatrix[9]; + var a22 = viewMatrix[10]; + var a23 = viewMatrix[11]; + + viewMatrix[0] = a00 * c - a20 * s; + viewMatrix[1] = a01 * c - a21 * s; + viewMatrix[2] = a02 * c - a22 * s; + viewMatrix[3] = a03 * c - a23 * s; + viewMatrix[8] = a00 * s + a20 * c; + viewMatrix[9] = a01 * s + a21 * c; + viewMatrix[10] = a02 * s + a22 * c; + viewMatrix[11] = a03 * s + a23 * c; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Rotates view matrix in the Z axis. + */ + viewRotateZ: function (radians) + { + var viewMatrix = this.viewMatrix; + var s = Math.sin(radians); + var c = Math.cos(radians); + var a00 = viewMatrix[0]; + var a01 = viewMatrix[1]; + var a02 = viewMatrix[2]; + var a03 = viewMatrix[3]; + var a10 = viewMatrix[4]; + var a11 = viewMatrix[5]; + var a12 = viewMatrix[6]; + var a13 = viewMatrix[7]; + + viewMatrix[0] = a00 * c + a10 * s; + viewMatrix[1] = a01 * c + a11 * s; + viewMatrix[2] = a02 * c + a12 * s; + viewMatrix[3] = a03 * c + a13 * s; + viewMatrix[4] = a10 * c - a00 * s; + viewMatrix[5] = a11 * c - a01 * s; + viewMatrix[6] = a12 * c - a02 * s; + viewMatrix[7] = a13 * c - a03 * s; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Loads a 2D view matrix (3x2 matrix) into a 4x4 view matrix + */ + viewLoad2D: function (matrix2D) + { + var vm = this.viewMatrix; + + vm[0] = matrix2D[0]; + vm[1] = matrix2D[1]; + vm[2] = 0.0; + vm[3] = 0.0; + vm[4] = matrix2D[2]; + vm[5] = matrix2D[3]; + vm[6] = 0.0; + vm[7] = 0.0; + vm[8] = matrix2D[4]; + vm[9] = matrix2D[5]; + vm[10] = 1.0; + vm[11] = 0.0; + vm[12] = 0.0; + vm[13] = 0.0; + vm[14] = 0.0; + vm[15] = 1.0; + + this.viewMatrixDirty = true; + + return this; + }, + + + /** + * Copies a 4x4 matrix into the view matrix + */ + viewLoad: function (matrix) + { + var vm = this.viewMatrix; + + vm[0] = matrix[0]; + vm[1] = matrix[1]; + vm[2] = matrix[2]; + vm[3] = matrix[3]; + vm[4] = matrix[4]; + vm[5] = matrix[5]; + vm[6] = matrix[6]; + vm[7] = matrix[7]; + vm[8] = matrix[8]; + vm[9] = matrix[9]; + vm[10] = matrix[10]; + vm[11] = matrix[11]; + vm[12] = matrix[12]; + vm[13] = matrix[13]; + vm[14] = matrix[14]; + vm[15] = matrix[15]; + + this.viewMatrixDirty = true; + + return this; + }, + + /** + * Loads identity matrix into the projection matrix. + */ + projIdentity: function () + { + var projectionMatrix = this.projectionMatrix; + + projectionMatrix[0] = 1; + projectionMatrix[1] = 0; + projectionMatrix[2] = 0; + projectionMatrix[3] = 0; + projectionMatrix[4] = 0; + projectionMatrix[5] = 1; + projectionMatrix[6] = 0; + projectionMatrix[7] = 0; + projectionMatrix[8] = 0; + projectionMatrix[9] = 0; + projectionMatrix[10] = 1; + projectionMatrix[11] = 0; + projectionMatrix[12] = 0; + projectionMatrix[13] = 0; + projectionMatrix[14] = 0; + projectionMatrix[15] = 1; + + this.projectionMatrixDirty = true; + + return this; + }, + + /** + * Sets up an orthographics projection matrix + */ + projOrtho: function (left, right, bottom, top, near, far) + { + var projectionMatrix = this.projectionMatrix; + var leftRight = 1.0 / (left - right); + var bottomTop = 1.0 / (bottom - top); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = -2.0 * leftRight; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = -2.0 * bottomTop; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = 2.0 * nearFar; + projectionMatrix[11] = 0.0; + projectionMatrix[12] = (left + right) * leftRight; + projectionMatrix[13] = (top + bottom) * bottomTop; + projectionMatrix[14] = (far + near) * nearFar; + projectionMatrix[15] = 1.0; + + this.projectionMatrixDirty = true; + return this; + }, + + /** + * Sets up a perspective projection matrix + */ + projPersp: function (fovy, aspectRatio, near, far) + { + var projectionMatrix = this.projectionMatrix; + var fov = 1.0 / Math.tan(fovy / 2.0); + var nearFar = 1.0 / (near - far); + + projectionMatrix[0] = fov / aspectRatio; + projectionMatrix[1] = 0.0; + projectionMatrix[2] = 0.0; + projectionMatrix[3] = 0.0; + projectionMatrix[4] = 0.0; + projectionMatrix[5] = fov; + projectionMatrix[6] = 0.0; + projectionMatrix[7] = 0.0; + projectionMatrix[8] = 0.0; + projectionMatrix[9] = 0.0; + projectionMatrix[10] = (far + near) * nearFar; + projectionMatrix[11] = -1.0; + projectionMatrix[12] = 0.0; + projectionMatrix[13] = 0.0; + projectionMatrix[14] = (2.0 * far * near) * nearFar; + projectionMatrix[15] = 0.0; + + this.projectionMatrixDirty = true; + return this; + } +}; + +module.exports = ModelViewProjection; + + +/***/ }), +/* 895 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS', + '', + 'precision mediump float;', + '', + 'struct Light', + '{', + ' vec2 position;', + ' vec3 color;', + ' float intensity;', + ' float radius;', + '};', + '', + 'const int kMaxLights = %LIGHT_COUNT%;', + '', + 'uniform vec4 uCamera; /* x, y, rotation, zoom */', + 'uniform vec2 uResolution;', + 'uniform sampler2D uMainSampler;', + 'uniform sampler2D uNormSampler;', + 'uniform vec3 uAmbientLightColor;', + 'uniform Light uLights[kMaxLights];', + '', + 'varying vec2 outTexCoord;', + 'varying vec4 outTint;', + '', + 'void main()', + '{', + ' vec3 finalColor = vec3(0.0, 0.0, 0.0);', + ' vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);', + ' vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;', + ' vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));', + ' vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;', + '', + ' for (int index = 0; index < kMaxLights; ++index)', + ' {', + ' Light light = uLights[index];', + ' vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);', + ' vec3 lightNormal = normalize(lightDir);', + ' float distToSurf = length(lightDir) * uCamera.w;', + ' float diffuseFactor = max(dot(normal, lightNormal), 0.0);', + ' float radius = (light.radius / res.x * uCamera.w) * uCamera.w;', + ' float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);', + ' vec3 diffuse = light.color * diffuseFactor;', + ' finalColor += (attenuation * diffuse) * light.intensity;', + ' }', + '', + ' vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);', + ' gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);', + '', + '}', + '' +].join('\n'); + + +/***/ }), +/* 896 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_BITMAP_MASK_VS', + '', + 'precision mediump float;', + '', + 'attribute vec2 inPosition;', + '', + 'void main()', + '{', + ' gl_Position = vec4(inPosition, 0.0, 1.0);', + '}', + '' +].join('\n'); + + +/***/ }), +/* 897 */ +/***/ (function(module, exports) { + +module.exports = [ + '#define SHADER_NAME PHASER_BITMAP_MASK_FS', + '', + 'precision mediump float;', + '', + 'uniform vec2 uResolution;', + 'uniform sampler2D uMainSampler;', + 'uniform sampler2D uMaskSampler;', + 'uniform bool uInvertMaskAlpha;', + '', + 'void main()', + '{', + ' vec2 uv = gl_FragCoord.xy / uResolution;', + ' vec4 mainColor = texture2D(uMainSampler, uv);', + ' vec4 maskColor = texture2D(uMaskSampler, uv);', + ' float alpha = mainColor.a;', + '', + ' if (!uInvertMaskAlpha)', + ' {', + ' alpha *= (maskColor.a);', + ' }', + ' else', + ' {', + ' alpha *= (1.0 - maskColor.a);', + ' }', + '', + ' gl_FragColor = vec4(mainColor.rgb * alpha, alpha);', + '}', + '' +].join('\n'); + + +/***/ }), +/* 898 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CanvasInterpolation = __webpack_require__(348); +var CanvasPool = __webpack_require__(24); +var CONST = __webpack_require__(26); +var Features = __webpack_require__(168); + +/** + * Called automatically by Phaser.Game and responsible for creating the renderer it will use. + * + * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. + * + * @function Phaser.Boot.CreateRenderer + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. + */ +var CreateRenderer = function (game) +{ + var config = game.config; + + // Game either requested Canvas, + // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas + + if (config.renderType !== CONST.HEADLESS) + { + if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) + { + if (Features.canvas) + { + // They requested Canvas and their browser supports it + config.renderType = CONST.CANVAS; + } + else + { + throw new Error('Cannot create Canvas or WebGL context, aborting.'); + } + } + else + { + // Game requested WebGL and browser says it supports it + config.renderType = CONST.WEBGL; + } + } + + // Pixel Art mode? + if (!config.antialias) + { + CanvasPool.disableSmoothing(); + } + + // Does the game config provide its own canvas element to use? + if (config.canvas) + { + game.canvas = config.canvas; + + game.canvas.width = game.config.width; + game.canvas.height = game.config.height; + } + else + { + game.canvas = CanvasPool.create(game, config.width * config.resolution, config.height * config.resolution, config.renderType); + } + + // Does the game config provide some canvas css styles to use? + if (config.canvasStyle) + { + game.canvas.style = config.canvasStyle; + } + + // Pixel Art mode? + if (!config.antialias) + { + CanvasInterpolation.setCrisp(game.canvas); + } + + // Zoomed? + game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; + game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; + + if (config.renderType === CONST.HEADLESS) + { + // Nothing more to do here + return; + } + + var CanvasRenderer; + var WebGLRenderer; + + if (true) + { + CanvasRenderer = __webpack_require__(426); + WebGLRenderer = __webpack_require__(423); + + // Let the config pick the renderer type, as both are included + if (config.renderType === CONST.WEBGL) + { + game.renderer = new WebGLRenderer(game); + } + else + { + game.renderer = new CanvasRenderer(game); + game.context = game.renderer.gameContext; + } + } + + if (false) + {} + + if (false) + {} +}; + +module.exports = CreateRenderer; + + +/***/ }), +/* 899 */ /***/ (function(module, exports) { /** @@ -108192,7 +144031,7 @@ module.exports = init(); /***/ }), -/* 520 */ +/* 900 */ /***/ (function(module, exports) { /** @@ -108277,7 +144116,7 @@ module.exports = init(); /***/ }), -/* 521 */ +/* 901 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -108286,7 +144125,7 @@ module.exports = init(); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Browser = __webpack_require__(80); +var Browser = __webpack_require__(118); /** * Determines the audio playback capabilities of the device running this Phaser Game instance. @@ -108402,7 +144241,7 @@ module.exports = init(); /***/ }), -/* 522 */ +/* 902 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -108411,8 +144250,8 @@ module.exports = init(); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var OS = __webpack_require__(57); -var Browser = __webpack_require__(80); +var OS = __webpack_require__(92); +var Browser = __webpack_require__(118); /** * Determines the input support of the browser running this Phaser Game instance. @@ -108481,521 +144320,7 @@ module.exports = init(); /***/ }), -/* 523 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// This singleton is instantiated as soon as Phaser loads, -// before a Phaser.Game instance has even been created. -// Which means all instances of Phaser Games can share it, -// without having to re-poll the device all over again - -/** - * @namespace Phaser.Device - * @since 3.0.0 - */ - -/** - * @typedef {object} Phaser.DeviceConf - * - * @property {Phaser.Device.OS} os - The OS Device functions. - * @property {Phaser.Device.Browser} browser - The Browser Device functions. - * @property {Phaser.Device.Features} features - The Features Device functions. - * @property {Phaser.Device.Input} input - The Input Device functions. - * @property {Phaser.Device.Audio} audio - The Audio Device functions. - * @property {Phaser.Device.Video} video - The Video Device functions. - * @property {Phaser.Device.Fullscreen} fullscreen - The Fullscreen Device functions. - * @property {Phaser.Device.CanvasFeatures} canvasFeatures - The Canvas Device functions. - */ - -module.exports = { - - os: __webpack_require__(57), - browser: __webpack_require__(80), - features: __webpack_require__(120), - input: __webpack_require__(522), - audio: __webpack_require__(521), - video: __webpack_require__(520), - fullscreen: __webpack_require__(519), - canvasFeatures: __webpack_require__(203) - -}; - - -/***/ }), -/* 524 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(20); - -/** - * Called automatically by Phaser.Game and responsible for creating the console.log debug header. - * - * You can customize or disable the header via the Game Config object. - * - * @function Phaser.Boot.DebugHeader - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header. - */ -var DebugHeader = function (game) -{ - var config = game.config; - - if (config.hideBanner) - { - return; - } - - var renderType = 'WebGL'; - - if (config.renderType === CONST.CANVAS) - { - renderType = 'Canvas'; - } - else if (config.renderType === CONST.HEADLESS) - { - renderType = 'Headless'; - } - - var audioConfig = config.audio; - var deviceAudio = game.device.audio; - - var audioType; - - if (deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) - { - audioType = 'Web Audio'; - } - else if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) - { - audioType = 'No Audio'; - } - else - { - audioType = 'HTML5 Audio'; - } - - if (!game.device.browser.ie) - { - var c = ''; - var args = [ c ]; - - if (Array.isArray(config.bannerBackgroundColor)) - { - var lastColor; - - config.bannerBackgroundColor.forEach(function (color) - { - c = c.concat('%c '); - - args.push('background: ' + color); - - lastColor = color; - - }); - - // inject the text color - args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor; - } - else - { - c = c.concat('%c '); - - args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor); - } - - // URL link background color (always white) - args.push('background: #fff'); - - if (config.gameTitle) - { - c = c.concat(config.gameTitle); - - if (config.gameVersion) - { - c = c.concat(' v' + config.gameVersion); - } - - if (!config.hidePhaser) - { - c = c.concat(' / '); - } - } - - if (!config.hidePhaser) - { - c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); - } - - c = c.concat(' %c ' + config.gameURL); - - // Inject the new string back into the args array - args[0] = c; - - console.log.apply(console, args); - } - else if (window['console']) - { - console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io'); - } -}; - -module.exports = DebugHeader; - - -/***/ }), -/* 525 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_TEXTURE_TINT_VS', - '', - 'precision mediump float;', - '', - 'uniform mat4 uProjectionMatrix;', - 'uniform mat4 uViewMatrix;', - 'uniform mat4 uModelMatrix;', - '', - 'attribute vec2 inPosition;', - 'attribute vec2 inTexCoord;', - 'attribute vec4 inTint;', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main ()', - '{', - ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', - ' outTexCoord = inTexCoord;', - ' outTint = inTint;', - '}', - '', - '' -].join('\n'); - - -/***/ }), -/* 526 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_TEXTURE_TINT_FS', - '', - 'precision mediump float;', - '', - 'uniform sampler2D uMainSampler;', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main()', - '{', - ' vec4 texel = texture2D(uMainSampler, outTexCoord);', - ' texel *= vec4(outTint.rgb * outTint.a, outTint.a);', - ' gl_FragColor = texel;', - '}', - '' -].join('\n'); - - -/***/ }), -/* 527 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS', - '', - 'precision mediump float;', - '', - 'struct Light', - '{', - ' vec2 position;', - ' vec3 color;', - ' float intensity;', - ' float radius;', - '};', - '', - 'const int kMaxLights = %LIGHT_COUNT%;', - '', - 'uniform vec4 uCamera; /* x, y, rotation, zoom */', - 'uniform vec2 uResolution;', - 'uniform sampler2D uMainSampler;', - 'uniform sampler2D uNormSampler;', - 'uniform vec3 uAmbientLightColor;', - 'uniform Light uLights[kMaxLights];', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main()', - '{', - ' vec3 finalColor = vec3(0.0, 0.0, 0.0);', - ' vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);', - ' vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;', - ' vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));', - ' vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;', - '', - ' for (int index = 0; index < kMaxLights; ++index)', - ' {', - ' Light light = uLights[index];', - ' vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);', - ' vec3 lightNormal = normalize(lightDir);', - ' float distToSurf = length(lightDir) * uCamera.w;', - ' float diffuseFactor = max(dot(normal, lightNormal), 0.0);', - ' float radius = (light.radius / res.x * uCamera.w) * uCamera.w;', - ' float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);', - ' vec3 diffuse = light.color * diffuseFactor;', - ' finalColor += (attenuation * diffuse) * light.intensity;', - ' }', - '', - ' vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);', - ' gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);', - '', - '}', - '' -].join('\n'); - - -/***/ }), -/* 528 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_FLAT_TINT_VS', - '', - 'precision mediump float;', - '', - 'uniform mat4 uProjectionMatrix;', - 'uniform mat4 uViewMatrix;', - 'uniform mat4 uModelMatrix;', - '', - 'attribute vec2 inPosition;', - 'attribute vec4 inTint;', - '', - 'varying vec4 outTint;', - '', - 'void main () {', - ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', - ' outTint = inTint;', - '}', - '' -].join('\n'); - - -/***/ }), -/* 529 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_FLAT_TINT_FS', - '', - 'precision mediump float;', - '', - 'varying vec4 outTint;', - '', - 'void main() {', - ' gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);', - '}', - '' -].join('\n'); - - -/***/ }), -/* 530 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_BITMAP_MASK_VS', - '', - 'precision mediump float;', - '', - 'attribute vec2 inPosition;', - '', - 'void main()', - '{', - ' gl_Position = vec4(inPosition, 0.0, 1.0);', - '}', - '' -].join('\n'); - - -/***/ }), -/* 531 */ -/***/ (function(module, exports) { - -module.exports = [ - '#define SHADER_NAME PHASER_BITMAP_MASK_FS', - '', - 'precision mediump float;', - '', - 'uniform vec2 uResolution;', - 'uniform sampler2D uMainSampler;', - 'uniform sampler2D uMaskSampler;', - 'uniform bool uInvertMaskAlpha;', - '', - 'void main()', - '{', - ' vec2 uv = gl_FragCoord.xy / uResolution;', - ' vec4 mainColor = texture2D(uMainSampler, uv);', - ' vec4 maskColor = texture2D(uMaskSampler, uv);', - ' float alpha = mainColor.a;', - '', - ' if (!uInvertMaskAlpha)', - ' {', - ' alpha *= (maskColor.a);', - ' }', - ' else', - ' {', - ' alpha *= (1.0 - maskColor.a);', - ' }', - '', - ' gl_FragColor = vec4(mainColor.rgb * alpha, alpha);', - '}', - '' -].join('\n'); - - -/***/ }), -/* 532 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CanvasInterpolation = __webpack_require__(272); -var CanvasPool = __webpack_require__(22); -var CONST = __webpack_require__(20); -var Features = __webpack_require__(120); - -/** - * Called automatically by Phaser.Game and responsible for creating the renderer it will use. - * - * Relies upon two webpack global flags to be defined: `WEBGL_RENDERER` and `CANVAS_RENDERER` during build time, but not at run-time. - * - * @function Phaser.Boot.CreateRenderer - * @since 3.0.0 - * - * @param {Phaser.Game} game - The Phaser.Game instance on which the renderer will be set. - */ -var CreateRenderer = function (game) -{ - var config = game.config; - - // Game either requested Canvas, - // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas - - if (config.renderType !== CONST.HEADLESS) - { - if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) - { - if (Features.canvas) - { - // They requested Canvas and their browser supports it - config.renderType = CONST.CANVAS; - } - else - { - throw new Error('Cannot create Canvas or WebGL context, aborting.'); - } - } - else - { - // Game requested WebGL and browser says it supports it - config.renderType = CONST.WEBGL; - } - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasPool.disableSmoothing(); - } - - // Does the game config provide its own canvas element to use? - if (config.canvas) - { - game.canvas = config.canvas; - } - else - { - game.canvas = CanvasPool.create(game, config.width, config.height, config.renderType); - } - - // Does the game config provide some canvas css styles to use? - if (config.canvasStyle) - { - game.canvas.style = config.canvasStyle; - } - - // Pixel Art mode? - if (config.pixelArt) - { - CanvasInterpolation.setCrisp(game.canvas); - } - - // Zoomed? - if (config.zoom !== 1) - { - game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; - game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; - } - - if (config.renderType === CONST.HEADLESS) - { - // Nothing more to do here - return; - } - - var CanvasRenderer; - var WebGLRenderer; - - if (true) - { - CanvasRenderer = __webpack_require__(267); - WebGLRenderer = __webpack_require__(262); - - // Let the config pick the renderer type, as both are included - if (config.renderType === CONST.WEBGL) - { - game.renderer = new WebGLRenderer(game); - - // The WebGL Renderer sets this value during its init, not on construction - game.context = null; - } - else - { - game.renderer = new CanvasRenderer(game); - game.context = game.renderer.gameContext; - } - } - - if (false) - {} - - if (false) - {} -}; - -module.exports = CreateRenderer; - - -/***/ }), -/* 533 */ +/* 903 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -109005,14 +144330,15 @@ module.exports = CreateRenderer; */ var Class = __webpack_require__(0); -var CONST = __webpack_require__(20); -var GetFastValue = __webpack_require__(1); +var CONST = __webpack_require__(26); +var Device = __webpack_require__(340); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); var IsPlainObject = __webpack_require__(8); var MATH = __webpack_require__(16); -var NOOP = __webpack_require__(3); -var DefaultPlugins = __webpack_require__(121); -var ValueToColor = __webpack_require__(132); +var NOOP = __webpack_require__(1); +var DefaultPlugins = __webpack_require__(167); +var ValueToColor = __webpack_require__(178); /** * This callback type is completely empty, a no-operation. @@ -109023,98 +144349,210 @@ var ValueToColor = __webpack_require__(132); /** * @callback BootCallback * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - The game. + */ + +/** + * @typedef {object} InputConfig + * + * @property {(boolean|KeyboardInputConfig)} [keyboard=true] - Keyboard input configuration. `true` uses the default configuration and `false` disables keyboard input. + * @property {(boolean|MouseInputConfig)} [mouse=true] - Mouse input configuration. `true` uses the default configuration and `false` disables mouse input. + * @property {(boolean|TouchInputConfig)} [touch=true] - Touch input configuration. `true` uses the default configuration and `false` disables touch input. + * @property {(boolean|GamepadInputConfig)} [gamepad=false] - Gamepad input configuration. `true` enables gamepad input. + * @property {integer} [activePointers=1] - The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}. + */ + +/** + * @typedef {object} MouseInputConfig + * + * @property {*} [target=null] - Where the Mouse Manager listens for mouse input events. The default is the game canvas. + * @property {boolean} [capture=true] - Whether mouse input events have preventDefault() called on them. + */ + +/** + * @typedef {object} KeyboardInputConfig + * + * @property {*} [target=window] - Where the Keyboard Manager listens for keyboard input events. + */ + +/** + * @typedef {object} TouchInputConfig + * + * @property {*} [target=null] - Where the Touch Manager listens for touch input events. The default is the game canvas. + * @property {boolean} [capture=true] - Whether touch input events have preventDefault() called on them. + */ + +/** + * @typedef {object} GamepadInputConfig + * + * @property {*} [target=window] - Where the Gamepad Manager listens for gamepad input events. + */ + +/** + * @typedef {object} BannerConfig + * + * @property {boolean} [hidePhaser=false] - Omit Phaser's name and version from the banner. + * @property {string} [text='#ffffff'] - The color of the banner text. + * @property {string[]} [background] - The background colors of the banner. */ /** * @typedef {object} FPSConfig * - * @property {integer} [min=10] - [description] - * @property {integer} [target=60] - [description] - * @property {boolean} [forceSetTimeOut=false] - [description] - * @property {integer} [deltaHistory=10] - [description] + * @property {integer} [min=10] - The minimum acceptable rendering rate, in frames per second. + * @property {integer} [target=60] - The optimum rendering rate, in frames per second. + * @property {boolean} [forceSetTimeOut=false] - Use setTimeout instead of requestAnimationFrame to run the game loop. + * @property {integer} [deltaHistory=10] - Calculate the average frame delta from this many consecutive frame intervals. * @property {integer} [panicMax=120] - [description] */ +/** + * @typedef {object} RenderConfig + * + * @property {boolean} [antialias=true] - When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. + * @property {boolean} [pixelArt=false] - Sets `antialias` and `roundPixels` to true. This is the best setting for pixel-art games. + * @property {boolean} [autoResize=true] - Automatically resize the Game Canvas if you resize the renderer. + * @property {boolean} [roundPixels=false] - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. + * @property {boolean} [transparent=false] - Whether the game canvas will be transparent. + * @property {boolean} [clearBeforeRender=true] - Whether the game canvas will be cleared between each rendering frame. + * @property {boolean} [premultipliedAlpha=true] - In WebGL mode, the drawing buffer contains colors with pre-multiplied alpha. + * @property {boolean} [preserveDrawingBuffer=false] - In WebGL mode, the drawing buffer won't be cleared automatically each frame. + * @property {boolean} [failIfMajorPerformanceCaveat=false] - Let the browser abort creating a WebGL context if it judges performance would be unacceptable. + * @property {string} [powerPreference='default'] - "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. + * @property {integer} [batchSize=2000] - The default WebGL batch size. + * @property {integer} [maxLights=10] - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + +/** + * @typedef {object} ScaleConfig + * + * @property {(integer|string)} [width=1024] - The base width of your game. + * @property {(integer|string)} [height=768] - The base height of your game. + * @property {integer} [zoom=1] - The zoom value of the game canvas. + * @property {number} [resolution=1] - The rendering resolution of the canvas. + * @property {(HTMLElement|string)} [parent] - The DOM element that will contain the game canvas, or its `id`. If null (the default) or if the named element doesn't exist, the game canvas is inserted directly into the document body. + * @property {integer} [mode=0] - The scale mode to apply to the canvas. SHOW_ALL, EXACT_FIT, USER_SCALE, or RESIZE. + * @property {integer} [minWidth] - The minimum width the canvas can be scaled down to. + * @property {integer} [minHeight] - The minimum height the canvas can be scaled down to. + * @property {integer} [maxWidth] - The maximum width the canvas can be scaled up to. + * @property {integer} [maxHeight] - The maximum height the canvas can be scaled up to. + */ + +/** + * @typedef {object} CallbacksConfig + * + * @property {BootCallback} [preBoot=NOOP] - A function to run at the start of the boot sequence. + * @property {BootCallback} [postBoot=NOOP] - A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. + */ + /** * @typedef {object} LoaderConfig * - * @property {string} [baseURL] - [description] - * @property {string} [path] - [description] - * @property {integer} [maxParallelDownloads=32] - [description] - * @property {(string|undefined)} [crossOrigin=undefined] - [description] - * @property {string} [responseType] - [description] - * @property {boolean} [async=true] - [description] - * @property {string} [user] - [description] - * @property {string} [password] - [description] - * @property {integer} [timeout=0] - [description] + * @property {string} [baseURL] - An URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. + * @property {string} [path] - An URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. + * @property {integer} [maxParallelDownloads=32] - The maximum number of resources the loader will start loading at once. + * @property {(string|undefined)} [crossOrigin=undefined] - 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. + * @property {string} [responseType] - The response type of the XHR request, e.g. `blob`, `text`, etc. + * @property {boolean} [async=true] - Should the XHR request use async or not? + * @property {string} [user] - Optional username for the XHR request. + * @property {string} [password] - Optional password for the XHR request. + * @property {integer} [timeout=0] - Optional XHR timeout value, in ms. + */ + +/** + * @typedef {object} DOMContainerConfig + * + * @property {boolean} [createContainer=false] - Create a div element in which DOM Elements will be contained. You must also provide a parent. + * @property {boolean} [behindCanvas=false] - Place the DOM Container behind the Phaser Canvas. The default is to place it over the Canvas. + */ + +/** + * @typedef {object} ImagesConfig + * + * @property {string} [default] - URL to use for the 'default' texture. + * @property {string} [missing] - URL to use for the 'missing' texture. + */ + +/** + * @typedef {object} PhysicsConfig + * + * @property {string} [default] - The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'. + * @property {ArcadeWorldConfig} [arcade] - Arcade Physics configuration. + * @property {Phaser.Physics.Impact.WorldConfig} [impact] - Impact Physics configuration. + * @property {object} [matter] - Matter Physics configuration. + */ + +/** + * @typedef {object} PluginObjectItem + * + * @property {string} [key] - A key to identify the plugin in the Plugin Manager. + * @property {*} [plugin] - The plugin itself. Usually a class/constructor. + * @property {boolean} [start] - Whether the plugin should be started automatically. + * @property {string} [systemKey] - For a scene plugin, add the plugin to the scene's systems object under this key (`this.sys.KEY`, from the scene). + * @property {string} [sceneKey] - For a scene plugin, add the plugin to the scene object under this key (`this.KEY`, from the scene). + * @property {*} [data] - Arbitrary data passed to the plugin's init() method. + * + * @example + * // Global plugin + * { key: 'BankPlugin', plugin: BankPluginV3, start: true, data: { gold: 5000 } } + * @example + * // Scene plugin + * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } + */ + +/** + * @typedef {object} PluginObject + * + * @property {?PluginObjectItem[]} [global] - Global plugins to install. + * @property {?PluginObjectItem[]} [scene] - Scene plugins to install. + * @property {string[]} [default] - The default set of scene plugins (names). + * @property {string[]} [defaultMerge] - Plugins to *add* to the default set of scene plugins. */ /** * @typedef {object} GameConfig * - * @property {(integer|string)} [width=1024] - [description] - * @property {(integer|string)} [height=768] - [description] - * @property {number} [zoom=1] - [description] - * @property {number} [resolution=1] - [description] - * @property {number} [type=CONST.AUTO] - [description] - * @property {*} [parent=null] - [description] + * @property {(integer|string)} [width=1024] - The width of the game, in game pixels. + * @property {(integer|string)} [height=768] - The height of the game, in game pixels. + * @property {number} [zoom=1] - Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc. + * @property {number} [resolution=1] - The size of each game pixel, in canvas pixels. Values larger than 1 are "high" resolution. + * @property {number} [type=CONST.AUTO] - Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS. + * @property {(HTMLElement|string)} [parent=null] - The DOM element that will contain the game canvas, or its `id`. If null (the default) or if the named element doesn't exist, the game canvas is inserted directly into the document body. * @property {HTMLCanvasElement} [canvas=null] - Provide your own Canvas element for Phaser to use instead of creating one. - * @property {string} [canvasStyle=null] - [description] + * @property {string} [canvasStyle=null] - CSS styles to apply to the game canvas instead of Phaser's default styles. * @property {CanvasRenderingContext2D} [context] - Provide your own Canvas Context for Phaser to use, instead of creating one. - * @property {object} [scene=null] - [description] - * @property {string[]} [seed] - [description] - * @property {string} [title=''] - [description] - * @property {string} [url='http://phaser.io'] - [description] - * @property {string} [version=''] - [description] - * @property {boolean} [autoFocus=true] - Automatically call window.focus() when the game boots. - * @property {(boolean|object)} [input] - [description] - * @property {boolean} [input.keyboard=true] - [description] - * @property {*} [input.keyboard.target=window] - [description] - * @property {(boolean|object)} [input.mouse=true] - [description] - * @property {*} [input.mouse.target=null] - [description] - * @property {boolean} [input.touch=true] - [description] - * @property {integer} [input.activePointers=1] - [description] - * @property {*} [input.touch.target=null] - [description] - * @property {boolean} [input.touch.capture=true] - [description] - * @property {(boolean|object)} [input.gamepad=false] - [description] - * @property {boolean} [disableContextMenu=false] - [description] - * @property {(boolean|object)} [banner=false] - [description] - * @property {boolean} [banner.hidePhaser=false] - [description] - * @property {string} [banner.text='#ffffff'] - [description] - * @property {string[]} [banner.background] - [description] - * @property {FPSConfig} [fps] - [description] - * @property {boolean} [render.antialias=true] - [description] - * @property {boolean} [render.pixelArt=false] - [description] - * @property {boolean} [render.autoResize=false] - [description] - * @property {boolean} [render.roundPixels=false] - [description] - * @property {boolean} [render.transparent=false] - [description] - * @property {boolean} [render.clearBeforeRender=true] - [description] - * @property {boolean} [render.premultipliedAlpha=true] - [description] - * @property {boolean} [render.preserveDrawingBuffer=false] - [description] - * @property {boolean} [render.failIfMajorPerformanceCaveat=false] - [description] - * @property {string} [render.powerPreference='default'] - "high-performance", "low-power" or "default" - * @property {(string|number)} [backgroundColor=0x000000] - [description] - * @property {object} [callbacks] - [description] - * @property {BootCallback} [callbacks.preBoot=NOOP] - [description] - * @property {BootCallback} [callbacks.postBoot=NOOP] - [description] - * @property {LoaderConfig} [loader] - [description] - * @property {object} [images] - [description] - * @property {string} [images.default] - [description] - * @property {string} [images.missing] - [description] - * @property {object} [physics] - [description] + * @property {object} [scene=null] - A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have { active: true }. + * @property {string[]} [seed] - Seed for the random number generator. + * @property {string} [title=''] - The title of the game. Shown in the browser console. + * @property {string} [url='http://phaser.io'] - The URL of the game. Shown in the browser console. + * @property {string} [version=''] - The version of the game. Shown in the browser console. + * @property {boolean} [autoFocus=true] - Automatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame. + * @property {(boolean|InputConfig)} [input] - Input configuration, or `false` to disable all game input. + * @property {boolean} [disableContextMenu=false] - Disable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click). + * @property {(boolean|BannerConfig)} [banner=false] - Configuration for the banner printed in the browser console when the game starts. + * @property {DOMContainerConfig} [dom] - The DOM Container configuration object. + * @property {FPSConfig} [fps] - Game loop configuration. + * @property {RenderConfig} [render] - Game renderer configuration. + * @property {(string|number)} [backgroundColor=0x000000] - The background color of the game canvas. The default is black. + * @property {CallbacksConfig} [callbacks] - Optional callbacks to run before or after game boot. + * @property {LoaderConfig} [loader] - Loader configuration. + * @property {ImagesConfig} [images] - Images configuration. + * @property {object} [physics] - Physics configuration. + * @property {PluginObject|PluginObjectItem[]} [plugins] - Plugins to install. */ /** * @classdesc - * [description] + * The active game configuration settings, parsed from a {@link GameConfig} object. * * @class Config - * @memberOf Phaser.Boot + * @memberof Phaser.Boot * @constructor * @since 3.0.0 * * @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. + * + * @see Phaser.Game#config */ var Config = new Class({ @@ -109154,16 +144592,65 @@ var Config = new Class({ */ this.resolution = GetValue(config, 'resolution', 1); - /** - * @const {number} Phaser.Boot.Config#renderType - [description] - */ - this.renderType = GetValue(config, 'type', CONST.AUTO); - /** * @const {?*} Phaser.Boot.Config#parent - [description] */ this.parent = GetValue(config, 'parent', null); + /** + * @const {integer} Phaser.Boot.Config#scaleMode - [description] + */ + this.scaleMode = GetValue(config, 'scaleMode', 0); + + /** + * @const {boolean} Phaser.Boot.Config#expandParent - [description] + */ + this.expandParent = GetValue(config, 'expandParent', false); + + /** + * @const {integer} Phaser.Boot.Config#minWidth - [description] + */ + this.minWidth = GetValue(config, 'minWidth', 0); + + /** + * @const {integer} Phaser.Boot.Config#maxWidth - [description] + */ + this.maxWidth = GetValue(config, 'maxWidth', 0); + + /** + * @const {integer} Phaser.Boot.Config#minHeight - [description] + */ + this.minHeight = GetValue(config, 'minHeight', 0); + + /** + * @const {integer} Phaser.Boot.Config#maxHeight - [description] + */ + this.maxHeight = GetValue(config, 'maxHeight', 0); + + // Scale Manager - Anything set in here over-rides anything set above + + var scaleConfig = GetValue(config, 'scale', null); + + if (scaleConfig) + { + this.width = GetValue(scaleConfig, 'width', this.width); + this.height = GetValue(scaleConfig, 'height', this.height); + this.zoom = GetValue(scaleConfig, 'zoom', this.zoom); + this.resolution = GetValue(scaleConfig, 'resolution', this.resolution); + this.parent = GetValue(scaleConfig, 'parent', this.parent); + this.scaleMode = GetValue(scaleConfig, 'mode', this.scaleMode); + this.expandParent = GetValue(scaleConfig, 'mode', this.expandParent); + this.minWidth = GetValue(scaleConfig, 'min.width', this.minWidth); + this.maxWidth = GetValue(scaleConfig, 'max.width', this.maxWidth); + this.minHeight = GetValue(scaleConfig, 'min.height', this.minHeight); + this.maxHeight = GetValue(scaleConfig, 'max.height', this.maxHeight); + } + + /** + * @const {number} Phaser.Boot.Config#renderType - Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) + */ + this.renderType = GetValue(config, 'type', CONST.AUTO); + /** * @const {?HTMLCanvasElement} Phaser.Boot.Config#canvas - Force Phaser to use your own Canvas element instead of creating one. */ @@ -109192,17 +144679,17 @@ var Config = new Class({ MATH.RND.init(this.seed); /** - * @const {string} Phaser.Boot.Config#gameTitle - [description] + * @const {string} Phaser.Boot.Config#gameTitle - The title of the game. */ this.gameTitle = GetValue(config, 'title', ''); /** - * @const {string} Phaser.Boot.Config#gameURL - [description] + * @const {string} Phaser.Boot.Config#gameURL - The URL of the game. */ this.gameURL = GetValue(config, 'url', 'https://phaser.io'); /** - * @const {string} Phaser.Boot.Config#gameVersion - [description] + * @const {string} Phaser.Boot.Config#gameVersion - The version of the game. */ this.gameVersion = GetValue(config, 'version', ''); @@ -109211,6 +144698,18 @@ var Config = new Class({ */ this.autoFocus = GetValue(config, 'autoFocus', true); + // DOM Element Container + + /** + * @const {?boolean} Phaser.Boot.Config#domCreateContainer - [description] + */ + this.domCreateContainer = GetValue(config, 'dom.createContainer', false); + + /** + * @const {?boolean} Phaser.Boot.Config#domBehindCanvas - [description] + */ + this.domBehindCanvas = GetValue(config, 'dom.behindCanvas', false); + // Input /** @@ -109241,7 +144740,7 @@ var Config = new Class({ /** * @const {boolean} Phaser.Boot.Config#inputTouch - [description] */ - this.inputTouch = GetValue(config, 'input.touch', true); + this.inputTouch = GetValue(config, 'input.touch', Device.input.touch); /** * @const {?*} Phaser.Boot.Config#inputTouchEventTarget - [description] @@ -109269,7 +144768,7 @@ var Config = new Class({ this.inputGamepadEventTarget = GetValue(config, 'input.gamepad.target', window); /** - * @const {boolean} Phaser.Boot.Config#disableContextMenu - [description] + * @const {boolean} Phaser.Boot.Config#disableContextMenu - Set to `true` to disable context menu. Default value is `false`. */ this.disableContextMenu = GetValue(config, 'disableContextMenu', false); @@ -109323,33 +144822,39 @@ var Config = new Class({ var renderConfig = GetValue(config, 'render', config); + /** + * @const {boolean} Phaser.Boot.Config#autoResize - Automatically resize the Game Canvas if you resize the renderer. + */ + this.autoResize = GetValue(renderConfig, 'autoResize', true); + /** * @const {boolean} Phaser.Boot.Config#antialias - [description] */ this.antialias = GetValue(renderConfig, 'antialias', true); - /** - * @const {boolean} Phaser.Boot.Config#pixelArt - [description] - */ - this.pixelArt = GetValue(renderConfig, 'pixelArt', false); - - /** - * @const {boolean} Phaser.Boot.Config#autoResize - [description] - */ - this.autoResize = GetValue(renderConfig, 'autoResize', false); - /** * @const {boolean} Phaser.Boot.Config#roundPixels - [description] */ this.roundPixels = GetValue(renderConfig, 'roundPixels', false); + /** + * @const {boolean} Phaser.Boot.Config#pixelArt - Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode). + */ + this.pixelArt = GetValue(renderConfig, 'pixelArt', false); + + if (this.pixelArt) + { + this.antialias = false; + this.roundPixels = true; + } + /** * @const {boolean} Phaser.Boot.Config#transparent - [description] */ this.transparent = GetValue(renderConfig, 'transparent', false); /** - * @const {boolean} Phaser.Boot.Config#zoclearBeforeRenderom - [description] + * @const {boolean} Phaser.Boot.Config#clearBeforeRender - [description] */ this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true); @@ -109373,6 +144878,16 @@ var Config = new Class({ */ this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default'); + /** + * @const {integer} Phaser.Boot.Config#batchSize - The default WebGL Batch size. + */ + this.batchSize = GetValue(renderConfig, 'batchSize', 2000); + + /** + * @const {integer} Phaser.Boot.Config#maxLights - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + this.maxLights = GetValue(renderConfig, 'maxLights', 10); + var bgc = GetValue(config, 'backgroundColor', 0); /** @@ -109428,7 +144943,7 @@ var Config = new Class({ this.loaderPath = GetValue(config, 'loader.path', ''); /** - * @const {integer} Phaser.Boot.Config#loaderMaxParallelDownloads - [description] + * @const {integer} Phaser.Boot.Config#loaderMaxParallelDownloads - Maximum parallel downloads allowed for resources (Default to 32). */ this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 32); @@ -109470,15 +144985,15 @@ var Config = new Class({ * * plugins: { * global: [ - * { key: 'TestPlugin', plugin: TestPlugin, start: true }, + * { key: 'TestPlugin', plugin: TestPlugin, start: true, data: { msg: 'The plugin is alive' } }, * ], * scene: [ * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } * ], * default: [], OR - * defaultMerge: { + * defaultMerge: [ * 'ModPlayer' - * } + * ] * } */ @@ -109530,11 +145045,23 @@ var Config = new Class({ * @const {string} Phaser.Boot.Config#defaultImage - [description] */ this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); - + /** * @const {string} Phaser.Boot.Config#missingImage - [description] */ this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); + + if (window) + { + if (window.FORCE_WEBGL) + { + this.renderType = CONST.WEBGL; + } + else if (window.FORCE_CANVAS) + { + this.renderType = CONST.CANVAS; + } + } } }); @@ -109543,7 +145070,7 @@ module.exports = Config; /***/ }), -/* 534 */ +/* 904 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -109552,25 +145079,32 @@ module.exports = Config; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AddToDOM = __webpack_require__(130); -var AnimationManager = __webpack_require__(207); -var CacheManager = __webpack_require__(205); -var CanvasPool = __webpack_require__(22); +var AddToDOM = __webpack_require__(169); +var AnimationManager = __webpack_require__(381); +var CacheManager = __webpack_require__(379); +var CanvasPool = __webpack_require__(24); var Class = __webpack_require__(0); -var Config = __webpack_require__(533); -var CreateRenderer = __webpack_require__(532); -var DataManager = __webpack_require__(81); -var DebugHeader = __webpack_require__(524); -var Device = __webpack_require__(523); -var DOMContentLoaded = __webpack_require__(271); -var EventEmitter = __webpack_require__(9); -var InputManager = __webpack_require__(201); -var PluginManager = __webpack_require__(196); -var SceneManager = __webpack_require__(194); -var SoundManagerCreator = __webpack_require__(191); -var TextureManager = __webpack_require__(184); -var TimeStep = __webpack_require__(506); -var VisibilityHandler = __webpack_require__(505); +var Config = __webpack_require__(903); +var CreateRenderer = __webpack_require__(898); +var DataManager = __webpack_require__(123); +var DebugHeader = __webpack_require__(891); +var Device = __webpack_require__(340); +var DOMContentLoaded = __webpack_require__(344); +var EventEmitter = __webpack_require__(11); +var InputManager = __webpack_require__(338); +var PluginCache = __webpack_require__(15); +var PluginManager = __webpack_require__(331); +var SceneManager = __webpack_require__(329); +var SoundManagerCreator = __webpack_require__(325); +var TextureManager = __webpack_require__(318); +var TimeStep = __webpack_require__(878); +var VisibilityHandler = __webpack_require__(877); + +if (false) +{ var CreateDOMContainer; } + +if (false) +{ var FacebookInstantGamesPlugin; } /** * @classdesc @@ -109583,7 +145117,7 @@ var VisibilityHandler = __webpack_require__(505); * made available to you via the Phaser.Scene Systems class instead. * * @class Game - * @memberOf Phaser + * @memberof Phaser * @constructor * @since 3.0.0 * @@ -109602,7 +145136,7 @@ var Game = new Class({ * * @name Phaser.Game#config * @type {Phaser.Boot.Config} - * @readOnly + * @readonly * @since 3.0.0 */ this.config = new Config(config); @@ -109616,6 +145150,9 @@ var Game = new Class({ */ this.renderer = null; + if (false) + {} + /** * A reference to the HTML Canvas Element that Phaser uses to render the game. * This is created automatically by Phaser unless you provide a `canvas` property @@ -109645,7 +145182,7 @@ var Game = new Class({ * * @name Phaser.Game#isBooted * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ this.isBooted = false; @@ -109655,7 +145192,7 @@ var Game = new Class({ * * @name Phaser.Game#isRunning * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ this.isRunning = false; @@ -109780,6 +145317,9 @@ var Game = new Class({ */ this.plugins = new PluginManager(this, this.config); + if (false) + {} + /** * Is this Game pending destruction at the start of the next frame? * @@ -109800,13 +145340,24 @@ var Game = new Class({ */ this.removeCanvas = false; + /** + * Remove everything when the game is destroyed. + * You cannot create a new Phaser instance on the same web page after doing this. + * + * @name Phaser.Game#noReturn + * @type {boolean} + * @private + * @since 3.12.0 + */ + this.noReturn = false; + /** * Does the window the game is running in currently have focus or not? * This is modified by the VisibilityHandler. * * @name Phaser.Game#hasFocus * @type {boolean} - * @readOnly + * @readonly * @since 3.9.0 */ this.hasFocus = false; @@ -109817,7 +145368,7 @@ var Game = new Class({ * * @name Phaser.Game#isOver * @type {boolean} - * @readOnly + * @readonly * @since 3.10.0 */ this.isOver = true; @@ -109847,20 +145398,47 @@ var Game = new Class({ */ boot: function () { + if (!PluginCache.hasCore('EventEmitter')) + { + console.warn('Aborting. Core Plugins missing.'); + return; + } + this.isBooted = true; this.config.preBoot(this); CreateRenderer(this); + if (false) + {} + DebugHeader(this); AddToDOM(this.canvas, this.config.parent); this.events.emit('boot'); - // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event - this.events.once('ready', this.start, this); + // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready. + // So it will emit this internal event when done: + this.events.once('texturesready', this.texturesReady, this); + }, + + /** + * Called automatically when the Texture Manager has finished setting up and preparing the + * default textures. + * + * @method Phaser.Game#texturesReady + * @private + * @fires Phaser.Game#ready + * @since 3.12.0 + */ + texturesReady: function () + { + // Start all the other systems + this.events.emit('ready'); + + this.start(); }, /** @@ -109899,40 +145477,48 @@ var Game = new Class({ /** * Game Pre-Step event. + * + * Listen for it using the event type `prestep`. * * This event is dispatched before the main Step starts. * By this point none of the Scene updates have happened. * Hook into it from plugins or systems that need to update before the Scene Manager does. * * @event Phaser.Game#prestepEvent - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ /** * Game Step event. + * + * Listen for it using the event type `step`. * * This event is dispatched after Pre-Step and before the Scene Manager steps. * Hook into it from plugins or systems that need to update before the Scene Manager does, but after core Systems. * * @event Phaser.Game#stepEvent - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ /** * Game Post-Step event. + * + * Listen for it using the event type `poststep`. * * This event is dispatched after the Scene Manager has updated. * Hook into it from plugins or systems that need to do things before the render starts. * * @event Phaser.Game#poststepEvent - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ /** * Game Pre-Render event. + * + * Listen for it using the event type `prerender`. * * This event is dispatched immediately before any of the Scenes have started to render. * The renderer will already have been initialized this frame, clearing itself and preparing to receive @@ -109944,6 +145530,8 @@ var Game = new Class({ /** * Game Post-Render event. + * + * Listen for it using the event type `postrender`. * * This event is dispatched right at the end of the render process. * Every Scene will have rendered and drawn to the canvas. @@ -109968,8 +145556,8 @@ var Game = new Class({ * @fires Phaser.Game#postrenderEvent * @since 3.0.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. + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ step: function (time, delta) { @@ -110032,8 +145620,8 @@ var Game = new Class({ * @fires Phaser.Game#postrenderEvent * @since 3.2.0 * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ headlessStep: function (time, delta) { @@ -110060,6 +145648,8 @@ var Game = new Class({ /** * Game Pause event. + * + * Listen for it using the event type `pause`. * * This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler. * @@ -110084,6 +145674,8 @@ var Game = new Class({ /** * Game Resume event. + * + * Listen for it using the event type `resume`. * * This event is dispatched when the game loop leaves a paused state and resumes running. * @@ -110138,6 +145730,8 @@ var Game = new Class({ /** * Game Resize event. + * + * Listen for it using the event type `resize`. * * @event Phaser.Game#resizeEvent * @param {number} width - The new width of the Game. @@ -110149,6 +145743,7 @@ var Game = new Class({ * Then resizes the Renderer and Input Manager scale. * * @method Phaser.Game#resize + * @fires Phaser.Game#resizeEvent * @since 3.2.0 * * @param {number} width - The new width of the game. @@ -110159,6 +145754,9 @@ var Game = new Class({ this.config.width = width; this.config.height = height; + if (false) + {} + this.renderer.resize(width, height); this.input.resize(); @@ -110168,20 +145766,36 @@ var Game = new Class({ this.events.emit('resize', width, height); }, + /** + * Game Destroy event. + * + * Listen for it using the event type `destroy`. + * + * @event Phaser.Game#destroyEvent + */ + /** * Flags this Game instance as needing to be destroyed on the next frame. * It will wait until the current frame has completed and then call `runDestroy` internally. + * + * If you **do not** need to run Phaser again on the same web page you can set the `noReturn` argument to `true` and it will free-up + * memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as `false`. * * @method Phaser.Game#destroy + * @fires Phaser.Game#destroyEvent * @since 3.0.0 * * @param {boolean} removeCanvas - Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. + * @param {boolean} [noReturn=false] - If `true` all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this. */ - destroy: function (removeCanvas) + destroy: function (removeCanvas, noReturn) { + if (noReturn === undefined) { noReturn = false; } + this.pendingDestroy = true; this.removeCanvas = removeCanvas; + this.noReturn = noReturn; }, /** @@ -110214,8 +145828,11 @@ var Game = new Class({ } } - this.loop.destroy(); + if (false) + {} + this.loop.destroy(); + this.pendingDestroy = false; } @@ -110225,7 +145842,7 @@ module.exports = Game; /***/ }), -/* 535 */ +/* 905 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -110235,15 +145852,15 @@ module.exports = Game; */ var Class = __webpack_require__(0); -var EE = __webpack_require__(9); -var PluginCache = __webpack_require__(12); +var EE = __webpack_require__(11); +var PluginCache = __webpack_require__(15); /** * @classdesc * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. * * @class EventEmitter - * @memberOf Phaser.Events + * @memberof Phaser.Events * @constructor * @since 3.0.0 */ @@ -110409,7 +146026,7 @@ module.exports = EventEmitter; /***/ }), -/* 536 */ +/* 906 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -110422,11 +146039,11 @@ module.exports = EventEmitter; * @namespace Phaser.Events */ -module.exports = { EventEmitter: __webpack_require__(535) }; +module.exports = { EventEmitter: __webpack_require__(905) }; /***/ }), -/* 537 */ +/* 907 */ /***/ (function(module, exports) { // shim for using process in browser @@ -110616,7 +146233,34 @@ process.umask = function() { return 0; }; /***/ }), -/* 538 */ +/* 908 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.DOM + */ + +var Dom = { + + AddToDOM: __webpack_require__(169), + DOMContentLoaded: __webpack_require__(344), + ParseXML: __webpack_require__(343), + RemoveFromDOM: __webpack_require__(342), + RequestAnimationFrame: __webpack_require__(341) + +}; + +module.exports = Dom; + + +/***/ }), +/* 909 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -110631,14 +146275,14 @@ process.umask = function() { return 0; }; module.exports = { - BitmapMask: __webpack_require__(214), - GeometryMask: __webpack_require__(213) + BitmapMask: __webpack_require__(394), + GeometryMask: __webpack_require__(393) }; /***/ }), -/* 539 */ +/* 910 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -110647,82 +146291,312 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetColor = __webpack_require__(152); +var ComponentToHex = __webpack_require__(346); /** - * Converts an HSV (hue, saturation and value) color value to RGB. - * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes HSV values are contained in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) + * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. * - * @function Phaser.Display.Color.HSVToRGB + * @function Phaser.Display.Color.RGBToString * @since 3.0.0 * - * @param {number} h - The hue, in the range 0 - 1. - * @param {number} s - The saturation, in the range 0 - 1. - * @param {number} v - The value, in the range 0 - 1. + * @param {integer} r - The red color value. A number between 0 and 255. + * @param {integer} g - The green color value. A number between 0 and 255. + * @param {integer} b - The blue color value. A number between 0 and 255. + * @param {integer} [a=255] - The alpha value. A number between 0 and 255. + * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + * @return {string} A string-based representation of the color values. */ -var HSVToRGB = function (h, s, v) +var RGBToString = function (r, g, b, a, prefix) +{ + if (a === undefined) { a = 255; } + if (prefix === undefined) { prefix = '#'; } + + if (prefix === '#') + { + return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); + } + else + { + return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); + } +}; + +module.exports = RGBToString; + + +/***/ }), +/* 911 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Between = __webpack_require__(170); +var Color = __webpack_require__(37); + +/** + * Creates a new Color object where the r, g, and b values have been set to random values + * based on the given min max values. + * + * @function Phaser.Display.Color.RandomRGB + * @since 3.0.0 + * + * @param {integer} [min=0] - The minimum value to set the random range from (between 0 and 255) + * @param {integer} [max=255] - The maximum value to set the random range from (between 0 and 255) + * + * @return {Phaser.Display.Color} A Color object. + */ +var RandomRGB = function (min, max) +{ + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + return new Color(Between(min, max), Between(min, max), Between(min, max)); +}; + +module.exports = RandomRGB; + + +/***/ }), +/* 912 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Linear = __webpack_require__(119); + +/** + * Interpolates color values + * + * @namespace Phaser.Display.Color.Interpolate + * @since 3.0.0 + */ + +/** + * Interpolates between the two given color ranges over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.RGBWithRGB + * @since 3.0.0 + * + * @param {number} r1 - Red value. + * @param {number} g1 - Blue value. + * @param {number} b1 - Green value. + * @param {number} r2 - Red value. + * @param {number} g2 - Blue value. + * @param {number} b2 - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + var t = index / length; + + return { + r: Linear(r1, r2, t), + g: Linear(g1, g2, t), + b: Linear(b1, b2, t) + }; +}; + +/** + * Interpolates between the two given color objects over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithColor + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {Phaser.Display.Color} color2 - The second Color object. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithColor = function (color1, color2, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); +}; + +/** + * Interpolates between the Color object and color values over the length supplied. + * + * @function Phaser.Display.Color.Interpolate.ColorWithRGB + * @since 3.0.0 + * + * @param {Phaser.Display.Color} color1 - The first Color object. + * @param {number} r - Red value. + * @param {number} g - Blue value. + * @param {number} b - Green value. + * @param {number} [length=100] - Distance to interpolate over. + * @param {number} [index=0] - Index to start from. + * + * @return {ColorObject} An object containing the interpolated color values. + */ +var ColorWithRGB = function (color, r, g, b, length, index) +{ + if (length === undefined) { length = 100; } + if (index === undefined) { index = 0; } + + return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); +}; + +module.exports = { + + RGBWithRGB: RGBWithRGB, + ColorWithRGB: ColorWithRGB, + ColorWithColor: ColorWithColor + +}; + + +/***/ }), +/* 913 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var HSVToRGB = __webpack_require__(176); + +/** + * Get HSV color wheel values in an array which will be 360 elements in size. + * + * @function Phaser.Display.Color.HSVColorWheel + * @since 3.0.0 + * + * @param {number} [s=1] - The saturation, in the range 0 - 1. + * @param {number} [v=1] - The value, in the range 0 - 1. + * + * @return {ColorObject[]} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel. + */ +var HSVColorWheel = function (s, v) { if (s === undefined) { s = 1; } if (v === undefined) { v = 1; } - var i = Math.floor(h * 6); - var f = h * 6 - i; + var colors = []; - var p = Math.floor((v * (1 - s)) * 255); - var q = Math.floor((v * (1 - f * s)) * 255); - var t = Math.floor((v * (1 - (1 - f) * s)) * 255); - - v = Math.floor(v *= 255); - - var output = { r: v, g: v, b: v, color: 0 }; - - var r = i % 6; - - if (r === 0) + for (var c = 0; c <= 359; c++) { - output.g = t; - output.b = p; - } - else if (r === 1) - { - output.r = q; - output.b = p; - } - else if (r === 2) - { - output.r = p; - output.b = t; - } - else if (r === 3) - { - output.r = p; - output.g = q; - } - else if (r === 4) - { - output.r = t; - output.g = p; - } - else if (r === 5) - { - output.g = p; - output.b = q; + colors.push(HSVToRGB(c / 359, s, v)); } - output.color = GetColor(output.r, output.g, output.b); + return colors; +}; + +module.exports = HSVColorWheel; + + +/***/ }), +/* 914 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Color = __webpack_require__(37); +var HueToComponent = __webpack_require__(345); + +/** + * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. + * + * @function Phaser.Display.Color.HSLToColor + * @since 3.0.0 + * + * @param {number} h - The hue value in the range 0 to 1. + * @param {number} s - The saturation value in the range 0 to 1. + * @param {number} l - The lightness value in the range 0 to 1. + * + * @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values. + */ +var HSLToColor = function (h, s, l) +{ + // achromatic by default + var r = l; + var g = l; + var b = l; + + if (s !== 0) + { + var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; + var p = 2 * l - q; + + r = HueToComponent(p, q, h + 1 / 3); + g = HueToComponent(p, q, h); + b = HueToComponent(p, q, h - 1 / 3); + } + + var color = new Color(); + + return color.setGLTo(r, g, b, 1); +}; + +module.exports = HSLToColor; + + +/***/ }), +/* 915 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Converts the given color value into an Object containing r,g,b and a properties. + * + * @function Phaser.Display.Color.ColorToRGBA + * @since 3.0.0 + * + * @param {number} color - A color value, optionally including the alpha value. + * + * @return {ColorObject} An object containing the parsed color values. + */ +var ColorToRGBA = function (color) +{ + var output = { + r: color >> 16 & 0xFF, + g: color >> 8 & 0xFF, + b: color & 0xFF, + a: 255 + }; + + if (color > 16777215) + { + output.a = color >>> 24; + } return output; }; -module.exports = HSVToRGB; +module.exports = ColorToRGBA; /***/ }), -/* 540 */ +/* 916 */ /***/ (function(module, exports) { /** @@ -110732,53 +146606,44 @@ module.exports = HSVToRGB; */ /** - * Converts a hue to an RGB color. - * Based on code by Michael Jackson (https://github.com/mjijackson) + * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. * - * @function Phaser.Display.Color.HueToComponent + * @function Phaser.Display.Canvas.UserSelect * @since 3.0.0 * - * @param {number} p - * @param {number} q - * @param {number} t + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts. * - * @return {number} The combined color value. + * @return {HTMLCanvasElement} The canvas element. */ -var HueToComponent = function (p, q, t) +var UserSelect = function (canvas, value) { - if (t < 0) - { - t += 1; - } + if (value === undefined) { value = 'none'; } - if (t > 1) - { - t -= 1; - } + var vendors = [ + '-webkit-', + '-khtml-', + '-moz-', + '-ms-', + '' + ]; - if (t < 1 / 6) + vendors.forEach(function (vendor) { - return p + (q - p) * 6 * t; - } + canvas.style[vendor + 'user-select'] = value; + }); - if (t < 1 / 2) - { - return q; - } + canvas.style['-webkit-touch-callout'] = value; + canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; - if (t < 2 / 3) - { - return p + (q - p) * (2 / 3 - t) * 6; - } - - return p; + return canvas; }; -module.exports = HueToComponent; +module.exports = UserSelect; /***/ }), -/* 541 */ +/* 917 */ /***/ (function(module, exports) { /** @@ -110788,27 +146653,32 @@ module.exports = HueToComponent; */ /** - * Returns a string containing a hex representation of the given color component. + * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. * - * @function Phaser.Display.Color.ComponentToHex + * @function Phaser.Display.Canvas.TouchAction * @since 3.0.0 * - * @param {integer} color - The color channel to get the hex value for, must be a value between 0 and 255. + * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. + * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. * - * @return {string} A string of length 2 characters, i.e. 255 = ff, 100 = 64. + * @return {HTMLCanvasElement} The canvas element. */ -var ComponentToHex = function (color) +var TouchAction = function (canvas, value) { - var hex = color.toString(16); + if (value === undefined) { value = 'none'; } - return (hex.length === 1) ? '0' + hex : hex; + canvas.style['msTouchAction'] = value; + canvas.style['ms-touch-action'] = value; + canvas.style['touch-action'] = value; + + return canvas; }; -module.exports = ComponentToHex; +module.exports = TouchAction; /***/ }), -/* 542 */ +/* 918 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -110818,48 +146688,762 @@ module.exports = ComponentToHex; */ /** - * @typedef {object} InputColorObject - * - * @property {number} [r] - The red color value in the range 0 to 255. - * @property {number} [g] - The green color value in the range 0 to 255. - * @property {number} [b] - The blue color value in the range 0 to 255. - * @property {number} [a] - The alpha color value in the range 0 to 255. + * @namespace Phaser.Display.Canvas */ -/** - * @typedef {Object} ColorObject - * @property {number} r - The red color value in the range 0 to 255. - * @property {number} g - The green color value in the range 0 to 255. - * @property {number} b - The blue color value in the range 0 to 255. - * @property {number} a - The alpha color value in the range 0 to 255. - */ +module.exports = { -var Color = __webpack_require__(30); - -Color.ColorToRGBA = __webpack_require__(923); -Color.ComponentToHex = __webpack_require__(541); -Color.GetColor = __webpack_require__(152); -Color.GetColor32 = __webpack_require__(284); -Color.HexStringToColor = __webpack_require__(285); -Color.HSLToColor = __webpack_require__(922); -Color.HSVColorWheel = __webpack_require__(921); -Color.HSVToRGB = __webpack_require__(539); -Color.HueToComponent = __webpack_require__(540); -Color.IntegerToColor = __webpack_require__(283); -Color.IntegerToRGB = __webpack_require__(282); -Color.Interpolate = __webpack_require__(920); -Color.ObjectToColor = __webpack_require__(281); -Color.RandomRGB = __webpack_require__(919); -Color.RGBStringToColor = __webpack_require__(280); -Color.RGBToHSV = __webpack_require__(918); -Color.RGBToString = __webpack_require__(917); -Color.ValueToColor = __webpack_require__(132); - -module.exports = Color; + CanvasInterpolation: __webpack_require__(348), + CanvasPool: __webpack_require__(24), + Smoothing: __webpack_require__(120), + TouchAction: __webpack_require__(917), + UserSelect: __webpack_require__(916) + +}; /***/ }), -/* 543 */ +/* 919 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its y coordinate. + * This is the same as `width * origin.y`. + * This value will only be > 0 if `origin.y` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetY + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The vertical offset of the Game Object. + */ +var GetOffsetY = function (gameObject) +{ + return gameObject.height * gameObject.originY; +}; + +module.exports = GetOffsetY; + + +/***/ }), +/* 920 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Returns the amount the Game Object is visually offset from its x coordinate. + * This is the same as `width * origin.x`. + * This value will only be > 0 if `origin.x` is not equal to zero. + * + * @function Phaser.Display.Bounds.GetOffsetX + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. + * + * @return {number} The horizontal offset of the Game Object. + */ +var GetOffsetX = function (gameObject) +{ + return gameObject.width * gameObject.originX; +}; + +module.exports = GetOffsetX; + + +/***/ }), +/* 921 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Bounds + */ + +module.exports = { + + CenterOn: __webpack_require__(411), + GetBottom: __webpack_require__(48), + GetCenterX: __webpack_require__(75), + GetCenterY: __webpack_require__(72), + GetLeft: __webpack_require__(46), + GetOffsetX: __webpack_require__(920), + GetOffsetY: __webpack_require__(919), + GetRight: __webpack_require__(44), + GetTop: __webpack_require__(42), + SetBottom: __webpack_require__(47), + SetCenterX: __webpack_require__(74), + SetCenterY: __webpack_require__(73), + SetLeft: __webpack_require__(45), + SetRight: __webpack_require__(43), + SetTop: __webpack_require__(41) + +}; + + +/***/ }), +/* 922 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(44); +var GetTop = __webpack_require__(42); +var SetBottom = __webpack_require__(47); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. + * + * @function Phaser.Display.Align.To.TopRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopRight; + + +/***/ }), +/* 923 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(46); +var GetTop = __webpack_require__(42); +var SetBottom = __webpack_require__(47); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. + * + * @function Phaser.Display.Align.To.TopLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopLeft; + + +/***/ }), +/* 924 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterX = __webpack_require__(75); +var GetTop = __webpack_require__(42); +var SetBottom = __webpack_require__(47); +var SetCenterX = __webpack_require__(74); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. + * + * @function Phaser.Display.Align.To.TopCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var TopCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetBottom(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = TopCenter; + + +/***/ }), +/* 925 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetRight = __webpack_require__(44); +var GetTop = __webpack_require__(42); +var SetLeft = __webpack_require__(45); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. + * + * @function Phaser.Display.Align.To.RightTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = RightTop; + + +/***/ }), +/* 926 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(72); +var GetRight = __webpack_require__(44); +var SetCenterY = __webpack_require__(73); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. + * + * @function Phaser.Display.Align.To.RightCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightCenter; + + +/***/ }), +/* 927 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetRight = __webpack_require__(44); +var SetBottom = __webpack_require__(47); +var SetLeft = __webpack_require__(45); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. + * + * @function Phaser.Display.Align.To.RightBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var RightBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetRight(alignTo) + offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = RightBottom; + + +/***/ }), +/* 928 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetLeft = __webpack_require__(46); +var GetTop = __webpack_require__(42); +var SetRight = __webpack_require__(43); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. + * + * @function Phaser.Display.Align.To.LeftTop + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftTop = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetTop(alignTo) - offsetY); + + return gameObject; +}; + +module.exports = LeftTop; + + +/***/ }), +/* 929 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetCenterY = __webpack_require__(72); +var GetLeft = __webpack_require__(46); +var SetCenterY = __webpack_require__(73); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. + * + * @function Phaser.Display.Align.To.LeftCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftCenter; + + +/***/ }), +/* 930 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetLeft = __webpack_require__(46); +var SetBottom = __webpack_require__(47); +var SetRight = __webpack_require__(43); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. + * + * @function Phaser.Display.Align.To.LeftBottom + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetLeft(alignTo) - offsetX); + SetBottom(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = LeftBottom; + + +/***/ }), +/* 931 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetRight = __webpack_require__(44); +var SetRight = __webpack_require__(43); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. + * + * @function Phaser.Display.Align.To.BottomRight + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomRight = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetRight(gameObject, GetRight(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomRight; + + +/***/ }), +/* 932 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetLeft = __webpack_require__(46); +var SetLeft = __webpack_require__(45); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. + * + * @function Phaser.Display.Align.To.BottomLeft + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetLeft(gameObject, GetLeft(alignTo) - offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomLeft; + + +/***/ }), +/* 933 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBottom = __webpack_require__(48); +var GetCenterX = __webpack_require__(75); +var SetCenterX = __webpack_require__(74); +var SetTop = __webpack_require__(41); + +/** + * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. + * + * @function Phaser.Display.Align.To.BottomCenter + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. + * @param {number} [offsetX=0] - Optional horizontal offset from the position. + * @param {number} [offsetY=0] - Optional vertical offset from the position. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. + */ +var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) +{ + if (offsetX === undefined) { offsetX = 0; } + if (offsetY === undefined) { offsetY = 0; } + + SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); + SetTop(gameObject, GetBottom(alignTo) + offsetY); + + return gameObject; +}; + +module.exports = BottomCenter; + + +/***/ }), +/* 934 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.To + */ + +module.exports = { + + BottomCenter: __webpack_require__(933), + BottomLeft: __webpack_require__(932), + BottomRight: __webpack_require__(931), + LeftBottom: __webpack_require__(930), + LeftCenter: __webpack_require__(929), + LeftTop: __webpack_require__(928), + RightBottom: __webpack_require__(927), + RightCenter: __webpack_require__(926), + RightTop: __webpack_require__(925), + TopCenter: __webpack_require__(924), + TopLeft: __webpack_require__(923), + TopRight: __webpack_require__(922) + +}; + + +/***/ }), +/* 935 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display.Align.In + */ + +module.exports = { + + BottomCenter: __webpack_require__(415), + BottomLeft: __webpack_require__(414), + BottomRight: __webpack_require__(413), + Center: __webpack_require__(412), + LeftCenter: __webpack_require__(410), + QuickSet: __webpack_require__(416), + RightCenter: __webpack_require__(409), + TopCenter: __webpack_require__(408), + TopLeft: __webpack_require__(407), + TopRight: __webpack_require__(406) + +}; + + +/***/ }), +/* 936 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(193); +var Extend = __webpack_require__(20); + +/** + * @namespace Phaser.Display.Align + */ + +var Align = { + + In: __webpack_require__(935), + To: __webpack_require__(934) + +}; + +// Merge in the consts +Align = Extend(false, Align, CONST); + +module.exports = Align; + + +/***/ }), +/* 937 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Display + */ + +module.exports = { + + Align: __webpack_require__(936), + Bounds: __webpack_require__(921), + Canvas: __webpack_require__(918), + Color: __webpack_require__(347), + Masks: __webpack_require__(909) + +}; + + +/***/ }), +/* 938 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -110869,8 +147453,8 @@ module.exports = Color; */ var Class = __webpack_require__(0); -var DataManager = __webpack_require__(81); -var PluginCache = __webpack_require__(12); +var DataManager = __webpack_require__(123); +var PluginCache = __webpack_require__(15); /** * @classdesc @@ -110880,7 +147464,7 @@ var PluginCache = __webpack_require__(12); * * @class DataManagerPlugin * @extends Phaser.Data.DataManager - * @memberOf Phaser.Data + * @memberof Phaser.Data * @constructor * @since 3.0.0 * @@ -110985,7 +147569,7 @@ module.exports = DataManagerPlugin; /***/ }), -/* 544 */ +/* 939 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -111000,30558 +147584,16 @@ module.exports = DataManagerPlugin; module.exports = { - DataManager: __webpack_require__(81), - DataManagerPlugin: __webpack_require__(543) + DataManager: __webpack_require__(123), + DataManagerPlugin: __webpack_require__(938) }; -/***/ }), -/* 545 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var CatmullRom = __webpack_require__(273); -var Class = __webpack_require__(0); -var Curve = __webpack_require__(86); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class Spline - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2[]} [points] - [description] - */ -var SplineCurve = new Class({ - - Extends: Curve, - - initialize: - - function SplineCurve (points) - { - if (points === undefined) { points = []; } - - Curve.call(this, 'SplineCurve'); - - /** - * [description] - * - * @name Phaser.Curves.Spline#points - * @type {Phaser.Math.Vector2[]} - * @default [] - * @since 3.0.0 - */ - this.points = []; - - this.addPoints(points); - }, - - /** - * [description] - * - * @method Phaser.Curves.Spline#addPoints - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2[]|number[]|number[][])} points - [description] - * - * @return {Phaser.Curves.Spline} This curve object. - */ - addPoints: function (points) - { - for (var i = 0; i < points.length; i++) - { - var p = new Vector2(); - - if (typeof points[i] === 'number') - { - p.x = points[i]; - p.y = points[i + 1]; - i++; - } - else if (Array.isArray(points[i])) - { - // An array of arrays? - p.x = points[i][0]; - p.y = points[i][1]; - } - else - { - p.x = points[i].x; - p.y = points[i].y; - } - - this.points.push(p); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Curves.Spline#addPoint - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - addPoint: function (x, y) - { - var vec = new Vector2(x, y); - - this.points.push(vec); - - return vec; - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.Spline#getStartPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.points[0]); - }, - - /** - * [description] - * - * @method Phaser.Curves.Spline#getResolution - * @since 3.0.0 - * - * @param {number} divisions - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - return divisions * this.points.length; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.Spline#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var points = this.points; - - var point = (points.length - 1) * t; - - var intPoint = Math.floor(point); - - var weight = point - intPoint; - - var p0 = points[(intPoint === 0) ? intPoint : intPoint - 1]; - var p1 = points[intPoint]; - var p2 = points[(intPoint > points.length - 2) ? points.length - 1 : intPoint + 1]; - var p3 = points[(intPoint > points.length - 3) ? points.length - 1 : intPoint + 2]; - - return out.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.Spline#toJSON - * @since 3.0.0 - * - * @return {JSONCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - var points = []; - - for (var i = 0; i < this.points.length; i++) - { - points.push(this.points[i].x); - points.push(this.points[i].y); - } - - return { - type: this.type, - points: points - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.Spline.fromJSON - * @since 3.0.0 - * - * @param {JSONCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.Spline} [description] - */ -SplineCurve.fromJSON = function (data) -{ - return new SplineCurve(data.points); -}; - -module.exports = SplineCurve; - - -/***/ }), -/* 546 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function P0 (t, p) -{ - var k = 1 - t; - - return k * k * p; -} - -function P1 (t, p) -{ - return 2 * (1 - t) * t * p; -} - -function P2 (t, p) -{ - return t * t * p; -} - -// p0 = start point -// p1 = control point 1 -// p2 = end point - -// https://github.com/mrdoob/three.js/blob/master/src/extras/core/Interpolations.js - -/** - * A quadratic bezier interpolation method. - * - * @function Phaser.Math.Interpolation.QuadraticBezier - * @since 3.2.0 - * - * @param {float} t - The percentage of interpolation, between 0 and 1. - * @param {number} p0 - The start point. - * @param {number} p1 - The control point. - * @param {number} p2 - The end point. - * - * @return {number} The interpolated value. - */ -var QuadraticBezierInterpolation = function (t, p0, p1, p2) -{ - return P0(t, p0) + P1(t, p1) + P2(t, p2); -}; - -module.exports = QuadraticBezierInterpolation; - - -/***/ }), -/* 547 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(86); -var QuadraticBezierInterpolation = __webpack_require__(546); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class QuadraticBezier - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.2.0 - * - * @param {(Phaser.Math.Vector2|number[])} p0 - Start point, or an array of point pairs. - * @param {Phaser.Math.Vector2} p1 - Control Point 1. - * @param {Phaser.Math.Vector2} p2 - Control Point 2. - */ -var QuadraticBezier = new Class({ - - Extends: Curve, - - initialize: - - function QuadraticBezier (p0, p1, p2) - { - Curve.call(this, 'QuadraticBezier'); - - if (Array.isArray(p0)) - { - p2 = new Vector2(p0[4], p0[5]); - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p0 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p1 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p1 = p1; - - /** - * [description] - * - * @name Phaser.Curves.QuadraticBezier#p2 - * @type {Phaser.Math.Vector2} - * @since 3.2.0 - */ - this.p2 = p2; - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.QuadraticBezier#getStartPoint - * @since 3.2.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#getResolution - * @since 3.2.0 - * - * @param {number} divisions - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - return divisions; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.QuadraticBezier#getPoint - * @since 3.2.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var p0 = this.p0; - var p1 = this.p1; - var p2 = this.p2; - - return out.set( - QuadraticBezierInterpolation(t, p0.x, p1.x, p2.x), - QuadraticBezierInterpolation(t, p0.y, p1.y, p2.y) - ); - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#draw - * @since 3.2.0 - * - * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - if (pointsTotal === undefined) { pointsTotal = 32; } - - var points = this.getPoints(pointsTotal); - - graphics.beginPath(); - graphics.moveTo(this.p0.x, this.p0.y); - - for (var i = 1; i < points.length; i++) - { - graphics.lineTo(points[i].x, points[i].y); - } - - graphics.strokePath(); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.QuadraticBezier#toJSON - * @since 3.2.0 - * - * @return {JSONCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y, - this.p2.x, this.p2.y - ] - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.QuadraticBezier.fromJSON - * @since 3.2.0 - * - * @param {JSONCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.QuadraticBezier} [description] - */ -QuadraticBezier.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - var p2 = new Vector2(points[4], points[5]); - - return new QuadraticBezier(p0, p1, p2); -}; - -module.exports = QuadraticBezier; - - -/***/ }), -/* 548 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(86); -var FromPoints = __webpack_require__(274); -var Rectangle = __webpack_require__(14); -var Vector2 = __webpack_require__(6); - -var tmpVec2 = new Vector2(); - -/** - * @classdesc - * [description] - * - * @class Line - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|number[])} p0 - [description] - * @param {Phaser.Math.Vector2} [p1] - [description] - */ -var LineCurve = new Class({ - - Extends: Curve, - - initialize: - - // vec2s or array - function LineCurve (p0, p1) - { - Curve.call(this, 'LineCurve'); - - if (Array.isArray(p0)) - { - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } - - /** - * [description] - * - * @name Phaser.Curves.Line#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.Line#p1 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p1 = p1; - }, - - /** - * Returns a Rectangle where the position and dimensions match the bounds of this Curve. - * - * @method Phaser.Curves.Line#getBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} [out] - A Rectangle object to store the bounds in. If not given a new Rectangle will be created. - * - * @return {Phaser.Geom.Rectangle} A Rectangle object holding the bounds of this curve. If `out` was given it will be this object. - */ - getBounds: function (out) - { - if (out === undefined) { out = new Rectangle(); } - - return FromPoints([ this.p0, this.p1 ], out); - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.Line#getStartPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.Line#getResolution - * @since 3.0.0 - * - * @param {number} [divisions=1] - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - if (divisions === undefined) { divisions = 1; } - - return divisions; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.Line#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - if (t === 1) - { - return out.copy(this.p1); - } - - out.copy(this.p1).subtract(this.p0).scale(t).add(this.p0); - - return out; - }, - - // Line curve is linear, so we can overwrite default getPointAt - - /** - * [description] - * - * @method Phaser.Curves.Line#getPointAt - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} u - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPointAt: function (u, out) - { - return this.getPoint(u, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.Line#getTangent - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @return {Phaser.Math.Vector2} [description] - */ - getTangent: function () - { - var tangent = tmpVec2.copy(this.p1).subtract(this.p0); - - return tangent.normalize(); - }, - - // Override default Curve.draw because this is better than calling getPoints on a line! - - /** - * Draws this curve on the given Graphics object. - * - * The curve is drawn using `Graphics.lineBetween` so will be drawn at whatever the present Graphics line color is. - * The Graphics object is not cleared before the draw, so the curve will appear on-top of anything else already rendered to it. - * - * @method Phaser.Curves.Line#draw - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] - * - * @param {Phaser.GameObjects.Graphics} graphics - The Graphics instance onto which this curve will be drawn. - * - * @return {Phaser.GameObjects.Graphics} The Graphics object to which the curve was drawn. - */ - draw: function (graphics) - { - graphics.lineBetween(this.p0.x, this.p0.y, this.p1.x, this.p1.y); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.Line#toJSON - * @since 3.0.0 - * - * @return {JSONCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y - ] - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.Line.fromJSON - * @since 3.0.0 - * - * @param {JSONCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.Line} [description] - */ -LineCurve.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - - return new LineCurve(p0, p1); -}; - -module.exports = LineCurve; - - -/***/ }), -/* 549 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var Curve = __webpack_require__(86); -var DegToRad = __webpack_require__(38); -var GetValue = __webpack_require__(4); -var RadToDeg = __webpack_require__(150); -var Vector2 = __webpack_require__(6); - -/** - * @typedef {object} JSONEllipseCurve - * - * @property {string} type - The of the curve. - * @property {number} x - [description] - * @property {number} y - [description] - * @property {number} xRadius - The horizontal radius of ellipse. - * @property {number} yRadius - The vertical radius of ellipse. - * @property {integer} startAngle - The start angle of ellipse. - * @property {integer} endAngle - The end angle of ellipse. - * @property {boolean} clockwise - The clockwise of ellipse. - * @property {integer} rotation - The rotation of ellipse. - */ - -/** - * @typedef {object} EllipseCurveConfig - * - * @property {number} [x=0] - [description] - * @property {number} [y=0] - [description] - * @property {number} [xRadius=0] - [description] - * @property {number} [yRadius=0] - [description] - * @property {integer} [startAngle=0] - [description] - * @property {integer} [endAngle=360] - [description] - * @property {boolean} [clockwise=false] - [description] - * @property {integer} [rotation=0] - [description] - */ - -/** - * @classdesc - * [description] - * - * @class Ellipse - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {(number|EllipseCurveConfig)} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [xRadius=0] - [description] - * @param {number} [yRadius=0] - [description] - * @param {integer} [startAngle=0] - [description] - * @param {integer} [endAngle=360] - [description] - * @param {boolean} [clockwise=false] - [description] - * @param {integer} [rotation=0] - [description] - */ -var EllipseCurve = new Class({ - - Extends: Curve, - - initialize: - - function EllipseCurve (x, y, xRadius, yRadius, startAngle, endAngle, clockwise, rotation) - { - if (typeof x === 'object') - { - var config = x; - - x = GetValue(config, 'x', 0); - y = GetValue(config, 'y', 0); - xRadius = GetValue(config, 'xRadius', 0); - yRadius = GetValue(config, 'yRadius', xRadius); - startAngle = GetValue(config, 'startAngle', 0); - endAngle = GetValue(config, 'endAngle', 360); - clockwise = GetValue(config, 'clockwise', false); - rotation = GetValue(config, 'rotation', 0); - } - else - { - if (yRadius === undefined) { yRadius = xRadius; } - if (startAngle === undefined) { startAngle = 0; } - if (endAngle === undefined) { endAngle = 360; } - if (clockwise === undefined) { clockwise = false; } - if (rotation === undefined) { rotation = 0; } - } - - Curve.call(this, 'EllipseCurve'); - - // Center point - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = new Vector2(x, y); - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#_xRadius - * @type {number} - * @private - * @since 3.0.0 - */ - this._xRadius = xRadius; - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#_yRadius - * @type {number} - * @private - * @since 3.0.0 - */ - this._yRadius = yRadius; - - // Radians - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#_startAngle - * @type {number} - * @private - * @since 3.0.0 - */ - this._startAngle = DegToRad(startAngle); - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#_endAngle - * @type {number} - * @private - * @since 3.0.0 - */ - this._endAngle = DegToRad(endAngle); - - /** - * Anti-clockwise direction. - * - * @name Phaser.Curves.Ellipse#_clockwise - * @type {boolean} - * @private - * @since 3.0.0 - */ - this._clockwise = clockwise; - - /** - * The rotation of the arc. - * - * @name Phaser.Curves.Ellipse#_rotation - * @type {number} - * @private - * @since 3.0.0 - */ - this._rotation = DegToRad(rotation); - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.Ellipse#getStartPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return this.getPoint(0, out); - }, - - /** - * [description] - * - * @method Phaser.Curves.Ellipse#getResolution - * @since 3.0.0 - * - * @param {number} divisions - [description] - * - * @return {number} [description] - */ - getResolution: function (divisions) - { - return divisions * 2; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.Ellipse#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var twoPi = Math.PI * 2; - var deltaAngle = this._endAngle - this._startAngle; - var samePoints = Math.abs(deltaAngle) < Number.EPSILON; - - // ensures that deltaAngle is 0 .. 2 PI - while (deltaAngle < 0) - { - deltaAngle += twoPi; - } - - while (deltaAngle > twoPi) - { - deltaAngle -= twoPi; - } - - if (deltaAngle < Number.EPSILON) - { - if (samePoints) - { - deltaAngle = 0; - } - else - { - deltaAngle = twoPi; - } - } - - if (this._clockwise && !samePoints) - { - if (deltaAngle === twoPi) - { - deltaAngle = - twoPi; - } - else - { - deltaAngle = deltaAngle - twoPi; - } - } - - var angle = this._startAngle + t * deltaAngle; - var x = this.p0.x + this._xRadius * Math.cos(angle); - var y = this.p0.y + this._yRadius * Math.sin(angle); - - if (this._rotation !== 0) - { - var cos = Math.cos(this._rotation); - var sin = Math.sin(this._rotation); - - var tx = x - this.p0.x; - var ty = y - this.p0.y; - - // Rotate the point about the center of the ellipse. - x = tx * cos - ty * sin + this.p0.x; - y = tx * sin + ty * cos + this.p0.y; - } - - return out.set(x, y); - }, - - /** - * Sets the horizontal radius of this curve. - * - * @method Phaser.Curves.Ellipse#setXRadius - * @since 3.0.0 - * - * @param {number} value - The horizontal radius of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setXRadius: function (value) - { - this.xRadius = value; - - return this; - }, - - /** - * Sets the vertical radius of this curve. - * - * @method Phaser.Curves.Ellipse#setYRadius - * @since 3.0.0 - * - * @param {number} value - The vertical radius of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setYRadius: function (value) - { - this.yRadius = value; - - return this; - }, - - /** - * Sets the width of this curve. - * - * @method Phaser.Curves.Ellipse#setWidth - * @since 3.0.0 - * - * @param {number} value - The width of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setWidth: function (value) - { - this.xRadius = value * 2; - - return this; - }, - - /** - * Sets the height of this curve. - * - * @method Phaser.Curves.Ellipse#setHeight - * @since 3.0.0 - * - * @param {number} value - The height of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setHeight: function (value) - { - this.yRadius = value * 2; - - return this; - }, - - /** - * Sets the start angle of this curve. - * - * @method Phaser.Curves.Ellipse#setStartAngle - * @since 3.0.0 - * - * @param {number} value - The start angle of this curve, in radians. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setStartAngle: function (value) - { - this.startAngle = value; - - return this; - }, - - /** - * Sets the end angle of this curve. - * - * @method Phaser.Curves.Ellipse#setEndAngle - * @since 3.0.0 - * - * @param {number} value - The end angle of this curve, in radians. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setEndAngle: function (value) - { - this.endAngle = value; - - return this; - }, - - /** - * Sets if this curve extends clockwise or anti-clockwise. - * - * @method Phaser.Curves.Ellipse#setClockwise - * @since 3.0.0 - * - * @param {boolean} value - The clockwise state of this curve. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setClockwise: function (value) - { - this.clockwise = value; - - return this; - }, - - /** - * Sets the rotation of this curve. - * - * @method Phaser.Curves.Ellipse#setRotation - * @since 3.0.0 - * - * @param {number} value - The rotation of this curve, in radians. - * - * @return {Phaser.Curves.Ellipse} This curve object. - */ - setRotation: function (value) - { - this.rotation = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#x - * @type {number} - * @since 3.0.0 - */ - x: { - - get: function () - { - return this.p0.x; - }, - - set: function (value) - { - this.p0.x = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#y - * @type {number} - * @since 3.0.0 - */ - y: { - - get: function () - { - return this.p0.y; - }, - - set: function (value) - { - this.p0.y = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#xRadius - * @type {number} - * @since 3.0.0 - */ - xRadius: { - - get: function () - { - return this._xRadius; - }, - - set: function (value) - { - this._xRadius = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#yRadius - * @type {number} - * @since 3.0.0 - */ - yRadius: { - - get: function () - { - return this._yRadius; - }, - - set: function (value) - { - this._yRadius = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#startAngle - * @type {number} - * @since 3.0.0 - */ - startAngle: { - - get: function () - { - return RadToDeg(this._startAngle); - }, - - set: function (value) - { - this._startAngle = DegToRad(value); - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#endAngle - * @type {number} - * @since 3.0.0 - */ - endAngle: { - - get: function () - { - return RadToDeg(this._endAngle); - }, - - set: function (value) - { - this._endAngle = DegToRad(value); - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#clockwise - * @type {boolean} - * @since 3.0.0 - */ - clockwise: { - - get: function () - { - return this._clockwise; - }, - - set: function (value) - { - this._clockwise = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Curves.Ellipse#rotation - * @type {number} - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this._rotation; - }, - - set: function (value) - { - this._rotation = DegToRad(value); - } - - }, - - /** - * [description] - * - * @method Phaser.Curves.Ellipse#toJSON - * @since 3.0.0 - * - * @return {JSONEllipseCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - return { - type: this.type, - x: this.p0.x, - y: this.p0.y, - xRadius: this._xRadius, - yRadius: this._yRadius, - startAngle: RadToDeg(this._startAngle), - endAngle: RadToDeg(this._endAngle), - clockwise: this._clockwise, - rotation: RadToDeg(this._rotation) - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.Ellipse.fromJSON - * @since 3.0.0 - * - * @param {JSONEllipseCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.Ellipse} [description] - */ -EllipseCurve.fromJSON = function (data) -{ - return new EllipseCurve(data); -}; - -module.exports = EllipseCurve; - - -/***/ }), -/* 550 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -function P0 (t, p) -{ - var k = 1 - t; - - return k * k * k * p; -} - -function P1 (t, p) -{ - var k = 1 - t; - - return 3 * k * k * t * p; -} - -function P2 (t, p) -{ - return 3 * (1 - t) * t * t * p; -} - -function P3 (t, p) -{ - return t * t * t * p; -} - -// p0 = start point -// p1 = control point 1 -// p2 = control point 2 -// p3 = end point - -// https://medium.com/@adrian_cooney/bezier-interpolation-13b68563313a - -/** - * A cubic bezier interpolation method. - * - * @function Phaser.Math.Interpolation.CubicBezier - * @since 3.0.0 - * - * @param {float} t - The percentage of interpolation, between 0 and 1. - * @param {number} p0 - The start point. - * @param {number} p1 - The first control point. - * @param {number} p2 - The second control point. - * @param {number} p3 - The end point. - * - * @return {number} The interpolated value. - */ -var CubicBezierInterpolation = function (t, p0, p1, p2, p3) -{ - return P0(t, p0) + P1(t, p1) + P2(t, p2) + P3(t, p3); -}; - -module.exports = CubicBezierInterpolation; - - -/***/ }), -/* 551 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) - -var Class = __webpack_require__(0); -var CubicBezier = __webpack_require__(550); -var Curve = __webpack_require__(86); -var Vector2 = __webpack_require__(6); - -/** - * @classdesc - * [description] - * - * @class CubicBezier - * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves - * @constructor - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector2[])} p0 - Start point, or an array of point pairs. - * @param {Phaser.Math.Vector2} p1 - Control Point 1. - * @param {Phaser.Math.Vector2} p2 - Control Point 2. - * @param {Phaser.Math.Vector2} p3 - End Point. - */ -var CubicBezierCurve = new Class({ - - Extends: Curve, - - initialize: - - function CubicBezierCurve (p0, p1, p2, p3) - { - Curve.call(this, 'CubicBezierCurve'); - - if (Array.isArray(p0)) - { - p3 = new Vector2(p0[6], p0[7]); - p2 = new Vector2(p0[4], p0[5]); - p1 = new Vector2(p0[2], p0[3]); - p0 = new Vector2(p0[0], p0[1]); - } - - /** - * [description] - * - * @name Phaser.Curves.CubicBezier#p0 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p0 = p0; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezier#p1 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p1 = p1; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezier#p2 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p2 = p2; - - /** - * [description] - * - * @name Phaser.Curves.CubicBezier#p3 - * @type {Phaser.Math.Vector2} - * @since 3.0.0 - */ - this.p3 = p3; - }, - - /** - * Gets the starting point on the curve. - * - * @method Phaser.Curves.CubicBezier#getStartPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getStartPoint: function (out) - { - if (out === undefined) { out = new Vector2(); } - - return out.copy(this.p0); - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezier#getResolution - * @since 3.0.0 - * - * @param {number} divisions - The amount of divisions used by this curve. - * - * @return {number} The resolution of the curve. - */ - getResolution: function (divisions) - { - return divisions; - }, - - /** - * Get point at relative position in curve according to length. - * - * @method Phaser.Curves.CubicBezier#getPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. - * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. - * - * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. - */ - getPoint: function (t, out) - { - if (out === undefined) { out = new Vector2(); } - - var p0 = this.p0; - var p1 = this.p1; - var p2 = this.p2; - var p3 = this.p3; - - return out.set(CubicBezier(t, p0.x, p1.x, p2.x, p3.x), CubicBezier(t, p0.y, p1.y, p2.y, p3.y)); - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezier#draw - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] - * - * @return {Phaser.GameObjects.Graphics} [description] - */ - draw: function (graphics, pointsTotal) - { - if (pointsTotal === undefined) { pointsTotal = 32; } - - var points = this.getPoints(pointsTotal); - - graphics.beginPath(); - graphics.moveTo(this.p0.x, this.p0.y); - - for (var i = 1; i < points.length; i++) - { - graphics.lineTo(points[i].x, points[i].y); - } - - graphics.strokePath(); - - // So you can chain graphics calls - return graphics; - }, - - /** - * [description] - * - * @method Phaser.Curves.CubicBezier#toJSON - * @since 3.0.0 - * - * @return {JSONCurve} The JSON object containing this curve data. - */ - toJSON: function () - { - return { - type: this.type, - points: [ - this.p0.x, this.p0.y, - this.p1.x, this.p1.y, - this.p2.x, this.p2.y, - this.p3.x, this.p3.y - ] - }; - } - -}); - -/** - * [description] - * - * @function Phaser.Curves.CubicBezier.fromJSON - * @since 3.0.0 - * - * @param {JSONCurve} data - The JSON object containing this curve data. - * - * @return {Phaser.Curves.CubicBezier} [description] - */ -CubicBezierCurve.fromJSON = function (data) -{ - var points = data.points; - - var p0 = new Vector2(points[0], points[1]); - var p1 = new Vector2(points[2], points[3]); - var p2 = new Vector2(points[4], points[5]); - var p3 = new Vector2(points[6], points[7]); - - return new CubicBezierCurve(p0, p1, p2, p3); -}; - -module.exports = CubicBezierCurve; - - -/***/ }), -/* 552 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(279); -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(87); - -// Local cache vars -var tmpVec3 = new Vector3(); - -/** - * @classdesc - * [description] - * - * @class PerspectiveCamera - * @extends Phaser.Cameras.Sprite3D.Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {integer} [fieldOfView=80] - [description] - * @param {integer} [viewportWidth=0] - [description] - * @param {integer} [viewportHeight=0] - [description] - */ -var PerspectiveCamera = new Class({ - - Extends: Camera, - - // FOV is converted to radians automatically - initialize: - - function PerspectiveCamera (scene, fieldOfView, viewportWidth, viewportHeight) - { - if (fieldOfView === undefined) { fieldOfView = 80; } - if (viewportWidth === undefined) { viewportWidth = 0; } - if (viewportHeight === undefined) { viewportHeight = 0; } - - Camera.call(this, scene); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportWidth - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.viewportWidth = viewportWidth; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportHeight - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - this.viewportHeight = viewportHeight; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#fieldOfView - * @type {integer} - * @default 80 - * @since 3.0.0 - */ - this.fieldOfView = fieldOfView * Math.PI / 180; - - this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#setFOV - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] - */ - setFOV: function (value) - { - this.fieldOfView = value * Math.PI / 180; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#update - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] - */ - update: function () - { - var aspect = this.viewportWidth / this.viewportHeight; - - // Create a perspective matrix for our camera - this.projection.perspective( - this.fieldOfView, - aspect, - Math.abs(this.near), - Math.abs(this.far) - ); - - // Build the view matrix - tmpVec3.copy(this.position).add(this.direction); - - this.view.lookAt(this.position, tmpVec3, this.up); - - // Projection * view matrix - this.combined.copy(this.projection).multiply(this.view); - - // Invert combined matrix, used for unproject - this.invProjectionView.copy(this.combined).invert(); - - this.billboardMatrixDirty = true; - - this.updateChildren(); - - return this; - } - -}); - -module.exports = PerspectiveCamera; - - -/***/ }), -/* 553 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(279); -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(87); - -// Local cache vars -var tmpVec3 = new Vector3(); - -/** - * @classdesc - * [description] - * - * @class OrthographicCamera - * @extends Phaser.Cameras.Sprite3D.Camera - * @memberOf Phaser.Cameras.Sprite3D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - * @param {integer} [viewportWidth=0] - [description] - * @param {integer} [viewportHeight=0] - [description] - */ -var OrthographicCamera = new Class({ - - Extends: Camera, - - initialize: - - function OrthographicCamera (scene, viewportWidth, viewportHeight) - { - if (viewportWidth === undefined) { viewportWidth = 0; } - if (viewportHeight === undefined) { viewportHeight = 0; } - - Camera.call(this, scene); - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportWidth - * @type {integer} - * @since 3.0.0 - */ - this.viewportWidth = viewportWidth; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportHeight - * @type {integer} - * @since 3.0.0 - */ - this.viewportHeight = viewportHeight; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom - * @type {float} - * @private - * @since 3.0.0 - */ - this._zoom = 1.0; - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#near - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.near = 0; - - this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.OrthographicCamera#setToOrtho - * @since 3.0.0 - * - * @param {number} yDown - [description] - * @param {number} [viewportWidth] - [description] - * @param {number} [viewportHeight] - [description] - * - * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] - */ - setToOrtho: function (yDown, viewportWidth, viewportHeight) - { - if (viewportWidth === undefined) { viewportWidth = this.viewportWidth; } - if (viewportHeight === undefined) { viewportHeight = this.viewportHeight; } - - var zoom = this.zoom; - - this.up.set(0, (yDown) ? -1 : 1, 0); - this.direction.set(0, 0, (yDown) ? 1 : -1); - this.position.set(zoom * viewportWidth / 2, zoom * viewportHeight / 2, 0); - - this.viewportWidth = viewportWidth; - this.viewportHeight = viewportHeight; - - return this.update(); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.OrthographicCamera#update - * @since 3.0.0 - * - * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] - */ - update: function () - { - var w = this.viewportWidth; - var h = this.viewportHeight; - var near = Math.abs(this.near); - var far = Math.abs(this.far); - var zoom = this.zoom; - - if (w === 0 || h === 0) - { - // What to do here... hmm? - return this; - } - - this.projection.ortho( - zoom * -w / 2, zoom * w / 2, - zoom * -h / 2, zoom * h / 2, - near, - far - ); - - // Build the view matrix - tmpVec3.copy(this.position).add(this.direction); - - this.view.lookAt(this.position, tmpVec3, this.up); - - // Projection * view matrix - this.combined.copy(this.projection).multiply(this.view); - - // Invert combined matrix, used for unproject - this.invProjectionView.copy(this.combined).invert(); - - this.billboardMatrixDirty = true; - - this.updateChildren(); - - return this; - }, - - /** - * [description] - * - * @name Phaser.Cameras.Sprite3D.OrthographicCamera#zoom - * @type {number} - * @since 3.0.0 - */ - zoom: { - - get: function () - { - return this._zoom; - }, - - set: function (value) - { - this._zoom = value; - this.update(); - } - } - -}); - -module.exports = OrthographicCamera; - - -/***/ }), -/* 554 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - renderer.drawImage(src, camera, parentMatrix); -}; - -module.exports = SpriteCanvasRenderer; - - -/***/ }), -/* 555 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Sprite#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchSprite(src, camera, parentMatrix); -}; - -module.exports = SpriteWebGLRenderer; - - -/***/ }), -/* 556 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(555); -} - -if (true) -{ - renderCanvas = __webpack_require__(554); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 557 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A three-dimensional matrix. - * - * Defaults to the identity matrix when instantiated. - * - * @class Matrix3 - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} [m] - Optional Matrix3 to copy values from. - */ -var Matrix3 = new Class({ - - initialize: - - function Matrix3 (m) - { - /** - * The matrix values. - * - * @name Phaser.Math.Matrix3#val - * @type {Float32Array} - * @since 3.0.0 - */ - this.val = new Float32Array(9); - - if (m) - { - // Assume Matrix3 with val: - this.copy(m); - } - else - { - // Default to identity - this.identity(); - } - }, - - /** - * Make a clone of this Matrix3. - * - * @method Phaser.Math.Matrix3#clone - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} A clone of this Matrix3. - */ - clone: function () - { - return new Matrix3(this); - }, - - /** - * This method is an alias for `Matrix3.copy`. - * - * @method Phaser.Math.Matrix3#set - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} src - The Matrix to set the values of this Matrix's from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - set: function (src) - { - return this.copy(src); - }, - - /** - * Copy the values of a given Matrix into this Matrix. - * - * @method Phaser.Math.Matrix3#copy - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} src - The Matrix to copy the values from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - copy: function (src) - { - var out = this.val; - var a = src.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - - return this; - }, - - /** - * Copy the values of a given Matrix4 into this Matrix3. - * - * @method Phaser.Math.Matrix3#fromMat4 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} m - The Matrix4 to copy the values from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - fromMat4: function (m) - { - var a = m.val; - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[4]; - out[4] = a[5]; - out[5] = a[6]; - out[6] = a[8]; - out[7] = a[9]; - out[8] = a[10]; - - return this; - }, - - /** - * Set the values of this Matrix from the given array. - * - * @method Phaser.Math.Matrix3#fromArray - * @since 3.0.0 - * - * @param {array} a - The array to copy the values from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - fromArray: function (a) - { - var out = this.val; - - out[0] = a[0]; - out[1] = a[1]; - out[2] = a[2]; - out[3] = a[3]; - out[4] = a[4]; - out[5] = a[5]; - out[6] = a[6]; - out[7] = a[7]; - out[8] = a[8]; - - return this; - }, - - /** - * Reset this Matrix to an identity (default) matrix. - * - * @method Phaser.Math.Matrix3#identity - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - identity: function () - { - var out = this.val; - - out[0] = 1; - out[1] = 0; - out[2] = 0; - out[3] = 0; - out[4] = 1; - out[5] = 0; - out[6] = 0; - out[7] = 0; - out[8] = 1; - - return this; - }, - - /** - * Transpose this Matrix. - * - * @method Phaser.Math.Matrix3#transpose - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - transpose: function () - { - var a = this.val; - var a01 = a[1]; - var a02 = a[2]; - var a12 = a[5]; - - a[1] = a[3]; - a[2] = a[6]; - a[3] = a01; - a[5] = a[7]; - a[6] = a02; - a[7] = a12; - - return this; - }, - - /** - * Invert this Matrix. - * - * @method Phaser.Math.Matrix3#invert - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - invert: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - var b01 = a22 * a11 - a12 * a21; - var b11 = -a22 * a10 + a12 * a20; - var b21 = a21 * a10 - a11 * a20; - - // Calculate the determinant - var det = a00 * b01 + a01 * b11 + a02 * b21; - - if (!det) - { - return null; - } - - det = 1 / det; - - a[0] = b01 * det; - a[1] = (-a22 * a01 + a02 * a21) * det; - a[2] = (a12 * a01 - a02 * a11) * det; - a[3] = b11 * det; - a[4] = (a22 * a00 - a02 * a20) * det; - a[5] = (-a12 * a00 + a02 * a10) * det; - a[6] = b21 * det; - a[7] = (-a21 * a00 + a01 * a20) * det; - a[8] = (a11 * a00 - a01 * a10) * det; - - return this; - }, - - /** - * Calculate the adjoint, or adjugate, of this Matrix. - * - * @method Phaser.Math.Matrix3#adjoint - * @since 3.0.0 - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - adjoint: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - a[0] = (a11 * a22 - a12 * a21); - a[1] = (a02 * a21 - a01 * a22); - a[2] = (a01 * a12 - a02 * a11); - a[3] = (a12 * a20 - a10 * a22); - a[4] = (a00 * a22 - a02 * a20); - a[5] = (a02 * a10 - a00 * a12); - a[6] = (a10 * a21 - a11 * a20); - a[7] = (a01 * a20 - a00 * a21); - a[8] = (a00 * a11 - a01 * a10); - - return this; - }, - - /** - * Calculate the determinant of this Matrix. - * - * @method Phaser.Math.Matrix3#determinant - * @since 3.0.0 - * - * @return {number} The determinant of this Matrix. - */ - determinant: function () - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); - }, - - /** - * Multiply this Matrix by the given Matrix. - * - * @method Phaser.Math.Matrix3#multiply - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} src - The Matrix to multiply this Matrix by. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - multiply: function (src) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - var a20 = a[6]; - var a21 = a[7]; - var a22 = a[8]; - - var b = src.val; - - var b00 = b[0]; - var b01 = b[1]; - var b02 = b[2]; - var b10 = b[3]; - var b11 = b[4]; - var b12 = b[5]; - var b20 = b[6]; - var b21 = b[7]; - var b22 = b[8]; - - a[0] = b00 * a00 + b01 * a10 + b02 * a20; - a[1] = b00 * a01 + b01 * a11 + b02 * a21; - a[2] = b00 * a02 + b01 * a12 + b02 * a22; - - a[3] = b10 * a00 + b11 * a10 + b12 * a20; - a[4] = b10 * a01 + b11 * a11 + b12 * a21; - a[5] = b10 * a02 + b11 * a12 + b12 * a22; - - a[6] = b20 * a00 + b21 * a10 + b22 * a20; - a[7] = b20 * a01 + b21 * a11 + b22 * a21; - a[8] = b20 * a02 + b21 * a12 + b22 * a22; - - return this; - }, - - /** - * Translate this Matrix using the given Vector. - * - * @method Phaser.Math.Matrix3#translate - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - translate: function (v) - { - var a = this.val; - var x = v.x; - var y = v.y; - - a[6] = x * a[0] + y * a[3] + a[6]; - a[7] = x * a[1] + y * a[4] + a[7]; - a[8] = x * a[2] + y * a[5] + a[8]; - - return this; - }, - - /** - * Apply a rotation transformation to this Matrix. - * - * @method Phaser.Math.Matrix3#rotate - * @since 3.0.0 - * - * @param {number} rad - The angle in radians to rotate by. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - rotate: function (rad) - { - var a = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a10 = a[3]; - var a11 = a[4]; - var a12 = a[5]; - - var s = Math.sin(rad); - var c = Math.cos(rad); - - a[0] = c * a00 + s * a10; - a[1] = c * a01 + s * a11; - a[2] = c * a02 + s * a12; - - a[3] = c * a10 - s * a00; - a[4] = c * a11 - s * a01; - a[5] = c * a12 - s * a02; - - return this; - }, - - /** - * Apply a scale transformation to this Matrix. - * - * Uses the `x` and `y` components of the given Vector to scale the Matrix. - * - * @method Phaser.Math.Matrix3#scale - * @since 3.0.0 - * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - scale: function (v) - { - var a = this.val; - var x = v.x; - var y = v.y; - - a[0] = x * a[0]; - a[1] = x * a[1]; - a[2] = x * a[2]; - - a[3] = y * a[3]; - a[4] = y * a[4]; - a[5] = y * a[5]; - - return this; - }, - - /** - * Set the values of this Matrix from the given Quaternion. - * - * @method Phaser.Math.Matrix3#fromQuat - * @since 3.0.0 - * - * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - fromQuat: function (q) - { - var x = q.x; - var y = q.y; - var z = q.z; - var w = q.w; - - var x2 = x + x; - var y2 = y + y; - var z2 = z + z; - - var xx = x * x2; - var xy = x * y2; - var xz = x * z2; - - var yy = y * y2; - var yz = y * z2; - var zz = z * z2; - - var wx = w * x2; - var wy = w * y2; - var wz = w * z2; - - var out = this.val; - - out[0] = 1 - (yy + zz); - out[3] = xy + wz; - out[6] = xz - wy; - - out[1] = xy - wz; - out[4] = 1 - (xx + zz); - out[7] = yz + wx; - - out[2] = xz + wy; - out[5] = yz - wx; - out[8] = 1 - (xx + yy); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Matrix3#normalFromMat4 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix4} m - [description] - * - * @return {Phaser.Math.Matrix3} This Matrix3. - */ - normalFromMat4: function (m) - { - var a = m.val; - var out = this.val; - - var a00 = a[0]; - var a01 = a[1]; - var a02 = a[2]; - var a03 = a[3]; - - var a10 = a[4]; - var a11 = a[5]; - var a12 = a[6]; - var a13 = a[7]; - - var a20 = a[8]; - var a21 = a[9]; - var a22 = a[10]; - var a23 = a[11]; - - var a30 = a[12]; - var a31 = a[13]; - var a32 = a[14]; - var a33 = a[15]; - - var b00 = a00 * a11 - a01 * a10; - var b01 = a00 * a12 - a02 * a10; - var b02 = a00 * a13 - a03 * a10; - var b03 = a01 * a12 - a02 * a11; - - var b04 = a01 * a13 - a03 * a11; - var b05 = a02 * a13 - a03 * a12; - var b06 = a20 * a31 - a21 * a30; - var b07 = a20 * a32 - a22 * a30; - - var b08 = a20 * a33 - a23 * a30; - var b09 = a21 * a32 - a22 * a31; - var b10 = a21 * a33 - a23 * a31; - var b11 = a22 * a33 - a23 * a32; - - // Calculate the determinant - var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; - - if (!det) - { - return null; - } - - det = 1 / det; - - out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; - out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; - out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; - - out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; - out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; - out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; - - out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; - out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; - out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; - - return this; - } - -}); - -module.exports = Matrix3; - - -/***/ }), -/* 558 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji -// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl - -var Class = __webpack_require__(0); -var Vector3 = __webpack_require__(87); -var Matrix3 = __webpack_require__(557); - -var EPSILON = 0.000001; - -// Some shared 'private' arrays -var siNext = new Int8Array([ 1, 2, 0 ]); -var tmp = new Float32Array([ 0, 0, 0 ]); - -var xUnitVec3 = new Vector3(1, 0, 0); -var yUnitVec3 = new Vector3(0, 1, 0); - -var tmpvec = new Vector3(); -var tmpMat3 = new Matrix3(); - -/** - * @classdesc - * A quaternion. - * - * @class Quaternion - * @memberOf Phaser.Math - * @constructor - * @since 3.0.0 - * - * @param {number} [x] - The x component. - * @param {number} [y] - The y component. - * @param {number} [z] - The z component. - * @param {number} [w] - The w component. - */ -var Quaternion = new Class({ - - initialize: - - function Quaternion (x, y, z, w) - { - /** - * The x component of this Quaternion. - * - * @name Phaser.Math.Quaternion#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The y component of this Quaternion. - * - * @name Phaser.Math.Quaternion#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The z component of this Quaternion. - * - * @name Phaser.Math.Quaternion#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - /** - * The w component of this Quaternion. - * - * @name Phaser.Math.Quaternion#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - }, - - /** - * Copy the components of a given Quaternion or Vector into this Quaternion. - * - * @method Phaser.Math.Quaternion#copy - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} src - The Quaternion or Vector to copy the components from. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - copy: function (src) - { - this.x = src.x; - this.y = src.y; - this.z = src.z; - this.w = src.w; - - return this; - }, - - /** - * Set the components of this Quaternion. - * - * @method Phaser.Math.Quaternion#set - * @since 3.0.0 - * - * @param {(number|object)} [x=0] - The x component, or an object containing x, y, z, and w components. - * @param {number} [y=0] - The y component. - * @param {number} [z=0] - The z component. - * @param {number} [w=0] - The w component. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - set: function (x, y, z, w) - { - if (typeof x === 'object') - { - this.x = x.x || 0; - this.y = x.y || 0; - this.z = x.z || 0; - this.w = x.w || 0; - } - else - { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; - this.w = w || 0; - } - - return this; - }, - - /** - * Add a given Quaternion or Vector to this Quaternion. Addition is component-wise. - * - * @method Phaser.Math.Quaternion#add - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to add to this Quaternion. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - add: function (v) - { - this.x += v.x; - this.y += v.y; - this.z += v.z; - this.w += v.w; - - return this; - }, - - /** - * Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise. - * - * @method Phaser.Math.Quaternion#subtract - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to subtract from this Quaternion. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - subtract: function (v) - { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - this.w -= v.w; - - return this; - }, - - /** - * Scale this Quaternion by the given value. - * - * @method Phaser.Math.Quaternion#scale - * @since 3.0.0 - * - * @param {number} scale - The value to scale this Quaternion by. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - scale: function (scale) - { - this.x *= scale; - this.y *= scale; - this.z *= scale; - this.w *= scale; - - return this; - }, - - /** - * Calculate the length of this Quaternion. - * - * @method Phaser.Math.Quaternion#length - * @since 3.0.0 - * - * @return {number} The length of this Quaternion. - */ - length: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return Math.sqrt(x * x + y * y + z * z + w * w); - }, - - /** - * Calculate the length of this Quaternion squared. - * - * @method Phaser.Math.Quaternion#lengthSq - * @since 3.0.0 - * - * @return {number} The length of this Quaternion, squared. - */ - lengthSq: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - - return x * x + y * y + z * z + w * w; - }, - - /** - * Normalize this Quaternion. - * - * @method Phaser.Math.Quaternion#normalize - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - normalize: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - var w = this.w; - var len = x * x + y * y + z * z + w * w; - - if (len > 0) - { - len = 1 / Math.sqrt(len); - - this.x = x * len; - this.y = y * len; - this.z = z * len; - this.w = w * len; - } - - return this; - }, - - /** - * Calculate the dot product of this Quaternion and the given Quaternion or Vector. - * - * @method Phaser.Math.Quaternion#dot - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to dot product with this Quaternion. - * - * @return {number} The dot product of this Quaternion and the given Quaternion or Vector. - */ - dot: function (v) - { - return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; - }, - - /** - * Linearly interpolate this Quaternion towards the given Quaternion or Vector. - * - * @method Phaser.Math.Quaternion#lerp - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to interpolate towards. - * @param {number} [t=0] - The percentage of interpolation. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - lerp: function (v, t) - { - if (t === undefined) { t = 0; } - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - this.x = ax + t * (v.x - ax); - this.y = ay + t * (v.y - ay); - this.z = az + t * (v.z - az); - this.w = aw + t * (v.w - aw); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Math.Quaternion#rotationTo - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} a - [description] - * @param {Phaser.Math.Vector3} b - [description] - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - rotationTo: function (a, b) - { - var dot = a.x * b.x + a.y * b.y + a.z * b.z; - - if (dot < -0.999999) - { - if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) - { - tmpvec.copy(yUnitVec3).cross(a); - } - - tmpvec.normalize(); - - return this.setAxisAngle(tmpvec, Math.PI); - - } - else if (dot > 0.999999) - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 1; - - return this; - } - else - { - tmpvec.copy(a).cross(b); - - this.x = tmpvec.x; - this.y = tmpvec.y; - this.z = tmpvec.z; - this.w = 1 + dot; - - return this.normalize(); - } - }, - - /** - * Set the axes of this Quaternion. - * - * @method Phaser.Math.Quaternion#setAxes - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} view - The view axis. - * @param {Phaser.Math.Vector3} right - The right axis. - * @param {Phaser.Math.Vector3} up - The upwards axis. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - setAxes: function (view, right, up) - { - var m = tmpMat3.val; - - m[0] = right.x; - m[3] = right.y; - m[6] = right.z; - - m[1] = up.x; - m[4] = up.y; - m[7] = up.z; - - m[2] = -view.x; - m[5] = -view.y; - m[8] = -view.z; - - return this.fromMat3(tmpMat3).normalize(); - }, - - /** - * Reset this Matrix to an identity (default) Quaternion. - * - * @method Phaser.Math.Quaternion#identity - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - identity: function () - { - this.x = 0; - this.y = 0; - this.z = 0; - this.w = 1; - - return this; - }, - - /** - * Set the axis angle of this Quaternion. - * - * @method Phaser.Math.Quaternion#setAxisAngle - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} axis - The axis. - * @param {number} rad - The angle in radians. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - setAxisAngle: function (axis, rad) - { - rad = rad * 0.5; - - var s = Math.sin(rad); - - this.x = s * axis.x; - this.y = s * axis.y; - this.z = s * axis.z; - this.w = Math.cos(rad); - - return this; - }, - - /** - * Multiply this Quaternion by the given Quaternion or Vector. - * - * @method Phaser.Math.Quaternion#multiply - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to multiply this Quaternion by. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - multiply: function (b) - { - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = b.x; - var by = b.y; - var bz = b.z; - var bw = b.w; - - this.x = ax * bw + aw * bx + ay * bz - az * by; - this.y = ay * bw + aw * by + az * bx - ax * bz; - this.z = az * bw + aw * bz + ax * by - ay * bx; - this.w = aw * bw - ax * bx - ay * by - az * bz; - - return this; - }, - - /** - * Smoothly linearly interpolate this Quaternion towards the given Quaternion or Vector. - * - * @method Phaser.Math.Quaternion#slerp - * @since 3.0.0 - * - * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to interpolate towards. - * @param {number} t - The percentage of interpolation. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - slerp: function (b, t) - { - // benchmarks: http://jsperf.com/quaternion-slerp-implementations - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = b.x; - var by = b.y; - var bz = b.z; - var bw = b.w; - - // calc cosine - var cosom = ax * bx + ay * by + az * bz + aw * bw; - - // adjust signs (if necessary) - if (cosom < 0) - { - cosom = -cosom; - bx = - bx; - by = - by; - bz = - bz; - bw = - bw; - } - - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - var scale0 = 1 - t; - var scale1 = t; - - // calculate coefficients - if ((1 - cosom) > EPSILON) - { - // standard case (slerp) - var omega = Math.acos(cosom); - var sinom = Math.sin(omega); - - scale0 = Math.sin((1.0 - t) * omega) / sinom; - scale1 = Math.sin(t * omega) / sinom; - } - - // calculate final values - this.x = scale0 * ax + scale1 * bx; - this.y = scale0 * ay + scale1 * by; - this.z = scale0 * az + scale1 * bz; - this.w = scale0 * aw + scale1 * bw; - - return this; - }, - - /** - * Invert this Quaternion. - * - * @method Phaser.Math.Quaternion#invert - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - invert: function () - { - var a0 = this.x; - var a1 = this.y; - var a2 = this.z; - var a3 = this.w; - - var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; - var invDot = (dot) ? 1 / dot : 0; - - // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 - - this.x = -a0 * invDot; - this.y = -a1 * invDot; - this.z = -a2 * invDot; - this.w = a3 * invDot; - - return this; - }, - - /** - * Convert this Quaternion into its conjugate. - * - * Sets the x, y and z components. - * - * @method Phaser.Math.Quaternion#conjugate - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - conjugate: function () - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - - return this; - }, - - /** - * Rotate this Quaternion on the X axis. - * - * @method Phaser.Math.Quaternion#rotateX - * @since 3.0.0 - * - * @param {number} rad - The rotation angle in radians. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - rotateX: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bx = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw + aw * bx; - this.y = ay * bw + az * bx; - this.z = az * bw - ay * bx; - this.w = aw * bw - ax * bx; - - return this; - }, - - /** - * Rotate this Quaternion on the Y axis. - * - * @method Phaser.Math.Quaternion#rotateY - * @since 3.0.0 - * - * @param {number} rad - The rotation angle in radians. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - rotateY: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var by = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw - az * by; - this.y = ay * bw + aw * by; - this.z = az * bw + ax * by; - this.w = aw * bw - ay * by; - - return this; - }, - - /** - * Rotate this Quaternion on the Z axis. - * - * @method Phaser.Math.Quaternion#rotateZ - * @since 3.0.0 - * - * @param {number} rad - The rotation angle in radians. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - rotateZ: function (rad) - { - rad *= 0.5; - - var ax = this.x; - var ay = this.y; - var az = this.z; - var aw = this.w; - - var bz = Math.sin(rad); - var bw = Math.cos(rad); - - this.x = ax * bw + ay * bz; - this.y = ay * bw - ax * bz; - this.z = az * bw + aw * bz; - this.w = aw * bw - az * bz; - - return this; - }, - - /** - * Create a unit (or rotation) Quaternion from its x, y, and z components. - * - * Sets the w component. - * - * @method Phaser.Math.Quaternion#calculateW - * @since 3.0.0 - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - calculateW: function () - { - var x = this.x; - var y = this.y; - var z = this.z; - - this.w = -Math.sqrt(1.0 - x * x - y * y - z * z); - - return this; - }, - - /** - * Convert the given Matrix into this Quaternion. - * - * @method Phaser.Math.Quaternion#fromMat3 - * @since 3.0.0 - * - * @param {Phaser.Math.Matrix3} mat - The Matrix to convert from. - * - * @return {Phaser.Math.Quaternion} This Quaternion. - */ - fromMat3: function (mat) - { - // benchmarks: - // http://jsperf.com/typed-array-access-speed - // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion - - // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes - // article "Quaternion Calculus and Fast Animation". - var m = mat.val; - var fTrace = m[0] + m[4] + m[8]; - var fRoot; - - if (fTrace > 0) - { - // |w| > 1/2, may as well choose w > 1/2 - fRoot = Math.sqrt(fTrace + 1.0); // 2w - - this.w = 0.5 * fRoot; - - fRoot = 0.5 / fRoot; // 1/(4w) - - this.x = (m[7] - m[5]) * fRoot; - this.y = (m[2] - m[6]) * fRoot; - this.z = (m[3] - m[1]) * fRoot; - } - else - { - // |w| <= 1/2 - var i = 0; - - if (m[4] > m[0]) - { - i = 1; - } - - if (m[8] > m[i * 3 + i]) - { - i = 2; - } - - var j = siNext[i]; - var k = siNext[j]; - - // This isn't quite as clean without array access - fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); - tmp[i] = 0.5 * fRoot; - - fRoot = 0.5 / fRoot; - - tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; - tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; - - this.x = tmp[0]; - this.y = tmp[1]; - this.z = tmp[2]; - this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; - } - - return this; - } - -}); - -module.exports = Quaternion; - - -/***/ }), -/* 559 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Vector3 = __webpack_require__(87); -var Matrix4 = __webpack_require__(278); -var Quaternion = __webpack_require__(558); - -var tmpMat4 = new Matrix4(); -var tmpQuat = new Quaternion(); -var tmpVec3 = new Vector3(); - -/** - * Rotates a vector in place by axis angle. - * - * This is the same as transforming a point by an - * axis-angle quaternion, but it has higher precision. - * - * @function Phaser.Math.RotateVec3 - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec - The vector to be rotated. - * @param {Phaser.Math.Vector3} axis - The axis to rotate around. - * @param {float} radians - The angle of rotation in radians. - * - * @return {Phaser.Math.Vector3} The given vector. - */ -var RotateVec3 = function (vec, axis, radians) -{ - // Set the quaternion to our axis angle - tmpQuat.setAxisAngle(axis, radians); - - // Create a rotation matrix from the axis angle - tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); - - // Multiply our vector by the rotation matrix - return vec.transformMat4(tmpMat4); -}; - -module.exports = RotateVec3; - - -/***/ }), -/* 560 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compute a random four-dimensional vector. - * - * @function Phaser.Math.RandomXYZW - * @since 3.0.0 - * - * @param {Phaser.Math.Vector4} vec4 - The Vector to compute random values for. - * @param {float} [scale=1] - The scale of the random values. - * - * @return {Phaser.Math.Vector4} The given Vector. - */ -var RandomXYZW = function (vec4, scale) -{ - if (scale === undefined) { scale = 1; } - - // TODO: Not spherical; should fix this for more uniform distribution - vec4.x = (Math.random() * 2 - 1) * scale; - vec4.y = (Math.random() * 2 - 1) * scale; - vec4.z = (Math.random() * 2 - 1) * scale; - vec4.w = (Math.random() * 2 - 1) * scale; - - return vec4; -}; - -module.exports = RandomXYZW; - - -/***/ }), -/* 561 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compute a random position vector in a spherical area, optionally defined by the given radius. - * - * @function Phaser.Math.RandomXYZ - * @since 3.0.0 - * - * @param {Phaser.Math.Vector3} vec3 - The Vector to compute random values for. - * @param {number} [radius=1] - The radius. - * - * @return {Phaser.Math.Vector3} The given Vector. - */ -var RandomXYZ = function (vec3, radius) -{ - if (radius === undefined) { radius = 1; } - - var r = Math.random() * 2 * Math.PI; - var z = (Math.random() * 2) - 1; - var zScale = Math.sqrt(1 - z * z) * radius; - - vec3.x = Math.cos(r) * zScale; - vec3.y = Math.sin(r) * zScale; - vec3.z = z * radius; - - return vec3; -}; - -module.exports = RandomXYZ; - - -/***/ }), -/* 562 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Camera = __webpack_require__(123); -var Class = __webpack_require__(0); -var GetFastValue = __webpack_require__(1); -var PluginCache = __webpack_require__(12); -var RectangleContains = __webpack_require__(31); - -/** - * @typedef {object} InputJSONCameraObject - * - * @property {string} [name=''] - [description] - * @property {integer} [x=0] - [description] - * @property {integer} [y=0] - [description] - * @property {integer} [width] - [description] - * @property {integer} [height] - [description] - * @property {float} [zoom=1] - [description] - * @property {float} [rotation=0] - [description] - * @property {boolean} [roundPixels=false] - [description] - * @property {float} [scrollX=0] - [description] - * @property {float} [scrollY=0] - [description] - * @property {(false|string)} [backgroundColor=false] - [description] - * @property {?object} [bounds] - [description] - * @property {number} [bounds.x=0] - [description] - * @property {number} [bounds.y=0] - [description] - * @property {number} [bounds.width] - [description] - * @property {number} [bounds.height] - [description] - */ - -/** - * @classdesc - * [description] - * - * @class CameraManager - * @memberOf Phaser.Cameras.Scene2D - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. - */ -var CameraManager = new Class({ - - initialize: - - function CameraManager (scene) - { - /** - * The Scene that owns the Camera Manager plugin. - * - * @name Phaser.Cameras.Scene2D.CameraManager#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * The current Camera ID. - * - * @name Phaser.Cameras.Scene2D.CameraManager#currentCameraId - * @type {number} - * @default 1 - * @readOnly - * @since 3.0.0 - */ - this.currentCameraId = 1; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameras - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameras = []; - - /** - * A pool of Camera objects available to be used by the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameraPool - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameraPool = []; - - /** - * The default Camera in the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#main - * @type {Phaser.Cameras.Scene2D.Camera} - * @since 3.0.0 - */ - this.main; - - /** - * This scale affects all cameras. It's used by Scale Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#baseScale - * @type {number} - * @since 3.0.0 - */ - this.baseScale = 1; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Cameras.Scene2D.CameraManager#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - 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]; - - this.systems.events.once('destroy', this.destroy, 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.Cameras.Scene2D.CameraManager#start - * @private - * @since 3.5.0 - */ - start: function () - { - if (!this.main) - { - this.boot(); - } - - var eventEmitter = this.systems.events; - - eventEmitter.on('update', this.update, this); - eventEmitter.once('shutdown', this.shutdown, this); - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#add - * @since 3.0.0 - * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] - * @param {boolean} [makeMain=false] - [description] - * @param {string} [name=''] - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - add: function (x, y, width, height, makeMain, name) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = this.scene.sys.game.config.width; } - if (height === undefined) { height = this.scene.sys.game.config.height; } - if (makeMain === undefined) { makeMain = false; } - if (name === undefined) { name = ''; } - - var camera = null; - - if (this.cameraPool.length > 0) - { - camera = this.cameraPool.pop(); - - camera.setViewport(x, y, width, height); - } - else - { - camera = new Camera(x, y, width, height); - } - - camera.setName(name); - camera.setScene(this.scene); - - this.cameras.push(camera); - - if (makeMain) - { - this.main = camera; - } - - camera._id = this.currentCameraId; - - this.currentCameraId = this.currentCameraId << 1; - - return camera; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#addExisting - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - addExisting: function (camera) - { - var index = this.cameras.indexOf(camera); - var poolIndex = this.cameraPool.indexOf(camera); - - if (index < 0 && poolIndex >= 0) - { - this.cameras.push(camera); - this.cameraPool.slice(poolIndex, 1); - - return camera; - } - - return null; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON - * @since 3.0.0 - * - * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - [description] - * - * @return {Phaser.Cameras.Scene2D.CameraManager} [description] - */ - fromJSON: function (config) - { - if (!Array.isArray(config)) - { - config = [ config ]; - } - - var gameWidth = this.scene.sys.game.config.width; - var gameHeight = this.scene.sys.game.config.height; - - for (var i = 0; i < config.length; i++) - { - var cameraConfig = config[i]; - - var x = GetFastValue(cameraConfig, 'x', 0); - var y = GetFastValue(cameraConfig, 'y', 0); - var width = GetFastValue(cameraConfig, 'width', gameWidth); - var height = GetFastValue(cameraConfig, 'height', gameHeight); - - var camera = this.add(x, y, width, height); - - // Direct properties - camera.name = GetFastValue(cameraConfig, 'name', ''); - camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); - camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); - camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); - camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); - camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); - camera.visible = GetFastValue(cameraConfig, 'visible', true); - - // Background Color - - var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); - - if (backgroundColor) - { - camera.setBackgroundColor(backgroundColor); - } - - // Bounds - - var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); - - if (boundsConfig) - { - var bx = GetFastValue(boundsConfig, 'x', 0); - var by = GetFastValue(boundsConfig, 'y', 0); - var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); - var bheight = GetFastValue(boundsConfig, 'height', gameHeight); - - camera.setBounds(bx, by, bwidth, bheight); - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCamera - * @since 3.0.0 - * - * @param {string} name - [description] - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - getCamera: function (name) - { - for (var i = 0; i < this.cameras.length; i++) - { - if (this.cameras[i].name === name) - { - return this.cameras[i]; - } - } - - return null; - }, - - /** - * Returns an array of all cameras below the given Pointer. - * - * The first camera in the array is the top-most camera in the camera list. - * - * @method Phaser.Cameras.Scene2D.CameraManager#getCamerasBelowPointer - * @since 3.10.0 - * - * @param {Phaser.Input.Pointer} pointer - The Pointer to check against. - * - * @return {Phaser.Cameras.Scene2D.Camera[]} An array of cameras below the Pointer. - */ - getCamerasBelowPointer: function (pointer) - { - var cameras = this.cameras; - - var x = pointer.x; - var y = pointer.y; - - var output = []; - - for (var i = 0; i < cameras.length; i++) - { - var camera = cameras[i]; - - if (camera.visible && camera.inputEnabled && RectangleContains(camera, x, y)) - { - // So the top-most camera is at the top of the search array - output.unshift(camera); - } - } - - return output; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#remove - * @since 3.0.0 - * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - remove: function (camera) - { - var cameraIndex = this.cameras.indexOf(camera); - - if (cameraIndex >= 0 && this.cameras.length > 1) - { - this.cameraPool.push(this.cameras[cameraIndex]); - this.cameras.splice(cameraIndex, 1); - - if (this.main === camera) - { - this.main = this.cameras[0]; - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#render - * @since 3.0.0 - * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. - * @param {Phaser.GameObjects.GameObject[]} children - An array of renderable Game Objects. - * @param {number} interpolation - Interpolation value. Reserved for future use. - */ - render: function (renderer, children, interpolation) - { - var cameras = this.cameras; - var baseScale = this.baseScale; - - for (var i = 0, l = cameras.length; i < l; ++i) - { - var camera = cameras[i]; - - if (camera.visible) - { - camera.preRender(baseScale, renderer.config.resolution); - - renderer.render(this.scene, children, interpolation, camera); - } - } - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#resetAll - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} [description] - */ - resetAll: function () - { - while (this.cameras.length > 0) - { - this.cameraPool.push(this.cameras.pop()); - } - - this.main = this.add(); - - return this.main; - }, - - /** - * [description] - * - * @method Phaser.Cameras.Scene2D.CameraManager#update - * @since 3.0.0 - * - * @param {number} timestep - [description] - * @param {number} delta - [description] - */ - update: function (timestep, delta) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].update(timestep, delta); - } - }, - - /** - * Resizes all cameras to the given dimensions. - * - * @method Phaser.Cameras.Scene2D.CameraManager#resize - * @since 3.2.0 - * - * @param {number} width - The new width of the camera. - * @param {number} height - The new height of the camera. - */ - resize: function (width, height) - { - for (var i = 0, l = this.cameras.length; i < l; ++i) - { - this.cameras[i].setSize(width, height); - } - }, - - /** - * 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 () - { - this.main = undefined; - - for (var i = 0; i < this.cameras.length; i++) - { - this.cameras[i].destroy(); - } - - for (i = 0; i < this.cameraPool.length; i++) - { - this.cameraPool[i].destroy(); - } - - this.cameras = []; - this.cameraPool = []; - - 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; - } - -}); - -PluginCache.register('CameraManager', CameraManager, 'cameras'); - -module.exports = CameraManager; - - -/***/ }), -/* 563 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); - -/** - * @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; - - -/***/ }), -/* 564 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); - -/** - * @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.Pipelines.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; - - -/***/ }), -/* 565 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); -var Class = __webpack_require__(0); - -/** - * @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.Pipelines.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; - - -/***/ }), -/* 566 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cameras.Scene2D - */ - -module.exports = { - - Camera: __webpack_require__(123), - CameraManager: __webpack_require__(562), - Effects: __webpack_require__(204) - -}; - - -/***/ }), -/* 567 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Cache - */ - -module.exports = { - - BaseCache: __webpack_require__(206), - CacheManager: __webpack_require__(205) - -}; - - -/***/ }), -/* 568 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Animations - */ - -module.exports = { - - Animation: __webpack_require__(210), - AnimationFrame: __webpack_require__(208), - AnimationManager: __webpack_require__(207) - -}; - - -/***/ }), -/* 569 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Using Bresenham's line algorithm this will return an array of all coordinates on this line. - * The start and end points are rounded before this runs as the algorithm works on integers. - * - * @function Phaser.Geom.Line.BresenhamPoints - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {integer} [stepRate=1] - [description] - * @param {array} [results] - [description] - * - * @return {array} [description] - */ -var BresenhamPoints = function (line, stepRate, results) -{ - if (stepRate === undefined) { stepRate = 1; } - if (results === undefined) { results = []; } - - var x1 = Math.round(line.x1); - var y1 = Math.round(line.y1); - var x2 = Math.round(line.x2); - var y2 = Math.round(line.y2); - - var dx = Math.abs(x2 - x1); - var dy = Math.abs(y2 - y1); - var sx = (x1 < x2) ? 1 : -1; - var sy = (y1 < y2) ? 1 : -1; - var err = dx - dy; - - results.push({ x: x1, y: y1 }); - - var i = 1; - - while (!((x1 === x2) && (y1 === y2))) - { - var e2 = err << 1; - - if (e2 > -dy) - { - err -= dy; - x1 += sx; - } - - if (e2 < dx) - { - err += dx; - y1 += sy; - } - - if (i % stepRate === 0) - { - results.push({ x: x1, y: y1 }); - } - - i++; - } - - return results; -}; - -module.exports = BresenhamPoints; - - -/***/ }), -/* 570 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Perimeter = __webpack_require__(97); -var Point = __webpack_require__(5); - -// Return an array of points from the perimeter of the rectangle -// each spaced out based on the quantity or step required - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.MarchingAnts - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point[]} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} step - [description] - * @param {integer} quantity - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Point[])} [description] - */ -var MarchingAnts = function (rect, step, quantity, out) -{ - if (out === undefined) { out = []; } - - if (!step && !quantity) - { - // Bail out - return out; - } - - // If step is a falsey value (false, null, 0, undefined, etc) then we calculate - // it based on the quantity instead, otherwise we always use the step value - if (!step) - { - step = Perimeter(rect) / quantity; - } - else - { - quantity = Math.round(Perimeter(rect) / step); - } - - var x = rect.x; - var y = rect.y; - var face = 0; - - // Loop across each face of the rectangle - - for (var i = 0; i < quantity; i++) - { - out.push(new Point(x, y)); - - switch (face) - { - - // Top face - case 0: - x += step; - - if (x >= rect.right) - { - face = 1; - y += (x - rect.right); - x = rect.right; - } - break; - - // Right face - case 1: - y += step; - - if (y >= rect.bottom) - { - face = 2; - x -= (y - rect.bottom); - y = rect.bottom; - } - break; - - // Bottom face - case 2: - x -= step; - - if (x <= rect.left) - { - face = 3; - y -= (rect.left - x); - x = rect.left; - } - break; - - // Left face - case 3: - y -= step; - - if (y <= rect.top) - { - face = 0; - y = rect.top; - } - break; - } - } - - return out; -}; - -module.exports = MarchingAnts; - - -/***/ }), -/* 571 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// bitmask flag for GameObject.renderMask -var _FLAG = 1; // 0001 - -/** - * Provides methods used for setting the visibility of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Visible - * @since 3.0.0 - */ - -var Visible = { - - /** - * Private internal value. Holds the visible value. - * - * @name Phaser.GameObjects.Components.Visible#_visible - * @type {boolean} - * @private - * @default true - * @since 3.0.0 - */ - _visible: true, - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @name Phaser.GameObjects.Components.Visible#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - if (value) - { - this._visible = true; - this.renderFlags |= _FLAG; - } - else - { - this._visible = false; - this.renderFlags &= ~_FLAG; - } - } - - }, - - /** - * Sets the visibility of this Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - * - * @method Phaser.GameObjects.Components.Visible#setVisible - * @since 3.0.0 - * - * @param {boolean} value - The visible state of the Game Object. - * - * @return {this} This Game Object instance. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - } -}; - -module.exports = Visible; - - -/***/ }), -/* 572 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var TransformMatrix = __webpack_require__(64); -var WrapAngle = __webpack_require__(212); -var WrapAngleDegrees = __webpack_require__(211); - -// global bitmask flag for GameObject.renderMask (used by Scale) -var _FLAG = 4; // 0100 - -/** - * Provides methods used for getting and setting the position, scale and rotation of a Game Object. - * - * @name Phaser.GameObjects.Components.Transform - * @since 3.0.0 - */ - -var Transform = { - - /** - * Private internal value. Holds the horizontal scale value. - * - * @name Phaser.GameObjects.Components.Transform#_scaleX - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _scaleX: 1, - - /** - * Private internal value. Holds the vertical scale value. - * - * @name Phaser.GameObjects.Components.Transform#_scaleY - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _scaleY: 1, - - /** - * Private internal value. Holds the rotation value in radians. - * - * @name Phaser.GameObjects.Components.Transform#_rotation - * @type {float} - * @private - * @default 0 - * @since 3.0.0 - */ - _rotation: 0, - - /** - * The x position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#x - * @type {number} - * @default 0 - * @since 3.0.0 - */ - x: 0, - - /** - * The y position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#y - * @type {number} - * @default 0 - * @since 3.0.0 - */ - y: 0, - - /** - * The z position of this Game Object. - * Note: Do not use this value to set the z-index, instead see the `depth` property. - * - * @name Phaser.GameObjects.Components.Transform#z - * @type {number} - * @default 0 - * @since 3.0.0 - */ - z: 0, - - /** - * The w position of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#w - * @type {number} - * @default 0 - * @since 3.0.0 - */ - w: 0, - - /** - * The horizontal scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleX: { - - get: function () - { - return this._scaleX; - }, - - set: function (value) - { - this._scaleX = value; - - if (this._scaleX === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The vertical scale of this Game Object. - * - * @name Phaser.GameObjects.Components.Transform#scaleY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scaleY: { - - get: function () - { - return this._scaleY; - }, - - set: function (value) - { - this._scaleY = value; - - if (this._scaleY === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The angle of this Game Object as expressed in degrees. - * - * Where 0 is to the right, 90 is down, 180 is left. - * - * If you prefer to work in radians, see the `rotation` property instead. - * - * @name Phaser.GameObjects.Components.Transform#angle - * @type {integer} - * @default 0 - * @since 3.0.0 - */ - angle: { - - get: function () - { - return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); - }, - - set: function (value) - { - // value is in degrees - this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; - } - }, - - /** - * The angle of this Game Object in radians. - * - * If you prefer to work in degrees, see the `angle` property instead. - * - * @name Phaser.GameObjects.Components.Transform#rotation - * @type {number} - * @default 1 - * @since 3.0.0 - */ - rotation: { - - get: function () - { - return this._rotation; - }, - - set: function (value) - { - // value is in radians - this._rotation = WrapAngle(value); - } - }, - - /** - * Sets the position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setPosition - * @since 3.0.0 - * - * @param {number} [x=0] - The x position of this Game Object. - * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value. - * @param {number} [z=0] - The z position of this Game Object. - * @param {number} [w=0] - The w position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setPosition: function (x, y, z, w) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - if (z === undefined) { z = 0; } - if (w === undefined) { w = 0; } - - this.x = x; - this.y = y; - this.z = z; - this.w = w; - - return this; - }, - - /** - * Sets the position of this Game Object to be a random position within the confines of - * the given area. - * - * If no area is specified a random position between 0 x 0 and the game width x height is used instead. - * - * The position does not factor in the size of this Game Object, meaning that only the origin is - * guaranteed to be within the area. - * - * @method Phaser.GameObjects.Components.Transform#setRandomPosition - * @since 3.8.0 - * - * @param {number} [x=0] - The x position of the top-left of the random area. - * @param {number} [y=0] - The y position of the top-left of the random area. - * @param {number} [width] - The width of the random area. - * @param {number} [height] - The height of the random area. - * - * @return {this} This Game Object instance. - */ - setRandomPosition: function (x, y, width, height) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = 0; } - if (width === undefined) { width = this.scene.sys.game.config.width; } - if (height === undefined) { height = this.scene.sys.game.config.height; } - - this.x = x + (Math.random() * width); - this.y = y + (Math.random() * height); - - return this; - }, - - /** - * Sets the rotation of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setRotation - * @since 3.0.0 - * - * @param {number} [radians=0] - The rotation of this Game Object, in radians. - * - * @return {this} This Game Object instance. - */ - setRotation: function (radians) - { - if (radians === undefined) { radians = 0; } - - this.rotation = radians; - - return this; - }, - - /** - * Sets the angle of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setAngle - * @since 3.0.0 - * - * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. - * - * @return {this} This Game Object instance. - */ - setAngle: function (degrees) - { - if (degrees === undefined) { degrees = 0; } - - this.angle = degrees; - - return this; - }, - - /** - * Sets the scale of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setScale - * @since 3.0.0 - * - * @param {number} x - The horizontal scale of this Game Object. - * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. - * - * @return {this} This Game Object instance. - */ - setScale: function (x, y) - { - if (x === undefined) { x = 1; } - if (y === undefined) { y = x; } - - this.scaleX = x; - this.scaleY = y; - - return this; - }, - - /** - * Sets the x position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setX - * @since 3.0.0 - * - * @param {number} [value=0] - The x position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setX: function (value) - { - if (value === undefined) { value = 0; } - - this.x = value; - - return this; - }, - - /** - * Sets the y position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setY - * @since 3.0.0 - * - * @param {number} [value=0] - The y position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setY: function (value) - { - if (value === undefined) { value = 0; } - - this.y = value; - - return this; - }, - - /** - * Sets the z position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setZ - * @since 3.0.0 - * - * @param {number} [value=0] - The z position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setZ: function (value) - { - if (value === undefined) { value = 0; } - - this.z = value; - - return this; - }, - - /** - * Sets the w position of this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#setW - * @since 3.0.0 - * - * @param {number} [value=0] - The w position of this Game Object. - * - * @return {this} This Game Object instance. - */ - setW: function (value) - { - if (value === undefined) { value = 0; } - - this.w = value; - - return this; - }, - - /** - * Gets the local transform matrix for this Game Object. - * - * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix - * @since 3.4.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. - * - * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. - */ - getLocalTransformMatrix: function (tempMatrix) - { - if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } - - return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); - }, - - /** - * Gets the world transform matrix for this Game Object, factoring in any parent Containers. - * - * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix - * @since 3.4.0 - * - * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. - * - * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. - */ - getWorldTransformMatrix: function (tempMatrix) - { - if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } - - var parent = this.parentContainer; - - if (!parent) - { - return this.getLocalTransformMatrix(tempMatrix); - } - - var parents = []; - - while (parent) - { - parents.unshift(parent); - parent = parent.parentContainer; - } - - tempMatrix.loadIdentity(); - - var length = parents.length; - - for (var i = 0; i < length; ++i) - { - parent = parents[i]; - - tempMatrix.translate(parent.x, parent.y); - tempMatrix.rotate(parent.rotation); - tempMatrix.scale(parent.scaleX, parent.scaleY); - } - - tempMatrix.translate(this.x, this.y); - tempMatrix.rotate(this._rotation); - tempMatrix.scale(this._scaleX, this._scaleY); - - return tempMatrix; - } - -}; - -module.exports = Transform; - - -/***/ }), -/* 573 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} JSONGameObject - * - * @property {string} name - The name of this Game Object. - * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. - * @property {number} x - The x position of this Game Object. - * @property {number} y - The y position of this Game Object. - * @property {object} scale - The scale of this Game Object - * @property {number} scale.x - The horizontal scale of this Game Object. - * @property {number} scale.y - The vertical scale of this Game Object. - * @property {object} origin - The origin of this Game Object. - * @property {float} origin.x - The horizontal origin of this Game Object. - * @property {float} origin.y - The vertical origin of this Game Object. - * @property {boolean} flipX - The horizontally flipped state of the Game Object. - * @property {boolean} flipY - The vertically flipped state of the Game Object. - * @property {number} rotation - The angle of this Game Object in radians. - * @property {float} alpha - The alpha value of the Game Object. - * @property {boolean} visible - The visible state of the Game Object. - * @property {integer} scaleMode - The Scale Mode being used by this Game Object. - * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. - * @property {string} textureKey - The texture key of this Game Object. - * @property {string} frameKey - The frame key of this Game Object. - * @property {object} data - The data of this Game Object. - */ - -/** - * Build a JSON representation of the given Game Object. - * - * This is typically extended further by Game Object specific implementations. - * - * @method Phaser.GameObjects.Components.ToJSON - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON. - * - * @return {JSONGameObject} The JSON representation of the Game Object. - */ -var ToJSON = function (gameObject) -{ - var out = { - name: gameObject.name, - type: gameObject.type, - x: gameObject.x, - y: gameObject.y, - depth: gameObject.depth, - scale: { - x: gameObject.scaleX, - y: gameObject.scaleY - }, - origin: { - x: gameObject.originX, - y: gameObject.originY - }, - flipX: gameObject.flipX, - flipY: gameObject.flipY, - rotation: gameObject.rotation, - alpha: gameObject.alpha, - visible: gameObject.visible, - scaleMode: gameObject.scaleMode, - blendMode: gameObject.blendMode, - textureKey: '', - frameKey: '', - data: {} - }; - - if (gameObject.texture) - { - out.textureKey = gameObject.texture.key; - out.frameKey = gameObject.frame.name; - } - - return out; -}; - -module.exports = ToJSON; - - -/***/ }), -/* 574 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @function GetColor - * @since 3.0.0 - * @private - */ -var GetColor = function (value) -{ - return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); -}; - -/** - * Provides methods used for setting the tint of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Tint - * @webglOnly - * @since 3.0.0 - */ - -var Tint = { - - /** - * Private internal value. Holds the top-left tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintTL - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintTL: 16777215, - - /** - * Private internal value. Holds the top-right tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintTR - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintTR: 16777215, - - /** - * Private internal value. Holds the bottom-left tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintBL - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintBL: 16777215, - - /** - * Private internal value. Holds the bottom-right tint value. - * - * @name Phaser.GameObjects.Components.Tint#_tintBR - * @type {number} - * @private - * @default 16777215 - * @since 3.0.0 - */ - _tintBR: 16777215, - - /** - * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) - * - * @method Phaser.GameObjects.Components.Tint#clearTint - * @webglOnly - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - clearTint: function () - { - this.setTint(0xffffff); - - return this; - }, - - /** - * Sets the tint values for this Game Object. - * - * @method Phaser.GameObjects.Components.Tint#setTint - * @webglOnly - * @since 3.0.0 - * - * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. - * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. - * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. - * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. - * - * @return {this} This Game Object instance. - */ - setTint: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 0xffffff; } - - if (topRight === undefined) - { - topRight = topLeft; - bottomLeft = topLeft; - bottomRight = topLeft; - } - - this._tintTL = GetColor(topLeft); - this._tintTR = GetColor(topRight); - this._tintBL = GetColor(bottomLeft); - this._tintBR = GetColor(bottomRight); - - return this; - }, - - /** - * The tint value being applied to the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopLeft: { - - get: function () - { - return this._tintTL; - }, - - set: function (value) - { - this._tintTL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintTopRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintTopRight: { - - get: function () - { - return this._tintTR; - }, - - set: function (value) - { - this._tintTR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomLeft - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomLeft: { - - get: function () - { - return this._tintBL; - }, - - set: function (value) - { - this._tintBL = GetColor(value); - } - - }, - - /** - * The tint value being applied to the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tintBottomRight - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tintBottomRight: { - - get: function () - { - return this._tintBR; - }, - - set: function (value) - { - this._tintBR = GetColor(value); - } - - }, - - /** - * The tint value being applied to the whole of the Game Object. - * - * @name Phaser.GameObjects.Components.Tint#tint - * @type {integer} - * @webglOnly - * @since 3.0.0 - */ - tint: { - - set: function (value) - { - this.setTint(value, value, value, value); - } - } - -}; - -module.exports = Tint; - - -/***/ }), -/* 575 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// bitmask flag for GameObject.renderMask -var _FLAG = 8; // 1000 - -/** - * Provides methods used for getting and setting the texture of a Game Object. - * - * @name Phaser.GameObjects.Components.Texture - * @since 3.0.0 - */ - -var Texture = { - - /** - * The Texture this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#texture - * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} - * @since 3.0.0 - */ - texture: null, - - /** - * The Texture Frame this Game Object is using to render with. - * - * @name Phaser.GameObjects.Components.Texture#frame - * @type {Phaser.Textures.Frame} - * @since 3.0.0 - */ - frame: null, - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * - * @method Phaser.GameObjects.Components.Texture#setTexture - * @since 3.0.0 - * - * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. - * - * @return {this} This Game Object instance. - */ - setTexture: function (key, frame) - { - this.texture = this.scene.sys.textures.get(key); - - return this.setFrame(frame); - }, - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * - * @method Phaser.GameObjects.Components.Texture#setFrame - * @since 3.0.0 - * - * @param {(string|integer)} frame - The name or index of the frame within the Texture. - * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? - * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? - * - * @return {this} This Game Object instance. - */ - setFrame: function (frame, updateSize, updateOrigin) - { - if (updateSize === undefined) { updateSize = true; } - if (updateOrigin === undefined) { updateOrigin = true; } - - this.frame = this.texture.get(frame); - - if (!this.frame.cutWidth || !this.frame.cutHeight) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - - if (this._sizeComponent && updateSize) - { - this.setSizeToFrame(); - } - - if (this._originComponent && updateOrigin) - { - if (this.frame.customPivot) - { - this.setOrigin(this.frame.pivotX, this.frame.pivotY); - } - else - { - this.updateDisplayOrigin(); - } - } - - return this; - } - -}; - -module.exports = Texture; - - -/***/ }), -/* 576 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the size of a Game Object. - * - * @name Phaser.GameObjects.Components.Size - * @since 3.0.0 - */ - -var Size = { - - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Size#_sizeComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _sizeComponent: true, - - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#width - * @type {number} - * @since 3.0.0 - */ - width: 0, - - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.Size#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.frame.realWidth; - }, - - set: function (value) - { - this.scaleX = value / this.frame.realWidth; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.Size#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.frame.realHeight; - }, - - set: function (value) - { - this.scaleY = value / this.frame.realHeight; - } - - }, - - /** - * Sets the size of this Game Object to be that of the given Frame. - * - * @method Phaser.GameObjects.Components.Size#setSizeToFrame - * @since 3.0.0 - * - * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. - * - * @return {this} This Game Object instance. - */ - setSizeToFrame: function (frame) - { - if (frame === undefined) { frame = this.frame; } - - this.width = frame.realWidth; - this.height = frame.realHeight; - - return this; - }, - - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Components.Size#setSize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setSize: function (width, height) - { - this.width = width; - this.height = height; - - return this; - }, - - /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Components.Size#setDisplaySize - * @since 3.0.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setDisplaySize: function (width, height) - { - this.displayWidth = width; - this.displayHeight = height; - - return this; - } - -}; - -module.exports = Size; - - -/***/ }), -/* 577 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the Scroll Factor of a Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor - * @since 3.0.0 - */ - -var ScrollFactor = { - - /** - * The horizontal scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorX: 1, - - /** - * The vertical scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY - * @type {number} - * @default 1 - * @since 3.0.0 - */ - scrollFactorY: 1, - - /** - * Sets the scroll factor of this Game Object. - * - * The scroll factor controls the influence of the movement of a Camera upon this Game Object. - * - * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. - * It does not change the Game Objects actual position values. - * - * A value of 1 means it will move exactly in sync with a camera. - * A value of 0 means it will not move at all, even if the camera moves. - * Other values control the degree to which the camera movement is mapped to this Game Object. - * - * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor - * @since 3.0.0 - * - * @param {number} x - The horizontal scroll factor of this Game Object. - * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. - * - * @return {this} This Game Object instance. - */ - setScrollFactor: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollFactorX = x; - this.scrollFactorY = y; - - return this; - } - -}; - -module.exports = ScrollFactor; - - -/***/ }), -/* 578 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ScaleModes = __webpack_require__(59); - -/** - * Provides methods used for getting and setting the scale of a Game Object. - * - * @name Phaser.GameObjects.Components.ScaleMode - * @since 3.0.0 - */ - -var ScaleMode = { - - _scaleMode: ScaleModes.DEFAULT, - - /** - * The Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @name Phaser.GameObjects.Components.ScaleMode#scaleMode - * @type {Phaser.ScaleModes} - * @since 3.0.0 - */ - scaleMode: { - - get: function () - { - return this._scaleMode; - }, - - set: function (value) - { - if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) - { - this._scaleMode = value; - } - } - - }, - - /** - * Sets the Scale Mode being used by this Game Object. - * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. - * - * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode - * @since 3.0.0 - * - * @param {Phaser.ScaleModes} value - The Scale Mode to be used by this Game Object. - * - * @return {this} This Game Object instance. - */ - setScaleMode: function (value) - { - this.scaleMode = value; - - return this; - } - -}; - -module.exports = ScaleMode; - - -/***/ }), -/* 579 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the origin of a Game Object. - * Values are normalized, given in the range 0 to 1. - * Display values contain the calculated pixel values. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Origin - * @since 3.0.0 - */ - -var Origin = { - - /** - * A property indicating that a Game Object has this component. - * - * @name Phaser.GameObjects.Components.Origin#_originComponent - * @type {boolean} - * @private - * @default true - * @since 3.2.0 - */ - _originComponent: true, - - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originX - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originX: 0.5, - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - * - * @name Phaser.GameObjects.Components.Origin#originY - * @type {float} - * @default 0.5 - * @since 3.0.0 - */ - originY: 0.5, - - // private + read only - _displayOriginX: 0, - _displayOriginY: 0, - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginX - * @type {float} - * @since 3.0.0 - */ - displayOriginX: { - - get: function () - { - return this._displayOriginX; - }, - - set: function (value) - { - this._displayOriginX = value; - this.originX = value / this.width; - } - - }, - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - * - * @name Phaser.GameObjects.Components.Origin#displayOriginY - * @type {float} - * @since 3.0.0 - */ - displayOriginY: { - - get: function () - { - return this._displayOriginY; - }, - - set: function (value) - { - this._displayOriginY = value; - this.originY = value / this.height; - } - - }, - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * - * @method Phaser.GameObjects.Components.Origin#setOrigin - * @since 3.0.0 - * - * @param {number} [x=0.5] - The horizontal origin value. - * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. - * - * @return {this} This Game Object instance. - */ - setOrigin: function (x, y) - { - if (x === undefined) { x = 0.5; } - if (y === undefined) { y = x; } - - this.originX = x; - this.originY = y; - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - * - * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - setOriginFromFrame: function () - { - if (!this.frame || !this.frame.customPivot) - { - return this.setOrigin(); - } - else - { - this.originX = this.frame.pivotX; - this.originY = this.frame.pivotY; - } - - return this.updateDisplayOrigin(); - }, - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * - * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin - * @since 3.0.0 - * - * @param {number} [x=0] - The horizontal display origin value. - * @param {number} [y=x] - The vertical display origin value. If not defined it will be set to the value of `x`. - * - * @return {this} This Game Object instance. - */ - setDisplayOrigin: function (x, y) - { - if (x === undefined) { x = 0; } - if (y === undefined) { y = x; } - - this.displayOriginX = x; - this.displayOriginY = y; - - return this; - }, - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - * - * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - updateDisplayOrigin: function () - { - this._displayOriginX = Math.round(this.originX * this.width); - this._displayOriginY = Math.round(this.originY * this.height); - - return this; - } - -}; - -module.exports = Origin; - - -/***/ }), -/* 580 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the transform values of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.MatrixStack - * @since 3.2.0 - */ - -var MatrixStack = { - - /** - * The matrix stack. - * - * @name Phaser.GameObjects.Components.MatrixStack#matrixStack - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - matrixStack: null, - - /** - * The current matrix. - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrix - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - currentMatrix: null, - - /** - * The current index of the top of the matrix stack. - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex - * @type {integer} - * @private - * @since 3.2.0 - */ - currentMatrixIndex: 0, - - /** - * Initialize the matrix stack. - * - * @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - initMatrixStack: function () - { - this.matrixStack = new Float32Array(6000); // up to 1000 matrices - this.currentMatrix = new Float32Array([ 1, 0, 0, 1, 0, 0 ]); - this.currentMatrixIndex = 0; - - return this; - }, - - /** - * Push the current matrix onto the matrix stack. - * - * @method Phaser.GameObjects.Components.MatrixStack#save - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - save: function () - { - if (this.currentMatrixIndex >= this.matrixStack.length) { return this; } - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - this.currentMatrixIndex += 6; - - matrixStack[currentMatrixIndex + 0] = currentMatrix[0]; - matrixStack[currentMatrixIndex + 1] = currentMatrix[1]; - matrixStack[currentMatrixIndex + 2] = currentMatrix[2]; - matrixStack[currentMatrixIndex + 3] = currentMatrix[3]; - matrixStack[currentMatrixIndex + 4] = currentMatrix[4]; - matrixStack[currentMatrixIndex + 5] = currentMatrix[5]; - - return this; - }, - - /** - * Pop the top of the matrix stack into the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#restore - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - restore: function () - { - if (this.currentMatrixIndex <= 0) { return this; } - - this.currentMatrixIndex -= 6; - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - - currentMatrix[0] = matrixStack[currentMatrixIndex + 0]; - currentMatrix[1] = matrixStack[currentMatrixIndex + 1]; - currentMatrix[2] = matrixStack[currentMatrixIndex + 2]; - currentMatrix[3] = matrixStack[currentMatrixIndex + 3]; - currentMatrix[4] = matrixStack[currentMatrixIndex + 4]; - currentMatrix[5] = matrixStack[currentMatrixIndex + 5]; - - return this; - }, - - /** - * Resets the current matrix to the identity matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#loadIdentity - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - loadIdentity: function () - { - this.setTransform(1, 0, 0, 1, 0, 0); - - return this; - }, - - /** - * Transform the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#transform - * @since 3.2.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This Game Object instance. - */ - transform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[0] = m0 * a + m2 * b; - currentMatrix[1] = m1 * a + m3 * b; - currentMatrix[2] = m0 * c + m2 * d; - currentMatrix[3] = m1 * c + m3 * d; - currentMatrix[4] = m0 * tx + m2 * ty + m4; - currentMatrix[5] = m1 * tx + m3 * ty + m5; - - return this; - }, - - /** - * Set a transform matrix as the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#setTransform - * @since 3.2.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This Game Object instance. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - - currentMatrix[0] = a; - currentMatrix[1] = b; - currentMatrix[2] = c; - currentMatrix[3] = d; - currentMatrix[4] = tx; - currentMatrix[5] = ty; - - return this; - }, - - /** - * Translate the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#translate - * @since 3.2.0 - * - * @param {number} x - The horizontal translation value. - * @param {number} y - The vertical translation value. - * - * @return {this} This Game Object instance. - */ - translate: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[4] = m0 * x + m2 * y + m4; - currentMatrix[5] = m1 * x + m3 * y + m5; - - return this; - }, - - /** - * Scale the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#scale - * @since 3.2.0 - * - * @param {number} x - The horizontal scale value. - * @param {number} y - The vertical scale value. - * - * @return {this} This Game Object instance. - */ - scale: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - - currentMatrix[0] = m0 * x; - currentMatrix[1] = m1 * x; - currentMatrix[2] = m2 * y; - currentMatrix[3] = m3 * y; - - return this; - }, - - /** - * Rotate the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#rotate - * @since 3.2.0 - * - * @param {number} t - The angle of rotation, in radians. - * - * @return {this} This Game Object instance. - */ - rotate: function (t) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var st = Math.sin(t); - var ct = Math.cos(t); - - currentMatrix[0] = m0 * ct + m2 * st; - currentMatrix[1] = m1 * ct + m3 * st; - currentMatrix[2] = m0 * -st + m2 * ct; - currentMatrix[3] = m1 * -st + m3 * ct; - - return this; - } - -}; - -module.exports = MatrixStack; - - -/***/ }), -/* 581 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapMask = __webpack_require__(214); -var GeometryMask = __webpack_require__(213); - -/** - * Provides methods used for getting and setting the mask of a Game Object. - * - * @name Phaser.GameObjects.Components.Mask - * @since 3.0.0 - */ - -var Mask = { - - /** - * The Mask this Game Object is using during render. - * - * @name Phaser.GameObjects.Components.Mask#mask - * @type {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} - * @since 3.0.0 - */ - mask: null, - - /** - * Sets the mask that this Game Object will use to render with. - * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * - * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. - * - * If a mask is already set on this Game Object it will be immediately replaced. - * - * @method Phaser.GameObjects.Components.Mask#setMask - * @since 3.6.2 - * - * @param {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} mask - The mask this Game Object will use when rendering. - * - * @return {this} This Game Object instance. - */ - setMask: function (mask) - { - this.mask = mask; - - return this; - }, - - /** - * Clears the mask that this Game Object was using. - * - * @method Phaser.GameObjects.Components.Mask#clearMask - * @since 3.6.2 - * - * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? - * - * @return {this} This Game Object instance. - */ - clearMask: function (destroyMask) - { - if (destroyMask === undefined) { destroyMask = false; } - - if (destroyMask) - { - this.mask.destroy(); - } - - this.mask = null; - - return this; - }, - - /** - * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a renderable Game Object. - * A renderable Game Object is one that uses a texture to render with, such as an - * Image, Sprite, Render Texture or BitmapText. - * - * If you do not provide a renderable object, and this Game Object has a texture, - * it will use itself as the object. This means you can call this method to create - * a Bitmap Mask from any renderable Game Object. - * - * @method Phaser.GameObjects.Components.Mask#createBitmapMask - * @since 3.6.2 - * - * @param {Phaser.GameObjects.GameObject} [renderable] - A renderable Game Object that uses a texture, such as a Sprite. - * - * @return {Phaser.Display.Masks.BitmapMask} This Bitmap Mask that was created. - */ - createBitmapMask: function (renderable) - { - if (renderable === undefined && this.texture) - { - // eslint-disable-next-line consistent-this - renderable = this; - } - - return new BitmapMask(this.scene, renderable); - }, - - /** - * Creates and returns a Geometry Mask. This mask can be used by any Game Object, - * including this one. - * - * To create the mask you need to pass in a reference to a Graphics Game Object. - * - * If you do not provide a graphics object, and this Game Object is an instance - * of a Graphics object, then it will use itself to create the mask. - * - * This means you can call this method to create a Geometry Mask from any Graphics Game Object. - * - * @method Phaser.GameObjects.Components.Mask#createGeometryMask - * @since 3.6.2 - * - * @param {Phaser.GameObjects.Graphics} [graphics] - A Graphics Game Object. The geometry within it will be used as the mask. - * - * @return {Phaser.Display.Masks.GeometryMask} This Geometry Mask that was created. - */ - createGeometryMask: function (graphics) - { - if (graphics === undefined && this.type === 'Graphics') - { - // eslint-disable-next-line consistent-this - graphics = this; - } - - return new GeometryMask(this.scene, graphics); - } - -}; - -module.exports = Mask; - - -/***/ }), -/* 582 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); -var RotateAround = __webpack_require__(292); -var Vector2 = __webpack_require__(6); - -/** - * Provides methods used for obtaining the bounds of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.GetBounds - * @since 3.0.0 - */ - -var GetBounds = { - - /** - * Gets the center coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getCenter - * @since 3.0.0 - * - * @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. - * - * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. - */ - getCenter: function (output) - { - if (output === undefined) { output = new Vector2(); } - - output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); - output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); - - return output; - }, - - /** - * Gets the top-left corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getTopLeft - * @since 3.0.0 - * - * @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, includeParent) - { - 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); - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the top-right corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getTopRight - * @since 3.0.0 - * - * @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, includeParent) - { - 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); - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft - * @since 3.0.0 - * - * @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, includeParent) - { - 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; - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. - * The returned point is calculated in local space and does not factor in any parent containers - * - * @method Phaser.GameObjects.Components.GetBounds#getBottomRight - * @since 3.0.0 - * - * @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, includeParent) - { - 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; - - if (this.rotation !== 0) - { - 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; - }, - - /** - * Gets the bounds of this Game Object, regardless of origin. - * The values are stored and returned in a Rectangle, or Rectangle-like, object. - * - * @method Phaser.GameObjects.Components.GetBounds#getBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [output,$return] - * - * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. - * - * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. - */ - getBounds: function (output) - { - if (output === undefined) { output = new Rectangle(); } - - // We can use the output object to temporarily store the x/y coords in: - - var TLx, TLy, TRx, TRy, BLx, BLy, BRx, BRy; - - // Instead of doing a check if parent container is - // defined per corner we only do it once. - if (this.parentContainer) - { - var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); - - this.getTopLeft(output); - parentMatrix.transformPoint(output.x, output.y, output); - - TLx = output.x; - TLy = output.y; - - this.getTopRight(output); - parentMatrix.transformPoint(output.x, output.y, output); - - TRx = output.x; - TRy = output.y; - - this.getBottomLeft(output); - parentMatrix.transformPoint(output.x, output.y, output); - - BLx = output.x; - BLy = output.y; - - this.getBottomRight(output); - parentMatrix.transformPoint(output.x, output.y, output); - - BRx = output.x; - BRy = output.y; - } - else - { - this.getTopLeft(output); - - TLx = output.x; - TLy = output.y; - - this.getTopRight(output); - - TRx = output.x; - TRy = output.y; - - this.getBottomLeft(output); - - BLx = output.x; - BLy = output.y; - - this.getBottomRight(output); - - BRx = output.x; - BRy = output.y; - } - - output.x = Math.min(TLx, TRx, BLx, BRx); - output.y = Math.min(TLy, TRy, BLy, BRy); - output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; - output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; - - return output; - } - -}; - -module.exports = GetBounds; - - -/***/ }), -/* 583 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for visually flipping a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Flip - * @since 3.0.0 - */ - -var Flip = { - - /** - * The horizontally flipped state of the Game Object. - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipX - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipX: false, - - /** - * The vertically flipped state of the Game Object. - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - * - * @name Phaser.GameObjects.Components.Flip#flipY - * @type {boolean} - * @default false - * @since 3.0.0 - */ - flipY: false, - - /** - * Toggles the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipX - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - toggleFlipX: function () - { - this.flipX = !this.flipX; - - return this; - }, - - /** - * Toggles the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#toggleFlipY - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - toggleFlipY: function () - { - this.flipY = !this.flipY; - - return this; - }, - - /** - * Sets the horizontal flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipX - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {this} This Game Object instance. - */ - setFlipX: function (value) - { - this.flipX = value; - - return this; - }, - - /** - * Sets the vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlipY - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {this} This Game Object instance. - */ - setFlipY: function (value) - { - this.flipY = value; - - return this; - }, - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * - * @method Phaser.GameObjects.Components.Flip#setFlip - * @since 3.0.0 - * - * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {this} This Game Object instance. - */ - setFlip: function (x, y) - { - this.flipX = x; - this.flipY = y; - - return this; - }, - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - * - * @method Phaser.GameObjects.Components.Flip#resetFlip - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - resetFlip: function () - { - this.flipX = false; - this.flipY = false; - - return this; - } - -}; - -module.exports = Flip; - - -/***/ }), -/* 584 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for setting the depth of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Depth - * @since 3.0.0 - */ - -var Depth = { - - /** - * Private internal value. Holds the depth of the Game Object. - * - * @name Phaser.GameObjects.Components.Depth#_depth - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - _depth: 0, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @name Phaser.GameObjects.Components.Depth#depth - * @type {number} - * @since 3.0.0 - */ - depth: { - - get: function () - { - return this._depth; - }, - - set: function (value) - { - this.scene.sys.queueDepthSort(); - this._depth = value; - } - - }, - - /** - * The depth of this Game Object within the Scene. - * - * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order - * of Game Objects, without actually moving their position in the display list. - * - * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth - * value will always render in front of one with a lower value. - * - * Setting the depth will queue a depth sort event within the Scene. - * - * @method Phaser.GameObjects.Components.Depth#setDepth - * @since 3.0.0 - * - * @param {integer} value - The depth of this Game Object. - * - * @return {this} This Game Object instance. - */ - setDepth: function (value) - { - if (value === undefined) { value = 0; } - - this.depth = value; - - return this; - } - -}; - -module.exports = Depth; - - -/***/ }), -/* 585 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for calculating and setting the size of a non-Frame based Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.ComputedSize - * @since 3.0.0 - */ - -var ComputedSize = { - - /** - * The native (un-scaled) width of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#width - * @type {number} - * @since 3.0.0 - */ - width: 0, - - /** - * The native (un-scaled) height of this Game Object. - * - * @name Phaser.GameObjects.Components.ComputedSize#height - * @type {number} - * @since 3.0.0 - */ - height: 0, - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayWidth - * @type {number} - * @since 3.0.0 - */ - displayWidth: { - - get: function () - { - return this.scaleX * this.width; - }, - - set: function (value) - { - this.scaleX = value / this.width; - } - - }, - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - * - * @name Phaser.GameObjects.Components.ComputedSize#displayHeight - * @type {number} - * @since 3.0.0 - */ - displayHeight: { - - get: function () - { - return this.scaleY * this.height; - }, - - set: function (value) - { - this.scaleY = value / this.height; - } - - }, - - /** - * Sets the size of this Game Object. - * - * @method Phaser.GameObjects.Components.ComputedSize#setSize - * @since 3.4.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setSize: function (width, height) - { - this.width = width; - this.height = height; - - return this; - }, - - /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * - * @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize - * @since 3.4.0 - * - * @param {number} width - The width of this Game Object. - * @param {number} height - The height of this Game Object. - * - * @return {this} This Game Object instance. - */ - setDisplaySize: function (width, height) - { - this.displayWidth = width; - this.displayHeight = height; - - return this; - } - -}; - -module.exports = ComputedSize; - - -/***/ }), -/* 586 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BlendModes = __webpack_require__(51); - -/** - * Provides methods used for setting the blend mode of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.BlendMode - * @since 3.0.0 - */ - -var BlendMode = { - - /** - * Private internal value. Holds the current blend mode. - * - * @name Phaser.GameObjects.Components.BlendMode#_blendMode - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - _blendMode: BlendModes.NORMAL, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @name Phaser.GameObjects.Components.BlendMode#blendMode - * @type {(Phaser.BlendModes|string)} - * @since 3.0.0 - */ - blendMode: { - - get: function () - { - return this._blendMode; - }, - - set: function (value) - { - if (typeof value === 'string') - { - value = BlendModes[value]; - } - - value |= 0; - - if (value >= 0) - { - this._blendMode = value; - } - } - - }, - - /** - * Sets the Blend Mode being used by this Game Object. - * - * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) - * - * Under WebGL only the following Blend Modes are available: - * - * * ADD - * * MULTIPLY - * * SCREEN - * - * Canvas has more available depending on browser support. - * - * You can also create your own custom Blend Modes in WebGL. - * - * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending - * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes - * are used. - * - * @method Phaser.GameObjects.Components.BlendMode#setBlendMode - * @since 3.0.0 - * - * @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST. - * - * @return {this} This Game Object instance. - */ - setBlendMode: function (value) - { - this.blendMode = value; - - return this; - } - -}; - -module.exports = BlendMode; - - -/***/ }), -/* 587 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clamp = __webpack_require__(23); - -// bitmask flag for GameObject.renderMask -var _FLAG = 2; // 0010 - -/** - * Provides methods used for setting the alpha properties of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.Alpha - * @since 3.0.0 - */ - -var Alpha = { - - /** - * Private internal value. Holds the global alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alpha - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alpha: 1, - - /** - * Private internal value. Holds the top-left alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaTL - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaTL: 1, - - /** - * Private internal value. Holds the top-right alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaTR - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaTR: 1, - - /** - * Private internal value. Holds the bottom-left alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaBL - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaBL: 1, - - /** - * Private internal value. Holds the bottom-right alpha value. - * - * @name Phaser.GameObjects.Components.Alpha#_alphaBR - * @type {float} - * @private - * @default 1 - * @since 3.0.0 - */ - _alphaBR: 1, - - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - * - * @method Phaser.GameObjects.Components.Alpha#clearAlpha - * @since 3.0.0 - * - * @return {this} This Game Object instance. - */ - clearAlpha: function () - { - return this.setAlpha(1); - }, - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * - * @method Phaser.GameObjects.Components.Alpha#setAlpha - * @since 3.0.0 - * - * @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. - * @param {float} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. - * @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. - * - * @return {this} This Game Object instance. - */ - setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) - { - if (topLeft === undefined) { topLeft = 1; } - - // Treat as if there is only one alpha value for the whole Game Object - if (topRight === undefined) - { - this.alpha = topLeft; - } - else - { - this._alphaTL = Clamp(topLeft, 0, 1); - this._alphaTR = Clamp(topRight, 0, 1); - this._alphaBL = Clamp(bottomLeft, 0, 1); - this._alphaBR = Clamp(bottomRight, 0, 1); - } - - return this; - }, - - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - * - * @name Phaser.GameObjects.Components.Alpha#alpha - * @type {float} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this._alpha; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alpha = v; - this._alphaTL = v; - this._alphaTR = v; - this._alphaBL = v; - this._alphaBR = v; - - if (v === 0) - { - this.renderFlags &= ~_FLAG; - } - else - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopLeft: { - - get: function () - { - return this._alphaTL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaTopRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaTopRight: { - - get: function () - { - return this._alphaTR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaTR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomLeft: { - - get: function () - { - return this._alphaBL; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBL = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - }, - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - * - * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight - * @type {float} - * @webglOnly - * @since 3.0.0 - */ - alphaBottomRight: { - - get: function () - { - return this._alphaBR; - }, - - set: function (value) - { - var v = Clamp(value, 0, 1); - - this._alphaBR = v; - - if (v !== 0) - { - this.renderFlags |= _FLAG; - } - } - - } - -}; - -module.exports = Alpha; - - -/***/ }), -/* 588 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(46); -var GetTop = __webpack_require__(44); -var SetRight = __webpack_require__(45); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned in the top right of the other. - * - * @function Phaser.Display.Align.In.TopRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopRight = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); - - return gameObject; -}; - -module.exports = TopRight; - - -/***/ }), -/* 589 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(48); -var GetTop = __webpack_require__(44); -var SetLeft = __webpack_require__(47); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned in the top left of the other. - * - * @function Phaser.Display.Align.In.TopLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopLeft = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); - - return gameObject; -}; - -module.exports = TopLeft; - - -/***/ }), -/* 590 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterX = __webpack_require__(92); -var GetTop = __webpack_require__(44); -var SetCenterX = __webpack_require__(91); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned in the top center of the other. - * - * @function Phaser.Display.Align.In.TopCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopCenter = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); - SetTop(gameObject, GetTop(alignIn) - offsetY); - - return gameObject; -}; - -module.exports = TopCenter; - - -/***/ }), -/* 591 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(89); -var GetRight = __webpack_require__(46); -var SetCenterY = __webpack_require__(90); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned in the right center of the other. - * - * @function Phaser.Display.Align.In.RightCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightCenter = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = RightCenter; - - -/***/ }), -/* 592 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(89); -var GetLeft = __webpack_require__(48); -var SetCenterY = __webpack_require__(90); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned in the left center of the other. - * - * @function Phaser.Display.Align.In.LeftCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftCenter = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetCenterY(gameObject, GetCenterY(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = LeftCenter; - - -/***/ }), -/* 593 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetCenterX = __webpack_require__(91); -var SetCenterY = __webpack_require__(90); - -/** - * Positions the Game Object so that it is centered on the given coordinates. - * - * @function Phaser.Display.Bounds.CenterOn - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. - * @param {number} x - The horizontal coordinate to position the Game Object on. - * @param {number} y - The vertical coordinate to position the Game Object on. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. - */ -var CenterOn = function (gameObject, x, y) -{ - SetCenterX(gameObject, x); - - return SetCenterY(gameObject, y); -}; - -module.exports = CenterOn; - - -/***/ }), -/* 594 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CenterOn = __webpack_require__(593); -var GetCenterX = __webpack_require__(92); -var GetCenterY = __webpack_require__(89); - -/** - * Takes given Game Object and aligns it so that it is positioned in the center of the other. - * - * @function Phaser.Display.Align.In.Center - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var Center = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - CenterOn(gameObject, GetCenterX(alignIn) + offsetX, GetCenterY(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = Center; - - -/***/ }), -/* 595 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetRight = __webpack_require__(46); -var SetBottom = __webpack_require__(49); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned in the bottom right of the other. - * - * @function Phaser.Display.Align.In.BottomRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomRight = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignIn) + offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = BottomRight; - - -/***/ }), -/* 596 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetLeft = __webpack_require__(48); -var SetBottom = __webpack_require__(49); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned in the bottom left of the other. - * - * @function Phaser.Display.Align.In.BottomLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomLeft = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignIn) - offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = BottomLeft; - - -/***/ }), -/* 597 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetCenterX = __webpack_require__(92); -var SetBottom = __webpack_require__(49); -var SetCenterX = __webpack_require__(91); - -/** - * Takes given Game Object and aligns it so that it is positioned in the bottom center of the other. - * - * @function Phaser.Display.Align.In.BottomCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomCenter = function (gameObject, alignIn, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignIn) + offsetX); - SetBottom(gameObject, GetBottom(alignIn) + offsetY); - - return gameObject; -}; - -module.exports = BottomCenter; - - -/***/ }), -/* 598 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ALIGN_CONST = __webpack_require__(299); - -var AlignInMap = []; - -AlignInMap[ALIGN_CONST.BOTTOM_CENTER] = __webpack_require__(597); -AlignInMap[ALIGN_CONST.BOTTOM_LEFT] = __webpack_require__(596); -AlignInMap[ALIGN_CONST.BOTTOM_RIGHT] = __webpack_require__(595); -AlignInMap[ALIGN_CONST.CENTER] = __webpack_require__(594); -AlignInMap[ALIGN_CONST.LEFT_CENTER] = __webpack_require__(592); -AlignInMap[ALIGN_CONST.RIGHT_CENTER] = __webpack_require__(591); -AlignInMap[ALIGN_CONST.TOP_CENTER] = __webpack_require__(590); -AlignInMap[ALIGN_CONST.TOP_LEFT] = __webpack_require__(589); -AlignInMap[ALIGN_CONST.TOP_RIGHT] = __webpack_require__(588); - -/** - * Takes given Game Object and aligns it so that it is positioned relative to the other. - * The alignment used is based on the `position` argument, which is an `ALIGN_CONST` value, such as `LEFT_CENTER` or `TOP_RIGHT`. - * - * @function Phaser.Display.Align.In.QuickSet - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [child,$return] - * - * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on. - * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `ALIGN_CONST.LEFT_CENTER`. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var QuickSet = function (child, alignIn, position, offsetX, offsetY) -{ - return AlignInMap[position](child, alignIn, offsetX, offsetY); -}; - -module.exports = QuickSet; - - -/***/ }), -/* 599 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Actions - */ - -module.exports = { - - Angle: __webpack_require__(1007), - Call: __webpack_require__(1006), - GetFirst: __webpack_require__(1005), - GetLast: __webpack_require__(1004), - GridAlign: __webpack_require__(1003), - IncAlpha: __webpack_require__(1002), - IncX: __webpack_require__(1001), - IncXY: __webpack_require__(1000), - IncY: __webpack_require__(999), - PlaceOnCircle: __webpack_require__(998), - PlaceOnEllipse: __webpack_require__(997), - PlaceOnLine: __webpack_require__(996), - PlaceOnRectangle: __webpack_require__(995), - PlaceOnTriangle: __webpack_require__(994), - PlayAnimation: __webpack_require__(993), - PropertyValueInc: __webpack_require__(35), - PropertyValueSet: __webpack_require__(25), - RandomCircle: __webpack_require__(992), - RandomEllipse: __webpack_require__(991), - RandomLine: __webpack_require__(990), - RandomRectangle: __webpack_require__(989), - RandomTriangle: __webpack_require__(988), - Rotate: __webpack_require__(987), - RotateAround: __webpack_require__(986), - RotateAroundDistance: __webpack_require__(985), - ScaleX: __webpack_require__(984), - ScaleXY: __webpack_require__(983), - ScaleY: __webpack_require__(982), - SetAlpha: __webpack_require__(981), - SetBlendMode: __webpack_require__(980), - SetDepth: __webpack_require__(979), - SetHitArea: __webpack_require__(978), - SetOrigin: __webpack_require__(977), - SetRotation: __webpack_require__(976), - SetScale: __webpack_require__(975), - SetScaleX: __webpack_require__(974), - SetScaleY: __webpack_require__(973), - SetTint: __webpack_require__(972), - SetVisible: __webpack_require__(971), - SetX: __webpack_require__(970), - SetXY: __webpack_require__(969), - SetY: __webpack_require__(968), - ShiftPosition: __webpack_require__(967), - Shuffle: __webpack_require__(966), - SmootherStep: __webpack_require__(965), - SmoothStep: __webpack_require__(964), - Spread: __webpack_require__(963), - ToggleVisible: __webpack_require__(962), - WrapInRectangle: __webpack_require__(961) - -}; - - -/***/ }), -/* 600 */ -/***/ (function(module, exports) { - -/** -* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 -* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ -* Cameron Foale (http://www.kibibu.com) -*/ -if (typeof window.Uint32Array !== 'function' && typeof window.Uint32Array !== 'object') -{ - var CheapArray = function (fakeType) - { - var proto = new Array(); // jshint ignore:line - - window[fakeType] = function(arg) { - - if (typeof(arg) === 'number') - { - Array.call(this, arg); - - this.length = arg; - - for (var i = 0; i < this.length; i++) - { - this[i] = 0; - } - } - else - { - Array.call(this, arg.length); - - this.length = arg.length; - - for (var i = 0; i < this.length; i++) - { - this[i] = arg[i]; - } - } - }; - - window[fakeType].prototype = proto; - window[fakeType].constructor = window[fakeType]; - }; - - CheapArray('Float32Array'); // jshint ignore:line - CheapArray('Uint32Array'); // jshint ignore:line - CheapArray('Uint16Array'); // jshint ignore:line - CheapArray('Int16Array'); // jshint ignore:line - CheapArray('ArrayBuffer'); // jshint ignore:line -} - - -/***/ }), -/* 601 */ -/***/ (function(module, exports, __webpack_require__) { - -/* WEBPACK VAR INJECTION */(function(global) {// References: -// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ -// https://gist.github.com/1579671 -// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision -// https://gist.github.com/timhall/4078614 -// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame - -// Expected to be used with Browserfiy -// Browserify automatically detects the use of `global` and passes the -// correct reference of `global`, `self`, and finally `window` - -// Date.now -if (!(Date.now && Date.prototype.getTime)) { - Date.now = function now() { - return new Date().getTime(); - }; -} - -// performance.now -if (!(global.performance && global.performance.now)) { - var startTime = Date.now(); - if (!global.performance) { - global.performance = {}; - } - global.performance.now = function () { - return Date.now() - startTime; - }; -} - -// requestAnimationFrame -var lastTime = Date.now(); -var vendors = ['ms', 'moz', 'webkit', 'o']; - -for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { - global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; - global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || - global[vendors[x] + 'CancelRequestAnimationFrame']; -} - -if (!global.requestAnimationFrame) { - global.requestAnimationFrame = function (callback) { - if (typeof callback !== 'function') { - throw new TypeError(callback + 'is not a function'); - } - - var currentTime = Date.now(), - delay = 16 + lastTime - currentTime; - - if (delay < 0) { - delay = 0; - } - - lastTime = currentTime; - - return setTimeout(function () { - lastTime = Date.now(); - callback(performance.now()); - }, delay); - }; -} - -if (!global.cancelAnimationFrame) { - global.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; -} - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(215))) - -/***/ }), -/* 602 */ -/***/ (function(module, exports) { - -/** - * performance.now - */ -(function () { - - if ('performance' in window === false) - { - window.performance = {}; - } - - // Thanks IE8 - Date.now = (Date.now || function () { - return new Date().getTime(); - }); - - if ('now' in window.performance === false) - { - var nowOffset = Date.now(); - - if (performance.timing && performance.timing.navigationStart) - { - nowOffset = performance.timing.navigationStart; - } - - window.performance.now = function now () - { - return Date.now() - nowOffset; - } - } - -})(); - - -/***/ }), -/* 603 */ -/***/ (function(module, exports) { - -// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc -if (!Math.trunc) { - Math.trunc = function trunc(x) { - return x < 0 ? Math.ceil(x) : Math.floor(x); - }; -} - - -/***/ }), -/* 604 */ -/***/ (function(module, exports) { - -/** -* A polyfill for Function.prototype.bind -*/ -if (!Function.prototype.bind) { - - /* jshint freeze: false */ - Function.prototype.bind = (function () { - - var slice = Array.prototype.slice; - - return function (thisArg) { - - var target = this, boundArgs = slice.call(arguments, 1); - - if (typeof target !== 'function') - { - throw new TypeError(); - } - - function bound() { - var args = boundArgs.concat(slice.call(arguments)); - target.apply(this instanceof bound ? this : thisArg, args); - } - - bound.prototype = (function F(proto) { - if (proto) - { - F.prototype = proto; - } - - if (!(this instanceof F)) - { - /* jshint supernew: true */ - return new F; - } - })(target.prototype); - - return bound; - }; - })(); -} - - - -/***/ }), -/* 605 */ -/***/ (function(module, exports) { - -/** - * Also fix for the absent console in IE9 - */ -if (!window.console) -{ - window.console = {}; - window.console.log = window.console.assert = function(){}; - window.console.warn = window.console.assert = function(){}; -} - - -/***/ }), -/* 606 */ -/***/ (function(module, exports) { - -/* Copyright 2013 Chris Wilson - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - -This monkeypatch library is intended to be included in projects that are -written to the proper AudioContext spec (instead of webkitAudioContext), -and that use the new naming and proper bits of the Web Audio API (e.g. -using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may -have to run on systems that only support the deprecated bits. - -This library should be harmless to include if the browser supports -unprefixed "AudioContext", and/or if it supports the new names. - -The patches this library handles: -if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). -if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or -noteGrainOn(), depending on parameters. - -The following aliases only take effect if the new names are not already in place: - -AudioBufferSourceNode.stop() is aliased to noteOff() -AudioContext.createGain() is aliased to createGainNode() -AudioContext.createDelay() is aliased to createDelayNode() -AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() -AudioContext.createPeriodicWave() is aliased to createWaveTable() -OscillatorNode.start() is aliased to noteOn() -OscillatorNode.stop() is aliased to noteOff() -OscillatorNode.setPeriodicWave() is aliased to setWaveTable() -AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() - -This library does NOT patch the enumerated type changes, as it is -recommended in the specification that implementations support both integer -and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel -BiquadFilterNode.type and OscillatorNode.type. - -*/ - -(function () { - - function fixSetTarget(param) { - if (!param) // if NYI, just return - return; - if (!param.setTargetAtTime) - param.setTargetAtTime = param.setTargetValueAtTime; - } - - if (window.hasOwnProperty('webkitAudioContext') && - !window.hasOwnProperty('AudioContext')) { - window.AudioContext = webkitAudioContext; - - if (!AudioContext.prototype.hasOwnProperty('createGain')) - AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; - if (!AudioContext.prototype.hasOwnProperty('createDelay')) - AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; - if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) - AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; - if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) - AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; - - - AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; - AudioContext.prototype.createGain = function() { - var node = this.internal_createGain(); - fixSetTarget(node.gain); - return node; - }; - - AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; - AudioContext.prototype.createDelay = function(maxDelayTime) { - var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); - fixSetTarget(node.delayTime); - return node; - }; - - AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; - AudioContext.prototype.createBufferSource = function() { - var node = this.internal_createBufferSource(); - if (!node.start) { - node.start = function ( when, offset, duration ) { - if ( offset || duration ) - this.noteGrainOn( when || 0, offset, duration ); - else - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function( when, offset, duration ) { - if( typeof duration !== 'undefined' ) - node.internal_start( when || 0, offset, duration ); - else - node.internal_start( when || 0, offset || 0 ); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - fixSetTarget(node.playbackRate); - return node; - }; - - AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; - AudioContext.prototype.createDynamicsCompressor = function() { - var node = this.internal_createDynamicsCompressor(); - fixSetTarget(node.threshold); - fixSetTarget(node.knee); - fixSetTarget(node.ratio); - fixSetTarget(node.reduction); - fixSetTarget(node.attack); - fixSetTarget(node.release); - return node; - }; - - AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; - AudioContext.prototype.createBiquadFilter = function() { - var node = this.internal_createBiquadFilter(); - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - fixSetTarget(node.Q); - fixSetTarget(node.gain); - return node; - }; - - if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { - AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; - AudioContext.prototype.createOscillator = function() { - var node = this.internal_createOscillator(); - if (!node.start) { - node.start = function ( when ) { - this.noteOn( when || 0 ); - }; - } else { - node.internal_start = node.start; - node.start = function ( when ) { - node.internal_start( when || 0); - }; - } - if (!node.stop) { - node.stop = function ( when ) { - this.noteOff( when || 0 ); - }; - } else { - node.internal_stop = node.stop; - node.stop = function( when ) { - node.internal_stop( when || 0 ); - }; - } - if (!node.setPeriodicWave) - node.setPeriodicWave = node.setWaveTable; - fixSetTarget(node.frequency); - fixSetTarget(node.detune); - return node; - }; - } - } - - if (window.hasOwnProperty('webkitOfflineAudioContext') && - !window.hasOwnProperty('OfflineAudioContext')) { - window.OfflineAudioContext = webkitOfflineAudioContext; - } - -})(); - - -/***/ }), -/* 607 */ -/***/ (function(module, exports) { - -/** -* A polyfill for Array.isArray -*/ -if (!Array.isArray) -{ - Array.isArray = function (arg) - { - return Object.prototype.toString.call(arg) === '[object Array]'; - }; -} - - -/***/ }), -/* 608 */ -/***/ (function(module, exports) { - -/** -* A polyfill for Array.forEach -* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach -*/ -if (!Array.prototype.forEach) -{ - Array.prototype.forEach = function (fun /*, thisArg */) - { - 'use strict'; - - if (this === void 0 || this === null) - { - throw new TypeError(); - } - - var t = Object(this); - var len = t.length >>> 0; - - if (typeof fun !== 'function') - { - throw new TypeError(); - } - - var thisArg = arguments.length >= 2 ? arguments[1] : void 0; - - for (var i = 0; i < len; i++) - { - if (i in t) - { - fun.call(thisArg, t[i], i, t); - } - } - }; -} - - -/***/ }), -/* 609 */ -/***/ (function(module, exports, __webpack_require__) { - -__webpack_require__(608); -__webpack_require__(607); -__webpack_require__(606); -__webpack_require__(605); -__webpack_require__(604); -__webpack_require__(603); -__webpack_require__(602); -__webpack_require__(601); -__webpack_require__(600); - - -/***/ }), -/* 610 */ -/***/ (function(module, exports) { - -/** -* The `Matter.Pair` module contains methods for creating and manipulating collision pairs. -* -* @class Pair -*/ - -var Pair = {}; - -module.exports = Pair; - -(function() { - - /** - * Creates a pair. - * @method create - * @param {collision} collision - * @param {number} timestamp - * @return {pair} A new pair - */ - Pair.create = function(collision, timestamp) { - var bodyA = collision.bodyA, - bodyB = collision.bodyB; - - var pair = { - id: Pair.id(bodyA, bodyB), - bodyA: bodyA, - bodyB: bodyB, - activeContacts: [], - separation: 0, - isActive: true, - confirmedActive: true, - isSensor: bodyA.isSensor || bodyB.isSensor, - timeCreated: timestamp, - timeUpdated: timestamp, - - collision: null, - inverseMass: 0, - friction: 0, - frictionStatic: 0, - restitution: 0, - slop: 0 - }; - - Pair.update(pair, collision, timestamp); - - return pair; - }; - - /** - * Updates a pair given a collision. - * @method update - * @param {pair} pair - * @param {collision} collision - * @param {number} timestamp - */ - Pair.update = function(pair, collision, timestamp) { - // var contacts = pair.contacts, - // supports = collision.supports, - // activeContacts = pair.activeContacts, - // parentA = collision.parentA, - // parentB = collision.parentB; - - pair.collision = collision; - // pair.inverseMass = parentA.inverseMass + parentB.inverseMass; - // pair.friction = Math.min(parentA.friction, parentB.friction); - // pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); - // pair.restitution = Math.max(parentA.restitution, parentB.restitution); - // pair.slop = Math.max(parentA.slop, parentB.slop); - // activeContacts.length = 0; - - if (collision.collided) { - - var supports = collision.supports, - activeContacts = pair.activeContacts, - parentA = collision.parentA, - parentB = collision.parentB; - - pair.inverseMass = parentA.inverseMass + parentB.inverseMass; - pair.friction = Math.min(parentA.friction, parentB.friction); - pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); - pair.restitution = Math.max(parentA.restitution, parentB.restitution); - pair.slop = Math.max(parentA.slop, parentB.slop); - - for (var i = 0; i < supports.length; i++) { - activeContacts[i] = supports[i].contact; - } - - var supportCount = supports.length; - - if (supportCount < activeContacts.length) { - activeContacts.length = supportCount; - } - - pair.separation = collision.depth; - Pair.setActive(pair, true, timestamp); - } else { - if (pair.isActive === true) - Pair.setActive(pair, false, timestamp); - } - }; - - /** - * Set a pair as active or inactive. - * @method setActive - * @param {pair} pair - * @param {bool} isActive - * @param {number} timestamp - */ - Pair.setActive = function(pair, isActive, timestamp) { - if (isActive) { - pair.isActive = true; - pair.timeUpdated = timestamp; - } else { - pair.isActive = false; - pair.activeContacts.length = 0; - } - }; - - /** - * Get the id for the given pair. - * @method id - * @param {body} bodyA - * @param {body} bodyB - * @return {string} Unique pairId - */ - Pair.id = function(bodyA, bodyB) { - if (bodyA.id < bodyB.id) { - return 'A' + bodyA.id + 'B' + bodyB.id; - } else { - return 'A' + bodyB.id + 'B' + bodyA.id; - } - }; - -})(); - - -/***/ }), -/* 611 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Physics.Matter.Components - */ - -module.exports = { - - Bounce: __webpack_require__(1047), - Collision: __webpack_require__(1046), - Force: __webpack_require__(1045), - Friction: __webpack_require__(1044), - Gravity: __webpack_require__(1043), - Mass: __webpack_require__(1042), - Static: __webpack_require__(1041), - Sensor: __webpack_require__(1040), - SetBody: __webpack_require__(1039), - Sleep: __webpack_require__(1037), - Transform: __webpack_require__(1036), - Velocity: __webpack_require__(1035) - -}; - - -/***/ }), -/* 612 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes the given string and reverses it, returning the reversed string. - * For example if given the string `Atari 520ST` it would return `TS025 iratA`. - * - * @function Phaser.Utils.String.ReverseString - * @since 3.0.0 - * - * @param {string} string - The string to be reversed. - * - * @return {string} The reversed string. - */ -var ReverseString = function (string) -{ - return string.split('').reverse().join(''); -}; - -module.exports = ReverseString; - - -/***/ }), -/* 613 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Takes a string and replaces instances of markers with values in the given array. - * The markers take the form of `%1`, `%2`, etc. I.e.: - * - * `Format("The %1 is worth %2 gold", [ 'Sword', 500 ])` - * - * @function Phaser.Utils.String.Format - * @since 3.0.0 - * - * @param {string} string - The string containing the replacement markers. - * @param {array} values - An array containing values that will replace the markers. If no value exists an empty string is inserted instead. - * - * @return {string} The string containing replaced values. - */ -var Format = function (string, values) -{ - return string.replace(/%([0-9]+)/g, function (s, n) - { - return values[Number(n) - 1]; - }); -}; - -module.exports = Format; - - -/***/ }), -/* 614 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils.String - */ - -module.exports = { - - Format: __webpack_require__(613), - Pad: __webpack_require__(133), - Reverse: __webpack_require__(612), - UppercaseFirst: __webpack_require__(256) - -}; - - -/***/ }), -/* 615 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Clone = __webpack_require__(33); - -/** - * Creates a new Object using all values from obj1. - * - * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. - * - * @function Phaser.Utils.Object.MergeRight - * @since 3.0.0 - * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] - * - * @return {object} [description] - */ -var MergeRight = function (obj1, obj2) -{ - var clone = Clone(obj1); - - for (var key in obj2) - { - if (clone.hasOwnProperty(key)) - { - clone[key] = obj2[key]; - } - } - - return clone; -}; - -module.exports = MergeRight; - - -/***/ }), -/* 616 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Verifies that an object contains all requested keys - * - * @function Phaser.Utils.Object.HasAll - * @since 3.0.0 - * - * @param {object} source - an object on which to check for key existence - * @param {string[]} keys - an array of keys to ensure the source object contains - * - * @return {boolean} true if the source object contains all keys, false otherwise. - */ -var HasAll = function (source, keys) -{ - for (var i = 0; i < keys.length; i++) - { - if (!source.hasOwnProperty(keys[i])) - { - return false; - } - } - - return true; -}; - -module.exports = HasAll; - - -/***/ }), -/* 617 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); -var Clamp = __webpack_require__(23); - -/** - * [description] - * - * @function Phaser.Utils.Object.GetMinMaxValue - * @since 3.0.0 - * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} defaultValue - [description] - * - * @return {number} [description] - */ -var GetMinMaxValue = function (source, key, min, max, defaultValue) -{ - if (defaultValue === undefined) { defaultValue = min; } - - var value = GetValue(source, key, defaultValue); - - return Clamp(value, min, max); -}; - -module.exports = GetMinMaxValue; - - -/***/ }), -/* 618 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils.Object - */ - -module.exports = { - - Clone: __webpack_require__(33), - Extend: __webpack_require__(17), - GetAdvancedValue: __webpack_require__(10), - GetFastValue: __webpack_require__(1), - GetMinMaxValue: __webpack_require__(617), - GetValue: __webpack_require__(4), - HasAll: __webpack_require__(616), - HasAny: __webpack_require__(420), - HasValue: __webpack_require__(111), - IsPlainObject: __webpack_require__(8), - Merge: __webpack_require__(94), - MergeRight: __webpack_require__(615) - -}; - - -/***/ }), -/* 619 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Utils - */ - -module.exports = { - - Array: __webpack_require__(147), - Objects: __webpack_require__(618), - String: __webpack_require__(614) - -}; - - -/***/ }), -/* 620 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(11); -var ParseToTilemap = __webpack_require__(216); - -/** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * - * @method Phaser.GameObjects.GameObjectFactory#tilemap - * @since 3.0.0 - * - * @param {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @param {integer} [tileWidth=32] - The width of a tile in pixels. Pass in `null` to leave as the - * default. - * @param {integer} [tileHeight=32] - The height of a tile in pixels. Pass in `null` to leave as the - * default. - * @param {integer} [width=10] - The width of the map in tiles. Pass in `null` to leave as the - * default. - * @param {integer} [height=10] - The height of the map in tiles. Pass in `null` to leave as the - * default. - * @param {integer[][]} [data] - Instead of loading from the cache, you can also load directly from - * a 2D array of tile indexes. Pass in `null` for no data. - * @param {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, in the - * map data are handled. If `true`, empty locations will get a value of `null`. If `false`, empty - * location will get a Tile object with an index of -1. If you've a large sparsely populated map and - * the tile data doesn't need to change then setting this value to `true` will help with memory - * consumption. However if your map is small or you need to update the tiles dynamically, then leave - * the default value set. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -GameObjectFactory.register('tilemap', function (key, tileWidth, tileHeight, width, height, data, insertNull) -{ - // Allow users to specify null to indicate that they want the default value, since null is - // shorter & more legible than undefined. Convert null to undefined to allow ParseToTilemap - // defaults to take effect. - - if (key === null) { key = undefined; } - if (tileWidth === null) { tileWidth = undefined; } - if (tileHeight === null) { tileHeight = undefined; } - if (width === null) { width = undefined; } - if (height === null) { height = undefined; } - - return ParseToTilemap(this.scene, key, tileWidth, tileHeight, width, height, data, insertNull); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 621 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var ParseToTilemap = __webpack_require__(216); - -/** - * @typedef {object} TilemapConfig - * - * @property {string} [key] - The key in the Phaser cache that corresponds to the loaded tilemap data. - * @property {integer[][]} [data] - Instead of loading from the cache, you can also load directly from a 2D array of tile indexes. - * @property {integer} [tileWidth=32] - The width of a tile in pixels. - * @property {integer} [tileHeight=32] - The height of a tile in pixels. - * @property {integer} [width=10] - The width of the map in tiles. - * @property {integer} [height=10] - The height of the map in tiles. - * @property {boolean} [insertNull=false] - Controls how empty tiles, tiles with an index of -1, - * in the map data are handled. If `true`, empty locations will get a value of `null`. If `false`, - * empty location will get a Tile object with an index of -1. If you've a large sparsely populated - * map and the tile data doesn't need to change then setting this value to `true` will help with - * memory consumption. However if your map is small or you need to update the tiles dynamically, - * then leave the default value set. - */ - -/** - * Creates a Tilemap from the given key or data, or creates a blank Tilemap if no key/data provided. - * When loading from CSV or a 2D array, you should specify the tileWidth & tileHeight. When parsing - * from a map from Tiled, the tileWidth, tileHeight, width & height will be pulled from the map - * data. For an empty map, you should specify tileWidth, tileHeight, width & height. - * - * @method Phaser.GameObjects.GameObjectCreator#tilemap - * @since 3.0.0 - * - * @param {TilemapConfig} [config] - The config options for the Tilemap. - * - * @return {Phaser.Tilemaps.Tilemap} - */ -GameObjectCreator.register('tilemap', function (config) -{ - // Defaults are applied in ParseToTilemap - var c = (config !== undefined) ? config : {}; - - return ParseToTilemap( - this.scene, - c.key, - c.tileWidth, - c.tileHeight, - c.width, - c.height, - c.data, - c.insertNull - ); -}); - - -/***/ }), -/* 622 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - var renderTiles = src.culledTiles; - var tileset = this.tileset; - var ctx = renderer.gameContext; - var tileCount = renderTiles.length; - var image = tileset.image.getSourceImage(); - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - ctx.globalAlpha = src.alpha; - - for (var index = 0; index < tileCount; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - - if (tileTexCoords === null) { continue; } - - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - tile.pixelX, tile.pixelY, - tile.width, tile.height - ); - } - - ctx.restore(); -}; - -module.exports = StaticTilemapLayerCanvasRenderer; - - -/***/ }), -/* 623 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.upload(camera); - - this.pipeline.drawStaticTilemapLayer(src, camera); -}; - -module.exports = StaticTilemapLayerWebGLRenderer; - - -/***/ }), -/* 624 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(623); -} - -if (true) -{ - renderCanvas = __webpack_require__(622); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 625 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - var renderTiles = src.culledTiles; - var length = renderTiles.length; - var image = src.tileset.image.getSourceImage(); - var tileset = this.tileset; - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - var ctx = renderer.gameContext; - - ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - for (var index = 0; index < length; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } - - var halfWidth = tile.width / 2; - var halfHeight = tile.height / 2; - - ctx.save(); - ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); - - if (tile.rotation !== 0) - { - ctx.rotate(tile.rotation); - } - - if (tile.flipX || tile.flipY) - { - ctx.scale(tile.flipX ? -1 : 1, tile.flipY ? -1 : 1); - } - - ctx.globalAlpha = src.alpha * tile.alpha; - - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - -halfWidth, -halfHeight, - tile.width, tile.height - ); - - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = DynamicTilemapLayerCanvasRenderer; - - -/***/ }), -/* 626 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.Tilemaps.DynamicTilemapLayer#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.cull(camera); - - this.pipeline.batchDynamicTilemapLayer(src, camera); -}; - -module.exports = DynamicTilemapLayerWebGLRenderer; - - -/***/ }), -/* 627 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(626); -} - -if (true) -{ - renderCanvas = __webpack_require__(625); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 628 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tileset = __webpack_require__(137); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseTilesets - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseTilesets = function (json) -{ - var tilesets = []; - var tilesetsNames = []; - - for (var i = 0; i < json.layer.length; i++) - { - var layer = json.layer[i]; - - // A relative filepath to the source image (within Weltmeister) is used for the name - var tilesetName = layer.tilesetName; - - // Only add unique tilesets that have a valid name. Collision layers will have a blank name. - if (tilesetName !== '' && tilesetsNames.indexOf(tilesetName) === -1) - { - tilesetsNames.push(tilesetName); - - // Tiles are stored with an ID relative to the tileset, rather than a globally unique ID - // across all tilesets. Also, tilesets in Weltmeister have no margin or padding. - tilesets.push(new Tileset(tilesetName, 0, layer.tilesize, layer.tilesize, 0, 0)); - } - } - - return tilesets; -}; - -module.exports = ParseTilesets; - - -/***/ }), -/* 629 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LayerData = __webpack_require__(104); -var Tile = __webpack_require__(66); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Impact.ParseTileLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * @param {boolean} insertNull - [description] - * - * @return {array} [description] - */ -var ParseTileLayers = function (json, insertNull) -{ - var tileLayers = []; - - for (var i = 0; i < json.layer.length; i++) - { - var layer = json.layer[i]; - - var layerData = new LayerData({ - name: layer.name, - width: layer.width, - height: layer.height, - tileWidth: layer.tilesize, - tileHeight: layer.tilesize, - visible: layer.visible === 1 - }); - - var row = []; - var tileGrid = []; - - // Loop through the data field in the JSON. This is a 2D array containing the tile indexes, - // one after the other. The indexes are relative to the tileset that contains the tile. - for (var y = 0; y < layer.data.length; y++) - { - for (var x = 0; x < layer.data[y].length; x++) - { - // In Weltmeister, 0 = no tile, but the Tilemap API expects -1 = no tile. - var index = layer.data[y][x] - 1; - - var tile; - - if (index > -1) - { - tile = new Tile(layerData, index, x, y, layer.tilesize, layer.tilesize); - } - else - { - tile = insertNull - ? null - : new Tile(layerData, -1, x, y, layer.tilesize, layer.tilesize); - } - - row.push(tile); - } - - tileGrid.push(row); - row = []; - } - - layerData.data = tileGrid; - - tileLayers.push(layerData); - } - - return tileLayers; -}; - -module.exports = ParseTileLayers; - - -/***/ }), -/* 630 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Extend = __webpack_require__(17); - -/** - * Copy properties from tileset to tiles. - * - * @function Phaser.Tilemaps.Parsers.Tiled.AssignTileProperties - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.MapData} mapData - [description] - */ -var AssignTileProperties = function (mapData) -{ - var layerData; - var tile; - var sid; - var set; - var row; - - // go through each of the map data layers - for (var i = 0; i < mapData.layers.length; i++) - { - layerData = mapData.layers[i]; - - set = null; - - // rows of tiles - for (var j = 0; j < layerData.data.length; j++) - { - row = layerData.data[j]; - - // individual tiles - for (var k = 0; k < row.length; k++) - { - tile = row[k]; - - if (tile === null || tile.index < 0) - { - continue; - } - - // find the relevant tileset - sid = mapData.tiles[tile.index][2]; - set = mapData.tilesets[sid]; - - // Ensure that a tile's size matches its tileset - tile.width = set.tileWidth; - tile.height = set.tileHeight; - - // if that tile type has any properties, add them to the tile object - if (set.tileProperties && set.tileProperties[tile.index - set.firstgid]) - { - tile.properties = Extend( - tile.properties, set.tileProperties[tile.index - set.firstgid] - ); - } - } - } - } -}; - -module.exports = AssignTileProperties; - - -/***/ }), -/* 631 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Master list of tiles -> x, y, index in tileset. - * - * @function Phaser.Tilemaps.Parsers.Tiled.BuildTilesetIndex - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.MapData} mapData - [description] - * - * @return {array} [description] - */ -var BuildTilesetIndex = function (mapData) -{ - var tiles = []; - - for (var i = 0; i < mapData.tilesets.length; i++) - { - var set = mapData.tilesets[i]; - - var x = set.tileMargin; - var y = set.tileMargin; - - var count = 0; - var countX = 0; - var countY = 0; - - for (var t = set.firstgid; t < set.firstgid + set.total; t++) - { - // Can add extra properties here as needed - tiles[t] = [ x, y, i ]; - - x += set.tileWidth + set.tileSpacing; - - count++; - - if (count === set.total) - { - break; - } - - countX++; - - if (countX === set.columns) - { - x = set.tileMargin; - y += set.tileHeight + set.tileSpacing; - - countX = 0; - countY++; - - if (countY === set.rows) - { - break; - } - } - } - } - - return tiles; -}; - -module.exports = BuildTilesetIndex; - - -/***/ }), -/* 632 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(1); -var ParseObject = __webpack_require__(314); -var ObjectLayer = __webpack_require__(313); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseObjectLayers = function (json) -{ - var objectLayers = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'objectgroup') - { - continue; - } - - var curo = json.layers[i]; - var offsetX = GetFastValue(curo, 'offsetx', 0); - var offsetY = GetFastValue(curo, 'offsety', 0); - var objects = []; - - for (var j = 0; j < curo.objects.length; j++) - { - var parsedObject = ParseObject(curo.objects[j], offsetX, offsetY); - - objects.push(parsedObject); - } - - var objectLayer = new ObjectLayer(curo); - objectLayer.objects = objects; - - objectLayers.push(objectLayer); - } - - return objectLayers; -}; - -module.exports = ParseObjectLayers; - - -/***/ }), -/* 633 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HasValue = __webpack_require__(111); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.Pick - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {array} keys - [description] - * - * @return {object} [description] - */ -var Pick = function (object, keys) -{ - var obj = {}; - - for (var i = 0; i < keys.length; i++) - { - var key = keys[i]; - - if (HasValue(object, key)) - { - obj[key] = object[key]; - } - } - - return obj; -}; - -module.exports = Pick; - - -/***/ }), -/* 634 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Tileset = __webpack_require__(137); -var ImageCollection = __webpack_require__(315); -var ParseObject = __webpack_require__(314); - -/** - * Tilesets & Image Collections - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseTilesets - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {object} [description] - */ -var ParseTilesets = function (json) -{ - var tilesets = []; - var imageCollections = []; - var lastSet = null; - var stringID; - - for (var i = 0; i < json.tilesets.length; i++) - { - // name, firstgid, width, height, margin, spacing, properties - var set = json.tilesets[i]; - - if (set.source) - { - console.warn('Phaser can\'t load external tilesets. Use the Embed Tileset button and then export the map again.'); - } - else if (set.image) - { - var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); - - // Properties stored per-tile in object with string indexes starting at "0" - if (set.tileproperties) - { - newSet.tileProperties = set.tileproperties; - } - - // Object & terrain shapes stored per-tile in object with string indexes starting at "0" - if (set.tiles) - { - newSet.tileData = set.tiles; - - // Parse the objects into Phaser format to match handling of other Tiled objects - for (stringID in newSet.tileData) - { - var objectGroup = newSet.tileData[stringID].objectgroup; - if (objectGroup && objectGroup.objects) - { - var parsedObjects = objectGroup.objects.map( - function (obj) { return ParseObject(obj); } - ); - newSet.tileData[stringID].objectgroup.objects = parsedObjects; - } - } - } - - // For a normal sliced tileset the row/count/size information is computed when updated. - // This is done (again) after the image is set. - newSet.updateTileData(set.imagewidth, set.imageheight); - - tilesets.push(newSet); - } - else - { - var newCollection = new ImageCollection(set.name, set.firstgid, set.tilewidth, - set.tileheight, set.margin, set.spacing, set.properties); - - for (stringID in set.tiles) - { - var image = set.tiles[stringID].image; - var gid = set.firstgid + parseInt(stringID, 10); - newCollection.addImage(gid, image); - } - - imageCollections.push(newCollection); - } - - // We've got a new Tileset, so set the lastgid into the previous one - if (lastSet) - { - lastSet.lastgid = set.firstgid - 1; - } - - lastSet = set; - } - - return { tilesets: tilesets, imageCollections: imageCollections }; -}; - -module.exports = ParseTilesets; - - -/***/ }), -/* 635 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetFastValue = __webpack_require__(1); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseImageLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * - * @return {array} [description] - */ -var ParseImageLayers = function (json) -{ - var images = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'imagelayer') - { - continue; - } - - var curi = json.layers[i]; - - images.push({ - name: curi.name, - image: curi.image, - x: GetFastValue(curi, 'offsetx', 0) + curi.x, - y: GetFastValue(curi, 'offsety', 0) + curi.y, - alpha: curi.opacity, - visible: curi.visible, - properties: GetFastValue(curi, 'properties', {}) - }); - } - - return images; -}; - -module.exports = ParseImageLayers; - - -/***/ }), -/* 636 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode - * @since 3.0.0 - * - * @param {object} data - [description] - * - * @return {array} [description] - */ -var Base64Decode = function (data) -{ - var binaryString = window.atob(data); - var len = binaryString.length; - var bytes = new Array(len / 4); - - // Interpret binaryString as an array of bytes representing little-endian encoded uint32 values. - for (var i = 0; i < len; i += 4) - { - bytes[i / 4] = ( - binaryString.charCodeAt(i) | - binaryString.charCodeAt(i + 1) << 8 | - binaryString.charCodeAt(i + 2) << 16 | - binaryString.charCodeAt(i + 3) << 24 - ) >>> 0; - } - - return bytes; -}; - -module.exports = Base64Decode; - - -/***/ }), -/* 637 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Base64Decode = __webpack_require__(636); -var GetFastValue = __webpack_require__(1); -var LayerData = __webpack_require__(104); -var ParseGID = __webpack_require__(316); -var Tile = __webpack_require__(66); - -/** - * [description] - * - * @function Phaser.Tilemaps.Parsers.Tiled.ParseTileLayers - * @since 3.0.0 - * - * @param {object} json - [description] - * @param {boolean} insertNull - [description] - * - * @return {array} [description] - */ -var ParseTileLayers = function (json, insertNull) -{ - var tileLayers = []; - - for (var i = 0; i < json.layers.length; i++) - { - if (json.layers[i].type !== 'tilelayer') - { - continue; - } - - var curl = json.layers[i]; - - // Base64 decode data if necessary. NOTE: uncompressed base64 only. - if (curl.compression) - { - console.warn( - 'TilemapParser.parseTiledJSON - Layer compression is unsupported, skipping layer \'' - + curl.name + '\'' - ); - continue; - } - else if (curl.encoding && curl.encoding === 'base64') - { - curl.data = Base64Decode(curl.data); - delete curl.encoding; // Allow the same map to be parsed multiple times - } - - var layerData = new LayerData({ - name: curl.name, - x: GetFastValue(curl, 'offsetx', 0) + curl.x, - y: GetFastValue(curl, 'offsety', 0) + curl.y, - width: curl.width, - height: curl.height, - tileWidth: json.tilewidth, - tileHeight: json.tileheight, - alpha: curl.opacity, - visible: curl.visible, - properties: GetFastValue(curl, 'properties', {}) - }); - - var x = 0; - var row = []; - var output = []; - - // Loop through the data field in the JSON. - - // This is an array containing the tile indexes, one after the other. -1 = no tile, - // everything else = the tile index (starting at 1 for Tiled, 0 for CSV) If the map - // contains multiple tilesets then the indexes are relative to that which the set starts - // from. Need to set which tileset in the cache = which tileset in the JSON, if you do this - // manually it means you can use the same map data but a new tileset. - - for (var t = 0, len = curl.data.length; t < len; t++) - { - var gidInfo = ParseGID(curl.data[t]); - - // index, x, y, width, height - if (gidInfo.gid > 0) - { - var tile = new Tile(layerData, gidInfo.gid, x, output.length, json.tilewidth, - json.tileheight); - - // Turning Tiled's FlippedHorizontal, FlippedVertical and FlippedAntiDiagonal - // propeties into flipX, flipY and rotation - tile.rotation = gidInfo.rotation; - tile.flipX = gidInfo.flipped; - - row.push(tile); - } - else - { - var blankTile = insertNull - ? null - : new Tile(layerData, -1, x, output.length, json.tilewidth, json.tileheight); - row.push(blankTile); - } - - x++; - - if (x === curl.width) - { - output.push(row); - x = 0; - row = []; - } - } - - layerData.data = output; - - tileLayers.push(layerData); - } - - return tileLayers; -}; - -module.exports = ParseTileLayers; - - -/***/ }), -/* 638 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps.Parsers - */ - -module.exports = { - - Parse: __webpack_require__(319), - Parse2DArray: __webpack_require__(217), - ParseCSV: __webpack_require__(318), - - Impact: __webpack_require__(312), - Tiled: __webpack_require__(317) - -}; - - -/***/ }), -/* 639 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); -var Vector2 = __webpack_require__(6); - -/** - * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @function Phaser.Tilemaps.Components.WorldToTileXY - * @private - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Math.Vector2} The XY location in tile units. - */ -var WorldToTileXY = function (worldX, worldY, snapToFloor, point, camera, layer) -{ - if (point === undefined) { point = new Vector2(0, 0); } - - point.x = WorldToTileX(worldX, snapToFloor, camera, layer); - point.y = WorldToTileY(worldY, snapToFloor, camera, layer); - - return point; -}; - -module.exports = WorldToTileXY; - - -/***/ }), -/* 640 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. New indexes are drawn from the given - * weightedIndexes array. An example weighted array: - * - * [ - * { index: 6, weight: 4 }, // Probability of index 6 is 4 / 8 - * { index: 7, weight: 2 }, // Probability of index 7 would be 2 / 8 - * { index: 8, weight: 1.5 }, // Probability of index 8 would be 1.5 / 8 - * { index: 26, weight: 0.5 } // Probability of index 27 would be 0.5 / 8 - * ] - * - * The probability of any index being choose is (the index's weight) / (sum of all weights). This - * method only modifies tile indexes and does not change collision information. - * - * @function Phaser.Tilemaps.Components.WeightedRandomize - * @private - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 } or - * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) -{ - if (weightedIndexes === undefined) { return; } - - var i; - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - var weightTotal = 0; - for (i = 0; i < weightedIndexes.length; i++) - { - weightTotal += weightedIndexes[i].weight; - } - - if (weightTotal <= 0) { return; } - - for (i = 0; i < tiles.length; i++) - { - var rand = Math.random() * weightTotal; - var sum = 0; - var randomIndex = -1; - for (var j = 0; j < weightedIndexes.length; j++) - { - sum += weightedIndexes[j].weight; - if (rand <= sum) - { - var chosen = weightedIndexes[j].index; - randomIndex = Array.isArray(chosen) - ? chosen[Math.floor(Math.random() * chosen.length)] - : chosen; - break; - } - } - - tiles[i].index = randomIndex; - } -}; - -module.exports = WeightedRandomize; - - -/***/ }), -/* 641 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileToWorldX = __webpack_require__(139); -var TileToWorldY = __webpack_require__(138); -var Vector2 = __webpack_require__(6); - -/** - * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the - * layer's position, scale and scroll. This will return a new Vector2 object or update the given - * `point` object. - * - * @function Phaser.Tilemaps.Components.TileToWorldXY - * @private - * @since 3.0.0 - * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Math.Vector2} The XY location in world coordinates. - */ -var TileToWorldXY = function (tileX, tileY, point, camera, layer) -{ - if (point === undefined) { point = new Vector2(0, 0); } - - point.x = TileToWorldX(tileX, camera, layer); - point.y = TileToWorldY(tileY, camera, layer); - - return point; -}; - -module.exports = TileToWorldXY; - - -/***/ }), -/* 642 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching - * `indexA` and swaps then with `indexB`. This only modifies the index and does not change collision - * information. - * - * @function Phaser.Tilemaps.Components.SwapByIndex - * @private - * @since 3.0.0 - * - * @param {integer} tileA - First tile index. - * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - if (tiles[i]) - { - if (tiles[i].index === indexA) - { - tiles[i].index = indexB; - } - else if (tiles[i].index === indexB) - { - tiles[i].index = indexA; - } - } - } -}; - -module.exports = SwapByIndex; - - -/***/ }), -/* 643 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var ShuffleArray = __webpack_require__(95); - -/** - * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given - * layer. It will only randomize the tiles in that area, so if they're all the same nothing will - * appear to have changed! This method only modifies tile indexes and does not change collision - * information. - * - * @function Phaser.Tilemaps.Components.Shuffle - * @private - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Shuffle = function (tileX, tileY, width, height, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - var indexes = tiles.map(function (tile) { return tile.index; }); - ShuffleArray(indexes); - - for (var i = 0; i < tiles.length; i++) - { - tiles[i].index = indexes[i]; - } -}; - -module.exports = Shuffle; - - -/***/ }), -/* 644 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. - * If a callback is already set for the tile index it will be replaced. Set the callback to null to - * remove it. - * - * @function Phaser.Tilemaps.Components.SetTileLocationCallback - * @private - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetTileLocationCallback = function (tileX, tileY, width, height, callback, callbackContext, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - tiles[i].setCollisionCallback(callback, callbackContext); - } - -}; - -module.exports = SetTileLocationCallback; - - -/***/ }), -/* 645 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets a global collision callback for the given tile index within the layer. This will affect all - * tiles on this layer that have the same index. If a callback is already set for the tile index it - * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile - * at a specific location on the map then see setTileLocationCallback. - * - * @function Phaser.Tilemaps.Components.SetTileIndexCallback - * @private - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. - * @param {function} callback - The callback that will be invoked when the tile is collided with. - * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetTileIndexCallback = function (indexes, callback, callbackContext, layer) -{ - if (typeof indexes === 'number') - { - layer.callbacks[indexes] = (callback !== null) - ? { callback: callback, callbackContext: callbackContext } - : undefined; - } - else - { - for (var i = 0, len = indexes.length; i < len; i++) - { - layer.callbacks[indexes[i]] = (callback !== null) - ? { callback: callback, callbackContext: callbackContext } - : undefined; - } - } -}; - -module.exports = SetTileIndexCallback; - - -/***/ }), -/* 646 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); - -/** - * Sets collision on the tiles within a layer by checking each tile's collision group data - * (typically defined in Tiled within the tileset collision editor). If any objects are found within - * a tile's collision group, the tile's colliding information will be set. The `collides` parameter - * controls if collision will be enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionFromCollisionGroup - * @private - * @since 3.0.0 - * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (!tile) { continue; } - - var collisionGroup = tile.getCollisionGroup(); - - // It's possible in Tiled to have a collision group without any shapes, e.g. create a - // shape and then delete the shape. - if (collisionGroup && collisionGroup.objects && collisionGroup.objects.length > 0) - { - SetTileCollision(tile, collides); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionFromCollisionGroup; - - -/***/ }), -/* 647 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); -var HasValue = __webpack_require__(111); - -/** - * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property - * that matches the given properties object, its collision flag will be set. The `collides` - * parameter controls if collision will be enabled (true) or disabled (false). Passing in - * `{ collides: true }` would update the collision flag on any tiles with a "collides" property that - * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can - * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a - * "types" property that matches any of those values, its collision flag will be updated. - * - * @function Phaser.Tilemaps.Components.SetCollisionByProperty - * @private - * @since 3.0.0 - * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (!tile) { continue; } - - for (var property in properties) - { - if (!HasValue(tile.properties, property)) { continue; } - - var values = properties[property]; - if (!Array.isArray(values)) - { - values = [ values ]; - } - - for (var i = 0; i < values.length; i++) - { - if (tile.properties[property] === values[i]) - { - SetTileCollision(tile, collides); - } - } - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionByProperty; - - -/***/ }), -/* 648 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); -var SetLayerCollisionIndex = __webpack_require__(218); - -/** - * Sets collision on all tiles in the given layer, except for tiles that have an index specified in - * the given array. The `collides` parameter controls if collision will be enabled (true) or - * disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionByExclusion - * @private - * @since 3.0.0 - * - * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - // Note: this only updates layer.collideIndexes for tile indexes found currently in the layer - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile && indexes.indexOf(tile.index) === -1) - { - SetTileCollision(tile, collides); - SetLayerCollisionIndex(tile.index, collides, layer); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionByExclusion; - - -/***/ }), -/* 649 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); -var SetLayerCollisionIndex = __webpack_require__(218); - -/** - * Sets collision on a range of tiles in a layer whose index is between the specified `start` and - * `stop` (inclusive). Calling this with a start value of 10 and a stop value of 14 would set - * collision for tiles 10, 11, 12, 13 and 14. The `collides` parameter controls if collision will be - * enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollisionBetween - * @private - * @since 3.0.0 - * - * @param {integer} start - The first index of the tile to be set for collision. - * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - if (start > stop) { return; } - - // Update the array of colliding indexes - for (var index = start; index <= stop; index++) - { - SetLayerCollisionIndex(index, collides, layer); - } - - // Update the tiles - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - if (tile) - { - if (tile.index >= start && tile.index <= stop) - { - SetTileCollision(tile, collides); - } - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollisionBetween; - - -/***/ }), -/* 650 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SetTileCollision = __webpack_require__(67); -var CalculateFacesWithin = __webpack_require__(40); -var SetLayerCollisionIndex = __webpack_require__(218); - -/** - * Sets collision on the given tile or tiles within a layer by index. You can pass in either a - * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if - * collision will be enabled (true) or disabled (false). - * - * @function Phaser.Tilemaps.Components.SetCollision - * @private - * @since 3.0.0 - * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var SetCollision = function (indexes, collides, recalculateFaces, layer) -{ - if (collides === undefined) { collides = true; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - // Update the array of colliding indexes - for (var i = 0; i < indexes.length; i++) - { - SetLayerCollisionIndex(indexes[i], collides, layer); - } - - // Update the tiles - for (var ty = 0; ty < layer.height; ty++) - { - for (var tx = 0; tx < layer.width; tx++) - { - var tile = layer.data[ty][tx]; - - if (tile && indexes.indexOf(tile.index) !== -1) - { - SetTileCollision(tile, collides); - } - } - } - - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } -}; - -module.exports = SetCollision; - - -/***/ }), -/* 651 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var Color = __webpack_require__(542); - -/** - * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to - * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles - * are drawn starting at (0, 0) in the Graphics, allowing you to place the debug representation - * wherever you want on the screen. - * - * @function Phaser.Tilemaps.Components.RenderDebug - * @private - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. - * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {?Phaser.Display.Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {?Phaser.Display.Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {?Phaser.Display.Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var RenderDebug = function (graphics, styleConfig, layer) -{ - if (styleConfig === undefined) { styleConfig = {}; } - - // Default colors without needlessly creating Color objects - var tileColor = styleConfig.tileColor !== undefined - ? styleConfig.tileColor - : new Color(105, 210, 231, 150); - var collidingTileColor = styleConfig.collidingTileColor !== undefined - ? styleConfig.collidingTileColor - : new Color(243, 134, 48, 200); - var faceColor = styleConfig.faceColor !== undefined - ? styleConfig.faceColor - : new Color(40, 39, 37, 150); - - var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); - - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - var tw = tile.width; - var th = tile.height; - var x = tile.pixelX; - var y = tile.pixelY; - - var color = tile.collides ? collidingTileColor : tileColor; - if (color !== null) - { - graphics.fillStyle(color.color, color.alpha / 255); - graphics.fillRect(x, y, tw, th); - } - - // Inset the face line to prevent neighboring tile's lines from overlapping - x += 1; - y += 1; - tw -= 2; - th -= 2; - - if (faceColor !== null) - { - graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); - if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } - if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } - if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } - if (tile.faceLeft) { graphics.lineBetween(x, y, x, y + th); } - } - } -}; - -module.exports = RenderDebug; - - -/***/ }), -/* 652 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RemoveTileAt = __webpack_require__(320); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Removes the tile at the given world coordinates in the specified layer and updates the layer's - * collision information. - * - * @function Phaser.Tilemaps.Components.RemoveTileAtWorldXY - * @private - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. - */ -var RemoveTileAtWorldXY = function (worldX, worldY, replaceWithNull, recalculateFaces, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - return RemoveTileAt(tileX, tileY, replaceWithNull, recalculateFaces, layer); -}; - -module.exports = RemoveTileAtWorldXY; - - -/***/ }), -/* 653 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var GetRandom = __webpack_require__(146); - -/** - * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the - * specified layer. Each tile will receive a new index. If an array of indexes is passed in, then - * those will be used for randomly assigning new tile indexes. If an array is not provided, the - * indexes found within the region (excluding -1) will be used for randomly assigning new tile - * indexes. This method only modifies tile indexes and does not change collision information. - * - * @function Phaser.Tilemaps.Components.Randomize - * @private - * @since 3.0.0 - * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Randomize = function (tileX, tileY, width, height, indexes, layer) -{ - var i; - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - - // If no indicies are given, then find all the unique indexes within the specified region - if (indexes === undefined) - { - indexes = []; - for (i = 0; i < tiles.length; i++) - { - if (indexes.indexOf(tiles[i].index) === -1) - { - indexes.push(tiles[i].index); - } - } - } - - for (i = 0; i < tiles.length; i++) - { - tiles[i].index = GetRandom(indexes); - } -}; - -module.exports = Randomize; - - -/***/ }), -/* 654 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CalculateFacesWithin = __webpack_require__(40); -var PutTileAt = __webpack_require__(219); - -/** - * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified - * layer. The array can be composed of either tile indexes or Tile objects. If you pass in a Tile, - * all attributes will be copied over to the specified location. If you pass in an index, only the - * index at the specified location will be changed. Collision information will be recalculated - * within the region tiles were changed. - * - * @function Phaser.Tilemaps.Components.PutTilesAt - * @private - * @since 3.0.0 - * - * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) -{ - if (!Array.isArray(tilesArray)) { return null; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - // Force the input array to be a 2D array - if (!Array.isArray(tilesArray[0])) - { - tilesArray = [ tilesArray ]; - } - - var height = tilesArray.length; - var width = tilesArray[0].length; - - for (var ty = 0; ty < height; ty++) - { - for (var tx = 0; tx < width; tx++) - { - var tile = tilesArray[ty][tx]; - PutTileAt(tile, tileX + tx, tileY + ty, false, layer); - } - } - - if (recalculateFaces) - { - // Recalculate the faces within the destination area and neighboring tiles - CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = PutTilesAt; - - - -/***/ }), -/* 655 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var PutTileAt = __webpack_require__(219); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either - * an index or a Tile object. If you pass in a Tile, all attributes will be copied over to the - * specified location. If you pass in an index, only the index at the specified location will be - * changed. Collision information will be recalculated at the specified location. - * - * @function Phaser.Tilemaps.Components.PutTileAtWorldXY - * @private - * @since 3.0.0 - * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. - */ -var PutTileAtWorldXY = function (tile, worldX, worldY, recalculateFaces, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - return PutTileAt(tile, tileX, tileY, recalculateFaces, layer); -}; - -module.exports = PutTileAtWorldXY; - - -/***/ }), -/* 656 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HasTileAt = __webpack_require__(321); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns - * false if there is no tile or if the tile at that location has an index of -1. - * - * @function Phaser.Tilemaps.Components.HasTileAtWorldXY - * @private - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {boolean} - */ -var HasTileAtWorldXY = function (worldX, worldY, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - - return HasTileAt(tileX, tileY, layer); -}; - -module.exports = HasTileAtWorldXY; - - -/***/ }), -/* 657 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * - * @function Phaser.Tilemaps.Components.GetTilesWithinWorldXY - * @private - * @since 3.0.0 - * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer) -{ - // Top left corner of the rect, rounded down to include partial tiles - var xStart = WorldToTileX(worldX, true, camera, layer); - var yStart = WorldToTileY(worldY, true, camera, layer); - - // Bottom right corner of the rect, rounded up to include partial tiles - var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer)); - var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer)); - - return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer); -}; - -module.exports = GetTilesWithinWorldXY; - - -/***/ }), -/* 658 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Geom = __webpack_require__(400); -var GetTilesWithin = __webpack_require__(21); -var Intersects = __webpack_require__(399); -var NOOP = __webpack_require__(3); -var TileToWorldX = __webpack_require__(139); -var TileToWorldY = __webpack_require__(138); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -var TriangleToRectangle = function (triangle, rect) -{ - return Intersects.RectangleToTriangle(rect, triangle); -}; - -// Note: Could possibly be optimized by copying the shape and shifting it into tilemapLayer -// coordinates instead of shifting the tiles. - -/** - * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, - * Line, Rectangle or Triangle. The shape should be in world coordinates. - * - * @function Phaser.Tilemaps.Components.GetTilesWithinShape - * @private - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. - */ -var GetTilesWithinShape = function (shape, filteringOptions, camera, layer) -{ - if (shape === undefined) { return []; } - - // intersectTest is a function with parameters: shape, rect - var intersectTest = NOOP; - if (shape instanceof Geom.Circle) { intersectTest = Intersects.CircleToRectangle; } - else if (shape instanceof Geom.Rectangle) { intersectTest = Intersects.RectangleToRectangle; } - else if (shape instanceof Geom.Triangle) { intersectTest = TriangleToRectangle; } - else if (shape instanceof Geom.Line) { intersectTest = Intersects.LineToRectangle; } - - // Top left corner of the shapes's bounding box, rounded down to include partial tiles - var xStart = WorldToTileX(shape.left, true, camera, layer); - var yStart = WorldToTileY(shape.top, true, camera, layer); - - // Bottom right corner of the shapes's bounding box, rounded up to include partial tiles - var xEnd = Math.ceil(WorldToTileX(shape.right, false, camera, layer)); - var yEnd = Math.ceil(WorldToTileY(shape.bottom, false, camera, layer)); - - // Tiles within bounding rectangle of shape. Bounds are forced to be at least 1 x 1 tile in size - // to grab tiles for shapes that don't have a height or width (e.g. a horizontal line). - var width = Math.max(xEnd - xStart, 1); - var height = Math.max(yEnd - yStart, 1); - var tiles = GetTilesWithin(xStart, yStart, width, height, filteringOptions, layer); - - var tileWidth = layer.tileWidth; - var tileHeight = layer.tileHeight; - if (layer.tilemapLayer) - { - tileWidth *= layer.tilemapLayer.scaleX; - tileHeight *= layer.tilemapLayer.scaleY; - } - - var results = []; - var tileRect = new Geom.Rectangle(0, 0, tileWidth, tileHeight); - for (var i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - tileRect.x = TileToWorldX(tile.x, camera, layer); - tileRect.y = TileToWorldY(tile.y, camera, layer); - if (intersectTest(shape, tileRect)) - { - results.push(tile); - } - } - - return results; -}; - -module.exports = GetTilesWithinShape; - - -/***/ }), -/* 659 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTileAt = __webpack_require__(140); -var WorldToTileX = __webpack_require__(53); -var WorldToTileY = __webpack_require__(52); - -/** - * Gets a tile at the given world coordinates from the given layer. - * - * @function Phaser.Tilemaps.Components.GetTileAtWorldXY - * @private - * @since 3.0.0 - * - * @param {number} worldX - X position to get the tile from (given in pixels) - * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates - * were invalid. - */ -var GetTileAtWorldXY = function (worldX, worldY, nonNull, camera, layer) -{ - var tileX = WorldToTileX(worldX, true, camera, layer); - var tileY = WorldToTileY(worldY, true, camera, layer); - - return GetTileAt(tileX, tileY, nonNull, layer); -}; - -module.exports = GetTileAtWorldXY; - - -/***/ }), -/* 660 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * @callback EachTileCallback - * - * @param {Phaser.Tilemaps.Tile} value - [description] - * @param {number} index - [description] - * @param {Phaser.Tilemaps.Tile[]} array - [description] - */ - -/** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * callback. Similar to Array.prototype.forEach in vanilla JS. - * - * @function Phaser.Tilemaps.Components.ForEachTile - * @private - * @since 3.0.0 - * - * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - tiles.forEach(callback, context); -}; - -module.exports = ForEachTile; - - -/***/ }), -/* 661 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * @callback FindTileCallback - * - * @param {Phaser.Tilemaps.Tile} value - [description] - * @param {number} index - [description] - * @param {Phaser.Tilemaps.Tile[]} array - [description] - * - * @return {boolean} [description] - */ - -/** - * Find the first tile in the given rectangular area (in tile coordinates) of the layer that - * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns - * true. Similar to Array.prototype.find in vanilla JS. - * - * @function Phaser.Tilemaps.Components.FindTile - * @private - * @since 3.0.0 - * - * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found - */ -var FindTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - return tiles.find(callback, context) || null; -}; - -module.exports = FindTile; - - -/***/ }), -/* 662 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Searches the entire map layer for the first tile matching the given index, then returns that Tile - * object. If no match is found, it returns null. The search starts from the top-left tile and - * continues horizontally until it hits the end of the row, then it drops down to the next column. - * If the reverse boolean is true, it scans starting from the bottom-right corner traveling up to - * the top-left. - * - * @function Phaser.Tilemaps.Components.FindByIndex - * @private - * @since 3.0.0 - * - * @param {integer} index - The tile index value to search for. - * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {?Phaser.Tilemaps.Tile} The first (or n skipped) tile with the matching index. - */ -var FindByIndex = function (findIndex, skip, reverse, layer) -{ - if (skip === undefined) { skip = 0; } - if (reverse === undefined) { reverse = false; } - - var count = 0; - var tx; - var ty; - var tile; - - if (reverse) - { - for (ty = layer.height - 1; ty >= 0; ty--) - { - for (tx = layer.width - 1; tx >= 0; tx--) - { - tile = layer.data[ty][tx]; - if (tile && tile.index === findIndex) - { - if (count === skip) - { - return tile; - } - else - { - count += 1; - } - } - } - } - } - else - { - for (ty = 0; ty < layer.height; ty++) - { - for (tx = 0; tx < layer.width; tx++) - { - tile = layer.data[ty][tx]; - if (tile && tile.index === findIndex) - { - if (count === skip) - { - return tile; - } - else - { - count += 1; - } - } - } - } - } - - return null; -}; - -module.exports = FindByIndex; - - -/***/ }), -/* 663 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); - -/** - * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given - * filter callback function. Any tiles that pass the filter test (i.e. where the callback returns - * true) will returned as a new array. Similar to Array.prototype.Filter in vanilla JS. - * - * @function Phaser.Tilemaps.Components.FilterTiles - * @private - * @since 3.0.0 - * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. The callback should return true for tiles that pass the - * filter. - * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. - */ -var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) -{ - var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); - return tiles.filter(callback, context); -}; - -module.exports = FilterTiles; - - - -/***/ }), -/* 664 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var CalculateFacesWithin = __webpack_require__(40); -var SetTileCollision = __webpack_require__(67); - -/** - * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the - * specified index. Tiles will be set to collide if the given index is a colliding index. - * Collision information in the region will be recalculated. - * - * @function Phaser.Tilemaps.Components.Fill - * @private - * @since 3.0.0 - * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) -{ - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); - - var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); - for (var i = 0; i < tiles.length; i++) - { - tiles[i].index = index; - - SetTileCollision(tiles[i], doesIndexCollide); - } - - if (recalculateFaces) - { - // Recalculate the faces within the area and neighboring tiles - CalculateFacesWithin(tileX - 1, tileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = Fill; - - -/***/ }), -/* 665 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the tiles in the given layer that are within the camera's viewport. This is used - * internally. - * - * @function Phaser.Tilemaps.Components.CullTiles - * @private - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * @param {array} [outputArray] - [description] - * - * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. - */ -var CullTiles = function (layer, camera, outputArray) -{ - if (outputArray === undefined) { outputArray = []; } - - outputArray.length = 0; - - var zoom = camera.zoom; - var originX = camera.width / 2; - var originY = camera.height / 2; - - camera.matrix.loadIdentity(); - camera.matrix.translate(camera.x + originX, camera.y + originY); - camera.matrix.rotate(camera.rotation); - camera.matrix.scale(zoom, zoom); - camera.matrix.translate(-originX, -originY); - camera.matrix.invert(); - - camera.shakeEffect.preRender(); - - var tilemapLayer = layer.tilemapLayer; - var tileW = layer.tileWidth; - var tileH = layer.tileHeight; - var cullX = ((camera.scrollX * tilemapLayer.scrollFactorX) - tileW); - var cullY = ((camera.scrollY * tilemapLayer.scrollFactorY) - tileH); - var cullW = (cullX + (camera.width + tileW * 2)); - var cullH = (cullY + (camera.height + tileH * 2)); - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - var cameraMatrix = camera.matrix.matrix; - var a = cameraMatrix[0]; - var b = cameraMatrix[1]; - var c = cameraMatrix[2]; - var d = cameraMatrix[3]; - var e = cameraMatrix[4]; - var f = cameraMatrix[5]; - var tCullX = cullX * a + cullY * c + e; - var tCullY = cullX * b + cullY * d + f; - var tCullW = cullW * a + cullH * c + e; - var tCullH = cullW * b + cullH * d + f; - - for (var y = 0; y < mapHeight; ++y) - { - for (var x = 0; x < mapWidth; ++x) - { - var tile = mapData[y][x]; - - if (tile === null || tile.index === -1) - { - continue; - } - - var tileX = tile.pixelX * a + tile.pixelY * c + e; - var tileY = tile.pixelX * b + tile.pixelY * d + f; - - if (tile.visible && - tileX >= tCullX && - tileY >= tCullY && - tileX + tileW <= tCullW && - tileY + tileH <= tCullH - ) - { - outputArray.push(tile); - } - } - } - - /* var tilemapLayer = layer.tilemapLayer; - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - var left = (camera.scrollX * camera.zoom * tilemapLayer.scrollFactorX) - tilemapLayer.x; - var top = (camera.scrollY * camera.zoom * tilemapLayer.scrollFactorY) - tilemapLayer.y; - var sx = tilemapLayer.scaleX; - var sy = tilemapLayer.scaleY; - var tileWidth = layer.tileWidth * sx; - var tileHeight = layer.tileHeight * sy; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile === null || tile.index === -1) { continue; } - - var tileX = tile.pixelX * sx - left; - var tileY = tile.pixelY * sy - top; - var cullW = camera.width + tileWidth; - var cullH = camera.height + tileHeight; - - if (tile.visible && - tileX > -tileWidth && tileY > -tileHeight && - tileX < cullW && tileY < cullH) - { - outputArray.push(tile); - } - } - } */ - - return outputArray; -}; - -module.exports = CullTiles; - - -/***/ }), -/* 666 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileToWorldX = __webpack_require__(139); -var TileToWorldY = __webpack_require__(138); -var GetTilesWithin = __webpack_require__(21); -var ReplaceByIndex = __webpack_require__(322); - -/** - * Creates a Sprite for every object matching the given tile indexes in the layer. You can - * optionally specify if each tile will be replaced with a new tile after the Sprite has been - * created. This is useful if you want to lay down special tiles in a level that are converted to - * Sprites, but want to replace the tile itself with a floor tile or similar once converted. - * - * @function Phaser.Tilemaps.Components.CreateFromTiles - * @private - * @since 3.0.0 - * - * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). - * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - * - * @return {Phaser.GameObjects.Sprite[]} An array of the Sprites that were created. - */ -var CreateFromTiles = function (indexes, replacements, spriteConfig, scene, camera, layer) -{ - if (spriteConfig === undefined) { spriteConfig = {}; } - - if (!Array.isArray(indexes)) { indexes = [ indexes ]; } - - var tilemapLayer = layer.tilemapLayer; - if (scene === undefined) { scene = tilemapLayer.scene; } - if (camera === undefined) { camera = scene.cameras.main; } - - var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); - var sprites = []; - var i; - - for (i = 0; i < tiles.length; i++) - { - var tile = tiles[i]; - - if (indexes.indexOf(tile.index) !== -1) - { - spriteConfig.x = TileToWorldX(tile.x, camera, layer); - spriteConfig.y = TileToWorldY(tile.y, camera, layer); - - var sprite = scene.make.sprite(spriteConfig); - sprites.push(sprite); - } - } - - if (typeof replacements === 'number') - { - // Assume 1 replacement for all types of tile given - for (i = 0; i < indexes.length; i++) - { - ReplaceByIndex(indexes[i], replacements, 0, 0, layer.width, layer.height, layer); - } - } - else if (Array.isArray(replacements)) - { - // Assume 1 to 1 mapping with indexes array - for (i = 0; i < indexes.length; i++) - { - ReplaceByIndex(indexes[i], replacements[i], 0, 0, layer.width, layer.height, layer); - } - } - - return sprites; -}; - -module.exports = CreateFromTiles; - - -/***/ }), -/* 667 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetTilesWithin = __webpack_require__(21); -var CalculateFacesWithin = __webpack_require__(40); - -/** - * Copies the tiles in the source rectangular area to a new destination (all specified in tile - * coordinates) within the layer. This copies all tile properties & recalculates collision - * information in the destination region. - * - * @function Phaser.Tilemaps.Components.Copy - * @private - * @since 3.0.0 - * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. - */ -var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) -{ - if (srcTileX < 0) { srcTileX = 0; } - if (srcTileY < 0) { srcTileY = 0; } - if (recalculateFaces === undefined) { recalculateFaces = true; } - - var srcTiles = GetTilesWithin(srcTileX, srcTileY, width, height, null, layer); - - var offsetX = destTileX - srcTileX; - var offsetY = destTileY - srcTileY; - - for (var i = 0; i < srcTiles.length; i++) - { - var tileX = srcTiles[i].x + offsetX; - var tileY = srcTiles[i].y + offsetY; - if (tileX >= 0 && tileX < layer.width && tileY >= 0 && tileY < layer.height) - { - if (layer.data[tileY][tileX]) - { - layer.data[tileY][tileX].copy(srcTiles[i]); - } - } - } - - if (recalculateFaces) - { - // Recalculate the faces within the destination area and neighboring tiles - CalculateFacesWithin(destTileX - 1, destTileY - 1, width + 2, height + 2, layer); - } -}; - -module.exports = Copy; - - -/***/ }), -/* 668 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Tilemaps - */ - -module.exports = { - - Components: __webpack_require__(141), - Parsers: __webpack_require__(638), - - Formats: __webpack_require__(26), - ImageCollection: __webpack_require__(315), - ParseToTilemap: __webpack_require__(216), - Tile: __webpack_require__(66), - Tilemap: __webpack_require__(311), - TilemapCreator: __webpack_require__(621), - TilemapFactory: __webpack_require__(620), - Tileset: __webpack_require__(137), - - LayerData: __webpack_require__(104), - MapData: __webpack_require__(103), - ObjectLayer: __webpack_require__(313), - - DynamicTilemapLayer: __webpack_require__(310), - StaticTilemapLayer: __webpack_require__(309) - -}; - - -/***/ }), -/* 669 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Renderer.WebGL.Pipelines - */ - -module.exports = { - - BitmapMaskPipeline: __webpack_require__(260), - FlatTintPipeline: __webpack_require__(259), - ForwardDiffuseLightPipeline: __webpack_require__(148), - TextureTintPipeline: __webpack_require__(129) - -}; - - -/***/ }), -/* 670 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Renderer.WebGL - */ - -module.exports = { - - Utils: __webpack_require__(27), - WebGLPipeline: __webpack_require__(84), - WebGLRenderer: __webpack_require__(262), - Pipelines: __webpack_require__(669), - - // Constants - BYTE: 0, - SHORT: 1, - UNSIGNED_BYTE: 2, - UNSIGNED_SHORT: 3, - FLOAT: 4 - -}; - - -/***/ }), -/* 671 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @callback SnapshotCallback - * - * @param {HTMLImageElement} snapshot - [description] - */ - -/** - * @namespace Phaser.Renderer.Snapshot - */ - -module.exports = { - - Canvas: __webpack_require__(265), - WebGL: __webpack_require__(261) - -}; - - -/***/ }), -/* 672 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Renderer.Canvas - */ - -module.exports = { - - BlitImage: __webpack_require__(266), - CanvasRenderer: __webpack_require__(267), - DrawImage: __webpack_require__(264), - GetBlendModes: __webpack_require__(263) - -}; - - -/***/ }), -/* 673 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} RendererConfig - * - * @property {boolean} clearBeforeRender - [description] - * @property {boolean} pixelArt - [description] - * @property {Phaser.Display.Color} backgroundColor - [description] - * @property {number} resolution - [description] - * @property {boolean} autoResize - [description] - * @property {boolean} roundPixels - [description] - */ - -/** - * @namespace Phaser.Renderer - */ - -module.exports = { - - Canvas: __webpack_require__(672), - Snapshot: __webpack_require__(671), - WebGL: __webpack_require__(670) - -}; - - -/***/ }), -/* 674 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.World` module contains methods for creating and manipulating the world composite. -* A `Matter.World` is a `Matter.Composite` body, which is a collection of `Matter.Body`, `Matter.Constraint` and other `Matter.Composite`. -* A `Matter.World` has a few additional properties including `gravity` and `bounds`. -* It is important to use the functions in the `Matter.Composite` module to modify the world composite, rather than directly modifying its properties. -* There are also a few methods here that alias those in `Matter.Composite` for easier readability. -* -* See the included usage [examples](https://github.com/liabru/matter-js/tree/master/examples). -* -* @class World -* @extends Composite -*/ - -var World = {}; - -module.exports = World; - -var Composite = __webpack_require__(221); -var Constraint = __webpack_require__(300); -var Common = __webpack_require__(41); - -(function() { - - /** - * Creates a new world composite. The options parameter is an object that specifies any properties you wish to override the defaults. - * See the properties section below for detailed information on what you can pass via the `options` object. - * @method create - * @constructor - * @param {} options - * @return {world} A new world - */ - World.create = function(options) { - var composite = Composite.create(); - - var defaults = { - label: 'World', - gravity: { - x: 0, - y: 1, - scale: 0.001 - }, - bounds: { - min: { x: -Infinity, y: -Infinity }, - max: { x: Infinity, y: Infinity } - } - }; - - return Common.extend(composite, defaults, options); - }; - - /* - * - * Properties Documentation - * - */ - - /** - * The gravity to apply on the world. - * - * @property gravity - * @type object - */ - - /** - * The gravity x component. - * - * @property gravity.x - * @type object - * @default 0 - */ - - /** - * The gravity y component. - * - * @property gravity.y - * @type object - * @default 1 - */ - - /** - * The gravity scale factor. - * - * @property gravity.scale - * @type object - * @default 0.001 - */ - - /** - * A `Bounds` object that defines the world bounds for collision detection. - * - * @property bounds - * @type bounds - * @default { min: { x: -Infinity, y: -Infinity }, max: { x: Infinity, y: Infinity } } - */ - - // World is a Composite body - // see src/module/Outro.js for these aliases: - - /** - * An alias for Composite.clear - * @method clear - * @param {world} world - * @param {boolean} keepStatic - */ - - /** - * An alias for Composite.add - * @method addComposite - * @param {world} world - * @param {composite} composite - * @return {world} The original world with the objects from composite added - */ - - /** - * An alias for Composite.addBody - * @method addBody - * @param {world} world - * @param {body} body - * @return {world} The original world with the body added - */ - - /** - * An alias for Composite.addConstraint - * @method addConstraint - * @param {world} world - * @param {constraint} constraint - * @return {world} The original world with the constraint added - */ - -})(); - - -/***/ }), -/* 675 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Plugin` module contains functions for registering and installing plugins on modules. -* -* @class Plugin -*/ - -var Plugin = {}; - -module.exports = Plugin; - -var Common = __webpack_require__(41); - -(function() { - - Plugin._registry = {}; - - /** - * Registers a plugin object so it can be resolved later by name. - * @method register - * @param plugin {} The plugin to register. - * @return {object} The plugin. - */ - Plugin.register = function(plugin) { - if (!Plugin.isPlugin(plugin)) { - Common.warn('Plugin.register:', Plugin.toString(plugin), 'does not implement all required fields.'); - } - - if (plugin.name in Plugin._registry) { - var registered = Plugin._registry[plugin.name], - pluginVersion = Plugin.versionParse(plugin.version).number, - registeredVersion = Plugin.versionParse(registered.version).number; - - if (pluginVersion > registeredVersion) { - Common.warn('Plugin.register:', Plugin.toString(registered), 'was upgraded to', Plugin.toString(plugin)); - Plugin._registry[plugin.name] = plugin; - } else if (pluginVersion < registeredVersion) { - Common.warn('Plugin.register:', Plugin.toString(registered), 'can not be downgraded to', Plugin.toString(plugin)); - } else if (plugin !== registered) { - Common.warn('Plugin.register:', Plugin.toString(plugin), 'is already registered to different plugin object'); - } - } else { - Plugin._registry[plugin.name] = plugin; - } - - return plugin; - }; - - /** - * Resolves a dependency to a plugin object from the registry if it exists. - * The `dependency` may contain a version, but only the name matters when resolving. - * @method resolve - * @param dependency {string} The dependency. - * @return {object} The plugin if resolved, otherwise `undefined`. - */ - Plugin.resolve = function(dependency) { - return Plugin._registry[Plugin.dependencyParse(dependency).name]; - }; - - /** - * Returns a pretty printed plugin name and version. - * @method toString - * @param plugin {} The plugin. - * @return {string} Pretty printed plugin name and version. - */ - Plugin.toString = function(plugin) { - return typeof plugin === 'string' ? plugin : (plugin.name || 'anonymous') + '@' + (plugin.version || plugin.range || '0.0.0'); - }; - - /** - * Returns `true` if the object meets the minimum standard to be considered a plugin. - * This means it must define the following properties: - * - `name` - * - `version` - * - `install` - * @method isPlugin - * @param obj {} The obj to test. - * @return {boolean} `true` if the object can be considered a plugin otherwise `false`. - */ - Plugin.isPlugin = function(obj) { - return obj && obj.name && obj.version && obj.install; - }; - - /** - * Returns `true` if a plugin with the given `name` been installed on `module`. - * @method isUsed - * @param module {} The module. - * @param name {string} The plugin name. - * @return {boolean} `true` if a plugin with the given `name` been installed on `module`, otherwise `false`. - */ - Plugin.isUsed = function(module, name) { - return module.used.indexOf(name) > -1; - }; - - /** - * Returns `true` if `plugin.for` is applicable to `module` by comparing against `module.name` and `module.version`. - * If `plugin.for` is not specified then it is assumed to be applicable. - * The value of `plugin.for` is a string of the format `'module-name'` or `'module-name@version'`. - * @method isFor - * @param plugin {} The plugin. - * @param module {} The module. - * @return {boolean} `true` if `plugin.for` is applicable to `module`, otherwise `false`. - */ - Plugin.isFor = function(plugin, module) { - var parsed = plugin.for && Plugin.dependencyParse(plugin.for); - return !plugin.for || (module.name === parsed.name && Plugin.versionSatisfies(module.version, parsed.range)); - }; - - /** - * Installs the plugins by calling `plugin.install` on each plugin specified in `plugins` if passed, otherwise `module.uses`. - * For installing plugins on `Matter` see the convenience function `Matter.use`. - * Plugins may be specified either by their name or a reference to the plugin object. - * Plugins themselves may specify further dependencies, but each plugin is installed only once. - * Order is important, a topological sort is performed to find the best resulting order of installation. - * This sorting attempts to satisfy every dependency's requested ordering, but may not be exact in all cases. - * This function logs the resulting status of each dependency in the console, along with any warnings. - * - A green tick ✅ indicates a dependency was resolved and installed. - * - An orange diamond 🔶 indicates a dependency was resolved but a warning was thrown for it or one if its dependencies. - * - A red cross ❌ indicates a dependency could not be resolved. - * Avoid calling this function multiple times on the same module unless you intend to manually control installation order. - * @method use - * @param module {} The module install plugins on. - * @param [plugins=module.uses] {} The plugins to install on module (optional, defaults to `module.uses`). - */ - Plugin.use = function(module, plugins) { - module.uses = (module.uses || []).concat(plugins || []); - - if (module.uses.length === 0) { - Common.warn('Plugin.use:', Plugin.toString(module), 'does not specify any dependencies to install.'); - return; - } - - var dependencies = Plugin.dependencies(module), - sortedDependencies = Common.topologicalSort(dependencies), - status = []; - - for (var i = 0; i < sortedDependencies.length; i += 1) { - if (sortedDependencies[i] === module.name) { - continue; - } - - var plugin = Plugin.resolve(sortedDependencies[i]); - - if (!plugin) { - status.push('❌ ' + sortedDependencies[i]); - continue; - } - - if (Plugin.isUsed(module, plugin.name)) { - continue; - } - - if (!Plugin.isFor(plugin, module)) { - Common.warn('Plugin.use:', Plugin.toString(plugin), 'is for', plugin.for, 'but installed on', Plugin.toString(module) + '.'); - plugin._warned = true; - } - - if (plugin.install) { - plugin.install(module); - } else { - Common.warn('Plugin.use:', Plugin.toString(plugin), 'does not specify an install function.'); - plugin._warned = true; - } - - if (plugin._warned) { - status.push('🔶 ' + Plugin.toString(plugin)); - delete plugin._warned; - } else { - status.push('✅ ' + Plugin.toString(plugin)); - } - - module.used.push(plugin.name); - } - - if (status.length > 0 && !plugin.silent) { - Common.info(status.join(' ')); - } - }; - - /** - * Recursively finds all of a module's dependencies and returns a flat dependency graph. - * @method dependencies - * @param module {} The module. - * @return {object} A dependency graph. - */ - Plugin.dependencies = function(module, tracked) { - var parsedBase = Plugin.dependencyParse(module), - name = parsedBase.name; - - tracked = tracked || {}; - - if (name in tracked) { - return; - } - - module = Plugin.resolve(module) || module; - - tracked[name] = Common.map(module.uses || [], function(dependency) { - if (Plugin.isPlugin(dependency)) { - Plugin.register(dependency); - } - - var parsed = Plugin.dependencyParse(dependency), - resolved = Plugin.resolve(dependency); - - if (resolved && !Plugin.versionSatisfies(resolved.version, parsed.range)) { - Common.warn( - 'Plugin.dependencies:', Plugin.toString(resolved), 'does not satisfy', - Plugin.toString(parsed), 'used by', Plugin.toString(parsedBase) + '.' - ); - - resolved._warned = true; - module._warned = true; - } else if (!resolved) { - Common.warn( - 'Plugin.dependencies:', Plugin.toString(dependency), 'used by', - Plugin.toString(parsedBase), 'could not be resolved.' - ); - - module._warned = true; - } - - return parsed.name; - }); - - for (var i = 0; i < tracked[name].length; i += 1) { - Plugin.dependencies(tracked[name][i], tracked); - } - - return tracked; - }; - - /** - * Parses a dependency string into its components. - * The `dependency` is a string of the format `'module-name'` or `'module-name@version'`. - * See documentation for `Plugin.versionParse` for a description of the format. - * This function can also handle dependencies that are already resolved (e.g. a module object). - * @method dependencyParse - * @param dependency {string} The dependency of the format `'module-name'` or `'module-name@version'`. - * @return {object} The dependency parsed into its components. - */ - Plugin.dependencyParse = function(dependency) { - if (Common.isString(dependency)) { - var pattern = /^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?))?$/; - - if (!pattern.test(dependency)) { - Common.warn('Plugin.dependencyParse:', dependency, 'is not a valid dependency string.'); - } - - return { - name: dependency.split('@')[0], - range: dependency.split('@')[1] || '*' - }; - } - - return { - name: dependency.name, - range: dependency.range || dependency.version - }; - }; - - /** - * Parses a version string into its components. - * Versions are strictly of the format `x.y.z` (as in [semver](http://semver.org/)). - * Versions may optionally have a prerelease tag in the format `x.y.z-alpha`. - * Ranges are a strict subset of [npm ranges](https://docs.npmjs.com/misc/semver#advanced-range-syntax). - * Only the following range types are supported: - * - Tilde ranges e.g. `~1.2.3` - * - Caret ranges e.g. `^1.2.3` - * - Exact version e.g. `1.2.3` - * - Any version `*` - * @method versionParse - * @param range {string} The version string. - * @return {object} The version range parsed into its components. - */ - Plugin.versionParse = function(range) { - var pattern = /^\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/; - - if (!pattern.test(range)) { - Common.warn('Plugin.versionParse:', range, 'is not a valid version or range.'); - } - - var identifiers = range.split('-'); - range = identifiers[0]; - - var isRange = isNaN(Number(range[0])), - version = isRange ? range.substr(1) : range, - parts = Common.map(version.split('.'), function(part) { - return Number(part); - }); - - return { - isRange: isRange, - version: version, - range: range, - operator: isRange ? range[0] : '', - parts: parts, - prerelease: identifiers[1], - number: parts[0] * 1e8 + parts[1] * 1e4 + parts[2] - }; - }; - - /** - * Returns `true` if `version` satisfies the given `range`. - * See documentation for `Plugin.versionParse` for a description of the format. - * If a version or range is not specified, then any version (`*`) is assumed to satisfy. - * @method versionSatisfies - * @param version {string} The version string. - * @param range {string} The range string. - * @return {boolean} `true` if `version` satisfies `range`, otherwise `false`. - */ - Plugin.versionSatisfies = function(version, range) { - range = range || '*'; - - var rangeParsed = Plugin.versionParse(range), - rangeParts = rangeParsed.parts, - versionParsed = Plugin.versionParse(version), - versionParts = versionParsed.parts; - - if (rangeParsed.isRange) { - if (rangeParsed.operator === '*' || version === '*') { - return true; - } - - if (rangeParsed.operator === '~') { - return versionParts[0] === rangeParts[0] && versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; - } - - if (rangeParsed.operator === '^') { - if (rangeParts[0] > 0) { - return versionParts[0] === rangeParts[0] && versionParsed.number >= rangeParsed.number; - } - - if (rangeParts[1] > 0) { - return versionParts[1] === rangeParts[1] && versionParts[2] >= rangeParts[2]; - } - - return versionParts[2] === rangeParts[2]; - } - } - - return version === range || version === '*'; - }; - -})(); - - -/***/ }), -/* 676 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Matter = __webpack_require__(1013); - -Matter.Body = __webpack_require__(74); -Matter.Composite = __webpack_require__(221); -Matter.World = __webpack_require__(674); - -Matter.Detector = __webpack_require__(678); -Matter.Grid = __webpack_require__(1012); -Matter.Pairs = __webpack_require__(1011); -Matter.Pair = __webpack_require__(610); -Matter.Query = __webpack_require__(1033); -Matter.Resolver = __webpack_require__(1010); -Matter.SAT = __webpack_require__(677); - -Matter.Constraint = __webpack_require__(300); - -Matter.Common = __webpack_require__(41); -Matter.Engine = __webpack_require__(1009); -Matter.Events = __webpack_require__(301); -Matter.Sleeping = __webpack_require__(331); -Matter.Plugin = __webpack_require__(675); - -Matter.Bodies = __webpack_require__(166); -Matter.Composites = __webpack_require__(1016); - -Matter.Axes = __webpack_require__(680); -Matter.Bounds = __webpack_require__(125); -Matter.Svg = __webpack_require__(1031); -Matter.Vector = __webpack_require__(106); -Matter.Vertices = __webpack_require__(126); - -// aliases - -Matter.World.add = Matter.Composite.add; -Matter.World.remove = Matter.Composite.remove; -Matter.World.addComposite = Matter.Composite.addComposite; -Matter.World.addBody = Matter.Composite.addBody; -Matter.World.addConstraint = Matter.Composite.addConstraint; -Matter.World.clear = Matter.Composite.clear; - -module.exports = Matter; - - -/***/ }), -/* 677 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.SAT` module contains methods for detecting collisions using the Separating Axis Theorem. -* -* @class SAT -*/ - -// TODO: true circles and curves - -var SAT = {}; - -module.exports = SAT; - -var Vertices = __webpack_require__(126); -var Vector = __webpack_require__(106); - -(function() { - - /** - * Detect collision between two bodies using the Separating Axis Theorem. - * @method collides - * @param {body} bodyA - * @param {body} bodyB - * @param {collision} previousCollision - * @return {collision} collision - */ - SAT.collides = function(bodyA, bodyB, previousCollision) { - var overlapAB, - overlapBA, - minOverlap, - collision, - canReusePrevCol = false; - - if (previousCollision) { - // estimate total motion - var parentA = bodyA.parent, - parentB = bodyB.parent, - motion = parentA.speed * parentA.speed + parentA.angularSpeed * parentA.angularSpeed - + parentB.speed * parentB.speed + parentB.angularSpeed * parentB.angularSpeed; - - // we may be able to (partially) reuse collision result - // but only safe if collision was resting - canReusePrevCol = previousCollision && previousCollision.collided && motion < 0.2; - - // reuse collision object - collision = previousCollision; - } else { - collision = { collided: false, bodyA: bodyA, bodyB: bodyB }; - } - - if (previousCollision && canReusePrevCol) { - // if we can reuse the collision result - // we only need to test the previously found axis - var axisBodyA = collision.axisBody, - axisBodyB = axisBodyA === bodyA ? bodyB : bodyA, - axes = [axisBodyA.axes[previousCollision.axisNumber]]; - - minOverlap = _overlapAxes(axisBodyA.vertices, axisBodyB.vertices, axes); - collision.reused = true; - - if (minOverlap.overlap <= 0) { - collision.collided = false; - return collision; - } - } else { - // if we can't reuse a result, perform a full SAT test - - overlapAB = _overlapAxes(bodyA.vertices, bodyB.vertices, bodyA.axes); - - if (overlapAB.overlap <= 0) { - collision.collided = false; - return collision; - } - - overlapBA = _overlapAxes(bodyB.vertices, bodyA.vertices, bodyB.axes); - - if (overlapBA.overlap <= 0) { - collision.collided = false; - return collision; - } - - if (overlapAB.overlap < overlapBA.overlap) { - minOverlap = overlapAB; - collision.axisBody = bodyA; - } else { - minOverlap = overlapBA; - collision.axisBody = bodyB; - } - - // important for reuse later - collision.axisNumber = minOverlap.axisNumber; - } - - collision.bodyA = bodyA.id < bodyB.id ? bodyA : bodyB; - collision.bodyB = bodyA.id < bodyB.id ? bodyB : bodyA; - collision.collided = true; - collision.depth = minOverlap.overlap; - collision.parentA = collision.bodyA.parent; - collision.parentB = collision.bodyB.parent; - - bodyA = collision.bodyA; - bodyB = collision.bodyB; - - // ensure normal is facing away from bodyA - if (Vector.dot(minOverlap.axis, Vector.sub(bodyB.position, bodyA.position)) < 0) { - collision.normal = { - x: minOverlap.axis.x, - y: minOverlap.axis.y - }; - } else { - collision.normal = { - x: -minOverlap.axis.x, - y: -minOverlap.axis.y - }; - } - - collision.tangent = Vector.perp(collision.normal); - - collision.penetration = collision.penetration || {}; - collision.penetration.x = collision.normal.x * collision.depth; - collision.penetration.y = collision.normal.y * collision.depth; - - // find support points, there is always either exactly one or two - var verticesB = _findSupports(bodyA, bodyB, collision.normal), - supports = []; - - // find the supports from bodyB that are inside bodyA - if (Vertices.contains(bodyA.vertices, verticesB[0])) - supports.push(verticesB[0]); - - if (Vertices.contains(bodyA.vertices, verticesB[1])) - supports.push(verticesB[1]); - - // find the supports from bodyA that are inside bodyB - if (supports.length < 2) { - var verticesA = _findSupports(bodyB, bodyA, Vector.neg(collision.normal)); - - if (Vertices.contains(bodyB.vertices, verticesA[0])) - supports.push(verticesA[0]); - - if (supports.length < 2 && Vertices.contains(bodyB.vertices, verticesA[1])) - supports.push(verticesA[1]); - } - - // account for the edge case of overlapping but no vertex containment - if (supports.length < 1) - supports = [verticesB[0]]; - - collision.supports = supports; - - return collision; - }; - - /** - * Find the overlap between two sets of vertices. - * @method _overlapAxes - * @private - * @param {} verticesA - * @param {} verticesB - * @param {} axes - * @return result - */ - var _overlapAxes = function(verticesA, verticesB, axes) { - var projectionA = Vector._temp[0], - projectionB = Vector._temp[1], - result = { overlap: Number.MAX_VALUE }, - overlap, - axis; - - for (var i = 0; i < axes.length; i++) { - axis = axes[i]; - - _projectToAxis(projectionA, verticesA, axis); - _projectToAxis(projectionB, verticesB, axis); - - overlap = Math.min(projectionA.max - projectionB.min, projectionB.max - projectionA.min); - - if (overlap <= 0) { - result.overlap = overlap; - return result; - } - - if (overlap < result.overlap) { - result.overlap = overlap; - result.axis = axis; - result.axisNumber = i; - } - } - - return result; - }; - - /** - * Projects vertices on an axis and returns an interval. - * @method _projectToAxis - * @private - * @param {} projection - * @param {} vertices - * @param {} axis - */ - var _projectToAxis = function(projection, vertices, axis) { - var min = Vector.dot(vertices[0], axis), - max = min; - - for (var i = 1; i < vertices.length; i += 1) { - var dot = Vector.dot(vertices[i], axis); - - if (dot > max) { - max = dot; - } else if (dot < min) { - min = dot; - } - } - - projection.min = min; - projection.max = max; - }; - - /** - * Finds supporting vertices given two bodies along a given direction using hill-climbing. - * @method _findSupports - * @private - * @param {} bodyA - * @param {} bodyB - * @param {} normal - * @return [vector] - */ - var _findSupports = function(bodyA, bodyB, normal) { - var nearestDistance = Number.MAX_VALUE, - vertexToBody = Vector._temp[0], - vertices = bodyB.vertices, - bodyAPosition = bodyA.position, - distance, - vertex, - vertexA, - vertexB; - - // find closest vertex on bodyB - for (var i = 0; i < vertices.length; i++) { - vertex = vertices[i]; - vertexToBody.x = vertex.x - bodyAPosition.x; - vertexToBody.y = vertex.y - bodyAPosition.y; - distance = -Vector.dot(normal, vertexToBody); - - if (distance < nearestDistance) { - nearestDistance = distance; - vertexA = vertex; - } - } - - // find next closest vertex using the two connected to it - var prevIndex = vertexA.index - 1 >= 0 ? vertexA.index - 1 : vertices.length - 1; - vertex = vertices[prevIndex]; - vertexToBody.x = vertex.x - bodyAPosition.x; - vertexToBody.y = vertex.y - bodyAPosition.y; - nearestDistance = -Vector.dot(normal, vertexToBody); - vertexB = vertex; - - var nextIndex = (vertexA.index + 1) % vertices.length; - vertex = vertices[nextIndex]; - vertexToBody.x = vertex.x - bodyAPosition.x; - vertexToBody.y = vertex.y - bodyAPosition.y; - distance = -Vector.dot(normal, vertexToBody); - if (distance < nearestDistance) { - vertexB = vertex; - } - - return [vertexA, vertexB]; - }; - -})(); - - -/***/ }), -/* 678 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Detector` module contains methods for detecting collisions given a set of pairs. -* -* @class Detector -*/ - -// TODO: speculative contacts - -var Detector = {}; - -module.exports = Detector; - -var SAT = __webpack_require__(677); -var Pair = __webpack_require__(610); -var Bounds = __webpack_require__(125); - -(function() { - - /** - * Finds all collisions given a list of pairs. - * @method collisions - * @param {pair[]} broadphasePairs - * @param {engine} engine - * @return {array} collisions - */ - Detector.collisions = function(broadphasePairs, engine) { - var collisions = [], - pairsTable = engine.pairs.table; - - // @if DEBUG - var metrics = engine.metrics; - // @endif - - for (var i = 0; i < broadphasePairs.length; i++) { - var bodyA = broadphasePairs[i][0], - bodyB = broadphasePairs[i][1]; - - if ((bodyA.isStatic || bodyA.isSleeping) && (bodyB.isStatic || bodyB.isSleeping)) - continue; - - if (!Detector.canCollide(bodyA.collisionFilter, bodyB.collisionFilter)) - continue; - - // @if DEBUG - metrics.midphaseTests += 1; - // @endif - - // mid phase - if (Bounds.overlaps(bodyA.bounds, bodyB.bounds)) { - for (var j = bodyA.parts.length > 1 ? 1 : 0; j < bodyA.parts.length; j++) { - var partA = bodyA.parts[j]; - - for (var k = bodyB.parts.length > 1 ? 1 : 0; k < bodyB.parts.length; k++) { - var partB = bodyB.parts[k]; - - if ((partA === bodyA && partB === bodyB) || Bounds.overlaps(partA.bounds, partB.bounds)) { - // find a previous collision we could reuse - var pairId = Pair.id(partA, partB), - pair = pairsTable[pairId], - previousCollision; - - if (pair && pair.isActive) { - previousCollision = pair.collision; - } else { - previousCollision = null; - } - - // narrow phase - var collision = SAT.collides(partA, partB, previousCollision); - - // @if DEBUG - metrics.narrowphaseTests += 1; - if (collision.reused) - metrics.narrowReuseCount += 1; - // @endif - - if (collision.collided) { - collisions.push(collision); - // @if DEBUG - metrics.narrowDetections += 1; - // @endif - } - } - } - } - } - } - - return collisions; - }; - - /** - * Returns `true` if both supplied collision filters will allow a collision to occur. - * See `body.collisionFilter` for more information. - * @method canCollide - * @param {} filterA - * @param {} filterB - * @return {bool} `true` if collision can occur - */ - Detector.canCollide = function(filterA, filterB) { - if (filterA.group === filterB.group && filterA.group !== 0) - return filterA.group > 0; - - return (filterA.mask & filterB.category) !== 0 && (filterB.mask & filterA.category) !== 0; - }; - -})(); - - -/***/ }), -/* 679 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Bodies = __webpack_require__(166); -var Body = __webpack_require__(74); -var Class = __webpack_require__(0); -var Components = __webpack_require__(611); -var GetFastValue = __webpack_require__(1); -var HasValue = __webpack_require__(111); -var Vertices = __webpack_require__(126); - -/** - * @classdesc - * A wrapper around a Tile that provides access to a corresponding Matter body. A tile can only - * have one Matter body associated with it. You can either pass in an existing Matter body for - * the tile or allow the constructor to create the corresponding body for you. If the Tile has a - * collision group (defined in Tiled), those shapes will be used to create the body. If not, the - * tile's rectangle bounding box will be used. - * - * The corresponding body will be accessible on the Tile itself via Tile.physics.matterBody. - * - * Note: not all Tiled collision shapes are supported. See - * Phaser.Physics.Matter.TileBody#setFromTileCollision for more information. - * - * @class TileBody - * @memberOf Phaser.Physics.Matter - * @constructor - * @since 3.0.0 - * - * @extends Phaser.Physics.Matter.Components.Bounce - * @extends Phaser.Physics.Matter.Components.Collision - * @extends Phaser.Physics.Matter.Components.Friction - * @extends Phaser.Physics.Matter.Components.Gravity - * @extends Phaser.Physics.Matter.Components.Mass - * @extends Phaser.Physics.Matter.Components.Sensor - * @extends Phaser.Physics.Matter.Components.Sleep - * @extends Phaser.Physics.Matter.Components.Static - * - * @param {Phaser.Physics.Matter.World} world - [description] - * @param {Phaser.Tilemaps.Tile} tile - The target tile that should have a Matter body. - * @param {object} [options] - Options to be used when creating the Matter body. See - * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. - * @param {Phaser.Physics.Matter.Matter.Body} [options.body=null] - An existing Matter body to - * be used instead of creating a new one. - * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be - * made static. This defaults to true since typically tiles should not be moved. - * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or - * existing body if options.body is used) to the Matter world. - */ -var MatterTileBody = new Class({ - - Mixins: [ - Components.Bounce, - Components.Collision, - Components.Friction, - Components.Gravity, - Components.Mass, - Components.Sensor, - Components.Sleep, - Components.Static - ], - - initialize: - - function MatterTileBody (world, tile, options) - { - /** - * The tile object the body is associated with. - * - * @name Phaser.Physics.Matter.TileBody#tile - * @type {Phaser.Tilemaps.Tile} - * @since 3.0.0 - */ - this.tile = tile; - - /** - * The Matter world the body exists within. - * - * @name Phaser.Physics.Matter.TileBody#world - * @type {Phaser.Physics.Matter.World} - * @since 3.0.0 - */ - this.world = world; - - // Install a reference to 'this' on the tile and ensure there can only be one matter body - // associated with the tile - if (tile.physics.matterBody) - { - tile.physics.matterBody.destroy(); - } - - tile.physics.matterBody = this; - - // Set the body either from an existing body (if provided), the shapes in the tileset - // collision layer (if it exists) or a rectangle matching the tile. - var body = GetFastValue(options, 'body', null); - - var addToWorld = GetFastValue(options, 'addToWorld', true); - - if (!body) - { - var collisionGroup = tile.getCollisionGroup(); - var collisionObjects = GetFastValue(collisionGroup, 'objects', []); - - if (collisionObjects.length > 0) - { - this.setFromTileCollision(options); - } - else - { - this.setFromTileRectangle(options); - } - } - else - { - this.setBody(body, addToWorld); - } - }, - - /** - * Sets the current body to a rectangle that matches the bounds of the tile. - * - * @method Phaser.Physics.Matter.TileBody#setFromTileRectangle - * @since 3.0.0 - * - * @param {object} [options] - Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. - * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be - * made static. This defaults to true since typically tiles should not be moved. - * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or - * existing body if options.body is used) to the Matter world. - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - setFromTileRectangle: function (options) - { - if (options === undefined) { options = {}; } - if (!HasValue(options, 'isStatic')) { options.isStatic = true; } - if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } - - var bounds = this.tile.getBounds(); - var cx = bounds.x + (bounds.width / 2); - var cy = bounds.y + (bounds.height / 2); - var body = Bodies.rectangle(cx, cy, bounds.width, bounds.height, options); - - this.setBody(body, options.addToWorld); - - return this; - }, - - /** - * Sets the current body from the collision group associated with the Tile. This is typically - * set up in Tiled's collision editor. - * - * Note: Matter doesn't support all shapes from Tiled. Rectangles and polygons are directly - * supported. Ellipses are converted into circle bodies. Polylines are treated as if they are - * closed polygons. If a tile has multiple shapes, a multi-part body will be created. Concave - * shapes are supported if poly-decomp library is included. Decomposition is not guaranteed to - * work for complex shapes (e.g. holes), so it's often best to manually decompose a concave - * polygon into multiple convex polygons yourself. - * - * @method Phaser.Physics.Matter.TileBody#setFromTileCollision - * @since 3.0.0 - * - * @param {object} [options] - Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. - * @param {boolean} [options.isStatic=true] - Whether or not the newly created body should be - * made static. This defaults to true since typically tiles should not be moved. - * @param {boolean} [options.addToWorld=true] - Whether or not to add the newly created body (or - * existing body if options.body is used) to the Matter world. - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - setFromTileCollision: function (options) - { - if (options === undefined) { options = {}; } - if (!HasValue(options, 'isStatic')) { options.isStatic = true; } - if (!HasValue(options, 'addToWorld')) { options.addToWorld = true; } - - var sx = this.tile.tilemapLayer.scaleX; - var sy = this.tile.tilemapLayer.scaleY; - var tileX = this.tile.getLeft(); - var tileY = this.tile.getTop(); - var collisionGroup = this.tile.getCollisionGroup(); - var collisionObjects = GetFastValue(collisionGroup, 'objects', []); - - var parts = []; - - for (var i = 0; i < collisionObjects.length; i++) - { - var object = collisionObjects[i]; - var ox = tileX + (object.x * sx); - var oy = tileY + (object.y * sy); - var ow = object.width * sx; - var oh = object.height * sy; - var body = null; - - if (object.rectangle) - { - body = Bodies.rectangle(ox + ow / 2, oy + oh / 2, ow, oh, options); - } - else if (object.ellipse) - { - body = Bodies.circle(ox + ow / 2, oy + oh / 2, ow / 2, options); - } - else if (object.polygon || object.polyline) - { - // Polygons and polylines are both treated as closed polygons - var originalPoints = object.polygon ? object.polygon : object.polyline; - - var points = originalPoints.map(function (p) - { - return { x: p.x * sx, y: p.y * sy }; - }); - - var vertices = Vertices.create(points); - - // Points are relative to the object's origin (first point placed in Tiled), but - // matter expects points to be relative to the center of mass. This only applies to - // convex shapes. When a concave shape is decomposed, multiple parts are created and - // the individual parts are positioned relative to (ox, oy). - if (Vertices.isConvex(points)) - { - var center = Vertices.centre(vertices); - ox += center.x; - oy += center.y; - } - - body = Bodies.fromVertices(ox, oy, vertices, options); - } - - if (body) - { - parts.push(body); - } - } - - if (parts.length === 1) - { - this.setBody(parts[0], options.addToWorld); - } - else if (parts.length > 1) - { - options.parts = parts; - this.setBody(Body.create(options), options.addToWorld); - } - - return this; - }, - - /** - * Sets the current body to the given body. This will remove the previous body, if one already - * exists. - * - * @method Phaser.Physics.Matter.TileBody#setBody - * @since 3.0.0 - * - * @param {MatterJS.Body} body - The new Matter body to use. - * @param {boolean} [addToWorld=true] - Whether or not to add the body to the Matter world. - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - setBody: function (body, addToWorld) - { - if (addToWorld === undefined) { addToWorld = true; } - - if (this.body) - { - this.removeBody(); - } - - this.body = body; - this.body.gameObject = this; - - if (addToWorld) - { - this.world.add(this.body); - } - - return this; - }, - - /** - * Removes the current body from the TileBody and from the Matter world - * - * @method Phaser.Physics.Matter.TileBody#removeBody - * @since 3.0.0 - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - removeBody: function () - { - if (this.body) - { - this.world.remove(this.body); - this.body.gameObject = undefined; - this.body = undefined; - } - - return this; - }, - - /** - * Removes the current body from the tile and the world. - * - * @method Phaser.Physics.Matter.TileBody#destroy - * @since 3.0.0 - * - * @return {Phaser.Physics.Matter.TileBody} This TileBody object. - */ - destroy: function () - { - this.removeBody(); - this.tile.physics.matterBody = undefined; - } - -}); - -module.exports = MatterTileBody; - - -/***/ }), -/* 680 */ -/***/ (function(module, exports, __webpack_require__) { - -/** -* The `Matter.Axes` module contains methods for creating and manipulating sets of axes. -* -* @class Axes -*/ - -var Axes = {}; - -module.exports = Axes; - -var Vector = __webpack_require__(106); -var Common = __webpack_require__(41); - -(function() { - - /** - * Creates a new set of axes from the given vertices. - * @method fromVertices - * @param {vertices} vertices - * @return {axes} A new axes from the given vertices - */ - Axes.fromVertices = function(vertices) { - var axes = {}; - - // find the unique axes, using edge normal gradients - for (var i = 0; i < vertices.length; i++) { - var j = (i + 1) % vertices.length, - normal = Vector.normalise({ - x: vertices[j].y - vertices[i].y, - y: vertices[i].x - vertices[j].x - }), - gradient = (normal.y === 0) ? Infinity : (normal.x / normal.y); - - // limit precision - gradient = gradient.toFixed(3).toString(); - axes[gradient] = normal; - } - - return Common.values(axes); - }; - - /** - * Rotates a set of axes by the given angle. - * @method rotate - * @param {axes} axes - * @param {number} angle - */ - Axes.rotate = function(axes, angle) { - if (angle === 0) - return; - - var cos = Math.cos(angle), - sin = Math.sin(angle); - - for (var i = 0; i < axes.length; i++) { - var axis = axes[i], - xx; - xx = axis.x * cos - axis.y * sin; - axis.y = axis.x * sin + axis.y * cos; - axis.x = xx; - } - }; - -})(); - - -/***/ }), -/* 681 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Physics.Impact.Components - */ - -module.exports = { - - Acceleration: __webpack_require__(1065), - BodyScale: __webpack_require__(1064), - BodyType: __webpack_require__(1063), - Bounce: __webpack_require__(1062), - CheckAgainst: __webpack_require__(1061), - Collides: __webpack_require__(1060), - Debug: __webpack_require__(1059), - Friction: __webpack_require__(1058), - Gravity: __webpack_require__(1057), - Offset: __webpack_require__(1056), - SetGameObject: __webpack_require__(1055), - Velocity: __webpack_require__(1054) - -}; - - -/***/ }), -/* 682 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetOverlapY = __webpack_require__(336); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.SeparateY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ -var SeparateY = function (body1, body2, overlapOnly, bias) -{ - var overlap = GetOverlapY(body1, body2, overlapOnly, bias); - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateY || body2.customSeparateY) - { - // return true if there was some overlap, otherwise false - return (overlap !== 0) || (body1.embedded && body2.embedded); - } - - // Adjust their positions and velocities accordingly (if there was any overlap) - var v1 = body1.velocity.y; - var v2 = body2.velocity.y; - - if (!body1.immovable && !body2.immovable) - { - overlap *= 0.5; - - body1.y -= overlap; - body2.y += overlap; - - var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); - var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); - var avg = (nv1 + nv2) * 0.5; - - nv1 -= avg; - nv2 -= avg; - - body1.velocity.y = avg + nv1 * body1.bounce.y; - body2.velocity.y = avg + nv2 * body2.bounce.y; - } - else if (!body1.immovable) - { - body1.y -= overlap; - body1.velocity.y = v2 - v1 * body1.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body2.moves) - { - body1.x += (body2.x - body2.prev.x) * body2.friction.x; - } - } - else - { - body2.y += overlap; - body2.velocity.y = v1 - v2 * body2.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body1.moves) - { - body2.x += (body1.x - body1.prev.x) * body1.friction.x; - } - } - - // If we got this far then there WAS overlap, and separation is complete, so return true - return true; -}; - -module.exports = SeparateY; - - -/***/ }), -/* 683 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetOverlapX = __webpack_require__(337); - -/** - * [description] - * - * @function Phaser.Physics.Arcade.SeparateX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] - * - * @return {boolean} [description] - */ -var SeparateX = function (body1, body2, overlapOnly, bias) -{ - var overlap = GetOverlapX(body1, body2, overlapOnly, bias); - - // Can't separate two immovable bodies, or a body with its own custom separation logic - if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX) - { - // return true if there was some overlap, otherwise false - return (overlap !== 0) || (body1.embedded && body2.embedded); - } - - // Adjust their positions and velocities accordingly (if there was any overlap) - var v1 = body1.velocity.x; - var v2 = body2.velocity.x; - - if (!body1.immovable && !body2.immovable) - { - overlap *= 0.5; - - body1.x -= overlap; - body2.x += overlap; - - var nv1 = Math.sqrt((v2 * v2 * body2.mass) / body1.mass) * ((v2 > 0) ? 1 : -1); - var nv2 = Math.sqrt((v1 * v1 * body1.mass) / body2.mass) * ((v1 > 0) ? 1 : -1); - var avg = (nv1 + nv2) * 0.5; - - nv1 -= avg; - nv2 -= avg; - - body1.velocity.x = avg + nv1 * body1.bounce.x; - body2.velocity.x = avg + nv2 * body2.bounce.x; - } - else if (!body1.immovable) - { - body1.x -= overlap; - body1.velocity.x = v2 - v1 * body1.bounce.x; - - // This is special case code that handles things like vertically moving platforms you can ride - if (body2.moves) - { - body1.y += (body2.y - body2.prev.y) * body2.friction.y; - } - } - else - { - body2.x += overlap; - body2.velocity.x = v1 - v2 * body2.bounce.x; - - // This is special case code that handles things like vertically moving platforms you can ride - if (body1.moves) - { - body2.y += (body1.y - body1.prev.y) * body1.friction.y; - } - } - - // If we got this far then there WAS overlap, and separation is complete, so return true - return true; -}; - -module.exports = SeparateX; - - -/***/ }), -/* 684 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internal function to process the separation of a physics body from a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {number} y - The y separation amount. - */ -var ProcessTileSeparationY = function (body, y) -{ - if (y < 0) - { - body.blocked.up = true; - } - else if (y > 0) - { - body.blocked.down = true; - } - - body.position.y -= y; - - if (body.bounce.y === 0) - { - body.velocity.y = 0; - } - else - { - body.velocity.y = -body.velocity.y * body.bounce.y; - } -}; - -module.exports = ProcessTileSeparationY; - - -/***/ }), -/* 685 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ProcessTileSeparationY = __webpack_require__(684); - -/** - * Check the body against the given tile on the Y axis. - * - * @function Phaser.Physics.Arcade.Tilemap.TileCheckY - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileTop - [description] - * @param {number} tileBottom - [description] - * @param {number} tileBias - [description] - * - * @return {number} The amount of separation that occurred. - */ -var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias) -{ - var oy = 0; - - if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up) - { - // Body is moving UP - if (tile.faceBottom && body.y < tileBottom) - { - oy = body.y - tileBottom; - - if (oy < -tileBias) - { - oy = 0; - } - } - } - else if (body.deltaY() > 0 && !body.blocked.down && tile.collideUp && body.checkCollision.down) - { - // Body is moving DOWN - if (tile.faceTop && body.bottom > tileTop) - { - oy = body.bottom - tileTop; - - if (oy > tileBias) - { - oy = 0; - } - } - } - - if (oy !== 0) - { - if (body.customSeparateY) - { - body.overlapY = oy; - } - else - { - ProcessTileSeparationY(body, oy); - } - } - - return oy; -}; - -module.exports = TileCheckY; - - -/***/ }), -/* 686 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Internal function to process the separation of a physics body from a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileSeparationX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {number} x - The x separation amount. - */ -var ProcessTileSeparationX = function (body, x) -{ - if (x < 0) - { - body.blocked.left = true; - } - else if (x > 0) - { - body.blocked.right = true; - } - - body.position.x -= x; - - if (body.bounce.x === 0) - { - body.velocity.x = 0; - } - else - { - body.velocity.x = -body.velocity.x * body.bounce.x; - } -}; - -module.exports = ProcessTileSeparationX; - - -/***/ }), -/* 687 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ProcessTileSeparationX = __webpack_require__(686); - -/** - * Check the body against the given tile on the X axis. - * - * @function Phaser.Physics.Arcade.Tilemap.TileCheckX - * @since 3.0.0 - * - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileLeft - [description] - * @param {number} tileRight - [description] - * @param {number} tileBias - [description] - * - * @return {number} The amount of separation that occurred. - */ -var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias) -{ - var ox = 0; - - if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left) - { - // Body is moving LEFT - if (tile.faceRight && body.x < tileRight) - { - ox = body.x - tileRight; - - if (ox < -tileBias) - { - ox = 0; - } - } - } - else if (body.deltaX() > 0 && !body.blocked.right && tile.collideLeft && body.checkCollision.right) - { - // Body is moving RIGHT - if (tile.faceLeft && body.right > tileLeft) - { - ox = body.right - tileLeft; - - if (ox > tileBias) - { - ox = 0; - } - } - } - - if (ox !== 0) - { - if (body.customSeparateX) - { - body.overlapX = ox; - } - else - { - ProcessTileSeparationX(body, ox); - } - } - - return ox; -}; - -module.exports = TileCheckX; - - -/***/ }), -/* 688 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileCheckX = __webpack_require__(687); -var TileCheckY = __webpack_require__(685); -var TileIntersectsBody = __webpack_require__(335); - -/** - * The core separation function to separate a physics body and a tile. - * - * @function Phaser.Physics.Arcade.Tilemap.SeparateTile - * @since 3.0.0 - * - * @param {number} i - [description] - * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. - * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. - * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] - * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemapLayer to collide against. - * @param {number} tileBias - [description] - * - * @return {boolean} Returns true if the body was separated, otherwise false. - */ -var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) -{ - var tileLeft = tileWorldRect.left; - var tileTop = tileWorldRect.top; - var tileRight = tileWorldRect.right; - var tileBottom = tileWorldRect.bottom; - var faceHorizontal = tile.faceLeft || tile.faceRight; - var faceVertical = tile.faceTop || tile.faceBottom; - - // We don't need to go any further if this tile doesn't actually have any colliding faces. This - // could happen if the tile was meant to be collided with re: a callback, but otherwise isn't - // needed for separation. - if (!faceHorizontal && !faceVertical) - { - return false; - } - - var ox = 0; - var oy = 0; - var minX = 0; - var minY = 1; - - if (body.deltaAbsX() > body.deltaAbsY()) - { - // Moving faster horizontally, check X axis first - minX = -1; - } - else if (body.deltaAbsX() < body.deltaAbsY()) - { - // Moving faster vertically, check Y axis first - minY = -1; - } - - if (body.deltaX() !== 0 && body.deltaY() !== 0 && faceHorizontal && faceVertical) - { - // We only need do this if both axes have colliding faces AND we're moving in both - // directions - minX = Math.min(Math.abs(body.position.x - tileRight), Math.abs(body.right - tileLeft)); - minY = Math.min(Math.abs(body.position.y - tileBottom), Math.abs(body.bottom - tileTop)); - } - - if (minX < minY) - { - if (faceHorizontal) - { - ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); - - // That's horizontal done, check if we still intersects? If not then we can return now - if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body)) - { - return true; - } - } - - if (faceVertical) - { - oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); - } - } - else - { - if (faceVertical) - { - oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias); - - // That's vertical done, check if we still intersects? If not then we can return now - if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body)) - { - return true; - } - } - - if (faceHorizontal) - { - ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias); - } - } - - return (ox !== 0 || oy !== 0); -}; - -module.exports = SeparateTile; - - -/***/ }), -/* 689 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.Tilemap} tile - [description] - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * - * @return {boolean} [description] - */ -var ProcessTileCallbacks = function (tile, sprite) -{ - // Tile callbacks take priority over layer level callbacks - if (tile.collisionCallback) - { - return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); - } - else if (tile.layer.callbacks[tile.index]) - { - return !tile.layer.callbacks[tile.index].callback.call( - tile.layer.callbacks[tile.index].callbackContext, sprite, tile - ); - } - - return true; -}; - -module.exports = ProcessTileCallbacks; - - -/***/ }), -/* 690 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Velocity - * @since 3.0.0 - */ -var Velocity = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setVelocity: function (x, y) - { - this.body.velocity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX - * @since 3.0.0 - * - * @param {number} x - [description] - * - * @return {this} This Game Object. - */ - setVelocityX: function (x) - { - this.body.velocity.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY - * @since 3.0.0 - * - * @param {number} y - [description] - * - * @return {this} This Game Object. - */ - setVelocityY: function (y) - { - this.body.velocity.y = y; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setMaxVelocity: function (x, y) - { - this.body.maxVelocity.set(x, y); - - return this; - } - -}; - -module.exports = Velocity; - - -/***/ }), -/* 691 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Size - * @since 3.0.0 - */ -var Size = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setOffset - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setOffset: function (x, y) - { - this.body.setOffset(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setSize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {boolean} [center=true] - [description] - * - * @return {this} This Game Object. - */ - setSize: function (width, height, center) - { - this.body.setSize(width, height, center); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Size#setCircle - * @since 3.0.0 - * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] - * - * @return {this} This Game Object. - */ - setCircle: function (radius, offsetX, offsetY) - { - this.body.setCircle(radius, offsetX, offsetY); - - return this; - } - -}; - -module.exports = Size; - - -/***/ }), -/* 692 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Mass - * @since 3.0.0 - */ -var Mass = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Mass#setMass - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setMass: function (value) - { - this.body.mass = value; - - return this; - } - -}; - -module.exports = Mass; - - -/***/ }), -/* 693 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Immovable - * @since 3.0.0 - */ -var Immovable = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable - * @since 3.0.0 - * - * @param {boolean} [value=true] - [description] - * - * @return {this} This Game Object. - */ - setImmovable: function (value) - { - if (value === undefined) { value = true; } - - this.body.immovable = value; - - return this; - } - -}; - -module.exports = Immovable; - - -/***/ }), -/* 694 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Gravity - * @since 3.0.0 - */ -var Gravity = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravity - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setGravity: function (x, y) - { - this.body.gravity.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX - * @since 3.0.0 - * - * @param {number} x - [description] - * - * @return {this} This Game Object. - */ - setGravityX: function (x) - { - this.body.gravity.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY - * @since 3.0.0 - * - * @param {number} y - [description] - * - * @return {this} This Game Object. - */ - setGravityY: function (y) - { - this.body.gravity.y = y; - - return this; - } - -}; - -module.exports = Gravity; - - -/***/ }), -/* 695 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Friction - * @since 3.0.0 - */ -var Friction = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFriction - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setFriction: function (x, y) - { - this.body.friction.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX - * @since 3.0.0 - * - * @param {number} x - [description] - * - * @return {this} This Game Object. - */ - setFrictionX: function (x) - { - this.body.friction.x = x; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY - * @since 3.0.0 - * - * @param {number} y - [description] - * - * @return {this} This Game Object. - */ - setFrictionY: function (y) - { - this.body.friction.y = y; - - return this; - } - -}; - -module.exports = Friction; - - -/***/ }), -/* 696 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Enable - * @since 3.0.0 - */ -var Enable = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Enable#enableBody - * @since 3.0.0 - * - * @param {boolean} reset - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {boolean} enableGameObject - [description] - * @param {boolean} showGameObject - [description] - * - * @return {this} This Game Object. - */ - enableBody: function (reset, x, y, enableGameObject, showGameObject) - { - if (reset) - { - this.body.reset(x, y); - } - - if (enableGameObject) - { - this.body.gameObject.active = true; - } - - if (showGameObject) - { - this.body.gameObject.visible = true; - } - - this.body.enable = true; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Enable#disableBody - * @since 3.0.0 - * - * @param {boolean} [disableGameObject=false] - [description] - * @param {boolean} [hideGameObject=false] - [description] - * - * @return {this} This Game Object. - */ - disableBody: function (disableGameObject, hideGameObject) - { - if (disableGameObject === undefined) { disableGameObject = false; } - if (hideGameObject === undefined) { hideGameObject = false; } - - this.body.stop(); - - this.body.enable = false; - - if (disableGameObject) - { - this.body.gameObject.active = false; - } - - if (hideGameObject) - { - this.body.gameObject.visible = false; - } - - return this; - }, - - /** - * Syncs the Bodies position and size with its parent Game Object. - * You don't need to call this for Dynamic Bodies, as it happens automatically. - * But for Static bodies it's a useful way of modifying the position of a Static Body - * in the Physics World, based on its Game Object. - * - * @method Phaser.Physics.Arcade.Components.Enable#refreshBody - * @since 3.1.0 - * - * @return {this} This Game Object. - */ - refreshBody: function () - { - this.body.updateFromGameObject(); - - return this; - } - -}; - -module.exports = Enable; - - -/***/ }), -/* 697 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Drag - * @since 3.0.0 - */ -var Drag = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDrag - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setDrag: function (x, y) - { - this.body.drag.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDragX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setDragX: function (value) - { - this.body.drag.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDragY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setDragY: function (value) - { - this.body.drag.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Drag#setDamping - * @since 3.10.0 - * - * @param {boolean} value - `true` to use damping for deceleration, or `false` to use linear deceleration. - * - * @return {this} This Game Object. - */ - setDamping: function (value) - { - this.body.useDamping = value; - - return this; - } - -}; - -module.exports = Drag; - - -/***/ }), -/* 698 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug - * @since 3.0.0 - */ -var Debug = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Debug#setDebug - * @since 3.0.0 - * - * @param {boolean} showBody - [description] - * @param {boolean} showVelocity - [description] - * @param {number} bodyColor - [description] - * - * @return {this} This Game Object. - */ - setDebug: function (showBody, showVelocity, bodyColor) - { - this.debugShowBody = showBody; - this.debugShowVelocity = showVelocity; - this.debugBodyColor = bodyColor; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setDebugBodyColor: function (value) - { - this.body.debugBodyColor = value; - - return this; - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody - * @type {boolean} - * @since 3.0.0 - */ - debugShowBody: { - - get: function () - { - return this.body.debugShowBody; - }, - - set: function (value) - { - this.body.debugShowBody = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity - * @type {boolean} - * @since 3.0.0 - */ - debugShowVelocity: { - - get: function () - { - return this.body.debugShowVelocity; - }, - - set: function (value) - { - this.body.debugShowVelocity = value; - } - - }, - - /** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor - * @type {number} - * @since 3.0.0 - */ - debugBodyColor: { - - get: function () - { - return this.body.debugBodyColor; - }, - - set: function (value) - { - this.body.debugBodyColor = value; - } - - } - -}; - -module.exports = Debug; - - -/***/ }), -/* 699 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Bounce - * @since 3.0.0 - */ -var Bounce = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounce - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} [y=x] - [description] - * - * @return {this} This Game Object. - */ - setBounce: function (x, y) - { - this.body.bounce.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setBounceX: function (value) - { - this.body.bounce.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setBounceY: function (value) - { - this.body.bounce.y = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds - * @since 3.0.0 - * - * @param {boolean} value - [description] - * - * @return {this} This Game Object. - */ - setCollideWorldBounds: function (value) - { - this.body.collideWorldBounds = value; - - return this; - } - -}; - -module.exports = Bounce; - - -/***/ }), -/* 700 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Angular - * @since 3.0.0 - */ -var Angular = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setAngularVelocity: function (value) - { - this.body.angularVelocity = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setAngularAcceleration: function (value) - { - this.body.angularAcceleration = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {this} This Game Object. - */ - setAngularDrag: function (value) - { - this.body.angularDrag = value; - - return this; - } - -}; - -module.exports = Angular; - - -/***/ }), -/* 701 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @name Phaser.Physics.Arcade.Components.Acceleration - * @since 3.0.0 - */ -var Acceleration = { - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration - * @since 3.0.0 - * - * @param {number} x - The horizontal acceleration - * @param {number} [y=x] - The vertical acceleration - * - * @return {this} This Game Object. - */ - setAcceleration: function (x, y) - { - this.body.acceleration.set(x, y); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX - * @since 3.0.0 - * - * @param {number} value - The horizontal acceleration - * - * @return {this} This Game Object. - */ - setAccelerationX: function (value) - { - this.body.acceleration.x = value; - - return this; - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY - * @since 3.0.0 - * - * @param {number} value - The vertical acceleration - * - * @return {this} This Game Object. - */ - setAccelerationY: function (value) - { - this.body.acceleration.y = value; - - return this; - } - -}; - -module.exports = Acceleration; - - -/***/ }), -/* 702 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var DegToRad = __webpack_require__(38); -var DistanceBetween = __webpack_require__(58); -var Factory = __webpack_require__(345); -var GetFastValue = __webpack_require__(1); -var Merge = __webpack_require__(94); -var PluginCache = __webpack_require__(12); -var Vector2 = __webpack_require__(6); -var World = __webpack_require__(340); - -// All methods in this class are available under `this.physics` in a Scene. - -/** - * @classdesc - * [description] - * - * @class ArcadePhysics - * @memberOf Phaser.Physics.Arcade - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var ArcadePhysics = new Class({ - - initialize: - - function ArcadePhysics (scene) - { - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#config - * @type {object} - * @since 3.0.0 - */ - this.config = this.getConfig(); - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#world - * @type {Phaser.Physics.Arcade.World} - * @since 3.0.0 - */ - this.world; - - /** - * [description] - * - * @name Phaser.Physics.Arcade.ArcadePhysics#add - * @type {Phaser.Physics.Arcade.Factory} - * @since 3.0.0 - */ - this.add; - - scene.sys.events.once('boot', this.boot, this); - scene.sys.events.on('start', this.start, this); - }, - - /** - * This method is called automatically, only once, when the Scene is first created. - * Do not invoke it directly. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#boot - * @private - * @since 3.5.1 - */ - boot: function () - { - this.world = new World(this.scene, this.config); - this.add = new Factory(this.world); - - this.systems.events.once('destroy', this.destroy, 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 () - { - if (!this.world) - { - 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); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig - * @since 3.0.0 - * - * @return {object} [description] - */ - getConfig: function () - { - var gameConfig = this.systems.game.config.physics; - var sceneConfig = this.systems.settings.physics; - - var config = Merge( - GetFastValue(sceneConfig, 'arcade', {}), - GetFastValue(gameConfig, 'arcade', {}) - ); - - return config; - }, - - /** - * Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body. - * - * Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. - * - * Both the first and second parameter can be arrays of objects, of differing types. - * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. - * - * ##### Tilemaps - * - * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. - * - * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). - * - * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#overlap - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {ArcadePhysicsCallback} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. - * @param {*} [callbackContext] - The context in which to run the callbacks. - * - * @return {boolean} True if an overlap occurred otherwise false. - */ - overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) - { - if (overlapCallback === undefined) { overlapCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = overlapCallback; } - - return this.world.collideObjects(object1, object2, overlapCallback, processCallback, callbackContext, true); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#collide - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {ArcadePhysicsCallback} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. - * @param {*} [callbackContext] - The context in which to run the callbacks. - * - * @return {boolean} True if a collision occurred otherwise false. - */ - collide: function (object1, object2, collideCallback, processCallback, callbackContext) - { - if (collideCallback === undefined) { collideCallback = null; } - if (processCallback === undefined) { processCallback = null; } - if (callbackContext === undefined) { callbackContext = collideCallback; } - - return this.world.collideObjects(object1, object2, collideCallback, processCallback, callbackContext, false); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#pause - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} [description] - */ - pause: function () - { - return this.world.pause(); - }, - - /** - * [description] - * - * @method Phaser.Physics.Arcade.ArcadePhysics#resume - * @since 3.0.0 - * - * @return {Phaser.Physics.Arcade.World} [description] - */ - resume: function () - { - return this.world.resume(); - }, - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateTo - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {number} x - The x coordinate to accelerate towards. - * @param {number} y - The y coordinate to accelerate towards. - * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. - * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. - * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - accelerateTo: function (gameObject, x, y, speed, xSpeedMax, ySpeedMax) - { - if (speed === undefined) { speed = 60; } - - var angle = Math.atan2(y - gameObject.y, x - gameObject.x); - - gameObject.body.acceleration.setToPolar(angle, speed); - - if (xSpeedMax !== undefined && ySpeedMax !== undefined) - { - gameObject.body.maxVelocity.set(xSpeedMax, ySpeedMax); - } - - return angle; - }, - - /** - * Sets the acceleration.x/y property on the game object so it will move towards the x/y coordinates at the given rate (in pixels per second squared) - * - * You must give a maximum speed value, beyond which the game object won't go any faster. - * - * Note: The game object does not continuously track the target. If the target changes location during transit the game object will not modify its course. - * Note: The game object doesn't stop moving once it reaches the destination coordinates. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#accelerateToObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {Phaser.GameObjects.GameObject} destination - The Game Object to move towards. Can be any object but must have visible x/y properties. - * @param {number} [speed=60] - The acceleration (change in speed) in pixels per second squared. - * @param {number} [xSpeedMax=500] - The maximum x velocity the game object can reach. - * @param {number} [ySpeedMax=500] - The maximum y velocity the game object can reach. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - accelerateToObject: function (gameObject, destination, speed, xSpeedMax, ySpeedMax) - { - return this.accelerateTo(gameObject, destination.x, destination.y, speed, xSpeedMax, ySpeedMax); - }, - - /** - * Finds the Body closest to a source point or object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#closest - * @since 3.0.0 - * - * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * - * @return {Phaser.Physics.Arcade.Body} The closest Body to the given source point. - */ - closest: function (source) - { - var bodies = this.tree.all(); - - var min = Number.MAX_VALUE; - var closest = null; - var x = source.x; - var y = source.y; - - for (var i = bodies.length - 1; i >= 0; i--) - { - var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); - - if (distance < min) - { - closest = target; - min = distance; - } - } - - return closest; - }, - - /** - * Finds the Body farthest from a source point or object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#furthest - * @since 3.0.0 - * - * @param {object} source - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * - * @return {Phaser.Physics.Arcade.Body} The Body furthest from the given source point. - */ - furthest: function (source) - { - var bodies = this.tree.all(); - - var max = -1; - var farthest = null; - var x = source.x; - var y = source.y; - - for (var i = bodies.length - 1; i >= 0; i--) - { - var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); - - if (distance > max) - { - farthest = target; - max = distance; - } - } - - return farthest; - }, - - /** - * Move the given display object towards the x/y coordinates at a steady velocity. - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @method Phaser.Physics.Arcade.ArcadePhysics#moveTo - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {number} x - The x coordinate to move towards. - * @param {number} y - The y coordinate to move towards. - * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - moveTo: function (gameObject, x, y, speed, maxTime) - { - if (speed === undefined) { speed = 60; } - if (maxTime === undefined) { maxTime = 0; } - - var angle = Math.atan2(y - gameObject.y, x - gameObject.x); - - if (maxTime > 0) - { - // We know how many pixels we need to move, but how fast? - speed = DistanceBetween(gameObject.x, gameObject.y, x, y) / (maxTime / 1000); - } - - gameObject.body.velocity.setToPolar(angle, speed); - - return angle; - }, - - /** - * Move the given display object towards the destination object at a steady velocity. - * If you specify a maxTime then it will adjust the speed (overwriting what you set) so it arrives at the destination in that number of seconds. - * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. - * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. - * Note: The display object doesn't stop moving once it reaches the destination coordinates. - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) - * - * @method Phaser.Physics.Arcade.ArcadePhysics#moveToObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - Any Game Object with an Arcade Physics body. - * @param {object} destination - Any object with public `x` and `y` properties, such as a Game Object or Geometry object. - * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. - * - * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. - */ - moveToObject: function (gameObject, destination, speed, maxTime) - { - return this.moveTo(gameObject, destination.x, destination.y, speed, maxTime); - }, - - /** - * Given the angle (in degrees) and speed calculate the velocity and return it as a vector, or set it to the given vector object. - * One way to use this is: velocityFromAngle(angle, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromAngle - * @since 3.0.0 - * - * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * @param {number} [speed=60] - The speed it will move, in pixels per second squared. - * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. - * - * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. - */ - velocityFromAngle: function (angle, speed, vec2) - { - if (speed === undefined) { speed = 60; } - if (vec2 === undefined) { vec2 = new Vector2(); } - - return vec2.setToPolar(DegToRad(angle), speed); - }, - - /** - * Given the rotation (in radians) and speed calculate the velocity and return it as a vector, or set it to the given vector object. - * One way to use this is: velocityFromRotation(rotation, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object. - * - * @method Phaser.Physics.Arcade.ArcadePhysics#velocityFromRotation - * @since 3.0.0 - * - * @param {number} rotation - The angle in radians. - * @param {number} [speed=60] - The speed it will move, in pixels per second squared - * @param {Phaser.Math.Vector2} [vec2] - The Vector2 in which the x and y properties will be set to the calculated velocity. - * - * @return {Phaser.Math.Vector2} The Vector2 that stores the velocity. - */ - velocityFromRotation: function (rotation, speed, vec2) - { - if (speed === undefined) { speed = 60; } - if (vec2 === undefined) { vec2 = new Vector2(); } - - return vec2.setToPolar(rotation, speed); - }, - - /** - * 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.add.destroy(); - this.world.destroy(); - - this.add = null; - this.world = null; - }, - - /** - * 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.scene.sys.events.off('start', this.start, this); - - this.scene = null; - this.systems = null; - } - -}); - -PluginCache.register('ArcadePhysics', ArcadePhysics, 'arcadePhysics'); - -module.exports = ArcadePhysics; - - -/***/ }), -/* 703 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(42); -var Extend = __webpack_require__(17); - -/** - * @callback ArcadePhysicsCallback - * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] - */ - -/** - * @namespace Phaser.Physics.Arcade - */ - -var Arcade = { - - ArcadePhysics: __webpack_require__(702), - Body: __webpack_require__(339), - Collider: __webpack_require__(338), - Factory: __webpack_require__(345), - Group: __webpack_require__(342), - Image: __webpack_require__(344), - Sprite: __webpack_require__(142), - StaticBody: __webpack_require__(334), - StaticGroup: __webpack_require__(341), - World: __webpack_require__(340) - -}; - -// Merge in the consts -Arcade = Extend(false, Arcade, CONST); - -module.exports = Arcade; - - -/***/ }), -/* 704 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks if the two values are within the given `tolerance` of each other. - * - * @function Phaser.Math.Within - * @since 3.0.0 - * - * @param {number} a - The first value to use in the calculation. - * @param {number} b - The second value to use in the calculation. - * @param {number} tolerance - The tolerance. Anything equal to or less than this value is considered as being within range. - * - * @return {boolean} Returns `true` if `a` is less than or equal to the tolerance of `b`. - */ -var Within = function (a, b, tolerance) -{ - return (Math.abs(a - b) <= tolerance); -}; - -module.exports = Within; - - -/***/ }), -/* 705 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} SinCosTable - * - * @property {number} sin - The sine value. - * @property {number} cos - The cosine value. - * @property {number} length - The length. - */ - -/** - * Generate a series of sine and cosine values. - * - * @function Phaser.Math.SinCosTableGenerator - * @since 3.0.0 - * - * @param {number} length - The number of values to generate. - * @param {number} [sinAmp=1] - The sine value amplitude. - * @param {number} [cosAmp=1] - The cosine value amplitude. - * @param {number} [frequency=1] - The frequency of the values. - * - * @return {SinCosTable} The generated values. - */ -var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency) -{ - if (sinAmp === undefined) { sinAmp = 1; } - if (cosAmp === undefined) { cosAmp = 1; } - if (frequency === undefined) { frequency = 1; } - - frequency *= Math.PI / length; - - var cos = []; - var sin = []; - - for (var c = 0; c < length; c++) - { - cosAmp -= sinAmp * frequency; - sinAmp += cosAmp * frequency; - - cos[c] = cosAmp; - sin[c] = sinAmp; - } - - return { - sin: sin, - cos: cos, - length: length - }; -}; - -module.exports = SinCosTableGenerator; - - -/***/ }), -/* 706 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Round a value to a given decimal place. - * - * @function Phaser.Math.RoundTo - * @since 3.0.0 - * - * @param {number} value - The value to round. - * @param {integer} [place=0] - The place to round to. - * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. - * - * @return {number} The rounded value. - */ -var RoundTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.round(value * p) / p; -}; - -module.exports = RoundTo; - - -/***/ }), -/* 707 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compute a random unit vector. - * - * Computes random values for the given vector between -1 and 1 that can be used to represent a direction. - * - * Optionally accepts a scale value to scale the resulting vector by. - * - * @function Phaser.Math.RandomXY - * @since 3.0.0 - * - * @param {Phaser.Math.Vector2} vector - The Vector to compute random values for. - * @param {float} [scale=1] - The scale of the random values. - * - * @return {Phaser.Math.Vector2} The given Vector. - */ -var RandomXY = function (vector, scale) -{ - if (scale === undefined) { scale = 1; } - - var r = Math.random() * 2 * Math.PI; - - vector.x = Math.cos(r) * scale; - vector.y = Math.sin(r) * scale; - - return vector; -}; - -module.exports = RandomXY; - - -/***/ }), -/* 708 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Work out what percentage `value` is of the range between `min` and `max`. - * If `max` isn't given then it will return the percentage of `value` to `min`. - * - * You can optionally specify an `upperMax` value, which is a mid-way point in the range that represents 100%, after which the % starts to go down to zero again. - * - * @function Phaser.Math.Percent - * @since 3.0.0 - * - * @param {number} value - The value to determine the percentage of. - * @param {number} min - The minimum value. - * @param {number} [max] - The maximum value. - * @param {number} [upperMax] - The mid-way point in the range that represents 100%. - * - * @return {float} A value between 0 and 1 representing the percentage. - */ -var Percent = function (value, min, max, upperMax) -{ - if (max === undefined) { max = min + 1; } - - var percentage = (value - min) / (max - min); - - if (percentage > 1) - { - if (upperMax !== undefined) - { - percentage = ((upperMax - value)) / (upperMax - max); - - if (percentage < 0) - { - percentage = 0; - } - } - else - { - percentage = 1; - } - } - else if (percentage < 0) - { - percentage = 0; - } - - return percentage; -}; - -module.exports = Percent; - - -/***/ }), -/* 709 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Subtract an `amount` from `value`, limiting the minimum result to `min`. - * - * @function Phaser.Math.MinSub - * @since 3.0.0 - * - * @param {number} value - The value to subtract from. - * @param {number} amount - The amount to subtract. - * @param {number} min - The minimum value to return. - * - * @return {number} The resulting value. - */ -var MinSub = function (value, amount, min) -{ - return Math.max(value - amount, min); -}; - -module.exports = MinSub; - - -/***/ }), -/* 710 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Add an `amount` to a `value`, limiting the maximum result to `max`. - * - * @function Phaser.Math.MaxAdd - * @since 3.0.0 - * - * @param {number} value - The value to add to. - * @param {number} amount - The amount to add. - * @param {number} max - The maximum value to return. - * - * @return {number} The resulting value. - */ -var MaxAdd = function (value, amount, max) -{ - return Math.min(value + amount, max); -}; - -module.exports = MaxAdd; - - -/***/ }), -/* 711 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check if a given value is an even number using a strict type check. - * - * @function Phaser.Math.IsEvenStrict - * @since 3.0.0 - * - * @param {number} value - The number to perform the check with. - * - * @return {boolean} Whether the number is even or not. - */ -var IsEvenStrict = function (value) -{ - // Use strict equality === for "is number" test - return (value === parseFloat(value)) ? !(value % 2) : void 0; -}; - -module.exports = IsEvenStrict; - - -/***/ }), -/* 712 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Check if a given value is an even number. - * - * @function Phaser.Math.IsEven - * @since 3.0.0 - * - * @param {number} value - The number to perform the check with. - * - * @return {boolean} Whether the number is even or not. - */ -var IsEven = function (value) -{ - // Use abstract equality == for "is number" test - - // eslint-disable-next-line eqeqeq - return (value == parseFloat(value)) ? !(value % 2) : void 0; -}; - -module.exports = IsEven; - - -/***/ }), -/* 713 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the speed required to cover a distance in the time given. - * - * @function Phaser.Math.GetSpeed - * @since 3.0.0 - * - * @param {number} distance - The distance to travel in pixels. - * @param {integer} time - The time, in ms, to cover the distance in. - * - * @return {number} The amount you will need to increment the position by each step in order to cover the distance in the time given. - */ -var GetSpeed = function (distance, time) -{ - return (distance / time) / 1000; -}; - -module.exports = GetSpeed; - - -/***/ }), -/* 714 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Floors to some place comparative to a `base`, default is 10 for decimal place. - * - * The `place` is represented by the power applied to `base` to get that place. - * - * @function Phaser.Math.FloorTo - * @since 3.0.0 - * - * @param {number} value - The value to round. - * @param {integer} [place=0] - The place to round to. - * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. - * - * @return {number} The rounded value. - */ -var FloorTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.floor(value * p) / p; -}; - -module.exports = FloorTo; - - -/***/ }), -/* 715 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the positive difference of two given numbers. - * - * @function Phaser.Math.Difference - * @since 3.0.0 - * - * @param {number} a - The first number in the calculation. - * @param {number} b - The second number in the calculation. - * - * @return {number} The positive difference of the two given numbers. - */ -var Difference = function (a, b) -{ - return Math.abs(a - b); -}; - -module.exports = Difference; - - -/***/ }), -/* 716 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Ceils to some place comparative to a `base`, default is 10 for decimal place. - * - * The `place` is represented by the power applied to `base` to get that place. - * - * @function Phaser.Math.CeilTo - * @since 3.0.0 - * - * @param {number} value - The value to round. - * @param {number} [place=0] - The place to round to. - * @param {integer} [base=10] - The base to round in. Default is 10 for decimal. - * - * @return {number} The rounded value. - */ -var CeilTo = function (value, place, base) -{ - if (place === undefined) { place = 0; } - if (base === undefined) { base = 10; } - - var p = Math.pow(base, -place); - - return Math.ceil(value * p) / p; -}; - -module.exports = CeilTo; - - -/***/ }), -/* 717 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the mean average of the given values. - * - * @function Phaser.Math.Average - * @since 3.0.0 - * - * @param {number[]} values - The values to average. - * - * @return {number} The average value. - */ -var Average = function (values) -{ - var sum = 0; - - for (var i = 0; i < values.length; i++) - { - sum += (+values[i]); - } - - return sum / values.length; -}; - -module.exports = Average; - - -/***/ }), -/* 718 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Snap a value to nearest grid slice, using rounding. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10` whereas `14` will snap to `15`. - * - * @function Phaser.Math.Snap.To - * @since 3.0.0 - * - * @param {number} value - The value to snap. - * @param {number} gap - The interval gap of the grid. - * @param {number} [start=0] - Optional starting offset for gap. - * - * @return {number} The snapped value. - */ -var SnapTo = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.round(value / gap); - - return start + value; -}; - -module.exports = SnapTo; - - -/***/ }), -/* 719 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Snap a value to nearest grid slice, using floor. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `10`. - * As will `14` snap to `10`... but `16` will snap to `15`. - * - * @function Phaser.Math.Snap.Floor - * @since 3.0.0 - * - * @param {number} value - The value to snap. - * @param {number} gap - The interval gap of the grid. - * @param {number} [start=0] - Optional starting offset for gap. - * - * @return {number} The snapped value. - */ -var SnapFloor = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.floor(value / gap); - - return start + value; -}; - -module.exports = SnapFloor; - - -/***/ }), -/* 720 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Snap a value to nearest grid slice, using ceil. - * - * Example: if you have an interval gap of `5` and a position of `12`... you will snap to `15`. - * As will `14` snap to `15`... but `16` will snap to `20`. - * - * @function Phaser.Math.Snap.Ceil - * @since 3.0.0 - * - * @param {number} value - The value to snap. - * @param {number} gap - The interval gap of the grid. - * @param {number} [start=0] - Optional starting offset for gap. - * - * @return {number} The snapped value. - */ -var SnapCeil = function (value, gap, start) -{ - if (start === undefined) { start = 0; } - - if (gap === 0) - { - return value; - } - - value -= start; - value = gap * Math.ceil(value / gap); - - return start + value; -}; - -module.exports = SnapCeil; - - -/***/ }), -/* 721 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Snap - */ - -module.exports = { - - Ceil: __webpack_require__(720), - Floor: __webpack_require__(719), - To: __webpack_require__(718) - -}; - - -/***/ }), -/* 722 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Tests the value and returns `true` if it is a power of two. - * - * @function Phaser.Math.Pow2.IsValuePowerOfTwo - * @since 3.0.0 - * - * @param {number} value - The value to check if it's a power of two. - * - * @return {boolean} Returns `true` if `value` is a power of two, otherwise `false`. - */ -var IsValuePowerOfTwo = function (value) -{ - return (value > 0 && (value & (value - 1)) === 0); -}; - -module.exports = IsValuePowerOfTwo; - - -/***/ }), -/* 723 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Pow2 - */ - -module.exports = { - - GetNext: __webpack_require__(411), - IsSize: __webpack_require__(85), - IsValue: __webpack_require__(722) - -}; - - -/***/ }), -/* 724 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SmootherStep = __webpack_require__(287); - -/** - * A Smoother Step interpolation method. - * - * @function Phaser.Math.Interpolation.SmootherStep - * @since 3.9.0 - * @see {@link https://en.wikipedia.org/wiki/Smoothstep#Variations} - * - * @param {number} t - The percentage of interpolation, between 0 and 1. - * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - * - * @return {number} The interpolated value. - */ -var SmootherStepInterpolation = function (t, min, max) -{ - return min + (max - min) * SmootherStep(t, 0, 1); -}; - -module.exports = SmootherStepInterpolation; - - -/***/ }), -/* 725 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var SmoothStep = __webpack_require__(286); - -/** - * A Smooth Step interpolation method. - * - * @function Phaser.Math.Interpolation.SmoothStep - * @since 3.9.0 - * @see {@link https://en.wikipedia.org/wiki/Smoothstep} - * - * @param {number} t - The percentage of interpolation, between 0 and 1. - * @param {number} min - The minimum value, also known as the 'left edge', assumed smaller than the 'right edge'. - * @param {number} max - The maximum value, also known as the 'right edge', assumed greater than the 'left edge'. - * - * @return {number} The interpolated value. - */ -var SmoothStepInterpolation = function (t, min, max) -{ - return min + (max - min) * SmoothStep(t, 0, 1); -}; - -module.exports = SmoothStepInterpolation; - - -/***/ }), -/* 726 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Linear = __webpack_require__(122); - -/** - * A linear interpolation method. - * - * @function Phaser.Math.Interpolation.Linear - * @since 3.0.0 - * @see {@link https://en.wikipedia.org/wiki/Linear_interpolation} - * - * @param {number[]} v - The input array of values to interpolate between. - * @param {!number} k - The percentage of interpolation, between 0 and 1. - * - * @return {!number} The interpolated value. - */ -var LinearInterpolation = function (v, k) -{ - var m = v.length - 1; - var f = m * k; - var i = Math.floor(f); - - if (k < 0) - { - return Linear(v[0], v[1], f); - } - - if (k > 1) - { - return Linear(v[m], v[m - 1], m - f); - } - - return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); -}; - -module.exports = LinearInterpolation; - - -/***/ }), -/* 727 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CatmullRom = __webpack_require__(273); - -/** - * A Catmull-Rom interpolation method. - * - * @function Phaser.Math.Interpolation.CatmullRom - * @since 3.0.0 - * - * @param {number[]} v - The input array of values to interpolate between. - * @param {number} k - The percentage of interpolation, between 0 and 1. - * - * @return {number} The interpolated value. - */ -var CatmullRomInterpolation = function (v, k) -{ - var m = v.length - 1; - var f = m * k; - var i = Math.floor(f); - - if (v[0] === v[m]) - { - if (k < 0) - { - i = Math.floor(f = m * (1 + k)); - } - - return CatmullRom(f - i, v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m]); - } - else - { - if (k < 0) - { - return v[0] - (CatmullRom(-f, v[0], v[0], v[1], v[1]) - v[0]); - } - - if (k > 1) - { - return v[m] - (CatmullRom(f - m, v[m], v[m], v[m - 1], v[m - 1]) - v[m]); - } - - return CatmullRom(f - i, v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2]); - } -}; - -module.exports = CatmullRomInterpolation; - - -/***/ }), -/* 728 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Bernstein = __webpack_require__(348); - -/** - * A bezier interpolation method. - * - * @function Phaser.Math.Interpolation.Bezier - * @since 3.0.0 - * - * @param {number[]} v - The input array of values to interpolate between. - * @param {number} k - The percentage of interpolation, between 0 and 1. - * - * @return {number} The interpolated value. - */ -var BezierInterpolation = function (v, k) -{ - var b = 0; - var n = v.length - 1; - - for (var i = 0; i <= n; i++) - { - b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * Bernstein(n, i); - } - - return b; -}; - -module.exports = BezierInterpolation; - - -/***/ }), -/* 729 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Interpolation - */ - -module.exports = { - - Bezier: __webpack_require__(728), - CatmullRom: __webpack_require__(727), - CubicBezier: __webpack_require__(550), - Linear: __webpack_require__(726), - QuadraticBezier: __webpack_require__(546), - SmoothStep: __webpack_require__(725), - SmootherStep: __webpack_require__(724) - -}; - - -/***/ }), -/* 730 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the fuzzy floor of the given value. - * - * @function Phaser.Math.Fuzzy.Floor - * @since 3.0.0 - * - * @param {number} value - The value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {number} The floor of the value. - */ -var Floor = function (value, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.floor(value + epsilon); -}; - -module.exports = Floor; - - -/***/ }), -/* 731 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the fuzzy ceiling of the given value. - * - * @function Phaser.Math.Fuzzy.Ceil - * @since 3.0.0 - * - * @param {number} value - The value. - * @param {float} [epsilon=0.0001] - The epsilon. - * - * @return {number} The fuzzy ceiling of the value. - */ -var Ceil = function (value, epsilon) -{ - if (epsilon === undefined) { epsilon = 0.0001; } - - return Math.ceil(value - epsilon); -}; - -module.exports = Ceil; - - -/***/ }), -/* 732 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Fuzzy - */ - -module.exports = { - - Ceil: __webpack_require__(731), - Equal: __webpack_require__(351), - Floor: __webpack_require__(730), - GreaterThan: __webpack_require__(350), - LessThan: __webpack_require__(349) - -}; - - -/***/ }), -/* 733 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Easing - */ - -module.exports = { - - Back: __webpack_require__(247), - Bounce: __webpack_require__(246), - Circular: __webpack_require__(245), - Cubic: __webpack_require__(244), - Elastic: __webpack_require__(243), - Expo: __webpack_require__(242), - Linear: __webpack_require__(241), - Quadratic: __webpack_require__(240), - Quartic: __webpack_require__(239), - Quintic: __webpack_require__(238), - Sine: __webpack_require__(237), - Stepped: __webpack_require__(236) - -}; - - -/***/ }), -/* 734 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the distance between two sets of coordinates (points), squared. - * - * @function Phaser.Math.Distance.Squared - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the first point. - * @param {number} y1 - The y coordinate of the first point. - * @param {number} x2 - The x coordinate of the second point. - * @param {number} y2 - The y coordinate of the second point. - * - * @return {number} The distance between each point, squared. - */ -var DistanceSquared = function (x1, y1, x2, y2) -{ - var dx = x1 - x2; - var dy = y1 - y2; - - return dx * dx + dy * dy; -}; - -module.exports = DistanceSquared; - - -/***/ }), -/* 735 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculate the distance between two sets of coordinates (points) to the power of `pow`. - * - * @function Phaser.Math.Distance.Power - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the first point. - * @param {number} y1 - The y coordinate of the first point. - * @param {number} x2 - The x coordinate of the second point. - * @param {number} y2 - The y coordinate of the second point. - * @param {number} pow - The exponent. - * - * @return {number} The distance between each point. - */ -var DistancePower = function (x1, y1, x2, y2, pow) -{ - if (pow === undefined) { pow = 2; } - - return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow)); -}; - -module.exports = DistancePower; - - -/***/ }), -/* 736 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Distance - */ - -module.exports = { - - Between: __webpack_require__(58), - Power: __webpack_require__(735), - Squared: __webpack_require__(734) - -}; - - -/***/ }), -/* 737 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Gets the shortest angle between `angle1` and `angle2`. - * - * Both angles must be in the range -180 to 180, which is the same clamped - * range that `sprite.angle` uses, so you can pass in two sprite angles to - * this method and get the shortest angle back between the two of them. - * - * The angle returned will be in the same range. If the returned angle is - * greater than 0 then it's a counter-clockwise rotation, if < 0 then it's - * a clockwise rotation. - * - * TODO: Wrap the angles in this function? - * - * @function Phaser.Math.Angle.ShortestBetween - * @since 3.0.0 - * - * @param {number} angle1 - The first angle in the range -180 to 180. - * @param {number} angle2 - The second angle in the range -180 to 180. - * - * @return {number} The shortest angle, in degrees. If greater than zero it's a counter-clockwise rotation. - */ -var ShortestBetween = function (angle1, angle2) -{ - var difference = angle2 - angle1; - - if (difference === 0) - { - return 0; - } - - var times = Math.floor((difference - (-180)) / 360); - - return difference - (times * 360); - -}; - -module.exports = ShortestBetween; - - -/***/ }), -/* 738 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); - -/** - * Rotates `currentAngle` towards `targetAngle`, taking the shortest rotation distance. The `lerp` argument is the amount to rotate by in this call. - * - * @function Phaser.Math.Angle.RotateTo - * @since 3.0.0 - * - * @param {number} currentAngle - The current angle, in radians. - * @param {number} targetAngle - The target angle to rotate to, in radians. - * @param {number} [lerp=0.05] - The lerp value to add to the current angle. - * - * @return {number} The adjusted angle. - */ -var RotateTo = function (currentAngle, targetAngle, lerp) -{ - if (lerp === undefined) { lerp = 0.05; } - - if (currentAngle === targetAngle) - { - return currentAngle; - } - - if (Math.abs(targetAngle - currentAngle) <= lerp || Math.abs(targetAngle - currentAngle) >= (MATH_CONST.PI2 - lerp)) - { - currentAngle = targetAngle; - } - else - { - if (Math.abs(targetAngle - currentAngle) > Math.PI) - { - if (targetAngle < currentAngle) - { - targetAngle += MATH_CONST.PI2; - } - else - { - targetAngle -= MATH_CONST.PI2; - } - } - - if (targetAngle > currentAngle) - { - currentAngle += lerp; - } - else if (targetAngle < currentAngle) - { - currentAngle -= lerp; - } - } - - return currentAngle; -}; - -module.exports = RotateTo; - - -/***/ }), -/* 739 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Normalize = __webpack_require__(352); - -/** - * Reverse the given angle. - * - * @function Phaser.Math.Angle.Reverse - * @since 3.0.0 - * - * @param {number} angle - The angle to reverse, in radians. - * - * @return {number} The reversed angle, in radians. - */ -var Reverse = function (angle) -{ - return Normalize(angle + Math.PI); -}; - -module.exports = Reverse; - - -/***/ }), -/* 740 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). - * - * The difference between this method and {@link Phaser.Math.Angle.BetweenPoints} is that this assumes the y coordinate - * travels down the screen. - * - * @function Phaser.Math.Angle.BetweenPointsY - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|object)} point1 - The first point. - * @param {(Phaser.Geom.Point|object)} point2 - The second point. - * - * @return {number} The angle in radians. - */ -var BetweenPointsY = function (point1, point2) -{ - return Math.atan2(point2.x - point1.x, point2.y - point1.y); -}; - -module.exports = BetweenPointsY; - - -/***/ }), -/* 741 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y). - * - * Calculates the angle of the vector from the first point to the second point. - * - * @function Phaser.Math.Angle.BetweenPoints - * @since 3.0.0 - * - * @param {(Phaser.Geom.Point|object)} point1 - The first point. - * @param {(Phaser.Geom.Point|object)} point2 - The second point. - * - * @return {number} The angle in radians. - */ -var BetweenPoints = function (point1, point2) -{ - return Math.atan2(point2.y - point1.y, point2.x - point1.x); -}; - -module.exports = BetweenPoints; - - -/***/ }), -/* 742 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Find the angle of a segment from (x1, y1) -> (x2, y2). - * - * The difference between this method and {@link Phaser.Math.Angle.Between} is that this assumes the y coordinate - * travels down the screen. - * - * @function Phaser.Math.Angle.BetweenY - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the first point. - * @param {number} y1 - The y coordinate of the first point. - * @param {number} x2 - The x coordinate of the second point. - * @param {number} y2 - The y coordinate of the second point. - * - * @return {number} The angle in radians. - */ -var BetweenY = function (x1, y1, x2, y2) -{ - return Math.atan2(x2 - x1, y2 - y1); -}; - -module.exports = BetweenY; - - -/***/ }), -/* 743 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Find the angle of a segment from (x1, y1) -> (x2, y2). - * - * @function Phaser.Math.Angle.Between - * @since 3.0.0 - * - * @param {number} x1 - The x coordinate of the first point. - * @param {number} y1 - The y coordinate of the first point. - * @param {number} x2 - The x coordinate of the second point. - * @param {number} y2 - The y coordinate of the second point. - * - * @return {number} The angle in radians. - */ -var Between = function (x1, y1, x2, y2) -{ - return Math.atan2(y2 - y1, x2 - x1); -}; - -module.exports = Between; - - -/***/ }), -/* 744 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Math.Angle - */ - -module.exports = { - - Between: __webpack_require__(743), - BetweenY: __webpack_require__(742), - BetweenPoints: __webpack_require__(741), - BetweenPointsY: __webpack_require__(740), - Reverse: __webpack_require__(739), - RotateTo: __webpack_require__(738), - ShortestBetween: __webpack_require__(737), - Normalize: __webpack_require__(352), - Wrap: __webpack_require__(212), - WrapDegrees: __webpack_require__(211) - -}; - - -/***/ }), -/* 745 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(16); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser.Math - */ - -var PhaserMath = { - - // Collections of functions - Angle: __webpack_require__(744), - Distance: __webpack_require__(736), - Easing: __webpack_require__(733), - Fuzzy: __webpack_require__(732), - Interpolation: __webpack_require__(729), - Pow2: __webpack_require__(723), - Snap: __webpack_require__(721), - - // Expose the RNG Class - RandomDataGenerator: __webpack_require__(297), - - // Single functions - Average: __webpack_require__(717), - Bernstein: __webpack_require__(348), - Between: __webpack_require__(149), - CatmullRom: __webpack_require__(273), - CeilTo: __webpack_require__(716), - Clamp: __webpack_require__(23), - DegToRad: __webpack_require__(38), - Difference: __webpack_require__(715), - Factorial: __webpack_require__(347), - FloatBetween: __webpack_require__(248), - FloorTo: __webpack_require__(714), - FromPercent: __webpack_require__(65), - GetSpeed: __webpack_require__(713), - IsEven: __webpack_require__(712), - IsEvenStrict: __webpack_require__(711), - Linear: __webpack_require__(122), - MaxAdd: __webpack_require__(710), - MinSub: __webpack_require__(709), - Percent: __webpack_require__(708), - RadToDeg: __webpack_require__(150), - RandomXY: __webpack_require__(707), - RandomXYZ: __webpack_require__(561), - RandomXYZW: __webpack_require__(560), - Rotate: __webpack_require__(346), - RotateAround: __webpack_require__(292), - RotateAroundDistance: __webpack_require__(288), - RoundAwayFromZero: __webpack_require__(255), - RoundTo: __webpack_require__(706), - SinCosTableGenerator: __webpack_require__(705), - SmootherStep: __webpack_require__(287), - SmoothStep: __webpack_require__(286), - TransformXY: __webpack_require__(257), - Within: __webpack_require__(704), - Wrap: __webpack_require__(39), - - // Vector classes - Vector2: __webpack_require__(6), - Vector3: __webpack_require__(87), - Vector4: __webpack_require__(277), - Matrix3: __webpack_require__(557), - Matrix4: __webpack_require__(278), - Quaternion: __webpack_require__(558), - RotateVec3: __webpack_require__(559) - -}; - -// Merge in the consts - -PhaserMath = Extend(false, PhaserMath, CONST); - -// Export it - -module.exports = PhaserMath; - - -/***/ }), -/* 746 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); -var IsPlainObject = __webpack_require__(8); -var MultiFile = __webpack_require__(36); -var TextFile = __webpack_require__(224); - -/** - * @typedef {object} Phaser.Loader.FileTypes.UnityAtlasFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. - * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. - * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. - * @property {string} [atlasURL] - The absolute or relative URL to load the atlas data file from. - * @property {string} [atlasExtension='txt'] - The default file extension to use for the atlas data if no url is provided. - * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas data file. - */ - -/** - * @classdesc - * A single text file based Unity Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#unityAtlas method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#unityAtlas. - * - * @class UnityAtlasFile - * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes - * @constructor - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. - */ -var UnityAtlasFile = new Class({ - - Extends: MultiFile, - - initialize: - - function UnityAtlasFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) - { - var image; - var data; - - if (IsPlainObject(key)) - { - var config = key; - - image = new ImageFile(loader, { - key: key, - url: GetFastValue(config, 'textureURL'), - extension: GetFastValue(config, 'textureExtension', 'png'), - normalMap: GetFastValue(config, 'normalMap'), - xhrSettings: GetFastValue(config, 'textureXhrSettings') - }); - - data = new TextFile(loader, { - key: key, - url: GetFastValue(config, 'atlasURL'), - extension: GetFastValue(config, 'atlasExtension', 'txt'), - xhrSettings: GetFastValue(config, 'atlasXhrSettings') - }); - } - else - { - image = new ImageFile(loader, key, textureURL, textureXhrSettings); - data = new TextFile(loader, key, atlasURL, atlasXhrSettings); - } - - if (image.linkFile) - { - // Image has a normal map - MultiFile.call(this, loader, 'unityatlas', key, [ image, data, image.linkFile ]); - } - else - { - MultiFile.call(this, loader, 'unityatlas', key, [ image, data ]); - } - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.UnityAtlasFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.failed === 0 && !this.complete) - { - var image = this.files[0]; - var text = this.files[1]; - var normalMap = (this.files[2]) ? this.files[2].data : null; - - this.loader.textureManager.addUnityAtlas(image.key, image.data, text.data, normalMap); - - text.addToCache(); - - this.complete = true; - } - } - -}); - -/** - * Adds a Unity YAML based Texture Atlas, or array of atlases, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.unityAtlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * atlasURL: 'images/MainMenu.txt' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.UnityAtlasFileConfig` for more details. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); - * // and later in your game ... - * this.add.image(x, y, 'mainmenu', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.unityAtlas({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * normalMap: 'images/MainMenu-n.png', - * atlasURL: 'images/MainMenu.txt' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Unity Atlas File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#unityAtlas - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig|Phaser.Loader.FileTypes.UnityAtlasFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('unityAtlas', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) -{ - var multifile; - - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - multifile = new UnityAtlasFile(this, key[i]); - - this.addFile(multifile.files); - } - } - else - { - multifile = new UnityAtlasFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); - - this.addFile(multifile.files); - } - - return this; -}); - -module.exports = UnityAtlasFile; - - -/***/ }), -/* 747 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(28); -var TILEMAP_FORMATS = __webpack_require__(26); - -/** - * @typedef {object} Phaser.Loader.FileTypes.TilemapJSONFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='json'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Tiled Tilemap JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. - * - * @class TilemapJSONFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var TilemapJSONFile = new Class({ - - Extends: JSONFile, - - initialize: - - function TilemapJSONFile (loader, key, url, xhrSettings) - { - JSONFile.call(this, loader, key, url, xhrSettings); - - this.type = 'tilemapJSON'; - - this.cache = loader.cacheManager.tilemap; - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.TilemapJSONFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var tiledata = { format: TILEMAP_FORMATS.TILED_JSON, data: this.data }; - - this.cache.add(this.key, tiledata); - - this.pendingDestroy(tiledata); - } - -}); - -/** - * Adds a Tiled JSON Tilemap file, or array of map files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.tilemapTiledJSON('level1', maps/Level1.json'); - * } - * ``` - * - * The Tilemap data is created using the Tiled Map Editor and selecting JSON as the export format. - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.tilemapTiledJSON({ - * key: 'level1', - * url: 'maps/Level1.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TilemapJSONFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); - * // and later in your game ... - * var map = this.make.tilemap({ key: 'level1' }); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Tilemap Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" - * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Tilemap JSON File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#tilemapTiledJSON - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.TilemapJSONFileConfig|Phaser.Loader.FileTypes.TilemapJSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('tilemapTiledJSON', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TilemapJSONFile(this, key[i])); - } - } - else - { - this.addFile(new TilemapJSONFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = TilemapJSONFile; - - -/***/ }), -/* 748 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(28); -var TILEMAP_FORMATS = __webpack_require__(26); - -/** - * @typedef {object} Phaser.Loader.FileTypes.TilemapImpactFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='json'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Impact.js Tilemap JSON File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. - * - * @class TilemapImpactFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var TilemapImpactFile = new Class({ - - Extends: JSONFile, - - initialize: - - function TilemapImpactFile (loader, key, url, xhrSettings) - { - JSONFile.call(this, loader, key, url, xhrSettings); - - this.type = 'tilemapJSON'; - - this.cache = loader.cacheManager.tilemap; - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.TilemapImpactFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var tiledata = { format: TILEMAP_FORMATS.WELTMEISTER, data: this.data }; - - this.cache.add(this.key, tiledata); - - this.pendingDestroy(tiledata); - } - -}); - -/** - * Adds an Impact.js Tilemap file, or array of map files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.tilemapImpact('level1', maps/Level1.json'); - * } - * ``` - * - * Impact Tilemap data is created the Impact.js Map Editor called Weltmeister. - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.tilemapImpact({ - * key: 'level1', - * url: 'maps/Level1.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TilemapImpactFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.tilemapImpact('level1', 'maps/Level1.json'); - * // and later in your game ... - * var map = this.make.tilemap({ key: 'level1' }); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Tilemap Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" - * and no URL is given then the Loader will set the URL to be "level.json". It will always add `.json` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Tilemap Impact File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#tilemapImpact - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.7.0 - * - * @param {(string|Phaser.Loader.FileTypes.TilemapImpactFileConfig|Phaser.Loader.FileTypes.TilemapImpactFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('tilemapImpact', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TilemapImpactFile(this, key[i])); - } - } - else - { - this.addFile(new TilemapImpactFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = TilemapImpactFile; - - -/***/ }), -/* 749 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); -var TILEMAP_FORMATS = __webpack_require__(26); - -/** - * @typedef {object} Phaser.Loader.FileTypes.TilemapCSVFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Tilemap Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='csv'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Tilemap CSV File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. - * - * @class TilemapCSVFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var TilemapCSVFile = new Class({ - - Extends: File, - - initialize: - - function TilemapCSVFile (loader, key, url, xhrSettings) - { - var extension = 'csv'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'tilemapCSV', - cache: loader.cacheManager.tilemap, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - - this.tilemapFormat = TILEMAP_FORMATS.CSV; - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.TilemapCSVFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onProcessComplete(); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.TilemapCSVFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var tiledata = { format: this.tilemapFormat, data: this.data }; - - this.cache.add(this.key, tiledata); - - this.pendingDestroy(tiledata); - } - -}); - -/** - * Adds a CSV Tilemap file, or array of CSV files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.tilemapCSV('level1', maps/Level1.csv'); - * } - * ``` - * - * Tilemap CSV data can be created in a text editor, or a 3rd party app that exports as CSV. - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Text Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.tilemapCSV({ - * key: 'level1', - * url: 'maps/Level1.csv' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.TilemapCSVFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.tilemapCSV('level1', 'maps/Level1.csv'); - * // and later in your game ... - * var map = this.make.tilemap({ key: 'level1' }); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and - * this is what you would use to retrieve the text from the Tilemap Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "level" - * and no URL is given then the Loader will set the URL to be "level.csv". It will always add `.csv` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Tilemap CSV File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#tilemapCSV - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.TilemapCSVFileConfig|Phaser.Loader.FileTypes.TilemapCSVFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.csv`, i.e. if `key` was "alien" then the URL will be "alien.csv". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('tilemapCSV', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new TilemapCSVFile(this, key[i])); - } - } - else - { - this.addFile(new TilemapCSVFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = TilemapCSVFile; - - -/***/ }), -/* 750 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.SVGFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='svg'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single SVG File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. - * - * @class SVGFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var SVGFile = new Class({ - - Extends: File, - - initialize: - - function SVGFile (loader, key, url, xhrSettings) - { - var extension = 'svg'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'svg', - cache: loader.textureManager, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.SVGFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - var svg = [ this.xhrLoader.responseText ]; - - try - { - var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); - } - catch (e) - { - this.onProcessError(); - - return; - } - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - var _this = this; - var retry = false; - - this.data.onload = function () - { - if (!retry) - { - File.revokeObjectURL(_this.data); - } - - _this.onProcessComplete(); - }; - - this.data.onerror = function () - { - // Safari 8 re-try - if (!retry) - { - retry = true; - - File.revokeObjectURL(_this.data); - - _this.data.src = 'data:image/svg+xml,' + encodeURIComponent(svg.join('')); - } - else - { - _this.onProcessError(); - } - }; - - File.createObjectURL(this.data, blob, 'image/svg+xml'); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.SVGFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var texture = this.cache.addImage(this.key, this.data); - - this.pendingDestroy(texture); - } - -}); - -/** - * Adds an SVG File, or array of SVG Files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.svg('morty', 'images/Morty.svg'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.svg({ - * key: 'morty', - * url: 'images/Morty.svg' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.SVGFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.svg('morty', 'images/Morty.svg'); - * // and later in your game ... - * this.add.image(x, y, 'morty'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#svg - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig|Phaser.Loader.FileTypes.SVGFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('svg', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new SVGFile(this, key[i])); - } - } - else - { - this.addFile(new SVGFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = SVGFile; - - -/***/ }), -/* 751 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.ScenePluginFileConfig - * - * @property {string} key - The key of the file. Must be unique within the Loader. - * @property {(string|function)} [url] - The absolute or relative URL to load the file from. Or, a Scene Plugin. - * @property {string} [extension='js'] - The default file extension to use if no url is provided. - * @property {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. - * @property {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single Scene Plugin Script File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#scenePlugin method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#scenePlugin. - * - * @class ScenePluginFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.8.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". - * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. - * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var ScenePluginFile = new Class({ - - Extends: File, - - initialize: - - function ScenePluginFile (loader, key, url, systemKey, sceneKey, xhrSettings) - { - var extension = 'js'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - systemKey = GetFastValue(config, 'systemKey'); - sceneKey = GetFastValue(config, 'sceneKey'); - } - - var fileConfig = { - type: 'scenePlugin', - cache: false, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings, - config: { - systemKey: systemKey, - sceneKey: sceneKey - } - }; - - File.call(this, loader, fileConfig); - - // If the url variable refers to a class, add the plugin directly - if (typeof url === 'function') - { - this.data = url; - - this.state = CONST.FILE_POPULATED; - } - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.ScenePluginFile#onProcess - * @since 3.8.0 - */ - onProcess: function () - { - var pluginManager = this.loader.systems.plugins; - var config = this.config; - - var key = this.key; - var systemKey = GetFastValue(config, 'systemKey', key); - var sceneKey = GetFastValue(config, 'sceneKey', key); - - if (this.state === CONST.FILE_POPULATED) - { - pluginManager.installScenePlugin(systemKey, this.data, sceneKey, this.loader.scene); - } - else - { - // Plugin added via a js file - this.state = CONST.FILE_PROCESSING; - - this.data = document.createElement('script'); - this.data.language = 'javascript'; - this.data.type = 'text/javascript'; - this.data.defer = false; - this.data.text = this.xhrLoader.responseText; - - document.head.appendChild(this.data); - - pluginManager.installScenePlugin(systemKey, window[this.key], sceneKey, this.loader.scene); - } - - this.onProcessComplete(); - } - -}); - -/** - * Adds a Scene Plugin Script file, or array of plugin files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.scenePlugin('ModPlayer', 'plugins/ModPlayer.js', 'modPlayer', 'mods'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String and not already in-use by another file in the Loader. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.scenePlugin({ - * key: 'modplayer', - * url: 'plugins/ModPlayer.js' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.ScenePluginFileConfig` for more details. - * - * Once the file has finished loading it will automatically be converted into a script element - * via `document.createElement('script')`. It will have its language set to JavaScript, `defer` set to - * false and then the resulting element will be appended to `document.head`. Any code then in the - * script will be executed. It will then be passed to the Phaser PluginCache.register method. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.js". It will always add `.js` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Script File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#scenePlugin - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.8.0 - * - * @param {(string|Phaser.Loader.FileTypes.ScenePluginFileConfig|Phaser.Loader.FileTypes.ScenePluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {(string|function)} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, set to a plugin function. - * @param {string} [systemKey] - If this plugin is to be added to Scene.Systems, this is the property key for it. - * @param {string} [sceneKey] - If this plugin is to be added to the Scene, this is the property key for it. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('scenePlugin', function (key, url, systemKey, sceneKey, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new ScenePluginFile(this, key[i])); - } - } - else - { - this.addFile(new ScenePluginFile(this, key, url, systemKey, sceneKey, xhrSettings)); - } - - return this; -}); - -module.exports = ScenePluginFile; - - -/***/ }), -/* 752 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var FileTypesManager = __webpack_require__(7); -var JSONFile = __webpack_require__(28); - -/** - * @typedef {object} Phaser.Loader.FileTypes.PackFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the JSON Cache. - * @property {string|any} [url] - The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly processed. - * @property {string} [extension='json'] - The default file extension to use if no url is provided. - * @property {string} [dataKey] - If specified instead of the whole JSON file being parsed, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single JSON Pack File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#pack method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#pack. - * - * @class PackFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.7.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. - */ -var PackFile = new Class({ - - Extends: JSONFile, - - initialize: - - // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object - // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing - - function PackFile (loader, key, url, xhrSettings, dataKey) - { - JSONFile.call(this, loader, key, url, xhrSettings, dataKey); - - this.type = 'packfile'; - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.PackFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - if (this.state !== CONST.FILE_POPULATED) - { - this.state = CONST.FILE_PROCESSING; - - this.data = JSON.parse(this.xhrLoader.responseText); - } - - // Let's pass the pack file data over to the Loader ... - this.loader.addPack(this.data, this.config); - - this.onProcessComplete(); - } - -}); - -/** - * Adds a JSON File Pack, or array of packs, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.pack('level1', 'data/Level1Files.json'); - * } - * ``` - * - * A File Pack is a JSON file (or object) that contains details about other files that should be added into the Loader. - * Here is a small example: - * - * ```json - * { - * "test1": { - * "files": [ - * { - * "type": "image", - * "key": "taikodrummaster", - * "url": "assets/pics/taikodrummaster.jpg" - * }, - * { - * "type": "image", - * "key": "sukasuka-chtholly", - * "url": "assets/pics/sukasuka-chtholly.png" - * } - * ] - * }, - * "meta": { - * "generated": "1401380327373", - * "app": "Phaser 3 Asset Packer", - * "url": "https://phaser.io", - * "version": "1.0", - * "copyright": "Photon Storm Ltd. 2018" - * } - * } - * ``` - * - * The pack can be split into sections. In the example above you'll see a section called `test1. You can tell - * the `load.pack` method to parse only a particular section of a pack. The pack is stored in the JSON Cache, - * so you can pass it to the Loader to process additional sections as needed in your game, or you can just load - * them all at once without specifying anything. - * - * The pack file can contain an entry for any type of file that Phaser can load. The object structures exactly - * match that of the file type configs, and all properties available within the file type configs can be used - * in the pack file too. - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the JSON Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.pack({ - * key: 'level1', - * url: 'data/Level1Files.json' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.PackFileConfig` for more details. - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and - * this is what you would use to retrieve the text from the JSON Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" - * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, - * rather than the whole file. For example, if your JSON data had a structure like this: - * - * ```json - * { - * "level1": { - * "baddies": { - * "aliens": {}, - * "boss": {} - * } - * }, - * "level2": {}, - * "level3": {} - * } - * ``` - * - * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. - * - * Note: The ability to load this type of file will only be available if the Pack File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#pack - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.7.0 - * - * @param {(string|Phaser.Loader.FileTypes.PackFileConfig|Phaser.Loader.FileTypes.PackFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". - * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('pack', function (key, url, packKey, xhrSettings) -{ - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - this.addFile(new PackFile(this, key[i])); - } - } - else - { - this.addFile(new PackFile(this, key, url, xhrSettings, packKey)); - } - - return this; -}); - -module.exports = PackFile; - - -/***/ }), -/* 753 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.HTMLFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='html'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @property {integer} [width=512] - The width of the texture the HTML will be rendered to. - * @property {integer} [height=512] - The height of the texture the HTML will be rendered to. - */ - -/** - * @classdesc - * A single HTML File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. - * - * @class HTMLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {integer} [width] - The width of the texture the HTML will be rendered to. - * @param {integer} [height] - The height of the texture the HTML will be rendered to. - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var HTMLFile = new Class({ - - Extends: File, - - initialize: - - function HTMLFile (loader, key, url, width, height, xhrSettings) - { - if (width === undefined) { width = 512; } - if (height === undefined) { height = 512; } - - var extension = 'html'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - width = GetFastValue(config, 'width', width); - height = GetFastValue(config, 'height', height); - } - - var fileConfig = { - type: 'html', - cache: loader.textureManager, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings, - config: { - width: width, - height: height - } - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.HTMLFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - var w = this.config.width; - var h = this.config.height; - - var data = []; - - data.push(''); - data.push(''); - data.push(''); - data.push(this.xhrLoader.responseText); - data.push(''); - data.push(''); - data.push(''); - - var svg = [ data.join('\n') ]; - var _this = this; - - try - { - var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); - } - catch (e) - { - _this.state = CONST.FILE_ERRORED; - - _this.onProcessComplete(); - - return; - } - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessComplete(); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessError(); - }; - - File.createObjectURL(this.data, blob, 'image/svg+xml'); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.HTMLFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var texture = this.cache.addImage(this.key, this.data); - - this.pendingDestroy(texture); - } - -}); - -/** - * Adds an HTML File, or array of HTML Files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.html('instructions', 'content/intro.html', 256, 512); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.html({ - * key: 'instructions', - * url: 'content/intro.html', - * width: 256, - * height: 512 - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. - * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * - * ```javascript - * this.load.html('instructions', 'content/intro.html', 256, 512); - * // and later in your game ... - * this.add.image(x, y, 'instructions'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * The width and height are the size of the texture to which the HTML will be rendered. It's not possible to determine these - * automatically, so you will need to provide them, either as arguments or in the file config object. - * When the HTML file has loaded a new SVG element is created with a size and viewbox set to the width and height given. - * The SVG file has a body tag added to it, with the HTML file contents included. It then calls `window.Blob` on the SVG, - * and if successful is added to the Texture Manager, otherwise it fails processing. The overall quality of the rendered - * HTML depends on your browser, and some of them may not even support the svg / blob process used. Be aware that there are - * limitations on what HTML can be inside an SVG. You can find out more details in this - * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). - * - * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#html - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {integer} [width=512] - The width of the texture the HTML will be rendered to. - * @param {integer} [height=512] - The height of the texture the HTML will be rendered to. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('html', function (key, url, width, height, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new HTMLFile(this, key[i])); - } - } - else - { - this.addFile(new HTMLFile(this, key, url, width, height, xhrSettings)); - } - - return this; -}); - -module.exports = HTMLFile; - - -/***/ }), -/* 754 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.GLSLFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='glsl'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ - -/** - * @classdesc - * A single GLSL File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl. - * - * @class GLSLFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - */ -var GLSLFile = new Class({ - - Extends: File, - - initialize: - - function GLSLFile (loader, key, url, xhrSettings) - { - var extension = 'glsl'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - } - - var fileConfig = { - type: 'glsl', - cache: loader.cacheManager.shader, - extension: extension, - responseType: 'text', - key: key, - url: url, - xhrSettings: xhrSettings - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.GLSLFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - this.data = this.xhrLoader.responseText; - - this.onProcessComplete(); - } - -}); - -/** - * Adds a GLSL file, or array of GLSL files, to the current load queue. - * In Phaser 3 GLSL files are just plain Text files at the current moment in time. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.glsl('plasma', 'shaders/Plasma.glsl'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Shader Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Shader Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Shader Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.glsl({ - * key: 'plasma', - * url: 'shaders/Plasma.glsl' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.GLSLFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.glsl('plasma', 'shaders/Plasma.glsl'); - * // and later in your game ... - * var data = this.cache.shader.get('plasma'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `FX.` and the key was `Plasma` the final key will be `FX.Plasma` and - * this is what you would use to retrieve the text from the Shader Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "plasma" - * and no URL is given then the Loader will set the URL to be "plasma.glsl". It will always add `.glsl` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the GLSL File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#glsl - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.GLSLFileConfig|Phaser.Loader.FileTypes.GLSLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.glsl`, i.e. if `key` was "alien" then the URL will be "alien.glsl". - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('glsl', function (key, url, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new GLSLFile(this, key[i])); - } - } - else - { - this.addFile(new GLSLFile(this, key, url, xhrSettings)); - } - - return this; -}); - -module.exports = GLSLFile; - - -/***/ }), -/* 755 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); -var IsPlainObject = __webpack_require__(8); -var MultiFile = __webpack_require__(36); -var ParseXMLBitmapFont = __webpack_require__(474); -var XMLFile = __webpack_require__(143); - -/** - * @typedef {object} Phaser.Loader.FileTypes.BitmapFontFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. - * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. - * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. - * @property {string} [fontDataURL] - The absolute or relative URL to load the font data xml file from. - * @property {string} [fontDataExtension='xml'] - The default file extension to use for the font data xml if no url is provided. - * @property {XHRSettingsObject} [fontDataXhrSettings] - Extra XHR Settings specifically for the font data xml file. - */ - -/** - * @classdesc - * A single Bitmap Font based File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#bitmapFont method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#bitmapFont. - * - * @class BitmapFontFile - * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. - */ -var BitmapFontFile = new Class({ - - Extends: MultiFile, - - initialize: - - function BitmapFontFile (loader, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) - { - var image; - var data; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - - image = new ImageFile(loader, { - key: key, - url: GetFastValue(config, 'textureURL'), - extension: GetFastValue(config, 'textureExtension', 'png'), - normalMap: GetFastValue(config, 'normalMap'), - xhrSettings: GetFastValue(config, 'textureXhrSettings') - }); - - data = new XMLFile(loader, { - key: key, - url: GetFastValue(config, 'fontDataURL'), - extension: GetFastValue(config, 'fontDataExtension', 'xml'), - xhrSettings: GetFastValue(config, 'fontDataXhrSettings') - }); - } - else - { - image = new ImageFile(loader, key, textureURL, textureXhrSettings); - data = new XMLFile(loader, key, fontDataURL, fontDataXhrSettings); - } - - if (image.linkFile) - { - // Image has a normal map - MultiFile.call(this, loader, 'bitmapfont', key, [ image, data, image.linkFile ]); - } - else - { - MultiFile.call(this, loader, 'bitmapfont', key, [ image, data ]); - } - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.BitmapFontFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.isReadyToProcess()) - { - var image = this.files[0]; - var xml = this.files[1]; - - image.addToCache(); - xml.addToCache(); - - this.loader.cacheManager.bitmapFont.add(image.key, { data: ParseXMLBitmapFont(xml.data), texture: image.key, frame: null }); - - this.complete = true; - } - } - -}); - -/** - * Adds an XML based Bitmap Font, or array of fonts, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - - * ```javascript - * function preload () - * { - * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the font data to be provided in an XML file format. - * These files are created by software such as the [Angelcode Bitmap Font Generator](http://www.angelcode.com/products/bmfont/), - * [Littera](http://kvazars.com/littera/) or [Glyph Designer](https://71squared.com/glyphdesigner) - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.bitmapFont({ - * key: 'goldenFont', - * textureURL: 'images/GoldFont.png', - * fontDataURL: 'images/GoldFont.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.BitmapFontFileConfig` for more details. - * - * Once the atlas has finished loading you can use key of it when creating a Bitmap Text Game Object: - * - * ```javascript - * this.load.bitmapFont('goldenFont', 'images/GoldFont.png', 'images/GoldFont.xml'); - * // and later in your game ... - * this.add.bitmapText(x, y, 'goldenFont', 'Hello World'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use when creating a Bitmap Text object. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.bitmapFont('goldenFont', [ 'images/GoldFont.png', 'images/GoldFont-n.png' ], 'images/GoldFont.xml'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.bitmapFont({ - * key: 'goldenFont', - * textureURL: 'images/GoldFont.png', - * normalMap: 'images/GoldFont-n.png', - * fontDataURL: 'images/GoldFont.xml' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Bitmap Font File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#bitmapFont - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.BitmapFontFileConfig|Phaser.Loader.FileTypes.BitmapFontFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the font image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [fontDataURL] - The absolute or relative URL to load the font xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the font image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [fontDataXhrSettings] - An XHR Settings configuration object for the font data xml file. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('bitmapFont', function (key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings) -{ - var multifile; - - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - multifile = new BitmapFontFile(this, key[i]); - - this.addFile(multifile.files); - } - } - else - { - multifile = new BitmapFontFile(this, key, textureURL, fontDataURL, textureXhrSettings, fontDataXhrSettings); - - this.addFile(multifile.files); - } - - return this; -}); - -module.exports = BitmapFontFile; - - -/***/ }), -/* 756 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var CONST = __webpack_require__(18); -var File = __webpack_require__(19); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var IsPlainObject = __webpack_require__(8); - -/** - * @typedef {object} Phaser.Loader.FileTypes.BinaryFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Binary Cache. - * @property {string} [url] - The absolute or relative URL to load the file from. - * @property {string} [extension='bin'] - The default file extension to use if no url is provided. - * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @property {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. - */ - -/** - * @classdesc - * A single Binary File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#binary method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#binary. - * - * @class BinaryFile - * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". - * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. - */ -var BinaryFile = new Class({ - - Extends: File, - - initialize: - - function BinaryFile (loader, key, url, xhrSettings, dataType) - { - var extension = 'bin'; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - url = GetFastValue(config, 'url'); - xhrSettings = GetFastValue(config, 'xhrSettings'); - extension = GetFastValue(config, 'extension', extension); - dataType = GetFastValue(config, 'dataType', dataType); - } - - var fileConfig = { - type: 'binary', - cache: loader.cacheManager.binary, - extension: extension, - responseType: 'arraybuffer', - key: key, - url: url, - xhrSettings: xhrSettings, - config: { dataType: dataType } - }; - - File.call(this, loader, fileConfig); - }, - - /** - * Called automatically by Loader.nextFile. - * This method controls what extra work this File does with its loaded data. - * - * @method Phaser.Loader.FileTypes.BinaryFile#onProcess - * @since 3.7.0 - */ - onProcess: function () - { - this.state = CONST.FILE_PROCESSING; - - var ctor = this.config.dataType; - - this.data = (ctor) ? new ctor(this.xhrLoader.response) : this.xhrLoader.response; - - this.onProcessComplete(); - } - -}); - -/** - * Adds a Binary file, or array of Binary files, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.binary('doom', 'files/Doom.wad'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * The key must be a unique String. It is used to add the file to the global Binary Cache upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Binary Cache. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Binary Cache first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.binary({ - * key: 'doom', - * url: 'files/Doom.wad', - * dataType: Uint8Array - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.BinaryFileConfig` for more details. - * - * Once the file has finished loading you can access it from its Cache using its key: - * - * ```javascript - * this.load.binary('doom', 'files/Doom.wad'); - * // and later in your game ... - * var data = this.cache.binary.get('doom'); - * ``` - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `LEVEL1.` and the key was `Data` the final key will be `LEVEL1.Data` and - * this is what you would use to retrieve the text from the Binary Cache. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "doom" - * and no URL is given then the Loader will set the URL to be "doom.bin". It will always add `.bin` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Note: The ability to load this type of file will only be available if the Binary File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#binary - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 - * - * @param {(string|Phaser.Loader.FileTypes.BinaryFileConfig|Phaser.Loader.FileTypes.BinaryFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.bin`, i.e. if `key` was "alien" then the URL will be "alien.bin". - * @param {any} [dataType] - Optional type to cast the binary file to once loaded. For example, `Uint8Array`. - * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('binary', function (key, url, dataType, xhrSettings) -{ - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object - this.addFile(new BinaryFile(this, key[i])); - } - } - else - { - this.addFile(new BinaryFile(this, key, url, xhrSettings, dataType)); - } - - return this; -}); - -module.exports = BinaryFile; - - -/***/ }), -/* 757 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FileTypesManager = __webpack_require__(7); -var GetFastValue = __webpack_require__(1); -var ImageFile = __webpack_require__(37); -var IsPlainObject = __webpack_require__(8); -var MultiFile = __webpack_require__(36); -var XMLFile = __webpack_require__(143); - -/** - * @typedef {object} Phaser.Loader.FileTypes.AtlasXMLFileConfig - * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. - * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. - * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. - * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. - * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. - * @property {string} [atlasURL] - The absolute or relative URL to load the atlas xml file from. - * @property {string} [atlasExtension='xml'] - The default file extension to use for the atlas xml if no url is provided. - * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas xml file. - */ - -/** - * @classdesc - * A single XML based Texture Atlas File suitable for loading by the Loader. - * - * These are created when you use the Phaser.Loader.LoaderPlugin#atlasXML method and are not typically created directly. - * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#atlasXML. - * - * @class AtlasXMLFile - * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes - * @constructor - * - * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. - * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. - */ -var AtlasXMLFile = new Class({ - - Extends: MultiFile, - - initialize: - - function AtlasXMLFile (loader, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) - { - var image; - var data; - - if (IsPlainObject(key)) - { - var config = key; - - key = GetFastValue(config, 'key'); - - image = new ImageFile(loader, { - key: key, - url: GetFastValue(config, 'textureURL'), - extension: GetFastValue(config, 'textureExtension', 'png'), - normalMap: GetFastValue(config, 'normalMap'), - xhrSettings: GetFastValue(config, 'textureXhrSettings') - }); - - data = new XMLFile(loader, { - key: key, - url: GetFastValue(config, 'atlasURL'), - extension: GetFastValue(config, 'atlasExtension', 'xml'), - xhrSettings: GetFastValue(config, 'atlasXhrSettings') - }); - } - else - { - image = new ImageFile(loader, key, textureURL, textureXhrSettings); - data = new XMLFile(loader, key, atlasURL, atlasXhrSettings); - } - - if (image.linkFile) - { - // Image has a normal map - MultiFile.call(this, loader, 'atlasxml', key, [ image, data, image.linkFile ]); - } - else - { - MultiFile.call(this, loader, 'atlasxml', key, [ image, data ]); - } - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.AtlasXMLFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - if (this.isReadyToProcess()) - { - var image = this.files[0]; - var xml = this.files[1]; - var normalMap = (this.files[2]) ? this.files[2].data : null; - - this.loader.textureManager.addAtlasXML(image.key, image.data, xml.data, normalMap); - - xml.addToCache(); - - this.complete = true; - } - } - -}); - -/** - * Adds an XML based Texture Atlas, or array of atlases, to the current load queue. - * - * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * - * ```javascript - * function preload () - * { - * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); - * } - * ``` - * - * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, - * or if it's already running, when the next free load slot becomes available. This happens automatically if you - * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued - * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. - * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the - * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been - * loaded. - * - * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring - * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. - * - * Phaser expects the atlas data to be provided in an XML file format. - * These files are created by software such as Shoebox and Adobe Flash / Animate. - * - * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. - * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. - * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. - * - * Instead of passing arguments you can pass a configuration object, such as: - * - * ```javascript - * this.load.atlasXML({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * atlasURL: 'images/MainMenu.xml' - * }); - * ``` - * - * See the documentation for `Phaser.Loader.FileTypes.AtlasXMLFileConfig` for more details. - * - * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: - * - * ```javascript - * this.load.atlasXML('mainmenu', 'images/MainMenu.png', 'images/MainMenu.xml'); - * // and later in your game ... - * this.add.image(x, y, 'mainmenu', 'background'); - * ``` - * - * To get a list of all available frames within an atlas please consult your Texture Atlas software. - * - * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. - * - * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. - * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although - * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. - * - * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, - * then you can specify it by providing an array as the `url` where the second element is the normal map: - * - * ```javascript - * this.load.atlasXML('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.xml'); - * ``` - * - * Or, if you are using a config object use the `normalMap` property: - * - * ```javascript - * this.load.atlasXML({ - * key: 'mainmenu', - * textureURL: 'images/MainMenu.png', - * normalMap: 'images/MainMenu-n.png', - * atlasURL: 'images/MainMenu.xml' - * }); - * ``` - * - * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. - * Normal maps are a WebGL only feature. - * - * Note: The ability to load this type of file will only be available if the Atlas XML File type has been built into Phaser. - * It is available in the default build but can be excluded from custom builds. - * - * @method Phaser.Loader.LoaderPlugin#atlasXML - * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.7.0 - * - * @param {(string|Phaser.Loader.FileTypes.AtlasXMLFileConfig|Phaser.Loader.FileTypes.AtlasXMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas xml data file from. If undefined or `null` it will be set to `.xml`, i.e. if `key` was "alien" then the URL will be "alien.xml". - * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. - * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas xml file. Used in replacement of the Loaders default XHR Settings. - * - * @return {Phaser.Loader.LoaderPlugin} The Loader instance. - */ -FileTypesManager.register('atlasXML', function (key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings) -{ - var multifile; - - // Supports an Object file definition in the key argument - // Or an array of objects in the key argument - // Or a single entry where all arguments have been defined - - if (Array.isArray(key)) - { - for (var i = 0; i < key.length; i++) - { - multifile = new AtlasXMLFile(this, key[i]); - - this.addFile(multifile.files); - } - } - else - { - multifile = new AtlasXMLFile(this, key, textureURL, atlasURL, textureXhrSettings, atlasXhrSettings); - - this.addFile(multifile.files); - } - - return this; -}); - -module.exports = AtlasXMLFile; - - -/***/ }), -/* 758 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Loader.FileTypes - */ - -module.exports = { - - AnimationJSONFile: __webpack_require__(360), - AtlasJSONFile: __webpack_require__(359), - AtlasXMLFile: __webpack_require__(757), - AudioFile: __webpack_require__(168), - AudioSpriteFile: __webpack_require__(358), - BinaryFile: __webpack_require__(756), - BitmapFontFile: __webpack_require__(755), - GLSLFile: __webpack_require__(754), - HTML5AudioFile: __webpack_require__(167), - HTMLFile: __webpack_require__(753), - ImageFile: __webpack_require__(37), - JSONFile: __webpack_require__(28), - MultiAtlasFile: __webpack_require__(357), - PackFile: __webpack_require__(752), - PluginFile: __webpack_require__(356), - ScenePluginFile: __webpack_require__(751), - ScriptFile: __webpack_require__(355), - SpriteSheetFile: __webpack_require__(354), - SVGFile: __webpack_require__(750), - TextFile: __webpack_require__(224), - TilemapCSVFile: __webpack_require__(749), - TilemapImpactFile: __webpack_require__(748), - TilemapJSONFile: __webpack_require__(747), - UnityAtlasFile: __webpack_require__(746), - XMLFile: __webpack_require__(143) - -}; - - -/***/ }), -/* 759 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(18); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser.Loader - */ - -var Loader = { - - FileTypes: __webpack_require__(758), - - File: __webpack_require__(19), - FileTypesManager: __webpack_require__(7), - GetURL: __webpack_require__(108), - LoaderPlugin: __webpack_require__(353), - MergeXHRSettings: __webpack_require__(107), - MultiFile: __webpack_require__(36), - XHRLoader: __webpack_require__(169), - XHRSettings: __webpack_require__(75) - -}; - -// Merge in the consts -Loader = Extend(false, Loader, CONST); - -module.exports = Loader; - - -/***/ }), -/* 760 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(225); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.RotateAroundPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var RotateAroundPoint = function (triangle, point, angle) -{ - return RotateAroundXY(triangle, point.x, point.y, angle); -}; - -module.exports = RotateAroundPoint; - - -/***/ }), -/* 761 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(225); -var InCenter = __webpack_require__(384); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Rotate - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Rotate = function (triangle, angle) -{ - var point = InCenter(triangle); - - return RotateAroundXY(triangle, point.x, point.y, angle); -}; - -module.exports = Rotate; - - -/***/ }), -/* 762 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Length = __webpack_require__(71); - -// The 2D area of a triangle. The area value is always non-negative. - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Perimeter - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {number} [description] - */ -var Perimeter = function (triangle) -{ - var line1 = triangle.getLineA(); - var line2 = triangle.getLineB(); - var line3 = triangle.getLineC(); - - return (Length(line1) + Length(line2) + Length(line3)); -}; - -module.exports = Perimeter; - - -/***/ }), -/* 763 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Triangle} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (triangle, toCompare) -{ - return ( - triangle.x1 === toCompare.x1 && - triangle.y1 === toCompare.y1 && - triangle.x2 === toCompare.x2 && - triangle.y2 === toCompare.y2 && - triangle.x3 === toCompare.x3 && - triangle.y3 === toCompare.y3 - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 764 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [dest,$return] - * - * @param {Phaser.Geom.Triangle} source - [description] - * @param {Phaser.Geom.Triangle} dest - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 765 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(60); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {boolean} [description] - */ -var ContainsPoint = function (triangle, point) -{ - return Contains(triangle, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 766 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Triangle = __webpack_require__(68); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} source - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var Clone = function (source) -{ - return new Triangle(source.x1, source.y1, source.x2, source.y2, source.x3, source.y3); -}; - -module.exports = Clone; - - -/***/ }), -/* 767 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(88); - -// Adapted from https://gist.github.com/mutoo/5617691 - -/** - * [description] - * - * @function Phaser.Geom.Triangle.CircumCircle - * @since 3.0.0 - * - * @generic {Phaser.Geom.Circle} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} [out] - [description] - * - * @return {Phaser.Geom.Circle} [description] - */ -var CircumCircle = function (triangle, out) -{ - if (out === undefined) { out = new Circle(); } - - // A - var x1 = triangle.x1; - var y1 = triangle.y1; - - // B - var x2 = triangle.x2; - var y2 = triangle.y2; - - // C - var x3 = triangle.x3; - var y3 = triangle.y3; - - var A = x2 - x1; - var B = y2 - y1; - var C = x3 - x1; - var D = y3 - y1; - var E = A * (x1 + x2) + B * (y1 + y2); - var F = C * (x1 + x3) + D * (y1 + y3); - var G = 2 * (A * (y3 - y2) - B * (x3 - x2)); - - var dx; - var dy; - - // If the points of the triangle are collinear, then just find the - // extremes and use the midpoint as the center of the circumcircle. - - if (Math.abs(G) < 0.000001) - { - var minX = Math.min(x1, x2, x3); - var minY = Math.min(y1, y2, y3); - dx = (Math.max(x1, x2, x3) - minX) * 0.5; - dy = (Math.max(y1, y2, y3) - minY) * 0.5; - - out.x = minX + dx; - out.y = minY + dy; - out.radius = Math.sqrt(dx * dx + dy * dy); - } - else - { - out.x = (D * E - B * F) / G; - out.y = (A * F - C * E) / G; - dx = out.x - x1; - dy = out.y - y1; - out.radius = Math.sqrt(dx * dx + dy * dy); - } - - return out; -}; - -module.exports = CircumCircle; - - -/***/ }), -/* 768 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Vector2 = __webpack_require__(6); - -// Adapted from http://bjornharrtell.github.io/jsts/doc/api/jsts_geom_Triangle.js.html - -/** - * Computes the determinant of a 2x2 matrix. Uses standard double-precision arithmetic, so is susceptible to round-off error. - * - * @function det - * @private - * @since 3.0.0 - * - * @param {number} m00 - The [0,0] entry of the matrix. - * @param {number} m01 - The [0,1] entry of the matrix. - * @param {number} m10 - The [1,0] entry of the matrix. - * @param {number} m11 - The [1,1] entry of the matrix. - * - * @return {number} the determinant. - */ -function det (m00, m01, m10, m11) -{ - return (m00 * m11) - (m01 * m10); -} - -/** - * Computes the circumcentre of a triangle. The circumcentre is the centre of - * the circumcircle, the smallest circle which encloses the triangle. It is also - * the common intersection point of the perpendicular bisectors of the sides of - * the triangle, and is the only point which has equal distance to all three - * vertices of the triangle. - * - * @function Phaser.Geom.Triangle.CircumCenter - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [out,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Math.Vector2} [out] - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ -var CircumCenter = function (triangle, out) -{ - if (out === undefined) { out = new Vector2(); } - - var cx = triangle.x3; - var cy = triangle.y3; - - var ax = triangle.x1 - cx; - var ay = triangle.y1 - cy; - - var bx = triangle.x2 - cx; - var by = triangle.y2 - cy; - - var denom = 2 * det(ax, ay, bx, by); - var numx = det(ay, ax * ax + ay * ay, by, bx * bx + by * by); - var numy = det(ax, ax * ax + ay * ay, bx, bx * bx + by * by); - - out.x = cx - numx / denom; - out.y = cy + numy / denom; - - return out; -}; - -module.exports = CircumCenter; - - -/***/ }), -/* 769 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Centroid = __webpack_require__(386); -var Offset = __webpack_require__(385); - -/** - * @callback CenterFunction - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {Phaser.Math.Vector2} [description] - */ - -/** - * [description] - * - * @function Phaser.Geom.Triangle.CenterOn - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle} O - [triangle,$return] - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {CenterFunction} [centerFunc] - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var CenterOn = function (triangle, x, y, centerFunc) -{ - if (centerFunc === undefined) { centerFunc = Centroid; } - - // Get the center of the triangle - var center = centerFunc(triangle); - - // Difference - var diffX = x - center.x; - var diffY = y - center.y; - - return Offset(triangle, diffX, diffY); -}; - -module.exports = CenterOn; - - -/***/ }), -/* 770 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Triangle = __webpack_require__(68); - -// Builds a right triangle, with one 90 degree angle and two acute angles -// The x/y is the coordinate of the 90 degree angle (and will map to x1/y1 in the resulting Triangle) -// w/h can be positive or negative and represent the length of each side - -/** - * [description] - * - * @function Phaser.Geom.Triangle.BuildRight - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var BuildRight = function (x, y, width, height) -{ - if (height === undefined) { height = width; } - - // 90 degree angle - var x1 = x; - var y1 = y; - - var x2 = x; - var y2 = y - height; - - var x3 = x + width; - var y3 = y; - - return new Triangle(x1, y1, x2, y2, x3, y3); -}; - -module.exports = BuildRight; - - -/***/ }), -/* 771 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var EarCut = __webpack_require__(258); -var Triangle = __webpack_require__(68); - -/** - * [description] - * - * @function Phaser.Geom.Triangle.BuildFromPolygon - * @since 3.0.0 - * - * @generic {Phaser.Geom.Triangle[]} O - [out,$return] - * - * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] - * @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). - * @param {float} [scaleX=1] - [description] - * @param {float} [scaleY=1] - [description] - * @param {(array|Phaser.Geom.Triangle[])} [out] - [description] - * - * @return {(array|Phaser.Geom.Triangle[])} [description] - */ -var BuildFromPolygon = function (data, holes, scaleX, scaleY, out) -{ - if (holes === undefined) { holes = null; } - if (scaleX === undefined) { scaleX = 1; } - if (scaleY === undefined) { scaleY = 1; } - if (out === undefined) { out = []; } - - var tris = EarCut(data, holes); - - var a; - var b; - var c; - - var x1; - var y1; - - var x2; - var y2; - - var x3; - var y3; - - for (var i = 0; i < tris.length; i += 3) - { - a = tris[i]; - b = tris[i + 1]; - c = tris[i + 2]; - - x1 = data[a * 2] * scaleX; - y1 = data[(a * 2) + 1] * scaleY; - - x2 = data[b * 2] * scaleX; - y2 = data[(b * 2) + 1] * scaleY; - - x3 = data[c * 2] * scaleX; - y3 = data[(c * 2) + 1] * scaleY; - - out.push(new Triangle(x1, y1, x2, y2, x3, y3)); - } - - return out; -}; - -module.exports = BuildFromPolygon; - - -/***/ }), -/* 772 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Triangle = __webpack_require__(68); - -// Builds an equilateral triangle. -// In the equilateral triangle, all the sides are the same length (congruent) -// and all the angles are the same size (congruent). - -// The x/y specifies the top-middle of the triangle (x1/y1) and length -// is the length of each side - -/** - * [description] - * - * @function Phaser.Geom.Triangle.BuildEquilateral - * @since 3.0.0 - * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} length - [description] - * - * @return {Phaser.Geom.Triangle} [description] - */ -var BuildEquilateral = function (x, y, length) -{ - var height = length * (Math.sqrt(3) / 2); - - var x1 = x; - var y1 = y; - - var x2 = x + (length / 2); - var y2 = y + height; - - var x3 = x - (length / 2); - var y3 = y + height; - - return new Triangle(x1, y1, x2, y2, x3, y3); -}; - -module.exports = BuildEquilateral; - - -/***/ }), -/* 773 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// The 2D area of a triangle. The area value is always non-negative. - -/** - * [description] - * - * @function Phaser.Geom.Triangle.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {number} [description] - */ -var Area = function (triangle) -{ - var x1 = triangle.x1; - var y1 = triangle.y1; - - var x2 = triangle.x2; - var y2 = triangle.y2; - - var x3 = triangle.x3; - var y3 = triangle.y3; - - return Math.abs(((x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1)) / 2); -}; - -module.exports = Area; - - -/***/ }), -/* 774 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Triangle = __webpack_require__(68); - -Triangle.Area = __webpack_require__(773); -Triangle.BuildEquilateral = __webpack_require__(772); -Triangle.BuildFromPolygon = __webpack_require__(771); -Triangle.BuildRight = __webpack_require__(770); -Triangle.CenterOn = __webpack_require__(769); -Triangle.Centroid = __webpack_require__(386); -Triangle.CircumCenter = __webpack_require__(768); -Triangle.CircumCircle = __webpack_require__(767); -Triangle.Clone = __webpack_require__(766); -Triangle.Contains = __webpack_require__(60); -Triangle.ContainsArray = __webpack_require__(231); -Triangle.ContainsPoint = __webpack_require__(765); -Triangle.CopyFrom = __webpack_require__(764); -Triangle.Decompose = __webpack_require__(394); -Triangle.Equals = __webpack_require__(763); -Triangle.GetPoint = __webpack_require__(227); -Triangle.GetPoints = __webpack_require__(226); -Triangle.InCenter = __webpack_require__(384); -Triangle.Perimeter = __webpack_require__(762); -Triangle.Offset = __webpack_require__(385); -Triangle.Random = __webpack_require__(153); -Triangle.Rotate = __webpack_require__(761); -Triangle.RotateAroundPoint = __webpack_require__(760); -Triangle.RotateAroundXY = __webpack_require__(225); - -module.exports = Triangle; - - -/***/ }), -/* 775 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Scales the width and height of this Rectangle by the given amounts. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Scale - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Scale = function (rect, x, y) -{ - if (y === undefined) { y = x; } - - rect.width *= x; - rect.height *= y; - - return rect; -}; - -module.exports = Scale; - - -/***/ }), -/* 776 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Between = __webpack_require__(149); -var ContainsRect = __webpack_require__(387); -var Point = __webpack_require__(5); - -/** - * Calculates a random point that lies within the `outer` Rectangle, but outside of the `inner` Rectangle. - * The inner Rectangle must be fully contained within the outer rectangle. - * - * @function Phaser.Geom.Rectangle.RandomOutside - * @since 3.10.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} outer - The outer Rectangle to get the random point within. - * @param {Phaser.Geom.Rectangle} inner - The inner Rectangle to exclude from the returned point. - * @param {Phaser.Geom.Point} [out] - A Point, or Point-like object to store the result in. If not specified, a new Point will be created. - * - * @return {Phaser.Geom.Point} A Point object containing the random values in its `x` and `y` properties. - */ -var RandomOutside = function (outer, inner, out) -{ - if (out === undefined) { out = new Point(); } - - if (ContainsRect(outer, inner)) - { - // Pick a random quadrant - // - // The quadrants don't extend the full widths / heights of the outer rect to give - // us a better uniformed distribution, otherwise you get clumping in the corners where - // the 4 quads would overlap - - switch (Between(0, 3)) - { - case 0: // Top - out.x = outer.x + (Math.random() * (inner.right - outer.x)); - out.y = outer.y + (Math.random() * (inner.top - outer.y)); - break; - - case 1: // Bottom - out.x = inner.x + (Math.random() * (outer.right - inner.x)); - out.y = inner.bottom + (Math.random() * (outer.bottom - inner.bottom)); - break; - - case 2: // Left - out.x = outer.x + (Math.random() * (inner.x - outer.x)); - out.y = inner.y + (Math.random() * (outer.bottom - inner.y)); - break; - - case 3: // Right - out.x = inner.right + (Math.random() * (outer.right - inner.right)); - out.y = outer.y + (Math.random() * (inner.bottom - outer.y)); - break; - } - } - - return out; -}; - -module.exports = RandomOutside; - - -/***/ }), -/* 777 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var DegToRad = __webpack_require__(38); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.PerimeterPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {integer} angle - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var PerimeterPoint = function (rectangle, angle, out) -{ - if (out === undefined) { out = new Point(); } - - angle = DegToRad(angle); - - var s = Math.sin(angle); - var c = Math.cos(angle); - - var dx = (c > 0) ? rectangle.width / 2 : rectangle.width / -2; - var dy = (s > 0) ? rectangle.height / 2 : rectangle.height / -2; - - if (Math.abs(dx * s) < Math.abs(dy * c)) - { - dy = (dx * s) / c; - } - else - { - dx = (dy * c) / s; - } - - out.x = dx + rectangle.centerX; - out.y = dy + rectangle.centerY; - - return out; -}; - -module.exports = PerimeterPoint; - - -/***/ }), -/* 778 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Overlaps - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * - * @return {boolean} [description] - */ -var Overlaps = function (rectA, rectB) -{ - return ( - rectA.x < rectB.right && - rectA.right > rectB.x && - rectA.y < rectB.bottom && - rectA.bottom > rectB.y - ); -}; - -module.exports = Overlaps; - - -/***/ }), -/* 779 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.OffsetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var OffsetPoint = function (rect, point) -{ - rect.x += point.x; - rect.y += point.y; - - return rect; -}; - -module.exports = OffsetPoint; - - -/***/ }), -/* 780 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Offset = function (rect, x, y) -{ - rect.x += x; - rect.y += y; - - return rect; -}; - -module.exports = Offset; - - -/***/ }), -/* 781 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.MergeXY - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var MergeXY = function (target, x, y) -{ - var minX = Math.min(target.x, x); - var maxX = Math.max(target.right, x); - - target.x = minX; - target.width = maxX - minX; - - var minY = Math.min(target.y, y); - var maxY = Math.max(target.bottom, y); - - target.y = minY; - target.height = maxY - minY; - - return target; -}; - -module.exports = MergeXY; - - -/***/ }), -/* 782 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Merges source rectangle into target rectangle and returns target -// Neither rect should have negative widths or heights - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.MergeRect - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var MergeRect = function (target, source) -{ - var minX = Math.min(target.x, source.x); - var maxX = Math.max(target.right, source.right); - - target.x = minX; - target.width = maxX - minX; - - var minY = Math.min(target.y, source.y); - var maxY = Math.max(target.bottom, source.bottom); - - target.y = minY; - target.height = maxY - minY; - - return target; -}; - -module.exports = MergeRect; - - -/***/ }), -/* 783 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Merges the target Rectangle with a list of points. -// The points is an array of objects with public x/y properties. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.MergePoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Point[]} points - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var MergePoints = function (target, points) -{ - var minX = target.x; - var maxX = target.right; - var minY = target.y; - var maxY = target.bottom; - - for (var i = 0; i < points.length; i++) - { - minX = Math.min(minX, points[i].x); - maxX = Math.max(maxX, points[i].x); - minY = Math.min(minY, points[i].y); - maxY = Math.max(maxY, points[i].y); - } - - target.x = minX; - target.y = minY; - target.width = maxX - minX; - target.height = maxY - minY; - - return target; -}; - -module.exports = MergePoints; - - -/***/ }), -/* 784 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CenterOn = __webpack_require__(388); - -// Increases the size of the Rectangle object by the specified amounts. -// The center point of the Rectangle object stays the same, and its size increases -// to the left and right by the x value, and to the top and the bottom by the y value. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Inflate - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Inflate = function (rect, x, y) -{ - var cx = rect.centerX; - var cy = rect.centerY; - - rect.setSize(rect.width + (x * 2), rect.height + (y * 2)); - - return CenterOn(rect, cx, cy); -}; - -module.exports = Inflate; - - -/***/ }), -/* 785 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// The size of the Rectangle object, expressed as a Point object -// with the values of the width and height properties. - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.GetSize - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetSize = function (rect, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = rect.width; - out.y = rect.height; - - return out; -}; - -module.exports = GetSize; - - -/***/ }), -/* 786 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -// The center of the Rectangle object, expressed as a Point object - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.GetCenter - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetCenter = function (rect, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = rect.centerX; - out.y = rect.centerY; - - return out; -}; - -module.exports = GetCenter; - - -/***/ }), -/* 787 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.FloorAll - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var FloorAll = function (rect) -{ - rect.x = Math.floor(rect.x); - rect.y = Math.floor(rect.y); - rect.width = Math.floor(rect.width); - rect.height = Math.floor(rect.height); - - return rect; -}; - -module.exports = FloorAll; - - -/***/ }), -/* 788 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Floor - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Floor = function (rect) -{ - rect.x = Math.floor(rect.x); - rect.y = Math.floor(rect.y); - - return rect; -}; - -module.exports = Floor; - - -/***/ }), -/* 789 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetAspectRatio = __webpack_require__(228); - -// Fits the target rectangle around the source rectangle. -// Preserves aspect ration. -// Scales and centers the target rectangle to the source rectangle - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.FitOutside - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var FitOutside = function (target, source) -{ - var ratio = GetAspectRatio(target); - - if (ratio > GetAspectRatio(source)) - { - // Wider than Tall - target.setSize(source.height * ratio, source.height); - } - else - { - // Taller than Wide - target.setSize(source.width, source.width / ratio); - } - - return target.setPosition( - source.centerX - target.width / 2, - source.centerY - target.height / 2 - ); -}; - -module.exports = FitOutside; - - -/***/ }), -/* 790 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetAspectRatio = __webpack_require__(228); - -// Fits the target rectangle into the source rectangle. -// Preserves aspect ratio. -// Scales and centers the target rectangle to the source rectangle - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.FitInside - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [target,$return] - * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var FitInside = function (target, source) -{ - var ratio = GetAspectRatio(target); - - if (ratio < GetAspectRatio(source)) - { - // Taller than Wide - target.setSize(source.height * ratio, source.height); - } - else - { - // Wider than Tall - target.setSize(source.width, source.width / ratio); - } - - return target.setPosition( - source.centerX - (target.width / 2), - source.centerY - (target.height / 2) - ); -}; - -module.exports = FitInside; - - -/***/ }), -/* 791 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Rectangle} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (rect, toCompare) -{ - return ( - rect.x === toCompare.x && - rect.y === toCompare.y && - rect.width === toCompare.width && - rect.height === toCompare.height - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 792 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [dest,$return] - * - * @param {Phaser.Geom.Rectangle} source - [description] - * @param {Phaser.Geom.Rectangle} dest - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.width, source.height); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 793 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(31); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {boolean} [description] - */ -var ContainsPoint = function (rect, point) -{ - return Contains(rect, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 794 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} source - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Clone = function (source) -{ - return new Rectangle(source.x, source.y, source.width, source.height); -}; - -module.exports = Clone; - - -/***/ }), -/* 795 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.CeilAll - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var CeilAll = function (rect) -{ - rect.x = Math.ceil(rect.x); - rect.y = Math.ceil(rect.y); - rect.width = Math.ceil(rect.width); - rect.height = Math.ceil(rect.height); - - return rect; -}; - -module.exports = CeilAll; - - -/***/ }), -/* 796 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Ceil - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [rect,$return] - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var Ceil = function (rect) -{ - rect.x = Math.ceil(rect.x); - rect.y = Math.ceil(rect.y); - - return rect; -}; - -module.exports = Ceil; - - -/***/ }), -/* 797 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Rectangle.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {number} [description] - */ -var Area = function (rect) -{ - return rect.width * rect.height; -}; - -module.exports = Area; - - -/***/ }), -/* 798 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -// Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] - -/** - * [description] - * - * @function Phaser.Geom.Polygon.GetNumberArray - * @since 3.0.0 - * - * @generic {number[]} O - [output,$return] - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {(array|number[])} [output] - [description] - * - * @return {(array|number[])} [description] - */ -var GetNumberArray = function (polygon, output) -{ - if (output === undefined) { output = []; } - - for (var i = 0; i < polygon.points.length; i++) - { - output.push(polygon.points[i].x); - output.push(polygon.points[i].y); - } - - return output; -}; - -module.exports = GetNumberArray; - - -/***/ }), -/* 799 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * [description] - * - * @function Phaser.Geom.Polygon.GetAABB - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {(Phaser.Geom.Rectangle|object)} [out] - [description] - * - * @return {(Phaser.Geom.Rectangle|object)} [description] - */ -var GetAABB = function (polygon, out) -{ - if (out === undefined) { out = new Rectangle(); } - - var minX = Infinity; - var minY = Infinity; - var maxX = -minX; - var maxY = -minY; - var p; - - for (var i = 0; i < polygon.points.length; i++) - { - p = polygon.points[i]; - - minX = Math.min(minX, p.x); - minY = Math.min(minY, p.y); - maxX = Math.max(maxX, p.x); - maxY = Math.max(maxY, p.y); - } - - out.x = minX; - out.y = minY; - out.width = maxX - minX; - out.height = maxY - minY; - - return out; -}; - -module.exports = GetAABB; - - -/***/ }), -/* 800 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(229); - -/** - * [description] - * - * @function Phaser.Geom.Polygon.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {Phaser.Geom.Point} point - [description] - * - * @return {boolean} [description] - */ -var ContainsPoint = function (polygon, point) -{ - return Contains(polygon, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 801 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Polygon = __webpack_require__(390); - -/** - * [description] - * - * @function Phaser.Geom.Polygon.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Polygon} polygon - [description] - * - * @return {Phaser.Geom.Polygon} [description] - */ -var Clone = function (polygon) -{ - return new Polygon(polygon.points); -}; - -module.exports = Clone; - - -/***/ }), -/* 802 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Polygon = __webpack_require__(390); - -Polygon.Clone = __webpack_require__(801); -Polygon.Contains = __webpack_require__(229); -Polygon.ContainsPoint = __webpack_require__(800); -Polygon.GetAABB = __webpack_require__(799); -Polygon.GetNumberArray = __webpack_require__(798); - -module.exports = Polygon; - - -/***/ }), -/* 803 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetMagnitude = __webpack_require__(392); - -/** - * [description] - * - * @function Phaser.Geom.Point.SetMagnitude - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * @param {number} magnitude - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var SetMagnitude = function (point, magnitude) -{ - if (point.x !== 0 || point.y !== 0) - { - var m = GetMagnitude(point); - - point.x /= m; - point.y /= m; - } - - point.x *= magnitude; - point.y *= magnitude; - - return point; -}; - -module.exports = SetMagnitude; - - -/***/ }), -/* 804 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.ProjectUnit - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var ProjectUnit = function (pointA, pointB, out) -{ - if (out === undefined) { out = new Point(); } - - var amt = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); - - if (amt !== 0) - { - out.x = amt * pointB.x; - out.y = amt * pointB.y; - } - - return out; -}; - -module.exports = ProjectUnit; - - -/***/ }), -/* 805 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); -var GetMagnitudeSq = __webpack_require__(391); - -/** - * [description] - * - * @function Phaser.Geom.Point.Project - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Project = function (pointA, pointB, out) -{ - if (out === undefined) { out = new Point(); } - - var dot = ((pointA.x * pointB.x) + (pointA.y * pointB.y)); - var amt = dot / GetMagnitudeSq(pointB); - - if (amt !== 0) - { - out.x = amt * pointB.x; - out.y = amt * pointB.y; - } - - return out; -}; - -module.exports = Project; - - -/***/ }), -/* 806 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Negative - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Negative = function (point, out) -{ - if (out === undefined) { out = new Point(); } - - return out.setTo(-point.x, -point.y); -}; - -module.exports = Negative; - - -/***/ }), -/* 807 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Invert - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Invert = function (point) -{ - return point.setTo(point.y, point.x); -}; - -module.exports = Invert; - - -/***/ }), -/* 808 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Interpolate - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {float} [t=0] - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var Interpolate = function (pointA, pointB, t, out) -{ - if (t === undefined) { t = 0; } - if (out === undefined) { out = new Point(); } - - out.x = pointA.x + ((pointB.x - pointA.x) * t); - out.y = pointA.y + ((pointB.y - pointA.y) * t); - - return out; -}; - -module.exports = Interpolate; - - -/***/ }), -/* 809 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * Calculates the Axis Aligned Bounding Box (or aabb) from an array of points. - * - * @function Phaser.Geom.Point.GetRectangleFromPoints - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var GetRectangleFromPoints = function (points, out) -{ - if (out === undefined) { out = new Rectangle(); } - - var xMax = Number.NEGATIVE_INFINITY; - var xMin = Number.POSITIVE_INFINITY; - var yMax = Number.NEGATIVE_INFINITY; - var yMin = Number.POSITIVE_INFINITY; - - for (var i = 0; i < points.length; i++) - { - var point = points[i]; - - if (point.x > xMax) - { - xMax = point.x; - } - - if (point.x < xMin) - { - xMin = point.x; - } - - if (point.y > yMax) - { - yMax = point.y; - } - - if (point.y < yMin) - { - yMin = point.y; - } - } - - out.x = xMin; - out.y = yMin; - out.width = xMax - xMin; - out.height = yMax - yMin; - - return out; -}; - -module.exports = GetRectangleFromPoints; - - -/***/ }), -/* 810 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.GetCentroid - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Point[]} points - [description] - * @param {Phaser.Geom.Point} [out] - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var GetCentroid = function (points, out) -{ - if (out === undefined) { out = new Point(); } - - if (!Array.isArray(points)) - { - throw new Error('GetCentroid points argument must be an array'); - } - - var len = points.length; - - if (len < 1) - { - throw new Error('GetCentroid points array must not be empty'); - } - else if (len === 1) - { - out.x = points[0].x; - out.y = points[0].y; - } - else - { - for (var i = 0; i < len; i++) - { - out.x += points[i].x; - out.y += points[i].y; - } - - out.x /= len; - out.y /= len; - } - - return out; -}; - -module.exports = GetCentroid; - - -/***/ }), -/* 811 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Floor - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Floor = function (point) -{ - return point.setTo(Math.floor(point.x), Math.floor(point.y)); -}; - -module.exports = Floor; - - -/***/ }), -/* 812 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (point, toCompare) -{ - return (point.x === toCompare.x && point.y === toCompare.y); -}; - -module.exports = Equals; - - -/***/ }), -/* 813 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [dest,$return] - * - * @param {Phaser.Geom.Point} source - [description] - * @param {Phaser.Geom.Point} dest - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 814 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Point.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} source - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Clone = function (source) -{ - return new Point(source.x, source.y); -}; - -module.exports = Clone; - - -/***/ }), -/* 815 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Point.Ceil - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [point,$return] - * - * @param {Phaser.Geom.Point} point - [description] - * - * @return {Phaser.Geom.Point} [description] - */ -var Ceil = function (point) -{ - return point.setTo(Math.ceil(point.x), Math.ceil(point.y)); -}; - -module.exports = Ceil; - - -/***/ }), -/* 816 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -Point.Ceil = __webpack_require__(815); -Point.Clone = __webpack_require__(814); -Point.CopyFrom = __webpack_require__(813); -Point.Equals = __webpack_require__(812); -Point.Floor = __webpack_require__(811); -Point.GetCentroid = __webpack_require__(810); -Point.GetMagnitude = __webpack_require__(392); -Point.GetMagnitudeSq = __webpack_require__(391); -Point.GetRectangleFromPoints = __webpack_require__(809); -Point.Interpolate = __webpack_require__(808); -Point.Invert = __webpack_require__(807); -Point.Negative = __webpack_require__(806); -Point.Project = __webpack_require__(805); -Point.ProjectUnit = __webpack_require__(804); -Point.SetMagnitude = __webpack_require__(803); - -module.exports = Point; - - -/***/ }), -/* 817 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Width - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Width = function (line) -{ - return Math.abs(line.x1 - line.x2); -}; - -module.exports = Width; - - -/***/ }), -/* 818 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Slope - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Slope = function (line) -{ - return (line.y2 - line.y1) / (line.x2 - line.x1); -}; - -module.exports = Slope; - - -/***/ }), -/* 819 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.SetToAngle - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] - * @param {number} length - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var SetToAngle = function (line, x, y, angle, length) -{ - line.x1 = x; - line.y1 = y; - - line.x2 = x + (Math.cos(angle) * length); - line.y2 = y + (Math.sin(angle) * length); - - return line; -}; - -module.exports = SetToAngle; - - -/***/ }), -/* 820 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(230); - -/** - * [description] - * - * @function Phaser.Geom.Line.RotateAroundPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {(Phaser.Geom.Point|object)} point - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var RotateAroundPoint = function (line, point, angle) -{ - return RotateAroundXY(line, point.x, point.y, angle); -}; - -module.exports = RotateAroundPoint; - - -/***/ }), -/* 821 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RotateAroundXY = __webpack_require__(230); - -/** - * [description] - * - * @function Phaser.Geom.Line.Rotate - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} angle - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Rotate = function (line, angle) -{ - var x = (line.x1 + line.x2) / 2; - var y = (line.y1 + line.y2) / 2; - - return RotateAroundXY(line, x, y, angle); -}; - -module.exports = Rotate; - - -/***/ }), -/* 822 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Angle = __webpack_require__(82); -var NormalAngle = __webpack_require__(393); - -/** -* Returns the reflected angle between two lines. -* This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. -*/ -/** - * [description] - * - * @function Phaser.Geom.Line.ReflectAngle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} lineA - [description] - * @param {Phaser.Geom.Line} lineB - [description] - * - * @return {number} [description] - */ -var ReflectAngle = function (lineA, lineB) -{ - return (2 * NormalAngle(lineB) - Math.PI - Angle(lineA)); -}; - -module.exports = ReflectAngle; - - -/***/ }), -/* 823 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.PerpSlope - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var PerpSlope = function (line) -{ - return -((line.x2 - line.x1) / (line.y2 - line.y1)); -}; - -module.exports = PerpSlope; - - -/***/ }), -/* 824 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [line,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Offset = function (line, x, y) -{ - line.x1 += x; - line.y1 += y; - - line.x2 += x; - line.y2 += y; - - return line; -}; - -module.exports = Offset; - - -/***/ }), -/* 825 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(82); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalY - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalY = function (line) -{ - return Math.sin(Angle(line) - MATH_CONST.TAU); -}; - -module.exports = NormalY; - - -/***/ }), -/* 826 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(82); - -/** - * [description] - * - * @function Phaser.Geom.Line.NormalX - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var NormalX = function (line) -{ - return Math.cos(Angle(line) - MATH_CONST.TAU); -}; - -module.exports = NormalX; - - -/***/ }), -/* 827 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Height - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * - * @return {number} [description] - */ -var Height = function (line) -{ - return Math.abs(line.y1 - line.y2); -}; - -module.exports = Height; - - -/***/ }), -/* 828 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var MATH_CONST = __webpack_require__(16); -var Angle = __webpack_require__(82); -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetNormal - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetNormal = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - var a = Angle(line) - MATH_CONST.TAU; - - out.x = Math.cos(a); - out.y = Math.sin(a); - - return out; -}; - -module.exports = GetNormal; - - -/***/ }), -/* 829 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Point = __webpack_require__(5); - -/** - * [description] - * - * @function Phaser.Geom.Line.GetMidPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Point} O - [out,$return] - * - * @param {Phaser.Geom.Line} line - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] - * - * @return {(Phaser.Geom.Point|object)} [description] - */ -var GetMidPoint = function (line, out) -{ - if (out === undefined) { out = new Point(); } - - out.x = (line.x1 + line.x2) / 2; - out.y = (line.y1 + line.y2) / 2; - - return out; -}; - -module.exports = GetMidPoint; - - -/***/ }), -/* 830 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Line} toCompare - [description] - * - * @return {boolean} [description] - */ -var Equals = function (line, toCompare) -{ - return ( - line.x1 === toCompare.x1 && - line.y1 === toCompare.y1 && - line.x2 === toCompare.x2 && - line.y2 === toCompare.y2 - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 831 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Line.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Line} O - [dest,$return] - * - * @param {Phaser.Geom.Line} source - [description] - * @param {Phaser.Geom.Line} dest - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x1, source.y1, source.x2, source.y2); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 832 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Line = __webpack_require__(96); - -/** - * [description] - * - * @function Phaser.Geom.Line.Clone - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} source - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var Clone = function (source) -{ - return new Line(source.x1, source.y1, source.x2, source.y2); -}; - -module.exports = Clone; - - -/***/ }), -/* 833 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - - -/** - * [description] - * - * @function Phaser.Geom.Line.CenterOn - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * - * @return {Phaser.Geom.Line} [description] - */ -var CenterOn = function (line, x, y) -{ - var tx = x - ((line.x1 + line.x2) / 2); - var ty = y - ((line.y1 + line.y2) / 2); - - line.x1 += tx; - line.y1 += ty; - - line.x2 += tx; - line.y2 += ty; - - return line; -}; - -module.exports = CenterOn; - - -/***/ }), -/* 834 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Line = __webpack_require__(96); - -Line.Angle = __webpack_require__(82); -Line.BresenhamPoints = __webpack_require__(569); -Line.CenterOn = __webpack_require__(833); -Line.Clone = __webpack_require__(832); -Line.CopyFrom = __webpack_require__(831); -Line.Equals = __webpack_require__(830); -Line.GetMidPoint = __webpack_require__(829); -Line.GetNormal = __webpack_require__(828); -Line.GetPoint = __webpack_require__(293); -Line.GetPoints = __webpack_require__(156); -Line.Height = __webpack_require__(827); -Line.Length = __webpack_require__(71); -Line.NormalAngle = __webpack_require__(393); -Line.NormalX = __webpack_require__(826); -Line.NormalY = __webpack_require__(825); -Line.Offset = __webpack_require__(824); -Line.PerpSlope = __webpack_require__(823); -Line.Random = __webpack_require__(155); -Line.ReflectAngle = __webpack_require__(822); -Line.Rotate = __webpack_require__(821); -Line.RotateAroundPoint = __webpack_require__(820); -Line.RotateAroundXY = __webpack_require__(230); -Line.SetToAngle = __webpack_require__(819); -Line.Slope = __webpack_require__(818); -Line.Width = __webpack_require__(817); - -module.exports = Line; - - -/***/ }), -/* 835 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ContainsArray = __webpack_require__(231); -var Decompose = __webpack_require__(394); -var LineToLine = __webpack_require__(144); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToTriangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangleA - [description] - * @param {Phaser.Geom.Triangle} triangleB - [description] - * - * @return {boolean} [description] - */ -var TriangleToTriangle = function (triangleA, triangleB) -{ - // First the cheapest ones: - - if ( - triangleA.left > triangleB.right || - triangleA.right < triangleB.left || - triangleA.top > triangleB.bottom || - triangleA.bottom < triangleB.top) - { - return false; - } - - var lineAA = triangleA.getLineA(); - var lineAB = triangleA.getLineB(); - var lineAC = triangleA.getLineC(); - - var lineBA = triangleB.getLineA(); - var lineBB = triangleB.getLineB(); - var lineBC = triangleB.getLineC(); - - // Now check the lines against each line of TriangleB - if (LineToLine(lineAA, lineBA) || LineToLine(lineAA, lineBB) || LineToLine(lineAA, lineBC)) - { - return true; - } - - if (LineToLine(lineAB, lineBA) || LineToLine(lineAB, lineBB) || LineToLine(lineAB, lineBC)) - { - return true; - } - - if (LineToLine(lineAC, lineBA) || LineToLine(lineAC, lineBB) || LineToLine(lineAC, lineBC)) - { - return true; - } - - // Nope, so check to see if any of the points of triangleA are within triangleB - - var points = Decompose(triangleA); - var within = ContainsArray(triangleB, points, true); - - if (within.length > 0) - { - return true; - } - - // Finally check to see if any of the points of triangleB are within triangleA - - points = Decompose(triangleB); - within = ContainsArray(triangleA, points, true); - - if (within.length > 0) - { - return true; - } - - return false; -}; - -module.exports = TriangleToTriangle; - - -/***/ }), -/* 836 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(60); -var LineToLine = __webpack_require__(144); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToLine - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] - */ -var TriangleToLine = function (triangle, line) -{ - // If the Triangle contains either the start or end point of the line, it intersects - if (Contains(triangle, line.getPointA()) || Contains(triangle, line.getPointB())) - { - return true; - } - - // Now check the line against each line of the Triangle - if (LineToLine(triangle.getLineA(), line)) - { - return true; - } - - if (LineToLine(triangle.getLineB(), line)) - { - return true; - } - - if (LineToLine(triangle.getLineC(), line)) - { - return true; - } - - return false; -}; - -module.exports = TriangleToLine; - - -/***/ }), -/* 837 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LineToCircle = __webpack_require__(397); -var Contains = __webpack_require__(60); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.TriangleToCircle - * @since 3.0.0 - * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} circle - [description] - * - * @return {boolean} [description] - */ -var TriangleToCircle = function (triangle, circle) -{ - // First the cheapest ones: - - if ( - triangle.left > circle.right || - triangle.right < circle.left || - triangle.top > circle.bottom || - triangle.bottom < circle.top) - { - return false; - } - - if (Contains(triangle, circle.x, circle.y)) - { - return true; - } - - if (LineToCircle(triangle.getLineA(), circle)) - { - return true; - } - - if (LineToCircle(triangle.getLineB(), circle)) - { - return true; - } - - if (LineToCircle(triangle.getLineC(), circle)) - { - return true; - } - - return false; -}; - -module.exports = TriangleToCircle; - - -/***/ }), -/* 838 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.RectangleToValues - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} left - [description] - * @param {number} right - [description] - * @param {number} top - [description] - * @param {number} bottom - [description] - * @param {float} [tolerance=0] - [description] - * - * @return {boolean} [description] - */ -var RectangleToValues = function (rect, left, right, top, bottom, tolerance) -{ - if (tolerance === undefined) { tolerance = 0; } - - return !( - left > rect.right + tolerance || - right < rect.left - tolerance || - top > rect.bottom + tolerance || - bottom < rect.top - tolerance - ); -}; - -module.exports = RectangleToValues; - - -/***/ }), -/* 839 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var LineToLine = __webpack_require__(144); -var Contains = __webpack_require__(31); -var ContainsArray = __webpack_require__(231); -var Decompose = __webpack_require__(395); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.RectangleToTriangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Triangle} triangle - [description] - * - * @return {boolean} [description] - */ -var RectangleToTriangle = function (rect, triangle) -{ - // First the cheapest ones: - - if ( - triangle.left > rect.right || - triangle.right < rect.left || - triangle.top > rect.bottom || - triangle.bottom < rect.top) - { - return false; - } - - var triA = triangle.getLineA(); - var triB = triangle.getLineB(); - var triC = triangle.getLineC(); - - // Are any of the triangle points within the rectangle? - - if (Contains(rect, triA.x1, triA.y1) || Contains(rect, triA.x2, triA.y2)) - { - return true; - } - - if (Contains(rect, triB.x1, triB.y1) || Contains(rect, triB.x2, triB.y2)) - { - return true; - } - - if (Contains(rect, triC.x1, triC.y1) || Contains(rect, triC.x2, triC.y2)) - { - return true; - } - - // Cheap tests over, now to see if any of the lines intersect ... - - var rectA = rect.getLineA(); - var rectB = rect.getLineB(); - var rectC = rect.getLineC(); - var rectD = rect.getLineD(); - - if (LineToLine(triA, rectA) || LineToLine(triA, rectB) || LineToLine(triA, rectC) || LineToLine(triA, rectD)) - { - return true; - } - - if (LineToLine(triB, rectA) || LineToLine(triB, rectB) || LineToLine(triB, rectC) || LineToLine(triB, rectD)) - { - return true; - } - - if (LineToLine(triC, rectA) || LineToLine(triC, rectB) || LineToLine(triC, rectC) || LineToLine(triC, rectD)) - { - return true; - } - - // None of the lines intersect, so are any rectangle points within the triangle? - - var points = Decompose(rect); - var within = ContainsArray(triangle, points, true); - - return (within.length > 0); -}; - -module.exports = RectangleToTriangle; - - -/***/ }), -/* 840 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var PointToLine = __webpack_require__(396); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.PointToLineSegment - * @since 3.0.0 - * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Line} line - [description] - * - * @return {boolean} [description] - */ -var PointToLineSegment = function (point, line) -{ - if (!PointToLine(point, line)) - { - return false; - } - - var xMin = Math.min(line.x1, line.x2); - var xMax = Math.max(line.x1, line.x2); - var yMin = Math.min(line.y1, line.y2); - var yMax = Math.max(line.y1, line.y2); - - return ((point.x >= xMin && point.x <= xMax) && (point.y >= yMin && point.y <= yMax)); -}; - -module.exports = PointToLineSegment; - - -/***/ }), -/* 841 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Checks for intersection between the Line and a Rectangle shape, or a rectangle-like - * object, with public `x`, `y`, `right` and `bottom` properties, such as a Sprite or Body. - * - * An intersection is considered valid if: - * - * The line starts within, or ends within, the Rectangle. - * The line segment intersects one of the 4 rectangle edges. - * - * The for the purposes of this function rectangles are considered 'solid'. - * - * @function Phaser.Geom.Intersects.LineToRectangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Line} line - [description] - * @param {(Phaser.Geom.Rectangle|object)} rect - [description] - * - * @return {boolean} [description] - */ -var LineToRectangle = function (line, rect) -{ - var x1 = line.x1; - var y1 = line.y1; - - var x2 = line.x2; - var y2 = line.y2; - - var bx1 = rect.x; - var by1 = rect.y; - var bx2 = rect.right; - var by2 = rect.bottom; - - var t = 0; - - // If the start or end of the line is inside the rect then we assume - // collision, as rects are solid for our use-case. - - if ((x1 >= bx1 && x1 <= bx2 && y1 >= by1 && y1 <= by2) || - (x2 >= bx1 && x2 <= bx2 && y2 >= by1 && y2 <= by2)) - { - return true; - } - - if (x1 < bx1 && x2 >= bx1) - { - // Left edge - t = y1 + (y2 - y1) * (bx1 - x1) / (x2 - x1); - - if (t > by1 && t <= by2) - { - return true; - } - } - else if (x1 > bx2 && x2 <= bx2) - { - // Right edge - t = y1 + (y2 - y1) * (bx2 - x1) / (x2 - x1); - - if (t >= by1 && t <= by2) - { - return true; - } - } - - if (y1 < by1 && y2 >= by1) - { - // Top edge - t = x1 + (x2 - x1) * (by1 - y1) / (y2 - y1); - - if (t >= bx1 && t <= bx2) - { - return true; - } - } - else if (y1 > by2 && y2 <= by2) - { - // Bottom edge - t = x1 + (x2 - x1) * (by2 - y1) / (y2 - y1); - - if (t >= bx1 && t <= bx2) - { - return true; - } - } - - return false; -}; - -module.exports = LineToRectangle; - - -/***/ }), -/* 842 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); -var RectangleToRectangle = __webpack_require__(398); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.GetRectangleIntersection - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [output,$return] - * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [output] - [description] - * - * @return {Phaser.Geom.Rectangle} [description] - */ -var GetRectangleIntersection = function (rectA, rectB, output) -{ - if (output === undefined) { output = new Rectangle(); } - - if (RectangleToRectangle(rectA, rectB)) - { - output.x = Math.max(rectA.x, rectB.x); - output.y = Math.max(rectA.y, rectB.y); - output.width = Math.min(rectA.right, rectB.right) - output.x; - output.height = Math.min(rectA.bottom, rectB.bottom) - output.y; - } - - return output; -}; - -module.exports = GetRectangleIntersection; - - -/***/ }), -/* 843 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Geom.Intersects.CircleToRectangle - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Rectangle} rect - [description] - * - * @return {boolean} [description] - */ -var CircleToRectangle = function (circle, rect) -{ - var halfWidth = rect.width / 2; - var halfHeight = rect.height / 2; - - var cx = Math.abs(circle.x - rect.x - halfWidth); - var cy = Math.abs(circle.y - rect.y - halfHeight); - var xDist = halfWidth + circle.radius; - var yDist = halfHeight + circle.radius; - - if (cx > xDist || cy > yDist) - { - return false; - } - else if (cx <= halfWidth || cy <= halfHeight) - { - return true; - } - else - { - var xCornerDist = cx - halfWidth; - var yCornerDist = cy - halfHeight; - var xCornerDistSq = xCornerDist * xCornerDist; - var yCornerDistSq = yCornerDist * yCornerDist; - var maxCornerDistSq = circle.radius * circle.radius; - - return (xCornerDistSq + yCornerDistSq <= maxCornerDistSq); - } -}; - -module.exports = CircleToRectangle; - - -/***/ }), -/* 844 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var DistanceBetween = __webpack_require__(58); - -/** - * [description] - * - * @function Phaser.Geom.Intersects.CircleToCircle - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circleA - [description] - * @param {Phaser.Geom.Circle} circleB - [description] - * - * @return {boolean} [description] - */ -var CircleToCircle = function (circleA, circleB) -{ - return (DistanceBetween(circleA.x, circleA.y, circleB.x, circleB.y) <= (circleA.radius + circleB.radius)); -}; - -module.exports = CircleToCircle; - - -/***/ }), -/* 845 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Circle by the values given in the `x` and `y` properties of the Point object. - * - * @function Phaser.Geom.Circle.OffsetPoint - * @since 3.0.0 - * - * @generic {Phaser.Geom.Circle} O - [circle,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) - * @param {(Phaser.Geom.Point|object)} point - The Point object containing the values to offset the Circle by. - * - * @return {Phaser.Geom.Circle} The Circle that was offset. - */ -var OffsetPoint = function (circle, point) -{ - circle.x += point.x; - circle.y += point.y; - - return circle; -}; - -module.exports = OffsetPoint; - - -/***/ }), -/* 846 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Offsets the Circle by the values given. - * - * @function Phaser.Geom.Circle.Offset - * @since 3.0.0 - * - * @generic {Phaser.Geom.Circle} O - [circle,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to be offset (translated.) - * @param {number} x - The amount to horizontally offset the Circle by. - * @param {number} y - The amount to vertically offset the Circle by. - * - * @return {Phaser.Geom.Circle} The Circle that was offset. - */ -var Offset = function (circle, x, y) -{ - circle.x += x; - circle.y += y; - - return circle; -}; - -module.exports = Offset; - - -/***/ }), -/* 847 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Rectangle = __webpack_require__(14); - -/** - * Returns the bounds of the Circle object. - * - * @function Phaser.Geom.Circle.GetBounds - * @since 3.0.0 - * - * @generic {Phaser.Geom.Rectangle} O - [out,$return] - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the bounds from. - * @param {(Phaser.Geom.Rectangle|object)} [out] - A Rectangle, or rectangle-like object, to store the circle bounds in. If not given a new Rectangle will be created. - * - * @return {(Phaser.Geom.Rectangle|object)} The Rectangle object containing the Circles bounds. - */ -var GetBounds = function (circle, out) -{ - if (out === undefined) { out = new Rectangle(); } - - out.x = circle.left; - out.y = circle.top; - out.width = circle.diameter; - out.height = circle.diameter; - - return out; -}; - -module.exports = GetBounds; - - -/***/ }), -/* 848 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Compares the `x`, `y` and `radius` properties of the two given Circles. - * Returns `true` if they all match, otherwise returns `false`. - * - * @function Phaser.Geom.Circle.Equals - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The first Circle to compare. - * @param {Phaser.Geom.Circle} toCompare - The second Circle to compare. - * - * @return {boolean} `true` if the two Circles equal each other, otherwise `false`. - */ -var Equals = function (circle, toCompare) -{ - return ( - circle.x === toCompare.x && - circle.y === toCompare.y && - circle.radius === toCompare.radius - ); -}; - -module.exports = Equals; - - -/***/ }), -/* 849 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Copies the `x`, `y` and `radius` properties from the `source` Circle - * into the given `dest` Circle, then returns the `dest` Circle. - * - * @function Phaser.Geom.Circle.CopyFrom - * @since 3.0.0 - * - * @generic {Phaser.Geom.Circle} O - [dest,$return] - * - * @param {Phaser.Geom.Circle} source - The source Circle to copy the values from. - * @param {Phaser.Geom.Circle} dest - The destination Circle to copy the values to. - * - * @return {Phaser.Geom.Circle} The dest Circle. - */ -var CopyFrom = function (source, dest) -{ - return dest.setTo(source.x, source.y, source.radius); -}; - -module.exports = CopyFrom; - - -/***/ }), -/* 850 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(32); - -/** - * Check to see if the Circle contains all four points of the given Rectangle object. - * - * @function Phaser.Geom.Circle.ContainsRect - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle object to check if it's within the Circle or not. - * - * @return {boolean} True if all of the Rectangle coordinates are within the circle, otherwise false. - */ -var ContainsRect = function (circle, rect) -{ - return ( - Contains(circle, rect.x, rect.y) && - Contains(circle, rect.right, rect.y) && - Contains(circle, rect.x, rect.bottom) && - Contains(circle, rect.right, rect.bottom) - ); -}; - -module.exports = ContainsRect; - - -/***/ }), -/* 851 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Contains = __webpack_require__(32); - -/** - * Check to see if the Circle contains the given Point object. - * - * @function Phaser.Geom.Circle.ContainsPoint - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to check. - * @param {(Phaser.Geom.Point|object)} point - The Point object to check if it's within the Circle or not. - * - * @return {boolean} True if the Point coordinates are within the circle, otherwise false. - */ -var ContainsPoint = function (circle, point) -{ - return Contains(circle, point.x, point.y); -}; - -module.exports = ContainsPoint; - - -/***/ }), -/* 852 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(88); - -/** - * Creates a new Circle instance based on the values contained in the given source. - * - * @function Phaser.Geom.Circle.Clone - * @since 3.0.0 - * - * @param {(Phaser.Geom.Circle|object)} source - The Circle to be cloned. Can be an instance of a Circle or a circle-like object, with x, y and radius properties. - * - * @return {Phaser.Geom.Circle} A clone of the source Circle. - */ -var Clone = function (source) -{ - return new Circle(source.x, source.y, source.radius); -}; - -module.exports = Clone; - - -/***/ }), -/* 853 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Calculates the area of the circle. - * - * @function Phaser.Geom.Circle.Area - * @since 3.0.0 - * - * @param {Phaser.Geom.Circle} circle - The Circle to get the area of. - * - * @return {number} The area of the Circle. - */ -var Area = function (circle) -{ - return (circle.radius > 0) ? Math.PI * circle.radius * circle.radius : 0; -}; - -module.exports = Area; - - -/***/ }), -/* 854 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Circle = __webpack_require__(88); - -Circle.Area = __webpack_require__(853); -Circle.Circumference = __webpack_require__(295); -Circle.CircumferencePoint = __webpack_require__(136); -Circle.Clone = __webpack_require__(852); -Circle.Contains = __webpack_require__(32); -Circle.ContainsPoint = __webpack_require__(851); -Circle.ContainsRect = __webpack_require__(850); -Circle.CopyFrom = __webpack_require__(849); -Circle.Equals = __webpack_require__(848); -Circle.GetBounds = __webpack_require__(847); -Circle.GetPoint = __webpack_require__(298); -Circle.GetPoints = __webpack_require__(296); -Circle.Offset = __webpack_require__(846); -Circle.OffsetPoint = __webpack_require__(845); -Circle.Random = __webpack_require__(157); - -module.exports = Circle; - - -/***/ }), -/* 855 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var LightsManager = __webpack_require__(401); -var PluginCache = __webpack_require__(12); - -/** - * @classdesc - * [description] - * - * @class LightsPlugin - * @extends Phaser.GameObjects.LightsManager - * @memberOf Phaser.GameObjects - * @constructor - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - [description] - */ -var LightsPlugin = new Class({ - - Extends: LightsManager, - - initialize: - - function LightsPlugin (scene) - { - /** - * [description] - * - * @name Phaser.GameObjects.LightsPlugin#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene = scene; - - /** - * [description] - * - * @name Phaser.GameObjects.LightsPlugin#systems - * @type {Phaser.Scenes.Systems} - * @since 3.0.0 - */ - this.systems = scene.sys; - - if (!scene.sys.settings.isBooted) - { - scene.sys.events.once('boot', this.boot, this); - } - - LightsManager.call(this); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsPlugin#boot - * @since 3.0.0 - */ - boot: function () - { - var eventEmitter = this.systems.events; - - eventEmitter.on('shutdown', this.shutdown, this); - eventEmitter.on('destroy', this.destroy, this); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.LightsPlugin#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.shutdown(); - - this.scene = undefined; - this.systems = undefined; - } - -}); - -PluginCache.register('LightsPlugin', LightsPlugin, 'lights'); - -module.exports = LightsPlugin; - - -/***/ }), -/* 856 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Quad = __webpack_require__(232); - -/** - * Creates a new Quad Game Object and returns it. - * - * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#quad - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Quad} The Game Object that was created. - */ -GameObjectCreator.register('quad', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var quad = new Quad(this.scene, x, y, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, quad, config); - - return quad; -}); - - -/***/ }), -/* 857 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); -var Mesh = __webpack_require__(145); - -/** - * Creates a new Mesh Game Object and returns it. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#mesh - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Mesh} The Game Object that was created. - */ -GameObjectCreator.register('mesh', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - var vertices = GetValue(config, 'vertices', []); - var colors = GetValue(config, 'colors', []); - var alphas = GetValue(config, 'alphas', []); - var uv = GetValue(config, 'uv', []); - - var mesh = new Mesh(this.scene, 0, 0, vertices, uv, colors, alphas, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, mesh, config); - - return mesh; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 858 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Quad = __webpack_require__(232); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Quad Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Quad Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#quad - * @webglOnly - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Quad} The Game Object that was created. - */ -if (true) -{ - GameObjectFactory.register('quad', function (x, y, key, frame) - { - return this.displayList.add(new Quad(this.scene, x, y, key, frame)); - }); -} - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 859 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Mesh = __webpack_require__(145); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Mesh Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Mesh Game Object and WebGL support have been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#mesh - * @webglOnly - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {float[]} vertices - An array containing the vertices data for this Mesh. - * @param {float[]} uv - An array containing the uv data for this Mesh. - * @param {float[]} colors - An array containing the color data for this Mesh. - * @param {float[]} alphas - An array containing the alpha data for this Mesh. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Mesh} The Game Object that was created. - */ -if (true) -{ - GameObjectFactory.register('mesh', function (x, y, vertices, uv, colors, alphas, texture, frame) - { - return this.displayList.add(new Mesh(this.scene, x, y, vertices, uv, colors, alphas, texture, frame)); - }); -} - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 860 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * This is a stub function for Mesh.Render. There is no Canvas renderer for Mesh objects. - * - * @method Phaser.GameObjects.Mesh#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - */ -var MeshCanvasRenderer = function () -{ -}; - -module.exports = MeshCanvasRenderer; - - -/***/ }), -/* 861 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Mesh#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Mesh} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchMesh(src, camera, parentMatrix); -}; - -module.exports = MeshWebGLRenderer; - - -/***/ }), -/* 862 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(861); -} - -if (true) -{ - renderCanvas = __webpack_require__(860); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 863 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Zone = __webpack_require__(158); - -/** - * Creates a new Zone Game Object and returns it. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#zone - * @since 3.0.0 - * - * @param {object} config - [description] - * - * @return {Phaser.GameObjects.Zone} The Game Object that was created. - */ -GameObjectCreator.register('zone', function (config) -{ - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 1); - var height = GetAdvancedValue(config, 'height', width); - - return new Zone(this.scene, x, y, width, height); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 864 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var TileSprite = __webpack_require__(233); - -/** - * @typedef {object} TileSprite - * @extends GameObjectConfig - * - * @property {number} [x=0] - The x coordinate of the Tile Sprite. - * @property {number} [y=0] - The y coordinate of the Tile Sprite. - * @property {number} [width=512] - The width of the Tile Sprite. - * @property {number} [height=512] - The height of the Tile Sprite. - * @property {string} [key=''] - The key of the Texture this Tile Sprite will use to render with, as stored in the Texture Manager. - * @property {string} [frame=''] - An optional frame from the Texture this Tile Sprite is rendering with. - */ - -/** - * Creates a new TileSprite Game Object and returns it. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#tileSprite - * @since 3.0.0 - * - * @param {TileSprite} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. - */ -GameObjectCreator.register('tileSprite', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 512); - var height = GetAdvancedValue(config, 'height', 512); - var key = GetAdvancedValue(config, 'key', ''); - var frame = GetAdvancedValue(config, 'frame', ''); - - var tile = new TileSprite(this.scene, x, y, width, height, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, tile, config); - - return tile; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 865 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(253); -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetValue = __webpack_require__(4); - -/** - * Creates a new Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#bitmapText - * @since 3.0.0 - * - * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. - */ -GameObjectCreator.register('bitmapText', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var font = GetValue(config, 'font', ''); - var text = GetAdvancedValue(config, 'text', ''); - var size = GetAdvancedValue(config, 'size', false); - - // var align = GetValue(config, 'align', 'left'); - - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, bitmapText, config); - - return bitmapText; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 866 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var BuildGameObjectAnimation = __webpack_require__(127); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var Sprite3D = __webpack_require__(151); - -/** - * Creates a new Sprite3D Game Object and returns it. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#sprite3D - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. - */ -GameObjectCreator.register('sprite3D', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var sprite = new Sprite3D(this.scene, 0, 0, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, sprite, config); - - // Sprite specific config options: - - BuildGameObjectAnimation(sprite, config); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 867 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var RenderTexture = __webpack_require__(234); - -/** - * @typedef {object} RenderTextureConfig - * - * @property {number} [x=0] - The x coordinate of the RenderTexture's position. - * @property {number} [y=0] - The y coordinate of the RenderTexture's position. - * @property {number} [width=32] - The width of the RenderTexture. - * @property {number} [height=32] - The height of the RenderTexture. - */ - -/** - * Creates a new Render Texture Game Object and returns it. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#renderTexture - * @since 3.2.0 - * - * @param {RenderTextureConfig} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. - */ -GameObjectCreator.register('renderTexture', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - var width = GetAdvancedValue(config, 'width', 32); - var height = GetAdvancedValue(config, 'height', 32); - - var renderTexture = new RenderTexture(this.scene, x, y, width, height); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, renderTexture, config); - - return renderTexture; -}); - - -/***/ }), -/* 868 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); -var GetFastValue = __webpack_require__(1); -var ParticleEmitterManager = __webpack_require__(235); - -/** - * Creates a new Particle Emitter Manager Game Object and returns it. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#particles - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. - */ -GameObjectCreator.register('particles', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - var emitters = GetFastValue(config, 'emitters', null); - - // frame is optional and can contain the emitters array or object if skipped - var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - var add = GetFastValue(config, 'add', false); - - if (add) - { - this.displayList.add(manager); - } - - this.updateList.add(manager); - - return manager; -}); - - -/***/ }), -/* 869 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectCreator = __webpack_require__(13); -var Group = __webpack_require__(112); - -/** - * Creates a new Group Game Object and returns it. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#group - * @since 3.0.0 - * - * @param {GroupConfig} config - [description] - * - * @return {Phaser.GameObjects.Group} The Game Object that was created. - */ -GameObjectCreator.register('group', function (config) -{ - return new Group(this.scene, null, config); -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 870 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(250); -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * @typedef {object} BitmapTextConfig - * @extends GameObjectConfig - * - * @property {string} [font=''] - The key of the font to use from the BitmapFont cache. - * @property {string} [text=''] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @property {(number|false)} [size=false] - The font size to set. - */ - -/** - * Creates a new Dynamic Bitmap Text Game Object and returns it. - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#dynamicBitmapText - * @since 3.0.0 - *² - * @param {BitmapTextConfig} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. - */ -GameObjectCreator.register('dynamicBitmapText', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var font = GetAdvancedValue(config, 'font', ''); - var text = GetAdvancedValue(config, 'text', ''); - var size = GetAdvancedValue(config, 'size', false); - - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, bitmapText, config); - - return bitmapText; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 871 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BuildGameObject = __webpack_require__(24); -var Container = __webpack_require__(251); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * Creates a new Container Game Object and returns it. - * - * Note: This method will only be available if the Container Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#container - * @since 3.4.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Container} The Game Object that was created. - */ -GameObjectCreator.register('container', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var x = GetAdvancedValue(config, 'x', 0); - var y = GetAdvancedValue(config, 'y', 0); - - var container = new Container(this.scene, x, y); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, container, config); - - return container; -}); - - -/***/ }), -/* 872 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Blitter = __webpack_require__(252); -var BuildGameObject = __webpack_require__(24); -var GameObjectCreator = __webpack_require__(13); -var GetAdvancedValue = __webpack_require__(10); - -/** - * Creates a new Blitter Game Object and returns it. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectCreator#blitter - * @since 3.0.0 - * - * @param {object} config - The configuration object this Game Object will use to create itself. - * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - * - * @return {Phaser.GameObjects.Blitter} The Game Object that was created. - */ -GameObjectCreator.register('blitter', function (config, addToScene) -{ - if (config === undefined) { config = {}; } - - var key = GetAdvancedValue(config, 'key', null); - var frame = GetAdvancedValue(config, 'frame', null); - - var blitter = new Blitter(this.scene, 0, 0, key, frame); - - if (addToScene !== undefined) - { - config.add = addToScene; - } - - BuildGameObject(this.scene, blitter, config); - - return blitter; -}); - -// When registering a factory function 'this' refers to the GameObjectCreator context. - - -/***/ }), -/* 873 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Zone = __webpack_require__(158); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Zone Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#zone - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * - * @return {Phaser.GameObjects.Zone} The Game Object that was created. - */ -GameObjectFactory.register('zone', function (x, y, width, height) -{ - return this.displayList.add(new Zone(this.scene, x, y, width, height)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 874 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var TileSprite = __webpack_require__(233); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new TileSprite Game Object and adds it to the Scene. - * - * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#tileSprite - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.TileSprite} The Game Object that was created. - */ -GameObjectFactory.register('tileSprite', function (x, y, width, height, key, frame) -{ - return this.displayList.add(new TileSprite(this.scene, x, y, width, height, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 875 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var BitmapText = __webpack_require__(253); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Bitmap Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#bitmapText - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} font - The key of the font to use from the BitmapFont cache. - * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @param {number} [size] - The font size to set. - * - * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. - */ -GameObjectFactory.register('bitmapText', function (x, y, font, text, size) -{ - return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 876 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Sprite3D = __webpack_require__(151); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Sprite3D Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#sprite3D - * @since 3.0.0 - * - * @param {number} x - The horizontal position of this Game Object. - * @param {number} y - The vertical position of this Game Object. - * @param {number} z - The z position of this Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. - */ -GameObjectFactory.register('sprite3D', function (x, y, z, key, frame) -{ - var sprite = new Sprite3D(this.scene, x, y, z, key, frame); - - this.displayList.add(sprite.gameObject); - this.updateList.add(sprite.gameObject); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 877 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(11); -var RenderTexture = __webpack_require__(234); - -/** - * Creates a new Render Texture Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#renderTexture - * @since 3.2.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {integer} [width=32] - The width of the Render Texture. - * @param {integer} [height=32] - The height of the Render Texture. - * - * @return {Phaser.GameObjects.RenderTexture} The Game Object that was created. - */ -GameObjectFactory.register('renderTexture', function (x, y, width, height) -{ - return this.displayList.add(new RenderTexture(this.scene, x, y, width, height)); -}); - - -/***/ }), -/* 878 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(11); -var PathFollower = __webpack_require__(418); - -/** - * Creates a new PathFollower Game Object and adds it to the Scene. - * - * Note: This method will only be available if the PathFollower Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#follower - * @since 3.0.0 - * - * @param {Phaser.Curves.Path} path - The Path this PathFollower is connected to. - * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * - * @return {Phaser.GameObjects.PathFollower} The Game Object that was created. - */ -GameObjectFactory.register('follower', function (path, x, y, key, frame) -{ - var sprite = new PathFollower(this.scene, path, x, y, key, frame); - - this.displayList.add(sprite); - this.updateList.add(sprite); - - return sprite; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 879 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObjectFactory = __webpack_require__(11); -var ParticleEmitterManager = __webpack_require__(235); - -/** - * Creates a new Particle Emitter Manager Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Particles Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#particles - * @since 3.0.0 - * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer|object)} [frame] - [description] - * @param {object} [emitters] - [description] - * - * @return {Phaser.GameObjects.Particles.ParticleEmitterManager} The Game Object that was created. - */ -GameObjectFactory.register('particles', function (key, frame, emitters) -{ - var manager = new ParticleEmitterManager(this.scene, key, frame, emitters); - - this.displayList.add(manager); - this.updateList.add(manager); - - return manager; -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 880 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Group = __webpack_require__(112); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Group Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Group Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#group - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject[]|GroupConfig)} [children] - Game Objects to add to this Group; or the `config` argument. - * @param {GroupConfig} [config] - A Group Configuration object. - * - * @return {Phaser.GameObjects.Group} The Game Object that was created. - */ -GameObjectFactory.register('group', function (children, config) -{ - if (typeof children === 'object' && config === undefined) - { - config = children; - children = []; - } - - return this.updateList.add(new Group(this.scene, children, config)); -}); - - -/***/ }), -/* 881 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var DynamicBitmapText = __webpack_require__(250); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#dynamicBitmapText - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} font - The key of the font to use from the BitmapFont cache. - * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. - * @param {number} [size] - The font size to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} The Game Object that was created. - */ -GameObjectFactory.register('dynamicBitmapText', function (x, y, font, text, size) -{ - return this.displayList.add(new DynamicBitmapText(this.scene, x, y, font, text, size)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 882 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Container = __webpack_require__(251); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Container Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Container Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#container - * @since 3.4.0 - * - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. - * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} [children] - An optional array of Game Objects to add to this Container. - * - * @return {Phaser.GameObjects.Container} The Game Object that was created. - */ -GameObjectFactory.register('container', function (x, y, children) -{ - return this.displayList.add(new Container(this.scene, x, y, children)); -}); - - -/***/ }), -/* 883 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Blitter = __webpack_require__(252); -var GameObjectFactory = __webpack_require__(11); - -/** - * Creates a new Blitter Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Blitter Game Object has been built into Phaser. - * - * @method Phaser.GameObjects.GameObjectFactory#blitter - * @since 3.0.0 - * - * @param {number} x - The x position of the Game Object. - * @param {number} y - The y position of the Game Object. - * @param {string} key - The key of the Texture the Blitter object will use. - * @param {(string|integer)} [frame] - The default Frame children of the Blitter will use. - * - * @return {Phaser.GameObjects.Blitter} The Game Object that was created. - */ -GameObjectFactory.register('blitter', function (x, y, key, frame) -{ - return this.displayList.add(new Blitter(this.scene, x, y, key, frame)); -}); - -// When registering a factory function 'this' refers to the GameObjectFactory context. -// -// There are several properties available to use: -// -// this.scene - a reference to the Scene that owns the GameObjectFactory -// this.displayList - a reference to the Display List the Scene owns -// this.updateList - a reference to the Update List the Scene owns - - -/***/ }), -/* 884 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.TileSprite#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - var frame = src.frame; - - src.updateTileTexture(); - - // Blend Mode - - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var dx = frame.x - (src.originX * src.width); - var dy = frame.y - (src.originY * src.height); - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - var fx = 1; - var fy = 1; - - // Flipping - - if (src.flipX) - { - fx = -1; - dx += src.width; - } - - if (src.flipY) - { - fy = -1; - dy += src.height; - } - - if (renderer.config.roundPixels) - { - dx |= 0; - dy |= 0; - tx |= 0; - ty |= 0; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(dx, dy); - - ctx.translate(tx, ty); - - // Flip - ctx.scale(fx, fy); - - // Rotate and scale around center - ctx.translate((src.originX * src.width), (src.originY * src.height)); - ctx.rotate(fx * fy * src.rotation); - ctx.scale(this.scaleX, this.scaleY); - ctx.translate(-(src.originX * src.width), -(src.originY * src.height)); - - // Draw - ctx.translate(-this.tilePositionX, -this.tilePositionY); - ctx.fillStyle = src.canvasPattern; - ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width, src.height); - - ctx.restore(); -}; - -module.exports = TileSpriteCanvasRenderer; - - -/***/ }), -/* 885 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.TileSprite#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.TileSprite} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - src.updateTileTexture(); - - this.pipeline.batchTileSprite(this, camera, parentMatrix); -}; - -module.exports = TileSpriteWebGLRenderer; - - -/***/ }), -/* 886 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(885); -} - -if (true) -{ - renderCanvas = __webpack_require__(884); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 887 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetValue = __webpack_require__(4); - -/** - * Parses a Retro Font configuration object so you can pass it to the BitmapText constructor - * and create a BitmapText object using a fixed-width retro font. - * - * @function Phaser.GameObjects.RetroFont.Parse - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - A reference to the Phaser Scene. - * @param {Phaser.GameObjects.RetroFont.Config} config - The font configuration object. - * - * @return {object} A parsed Bitmap Font data entry for the Bitmap Font cache. - */ -var ParseRetroFont = function (scene, config) -{ - var w = config.width; - var h = config.height; - var cx = Math.floor(w / 2); - var cy = Math.floor(h / 2); - var letters = GetValue(config, 'chars', ''); - - if (letters === '') - { - return; - } - - var key = GetValue(config, 'image', ''); - var offsetX = GetValue(config, 'offset.x', 0); - var offsetY = GetValue(config, 'offset.y', 0); - var spacingX = GetValue(config, 'spacing.x', 0); - var spacingY = GetValue(config, 'spacing.y', 0); - - var charsPerRow = GetValue(config, 'charsPerRow', null); - - if (charsPerRow === null) - { - charsPerRow = scene.sys.textures.getFrame(key).width / w; - - if (charsPerRow > letters.length) - { - charsPerRow = letters.length; - } - } - - var x = offsetX; - var y = offsetY; - - var data = { - retroFont: true, - font: key, - size: w, - lineHeight: h, - chars: {} - }; - - var r = 0; - - for (var i = 0; i < letters.length; i++) - { - // var node = letters[i]; - - var charCode = letters.charCodeAt(i); - - data.chars[charCode] = - { - x: x, - y: y, - width: w, - height: h, - centerX: cx, - centerY: cy, - xOffset: 0, - yOffset: 0, - xAdvance: w, - data: {}, - kerning: {} - }; - - r++; - - if (r === charsPerRow) - { - r = 0; - x = offsetX; - y += h + spacingY; - } - else - { - x += w + spacingX; - } - } - - var entry = { - data: data, - frame: null, - texture: key - }; - - return entry; -}; - -module.exports = ParseRetroFont; - - -/***/ }), -/* 888 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RETRO_FONT_CONST = { - - /** - * Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET1 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET1: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~', - - /** - * Text Set 2 = !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET2 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET2: ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ', - - /** - * Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET3 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET3: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ', - - /** - * Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET4 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET4: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789', - - /** - * Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET5 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET5: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() \'!?-*:0123456789', - - /** - * Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.' - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET6 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET6: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789"(),-.\' ', - - /** - * Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-'39 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET7 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET7: 'AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW")28FLRX-\'39', - - /** - * Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET8 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET8: '0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ', - - /** - * Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'"?! - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET9 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET9: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,\'"?!', - - /** - * Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET10 - * @type {string} - * @since 3.6.0 - */ - TEXT_SET10: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', - - /** - * Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()':;0123456789 - * - * @name Phaser.GameObjects.RetroFont.TEXT_SET11 - * @since 3.6.0 - * @type {string} - */ - TEXT_SET11: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.,"-+!?()\':;0123456789' - -}; - -module.exports = RETRO_FONT_CONST; - - -/***/ }), -/* 889 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var RETRO_FONT_CONST = __webpack_require__(888); -var Extend = __webpack_require__(17); - -/** - * @typedef {object} Phaser.GameObjects.RetroFont.Config - * - * @property {string} image - The key of the image containing the font. - * @property {number} offset.x - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here. - * @property {number} offset.y - If the font set doesn't start at the top left of the given image, specify the Y coordinate offset here. - * @property {number} width - The width of each character in the font set. - * @property {number} height - The height of each character in the font set. - * @property {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements. - * @property {number} charsPerRow - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. - * @property {number} spacing.x - If the characters in the font set have horizontal spacing between them set the required amount here. - * @property {number} spacing.y - If the characters in the font set have vertical spacing between them set the required amount here. -*/ - -/** - * @namespace Phaser.GameObjects.RetroFont - * @since 3.6.0 - */ - -var RetroFont = { Parse: __webpack_require__(887) }; - -// Merge in the consts -RetroFont = Extend(false, RetroFont, RETRO_FONT_CONST); - -module.exports = RetroFont; - - -/***/ }), -/* 890 */ -/***/ (function(module, exports) { - -var RenderTextureWebGL = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, 1); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - clear: function () - { - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - draw: function (texture, frame, x, y) - { - 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.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; - } - -}; - -module.exports = RenderTextureWebGL; - - -/***/ }), -/* 891 */ -/***/ (function(module, exports) { - -var RenderTextureCanvas = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; - this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); - - return this; - }, - - clear: function () - { - this.context.save(); - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); - this.context.restore(); - - return this; - }, - - draw: function (texture, frame, x, y) - { - var cd = frame.canvasData; - var source = frame.source.image; - - var matrix = this.currentMatrix; - - this.context.globalAlpha = this.globalAlpha; - this.context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - this.context.drawImage(source, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); - - return this; - } - -}; - -module.exports = RenderTextureCanvas; - - -/***/ }), -/* 892 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.RenderTexture#renderCanvas - * @since 3.2.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - - if (renderer.currentBlendMode !== renderTexture.blendMode) - { - renderer.currentBlendMode = renderTexture.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; - } - - if (renderer.currentAlpha !== renderTexture.alpha) - { - renderer.currentAlpha = renderTexture.alpha; - ctx.globalAlpha = renderTexture.alpha; - } - - if (renderer.currentScaleMode !== renderTexture.scaleMode) - { - renderer.currentScaleMode = renderTexture.scaleMode; - } - - var dx = 0; - var dy = 0; - - var fx = 1; - var fy = 1; - - if (renderTexture.flipX) - { - fx = -1; - dx -= renderTexture.canvas.width - renderTexture.displayOriginX; - } - else - { - dx -= renderTexture.displayOriginX; - } - - if (renderTexture.flipY) - { - fy = -1; - dy -= renderTexture.canvas.height - renderTexture.displayOriginY; - } - else - { - dy -= renderTexture.displayOriginY; - } - - ctx.save(); - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY); - ctx.rotate(renderTexture.rotation); - ctx.scale(renderTexture.scaleX, renderTexture.scaleY); - ctx.scale(fx, fy); - ctx.drawImage(renderTexture.canvas, dx, dy); - ctx.restore(); -}; - -module.exports = RenderTextureCanvasRenderer; - - -/***/ }), -/* 893 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); -var Utils = __webpack_require__(27); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.RenderTexture#renderWebgl - * @since 3.2.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchTexture( - renderTexture, - renderTexture.texture, - renderTexture.texture.width, renderTexture.texture.height, - renderTexture.x, renderTexture.y, - renderTexture.width, renderTexture.height, - renderTexture.scaleX, renderTexture.scaleY, - renderTexture.rotation, - renderTexture.flipX, !renderTexture.flipY, - renderTexture.scrollFactorX, renderTexture.scrollFactorY, - renderTexture.displayOriginX, renderTexture.displayOriginY, - 0, 0, renderTexture.texture.width, renderTexture.texture.height, - Utils.getTintAppendFloatAlpha(renderTexture.tintTopLeft, renderTexture.alphaTopLeft), Utils.getTintAppendFloatAlpha(renderTexture.tintTopRight, renderTexture.alphaTopRight), Utils.getTintAppendFloatAlpha(renderTexture.tintBottomLeft, renderTexture.alphaBottomLeft), Utils.getTintAppendFloatAlpha(renderTexture.tintBottomRight, renderTexture.alphaBottomRight), - 0, 0, - camera, - parentMatrix - ); -}; - -module.exports = RenderTextureWebGLRenderer; - - -/***/ }), -/* 894 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(893); -} - -if (true) -{ - renderCanvas = __webpack_require__(892); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 895 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects.Particles.Zones - */ - -module.exports = { - - DeathZone: __webpack_require__(455), - EdgeZone: __webpack_require__(454), - RandomZone: __webpack_require__(419) - -}; - - -/***/ }), -/* 896 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Particles.EmitterManager#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) -{ - var emitters = emitterManager.emitters.list; - - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - - ctx.save(); - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - - var particles = emitter.alive; - var length = particles.length; - - if (!emitter.visible || length === 0) - { - continue; - } - - - var lastAlpha = ctx.globalAlpha; - var cameraScrollX = camera.scrollX * emitter.scrollFactorX; - var cameraScrollY = camera.scrollY * emitter.scrollFactorY; - - if (renderer.currentBlendMode !== emitter.blendMode) - { - renderer.currentBlendMode = emitter.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; - } - - var roundPixels = renderer.config.roundPixels; - - for (var index = 0; index < length; ++index) - { - var particle = particles[index]; - - var alpha = ((particle.color >> 24) & 0xFF) / 255.0; - - if (alpha <= 0) - { - continue; - } - - var frame = particle.frame; - var width = frame.width; - var height = frame.height; - var ox = width * 0.5; - var oy = height * 0.5; - var cd = frame.canvasData; - - var x = -ox; - var y = -oy; - - var tx = particle.x - cameraScrollX; - var ty = particle.y - cameraScrollY; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.globalAlpha = alpha; - - ctx.save(); - - ctx.translate(tx, ty); - - ctx.rotate(particle.rotation); - - ctx.scale(particle.scaleX, particle.scaleY); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); - - ctx.restore(); - } - - ctx.globalAlpha = lastAlpha; - } - - ctx.restore(); -}; - -module.exports = ParticleManagerCanvasRenderer; - - -/***/ }), -/* 897 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Particles.EmitterManager#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) -{ - var emitters = emitterManager.emitters; - - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.drawEmitterManager(emitterManager, camera, parentMatrix); -}; - -module.exports = ParticleManagerWebGLRenderer; - - -/***/ }), -/* 898 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(897); -} - -if (true) -{ - renderCanvas = __webpack_require__(896); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 899 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); -var FloatBetween = __webpack_require__(248); -var GetEaseFunction = __webpack_require__(63); -var GetFastValue = __webpack_require__(1); -var Wrap = __webpack_require__(39); - -/** - * The returned value sets what the property will be at the START of the particle's life, on emit. - * @callback EmitterOpOnEmitCallback - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. - * @param {string} key - The name of the property. - * @param {number} value - The current value of the property. - * - * @return {number} The new value of the property. - */ - -/** - * The returned value updates the property for the duration of the particle's life. - * @callback EmitterOpOnUpdateCallback - * - * @param {Phaser.GameObjects.Particles.Particle} particle - The particle. - * @param {string} key - The name of the property. - * @param {float} t - The normalized lifetime of the particle, between 0 (start) and 1 (end). - * @param {number} value - The current value of the property. - * - * @return {number} The new value of the property. - */ - -/** - * Defines an operation yielding a random value within a range. - * @typedef {object} EmitterOpRandomConfig - * - * @property {float[]} random - The minimum and maximum values, as [min, max]. - */ - -/** - * Defines an operation yielding a random value within a range. - * @typedef {object} EmitterOpRandomMinMaxConfig - * - * @property {float} min - The minimum value. - * @property {float} max - The maximum value. - */ - -/** - * Defines an operation yielding a random value within a range. - * @typedef {object} EmitterOpRandomStartEndConfig - * - * @property {float} start - The starting value. - * @property {float} end - The ending value. - * @property {boolean} random - If false, this becomes {@link EmitterOpEaseConfig}. - */ - -/** - * Defines an operation yielding a value incremented continuously across a range. - * @typedef {object} EmitterOpEaseConfig - * - * @property {float} start - The starting value. - * @property {float} end - The ending value. - * @property {string} [ease='Linear'] - The name of the easing function. - */ - -/** - * Defines an operation yielding a value incremented by steps across a range. - * @typedef {object} EmitterOpSteppedConfig - * - * @property {number} start - The starting value. - * @property {number} end - The ending value. - * @property {number} steps - The number of steps between start and end. - */ - -/** - * @typedef {object} EmitterOpCustomEmitConfig - * - * @property {EmitterOpOnEmitCallback} onEmit - [description] - */ - -/** - * @typedef {object} EmitterOpCustomUpdateConfig - * - * @property {EmitterOpOnEmitCallback} [onEmit] - [description] - * @property {EmitterOpOnUpdateCallback} onUpdate - [description] - */ - -/** - * @classdesc - * [description] - * - * @class EmitterOp - * @memberOf Phaser.GameObjects.Particles - * @constructor - * @since 3.0.0 - * - * @param {object} config - [description] - * @param {string} key - [description] - * @param {number} defaultValue - [description] - * @param {boolean} [emitOnly=false] - [description] - */ -var EmitterOp = new Class({ - - initialize: - - function EmitterOp (config, key, defaultValue, emitOnly) - { - if (emitOnly === undefined) - { - emitOnly = false; - } - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#propertyKey - * @type {string} - * @since 3.0.0 - */ - this.propertyKey = key; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#propertyValue - * @type {number} - * @since 3.0.0 - */ - this.propertyValue = defaultValue; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#defaultValue - * @type {number} - * @since 3.0.0 - */ - this.defaultValue = defaultValue; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#steps - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.steps = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#counter - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.counter = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#start - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.start = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#end - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.end = 0; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#ease - * @type {?function} - * @since 3.0.0 - */ - this.ease; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#emitOnly - * @type {boolean} - * @since 3.0.0 - */ - this.emitOnly = emitOnly; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#onEmit - * @type {EmitterOpOnEmitCallback} - * @since 3.0.0 - */ - this.onEmit = this.defaultEmit; - - /** - * [description] - * - * @name Phaser.GameObjects.Particles.EmitterOp#onUpdate - * @type {EmitterOpOnUpdateCallback} - * @since 3.0.0 - */ - this.onUpdate = this.defaultUpdate; - - this.loadConfig(config); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#loadConfig - * @since 3.0.0 - * - * @param {object} [config] - [description] - * @param {string} [newKey] - [description] - */ - loadConfig: function (config, newKey) - { - if (config === undefined) - { - config = {}; - } - - if (newKey) - { - this.propertyKey = newKey; - } - - this.propertyValue = GetFastValue( - config, - this.propertyKey, - this.defaultValue - ); - - this.setMethods(); - - if (this.emitOnly) - { - // Reset it back again - this.onUpdate = this.defaultUpdate; - } - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#toJSON - * @since 3.0.0 - * - * @return {object} [description] - */ - toJSON: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#onChange - * @since 3.0.0 - * - * @param {number} value - [description] - * - * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. - */ - onChange: function (value) - { - this.propertyValue = value; - - return this.setMethods(); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#setMethods - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Particles.EmitterOp} This Emitter Op object. - */ - setMethods: function () - { - var value = this.propertyValue; - - var t = typeof value; - - if (t === 'number') - { - // Explicit static value: - // x: 400 - - this.onEmit = this.staticValueEmit; - this.onUpdate = this.staticValueUpdate; // How? - } - else if (Array.isArray(value)) - { - // Picks a random element from the array: - // x: [ 100, 200, 300, 400 ] - - this.onEmit = this.randomStaticValueEmit; - } - else if (t === 'function') - { - // The same as setting just the onUpdate function and no onEmit (unless this op is an emitOnly one) - // Custom callback, must return a value: - - /* - x: function (particle, key, t, value) - { - return value + 50; - } - */ - - if (this.emitOnly) - { - this.onEmit = value; - } - else - { - this.onUpdate = value; - } - } - else if (t === 'object' && (this.has(value, 'random') || this.hasBoth(value, 'start', 'end') || this.hasBoth(value, 'min', 'max'))) - { - this.start = this.has(value, 'start') ? value.start : value.min; - this.end = this.has(value, 'end') ? value.end : value.max; - - var isRandom = (this.hasBoth(value, 'min', 'max') || this.has(value, 'random')); - - // A random starting value (using 'min | max' instead of 'start | end' automatically implies a random value) - - // x: { start: 100, end: 400, random: true } OR { min: 100, max: 400 } OR { random: [ 100, 400 ] } - - if (isRandom) - { - var rnd = value.random; - - // x: { random: [ 100, 400 ] } = the same as doing: x: { start: 100, end: 400, random: true } - if (Array.isArray(rnd)) - { - this.start = rnd[0]; - this.end = rnd[1]; - } - - this.onEmit = this.randomRangedValueEmit; - } - - if (this.has(value, 'steps')) - { - // A stepped (per emit) range - - // x: { start: 100, end: 400, steps: 64 } - - // Increments a value stored in the emitter - - this.steps = value.steps; - this.counter = this.start; - - this.onEmit = this.steppedEmit; - } - else - { - // An eased range (defaults to Linear if not specified) - - // x: { start: 100, end: 400, [ ease: 'Linear' ] } - - var easeType = this.has(value, 'ease') ? value.ease : 'Linear'; - - this.ease = GetEaseFunction(easeType); - - if (!isRandom) - { - this.onEmit = this.easedValueEmit; - } - - // BUG: alpha, rotate, scaleX, scaleY, or tint are eased here if {min, max} is given. - // Probably this branch should exclude isRandom entirely. - - this.onUpdate = this.easeValueUpdate; - } - } - else if (t === 'object' && this.hasEither(value, 'onEmit', 'onUpdate')) - { - // Custom onEmit and onUpdate callbacks - - /* - x: { - // Called at the start of the particles life, when it is being created - onEmit: function (particle, key, t, value) - { - return value; - }, - - // Called during the particles life on each update - onUpdate: function (particle, key, t, value) - { - return value; - } - } - */ - - if (this.has(value, 'onEmit')) - { - this.onEmit = value.onEmit; - } - - if (this.has(value, 'onUpdate')) - { - this.onUpdate = value.onUpdate; - } - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#has - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key - [description] - * - * @return {boolean} [description] - */ - has: function (object, key) - { - return object.hasOwnProperty(key); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#hasBoth - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key1 - [description] - * @param {string} key2 - [description] - * - * @return {boolean} [description] - */ - hasBoth: function (object, key1, key2) - { - return object.hasOwnProperty(key1) && object.hasOwnProperty(key2); - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#hasEither - * @since 3.0.0 - * - * @param {object} object - [description] - * @param {string} key1 - [description] - * @param {string} key2 - [description] - * - * @return {boolean} [description] - */ - hasEither: function (object, key1, key2) - { - return object.hasOwnProperty(key1) || object.hasOwnProperty(key2); - }, - - /** - * The returned value sets what the property will be at the START of the particles life, on emit. - * - * @method Phaser.GameObjects.Particles.EmitterOp#defaultEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {number} value - [description] - * - * @return {number} [description] - */ - defaultEmit: function (particle, key, value) - { - return value; - }, - - /** - * The returned value updates the property for the duration of the particles life. - * - * @method Phaser.GameObjects.Particles.EmitterOp#defaultUpdate - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {float} t - The T value (between 0 and 1) - * @param {number} value - [description] - * - * @return {number} [description] - */ - defaultUpdate: function (particle, key, t, value) - { - return value; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#staticValueEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - staticValueEmit: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#staticValueUpdate - * @since 3.0.0 - * - * @return {number} [description] - */ - staticValueUpdate: function () - { - return this.propertyValue; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#randomStaticValueEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - randomStaticValueEmit: function () - { - var randomIndex = Math.floor(Math.random() * this.propertyValue.length); - - return this.propertyValue[randomIndex]; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#randomRangedValueEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * - * @return {number} [description] - */ - randomRangedValueEmit: function (particle, key) - { - var value = FloatBetween(this.start, this.end); - - if (particle && particle.data[key]) - { - particle.data[key].min = value; - } - - return value; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#steppedEmit - * @since 3.0.0 - * - * @return {number} [description] - */ - steppedEmit: function () - { - var current = this.counter; - - var next = this.counter + (this.end - this.start) / this.steps; - - this.counter = Wrap(next, this.start, this.end); - - return current; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#easedValueEmit - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * - * @return {number} [description] - */ - easedValueEmit: function (particle, key) - { - if (particle && particle.data[key]) - { - var data = particle.data[key]; - - data.min = this.start; - data.max = this.end; - } - - return this.start; - }, - - /** - * [description] - * - * @method Phaser.GameObjects.Particles.EmitterOp#easeValueUpdate - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.Particle} particle - [description] - * @param {string} key - [description] - * @param {float} t - The T value (between 0 and 1) - * - * @return {number} [description] - */ - easeValueUpdate: function (particle, key, t) - { - var data = particle.data[key]; - - return (data.max - data.min) * this.ease(t) + data.min; - } -}); - -module.exports = EmitterOp; - - -/***/ }), -/* 900 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects.Particles - */ - -module.exports = { - - GravityWell: __webpack_require__(458), - Particle: __webpack_require__(457), - ParticleEmitter: __webpack_require__(456), - ParticleEmitterManager: __webpack_require__(235), - Zones: __webpack_require__(895) - -}; - - -/***/ }), -/* 901 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.DynamicBitmapText#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - var text = src.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var textureFrame = src.frame; - - var displayCallback = src.displayCallback; - - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; - - var xAdvance = 0; - var yAdvance = 0; - - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - var ctx = renderer.currentContext; - var image = src.frame.source.image; - - var textureX = textureFrame.cutX; - var textureY = textureFrame.cutY; - - var rotation = 0; - var scale = (src.fontSize / src.fontData.size); - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(src.x, src.y); - - ctx.rotate(src.rotation); - - ctx.translate(-src.displayOriginX, -src.displayOriginY); - - ctx.scale(src.scaleX, src.scaleY); - - if (src.cropWidth > 0 && src.cropHeight > 0) - { - ctx.save(); - ctx.beginPath(); - ctx.rect(0, 0, src.cropWidth, src.cropHeight); - ctx.clip(); - } - - var roundPixels = renderer.config.roundPixels; - - for (var index = 0; index < textLength; ++index) - { - // Reset the scale (in case the callback changed it) - scale = (src.fontSize / src.fontData.size); - rotation = 0; - - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) - src.scrollX; - y = (glyph.yOffset + yAdvance) - src.scrollY; - - // This could be optimized so that it doesn't even bother drawing it if the x/y is out of range - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - if (displayCallback) - { - var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); - - x = output.x; - y = output.y; - scale = output.scale; - rotation = output.rotation; - } - - x *= scale; - y *= scale; - - x -= cameraScrollX; - y -= cameraScrollY; - - if (roundPixels) - { - x |= 0; - y |= 0; - } - - ctx.save(); - - ctx.translate(x, y); - - ctx.rotate(rotation); - - ctx.scale(scale, scale); - - ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); - - ctx.restore(); - - xAdvance += glyph.xAdvance; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - } - - if (src.cropWidth > 0 && src.cropHeight > 0) - { - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = DynamicBitmapTextCanvasRenderer; - - -/***/ }), -/* 902 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.DynamicBitmapText#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.DynamicBitmapText} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolationPercentage, camera, parentMatrix) -{ - var text = bitmapText.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== bitmapText.renderFlags || textLength === 0 || (bitmapText.cameraFilter > 0 && (bitmapText.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchDynamicBitmapText(bitmapText, camera, parentMatrix); -}; - -module.exports = DynamicBitmapTextWebGLRenderer; - - -/***/ }), -/* 903 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(902); -} - -if (true) -{ - renderCanvas = __webpack_require__(901); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 904 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Container#renderCanvas - * @since 3.4.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ContainerCanvasRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== container.renderFlags || (container.cameraFilter > 0 && (container.cameraFilter & camera._id))) - { - return; - } - - var children = container.list; - var transformMatrix = container.localTransform; - - if (parentMatrix === undefined) - { - transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); - } - else - { - transformMatrix.loadIdentity(); - transformMatrix.multiply(parentMatrix); - transformMatrix.translate(container.x, container.y); - transformMatrix.rotate(container.rotation); - transformMatrix.scale(container.scaleX, container.scaleY); - } - - var alpha = container._alpha; - var scrollFactorX = container.scrollFactorX; - var scrollFactorY = container.scrollFactorY; - - for (var index = 0; index < children.length; ++index) - { - var child = children[index]; - var childAlpha = child._alpha; - var childScrollFactorX = child.scrollFactorX; - var childScrollFactorY = child.scrollFactorY; - - child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); - child.setAlpha(childAlpha * alpha); - child.renderCanvas(renderer, child, interpolationPercentage, camera, transformMatrix); - child.setAlpha(childAlpha); - child.setScrollFactor(childScrollFactorX, childScrollFactorY); - } -}; - -module.exports = ContainerCanvasRenderer; - - -/***/ }), -/* 905 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Container#renderWebGL - * @since 3.4.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Container} container - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var ContainerWebGLRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== container.renderFlags || (container.cameraFilter > 0 && (container.cameraFilter & camera._id))) - { - return; - } - - var children = container.list; - var transformMatrix = container.localTransform; - - if (parentMatrix === undefined) - { - transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); - } - else - { - transformMatrix.loadIdentity(); - transformMatrix.multiply(parentMatrix); - transformMatrix.translate(container.x, container.y); - transformMatrix.rotate(container.rotation); - transformMatrix.scale(container.scaleX, container.scaleY); - } - - var alpha = container._alpha; - var scrollFactorX = container.scrollFactorX; - var scrollFactorY = container.scrollFactorY; - - for (var index = 0; index < children.length; ++index) - { - var child = children[index]; - var childAlpha = child._alpha; - var childScrollFactorX = child.scrollFactorX; - var childScrollFactorY = child.scrollFactorY; - - child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); - child.setAlpha(childAlpha * alpha); - child.renderWebGL(renderer, child, interpolationPercentage, camera, transformMatrix); - child.setAlpha(childAlpha); - child.setScrollFactor(childScrollFactorX, childScrollFactorY); - } -}; - -module.exports = ContainerWebGLRenderer; - - -/***/ }), -/* 906 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(905); -} - -if (true) -{ - renderCanvas = __webpack_require__(904); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 907 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = __webpack_require__(0); - -/** - * @classdesc - * A Bob Game Object. - * - * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. - * - * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle - * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it - * must be a Frame within the Texture used by the parent Blitter. - * - * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will - * have their positions impacted by this change as well. - * - * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be - * handled via the Blitter parent. - * - * @class Bob - * @memberOf Phaser.GameObjects.Blitter - * @constructor - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - The parent Blitter object is responsible for updating this Bob. - * @param {number} x - The horizontal position of this Game Object in the world, relative to the parent Blitter position. - * @param {number} y - The vertical position of this Game Object in the world, relative to the parent Blitter position. - * @param {(string|integer)} frame - The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. - * @param {boolean} visible - Should the Bob render visible or not to start with? - */ -var Bob = new Class({ - - initialize: - - function Bob (blitter, x, y, frame, visible) - { - /** - * The Blitter object that this Bob belongs to. - * - * @name Phaser.GameObjects.Blitter.Bob#parent - * @type {Phaser.GameObjects.Blitter} - * @since 3.0.0 - */ - this.parent = blitter; - - /** - * The x position of this Bob, relative to the x position of the Blitter. - * - * @name Phaser.GameObjects.Blitter.Bob#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of this Bob, relative to the y position of the Blitter. - * - * @name Phaser.GameObjects.Blitter.Bob#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The frame that the Bob uses to render with. - * To change the frame use the `Bob.setFrame` method. - * - * @name Phaser.GameObjects.Blitter.Bob#frame - * @type {Phaser.Textures.Frame} - * @protected - * @since 3.0.0 - */ - this.frame = frame; - - /** - * A blank object which can be used to store data related to this Bob in. - * - * @name Phaser.GameObjects.Blitter.Bob#data - * @type {object} - * @default {} - * @since 3.0.0 - */ - this.data = {}; - - /** - * The visible state of this Bob. - * - * @name Phaser.GameObjects.Blitter.Bob#_visible - * @type {boolean} - * @private - * @since 3.0.0 - */ - this._visible = visible; - - /** - * The alpha value of this Bob. - * - * @name Phaser.GameObjects.Blitter.Bob#_alpha - * @type {number} - * @private - * @default 1 - * @since 3.0.0 - */ - this._alpha = 1; - - /** - * The horizontally flipped state of the Bob. - * A Bob that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture. - * - * @name Phaser.GameObjects.Blitter.Bob#flipX - * @type {boolean} - * @since 3.0.0 - */ - this.flipX = false; - - /** - * The vertically flipped state of the Bob. - * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture. - * - * @name Phaser.GameObjects.Blitter.Bob#flipY - * @type {boolean} - * @since 3.0.0 - */ - this.flipY = false; - }, - - /** - * Changes the Texture Frame being used by this Bob. - * The frame must be part of the Texture the parent Blitter is using. - * If no value is given it will use the default frame of the Blitter parent. - * - * @method Phaser.GameObjects.Blitter.Bob#setFrame - * @since 3.0.0 - * - * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The frame to be used during rendering. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFrame: function (frame) - { - if (frame === undefined) - { - frame = this.parent.frame; - } - else - { - frame = this.parent.texture.get(frame); - } - - return this; - }, - - /** - * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. - * - * @method Phaser.GameObjects.Blitter.Bob#resetFlip - * @since 3.0.0 - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - resetFlip: function () - { - this.flipX = false; - this.flipY = false; - - return this; - }, - - /** - * Resets this Bob. - * - * Changes the position to the values given, and optionally changes the frame. - * - * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. - * - * @method Phaser.GameObjects.Blitter.Bob#reset - * @since 3.0.0 - * - * @param {number} x - The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {number} y - The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param {(string|integer|Phaser.Textures.Frame)} [frame] - The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - reset: function (x, y, frame) - { - this.x = x; - this.y = y; - - this.flipX = false; - this.flipY = false; - - this._alpha = 1; - this._visible = true; - - this.parent.dirty = true; - - if (frame) - { - this.setFrame(frame); - } - - return this; - }, - - /** - * Sets the horizontal flipped state of this Bob. - * - * @method Phaser.GameObjects.Blitter.Bob#setFlipX - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlipX: function (value) - { - this.flipX = value; - - return this; - }, - - /** - * Sets the vertical flipped state of this Bob. - * - * @method Phaser.GameObjects.Blitter.Bob#setFlipY - * @since 3.0.0 - * - * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlipY: function (value) - { - this.flipY = value; - - return this; - }, - - /** - * Sets the horizontal and vertical flipped state of this Bob. - * - * @method Phaser.GameObjects.Blitter.Bob#setFlip - * @since 3.0.0 - * - * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setFlip: function (x, y) - { - this.flipX = x; - this.flipY = y; - - return this; - }, - - /** - * Sets the visibility of this Bob. - * - * An invisible Bob will skip rendering. - * - * @method Phaser.GameObjects.Blitter.Bob#setVisible - * @since 3.0.0 - * - * @param {boolean} value - The visible state of the Game Object. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - - /** - * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * A Bob with alpha 0 will skip rendering. - * - * @method Phaser.GameObjects.Blitter.Bob#setAlpha - * @since 3.0.0 - * - * @param {float} value - The alpha value used for this Bob. Between 0 and 1. - * - * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. - */ - setAlpha: function (value) - { - this.alpha = value; - - return this; - }, - - /** - * Destroys this Bob instance. - * Removes itself from the Blitter and clears the parent, frame and data properties. - * - * @method Phaser.GameObjects.Blitter.Bob#destroy - * @since 3.0.0 - */ - destroy: function () - { - this.parent.dirty = true; - - this.parent.children.remove(this); - - this.parent = undefined; - this.frame = undefined; - this.data = undefined; - }, - - /** - * The visible state of the Bob. - * - * An invisible Bob will skip rendering. - * - * @name Phaser.GameObjects.Blitter.Bob#visible - * @type {boolean} - * @since 3.0.0 - */ - visible: { - - get: function () - { - return this._visible; - }, - - set: function (value) - { - this._visible = value; - this.parent.dirty = true; - } - - }, - - /** - * The alpha value of the Bob, between 0 and 1. - * - * A Bob with alpha 0 will skip rendering. - * - * @name Phaser.GameObjects.Blitter.Bob#alpha - * @type {number} - * @since 3.0.0 - */ - alpha: { - - get: function () - { - return this._alpha; - }, - - set: function (value) - { - this._alpha = value; - this.parent.dirty = true; - } - - } - -}); - -module.exports = Bob; - - -/***/ }), -/* 908 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Blitter#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var list = src.getRenderList(); - - renderer.setBlendMode(src.blendMode); - - var ctx = renderer.gameContext; - var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; - var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - // Render bobs - for (var i = 0; i < list.length; i++) - { - var bob = list[i]; - var flip = (bob.flipX || bob.flipY); - var frame = bob.frame; - var cd = frame.canvasData; - var dx = frame.x; - var dy = frame.y; - var fx = 1; - var fy = 1; - - if (!flip) - { - renderer.blitImage(dx + bob.x + cameraScrollX, dy + bob.y + cameraScrollY, bob.frame); - } - else - { - if (bob.flipX) - { - fx = -1; - dx -= cd.dWidth; - } - - if (bob.flipY) - { - fy = -1; - dy -= cd.dHeight; - } - - ctx.save(); - ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); - ctx.scale(fx, fy); - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - ctx.restore(); - } - } - - ctx.restore(); -}; - -module.exports = BlitterCanvasRenderer; - - -/***/ }), -/* 909 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.Blitter#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Blitter} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var BlitterWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera, parentMatrix) -{ - if (GameObject.RENDER_MASK !== gameObject.renderFlags || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.drawBlitter(gameObject, camera, parentMatrix); -}; - -module.exports = BlitterWebGLRenderer; - - -/***/ }), -/* 910 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(909); -} - -if (true) -{ - renderCanvas = __webpack_require__(908); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 911 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the Canvas Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.BitmapText#renderCanvas - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) -{ - var text = src.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) - { - return; - } - - var textureFrame = src.frame; - - var chars = src.fontData.chars; - var lineHeight = src.fontData.lineHeight; - var letterSpacing = src.letterSpacing; - - var xAdvance = 0; - var yAdvance = 0; - - var indexCount = 0; - var charCode = 0; - - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - - var x = 0; - var y = 0; - - var lastGlyph = null; - var lastCharCode = 0; - - var ctx = renderer.currentContext; - var image = src.frame.source.image; - - var textureX = textureFrame.cutX; - var textureY = textureFrame.cutY; - - var scale = (src.fontSize / src.fontData.size); - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var roundPixels = renderer.config.roundPixels; - - var tx = (src.x - camera.scrollX * src.scrollFactorX) + src.frame.x; - var ty = (src.y - camera.scrollY * src.scrollFactorY) + src.frame.y; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.translate(-src.displayOriginX, -src.displayOriginY); - - ctx.scale(src.scaleX, src.scaleY); - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = indexCount + glyph.xOffset + xAdvance; - y = glyph.yOffset + yAdvance; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - x *= scale; - y *= scale; - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - if (roundPixels) - { - x |= 0; - y |= 0; - } - - ctx.save(); - - ctx.translate(x, y); - - ctx.scale(scale, scale); - - ctx.drawImage(image, glyphX, glyphY, glyphW, glyphH, 0, 0, glyphW, glyphH); - - ctx.restore(); - } - - ctx.restore(); -}; - -module.exports = BitmapTextCanvasRenderer; - - -/***/ }), -/* 912 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GameObject = __webpack_require__(2); - -/** - * Renders this Game Object with the WebGL Renderer to the given Camera. - * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. - * This method should not be called directly. It is a utility function of the Render module. - * - * @method Phaser.GameObjects.BitmapText#renderWebGL - * @since 3.0.0 - * @private - * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.BitmapText} gameObject - The Game Object being rendered in this call. - * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. - * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested - */ -var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera, parentMatrix) -{ - var text = gameObject.text; - var textLength = text.length; - - if (GameObject.RENDER_MASK !== gameObject.renderFlags || textLength === 0 || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) - { - return; - } - - this.pipeline.batchBitmapText(this, camera, parentMatrix); -}; - -module.exports = BitmapTextWebGLRenderer; - - -/***/ }), -/* 913 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var renderWebGL = __webpack_require__(3); -var renderCanvas = __webpack_require__(3); - -if (true) -{ - renderWebGL = __webpack_require__(912); -} - -if (true) -{ - renderCanvas = __webpack_require__(911); -} - -module.exports = { - - renderWebGL: renderWebGL, - renderCanvas: renderCanvas - -}; - - -/***/ }), -/* 914 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ParseXMLBitmapFont = __webpack_require__(474); - -/** - * Parse an XML Bitmap Font from an Atlas. - * - * Adds the parsed Bitmap Font data to the cache with the `fontName` key. - * - * @function ParseFromAtlas - * @since 3.0.0 - * @private - * - * @param {Phaser.Scene} scene - The Scene to parse the Bitmap Font for. - * @param {string} fontName - The key of the font to add to the Bitmap Font cache. - * @param {string} textureKey - The key of the BitmapFont's texture. - * @param {string} frameKey - The key of the BitmapFont texture's frame. - * @param {string} xmlKey - The key of the XML data of the font to parse. - * @param {integer} xSpacing - The x-axis spacing to add between each letter. - * @param {integer} ySpacing - The y-axis spacing to add to the line height. - * - * @return {boolean} Whether the parsing was successful or not. - */ -var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing) -{ - var frame = scene.sys.textures.getFrame(textureKey, frameKey); - var xml = scene.sys.cache.xml.get(xmlKey); - - if (frame && xml) - { - var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame); - - scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey }); - - return true; - } - else - { - return false; - } -}; - -module.exports = ParseFromAtlas; - - -/***/ }), -/* 915 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.GameObjects - */ - -var GameObjects = { - - DisplayList: __webpack_require__(504), - GameObjectCreator: __webpack_require__(13), - GameObjectFactory: __webpack_require__(11), - UpdateList: __webpack_require__(476), - - Components: __webpack_require__(15), - - BuildGameObject: __webpack_require__(24), - BuildGameObjectAnimation: __webpack_require__(127), - GameObject: __webpack_require__(2), - BitmapText: __webpack_require__(253), - Blitter: __webpack_require__(252), - Container: __webpack_require__(251), - DynamicBitmapText: __webpack_require__(250), - Graphics: __webpack_require__(115), - Group: __webpack_require__(112), - Image: __webpack_require__(69), - Particles: __webpack_require__(900), - PathFollower: __webpack_require__(418), - RenderTexture: __webpack_require__(234), - RetroFont: __webpack_require__(889), - Sprite3D: __webpack_require__(151), - Sprite: __webpack_require__(34), - Text: __webpack_require__(110), - TileSprite: __webpack_require__(233), - Zone: __webpack_require__(158), - - // Game Object Factories - - Factories: { - Blitter: __webpack_require__(883), - Container: __webpack_require__(882), - DynamicBitmapText: __webpack_require__(881), - Graphics: __webpack_require__(410), - Group: __webpack_require__(880), - Image: __webpack_require__(409), - Particles: __webpack_require__(879), - PathFollower: __webpack_require__(878), - RenderTexture: __webpack_require__(877), - Sprite3D: __webpack_require__(876), - Sprite: __webpack_require__(408), - StaticBitmapText: __webpack_require__(875), - Text: __webpack_require__(407), - TileSprite: __webpack_require__(874), - Zone: __webpack_require__(873) - }, - - Creators: { - Blitter: __webpack_require__(872), - Container: __webpack_require__(871), - DynamicBitmapText: __webpack_require__(870), - Graphics: __webpack_require__(406), - Group: __webpack_require__(869), - Image: __webpack_require__(405), - Particles: __webpack_require__(868), - RenderTexture: __webpack_require__(867), - Sprite3D: __webpack_require__(866), - Sprite: __webpack_require__(404), - StaticBitmapText: __webpack_require__(865), - Text: __webpack_require__(403), - TileSprite: __webpack_require__(864), - Zone: __webpack_require__(863) - } - -}; - -if (true) -{ - // WebGL only Game Objects - GameObjects.Mesh = __webpack_require__(145); - GameObjects.Quad = __webpack_require__(232); - - GameObjects.Factories.Mesh = __webpack_require__(859); - GameObjects.Factories.Quad = __webpack_require__(858); - - GameObjects.Creators.Mesh = __webpack_require__(857); - GameObjects.Creators.Quad = __webpack_require__(856); - - GameObjects.Light = __webpack_require__(402); - - __webpack_require__(401); - __webpack_require__(855); -} - -module.exports = GameObjects; - - -/***/ }), -/* 916 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.DOM - */ - -module.exports = { - - AddToDOM: __webpack_require__(130), - DOMContentLoaded: __webpack_require__(271), - ParseXML: __webpack_require__(270), - RemoveFromDOM: __webpack_require__(269), - RequestAnimationFrame: __webpack_require__(268) - -}; - - -/***/ }), -/* 917 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var ComponentToHex = __webpack_require__(541); - -/** - * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. - * - * @function Phaser.Display.Color.RGBToString - * @since 3.0.0 - * - * @param {integer} r - The red color value. A number between 0 and 255. - * @param {integer} g - The green color value. A number between 0 and 255. - * @param {integer} b - The blue color value. A number between 0 and 255. - * @param {integer} [a=255] - The alpha value. A number between 0 and 255. - * @param {string} [prefix=#] - The prefix of the string. Either `#` or `0x`. - * - * @return {string} A string-based representation of the color values. - */ -var RGBToString = function (r, g, b, a, prefix) -{ - if (a === undefined) { a = 255; } - if (prefix === undefined) { prefix = '#'; } - - if (prefix === '#') - { - return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); - } - else - { - return '0x' + ComponentToHex(a) + ComponentToHex(r) + ComponentToHex(g) + ComponentToHex(b); - } -}; - -module.exports = RGBToString; - - -/***/ }), -/* 918 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @typedef {object} HSLColorObject - * - * @property {number} h - The hue color value. A number between 0 and 1 - * @property {number} s - The saturation color value. A number between 0 and 1 - * @property {number} l - The lightness color value. A number between 0 and 1 - */ - -/** - * Converts an RGB color value to HSV (hue, saturation and value). - * Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes RGB values are contained in the set [0, 255] and returns h, s and v in the set [0, 1]. - * Based on code by Michael Jackson (https://github.com/mjijackson) - * - * @function Phaser.Display.Color.RGBToHSV - * @since 3.0.0 - * - * @param {integer} r - The red color value. A number between 0 and 255. - * @param {integer} g - The green color value. A number between 0 and 255. - * @param {integer} b - The blue color value. A number between 0 and 255. - * - * @return {HSLColorObject} An object with the properties `h`, `s` and `v`. - */ -var RGBToHSV = function (r, g, b) -{ - r /= 255; - g /= 255; - b /= 255; - - var min = Math.min(r, g, b); - var max = Math.max(r, g, b); - var d = max - min; - - // achromatic by default - var h = 0; - var s = (max === 0) ? 0 : d / max; - var v = max; - - if (max !== min) - { - if (max === r) - { - h = (g - b) / d + ((g < b) ? 6 : 0); - } - else if (max === g) - { - h = (b - r) / d + 2; - } - else if (max === b) - { - h = (r - g) / d + 4; - } - - h /= 6; - } - - return { h: h, s: s, v: v }; -}; - -module.exports = RGBToHSV; - - -/***/ }), -/* 919 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Between = __webpack_require__(149); -var Color = __webpack_require__(30); - -/** - * Creates a new Color object where the r, g, and b values have been set to random values - * based on the given min max values. - * - * @function Phaser.Display.Color.RandomRGB - * @since 3.0.0 - * - * @param {integer} [min=0] - The minimum value to set the random range from (between 0 and 255) - * @param {integer} [max=255] - The maximum value to set the random range from (between 0 and 255) - * - * @return {Phaser.Display.Color} A Color object. - */ -var RandomRGB = function (min, max) -{ - if (min === undefined) { min = 0; } - if (max === undefined) { max = 255; } - - return new Color(Between(min, max), Between(min, max), Between(min, max)); -}; - -module.exports = RandomRGB; - - -/***/ }), -/* 920 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Linear = __webpack_require__(122); - -/** - * Interpolates color values - * - * @namespace Phaser.Display.Color.Interpolate - * @since 3.0.0 - */ - -/** - * Interpolates between the two given color ranges over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.RGBWithRGB - * @since 3.0.0 - * - * @param {number} r1 - Red value. - * @param {number} g1 - Blue value. - * @param {number} b1 - Green value. - * @param {number} r2 - Red value. - * @param {number} g2 - Blue value. - * @param {number} b2 - Green value. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var RGBWithRGB = function (r1, g1, b1, r2, g2, b2, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - var t = index / length; - - return { - r: Linear(r1, r2, t), - g: Linear(g1, g2, t), - b: Linear(b1, b2, t) - }; -}; - -/** - * Interpolates between the two given color objects over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.ColorWithColor - * @since 3.0.0 - * - * @param {Phaser.Display.Color} color1 - The first Color object. - * @param {Phaser.Display.Color} color2 - The second Color object. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var ColorWithColor = function (color1, color2, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - return RGBWithRGB(color1.r, color1.g, color1.b, color2.r, color2.g, color2.b, length, index); -}; - -/** - * Interpolates between the Color object and color values over the length supplied. - * - * @function Phaser.Display.Color.Interpolate.ColorWithRGB - * @since 3.0.0 - * - * @param {Phaser.Display.Color} color1 - The first Color object. - * @param {number} r - Red value. - * @param {number} g - Blue value. - * @param {number} b - Green value. - * @param {number} [length=100] - Distance to interpolate over. - * @param {number} [index=0] - Index to start from. - * - * @return {ColorObject} An object containing the interpolated color values. - */ -var ColorWithRGB = function (color, r, g, b, length, index) -{ - if (length === undefined) { length = 100; } - if (index === undefined) { index = 0; } - - return RGBWithRGB(color.r, color.g, color.b, r, g, b, length, index); -}; - -module.exports = { - - RGBWithRGB: RGBWithRGB, - ColorWithRGB: ColorWithRGB, - ColorWithColor: ColorWithColor - -}; - - -/***/ }), -/* 921 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var HSVToRGB = __webpack_require__(539); - -/** - * Get HSV color wheel values in an array which will be 360 elements in size. - * - * @function Phaser.Display.Color.HSVColorWheel - * @since 3.0.0 - * - * @param {number} [s=1] - The saturation, in the range 0 - 1. - * @param {number} [v=1] - The value, in the range 0 - 1. - * - * @return {ColorObject[]} An array containing 360 elements, where each contains a single numeric value corresponding to the color at that point in the HSV color wheel. - */ -var HSVColorWheel = function (s, v) -{ - if (s === undefined) { s = 1; } - if (v === undefined) { v = 1; } - - var colors = []; - - for (var c = 0; c <= 359; c++) - { - colors.push(HSVToRGB(c / 359, s, v)); - } - - return colors; -}; - -module.exports = HSVColorWheel; - - -/***/ }), -/* 922 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Color = __webpack_require__(30); -var HueToComponent = __webpack_require__(540); - -/** - * Converts HSL (hue, saturation and lightness) values to a Phaser Color object. - * - * @function Phaser.Display.Color.HSLToColor - * @since 3.0.0 - * - * @param {number} h - The hue value in the range 0 to 1. - * @param {number} s - The saturation value in the range 0 to 1. - * @param {number} l - The lightness value in the range 0 to 1. - * - * @return {Phaser.Display.Color} A Color object created from the results of the h, s and l values. - */ -var HSLToColor = function (h, s, l) -{ - // achromatic by default - var r = l; - var g = l; - var b = l; - - if (s !== 0) - { - var q = (l < 0.5) ? l * (1 + s) : l + s - l * s; - var p = 2 * l - q; - - r = HueToComponent(p, q, h + 1 / 3); - g = HueToComponent(p, q, h); - b = HueToComponent(p, q, h - 1 / 3); - } - - var color = new Color(); - - return color.setGLTo(r, g, b, 1); -}; - -module.exports = HSLToColor; - - -/***/ }), -/* 923 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Converts the given color value into an Object containing r,g,b and a properties. - * - * @function Phaser.Display.Color.ColorToRGBA - * @since 3.0.0 - * - * @param {number} color - A color value, optionally including the alpha value. - * - * @return {ColorObject} An object containing the parsed color values. - */ -var ColorToRGBA = function (color) -{ - var output = { - r: color >> 16 & 0xFF, - g: color >> 8 & 0xFF, - b: color & 0xFF, - a: 255 - }; - - if (color > 16777215) - { - output.a = color >>> 24; - } - - return output; -}; - -module.exports = ColorToRGBA; - - -/***/ }), -/* 924 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. - * - * @function Phaser.Display.Canvas.UserSelect - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. - * @param {string} [value='none'] - The touch callout value to set on the canvas. Set to `none` to disable touch callouts. - * - * @return {HTMLCanvasElement} The canvas element. - */ -var UserSelect = function (canvas, value) -{ - if (value === undefined) { value = 'none'; } - - var vendors = [ - '-webkit-', - '-khtml-', - '-moz-', - '-ms-', - '' - ]; - - vendors.forEach(function (vendor) - { - canvas.style[vendor + 'user-select'] = value; - }); - - canvas.style['-webkit-touch-callout'] = value; - canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; - - return canvas; -}; - -module.exports = UserSelect; - - -/***/ }), -/* 925 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. - * - * @function Phaser.Display.Canvas.TouchAction - * @since 3.0.0 - * - * @param {HTMLCanvasElement} canvas - The canvas element to have the style applied to. - * @param {string} [value='none'] - The touch action value to set on the canvas. Set to `none` to disable touch actions. - * - * @return {HTMLCanvasElement} The canvas element. - */ -var TouchAction = function (canvas, value) -{ - if (value === undefined) { value = 'none'; } - - canvas.style['msTouchAction'] = value; - canvas.style['ms-touch-action'] = value; - canvas.style['touch-action'] = value; - - return canvas; -}; - -module.exports = TouchAction; - - -/***/ }), -/* 926 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Canvas - */ - -module.exports = { - - Interpolation: __webpack_require__(272), - Pool: __webpack_require__(22), - Smoothing: __webpack_require__(131), - TouchAction: __webpack_require__(925), - UserSelect: __webpack_require__(924) - -}; - - -/***/ }), -/* 927 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the amount the Game Object is visually offset from its y coordinate. - * This is the same as `width * origin.y`. - * This value will only be > 0 if `origin.y` is not equal to zero. - * - * @function Phaser.Display.Bounds.GetOffsetY - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The vertical offset of the Game Object. - */ -var GetOffsetY = function (gameObject) -{ - return gameObject.height * gameObject.originY; -}; - -module.exports = GetOffsetY; - - -/***/ }), -/* 928 */ -/***/ (function(module, exports) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Returns the amount the Game Object is visually offset from its x coordinate. - * This is the same as `width * origin.x`. - * This value will only be > 0 if `origin.x` is not equal to zero. - * - * @function Phaser.Display.Bounds.GetOffsetX - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to get the bounds value from. - * - * @return {number} The horizontal offset of the Game Object. - */ -var GetOffsetX = function (gameObject) -{ - return gameObject.width * gameObject.originX; -}; - -module.exports = GetOffsetX; - - -/***/ }), -/* 929 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Bounds - */ - -module.exports = { - - CenterOn: __webpack_require__(593), - GetBottom: __webpack_require__(50), - GetCenterX: __webpack_require__(92), - GetCenterY: __webpack_require__(89), - GetLeft: __webpack_require__(48), - GetOffsetX: __webpack_require__(928), - GetOffsetY: __webpack_require__(927), - GetRight: __webpack_require__(46), - GetTop: __webpack_require__(44), - SetBottom: __webpack_require__(49), - SetCenterX: __webpack_require__(91), - SetCenterY: __webpack_require__(90), - SetLeft: __webpack_require__(47), - SetRight: __webpack_require__(45), - SetTop: __webpack_require__(43) - -}; - - -/***/ }), -/* 930 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(46); -var GetTop = __webpack_require__(44); -var SetBottom = __webpack_require__(49); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top right position of the other. - * - * @function Phaser.Display.Align.To.TopRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopRight = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignTo) + offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopRight; - - -/***/ }), -/* 931 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(48); -var GetTop = __webpack_require__(44); -var SetBottom = __webpack_require__(49); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top left position of the other. - * - * @function Phaser.Display.Align.To.TopLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopLeft = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignTo) - offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopLeft; - - -/***/ }), -/* 932 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterX = __webpack_require__(92); -var GetTop = __webpack_require__(44); -var SetBottom = __webpack_require__(49); -var SetCenterX = __webpack_require__(91); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the top center position of the other. - * - * @function Phaser.Display.Align.To.TopCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var TopCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); - SetBottom(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = TopCenter; - - -/***/ }), -/* 933 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetRight = __webpack_require__(46); -var GetTop = __webpack_require__(44); -var SetLeft = __webpack_require__(47); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right top position of the other. - * - * @function Phaser.Display.Align.To.RightTop - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightTop = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetTop(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = RightTop; - - -/***/ }), -/* 934 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(89); -var GetRight = __webpack_require__(46); -var SetCenterY = __webpack_require__(90); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right center position of the other. - * - * @function Phaser.Display.Align.To.RightCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = RightCenter; - - -/***/ }), -/* 935 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetRight = __webpack_require__(46); -var SetBottom = __webpack_require__(49); -var SetLeft = __webpack_require__(47); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the right bottom position of the other. - * - * @function Phaser.Display.Align.To.RightBottom - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var RightBottom = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetRight(alignTo) + offsetX); - SetBottom(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = RightBottom; - - -/***/ }), -/* 936 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetLeft = __webpack_require__(48); -var GetTop = __webpack_require__(44); -var SetRight = __webpack_require__(45); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left top position of the other. - * - * @function Phaser.Display.Align.To.LeftTop - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftTop = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetTop(gameObject, GetTop(alignTo) - offsetY); - - return gameObject; -}; - -module.exports = LeftTop; - - -/***/ }), -/* 937 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetCenterY = __webpack_require__(89); -var GetLeft = __webpack_require__(48); -var SetCenterY = __webpack_require__(90); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left center position of the other. - * - * @function Phaser.Display.Align.To.LeftCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetCenterY(gameObject, GetCenterY(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = LeftCenter; - - -/***/ }), -/* 938 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetLeft = __webpack_require__(48); -var SetBottom = __webpack_require__(49); -var SetRight = __webpack_require__(45); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the left bottom position of the other. - * - * @function Phaser.Display.Align.To.LeftBottom - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var LeftBottom = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetLeft(alignTo) - offsetX); - SetBottom(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = LeftBottom; - - -/***/ }), -/* 939 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetRight = __webpack_require__(46); -var SetRight = __webpack_require__(45); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom right position of the other. - * - * @function Phaser.Display.Align.To.BottomRight - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomRight = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetRight(gameObject, GetRight(alignTo) + offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomRight; - - /***/ }), /* 940 */ /***/ (function(module, exports, __webpack_require__) { -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetLeft = __webpack_require__(48); -var SetLeft = __webpack_require__(47); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom left position of the other. - * - * @function Phaser.Display.Align.To.BottomLeft - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomLeft = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetLeft(gameObject, GetLeft(alignTo) - offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomLeft; - - -/***/ }), -/* 941 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var GetBottom = __webpack_require__(50); -var GetCenterX = __webpack_require__(92); -var SetCenterX = __webpack_require__(91); -var SetTop = __webpack_require__(43); - -/** - * Takes given Game Object and aligns it so that it is positioned next to the bottom center position of the other. - * - * @function Phaser.Display.Align.To.BottomCenter - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] - * - * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned. - * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. - * @param {number} [offsetX=0] - Optional horizontal offset from the position. - * @param {number} [offsetY=0] - Optional vertical offset from the position. - * - * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. - */ -var BottomCenter = function (gameObject, alignTo, offsetX, offsetY) -{ - if (offsetX === undefined) { offsetX = 0; } - if (offsetY === undefined) { offsetY = 0; } - - SetCenterX(gameObject, GetCenterX(alignTo) + offsetX); - SetTop(gameObject, GetBottom(alignTo) + offsetY); - - return gameObject; -}; - -module.exports = BottomCenter; - - -/***/ }), -/* 942 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align.To - */ - -module.exports = { - - BottomCenter: __webpack_require__(941), - BottomLeft: __webpack_require__(940), - BottomRight: __webpack_require__(939), - LeftBottom: __webpack_require__(938), - LeftCenter: __webpack_require__(937), - LeftTop: __webpack_require__(936), - RightBottom: __webpack_require__(935), - RightCenter: __webpack_require__(934), - RightTop: __webpack_require__(933), - TopCenter: __webpack_require__(932), - TopLeft: __webpack_require__(931), - TopRight: __webpack_require__(930) - -}; - - -/***/ }), -/* 943 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display.Align.In - */ - -module.exports = { - - BottomCenter: __webpack_require__(597), - BottomLeft: __webpack_require__(596), - BottomRight: __webpack_require__(595), - Center: __webpack_require__(594), - LeftCenter: __webpack_require__(592), - QuickSet: __webpack_require__(598), - RightCenter: __webpack_require__(591), - TopCenter: __webpack_require__(590), - TopLeft: __webpack_require__(589), - TopRight: __webpack_require__(588) - -}; - - -/***/ }), -/* 944 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var CONST = __webpack_require__(299); -var Extend = __webpack_require__(17); - -/** - * @namespace Phaser.Display.Align - */ - -var Align = { - - In: __webpack_require__(943), - To: __webpack_require__(942) - -}; - -// Merge in the consts -Align = Extend(false, Align, CONST); - -module.exports = Align; - - -/***/ }), -/* 945 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * @namespace Phaser.Display - */ - -module.exports = { - - Align: __webpack_require__(944), - Bounds: __webpack_require__(929), - Canvas: __webpack_require__(926), - Color: __webpack_require__(542), - Masks: __webpack_require__(538) - -}; - - -/***/ }), -/* 946 */ -/***/ (function(module, exports, __webpack_require__) { - /** * @author Richard Davey * @copyright 2018 Photon Storm Ltd. @@ -141559,14 +147601,14 @@ module.exports = { */ var Class = __webpack_require__(0); -var Vector2 = __webpack_require__(6); +var Vector2 = __webpack_require__(3); /** * @classdesc * [description] * * @class MoveTo - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * @@ -141609,7 +147651,7 @@ var MoveTo = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. @@ -141629,7 +147671,7 @@ var MoveTo = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -141689,7 +147731,7 @@ module.exports = MoveTo; /***/ }), -/* 947 */ +/* 941 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -141701,15 +147743,15 @@ module.exports = MoveTo; // Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) var Class = __webpack_require__(0); -var CubicBezierCurve = __webpack_require__(551); -var EllipseCurve = __webpack_require__(549); -var GameObjectFactory = __webpack_require__(11); -var LineCurve = __webpack_require__(548); -var MovePathTo = __webpack_require__(946); -var QuadraticBezierCurve = __webpack_require__(547); -var Rectangle = __webpack_require__(14); -var SplineCurve = __webpack_require__(545); -var Vector2 = __webpack_require__(6); +var CubicBezierCurve = __webpack_require__(355); +var EllipseCurve = __webpack_require__(353); +var GameObjectFactory = __webpack_require__(5); +var LineCurve = __webpack_require__(352); +var MovePathTo = __webpack_require__(940); +var QuadraticBezierCurve = __webpack_require__(351); +var Rectangle = __webpack_require__(9); +var SplineCurve = __webpack_require__(349); +var Vector2 = __webpack_require__(3); /** * @typedef {object} JSONPath @@ -141726,7 +147768,7 @@ var Vector2 = __webpack_require__(6); * [description] * * @class Path - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * @@ -142252,9 +148294,9 @@ var Path = new Class({ * @method Phaser.Curves.Path#getPoints * @since 3.0.0 * - * @param {integer} [divisions=12] - [description] + * @param {integer} [divisions=12] - The number of points to divide the path in to. * - * @return {Phaser.Math.Vector2[]} [description] + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects that containing the points along the Path. */ getPoints: function (divisions) { @@ -142308,7 +148350,7 @@ var Path = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {Phaser.Math.Vector2} [out] - [description] + * @param {Phaser.Math.Vector2} [out] - `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. * * @return {Phaser.Math.Vector2} [description] */ @@ -142515,7 +148557,7 @@ module.exports = Path; /***/ }), -/* 948 */ +/* 942 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -142536,19 +148578,19 @@ module.exports = Path; */ module.exports = { - Path: __webpack_require__(947), + Path: __webpack_require__(941), - CubicBezier: __webpack_require__(551), - Curve: __webpack_require__(86), - Ellipse: __webpack_require__(549), - Line: __webpack_require__(548), - QuadraticBezier: __webpack_require__(547), - Spline: __webpack_require__(545) + CubicBezier: __webpack_require__(355), + Curve: __webpack_require__(70), + Ellipse: __webpack_require__(353), + Line: __webpack_require__(352), + QuadraticBezier: __webpack_require__(351), + Spline: __webpack_require__(349) }; /***/ }), -/* 949 */ +/* 943 */ /***/ (function(module, exports) { /** @@ -142586,7 +148628,7 @@ module.exports = { /***/ }), -/* 950 */ +/* 944 */ /***/ (function(module, exports) { /** @@ -142624,7 +148666,7 @@ module.exports = { /***/ }), -/* 951 */ +/* 945 */ /***/ (function(module, exports) { /** @@ -142662,7 +148704,7 @@ module.exports = { /***/ }), -/* 952 */ +/* 946 */ /***/ (function(module, exports) { /** @@ -142700,7 +148742,7 @@ module.exports = { /***/ }), -/* 953 */ +/* 947 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -142736,17 +148778,17 @@ module.exports = { module.exports = { - ARNE16: __webpack_require__(275), - C64: __webpack_require__(952), - CGA: __webpack_require__(951), - JMP: __webpack_require__(950), - MSX: __webpack_require__(949) + ARNE16: __webpack_require__(356), + C64: __webpack_require__(946), + CGA: __webpack_require__(945), + JMP: __webpack_require__(944), + MSX: __webpack_require__(943) }; /***/ }), -/* 954 */ +/* 948 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -142761,14 +148803,14 @@ module.exports = { module.exports = { - GenerateTexture: __webpack_require__(276), - Palettes: __webpack_require__(953) + GenerateTexture: __webpack_require__(357), + Palettes: __webpack_require__(947) }; /***/ }), -/* 955 */ +/* 949 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -142777,21 +148819,70 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Camera = __webpack_require__(378); var Class = __webpack_require__(0); -var OrthographicCamera = __webpack_require__(553); -var PerspectiveCamera = __webpack_require__(552); -var PluginCache = __webpack_require__(12); +var GetFastValue = __webpack_require__(2); +var PluginCache = __webpack_require__(15); +var RectangleContains = __webpack_require__(39); + +/** + * @typedef {object} InputJSONCameraObject + * + * @property {string} [name=''] - The name of the Camera. + * @property {integer} [x=0] - The horizontal position of the Camera viewport. + * @property {integer} [y=0] - The vertical position of the Camera viewport. + * @property {integer} [width] - The width of the Camera viewport. + * @property {integer} [height] - The height of the Camera viewport. + * @property {number} [zoom=1] - The default zoom level of the Camera. + * @property {number} [rotation=0] - The rotation of the Camera, in radians. + * @property {boolean} [roundPixels=false] - Should the Camera round pixels before rendering? + * @property {number} [scrollX=0] - The horizontal scroll position of the Camera. + * @property {number} [scrollY=0] - The vertical scroll position of the Camera. + * @property {(false|string)} [backgroundColor=false] - A CSS color string controlling the Camera background color. + * @property {?object} [bounds] - Defines the Camera bounds. + * @property {number} [bounds.x=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.y=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.width] - The width of the Camera bounds. + * @property {number} [bounds.height] - The height of the Camera bounds. + */ /** * @classdesc - * [description] + * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. + * + * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed + * in your game config. + * + * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add + * the new Camera in using the `addExisting` method. + * + * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique + * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of + * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore + * Game Objects, make sure it's one of the first 31 created. + * + * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. * * @class CameraManager - * @memberOf Phaser.Cameras.Sprite3D + * @memberof Phaser.Cameras.Scene2D * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene that owns the Camera Manager plugin. */ var CameraManager = new Class({ @@ -142800,47 +148891,102 @@ var CameraManager = new Class({ function CameraManager (scene) { /** - * [description] + * The Scene that owns the Camera Manager plugin. * - * @name Phaser.Cameras.Sprite3D.CameraManager#scene + * @name Phaser.Cameras.Scene2D.CameraManager#scene * @type {Phaser.Scene} * @since 3.0.0 */ this.scene = scene; /** - * [description] + * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. * - * @name Phaser.Cameras.Sprite3D.CameraManager#systems + * @name Phaser.Cameras.Scene2D.CameraManager#systems * @type {Phaser.Scenes.Systems} * @since 3.0.0 */ this.systems = scene.sys; /** - * An Array of the Camera objects being managed by this Camera Manager. + * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` + * property set to match this value. By default it is set to match the value set in the + * game configuration, but can be changed at any point. Equally, individual cameras can + * also be changed as needed. * - * @name Phaser.Cameras.Sprite3D.CameraManager#cameras - * @type {Phaser.Cameras.Sprite3D.Camera[]} + * @name Phaser.Cameras.Scene2D.CameraManager#roundPixels + * @type {boolean} + * @since 3.11.0 + */ + this.roundPixels = scene.sys.game.config.roundPixels; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * The Cameras are updated and rendered in the same order in which they appear in this array. + * Do not directly add or remove entries to this array. However, you can move the contents + * around the array should you wish to adjust the display order. + * + * @name Phaser.Cameras.Scene2D.CameraManager#cameras + * @type {Phaser.Cameras.Scene2D.Camera[]} * @since 3.0.0 */ this.cameras = []; + /** + * A handy reference to the 'main' camera. By default this is the first Camera the + * Camera Manager creates. You can also set it directly, or use the `makeMain` argument + * in the `add` and `addExisting` methods. It allows you to access it from your game: + * + * ```javascript + * var cam = this.cameras.main; + * ``` + * + * Also see the properties `camera1`, `camera2` and so on. + * + * @name Phaser.Cameras.Scene2D.CameraManager#main + * @type {Phaser.Cameras.Scene2D.Camera} + * @since 3.0.0 + */ + this.main; + + /** + * This scale affects all cameras. It's used by the Scale Manager. + * + * @name Phaser.Cameras.Scene2D.CameraManager#baseScale + * @type {number} + * @since 3.0.0 + */ + this.baseScale = 1; + scene.sys.events.once('boot', this.boot, this); scene.sys.events.on('start', this.start, this); }, - /** * This method is called automatically, only once, when the Scene is first created. * Do not invoke it directly. * - * @method Phaser.Cameras.Scene3D.CameraManager#boot + * @method Phaser.Cameras.Scene2D.CameraManager#boot * @private * @since 3.5.1 */ boot: function () { + 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]; + this.systems.events.once('destroy', this.destroy, this); }, @@ -142849,12 +148995,30 @@ var CameraManager = new Class({ * It is responsible for creating local systems, properties and listening for Scene events. * Do not invoke it directly. * - * @method Phaser.Cameras.Sprite3D.CameraManager#start + * @method Phaser.Cameras.Scene2D.CameraManager#start * @private * @since 3.5.0 */ start: function () { + if (!this.main) + { + 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 = this.systems.events; eventEmitter.on('update', this.update, this); @@ -142862,91 +149026,279 @@ var CameraManager = new Class({ }, /** - * [description] + * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. + * + * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. + * + * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the + * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, + * pan and zoom. + * + * By default Cameras are transparent and will render anything that they can see based on their `scrollX` + * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. + * + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after creation if required. + * + * See the Camera class documentation for more details. * - * @method Phaser.Cameras.Sprite3D.CameraManager#add + * @method Phaser.Cameras.Scene2D.CameraManager#add * @since 3.0.0 * - * @param {number} [fieldOfView=80] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] + * @param {integer} [x=0] - The horizontal position of the Camera viewport. + * @param {integer} [y=0] - The vertical position of the Camera viewport. + * @param {integer} [width] - The width of the Camera viewport. If not given it'll be the game config size. + * @param {integer} [height] - The height of the Camera viewport. If not given it'll be the game config size. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. + * @param {string} [name=''] - The name of the Camera. * - * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + * @return {Phaser.Cameras.Scene2D.Camera} The newly created Camera. */ - add: function (fieldOfView, width, height) + add: function (x, y, width, height, makeMain, name) { - return this.addPerspectiveCamera(fieldOfView, width, height); - }, + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + if (makeMain === undefined) { makeMain = false; } + if (name === undefined) { name = ''; } - /** - * [description] - * - * @method Phaser.Cameras.Sprite3D.CameraManager#addOrthographicCamera - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * - * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] - */ - addOrthographicCamera: function (width, height) - { - var config = this.scene.sys.game.config; + var camera = new Camera(x, y, width, height); - if (width === undefined) { width = config.width; } - if (height === undefined) { height = config.height; } + camera.setName(name); + camera.setScene(this.scene); + camera.setRoundPixels(this.roundPixels); - var camera = new OrthographicCamera(this.scene, width, height); + camera.id = this.getNextID(); this.cameras.push(camera); + if (makeMain) + { + this.main = camera; + } + return camera; }, /** - * [description] + * Adds an existing Camera into the Camera Manager. + * + * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after addition if required. + * + * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the + * manager. As long as it doesn't already exist in the manager it will be added then returned. + * + * If this method returns `null` then the Camera already exists in this Camera Manager. * - * @method Phaser.Cameras.Sprite3D.CameraManager#addPerspectiveCamera + * @method Phaser.Cameras.Scene2D.CameraManager#addExisting * @since 3.0.0 * - * @param {number} [fieldOfView=80] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be added to the Camera Manager. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. * - * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + * @return {?Phaser.Cameras.Scene2D.Camera} The Camera that was added to the Camera Manager, or `null` if it couldn't be added. */ - addPerspectiveCamera: function (fieldOfView, width, height) + addExisting: function (camera, makeMain) { - var config = this.scene.sys.game.config; + if (makeMain === undefined) { makeMain = false; } - if (fieldOfView === undefined) { fieldOfView = 80; } - if (width === undefined) { width = config.width; } - if (height === undefined) { height = config.height; } + var index = this.cameras.indexOf(camera); - var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height); + if (index === -1) + { + camera.id = this.getNextID(); - this.cameras.push(camera); + camera.setRoundPixels(this.roundPixels); - return camera; + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + + return camera; + } + + return null; }, /** - * [description] + * Gets the next available Camera ID number. + * + * The Camera Manager supports up to 31 unique cameras, after which the ID returned will always be zero. + * You can create additional cameras beyond 31, but they cannot be used for Game Object exclusion. * - * @method Phaser.Cameras.Sprite3D.CameraManager#getCamera + * @method Phaser.Cameras.Scene2D.CameraManager#getNextID + * @private + * @since 3.11.0 + * + * @return {number} The next available Camera ID, or 0 if they're all already in use. + */ + getNextID: function () + { + var cameras = this.cameras; + + var testID = 1; + + // Find the first free camera ID we can use + + for (var t = 0; t < 32; t++) + { + var found = false; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera && camera.id === testID) + { + found = true; + continue; + } + } + + if (found) + { + testID = testID << 1; + } + else + { + return testID; + } + } + + return 0; + }, + + /** + * Gets the total number of Cameras in this Camera Manager. + * + * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getTotal + * @since 3.11.0 + * + * @param {boolean} [isVisible=false] - Set the `true` to only include visible Cameras in the total. + * + * @return {integer} The total number of Cameras in this Camera Manager. + */ + getTotal: function (isVisible) + { + if (isVisible === undefined) { isVisible = false; } + + var total = 0; + + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (!isVisible || (isVisible && camera.visible)) + { + total++; + } + } + + return total; + }, + + /** + * Populates this Camera Manager based on the given configuration object, or an array of config objects. + * + * See the `InputJSONCameraObject` documentation for details of the object structure. + * + * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON * @since 3.0.0 * - * @param {string} name - [description] + * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - A Camera configuration object, or an array of them, to be added to this Camera Manager. * - * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + * @return {Phaser.Cameras.Scene2D.CameraManager} This Camera Manager instance. + */ + fromJSON: function (config) + { + if (!Array.isArray(config)) + { + config = [ config ]; + } + + var gameWidth = this.scene.sys.game.config.width; + var gameHeight = this.scene.sys.game.config.height; + + for (var i = 0; i < config.length; i++) + { + var cameraConfig = config[i]; + + var x = GetFastValue(cameraConfig, 'x', 0); + var y = GetFastValue(cameraConfig, 'y', 0); + var width = GetFastValue(cameraConfig, 'width', gameWidth); + var height = GetFastValue(cameraConfig, 'height', gameHeight); + + var camera = this.add(x, y, width, height); + + // Direct properties + camera.name = GetFastValue(cameraConfig, 'name', ''); + camera.zoom = GetFastValue(cameraConfig, 'zoom', 1); + camera.rotation = GetFastValue(cameraConfig, 'rotation', 0); + camera.scrollX = GetFastValue(cameraConfig, 'scrollX', 0); + camera.scrollY = GetFastValue(cameraConfig, 'scrollY', 0); + camera.roundPixels = GetFastValue(cameraConfig, 'roundPixels', false); + camera.visible = GetFastValue(cameraConfig, 'visible', true); + + // Background Color + + var backgroundColor = GetFastValue(cameraConfig, 'backgroundColor', false); + + if (backgroundColor) + { + camera.setBackgroundColor(backgroundColor); + } + + // Bounds + + var boundsConfig = GetFastValue(cameraConfig, 'bounds', null); + + if (boundsConfig) + { + var bx = GetFastValue(boundsConfig, 'x', 0); + var by = GetFastValue(boundsConfig, 'y', 0); + var bwidth = GetFastValue(boundsConfig, 'width', gameWidth); + var bheight = GetFastValue(boundsConfig, 'height', gameHeight); + + camera.setBounds(bx, by, bwidth, bheight); + } + } + + return this; + }, + + /** + * Gets a Camera based on its name. + * + * Camera names are optional and don't have to be set, so this method is only of any use if you + * have given your Cameras unique names. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getCamera + * @since 3.0.0 + * + * @param {string} name - The name of the Camera. + * + * @return {?Phaser.Cameras.Scene2D.Camera} The first Camera with a name matching the given string, otherwise `null`. */ getCamera: function (name) { - for (var i = 0; i < this.cameras.length; i++) + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) { - if (this.cameras[i].name === name) + if (cameras[i].name === name) { - return this.cameras[i]; + return cameras[i]; } } @@ -142954,83 +149306,219 @@ var CameraManager = new Class({ }, /** - * [description] + * Returns an array of all cameras below the given Pointer. + * + * The first camera in the array is the top-most camera in the camera list. * - * @method Phaser.Cameras.Sprite3D.CameraManager#removeCamera + * @method Phaser.Cameras.Scene2D.CameraManager#getCamerasBelowPointer + * @since 3.10.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer to check against. + * + * @return {Phaser.Cameras.Scene2D.Camera[]} An array of cameras below the Pointer. + */ + getCamerasBelowPointer: function (pointer) + { + var cameras = this.cameras; + + var x = pointer.x; + var y = pointer.y; + + var output = []; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera.visible && camera.inputEnabled && RectangleContains(camera, x, y)) + { + // So the top-most camera is at the top of the search array + output.unshift(camera); + } + } + + return output; + }, + + /** + * Removes the given Camera, or an array of Cameras, from this Camera Manager. + * + * If found in the Camera Manager it will be immediately removed from the local cameras array. + * If also currently the 'main' camera, 'main' will be reset to be camera 0. + * + * The removed Cameras are automatically destroyed if the `runDestroy` argument is `true`, which is the default. + * If you wish to re-use the cameras then set this to `false`, but know that they will retain their references + * and internal data until destroyed or re-added to a Camera Manager. + * + * @method Phaser.Cameras.Scene2D.CameraManager#remove * @since 3.0.0 * - * @param {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} camera - [description] + * @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager. + * @param {boolean} [runDestroy=true] - Automatically call `Camera.destroy` on each Camera removed from this Camera Manager. + * + * @return {integer} The total number of Cameras removed. */ - removeCamera: function (camera) + remove: function (camera, runDestroy) { - var cameraIndex = this.cameras.indexOf(camera); + if (runDestroy === undefined) { runDestroy = true; } - if (cameraIndex !== -1) + if (!Array.isArray(camera)) { - this.cameras.splice(cameraIndex, 1); + camera = [ camera ]; + } + + var total = 0; + var cameras = this.cameras; + + for (var i = 0; i < camera.length; i++) + { + var index = cameras.indexOf(camera[i]); + + if (index !== -1) + { + if (runDestroy) + { + cameras[index].destroy(); + } + + cameras.splice(index, 1); + + total++; + } + } + + if (!this.main && cameras[0]) + { + this.main = cameras[0]; + } + + return total; + }, + + /** + * The internal render method. This is called automatically by the Scene and should not be invoked directly. + * + * It will iterate through all local cameras and render them in turn, as long as they're visible and have + * an alpha level > 0. + * + * @method Phaser.Cameras.Scene2D.CameraManager#render + * @protected + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. + * @param {Phaser.GameObjects.GameObject[]} children - An array of renderable Game Objects. + * @param {number} interpolation - Interpolation value. Reserved for future use. + */ + render: function (renderer, children, interpolation) + { + var scene = this.scene; + var cameras = this.cameras; + var baseScale = this.baseScale; + var resolution = renderer.config.resolution; + + for (var i = 0; i < this.cameras.length; i++) + { + var camera = cameras[i]; + + if (camera.visible && camera.alpha > 0) + { + camera.preRender(baseScale, resolution); + + renderer.render(scene, children, interpolation, camera); + } } }, /** - * [description] + * Resets this Camera Manager. + * + * This will iterate through all current Cameras, destroying them all, then it will reset the + * cameras array, reset the ID counter and create 1 new single camera using the default values. * - * @method Phaser.Cameras.Sprite3D.CameraManager#removeAll + * @method Phaser.Cameras.Scene2D.CameraManager#resetAll * @since 3.0.0 * - * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + * @return {Phaser.Cameras.Scene2D.Camera} The freshly created main Camera. */ - removeAll: function () + resetAll: function () { - while (this.cameras.length > 0) + for (var i = 0; i < this.cameras.length; i++) { - var camera = this.cameras.pop(); - - camera.destroy(); + this.cameras[i].destroy(); } + this.cameras = []; + + this.main = this.add(); + return this.main; }, /** - * [description] + * The main update loop. Called automatically when the Scene steps. * - * @method Phaser.Cameras.Sprite3D.CameraManager#update + * @method Phaser.Cameras.Scene2D.CameraManager#update + * @protected * @since 3.0.0 * - * @param {number} timestep - [description] - * @param {number} delta - [description] + * @param {number} timestep - The timestep value. + * @param {number} delta - The delta value since the last frame. */ update: function (timestep, delta) { - for (var i = 0, l = this.cameras.length; i < l; ++i) + for (var i = 0; i < this.cameras.length; i++) { this.cameras[i].update(timestep, delta); } }, + /** + * Resizes all cameras to the given dimensions. + * + * @method Phaser.Cameras.Scene2D.CameraManager#resize + * @since 3.2.0 + * + * @param {number} width - The new width of the camera. + * @param {number} height - The new height of the camera. + */ + resize: function (width, height) + { + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].setSize(width, height); + } + }, + /** * 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 + * @method Phaser.Cameras.Scene2D.CameraManager#shutdown * @private * @since 3.0.0 */ shutdown: function () { + this.main = undefined; + + for (var i = 0; i < this.cameras.length; i++) + { + this.cameras[i].destroy(); + } + + this.cameras = []; + var eventEmitter = this.systems.events; eventEmitter.off('update', this.update, this); eventEmitter.off('shutdown', this.shutdown, this); - - this.removeAll(); }, /** * 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 + * @method Phaser.Cameras.Scene2D.CameraManager#destroy * @private * @since 3.0.0 */ @@ -143046,13 +149534,2991 @@ var CameraManager = new Class({ }); -PluginCache.register('CameraManager3D', CameraManager, 'cameras3d'); +PluginCache.register('CameraManager', CameraManager, 'cameras'); module.exports = CameraManager; +/***/ }), +/* 950 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var EaseMap = __webpack_require__(174); + +/** + * @classdesc + * A Camera Zoom effect. + * + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * 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 Zoom + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.11.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Zoom = new Class({ + + initialize: + + function Zoom (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.11.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.11.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#duration + * @type {integer} + * @readonly + * @default 0 + * @since 3.11.0 + */ + this.duration = 0; + + /** + * The starting zoom value; + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#source + * @type {number} + * @since 3.11.0 + */ + this.source = 1; + + /** + * The destination zoom value. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#destination + * @type {number} + * @since 3.11.0 + */ + this.destination = 1; + + /** + * The ease function to use during the zoom. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#ease + * @type {function} + * @since 3.11.0 + */ + this.ease; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#progress + * @type {number} + * @since 3.11.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_elapsed + * @type {number} + * @private + * @since 3.11.0 + */ + this._elapsed = 0; + + /** + * @callback CameraZoomCallback + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. + * @param {number} progress - The progress of the effect. A value between 0 and 1. + * @param {number} zoom - The Camera's new zoom value. + */ + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdate + * @type {?CameraZoomCallback} + * @private + * @default null + * @since 3.11.0 + */ + this._onUpdate; + + /** + * On Complete callback scope. + * + * @name Phaser.Cameras.Scene2D.Effects.Zoom#_onUpdateScope + * @type {any} + * @private + * @since 3.11.0 + */ + this._onUpdateScope; + }, + + /** + * This event is fired when the Zoom effect begins to run on a camera. + * + * @event CameraZoomStartEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. + * @param {integer} duration - The duration of the effect. + * @param {number} zoom - The destination zoom value. + */ + + /** + * This event is fired when the Zoom effect completes. + * + * @event CameraZoomCompleteEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Zoom} effect - A reference to the effect instance. + */ + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#start + * @fires CameraZoomStartEvent + * @fires CameraZoomCompleteEvent + * @since 3.11.0 + * + * @param {number} zoom - The target Camera zoom value. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the Zoom. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraZoomCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * and the current camera zoom value. + * @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 (zoom, duration, ease, force, callback, context) + { + if (duration === undefined) { duration = 1000; } + if (ease === undefined) { ease = EaseMap.Linear; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + var cam = this.camera; + + if (!force && this.isRunning) + { + return cam; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + // Starting from + this.source = cam.zoom; + + // Zooming to + this.destination = zoom; + + // Using this ease + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + this.ease = EaseMap[ease]; + } + else if (typeof ease === 'function') + { + this.ease = ease; + } + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit('camerazoomstart', this.camera, this, duration, zoom); + + return cam; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#update + * @since 3.11.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._elapsed < this.duration) + { + this.camera.zoom = this.source + ((this.destination - this.source) * this.ease(this.progress)); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.camera.zoom); + } + } + else + { + this.camera.zoom = this.destination; + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, this.camera, this.progress, this.destination); + } + + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Zoom#effectComplete + * @since 3.11.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit('camerazoomcomplete', 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.Zoom#reset + * @since 3.11.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.Zoom#destroy + * @since 3.11.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + } + +}); + +module.exports = Zoom; + + +/***/ }), +/* 951 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); + +/** + * @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 {number} + * @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 {number} 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 {number} 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._cw; + var height = this.camera._ch; + 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; + + +/***/ }), +/* 952 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Stepped easing. + * + * @function Phaser.Math.Easing.Stepped.Stepped + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [steps=1] - The number of steps in the ease. + * + * @return {number} The tweened value. + */ +var Stepped = function (v, steps) +{ + if (steps === undefined) { steps = 1; } + + if (v <= 0) + { + return 0; + } + else if (v >= 1) + { + return 1; + } + else + { + return (((steps * v) | 0) + 1) * (1 / steps); + } +}; + +module.exports = Stepped; + + +/***/ }), +/* 953 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sinusoidal ease-in/out. + * + * @function Phaser.Math.Easing.Sine.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 0.5 * (1 - Math.cos(Math.PI * v)); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 954 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sinusoidal ease-out. + * + * @function Phaser.Math.Easing.Sine.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return Math.sin(v * Math.PI / 2); + } +}; + +module.exports = Out; + + +/***/ }), +/* 955 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sinusoidal ease-in. + * + * @function Phaser.Math.Easing.Sine.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + return 1 - Math.cos(v * Math.PI / 2); + } +}; + +module.exports = In; + + /***/ }), /* 956 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quintic ease-in/out. + * + * @function Phaser.Math.Easing.Quintic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v * v * v + 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 957 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quintic ease-out. + * + * @function Phaser.Math.Easing.Quintic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return --v * v * v * v * v + 1; +}; + +module.exports = Out; + + +/***/ }), +/* 958 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quintic ease-in. + * + * @function Phaser.Math.Easing.Quintic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v * v * v * v; +}; + +module.exports = In; + + +/***/ }), +/* 959 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quartic ease-in/out. + * + * @function Phaser.Math.Easing.Quartic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v * v * v; + } + else + { + return -0.5 * ((v -= 2) * v * v * v - 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 960 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quartic ease-out. + * + * @function Phaser.Math.Easing.Quartic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return 1 - (--v * v * v * v); +}; + +module.exports = Out; + + +/***/ }), +/* 961 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quartic ease-in. + * + * @function Phaser.Math.Easing.Quartic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v * v * v; +}; + +module.exports = In; + + +/***/ }), +/* 962 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quadratic ease-in/out. + * + * @function Phaser.Math.Easing.Quadratic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v; + } + else + { + return -0.5 * (--v * (v - 2) - 1); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 963 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quadratic ease-out. + * + * @function Phaser.Math.Easing.Quadratic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return v * (2 - v); +}; + +module.exports = Out; + + +/***/ }), +/* 964 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Quadratic ease-in. + * + * @function Phaser.Math.Easing.Quadratic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v; +}; + +module.exports = In; + + +/***/ }), +/* 965 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Linear easing (no variation). + * + * @function Phaser.Math.Easing.Linear.Linear + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Linear = function (v) +{ + return v; +}; + +module.exports = Linear; + + +/***/ }), +/* 966 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Exponential ease-in/out. + * + * @function Phaser.Math.Easing.Expo.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * Math.pow(2, 10 * (v - 1)); + } + else + { + return 0.5 * (2 - Math.pow(2, -10 * (v - 1))); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 967 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Exponential ease-out. + * + * @function Phaser.Math.Easing.Expo.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return 1 - Math.pow(2, -10 * v); +}; + +module.exports = Out; + + +/***/ }), +/* 968 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Exponential ease-in. + * + * @function Phaser.Math.Easing.Expo.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return Math.pow(2, 10 * (v - 1)) - 0.001; +}; + +module.exports = In; + + +/***/ }), +/* 969 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Elastic ease-in/out. + * + * @function Phaser.Math.Easing.Elastic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] + * + * @return {number} The tweened value. + */ +var InOut = function (v, amplitude, period) +{ + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } + + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; + + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + if ((v *= 2) < 1) + { + return -0.5 * (amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } + else + { + return amplitude * Math.pow(2, -10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period) * 0.5 + 1; + } + } +}; + +module.exports = InOut; + + +/***/ }), +/* 970 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Elastic ease-out. + * + * @function Phaser.Math.Easing.Elastic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] + * + * @return {number} The tweened value. + */ +var Out = function (v, amplitude, period) +{ + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } + + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; + + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return (amplitude * Math.pow(2, -10 * v) * Math.sin((v - s) * (2 * Math.PI) / period) + 1); + } +}; + +module.exports = Out; + + +/***/ }), +/* 971 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Elastic ease-in. + * + * @function Phaser.Math.Easing.Elastic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] + * + * @return {number} The tweened value. + */ +var In = function (v, amplitude, period) +{ + if (amplitude === undefined) { amplitude = 0.1; } + if (period === undefined) { period = 0.1; } + + if (v === 0) + { + return 0; + } + else if (v === 1) + { + return 1; + } + else + { + var s = period / 4; + + if (amplitude < 1) + { + amplitude = 1; + } + else + { + s = period * Math.asin(1 / amplitude) / (2 * Math.PI); + } + + return -(amplitude * Math.pow(2, 10 * (v -= 1)) * Math.sin((v - s) * (2 * Math.PI) / period)); + } +}; + +module.exports = In; + + +/***/ }), +/* 972 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Cubic ease-in/out. + * + * @function Phaser.Math.Easing.Cubic.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return 0.5 * v * v * v; + } + else + { + return 0.5 * ((v -= 2) * v * v + 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 973 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Cubic ease-out. + * + * @function Phaser.Math.Easing.Cubic.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return --v * v * v + 1; +}; + +module.exports = Out; + + +/***/ }), +/* 974 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Cubic ease-in. + * + * @function Phaser.Math.Easing.Cubic.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return v * v * v; +}; + +module.exports = In; + + +/***/ }), +/* 975 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Circular ease-in/out. + * + * @function Phaser.Math.Easing.Circular.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + if ((v *= 2) < 1) + { + return -0.5 * (Math.sqrt(1 - v * v) - 1); + } + else + { + return 0.5 * (Math.sqrt(1 - (v -= 2) * v) + 1); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 976 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Circular ease-out. + * + * @function Phaser.Math.Easing.Circular.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + return Math.sqrt(1 - (--v * v)); +}; + +module.exports = Out; + + +/***/ }), +/* 977 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Circular ease-in. + * + * @function Phaser.Math.Easing.Circular.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + return 1 - Math.sqrt(1 - v * v); +}; + +module.exports = In; + + +/***/ }), +/* 978 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Bounce ease-in/out. + * + * @function Phaser.Math.Easing.Bounce.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var InOut = function (v) +{ + var reverse = false; + + if (v < 0.5) + { + v = 1 - (v * 2); + reverse = true; + } + else + { + v = (v * 2) - 1; + } + + if (v < 1 / 2.75) + { + v = 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + v = 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + v = 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + v = 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } + + if (reverse) + { + return (1 - v) * 0.5; + } + else + { + return v * 0.5 + 0.5; + } +}; + +module.exports = InOut; + + +/***/ }), +/* 979 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Bounce ease-out. + * + * @function Phaser.Math.Easing.Bounce.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var Out = function (v) +{ + if (v < 1 / 2.75) + { + return 7.5625 * v * v; + } + else if (v < 2 / 2.75) + { + return 7.5625 * (v -= 1.5 / 2.75) * v + 0.75; + } + else if (v < 2.5 / 2.75) + { + return 7.5625 * (v -= 2.25 / 2.75) * v + 0.9375; + } + else + { + return 7.5625 * (v -= 2.625 / 2.75) * v + 0.984375; + } +}; + +module.exports = Out; + + +/***/ }), +/* 980 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Bounce ease-in. + * + * @function Phaser.Math.Easing.Bounce.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * + * @return {number} The tweened value. + */ +var In = function (v) +{ + v = 1 - v; + + if (v < 1 / 2.75) + { + return 1 - (7.5625 * v * v); + } + else if (v < 2 / 2.75) + { + return 1 - (7.5625 * (v -= 1.5 / 2.75) * v + 0.75); + } + else if (v < 2.5 / 2.75) + { + return 1 - (7.5625 * (v -= 2.25 / 2.75) * v + 0.9375); + } + else + { + return 1 - (7.5625 * (v -= 2.625 / 2.75) * v + 0.984375); + } +}; + +module.exports = In; + + +/***/ }), +/* 981 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Back ease-in/out. + * + * @function Phaser.Math.Easing.Back.InOut + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [overshoot=1.70158] - The overshoot amount. + * + * @return {number} The tweened value. + */ +var InOut = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } + + var s = overshoot * 1.525; + + if ((v *= 2) < 1) + { + return 0.5 * (v * v * ((s + 1) * v - s)); + } + else + { + return 0.5 * ((v -= 2) * v * ((s + 1) * v + s) + 2); + } +}; + +module.exports = InOut; + + +/***/ }), +/* 982 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Back ease-out. + * + * @function Phaser.Math.Easing.Back.Out + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [overshoot=1.70158] - The overshoot amount. + * + * @return {number} The tweened value. + */ +var Out = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } + + return --v * v * ((overshoot + 1) * v + overshoot) + 1; +}; + +module.exports = Out; + + +/***/ }), +/* 983 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Back ease-in. + * + * @function Phaser.Math.Easing.Back.In + * @since 3.0.0 + * + * @param {number} v - The value to be tweened. + * @param {number} [overshoot=1.70158] - The overshoot amount. + * + * @return {number} The tweened value. + */ +var In = function (v, overshoot) +{ + if (overshoot === undefined) { overshoot = 1.70158; } + + return v * v * ((overshoot + 1) * v - overshoot); +}; + +module.exports = In; + + +/***/ }), +/* 984 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); +var Vector2 = __webpack_require__(3); +var EaseMap = __webpack_require__(174); + +/** + * @classdesc + * A Camera Pan effect. + * + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * Only the camera scroll 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 Pan + * @memberof Phaser.Cameras.Scene2D.Effects + * @constructor + * @since 3.11.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera this effect is acting upon. + */ +var Pan = new Class({ + + initialize: + + function Pan (camera) + { + /** + * The Camera this effect belongs to. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#camera + * @type {Phaser.Cameras.Scene2D.Camera} + * @readonly + * @since 3.11.0 + */ + this.camera = camera; + + /** + * Is this effect actively running? + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#isRunning + * @type {boolean} + * @readonly + * @default false + * @since 3.11.0 + */ + this.isRunning = false; + + /** + * The duration of the effect, in milliseconds. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#duration + * @type {integer} + * @readonly + * @default 0 + * @since 3.11.0 + */ + this.duration = 0; + + /** + * The starting scroll coordinates to pan the camera from. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#source + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.source = new Vector2(); + + /** + * The constantly updated value based on zoom. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#current + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.current = new Vector2(); + + /** + * The destination scroll coordinates to pan the camera to. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#destination + * @type {Phaser.Math.Vector2} + * @since 3.11.0 + */ + this.destination = new Vector2(); + + /** + * The ease function to use during the pan. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#ease + * @type {function} + * @since 3.11.0 + */ + this.ease; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#progress + * @type {number} + * @since 3.11.0 + */ + this.progress = 0; + + /** + * Effect elapsed timer. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_elapsed + * @type {number} + * @private + * @since 3.11.0 + */ + this._elapsed = 0; + + /** + * @callback CameraPanCallback + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. + * @param {number} progress - The progress of the effect. A value between 0 and 1. + * @param {number} x - The Camera's new scrollX coordinate. + * @param {number} y - The Camera's new scrollY coordinate. + */ + + /** + * This callback is invoked every frame for the duration of the effect. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdate + * @type {?CameraPanCallback} + * @private + * @default null + * @since 3.11.0 + */ + this._onUpdate; + + /** + * On Complete callback scope. + * + * @name Phaser.Cameras.Scene2D.Effects.Pan#_onUpdateScope + * @type {any} + * @private + * @since 3.11.0 + */ + this._onUpdateScope; + }, + + /** + * This event is fired when the pan effect begins to run on a camera. + * + * @event CameraPanStartEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. + * @param {integer} duration - The duration of the effect. + * @param {number} x - The destination scroll x coordinate. + * @param {number} y - The destination scroll y coordinate. + */ + + /** + * This event is fired when the pan effect completes. + * + * @event CameraPanCompleteEvent + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. + * @param {Phaser.Cameras.Scene2D.Effects.Pan} effect - A reference to the effect instance. + */ + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#start + * @fires CameraPanStartEvent + * @fires CameraPanCompleteEvent + * @since 3.11.0 + * + * @param {number} x - The destination x coordinate to scroll the center of the Camera viewport to. + * @param {number} y - The destination y coordinate to scroll the center of the Camera viewport to. + * @param {integer} [duration=1000] - The duration of the effect in milliseconds. + * @param {(string|function)} [ease='Linear'] - The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. + * @param {boolean} [force=false] - Force the shake effect to start immediately, even if already running. + * @param {CameraPanCallback} [callback] - This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @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 (x, y, duration, ease, force, callback, context) + { + if (duration === undefined) { duration = 1000; } + if (ease === undefined) { ease = EaseMap.Linear; } + if (force === undefined) { force = false; } + if (callback === undefined) { callback = null; } + if (context === undefined) { context = this.camera.scene; } + + var cam = this.camera; + + if (!force && this.isRunning) + { + return cam; + } + + this.isRunning = true; + this.duration = duration; + this.progress = 0; + + // Starting from + this.source.set(cam.scrollX, cam.scrollY); + + // Destination + this.destination.set(x, y); + + // Zoom factored version + cam.getScroll(x, y, this.current); + + // Using this ease + if (typeof ease === 'string' && EaseMap.hasOwnProperty(ease)) + { + this.ease = EaseMap[ease]; + } + else if (typeof ease === 'function') + { + this.ease = ease; + } + + this._elapsed = 0; + + this._onUpdate = callback; + this._onUpdateScope = context; + + this.camera.emit('camerapanstart', this.camera, this, duration, x, y); + + return cam; + }, + + /** + * The main update loop for this effect. Called automatically by the Camera. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#update + * @since 3.11.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; + + var progress = Clamp(this._elapsed / this.duration, 0, 1); + + this.progress = progress; + + var cam = this.camera; + + if (this._elapsed < this.duration) + { + var v = this.ease(progress); + + cam.getScroll(this.destination.x, this.destination.y, this.current); + + var x = this.source.x + ((this.current.x - this.source.x) * v); + var y = this.source.y + ((this.current.y - this.source.y) * v); + + cam.setScroll(x, y); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, x, y); + } + } + else + { + cam.centerOn(this.destination.x, this.destination.y); + + if (this._onUpdate) + { + this._onUpdate.call(this._onUpdateScope, cam, progress, cam.scrollX, cam.scrollY); + } + + this.effectComplete(); + } + }, + + /** + * Called internally when the effect completes. + * + * @method Phaser.Cameras.Scene2D.Effects.Pan#effectComplete + * @since 3.11.0 + */ + effectComplete: function () + { + this._onUpdate = null; + this._onUpdateScope = null; + + this.isRunning = false; + + this.camera.emit('camerapancomplete', 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.Pan#reset + * @since 3.11.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.Pan#destroy + * @since 3.11.0 + */ + destroy: function () + { + this.reset(); + + this.camera = null; + this.source = null; + this.destination = null; + } + +}); + +module.exports = Pan; + + +/***/ }), +/* 985 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); + +/** + * @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 {number} + * @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 {number} + * @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 {number} 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._cx, camera._cy, camera._cw, camera._ch); + + return true; + }, + + /** + * Called internally by the WebGL Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderWebGL + * @since 3.5.0 + * + * @param {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} 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.drawFillRect( + camera._cx, camera._cy, camera._cw, camera._ch, + getTintFunction(red, green, blue, 1), + this.alpha + ); + + 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; + + +/***/ }), +/* 986 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(23); +var Class = __webpack_require__(0); + +/** + * @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 {number} + * @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 {number} + * @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 {number} 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._cx, camera._cy, camera._cw, camera._ch); + + return true; + }, + + /** + * Called internally by the WebGL Renderer. + * + * @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderWebGL + * @since 3.5.0 + * + * @param {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} 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.drawFillRect( + camera._cx, camera._cy, camera._cw, camera._ch, + getTintFunction(red, green, blue, 1), + this.alpha + ); + + 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; + + +/***/ }), +/* 987 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -143062,21 +152528,20 @@ module.exports = CameraManager; */ /** - * @namespace Phaser.Cameras.Sprite3D + * @namespace Phaser.Cameras.Scene2D */ module.exports = { - Camera: __webpack_require__(279), - CameraManager: __webpack_require__(955), - OrthographicCamera: __webpack_require__(553), - PerspectiveCamera: __webpack_require__(552) + Camera: __webpack_require__(378), + CameraManager: __webpack_require__(949), + Effects: __webpack_require__(370) }; /***/ }), -/* 957 */ +/* 988 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -143111,10 +152576,10 @@ var GetValue = __webpack_require__(4); * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. - * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * @property {(float|{x:float,y:float})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. - * @property {(float|{x:float,y:float})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. - * @property {(float|{x:float,y:float})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. + * @property {(number|{x:number,y:number})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. + * @property {(number|{x:number,y:number})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. */ /** @@ -143122,7 +152587,7 @@ var GetValue = __webpack_require__(4); * [description] * * @class SmoothedKeyControl - * @memberOf Phaser.Cameras.Controls + * @memberof Phaser.Cameras.Controls * @constructor * @since 3.0.0 * @@ -143208,7 +152673,7 @@ var SmoothedKeyControl = new Class({ * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed - * @type {float} + * @type {number} * @default 0.01 * @since 3.0.0 */ @@ -143218,7 +152683,7 @@ var SmoothedKeyControl = new Class({ * The horizontal acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -143228,7 +152693,7 @@ var SmoothedKeyControl = new Class({ * The vertical acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -143251,7 +152716,7 @@ var SmoothedKeyControl = new Class({ * The horizontal drag applied to the camera when it is moving. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -143261,7 +152726,7 @@ var SmoothedKeyControl = new Class({ * The vertical drag applied to the camera when it is moving. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -143284,7 +152749,7 @@ var SmoothedKeyControl = new Class({ * The maximum horizontal speed the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -143294,7 +152759,7 @@ var SmoothedKeyControl = new Class({ * The maximum vertical speed the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -143565,7 +153030,7 @@ module.exports = SmoothedKeyControl; /***/ }), -/* 958 */ +/* 989 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -143591,10 +153056,11 @@ var GetValue = __webpack_require__(4); * @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left. * @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right. * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. + * @property {Phaser.Input.Keyboard.Key} [down] - The Key to be pressed that will move the Camera down. * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. - * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * @property {(float|{x:float,y:float})} [speed=0] - The horizontal and vertical speed the camera will move. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [speed=0] - The horizontal and vertical speed the camera will move. */ /** @@ -143602,7 +153068,7 @@ var GetValue = __webpack_require__(4); * [description] * * @class FixedKeyControl - * @memberOf Phaser.Cameras.Controls + * @memberof Phaser.Cameras.Controls * @constructor * @since 3.0.0 * @@ -143688,7 +153154,7 @@ var FixedKeyControl = new Class({ * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. * * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed - * @type {float} + * @type {number} * @default 0.01 * @since 3.0.0 */ @@ -143698,7 +153164,7 @@ var FixedKeyControl = new Class({ * The horizontal speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -143708,7 +153174,7 @@ var FixedKeyControl = new Class({ * The vertical speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -143801,7 +153267,7 @@ var FixedKeyControl = new Class({ * @method Phaser.Cameras.Controls.FixedKeyControl#update * @since 3.0.0 * - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (delta) { @@ -143874,7 +153340,7 @@ module.exports = FixedKeyControl; /***/ }), -/* 959 */ +/* 990 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -143889,14 +153355,14 @@ module.exports = FixedKeyControl; module.exports = { - FixedKeyControl: __webpack_require__(958), - SmoothedKeyControl: __webpack_require__(957) + FixedKeyControl: __webpack_require__(989), + SmoothedKeyControl: __webpack_require__(988) }; /***/ }), -/* 960 */ +/* 991 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -143911,15 +153377,59 @@ module.exports = { module.exports = { - Controls: __webpack_require__(959), - Scene2D: __webpack_require__(566), - Sprite3D: __webpack_require__(956) + Controls: __webpack_require__(990), + Scene2D: __webpack_require__(987) }; /***/ }), -/* 961 */ +/* 992 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Cache + */ + +module.exports = { + + BaseCache: __webpack_require__(380), + CacheManager: __webpack_require__(379) + +}; + + +/***/ }), +/* 993 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Animations + */ + +module.exports = { + + Animation: __webpack_require__(384), + AnimationFrame: __webpack_require__(382), + AnimationManager: __webpack_require__(381) + +}; + + +/***/ }), +/* 994 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -143929,7 +153439,7 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Wrap = __webpack_require__(39); +var Wrap = __webpack_require__(53); /** * Wrap each item's coordinates within a rectangle's area. @@ -143968,7 +153478,7 @@ module.exports = WrapInRectangle; /***/ }), -/* 962 */ +/* 995 */ /***/ (function(module, exports) { /** @@ -143978,7 +153488,8 @@ module.exports = WrapInRectangle; */ /** - * [description] + * Takes an array of Game Objects and toggles the visibility of each one. + * Those previously `visible = false` will become `visible = true`, and vice versa. * * @function Phaser.Actions.ToggleVisible * @since 3.0.0 @@ -144003,7 +153514,7 @@ module.exports = ToggleVisible; /***/ }), -/* 963 */ +/* 996 */ /***/ (function(module, exports) { /** @@ -144013,7 +153524,16 @@ module.exports = ToggleVisible; */ /** - * [description] + * Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, the + * calculated spread value. + * + * The spread value is derived from the given `min` and `max` values and the total number of items in the array.//#endregion + * + * For example, to cause an array of Sprites to change in alpha from 0 to 1 you could call: + * + * ```javascript + * Phaser.Actions.Spread(itemsArray, 'alpha', 0, 1); + * ``` * * @function Phaser.Actions.Spread * @since 3.0.0 @@ -144021,12 +153541,12 @@ module.exports = ToggleVisible; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} [inc=false] - [description] + * @param {string} property - The property of the Game Object to spread. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * - * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that were passed to this Action. */ var Spread = function (items, property, min, max, inc) { @@ -144057,7 +153577,7 @@ module.exports = Spread; /***/ }), -/* 964 */ +/* 997 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144066,10 +153586,12 @@ module.exports = Spread; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathSmoothStep = __webpack_require__(286); +var MathSmoothStep = __webpack_require__(181); /** - * [description] + * Smoothstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * * @function Phaser.Actions.SmoothStep * @since 3.0.0 @@ -144077,10 +153599,10 @@ var MathSmoothStep = __webpack_require__(286); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The minimum interpolation value. + * @param {number} max - The maximum interpolation value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -144113,7 +153635,7 @@ module.exports = SmoothStep; /***/ }), -/* 965 */ +/* 998 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144122,10 +153644,12 @@ module.exports = SmoothStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathSmootherStep = __webpack_require__(287); +var MathSmootherStep = __webpack_require__(182); /** - * [description] + * Smootherstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * * @function Phaser.Actions.SmootherStep * @since 3.0.0 @@ -144133,10 +153657,10 @@ var MathSmootherStep = __webpack_require__(287); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The minimum interpolation value. + * @param {number} max - The maximum interpolation value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -144169,7 +153693,7 @@ module.exports = SmootherStep; /***/ }), -/* 966 */ +/* 999 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144178,7 +153702,7 @@ module.exports = SmootherStep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var ArrayShuffle = __webpack_require__(95); +var ArrayShuffle = __webpack_require__(122); /** * Shuffles the array in place. The shuffled array is both modified and returned. @@ -144202,7 +153726,7 @@ module.exports = Shuffle; /***/ }), -/* 967 */ +/* 1000 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144211,12 +153735,14 @@ module.exports = Shuffle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Vector2 = __webpack_require__(6); +var Vector2 = __webpack_require__(3); /** - * Iterate through items changing the position of each element to - * be that of the element that came before it in the array (or after it if direction = 1) + * Iterate through the items array changing the position of each element to be that of the element that came before + * it in the array (or after it if direction = 1) + * * The first items position is set to x/y. + * * The final x/y coords are returned * * @function Phaser.Actions.ShiftPosition @@ -144226,10 +153752,10 @@ var Vector2 = __webpack_require__(6); * @generic {Phaser.Math.Vector2} O - [output,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * @param {integer} [direction=0] - [description] - * @param {(Phaser.Math.Vector2|object)} [output] - [description] + * @param {number} x - The x coordinate to place the first item in the array at. + * @param {number} y - The y coordinate to place the first item in the array at. + * @param {integer} [direction=0] - The iteration direction. 0 = first to last and 1 = last to first. + * @param {(Phaser.Math.Vector2|object)} [output] - An optional objec to store the final objects position in. * * @return {Phaser.Math.Vector2} The output vector. */ @@ -144330,7 +153856,7 @@ module.exports = ShiftPosition; /***/ }), -/* 968 */ +/* 1001 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144371,7 +153897,7 @@ module.exports = SetY; /***/ }), -/* 969 */ +/* 1002 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144418,7 +153944,7 @@ module.exports = SetXY; /***/ }), -/* 970 */ +/* 1003 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144459,7 +153985,7 @@ module.exports = SetX; /***/ }), -/* 971 */ +/* 1004 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144497,7 +154023,7 @@ module.exports = SetVisible; /***/ }), -/* 972 */ +/* 1005 */ /***/ (function(module, exports) { /** @@ -144507,7 +154033,7 @@ module.exports = SetVisible; */ /** - * [description] + * Takes an array of Game Objects, or any objects that have the public method setTint() and then updates it to the given value(s). You can specify tint color per corner or provide only one color value for `topLeft` parameter, in which case whole item will be tinted with that color. * * @function Phaser.Actions.SetTint * @since 3.0.0 @@ -144515,10 +154041,10 @@ module.exports = SetVisible; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} topLeft - [description] - * @param {number} [topRight] - [description] - * @param {number} [bottomLeft] - [description] - * @param {number} [bottomRight] - [description] + * @param {number} topLeft - The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. + * @param {number} [topRight] - The tint to be applied to top-right corner of item. + * @param {number} [bottomLeft] - The tint to be applied to the bottom-left corner of item. + * @param {number} [bottomRight] - The tint to be applied to the bottom-right corner of item. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -144536,7 +154062,7 @@ module.exports = SetTint; /***/ }), -/* 973 */ +/* 1006 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144577,7 +154103,7 @@ module.exports = SetScaleY; /***/ }), -/* 974 */ +/* 1007 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144618,7 +154144,7 @@ module.exports = SetScaleX; /***/ }), -/* 975 */ +/* 1008 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144665,7 +154191,7 @@ module.exports = SetScale; /***/ }), -/* 976 */ +/* 1009 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144706,7 +154232,7 @@ module.exports = SetRotation; /***/ }), -/* 977 */ +/* 1010 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144753,7 +154279,7 @@ module.exports = SetOrigin; /***/ }), -/* 978 */ +/* 1011 */ /***/ (function(module, exports) { /** @@ -144763,7 +154289,9 @@ module.exports = SetOrigin; */ /** - * [description] + * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. + * + * @see {@link Phaser.GameObjects.GameObject#setInteractive} * * @function Phaser.Actions.SetHitArea * @since 3.0.0 @@ -144771,8 +154299,8 @@ module.exports = SetOrigin; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {*} hitArea - [description] - * @param {HitAreaCallback} hitAreaCallback - [description] + * @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -144790,7 +154318,7 @@ module.exports = SetHitArea; /***/ }), -/* 979 */ +/* 1012 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144831,7 +154359,7 @@ module.exports = SetDepth; /***/ }), -/* 980 */ +/* 1013 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144871,7 +154399,7 @@ module.exports = SetBlendMode; /***/ }), -/* 981 */ +/* 1014 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144912,7 +154440,7 @@ module.exports = SetAlpha; /***/ }), -/* 982 */ +/* 1015 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144921,7 +154449,7 @@ module.exports = SetAlpha; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `scaleY` property, @@ -144953,7 +154481,7 @@ module.exports = ScaleY; /***/ }), -/* 983 */ +/* 1016 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -144962,7 +154490,7 @@ module.exports = ScaleY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, @@ -145000,7 +154528,7 @@ module.exports = ScaleXY; /***/ }), -/* 984 */ +/* 1017 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145009,7 +154537,7 @@ module.exports = ScaleXY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `scaleX` property, @@ -145041,7 +154569,7 @@ module.exports = ScaleX; /***/ }), -/* 985 */ +/* 1018 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145050,10 +154578,10 @@ module.exports = ScaleX; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MathRotateAroundDistance = __webpack_require__(288); +var MathRotateAroundDistance = __webpack_require__(183); /** - * [description] + * Rotates an array of Game Objects around a point by the given angle and distance. * * @function Phaser.Actions.RotateAroundDistance * @since 3.0.0 @@ -145090,7 +154618,7 @@ module.exports = RotateAroundDistance; /***/ }), -/* 986 */ +/* 1019 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145099,8 +154627,8 @@ module.exports = RotateAroundDistance; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RotateAroundDistance = __webpack_require__(288); -var DistanceBetween = __webpack_require__(58); +var RotateAroundDistance = __webpack_require__(183); +var DistanceBetween = __webpack_require__(52); /** * Rotates each item around the given point by the given angle. @@ -145136,7 +154664,7 @@ module.exports = RotateAround; /***/ }), -/* 987 */ +/* 1020 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145145,7 +154673,7 @@ module.exports = RotateAround; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `rotation` property, @@ -145177,7 +154705,7 @@ module.exports = Rotate; /***/ }), -/* 988 */ +/* 1021 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145186,10 +154714,12 @@ module.exports = Rotate; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(153); +var Random = __webpack_require__(184); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomTriangle * @since 3.0.0 @@ -145197,7 +154727,7 @@ var Random = __webpack_require__(153); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145215,7 +154745,7 @@ module.exports = RandomTriangle; /***/ }), -/* 989 */ +/* 1022 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145224,10 +154754,10 @@ module.exports = RandomTriangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(154); +var Random = __webpack_require__(187); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Ellipse. * * @function Phaser.Actions.RandomRectangle * @since 3.0.0 @@ -145235,7 +154765,7 @@ var Random = __webpack_require__(154); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145253,7 +154783,7 @@ module.exports = RandomRectangle; /***/ }), -/* 990 */ +/* 1023 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145262,10 +154792,12 @@ module.exports = RandomRectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(155); +var Random = __webpack_require__(188); /** - * [description] + * Takes an array of Game Objects and positions them at random locations on the Line. + * + * If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomLine * @since 3.0.0 @@ -145273,7 +154805,7 @@ var Random = __webpack_require__(155); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects randomly on. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145291,7 +154823,7 @@ module.exports = RandomLine; /***/ }), -/* 991 */ +/* 1024 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145300,10 +154832,12 @@ module.exports = RandomLine; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(134); +var Random = __webpack_require__(185); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomEllipse * @since 3.0.0 @@ -145311,7 +154845,7 @@ var Random = __webpack_require__(134); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145329,7 +154863,7 @@ module.exports = RandomEllipse; /***/ }), -/* 992 */ +/* 1025 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145338,10 +154872,12 @@ module.exports = RandomEllipse; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Random = __webpack_require__(157); +var Random = __webpack_require__(191); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomCircle * @since 3.0.0 @@ -145349,7 +154885,7 @@ var Random = __webpack_require__(157); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145367,7 +154903,7 @@ module.exports = RandomCircle; /***/ }), -/* 993 */ +/* 1026 */ /***/ (function(module, exports) { /** @@ -145404,7 +154940,7 @@ module.exports = PlayAnimation; /***/ }), -/* 994 */ +/* 1027 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145413,11 +154949,12 @@ module.exports = PlayAnimation; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// var GetPointsOnLine = require('../geom/line/GetPointsOnLine'); -var BresenhamPoints = __webpack_require__(569); +var BresenhamPoints = __webpack_require__(385); /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnTriangle * @since 3.0.0 @@ -145425,8 +154962,8 @@ var BresenhamPoints = __webpack_require__(569); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} [stepRate=1] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects on. + * @param {number} [stepRate=1] - An optional step rate, to increase or decrease the packing of the Game Objects on the lines. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145464,7 +155001,7 @@ module.exports = PlaceOnTriangle; /***/ }), -/* 995 */ +/* 1028 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145473,18 +155010,15 @@ module.exports = PlaceOnTriangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MarchingAnts = __webpack_require__(570); -var RotateLeft = __webpack_require__(290); -var RotateRight = __webpack_require__(289); - -// Place the items in the array around the perimeter of the given rectangle. - -// Placement starts from the top-left of the rectangle, and proceeds in a -// clockwise direction. If the shift parameter is given you can offset where -// placement begins. +var MarchingAnts = __webpack_require__(388); +var RotateLeft = __webpack_require__(387); +var RotateRight = __webpack_require__(386); /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. + * + * Placement starts from the top-left of the rectangle, and proceeds in a clockwise direction. + * If the `shift` parameter is given you can offset where placement begins. * * @function Phaser.Actions.PlaceOnRectangle * @since 3.0.0 @@ -145492,8 +155026,8 @@ var RotateRight = __webpack_require__(289); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {integer} [shift=1] - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects on. + * @param {integer} [shift=1] - An optional positional offset. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145525,7 +155059,7 @@ module.exports = PlaceOnRectangle; /***/ }), -/* 996 */ +/* 1029 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145534,10 +155068,10 @@ module.exports = PlaceOnRectangle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GetPoints = __webpack_require__(156); +var GetPoints = __webpack_require__(189); /** - * [description] + * Positions an array of Game Objects on evenly spaced points of a Line. * * @function Phaser.Actions.PlaceOnLine * @since 3.0.0 @@ -145545,7 +155079,7 @@ var GetPoints = __webpack_require__(156); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects on. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145569,7 +155103,7 @@ module.exports = PlaceOnLine; /***/ }), -/* 997 */ +/* 1030 */ /***/ (function(module, exports) { /** @@ -145579,7 +155113,9 @@ module.exports = PlaceOnLine; */ /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnEllipse * @since 3.0.0 @@ -145587,9 +155123,9 @@ module.exports = PlaceOnLine; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145619,7 +155155,7 @@ module.exports = PlaceOnEllipse; /***/ }), -/* 998 */ +/* 1031 */ /***/ (function(module, exports) { /** @@ -145629,7 +155165,9 @@ module.exports = PlaceOnEllipse; */ /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnCircle * @since 3.0.0 @@ -145637,9 +155175,9 @@ module.exports = PlaceOnEllipse; * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ @@ -145666,7 +155204,7 @@ module.exports = PlaceOnCircle; /***/ }), -/* 999 */ +/* 1032 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145675,7 +155213,7 @@ module.exports = PlaceOnCircle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `y` property, @@ -145707,7 +155245,7 @@ module.exports = IncY; /***/ }), -/* 1000 */ +/* 1033 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145716,7 +155254,7 @@ module.exports = IncY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, @@ -145754,7 +155292,7 @@ module.exports = IncXY; /***/ }), -/* 1001 */ +/* 1034 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145763,7 +155301,7 @@ module.exports = IncXY; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `x` property, @@ -145795,7 +155333,7 @@ module.exports = IncX; /***/ }), -/* 1002 */ +/* 1035 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145804,7 +155342,7 @@ module.exports = IncX; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `alpha` property, @@ -145836,7 +155374,871 @@ module.exports = IncAlpha; /***/ }), -/* 1003 */ +/* 1036 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @function GetColor + * @since 3.0.0 + * @private + */ +var GetColor = function (value) +{ + return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); +}; + +/** + * Provides methods used for setting the tint of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Tint + * @webglOnly + * @since 3.0.0 + */ + +var Tint = { + + /** + * Private internal value. Holds the top-left tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintTL + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintTL: 16777215, + + /** + * Private internal value. Holds the top-right tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintTR + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintTR: 16777215, + + /** + * Private internal value. Holds the bottom-left tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintBL + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintBL: 16777215, + + /** + * Private internal value. Holds the bottom-right tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintBR + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintBR: 16777215, + + /** + * Private internal value. Holds if the Game Object is tinted or not. + * + * @name Phaser.GameObjects.Components.Tint#_isTinted + * @type {boolean} + * @private + * @default false + * @since 3.11.0 + */ + _isTinted: false, + + /** + * Fill or additive? + * + * @name Phaser.GameObjects.Components.Tint#tintFill + * @type {boolean} + * @default false + * @since 3.11.0 + */ + tintFill: false, + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + * + * @method Phaser.GameObjects.Components.Tint#clearTint + * @webglOnly + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearTint: function () + { + this.setTint(0xffffff); + + this._isTinted = false; + + return this; + }, + + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * + * @method Phaser.GameObjects.Components.Tint#setTint + * @webglOnly + * @since 3.0.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTint: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 0xffffff; } + + if (topRight === undefined) + { + topRight = topLeft; + bottomLeft = topLeft; + bottomRight = topLeft; + } + + this._tintTL = GetColor(topLeft); + this._tintTR = GetColor(topRight); + this._tintBL = GetColor(bottomLeft); + this._tintBR = GetColor(bottomRight); + + this._isTinted = true; + + this.tintFill = false; + + return this; + }, + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * + * @method Phaser.GameObjects.Components.Tint#setTintFill + * @webglOnly + * @since 3.11.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTintFill: function (topLeft, topRight, bottomLeft, bottomRight) + { + this.setTint(topLeft, topRight, bottomLeft, bottomRight); + + this.tintFill = true; + + return this; + }, + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopLeft: { + + get: function () + { + return this._tintTL; + }, + + set: function (value) + { + this._tintTL = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopRight: { + + get: function () + { + return this._tintTR; + }, + + set: function (value) + { + this._tintTR = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomLeft: { + + get: function () + { + return this._tintBL; + }, + + set: function (value) + { + this._tintBL = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomRight: { + + get: function () + { + return this._tintBR; + }, + + set: function (value) + { + this._tintBR = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the whole of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tint + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tint: { + + set: function (value) + { + this.setTint(value, value, value, value); + } + }, + + /** + * Does this Game Object have a tint applied to it or not? + * + * @name Phaser.GameObjects.Components.Tint#isTinted + * @type {boolean} + * @webglOnly + * @readonly + * @since 3.11.0 + */ + isTinted: { + + get: function () + { + return this._isTinted; + } + + } + +}; + +module.exports = Tint; + + +/***/ }), +/* 1037 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.TextureCrop + * @since 3.0.0 + */ + +var TextureCrop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.TextureCrop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.TextureCrop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.TextureCrop#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.TextureCrop#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + if (this.isCropped) + { + this.frame.updateCropUVs(this._crop, this.flipX, this.flipY); + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.TextureCrop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = TextureCrop; + + +/***/ }), +/* 1038 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Texture + * @since 3.0.0 + */ + +var Texture = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * Internal flag. Not to be set by this Game Object. + * + * @name Phaser.GameObjects.Components.Texture#isCropped + * @type {boolean} + * @private + * @since 3.11.0 + */ + isCropped: false, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.Texture#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.Texture#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + return this; + } + +}; + +module.exports = Texture; + + +/***/ }), +/* 1039 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the size of a Game Object. + * + * @name Phaser.GameObjects.Components.Size + * @since 3.0.0 + */ + +var Size = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Size#_sizeComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _sizeComponent: true, + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.Size#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.Size#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.frame.realWidth; + }, + + set: function (value) + { + this.scaleX = value / this.frame.realWidth; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.frame.realHeight; + }, + + set: function (value) + { + this.scaleY = value / this.frame.realHeight; + } + + }, + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.Size#setSizeToFrame + * @since 3.0.0 + * + * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. + * + * @return {this} This Game Object instance. + */ + setSizeToFrame: function (frame) + { + if (frame === undefined) { frame = this.frame; } + + this.width = frame.realWidth; + this.height = frame.realHeight; + + return this; + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.Size#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = Size; + + +/***/ }), +/* 1040 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -145845,11 +156247,989 @@ module.exports = IncAlpha; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AlignIn = __webpack_require__(598); -var CONST = __webpack_require__(299); -var GetFastValue = __webpack_require__(1); -var NOOP = __webpack_require__(3); -var Zone = __webpack_require__(158); +var ScaleModes = __webpack_require__(94); + +/** + * Provides methods used for getting and setting the scale of a Game Object. + * + * @name Phaser.GameObjects.Components.ScaleMode + * @since 3.0.0 + */ + +var ScaleMode = { + + _scaleMode: ScaleModes.DEFAULT, + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @name Phaser.GameObjects.Components.ScaleMode#scaleMode + * @type {Phaser.ScaleModes} + * @since 3.0.0 + */ + scaleMode: { + + get: function () + { + return this._scaleMode; + }, + + set: function (value) + { + if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) + { + this._scaleMode = value; + } + } + + }, + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode + * @since 3.0.0 + * + * @param {Phaser.ScaleModes} value - The Scale Mode to be used by this Game Object. + * + * @return {this} This Game Object instance. + */ + setScaleMode: function (value) + { + this.scaleMode = value; + + return this; + } + +}; + +module.exports = ScaleMode; + + +/***/ }), +/* 1041 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the origin of a Game Object. + * Values are normalized, given in the range 0 to 1. + * Display values contain the calculated pixel values. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Origin + * @since 3.0.0 + */ + +var Origin = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Origin#_originComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _originComponent: true, + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originX + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originX: 0.5, + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originY + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originY: 0.5, + + // private + read only + _displayOriginX: 0, + _displayOriginY: 0, + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginX + * @type {number} + * @since 3.0.0 + */ + displayOriginX: { + + get: function () + { + return this._displayOriginX; + }, + + set: function (value) + { + this._displayOriginX = value; + this.originX = value / this.width; + } + + }, + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginY + * @type {number} + * @since 3.0.0 + */ + displayOriginY: { + + get: function () + { + return this._displayOriginY; + }, + + set: function (value) + { + this._displayOriginY = value; + this.originY = value / this.height; + } + + }, + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * + * @method Phaser.GameObjects.Components.Origin#setOrigin + * @since 3.0.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + * + * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + setOriginFromFrame: function () + { + if (!this.frame || !this.frame.customPivot) + { + return this.setOrigin(); + } + else + { + this.originX = this.frame.pivotX; + this.originY = this.frame.pivotY; + } + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * + * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal display origin value. + * @param {number} [y=x] - The vertical display origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setDisplayOrigin: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.displayOriginX = x; + this.displayOriginY = y; + + return this; + }, + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + * + * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + updateDisplayOrigin: function () + { + this._displayOriginX = Math.round(this.originX * this.width); + this._displayOriginY = Math.round(this.originY * this.height); + + return this; + } + +}; + +module.exports = Origin; + + +/***/ }), +/* 1042 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(9); +var RotateAround = __webpack_require__(396); +var Vector2 = __webpack_require__(3); + +/** + * Provides methods used for obtaining the bounds of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.GetBounds + * @since 3.0.0 + */ + +var GetBounds = { + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getCenter + * @since 3.0.0 + * + * @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. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getCenter: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); + output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); + + return output; + }, + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getTopLeft + * @since 3.0.0 + * + * @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, includeParent) + { + 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); + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getTopRight + * @since 3.0.0 + * + * @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, includeParent) + { + 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); + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft + * @since 3.0.0 + * + * @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, includeParent) + { + 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; + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomRight + * @since 3.0.0 + * + * @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, includeParent) + { + 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; + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * + * @method Phaser.GameObjects.Components.GetBounds#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [output,$return] + * + * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + // We can use the output object to temporarily store the x/y coords in: + + var TLx, TLy, TRx, TRy, BLx, BLy, BRx, BRy; + + // Instead of doing a check if parent container is + // defined per corner we only do it once. + if (this.parentContainer) + { + var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); + + this.getTopLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BRx = output.x; + BRy = output.y; + } + else + { + this.getTopLeft(output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + + BRx = output.x; + BRy = output.y; + } + + output.x = Math.min(TLx, TRx, BLx, BRx); + output.y = Math.min(TLy, TRy, BLy, BRy); + output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; + output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; + + return output; + } + +}; + +module.exports = GetBounds; + + +/***/ }), +/* 1043 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for visually flipping a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Flip + * @since 3.0.0 + */ + +var Flip = { + + /** + * The horizontally flipped state of the Game Object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipX: false, + + /** + * The vertically flipped state of the Game Object. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipY: false, + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipX + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipX: function () + { + this.flipX = !this.flipX; + + return this; + }, + + /** + * Toggles the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipY + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipY: function () + { + this.flipY = !this.flipY; + + return this; + }, + + /** + * Sets the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * + * @method Phaser.GameObjects.Components.Flip#resetFlip + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + } + +}; + +module.exports = Flip; + + +/***/ }), +/* 1044 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Crop + * @since 3.12.0 + */ + +var Crop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.Crop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.Crop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.Crop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = Crop; + + +/***/ }), +/* 1045 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for calculating and setting the size of a non-Frame based Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.ComputedSize + * @since 3.0.0 + */ + +var ComputedSize = { + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.ComputedSize#setSize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = ComputedSize; + + +/***/ }), +/* 1046 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AlignIn = __webpack_require__(416); +var CONST = __webpack_require__(193); +var GetFastValue = __webpack_require__(2); +var NOOP = __webpack_require__(1); +var Zone = __webpack_require__(125); var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1); @@ -145960,7 +157340,7 @@ module.exports = GridAlign; /***/ }), -/* 1004 */ +/* 1047 */ /***/ (function(module, exports) { /** @@ -146018,7 +157398,7 @@ module.exports = GetLast; /***/ }), -/* 1005 */ +/* 1048 */ /***/ (function(module, exports) { /** @@ -146076,7 +157456,7 @@ module.exports = GetFirst; /***/ }), -/* 1006 */ +/* 1049 */ /***/ (function(module, exports) { /** @@ -146088,7 +157468,7 @@ module.exports = GetFirst; /** * @callback CallCallback * - * @param {Phaser.GameObjects.GameObject} item - [description] + * @param {Phaser.GameObjects.GameObject} item - The Game Object to run the callback on. */ /** @@ -146121,7 +157501,7 @@ module.exports = Call; /***/ }), -/* 1007 */ +/* 1050 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -146130,7 +157510,7 @@ module.exports = Call; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var PropertyValueInc = __webpack_require__(35); +var PropertyValueInc = __webpack_require__(32); /** * Takes an array of Game Objects, or any objects that have a public `angle` property, @@ -146162,7 +157542,454 @@ module.exports = Angle; /***/ }), -/* 1008 */ +/* 1051 */ +/***/ (function(module, exports) { + +/** +* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 +* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ +* Cameron Foale (http://www.kibibu.com) +*/ +if (typeof window.Uint32Array !== 'function' && typeof window.Uint32Array !== 'object') +{ + var CheapArray = function (fakeType) + { + var proto = new Array(); // jshint ignore:line + + window[fakeType] = function(arg) { + + if (typeof(arg) === 'number') + { + Array.call(this, arg); + + this.length = arg; + + for (var i = 0; i < this.length; i++) + { + this[i] = 0; + } + } + else + { + Array.call(this, arg.length); + + this.length = arg.length; + + for (var i = 0; i < this.length; i++) + { + this[i] = arg[i]; + } + } + }; + + window[fakeType].prototype = proto; + window[fakeType].constructor = window[fakeType]; + }; + + CheapArray('Float32Array'); // jshint ignore:line + CheapArray('Uint32Array'); // jshint ignore:line + CheapArray('Uint16Array'); // jshint ignore:line + CheapArray('Int16Array'); // jshint ignore:line + CheapArray('ArrayBuffer'); // jshint ignore:line +} + + +/***/ }), +/* 1052 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {// References: +// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ +// https://gist.github.com/1579671 +// http://updates.html5rocks.com/2012/05/requestAnimationFrame-API-now-with-sub-millisecond-precision +// https://gist.github.com/timhall/4078614 +// https://github.com/Financial-Times/polyfill-service/tree/master/polyfills/requestAnimationFrame + +// Expected to be used with Browserfiy +// Browserify automatically detects the use of `global` and passes the +// correct reference of `global`, `self`, and finally `window` + +// Date.now +if (!(Date.now && Date.prototype.getTime)) { + Date.now = function now() { + return new Date().getTime(); + }; +} + +// performance.now +if (!(global.performance && global.performance.now)) { + var startTime = Date.now(); + if (!global.performance) { + global.performance = {}; + } + global.performance.now = function () { + return Date.now() - startTime; + }; +} + +// requestAnimationFrame +var lastTime = Date.now(); +var vendors = ['ms', 'moz', 'webkit', 'o']; + +for(var x = 0; x < vendors.length && !global.requestAnimationFrame; ++x) { + global.requestAnimationFrame = global[vendors[x] + 'RequestAnimationFrame']; + global.cancelAnimationFrame = global[vendors[x] + 'CancelAnimationFrame'] || + global[vendors[x] + 'CancelRequestAnimationFrame']; +} + +if (!global.requestAnimationFrame) { + global.requestAnimationFrame = function (callback) { + if (typeof callback !== 'function') { + throw new TypeError(callback + 'is not a function'); + } + + var currentTime = Date.now(), + delay = 16 + lastTime - currentTime; + + if (delay < 0) { + delay = 0; + } + + lastTime = currentTime; + + return setTimeout(function () { + lastTime = Date.now(); + callback(performance.now()); + }, delay); + }; +} + +if (!global.cancelAnimationFrame) { + global.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; +} + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(200))) + +/***/ }), +/* 1053 */ +/***/ (function(module, exports) { + +/** + * performance.now + */ +(function () { + + if ('performance' in window === false) + { + window.performance = {}; + } + + // Thanks IE8 + Date.now = (Date.now || function () { + return new Date().getTime(); + }); + + if ('now' in window.performance === false) + { + var nowOffset = Date.now(); + + if (performance.timing && performance.timing.navigationStart) + { + nowOffset = performance.timing.navigationStart; + } + + window.performance.now = function now () + { + return Date.now() - nowOffset; + } + } + +})(); + + +/***/ }), +/* 1054 */ +/***/ (function(module, exports) { + +// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc +if (!Math.trunc) { + Math.trunc = function trunc(x) { + return x < 0 ? Math.ceil(x) : Math.floor(x); + }; +} + + +/***/ }), +/* 1055 */ +/***/ (function(module, exports) { + +/** + * Also fix for the absent console in IE9 + */ +if (!window.console) +{ + window.console = {}; + window.console.log = window.console.assert = function(){}; + window.console.warn = window.console.assert = function(){}; +} + + +/***/ }), +/* 1056 */ +/***/ (function(module, exports) { + +/* Copyright 2013 Chris Wilson + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + +This monkeypatch library is intended to be included in projects that are +written to the proper AudioContext spec (instead of webkitAudioContext), +and that use the new naming and proper bits of the Web Audio API (e.g. +using BufferSourceNode.start() instead of BufferSourceNode.noteOn()), but may +have to run on systems that only support the deprecated bits. + +This library should be harmless to include if the browser supports +unprefixed "AudioContext", and/or if it supports the new names. + +The patches this library handles: +if window.AudioContext is unsupported, it will be aliased to webkitAudioContext(). +if AudioBufferSourceNode.start() is unimplemented, it will be routed to noteOn() or +noteGrainOn(), depending on parameters. + +The following aliases only take effect if the new names are not already in place: + +AudioBufferSourceNode.stop() is aliased to noteOff() +AudioContext.createGain() is aliased to createGainNode() +AudioContext.createDelay() is aliased to createDelayNode() +AudioContext.createScriptProcessor() is aliased to createJavaScriptNode() +AudioContext.createPeriodicWave() is aliased to createWaveTable() +OscillatorNode.start() is aliased to noteOn() +OscillatorNode.stop() is aliased to noteOff() +OscillatorNode.setPeriodicWave() is aliased to setWaveTable() +AudioParam.setTargetAtTime() is aliased to setTargetValueAtTime() + +This library does NOT patch the enumerated type changes, as it is +recommended in the specification that implementations support both integer +and string types for AudioPannerNode.panningModel, AudioPannerNode.distanceModel +BiquadFilterNode.type and OscillatorNode.type. + +*/ + +(function () { + + function fixSetTarget(param) { + if (!param) // if NYI, just return + return; + if (!param.setTargetAtTime) + param.setTargetAtTime = param.setTargetValueAtTime; + } + + if (window.hasOwnProperty('webkitAudioContext') && + !window.hasOwnProperty('AudioContext')) { + window.AudioContext = webkitAudioContext; + + if (!AudioContext.prototype.hasOwnProperty('createGain')) + AudioContext.prototype.createGain = AudioContext.prototype.createGainNode; + if (!AudioContext.prototype.hasOwnProperty('createDelay')) + AudioContext.prototype.createDelay = AudioContext.prototype.createDelayNode; + if (!AudioContext.prototype.hasOwnProperty('createScriptProcessor')) + AudioContext.prototype.createScriptProcessor = AudioContext.prototype.createJavaScriptNode; + if (!AudioContext.prototype.hasOwnProperty('createPeriodicWave')) + AudioContext.prototype.createPeriodicWave = AudioContext.prototype.createWaveTable; + + + AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain; + AudioContext.prototype.createGain = function() { + var node = this.internal_createGain(); + fixSetTarget(node.gain); + return node; + }; + + AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay; + AudioContext.prototype.createDelay = function(maxDelayTime) { + var node = maxDelayTime ? this.internal_createDelay(maxDelayTime) : this.internal_createDelay(); + fixSetTarget(node.delayTime); + return node; + }; + + AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource; + AudioContext.prototype.createBufferSource = function() { + var node = this.internal_createBufferSource(); + if (!node.start) { + node.start = function ( when, offset, duration ) { + if ( offset || duration ) + this.noteGrainOn( when || 0, offset, duration ); + else + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function( when, offset, duration ) { + if( typeof duration !== 'undefined' ) + node.internal_start( when || 0, offset, duration ); + else + node.internal_start( when || 0, offset || 0 ); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + fixSetTarget(node.playbackRate); + return node; + }; + + AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor; + AudioContext.prototype.createDynamicsCompressor = function() { + var node = this.internal_createDynamicsCompressor(); + fixSetTarget(node.threshold); + fixSetTarget(node.knee); + fixSetTarget(node.ratio); + fixSetTarget(node.reduction); + fixSetTarget(node.attack); + fixSetTarget(node.release); + return node; + }; + + AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter; + AudioContext.prototype.createBiquadFilter = function() { + var node = this.internal_createBiquadFilter(); + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + fixSetTarget(node.Q); + fixSetTarget(node.gain); + return node; + }; + + if (AudioContext.prototype.hasOwnProperty( 'createOscillator' )) { + AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator; + AudioContext.prototype.createOscillator = function() { + var node = this.internal_createOscillator(); + if (!node.start) { + node.start = function ( when ) { + this.noteOn( when || 0 ); + }; + } else { + node.internal_start = node.start; + node.start = function ( when ) { + node.internal_start( when || 0); + }; + } + if (!node.stop) { + node.stop = function ( when ) { + this.noteOff( when || 0 ); + }; + } else { + node.internal_stop = node.stop; + node.stop = function( when ) { + node.internal_stop( when || 0 ); + }; + } + if (!node.setPeriodicWave) + node.setPeriodicWave = node.setWaveTable; + fixSetTarget(node.frequency); + fixSetTarget(node.detune); + return node; + }; + } + } + + if (window.hasOwnProperty('webkitOfflineAudioContext') && + !window.hasOwnProperty('OfflineAudioContext')) { + window.OfflineAudioContext = webkitOfflineAudioContext; + } + +})(); + + +/***/ }), +/* 1057 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.isArray +*/ +if (!Array.isArray) +{ + Array.isArray = function (arg) + { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; +} + + +/***/ }), +/* 1058 */ +/***/ (function(module, exports) { + +/** +* A polyfill for Array.forEach +* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach +*/ +if (!Array.prototype.forEach) +{ + Array.prototype.forEach = function (fun /*, thisArg */) + { + 'use strict'; + + if (this === void 0 || this === null) + { + throw new TypeError(); + } + + var t = Object(this); + var len = t.length >>> 0; + + if (typeof fun !== 'function') + { + throw new TypeError(); + } + + var thisArg = arguments.length >= 2 ? arguments[1] : void 0; + + for (var i = 0; i < len; i++) + { + if (i in t) + { + fun.call(thisArg, t[i], i, t); + } + } + }; +} + + +/***/ }), +/* 1059 */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__(1058); +__webpack_require__(1057); +__webpack_require__(1056); +__webpack_require__(1055); +__webpack_require__(1054); +__webpack_require__(1053); +__webpack_require__(1052); +__webpack_require__(1051); + + +/***/ }), +/* 1060 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -146171,19 +157998,19 @@ module.exports = Angle; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Bodies = __webpack_require__(166); +var Bodies = __webpack_require__(126); var Class = __webpack_require__(0); -var Common = __webpack_require__(41); -var Composite = __webpack_require__(221); -var Engine = __webpack_require__(1009); -var EventEmitter = __webpack_require__(9); -var GetFastValue = __webpack_require__(1); +var Common = __webpack_require__(33); +var Composite = __webpack_require__(137); +var Engine = __webpack_require__(1061); +var EventEmitter = __webpack_require__(11); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); -var MatterBody = __webpack_require__(74); -var MatterEvents = __webpack_require__(301); -var MatterTileBody = __webpack_require__(679); -var MatterWorld = __webpack_require__(674); -var Vector = __webpack_require__(106); +var MatterBody = __webpack_require__(67); +var MatterEvents = __webpack_require__(195); +var MatterTileBody = __webpack_require__(504); +var MatterWorld = __webpack_require__(499); +var Vector = __webpack_require__(81); /** * @classdesc @@ -146191,11 +158018,11 @@ var Vector = __webpack_require__(106); * * @class World * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene to which this Matter World instance belongs. * @param {object} config - [description] */ var World = new Class({ @@ -146209,7 +158036,7 @@ var World = new Class({ EventEmitter.call(this); /** - * [description] + * The Scene to which this Matter World instance belongs. * * @name Phaser.Physics.Matter.World#scene * @type {Phaser.Scene} @@ -146218,7 +158045,7 @@ var World = new Class({ this.scene = scene; /** - * [description] + * An instance of the MatterJS Engine. * * @name Phaser.Physics.Matter.World#engine * @type {MatterJS.Engine} @@ -146276,7 +158103,7 @@ var World = new Class({ } /** - * [description] + * A flag that toggles if the world is enabled or not. * * @name Phaser.Physics.Matter.World#enabled * @type {boolean} @@ -146342,7 +158169,7 @@ var World = new Class({ this.autoUpdate = GetValue(config, 'autoUpdate', true); /** - * [description] + * A flag that controls if the debug graphics will be drawn to or not. * * @name Phaser.Physics.Matter.World#drawDebug * @type {boolean} @@ -146352,7 +158179,7 @@ var World = new Class({ this.drawDebug = GetValue(config, 'debug', false); /** - * [description] + * An instance of the Graphics object the debug bodies are drawn to, if enabled. * * @name Phaser.Physics.Matter.World#debugGraphic * @type {Phaser.GameObjects.Graphics} @@ -146361,21 +158188,27 @@ var World = new Class({ this.debugGraphic; /** - * [description] + * The default configuration values. * * @name Phaser.Physics.Matter.World#defaults * @type {object} * @since 3.0.0 */ this.defaults = { - debugShowBody: GetValue(config, 'debugShowBody', true), - debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), - debugShowVelocity: GetValue(config, 'debugShowVelocity', true), - bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), - staticBodyDebugColor: GetValue(config, 'debugBodyColor', 0x0000ff), - velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00), - debugShowJoint: GetValue(config, 'debugShowJoint', true), - jointDebugColor: GetValue(config, 'debugJointColor', 0x000000) + debugShowBody: GetFastValue(config, 'debugShowBody', true), + debugShowStaticBody: GetFastValue(config, 'debugShowStaticBody', true), + debugShowVelocity: GetFastValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetFastValue(config, 'debugBodyColor', 0xff00ff), + bodyDebugFillColor: GetFastValue(config, 'bodyDebugFillColor', 0xe3a7e3), + staticBodyDebugColor: GetFastValue(config, 'debugBodyColor', 0x0000ff), + velocityDebugColor: GetFastValue(config, 'debugVelocityColor', 0x00ff00), + debugShowJoint: GetFastValue(config, 'debugShowJoint', true), + jointDebugColor: GetFastValue(config, 'debugJointColor', 0x000000), + debugWireframes: GetFastValue(config, 'debugWireframes', true), + debugShowInternalEdges: GetFastValue(config, 'debugShowInternalEdges', false), + debugShowConvexHulls: GetFastValue(config, 'debugShowConvexHulls', false), + debugConvexHullColor: GetFastValue(config, 'debugConvexHullColor', 0xaaaaaa), + debugShowSleeping: GetFastValue(config, 'debugShowSleeping', false) }; if (this.drawDebug) @@ -146605,18 +158438,18 @@ var World = new Class({ }, /** - * [description] + * Creates a rectangle Matter body and adds it to the world. * * @method Phaser.Physics.Matter.World#create * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} options - [description] + * @param {number} x - The horizontal position of the body in the world. + * @param {number} y - The vertical position of the body in the world. + * @param {number} width - The width of the body. + * @param {number} height - The height of the body. + * @param {object} options - Optional Matter configuration object. * - * @return {MatterJS.Body} [description] + * @return {MatterJS.Body} The Matter.js body that was created. */ create: function (x, y, width, height, options) { @@ -146800,8 +158633,8 @@ var World = new Class({ * @method Phaser.Physics.Matter.World#update * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (time, delta) { @@ -146870,9 +158703,10 @@ var World = new Class({ }, /** - * [description] + * Handles the rendering of bodies and debug information to the debug Graphics object, if enabled. * * @method Phaser.Physics.Matter.World#postUpdate + * @private * @since 3.0.0 */ postUpdate: function () @@ -146882,135 +158716,325 @@ var World = new Class({ return; } - var graphics = this.debugGraphic; + this.debugGraphic.clear(); + var bodies = Composite.allBodies(this.localWorld); - graphics.clear(); - graphics.lineStyle(1, this.defaults.bodyDebugColor); - graphics.beginPath(); - - var i,j; - - for (i = 0; i < bodies.length; i++) + if (this.defaults.debugWireframes) { - if (!bodies[i].render.visible) + if (this.defaults.debugShowConvexHulls) { - return; + this.renderConvexHulls(bodies); } - // Handle drawing both single bodies and compound bodies. If compound, draw both the - // convex hull (first part) and the rest of the bodies. - for (j = 0; j < bodies[i].parts.length; j++) - { - var body = bodies[i].parts[j]; - - var vertices = body.vertices; - - graphics.moveTo(vertices[0].x, vertices[0].y); - - for (var k = 1; k < vertices.length; k++) - { - graphics.lineTo(vertices[k].x, vertices[k].y); - } - - graphics.lineTo(vertices[0].x, vertices[0].y); - - graphics.strokePath(); - } + this.renderWireframes(bodies); + } + else + { + this.renderBodies(bodies); } - - graphics.closePath(); if (this.defaults.debugShowJoint) { - graphics.lineStyle(2, this.defaults.jointDebugColor); + this.renderJoints(); + } + }, - // Render constraints - var constraints = Composite.allConstraints(this.localWorld); + /** + * Renders the debug convex hulls from the given array of bodies. + * + * @method Phaser.Physics.Matter.World#renderConvexHulls + * @private + * @since 3.14.0 + * + * @param {array} bodies - An array of bodies from the localWorld. + */ + renderConvexHulls: function (bodies) + { + var graphics = this.debugGraphic; - for (i = 0; i < constraints.length; i++) + graphics.lineStyle(1, this.defaults.debugConvexHullColor); + + graphics.beginPath(); + + for (var i = 0; i < bodies.length; i++) + { + var body = bodies[i]; + + if (!body.render.visible || body.parts.length === 1) { - var constraint = constraints[i]; + continue; + } - if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) + graphics.moveTo(body.vertices[0].x, body.vertices[0].y); + + for (var j = 1; j < body.vertices.length; j++) + { + graphics.lineTo(body.vertices[j].x, body.vertices[j].y); + } + + graphics.lineTo(body.vertices[0].x, body.vertices[0].y); + } + + graphics.strokePath(); + }, + + /** + * Renders the wireframes of the given array of bodies. + * + * @method Phaser.Physics.Matter.World#renderWireframes + * @private + * @since 3.14.0 + * + * @param {array} bodies - An array of bodies from the localWorld. + */ + renderWireframes: function (bodies) + { + var graphics = this.debugGraphic; + var showInternalEdges = this.defaults.debugShowInternalEdges; + + graphics.lineStyle(1, this.defaults.bodyDebugColor); + + graphics.beginPath(); + + for (var i = 0; i < bodies.length; i++) + { + var body = bodies[i]; + + if (!body.render.visible) + { + continue; + } + + for (var k = (body.parts.length > 1) ? 1 : 0; k < body.parts.length; k++) + { + var part = body.parts[k]; + + var vertLength = part.vertices.length; + + graphics.moveTo(part.vertices[0].x, part.vertices[0].y); + + for (var j = 1; j < vertLength; j++) + { + if (!part.vertices[j - 1].isInternal || showInternalEdges) + { + graphics.lineTo(part.vertices[j].x, part.vertices[j].y); + } + else + { + graphics.moveTo(part.vertices[j].x, part.vertices[j].y); + } + + if (part.vertices[j].isInternal && !showInternalEdges) + { + graphics.moveTo(part.vertices[(j + 1) % vertLength].x, part.vertices[(j + 1) % vertLength].y); + } + } + + graphics.lineTo(part.vertices[0].x, part.vertices[0].y); + } + } + + graphics.strokePath(); + }, + + /** + * Renders the array of bodies. + * + * @method Phaser.Physics.Matter.World#renderBodies + * @private + * @since 3.14.0 + * + * @param {array} bodies - An array of bodies from the localWorld. + */ + renderBodies: function (bodies) + { + var graphics = this.debugGraphic; + + var showInternalEdges = this.defaults.debugShowInternalEdges || !this.defaults.debugWireframes; + var showSleeping = this.defaults.debugShowSleeping; + var wireframes = this.defaults.debugWireframes; + + var body; + var part; + var i; + var k; + + for (i = 0; i < bodies.length; i++) + { + body = bodies[i]; + + if (!body.render.visible) + { + continue; + } + + // Handle compound parts + for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) + { + part = body.parts[k]; + + if (!part.render.visible) { continue; } - if (constraint.render.lineWidth) + if (showSleeping && body.isSleeping) { - graphics.lineStyle(constraint.render.lineWidth, Common.colorToNumber(constraint.render.strokeStyle)); - } - - var bodyA = constraint.bodyA; - var bodyB = constraint.bodyB; - var start; - var end; - - if (bodyA) - { - start = Vector.add(bodyA.position, constraint.pointA); + graphics.lineStyle(1, this.defaults.bodyDebugColor, 0.5 * part.render.opacity); + graphics.fillStyle(this.defaults.bodyDebugColor, 0.5 * part.render.opacity); } else { - start = constraint.pointA; + graphics.lineStyle(1, this.defaults.bodyDebugColor, part.render.opacity); + graphics.fillStyle(this.defaults.bodyDebugColor, part.render.opacity); } - if (constraint.render.type === 'pin') + // Part polygon + if (part.circleRadius) { graphics.beginPath(); - graphics.arc(start.x, start.y, 3, 0, 2 * Math.PI); - graphics.closePath(); + graphics.arc(part.position.x, part.position.y, part.circleRadius, 0, 2 * Math.PI); } else { - if (bodyB) - { - end = Vector.add(bodyB.position, constraint.pointB); - } - else - { - end = constraint.pointB; - } - graphics.beginPath(); - graphics.moveTo(start.x, start.y); + graphics.moveTo(part.vertices[0].x, part.vertices[0].y); - if (constraint.render.type === 'spring') + var vertLength = part.vertices.length; + + for (var j = 1; j < vertLength; j++) { - var delta = Vector.sub(end, start); - var normal = Vector.perp(Vector.normalise(delta)); - var coils = Math.ceil(Common.clamp(constraint.length / 5, 12, 20)); - var offset; - - for (j = 1; j < coils; j += 1) + if (!part.vertices[j - 1].isInternal || showInternalEdges) { - offset = (j % 2 === 0) ? 1 : -1; + graphics.lineTo(part.vertices[j].x, part.vertices[j].y); + } + else + { + graphics.moveTo(part.vertices[j].x, part.vertices[j].y); + } - graphics.lineTo( - start.x + delta.x * (j / coils) + normal.x * offset * 4, - start.y + delta.y * (j / coils) + normal.y * offset * 4 - ); + if (part.vertices[j].isInternal && !showInternalEdges) + { + graphics.moveTo(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y); } } + + graphics.lineTo(part.vertices[0].x, part.vertices[0].y); - graphics.lineTo(end.x, end.y); + graphics.closePath(); } - if (constraint.render.lineWidth) + if (!wireframes) + { + graphics.fillPath(); + } + else { graphics.strokePath(); } + } + } + }, - if (constraint.render.anchors) + /** + * Renders world constraints. + * + * @method Phaser.Physics.Matter.World#renderJoints + * @private + * @since 3.14.0 + */ + renderJoints: function () + { + var graphics = this.debugGraphic; + + graphics.lineStyle(2, this.defaults.jointDebugColor); + + // Render constraints + var constraints = Composite.allConstraints(this.localWorld); + + for (var i = 0; i < constraints.length; i++) + { + var constraint = constraints[i]; + + if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) + { + continue; + } + + if (constraint.render.lineWidth) + { + graphics.lineStyle(constraint.render.lineWidth, Common.colorToNumber(constraint.render.strokeStyle)); + } + + var bodyA = constraint.bodyA; + var bodyB = constraint.bodyB; + var start; + var end; + + if (bodyA) + { + start = Vector.add(bodyA.position, constraint.pointA); + } + else + { + start = constraint.pointA; + } + + if (constraint.render.type === 'pin') + { + graphics.beginPath(); + graphics.arc(start.x, start.y, 3, 0, 2 * Math.PI); + graphics.closePath(); + } + else + { + if (bodyB) { - graphics.fillStyle(Common.colorToNumber(constraint.render.strokeStyle)); - graphics.beginPath(); - graphics.arc(start.x, start.y, 6, 0, 2 * Math.PI); - graphics.arc(end.x, end.y, 6, 0, 2 * Math.PI); - graphics.closePath(); - graphics.fillPath(); + end = Vector.add(bodyB.position, constraint.pointB); } + else + { + end = constraint.pointB; + } + + graphics.beginPath(); + graphics.moveTo(start.x, start.y); + + if (constraint.render.type === 'spring') + { + var delta = Vector.sub(end, start); + var normal = Vector.perp(Vector.normalise(delta)); + var coils = Math.ceil(Common.clamp(constraint.length / 5, 12, 20)); + var offset; + + for (var j = 1; j < coils; j += 1) + { + offset = (j % 2 === 0) ? 1 : -1; + + graphics.lineTo( + start.x + delta.x * (j / coils) + normal.x * offset * 4, + start.y + delta.y * (j / coils) + normal.y * offset * 4 + ); + } + } + + graphics.lineTo(end.x, end.y); + } + + if (constraint.render.lineWidth) + { + graphics.strokePath(); + } + + if (constraint.render.anchors) + { + graphics.fillStyle(Common.colorToNumber(constraint.render.strokeStyle)); + graphics.beginPath(); + graphics.arc(start.x, start.y, 6, 0, 2 * Math.PI); + graphics.arc(end.x, end.y, 6, 0, 2 * Math.PI); + graphics.closePath(); + graphics.fillPath(); } } }, @@ -147058,6 +159082,11 @@ var World = new Class({ MatterWorld.clear(this.localWorld, false); Engine.clear(this.engine); + + if (this.drawDebug) + { + this.debugGraphic.destroy(); + } }, /** @@ -147077,7 +159106,7 @@ module.exports = World; /***/ }), -/* 1009 */ +/* 1061 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -147094,17 +159123,17 @@ var Engine = {}; module.exports = Engine; -var World = __webpack_require__(674); -var Sleeping = __webpack_require__(331); -var Resolver = __webpack_require__(1010); -var Pairs = __webpack_require__(1011); -var Metrics = __webpack_require__(1032); -var Grid = __webpack_require__(1012); -var Events = __webpack_require__(301); -var Composite = __webpack_require__(221); -var Constraint = __webpack_require__(300); -var Common = __webpack_require__(41); -var Body = __webpack_require__(74); +var World = __webpack_require__(499); +var Sleeping = __webpack_require__(222); +var Resolver = __webpack_require__(1062); +var Pairs = __webpack_require__(1063); +var Metrics = __webpack_require__(1088); +var Grid = __webpack_require__(1064); +var Events = __webpack_require__(195); +var Composite = __webpack_require__(137); +var Constraint = __webpack_require__(194); +var Common = __webpack_require__(33); +var Body = __webpack_require__(67); (function() { @@ -147144,7 +159173,6 @@ var Body = __webpack_require__(74); var engine = Common.extend(defaults, options); - /* // @deprecated if (element || engine.render) { var renderDefaults = { @@ -147164,7 +159192,6 @@ var Body = __webpack_require__(74); if (engine.render) { engine.render.engine = engine; } - */ engine.world = options.world || World.create(engine.world); engine.pairs = Pairs.create(); @@ -147227,10 +159254,10 @@ var Body = __webpack_require__(74); Sleeping.update(allBodies, timing.timeScale); // applies gravity to all bodies - _bodiesApplyGravity(allBodies, world.gravity); + Engine._bodiesApplyGravity(allBodies, world.gravity); // update all body position and rotation by integration - _bodiesUpdate(allBodies, delta, timing.timeScale, correction, world.bounds); + Engine._bodiesUpdate(allBodies, delta, timing.timeScale, correction, world.bounds); // update all constraints (first pass) Constraint.preSolveAll(allBodies); @@ -147308,7 +159335,7 @@ var Body = __webpack_require__(74); // @endif // clear force buffers - _bodiesClearForces(allBodies); + Engine._bodiesClearForces(allBodies); Events.trigger(engine, 'afterUpdate', event); @@ -147359,11 +159386,11 @@ var Body = __webpack_require__(74); /** * Zeroes the `body.force` and `body.torque` force buffers. - * @method bodiesClearForces + * @method _bodiesClearForces * @private * @param {body[]} bodies */ - var _bodiesClearForces = function(bodies) { + Engine._bodiesClearForces = function(bodies) { for (var i = 0; i < bodies.length; i++) { var body = bodies[i]; @@ -147376,12 +159403,12 @@ var Body = __webpack_require__(74); /** * Applys a mass dependant force to all given bodies. - * @method bodiesApplyGravity + * @method _bodiesApplyGravity * @private * @param {body[]} bodies * @param {vector} gravity */ - var _bodiesApplyGravity = function(bodies, gravity) { + Engine._bodiesApplyGravity = function(bodies, gravity) { var gravityScale = typeof gravity.scale !== 'undefined' ? gravity.scale : 0.001; if ((gravity.x === 0 && gravity.y === 0) || gravityScale === 0) { @@ -147402,7 +159429,7 @@ var Body = __webpack_require__(74); /** * Applys `Body.update` to all given `bodies`. - * @method updateAll + * @method _bodiesUpdate * @private * @param {body[]} bodies * @param {number} deltaTime @@ -147412,7 +159439,7 @@ var Body = __webpack_require__(74); * The Verlet correction factor (deltaTime / lastDeltaTime) * @param {bounds} worldBounds */ - var _bodiesUpdate = function(bodies, deltaTime, timeScale, correction, worldBounds) { + Engine._bodiesUpdate = function(bodies, deltaTime, timeScale, correction, worldBounds) { for (var i = 0; i < bodies.length; i++) { var body = bodies[i]; @@ -147592,7 +159619,7 @@ var Body = __webpack_require__(74); /***/ }), -/* 1010 */ +/* 1062 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -147605,10 +159632,10 @@ var Resolver = {}; module.exports = Resolver; -var Vertices = __webpack_require__(126); -var Vector = __webpack_require__(106); -var Common = __webpack_require__(41); -var Bounds = __webpack_require__(125); +var Vertices = __webpack_require__(76); +var Vector = __webpack_require__(81); +var Common = __webpack_require__(33); +var Bounds = __webpack_require__(80); (function() { @@ -147645,6 +159672,7 @@ var Bounds = __webpack_require__(125); * Find a solution for pair positions. * @method solvePosition * @param {pair[]} pairs + * @param {body[]} bodies * @param {number} timeScale */ Resolver.solvePosition = function(pairs, bodies, timeScale) { @@ -147664,7 +159692,7 @@ var Bounds = __webpack_require__(125); bodyBtoAX, bodyBtoAY, positionImpulse, - impulseCoefficient = timeScale * Resolver._positionDampen; + impulseCoefficient = timeScale * Resolver._positionDampen; for (i = 0; i < bodies.length; i++) { var body = bodies[i]; @@ -147689,14 +159717,12 @@ var Bounds = __webpack_require__(125); penetration = collision.penetration; - // bodyBtoA = positionImpulseB - positionImpulseA + penetration bodyBtoAX = positionImpulseB.x - positionImpulseA.x + penetration.x; bodyBtoAY = positionImpulseB.y - positionImpulseA.y + penetration.y; normalX = normal.x; normalY = normal.y; - // separation = dot(normal, bodyBtoA) separation = normalX * bodyBtoAX + normalY * bodyBtoAY; pair.separation = separation; @@ -147949,7 +159975,7 @@ var Bounds = __webpack_require__(125); /***/ }), -/* 1011 */ +/* 1063 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -147962,12 +159988,12 @@ var Pairs = {}; module.exports = Pairs; -var Pair = __webpack_require__(610); -var Common = __webpack_require__(41); +var Pair = __webpack_require__(418); +var Common = __webpack_require__(33); (function() { - var _pairMaxIdleLife = 1000; + Pairs._pairMaxIdleLife = 1000; /** * Creates a new pairs structure. @@ -148048,7 +160074,7 @@ var Common = __webpack_require__(41); // deactivate previously active pairs that are now inactive for (i = 0; i < pairsList.length; i++) { pair = pairsList[i]; - if (!pair.confirmedActive) { + if (pair.isActive && !pair.confirmedActive) { Pair.setActive(pair, false, timestamp); collisionEnd.push(pair); } @@ -148081,7 +160107,7 @@ var Common = __webpack_require__(41); } // if pair is inactive for too long, mark it to be removed - if (timestamp - pair.timeUpdated > _pairMaxIdleLife) { + if (timestamp - pair.timeUpdated > Pairs._pairMaxIdleLife) { indexesToRemove.push(i); } } @@ -148114,7 +160140,7 @@ var Common = __webpack_require__(41); /***/ }), -/* 1012 */ +/* 1064 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -148127,9 +160153,9 @@ var Grid = {}; module.exports = Grid; -var Pair = __webpack_require__(610); -var Detector = __webpack_require__(678); -var Common = __webpack_require__(41); +var Pair = __webpack_require__(418); +var Detector = __webpack_require__(503); +var Common = __webpack_require__(33); (function() { @@ -148201,7 +160227,7 @@ var Common = __webpack_require__(41); || body.bounds.max.y < world.bounds.min.y || body.bounds.min.y > world.bounds.max.y) continue; - var newRegion = _getRegion(grid, body); + var newRegion = Grid._getRegion(grid, body); // if the body has changed grid region if (!body.region || newRegion.id !== body.region.id || forceUpdate) { @@ -148213,13 +160239,13 @@ var Common = __webpack_require__(41); if (!body.region || forceUpdate) body.region = newRegion; - var union = _regionUnion(newRegion, body.region); + var union = Grid._regionUnion(newRegion, body.region); // update grid buckets affected by region change // iterate over the union of both regions for (col = union.startCol; col <= union.endCol; col++) { for (row = union.startRow; row <= union.endRow; row++) { - bucketId = _getBucketId(col, row); + bucketId = Grid._getBucketId(col, row); bucket = buckets[bucketId]; var isInsideNewRegion = (col >= newRegion.startCol && col <= newRegion.endCol @@ -148232,15 +160258,15 @@ var Common = __webpack_require__(41); if (!isInsideNewRegion && isInsideOldRegion) { if (isInsideOldRegion) { if (bucket) - _bucketRemoveBody(grid, bucket, body); + Grid._bucketRemoveBody(grid, bucket, body); } } // add to new region buckets if (body.region === newRegion || (isInsideNewRegion && !isInsideOldRegion) || forceUpdate) { if (!bucket) - bucket = _createBucket(buckets, bucketId); - _bucketAddBody(grid, bucket, body); + bucket = Grid._createBucket(buckets, bucketId); + Grid._bucketAddBody(grid, bucket, body); } } } @@ -148255,7 +160281,7 @@ var Common = __webpack_require__(41); // update pairs list only if pairs changed (i.e. a body changed region) if (gridChanged) - grid.pairsList = _createActivePairsList(grid); + grid.pairsList = Grid._createActivePairsList(grid); }; /** @@ -148277,13 +160303,13 @@ var Common = __webpack_require__(41); * @param {} regionB * @return {} region */ - var _regionUnion = function(regionA, regionB) { + Grid._regionUnion = function(regionA, regionB) { var startCol = Math.min(regionA.startCol, regionB.startCol), endCol = Math.max(regionA.endCol, regionB.endCol), startRow = Math.min(regionA.startRow, regionB.startRow), endRow = Math.max(regionA.endRow, regionB.endRow); - return _createRegion(startCol, endCol, startRow, endRow); + return Grid._createRegion(startCol, endCol, startRow, endRow); }; /** @@ -148294,14 +160320,14 @@ var Common = __webpack_require__(41); * @param {} body * @return {} region */ - var _getRegion = function(grid, body) { + Grid._getRegion = function(grid, body) { var bounds = body.bounds, startCol = Math.floor(bounds.min.x / grid.bucketWidth), endCol = Math.floor(bounds.max.x / grid.bucketWidth), startRow = Math.floor(bounds.min.y / grid.bucketHeight), endRow = Math.floor(bounds.max.y / grid.bucketHeight); - return _createRegion(startCol, endCol, startRow, endRow); + return Grid._createRegion(startCol, endCol, startRow, endRow); }; /** @@ -148314,7 +160340,7 @@ var Common = __webpack_require__(41); * @param {} endRow * @return {} region */ - var _createRegion = function(startCol, endCol, startRow, endRow) { + Grid._createRegion = function(startCol, endCol, startRow, endRow) { return { id: startCol + ',' + endCol + ',' + startRow + ',' + endRow, startCol: startCol, @@ -148332,7 +160358,7 @@ var Common = __webpack_require__(41); * @param {} row * @return {string} bucket id */ - var _getBucketId = function(column, row) { + Grid._getBucketId = function(column, row) { return 'C' + column + 'R' + row; }; @@ -148344,7 +160370,7 @@ var Common = __webpack_require__(41); * @param {} bucketId * @return {} bucket */ - var _createBucket = function(buckets, bucketId) { + Grid._createBucket = function(buckets, bucketId) { var bucket = buckets[bucketId] = []; return bucket; }; @@ -148357,7 +160383,7 @@ var Common = __webpack_require__(41); * @param {} bucket * @param {} body */ - var _bucketAddBody = function(grid, bucket, body) { + Grid._bucketAddBody = function(grid, bucket, body) { // add new pairs for (var i = 0; i < bucket.length; i++) { var bodyB = bucket[i]; @@ -148389,9 +160415,9 @@ var Common = __webpack_require__(41); * @param {} bucket * @param {} body */ - var _bucketRemoveBody = function(grid, bucket, body) { + Grid._bucketRemoveBody = function(grid, bucket, body) { // remove from bucket - bucket.splice(bucket.indexOf(body), 1); + bucket.splice(Common.indexOf(bucket, body), 1); // update pair counts for (var i = 0; i < bucket.length; i++) { @@ -148413,7 +160439,7 @@ var Common = __webpack_require__(41); * @param {} grid * @return [] pairs */ - var _createActivePairsList = function(grid) { + Grid._createActivePairsList = function(grid) { var pairKeys, pair, pairs = []; @@ -148441,7 +160467,7 @@ var Common = __webpack_require__(41); /***/ }), -/* 1013 */ +/* 1065 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -148454,8 +160480,8 @@ var Matter = {}; module.exports = Matter; -var Plugin = __webpack_require__(675); -var Common = __webpack_require__(41); +var Plugin = __webpack_require__(500); +var Common = __webpack_require__(33); (function() { @@ -148473,7 +160499,7 @@ var Common = __webpack_require__(41); * @readOnly * @type {String} */ - Matter.version = '0.13.1'; + Matter.version = '0.14.2'; /** * A list of plugin dependencies to be installed. These are normally set and installed through `Matter.use`. @@ -148533,7 +160559,7 @@ var Common = __webpack_require__(41); /***/ }), -/* 1014 */ +/* 1066 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -148542,14 +160568,14 @@ var Common = __webpack_require__(41); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var AnimationComponent = __webpack_require__(302); +var AnimationComponent = __webpack_require__(427); var Class = __webpack_require__(0); -var Components = __webpack_require__(611); -var GameObject = __webpack_require__(2); -var GetFastValue = __webpack_require__(1); -var Pipeline = __webpack_require__(291); -var Sprite = __webpack_require__(34); -var Vector2 = __webpack_require__(6); +var Components = __webpack_require__(419); +var GameObject = __webpack_require__(19); +var GetFastValue = __webpack_require__(2); +var Pipeline = __webpack_require__(186); +var Sprite = __webpack_require__(61); +var Vector2 = __webpack_require__(3); /** * @classdesc @@ -148565,7 +160591,7 @@ var Vector2 = __webpack_require__(6); * * @class Sprite * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * @@ -148676,7 +160702,7 @@ module.exports = MatterSprite; /***/ }), -/* 1015 */ +/* 1067 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -148686,12 +160712,12 @@ module.exports = MatterSprite; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(611); -var GameObject = __webpack_require__(2); -var GetFastValue = __webpack_require__(1); -var Image = __webpack_require__(69); -var Pipeline = __webpack_require__(291); -var Vector2 = __webpack_require__(6); +var Components = __webpack_require__(419); +var GameObject = __webpack_require__(19); +var GetFastValue = __webpack_require__(2); +var Image = __webpack_require__(87); +var Pipeline = __webpack_require__(186); +var Vector2 = __webpack_require__(3); /** * @classdesc @@ -148704,7 +160730,7 @@ var Vector2 = __webpack_require__(6); * * @class Image * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * @@ -148813,7 +160839,7 @@ module.exports = MatterImage; /***/ }), -/* 1016 */ +/* 1068 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -148829,11 +160855,11 @@ var Composites = {}; module.exports = Composites; -var Composite = __webpack_require__(221); -var Constraint = __webpack_require__(300); -var Common = __webpack_require__(41); -var Body = __webpack_require__(74); -var Bodies = __webpack_require__(166); +var Composite = __webpack_require__(137); +var Constraint = __webpack_require__(194); +var Common = __webpack_require__(33); +var Body = __webpack_require__(67); +var Bodies = __webpack_require__(126); (function() { @@ -149146,20 +161172,22 @@ var Bodies = __webpack_require__(166); /***/ }), -/* 1017 */ +/* 1069 */ /***/ (function(module, exports) { /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. + * @author Stefan Hedman (http://steffe.se) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// v0.3.0 + module.exports = { decomp: polygonDecomp, quickDecomp: polygonQuickDecomp, isSimple: polygonIsSimple, removeCollinearPoints: polygonRemoveCollinearPoints, + removeDuplicatePoints: polygonRemoveDuplicatePoints, makeCCW: polygonMakeCCW }; @@ -149335,6 +161363,9 @@ function polygonMakeCCW(polygon){ // reverse poly if clockwise if (!isLeft(polygonAt(polygon, br - 1), polygonAt(polygon, br), polygonAt(polygon, br + 1))) { polygonReverse(polygon); + return true; + } else { + return false; } } @@ -149399,6 +161430,27 @@ function polygonCanSee(polygon, a,b) { return true; } +/** + * Check if two vertices in the polygon can see each other + * @method canSee2 + * @param {Number} a Vertex index 1 + * @param {Number} b Vertex index 2 + * @return {Boolean} + */ +function polygonCanSee2(polygon, a,b) { + // for each edge + for (var i = 0; i !== polygon.length; ++i) { + // ignore incident edges + if (i === a || i === b || (i + 1) % polygon.length === a || (i + 1) % polygon.length === b){ + continue; + } + if( lineSegmentsIntersect(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i), polygonAt(polygon, i+1)) ){ + return false; + } + } + return true; +} + /** * Copy the polygon from vertex i to vertex j. * @method copy @@ -149682,9 +161734,12 @@ function polygonQuickDecomp(polygon, result,reflexVertices,steinerPoints,delta,m } for (var j = lowerIndex; j <= upperIndex; ++j) { - if (isLeftOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j))) { + if ( + isLeftOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && + isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j)) + ) { d = sqdist(polygonAt(poly, i), polygonAt(poly, j)); - if (d < closestDist) { + if (d < closestDist && polygonCanSee2(poly, i, j)) { closestDist = d; closestIndex = j % polygon.length; } @@ -149741,6 +161796,23 @@ function polygonRemoveCollinearPoints(polygon, precision){ return num; } +/** + * Remove duplicate points in the polygon. + * @method removeDuplicatePoints + * @param {Number} [precision] The threshold to use when determining whether two points are the same. Use zero for best precision. + */ +function polygonRemoveDuplicatePoints(polygon, precision){ + for(var i=polygon.length-1; i>=1; --i){ + var pi = polygon[i]; + for(var j=i-1; j>=0; --j){ + if(points_eq(pi, polygon[j], precision)){ + polygon.splice(i,1); + continue; + } + } + } +} + /** * Check if two scalars are equal * @static @@ -149752,12 +161824,25 @@ function polygonRemoveCollinearPoints(polygon, precision){ */ function scalar_eq(a,b,precision){ precision = precision || 0; - return Math.abs(a-b) < precision; + return Math.abs(a-b) <= precision; +} + +/** + * Check if two points are equal + * @static + * @method points_eq + * @param {Array} a + * @param {Array} b + * @param {Number} [precision] + * @return {Boolean} + */ +function points_eq(a,b,precision){ + return scalar_eq(a[0],b[0],precision) && scalar_eq(a[1],b[1],precision); } /***/ }), -/* 1018 */ +/* 1070 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -149766,22 +161851,22 @@ function scalar_eq(a,b,precision){ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Bodies = __webpack_require__(166); +var Bodies = __webpack_require__(126); var Class = __webpack_require__(0); -var Composites = __webpack_require__(1016); -var Constraint = __webpack_require__(300); -var MatterGameObject = __webpack_require__(1048); -var MatterImage = __webpack_require__(1015); -var MatterSprite = __webpack_require__(1014); -var MatterTileBody = __webpack_require__(679); -var PointerConstraint = __webpack_require__(1034); +var Composites = __webpack_require__(1068); +var Constraint = __webpack_require__(194); +var MatterGameObject = __webpack_require__(1104); +var MatterImage = __webpack_require__(1067); +var MatterSprite = __webpack_require__(1066); +var MatterTileBody = __webpack_require__(504); +var PointerConstraint = __webpack_require__(1090); /** * @classdesc * [description] * * @class Factory - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * @@ -150387,7 +162472,7 @@ module.exports = Factory; /***/ }), -/* 1019 */ +/* 1071 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -150396,46 +162481,46 @@ module.exports = Factory; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Body = __webpack_require__(1025); +var Body = __webpack_require__(1077); var Class = __webpack_require__(0); -var COLLIDES = __webpack_require__(333); -var CollisionMap = __webpack_require__(1024); -var EventEmitter = __webpack_require__(9); -var GetFastValue = __webpack_require__(1); -var HasValue = __webpack_require__(111); -var Set = __webpack_require__(70); -var Solver = __webpack_require__(1052); -var TILEMAP_FORMATS = __webpack_require__(26); -var TYPE = __webpack_require__(332); +var COLLIDES = __webpack_require__(224); +var CollisionMap = __webpack_require__(1076); +var EventEmitter = __webpack_require__(11); +var GetFastValue = __webpack_require__(2); +var HasValue = __webpack_require__(85); +var Set = __webpack_require__(95); +var Solver = __webpack_require__(1108); +var TILEMAP_FORMATS = __webpack_require__(29); +var TYPE = __webpack_require__(223); /** * @typedef {object} Phaser.Physics.Impact.WorldConfig * - * @property {number} [gravity=0] - [description] - * @property {number} [cellSize=64] - [description] - * @property {number} [timeScale=1] - [description] - * @property {float} [maxStep=0.05] - [description] - * @property {boolean} [debug=false] - [description] - * @property {number} [maxVelocity=100] - [description] - * @property {boolean} [debugShowBody=true] - [description] - * @property {boolean} [debugShowVelocity=true] - [description] - * @property {number} [debugBodyColor=0xff00ff] - [description] - * @property {number} [debugVelocityColor=0x00ff00] - [description] - * @property {number} [maxVelocityX=maxVelocity] - [description] - * @property {number} [maxVelocityY=maxVelocity] - [description] - * @property {number} [minBounceVelocity=40] - [description] - * @property {number} [gravityFactor=1] - [description] - * @property {number} [bounciness=0] - [description] - * @property {(object|boolean)} [setBounds] - [description] - * @property {number} [setBounds.x=0] - [description] - * @property {number} [setBounds.y=0] - [description] - * @property {number} [setBounds.width] - [description] - * @property {number} [setBounds.height] - [description] - * @property {number} [setBounds.thickness=64] - [description] - * @property {boolean} [setBounds.left=true] - [description] - * @property {boolean} [setBounds.right=true] - [description] - * @property {boolean} [setBounds.top=true] - [description] - * @property {boolean} [setBounds.bottom=true] - [description] + * @property {number} [gravity=0] - Sets {@link Phaser.Physics.Impact.World#gravity} + * @property {number} [cellSize=64] - The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world. + * @property {number} [timeScale=1] - A `Number` that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed. + * @property {number} [maxStep=0.05] - [description] + * @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Impact.World#debug}. + * @property {number} [maxVelocity=100] - The maximum velocity a body can move. + * @property {boolean} [debugShowBody=true] - Whether the Body's boundary is drawn to the debug display. + * @property {boolean} [debugShowVelocity=true] - Whether the Body's velocity is drawn to the debug display. + * @property {number} [debugBodyColor=0xff00ff] - The color of this Body on the debug display. + * @property {number} [debugVelocityColor=0x00ff00] - The color of the Body's velocity on the debug display. + * @property {number} [maxVelocityX=maxVelocity] - Maximum X velocity objects can move. + * @property {number} [maxVelocityY=maxVelocity] - Maximum Y velocity objects can move. + * @property {number} [minBounceVelocity=40] - The minimum velocity an object can be moving at to be considered for bounce. + * @property {number} [gravityFactor=1] - Gravity multiplier. Set to 0 for no gravity. + * @property {number} [bounciness=0] - The default bounce, or restitution, of bodies in the world. + * @property {(object|boolean)} [setBounds] - Should the world have bounds enabled by default? + * @property {number} [setBounds.x=0] - The x coordinate of the world bounds. + * @property {number} [setBounds.y=0] - The y coordinate of the world bounds. + * @property {number} [setBounds.width] - The width of the world bounds. + * @property {number} [setBounds.height] - The height of the world bounds. + * @property {number} [setBounds.thickness=64] - The thickness of the walls of the world bounds. + * @property {boolean} [setBounds.left=true] - Should the left-side world bounds wall be created? + * @property {boolean} [setBounds.right=true] - Should the right-side world bounds wall be created? + * @property {boolean} [setBounds.top=true] - Should the top world bounds wall be created? + * @property {boolean} [setBounds.bottom=true] - Should the bottom world bounds wall be created? */ /** @@ -150443,24 +162528,24 @@ var TYPE = __webpack_require__(332); * * @typedef {object} Phaser.Physics.Impact.WorldDefaults * - * @property {boolean} debugShowBody - [description] - * @property {boolean} debugShowVelocity - [description] - * @property {number} bodyDebugColor - [description] - * @property {number} velocityDebugColor - [description] - * @property {number} maxVelocityX - [description] - * @property {number} maxVelocityY - [description] - * @property {number} minBounceVelocity - [description] - * @property {number} gravityFactor - [description] - * @property {number} bounciness - [description] + * @property {boolean} debugShowBody - Whether the Body's boundary is drawn to the debug display. + * @property {boolean} debugShowVelocity - Whether the Body's velocity is drawn to the debug display. + * @property {number} bodyDebugColor - The color of this Body on the debug display. + * @property {number} velocityDebugColor - The color of the Body's velocity on the debug display. + * @property {number} maxVelocityX - Maximum X velocity objects can move. + * @property {number} maxVelocityY - Maximum Y velocity objects can move. + * @property {number} minBounceVelocity - The minimum velocity an object can be moving at to be considered for bounce. + * @property {number} gravityFactor - Gravity multiplier. Set to 0 for no gravity. + * @property {number} bounciness - The default bounce, or restitution, of bodies in the world. */ /** * @typedef {object} Phaser.Physics.Impact.WorldWalls * - * @property {?Phaser.Physics.Impact.Body} left - [description] - * @property {?Phaser.Physics.Impact.Body} right - [description] - * @property {?Phaser.Physics.Impact.Body} top - [description] - * @property {?Phaser.Physics.Impact.Body} bottom - [description] + * @property {?Phaser.Physics.Impact.Body} left - The left-side wall of the world bounds. + * @property {?Phaser.Physics.Impact.Body} right - The right-side wall of the world bounds. + * @property {?Phaser.Physics.Impact.Body} top - The top wall of the world bounds. + * @property {?Phaser.Physics.Impact.Body} bottom - The bottom wall of the world bounds. */ /** @@ -150469,7 +162554,7 @@ var TYPE = __webpack_require__(332); * * @class World * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -150537,7 +162622,7 @@ var World = new Class({ * [description] * * @name Phaser.Physics.Impact.World#timeScale - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -150876,12 +162961,12 @@ var World = new Class({ }, /** - * [description] + * Creates a Graphics Game Object used for debug display and enables the world for debug drawing. * * @method Phaser.Physics.Impact.World#createDebugGraphic * @since 3.0.0 * - * @return {Phaser.GameObjects.Graphics} [description] + * @return {Phaser.GameObjects.Graphics} The Graphics object created that will have the debug visuals drawn to it. */ createDebugGraphic: function () { @@ -150984,8 +163069,8 @@ var World = new Class({ * @method Phaser.Physics.Impact.World#update * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (time, delta) { @@ -151433,7 +163518,7 @@ module.exports = World; /***/ }), -/* 1020 */ +/* 1072 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -151443,8 +163528,8 @@ module.exports = World; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(681); -var Sprite = __webpack_require__(34); +var Components = __webpack_require__(506); +var Sprite = __webpack_require__(61); /** * @classdesc @@ -151460,7 +163545,7 @@ var Sprite = __webpack_require__(34); * * @class ImpactSprite * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -151595,7 +163680,7 @@ module.exports = ImpactSprite; /***/ }), -/* 1021 */ +/* 1073 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -151605,8 +163690,8 @@ module.exports = ImpactSprite; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(681); -var Image = __webpack_require__(69); +var Components = __webpack_require__(506); +var Image = __webpack_require__(87); /** * @classdesc @@ -151619,7 +163704,7 @@ var Image = __webpack_require__(69); * * @class ImpactImage * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -151754,7 +163839,7 @@ module.exports = ImpactImage; /***/ }), -/* 1022 */ +/* 1074 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -151764,14 +163849,14 @@ module.exports = ImpactImage; */ var Class = __webpack_require__(0); -var Components = __webpack_require__(681); +var Components = __webpack_require__(506); /** * @classdesc * [description] * * @class ImpactBody - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -151887,7 +163972,7 @@ module.exports = ImpactBody; /***/ }), -/* 1023 */ +/* 1075 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -151897,9 +163982,9 @@ module.exports = ImpactBody; */ var Class = __webpack_require__(0); -var ImpactBody = __webpack_require__(1022); -var ImpactImage = __webpack_require__(1021); -var ImpactSprite = __webpack_require__(1020); +var ImpactBody = __webpack_require__(1074); +var ImpactImage = __webpack_require__(1073); +var ImpactSprite = __webpack_require__(1072); /** * @classdesc @@ -151907,11 +163992,11 @@ var ImpactSprite = __webpack_require__(1020); * Objects that are created by this Factory are automatically added to the physics world. * * @class Factory - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * - * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Impact.World} world - A reference to the Impact Physics world. */ var Factory = new Class({ @@ -151920,7 +164005,7 @@ var Factory = new Class({ function Factory (world) { /** - * [description] + * A reference to the Impact Physics world. * * @name Phaser.Physics.Impact.Factory#world * @type {Phaser.Physics.Impact.World} @@ -151939,15 +164024,15 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new ImpactBody object and adds it to the physics simulation. * * @method Phaser.Physics.Impact.Factory#body * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} x - The horizontal position of the body in the physics world. + * @param {number} y - The vertical position of the body in the physics world. + * @param {number} width - The width of the body. + * @param {number} height - The height of the body. * * @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created. */ @@ -151962,7 +164047,7 @@ var Factory = new Class({ * @method Phaser.Physics.Impact.Factory#existing * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to receive the physics body. * * @return {Phaser.GameObjects.GameObject} The Game Object. */ @@ -151982,7 +164067,7 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new ImpactImage object and adds it to the physics world. * * @method Phaser.Physics.Impact.Factory#image * @since 3.0.0 @@ -152004,7 +164089,7 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new ImpactSprite object and adds it to the physics world. * * @method Phaser.Physics.Impact.Factory#sprite * @since 3.0.0 @@ -152044,7 +164129,7 @@ module.exports = Factory; /***/ }), -/* 1024 */ +/* 1076 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -152054,14 +164139,14 @@ module.exports = Factory; */ var Class = __webpack_require__(0); -var DefaultDefs = __webpack_require__(1066); +var DefaultDefs = __webpack_require__(1122); /** * @classdesc * [description] * * @class CollisionMap - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -152408,7 +164493,7 @@ module.exports = CollisionMap; /***/ }), -/* 1025 */ +/* 1077 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -152418,10 +164503,10 @@ module.exports = CollisionMap; */ var Class = __webpack_require__(0); -var COLLIDES = __webpack_require__(333); -var GetVelocity = __webpack_require__(1068); -var TYPE = __webpack_require__(332); -var UpdateMotion = __webpack_require__(1067); +var COLLIDES = __webpack_require__(224); +var GetVelocity = __webpack_require__(1124); +var TYPE = __webpack_require__(223); +var UpdateMotion = __webpack_require__(1123); /** * @callback BodyUpdateCallback @@ -152454,7 +164539,7 @@ var UpdateMotion = __webpack_require__(1067); * This re-creates the properties you'd get on an Entity and the math needed to update them. * * @class Body - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -152781,7 +164866,7 @@ var Body = new Class({ * @method Phaser.Physics.Impact.Body#update * @since 3.0.0 * - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (delta) { @@ -152894,15 +164979,15 @@ var Body = new Class({ }, /** - * [description] + * Reset the size and position of the physics body. * * @method Phaser.Physics.Impact.Body#resetSize * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} x - The x coordinate to position the body. + * @param {number} y - The y coordinate to position the body. + * @param {number} width - The width of the body. + * @param {number} height - The height of the body. * * @return {Phaser.Physics.Impact.Body} This Body object. */ @@ -153027,12 +165112,150 @@ module.exports = Body; /***/ }), -/* 1026 */, -/* 1027 */, -/* 1028 */ +/* 1078 */, +/* 1079 */ /***/ (function(module, exports, __webpack_require__) { -var Matter = __webpack_require__(676); +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL.Pipelines + */ + +module.exports = { + + BitmapMaskPipeline: __webpack_require__(421), + ForwardDiffuseLightPipeline: __webpack_require__(420), + TextureTintPipeline: __webpack_require__(196) + +}; + + +/***/ }), +/* 1080 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL + */ + +module.exports = { + + Utils: __webpack_require__(10), + WebGLPipeline: __webpack_require__(197), + WebGLRenderer: __webpack_require__(423), + Pipelines: __webpack_require__(1079), + + // Constants + BYTE: 0, + SHORT: 1, + UNSIGNED_BYTE: 2, + UNSIGNED_SHORT: 3, + FLOAT: 4 + +}; + + +/***/ }), +/* 1081 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @callback SnapshotCallback + * + * @param {HTMLImageElement} snapshot - [description] + */ + +/** + * @namespace Phaser.Renderer.Snapshot + */ + +module.exports = { + + Canvas: __webpack_require__(425), + WebGL: __webpack_require__(422) + +}; + + +/***/ }), +/* 1082 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Renderer.Canvas + */ + +module.exports = { + + CanvasRenderer: __webpack_require__(426), + GetBlendModes: __webpack_require__(424), + SetTransform: __webpack_require__(22) + +}; + + +/***/ }), +/* 1083 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} RendererConfig + * + * @property {boolean} clearBeforeRender - [description] + * @property {boolean} antialias - [description] + * @property {Phaser.Display.Color} backgroundColor - [description] + * @property {number} resolution - [description] + * @property {boolean} autoResize - [description] + * @property {boolean} roundPixels - [description] + */ + +/** + * @namespace Phaser.Renderer + */ + +module.exports = { + + Canvas: __webpack_require__(1082), + Snapshot: __webpack_require__(1081), + WebGL: __webpack_require__(1080) + +}; + + +/***/ }), +/* 1084 */ +/***/ (function(module, exports, __webpack_require__) { + +var Matter = __webpack_require__(501); /** * A coordinate wrapping plugin for matter.js. @@ -153211,10 +165434,10 @@ module.exports = MatterWrap; */ /***/ }), -/* 1029 */ +/* 1085 */ /***/ (function(module, exports, __webpack_require__) { -var Matter = __webpack_require__(676); +var Matter = __webpack_require__(501); /** * An attractors plugin for matter.js. @@ -153353,7 +165576,7 @@ module.exports = MatterAttractors; /***/ }), -/* 1030 */ +/* 1086 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -153363,23 +165586,24 @@ module.exports = MatterAttractors; */ var Class = __webpack_require__(0); -var Factory = __webpack_require__(1018); -var GetFastValue = __webpack_require__(1); +var Factory = __webpack_require__(1070); +var GetFastValue = __webpack_require__(2); var GetValue = __webpack_require__(4); -var MatterAttractors = __webpack_require__(1029); -var MatterLib = __webpack_require__(1013); -var MatterWrap = __webpack_require__(1028); -var Merge = __webpack_require__(94); -var Plugin = __webpack_require__(675); -var PluginCache = __webpack_require__(12); -var World = __webpack_require__(1008); +var MatterAttractors = __webpack_require__(1085); +var MatterLib = __webpack_require__(1065); +var MatterWrap = __webpack_require__(1084); +var Merge = __webpack_require__(96); +var Plugin = __webpack_require__(500); +var PluginCache = __webpack_require__(15); +var World = __webpack_require__(1060); +var Vertices = __webpack_require__(76); /** * @classdesc * [description] * * @class MatterPhysics - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * @@ -153436,6 +165660,17 @@ var MatterPhysics = new Class({ */ this.add; + /** + * A reference to the `Matter.Vertices` module which contains methods for creating and manipulating sets of vertices. + * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. + * A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). + * + * @name Phaser.Physics.Matter.MatterPhysics#verts + * @type {MatterJS.Vertices} + * @since 3.14.0 + */ + this.verts = Vertices; + // Matter plugins if (GetValue(this.config, 'plugins.attractors', false)) @@ -153688,7 +165923,7 @@ module.exports = MatterPhysics; /***/ }), -/* 1031 */ +/* 1087 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -153705,7 +165940,8 @@ var Svg = {}; module.exports = Svg; -var Bounds = __webpack_require__(125); +var Bounds = __webpack_require__(80); +var Common = __webpack_require__(33); (function() { @@ -153714,12 +165950,17 @@ var Bounds = __webpack_require__(125); * If the input path forms a concave shape, you must decompose the result into convex parts before use. * See `Bodies.fromVertices` which provides support for this. * Note that this function is not guaranteed to support complex paths (such as those with holes). + * You must load the `pathseg.js` polyfill on newer browsers. * @method pathToVertices * @param {SVGPathElement} path * @param {Number} [sampleLength=15] * @return {Vector[]} points */ Svg.pathToVertices = function(path, sampleLength) { + if (typeof window !== 'undefined' && !('SVGPathSeg' in window)) { + Common.warn('Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.'); + } + // https://github.com/wout/svg.topoly.js/blob/master/svg.topoly.js var i, il, total, point, segment, segments, segmentsQueue, lastSegment, @@ -153790,7 +166031,7 @@ var Bounds = __webpack_require__(125); }; // ensure path is absolute - _svgPathToAbsolute(path); + Svg._svgPathToAbsolute(path); // get total length total = path.getTotalLength(); @@ -153842,7 +166083,7 @@ var Bounds = __webpack_require__(125); return points; }; - var _svgPathToAbsolute = function(path) { + Svg._svgPathToAbsolute = function(path) { // http://phrogz.net/convert-svg-path-to-all-absolute-commands // Copyright (c) Gavin Kistner // http://phrogz.net/js/_ReuseLicense.txt @@ -153913,7 +166154,7 @@ var Bounds = __webpack_require__(125); })(); /***/ }), -/* 1032 */ +/* 1088 */ /***/ (function(module, exports, __webpack_require__) { // @if DEBUG @@ -153926,8 +166167,8 @@ var Metrics = {}; module.exports = Metrics; -var Composite = __webpack_require__(221); -var Common = __webpack_require__(41); +var Composite = __webpack_require__(137); +var Common = __webpack_require__(33); (function() { @@ -154012,7 +166253,7 @@ var Common = __webpack_require__(41); /***/ }), -/* 1033 */ +/* 1089 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -154027,14 +166268,46 @@ var Query = {}; module.exports = Query; -var Vector = __webpack_require__(106); -var SAT = __webpack_require__(677); -var Bounds = __webpack_require__(125); -var Bodies = __webpack_require__(166); -var Vertices = __webpack_require__(126); +var Vector = __webpack_require__(81); +var SAT = __webpack_require__(502); +var Bounds = __webpack_require__(80); +var Bodies = __webpack_require__(126); +var Vertices = __webpack_require__(76); (function() { + /** + * Returns a list of collisions between `body` and `bodies`. + * @method collides + * @param {body} body + * @param {body[]} bodies + * @return {object[]} Collisions + */ + Query.collides = function(body, bodies) { + var collisions = []; + + for (var i = 0; i < bodies.length; i++) { + var bodyA = bodies[i]; + + if (Bounds.overlaps(bodyA.bounds, body.bounds)) { + for (var j = bodyA.parts.length === 1 ? 0 : 1; j < bodyA.parts.length; j++) { + var part = bodyA.parts[j]; + + if (Bounds.overlaps(part.bounds, body.bounds)) { + var collision = SAT.collides(part, body); + + if (collision.collided) { + collisions.push(collision); + break; + } + } + } + } + } + + return collisions; + }; + /** * Casts a ray segment against a set of bodies and returns all collisions, ray width is optional. Intersection points are not provided. * @method ray @@ -154052,25 +166325,11 @@ var Vertices = __webpack_require__(126); rayX = (endPoint.x + startPoint.x) * 0.5, rayY = (endPoint.y + startPoint.y) * 0.5, ray = Bodies.rectangle(rayX, rayY, rayLength, rayWidth, { angle: rayAngle }), - collisions = []; + collisions = Query.collides(ray, bodies); - for (var i = 0; i < bodies.length; i++) { - var bodyA = bodies[i]; - - if (Bounds.overlaps(bodyA.bounds, ray.bounds)) { - for (var j = bodyA.parts.length === 1 ? 0 : 1; j < bodyA.parts.length; j++) { - var part = bodyA.parts[j]; - - if (Bounds.overlaps(part.bounds, ray.bounds)) { - var collision = SAT.collides(part, ray); - if (collision.collided) { - collision.body = collision.bodyA = collision.bodyB = bodyA; - collisions.push(collision); - break; - } - } - } - } + for (var i = 0; i < collisions.length; i += 1) { + var collision = collisions[i]; + collision.body = collision.bodyB = collision.bodyA; } return collisions; @@ -154130,7 +166389,7 @@ var Vertices = __webpack_require__(126); /***/ }), -/* 1034 */ +/* 1090 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -154139,23 +166398,23 @@ var Vertices = __webpack_require__(126); * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Bounds = __webpack_require__(125); +var Bounds = __webpack_require__(80); var Class = __webpack_require__(0); -var Composite = __webpack_require__(221); -var Constraint = __webpack_require__(300); -var Detector = __webpack_require__(678); -var GetFastValue = __webpack_require__(1); -var Merge = __webpack_require__(94); -var Sleeping = __webpack_require__(331); -var Vector2 = __webpack_require__(6); -var Vertices = __webpack_require__(126); +var Composite = __webpack_require__(137); +var Constraint = __webpack_require__(194); +var Detector = __webpack_require__(503); +var GetFastValue = __webpack_require__(2); +var Merge = __webpack_require__(96); +var Sleeping = __webpack_require__(222); +var Vector2 = __webpack_require__(3); +var Vertices = __webpack_require__(76); /** * @classdesc * [description] * * @class PointerConstraint - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * @@ -154421,7 +166680,7 @@ module.exports = PointerConstraint; /***/ }), -/* 1035 */ +/* 1091 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -154430,7 +166689,7 @@ module.exports = PointerConstraint; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Body = __webpack_require__(74); +var Body = __webpack_require__(67); /** * [description] @@ -154521,7 +166780,7 @@ module.exports = Velocity; /***/ }), -/* 1036 */ +/* 1092 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -154530,10 +166789,10 @@ module.exports = Velocity; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Body = __webpack_require__(74); +var Body = __webpack_require__(67); var MATH_CONST = __webpack_require__(16); -var WrapAngle = __webpack_require__(212); -var WrapAngleDegrees = __webpack_require__(211); +var WrapAngle = __webpack_require__(199); +var WrapAngleDegrees = __webpack_require__(198); // global bitmask flag for GameObject.renderMask (used by Scale) var _FLAG = 4; // 0100 @@ -154541,7 +166800,7 @@ var _FLAG = 4; // 0100 // Transform Component /** - * [description] + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. * * @name Phaser.Physics.Matter.Components.Transform * @since 3.0.0 @@ -154549,7 +166808,7 @@ var _FLAG = 4; // 0100 var Transform = { /** - * [description] + * The x position of this Game Object. * * @name Phaser.Physics.Matter.Components.Transform#x * @type {number} @@ -154572,7 +166831,7 @@ var Transform = { }, /** - * [description] + * The y position of this Game Object. * * @name Phaser.Physics.Matter.Components.Transform#y * @type {number} @@ -154595,7 +166854,7 @@ var Transform = { }, /** - * [description] + * The horizontal scale of this Game Object. * * @name Phaser.Physics.Matter.Components.Transform#scaleX * @type {number} @@ -154610,6 +166869,8 @@ var Transform = { set: function (value) { + var factor = 1 / this._scaleX; + this._scaleX = value; if (this._scaleX === 0) @@ -154621,13 +166882,16 @@ var Transform = { this.renderFlags |= _FLAG; } + // Reset Matter scale back to 1 (sigh) + Body.scale(this.body, factor, this._scaleY); + Body.scale(this.body, value, this._scaleY); } }, /** - * [description] + * The vertical scale of this Game Object. * * @name Phaser.Physics.Matter.Components.Transform#scaleY * @type {number} @@ -154642,6 +166906,8 @@ var Transform = { set: function (value) { + var factor = 1 / this._scaleY; + this._scaleY = value; if (this._scaleY === 0) @@ -154653,13 +166919,15 @@ var Transform = { this.renderFlags |= _FLAG; } + Body.scale(this.body, this._scaleX, factor); + Body.scale(this.body, this._scaleX, value); } }, /** - * [description] + * Use `angle` to set or get rotation of the physics body associated to this GameObject. Unlike rotation, when using set the value can be in degrees, which will be converted to radians internally. * * @name Phaser.Physics.Matter.Components.Transform#angle * @type {number} @@ -154680,7 +166948,7 @@ var Transform = { }, /** - * [description] + * Use `rotation` to set or get the rotation of the physics body associated with this GameObject. The value when set must be in radians. * * @name Phaser.Physics.Matter.Components.Transform#rotation * @type {number} @@ -154703,15 +166971,15 @@ var Transform = { }, /** - * [description] + * Sets the position of the physics body along x and y axes. Both the parameters to this function are optional and if not passed any they default to 0. * * @method Phaser.Physics.Matter.Components.Transform#setPosition * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=x] - [description] + * @param {number} [x=0] - The horizontal position of the body. + * @param {number} [y=x] - The vertical position of the body. * - * @return{Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setPosition: function (x, y) { @@ -154733,7 +167001,7 @@ var Transform = { * * @param {number} [radians=0] - [description] * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setRotation: function (radians) { @@ -154752,7 +167020,7 @@ var Transform = { * @method Phaser.Physics.Matter.Components.Transform#setFixedRotation * @since 3.0.0 * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setFixedRotation: function () { @@ -154769,7 +167037,7 @@ var Transform = { * * @param {number} [degrees=0] - [description] * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setAngle: function (degrees) { @@ -154783,25 +167051,30 @@ var Transform = { }, /** - * [description] + * Sets the scale of this Game Object. * * @method Phaser.Physics.Matter.Components.Transform#setScale * @since 3.0.0 * - * @param {number} [x=1] - [description] - * @param {number} [y=x] - [description] - * @param {Phaser.Math.Vector2} [point] - [description] + * @param {number} [x=1] - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the x value. + * @param {Phaser.Math.Vector2} [point] - The point (Vector2) from which scaling will occur. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setScale: function (x, y, point) { if (x === undefined) { x = 1; } if (y === undefined) { y = x; } + var factorX = 1 / this._scaleX; + var factorY = 1 / this._scaleY; + this._scaleX = x; this._scaleY = y; + Body.scale(this.body, factorX, factorY, point); + Body.scale(this.body, x, y, point); return this; @@ -154813,7 +167086,7 @@ module.exports = Transform; /***/ }), -/* 1037 */ +/* 1093 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -154822,7 +167095,7 @@ module.exports = Transform; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var MatterEvents = __webpack_require__(301); +var MatterEvents = __webpack_require__(195); /** * [description] @@ -154934,7 +167207,7 @@ module.exports = Sleep; /***/ }), -/* 1038 */ +/* 1094 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -154943,13 +167216,13 @@ module.exports = Sleep; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Bodies = __webpack_require__(166); -var Body = __webpack_require__(74); -var Bounds = __webpack_require__(125); -var Common = __webpack_require__(41); -var GetFastValue = __webpack_require__(1); -var Vector = __webpack_require__(106); -var Vertices = __webpack_require__(126); +var Bodies = __webpack_require__(126); +var Body = __webpack_require__(67); +var Bounds = __webpack_require__(80); +var Common = __webpack_require__(33); +var GetFastValue = __webpack_require__(2); +var Vector = __webpack_require__(81); +var Vertices = __webpack_require__(76); /** * Use PhysicsEditorParser.parseBody() to build a Matter body object, based on a physics data file @@ -155111,7 +167384,7 @@ module.exports = PhysicsEditorParser; /***/ }), -/* 1039 */ +/* 1095 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -155120,10 +167393,11 @@ module.exports = PhysicsEditorParser; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Bodies = __webpack_require__(166); -var Body = __webpack_require__(74); -var GetFastValue = __webpack_require__(1); -var PhysicsEditorParser = __webpack_require__(1038); +var Bodies = __webpack_require__(126); +var Body = __webpack_require__(67); +var GetFastValue = __webpack_require__(2); +var PhysicsEditorParser = __webpack_require__(1094); +var Vertices = __webpack_require__(76); /** * [description] @@ -155227,7 +167501,11 @@ var SetBody = { } this.body = body; - this.body.gameObject = this; + + for (var i = 0; i < body.parts.length; i++) + { + body.parts[i].gameObject = this; + } var _this = this; @@ -155302,26 +167580,39 @@ var SetBody = { case 'polygon': var sides = GetFastValue(config, 'sides', 5); - var pradius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); - body = Bodies.polygon(bodyX, bodyY, sides, pradius, options); + var pRadius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); + body = Bodies.polygon(bodyX, bodyY, sides, pRadius, options); break; case 'fromVertices': case 'fromVerts': - var verts = GetFastValue(config, 'verts', []); - if (this.body) + var verts = GetFastValue(config, 'verts', null); + + if (verts) { - Body.setVertices(this.body, verts); - body = this.body; - } - else - { - var flagInternal = GetFastValue(config, 'flagInternal', false); - var removeCollinear = GetFastValue(config, 'removeCollinear', 0.01); - var minimumArea = GetFastValue(config, 'minimumArea', 10); - body = Bodies.fromVertices(bodyX, bodyY, verts, options, flagInternal, removeCollinear, minimumArea); + // Has the verts array come from Vertices.fromPath, or is it raw? + if (typeof verts === 'string') + { + verts = Vertices.fromPath(verts); + } + + if (this.body && !this.body.hasOwnProperty('temp')) + { + Body.setVertices(this.body, verts); + + body = this.body; + } + else + { + var flagInternal = GetFastValue(config, 'flagInternal', false); + var removeCollinear = GetFastValue(config, 'removeCollinear', 0.01); + var minimumArea = GetFastValue(config, 'minimumArea', 10); + + body = Bodies.fromVertices(bodyX, bodyY, verts, options, flagInternal, removeCollinear, minimumArea); + } } + break; case 'fromPhysicsEditor': @@ -155329,7 +167620,10 @@ var SetBody = { break; } - this.setExistingBody(body, config.addToWorld); + if (body) + { + this.setExistingBody(body, config.addToWorld); + } return this; } @@ -155340,7 +167634,7 @@ module.exports = SetBody; /***/ }), -/* 1040 */ +/* 1096 */ /***/ (function(module, exports) { /** @@ -155393,7 +167687,7 @@ module.exports = Sensor; /***/ }), -/* 1041 */ +/* 1097 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -155402,7 +167696,7 @@ module.exports = Sensor; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Body = __webpack_require__(74); +var Body = __webpack_require__(67); /** * [description] @@ -155448,7 +167742,7 @@ module.exports = Static; /***/ }), -/* 1042 */ +/* 1098 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -155457,8 +167751,8 @@ module.exports = Static; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Body = __webpack_require__(74); -var Vector2 = __webpack_require__(6); +var Body = __webpack_require__(67); +var Vector2 = __webpack_require__(3); /** * [description] @@ -155506,7 +167800,7 @@ var Mass = { * The body's center of mass. * * @name Phaser.Physics.Matter.Components.Mass#centerOfMass - * @readOnly + * @readonly * @since 3.10.0 * * @return {Phaser.Math.Vector2} The center of mass. @@ -155525,7 +167819,7 @@ module.exports = Mass; /***/ }), -/* 1043 */ +/* 1099 */ /***/ (function(module, exports) { /** @@ -155535,7 +167829,7 @@ module.exports = Mass; */ /** - * [description] + * A component to manipulate world gravity for Matter.js bodies. * * @name Phaser.Physics.Matter.Components.Gravity * @since 3.0.0 @@ -155543,12 +167837,12 @@ module.exports = Mass; var Gravity = { /** - * [description] + * A togglable function for ignoring world gravity in real-time on the current body. * * @method Phaser.Physics.Matter.Components.Gravity#setIgnoreGravity * @since 3.0.0 * - * @param {boolean} value - [description] + * @param {boolean} value - Set to true to ignore the effect of world gravity, or false to not ignore it. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -155565,7 +167859,7 @@ module.exports = Gravity; /***/ }), -/* 1044 */ +/* 1100 */ /***/ (function(module, exports) { /** @@ -155651,7 +167945,7 @@ module.exports = Friction; /***/ }), -/* 1045 */ +/* 1101 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -155660,10 +167954,10 @@ module.exports = Friction; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Body = __webpack_require__(74); +var Body = __webpack_require__(67); /** - * [description] + * A component to apply force to Matter.js bodies. * * @name Phaser.Physics.Matter.Components.Force * @since 3.0.0 @@ -155671,13 +167965,14 @@ var Body = __webpack_require__(74); var Force = { // force = vec2 / point + /** - * [description] + * Applies a force to a body. * * @method Phaser.Physics.Matter.Components.Force#applyForce * @since 3.0.0 * - * @param {Phaser.Math.Vector2} force - [description] + * @param {Phaser.Math.Vector2} force - A Vector that specifies the force to apply. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -155691,13 +167986,13 @@ var Force = { }, /** - * [description] + * Applies a force to a body from a given position. * * @method Phaser.Physics.Matter.Components.Force#applyForceFrom * @since 3.0.0 * - * @param {Phaser.Math.Vector2} position - [description] - * @param {Phaser.Math.Vector2} force - [description] + * @param {Phaser.Math.Vector2} position - The position in which the force comes from. + * @param {Phaser.Math.Vector2} force - A Vector that specifies the force to apply. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -155709,12 +168004,12 @@ var Force = { }, /** - * [description] + * Apply thrust to the forward position of the body. * * @method Phaser.Physics.Matter.Components.Force#thrust * @since 3.0.0 * - * @param {number} speed - [description] + * @param {number} speed - A speed value to be applied to a directional force. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -155730,12 +168025,12 @@ var Force = { }, /** - * [description] + * Apply thrust to the left position of the body. * * @method Phaser.Physics.Matter.Components.Force#thrustLeft * @since 3.0.0 * - * @param {number} speed - [description] + * @param {number} speed - A speed value to be applied to a directional force. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -155751,12 +168046,12 @@ var Force = { }, /** - * [description] + * Apply thrust to the right position of the body. * * @method Phaser.Physics.Matter.Components.Force#thrustRight * @since 3.0.0 * - * @param {number} speed - [description] + * @param {number} speed - A speed value to be applied to a directional force. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -155772,12 +168067,12 @@ var Force = { }, /** - * [description] + * Apply thrust to the back position of the body. * * @method Phaser.Physics.Matter.Components.Force#thrustBack * @since 3.0.0 * - * @param {number} speed - [description] + * @param {number} speed - A speed value to be applied to a directional force. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -155798,7 +168093,7 @@ module.exports = Force; /***/ }), -/* 1046 */ +/* 1102 */ /***/ (function(module, exports) { /** @@ -155886,7 +168181,7 @@ module.exports = Collision; /***/ }), -/* 1047 */ +/* 1103 */ /***/ (function(module, exports) { /** @@ -155909,7 +168204,7 @@ var Bounce = { * @method Phaser.Physics.Matter.Components.Bounce#setBounce * @since 3.0.0 * - * @param {float} value - [description] + * @param {number} value - [description] * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -155926,7 +168221,7 @@ module.exports = Bounce; /***/ }), -/* 1048 */ +/* 1104 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -155935,12 +168230,12 @@ module.exports = Bounce; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Components = __webpack_require__(611); -var GetFastValue = __webpack_require__(1); -var Vector2 = __webpack_require__(6); +var Components = __webpack_require__(419); +var GetFastValue = __webpack_require__(2); +var Vector2 = __webpack_require__(3); /** - * [description] + * Internal function to check if the object has a getter or setter. * * @function hasGetterOrSetter * @private @@ -155960,11 +168255,11 @@ function hasGetterOrSetter (def) * @function Phaser.Physics.Matter.MatterGameObject * @since 3.3.0 * - * @param {Phaser.Physics.Matter.World} world - [description] - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {object} options - [description] + * @param {Phaser.Physics.Matter.World} world - The Matter world to add the body to. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will have the Matter body applied to it. + * @param {object} options - Matter options config object. * - * @return {Phaser.GameObjects.GameObject} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was created with the Matter body. */ var MatterGameObject = function (world, gameObject, options) { @@ -155975,6 +168270,7 @@ var MatterGameObject = function (world, gameObject, options) // Temp body pos to avoid body null checks gameObject.body = { + temp: true, position: { x: x, y: y @@ -156036,7 +168332,7 @@ module.exports = MatterGameObject; /***/ }), -/* 1049 */ +/* 1105 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -156051,14 +168347,14 @@ module.exports = MatterGameObject; module.exports = { - Factory: __webpack_require__(1018), - Image: __webpack_require__(1015), - Matter: __webpack_require__(676), - MatterPhysics: __webpack_require__(1030), - PolyDecomp: __webpack_require__(1017), - Sprite: __webpack_require__(1014), - TileBody: __webpack_require__(679), - World: __webpack_require__(1008) + Factory: __webpack_require__(1070), + Image: __webpack_require__(1067), + Matter: __webpack_require__(501), + MatterPhysics: __webpack_require__(1086), + PolyDecomp: __webpack_require__(1069), + Sprite: __webpack_require__(1066), + TileBody: __webpack_require__(504), + World: __webpack_require__(1060) }; @@ -156114,9 +168410,18 @@ module.exports = { * @class MatterJS.Engine */ +/** + * @classdesc +* The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. +* A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. +* A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). +* +* @class MatterJS.Vertices +*/ + /***/ }), -/* 1050 */ +/* 1106 */ /***/ (function(module, exports) { /** @@ -156201,7 +168506,7 @@ module.exports = SeperateY; /***/ }), -/* 1051 */ +/* 1107 */ /***/ (function(module, exports) { /** @@ -156257,7 +168562,7 @@ module.exports = SeperateX; /***/ }), -/* 1052 */ +/* 1108 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -156266,9 +168571,9 @@ module.exports = SeperateX; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var COLLIDES = __webpack_require__(333); -var SeperateX = __webpack_require__(1051); -var SeperateY = __webpack_require__(1050); +var COLLIDES = __webpack_require__(224); +var SeperateX = __webpack_require__(1107); +var SeperateY = __webpack_require__(1106); /** * Impact Physics Solver @@ -156331,7 +168636,7 @@ module.exports = Solver; /***/ }), -/* 1053 */ +/* 1109 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -156341,18 +168646,18 @@ module.exports = Solver; */ var Class = __webpack_require__(0); -var Factory = __webpack_require__(1023); -var GetFastValue = __webpack_require__(1); -var Merge = __webpack_require__(94); -var PluginCache = __webpack_require__(12); -var World = __webpack_require__(1019); +var Factory = __webpack_require__(1075); +var GetFastValue = __webpack_require__(2); +var Merge = __webpack_require__(96); +var PluginCache = __webpack_require__(15); +var World = __webpack_require__(1071); /** * @classdesc * [description] * * @class ImpactPhysics - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -156547,7 +168852,7 @@ module.exports = ImpactPhysics; /***/ }), -/* 1054 */ +/* 1110 */ /***/ (function(module, exports) { /** @@ -156557,7 +168862,8 @@ module.exports = ImpactPhysics; */ /** - * [description] + * The Impact Velocity component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Velocity * @since 3.0.0 @@ -156565,14 +168871,14 @@ module.exports = ImpactPhysics; var Velocity = { /** - * [description] + * Sets the horizontal velocity of the physics body. * * @method Phaser.Physics.Impact.Components.Velocity#setVelocityX * @since 3.0.0 * - * @param {number} x - [description] + * @param {number} x - The horizontal velocity value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setVelocityX: function (x) { @@ -156582,14 +168888,14 @@ var Velocity = { }, /** - * [description] + * Sets the vertical velocity of the physics body. * * @method Phaser.Physics.Impact.Components.Velocity#setVelocityY * @since 3.0.0 * - * @param {number} y - [description] + * @param {number} y - The vertical velocity value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setVelocityY: function (y) { @@ -156599,15 +168905,15 @@ var Velocity = { }, /** - * [description] + * Sets the horizontal and vertical velocities of the physics body. * * @method Phaser.Physics.Impact.Components.Velocity#setVelocity * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The horizontal velocity value. + * @param {number} [y=x] - The vertical velocity value. If not given, defaults to the horizontal value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setVelocity: function (x, y) { @@ -156620,15 +168926,15 @@ var Velocity = { }, /** - * [description] + * Sets the maximum velocity this body can travel at. * * @method Phaser.Physics.Impact.Components.Velocity#setMaxVelocity * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The maximum allowed horizontal velocity. + * @param {number} [y=x] - The maximum allowed vertical velocity. If not given, defaults to the horizontal value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setMaxVelocity: function (x, y) { @@ -156646,7 +168952,7 @@ module.exports = Velocity; /***/ }), -/* 1055 */ +/* 1111 */ /***/ (function(module, exports) { /** @@ -156656,7 +168962,8 @@ module.exports = Velocity; */ /** - * [description] + * The Impact Set Game Object component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.SetGameObject * @since 3.0.0 @@ -156721,7 +169028,7 @@ module.exports = SetGameObject; /***/ }), -/* 1056 */ +/* 1112 */ /***/ (function(module, exports) { /** @@ -156731,7 +169038,8 @@ module.exports = SetGameObject; */ /** - * [description] + * The Impact Offset component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Offset * @since 3.0.0 @@ -156770,7 +169078,7 @@ module.exports = Offset; /***/ }), -/* 1057 */ +/* 1113 */ /***/ (function(module, exports) { /** @@ -156780,7 +169088,8 @@ module.exports = Offset; */ /** - * [description] + * The Impact Gravity component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Gravity * @since 3.0.0 @@ -156831,7 +169140,7 @@ module.exports = Gravity; /***/ }), -/* 1058 */ +/* 1114 */ /***/ (function(module, exports) { /** @@ -156841,7 +169150,8 @@ module.exports = Gravity; */ /** - * [description] + * The Impact Friction component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Friction * @since 3.0.0 @@ -156907,7 +169217,7 @@ module.exports = Friction; /***/ }), -/* 1059 */ +/* 1115 */ /***/ (function(module, exports) { /** @@ -156917,7 +169227,8 @@ module.exports = Friction; */ /** - * [description] + * The Impact Debug component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Debug * @since 3.0.0 @@ -157031,7 +169342,7 @@ module.exports = Debug; /***/ }), -/* 1060 */ +/* 1116 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -157040,7 +169351,7 @@ module.exports = Debug; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var COLLIDES = __webpack_require__(333); +var COLLIDES = __webpack_require__(224); /** * @callback CollideCallback @@ -157051,7 +169362,8 @@ var COLLIDES = __webpack_require__(333); */ /** - * [description] + * The Impact Collides component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Collides * @since 3.0.0 @@ -157186,7 +169498,7 @@ module.exports = Collides; /***/ }), -/* 1061 */ +/* 1117 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -157195,10 +169507,11 @@ module.exports = Collides; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var TYPE = __webpack_require__(332); +var TYPE = __webpack_require__(223); /** - * [description] + * The Impact Check Against component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.CheckAgainst * @since 3.0.0 @@ -157307,7 +169620,7 @@ module.exports = CheckAgainst; /***/ }), -/* 1062 */ +/* 1118 */ /***/ (function(module, exports) { /** @@ -157317,7 +169630,8 @@ module.exports = CheckAgainst; */ /** - * [description] + * The Impact Bounce component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Bounce * @since 3.0.0 @@ -157325,12 +169639,12 @@ module.exports = CheckAgainst; var Bounce = { /** - * [description] + * Sets the impact physics bounce, or restitution, value. * * @method Phaser.Physics.Impact.Components.Bounce#setBounce * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - A value between 0 (no rebound) and 1 (full rebound) * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -157342,12 +169656,12 @@ var Bounce = { }, /** - * [description] + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. * * @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The minimum allowed velocity. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -157359,7 +169673,8 @@ var Bounce = { }, /** - * [description] + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) * * @name Phaser.Physics.Impact.Components.Bounce#bounce * @type {number} @@ -157385,7 +169700,7 @@ module.exports = Bounce; /***/ }), -/* 1063 */ +/* 1119 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -157394,10 +169709,11 @@ module.exports = Bounce; * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var TYPE = __webpack_require__(332); +var TYPE = __webpack_require__(223); /** - * [description] + * The Impact Body Type component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.BodyType * @since 3.0.0 @@ -157468,7 +169784,7 @@ module.exports = BodyType; /***/ }), -/* 1064 */ +/* 1120 */ /***/ (function(module, exports) { /** @@ -157478,7 +169794,8 @@ module.exports = BodyType; */ /** - * [description] + * The Impact Body Scale component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.BodyScale * @since 3.0.0 @@ -157486,15 +169803,15 @@ module.exports = BodyType; var BodyScale = { /** - * [description] + * Sets the size of the physics body. * * @method Phaser.Physics.Impact.Components.BodyScale#setBodySize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} [height=width] - [description] + * @param {number} width - The width of the body in pixels. + * @param {number} [height=width] - The height of the body in pixels. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setBodySize: function (width, height) { @@ -157507,15 +169824,15 @@ var BodyScale = { }, /** - * [description] + * Sets the scale of the physics body. * * @method Phaser.Physics.Impact.Components.BodyScale#setBodyScale * @since 3.0.0 * - * @param {number} scaleX - [description] - * @param {number} [scaleY] - [description] + * @param {number} scaleX - The horizontal scale of the body. + * @param {number} [scaleY] - The vertical scale of the body. If not given, will use the horizontal scale value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setBodyScale: function (scaleX, scaleY) { @@ -157541,7 +169858,7 @@ module.exports = BodyScale; /***/ }), -/* 1065 */ +/* 1121 */ /***/ (function(module, exports) { /** @@ -157551,7 +169868,8 @@ module.exports = BodyScale; */ /** - * [description] + * The Impact Acceleration component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Acceleration * @since 3.0.0 @@ -157559,14 +169877,14 @@ module.exports = BodyScale; var Acceleration = { /** - * [description] + * Sets the horizontal acceleration of this body. * * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX * @since 3.0.0 * - * @param {number} x - [description] + * @param {number} x - The amount of acceleration to apply. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setAccelerationX: function (x) { @@ -157576,14 +169894,14 @@ var Acceleration = { }, /** - * [description] + * Sets the vertical acceleration of this body. * * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY * @since 3.0.0 * - * @param {number} y - [description] + * @param {number} y - The amount of acceleration to apply. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setAccelerationY: function (y) { @@ -157593,15 +169911,15 @@ var Acceleration = { }, /** - * [description] + * Sets the horizontal and vertical acceleration of this body. * * @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The amount of horizontal acceleration to apply. + * @param {number} y - The amount of vertical acceleration to apply. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setAcceleration: function (x, y) { @@ -157617,7 +169935,7 @@ module.exports = Acceleration; /***/ }), -/* 1066 */ +/* 1122 */ /***/ (function(module, exports) { /** @@ -157688,7 +170006,7 @@ module.exports = { /***/ }), -/* 1067 */ +/* 1123 */ /***/ (function(module, exports) { /** @@ -157783,7 +170101,7 @@ module.exports = UpdateMotion; /***/ }), -/* 1068 */ +/* 1124 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -157800,7 +170118,7 @@ var Clamp = __webpack_require__(23); * @function Phaser.Physics.Impact.GetVelocity * @since 3.0.0 * - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. * @param {number} vel - [description] * @param {number} accel - [description] * @param {number} friction - [description] @@ -157839,7 +170157,7 @@ module.exports = GetVelocity; /***/ }), -/* 1069 */ +/* 1125 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -157865,22 +170183,22 @@ module.exports = GetVelocity; */ module.exports = { - Body: __webpack_require__(1025), - COLLIDES: __webpack_require__(333), - CollisionMap: __webpack_require__(1024), - Factory: __webpack_require__(1023), - Image: __webpack_require__(1021), - ImpactBody: __webpack_require__(1022), - ImpactPhysics: __webpack_require__(1053), - Sprite: __webpack_require__(1020), - TYPE: __webpack_require__(332), - World: __webpack_require__(1019) + Body: __webpack_require__(1077), + COLLIDES: __webpack_require__(224), + CollisionMap: __webpack_require__(1076), + Factory: __webpack_require__(1075), + Image: __webpack_require__(1073), + ImpactBody: __webpack_require__(1074), + ImpactPhysics: __webpack_require__(1109), + Sprite: __webpack_require__(1072), + TYPE: __webpack_require__(223), + World: __webpack_require__(1071) }; /***/ }), -/* 1070 */ +/* 1126 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -157895,15 +170213,15 @@ module.exports = { module.exports = { - Arcade: __webpack_require__(703), - Impact: __webpack_require__(1069), - Matter: __webpack_require__(1049) + Arcade: __webpack_require__(528), + Impact: __webpack_require__(1125), + Matter: __webpack_require__(1105) }; /***/ }), -/* 1071 */ +/* 1127 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) {/** @@ -157912,10 +170230,10 @@ module.exports = { * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -__webpack_require__(609); +__webpack_require__(1059); -var CONST = __webpack_require__(20); -var Extend = __webpack_require__(17); +var CONST = __webpack_require__(26); +var Extend = __webpack_require__(20); /** * @namespace Phaser @@ -157923,38 +170241,46 @@ var Extend = __webpack_require__(17); var Phaser = { - Actions: __webpack_require__(599), - Animation: __webpack_require__(568), - Cache: __webpack_require__(567), - Cameras: __webpack_require__(960), + Actions: __webpack_require__(417), + Animation: __webpack_require__(993), + Cache: __webpack_require__(992), + Cameras: __webpack_require__(991), Class: __webpack_require__(0), - Create: __webpack_require__(954), - Curves: __webpack_require__(948), - Data: __webpack_require__(544), - Display: __webpack_require__(945), - DOM: __webpack_require__(916), - Events: __webpack_require__(536), - Game: __webpack_require__(534), - GameObjects: __webpack_require__(915), - Geom: __webpack_require__(400), - Input: __webpack_require__(383), - Loader: __webpack_require__(759), - Math: __webpack_require__(745), - Physics: __webpack_require__(1070), - Plugins: __webpack_require__(330), - Renderer: __webpack_require__(673), - Scene: __webpack_require__(193), - Scenes: __webpack_require__(328), - Sound: __webpack_require__(326), - Structs: __webpack_require__(325), - Textures: __webpack_require__(324), - Tilemaps: __webpack_require__(668), - Time: __webpack_require__(308), - Tweens: __webpack_require__(306), - Utils: __webpack_require__(619) + Create: __webpack_require__(948), + Curves: __webpack_require__(942), + Data: __webpack_require__(939), + Display: __webpack_require__(937), + DOM: __webpack_require__(908), + Events: __webpack_require__(906), + Game: __webpack_require__(904), + GameObjects: __webpack_require__(876), + Geom: __webpack_require__(274), + Input: __webpack_require__(616), + Loader: __webpack_require__(593), + Math: __webpack_require__(570), + Physics: __webpack_require__(1126), + Plugins: __webpack_require__(498), + Renderer: __webpack_require__(1083), + Scene: __webpack_require__(328), + Scenes: __webpack_require__(496), + Sound: __webpack_require__(494), + Structs: __webpack_require__(493), + Textures: __webpack_require__(492), + Tilemaps: __webpack_require__(490), + Time: __webpack_require__(441), + Tweens: __webpack_require__(439), + Utils: __webpack_require__(435) }; +// Merge in the optional plugins + +if (false) +{} + +if (false) +{} + // Merge in the consts Phaser = Extend(false, Phaser, CONST); @@ -157971,7 +170297,7 @@ global.Phaser = Phaser; * -- Dick Brandon */ -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(215))) +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(200))) /***/ }) /******/ ]); diff --git a/dist/phaser.min.js b/dist/phaser.min.js index b572aef49..e6b557509 100644 --- a/dist/phaser.min.js +++ b/dist/phaser.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}(window,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1071)}([function(t,e){function i(t,e,i){var n=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&n.value&&"object"==typeof n.value&&(n=n.value),!(!n||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(n))&&(void 0===n.enumerable&&(n.enumerable=!0),void 0===n.configurable&&(n.configurable=!0),n)}function n(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function s(t,e,s,r){for(var a in e)if(e.hasOwnProperty(a)){var h=i(e,a,s);if(!1!==h){if(n((r||t).prototype,a)){if(o.ignoreFinals)continue;throw new Error("cannot override final property '"+a+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,a,h)}else t.prototype[a]=e[a]}}function r(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},transformMat3:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},transformMat4:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[4]*i+n[12],this.y=n[1]*e+n[5]*i+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,e){var i={},n={install:function(t){for(var e in i)t[e]=i[e]},register:function(t,e){i[t]=e},destroy:function(){i={}}};t.exports=n},function(t,e){t.exports=function(t){if("object"!=typeof t||t.nodeType||t===t.window)return!1;try{if(t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0}},function(t,e,i){"use strict";var n=Object.prototype.hasOwnProperty,s="~";function r(){}function o(t,e,i,n,r){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new function(t,e,i){this.fn=t,this.context=e,this.once=i||!1}(i,n||t,r),a=s?s+e:e;return t._events[a]?t._events[a].fn?t._events[a]=[t._events[a],o]:t._events[a].push(o):(t._events[a]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function h(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(s=!1)),h.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)n.call(t,e)&&i.push(s?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},h.prototype.listeners=function(t){var e=s?s+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,r=i.length,o=new Array(r);n=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=l},function(t,e,i){t.exports={Alpha:i(587),Animation:i(302),BlendMode:i(586),ComputedSize:i(585),Depth:i(584),Flip:i(583),GetBounds:i(582),Mask:i(581),MatrixStack:i(580),Origin:i(579),Pipeline:i(291),ScaleMode:i(578),ScrollFactor:i(577),Size:i(576),Texture:i(575),Tint:i(574),ToJSON:i(573),Transform:i(572),TransformMatrix:i(64),Visible:i(571)}},function(t,e,i){var n=i(297),s={PI2:2*Math.PI,TAU:.5*Math.PI,EPSILON:1e-6,DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI,RND:new n};t.exports=s},function(t,e,i){var n=i(8),s=function(){var t,e,i,r,o,a,h=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof h&&(c=h,h=arguments[1]||{},l=2),u===l&&(h=this,--l);l=400&&t.status<=599&&(i=!1),this.resetXHR(),this.loader.nextFile(this,i)},onError:function(){this.resetXHR(),this.loader.nextFile(this,!1)},onProgress:function(t){t.lengthComputable&&(this.bytesLoaded=t.loaded,this.bytesTotal=t.total,this.percentComplete=Math.min(this.bytesLoaded/this.bytesTotal,1),this.loader.emit("fileprogress",this,this.percentComplete))},onProcess:function(){this.state=s.FILE_PROCESSING,this.onProcessComplete()},onProcessComplete:function(){this.state=s.FILE_COMPLETE,this.multiFile&&this.multiFile.onFileComplete(this),this.loader.fileProcessComplete(this)},onProcessError:function(){this.state=s.FILE_ERRORED,this.multiFile&&this.multiFile.onFileFailed(this),this.loader.fileProcessComplete(this)},hasCacheConflict:function(){return this.cache&&this.cache.exists(this.key)},addToCache:function(){this.cache&&this.cache.add(this.key,this.data),this.pendingDestroy()},pendingDestroy:function(t){void 0===t&&(t=this.data);var e=this.key,i=this.type;this.loader.emit("filecomplete",e,i,t),this.loader.emit("filecomplete_"+i+"_"+e,e,i,t),this.loader.flagForRemoval(this)},destroy:function(){this.loader=null,this.cache=null,this.xhrSettings=null,this.multiFile=null,this.linkFile=null,this.data=null}});u.createObjectURL=function(t,e,i){if("function"==typeof URL)t.src=URL.createObjectURL(e);else{var n=new FileReader;n.onload=function(){t.removeAttribute("crossOrigin"),t.src="data:"+(e.type||i)+";base64,"+n.result.split(",")[1]},n.onerror=t.onerror,n.readAsDataURL(e)}},u.revokeObjectURL=function(t){"function"==typeof URL&&URL.revokeObjectURL(t.src)},t.exports=u},function(t,e,i){var n={VERSION:"3.10.1",BlendModes:i(51),ScaleModes:i(59),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=n},function(t,e,i){var n=i(1);t.exports=function(t,e,i,s,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=o.width),void 0===s&&(s=o.height);var a=n(r,"isNotEmpty",!1),h=n(r,"isColliding",!1),l=n(r,"hasInterestingFace",!1);t<0&&(i+=t,t=0),e<0&&(s+=e,e=0),t+i>o.width&&(i=Math.max(o.width-t,0)),e+s>o.height&&(s=Math.max(o.height-e,0));for(var u=[],c=e;c=0;o--)t[o][e]=i+a*n,a++;return t}},function(t,e){t.exports={CSV:0,TILED_JSON:1,ARRAY_2D:2,WELTMEISTER:3}},function(t,e){t.exports={getTintFromFloats:function(t,e,i,n){return((255&(255*n|0))<<24|(255&(255*t|0))<<16|(255&(255*e|0))<<8|255&(255*i|0))>>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,n=0;ns||e>=i||i>s||e+i>s){if(n)throw new Error("Range Error: Values outside acceptable range");return!1}return!0}},function(t,e,i){var n=i(0),s=i(152),r=i(284),o=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=255),this.r=0,this.g=0,this.b=0,this.a=255,this.gl=[0,0,0,1],this._color=0,this._color32=0,this._rgba="",this.setTo(t,e,i,n)},transparent:function(){return this.red=0,this.green=0,this.blue=0,this.alpha=0,this.update()},setTo:function(t,e,i,n){return void 0===n&&(n=255),this.red=t,this.green=e,this.blue=i,this.alpha=n,this.update()},setGLTo:function(t,e,i,n){return void 0===n&&(n=1),this.redGL=t,this.greenGL=e,this.blueGL=i,this.alphaGL=n,this.update()},setFromRGB:function(t){return this.red=t.r,this.green=t.g,this.blue=t.b,t.hasOwnProperty("a")&&(this.alpha=t.a),this.update()},update:function(){return this._color=s(this.r,this.g,this.b),this._color32=r(this.r,this.g,this.b,this.a),this._rgba="rgba("+this.r+","+this.g+","+this.b+","+this.a/255+")",this},clone:function(){return new o(this.r,this.g,this.b,this.a)},color:{get:function(){return this._color}},color32:{get:function(){return this._color32}},rgba:{get:function(){return this._rgba}},redGL:{get:function(){return this.gl[0]},set:function(t){this.gl[0]=Math.min(Math.abs(t),1),this.r=Math.floor(255*this.gl[0]),this.update()}},greenGL:{get:function(){return this.gl[1]},set:function(t){this.gl[1]=Math.min(Math.abs(t),1),this.g=Math.floor(255*this.gl[1]),this.update()}},blueGL:{get:function(){return this.gl[2]},set:function(t){this.gl[2]=Math.min(Math.abs(t),1),this.b=Math.floor(255*this.gl[2]),this.update()}},alphaGL:{get:function(){return this.gl[3]},set:function(t){this.gl[3]=Math.min(Math.abs(t),1),this.a=Math.floor(255*this.gl[3]),this.update()}},red:{get:function(){return this.r},set:function(t){t=Math.floor(Math.abs(t)),this.r=Math.min(t,255),this.gl[0]=t/255,this.update()}},green:{get:function(){return this.g},set:function(t){t=Math.floor(Math.abs(t)),this.g=Math.min(t,255),this.gl[1]=t/255,this.update()}},blue:{get:function(){return this.b},set:function(t){t=Math.floor(Math.abs(t)),this.b=Math.min(t,255),this.gl[2]=t/255,this.update()}},alpha:{get:function(){return this.a},set:function(t){t=Math.floor(Math.abs(t)),this.a=Math.min(t,255),this.gl[3]=t/255,this.update()}}});t.exports=o},function(t,e){t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i}},function(t,e){t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(556),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Size,s.Texture,s.Tint,s.Transform,s.Visible,o],initialize:function(t,e,i,n,o){r.call(this,t,"Sprite"),this.anims=new s.Animation(this),this.setTexture(n,o),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline")},preUpdate:function(t,e){this.anims.update(t,e)},play:function(t,e,i){return this.anims.play(t,e,i),this},toJSON:function(){return s.ToJSON(this)}});t.exports=a},function(t,e){t.exports=function(t,e,i,n,s,r){var o;void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=s;o=0;o--)t[o][e]+=i+a*n,a++;return t}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n){this.loader=t,this.type=e,this.key=i,this.files=n,this.complete=!1,this.pending=n.length,this.failed=0,this.config={};for(var s=0;s0;e--){var n=Math.floor(i.random()*(e+1)),s=t[e];t[e]=t[n],t[n]=s}return t},i.choose=function(t){return t[Math.floor(i.random()*t.length)]},i.isElement=function(t){return t instanceof HTMLElement},i.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},i.isFunction=function(t){return"function"==typeof t},i.isPlainObject=function(t){return"object"==typeof t&&t.constructor===Object},i.isString=function(t){return"[object String]"===Object.prototype.toString.call(t)},i.clamp=function(t,e,i){return ti?i:t},i.sign=function(t){return t<0?-1:1},i.now=function(){if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-i._nowStartTime},i.random=function(e,i){return e=void 0!==e?e:0,i=void 0!==i?i:1,e+t()*(i-e)};var t=function(){return i._seed=(9301*i._seed+49297)%233280,i._seed/233280};i.colorToNumber=function(t){return 3==(t=t.replace("#","")).length&&(t=t.charAt(0)+t.charAt(0)+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)),parseInt(t,16)},i.logLevel=1,i.log=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.info=function(){console&&i.logLevel>0&&i.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.warn=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.nextId=function(){return i._nextId++},i.map=function(t,e){if(t.map)return t.map(e);for(var i=[],n=0;n=t.length)){for(var i=t.length-1,n=t[e],s=e;s=0&&y>=0&&v+y<1}},function(t,e){t.exports={CREATED:0,INIT:1,DELAY:2,OFFSET_DELAY:3,PENDING_RENDER:4,PLAYING_FORWARD:5,PLAYING_BACKWARD:6,HOLD_DELAY:7,REPEAT_DELAY:8,COMPLETE:9,PENDING_ADD:20,PAUSED:21,LOOP_DELAY:22,ACTIVE:23,COMPLETE_DELAY:24,PENDING_REMOVE:25,REMOVED:26}},function(t,e){t.exports=function(t,e,i){return t&&t.hasOwnProperty(e)?t[e]:i}},function(t,e,i){var n=i(453);t.exports=function(t,e){if("string"==typeof t&&n.hasOwnProperty(t)){if(e){var i=e.slice(0);return i.unshift(0),function(e){return i[0]=e,n[t].apply(this,i)}}return n[t]}return"function"==typeof t?t:(Array.isArray(t)&&t.length,n.Power0)}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,n,s,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0}},a:{get:function(){return this.matrix[0]},set:function(t){this.matrix[0]=t}},b:{get:function(){return this.matrix[1]},set:function(t){this.matrix[1]=t}},c:{get:function(){return this.matrix[2]},set:function(t){this.matrix[2]=t}},d:{get:function(){return this.matrix[3]},set:function(t){this.matrix[3]=t}},tx:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},ty:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},rotation:{get:function(){return Math.acos(this.a/this.scaleX)*(Math.atan(-this.c/this.a)<0?-1:1)}},scaleX:{get:function(){return Math.sqrt(this.a*this.a+this.c*this.c)}},scaleY:{get:function(){return Math.sqrt(this.b*this.b+this.d*this.d)}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3];return n[0]=s*i+o*e,n[1]=r*i+a*e,n[2]=s*-e+o*i,n[3]=r*-e+a*i,this},multiply:function(t){var e=this.matrix,i=t.matrix,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=i[0],u=i[1],c=i[2],d=i[3],f=i[4],p=i[5];return e[0]=l*n+u*r,e[1]=l*s+u*o,e[2]=c*n+d*r,e[3]=c*s+d*o,e[4]=f*n+p*r+a,e[5]=f*s+p*o+h,this},transform:function(t,e,i,n,s,r){var o=this.matrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=t*a+e*l,o[1]=t*h+e*u,o[2]=i*a+n*l,o[3]=i*h+n*u,o[4]=s*a+r*l+c,o[5]=s*h+r*u+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3],h=n[4],l=n[5];return i.x=t*s+e*o+h,i.y=t*r+e*a+l,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=e*s-i*n;return t[0]=s/a,t[1]=-i/a,t[2]=-n/a,t[3]=e/a,t[4]=(n*o-s*r)/a,t[5]=-(e*o-i*r)/a,this},setTransform:function(t,e,i,n,s,r){var o=this.matrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],n=e[1],s=e[2],r=e[3],o=i*i,a=n*n,h=s*s,l=r*r,u=Math.sqrt(o+h),c=Math.sqrt(a+l);return t.translateX=e[4],t.translateY=e[5],t.scaleX=u,t.scaleY=c,t.rotation=Math.acos(i/u)*(Math.atan(-s/i)<0?-1:1),t},applyITRS:function(t,e,i,n,s){var r=this.matrix,o=Math.sin(i),a=Math.cos(i);return r[4]=t,r[5]=e,r[0]=a*n,r[1]=o*n,r[2]=-o*s,r[3]=a*s,this},destroy:function(){this.matrix=null,this.decomposedMatrix=null}});t.exports=n},function(t,e,i){var n=i(23);t.exports=function(t,e,i){return(i-e)*(t=n(t,0,1))}},function(t,e,i){var n=i(0),s=i(15),r=i(389),o=new n({Mixins:[s.Alpha,s.Flip,s.Visible],initialize:function(t,e,i,n,s,r,o,a){this.layer=t,this.index=e,this.x=i,this.y=n,this.width=s,this.height=r,this.baseWidth=void 0!==o?o:s,this.baseHeight=void 0!==a?a:r,this.pixelX=0,this.pixelY=0,this.updatePixelXY(),this.properties={},this.rotation=0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceLeft=!1,this.faceRight=!1,this.faceTop=!1,this.faceBottom=!1,this.collisionCallback=null,this.collisionCallbackContext=this,this.tint=16777215,this.physics={}},containsPoint:function(t,e){return!(tthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldX(this.x,t):this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldY(this.y,t)-(this.height-this.baseHeight)*e.scaleY:this.y*this.baseHeight-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new r),e.x=this.getLeft(),e.y=this.getTop(),e.width=this.getRight()-e.x,e.height=this.getBottom()-e.y,e},getCenterX:function(t){return this.getLeft(t)+this.width/2},getCenterY:function(t){return this.getTop(t)+this.height/2},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},intersects:function(t,e,i,n){return!(i<=this.pixelX||n<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,n,s){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===n&&(n=t),void 0===s&&(s=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=n,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=n,s)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,n){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==n&&(this.baseHeight=n),this.updatePixelXY(),this},updatePixelXY:function(){return this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight-(this.height-this.baseHeight),this},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.tilemapLayer;return t?t.tileset:null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=o},function(t,e){t.exports=function(t,e){e?t.setCollision(!0,!0,!0,!0,!1):t.resetCollision(!1)}},function(t,e,i){var n=i(0),s=i(60),r=i(227),o=i(226),a=i(96),h=i(153),l=new n({initialize:function(t,e,i,n,s,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this.x3=s,this.y3=r},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return h(this,t)},setTo:function(t,e,i,n,s,r){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this.x3=s,this.y3=r,this},getLineA:function(t){return void 0===t&&(t=new a),t.setTo(this.x1,this.y1,this.x2,this.y2),t},getLineB:function(t){return void 0===t&&(t=new a),t.setTo(this.x2,this.y2,this.x3,this.y3),t},getLineC:function(t){return void 0===t&&(t=new a),t.setTo(this.x3,this.y3,this.x1,this.y1),t},left:{get:function(){return Math.min(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1<=this.x2&&this.x1<=this.x3?this.x1-t:this.x2<=this.x1&&this.x2<=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},right:{get:function(){return Math.max(this.x1,this.x2,this.x3)},set:function(t){var e=0;e=this.x1>=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=l},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(461),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Size,s.Texture,s.Tint,s.Transform,s.Visible,o],initialize:function(t,e,i,n,s){r.call(this,t,"Image"),this.setTexture(n,s),this.setPosition(e,i),this.setSizeToFrame(),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline")}});t.exports=a},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries=[],Array.isArray(t))for(var e=0;e-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new n;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return this.entries.length=t}}});t.exports=n},function(t,e){t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},function(t,e,i){var n=i(100),s=i(10),r=i(62),o=i(63),a=i(73),h=i(163),l=i(102),u=i(4),c=i(101),d=i(99),f=i(98);t.exports=function(t,e,i){void 0===i&&(i=n);for(var p=i.targets?i.targets:l(e),g=h(e),v=a(e,"delay",i.delay),y=a(e,"duration",i.duration),m=u(e,"easeParams",i.easeParams),x=o(u(e,"ease",i.ease),m),w=a(e,"hold",i.hold),b=a(e,"repeat",i.repeat),T=a(e,"repeatDelay",i.repeatDelay),S=r(e,"yoyo",i.yoyo),A=r(e,"flipX",i.flipX),C=r(e,"flipY",i.flipY),M=[],_=0;_0&&r.rotateAbout(o.position,i,t.position,o.position)}},n.setVelocity=function(t,e){t.positionPrev.x=t.position.x-e.x,t.positionPrev.y=t.position.y-e.y,t.velocity.x=e.x,t.velocity.y=e.y,t.speed=r.magnitude(t.velocity)},n.setAngularVelocity=function(t,e){t.anglePrev=t.angle-e,t.angularVelocity=e,t.angularSpeed=Math.abs(t.angularVelocity)},n.translate=function(t,e){n.setPosition(t,r.add(t.position,e))},n.rotate=function(t,e,i){if(i){var s=Math.cos(e),r=Math.sin(e),o=t.position.x-i.x,a=t.position.y-i.y;n.setPosition(t,{x:i.x+(o*s-a*r),y:i.y+(o*r+a*s)}),n.setAngle(t,t.angle+e)}else n.setAngle(t,t.angle+e)},n.scale=function(t,i,r,o){o=o||t.position;for(var a=0;a0&&(f.position.x+=t.velocity.x,f.position.y+=t.velocity.y),0!==t.angularVelocity&&(s.rotate(f.vertices,t.angularVelocity,t.position),l.rotate(f.axes,t.angularVelocity),d>0&&r.rotateAbout(f.position,t.angularVelocity,t.position,f.position)),h.update(f.bounds,f.vertices,t.velocity)}},n.applyForce=function(t,e,i){t.force.x+=i.x,t.force.y+=i.y;var n=e.x-t.position.x,s=e.y-t.position.y;t.torque+=n*i.y-s*i.x};var e=function(t){for(var e={mass:0,area:0,inertia:0,centre:{x:0,y:0}},i=1===t.parts.length?0:1;i=0;i--){var n=this.sounds[i];n.key===t&&(n.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:o,onBlur:o,onFocus:o,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(n,s){n.pendingRemove||t.call(e||i,n,s,i.sounds)})},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("detune",this,t)}}});t.exports=a},function(t,e,i){var n,s=i(57),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(n=navigator.userAgent,/Edge\/\d+/.test(n)?r.edge=!0:/Chrome\/(\d+)/.test(n)&&!s.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(n)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&s.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(n)?r.opera=!0:/Safari/.test(n)&&!s.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(r.silk=!0),r)},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.parent=t,this.events=e,e||(this.events=t.events?t.events:t),this.list={},this.values={},this._frozen=!1,!t.hasOwnProperty("sys")&&this.events&&this.events.once("destroy",this.destroy,this)},get:function(t){var e=this.list;if(Array.isArray(t)){for(var i=[],n=0;nl&&(r=l),o>l&&(o=l),a=s,h=r;;)if(a=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,n=this.program,s=this.renderer,r=this.vertexSize;s.setProgram(n),s.setVertexBuffer(e);for(var o=0;o=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,a.size,a.type,a.normalized,r,a.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,n=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*n)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,n){return this.renderer.setFloat3(this.program,t,e,i,n),this},setFloat4:function(t,e,i,n,s){return this.renderer.setFloat4(this.program,t,e,i,n,s),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,n){return this.renderer.setInt3(this.program,t,e,i,n),this},setInt4:function(t,e,i,n,s){return this.renderer.setInt4(this.program,t,e,i,n,s),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e){t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},function(t,e,i){var n=i(0),s=i(274),r=i(14),o=i(6),a=new n({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var n=Math.max(1,Math.round(i/e));return s(this.getSpacedPoints(n),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],n=this.getPoint(0,this._tmpVec2A),s=0;i.push(0);for(var r=1;r<=t;r++)s+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(n),i.push(s),n.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++){var n=this.getUtoTmapping(i/t,null,t);e.push(this.getPoint(n))}return e},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=t-1e-4,n=t+1e-4;return i<0&&(i=0),n>1&&(n=1),this.getPoint(i,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var n,s=this.getLengths(i),r=0,o=s.length;n=e?Math.min(e,s[o-1]):t*s[o-1];for(var a,h=0,l=o-1;h<=l;)if((a=s[r=Math.floor(h+(l-h)/2)]-n)<0)h=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(s[r=l]===n)return r/(o-1);var u=s[r];return(r+(n-u)/(s[r+1]-u))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i){this.x=0,this.y=0,this.z=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0)},up:function(){return this.x=0,this.y=1,this.z=0,this},clone:function(){return new n(this.x,this.y,this.z)},crossVectors:function(t,e){var i=t.x,n=t.y,s=t.z,r=e.x,o=e.y,a=e.z;return this.x=n*a-s*o,this.y=s*r-i*a,this.z=i*o-n*r,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},set:function(t,e,i){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0):(this.x=t||0,this.y=e||0,this.z=i||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t,this.z*=t):(this.x=0,this.y=0,this.z=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return Math.sqrt(e*e+i*i+n*n)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0;return e*e+i*i+n*n},length:function(){var t=this.x,e=this.y,i=this.z;return Math.sqrt(t*t+e*e+i*i)},lengthSq:function(){var t=this.x,e=this.y,i=this.z;return t*t+e*e+i*i},normalize:function(){var t=this.x,e=this.y,i=this.z,n=t*t+e*e+i*i;return n>0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return this.x=i*o-n*r,this.y=n*s-e*o,this.z=e*r-i*s,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this},transformMat3:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=e*s[0]+i*s[3]+n*s[6],this.y=e*s[1]+i*s[4]+n*s[7],this.z=e*s[2]+i*s[5]+n*s[8],this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12],this.y=s[1]*e+s[5]*i+s[9]*n+s[13],this.z=s[2]*e+s[6]*i+s[10]*n+s[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=e*s[0]+i*s[4]+n*s[8]+s[12],o=e*s[1]+i*s[5]+n*s[9]+s[13],a=e*s[2]+i*s[6]+n*s[10]+s[14],h=e*s[3]+i*s[7]+n*s[11]+s[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},project:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=s[0],o=s[1],a=s[2],h=s[3],l=s[4],u=s[5],c=s[6],d=s[7],f=s[8],p=s[9],g=s[10],v=s[11],y=s[12],m=s[13],x=s[14],w=1/(e*h+i*d+n*v+s[15]);return this.x=(e*r+i*l+n*f+y)*w,this.y=(e*o+i*u+n*p+m)*w,this.z=(e*a+i*c+n*g+x)*w,this},unproject:function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,o=this.x-i,a=r-this.y-1-n,h=this.z;return this.x=2*o/s-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,e,i){var n=i(0),s=i(32),r=i(298),o=i(296),a=i(157),h=new n({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=h},function(t,e){t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},function(t,e){t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},function(t,e){t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},function(t,e,i){var n=i(147),s=i(0),r=i(3),o=i(83),a=new s({initialize:function(t){this.parent=t,this.list=[],this.position=0,this.addCallback=r,this.removeCallback=r,this._sortKey=""},add:function(t,e){return e?n.Add(this.list,t):n.Add(this.list,t,0,this.addCallback,this)},addAt:function(t,e,i){return i?n.AddAt(this.list,t,e):n.AddAt(this.list,t,e,0,this.addCallback,this)},getAt:function(t){return this.list[t]},getIndex:function(t){return this.list.indexOf(t)},sort:function(t){return t&&(this._sortKey=t,o.inplace(this.list,this.sortHandler)),this},sortHandler:function(t,e){return t[this._sortKey]-e[this._sortKey]},getByName:function(t){return n.GetFirst(this.list,"name",t)},getRandom:function(t,e){return n.GetRandom(this.list,t,e)},getFirst:function(t,e,i,s){return n.GetFirstElement(this.list,t,e,i,s)},getAll:function(t,e,i,s){return n.GetAll(this.list,t,e,i,s)},count:function(t,e){return n.CountAllMatching(this.list,t,e)},swap:function(t,e){n.Swap(this.list,t,e)},moveTo:function(t,e){return n.MoveTo(this.list,t,e)},remove:function(t,e){return e?n.Remove(this.list,t):n.Remove(this.list,t,this.removeCallback,this)},removeAt:function(t,e){return e?n.RemoveAt(this.list,t):n.RemoveAt(this.list,t,this.removeCallback,this)},removeBetween:function(t,e,i){return i?n.RemoveBetween(this.list,t,e):n.RemoveBetween(this.list,t,e,this.removeCallback,this)},removeAll:function(t){for(var e=this.list.length;e--;)this.remove(this.list[e],t);return this},bringToTop:function(t){return n.BringToTop(this.list,t)},sendToBack:function(t){return n.SendToBack(this.list,t)},moveUp:function(t){return n.MoveUp(this.list,t),t},moveDown:function(t){return n.MoveDown(this.list,t),t},reverse:function(){return this.list.reverse(),this},shuffle:function(){return n.Shuffle(this.list),this},replace:function(t,e){return n.Replace(this.list,t,e)},exists:function(t){return this.list.indexOf(t)>-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){for(var i=[null],n=2;n0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=a},function(t,e,i){var n=i(33);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)||(i[s]=e[s]);return i}},function(t,e){t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},function(t,e,i){var n=i(0),s=i(293),r=i(156),o=i(155),a=i(6),h=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n},getPoint:function(t,e){return s(this,t,e)},getPoints:function(t,e,i){return r(this,t,e,i)},getRandomPoint:function(t){return o(this,t)},setTo:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x1=t,this.y1=e,this.x2=i,this.y2=n,this},getPointA:function(t){return void 0===t&&(t=new a),t.set(this.x1,this.y1),t},getPointB:function(t){return void 0===t&&(t=new a),t.set(this.x2,this.y2),t},left:{get:function(){return Math.min(this.x1,this.x2)},set:function(t){this.x1<=this.x2?this.x1=t:this.x2=t}},right:{get:function(){return Math.max(this.x1,this.x2)},set:function(t){this.x1>this.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=h},function(t,e){t.exports=function(t){return 2*(t.width+t.height)}},function(t,e){t.exports=function(t,e,i,n,s,r,o,a,h,l,u,c,d){return{target:t,key:e,getEndValue:i,getStartValue:n,ease:s,duration:0,totalDuration:0,delay:0,yoyo:a,hold:0,repeat:0,repeatDelay:0,flipX:c,flipY:d,progress:0,elapsed:0,repeatCounter:0,start:0,current:0,end:0,t1:0,t2:0,gen:{delay:r,duration:o,hold:h,repeat:l,repeatDelay:u},state:0}}},function(t,e,i){var n=i(0),s=i(13),r=i(11),o=i(61),a=new n({initialize:function(t,e,i){this.parent=t,this.parentIsTimeline=t.hasOwnProperty("isTimeline"),this.data=e,this.totalData=e.length,this.targets=i,this.totalTargets=i.length,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.offset=0,this.calculatedOffset=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onRepeat:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},getValue:function(){return this.data[0].current},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},isPaused:function(){return this.state===o.PAUSED},hasTarget:function(t){return-1!==this.targets.indexOf(t)},updateTo:function(t,e,i){for(var n=0;n0&&(n.totalDuration+=n.t2*n.repeat),n.totalDuration>t&&(t=n.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},pause:function(){if(this.state!==o.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=o.PAUSED,this},play:function(t){if(this.state!==o.ACTIVE){this.state!==o.PENDING_REMOVE&&this.state!==o.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.ACTIVE):(this.countdown=this.calculatedOffset,this.state=o.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=o.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(n.elapsed=n.delay,n.state=o.DELAY):n.state=o.PENDING_RENDER}},resume:function(){return this.state===o.PAUSED?(this.paused=!1,this.state=this._pausedState):this.play(),this},seek:function(t){for(var e=this.data,i=0;i=s.totalDuration?(r=1,o=s.duration):n>s.delay&&n<=s.t1?(r=(n=Math.max(0,n-s.delay))/s.t1,o=s.duration*r):n>s.t1&&ns.repeatDelay&&(r=n/s.t1,o=s.duration*r)),s.progress=r,s.elapsed=o;var a=s.ease(s.progress);s.current=s.start+(s.end-s.start)*a,s.target[s.key]=s.current}},setCallback:function(t,e,i,n){return this.callbacks[t]={func:e,scope:n,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},stop:function(t){this.state===o.ACTIVE&&void 0!==t&&this.seek(t),this.state!==o.REMOVED&&(this.state=o.PENDING_REMOVE)},update:function(t,e){if(this.state===o.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var i=!1,n=0;n0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case o.PLAYING_FORWARD:case o.PLAYING_BACKWARD:if(!e.target){e.state=o.COMPLETE;break}var n=e.elapsed,s=e.duration,r=0;(n+=i)>s&&(r=n-s,n=s);var a,h=e.state===o.PLAYING_FORWARD,l=n/s;a=h?e.ease(l):e.ease(1-l),e.current=e.start+(e.end-e.start)*a,e.target[e.key]=e.current,e.elapsed=n,e.progress=l;var u=t.callbacks.onUpdate;u&&(u.params[1]=e.target,u.func.apply(u.scope,u.params)),1===l&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=o.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case o.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PENDING_RENDER);break;case o.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PLAYING_FORWARD);break;case o.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case o.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=o.PLAYING_FORWARD):e.state=o.COMPLETE}return e.state!==o.COMPLETE}});a.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),s.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=a},function(t,e){t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1}},function(t,e){function i(t){return!!t.getStart&&"function"==typeof t.getStart}function n(t){return!!t.getEnd&&"function"==typeof t.getEnd}var s=function(t,e){var r,o,a=function(t,e,i){return i},h=function(t,e,i){return i},l=typeof e;if("number"===l)a=function(){return e};else if("string"===l){var u=e[0],c=parseFloat(e.substr(2));switch(u){case"+":a=function(t,e,i){return i+c};break;case"-":a=function(t,e,i){return i-c};break;case"*":a=function(t,e,i){return i*c};break;case"/":a=function(t,e,i){return i/c};break;default:a=function(){return parseFloat(e)}}}else"function"===l?a=e:"object"===l&&(i(o=e)||n(o))?(n(e)&&(a=e.getEnd),i(e)&&(h=e.getStart)):e.hasOwnProperty("value")&&(r=s(t,e.value));return r||(r={getEnd:a,getStart:h}),r};t.exports=s},function(t,e,i){var n=i(4);t.exports=function(t){var e=n(t,"targets",null);return null===e?e:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","map"),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.widthInPixels=s(t,"widthInPixels",this.width*this.tileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.tileHeight),this.format=s(t,"format",null),this.orientation=s(t,"orientation","orthogonal"),this.version=s(t,"version","1"),this.properties=s(t,"properties",{}),this.layers=s(t,"layers",[]),this.images=s(t,"images",[]),this.objects=s(t,"objects",{}),this.collision=s(t,"collision",{}),this.tilesets=s(t,"tilesets",[]),this.imageCollections=s(t,"imageCollections",[]),this.tiles=s(t,"tiles",[])}});t.exports=r},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","layer"),this.x=s(t,"x",0),this.y=s(t,"y",0),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.baseTileWidth=s(t,"baseTileWidth",this.tileWidth),this.baseTileHeight=s(t,"baseTileHeight",this.tileHeight),this.widthInPixels=s(t,"widthInPixels",this.width*this.baseTileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.baseTileHeight),this.alpha=s(t,"alpha",1),this.visible=s(t,"visible",!0),this.properties=s(t,"properties",{}),this.indexes=s(t,"indexes",[]),this.collideIndexes=s(t,"collideIndexes",[]),this.callbacks=s(t,"callbacks",[]),this.bodies=s(t,"bodies",[]),this.data=s(t,"data",[]),this.tilemapLayer=s(t,"tilemapLayer",null)}});t.exports=r},function(t,e){t.exports=function(t,e,i){return t>=0&&t=0&&el){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var v=d.substr(g.length);u[c]=v,h+=g}var y=u[c].length?c:c+1,m=u.slice(y).join(" ").replace(/[ \n]*$/gi,"");s[o+1]=m+" "+(s[o+1]||""),r=s.length;break}h+=f,l-=p}n+=h.replace(/[ \n]*$/gi,"")+"\n"}}return n=n.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var n="",s=t.split(this.splitRegExp),r=0;ro?(h>0&&(n+="\n"),n+=a[h]+" ",o=i-l):(o-=u,n+=a[h],h0&&(a+=u.lineSpacing*p),i.rtl?o=d-o:"right"===i.align?o+=u.width-u.lineWidths[p]:"center"===i.align&&(o+=(u.width-u.lineWidths[p])/2),this.autoRound&&(o=Math.round(o),a=Math.round(a)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],o,a)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],o,a));return e.restore(),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this.text,style:this.style.toJSON(),resolution:this.resolution,padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),s.remove(this.canvas)}});t.exports=p},function(t,e){t.exports=function(t,e){return t.hasOwnProperty(e)}},function(t,e,i){var n=i(599),s=i(0),r=i(1),o=i(4),a=i(254),h=i(70),l=i(34),u=new s({initialize:function(t,e,i){void 0!==i||Array.isArray(e)||"object"!=typeof e||(i=e,e=null),this.scene=t,this.children=new h(e),this.isParent=!0,this.classType=r(i,"classType",l),this.active=r(i,"active",!0),this.maxSize=r(i,"maxSize",-1),this.defaultKey=r(i,"defaultKey",null),this.defaultFrame=r(i,"defaultFrame",null),this.runChildUpdate=r(i,"runChildUpdate",!1),this.createCallback=r(i,"createCallback",null),this.removeCallback=r(i,"removeCallback",null),this.createMultipleCallback=r(i,"createMultipleCallback",null),i&&this.createMultiple(i)},create:function(t,e,i,n,s,r){if(void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.defaultKey),void 0===n&&(n=this.defaultFrame),void 0===s&&(s=!0),void 0===r&&(r=!0),this.isFull())return null;var o=new this.classType(this.scene,t,e,i,n);return this.scene.sys.displayList.add(o),o.preUpdate&&this.scene.sys.updateList.add(o),o.visible=s,o.setActive(r),this.add(o),o},createMultiple:function(t){if(this.isFull())return[];if(Array.isArray(t)||(t=[t]),void 0===t[0].key)return[];for(var e=[],i=0;i=0;u--)if((l=d[u]).active===i){if(++c===e)break}else l=null;return l?("number"==typeof s&&(l.x=s),"number"==typeof r&&(l.y=r),l):n?this.create(s,r,o,a,h):null},get:function(t,e,i,n,s){return this.getFirst(!1,!0,t,e,i,n,s)},getFirstAlive:function(t,e,i,n,s,r){return this.getFirst(!0,t,e,i,n,s,r)},getFirstDead:function(t,e,i,n,s,r){return this.getFirst(!1,t,e,i,n,s,r)},playAnimation:function(t,e){return n.PlayAnimation(this.children.entries,t,e),this},isFull:function(){return-1!==this.maxSize&&this.children.size>=this.maxSize},countActive:function(t){void 0===t&&(t=!0);for(var e=0,i=0;i-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var n,s,r=this.scene.sys;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),d.TargetCamera.setViewport(0,0,e,i),d.TargetCamera.scrollX=this.x,d.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var o=(n=r.textures.get(t)).getSourceImage();o instanceof HTMLCanvasElement&&(s=o.getContext("2d"))}else s=(n=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(s=t.getContext("2d"));return s&&(this.renderCanvas(r.game.renderer,this,0,d.TargetCamera,null,s),r.game.renderer.gl&&n&&(n.source[0].glTexture=r.game.renderer.canvasToTexture(s.canvas,n.source[0].glTexture))),this},preDestroy:function(){this.commandBuffer=[]}});d.TargetCamera=new n(0,0,0,0),t.exports=d},function(t,e){t.exports=function(t){if(!Array.isArray(t)||t.length<2||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i0},isTransitionIn:function(){return this.settings.isTransition},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t){return t?this.resume():this.pause()},start:function(t){t&&(this.settings.data=t),this.settings.status=s.START,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this),this.events.emit("ready",this)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(){this.events.off("transitioninit"),this.events.off("transitionstart"),this.events.off("transitioncomplete"),this.events.off("transitionout"),this.settings.status=s.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this)},destroy:function(){this.settings.status=s.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this),this.events.removeAllListeners();for(var t=["scene","game","anims","cache","plugins","registry","sound","textures","add","camera","displayList","events","make","scenePlugin","updateList"],e=0;e-y&&T>-m&&b-y&&A>-m&&Sc&&(this.scrollX=c),this.scrollYd&&(this.scrollY=d)}this.roundPixels&&(this.scrollX=Math.round(this.scrollX),this.scrollY=Math.round(this.scrollY)),r.loadIdentity(),r.scale(e,e),r.translate(this.x+o,this.y+a),r.rotate(this.rotation),r.scale(s,s),r.translate(-o,-a),this.shakeEffect.preRender()},removeBounds:function(){return this.useBounds=!1,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=r(t),this},setLerp:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.lerp.set(t,e),this},setFollowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.followOffset.set(t,e),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=c(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,n){return this._bounds.setTo(t,e,i,n),this.useBounds=!0,this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){return this.scene=t,this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setZoom:function(t){return void 0===t&&(t=1),this.zoom=t,this},setVisible:function(t){return this.visible=t,this},startFollow:function(t,e,i,s,r,o){void 0===e&&(e=!1),void 0===i&&(i=1),void 0===s&&(s=i),void 0===r&&(r=0),void 0===o&&(o=r),this._follow=t,this.roundPixels=e,i=n(i,0,1),s=n(s,0,1),this.lerp.set(i,s),this.followOffset.set(r,o);var a=this.zoom,h=this.width/2,l=this.height/2;return this.scrollX=(t.x-r-h)/a,this.scrollY=(t.y-o-l)/a,this},stopFollow:function(){return this._follow=null,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},resetFX:function(){return this.shakeEffect.reset(),this.flashEffect.reset(),this.fadeEffect.reset(),this},update:function(t,e){this.visible&&(this.shakeEffect.update(t,e),this.flashEffect.update(t,e),this.fadeEffect.update(t,e))},destroy:function(){this.emit("cameradestroy",this),this.removeAllListeners(),this.resetFX(),this.matrix.destroy(),this.culledObjects=[],this._follow=null,this._bounds=null,this.scene=null},centerX:{get:function(){return this.x+.5*this.width}},centerY:{get:function(){return this.y+.5*this.height}}});t.exports=f},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;et.max.x&&(t.max.x=s.x),s.xt.max.y&&(t.max.y=s.y),s.y0?t.max.x+=i.x:t.min.x+=i.x,i.y>0?t.max.y+=i.y:t.min.y+=i.y)},i.contains=function(t,e){return e.x>=t.min.x&&e.x<=t.max.x&&e.y>=t.min.y&&e.y<=t.max.y},i.overlaps=function(t,e){return t.min.x<=e.max.x&&t.max.x>=e.min.x&&t.max.y>=e.min.y&&t.min.y<=e.max.y},i.translate=function(t,e){t.min.x+=e.x,t.max.x+=e.x,t.min.y+=e.y,t.max.y+=e.y},i.shift=function(t,e){var i=t.max.x-t.min.x,n=t.max.y-t.min.y;t.min.x=e.x,t.max.x=e.x+i,t.min.y=e.y,t.max.y=e.y+n}},function(t,e,i){var n={};t.exports=n;var s=i(106),r=i(41);n.create=function(t,e){for(var i=[],n=0;n0)return!1}return!0},n.scale=function(t,e,i,r){if(1===e&&1===i)return t;var o,a;r=r||n.centre(t);for(var h=0;h=0?h-1:t.length-1],u=t[h],c=t[(h+1)%t.length],d=e[h0&&(r|=2),3===r)return!1;return 0!==r||null},n.hull=function(t){var e,i,n=[],r=[];for((t=t.slice(0)).sort(function(t,e){var i=t.x-e.x;return 0!==i?i:t.y-e.y}),i=0;i=2&&s.cross3(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(i=t.length-1;i>=0;i-=1){for(e=t[i];n.length>=2&&s.cross3(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}return n.pop(),r.pop(),n.concat(r)}},function(t,e,i){var n=i(10);t.exports=function(t,e){var i=n(e,"anims",null);if(null===i)return t;if("string"==typeof i)t.anims.play(i);else if("object"==typeof i){var s=t.anims,r=n(i,"key",void 0),o=n(i,"startFrame",void 0),a=n(i,"delay",0),h=n(i,"repeat",0),l=n(i,"repeatDelay",0),u=n(i,"yoyo",!1),c=n(i,"play",!1),d=n(i,"delayedPlay",0);s.delay(a),s.repeat(h),s.repeatDelay(l),s.yoyo(u),c?s.play(r,o):d>0?s.delayedPlay(d,r,o):s.load(r)}return t}},function(t,e,i){var n=i(0),s=i(17),r=new n({initialize:function(t,e,i,n,s,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.cutX,this.cutY,this.cutWidth,this.cutHeight,this.x=0,this.y=0,this.width,this.height,this.halfWidth,this.halfHeight,this.centerX,this.centerY,this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.data={cut:{x:0,y:0,w:0,h:0,r:0,b:0},trim:!1,sourceSize:{w:0,h:0},spriteSourceSize:{x:0,y:0,w:0,h:0},uvs:{x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},radius:0,drawImage:{sx:0,sy:0,sWidth:0,sHeight:0,dWidth:0,dHeight:0}},this.setSize(r,o,n,s)},setSize:function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this.cutX=i,this.cutY=n,this.cutWidth=t,this.cutHeight=e,this.width=t,this.height=e,this.halfWidth=Math.floor(.5*t),this.halfHeight=Math.floor(.5*e),this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2);var s=this.data,r=s.cut;r.x=i,r.y=n,r.w=t,r.h=e,r.r=i+t,r.b=n+e,s.sourceSize.w=t,s.sourceSize.h=e,s.spriteSourceSize.w=t,s.spriteSourceSize.h=e,s.radius=.5*Math.sqrt(t*t+e*e);var o=s.drawImage;return o.sx=i,o.sy=n,o.sWidth=t,o.sHeight=e,o.dWidth=t,o.dHeight=e,this.updateUVs()},setTrim:function(t,e,i,n,s,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=n,a.w=s,a.h=r,this.x=i,this.y=n,this.width=s,this.height=r,this.halfWidth=.5*s,this.halfHeight=.5*r,this.centerX=Math.floor(s/2),this.centerY=Math.floor(r/2),this.updateUVs()},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,n=this.cutHeight,s=this.data.drawImage;s.sWidth=i,s.sHeight=n,s.dWidth=i,s.dHeight=n;var r=this.source.width,o=this.source.height,a=this.data.uvs;return a.x0=t/r,a.y0=e/o,a.x1=t/r,a.y1=(e+n)/o,a.x2=(t+i)/r,a.y2=(e+n)/o,a.x3=(t+i)/r,a.y3=e/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height,i=this.data.uvs;return i.x3=(this.cutX+this.cutHeight)/t,i.y3=(this.cutY+this.cutWidth)/e,i.x2=this.cutX/t,i.y2=(this.cutY+this.cutWidth)/e,i.x1=this.cutX/t,i.y1=this.cutY/e,i.x0=(this.cutX+this.cutHeight)/t,i.y0=this.cutY/e,this},clone:function(){var t=new r(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=s(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},uvs:{get:function(){return this.data.uvs}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=r},function(t,e,i){var n=i(0),s=i(202),r=i(526),o=i(525),a=i(27),h=i(84),l=new n({Extends:h,Mixins:[s],initialize:function(t){h.call(this,{game:t.game,renderer:t.renderer,gl:t.renderer.gl,topology:t.topology?t.topology:t.renderer.gl.TRIANGLES,vertShader:t.vertShader?t.vertShader:o,fragShader:t.fragShader?t.fragShader:r,vertexCapacity:t.vertexCapacity?t.vertexCapacity:12e3,vertexSize:t.vertexSize?t.vertexSize:2*Float32Array.BYTES_PER_ELEMENT+2*Float32Array.BYTES_PER_ELEMENT+4*Uint8Array.BYTES_PER_ELEMENT,attributes:[{name:"inPosition",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:0},{name:"inTexCoord",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:2*Float32Array.BYTES_PER_ELEMENT},{name:"inTint",size:4,type:t.renderer.gl.UNSIGNED_BYTE,normalized:!0,offset:4*Float32Array.BYTES_PER_ELEMENT}]}),this.vertexViewF32=new Float32Array(this.vertexData),this.vertexViewU32=new Uint32Array(this.vertexData),this.maxQuads=2e3,this.batches=[],this.mvpInit()},setTexture2D:function(t,e){if(!t)return this;var i=this.batches;0===i.length&&this.pushBatch();var n=i[i.length-1];return e>0?(n.textures[e-1]&&n.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==n.texture&&n.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,n=this.gl,s=this.renderer,r=this.vertexCount,o=this.topology,a=this.vertexSize,h=this.batches,l=0,u=null;if(0===h.length||0===r)return this.flushLocked=!1,this;n.bufferSubData(n.ARRAY_BUFFER,0,this.bytes.subarray(0,r*a));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(s.setTexture2D(u.texture,0),n.drawArrays(o,u.first,l)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},onBind:function(){return h.prototype.onBind.call(this),this.mvpUpdate(),0===this.batches.length&&this.pushBatch(),this},resize:function(t,e,i){return h.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},drawStaticTilemapLayer:function(t){if(t.vertexCount>0){var e=this.vertexBuffer,i=this.gl,n=this.renderer,s=t.tileset.image.get();n.currentPipeline&&n.currentPipeline.vertexCount>0&&n.flush(),this.vertexBuffer=t.vertexBuffer,n.setPipeline(this),n.setTexture2D(s.source.glTexture,0),i.drawArrays(this.topology,0,t.vertexCount),this.vertexBuffer=e}this.viewIdentity(),this.modelIdentity()},drawEmitterManager:function(t,e,i){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this);var s,r,o,a,h,l,u,c,d,f,p=this.renderer.config.roundPixels,g=t.emitters.list,v=g.length,y=this.vertexViewF32,m=this.vertexViewU32,x=this.renderer,w=this.maxQuads,b=e.scrollX,T=e.scrollY,S=e.matrix.matrix,A=S[0],C=S[1],M=S[2],_=S[3],E=S[4],P=S[5],k=Math.sin,L=Math.cos,F=this.vertexComponentCount,R=this.vertexCapacity,O=t.defaultFrame.source.glTexture;n&&(h=n[0],l=n[1],u=n[2],c=n[3],d=n[4],f=n[5]),this.setTexture2D(O,0);for(var B=0;B=R&&(this.flush(),this.setTexture2D(O,0));for(var W=0;W=R&&(this.flush(),this.setTexture2D(O,0))}}X+=H,z-=H,this.vertexCount>=R&&(this.flush(),this.setTexture2D(O,0))}}}this.setTexture2D(O,0)},drawBlitter:function(t,e,i){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this);var s=this.renderer.config.roundPixels,r=a.getTintAppendFloatAlpha,o=this.vertexViewF32,h=this.vertexViewU32,l=t.getRenderList(),u=l.length,c=e.matrix.matrix,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=e.scrollX*t.scrollFactorX,x=e.scrollY*t.scrollFactorY,w=Math.ceil(u/this.maxQuads),b=0;if(n){var T=n[0],S=n[1],A=n[2],C=n[3],M=n[4],_=n[5],E=-m,P=-x,k=A*d+C*p,L=A*f+C*g,F=M*d+_*p+(E*d+P*p+v),R=M*f+_*g+(E*f+P*g+y);d=T*d+S*p,f=T*f+S*g,p=k,g=L,v=F,y=R,m=0,x=0}for(var O,B=t.x-m,D=t.y-x,I=0;I=this.vertexCapacity&&(this.flush(),O=-1)}}b+=z,u-=z,this.vertexCount>=this.vertexCapacity&&this.flush()}},batchSprite:function(t,e,i){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var s,r,o,h,l,u,c=this.renderer.config.roundPixels,d=a.getTintAppendFloatAlpha,f=this.vertexViewF32,p=this.vertexViewU32,g=e.matrix.matrix,v=t.frame,y=v.texture.source[v.sourceIndex].glTexture,m=!!y.isRenderTexture,x=t.flipX,w=t.flipY^m,b=v.uvs,T=v.width*(x?-1:1),S=v.height*(w?-1:1),A=-t.displayOriginX+v.x+v.width*(x?1:0),C=-t.displayOriginY+v.y+v.height*(w?1:0),M=(c?0|A:A)+T,_=(c?0|C:C)+S,E=t.scaleX,P=t.scaleY,k=t.rotation,L=t._alphaTL,F=t._alphaTR,R=t._alphaBL,O=t._alphaBR,B=t._tintTL,D=t._tintTR,I=t._tintBL,z=t._tintBR,Y=Math.sin(k),X=Math.cos(k),N=X*E,V=Y*E,U=-Y*P,G=X*P,W=t.x,H=t.y,j=g[0],q=g[1],K=g[2],J=g[3],Z=g[4],Q=g[5];if(n){var $=n[0],tt=n[1],et=n[2],it=n[3],nt=n[4],st=n[5],rt=-e.scrollX*t.scrollFactorX,ot=-e.scrollY*t.scrollFactorY,at=$*j+tt*K,ht=$*q+tt*J,lt=et*j+it*K,ut=et*q+it*J;s=N*at+V*lt,r=N*ht+V*ut,o=U*at+G*lt,h=U*ht+G*ut,l=W*at+H*lt+(nt*j+st*K+(rt*j+ot*K+Z)),u=W*ht+H*ut+(nt*q+st*J+(rt*q+ot*J+Q))}else s=N*j+V*K,r=N*q+V*J,o=U*j+G*K,h=U*q+G*J,l=(W-=e.scrollX*t.scrollFactorX)*j+(H-=e.scrollY*t.scrollFactorY)*K+Z,u=W*q+H*J+Q;var ct,dt=A*s+C*o+l,ft=A*r+C*h+u,pt=A*s+_*o+l,gt=A*r+_*h+u,vt=M*s+_*o+l,yt=M*r+_*h+u,mt=M*s+C*o+l,xt=M*r+C*h+u,wt=d(B,L),bt=d(D,F),Tt=d(I,R),St=d(z,O);c&&(dt|=0,ft|=0,pt|=0,gt|=0,vt|=0,yt|=0,mt|=0,xt|=0),this.setTexture2D(y,0),f[(ct=this.vertexCount*this.vertexComponentCount)+0]=dt,f[ct+1]=ft,f[ct+2]=b.x0,f[ct+3]=b.y0,p[ct+4]=wt,f[ct+5]=pt,f[ct+6]=gt,f[ct+7]=b.x1,f[ct+8]=b.y1,p[ct+9]=Tt,f[ct+10]=vt,f[ct+11]=yt,f[ct+12]=b.x2,f[ct+13]=b.y2,p[ct+14]=St,f[ct+15]=dt,f[ct+16]=ft,f[ct+17]=b.x0,f[ct+18]=b.y0,p[ct+19]=wt,f[ct+20]=vt,f[ct+21]=yt,f[ct+22]=b.x2,f[ct+23]=b.y2,p[ct+24]=St,f[ct+25]=mt,f[ct+26]=xt,f[ct+27]=b.x3,f[ct+28]=b.y3,p[ct+29]=bt,this.vertexCount+=6},batchMesh:function(t,e,i){var n=null;i&&(n=i.matrix);var s=t.vertices,r=s.length,o=r/2|0;this.renderer.setPipeline(this),this.vertexCount+o>this.vertexCapacity&&this.flush();var h,l,u,c,d,f,p=this.renderer.config.roundPixels,g=a.getTintAppendFloatAlpha,v=t.uv,y=t.colors,m=t.alphas,x=this.vertexViewF32,w=this.vertexViewU32,b=e.matrix.matrix,T=t.frame,S=t.texture.source[T.sourceIndex].glTexture,A=t.x,C=t.y,M=t.scaleX,_=t.scaleY,E=t.rotation,P=Math.sin(E),k=Math.cos(E),L=k*M,F=P*M,R=-P*_,O=k*_,B=A,D=C,I=b[0],z=b[1],Y=b[2],X=b[3],N=b[4],V=b[5],U=0;if(n){var G=n[0],W=n[1],H=n[2],j=n[3],q=n[4],K=n[5],J=-e.scrollX*t.scrollFactorX,Z=-e.scrollY*t.scrollFactorY,Q=G*I+W*Y,$=G*z+W*X,tt=H*I+j*Y,et=H*z+j*X;h=L*Q+F*tt,l=L*$+F*et,u=R*Q+O*tt,c=R*$+O*et,d=B*Q+D*tt+(q*I+K*Y+(J*I+Z*Y+N)),f=B*$+D*et+(q*z+K*X+(J*z+Z*X+V))}else h=L*I+F*Y,l=L*z+F*X,u=R*I+O*Y,c=R*z+O*X,d=(B-=e.scrollX*t.scrollFactorX)*I+(D-=e.scrollY*t.scrollFactorY)*Y+N,f=B*z+D*X+V;this.setTexture2D(S,0),U=this.vertexCount*this.vertexComponentCount;for(var it=0,nt=0;itthis.vertexCapacity&&this.flush();var s,r,o,h,l,u,c,d,f,p,g,v,y,m,x=this.renderer.config.roundPixels,w=t.text,b=w.length,T=a.getTintAppendFloatAlpha,S=this.vertexViewF32,A=this.vertexViewU32,C=e.matrix.matrix,M=e.width+50,_=e.height+50,E=t.frame,P=t.texture.source[E.sourceIndex],k=e.scrollX*t.scrollFactorX,L=e.scrollY*t.scrollFactorY,F=t.fontData,R=F.lineHeight,O=t.fontSize/F.size,B=F.chars,D=t.alpha,I=T(t._tintTL,D),z=T(t._tintTR,D),Y=T(t._tintBL,D),X=T(t._tintBR,D),N=t.x,V=t.y,U=E.cutX,G=E.cutY,W=P.width,H=P.height,j=P.glTexture,q=0,K=0,J=0,Z=0,Q=null,$=0,tt=0,et=0,it=0,nt=0,st=0,rt=0,ot=0,at=0,ht=0,lt=0,ut=0,ct=null,dt=0,ft=N+E.x,pt=V+E.y,gt=t.rotation,vt=t.scaleX,yt=t.scaleY,mt=t.letterSpacing,xt=Math.sin(gt),wt=Math.cos(gt),bt=wt*vt,Tt=xt*vt,St=-xt*yt,At=wt*yt,Ct=ft,Mt=pt,_t=C[0],Et=C[1],Pt=C[2],kt=C[3],Lt=C[4],Ft=C[5],Rt=0;if(n){var Ot=n[0],Bt=n[1],Dt=n[2],It=n[3],zt=n[4],Yt=n[5],Xt=-k,Nt=-L,Vt=Ot*_t+Bt*Pt,Ut=Ot*Et+Bt*kt,Gt=Dt*_t+It*Pt,Wt=Dt*Et+It*kt;f=bt*Vt+Tt*Gt,p=bt*Ut+Tt*Wt,g=St*Vt+At*Gt,v=St*Ut+At*Wt,y=Ct*Vt+Mt*Gt+(zt*_t+Yt*Pt+(Xt*_t+Nt*Pt+Lt)),m=Ct*Ut+Mt*Wt+(zt*Et+Yt*kt+(Xt*Et+Nt*kt+Ft))}else f=bt*_t+Tt*Pt,p=bt*Et+Tt*kt,g=St*_t+At*Pt,v=St*Et+At*kt,y=(Ct-=k)*_t+(Mt-=L)*Pt+Lt,m=Ct*Et+Mt*kt+Ft;this.setTexture2D(j,0);for(var Ht=0;HtM||r<-50||r>_)&&(o<-50||o>M||h<-50||h>_)&&(l<-50||l>M||u<-50||u>_)&&(c<-50||c>M||d<-50||d>_)||(this.vertexCount+6>this.vertexCapacity&&this.flush(),Rt=this.vertexCount*this.vertexComponentCount,x&&(s|=0,r|=0,o|=0,h|=0,l|=0,u|=0,c|=0,d|=0),S[Rt+0]=s,S[Rt+1]=r,S[Rt+2]=at,S[Rt+3]=lt,A[Rt+4]=I,S[Rt+5]=o,S[Rt+6]=h,S[Rt+7]=at,S[Rt+8]=ut,A[Rt+9]=Y,S[Rt+10]=l,S[Rt+11]=u,S[Rt+12]=ht,S[Rt+13]=ut,A[Rt+14]=X,S[Rt+15]=s,S[Rt+16]=r,S[Rt+17]=at,S[Rt+18]=lt,A[Rt+19]=I,S[Rt+20]=l,S[Rt+21]=u,S[Rt+22]=ht,S[Rt+23]=ut,A[Rt+24]=X,S[Rt+25]=c,S[Rt+26]=d,S[Rt+27]=ht,S[Rt+28]=lt,A[Rt+29]=z,this.vertexCount+=6))}}else q=0,J=0,K+=R,ct=null},batchDynamicBitmapText:function(t,e,i){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var s,r,o,h,l,u,c,d,f,p,g,v,y,m,x,w,b,T,S,A,C=this.renderer.config.roundPixels,M=t.displayCallback,_=t.text,E=_.length,P=a.getTintAppendFloatAlpha,k=this.vertexViewF32,L=this.vertexViewU32,F=this.renderer,R=e.matrix.matrix,O=t.frame,B=t.texture.source[O.sourceIndex],D=e.scrollX*t.scrollFactorX,I=e.scrollY*t.scrollFactorY,z=t.scrollX,Y=t.scrollY,X=t.fontData,N=X.lineHeight,V=t.fontSize/X.size,U=X.chars,G=t.alpha,W=P(t._tintTL,G),H=P(t._tintTR,G),j=P(t._tintBL,G),q=P(t._tintBR,G),K=t.x,J=t.y,Z=O.cutX,Q=O.cutY,$=B.width,tt=B.height,et=B.glTexture,it=0,nt=0,st=0,rt=0,ot=null,at=0,ht=0,lt=0,ut=0,ct=0,dt=0,ft=0,pt=0,gt=0,vt=0,yt=0,mt=0,xt=null,wt=0,bt=K+O.x,Tt=J+O.y,St=t.rotation,At=t.scaleX,Ct=t.scaleY,Mt=t.letterSpacing,_t=Math.sin(St),Et=Math.cos(St),Pt=Et*At,kt=_t*At,Lt=-_t*Ct,Ft=Et*Ct,Rt=bt,Ot=Tt,Bt=R[0],Dt=R[1],It=R[2],zt=R[3],Yt=R[4],Xt=R[5],Nt=t.cropWidth>0||t.cropHeight>0,Vt=0;if(n){var Ut=n[0],Gt=n[1],Wt=n[2],Ht=n[3],jt=n[4],qt=n[5],Kt=-D,Jt=-I,Zt=Ut*Bt+Gt*It,Qt=Ut*Dt+Gt*zt,$t=Wt*Bt+Ht*It,te=Wt*Dt+Ht*zt;x=Pt*Zt+kt*$t,w=Pt*Qt+kt*te,b=Lt*Zt+Ft*$t,T=Lt*Qt+Ft*te,S=Rt*Zt+Ot*$t+(jt*Bt+qt*It+(Kt*Bt+Jt*It+Yt)),A=Rt*Qt+Ot*te+(jt*Dt+qt*zt+(Kt*Dt+Jt*zt+Xt))}else x=Pt*Bt+kt*It,w=Pt*Dt+kt*zt,b=Lt*Bt+Ft*It,T=Lt*Dt+Ft*zt,S=(Rt-=D)*Bt+(Ot-=I)*It+Yt,A=Rt*Dt+Ot*zt+Xt;this.setTexture2D(et,0),Nt&&F.pushScissor(t.x,t.y,t.cropWidth*t.scaleX,t.cropHeight*t.scaleY);for(var ee=0;eethis.vertexCapacity&&this.flush(),Vt=this.vertexCount*this.vertexComponentCount,C&&(s|=0,r|=0,o|=0,h|=0,l|=0,u|=0,c|=0,d|=0),k[Vt+0]=s,k[Vt+1]=r,k[Vt+2]=gt,k[Vt+3]=yt,L[Vt+4]=W,k[Vt+5]=o,k[Vt+6]=h,k[Vt+7]=gt,k[Vt+8]=mt,L[Vt+9]=j,k[Vt+10]=l,k[Vt+11]=u,k[Vt+12]=vt,k[Vt+13]=mt,L[Vt+14]=q,k[Vt+15]=s,k[Vt+16]=r,k[Vt+17]=gt,k[Vt+18]=yt,L[Vt+19]=W,k[Vt+20]=l,k[Vt+21]=u,k[Vt+22]=vt,k[Vt+23]=mt,L[Vt+24]=q,k[Vt+25]=c,k[Vt+26]=d,k[Vt+27]=vt,k[Vt+28]=yt,L[Vt+29]=H,this.vertexCount+=6}}}else it=0,st=0,nt+=N,xt=null;Nt&&F.popScissor()},batchText:function(t,e,i){var n=a.getTintAppendFloatAlpha;this.batchTexture(t,t.canvasTexture,t.canvasTexture.width,t.canvasTexture.height,t.x,t.y,t.canvasTexture.width,t.canvasTexture.height,t.scaleX,t.scaleY,t.rotation,t.flipX,t.flipY,t.scrollFactorX,t.scrollFactorY,t.displayOriginX,t.displayOriginY,0,0,t.canvasTexture.width,t.canvasTexture.height,n(t._tintTL,t._alphaTL),n(t._tintTR,t._alphaTR),n(t._tintBL,t._alphaBL),n(t._tintBR,t._alphaBR),0,0,e,i)},batchDynamicTilemapLayer:function(t,e,i){for(var n=t.culledTiles,s=n.length,r=t.tileset.image.get().source.glTexture,o=t.tileset,h=t.scrollFactorX,l=t.scrollFactorY,u=t.alpha,c=t.x,d=t.y,f=t.scaleX,p=t.scaleY,g=a.getTintAppendFloatAlpha,v=0;vthis.vertexCapacity&&this.flush(),d^=e.isRenderTexture?1:0;var k,L,F,R,O,B,D=this.renderer.config.roundPixels,I=this.vertexViewF32,z=this.vertexViewU32,Y=_.matrix.matrix,X=o*(c?1:0)-g,N=a*(d?1:0)-v,V=X+o*(c?-1:1),U=N+a*(d?-1:1),G=s,W=r,H=Math.sin(u),j=Math.cos(u),q=j*h,K=H*h,J=-H*l,Z=j*l,Q=G,$=W,tt=Y[0],et=Y[1],it=Y[2],nt=Y[3],st=Y[4],rt=Y[5];if(P){var ot=P[0],at=P[1],ht=P[2],lt=P[3],ut=P[4],ct=P[5],dt=-_.scrollX*f,ft=-_.scrollY*p,pt=ot*tt+at*it,gt=ot*et+at*nt,vt=ht*tt+lt*it,yt=ht*et+lt*nt;k=q*pt+K*vt,L=q*gt+K*yt,F=J*pt+Z*vt,R=J*gt+Z*yt,O=Q*pt+$*vt+(ut*tt+ct*it+(dt*tt+ft*it+st)),B=Q*gt+$*yt+(ut*et+ct*nt+(dt*et+ft*nt+rt))}else k=q*tt+K*it,L=q*et+K*nt,F=J*tt+Z*it,R=J*et+Z*nt,O=(Q-=_.scrollX*f)*tt+($-=_.scrollY*p)*it+st,B=Q*et+$*nt+rt;var mt,xt=X*k+N*F+O,wt=X*L+N*R+B,bt=X*k+U*F+O,Tt=X*L+U*R+B,St=V*k+U*F+O,At=V*L+U*R+B,Ct=V*k+N*F+O,Mt=V*L+N*R+B,_t=y/i+C,Et=m/n+M,Pt=(y+x)/i+C,kt=(m+w)/n+M;this.setTexture2D(e,0),mt=this.vertexCount*this.vertexComponentCount,D&&(xt|=0,wt|=0,bt|=0,Tt|=0,St|=0,At|=0,Ct|=0,Mt|=0),I[mt+0]=xt,I[mt+1]=wt,I[mt+2]=_t,I[mt+3]=Et,z[mt+4]=b,I[mt+5]=bt,I[mt+6]=Tt,I[mt+7]=_t,I[mt+8]=kt,z[mt+9]=T,I[mt+10]=St,I[mt+11]=At,I[mt+12]=Pt,I[mt+13]=kt,z[mt+14]=S,I[mt+15]=xt,I[mt+16]=wt,I[mt+17]=_t,I[mt+18]=Et,z[mt+19]=b,I[mt+20]=St,I[mt+21]=At,I[mt+22]=Pt,I[mt+23]=kt,z[mt+24]=S,I[mt+25]=Ct,I[mt+26]=Mt,I[mt+27]=Pt,I[mt+28]=Et,z[mt+29]=A,this.vertexCount+=6},drawTexture:function(t,e,i,n,s,r,o,h,l,u,c){var d=null;c&&(d=c.matrix),this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var f=this.renderer.config.roundPixels,p=this.vertexViewF32,g=this.vertexViewU32,v=e,y=i,m=v+h,x=y+l,w=u[0],b=u[1],T=u[2],S=u[3],A=u[4],C=u[5];if(d){var M=d[0],_=d[1],E=d[2],P=d[3],k=d[4],L=w*_+b*P,F=T*_+S*P,R=A*_+C*P+d[5];w=w*M+b*E,b=L,T=T*M+S*E,S=F,A=A*M+C*E+k,C=R}var O,B=v*w+y*T+A,D=v*b+y*S+C,I=v*w+x*T+A,z=v*b+x*S+C,Y=m*w+x*T+A,X=m*b+x*S+C,N=m*w+y*T+A,V=m*b+y*S+C,U=t.width,G=t.height,W=r/U,H=o/G,j=(r+h)/U,q=(o+l)/G;n=a.getTintAppendFloatAlpha(n,s),this.setTexture2D(t,0),O=this.vertexCount*this.vertexComponentCount,f&&(B|=0,D|=0,I|=0,z|=0,Y|=0,X|=0,N|=0,V|=0),p[O+0]=B,p[O+1]=D,p[O+2]=W,p[O+3]=H,g[O+4]=n,p[O+5]=I,p[O+6]=z,p[O+7]=W,p[O+8]=q,g[O+9]=n,p[O+10]=Y,p[O+11]=X,p[O+12]=j,p[O+13]=q,g[O+14]=n,p[O+15]=B,p[O+16]=D,p[O+17]=W,p[O+18]=H,g[O+19]=n,p[O+20]=Y,p[O+21]=X,p[O+22]=j,p[O+23]=q,g[O+24]=n,p[O+25]=N,p[O+26]=V,p[O+27]=j,p[O+28]=H,g[O+29]=n,this.vertexCount+=6,this.flush()},batchGraphics:function(){}});t.exports=l},function(t,e){t.exports=function(t,e,i){var n;if(void 0===i&&(i=!0),e)"string"==typeof e?n=document.getElementById(e):"object"==typeof e&&1===e.nodeType&&(n=e);else if(t.parentElement)return t;return n||(n=document.body),i&&n.style&&(n.style.overflow="hidden"),n.appendChild(t),t}},function(t,e){var i,n="";t.exports={disable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!1),t},enable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!0),t},getPrefix:i=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i=(t=t.toString()).length)switch(n){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((s=e-t.length)/2);t=new Array(s-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var n=i(5);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return e.x=t.x+s*Math.cos(i)*t.width/2,e.y=t.y+s*Math.sin(i)*t.height/2,e}},function(t,e,i){var n=i(97),s=i(5);t.exports=function(t,e,i){if(void 0===i&&(i=new s),e<=0||e>=1)return i.x=t.x,i.y=t.y,i;var r=n(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var n=i(5);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o,a){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),void 0===o&&(o={}),void 0===a&&(a={}),this.name=t,this.firstgid=e,this.tileWidth=i,this.tileHeight=n,this.tileMargin=s,this.tileSpacing=r,this.tileProperties=o,this.tileData=a,this.image=null,this.rows=0,this.columns=0,this.total=0,this.texCoordinates=[]},getTileProperties:function(t){return this.containsTileIndex(t)?this.tileProperties[t-this.firstgid]:null},getTileData:function(t){return this.containsTileIndex(t)?this.tileData[t-this.firstgid]:null},getTileCollisionGroup:function(t){var e=this.getTileData(t);return e&&e.objectgroup?e.objectgroup:null},containsTileIndex:function(t){return t>=this.firstgid&&t=0&&g<=1&&v>=0&&v<=1&&(i.x=s+g*(o-s),i.y=r+g*(a-r),!0)}},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(862),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Texture,s.Transform,s.Visible,s.ScrollFactor,o],initialize:function(t,e,i,n,s,o,a,h,l){if(r.call(this,t,"Mesh"),this.setTexture(h,l),this.setPosition(e,i),this.setSizeToFrame(),this.setOrigin(),this.initPipeline("TextureTintPipeline"),n.length!==s.length)throw new Error("Mesh Vertex count must match UV count");var u,c=n.length/2|0;if(o.length>0&&o.length0&&a.length=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(s*a+o*h),e}},function(t,e,i){var n=i(5);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var n=i(5);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},function(t,e,i){var n=i(71),s=i(5);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=n(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,l=t.y2,u=0;u1?2-s:s,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},function(t,e,i){var n=i(51),s=i(88),r=i(32),o=i(0),a=i(15),h=i(2),l=i(14),u=i(31),c=new o({Extends:h,Mixins:[a.Depth,a.GetBounds,a.Origin,a.ScaleMode,a.Transform,a.ScrollFactor,a.Visible],initialize:function(t,e,i,s,r){void 0===s&&(s=1),void 0===r&&(r=s),h.call(this,t,"Zone"),this.setPosition(e,i),this.width=s,this.height=r,this.blendMode=n.NORMAL},displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e,i){return void 0===i&&(i=!0),this.width=t,this.height=e,i&&this.input&&this.input.hitArea instanceof l&&(this.input.hitArea.width=t,this.input.hitArea.height=e),this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this},setCircleDropZone:function(t){return this.setDropZone(new s(0,0,t),r)},setRectangleDropZone:function(t,e){var i=-t/2,n=-e/2;return this.setDropZone(new l(i,n,t,e),u)},setDropZone:function(t,e){return void 0===t?this.setRectangleDropZone(this.width,this.height):this.input||this.setInteractive(t,e,!0),this},renderCanvas:function(){},renderWebGL:function(){}});t.exports=c},function(t,e,i){var n=i(0),s=i(9),r=i(72),o=i(61),a=new n({Extends:s,initialize:function(t){s.call(this),this.manager=t,this.isTimeline=!0,this.data=[],this.totalData=0,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},add:function(t){return this.queue(r(this,t))},queue:function(t){return this.isPlaying()||(t.parent=this,t.parentIsTimeline=!0,this.data.push(t),this.totalData=this.data.length),this},hasOffset:function(t){return null!==t.offset},isOffsetAbsolute:function(t){return"number"==typeof t},isOffsetRelative:function(t){if("string"===typeof t){var e=t[0];if("-"===e||"+"===e)return!0}return!1},getRelativeOffset:function(t,e){var i=t[0],n=parseFloat(t.substr(2)),s=e;switch(i){case"+":s+=n;break;case"-":s-=n}return Math.max(0,s)},calcDuration:function(){for(var t=0,e=0,i=0,n=0;n0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=o.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=o.PENDING_REMOVE}},update:function(t,e){if(this.state!==o.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var n=this.totalData,s=0;s0?Math.floor(v/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=a(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=o(e,"yoyo",g.yoyo),g.flipX=o(e,"flipX",g.flipX),g.flipY=o(e,"flipY",g.flipY);for(var y=0;y0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var n=new(i(0))({initialize:function(t){this.pluginManager=t,this.game=t.game,this.scene,this.systems},init:function(){},start:function(){},stop:function(){},boot:function(){},destroy:function(){this.pluginManager=null,this.game=null,this.scene=null,this.systems=null}});t.exports=n},function(t,e,i){var n={};t.exports=n;var s=i(126),r=i(41),o=i(74),a=i(125),h=i(106),l=i(1017);n.rectangle=function(t,e,i,n,a){a=a||{};var h={label:"Rectangle Body",position:{x:t,y:e},vertices:s.fromPath("L 0 0 L "+i+" 0 L "+i+" "+n+" L 0 "+n)};if(a.chamfer){var l=a.chamfer;h.vertices=s.chamfer(h.vertices,l.radius,l.quality,l.qualityMin,l.qualityMax),delete a.chamfer}return o.create(r.extend({},h,a))},n.trapezoid=function(t,e,i,n,a,h){h=h||{};var l,u=i*(a*=.5),c=u+(1-2*a)*i,d=c+u;l=a<.5?"L 0 0 L "+u+" "+-n+" L "+c+" "+-n+" L "+d+" 0":"L 0 0 L "+c+" "+-n+" L "+d+" 0";var f={label:"Trapezoid Body",position:{x:t,y:e},vertices:s.fromPath(l)};if(h.chamfer){var p=h.chamfer;f.vertices=s.chamfer(f.vertices,p.radius,p.quality,p.qualityMin,p.qualityMax),delete h.chamfer}return o.create(r.extend({},f,h))},n.circle=function(t,e,i,s,o){s=s||{};var a={label:"Circle Body",circleRadius:i};o=o||25;var h=Math.ceil(Math.max(10,Math.min(o,i)));return h%2==1&&(h+=1),n.polygon(t,e,h,i,r.extend({},a,s))},n.polygon=function(t,e,i,a,h){if(h=h||{},i<3)return n.circle(t,e,a,h);for(var l=2*Math.PI/i,u="",c=.5*l,d=0;d0&&s.area(A)1?(f=o.create(r.extend({parts:p.slice(0)},n)),o.setPosition(f,{x:t,y:e}),f):p[0]}},function(t,e,i){var n=i(0),s=i(19),r=i(1),o=i(108),a=i(8),h=new n({Extends:s,initialize:function(t,e,i,n){if(a(e)){var o=e;e=r(o,"key"),n=r(o,"config",n)}var h={type:"audio",cache:t.cacheManager.audio,extension:i.type,key:e,url:i.url,config:n};s.call(this,t,h),this.locked="ontouchstart"in window,this.loaded=!1,this.filesLoaded=0,this.filesTotal=0},onLoad:function(){this.loaded||(this.loaded=!0,this.loader.nextFile(this,!0))},onError:function(){for(var t=0;t=2&&(this.leftStick.set(r[0].getValue(),r[1].getValue()),s>=4&&this.rightStick.set(r[2].getValue(),r[3].getValue()))},destroy:function(){var t;for(this.removeAllListeners(),this.manager=null,this.pad=null,t=0;t=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",e,this,t),this.pad.emit("down",i,t,this)):this.pressed&&(this.pressed=!1,this.events.emit("up",e,this,t),this.pad.emit("up",i,t,this))},destroy:function(){this.pad=null,this.events=null}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.1},update:function(t){this.value=t},getValue:function(){return Math.abs(this.value)0&&e.cameraFilter&r._id)){var l=r.scrollX*e.scrollFactorX,u=r.scrollY*e.scrollFactorY,c=e.x,d=e.y,f=e.scaleX,p=e.scaleY,g=e.rotation,v=e.commandBuffer,y=a||t.currentContext,m=1,x=1,w=0,b=0,T=1,S=0,A=0,C=0;if(t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,y.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,y.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),y.save(),o){var M=o.matrix;y.transform(M[0],M[1],M[2],M[3],M[4],M[5])}y.translate(c-l,d-u),y.rotate(g),y.scale(f,p),y.fillStyle="#fff",y.globalAlpha=e.alpha;for(var _=0,E=v.length;_>>16,A=(65280&w)>>>8,C=255&w,y.strokeStyle="rgba("+S+","+A+","+C+","+m+")",y.lineWidth=T,_+=3;break;case n.FILL_STYLE:b=v[_+1],x=v[_+2],S=(16711680&b)>>>16,A=(65280&b)>>>8,C=255&b,y.fillStyle="rgba("+S+","+A+","+C+","+x+")",_+=2;break;case n.BEGIN_PATH:y.beginPath();break;case n.CLOSE_PATH:y.closePath();break;case n.FILL_PATH:h||y.fill();break;case n.STROKE_PATH:h||y.stroke();break;case n.FILL_RECT:h?y.rect(v[_+1],v[_+2],v[_+3],v[_+4]):y.fillRect(v[_+1],v[_+2],v[_+3],v[_+4]),_+=4;break;case n.FILL_TRIANGLE:y.beginPath(),y.moveTo(v[_+1],v[_+2]),y.lineTo(v[_+3],v[_+4]),y.lineTo(v[_+5],v[_+6]),y.closePath(),h||y.fill(),_+=6;break;case n.STROKE_TRIANGLE:y.beginPath(),y.moveTo(v[_+1],v[_+2]),y.lineTo(v[_+3],v[_+4]),y.lineTo(v[_+5],v[_+6]),y.closePath(),h||y.stroke(),_+=6;break;case n.LINE_TO:y.lineTo(v[_+1],v[_+2]),_+=2;break;case n.MOVE_TO:y.moveTo(v[_+1],v[_+2]),_+=2;break;case n.LINE_FX_TO:y.lineTo(v[_+1],v[_+2]),_+=5;break;case n.MOVE_FX_TO:y.moveTo(v[_+1],v[_+2]),_+=5;break;case n.SAVE:y.save();break;case n.RESTORE:y.restore();break;case n.TRANSLATE:y.translate(v[_+1],v[_+2]),_+=2;break;case n.SCALE:y.scale(v[_+1],v[_+2]),_+=2;break;case n.ROTATE:y.rotate(v[_+1]),_+=1}y.restore()}}},function(t,e){t.exports=function(t){var e=t.width/2,i=t.height/2,n=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*n/(10+Math.sqrt(4-3*n)))}},function(t,e,i){var n=i(177),s=i(113),r=i(65),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;hr;){if(o-r>600){var h=o-r+1,l=e-r+1,u=Math.log(h),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(h-c)/h)*(l-h/2<0?-1:1),f=Math.max(r,Math.floor(e-l*c/h+d)),p=Math.min(o,Math.floor(e+(h-l)*c/h+d));i(t,e,f,p,a)}var g=t[e],v=r,y=o;for(n(t,r,e),a(t[o],g)>0&&n(t,r,o);v0;)y--}0===a(t[r],g)?n(t,r,y):n(t,++y,o),y<=e&&(r=y+1),e<=y&&(o=y-1)}};function n(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function s(t,e){return te?1:0}t.exports=i},function(t,e){t.exports=function(t){for(var e=t.length,i=t[0].length,n=new Array(i),s=0;s-1;r--)n[s][r]=t[r][s]}return n}},function(t,e,i){t.exports={AtlasXML:i(514),Canvas:i(513),Image:i(512),JSONArray:i(511),JSONHash:i(510),SpriteSheet:i(509),SpriteSheetFromAtlas:i(508),UnityYAML:i(507)}},function(t,e,i){var n=i(22),s=i(0),r=i(85),o=i(59),a=new s({initialize:function(t,e,i,n){var s=t.manager.game;this.renderer=s.renderer,this.texture=t,this.image=e,this.compressionAlgorithm=null,this.resolution=1,this.width=i||e.naturalWidth||e.width||0,this.height=n||e.naturalHeight||e.height||0,this.scaleMode=o.DEFAULT,this.isCanvas=e instanceof HTMLCanvasElement,this.isPowerOf2=r(this.width,this.height),this.glTexture=null,this.init(s)},init:function(t){this.renderer&&this.renderer.gl&&(this.isCanvas?this.glTexture=this.renderer.canvasToTexture(this.image):this.glTexture=this.renderer.createTextureFromSource(this.image,this.width,this.height,this.scaleMode)),t.config.pixelArt&&this.setFilter(1)},setFilter:function(t){this.renderer.gl&&this.renderer.setTextureFilter(this.glTexture,t)},update:function(){this.renderer.gl&&this.isCanvas&&this.renderer.canvasToTexture(this.image,this.glTexture)},destroy:function(){this.glTexture&&this.renderer.deleteTexture(this.glTexture),this.isCanvas&&n.remove(this.image),this.renderer=null,this.texture=null,this.image=null}});t.exports=a},function(t,e,i){var n=i(22),s=i(515),r=i(0),o=i(30),a=i(20),h=i(9),l=i(276),u=i(4),c=i(182),d=i(117),f=new r({Extends:h,initialize:function(t){h.call(this),this.game=t,this.name="TextureManager",this.list={},this._tempCanvas=n.create2D(this,1,1),this._tempContext=this._tempCanvas.getContext("2d"),this._pending=0,t.events.once("boot",this.boot,this)},boot:function(){this._pending=2,this.on("onload",this.updatePending,this),this.on("onerror",this.updatePending,this),this.addBase64("__DEFAULT",this.game.config.defaultImage),this.addBase64("__MISSING",this.game.config.missingImage),this.game.events.once("destroy",this.destroy,this)},updatePending:function(){this._pending--,0===this._pending&&(this.off("onload"),this.off("onerror"),this.game.events.emit("ready"))},checkKey:function(t){return!this.exists(t)||(console.error("Texture key already in use: "+t),!1)},remove:function(t){if("string"==typeof t){if(!this.exists(t))return console.warn("No texture found matching key: "+t),this;t=this.get(t)}return this.list.hasOwnProperty(t.key)&&(delete this.list[t.key],t.destroy(),this.emit("removetexture",t.key)),this},addBase64:function(t,e){if(this.checkKey(t)){var i=this,n=new Image;n.onerror=function(){i.emit("onerror",t)},n.onload=function(){var e=i.create(t,n);c.Image(e,0),i.emit("addtexture",t,e),i.emit("onload",t,e)},n.src=e}},addImage:function(t,e,i){var n=null;return this.checkKey(t)&&(n=this.create(t,e),c.Image(n,0),i&&n.setDataSource(i),this.emit("addtexture",t,n)),n},generate:function(t,e){if(this.checkKey(t)){var i=n.create(this,1,1);return e.canvas=i,l(e),this.addCanvas(t,i)}return null},createCanvas:function(t,e,i){if(void 0===e&&(e=256),void 0===i&&(i=256),this.checkKey(t)){var s=n.create(this,e,i,a.CANVAS,!0);return this.addCanvas(t,s)}return null},addCanvas:function(t,e){var i=null;return this.checkKey(t)&&(i=new s(this,t,e,e.width,e.height),this.list[t]=i,this.emit("addtexture",t,i)),i},addAtlas:function(t,e,i,n){return Array.isArray(i.textures)||Array.isArray(i.frames)?this.addAtlasJSONArray(t,e,i,n):this.addAtlasJSONHash(t,e,i,n)},addAtlasJSONArray:function(t,e,i,n){var s=null;if(this.checkKey(t)){if(s=this.create(t,e),Array.isArray(i))for(var r=1===i.length,o=0;o=0&&t<=r.width&&e>=0&&e<=r.height){t+=s.cutX,e+=s.cutY;var a=this._tempContext;a.clearRect(0,0,1,1),a.drawImage(r,t,e,1,1,0,0,1,1);var h=a.getImageData(0,0,1,1);return new o(h.data[0],h.data[1],h.data[2],h.data[3])}}return null},getPixelAlpha:function(t,e,i,n){var s=this.getFrame(i,n);if(s){var r=s.source.image;if(t>=0&&t<=r.width&&e>=0&&e<=r.height){t+=s.cutX,e+=s.cutY;var o=this._tempContext;return o.clearRect(0,0,1,1),o.drawImage(r,t,e,1,1,0,0,1,1),o.getImageData(0,0,1,1).data[3]}}return null},setTexture:function(t,e,i){return this.list[e]&&(t.texture=this.list[e],t.frame=t.texture.get(i)),t},each:function(t,e){for(var i=[null],n=1;n0)&&(!!n.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!n.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!n.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=n-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,s-n),s=this.audio.currentTime):s=n)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=s}},destroy:function(){n.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},updateMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},updateVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},calculateRate:function(){n.prototype.calculateRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)},mute:{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||this.emit("mute",this,t)}},setMute:function(t){return this.mute=t,this},volume:{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||this.emit("volume",this,t)}},setVolume:function(t){return this.volume=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||(this.calculateRate(),this.emit("rate",this,t))}},setRate:function(t){return this.rate=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||(this.calculateRate(),this.emit("detune",this,t))}},setDetune:function(t){return this.detune=t,this},seek:{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}},setSeek:function(t){return this.seek=t,this},loop:{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}},setLoop:function(t){return this.loop=t,this}});t.exports=s},function(t,e,i){var n=i(79),s=i(0),r=i(189),o=new s({Extends:n,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,n.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){this.locked=!1;var t=this;if(this.game.cache.audio.entries.each(function(e,i){for(var n=0;n-1&&(delete this.keys[n],this.scenes.splice(i,1),this._start.indexOf(n)>-1&&(i=this._start.indexOf(n),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e,i=t.sys,n=i.settings;t.init&&(t.init.call(t,n.data),n.isTransition&&i.events.emit("transitioninit",n.transitionFrom,n.transitionDuration)),i.load&&(e=i.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(n.status=s.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.game.sound.onBlurPausedSounds&&this.game.sound.unlock(),this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this.isProcessing=!0;for(var i=this.scenes.length-1;i>=0;i--){var n=this.scenes[i].sys;n.settings.status>s.START&&n.settings.status<=s.RUNNING&&n.step(t,e)}},resize:function(t,e){for(var i=0;i=s.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this.isProcessing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,n=this.getScene(t),s=this.getAt(i);this.scenes[e]=s,this.scenes[i]=n}}return this},moveUp:function(t){if(this.isProcessing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e=0;t--){this.scenes[t].sys.destroy()}this.update=o,this.scenes=[],this._pending=[],this._start=[],this._queue=[],this.game=null}});t.exports=l},function(t,e,i){var n=i(56);t.exports=function(t,e,i,s){var r;if(void 0===s&&(s=t),!Array.isArray(e))return-1!==(r=t.indexOf(e))?(n(t,r),i&&i.call(s,e),e):null;for(var o=e.length-1;o>=0;){var a=e[o];-1!==(r=t.indexOf(a))?(n(t,r),i&&i.call(s,a)):e.pop(),o--}return e}},function(t,e,i){var n=i(0),s=i(9),r=i(7),o=i(13),a=i(11),h=i(1),l=i(12),u=i(195),c=new n({Extends:s,initialize:function(t){s.call(this),this.game=t,this.plugins=[],this.scenePlugins=[],this._pendingGlobal=[],this._pendingScene=[],t.isBooted?this.boot():t.events.once("boot",this.boot,this)},boot:function(){var t,e,i,n,s,r,o=this.game.config,a=o.installGlobalPlugins;for(a=a.concat(this._pendingGlobal),t=0;t10&&(t=10-this.pointersTotal);for(var i=0;i0},queueTouchStart:function(t){if(this.queue.push(s.TOUCH_START,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueTouchMove:function(t){if(this.queue.push(s.TOUCH_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueTouchEnd:function(t){if(this.queue.push(s.TOUCH_END,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},queueMouseDown:function(t){if(this.queue.push(s.MOUSE_DOWN,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueMouseMove:function(t){if(this.queue.push(s.MOUSE_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueMouseUp:function(t){if(this.queue.push(s.MOUSE_UP,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},addUpCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.upOnce.push(t):this.domCallbacks.up.push(t),this._hasUpCallback=!0,this},addDownCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.downOnce.push(t):this.domCallbacks.down.push(t),this._hasDownCallback=!0,this},addMoveCallback:function(t,e){return void 0===e&&(e=!1),e?this.domCallbacks.moveOnce.push(t):this.domCallbacks.move.push(t),this._hasMoveCallback=!0,this},inputCandidate:function(t){var e=t.input;if(!e||!e.enabled||!t.willRender())return!1;var i=!0,n=t.parentContainer;if(n)do{if(!n.visible){i=!1;break}n=n.parentContainer}while(n);return i},hitTest:function(t,e,i,n){void 0===n&&(n=this._tempHitTest);var s=this._tempPoint,r=i.width,o=i.height;n.length=0;var a=t.x,h=t.y;if(!(a>=i.x&&h>=i.y&&a<=i.x+r&&h<=i.y+o))return n;i.getWorldPoint(a,h,s),t.worldX=s.x,t.worldY=s.y;for(var l={x:0,y:0},u=this.game.config.resolution,d=this._tempMatrix,f=0;fe.length&&(r=e.length),i?(n=e[r-1][i],(s=e[r][i])-t<=t-n?e[r]:e[r-1]):(n=e[r-1],(s=e[r])-t<=t-n?s:n)}},function(t,e,i){var n=i(23),s=i(0),r=i(209),o=i(208),a=i(4),h=new s({initialize:function(t,e,i){this.manager=t,this.key=e,this.type="frame",this.frames=this.getFrames(t.textureManager,a(i,"frames",[]),a(i,"defaultTextureKey",null)),this.frameRate=a(i,"frameRate",null),this.duration=a(i,"duration",null),null===this.duration&&null===this.frameRate?(this.frameRate=24,this.duration=this.frameRate/this.frames.length*1e3):this.duration&&null===this.frameRate?this.frameRate=this.frames.length/(this.duration/1e3):this.duration=this.frames.length/this.frameRate*1e3,this.msPerFrame=1e3/this.frameRate,this.skipMissedFrames=a(i,"skipMissedFrames",!0),this.delay=a(i,"delay",0),this.repeat=a(i,"repeat",0),this.repeatDelay=a(i,"repeatDelay",0),this.yoyo=a(i,"yoyo",!1),this.showOnStart=a(i,"showOnStart",!1),this.hideOnComplete=a(i,"hideOnComplete",!1),this.paused=!1,this.manager.on("pauseall",this.pause,this),this.manager.on("resumeall",this.resume,this)},addFrame:function(t){return this.addFrameAt(this.frames.length,t)},addFrameAt:function(t,e){var i=this.getFrames(this.manager.textureManager,e);if(i.length>0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var n=this.frames.slice(0,t),s=this.frames.slice(t);this.frames=n.concat(i,s)}this.updateFrameSequence()}return this},checkFrame:function(t){return t>=0&&t0){s.isLast=!0,s.nextFrame=l[0],l[0].prevFrame=s;var v=1/(l.length-1);for(r=0;r=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._timeScale=1,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo),t.updateFrame(this.frames[e])},getFrameByProgress:function(t){return t=n(t,0,1),r(t,this.frames,"progress")},nextFrame:function(t){var e=t.currentFrame;e.isLast?t._yoyo?(t.forward=!1,t.updateFrame(e.prevFrame),this.getNextTick(t)):t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.nextFrame),this.getNextTick(t))},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t.repeatCounter>0?this.repeatAnimation(t):this.completeAnimation(t):(t.updateFrame(e.prevFrame),this.getNextTick(t))},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){if(2===t._pendingStop)return this.completeAnimation(t);t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=t._repeatDelay):(t.repeatCounter--,t.forward=!0,t.updateFrame(t.currentFrame.nextFrame),t.isPlaying&&(this.getNextTick(t),t.pendingRepeat=!1,t.parent.emit("animationrepeat",this,t.currentFrame,t.repeatCounter)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(n.prevFrame=this.frames[i-1],n.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){this.manager.off("pauseall",this.pause,this),this.manager.off("resumeall",this.resume,this),this.manager.remove(this.key);for(var t=0;t=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(t,e,i,s,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=s||(o=e+Math.ceil((i-e)/s/2)*s,n(t,o,e,i,r),a.push(e,o,o,i))}s.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!p(t,e))return i;for(var s,r,o,a,h=[];e;){for(s=0,r=e.children.length;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)},_split:function(t,e){var i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);var r=this._chooseSplitIndex(i,s,n),a=g(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,s,r,o,h,l,u,d,f,p,g,v,y,m;for(l=u=1/0,n=e;n<=i-e;n++)s=a(t,0,n,this.toBBox),r=a(t,n,i,this.toBBox),f=s,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),v=Math.max(f.minY,p.minY),y=Math.min(f.maxX,p.maxX),m=Math.min(f.maxY,p.maxY),o=Math.max(0,y-g)*Math.max(0,m-v),h=c(s)+c(r),o=e;s--)r=t.children[s],h(u,t.leaf?o(r):r),c+=d(u);return c},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)h(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},compareMinX:function(t,e){return t.left-e.left},compareMinY:function(t,e){return t.top-e.top},toBBox:function(t){return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}},t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,n=this._active;for(t=0;tl+u?(g=(p-=l+u)/c,v.x=h.x1+(h.x2-h.x1)*g,v.y=h.y1+(h.y2-h.y1)*g):(g=(p-=l)/u,v.x=a.x1+(a.x2-a.x1)*g,v.y=a.y1+(a.y2-a.y1)*g),r.push(v)}return r}},function(t,e,i){var n=i(5),s=i(71);t.exports=function(t,e,i){void 0===i&&(i=new n);var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=s(r),l=s(o),u=s(a),c=(h+l+u)*e,d=0;return ch+l?(d=(c-=h+l)/u,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/l,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},function(t,e){t.exports=function(t){return 0===t.height?NaN:t.width/t.height}},function(t,e){t.exports=function(t,e,i){for(var n=!1,s=-1,r=t.points.length-1;++s=0&&r>=0&&s+r<1&&(n.push({x:e[b].x,y:e[b].y}),i)));b++);return n}},function(t,e,i){var n=i(0),s=i(145),r=new n({Extends:s,initialize:function(t,e,i,n,r){s.call(this,t,e,i,[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1,1,0],[16777215,16777215,16777215,16777215,16777215,16777215],[1,1,1,1,1,1],n,r),this.resetPosition()},topLeftX:{get:function(){return this.x+this.vertices[0]},set:function(t){this.vertices[0]=t-this.x,this.vertices[6]=t-this.x}},topLeftY:{get:function(){return this.y+this.vertices[1]},set:function(t){this.vertices[1]=t-this.y,this.vertices[7]=t-this.y}},topRightX:{get:function(){return this.x+this.vertices[10]},set:function(t){this.vertices[10]=t-this.x}},topRightY:{get:function(){return this.y+this.vertices[11]},set:function(t){this.vertices[11]=t-this.y}},bottomLeftX:{get:function(){return this.x+this.vertices[2]},set:function(t){this.vertices[2]=t-this.x}},bottomLeftY:{get:function(){return this.y+this.vertices[3]},set:function(t){this.vertices[3]=t-this.y}},bottomRightX:{get:function(){return this.x+this.vertices[4]},set:function(t){this.vertices[4]=t-this.x,this.vertices[8]=t-this.x}},bottomRightY:{get:function(){return this.y+this.vertices[5]},set:function(t){this.vertices[5]=t-this.y,this.vertices[9]=t-this.y}},topLeftAlpha:{get:function(){return this.alphas[0]},set:function(t){this.alphas[0]=t,this.alphas[3]=t}},topRightAlpha:{get:function(){return this.alphas[5]},set:function(t){this.alphas[5]=t}},bottomLeftAlpha:{get:function(){return this.alphas[1]},set:function(t){this.alphas[1]=t}},bottomRightAlpha:{get:function(){return this.alphas[2]},set:function(t){this.alphas[2]=t,this.alphas[4]=t}},topLeftColor:{get:function(){return this.colors[0]},set:function(t){this.colors[0]=t,this.colors[3]=t}},topRightColor:{get:function(){return this.colors[5]},set:function(t){this.colors[5]=t}},bottomLeftColor:{get:function(){return this.colors[1]},set:function(t){this.colors[1]=t}},bottomRightColor:{get:function(){return this.colors[2]},set:function(t){this.colors[2]=t,this.colors[4]=t}},setTopLeft:function(t,e){return this.topLeftX=t,this.topLeftY=e,this},setTopRight:function(t,e){return this.topRightX=t,this.topRightY=e,this},setBottomLeft:function(t,e){return this.bottomLeftX=t,this.bottomLeftY=e,this},setBottomRight:function(t,e){return this.bottomRightX=t,this.bottomRightY=e,this},resetPosition:function(){var t=this.x,e=this.y,i=Math.floor(this.width/2),n=Math.floor(this.height/2);return this.setTopLeft(t-i,e-n),this.setTopRight(t+i,e-n),this.setBottomLeft(t-i,e+n),this.setBottomRight(t+i,e+n),this},resetAlpha:function(){var t=this.alphas;return t[0]=1,t[1]=1,t[2]=1,t[3]=1,t[4]=1,t[5]=1,this},resetColors:function(){var t=this.colors;return t[0]=16777215,t[1]=16777215,t[2]=16777215,t[3]=16777215,t[4]=16777215,t[5]=16777215,this},reset:function(){return this.resetPosition(),this.resetAlpha(),this.resetColors()}});t.exports=r},function(t,e,i){var n=i(22),s=i(0),r=i(15),o=i(20),a=i(2),h=i(411),l=i(886),u=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.Depth,r.Flip,r.GetBounds,r.Mask,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Size,r.Texture,r.Tint,r.Transform,r.Visible,l],initialize:function(t,e,i,s,r,l,u){var c=t.sys.game.renderer;a.call(this,t,"TileSprite"),this.tilePositionX=0,this.tilePositionY=0,this.dirty=!0,this.tileTexture=null,this.renderer=c,this.setTexture(l,u),this.setPosition(e,i),this.setSize(s,r),this.setOriginFromFrame(),this.initPipeline("TextureTintPipeline"),this.potWidth=h(this.frame.width),this.potHeight=h(this.frame.height),this.canvasPattern=null,this.canvasBuffer=n.create2D(this,this.potWidth,this.potHeight),this.canvasBufferCtx=this.canvasBuffer.getContext("2d"),this.oldFrame=null,this.updateTileTexture(),t.sys.game.config.renderType===o.WEBGL&&t.sys.game.renderer.onContextRestored(function(t){var e=t.gl;this.tileTexture=null,this.dirty=!0,this.tileTexture=t.createTexture2D(0,e.LINEAR,e.LINEAR,e.REPEAT,e.REPEAT,e.RGBA,this.canvasBuffer,this.potWidth,this.potHeight)},this)},setTilePosition:function(t,e){return void 0!==t&&(this.tilePositionX=t),void 0!==e&&(this.tilePositionY=e),this},updateTileTexture:function(){(this.dirty||this.oldFrame!==this.frame)&&(this.oldFrame=this.frame,this.canvasBufferCtx.clearRect(0,0,this.canvasBuffer.width,this.canvasBuffer.height),this.renderer.gl?(this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.potWidth,this.potHeight),this.tileTexture=this.renderer.canvasToTexture(this.canvasBuffer,this.tileTexture)):(this.canvasBuffer.width=this.frame.cutWidth,this.canvasBuffer.height=this.frame.cutHeight,this.canvasBufferCtx.drawImage(this.frame.source.image,this.frame.cutX,this.frame.cutY,this.frame.cutWidth,this.frame.cutHeight,0,0,this.frame.cutWidth,this.frame.cutHeight),this.canvasPattern=this.canvasBufferCtx.createPattern(this.canvasBuffer,"repeat")),this.dirty=!1)},preDestroy:function(){this.renderer&&this.renderer.gl&&this.renderer.deleteTexture(this.tileTexture),n.remove(this.canvasBuffer),this.canvasPattern=null,this.canvasBufferCtx=null,this.canvasBuffer=null,this.renderer=null}});t.exports=u},function(t,e,i){var n=i(22),s=i(0),r=i(15),o=i(20),a=i(2),h=i(894),l=i(891),u=i(890),c=new s({Extends:a,Mixins:[r.Alpha,r.BlendMode,r.ComputedSize,r.Depth,r.Flip,r.GetBounds,r.Mask,r.MatrixStack,r.Origin,r.Pipeline,r.ScaleMode,r.ScrollFactor,r.Tint,r.Transform,r.Visible,h],initialize:function(t,e,i,s,r){if(void 0===s&&(s=32),void 0===r&&(r=32),a.call(this,t,"RenderTexture"),this.initMatrixStack(),this.renderer=t.sys.game.renderer,this.globalTint=16777215,this.globalAlpha=1,this.canvas=null,this.context=null,this.framebuffer=null,this.renderer.type===o.WEBGL){var h=this.renderer.gl;this.gl=h,this.fill=u.fill,this.clear=u.clear,this.draw=u.draw,this.drawFrame=u.drawFrame,this.texture=this.renderer.createTexture2D(0,h.NEAREST,h.NEAREST,h.CLAMP_TO_EDGE,h.CLAMP_TO_EDGE,h.RGBA,null,s,r,!1),this.framebuffer=this.renderer.createFramebuffer(s,r,this.texture,!1)}else this.renderer.type===o.CANVAS&&(this.fill=l.fill,this.clear=l.clear,this.draw=l.draw,this.drawFrame=l.drawFrame,this.canvas=n.create2D(this,s,r),this.context=this.canvas.getContext("2d"));this.setPosition(e,i),this.setSize(s,r),this.initPipeline("TextureTintPipeline")},resize:function(t,e){if(void 0===e&&(e=t),t!==this.width||e!==this.height){if(this.canvas)this.canvas.width=t,this.canvas.height=e;else{this.renderer.deleteTexture(this.texture),this.renderer.deleteFramebuffer(this.framebuffer);var i=this.renderer.gl;this.texture=this.renderer.createTexture2D(0,i.NEAREST,i.NEAREST,i.CLAMP_TO_EDGE,i.CLAMP_TO_EDGE,i.RGBA,null,t,e,!1),this.framebuffer=this.renderer.createFramebuffer(t,e,this.texture,!1)}this.setSize(t,e)}return this},setGlobalTint:function(t){return this.globalTint=t,this},setGlobalAlpha:function(t){return this.globalAlpha=t,this},preDestroy:function(){this.renderer&&this.renderer.gl&&(this.renderer.deleteTexture(this.texture),this.renderer.deleteFramebuffer(this.framebuffer))}});t.exports=c},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(458),a=i(93),h=i(456),l=i(898),u=new n({Extends:r,Mixins:[s.Depth,s.Pipeline,s.Visible,l],initialize:function(t,e,i,n){if(r.call(this,t,"ParticleEmitterManager"),this.blendMode=-1,this.timeScale=1,this.texture=null,this.frame=null,this.frameNames=[],null===i||"object"!=typeof i&&!Array.isArray(i)||(n=i,i=null),this.setTexture(e,i),this.initPipeline("TextureTintPipeline"),this.emitters=new a(this),this.wells=new a(this),n){Array.isArray(n)||(n=[n]);for(var s=0;s0?e.defaultFrame=i[0]:e.defaultFrame=this.defaultFrame,this},addEmitter:function(t){return this.emitters.add(t)},createEmitter:function(t){return this.addEmitter(new h(this,t))},addGravityWell:function(t){return this.wells.add(t)},createGravityWell:function(t){return this.addGravityWell(new o(t))},emitParticle:function(t,e,i){for(var n=this.emitters.list,s=0;s0)for(var e=this.list,i=new a,n=0;n-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){var i,n=[null],s=this.list.slice(),r=s.length;for(i=2;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}},preDestroy:function(){this.removeAll(!!this.exclusive),this.localTransform.destroy(),this.tempTransformMatrix.destroy(),this.list=[],this._displayList=null}});t.exports=c},function(t,e,i){var n=i(910),s=i(907),r=i(0),o=i(15),a=i(128),h=i(2),l=i(93),u=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Mask,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,n],initialize:function(t,e,i,n,s){h.call(this,t,"Blitter"),this.setTexture(n,s),this.setPosition(e,i),this.initPipeline("TextureTintPipeline"),this.children=new l,this.renderList=[],this.dirty=!1},create:function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new s(this,t,e,i,n);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,n){for(var s=this.createMultiple(e,i,n),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0},preDestroy:function(){this.children.destroy(),this.renderList=[]}});t.exports=u},function(t,e,i){var n=i(0),s=i(15),r=i(2),o=i(475),a=i(914),h=i(913),l=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Texture,s.Tint,s.Transform,s.Visible,h],initialize:function(t,e,i,n,s,o){void 0===s&&(s=""),r.call(this,t,"BitmapText"),this.font=n;var a=this.scene.sys.cache.bitmapFont.get(n);this.fontData=a.data,this.text="",this.fontSize=o||this.fontData.size,this.letterSpacing=0,this.setText(s),this.setTexture(a.texture,a.frame),this.setPosition(e,i),this.setOrigin(0,0),this.initPipeline("TextureTintPipeline"),this._bounds=this.getTextBounds()},setFontSize:function(t){return this.fontSize=t,this},setLetterSpacing:function(t){return void 0===t&&(t=0),this.letterSpacing=t,this},setText:function(t){return t||0===t||(t=""),Array.isArray(t)&&(t=t.join("\n")),t!==this.text&&(this.text=t.toString(),this.updateDisplayOrigin()),this},getTextBounds:function(t){return this._bounds=o(this,t),this._bounds},width:{get:function(){return this.getTextBounds(!1),this._bounds.global.width}},height:{get:function(){return this.getTextBounds(!1),this._bounds.global.height}},toJSON:function(){var t=s.ToJSON(this),e={font:this.font,text:this.text,fontSize:this.fontSize,letterSpacing:this.letterSpacing};return t.data=e,t}});l.ParseFromAtlas=a,t.exports=l},function(t,e,i){var n=i(4),s=i(95),r=function(t,e,i){for(var n=[],s=0;s0?Math.ceil(t):Math.floor(t)}},function(t,e){t.exports=function(t){return t&&t[0].toUpperCase()+t.slice(1)}},function(t,e,i){var n=i(6);t.exports=function(t,e,i,s,r,o,a,h){void 0===h&&(h=new n);var l=Math.sin(-r),u=Math.cos(-r),c=u*o,d=-l*o,f=l*a,p=u*a,g=c*p-d*f,v=p/g,y=-d/g,m=-f/g,x=c/g,w=(f*s-p*i)/g,b=-(c*s-d*i)/g;return h.x=t*v+e*m+w,h.y=t*y+e*x+b,h}},function(t,e,i){"use strict";function n(t,e,i){i=i||2;var n,a,h,l,u,f,g,v=e&&e.length,y=v?e[0]*i:t.length,m=s(t,0,y,i,!0),x=[];if(!m)return x;if(v&&(m=function(t,e,i,n){var o,a,h,l,u,f=[];for(o=0,a=e.length;o80*i){n=h=t[0],a=l=t[1];for(var w=i;wh&&(h=u),f>l&&(l=f);g=Math.max(h-n,l-a)}return o(m,x,i,n,a,g),x}function s(t,e,i,n,s){var r,o;if(s===C(t,e,i,n)>0)for(r=e;r=e;r-=n)o=T(r,t[r],t[r+1],o);return o&&m(o,o.next)&&(S(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!m(n,n.next)&&0!==y(n.prev,n,n.next))n=n.next;else{if(S(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,s,c,d){if(t){!d&&c&&function(t,e,i,n){var s=t;do{null===s.z&&(s.z=f(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,n,s,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,l*=2}while(o>1)}(s)}(t,n,s,c);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,n,s,c):a(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),S(t),t=g.next,v=g.next;else if((t=g)===v){d?1===d?o(t=l(t,e,i),e,i,n,s,c,2):2===d&&u(t,e,i,n,s,c):o(r(t),e,i,n,s,c,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(y(e,i,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(g(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&y(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function h(t,e,i,n){var s=t.prev,r=t,o=t.next;if(y(s,r,o)>=0)return!1;for(var a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,u=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,c=f(a,h,e,i,n),d=f(l,u,e,i,n),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function l(t,e,i){var n=t;do{var s=n.prev,r=n.next.next;!m(s,r)&&x(s,n,n.next,r)&&w(s,r)&&w(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),S(n),S(n.next),n=t=r),n=n.next}while(n!==t);return n}function u(t,e,i,n,s,a){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var u=b(h,l);return h=r(h,h.next),u=r(u,u.next),o(h,e,i,n,s,a),void o(u,e,i,n,s,a)}l=l.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,n=e,s=t.x,r=t.y,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var a=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=s&&a>o){if(o=a,a===s){if(r===n.y)return n;if(r===n.next.y)return n.next}i=n.x=n.x&&n.x>=u&&s!==n.x&&g(ri.x)&&w(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=b(e,t);r(i,i.next)}}function f(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&w(t,e)&&w(e,t)&&function(t,e){var i=t,n=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function y(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,n){return!!(m(t,e)&&m(i,n)||m(t,n)&&m(i,e))||y(t,e,i)>0!=y(t,e,n)>0&&y(i,n,t)>0!=y(i,n,e)>0}function w(t,e){return y(t.prev,t,t.next)<0?y(t,e,t.next)>=0&&y(t,t.prev,e)>=0:y(t,e,t.prev)<0||y(t,t.next,e)<0}function b(t,e){var i=new A(t.i,t.x,t.y),n=new A(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function T(t,e,i,n){var s=new A(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function S(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function C(t,e,i,n){for(var s=0,r=e,o=i-n;r0&&(n+=t[s-1].length,i.holes.push(n))}return i}},function(t,e,i){var n=i(0),s=i(119),r=i(258),o=i(202),a=i(529),h=i(528),l=i(27),u=i(84),c=function(t,e,i,n,s){this.x=t,this.y=e,this.width=i,this.rgb=n,this.alpha=s},d=function(t,e,i,n,s){this.points=[],this.pointsLength=1,this.points[0]=new c(t,e,i,n,s)},f=new Float32Array([1,0,0,1,0,0]),p=new Float32Array(6e3),g=0,v=[],y=new n({Extends:u,Mixins:[o],initialize:function(t){u.call(this,{game:t.game,renderer:t.renderer,gl:t.renderer.gl,topology:t.topology?t.topology:t.renderer.gl.TRIANGLES,vertShader:t.vertShader?t.vertShader:h,fragShader:t.fragShader?t.fragShader:a,vertexCapacity:t.vertexCapcity?t.vertexCapacity:12e3,vertexSize:t.vertexSize?t.vertexSize:2*Float32Array.BYTES_PER_ELEMENT+4*Uint8Array.BYTES_PER_ELEMENT,attributes:[{name:"inPosition",size:2,type:t.renderer.gl.FLOAT,normalized:!1,offset:0},{name:"inTint",size:4,type:t.renderer.gl.UNSIGNED_BYTE,normalized:!0,offset:2*Float32Array.BYTES_PER_ELEMENT}]}),this.vertexViewF32=new Float32Array(this.vertexData),this.vertexViewU32=new Uint32Array(this.vertexData),this.tempTriangle=[{x:0,y:0,width:0,rgb:16777215,alpha:1},{x:0,y:0,width:0,rgb:16777215,alpha:1},{x:0,y:0,width:0,rgb:16777215,alpha:1},{x:0,y:0,width:0,rgb:16777215,alpha:1}],this.polygonCache=[],this.mvpInit()},onBind:function(){return u.prototype.onBind.call(this),this.mvpUpdate(),this},resize:function(t,e,i){return u.prototype.resize.call(this,t,e,i),this.projOrtho(0,this.width,this.height,0,-1e3,1e3),this},batchFillRect:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y,m){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var x=this.vertexViewF32,w=this.vertexViewU32,b=this.vertexCount*this.vertexComponentCount,T=r+a,S=o+h,A=m[0],C=m[1],M=m[2],_=m[3],E=d*A+f*M,P=d*C+f*_,k=p*A+g*M,L=p*C+g*_,F=v*A+y*M+m[4],R=v*C+y*_+m[5],O=r*E+o*k+F,B=r*P+o*L+R,D=r*E+S*k+F,I=r*P+S*L+R,z=T*E+S*k+F,Y=T*P+S*L+R,X=T*E+o*k+F,N=T*P+o*L+R,V=l.getTintAppendFloatAlphaAndSwap(u,c);x[b+0]=O,x[b+1]=B,w[b+2]=V,x[b+3]=D,x[b+4]=I,w[b+5]=V,x[b+6]=z,x[b+7]=Y,w[b+8]=V,x[b+9]=O,x[b+10]=B,w[b+11]=V,x[b+12]=z,x[b+13]=Y,w[b+14]=V,x[b+15]=X,x[b+16]=N,w[b+17]=V,this.vertexCount+=6},batchFillTriangle:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y,m,x,w){this.renderer.setPipeline(this),this.vertexCount+3>this.vertexCapacity&&this.flush();var b=this.vertexViewF32,T=this.vertexViewU32,S=this.vertexCount*this.vertexComponentCount,A=w[0],C=w[1],M=w[2],_=w[3],E=p*A+g*M,P=p*C+g*_,k=v*A+y*M,L=v*C+y*_,F=m*A+x*M+w[4],R=m*C+x*_+w[5],O=r*E+o*k+F,B=r*P+o*L+R,D=a*E+h*k+F,I=a*P+h*L+R,z=u*E+c*k+F,Y=u*P+c*L+R,X=l.getTintAppendFloatAlphaAndSwap(d,f);b[S+0]=O,b[S+1]=B,T[S+2]=X,b[S+3]=D,b[S+4]=I,T[S+5]=X,b[S+6]=z,b[S+7]=Y,T[S+8]=X,this.vertexCount+=3},batchStrokeTriangle:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f,p,g,v,y,m,x,w){var b=this.tempTriangle;b[0].x=r,b[0].y=o,b[0].width=c,b[0].rgb=d,b[0].alpha=f,b[1].x=a,b[1].y=h,b[1].width=c,b[1].rgb=d,b[1].alpha=f,b[2].x=l,b[2].y=u,b[2].width=c,b[2].rgb=d,b[2].alpha=f,b[3].x=r,b[3].y=o,b[3].width=c,b[3].rgb=d,b[3].alpha=f,this.batchStrokePath(t,e,i,n,s,b,c,d,f,p,g,v,y,m,x,!1,w)},batchFillPath:function(t,e,i,n,s,o,a,h,u,c,d,f,p,g,v){this.renderer.setPipeline(this);for(var y,m,x,w,b,T,S,A,C,M,_,E,P,k,L,F,R,O=o.length,B=this.polygonCache,D=this.vertexViewF32,I=this.vertexViewU32,z=0,Y=v[0],X=v[1],N=v[2],V=v[3],U=u*Y+c*N,G=u*X+c*V,W=d*Y+f*N,H=d*X+f*V,j=p*Y+g*N+v[4],q=p*X+g*V+v[5],K=l.getTintAppendFloatAlphaAndSwap(a,h),J=0;Jthis.vertexCapacity&&this.flush(),z=this.vertexCount*this.vertexComponentCount,E=(T=B[x+0])*U+(S=B[x+1])*W+j,P=T*G+S*H+q,k=(A=B[w+0])*U+(C=B[w+1])*W+j,L=A*G+C*H+q,F=(M=B[b+0])*U+(_=B[b+1])*W+j,R=M*G+_*H+q,D[z+0]=E,D[z+1]=P,I[z+2]=K,D[z+3]=k,D[z+4]=L,I[z+5]=K,D[z+6]=F,D[z+7]=R,I[z+8]=K,this.vertexCount+=3;B.length=0},batchStrokePath:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y){var m,x;this.renderer.setPipeline(this);for(var w,b,T,S,A=r.length,C=this.polygonCache,M=this.vertexViewF32,_=this.vertexViewU32,E=l.getTintAppendFloatAlphaAndSwap,P=0;P+1this.vertexCapacity&&this.flush(),w=C[k-1]||C[L-1],b=C[k],M[(T=this.vertexCount*this.vertexComponentCount)+0]=w[6],M[T+1]=w[7],_[T+2]=E(w[8],h),M[T+3]=w[0],M[T+4]=w[1],_[T+5]=E(w[2],h),M[T+6]=b[9],M[T+7]=b[10],_[T+8]=E(b[11],h),M[T+9]=w[0],M[T+10]=w[1],_[T+11]=E(w[2],h),M[T+12]=w[6],M[T+13]=w[7],_[T+14]=E(w[8],h),M[T+15]=b[3],M[T+16]=b[4],_[T+17]=E(b[5],h),this.vertexCount+=6;C.length=0},batchLine:function(t,e,i,n,s,r,o,a,h,u,c,d,f,p,g,v,y,m,x,w,b){this.renderer.setPipeline(this),this.vertexCount+6>this.vertexCapacity&&this.flush();var T=b[0],S=b[1],A=b[2],C=b[3],M=g*T+v*A,_=g*S+v*C,E=y*T+m*A,P=y*S+m*C,k=x*T+w*A+b[4],L=x*S+w*C+b[5],F=this.vertexViewF32,R=this.vertexViewU32,O=a-r,B=h-o,D=Math.sqrt(O*O+B*B),I=u*(h-o)/D,z=u*(r-a)/D,Y=c*(h-o)/D,X=c*(r-a)/D,N=a-Y,V=h-X,U=r-I,G=o-z,W=a+Y,H=h+X,j=r+I,q=o+z,K=N*M+V*E+k,J=N*_+V*P+L,Z=U*M+G*E+k,Q=U*_+G*P+L,$=W*M+H*E+k,tt=W*_+H*P+L,et=j*M+q*E+k,it=j*_+q*P+L,nt=l.getTintAppendFloatAlphaAndSwap,st=nt(d,p),rt=nt(f,p),ot=this.vertexCount*this.vertexComponentCount;return F[ot+0]=K,F[ot+1]=J,R[ot+2]=rt,F[ot+3]=Z,F[ot+4]=Q,R[ot+5]=st,F[ot+6]=$,F[ot+7]=tt,R[ot+8]=rt,F[ot+9]=Z,F[ot+10]=Q,R[ot+11]=st,F[ot+12]=et,F[ot+13]=it,R[ot+14]=st,F[ot+15]=$,F[ot+16]=tt,R[ot+17]=rt,this.vertexCount+=6,[K,J,f,Z,Q,d,$,tt,f,et,it,d]},batchGraphics:function(t,e,i){if(!(t.commandBuffer.length<=0)){var n=null;i&&(n=i.matrix),this.renderer.setPipeline(this);var r,o,a,h,l,u,y,m,x=e.scrollX*t.scrollFactorX,w=e.scrollY*t.scrollFactorY,b=t.x,T=t.y,S=t.scaleX,A=t.scaleY,C=t.rotation,M=t.commandBuffer,_=t.alpha,E=1,P=1,k=0,L=0,F=1,R=e.matrix.matrix,O=null,B=0,D=0,I=0,z=0,Y=0,X=0,N=0,V=0,U=0,G=0,W=null,H=Math.sin,j=Math.cos,q=2*Math.PI,K=H(C),J=j(C),Z=J*S,Q=K*S,$=-K*A,tt=J*A,et=b,it=T,nt=R[0],st=R[1],rt=R[2],ot=R[3],at=R[4],ht=R[5];if(n){var lt=n[0],ut=n[1],ct=n[2],dt=n[3],ft=n[4],pt=n[5],gt=-x,vt=-w,yt=lt*nt+ut*rt,mt=lt*st+ut*ot,xt=ct*nt+dt*rt,wt=ct*st+dt*ot;r=Z*yt+Q*xt,o=Z*mt+Q*wt,a=$*yt+tt*xt,h=$*mt+tt*wt,l=et*yt+it*xt+(ft*nt+pt*rt+(gt*nt+vt*rt+at)),u=et*mt+it*wt+(ft*st+pt*ot+(gt*st+vt*ot+ht))}else r=Z*nt+Q*rt,o=Z*st+Q*ot,a=$*nt+tt*rt,h=$*st+tt*ot,l=(et-=x)*nt+(it-=w)*rt+at,u=et*st+it*ot+ht;v.length=0;for(var bt=0,Tt=M.length;bt0&&(U=U%q-q):U>q?U=q:U<0&&(U=q+U%q);B<1;)D=Y+j(z=U*B+V)*N,I=X+H(z)*N,O.points.push(new c(D,I,F,k,E*_)),B+=.01;D=Y+j(z=U+V)*N,I=X+H(z)*N,O.points.push(new c(D,I,F,k,E*_)),bt+=6;break;case s.LINE_STYLE:F=M[bt+1],k=M[bt+2],E=M[bt+3],bt+=3;break;case s.FILL_STYLE:L=M[bt+1],P=M[bt+2],bt+=2;break;case s.BEGIN_PATH:v.length=0,O=null;break;case s.CLOSE_PATH:O&&O.points.length&&O.points.push(O.points[0]);break;case s.FILL_PATH:for(y=0,m=v.length;y=0&&n>=0;return r[0]===t&&r[1]===e&&r[2]===i&&r[3]===n||this.flush(),r[0]=t,r[1]=e,r[2]=i,r[3]=n,this.currentScissorEnabled=o,o?(s.disable(s.SCISSOR_TEST),this):(s.enable(s.SCISSOR_TEST),s.scissor(t,s.drawingBufferHeight-e-n,i,n),this)},pushScissor:function(t,e,i,n){var s=this.scissorStack,r=this.currentScissorIdx,o=this.currentScissor;return s[r+0]=o[0],s[r+1]=o[1],s[r+2]=o[2],s[r+3]=o[3],this.currentScissorIdx+=4,this.setScissor(t,e,i,n),this},popScissor:function(){var t=this.scissorStack,e=this.currentScissorIdx-4,i=t[e+0],n=t[e+1],s=t[e+2],r=t[e+3];return this.currentScissorIdx=e,this.setScissor(i,n,s,r),this},setPipeline:function(t){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==s.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t),this},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl;return t!==this.currentFramebuffer&&(this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,n){var o=this.gl,a=o.NEAREST,h=o.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,r(e,i)&&(h=o.REPEAT),n===s.ScaleModes.LINEAR?a=o.LINEAR:(n===s.ScaleModes.NEAREST||this.config.pixelArt)&&(a=o.NEAREST),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,a,h,h,o.RGBA,t):this.createTexture2D(0,a,a,h,h,o.RGBA,null,e,i)},createTexture2D:function(t,e,i,n,s,r,o,a,h,l){var u=this.gl,c=u.createTexture();return l=void 0===l||null===l||l,this.setTexture2D(c,0),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,e),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,i),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,s),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,n),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),null===o||void 0===o?u.texImage2D(u.TEXTURE_2D,t,r,a,h,0,r,u.UNSIGNED_BYTE,null):(u.texImage2D(u.TEXTURE_2D,t,r,r,u.UNSIGNED_BYTE,o),a=o.width,h=o.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=l,c.isRenderTexture=!1,c.width=a,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,n){var s,r=this.gl,o=r.createFramebuffer();if(this.setFramebuffer(o),n){var a=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,a),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(s=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[s])}return o.renderTexture=i,this.setFramebuffer(null),o},createProgram:function(t,e){var i=this.gl,n=i.createProgram(),s=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,t),i.shaderSource(r,e),i.compileShader(s),i.compileShader(r),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(s));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(n,s),i.attachShader(n,r),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(n));return n},createVertexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setVertexBuffer(n),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),n},createIndexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setIndexBuffer(n),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),n},deleteTexture:function(t){var e=this.nativeTextures.indexOf(t);return-1!==e&&o(this.nativeTextures,e),this.gl.deleteTexture(t),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=this.config.resolution,i=Math.floor(t.x*e),n=Math.floor(t.y*e),s=Math.floor(t.width*e),r=Math.floor(t.height*e);if(this.pushScissor(i,n,s,r),t.backgroundColor.alphaGL>0){var o=t.backgroundColor,h=this.pipelines.FlatTintPipeline;h.batchFillRect(0,0,1,1,0,t.x,t.y,t.width,t.height,a.getTintFromFloats(o.redGL,o.greenGL,o.blueGL,1),o.alphaGL,1,0,0,1,0,0,[1,0,0,1,0,0]),h.flush()}},postRenderCamera:function(t){var e=this.pipelines.FlatTintPipeline,i=t.flashEffect.postRenderWebGL(e,a.getTintFromFloats);(t.fadeEffect.postRenderWebGL(e,a.getTintFromFloats)||i)&&e.flush(),this.popScissor()},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var n in t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),this.config.clearBeforeRender&&t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT),i)i[n].onPreRender()}},render:function(t,e,i,n){if(!this.contextLost){var r=e.list,o=r.length,a=this.pipelines;for(var h in a)a[h].onRender(t,n);this.preRenderCamera(n);for(var l=0;l0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(e*e+i*i+n*n+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return e*e+i*i+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this},zero:function(){var t=this.val;return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,this},xyz:function(t,e,i){this.identity();var n=this.val;return n[12]=t,n[13]=e,n[14]=i,this},scaling:function(t,e,i){this.zero();var n=this.val;return n[0]=t,n[5]=e,n[10]=i,n[15]=1,this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[3],s=t[6],r=t[7],o=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=s,t[11]=t[14],t[12]=n,t[13]=r,t[14]=o,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15],y=e*o-i*r,m=e*a-n*r,x=e*h-s*r,w=i*a-n*o,b=i*h-s*o,T=n*h-s*a,S=l*p-u*f,A=l*g-c*f,C=l*v-d*f,M=u*g-c*p,_=u*v-d*p,E=c*v-d*g,P=y*E-m*_+x*M+w*C-b*A+T*S;return P?(P=1/P,t[0]=(o*E-a*_+h*M)*P,t[1]=(n*_-i*E-s*M)*P,t[2]=(p*T-g*b+v*w)*P,t[3]=(c*b-u*T-d*w)*P,t[4]=(a*C-r*E-h*A)*P,t[5]=(e*E-n*C+s*A)*P,t[6]=(g*x-f*T-v*m)*P,t[7]=(l*T-c*x+d*m)*P,t[8]=(r*_-o*C+h*S)*P,t[9]=(i*C-e*_-s*S)*P,t[10]=(f*b-p*x+v*y)*P,t[11]=(u*x-l*b-d*y)*P,t[12]=(o*A-r*M-a*S)*P,t[13]=(e*M-i*A+n*S)*P,t[14]=(p*m-f*w-g*y)*P,t[15]=(l*w-u*m+c*y)*P,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return t[0]=o*(c*v-d*g)-u*(a*v-h*g)+p*(a*d-h*c),t[1]=-(i*(c*v-d*g)-u*(n*v-s*g)+p*(n*d-s*c)),t[2]=i*(a*v-h*g)-o*(n*v-s*g)+p*(n*h-s*a),t[3]=-(i*(a*d-h*c)-o*(n*d-s*c)+u*(n*h-s*a)),t[4]=-(r*(c*v-d*g)-l*(a*v-h*g)+f*(a*d-h*c)),t[5]=e*(c*v-d*g)-l*(n*v-s*g)+f*(n*d-s*c),t[6]=-(e*(a*v-h*g)-r*(n*v-s*g)+f*(n*h-s*a)),t[7]=e*(a*d-h*c)-r*(n*d-s*c)+l*(n*h-s*a),t[8]=r*(u*v-d*p)-l*(o*v-h*p)+f*(o*d-h*u),t[9]=-(e*(u*v-d*p)-l*(i*v-s*p)+f*(i*d-s*u)),t[10]=e*(o*v-h*p)-r*(i*v-s*p)+f*(i*h-s*o),t[11]=-(e*(o*d-h*u)-r*(i*d-s*u)+l*(i*h-s*o)),t[12]=-(r*(u*g-c*p)-l*(o*g-a*p)+f*(o*c-a*u)),t[13]=e*(u*g-c*p)-l*(i*g-n*p)+f*(i*c-n*u),t[14]=-(e*(o*g-a*p)-r*(i*g-n*p)+f*(i*a-n*o)),t[15]=e*(o*c-a*u)-r*(i*c-n*u)+l*(i*a-n*o),this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return(e*o-i*r)*(c*v-d*g)-(e*a-n*r)*(u*v-d*p)+(e*h-s*r)*(u*g-c*p)+(i*a-n*o)*(l*v-d*f)-(i*h-s*o)*(l*g-c*f)+(n*h-s*a)*(l*p-u*f)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],y=e[15],m=t.val,x=m[0],w=m[1],b=m[2],T=m[3];return e[0]=x*i+w*o+b*u+T*p,e[1]=x*n+w*a+b*c+T*g,e[2]=x*s+w*h+b*d+T*v,e[3]=x*r+w*l+b*f+T*y,x=m[4],w=m[5],b=m[6],T=m[7],e[4]=x*i+w*o+b*u+T*p,e[5]=x*n+w*a+b*c+T*g,e[6]=x*s+w*h+b*d+T*v,e[7]=x*r+w*l+b*f+T*y,x=m[8],w=m[9],b=m[10],T=m[11],e[8]=x*i+w*o+b*u+T*p,e[9]=x*n+w*a+b*c+T*g,e[10]=x*s+w*h+b*d+T*v,e[11]=x*r+w*l+b*f+T*y,x=m[12],w=m[13],b=m[14],T=m[15],e[12]=x*i+w*o+b*u+T*p,e[13]=x*n+w*a+b*c+T*g,e[14]=x*s+w*h+b*d+T*v,e[15]=x*r+w*l+b*f+T*y,this},multiplyLocal:function(t){var e=[],i=this.val,n=t.val;return e[0]=i[0]*n[0]+i[1]*n[4]+i[2]*n[8]+i[3]*n[12],e[1]=i[0]*n[1]+i[1]*n[5]+i[2]*n[9]+i[3]*n[13],e[2]=i[0]*n[2]+i[1]*n[6]+i[2]*n[10]+i[3]*n[14],e[3]=i[0]*n[3]+i[1]*n[7]+i[2]*n[11]+i[3]*n[15],e[4]=i[4]*n[0]+i[5]*n[4]+i[6]*n[8]+i[7]*n[12],e[5]=i[4]*n[1]+i[5]*n[5]+i[6]*n[9]+i[7]*n[13],e[6]=i[4]*n[2]+i[5]*n[6]+i[6]*n[10]+i[7]*n[14],e[7]=i[4]*n[3]+i[5]*n[7]+i[6]*n[11]+i[7]*n[15],e[8]=i[8]*n[0]+i[9]*n[4]+i[10]*n[8]+i[11]*n[12],e[9]=i[8]*n[1]+i[9]*n[5]+i[10]*n[9]+i[11]*n[13],e[10]=i[8]*n[2]+i[9]*n[6]+i[10]*n[10]+i[11]*n[14],e[11]=i[8]*n[3]+i[9]*n[7]+i[10]*n[11]+i[11]*n[15],e[12]=i[12]*n[0]+i[13]*n[4]+i[14]*n[8]+i[15]*n[12],e[13]=i[12]*n[1]+i[13]*n[5]+i[14]*n[9]+i[15]*n[13],e[14]=i[12]*n[2]+i[13]*n[6]+i[14]*n[10]+i[15]*n[14],e[15]=i[12]*n[3]+i[13]*n[7]+i[14]*n[11]+i[15]*n[15],this.fromArray(e)},translate:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[12]=s[0]*e+s[4]*i+s[8]*n+s[12],s[13]=s[1]*e+s[5]*i+s[9]*n+s[13],s[14]=s[2]*e+s[6]*i+s[10]*n+s[14],s[15]=s[3]*e+s[7]*i+s[11]*n+s[15],this},scale:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[0]=s[0]*e,s[1]=s[1]*e,s[2]=s[2]*e,s[3]=s[3]*e,s[4]=s[4]*i,s[5]=s[5]*i,s[6]=s[6]*i,s[7]=s[7]*i,s[8]=s[8]*n,s[9]=s[9]*n,s[10]=s[10]*n,s[11]=s[11]*n,this},makeRotationAxis:function(t,e){var i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,a=t.z,h=s*r,l=s*o;return this.fromArray([h*r+i,h*o-n*a,h*a+n*o,0,h*o+n*a,l*o+i,l*a-n*r,0,h*a-n*o,l*a+n*r,s*a*a+i,0,0,0,0,1]),this},rotate:function(t,e){var i=this.val,n=e.x,s=e.y,r=e.z,o=Math.sqrt(n*n+s*s+r*r);if(Math.abs(o)<1e-6)return null;n*=o=1/o,s*=o,r*=o;var a=Math.sin(t),h=Math.cos(t),l=1-h,u=i[0],c=i[1],d=i[2],f=i[3],p=i[4],g=i[5],v=i[6],y=i[7],m=i[8],x=i[9],w=i[10],b=i[11],T=n*n*l+h,S=s*n*l+r*a,A=r*n*l-s*a,C=n*s*l-r*a,M=s*s*l+h,_=r*s*l+n*a,E=n*r*l+s*a,P=s*r*l-n*a,k=r*r*l+h;return i[0]=u*T+p*S+m*A,i[1]=c*T+g*S+x*A,i[2]=d*T+v*S+w*A,i[3]=f*T+y*S+b*A,i[4]=u*C+p*M+m*_,i[5]=c*C+g*M+x*_,i[6]=d*C+v*M+w*_,i[7]=f*C+y*M+b*_,i[8]=u*E+p*P+m*k,i[9]=c*E+g*P+x*k,i[10]=d*E+v*P+w*k,i[11]=f*E+y*P+b*k,this},rotateX:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],l=e[9],u=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+l*i,e[6]=o*n+u*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=l*n-r*i,e[10]=u*n-o*i,e[11]=c*n-a*i,this},rotateY:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],l=e[9],u=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-l*i,e[2]=o*n-u*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+l*n,e[10]=o*i+u*n,e[11]=a*i+c*n,this},rotateZ:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],l=e[5],u=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+l*i,e[2]=o*n+u*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=l*n-r*i,e[6]=u*n-o*i,e[7]=c*n-a*i,this},fromRotationTranslation:function(t,e){var i=this.val,n=t.x,s=t.y,r=t.z,o=t.w,a=n+n,h=s+s,l=r+r,u=n*a,c=n*h,d=n*l,f=s*h,p=s*l,g=r*l,v=o*a,y=o*h,m=o*l;return i[0]=1-(f+g),i[1]=c+m,i[2]=d-y,i[3]=0,i[4]=c-m,i[5]=1-(u+g),i[6]=p+v,i[7]=0,i[8]=d+y,i[9]=p-v,i[10]=1-(u+f),i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},fromQuat:function(t){var e=this.val,i=t.x,n=t.y,s=t.z,r=t.w,o=i+i,a=n+n,h=s+s,l=i*o,u=i*a,c=i*h,d=n*a,f=n*h,p=s*h,g=r*o,v=r*a,y=r*h;return e[0]=1-(d+p),e[1]=u+y,e[2]=c-v,e[3]=0,e[4]=u-y,e[5]=1-(l+p),e[6]=f+g,e[7]=0,e[8]=c+v,e[9]=f-g,e[10]=1-(l+d),e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},frustum:function(t,e,i,n,s,r){var o=this.val,a=1/(e-t),h=1/(n-i),l=1/(s-r);return o[0]=2*s*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2*s*h,o[6]=0,o[7]=0,o[8]=(e+t)*a,o[9]=(n+i)*h,o[10]=(r+s)*l,o[11]=-1,o[12]=0,o[13]=0,o[14]=r*s*2*l,o[15]=0,this},perspective:function(t,e,i,n){var s=this.val,r=1/Math.tan(t/2),o=1/(i-n);return s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+i)*o,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*i*o,s[15]=0,this},perspectiveLH:function(t,e,i,n){var s=this.val;return s[0]=2*i/t,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*i/e,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=-n/(i-n),s[11]=1,s[12]=0,s[13]=0,s[14]=i*n/(i-n),s[15]=0,this},ortho:function(t,e,i,n,s,r){var o=this.val,a=t-e,h=i-n,l=s-r;return a=0===a?a:1/a,h=0===h?h:1/h,l=0===l?l:1/l,o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*l,o[11]=0,o[12]=(t+e)*a,o[13]=(n+i)*h,o[14]=(r+s)*l,o[15]=1,this},lookAt:function(t,e,i){var n=this.val,s=t.x,r=t.y,o=t.z,a=i.x,h=i.y,l=i.z,u=e.x,c=e.y,d=e.z;if(Math.abs(s-u)<1e-6&&Math.abs(r-c)<1e-6&&Math.abs(o-d)<1e-6)return this.identity();var f=s-u,p=r-c,g=o-d,v=1/Math.sqrt(f*f+p*p+g*g),y=h*(g*=v)-l*(p*=v),m=l*(f*=v)-a*g,x=a*p-h*f;(v=Math.sqrt(y*y+m*m+x*x))?(y*=v=1/v,m*=v,x*=v):(y=0,m=0,x=0);var w=p*x-g*m,b=g*y-f*x,T=f*m-p*y;return(v=Math.sqrt(w*w+b*b+T*T))?(w*=v=1/v,b*=v,T*=v):(w=0,b=0,T=0),n[0]=y,n[1]=w,n[2]=f,n[3]=0,n[4]=m,n[5]=b,n[6]=p,n[7]=0,n[8]=x,n[9]=T,n[10]=g,n[11]=0,n[12]=-(y*s+m*r+x*o),n[13]=-(w*s+b*r+T*o),n[14]=-(f*s+p*r+g*o),n[15]=1,this},yawPitchRoll:function(t,e,i){this.zero(),s.zero(),r.zero();var n=this.val,o=s.val,a=r.val,h=Math.sin(i),l=Math.cos(i);return n[10]=1,n[15]=1,n[0]=l,n[1]=h,n[4]=-h,n[5]=l,h=Math.sin(e),l=Math.cos(e),o[0]=1,o[15]=1,o[5]=l,o[10]=l,o[9]=-h,o[6]=h,h=Math.sin(t),l=Math.cos(t),a[5]=1,a[15]=1,a[0]=l,a[2]=-h,a[8]=h,a[10]=l,this.multiplyLocal(s),this.multiplyLocal(r),this},setWorldMatrix:function(t,e,i,n,o){return this.yawPitchRoll(t.y,t.x,t.z),s.scaling(i.x,i.y,i.z),r.xyz(e.x,e.y,e.z),this.multiplyLocal(s),this.multiplyLocal(r),void 0!==n&&this.multiplyLocal(n),void 0!==o&&this.multiplyLocal(o),this}}),s=new n,r=new n;t.exports=n},function(t,e,i){var n=i(0),s=i(278),r=i(561),o=i(560),a=i(559),h=i(70),l=i(151),u=i(6),c=i(87),d=i(277),f=new c,p=new d,g=new c,v=new c,y=new s,m=new n({initialize:function(t){this.scene=t,this.displayList=t.sys.displayList,this.updateList=t.sys.updateList,this.name="",this.direction=new c(0,0,-1),this.up=new c(0,1,0),this.position=new c,this.pixelScale=128,this.projection=new s,this.view=new s,this.combined=new s,this.invProjectionView=new s,this.near=1,this.far=100,this.ray={origin:new c,direction:new c},this.viewportWidth=0,this.viewportHeight=0,this.billboardMatrixDirty=!0,this.children=new h},setPosition:function(t,e,i){return this.position.set(t,e,i),this.update()},setScene:function(t){return this.scene=t,this},setPixelScale:function(t){return this.pixelScale=t,this.update()},add:function(t){return this.children.set(t),this.updateChildren(),t},remove:function(t){return this.displayList.remove(t.gameObject),this.updateList.remove(t.gameObject),this.children.delete(t),this},clear:function(){for(var t=this.getChildren(),e=0;e16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var n=i(30),s=i(282);t.exports=function(t){var e=s(t);return new n(e.r,e.g,e.b,e.a)}},function(t,e){t.exports=function(t,e,i,n){return n<<24|t<<16|e<<8|i}},function(t,e,i){var n=i(30);t.exports=function(t){var e=new n;t=t.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(t,e,i,n){return e+e+i+i+n+n});var i=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);if(i){var s=parseInt(i[1],16),r=parseInt(i[2],16),o=parseInt(i[3],16);e.setTo(s,r,o)}return e}},function(t,e){t.exports=function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}},function(t,e){t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)}},function(t,e){t.exports=function(t,e,i,n,s){var r=n+Math.atan2(t.y-i,t.x-e);return t.x=e+s*Math.cos(r),t.y=i+s*Math.sin(r),t}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);for(var i=null,n=0;n>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e0;i--){var n=Math.floor(this.frac()*(e+1)),s=t[n];t[n]=t[i],t[i]=s}return t}});t.exports=n},function(t,e,i){var n=i(136),s=i(65),r=i(16),o=i(5);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=s(e,0,r.PI2);return n(t,a,i)}},function(t,e){t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},function(t,e,i){var n={};t.exports=n;var s=i(126),r=i(106),o=i(331),a=i(125),h=i(680),l=i(41);n._warming=.4,n._torqueDampen=1,n._minLength=1e-6,n.create=function(t){var e=t;e.bodyA&&!e.pointA&&(e.pointA={x:0,y:0}),e.bodyB&&!e.pointB&&(e.pointB={x:0,y:0});var i=e.bodyA?r.add(e.bodyA.position,e.pointA):e.pointA,n=e.bodyB?r.add(e.bodyB.position,e.pointB):e.pointB,s=r.magnitude(r.sub(i,n));e.length=void 0!==e.length?e.length:s,e.id=e.id||l.nextId(),e.label=e.label||"Constraint",e.type="constraint",e.stiffness=e.stiffness||(e.length>0?1:.7),e.damping=e.damping||0,e.angularStiffness=e.angularStiffness||0,e.angleA=e.bodyA?e.bodyA.angle:e.angleA,e.angleB=e.bodyB?e.bodyB.angle:e.angleB,e.plugin={};var o={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===e.length&&e.stiffness>.1?(o.type="pin",o.anchors=!1):e.stiffness<.9&&(o.type="spring"),e.render=l.extend(o,e.render),e},n.preSolveAll=function(t){for(var e=0;e0&&(c.position.x+=l.x,c.position.y+=l.y),0!==l.angle&&(s.rotate(c.vertices,l.angle,i.position),h.rotate(c.axes,l.angle),u>0&&r.rotateAbout(c.position,l.angle,i.position,c.position)),a.update(c.bounds,c.vertices,i.velocity)}l.angle*=n._warming,l.x*=n._warming,l.y*=n._warming}}}},function(t,e,i){var n={};t.exports=n;var s=i(41);n.on=function(t,e,i){for(var n,s=e.split(" "),r=0;r=this.nextTick&&this.currentAnim.setFrame(this)}},setCurrentFrame:function(t){var e=this.parent;return this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,e.setSizeToFrame(),t.frame.customPivot?e.setOrigin(t.frame.pivotX,t.frame.pivotY):e.updateDisplayOrigin(),e},updateFrame:function(t){var e=this.setCurrentFrame(t);if(this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;e.emit("animationupdate",i,t),3===this._pendingStop&&this._pendingStopValue===t&&this.currentAnim.completeAnimation(this)}},setYoyo:function(t){return void 0===t&&(t=!1),this._yoyo=t,this.parent},getYoyo:function(){return this._yoyo},destroy:function(){this.animationManager.off("remove",this.remove,this),this.animationManager=null,this.parent=null,this.currentAnim=null,this.currentFrame=null}});t.exports=n},function(t,e,i){var n=i(0),s=i(161),r=i(12),o=i(160),a=i(61),h=i(72),l=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this.timeScale=1,this._add=[],this._pending=[],this._active=[],this._destroy=[],this._toProcess=0,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.systems.events.once("destroy",this.destroy,this)},start:function(){var t=this.systems.events;t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this),this.timeScale=1},createTimeline:function(t){return o(this,t)},timeline:function(t){var e=o(this,t);return e.paused||(this._add.push(e),this._toProcess++),e},create:function(t){return h(this,t)},add:function(t){var e=h(this,t);return this._add.push(e),this._toProcess++,e},existing:function(t){return this._add.push(t),this._toProcess++,this},addCounter:function(t){var e=s(this,t);return this._add.push(e),this._toProcess++,e},preUpdate:function(){if(0!==this._toProcess){var t,e,i=this._destroy,n=this._active;for(t=0;t-1&&this._active.splice(s,1),n.destroy()}for(i=0;i=n.delay)){var s=n.elapsed-n.delay;n.elapsed=n.delay,!n.hasDispatched&&n.callback&&(n.hasDispatched=!0,n.callback.apply(n.callbackScope,n.args)),n.repeatCount>0?(n.repeatCount--,n.elapsed=s,n.hasDispatched=!1):this._pendingRemoval.push(n)}}}},shutdown:function(){var t;for(t=0;ta&&(a=e.layer[l].width),e.layer[l].height>h&&(h=e.layer[l].height);var u=new s({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:n.WELTMEISTER});return u.layers=r(e,i),u.tilesets=o(e),u}},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","object layer"),this.opacity=s(t,"opacity",1),this.properties=s(t,"properties",{}),this.propertyTypes=s(t,"propertytypes",{}),this.type=s(t,"type","objectgroup"),this.visible=s(t,"visible",!0),this.objects=s(t,"objects",[])}});t.exports=r},function(t,e,i){var n=i(633),s=i(316),r=function(t){return{x:t.x,y:t.y}},o=["id","name","type","rotation","properties","visible","x","y","width","height"];t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var a=n(t,o);if(a.x+=e,a.y+=i,t.gid){var h=s(t.gid);a.gid=h.gid,a.flippedHorizontal=h.flippedHorizontal,a.flippedVertical=h.flippedVertical,a.flippedAntiDiagonal=h.flippedAntiDiagonal}else t.polyline?a.polyline=t.polyline.map(r):t.polygon?a.polygon=t.polygon.map(r):t.ellipse?(a.ellipse=t.ellipse,a.width=t.width,a.height=t.height):t.text?(a.width=t.width,a.height=t.height,a.text=t.text):(a.rectangle=!0,a.width=t.width,a.height=t.height);return a}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|n,this.imageMargin=0|s,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&t-1}return!1}},function(t,e,i){var n=i(21);t.exports=function(t,e,i,s,r,o,a){for(var h=n(i,s,r,o,null,a),l=0;l=this._duration&&this.transitionComplete()},transitionComplete:function(){var t=this._target.sys,e=this._target.sys.settings;this.systems.events.off("update",this.step,this),t.events.emit("transitioncomplete",this.scene),e.isTransition=!1,e.transitionFrom=null,this._duration=0,this._target=null,this._onUpdate=null,this._onUpdateScope=null,this._willRemove?this.manager.remove(this.key):this._willSleep?this.systems.sleep():this.manager.stop(this.key)},add:function(t,e,i){return this.manager.add(t,e,i),this},launch:function(t,e){return t&&t!==this.key&&(this.settings.status!==r.RUNNING?this.manager.queueOp("start",t,e):this.manager.start(t,e)),this},run:function(t,e){return this.settings.status!==r.RUNNING?this.manager.queueOp("run",t,e):this.manager.run(t,e),this},pause:function(t){return void 0===t&&(t=this.key),this.manager.pause(t),this},resume:function(t){return void 0===t&&(t=this.key),this.manager.resume(t),this},sleep:function(t){return void 0===t&&(t=this.key),this.manager.sleep(t),this},wake:function(t){return void 0===t&&(t=this.key),this.manager.wake(t),this},switch:function(t){return t!==this.key&&(this.settings.status!==r.RUNNING?this.manager.queueOp("switch",this.key,t):this.manager.switch(this.key,t)),this},stop:function(t){return void 0===t&&(t=this.key),this.manager.stop(t),this},setActive:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setActive(t),this},setVisible:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setVisible(t),this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},getIndex:function(t){return void 0===t&&(t=this.key),this.manager.getIndex(t)},shutdown:function(){var t=this.systems.events;t.off("shutdown",this.shutdown,this),t.off("postupdate",this.step,this),t.off("transitionout")},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null,this.settings=null,this.manager=null}});a.register("ScenePlugin",h,"scenePlugin"),t.exports=h},function(t,e,i){var n=i(55),s=i(17),r={SceneManager:i(194),ScenePlugin:i(327),Settings:i(192),Systems:i(118)};r=s(!1,r,n),t.exports=r},function(t,e,i){var n=i(165),s=new(i(0))({Extends:n,initialize:function(t,e){n.call(this,e),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this)},boot:function(){}});t.exports=s},function(t,e,i){t.exports={BasePlugin:i(165),DefaultPlugins:i(121),PluginCache:i(12),PluginManager:i(196),ScenePlugin:i(329)}},function(t,e,i){var n={};t.exports=n;var s=i(301);n._motionWakeThreshold=.18,n._motionSleepThreshold=.08,n._minBias=.9,n.update=function(t,e){for(var i=e*e*e,s=0;s0&&r.motion=r.sleepThreshold&&n.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else n.set(r,!1)}},n.afterCollisions=function(t,e){for(var i=e*e*e,s=0;sn._motionWakeThreshold*i&&n.set(l,!1)}}}},n.set=function(t,e){var i=t.isSleeping;e?(t.isSleeping=!0,t.sleepCounter=t.sleepThreshold,t.positionImpulse.x=0,t.positionImpulse.y=0,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.anglePrev=t.angle,t.speed=0,t.angularSpeed=0,t.motion=0,i||s.trigger(t,"sleepStart")):(t.isSleeping=!1,t.sleepCounter=0,i&&s.trigger(t,"sleepEnd"))}},function(t,e){t.exports={NONE:0,A:1,B:2,BOTH:3}},function(t,e){t.exports={NEVER:0,LITE:1,PASSIVE:2,ACTIVE:4,FIXED:8}},function(t,e,i){var n=i(32),s=i(0),r=i(42),o=i(31),a=i(6),h=new s({initialize:function(t,e){var i=e.width?e.width:64,n=e.height?e.height:64;this.world=t,this.gameObject=e,this.debugShowBody=t.defaults.debugShowStaticBody,this.debugBodyColor=t.defaults.staticBodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new a,this.position=new a(e.x-e.displayOriginX,e.y-e.displayOriginY),this.width=i,this.height=n,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center=new a(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=a.ZERO,this.allowGravity=!1,this.gravity=a.ZERO,this.bounce=a.ZERO,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.mass=1,this.immovable=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.physicsType=r.STATIC_BODY,this._dx=0,this._dy=0},setGameObject:function(t,e){return t&&t!==this.gameObject&&(this.gameObject.body=null,t.body=this,this.gameObject=t),e&&this.updateFromGameObject(),this},updateFromGameObject:function(){this.world.staticTree.remove(this);var t=this.gameObject;return t.getTopLeft(this.position),this.width=t.displayWidth,this.height=t.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.world.staticTree.insert(this),this},setOffset:function(t,e){return void 0===e&&(e=t),this.world.staticTree.remove(this),this.position.x-=this.offset.x,this.position.y-=this.offset.y,this.offset.set(t,e),this.position.x+=this.offset.x,this.position.y+=this.offset.y,this.updateCenter(),this.world.staticTree.insert(this),this},setSize:function(t,e,i,n){return void 0===i&&(i=this.offset.x),void 0===n&&(n=this.offset.y),this.world.staticTree.remove(this),this.width=t,this.height=e,this.halfWidth=Math.floor(t/2),this.halfHeight=Math.floor(e/2),this.offset.set(i,n),this.updateCenter(),this.isCircle=!1,this.radius=0,this.world.staticTree.insert(this),this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):o(this,t,e)},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},function(t,e){t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},function(t,e,i){var n=i(42);t.exports=function(t,e,i,s){var r=0,o=t.deltaAbsY()+e.deltaAbsY()+s;return 0===t._dy&&0===e._dy?(t.embedded=!0,e.embedded=!0):t._dy>e._dy?(r=t.bottom-e.y)>o&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?r=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.down=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.up=!0)):t._dyo&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?r=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.up=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.down=!0))),t.overlapY=r,e.overlapY=r,r}},function(t,e,i){var n=i(42);t.exports=function(t,e,i,s){var r=0,o=t.deltaAbsX()+e.deltaAbsX()+s;return 0===t._dx&&0===e._dx?(t.embedded=!0,e.embedded=!0):t._dx>e._dx?(r=t.right-e.x)>o&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?r=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.right=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.left=!0)):t._dxo&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?r=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.left=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.right=!0))),t.overlapX=r,e.overlapX=r,r}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=n,this.collideCallback=s,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=n},function(t,e,i){var n=i(32),s=i(0),r=i(42),o=i(150),a=i(14),h=i(31),l=i(64),u=i(6),c=new s({initialize:function(t,e){var i=e.width?e.width:64,n=e.height?e.height:64;this.world=t,this.gameObject=e,this.transform={x:e.x,y:e.y,rotation:e.angle,scaleX:e.scaleX,scaleY:e.scaleY,displayOriginX:e.displayOriginX,displayOriginY:e.displayOriginY},this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new u,this.position=new u(e.x,e.y),this.prev=new u(e.x,e.y),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=i,this.height=n,this.sourceWidth=i,this.sourceHeight=n,e.frame&&(this.sourceWidth=e.frame.realWidth,this.sourceHeight=e.frame.realHeight),this.halfWidth=Math.abs(i/2),this.halfHeight=Math.abs(n/2),this.center=new u(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=new u,this.newVelocity=new u,this.deltaMax=new u,this.acceleration=new u,this.allowDrag=!0,this.drag=new u,this.allowGravity=!0,this.gravity=new u,this.bounce=new u,this.worldBounce=null,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.maxVelocity=new u(1e4,1e4),this.friction=new u(1,0),this.useDamping=!1,this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=r.FACING_NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.physicsType=r.DYNAMIC_BODY,this._reset=!0,this._sx=e.scaleX,this._sy=e.scaleY,this._dx=0,this._dy=0,this._bounds=new a,this._tempMatrix=new l},updateBounds:function(){var t=this.gameObject,e=this.transform;if(t.parentContainer){var i=t.getWorldTransformMatrix(this._tempMatrix);e.x=i.tx,e.y=i.ty,e.rotation=o(i.rotation),e.scaleX=i.scaleX,e.scaleY=i.scaleY}else e.x=t.x,e.y=t.y,e.rotation=t.angle,e.scaleX=t.scaleX,e.scaleY=t.scaleY;var n=!1;if(this.syncBounds){var s=t.getBounds(this._bounds);this.width=s.width,this.height=s.height,n=!0}else{var r=Math.abs(e.scaleX),a=Math.abs(e.scaleY);this._sx===r&&this._sy===a||(this.width=this.sourceWidth*r,this.height=this.sourceHeight*a,this._sx=r,this._sy=a,n=!0)}n&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},update:function(t){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds();var e=this.transform;if(this.position.x=e.x+e.scaleX*(this.offset.x-e.displayOriginX),this.position.y=e.y+e.scaleY*(this.offset.y-e.displayOriginY),this.updateCenter(),this.rotation=e.rotation,this.preRotation=this.rotation,this._reset&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves){this.world.updateMotion(this,t);var i=this.velocity.x,n=this.velocity.y;this.newVelocity.set(i*t,n*t),this.position.add(this.newVelocity),this.updateCenter(),this.angle=Math.atan2(n,i),this.speed=Math.sqrt(i*i+n*n),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.world.emit("worldbounds",this,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)}this._dx=this.deltaX(),this._dy=this.deltaY()},postUpdate:function(){this._dx=this.deltaX(),this._dy=this.deltaY(),this.moves&&(0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.gameObject.x+=this._dx,this.gameObject.y+=this._dy,this._reset=!0),this._dx<0?this.facing=r.FACING_LEFT:this._dx>0&&(this.facing=r.FACING_RIGHT),this._dy<0?this.facing=r.FACING_UP:this._dy>0&&(this.facing=r.FACING_DOWN),this.allowRotation&&(this.gameObject.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y},checkWorldBounds:function(){var t=this.position,e=this.world.bounds,i=this.world.checkCollision,n=this.worldBounce?-this.worldBounce.x:-this.bounce.x,s=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=n,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=s,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setSize:function(t,e,i){void 0===i&&(i=!0);var n=this.gameObject;if(this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&n.getCenter){var s=n.displayWidth/2,r=n.displayHeight/2;this.offset.set(s-this.halfWidth,r-this.halfHeight)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i.setPosition(t,e),i.getTopLeft(this.position),this.prev.copy(this.position),this.rotation=i.angle,this.preRotation=i.angle,this.updateBounds(),this.updateCenter()},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):h(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this._dx>0?this._dx:-this._dx},deltaAbsY:function(){return this._dy>0?this._dy:-this._dy},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,n=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor),this.isCircle?t.strokeCircle(i,n,this.width/2):t.strokeRect(e.x,e.y,this.width,this.height)),this.debugShowVelocity&&(t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.velocity.x/2,n+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t){return void 0===t&&(t=!0),this.collideWorldBounds=t,this},setVelocity:function(t,e){return this.velocity.set(t,e),this},setVelocityX:function(t){return this.velocity.x=t,this},setVelocityY:function(t){return this.velocity.y=t,this},setMaxVelocity:function(t,e){return this.maxVelocity.set(t,e),this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setAllowDrag:function(t){return void 0===t&&(t=!0),this.allowDrag=t,this},setAllowGravity:function(t){return void 0===t&&(t=!0),this.allowGravity=t,this},setAllowRotation:function(t){return void 0===t&&(t=!0),this.allowRotation=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return void 0===t&&(t=!0),this.immovable=t,this},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=c},function(t,e,i){var n=i(339),s=i(23),r=i(0),o=i(338),a=i(42),h=i(58),l=i(9),u=i(351),c=i(350),d=i(349),f=i(337),p=i(336),g=i(4),v=i(223),y=i(689),m=i(14),x=i(222),w=i(688),b=i(683),T=i(682),S=i(70),A=i(334),C=i(335),M=i(6),_=i(39),E=new r({Extends:l,initialize:function(t,e){l.call(this),this.scene=t,this.bodies=new S,this.staticBodies=new S,this.pendingDestroy=new S,this.colliders=new v,this.gravity=new M(g(e,"gravity.x",0),g(e,"gravity.y",0)),this.bounds=new m(g(e,"x",0),g(e,"y",0),g(e,"width",t.sys.game.config.width),g(e,"height",t.sys.game.config.height)),this.checkCollision={up:g(e,"checkCollision.up",!0),down:g(e,"checkCollision.down",!0),left:g(e,"checkCollision.left",!0),right:g(e,"checkCollision.right",!0)},this.fps=g(e,"fps",60),this._elapsed=0,this._frameTime=1/this.fps,this._frameTimeMS=1e3*this._frameTime,this.stepsLastFrame=0,this.timeScale=g(e,"timeScale",1),this.OVERLAP_BIAS=g(e,"overlapBias",4),this.TILE_BIAS=g(e,"tileBias",16),this.forceX=g(e,"forceX",!1),this.isPaused=g(e,"isPaused",!1),this._total=0,this.drawDebug=g(e,"debug",!1),this.debugGraphic,this.defaults={debugShowBody:g(e,"debugShowBody",!0),debugShowStaticBody:g(e,"debugShowStaticBody",!0),debugShowVelocity:g(e,"debugShowVelocity",!0),bodyDebugColor:g(e,"debugBodyColor",16711935),staticBodyDebugColor:g(e,"debugStaticBodyColor",255),velocityDebugColor:g(e,"debugVelocityColor",65280)},this.maxEntries=g(e,"maxEntries",16),this.useTree=g(e,"useTree",!0),this.tree=new x(this.maxEntries),this.staticTree=new x(this.maxEntries),this.treeMinMax={minX:0,minY:0,maxX:0,maxY:0},this.drawDebug&&this.createDebugGraphic()},enable:function(t,e){void 0===e&&(e=a.DYNAMIC_BODY),Array.isArray(t)||(t=[t]);for(var i=0;i=s;)this._elapsed-=s,i++,this.step(n);this.stepsLastFrame=i}},step:function(t){var e,i,n=this.bodies.entries,s=n.length;for(e=0;e0){var l=this.tree,u=this.staticTree;for(o=(r=s.entries).length,t=0;ta.bottom)&&(h.xa.right))return this.separateCircle(t,e,s)}var l=!1,u=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)l.right&&(a=h(u.x,u.y,l.right,l.y)-u.radius):u.y>l.bottom&&(u.xl.right&&(a=h(u.x,u.y,l.right,l.bottom)-u.radius)),a*=-1}else a=t.halfWidth+e.halfWidth-h(t.center.x,t.center.y,e.center.x,e.center.y);if(i||0===a||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==a&&(t.onOverlap||e.onOverlap)&&this.emit("overlap",t.gameObject,e.gameObject,t,e),0!==a;var c=t.velocity.x,d=t.velocity.y,g=t.mass,v=e.velocity.x,y=e.velocity.y,m=e.mass,x=c*Math.cos(o)+d*Math.sin(o),w=c*Math.sin(o)-d*Math.cos(o),b=v*Math.cos(o)+y*Math.sin(o),T=v*Math.sin(o)-y*Math.cos(o),S=((g-m)*x+2*m*b)/(g+m),A=(2*g*x+(m-g)*b)/(g+m);t.immovable||(t.velocity.x=(S*Math.cos(o)-w*Math.sin(o))*t.bounce.x,t.velocity.y=(w*Math.cos(o)+S*Math.sin(o))*t.bounce.y,c=t.velocity.x,d=t.velocity.y),e.immovable||(e.velocity.x=(A*Math.cos(o)-T*Math.sin(o))*e.bounce.x,e.velocity.y=(T*Math.cos(o)+A*Math.sin(o))*e.bounce.y,v=e.velocity.x,y=e.velocity.y),Math.abs(o)0&&!t.immovable&&v>c?t.velocity.x*=-1:v<0&&!e.immovable&&c0&&!t.immovable&&y>d?t.velocity.y*=-1:y<0&&!e.immovable&&dMath.PI/2&&(c<0&&!t.immovable&&v0&&!e.immovable&&c>v?e.velocity.x*=-1:d<0&&!t.immovable&&y0&&!e.immovable&&c>y&&(e.velocity.y*=-1));var C=this._frameTime;return t.immovable||(t.x+=t.velocity.x*C-a*Math.cos(o),t.y+=t.velocity.y*C-a*Math.sin(o)),e.immovable||(e.x+=e.velocity.x*C+a*Math.cos(o),e.y+=e.velocity.y*C+a*Math.sin(o)),(t.onCollide||e.onCollide)&&this.emit("collide",t.gameObject,e.gameObject,t,e),!0},intersects:function(t,e){return t!==e&&(t.isCircle||e.isCircle?t.isCircle?e.isCircle?h(t.center.x,t.center.y,e.center.x,e.center.y)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):this.circleBodyIntersects(e,t):!(t.right<=e.position.x||t.bottom<=e.position.y||t.position.x>=e.right||t.position.y>=e.bottom))},circleBodyIntersects:function(t,e){var i=s(t.center.x,e.left,e.right),n=s(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!0)},collide:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!1)},collideObjects:function(t,e,i,n,s,r){var o;t.isParent&&void 0===t.physicsType&&(t=t.children.entries),e&&e.isParent&&void 0===e.physicsType&&(e=e.children.entries);var a=Array.isArray(t),h=Array.isArray(e);if(this._total=0,a||h)if(!a&&h)for(o=0;o0},collideHandler:function(t,e,i,n,s,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,n,s,r);if(!t||!e)return!1;if(t.body){if(e.body)return this.collideSpriteVsSprite(t,e,i,n,s,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,n,s,r)}else if(t.isParent){if(e.body)return this.collideSpriteVsGroup(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,n,s,r)}else if(t.isTilemap){if(e.body)return this.collideSpriteVsTilemapLayer(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,n,s,r)}},collideSpriteVsSprite:function(t,e,i,n,s,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,n,s,r)&&(i&&i.call(s,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,n,s,r){var o,h,l,u=t.body;if(0!==e.length&&u&&u.enable)if(this.useTree){var c=this.treeMinMax;c.minX=u.left,c.minY=u.top,c.maxX=u.right,c.maxY=u.bottom;var d=e.physicsType===a.DYNAMIC_BODY?this.tree.search(c):this.staticTree.search(c);for(h=d.length,o=0;oc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,l+=d}c.tileHeight>c.baseTileHeight&&(u+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f,p=e.getTilesWithinWorldXY(a,h,l,u);if(0===p.length)return!1;for(var g={left:0,right:0,top:0,bottom:0},v=0;ve-i}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)=0?t:t+2*Math.PI}},function(t,e,i){var n=i(0),s=i(18),r=i(70),o=i(9),a=i(7),h=i(1),l=i(12),u=i(75),c=new n({Extends:o,initialize:function(t){o.call(this);var e=t.sys.game.config,i=t.sys.settings.loader;this.scene=t,this.systems=t.sys,this.cacheManager=t.sys.cache,this.textureManager=t.sys.textures,a.install(this),this.prefix="",this.path="",this.baseURL="",this.setBaseURL(h(i,"baseURL",e.loaderBaseURL)),this.setPath(h(i,"path",e.loaderPath)),this.setPrefix(h(i,"prefix",e.loaderPrefix)),this.maxParallelDownloads=h(i,"maxParallelDownloads",e.loaderMaxParallelDownloads),this.xhr=u(h(i,"responseType",e.loaderResponseType),h(i,"async",e.loaderAsync),h(i,"user",e.loaderUser),h(i,"password",e.loaderPassword),h(i,"timeout",e.loaderTimeout)),this.crossOrigin=h(i,"crossOrigin",e.loaderCrossOrigin),this.totalToLoad=0,this.progress=0,this.list=new r,this.inflight=new r,this.queue=new r,this._deleteQueue=new r,this.totalFailed=0,this.totalComplete=0,this.state=s.LOADER_IDLE,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.pluginStart,this)},boot:function(){this.systems.events.once("destroy",this.destroy,this)},pluginStart:function(){this.systems.events.once("shutdown",this.shutdown,this)},setBaseURL:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.baseURL=t,this},setPath:function(t){return void 0===t&&(t=""),""!==t&&"/"!==t.substr(-1)&&(t=t.concat("/")),this.path=t,this},setPrefix:function(t){return void 0===t&&(t=""),this.prefix=t,this},setCORS:function(t){return this.crossOrigin=t,this},addFile:function(t){Array.isArray(t)||(t=[t]);for(var e=0;e0},isLoading:function(){return this.state===s.LOADER_LOADING||this.state===s.LOADER_PROCESSING},isReady:function(){return this.state===s.LOADER_IDLE||this.state===s.LOADER_COMPLETE},start:function(){this.isReady()&&(this.progress=0,this.totalFailed=0,this.totalComplete=0,this.totalToLoad=this.list.size,this.emit("start",this),0===this.list.size?this.loadComplete():(this.state=s.LOADER_LOADING,this.inflight.clear(),this.queue.clear(),this.updateProgress(),this.checkLoadQueue(),this.systems.events.on("update",this.update,this)))},updateProgress:function(){this.progress=1-(this.list.size+this.inflight.size)/this.totalToLoad,this.emit("progress",this.progress)},update:function(){this.state===s.LOADER_LOADING&&this.list.size>0&&this.inflight.size0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(s=!0,i=n(t,e))}else s=!0,i=n(t,e);return!s&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e,i){var n=i(0),s=i(9),r=i(4),o=i(76),a=i(171),h=i(109),l=i(170),u=i(369),c=i(368),d=i(367),f=new n({Extends:s,initialize:function(t){s.call(this),this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.enabled=!0,this.target,this.keys=[],this.combos=[],this.queue=[],this.onKeyHandler,t.pluginEvents.once("boot",this.boot,this),t.pluginEvents.on("start",this.start,this)},boot:function(){var t=this.settings.input,e=this.scene.sys.game.config;this.enabled=r(t,"keyboard",e.inputKeyboard),this.target=r(t,"keyboard.target",e.inputKeyboardEventTarget),this.sceneInputPlugin.pluginEvents.once("destroy",this.destroy,this)},start:function(){this.enabled&&this.startListeners(),this.sceneInputPlugin.pluginEvents.once("shutdown",this.shutdown,this)},isActive:function(){return this.enabled&&this.scene.sys.isActive()},startListeners:function(){var t=this,e=function(e){if(!e.defaultPrevented&&t.isActive()){t.queue.push(e);var i=t.keys[e.keyCode];i&&i.preventDefault&&e.preventDefault()}};this.onKeyHandler=e,this.target.addEventListener("keydown",e,!1),this.target.addEventListener("keyup",e,!1),this.sceneInputPlugin.pluginEvents.on("update",this.update,this)},stopListeners:function(){this.target.removeEventListener("keydown",this.onKeyHandler),this.target.removeEventListener("keyup",this.onKeyHandler),this.sceneInputPlugin.pluginEvents.off("update",this.update)},createCursorKeys:function(){return this.addKeys({up:h.UP,down:h.DOWN,left:h.LEFT,right:h.RIGHT,space:h.SPACE,shift:h.SHIFT})},addKeys:function(t){var e={};if("string"==typeof t){t=t.split(",");for(var i=0;i-1?e[i]=t:e[t.keyCode]=t,t}return"string"==typeof t&&(t=h[t.toUpperCase()]),e[t]||(e[t]=new a(t)),e[t]},removeKey:function(t){var e=this.keys;if(t instanceof a){var i=e.indexOf(t);i>-1&&(this.keys[i]=void 0)}else"string"==typeof t&&(t=h[t.toUpperCase()]);e[t]&&(e[t]=void 0)},createCombo:function(t,e){return new l(this,t,e)},update:function(){var t=this.queue.length;if(this.enabled&&0!==t)for(var e=this.queue.splice(0,t),i=this.keys,n=0;n=e}}},function(t,e,i){var n=i(88),s=i(32),r=i(0),o=i(175),a=i(375),h=i(58),l=i(114),u=i(54),c=i(9),d=i(1),f=i(76),p=i(8),g=i(12),v=i(14),y=i(31),m=i(68),x=i(60),w=new r({Extends:c,initialize:function(t){c.call(this),this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.manager=t.sys.game.input,this.pluginEvents=new c,this.enabled=!0,this.displayList,this.cameras,f.install(this),this.mouse=this.manager.mouse,this.topOnly=!0,this.pollRate=-1,this._pollTimer=0,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this._temp=[],this._tempZones=[],this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],this._draggable=[],this._drag={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._over={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._validTypes=["onDown","onUp","onOver","onOut","onMove","onDragStart","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop"],t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.cameras=this.systems.cameras,this.displayList=this.systems.displayList,this.systems.events.once("destroy",this.destroy,this),this.pluginEvents.emit("boot")},start:function(){var t=this.systems.events;t.on("transitionstart",this.transitionIn,this),t.on("transitionout",this.transitionOut,this),t.on("transitioncomplete",this.transitionComplete,this),t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this),this.enabled=!0,this.pluginEvents.emit("start")},preUpdate:function(){this.pluginEvents.emit("preUpdate");var t=this._pendingRemoval,e=this._pendingInsertion,i=t.length,n=e.length;if(0!==i||0!==n){for(var s=this._list,r=0;r-1&&(s.splice(a,1),this.clear(o))}t.length=0,this._pendingRemoval.length=0,this._list=s.concat(e.splice(0))}},isActive:function(){return this.enabled&&this.scene.sys.isActive()},update:function(t,e){if(this.isActive()){this.pluginEvents.emit("update",t,e);var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var n=i.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(n=!0,this._pollTimer=this.pollRate)),n)for(var s=this.manager.pointers,r=0;r0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}}},clear:function(t){var e=t.input;if(e){this.queueForRemoval(t),e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t}},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,n){return void 0===n&&(n=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input&&n&&!t.input.dropZone&&(t.input.dropZone=n),this},hitTestPointer:function(t){for(var e=this.cameras.getCamerasBelowPointer(t),i=0;i0)return t.camera=n,s}return[]},processDownEvents:function(t){var e=this._temp;this.emit("pointerdown",t,e);for(var i=0,n=0;n0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var a=[];for(i=0;i1&&(this.sortGameObjects(a),this.topOnly&&a.splice(1)),this._drag[t.id]=a,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&h(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(s=this._drag[t.id],i=0;i0?(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),l[0]?(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):r.target=null)}else!r.target&&l[0]&&(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target));var c=t.x-n.input.dragX,d=t.y-n.input.dragY;n.emit("drag",t,c,d),this.emit("drag",t,n,c,d)}return s.length}if(5===t.dragState){for(s=this._drag[t.id],i=0;i0)for(this.sortGameObjects(s),this.emit("pointerout",t,s),e=0;e0)for(this.sortGameObjects(r),this.emit("pointerover",t,r),e=0;e-1&&this._draggable.splice(s,1)}return this},makePixelPerfect:function(t){void 0===t&&(t=1);var e=this.systems.textures;return a(e,t)},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);var n=!1,s=!1,r=!1,a=!1;if(p(e)){var h=e;e=d(h,"hitArea",null),i=d(h,"hitAreaCallback",null),n=d(h,"draggable",!1),s=d(h,"dropZone",!1),r=d(h,"cursor",!1),a=d(h,"useHandCursor",!1);var l=d(h,"pixelPerfect",!1),u=d(h,"alphaTolerance",1);l&&(e={},i=this.makePixelPerfect(u)),e&&i||this.setHitAreaFromTexture(t)}else"function"!=typeof e||i||(i=e,e={});for(var c=0;ct.width*t.height)&&e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottom0){var d=(a*r+h*o)/l;u*=d,c*=d}return i.x=t.x1+u,i.y=t.y1+c,u*u+c*c<=l&&u*r+c*o>=0&&n(e,i.x,i.y)}},function(t,e){t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.righte.right||t.y>e.bottom)}},function(t,e,i){t.exports={CircleToCircle:i(844),CircleToRectangle:i(843),GetRectangleIntersection:i(842),LineToCircle:i(397),LineToLine:i(144),LineToRectangle:i(841),PointToLine:i(396),PointToLineSegment:i(840),RectangleToRectangle:i(398),RectangleToTriangle:i(839),RectangleToValues:i(838),TriangleToCircle:i(837),TriangleToLine:i(836),TriangleToTriangle:i(835)}},function(t,e,i){t.exports={Circle:i(854),Ellipse:i(249),Intersects:i(399),Line:i(834),Point:i(816),Polygon:i(802),Rectangle:i(389),Triangle:i(774)}},function(t,e,i){var n=i(0),s=i(402),r=i(148),o=i(27),a=new n({initialize:function(){this.lightPool=[],this.lights=[],this.culledLights=[],this.ambientColor={r:.1,g:.1,b:.1},this.active=!1},enable:function(){return this.active=!0,this},disable:function(){return this.active=!1,this},cull:function(t){var e=this.lights,i=this.culledLights,n=e.length,s=t.x+t.width/2,o=t.y+t.height/2,a=(t.width+t.height)/2,h={x:0,y:0},l=t.matrix,u=this.systems.game.config.height;i.length=0;for(var c=0;c0?(h=this.lightPool.pop()).set(t,e,i,a[0],a[1],a[2],r):h=new s(t,e,i,a[0],a[1],a[2],r),this.lights.push(h),h},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&(this.lightPool.push(t),this.lights.splice(e,1)),this},shutdown:function(){for(;this.lights.length>0;)this.lightPool.push(this.lights.pop());this.ambientColor={r:.1,g:.1,b:.1},this.culledLights.length=0,this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=a},function(t,e,i){var n=i(0),s=i(27),r=new n({initialize:function(t,e,i,n,s,r,o){this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1},set:function(t,e,i,n,s,r,o){return this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1,this},setScrollFactor:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this},setColor:function(t){var e=s.getFloatsFromUintRGB(t);return this.r=e[0],this.g=e[1],this.b=e[2],this},setIntensity:function(t){return this.intensity=t,this},setPosition:function(t,e){return this.x=t,this.y=e,this},setRadius:function(t){return this.radius=t,this}});t.exports=r},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(110);s.register("text",function(t,e){void 0===t&&(t={});var i=r(t,"text",""),s=r(t,"style",null),a=r(t,"padding",null);null!==a&&(s.padding=a);var h=new o(this.scene,0,0,i,s);return void 0!==e&&(t.add=e),n(this.scene,h,t),h.autoRound=r(t,"autoRound",!0),h.resolution=r(t,"resolution",1),h})},function(t,e,i){var n=i(24),s=i(127),r=i(13),o=i(10),a=i(34);r.register("sprite",function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),h=new a(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),n(this.scene,h,t),s(h,t),h})},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(69);s.register("image",function(t,e){void 0===t&&(t={});var i=r(t,"key",null),s=r(t,"frame",null),a=new o(this.scene,0,0,i,s);return void 0!==e&&(t.add=e),n(this.scene,a,t),a})},function(t,e,i){var n=i(13),s=i(115);n.register("graphics",function(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=new s(this.scene,t);return t.add&&this.scene.sys.displayList.add(i),i})},function(t,e,i){var n=i(110);i(11).register("text",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(11),s=i(34);n.register("sprite",function(t,e,i,n){var r=new s(this.scene,t,e,i,n);return this.displayList.add(r),this.updateList.add(r),r})},function(t,e,i){var n=i(69);i(11).register("image",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(115);i(11).register("graphics",function(t){return this.displayList.add(new n(this.scene,t))})},function(t,e){t.exports=function(t){var e=Math.log(t)/.6931471805599453;return 1<r;h--){for(l=0;l0&&e.cameraFilter&s._id||""===e.text)){var o=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,o.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,o.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var a=e.canvas;if(o.save(),void 0!==r){var h=r.matrix;o.transform(h[0],h[1],h[2],h[3],h[4],h[5])}var l=e.x-s.scrollX*e.scrollFactorX,u=e.y-s.scrollY*e.scrollFactorY;t.config.roundPixels&&(l|=0,u|=0),o.translate(l,u),o.rotate(e.rotation),o.scale(e.scaleX,e.scaleY),o.translate(a.width*(e.flipX?1:0),a.height*(e.flipY?1:0)),o.scale(e.flipX?-1:1,e.flipY?-1:1),o.drawImage(a,0,0,a.width,a.height,-e.displayOriginX,-e.displayOriginY,a.width,a.height),o.restore()}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||""===e.text||(e.dirty&&(e.canvasTexture=t.canvasToTexture(e.canvas,e.canvasTexture),e.dirty=!1),this.pipeline.batchText(this,s,r))}},function(t,e,i){var n=i(3),s=i(3);n=i(415),s=i(414),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e,i){var n=t.canvas,s=t.context,r=t.style,o=[],a=0,h=i.length;r.maxLines>0&&r.maxLinesc&&(f=-c),0!==f&&(d+=f>0?f*i.length:f*(i.length-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},function(t,e,i){var n=i(0),s=i(38),r=i(62),o=i(4),a=i(34),h=i(61),l=i(6),u=new n({Extends:a,initialize:function(t,e,i,n,s,r){a.call(this,t,i,n,s,r),this.path=e,this.rotateToPath=!1,this.pathRotationVerticalAdjust=!1,this.pathRotationOffset=0,this.pathOffset=new l(i,n),this.pathVector=new l,this.pathTween,this.pathConfig=null,this._prevDirection=h.PLAYING_FORWARD},setPath:function(t,e){void 0===e&&(e=this.pathConfig);var i=this.pathTween;return i&&i.isPlaying()&&i.stop(),this.path=t,e&&this.startFollow(e),this},setRotateToPath:function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=!1),this.rotateToPath=t,this.pathRotationOffset=e,this.pathRotationVerticalAdjust=i,this},isFollowing:function(){var t=this.pathTween;return t&&t.isPlaying()},startFollow:function(t,e){void 0===t&&(t={}),void 0===e&&(e=0);var i=this.pathTween;i&&i.isPlaying()&&i.stop(),"number"==typeof t&&(t={duration:t}),t.from=0,t.to=1;var n=r(t,"positionOnPath",!1);if(this.rotateToPath=r(t,"rotateToPath",!1),this.pathRotationOffset=o(t,"rotationOffset",0),this.pathRotationVerticalAdjust=r(t,"verticalAdjust",!1),this.pathTween=this.scene.sys.tweens.addCounter(t),this.path.getStartPoint(this.pathOffset),n&&(this.x=this.pathOffset.x,this.y=this.pathOffset.y),this.pathOffset.x=this.x-this.pathOffset.x,this.pathOffset.y=this.y-this.pathOffset.y,this._prevDirection=h.PLAYING_FORWARD,this.rotateToPath){var a=this.path.getPoint(.1);this.rotation=Math.atan2(a.y-this.y,a.x-this.x)+s(this.pathRotationOffset)}return this.pathConfig=t,this},pauseFollow:function(){var t=this.pathTween;return t&&t.isPlaying()&&t.pause(),this},resumeFollow:function(){var t=this.pathTween;return t&&t.isPaused()&&t.resume(),this},stopFollow:function(){var t=this.pathTween;return t&&t.isPlaying()&&t.stop(),this},preUpdate:function(t,e){this.anims.update(t,e);var i=this.pathTween;if(i){var n=i.data[0];if(n.state!==h.PLAYING_FORWARD&&n.state!==h.PLAYING_BACKWARD)return;var r=this.pathVector;this.path.getPoint(i.getValue(),r),r.add(this.pathOffset);var o=this.x,a=this.y;this.setPosition(r.x,r.y);var l=this.x-o,u=this.y-a;if(0===l&&0===u)return;if(n.state!==this._prevDirection)return void(this._prevDirection=n.state);this.rotateToPath&&(this.rotation=Math.atan2(u,l)+s(this.pathRotationOffset),this.pathRotationVerticalAdjust&&(this.flipY=0!==this.rotation&&n.state===h.PLAYING_BACKWARD))}}});t.exports=u},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t){this.source=t,this._tempVec=new s},getPoint:function(t){var e=this._tempVec;this.source.getRandomPoint(e),t.x=e.x,t.y=e.y}});t.exports=r},function(t,e){t.exports=function(t,e){for(var i=0;i=1?1:1/e*(1+(e*t|0))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e,i){var n=i(247),s=i(246),r=i(245),o=i(244),a=i(243),h=i(242),l=i(241),u=i(240),c=i(239),d=i(238),f=i(237),p=i(236);t.exports={Power0:l,Power1:u.Out,Power2:o.Out,Power3:c.Out,Power4:d.Out,Linear:l,Quad:u.Out,Cubic:o.Out,Quart:c.Out,Quint:d.Out,Sine:f.Out,Expo:h.Out,Circ:r.Out,Elastic:a.Out,Back:n.Out,Bounce:s.Out,Stepped:p,"Quad.easeIn":u.In,"Cubic.easeIn":o.In,"Quart.easeIn":c.In,"Quint.easeIn":d.In,"Sine.easeIn":f.In,"Expo.easeIn":h.In,"Circ.easeIn":r.In,"Elastic.easeIn":a.In,"Back.easeIn":n.In,"Bounce.easeIn":s.In,"Quad.easeOut":u.Out,"Cubic.easeOut":o.Out,"Quart.easeOut":c.Out,"Quint.easeOut":d.Out,"Sine.easeOut":f.Out,"Expo.easeOut":h.Out,"Circ.easeOut":r.Out,"Elastic.easeOut":a.Out,"Back.easeOut":n.Out,"Bounce.easeOut":s.Out,"Quad.easeInOut":u.InOut,"Cubic.easeInOut":o.InOut,"Quart.easeInOut":c.InOut,"Quint.easeInOut":d.InOut,"Sine.easeInOut":f.InOut,"Expo.easeInOut":h.InOut,"Circ.easeInOut":r.InOut,"Elastic.easeInOut":a.InOut,"Back.easeInOut":n.InOut,"Bounce.easeInOut":s.InOut}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s){void 0===n&&(n=!1),void 0===s&&(s=!0),this.source=t,this.points=[],this.quantity=e,this.stepRate=i,this.yoyo=n,this.counter=-1,this.seamless=s,this._length=0,this._direction=0,this.updateSource()},updateSource:function(){if(this.points=this.source.getPoints(this.quantity,this.stepRate),this.seamless){var t=this.points[0],e=this.points[this.points.length-1];t.x===e.x&&t.y===e.y&&this.points.pop()}var i=this._length;return this._length=this.points.length,this._lengththis._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=this.source.contains(t.x,t.y);return e&&this.killOnEnter||!e&&!this.killOnEnter}});t.exports=n},function(t,e,i){var n=i(51),s=i(0),r=i(15),o=i(455),a=i(454),h=i(899),l=i(1),u=i(146),c=i(420),d=i(111),f=i(457),p=i(419),g=i(14),v=i(83),y=i(6),m=i(39),x=new s({Mixins:[r.BlendMode,r.Mask,r.ScrollFactor,r.Visible],initialize:function(t,e){this.manager=t,this.texture=t.texture,this.frames=[t.defaultFrame],this.defaultFrame=t.defaultFrame,this.configFastMap=["active","blendMode","collideBottom","collideLeft","collideRight","collideTop","deathCallback","deathCallbackScope","emitCallback","emitCallbackScope","follow","frequency","gravityX","gravityY","maxParticles","name","on","particleBringToTop","particleClass","radial","timeScale","trackVisible","visible"],this.configOpMap=["accelerationX","accelerationY","angle","alpha","bounce","delay","lifespan","maxVelocityX","maxVelocityY","moveToX","moveToY","quantity","rotate","scaleX","scaleY","speedX","speedY","tint","x","y"],this.name="",this.particleClass=f,this.x=new h(e,"x",0),this.y=new h(e,"y",0),this.radial=!0,this.gravityX=0,this.gravityY=0,this.acceleration=!1,this.accelerationX=new h(e,"accelerationX",0,!0),this.accelerationY=new h(e,"accelerationY",0,!0),this.maxVelocityX=new h(e,"maxVelocityX",1e4,!0),this.maxVelocityY=new h(e,"maxVelocityY",1e4,!0),this.speedX=new h(e,"speedX",0,!0),this.speedY=new h(e,"speedY",0,!0),this.moveTo=!1,this.moveToX=new h(e,"moveToX",0,!0),this.moveToY=new h(e,"moveToY",0,!0),this.bounce=new h(e,"bounce",0,!0),this.scaleX=new h(e,"scaleX",1),this.scaleY=new h(e,"scaleY",1),this.tint=new h(e,"tint",4294967295),this.alpha=new h(e,"alpha",1),this.lifespan=new h(e,"lifespan",1e3),this.angle=new h(e,"angle",{min:0,max:360}),this.rotate=new h(e,"rotate",0),this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.maxParticles=0,this.quantity=new h(e,"quantity",1,!0),this.delay=new h(e,"delay",0,!0),this.frequency=0,this.on=!0,this.particleBringToTop=!0,this.timeScale=1,this.emitZone=null,this.deathZone=null,this.bounds=null,this.collideLeft=!0,this.collideRight=!0,this.collideTop=!0,this.collideBottom=!0,this.active=!0,this.visible=!0,this.blendMode=n.NORMAL,this.follow=null,this.followOffset=new y,this.trackVisible=!1,this.currentFrame=0,this.randomFrame=!0,this.frameQuantity=1,this.dead=[],this.alive=[],this._counter=0,this._frameCounter=0,e&&this.fromJSON(e)},fromJSON:function(t){if(!t)return this;var e=0,i="";for(e=0;e0&&this.getParticleCount()===this.maxParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,n=i.length,s=0;s0?n.pop():new this.particleClass(this)).fire(e,i),this.particleBringToTop?this.alive.push(r):this.alive.unshift(r),this.emitCallback&&this.emitCallback.call(this.emitCallbackScope,r,this),this.atLimit())break}return r}},preUpdate:function(t,e){var i=(e*=this.timeScale)/1e3;this.trackVisible&&(this.visible=this.follow.visible);for(var n=this.manager.getProcessors(),s=this.alive,r=s.length,o=0;o0){var u=s.splice(s.length-l,l),c=this.deathCallback,d=this.deathCallbackScope;if(c)for(var f=0;f0&&(this._counter-=e,this._counter<=0&&(this.emitParticle(),this._counter=this.frequency-Math.abs(this._counter))))},depthSortCallback:function(t,e){return t.y-e.y},indexSortCallback:function(t,e){return t.index-e.index}});t.exports=x},function(t,e,i){var n=i(0),s=i(38),r=i(58),o=function(t){return(t>>16)+(65280&t)+((255&t)<<16)},a=new n({initialize:function(t){this.emitter=t,this.frame=null,this.index=0,this.x=0,this.y=0,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.tint=16777215,this.color=16777215,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215,current:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1}}},isAlive:function(){return this.lifeCurrent>0},fire:function(t,e){var i=this.emitter;this.frame=i.getFrame(),i.emitZone&&i.emitZone.getPoint(this),void 0===t?(i.follow&&(this.x+=i.follow.x+i.followOffset.x),this.x+=i.x.onEmit(this,"x")):this.x+=t,void 0===e?(i.follow&&(this.y+=i.follow.y+i.followOffset.y),this.y+=i.y.onEmit(this,"y")):this.y+=e,this.life=i.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0;var n=i.speedX.onEmit(this,"speedX"),a=i.speedY?i.speedY.onEmit(this,"speedY"):n;if(i.radial){var h=s(i.angle.onEmit(this,"angle"));this.velocityX=Math.cos(h)*Math.abs(n),this.velocityY=Math.sin(h)*Math.abs(a)}else if(i.moveTo){var l=i.moveToX.onEmit(this,"moveToX"),u=i.moveToY?i.moveToY.onEmit(this,"moveToY"):l,c=Math.atan2(u-this.y,l-this.x),d=r(this.x,this.y,l,u)/(this.life/1e3);this.velocityX=Math.cos(c)*d,this.velocityY=Math.sin(c)*d}else this.velocityX=n,this.velocityY=a;i.acceleration&&(this.accelerationX=i.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=i.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=i.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=i.maxVelocityY.onEmit(this,"maxVelocityY"),this.delayCurrent=i.delay.onEmit(this,"delay"),this.scaleX=i.scaleX.onEmit(this,"scaleX"),this.scaleY=i.scaleY?i.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=i.rotate.onEmit(this,"rotate"),this.rotation=s(this.angle),this.bounce=i.bounce.onEmit(this,"bounce"),this.alpha=i.alpha.onEmit(this,"alpha"),this.tint=i.tint.onEmit(this,"tint");var f=255&(255*this.alpha|0);this.color=(f<<24|o(this.tint))>>>0,this.index=i.alive.length},computeVelocity:function(t,e,i,n){var s=this.velocityX,r=this.velocityY,o=this.accelerationX,a=this.accelerationY,h=this.maxVelocityX,l=this.maxVelocityY;s+=t.gravityX*i,r+=t.gravityY*i,o&&(s+=o*i),a&&(r+=a*i),s>h?s=h:s<-h&&(s=-h),r>l?r=l:r<-l&&(r=-l),this.velocityX=s,this.velocityY=r;for(var u=0;ue.right&&t.collideRight&&(this.x=e.right,this.velocityX*=i),this.ye.bottom&&t.collideBottom&&(this.y=e.bottom,this.velocityY*=i)},update:function(t,e,i){if(this.delayCurrent>0)return this.delayCurrent-=t,!1;var n=this.emitter,r=1-this.lifeCurrent/this.life;if(this.lifeT=r,this.computeVelocity(n,t,e,i),this.x+=this.velocityX*e,this.y+=this.velocityY*e,n.bounds&&this.checkBounds(n),n.deathZone&&n.deathZone.willKill(this))return this.lifeCurrent=0,!0;this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),n.scaleY?this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY):this.scaleY=this.scaleX,this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=s(this.angle),this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),this.tint=n.tint.onUpdate(this,"tint",r,this.tint);var a=255&(255*this.alpha|0);return this.color=(a<<24|o(this.tint))>>>0,this.lifeCurrent-=t,this.lifeCurrent<=0}});t.exports=a},function(t,e,i){var n=i(0),s=i(1),r=new n({initialize:function(t,e,i,n,r){if("object"==typeof t){var o=t;t=s(o,"x",0),e=s(o,"y",0),i=s(o,"power",0),n=s(o,"epsilon",100),r=s(o,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=50);this.x=t,this.y=e,this.active=!0,this._gravity=r,this._power=0,this._epsilon=0,this.power=i,this.epsilon=n},update:function(t,e){var i=this.x-t.x,n=this.y-t.y,s=i*i+n*n;if(0!==s){var r=Math.sqrt(s);s0&&e.cameraFilter&s._id||t.drawImage(e,s,r)}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(460),s=i(459),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchGraphics(this,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(462),s=i(176),s=i(176),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(14);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e,i){var n=i(54);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(54);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(114);t.exports=function(t){return new n(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},function(t,e,i){var n=i(14);t.exports=function(t,e,i){void 0===i&&(i=new n);var s=Math.min(t.x,e.x),r=Math.min(t.y,e.y),o=Math.max(t.right,e.right)-s,a=Math.max(t.bottom,e.bottom)-r;return i.setTo(s,r,o,a)}},function(t,e){function i(t,e){return parseInt(t.getAttribute(e),10)}t.exports=function(t,e,n,s){void 0===e&&(e=0),void 0===n&&(n=0);var r={},o=t.getElementsByTagName("info")[0],a=t.getElementsByTagName("common")[0];r.font=o.getAttribute("face"),r.size=i(o,"size"),r.lineHeight=i(a,"lineHeight")+n,r.chars={};var h=t.getElementsByTagName("char"),l=void 0!==s&&s.trimmed;if(l)var u=s.height,c=s.width;for(var d=0;dm&&(s=m),r>x&&(r=x);var A=m+v-s,C=x+y-r;o-1&&this._list.splice(s,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;i0&&(t.splice(i,1),t.unshift(e)),e}},function(t,e){t.exports=function(t,e,i){var n=t.indexOf(e),s=t.indexOf(i);return-1!==n&&-1===s&&(t[n]=i,!0)}},function(t,e,i){var n=i(56);t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return n(t,s)}},function(t,e,i){var n=i(29);t.exports=function(t,e,i,s,r){if(void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===r&&(r=t),n(t,e,i)){var o=i-e,a=t.splice(e,o);if(s)for(var h=0;ht.length-1)throw new Error("Index out of bounds");var r=n(t,e);return i&&i.call(s,r),r}},function(t,e,i){var n=i(255);t.exports=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=null),void 0===i&&(i=1),null===e&&(e=t,t=0);for(var s=[],r=Math.max(n((e-t)/(i||1)),0),o=0;o=t.length)throw new Error("Supplied index out of bounds");return n!==i&&(t.splice(n,1),t.splice(i,0,e)),e}},function(t,e){t.exports=function(t,e){var i=t.indexOf(e);if(i>0){var n=t[i-1],s=t.indexOf(n);t[i]=n,t[s]=e}return t}},function(t,e,i){var n=i(29);t.exports=function(t,e,i,s,r){if(void 0===s&&(s=0),void 0===r&&(r=t.length),n(t,s,r))for(var o=s;o0){var o=n-t.length;if(o<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.splice(i,0,e),s&&s.call(r,e),e):null;for(var a=e.length-1;a>=0;)-1!==t.indexOf(e[a])&&e.pop(),a--;if(0===(a=e.length))return null;n>0&&a>o&&(e.splice(o),a=o);for(var h=a;h>0;h--){var l=e[h];t.splice(i,0,l),s&&s.call(r,l)}return e}},function(t,e){t.exports=function(t,e,i,n,s){if(void 0===s&&(s=t),i>0){var r=i-t.length;if(r<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.push(e),n&&n.call(s,e),e):null;for(var o=e.length-1;o>=0;)-1!==t.indexOf(e[o])&&e.pop(),o--;if(0===(o=e.length))return null;i>0&&o>r&&(e.splice(r),o=r);for(var a=0;a0||!this.inFocus)&&(this._coolDown--,r=Math.min(r,this._target)),r>this._min&&(r=n[i],r=Math.min(r,this._min)),n[i]=r,this.deltaIndex++,this.deltaIndex>s&&(this.deltaIndex=0);for(var o=0,a=0;athis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var h=o/this._target;this.callback(t,o,h),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=a},function(t,e){var i=0,n=function(t,e,n,s){var r=i-s.y-s.height;t.add(n,e,s.x,r,s.width,s.height)};t.exports=function(t,e,s){var r=t.source[e];t.add("__BASE",e,0,0,r.width,r.height),i=r.height;for(var o=s.split("\n"),a=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",l="",u={x:0,y:0,width:0,height:0},c=0;cx||a<-x)&&(a=0),a<0&&(a=x+a),-1!==h&&(x=a+(h+1));for(var M=l,_=l,E=0,P=e.sourceIndex,k=0;kg||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var v=f,y=f,m=0,x=0,w=0;wr&&(m=b-r),T>o&&(x=T-o),t.add(w,e,i+v,s+y,h-m,l-x),(v+=h+p)+h>r&&(v=f,y+=l+p)}return t}},function(t,e,i){var n=i(33);t.exports=function(t,e,i){if(i.frames){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);var r,o=i.frames;for(var a in o){var h=o[a];r=t.add(a,e,h.frame.x,h.frame.y,h.frame.w,h.frame.h),h.trimmed&&r.setTrim(h.sourceSize.w,h.sourceSize.h,h.spriteSourceSize.x,h.spriteSourceSize.y,h.spriteSourceSize.w,h.spriteSourceSize.h),h.rotated&&(r.rotated=!0,r.updateUVsInverted()),r.customData=n(h)}for(var l in i)"frames"!==l&&(Array.isArray(i[l])?t.customData[l]=i[l].slice(0):t.customData[l]=i[l]);return t}console.warn("Invalid Texture Atlas JSON Hash given, missing 'frames' Object")}},function(t,e,i){var n=i(33);t.exports=function(t,e,i){if(i.frames||i.textures){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);for(var r,o=Array.isArray(i.textures)?i.textures[e].frames:i.frames,a=0;a=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(s.dolby=!0)}}catch(t){}return s}()},function(t,e,i){var n=i(57),s=i(80),r={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),n.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){t.exports={os:i(57),browser:i(80),features:i(120),input:i(522),audio:i(521),video:i(520),fullscreen:i(519),canvasFeatures:i(203)}},function(t,e,i){var n=i(20);t.exports=function(t){var e=t.config;if(!e.hideBanner){var i="WebGL";e.renderType===n.CANVAS?i="Canvas":e.renderType===n.HEADLESS&&(i="Headless");var s,r=e.audio,o=t.device.audio;if(s=!o.webAudio||r&&r.disableWebAudio?r&&r.noAudio||!o.webAudio&&!o.audioData?"No Audio":"HTML5 Audio":"Web Audio",t.device.browser.ie)window.console&&console.log("Phaser v"+n.VERSION+" / https://phaser.io");else{var a,h="",l=[h];Array.isArray(e.bannerBackgroundColor)?(e.bannerBackgroundColor.forEach(function(t){h=h.concat("%c "),l.push("background: "+t),a=t}),l[l.length-1]="color: "+e.bannerTextColor+"; background: "+a):(h=h.concat("%c "),l.push("color: "+e.bannerTextColor+"; background: "+e.bannerBackgroundColor)),l.push("background: #fff"),e.gameTitle&&(h=h.concat(e.gameTitle),e.gameVersion&&(h=h.concat(" v"+e.gameVersion)),e.hidePhaser||(h=h.concat(" / "))),e.hidePhaser||(h=h.concat("Phaser v"+n.VERSION+" ("+i+" | "+s+")")),h=h.concat(" %c "+e.gameURL),l[0]=h,console.log.apply(console,l)}}}},function(t,e){t.exports=["#define SHADER_NAME PHASER_TEXTURE_TINT_VS","","precision mediump float;","","uniform mat4 uProjectionMatrix;","uniform mat4 uViewMatrix;","uniform mat4 uModelMatrix;","","attribute vec2 inPosition;","attribute vec2 inTexCoord;","attribute vec4 inTint;","","varying vec2 outTexCoord;","varying vec4 outTint;","","void main ()","{"," gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);"," outTexCoord = inTexCoord;"," outTint = inTint;","}","",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_TEXTURE_TINT_FS","","precision mediump float;","","uniform sampler2D uMainSampler;","","varying vec2 outTexCoord;","varying vec4 outTint;","","void main()","{"," vec4 texel = texture2D(uMainSampler, outTexCoord);"," texel *= vec4(outTint.rgb * outTint.a, outTint.a);"," gl_FragColor = texel;","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_FORWARD_DIFFUSE_FS","","precision mediump float;","","struct Light","{"," vec2 position;"," vec3 color;"," float intensity;"," float radius;","};","","const int kMaxLights = %LIGHT_COUNT%;","","uniform vec4 uCamera; /* x, y, rotation, zoom */","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uNormSampler;","uniform vec3 uAmbientLightColor;","uniform Light uLights[kMaxLights];","","varying vec2 outTexCoord;","varying vec4 outTint;","","void main()","{"," vec3 finalColor = vec3(0.0, 0.0, 0.0);"," vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);"," vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;"," vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));"," vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;",""," for (int index = 0; index < kMaxLights; ++index)"," {"," Light light = uLights[index];"," vec3 lightDir = vec3((light.position.xy / res) - (gl_FragCoord.xy / res), 0.1);"," vec3 lightNormal = normalize(lightDir);"," float distToSurf = length(lightDir) * uCamera.w;"," float diffuseFactor = max(dot(normal, lightNormal), 0.0);"," float radius = (light.radius / res.x * uCamera.w) * uCamera.w;"," float attenuation = clamp(1.0 - distToSurf * distToSurf / (radius * radius), 0.0, 1.0);"," vec3 diffuse = light.color * diffuseFactor;"," finalColor += (attenuation * diffuse) * light.intensity;"," }",""," vec4 colorOutput = vec4(uAmbientLightColor + finalColor, 1.0);"," gl_FragColor = color * vec4(colorOutput.rgb * colorOutput.a, colorOutput.a);","","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_FLAT_TINT_VS","","precision mediump float;","","uniform mat4 uProjectionMatrix;","uniform mat4 uViewMatrix;","uniform mat4 uModelMatrix;","","attribute vec2 inPosition;","attribute vec4 inTint;","","varying vec4 outTint;","","void main () {"," gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);"," outTint = inTint;","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_FLAT_TINT_FS","","precision mediump float;","","varying vec4 outTint;","","void main() {"," gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_VS","","precision mediump float;","","attribute vec2 inPosition;","","void main()","{"," gl_Position = vec4(inPosition, 0.0, 1.0);","}",""].join("\n")},function(t,e){t.exports=["#define SHADER_NAME PHASER_BITMAP_MASK_FS","","precision mediump float;","","uniform vec2 uResolution;","uniform sampler2D uMainSampler;","uniform sampler2D uMaskSampler;","uniform bool uInvertMaskAlpha;","","void main()","{"," vec2 uv = gl_FragCoord.xy / uResolution;"," vec4 mainColor = texture2D(uMainSampler, uv);"," vec4 maskColor = texture2D(uMaskSampler, uv);"," float alpha = mainColor.a;",""," if (!uInvertMaskAlpha)"," {"," alpha *= (maskColor.a);"," }"," else"," {"," alpha *= (1.0 - maskColor.a);"," }",""," gl_FragColor = vec4(mainColor.rgb * alpha, alpha);","}",""].join("\n")},function(t,e,i){var n=i(272),s=i(22),r=i(20),o=i(120);t.exports=function(t){var e,a,h=t.config;if(h.renderType!==r.HEADLESS)if(h.renderType===r.CANVAS||h.renderType!==r.CANVAS&&!o.webGL){if(!o.canvas)throw new Error("Cannot create Canvas or WebGL context, aborting.");h.renderType=r.CANVAS}else h.renderType=r.WEBGL;h.pixelArt&&s.disableSmoothing(),h.canvas?t.canvas=h.canvas:t.canvas=s.create(t,h.width,h.height,h.renderType),h.canvasStyle&&(t.canvas.style=h.canvasStyle),h.pixelArt&&n.setCrisp(t.canvas),1!==h.zoom&&(t.canvas.style.width=(h.width*h.zoom).toString()+"px",t.canvas.style.height=(h.height*h.zoom).toString()+"px"),h.renderType!==r.HEADLESS&&(e=i(267),a=i(262),h.renderType===r.WEBGL?(t.renderer=new a(t),t.context=null):(t.renderer=new e(t),t.context=t.renderer.gameContext))}},function(t,e,i){var n=i(0),s=i(20),r=i(1),o=i(4),a=i(8),h=i(16),l=i(3),u=i(121),c=i(132),d=new n({initialize:function(t){void 0===t&&(t={});this.width=o(t,"width",1024),this.height=o(t,"height",768),this.zoom=o(t,"zoom",1),this.resolution=o(t,"resolution",1),this.renderType=o(t,"type",s.AUTO),this.parent=o(t,"parent",null),this.canvas=o(t,"canvas",null),this.context=o(t,"context",null),this.canvasStyle=o(t,"canvasStyle",null),this.sceneConfig=o(t,"scene",null),this.seed=o(t,"seed",[(Date.now()*Math.random()).toString()]),h.RND.init(this.seed),this.gameTitle=o(t,"title",""),this.gameURL=o(t,"url","https://phaser.io"),this.gameVersion=o(t,"version",""),this.autoFocus=o(t,"autoFocus",!0),this.inputKeyboard=o(t,"input.keyboard",!0),this.inputKeyboardEventTarget=o(t,"input.keyboard.target",window),this.inputMouse=o(t,"input.mouse",!0),this.inputMouseEventTarget=o(t,"input.mouse.target",null),this.inputMouseCapture=o(t,"input.mouse.capture",!0),this.inputTouch=o(t,"input.touch",!0),this.inputTouchEventTarget=o(t,"input.touch.target",null),this.inputTouchCapture=o(t,"input.touch.capture",!0),this.inputActivePointers=o(t,"input.activePointers",1),this.inputGamepad=o(t,"input.gamepad",!1),this.inputGamepadEventTarget=o(t,"input.gamepad.target",window),this.disableContextMenu=o(t,"disableContextMenu",!1),this.audio=o(t,"audio"),this.hideBanner=!1===o(t,"banner",null),this.hidePhaser=o(t,"banner.hidePhaser",!1),this.bannerTextColor=o(t,"banner.text","#ffffff"),this.bannerBackgroundColor=o(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=o(t,"fps",null);var e=o(t,"render",t);this.antialias=o(e,"antialias",!0),this.pixelArt=o(e,"pixelArt",!1),this.autoResize=o(e,"autoResize",!1),this.roundPixels=o(e,"roundPixels",!1),this.transparent=o(e,"transparent",!1),this.clearBeforeRender=o(e,"clearBeforeRender",!0),this.premultipliedAlpha=o(e,"premultipliedAlpha",!0),this.preserveDrawingBuffer=o(e,"preserveDrawingBuffer",!1),this.failIfMajorPerformanceCaveat=o(e,"failIfMajorPerformanceCaveat",!1),this.powerPreference=o(e,"powerPreference","default");var i=o(t,"backgroundColor",0);this.backgroundColor=c(i),0===i&&this.transparent&&(this.backgroundColor.alpha=0),this.preBoot=o(t,"callbacks.preBoot",l),this.postBoot=o(t,"callbacks.postBoot",l),this.physics=o(t,"physics",{}),this.defaultPhysicsSystem=o(this.physics,"default",!1),this.loaderBaseURL=o(t,"loader.baseURL",""),this.loaderPath=o(t,"loader.path",""),this.loaderMaxParallelDownloads=o(t,"loader.maxParallelDownloads",32),this.loaderCrossOrigin=o(t,"loader.crossOrigin",void 0),this.loaderResponseType=o(t,"loader.responseType",""),this.loaderAsync=o(t,"loader.async",!0),this.loaderUser=o(t,"loader.user",""),this.loaderPassword=o(t,"loader.password",""),this.loaderTimeout=o(t,"loader.timeout",0),this.installGlobalPlugins=[],this.installScenePlugins=[];var n=o(t,"plugins",null),d=u.DefaultScene;n&&(Array.isArray(n)?this.defaultPlugins=n:a(n)&&(this.installGlobalPlugins=r(n,"global",[]),this.installScenePlugins=r(n,"scene",[]),Array.isArray(n.default)?d=n.default:Array.isArray(n.defaultMerge)&&(d=d.concat(n.defaultMerge)))),this.defaultPlugins=d;var f="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=o(t,"images.default",f+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=o(t,"images.missing",f+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==")}});t.exports=d},function(t,e,i){var n=i(130),s=i(207),r=i(205),o=i(22),a=i(0),h=i(533),l=i(532),u=i(81),c=i(524),d=i(523),f=i(271),p=i(9),g=i(201),v=i(196),y=i(194),m=i(191),x=i(184),w=i(506),b=i(505),T=new a({initialize:function(t){this.config=new h(t),this.renderer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new p,this.anims=new s(this),this.textures=new x(this),this.cache=new r(this),this.registry=new u(this),this.input=new g(this,this.config),this.scene=new y(this,this.config.sceneConfig),this.device=d,this.sound=m.create(this),this.loop=new w(this,this.config.fps),this.plugins=new v(this,this.config),this.pendingDestroy=!1,this.removeCanvas=!1,this.hasFocus=!1,this.isOver=!0,f(this.boot.bind(this))},boot:function(){this.isBooted=!0,this.config.preBoot(this),l(this),c(this),n(this.canvas,this.config.parent),this.events.emit("boot"),this.events.once("ready",this.start,this)},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),b(this);var t=this.events;t.on("hidden",this.onHidden,this),t.on("visible",this.onVisible,this),t.on("blur",this.onBlur,this),t.on("focus",this.onFocus,this)},step:function(t,e){if(this.pendingDestroy)return this.runDestroy();var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e);var n=this.renderer;n.preRender(),i.emit("prerender",n,t,e),this.scene.render(n),n.postRender(),i.emit("postrender",n,t,e)},headlessStep:function(t,e){var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e),i.emit("prerender"),i.emit("postrender")},onHidden:function(){this.loop.pause(),this.events.emit("pause")},onVisible:function(){this.loop.resume(),this.events.emit("resume")},onBlur:function(){this.hasFocus=!1,this.loop.blur()},onFocus:function(){this.hasFocus=!0,this.loop.focus()},resize:function(t,e){this.config.width=t,this.config.height=e,this.renderer.resize(t,e),this.input.resize(),this.scene.resize(t,e),this.events.emit("resize",t,e)},destroy:function(t){this.pendingDestroy=!0,this.removeCanvas=t},runDestroy:function(){this.events.emit("destroy"),this.events.removeAllListeners(),this.scene.destroy(),this.renderer&&this.renderer.destroy(),this.removeCanvas&&this.canvas&&(o.remove(this.canvas),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)),this.loop.destroy(),this.pendingDestroy=!1}});t.exports=T},function(t,e,i){var n=i(0),s=i(9),r=i(12),o=new n({Extends:s,initialize:function(){s.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",o,"events"),t.exports=o},function(t,e,i){t.exports={EventEmitter:i(535)}},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var h,l=[],u=!1,c=-1;function d(){u&&h&&(u=!1,h.length?l=h.concat(l):c=-1,l.length&&f())}function f(){if(!u){var t=a(d);u=!0;for(var e=l.length;e;){for(h=l,l=[];++c1)for(var i=1;i1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}},function(t,e){t.exports=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},function(t,e,i){var n=i(30);n.ColorToRGBA=i(923),n.ComponentToHex=i(541),n.GetColor=i(152),n.GetColor32=i(284),n.HexStringToColor=i(285),n.HSLToColor=i(922),n.HSVColorWheel=i(921),n.HSVToRGB=i(539),n.HueToComponent=i(540),n.IntegerToColor=i(283),n.IntegerToRGB=i(282),n.Interpolate=i(920),n.ObjectToColor=i(281),n.RandomRGB=i(919),n.RGBStringToColor=i(280),n.RGBToHSV=i(918),n.RGBToString=i(917),n.ValueToColor=i(132),t.exports=n},function(t,e,i){var n=i(0),s=i(81),r=i(12),o=new n({Extends:s,initialize:function(t){s.call(this,t,t.sys.events),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.events=this.systems.events,this.events.once("destroy",this.destroy,this)},start:function(){this.events.once("shutdown",this.shutdown,this)},shutdown:function(){this.systems.events.off("shutdown",this.shutdown,this)},destroy:function(){s.prototype.destroy.call(this),this.events.off("start",this.start,this),this.scene=null,this.systems=null}});r.register("DataManagerPlugin",o,"data"),t.exports=o},function(t,e,i){t.exports={DataManager:i(81),DataManagerPlugin:i(543)}},function(t,e,i){var n=i(273),s=i(0),r=i(86),o=i(6),a=new s({Extends:r,initialize:function(t){void 0===t&&(t=[]),r.call(this,"SplineCurve"),this.points=[],this.addPoints(t)},addPoints:function(t){for(var e=0;ei.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(n(a,h.x,l.x,u.x,c.x),n(a,h.y,l.y,u.y,c.y))},toJSON:function(){for(var t=[],e=0;ei;)n-=i;n0&&e.cameraFilter&s._id||t.drawImage(e,s,r)}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchSprite(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(555),s=i(554),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},fromMat4:function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=n,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=l*r-o*h,c=-l*s+o*a,d=h*s-r*a,f=e*u+i*c+n*d;return f?(f=1/f,t[0]=u*f,t[1]=(-l*i+n*h)*f,t[2]=(o*i-n*r)*f,t[3]=c*f,t[4]=(l*e-n*a)*f,t[5]=(-o*e+n*s)*f,t[6]=d*f,t[7]=(-h*e+i*a)*f,t[8]=(r*e-i*s)*f,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return t[0]=r*l-o*h,t[1]=n*h-i*l,t[2]=i*o-n*r,t[3]=o*a-s*l,t[4]=e*l-n*a,t[5]=n*s-e*o,t[6]=s*h-r*a,t[7]=i*a-e*h,t[8]=e*r-i*s,this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return e*(l*r-o*h)+i*(-l*s+o*a)+n*(h*s-r*a)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=t.val,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=c[6],x=c[7],w=c[8];return e[0]=d*i+f*r+p*h,e[1]=d*n+f*o+p*l,e[2]=d*s+f*a+p*u,e[3]=g*i+v*r+y*h,e[4]=g*n+v*o+y*l,e[5]=g*s+v*a+y*u,e[6]=m*i+x*r+w*h,e[7]=m*n+x*o+w*l,e[8]=m*s+x*a+w*u,this},translate:function(t){var e=this.val,i=t.x,n=t.y;return e[6]=i*e[0]+n*e[3]+e[6],e[7]=i*e[1]+n*e[4]+e[7],e[8]=i*e[2]+n*e[5]+e[8],this},rotate:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=Math.sin(t),l=Math.cos(t);return e[0]=l*i+h*r,e[1]=l*n+h*o,e[2]=l*s+h*a,e[3]=l*r-h*i,e[4]=l*o-h*n,e[5]=l*a-h*s,this},scale:function(t){var e=this.val,i=t.x,n=t.y;return e[0]=i*e[0],e[1]=i*e[1],e[2]=i*e[2],e[3]=n*e[3],e[4]=n*e[4],e[5]=n*e[5],this},fromQuat:function(t){var e=t.x,i=t.y,n=t.z,s=t.w,r=e+e,o=i+i,a=n+n,h=e*r,l=e*o,u=e*a,c=i*o,d=i*a,f=n*a,p=s*r,g=s*o,v=s*a,y=this.val;return y[0]=1-(c+f),y[3]=l+v,y[6]=u-g,y[1]=l-v,y[4]=1-(h+f),y[7]=d+p,y[2]=u+g,y[5]=d-p,y[8]=1-(h+c),this},normalFromMat4:function(t){var e=t.val,i=this.val,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],g=e[12],v=e[13],y=e[14],m=e[15],x=n*h-s*a,w=n*l-r*a,b=n*u-o*a,T=s*l-r*h,S=s*u-o*h,A=r*u-o*l,C=c*v-d*g,M=c*y-f*g,_=c*m-p*g,E=d*y-f*v,P=d*m-p*v,k=f*m-p*y,L=x*k-w*P+b*E+T*_-S*M+A*C;return L?(L=1/L,i[0]=(h*k-l*P+u*E)*L,i[1]=(l*_-a*k-u*M)*L,i[2]=(a*P-h*_+u*C)*L,i[3]=(r*P-s*k-o*E)*L,i[4]=(n*k-r*_+o*M)*L,i[5]=(s*_-n*P-o*C)*L,i[6]=(v*A-y*S+m*T)*L,i[7]=(y*b-g*A-m*w)*L,i[8]=(g*S-v*b+m*x)*L,this):null}});t.exports=n},function(t,e,i){var n=i(0),s=i(87),r=i(557),o=new Int8Array([1,2,0]),a=new Float32Array([0,0,0]),h=new s(1,0,0),l=new s(0,1,0),u=new s,c=new r,d=new n({initialize:function(t,e,i,n){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},set:function(t,e,i,n){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},normalize:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(u.copy(h).cross(t).length()<1e-6&&u.copy(l).cross(t),u.normalize(),this.setAxisAngle(u,Math.PI)):i>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(u.copy(t).cross(e),this.x=u.x,this.y=u.y,this.z=u.z,this.w=1+i,this.normalize())},setAxes:function(t,e,i){var n=c.val;return n[0]=e.x,n[3]=e.y,n[6]=e.z,n[1]=i.x,n[4]=i.y,n[7]=i.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(c).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=Math.cos(e),this},multiply:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.x=e*h+s*r+i*a-n*o,this.y=i*h+s*o+n*r-e*a,this.z=n*h+s*a+e*o-i*r,this.w=s*h-e*r-i*o-n*a,this},slerp:function(t,e){var i=this.x,n=this.y,s=this.z,r=this.w,o=t.x,a=t.y,h=t.z,l=t.w,u=i*o+n*a+s*h+r*l;u<0&&(u=-u,o=-o,a=-a,h=-h,l=-l);var c=1-e,d=e;if(1-u>1e-6){var f=Math.acos(u),p=Math.sin(f);c=Math.sin((1-e)*f)/p,d=Math.sin(e*f)/p}return this.x=c*i+d*o,this.y=c*n+d*a,this.z=c*s+d*h,this.w=c*r+d*l,this},invert:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-e*r,this.z=-i*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+s*r,this.y=i*o+n*r,this.z=n*o-i*r,this.w=s*o-e*r,this},rotateY:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o-n*r,this.y=i*o+s*r,this.z=n*o+e*r,this.w=s*o-i*r,this},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+i*r,this.y=i*o-e*r,this.z=n*o+s*r,this.w=s*o-n*r,this},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(1-t*t-e*e-i*i),this},fromMat3:function(t){var e,i=t.val,n=i[0]+i[4]+i[8];if(n>0)e=Math.sqrt(n+1),this.w=.5*e,e=.5/e,this.x=(i[7]-i[5])*e,this.y=(i[2]-i[6])*e,this.z=(i[3]-i[1])*e;else{var s=0;i[4]>i[0]&&(s=1),i[8]>i[3*s+s]&&(s=2);var r=o[s],h=o[r];e=Math.sqrt(i[3*s+s]-i[3*r+r]-i[3*h+h]+1),a[s]=.5*e,e=.5/e,a[r]=(i[3*r+s]+i[3*s+r])*e,a[h]=(i[3*h+s]+i[3*s+h])*e,this.x=a[0],this.y=a[1],this.z=a[2],this.w=(i[3*h+r]-i[3*r+h])*e}return this}});t.exports=d},function(t,e,i){var n=i(87),s=i(278),r=i(558),o=new s,a=new r,h=new n;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1),t.x=(2*Math.random()-1)*e,t.y=(2*Math.random()-1)*e,t.z=(2*Math.random()-1)*e,t.w=(2*Math.random()-1)*e,t}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1);var i=2*Math.random()*Math.PI,n=2*Math.random()-1,s=Math.sqrt(1-n*n)*e;return t.x=Math.cos(i)*s,t.y=Math.sin(i)*s,t.z=n*e,t}},function(t,e,i){var n=i(123),s=i(0),r=i(1),o=i(12),a=i(31),h=new s({initialize:function(t){this.scene=t,this.systems=t.sys,this.currentCameraId=1,this.cameras=[],this.cameraPool=[],this.main,this.baseScale=1,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){var t=this.systems;t.settings.cameras?this.fromJSON(t.settings.cameras):this.add(),this.main=this.cameras[0],this.systems.events.once("destroy",this.destroy,this)},start:function(){this.main||this.boot();var t=this.systems.events;t.on("update",this.update,this),t.once("shutdown",this.shutdown,this)},add:function(t,e,i,s,r,o){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===s&&(s=this.scene.sys.game.config.height),void 0===r&&(r=!1),void 0===o&&(o="");var a=null;return this.cameraPool.length>0?(a=this.cameraPool.pop()).setViewport(t,e,i,s):a=new n(t,e,i,s),a.setName(o),a.setScene(this.scene),this.cameras.push(a),r&&(this.main=a),a._id=this.currentCameraId,this.currentCameraId=this.currentCameraId<<1,a},addExisting:function(t){var e=this.cameras.indexOf(t),i=this.cameraPool.indexOf(t);return e<0&&i>=0?(this.cameras.push(t),this.cameraPool.slice(i,1),t):null},fromJSON:function(t){Array.isArray(t)||(t=[t]);for(var e=this.scene.sys.game.config.width,i=this.scene.sys.game.config.height,n=0;n=0&&this.cameras.length>1&&(this.cameraPool.push(this.cameras[e]),this.cameras.splice(e,1),this.main===t&&(this.main=this.cameras[0]))},render:function(t,e,i){for(var n=this.cameras,s=this.baseScale,r=0,o=n.length;r0;)this.cameraPool.push(this.cameras.pop());return this.main=this.add(),this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i-h&&(c-=h,n+=l),f=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},function(t,e){var i={_visible:!0,visible:{get:function(){return this._visible},set:function(t){t?(this._visible=!0,this.renderFlags|=1):(this._visible=!1,this.renderFlags&=-2)}},setVisible:function(t){return this.visible=t,this}};t.exports=i},function(t,e,i){var n=i(16),s=i(64),r=i(212),o=i(211),a={_scaleX:1,_scaleY:1,_rotation:0,x:0,y:0,z:0,w:0,scaleX:{get:function(){return this._scaleX},set:function(t){this._scaleX=t,0===this._scaleX?this.renderFlags&=-5:this.renderFlags|=4}},scaleY:{get:function(){return this._scaleY},set:function(t){this._scaleY=t,0===this._scaleY?this.renderFlags&=-5:this.renderFlags|=4}},angle:{get:function(){return o(this._rotation*n.RAD_TO_DEG)},set:function(t){this.rotation=o(t)*n.DEG_TO_RAD}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=r(t)}},setPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=i,this.w=n,this},setRandomPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),this.x=t+Math.random()*i,this.y=e+Math.random()*n,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,this},setScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this},setX:function(t){return void 0===t&&(t=0),this.x=t,this},setY:function(t){return void 0===t&&(t=0),this.y=t,this},setZ:function(t){return void 0===t&&(t=0),this.z=t,this},setW:function(t){return void 0===t&&(t=0),this.w=t,this},getLocalTransformMatrix:function(t){return void 0===t&&(t=new s),t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY)},getWorldTransformMatrix:function(t){void 0===t&&(t=new s);var e=this.parentContainer;if(!e)return this.getLocalTransformMatrix(t);for(var i=[];e;)i.unshift(e),e=e.parentContainer;t.loadIdentity();for(var n=i.length,r=0;r>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,clearTint:function(){return this.setTint(16777215),this},setTint:function(t,e,n,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,n=t,s=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(n),this._tintBR=i(s),this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t)}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t)}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t)}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t)}},tint:{set:function(t){this.setTint(t,t,t,t)}}};t.exports=n},function(t,e){var i={texture:null,frame:null,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e,i){var n=i(59),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e){var i={matrixStack:null,currentMatrix:null,currentMatrixIndex:0,initMatrixStack:function(){return this.matrixStack=new Float32Array(6e3),this.currentMatrix=new Float32Array([1,0,0,1,0,0]),this.currentMatrixIndex=0,this},save:function(){if(this.currentMatrixIndex>=this.matrixStack.length)return this;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return this.currentMatrixIndex+=6,t[i+0]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=e[3],t[i+4]=e[4],t[i+5]=e[5],this},restore:function(){if(this.currentMatrixIndex<=0)return this;this.currentMatrixIndex-=6;var t=this.matrixStack,e=this.currentMatrix,i=this.currentMatrixIndex;return e[0]=t[i+0],e[1]=t[i+1],e[2]=t[i+2],e[3]=t[i+3],e[4]=t[i+4],e[5]=t[i+5],this},loadIdentity:function(){return this.setTransform(1,0,0,1,0,0),this},transform:function(t,e,i,n,s,r){var o=this.currentMatrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=a*t+l*e,o[1]=h*t+u*e,o[2]=a*i+l*n,o[3]=h*i+u*n,o[4]=a*s+l*r+c,o[5]=h*s+u*r+d,this},setTransform:function(t,e,i,n,s,r){var o=this.currentMatrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},translate:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3],a=i[4],h=i[5];return i[4]=n*t+r*e+a,i[5]=s*t+o*e+h,this},scale:function(t,e){var i=this.currentMatrix,n=i[0],s=i[1],r=i[2],o=i[3];return i[0]=n*t,i[1]=s*t,i[2]=r*e,i[3]=o*e,this},rotate:function(t){var e=this.currentMatrix,i=e[0],n=e[1],s=e[2],r=e[3],o=Math.sin(t),a=Math.cos(t);return e[0]=i*a+s*o,e[1]=n*a+r*o,e[2]=i*-o+s*a,e[3]=n*-o+r*a,this}};t.exports=i},function(t,e,i){var n=i(214),s=i(213),r={mask:null,setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask.destroy(),this.mask=null,this},createBitmapMask:function(t){return void 0===t&&this.texture&&(t=this),new n(this.scene,t)},createGeometryMask:function(t){return void 0===t&&"Graphics"===this.type&&(t=this),new s(this.scene,t)}};t.exports=r},function(t,e,i){var n=i(14),s=i(292),r=i(6),o={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getTopRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBounds:function(t){var e,i,s,r,o,a,h,l;if(void 0===t&&(t=new n),this.parentContainer){var u=this.parentContainer.getBoundsTransformMatrix();this.getTopLeft(t),u.transformPoint(t.x,t.y,t),e=t.x,i=t.y,this.getTopRight(t),u.transformPoint(t.x,t.y,t),s=t.x,r=t.y,this.getBottomLeft(t),u.transformPoint(t.x,t.y,t),o=t.x,a=t.y,this.getBottomRight(t),u.transformPoint(t.x,t.y,t),h=t.x,l=t.y}else this.getTopLeft(t),e=t.x,i=t.y,this.getTopRight(t),s=t.x,r=t.y,this.getBottomLeft(t),o=t.x,a=t.y,this.getBottomRight(t),h=t.x,l=t.y;return t.x=Math.min(e,s,o,h),t.y=Math.min(i,r,a,l),t.width=Math.max(e,s,o,h)-t.x,t.height=Math.max(i,r,a,l)-t.y,t}};t.exports=o},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e){var i={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.scene.sys.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=i},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}}},function(t,e,i){var n=i(51),s={_blendMode:n.NORMAL,blendMode:{get:function(){return this._blendMode},set:function(t){"string"==typeof t&&(t=n[t]),(t|=0)>=0&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,e,i){var n=i(23),s={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,s){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=n(t,0,1),this._alphaTR=n(e,0,1),this._alphaBL=n(i,0,1),this._alphaBR=n(s,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=n(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=n(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=n(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=n(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=n(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=s},function(t,e,i){var n=i(46),s=i(44),r=i(45),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(92),s=i(44),r=i(91),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(89),s=i(46),r=i(90),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(89),s=i(48),r=i(90),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(91),s=i(90);t.exports=function(t,e,i){return n(t,e),s(t,i)}},function(t,e,i){var n=i(593),s=i(92),r=i(89);t.exports=function(t,e,i,o){return void 0===i&&(i=0),void 0===o&&(o=0),n(t,s(e)+i,r(e)+o),t}},function(t,e,i){var n=i(50),s=i(46),r=i(49),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(48),r=i(49),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(92),r=i(49),o=i(91);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(299),s=[];s[n.BOTTOM_CENTER]=i(597),s[n.BOTTOM_LEFT]=i(596),s[n.BOTTOM_RIGHT]=i(595),s[n.CENTER]=i(594),s[n.LEFT_CENTER]=i(592),s[n.RIGHT_CENTER]=i(591),s[n.TOP_CENTER]=i(590),s[n.TOP_LEFT]=i(589),s[n.TOP_RIGHT]=i(588);t.exports=function(t,e,i,n,r){return s[i](t,e,n,r)}},function(t,e,i){t.exports={Angle:i(1007),Call:i(1006),GetFirst:i(1005),GetLast:i(1004),GridAlign:i(1003),IncAlpha:i(1002),IncX:i(1001),IncXY:i(1e3),IncY:i(999),PlaceOnCircle:i(998),PlaceOnEllipse:i(997),PlaceOnLine:i(996),PlaceOnRectangle:i(995),PlaceOnTriangle:i(994),PlayAnimation:i(993),PropertyValueInc:i(35),PropertyValueSet:i(25),RandomCircle:i(992),RandomEllipse:i(991),RandomLine:i(990),RandomRectangle:i(989),RandomTriangle:i(988),Rotate:i(987),RotateAround:i(986),RotateAroundDistance:i(985),ScaleX:i(984),ScaleXY:i(983),ScaleY:i(982),SetAlpha:i(981),SetBlendMode:i(980),SetDepth:i(979),SetHitArea:i(978),SetOrigin:i(977),SetRotation:i(976),SetScale:i(975),SetScaleX:i(974),SetScaleY:i(973),SetTint:i(972),SetVisible:i(971),SetX:i(970),SetXY:i(969),SetY:i(968),ShiftPosition:i(967),Shuffle:i(966),SmootherStep:i(965),SmoothStep:i(964),Spread:i(963),ToggleVisible:i(962),WrapInRectangle:i(961)}},function(t,e){if("function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var i=function(t){var e=new Array;window[t]=function(t){if("number"==typeof t){Array.call(this,t),this.length=t;for(var e=0;e>>0;if("function"!=typeof t)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,s=0;s0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=this.tileset,a=t.gameContext,h=r.length,l=o.image.getSourceImage(),u=e.x-s.scrollX*e.scrollFactorX,c=e.y-s.scrollY*e.scrollFactorY;a.save(),a.translate(u,c),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY),a.scale(e.flipX?-1:1,e.flipY?-1:1),a.globalAlpha=e.alpha;for(var d=0;d0&&e.cameraFilter&s._id||(e.upload(s),this.pipeline.drawStaticTilemapLayer(e,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(623),s=i(622),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){e.cull(s);var r=e.culledTiles,o=r.length,a=e.tileset.image.getSourceImage(),h=this.tileset,l=e.x-s.scrollX*e.scrollFactorX,u=e.y-s.scrollY*e.scrollFactorY,c=t.gameContext;c.save(),c.translate(l,u),c.rotate(e.rotation),c.scale(e.scaleX,e.scaleY),c.scale(e.flipX?-1:1,e.flipY?-1:1);for(var d=0;d0&&e.cameraFilter&s._id||(e.cull(s),this.pipeline.batchDynamicTilemapLayer(e,s))}},function(t,e,i){var n=i(3),s=i(3);n=i(626),s=i(625),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(137);t.exports=function(t){for(var e=[],i=[],s=0;s-1?new s(a,f,c,u,o.tilesize,o.tilesize):e?null:new s(a,-1,c,u,o.tilesize,o.tilesize),h.push(d)}l.push(h),h=[]}a.data=l,i.push(a)}return i}},function(t,e,i){var n=i(17);t.exports=function(t){for(var e,i,s,r,o,a=0;a>>0;return n}},function(t,e,i){var n=i(636),s=i(1),r=i(104),o=i(316),a=i(66);t.exports=function(t,e){for(var i=[],h=0;h0){var y=new a(u,v.gid,c,f.length,t.tilewidth,t.tileheight);y.rotation=v.rotation,y.flipX=v.flipped,d.push(y)}else{var m=e?null:new a(u,-1,c,f.length,t.tilewidth,t.tileheight);d.push(m)}++c===l.width&&(f.push(d),c=0,d=[])}u.data=f,i.push(u)}}return i}},function(t,e,i){t.exports={Parse:i(319),Parse2DArray:i(217),ParseCSV:i(318),Impact:i(312),Tiled:i(317)}},function(t,e,i){var n=i(53),s=i(52),r=i(6);t.exports=function(t,e,i,o,a,h){return void 0===o&&(o=new r(0,0)),o.x=n(t,i,a,h),o.y=s(e,i,a,h),o}},function(t,e,i){var n=i(21);t.exports=function(t,e,i,s,r,o){if(void 0!==r){var a,h=n(t,e,i,s,null,o),l=0;for(a=0;a0&&n(a,t)}}e&&s(0,0,i.width,i.height,i)}},function(t,e,i){var n=i(67),s=i(40),r=i(111);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0);for(var a=0;ae)){for(var h=t;h<=e;h++)r(h,i,a);for(var l=0;l=t&&c.index<=e&&n(c,i)}o&&s(0,0,a.width,a.height,a)}}},function(t,e,i){var n=i(67),s=i(40),r=i(218);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a=0;r--)for(s=n.width-1;s>=0;s--)if((o=n.data[r][s])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;r=S&&L>=A&&k+a<=C&&L+h<=M&&i.push(P)}}return i}},function(t,e,i){var n=i(139),s=i(138),r=i(21),o=i(322);t.exports=function(t,e,i,a,h,l){void 0===i&&(i={}),Array.isArray(t)||(t=[t]);var u=l.tilemapLayer;void 0===a&&(a=u.scene),void 0===h&&(h=a.cameras.main);var c,d=r(0,0,l.width,l.height,null,l),f=[];for(c=0;c=0&&p=0&&gr?(s.warn("Plugin.register:",n.toString(e),"was upgraded to",n.toString(t)),n._registry[t.name]=t):i-1},n.isFor=function(t,e){var i=t.for&&n.dependencyParse(t.for);return!t.for||e.name===i.name&&n.versionSatisfies(e.version,i.range)},n.use=function(t,e){if(t.uses=(t.uses||[]).concat(e||[]),0!==t.uses.length){for(var i=n.dependencies(t),r=s.topologicalSort(i),o=[],a=0;a0&&!h.silent&&s.info(o.join(" "))}else s.warn("Plugin.use:",n.toString(t),"does not specify any dependencies to install.")},n.dependencies=function(t,e){var i=n.dependencyParse(t),r=i.name;if(!(r in(e=e||{}))){t=n.resolve(t)||t,e[r]=s.map(t.uses||[],function(e){n.isPlugin(e)&&n.register(e);var r=n.dependencyParse(e),o=n.resolve(e);return o&&!n.versionSatisfies(o.version,r.range)?(s.warn("Plugin.dependencies:",n.toString(o),"does not satisfy",n.toString(r),"used by",n.toString(i)+"."),o._warned=!0,t._warned=!0):o||(s.warn("Plugin.dependencies:",n.toString(e),"used by",n.toString(i),"could not be resolved."),t._warned=!0),r.name});for(var o=0;o=s[2];if("^"===i.operator)return s[0]>0?o[0]===s[0]&&r.number>=i.number:s[1]>0?o[1]===s[1]&&o[2]>=s[2]:o[2]===s[2]}return t===e||"*"===t}},function(t,e,i){var n=i(1013);n.Body=i(74),n.Composite=i(221),n.World=i(674),n.Detector=i(678),n.Grid=i(1012),n.Pairs=i(1011),n.Pair=i(610),n.Query=i(1033),n.Resolver=i(1010),n.SAT=i(677),n.Constraint=i(300),n.Common=i(41),n.Engine=i(1009),n.Events=i(301),n.Sleeping=i(331),n.Plugin=i(675),n.Bodies=i(166),n.Composites=i(1016),n.Axes=i(680),n.Bounds=i(125),n.Svg=i(1031),n.Vector=i(106),n.Vertices=i(126),n.World.add=n.Composite.add,n.World.remove=n.Composite.remove,n.World.addComposite=n.Composite.addComposite,n.World.addBody=n.Composite.addBody,n.World.addConstraint=n.Composite.addConstraint,n.World.clear=n.Composite.clear,t.exports=n},function(t,e,i){var n={};t.exports=n;var s=i(126),r=i(106);!function(){n.collides=function(e,n,o){var a,h,l,u,c=!1;if(o){var d=e.parent,f=n.parent,p=d.speed*d.speed+d.angularSpeed*d.angularSpeed+f.speed*f.speed+f.angularSpeed*f.angularSpeed;c=o&&o.collided&&p<.2,u=o}else u={collided:!1,bodyA:e,bodyB:n};if(o&&c){var g=u.axisBody,v=g===e?n:e,y=[g.axes[o.axisNumber]];if(l=t(g.vertices,v.vertices,y),u.reused=!0,l.overlap<=0)return u.collided=!1,u}else{if((a=t(e.vertices,n.vertices,e.axes)).overlap<=0)return u.collided=!1,u;if((h=t(n.vertices,e.vertices,n.axes)).overlap<=0)return u.collided=!1,u;a.overlaps?s=a:a=0?o.index-1:u.length-1],l.x=s.x-c.x,l.y=s.y-c.y,h=-r.dot(i,l),a=s,s=u[(o.index+1)%u.length],l.x=s.x-c.x,l.y=s.y-c.y,(n=-r.dot(i,l))1?1:0;d1?1:0;p0:0!=(t.mask&e.category)&&0!=(e.mask&t.category)}},function(t,e,i){var n=i(166),s=i(74),r=i(0),o=i(611),a=i(1),h=i(111),l=i(126),u=new r({Mixins:[o.Bounce,o.Collision,o.Friction,o.Gravity,o.Mass,o.Sensor,o.Sleep,o.Static],initialize:function(t,e,i){this.tile=e,this.world=t,e.physics.matterBody&&e.physics.matterBody.destroy(),e.physics.matterBody=this;var n=a(i,"body",null),s=a(i,"addToWorld",!0);if(n)this.setBody(n,s);else{var r=e.getCollisionGroup();a(r,"objects",[]).length>0?this.setFromTileCollision(i):this.setFromTileRectangle(i)}},setFromTileRectangle:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);var e=this.tile.getBounds(),i=e.x+e.width/2,s=e.y+e.height/2,r=n.rectangle(i,s,e.width,e.height,t);return this.setBody(r,t.addToWorld),this},setFromTileCollision:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);for(var e=this.tile.tilemapLayer.scaleX,i=this.tile.tilemapLayer.scaleY,r=this.tile.getLeft(),o=this.tile.getTop(),u=this.tile.getCollisionGroup(),c=a(u,"objects",[]),d=[],f=0;f1&&(t.parts=d,this.setBody(s.create(t),t.addToWorld)),this},setBody:function(t,e){return void 0===e&&(e=!0),this.body&&this.removeBody(),this.body=t,this.body.gameObject=this,e&&this.world.add(this.body),this},removeBody:function(){return this.body&&(this.world.remove(this.body),this.body.gameObject=void 0,this.body=void 0),this},destroy:function(){this.removeBody(),this.tile.physics.matterBody=void 0}});t.exports=u},function(t,e,i){var n={};t.exports=n;var s=i(106),r=i(41);n.fromVertices=function(t){for(var e={},i=0;i0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.y=u+h*t.bounce.y,e.velocity.y=u+l*e.bounce.y}return!0}},function(t,e,i){var n=i(337);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.x,a=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=r,e.velocity.x=o-a*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=r,t.velocity.x=a-o*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{r*=.5,t.x-=r,e.x+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.x=u+h*t.bounce.x,e.velocity.x=u+l*e.bounce.x}return!0}},function(t,e){t.exports=function(t,e){e<0?t.blocked.up=!0:e>0&&(t.blocked.down=!0),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},function(t,e,i){var n=i(684);t.exports=function(t,e,i,s,r){var o=0;return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom>i&&(o=t.bottom-i)>r&&(o=0),0!==o&&(t.customSeparateY?t.overlapY=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?t.blocked.left=!0:e>0&&(t.blocked.right=!0),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},function(t,e,i){var n=i(686);t.exports=function(t,e,i,s,r){var o=0;return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right>i&&(o=t.right-i)>r&&(o=0),0!==o&&(t.customSeparateX?t.overlapX=o:n(t,o)),o}},function(t,e,i){var n=i(687),s=i(685),r=i(335);t.exports=function(t,e,i,o,a,h){var l=o.left,u=o.top,c=o.right,d=o.bottom,f=i.faceLeft||i.faceRight,p=i.faceTop||i.faceBottom;if(!f&&!p)return!1;var g=0,v=0,y=0,m=1;if(e.deltaAbsX()>e.deltaAbsY()?y=-1:e.deltaAbsX()=0;a--){var h=e[a],l=r(s,o,h.x,h.y);l=0;a--){var h=e[a],l=r(s,o,h.x,h.y);l>i&&(n=h,i=l)}return n},moveTo:function(t,e,i,n,s){void 0===n&&(n=60),void 0===s&&(s=0);var o=Math.atan2(i-t.y,e-t.x);return s>0&&(n=r(t.x,t.y,e,i)/(s/1e3)),t.body.velocity.setToPolar(o,n),o},moveToObject:function(t,e,i,n){return this.moveTo(t,e.x,e.y,i,n)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new u),i.setToPolar(s(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new u),i.setToPolar(t,e)},shutdown:function(){var t=this.systems.events;t.off("update",this.world.update,this.world),t.off("postupdate",this.world.postUpdate,this.world),t.off("shutdown",this.shutdown,this),this.add.destroy(),this.world.destroy(),this.add=null,this.world=null},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null}});l.register("ArcadePhysics",d,"arcadePhysics"),t.exports=d},function(t,e,i){var n=i(42),s=i(17),r={ArcadePhysics:i(702),Body:i(339),Collider:i(338),Factory:i(345),Group:i(342),Image:i(344),Sprite:i(142),StaticBody:i(334),StaticGroup:i(341),World:i(340)};r=s(!1,r,n),t.exports=r},function(t,e){t.exports=function(t,e,i){return Math.abs(t-e)<=i}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),n*=Math.PI/t;for(var s=[],r=[],o=0;o1?void 0!==n?(s=(n-t)/(n-i))<0&&(s=0):s=1:s<0&&(s=0),s}},function(t,e){t.exports=function(t,e,i){return Math.max(t-e,i)}},function(t,e){t.exports=function(t,e,i){return Math.min(t+e,i)}},function(t,e){t.exports=function(t){return t===parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t){return t==parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t,e){return t/e/1e3}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.floor(t*n)/n}},function(t,e){t.exports=function(t,e){return Math.abs(t-e)}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.ceil(t*n)/n}},function(t,e){t.exports=function(t){for(var e=0,i=0;i0&&0==(t&t-1)}},function(t,e,i){t.exports={GetNext:i(411),IsSize:i(85),IsValue:i(722)}},function(t,e,i){var n=i(287);t.exports=function(t,e,i){return e+(i-e)*n(t,0,1)}},function(t,e,i){var n=i(286);t.exports=function(t,e,i){return e+(i-e)*n(t,0,1)}},function(t,e,i){var n=i(122);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return e<0?n(t[0],t[1],s):e>1?n(t[i],t[i-1],i-s):n(t[r],t[r+1>i?i:r+1],s-r)}},function(t,e,i){var n=i(273);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return t[0]===t[i]?(e<0&&(r=Math.floor(s=i*(1+e))),n(s-r,t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i])):e<0?t[0]-(n(-s,t[0],t[0],t[1],t[1])-t[0]):e>1?t[i]-(n(s-i,t[i],t[i],t[i-1],t[i-1])-t[i]):n(s-r,t[r?r-1:0],t[r],t[i=n.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:e'),i.push(''),i.push(''),i.push(this.xhrLoader.responseText),i.push(""),i.push(""),i.push("");var n=[i.join("\n")],o=this;try{var a=new window.Blob(n,{type:"image/svg+xml;charset=utf-8"})}catch(t){return o.state=s.FILE_ERRORED,void o.onProcessComplete()}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(o.data),o.onProcessComplete()},this.data.onerror=function(){r.revokeObjectURL(o.data),o.onProcessError()},r.createObjectURL(this.data,a,"image/svg+xml")},addToCache:function(){var t=this.cache.addImage(this.key,this.data);this.pendingDestroy(t)}});o.register("html",function(t,e,i,n,s){if(Array.isArray(t))for(var r=0;r0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r)e.x&&t.ye.y}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e,i){var n=Math.min(t.x,e),s=Math.max(t.right,e);t.x=n,t.width=s-n;var r=Math.min(t.y,i),o=Math.max(t.bottom,i);return t.y=r,t.height=o-r,t}},function(t,e){t.exports=function(t,e){var i=Math.min(t.x,e.x),n=Math.max(t.right,e.right);t.x=i,t.width=n-i;var s=Math.min(t.y,e.y),r=Math.max(t.bottom,e.bottom);return t.y=s,t.height=r-s,t}},function(t,e){t.exports=function(t,e){for(var i=t.x,n=t.right,s=t.y,r=t.bottom,o=0;on(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},function(t,e,i){var n=i(228);t.exports=function(t,e){var i=n(t);return ii&&(i=h.x),h.xr&&(r=h.y),h.ye.right||t.righte.bottom||t.bottom0||(c=s(e),(d=n(t,c,!0)).length>0)}},function(t,e,i){var n=i(60),s=i(144);t.exports=function(t,e){return!!(n(t,e.getPointA())||n(t,e.getPointB())||s(t.getLineA(),e)||s(t.getLineB(),e)||s(t.getLineC(),e))}},function(t,e,i){var n=i(397),s=i(60);t.exports=function(t,e){return!(t.left>e.right||t.righte.bottom||t.bottomt.right+r||it.bottom+r||st.right||e.rightt.bottom||e.bottom0}},function(t,e,i){var n=i(396);t.exports=function(t,e){if(!n(t,e))return!1;var i=Math.min(e.x1,e.x2),s=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=s&&t.y>=r&&t.y<=o}},function(t,e){t.exports=function(t,e){var i=t.x1,n=t.y1,s=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,l=e.bottom,u=0;if(i>=o&&i<=h&&n>=a&&n<=l||s>=o&&s<=h&&r>=a&&r<=l)return!0;if(i=o){if((u=n+(r-n)*(o-i)/(s-i))>a&&u<=l)return!0}else if(i>h&&s<=h&&(u=n+(r-n)*(h-i)/(s-i))>=a&&u<=l)return!0;if(n=a){if((u=i+(s-i)*(a-n)/(r-n))>=o&&u<=h)return!0}else if(n>l&&r<=l&&(u=i+(s-i)*(l-n)/(r-n))>=o&&u<=h)return!0;return!1}},function(t,e,i){var n=i(14),s=i(398);t.exports=function(t,e,i){return void 0===i&&(i=new n),s(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},function(t,e){t.exports=function(t,e){var i=e.width/2,n=e.height/2,s=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-n),o=i+t.radius,a=n+t.radius;if(s>o||r>a)return!1;if(s<=i||r<=n)return!0;var h=s-i,l=r-n;return h*h+l*l<=t.radius*t.radius}},function(t,e,i){var n=i(58);t.exports=function(t,e){return n(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(14);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},function(t,e,i){var n=i(32);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(32);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(88);t.exports=function(t){return new n(t.x,t.y,t.radius)}},function(t,e){t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},function(t,e,i){var n=i(88);n.Area=i(853),n.Circumference=i(295),n.CircumferencePoint=i(136),n.Clone=i(852),n.Contains=i(32),n.ContainsPoint=i(851),n.ContainsRect=i(850),n.CopyFrom=i(849),n.Equals=i(848),n.GetBounds=i(847),n.GetPoint=i(298),n.GetPoints=i(296),n.Offset=i(846),n.OffsetPoint=i(845),n.Random=i(157),t.exports=n},function(t,e,i){var n=i(0),s=i(401),r=i(12),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",o,"lights"),t.exports=o},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(232);s.register("quad",function(t,e){void 0===t&&(t={});var i=r(t,"x",0),s=r(t,"y",0),a=r(t,"key",null),h=r(t,"frame",null),l=new o(this.scene,i,s,a,h);return void 0!==e&&(t.add=e),n(this.scene,l,t),l})},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(4),a=i(145);s.register("mesh",function(t,e){void 0===t&&(t={});var i=r(t,"key",null),s=r(t,"frame",null),h=o(t,"vertices",[]),l=o(t,"colors",[]),u=o(t,"alphas",[]),c=o(t,"uv",[]),d=new a(this.scene,0,0,h,c,l,u,i,s);return void 0!==e&&(t.add=e),n(this.scene,d,t),d})},function(t,e,i){var n=i(232);i(11).register("quad",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(145);i(11).register("mesh",function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))})},function(t,e){t.exports=function(){}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchMesh(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(861),s=i(860),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(13),s=i(10),r=i(158);n.register("zone",function(t){var e=s(t,"x",0),i=s(t,"y",0),n=s(t,"width",1),o=s(t,"height",n);return new r(this.scene,e,i,n,o)})},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(233);s.register("tileSprite",function(t,e){void 0===t&&(t={});var i=r(t,"x",0),s=r(t,"y",0),a=r(t,"width",512),h=r(t,"height",512),l=r(t,"key",""),u=r(t,"frame",""),c=new o(this.scene,i,s,a,h,l,u);return void 0!==e&&(t.add=e),n(this.scene,c,t),c})},function(t,e,i){var n=i(253),s=i(24),r=i(13),o=i(10),a=i(4);r.register("bitmapText",function(t,e){void 0===t&&(t={});var i=a(t,"font",""),r=o(t,"text",""),h=o(t,"size",!1),l=new n(this.scene,0,0,i,r,h);return void 0!==e&&(t.add=e),s(this.scene,l,t),l})},function(t,e,i){var n=i(24),s=i(127),r=i(13),o=i(10),a=i(151);r.register("sprite3D",function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),h=new a(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),n(this.scene,h,t),s(h,t),h})},function(t,e,i){var n=i(24),s=i(13),r=i(10),o=i(234);s.register("renderTexture",function(t,e){void 0===t&&(t={});var i=r(t,"x",0),s=r(t,"y",0),a=r(t,"width",32),h=r(t,"height",32),l=new o(this.scene,i,s,a,h);return void 0!==e&&(t.add=e),n(this.scene,l,t),l})},function(t,e,i){var n=i(13),s=i(10),r=i(1),o=i(235);n.register("particles",function(t,e){void 0===t&&(t={});var i=s(t,"key",null),n=s(t,"frame",null),a=r(t,"emitters",null),h=new o(this.scene,i,n,a);return void 0!==e&&(t.add=e),r(t,"add",!1)&&this.displayList.add(h),this.updateList.add(h),h})},function(t,e,i){var n=i(13),s=i(112);n.register("group",function(t){return new s(this.scene,null,t)})},function(t,e,i){var n=i(250),s=i(24),r=i(13),o=i(10);r.register("dynamicBitmapText",function(t,e){void 0===t&&(t={});var i=o(t,"font",""),r=o(t,"text",""),a=o(t,"size",!1),h=new n(this.scene,0,0,i,r,a);return void 0!==e&&(t.add=e),s(this.scene,h,t),h})},function(t,e,i){var n=i(24),s=i(251),r=i(13),o=i(10);r.register("container",function(t,e){void 0===t&&(t={});var i=o(t,"x",0),r=o(t,"y",0),a=new s(this.scene,i,r);return void 0!==e&&(t.add=e),n(this.scene,a,t),a})},function(t,e,i){var n=i(252),s=i(24),r=i(13),o=i(10);r.register("blitter",function(t,e){void 0===t&&(t={});var i=o(t,"key",null),r=o(t,"frame",null),a=new n(this.scene,0,0,i,r);return void 0!==e&&(t.add=e),s(this.scene,a,t),a})},function(t,e,i){var n=i(158);i(11).register("zone",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(233);i(11).register("tileSprite",function(t,e,i,s,r,o){return this.displayList.add(new n(this.scene,t,e,i,s,r,o))})},function(t,e,i){var n=i(253);i(11).register("bitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(151);i(11).register("sprite3D",function(t,e,i,s,r){var o=new n(this.scene,t,e,i,s,r);return this.displayList.add(o.gameObject),this.updateList.add(o.gameObject),o})},function(t,e,i){var n=i(11),s=i(234);n.register("renderTexture",function(t,e,i,n){return this.displayList.add(new s(this.scene,t,e,i,n))})},function(t,e,i){var n=i(11),s=i(418);n.register("follower",function(t,e,i,n,r){var o=new s(this.scene,t,e,i,n,r);return this.displayList.add(o),this.updateList.add(o),o})},function(t,e,i){var n=i(11),s=i(235);n.register("particles",function(t,e,i){var n=new s(this.scene,t,e,i);return this.displayList.add(n),this.updateList.add(n),n})},function(t,e,i){var n=i(112);i(11).register("group",function(t,e){return"object"==typeof t&&void 0===e&&(e=t,t=[]),this.updateList.add(new n(this.scene,t,e))})},function(t,e,i){var n=i(250);i(11).register("dynamicBitmapText",function(t,e,i,s,r){return this.displayList.add(new n(this.scene,t,e,i,s,r))})},function(t,e,i){var n=i(251);i(11).register("container",function(t,e,i){return this.displayList.add(new n(this.scene,t,e,i))})},function(t,e,i){var n=i(252);i(11).register("blitter",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var o=t.currentContext,a=e.frame;e.updateTileTexture(),t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,o.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,o.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var h=a.x-e.originX*e.width,l=a.y-e.originY*e.height,u=e.x-s.scrollX*e.scrollFactorX,c=e.y-s.scrollY*e.scrollFactorY,d=1,f=1;if(e.flipX&&(d=-1,h+=e.width),e.flipY&&(f=-1,l+=e.height),t.config.roundPixels&&(h|=0,l|=0,u|=0,c|=0),o.save(),void 0!==r){var p=r.matrix;o.transform(p[0],p[1],p[2],p[3],p[4],p[5])}o.translate(h,l),o.translate(u,c),o.scale(d,f),o.translate(e.originX*e.width,e.originY*e.height),o.rotate(d*f*e.rotation),o.scale(this.scaleX,this.scaleY),o.translate(-e.originX*e.width,-e.originY*e.height),o.translate(-this.tilePositionX,-this.tilePositionY),o.fillStyle=e.canvasPattern,o.fillRect(this.tilePositionX,this.tilePositionY,e.width,e.height),o.restore()}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||(e.updateTileTexture(),this.pipeline.batchTileSprite(this,s,r))}},function(t,e,i){var n=i(3),s=i(3);n=i(885),s=i(884),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(4);t.exports=function(t,e){var i=e.width,s=e.height,r=Math.floor(i/2),o=Math.floor(s/2),a=n(e,"chars","");if(""!==a){var h=n(e,"image",""),l=n(e,"offset.x",0),u=n(e,"offset.y",0),c=n(e,"spacing.x",0),d=n(e,"spacing.y",0),f=n(e,"charsPerRow",null);null===f&&(f=t.sys.textures.getFrame(h).width/i)>a.length&&(f=a.length);for(var p=l,g=u,v={retroFont:!0,font:h,size:i,lineHeight:s,chars:{}},y=0,m=0;m?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",TEXT_SET2:" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET3:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",TEXT_SET4:"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",TEXT_SET5:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",TEXT_SET6:"ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",TEXT_SET7:"AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",TEXT_SET8:"0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET9:"ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",TEXT_SET10:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET11:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789"}},function(t,e,i){var n=i(888),s=i(17),r={Parse:i(887)};r=s(!1,r,n),t.exports=r},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);this.renderer.setFramebuffer(this.framebuffer);var s=this.gl;return s.clearColor(e/255,i/255,n/255,1),s.clear(s.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},clear:function(){this.renderer.setFramebuffer(this.framebuffer);var t=this.gl;return t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null),this},draw:function(t,e,i,n){var s=t.source[e.sourceIndex].glTexture,r=(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16);return this.renderer.setFramebuffer(this.framebuffer),this.renderer.pipelines.TextureTintPipeline.projOrtho(0,this.renderer.pipelines.TextureTintPipeline.width,0,this.renderer.pipelines.TextureTintPipeline.height,-1e3,1e3),this.renderer.pipelines.TextureTintPipeline.drawTexture(s,i,n,r,this.globalAlpha,e.cutX,e.cutY,e.cutWidth,e.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,-1e3,1e3),this}}},function(t,e){t.exports={fill:function(t){var e=255&(t>>16|0),i=255&(t>>8|0),n=255&(0|t);return this.context.fillStyle="rgb("+e+","+i+","+n+")",this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this},clear:function(){return this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.restore(),this},draw:function(t,e,i,n){var s=e.canvasData,r=e.source.image,o=this.currentMatrix;return this.context.globalAlpha=this.globalAlpha,this.context.setTransform(o[0],o[1],o[2],o[3],o[4],o[5]),this.context.drawImage(r,s.sx,s.sy,s.sWidth,s.sHeight,i,n,s.dWidth,s.dHeight),this}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var o=t.currentContext;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,o.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,o.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var a=0,h=0,l=1,u=1;if(e.flipX?(l=-1,a-=e.canvas.width-e.displayOriginX):a-=e.displayOriginX,e.flipY?(u=-1,h-=e.canvas.height-e.displayOriginY):h-=e.displayOriginY,o.save(),void 0!==r){var c=r.matrix;o.transform(c[0],c[1],c[2],c[3],c[4],c[5])}o.translate(e.x-s.scrollX*e.scrollFactorX,e.y-s.scrollY*e.scrollFactorY),o.rotate(e.rotation),o.scale(e.scaleX,e.scaleY),o.scale(l,u),o.drawImage(e.canvas,a,h),o.restore()}}},function(t,e,i){var n=i(2),s=i(27);t.exports=function(t,e,i,r,o){n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&r._id||this.pipeline.batchTexture(e,e.texture,e.texture.width,e.texture.height,e.x,e.y,e.width,e.height,e.scaleX,e.scaleY,e.rotation,e.flipX,!e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,e.texture.width,e.texture.height,s.getTintAppendFloatAlpha(e.tintTopLeft,e.alphaTopLeft),s.getTintAppendFloatAlpha(e.tintTopRight,e.alphaTopRight),s.getTintAppendFloatAlpha(e.tintBottomLeft,e.alphaBottomLeft),s.getTintAppendFloatAlpha(e.tintBottomRight,e.alphaBottomRight),0,0,r,o)}},function(t,e,i){var n=i(3),s=i(3);n=i(893),s=i(892),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){t.exports={DeathZone:i(455),EdgeZone:i(454),RandomZone:i(419)}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){var o=e.emitters.list;if(!(0===o.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var a=t.currentContext;if(a.save(),void 0!==r){var h=r.matrix;a.transform(h[0],h[1],h[2],h[3],h[4],h[5])}for(var l=0;l>24&255)/255;if(!(x<=0)){var w=m.frame,b=.5*w.width,T=.5*w.height,S=w.canvasData,A=-b,C=-T,M=m.x-p,_=m.y-g;v&&(M|=0,_|=0),a.globalAlpha=x,a.save(),a.translate(M,_),a.rotate(m.rotation),a.scale(m.scaleX,m.scaleY),a.drawImage(w.source.image,S.sx,S.sy,S.sWidth,S.sHeight,A,C,S.dWidth,S.dHeight),a.restore()}}a.globalAlpha=f}}a.restore()}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){0===e.emitters.length||n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.drawEmitterManager(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(897),s=i(896),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(0),s=i(248),r=i(63),o=i(1),a=i(39),h=new n({initialize:function(t,e,i,n){void 0===n&&(n=!1),this.propertyKey=e,this.propertyValue=i,this.defaultValue=i,this.steps=0,this.counter=0,this.start=0,this.end=0,this.ease,this.emitOnly=n,this.onEmit=this.defaultEmit,this.onUpdate=this.defaultUpdate,this.loadConfig(t)},loadConfig:function(t,e){void 0===t&&(t={}),e&&(this.propertyKey=e),this.propertyValue=o(t,this.propertyKey,this.defaultValue),this.setMethods(),this.emitOnly&&(this.onUpdate=this.defaultUpdate)},toJSON:function(){return this.propertyValue},onChange:function(t){return this.propertyValue=t,this.setMethods()},setMethods:function(){var t=this.propertyValue,e=typeof t;if("number"===e)this.onEmit=this.staticValueEmit,this.onUpdate=this.staticValueUpdate;else if(Array.isArray(t))this.onEmit=this.randomStaticValueEmit;else if("function"===e)this.emitOnly?this.onEmit=t:this.onUpdate=t;else if("object"===e&&(this.has(t,"random")||this.hasBoth(t,"start","end")||this.hasBoth(t,"min","max"))){this.start=this.has(t,"start")?t.start:t.min,this.end=this.has(t,"end")?t.end:t.max;var i=this.hasBoth(t,"min","max")||this.has(t,"random");if(i){var n=t.random;Array.isArray(n)&&(this.start=n[0],this.end=n[1]),this.onEmit=this.randomRangedValueEmit}if(this.has(t,"steps"))this.steps=t.steps,this.counter=this.start,this.onEmit=this.steppedEmit;else{var s=this.has(t,"ease")?t.ease:"Linear";this.ease=r(s),i||(this.onEmit=this.easedValueEmit),this.onUpdate=this.easeValueUpdate}}else"object"===e&&this.hasEither(t,"onEmit","onUpdate")&&(this.has(t,"onEmit")&&(this.onEmit=t.onEmit),this.has(t,"onUpdate")&&(this.onUpdate=t.onUpdate));return this},has:function(t,e){return t.hasOwnProperty(e)},hasBoth:function(t,e,i){return t.hasOwnProperty(e)&&t.hasOwnProperty(i)},hasEither:function(t,e,i){return t.hasOwnProperty(e)||t.hasOwnProperty(i)},defaultEmit:function(t,e,i){return i},defaultUpdate:function(t,e,i,n){return n},staticValueEmit:function(){return this.propertyValue},staticValueUpdate:function(){return this.propertyValue},randomStaticValueEmit:function(){var t=Math.floor(Math.random()*this.propertyValue.length);return this.propertyValue[t]},randomRangedValueEmit:function(t,e){var i=s(this.start,this.end);return t&&t.data[e]&&(t.data[e].min=i),i},steppedEmit:function(){var t=this.counter,e=this.counter+(this.end-this.start)/this.steps;return this.counter=a(e,this.start,this.end),t},easedValueEmit:function(t,e){if(t&&t.data[e]){var i=t.data[e];i.min=this.start,i.max=this.end}return this.start},easeValueUpdate:function(t,e,i){var n=t.data[e];return(n.max-n.min)*this.ease(i)+n.min}});t.exports=h},function(t,e,i){t.exports={GravityWell:i(458),Particle:i(457),ParticleEmitter:i(456),ParticleEmitterManager:i(235),Zones:i(895)}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length;if(!(n.RENDER_MASK!==e.renderFlags||0===a||e.cameraFilter>0&&e.cameraFilter&s._id)){var h=e.frame,l=e.displayCallback,u=s.scrollX*e.scrollFactorX,c=s.scrollY*e.scrollFactorY,d=e.fontData.chars,f=e.fontData.lineHeight,p=0,g=0,v=0,y=0,m=null,x=0,w=0,b=0,T=0,S=0,A=0,C=null,M=0,_=t.currentContext,E=e.frame.source.image,P=h.cutX,k=h.cutY,L=0,F=e.fontSize/e.fontData.size;if(t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,_.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,_.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode),_.save(),void 0!==r){var R=r.matrix;_.transform(R[0],R[1],R[2],R[3],R[4],R[5])}_.translate(e.x,e.y),_.rotate(e.rotation),_.translate(-e.displayOriginX,-e.displayOriginY),_.scale(e.scaleX,e.scaleY),e.cropWidth>0&&e.cropHeight>0&&(_.save(),_.beginPath(),_.rect(0,0,e.cropWidth,e.cropHeight),_.clip());for(var O=t.config.roundPixels,B=0;B0&&e.cropHeight>0&&_.restore(),_.restore()}}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){var o=e.text.length;n.RENDER_MASK!==e.renderFlags||0===o||e.cameraFilter>0&&e.cameraFilter&s._id||this.pipeline.batchDynamicBitmapText(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(902),s=i(901),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){if(!(n.RENDER_MASK!==e.renderFlags||e.cameraFilter>0&&e.cameraFilter&s._id)){var o=e.list,a=e.localTransform;void 0===r?a.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY):(a.loadIdentity(),a.multiply(r),a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY));for(var h=e._alpha,l=e.scrollFactorX,u=e.scrollFactorY,c=0;c0&&e.cameraFilter&s._id)){var o=e.list,a=e.localTransform;void 0===r?a.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY):(a.loadIdentity(),a.multiply(r),a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(e.scaleX,e.scaleY));for(var h=e._alpha,l=e.scrollFactorX,u=e.scrollFactorY,c=0;c0&&e.cameraFilter&s._id)){var o=e.getRenderList();t.setBlendMode(e.blendMode);var a=t.gameContext,h=e.x-s.scrollX*e.scrollFactorX,l=e.y-s.scrollY*e.scrollFactorY;if(a.save(),void 0!==r){var u=r.matrix;a.transform(u[0],u[1],u[2],u[3],u[4],u[5])}for(var c=0;c0&&e.cameraFilter&s._id||this.pipeline.drawBlitter(e,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(909),s=i(908),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(2);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length;if(!(n.RENDER_MASK!==e.renderFlags||0===a||e.cameraFilter>0&&e.cameraFilter&s._id)){var h=e.frame,l=e.fontData.chars,u=e.fontData.lineHeight,c=e.letterSpacing,d=0,f=0,p=0,g=0,v=null,y=0,m=0,x=0,w=0,b=0,T=0,S=null,A=0,C=t.currentContext,M=e.frame.source.image,_=h.cutX,E=h.cutY,P=e.fontSize/e.fontData.size;t.currentBlendMode!==e.blendMode&&(t.currentBlendMode=e.blendMode,C.globalCompositeOperation=t.blendModes[e.blendMode]),t.currentAlpha!==e.alpha&&(t.currentAlpha=e.alpha,C.globalAlpha=e.alpha),t.currentScaleMode!==e.scaleMode&&(t.currentScaleMode=e.scaleMode);var k=t.config.roundPixels,L=e.x-s.scrollX*e.scrollFactorX+e.frame.x,F=e.y-s.scrollY*e.scrollFactorY+e.frame.y;if(k&&(L|=0,F|=0),C.save(),void 0!==r){var R=r.matrix;C.transform(R[0],R[1],R[2],R[3],R[4],R[5])}C.translate(L,F),C.rotate(e.rotation),C.translate(-e.displayOriginX,-e.displayOriginY),C.scale(e.scaleX,e.scaleY);for(var O=0;O0&&e.cameraFilter&s._id||this.pipeline.batchBitmapText(this,s,r)}},function(t,e,i){var n=i(3),s=i(3);n=i(912),s=i(911),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(474);t.exports=function(t,e,i,s,r,o,a){var h=t.sys.textures.getFrame(i,s),l=t.sys.cache.xml.get(r);if(h&&l){var u=n(l,o,a,h);return t.sys.cache.bitmapFont.add(e,{data:u,texture:i,frame:s}),!0}return!1}},function(t,e,i){var n={DisplayList:i(504),GameObjectCreator:i(13),GameObjectFactory:i(11),UpdateList:i(476),Components:i(15),BuildGameObject:i(24),BuildGameObjectAnimation:i(127),GameObject:i(2),BitmapText:i(253),Blitter:i(252),Container:i(251),DynamicBitmapText:i(250),Graphics:i(115),Group:i(112),Image:i(69),Particles:i(900),PathFollower:i(418),RenderTexture:i(234),RetroFont:i(889),Sprite3D:i(151),Sprite:i(34),Text:i(110),TileSprite:i(233),Zone:i(158),Factories:{Blitter:i(883),Container:i(882),DynamicBitmapText:i(881),Graphics:i(410),Group:i(880),Image:i(409),Particles:i(879),PathFollower:i(878),RenderTexture:i(877),Sprite3D:i(876),Sprite:i(408),StaticBitmapText:i(875),Text:i(407),TileSprite:i(874),Zone:i(873)},Creators:{Blitter:i(872),Container:i(871),DynamicBitmapText:i(870),Graphics:i(406),Group:i(869),Image:i(405),Particles:i(868),RenderTexture:i(867),Sprite3D:i(866),Sprite:i(404),StaticBitmapText:i(865),Text:i(403),TileSprite:i(864),Zone:i(863)}};n.Mesh=i(145),n.Quad=i(232),n.Factories.Mesh=i(859),n.Factories.Quad=i(858),n.Creators.Mesh=i(857),n.Creators.Quad=i(856),n.Light=i(402),i(401),i(855),t.exports=n},function(t,e,i){t.exports={AddToDOM:i(130),DOMContentLoaded:i(271),ParseXML:i(270),RemoveFromDOM:i(269),RequestAnimationFrame:i(268)}},function(t,e,i){var n=i(541);t.exports=function(t,e,i,s,r){return void 0===s&&(s=255),void 0===r&&(r="#"),"#"===r?"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1):"0x"+n(s)+n(t)+n(e)+n(i)}},function(t,e){t.exports=function(t,e,i){t/=255,e/=255,i/=255;var n=Math.min(t,e,i),s=Math.max(t,e,i),r=s-n,o=0;return s!==n&&(s===t?o=(e-i)/r+(e>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},function(t,e){t.exports=function(t,e){void 0===e&&(e="none");return["-webkit-","-khtml-","-moz-","-ms-",""].forEach(function(i){t.style[i+"user-select"]=e}),t.style["-webkit-touch-callout"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}},function(t,e){t.exports=function(t,e){return void 0===e&&(e="none"),t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}},function(t,e,i){t.exports={Interpolation:i(272),Pool:i(22),Smoothing:i(131),TouchAction:i(925),UserSelect:i(924)}},function(t,e){t.exports=function(t){return t.height*t.originY}},function(t,e){t.exports=function(t){return t.width*t.originX}},function(t,e,i){t.exports={CenterOn:i(593),GetBottom:i(50),GetCenterX:i(92),GetCenterY:i(89),GetLeft:i(48),GetOffsetX:i(928),GetOffsetY:i(927),GetRight:i(46),GetTop:i(44),SetBottom:i(49),SetCenterX:i(91),SetCenterY:i(90),SetLeft:i(47),SetRight:i(45),SetTop:i(43)}},function(t,e,i){var n=i(46),s=i(44),r=i(49),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(49),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)-a),t}},function(t,e,i){var n=i(92),s=i(44),r=i(49),o=i(91);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(46),s=i(44),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(89),s=i(46),r=i(90),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(46),r=i(49),o=i(47);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(45),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(89),s=i(48),r=i(90),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(48),r=i(49),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(46),r=i(45),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(48),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)+a),t}},function(t,e,i){var n=i(50),s=i(92),r=i(91),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){t.exports={BottomCenter:i(941),BottomLeft:i(940),BottomRight:i(939),LeftBottom:i(938),LeftCenter:i(937),LeftTop:i(936),RightBottom:i(935),RightCenter:i(934),RightTop:i(933),TopCenter:i(932),TopLeft:i(931),TopRight:i(930)}},function(t,e,i){t.exports={BottomCenter:i(597),BottomLeft:i(596),BottomRight:i(595),Center:i(594),LeftCenter:i(592),QuickSet:i(598),RightCenter:i(591),TopCenter:i(590),TopLeft:i(589),TopRight:i(588)}},function(t,e,i){var n=i(299),s=i(17),r={In:i(943),To:i(942)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Align:i(944),Bounds:i(929),Canvas:i(926),Color:i(542),Masks:i(538)}},function(t,e,i){var n=i(0),s=i(6),r=new n({initialize:function(t,e){this.active=!1,this.p0=new s(t,e)},getPoint:function(t,e){return void 0===e&&(e=new s),e.copy(this.p0)},getPointAt:function(t,e){return this.getPoint(t,e)},getResolution:function(){return 1},getLength:function(){return 0},toJSON:function(){return{type:"MoveTo",points:[this.p0.x,this.p0.y]}}});t.exports=r},function(t,e,i){var n=i(0),s=i(551),r=i(549),o=i(11),a=i(548),h=i(946),l=i(547),u=i(14),c=i(545),d=i(6),f=new n({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.name="",this.curves=[],this.cacheLengths=[],this.autoClose=!1,this.startPoint=new d,this._tmpVec2A=new d,this._tmpVec2B=new d,"object"==typeof t?this.fromJSON(t):this.startPoint.set(t,e)},add:function(t){return this.curves.push(t),this},circleTo:function(t,e,i){return void 0===e&&(e=!1),this.ellipseTo(t,t,0,360,e,i)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return t.equals(e)||this.curves.push(new a(e,t)),this},cubicBezierTo:function(t,e,i,n,r,o){var a,h,l,u=this.getEndPoint();return t instanceof d?(a=t,h=e,l=i):(a=new d(i,n),h=new d(r,o),l=new d(t,e)),this.add(new s(u,a,h,l))},quadraticBezierTo:function(t,e,i,n){var s,r,o=this.getEndPoint();return t instanceof d?(s=t,r=e):(s=new d(i,n),r=new d(t,e)),this.add(new l(o,s,r))},draw:function(t,e){for(var i=0;i0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),n=this.getCurveLengths(),s=0;s=i){var r=n[s]-i,o=this.curves[s],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}s++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],n=0;n1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e0;){this.cameras.pop().destroy()}return this.main},update:function(t,e){for(var i=0,n=this.cameras.length;i0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoom<.1&&(e.zoom=.1))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(4),r=new n({initialize:function(t){this.camera=s(t,"camera",null),this.left=s(t,"left",null),this.right=s(t,"right",null),this.up=s(t,"up",null),this.down=s(t,"down",null),this.zoomIn=s(t,"zoomIn",null),this.zoomOut=s(t,"zoomOut",null),this.zoomSpeed=s(t,"zoomSpeed",.01),this.speedX=0,this.speedY=0;var e=s(t,"speed",null);"number"==typeof e?(this.speedX=e,this.speedY=e):(this.speedX=s(t,"speed.x",0),this.speedY=s(t,"speed.y",0)),this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this.up&&this.up.isDown?e.scrollY-=this.speedY*t|0:this.down&&this.down.isDown&&(e.scrollY+=this.speedY*t|0),this.left&&this.left.isDown?e.scrollX-=this.speedX*t|0:this.right&&this.right.isDown&&(e.scrollX+=this.speedX*t|0),this.zoomIn&&this.zoomIn.isDown?(e.zoom-=this.zoomSpeed,e.zoom<.1&&(e.zoom=.1)):this.zoomOut&&this.zoomOut.isDown&&(e.zoom+=this.zoomSpeed)}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){t.exports={FixedKeyControl:i(958),SmoothedKeyControl:i(957)}},function(t,e,i){t.exports={Controls:i(959),Scene2D:i(566),Sprite3D:i(956)}},function(t,e,i){var n=i(39);t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=0;s1)if(0===s){var d=t.length-1;for(o=t[d].x,a=t[d].y,h=d-1;h>=0;h--)l=(c=t[h]).x,u=c.y,c.x=o,c.y=a,o=l,a=u;t[d].x=e,t[d].y=i}else{for(o=t[0].x,a=t[0].y,h=1;h0?s(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionstart",e,i,n)}),d.on(e,"collisionActive",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionactive",e,i,n)}),d.on(e,"collisionEnd",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionend",e,i,n)})},setBounds:function(t,e,i,n,s,r,o,a,h){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),void 0===s&&(s=128),void 0===r&&(r=!0),void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),this.updateWall(r,"left",t-s,e,s,n),this.updateWall(o,"right",t+i,e,s,n),this.updateWall(a,"top",t,e-s,i,s),this.updateWall(h,"bottom",t,e+n,i,s),this},updateWall:function(t,e,i,n,s,r){var o=this.walls[e];t?(o&&p.remove(this.localWorld,o),i+=s/2,n+=r/2,this.walls[e]=this.create(i,n,s,r,{isStatic:!0,friction:0,frictionStatic:0})):(o&&p.remove(this.localWorld,o),this.walls[e]=null)},createDebugGraphic:function(){var t=this.scene.sys.add.graphics({x:0,y:0});return t.setDepth(Number.MAX_VALUE),this.debugGraphic=t,this.drawDebug=!0,t},disableGravity:function(){return this.localWorld.gravity.x=0,this.localWorld.gravity.y=0,this.localWorld.gravity.scale=0,this},setGravity:function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=1),this.localWorld.gravity.x=t,this.localWorld.gravity.y=e,void 0!==i&&(this.localWorld.gravity.scale=i),this},create:function(t,e,i,s,r){var o=n.rectangle(t,e,i,s,r);return p.add(this.localWorld,o),o},add:function(t){return p.add(this.localWorld,t),this},remove:function(t,e){var i=t.body?t.body:t;return o.removeBody(this.localWorld,i,e),this},removeConstraint:function(t,e){return o.remove(this.localWorld,t,e),this},convertTilemapLayer:function(t,e){var i=t.layer,n=t.getTilesWithin(0,0,i.width,i.height,{isColliding:!0});return this.convertTiles(n,e),this},convertTiles:function(t,e){if(0===t.length)return this;for(var i=0;i0&&u.trigger(n,"collisionStart",{pairs:T.collisionStart}),o.preSolvePosition(T.list),f=0;f0&&u.trigger(n,"collisionActive",{pairs:T.collisionActive}),T.collisionEnd.length>0&&u.trigger(n,"collisionEnd",{pairs:T.collisionEnd}),h.update(n.metrics,n),t(x),u.trigger(n,"afterUpdate",m),n},n.merge=function(t,e){if(f.extend(t,e),e.world){t.world=e.world,n.clear(t);for(var i=c.allBodies(t.world),s=0;sf.friction*f.frictionStatic*O*i&&(D=L,B=o.clamp(f.friction*F*i,-D,D));var I=r.cross(A,y),z=r.cross(C,y),Y=w/(g.inverseMass+v.inverseMass+g.inverseInertia*I*I+v.inverseInertia*z*z);if(R*=Y,B*=Y,P<0&&P*P>n._restingThresh*i)T.normalImpulse=0;else{var X=T.normalImpulse;T.normalImpulse=Math.min(T.normalImpulse+R,0),R=T.normalImpulse-X}if(k*k>n._restingThreshTangent*i)T.tangentImpulse=0;else{var N=T.tangentImpulse;T.tangentImpulse=o.clamp(T.tangentImpulse+B,-D,D),B=T.tangentImpulse-N}s.x=y.x*R+m.x*B,s.y=y.y*R+m.y*B,g.isStatic||g.isSleeping||(g.positionPrev.x+=s.x*g.inverseMass,g.positionPrev.y+=s.y*g.inverseMass,g.anglePrev+=r.cross(A,s)*g.inverseInertia),v.isStatic||v.isSleeping||(v.positionPrev.x-=s.x*v.inverseMass,v.positionPrev.y-=s.y*v.inverseMass,v.anglePrev-=r.cross(C,s)*v.inverseInertia)}}}}},function(t,e,i){var n={};t.exports=n;var s=i(610),r=i(41);n.create=function(t){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},t)},n.update=function(t,e,i){var n,r,o,a,h=t.list,l=t.table,u=t.collisionStart,c=t.collisionEnd,d=t.collisionActive;for(u.length=0,c.length=0,d.length=0,a=0;a1e3&&h.push(r);for(r=0;rv.bounds.max.x||w.bounds.max.yv.bounds.max.y)){var b=e(i,w);if(!w.region||b.id!==w.region.id||r){x.broadphaseTests+=1,w.region&&!r||(w.region=b);var T=t(b,w.region);for(d=T.startCol;d<=T.endCol;d++)for(f=T.startRow;f<=T.endRow;f++){p=y[g=a(d,f)];var S=d>=b.startCol&&d<=b.endCol&&f>=b.startRow&&f<=b.endRow,A=d>=w.region.startCol&&d<=w.region.endCol&&f>=w.region.startRow&&f<=w.region.endRow;!S&&A&&A&&p&&u(i,p,w),(w.region===b||S&&!A||r)&&(p||(p=h(y,g)),l(i,p,w))}w.region=b,m=!0}}}m&&(i.pairsList=c(i))},n.clear=function(t){t.buckets={},t.pairs={},t.pairsList=[]};var t=function(t,e){var n=Math.min(t.startCol,e.startCol),s=Math.max(t.endCol,e.endCol),r=Math.min(t.startRow,e.startRow),o=Math.max(t.endRow,e.endRow);return i(n,s,r,o)},e=function(t,e){var n=e.bounds,s=Math.floor(n.min.x/t.bucketWidth),r=Math.floor(n.max.x/t.bucketWidth),o=Math.floor(n.min.y/t.bucketHeight),a=Math.floor(n.max.y/t.bucketHeight);return i(s,r,o,a)},i=function(t,e,i,n){return{id:t+","+e+","+i+","+n,startCol:t,endCol:e,startRow:i,endRow:n}},a=function(t,e){return"C"+t+"R"+e},h=function(t,e){return t[e]=[]},l=function(t,e,i){for(var n=0;n0?n.push(i):delete t.pairs[e[s]];return n}}()},function(t,e,i){var n={};t.exports=n;var s=i(675),r=i(41);n.name="matter-js",n.version="0.13.1",n.uses=[],n.used=[],n.use=function(){s.use(n,Array.prototype.slice.call(arguments))},n.before=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathBefore(n,t,e)},n.after=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathAfter(n,t,e)}},function(t,e,i){var n=i(302),s=i(0),r=i(611),o=i(2),a=i(1),h=i(291),l=i(34),u=i(6),c=new s({Extends:l,Mixins:[r.Bounce,r.Collision,r.Force,r.Friction,r.Gravity,r.Mass,r.Sensor,r.SetBody,r.Sleep,r.Static,r.Transform,r.Velocity,h],initialize:function(t,e,i,s,r,h){o.call(this,t.scene,"Image"),this.anims=new n(this),this.setTexture(s,r),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new u(e,i);var l=a(h,"shape",null);l?this.setBody(l,h):this.setRectangle(this.width,this.height,h),this.setPosition(e,i),this.initPipeline("TextureTintPipeline")}});t.exports=c},function(t,e,i){var n=i(0),s=i(611),r=i(2),o=i(1),a=i(69),h=i(291),l=i(6),u=new n({Extends:a,Mixins:[s.Bounce,s.Collision,s.Force,s.Friction,s.Gravity,s.Mass,s.Sensor,s.SetBody,s.Sleep,s.Static,s.Transform,s.Velocity,h],initialize:function(t,e,i,n,s,a){r.call(this,t.scene,"Image"),this.setTexture(n,s),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new l(e,i);var h=o(a,"shape",null);h?this.setBody(h,a):this.setRectangle(this.width,this.height,a),this.setPosition(e,i),this.initPipeline("TextureTintPipeline")}});t.exports=u},function(t,e,i){var n={};t.exports=n;var s=i(221),r=i(300),o=i(41),a=i(74),h=i(166);n.stack=function(t,e,i,n,r,o,h){for(var l,u=s.create({label:"Stack"}),c=t,d=e,f=0,p=0;pg&&(g=m),a.translate(y,{x:.5*x,y:.5*m}),c=y.bounds.max.x+r,s.addBody(u,y),l=y,f+=1}else c+=r}d+=g+o,c=t}return u},n.chain=function(t,e,i,n,a,h){for(var l=t.bodies,u=1;u0)for(l=0;l0&&(d=f[l-1+(h-1)*e],s.addConstraint(t,r.create(o.extend({bodyA:d,bodyB:c},a)))),n&&ld||o<(l=d-l)||o>i-1-l))return 1===c&&a.translate(u,{x:(o+(i%2==1?1:-1))*f,y:0}),h(t+(u?o*f:0)+o*r,n,o,l,u,c)})},n.newtonsCradle=function(t,e,i,n,o){for(var a=s.create({label:"Newtons Cradle"}),l=0;l=0&&h<=1&&l>=0&&l<=1}function s(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])}function r(t,e,i){return s(t,e,i)>0}function o(t,e,i){return s(t,e,i)>=0}function a(t,e,i){return s(t,e,i)<0}function h(t,e,i){return s(t,e,i)<=0}t.exports={decomp:function(t){var e=function t(e){var i=[],n=[],s=[],r=[];var o=Number.MAX_VALUE;for(var a=0;a0?function t(e,i){if(0===i.length)return[e];if(i instanceof Array&&i.length&&i[0]instanceof Array&&2===i[0].length&&i[0][0]instanceof Array){for(var n=[e],s=0;su)return console.warn("quickDecomp: max level ("+u+") reached."),i;for(var L=0;LA&&(A+=e.length),S=Number.MAX_VALUE,A3&&n>=0;--n)c(f(t,n-1),f(t,n),f(t,n+1),e)&&(t.splice(n%t.length,1),i++);return i},makeCCW:function(t){for(var e=0,i=t,n=1;ni[e][0])&&(e=n);r(f(t,e-1),f(t,e),f(t,e+1))||function(t){for(var e=[],i=t.length,n=0;n!==i;n++)e.push(t.pop());for(var n=0;n!==i;n++)t[n]=e[n]}(t)}};var l=[],u=[];function c(t,e,i,n){if(n){var r=l,o=u;r[0]=e[0]-t[0],r[1]=e[1]-t[1],o[0]=i[0]-e[0],o[1]=i[1]-e[1];var a=r[0]*o[0]+r[1]*o[1],h=Math.sqrt(r[0]*r[0]+r[1]*r[1]),c=Math.sqrt(o[0]*o[0]+o[1]*o[1]);return Math.acos(a/(h*c))r.ACTIVE&&c(this,t,e))},setCollidesNever:function(t){for(var e=0;e1)for(var h=i/a,l=n/a,u=0;u0?r:0,y=n<0?f:0,m=Math.max(Math.floor(i/f),0),x=Math.min(Math.ceil((i+o)/f),g);u=Math.floor((t.pos.x+v)/f);var w=Math.floor((e+v)/f);if((l>0||u===w||w<0||w>=p)&&(w=-1),u>=0&&u1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,w,c));c++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.x=!0,t.tile.x=d,t.pos.x=u*f-v+y,e=t.pos.x,a=0;break}}if(s){var b=s>0?o:0,T=s<0?f:0,S=Math.max(Math.floor(t.pos.x/f),0),A=Math.min(Math.ceil((t.pos.x+r)/f),p);c=Math.floor((t.pos.y+b)/f);var C=Math.floor((i+b)/f);if((l>0||c===C||C<0||C>=g)&&(C=-1),c>=0&&c1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,u,C));u++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.y=!0,t.tile.y=d,t.pos.y=c*f-b+T;break}}},checkDef:function(t,e,i,n,s,r,o,a,h,l){var u=this.tiledef[e];if(!u)return!1;var c=this.tilesize,d=(h+u[0])*c,f=(l+u[1])*c,p=(u[2]-u[0])*c,g=(u[3]-u[1])*c,v=u[4],y=i+s+(g<0?o:0)-d,m=n+r+(p>0?a:0)-f;if(p*m-g*y>0){if(s*-g+r*p<0)return v;var x=Math.sqrt(p*p+g*g),w=g/x,b=-p/x,T=y*w+m*b,S=w*T,A=b*T;return S*S+A*A>=s*s+r*r?v||p*(m-r)-g*(y-s)<.5:(t.pos.x=i+s-S,t.pos.y=n+r-A,t.collision.slope={x:p,y:g,nx:w,ny:b},!0)}return!1}});t.exports=r},function(t,e,i){var n=i(0),s=i(333),r=i(1068),o=i(332),a=i(1067),h=new n({initialize:function(t,e,i,n,r){void 0===n&&(n=16),void 0===r&&(r=n),this.world=t,this.gameObject=null,this.enabled=!0,this.parent,this.id=t.getNextID(),this.name="",this.size={x:n,y:r},this.offset={x:0,y:0},this.pos={x:e,y:i},this.last={x:e,y:i},this.vel={x:0,y:0},this.accel={x:0,y:0},this.friction={x:0,y:0},this.maxVel={x:t.defaults.maxVelocityX,y:t.defaults.maxVelocityY},this.standing=!1,this.gravityFactor=t.defaults.gravityFactor,this.bounciness=t.defaults.bounciness,this.minBounceVelocity=t.defaults.minBounceVelocity,this.accelGround=0,this.accelAir=0,this.jumpSpeed=0,this.type=o.NONE,this.checkAgainst=o.NONE,this.collides=s.NEVER,this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.updateCallback,this.slopeStanding={min:.767944870877505,max:2.3736477827122884}},reset:function(t,e){this.pos={x:t,y:e},this.last={x:t,y:e},this.vel={x:0,y:0},this.accel={x:0,y:0},this.friction={x:0,y:0},this.maxVel={x:100,y:100},this.standing=!1,this.gravityFactor=1,this.bounciness=0,this.minBounceVelocity=40,this.accelGround=0,this.accelAir=0,this.jumpSpeed=0,this.type=o.NONE,this.checkAgainst=o.NONE,this.collides=s.NEVER},update:function(t){var e=this.pos;this.last.x=e.x,this.last.y=e.y,this.vel.y+=this.world.gravity*t*this.gravityFactor,this.vel.x=r(t,this.vel.x,this.accel.x,this.friction.x,this.maxVel.x),this.vel.y=r(t,this.vel.y,this.accel.y,this.friction.y,this.maxVel.y);var i=this.vel.x*t,n=this.vel.y*t,s=this.world.collisionMap.trace(e.x,e.y,i,n,this.size.x,this.size.y);this.handleMovementTrace(s)&&a(this,s);var o=this.gameObject;o&&(o.x=e.x-this.offset.x+o.displayOriginX*o.scaleX,o.y=e.y-this.offset.y+o.displayOriginY*o.scaleY),this.updateCallback&&this.updateCallback(this)},drawDebug:function(t){var e=this.pos;if(this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.size.x,this.size.y)),this.debugShowVelocity){var i=e.x+this.size.x/2,n=e.y+this.size.y/2;t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.vel.x,n+this.vel.y)}},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},skipHash:function(){return!this.enabled||0===this.type&&0===this.checkAgainst&&0===this.collides},touches:function(t){return!(this.pos.x>=t.pos.x+t.size.x||this.pos.x+this.size.x<=t.pos.x||this.pos.y>=t.pos.y+t.size.y||this.pos.y+this.size.y<=t.pos.y)},resetSize:function(t,e,i,n){return this.pos.x=t,this.pos.y=e,this.size.x=i,this.size.y=n,this},toJSON:function(){return{name:this.name,size:{x:this.size.x,y:this.size.y},pos:{x:this.pos.x,y:this.pos.y},vel:{x:this.vel.x,y:this.vel.y},accel:{x:this.accel.x,y:this.accel.y},friction:{x:this.friction.x,y:this.friction.y},maxVel:{x:this.maxVel.x,y:this.maxVel.y},gravityFactor:this.gravityFactor,bounciness:this.bounciness,minBounceVelocity:this.minBounceVelocity,type:this.type,checkAgainst:this.checkAgainst,collides:this.collides}},fromJSON:function(){},check:function(){},collideWith:function(t,e){this.parent&&this.parent._collideCallback&&this.parent._collideCallback.call(this.parent._callbackScope,this,t,e)},handleMovementTrace:function(){return!0},destroy:function(){this.world.remove(this),this.enabled=!1,this.world=null,this.gameObject=null,this.parent=null}});t.exports=h},,,function(t,e,i){var n=i(676),s={name:"matter-wrap",version:"0.1.4",for:"matter-js@^0.13.1",silent:!0,install:function(t){t.after("Engine.update",function(){s.Engine.update(this)})},Engine:{update:function(t){for(var e=t.world,i=n.Composite.allBodies(e),r=n.Composite.allComposites(e),o=0;oe.max.x?i=e.min.x-t.max.x:t.max.xe.max.y?n=e.min.y-t.max.y:t.max.y0)for(var a=s+1;a1;if(!c||t!=c.x||e!=c.y){c&&n?(d=c.x,f=c.y):(d=0,f=0);var s={x:d+t,y:f+e};!n&&c||(c=s),p.push(s),v=d+t,y=f+e}},x=function(t){var e=t.pathSegTypeAsLetter.toUpperCase();if("Z"!==e){switch(e){case"M":case"L":case"T":case"C":case"S":case"Q":v=t.x,y=t.y;break;case"H":v=t.x;break;case"V":y=t.y}m(v,y,t.pathSegType)}};for(t(e),r=e.getTotalLength(),h=[],n=0;n1?1:0;n0))r=t.collisionMap.trace(e.pos.x,e.pos.y,0,-(e.pos.y+e.size.y-i.pos.y),e.size.x,e.size.y),e.pos.y=r.pos.y,e.bounciness>0&&e.vel.y>e.minBounceVelocity?e.vel.y*=-e.bounciness:(e.standing=!0,e.vel.y=0);else{var l=(e.vel.y-i.vel.y)/2;e.vel.y=-l,i.vel.y=l,s=i.vel.x*t.delta,r=t.collisionMap.trace(e.pos.x,e.pos.y,s,-o/2,e.size.x,e.size.y),e.pos.y=r.pos.y;var u=t.collisionMap.trace(i.pos.x,i.pos.y,0,o/2,i.size.x,i.size.y);i.pos.y=u.pos.y}}},function(t,e){t.exports=function(t,e,i,n){var s=e.pos.x+e.size.x-i.pos.x;if(n){var r=e===n?i:e;n.vel.x=-n.vel.x*n.bounciness+r.vel.x;var o=t.collisionMap.trace(n.pos.x,n.pos.y,n===e?-s:s,0,n.size.x,n.size.y);n.pos.x=o.pos.x}else{var a=(e.vel.x-i.vel.x)/2;e.vel.x=-a,i.vel.x=a;var h=t.collisionMap.trace(e.pos.x,e.pos.y,-s/2,0,e.size.x,e.size.y);e.pos.x=Math.floor(h.pos.x);var l=t.collisionMap.trace(i.pos.x,i.pos.y,s/2,0,i.size.x,i.size.y);i.pos.x=Math.ceil(l.pos.x)}}},function(t,e,i){var n=i(333),s=i(1051),r=i(1050);t.exports=function(t,e,i){var o=null;e.collides===n.LITE||i.collides===n.FIXED?o=e:i.collides!==n.LITE&&e.collides!==n.FIXED||(o=i),e.last.x+e.size.x>i.last.x&&e.last.xi.last.y&&e.last.y0&&Math.abs(t.vel.y)>t.minBounceVelocity?t.vel.y*=-t.bounciness:(t.vel.y>0&&(t.standing=!0),t.vel.y=0)),e.collision.x&&(t.bounciness>0&&Math.abs(t.vel.x)>t.minBounceVelocity?t.vel.x*=-t.bounciness:t.vel.x=0),e.collision.slope){var i=e.collision.slope;if(t.bounciness>0){var n=t.vel.x*i.nx+t.vel.y*i.ny;t.vel.x=(t.vel.x-i.nx*n*2)*t.bounciness,t.vel.y=(t.vel.y-i.ny*n*2)*t.bounciness}else{var s=i.x*i.x+i.y*i.y,r=(t.vel.x*i.x+t.vel.y*i.y)/s;t.vel.x=i.x*r,t.vel.y=i.y*r;var o=Math.atan2(i.x,i.y);o>t.slopeStanding.min&&o0?e-o:e+o<0?e+o:0}return n(e,-r,r)}},function(t,e,i){t.exports={Body:i(1025),COLLIDES:i(333),CollisionMap:i(1024),Factory:i(1023),Image:i(1021),ImpactBody:i(1022),ImpactPhysics:i(1053),Sprite:i(1020),TYPE:i(332),World:i(1019)}},function(t,e,i){t.exports={Arcade:i(703),Impact:i(1069),Matter:i(1049)}},function(t,e,i){(function(e){i(609);var n=i(20),s=i(17),r={Actions:i(599),Animation:i(568),Cache:i(567),Cameras:i(960),Class:i(0),Create:i(954),Curves:i(948),Data:i(544),Display:i(945),DOM:i(916),Events:i(536),Game:i(534),GameObjects:i(915),Geom:i(400),Input:i(383),Loader:i(759),Math:i(745),Physics:i(1070),Plugins:i(330),Renderer:i(673),Scene:i(193),Scenes:i(328),Sound:i(326),Structs:i(325),Textures:i(324),Tilemaps:i(668),Time:i(308),Tweens:i(306),Utils:i(619)};r=s(!1,r,n),t.exports=r,e.Phaser=r}).call(this,i(215))}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Phaser",[],e):"object"==typeof exports?exports.Phaser=e():t.Phaser=e()}(window,function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},i.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=1127)}([function(t,e){function i(t,e,i){var n=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&n.value&&"object"==typeof n.value&&(n=n.value),!(!n||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(n))&&(void 0===n.enumerable&&(n.enumerable=!0),void 0===n.configurable&&(n.configurable=!0),n)}function n(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function s(t,e,s,r){for(var a in e)if(e.hasOwnProperty(a)){var h=i(e,a,s);if(!1!==h){if(n((r||t).prototype,a)){if(o.ignoreFinals)continue;throw new Error("cannot override final property '"+a+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,a,h)}else t.prototype[a]=e[a]}}function r(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},transformMat3:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this},transformMat4:function(t){var e=this.x,i=this.y,n=t.val;return this.x=n[0]*e+n[4]*i+n[12],this.y=n[1]*e+n[5]*i+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,e){t.exports=function(t,e,i){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(e.indexOf(".")){for(var n=e.split("."),s=t,r=i,o=0;o=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=l},function(t,e){t.exports={getTintFromFloats:function(t,e,i,n){return((255&(255*n|0))<<24|(255&(255*t|0))<<16|(255&(255*e|0))<<8|255&(255*i|0))>>>0},getTintAppendFloatAlpha:function(t,e){return((255&(255*e|0))<<24|t)>>>0},getTintAppendFloatAlphaAndSwap:function(t,e){return((255&(255*e|0))<<24|(255&(0|t))<<16|(255&(t>>8|0))<<8|255&(t>>16|0))>>>0},getFloatsFromUintRGB:function(t){return[(255&(t>>16|0))/255,(255&(t>>8|0))/255,(255&(0|t))/255]},getComponentCount:function(t,e){for(var i=0,n=0;no.width&&(i=Math.max(o.width-t,0)),e+s>o.height&&(s=Math.max(o.height-e,0));for(var u=[],c=e;c0&&this.cameraFilter&t.id)},getIndexList:function(){for(var t=this,e=this.parentContainer,i=[];e&&(i.unshift(e.getIndex(t)),t=e,e.parentContainer);)e=e.parentContainer;return i.unshift(this.scene.sys.displayList.getIndex(t)),i},destroy:function(t){if(void 0===t&&(t=!1),this.scene&&!this.ignoreDestroy){this.preDestroy&&this.preDestroy.call(this),this.emit("destroy",this);var e=this.scene.sys;t||(e.displayList.remove(this),e.updateList.remove(this)),this.input&&(e.input.clear(this),this.input=void 0),this.data&&(this.data.destroy(),this.data=void 0),this.body&&(this.body.destroy(),this.body=void 0),t||e.queueDepthSort(),this.active=!1,this.visible=!1,this.scene=void 0,this.parentContainer=void 0,this.removeAllListeners()}}});a.RENDER_MASK=15,t.exports=a},function(t,e,i){var n=i(8),s=function(){var t,e,i,r,o,a,h=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof h&&(c=h,h=arguments[1]||{},l=2),u===l&&(h=this,--l);l=400&&t.status<=599&&(i=!1),this.resetXHR(),this.loader.nextFile(this,i)},onError:function(){this.resetXHR(),this.loader.nextFile(this,!1)},onProgress:function(t){t.lengthComputable&&(this.bytesLoaded=t.loaded,this.bytesTotal=t.total,this.percentComplete=Math.min(this.bytesLoaded/this.bytesTotal,1),this.loader.emit("fileprogress",this,this.percentComplete))},onProcess:function(){this.state=s.FILE_PROCESSING,this.onProcessComplete()},onProcessComplete:function(){this.state=s.FILE_COMPLETE,this.multiFile&&this.multiFile.onFileComplete(this),this.loader.fileProcessComplete(this)},onProcessError:function(){this.state=s.FILE_ERRORED,this.multiFile&&this.multiFile.onFileFailed(this),this.loader.fileProcessComplete(this)},hasCacheConflict:function(){return this.cache&&this.cache.exists(this.key)},addToCache:function(){this.cache&&this.cache.add(this.key,this.data),this.pendingDestroy()},pendingDestroy:function(t){void 0===t&&(t=this.data);var e=this.key,i=this.type;this.loader.emit("filecomplete",e,i,t),this.loader.emit("filecomplete-"+i+"-"+e,e,i,t),this.loader.flagForRemoval(this)},destroy:function(){this.loader=null,this.cache=null,this.xhrSettings=null,this.multiFile=null,this.linkFile=null,this.data=null}});u.createObjectURL=function(t,e,i){if("function"==typeof URL)t.src=URL.createObjectURL(e);else{var n=new FileReader;n.onload=function(){t.removeAttribute("crossOrigin"),t.src="data:"+(e.type||i)+";base64,"+n.result.split(",")[1]},n.onerror=t.onerror,n.readAsDataURL(e)}},u.revokeObjectURL=function(t){"function"==typeof URL&&URL.revokeObjectURL(t.src)},t.exports=u},function(t,e){t.exports=function(t,e,i,n,s){var r=n.alpha*i.alpha;if(r<=0)return!1;var o=t._tempMatrix1.copyFromArray(n.matrix.matrix),a=t._tempMatrix2.applyITRS(i.x,i.y,i.rotation,i.scaleX,i.scaleY),h=t._tempMatrix3;return s?(o.multiplyWithOffset(s,-n.scrollX*i.scrollFactorX,-n.scrollY*i.scrollFactorY),a.e=i.x,a.f=i.y,o.multiply(a,h)):(a.e-=n.scrollX*i.scrollFactorX,a.f-=n.scrollY*i.scrollFactorY,o.multiply(a,h)),e.globalCompositeOperation=t.blendModes[i.blendMode],e.globalAlpha=r,e.save(),h.setToContext(e),!0}},function(t,e){t.exports=function(t,e,i){return Math.max(e,Math.min(i,t))}},function(t,e,i){var n,s,r,o=i(26),a=i(120),h=[],l=!1;t.exports={create2D:function(t,e,i){return n(t,e,i,o.CANVAS)},create:n=function(t,e,i,n,r){var u;void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=o.CANVAS),void 0===r&&(r=!1);var c=s(n);return null===c?(c={parent:t,canvas:document.createElement("canvas"),type:n},n===o.CANVAS&&h.push(c),u=c.canvas):(c.parent=t,u=c.canvas),r&&(c.parent=u),u.width=e,u.height=i,l&&n===o.CANVAS&&a.disable(u.getContext("2d")),u},createWebGL:function(t,e,i){return n(t,e,i,o.WEBGL)},disableSmoothing:function(){l=!0},enableSmoothing:function(){l=!1},first:s=function(t){if(void 0===t&&(t=o.CANVAS),t===o.WEBGL)return null;for(var e=0;e=0;o--)t[o][e]=i+a*n,a++;return t}},function(t,e,i){var n={VERSION:"3.15.1",BlendModes:i(66),ScaleModes:i(94),AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,FOREVER:-1,NONE:4,UP:5,DOWN:6,LEFT:7,RIGHT:8};t.exports=n},function(t,e,i){var n=i(0),s=i(14),r=i(19),o=i(54),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.ComputedSize,s.Depth,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.ScrollFactor,s.Transform,s.Visible],initialize:function(t,e,i){void 0===e&&(e="Shape"),r.call(this,t,e),this.geom=i,this.pathData=[],this.pathIndexes=[],this.fillColor=16777215,this.fillAlpha=1,this.strokeColor=16777215,this.strokeAlpha=1,this.lineWidth=1,this.isFilled=!1,this.isStroked=!1,this.closePath=!0,this._tempLine=new o,this.initPipeline()},setFillStyle:function(t,e){return void 0===e&&(e=1),void 0===t?this.isFilled=!1:(this.fillColor=t,this.fillAlpha=e,this.isFilled=!0),this},setStrokeStyle:function(t,e,i){return void 0===i&&(i=1),void 0===t?this.isStroked=!1:(this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i,this.isStroked=!0),this},setClosePath:function(t){return this.closePath=t,this},preDestroy:function(){this.geom=null,this._tempLine=null,this.pathData=[],this.pathIndexes=[]}});t.exports=a},function(t,e,i){var n=i(66),s=i(12),r=i(94);t.exports=function(t,e,i){e.x=s(i,"x",0),e.y=s(i,"y",0),e.depth=s(i,"depth",0),e.flipX=s(i,"flipX",!1),e.flipY=s(i,"flipY",!1);var o=s(i,"scale",null);"number"==typeof o?e.setScale(o):null!==o&&(e.scaleX=s(o,"x",1),e.scaleY=s(o,"y",1));var a=s(i,"scrollFactor",null);"number"==typeof a?e.setScrollFactor(a):null!==a&&(e.scrollFactorX=s(a,"x",1),e.scrollFactorY=s(a,"y",1)),e.rotation=s(i,"rotation",0);var h=s(i,"angle",null);null!==h&&(e.angle=h),e.alpha=s(i,"alpha",1);var l=s(i,"origin",null);if("number"==typeof l)e.setOrigin(l);else if(null!==l){var u=s(l,"x",.5),c=s(l,"y",.5);e.setOrigin(u,c)}return e.scaleMode=s(i,"scaleMode",r.DEFAULT),e.blendMode=s(i,"blendMode",n.NORMAL),e.visible=s(i,"visible",!0),s(i,"add",!0)&&t.sys.displayList.add(e),e.preUpdate&&t.sys.updateList.add(e),e}},function(t,e){t.exports={CSV:0,TILED_JSON:1,ARRAY_2D:2,WELTMEISTER:3}},function(t,e){t.exports=function(t,e,i){var n=i||e.fillColor,s=e.fillAlpha,r=(16711680&n)>>>16,o=(65280&n)>>>8,a=255&n;t.fillStyle="rgba("+r+","+o+","+a+","+s+")"}},function(t,e,i){var n=i(16);t.exports=function(t){return t*n.DEG_TO_RAD}},function(t,e){t.exports=function(t,e,i,n,s,r){var o;void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=1);var a=0,h=t.length;if(1===r)for(o=s;o=0;o--)t[o][e]+=i+a*n,a++;return t}},function(t,e,i){(function(e){var i={};t.exports=i,function(){i._nextId=0,i._seed=0,i._nowStartTime=+new Date,i.extend=function(t,e){var n,s;"boolean"==typeof e?(n=2,s=e):(n=1,s=!0);for(var r=n;r0;e--){var n=Math.floor(i.random()*(e+1)),s=t[e];t[e]=t[n],t[n]=s}return t},i.choose=function(t){return t[Math.floor(i.random()*t.length)]},i.isElement=function(t){return"undefined"!=typeof HTMLElement?t instanceof HTMLElement:!!(t&&t.nodeType&&t.nodeName)},i.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},i.isFunction=function(t){return"function"==typeof t},i.isPlainObject=function(t){return"object"==typeof t&&t.constructor===Object},i.isString=function(t){return"[object String]"===toString.call(t)},i.clamp=function(t,e,i){return ti?i:t},i.sign=function(t){return t<0?-1:1},i.now=function(){if(window.performance){if(window.performance.now)return window.performance.now();if(window.performance.webkitNow)return window.performance.webkitNow()}return new Date-i._nowStartTime},i.random=function(e,i){return e=void 0!==e?e:0,i=void 0!==i?i:1,e+t()*(i-e)};var t=function(){return i._seed=(9301*i._seed+49297)%233280,i._seed/233280};i.colorToNumber=function(t){return 3==(t=t.replace("#","")).length&&(t=t.charAt(0)+t.charAt(0)+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)),parseInt(t,16)},i.logLevel=1,i.log=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.log.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.info=function(){console&&i.logLevel>0&&i.logLevel<=2&&console.info.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.warn=function(){console&&i.logLevel>0&&i.logLevel<=3&&console.warn.apply(console,["matter-js:"].concat(Array.prototype.slice.call(arguments)))},i.nextId=function(){return i._nextId++},i.indexOf=function(t,e){if(t.indexOf)return t.indexOf(e);for(var i=0;i>>16,r=(65280&i)>>>8,o=255&i;t.strokeStyle="rgba("+s+","+r+","+o+","+n+")",t.lineWidth=e.lineWidth}},function(t,e,i){var n=i(0),s=i(177),r=i(376),o=i(176),a=i(375),h=new n({initialize:function(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=255),this.r=0,this.g=0,this.b=0,this.a=255,this._h=0,this._s=0,this._v=0,this._locked=!1,this.gl=[0,0,0,1],this._color=0,this._color32=0,this._rgba="",this.setTo(t,e,i,n)},transparent:function(){return this._locked=!0,this.red=0,this.green=0,this.blue=0,this.alpha=0,this._locked=!1,this.update(!0)},setTo:function(t,e,i,n,s){return void 0===n&&(n=255),void 0===s&&(s=!0),this._locked=!0,this.red=t,this.green=e,this.blue=i,this.alpha=n,this._locked=!1,this.update(s)},setGLTo:function(t,e,i,n){return void 0===n&&(n=1),this._locked=!0,this.redGL=t,this.greenGL=e,this.blueGL=i,this.alphaGL=n,this._locked=!1,this.update(!0)},setFromRGB:function(t){return this._locked=!0,this.red=t.r,this.green=t.g,this.blue=t.b,t.hasOwnProperty("a")&&(this.alpha=t.a),this._locked=!1,this.update(!0)},setFromHSV:function(t,e,i){return o(t,e,i,this)},update:function(t){if(void 0===t&&(t=!1),this._locked)return this;var e=this.r,i=this.g,n=this.b,o=this.a;return this._color=s(e,i,n),this._color32=r(e,i,n,o),this._rgba="rgba("+e+","+i+","+n+","+o/255+")",t&&a(e,i,n,this),this},updateHSV:function(){var t=this.r,e=this.g,i=this.b;return a(t,e,i,this),this},clone:function(){return new h(this.r,this.g,this.b,this.a)},gray:function(t){return this.setTo(t,t,t)},random:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t)),n=Math.floor(t+Math.random()*(e-t)),s=Math.floor(t+Math.random()*(e-t));return this.setTo(i,n,s)},randomGray:function(t,e){void 0===t&&(t=0),void 0===e&&(e=255);var i=Math.floor(t+Math.random()*(e-t));return this.setTo(i,i,i)},saturate:function(t){return this.s+=t/100,this},desaturate:function(t){return this.s-=t/100,this},lighten:function(t){return this.v+=t/100,this},darken:function(t){return this.v-=t/100,this},brighten:function(t){var e=this.r,i=this.g,n=this.b;return e=Math.max(0,Math.min(255,e-Math.round(-t/100*255))),i=Math.max(0,Math.min(255,i-Math.round(-t/100*255))),n=Math.max(0,Math.min(255,n-Math.round(-t/100*255))),this.setTo(e,i,n)},color:{get:function(){return this._color}},color32:{get:function(){return this._color32}},rgba:{get:function(){return this._rgba}},redGL:{get:function(){return this.gl[0]},set:function(t){this.gl[0]=Math.min(Math.abs(t),1),this.r=Math.floor(255*this.gl[0]),this.update(!0)}},greenGL:{get:function(){return this.gl[1]},set:function(t){this.gl[1]=Math.min(Math.abs(t),1),this.g=Math.floor(255*this.gl[1]),this.update(!0)}},blueGL:{get:function(){return this.gl[2]},set:function(t){this.gl[2]=Math.min(Math.abs(t),1),this.b=Math.floor(255*this.gl[2]),this.update(!0)}},alphaGL:{get:function(){return this.gl[3]},set:function(t){this.gl[3]=Math.min(Math.abs(t),1),this.a=Math.floor(255*this.gl[3]),this.update()}},red:{get:function(){return this.r},set:function(t){t=Math.floor(Math.abs(t)),this.r=Math.min(t,255),this.gl[0]=t/255,this.update(!0)}},green:{get:function(){return this.g},set:function(t){t=Math.floor(Math.abs(t)),this.g=Math.min(t,255),this.gl[1]=t/255,this.update(!0)}},blue:{get:function(){return this.b},set:function(t){t=Math.floor(Math.abs(t)),this.b=Math.min(t,255),this.gl[2]=t/255,this.update(!0)}},alpha:{get:function(){return this.a},set:function(t){t=Math.floor(Math.abs(t)),this.a=Math.min(t,255),this.gl[3]=t/255,this.update()}},h:{get:function(){return this._h},set:function(t){this._h=t,o(t,this._s,this._v,this)}},s:{get:function(){return this._s},set:function(t){this._s=t,o(this._h,t,this._v,this)}},v:{get:function(){return this._v},set:function(t){this._v=t,o(this._h,this._s,t,this)}}});t.exports=h},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(t,e,i,n,s,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,e,i,n,s,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0}},a:{get:function(){return this.matrix[0]},set:function(t){this.matrix[0]=t}},b:{get:function(){return this.matrix[1]},set:function(t){this.matrix[1]=t}},c:{get:function(){return this.matrix[2]},set:function(t){this.matrix[2]=t}},d:{get:function(){return this.matrix[3]},set:function(t){this.matrix[3]=t}},e:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},f:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},tx:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},ty:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},rotation:{get:function(){return Math.acos(this.a/this.scaleX)*(Math.atan(-this.c/this.a)<0?-1:1)}},scaleX:{get:function(){return Math.sqrt(this.a*this.a+this.c*this.c)}},scaleY:{get:function(){return Math.sqrt(this.b*this.b+this.d*this.d)}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,e){var i=this.matrix;return i[4]=i[0]*t+i[2]*e+i[4],i[5]=i[1]*t+i[3]*e+i[5],this},scale:function(t,e){var i=this.matrix;return i[0]*=t,i[1]*=t,i[2]*=e,i[3]*=e,this},rotate:function(t){var e=Math.sin(t),i=Math.cos(t),n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3];return n[0]=s*i+o*e,n[1]=r*i+a*e,n[2]=s*-e+o*i,n[3]=r*-e+a*i,this},multiply:function(t,e){var i=this.matrix,n=t.matrix,s=i[0],r=i[1],o=i[2],a=i[3],h=i[4],l=i[5],u=n[0],c=n[1],d=n[2],f=n[3],p=n[4],g=n[5],v=void 0===e?this:e;return v.a=u*s+c*o,v.b=u*r+c*a,v.c=d*s+f*o,v.d=d*r+f*a,v.e=p*s+g*o+h,v.f=p*r+g*a+l,v},multiplyWithOffset:function(t,e,i){var n=this.matrix,s=t.matrix,r=n[0],o=n[1],a=n[2],h=n[3],l=e*r+i*a+n[4],u=e*o+i*h+n[5],c=s[0],d=s[1],f=s[2],p=s[3],g=s[4],v=s[5];return n[0]=c*r+d*a,n[1]=c*o+d*h,n[2]=f*r+p*a,n[3]=f*o+p*h,n[4]=g*r+v*a+l,n[5]=g*o+v*h+u,this},transform:function(t,e,i,n,s,r){var o=this.matrix,a=o[0],h=o[1],l=o[2],u=o[3],c=o[4],d=o[5];return o[0]=t*a+e*l,o[1]=t*h+e*u,o[2]=i*a+n*l,o[3]=i*h+n*u,o[4]=s*a+r*l+c,o[5]=s*h+r*u+d,this},transformPoint:function(t,e,i){void 0===i&&(i={x:0,y:0});var n=this.matrix,s=n[0],r=n[1],o=n[2],a=n[3],h=n[4],l=n[5];return i.x=t*s+e*o+h,i.y=t*r+e*a+l,i},invert:function(){var t=this.matrix,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=e*s-i*n;return t[0]=s/a,t[1]=-i/a,t[2]=-n/a,t[3]=e/a,t[4]=(n*o-s*r)/a,t[5]=-(e*o-i*r)/a,this},copyFrom:function(t){var e=this.matrix;return e[0]=t.a,e[1]=t.b,e[2]=t.c,e[3]=t.d,e[4]=t.e,e[5]=t.f,this},copyFromArray:function(t){var e=this.matrix;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],this},copyToContext:function(t){var e=this.matrix;return t.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t},setToContext:function(t){var e=this.matrix;return t.setTransform(e[0],e[1],e[2],e[3],e[4],e[5]),t},copyToArray:function(t){var e=this.matrix;return void 0===t?t=[e[0],e[1],e[2],e[3],e[4],e[5]]:(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5]),t},setTransform:function(t,e,i,n,s,r){var o=this.matrix;return o[0]=t,o[1]=e,o[2]=i,o[3]=n,o[4]=s,o[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,e=this.matrix,i=e[0],n=e[1],s=e[2],r=e[3],o=i*i,a=n*n,h=s*s,l=r*r,u=Math.sqrt(o+h),c=Math.sqrt(a+l);return t.translateX=e[4],t.translateY=e[5],t.scaleX=u,t.scaleY=c,t.rotation=Math.acos(i/u)*(Math.atan(-s/i)<0?-1:1),t},applyITRS:function(t,e,i,n,s){var r=this.matrix,o=Math.sin(i),a=Math.cos(i);return r[4]=t,r[5]=e,r[0]=a*n,r[1]=o*n,r[2]=-o*s,r[3]=a*s,this},applyInverse:function(t,e,i){void 0===i&&(i=new s);var n=this.matrix,r=n[0],o=n[1],a=n[2],h=n[3],l=n[4],u=n[5],c=1/(r*h+a*-o);return i.x=h*c*t+-a*c*e+(u*a-l*h)*c,i.y=r*c*e+-o*c*t+(-u*r+l*o)*c,i},getX:function(t,e){return t*this.a+e*this.c+this.e},getY:function(t,e){return t*this.b+e*this.d+this.f},getCSSMatrix:function(){var t=this.matrix;return"matrix("+t[0]+","+t[1]+","+t[2]+","+t[3]+","+t[4]+","+t[5]+")"},destroy:function(){this.matrix=null,this.decomposedMatrix=null}});t.exports=r},function(t,e){t.exports=function(t,e,i){return!(t.width<=0||t.height<=0)&&t.x<=e&&t.x+t.width>=e&&t.y<=i&&t.y+t.height>=i}},function(t,e){t.exports=function(t,e,i){return t.radius>0&&e>=t.left&&e<=t.right&&i>=t.top&&i<=t.bottom&&(t.x-e)*(t.x-e)+(t.y-i)*(t.y-i)<=t.radius*t.radius}},function(t,e){t.exports=function(t,e){return t.y=e+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y-t.height*t.originY}},function(t,e){t.exports=function(t,e){return t.x=e-t.width+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x+t.width-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.x=e+t.width*t.originX,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX}},function(t,e){t.exports=function(t,e){return t.y=e-t.height+t.height*t.originY,t}},function(t,e){t.exports=function(t){return t.y+t.height-t.height*t.originY}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileHeight,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.y+i.scrollY*(1-r.scrollFactorY),s*=r.scaleY),e?Math.floor(t/s):t/s}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=!0);var s=n.baseTileWidth,r=n.tilemapLayer;return r&&(void 0===i&&(i=r.scene.cameras.main),t-=r.x+i.scrollX*(1-r.scrollFactorX),s*=r.scaleX),e?Math.floor(t/s):t/s}},function(t,e,i){var n=i(0),s=i(18),r=i(21),o=i(7),a=i(2),h=i(4),l=i(8),u=new n({Extends:r,initialize:function(t,e,i,n,o){var u="json";if(l(e)){var c=e;e=a(c,"key"),i=a(c,"url"),n=a(c,"xhrSettings"),u=a(c,"extension",u),o=a(c,"dataKey",o)}var d={type:"json",cache:t.cacheManager.json,extension:u,responseType:"text",key:e,url:i,xhrSettings:n,config:o};r.call(this,t,d),l(i)&&(this.data=o?h(i,o):i,this.state=s.FILE_POPULATED)},onProcess:function(){if(this.state!==s.FILE_POPULATED){this.state=s.FILE_PROCESSING;var t=JSON.parse(this.xhrLoader.responseText),e=this.config;this.data="string"==typeof e?h(t,e,t):t}this.onProcessComplete()}});o.register("json",function(t,e,i,n){if(Array.isArray(t))for(var s=0;sthis.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=h},function(t,e,i){var n=i(0),s=i(14),r=i(265),o=new n({Mixins:[s.Alpha,s.Flip,s.Visible],initialize:function(t,e,i,n,s,r,o,a){this.layer=t,this.index=e,this.x=i,this.y=n,this.width=s,this.height=r,this.baseWidth=void 0!==o?o:s,this.baseHeight=void 0!==a?a:r,this.pixelX=0,this.pixelY=0,this.updatePixelXY(),this.properties={},this.rotation=0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceLeft=!1,this.faceRight=!1,this.faceTop=!1,this.faceBottom=!1,this.collisionCallback=null,this.collisionCallbackContext=this,this.tint=16777215,this.physics={}},containsPoint:function(t,e){return!(tthis.right||e>this.bottom)},copy:function(t){return this.index=t.index,this.alpha=t.alpha,this.properties=t.properties,this.visible=t.visible,this.setFlip(t.flipX,t.flipY),this.tint=t.tint,this.rotation=t.rotation,this.collideUp=t.collideUp,this.collideDown=t.collideDown,this.collideLeft=t.collideLeft,this.collideRight=t.collideRight,this.collisionCallback=t.collisionCallback,this.collisionCallbackContext=t.collisionCallbackContext,this},getCollisionGroup:function(){return this.tileset?this.tileset.getTileCollisionGroup(this.index):null},getTileData:function(){return this.tileset?this.tileset.getTileData(this.index):null},getLeft:function(t){var e=this.tilemapLayer;return e?e.tileToWorldX(this.x,t):this.x*this.baseWidth},getRight:function(t){var e=this.tilemapLayer;return e?this.getLeft(t)+this.width*e.scaleX:this.getLeft(t)+this.width},getTop:function(t){var e=this.tilemapLayer;return e?e.tileToWorldY(this.y,t)-(this.height-this.baseHeight)*e.scaleY:this.y*this.baseHeight-(this.height-this.baseHeight)},getBottom:function(t){var e=this.tilemapLayer;return e?this.getTop(t)+this.height*e.scaleY:this.getTop(t)+this.height},getBounds:function(t,e){return void 0===e&&(e=new r),e.x=this.getLeft(),e.y=this.getTop(),e.width=this.getRight()-e.x,e.height=this.getBottom()-e.y,e},getCenterX:function(t){return this.getLeft(t)+this.width/2},getCenterY:function(t){return this.getTop(t)+this.height/2},destroy:function(){this.collisionCallback=void 0,this.collisionCallbackContext=void 0,this.properties=void 0},intersects:function(t,e,i,n){return!(i<=this.pixelX||n<=this.pixelY||t>=this.right||e>=this.bottom)},isInteresting:function(t,e){return t&&e?this.canCollide||this.hasInterestingFace:t?this.collides:!!e&&this.hasInterestingFace},resetCollision:function(t){(void 0===t&&(t=!0),this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,t)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},resetFaces:function(){return this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this},setCollision:function(t,e,i,n,s){(void 0===e&&(e=t),void 0===i&&(i=t),void 0===n&&(n=t),void 0===s&&(s=!0),this.collideLeft=t,this.collideRight=e,this.collideUp=i,this.collideDown=n,this.faceLeft=t,this.faceRight=e,this.faceTop=i,this.faceBottom=n,s)&&(this.tilemapLayer&&this.tilemapLayer.calculateFacesAt(this.x,this.y));return this},setCollisionCallback:function(t,e){return null===t?(this.collisionCallback=void 0,this.collisionCallbackContext=void 0):(this.collisionCallback=t,this.collisionCallbackContext=e),this},setSize:function(t,e,i,n){return void 0!==t&&(this.width=t),void 0!==e&&(this.height=e),void 0!==i&&(this.baseWidth=i),void 0!==n&&(this.baseHeight=n),this.updatePixelXY(),this},updatePixelXY:function(){return this.pixelX=this.x*this.baseWidth,this.pixelY=this.y*this.baseHeight-(this.height-this.baseHeight),this},canCollide:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}},collides:{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}},hasInterestingFace:{get:function(){return this.faceTop||this.faceBottom||this.faceLeft||this.faceRight}},tileset:{get:function(){var t=this.tilemapLayer;return t?t.tileset:null}},tilemapLayer:{get:function(){return this.layer.tilemapLayer}},tilemap:{get:function(){var t=this.tilemapLayer;return t?t.tilemap:null}}});t.exports=o},function(t,e){t.exports=function(t,e){e?t.setCollision(!0,!0,!0,!0,!1):t.resetCollision(!1)}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n){this.loader=t,this.type=e,this.key=i,this.files=n,this.complete=!1,this.pending=n.length,this.failed=0,this.config={};for(var s=0;s=this.x2&&this.x1>=this.x3?this.x1-t:this.x2>=this.x1&&this.x2>=this.x3?this.x2-t:this.x3-t,this.x1-=e,this.x2-=e,this.x3-=e}},top:{get:function(){return Math.min(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1<=this.y2&&this.y1<=this.y3?this.y1-t:this.y2<=this.y1&&this.y2<=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}},bottom:{get:function(){return Math.max(this.y1,this.y2,this.y3)},set:function(t){var e=0;e=this.y1>=this.y2&&this.y1>=this.y3?this.y1-t:this.y2>=this.y1&&this.y2>=this.y3?this.y2-t:this.y3-t,this.y1-=e,this.y2-=e,this.y3-=e}}});t.exports=l},function(t,e,i){var n=i(10);t.exports=function(t,e,i,s,r){var o=t.strokeTint,a=n.getTintAppendFloatAlphaAndSwap(e.strokeColor,e.strokeAlpha*i);o.TL=a,o.TR=a,o.BL=a,o.BR=a;var h=e.pathData,l=h.length-1,u=e.lineWidth,c=u/2,d=h[0]-s,f=h[1]-r;e.closePath||(l-=2);for(var p=2;ps||e>=i||i>s||e+i>s){if(n)throw new Error("Range Error: Values outside acceptable range");return!1}return!0}},function(t,e){t.exports=function(t){var e={};for(var i in t)Array.isArray(t[i])?e[i]=t[i].slice(0):e[i]=t[i];return e}},function(t,e,i){"use strict";function n(t,e,i){i=i||2;var n,a,h,l,u,f,g,v=e&&e.length,y=v?e[0]*i:t.length,m=s(t,0,y,i,!0),x=[];if(!m)return x;if(v&&(m=function(t,e,i,n){var o,a,h,l,u,f=[];for(o=0,a=e.length;o80*i){n=h=t[0],a=l=t[1];for(var w=i;wh&&(h=u),f>l&&(l=f);g=Math.max(h-n,l-a)}return o(m,x,i,n,a,g),x}function s(t,e,i,n,s){var r,o;if(s===A(t,e,i,n)>0)for(r=e;r=e;r-=n)o=T(r,t[r],t[r+1],o);return o&&m(o,o.next)&&(S(o),o=o.next),o}function r(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!m(n,n.next)&&0!==y(n.prev,n,n.next))n=n.next;else{if(S(n),(n=e=n.prev)===n.next)return null;i=!0}}while(i||n!==e);return e}function o(t,e,i,n,s,c,d){if(t){!d&&c&&function(t,e,i,n){var s=t;do{null===s.z&&(s.z=f(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,n,s,r,o,a,h,l=1;do{for(i=t,t=null,r=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0!==a&&(0===h||!n||i.z<=n.z)?(s=i,i=i.nextZ,a--):(s=n,n=n.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;i=n}r.nextZ=null,l*=2}while(o>1)}(s)}(t,n,s,c);for(var p,g,v=t;t.prev!==t.next;)if(p=t.prev,g=t.next,c?h(t,n,s,c):a(t))e.push(p.i/i),e.push(t.i/i),e.push(g.i/i),S(t),t=g.next,v=g.next;else if((t=g)===v){d?1===d?o(t=l(t,e,i),e,i,n,s,c,2):2===d&&u(t,e,i,n,s,c):o(r(t),e,i,n,s,c,1);break}}}function a(t){var e=t.prev,i=t,n=t.next;if(y(e,i,n)>=0)return!1;for(var s=t.next.next;s!==t.prev;){if(g(e.x,e.y,i.x,i.y,n.x,n.y,s.x,s.y)&&y(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function h(t,e,i,n){var s=t.prev,r=t,o=t.next;if(y(s,r,o)>=0)return!1;for(var a=s.xr.x?s.x>o.x?s.x:o.x:r.x>o.x?r.x:o.x,u=s.y>r.y?s.y>o.y?s.y:o.y:r.y>o.y?r.y:o.y,c=f(a,h,e,i,n),d=f(l,u,e,i,n),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&g(s.x,s.y,r.x,r.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function l(t,e,i){var n=t;do{var s=n.prev,r=n.next.next;!m(s,r)&&x(s,n,n.next,r)&&w(s,r)&&w(r,s)&&(e.push(s.i/i),e.push(n.i/i),e.push(r.i/i),S(n),S(n.next),n=t=r),n=n.next}while(n!==t);return n}function u(t,e,i,n,s,a){var h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&v(h,l)){var u=b(h,l);return h=r(h,h.next),u=r(u,u.next),o(h,e,i,n,s,a),void o(u,e,i,n,s,a)}l=l.next}h=h.next}while(h!==t)}function c(t,e){return t.x-e.x}function d(t,e){if(e=function(t,e){var i,n=e,s=t.x,r=t.y,o=-1/0;do{if(r<=n.y&&r>=n.next.y&&n.next.y!==n.y){var a=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=s&&a>o){if(o=a,a===s){if(r===n.y)return n;if(r===n.next.y)return n.next}i=n.x=n.x&&n.x>=u&&s!==n.x&&g(ri.x)&&w(n,t)&&(i=n,d=h),n=n.next;return i}(t,e)){var i=b(e,t);r(i,i.next)}}function f(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/s)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/s)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function p(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(r-a)-(s-o)*(n-a)>=0}function v(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&x(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&w(t,e)&&w(e,t)&&function(t,e){var i=t,n=!1,s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)}function y(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function m(t,e){return t.x===e.x&&t.y===e.y}function x(t,e,i,n){return!!(m(t,e)&&m(i,n)||m(t,n)&&m(i,e))||y(t,e,i)>0!=y(t,e,n)>0&&y(i,n,t)>0!=y(i,n,e)>0}function w(t,e){return y(t.prev,t,t.next)<0?y(t,e,t.next)>=0&&y(t,t.prev,e)>=0:y(t,e,t.prev)<0||y(t,t.next,e)<0}function b(t,e){var i=new _(t.i,t.x,t.y),n=new _(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function T(t,e,i,n){var s=new _(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function S(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function _(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function A(t,e,i,n){for(var s=0,r=e,o=i-n;r0&&(n+=t[s-1].length,i.holes.push(n))}return i}},function(t,e){t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},function(t,e){t.exports={SKIP_CHECK:-1,NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16}},function(t,e,i){var n={};t.exports=n;var s=i(76),r=i(81),o=i(222),a=i(33),h=i(80),l=i(505);!function(){n._inertiaScale=4,n._nextCollidingGroupId=1,n._nextNonCollidingGroupId=-1,n._nextCategory=1,n.create=function(e){var i={id:a.nextId(),type:"body",label:"Body",gameObject:null,parts:[],plugin:{},angle:0,vertices:s.fromPath("L 0 0 L 40 0 L 40 40 L 0 40"),position:{x:0,y:0},force:{x:0,y:0},torque:0,positionImpulse:{x:0,y:0},previousPositionImpulse:{x:0,y:0},constraintImpulse:{x:0,y:0,angle:0},totalContacts:0,speed:0,angularSpeed:0,velocity:{x:0,y:0},angularVelocity:0,isSensor:!1,isStatic:!1,isSleeping:!1,ignoreGravity:!1,ignorePointer:!1,motion:0,sleepThreshold:60,density:.001,restitution:0,friction:.1,frictionStatic:.5,frictionAir:.01,collisionFilter:{category:1,mask:4294967295,group:0},slop:.05,timeScale:1,render:{visible:!0,opacity:1,sprite:{xScale:1,yScale:1,xOffset:0,yOffset:0},lineWidth:0},events:null,bounds:null,chamfer:null,circleRadius:0,positionPrev:null,anglePrev:0,parent:null,axes:null,area:0,mass:0,inertia:0,_original:null},n=a.extend(i,e);return t(n,e),n},n.nextGroup=function(t){return t?n._nextNonCollidingGroupId--:n._nextCollidingGroupId++},n.nextCategory=function(){return n._nextCategory=n._nextCategory<<1,n._nextCategory};var t=function(t,e){e=e||{},n.set(t,{bounds:t.bounds||h.create(t.vertices),positionPrev:t.positionPrev||r.clone(t.position),anglePrev:t.anglePrev||t.angle,vertices:t.vertices,parts:t.parts||[t],isStatic:t.isStatic,isSleeping:t.isSleeping,parent:t.parent||t}),s.rotate(t.vertices,t.angle,t.position),l.rotate(t.axes,t.angle),h.update(t.bounds,t.vertices,t.velocity),n.set(t,{axes:e.axes||t.axes,area:e.area||t.area,mass:e.mass||t.mass,inertia:e.inertia||t.inertia});var i=t.isStatic?"#2e2b44":a.choose(["#006BA6","#0496FF","#FFBC42","#D81159","#8F2D56"]);t.render.fillStyle=t.render.fillStyle||i,t.render.strokeStyle=t.render.strokeStyle||"#000",t.render.sprite.xOffset+=-(t.bounds.min.x-t.position.x)/(t.bounds.max.x-t.bounds.min.x),t.render.sprite.yOffset+=-(t.bounds.min.y-t.position.y)/(t.bounds.max.y-t.bounds.min.y)};n.set=function(t,e,i){var s;for(s in"string"==typeof e&&(s=e,(e={})[s]=i),e)if(e.hasOwnProperty(s))switch(i=e[s],s){case"isStatic":n.setStatic(t,i);break;case"isSleeping":o.set(t,i);break;case"mass":n.setMass(t,i);break;case"density":n.setDensity(t,i);break;case"inertia":n.setInertia(t,i);break;case"vertices":n.setVertices(t,i);break;case"position":n.setPosition(t,i);break;case"angle":n.setAngle(t,i);break;case"velocity":n.setVelocity(t,i);break;case"angularVelocity":n.setAngularVelocity(t,i);break;case"parts":n.setParts(t,i);break;default:t[s]=i}},n.setStatic=function(t,e){for(var i=0;i0&&r.rotateAbout(o.position,i,t.position,o.position)}},n.setVelocity=function(t,e){t.positionPrev.x=t.position.x-e.x,t.positionPrev.y=t.position.y-e.y,t.velocity.x=e.x,t.velocity.y=e.y,t.speed=r.magnitude(t.velocity)},n.setAngularVelocity=function(t,e){t.anglePrev=t.angle-e,t.angularVelocity=e,t.angularSpeed=Math.abs(t.angularVelocity)},n.translate=function(t,e){n.setPosition(t,r.add(t.position,e))},n.rotate=function(t,e,i){if(i){var s=Math.cos(e),r=Math.sin(e),o=t.position.x-i.x,a=t.position.y-i.y;n.setPosition(t,{x:i.x+(o*s-a*r),y:i.y+(o*r+a*s)}),n.setAngle(t,t.angle+e)}else n.setAngle(t,t.angle+e)},n.scale=function(t,e,i,r){var o=0,a=0;r=r||t.position;for(var u=0;u0&&(o+=c.area,a+=c.inertia),c.position.x=r.x+(c.position.x-r.x)*e,c.position.y=r.y+(c.position.y-r.y)*i,h.update(c.bounds,c.vertices,t.velocity)}t.parts.length>1&&(t.area=o,t.isStatic||(n.setMass(t,t.density*o),n.setInertia(t,a))),t.circleRadius&&(e===i?t.circleRadius*=e:t.circleRadius=null)},n.update=function(t,e,i,n){var o=Math.pow(e*i*t.timeScale,2),a=1-t.frictionAir*i*t.timeScale,u=t.position.x-t.positionPrev.x,c=t.position.y-t.positionPrev.y;t.velocity.x=u*a*n+t.force.x/t.mass*o,t.velocity.y=c*a*n+t.force.y/t.mass*o,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.position.x+=t.velocity.x,t.position.y+=t.velocity.y,t.angularVelocity=(t.angle-t.anglePrev)*a*n+t.torque/t.inertia*o,t.anglePrev=t.angle,t.angle+=t.angularVelocity,t.speed=r.magnitude(t.velocity),t.angularSpeed=Math.abs(t.angularVelocity);for(var d=0;d0&&(f.position.x+=t.velocity.x,f.position.y+=t.velocity.y),0!==t.angularVelocity&&(s.rotate(f.vertices,t.angularVelocity,t.position),l.rotate(f.axes,t.angularVelocity),d>0&&r.rotateAbout(f.position,t.angularVelocity,t.position,f.position)),h.update(f.bounds,f.vertices,t.velocity)}},n.applyForce=function(t,e,i){t.force.x+=i.x,t.force.y+=i.y;var n=e.x-t.position.x,s=e.y-t.position.y;t.torque+=n*i.y-s*i.x},n._totalProperties=function(t){for(var e={mass:0,area:0,inertia:0,centre:{x:0,y:0}},i=1===t.parts.length?0:1;i=0&&y>=0&&v+y<1}},function(t,e,i){var n=i(0),s=i(173),r=i(9),o=i(3),a=new n({initialize:function(t){this.type=t,this.defaultDivisions=5,this.arcLengthDivisions=100,this.cacheArcLengths=[],this.needsUpdate=!0,this.active=!0,this._tmpVec2A=new o,this._tmpVec2B=new o},draw:function(t,e){return void 0===e&&(e=32),t.strokePoints(this.getPoints(e))},getBounds:function(t,e){t||(t=new r),void 0===e&&(e=16);var i=this.getLength();e>i&&(e=i/2);var n=Math.max(1,Math.round(i/e));return s(this.getSpacedPoints(n),t)},getDistancePoints:function(t){var e=this.getLength(),i=Math.max(1,e/t);return this.getSpacedPoints(i)},getEndPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(1,t)},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,i=[],n=this.getPoint(0,this._tmpVec2A),s=0;i.push(0);for(var r=1;r<=t;r++)s+=(e=this.getPoint(r/t,this._tmpVec2B)).distance(n),i.push(s),n.copy(e);return this.cacheArcLengths=i,i},getPointAt:function(t,e){var i=this.getUtoTmapping(t);return this.getPoint(i,e)},getPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return e},getRandomPoint:function(t){return void 0===t&&(t=new o),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=this.defaultDivisions);for(var e=[],i=0;i<=t;i++){var n=this.getUtoTmapping(i/t,null,t);e.push(this.getPoint(n))}return e},getStartPoint:function(t){return void 0===t&&(t=new o),this.getPointAt(0,t)},getTangent:function(t,e){void 0===e&&(e=new o);var i=t-1e-4,n=t+1e-4;return i<0&&(i=0),n>1&&(n=1),this.getPoint(i,this._tmpVec2A),this.getPoint(n,e),e.subtract(this._tmpVec2A).normalize()},getTangentAt:function(t,e){var i=this.getUtoTmapping(t);return this.getTangent(i,e)},getTFromDistance:function(t,e){return t<=0?0:this.getUtoTmapping(0,t,e)},getUtoTmapping:function(t,e,i){var n,s=this.getLengths(i),r=0,o=s.length;n=e?Math.min(e,s[o-1]):t*s[o-1];for(var a,h=0,l=o-1;h<=l;)if((a=s[r=Math.floor(h+(l-h)/2)]-n)<0)h=r+1;else{if(!(a>0)){l=r;break}l=r-1}if(s[r=l]===n)return r/(o-1);var u=s[r];return(r+(n-u)/(s[r+1]-u))/(o-1)},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()}});t.exports=a},function(t,e,i){var n=i(0),s=i(40),r=i(405),o=i(403),a=i(191),h=new n({initialize:function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this._radius=i,this._diameter=2*i},contains:function(t,e){return s(this,t,e)},getPoint:function(t,e){return r(this,t,e)},getPoints:function(t,e,i){return o(this,t,e,i)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,e,i){return this.x=t,this.y=e,this._radius=i,this._diameter=2*i,this},setEmpty:function(){return this._radius=0,this._diameter=0,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},isEmpty:function(){return this._radius<=0},radius:{get:function(){return this._radius},set:function(t){this._radius=t,this._diameter=2*t}},diameter:{get:function(){return this._diameter},set:function(t){this._diameter=t,this._radius=.5*t}},left:{get:function(){return this.x-this._radius},set:function(t){this.x=t+this._radius}},right:{get:function(){return this.x+this._radius},set:function(t){this.x=t-this._radius}},top:{get:function(){return this.y-this._radius},set:function(t){this.y=t+this._radius}},bottom:{get:function(){return this.y+this._radius},set:function(t){this.y=t-this._radius}}});t.exports=h},function(t,e){t.exports=function(t){return t.y-t.height*t.originY+.5*t.height}},function(t,e){t.exports=function(t,e){var i=t.height*t.originY;return t.y=e+i-.5*t.height,t}},function(t,e){t.exports=function(t,e){var i=t.width*t.originX;return t.x=e+i-.5*t.width,t}},function(t,e){t.exports=function(t){return t.x-t.width*t.originX+.5*t.width}},function(t,e,i){var n={};t.exports=n;var s=i(81),r=i(33);n.create=function(t,e){for(var i=[],n=0;n0)return!1}return!0},n.scale=function(t,e,i,r){if(1===e&&1===i)return t;var o,a;r=r||n.centre(t);for(var h=0;h=0?h-1:t.length-1],u=t[h],c=t[(h+1)%t.length],d=e[h0&&(r|=2),3===r)return!1;return 0!==r||null},n.hull=function(t){var e,i,n=[],r=[];for((t=t.slice(0)).sort(function(t,e){var i=t.x-e.x;return 0!==i?i:t.y-e.y}),i=0;i=2&&s.cross3(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(i=t.length-1;i>=0;i-=1){for(e=t[i];n.length>=2&&s.cross3(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}return n.pop(),r.pop(),n.concat(r)}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","map"),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.widthInPixels=s(t,"widthInPixels",this.width*this.tileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.tileHeight),this.format=s(t,"format",null),this.orientation=s(t,"orientation","orthogonal"),this.renderOrder=s(t,"renderOrder","right-down"),this.version=s(t,"version","1"),this.properties=s(t,"properties",{}),this.layers=s(t,"layers",[]),this.images=s(t,"images",[]),this.objects=s(t,"objects",{}),this.collision=s(t,"collision",{}),this.tilesets=s(t,"tilesets",[]),this.imageCollections=s(t,"imageCollections",[]),this.tiles=s(t,"tiles",[])}});t.exports=r},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","layer"),this.x=s(t,"x",0),this.y=s(t,"y",0),this.width=s(t,"width",0),this.height=s(t,"height",0),this.tileWidth=s(t,"tileWidth",0),this.tileHeight=s(t,"tileHeight",0),this.baseTileWidth=s(t,"baseTileWidth",this.tileWidth),this.baseTileHeight=s(t,"baseTileHeight",this.tileHeight),this.widthInPixels=s(t,"widthInPixels",this.width*this.baseTileWidth),this.heightInPixels=s(t,"heightInPixels",this.height*this.baseTileHeight),this.alpha=s(t,"alpha",1),this.visible=s(t,"visible",!0),this.properties=s(t,"properties",{}),this.indexes=s(t,"indexes",[]),this.collideIndexes=s(t,"collideIndexes",[]),this.callbacks=s(t,"callbacks",[]),this.bodies=s(t,"bodies",[]),this.data=s(t,"data",[]),this.tilemapLayer=s(t,"tilemapLayer",null)}});t.exports=r},function(t,e){t.exports=function(t,e,i){return t>=0&&t=0&&et.max.x&&(t.max.x=s.x),s.xt.max.y&&(t.max.y=s.y),s.y0?t.max.x+=i.x:t.min.x+=i.x,i.y>0?t.max.y+=i.y:t.min.y+=i.y)},i.contains=function(t,e){return e.x>=t.min.x&&e.x<=t.max.x&&e.y>=t.min.y&&e.y<=t.max.y},i.overlaps=function(t,e){return t.min.x<=e.max.x&&t.max.x>=e.min.x&&t.max.y>=e.min.y&&t.min.y<=e.max.y},i.translate=function(t,e){t.min.x+=e.x,t.max.x+=e.x,t.min.y+=e.y,t.max.y+=e.y},i.shift=function(t,e){var i=t.max.x-t.min.x,n=t.max.y-t.min.y;t.min.x=e.x,t.max.x=e.x+i,t.min.y=e.y,t.max.y=e.y+n}},function(t,e){var i={};t.exports=i,i.create=function(t,e){return{x:t||0,y:e||0}},i.clone=function(t){return{x:t.x,y:t.y}},i.magnitude=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},i.magnitudeSquared=function(t){return t.x*t.x+t.y*t.y},i.rotate=function(t,e,i){var n=Math.cos(e),s=Math.sin(e);i||(i={});var r=t.x*n-t.y*s;return i.y=t.x*s+t.y*n,i.x=r,i},i.rotateAbout=function(t,e,i,n){var s=Math.cos(e),r=Math.sin(e);n||(n={});var o=i.x+((t.x-i.x)*s-(t.y-i.y)*r);return n.y=i.y+((t.x-i.x)*r+(t.y-i.y)*s),n.x=o,n},i.normalise=function(t){var e=i.magnitude(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},i.dot=function(t,e){return t.x*e.x+t.y*e.y},i.cross=function(t,e){return t.x*e.y-t.y*e.x},i.cross3=function(t,e,i){return(e.x-t.x)*(i.y-t.y)-(e.y-t.y)*(i.x-t.x)},i.add=function(t,e,i){return i||(i={}),i.x=t.x+e.x,i.y=t.y+e.y,i},i.sub=function(t,e,i){return i||(i={}),i.x=t.x-e.x,i.y=t.y-e.y,i},i.mult=function(t,e){return{x:t.x*e,y:t.y*e}},i.div=function(t,e){return{x:t.x/e,y:t.y/e}},i.perp=function(t,e){return{x:(e=!0===e?-1:1)*-t.y,y:e*t.x}},i.neg=function(t){return{x:-t.x,y:-t.y}},i.angle=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},i._temp=[i.create(),i.create(),i.create(),i.create(),i.create(),i.create()]},function(t,e,i){var n=i(10);t.exports=function(t,e,i,s,r,o){for(var a=n.getTintAppendFloatAlphaAndSwap(i.fillColor,i.fillAlpha*s),h=i.pathData,l=i.pathIndexes,u=0;u=0;u--)if((l=d[u]).active===i){if(++c===e)break}else l=null;return l?("number"==typeof s&&(l.x=s),"number"==typeof r&&(l.y=r),l):n?this.create(s,r,o,a,h):null},get:function(t,e,i,n,s){return this.getFirst(!1,!0,t,e,i,n,s)},getFirstAlive:function(t,e,i,n,s,r){return this.getFirst(!0,t,e,i,n,s,r)},getFirstDead:function(t,e,i,n,s,r){return this.getFirst(!1,t,e,i,n,s,r)},playAnimation:function(t,e){return n.PlayAnimation(this.children.entries,t,e),this},isFull:function(){return-1!==this.maxSize&&this.children.size>=this.maxSize},countActive:function(t){void 0===t&&(t=!0);for(var e=0,i=0;i=t.length)){for(var i=t.length-1,n=t[e],s=e;s-1&&this.entries.splice(e,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var e=new n;return t.entries.forEach(function(t){e.set(t)}),this.entries.forEach(function(t){e.set(t)}),e},intersect:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)&&e.set(i)}),e},difference:function(t){var e=new n;return this.entries.forEach(function(i){t.contains(i)||e.set(i)}),e},size:{get:function(){return this.entries.length},set:function(t){return t=this.firstgid&&t=0&&g<=1&&v>=0&&v<=1&&(i.x=s+g*(o-s),i.y=r+g*(a-r),!0)}},function(t,e,i){var n=i(0),s=i(14),r=i(19),o=i(731),a=new n({Extends:r,Mixins:[s.Alpha,s.BlendMode,s.Depth,s.Flip,s.GetBounds,s.Mask,s.Origin,s.Pipeline,s.ScaleMode,s.Size,s.Texture,s.Transform,s.Visible,s.ScrollFactor,o],initialize:function(t,e,i,n,s,o,a,h,l){if(r.call(this,t,"Mesh"),n.length!==s.length)throw new Error("Mesh Vertex count must match UV count");var u,c=n.length/2|0;if(o.length>0&&o.length0&&a.lengthl&&(r=l),o>l&&(o=l),a=s,h=r;;)if(a-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){for(var i=[null],n=2;n0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}}});t.exports=a},function(t,e,i){var n=i(0),s=i(23),r=i(20),o=new n({initialize:function(t,e,i,n,s,r,o){this.texture=t,this.name=e,this.source=t.source[i],this.sourceIndex=i,this.glTexture=this.source.glTexture,this.cutX,this.cutY,this.cutWidth,this.cutHeight,this.x=0,this.y=0,this.width,this.height,this.halfWidth,this.halfHeight,this.centerX,this.centerY,this.pivotX=0,this.pivotY=0,this.customPivot=!1,this.rotated=!1,this.autoRound=-1,this.customData={},this.u0=0,this.v0=0,this.u1=0,this.v1=0,this.data={cut:{x:0,y:0,w:0,h:0,r:0,b:0},trim:!1,sourceSize:{w:0,h:0},spriteSourceSize:{x:0,y:0,w:0,h:0,r:0,b:0},radius:0,drawImage:{x:0,y:0,width:0,height:0}},this.setSize(r,o,n,s)},setSize:function(t,e,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this.cutX=i,this.cutY=n,this.cutWidth=t,this.cutHeight=e,this.width=t,this.height=e,this.halfWidth=Math.floor(.5*t),this.halfHeight=Math.floor(.5*e),this.centerX=Math.floor(t/2),this.centerY=Math.floor(e/2);var s=this.data,r=s.cut;r.x=i,r.y=n,r.w=t,r.h=e,r.r=i+t,r.b=n+e,s.sourceSize.w=t,s.sourceSize.h=e,s.spriteSourceSize.w=t,s.spriteSourceSize.h=e,s.radius=.5*Math.sqrt(t*t+e*e);var o=s.drawImage;return o.x=i,o.y=n,o.width=t,o.height=e,this.updateUVs()},setTrim:function(t,e,i,n,s,r){var o=this.data,a=o.spriteSourceSize;return o.trim=!0,o.sourceSize.w=t,o.sourceSize.h=e,a.x=i,a.y=n,a.w=s,a.h=r,a.r=i+s,a.b=n+r,this.x=i,this.y=n,this.width=s,this.height=r,this.halfWidth=.5*s,this.halfHeight=.5*r,this.centerX=Math.floor(s/2),this.centerY=Math.floor(r/2),this.updateUVs()},setCropUVs:function(t,e,i,n,r,o,a){var h=this.cutX,l=this.cutY,u=this.cutWidth,c=this.cutHeight,d=this.realWidth,f=this.realHeight,p=h+(e=s(e,0,d)),g=l+(i=s(i,0,f)),v=n=s(n,0,d-e),y=r=s(r,0,f-i),m=this.data;if(m.trim){var x=m.spriteSourceSize,w=e+(n=s(n,0,u-e)),b=i+(r=s(r,0,c-i));if(!(x.rw||x.y>b)){var T=Math.max(x.x,e),S=Math.max(x.y,i),_=Math.min(x.r,w)-T,A=Math.min(x.b,b)-S;v=_,y=A,p=o?h+(u-(T-x.x)-_):h+(T-x.x),g=a?l+(c-(S-x.y)-A):l+(S-x.y),e=T,i=S,n=_,r=A}else p=0,g=0,v=0,y=0}else o&&(p=h+(u-e-n)),a&&(g=l+(c-i-r));var C=this.source.width,M=this.source.height;return t.u0=Math.max(0,p/C),t.v0=Math.max(0,g/M),t.u1=Math.min(1,(p+v)/C),t.v1=Math.min(1,(g+y)/M),t.x=e,t.y=i,t.cx=p,t.cy=g,t.cw=v,t.ch=y,t.width=n,t.height=r,t.flipX=o,t.flipY=a,t},updateCropUVs:function(t,e,i){return this.setCropUVs(t,t.x,t.y,t.width,t.height,e,i)},updateUVs:function(){var t=this.cutX,e=this.cutY,i=this.cutWidth,n=this.cutHeight,s=this.data.drawImage;s.width=i,s.height=n;var r=this.source.width,o=this.source.height;return this.u0=t/r,this.v0=e/o,this.u1=(t+i)/r,this.v1=(e+n)/o,this},updateUVsInverted:function(){var t=this.source.width,e=this.source.height;return this.u0=(this.cutX+this.cutHeight)/t,this.v0=this.cutY/e,this.u1=this.cutX/t,this.v1=(this.cutY+this.cutWidth)/e,this},clone:function(){var t=new o(this.texture,this.name,this.sourceIndex);return t.cutX=this.cutX,t.cutY=this.cutY,t.cutWidth=this.cutWidth,t.cutHeight=this.cutHeight,t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t.halfWidth=this.halfWidth,t.halfHeight=this.halfHeight,t.centerX=this.centerX,t.centerY=this.centerY,t.rotated=this.rotated,t.data=r(!0,t.data,this.data),t.updateUVs(),t},destroy:function(){this.texture=null,this.source=null},realWidth:{get:function(){return this.data.sourceSize.w}},realHeight:{get:function(){return this.data.sourceSize.h}},radius:{get:function(){return this.data.radius}},trimmed:{get:function(){return this.data.trim}},canvasData:{get:function(){return this.data.drawImage}}});t.exports=o},function(t,e,i){var n=i(0),s=i(11),r=i(20),o=i(1),a=new n({Extends:s,initialize:function(t,e,i){s.call(this),this.manager=t,this.key=e,this.isPlaying=!1,this.isPaused=!1,this.totalRate=1,this.duration=this.duration||0,this.totalDuration=this.totalDuration||0,this.config={mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0},this.currentConfig=this.config,this.config=r(this.config,i),this.markers={},this.currentMarker=null,this.pendingRemove=!1},addMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(console.error("addMarker "+t.name+" already exists in Sound"),!1):(t=r(!0,{name:"",start:0,duration:this.totalDuration-(t.start||0),config:{mute:!1,volume:1,rate:1,detune:0,seek:0,loop:!1,delay:0}},t),this.markers[t.name]=t,!0))},updateMarker:function(t){return!(!t||!t.name||"string"!=typeof t.name)&&(this.markers[t.name]?(this.markers[t.name]=r(!0,this.markers[t.name],t),!0):(console.warn("Audio Marker: "+t.name+" missing in Sound: "+this.key),!1))},removeMarker:function(t){var e=this.markers[t];return e?(this.markers[t]=null,e):null},play:function(t,e){if(void 0===t&&(t=""),"object"==typeof t&&(e=t,t=""),"string"!=typeof t)return!1;if(t){if(!this.markers[t])return console.warn("Marker: "+t+" missing in Sound: "+this.key),!1;this.currentMarker=this.markers[t],this.currentConfig=this.currentMarker.config,this.duration=this.currentMarker.duration}else this.currentMarker=null,this.currentConfig=this.config,this.duration=this.totalDuration;return this.resetConfig(),this.currentConfig=r(this.currentConfig,e),this.isPlaying=!0,this.isPaused=!1,!0},pause:function(){return!(this.isPaused||!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!0,!0)},resume:function(){return!(!this.isPaused||this.isPlaying)&&(this.isPlaying=!0,this.isPaused=!1,!0)},stop:function(){return!(!this.isPaused&&!this.isPlaying)&&(this.isPlaying=!1,this.isPaused=!1,this.resetConfig(),!0)},applyConfig:function(){this.mute=this.currentConfig.mute,this.volume=this.currentConfig.volume,this.rate=this.currentConfig.rate,this.detune=this.currentConfig.detune,this.loop=this.currentConfig.loop},resetConfig:function(){this.currentConfig.seek=0,this.currentConfig.delay=0},update:o,calculateRate:function(){var t=this.currentConfig.detune+this.manager.detune,e=Math.pow(1.0005777895065548,t);this.totalRate=this.currentConfig.rate*this.manager.rate*e},destroy:function(){this.pendingRemove||(this.emit("destroy",this),this.pendingRemove=!0,this.manager=null,this.key="",this.removeAllListeners(),this.isPlaying=!1,this.isPaused=!1,this.config=null,this.currentConfig=null,this.markers=null,this.currentMarker=null)}});t.exports=a},function(t,e,i){var n=i(0),s=i(63),r=i(11),o=i(1),a=new n({Extends:r,initialize:function(t){r.call(this),this.game=t,this.jsonCache=t.cache.json,this.sounds=[],this.mute=!1,this.volume=1,this.pauseOnBlur=!0,this._rate=1,this._detune=0,this.locked=this.locked||!1,this.unlocked=!1,t.events.on("blur",function(){this.pauseOnBlur&&this.onBlur()},this),t.events.on("focus",function(){this.pauseOnBlur&&this.onFocus()},this),t.events.on("prestep",this.update,this),t.events.once("destroy",this.destroy,this)},add:o,addAudioSprite:function(t,e){void 0===e&&(e={});var i=this.add(t,e);for(var n in i.spritemap=this.jsonCache.get(t).spritemap,i.spritemap)if(i.spritemap.hasOwnProperty(n)){var r=s(e),o=i.spritemap[n];r.loop=!!o.hasOwnProperty("loop")&&o.loop,i.addMarker({name:n,start:o.start,duration:o.end-o.start,config:r})}return i},play:function(t,e){var i=this.add(t);return i.once("ended",i.destroy,i),e?e.name?(i.addMarker(e),i.play(e.name)):i.play(e):i.play()},playAudioSprite:function(t,e,i){var n=this.addAudioSprite(t);return n.once("ended",n.destroy,n),n.play(e,i)},remove:function(t){var e=this.sounds.indexOf(t);return-1!==e&&(t.destroy(),this.sounds.splice(e,1),!0)},removeByKey:function(t){for(var e=0,i=this.sounds.length-1;i>=0;i--){var n=this.sounds[i];n.key===t&&(n.destroy(),this.sounds.splice(i,1),e++)}return e},pauseAll:function(){this.forEachActiveSound(function(t){t.pause()}),this.emit("pauseall",this)},resumeAll:function(){this.forEachActiveSound(function(t){t.resume()}),this.emit("resumeall",this)},stopAll:function(){this.forEachActiveSound(function(t){t.stop()}),this.emit("stopall",this)},unlock:o,onBlur:o,onFocus:o,update:function(t,e){this.unlocked&&(this.unlocked=!1,this.locked=!1,this.emit("unlocked",this));for(var i=this.sounds.length-1;i>=0;i--)this.sounds[i].pendingRemove&&this.sounds.splice(i,1);this.sounds.forEach(function(i){i.update(t,e)})},destroy:function(){this.removeAllListeners(),this.forEachActiveSound(function(t){t.destroy()}),this.sounds.length=0,this.sounds=null,this.game=null},forEachActiveSound:function(t,e){var i=this;this.sounds.forEach(function(n,s){n.pendingRemove||t.call(e||i,n,s,i.sounds)})},setRate:function(t){return this.rate=t,this},rate:{get:function(){return this._rate},set:function(t){this._rate=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("rate",this,t)}},setDetune:function(t){return this.detune=t,this},detune:{get:function(){return this._detune},set:function(t){this._detune=t,this.forEachActiveSound(function(t){t.calculateRate()}),this.emit("detune",this,t)}}});t.exports=a},function(t,e){t.exports={PENDING:0,INIT:1,START:2,LOADING:3,CREATING:4,RUNNING:5,PAUSED:6,SLEEPING:7,SHUTDOWN:8,DESTROYED:9}},function(t,e){t.exports=function(t,e){return t>0&&0==(t&t-1)&&e>0&&0==(e&e-1)}},function(t,e,i){var n,s=i(92),r={chrome:!1,chromeVersion:0,edge:!1,firefox:!1,firefoxVersion:0,ie:!1,ieVersion:0,mobileSafari:!1,opera:!1,safari:!1,safariVersion:0,silk:!1,trident:!1,tridentVersion:0};t.exports=(n=navigator.userAgent,/Edge\/\d+/.test(n)?r.edge=!0:/Chrome\/(\d+)/.test(n)&&!s.windowsPhone?(r.chrome=!0,r.chromeVersion=parseInt(RegExp.$1,10)):/Firefox\D+(\d+)/.test(n)?(r.firefox=!0,r.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(n)&&s.iOS?r.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(n)?(r.ie=!0,r.ieVersion=parseInt(RegExp.$1,10)):/Opera/.test(n)?r.opera=!0:/Safari/.test(n)&&!s.windowsPhone?r.safari=!0:/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(n)&&(r.ie=!0,r.trident=!0,r.tridentVersion=parseInt(RegExp.$1,10),r.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(n)&&(r.silk=!0),r)},function(t,e){t.exports=function(t,e,i){return(e-t)*i+t}},function(t,e){var i,n="";t.exports={disable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!1),t},enable:function(t){return""===n&&(n=i(t)),n&&(t[n]=!0),t},getPrefix:i=function(t){for(var e=["i","webkitI","msI","mozI","oI"],i=0;i-y&&T>-m&&b-y&&_>-m&&Ss&&(t=s),t},clampY:function(t){var e=this._bounds,i=this.displayHeight,n=e.y+(i-this.height)/2,s=Math.max(n,n+e.height-i);return ts&&(t=s),t},removeBounds:function(){return this.useBounds=!1,this.dirty=!0,this._bounds.setEmpty(),this},setAngle:function(t){return void 0===t&&(t=0),this.rotation=r(t),this},setBackgroundColor:function(t){return void 0===t&&(t="rgba(0,0,0,0)"),this.backgroundColor=l(t),this.transparent=0===this.backgroundColor.alpha,this},setBounds:function(t,e,i,n,s){return this._bounds.setTo(t,e,i,n),this.dirty=!0,this.useBounds=!0,s?this.centerToBounds():(this.scrollX=this.clampX(this.scrollX),this.scrollY=this.clampY(this.scrollY)),this},setName:function(t){return void 0===t&&(t=""),this.name=t,this},setPosition:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setRoundPixels:function(t){return this.roundPixels=t,this},setScene:function(t){this.scene&&this._customViewport&&this.sceneManager.customViewports--,this.scene=t,this.config=t.sys.game.config,this.sceneManager=t.sys.game.scene;var e=this.config.resolution;return this.resolution=e,this._cx=this._x*e,this._cy=this._y*e,this._cw=this._width*e,this._ch=this._height*e,this.updateSystem(),this},setScroll:function(t,e){return void 0===e&&(e=t),this.scrollX=t,this.scrollY=e,this},setSize:function(t,e){return void 0===e&&(e=t),this.width=t,this.height=e,this},setViewport:function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},setZoom:function(t){return void 0===t&&(t=1),0===t&&(t=.001),this.zoom=t,this},toJSON:function(){var t={name:this.name,x:this.x,y:this.y,width:this.width,height:this.height,zoom:this.zoom,rotation:this.rotation,roundPixels:this.roundPixels,scrollX:this.scrollX,scrollY:this.scrollY,backgroundColor:this.backgroundColor.rgba};return this.useBounds&&(t.bounds={x:this._bounds.x,y:this._bounds.y,width:this._bounds.width,height:this._bounds.height}),t},update:function(){},updateSystem:function(){if(this.config){var t=0!==this._x||0!==this._y||this.config.width!==this._width||this.config.height!==this._height,e=this.sceneManager;t&&!this._customViewport?e.customViewports++:!t&&this._customViewport&&e.customViewports--,this.dirty=!0,this._customViewport=t}},destroy:function(){this.emit("cameradestroy",this),this.removeAllListeners(),this.matrix.destroy(),this.culledObjects=[],this._customViewport&&this.sceneManager.customViewports--,this._bounds=null,this.scene=null,this.config=null,this.sceneManager=null},x:{get:function(){return this._x},set:function(t){this._x=t,this._cx=t*this.resolution,this.updateSystem()}},y:{get:function(){return this._y},set:function(t){this._y=t,this._cy=t*this.resolution,this.updateSystem()}},width:{get:function(){return this._width},set:function(t){this._width=t,this._cw=t*this.resolution,this.updateSystem()}},height:{get:function(){return this._height},set:function(t){this._height=t,this._ch=t*this.resolution,this.updateSystem()}},scrollX:{get:function(){return this._scrollX},set:function(t){this._scrollX=t,this.dirty=!0}},scrollY:{get:function(){return this._scrollY},set:function(t){this._scrollY=t,this.dirty=!0}},zoom:{get:function(){return this._zoom},set:function(t){this._zoom=t,this.dirty=!0}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=t,this.dirty=!0}},centerX:{get:function(){return this.x+.5*this.width}},centerY:{get:function(){return this.y+.5*this.height}},displayWidth:{get:function(){return this.width/this.zoom}},displayHeight:{get:function(){return this.height/this.zoom}}});t.exports=c},function(t,e){t.exports=function(t){for(var e=t.length-1;e>0;e--){var i=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[i],t[i]=n}return t}},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.parent=t,this.events=e,e||(this.events=t.events?t.events:t),this.list={},this.values={},this._frozen=!1,!t.hasOwnProperty("sys")&&this.events&&this.events.once("destroy",this.destroy,this)},get:function(t){var e=this.list;if(Array.isArray(t)){for(var i=[],n=0;n0&&s.area(_)1?(f=o.create(r.extend({parts:p.slice(0)},n)),o.setPosition(f,{x:t,y:e}),f):p[0]}},function(t,e){t.exports=function(t,e,i,n,s,r,o,a,h,l,u,c,d){return{target:t,key:e,getEndValue:i,getStartValue:n,ease:s,duration:0,totalDuration:0,delay:0,yoyo:a,hold:0,repeat:0,repeatDelay:0,flipX:c,flipY:d,progress:0,elapsed:0,repeatCounter:0,start:0,current:0,end:0,t1:0,t2:0,gen:{delay:r,duration:o,hold:h,repeat:l,repeatDelay:u},state:0}}},function(t,e,i){var n=i(0),s=i(13),r=i(5),o=i(83),a=new n({initialize:function(t,e,i){this.parent=t,this.parentIsTimeline=t.hasOwnProperty("isTimeline"),this.data=e,this.totalData=e.length,this.targets=i,this.totalTargets=i.length,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.offset=0,this.calculatedOffset=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onRepeat:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},getValue:function(){return this.data[0].current},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},isPaused:function(){return this.state===o.PAUSED},hasTarget:function(t){return-1!==this.targets.indexOf(t)},updateTo:function(t,e,i){for(var n=0;n0&&(n.totalDuration+=n.t2*n.repeat),n.totalDuration>t&&(t=n.totalDuration)}this.duration=t,this.loopCounter=-1===this.loop?999999999999:this.loop,this.loopCounter>0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){for(var t=this.data,e=this.totalTargets,i=0;i0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&(t.params[1]=this.targets,t.func.apply(t.scope,t.params)),this.resetTweenData(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},pause:function(){if(this.state!==o.PAUSED)return this.paused=!0,this._pausedState=this.state,this.state=o.PAUSED,this},play:function(t){if(this.state!==o.ACTIVE){this.state!==o.PENDING_REMOVE&&this.state!==o.REMOVED||(this.init(),this.parent.makeActive(this),t=!0);var e=this.callbacks.onStart;this.parentIsTimeline?(this.resetTweenData(t),0===this.calculatedOffset?(e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.ACTIVE):(this.countdown=this.calculatedOffset,this.state=o.OFFSET_DELAY)):this.paused?(this.paused=!1,this.parent.makeActive(this)):(this.resetTweenData(t),this.state=o.ACTIVE,e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.parent.makeActive(this))}},resetTweenData:function(t){for(var e=this.data,i=0;i0?(n.elapsed=n.delay,n.state=o.DELAY):n.state=o.PENDING_RENDER}},resume:function(){return this.state===o.PAUSED?(this.paused=!1,this.state=this._pausedState):this.play(),this},seek:function(t){for(var e=this.data,i=0;i=s.totalDuration?(r=1,o=s.duration):n>s.delay&&n<=s.t1?(r=(n=Math.max(0,n-s.delay))/s.t1,o=s.duration*r):n>s.t1&&ns.repeatDelay&&(r=n/s.t1,o=s.duration*r)),s.progress=r,s.elapsed=o;var a=s.ease(s.progress);s.current=s.start+(s.end-s.start)*a,s.target[s.key]=s.current}},setCallback:function(t,e,i,n){return this.callbacks[t]={func:e,scope:n,params:i},this},complete:function(t){if(void 0===t&&(t=0),t)this.countdown=t,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&(e.params[1]=this.targets,e.func.apply(e.scope,e.params)),this.state=o.PENDING_REMOVE}},stop:function(t){this.state===o.ACTIVE&&void 0!==t&&this.seek(t),this.state!==o.REMOVED&&(this.state!==o.PAUSED&&this.state!==o.PENDING_ADD||(this.parent._destroy.push(this),this.parent._toProcess++),this.state=o.PENDING_REMOVE)},update:function(t,e){if(this.state===o.PAUSED)return!1;switch(this.useFrames&&(e=1*this.parent.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var i=!1,n=0;n0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var s=t.callbacks.onRepeat;return s&&(s.params[1]=e.target,s.func.apply(s.scope,s.params)),e.start=e.getStartValue(e.target,e.key,e.start),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},setStateFromStart:function(t,e,i){if(e.repeatCounter>0){e.repeatCounter--,e.elapsed=i,e.progress=i/e.duration,e.flipX&&e.target.toggleFlipX(),e.flipY&&e.target.toggleFlipY();var n=t.callbacks.onRepeat;return n&&(n.params[1]=e.target,n.func.apply(n.scope,n.params)),e.end=e.getEndValue(e.target,e.key,e.start),e.repeatDelay>0?(e.elapsed=e.repeatDelay-i,e.current=e.start,e.target[e.key]=e.current,o.REPEAT_DELAY):o.PLAYING_FORWARD}return o.COMPLETE},updateTweenData:function(t,e,i){switch(e.state){case o.PLAYING_FORWARD:case o.PLAYING_BACKWARD:if(!e.target){e.state=o.COMPLETE;break}var n=e.elapsed,s=e.duration,r=0;(n+=i)>s&&(r=n-s,n=s);var a,h=e.state===o.PLAYING_FORWARD,l=n/s;a=h?e.ease(l):e.ease(1-l),e.current=e.start+(e.end-e.start)*a,e.target[e.key]=e.current,e.elapsed=n,e.progress=l;var u=t.callbacks.onUpdate;u&&(u.params[1]=e.target,u.func.apply(u.scope,u.params)),1===l&&(h?e.hold>0?(e.elapsed=e.hold-r,e.state=o.HOLD_DELAY):e.state=this.setStateFromEnd(t,e,r):e.state=this.setStateFromStart(t,e,r));break;case o.DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PENDING_RENDER);break;case o.REPEAT_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.elapsed=Math.abs(e.elapsed),e.state=o.PLAYING_FORWARD);break;case o.HOLD_DELAY:e.elapsed-=i,e.elapsed<=0&&(e.state=this.setStateFromEnd(t,e,Math.abs(e.elapsed)));break;case o.PENDING_RENDER:e.target?(e.start=e.getStartValue(e.target,e.key,e.target[e.key]),e.end=e.getEndValue(e.target,e.key,e.start),e.current=e.start,e.target[e.key]=e.start,e.state=o.PLAYING_FORWARD):e.state=o.COMPLETE}return e.state!==o.COMPLETE}});a.TYPES=["onComplete","onLoop","onRepeat","onStart","onUpdate","onYoyo"],r.register("tween",function(t){return this.scene.sys.tweens.add(t)}),s.register("tween",function(t){return this.scene.sys.tweens.create(t)}),t.exports=a},function(t,e){t.exports={targets:null,delay:0,duration:1e3,ease:"Power0",easeParams:null,hold:0,repeat:0,repeatDelay:0,yoyo:!1,flipX:!1,flipY:!1}},function(t,e){function i(t){return!!t.getStart&&"function"==typeof t.getStart}function n(t){return!!t.getEnd&&"function"==typeof t.getEnd}var s=function(t,e){var r,o,a=function(t,e,i){return i},h=function(t,e,i){return i},l=typeof e;if("number"===l)a=function(){return e};else if("string"===l){var u=e[0],c=parseFloat(e.substr(2));switch(u){case"+":a=function(t,e,i){return i+c};break;case"-":a=function(t,e,i){return i-c};break;case"*":a=function(t,e,i){return i*c};break;case"/":a=function(t,e,i){return i/c};break;default:a=function(){return parseFloat(e)}}}else"function"===l?a=e:"object"===l&&(i(o=e)||n(o))?(n(e)&&(a=e.getEnd),i(e)&&(h=e.getStart)):e.hasOwnProperty("value")&&(r=s(t,e.value));return r||(r={getEnd:a,getStart:h}),r};t.exports=s},function(t,e,i){var n=i(4);t.exports=function(t){var e=n(t,"targets",null);return null===e?e:("function"==typeof e&&(e=e.call()),Array.isArray(e)||(e=[e]),e)}},function(t,e,i){var n=i(29),s=i(77),r=i(217),o=i(209);t.exports=function(t,e,i,a,h,l,u,c){void 0===i&&(i=32),void 0===a&&(a=32),void 0===h&&(h=10),void 0===l&&(l=10),void 0===c&&(c=!1);var d=null;if(Array.isArray(u))d=r(void 0!==e?e:"map",n.ARRAY_2D,u,i,a,c);else if(void 0!==e){var f=t.cache.tilemap.get(e);f?d=r(e,f.format,f.data,i,a,c):console.warn("No map data found for key "+e)}return null===d&&(d=new s({tileWidth:i,tileHeight:a,width:h,height:l})),new o(t,d)}},function(t,e,i){var n=i(29),s=i(78),r=i(77),o=i(55);t.exports=function(t,e,i,a,h){for(var l=new s({tileWidth:i,tileHeight:a}),u=new r({name:t,tileWidth:i,tileHeight:a,format:n.ARRAY_2D,layers:[l]}),c=[],d=e.length,f=0,p=0;p0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z;return this.x=i*o-n*r,this.y=n*s-e*o,this.z=e*r-i*s,this},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this},transformMat3:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=e*s[0]+i*s[3]+n*s[6],this.y=e*s[1]+i*s[4]+n*s[7],this.z=e*s[2]+i*s[5]+n*s[8],this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=t.val;return this.x=s[0]*e+s[4]*i+s[8]*n+s[12],this.y=s[1]*e+s[5]*i+s[9]*n+s[13],this.z=s[2]*e+s[6]*i+s[10]*n+s[14],this},transformCoordinates:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=e*s[0]+i*s[4]+n*s[8]+s[12],o=e*s[1]+i*s[5]+n*s[9]+s[13],a=e*s[2]+i*s[6]+n*s[10]+s[14],h=e*s[3]+i*s[7]+n*s[11]+s[15];return this.x=r/h,this.y=o/h,this.z=a/h,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},project:function(t){var e=this.x,i=this.y,n=this.z,s=t.val,r=s[0],o=s[1],a=s[2],h=s[3],l=s[4],u=s[5],c=s[6],d=s[7],f=s[8],p=s[9],g=s[10],v=s[11],y=s[12],m=s[13],x=s[14],w=1/(e*h+i*d+n*v+s[15]);return this.x=(e*r+i*l+n*f+y)*w,this.y=(e*o+i*u+n*p+m)*w,this.z=(e*a+i*c+n*g+x)*w,this},unproject:function(t,e){var i=t.x,n=t.y,s=t.z,r=t.w,o=this.x-i,a=r-this.y-1-n,h=this.z;return this.x=2*o/s-1,this.y=2*a/r-1,this.z=2*h-1,this.project(e)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,e,i){var n=i(0),s=i(18),r=i(21),o=i(7),a=i(2),h=i(8),l=i(343),u=new n({Extends:r,initialize:function(t,e,i,n){var s="xml";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),n=a(o,"xhrSettings"),s=a(o,"extension",s)}var l={type:"xml",cache:t.cacheManager.xml,extension:s,responseType:"text",key:e,url:i,xhrSettings:n};r.call(this,t,l)},onProcess:function(){this.state=s.FILE_PROCESSING,this.data=l(this.xhrLoader.responseText),this.data?this.onProcessComplete():(console.warn("Invalid XMLFile: "+this.key),this.onProcessError())}});o.register("xml",function(t,e,i){if(Array.isArray(t))for(var n=0;n=0&&r>=0&&s+r<1&&(n.push({x:e[b].x,y:e[b].y}),i)));b++);return n}},function(t,e){t.exports=function(t,e){return!(t.width<=0||t.height<=0||e.width<=0||e.height<=0||t.righte.right||t.y>e.bottom)}},function(t,e,i){var n=i(0),s=i(108),r=new n({Extends:s,initialize:function(t,e,i,n,r){s.call(this,t,e,i,[0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,1,1,1,0,0,1,1,1,0],[16777215,16777215,16777215,16777215,16777215,16777215],[1,1,1,1,1,1],n,r),this.resetPosition()},setFrame:function(t){return this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,t=this.frame,this.uv[0]=t.u0,this.uv[1]=t.v0,this.uv[2]=t.u0,this.uv[3]=t.v1,this.uv[4]=t.u1,this.uv[5]=t.v1,this.uv[6]=t.u0,this.uv[7]=t.v0,this.uv[8]=t.u1,this.uv[9]=t.v1,this.uv[10]=t.u1,this.uv[11]=t.v0,this},topLeftX:{get:function(){return this.x+this.vertices[0]},set:function(t){this.vertices[0]=t-this.x,this.vertices[6]=t-this.x}},topLeftY:{get:function(){return this.y+this.vertices[1]},set:function(t){this.vertices[1]=t-this.y,this.vertices[7]=t-this.y}},topRightX:{get:function(){return this.x+this.vertices[10]},set:function(t){this.vertices[10]=t-this.x}},topRightY:{get:function(){return this.y+this.vertices[11]},set:function(t){this.vertices[11]=t-this.y}},bottomLeftX:{get:function(){return this.x+this.vertices[2]},set:function(t){this.vertices[2]=t-this.x}},bottomLeftY:{get:function(){return this.y+this.vertices[3]},set:function(t){this.vertices[3]=t-this.y}},bottomRightX:{get:function(){return this.x+this.vertices[4]},set:function(t){this.vertices[4]=t-this.x,this.vertices[8]=t-this.x}},bottomRightY:{get:function(){return this.y+this.vertices[5]},set:function(t){this.vertices[5]=t-this.y,this.vertices[9]=t-this.y}},topLeftAlpha:{get:function(){return this.alphas[0]},set:function(t){this.alphas[0]=t,this.alphas[3]=t}},topRightAlpha:{get:function(){return this.alphas[5]},set:function(t){this.alphas[5]=t}},bottomLeftAlpha:{get:function(){return this.alphas[1]},set:function(t){this.alphas[1]=t}},bottomRightAlpha:{get:function(){return this.alphas[2]},set:function(t){this.alphas[2]=t,this.alphas[4]=t}},topLeftColor:{get:function(){return this.colors[0]},set:function(t){this.colors[0]=t,this.colors[3]=t}},topRightColor:{get:function(){return this.colors[5]},set:function(t){this.colors[5]=t}},bottomLeftColor:{get:function(){return this.colors[1]},set:function(t){this.colors[1]=t}},bottomRightColor:{get:function(){return this.colors[2]},set:function(t){this.colors[2]=t,this.colors[4]=t}},setTopLeft:function(t,e){return this.topLeftX=t,this.topLeftY=e,this},setTopRight:function(t,e){return this.topRightX=t,this.topRightY=e,this},setBottomLeft:function(t,e){return this.bottomLeftX=t,this.bottomLeftY=e,this},setBottomRight:function(t,e){return this.bottomRightX=t,this.bottomRightY=e,this},resetPosition:function(){var t=this.x,e=this.y,i=Math.floor(this.width/2),n=Math.floor(this.height/2);return this.setTopLeft(t-i,e-n),this.setTopRight(t+i,e-n),this.setBottomLeft(t-i,e+n),this.setBottomRight(t+i,e+n),this},resetAlpha:function(){var t=this.alphas;return t[0]=1,t[1]=1,t[2]=1,t[3]=1,t[4]=1,t[5]=1,this},resetColors:function(){var t=this.colors;return t[0]=16777215,t[1]=16777215,t[2]=16777215,t[3]=16777215,t[4]=16777215,t[5]=16777215,this},reset:function(){return this.resetPosition(),this.resetAlpha(),this.resetColors()}});t.exports=r},function(t,e){t.exports=function(t,e,i){for(var n=!1,s=-1,r=t.points.length-1;++sl){if(0===c){for(var g=f;g.length&&(g=g.slice(0,-1),!((p=e.measureText(g).width)<=l)););if(!g.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var v=d.substr(g.length);u[c]=v,h+=g}var y=u[c].length?c:c+1,m=u.slice(y).join(" ").replace(/[ \n]*$/gi,"");s[o+1]=m+" "+(s[o+1]||""),r=s.length;break}h+=f,l-=p}n+=h.replace(/[ \n]*$/gi,"")+"\n"}}return n=n.replace(/[\s|\n]*$/gi,"")},basicWordWrap:function(t,e,i){for(var n="",s=t.split(this.splitRegExp),r=0;ro?(h>0&&(n+="\n"),n+=a[h]+" ",o=i-l):(o-=u,n+=a[h],h0&&(a+=u.lineSpacing*p),i.rtl?o=d-o:"right"===i.align?o+=u.width-u.lineWidths[p]:"center"===i.align&&(o+=(u.width-u.lineWidths[p])/2),this.autoRound&&(o=Math.round(o),a=Math.round(a)),i.strokeThickness&&(this.style.syncShadow(e,i.shadowStroke),e.strokeText(h[p],o,a)),i.color&&(this.style.syncShadow(e,i.shadowFill),e.fillText(h[p],o,a));return e.restore(),this.renderer.gl&&(this.frame.source.glTexture=this.renderer.canvasToTexture(t,this.frame.source.glTexture,!0),this.frame.glTexture=this.frame.source.glTexture),this.dirty=!0,this},getTextMetrics:function(){return this.style.getTextMetrics()},text:{get:function(){return this._text},set:function(t){this.setText(t)}},toJSON:function(){var t=o.ToJSON(this),e={autoRound:this.autoRound,text:this._text,style:this.style.toJSON(),padding:{left:this.padding.left,right:this.padding.right,top:this.padding.top,bottom:this.padding.bottom}};return t.data=e,t},preDestroy:function(){this.style.rtl&&c(this.canvas),s.remove(this.canvas),this.texture.destroy()}});t.exports=p},function(t,e,i){var n=i(121),s=i(24),r=i(0),o=i(14),a=i(26),h=i(113),l=i(19),u=i(817),c=i(295),d=new r({Extends:l,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Crop,o.Depth,o.Flip,o.GetBounds,o.Mask,o.Origin,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Tint,o.Transform,o.Visible,u],initialize:function(t,e,i,r,o){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=32),void 0===o&&(o=32),l.call(this,t,"RenderTexture"),this.renderer=t.sys.game.renderer,this.textureManager=t.sys.textures,this.globalTint=16777215,this.globalAlpha=1,this.canvas=s.create2D(this,r,o),this.context=this.canvas.getContext("2d"),this.framebuffer=null,this._crop=this.resetCropObject(),this.texture=t.sys.textures.addCanvas(c(),this.canvas),this.frame=this.texture.get(),this._saved=!1,this.camera=new n(0,0,r,o),this.dirty=!1,this.gl=null;var h=this.renderer;if(h.type===a.WEBGL){var u=h.gl;this.gl=u,this.drawGameObject=this.batchGameObjectWebGL,this.framebuffer=h.createFramebuffer(r,o,this.frame.source.glTexture,!1)}else h.type===a.CANVAS&&(this.drawGameObject=this.batchGameObjectCanvas);this.camera.setScene(t),this.setPosition(e,i),this.setSize(r,o),this.setOrigin(0,0),this.initPipeline()},setSize:function(t,e){return this.resize(t,e)},resize:function(t,e){if(void 0===e&&(e=t),t!==this.width||e!==this.height){if(this.canvas.width=t,this.canvas.height=e,this.gl){var i=this.gl;this.renderer.deleteTexture(this.frame.source.glTexture),this.renderer.deleteFramebuffer(this.framebuffer),this.frame.source.glTexture=this.renderer.createTexture2D(0,i.NEAREST,i.NEAREST,i.CLAMP_TO_EDGE,i.CLAMP_TO_EDGE,i.RGBA,null,t,e,!1),this.framebuffer=this.renderer.createFramebuffer(t,e,this.frame.source.glTexture,!1),this.frame.glTexture=this.frame.source.glTexture}this.frame.source.width=t,this.frame.source.height=e,this.camera.setSize(t,e),this.frame.setSize(t,e),this.width=t,this.height=e}return this},setGlobalTint:function(t){return this.globalTint=t,this},setGlobalAlpha:function(t){return this.globalAlpha=t,this},saveTexture:function(t){return this.textureManager.renameTexture(this.texture.key,t),this._saved=!0,this.texture},fill:function(t,e){void 0===e&&(e=1);var i=255&(t>>16|0),n=255&(t>>8|0),s=255&(0|t);if(this.gl){this.renderer.setFramebuffer(this.framebuffer);var r=this.gl;r.clearColor(i/255,n/255,s/255,e),r.clear(r.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null)}else this.context.fillStyle="rgb("+i+","+n+","+s+")",this.context.fillRect(0,0,this.canvas.width,this.canvas.height);return this},clear:function(){if(this.dirty){if(this.gl){this.renderer.setFramebuffer(this.framebuffer);var t=this.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),this.renderer.setFramebuffer(null)}else{var e=this.context;e.save(),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,this.canvas.width,this.canvas.height),e.restore()}this.dirty=!1}return this},draw:function(t,e,i,n,s){void 0===n&&(n=this.globalAlpha),s=void 0===s?(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16):(s>>16)+(65280&s)+((255&s)<<16),Array.isArray(t)||(t=[t]);var r=this.gl;if(this.camera.preRender(1,1,1),r){this.renderer.setFramebuffer(this.framebuffer);var o=this.pipeline;o.projOrtho(0,this.width,0,this.height,-1e3,1e3),this.batchList(t,e,i,n,s),o.flush(),this.renderer.setFramebuffer(null),o.projOrtho(0,o.width,o.height,0,-1e3,1e3)}else this.renderer.setContext(this.context),this.batchList(t,e,i,n,s),this.renderer.setContext();return this.dirty=!0,this},drawFrame:function(t,e,i,n,s,r){void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=this.globalAlpha),r=void 0===r?(this.globalTint>>16)+(65280&this.globalTint)+((255&this.globalTint)<<16):(r>>16)+(65280&r)+((255&r)<<16);var o=this.gl,a=this.textureManager.getFrame(t,e);if(a){if(this.camera.preRender(1,1,1),o){this.renderer.setFramebuffer(this.framebuffer);var h=this.pipeline;h.projOrtho(0,this.width,0,this.height,-1e3,1e3),h.batchTextureFrame(a,i,n,r,s,this.camera.matrix,null),h.flush(),this.renderer.setFramebuffer(null),h.projOrtho(0,h.width,h.height,0,-1e3,1e3)}else this.batchTextureFrame(a,i,n,s,r);this.dirty=!0}return this},batchList:function(t,e,i,n,s){for(var r=0;r0?e.defaultFrame=i[0]:e.defaultFrame=this.defaultFrame,this},addEmitter:function(t){return this.emitters.add(t)},createEmitter:function(t){return this.addEmitter(new h(this,t))},addGravityWell:function(t){return this.wells.add(t)},createGravityWell:function(t){return this.addGravityWell(new o(t))},emitParticle:function(t,e,i){for(var n=this.emitters.list,s=0;s-1&&this.fillStyle(this.defaultFillColor,this.defaultFillAlpha),this.defaultStrokeColor>-1&&this.lineStyle(this.defaultStrokeWidth,this.defaultStrokeColor,this.defaultStrokeAlpha),this},generateTexture:function(t,e,i){var n,s,r=this.scene.sys,o=r.game.renderer;if(void 0===e&&(e=r.game.config.width),void 0===i&&(i=r.game.config.height),w.TargetCamera.setScene(this.scene),w.TargetCamera.setViewport(0,0,e,i),w.TargetCamera.scrollX=this.x,w.TargetCamera.scrollY=this.y,"string"==typeof t)if(r.textures.exists(t)){var a=(n=r.textures.get(t)).getSourceImage();a instanceof HTMLCanvasElement&&(s=a.getContext("2d"))}else s=(n=r.textures.createCanvas(t,e,i)).getSourceImage().getContext("2d");else t instanceof HTMLCanvasElement&&(s=t.getContext("2d"));return s&&(this.renderCanvas(o,this,0,w.TargetCamera,null,s,!1),n&&n.refresh()),this},preDestroy:function(){this.commandBuffer=[]}});w.TargetCamera=new n,t.exports=w},function(t,e,i){var n=i(109),s=i(0),r=i(834),o=new s({Extends:n,Mixins:[r],initialize:function(t,e,i,s,r,o,a){n.call(this,t,e,i,s,r,o,a),this.type="DynamicBitmapText",this.scrollX=0,this.scrollY=0,this.cropWidth=0,this.cropHeight=0,this.displayCallback,this.callbackData={color:0,tint:{topLeft:0,topRight:0,bottomLeft:0,bottomRight:0},index:0,charCode:0,x:0,y:0,scale:0,rotation:0,data:0}},setSize:function(t,e){return this.cropWidth=t,this.cropHeight=e,this},setDisplayCallback:function(t){return this.displayCallback=t,this},setScrollX:function(t){return this.scrollX=t,this},setScrollY:function(t){return this.scrollY=t,this}});t.exports=o},function(t,e,i){var n=i(164),s=i(66),r=i(0),o=i(14),a=i(19),h=i(9),l=i(837),u=i(309),c=i(3),d=new r({Extends:a,Mixins:[o.Alpha,o.BlendMode,o.ComputedSize,o.Depth,o.Mask,o.ScrollFactor,o.Transform,o.Visible,l],initialize:function(t,e,i,n){a.call(this,t,"Container"),this.list=[],this.exclusive=!0,this.maxSize=-1,this.position=0,this.localTransform=new o.TransformMatrix,this.tempTransformMatrix=new o.TransformMatrix,this._displayList=t.sys.displayList,this._sortKey="",this._sysEvents=t.sys.events,this.setPosition(e,i),this.clearAlpha(),this.setBlendMode(s.SKIP_CHECK),n&&this.add(n)},originX:{get:function(){return.5}},originY:{get:function(){return.5}},displayOriginX:{get:function(){return.5*this.width}},displayOriginY:{get:function(){return.5*this.height}},setExclusive:function(t){return void 0===t&&(t=!0),this.exclusive=t,this},getBounds:function(t){if(void 0===t&&(t=new h),t.setTo(this.x,this.y,0,0),this.list.length>0)for(var e=this.list,i=new h,n=0;n-1},setAll:function(t,e,i,s){return n.SetAll(this.list,t,e,i,s),this},each:function(t,e){var i,n=[null],s=this.list.slice(),r=s.length;for(i=2;i0?this.list[0]:null}},last:{get:function(){return this.list.length>0?(this.position=this.list.length-1,this.list[this.position]):null}},next:{get:function(){return this.position0?(this.position--,this.list[this.position]):null}},preDestroy:function(){this.removeAll(!!this.exclusive),this.localTransform.destroy(),this.tempTransformMatrix.destroy(),this.list=[],this._displayList=null}});t.exports=d},function(t,e,i){var n=i(841),s=i(838),r=i(0),o=i(14),a=i(113),h=i(19),l=i(112),u=new r({Extends:h,Mixins:[o.Alpha,o.BlendMode,o.Depth,o.Mask,o.Pipeline,o.ScaleMode,o.ScrollFactor,o.Size,o.Texture,o.Transform,o.Visible,n],initialize:function(t,e,i,n,s){h.call(this,t,"Blitter"),this.setTexture(n,s),this.setPosition(e,i),this.initPipeline(),this.children=new l,this.renderList=[],this.dirty=!1},create:function(t,e,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=this.children.length),void 0===i?i=this.frame:i instanceof a||(i=this.texture.get(i));var o=new s(this,t,e,i,n);return this.children.addAt(o,r,!1),this.dirty=!0,o},createFromCallback:function(t,e,i,n){for(var s=this.createMultiple(e,i,n),r=0;r0},getRenderList:function(){return this.dirty&&(this.renderList=this.children.list.filter(this.childCanRender,this),this.dirty=!1),this.renderList},clear:function(){this.children.removeAll(),this.dirty=!0},preDestroy:function(){this.children.destroy(),this.renderList=[]}});t.exports=u},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var n=e+Math.floor(Math.random()*i);return void 0===t[n]?null:t[n]}},function(t,e){t.exports=function(t){if(!Array.isArray(t)||t.length<2||!Array.isArray(t[0]))return!1;for(var e=t[0].length,i=1;i0},isTransitionIn:function(){return this.settings.isTransition},isVisible:function(){return this.settings.visible},setVisible:function(t){return this.settings.visible=t,this},setActive:function(t,e){return t?this.resume(e):this.pause(e)},start:function(t){t&&(this.settings.data=t),this.settings.status=s.START,this.settings.active=!0,this.settings.visible=!0,this.events.emit("start",this),this.events.emit("ready",this,t)},resize:function(t,e){this.events.emit("resize",t,e)},shutdown:function(t){this.events.off("transitioninit"),this.events.off("transitionstart"),this.events.off("transitioncomplete"),this.events.off("transitionout"),this.settings.status=s.SHUTDOWN,this.settings.active=!1,this.settings.visible=!1,this.events.emit("shutdown",this,t)},destroy:function(){this.settings.status=s.DESTROYED,this.settings.active=!1,this.settings.visible=!1,this.events.emit("destroy",this),this.events.removeAllListeners();for(var t=["scene","game","anims","cache","plugins","registry","sound","textures","add","camera","displayList","events","make","scenePlugin","updateList"],e=0;e=(t=t.toString()).length)switch(n){case 1:t=new Array(e+1-t.length).join(i)+t;break;case 3:var r=Math.ceil((s=e-t.length)/2);t=new Array(s-r+1).join(i)+t+new Array(r+1).join(i);break;default:t+=new Array(e+1-t.length).join(i)}return t}},function(t,e,i){var n=new(i(0))({initialize:function(t){if(this.entries={},this.size=0,Array.isArray(t))for(var e=0;e=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}},function(t,e){t.exports=function(t,e,i){return(t=Math.max(0,Math.min(1,(t-e)/(i-e))))*t*t*(t*(6*t-15)+10)}},function(t,e){t.exports=function(t,e,i,n,s){var r=n+Math.atan2(t.y-i,t.x-e);return t.x=e+s*Math.cos(r),t.y=i+s*Math.sin(r),t}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=t.x2-t.x1,s=t.y2-t.y1,r=t.x3-t.x1,o=t.y3-t.y1,a=Math.random(),h=Math.random();return a+h>=1&&(a=1-a,h=1-h),e.x=t.x1+(i*a+r*h),e.y=t.y1+(s*a+o*h),e}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random()*Math.PI*2,s=Math.sqrt(Math.random());return e.x=t.x+s*Math.cos(i)*t.width/2,e.y=t.y+s*Math.sin(i)*t.height/2,e}},function(t,e){var i={defaultPipeline:null,pipeline:null,initPipeline:function(t){void 0===t&&(t="TextureTintPipeline");var e=this.scene.sys.game.renderer;return!!(e&&e.gl&&e.hasPipeline(t))&&(this.defaultPipeline=e.getPipeline(t),this.pipeline=this.defaultPipeline,!0)},setPipeline:function(t){var e=this.scene.sys.game.renderer;return e&&e.gl&&e.hasPipeline(t)&&(this.pipeline=e.getPipeline(t)),this},resetPipeline:function(){return this.pipeline=this.defaultPipeline,null!==this.pipeline},getPipelineName:function(){return this.pipeline.name}};t.exports=i},function(t,e,i){var n=i(6);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.x+Math.random()*t.width,e.y=t.y+Math.random()*t.height,e}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=Math.random();return e.x=t.x1+i*(t.x2-t.x1),e.y=t.y1+i*(t.y2-t.y1),e}},function(t,e,i){var n=i(65),s=i(6);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=n(t)/i);for(var o=t.x1,a=t.y1,h=t.x2,l=t.y2,u=0;u=1)return i.x=t.x,i.y=t.y,i;var r=n(t)*e;return e>.5?(r-=t.width+t.height)<=t.width?(i.x=t.right-r,i.y=t.bottom):(i.x=t.x,i.y=t.bottom-(r-t.width)):r<=t.width?(i.x=t.x+r,i.y=t.y):(i.x=t.right,i.y=t.y+(r-t.width)),i}},function(t,e,i){var n=i(6);t.exports=function(t,e){void 0===e&&(e=new n);var i=2*Math.PI*Math.random(),s=Math.random()+Math.random(),r=s>1?2-s:s,o=r*Math.cos(i),a=r*Math.sin(i);return e.x=t.x+o*t.radius,e.y=t.y+a*t.radius,e}},function(t,e,i){var n=i(6);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x+t.radius*Math.cos(e),i.y=t.y+t.radius*Math.sin(e),i}},function(t,e){t.exports={TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12}},function(t,e,i){var n={};t.exports=n;var s=i(76),r=i(81),o=i(222),a=i(80),h=i(505),l=i(33);n._warming=.4,n._torqueDampen=1,n._minLength=1e-6,n.create=function(t){var e=t;e.bodyA&&!e.pointA&&(e.pointA={x:0,y:0}),e.bodyB&&!e.pointB&&(e.pointB={x:0,y:0});var i=e.bodyA?r.add(e.bodyA.position,e.pointA):e.pointA,n=e.bodyB?r.add(e.bodyB.position,e.pointB):e.pointB,s=r.magnitude(r.sub(i,n));e.length=void 0!==e.length?e.length:s,e.id=e.id||l.nextId(),e.label=e.label||"Constraint",e.type="constraint",e.stiffness=e.stiffness||(e.length>0?1:.7),e.damping=e.damping||0,e.angularStiffness=e.angularStiffness||0,e.angleA=e.bodyA?e.bodyA.angle:e.angleA,e.angleB=e.bodyB?e.bodyB.angle:e.angleB,e.plugin={};var o={visible:!0,lineWidth:2,strokeStyle:"#ffffff",type:"line",anchors:!0};return 0===e.length&&e.stiffness>.1?(o.type="pin",o.anchors=!1):e.stiffness<.9&&(o.type="spring"),e.render=l.extend(o,e.render),e},n.preSolveAll=function(t){for(var e=0;e0&&(c.position.x+=l.x,c.position.y+=l.y),0!==l.angle&&(s.rotate(c.vertices,l.angle,i.position),h.rotate(c.axes,l.angle),u>0&&r.rotateAbout(c.position,l.angle,i.position,c.position)),a.update(c.bounds,c.vertices,i.velocity)}l.angle*=n._warming,l.x*=n._warming,l.y*=n._warming}}}},function(t,e,i){var n={};t.exports=n;var s=i(33);n.on=function(t,e,i){for(var n,s=e.split(" "),r=0;r0){i||(i={}),n=e.split(" ");for(var l=0;l0?(n.textures[e-1]&&n.textures[e-1]!==t&&this.pushBatch(),i[i.length-1].textures[e-1]=t):(null!==n.texture&&n.texture!==t&&this.pushBatch(),i[i.length-1].texture=t),this},pushBatch:function(){var t={first:this.vertexCount,texture:null,textures:[]};this.batches.push(t)},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t,e,i,n=this.gl,s=this.vertexCount,r=this.topology,o=this.vertexSize,a=this.renderer,h=this.batches,l=0,u=null;if(0===h.length||0===s)return this.flushLocked=!1,this;n.bufferSubData(n.ARRAY_BUFFER,0,this.bytes.subarray(0,s*o));for(var c=0;c0){for(e=0;e0){for(e=0;e0&&(a.setTexture2D(u.texture,0),n.drawArrays(r,u.first,l)),this.vertexCount=0,h.length=0,this.pushBatch(),this.flushLocked=!1,this},batchSprite:function(t,e,i){this.renderer.setPipeline(this);var n=this._tempMatrix1,s=this._tempMatrix2,r=this._tempMatrix3,o=t.frame,a=o.glTexture,h=o.u0,l=o.v0,c=o.u1,d=o.v1,f=o.x,p=o.y,g=o.cutWidth,v=o.cutHeight,y=-t.displayOriginX+f,m=-t.displayOriginY+p;if(t.isCropped){var x=t._crop;x.flipX===t.flipX&&x.flipY===t.flipY||o.updateCropUVs(x,t.flipX,t.flipY),h=x.u0,l=x.v0,c=x.u1,d=x.v1,g=x.width,v=x.height,f=x.x,p=x.y,y=-t.displayOriginX+f,m=-t.displayOriginY+p}t.flipX&&(y+=g,g*=-1),t.flipY&&(m+=v,v*=-1);var w=y+g,b=m+v;s.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),n.copyFrom(e.matrix),i?(n.multiplyWithOffset(i,-e.scrollX*t.scrollFactorX,-e.scrollY*t.scrollFactorY),s.e=t.x,s.f=t.y,n.multiply(s,r)):(s.e-=e.scrollX*t.scrollFactorX,s.f-=e.scrollY*t.scrollFactorY,n.multiply(s,r));var T=r.getX(y,m),S=r.getY(y,m),_=r.getX(y,b),A=r.getY(y,b),C=r.getX(w,b),M=r.getY(w,b),P=r.getX(w,m),E=r.getY(w,m),k=u.getTintAppendFloatAlpha(t._tintTL,e.alpha*t._alphaTL),L=u.getTintAppendFloatAlpha(t._tintTR,e.alpha*t._alphaTR),F=u.getTintAppendFloatAlpha(t._tintBL,e.alpha*t._alphaBL),R=u.getTintAppendFloatAlpha(t._tintBR,e.alpha*t._alphaBR);e.roundPixels&&(T|=0,S|=0,_|=0,A|=0,C|=0,M|=0,P|=0,E|=0),this.setTexture2D(a,0);var O=t._isTinted&&t.tintFill;this.batchQuad(T,S,_,A,C,M,P,E,h,l,c,d,k,L,F,R,O)},batchQuad:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f,p,g,v){var y=!1;this.vertexCount+6>this.vertexCapacity&&(this.flush(),y=!0);var m=this.vertexViewF32,x=this.vertexViewU32,w=this.vertexCount*this.vertexComponentCount-1;return m[++w]=t,m[++w]=e,m[++w]=h,m[++w]=l,m[++w]=v,x[++w]=d,m[++w]=i,m[++w]=n,m[++w]=h,m[++w]=c,m[++w]=v,x[++w]=p,m[++w]=s,m[++w]=r,m[++w]=u,m[++w]=c,m[++w]=v,x[++w]=g,m[++w]=t,m[++w]=e,m[++w]=h,m[++w]=l,m[++w]=v,x[++w]=d,m[++w]=s,m[++w]=r,m[++w]=u,m[++w]=c,m[++w]=v,x[++w]=g,m[++w]=o,m[++w]=a,m[++w]=u,m[++w]=l,m[++w]=v,x[++w]=f,this.vertexCount+=6,y},batchTri:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f){var p=!1;this.vertexCount+3>this.vertexCapacity&&(this.flush(),p=!0);var g=this.vertexViewF32,v=this.vertexViewU32,y=this.vertexCount*this.vertexComponentCount-1;return g[++y]=t,g[++y]=e,g[++y]=o,g[++y]=a,g[++y]=f,v[++y]=u,g[++y]=i,g[++y]=n,g[++y]=o,g[++y]=l,g[++y]=f,v[++y]=c,g[++y]=s,g[++y]=r,g[++y]=h,g[++y]=l,g[++y]=f,v[++y]=d,this.vertexCount+=3,p},batchTexture:function(t,e,i,n,s,r,o,a,h,l,u,c,d,f,p,g,v,y,m,x,w,b,T,S,_,A,C,M,P,E,k){this.renderer.setPipeline(this,t);var L=this._tempMatrix1,F=this._tempMatrix2,R=this._tempMatrix3,O=y/i+C,D=m/n+M,B=(y+x)/i+C,I=(m+w)/n+M,Y=o,X=a,z=-g,N=-v;if(t.isCropped){var U=t._crop;Y=U.width,X=U.height,o=U.width,a=U.height;var V=y=U.x,G=m=U.y;c&&(V=x-U.x-U.width),d&&!e.isRenderTexture&&(G=w-U.y-U.height),O=V/i+C,D=G/n+M,B=(V+U.width)/i+C,I=(G+U.height)/n+M,z=-g+y,N=-v+m}d^=!k&&e.isRenderTexture?1:0,c&&(Y*=-1,z+=o),d&&(X*=-1,N+=a);var W=z+Y,H=N+X;F.applyITRS(s,r,u,h,l),L.copyFrom(P.matrix),E?(L.multiplyWithOffset(E,-P.scrollX*f,-P.scrollY*p),F.e=s,F.f=r,L.multiply(F,R)):(F.e-=P.scrollX*f,F.f-=P.scrollY*p,L.multiply(F,R));var j=R.getX(z,N),q=R.getY(z,N),K=R.getX(z,H),J=R.getY(z,H),Z=R.getX(W,H),Q=R.getY(W,H),$=R.getX(W,N),tt=R.getY(W,N);P.roundPixels&&(j|=0,q|=0,K|=0,J|=0,Z|=0,Q|=0,$|=0,tt|=0),this.setTexture2D(e,0),this.batchQuad(j,q,K,J,Z,Q,$,tt,O,D,B,I,b,T,S,_,A)},batchTextureFrame:function(t,e,i,n,s,r,o){this.renderer.setPipeline(this);var a=this._tempMatrix1.copyFrom(r),h=this._tempMatrix2,l=e+t.width,c=i+t.height;o?a.multiply(o,h):h=a;var d=h.getX(e,i),f=h.getY(e,i),p=h.getX(e,c),g=h.getY(e,c),v=h.getX(l,c),y=h.getY(l,c),m=h.getX(l,i),x=h.getY(l,i);this.setTexture2D(t.glTexture,0),n=u.getTintAppendFloatAlpha(n,s),this.batchQuad(d,f,p,g,v,y,m,x,t.u0,t.v0,t.u1,t.v1,n,n,n,n,0)},drawFillRect:function(t,e,i,n,s,r){var o=t+i,a=e+n,h=u.getTintAppendFloatAlphaAndSwap(s,r);this.batchQuad(t,e,t,a,o,a,o,e,0,0,1,1,h,h,h,h,2)},batchFillRect:function(t,e,i,n,s,r){this.renderer.setPipeline(this);var o=this._tempMatrix3;r&&r.multiply(s,o);var a=t+i,h=e+n,l=o.getX(t,e),u=o.getY(t,e),c=o.getX(t,h),d=o.getY(t,h),f=o.getX(a,h),p=o.getY(a,h),g=o.getX(a,e),v=o.getY(a,e),y=this.currentFrame,m=y.u0,x=y.v0,w=y.u1,b=y.v1;this.batchQuad(l,u,c,d,f,p,g,v,m,x,w,b,this.fillTint.TL,this.fillTint.TR,this.fillTint.BL,this.fillTint.BR,this.tintEffect)},batchFillTriangle:function(t,e,i,n,s,r,o,a){this.renderer.setPipeline(this);var h=this._tempMatrix3;a&&a.multiply(o,h);var l=h.getX(t,e),u=h.getY(t,e),c=h.getX(i,n),d=h.getY(i,n),f=h.getX(s,r),p=h.getY(s,r),g=this.currentFrame,v=g.u0,y=g.v0,m=g.u1,x=g.v1;this.batchTri(l,u,c,d,f,p,v,y,m,x,this.fillTint.TL,this.fillTint.TR,this.fillTint.BL,this.tintEffect)},batchStrokeTriangle:function(t,e,i,n,s,r,o,a,h){var l=this.tempTriangle;l[0].x=t,l[0].y=e,l[0].width=o,l[1].x=i,l[1].y=n,l[1].width=o,l[2].x=s,l[2].y=r,l[2].width=o,l[3].x=t,l[3].y=e,l[3].width=o,this.batchStrokePath(l,o,!1,a,h)},batchFillPath:function(t,e,i){this.renderer.setPipeline(this);var n=this._tempMatrix3;i&&i.multiply(e,n);for(var r,o,a=t.length,h=this.polygonCache,l=this.fillTint.TL,u=this.fillTint.TR,c=this.fillTint.BL,d=this.tintEffect,f=0;f0&&H[4]?this.batchQuad(R,O,E,k,H[0],H[1],H[2],H[3],U,V,G,W,I,Y,X,z,B):(j[0]=R,j[1]=O,j[2]=E,j[3]=k,j[4]=1),h&&j[4]?this.batchQuad(M,P,L,F,j[0],j[1],j[2],j[3],U,V,G,W,I,Y,X,z,B):(H[0]=M,H[1]=P,H[2]=L,H[3]=F,H[4]=1)}}});t.exports=d},function(t,e,i){var n=i(0),s=i(10),r=new n({initialize:function(t){this.name="WebGLPipeline",this.game=t.game,this.view=t.game.canvas,this.resolution=t.game.config.resolution,this.width=t.game.config.width*this.resolution,this.height=t.game.config.height*this.resolution,this.gl=t.gl,this.vertexCount=0,this.vertexCapacity=t.vertexCapacity,this.renderer=t.renderer,this.vertexData=t.vertices?t.vertices:new ArrayBuffer(t.vertexCapacity*t.vertexSize),this.vertexBuffer=this.renderer.createVertexBuffer(t.vertices?t.vertices:this.vertexData.byteLength,this.gl.STREAM_DRAW),this.program=this.renderer.createProgram(t.vertShader,t.fragShader),this.attributes=t.attributes,this.vertexSize=t.vertexSize,this.topology=t.topology,this.bytes=new Uint8Array(this.vertexData),this.vertexComponentCount=s.getComponentCount(t.attributes,this.gl),this.flushLocked=!1,this.active=!1},boot:function(){},addAttribute:function(t,e,i,n,s){return this.attributes.push({name:t,size:e,type:this.renderer.glFormats[i],normalized:n,offset:s}),this},shouldFlush:function(){return this.vertexCount>=this.vertexCapacity},resize:function(t,e,i){return this.width=t*i,this.height=e*i,this},bind:function(){var t=this.gl,e=this.vertexBuffer,i=this.attributes,n=this.program,s=this.renderer,r=this.vertexSize;s.setProgram(n),s.setVertexBuffer(e);for(var o=0;o=0?(t.enableVertexAttribArray(h),t.vertexAttribPointer(h,a.size,a.type,a.normalized,r,a.offset)):t.disableVertexAttribArray(h)}return this},onBind:function(){return this},onPreRender:function(){return this},onRender:function(){return this},onPostRender:function(){return this},flush:function(){if(this.flushLocked)return this;this.flushLocked=!0;var t=this.gl,e=this.vertexCount,i=this.topology,n=this.vertexSize;if(0!==e)return t.bufferSubData(t.ARRAY_BUFFER,0,this.bytes.subarray(0,e*n)),t.drawArrays(i,0,e),this.vertexCount=0,this.flushLocked=!1,this;this.flushLocked=!1},destroy:function(){var t=this.gl;return t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),delete this.program,delete this.vertexBuffer,delete this.gl,this},setFloat1:function(t,e){return this.renderer.setFloat1(this.program,t,e),this},setFloat2:function(t,e,i){return this.renderer.setFloat2(this.program,t,e,i),this},setFloat3:function(t,e,i,n){return this.renderer.setFloat3(this.program,t,e,i,n),this},setFloat4:function(t,e,i,n,s){return this.renderer.setFloat4(this.program,t,e,i,n,s),this},setFloat1v:function(t,e){return this.renderer.setFloat1v(this.program,t,e),this},setFloat2v:function(t,e){return this.renderer.setFloat2v(this.program,t,e),this},setFloat3v:function(t,e){return this.renderer.setFloat3v(this.program,t,e),this},setFloat4v:function(t,e){return this.renderer.setFloat4v(this.program,t,e),this},setInt1:function(t,e){return this.renderer.setInt1(this.program,t,e),this},setInt2:function(t,e,i){return this.renderer.setInt2(this.program,t,e,i),this},setInt3:function(t,e,i,n){return this.renderer.setInt3(this.program,t,e,i,n),this},setInt4:function(t,e,i,n,s){return this.renderer.setInt4(this.program,t,e,i,n,s),this},setMatrix2:function(t,e,i){return this.renderer.setMatrix2(this.program,t,e,i),this},setMatrix3:function(t,e,i){return this.renderer.setMatrix3(this.program,t,e,i),this},setMatrix4:function(t,e,i){return this.renderer.setMatrix4(this.program,t,e,i),this}});t.exports=r},function(t,e,i){var n=i(53);t.exports=function(t){return n(t,-180,180)}},function(t,e,i){var n=i(53);t.exports=function(t){return n(t,-Math.PI,Math.PI)}},function(t,e){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){var n=i(0),s=i(11),r=i(97),o=i(83),a=new n({Extends:s,initialize:function(t){s.call(this),this.manager=t,this.isTimeline=!0,this.data=[],this.totalData=0,this.useFrames=!1,this.timeScale=1,this.loop=0,this.loopDelay=0,this.loopCounter=0,this.completeDelay=0,this.countdown=0,this.state=o.PENDING_ADD,this._pausedState=o.PENDING_ADD,this.paused=!1,this.elapsed=0,this.totalElapsed=0,this.duration=0,this.progress=0,this.totalDuration=0,this.totalProgress=0,this.callbacks={onComplete:null,onLoop:null,onStart:null,onUpdate:null,onYoyo:null},this.callbackScope},setTimeScale:function(t){return this.timeScale=t,this},getTimeScale:function(){return this.timeScale},isPlaying:function(){return this.state===o.ACTIVE},add:function(t){return this.queue(r(this,t))},queue:function(t){return this.isPlaying()||(t.parent=this,t.parentIsTimeline=!0,this.data.push(t),this.totalData=this.data.length),this},hasOffset:function(t){return null!==t.offset},isOffsetAbsolute:function(t){return"number"==typeof t},isOffsetRelative:function(t){if("string"===typeof t){var e=t[0];if("-"===e||"+"===e)return!0}return!1},getRelativeOffset:function(t,e){var i=t[0],n=parseFloat(t.substr(2)),s=e;switch(i){case"+":s+=n;break;case"-":s-=n}return Math.max(0,s)},calcDuration:function(){for(var t=0,e=0,i=0,n=0;n0?this.totalDuration=this.duration+this.completeDelay+(this.duration+this.loopDelay)*this.loopCounter:this.totalDuration=this.duration+this.completeDelay},init:function(){return this.calcDuration(),this.progress=0,this.totalProgress=0,!this.paused||(this.state=o.PAUSED,!1)},resetTweens:function(t){for(var e=0;e0){this.elapsed=0,this.progress=0,this.loopCounter--;var t=this.callbacks.onLoop;t&&t.func.apply(t.scope,t.params),this.emit("loop",this,this.loopCounter),this.resetTweens(!0),this.loopDelay>0?(this.countdown=this.loopDelay,this.state=o.LOOP_DELAY):this.state=o.ACTIVE}else if(this.completeDelay>0)this.countdown=this.completeDelay,this.state=o.COMPLETE_DELAY;else{var e=this.callbacks.onComplete;e&&e.func.apply(e.scope,e.params),this.emit("complete",this),this.state=o.PENDING_REMOVE}},update:function(t,e){if(this.state!==o.PAUSED){var i=e;switch(this.useFrames&&(e=1*this.manager.timeScale),e*=this.timeScale,this.elapsed+=e,this.progress=Math.min(this.elapsed/this.duration,1),this.totalElapsed+=e,this.totalProgress=Math.min(this.totalElapsed/this.totalDuration,1),this.state){case o.ACTIVE:for(var n=this.totalData,s=0;s0?Math.floor(v/p.length):h(e,"duration",g.duration),g.delay=h(e,"delay",g.delay),g.easeParams=c(e,"easeParams",g.easeParams),g.ease=a(c(e,"ease",g.ease),g.easeParams),g.hold=h(e,"hold",g.hold),g.repeat=h(e,"repeat",g.repeat),g.repeatDelay=h(e,"repeatDelay",g.repeatDelay),g.yoyo=o(e,"yoyo",g.yoyo),g.flipX=o(e,"flipX",g.flipX),g.flipY=o(e,"flipY",g.flipY);for(var y=0;y0){var t=this.delay+this.delay*this.repeat;return(this.elapsed+this.delay*(this.repeat-this.repeatCount))/t}return this.getProgress()},getRepeatCount:function(){return this.repeatCount},getElapsed:function(){return this.elapsed},getElapsedSeconds:function(){return.001*this.elapsed},remove:function(t){void 0===t&&(t=!1),this.elapsed=this.delay,this.hasDispatched=!t,this.repeatCount=0},destroy:function(){this.callback=void 0,this.callbackScope=void 0,this.args=[]}});t.exports=r},function(t,e,i){var n=i(0),s=i(14),r=i(26),o=i(19),a=i(446),h=i(103),l=i(38),u=i(10),c=new n({Extends:o,Mixins:[s.Alpha,s.BlendMode,s.ComputedSize,s.Depth,s.Flip,s.GetBounds,s.Origin,s.Pipeline,s.ScaleMode,s.Transform,s.Visible,s.ScrollFactor,a],initialize:function(t,e,i,n,s,a){o.call(this,t,"StaticTilemapLayer"),this.isTilemap=!0,this.tilemap=e,this.layerIndex=i,this.layer=e.layers[i],this.layer.tilemapLayer=this,this.tileset=[],this.culledTiles=[],this.skipCull=!1,this.tilesDrawn=0,this.tilesTotal=this.layer.width*this.layer.height,this.cullPaddingX=1,this.cullPaddingY=1,this.cullCallback=h.CullTiles,this.renderer=t.sys.game.renderer,this.vertexBuffer=[],this.bufferData=[],this.vertexViewF32=[],this.vertexViewU32=[],this.dirty=[],this.vertexCount=[],this._renderOrder=0,this._tempMatrix=new l,this.gidMap=[],this.setTilesets(n),this.setAlpha(this.layer.alpha),this.setPosition(s,a),this.setOrigin(),this.setSize(this.layer.tileWidth*this.layer.width,this.layer.tileHeight*this.layer.height),this.updateVBOData(),this.initPipeline("TextureTintPipeline"),t.sys.game.config.renderType===r.WEBGL&&t.sys.game.renderer.onContextRestored(function(){this.updateVBOData()},this)},setTilesets:function(t){var e=[],i=[],n=this.tilemap;Array.isArray(t)||(t=[t]);for(var s=0;sv||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));else if(1===p)for(o=0;o=0;a--)!(r=f[o][a])||r.indexv||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));else if(2===p)for(o=u-1;o>=0;o--)for(a=0;av||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));else if(3===p)for(o=u-1;o>=0;o--)for(a=l-1;a>=0;a--)!(r=f[o][a])||r.indexv||!r.visible||(x=this.batchTile(x,r,h,c,d,t,e));this.dirty[e]=!1,null===y?(y=i.createVertexBuffer(m,n.STATIC_DRAW),this.vertexBuffer[e]=y):(i.setVertexBuffer(y),n.bufferSubData(n.ARRAY_BUFFER,0,m))}return this},batchTile:function(t,e,i,n,s,r,o){var a=i.getTileTextureCoordinates(e.index);if(!a)return t;var h=a.x/n,l=a.y/s,c=(a.x+e.width)/n,d=(a.y+e.height)/s,f=this._tempMatrix,p=e.width,g=e.height,v=p/2,y=g/2,m=-v,x=-y;e.flipX&&(p*=-1,m+=e.width),e.flipY&&(g*=-1,x+=e.height);var w=m+p,b=x+g;f.applyITRS(v+e.pixelX,y+e.pixelY,e.rotation,1,1);var T=u.getTintAppendFloatAlpha(16777215,r.alpha*this.alpha*e.alpha),S=f.getX(m,x),_=f.getY(m,x),A=f.getX(m,b),C=f.getY(m,b),M=f.getX(w,b),P=f.getY(w,b),E=f.getX(w,x),k=f.getY(w,x);r.roundPixels&&(S|=0,_|=0,A|=0,C|=0,M|=0,P|=0,E|=0,k|=0);var L=this.vertexViewF32[o],F=this.vertexViewU32[o];return L[++t]=S,L[++t]=_,L[++t]=h,L[++t]=l,L[++t]=0,F[++t]=T,L[++t]=A,L[++t]=C,L[++t]=h,L[++t]=d,L[++t]=0,F[++t]=T,L[++t]=M,L[++t]=P,L[++t]=c,L[++t]=d,L[++t]=0,F[++t]=T,L[++t]=S,L[++t]=_,L[++t]=h,L[++t]=l,L[++t]=0,F[++t]=T,L[++t]=M,L[++t]=P,L[++t]=c,L[++t]=d,L[++t]=0,F[++t]=T,L[++t]=E,L[++t]=k,L[++t]=c,L[++t]=l,L[++t]=0,F[++t]=T,this.vertexCount[o]+=6,t},setRenderOrder:function(t){if("string"==typeof t&&(t=["right-down","left-down","right-up","left-up"].indexOf(t)),t>=0&&t<4){this._renderOrder=t;for(var e=0;e=0&&t<4&&(this._renderOrder=t),this},calculateFacesAt:function(t,e){return a.CalculateFacesAt(t,e,this.layer),this},calculateFacesWithin:function(t,e,i,n){return a.CalculateFacesWithin(t,e,i,n,this.layer),this},createFromTiles:function(t,e,i,n,s){return a.CreateFromTiles(t,e,i,n,s,this.layer)},cull:function(t){return this.cullCallback(this.layer,t,this.culledTiles,this._renderOrder)},copy:function(t,e,i,n,s,r,o){return a.Copy(t,e,i,n,s,r,o,this.layer),this},destroy:function(){this.layer.tilemapLayer===this&&(this.layer.tilemapLayer=void 0),this.tilemap=void 0,this.layer=void 0,this.culledTiles.length=0,this.cullCallback=null,this.gidMap=[],this.tileset=[],o.prototype.destroy.call(this)},fill:function(t,e,i,n,s,r){return a.Fill(t,e,i,n,s,r,this.layer),this},filterTiles:function(t,e,i,n,s,r,o){return a.FilterTiles(t,e,i,n,s,r,o,this.layer)},findByIndex:function(t,e,i){return a.FindByIndex(t,e,i,this.layer)},findTile:function(t,e,i,n,s,r,o){return a.FindTile(t,e,i,n,s,r,o,this.layer)},forEachTile:function(t,e,i,n,s,r,o){return a.ForEachTile(t,e,i,n,s,r,o,this.layer),this},getTileAt:function(t,e,i){return a.GetTileAt(t,e,i,this.layer)},getTileAtWorldXY:function(t,e,i,n){return a.GetTileAtWorldXY(t,e,i,n,this.layer)},getTilesWithin:function(t,e,i,n,s){return a.GetTilesWithin(t,e,i,n,s,this.layer)},getTilesWithinShape:function(t,e,i){return a.GetTilesWithinShape(t,e,i,this.layer)},getTilesWithinWorldXY:function(t,e,i,n,s,r){return a.GetTilesWithinWorldXY(t,e,i,n,s,r,this.layer)},hasTileAt:function(t,e){return a.HasTileAt(t,e,this.layer)},hasTileAtWorldXY:function(t,e,i){return a.HasTileAtWorldXY(t,e,i,this.layer)},putTileAt:function(t,e,i,n){return a.PutTileAt(t,e,i,n,this.layer)},putTileAtWorldXY:function(t,e,i,n,s){return a.PutTileAtWorldXY(t,e,i,n,s,this.layer)},putTilesAt:function(t,e,i,n){return a.PutTilesAt(t,e,i,n,this.layer),this},randomize:function(t,e,i,n,s){return a.Randomize(t,e,i,n,s,this.layer),this},removeTileAt:function(t,e,i,n){return a.RemoveTileAt(t,e,i,n,this.layer)},removeTileAtWorldXY:function(t,e,i,n,s){return a.RemoveTileAtWorldXY(t,e,i,n,s,this.layer)},renderDebug:function(t,e){return a.RenderDebug(t,e,this.layer),this},replaceByIndex:function(t,e,i,n,s,r){return a.ReplaceByIndex(t,e,i,n,s,r,this.layer),this},setSkipCull:function(t){return void 0===t&&(t=!0),this.skipCull=t,this},setCullPadding:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=1),this.cullPaddingX=t,this.cullPaddingY=e,this},setCollision:function(t,e,i){return a.SetCollision(t,e,i,this.layer),this},setCollisionBetween:function(t,e,i,n){return a.SetCollisionBetween(t,e,i,n,this.layer),this},setCollisionByProperty:function(t,e,i){return a.SetCollisionByProperty(t,e,i,this.layer),this},setCollisionByExclusion:function(t,e,i){return a.SetCollisionByExclusion(t,e,i,this.layer),this},setCollisionFromCollisionGroup:function(t,e){return a.SetCollisionFromCollisionGroup(t,e,this.layer),this},setTileIndexCallback:function(t,e,i){return a.SetTileIndexCallback(t,e,i,this.layer),this},setTileLocationCallback:function(t,e,i,n,s,r){return a.SetTileLocationCallback(t,e,i,n,s,r,this.layer),this},shuffle:function(t,e,i,n){return a.Shuffle(t,e,i,n,this.layer),this},swapByIndex:function(t,e,i,n,s,r){return a.SwapByIndex(t,e,i,n,s,r,this.layer),this},tileToWorldX:function(t,e){return a.TileToWorldX(t,e,this.layer)},tileToWorldY:function(t,e){return a.TileToWorldY(t,e,this.layer)},tileToWorldXY:function(t,e,i,n){return a.TileToWorldXY(t,e,i,n,this.layer)},weightedRandomize:function(t,e,i,n,s){return a.WeightedRandomize(t,e,i,n,s,this.layer),this},worldToTileX:function(t,e,i){return a.WorldToTileX(t,e,i,this.layer)},worldToTileY:function(t,e,i){return a.WorldToTileY(t,e,i,this.layer)},worldToTileXY:function(t,e,i,n,s){return a.WorldToTileXY(t,e,i,n,s,this.layer)}});t.exports=h},function(t,e,i){var n=i(0),s=i(31),r=i(208),o=i(20),a=i(29),h=i(78),l=i(242),u=i(207),c=i(55),d=i(103),f=i(99),p=new n({initialize:function(t,e){this.scene=t,this.tileWidth=e.tileWidth,this.tileHeight=e.tileHeight,this.width=e.width,this.height=e.height,this.orientation=e.orientation,this.renderOrder=e.renderOrder,this.format=e.format,this.version=e.version,this.properties=e.properties,this.widthInPixels=e.widthInPixels,this.heightInPixels=e.heightInPixels,this.imageCollections=e.imageCollections,this.images=e.images,this.layers=e.layers,this.tilesets=e.tilesets,this.objects=e.objects,this.currentLayerIndex=0},setRenderOrder:function(t){var e=["right-down","left-down","right-up","left-up"];return"number"==typeof t&&(t=e[t]),e.indexOf(t)>-1&&(this.renderOrder=t),this},addTilesetImage:function(t,e,i,n,s,r,o){if(void 0===t)return null;if(void 0!==e&&null!==e||(e=t),!this.scene.sys.textures.exists(e))return console.warn("Invalid Tileset Image: "+e),null;var h=this.scene.sys.textures.get(e),l=this.getTilesetIndex(t);if(null===l&&this.format===a.TILED_JSON)return console.warn("No data found for Tileset: "+t),null;var u=this.tilesets[l];return u?(u.setTileSize(i,n),u.setSpacing(s,r),u.setImage(h),u):(void 0===i&&(i=this.tileWidth),void 0===n&&(n=this.tileHeight),void 0===s&&(s=0),void 0===r&&(r=0),void 0===o&&(o=0),(u=new f(t,o,i,n,s,r)).setImage(h),this.tilesets.push(u),u)},convertLayerToStatic:function(t){if(null===(t=this.getLayer(t)))return null;var e=t.tilemapLayer;if(!(e&&e instanceof r))return null;var i=new u(e.scene,e.tilemap,e.layerIndex,e.tileset,e.x,e.y);return this.scene.sys.displayList.add(i),e.destroy(),i},copy:function(t,e,i,n,s,r,o,a){return a=this.getLayer(a),this._isStaticCall(a,"copy")?this:(null!==a&&d.Copy(t,e,i,n,s,r,o,a),this)},createBlankDynamicLayer:function(t,e,i,n,s,o,a,l){if(void 0===a&&(a=e.tileWidth),void 0===l&&(l=e.tileHeight),void 0===s&&(s=this.width),void 0===o&&(o=this.height),void 0===i&&(i=0),void 0===n&&(n=0),null!==this.getLayerIndex(t))return console.warn("Invalid Tilemap Layer ID: "+t),null;for(var u,d=new h({name:t,tileWidth:a,tileHeight:l,width:s,height:o}),f=0;fa&&(a=e.layer[l].width),e.layer[l].height>h&&(h=e.layer[l].height);var u=new s({width:a,height:h,name:t,tileWidth:e.layer[0].tilesize,tileHeight:e.layer[0].tilesize,format:n.WELTMEISTER});return u.layers=r(e,i),u.tilesets=o(e),u}},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t){void 0===t&&(t={}),this.name=s(t,"name","object layer"),this.opacity=s(t,"opacity",1),this.properties=s(t,"properties",{}),this.propertyTypes=s(t,"propertytypes",{}),this.type=s(t,"type","objectgroup"),this.visible=s(t,"visible",!0),this.objects=s(t,"objects",[])}});t.exports=r},function(t,e,i){var n=i(455),s=i(214),r=function(t){return{x:t.x,y:t.y}},o=["id","name","type","rotation","properties","visible","x","y","width","height"];t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var a=n(t,o);if(a.x+=e,a.y+=i,t.gid){var h=s(t.gid);a.gid=h.gid,a.flippedHorizontal=h.flippedHorizontal,a.flippedVertical=h.flippedVertical,a.flippedAntiDiagonal=h.flippedAntiDiagonal}else t.polyline?a.polyline=t.polyline.map(r):t.polygon?a.polygon=t.polygon.map(r):t.ellipse?(a.ellipse=t.ellipse,a.width=t.width,a.height=t.height):t.text?(a.width=t.width,a.height=t.height,a.text=t.text):(a.rectangle=!0,a.width=t.width,a.height=t.height);return a}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){(void 0===i||i<=0)&&(i=32),(void 0===n||n<=0)&&(n=32),void 0===s&&(s=0),void 0===r&&(r=0),this.name=t,this.firstgid=0|e,this.imageWidth=0|i,this.imageHeight=0|n,this.imageMargin=0|s,this.imageSpacing=0|r,this.properties=o||{},this.images=[],this.total=0},containsImageIndex:function(t){return t>=this.firstgid&&t-1}return!1}},function(t,e,i){var n=i(17);t.exports=function(t,e,i,s,r,o,a){for(var h=n(i,s,r,o,null,a),l=0;l0&&r.motion=r.sleepThreshold&&n.set(r,!0)):r.sleepCounter>0&&(r.sleepCounter-=1)}else n.set(r,!1)}},n.afterCollisions=function(t,e){for(var i=e*e*e,s=0;sn._motionWakeThreshold*i&&n.set(l,!1)}}}},n.set=function(t,e){var i=t.isSleeping;e?(t.isSleeping=!0,t.sleepCounter=t.sleepThreshold,t.positionImpulse.x=0,t.positionImpulse.y=0,t.positionPrev.x=t.position.x,t.positionPrev.y=t.position.y,t.anglePrev=t.angle,t.speed=0,t.angularSpeed=0,t.motion=0,i||s.trigger(t,"sleepStart")):(t.isSleeping=!1,t.sleepCounter=0,i&&s.trigger(t,"sleepEnd"))}},function(t,e){t.exports={NONE:0,A:1,B:2,BOTH:3}},function(t,e){t.exports={NEVER:0,LITE:1,PASSIVE:2,ACTIVE:4,FIXED:8}},function(t,e,i){var n=i(40),s=i(0),r=i(35),o=i(39),a=i(3),h=new s({initialize:function(t,e){var i=e.width?e.width:64,n=e.height?e.height:64;this.world=t,this.gameObject=e,this.debugShowBody=t.defaults.debugShowStaticBody,this.debugBodyColor=t.defaults.staticBodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new a,this.position=new a(e.x-e.displayOriginX,e.y-e.displayOriginY),this.width=i,this.height=n,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center=new a(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=a.ZERO,this.allowGravity=!1,this.gravity=a.ZERO,this.bounce=a.ZERO,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.mass=1,this.immovable=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.physicsType=r.STATIC_BODY,this._dx=0,this._dy=0},setGameObject:function(t,e){return t&&t!==this.gameObject&&(this.gameObject.body=null,t.body=this,this.gameObject=t),e&&this.updateFromGameObject(),this},updateFromGameObject:function(){this.world.staticTree.remove(this);var t=this.gameObject;return t.getTopLeft(this.position),this.width=t.displayWidth,this.height=t.displayHeight,this.halfWidth=Math.abs(this.width/2),this.halfHeight=Math.abs(this.height/2),this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.world.staticTree.insert(this),this},setOffset:function(t,e){return void 0===e&&(e=t),this.world.staticTree.remove(this),this.position.x-=this.offset.x,this.position.y-=this.offset.y,this.offset.set(t,e),this.position.x+=this.offset.x,this.position.y+=this.offset.y,this.updateCenter(),this.world.staticTree.insert(this),this},setSize:function(t,e,i,n){void 0===i&&(i=this.offset.x),void 0===n&&(n=this.offset.y);var s=this.gameObject;return!t&&s.frame&&(t=s.frame.realWidth),!e&&s.frame&&(e=s.frame.realHeight),this.world.staticTree.remove(this),this.width=t,this.height=e,this.halfWidth=Math.floor(t/2),this.halfHeight=Math.floor(e/2),this.offset.set(i,n),this.updateCenter(),this.isCircle=!1,this.radius=0,this.world.staticTree.insert(this),this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.world.staticTree.remove(this),this.isCircle=!0,this.radius=t,this.width=2*t,this.height=2*t,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter(),this.world.staticTree.insert(this)):this.isCircle=!1,this},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},reset:function(t,e){var i=this.gameObject;void 0===t&&(t=i.x),void 0===e&&(e=i.y),this.world.staticTree.remove(this),i.getTopLeft(this.position),this.updateCenter(),this.world.staticTree.insert(this)},stop:function(){return this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):o(this,t,e)},postUpdate:function(){},deltaAbsX:function(){return 0},deltaAbsY:function(){return 0},deltaX:function(){return 0},deltaY:function(){return 0},deltaZ:function(){return 0},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.width,this.height))},willDrawDebug:function(){return this.debugShowBody},setMass:function(t){return t<=0&&(t=.1),this.mass=t,this},x:{get:function(){return this.position.x},set:function(t){this.world.staticTree.remove(this),this.position.x=t,this.world.staticTree.insert(this)}},y:{get:function(){return this.position.y},set:function(t){this.world.staticTree.remove(this),this.position.y=t,this.world.staticTree.insert(this)}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=h},function(t,e){t.exports=function(t,e){return!(e.right<=t.left||e.bottom<=t.top||e.position.x>=t.right||e.position.y>=t.bottom)}},function(t,e,i){var n=i(313);function s(t){if(!(this instanceof s))return new s(t,[".left",".top",".right",".bottom"]);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}function r(t,e,i){if(!i)return e.indexOf(t);for(var n=0;n=t.minX&&e.maxY>=t.minY}function g(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(t,e,i,s,r){for(var o,a=[e,i];a.length;)(i=a.pop())-(e=a.pop())<=s||(o=e+Math.ceil((i-e)/s/2)*s,n(t,o,e,i,r),a.push(e,o,o,i))}s.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,i=[],n=this.toBBox;if(!p(t,e))return i;for(var s,r,o,a,h=[];e;){for(s=0,r=e.children.length;s=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(s,r,e)},_split:function(t,e){var i=t[e],n=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,n);var r=this._chooseSplitIndex(i,s,n),a=g(i.children.splice(r,i.children.length-r));a.height=i.height,a.leaf=i.leaf,o(i,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)},_splitRoot:function(t,e){this.data=g([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,i){var n,s,r,o,h,l,u,d,f,p,g,v,y,m;for(l=u=1/0,n=e;n<=i-e;n++)s=a(t,0,n,this.toBBox),r=a(t,n,i,this.toBBox),f=s,p=r,void 0,void 0,void 0,void 0,g=Math.max(f.minX,p.minX),v=Math.max(f.minY,p.minY),y=Math.min(f.maxX,p.maxX),m=Math.min(f.maxY,p.maxY),o=Math.max(0,y-g)*Math.max(0,m-v),h=c(s)+c(r),o=e;s--)r=t.children[s],h(u,t.leaf?o(r):r),c+=d(u);return c},_adjustParentBBoxes:function(t,e,i){for(var n=i;n>=0;n--)h(e[n],t)},_condense:function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():o(t[i],this.toBBox)},compareMinX:function(t,e){return t.left-e.left},compareMinY:function(t,e){return t.top-e.top},toBBox:function(t){return{minX:t.left,minY:t.top,maxX:t.right,maxY:t.bottom}}},t.exports=s},function(t,e,i){var n=new(i(0))({initialize:function(){this._pending=[],this._active=[],this._destroy=[],this._toProcess=0},add:function(t){return this._pending.push(t),this._toProcess++,this},remove:function(t){return this._destroy.push(t),this._toProcess++,this},update:function(){if(0===this._toProcess)return this._active;var t,e,i=this._destroy,n=this._active;for(t=0;te._dy?(r=t.bottom-e.y)>o&&!i||!1===t.checkCollision.down||!1===e.checkCollision.up?r=0:(t.touching.none=!1,t.touching.down=!0,e.touching.none=!1,e.touching.up=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.down=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.up=!0)):t._dyo&&!i||!1===t.checkCollision.up||!1===e.checkCollision.down?r=0:(t.touching.none=!1,t.touching.up=!0,e.touching.none=!1,e.touching.down=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.up=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.down=!0))),t.overlapY=r,e.overlapY=r,r}},function(t,e,i){var n=i(35);t.exports=function(t,e,i,s){var r=0,o=t.deltaAbsX()+e.deltaAbsX()+s;return 0===t._dx&&0===e._dx?(t.embedded=!0,e.embedded=!0):t._dx>e._dx?(r=t.right-e.x)>o&&!i||!1===t.checkCollision.right||!1===e.checkCollision.left?r=0:(t.touching.none=!1,t.touching.right=!0,e.touching.none=!1,e.touching.left=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.right=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.left=!0)):t._dxo&&!i||!1===t.checkCollision.left||!1===e.checkCollision.right?r=0:(t.touching.none=!1,t.touching.left=!0,e.touching.none=!1,e.touching.right=!0,e.physicsType===n.STATIC_BODY&&(t.blocked.none=!1,t.blocked.left=!0),t.physicsType===n.STATIC_BODY&&(e.blocked.none=!1,e.blocked.right=!0))),t.overlapX=r,e.overlapX=r,r}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n,s,r,o){this.world=t,this.name="",this.active=!0,this.overlapOnly=e,this.object1=i,this.object2=n,this.collideCallback=s,this.processCallback=r,this.callbackContext=o},setName:function(t){return this.name=t,this},update:function(){this.world.collideObjects(this.object1,this.object2,this.collideCallback,this.processCallback,this.callbackContext,this.overlapOnly)},destroy:function(){this.world.removeCollider(this),this.active=!1,this.world=null,this.object1=null,this.object2=null,this.collideCallback=null,this.processCallback=null,this.callbackContext=null}});t.exports=n},function(t,e,i){var n=i(40),s=i(0),r=i(35),o=i(172),a=i(9),h=i(39),l=i(3),u=new s({initialize:function(t,e){var i=e.width?e.width:64,n=e.height?e.height:64;this.world=t,this.gameObject=e,this.transform={x:e.x,y:e.y,rotation:e.angle,scaleX:e.scaleX,scaleY:e.scaleY,displayOriginX:e.displayOriginX,displayOriginY:e.displayOriginY},this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new l,this.position=new l(e.x,e.y),this.prev=new l(e.x,e.y),this.allowRotation=!0,this.rotation=e.angle,this.preRotation=e.angle,this.width=i,this.height=n,this.sourceWidth=i,this.sourceHeight=n,e.frame&&(this.sourceWidth=e.frame.realWidth,this.sourceHeight=e.frame.realHeight),this.halfWidth=Math.abs(i/2),this.halfHeight=Math.abs(n/2),this.center=new l(e.x+this.halfWidth,e.y+this.halfHeight),this.velocity=new l,this.newVelocity=new l,this.deltaMax=new l,this.acceleration=new l,this.allowDrag=!0,this.drag=new l,this.allowGravity=!0,this.gravity=new l,this.bounce=new l,this.worldBounce=null,this.onWorldBounds=!1,this.onCollide=!1,this.onOverlap=!1,this.maxVelocity=new l(1e4,1e4),this.friction=new l(1,0),this.useDamping=!1,this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=r.FACING_NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={none:!0,up:!1,down:!1,left:!1,right:!1},this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.physicsType=r.DYNAMIC_BODY,this._reset=!0,this._sx=e.scaleX,this._sy=e.scaleY,this._dx=0,this._dy=0,this._bounds=new a},updateBounds:function(){var t=this.gameObject,e=this.transform;if(t.parentContainer){var i=t.getWorldTransformMatrix(this.world._tempMatrix,this.world._tempMatrix2);e.x=i.tx,e.y=i.ty,e.rotation=o(i.rotation),e.scaleX=i.scaleX,e.scaleY=i.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY}else e.x=t.x,e.y=t.y,e.rotation=t.angle,e.scaleX=t.scaleX,e.scaleY=t.scaleY,e.displayOriginX=t.displayOriginX,e.displayOriginY=t.displayOriginY;var n=!1;if(this.syncBounds){var s=t.getBounds(this._bounds);this.width=s.width,this.height=s.height,n=!0}else{var r=Math.abs(e.scaleX),a=Math.abs(e.scaleY);this._sx===r&&this._sy===a||(this.width=this.sourceWidth*r,this.height=this.sourceHeight*a,this._sx=r,this._sy=a,n=!0)}n&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter())},updateCenter:function(){this.center.set(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},update:function(t){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.none=!0,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.overlapR=0,this.overlapX=0,this.overlapY=0,this.embedded=!1,this.updateBounds();var e=this.transform;if(this.position.x=e.x+e.scaleX*(this.offset.x-e.displayOriginX),this.position.y=e.y+e.scaleY*(this.offset.y-e.displayOriginY),this.updateCenter(),this.rotation=e.rotation,this.preRotation=this.rotation,this._reset&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves){this.world.updateMotion(this,t);var i=this.velocity.x,n=this.velocity.y;this.newVelocity.set(i*t,n*t),this.position.add(this.newVelocity),this.updateCenter(),this.angle=Math.atan2(n,i),this.speed=Math.sqrt(i*i+n*n),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.world.emit("worldbounds",this,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)}this._dx=this.position.x-this.prev.x,this._dy=this.position.y-this.prev.y},postUpdate:function(){this._dx=this.position.x-this.prev.x,this._dy=this.position.y-this.prev.y,this.moves&&(0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:this._dx>0&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:this._dy>0&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.gameObject.x+=this._dx,this.gameObject.y+=this._dy,this._reset=!0),this._dx<0?this.facing=r.FACING_LEFT:this._dx>0&&(this.facing=r.FACING_RIGHT),this._dy<0?this.facing=r.FACING_UP:this._dy>0&&(this.facing=r.FACING_DOWN),this.allowRotation&&(this.gameObject.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y},checkWorldBounds:function(){var t=this.position,e=this.world.bounds,i=this.world.checkCollision,n=this.worldBounce?-this.worldBounce.x:-this.bounce.x,s=this.worldBounce?-this.worldBounce.y:-this.bounce.y;return t.xe.right&&i.right&&(t.x=e.right-this.width,this.velocity.x*=n,this.blocked.right=!0,this.blocked.none=!1),t.ye.bottom&&i.down&&(t.y=e.bottom-this.height,this.velocity.y*=s,this.blocked.down=!0,this.blocked.none=!1),!this.blocked.none},setOffset:function(t,e){return void 0===e&&(e=t),this.offset.set(t,e),this},setSize:function(t,e,i){void 0===i&&(i=!0);var n=this.gameObject;if(!t&&n.frame&&(t=n.frame.realWidth),!e&&n.frame&&(e=n.frame.realHeight),this.sourceWidth=t,this.sourceHeight=e,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.updateCenter(),i&&n.getCenter){var s=n.displayWidth/2,r=n.displayHeight/2;this.offset.set(s-this.halfWidth,r-this.halfHeight)}return this.isCircle=!1,this.radius=0,this},setCircle:function(t,e,i){return void 0===e&&(e=this.offset.x),void 0===i&&(i=this.offset.y),t>0?(this.isCircle=!0,this.radius=t,this.sourceWidth=2*t,this.sourceHeight=2*t,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.set(e,i),this.updateCenter()):this.isCircle=!1,this},reset:function(t,e){this.stop();var i=this.gameObject;i.setPosition(t,e),i.getTopLeft(this.position),this.prev.copy(this.position),this.rotation=i.angle,this.preRotation=i.angle,this.updateBounds(),this.updateCenter()},stop:function(){return this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this},getBounds:function(t){return t.x=this.x,t.y=this.y,t.right=this.right,t.bottom=this.bottom,t},hitTest:function(t,e){return this.isCircle?n(this,t,e):h(this,t,e)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return this._dx>0?this._dx:-this._dx},deltaAbsY:function(){return this._dy>0?this._dy:-this._dy},deltaX:function(){return this._dx},deltaY:function(){return this._dy},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.enable=!1,this.world.pendingDestroy.set(this)},drawDebug:function(t){var e=this.position,i=e.x+this.halfWidth,n=e.y+this.halfHeight;this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor),this.isCircle?t.strokeCircle(i,n,this.width/2):t.strokeRect(e.x,e.y,this.width,this.height)),this.debugShowVelocity&&(t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.velocity.x/2,n+this.velocity.y/2))},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},setCollideWorldBounds:function(t){return void 0===t&&(t=!0),this.collideWorldBounds=t,this},setVelocity:function(t,e){return this.velocity.set(t,e),this.speed=Math.sqrt(t*t+e*e),this},setVelocityX:function(t){this.velocity.x=t;var e=t,i=this.velocity.y;return this.speed=Math.sqrt(e*e+i*i),this},setVelocityY:function(t){this.velocity.y=t;var e=this.velocity.x,i=t;return this.speed=Math.sqrt(e*e+i*i),this},setMaxVelocity:function(t,e){return this.maxVelocity.set(t,e),this},setBounce:function(t,e){return this.bounce.set(t,e),this},setBounceX:function(t){return this.bounce.x=t,this},setBounceY:function(t){return this.bounce.y=t,this},setAcceleration:function(t,e){return this.acceleration.set(t,e),this},setAccelerationX:function(t){return this.acceleration.x=t,this},setAccelerationY:function(t){return this.acceleration.y=t,this},setAllowDrag:function(t){return void 0===t&&(t=!0),this.allowDrag=t,this},setAllowGravity:function(t){return void 0===t&&(t=!0),this.allowGravity=t,this},setAllowRotation:function(t){return void 0===t&&(t=!0),this.allowRotation=t,this},setDrag:function(t,e){return this.drag.set(t,e),this},setDragX:function(t){return this.drag.x=t,this},setDragY:function(t){return this.drag.y=t,this},setGravity:function(t,e){return this.gravity.set(t,e),this},setGravityX:function(t){return this.gravity.x=t,this},setGravityY:function(t){return this.gravity.y=t,this},setFriction:function(t,e){return this.friction.set(t,e),this},setFrictionX:function(t){return this.friction.x=t,this},setFrictionY:function(t){return this.friction.y=t,this},setAngularVelocity:function(t){return this.angularVelocity=t,this},setAngularAcceleration:function(t){return this.angularAcceleration=t,this},setAngularDrag:function(t){return this.angularDrag=t,this},setMass:function(t){return this.mass=t,this},setImmovable:function(t){return void 0===t&&(t=!0),this.immovable=t,this},setEnable:function(t){return void 0===t&&(t=!0),this.enable=t,this},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},left:{get:function(){return this.position.x}},right:{get:function(){return this.position.x+this.width}},top:{get:function(){return this.position.y}},bottom:{get:function(){return this.position.y+this.height}}});t.exports=u},function(t,e,i){var n=i(232),s=i(23),r=i(0),o=i(231),a=i(35),h=i(52),l=i(11),u=i(248),c=i(247),d=i(246),f=i(230),p=i(229),g=i(4),v=i(228),y=i(514),m=i(9),x=i(227),w=i(513),b=i(508),T=i(507),S=i(95),_=i(225),A=i(226),C=i(38),M=i(3),P=i(53),E=new r({Extends:l,initialize:function(t,e){l.call(this),this.scene=t,this.bodies=new S,this.staticBodies=new S,this.pendingDestroy=new S,this.colliders=new v,this.gravity=new M(g(e,"gravity.x",0),g(e,"gravity.y",0)),this.bounds=new m(g(e,"x",0),g(e,"y",0),g(e,"width",t.sys.game.config.width),g(e,"height",t.sys.game.config.height)),this.checkCollision={up:g(e,"checkCollision.up",!0),down:g(e,"checkCollision.down",!0),left:g(e,"checkCollision.left",!0),right:g(e,"checkCollision.right",!0)},this.fps=g(e,"fps",60),this._elapsed=0,this._frameTime=1/this.fps,this._frameTimeMS=1e3*this._frameTime,this.stepsLastFrame=0,this.timeScale=g(e,"timeScale",1),this.OVERLAP_BIAS=g(e,"overlapBias",4),this.TILE_BIAS=g(e,"tileBias",16),this.forceX=g(e,"forceX",!1),this.isPaused=g(e,"isPaused",!1),this._total=0,this.drawDebug=g(e,"debug",!1),this.debugGraphic,this.defaults={debugShowBody:g(e,"debugShowBody",!0),debugShowStaticBody:g(e,"debugShowStaticBody",!0),debugShowVelocity:g(e,"debugShowVelocity",!0),bodyDebugColor:g(e,"debugBodyColor",16711935),staticBodyDebugColor:g(e,"debugStaticBodyColor",255),velocityDebugColor:g(e,"debugVelocityColor",65280)},this.maxEntries=g(e,"maxEntries",16),this.useTree=g(e,"useTree",!0),this.tree=new x(this.maxEntries),this.staticTree=new x(this.maxEntries),this.treeMinMax={minX:0,minY:0,maxX:0,maxY:0},this._tempMatrix=new C,this._tempMatrix2=new C,this.drawDebug&&this.createDebugGraphic()},enable:function(t,e){void 0===e&&(e=a.DYNAMIC_BODY),Array.isArray(t)||(t=[t]);for(var i=0;i=s;)this._elapsed-=s,i++,this.step(n);this.stepsLastFrame=i}},step:function(t){var e,i,n=this.bodies.entries,s=n.length;for(e=0;e0){var l=this.tree,u=this.staticTree;for(o=(r=s.entries).length,t=0;ta.bottom)&&(h.xa.right))return this.separateCircle(t,e,s)}var l=!1,u=!1;this.forceX||Math.abs(this.gravity.y+t.gravity.y)l.right&&(a=h(u.x,u.y,l.right,l.y)-u.radius):u.y>l.bottom&&(u.xl.right&&(a=h(u.x,u.y,l.right,l.bottom)-u.radius)),a*=-1}else a=t.halfWidth+e.halfWidth-h(t.center.x,t.center.y,e.center.x,e.center.y);if(i||0===a||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==a&&(t.onOverlap||e.onOverlap)&&this.emit("overlap",t.gameObject,e.gameObject,t,e),0!==a;var c=t.velocity.x,d=t.velocity.y,g=t.mass,v=e.velocity.x,y=e.velocity.y,m=e.mass,x=c*Math.cos(o)+d*Math.sin(o),w=c*Math.sin(o)-d*Math.cos(o),b=v*Math.cos(o)+y*Math.sin(o),T=v*Math.sin(o)-y*Math.cos(o),S=((g-m)*x+2*m*b)/(g+m),_=(2*g*x+(m-g)*b)/(g+m);t.immovable||(t.velocity.x=(S*Math.cos(o)-w*Math.sin(o))*t.bounce.x,t.velocity.y=(w*Math.cos(o)+S*Math.sin(o))*t.bounce.y,c=t.velocity.x,d=t.velocity.y),e.immovable||(e.velocity.x=(_*Math.cos(o)-T*Math.sin(o))*e.bounce.x,e.velocity.y=(T*Math.cos(o)+_*Math.sin(o))*e.bounce.y,v=e.velocity.x,y=e.velocity.y),Math.abs(o)0&&!t.immovable&&v>c?t.velocity.x*=-1:v<0&&!e.immovable&&c0&&!t.immovable&&y>d?t.velocity.y*=-1:y<0&&!e.immovable&&dMath.PI/2&&(c<0&&!t.immovable&&v0&&!e.immovable&&c>v?e.velocity.x*=-1:d<0&&!t.immovable&&y0&&!e.immovable&&c>y&&(e.velocity.y*=-1));var A=this._frameTime;return t.immovable||(t.x+=t.velocity.x*A-a*Math.cos(o),t.y+=t.velocity.y*A-a*Math.sin(o)),e.immovable||(e.x+=e.velocity.x*A+a*Math.cos(o),e.y+=e.velocity.y*A+a*Math.sin(o)),(t.onCollide||e.onCollide)&&this.emit("collide",t.gameObject,e.gameObject,t,e),t.postUpdate(),e.postUpdate(),!0},intersects:function(t,e){return t!==e&&(t.isCircle||e.isCircle?t.isCircle?e.isCircle?h(t.center.x,t.center.y,e.center.x,e.center.y)<=t.halfWidth+e.halfWidth:this.circleBodyIntersects(t,e):this.circleBodyIntersects(e,t):!(t.right<=e.position.x||t.bottom<=e.position.y||t.position.x>=e.right||t.position.y>=e.bottom))},circleBodyIntersects:function(t,e){var i=s(t.center.x,e.left,e.right),n=s(t.center.y,e.top,e.bottom);return(t.center.x-i)*(t.center.x-i)+(t.center.y-n)*(t.center.y-n)<=t.halfWidth*t.halfWidth},overlap:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!0)},collide:function(t,e,i,n,s){return void 0===i&&(i=null),void 0===n&&(n=null),void 0===s&&(s=i),this.collideObjects(t,e,i,n,s,!1)},collideObjects:function(t,e,i,n,s,r){var o;t.isParent&&void 0===t.physicsType&&(t=t.children.entries),e&&e.isParent&&void 0===e.physicsType&&(e=e.children.entries);var a=Array.isArray(t),h=Array.isArray(e);if(this._total=0,a||h)if(!a&&h)for(o=0;o0},collideHandler:function(t,e,i,n,s,r){if(void 0===e&&t.isParent)return this.collideGroupVsGroup(t,t,i,n,s,r);if(!t||!e)return!1;if(t.body){if(e.body)return this.collideSpriteVsSprite(t,e,i,n,s,r);if(e.isParent)return this.collideSpriteVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideSpriteVsTilemapLayer(t,e,i,n,s,r)}else if(t.isParent){if(e.body)return this.collideSpriteVsGroup(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsGroup(t,e,i,n,s,r);if(e.isTilemap)return this.collideGroupVsTilemapLayer(t,e,i,n,s,r)}else if(t.isTilemap){if(e.body)return this.collideSpriteVsTilemapLayer(e,t,i,n,s,r);if(e.isParent)return this.collideGroupVsTilemapLayer(e,t,i,n,s,r)}},collideSpriteVsSprite:function(t,e,i,n,s,r){return!(!t.body||!e.body)&&(this.separate(t.body,e.body,n,s,r)&&(i&&i.call(s,t,e),this._total++),!0)},collideSpriteVsGroup:function(t,e,i,n,s,r){var o,h,l,u=t.body;if(0!==e.length&&u&&u.enable)if(this.useTree){var c=this.treeMinMax;c.minX=u.left,c.minY=u.top,c.maxX=u.right,c.maxY=u.bottom;var d=e.physicsType===a.DYNAMIC_BODY?this.tree.search(c):this.staticTree.search(c);for(h=d.length,o=0;oc.baseTileWidth){var d=(c.tileWidth-c.baseTileWidth)*e.scaleX;a-=d,l+=d}c.tileHeight>c.baseTileHeight&&(u+=(c.tileHeight-c.baseTileHeight)*e.scaleY);var f,p=e.getTilesWithinWorldXY(a,h,l,u);if(0===p.length)return!1;for(var g={left:0,right:0,top:0,bottom:0},v=0;v0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},rotationTo:function(t,e){var i=t.x*e.x+t.y*e.y+t.z*e.z;return i<-.999999?(u.copy(h).cross(t).length()<1e-6&&u.copy(l).cross(t),u.normalize(),this.setAxisAngle(u,Math.PI)):i>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(u.copy(t).cross(e),this.x=u.x,this.y=u.y,this.z=u.z,this.w=1+i,this.normalize())},setAxes:function(t,e,i){var n=c.val;return n[0]=e.x,n[3]=e.y,n[6]=e.z,n[1]=i.x,n[4]=i.y,n[7]=i.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(c).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,e){e*=.5;var i=Math.sin(e);return this.x=i*t.x,this.y=i*t.y,this.z=i*t.z,this.w=Math.cos(e),this},multiply:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.x,o=t.y,a=t.z,h=t.w;return this.x=e*h+s*r+i*a-n*o,this.y=i*h+s*o+n*r-e*a,this.z=n*h+s*a+e*o-i*r,this.w=s*h-e*r-i*o-n*a,this},slerp:function(t,e){var i=this.x,n=this.y,s=this.z,r=this.w,o=t.x,a=t.y,h=t.z,l=t.w,u=i*o+n*a+s*h+r*l;u<0&&(u=-u,o=-o,a=-a,h=-h,l=-l);var c=1-e,d=e;if(1-u>1e-6){var f=Math.acos(u),p=Math.sin(f);c=Math.sin((1-e)*f)/p,d=Math.sin(e*f)/p}return this.x=c*i+d*o,this.y=c*n+d*a,this.z=c*s+d*h,this.w=c*r+d*l,this},invert:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-e*r,this.z=-i*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+s*r,this.y=i*o+n*r,this.z=n*o-i*r,this.w=s*o-e*r,this},rotateY:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o-n*r,this.y=i*o+s*r,this.z=n*o+e*r,this.w=s*o-i*r,this},rotateZ:function(t){t*=.5;var e=this.x,i=this.y,n=this.z,s=this.w,r=Math.sin(t),o=Math.cos(t);return this.x=e*o+i*r,this.y=i*o-e*r,this.z=n*o+s*r,this.w=s*o-n*r,this},calculateW:function(){var t=this.x,e=this.y,i=this.z;return this.w=-Math.sqrt(1-t*t-e*e-i*i),this},fromMat3:function(t){var e,i=t.val,n=i[0]+i[4]+i[8];if(n>0)e=Math.sqrt(n+1),this.w=.5*e,e=.5/e,this.x=(i[7]-i[5])*e,this.y=(i[2]-i[6])*e,this.z=(i[3]-i[1])*e;else{var s=0;i[4]>i[0]&&(s=1),i[8]>i[3*s+s]&&(s=2);var r=o[s],h=o[r];e=Math.sqrt(i[3*s+s]-i[3*r+r]-i[3*h+h]+1),a[s]=.5*e,e=.5/e,a[r]=(i[3*r+s]+i[3*s+r])*e,a[h]=(i[3*h+s]+i[3*s+h])*e,this.x=a[0],this.y=a[1],this.z=a[2],this.w=(i[3*h+r]-i[3*r+h])*e}return this}});t.exports=d},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],this},zero:function(){var t=this.val;return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,this},xyz:function(t,e,i){this.identity();var n=this.val;return n[12]=t,n[13]=e,n[14]=i,this},scaling:function(t,e,i){this.zero();var n=this.val;return n[0]=t,n[5]=e,n[10]=i,n[15]=1,this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[3],s=t[6],r=t[7],o=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=e,t[6]=t[9],t[7]=t[13],t[8]=i,t[9]=s,t[11]=t[14],t[12]=n,t[13]=r,t[14]=o,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15],y=e*o-i*r,m=e*a-n*r,x=e*h-s*r,w=i*a-n*o,b=i*h-s*o,T=n*h-s*a,S=l*p-u*f,_=l*g-c*f,A=l*v-d*f,C=u*g-c*p,M=u*v-d*p,P=c*v-d*g,E=y*P-m*M+x*C+w*A-b*_+T*S;return E?(E=1/E,t[0]=(o*P-a*M+h*C)*E,t[1]=(n*M-i*P-s*C)*E,t[2]=(p*T-g*b+v*w)*E,t[3]=(c*b-u*T-d*w)*E,t[4]=(a*A-r*P-h*_)*E,t[5]=(e*P-n*A+s*_)*E,t[6]=(g*x-f*T-v*m)*E,t[7]=(l*T-c*x+d*m)*E,t[8]=(r*M-o*A+h*S)*E,t[9]=(i*A-e*M-s*S)*E,t[10]=(f*b-p*x+v*y)*E,t[11]=(u*x-l*b-d*y)*E,t[12]=(o*_-r*C-a*S)*E,t[13]=(e*C-i*_+n*S)*E,t[14]=(p*m-f*w-g*y)*E,t[15]=(l*w-u*m+c*y)*E,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return t[0]=o*(c*v-d*g)-u*(a*v-h*g)+p*(a*d-h*c),t[1]=-(i*(c*v-d*g)-u*(n*v-s*g)+p*(n*d-s*c)),t[2]=i*(a*v-h*g)-o*(n*v-s*g)+p*(n*h-s*a),t[3]=-(i*(a*d-h*c)-o*(n*d-s*c)+u*(n*h-s*a)),t[4]=-(r*(c*v-d*g)-l*(a*v-h*g)+f*(a*d-h*c)),t[5]=e*(c*v-d*g)-l*(n*v-s*g)+f*(n*d-s*c),t[6]=-(e*(a*v-h*g)-r*(n*v-s*g)+f*(n*h-s*a)),t[7]=e*(a*d-h*c)-r*(n*d-s*c)+l*(n*h-s*a),t[8]=r*(u*v-d*p)-l*(o*v-h*p)+f*(o*d-h*u),t[9]=-(e*(u*v-d*p)-l*(i*v-s*p)+f*(i*d-s*u)),t[10]=e*(o*v-h*p)-r*(i*v-s*p)+f*(i*h-s*o),t[11]=-(e*(o*d-h*u)-r*(i*d-s*u)+l*(i*h-s*o)),t[12]=-(r*(u*g-c*p)-l*(o*g-a*p)+f*(o*c-a*u)),t[13]=e*(u*g-c*p)-l*(i*g-n*p)+f*(i*c-n*u),t[14]=-(e*(o*g-a*p)-r*(i*g-n*p)+f*(i*a-n*o)),t[15]=e*(o*c-a*u)-r*(i*c-n*u)+l*(i*a-n*o),this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=t[9],c=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return(e*o-i*r)*(c*v-d*g)-(e*a-n*r)*(u*v-d*p)+(e*h-s*r)*(u*g-c*p)+(i*a-n*o)*(l*v-d*f)-(i*h-s*o)*(l*g-c*f)+(n*h-s*a)*(l*p-u*f)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],y=e[15],m=t.val,x=m[0],w=m[1],b=m[2],T=m[3];return e[0]=x*i+w*o+b*u+T*p,e[1]=x*n+w*a+b*c+T*g,e[2]=x*s+w*h+b*d+T*v,e[3]=x*r+w*l+b*f+T*y,x=m[4],w=m[5],b=m[6],T=m[7],e[4]=x*i+w*o+b*u+T*p,e[5]=x*n+w*a+b*c+T*g,e[6]=x*s+w*h+b*d+T*v,e[7]=x*r+w*l+b*f+T*y,x=m[8],w=m[9],b=m[10],T=m[11],e[8]=x*i+w*o+b*u+T*p,e[9]=x*n+w*a+b*c+T*g,e[10]=x*s+w*h+b*d+T*v,e[11]=x*r+w*l+b*f+T*y,x=m[12],w=m[13],b=m[14],T=m[15],e[12]=x*i+w*o+b*u+T*p,e[13]=x*n+w*a+b*c+T*g,e[14]=x*s+w*h+b*d+T*v,e[15]=x*r+w*l+b*f+T*y,this},multiplyLocal:function(t){var e=[],i=this.val,n=t.val;return e[0]=i[0]*n[0]+i[1]*n[4]+i[2]*n[8]+i[3]*n[12],e[1]=i[0]*n[1]+i[1]*n[5]+i[2]*n[9]+i[3]*n[13],e[2]=i[0]*n[2]+i[1]*n[6]+i[2]*n[10]+i[3]*n[14],e[3]=i[0]*n[3]+i[1]*n[7]+i[2]*n[11]+i[3]*n[15],e[4]=i[4]*n[0]+i[5]*n[4]+i[6]*n[8]+i[7]*n[12],e[5]=i[4]*n[1]+i[5]*n[5]+i[6]*n[9]+i[7]*n[13],e[6]=i[4]*n[2]+i[5]*n[6]+i[6]*n[10]+i[7]*n[14],e[7]=i[4]*n[3]+i[5]*n[7]+i[6]*n[11]+i[7]*n[15],e[8]=i[8]*n[0]+i[9]*n[4]+i[10]*n[8]+i[11]*n[12],e[9]=i[8]*n[1]+i[9]*n[5]+i[10]*n[9]+i[11]*n[13],e[10]=i[8]*n[2]+i[9]*n[6]+i[10]*n[10]+i[11]*n[14],e[11]=i[8]*n[3]+i[9]*n[7]+i[10]*n[11]+i[11]*n[15],e[12]=i[12]*n[0]+i[13]*n[4]+i[14]*n[8]+i[15]*n[12],e[13]=i[12]*n[1]+i[13]*n[5]+i[14]*n[9]+i[15]*n[13],e[14]=i[12]*n[2]+i[13]*n[6]+i[14]*n[10]+i[15]*n[14],e[15]=i[12]*n[3]+i[13]*n[7]+i[14]*n[11]+i[15]*n[15],this.fromArray(e)},translate:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[12]=s[0]*e+s[4]*i+s[8]*n+s[12],s[13]=s[1]*e+s[5]*i+s[9]*n+s[13],s[14]=s[2]*e+s[6]*i+s[10]*n+s[14],s[15]=s[3]*e+s[7]*i+s[11]*n+s[15],this},scale:function(t){var e=t.x,i=t.y,n=t.z,s=this.val;return s[0]=s[0]*e,s[1]=s[1]*e,s[2]=s[2]*e,s[3]=s[3]*e,s[4]=s[4]*i,s[5]=s[5]*i,s[6]=s[6]*i,s[7]=s[7]*i,s[8]=s[8]*n,s[9]=s[9]*n,s[10]=s[10]*n,s[11]=s[11]*n,this},makeRotationAxis:function(t,e){var i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,a=t.z,h=s*r,l=s*o;return this.fromArray([h*r+i,h*o-n*a,h*a+n*o,0,h*o+n*a,l*o+i,l*a-n*r,0,h*a-n*o,l*a+n*r,s*a*a+i,0,0,0,0,1]),this},rotate:function(t,e){var i=this.val,n=e.x,s=e.y,r=e.z,o=Math.sqrt(n*n+s*s+r*r);if(Math.abs(o)<1e-6)return null;n*=o=1/o,s*=o,r*=o;var a=Math.sin(t),h=Math.cos(t),l=1-h,u=i[0],c=i[1],d=i[2],f=i[3],p=i[4],g=i[5],v=i[6],y=i[7],m=i[8],x=i[9],w=i[10],b=i[11],T=n*n*l+h,S=s*n*l+r*a,_=r*n*l-s*a,A=n*s*l-r*a,C=s*s*l+h,M=r*s*l+n*a,P=n*r*l+s*a,E=s*r*l-n*a,k=r*r*l+h;return i[0]=u*T+p*S+m*_,i[1]=c*T+g*S+x*_,i[2]=d*T+v*S+w*_,i[3]=f*T+y*S+b*_,i[4]=u*A+p*C+m*M,i[5]=c*A+g*C+x*M,i[6]=d*A+v*C+w*M,i[7]=f*A+y*C+b*M,i[8]=u*P+p*E+m*k,i[9]=c*P+g*E+x*k,i[10]=d*P+v*E+w*k,i[11]=f*P+y*E+b*k,this},rotateX:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[4],r=e[5],o=e[6],a=e[7],h=e[8],l=e[9],u=e[10],c=e[11];return e[4]=s*n+h*i,e[5]=r*n+l*i,e[6]=o*n+u*i,e[7]=a*n+c*i,e[8]=h*n-s*i,e[9]=l*n-r*i,e[10]=u*n-o*i,e[11]=c*n-a*i,this},rotateY:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[8],l=e[9],u=e[10],c=e[11];return e[0]=s*n-h*i,e[1]=r*n-l*i,e[2]=o*n-u*i,e[3]=a*n-c*i,e[8]=s*i+h*n,e[9]=r*i+l*n,e[10]=o*i+u*n,e[11]=a*i+c*n,this},rotateZ:function(t){var e=this.val,i=Math.sin(t),n=Math.cos(t),s=e[0],r=e[1],o=e[2],a=e[3],h=e[4],l=e[5],u=e[6],c=e[7];return e[0]=s*n+h*i,e[1]=r*n+l*i,e[2]=o*n+u*i,e[3]=a*n+c*i,e[4]=h*n-s*i,e[5]=l*n-r*i,e[6]=u*n-o*i,e[7]=c*n-a*i,this},fromRotationTranslation:function(t,e){var i=this.val,n=t.x,s=t.y,r=t.z,o=t.w,a=n+n,h=s+s,l=r+r,u=n*a,c=n*h,d=n*l,f=s*h,p=s*l,g=r*l,v=o*a,y=o*h,m=o*l;return i[0]=1-(f+g),i[1]=c+m,i[2]=d-y,i[3]=0,i[4]=c-m,i[5]=1-(u+g),i[6]=p+v,i[7]=0,i[8]=d+y,i[9]=p-v,i[10]=1-(u+f),i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this},fromQuat:function(t){var e=this.val,i=t.x,n=t.y,s=t.z,r=t.w,o=i+i,a=n+n,h=s+s,l=i*o,u=i*a,c=i*h,d=n*a,f=n*h,p=s*h,g=r*o,v=r*a,y=r*h;return e[0]=1-(d+p),e[1]=u+y,e[2]=c-v,e[3]=0,e[4]=u-y,e[5]=1-(l+p),e[6]=f+g,e[7]=0,e[8]=c+v,e[9]=f-g,e[10]=1-(l+d),e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},frustum:function(t,e,i,n,s,r){var o=this.val,a=1/(e-t),h=1/(n-i),l=1/(s-r);return o[0]=2*s*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=2*s*h,o[6]=0,o[7]=0,o[8]=(e+t)*a,o[9]=(n+i)*h,o[10]=(r+s)*l,o[11]=-1,o[12]=0,o[13]=0,o[14]=r*s*2*l,o[15]=0,this},perspective:function(t,e,i,n){var s=this.val,r=1/Math.tan(t/2),o=1/(i-n);return s[0]=r/e,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+i)*o,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*i*o,s[15]=0,this},perspectiveLH:function(t,e,i,n){var s=this.val;return s[0]=2*i/t,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*i/e,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=-n/(i-n),s[11]=1,s[12]=0,s[13]=0,s[14]=i*n/(i-n),s[15]=0,this},ortho:function(t,e,i,n,s,r){var o=this.val,a=t-e,h=i-n,l=s-r;return a=0===a?a:1/a,h=0===h?h:1/h,l=0===l?l:1/l,o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*h,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*l,o[11]=0,o[12]=(t+e)*a,o[13]=(n+i)*h,o[14]=(r+s)*l,o[15]=1,this},lookAt:function(t,e,i){var n=this.val,s=t.x,r=t.y,o=t.z,a=i.x,h=i.y,l=i.z,u=e.x,c=e.y,d=e.z;if(Math.abs(s-u)<1e-6&&Math.abs(r-c)<1e-6&&Math.abs(o-d)<1e-6)return this.identity();var f=s-u,p=r-c,g=o-d,v=1/Math.sqrt(f*f+p*p+g*g),y=h*(g*=v)-l*(p*=v),m=l*(f*=v)-a*g,x=a*p-h*f;(v=Math.sqrt(y*y+m*m+x*x))?(y*=v=1/v,m*=v,x*=v):(y=0,m=0,x=0);var w=p*x-g*m,b=g*y-f*x,T=f*m-p*y;return(v=Math.sqrt(w*w+b*b+T*T))?(w*=v=1/v,b*=v,T*=v):(w=0,b=0,T=0),n[0]=y,n[1]=w,n[2]=f,n[3]=0,n[4]=m,n[5]=b,n[6]=p,n[7]=0,n[8]=x,n[9]=T,n[10]=g,n[11]=0,n[12]=-(y*s+m*r+x*o),n[13]=-(w*s+b*r+T*o),n[14]=-(f*s+p*r+g*o),n[15]=1,this},yawPitchRoll:function(t,e,i){this.zero(),s.zero(),r.zero();var n=this.val,o=s.val,a=r.val,h=Math.sin(i),l=Math.cos(i);return n[10]=1,n[15]=1,n[0]=l,n[1]=h,n[4]=-h,n[5]=l,h=Math.sin(e),l=Math.cos(e),o[0]=1,o[15]=1,o[5]=l,o[10]=l,o[9]=-h,o[6]=h,h=Math.sin(t),l=Math.cos(t),a[5]=1,a[15]=1,a[0]=l,a[2]=-h,a[8]=h,a[10]=l,this.multiplyLocal(s),this.multiplyLocal(r),this},setWorldMatrix:function(t,e,i,n,o){return this.yawPitchRoll(t.y,t.x,t.z),s.scaling(i.x,i.y,i.z),r.xyz(e.x,e.y,e.z),this.multiplyLocal(s),this.multiplyLocal(r),void 0!==n&&this.multiplyLocal(n),void 0!==o&&this.multiplyLocal(o),this}}),s=new n,r=new n;t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var e=this.val,i=t.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this},fromMat4:function(t){var e=t.val,i=this.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[4],i[4]=e[5],i[5]=e[6],i[6]=e[8],i[7]=e[9],i[8]=e[10],this},fromArray:function(t){var e=this.val;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,e=t[1],i=t[2],n=t[5];return t[1]=t[3],t[2]=t[6],t[3]=e,t[5]=t[7],t[6]=i,t[7]=n,this},invert:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8],u=l*r-o*h,c=-l*s+o*a,d=h*s-r*a,f=e*u+i*c+n*d;return f?(f=1/f,t[0]=u*f,t[1]=(-l*i+n*h)*f,t[2]=(o*i-n*r)*f,t[3]=c*f,t[4]=(l*e-n*a)*f,t[5]=(-o*e+n*s)*f,t[6]=d*f,t[7]=(-h*e+i*a)*f,t[8]=(r*e-i*s)*f,this):null},adjoint:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return t[0]=r*l-o*h,t[1]=n*h-i*l,t[2]=i*o-n*r,t[3]=o*a-s*l,t[4]=e*l-n*a,t[5]=n*s-e*o,t[6]=s*h-r*a,t[7]=i*a-e*h,t[8]=e*r-i*s,this},determinant:function(){var t=this.val,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return e*(l*r-o*h)+i*(-l*s+o*a)+n*(h*s-r*a)},multiply:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],u=e[8],c=t.val,d=c[0],f=c[1],p=c[2],g=c[3],v=c[4],y=c[5],m=c[6],x=c[7],w=c[8];return e[0]=d*i+f*r+p*h,e[1]=d*n+f*o+p*l,e[2]=d*s+f*a+p*u,e[3]=g*i+v*r+y*h,e[4]=g*n+v*o+y*l,e[5]=g*s+v*a+y*u,e[6]=m*i+x*r+w*h,e[7]=m*n+x*o+w*l,e[8]=m*s+x*a+w*u,this},translate:function(t){var e=this.val,i=t.x,n=t.y;return e[6]=i*e[0]+n*e[3]+e[6],e[7]=i*e[1]+n*e[4]+e[7],e[8]=i*e[2]+n*e[5]+e[8],this},rotate:function(t){var e=this.val,i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=Math.sin(t),l=Math.cos(t);return e[0]=l*i+h*r,e[1]=l*n+h*o,e[2]=l*s+h*a,e[3]=l*r-h*i,e[4]=l*o-h*n,e[5]=l*a-h*s,this},scale:function(t){var e=this.val,i=t.x,n=t.y;return e[0]=i*e[0],e[1]=i*e[1],e[2]=i*e[2],e[3]=n*e[3],e[4]=n*e[4],e[5]=n*e[5],this},fromQuat:function(t){var e=t.x,i=t.y,n=t.z,s=t.w,r=e+e,o=i+i,a=n+n,h=e*r,l=e*o,u=e*a,c=i*o,d=i*a,f=n*a,p=s*r,g=s*o,v=s*a,y=this.val;return y[0]=1-(c+f),y[3]=l+v,y[6]=u-g,y[1]=l-v,y[4]=1-(h+f),y[7]=d+p,y[2]=u+g,y[5]=d-p,y[8]=1-(h+c),this},normalFromMat4:function(t){var e=t.val,i=this.val,n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=e[6],u=e[7],c=e[8],d=e[9],f=e[10],p=e[11],g=e[12],v=e[13],y=e[14],m=e[15],x=n*h-s*a,w=n*l-r*a,b=n*u-o*a,T=s*l-r*h,S=s*u-o*h,_=r*u-o*l,A=c*v-d*g,C=c*y-f*g,M=c*m-p*g,P=d*y-f*v,E=d*m-p*v,k=f*m-p*y,L=x*k-w*E+b*P+T*M-S*C+_*A;return L?(L=1/L,i[0]=(h*k-l*E+u*P)*L,i[1]=(l*M-a*k-u*C)*L,i[2]=(a*E-h*M+u*A)*L,i[3]=(r*E-s*k-o*P)*L,i[4]=(n*k-r*M+o*C)*L,i[5]=(s*M-n*E-o*A)*L,i[6]=(v*_-y*S+m*T)*L,i[7]=(y*b-g*_-m*w)*L,i[8]=(g*S-v*b+m*x)*L,this):null}});t.exports=n},function(t,e){t.exports=function(t,e){var i=t.x,n=t.y;return t.x=i*Math.cos(e)-n*Math.sin(e),t.y=i*Math.sin(e)+n*Math.cos(e),t}},function(t,e){t.exports=function(t,e,i,n){return void 0===i&&(i=0),0===e?t:(t-=i,t=e*Math.ceil(t/e),n?(i+t)/e:i+t)}},function(t,e){t.exports=function(t){if(0===t)return 1;for(var e=t;--t;)e*=t;return e}},function(t,e,i){var n=i(244);t.exports=function(t,e){return n(t)/n(e)/n(t-e)}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),te-i}},function(t,e){t.exports=function(t,e,i){return void 0===i&&(i=1e-4),Math.abs(t-e)=0?t:t+2*Math.PI}},function(t,e,i){var n=i(0),s=i(18),r=i(21),o=i(7),a=i(2),h=i(8),l=new n({Extends:r,initialize:function(t,e,i,n){var s="txt";if(h(e)){var o=e;e=a(o,"key"),i=a(o,"url"),n=a(o,"xhrSettings"),s=a(o,"extension",s)}var l={type:"text",cache:t.cacheManager.text,extension:s,responseType:"text",key:e,url:i,xhrSettings:n};r.call(this,t,l)},onProcess:function(){this.state=s.FILE_PROCESSING,this.data=this.xhrLoader.responseText,this.onProcessComplete()}});o.register("text",function(t,e,i){if(Array.isArray(t))for(var n=0;n=2&&(this.leftStick.set(r[0].getValue(),r[1].getValue()),s>=4&&this.rightStick.set(r[2].getValue(),r[3].getValue()))},destroy:function(){var t;for(this.removeAllListeners(),this.manager=null,this.pad=null,t=0;t=this.threshold?this.pressed||(this.pressed=!0,this.events.emit("down",e,this,t),this.pad.emit("down",i,t,this)):this.pressed&&(this.pressed=!1,this.events.emit("up",e,this,t),this.pad.emit("up",i,t,this))},destroy:function(){this.pad=null,this.events=null}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.pad=t,this.events=t.events,this.index=e,this.value=0,this.threshold=.1},update:function(t){this.value=t},getValue:function(){return Math.abs(this.value)t.width*t.height)&&e.x>t.x&&e.xt.x&&e.rightt.y&&e.yt.y&&e.bottom0){var d=(a*r+h*o)/l;u*=d,c*=d}return i.x=t.x1+u,i.y=t.y1+c,u*u+c*c<=l&&u*r+c*o>=0&&n(e,i.x,i.y)}},function(t,e,i){t.exports={CircleToCircle:i(703),CircleToRectangle:i(702),GetRectangleIntersection:i(701),LineToCircle:i(272),LineToLine:i(107),LineToRectangle:i(700),PointToLine:i(271),PointToLineSegment:i(699),RectangleToRectangle:i(148),RectangleToTriangle:i(698),RectangleToValues:i(697),TriangleToCircle:i(696),TriangleToLine:i(695),TriangleToTriangle:i(694)}},function(t,e,i){t.exports={Circle:i(723),Ellipse:i(713),Intersects:i(273),Line:i(693),Point:i(675),Polygon:i(661),Rectangle:i(265),Triangle:i(631)}},function(t,e,i){var n=i(0),s=i(276),r=i(10),o=new n({initialize:function(){this.lightPool=[],this.lights=[],this.culledLights=[],this.ambientColor={r:.1,g:.1,b:.1},this.active=!1,this.maxLights=-1},enable:function(){return-1===this.maxLights&&(this.maxLights=this.scene.sys.game.renderer.config.maxLights),this.active=!0,this},disable:function(){return this.active=!1,this},cull:function(t){var e=this.lights,i=this.culledLights,n=e.length,s=t.x+t.width/2,r=t.y+t.height/2,o=(t.width+t.height)/2,a={x:0,y:0},h=t.matrix,l=this.systems.game.config.height;i.length=0;for(var u=0;u0?(h=this.lightPool.pop()).set(t,e,i,a[0],a[1],a[2],o):h=new s(t,e,i,a[0],a[1],a[2],o),this.lights.push(h),h},removeLight:function(t){var e=this.lights.indexOf(t);return e>=0&&(this.lightPool.push(t),this.lights.splice(e,1)),this},shutdown:function(){for(;this.lights.length>0;)this.lightPool.push(this.lights.pop());this.ambientColor={r:.1,g:.1,b:.1},this.culledLights.length=0,this.lights.length=0},destroy:function(){this.shutdown()}});t.exports=o},function(t,e,i){var n=i(0),s=i(10),r=new n({initialize:function(t,e,i,n,s,r,o){this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1},set:function(t,e,i,n,s,r,o){return this.x=t,this.y=e,this.radius=i,this.r=n,this.g=s,this.b=r,this.intensity=o,this.scrollFactorX=1,this.scrollFactorY=1,this},setScrollFactor:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this},setColor:function(t){var e=s.getFloatsFromUintRGB(t);return this.r=e[0],this.g=e[1],this.b=e[2],this},setIntensity:function(t){return this.intensity=t,this},setPosition:function(t,e){return this.x=t,this.y=e,this},setRadius:function(t){return this.radius=t,this}});t.exports=r},function(t,e,i){var n=i(65),s=i(6);t.exports=function(t,e,i,r){void 0===r&&(r=[]);var o=t.getLineA(),a=t.getLineB(),h=t.getLineC(),l=n(o),u=n(a),c=n(h),d=l+u+c;e||(e=d/i);for(var f=0;fl+u?(g=(p-=l+u)/c,v.x=h.x1+(h.x2-h.x1)*g,v.y=h.y1+(h.y2-h.y1)*g):(g=(p-=l)/u,v.x=a.x1+(a.x2-a.x1)*g,v.y=a.y1+(a.y2-a.y1)*g),r.push(v)}return r}},function(t,e,i){var n=i(6),s=i(65);t.exports=function(t,e,i){void 0===i&&(i=new n);var r=t.getLineA(),o=t.getLineB(),a=t.getLineC();if(e<=0||e>=1)return i.x=r.x1,i.y=r.y1,i;var h=s(r),l=s(o),u=s(a),c=(h+l+u)*e,d=0;return ch+l?(d=(c-=h+l)/u,i.x=a.x1+(a.x2-a.x1)*d,i.y=a.y1+(a.y2-a.y1)*d):(d=(c-=h)/l,i.x=o.x1+(o.x2-o.x1)*d,i.y=o.y1+(o.y2-o.y1)*d),i}},function(t,e,i){var n=i(0),s=i(27),r=i(59),o=i(772),a=new n({Extends:s,Mixins:[o],initialize:function(t,e,i,n,o,a,h,l,u,c,d){void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=128),void 0===a&&(a=64),void 0===h&&(h=0),void 0===l&&(l=128),void 0===u&&(u=128),s.call(this,t,"Triangle",new r(n,o,a,h,l,u));var f=this.geom.right-this.geom.left,p=this.geom.bottom-this.geom.top;this.setPosition(e,i),this.setSize(f,p),void 0!==c&&this.setFillStyle(c,d),this.updateDisplayOrigin(),this.updateData()},setTo:function(t,e,i,n,s,r){return this.geom.setTo(t,e,i,n,s,r),this.updateData()},updateData:function(){var t=[],e=this.geom,i=this._tempLine;return e.getLineA(i),t.push(i.x1,i.y1,i.x2,i.y2),e.getLineB(i),t.push(i.x2,i.y2),e.getLineC(i),t.push(i.x2,i.y2),this.pathData=t,this}});t.exports=a},function(t,e,i){var n=i(775),s=i(0),r=i(64),o=i(27),a=new s({Extends:o,Mixins:[n],initialize:function(t,e,i,n,s,r,a,h){void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=5),void 0===s&&(s=32),void 0===r&&(r=64),o.call(this,t,"Star",null),this._points=n,this._innerRadius=s,this._outerRadius=r,this.setPosition(e,i),this.setSize(2*r,2*r),void 0!==a&&this.setFillStyle(a,h),this.updateDisplayOrigin(),this.updateData()},setPoints:function(t){return this._points=t,this.updateData()},setInnerRadius:function(t){return this._innerRadius=t,this.updateData()},setOuterRadius:function(t){return this._outerRadius=t,this.updateData()},points:{get:function(){return this._points},set:function(t){this._points=t,this.updateData()}},innerRadius:{get:function(){return this._innerRadius},set:function(t){this._innerRadius=t,this.updateData()}},outerRadius:{get:function(){return this._outerRadius},set:function(t){this._outerRadius=t,this.updateData()}},updateData:function(){var t=[],e=this._points,i=this._innerRadius,n=this._outerRadius,s=Math.PI/2*3,o=Math.PI/e,a=n,h=n;t.push(a,h+-n);for(var l=0;l0&&r.push(i([0,0],n[0])),e=0;e1&&r.push(i([0,0],n[n.length-1])),t.setTo(r)}},function(t,e,i){var n=i(65),s=i(54);t.exports=function(t){for(var e=t.points,i=0,r=0;rc+v)){var y=g.getPoint((u-c)/v);o.push(y);break}c+=v}return o}},function(t,e,i){var n=i(9);t.exports=function(t,e){void 0===e&&(e=new n);for(var i,s=1/0,r=1/0,o=-s,a=-r,h=0;h0&&(s=-h.PI2+s%h.PI2):s>h.PI2?s=h.PI2:s<0&&(s=h.PI2+s%h.PI2);for(var u,c=[a+Math.cos(n)*i,l+Math.sin(n)*i];e<1;)u=s*e+n,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),e+=t;return u=s+n,c.push(a+Math.cos(u)*i,l+Math.sin(u)*i),c.push(a+Math.cos(n)*i,l+Math.sin(n)*i),this.pathIndexes=o(c),this.pathData=c,this}});t.exports=u},function(t,e){t.exports=function(t){var e=Math.log(t)/.6931471805599453;return 1<this._length&&(this.counter=this._length-1),this},changeSource:function(t){return this.source=t,this.updateSource()},getPoint:function(t){0===this._direction?(this.counter++,this.counter>=this._length&&(this.yoyo?(this._direction=1,this.counter=this._length-1):this.counter=0)):(this.counter--,-1===this.counter&&(this.yoyo?(this._direction=0,this.counter=0):this.counter=this._length-1));var e=this.points[this.counter];e&&(t.x=e.x,t.y=e.y)}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.source=t,this.killOnEnter=e},willKill:function(t){var e=this.source.contains(t.x,t.y);return e&&this.killOnEnter||!e&&!this.killOnEnter}});t.exports=n},function(t,e,i){var n=i(66),s=i(0),r=i(14),o=i(301),a=i(300),h=i(822),l=i(2),u=i(162),c=i(298),d=i(85),f=i(303),p=i(297),g=i(9),v=i(110),y=i(3),m=i(53),x=new s({Mixins:[r.BlendMode,r.Mask,r.ScrollFactor,r.Visible],initialize:function(t,e){this.manager=t,this.texture=t.texture,this.frames=[t.defaultFrame],this.defaultFrame=t.defaultFrame,this.configFastMap=["active","blendMode","collideBottom","collideLeft","collideRight","collideTop","deathCallback","deathCallbackScope","emitCallback","emitCallbackScope","follow","frequency","gravityX","gravityY","maxParticles","name","on","particleBringToTop","particleClass","radial","timeScale","trackVisible","visible"],this.configOpMap=["accelerationX","accelerationY","angle","alpha","bounce","delay","lifespan","maxVelocityX","maxVelocityY","moveToX","moveToY","quantity","rotate","scaleX","scaleY","speedX","speedY","tint","x","y"],this.name="",this.particleClass=f,this.x=new h(e,"x",0),this.y=new h(e,"y",0),this.radial=!0,this.gravityX=0,this.gravityY=0,this.acceleration=!1,this.accelerationX=new h(e,"accelerationX",0,!0),this.accelerationY=new h(e,"accelerationY",0,!0),this.maxVelocityX=new h(e,"maxVelocityX",1e4,!0),this.maxVelocityY=new h(e,"maxVelocityY",1e4,!0),this.speedX=new h(e,"speedX",0,!0),this.speedY=new h(e,"speedY",0,!0),this.moveTo=!1,this.moveToX=new h(e,"moveToX",0,!0),this.moveToY=new h(e,"moveToY",0,!0),this.bounce=new h(e,"bounce",0,!0),this.scaleX=new h(e,"scaleX",1),this.scaleY=new h(e,"scaleY",1),this.tint=new h(e,"tint",4294967295),this.alpha=new h(e,"alpha",1),this.lifespan=new h(e,"lifespan",1e3),this.angle=new h(e,"angle",{min:0,max:360}),this.rotate=new h(e,"rotate",0),this.emitCallback=null,this.emitCallbackScope=null,this.deathCallback=null,this.deathCallbackScope=null,this.maxParticles=0,this.quantity=new h(e,"quantity",1,!0),this.delay=new h(e,"delay",0,!0),this.frequency=0,this.on=!0,this.particleBringToTop=!0,this.timeScale=1,this.emitZone=null,this.deathZone=null,this.bounds=null,this.collideLeft=!0,this.collideRight=!0,this.collideTop=!0,this.collideBottom=!0,this.active=!0,this.visible=!0,this.blendMode=n.NORMAL,this.follow=null,this.followOffset=new y,this.trackVisible=!1,this.currentFrame=0,this.randomFrame=!0,this.frameQuantity=1,this.dead=[],this.alive=[],this._counter=0,this._frameCounter=0,e&&this.fromJSON(e)},fromJSON:function(t){if(!t)return this;var e=0,i="";for(e=0;e0&&this.getParticleCount()===this.maxParticles},onParticleEmit:function(t,e){return void 0===t?(this.emitCallback=null,this.emitCallbackScope=null):"function"==typeof t&&(this.emitCallback=t,e&&(this.emitCallbackScope=e)),this},onParticleDeath:function(t,e){return void 0===t?(this.deathCallback=null,this.deathCallbackScope=null):"function"==typeof t&&(this.deathCallback=t,e&&(this.deathCallbackScope=e)),this},killAll:function(){for(var t=this.dead,e=this.alive;e.length>0;)t.push(e.pop());return this},forEachAlive:function(t,e){for(var i=this.alive,n=i.length,s=0;s0?n.pop():new this.particleClass(this)).fire(e,i),this.particleBringToTop?this.alive.push(r):this.alive.unshift(r),this.emitCallback&&this.emitCallback.call(this.emitCallbackScope,r,this),this.atLimit())break}return r}},preUpdate:function(t,e){var i=(e*=this.timeScale)/1e3;this.trackVisible&&(this.visible=this.follow.visible);for(var n=this.manager.getProcessors(),s=this.alive,r=s.length,o=0;o0){var u=s.splice(s.length-l,l),c=this.deathCallback,d=this.deathCallbackScope;if(c)for(var f=0;f0&&(this._counter-=e,this._counter<=0&&(this.emitParticle(),this._counter=this.frequency-Math.abs(this._counter))))},depthSortCallback:function(t,e){return t.y-e.y},indexSortCallback:function(t,e){return t.index-e.index}});t.exports=x},function(t,e,i){var n=i(0),s=i(31),r=i(52),o=new n({initialize:function(t){this.emitter=t,this.frame=null,this.index=0,this.x=0,this.y=0,this.velocityX=0,this.velocityY=0,this.accelerationX=0,this.accelerationY=0,this.maxVelocityX=1e4,this.maxVelocityY=1e4,this.bounce=0,this.scaleX=1,this.scaleY=1,this.alpha=1,this.angle=0,this.rotation=0,this.tint=16777215,this.life=1e3,this.lifeCurrent=1e3,this.delayCurrent=0,this.lifeT=0,this.data={tint:{min:16777215,max:16777215,current:16777215},alpha:{min:1,max:1},rotate:{min:0,max:0},scaleX:{min:1,max:1},scaleY:{min:1,max:1}}},isAlive:function(){return this.lifeCurrent>0},fire:function(t,e){var i=this.emitter;this.frame=i.getFrame(),i.emitZone&&i.emitZone.getPoint(this),void 0===t?(i.follow&&(this.x+=i.follow.x+i.followOffset.x),this.x+=i.x.onEmit(this,"x")):this.x+=t,void 0===e?(i.follow&&(this.y+=i.follow.y+i.followOffset.y),this.y+=i.y.onEmit(this,"y")):this.y+=e,this.life=i.lifespan.onEmit(this,"lifespan"),this.lifeCurrent=this.life,this.lifeT=0;var n=i.speedX.onEmit(this,"speedX"),o=i.speedY?i.speedY.onEmit(this,"speedY"):n;if(i.radial){var a=s(i.angle.onEmit(this,"angle"));this.velocityX=Math.cos(a)*Math.abs(n),this.velocityY=Math.sin(a)*Math.abs(o)}else if(i.moveTo){var h=i.moveToX.onEmit(this,"moveToX"),l=i.moveToY?i.moveToY.onEmit(this,"moveToY"):h,u=Math.atan2(l-this.y,h-this.x),c=r(this.x,this.y,h,l)/(this.life/1e3);this.velocityX=Math.cos(u)*c,this.velocityY=Math.sin(u)*c}else this.velocityX=n,this.velocityY=o;i.acceleration&&(this.accelerationX=i.accelerationX.onEmit(this,"accelerationX"),this.accelerationY=i.accelerationY.onEmit(this,"accelerationY")),this.maxVelocityX=i.maxVelocityX.onEmit(this,"maxVelocityX"),this.maxVelocityY=i.maxVelocityY.onEmit(this,"maxVelocityY"),this.delayCurrent=i.delay.onEmit(this,"delay"),this.scaleX=i.scaleX.onEmit(this,"scaleX"),this.scaleY=i.scaleY?i.scaleY.onEmit(this,"scaleY"):this.scaleX,this.angle=i.rotate.onEmit(this,"rotate"),this.rotation=s(this.angle),this.bounce=i.bounce.onEmit(this,"bounce"),this.alpha=i.alpha.onEmit(this,"alpha"),this.tint=i.tint.onEmit(this,"tint"),this.index=i.alive.length},computeVelocity:function(t,e,i,n){var s=this.velocityX,r=this.velocityY,o=this.accelerationX,a=this.accelerationY,h=this.maxVelocityX,l=this.maxVelocityY;s+=t.gravityX*i,r+=t.gravityY*i,o&&(s+=o*i),a&&(r+=a*i),s>h?s=h:s<-h&&(s=-h),r>l?r=l:r<-l&&(r=-l),this.velocityX=s,this.velocityY=r;for(var u=0;ue.right&&t.collideRight&&(this.x=e.right,this.velocityX*=i),this.ye.bottom&&t.collideBottom&&(this.y=e.bottom,this.velocityY*=i)},update:function(t,e,i){if(this.delayCurrent>0)return this.delayCurrent-=t,!1;var n=this.emitter,r=1-this.lifeCurrent/this.life;return this.lifeT=r,this.computeVelocity(n,t,e,i),this.x+=this.velocityX*e,this.y+=this.velocityY*e,n.bounds&&this.checkBounds(n),n.deathZone&&n.deathZone.willKill(this)?(this.lifeCurrent=0,!0):(this.scaleX=n.scaleX.onUpdate(this,"scaleX",r,this.scaleX),n.scaleY?this.scaleY=n.scaleY.onUpdate(this,"scaleY",r,this.scaleY):this.scaleY=this.scaleX,this.angle=n.rotate.onUpdate(this,"rotate",r,this.angle),this.rotation=s(this.angle),this.alpha=n.alpha.onUpdate(this,"alpha",r,this.alpha),this.tint=n.tint.onUpdate(this,"tint",r,this.tint),this.lifeCurrent-=t,this.lifeCurrent<=0)}});t.exports=o},function(t,e,i){var n=i(0),s=i(2),r=new n({initialize:function(t,e,i,n,r){if("object"==typeof t){var o=t;t=s(o,"x",0),e=s(o,"y",0),i=s(o,"power",0),n=s(o,"epsilon",100),r=s(o,"gravity",50)}else void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=50);this.x=t,this.y=e,this.active=!0,this._gravity=r,this._power=0,this._epsilon=0,this.power=i,this.epsilon=n},update:function(t,e){var i=this.x-t.x,n=this.y-t.y,s=i*i+n*n;if(0!==s){var r=Math.sqrt(s);s>>16,m=(65280&p)>>>8,x=255&p,c.strokeStyle="rgba("+y+","+m+","+x+","+d+")",c.lineWidth=v,w+=3;break;case n.FILL_STYLE:g=l[w+1],f=l[w+2],y=(16711680&g)>>>16,m=(65280&g)>>>8,x=255&g,c.fillStyle="rgba("+y+","+m+","+x+","+f+")",w+=2;break;case n.BEGIN_PATH:c.beginPath();break;case n.CLOSE_PATH:c.closePath();break;case n.FILL_PATH:h||c.fill();break;case n.STROKE_PATH:h||c.stroke();break;case n.FILL_RECT:h?c.rect(l[w+1],l[w+2],l[w+3],l[w+4]):c.fillRect(l[w+1],l[w+2],l[w+3],l[w+4]),w+=4;break;case n.FILL_TRIANGLE:c.beginPath(),c.moveTo(l[w+1],l[w+2]),c.lineTo(l[w+3],l[w+4]),c.lineTo(l[w+5],l[w+6]),c.closePath(),h||c.fill(),w+=6;break;case n.STROKE_TRIANGLE:c.beginPath(),c.moveTo(l[w+1],l[w+2]),c.lineTo(l[w+3],l[w+4]),c.lineTo(l[w+5],l[w+6]),c.closePath(),h||c.stroke(),w+=6;break;case n.LINE_TO:c.lineTo(l[w+1],l[w+2]),w+=2;break;case n.MOVE_TO:c.moveTo(l[w+1],l[w+2]),w+=2;break;case n.LINE_FX_TO:c.lineTo(l[w+1],l[w+2]),w+=5;break;case n.MOVE_FX_TO:c.moveTo(l[w+1],l[w+2]),w+=5;break;case n.SAVE:c.save();break;case n.RESTORE:c.restore();break;case n.TRANSLATE:c.translate(l[w+1],l[w+2]),w+=2;break;case n.SCALE:c.scale(l[w+1],l[w+2]),w+=2;break;case n.ROTATE:c.rotate(l[w+1]),w+=1;break;case n.GRADIENT_FILL_STYLE:w+=5;break;case n.GRADIENT_LINE_STYLE:w+=6;break;case n.SET_TEXTURE:w+=2}c.restore()}}},function(t,e){t.exports=function(t){var e=t.width/2,i=t.height/2,n=Math.pow(e-i,2)/Math.pow(e+i,2);return Math.PI*(e+i)*(1+3*n/(10+Math.sqrt(4-3*n)))}},function(t,e,i){var n=i(306),s=i(156),r=i(93),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;h0?s.delayedPlay(d,r,o):s.load(r)}return t}},function(t,e,i){var n=i(4),s=i(122),r=function(t,e,i){for(var n=[],s=0;sr;){if(o-r>600){var h=o-r+1,l=e-r+1,u=Math.log(h),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(h-c)/h)*(l-h/2<0?-1:1),f=Math.max(r,Math.floor(e-l*c/h+d)),p=Math.min(o,Math.floor(e+(h-l)*c/h+d));i(t,e,f,p,a)}var g=t[e],v=r,y=o;for(n(t,r,e),a(t[o],g)>0&&n(t,r,o);v0;)y--}0===a(t[r],g)?n(t,r,y):n(t,++y,o),y<=e&&(r=y+1),e<=y&&(o=y-1)}};function n(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function s(t,e){return te?1:0}t.exports=i},function(t,e){t.exports=function(t){return t>0?Math.ceil(t):Math.floor(t)}},function(t,e){t.exports=function(t){for(var e=t.length,i=t[0].length,n=new Array(i),s=0;s-1;r--)n[s][r]=t[r][s]}return n}},function(t,e,i){t.exports={AtlasXML:i(886),Canvas:i(885),Image:i(884),JSONArray:i(883),JSONHash:i(882),SpriteSheet:i(881),SpriteSheetFromAtlas:i(880),UnityYAML:i(879)}},function(t,e,i){var n=i(24),s=i(0),r=i(117),o=i(94),a=new s({initialize:function(t,e,i,n){var s=t.manager.game;this.renderer=s.renderer,this.texture=t,this.source=e,this.image=e,this.compressionAlgorithm=null,this.resolution=1,this.width=i||e.naturalWidth||e.width||0,this.height=n||e.naturalHeight||e.height||0,this.scaleMode=o.DEFAULT,this.isCanvas=e instanceof HTMLCanvasElement,this.isRenderTexture="RenderTexture"===e.type,this.isPowerOf2=r(this.width,this.height),this.glTexture=null,this.init(s)},init:function(t){this.renderer&&(this.renderer.gl?this.isCanvas?this.glTexture=this.renderer.canvasToTexture(this.image):this.isRenderTexture?(this.image=this.source.canvas,this.glTexture=this.renderer.createTextureFromSource(null,this.width,this.height,this.scaleMode)):this.glTexture=this.renderer.createTextureFromSource(this.image,this.width,this.height,this.scaleMode):this.isRenderTexture&&(this.image=this.source.canvas)),t.config.antialias||this.setFilter(1)},setFilter:function(t){this.renderer.gl&&this.renderer.setTextureFilter(this.glTexture,t)},update:function(){this.renderer.gl&&this.isCanvas&&(this.glTexture=this.renderer.canvasToTexture(this.image,this.glTexture))},destroy:function(){this.glTexture&&this.renderer.deleteTexture(this.glTexture),this.isCanvas&&n.remove(this.image),this.renderer=null,this.texture=null,this.source=null,this.image=null,this.glTexture=null}});t.exports=a},function(t,e,i){var n=i(24),s=i(887),r=i(0),o=i(37),a=i(26),h=i(11),l=i(357),u=i(4),c=i(316),d=i(165),f=new r({Extends:h,initialize:function(t){h.call(this),this.game=t,this.name="TextureManager",this.list={},this._tempCanvas=n.create2D(this,1,1),this._tempContext=this._tempCanvas.getContext("2d"),this._pending=0,t.events.once("boot",this.boot,this)},boot:function(){this._pending=2,this.on("onload",this.updatePending,this),this.on("onerror",this.updatePending,this),this.addBase64("__DEFAULT",this.game.config.defaultImage),this.addBase64("__MISSING",this.game.config.missingImage),this.game.events.once("destroy",this.destroy,this)},updatePending:function(){this._pending--,0===this._pending&&(this.off("onload"),this.off("onerror"),this.game.events.emit("texturesready"))},checkKey:function(t){return!this.exists(t)||(console.error("Texture key already in use: "+t),!1)},remove:function(t){if("string"==typeof t){if(!this.exists(t))return console.warn("No texture found matching key: "+t),this;t=this.get(t)}return this.list.hasOwnProperty(t.key)&&(delete this.list[t.key],t.destroy(),this.emit("removetexture",t.key)),this},addBase64:function(t,e){if(this.checkKey(t)){var i=this,n=new Image;n.onerror=function(){i.emit("onerror",t)},n.onload=function(){var e=i.create(t,n);c.Image(e,0),i.emit("addtexture",t,e),i.emit("onload",t,e)},n.src=e}return this},getBase64:function(t,e,i,s){void 0===i&&(i="image/png"),void 0===s&&(s=.92);var r="",o=this.getFrame(t,e);if(o){var a=o.canvasData,h=n.create2D(this,a.width,a.height);h.getContext("2d").drawImage(o.source.image,a.x,a.y,a.width,a.height,0,0,a.width,a.height),r=h.toDataURL(i,s),n.remove(h)}return r},addImage:function(t,e,i){var n=null;return this.checkKey(t)&&(n=this.create(t,e),c.Image(n,0),i&&n.setDataSource(i),this.emit("addtexture",t,n)),n},addRenderTexture:function(t,e){var i=null;return this.checkKey(t)&&((i=this.create(t,e)).add("__BASE",0,0,0,e.width,e.height),this.emit("addtexture",t,i)),i},generate:function(t,e){if(this.checkKey(t)){var i=n.create(this,1,1);return e.canvas=i,l(e),this.addCanvas(t,i)}return null},createCanvas:function(t,e,i){if(void 0===e&&(e=256),void 0===i&&(i=256),this.checkKey(t)){var s=n.create(this,e,i,a.CANVAS,!0);return this.addCanvas(t,s)}return null},addCanvas:function(t,e,i){void 0===i&&(i=!1);var n=null;return i?n=new s(this,t,e,e.width,e.height):this.checkKey(t)&&(n=new s(this,t,e,e.width,e.height),this.list[t]=n,this.emit("addtexture",t,n)),n},addAtlas:function(t,e,i,n){return Array.isArray(i.textures)||Array.isArray(i.frames)?this.addAtlasJSONArray(t,e,i,n):this.addAtlasJSONHash(t,e,i,n)},addAtlasJSONArray:function(t,e,i,n){var s=null;if(this.checkKey(t)){if(s=this.create(t,e),Array.isArray(i))for(var r=1===i.length,o=0;o=r.x&&t=r.y&&e=r.x&&t=r.y&&e0)&&(!!n.prototype.pause.call(this)&&(this.currentConfig.seek=this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0),this.stopAndReleaseAudioTag(),this.emit("pause",this),!0)))},resume:function(){return!this.manager.isLocked(this,"resume")&&(!(this.startTime>0)&&(!!n.prototype.resume.call(this)&&(!!this.pickAndPlayAudioTag()&&(this.emit("resume",this),!0))))},stop:function(){return!this.manager.isLocked(this,"stop")&&(!!n.prototype.stop.call(this)&&(this.stopAndReleaseAudioTag(),this.emit("stop",this),!0))},pickAndPlayAudioTag:function(){if(!this.pickAudioTag())return this.reset(),!1;var t=this.currentConfig.seek,e=this.currentConfig.delay,i=(this.currentMarker?this.currentMarker.start:0)+t;return this.previousTime=i,this.audio.currentTime=i,this.applyConfig(),0===e?(this.startTime=0,this.audio.paused&&this.playCatchPromise()):(this.startTime=window.performance.now()+1e3*e,this.audio.paused||this.audio.pause()),this.resetConfig(),!0},pickAudioTag:function(){if(this.audio)return!0;for(var t=0;t0)this.startTime=n-this.manager.loopEndOffset?(this.audio.currentTime=i+Math.max(0,s-n),s=this.audio.currentTime):s=n)return this.reset(),this.stopAndReleaseAudioTag(),void this.emit("ended",this);this.previousTime=s}},destroy:function(){n.prototype.destroy.call(this),this.tags=null,this.audio&&this.stopAndReleaseAudioTag()},updateMute:function(){this.audio&&(this.audio.muted=this.currentConfig.mute||this.manager.mute)},updateVolume:function(){this.audio&&(this.audio.volume=this.currentConfig.volume*this.manager.volume)},calculateRate:function(){n.prototype.calculateRate.call(this),this.audio&&(this.audio.playbackRate=this.totalRate)},mute:{get:function(){return this.currentConfig.mute},set:function(t){this.currentConfig.mute=t,this.manager.isLocked(this,"mute",t)||this.emit("mute",this,t)}},setMute:function(t){return this.mute=t,this},volume:{get:function(){return this.currentConfig.volume},set:function(t){this.currentConfig.volume=t,this.manager.isLocked(this,"volume",t)||this.emit("volume",this,t)}},setVolume:function(t){return this.volume=t,this},rate:{get:function(){return this.currentConfig.rate},set:function(t){this.currentConfig.rate=t,this.manager.isLocked(this,"rate",t)||(this.calculateRate(),this.emit("rate",this,t))}},setRate:function(t){return this.rate=t,this},detune:{get:function(){return this.currentConfig.detune},set:function(t){this.currentConfig.detune=t,this.manager.isLocked(this,"detune",t)||(this.calculateRate(),this.emit("detune",this,t))}},setDetune:function(t){return this.detune=t,this},seek:{get:function(){return this.isPlaying?this.audio.currentTime-(this.currentMarker?this.currentMarker.start:0):this.isPaused?this.currentConfig.seek:0},set:function(t){this.manager.isLocked(this,"seek",t)||this.startTime>0||(this.isPlaying||this.isPaused)&&(t=Math.min(Math.max(0,t),this.duration),this.isPlaying?(this.previousTime=t,this.audio.currentTime=t):this.isPaused&&(this.currentConfig.seek=t),this.emit("seek",this,t))}},setSeek:function(t){return this.seek=t,this},loop:{get:function(){return this.currentConfig.loop},set:function(t){this.currentConfig.loop=t,this.manager.isLocked(this,"loop",t)||(this.audio&&(this.audio.loop=t),this.emit("loop",this,t))}},setLoop:function(t){return this.loop=t,this}});t.exports=s},function(t,e,i){var n=i(115),s=i(0),r=i(323),o=new s({Extends:n,initialize:function(t){this.override=!0,this.audioPlayDelay=.1,this.loopEndOffset=.05,this.onBlurPausedSounds=[],this.locked="ontouchstart"in window,this.lockedActionsQueue=this.locked?[]:null,this._mute=!1,this._volume=1,n.call(this,t)},add:function(t,e){var i=new r(this,t,e);return this.sounds.push(i),i},unlock:function(){this.locked=!1;var t=this;if(this.game.cache.audio.entries.each(function(e,i){for(var n=0;n-1&&(delete this.keys[n],this.scenes.splice(i,1),this._start.indexOf(n)>-1&&(i=this._start.indexOf(n),this._start.splice(i,1)),e.sys.destroy())}return this},bootScene:function(t){var e,i=t.sys,n=i.settings;t.init&&(t.init.call(t,n.data),n.status=s.INIT,n.isTransition&&i.events.emit("transitioninit",n.transitionFrom,n.transitionDuration)),i.load&&(e=i.load).reset(),e&&t.preload?(t.preload.call(t),0===e.list.size?this.create(t):(n.status=s.LOADING,e.once("complete",this.loadComplete,this),e.start())):this.create(t)},loadComplete:function(t){var e=t.scene;this.game.sound.onBlurPausedSounds&&this.game.sound.unlock(),this.create(e)},payloadComplete:function(t){this.bootScene(t.scene)},update:function(t,e){this.processQueue(),this.isProcessing=!0;for(var i=this.scenes.length-1;i>=0;i--){var n=this.scenes[i].sys;n.settings.status>s.START&&n.settings.status<=s.RUNNING&&n.step(t,e)}},resize:function(t,e){for(var i=0;i=s.LOADING&&i.settings.status0){var i=this.getScene(t);this.scenes.splice(e,1),this.scenes.unshift(i)}}return this},moveDown:function(t){if(this.isProcessing)this._queue.push({op:"moveDown",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e>0){var i=e-1,n=this.getScene(t),s=this.getAt(i);this.scenes[e]=s,this.scenes[i]=n}}return this},moveUp:function(t){if(this.isProcessing)this._queue.push({op:"moveUp",keyA:t,keyB:null});else{var e=this.getIndex(t);if(e=0;){var a=e[o];-1!==(r=t.indexOf(a))?(n(t,r),i&&i.call(s,a)):e.pop(),o--}return e}},function(t,e,i){var n=i(0),s=i(11),r=i(7),o=i(13),a=i(5),h=i(2),l=i(15),u=i(330),c=new n({Extends:s,initialize:function(t){s.call(this),this.game=t,this.plugins=[],this.scenePlugins=[],this._pendingGlobal=[],this._pendingScene=[],t.isBooted?this.boot():t.events.once("boot",this.boot,this)},boot:function(){var t,e,i,n,s,r,o,a=this.game.config,l=a.installGlobalPlugins;for(l=l.concat(this._pendingGlobal),t=0;t10&&(t=10-this.pointersTotal);for(var i=0;i0},queueTouchStart:function(t){if(this.queue.push(s.TOUCH_START,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueTouchMove:function(t){if(this.queue.push(s.TOUCH_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueTouchEnd:function(t){if(this.queue.push(s.TOUCH_END,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},queueTouchCancel:function(t){this.queue.push(s.TOUCH_CANCEL,t)},queueMouseDown:function(t){if(this.queue.push(s.MOUSE_DOWN,t),this._hasDownCallback){var e=this.domCallbacks;this._hasDownCallback=this.processDomCallbacks(e.downOnce,e.down,t)}},queueMouseMove:function(t){if(this.queue.push(s.MOUSE_MOVE,t),this._hasMoveCallback){var e=this.domCallbacks;this._hasMoveCallback=this.processDomCallbacks(e.moveOnce,e.move,t)}},queueMouseUp:function(t){if(this.queue.push(s.MOUSE_UP,t),this._hasUpCallback){var e=this.domCallbacks;this._hasUpCallback=this.processDomCallbacks(e.upOnce,e.up,t)}},addUpCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.upOnce.push(t):this.domCallbacks.up.push(t),this._hasUpCallback=!0,this},addDownCallback:function(t,e){return void 0===e&&(e=!0),e?this.domCallbacks.downOnce.push(t):this.domCallbacks.down.push(t),this._hasDownCallback=!0,this},addMoveCallback:function(t,e){return void 0===e&&(e=!1),e?this.domCallbacks.moveOnce.push(t):this.domCallbacks.move.push(t),this._hasMoveCallback=!0,this},inputCandidate:function(t,e){var i=t.input;if(!i||!i.enabled||!t.willRender(e))return!1;var n=!0,s=t.parentContainer;if(s)do{if(!s.willRender(e)){n=!1;break}s=s.parentContainer}while(s);return n},hitTest:function(t,e,i,n){void 0===n&&(n=this._tempHitTest);var s=this._tempPoint,r=i.scrollX,o=i.scrollY;n.length=0;var a=t.x,h=t.y;1!==i.resolution&&(a+=i._x,h+=i._y),i.getWorldPoint(a,h,s),t.worldX=s.x,t.worldY=s.y;for(var l={x:0,y:0},u=this._tempMatrix,d=this._tempMatrix2,f=0;f1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t}},function(t,e){t.exports=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e}},function(t,e,i){var n=i(37);n.ColorToRGBA=i(915),n.ComponentToHex=i(346),n.GetColor=i(177),n.GetColor32=i(376),n.HexStringToColor=i(377),n.HSLToColor=i(914),n.HSVColorWheel=i(913),n.HSVToRGB=i(176),n.HueToComponent=i(345),n.IntegerToColor=i(374),n.IntegerToRGB=i(373),n.Interpolate=i(912),n.ObjectToColor=i(372),n.RandomRGB=i(911),n.RGBStringToColor=i(371),n.RGBToHSV=i(375),n.RGBToString=i(910),n.ValueToColor=i(178),t.exports=n},function(t,e){t.exports={setCrisp:function(t){return["optimizeSpeed","crisp-edges","-moz-crisp-edges","-webkit-optimize-contrast","optimize-contrast","pixelated"].forEach(function(e){t.style["image-rendering"]=e}),t.style.msInterpolationMode="nearest-neighbor",t},setBicubic:function(t){return t.style["image-rendering"]="auto",t.style.msInterpolationMode="bicubic",t}}},function(t,e,i){var n=i(171),s=i(0),r=i(70),o=i(3),a=new s({Extends:r,initialize:function(t){void 0===t&&(t=[]),r.call(this,"SplineCurve"),this.points=[],this.addPoints(t)},addPoints:function(t){for(var e=0;ei.length-2?i.length-1:r+1],c=i[r>i.length-3?i.length-1:r+2];return e.set(n(a,h.x,l.x,u.x,c.x),n(a,h.y,l.y,u.y,c.y))},toJSON:function(){for(var t=[],e=0;ei;)n-=i;n16777215?{a:t>>>24,r:t>>16&255,g:t>>8&255,b:255&t}:{a:255,r:t>>16&255,g:t>>8&255,b:255&t}}},function(t,e,i){var n=i(37),s=i(373);t.exports=function(t){var e=s(t);return new n(e.r,e.g,e.b,e.a)}},function(t,e){t.exports=function(t,e,i,n){void 0===n&&(n={h:0,s:0,v:0}),t/=255,e/=255,i/=255;var s=Math.min(t,e,i),r=Math.max(t,e,i),o=r-s,a=0,h=0===r?0:o/r,l=r;return r!==s&&(r===t?a=(e-i)/o+(ef.right&&(p=u(p,p+(v-f.right),this.lerp.x)),yf.bottom&&(g=u(g,g+(y-f.bottom),this.lerp.y))):(p=u(p,v-l,this.lerp.x),g=u(g,y-c,this.lerp.y))}this.useBounds&&(p=this.clampX(p),g=this.clampY(g)),this.roundPixels&&(l=Math.round(l),c=Math.round(c)),this.scrollX=p,this.scrollY=g;var m=p+s,x=g+o;this.midPoint.set(m,x);var w=i/a,b=n/a;this.worldView.setTo(m-w/2,x-b/2,w,b),h.loadIdentity(),h.scale(e,e),h.translate(this.x+l,this.y+c),h.rotate(this.rotation),h.scale(a,a),h.translate(-l,-c),this.shakeEffect.preRender()},setLerp:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.lerp.set(t,e),this},setFollowOffset:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.followOffset.set(t,e),this},startFollow:function(t,e,i,n,s,r){void 0===e&&(e=!1),void 0===i&&(i=1),void 0===n&&(n=i),void 0===s&&(s=0),void 0===r&&(r=s),this._follow=t,this.roundPixels=e,i=o(i,0,1),n=o(n,0,1),this.lerp.set(i,n),this.followOffset.set(s,r);var a=this.width/2,h=this.height/2,l=t.x-s,u=t.y-r;return this.midPoint.set(l,u),this.scrollX=l-a,this.scrollY=u-h,this},stopFollow:function(){return this._follow=null,this},resetFX:function(){return this.panEffect.reset(),this.shakeEffect.reset(),this.flashEffect.reset(),this.fadeEffect.reset(),this},update:function(t,e){this.visible&&(this.panEffect.update(t,e),this.zoomEffect.update(t,e),this.shakeEffect.update(t,e),this.flashEffect.update(t,e),this.fadeEffect.update(t,e))},destroy:function(){this.clearRenderToTexture(),this.resetFX(),n.prototype.destroy.call(this),this._follow=null,this.deadzone=null}});t.exports=f},function(t,e,i){var n=i(380),s=new(i(0))({initialize:function(t){this.game=t,this.binary=new n,this.bitmapFont=new n,this.json=new n,this.physics=new n,this.shader=new n,this.audio=new n,this.text=new n,this.html=new n,this.obj=new n,this.tilemap=new n,this.xml=new n,this.custom={},this.game.events.once("destroy",this.destroy,this)},addCustom:function(t){return this.custom.hasOwnProperty(t)||(this.custom[t]=new n),this.custom[t]},destroy:function(){for(var t=["binary","bitmapFont","json","physics","shader","audio","text","html","obj","tilemap","xml"],e=0;ee.length&&(r=e.length),i?(n=e[r-1][i],(s=e[r][i])-t<=t-n?e[r]:e[r-1]):(n=e[r-1],(s=e[r])-t<=t-n?s:n)}},function(t,e,i){var n=i(23),s=i(0),r=i(383),o=i(382),a=i(4),h=new s({initialize:function(t,e,i){this.manager=t,this.key=e,this.type="frame",this.frames=this.getFrames(t.textureManager,a(i,"frames",[]),a(i,"defaultTextureKey",null)),this.frameRate=a(i,"frameRate",null),this.duration=a(i,"duration",null),null===this.duration&&null===this.frameRate?(this.frameRate=24,this.duration=this.frameRate/this.frames.length*1e3):this.duration&&null===this.frameRate?this.frameRate=this.frames.length/(this.duration/1e3):this.duration=this.frames.length/this.frameRate*1e3,this.msPerFrame=1e3/this.frameRate,this.skipMissedFrames=a(i,"skipMissedFrames",!0),this.delay=a(i,"delay",0),this.repeat=a(i,"repeat",0),this.repeatDelay=a(i,"repeatDelay",0),this.yoyo=a(i,"yoyo",!1),this.showOnStart=a(i,"showOnStart",!1),this.hideOnComplete=a(i,"hideOnComplete",!1),this.paused=!1,this.manager.on("pauseall",this.pause,this),this.manager.on("resumeall",this.resume,this)},addFrame:function(t){return this.addFrameAt(this.frames.length,t)},addFrameAt:function(t,e){var i=this.getFrames(this.manager.textureManager,e);if(i.length>0){if(0===t)this.frames=i.concat(this.frames);else if(t===this.frames.length)this.frames=this.frames.concat(i);else{var n=this.frames.slice(0,t),s=this.frames.slice(t);this.frames=n.concat(i,s)}this.updateFrameSequence()}return this},checkFrame:function(t){return t>=0&&t0){s.isLast=!0,s.nextFrame=l[0],l[0].prevFrame=s;var v=1/(l.length-1);for(r=0;r=this.frames.length&&(e=0),t.currentAnim!==this&&(t.currentAnim=this,t.frameRate=this.frameRate,t.duration=this.duration,t.msPerFrame=this.msPerFrame,t.skipMissedFrames=this.skipMissedFrames,t._delay=this.delay,t._repeat=this.repeat,t._repeatDelay=this.repeatDelay,t._yoyo=this.yoyo);var i=this.frames[e];0!==e||t.forward||(i=this.getLastFrame()),t.updateFrame(i)},getFrameByProgress:function(t){return t=n(t,0,1),r(t,this.frames,"progress")},nextFrame:function(t){var e=t.currentFrame;e.isLast?t._yoyo?this.handleYoyoFrame(t,!1):t.repeatCounter>0?t._reverse&&t.forward?t.forward=!1:this.repeatAnimation(t):this.completeAnimation(t):this.updateAndGetNextTick(t,e.nextFrame)},handleYoyoFrame:function(t,e){if(e||(e=!1),t._reverse===!e&&t.repeatCounter>0)return t.forward=e,void this.repeatAnimation(t);if(t._reverse===e||0!==t.repeatCounter){t.forward=e;var i=e?t.currentFrame.nextFrame:t.currentFrame.prevFrame;this.updateAndGetNextTick(t,i)}else this.completeAnimation(t)},getLastFrame:function(){return this.frames[this.frames.length-1]},previousFrame:function(t){var e=t.currentFrame;e.isFirst?t._yoyo?this.handleYoyoFrame(t,!0):t.repeatCounter>0?t._reverse&&!t.forward?(t.currentFrame=this.getLastFrame(),this.repeatAnimation(t)):(t.forward=!0,this.repeatAnimation(t)):this.completeAnimation(t):this.updateAndGetNextTick(t,e.prevFrame)},updateAndGetNextTick:function(t,e){t.updateFrame(e),this.getNextTick(t)},removeFrame:function(t){var e=this.frames.indexOf(t);return-1!==e&&this.removeFrameAt(e),this},removeFrameAt:function(t){return this.frames.splice(t,1),this.updateFrameSequence(),this},repeatAnimation:function(t){if(2===t._pendingStop)return this.completeAnimation(t);t._repeatDelay>0&&!1===t.pendingRepeat?(t.pendingRepeat=!0,t.accumulator-=t.nextTick,t.nextTick+=t._repeatDelay):(t.repeatCounter--,t.updateFrame(t.currentFrame[t.forward?"nextFrame":"prevFrame"]),t.isPlaying&&(this.getNextTick(t),t.pendingRepeat=!1,t.parent.emit("animationrepeat",this,t.currentFrame,t.repeatCounter,t.parent)))},setFrame:function(t){t.forward?this.nextFrame(t):this.previousFrame(t)},toJSON:function(){var t={key:this.key,type:this.type,frames:[],frameRate:this.frameRate,duration:this.duration,skipMissedFrames:this.skipMissedFrames,delay:this.delay,repeat:this.repeat,repeatDelay:this.repeatDelay,yoyo:this.yoyo,showOnStart:this.showOnStart,hideOnComplete:this.hideOnComplete};return this.frames.forEach(function(e){t.frames.push(e.toJSON())}),t},updateFrameSequence:function(){for(var t=this.frames.length,e=1/(t-1),i=0;i1&&(n.prevFrame=this.frames[i-1],n.nextFrame=this.frames[i+1])}return this},pause:function(){return this.paused=!0,this},resume:function(){return this.paused=!1,this},destroy:function(){this.manager.off("pauseall",this.pause,this),this.manager.off("resumeall",this.resume,this),this.manager.remove(this.key);for(var t=0;t-h&&(c-=h,n+=l),f=t.right&&(h=1,a+=o-t.right,o=t.right);break;case 1:(a+=e)>=t.bottom&&(h=2,o-=a-t.bottom,a=t.bottom);break;case 2:(o-=e)<=t.left&&(h=3,a-=t.left-o,o=t.left);break;case 3:(a-=e)<=t.top&&(h=0,a=t.top)}return r}},function(t,e){var i={_visible:!0,visible:{get:function(){return this._visible},set:function(t){t?(this._visible=!0,this.renderFlags|=1):(this._visible=!1,this.renderFlags&=-2)}},setVisible:function(t){return this.visible=t,this}};t.exports=i},function(t,e,i){var n=i(16),s=i(38),r=i(199),o=i(198),a={_scaleX:1,_scaleY:1,_rotation:0,x:0,y:0,z:0,w:0,scaleX:{get:function(){return this._scaleX},set:function(t){this._scaleX=t,0===this._scaleX?this.renderFlags&=-5:this.renderFlags|=4}},scaleY:{get:function(){return this._scaleY},set:function(t){this._scaleY=t,0===this._scaleY?this.renderFlags&=-5:this.renderFlags|=4}},angle:{get:function(){return o(this._rotation*n.RAD_TO_DEG)},set:function(t){this.rotation=o(t)*n.DEG_TO_RAD}},rotation:{get:function(){return this._rotation},set:function(t){this._rotation=r(t)}},setPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=t),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=i,this.w=n,this},setRandomPosition:function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),this.x=t+Math.random()*i,this.y=e+Math.random()*n,this},setRotation:function(t){return void 0===t&&(t=0),this.rotation=t,this},setAngle:function(t){return void 0===t&&(t=0),this.angle=t,this},setScale:function(t,e){return void 0===t&&(t=1),void 0===e&&(e=t),this.scaleX=t,this.scaleY=e,this},setX:function(t){return void 0===t&&(t=0),this.x=t,this},setY:function(t){return void 0===t&&(t=0),this.y=t,this},setZ:function(t){return void 0===t&&(t=0),this.z=t,this},setW:function(t){return void 0===t&&(t=0),this.w=t,this},getLocalTransformMatrix:function(t){return void 0===t&&(t=new s),t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY)},getWorldTransformMatrix:function(t,e){void 0===t&&(t=new s),void 0===e&&(e=new s);var i=this.parentContainer;if(!i)return this.getLocalTransformMatrix(t);for(t.applyITRS(this.x,this.y,this._rotation,this._scaleX,this._scaleY);i;)e.applyITRS(i.x,i.y,i._rotation,i._scaleX,i._scaleY),e.multiply(t,t),i=i.parentContainer;return t}};t.exports=a},function(t,e){t.exports=function(t){var e={name:t.name,type:t.type,x:t.x,y:t.y,depth:t.depth,scale:{x:t.scaleX,y:t.scaleY},origin:{x:t.originX,y:t.originY},flipX:t.flipX,flipY:t.flipY,rotation:t.rotation,alpha:t.alpha,visible:t.visible,scaleMode:t.scaleMode,blendMode:t.blendMode,textureKey:"",frameKey:"",data:{}};return t.texture&&(e.textureKey=t.texture.key,e.frameKey=t.frame.name),e}},function(t,e){var i={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,e){return void 0===e&&(e=t),this.scrollFactorX=t,this.scrollFactorY=e,this}};t.exports=i},function(t,e,i){var n=new(i(0))({initialize:function(t,e){this.geometryMask=e},setShape:function(t){this.geometryMask=t},preRenderWebGL:function(t,e,i){var n=t.gl,s=this.geometryMask;t.flush(),n.enable(n.STENCIL_TEST),n.clear(n.STENCIL_BUFFER_BIT),n.colorMask(!1,!1,!1,!1),n.stencilFunc(n.NOTEQUAL,1,1),n.stencilOp(n.REPLACE,n.REPLACE,n.REPLACE),s.renderWebGL(t,s,0,i),t.flush(),n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.EQUAL,1,1),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)},postRenderWebGL:function(t){var e=t.gl;t.flush(),e.disable(e.STENCIL_TEST)},preRenderCanvas:function(t,e,i){var n=this.geometryMask;t.currentContext.save(),n.renderCanvas(t,n,0,i,null,null,!0),t.currentContext.clip()},postRenderCanvas:function(t){t.currentContext.restore()},destroy:function(){this.geometryMask=null}});t.exports=n},function(t,e,i){var n=new(i(0))({initialize:function(t,e){var i=t.sys.game.renderer;if(this.renderer=i,this.bitmapMask=e,this.maskTexture=null,this.mainTexture=null,this.dirty=!0,this.mainFramebuffer=null,this.maskFramebuffer=null,this.invertAlpha=!1,i&&i.gl){var n=i.width,s=i.height,r=0==(n&n-1)&&0==(s&s-1),o=i.gl,a=r?o.REPEAT:o.CLAMP_TO_EDGE,h=o.LINEAR;this.mainTexture=i.createTexture2D(0,h,h,a,a,o.RGBA,null,n,s),this.maskTexture=i.createTexture2D(0,h,h,a,a,o.RGBA,null,n,s),this.mainFramebuffer=i.createFramebuffer(n,s,this.mainTexture,!1),this.maskFramebuffer=i.createFramebuffer(n,s,this.maskTexture,!1),i.onContextRestored(function(t){var e=t.width,i=t.height,n=0==(e&e-1)&&0==(i&i-1),s=t.gl,r=n?s.REPEAT:s.CLAMP_TO_EDGE,o=s.LINEAR;this.mainTexture=t.createTexture2D(0,o,o,r,r,s.RGBA,null,e,i),this.maskTexture=t.createTexture2D(0,o,o,r,r,s.RGBA,null,e,i),this.mainFramebuffer=t.createFramebuffer(e,i,this.mainTexture,!1),this.maskFramebuffer=t.createFramebuffer(e,i,this.maskTexture,!1)},this)}},setBitmap:function(t){this.bitmapMask=t},preRenderWebGL:function(t,e,i){t.pipelines.BitmapMaskPipeline.beginMask(this,e,i)},postRenderWebGL:function(t){t.pipelines.BitmapMaskPipeline.endMask(this)},preRenderCanvas:function(){},postRenderCanvas:function(){},destroy:function(){this.bitmapMask=null;var t=this.renderer;t&&t.gl&&(t.deleteTexture(this.mainTexture),t.deleteTexture(this.maskTexture),t.deleteFramebuffer(this.mainFramebuffer),t.deleteFramebuffer(this.maskFramebuffer)),this.mainTexture=null,this.maskTexture=null,this.mainFramebuffer=null,this.maskFramebuffer=null,this.renderer=null}});t.exports=n},function(t,e,i){var n=i(394),s=i(393),r={mask:null,setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this},createBitmapMask:function(t){return void 0===t&&this.texture&&(t=this),new n(this.scene,t)},createGeometryMask:function(t){return void 0===t&&"Graphics"===this.type&&(t=this),new s(this.scene,t)}};t.exports=r},function(t,e){t.exports=function(t,e,i,n){var s=Math.cos(n),r=Math.sin(n),o=t.x-e,a=t.y-i;return t.x=o*s-a*r+e,t.y=o*r+a*s+i,t}},function(t,e,i){var n=i(6);t.exports=function(t,e,i){return void 0===i&&(i=new n),i.x=t.x1+(t.x2-t.x1)*e,i.y=t.y1+(t.y2-t.y1)*e,i}},function(t,e,i){var n=i(190),s=i(124);t.exports=function(t,e,i,r){void 0===r&&(r=[]),e||(e=s(t)/i);for(var o=0;o=-1&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,e,i){var n=i(23),s={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,e,i,s){return void 0===t&&(t=1),void 0===e?this.alpha=t:(this._alphaTL=n(t,0,1),this._alphaTR=n(e,0,1),this._alphaBL=n(i,0,1),this._alphaBR=n(s,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var e=n(t,0,1);this._alpha=e,this._alphaTL=e,this._alphaTR=e,this._alphaBL=e,this._alphaBR=e,0===e?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var e=n(t,0,1);this._alphaTL=e,0!==e&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var e=n(t,0,1);this._alphaTR=e,0!==e&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var e=n(t,0,1);this._alphaBL=e,0!==e&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var e=n(t,0,1);this._alphaBR=e,0!==e&&(this.renderFlags|=2)}}};t.exports=s},function(t,e){t.exports=function(t){return Math.PI*t.radius*2}},function(t,e,i){var n=i(402),s=i(192),r=i(93),o=i(16);t.exports=function(t,e,i,a){void 0===a&&(a=[]),e||(e=n(t)/i);for(var h=0;h>>0,i=(e*=i)>>>0,i+=4294967296*(e-=i);return this.n=i,2.3283064365386963e-10*(i>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var e=0;e0;i--){var n=Math.floor(this.frac()*(e+1)),s=t[n];t[n]=t[i],t[i]=s}return t}});t.exports=n},function(t,e,i){var n=i(192),s=i(93),r=i(16),o=i(6);t.exports=function(t,e,i){void 0===i&&(i=new o);var a=s(e,0,r.PI2);return n(t,a,i)}},function(t,e,i){var n=i(44),s=i(42),r=i(43),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(46),s=i(42),r=i(45),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(75),s=i(42),r=i(74),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(72),s=i(44),r=i(73),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(72),s=i(46),r=i(73),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(74),s=i(73);t.exports=function(t,e,i){return n(t,e),s(t,i)}},function(t,e,i){var n=i(411),s=i(75),r=i(72);t.exports=function(t,e,i,o){return void 0===i&&(i=0),void 0===o&&(o=0),n(t,s(e)+i,r(e)+o),t}},function(t,e,i){var n=i(48),s=i(44),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(46),r=i(47),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(75),r=i(47),o=i(74);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(193),s=[];s[n.BOTTOM_CENTER]=i(415),s[n.BOTTOM_LEFT]=i(414),s[n.BOTTOM_RIGHT]=i(413),s[n.CENTER]=i(412),s[n.LEFT_CENTER]=i(410),s[n.RIGHT_CENTER]=i(409),s[n.TOP_CENTER]=i(408),s[n.TOP_LEFT]=i(407),s[n.TOP_RIGHT]=i(406);t.exports=function(t,e,i,n,r){return s[i](t,e,n,r)}},function(t,e,i){t.exports={Angle:i(1050),Call:i(1049),GetFirst:i(1048),GetLast:i(1047),GridAlign:i(1046),IncAlpha:i(1035),IncX:i(1034),IncXY:i(1033),IncY:i(1032),PlaceOnCircle:i(1031),PlaceOnEllipse:i(1030),PlaceOnLine:i(1029),PlaceOnRectangle:i(1028),PlaceOnTriangle:i(1027),PlayAnimation:i(1026),PropertyValueInc:i(32),PropertyValueSet:i(25),RandomCircle:i(1025),RandomEllipse:i(1024),RandomLine:i(1023),RandomRectangle:i(1022),RandomTriangle:i(1021),Rotate:i(1020),RotateAround:i(1019),RotateAroundDistance:i(1018),ScaleX:i(1017),ScaleXY:i(1016),ScaleY:i(1015),SetAlpha:i(1014),SetBlendMode:i(1013),SetDepth:i(1012),SetHitArea:i(1011),SetOrigin:i(1010),SetRotation:i(1009),SetScale:i(1008),SetScaleX:i(1007),SetScaleY:i(1006),SetTint:i(1005),SetVisible:i(1004),SetX:i(1003),SetXY:i(1002),SetY:i(1001),ShiftPosition:i(1e3),Shuffle:i(999),SmootherStep:i(998),SmoothStep:i(997),Spread:i(996),ToggleVisible:i(995),WrapInRectangle:i(994)}},function(t,e){var i={};t.exports=i,i.create=function(t,e){var n=t.bodyA,s=t.bodyB,r={id:i.id(n,s),bodyA:n,bodyB:s,activeContacts:[],separation:0,isActive:!0,confirmedActive:!0,isSensor:n.isSensor||s.isSensor,timeCreated:e,timeUpdated:e,collision:null,inverseMass:0,friction:0,frictionStatic:0,restitution:0,slop:0};return i.update(r,t,e),r},i.update=function(t,e,n){if(t.collision=e,e.collided){var s=e.supports,r=t.activeContacts,o=e.parentA,a=e.parentB;t.inverseMass=o.inverseMass+a.inverseMass,t.friction=Math.min(o.friction,a.friction),t.frictionStatic=Math.max(o.frictionStatic,a.frictionStatic),t.restitution=Math.max(o.restitution,a.restitution),t.slop=Math.max(o.slop,a.slop);for(var h=0;h0&&n>0&&s.scissor(t,this.drawingBufferHeight-e-n,i,n))},popScissor:function(){var t=this.scissorStack;t.pop();var e=t[t.length-1];e&&this.setScissor(e[0],e[1],e[2],e[3]),this.currentScissor=e},setPipeline:function(t,e){return this.currentPipeline===t&&this.currentPipeline.vertexBuffer===this.currentVertexBuffer&&this.currentPipeline.program===this.currentProgram||(this.flush(),this.currentPipeline=t,this.currentPipeline.bind()),this.currentPipeline.onBind(e),this.currentPipeline},setBlendMode:function(t){var e=this.gl,i=this.blendModes[t];return t!==r.BlendModes.SKIP_CHECK&&this.currentBlendMode!==t&&(this.flush(),e.enable(e.BLEND),e.blendEquation(i.equation),i.func.length>2?e.blendFuncSeparate(i.func[0],i.func[1],i.func[2],i.func[3]):e.blendFunc(i.func[0],i.func[1]),this.currentBlendMode=t,!0)},addBlendMode:function(t,e){return this.blendModes.push({func:t,equation:e})-1},updateBlendMode:function(t,e,i){return this.blendModes[t]&&(this.blendModes[t].func=e,i&&(this.blendModes[t].equation=i)),this},removeBlendMode:function(t){return t>16&&this.blendModes[t]&&this.blendModes.splice(t,1),this},setBlankTexture:function(t){void 0===t&&(t=!1),!t&&0===this.currentActiveTextureUnit&&this.currentTextures[0]||this.setTexture2D(this.blankTexture.glTexture,0)},setTexture2D:function(t,e){var i=this.gl;return t!==this.currentTextures[e]&&(this.flush(),this.currentActiveTextureUnit!==e&&(i.activeTexture(i.TEXTURE0+e),this.currentActiveTextureUnit=e),i.bindTexture(i.TEXTURE_2D,t),this.currentTextures[e]=t),this},setFramebuffer:function(t){var e=this.gl,i=this.width,n=this.height;return t!==this.currentFramebuffer&&(t&&t.renderTexture?(i=t.renderTexture.width,n=t.renderTexture.height):this.flush(),e.bindFramebuffer(e.FRAMEBUFFER,t),e.viewport(0,0,i,n),this.currentFramebuffer=t),this},setProgram:function(t){var e=this.gl;return t!==this.currentProgram&&(this.flush(),e.useProgram(t),this.currentProgram=t),this},setVertexBuffer:function(t){var e=this.gl;return t!==this.currentVertexBuffer&&(this.flush(),e.bindBuffer(e.ARRAY_BUFFER,t),this.currentVertexBuffer=t),this},setIndexBuffer:function(t){var e=this.gl;return t!==this.currentIndexBuffer&&(this.flush(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.currentIndexBuffer=t),this},createTextureFromSource:function(t,e,i,n){var s=this.gl,a=s.NEAREST,h=s.CLAMP_TO_EDGE;return e=t?t.width:e,i=t?t.height:i,o(e,i)&&(h=s.REPEAT),n===r.ScaleModes.LINEAR&&this.config.antialias&&(a=s.LINEAR),t||"number"!=typeof e||"number"!=typeof i?this.createTexture2D(0,a,a,h,h,s.RGBA,t):this.createTexture2D(0,a,a,h,h,s.RGBA,null,e,i)},createTexture2D:function(t,e,i,n,s,r,o,a,h,l){l=void 0===l||null===l||l;var u=this.gl,c=u.createTexture();return this.setTexture2D(c,0),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,e),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,i),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,s),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,n),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),null===o||void 0===o?u.texImage2D(u.TEXTURE_2D,t,r,a,h,0,r,u.UNSIGNED_BYTE,null):(u.texImage2D(u.TEXTURE_2D,t,r,r,u.UNSIGNED_BYTE,o),a=o.width,h=o.height),this.setTexture2D(null,0),c.isAlphaPremultiplied=l,c.isRenderTexture=!1,c.width=a,c.height=h,this.nativeTextures.push(c),c},createFramebuffer:function(t,e,i,n){var s,r=this.gl,o=r.createFramebuffer();if(this.setFramebuffer(o),n){var a=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,a),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)}if(i.isRenderTexture=!0,i.isAlphaPremultiplied=!1,r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i,0),(s=r.checkFramebufferStatus(r.FRAMEBUFFER))!==r.FRAMEBUFFER_COMPLETE){throw new Error("Framebuffer incomplete. Framebuffer status: "+{36054:"Incomplete Attachment",36055:"Missing Attachment",36057:"Incomplete Dimensions",36061:"Framebuffer Unsupported"}[s])}return o.renderTexture=i,this.setFramebuffer(null),o},createProgram:function(t,e){var i=this.gl,n=i.createProgram(),s=i.createShader(i.VERTEX_SHADER),r=i.createShader(i.FRAGMENT_SHADER);if(i.shaderSource(s,t),i.shaderSource(r,e),i.compileShader(s),i.compileShader(r),!i.getShaderParameter(s,i.COMPILE_STATUS))throw new Error("Failed to compile Vertex Shader:\n"+i.getShaderInfoLog(s));if(!i.getShaderParameter(r,i.COMPILE_STATUS))throw new Error("Failed to compile Fragment Shader:\n"+i.getShaderInfoLog(r));if(i.attachShader(n,s),i.attachShader(n,r),i.linkProgram(n),!i.getProgramParameter(n,i.LINK_STATUS))throw new Error("Failed to link program:\n"+i.getProgramInfoLog(n));return n},createVertexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setVertexBuffer(n),i.bufferData(i.ARRAY_BUFFER,t,e),this.setVertexBuffer(null),n},createIndexBuffer:function(t,e){var i=this.gl,n=i.createBuffer();return this.setIndexBuffer(n),i.bufferData(i.ELEMENT_ARRAY_BUFFER,t,e),this.setIndexBuffer(null),n},deleteTexture:function(t){var e=this.nativeTextures.indexOf(t);return-1!==e&&a(this.nativeTextures,e),this.gl.deleteTexture(t),this.currentTextures[0]===t&&this.setBlankTexture(!0),this},deleteFramebuffer:function(t){return this.gl.deleteFramebuffer(t),this},deleteProgram:function(t){return this.gl.deleteProgram(t),this},deleteBuffer:function(t){return this.gl.deleteBuffer(t),this},preRenderCamera:function(t){var e=t._cx,i=t._cy,n=t._cw,s=t._ch,r=this.pipelines.TextureTintPipeline,o=t.backgroundColor;if(t.renderToTexture){this.flush(),this.pushScissor(e,i,n,-s),this.setFramebuffer(t.framebuffer);var a=this.gl;a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT),r.projOrtho(e,n+e,i,s+i,-1e3,1e3),o.alphaGL>0&&r.drawFillRect(e,i,n+e,s+i,l.getTintFromFloats(o.redGL,o.greenGL,o.blueGL,1),o.alphaGL),t.emit("prerender",t)}else this.pushScissor(e,i,n,s),o.alphaGL>0&&r.drawFillRect(e,i,n,s,l.getTintFromFloats(o.redGL,o.greenGL,o.blueGL,1),o.alphaGL)},postRenderCamera:function(t){var e=this.pipelines.TextureTintPipeline;if(t.flashEffect.postRenderWebGL(e,l.getTintFromFloats),t.fadeEffect.postRenderWebGL(e,l.getTintFromFloats),t.dirty=!1,this.popScissor(),t.renderToTexture){e.flush(),this.setFramebuffer(null),t.emit("postrender",t),e.projOrtho(0,e.width,e.height,0,-1e3,1e3);var i=l.getTintAppendFloatAlpha;(t.pipeline?t.pipeline:e).batchTexture(t,t.glTexture,t.width,t.height,t.x,t.y,t.width,t.height,t.zoom,t.zoom,t.rotation,t.flipX,!t.flipY,1,1,0,0,0,0,t.width,t.height,i(t._tintTL,t._alphaTL),i(t._tintTR,t._alphaTR),i(t._tintBL,t._alphaBL),i(t._tintBR,t._alphaBR),t._isTinted&&t.tintFill,0,0,this.defaultCamera,null),this.setBlankTexture(!0)}},preRender:function(){if(!this.contextLost){var t=this.gl,e=this.config.backgroundColor,i=this.pipelines;for(var n in this.config.clearBeforeRender&&(t.clearColor(e.redGL,e.greenGL,e.blueGL,e.alphaGL),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT|t.STENCIL_BUFFER_BIT)),t.enable(t.SCISSOR_TEST),i)i[n].onPreRender();this.currentScissor=[0,0,this.width,this.height],this.scissorStack=[this.currentScissor],this.game.scene.customViewports&&t.scissor(0,this.drawingBufferHeight-this.height,this.width,this.height),this.setPipeline(this.pipelines.TextureTintPipeline)}},render:function(t,e,i,n){if(!this.contextLost){var s=e.list,o=s.length,a=this.pipelines;for(var h in a)a[h].onRender(t,n);this.preRenderCamera(n);for(var l=0;l=0?g=-(g+d):g<0&&(g=Math.abs(g)-d)),-1===m&&(v>=0?v=-(v+f):v<0&&(v=Math.abs(v)-f))}a.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),o.copyFrom(i.matrix),n?(o.multiplyWithOffset(n,-i.scrollX*t.scrollFactorX,-i.scrollY*t.scrollFactorY),a.e=t.x,a.f=t.y,o.multiply(a,h)):(a.e-=i.scrollX*t.scrollFactorX,a.f-=i.scrollY*t.scrollFactorY,o.multiply(a,h)),r.save(),h.setToContext(r),r.scale(y,m),r.globalCompositeOperation=this.blendModes[t.blendMode],r.globalAlpha=s,r.drawImage(e.source.image,u,c,d,f,g,v,d/p,f/p),r.restore()}},destroy:function(){this.gameCanvas=null,this.gameContext=null,this.game=null}});t.exports=u},function(t,e,i){var n=new(i(0))({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.once("remove",this.remove,this),this.isPlaying=!1,this.currentAnim=null,this.currentFrame=null,this._timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this._delay=0,this._repeat=0,this._repeatDelay=0,this._yoyo=!1,this.forward=!0,this._reverse=!1,this.accumulator=0,this.nextTick=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._pendingStop=0,this._pendingStopValue},setDelay:function(t){return void 0===t&&(t=0),this._delay=t,this.parent},getDelay:function(){return this._delay},delayedPlay:function(t,e,i){return this.play(e,!0,i),this.nextTick+=t,this.parent},getCurrentKey:function(){if(this.currentAnim)return this.currentAnim.key},load:function(t,e){return void 0===e&&(e=0),this.isPlaying&&this.stop(),this.animationManager.load(this,t,e),this.parent},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.updateFrame(t),this.parent},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.updateFrame(t),this.parent},isPaused:{get:function(){return this._paused}},play:function(t,e,i){return void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t?this.parent:(this.forward=!0,this._reverse=!1,this._startAnimation(t,i))},playReverse:function(t,e,i){return void 0===e&&(e=!1),void 0===i&&(i=0),e&&this.isPlaying&&this.currentAnim.key===t?this.parent:(this.forward=!1,this._reverse=!0,this._startAnimation(t,i))},_startAnimation:function(t,e){this.load(t,e);var i=this.currentAnim,n=this.parent;return this.repeatCounter=-1===this._repeat?Number.MAX_VALUE:this._repeat,i.getFirstTick(this),this.isPlaying=!0,this.pendingRepeat=!1,i.showOnStart&&(n.visible=!0),n.emit("animationstart",this.currentAnim,this.currentFrame,n),n},reverse:function(t){return this.isPlaying&&this.currentAnim.key===t?(this._reverse=!this._reverse,this.forward=!this.forward,this.parent):this.parent},getProgress:function(){var t=this.currentFrame.progress;return this.forward||(t=1-t),t},setProgress:function(t){return this.forward||(t=1-t),this.setCurrentFrame(this.currentAnim.getFrameByProgress(t)),this.parent},remove:function(t,e){void 0===e&&(e=this.currentAnim),this.isPlaying&&e.key===this.currentAnim.key&&(this.stop(),this.setCurrentFrame(this.currentAnim.frames[0]))},getRepeat:function(){return this._repeat},setRepeat:function(t){return this._repeat=t,this.repeatCounter=0,this.parent},getRepeatDelay:function(){return this._repeatDelay},setRepeatDelay:function(t){return this._repeatDelay=t,this.parent},restart:function(t){void 0===t&&(t=!1),this.currentAnim.getFirstTick(this,t),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,this._paused=!1,this.updateFrame(this.currentAnim.frames[0]);var e=this.parent;return e.emit("animationrestart",this.currentAnim,this.currentFrame,e),this.parent},stop:function(){this._pendingStop=0,this.isPlaying=!1;var t=this.parent;return t.emit("animationcomplete",this.currentAnim,this.currentFrame,t),t},stopAfterDelay:function(t){return this._pendingStop=1,this._pendingStopValue=t,this.parent},stopOnRepeat:function(){return this._pendingStop=2,this.parent},stopOnFrame:function(t){return this._pendingStop=3,this._pendingStopValue=t,this.parent},setTimeScale:function(t){return void 0===t&&(t=1),this._timeScale=t,this.parent},getTimeScale:function(){return this._timeScale},getTotalFrames:function(){return this.currentAnim.frames.length},update:function(t,e){if(this.currentAnim&&this.isPlaying&&!this.currentAnim.paused){if(this.accumulator+=e*this._timeScale,1===this._pendingStop&&(this._pendingStopValue-=e,this._pendingStopValue<=0))return this.currentAnim.completeAnimation(this);this.accumulator>=this.nextTick&&this.currentAnim.setFrame(this)}},setCurrentFrame:function(t){var e=this.parent;return this.currentFrame=t,e.texture=t.frame.texture,e.frame=t.frame,e.isCropped&&e.frame.updateCropUVs(e._crop,e.flipX,e.flipY),e.setSizeToFrame(),t.frame.customPivot?e.setOrigin(t.frame.pivotX,t.frame.pivotY):e.updateDisplayOrigin(),e},updateFrame:function(t){var e=this.setCurrentFrame(t);if(this.isPlaying){t.setAlpha&&(e.alpha=t.alpha);var i=this.currentAnim;e.emit("animationupdate",i,t,e),3===this._pendingStop&&this._pendingStopValue===t&&this.currentAnim.completeAnimation(this)}},setYoyo:function(t){return void 0===t&&(t=!1),this._yoyo=t,this.parent},getYoyo:function(){return this._yoyo},destroy:function(){this.animationManager.off("remove",this.remove,this),this.animationManager=null,this.parent=null,this.currentAnim=null,this.currentFrame=null}});t.exports=n},function(t,e){t.exports=function(t){return t.split("").reverse().join("")}},function(t,e){t.exports=function(t,e){return t.replace(/%([0-9]+)/g,function(t,i){return e[Number(i)-1]})}},function(t,e,i){t.exports={Format:i(429),Pad:i(179),Reverse:i(428),UppercaseFirst:i(327),UUID:i(295)}},function(t,e,i){var n=i(63);t.exports=function(t,e){var i=n(t);for(var s in e)i.hasOwnProperty(s)&&(i[s]=e[s]);return i}},function(t,e){t.exports=function(t,e){for(var i=0;i-1&&(e.state=a.REMOVED,s.splice(r,1)):(e.state=a.REMOVED,n.splice(r,1))}for(i.length=0,i=this._add,t=0;t-1&&this._active.splice(s,1),n.destroy()}for(i=0;i=n.delay)){var s=n.elapsed-n.delay;n.elapsed=n.delay,!n.hasDispatched&&n.callback&&(n.hasDispatched=!0,n.callback.apply(n.callbackScope,n.args)),n.repeatCount>0?(n.repeatCount--,n.elapsed=s,n.hasDispatched=!1):this._pendingRemoval.push(n)}}}},shutdown:function(){var t;for(t=0;t0&&(t.currentPipeline&&t.currentPipeline.vertexCount>0&&t.flush(),r.vertexBuffer=e.vertexBuffer[a],t.setPipeline(r),t.setTexture2D(s[a].glTexture,0),t.gl.drawArrays(r.topology,0,e.vertexCount[a]));r.vertexBuffer=o,r.viewIdentity(),r.modelIdentity()}},function(t,e,i){var n=i(1),s=i(1);n=i(445),s=i(444),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e){t.exports=function(t,e,i,n,s){e.cull(n);var r=e.culledTiles,o=r.length;if(0!==o){var a=t._tempMatrix1,h=t._tempMatrix2,l=t._tempMatrix3;h.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),a.copyFrom(n.matrix);var u=t.currentContext,c=e.gidMap;u.save(),s?(a.multiplyWithOffset(s,-n.scrollX*e.scrollFactorX,-n.scrollY*e.scrollFactorY),h.e=e.x,h.f=e.y,a.multiply(h,l),l.copyToContext(u)):(h.e-=n.scrollX*e.scrollFactorX,h.f-=n.scrollY*e.scrollFactorY,h.copyToContext(u));for(var d=n.alpha*e.alpha,f=0;f-1?new s(a,f,c,u,o.tilesize,o.tilesize):e?null:new s(a,-1,c,u,o.tilesize,o.tilesize),h.push(d)}l.push(h),h=[]}a.data=l,i.push(a)}return i}},function(t,e,i){var n=i(20);t.exports=function(t){for(var e,i,s,r,o,a=0;a1){if(Array.isArray(l.tiles)){for(var c={},d={},f=0;f>>0;return n}},function(t,e,i){var n=i(458),s=i(2),r=i(78),o=i(214),a=i(55);t.exports=function(t,e){for(var i=[],h=0;h0){var y=new a(u,v.gid,c,f.length,t.tilewidth,t.tileheight);y.rotation=v.rotation,y.flipX=v.flipped,d.push(y)}else{var m=e?null:new a(u,-1,c,f.length,t.tilewidth,t.tileheight);d.push(m)}++c===l.width&&(f.push(d),c=0,d=[])}u.data=f,i.push(u)}}return i}},function(t,e,i){t.exports={Parse:i(217),Parse2DArray:i(133),ParseCSV:i(216),Impact:i(210),Tiled:i(215)}},function(t,e,i){var n=i(50),s=i(49),r=i(3);t.exports=function(t,e,i,o,a,h){return void 0===o&&(o=new r(0,0)),o.x=n(t,i,a,h),o.y=s(e,i,a,h),o}},function(t,e,i){var n=i(17);t.exports=function(t,e,i,s,r,o){if(void 0!==r){var a,h=n(t,e,i,s,null,o),l=0;for(a=0;a0&&n(a,t)}}e&&s(0,0,i.width,i.height,i)}},function(t,e,i){var n=i(56),s=i(34),r=i(85);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0);for(var a=0;ae)){for(var h=t;h<=e;h++)r(h,i,a);for(var l=0;l=t&&c.index<=e&&n(c,i)}o&&s(0,0,a.width,a.height,a)}}},function(t,e,i){var n=i(56),s=i(34),r=i(134);t.exports=function(t,e,i,o){void 0===e&&(e=!0),void 0===i&&(i=!0),Array.isArray(t)||(t=[t]);for(var a=0;a=0;r--)for(s=n.width-1;s>=0;s--)if((o=n.data[r][s])&&o.index===t){if(a===e)return o;a+=1}}else for(r=0;r=v;o--)(h=c[a][o])&&-1!==h.index&&h.visible&&0!==h.alpha&&i.push(h);else if(2===r)for(a=x;a>=m;a--)for(o=v;o=m;a--)for(o=y;o>=v;o--)(h=c[a][o])&&-1!==h.index&&h.visible&&0!==h.alpha&&i.push(h);return u.tilesDrawn=i.length,u.tilesTotal=d*f,i}},function(t,e,i){var n=i(101),s=i(100),r=i(17),o=i(220);t.exports=function(t,e,i,a,h,l){void 0===i&&(i={}),Array.isArray(t)||(t=[t]);var u=l.tilemapLayer;void 0===a&&(a=u.scene),void 0===h&&(h=a.cameras.main);var c,d=r(0,0,l.width,l.height,null,l),f=[];for(c=0;c=0&&p=0&&g=this._duration&&this.transitionComplete()},transitionComplete:function(){var t=this._target.sys,e=this._target.sys.settings;this.systems.events.off("update",this.step,this),t.events.emit("transitioncomplete",this.scene),e.isTransition=!1,e.transitionFrom=null,this._duration=0,this._target=null,this._onUpdate=null,this._onUpdateScope=null,this._willRemove?this.manager.remove(this.key):this._willSleep?this.systems.sleep():this.manager.stop(this.key)},add:function(t,e,i){return this.manager.add(t,e,i),this},launch:function(t,e){return t&&t!==this.key&&this.manager.queueOp("start",t,e),this},run:function(t,e){return t&&t!==this.key&&this.manager.queueOp("run",t,e),this},pause:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("pause",t,e),this},resume:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("resume",t,e),this},sleep:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("sleep",t,e),this},wake:function(t,e){return void 0===t&&(t=this.key),this.manager.queueOp("wake",t,e),this},switch:function(t){return t!==this.key&&this.manager.queueOp("switch",this.key,t),this},stop:function(t){return void 0===t&&(t=this.key),this.manager.queueOp("stop",t),this},setActive:function(t,e,i){void 0===e&&(e=this.key);var n=this.manager.getScene(e);return n&&n.sys.setActive(t,i),this},setVisible:function(t,e){void 0===e&&(e=this.key);var i=this.manager.getScene(e);return i&&i.sys.setVisible(t),this},isSleeping:function(t){return void 0===t&&(t=this.key),this.manager.isSleeping(t)},isActive:function(t){return void 0===t&&(t=this.key),this.manager.isActive(t)},isVisible:function(t){return void 0===t&&(t=this.key),this.manager.isVisible(t)},swapPosition:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.swapPosition(t,e),this},moveAbove:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveAbove(t,e),this},moveBelow:function(t,e){return void 0===e&&(e=this.key),t!==e&&this.manager.moveBelow(t,e),this},remove:function(t){return void 0===t&&(t=this.key),this.manager.remove(t),this},moveUp:function(t){return void 0===t&&(t=this.key),this.manager.moveUp(t),this},moveDown:function(t){return void 0===t&&(t=this.key),this.manager.moveDown(t),this},bringToTop:function(t){return void 0===t&&(t=this.key),this.manager.bringToTop(t),this},sendToBack:function(t){return void 0===t&&(t=this.key),this.manager.sendToBack(t),this},get:function(t){return this.manager.getScene(t)},getIndex:function(t){return void 0===t&&(t=this.key),this.manager.getIndex(t)},shutdown:function(){var t=this.systems.events;t.off("shutdown",this.shutdown,this),t.off("postupdate",this.step,this),t.off("transitionout")},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null,this.settings=null,this.manager=null}});o.register("ScenePlugin",a,"scenePlugin"),t.exports=a},function(t,e,i){var n=i(116),s=i(20),r={SceneManager:i(329),ScenePlugin:i(495),Settings:i(326),Systems:i(166)};r=s(!1,r,n),t.exports=r},function(t,e,i){var n=i(221),s=new(i(0))({Extends:n,initialize:function(t,e){n.call(this,e),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this)},boot:function(){}});t.exports=s},function(t,e,i){t.exports={BasePlugin:i(221),DefaultPlugins:i(167),PluginCache:i(15),PluginManager:i(331),ScenePlugin:i(497)}},function(t,e,i){var n={};t.exports=n;var s=i(137),r=(i(194),i(33));n.create=function(t){var e=s.create(),i={label:"World",gravity:{x:0,y:1,scale:.001},bounds:{min:{x:-1/0,y:-1/0},max:{x:1/0,y:1/0}}};return r.extend(e,i,t)}},function(t,e,i){var n={};t.exports=n;var s=i(33);n._registry={},n.register=function(t){if(n.isPlugin(t)||s.warn("Plugin.register:",n.toString(t),"does not implement all required fields."),t.name in n._registry){var e=n._registry[t.name],i=n.versionParse(t.version).number,r=n.versionParse(e.version).number;i>r?(s.warn("Plugin.register:",n.toString(e),"was upgraded to",n.toString(t)),n._registry[t.name]=t):i-1},n.isFor=function(t,e){var i=t.for&&n.dependencyParse(t.for);return!t.for||e.name===i.name&&n.versionSatisfies(e.version,i.range)},n.use=function(t,e){if(t.uses=(t.uses||[]).concat(e||[]),0!==t.uses.length){for(var i=n.dependencies(t),r=s.topologicalSort(i),o=[],a=0;a0&&!h.silent&&s.info(o.join(" "))}else s.warn("Plugin.use:",n.toString(t),"does not specify any dependencies to install.")},n.dependencies=function(t,e){var i=n.dependencyParse(t),r=i.name;if(!(r in(e=e||{}))){t=n.resolve(t)||t,e[r]=s.map(t.uses||[],function(e){n.isPlugin(e)&&n.register(e);var r=n.dependencyParse(e),o=n.resolve(e);return o&&!n.versionSatisfies(o.version,r.range)?(s.warn("Plugin.dependencies:",n.toString(o),"does not satisfy",n.toString(r),"used by",n.toString(i)+"."),o._warned=!0,t._warned=!0):o||(s.warn("Plugin.dependencies:",n.toString(e),"used by",n.toString(i),"could not be resolved."),t._warned=!0),r.name});for(var o=0;o=s[2];if("^"===i.operator)return s[0]>0?o[0]===s[0]&&r.number>=i.number:s[1]>0?o[1]===s[1]&&o[2]>=s[2]:o[2]===s[2]}return t===e||"*"===t}},function(t,e,i){var n=i(1065);n.Body=i(67),n.Composite=i(137),n.World=i(499),n.Detector=i(503),n.Grid=i(1064),n.Pairs=i(1063),n.Pair=i(418),n.Query=i(1089),n.Resolver=i(1062),n.SAT=i(502),n.Constraint=i(194),n.Common=i(33),n.Engine=i(1061),n.Events=i(195),n.Sleeping=i(222),n.Plugin=i(500),n.Bodies=i(126),n.Composites=i(1068),n.Axes=i(505),n.Bounds=i(80),n.Svg=i(1087),n.Vector=i(81),n.Vertices=i(76),n.World.add=n.Composite.add,n.World.remove=n.Composite.remove,n.World.addComposite=n.Composite.addComposite,n.World.addBody=n.Composite.addBody,n.World.addConstraint=n.Composite.addConstraint,n.World.clear=n.Composite.clear,t.exports=n},function(t,e,i){var n={};t.exports=n;var s=i(76),r=i(81);n.collides=function(t,e,i){var o,a,h,l,u=!1;if(i){var c=t.parent,d=e.parent,f=c.speed*c.speed+c.angularSpeed*c.angularSpeed+d.speed*d.speed+d.angularSpeed*d.angularSpeed;u=i&&i.collided&&f<.2,l=i}else l={collided:!1,bodyA:t,bodyB:e};if(i&&u){var p=l.axisBody,g=p===t?e:t,v=[p.axes[i.axisNumber]];if(h=n._overlapAxes(p.vertices,g.vertices,v),l.reused=!0,h.overlap<=0)return l.collided=!1,l}else{if((o=n._overlapAxes(t.vertices,e.vertices,t.axes)).overlap<=0)return l.collided=!1,l;if((a=n._overlapAxes(e.vertices,t.vertices,e.axes)).overlap<=0)return l.collided=!1,l;o.overlaps?s=a:a=0?o.index-1:u.length-1],l.x=s.x-c.x,l.y=s.y-c.y,h=-r.dot(i,l),a=s,s=u[(o.index+1)%u.length],l.x=s.x-c.x,l.y=s.y-c.y,(n=-r.dot(i,l))1?1:0;d1?1:0;p0:0!=(t.mask&e.category)&&0!=(e.mask&t.category)}},function(t,e,i){var n=i(126),s=i(67),r=i(0),o=i(419),a=i(2),h=i(85),l=i(76),u=new r({Mixins:[o.Bounce,o.Collision,o.Friction,o.Gravity,o.Mass,o.Sensor,o.Sleep,o.Static],initialize:function(t,e,i){this.tile=e,this.world=t,e.physics.matterBody&&e.physics.matterBody.destroy(),e.physics.matterBody=this;var n=a(i,"body",null),s=a(i,"addToWorld",!0);if(n)this.setBody(n,s);else{var r=e.getCollisionGroup();a(r,"objects",[]).length>0?this.setFromTileCollision(i):this.setFromTileRectangle(i)}},setFromTileRectangle:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);var e=this.tile.getBounds(),i=e.x+e.width/2,s=e.y+e.height/2,r=n.rectangle(i,s,e.width,e.height,t);return this.setBody(r,t.addToWorld),this},setFromTileCollision:function(t){void 0===t&&(t={}),h(t,"isStatic")||(t.isStatic=!0),h(t,"addToWorld")||(t.addToWorld=!0);for(var e=this.tile.tilemapLayer.scaleX,i=this.tile.tilemapLayer.scaleY,r=this.tile.getLeft(),o=this.tile.getTop(),u=this.tile.getCollisionGroup(),c=a(u,"objects",[]),d=[],f=0;f1&&(t.parts=d,this.setBody(s.create(t),t.addToWorld)),this},setBody:function(t,e){return void 0===e&&(e=!0),this.body&&this.removeBody(),this.body=t,this.body.gameObject=this,e&&this.world.add(this.body),this},removeBody:function(){return this.body&&(this.world.remove(this.body),this.body.gameObject=void 0,this.body=void 0),this},destroy:function(){this.removeBody(),this.tile.physics.matterBody=void 0}});t.exports=u},function(t,e,i){var n={};t.exports=n;var s=i(81),r=i(33);n.fromVertices=function(t){for(var e={},i=0;i0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.y=u+h*t.bounce.y,e.velocity.y=u+l*e.bounce.y}return!0}},function(t,e,i){var n=i(230);t.exports=function(t,e,i,s){var r=n(t,e,i,s);if(i||0===r||t.immovable&&e.immovable||t.customSeparateX||e.customSeparateX)return 0!==r||t.embedded&&e.embedded;var o=t.velocity.x,a=e.velocity.x;if(t.immovable||e.immovable)t.immovable?(e.x+=r,e.velocity.x=o-a*e.bounce.x,t.moves&&(e.y+=(t.y-t.prev.y)*t.friction.y)):(t.x-=r,t.velocity.x=a-o*t.bounce.x,e.moves&&(t.y+=(e.y-e.prev.y)*e.friction.y));else{r*=.5,t.x-=r,e.x+=r;var h=Math.sqrt(a*a*e.mass/t.mass)*(a>0?1:-1),l=Math.sqrt(o*o*t.mass/e.mass)*(o>0?1:-1),u=.5*(h+l);h-=u,l-=u,t.velocity.x=u+h*t.bounce.x,e.velocity.x=u+l*e.bounce.x}return!0}},function(t,e){t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.up=!0):e>0&&(t.blocked.none=!1,t.blocked.down=!0),t.position.y-=e,0===t.bounce.y?t.velocity.y=0:t.velocity.y=-t.velocity.y*t.bounce.y}},function(t,e,i){var n=i(509);t.exports=function(t,e,i,s,r){var o=0;return t.deltaY()<0&&!t.blocked.up&&e.collideDown&&t.checkCollision.up?e.faceBottom&&t.y0&&!t.blocked.down&&e.collideUp&&t.checkCollision.down&&e.faceTop&&t.bottom>i&&(o=t.bottom-i)>r&&(o=0),0!==o&&(t.customSeparateY?t.overlapY=o:n(t,o)),o}},function(t,e){t.exports=function(t,e){e<0?(t.blocked.none=!1,t.blocked.left=!0):e>0&&(t.blocked.none=!1,t.blocked.right=!0),t.position.x-=e,0===t.bounce.x?t.velocity.x=0:t.velocity.x=-t.velocity.x*t.bounce.x}},function(t,e,i){var n=i(511);t.exports=function(t,e,i,s,r){var o=0;return t.deltaX()<0&&!t.blocked.left&&e.collideRight&&t.checkCollision.left?e.faceRight&&t.x0&&!t.blocked.right&&e.collideLeft&&t.checkCollision.right&&e.faceLeft&&t.right>i&&(o=t.right-i)>r&&(o=0),0!==o&&(t.customSeparateX?t.overlapX=o:n(t,o)),o}},function(t,e,i){var n=i(512),s=i(510),r=i(226);t.exports=function(t,e,i,o,a,h){var l=o.left,u=o.top,c=o.right,d=o.bottom,f=i.faceLeft||i.faceRight,p=i.faceTop||i.faceBottom;if(!f&&!p)return!1;var g=0,v=0,y=0,m=1;if(e.deltaAbsX()>e.deltaAbsY()?y=-1:e.deltaAbsX()=0;a--){var h=e[a],l=o(s,r,h.x,h.y);l=0;a--){var h=e[a],l=o(s,r,h.x,h.y);l>i&&(n=h,i=l)}return n},moveTo:function(t,e,i,n,s){void 0===n&&(n=60),void 0===s&&(s=0);var o=Math.atan2(i-t.y,e-t.x);return s>0&&(n=r(t.x,t.y,e,i)/(s/1e3)),t.body.velocity.setToPolar(o,n),o},moveToObject:function(t,e,i,n){return this.moveTo(t,e.x,e.y,i,n)},velocityFromAngle:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new c),i.setToPolar(s(t),e)},velocityFromRotation:function(t,e,i){return void 0===e&&(e=60),void 0===i&&(i=new c),i.setToPolar(t,e)},shutdown:function(){if(this.world){var t=this.systems.events;t.off("update",this.world.update,this.world),t.off("postupdate",this.world.postUpdate,this.world),t.off("shutdown",this.shutdown,this),this.add.destroy(),this.world.destroy(),this.add=null,this.world=null}},destroy:function(){this.shutdown(),this.scene.sys.events.off("start",this.start,this),this.scene=null,this.systems=null}});u.register("ArcadePhysics",f,"arcadePhysics"),t.exports=f},function(t,e,i){var n=i(35),s=i(20),r={ArcadePhysics:i(527),Body:i(232),Collider:i(231),Factory:i(238),Group:i(235),Image:i(237),Sprite:i(104),StaticBody:i(225),StaticGroup:i(234),World:i(233)};r=s(!1,r,n),t.exports=r},function(t,e,i){var n=i(138),s=i(240),r=i(239),o=new s,a=new r,h=new n;t.exports=function(t,e,i){return a.setAxisAngle(e,i),o.fromRotationTranslation(a,h.set(0,0,0)),t.transformMat4(o)}},function(t,e,i){var n=new(i(0))({initialize:function(t,e,i,n){this.x=0,this.y=0,this.z=0,this.w=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0)},clone:function(){return new n(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this.w=t.w||0,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},set:function(t,e,i,n){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this.w+=t.w||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this.w-=t.w||0,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},lengthSq:function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},normalize:function(){var t=this.x,e=this.y,i=this.z,n=this.w,s=t*t+e*e+i*i+n*n;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=e*s,this.z=i*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,e){void 0===e&&(e=0);var i=this.x,n=this.y,s=this.z,r=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=s+e*(t.z-s),this.w=r+e*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(e*e+i*i+n*n+s*s)},distanceSq:function(t){var e=t.x-this.x,i=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return e*e+i*i+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var e=this.x,i=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,this},transformQuat:function(t){var e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,a=t.w,h=a*e+r*n-o*i,l=a*i+o*e-s*n,u=a*n+s*i-r*e,c=-s*e-r*i-o*n;return this.x=h*a+c*-s+l*-o-u*-r,this.y=l*a+c*-r+u*-s-h*-o,this.z=u*a+c*-o+h*-r-l*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,e){t.exports=function(t,e,i){return Math.abs(t-e)<=i}},function(t,e){t.exports=function(t,e,i,n){void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),n*=Math.PI/t;for(var s=[],r=[],o=0;o1?void 0!==n?(s=(n-t)/(n-i))<0&&(s=0):s=1:s<0&&(s=0),s}},function(t,e){t.exports=function(t,e,i){return Math.max(t-e,i)}},function(t,e){t.exports=function(t,e,i){return Math.min(t+e,i)}},function(t,e){t.exports=function(t){return t===parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t){return t==parseFloat(t)?!(t%2):void 0}},function(t,e){t.exports=function(t,e){return t/e/1e3}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.floor(t*n)/n}},function(t,e){t.exports=function(t,e){return Math.abs(t-e)}},function(t,e){t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=10);var n=Math.pow(i,-e);return Math.ceil(t*n)/n}},function(t,e){t.exports=function(t){for(var e=0,i=0;i0&&0==(t&t-1)}},function(t,e,i){t.exports={GetNext:i(294),IsSize:i(117),IsValue:i(549)}},function(t,e,i){var n=i(182);t.exports=function(t,e,i){return e+(i-e)*n(t,0,1)}},function(t,e,i){var n=i(119);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return e<0?n(t[0],t[1],s):e>1?n(t[i],t[i-1],i-s):n(t[r],t[r+1>i?i:r+1],s-r)}},function(t,e,i){var n=i(171);t.exports=function(t,e){var i=t.length-1,s=i*e,r=Math.floor(s);return t[0]===t[i]?(e<0&&(r=Math.floor(s=i*(1+e))),n(s-r,t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i])):e<0?t[0]-(n(-s,t[0],t[0],t[1],t[1])-t[0]):e>1?t[i]-(n(s-i,t[i],t[i],t[i-1],t[i-1])-t[i]):n(s-r,t[r?r-1:0],t[r],t[i=n.PI2-i?t=e:(Math.abs(e-t)>Math.PI&&(et?t+=i:e0},isLoading:function(){return this.state===s.LOADER_LOADING||this.state===s.LOADER_PROCESSING},isReady:function(){return this.state===s.LOADER_IDLE||this.state===s.LOADER_COMPLETE},start:function(){this.isReady()&&(this.progress=0,this.totalFailed=0,this.totalComplete=0,this.totalToLoad=this.list.size,this.emit("start",this),0===this.list.size?this.loadComplete():(this.state=s.LOADER_LOADING,this.inflight.clear(),this.queue.clear(),this.updateProgress(),this.checkLoadQueue(),this.systems.events.on("update",this.update,this)))},updateProgress:function(){this.progress=1-(this.list.size+this.inflight.size)/this.totalToLoad,this.emit("progress",this.progress)},update:function(){this.state===s.LOADER_LOADING&&this.list.size>0&&this.inflight.size'),i.push(''),i.push(''),i.push(this.xhrLoader.responseText),i.push(""),i.push(""),i.push("");var n=[i.join("\n")],o=this;try{var a=new window.Blob(n,{type:"image/svg+xml;charset=utf-8"})}catch(t){return o.state=s.FILE_ERRORED,void o.onProcessComplete()}this.data=new Image,this.data.crossOrigin=this.crossOrigin,this.data.onload=function(){r.revokeObjectURL(o.data),o.onProcessComplete()},this.data.onerror=function(){r.revokeObjectURL(o.data),o.onProcessError()},r.createObjectURL(this.data,a,"image/svg+xml")},addToCache:function(){var t=this.cache.addImage(this.key,this.data);this.pendingDestroy(t)}});o.register("htmlTexture",function(t,e,i,n,s){if(Array.isArray(t))for(var r=0;r0&&e.maxKeyDelay>0){var r=e.timeLastMatched+e.maxKeyDelay;t.timeStamp<=r&&(s=!0,i=n(t,e))}else s=!0,i=n(t,e);return!s&&e.resetOnWrongKey&&(e.index=0,e.current=e.keyCodes[0]),i&&(e.timeLastMatched=t.timeStamp,e.matched=!0,e.timeMatched=t.timeStamp),i}},function(t,e,i){var n=i(0),s=i(11),r=i(4),o=i(106),a=i(256),h=i(143),l=i(255),u=i(602),c=i(601),d=i(600),f=i(142),p=new n({Extends:s,initialize:function(t){s.call(this),this.scene=t.scene,this.settings=this.scene.sys.settings,this.sceneInputPlugin=t,this.enabled=!0,this.target,this.keys=[],this.combos=[],this.queue=[],this.onKeyHandler,this.time=0,t.pluginEvents.once("boot",this.boot,this),t.pluginEvents.on("start",this.start,this)},boot:function(){var t=this.settings.input,e=this.scene.sys.game.config;this.enabled=r(t,"keyboard",e.inputKeyboard),this.target=r(t,"keyboard.target",e.inputKeyboardEventTarget),this.sceneInputPlugin.pluginEvents.once("destroy",this.destroy,this)},start:function(){this.enabled&&this.startListeners(),this.sceneInputPlugin.pluginEvents.once("shutdown",this.shutdown,this)},isActive:function(){return this.enabled&&this.scene.sys.isActive()},startListeners:function(){var t=this,e=function(e){if(!e.defaultPrevented&&t.isActive()){t.queue.push(e);var i=t.keys[e.keyCode];i&&i.preventDefault&&e.preventDefault()}};this.onKeyHandler=e,this.target.addEventListener("keydown",e,!1),this.target.addEventListener("keyup",e,!1),this.sceneInputPlugin.pluginEvents.on("update",this.update,this)},stopListeners:function(){this.target.removeEventListener("keydown",this.onKeyHandler),this.target.removeEventListener("keyup",this.onKeyHandler),this.sceneInputPlugin.pluginEvents.off("update",this.update)},createCursorKeys:function(){return this.addKeys({up:h.UP,down:h.DOWN,left:h.LEFT,right:h.RIGHT,space:h.SPACE,shift:h.SHIFT})},addKeys:function(t){var e={};if("string"==typeof t){t=t.split(",");for(var i=0;i-1?e[i]=t:e[t.keyCode]=t,t}return"string"==typeof t&&(t=h[t.toUpperCase()]),e[t]||(e[t]=new a(t)),e[t]},removeKey:function(t){var e=this.keys;if(t instanceof a){var i=e.indexOf(t);i>-1&&(this.keys[i]=void 0)}else"string"==typeof t&&(t=h[t.toUpperCase()]);e[t]&&(e[t]=void 0)},createCombo:function(t,e){return new l(this,t,e)},checkDown:function(t,e){if(this.enabled&&t.isDown){var i=f(this.time-t.timeDown,e);if(i>t._tick)return t._tick=i,!0}return!1},update:function(t){this.time=t;var e=this.queue.length;if(this.enabled&&0!==e)for(var i=this.queue.splice(0,e),n=this.keys,s=0;s=e}}},function(t,e,i){var n=i(71),s=i(40),r=i(0),o=i(260),a=i(608),h=i(52),l=i(90),u=i(89),c=i(11),d=i(2),f=i(106),p=i(8),g=i(15),v=i(9),y=i(39),m=i(59),x=i(69),w=new r({Extends:c,initialize:function(t){c.call(this),this.scene=t,this.systems=t.sys,this.settings=t.sys.settings,this.manager=t.sys.game.input,this.pluginEvents=new c,this.enabled=!0,this.displayList,this.cameras,f.install(this),this.mouse=this.manager.mouse,this.topOnly=!0,this.pollRate=-1,this._pollTimer=0;var e={cancelled:!1};this._eventContainer={stopPropagation:function(){e.cancelled=!0}},this._eventData=e,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this._temp=[],this._tempZones=[],this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],this._draggable=[],this._drag={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._over={0:[],1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},this._validTypes=["onDown","onUp","onOver","onOut","onMove","onDragStart","onDrag","onDragEnd","onDragEnter","onDragLeave","onDragOver","onDrop"],t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.cameras=this.systems.cameras,this.displayList=this.systems.displayList,this.systems.events.once("destroy",this.destroy,this),this.pluginEvents.emit("boot")},start:function(){var t=this.systems.events;t.on("transitionstart",this.transitionIn,this),t.on("transitionout",this.transitionOut,this),t.on("transitioncomplete",this.transitionComplete,this),t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this),this.enabled=!0,this.pluginEvents.emit("start")},preUpdate:function(){this.pluginEvents.emit("preUpdate");var t=this._pendingRemoval,e=this._pendingInsertion,i=t.length,n=e.length;if(0!==i||0!==n){for(var s=this._list,r=0;r-1&&(s.splice(a,1),this.clear(o))}t.length=0,this._pendingRemoval.length=0,this._list=s.concat(e.splice(0))}},isActive:function(){return this.enabled&&this.scene.sys.isActive()},update:function(t,e){if(this.isActive()){this.pluginEvents.emit("update",t,e);var i=this.manager;if(!i.globalTopOnly||!i.ignoreEvents){var n=i.dirty||0===this.pollRate;if(this.pollRate>-1&&(this._pollTimer-=e,this._pollTimer<0&&(n=!0,this._pollTimer=this.pollRate)),n)for(var s=this.manager.pointers,r=0;r0&&i.globalTopOnly&&(i.ignoreEvents=!0)}}}},clear:function(t){var e=t.input;if(e){this.queueForRemoval(t),e.gameObject=void 0,e.target=void 0,e.hitArea=void 0,e.hitAreaCallback=void 0,e.callbackContext=void 0,this.manager.resetCursor(e),t.input=null;var i=this._draggable.indexOf(t);return i>-1&&this._draggable.splice(i,1),(i=this._drag[0].indexOf(t))>-1&&this._drag[0].splice(i,1),(i=this._over[0].indexOf(t))>-1&&this._over[0].splice(i,1),t}},disable:function(t){t.input.enabled=!1},enable:function(t,e,i,n){return void 0===n&&(n=!1),t.input?t.input.enabled=!0:this.setHitArea(t,e,i),t.input&&n&&!t.input.dropZone&&(t.input.dropZone=n),this},hitTestPointer:function(t){for(var e=this.cameras.getCamerasBelowPointer(t),i=0;i0)return t.camera=n,s}return t.camera=e[0],[]},processDownEvents:function(t){var e=0,i=this._temp,n=this._eventData,s=this._eventContainer;n.cancelled=!1;for(var r=!1,o=0;o0?t.dragState=1:t.dragState>0&&!t.primaryDown&&t.justUp&&(t.dragState=5),1===t.dragState){var a=[];for(i=0;i1&&(this.sortGameObjects(a),this.topOnly&&a.splice(1)),this._drag[t.id]=a,0===this.dragDistanceThreshold&&0===this.dragTimeThreshold?t.dragState=3:t.dragState=2}if(2===t.dragState&&(this.dragDistanceThreshold>0&&h(t.x,t.y,t.downX,t.downY)>=this.dragDistanceThreshold&&(t.dragState=3),this.dragTimeThreshold>0&&e>=t.downTime+this.dragTimeThreshold&&(t.dragState=3)),3===t.dragState){for(s=this._drag[t.id],i=0;i0?(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):(n.emit("dragleave",t,r.target),this.emit("dragleave",t,n,r.target),l[0]?(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target)):r.target=null)}else!r.target&&l[0]&&(r.target=l[0],n.emit("dragenter",t,r.target),this.emit("dragenter",t,n,r.target));var c=t.x-n.input.dragX,d=t.y-n.input.dragY;n.emit("drag",t,c,d),this.emit("drag",t,n,c,d)}return s.length}if(5===t.dragState){for(s=this._drag[t.id],i=0;i0){for(this.sortGameObjects(s),e=0;e0){for(this.sortGameObjects(r),e=0;e-1&&this._draggable.splice(s,1)}return this},makePixelPerfect:function(t){void 0===t&&(t=1);var e=this.systems.textures;return a(e,t)},setHitArea:function(t,e,i){if(void 0===e)return this.setHitAreaFromTexture(t);Array.isArray(t)||(t=[t]);var n=!1,s=!1,r=!1,a=!1;if(p(e)){var h=e;e=d(h,"hitArea",null),i=d(h,"hitAreaCallback",null),n=d(h,"draggable",!1),s=d(h,"dropZone",!1),r=d(h,"cursor",!1),a=d(h,"useHandCursor",!1);var l=d(h,"pixelPerfect",!1),u=d(h,"alphaTolerance",1);l&&(e={},i=this.makePixelPerfect(u)),e&&i||this.setHitAreaFromTexture(t)}else"function"!=typeof e||i||(i=e,e={});for(var c=0;c0?t.width/2:t.width/-2,h=r>0?t.height/2:t.height/-2;return Math.abs(a*r)e.x&&t.ye.y}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e){t.exports=function(t,e,i){var n=Math.min(t.x,e),s=Math.max(t.right,e);t.x=n,t.width=s-n;var r=Math.min(t.y,i),o=Math.max(t.bottom,i);return t.y=r,t.height=o-r,t}},function(t,e){t.exports=function(t,e){var i=Math.min(t.x,e.x),n=Math.max(t.right,e.right);t.x=i,t.width=n-i;var s=Math.min(t.y,e.y),r=Math.max(t.bottom,e.bottom);return t.y=s,t.height=r-s,t}},function(t,e){t.exports=function(t,e){for(var i=t.x,n=t.right,s=t.y,r=t.bottom,o=0;on(e)?t.setSize(e.height*i,e.height):t.setSize(e.width,e.width/i),t.setPosition(e.centerX-t.width/2,e.centerY-t.height/2)}},function(t,e,i){var n=i(145);t.exports=function(t,e){var i=n(t);return ii&&(i=h.x),h.xr&&(r=h.y),h.ye.right||t.righte.bottom||t.bottom0||(c=s(e),(d=n(t,c,!0)).length>0)}},function(t,e,i){var n=i(69),s=i(107);t.exports=function(t,e){return!!(n(t,e.getPointA())||n(t,e.getPointB())||s(t.getLineA(),e)||s(t.getLineB(),e)||s(t.getLineC(),e))}},function(t,e,i){var n=i(272),s=i(69);t.exports=function(t,e){return!(t.left>e.right||t.righte.bottom||t.bottomt.right+r||it.bottom+r||st.right||e.rightt.bottom||e.bottom0}},function(t,e,i){var n=i(271);t.exports=function(t,e){if(!n(t,e))return!1;var i=Math.min(e.x1,e.x2),s=Math.max(e.x1,e.x2),r=Math.min(e.y1,e.y2),o=Math.max(e.y1,e.y2);return t.x>=i&&t.x<=s&&t.y>=r&&t.y<=o}},function(t,e){t.exports=function(t,e){var i=t.x1,n=t.y1,s=t.x2,r=t.y2,o=e.x,a=e.y,h=e.right,l=e.bottom,u=0;if(i>=o&&i<=h&&n>=a&&n<=l||s>=o&&s<=h&&r>=a&&r<=l)return!0;if(i=o){if((u=n+(r-n)*(o-i)/(s-i))>a&&u<=l)return!0}else if(i>h&&s<=h&&(u=n+(r-n)*(h-i)/(s-i))>=a&&u<=l)return!0;if(n=a){if((u=i+(s-i)*(a-n)/(r-n))>=o&&u<=h)return!0}else if(n>l&&r<=l&&(u=i+(s-i)*(l-n)/(r-n))>=o&&u<=h)return!0;return!1}},function(t,e,i){var n=i(9),s=i(148);t.exports=function(t,e,i){return void 0===i&&(i=new n),s(t,e)&&(i.x=Math.max(t.x,e.x),i.y=Math.max(t.y,e.y),i.width=Math.min(t.right,e.right)-i.x,i.height=Math.min(t.bottom,e.bottom)-i.y),i}},function(t,e){t.exports=function(t,e){var i=e.width/2,n=e.height/2,s=Math.abs(t.x-e.x-i),r=Math.abs(t.y-e.y-n),o=i+t.radius,a=n+t.radius;if(s>o||r>a)return!1;if(s<=i||r<=n)return!0;var h=s-i,l=r-n;return h*h+l*l<=t.radius*t.radius}},function(t,e,i){var n=i(52);t.exports=function(t,e){return n(t.x,t.y,e.x,e.y)<=t.radius+e.radius}},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(9);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.width,e.height=t.height,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.width,t.height)}},function(t,e,i){var n=i(89);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(89);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(90);t.exports=function(t){return new n(t.x,t.y,t.width,t.height)}},function(t,e){t.exports=function(t){return t.isEmpty()?0:t.getMajorRadius()*t.getMinorRadius()*Math.PI}},function(t,e,i){var n=i(90);n.Area=i(712),n.Circumference=i(306),n.CircumferencePoint=i(156),n.Clone=i(711),n.Contains=i(89),n.ContainsPoint=i(710),n.ContainsRect=i(709),n.CopyFrom=i(708),n.Equals=i(707),n.GetBounds=i(706),n.GetPoint=i(308),n.GetPoints=i(307),n.Offset=i(705),n.OffsetPoint=i(704),n.Random=i(185),t.exports=n},function(t,e){t.exports=function(t,e){return t.x+=e.x,t.y+=e.y,t}},function(t,e){t.exports=function(t,e,i){return t.x+=e,t.y+=i,t}},function(t,e,i){var n=i(9);t.exports=function(t,e){return void 0===e&&(e=new n),e.x=t.left,e.y=t.top,e.width=t.diameter,e.height=t.diameter,e}},function(t,e){t.exports=function(t,e){return t.x===e.x&&t.y===e.y&&t.radius===e.radius}},function(t,e){t.exports=function(t,e){return e.setTo(t.x,t.y,t.radius)}},function(t,e,i){var n=i(40);t.exports=function(t,e){return n(t,e.x,e.y)&&n(t,e.right,e.y)&&n(t,e.x,e.bottom)&&n(t,e.right,e.bottom)}},function(t,e,i){var n=i(40);t.exports=function(t,e){return n(t,e.x,e.y)}},function(t,e,i){var n=i(71);t.exports=function(t){return new n(t.x,t.y,t.radius)}},function(t,e){t.exports=function(t){return t.radius>0?Math.PI*t.radius*t.radius:0}},function(t,e,i){var n=i(71);n.Area=i(722),n.Circumference=i(402),n.CircumferencePoint=i(192),n.Clone=i(721),n.Contains=i(40),n.ContainsPoint=i(720),n.ContainsRect=i(719),n.CopyFrom=i(718),n.Equals=i(717),n.GetBounds=i(716),n.GetPoint=i(405),n.GetPoints=i(403),n.Offset=i(715),n.OffsetPoint=i(714),n.Random=i(191),t.exports=n},function(t,e,i){var n=i(0),s=i(275),r=i(15),o=new n({Extends:s,initialize:function(t){this.scene=t,this.systems=t.sys,t.sys.settings.isBooted||t.sys.events.once("boot",this.boot,this),s.call(this)},boot:function(){var t=this.systems.events;t.on("shutdown",this.shutdown,this),t.on("destroy",this.destroy,this)},destroy:function(){this.shutdown(),this.scene=void 0,this.systems=void 0}});r.register("LightsPlugin",o,"lights"),t.exports=o},function(t,e,i){var n=i(28),s=i(13),r=i(12),o=i(149);s.register("quad",function(t,e){void 0===t&&(t={});var i=r(t,"x",0),s=r(t,"y",0),a=r(t,"key",null),h=r(t,"frame",null),l=new o(this.scene,i,s,a,h);return void 0!==e&&(t.add=e),n(this.scene,l,t),l})},function(t,e,i){var n=i(28),s=i(13),r=i(12),o=i(4),a=i(108);s.register("mesh",function(t,e){void 0===t&&(t={});var i=r(t,"key",null),s=r(t,"frame",null),h=o(t,"vertices",[]),l=o(t,"colors",[]),u=o(t,"alphas",[]),c=o(t,"uv",[]),d=new a(this.scene,0,0,h,c,l,u,i,s);return void 0!==e&&(t.add=e),n(this.scene,d,t),d})},function(t,e,i){var n=i(149);i(5).register("quad",function(t,e,i,s){return this.displayList.add(new n(this.scene,t,e,i,s))})},function(t,e,i){var n=i(108);i(5).register("mesh",function(t,e,i,s,r,o,a,h){return this.displayList.add(new n(this.scene,t,e,i,s,r,o,a,h))})},function(t,e){t.exports=function(){}},function(t,e,i){var n=i(10);t.exports=function(t,e,i,s,r){var o=this.pipeline;t.setPipeline(o,e);var a=o._tempMatrix1,h=o._tempMatrix2,l=o._tempMatrix3;h.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),a.copyFrom(s.matrix),r?(a.multiplyWithOffset(r,-s.scrollX*e.scrollFactorX,-s.scrollY*e.scrollFactorY),h.e=e.x,h.f=e.y,a.multiply(h,l)):(h.e-=s.scrollX*e.scrollFactorX,h.f-=s.scrollY*e.scrollFactorY,a.multiply(h,l));var u=e.frame.glTexture,c=e.vertices,d=e.uv,f=e.colors,p=e.alphas,g=c.length,v=Math.floor(.5*g);o.vertexCount+v>=o.vertexCapacity&&o.flush(),o.setTexture2D(u,0);for(var y=o.vertexViewF32,m=o.vertexViewU32,x=o.vertexCount*o.vertexComponentCount-1,w=0,b=e.tintFill,T=0;T0)for(u=o.fillTint,c=n.getTintAppendFloatAlphaAndSwap(e.fillColor,e.fillAlpha*d),u.TL=c,u.TR=c,u.BL=c,u.BR=c,M=0;M0)for(u=o.fillTint,c=n.getTintAppendFloatAlphaAndSwap(e.altFillColor,e.altFillAlpha*d),u.TL=c,u.TR=c,u.BL=c,u.BR=c,M=0;M0){var L=o.strokeTint,F=n.getTintAppendFloatAlphaAndSwap(e.outlineFillColor,e.outlineFillAlpha*d);for(L.TL=F,L.TR=F,L.BL=F,L.BR=F,C=1;Cr;h--){for(l=0;l0&&r.maxLines1&&(d+=f*(i.length-1)),{width:a,height:d,lines:h,lineWidths:o,lineSpacing:f,lineHeight:c}}},function(t,e,i){var n=i(4);t.exports=function(t,e){var i=e.width,s=e.height,r=Math.floor(i/2),o=Math.floor(s/2),a=n(e,"chars","");if(""!==a){var h=n(e,"image",""),l=n(e,"offset.x",0),u=n(e,"offset.y",0),c=n(e,"spacing.x",0),d=n(e,"spacing.y",0),f=n(e,"lineSpacing",0),p=n(e,"charsPerRow",null);null===p&&(p=t.sys.textures.getFrame(h).width/i)>a.length&&(p=a.length);for(var g=l,v=u,y={retroFont:!0,font:h,size:i,lineHeight:s+f,chars:{}},m=0,x=0;x?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",TEXT_SET2:" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET3:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",TEXT_SET4:"ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",TEXT_SET5:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",TEXT_SET6:"ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",TEXT_SET7:"AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",TEXT_SET8:"0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET9:"ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",TEXT_SET10:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",TEXT_SET11:"ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789"}},function(t,e,i){var n=i(813),s=i(20),r={Parse:i(812)};r=s(!1,r,n),t.exports=r},function(t,e){t.exports=function(t,e,i,n,s){t.batchSprite(e,e.frame,n,s)}},function(t,e,i){var n=i(10);t.exports=function(t,e,i,s,r){var o=e.frame,a=o.width,h=o.height,l=n.getTintAppendFloatAlpha;this.pipeline.batchTexture(e,o.glTexture,a,h,e.x,e.y,a,h,e.scaleX,e.scaleY,e.rotation,e.flipX,!e.flipY,e.scrollFactorX,e.scrollFactorY,e.displayOriginX,e.displayOriginY,0,0,a,h,l(e._tintTL,s.alpha*e._alphaTL),l(e._tintTR,s.alpha*e._alphaTR),l(e._tintBL,s.alpha*e._alphaBL),l(e._tintBR,s.alpha*e._alphaBR),e._isTinted&&e.tintFill,0,0,s,r),t.setBlankTexture(!0)}},function(t,e,i){var n=i(1),s=i(1);n=i(816),s=i(815),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){t.exports={DeathZone:i(301),EdgeZone:i(300),RandomZone:i(297)}},function(t,e){t.exports=function(t,e,i,n,s){var r=e.emitters.list,o=r.length;if(0!==o){var a=t._tempMatrix1.copyFrom(n.matrix),h=t._tempMatrix2,l=t._tempMatrix3,u=t._tempMatrix4.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY);a.multiply(u);var c=n.roundPixels,d=t.currentContext;d.save();for(var f=0;f0&&(X=X%T-T):X>T?X=T:X<0&&(X=T+X%T),null===C&&(C=new o(D+Math.cos(Y)*I,B+Math.sin(Y)*I,v),S.push(C),O+=.01);O<1+N;)b=X*O+Y,x=D+Math.cos(b)*I,w=B+Math.sin(b)*I,C.points.push(new r(x,w,v)),O+=.01;b=X+Y,x=D+Math.cos(b)*I,w=B+Math.sin(b)*I,C.points.push(new r(x,w,v));break;case n.FILL_RECT:u.setTexture2D(P),u.batchFillRect(p[++E],p[++E],p[++E],p[++E],f,c);break;case n.FILL_TRIANGLE:u.setTexture2D(P),u.batchFillTriangle(p[++E],p[++E],p[++E],p[++E],p[++E],p[++E],f,c);break;case n.STROKE_TRIANGLE:u.setTexture2D(P),u.batchStrokeTriangle(p[++E],p[++E],p[++E],p[++E],p[++E],p[++E],v,f,c);break;case n.LINE_TO:null!==C?C.points.push(new r(p[++E],p[++E],v)):(C=new o(p[++E],p[++E],v),S.push(C));break;case n.MOVE_TO:C=new o(p[++E],p[++E],v),S.push(C);break;case n.SAVE:a.push(f.copyToArray());break;case n.RESTORE:f.copyFromArray(a.pop());break;case n.TRANSLATE:D=p[++E],B=p[++E],f.translate(D,B);break;case n.SCALE:D=p[++E],B=p[++E],f.scale(D,B);break;case n.ROTATE:f.rotate(p[++E]);break;case n.SET_TEXTURE:var U=p[++E],V=p[++E];u.currentFrame=U,u.setTexture2D(U.glTexture,0),u.tintEffect=V,P=U.glTexture;break;case n.CLEAR_TEXTURE:u.currentFrame=t.blankTexture,u.tintEffect=2,P=t.blankTexture.glTexture}}}},function(t,e,i){var n=i(1),s=i(1);n=i(830),s=i(305),s=i(305),t.exports={renderWebGL:n,renderCanvas:s}},function(t,e,i){var n=i(22);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length,h=t.currentContext;if(0!==a&&n(t,h,e,s,r)){var l=e.frame,u=e.displayCallback,c=s.scrollX*e.scrollFactorX,d=s.scrollY*e.scrollFactorY,f=e.fontData.chars,p=e.fontData.lineHeight,g=0,v=0,y=0,m=0,x=null,w=0,b=0,T=0,S=0,_=0,A=0,C=null,M=0,P=e.frame.source.image,E=l.cutX,k=l.cutY,L=0,F=e.fontSize/e.fontData.size;e.cropWidth>0&&e.cropHeight>0&&(h.save(),h.beginPath(),h.rect(0,0,e.cropWidth,e.cropHeight),h.clip());for(var R=0;R0&&e.cropHeight>0&&h.restore(),h.restore()}}},function(t,e,i){var n=i(10);t.exports=function(t,e,i,s,r){var o=e.text,a=o.length;if(0!==a){var h=this.pipeline;t.setPipeline(h,e);var l=e.cropWidth>0||e.cropHeight>0;l&&(h.flush(),t.pushScissor(e.x,e.y,e.cropWidth*e.scaleX,e.cropHeight*e.scaleY));var u=h._tempMatrix1,c=h._tempMatrix2,d=h._tempMatrix3,f=h._tempMatrix4;c.applyITRS(e.x,e.y,e.rotation,e.scaleX,e.scaleY),u.copyFrom(s.matrix),r?(u.multiplyWithOffset(r,-s.scrollX*e.scrollFactorX,-s.scrollY*e.scrollFactorY),c.e=e.x,c.f=e.y,u.multiply(c,d)):(c.e-=s.scrollX*e.scrollFactorX,c.f-=s.scrollY*e.scrollFactorY,u.multiply(c,d));var p=e.frame,g=p.glTexture,v=p.cutX,y=p.cutY,m=g.width,x=g.height,w=e._isTinted&&e.tintFill,b=n.getTintAppendFloatAlpha(e._tintTL,s.alpha*e._alphaTL),T=n.getTintAppendFloatAlpha(e._tintTR,s.alpha*e._alphaTR),S=n.getTintAppendFloatAlpha(e._tintBL,s.alpha*e._alphaBL),_=n.getTintAppendFloatAlpha(e._tintBR,s.alpha*e._alphaBR);h.setTexture2D(g,0);var A,C,M=0,P=0,E=0,k=0,L=e.letterSpacing,F=0,R=0,O=0,D=0,B=e.scrollX,I=e.scrollY,Y=e.fontData,X=Y.chars,z=Y.lineHeight,N=e.fontSize/Y.size,U=0,V=e._align,G=0,W=0;e.getTextBounds(!1);var H=e._bounds.lines;1===V?W=(H.longest-H.lengths[0])/2:2===V&&(W=H.longest-H.lengths[0]);for(var j=s.roundPixels,q=e.displayCallback,K=e.callbackData,J=0;Jv&&(r=v),o>y&&(o=y);var k=v+g.xAdvance,L=y+u;aA&&(A=M),M<_&&(_=M),C++,M=0;S[C]=M,M>A&&(A=M),M<_&&(_=M);var F=i.local,R=i.global,O=i.lines;return F.x=r*m,F.y=o*m,F.width=a*m,F.height=h*m,R.x=t.x-t.displayOriginX+r*x,R.y=t.y-t.displayOriginY+o*w,R.width=a*x,R.height=h*w,O.shortest=_,O.longest=A,O.lengths=S,e&&(F.x=Math.round(F.x),F.y=Math.round(F.y),F.width=Math.round(F.width),F.height=Math.round(F.height),R.x=Math.round(R.x),R.y=Math.round(R.y),R.width=Math.round(R.width),R.height=Math.round(R.height),O.shortest=Math.round(_),O.longest=Math.round(A)),i}},function(t,e,i){var n=i(0),s=i(15),r=new n({initialize:function(t){this.scene=t,this.systems=t.sys,this._list=[],this._pendingInsertion=[],this._pendingRemoval=[],t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.systems.events.once("destroy",this.destroy,this)},start:function(){var t=this.systems.events;t.on("preupdate",this.preUpdate,this),t.on("update",this.update,this),t.once("shutdown",this.shutdown,this)},add:function(t){return-1===this._list.indexOf(t)&&-1===this._pendingInsertion.indexOf(t)&&this._pendingInsertion.push(t),t},preUpdate:function(){var t=this._pendingRemoval.length,e=this._pendingInsertion.length;if(0!==t||0!==e){var i,n;for(i=0;i-1&&this._list.splice(s,1)}this._list=this._list.concat(this._pendingInsertion.splice(0)),this._pendingRemoval.length=0,this._pendingInsertion.length=0}},update:function(t,e){for(var i=0;i0&&(t.splice(i,1),t.unshift(e)),e}},function(t,e){t.exports=function(t,e,i){var n=t.indexOf(e),s=t.indexOf(i);return-1!==n&&-1===s&&(t[n]=i,!0)}},function(t,e,i){var n=i(91);t.exports=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=t.length);var s=e+Math.floor(Math.random()*i);return n(t,s)}},function(t,e,i){var n=i(62);t.exports=function(t,e,i,s,r){if(void 0===e&&(e=0),void 0===i&&(i=t.length),void 0===r&&(r=t),n(t,e,i)){var o=i-e,a=t.splice(e,o);if(s)for(var h=0;ht.length-1)throw new Error("Index out of bounds");var r=n(t,e);return i&&i.call(s,r),r}},function(t,e,i){var n=i(314);t.exports=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=null),void 0===i&&(i=1),null===e&&(e=t,t=0);for(var s=[],r=Math.max(n((e-t)/(i||1)),0),o=0;o=t.length)throw new Error("Supplied index out of bounds");return n!==i&&(t.splice(n,1),t.splice(i,0,e)),e}},function(t,e){t.exports=function(t,e){var i=t.indexOf(e);if(i>0){var n=t[i-1],s=t.indexOf(n);t[i]=n,t[s]=e}return t}},function(t,e,i){var n=i(62);t.exports=function(t,e,i,s,r){if(void 0===s&&(s=0),void 0===r&&(r=t.length),n(t,s,r))for(var o=s;o0){var o=n-t.length;if(o<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.splice(i,0,e),s&&s.call(r,e),e):null;for(var a=e.length-1;a>=0;)-1!==t.indexOf(e[a])&&e.pop(),a--;if(0===(a=e.length))return null;n>0&&a>o&&(e.splice(o),a=o);for(var h=a-1;h>=0;h--){var l=e[h];t.splice(i,0,l),s&&s.call(r,l)}return e}},function(t,e){t.exports=function(t,e,i,n,s){if(void 0===s&&(s=t),i>0){var r=i-t.length;if(r<=0)return null}if(!Array.isArray(e))return-1===t.indexOf(e)?(t.push(e),n&&n.call(s,e),e):null;for(var o=e.length-1;o>=0;)-1!==t.indexOf(e[o])&&e.pop(),o--;if(0===(o=e.length))return null;i>0&&o>r&&(e.splice(r),o=r);for(var a=0;a0||!this.inFocus)&&(this._coolDown--,r=Math.min(r,this._target)),r>this._min&&(r=n[i],r=Math.min(r,this._min)),n[i]=r,this.deltaIndex++,this.deltaIndex>s&&(this.deltaIndex=0);for(var o=0,a=0;athis.nextFpsUpdate&&(this.actualFps=.25*this.framesThisSecond+.75*this.actualFps,this.nextFpsUpdate=t+1e3,this.framesThisSecond=0),this.framesThisSecond++;var h=o/this._target;this.callback(t,o,h),this.lastTime=t},tick:function(){this.step(window.performance.now())},sleep:function(){this.running&&(this.raf.stop(),this.running=!1)},wake:function(t){this.running?this.sleep():t&&(this.startTime+=-this.lastTime+(this.lastTime=window.performance.now())),this.raf.start(this.step.bind(this),this.useRAF),this.running=!0,this.step(window.performance.now())},stop:function(){return this.running=!1,this.started=!1,this.raf.stop(),this},destroy:function(){this.stop(),this.callback=r,this.raf=null,this.game=null}});t.exports=a},function(t,e){var i=0,n=function(t,e,n,s){var r=i-s.y-s.height;t.add(n,e,s.x,r,s.width,s.height)};t.exports=function(t,e,s){var r=t.source[e];t.add("__BASE",e,0,0,r.width,r.height),i=r.height;for(var o=s.split("\n"),a=/^[ ]*(- )*(\w+)+[: ]+(.*)/,h="",l="",u={x:0,y:0,width:0,height:0},c=0;cx||a<-x)&&(a=0),a<0&&(a=x+a),-1!==h&&(x=a+(h+1));for(var C=l,M=l,P=0,E=e.sourceIndex,k=0;kg||c<-g)&&(c=0),c<0&&(c=g+c),-1!==d&&(g=c+(d+1));for(var v=f,y=f,m=0,x=0,w=0;wr&&(m=b-r),T>o&&(x=T-o),t.add(w,e,i+v,s+y,h-m,l-x),(v+=h+p)+h>r&&(v=f,y+=l+p)}return t}},function(t,e,i){var n=i(63);t.exports=function(t,e,i){if(i.frames){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);var r,o=i.frames;for(var a in o){var h=o[a];r=t.add(a,e,h.frame.x,h.frame.y,h.frame.w,h.frame.h),h.trimmed&&r.setTrim(h.sourceSize.w,h.sourceSize.h,h.spriteSourceSize.x,h.spriteSourceSize.y,h.spriteSourceSize.w,h.spriteSourceSize.h),h.rotated&&(r.rotated=!0,r.updateUVsInverted()),r.customData=n(h)}for(var l in i)"frames"!==l&&(Array.isArray(i[l])?t.customData[l]=i[l].slice(0):t.customData[l]=i[l]);return t}console.warn("Invalid Texture Atlas JSON Hash given, missing 'frames' Object")}},function(t,e,i){var n=i(63);t.exports=function(t,e,i){if(i.frames||i.textures){var s=t.source[e];t.add("__BASE",e,0,0,s.width,s.height);for(var r,o=Array.isArray(i.textures)?i.textures[e].frames:i.frames,a=0;a=9&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var i=parseInt(RegExp.$1,10),r=parseInt(RegExp.$2,10);(10===i&&r>=11||i>10)&&(s.dolby=!0)}}catch(t){}return s}()},function(t,e,i){var n=i(92),s=i(118),r={gamepads:!1,mspointer:!1,touch:!1,wheelEvent:null};t.exports=(("ontouchstart"in document.documentElement||navigator.maxTouchPoints&&navigator.maxTouchPoints>=1)&&(r.touch=!0),(navigator.msPointerEnabled||navigator.pointerEnabled)&&(r.mspointer=!0),navigator.getGamepads&&(r.gamepads=!0),n.cocoonJS||("onwheel"in window||s.ie&&"WheelEvent"in window?r.wheelEvent="wheel":"onmousewheel"in window?r.wheelEvent="mousewheel":s.firefox&&"MouseScrollEvent"in window&&(r.wheelEvent="DOMMouseScroll")),r)},function(t,e,i){var n=i(0),s=i(26),r=i(340),o=i(2),a=i(4),h=i(8),l=i(16),u=i(1),c=i(167),d=i(178),f=new n({initialize:function(t){void 0===t&&(t={});this.width=a(t,"width",1024),this.height=a(t,"height",768),this.zoom=a(t,"zoom",1),this.resolution=a(t,"resolution",1),this.parent=a(t,"parent",null),this.scaleMode=a(t,"scaleMode",0),this.expandParent=a(t,"expandParent",!1),this.minWidth=a(t,"minWidth",0),this.maxWidth=a(t,"maxWidth",0),this.minHeight=a(t,"minHeight",0),this.maxHeight=a(t,"maxHeight",0);var e=a(t,"scale",null);e&&(this.width=a(e,"width",this.width),this.height=a(e,"height",this.height),this.zoom=a(e,"zoom",this.zoom),this.resolution=a(e,"resolution",this.resolution),this.parent=a(e,"parent",this.parent),this.scaleMode=a(e,"mode",this.scaleMode),this.expandParent=a(e,"mode",this.expandParent),this.minWidth=a(e,"min.width",this.minWidth),this.maxWidth=a(e,"max.width",this.maxWidth),this.minHeight=a(e,"min.height",this.minHeight),this.maxHeight=a(e,"max.height",this.maxHeight)),this.renderType=a(t,"type",s.AUTO),this.canvas=a(t,"canvas",null),this.context=a(t,"context",null),this.canvasStyle=a(t,"canvasStyle",null),this.sceneConfig=a(t,"scene",null),this.seed=a(t,"seed",[(Date.now()*Math.random()).toString()]),l.RND.init(this.seed),this.gameTitle=a(t,"title",""),this.gameURL=a(t,"url","https://phaser.io"),this.gameVersion=a(t,"version",""),this.autoFocus=a(t,"autoFocus",!0),this.domCreateContainer=a(t,"dom.createContainer",!1),this.domBehindCanvas=a(t,"dom.behindCanvas",!1),this.inputKeyboard=a(t,"input.keyboard",!0),this.inputKeyboardEventTarget=a(t,"input.keyboard.target",window),this.inputMouse=a(t,"input.mouse",!0),this.inputMouseEventTarget=a(t,"input.mouse.target",null),this.inputMouseCapture=a(t,"input.mouse.capture",!0),this.inputTouch=a(t,"input.touch",r.input.touch),this.inputTouchEventTarget=a(t,"input.touch.target",null),this.inputTouchCapture=a(t,"input.touch.capture",!0),this.inputActivePointers=a(t,"input.activePointers",1),this.inputGamepad=a(t,"input.gamepad",!1),this.inputGamepadEventTarget=a(t,"input.gamepad.target",window),this.disableContextMenu=a(t,"disableContextMenu",!1),this.audio=a(t,"audio"),this.hideBanner=!1===a(t,"banner",null),this.hidePhaser=a(t,"banner.hidePhaser",!1),this.bannerTextColor=a(t,"banner.text","#ffffff"),this.bannerBackgroundColor=a(t,"banner.background",["#ff0000","#ffff00","#00ff00","#00ffff","#000000"]),""===this.gameTitle&&this.hidePhaser&&(this.hideBanner=!0),this.fps=a(t,"fps",null);var i=a(t,"render",t);this.autoResize=a(i,"autoResize",!0),this.antialias=a(i,"antialias",!0),this.roundPixels=a(i,"roundPixels",!1),this.pixelArt=a(i,"pixelArt",!1),this.pixelArt&&(this.antialias=!1,this.roundPixels=!0),this.transparent=a(i,"transparent",!1),this.clearBeforeRender=a(i,"clearBeforeRender",!0),this.premultipliedAlpha=a(i,"premultipliedAlpha",!0),this.preserveDrawingBuffer=a(i,"preserveDrawingBuffer",!1),this.failIfMajorPerformanceCaveat=a(i,"failIfMajorPerformanceCaveat",!1),this.powerPreference=a(i,"powerPreference","default"),this.batchSize=a(i,"batchSize",2e3),this.maxLights=a(i,"maxLights",10);var n=a(t,"backgroundColor",0);this.backgroundColor=d(n),0===n&&this.transparent&&(this.backgroundColor.alpha=0),this.preBoot=a(t,"callbacks.preBoot",u),this.postBoot=a(t,"callbacks.postBoot",u),this.physics=a(t,"physics",{}),this.defaultPhysicsSystem=a(this.physics,"default",!1),this.loaderBaseURL=a(t,"loader.baseURL",""),this.loaderPath=a(t,"loader.path",""),this.loaderMaxParallelDownloads=a(t,"loader.maxParallelDownloads",32),this.loaderCrossOrigin=a(t,"loader.crossOrigin",void 0),this.loaderResponseType=a(t,"loader.responseType",""),this.loaderAsync=a(t,"loader.async",!0),this.loaderUser=a(t,"loader.user",""),this.loaderPassword=a(t,"loader.password",""),this.loaderTimeout=a(t,"loader.timeout",0),this.installGlobalPlugins=[],this.installScenePlugins=[];var f=a(t,"plugins",null),p=c.DefaultScene;f&&(Array.isArray(f)?this.defaultPlugins=f:h(f)&&(this.installGlobalPlugins=o(f,"global",[]),this.installScenePlugins=o(f,"scene",[]),Array.isArray(f.default)?p=f.default:Array.isArray(f.defaultMerge)&&(p=p.concat(f.defaultMerge)))),this.defaultPlugins=p;var g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg";this.defaultImage=a(t,"images.default",g+"AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=="),this.missingImage=a(t,"images.missing",g+"CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=="),window&&(window.FORCE_WEBGL?this.renderType=s.WEBGL:window.FORCE_CANVAS&&(this.renderType=s.CANVAS))}});t.exports=f},function(t,e,i){var n=i(169),s=i(381),r=i(379),o=i(24),a=i(0),h=i(903),l=i(898),u=i(123),c=i(891),d=i(340),f=i(344),p=i(11),g=i(338),v=i(15),y=i(331),m=i(329),x=i(325),w=i(318),b=i(878),T=i(877),S=new a({initialize:function(t){this.config=new h(t),this.renderer=null,this.canvas=null,this.context=null,this.isBooted=!1,this.isRunning=!1,this.events=new p,this.anims=new s(this),this.textures=new w(this),this.cache=new r(this),this.registry=new u(this),this.input=new g(this,this.config),this.scene=new m(this,this.config.sceneConfig),this.device=d,this.sound=x.create(this),this.loop=new b(this,this.config.fps),this.plugins=new y(this,this.config),this.pendingDestroy=!1,this.removeCanvas=!1,this.noReturn=!1,this.hasFocus=!1,this.isOver=!0,f(this.boot.bind(this))},boot:function(){v.hasCore("EventEmitter")?(this.isBooted=!0,this.config.preBoot(this),l(this),c(this),n(this.canvas,this.config.parent),this.events.emit("boot"),this.events.once("texturesready",this.texturesReady,this)):console.warn("Aborting. Core Plugins missing.")},texturesReady:function(){this.events.emit("ready"),this.start()},start:function(){this.isRunning=!0,this.config.postBoot(this),this.renderer?this.loop.start(this.step.bind(this)):this.loop.start(this.headlessStep.bind(this)),T(this);var t=this.events;t.on("hidden",this.onHidden,this),t.on("visible",this.onVisible,this),t.on("blur",this.onBlur,this),t.on("focus",this.onFocus,this)},step:function(t,e){if(this.pendingDestroy)return this.runDestroy();var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e);var n=this.renderer;n.preRender(),i.emit("prerender",n,t,e),this.scene.render(n),n.postRender(),i.emit("postrender",n,t,e)},headlessStep:function(t,e){var i=this.events;i.emit("prestep",t,e),i.emit("step",t,e),this.scene.update(t,e),i.emit("poststep",t,e),i.emit("prerender"),i.emit("postrender")},onHidden:function(){this.loop.pause(),this.events.emit("pause")},onVisible:function(){this.loop.resume(),this.events.emit("resume")},onBlur:function(){this.hasFocus=!1,this.loop.blur()},onFocus:function(){this.hasFocus=!0,this.loop.focus()},resize:function(t,e){this.config.width=t,this.config.height=e,this.renderer.resize(t,e),this.input.resize(),this.scene.resize(t,e),this.events.emit("resize",t,e)},destroy:function(t,e){void 0===e&&(e=!1),this.pendingDestroy=!0,this.removeCanvas=t,this.noReturn=e},runDestroy:function(){this.events.emit("destroy"),this.events.removeAllListeners(),this.scene.destroy(),this.renderer&&this.renderer.destroy(),this.removeCanvas&&this.canvas&&(o.remove(this.canvas),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)),this.loop.destroy(),this.pendingDestroy=!1}});t.exports=S},function(t,e,i){var n=i(0),s=i(11),r=i(15),o=new n({Extends:s,initialize:function(){s.call(this)},shutdown:function(){this.removeAllListeners()},destroy:function(){this.removeAllListeners()}});r.register("EventEmitter",o,"events"),t.exports=o},function(t,e,i){t.exports={EventEmitter:i(905)}},function(t,e){var i,n,s=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(t){if(i===setTimeout)return setTimeout(t,0);if((i===r||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:r}catch(t){i=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var h,l=[],u=!1,c=-1;function d(){u&&h&&(u=!1,h.length?l=h.concat(l):c=-1,l.length&&f())}function f(){if(!u){var t=a(d);u=!0;for(var e=l.length;e;){for(h=l,l=[];++c1)for(var i=1;i>16&255,g:t>>8&255,b:255&t,a:255};return t>16777215&&(e.a=t>>>24),e}},function(t,e){t.exports=function(t,e){void 0===e&&(e="none");return["-webkit-","-khtml-","-moz-","-ms-",""].forEach(function(i){t.style[i+"user-select"]=e}),t.style["-webkit-touch-callout"]=e,t.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",t}},function(t,e){t.exports=function(t,e){return void 0===e&&(e="none"),t.style.msTouchAction=e,t.style["ms-touch-action"]=e,t.style["touch-action"]=e,t}},function(t,e,i){t.exports={CanvasInterpolation:i(348),CanvasPool:i(24),Smoothing:i(120),TouchAction:i(917),UserSelect:i(916)}},function(t,e){t.exports=function(t){return t.height*t.originY}},function(t,e){t.exports=function(t){return t.width*t.originX}},function(t,e,i){t.exports={CenterOn:i(411),GetBottom:i(48),GetCenterX:i(75),GetCenterY:i(72),GetLeft:i(46),GetOffsetX:i(920),GetOffsetY:i(919),GetRight:i(44),GetTop:i(42),SetBottom:i(47),SetCenterX:i(74),SetCenterY:i(73),SetLeft:i(45),SetRight:i(43),SetTop:i(41)}},function(t,e,i){var n=i(44),s=i(42),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(46),s=i(42),r=i(47),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)-i),r(t,s(e)-a),t}},function(t,e,i){var n=i(75),s=i(42),r=i(47),o=i(74);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,n(e)+i),r(t,s(e)-a),t}},function(t,e,i){var n=i(44),s=i(42),r=i(45),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)+i),o(t,s(e)-a),t}},function(t,e,i){var n=i(72),s=i(44),r=i(73),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(47),o=i(45);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)+i),r(t,n(e)+a),t}},function(t,e,i){var n=i(46),s=i(42),r=i(43),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,n(e)-i),o(t,s(e)-a),t}},function(t,e,i){var n=i(72),s=i(46),r=i(73),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(46),r=i(47),o=i(43);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),o(t,s(e)-i),r(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(44),r=i(43),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(46),r=i(45),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)-i),o(t,n(e)+a),t}},function(t,e,i){var n=i(48),s=i(75),r=i(74),o=i(41);t.exports=function(t,e,i,a){return void 0===i&&(i=0),void 0===a&&(a=0),r(t,s(e)+i),o(t,n(e)+a),t}},function(t,e,i){t.exports={BottomCenter:i(933),BottomLeft:i(932),BottomRight:i(931),LeftBottom:i(930),LeftCenter:i(929),LeftTop:i(928),RightBottom:i(927),RightCenter:i(926),RightTop:i(925),TopCenter:i(924),TopLeft:i(923),TopRight:i(922)}},function(t,e,i){t.exports={BottomCenter:i(415),BottomLeft:i(414),BottomRight:i(413),Center:i(412),LeftCenter:i(410),QuickSet:i(416),RightCenter:i(409),TopCenter:i(408),TopLeft:i(407),TopRight:i(406)}},function(t,e,i){var n=i(193),s=i(20),r={In:i(935),To:i(934)};r=s(!1,r,n),t.exports=r},function(t,e,i){t.exports={Align:i(936),Bounds:i(921),Canvas:i(918),Color:i(347),Masks:i(909)}},function(t,e,i){var n=i(0),s=i(123),r=i(15),o=new n({Extends:s,initialize:function(t){s.call(this,t,t.sys.events),this.scene=t,this.systems=t.sys,t.sys.events.once("boot",this.boot,this),t.sys.events.on("start",this.start,this)},boot:function(){this.events=this.systems.events,this.events.once("destroy",this.destroy,this)},start:function(){this.events.once("shutdown",this.shutdown,this)},shutdown:function(){this.systems.events.off("shutdown",this.shutdown,this)},destroy:function(){s.prototype.destroy.call(this),this.events.off("start",this.start,this),this.scene=null,this.systems=null}});r.register("DataManagerPlugin",o,"data"),t.exports=o},function(t,e,i){t.exports={DataManager:i(123),DataManagerPlugin:i(938)}},function(t,e,i){var n=i(0),s=i(3),r=new n({initialize:function(t,e){this.active=!1,this.p0=new s(t,e)},getPoint:function(t,e){return void 0===e&&(e=new s),e.copy(this.p0)},getPointAt:function(t,e){return this.getPoint(t,e)},getResolution:function(){return 1},getLength:function(){return 0},toJSON:function(){return{type:"MoveTo",points:[this.p0.x,this.p0.y]}}});t.exports=r},function(t,e,i){var n=i(0),s=i(355),r=i(353),o=i(5),a=i(352),h=i(940),l=i(351),u=i(9),c=i(349),d=i(3),f=new n({initialize:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.name="",this.curves=[],this.cacheLengths=[],this.autoClose=!1,this.startPoint=new d,this._tmpVec2A=new d,this._tmpVec2B=new d,"object"==typeof t?this.fromJSON(t):this.startPoint.set(t,e)},add:function(t){return this.curves.push(t),this},circleTo:function(t,e,i){return void 0===e&&(e=!1),this.ellipseTo(t,t,0,360,e,i)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);return t.equals(e)||this.curves.push(new a(e,t)),this},cubicBezierTo:function(t,e,i,n,r,o){var a,h,l,u=this.getEndPoint();return t instanceof d?(a=t,h=e,l=i):(a=new d(i,n),h=new d(r,o),l=new d(t,e)),this.add(new s(u,a,h,l))},quadraticBezierTo:function(t,e,i,n){var s,r,o=this.getEndPoint();return t instanceof d?(s=t,r=e):(s=new d(i,n),r=new d(t,e)),this.add(new l(o,s,r))},draw:function(t,e){for(var i=0;i0?this.curves[this.curves.length-1].getPoint(1,t):t.copy(this.startPoint),t},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},getPoint:function(t,e){void 0===e&&(e=new d);for(var i=t*this.getLength(),n=this.getCurveLengths(),s=0;s=i){var r=n[s]-i,o=this.curves[s],a=o.getLength(),h=0===a?0:1-r/a;return o.getPointAt(h,e)}s++}return null},getPoints:function(t){void 0===t&&(t=12);for(var e,i=[],n=0;n1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i},getRandomPoint:function(t){return void 0===t&&(t=new d),this.getPoint(Math.random(),t)},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],i=0;i<=t;i++)e.push(this.getPoint(i/t));return this.autoClose&&e.push(e[0]),e},getStartPoint:function(t){return void 0===t&&(t=new d),t.copy(this.startPoint)},lineTo:function(t,e){t instanceof d?this._tmpVec2B.copy(t):this._tmpVec2B.set(t,e);var i=this.getEndPoint(this._tmpVec2A);return this.add(new a([i.x,i.y,this._tmpVec2B.x,this._tmpVec2B.y]))},splineTo:function(t){return t.unshift(this.getEndPoint()),this.add(new c(t))},moveTo:function(t,e){return this.add(new h(t,e))},toJSON:function(){for(var t=[],e=0;e0&&(h.preRender(r,o),t.render(n,e,i,h))}},resetAll:function(){for(var t=0;t=1?1:1/e*(1+(e*t|0))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:.5*(1-Math.cos(Math.PI*t))}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:Math.sin(t*Math.PI/2)}},function(t,e){t.exports=function(t){return 0===t?0:1===t?1:1-Math.cos(t*Math.PI/2)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},function(t,e){t.exports=function(t){return 1- --t*t*t*t}},function(t,e){t.exports=function(t){return t*t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},function(t,e){t.exports=function(t){return t*(2-t)}},function(t,e){t.exports=function(t){return t*t}},function(t,e){t.exports=function(t){return t}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))}},function(t,e){t.exports=function(t){return 1-Math.pow(2,-10*t)}},function(t,e){t.exports=function(t){return Math.pow(2,10*(t-1))-.001}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),(t*=2)<1?e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*-.5:e*Math.pow(2,-10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)*.5+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*t)*Math.sin((t-n)*(2*Math.PI)/i)+1}},function(t,e){t.exports=function(t,e,i){if(void 0===e&&(e=.1),void 0===i&&(i=.1),0===t)return 0;if(1===t)return 1;var n=i/4;return e<1?e=1:n=i*Math.asin(1/e)/(2*Math.PI),-e*Math.pow(2,10*(t-=1))*Math.sin((t-n)*(2*Math.PI)/i)}},function(t,e){t.exports=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},function(t,e){t.exports=function(t){return--t*t*t+1}},function(t,e){t.exports=function(t){return t*t*t}},function(t,e){t.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},function(t,e){t.exports=function(t){return Math.sqrt(1- --t*t)}},function(t,e){t.exports=function(t){return 1-Math.sqrt(1-t*t)}},function(t,e){t.exports=function(t){var e=!1;return t<.5?(t=1-2*t,e=!0):t=2*t-1,t<1/2.75?t*=7.5625*t:t=t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5}},function(t,e){t.exports=function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},function(t,e){t.exports=function(t){return(t=1-t)<1/2.75?1-7.5625*t*t:t<2/2.75?1-(7.5625*(t-=1.5/2.75)*t+.75):t<2.5/2.75?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}},function(t,e){t.exports=function(t,e){void 0===e&&(e=1.70158);var i=1.525*e;return(t*=2)<1?t*t*((i+1)*t-i)*.5:.5*((t-=2)*t*((i+1)*t+i)+2)}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),--t*t*((e+1)*t+e)+1}},function(t,e){t.exports=function(t,e){return void 0===e&&(e=1.70158),t*t*((e+1)*t-e)}},function(t,e,i){var n=i(23),s=i(0),r=i(3),o=i(174),a=new s({initialize:function(t){this.camera=t,this.isRunning=!1,this.duration=0,this.source=new r,this.current=new r,this.destination=new r,this.ease,this.progress=0,this._elapsed=0,this._onUpdate,this._onUpdateScope},start:function(t,e,i,n,s,r,a){void 0===i&&(i=1e3),void 0===n&&(n=o.Linear),void 0===s&&(s=!1),void 0===r&&(r=null),void 0===a&&(a=this.camera.scene);var h=this.camera;return!s&&this.isRunning?h:(this.isRunning=!0,this.duration=i,this.progress=0,this.source.set(h.scrollX,h.scrollY),this.destination.set(t,e),h.getScroll(t,e,this.current),"string"==typeof n&&o.hasOwnProperty(n)?this.ease=o[n]:"function"==typeof n&&(this.ease=n),this._elapsed=0,this._onUpdate=r,this._onUpdateScope=a,this.camera.emit("camerapanstart",this.camera,this,i,t,e),h)},update:function(t,e){if(this.isRunning){this._elapsed+=e;var i=n(this._elapsed/this.duration,0,1);this.progress=i;var s=this.camera;if(this._elapsed0?(this._speedX-=this.dragX*t,this._speedX<0&&(this._speedX=0)):this._speedX<0&&(this._speedX+=this.dragX*t,this._speedX>0&&(this._speedX=0)),this._speedY>0?(this._speedY-=this.dragY*t,this._speedY<0&&(this._speedY=0)):this._speedY<0&&(this._speedY+=this.dragY*t,this._speedY>0&&(this._speedY=0)),this.up&&this.up.isDown?(this._speedY+=this.accelY,this._speedY>this.maxSpeedY&&(this._speedY=this.maxSpeedY)):this.down&&this.down.isDown&&(this._speedY-=this.accelY,this._speedY<-this.maxSpeedY&&(this._speedY=-this.maxSpeedY)),this.left&&this.left.isDown?(this._speedX+=this.accelX,this._speedX>this.maxSpeedX&&(this._speedX=this.maxSpeedX)):this.right&&this.right.isDown&&(this._speedX-=this.accelX,this._speedX<-this.maxSpeedX&&(this._speedX=-this.maxSpeedX)),this.zoomIn&&this.zoomIn.isDown?this._zoom=-this.zoomSpeed:this.zoomOut&&this.zoomOut.isDown?this._zoom=this.zoomSpeed:this._zoom=0,0!==this._speedX&&(e.scrollX-=this._speedX*t|0),0!==this._speedY&&(e.scrollY-=this._speedY*t|0),0!==this._zoom&&(e.zoom+=this._zoom,e.zoom<.1&&(e.zoom=.1))}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){var n=i(0),s=i(4),r=new n({initialize:function(t){this.camera=s(t,"camera",null),this.left=s(t,"left",null),this.right=s(t,"right",null),this.up=s(t,"up",null),this.down=s(t,"down",null),this.zoomIn=s(t,"zoomIn",null),this.zoomOut=s(t,"zoomOut",null),this.zoomSpeed=s(t,"zoomSpeed",.01),this.speedX=0,this.speedY=0;var e=s(t,"speed",null);"number"==typeof e?(this.speedX=e,this.speedY=e):(this.speedX=s(t,"speed.x",0),this.speedY=s(t,"speed.y",0)),this._zoom=0,this.active=null!==this.camera},start:function(){return this.active=null!==this.camera,this},stop:function(){return this.active=!1,this},setCamera:function(t){return this.camera=t,this},update:function(t){if(this.active){void 0===t&&(t=1);var e=this.camera;this.up&&this.up.isDown?e.scrollY-=this.speedY*t|0:this.down&&this.down.isDown&&(e.scrollY+=this.speedY*t|0),this.left&&this.left.isDown?e.scrollX-=this.speedX*t|0:this.right&&this.right.isDown&&(e.scrollX+=this.speedX*t|0),this.zoomIn&&this.zoomIn.isDown?(e.zoom-=this.zoomSpeed,e.zoom<.1&&(e.zoom=.1)):this.zoomOut&&this.zoomOut.isDown&&(e.zoom+=this.zoomSpeed)}},destroy:function(){this.camera=null,this.left=null,this.right=null,this.up=null,this.down=null,this.zoomIn=null,this.zoomOut=null}});t.exports=r},function(t,e,i){t.exports={FixedKeyControl:i(989),SmoothedKeyControl:i(988)}},function(t,e,i){t.exports={Controls:i(990),Scene2D:i(987)}},function(t,e,i){t.exports={BaseCache:i(380),CacheManager:i(379)}},function(t,e,i){t.exports={Animation:i(384),AnimationFrame:i(382),AnimationManager:i(381)}},function(t,e,i){var n=i(53);t.exports=function(t,e,i){void 0===i&&(i=0);for(var s=0;s1)if(0===s){var d=t.length-1;for(o=t[d].x,a=t[d].y,h=d-1;h>=0;h--)l=(c=t[h]).x,u=c.y,c.x=o,c.y=a,o=l,a=u;t[d].x=e,t[d].y=i}else{for(o=t[0].x,a=t[0].y,h=1;h0?s(o,i):i<0&&r(o,Math.abs(i));for(var a=0;a>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,_isTinted:!1,tintFill:!1,clearTint:function(){return this.setTint(16777215),this._isTinted=!1,this},setTint:function(t,e,n,s){return void 0===t&&(t=16777215),void 0===e&&(e=t,n=t,s=t),this._tintTL=i(t),this._tintTR=i(e),this._tintBL=i(n),this._tintBR=i(s),this._isTinted=!0,this.tintFill=!1,this},setTintFill:function(t,e,i,n){return this.setTint(t,e,i,n),this.tintFill=!0,this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=i(t),this._isTinted=!0}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=i(t),this._isTinted=!0}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=i(t),this._isTinted=!0}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=i(t),this._isTinted=!0}},tint:{set:function(t){this.setTint(t,t,t,t)}},isTinted:{get:function(){return this._isTinted}}};t.exports=n},function(t,e){var i={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,n){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,n,this.flipX,this.flipY);else{var s=t;this.frame.setCropUVs(this._crop,s.x,s.y,s.width,s.height,this.flipX,this.flipY)}this.isCropped=!0}return this},setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this.isCropped&&this.frame.updateCropUVs(this._crop,this.flipX,this.flipY),this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=i},function(t,e){var i={texture:null,frame:null,isCropped:!1,setTexture:function(t,e){return this.texture=this.scene.sys.textures.get(t),this.setFrame(e)},setFrame:function(t,e,i){return void 0===e&&(e=!0),void 0===i&&(i=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&e&&this.setSizeToFrame(),this._originComponent&&i&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=i},function(t,e){var i={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}};t.exports=i},function(t,e,i){var n=i(94),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,e){var i={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,e){return void 0===t&&(t=.5),void 0===e&&(e=t),this.originX=t,this.originY=e,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.displayOriginX=t,this.displayOriginY=e,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=i},function(t,e,i){var n=i(9),s=i(396),r=i(3),o={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getTopRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomLeft:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomRight:function(t,e){(t||(t=new r),void 0===e&&(e=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),e&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBounds:function(t){var e,i,s,r,o,a,h,l;if(void 0===t&&(t=new n),this.parentContainer){var u=this.parentContainer.getBoundsTransformMatrix();this.getTopLeft(t),u.transformPoint(t.x,t.y,t),e=t.x,i=t.y,this.getTopRight(t),u.transformPoint(t.x,t.y,t),s=t.x,r=t.y,this.getBottomLeft(t),u.transformPoint(t.x,t.y,t),o=t.x,a=t.y,this.getBottomRight(t),u.transformPoint(t.x,t.y,t),h=t.x,l=t.y}else this.getTopLeft(t),e=t.x,i=t.y,this.getTopRight(t),s=t.x,r=t.y,this.getBottomLeft(t),o=t.x,a=t.y,this.getBottomRight(t),h=t.x,l=t.y;return t.x=Math.min(e,s,o,h),t.y=Math.min(i,r,a,l),t.width=Math.max(e,s,o,h)-t.x,t.height=Math.max(i,r,a,l)-t.y,t}};t.exports=o},function(t,e){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,e){return this.flipX=t,this.flipY=e,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,e){var i={texture:null,frame:null,isCropped:!1,setCrop:function(t,e,i,n){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,e,i,n,this.flipX,this.flipY);else{var s=t;this.frame.setCropUVs(this._crop,s.x,s.y,s.width,s.height,this.flipX,this.flipY)}this.isCropped=!0}return this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=i},function(t,e){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,e){return this.width=t,this.height=e,this},setDisplaySize:function(t,e){return this.displayWidth=t,this.displayHeight=e,this}}},function(t,e,i){var n=i(416),s=i(193),r=i(2),o=i(1),a=new(i(125))({sys:{queueDepthSort:o,events:{once:o}}},0,0,1,1);t.exports=function(t,e){void 0===e&&(e={});var i=r(e,"width",-1),o=r(e,"height",-1),h=r(e,"cellWidth",1),l=r(e,"cellHeight",h),u=r(e,"position",s.TOP_LEFT),c=r(e,"x",0),d=r(e,"y",0),f=0,p=0,g=i*h,v=o*l;a.setPosition(c,d),a.setSize(h,l);for(var y=0;y>>0;if("function"!=typeof t)throw new TypeError;for(var n=arguments.length>=2?arguments[1]:void 0,s=0;s0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionstart",e,i,n)}),d.on(e,"collisionActive",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionactive",e,i,n)}),d.on(e,"collisionEnd",function(e){var i,n,s=e.pairs;s.length>0&&(i=s[0].bodyA,n=s[0].bodyB),t.emit("collisionend",e,i,n)})},setBounds:function(t,e,i,n,s,r,o,a,h){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=this.scene.sys.game.config.width),void 0===n&&(n=this.scene.sys.game.config.height),void 0===s&&(s=128),void 0===r&&(r=!0),void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),this.updateWall(r,"left",t-s,e,s,n),this.updateWall(o,"right",t+i,e,s,n),this.updateWall(a,"top",t,e-s,i,s),this.updateWall(h,"bottom",t,e+n,i,s),this},updateWall:function(t,e,i,n,s,r){var o=this.walls[e];t?(o&&p.remove(this.localWorld,o),i+=s/2,n+=r/2,this.walls[e]=this.create(i,n,s,r,{isStatic:!0,friction:0,frictionStatic:0})):(o&&p.remove(this.localWorld,o),this.walls[e]=null)},createDebugGraphic:function(){var t=this.scene.sys.add.graphics({x:0,y:0});return t.setDepth(Number.MAX_VALUE),this.debugGraphic=t,this.drawDebug=!0,t},disableGravity:function(){return this.localWorld.gravity.x=0,this.localWorld.gravity.y=0,this.localWorld.gravity.scale=0,this},setGravity:function(t,e,i){return void 0===t&&(t=0),void 0===e&&(e=1),this.localWorld.gravity.x=t,this.localWorld.gravity.y=e,void 0!==i&&(this.localWorld.gravity.scale=i),this},create:function(t,e,i,s,r){var o=n.rectangle(t,e,i,s,r);return p.add(this.localWorld,o),o},add:function(t){return p.add(this.localWorld,t),this},remove:function(t,e){var i=t.body?t.body:t;return o.removeBody(this.localWorld,i,e),this},removeConstraint:function(t,e){return o.remove(this.localWorld,t,e),this},convertTilemapLayer:function(t,e){var i=t.layer,n=t.getTilesWithin(0,0,i.width,i.height,{isColliding:!0});return this.convertTiles(n,e),this},convertTiles:function(t,e){if(0===t.length)return this;for(var i=0;i1?1:0;r1?1:0;s0&&u.trigger(t,"collisionStart",{pairs:w.collisionStart}),o.preSolvePosition(w.list),s=0;s0&&u.trigger(t,"collisionActive",{pairs:w.collisionActive}),w.collisionEnd.length>0&&u.trigger(t,"collisionEnd",{pairs:w.collisionEnd}),h.update(t.metrics,t),n._bodiesClearForces(y),u.trigger(t,"afterUpdate",v),t},n.merge=function(t,e){if(f.extend(t,e),e.world){t.world=e.world,n.clear(t);for(var i=c.allBodies(t.world),s=0;sf.friction*f.frictionStatic*O*i&&(B=L,D=o.clamp(f.friction*F*i,-B,B));var I=r.cross(_,y),Y=r.cross(A,y),X=w/(g.inverseMass+v.inverseMass+g.inverseInertia*I*I+v.inverseInertia*Y*Y);if(R*=X,D*=X,E<0&&E*E>n._restingThresh*i)T.normalImpulse=0;else{var z=T.normalImpulse;T.normalImpulse=Math.min(T.normalImpulse+R,0),R=T.normalImpulse-z}if(k*k>n._restingThreshTangent*i)T.tangentImpulse=0;else{var N=T.tangentImpulse;T.tangentImpulse=o.clamp(T.tangentImpulse+D,-B,B),D=T.tangentImpulse-N}s.x=y.x*R+m.x*D,s.y=y.y*R+m.y*D,g.isStatic||g.isSleeping||(g.positionPrev.x+=s.x*g.inverseMass,g.positionPrev.y+=s.y*g.inverseMass,g.anglePrev+=r.cross(_,s)*g.inverseInertia),v.isStatic||v.isSleeping||(v.positionPrev.x-=s.x*v.inverseMass,v.positionPrev.y-=s.y*v.inverseMass,v.anglePrev-=r.cross(A,s)*v.inverseInertia)}}}}},function(t,e,i){var n={};t.exports=n;var s=i(418),r=i(33);n._pairMaxIdleLife=1e3,n.create=function(t){return r.extend({table:{},list:[],collisionStart:[],collisionActive:[],collisionEnd:[]},t)},n.update=function(t,e,i){var n,r,o,a,h=t.list,l=t.table,u=t.collisionStart,c=t.collisionEnd,d=t.collisionActive;for(u.length=0,c.length=0,d.length=0,a=0;an._pairMaxIdleLife&&l.push(o);for(o=0;ou.bounds.max.x||p.bounds.max.yu.bounds.max.y)){var g=n._getRegion(t,p);if(!p.region||g.id!==p.region.id||s){f.broadphaseTests+=1,p.region&&!s||(p.region=g);var v=n._regionUnion(g,p.region);for(o=v.startCol;o<=v.endCol;o++)for(a=v.startRow;a<=v.endRow;a++){h=c[l=n._getBucketId(o,a)];var y=o>=g.startCol&&o<=g.endCol&&a>=g.startRow&&a<=g.endRow,m=o>=p.region.startCol&&o<=p.region.endCol&&a>=p.region.startRow&&a<=p.region.endRow;!y&&m&&m&&h&&n._bucketRemoveBody(t,h,p),(p.region===g||y&&!m||s)&&(h||(h=n._createBucket(c,l)),n._bucketAddBody(t,h,p))}p.region=g,d=!0}}}d&&(t.pairsList=n._createActivePairsList(t))},n.clear=function(t){t.buckets={},t.pairs={},t.pairsList=[]},n._regionUnion=function(t,e){var i=Math.min(t.startCol,e.startCol),s=Math.max(t.endCol,e.endCol),r=Math.min(t.startRow,e.startRow),o=Math.max(t.endRow,e.endRow);return n._createRegion(i,s,r,o)},n._getRegion=function(t,e){var i=e.bounds,s=Math.floor(i.min.x/t.bucketWidth),r=Math.floor(i.max.x/t.bucketWidth),o=Math.floor(i.min.y/t.bucketHeight),a=Math.floor(i.max.y/t.bucketHeight);return n._createRegion(s,r,o,a)},n._createRegion=function(t,e,i,n){return{id:t+","+e+","+i+","+n,startCol:t,endCol:e,startRow:i,endRow:n}},n._getBucketId=function(t,e){return"C"+t+"R"+e},n._createBucket=function(t,e){return t[e]=[]},n._bucketAddBody=function(t,e,i){for(var n=0;n0?n.push(i):delete t.pairs[e[s]];return n}},function(t,e,i){var n={};t.exports=n;var s=i(500),r=i(33);n.name="matter-js",n.version="0.14.2",n.uses=[],n.used=[],n.use=function(){s.use(n,Array.prototype.slice.call(arguments))},n.before=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathBefore(n,t,e)},n.after=function(t,e){return t=t.replace(/^Matter./,""),r.chainPathAfter(n,t,e)}},function(t,e,i){var n=i(427),s=i(0),r=i(419),o=i(19),a=i(2),h=i(186),l=i(61),u=i(3),c=new s({Extends:l,Mixins:[r.Bounce,r.Collision,r.Force,r.Friction,r.Gravity,r.Mass,r.Sensor,r.SetBody,r.Sleep,r.Static,r.Transform,r.Velocity,h],initialize:function(t,e,i,s,r,h){o.call(this,t.scene,"Image"),this.anims=new n(this),this.setTexture(s,r),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new u(e,i);var l=a(h,"shape",null);l?this.setBody(l,h):this.setRectangle(this.width,this.height,h),this.setPosition(e,i),this.initPipeline("TextureTintPipeline")}});t.exports=c},function(t,e,i){var n=i(0),s=i(419),r=i(19),o=i(2),a=i(87),h=i(186),l=i(3),u=new n({Extends:a,Mixins:[s.Bounce,s.Collision,s.Force,s.Friction,s.Gravity,s.Mass,s.Sensor,s.SetBody,s.Sleep,s.Static,s.Transform,s.Velocity,h],initialize:function(t,e,i,n,s,a){r.call(this,t.scene,"Image"),this.setTexture(n,s),this.setSizeToFrame(),this.setOrigin(),this.world=t,this._tempVec2=new l(e,i);var h=o(a,"shape",null);h?this.setBody(h,a):this.setRectangle(this.width,this.height,a),this.setPosition(e,i),this.initPipeline("TextureTintPipeline")}});t.exports=u},function(t,e,i){var n={};t.exports=n;var s=i(137),r=i(194),o=i(33),a=i(67),h=i(126);n.stack=function(t,e,i,n,r,o,h){for(var l,u=s.create({label:"Stack"}),c=t,d=e,f=0,p=0;pg&&(g=m),a.translate(y,{x:.5*x,y:.5*m}),c=y.bounds.max.x+r,s.addBody(u,y),l=y,f+=1}else c+=r}d+=g+o,c=t}return u},n.chain=function(t,e,i,n,a,h){for(var l=t.bodies,u=1;u0)for(l=0;l0&&(d=f[l-1+(h-1)*e],s.addConstraint(t,r.create(o.extend({bodyA:d,bodyB:c},a)))),n&&ld||o<(l=d-l)||o>i-1-l))return 1===c&&a.translate(u,{x:(o+(i%2==1?1:-1))*f,y:0}),h(t+(u?o*f:0)+o*r,n,o,l,u,c)})},n.newtonsCradle=function(t,e,i,n,o){for(var a=s.create({label:"Newtons Cradle"}),l=0;l=0&&h<=1&&l>=0&&l<=1}function s(t,e,i){return(e[0]-t[0])*(i[1]-t[1])-(i[0]-t[0])*(e[1]-t[1])}function r(t,e,i){return s(t,e,i)>0}function o(t,e,i){return s(t,e,i)>=0}function a(t,e,i){return s(t,e,i)<0}function h(t,e,i){return s(t,e,i)<=0}t.exports={decomp:function(t){var e=function t(e){var i=[],n=[],s=[],r=[];var o=Number.MAX_VALUE;for(var a=0;a0?function t(e,i){if(0===i.length)return[e];if(i instanceof Array&&i.length&&i[0]instanceof Array&&2===i[0].length&&i[0][0]instanceof Array){for(var n=[e],s=0;su)return console.warn("quickDecomp: max level ("+u+") reached."),i;for(var F=0;FA&&(A+=e.length),_=Number.MAX_VALUE,A3&&n>=0;--n)c(f(t,n-1),f(t,n),f(t,n+1),e)&&(t.splice(n%t.length,1),i++);return i},removeDuplicatePoints:function(t,e){for(var i=t.length-1;i>=1;--i)for(var n=t[i],s=i-1;s>=0;--s)S(n,t[s],e)&&t.splice(i,1)},makeCCW:function(t){for(var e=0,i=t,n=1;ni[e][0])&&(e=n);return!r(f(t,e-1),f(t,e),f(t,e+1))&&(function(t){for(var e=[],i=t.length,n=0;n!==i;n++)e.push(t.pop());for(var n=0;n!==i;n++)t[n]=e[n]}(t),!0)}};var l=[],u=[];function c(t,e,i,n){if(n){var r=l,o=u;r[0]=e[0]-t[0],r[1]=e[1]-t[1],o[0]=i[0]-e[0],o[1]=i[1]-e[1];var a=r[0]*o[0]+r[1]*o[1],h=Math.sqrt(r[0]*r[0]+r[1]*r[1]),c=Math.sqrt(o[0]*o[0]+o[1]*o[1]);return Math.acos(a/(h*c))r.ACTIVE&&c(this,t,e))},setCollidesNever:function(t){for(var e=0;e1)for(var h=i/a,l=n/a,u=0;u0?r:0,y=n<0?f:0,m=Math.max(Math.floor(i/f),0),x=Math.min(Math.ceil((i+o)/f),g);u=Math.floor((t.pos.x+v)/f);var w=Math.floor((e+v)/f);if((l>0||u===w||w<0||w>=p)&&(w=-1),u>=0&&u1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,w,c));c++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.x=!0,t.tile.x=d,t.pos.x=u*f-v+y,e=t.pos.x,a=0;break}}if(s){var b=s>0?o:0,T=s<0?f:0,S=Math.max(Math.floor(t.pos.x/f),0),_=Math.min(Math.ceil((t.pos.x+r)/f),p);c=Math.floor((t.pos.y+b)/f);var A=Math.floor((i+b)/f);if((l>0||c===A||A<0||A>=g)&&(A=-1),c>=0&&c1&&d<=this.lastSlope&&this.checkDef(t,d,e,i,a,h,r,o,u,A));u++)if(1===(d=this.data[c][u])||d>this.lastSlope||d>1&&this.checkDef(t,d,e,i,a,h,r,o,u,c)){if(d>1&&d<=this.lastSlope&&t.collision.slope)break;t.collision.y=!0,t.tile.y=d,t.pos.y=c*f-b+T;break}}},checkDef:function(t,e,i,n,s,r,o,a,h,l){var u=this.tiledef[e];if(!u)return!1;var c=this.tilesize,d=(h+u[0])*c,f=(l+u[1])*c,p=(u[2]-u[0])*c,g=(u[3]-u[1])*c,v=u[4],y=i+s+(g<0?o:0)-d,m=n+r+(p>0?a:0)-f;if(p*m-g*y>0){if(s*-g+r*p<0)return v;var x=Math.sqrt(p*p+g*g),w=g/x,b=-p/x,T=y*w+m*b,S=w*T,_=b*T;return S*S+_*_>=s*s+r*r?v||p*(m-r)-g*(y-s)<.5:(t.pos.x=i+s-S,t.pos.y=n+r-_,t.collision.slope={x:p,y:g,nx:w,ny:b},!0)}return!1}});t.exports=r},function(t,e,i){var n=i(0),s=i(224),r=i(1124),o=i(223),a=i(1123),h=new n({initialize:function(t,e,i,n,r){void 0===n&&(n=16),void 0===r&&(r=n),this.world=t,this.gameObject=null,this.enabled=!0,this.parent,this.id=t.getNextID(),this.name="",this.size={x:n,y:r},this.offset={x:0,y:0},this.pos={x:e,y:i},this.last={x:e,y:i},this.vel={x:0,y:0},this.accel={x:0,y:0},this.friction={x:0,y:0},this.maxVel={x:t.defaults.maxVelocityX,y:t.defaults.maxVelocityY},this.standing=!1,this.gravityFactor=t.defaults.gravityFactor,this.bounciness=t.defaults.bounciness,this.minBounceVelocity=t.defaults.minBounceVelocity,this.accelGround=0,this.accelAir=0,this.jumpSpeed=0,this.type=o.NONE,this.checkAgainst=o.NONE,this.collides=s.NEVER,this.debugShowBody=t.defaults.debugShowBody,this.debugShowVelocity=t.defaults.debugShowVelocity,this.debugBodyColor=t.defaults.bodyDebugColor,this.updateCallback,this.slopeStanding={min:.767944870877505,max:2.3736477827122884}},reset:function(t,e){this.pos={x:t,y:e},this.last={x:t,y:e},this.vel={x:0,y:0},this.accel={x:0,y:0},this.friction={x:0,y:0},this.maxVel={x:100,y:100},this.standing=!1,this.gravityFactor=1,this.bounciness=0,this.minBounceVelocity=40,this.accelGround=0,this.accelAir=0,this.jumpSpeed=0,this.type=o.NONE,this.checkAgainst=o.NONE,this.collides=s.NEVER},update:function(t){var e=this.pos;this.last.x=e.x,this.last.y=e.y,this.vel.y+=this.world.gravity*t*this.gravityFactor,this.vel.x=r(t,this.vel.x,this.accel.x,this.friction.x,this.maxVel.x),this.vel.y=r(t,this.vel.y,this.accel.y,this.friction.y,this.maxVel.y);var i=this.vel.x*t,n=this.vel.y*t,s=this.world.collisionMap.trace(e.x,e.y,i,n,this.size.x,this.size.y);this.handleMovementTrace(s)&&a(this,s);var o=this.gameObject;o&&(o.x=e.x-this.offset.x+o.displayOriginX*o.scaleX,o.y=e.y-this.offset.y+o.displayOriginY*o.scaleY),this.updateCallback&&this.updateCallback(this)},drawDebug:function(t){var e=this.pos;if(this.debugShowBody&&(t.lineStyle(1,this.debugBodyColor,1),t.strokeRect(e.x,e.y,this.size.x,this.size.y)),this.debugShowVelocity){var i=e.x+this.size.x/2,n=e.y+this.size.y/2;t.lineStyle(1,this.world.defaults.velocityDebugColor,1),t.lineBetween(i,n,i+this.vel.x,n+this.vel.y)}},willDrawDebug:function(){return this.debugShowBody||this.debugShowVelocity},skipHash:function(){return!this.enabled||0===this.type&&0===this.checkAgainst&&0===this.collides},touches:function(t){return!(this.pos.x>=t.pos.x+t.size.x||this.pos.x+this.size.x<=t.pos.x||this.pos.y>=t.pos.y+t.size.y||this.pos.y+this.size.y<=t.pos.y)},resetSize:function(t,e,i,n){return this.pos.x=t,this.pos.y=e,this.size.x=i,this.size.y=n,this},toJSON:function(){return{name:this.name,size:{x:this.size.x,y:this.size.y},pos:{x:this.pos.x,y:this.pos.y},vel:{x:this.vel.x,y:this.vel.y},accel:{x:this.accel.x,y:this.accel.y},friction:{x:this.friction.x,y:this.friction.y},maxVel:{x:this.maxVel.x,y:this.maxVel.y},gravityFactor:this.gravityFactor,bounciness:this.bounciness,minBounceVelocity:this.minBounceVelocity,type:this.type,checkAgainst:this.checkAgainst,collides:this.collides}},fromJSON:function(){},check:function(){},collideWith:function(t,e){this.parent&&this.parent._collideCallback&&this.parent._collideCallback.call(this.parent._callbackScope,this,t,e)},handleMovementTrace:function(){return!0},destroy:function(){this.world.remove(this),this.enabled=!1,this.world=null,this.gameObject=null,this.parent=null}});t.exports=h},,function(t,e,i){t.exports={BitmapMaskPipeline:i(421),ForwardDiffuseLightPipeline:i(420),TextureTintPipeline:i(196)}},function(t,e,i){t.exports={Utils:i(10),WebGLPipeline:i(197),WebGLRenderer:i(423),Pipelines:i(1079),BYTE:0,SHORT:1,UNSIGNED_BYTE:2,UNSIGNED_SHORT:3,FLOAT:4}},function(t,e,i){t.exports={Canvas:i(425),WebGL:i(422)}},function(t,e,i){t.exports={CanvasRenderer:i(426),GetBlendModes:i(424),SetTransform:i(22)}},function(t,e,i){t.exports={Canvas:i(1082),Snapshot:i(1081),WebGL:i(1080)}},function(t,e,i){var n=i(501),s={name:"matter-wrap",version:"0.1.4",for:"matter-js@^0.13.1",silent:!0,install:function(t){t.after("Engine.update",function(){s.Engine.update(this)})},Engine:{update:function(t){for(var e=t.world,i=n.Composite.allBodies(e),r=n.Composite.allComposites(e),o=0;oe.max.x?i=e.min.x-t.max.x:t.max.xe.max.y?n=e.min.y-t.max.y:t.max.y0)for(var a=s+1;a1;if(!d||t!=d.x||e!=d.y){d&&n?(f=d.x,p=d.y):(f=0,p=0);var s={x:f+t,y:p+e};!n&&d||(d=s),g.push(s),y=f+t,m=p+e}},w=function(t){var e=t.pathSegTypeAsLetter.toUpperCase();if("Z"!==e){switch(e){case"M":case"L":case"T":case"C":case"S":case"Q":y=t.x,m=t.y;break;case"H":y=t.x;break;case"V":m=t.y}x(y,m,t.pathSegType)}};for(n._svgPathToAbsolute(t),o=t.getTotalLength(),l=[],i=0;i1?1:0;n0))r=t.collisionMap.trace(e.pos.x,e.pos.y,0,-(e.pos.y+e.size.y-i.pos.y),e.size.x,e.size.y),e.pos.y=r.pos.y,e.bounciness>0&&e.vel.y>e.minBounceVelocity?e.vel.y*=-e.bounciness:(e.standing=!0,e.vel.y=0);else{var l=(e.vel.y-i.vel.y)/2;e.vel.y=-l,i.vel.y=l,s=i.vel.x*t.delta,r=t.collisionMap.trace(e.pos.x,e.pos.y,s,-o/2,e.size.x,e.size.y),e.pos.y=r.pos.y;var u=t.collisionMap.trace(i.pos.x,i.pos.y,0,o/2,i.size.x,i.size.y);i.pos.y=u.pos.y}}},function(t,e){t.exports=function(t,e,i,n){var s=e.pos.x+e.size.x-i.pos.x;if(n){var r=e===n?i:e;n.vel.x=-n.vel.x*n.bounciness+r.vel.x;var o=t.collisionMap.trace(n.pos.x,n.pos.y,n===e?-s:s,0,n.size.x,n.size.y);n.pos.x=o.pos.x}else{var a=(e.vel.x-i.vel.x)/2;e.vel.x=-a,i.vel.x=a;var h=t.collisionMap.trace(e.pos.x,e.pos.y,-s/2,0,e.size.x,e.size.y);e.pos.x=Math.floor(h.pos.x);var l=t.collisionMap.trace(i.pos.x,i.pos.y,s/2,0,i.size.x,i.size.y);i.pos.x=Math.ceil(l.pos.x)}}},function(t,e,i){var n=i(224),s=i(1107),r=i(1106);t.exports=function(t,e,i){var o=null;e.collides===n.LITE||i.collides===n.FIXED?o=e:i.collides!==n.LITE&&e.collides!==n.FIXED||(o=i),e.last.x+e.size.x>i.last.x&&e.last.xi.last.y&&e.last.y0&&Math.abs(t.vel.y)>t.minBounceVelocity?t.vel.y*=-t.bounciness:(t.vel.y>0&&(t.standing=!0),t.vel.y=0)),e.collision.x&&(t.bounciness>0&&Math.abs(t.vel.x)>t.minBounceVelocity?t.vel.x*=-t.bounciness:t.vel.x=0),e.collision.slope){var i=e.collision.slope;if(t.bounciness>0){var n=t.vel.x*i.nx+t.vel.y*i.ny;t.vel.x=(t.vel.x-i.nx*n*2)*t.bounciness,t.vel.y=(t.vel.y-i.ny*n*2)*t.bounciness}else{var s=i.x*i.x+i.y*i.y,r=(t.vel.x*i.x+t.vel.y*i.y)/s;t.vel.x=i.x*r,t.vel.y=i.y*r;var o=Math.atan2(i.x,i.y);o>t.slopeStanding.min&&o0?e-o:e+o<0?e+o:0}return n(e,-r,r)}},function(t,e,i){t.exports={Body:i(1077),COLLIDES:i(224),CollisionMap:i(1076),Factory:i(1075),Image:i(1073),ImpactBody:i(1074),ImpactPhysics:i(1109),Sprite:i(1072),TYPE:i(223),World:i(1071)}},function(t,e,i){t.exports={Arcade:i(528),Impact:i(1125),Matter:i(1105)}},function(t,e,i){(function(e){i(1059);var n=i(26),s=i(20),r={Actions:i(417),Animation:i(993),Cache:i(992),Cameras:i(991),Class:i(0),Create:i(948),Curves:i(942),Data:i(939),Display:i(937),DOM:i(908),Events:i(906),Game:i(904),GameObjects:i(876),Geom:i(274),Input:i(616),Loader:i(593),Math:i(570),Physics:i(1126),Plugins:i(498),Renderer:i(1083),Scene:i(328),Scenes:i(496),Sound:i(494),Structs:i(493),Textures:i(492),Tilemaps:i(490),Time:i(441),Tweens:i(439),Utils:i(435)};r=s(!1,r,n),t.exports=r,e.Phaser=r}).call(this,i(200))}])}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 141074c16..782af1140 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,189 +1,193 @@ { "name": "phaser", - "version": "3.11.0-beta1", + "version": "3.16.0", "lockfileVersion": 1, "requires": true, "dependencies": { - "@mrmlnc/readdir-enhanced": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", - "integrity": "sha1-UkryQNGjYFJ7cwR17PoTRKpUDd4=", - "dev": true, - "requires": { - "call-me-maybe": "^1.0.1", - "glob-to-regexp": "^0.3.0" - } - }, - "@nodelib/fs.stat": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.0.2.tgz", - "integrity": "sha512-vCpf75JDcdomXvUd7Rn6DfYAVqPAFI66FVjxiWGwh85OLdvfo3paBoPJaam5keIYRyUolnS7SleS/ZPCidCvzw==", - "dev": true - }, - "@sindresorhus/is": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.7.0.tgz", - "integrity": "sha1-mgb08TfuhNffBGDB/bETX/psUP0=", - "dev": true - }, "@webassemblyjs/ast": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.4.3.tgz", - "integrity": "sha512-S6npYhPcTHDYe9nlsKa9CyWByFi8Vj8HovcAgtmMAQZUOczOZbQ8CnwMYKYC5HEZzxEE+oY0jfQk4cVlI3J59Q==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.10.tgz", + "integrity": "sha512-wTUeaByYN2EA6qVqhbgavtGc7fLTOx0glG2IBsFlrFG51uXIGlYBTyIZMf4SPLo3v1bgV/7lBN3l7Z0R6Hswew==", "dev": true, "requires": { - "@webassemblyjs/helper-wasm-bytecode": "1.4.3", - "@webassemblyjs/wast-parser": "1.4.3", - "debug": "^3.1.0", - "webassemblyjs": "1.4.3" + "@webassemblyjs/helper-module-context": "1.7.10", + "@webassemblyjs/helper-wasm-bytecode": "1.7.10", + "@webassemblyjs/wast-parser": "1.7.10" } }, "@webassemblyjs/floating-point-hex-parser": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.4.3.tgz", - "integrity": "sha512-3zTkSFswwZOPNHnzkP9ONq4bjJSeKVMcuahGXubrlLmZP8fmTIJ58dW7h/zOVWiFSuG2em3/HH3BlCN7wyu9Rw==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.10.tgz", + "integrity": "sha512-gMsGbI6I3p/P1xL2UxqhNh1ga2HCsx5VBB2i5VvJFAaqAjd2PBTRULc3BpTydabUQEGlaZCzEUQhLoLG7TvEYQ==", + "dev": true + }, + "@webassemblyjs/helper-api-error": { + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.10.tgz", + "integrity": "sha512-DoYRlPWtuw3yd5BOr9XhtrmB6X1enYF0/54yNvQWGXZEPDF5PJVNI7zQ7gkcKfTESzp8bIBWailaFXEK/jjCsw==", "dev": true }, "@webassemblyjs/helper-buffer": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.4.3.tgz", - "integrity": "sha512-e8+KZHh+RV8MUvoSRtuT1sFXskFnWG9vbDy47Oa166xX+l0dD5sERJ21g5/tcH8Yo95e9IN3u7Jc3NbhnUcSkw==", - "dev": true, - "requires": { - "debug": "^3.1.0" - } + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.10.tgz", + "integrity": "sha512-+RMU3dt/dPh4EpVX4u5jxsOlw22tp3zjqE0m3ftU2tsYxnPULb4cyHlgaNd2KoWuwasCQqn8Mhr+TTdbtj3LlA==", + "dev": true }, "@webassemblyjs/helper-code-frame": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.4.3.tgz", - "integrity": "sha512-9FgHEtNsZQYaKrGCtsjswBil48Qp1agrzRcPzCbQloCoaTbOXLJ9IRmqT+uEZbenpULLRNFugz3I4uw18hJM8w==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.10.tgz", + "integrity": "sha512-UiytbpKAULOEab2hUZK2ywXen4gWJVrgxtwY3Kn+eZaaSWaRM8z/7dAXRSoamhKFiBh1uaqxzE/XD9BLlug3gw==", "dev": true, "requires": { - "@webassemblyjs/wast-printer": "1.4.3" + "@webassemblyjs/wast-printer": "1.7.10" } }, "@webassemblyjs/helper-fsm": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.4.3.tgz", - "integrity": "sha512-JINY76U+702IRf7ePukOt037RwmtH59JHvcdWbTTyHi18ixmQ+uOuNhcdCcQHTquDAH35/QgFlp3Y9KqtyJsCQ==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.10.tgz", + "integrity": "sha512-w2vDtUK9xeSRtt5+RnnlRCI7wHEvLjF0XdnxJpgx+LJOvklTZPqWkuy/NhwHSLP19sm9H8dWxKeReMR7sCkGZA==", + "dev": true + }, + "@webassemblyjs/helper-module-context": { + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.10.tgz", + "integrity": "sha512-yE5x/LzZ3XdPdREmJijxzfrf+BDRewvO0zl8kvORgSWmxpRrkqY39KZSq6TSgIWBxkK4SrzlS3BsMCv2s1FpsQ==", "dev": true }, "@webassemblyjs/helper-wasm-bytecode": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.4.3.tgz", - "integrity": "sha512-I7bS+HaO0K07Io89qhJv+z1QipTpuramGwUSDkwEaficbSvCcL92CUZEtgykfNtk5wb0CoLQwWlmXTwGbNZUeQ==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.10.tgz", + "integrity": "sha512-u5qy4SJ/OrxKxZqJ9N3qH4ZQgHaAzsopsYwLvoWJY6Q33r8PhT3VPyNMaJ7ZFoqzBnZlCcS/0f4Sp8WBxylXfg==", "dev": true }, "@webassemblyjs/helper-wasm-section": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.4.3.tgz", - "integrity": "sha512-p0yeeO/h2r30PyjnJX9xXSR6EDcvJd/jC6xa/Pxg4lpfcNi7JUswOpqDToZQ55HMMVhXDih/yqkaywHWGLxqyQ==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.10.tgz", + "integrity": "sha512-Ecvww6sCkcjatcyctUrn22neSJHLN/TTzolMGG/N7S9rpbsTZ8c6Bl98GpSpV77EvzNijiNRHBG0+JO99qKz6g==", "dev": true, "requires": { - "@webassemblyjs/ast": "1.4.3", - "@webassemblyjs/helper-buffer": "1.4.3", - "@webassemblyjs/helper-wasm-bytecode": "1.4.3", - "@webassemblyjs/wasm-gen": "1.4.3", - "debug": "^3.1.0" + "@webassemblyjs/ast": "1.7.10", + "@webassemblyjs/helper-buffer": "1.7.10", + "@webassemblyjs/helper-wasm-bytecode": "1.7.10", + "@webassemblyjs/wasm-gen": "1.7.10" + } + }, + "@webassemblyjs/ieee754": { + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.7.10.tgz", + "integrity": "sha512-HRcWcY+YWt4+s/CvQn+vnSPfRaD4KkuzQFt5MNaELXXHSjelHlSEA8ZcqT69q0GTIuLWZ6JaoKar4yWHVpZHsQ==", + "dev": true, + "requires": { + "@xtuc/ieee754": "^1.2.0" } }, "@webassemblyjs/leb128": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.4.3.tgz", - "integrity": "sha512-4u0LJLSPzuRDWHwdqsrThYn+WqMFVqbI2ltNrHvZZkzFPO8XOZ0HFQ5eVc4jY/TNHgXcnwrHjONhPGYuuf//KQ==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.7.10.tgz", + "integrity": "sha512-og8MciYlA8hvzCLR71hCuZKPbVBfLQeHv7ImKZ4nlyxrYbG7uJHYtHiHu6OV9SqrGuD03H/HtXC4Bgdjfm9FHw==", "dev": true, "requires": { - "leb": "^0.3.0" + "@xtuc/long": "4.2.1" } }, - "@webassemblyjs/validation": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/validation/-/validation-1.4.3.tgz", - "integrity": "sha512-R+rRMKfhd9mq0rj2mhU9A9NKI2l/Rw65vIYzz4lui7eTKPcCu1l7iZNi4b9Gen8D42Sqh/KGiaQNk/x5Tn/iBQ==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.4.3" - } + "@webassemblyjs/utf8": { + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.7.10.tgz", + "integrity": "sha512-Ng6Pxv6siyZp635xCSnH3mKmIFgqWPCcGdoo0GBYgyGdxu7cUj4agV7Uu1a8REP66UYUFXJLudeGgd4RvuJAnQ==", + "dev": true }, "@webassemblyjs/wasm-edit": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.4.3.tgz", - "integrity": "sha512-qzuwUn771PV6/LilqkXcS0ozJYAeY/OKbXIWU3a8gexuqb6De2p4ya/baBeH5JQ2WJdfhWhSvSbu86Vienttpw==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.10.tgz", + "integrity": "sha512-e9RZFQlb+ZuYcKRcW9yl+mqX/Ycj9+3/+ppDI8nEE/NCY6FoK8f3dKBcfubYV/HZn44b+ND4hjh+4BYBt+sDnA==", "dev": true, "requires": { - "@webassemblyjs/ast": "1.4.3", - "@webassemblyjs/helper-buffer": "1.4.3", - "@webassemblyjs/helper-wasm-bytecode": "1.4.3", - "@webassemblyjs/helper-wasm-section": "1.4.3", - "@webassemblyjs/wasm-gen": "1.4.3", - "@webassemblyjs/wasm-opt": "1.4.3", - "@webassemblyjs/wasm-parser": "1.4.3", - "@webassemblyjs/wast-printer": "1.4.3", - "debug": "^3.1.0" + "@webassemblyjs/ast": "1.7.10", + "@webassemblyjs/helper-buffer": "1.7.10", + "@webassemblyjs/helper-wasm-bytecode": "1.7.10", + "@webassemblyjs/helper-wasm-section": "1.7.10", + "@webassemblyjs/wasm-gen": "1.7.10", + "@webassemblyjs/wasm-opt": "1.7.10", + "@webassemblyjs/wasm-parser": "1.7.10", + "@webassemblyjs/wast-printer": "1.7.10" } }, "@webassemblyjs/wasm-gen": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.4.3.tgz", - "integrity": "sha512-eR394T8dHZfpLJ7U/Z5pFSvxl1L63JdREebpv9gYc55zLhzzdJPAuxjBYT4XqevUdW67qU2s0nNA3kBuNJHbaQ==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.10.tgz", + "integrity": "sha512-M0lb6cO2Y0PzDye/L39PqwV+jvO+2YxEG5ax+7dgq7EwXdAlpOMx1jxyXJTScQoeTpzOPIb+fLgX/IkLF8h2yw==", "dev": true, "requires": { - "@webassemblyjs/ast": "1.4.3", - "@webassemblyjs/helper-wasm-bytecode": "1.4.3", - "@webassemblyjs/leb128": "1.4.3" + "@webassemblyjs/ast": "1.7.10", + "@webassemblyjs/helper-wasm-bytecode": "1.7.10", + "@webassemblyjs/ieee754": "1.7.10", + "@webassemblyjs/leb128": "1.7.10", + "@webassemblyjs/utf8": "1.7.10" } }, "@webassemblyjs/wasm-opt": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.4.3.tgz", - "integrity": "sha512-7Gp+nschuKiDuAL1xmp4Xz0rgEbxioFXw4nCFYEmy+ytynhBnTeGc9W9cB1XRu1w8pqRU2lbj2VBBA4cL5Z2Kw==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.10.tgz", + "integrity": "sha512-R66IHGCdicgF5ZliN10yn5HaC7vwYAqrSVJGjtJJQp5+QNPBye6heWdVH/at40uh0uoaDN/UVUfXK0gvuUqtVg==", "dev": true, "requires": { - "@webassemblyjs/ast": "1.4.3", - "@webassemblyjs/helper-buffer": "1.4.3", - "@webassemblyjs/wasm-gen": "1.4.3", - "@webassemblyjs/wasm-parser": "1.4.3", - "debug": "^3.1.0" + "@webassemblyjs/ast": "1.7.10", + "@webassemblyjs/helper-buffer": "1.7.10", + "@webassemblyjs/wasm-gen": "1.7.10", + "@webassemblyjs/wasm-parser": "1.7.10" } }, "@webassemblyjs/wasm-parser": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.4.3.tgz", - "integrity": "sha512-KXBjtlwA3BVukR/yWHC9GF+SCzBcgj0a7lm92kTOaa4cbjaTaa47bCjXw6cX4SGQpkncB9PU2hHGYVyyI7wFRg==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.10.tgz", + "integrity": "sha512-AEv8mkXVK63n/iDR3T693EzoGPnNAwKwT3iHmKJNBrrALAhhEjuPzo/lTE4U7LquEwyvg5nneSNdTdgrBaGJcA==", "dev": true, "requires": { - "@webassemblyjs/ast": "1.4.3", - "@webassemblyjs/helper-wasm-bytecode": "1.4.3", - "@webassemblyjs/leb128": "1.4.3", - "@webassemblyjs/wasm-parser": "1.4.3", - "webassemblyjs": "1.4.3" + "@webassemblyjs/ast": "1.7.10", + "@webassemblyjs/helper-api-error": "1.7.10", + "@webassemblyjs/helper-wasm-bytecode": "1.7.10", + "@webassemblyjs/ieee754": "1.7.10", + "@webassemblyjs/leb128": "1.7.10", + "@webassemblyjs/utf8": "1.7.10" } }, "@webassemblyjs/wast-parser": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.4.3.tgz", - "integrity": "sha512-QhCsQzqV0CpsEkRYyTzQDilCNUZ+5j92f+g35bHHNqS22FppNTywNFfHPq8ZWZfYCgbectc+PoghD+xfzVFh1Q==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.7.10.tgz", + "integrity": "sha512-YTPEtOBljkCL0VjDp4sHe22dAYSm3ZwdJ9+2NTGdtC7ayNvuip1wAhaAS8Zt9Q6SW9E5Jf5PX7YE3XWlrzR9cw==", "dev": true, "requires": { - "@webassemblyjs/ast": "1.4.3", - "@webassemblyjs/floating-point-hex-parser": "1.4.3", - "@webassemblyjs/helper-code-frame": "1.4.3", - "@webassemblyjs/helper-fsm": "1.4.3", - "long": "^3.2.0", - "webassemblyjs": "1.4.3" + "@webassemblyjs/ast": "1.7.10", + "@webassemblyjs/floating-point-hex-parser": "1.7.10", + "@webassemblyjs/helper-api-error": "1.7.10", + "@webassemblyjs/helper-code-frame": "1.7.10", + "@webassemblyjs/helper-fsm": "1.7.10", + "@xtuc/long": "4.2.1" } }, "@webassemblyjs/wast-printer": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.4.3.tgz", - "integrity": "sha512-EgXk4anf8jKmuZJsqD8qy5bz2frEQhBvZruv+bqwNoLWUItjNSFygk8ywL3JTEz9KtxTlAmqTXNrdD1d9gNDtg==", + "version": "1.7.10", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.7.10.tgz", + "integrity": "sha512-mJ3QKWtCchL1vhU/kZlJnLPuQZnlDOdZsyP0bbLWPGdYsQDnSBvyTLhzwBA3QAMlzEL9V4JHygEmK6/OTEyytA==", "dev": true, "requires": { - "@webassemblyjs/ast": "1.4.3", - "@webassemblyjs/wast-parser": "1.4.3", - "long": "^3.2.0" + "@webassemblyjs/ast": "1.7.10", + "@webassemblyjs/wast-parser": "1.7.10", + "@xtuc/long": "4.2.1" } }, + "@xtuc/ieee754": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", + "dev": true + }, + "@xtuc/long": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.1.tgz", + "integrity": "sha512-FZdkNBDqBRHKQ2MEbSC17xnPFOhZxeJ2YGSfr2BKf3sujG49Qe3bB+rGCwQfIaA7WHnGeGkSijX4FuBCdrzW/g==", + "dev": true + }, "acorn": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", @@ -193,7 +197,7 @@ "acorn-dynamic-import": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz", - "integrity": "sha1-kBzu5Mf6rvfgetKkfokGddpQong=", + "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==", "dev": true, "requires": { "acorn": "^5.0.0" @@ -252,16 +256,10 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, - "any-observable": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/any-observable/-/any-observable-0.2.0.tgz", - "integrity": "sha1-xnhwBYADV5AJCD9UrAq6+1wz0kI=", - "dev": true - }, "anymatch": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha1-vLJLTzeTTZqnrBe0ra+J58du8us=", + "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", "dev": true, "requires": { "micromatch": "^3.1.4", @@ -271,7 +269,7 @@ "aproba": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo=", + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true }, "argparse": { @@ -292,7 +290,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { @@ -301,12 +299,6 @@ "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", "dev": true }, - "array-differ": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", - "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", - "dev": true - }, "array-union": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", @@ -343,7 +335,7 @@ "asn1.js": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha1-ucK/WAXx5kqt7tbfOiv6+1pz9aA=", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", "dev": true, "requires": { "bn.js": "^4.0.0", @@ -358,6 +350,23 @@ "dev": true, "requires": { "util": "0.10.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "requires": { + "inherits": "2.0.1" + } + } } }, "assign-symbols": { @@ -366,18 +375,6 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, - "ast-types": { - "version": "0.11.3", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.11.3.tgz", - "integrity": "sha1-wgdX/nLucSeOoP89h+XCyjDZ7fg=", - "dev": true - }, - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - }, "async-each": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", @@ -385,9 +382,9 @@ "dev": true }, "atob": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.0.tgz", - "integrity": "sha512-SuiKH8vbsOyCALjA/+EINmt/Kdl+TQPrtFgW7XZZcwtryFu9e5kQoX3bjCW6mIvGH1fbeAZZuvwGR5IlBRznGw==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", + "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", "dev": true }, "babel-code-frame": { @@ -425,854 +422,6 @@ } } }, - "babel-core": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-6.26.0.tgz", - "integrity": "sha1-rzL3izGm/O8RnIew/Y2XU/A6C7g=", - "dev": true, - "requires": { - "babel-code-frame": "^6.26.0", - "babel-generator": "^6.26.0", - "babel-helpers": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-register": "^6.26.0", - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "convert-source-map": "^1.5.0", - "debug": "^2.6.8", - "json5": "^0.5.1", - "lodash": "^4.17.4", - "minimatch": "^3.0.4", - "path-is-absolute": "^1.0.1", - "private": "^0.1.7", - "slash": "^1.0.0", - "source-map": "^0.5.6" - }, - "dependencies": { - "babylon": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha1-ry87iPpvXB5MY00aD46sT1WzleM=", - "dev": true - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } - } - }, - "babel-generator": { - "version": "6.26.1", - "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", - "integrity": "sha1-GERAjTuPDTWkBOp6wYDwh6YBvZA=", - "dev": true, - "requires": { - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "detect-indent": "^4.0.0", - "jsesc": "^1.3.0", - "lodash": "^4.17.4", - "source-map": "^0.5.7", - "trim-right": "^1.0.1" - }, - "dependencies": { - "jsesc": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", - "integrity": "sha1-RsP+yMGJKxKwgz25vHYiF226s0s=", - "dev": true - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } - } - }, - "babel-helper-bindify-decorators": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-bindify-decorators/-/babel-helper-bindify-decorators-6.24.1.tgz", - "integrity": "sha1-FMGeXxQte0fxmlJDHlKxzLxAozA=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-builder-binary-assignment-operator-visitor": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz", - "integrity": "sha1-zORReto1b0IgvK6KAsKzRvmlZmQ=", - "dev": true, - "requires": { - "babel-helper-explode-assignable-expression": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-helper-call-delegate": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz", - "integrity": "sha1-7Oaqzdx25Bw0YfiL/Fdb0Nqi340=", - "dev": true, - "requires": { - "babel-helper-hoist-variables": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-define-map": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz", - "integrity": "sha1-pfVtq0GiX5fstJjH66ypgZ+Vvl8=", - "dev": true, - "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" - } - }, - "babel-helper-explode-assignable-expression": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz", - "integrity": "sha1-8luCz33BBDPFX3BZLVdGQArCLKo=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-explode-class": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-explode-class/-/babel-helper-explode-class-6.24.1.tgz", - "integrity": "sha1-fcKjkQ3uAHBW4eMdZAztPVTqqes=", - "dev": true, - "requires": { - "babel-helper-bindify-decorators": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-function-name": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", - "integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", - "dev": true, - "requires": { - "babel-helper-get-function-arity": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-get-function-arity": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", - "integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-helper-hoist-variables": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz", - "integrity": "sha1-HssnaJydJVE+rbyZFKc/VAi+enY=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-helper-optimise-call-expression": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz", - "integrity": "sha1-96E0J7qfc/j0+pk8VKl4gtEkQlc=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-helper-regex": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz", - "integrity": "sha1-MlxZ+QL4LyS3T6zu0DY5VPZJXnI=", - "dev": true, - "requires": { - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" - } - }, - "babel-helper-remap-async-to-generator": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz", - "integrity": "sha1-XsWBgnrXI/7N04HxySg5BnbkVRs=", - "dev": true, - "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helper-replace-supers": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz", - "integrity": "sha1-v22/5Dk40XNpohPKiov3S2qQqxo=", - "dev": true, - "requires": { - "babel-helper-optimise-call-expression": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-helpers": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-helpers/-/babel-helpers-6.24.1.tgz", - "integrity": "sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-messages": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", - "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-check-es2015-constants": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", - "integrity": "sha1-NRV7EBQm/S/9PaP3XH0ekYNbv4o=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-syntax-async-functions": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", - "integrity": "sha1-ytnK0RkbWtY0vzCuCHI5HgZHvpU=", - "dev": true - }, - "babel-plugin-syntax-async-generators": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-generators/-/babel-plugin-syntax-async-generators-6.13.0.tgz", - "integrity": "sha1-a8lj67FuzLrmuStZbrfzXDQqi5o=", - "dev": true - }, - "babel-plugin-syntax-class-constructor-call": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-class-constructor-call/-/babel-plugin-syntax-class-constructor-call-6.18.0.tgz", - "integrity": "sha1-nLnTn+Q8hgC+yBRkVt3L1OGnZBY=", - "dev": true - }, - "babel-plugin-syntax-class-properties": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz", - "integrity": "sha1-1+sjt5oxf4VDlixQW4J8fWysJ94=", - "dev": true - }, - "babel-plugin-syntax-decorators": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz", - "integrity": "sha1-MSVjtNvePMgGzuPkFszurd0RrAs=", - "dev": true - }, - "babel-plugin-syntax-dynamic-import": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-dynamic-import/-/babel-plugin-syntax-dynamic-import-6.18.0.tgz", - "integrity": "sha1-jWomIpyDdFqZgqRBBRVyyqF5sdo=", - "dev": true - }, - "babel-plugin-syntax-exponentiation-operator": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz", - "integrity": "sha1-nufoM3KQ2pUoggGmpX9BcDF4MN4=", - "dev": true - }, - "babel-plugin-syntax-export-extensions": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-export-extensions/-/babel-plugin-syntax-export-extensions-6.13.0.tgz", - "integrity": "sha1-cKFITw+QiaToStRLrDU8lbmxJyE=", - "dev": true - }, - "babel-plugin-syntax-flow": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.18.0.tgz", - "integrity": "sha1-TDqyCiryaqIM0lmVw5jE63AxDI0=", - "dev": true - }, - "babel-plugin-syntax-object-rest-spread": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz", - "integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=", - "dev": true - }, - "babel-plugin-syntax-trailing-function-commas": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz", - "integrity": "sha1-ugNgk3+NBuQBgKQ/4NVhb/9TLPM=", - "dev": true - }, - "babel-plugin-transform-async-generator-functions": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-generator-functions/-/babel-plugin-transform-async-generator-functions-6.24.1.tgz", - "integrity": "sha1-8FiQAUX9PpkHpt3yjaWfIVJYpds=", - "dev": true, - "requires": { - "babel-helper-remap-async-to-generator": "^6.24.1", - "babel-plugin-syntax-async-generators": "^6.5.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-async-to-generator": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz", - "integrity": "sha1-ZTbjeK/2yx1VF6wOQOs+n8jQh2E=", - "dev": true, - "requires": { - "babel-helper-remap-async-to-generator": "^6.24.1", - "babel-plugin-syntax-async-functions": "^6.8.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-class-constructor-call": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-class-constructor-call/-/babel-plugin-transform-class-constructor-call-6.24.1.tgz", - "integrity": "sha1-gNwoVQWsBn3LjWxl4vbxGrd2Xvk=", - "dev": true, - "requires": { - "babel-plugin-syntax-class-constructor-call": "^6.18.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-class-properties": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz", - "integrity": "sha1-anl2PqYdM9NvN7YRqp3vgagbRqw=", - "dev": true, - "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-plugin-syntax-class-properties": "^6.8.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-decorators": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-decorators/-/babel-plugin-transform-decorators-6.24.1.tgz", - "integrity": "sha1-eIAT2PjGtSIr33s0Q5Df13Vp4k0=", - "dev": true, - "requires": { - "babel-helper-explode-class": "^6.24.1", - "babel-plugin-syntax-decorators": "^6.13.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-arrow-functions": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz", - "integrity": "sha1-RSaSy3EdX3ncf4XkQM5BufJE0iE=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-block-scoped-functions": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz", - "integrity": "sha1-u8UbSflk1wy42OC5ToICRs46YUE=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-block-scoping": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz", - "integrity": "sha1-1w9SmcEwjQXBL0Y4E7CgnnOxiV8=", - "dev": true, - "requires": { - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "lodash": "^4.17.4" - } - }, - "babel-plugin-transform-es2015-classes": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz", - "integrity": "sha1-WkxYpQyclGHlZLSyo7+ryXolhNs=", - "dev": true, - "requires": { - "babel-helper-define-map": "^6.24.1", - "babel-helper-function-name": "^6.24.1", - "babel-helper-optimise-call-expression": "^6.24.1", - "babel-helper-replace-supers": "^6.24.1", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-computed-properties": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz", - "integrity": "sha1-b+Ko0WiV1WNPTNmZttNICjCBWbM=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-destructuring": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz", - "integrity": "sha1-mXux8auWf2gtKwh2/jWNYOdlxW0=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-duplicate-keys": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz", - "integrity": "sha1-c+s9MQypaePvnskcU3QabxV2Qj4=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-for-of": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz", - "integrity": "sha1-9HyVsrYT3x0+zC/bdXNiPHUkhpE=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-function-name": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz", - "integrity": "sha1-g0yJhTvDaxrw86TF26qU/Y6sqos=", - "dev": true, - "requires": { - "babel-helper-function-name": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-literals": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz", - "integrity": "sha1-T1SgLWzWbPkVKAAZox0xklN3yi4=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-modules-amd": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz", - "integrity": "sha1-Oz5UAXI5hC1tGcMBHEvS8AoA0VQ=", - "dev": true, - "requires": { - "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-modules-commonjs": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz", - "integrity": "sha1-DYOUApt9xqvhqX7xgeAHWN0uXYo=", - "dev": true, - "requires": { - "babel-plugin-transform-strict-mode": "^6.24.1", - "babel-runtime": "^6.26.0", - "babel-template": "^6.26.0", - "babel-types": "^6.26.0" - } - }, - "babel-plugin-transform-es2015-modules-systemjs": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz", - "integrity": "sha1-/4mhQrkRmpBhlfXxBuzzBdlAfSM=", - "dev": true, - "requires": { - "babel-helper-hoist-variables": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-modules-umd": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz", - "integrity": "sha1-rJl+YoXNGO1hdq22B9YCNErThGg=", - "dev": true, - "requires": { - "babel-plugin-transform-es2015-modules-amd": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-object-super": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz", - "integrity": "sha1-JM72muIcuDp/hgPa0CH1cusnj40=", - "dev": true, - "requires": { - "babel-helper-replace-supers": "^6.24.1", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-parameters": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz", - "integrity": "sha1-V6w1GrScrxSpfNE7CfZv3wpiXys=", - "dev": true, - "requires": { - "babel-helper-call-delegate": "^6.24.1", - "babel-helper-get-function-arity": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-template": "^6.24.1", - "babel-traverse": "^6.24.1", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-shorthand-properties": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz", - "integrity": "sha1-JPh11nIch2YbvZmkYi5R8U3jiqA=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-spread": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz", - "integrity": "sha1-1taKmfia7cRTbIGlQujdnxdG+NE=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-sticky-regex": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz", - "integrity": "sha1-AMHNsaynERLN8M9hJsLta0V8zbw=", - "dev": true, - "requires": { - "babel-helper-regex": "^6.24.1", - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-plugin-transform-es2015-template-literals": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz", - "integrity": "sha1-qEs0UPfp+PH2g51taH2oS7EjbY0=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-typeof-symbol": { - "version": "6.23.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz", - "integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-es2015-unicode-regex": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz", - "integrity": "sha1-04sS9C6nMj9yk4fxinxa4frrNek=", - "dev": true, - "requires": { - "babel-helper-regex": "^6.24.1", - "babel-runtime": "^6.22.0", - "regexpu-core": "^2.0.0" - } - }, - "babel-plugin-transform-exponentiation-operator": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz", - "integrity": "sha1-KrDJx/MJj6SJB3cruBP+QejeOg4=", - "dev": true, - "requires": { - "babel-helper-builder-binary-assignment-operator-visitor": "^6.24.1", - "babel-plugin-syntax-exponentiation-operator": "^6.8.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-export-extensions": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-export-extensions/-/babel-plugin-transform-export-extensions-6.22.0.tgz", - "integrity": "sha1-U3OLR+deghhYnuqUbLvTkQm75lM=", - "dev": true, - "requires": { - "babel-plugin-syntax-export-extensions": "^6.8.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-flow-strip-types": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-flow-strip-types/-/babel-plugin-transform-flow-strip-types-6.22.0.tgz", - "integrity": "sha1-hMtnKTXUNxT9wyvOhFaNh0Qc988=", - "dev": true, - "requires": { - "babel-plugin-syntax-flow": "^6.18.0", - "babel-runtime": "^6.22.0" - } - }, - "babel-plugin-transform-object-rest-spread": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz", - "integrity": "sha1-DzZpLVD+9rfi1LOsFHgTepY7ewY=", - "dev": true, - "requires": { - "babel-plugin-syntax-object-rest-spread": "^6.8.0", - "babel-runtime": "^6.26.0" - } - }, - "babel-plugin-transform-regenerator": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", - "integrity": "sha1-4HA2lvveJ/Cj78rPi03KL3s6jy8=", - "dev": true, - "requires": { - "regenerator-transform": "^0.10.0" - } - }, - "babel-plugin-transform-strict-mode": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz", - "integrity": "sha1-1fr3qleKZbvlkc9e2uBKDGcCB1g=", - "dev": true, - "requires": { - "babel-runtime": "^6.22.0", - "babel-types": "^6.24.1" - } - }, - "babel-preset-es2015": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-es2015/-/babel-preset-es2015-6.24.1.tgz", - "integrity": "sha1-1EBQ1rwsn+6nAqrzjXJ6AhBTiTk=", - "dev": true, - "requires": { - "babel-plugin-check-es2015-constants": "^6.22.0", - "babel-plugin-transform-es2015-arrow-functions": "^6.22.0", - "babel-plugin-transform-es2015-block-scoped-functions": "^6.22.0", - "babel-plugin-transform-es2015-block-scoping": "^6.24.1", - "babel-plugin-transform-es2015-classes": "^6.24.1", - "babel-plugin-transform-es2015-computed-properties": "^6.24.1", - "babel-plugin-transform-es2015-destructuring": "^6.22.0", - "babel-plugin-transform-es2015-duplicate-keys": "^6.24.1", - "babel-plugin-transform-es2015-for-of": "^6.22.0", - "babel-plugin-transform-es2015-function-name": "^6.24.1", - "babel-plugin-transform-es2015-literals": "^6.22.0", - "babel-plugin-transform-es2015-modules-amd": "^6.24.1", - "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", - "babel-plugin-transform-es2015-modules-systemjs": "^6.24.1", - "babel-plugin-transform-es2015-modules-umd": "^6.24.1", - "babel-plugin-transform-es2015-object-super": "^6.24.1", - "babel-plugin-transform-es2015-parameters": "^6.24.1", - "babel-plugin-transform-es2015-shorthand-properties": "^6.24.1", - "babel-plugin-transform-es2015-spread": "^6.22.0", - "babel-plugin-transform-es2015-sticky-regex": "^6.24.1", - "babel-plugin-transform-es2015-template-literals": "^6.22.0", - "babel-plugin-transform-es2015-typeof-symbol": "^6.22.0", - "babel-plugin-transform-es2015-unicode-regex": "^6.24.1", - "babel-plugin-transform-regenerator": "^6.24.1" - } - }, - "babel-preset-stage-1": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-stage-1/-/babel-preset-stage-1-6.24.1.tgz", - "integrity": "sha1-dpLNfc1oSZB+auSgqFWJz7niv7A=", - "dev": true, - "requires": { - "babel-plugin-transform-class-constructor-call": "^6.24.1", - "babel-plugin-transform-export-extensions": "^6.22.0", - "babel-preset-stage-2": "^6.24.1" - } - }, - "babel-preset-stage-2": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-stage-2/-/babel-preset-stage-2-6.24.1.tgz", - "integrity": "sha1-2eKWD7PXEYfw5k7sYrwHdnIZvcE=", - "dev": true, - "requires": { - "babel-plugin-syntax-dynamic-import": "^6.18.0", - "babel-plugin-transform-class-properties": "^6.24.1", - "babel-plugin-transform-decorators": "^6.24.1", - "babel-preset-stage-3": "^6.24.1" - } - }, - "babel-preset-stage-3": { - "version": "6.24.1", - "resolved": "https://registry.npmjs.org/babel-preset-stage-3/-/babel-preset-stage-3-6.24.1.tgz", - "integrity": "sha1-g2raCp56f6N8sTj7kyb4eTSkg5U=", - "dev": true, - "requires": { - "babel-plugin-syntax-trailing-function-commas": "^6.22.0", - "babel-plugin-transform-async-generator-functions": "^6.24.1", - "babel-plugin-transform-async-to-generator": "^6.24.1", - "babel-plugin-transform-exponentiation-operator": "^6.24.1", - "babel-plugin-transform-object-rest-spread": "^6.22.0" - } - }, - "babel-register": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-register/-/babel-register-6.26.0.tgz", - "integrity": "sha1-btAhFz4vy0htestFxgCahW9kcHE=", - "dev": true, - "requires": { - "babel-core": "^6.26.0", - "babel-runtime": "^6.26.0", - "core-js": "^2.5.0", - "home-or-tmp": "^2.0.0", - "lodash": "^4.17.4", - "mkdirp": "^0.5.1", - "source-map-support": "^0.4.15" - } - }, - "babel-runtime": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", - "dev": true, - "requires": { - "core-js": "^2.4.0", - "regenerator-runtime": "^0.11.0" - } - }, - "babel-template": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz", - "integrity": "sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI=", - "dev": true, - "requires": { - "babel-runtime": "^6.26.0", - "babel-traverse": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "lodash": "^4.17.4" - }, - "dependencies": { - "babylon": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha1-ry87iPpvXB5MY00aD46sT1WzleM=", - "dev": true - } - } - }, - "babel-traverse": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", - "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", - "dev": true, - "requires": { - "babel-code-frame": "^6.26.0", - "babel-messages": "^6.23.0", - "babel-runtime": "^6.26.0", - "babel-types": "^6.26.0", - "babylon": "^6.18.0", - "debug": "^2.6.8", - "globals": "^9.18.0", - "invariant": "^2.2.2", - "lodash": "^4.17.4" - }, - "dependencies": { - "babylon": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha1-ry87iPpvXB5MY00aD46sT1WzleM=", - "dev": true - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "globals": { - "version": "9.18.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha1-qjiWs+abSH8X4x7SFD1pqOMMLYo=", - "dev": true - } - } - }, - "babel-types": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", - "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", - "dev": true, - "requires": { - "babel-runtime": "^6.26.0", - "esutils": "^2.0.2", - "lodash": "^4.17.4", - "to-fast-properties": "^1.0.3" - } - }, - "babylon": { - "version": "7.0.0-beta.42", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.42.tgz", - "integrity": "sha512-h6E/OkkvcBw/JimbL0p8dIaxrcuQn3QmIYGC/GtJlRYif5LTKBYPHXYwqluJpfS/kOXoz0go+9mkmOVC0M+zWw==", - "dev": true - }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -1282,7 +431,7 @@ "base": { "version": "0.11.2", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=", + "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, "requires": { "cache-base": "^1.0.1", @@ -1302,43 +451,65 @@ "requires": { "is-descriptor": "^1.0.0" } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } } } }, "base64-js": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.3.tgz", - "integrity": "sha512-MsAhsUW1GxCdgYSO6tAfZrNapmUKk7mWx/k5mFY/A1gBtkaCaNapTg+FExCw1r9yeaZhqx/xPg43xgTFH6KL5w==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", + "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", "dev": true }, "big.js": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", - "integrity": "sha1-pfwpi4G54Nyi5FiCR4S2XFK6WI4=", - "dev": true + "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==" }, "binary-extensions": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", - "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", - "dev": true - }, - "binaryextensions": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/binaryextensions/-/binaryextensions-2.1.1.tgz", - "integrity": "sha1-MgmlHKSkrVQaO409am1bg6JIWTU=", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.12.0.tgz", + "integrity": "sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg==", "dev": true }, "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha1-2VUfnemPH82h5oPRfukaBgLuLrk=", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.2.tgz", + "integrity": "sha512-dhHTWMI7kMx5whMQntl7Vr9C6BvV10lFXDAasnqnrMYhXVCzzk6IO9Fo2L75jXHT07WrOngL1WDXOp+yYS91Yg==", "dev": true }, "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha1-LN4J617jQfSEdGuwMJsyU7GxRC8=", + "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==", "dev": true }, "brace-expansion": { @@ -1352,18 +523,16 @@ } }, "braces": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.1.tgz", - "integrity": "sha512-SO5lYHA3vO6gz66erVvedSCkp7AKWdv6VcQ2N4ysXfPxdAlxAMMAdwegGGcv1Bqwm7naF1hNdk5d6AAIEHV2nQ==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", + "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, "requires": { "arr-flatten": "^1.1.0", "array-unique": "^0.3.2", - "define-property": "^1.0.0", "extend-shallow": "^2.0.1", "fill-range": "^4.0.0", "isobject": "^3.0.1", - "kind-of": "^6.0.2", "repeat-element": "^1.1.2", "snapdragon": "^0.8.1", "snapdragon-node": "^2.0.1", @@ -1371,15 +540,6 @@ "to-regex": "^3.0.1" }, "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", @@ -1398,9 +558,9 @@ "dev": true }, "browserify-aes": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.1.1.tgz", - "integrity": "sha512-UGnTYAnB2a3YuYKIRy1/4FB2HdM866E0qC46JXvVTYKlBlZlnvfpSfY6OKfXZAkv70eJ2a1SqzpAo5CRhZGDFg==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { "buffer-xor": "^1.0.3", @@ -1412,9 +572,9 @@ } }, "browserify-cipher": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", - "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, "requires": { "browserify-aes": "^1.0.4", @@ -1423,14 +583,23 @@ } }, "browserify-des": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", - "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, "requires": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "browserify-rsa": { @@ -1461,7 +630,7 @@ "browserify-zlib": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", - "integrity": "sha1-KGlFnZqjviRf6P4sofRuLn9U1z8=", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, "requires": { "pako": "~1.0.5" @@ -1490,12 +659,6 @@ "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", @@ -1505,7 +668,7 @@ "cacache": { "version": "10.0.4", "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", - "integrity": "sha1-ZFI2eZnv+dQYiu/ZoU6dfGomNGA=", + "integrity": "sha512-Dph0MzuH+rTQzGPNT9fAnrPmMmjKfST6trxJeK7NQuHRaVw24VzPRWTmg9MpcwOVQZO0E1FBICUlFeNaKPIfHA==", "dev": true, "requires": { "bluebird": "^3.5.1", @@ -1526,7 +689,7 @@ "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=", + "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, "requires": { "collection-visit": "^1.0.0", @@ -1540,35 +703,6 @@ "unset-value": "^1.0.0" } }, - "cacheable-request": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-2.1.4.tgz", - "integrity": "sha1-DYCIAbY0KtM8kd+dC0TcCbkeXD0=", - "dev": true, - "requires": { - "clone-response": "1.0.2", - "get-stream": "3.0.0", - "http-cache-semantics": "3.8.1", - "keyv": "3.0.0", - "lowercase-keys": "1.0.0", - "normalize-url": "2.0.1", - "responselike": "1.0.2" - }, - "dependencies": { - "lowercase-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", - "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=", - "dev": true - } - } - }, - "call-me-maybe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz", - "integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=", - "dev": true - }, "caller-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", @@ -1628,41 +762,45 @@ "dev": true }, "chokidar": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.3.tgz", - "integrity": "sha1-3L1PbLsqVbR5m6ioQKxSfl9LEXY=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz", + "integrity": "sha512-z9n7yt9rOvIJrMhvDtDictKrkFHeihkNl6uWMmZlmL6tJtX9Cs+87oK+teBx+JIgzvbX3yZHT3eF8vpbDxHJXQ==", "dev": true, "requires": { "anymatch": "^2.0.0", "async-each": "^1.0.0", "braces": "^2.3.0", - "fsevents": "^1.1.2", + "fsevents": "^1.2.2", "glob-parent": "^3.1.0", "inherits": "^2.0.1", "is-binary-path": "^1.0.0", "is-glob": "^4.0.0", + "lodash.debounce": "^4.0.8", "normalize-path": "^2.1.1", "path-is-absolute": "^1.0.0", "readdirp": "^2.0.0", - "upath": "^1.0.0" + "upath": "^1.0.5" } }, "chownr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz", - "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", "dev": true }, "chrome-trace-event": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-0.1.2.tgz", - "integrity": "sha1-kPNohdU0WlBiEzLwcXtZWIPV2YI=", - "dev": true + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.0.tgz", + "integrity": "sha512-xDbVgyfDTT2piup/h8dK/y4QZfJRSa73bw1WZ8b4XM1o7fsFubUVGYcE+1ANtOzJJELGpYoG2961z0Z6OAld9A==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } }, "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha1-h2Dk7MJy9MNjUy+SbYdKriwTl94=", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -1678,7 +816,7 @@ "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=", + "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, "requires": { "arr-union": "^3.1.0", @@ -1695,63 +833,6 @@ "requires": { "is-descriptor": "^0.1.0" } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true } } }, @@ -1773,76 +854,6 @@ "restore-cursor": "^2.0.0" } }, - "cli-spinners": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-0.1.2.tgz", - "integrity": "sha1-u3ZNiOGF+54eaiofGXcjGPYF4xw=", - "dev": true - }, - "cli-table": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz", - "integrity": "sha1-9TsFJmqLGguTSz0IIebi3FkUriM=", - "dev": true, - "requires": { - "colors": "1.0.3" - }, - "dependencies": { - "colors": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", - "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", - "dev": true - } - } - }, - "cli-truncate": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-0.2.1.tgz", - "integrity": "sha1-nxXPuwcFAFNpIWxiasfQWrkN1XQ=", - "dev": true, - "requires": { - "slice-ansi": "0.0.4", - "string-width": "^1.0.1" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "slice-ansi": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", - "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", - "dev": true - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, "cli-width": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", @@ -1850,9 +861,9 @@ "dev": true }, "cliui": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.0.0.tgz", - "integrity": "sha512-nY3W5Gu2racvdDk//ELReY+dHjb9PlIcVDFXP72nVIhq2Gy3LuVXYwJoPVudwQnv1shtohpgkdCKT2YaKY0CKw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", "dev": true, "requires": { "string-width": "^2.1.1", @@ -1860,44 +871,6 @@ "wrap-ansi": "^2.0.0" } }, - "clone": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", - "dev": true - }, - "clone-buffer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", - "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", - "dev": true - }, - "clone-response": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", - "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", - "dev": true, - "requires": { - "mimic-response": "^1.0.0" - } - }, - "clone-stats": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", - "dev": true - }, - "cloneable-readable": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.2.tgz", - "integrity": "sha1-1ZHe5Kj4vBXaQ86X3O66E9Q+KmU=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "process-nextick-args": "^2.0.0", - "readable-stream": "^2.3.5" - } - }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -1935,16 +908,10 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, - "colors": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.1.tgz", - "integrity": "sha512-s8+wktIuDSLffCywiwSxQOMqtPxML11a/dtHE17tMn4B1MSWw/C22EKf7M2KGUBcDaVFEGT+S8N02geDXeuNKg==", - "dev": true - }, "commander": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", - "integrity": "sha1-aWS8pnaF33wfFDDFhPB9dZeIW5w=", + "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", "dev": true }, "commondir": { @@ -1992,16 +959,10 @@ "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", "dev": true }, - "convert-source-map": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", - "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=", - "dev": true - }, "copy-concurrently": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", - "integrity": "sha1-kilzmMrjSTf8r9bsgTnBgFHwteA=", + "integrity": "sha512-f2domd9fsVDFtaFcbaRZuYXwtdmnzqbADSwhSWYxYB/Q8zsdUUFMXVRwXGDMWmbEzAn1kdRrtI1T/KTFOL4X2A==", "dev": true, "requires": { "aproba": "^1.1.1", @@ -2018,12 +979,6 @@ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", "dev": true }, - "core-js": { - "version": "2.5.4", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.4.tgz", - "integrity": "sha1-8si/GB8qgLkvNgEhQpzmOi8K6uA=", - "dev": true - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -2031,9 +986,9 @@ "dev": true }, "create-ecdh": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz", - "integrity": "sha1-iIxyNZbN92EvZJgjPuvXo1MBc30=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", + "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", "dev": true, "requires": { "bn.js": "^4.1.0", @@ -2041,21 +996,22 @@ } }, "create-hash": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", - "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", - "ripemd160": "^2.0.0", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", "sha.js": "^2.4.0" } }, "create-hmac": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.6.tgz", - "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { "cipher-base": "^1.0.3", @@ -2080,7 +1036,7 @@ "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha1-OWz58xN/A+S45TLFj2mCVOAPgOw=", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { "browserify-cipher": "^1.0.0", @@ -2102,30 +1058,12 @@ "integrity": "sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA=", "dev": true }, - "dargs": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/dargs/-/dargs-5.1.0.tgz", - "integrity": "sha1-7H6lDHhWTNNsnV7Bj2Yyn63ieCk=", - "dev": true - }, - "date-fns": { - "version": "1.29.0", - "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz", - "integrity": "sha1-EuYJzcuTUScxHQTTMzTilgoqVOY=", - "dev": true - }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", "dev": true }, - "dateformat": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", - "integrity": "sha1-puN0maTZqc+F71hyBE1ikByYia4=", - "dev": true - }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -2136,10 +1074,13 @@ } }, "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-2.0.0.tgz", + "integrity": "sha512-Ikpp5scV3MSYxY39ymh45ZLEecsTdv/Xj2CaQfI8RLMuwi7XvjX9H/fhraiSuU+C5w5NTDu4ZU72xNiZnurBPg==", + "dev": true, + "requires": { + "xregexp": "4.0.0" + } }, "decode-uri-component": { "version": "0.2.0", @@ -2147,15 +1088,6 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, - "decompress-response": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", - "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", - "dev": true, - "requires": { - "mimic-response": "^1.0.0" - } - }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -2165,11 +1097,42 @@ "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha1-1Flono1lS6d+AqgX+HENcCyxbp0=", + "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, "requires": { "is-descriptor": "^1.0.2", "isobject": "^3.0.1" + }, + "dependencies": { + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + } } }, "del": { @@ -2197,31 +1160,10 @@ "minimalistic-assert": "^1.0.0" } }, - "detect-conflict": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/detect-conflict/-/detect-conflict-1.0.1.tgz", - "integrity": "sha1-CIZXpmqWHAUBnbfEIwiDsca0F24=", - "dev": true - }, - "detect-indent": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-4.0.0.tgz", - "integrity": "sha1-920GQ1LN9Docts5hnE7jqUdd4gg=", - "dev": true, - "requires": { - "repeating": "^2.0.0" - } - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha1-gAwN0eCov7yVg1wgKtIg/jF+WhI=", - "dev": true - }, "diffie-hellman": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz", - "integrity": "sha1-tYNXOScM/ias9jIJn97SoH8gnl4=", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { "bn.js": "^4.1.0", @@ -2229,16 +1171,6 @@ "randombytes": "^2.0.0" } }, - "dir-glob": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-2.0.0.tgz", - "integrity": "sha1-CyBdK2rvmCOMooZZioIE0p0KADQ=", - "dev": true, - "requires": { - "arrify": "^1.0.1", - "path-type": "^3.0.0" - } - }, "doctrine": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", @@ -2251,19 +1183,13 @@ "domain-browser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", - "integrity": "sha1-PTH1AZGmdJ3RN1p/Ui6CPULlTto=", - "dev": true - }, - "duplexer3": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", - "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", + "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", "dev": true }, "duplexify": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.4.tgz", - "integrity": "sha1-S7RsF5bqvr7sTKmi5muAjLej2LQ=", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.6.1.tgz", + "integrity": "sha512-vM58DwdnKmty+FSPzT14K9JXb90H+j5emaR4KYbr2KTIz00WHGbWOe5ghQTx233ZCLZtrGDALzKwcjEtSt35mA==", "dev": true, "requires": { "end-of-stream": "^1.0.0", @@ -2272,22 +1198,10 @@ "stream-shift": "^1.0.0" } }, - "editions": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/editions/-/editions-1.3.4.tgz", - "integrity": "sha1-NmLLWSNHwxaOuOSYoP9zJx1n9Qs=", - "dev": true - }, - "elegant-spinner": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/elegant-spinner/-/elegant-spinner-1.0.1.tgz", - "integrity": "sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4=", - "dev": true - }, "elliptic": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", - "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", + "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", "dev": true, "requires": { "bn.js": "^4.4.0", @@ -2302,22 +1216,21 @@ "emojis-list": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", - "dev": true + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=" }, "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha1-7SljTRm6ukY7bOa4CjchPqtx7EM=", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "dev": true, "requires": { "once": "^1.4.0" } }, "enhanced-resolve": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.0.0.tgz", - "integrity": "sha1-40puqnkPYvzNcdk5WfVrK0MtsQo=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz", + "integrity": "sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng==", "dev": true, "requires": { "graceful-fs": "^4.1.2", @@ -2325,40 +1238,15 @@ "tapable": "^1.0.0" } }, - "envinfo": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-4.4.2.tgz", - "integrity": "sha1-RyxJ86i5vKc5YmQc58tpK/YjzRw=", - "dev": true - }, "errno": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", - "integrity": "sha1-RoTXF3mtOa8Xfj8AeZb3xnyFJhg=", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", "dev": true, "requires": { "prr": "~1.0.1" } }, - "error": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/error/-/error-7.0.2.tgz", - "integrity": "sha1-pfdf/02ZJhJt2sDqXcOOaJFTywI=", - "dev": true, - "requires": { - "string-template": "~0.2.1", - "xtend": "~4.0.0" - } - }, - "error-ex": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", - "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", - "dev": true, - "requires": { - "is-arrayish": "^0.2.1" - } - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -2493,7 +1381,7 @@ "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha1-f8vbGY3HGVlDLv4ThCaE4FJaywI=", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { "md5.js": "^1.3.4", @@ -2501,26 +1389,35 @@ } }, "execa": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.10.0.tgz", + "integrity": "sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw==", "dev": true, "requires": { - "cross-spawn": "^5.0.1", + "cross-spawn": "^6.0.0", "get-stream": "^3.0.0", "is-stream": "^1.1.0", "npm-run-path": "^2.0.0", "p-finally": "^1.0.0", "signal-exit": "^3.0.0", "strip-eof": "^1.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + } } }, - "exit-hook": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", - "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", - "dev": true - }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -2539,7 +1436,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -2562,126 +1459,25 @@ "requires": { "is-extendable": "^0.1.0" } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true } } }, - "expand-range": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", - "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true, + "exports-loader": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/exports-loader/-/exports-loader-0.7.0.tgz", + "integrity": "sha512-RKwCrO4A6IiKm0pG3c9V46JxIHcDplwwGJn6+JJ1RcVnh/WSGJa0xkmk5cRVtgOPzCAtTMGj2F7nluh9L0vpSA==", "requires": { - "fill-range": "^2.1.0" + "loader-utils": "^1.1.0", + "source-map": "0.5.0" }, "dependencies": { - "fill-range": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", - "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", - "dev": true, - "requires": { - "is-number": "^2.1.0", - "isobject": "^2.0.0", - "randomatic": "^1.1.3", - "repeat-element": "^1.1.2", - "repeat-string": "^1.5.2" - } - }, - "is-number": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - } - }, - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } + "source-map": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.0.tgz", + "integrity": "sha1-D+llA6yGpa213mP05BKuSHLNvoY=" } } }, - "expand-tilde": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz", - "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", - "dev": true, - "requires": { - "homedir-polyfill": "^1.0.1" - } - }, "extend-shallow": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", @@ -2695,7 +1491,7 @@ "is-extendable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { "is-plain-object": "^2.0.4" @@ -2717,7 +1513,7 @@ "extglob": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha1-rQD+TcYSqSMuhxhxHcXLWrAoVUM=", + "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, "requires": { "array-unique": "^0.3.2", @@ -2747,6 +1543,35 @@ "requires": { "is-extendable": "^0.1.0" } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } } } }, @@ -2756,20 +1581,6 @@ "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", "dev": true }, - "fast-glob": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-2.2.2.tgz", - "integrity": "sha512-TR6zxCKftDQnUAPvkrCWdBgDq/gbqx8A3ApnBrR5rMvpp6+KMJI0Igw7fkWPgeVK0uhRXTXdvO3O+YP0CaUX2g==", - "dev": true, - "requires": { - "@mrmlnc/readdir-enhanced": "^2.2.1", - "@nodelib/fs.stat": "^1.0.1", - "glob-parent": "^3.1.0", - "is-glob": "^4.0.0", - "merge2": "^1.2.1", - "micromatch": "^3.1.10" - } - }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", @@ -2801,12 +1612,6 @@ "object-assign": "^4.0.1" } }, - "filename-regex": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", - "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", - "dev": true - }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -2850,15 +1655,6 @@ "locate-path": "^2.0.0" } }, - "first-chunk-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz", - "integrity": "sha1-G97NuOCDwGZLkZRVgVd6Q6nzHXA=", - "dev": true, - "requires": { - "readable-stream": "^2.0.2" - } - }, "flat-cache": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", @@ -2871,16 +1667,10 @@ "write": "^0.2.1" } }, - "flow-parser": { - "version": "0.68.0", - "resolved": "https://registry.npmjs.org/flow-parser/-/flow-parser-0.68.0.tgz", - "integrity": "sha1-nMlmIKEC4xajFLa81WIFzqzoYtg=", - "dev": true - }, "flush-write-stream": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.0.3.tgz", - "integrity": "sha1-xdWG7zivYJdlC0m8QbVfq7GfNb0=", + "integrity": "sha512-calZMC10u0FMUqoiunI2AiGIIUtUIvifNwkHhNupZH4cbNnW1Itkoh/Nf5HFYmDrwWPjrUxpkZT0KhuCq0jmGw==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -2893,15 +1683,6 @@ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", "dev": true }, - "for-own": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", - "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", - "dev": true, - "requires": { - "for-in": "^1.0.1" - } - }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", @@ -2951,39 +1732,29 @@ "dev": true }, "fsevents": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", - "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz", + "integrity": "sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==", "dev": true, "optional": true, "requires": { - "nan": "^2.3.0", - "node-pre-gyp": "^0.6.39" + "nan": "^2.9.2", + "node-pre-gyp": "^0.10.0" }, "dependencies": { "abbrev": { - "version": "1.1.0", + "version": "1.1.1", "bundled": true, "dev": true, "optional": true }, - "ajv": { - "version": "4.11.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "co": "^4.6.0", - "json-stable-stringify": "^1.0.1" - } - }, "ansi-regex": { "version": "2.1.1", "bundled": true, "dev": true }, "aproba": { - "version": "1.1.1", + "version": "1.2.0", "bundled": true, "dev": true, "optional": true @@ -2998,88 +1769,22 @@ "readable-stream": "^2.0.6" } }, - "asn1": { - "version": "0.2.3", - "bundled": true, - "dev": true, - "optional": true - }, - "assert-plus": { - "version": "0.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "asynckit": { - "version": "0.4.0", - "bundled": true, - "dev": true, - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "aws4": { - "version": "1.6.0", - "bundled": true, - "dev": true, - "optional": true - }, "balanced-match": { - "version": "0.4.2", - "bundled": true, - "dev": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "tweetnacl": "^0.14.3" - } - }, - "block-stream": { - "version": "0.0.9", - "bundled": true, - "dev": true, - "requires": { - "inherits": "~2.0.0" - } - }, - "boom": { - "version": "2.10.1", - "bundled": true, - "dev": true, - "requires": { - "hoek": "2.x.x" - } - }, - "brace-expansion": { - "version": "1.1.7", - "bundled": true, - "dev": true, - "requires": { - "balanced-match": "^0.4.1", - "concat-map": "0.0.1" - } - }, - "buffer-shims": { "version": "1.0.0", "bundled": true, "dev": true }, - "caseless": { - "version": "0.12.0", + "brace-expansion": { + "version": "1.1.11", "bundled": true, "dev": true, - "optional": true + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } }, - "co": { - "version": "4.6.0", + "chownr": { + "version": "1.0.1", "bundled": true, "dev": true, "optional": true @@ -3089,14 +1794,6 @@ "bundled": true, "dev": true }, - "combined-stream": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "requires": { - "delayed-stream": "~1.0.0" - } - }, "concat-map": { "version": "0.0.1", "bundled": true, @@ -3110,35 +1807,11 @@ "core-util-is": { "version": "1.0.2", "bundled": true, - "dev": true - }, - "cryptiles": { - "version": "2.0.5", - "bundled": true, "dev": true, - "requires": { - "boom": "2.x.x" - } - }, - "dashdash": { - "version": "1.14.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "^1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } + "optional": true }, "debug": { - "version": "2.6.8", + "version": "2.6.9", "bundled": true, "dev": true, "optional": true, @@ -3147,16 +1820,11 @@ } }, "deep-extend": { - "version": "0.4.2", + "version": "0.5.1", "bundled": true, "dev": true, "optional": true }, - "delayed-stream": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, "delegates": { "version": "1.0.0", "bundled": true, @@ -3164,74 +1832,25 @@ "optional": true }, "detect-libc": { - "version": "1.0.2", + "version": "1.0.3", "bundled": true, "dev": true, "optional": true }, - "ecc-jsbn": { - "version": "0.1.1", + "fs-minipass": { + "version": "1.2.5", "bundled": true, "dev": true, "optional": true, "requires": { - "jsbn": "~0.1.0" - } - }, - "extend": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "extsprintf": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "forever-agent": { - "version": "0.6.1", - "bundled": true, - "dev": true, - "optional": true - }, - "form-data": { - "version": "2.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.5", - "mime-types": "^2.1.12" + "minipass": "^2.2.1" } }, "fs.realpath": { "version": "1.0.0", "bundled": true, - "dev": true - }, - "fstream": { - "version": "1.0.11", - "bundled": true, "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" - } - }, - "fstream-ignore": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fstream": "^1.0.0", - "inherits": "2", - "minimatch": "^3.0.0" - } + "optional": true }, "gauge": { "version": "2.7.4", @@ -3249,27 +1868,11 @@ "wide-align": "^1.1.0" } }, - "getpass": { - "version": "0.1.7", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "^1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, "glob": { "version": "7.1.2", "bundled": true, "dev": true, + "optional": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -3279,64 +1882,35 @@ "path-is-absolute": "^1.0.0" } }, - "graceful-fs": { - "version": "4.1.11", - "bundled": true, - "dev": true - }, - "har-schema": { - "version": "1.0.5", - "bundled": true, - "dev": true, - "optional": true - }, - "har-validator": { - "version": "4.2.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ajv": "^4.9.1", - "har-schema": "^1.0.5" - } - }, "has-unicode": { "version": "2.0.1", "bundled": true, "dev": true, "optional": true }, - "hawk": { - "version": "3.1.3", - "bundled": true, - "dev": true, - "requires": { - "boom": "2.x.x", - "cryptiles": "2.x.x", - "hoek": "2.x.x", - "sntp": "1.x.x" - } - }, - "hoek": { - "version": "2.16.3", - "bundled": true, - "dev": true - }, - "http-signature": { - "version": "1.1.1", + "iconv-lite": { + "version": "0.4.21", "bundled": true, "dev": true, "optional": true, "requires": { - "assert-plus": "^0.2.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" + "safer-buffer": "^2.1.0" + } + }, + "ignore-walk": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minimatch": "^3.0.4" } }, "inflight": { "version": "1.0.6", "bundled": true, "dev": true, + "optional": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -3348,7 +1922,7 @@ "dev": true }, "ini": { - "version": "1.3.4", + "version": "1.3.5", "bundled": true, "dev": true, "optional": true @@ -3361,98 +1935,12 @@ "number-is-nan": "^1.0.0" } }, - "is-typedarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, "isarray": { "version": "1.0.0", "bundled": true, - "dev": true - }, - "isstream": { - "version": "0.1.2", - "bundled": true, "dev": true, "optional": true }, - "jodid25519": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsbn": "~0.1.0" - } - }, - "jsbn": { - "version": "0.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "bundled": true, - "dev": true, - "optional": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "jsonify": "~0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "jsonify": { - "version": "0.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "jsprim": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.0.2", - "json-schema": "0.2.3", - "verror": "1.3.6" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "mime-db": { - "version": "1.27.0", - "bundled": true, - "dev": true - }, - "mime-types": { - "version": "2.1.15", - "bundled": true, - "dev": true, - "requires": { - "mime-db": "~1.27.0" - } - }, "minimatch": { "version": "3.0.4", "bundled": true, @@ -3466,6 +1954,24 @@ "bundled": true, "dev": true }, + "minipass": { + "version": "2.2.4", + "bundled": true, + "dev": true, + "requires": { + "safe-buffer": "^5.1.1", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.1.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "minipass": "^2.2.1" + } + }, "mkdirp": { "version": "0.5.1", "bundled": true, @@ -3480,23 +1986,33 @@ "dev": true, "optional": true }, + "needle": { + "version": "2.2.0", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "debug": "^2.1.2", + "iconv-lite": "^0.4.4", + "sax": "^1.2.4" + } + }, "node-pre-gyp": { - "version": "0.6.39", + "version": "0.10.0", "bundled": true, "dev": true, "optional": true, "requires": { "detect-libc": "^1.0.2", - "hawk": "3.1.3", "mkdirp": "^0.5.1", + "needle": "^2.2.0", "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", "npmlog": "^4.0.2", "rc": "^1.1.7", - "request": "2.81.0", "rimraf": "^2.6.1", "semver": "^5.3.0", - "tar": "^2.2.1", - "tar-pack": "^3.4.0" + "tar": "^4" } }, "nopt": { @@ -3509,8 +2025,24 @@ "osenv": "^0.1.4" } }, + "npm-bundled": { + "version": "1.0.3", + "bundled": true, + "dev": true, + "optional": true + }, + "npm-packlist": { + "version": "1.1.10", + "bundled": true, + "dev": true, + "optional": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1" + } + }, "npmlog": { - "version": "4.1.0", + "version": "4.1.2", "bundled": true, "dev": true, "optional": true, @@ -3526,12 +2058,6 @@ "bundled": true, "dev": true }, - "oauth-sign": { - "version": "0.8.2", - "bundled": true, - "dev": true, - "optional": true - }, "object-assign": { "version": "4.1.1", "bundled": true, @@ -3559,7 +2085,7 @@ "optional": true }, "osenv": { - "version": "0.1.4", + "version": "0.1.5", "bundled": true, "dev": true, "optional": true, @@ -3571,38 +2097,22 @@ "path-is-absolute": { "version": "1.0.1", "bundled": true, - "dev": true - }, - "performance-now": { - "version": "0.2.0", - "bundled": true, "dev": true, "optional": true }, "process-nextick-args": { - "version": "1.0.7", - "bundled": true, - "dev": true - }, - "punycode": { - "version": "1.4.1", - "bundled": true, - "dev": true, - "optional": true - }, - "qs": { - "version": "6.4.0", + "version": "2.0.0", "bundled": true, "dev": true, "optional": true }, "rc": { - "version": "1.2.1", + "version": "1.2.7", "bundled": true, "dev": true, "optional": true, "requires": { - "deep-extend": "~0.4.0", + "deep-extend": "^0.5.1", "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" @@ -3617,64 +2127,48 @@ } }, "readable-stream": { - "version": "2.2.9", - "bundled": true, - "dev": true, - "requires": { - "buffer-shims": "~1.0.0", - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~1.0.0", - "util-deprecate": "~1.0.1" - } - }, - "request": { - "version": "2.81.0", + "version": "2.3.6", "bundled": true, "dev": true, "optional": true, "requires": { - "aws-sign2": "~0.6.0", - "aws4": "^1.2.1", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.0", - "forever-agent": "~0.6.1", - "form-data": "~2.1.1", - "har-validator": "~4.2.1", - "hawk": "~3.1.3", - "http-signature": "~1.1.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.7", - "oauth-sign": "~0.8.1", - "performance-now": "^0.2.0", - "qs": "~6.4.0", - "safe-buffer": "^5.0.1", - "stringstream": "~0.0.4", - "tough-cookie": "~2.3.0", - "tunnel-agent": "^0.6.0", - "uuid": "^3.0.0" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, "rimraf": { - "version": "2.6.1", + "version": "2.6.2", "bundled": true, "dev": true, + "optional": true, "requires": { "glob": "^7.0.5" } }, "safe-buffer": { - "version": "5.0.1", + "version": "5.1.1", "bundled": true, "dev": true }, + "safer-buffer": { + "version": "2.1.2", + "bundled": true, + "dev": true, + "optional": true + }, + "sax": { + "version": "1.2.4", + "bundled": true, + "dev": true, + "optional": true + }, "semver": { - "version": "5.3.0", + "version": "5.5.0", "bundled": true, "dev": true, "optional": true @@ -3691,39 +2185,6 @@ "dev": true, "optional": true }, - "sntp": { - "version": "1.0.9", - "bundled": true, - "dev": true, - "requires": { - "hoek": "2.x.x" - } - }, - "sshpk": { - "version": "1.13.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jodid25519": "^1.0.0", - "jsbn": "~0.1.0", - "tweetnacl": "~0.14.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, "string-width": { "version": "1.0.2", "bundled": true, @@ -3735,19 +2196,14 @@ } }, "string_decoder": { - "version": "1.0.1", + "version": "1.1.1", "bundled": true, "dev": true, + "optional": true, "requires": { - "safe-buffer": "^5.0.1" + "safe-buffer": "~5.1.0" } }, - "stringstream": { - "version": "0.0.5", - "bundled": true, - "dev": true, - "optional": true - }, "strip-ansi": { "version": "3.0.1", "bundled": true, @@ -3763,81 +2219,26 @@ "optional": true }, "tar": { - "version": "2.2.1", - "bundled": true, - "dev": true, - "requires": { - "block-stream": "*", - "fstream": "^1.0.2", - "inherits": "2" - } - }, - "tar-pack": { - "version": "3.4.0", + "version": "4.4.1", "bundled": true, "dev": true, "optional": true, "requires": { - "debug": "^2.2.0", - "fstream": "^1.0.10", - "fstream-ignore": "^1.0.5", - "once": "^1.3.3", - "readable-stream": "^2.1.4", - "rimraf": "^2.5.1", - "tar": "^2.2.1", - "uid-number": "^0.0.6" + "chownr": "^1.0.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.2.4", + "minizlib": "^1.1.0", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.1", + "yallist": "^3.0.2" } }, - "tough-cookie": { - "version": "2.3.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "punycode": "^1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "^5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "bundled": true, - "dev": true, - "optional": true - }, - "uid-number": { - "version": "0.0.6", - "bundled": true, - "dev": true, - "optional": true - }, "util-deprecate": { "version": "1.0.2", "bundled": true, - "dev": true - }, - "uuid": { - "version": "3.0.1", - "bundled": true, "dev": true, "optional": true }, - "verror": { - "version": "1.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "extsprintf": "1.0.2" - } - }, "wide-align": { "version": "1.1.2", "bundled": true, @@ -3851,6 +2252,11 @@ "version": "1.0.2", "bundled": true, "dev": true + }, + "yallist": { + "version": "3.0.2", + "bundled": true, + "dev": true } } }, @@ -3861,9 +2267,9 @@ "dev": true }, "get-caller-file": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", - "integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", "dev": true }, "get-stream": { @@ -3878,79 +2284,6 @@ "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", "dev": true }, - "gh-got": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/gh-got/-/gh-got-6.0.0.tgz", - "integrity": "sha1-10NTAExuxGZkdSChC9RvcpnSaNA=", - "dev": true, - "requires": { - "got": "^7.0.0", - "is-plain-obj": "^1.1.0" - }, - "dependencies": { - "got": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/got/-/got-7.1.0.tgz", - "integrity": "sha1-BUUP2ECU5rvqVvRRpDqcKJFmOFo=", - "dev": true, - "requires": { - "decompress-response": "^3.2.0", - "duplexer3": "^0.1.4", - "get-stream": "^3.0.0", - "is-plain-obj": "^1.1.0", - "is-retry-allowed": "^1.0.0", - "is-stream": "^1.0.0", - "isurl": "^1.0.0-alpha5", - "lowercase-keys": "^1.0.0", - "p-cancelable": "^0.3.0", - "p-timeout": "^1.1.1", - "safe-buffer": "^5.0.1", - "timed-out": "^4.0.0", - "url-parse-lax": "^1.0.0", - "url-to-options": "^1.0.1" - } - }, - "p-cancelable": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.3.0.tgz", - "integrity": "sha1-ueEjgAvOu3rBOkeb4ZW1B7mNMPo=", - "dev": true - }, - "p-timeout": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-1.2.1.tgz", - "integrity": "sha1-XrOzU7f86Z8QGhA4iAuwVOu+o4Y=", - "dev": true, - "requires": { - "p-finally": "^1.0.0" - } - }, - "prepend-http": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", - "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", - "dev": true - }, - "url-parse-lax": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", - "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", - "dev": true, - "requires": { - "prepend-http": "^1.0.1" - } - } - } - }, - "github-username": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/github-username/-/github-username-4.1.0.tgz", - "integrity": "sha1-y+KABBiDIG2kISrp5LXxacML9Bc=", - "dev": true, - "requires": { - "gh-got": "^6.0.0" - } - }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -3965,69 +2298,6 @@ "path-is-absolute": "^1.0.0" } }, - "glob-all": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-all/-/glob-all-3.1.0.tgz", - "integrity": "sha1-iRPd+17hrHgSZWJBsD1SF8ZLAqs=", - "dev": true, - "requires": { - "glob": "^7.0.5", - "yargs": "~1.2.6" - }, - "dependencies": { - "minimist": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.1.0.tgz", - "integrity": "sha1-md9lelJXTCHJBXSX33QnkLK0wN4=", - "dev": true - }, - "yargs": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-1.2.6.tgz", - "integrity": "sha1-nHtKgv1dWVsr8Xq23MQxNUMv40s=", - "dev": true, - "requires": { - "minimist": "^0.1.0" - } - } - } - }, - "glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true, - "requires": { - "glob-parent": "^2.0.0", - "is-glob": "^2.0.0" - }, - "dependencies": { - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true, - "requires": { - "is-glob": "^2.0.0" - } - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - } - } - }, "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -4049,36 +2319,12 @@ } } }, - "glob-to-regexp": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz", - "integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=", + "global-modules-path": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/global-modules-path/-/global-modules-path-2.3.0.tgz", + "integrity": "sha512-HchvMJNYh9dGSCy8pOQ2O8u/hoXaL+0XhnrwH0RyLiSXMMTl9W3N6KUU73+JFOg5PGjtzl6VZzUQsnrpm7Szag==", "dev": true }, - "global-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha1-bXcPDrUjrHgWTXK15xqIdyZcw+o=", - "dev": true, - "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" - } - }, - "global-prefix": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-1.0.2.tgz", - "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.2", - "homedir-polyfill": "^1.0.1", - "ini": "^1.3.4", - "is-windows": "^1.0.1", - "which": "^1.2.14" - } - }, "globals": { "version": "11.4.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.4.0.tgz", @@ -4099,54 +2345,12 @@ "pinkie-promise": "^2.0.0" } }, - "got": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/got/-/got-8.3.0.tgz", - "integrity": "sha512-kBNy/S2CGwrYgDSec5KTWGKUvupwkkTVAjIsVFF2shXO13xpZdFP4d4kxa//CLX2tN/rV0aYwK8vY6UKWGn2vQ==", - "dev": true, - "requires": { - "@sindresorhus/is": "^0.7.0", - "cacheable-request": "^2.1.1", - "decompress-response": "^3.3.0", - "duplexer3": "^0.1.4", - "get-stream": "^3.0.0", - "into-stream": "^3.1.0", - "is-retry-allowed": "^1.1.0", - "isurl": "^1.0.0-alpha5", - "lowercase-keys": "^1.0.0", - "mimic-response": "^1.0.0", - "p-cancelable": "^0.4.0", - "p-timeout": "^2.0.1", - "pify": "^3.0.0", - "safe-buffer": "^5.1.1", - "timed-out": "^4.0.1", - "url-parse-lax": "^3.0.0", - "url-to-options": "^1.0.1" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - } - } - }, "graceful-fs": { "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", "dev": true }, - "grouped-queue": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/grouped-queue/-/grouped-queue-0.3.3.tgz", - "integrity": "sha1-wWfSpTGcWg4JZO9qJbfC34mWyFw=", - "dev": true, - "requires": { - "lodash": "^4.17.2" - } - }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", @@ -4156,33 +2360,12 @@ "ansi-regex": "^2.0.0" } }, - "has-color": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz", - "integrity": "sha1-ZxRKUmDDT8PMpnfQQdr1L+e3iy8=", - "dev": true - }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "has-symbol-support-x": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz", - "integrity": "sha1-FAn5i8ACR9pF2mfO4KNvKC/yZFU=", - "dev": true - }, - "has-to-string-tag-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", - "integrity": "sha1-oEWrOD17SyASoAFIqwql8pAETU0=", - "dev": true, - "requires": { - "has-symbol-support-x": "^1.4.1" - } - }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -4216,22 +2399,23 @@ } }, "hash-base": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", - "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", + "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", "dev": true, "requires": { - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" } }, "hash.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha1-NA3tvmKQGHFRweodd3o0SJNd+EY=", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz", + "integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==", "dev": true, "requires": { "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.1" } }, "hmac-drbg": { @@ -4245,37 +2429,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "home-or-tmp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz", - "integrity": "sha1-42w/LSyufXRqhX440Y1fMqeILbg=", - "dev": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.1" - } - }, - "homedir-polyfill": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", - "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", - "dev": true, - "requires": { - "parse-passwd": "^1.0.0" - } - }, - "hosted-git-info": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz", - "integrity": "sha1-IyNbKasjDFdqqw1PE/wEawsDgiI=", - "dev": true - }, - "http-cache-semantics": { - "version": "3.8.1", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-3.8.1.tgz", - "integrity": "sha1-ObDhat2bYFvwqe89nar0hDtMrNI=", - "dev": true - }, "https-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", @@ -4289,9 +2442,9 @@ "dev": true }, "ieee754": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.11.tgz", - "integrity": "sha1-wWOE/+APW3g1gk5ntvK9RKUilFU=", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", + "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==", "dev": true }, "iferr": { @@ -4307,13 +2460,76 @@ "dev": true }, "import-local": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-1.0.0.tgz", - "integrity": "sha1-Xk/9wD9P5sAJxnKb6yljHC+CJ7w=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz", + "integrity": "sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ==", "dev": true, "requires": { - "pkg-dir": "^2.0.0", + "pkg-dir": "^3.0.0", "resolve-cwd": "^2.0.0" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz", + "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", + "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", + "dev": true + }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "requires": { + "find-up": "^3.0.0" + } + } + } + }, + "imports-loader": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/imports-loader/-/imports-loader-0.8.0.tgz", + "integrity": "sha512-kXWL7Scp8KQ4552ZcdVTeaQCZSLW+e6nJfp3cwUMB673T7Hr98Xjx5JK+ql7ADlJUvj1JS5O01RLbKoutN5QDQ==", + "requires": { + "loader-utils": "^1.0.2", + "source-map": "^0.6.1" } }, "imurmurhash": { @@ -4322,15 +2538,6 @@ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, - "indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "requires": { - "repeating": "^2.0.0" - } - }, "indexof": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", @@ -4353,12 +2560,6 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha1-7uJfVtscnsYIXgwid4CD9Zar+Sc=", - "dev": true - }, "inquirer": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", @@ -4387,46 +2588,32 @@ "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", "dev": true }, - "into-stream": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/into-stream/-/into-stream-3.1.0.tgz", - "integrity": "sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=", - "dev": true, - "requires": { - "from2": "^2.1.1", - "p-is-promise": "^1.1.0" - } - }, - "invariant": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", - "integrity": "sha1-YQ88ksk1nOHbYW5TgAjSP/NRWOY=", - "dev": true, - "requires": { - "loose-envify": "^1.0.0" - } - }, "invert-kv": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", "dev": true }, "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } } }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", @@ -4439,51 +2626,46 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, - "is-builtin-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", - "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "dev": true, - "requires": { - "builtin-modules": "^1.0.0" - } - }, "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { - "kind-of": "^6.0.0" + "kind-of": "^3.0.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "^1.1.5" + } + } } }, "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", + "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - }, - "is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", - "dev": true - }, - "is-equal-shallow": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", - "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true, - "requires": { - "is-primitive": "^2.0.0" + "is-accessor-descriptor": "^0.1.6", + "is-data-descriptor": "^0.1.4", + "kind-of": "^5.0.0" + }, + "dependencies": { + "kind-of": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", + "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", + "dev": true + } } }, "is-extendable": { @@ -4498,15 +2680,6 @@ "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true }, - "is-finite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", @@ -4542,46 +2715,6 @@ } } }, - "is-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.1.tgz", - "integrity": "sha1-iVJojF7C/9awPsyF52ngKQMINHA=", - "dev": true - }, - "is-observable": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/is-observable/-/is-observable-0.2.0.tgz", - "integrity": "sha1-s2ExHYPG5dcmyr9eJQsCNxBvWuI=", - "dev": true, - "requires": { - "symbol-observable": "^0.2.2" - }, - "dependencies": { - "symbol-observable": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-0.2.4.tgz", - "integrity": "sha1-lag9smGG1q9+ehjb2XYKL4bQj0A=", - "dev": true - } - } - }, - "is-odd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz", - "integrity": "sha1-dkZiRnH9fqVYzNmieVGC8pWPGyQ=", - "dev": true, - "requires": { - "is-number": "^4.0.0" - }, - "dependencies": { - "is-number": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha1-ACbjf1RU1z41bf5lZGmYZ8an8P8=", - "dev": true - } - } - }, "is-path-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", @@ -4606,33 +2739,15 @@ "path-is-inside": "^1.0.1" } }, - "is-plain-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", - "dev": true - }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, "requires": { "isobject": "^3.0.1" } }, - "is-posix-bracket": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", - "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", - "dev": true - }, - "is-primitive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - }, "is-promise": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", @@ -4645,37 +2760,16 @@ "integrity": "sha1-+xj4fOH+uSUWnJpAfBkxijIG7Yg=", "dev": true }, - "is-retry-allowed": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", - "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", - "dev": true - }, - "is-scoped": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-scoped/-/is-scoped-1.0.0.tgz", - "integrity": "sha1-RJypgpnnEwOCViieyytUDcQ3yzA=", - "dev": true, - "requires": { - "scoped-regex": "^1.0.0" - } - }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, - "is-utf8": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true - }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha1-0YUOuXkezRjmGCzhKjDzlmNLsZ0=", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", "dev": true }, "isarray": { @@ -4684,12 +2778,6 @@ "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "isbinaryfile": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-3.0.2.tgz", - "integrity": "sha1-Sj6XTsDLqQBNP8bN5yCeppNopiE=", - "dev": true - }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -4702,27 +2790,6 @@ "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", "dev": true }, - "istextorbinary": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/istextorbinary/-/istextorbinary-2.2.1.tgz", - "integrity": "sha1-pSMaCO9t0ismjQiVCEz41Ytb7FM=", - "dev": true, - "requires": { - "binaryextensions": "2", - "editions": "^1.3.3", - "textextensions": "2" - } - }, - "isurl": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isurl/-/isurl-1.0.0.tgz", - "integrity": "sha1-sn9PSfPNqj6kSgpbfzRi5u3DnWc=", - "dev": true, - "requires": { - "has-to-string-tag-x": "^1.2.0", - "is-object": "^1.0.1" - } - }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", @@ -4739,136 +2806,10 @@ "esprima": "^4.0.0" } }, - "jscodeshift": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jscodeshift/-/jscodeshift-0.5.0.tgz", - "integrity": "sha1-vbe2zCDdYsFqpyjD+i0v5mynx0g=", - "dev": true, - "requires": { - "babel-plugin-transform-flow-strip-types": "^6.8.0", - "babel-preset-es2015": "^6.9.0", - "babel-preset-stage-1": "^6.5.0", - "babel-register": "^6.9.0", - "babylon": "^7.0.0-beta.30", - "colors": "^1.1.2", - "flow-parser": "^0.*", - "lodash": "^4.13.1", - "micromatch": "^2.3.7", - "neo-async": "^2.5.0", - "node-dir": "0.1.8", - "nomnom": "^1.8.1", - "recast": "^0.14.1", - "temp": "^0.8.1", - "write-file-atomic": "^1.2.0" - }, - "dependencies": { - "arr-diff": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true, - "requires": { - "arr-flatten": "^1.0.1" - } - }, - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, - "braces": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true, - "requires": { - "expand-range": "^1.8.1", - "preserve": "^0.2.0", - "repeat-element": "^1.1.2" - } - }, - "expand-brackets": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true, - "requires": { - "is-posix-bracket": "^0.1.0" - } - }, - "extglob": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - }, - "micromatch": { - "version": "2.3.11", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true, - "requires": { - "arr-diff": "^2.0.0", - "array-unique": "^0.2.1", - "braces": "^1.8.2", - "expand-brackets": "^0.1.4", - "extglob": "^0.3.1", - "filename-regex": "^2.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.1", - "kind-of": "^3.0.2", - "normalize-path": "^2.0.1", - "object.omit": "^2.0.0", - "parse-glob": "^3.0.4", - "regex-cache": "^0.4.2" - } - } - } - }, - "jsesc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", - "dev": true - }, - "json-buffer": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", - "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=", - "dev": true - }, "json-parse-better-errors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.1.tgz", - "integrity": "sha512-xyQpxeWWMKyJps9CuGJYeng6ssI5bpqS9ltQpdVQ90t4ql6NdnxFKh95JcRt2cun/DjMVNrdjniLPuMA69xmCw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", "dev": true }, "json-schema-traverse": { @@ -4886,8 +2827,7 @@ "json5": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", - "dev": true + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" }, "jsonfile": { "version": "4.0.0", @@ -4898,36 +2838,21 @@ "graceful-fs": "^4.1.6" } }, - "keyv": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.0.0.tgz", - "integrity": "sha1-RJI7o55osSp87H32wyaMAx8u83M=", - "dev": true, - "requires": { - "json-buffer": "3.0.0" - } - }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha1-ARRrNqYhjmTljzqNZt5df8b20FE=", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true }, "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", "dev": true, "requires": { - "invert-kv": "^1.0.0" + "invert-kv": "^2.0.0" } }, - "leb": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/leb/-/leb-0.3.0.tgz", - "integrity": "sha1-Mr7p+tFoMo1q6oUi2DP0GA7tHaM=", - "dev": true - }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -4938,253 +2863,16 @@ "type-check": "~0.3.2" } }, - "listr": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/listr/-/listr-0.13.0.tgz", - "integrity": "sha1-ILsLowuuZg7oTMBQPfS+PVYjiH0=", - "dev": true, - "requires": { - "chalk": "^1.1.3", - "cli-truncate": "^0.2.1", - "figures": "^1.7.0", - "indent-string": "^2.1.0", - "is-observable": "^0.2.0", - "is-promise": "^2.1.0", - "is-stream": "^1.1.0", - "listr-silent-renderer": "^1.1.1", - "listr-update-renderer": "^0.4.0", - "listr-verbose-renderer": "^0.4.0", - "log-symbols": "^1.0.2", - "log-update": "^1.0.2", - "ora": "^0.2.3", - "p-map": "^1.1.1", - "rxjs": "^5.4.2", - "stream-to-observable": "^0.2.0", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5", - "object-assign": "^4.1.0" - } - }, - "log-symbols": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", - "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", - "dev": true, - "requires": { - "chalk": "^1.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "listr-silent-renderer": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz", - "integrity": "sha1-kktaN1cVN3C/Go4/v3S4u/P5JC4=", - "dev": true - }, - "listr-update-renderer": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/listr-update-renderer/-/listr-update-renderer-0.4.0.tgz", - "integrity": "sha1-NE2YDaLKLosUW6MFkI8yrj9MyKc=", - "dev": true, - "requires": { - "chalk": "^1.1.3", - "cli-truncate": "^0.2.1", - "elegant-spinner": "^1.0.1", - "figures": "^1.7.0", - "indent-string": "^3.0.0", - "log-symbols": "^1.0.2", - "log-update": "^1.0.2", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5", - "object-assign": "^4.1.0" - } - }, - "indent-string": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", - "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", - "dev": true - }, - "log-symbols": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", - "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", - "dev": true, - "requires": { - "chalk": "^1.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "listr-verbose-renderer": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/listr-verbose-renderer/-/listr-verbose-renderer-0.4.1.tgz", - "integrity": "sha1-ggb0z21S3cWCfl/RSYng6WWTOjU=", - "dev": true, - "requires": { - "chalk": "^1.1.3", - "cli-cursor": "^1.0.2", - "date-fns": "^1.27.2", - "figures": "^1.7.0" - }, - "dependencies": { - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "cli-cursor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", - "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", - "dev": true, - "requires": { - "restore-cursor": "^1.0.1" - } - }, - "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5", - "object-assign": "^4.1.0" - } - }, - "onetime": { - "version": "1.1.0", - "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true - }, - "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", - "dev": true, - "requires": { - "exit-hook": "^1.0.0", - "onetime": "^1.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "load-json-file": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", - "integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0", - "strip-bom": "^3.0.0" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - } - } - }, "loader-runner": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.3.0.tgz", - "integrity": "sha1-9IKuqC1UPgeSFwDVpG7yb9rGuKI=", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.3.1.tgz", + "integrity": "sha512-By6ZFY7ETWOc9RFaAIb23IjJVcM4dvJC/N57nmdz9RSkMXvAXGI7SyVlAw3v8vjtDRlqThgVDVmTnr9fqMlxkw==", "dev": true }, "loader-utils": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", - "dev": true, "requires": { "big.js": "^3.1.3", "emojis-list": "^2.0.0", @@ -5207,77 +2895,10 @@ "integrity": "sha1-maktZcAnLevoyWtgV7yPv6O+1RE=", "dev": true }, - "log-symbols": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", - "integrity": "sha1-V0Dhxdbw39pK2TI7UzIQfva0xAo=", - "dev": true, - "requires": { - "chalk": "^2.0.1" - } - }, - "log-update": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/log-update/-/log-update-1.0.2.tgz", - "integrity": "sha1-GZKfZMQJPS0ucHWh2tivWcKWuNE=", - "dev": true, - "requires": { - "ansi-escapes": "^1.0.0", - "cli-cursor": "^1.0.2" - }, - "dependencies": { - "ansi-escapes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", - "dev": true - }, - "cli-cursor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", - "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", - "dev": true, - "requires": { - "restore-cursor": "^1.0.1" - } - }, - "onetime": { - "version": "1.1.0", - "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true - }, - "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", - "dev": true, - "requires": { - "exit-hook": "^1.0.0", - "onetime": "^1.0.0" - } - } - } - }, - "long": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", - "integrity": "sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s=", - "dev": true - }, - "loose-envify": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", - "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", - "dev": true, - "requires": { - "js-tokens": "^3.0.0" - } - }, - "lowercase-keys": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", - "integrity": "sha1-b54wtHCE2XGnyCD/FabFFnt0wm8=", + "lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", "dev": true }, "lru-cache": { @@ -5291,9 +2912,9 @@ } }, "make-dir": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.2.0.tgz", - "integrity": "sha1-bWpJ7q1KrilsU7vzoaAIvWyJRps=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", "dev": true, "requires": { "pify": "^3.0.0" @@ -5307,6 +2928,15 @@ } } }, + "map-age-cleaner": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.2.tgz", + "integrity": "sha512-UN1dNocxQq44IhJyMI4TU8phc2m9BddacHRPRjKGLYaF0jqd3xLz0jS0skpAU9WgYyoR4gHtUpzytNBS385FWQ==", + "dev": true, + "requires": { + "p-defer": "^1.0.0" + } + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -5323,45 +2953,33 @@ } }, "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, "requires": { "hash-base": "^3.0.0", - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" }, "dependencies": { - "hash-base": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", - "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true } } }, "mem": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", - "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.0.0.tgz", + "integrity": "sha512-WQxG/5xYc3tMbYLXoXPm81ET2WDULiU5FxbuIoNbJqLOOI8zehXFdZuiUEgfdrU2mVB1pxBZUGlYORSrpuJreA==", "dev": true, "requires": { - "mimic-fn": "^1.0.0" - } - }, - "mem-fs": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/mem-fs/-/mem-fs-1.1.3.tgz", - "integrity": "sha1-uK6NLj/Lb10/kWXBLUVRoGXZicw=", - "dev": true, - "requires": { - "through2": "^2.0.0", - "vinyl": "^1.1.0", - "vinyl-file": "^2.0.0" + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^1.0.0", + "p-is-promise": "^1.1.0" } }, "memory-fs": { @@ -5374,16 +2992,10 @@ "readable-stream": "^2.0.1" } }, - "merge2": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.2.2.tgz", - "integrity": "sha512-bgM8twH86rWni21thii6WCMQMRMmwqqdW3sGWi9IipnVAszdLXRjwDwAnyrVXo6DuP3AjRMMttZKUB48QWIFGg==", - "dev": true - }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha1-cIWbyVyYQJUvNZoGij/En57PrCM=", + "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, "requires": { "arr-diff": "^4.0.0", @@ -5404,7 +3016,7 @@ "miller-rabin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha1-8IA1HIZbDcViqEYpZtqlNUPHik0=", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, "requires": { "bn.js": "^4.0.0", @@ -5417,16 +3029,10 @@ "integrity": "sha1-ggyGo5M0ZA6ZUWkovQP8qIBX0CI=", "dev": true }, - "mimic-response": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.0.tgz", - "integrity": "sha1-3z02Uqc/3ta5sLJBRub9BSNTRY4=", - "dev": true - }, "minimalistic-assert": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz", - "integrity": "sha1-cCvi3aazf0g2vLP121ZkG2Sh09M=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "dev": true }, "minimalistic-crypto-utils": { @@ -5453,7 +3059,7 @@ "mississippi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-2.0.0.tgz", - "integrity": "sha1-NEKlCPr8KFAEhv7qmUCWduTuWm8=", + "integrity": "sha512-zHo8v+otD1J10j/tC+VNoGK9keCuByhKovAvdn74dmxJl9+mWHnx6EMsDN4lgRoMI/eYo2nchAxniIbUPb5onw==", "dev": true, "requires": { "concat-stream": "^1.5.0", @@ -5471,7 +3077,7 @@ "mixin-deep": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha1-pJ5yaNzhoNlpjkUybFYm3zVD0P4=", + "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", "dev": true, "requires": { "for-in": "^1.0.2", @@ -5481,7 +3087,7 @@ "is-extendable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { "is-plain-object": "^2.0.4" @@ -5518,18 +3124,6 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "multimatch": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/multimatch/-/multimatch-2.1.0.tgz", - "integrity": "sha1-nHkGoi+0wCkZ4vX3UWG0zb1LKis=", - "dev": true, - "requires": { - "array-differ": "^1.0.0", - "array-union": "^1.0.1", - "arrify": "^1.0.0", - "minimatch": "^3.0.0" - } - }, "mute-stream": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", @@ -5537,16 +3131,16 @@ "dev": true }, "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz", + "integrity": "sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==", "dev": true, "optional": true }, "nanomatch": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", - "integrity": "sha1-h59xUMstq3pHElkGbBBO7m4Pp8I=", + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", "dev": true, "requires": { "arr-diff": "^4.0.0", @@ -5554,7 +3148,6 @@ "define-property": "^2.0.2", "extend-shallow": "^3.0.2", "fragment-cache": "^0.2.1", - "is-odd": "^2.0.0", "is-windows": "^1.0.2", "kind-of": "^6.0.2", "object.pick": "^1.3.0", @@ -5570,27 +3163,21 @@ "dev": true }, "neo-async": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.5.0.tgz", - "integrity": "sha512-nJmSswG4As/MkRq7QZFuH/sf/yuv8ODdMZrY4Bedjp77a5MK4A6s7YbBB64c9u79EBUOfXUXBvArmvzTD0X+6g==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.5.1.tgz", + "integrity": "sha512-3KL3fvuRkZ7s4IFOMfztb7zJp3QaVWnBeGoJlgB38XnCRPj/0tLzzLG5IB8NYOHbJ8g8UGrgZv44GLDk6CxTxA==", "dev": true }, "nice-try": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.4.tgz", - "integrity": "sha1-2Tli9sUvLBVYwPvabVEoGfHv4cQ=", - "dev": true - }, - "node-dir": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/node-dir/-/node-dir-0.1.8.tgz", - "integrity": "sha1-VfuN62mQcHB/tn+RpGDwRIKUx30=", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, "node-libs-browser": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.1.0.tgz", - "integrity": "sha1-X5QmPUBPbkR2fXJpAf/wVHjWAN8=", + "integrity": "sha512-5AzFzdoIMb89hBGMZglEegffzgRg+ZFoUmisQ8HI4j1KDdpx13J0taNp2y9xPbur6W61gepGDDotGBVQ7mfUCg==", "dev": true, "requires": { "assert": "^1.1.1", @@ -5627,15 +3214,15 @@ } }, "node-sloc": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/node-sloc/-/node-sloc-0.1.10.tgz", - "integrity": "sha1-dSNlnj28YfKzhRp1ud3lJJtSWys=", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/node-sloc/-/node-sloc-0.1.11.tgz", + "integrity": "sha512-hKvVhaJliSdKaQ7MosSLPQfefwMd0GhncudU5zAmSk/iXZq2tZVxezSrZrUls5QyKufkRto9S2IMRfTzhKXQAw==", "dev": true, "requires": { "chalk": "^1.1.3", "graceful-fs": "^4.1.11", "minimist": "^1.2.0", - "promisify-node": "^0.4.0" + "promisify-node": "^0.5.0" }, "dependencies": { "chalk": { @@ -5677,53 +3264,6 @@ "asap": "~2.0.3" } }, - "nomnom": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/nomnom/-/nomnom-1.8.1.tgz", - "integrity": "sha1-IVH3Ikcrp55Qp2/BJbuMjy5Nwqc=", - "dev": true, - "requires": { - "chalk": "~0.4.0", - "underscore": "~1.6.0" - }, - "dependencies": { - "ansi-styles": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.0.0.tgz", - "integrity": "sha1-yxAt8cVvUSPquLZ817mAJ6AnkXg=", - "dev": true - }, - "chalk": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz", - "integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=", - "dev": true, - "requires": { - "ansi-styles": "~1.0.0", - "has-color": "~0.1.0", - "strip-ansi": "~0.1.0" - } - }, - "strip-ansi": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz", - "integrity": "sha1-OeipjQRNFQZgq+SmgIrPcLt7yZE=", - "dev": true - } - } - }, - "normalize-package-data": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", - "dev": true, - "requires": { - "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - } - }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", @@ -5733,17 +3273,6 @@ "remove-trailing-separator": "^1.0.1" } }, - "normalize-url": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-2.0.1.tgz", - "integrity": "sha1-g1qdoVUfom9w6SMpBpojqmV01+Y=", - "dev": true, - "requires": { - "prepend-http": "^2.0.0", - "query-string": "^5.0.1", - "sort-keys": "^2.0.0" - } - }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -5785,43 +3314,6 @@ "is-descriptor": "^0.1.0" } }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -5842,16 +3334,6 @@ "isobject": "^3.0.0" } }, - "object.omit": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", - "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true, - "requires": { - "for-own": "^0.1.4", - "is-extendable": "^0.1.1" - } - }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -5893,88 +3375,21 @@ "wordwrap": "~1.0.0" } }, - "ora": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/ora/-/ora-0.2.3.tgz", - "integrity": "sha1-N1J9Igrc1Tw5tzVx11QVbV22V6Q=", - "dev": true, - "requires": { - "chalk": "^1.1.1", - "cli-cursor": "^1.0.2", - "cli-spinners": "^0.1.2", - "object-assign": "^4.0.1" - }, - "dependencies": { - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "cli-cursor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", - "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", - "dev": true, - "requires": { - "restore-cursor": "^1.0.1" - } - }, - "onetime": { - "version": "1.1.0", - "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true - }, - "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", - "dev": true, - "requires": { - "exit-hook": "^1.0.0", - "onetime": "^1.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, "os-browserify": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", "dev": true }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true - }, "os-locale": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha1-QrwpAKa1uL0XN2yOiCtlr8zyS/I=", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.0.1.tgz", + "integrity": "sha512-7g5e7dmXPtzcP4bgsZ8ixDVqA7oWYuEz4lOSujeWyliPai4gfVDiFIcwBg3aGCPnmSGfzOKTK3ccPn0CKv3DBw==", "dev": true, "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" + "execa": "^0.10.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" } }, "os-tmpdir": { @@ -5983,20 +3398,11 @@ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, - "p-cancelable": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-0.4.0.tgz", - "integrity": "sha512-/AodqPe1y/GYbhSlnMjxukLGQfQIgsmjSy2CXCNB96kg4ozKvmlovuHEKICToOO/yS3LLWgrWI1dFtFfrePS1g==", - "dev": true - }, - "p-each-series": { + "p-defer": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-each-series/-/p-each-series-1.0.0.tgz", - "integrity": "sha1-kw89Et0fUOdDRFeiLNbwSsatf3E=", - "dev": true, - "requires": { - "p-reduce": "^1.0.0" - } + "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", + "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", + "dev": true }, "p-finally": { "version": "1.0.0", @@ -6010,16 +3416,10 @@ "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=", "dev": true }, - "p-lazy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-lazy/-/p-lazy-1.0.0.tgz", - "integrity": "sha1-7FPIAvLuOsKPFmzILQsrAt4nqDU=", - "dev": true - }, "p-limit": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz", - "integrity": "sha1-DpK2vty1nwIsE9DxlJ3ILRWQnxw=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", "dev": true, "requires": { "p-try": "^1.0.0" @@ -6034,27 +3434,6 @@ "p-limit": "^1.1.0" } }, - "p-map": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz", - "integrity": "sha1-5OlPMR6rvIYzoeeZCBZfyiYkG2s=", - "dev": true - }, - "p-reduce": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-reduce/-/p-reduce-1.0.0.tgz", - "integrity": "sha1-GMKw3ZNqRpClKfgjH1ig/bakffo=", - "dev": true - }, - "p-timeout": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-2.0.1.tgz", - "integrity": "sha1-2N0ZeVldLcATnh/ka4tkbLPN8Dg=", - "dev": true, - "requires": { - "p-finally": "^1.0.0" - } - }, "p-try": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", @@ -6064,7 +3443,7 @@ "pako": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha1-AQEhG6pwxLykoPY/Igbpe3368lg=", + "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==", "dev": true }, "parallel-transform": { @@ -6079,9 +3458,9 @@ } }, "parse-asn1": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.0.tgz", - "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", + "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", "dev": true, "requires": { "asn1.js": "^4.0.0", @@ -6091,51 +3470,6 @@ "pbkdf2": "^3.0.3" } }, - "parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true, - "requires": { - "glob-base": "^0.3.0", - "is-dotfile": "^1.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.0" - }, - "dependencies": { - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - } - } - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "parse-passwd": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true - }, "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -6178,33 +3512,10 @@ "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", "dev": true }, - "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true - }, - "path-type": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", - "integrity": "sha1-zvMdyOCho7sNEFwM2Xzzv0f0428=", - "dev": true, - "requires": { - "pify": "^3.0.0" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - } - } - }, "pbkdf2": { - "version": "3.0.14", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.14.tgz", - "integrity": "sha512-gjsZW9O34fm0R7PaLHRJmLLVfSoesxztjPjE9o6R+qtVJij90ltg1joIovN9GKrRW3t1PzhDDG3UMEMFfZ+1wA==", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", + "integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==", "dev": true, "requires": { "create-hash": "^1.1.2", @@ -6262,36 +3573,6 @@ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, - "prepend-http": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", - "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", - "dev": true - }, - "preserve": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", - "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", - "dev": true - }, - "prettier": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.11.1.tgz", - "integrity": "sha512-T/KD65Ot0PB97xTrG8afQ46x3oiVhnfGjGESSI9NWYcG92+OUPZKkwHqGWXH2t9jK1crnQjubECW0FuOth+hxw==", - "dev": true - }, - "pretty-bytes": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-4.0.2.tgz", - "integrity": "sha1-sr+C5zUNZcbDOqlaqlpPYyf2HNk=", - "dev": true - }, - "private": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", - "integrity": "sha1-I4Hts2ifelPWUxkAYPz4ItLzaP8=", - "dev": true - }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -6317,13 +3598,13 @@ "dev": true }, "promisify-node": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/promisify-node/-/promisify-node-0.4.0.tgz", - "integrity": "sha1-MoA4dOxBF4TkeGwzmQKoeheaRpw=", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/promisify-node/-/promisify-node-0.5.0.tgz", + "integrity": "sha512-GR2E4qgCoKFTprhULqP2OP3bl8kHo16XtnqtkHH6be7tPW1yL6rXd15nl3oV2sLTFv1+j6tqoF69VVpFtJ/j+A==", "dev": true, "requires": { - "nodegit-promise": "~4.0.0", - "object-assign": "^4.0.1" + "nodegit-promise": "^4.0.0", + "object-assign": "^4.1.1" } }, "prr": { @@ -6339,22 +3620,31 @@ "dev": true }, "public-encrypt": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", - "integrity": "sha1-OfaZ86RlYN1eusvKaTyvfGXBjMY=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, "requires": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1" + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "pump": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", - "integrity": "sha1-Ejma3W5M91Jtlzy8i1zi4pCLOQk=", + "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", "dev": true, "requires": { "end-of-stream": "^1.1.0", @@ -6362,33 +3652,22 @@ } }, "pumpify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.4.0.tgz", - "integrity": "sha1-gLfF334kFT0D8OesigWl0Gi9B/s=", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", + "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", "dev": true, "requires": { - "duplexify": "^3.5.3", + "duplexify": "^3.6.0", "inherits": "^2.0.3", "pump": "^2.0.0" } }, "punycode": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", - "integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, - "query-string": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", - "integrity": "sha1-p4wBK3HBfgXy4/ojGd0zBoLvs8s=", - "dev": true, - "requires": { - "decode-uri-component": "^0.2.0", - "object-assign": "^4.1.0", - "strict-uri-encode": "^1.0.0" - } - }, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", @@ -6401,31 +3680,10 @@ "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "dev": true }, - "randomatic": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "randombytes": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", - "integrity": "sha1-0wLFIpSFiISKjTAMkytEwkIx2oA=", + "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", "dev": true, "requires": { "safe-buffer": "^5.1.0" @@ -6434,52 +3692,13 @@ "randomfill": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha1-ySGW/IarQr6YPxvzF3giSTHWFFg=", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, "requires": { "randombytes": "^2.0.5", "safe-buffer": "^5.1.0" } }, - "read-chunk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/read-chunk/-/read-chunk-2.1.0.tgz", - "integrity": "sha1-agTAkoAF7Z1C4aasVgDhnLx/9lU=", - "dev": true, - "requires": { - "pify": "^3.0.0", - "safe-buffer": "^5.1.1" - }, - "dependencies": { - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - } - } - }, - "read-pkg": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", - "integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=", - "dev": true, - "requires": { - "load-json-file": "^4.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^3.0.0" - } - }, - "read-pkg-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-3.0.0.tgz", - "integrity": "sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc=", - "dev": true, - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^3.0.0" - } - }, "readable-stream": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", @@ -6496,74 +3715,20 @@ } }, "readdirp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "minimatch": "^3.0.2", - "readable-stream": "^2.0.2", - "set-immediate-shim": "^1.0.1" - } - }, - "recast": { - "version": "0.14.7", - "resolved": "https://registry.npmjs.org/recast/-/recast-0.14.7.tgz", - "integrity": "sha1-TxSXwrWCbUKmbo48nYDFEpg/9h0=", - "dev": true, - "requires": { - "ast-types": "0.11.3", - "esprima": "~4.0.0", - "private": "~0.1.5", - "source-map": "~0.6.1" - } - }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "^1.1.6" - } - }, - "regenerate": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.3.tgz", - "integrity": "sha1-DDNtOYBVPXVcObWGrjsgqknIK38=", - "dev": true - }, - "regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk=", - "dev": true - }, - "regenerator-transform": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", - "integrity": "sha1-HkmWg3Ix2ot/PPQRTXG1aRoGgN0=", - "dev": true, - "requires": { - "babel-runtime": "^6.18.0", - "babel-types": "^6.19.0", - "private": "^0.1.6" - } - }, - "regex-cache": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", - "dev": true, - "requires": { - "is-equal-shallow": "^0.1.3" + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" } }, "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha1-H07OJ+ALC2XgJHpoEOaoXYOldSw=", + "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, "requires": { "extend-shallow": "^3.0.2", @@ -6576,32 +3741,6 @@ "integrity": "sha512-8Ph721maXiOYSLtaDGKVmDn5wdsNaF6Px85qFNeMPQq0r8K5Y10tgP6YuR65Ws35n4DvzFcCxEnRNBIXQunzLw==", "dev": true }, - "regexpu-core": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-2.0.0.tgz", - "integrity": "sha1-SdA4g3uNz4v6W5pCE5k45uoq4kA=", - "dev": true, - "requires": { - "regenerate": "^1.2.1", - "regjsgen": "^0.2.0", - "regjsparser": "^0.1.4" - } - }, - "regjsgen": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", - "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", - "dev": true - }, - "regjsparser": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", - "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", - "dev": true, - "requires": { - "jsesc": "~0.5.0" - } - }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -6620,21 +3759,6 @@ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true }, - "repeating": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", - "dev": true, - "requires": { - "is-finite": "^1.0.0" - } - }, - "replace-ext": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", - "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", - "dev": true - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -6657,15 +3781,6 @@ "resolve-from": "^1.0.0" } }, - "resolve": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.6.0.tgz", - "integrity": "sha512-mw7JQNu5ExIkcw4LPih0owX/TZXjD/ZUF/ZQ/pDnkw3ZKhDcZZw5klmBlj6gVMwjQ3Pz5Jgu7F3d0jcDVuEWdw==", - "dev": true, - "requires": { - "path-parse": "^1.0.5" - } - }, "resolve-cwd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz", @@ -6683,16 +3798,6 @@ } } }, - "resolve-dir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-1.0.1.tgz", - "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", - "dev": true, - "requires": { - "expand-tilde": "^2.0.0", - "global-modules": "^1.0.0" - } - }, "resolve-from": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", @@ -6705,15 +3810,6 @@ "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", "dev": true }, - "responselike": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", - "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", - "dev": true, - "requires": { - "lowercase-keys": "^1.0.0" - } - }, "restore-cursor": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", @@ -6727,7 +3823,7 @@ "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha1-uKSCXVvbH8P29Twrwz+BOIaBx7w=", + "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", "dev": true }, "rimraf": { @@ -6740,12 +3836,12 @@ } }, "ripemd160": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", - "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { - "hash-base": "^2.0.0", + "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, @@ -6782,15 +3878,6 @@ "rx-lite": "*" } }, - "rxjs": { - "version": "5.5.8", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.8.tgz", - "integrity": "sha512-Bz7qou7VAIoGiglJZbzbXa4vpX5BmTTN2Dj/se6+SwADtw4SihqBIiEa7VmTXJ8pynvq0iFr5Gx9VLyye1rIxQ==", - "dev": true, - "requires": { - "symbol-observable": "1.0.1" - } - }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", @@ -6807,9 +3894,9 @@ } }, "schema-utils": { - "version": "0.4.5", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.5.tgz", - "integrity": "sha1-IYNvBgiqwXt4+ePiTa/xSlyhOj4=", + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz", + "integrity": "sha512-v/iwU6wvwGK8HbU9yi3/nhGzP0yGSuhQMzL6ySiec1FSrZZDkhm4noOSWzrNFo/jEc+SJY6jRTwuwbSXJPDUnQ==", "dev": true, "requires": { "ajv": "^6.1.0", @@ -6817,31 +3904,37 @@ }, "dependencies": { "ajv": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.4.0.tgz", - "integrity": "sha1-06/3jpJ3VJdx2vAWTP9ISCt1T8Y=", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", + "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", "dev": true, "requires": { - "fast-deep-equal": "^1.0.0", + "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0", - "uri-js": "^3.0.2" + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" } }, "ajv-keywords": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.1.0.tgz", - "integrity": "sha1-rCsnk5xUPpXSwG5/f1wnvkqlQ74=", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.2.0.tgz", + "integrity": "sha1-6GuBnGAs+IIa1jdBNpjx3sAhhHo=", + "dev": true + }, + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true } } }, - "scoped-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/scoped-regex/-/scoped-regex-1.0.0.tgz", - "integrity": "sha1-o0a7Gs1CB65wvXwMfKnlZra63bg=", - "dev": true - }, "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", @@ -6849,9 +3942,9 @@ "dev": true }, "serialize-javascript": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.4.0.tgz", - "integrity": "sha1-fJWFFNtqwkQ6irwGLcn3iGp/YAU=", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.5.0.tgz", + "integrity": "sha512-Ga8c8NjAAp46Br4+0oZ2WxJCwIzwP60Gq1YPgU+39PiTVxyed/iKE/zyZI6+UlVYH5Q4PaQdHhcegIFPZTUfoQ==", "dev": true }, "set-blocking": { @@ -6860,16 +3953,10 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true - }, "set-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha1-ca5KiPD+77v1LR6mBPP7MV67YnQ=", + "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -6898,7 +3985,7 @@ "sha.js": { "version": "2.4.11", "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha1-N6XPC4HsvGlD3hCbopYNGyZYSuc=", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -6920,29 +4007,12 @@ "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, - "shelljs": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.1.tgz", - "integrity": "sha1-cp4DjEE6IlTEB4uV7UbgOXFUqfE=", - "dev": true, - "requires": { - "glob": "^7.0.0", - "interpret": "^1.0.0", - "rechoir": "^0.6.2" - } - }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, - "slash": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", - "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", - "dev": true - }, "slice-ansi": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz", @@ -6952,16 +4022,10 @@ "is-fullwidth-code-point": "^2.0.0" } }, - "slide": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/slide/-/slide-1.1.6.tgz", - "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=", - "dev": true - }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha1-ZJIufFZbDhQgS6GqfWlkJ40lGC0=", + "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, "requires": { "base": "^0.11.1", @@ -6977,7 +4041,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, "requires": { "ms": "2.0.0" @@ -7001,63 +4065,6 @@ "is-extendable": "^0.1.0" } }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -7069,7 +4076,7 @@ "snapdragon-node": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=", + "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, "requires": { "define-property": "^1.0.0", @@ -7085,13 +4092,42 @@ "requires": { "is-descriptor": "^1.0.0" } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } } } }, "snapdragon-util": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=", + "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, "requires": { "kind-of": "^3.2.0" @@ -7108,99 +4144,40 @@ } } }, - "sort-keys": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", - "integrity": "sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=", - "dev": true, - "requires": { - "is-plain-obj": "^1.0.0" - } - }, "source-list-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz", - "integrity": "sha1-qqR0A/eyRakvvJfqCPJQ1gh+0IU=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz", + "integrity": "sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==", "dev": true }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", - "dev": true + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" }, "source-map-resolve": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.1.tgz", - "integrity": "sha1-etD1k/IoFZjoVN+A8ZquS5LXoRo=", + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", + "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", "dev": true, "requires": { - "atob": "^2.0.0", + "atob": "^2.1.1", "decode-uri-component": "^0.2.0", "resolve-url": "^0.2.1", "source-map-url": "^0.4.0", "urix": "^0.1.0" } }, - "source-map-support": { - "version": "0.4.18", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", - "integrity": "sha1-Aoam3ovkJkEzhZTpfM6nXwosWF8=", - "dev": true, - "requires": { - "source-map": "^0.5.6" - }, - "dependencies": { - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } - } - }, "source-map-url": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", "dev": true }, - "spdx-correct": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", - "dev": true, - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-exceptions": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=", - "dev": true - }, - "spdx-expression-parse": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", - "dev": true, - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-license-ids": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=", - "dev": true - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=", + "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, "requires": { "extend-shallow": "^3.0.0" @@ -7215,7 +4192,7 @@ "ssri": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/ssri/-/ssri-5.3.0.tgz", - "integrity": "sha1-ujhyycbTOgcEp9cf8EXl7EiZnQY=", + "integrity": "sha512-XRSIPqLij52MtgoQavH/x/dU1qVKtWUAAZeOHsR9c2Ddi4XerFy3mc1alf+dLJKl9EUIm/Ht+EowFkTUOA6GAQ==", "dev": true, "requires": { "safe-buffer": "^5.1.1" @@ -7239,63 +4216,6 @@ "requires": { "is-descriptor": "^0.1.0" } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true } } }, @@ -7310,9 +4230,9 @@ } }, "stream-each": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.2.tgz", - "integrity": "sha1-joxGP5HaiZF3h2WHP+TZYNj2Fr0=", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.3.tgz", + "integrity": "sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw==", "dev": true, "requires": { "end-of-stream": "^1.1.0", @@ -7320,16 +4240,42 @@ } }, "stream-http": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.1.tgz", - "integrity": "sha1-0EQb4aRXpzpzOop7U1cL69nvZqQ=", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", + "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", "dev": true, "requires": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.1", - "readable-stream": "^2.3.3", + "readable-stream": "^2.3.6", "to-arraybuffer": "^1.0.0", "xtend": "^4.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "stream-shift": { @@ -7338,27 +4284,6 @@ "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", "dev": true }, - "stream-to-observable": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/stream-to-observable/-/stream-to-observable-0.2.0.tgz", - "integrity": "sha1-WdbqOT2HwsDdrBCqDVYbxrpvDhA=", - "dev": true, - "requires": { - "any-observable": "^0.2.0" - } - }, - "strict-uri-encode": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", - "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", - "dev": true - }, - "string-template": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz", - "integrity": "sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0=", - "dev": true - }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -7395,25 +4320,6 @@ } } }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "^0.2.0" - } - }, - "strip-bom-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz", - "integrity": "sha1-+H217yYT9paKpUWr/h7HKLaoKco=", - "dev": true, - "requires": { - "first-chunk-stream": "^2.0.0", - "strip-bom": "^2.0.0" - } - }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -7432,12 +4338,6 @@ "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true }, - "symbol-observable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz", - "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=", - "dev": true - }, "table": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz", @@ -7455,39 +4355,15 @@ "tapable": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.0.0.tgz", - "integrity": "sha1-y7Y52QAu7ZxrWXXrIFmNeTbx+fI=", + "integrity": "sha512-dQRhbNQkRnaqauC7WqSJ21EEksgT0fYZX2lqXzGkpo8JNig9zGZTYoMGvyI2nWmXlE2VSVXVDu7wLVGu/mQEsg==", "dev": true }, - "temp": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", - "integrity": "sha1-4Ma8TSa5AxJEEOT+2BEDAU38H1k=", - "dev": true, - "requires": { - "os-tmpdir": "^1.0.0", - "rimraf": "~2.2.6" - }, - "dependencies": { - "rimraf": { - "version": "2.2.8", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", - "dev": true - } - } - }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, - "textextensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/textextensions/-/textextensions-2.2.0.tgz", - "integrity": "sha1-OKxnYVEoW2WGVFgZh6DOGkSQ0oY=", - "dev": true - }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -7504,16 +4380,10 @@ "xtend": "~4.0.1" } }, - "timed-out": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", - "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", - "dev": true - }, "timers-browserify": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.6.tgz", - "integrity": "sha512-HQ3nbYRAowdVd0ckGFvmJPPCOH/CHleFN/Y0YQCX1DVaB7t+KFvisuyN09fuP8Jtp1CpfSh8O8bMkHbdbPe6Pw==", + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.10.tgz", + "integrity": "sha512-YvC1SV1XdOUaL6gx5CoGroT3Gu49pK9+TZ38ErPldOWW4j49GI1HKs9DV+KGq/w6y+LZ72W1c8cKz2vzY+qpzg==", "dev": true, "requires": { "setimmediate": "^1.0.4" @@ -7534,12 +4404,6 @@ "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", "dev": true }, - "to-fast-properties": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", - "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", - "dev": true - }, "to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", @@ -7563,7 +4427,7 @@ "to-regex": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha1-E8/dmzNlUvMLUfM6iuG0Knp1mc4=", + "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, "requires": { "define-property": "^2.0.2", @@ -7582,10 +4446,10 @@ "repeat-string": "^1.6.1" } }, - "trim-right": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", - "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", "dev": true }, "tty-browserify": { @@ -7612,7 +4476,7 @@ "uglify-es": { "version": "3.3.9", "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz", - "integrity": "sha1-DBxPBwC+2NvBJM2zBNJZLKID5nc=", + "integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==", "dev": true, "requires": { "commander": "~2.13.0", @@ -7620,9 +4484,9 @@ } }, "uglifyjs-webpack-plugin": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.5.tgz", - "integrity": "sha1-Lvg4fI8akD7F5E+jb588vc6mdkE=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.3.0.tgz", + "integrity": "sha512-ovHIch0AMlxjD/97j9AYovZxG5wnHOPkL7T1GKochBADp/Zwc44pEWNqpKl1Loupp1WhFg7SlYmHZRUfdAacgw==", "dev": true, "requires": { "cacache": "^10.0.4", @@ -7635,12 +4499,6 @@ "worker-farm": "^1.5.2" } }, - "underscore": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.6.0.tgz", - "integrity": "sha1-izixDKze9jM3uLJOT/htRa6lKag=", - "dev": true - }, "union-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", @@ -7677,18 +4535,18 @@ } }, "unique-filename": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.0.tgz", - "integrity": "sha1-0F8v5AMlYIcfMOk8vnNe6iAVFPM=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", + "integrity": "sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ==", "dev": true, "requires": { "unique-slug": "^2.0.0" } }, "unique-slug": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.0.tgz", - "integrity": "sha1-22Z258fMBimHj/GWCXx4hVrp9Ks=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.1.tgz", + "integrity": "sha512-n9cU6+gITaVu7VGj1Z8feKMmfAjEAQGhwD9fE3zvpRRa0wEIx8ODYkVGfSc94M2OX00tUFV8wH3zYbm1I8mxFg==", "dev": true, "requires": { "imurmurhash": "^0.1.4" @@ -7740,22 +4598,16 @@ } } }, - "untildify": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/untildify/-/untildify-3.0.2.tgz", - "integrity": "sha1-fx8wIFWz/qDz6B3HjrNnZstl4/E=", - "dev": true - }, "upath": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.0.4.tgz", - "integrity": "sha512-d4SJySNBXDaQp+DPrziv3xGS6w3d2Xt69FijJr86zMPBy23JEloMCEOUBBzuN7xCtjLCnmB9tI/z7SBCahHBOw==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.0.tgz", + "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", "dev": true }, "uri-js": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-3.0.2.tgz", - "integrity": "sha1-+QuFhQf4HepNz7s8TD2/orVX+qo=", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", "dev": true, "requires": { "punycode": "^2.1.0" @@ -7785,45 +4637,22 @@ } } }, - "url-parse-lax": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", - "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", - "dev": true, - "requires": { - "prepend-http": "^2.0.0" - } - }, - "url-to-options": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/url-to-options/-/url-to-options-1.0.1.tgz", - "integrity": "sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k=", - "dev": true - }, "use": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/use/-/use-3.1.0.tgz", - "integrity": "sha1-FHFr8D/f79AwQK71jYtLhfOnxUQ=", + "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", "dev": true, "requires": { "kind-of": "^6.0.2" } }, "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, "requires": { - "inherits": "2.0.1" - }, - "dependencies": { - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true - } + "inherits": "2.0.3" } }, "util-deprecate": { @@ -7833,46 +4662,11 @@ "dev": true }, "v8-compile-cache": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-1.1.2.tgz", - "integrity": "sha1-jTLk8Wl0ZUZX5nbg5GejSOibDcQ=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.2.tgz", + "integrity": "sha512-1wFuMUIM16MDJRCrpbpuEPTUGmM5QMUg0cr3KFwra2XgOgFcPGDQHDh3CszSCD2Zewc/dh/pamNEW8CbfDebUw==", "dev": true }, - "validate-npm-package-license": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", - "dev": true, - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, - "vinyl": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-1.2.0.tgz", - "integrity": "sha1-XIgDbPVl5d8FVYv8kR+GVt8hiIQ=", - "dev": true, - "requires": { - "clone": "^1.0.0", - "clone-stats": "^0.0.1", - "replace-ext": "0.0.1" - } - }, - "vinyl-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/vinyl-file/-/vinyl-file-2.0.0.tgz", - "integrity": "sha1-p+v1/779obfRjRQPyweyI++2dRo=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "pify": "^2.3.0", - "pinkie-promise": "^2.0.0", - "strip-bom": "^2.0.0", - "strip-bom-stream": "^2.0.0", - "vinyl": "^1.1.0" - } - }, "vivid-cli": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vivid-cli/-/vivid-cli-1.1.2.tgz", @@ -7889,9 +4683,9 @@ } }, "watchpack": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.5.0.tgz", - "integrity": "sha512-RSlipNQB1u48cq0wH/BNfCu1tD/cJ8ydFIkNYhp9o+3d+8unClkIovpW5qpFPgmL9OE48wfAnlZydXByWP82AA==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", + "integrity": "sha512-i6dHe3EyLjMmDlU1/bGQpEw25XSjkJULPuAVKCbNRefQVq48yXKUpwg538F7AZTf9kyr57zj++pQFltUa5H7yA==", "dev": true, "requires": { "chokidar": "^2.0.2", @@ -7899,35 +4693,24 @@ "neo-async": "^2.5.0" } }, - "webassemblyjs": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/webassemblyjs/-/webassemblyjs-1.4.3.tgz", - "integrity": "sha512-4lOV1Lv6olz0PJkDGQEp82HempAn147e6BXijWDzz9g7/2nSebVP9GVg62Fz5ZAs55mxq13GA0XLyvY8XkyDjg==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.4.3", - "@webassemblyjs/validation": "1.4.3", - "@webassemblyjs/wasm-parser": "1.4.3", - "@webassemblyjs/wast-parser": "1.4.3", - "long": "^3.2.0" - } - }, "webpack": { - "version": "4.8.3", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.8.3.tgz", - "integrity": "sha512-/hfAjBISycdK597lxONjKEFX7dSIU1PsYwC3XlXUXoykWBlv9QV5HnO+ql3HvrrgfBJ7WXdnjO9iGPR2aAc5sw==", + "version": "4.23.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.23.0.tgz", + "integrity": "sha512-Osh/3U9y4swhEKDjy8fF48v2Qx5VC6VvdQ8bEm1HMaVVddiQBw4+mIyDrzVcVRCPT/+4uJFOcklPuoB+I3Zw0w==", "dev": true, "requires": { - "@webassemblyjs/ast": "1.4.3", - "@webassemblyjs/wasm-edit": "1.4.3", - "@webassemblyjs/wasm-parser": "1.4.3", - "acorn": "^5.0.0", + "@webassemblyjs/ast": "1.7.10", + "@webassemblyjs/helper-module-context": "1.7.10", + "@webassemblyjs/wasm-edit": "1.7.10", + "@webassemblyjs/wasm-parser": "1.7.10", + "acorn": "^5.6.2", "acorn-dynamic-import": "^3.0.0", "ajv": "^6.1.0", "ajv-keywords": "^3.1.0", - "chrome-trace-event": "^0.1.1", - "enhanced-resolve": "^4.0.0", - "eslint-scope": "^3.7.1", + "chrome-trace-event": "^1.0.0", + "enhanced-resolve": "^4.1.0", + "eslint-scope": "^4.0.0", + "json-parse-better-errors": "^1.0.2", "loader-runner": "^2.3.0", "loader-utils": "^1.1.0", "memory-fs": "~0.4.1", @@ -7936,22 +4719,28 @@ "neo-async": "^2.5.0", "node-libs-browser": "^2.0.0", "schema-utils": "^0.4.4", - "tapable": "^1.0.0", + "tapable": "^1.1.0", "uglifyjs-webpack-plugin": "^1.2.4", "watchpack": "^1.5.0", - "webpack-sources": "^1.0.1" + "webpack-sources": "^1.3.0" }, "dependencies": { + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", + "dev": true + }, "ajv": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.0.tgz", - "integrity": "sha512-VDUX1oSajablmiyFyED9L1DFndg0P9h7p1F+NO8FkIzei6EPrR6Zu1n18rd5P8PqaSRd/FrWv3G1TVBqpM83gA==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", + "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", "dev": true, "requires": { "fast-deep-equal": "^2.0.1", "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0", - "uri-js": "^4.2.1" + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" } }, "ajv-keywords": { @@ -7960,225 +4749,73 @@ "integrity": "sha1-6GuBnGAs+IIa1jdBNpjx3sAhhHo=", "dev": true }, + "eslint-scope": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz", + "integrity": "sha512-1G6UTDi7Jc1ELFwnR58HV4fK9OQK4S6N985f166xqXxpjU6plxFISJa2Ba9KCQuFa8RCnj/lSFJbHo7UFDBnUA==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, "fast-deep-equal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", "dev": true }, - "uri-js": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.1.tgz", - "integrity": "sha512-jpKCA3HjsBfSDOEgxRDAxQCNyHfCPSbq57PqCkd3gAyBuPb3IWxw54EHncqESznIdqSetHfw3D7ylThu2Kcc9A==", - "dev": true, - "requires": { - "punycode": "^2.1.0" - } - } - } - }, - "webpack-addons": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/webpack-addons/-/webpack-addons-1.1.5.tgz", - "integrity": "sha1-KxeN/oc/tudeQKgZ+lwm5Km8g3o=", - "dev": true, - "requires": { - "jscodeshift": "^0.4.0" - }, - "dependencies": { - "arr-diff": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true, - "requires": { - "arr-flatten": "^1.0.1" - } - }, - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, - "ast-types": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.10.1.tgz", - "integrity": "sha1-9S/KlxVXmhT4QdZ9f40lQyq2o90=", - "dev": true - }, - "babylon": { - "version": "6.18.0", - "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha1-ry87iPpvXB5MY00aD46sT1WzleM=", - "dev": true - }, - "braces": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true, - "requires": { - "expand-range": "^1.8.1", - "preserve": "^0.2.0", - "repeat-element": "^1.1.2" - } - }, - "expand-brackets": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true, - "requires": { - "is-posix-bracket": "^0.1.0" - } - }, - "extglob": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "jscodeshift": { + "json-schema-traverse": { "version": "0.4.1", - "resolved": "https://registry.npmjs.org/jscodeshift/-/jscodeshift-0.4.1.tgz", - "integrity": "sha1-2pGhwuzPoDozh6IdOZSOJRztREo=", - "dev": true, - "requires": { - "async": "^1.5.0", - "babel-plugin-transform-flow-strip-types": "^6.8.0", - "babel-preset-es2015": "^6.9.0", - "babel-preset-stage-1": "^6.5.0", - "babel-register": "^6.9.0", - "babylon": "^6.17.3", - "colors": "^1.1.2", - "flow-parser": "^0.*", - "lodash": "^4.13.1", - "micromatch": "^2.3.7", - "node-dir": "0.1.8", - "nomnom": "^1.8.1", - "recast": "^0.12.5", - "temp": "^0.8.1", - "write-file-atomic": "^1.2.0" - } + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - }, - "micromatch": { - "version": "2.3.11", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true, - "requires": { - "arr-diff": "^2.0.0", - "array-unique": "^0.2.1", - "braces": "^1.8.2", - "expand-brackets": "^0.1.4", - "extglob": "^0.3.1", - "filename-regex": "^2.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.1", - "kind-of": "^3.0.2", - "normalize-path": "^2.0.1", - "object.omit": "^2.0.0", - "parse-glob": "^3.0.4", - "regex-cache": "^0.4.2" - } - }, - "recast": { - "version": "0.12.9", - "resolved": "https://registry.npmjs.org/recast/-/recast-0.12.9.tgz", - "integrity": "sha1-6OUr25aRr0Ysy9fBXVpRE2R6FfE=", - "dev": true, - "requires": { - "ast-types": "0.10.1", - "core-js": "^2.4.1", - "esprima": "~4.0.0", - "private": "~0.1.5", - "source-map": "~0.6.1" - } + "tapable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.0.tgz", + "integrity": "sha512-IlqtmLVaZA2qab8epUXbVWRn3aB1imbDMJtjB3nu4X0NqPkcY/JH9ZtCBWKHWPxs8Svi9tyo8w2dBoi07qZbBA==", + "dev": true } } }, "webpack-cli": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-2.1.3.tgz", - "integrity": "sha512-5AsKoL/Ccn8iTrwk3uErdyhetGH+c7VRQ7Itim2GL0IhBRq5rtojVDk00buMRmFmBpw1RvHXq97Gup965LbozA==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.1.2.tgz", + "integrity": "sha512-Cnqo7CeqeSvC6PTdts+dywNi5CRlIPbLx1AoUPK2T6vC1YAugMG3IOoO9DmEscd+Dghw7uRlnzV1KwOe5IrtgQ==", "dev": true, "requires": { - "chalk": "^2.3.2", + "chalk": "^2.4.1", "cross-spawn": "^6.0.5", - "diff": "^3.5.0", - "enhanced-resolve": "^4.0.0", - "envinfo": "^4.4.2", - "glob-all": "^3.1.0", - "global-modules": "^1.0.0", - "got": "^8.2.0", - "import-local": "^1.0.0", - "inquirer": "^5.1.0", - "interpret": "^1.0.4", - "jscodeshift": "^0.5.0", - "listr": "^0.13.0", + "enhanced-resolve": "^4.1.0", + "global-modules-path": "^2.3.0", + "import-local": "^2.0.0", + "interpret": "^1.1.0", "loader-utils": "^1.1.0", - "lodash": "^4.17.5", - "log-symbols": "^2.2.0", - "mkdirp": "^0.5.1", - "p-each-series": "^1.0.0", - "p-lazy": "^1.0.0", - "prettier": "^1.5.3", - "supports-color": "^5.3.0", - "v8-compile-cache": "^1.1.2", - "webpack-addons": "^1.1.5", - "yargs": "^11.1.0", - "yeoman-environment": "^2.0.0", - "yeoman-generator": "^2.0.4" + "supports-color": "^5.5.0", + "v8-compile-cache": "^2.0.2", + "yargs": "^12.0.2" }, "dependencies": { - "async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", - "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "lodash": "^4.14.0" + "color-convert": "^1.9.0" } }, - "clone": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz", - "integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs=", - "dev": true - }, - "clone-stats": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", - "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", - "dev": true + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } }, "cross-spawn": { "version": "6.0.5", @@ -8193,180 +4830,14 @@ "which": "^1.2.9" } }, - "deep-extend": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.5.1.tgz", - "integrity": "sha512-N8vBdOa+DF7zkRrDCsaOXoCs/E2fJfx9B9MrKnnSiHNh4ws7eSys6YQE4KvT1cecKmOASYQBhbKjeuDD9lT81w==", - "dev": true - }, - "ejs": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.6.1.tgz", - "integrity": "sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ==", - "dev": true - }, - "globby": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/globby/-/globby-8.0.1.tgz", - "integrity": "sha512-oMrYrJERnKBLXNLVTqhm3vPEdJ/b2ZE28xN4YARiix1NOIOBPEpOUnm844K1iu/BkphCaf2WNFwMszv8Soi1pw==", - "dev": true, - "requires": { - "array-union": "^1.0.1", - "dir-glob": "^2.0.0", - "fast-glob": "^2.0.2", - "glob": "^7.1.2", - "ignore": "^3.3.5", - "pify": "^3.0.0", - "slash": "^1.0.0" - } - }, - "inquirer": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.2.0.tgz", - "integrity": "sha512-E9BmnJbAKLPGonz0HeWHtbKf+EeSP93paWO3ZYoUpq/aowXvYGjjCSuashhXPpzbArIjBbji39THkxTz9ZeEUQ==", - "dev": true, - "requires": { - "ansi-escapes": "^3.0.0", - "chalk": "^2.0.0", - "cli-cursor": "^2.1.0", - "cli-width": "^2.0.0", - "external-editor": "^2.1.0", - "figures": "^2.0.0", - "lodash": "^4.3.0", - "mute-stream": "0.0.7", - "run-async": "^2.2.0", - "rxjs": "^5.5.2", - "string-width": "^2.1.0", - "strip-ansi": "^4.0.0", - "through": "^2.3.6" - } - }, - "mem-fs-editor": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/mem-fs-editor/-/mem-fs-editor-4.0.2.tgz", - "integrity": "sha512-QHvdXLLNmwJXxKdf7x27aNUren6IoPxwcM8Sfd+S6/ddQQMcYdEtVKsh6ilpqMrU18VQuKZEaH0aCGt3JDbA0g==", - "dev": true, - "requires": { - "commondir": "^1.0.1", - "deep-extend": "^0.5.1", - "ejs": "^2.5.9", - "glob": "^7.0.3", - "globby": "^8.0.0", - "isbinaryfile": "^3.0.2", - "mkdirp": "^0.5.0", - "multimatch": "^2.0.0", - "rimraf": "^2.2.8", - "through2": "^2.0.0", - "vinyl": "^2.0.1" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - }, - "replace-ext": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", - "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", - "dev": true - }, "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, "requires": { "has-flag": "^3.0.0" } - }, - "vinyl": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.1.0.tgz", - "integrity": "sha1-Ah+cLPlR1rk5lDyJ617lrdT9kkw=", - "dev": true, - "requires": { - "clone": "^2.1.1", - "clone-buffer": "^1.0.0", - "clone-stats": "^1.0.0", - "cloneable-readable": "^1.0.0", - "remove-trailing-separator": "^1.0.1", - "replace-ext": "^1.0.0" - } - }, - "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", - "dev": true - }, - "yargs": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz", - "integrity": "sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A==", - "dev": true, - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.1.1", - "find-up": "^2.1.0", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^9.0.2" - } - }, - "yeoman-generator": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/yeoman-generator/-/yeoman-generator-2.0.5.tgz", - "integrity": "sha512-rV6tJ8oYzm4mmdF2T3wjY+Q42jKF2YiiD0VKfJ8/0ZYwmhCKC9Xs2346HVLPj/xE13i68psnFJv7iS6gWRkeAg==", - "dev": true, - "requires": { - "async": "^2.6.0", - "chalk": "^2.3.0", - "cli-table": "^0.3.1", - "cross-spawn": "^6.0.5", - "dargs": "^5.1.0", - "dateformat": "^3.0.3", - "debug": "^3.1.0", - "detect-conflict": "^1.0.0", - "error": "^7.0.2", - "find-up": "^2.1.0", - "github-username": "^4.0.0", - "istextorbinary": "^2.2.1", - "lodash": "^4.17.10", - "make-dir": "^1.1.0", - "mem-fs-editor": "^4.0.0", - "minimist": "^1.2.0", - "pretty-bytes": "^4.0.2", - "read-chunk": "^2.1.0", - "read-pkg-up": "^3.0.0", - "rimraf": "^2.6.2", - "run-async": "^2.0.0", - "shelljs": "^0.8.0", - "text-table": "^0.2.0", - "through2": "^2.0.0", - "yeoman-environment": "^2.0.5" - }, - "dependencies": { - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true - } - } } } }, @@ -8377,9 +4848,9 @@ "dev": true }, "webpack-sources": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz", - "integrity": "sha1-oQHrrlnWUHNU1x2AE5UKOot6WlQ=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.3.0.tgz", + "integrity": "sha512-OiVgSrbGu7NEnEvQJJgdSFPl2qWKkWq5lHMhgiToIiN9w34EBnjYzSYs+VbL5KoYiLNtFFa7BZIKxRED3I32pA==", "dev": true, "requires": { "source-list-map": "^2.0.0", @@ -8410,7 +4881,7 @@ "worker-farm": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.6.0.tgz", - "integrity": "sha1-rsxAWXb6talVJhgIRvDboojzpKA=", + "integrity": "sha512-6w+3tHbM87WnSWnENBUvA2pxJPLhQUg5LKwUQHq3r+XPhIM+Gh2R5ycbwPCyuGbNg+lPgdcnQUhuC02kJCvffQ==", "dev": true, "requires": { "errno": "~0.1.7" @@ -8472,16 +4943,11 @@ "mkdirp": "^0.5.1" } }, - "write-file-atomic": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.4.tgz", - "integrity": "sha1-+Aek8LHZ6ROuekgRLmzDrxmRtF8=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.11", - "imurmurhash": "^0.1.4", - "slide": "^1.1.5" - } + "xregexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-4.0.0.tgz", + "integrity": "sha512-PHyM+sQouu7xspQQwELlGwwd05mXUFqwFYfqPO0cC7x4fxyHnnuetmQr6CjJiafIDoH4MogHb9dOoJzR/Y4rFg==", + "dev": true }, "xtend": { "version": "4.0.1", @@ -8492,7 +4958,7 @@ "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha1-le+U+F7MgdAHwmThkKEg8KPIVms=", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "dev": true }, "yallist": { @@ -8501,50 +4967,79 @@ "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", "dev": true }, + "yargs": { + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.2.tgz", + "integrity": "sha512-e7SkEx6N6SIZ5c5H22RTZae61qtn3PYUE8JYbBFlK9sYmh3DMQ6E5ygtaG/2BW0JZi4WGgTR2IV5ChqlqrDGVQ==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^2.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^10.1.0" + }, + "dependencies": { + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz", + "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", + "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", + "dev": true + } + } + }, "yargs-parser": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-9.0.2.tgz", - "integrity": "sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc=", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", + "integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==", "dev": true, "requires": { "camelcase": "^4.1.0" } - }, - "yeoman-environment": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/yeoman-environment/-/yeoman-environment-2.0.5.tgz", - "integrity": "sha512-6/W7/B54OPHJXob0n0+pmkwFsirC8cokuQkPSmT/D0lCcSxkKtg/BA6ZnjUBIwjuGqmw3DTrT4en++htaUju5g==", - "dev": true, - "requires": { - "chalk": "^2.1.0", - "debug": "^3.1.0", - "diff": "^3.3.1", - "escape-string-regexp": "^1.0.2", - "globby": "^6.1.0", - "grouped-queue": "^0.3.3", - "inquirer": "^3.3.0", - "is-scoped": "^1.0.0", - "lodash": "^4.17.4", - "log-symbols": "^2.1.0", - "mem-fs": "^1.1.0", - "text-table": "^0.2.0", - "untildify": "^3.0.2" - }, - "dependencies": { - "globby": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", - "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", - "dev": true, - "requires": { - "array-union": "^1.0.1", - "glob": "^7.0.3", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - } - } } } } diff --git a/package.json b/package.json index fb9341f34..ed9da6d2d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "phaser", - "version": "3.11.0-beta1", - "release": "Leafa", + "version": "3.16.0", + "release": "Ishikawa", "description": "A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.", "author": "Richard Davey (http://www.photonstorm.com)", "logo": "https://raw.github.com/photonstorm/phaser/master/phaser-logo-small.png", @@ -15,10 +15,23 @@ "url": "https://photonstorm@github.com/photonstorm/phaser.git" }, "scripts": { + "beta": "npm publish --tag beta", "help": "node scripts/help.js", "build": "webpack", "watch": "webpack --watch", + "buildfb": "webpack --config webpack.fb.config.js", + "watchfb": "webpack --config webpack.fb.config.js --watch", "dist": "webpack --config webpack.dist.config.js", + "distfb": "webpack --config webpack.fb.dist.config.js", + "distfull": "npm run dist && npm run distfb", + "plugin.cam3d": "webpack --config plugins/camera3d/webpack.config.js", + "plugin.spine": "webpack --config plugins/spine/webpack.config.js", + "plugin.spine.dist": "webpack --config plugins/spine/webpack.auto.dist.config.js", + "plugin.spine.watch": "webpack --config plugins/spine/webpack.auto.config.js --watch --display-modules", + "plugin.spine.canvas.dist": "webpack --config plugins/spine/webpack.canvas.dist.config.js", + "plugin.spine.canvas.watch": "webpack --config plugins/spine/webpack.canvas.config.js --watch --display-modules", + "plugin.spine.webgl.dist": "webpack --config plugins/spine/webpack.webgl.dist.config.js", + "plugin.spine.webgl.watch": "webpack --config plugins/spine/webpack.webgl.config.js --watch", "lint": "eslint --config .eslintrc.json \"src/**/*.js\"", "lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix", "sloc": "node-sloc \"./src\" --include-extensions \"js\"", @@ -42,14 +55,16 @@ "eslint": "^4.19.1", "eslint-plugin-es5": "^1.3.1", "fs-extra": "^6.0.0", - "node-sloc": "^0.1.10", - "uglifyjs-webpack-plugin": "^1.2.5", + "node-sloc": "^0.1.11", + "uglifyjs-webpack-plugin": "^1.3.0", "vivid-cli": "^1.1.2", - "webpack": "^4.6.0", - "webpack-cli": "^2.1.2", + "webpack": "^4.23.0", + "webpack-cli": "^3.1.1", "webpack-shell-plugin": "^0.5.0" }, "dependencies": { - "eventemitter3": "^3.1.0" + "eventemitter3": "^3.1.0", + "exports-loader": "^0.7.0", + "imports-loader": "^0.8.0" } } diff --git a/plugins/camera3d/dist/camera3d.js b/plugins/camera3d/dist/camera3d.js new file mode 100644 index 000000000..3d5710ed0 --- /dev/null +++ b/plugins/camera3d/dist/camera3d.js @@ -0,0 +1,18079 @@ +var Camera3DPlugin = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 74); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Taken from klasse by mattdesl https://github.com/mattdesl/klasse + +function hasGetterOrSetter (def) +{ + return (!!def.get && typeof def.get === 'function') || (!!def.set && typeof def.set === 'function'); +} + +function getProperty (definition, k, isClassDescriptor) +{ + // This may be a lightweight object, OR it might be a property that was defined previously. + + // For simple class descriptors we can just assume its NOT previously defined. + var def = (isClassDescriptor) ? definition[k] : Object.getOwnPropertyDescriptor(definition, k); + + if (!isClassDescriptor && def.value && typeof def.value === 'object') + { + def = def.value; + } + + // This might be a regular property, or it may be a getter/setter the user defined in a class. + if (def && hasGetterOrSetter(def)) + { + if (typeof def.enumerable === 'undefined') + { + def.enumerable = true; + } + + if (typeof def.configurable === 'undefined') + { + def.configurable = true; + } + + return def; + } + else + { + return false; + } +} + +function hasNonConfigurable (obj, k) +{ + var prop = Object.getOwnPropertyDescriptor(obj, k); + + if (!prop) + { + return false; + } + + if (prop.value && typeof prop.value === 'object') + { + prop = prop.value; + } + + if (prop.configurable === false) + { + return true; + } + + return false; +} + +function extend (ctor, definition, isClassDescriptor, extend) +{ + for (var k in definition) + { + if (!definition.hasOwnProperty(k)) + { + continue; + } + + var def = getProperty(definition, k, isClassDescriptor); + + if (def !== false) + { + // If Extends is used, we will check its prototype to see if the final variable exists. + + var parent = extend || ctor; + + if (hasNonConfigurable(parent.prototype, k)) + { + // Just skip the final property + if (Class.ignoreFinals) + { + continue; + } + + // We cannot re-define a property that is configurable=false. + // So we will consider them final and throw an error. This is by + // default so it is clear to the developer what is happening. + // You can set ignoreFinals to true if you need to extend a class + // which has configurable=false; it will simply not re-define final properties. + throw new Error('cannot override final property \'' + k + '\', set Class.ignoreFinals = true to skip'); + } + + Object.defineProperty(ctor.prototype, k, def); + } + else + { + ctor.prototype[k] = definition[k]; + } + } +} + +function mixin (myClass, mixins) +{ + if (!mixins) + { + return; + } + + if (!Array.isArray(mixins)) + { + mixins = [ mixins ]; + } + + for (var i = 0; i < mixins.length; i++) + { + extend(myClass, mixins[i].prototype || mixins[i]); + } +} + +/** + * Creates a new class with the given descriptor. + * The constructor, defined by the name `initialize`, + * is an optional function. If unspecified, an anonymous + * function will be used which calls the parent class (if + * one exists). + * + * You can also use `Extends` and `Mixins` to provide subclassing + * and inheritance. + * + * @class Class + * @constructor + * @param {Object} definition a dictionary of functions for the class + * @example + * + * var MyClass = new Phaser.Class({ + * + * initialize: function() { + * this.foo = 2.0; + * }, + * + * bar: function() { + * return this.foo + 5; + * } + * }); + */ +function Class (definition) +{ + if (!definition) + { + definition = {}; + } + + // The variable name here dictates what we see in Chrome debugger + var initialize; + var Extends; + + if (definition.initialize) + { + if (typeof definition.initialize !== 'function') + { + throw new Error('initialize must be a function'); + } + + initialize = definition.initialize; + + // Usually we should avoid 'delete' in V8 at all costs. + // However, its unlikely to make any performance difference + // here since we only call this on class creation (i.e. not object creation). + delete definition.initialize; + } + else if (definition.Extends) + { + var base = definition.Extends; + + initialize = function () + { + base.apply(this, arguments); + }; + } + else + { + initialize = function () {}; + } + + if (definition.Extends) + { + initialize.prototype = Object.create(definition.Extends.prototype); + initialize.prototype.constructor = initialize; + + // For getOwnPropertyDescriptor to work, we need to act directly on the Extends (or Mixin) + + Extends = definition.Extends; + + delete definition.Extends; + } + else + { + initialize.prototype.constructor = initialize; + } + + // Grab the mixins, if they are specified... + var mixins = null; + + if (definition.Mixins) + { + mixins = definition.Mixins; + delete definition.Mixins; + } + + // First, mixin if we can. + mixin(initialize, mixins); + + // Now we grab the actual definition which defines the overrides. + extend(initialize, definition, true, Extends); + + return initialize; +} + +Class.extend = extend; +Class.mixin = mixin; +Class.ignoreFinals = false; + +module.exports = Class; + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * Defines a Point in 2D space, with an x and y component. + * + * @class Point + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of this Point. + * @param {number} [y=x] - The y coordinate of this Point. + */ +var Point = new Class({ + + initialize: + + function Point (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + /** + * The x coordinate of this Point. + * + * @name Phaser.Geom.Point#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * The y coordinate of this Point. + * + * @name Phaser.Geom.Point#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + }, + + /** + * Set the x and y coordinates of the point to the given values. + * + * @method Phaser.Geom.Point#setTo + * @since 3.0.0 + * + * @param {number} [x=0] - The x coordinate of this Point. + * @param {number} [y=x] - The y coordinate of this Point. + * + * @return {Phaser.Geom.Point} This Point object. + */ + setTo: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + } + +}); + +module.exports = Point; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A representation of a vector in 3D space. + * + * A three-component vector. + * + * @class Vector3 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + */ +var Vector3 = new Class({ + + initialize: + + function Vector3 (x, y, z) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector3#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector3#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector3#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.z = 0; + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + }, + + /** + * Set this Vector to point up. + * + * Sets the y component of the vector to 1, and the others to 0. + * + * @method Phaser.Math.Vector3#up + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + up: function () + { + this.x = 0; + this.y = 1; + this.z = 0; + + return this; + }, + + /** + * Make a clone of this Vector3. + * + * @method Phaser.Math.Vector3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} A new Vector3 object containing this Vectors values. + */ + clone: function () + { + return new Vector3(this.x, this.y, this.z); + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#crossVectors + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - [description] + * @param {Phaser.Math.Vector3} b - [description] + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + crossVectors: function (a, b) + { + var ax = a.x; + var ay = a.y; + var az = a.z; + var bx = b.x; + var by = b.y; + var bz = b.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict equality check against each Vector's components. + * + * @method Phaser.Math.Vector3#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to compare against. + * + * @return {boolean} True if the two vectors strictly match, otherwise false. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z)); + }, + + /** + * Copy the components of a given Vector into this Vector. + * + * @method Phaser.Math.Vector3#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + + return this; + }, + + /** + * Set the `x`, `y`, and `z` components of this Vector to the given `x`, `y`, and `z` values. + * + * @method Phaser.Math.Vector3#set + * @since 3.0.0 + * + * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y and z components. + * @param {number} [y] - The y value to set for this Vector. + * @param {number} [z] - The z value to set for this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + set: function (x, y, z) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + } + + return this; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector3#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector3#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector3#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector3#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + scale: function (scale) + { + if (isFinite(scale)) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + } + else + { + this.x = 0; + this.y = 0; + this.z = 0; + } + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector3#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + + return this; + }, + + /** + * Negate the `x`, `y` and `z` components of this Vector. + * + * @method Phaser.Math.Vector3#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector3#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector3#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + + return dx * dx + dy * dy + dz * dz; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector3#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return Math.sqrt(x * x + y * y + z * z); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector3#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + return x * x + y * y + z * z; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector3#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var len = x * x + y * y + z * z; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector3#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to dot product with this Vector3. + * + * @return {number} [description] + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#cross + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - [description] + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + cross: function (v) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var bx = v.x; + var by = v.y; + var bz = v.z; + + this.x = ay * bz - az * by; + this.y = az * bx - ax * bz; + this.z = ax * by - ay * bx; + + return this; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector3#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} v - The Vector3 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector3#transformMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformMat3: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = x * m[0] + y * m[3] + z * m[6]; + this.y = x * m[1] + y * m[4] + z * m[7]; + this.z = x * m[2] + y * m[5] + z * m[8]; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector3#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12]; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13]; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14]; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector3#transformCoordinates + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformCoordinates: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var tx = (x * m[0]) + (y * m[4]) + (z * m[8]) + m[12]; + var ty = (x * m[1]) + (y * m[5]) + (z * m[9]) + m[13]; + var tz = (x * m[2]) + (y * m[6]) + (z * m[10]) + m[14]; + var tw = (x * m[3]) + (y * m[7]) + (z * m[11]) + m[15]; + + this.x = tx / tw; + this.y = ty / tw; + this.z = tz / tw; + + return this; + }, + + /** + * Transform this Vector with the given Quaternion. + * + * @method Phaser.Math.Vector3#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + transformQuat: function (q) + { + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Multiplies this Vector3 by the specified matrix, applying a W divide. This is useful for projection, + * e.g. unprojecting a 2D point into 3D space. + * + * @method Phaser.Math.Vector3#project + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to multiply this Vector3 with. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + project: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var m = mat.val; + + var a00 = m[0]; + var a01 = m[1]; + var a02 = m[2]; + var a03 = m[3]; + var a10 = m[4]; + var a11 = m[5]; + var a12 = m[6]; + var a13 = m[7]; + var a20 = m[8]; + var a21 = m[9]; + var a22 = m[10]; + var a23 = m[11]; + var a30 = m[12]; + var a31 = m[13]; + var a32 = m[14]; + var a33 = m[15]; + + var lw = 1 / (x * a03 + y * a13 + z * a23 + a33); + + this.x = (x * a00 + y * a10 + z * a20 + a30) * lw; + this.y = (x * a01 + y * a11 + z * a21 + a31) * lw; + this.z = (x * a02 + y * a12 + z * a22 + a32) * lw; + + return this; + }, + + /** + * Unproject this point from 2D space to 3D space. + * The point should have its x and y properties set to + * 2D screen space, and the z either at 0 (near plane) + * or 1 (far plane). The provided matrix is assumed to already + * be combined, i.e. projection * view * model. + * + * After this operation, this vector's (x, y, z) components will + * represent the unprojected 3D coordinate. + * + * @method Phaser.Math.Vector3#unproject + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} viewport - Screen x, y, width and height in pixels. + * @param {Phaser.Math.Matrix4} invProjectionView - Combined projection and view matrix. + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + unproject: function (viewport, invProjectionView) + { + var viewX = viewport.x; + var viewY = viewport.y; + var viewWidth = viewport.z; + var viewHeight = viewport.w; + + var x = this.x - viewX; + var y = (viewHeight - this.y - 1) - viewY; + var z = this.z; + + this.x = (2 * x) / viewWidth - 1; + this.y = (2 * y) / viewHeight - 1; + this.z = 2 * z - 1; + + return this.project(invProjectionView); + }, + + /** + * Make this Vector the zero vector (0, 0, 0). + * + * @method Phaser.Math.Vector3#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector3} This Vector3. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + + return this; + } + +}); + +/* +Vector3.Zero = function () +{ + return new Vector3(0, 0, 0); +}; + +Vector3.Up = function () +{ + return new Vector3(0, 1.0, 0); +}; + +Vector3.Copy = function (source) +{ + return new Vector3(source.x, source.y, source.z); +}; + +Vector3.TransformCoordinates = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]) + transformation.m[12]; + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]) + transformation.m[13]; + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]) + transformation.m[14]; + var w = (vector.x * transformation.m[3]) + (vector.y * transformation.m[7]) + (vector.z * transformation.m[11]) + transformation.m[15]; + + return new Vector3(x / w, y / w, z / w); +}; + +Vector3.TransformNormal = function (vector, transformation) +{ + var x = (vector.x * transformation.m[0]) + (vector.y * transformation.m[4]) + (vector.z * transformation.m[8]); + var y = (vector.x * transformation.m[1]) + (vector.y * transformation.m[5]) + (vector.z * transformation.m[9]); + var z = (vector.x * transformation.m[2]) + (vector.y * transformation.m[6]) + (vector.z * transformation.m[10]); + + return new Vector3(x, y, z); +}; + +Vector3.Dot = function (left, right) +{ + return (left.x * right.x + left.y * right.y + left.z * right.z); +}; + +Vector3.Cross = function (left, right) +{ + var x = left.y * right.z - left.z * right.y; + var y = left.z * right.x - left.x * right.z; + var z = left.x * right.y - left.y * right.x; + + return new Vector3(x, y, z); +}; + +Vector3.Normalize = function (vector) +{ + var newVector = Vector3.Copy(vector); + newVector.normalize(); + + return newVector; +}; + +Vector3.Distance = function (value1, value2) +{ + return Math.sqrt(Vector3.DistanceSquared(value1, value2)); +}; + +Vector3.DistanceSquared = function (value1, value2) +{ + var x = value1.x - value2.x; + var y = value1.y - value2.y; + var z = value1.z - value2.z; + + return (x * x) + (y * y) + (z * z); +}; +*/ + +module.exports = Vector3; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @typedef {object} Vector2Like + * + * @property {number} x - The x component. + * @property {number} y - The y component. + */ + +/** + * @classdesc + * A representation of a vector in 2D space. + * + * A two-component vector. + * + * @class Vector2 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number|Vector2Like} [x] - The x component, or an object with `x` and `y` properties. + * @param {number} [y] - The y component. + */ +var Vector2 = new Class({ + + initialize: + + function Vector2 (x, y) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector2#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector2#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + } + else + { + if (y === undefined) { y = x; } + + this.x = x || 0; + this.y = y || 0; + } + }, + + /** + * Make a clone of this Vector2. + * + * @method Phaser.Math.Vector2#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} A clone of this Vector2. + */ + clone: function () + { + return new Vector2(this.x, this.y); + }, + + /** + * Copy the components of a given Vector into this Vector. + * + * @method Phaser.Math.Vector2#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + copy: function (src) + { + this.x = src.x || 0; + this.y = src.y || 0; + + return this; + }, + + /** + * Set the component values of this Vector from a given Vector2Like object. + * + * @method Phaser.Math.Vector2#setFromObject + * @since 3.0.0 + * + * @param {Vector2Like} obj - The object containing the component values to set for this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + setFromObject: function (obj) + { + this.x = obj.x || 0; + this.y = obj.y || 0; + + return this; + }, + + /** + * Set the `x` and `y` components of the this Vector to the given `x` and `y` values. + * + * @method Phaser.Math.Vector2#set + * @since 3.0.0 + * + * @param {number} x - The x value to set for this Vector. + * @param {number} [y=x] - The y value to set for this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + set: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * This method is an alias for `Vector2.set`. + * + * @method Phaser.Math.Vector2#setTo + * @since 3.4.0 + * + * @param {number} x - The x value to set for this Vector. + * @param {number} [y=x] - The y value to set for this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + setTo: function (x, y) + { + return this.set(x, y); + }, + + /** + * Sets the `x` and `y` values of this object from a given polar coordinate. + * + * @method Phaser.Math.Vector2#setToPolar + * @since 3.0.0 + * + * @param {number} azimuth - The angular coordinate, in radians. + * @param {number} [radius=1] - The radial coordinate (length). + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + setToPolar: function (azimuth, radius) + { + if (radius == null) { radius = 1; } + + this.x = Math.cos(azimuth) * radius; + this.y = Math.sin(azimuth) * radius; + + return this; + }, + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict equality check against each Vector's components. + * + * @method Phaser.Math.Vector2#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} v - The vector to compare with this Vector. + * + * @return {boolean} Whether the given Vector is equal to this Vector. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y)); + }, + + /** + * Calculate the angle between this Vector and the positive x-axis, in radians. + * + * @method Phaser.Math.Vector2#angle + * @since 3.0.0 + * + * @return {number} The angle between this Vector, and the positive x-axis, given in radians. + */ + angle: function () + { + // computes the angle in radians with respect to the positive x-axis + + var angle = Math.atan2(this.y, this.x); + + if (angle < 0) + { + angle += 2 * Math.PI; + } + + return angle; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector2#add + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + add: function (src) + { + this.x += src.x; + this.y += src.y; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector2#subtract + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + subtract: function (src) + { + this.x -= src.x; + this.y -= src.y; + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector2#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + multiply: function (src) + { + this.x *= src.x; + this.y *= src.y; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector2#scale + * @since 3.0.0 + * + * @param {number} value - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + scale: function (value) + { + if (isFinite(value)) + { + this.x *= value; + this.y *= value; + } + else + { + this.x = 0; + this.y = 0; + } + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector2#divide + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + divide: function (src) + { + this.x /= src.x; + this.y /= src.y; + + return this; + }, + + /** + * Negate the `x` and `y` components of this Vector. + * + * @method Phaser.Math.Vector2#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector2#distance + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (src) + { + var dx = src.x - this.x; + var dy = src.y - this.y; + + return Math.sqrt(dx * dx + dy * dy); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector2#distanceSq + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (src) + { + var dx = src.x - this.x; + var dy = src.y - this.y; + + return dx * dx + dy * dy; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector2#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + + return Math.sqrt(x * x + y * y); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector2#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + + return x * x + y * y; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector2#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var len = x * x + y * y; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + } + + return this; + }, + + /** + * Right-hand normalize (make unit length) this Vector. + * + * @method Phaser.Math.Vector2#normalizeRightHand + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + normalizeRightHand: function () + { + var x = this.x; + + this.x = this.y * -1; + this.y = x; + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector2#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector2 to dot product with this Vector2. + * + * @return {number} The dot product of this Vector and the given Vector. + */ + dot: function (src) + { + return this.x * src.x + this.y * src.y; + }, + + /** + * [description] + * + * @method Phaser.Math.Vector2#cross + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - [description] + * + * @return {number} [description] + */ + cross: function (src) + { + return this.x * src.y - this.y * src.x; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector2#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector2 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + lerp: function (src, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + + this.x = ax + t * (src.x - ax); + this.y = ay + t * (src.y - ay); + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector2#transformMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector2 with. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + transformMat3: function (mat) + { + var x = this.x; + var y = this.y; + var m = mat.val; + + this.x = m[0] * x + m[3] * y + m[6]; + this.y = m[1] * x + m[4] * y + m[7]; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector2#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector2 with. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[12]; + this.y = m[1] * x + m[5] * y + m[13]; + + return this; + }, + + /** + * Make this Vector the zero vector (0, 0). + * + * @method Phaser.Math.Vector2#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + reset: function () + { + this.x = 0; + this.y = 0; + + return this; + } + +}); + +/** + * A static zero Vector2 for use by reference. + * + * @constant + * @name Phaser.Math.Vector2.ZERO + * @type {Vector2} + * @since 3.1.0 + */ +Vector2.ZERO = new Vector2(); + +module.exports = Vector2; + + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH = __webpack_require__(17); +var GetValue = __webpack_require__(71); + +// Allowed types: + +// Implicit +// { +// x: 4 +// } +// +// From function +// { +// x: function () +// } +// +// Randomly pick one element from the array +// { +// x: [a, b, c, d, e, f] +// } +// +// Random integer between min and max: +// { +// x: { randInt: [min, max] } +// } +// +// Random float between min and max: +// { +// x: { randFloat: [min, max] } +// } + +/** + * [description] + * + * @function Phaser.Utils.Objects.GetAdvancedValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {*} [description] + */ +var GetAdvancedValue = function (source, key, defaultValue) +{ + var value = GetValue(source, key, null); + + if (value === null) + { + return defaultValue; + } + else if (Array.isArray(value)) + { + return MATH.RND.pick(value); + } + else if (typeof value === 'object') + { + if (value.hasOwnProperty('randInt')) + { + return MATH.RND.integerInRange(value.randInt[0], value.randInt[1]); + } + else if (value.hasOwnProperty('randFloat')) + { + return MATH.RND.realInRange(value.randFloat[0], value.randFloat[1]); + } + } + else if (typeof value === 'function') + { + return value(key); + } + + return value; +}; + +module.exports = GetAdvancedValue; + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A representation of a vector in 4D space. + * + * A four-component vector. + * + * @class Vector4 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + * @param {number} [w] - The w component. + */ +var Vector4 = new Class({ + + initialize: + + function Vector4 (x, y, z, w) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector4#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector4#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + /** + * The z component of this Vector. + * + * @name Phaser.Math.Vector4#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.z = 0; + + /** + * The w component of this Vector. + * + * @name Phaser.Math.Vector4#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.w = 0; + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * Make a clone of this Vector4. + * + * @method Phaser.Math.Vector4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} A clone of this Vector4. + */ + clone: function () + { + return new Vector4(this.x, this.y, this.z, this.w); + }, + + /** + * Copy the components of a given Vector into this Vector. + * + * @method Phaser.Math.Vector4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z || 0; + this.w = src.w || 0; + + return this; + }, + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict quality check against each Vector's components. + * + * @method Phaser.Math.Vector4#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - [description] + * + * @return {boolean} [description] + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y) && (this.z === v.z) && (this.w === v.w)); + }, + + /** + * Set the `x`, `y`, `z` and `w` components of the this Vector to the given `x`, `y`, `z` and `w` values. + * + * @method Phaser.Math.Vector4#set + * @since 3.0.0 + * + * @param {(number|object)} x - The x value to set for this Vector, or an object containing x, y, z and w components. + * @param {number} y - The y value to set for this Vector. + * @param {number} z - The z value to set for this Vector. + * @param {number} w - The z value to set for this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector4#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z || 0; + this.w += v.w || 0; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector4#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z || 0; + this.w -= v.w || 0; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector4#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector4#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector4#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector4#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector4#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - The Vector4 to dot product with this Vector4. + * + * @return {number} The dot product of this Vector and the given Vector. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector4#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} v - The Vector4 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector4#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + multiply: function (v) + { + this.x *= v.x; + this.y *= v.y; + this.z *= v.z || 1; + this.w *= v.w || 1; + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector4#divide + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + divide: function (v) + { + this.x /= v.x; + this.y /= v.y; + this.z /= v.z || 1; + this.w /= v.w || 1; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector4#distance + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return Math.sqrt(dx * dx + dy * dy + dz * dz + dw * dw); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector4#distanceSq + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (v) + { + var dx = v.x - this.x; + var dy = v.y - this.y; + var dz = v.z - this.z || 0; + var dw = v.w - this.w || 0; + + return dx * dx + dy * dy + dz * dz + dw * dw; + }, + + /** + * Negate the `x`, `y`, `z` and `w` components of this Vector. + * + * @method Phaser.Math.Vector4#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + this.w = -this.w; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector4#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector4 with. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[8] * z + m[12] * w; + this.y = m[1] * x + m[5] * y + m[9] * z + m[13] * w; + this.z = m[2] * x + m[6] * y + m[10] * z + m[14] * w; + this.w = m[3] * x + m[7] * y + m[11] * z + m[15] * w; + + return this; + }, + + /** + * Transform this Vector with the given Quaternion. + * + * @method Phaser.Math.Vector4#transformQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to transform this Vector with. + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + transformQuat: function (q) + { + // TODO: is this really the same as Vector3? + // Also, what about this: http://molecularmusings.wordpress.com/2013/05/24/a-faster-quaternion-vector-multiplication/ + // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations + var x = this.x; + var y = this.y; + var z = this.z; + var qx = q.x; + var qy = q.y; + var qz = q.z; + var qw = q.w; + + // calculate quat * vec + var ix = qw * x + qy * z - qz * y; + var iy = qw * y + qz * x - qx * z; + var iz = qw * z + qx * y - qy * x; + var iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + this.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + this.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + this.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return this; + }, + + /** + * Make this Vector the zero vector (0, 0, 0, 0). + * + * @method Phaser.Math.Vector4#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector4} This Vector4. + */ + reset: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 0; + + return this; + } + +}); + +// TODO: Check if these are required internally, if not, remove. +Vector4.prototype.sub = Vector4.prototype.subtract; +Vector4.prototype.mul = Vector4.prototype.multiply; +Vector4.prototype.div = Vector4.prototype.divide; +Vector4.prototype.dist = Vector4.prototype.distance; +Vector4.prototype.distSq = Vector4.prototype.distanceSq; +Vector4.prototype.len = Vector4.prototype.length; +Vector4.prototype.lenSq = Vector4.prototype.lengthSq; + +module.exports = Vector4; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A NOOP (No Operation) callback function. + * + * Used internally by Phaser when it's more expensive to determine if a callback exists + * than it is to just invoke an empty function. + * + * @function Phaser.Utils.NOOP + * @since 3.0.0 + */ +var NOOP = function () +{ + // NOOP +}; + +module.exports = NOOP; + + +/***/ }), +/* 7 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Wrap the given `value` between `min` and `max. + * + * @function Phaser.Math.Wrap + * @since 3.0.0 + * + * @param {number} value - The value to wrap. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. + * + * @return {number} The wrapped value. + */ +var Wrap = function (value, min, max) +{ + var range = max - min; + + return (min + ((((value - min) % range) + range) % range)); +}; + +module.exports = Wrap; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Matrix used for display transformations for rendering. + * + * It is represented like so: + * + * ``` + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * ``` + * + * @class TransformMatrix + * @memberOf Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {number} [a=1] - The Scale X value. + * @param {number} [b=0] - The Shear Y value. + * @param {number} [c=0] - The Shear X value. + * @param {number} [d=1] - The Scale Y value. + * @param {number} [tx=0] - The Translate X value. + * @param {number} [ty=0] - The Translate Y value. + */ +var TransformMatrix = new Class({ + + initialize: + + function TransformMatrix (a, b, c, d, tx, ty) + { + if (a === undefined) { a = 1; } + if (b === undefined) { b = 0; } + if (c === undefined) { c = 0; } + if (d === undefined) { d = 1; } + if (tx === undefined) { tx = 0; } + if (ty === undefined) { ty = 0; } + + /** + * The matrix values. + * + * @name Phaser.GameObjects.Components.TransformMatrix#matrix + * @type {Float32Array} + * @since 3.0.0 + */ + this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + + /** + * The decomposed matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * @type {object} + * @since 3.0.0 + */ + this.decomposedMatrix = { + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotation: 0 + }; + }, + + /** + * The Scale X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#a + * @type {number} + * @since 3.4.0 + */ + a: { + + get: function () + { + return this.matrix[0]; + }, + + set: function (value) + { + this.matrix[0] = value; + } + + }, + + /** + * The Shear Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#b + * @type {number} + * @since 3.4.0 + */ + b: { + + get: function () + { + return this.matrix[1]; + }, + + set: function (value) + { + this.matrix[1] = value; + } + + }, + + /** + * The Shear X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#c + * @type {number} + * @since 3.4.0 + */ + c: { + + get: function () + { + return this.matrix[2]; + }, + + set: function (value) + { + this.matrix[2] = value; + } + + }, + + /** + * The Scale Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#d + * @type {number} + * @since 3.4.0 + */ + d: { + + get: function () + { + return this.matrix[3]; + }, + + set: function (value) + { + this.matrix[3] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#e + * @type {number} + * @since 3.11.0 + */ + e: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#f + * @type {number} + * @since 3.11.0 + */ + f: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#tx + * @type {number} + * @since 3.4.0 + */ + tx: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#ty + * @type {number} + * @since 3.4.0 + */ + ty: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The rotation of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#rotation + * @type {number} + * @readOnly + * @since 3.4.0 + */ + rotation: { + + get: function () + { + return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1); + } + + }, + + /** + * The horizontal scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleX + * @type {number} + * @readOnly + * @since 3.4.0 + */ + scaleX: { + + get: function () + { + return Math.sqrt((this.a * this.a) + (this.c * this.c)); + } + + }, + + /** + * The vertical scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleY + * @type {number} + * @readOnly + * @since 3.4.0 + */ + scaleY: { + + get: function () + { + return Math.sqrt((this.b * this.b) + (this.d * this.d)); + } + + }, + + /** + * Reset the Matrix to an identity matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + loadIdentity: function () + { + var matrix = this.matrix; + + matrix[0] = 1; + matrix[1] = 0; + matrix[2] = 0; + matrix[3] = 1; + matrix[4] = 0; + matrix[5] = 0; + + return this; + }, + + /** + * Translate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @since 3.0.0 + * + * @param {number} x - The horizontal translation value. + * @param {number} y - The vertical translation value. + * + * @return {this} This TransformMatrix. + */ + translate: function (x, y) + { + var matrix = this.matrix; + + matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; + matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; + + return this; + }, + + /** + * Scale the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#scale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale value. + * @param {number} y - The vertical scale value. + * + * @return {this} This TransformMatrix. + */ + scale: function (x, y) + { + var matrix = this.matrix; + + matrix[0] *= x; + matrix[1] *= x; + matrix[2] *= y; + matrix[3] *= y; + + return this; + }, + + /** + * Rotate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#rotate + * @since 3.0.0 + * + * @param {number} angle - The angle of rotation in radians. + * + * @return {this} This TransformMatrix. + */ + rotate: function (angle) + { + var sin = Math.sin(angle); + var cos = Math.cos(angle); + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + matrix[0] = a * cos + c * sin; + matrix[1] = b * cos + d * sin; + matrix[2] = a * -sin + c * cos; + matrix[3] = b * -sin + d * cos; + + return this; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiply + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - The Matrix to multiply by. + * @param {Phaser.GameObjects.Components.TransformMatrix} [out] - An optional Matrix to store the results in. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} Either this TransformMatrix, or the `out` Matrix, if given in the arguments. + */ + multiply: function (rhs, out) + { + var matrix = this.matrix; + var source = rhs.matrix; + + var localA = matrix[0]; + var localB = matrix[1]; + var localC = matrix[2]; + var localD = matrix[3]; + var localE = matrix[4]; + var localF = matrix[5]; + + var sourceA = source[0]; + var sourceB = source[1]; + var sourceC = source[2]; + var sourceD = source[3]; + var sourceE = source[4]; + var sourceF = source[5]; + + var destinationMatrix = (out === undefined) ? this : out; + + destinationMatrix.a = sourceA * localA + sourceB * localC; + destinationMatrix.b = sourceA * localB + sourceB * localD; + destinationMatrix.c = sourceC * localA + sourceD * localC; + destinationMatrix.d = sourceC * localB + sourceD * localD; + destinationMatrix.e = sourceE * localA + sourceF * localC + localE; + destinationMatrix.f = sourceE * localB + sourceF * localD + localF; + + return destinationMatrix; + }, + + /** + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiplyWithOffset + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * @param {number} offsetX - Horizontal offset to factor in to the multiplication. + * @param {number} offsetY - Vertical offset to factor in to the multiplication. + * + * @return {this} This TransformMatrix. + */ + multiplyWithOffset: function (src, offsetX, offsetY) + { + var matrix = this.matrix; + var otherMatrix = src.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + var pse = offsetX * a0 + offsetY * c0 + tx0; + var psf = offsetX * b0 + offsetY * d0 + ty0; + + var a1 = otherMatrix[0]; + var b1 = otherMatrix[1]; + var c1 = otherMatrix[2]; + var d1 = otherMatrix[3]; + var tx1 = otherMatrix[4]; + var ty1 = otherMatrix[5]; + + matrix[0] = a1 * a0 + b1 * c0; + matrix[1] = a1 * b0 + b1 * d0; + matrix[2] = c1 * a0 + d1 * c0; + matrix[3] = c1 * b0 + d1 * d0; + matrix[4] = tx1 * a0 + ty1 * c0 + pse; + matrix[5] = tx1 * b0 + ty1 * d0 + psf; + + return this; + }, + + /** + * Transform the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + transform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + matrix[0] = a * a0 + b * c0; + matrix[1] = a * b0 + b * d0; + matrix[2] = c * a0 + d * c0; + matrix[3] = c * b0 + d * d0; + matrix[4] = tx * a0 + ty * c0 + tx0; + matrix[5] = tx * b0 + ty * d0 + ty0; + + return this; + }, + + /** + * Transform a point using this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point to transform. + * @param {number} y - The y coordinate of the point to transform. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - The Point object to store the transformed coordinates. + * + * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} The Point containing the transformed coordinates. + */ + transformPoint: function (x, y, point) + { + if (point === undefined) { point = { x: 0, y: 0 }; } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + point.x = x * a + y * c + tx; + point.y = x * b + y * d + ty; + + return point; + }, + + /** + * Invert the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#invert + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + invert: function () + { + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var n = a * d - b * c; + + matrix[0] = d / n; + matrix[1] = -b / n; + matrix[2] = -c / n; + matrix[3] = a / n; + matrix[4] = (c * ty - d * tx) / n; + matrix[5] = -(a * ty - b * tx) / n; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the matrix given. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFrom + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * + * @return {this} This TransformMatrix. + */ + copyFrom: function (src) + { + var matrix = this.matrix; + + matrix[0] = src.a; + matrix[1] = src.b; + matrix[2] = src.c; + matrix[3] = src.d; + matrix[4] = src.e; + matrix[5] = src.f; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFromArray + * @since 3.11.0 + * + * @param {array} src - The array of values to set into this matrix. + * + * @return {this} This TransformMatrix. + */ + copyFromArray: function (src) + { + var matrix = this.matrix; + + matrix[0] = src[0]; + matrix[1] = src[1]; + matrix[2] = src[2]; + matrix[3] = src[3]; + matrix[4] = src[4]; + matrix[5] = src[5]; + + return this; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + copyToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + setToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToArray + * @since 3.12.0 + * + * @param {array} [out] - The array to copy the matrix values in to. + * + * @return {array} An array where elements 0 to 5 contain the values from this matrix. + */ + copyToArray: function (out) + { + var matrix = this.matrix; + + if (out === undefined) + { + out = [ matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] ]; + } + else + { + out[0] = matrix[0]; + out[1] = matrix[1]; + out[2] = matrix[2]; + out[3] = matrix[3]; + out[4] = matrix[4]; + out[5] = matrix[5]; + } + + return out; + }, + + /** + * Set the values of this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setTransform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + matrix[0] = a; + matrix[1] = b; + matrix[2] = c; + matrix[3] = d; + matrix[4] = tx; + matrix[5] = ty; + + return this; + }, + + /** + * Decompose this Matrix into its translation, scale and rotation values. + * + * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix + * @since 3.0.0 + * + * @return {object} The decomposed Matrix. + */ + decomposeMatrix: function () + { + var decomposedMatrix = this.decomposedMatrix; + + var matrix = this.matrix; + + // a = scale X (1) + // b = shear Y (0) + // c = shear X (0) + // d = scale Y (1) + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + var a2 = a * a; + var b2 = b * b; + var c2 = c * c; + var d2 = d * d; + + var sx = Math.sqrt(a2 + c2); + var sy = Math.sqrt(b2 + d2); + + decomposedMatrix.translateX = matrix[4]; + decomposedMatrix.translateY = matrix[5]; + + decomposedMatrix.scaleX = sx; + decomposedMatrix.scaleY = sy; + + decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); + + return decomposedMatrix; + }, + + /** + * Apply the identity, translate, rotate and scale operations on the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS + * @since 3.0.0 + * + * @param {number} x - The horizontal translation. + * @param {number} y - The vertical translation. + * @param {number} rotation - The angle of rotation in radians. + * @param {number} scaleX - The horizontal scale. + * @param {number} scaleY - The vertical scale. + * + * @return {this} This TransformMatrix. + */ + applyITRS: function (x, y, rotation, scaleX, scaleY) + { + var matrix = this.matrix; + + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); + + // Translate + matrix[4] = x; + matrix[5] = y; + + // Rotate and Scale + matrix[0] = radianCos * scaleX; + matrix[1] = radianSin * scaleX; + matrix[2] = -radianSin * scaleY; + matrix[3] = radianCos * scaleY; + + return this; + }, + + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getX + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated x value. + */ + getX: function (x, y) + { + return x * this.a + y * this.c + this.e; + }, + + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getY + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated y value. + */ + getY: function (x, y) + { + return x * this.b + y * this.d + this.f; + }, + + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getCSSMatrix + * @since 3.12.0 + * + * @return {string} A string containing the CSS Transform matrix values. + */ + getCSSMatrix: function () + { + var m = this.matrix; + + return 'matrix(' + m[0] + ',' + m[1] + ',' + m[2] + ',' + m[3] + ',' + m[4] + ',' + m[5] + ')'; + }, + + /** + * Destroys this Transform Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#destroy + * @since 3.4.0 + */ + destroy: function () + { + this.matrix = null; + this.decomposedMatrix = null; + } + +}); + +module.exports = TransformMatrix; + + +/***/ }), +/* 9 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Perimeter + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * + * @return {number} [description] + */ +var Perimeter = function (rect) +{ + return 2 * (rect.width + rect.height); +}; + +module.exports = Perimeter; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Perimeter = __webpack_require__(9); +var Point = __webpack_require__(1); + +/** + * Position is a value between 0 and 1 where 0 = the top-left of the rectangle and 0.5 = the bottom right. + * + * @function Phaser.Geom.Rectangle.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {number} position - [description] + * @param {(Phaser.Geom.Point|object)} [out] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var GetPoint = function (rectangle, position, out) +{ + if (out === undefined) { out = new Point(); } + + if (position <= 0 || position >= 1) + { + out.x = rectangle.x; + out.y = rectangle.y; + + return out; + } + + var p = Perimeter(rectangle) * position; + + if (position > 0.5) + { + p -= (rectangle.width + rectangle.height); + + if (p <= rectangle.width) + { + // Face 3 + out.x = rectangle.right - p; + out.y = rectangle.bottom; + } + else + { + // Face 4 + out.x = rectangle.x; + out.y = rectangle.bottom - (p - rectangle.width); + } + } + else if (p <= rectangle.width) + { + // Face 1 + out.x = rectangle.x + p; + out.y = rectangle.y; + } + else + { + // Face 2 + out.x = rectangle.right; + out.y = rectangle.y + (p - rectangle.width); + } + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.GameObjects.Components + */ + +module.exports = { + + Alpha: __webpack_require__(62), + Animation: __webpack_require__(60), + BlendMode: __webpack_require__(59), + ComputedSize: __webpack_require__(58), + Crop: __webpack_require__(57), + Depth: __webpack_require__(56), + Flip: __webpack_require__(55), + GetBounds: __webpack_require__(54), + Mask: __webpack_require__(43), + Origin: __webpack_require__(40), + Pipeline: __webpack_require__(39), + ScaleMode: __webpack_require__(38), + ScrollFactor: __webpack_require__(37), + Size: __webpack_require__(36), + Texture: __webpack_require__(35), + TextureCrop: __webpack_require__(34), + Tint: __webpack_require__(33), + ToJSON: __webpack_require__(32), + Transform: __webpack_require__(31), + TransformMatrix: __webpack_require__(8), + Visible: __webpack_require__(28) + +}; + + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(11); +var DataManager = __webpack_require__(27); +var EventEmitter = __webpack_require__(26); + +/** + * @classdesc + * The base class that all Game Objects extend. + * You don't create GameObjects directly and they cannot be added to the display list. + * Instead, use them as the base for your own custom classes. + * + * @class GameObject + * @memberOf Phaser.GameObjects + * @extends Phaser.Events.EventEmitter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`. + */ +var GameObject = new Class({ + + Extends: EventEmitter, + + initialize: + + function GameObject (scene, type) + { + EventEmitter.call(this); + + /** + * The Scene to which this Game Object belongs. + * Game Objects can only belong to one Scene. + * + * @name Phaser.GameObjects.GameObject#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A textual representation of this Game Object, i.e. `sprite`. + * Used internally by Phaser but is available for your own custom classes to populate. + * + * @name Phaser.GameObjects.GameObject#type + * @type {string} + * @since 3.0.0 + */ + this.type = type; + + /** + * The parent Container of this Game Object, if it has one. + * + * @name Phaser.GameObjects.GameObject#parentContainer + * @type {Phaser.GameObjects.Container} + * @since 3.4.0 + */ + this.parentContainer = null; + + /** + * The name of this Game Object. + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.GameObject#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The active state of this Game Object. + * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. + * An active object is one which is having its logic and internal systems updated. + * + * @name Phaser.GameObjects.GameObject#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * The Tab Index of the Game Object. + * Reserved for future use by plugins and the Input Manager. + * + * @name Phaser.GameObjects.GameObject#tabIndex + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.tabIndex = -1; + + /** + * A Data Manager. + * It allows you to store, query and get key/value paired information specific to this Game Object. + * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. + * + * @name Phaser.GameObjects.GameObject#data + * @type {Phaser.Data.DataManager} + * @default null + * @since 3.0.0 + */ + this.data = null; + + /** + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. + * + * @name Phaser.GameObjects.GameObject#renderFlags + * @type {integer} + * @default 15 + * @since 3.0.0 + */ + this.renderFlags = 15; + + /** + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + * + * @example + * this.cameraFilter |= camera.id + * + * @name Phaser.GameObjects.GameObject#cameraFilter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cameraFilter = 0; + + /** + * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. + * Not usually set directly. Instead call `GameObject.setInteractive()`. + * + * @name Phaser.GameObjects.GameObject#input + * @type {?Phaser.Input.InteractiveObject} + * @default null + * @since 3.0.0 + */ + this.input = null; + + /** + * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. + * + * @name Phaser.GameObjects.GameObject#body + * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} + * @default null + * @since 3.0.0 + */ + 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 + scene.sys.queueDepthSort(); + + scene.sys.events.once('shutdown', this.destroy, this); + }, + + /** + * Sets the `active` property of this Game Object and returns this Game Object for further chaining. + * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. + * + * @method Phaser.GameObjects.GameObject#setActive + * @since 3.0.0 + * + * @param {boolean} value - True if this Game Object should be set as active, false if not. + * + * @return {this} This GameObject. + */ + setActive: function (value) + { + this.active = value; + + return this; + }, + + /** + * Sets the `name` property of this Game Object and returns this Game Object for further chaining. + * The `name` property is not populated by Phaser and is presented for your own use. + * + * @method Phaser.GameObjects.GameObject#setName + * @since 3.0.0 + * + * @param {string} value - The name to be given to this Game Object. + * + * @return {this} This GameObject. + */ + setName: function (value) + { + this.name = value; + + return this; + }, + + /** + * Adds a Data Manager component to this Game Object. + * + * @method Phaser.GameObjects.GameObject#setDataEnabled + * @since 3.0.0 + * @see Phaser.Data.DataManager + * + * @return {this} This GameObject. + */ + setDataEnabled: function () + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this; + }, + + /** + * Allows you to store a key value pair within this Game Objects Data Manager. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * sprite.setData('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `getData`: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * sprite.data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.GameObjects.GameObject#setData + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {this} This GameObject. + */ + setData: function (key, value) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + this.data.set(key, value); + + return this; + }, + + /** + * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * sprite.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * sprite.getData([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.GameObjects.GameObject#getData + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + getData: function (key) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this.data.get(key); + }, + + /** + * Pass this Game Object to the Input Manager to enable it for Input. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * + * @method Phaser.GameObjects.GameObject#setInteractive + * @since 3.0.0 + * + * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? + * + * @return {this} This GameObject. + */ + setInteractive: function (shape, callback, dropZone) + { + this.scene.sys.input.enable(this, shape, callback, dropZone); + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will disable it. + * + * An object that is disabled for input stops processing or being considered for + * input events, but can be turned back on again at any time by simply calling + * `setInteractive()` with no arguments provided. + * + * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. + * + * @method Phaser.GameObjects.GameObject#disableInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + disableInteractive: function () + { + if (this.input) + { + this.input.enabled = false; + } + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. + * + * The Interactive Object that was assigned to this Game Object will be destroyed, + * removed from the Input Manager and cleared from this Game Object. + * + * If you wish to re-enable this Game Object at a later date you will need to + * re-create its InteractiveObject by calling `setInteractive` again. + * + * If you wish to only temporarily stop an object from receiving input then use + * `disableInteractive` instead, as that toggles the interactive state, where-as + * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) + * + * @method Phaser.GameObjects.GameObject#removeInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + removeInteractive: function () + { + this.scene.sys.input.clear(this); + + this.input = undefined; + + return this; + }, + + /** + * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. + * + * @method Phaser.GameObjects.GameObject#update + * @since 3.0.0 + * + * @param {...*} [args] - args + */ + update: function () + { + }, + + /** + * Returns a JSON representation of the Game Object. + * + * @method Phaser.GameObjects.GameObject#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + return Components.ToJSON(this); + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * + * @method Phaser.GameObjects.GameObject#willRender + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * + * @return {boolean} True if the Game Object should be rendered, otherwise false. + */ + willRender: function (camera) + { + return !(GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter > 0 && (this.cameraFilter & camera.id))); + }, + + /** + * Returns an array containing the display list index of either this Game Object, or if it has one, + * its parent Container. It then iterates up through all of the parent containers until it hits the + * root of the display list (which is index 0 in the returned array). + * + * Used internally by the InputPlugin but also useful if you wish to find out the display depth of + * this Game Object and all of its ancestors. + * + * @method Phaser.GameObjects.GameObject#getIndexList + * @since 3.4.0 + * + * @return {integer[]} An array of display list position indexes. + */ + getIndexList: function () + { + // eslint-disable-next-line consistent-this + var child = this; + var parent = this.parentContainer; + + var indexes = []; + + while (parent) + { + // indexes.unshift([parent.getIndex(child), parent.name]); + indexes.unshift(parent.getIndex(child)); + + child = parent; + + if (!parent.parentContainer) + { + break; + } + else + { + parent = parent.parentContainer; + } + } + + // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']); + indexes.unshift(this.scene.sys.displayList.getIndex(child)); + + return indexes; + }, + + /** + * Destroys this Game Object removing it from the Display List and Update List and + * severing all ties to parent resources. + * + * Also removes itself from the Input Manager and Physics Manager if previously enabled. + * + * Use this to remove a Game Object from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * + * @method Phaser.GameObjects.GameObject#destroy + * @since 3.0.0 + */ + destroy: function () + { + // This Game Object had already been destroyed + if (!this.scene || this.ignoreDestroy) + { + return; + } + + if (this.preDestroy) + { + this.preDestroy.call(this); + } + + this.emit('destroy', this); + + var sys = this.scene.sys; + + sys.displayList.remove(this); + sys.updateList.remove(this); + + if (this.input) + { + sys.input.clear(this); + this.input = undefined; + } + + if (this.data) + { + this.data.destroy(); + + this.data = undefined; + } + + if (this.body) + { + this.body.destroy(); + this.body = undefined; + } + + // Tell the Scene to re-sort the children + sys.queueDepthSort(); + + this.active = false; + this.visible = false; + + this.scene = undefined; + + this.parentContainer = undefined; + + this.removeAllListeners(); + } + +}); + +/** + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + * + * @constant {integer} RENDER_MASK + * @memberOf Phaser.GameObjects.GameObject + * @default + */ +GameObject.RENDER_MASK = 15; + +module.exports = GameObject; + + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GameObject = __webpack_require__(12); +var Sprite = __webpack_require__(25); +var Vector2 = __webpack_require__(3); +var Vector4 = __webpack_require__(5); + +/** + * @classdesc + * A Sprite 3D Game Object. + * + * The Sprite 3D object is an encapsulation of a standard Sprite object, with additional methods to allow + * it to be rendered by a 3D Camera. The Sprite can be positioned anywhere within 3D space. + * + * @class Sprite3D + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The x position of this Game Object. + * @param {number} y - The y position of this Game Object. + * @param {number} z - The z position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Sprite3D = new Class({ + + Extends: GameObject, + + initialize: + + function Sprite3D (scene, x, y, z, texture, frame) + { + GameObject.call(this, scene, 'Sprite3D'); + + /** + * The encapsulated Sprite. + * + * @name Phaser.GameObjects.Sprite3D#gameObject + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.gameObject = new Sprite(scene, 0, 0, texture, frame); + + /** + * The position of the Sprite. + * + * @name Phaser.GameObjects.Sprite3D#position + * @type {Phaser.Math.Vector4} + * @since 3.0.0 + */ + this.position = new Vector4(x, y, z); + + /** + * The 2D size of the Sprite. + * + * @name Phaser.GameObjects.Sprite3D#size + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.size = new Vector2(this.gameObject.width, this.gameObject.height); + + /** + * The 2D scale of the Sprite. + * + * @name Phaser.GameObjects.Sprite3D#scale + * @type {Phaser.Math.Vector2} + * @since 3.0.0 + */ + this.scale = new Vector2(1, 1); + + /** + * Whether to automatically set the horizontal scale of the encapsulated Sprite. + * + * @name Phaser.GameObjects.Sprite3D#adjustScaleX + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.adjustScaleX = true; + + /** + * Whether to automatically set the vertical scale of the encapsulated Sprite. + * + * @name Phaser.GameObjects.Sprite3D#adjustScaleY + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.adjustScaleY = true; + + /** + * The visible state of the Game Object. + * + * @name Phaser.GameObjects.Sprite3D#_visible + * @type {boolean} + * @default true + * @private + * @since 3.0.0 + */ + this._visible = true; + }, + + /** + * Project this Sprite onto the given 3D Camera. + * + * @method Phaser.GameObjects.Sprite3D#project + * @since 3.0.0 + * + * @param {Phaser.Cameras.Sprite3D.Camera} camera - The 3D Camera onto which to project this Sprite. + */ + project: function (camera) + { + var pos = this.position; + + var gameObject = this.gameObject; + + camera.project(pos, gameObject); + + camera.getPointSize(pos, this.size, this.scale); + + if (this.scale.x <= 0 || this.scale.y <= 0) + { + gameObject.setVisible(false); + } + else + { + if (!gameObject.visible) + { + gameObject.setVisible(true); + } + + if (this.adjustScaleX) + { + gameObject.scaleX = this.scale.x; + } + + if (this.adjustScaleY) + { + gameObject.scaleY = this.scale.y; + } + + gameObject.setDepth(gameObject.z * -1); + } + }, + + /** + * Set the visible state of the Game Object. + * + * @method Phaser.GameObjects.Sprite3D#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {Phaser.GameObjects.Sprite3D} This Sprite3D Object. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + }, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Sprite3D#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + this._visible = value; + this.gameObject.visible = value; + } + + }, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Sprite3D#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + } + + }, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Sprite3D#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + } + + }, + + /** + * The z position of this Game Object. + * + * @name Phaser.GameObjects.Sprite3D#z + * @type {number} + * @since 3.0.0 + */ + z: { + + get: function () + { + return this.position.z; + }, + + set: function (value) + { + this.position.z = value; + } + + } + +}); + +module.exports = Sprite3D; + + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +var EPSILON = 0.000001; + +/** + * @classdesc + * A four-dimensional matrix. + * + * @class Matrix4 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} [m] - Optional Matrix4 to copy values from. + */ +var Matrix4 = new Class({ + + initialize: + + function Matrix4 (m) + { + /** + * The matrix values. + * + * @name Phaser.Math.Matrix4#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(16); + + if (m) + { + // Assume Matrix4 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * Make a clone of this Matrix4. + * + * @method Phaser.Math.Matrix4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} A clone of this Matrix4. + */ + clone: function () + { + return new Matrix4(this); + }, + + // TODO - Should work with basic values + + /** + * This method is an alias for `Matrix4.copy`. + * + * @method Phaser.Math.Matrix4#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to set the values of this Matrix's from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * Copy the values of a given Matrix into this Matrix. + * + * @method Phaser.Math.Matrix4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Set the values of this Matrix from the given array. + * + * @method Phaser.Math.Matrix4#fromArray + * @since 3.0.0 + * + * @param {array} a - The array to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Reset this Matrix. + * + * Sets all values to `0`. + * + * @method Phaser.Math.Matrix4#zero + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + zero: function () + { + var out = this.val; + + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 0; + + return this; + }, + + /** + * Set the `x`, `y` and `z` values of this Matrix. + * + * @method Phaser.Math.Matrix4#xyz + * @since 3.0.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * @param {number} z - The z value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + xyz: function (x, y, z) + { + this.identity(); + + var out = this.val; + + out[12] = x; + out[13] = y; + out[14] = z; + + return this; + }, + + /** + * Set the scaling values of this Matrix. + * + * @method Phaser.Math.Matrix4#scaling + * @since 3.0.0 + * + * @param {number} x - The x scaling value. + * @param {number} y - The y scaling value. + * @param {number} z - The z scaling value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scaling: function (x, y, z) + { + this.zero(); + + var out = this.val; + + out[0] = x; + out[5] = y; + out[10] = z; + out[15] = 1; + + return this; + }, + + /** + * Reset this Matrix to an identity (default) matrix. + * + * @method Phaser.Math.Matrix4#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Transpose this Matrix. + * + * @method Phaser.Math.Matrix4#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + transpose: function () + { + var a = this.val; + + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a12 = a[6]; + var a13 = a[7]; + var a23 = a[11]; + + a[1] = a[4]; + a[2] = a[8]; + a[3] = a[12]; + a[4] = a01; + a[6] = a[9]; + a[7] = a[13]; + a[8] = a02; + a[9] = a12; + a[11] = a[14]; + a[12] = a03; + a[13] = a13; + a[14] = a23; + + return this; + }, + + /** + * Invert this Matrix. + * + * @method Phaser.Math.Matrix4#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return this; + }, + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + * + * @method Phaser.Math.Matrix4#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); + a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); + a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); + a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); + a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); + a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); + a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); + a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); + + return this; + }, + + /** + * Calculate the determinant of this Matrix. + * + * @method Phaser.Math.Matrix4#determinant + * @since 3.0.0 + * + * @return {number} The determinant of this Matrix. + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * @method Phaser.Math.Matrix4#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to multiply this Matrix by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b = src.val; + + // Cache only the current line of the second matrix + var b0 = b[0]; + var b1 = b[1]; + var b2 = b[2]; + var b3 = b[3]; + + a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + + a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + + a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + + a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#multiplyLocal + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiplyLocal: function (src) + { + var a = []; + var m1 = this.val; + var m2 = src.val; + + a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; + a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; + a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; + a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; + + a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; + a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; + a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; + a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; + + a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; + a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; + a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; + a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; + + a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; + a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; + a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; + a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; + + return this.fromArray(a); + }, + + /** + * Translate this Matrix using the given Vector. + * + * @method Phaser.Math.Matrix4#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + translate: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix. + * + * @method Phaser.Math.Matrix4#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scale: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[0] = a[0] * x; + a[1] = a[1] * x; + a[2] = a[2] * x; + a[3] = a[3] * x; + + a[4] = a[4] * y; + a[5] = a[5] * y; + a[6] = a[6] * y; + a[7] = a[7] * y; + + a[8] = a[8] * z; + a[9] = a[9] * z; + a[10] = a[10] * z; + a[11] = a[11] * z; + + return this; + }, + + /** + * Derive a rotation matrix around the given axis. + * + * @method Phaser.Math.Matrix4#makeRotationAxis + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis. + * @param {number} angle - The rotation angle in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + makeRotationAxis: function (axis, angle) + { + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + var c = Math.cos(angle); + var s = Math.sin(angle); + var t = 1 - c; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var tx = t * x; + var ty = t * y; + + this.fromArray([ + tx * x + c, tx * y - s * z, tx * z + s * y, 0, + tx * y + s * z, ty * y + c, ty * z - s * x, 0, + tx * z - s * y, ty * z + s * x, t * z * z + c, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + /** + * Apply a rotation transformation to this Matrix. + * + * @method Phaser.Math.Matrix4#rotate + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * @param {Phaser.Math.Vector3} axis - The axis to rotate upon. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotate: function (rad, axis) + { + var a = this.val; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var len = Math.sqrt(x * x + y * y + z * z); + + if (Math.abs(len) < EPSILON) + { + return null; + } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + var s = Math.sin(rad); + var c = Math.cos(rad); + var t = 1 - c; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Construct the elements of the rotation matrix + var b00 = x * x * t + c; + var b01 = y * x * t + z * s; + var b02 = z * x * t - y * s; + + var b10 = x * y * t - z * s; + var b11 = y * y * t + c; + var b12 = z * y * t + x * s; + + var b20 = x * z * t + y * s; + var b21 = y * z * t - x * s; + var b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + a[0] = a00 * b00 + a10 * b01 + a20 * b02; + a[1] = a01 * b00 + a11 * b01 + a21 * b02; + a[2] = a02 * b00 + a12 * b01 + a22 * b02; + a[3] = a03 * b00 + a13 * b01 + a23 * b02; + a[4] = a00 * b10 + a10 * b11 + a20 * b12; + a[5] = a01 * b10 + a11 * b11 + a21 * b12; + a[6] = a02 * b10 + a12 * b11 + a22 * b12; + a[7] = a03 * b10 + a13 * b11 + a23 * b12; + a[8] = a00 * b20 + a10 * b21 + a20 * b22; + a[9] = a01 * b20 + a11 * b21 + a21 * b22; + a[10] = a02 * b20 + a12 * b21 + a22 * b22; + a[11] = a03 * b20 + a13 * b21 + a23 * b22; + + return this; + }, + + /** + * Rotate this matrix on its X axis. + * + * @method Phaser.Math.Matrix4#rotateX + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateX: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[4] = a10 * c + a20 * s; + a[5] = a11 * c + a21 * s; + a[6] = a12 * c + a22 * s; + a[7] = a13 * c + a23 * s; + a[8] = a20 * c - a10 * s; + a[9] = a21 * c - a11 * s; + a[10] = a22 * c - a12 * s; + a[11] = a23 * c - a13 * s; + + return this; + }, + + /** + * Rotate this matrix on its Y axis. + * + * @method Phaser.Math.Matrix4#rotateY + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateY: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c - a20 * s; + a[1] = a01 * c - a21 * s; + a[2] = a02 * c - a22 * s; + a[3] = a03 * c - a23 * s; + a[8] = a00 * s + a20 * c; + a[9] = a01 * s + a21 * c; + a[10] = a02 * s + a22 * c; + a[11] = a03 * s + a23 * c; + + return this; + }, + + /** + * Rotate this matrix on its Z axis. + * + * @method Phaser.Math.Matrix4#rotateZ + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateZ: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c + a10 * s; + a[1] = a01 * c + a11 * s; + a[2] = a02 * c + a12 * s; + a[3] = a03 * c + a13 * s; + a[4] = a10 * c - a00 * s; + a[5] = a11 * c - a01 * s; + a[6] = a12 * c - a02 * s; + a[7] = a13 * c - a03 * s; + + return this; + }, + + /** + * Set the values of this Matrix from the given rotation Quaternion and translation Vector. + * + * @method Phaser.Math.Matrix4#fromRotationTranslation + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set rotation from. + * @param {Phaser.Math.Vector3} v - The Vector to set translation from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromRotationTranslation: function (q, v) + { + // Quaternion math + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = v.x; + out[13] = v.y; + out[14] = v.z; + out[15] = 1; + + return this; + }, + + /** + * Set the values of this Matrix from the given Quaternion. + * + * @method Phaser.Math.Matrix4#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromQuat: function (q) + { + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Generate a frustum matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#frustum + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + frustum: function (left, right, bottom, top, near, far) + { + var out = this.val; + + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + + out[0] = (near * 2) * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (near * 2) * tb; + out[6] = 0; + out[7] = 0; + + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (far * near * 2) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspective + * @since 3.0.0 + * + * @param {number} fovy - Vertical field of view in radians + * @param {number} aspect - Aspect ratio. Typically viewport width /height. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspective: function (fovy, aspect, near, far) + { + var out = this.val; + var f = 1.0 / Math.tan(fovy / 2); + var nf = 1 / (near - far); + + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspectiveLH + * @since 3.0.0 + * + * @param {number} width - The width of the frustum. + * @param {number} height - The height of the frustum. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspectiveLH: function (width, height, near, far) + { + var out = this.val; + + out[0] = (2 * near) / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (2 * near) / height; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = -far / (near - far); + out[11] = 1; + + out[12] = 0; + out[13] = 0; + out[14] = (near * far) / (near - far); + out[15] = 0; + + return this; + }, + + /** + * Generate an orthogonal projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#ortho + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + ortho: function (left, right, bottom, top, near, far) + { + var out = this.val; + var lr = left - right; + var bt = bottom - top; + var nf = near - far; + + // Avoid division by zero + lr = (lr === 0) ? lr : 1 / lr; + bt = (bt === 0) ? bt : 1 / bt; + nf = (nf === 0) ? nf : 1 / nf; + + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; + + return this; + }, + + /** + * Generate a look-at matrix with the given eye position, focal point, and up axis. + * + * @method Phaser.Math.Matrix4#lookAt + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} eye - Position of the viewer + * @param {Phaser.Math.Vector3} center - Point the viewer is looking at + * @param {Phaser.Math.Vector3} up - vec3 pointing up. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + lookAt: function (eye, center, up) + { + var out = this.val; + + var eyex = eye.x; + var eyey = eye.y; + var eyez = eye.z; + + var upx = up.x; + var upy = up.y; + var upz = up.z; + + var centerx = center.x; + var centery = center.y; + var centerz = center.z; + + if (Math.abs(eyex - centerx) < EPSILON && + Math.abs(eyey - centery) < EPSILON && + Math.abs(eyez - centerz) < EPSILON) + { + return this.identity(); + } + + var z0 = eyex - centerx; + var z1 = eyey - centery; + var z2 = eyez - centerz; + + var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + + z0 *= len; + z1 *= len; + z2 *= len; + + var x0 = upy * z2 - upz * z1; + var x1 = upz * z0 - upx * z2; + var x2 = upx * z1 - upy * z0; + + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + + if (!len) + { + x0 = 0; + x1 = 0; + x2 = 0; + } + else + { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + var y0 = z1 * x2 - z2 * x1; + var y1 = z2 * x0 - z0 * x2; + var y2 = z0 * x1 - z1 * x0; + + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + + if (!len) + { + y0 = 0; + y1 = 0; + y2 = 0; + } + else + { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + + return this; + }, + + /** + * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values. + * + * @method Phaser.Math.Matrix4#yawPitchRoll + * @since 3.0.0 + * + * @param {number} yaw - [description] + * @param {number} pitch - [description] + * @param {number} roll - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + yawPitchRoll: function (yaw, pitch, roll) + { + this.zero(); + _tempMat1.zero(); + _tempMat2.zero(); + + var m0 = this.val; + var m1 = _tempMat1.val; + var m2 = _tempMat2.val; + + // Rotate Z + var s = Math.sin(roll); + var c = Math.cos(roll); + + m0[10] = 1; + m0[15] = 1; + m0[0] = c; + m0[1] = s; + m0[4] = -s; + m0[5] = c; + + // Rotate X + s = Math.sin(pitch); + c = Math.cos(pitch); + + m1[0] = 1; + m1[15] = 1; + m1[5] = c; + m1[10] = c; + m1[9] = -s; + m1[6] = s; + + // Rotate Y + s = Math.sin(yaw); + c = Math.cos(yaw); + + m2[5] = 1; + m2[15] = 1; + m2[0] = c; + m2[2] = -s; + m2[8] = s; + m2[10] = c; + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + return this; + }, + + /** + * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix. + * + * @method Phaser.Math.Matrix4#setWorldMatrix + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} rotation - The rotation of the world matrix. + * @param {Phaser.Math.Vector3} position - The position of the world matrix. + * @param {Phaser.Math.Vector3} scale - The scale of the world matrix. + * @param {Phaser.Math.Matrix4} [viewMatrix] - The view matrix. + * @param {Phaser.Math.Matrix4} [projectionMatrix] - The projection matrix. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) + { + this.yawPitchRoll(rotation.y, rotation.x, rotation.z); + + _tempMat1.scaling(scale.x, scale.y, scale.z); + _tempMat2.xyz(position.x, position.y, position.z); + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + if (viewMatrix !== undefined) + { + this.multiplyLocal(viewMatrix); + } + + if (projectionMatrix !== undefined) + { + this.multiplyLocal(projectionMatrix); + } + + return this; + } + +}); + +var _tempMat1 = new Matrix4(); +var _tempMat2 = new Matrix4(); + +module.exports = Matrix4; + + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Matrix4 = __webpack_require__(14); +var RandomXYZ = __webpack_require__(68); +var RandomXYZW = __webpack_require__(67); +var RotateVec3 = __webpack_require__(66); +var Set = __webpack_require__(63); +var Sprite3D = __webpack_require__(13); +var Vector2 = __webpack_require__(3); +var Vector3 = __webpack_require__(2); +var Vector4 = __webpack_require__(5); + +// Local cache vars +var tmpVec3 = new Vector3(); +var tmpVec4 = new Vector4(); +var dirvec = new Vector3(); +var rightvec = new Vector3(); +var billboardMatrix = new Matrix4(); + +// @author attribute https://github.com/mattdesl/cam3d/wiki + +/** + * @typedef {object} RayDef + * + * @property {Phaser.Math.Vector3} origin - [description] + * @property {Phaser.Math.Vector3} direction - [description] + */ + +/** + * @classdesc + * [description] + * + * @class Camera + * @memberOf Phaser.Cameras.Sprite3D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ +var Camera = new Class({ + + initialize: + + function Camera (scene) + { + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene = scene; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#displayList + * @type {Phaser.GameObjects.DisplayList} + * @since 3.0.0 + */ + this.displayList = scene.sys.displayList; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#updateList + * @type {Phaser.GameObjects.UpdateList} + * @since 3.0.0 + */ + this.updateList = scene.sys.updateList; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#direction + * @type {Phaser.Math.Vector3} + * @since 3.0.0 + */ + this.direction = new Vector3(0, 0, -1); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#up + * @type {Phaser.Math.Vector3} + * @since 3.0.0 + */ + this.up = new Vector3(0, 1, 0); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#position + * @type {Phaser.Math.Vector3} + * @since 3.0.0 + */ + this.position = new Vector3(); + + // The mapping from 3D size units to pixels. + // In the default case 1 3D unit = 128 pixels. So a sprite that is + // 256 x 128 px in size will be 2 x 1 units. + // Change to whatever best fits your game assets. + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#pixelScale + * @type {number} + * @since 3.0.0 + */ + this.pixelScale = 128; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#projection + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.projection = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#view + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.view = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#combined + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.combined = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#invProjectionView + * @type {Phaser.Math.Matrix4} + * @since 3.0.0 + */ + this.invProjectionView = new Matrix4(); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#near + * @type {number} + * @default 1 + * @since 3.0.0 + */ + this.near = 1; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#far + * @type {number} + * @since 3.0.0 + */ + this.far = 100; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#ray + * @type {RayDef} + * @since 3.0.0 + */ + this.ray = { + origin: new Vector3(), + direction: new Vector3() + }; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#viewportWidth + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.viewportWidth = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#viewportHeight + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.viewportHeight = 0; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#billboardMatrixDirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.billboardMatrixDirty = true; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D#children + * @type {Phaser.Structs.Set.} + * @since 3.0.0 + */ + this.children = new Set(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setPosition: function (x, y, z) + { + this.position.set(x, y, z); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setScene: function (scene) + { + this.scene = scene; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setPixelScale + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setPixelScale: function (value) + { + this.pixelScale = value; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#add + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite3D} sprite3D - [description] + * + * @return {Phaser.GameObjects.Sprite3D} [description] + */ + add: function (sprite3D) + { + this.children.set(sprite3D); + + this.displayList.add(sprite3D.gameObject); + this.updateList.add(sprite3D.gameObject); + + this.updateChildren(); + + return sprite3D; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#remove + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} child - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + remove: function (child) + { + this.displayList.remove(child.gameObject); + this.updateList.remove(child.gameObject); + + this.children.delete(child); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#clear + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + clear: function () + { + var children = this.getChildren(); + + for (var i = 0; i < children.length; i++) + { + this.remove(children[i]); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#getChildren + * @since 3.0.0 + * + * @return {array} [description] + */ + getChildren: function () + { + return this.children.entries; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#create + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] + * @param {string} key - [description] + * @param {(string|number)} frame - [description] + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Sprite3D} [description] + */ + create: function (x, y, z, key, frame, visible) + { + if (visible === undefined) { visible = true; } + + var child = new Sprite3D(this.scene, x, y, z, key, frame); + + this.displayList.add(child.gameObject); + this.updateList.add(child.gameObject); + + child.visible = visible; + + this.children.set(child); + + this.updateChildren(); + + return child; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#createMultiple + * @since 3.0.0 + * + * @param {number} quantity - [description] + * @param {string} key - [description] + * @param {(string|number)} frame - [description] + * @param {boolean} [visible=true] - [description] + * + * @return {Phaser.GameObjects.Sprite3D[]} [description] + */ + createMultiple: function (quantity, key, frame, visible) + { + if (visible === undefined) { visible = true; } + + var output = []; + + for (var i = 0; i < quantity; i++) + { + var child = new Sprite3D(this.scene, 0, 0, 0, key, frame); + + this.displayList.add(child.gameObject); + this.updateList.add(child.gameObject); + + child.visible = visible; + + this.children.set(child); + + output.push(child); + } + + return output; + }, + + // Create a bunch of Sprite3D objects in a rectangle + // size and spacing are Vec3s (or if integers are converted to vec3s) + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#createRect + * @since 3.0.0 + * + * @param {(number|{x:number,y:number})} size - [description] + * @param {(number|{x:number,y:number,z:number})} spacing - [description] + * @param {string} key - [description] + * @param {(string|number)} [frame] - [description] + * + * @return {Phaser.GameObjects.Sprite3D[]} [description] + */ + createRect: function (size, spacing, key, frame) + { + if (typeof size === 'number') { size = { x: size, y: size, z: size }; } + if (typeof spacing === 'number') { spacing = { x: spacing, y: spacing, z: spacing }; } + + var quantity = size.x * size.y * size.z; + + var sprites = this.createMultiple(quantity, key, frame); + + var i = 0; + + for (var z = 0.5 - (size.z / 2); z < (size.z / 2); z++) + { + for (var y = 0.5 - (size.y / 2); y < (size.y / 2); y++) + { + for (var x = 0.5 - (size.x / 2); x < (size.x / 2); x++) + { + var bx = (x * spacing.x); + var by = (y * spacing.y); + var bz = (z * spacing.z); + + sprites[i].position.set(bx, by, bz); + + i++; + } + } + } + + this.update(); + + return sprites; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#randomSphere + * @since 3.0.0 + * + * @param {number} [radius=1] - [description] + * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + randomSphere: function (radius, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + RandomXYZ(sprites[i].position, radius); + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#randomCube + * @since 3.0.0 + * + * @param {number} [scale=1] - [description] + * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + randomCube: function (scale, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + RandomXYZW(sprites[i].position, scale); + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#translateChildren + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec3 - [description] + * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + translateChildren: function (vec3, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + sprites[i].position.add(vec3); + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#transformChildren + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat4 - [description] + * @param {Phaser.GameObjects.Sprite3D[]} sprites - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + transformChildren: function (mat4, sprites) + { + if (sprites === undefined) { sprites = this.getChildren(); } + + for (var i = 0; i < sprites.length; i++) + { + sprites[i].position.transformMat4(mat4); + } + + return this.update(); + }, + + /** + * Sets the width and height of the viewport. Does not update any matrices. + * + * @method Phaser.Cameras.Sprite3D.Camera#setViewport + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setViewport: function (width, height) + { + this.viewportWidth = width; + this.viewportHeight = height; + + return this.update(); + }, + + /** + * Translates this camera by a specified Vector3 object + * or x, y, z parameters. Any undefined x y z values will + * default to zero, leaving that component unaffected. + * If you wish to set the camera position directly call setPosition instead. + * + * @method Phaser.Cameras.Sprite3D.Camera#translate + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + translate: function (x, y, z) + { + if (typeof x === 'object') + { + this.position.x += x.x || 0; + this.position.y += x.y || 0; + this.position.z += x.z || 0; + } + else + { + this.position.x += x || 0; + this.position.y += y || 0; + this.position.z += z || 0; + } + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#lookAt + * @since 3.0.0 + * + * @param {(number|object)} x - [description] + * @param {number} [y] - [description] + * @param {number} [z] - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + lookAt: function (x, y, z) + { + var dir = this.direction; + var up = this.up; + + if (typeof x === 'object') + { + dir.copy(x); + } + else + { + dir.set(x, y, z); + } + + dir.subtract(this.position).normalize(); + + // Calculate right vector + tmpVec3.copy(dir).cross(up).normalize(); + + // Calculate up vector + up.copy(tmpVec3).cross(dir).normalize(); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#rotate + * @since 3.0.0 + * + * @param {number} radians - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + rotate: function (radians, axis) + { + RotateVec3(this.direction, axis, radians); + RotateVec3(this.up, axis, radians); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#rotateAround + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} point - [description] + * @param {number} radians - [description] + * @param {Phaser.Math.Vector3} axis - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + rotateAround: function (point, radians, axis) + { + tmpVec3.copy(point).subtract(this.position); + + this.translate(tmpVec3); + this.rotate(radians, axis); + this.translate(tmpVec3.negate()); + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#project + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec - [description] + * @param {Phaser.Math.Vector4} out - [description] + * + * @return {Phaser.Math.Vector4} [description] + */ + project: function (vec, out) + { + if (out === undefined) { out = new Vector4(); } + + // TODO: support viewport XY + var viewportWidth = this.viewportWidth; + var viewportHeight = this.viewportHeight; + var n = Camera.NEAR_RANGE; + var f = Camera.FAR_RANGE; + + // For useful Z and W values we should do the usual steps: clip space -> NDC -> window coords + + // Implicit 1.0 for w component + tmpVec4.set(vec.x, vec.y, vec.z, 1.0); + + // Transform into clip space + tmpVec4.transformMat4(this.combined); + + // Avoid divide by zero when 0x0x0 camera projects to a 0x0x0 vec3 + if (tmpVec4.w === 0) + { + tmpVec4.w = 1; + } + + // Now into NDC + tmpVec4.x = tmpVec4.x / tmpVec4.w; + tmpVec4.y = tmpVec4.y / tmpVec4.w; + tmpVec4.z = tmpVec4.z / tmpVec4.w; + + // And finally into window coordinates + out.x = viewportWidth / 2 * tmpVec4.x + (0 + viewportWidth / 2); + out.y = viewportHeight / 2 * tmpVec4.y + (0 + viewportHeight / 2); + out.z = (f - n) / 2 * tmpVec4.z + (f + n) / 2; + + // If the out vector has a fourth component, we also store (1/clip.w), same idea as gl_FragCoord.w + if (out.w === 0 || out.w) + { + out.w = 1 / tmpVec4.w; + } + + return out; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#unproject + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} vec - [description] + * @param {Phaser.Math.Vector3} out - [description] + * + * @return {Phaser.Math.Vector3} [description] + */ + unproject: function (vec, out) + { + if (out === undefined) { out = new Vector3(); } + + var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); + + return out.copy(vec).unproject(viewport, this.invProjectionView); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#getPickRay + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y] - [description] + * + * @return {RayDef} [description] + */ + getPickRay: function (x, y) + { + var origin = this.ray.origin.set(x, y, 0); + var direction = this.ray.direction.set(x, y, 1); + var viewport = tmpVec4.set(0, 0, this.viewportWidth, this.viewportHeight); + var mtx = this.invProjectionView; + + origin.unproject(viewport, mtx); + + direction.unproject(viewport, mtx); + + direction.subtract(origin).normalize(); + + return this.ray; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#updateChildren + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + updateChildren: function () + { + var children = this.children.entries; + + for (var i = 0; i < children.length; i++) + { + children[i].project(this); + } + + return this; + }, + + // Overriden by subclasses + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#update + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + update: function () + { + return this.updateChildren(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#updateBillboardMatrix + * @since 3.0.0 + */ + updateBillboardMatrix: function () + { + var dir = dirvec.set(this.direction).negate(); + + // Better view-aligned billboards might use this: + // var dir = tmp.set(camera.position).subtract(p).normalize(); + + var right = rightvec.set(this.up).cross(dir).normalize(); + var up = tmpVec3.set(dir).cross(right).normalize(); + + var out = billboardMatrix.val; + + out[0] = right.x; + out[1] = right.y; + out[2] = right.z; + out[3] = 0; + + out[4] = up.x; + out[5] = up.y; + out[6] = up.z; + out[7] = 0; + + out[8] = dir.x; + out[9] = dir.y; + out[10] = dir.z; + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + this.billboardMatrixDirty = false; + }, + + /** + * This is a utility function for canvas 3D rendering, + * which determines the "point size" of a camera-facing + * sprite billboard given its 3D world position + * (origin at center of sprite) and its world width + * and height in x/y. + * + * We place into the output Vector2 the scaled width + * and height. If no `out` is specified, a new Vector2 + * will be created for convenience (this should be avoided + * in tight loops). + * + * @method Phaser.Cameras.Sprite3D.Camera#getPointSize + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} vec - The position of the 3D Sprite. + * @param {Phaser.Math.Vector2} size - The x and y dimensions. + * @param {Phaser.Math.Vector2} out - The result, scaled x and y dimensions. + * + * @return {Phaser.Math.Vector2} [description] + */ + getPointSize: function (vec, size, out) + { + if (out === undefined) { out = new Vector2(); } + + // TODO: optimize this with a simple distance calculation: + // https://developer.valvesoftware.com/wiki/Field_of_View + + if (this.billboardMatrixDirty) + { + this.updateBillboardMatrix(); + } + + var tmp = tmpVec3; + + var dx = (size.x / this.pixelScale) / 2; + var dy = (size.y / this.pixelScale) / 2; + + tmp.set(-dx, -dy, 0).transformMat4(billboardMatrix).add(vec); + + this.project(tmp, tmp); + + var tlx = tmp.x; + var tly = tmp.y; + + tmp.set(dx, dy, 0).transformMat4(billboardMatrix).add(vec); + + this.project(tmp, tmp); + + var brx = tmp.x; + var bry = tmp.y; + + // var w = Math.abs(brx - tlx); + // var h = Math.abs(bry - tly); + + // Allow the projection to get negative ... + var w = brx - tlx; + var h = bry - tly; + + return out.set(w, h); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.children.clear(); + + this.scene = undefined; + this.children = undefined; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setX + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setX: function (value) + { + this.position.x = value; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setY + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setY: function (value) + { + this.position.y = value; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.Camera#setZ + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. + */ + setZ: function (value) + { + this.position.z = value; + + return this.update(); + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.Camera#x + * @type {number} + * @since 3.0.0 + */ + x: { + get: function () + { + return this.position.x; + }, + + set: function (value) + { + this.position.x = value; + this.update(); + } + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.Camera#y + * @type {number} + * @since 3.0.0 + */ + y: { + get: function () + { + return this.position.y; + }, + + set: function (value) + { + this.position.y = value; + this.update(); + } + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.Camera#z + * @type {number} + * @since 3.0.0 + */ + z: { + get: function () + { + return this.position.z; + }, + + set: function (value) + { + this.position.z = value; + this.update(); + } + } + +}); + +Camera.FAR_RANGE = 1.0; +Camera.NEAR_RANGE = 0.0; + +module.exports = Camera; + + +/***/ }), +/* 16 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser Scale Modes. + * + * @name Phaser.ScaleModes + * @enum {integer} + * @memberOf Phaser + * @readOnly + * @since 3.0.0 + */ + +module.exports = { + + /** + * Default Scale Mode (Linear). + * + * @name Phaser.ScaleModes.DEFAULT + */ + DEFAULT: 0, + + /** + * Linear Scale Mode. + * + * @name Phaser.ScaleModes.LINEAR + */ + LINEAR: 0, + + /** + * Nearest Scale Mode. + * + * @name Phaser.ScaleModes.NEAREST + */ + NEAREST: 1 + +}; + + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var RND = __webpack_require__(72); + +var MATH_CONST = { + + /** + * The value of PI * 2. + * + * @name Phaser.Math.PI2 + * @type {number} + * @since 3.0.0 + */ + PI2: Math.PI * 2, + + /** + * The value of PI * 0.5. + * + * @name Phaser.Math.TAU + * @type {number} + * @since 3.0.0 + */ + TAU: Math.PI * 0.5, + + /** + * An epsilon value (1.0e-6) + * + * @name Phaser.Math.EPSILON + * @type {number} + * @since 3.0.0 + */ + EPSILON: 1.0e-6, + + /** + * For converting degrees to radians (PI / 180) + * + * @name Phaser.Math.DEG_TO_RAD + * @type {number} + * @since 3.0.0 + */ + DEG_TO_RAD: Math.PI / 180, + + /** + * For converting radians to degrees (180 / PI) + * + * @name Phaser.Math.RAD_TO_DEG + * @type {number} + * @since 3.0.0 + */ + RAD_TO_DEG: 180 / Math.PI, + + /** + * An instance of the Random Number Generator. + * + * @name Phaser.Math.RND + * @type {Phaser.Math.RandomDataGenerator} + * @since 3.0.0 + */ + RND: new RND() + +}; + +module.exports = MATH_CONST; + + +/***/ }), +/* 18 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser Blend Modes. + * + * @name Phaser.BlendModes + * @enum {integer} + * @memberOf Phaser + * @readOnly + * @since 3.0.0 + */ + +module.exports = { + + /** + * Skips the Blend Mode check in the renderer. + * + * @name Phaser.BlendModes.SKIP_CHECK + */ + SKIP_CHECK: -1, + + /** + * Normal blend mode. + * + * @name Phaser.BlendModes.NORMAL + */ + NORMAL: 0, + + /** + * Add blend mode. + * + * @name Phaser.BlendModes.ADD + */ + ADD: 1, + + /** + * Multiply blend mode. + * + * @name Phaser.BlendModes.MULTIPLY + */ + MULTIPLY: 2, + + /** + * Screen blend mode. + * + * @name Phaser.BlendModes.SCREEN + */ + SCREEN: 3, + + /** + * Overlay blend mode. + * + * @name Phaser.BlendModes.OVERLAY + */ + OVERLAY: 4, + + /** + * Darken blend mode. + * + * @name Phaser.BlendModes.DARKEN + */ + DARKEN: 5, + + /** + * Lighten blend mode. + * + * @name Phaser.BlendModes.LIGHTEN + */ + LIGHTEN: 6, + + /** + * Color Dodge blend mode. + * + * @name Phaser.BlendModes.COLOR_DODGE + */ + COLOR_DODGE: 7, + + /** + * Color Burn blend mode. + * + * @name Phaser.BlendModes.COLOR_BURN + */ + COLOR_BURN: 8, + + /** + * Hard Light blend mode. + * + * @name Phaser.BlendModes.HARD_LIGHT + */ + HARD_LIGHT: 9, + + /** + * Soft Light blend mode. + * + * @name Phaser.BlendModes.SOFT_LIGHT + */ + SOFT_LIGHT: 10, + + /** + * Difference blend mode. + * + * @name Phaser.BlendModes.DIFFERENCE + */ + DIFFERENCE: 11, + + /** + * Exclusion blend mode. + * + * @name Phaser.BlendModes.EXCLUSION + */ + EXCLUSION: 12, + + /** + * Hue blend mode. + * + * @name Phaser.BlendModes.HUE + */ + HUE: 13, + + /** + * Saturation blend mode. + * + * @name Phaser.BlendModes.SATURATION + */ + SATURATION: 14, + + /** + * Color blend mode. + * + * @name Phaser.BlendModes.COLOR + */ + COLOR: 15, + + /** + * Luminosity blend mode. + * + * @name Phaser.BlendModes.LUMINOSITY + */ + LUMINOSITY: 16 + +}; + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* @author Richard Davey +* @copyright 2018 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} +*/ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Global Plugin is installed just once into the Game owned Plugin Manager. + * It can listen for Game events and respond to them. + * + * @class BasePlugin + * @memberOf Phaser.Plugins + * @constructor + * @since 3.8.0 + * + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager. + */ +var BasePlugin = new Class({ + + initialize: + + function BasePlugin (pluginManager) + { + /** + * A handy reference to the Plugin Manager that is responsible for this plugin. + * Can be used as a route to gain access to game systems and events. + * + * @name Phaser.Plugins.BasePlugin#pluginManager + * @type {Phaser.Plugins.PluginManager} + * @protected + * @since 3.8.0 + */ + this.pluginManager = pluginManager; + + /** + * A reference to the Game instance this plugin is running under. + * + * @name Phaser.Plugins.BasePlugin#game + * @type {Phaser.Game} + * @protected + * @since 3.8.0 + */ + this.game = pluginManager.game; + + /** + * A reference to the Scene that has installed this plugin. + * Only set if it's a Scene Plugin, otherwise `null`. + * This property is only set when the plugin is instantiated and added to the Scene, not before. + * You cannot use it during the `init` method, but you can during the `boot` method. + * + * @name Phaser.Plugins.BasePlugin#scene + * @type {?Phaser.Scene} + * @protected + * @since 3.8.0 + */ + this.scene; + + /** + * A reference to the Scene Systems of the Scene that has installed this plugin. + * Only set if it's a Scene Plugin, otherwise `null`. + * This property is only set when the plugin is instantiated and added to the Scene, not before. + * You cannot use it during the `init` method, but you can during the `boot` method. + * + * @name Phaser.Plugins.BasePlugin#systems + * @type {?Phaser.Scenes.Systems} + * @protected + * @since 3.8.0 + */ + this.systems; + }, + + /** + * Called by the PluginManager when this plugin is first instantiated. + * It will never be called again on this instance. + * In here you can set-up whatever you need for this plugin to run. + * If a plugin is set to automatically start then `BasePlugin.start` will be called immediately after this. + * + * @method Phaser.Plugins.BasePlugin#init + * @since 3.8.0 + * + * @param {?any} [data] - A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually). + */ + init: function () + { + }, + + /** + * Called by the PluginManager when this plugin is started. + * If a plugin is stopped, and then started again, this will get called again. + * Typically called immediately after `BasePlugin.init`. + * + * @method Phaser.Plugins.BasePlugin#start + * @since 3.8.0 + */ + start: function () + { + // Here are the game-level events you can listen to. + // At the very least you should offer a destroy handler for when the game closes down. + + // var eventEmitter = this.game.events; + + // eventEmitter.once('destroy', this.gameDestroy, this); + // eventEmitter.on('pause', this.gamePause, this); + // eventEmitter.on('resume', this.gameResume, this); + // eventEmitter.on('resize', this.gameResize, this); + // eventEmitter.on('prestep', this.gamePreStep, this); + // eventEmitter.on('step', this.gameStep, this); + // eventEmitter.on('poststep', this.gamePostStep, this); + // eventEmitter.on('prerender', this.gamePreRender, this); + // eventEmitter.on('postrender', this.gamePostRender, this); + }, + + /** + * Called by the PluginManager when this plugin is stopped. + * The game code has requested that your plugin stop doing whatever it does. + * It is now considered as 'inactive' by the PluginManager. + * Handle that process here (i.e. stop listening for events, etc) + * If the plugin is started again then `BasePlugin.start` will be called again. + * + * @method Phaser.Plugins.BasePlugin#stop + * @since 3.8.0 + */ + stop: function () + { + }, + + /** + * If this is a Scene Plugin (i.e. installed into a Scene) then this method is called when the Scene boots. + * By this point the plugin properties `scene` and `systems` will have already been set. + * In here you can listen for Scene events and set-up whatever you need for this plugin to run. + * + * @method Phaser.Plugins.BasePlugin#boot + * @since 3.8.0 + */ + boot: function () + { + // Here are the Scene events you can listen to. + // At the very least you should offer a destroy handler for when the Scene closes down. + + // var eventEmitter = this.systems.events; + + // eventEmitter.once('destroy', this.sceneDestroy, this); + // eventEmitter.on('start', this.sceneStart, this); + // eventEmitter.on('preupdate', this.scenePreUpdate, this); + // eventEmitter.on('update', this.sceneUpdate, this); + // eventEmitter.on('postupdate', this.scenePostUpdate, this); + // eventEmitter.on('pause', this.scenePause, this); + // eventEmitter.on('resume', this.sceneResume, this); + // eventEmitter.on('sleep', this.sceneSleep, this); + // eventEmitter.on('wake', this.sceneWake, this); + // eventEmitter.on('shutdown', this.sceneShutdown, this); + // eventEmitter.on('destroy', this.sceneDestroy, this); + }, + + /** + * Game instance has been destroyed. + * You must release everything in here, all references, all objects, free it all up. + * + * @method Phaser.Plugins.BasePlugin#destroy + * @since 3.8.0 + */ + destroy: function () + { + this.pluginManager = null; + this.game = null; + this.scene = null; + this.systems = null; + } + +}); + +module.exports = BasePlugin; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* @author Richard Davey +* @copyright 2018 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} +*/ + +var BasePlugin = __webpack_require__(19); +var Class = __webpack_require__(0); + +/** + * @classdesc + * A Scene Level Plugin is installed into every Scene and belongs to that Scene. + * It can listen for Scene events and respond to them. + * It can map itself to a Scene property, or into the Scene Systems, or both. + * + * @class ScenePlugin + * @memberOf Phaser.Plugins + * @extends Phaser.Plugins.BasePlugin + * @constructor + * @since 3.8.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager. + */ +var ScenePlugin = new Class({ + + Extends: BasePlugin, + + initialize: + + function ScenePlugin (scene, pluginManager) + { + BasePlugin.call(this, pluginManager); + + this.scene = scene; + this.systems = scene.sys; + + scene.sys.events.once('boot', this.boot, this); + }, + + /** + * This method is called when the Scene boots. It is only ever called once. + * + * By this point the plugin properties `scene` and `systems` will have already been set. + * + * In here you can listen for Scene events and set-up whatever you need for this plugin to run. + * Here are the Scene events you can listen to: + * + * start + * ready + * preupdate + * update + * postupdate + * resize + * pause + * resume + * sleep + * wake + * transitioninit + * transitionstart + * transitioncomplete + * transitionout + * shutdown + * destroy + * + * At the very least you should offer a destroy handler for when the Scene closes down, i.e: + * + * ```javascript + * var eventEmitter = this.systems.events; + * eventEmitter.once('destroy', this.sceneDestroy, this); + * ``` + * + * @method Phaser.Plugins.ScenePlugin#boot + * @since 3.8.0 + */ + boot: function () + { + } + +}); + +module.exports = ScenePlugin; + + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(15); +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(2); + +// Local cache vars +var tmpVec3 = new Vector3(); + +/** + * @classdesc + * [description] + * + * @class PerspectiveCamera + * @extends Phaser.Cameras.Sprite3D.Camera + * @memberOf Phaser.Cameras.Sprite3D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {integer} [fieldOfView=80] - [description] + * @param {integer} [viewportWidth=0] - [description] + * @param {integer} [viewportHeight=0] - [description] + */ +var PerspectiveCamera = new Class({ + + Extends: Camera, + + // FOV is converted to radians automatically + initialize: + + function PerspectiveCamera (scene, fieldOfView, viewportWidth, viewportHeight) + { + if (fieldOfView === undefined) { fieldOfView = 80; } + if (viewportWidth === undefined) { viewportWidth = 0; } + if (viewportHeight === undefined) { viewportHeight = 0; } + + Camera.call(this, scene); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportWidth + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.viewportWidth = viewportWidth; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#viewportHeight + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + this.viewportHeight = viewportHeight; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.PerspectiveCamera#fieldOfView + * @type {integer} + * @default 80 + * @since 3.0.0 + */ + this.fieldOfView = fieldOfView * Math.PI / 180; + + this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#setFOV + * @since 3.0.0 + * + * @param {number} value - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + setFOV: function (value) + { + this.fieldOfView = value * Math.PI / 180; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.PerspectiveCamera#update + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + update: function () + { + var aspect = this.viewportWidth / this.viewportHeight; + + // Create a perspective matrix for our camera + this.projection.perspective( + this.fieldOfView, + aspect, + Math.abs(this.near), + Math.abs(this.far) + ); + + // Build the view matrix + tmpVec3.copy(this.position).add(this.direction); + + this.view.lookAt(this.position, tmpVec3, this.up); + + // Projection * view matrix + this.combined.copy(this.projection).multiply(this.view); + + // Invert combined matrix, used for unproject + this.invProjectionView.copy(this.combined).invert(); + + this.billboardMatrixDirty = true; + + this.updateChildren(); + + return this; + } + +}); + +module.exports = PerspectiveCamera; + + +/***/ }), +/* 22 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderCanvas + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + renderer.batchSprite(src, src.frame, camera, parentMatrix); +}; + +module.exports = SpriteCanvasRenderer; + + +/***/ }), +/* 23 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Sprite#renderWebGL + * @since 3.0.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Sprite} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + this.pipeline.batchSprite(src, camera, parentMatrix); +}; + +module.exports = SpriteWebGLRenderer; + + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(6); +var renderCanvas = __webpack_require__(6); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = __webpack_require__(23); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = __webpack_require__(22); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Components = __webpack_require__(11); +var GameObject = __webpack_require__(12); +var SpriteRender = __webpack_require__(24); + +/** + * @classdesc + * A Sprite Game Object. + * + * A Sprite Game Object is used for the display of both static and animated images in your game. + * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled + * and animated. + * + * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. + * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation + * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * + * @class Sprite + * @extends Phaser.GameObjects.GameObject + * @memberOf Phaser.GameObjects + * @constructor + * @since 3.0.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.TextureCrop + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ +var Sprite = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.TextureCrop, + Components.Tint, + Components.Transform, + Components.Visible, + SpriteRender + ], + + initialize: + + function Sprite (scene, x, y, texture, frame) + { + GameObject.call(this, scene, 'Sprite'); + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Sprite#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Animation Controller of this Sprite. + * + * @name Phaser.GameObjects.Sprite#anims + * @type {Phaser.GameObjects.Components.Animation} + * @since 3.0.0 + */ + this.anims = new Components.Animation(this); + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.setOriginFromFrame(); + this.initPipeline('TextureTintPipeline'); + }, + + /** + * Update this Sprite's animations. + * + * @method Phaser.GameObjects.Sprite#preUpdate + * @protected + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + preUpdate: function (time, delta) + { + this.anims.update(time, delta); + }, + + /** + * Start playing the given animation. + * + * @method Phaser.GameObjects.Sprite#play + * @since 3.0.0 + * + * @param {string} key - The string-based key of the animation to play. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.Sprite} This Game Object. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + this.anims.play(key, ignoreIfPlaying, startFrame); + + return this; + }, + + /** + * Build a JSON representation of this Sprite. + * + * @method Phaser.GameObjects.Sprite#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + var data = Components.ToJSON(this); + + // Extra Sprite data is added here + + return data; + } + +}); + +module.exports = Sprite; + + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var has = Object.prototype.hasOwnProperty + , prefix = '~'; + +/** + * Constructor to create a storage for our `EE` objects. + * An `Events` instance is a plain object whose properties are event names. + * + * @constructor + * @private + */ +function Events() {} + +// +// We try to not inherit from `Object.prototype`. In some engines creating an +// instance in this way is faster than calling `Object.create(null)` directly. +// If `Object.create(null)` is not supported we prefix the event names with a +// character to make sure that the built-in object properties are not +// overridden or used as an attack vector. +// +if (Object.create) { + Events.prototype = Object.create(null); + + // + // This hack is needed because the `__proto__` property is still inherited in + // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. + // + if (!new Events().__proto__) prefix = false; +} + +/** + * Representation of a single event listener. + * + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor + * @private + */ +function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; +} + +/** + * Add a listener for a given event. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} once Specify if the listener is a one-time listener. + * @returns {EventEmitter} + * @private + */ +function addListener(emitter, event, fn, context, once) { + if (typeof fn !== 'function') { + throw new TypeError('The listener must be a function'); + } + + var listener = new EE(fn, context || emitter, once) + , evt = prefix ? prefix + event : event; + + if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; + else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); + else emitter._events[evt] = [emitter._events[evt], listener]; + + return emitter; +} + +/** + * Clear event by name. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} evt The Event name. + * @private + */ +function clearEvent(emitter, evt) { + if (--emitter._eventsCount === 0) emitter._events = new Events(); + else delete emitter._events[evt]; +} + +/** + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. + * + * @constructor + * @public + */ +function EventEmitter() { + this._events = new Events(); + this._eventsCount = 0; +} + +/** + * Return an array listing the events for which the emitter has registered + * listeners. + * + * @returns {Array} + * @public + */ +EventEmitter.prototype.eventNames = function eventNames() { + var names = [] + , events + , name; + + if (this._eventsCount === 0) return names; + + for (name in (events = this._events)) { + if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); + } + + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + + return names; +}; + +/** + * Return the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Array} The registered listeners. + * @public + */ +EventEmitter.prototype.listeners = function listeners(event) { + var evt = prefix ? prefix + event : event + , handlers = this._events[evt]; + + if (!handlers) return []; + if (handlers.fn) return [handlers.fn]; + + for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { + ee[i] = handlers[i].fn; + } + + return ee; +}; + +/** + * Return the number of listeners listening to a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Number} The number of listeners. + * @public + */ +EventEmitter.prototype.listenerCount = function listenerCount(event) { + var evt = prefix ? prefix + event : event + , listeners = this._events[evt]; + + if (!listeners) return 0; + if (listeners.fn) return 1; + return listeners.length; +}; + +/** + * Calls each of the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Boolean} `true` if the event had listeners, else `false`. + * @public + */ +EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return false; + + var listeners = this._events[evt] + , len = arguments.length + , args + , i; + + if (listeners.fn) { + if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); + + switch (len) { + case 1: return listeners.fn.call(listeners.context), true; + case 2: return listeners.fn.call(listeners.context, a1), true; + case 3: return listeners.fn.call(listeners.context, a1, a2), true; + case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + + for (i = 1, args = new Array(len -1); i < len; i++) { + args[i - 1] = arguments[i]; + } + + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length + , j; + + for (i = 0; i < length; i++) { + if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); + + switch (len) { + case 1: listeners[i].fn.call(listeners[i].context); break; + case 2: listeners[i].fn.call(listeners[i].context, a1); break; + case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; + case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; + default: + if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { + args[j - 1] = arguments[j]; + } + + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + + return true; +}; + +/** + * Add a listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.on = function on(event, fn, context) { + return addListener(this, event, fn, context, false); +}; + +/** + * Add a one-time listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.once = function once(event, fn, context) { + return addListener(this, event, fn, context, true); +}; + +/** + * Remove the listeners of a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn Only remove the listeners that match this function. + * @param {*} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return this; + if (!fn) { + clearEvent(this, evt); + return this; + } + + var listeners = this._events[evt]; + + if (listeners.fn) { + if ( + listeners.fn === fn && + (!once || listeners.once) && + (!context || listeners.context === context) + ) { + clearEvent(this, evt); + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if ( + listeners[i].fn !== fn || + (once && !listeners[i].once) || + (context && listeners[i].context !== context) + ) { + events.push(listeners[i]); + } + } + + // + // Reset the array, or remove it completely if we have no more listeners. + // + if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; + else clearEvent(this, evt); + } + + return this; +}; + +/** + * Remove all listeners, or those of the specified event. + * + * @param {(String|Symbol)} [event] The event name. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) clearEvent(this, evt); + } else { + this._events = new Events(); + this._eventsCount = 0; + } + + return this; +}; + +// +// Alias methods names because people roll like that. +// +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; +EventEmitter.prototype.addListener = EventEmitter.prototype.on; + +// +// Expose the prefix. +// +EventEmitter.prefixed = prefix; + +// +// Allow `EventEmitter` to be imported as module namespace. +// +EventEmitter.EventEmitter = EventEmitter; + +// +// Expose the module. +// +if (true) { + module.exports = EventEmitter; +} + + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback DataEachCallback + * + * @param {*} parent - The parent object of the DataManager. + * @param {string} key - The key of the value. + * @param {*} value - The value. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + */ + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManager + * @memberOf Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {object} parent - The object that this DataManager belongs to. + * @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter. + */ +var DataManager = new Class({ + + initialize: + + function DataManager (parent, eventEmitter) + { + /** + * The object that this DataManager belongs to. + * + * @name Phaser.Data.DataManager#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The DataManager's event emitter. + * + * @name Phaser.Data.DataManager#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = eventEmitter; + + if (!eventEmitter) + { + this.events = (parent.events) ? parent.events : parent; + } + + /** + * The data list. + * + * @name Phaser.Data.DataManager#list + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * The public values list. You can use this to access anything you have stored + * in this Data Manager. For example, if you set a value called `gold` you can + * access it via: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also modify it directly: + * + * ```javascript + * this.data.values.gold += 1000; + * ``` + * + * Doing so will emit a `setdata` event from the parent of this Data Manager. + * + * @name Phaser.Data.DataManager#values + * @type {Object.} + * @default {} + * @since 3.10.0 + */ + this.values = {}; + + /** + * Whether setting data is frozen for this DataManager. + * + * @name Phaser.Data.DataManager#_frozen + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._frozen = false; + + if (!parent.hasOwnProperty('sys') && this.events) + { + this.events.once('destroy', this.destroy, this); + } + }, + + /** + * Retrieves the value for the given key, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * this.data.get('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * this.data.get([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.Data.DataManager#get + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + get: function (key) + { + var list = this.list; + + if (Array.isArray(key)) + { + var output = []; + + for (var i = 0; i < key.length; i++) + { + output.push(list[key[i]]); + } + + return output; + } + else + { + return list[key]; + } + }, + + /** + * Retrieves all data values in a new object. + * + * @method Phaser.Data.DataManager#getAll + * @since 3.0.0 + * + * @return {Object.} All data values. + */ + getAll: function () + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Queries the DataManager for the values of keys matching the given regular expression. + * + * @method Phaser.Data.DataManager#query + * @since 3.0.0 + * + * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). + * + * @return {Object.} The values of the keys matching the search string. + */ + query: function (search) + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key) && key.match(search)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * data.set('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `get`: + * + * ```javascript + * data.get('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#set + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + set: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (typeof key === 'string') + { + return this.setValue(key, data); + } + else + { + for (var entry in key) + { + this.setValue(entry, key[entry]); + } + } + + return this; + }, + + /** + * Internal value setter, called automatically by the `set` method. + * + * @method Phaser.Data.DataManager#setValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * @param {*} data - The value to set. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setValue: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (this.has(key)) + { + // Hit the key getter, which will in turn emit the events. + this.values[key] = data; + } + else + { + var _this = this; + var list = this.list; + var events = this.events; + var parent = this.parent; + + Object.defineProperty(this.values, key, { + + enumerable: true, + + configurable: true, + + get: function () + { + return list[key]; + }, + + set: function (value) + { + if (!_this._frozen) + { + var previousValue = list[key]; + list[key] = value; + + events.emit('changedata', parent, key, value, previousValue); + events.emit('changedata_' + key, parent, value, previousValue); + } + } + + }); + + list[key] = data; + + events.emit('setdata', parent, key, data); + } + + return this; + }, + + /** + * Passes all data entries to the given callback. + * + * @method Phaser.Data.DataManager#each + * @since 3.0.0 + * + * @param {DataEachCallback} callback - The function to call. + * @param {*} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + each: function (callback, context) + { + var args = [ this.parent, null, undefined ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var key in this.list) + { + args[1] = key; + args[2] = this.list[key]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Merge the given object of key value pairs into this DataManager. + * + * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) + * will emit a `changedata` event. + * + * @method Phaser.Data.DataManager#merge + * @since 3.0.0 + * + * @param {Object.} data - The data to merge. + * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + merge: function (data, overwrite) + { + if (overwrite === undefined) { overwrite = true; } + + // Merge data from another component into this one + for (var key in data) + { + if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) + { + this.setValue(key, data[key]); + } + } + + return this; + }, + + /** + * Remove the value for the given key. + * + * If the key is found in this Data Manager it is removed from the internal lists and a + * `removedata` event is emitted. + * + * You can also pass in an array of keys, in which case all keys in the array will be removed: + * + * ```javascript + * this.data.remove([ 'gold', 'armor', 'health' ]); + * ``` + * + * @method Phaser.Data.DataManager#remove + * @since 3.0.0 + * + * @param {(string|string[])} key - The key to remove, or an array of keys to remove. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + remove: function (key) + { + if (this._frozen) + { + return this; + } + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.removeValue(key[i]); + } + } + else + { + return this.removeValue(key); + } + + return this; + }, + + /** + * Internal value remover, called automatically by the `remove` method. + * + * @method Phaser.Data.DataManager#removeValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + removeValue: function (key) + { + if (this.has(key)) + { + var data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this.parent, key, data); + } + + return this; + }, + + /** + * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. + * + * @method Phaser.Data.DataManager#pop + * @since 3.0.0 + * + * @param {string} key - The key of the value to retrieve and delete. + * + * @return {*} The value of the given key. + */ + pop: function (key) + { + var data = undefined; + + if (!this._frozen && this.has(key)) + { + data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this, key, data); + } + + return data; + }, + + /** + * Determines whether the given key is set in this Data Manager. + * + * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#has + * @since 3.0.0 + * + * @param {string} key - The key to check. + * + * @return {boolean} Returns `true` if the key exists, otherwise `false`. + */ + has: function (key) + { + return this.list.hasOwnProperty(key); + }, + + /** + * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts + * to create new values or update existing ones. + * + * @method Phaser.Data.DataManager#setFreeze + * @since 3.0.0 + * + * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setFreeze: function (value) + { + this._frozen = value; + + return this; + }, + + /** + * Delete all data in this Data Manager and unfreeze it. + * + * @method Phaser.Data.DataManager#reset + * @since 3.0.0 + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + reset: function () + { + for (var key in this.list) + { + delete this.list[key]; + delete this.values[key]; + } + + this._frozen = false; + + return this; + }, + + /** + * Destroy this data manager. + * + * @method Phaser.Data.DataManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + + this.events.off('changedata'); + this.events.off('setdata'); + this.events.off('removedata'); + + this.parent = null; + }, + + /** + * Gets or sets the frozen state of this Data Manager. + * A frozen Data Manager will block all attempts to create new values or update existing ones. + * + * @name Phaser.Data.DataManager#freeze + * @type {boolean} + * @since 3.0.0 + */ + freeze: { + + get: function () + { + return this._frozen; + }, + + set: function (value) + { + this._frozen = (value) ? true : false; + } + + }, + + /** + * Return the total number of entries in this Data Manager. + * + * @name Phaser.Data.DataManager#count + * @type {integer} + * @since 3.0.0 + */ + count: { + + get: function () + { + var i = 0; + + for (var key in this.list) + { + if (this.list[key] !== undefined) + { + i++; + } + } + + return i; + } + + } + +}); + +module.exports = DataManager; + + +/***/ }), +/* 28 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 1; // 0001 + +/** + * Provides methods used for setting the visibility of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Visible + * @since 3.0.0 + */ + +var Visible = { + + /** + * Private internal value. Holds the visible value. + * + * @name Phaser.GameObjects.Components.Visible#_visible + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + _visible: true, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Components.Visible#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + if (value) + { + this._visible = true; + this.renderFlags |= _FLAG; + } + else + { + this._visible = false; + this.renderFlags &= ~_FLAG; + } + } + + }, + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @method Phaser.GameObjects.Components.Visible#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {this} This Game Object instance. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + } +}; + +module.exports = Visible; + + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Wrap = __webpack_require__(7); + +/** + * Wrap an angle in degrees. + * + * Wraps the angle to a value in the range of -180 to 180. + * + * @function Phaser.Math.Angle.WrapDegrees + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in degrees. + * + * @return {number} The wrapped angle, in degrees. + */ +var WrapDegrees = function (angle) +{ + return Wrap(angle, -180, 180); +}; + +module.exports = WrapDegrees; + + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathWrap = __webpack_require__(7); + +/** + * Wrap an angle. + * + * Wraps the angle to a value in the range of -PI to PI. + * + * @function Phaser.Math.Angle.Wrap + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in radians. + * + * @return {number} The wrapped angle, in radians. + */ +var Wrap = function (angle) +{ + return MathWrap(angle, -Math.PI, Math.PI); +}; + +module.exports = Wrap; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(17); +var TransformMatrix = __webpack_require__(8); +var WrapAngle = __webpack_require__(30); +var WrapAngleDegrees = __webpack_require__(29); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 + +/** + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. + * + * @name Phaser.GameObjects.Components.Transform + * @since 3.0.0 + */ + +var Transform = { + + /** + * Private internal value. Holds the horizontal scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleX + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleX: 1, + + /** + * Private internal value. Holds the vertical scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleY + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleY: 1, + + /** + * Private internal value. Holds the rotation value in radians. + * + * @name Phaser.GameObjects.Components.Transform#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + _rotation: 0, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + x: 0, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + y: 0, + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + * + * @name Phaser.GameObjects.Components.Transform#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + z: 0, + + /** + * The w position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + w: 0, + + /** + * The horizontal scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + this._scaleX = value; + + if (this._scaleX === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The vertical scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + this._scaleY = value; + + if (this._scaleY === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + * + * @name Phaser.GameObjects.Components.Transform#angle + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + * + * @name Phaser.GameObjects.Components.Transform#rotation + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + } + }, + + /** + * Sets the position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of this Game Object. + * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value. + * @param {number} [z=0] - The z position of this Game Object. + * @param {number} [w=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setPosition: function (x, y, z, w) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + if (z === undefined) { z = 0; } + if (w === undefined) { w = 0; } + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + }, + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * + * @method Phaser.GameObjects.Components.Transform#setRandomPosition + * @since 3.8.0 + * + * @param {number} [x=0] - The x position of the top-left of the random area. + * @param {number} [y=0] - The y position of the top-left of the random area. + * @param {number} [width] - The width of the random area. + * @param {number} [height] - The height of the random area. + * + * @return {this} This Game Object instance. + */ + setRandomPosition: function (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + + this.x = x + (Math.random() * width); + this.y = y + (Math.random() * height); + + return this; + }, + + /** + * Sets the rotation of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - The rotation of this Game Object, in radians. + * + * @return {this} This Game Object instance. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this.rotation = radians; + + return this; + }, + + /** + * Sets the angle of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. + * + * @return {this} This Game Object instance. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + return this; + }, + + /** + * Sets the scale of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScale: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scaleX = x; + this.scaleY = y; + + return this; + }, + + /** + * Sets the x position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setX + * @since 3.0.0 + * + * @param {number} [value=0] - The x position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setX: function (value) + { + if (value === undefined) { value = 0; } + + this.x = value; + + return this; + }, + + /** + * Sets the y position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setY + * @since 3.0.0 + * + * @param {number} [value=0] - The y position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setY: function (value) + { + if (value === undefined) { value = 0; } + + this.y = value; + + return this; + }, + + /** + * Sets the z position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setZ + * @since 3.0.0 + * + * @param {number} [value=0] - The z position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setZ: function (value) + { + if (value === undefined) { value = 0; } + + this.z = value; + + return this; + }, + + /** + * Sets the w position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setW + * @since 3.0.0 + * + * @param {number} [value=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setW: function (value) + { + if (value === undefined) { value = 0; } + + this.w = value; + + return this; + }, + + /** + * Gets the local transform matrix for this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getLocalTransformMatrix: function (tempMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + + return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + }, + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * + * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getWorldTransformMatrix: function (tempMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + + var parent = this.parentContainer; + + if (!parent) + { + return this.getLocalTransformMatrix(tempMatrix); + } + + var parents = []; + + while (parent) + { + parents.unshift(parent); + parent = parent.parentContainer; + } + + tempMatrix.loadIdentity(); + + var length = parents.length; + + for (var i = 0; i < length; ++i) + { + parent = parents[i]; + + tempMatrix.translate(parent.x, parent.y); + tempMatrix.rotate(parent.rotation); + tempMatrix.scale(parent.scaleX, parent.scaleY); + } + + tempMatrix.translate(this.x, this.y); + tempMatrix.rotate(this._rotation); + tempMatrix.scale(this._scaleX, this._scaleY); + + return tempMatrix; + } + +}; + +module.exports = Transform; + + +/***/ }), +/* 32 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} JSONGameObject + * + * @property {string} name - The name of this Game Object. + * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. + * @property {number} x - The x position of this Game Object. + * @property {number} y - The y position of this Game Object. + * @property {object} scale - The scale of this Game Object + * @property {number} scale.x - The horizontal scale of this Game Object. + * @property {number} scale.y - The vertical scale of this Game Object. + * @property {object} origin - The origin of this Game Object. + * @property {number} origin.x - The horizontal origin of this Game Object. + * @property {number} origin.y - The vertical origin of this Game Object. + * @property {boolean} flipX - The horizontally flipped state of the Game Object. + * @property {boolean} flipY - The vertically flipped state of the Game Object. + * @property {number} rotation - The angle of this Game Object in radians. + * @property {number} alpha - The alpha value of the Game Object. + * @property {boolean} visible - The visible state of the Game Object. + * @property {integer} scaleMode - The Scale Mode being used by this Game Object. + * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. + * @property {string} textureKey - The texture key of this Game Object. + * @property {string} frameKey - The frame key of this Game Object. + * @property {object} data - The data of this Game Object. + */ + +/** + * Build a JSON representation of the given Game Object. + * + * This is typically extended further by Game Object specific implementations. + * + * @method Phaser.GameObjects.Components.ToJSON + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON. + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ +var ToJSON = function (gameObject) +{ + var out = { + name: gameObject.name, + type: gameObject.type, + x: gameObject.x, + y: gameObject.y, + depth: gameObject.depth, + scale: { + x: gameObject.scaleX, + y: gameObject.scaleY + }, + origin: { + x: gameObject.originX, + y: gameObject.originY + }, + flipX: gameObject.flipX, + flipY: gameObject.flipY, + rotation: gameObject.rotation, + alpha: gameObject.alpha, + visible: gameObject.visible, + scaleMode: gameObject.scaleMode, + blendMode: gameObject.blendMode, + textureKey: '', + frameKey: '', + data: {} + }; + + if (gameObject.texture) + { + out.textureKey = gameObject.texture.key; + out.frameKey = gameObject.frame.name; + } + + return out; +}; + +module.exports = ToJSON; + + +/***/ }), +/* 33 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @function GetColor + * @since 3.0.0 + * @private + */ +var GetColor = function (value) +{ + return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); +}; + +/** + * Provides methods used for setting the tint of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Tint + * @webglOnly + * @since 3.0.0 + */ + +var Tint = { + + /** + * Private internal value. Holds the top-left tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintTL + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintTL: 16777215, + + /** + * Private internal value. Holds the top-right tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintTR + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintTR: 16777215, + + /** + * Private internal value. Holds the bottom-left tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintBL + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintBL: 16777215, + + /** + * Private internal value. Holds the bottom-right tint value. + * + * @name Phaser.GameObjects.Components.Tint#_tintBR + * @type {number} + * @private + * @default 16777215 + * @since 3.0.0 + */ + _tintBR: 16777215, + + /** + * Private internal value. Holds if the Game Object is tinted or not. + * + * @name Phaser.GameObjects.Components.Tint#_isTinted + * @type {boolean} + * @private + * @default false + * @since 3.11.0 + */ + _isTinted: false, + + /** + * Fill or additive? + * + * @name Phaser.GameObjects.Components.Tint#tintFill + * @type {boolean} + * @default false + * @since 3.11.0 + */ + tintFill: false, + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + * + * @method Phaser.GameObjects.Components.Tint#clearTint + * @webglOnly + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearTint: function () + { + this.setTint(0xffffff); + + this._isTinted = false; + + return this; + }, + + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * + * @method Phaser.GameObjects.Components.Tint#setTint + * @webglOnly + * @since 3.0.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTint: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 0xffffff; } + + if (topRight === undefined) + { + topRight = topLeft; + bottomLeft = topLeft; + bottomRight = topLeft; + } + + this._tintTL = GetColor(topLeft); + this._tintTR = GetColor(topRight); + this._tintBL = GetColor(bottomLeft); + this._tintBR = GetColor(bottomRight); + + this._isTinted = true; + + this.tintFill = false; + + return this; + }, + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * + * @method Phaser.GameObjects.Components.Tint#setTintFill + * @webglOnly + * @since 3.11.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTintFill: function (topLeft, topRight, bottomLeft, bottomRight) + { + this.setTint(topLeft, topRight, bottomLeft, bottomRight); + + this.tintFill = true; + + return this; + }, + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopLeft: { + + get: function () + { + return this._tintTL; + }, + + set: function (value) + { + this._tintTL = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintTopRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintTopRight: { + + get: function () + { + return this._tintTR; + }, + + set: function (value) + { + this._tintTR = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomLeft + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomLeft: { + + get: function () + { + return this._tintBL; + }, + + set: function (value) + { + this._tintBL = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tintBottomRight + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tintBottomRight: { + + get: function () + { + return this._tintBR; + }, + + set: function (value) + { + this._tintBR = GetColor(value); + this._isTinted = true; + } + + }, + + /** + * The tint value being applied to the whole of the Game Object. + * + * @name Phaser.GameObjects.Components.Tint#tint + * @type {integer} + * @webglOnly + * @since 3.0.0 + */ + tint: { + + set: function (value) + { + this.setTint(value, value, value, value); + } + }, + + /** + * Does this Game Object have a tint applied to it or not? + * + * @name Phaser.GameObjects.Components.Tint#isTinted + * @type {boolean} + * @webglOnly + * @readOnly + * @since 3.11.0 + */ + isTinted: { + + get: function () + { + return this._isTinted; + } + + } + +}; + +module.exports = Tint; + + +/***/ }), +/* 34 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.TextureCrop + * @since 3.0.0 + */ + +var TextureCrop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.TextureCrop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.TextureCrop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.TextureCrop#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.TextureCrop#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + if (this.isCropped) + { + this.frame.updateCropUVs(this._crop, this.flipX, this.flipY); + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.TextureCrop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = TextureCrop; + + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Texture + * @since 3.0.0 + */ + +var Texture = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Texture#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * Internal flag. Not to be set by this Game Object. + * + * @name Phaser.GameObjects.Components.Texture#isCropped + * @type {boolean} + * @private + * @since 3.11.0 + */ + isCropped: false, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.Texture#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.Texture#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + return this; + } + +}; + +module.exports = Texture; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the size of a Game Object. + * + * @name Phaser.GameObjects.Components.Size + * @since 3.0.0 + */ + +var Size = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Size#_sizeComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _sizeComponent: true, + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.Size#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.Size#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.frame.realWidth; + }, + + set: function (value) + { + this.scaleX = value / this.frame.realWidth; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.Size#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.frame.realHeight; + }, + + set: function (value) + { + this.scaleY = value / this.frame.realHeight; + } + + }, + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.Size#setSizeToFrame + * @since 3.0.0 + * + * @param {Phaser.Textures.Frame} frame - The frame to base the size of this Game Object on. + * + * @return {this} This Game Object instance. + */ + setSizeToFrame: function (frame) + { + if (frame === undefined) { frame = this.frame; } + + this.width = frame.realWidth; + this.height = frame.realHeight; + + return this; + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.Size#setDisplaySize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = Size; + + +/***/ }), +/* 37 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the Scroll Factor of a Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor + * @since 3.0.0 + */ + +var ScrollFactor = { + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorX: 1, + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorY: 1, + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of this Game Object. + * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScrollFactor: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + } + +}; + +module.exports = ScrollFactor; + + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ScaleModes = __webpack_require__(16); + +/** + * Provides methods used for getting and setting the scale of a Game Object. + * + * @name Phaser.GameObjects.Components.ScaleMode + * @since 3.0.0 + */ + +var ScaleMode = { + + _scaleMode: ScaleModes.DEFAULT, + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @name Phaser.GameObjects.Components.ScaleMode#scaleMode + * @type {Phaser.ScaleModes} + * @since 3.0.0 + */ + scaleMode: { + + get: function () + { + return this._scaleMode; + }, + + set: function (value) + { + if (value === ScaleModes.LINEAR || value === ScaleModes.NEAREST) + { + this._scaleMode = value; + } + } + + }, + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * + * @method Phaser.GameObjects.Components.ScaleMode#setScaleMode + * @since 3.0.0 + * + * @param {Phaser.ScaleModes} value - The Scale Mode to be used by this Game Object. + * + * @return {this} This Game Object instance. + */ + setScaleMode: function (value) + { + this.scaleMode = value; + + return this; + } + +}; + +module.exports = ScaleMode; + + +/***/ }), +/* 39 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the WebGL rendering pipeline of a Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline + * @webglOnly + * @since 3.0.0 + */ + +var Pipeline = { + + /** + * The initial WebGL pipeline of this Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline#defaultPipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + defaultPipeline: null, + + /** + * The current WebGL pipeline of this Game Object. + * + * @name Phaser.GameObjects.Components.Pipeline#pipeline + * @type {Phaser.Renderer.WebGL.WebGLPipeline} + * @default null + * @webglOnly + * @since 3.0.0 + */ + pipeline: null, + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#initPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + initPipeline: function (pipelineName) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.defaultPipeline = renderer.getPipeline(pipelineName); + this.pipeline = this.defaultPipeline; + + return true; + } + + return false; + }, + + /** + * Sets the active WebGL Pipeline of this Game Object. + * + * @method Phaser.GameObjects.Components.Pipeline#setPipeline + * @webglOnly + * @since 3.0.0 + * + * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * + * @return {this} This Game Object instance. + */ + setPipeline: function (pipelineName) + { + var renderer = this.scene.sys.game.renderer; + + if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) + { + this.pipeline = renderer.getPipeline(pipelineName); + } + + return this; + }, + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + * + * @method Phaser.GameObjects.Components.Pipeline#resetPipeline + * @webglOnly + * @since 3.0.0 + * + * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + */ + resetPipeline: function () + { + this.pipeline = this.defaultPipeline; + + return (this.pipeline !== null); + }, + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + * + * @method Phaser.GameObjects.Components.Pipeline#getPipelineName + * @webglOnly + * @since 3.0.0 + * + * @return {string} The string-based name of the pipeline being used by this Game Object. + */ + getPipelineName: function () + { + return this.pipeline.name; + } + +}; + +module.exports = Pipeline; + + +/***/ }), +/* 40 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the origin of a Game Object. + * Values are normalized, given in the range 0 to 1. + * Display values contain the calculated pixel values. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Origin + * @since 3.0.0 + */ + +var Origin = { + + /** + * A property indicating that a Game Object has this component. + * + * @name Phaser.GameObjects.Components.Origin#_originComponent + * @type {boolean} + * @private + * @default true + * @since 3.2.0 + */ + _originComponent: true, + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originX + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originX: 0.5, + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + * + * @name Phaser.GameObjects.Components.Origin#originY + * @type {number} + * @default 0.5 + * @since 3.0.0 + */ + originY: 0.5, + + // private + read only + _displayOriginX: 0, + _displayOriginY: 0, + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginX + * @type {number} + * @since 3.0.0 + */ + displayOriginX: { + + get: function () + { + return this._displayOriginX; + }, + + set: function (value) + { + this._displayOriginX = value; + this.originX = value / this.width; + } + + }, + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + * + * @name Phaser.GameObjects.Components.Origin#displayOriginY + * @type {number} + * @since 3.0.0 + */ + displayOriginY: { + + get: function () + { + return this._displayOriginY; + }, + + set: function (value) + { + this._displayOriginY = value; + this.originY = value / this.height; + } + + }, + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * + * @method Phaser.GameObjects.Components.Origin#setOrigin + * @since 3.0.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + * + * @method Phaser.GameObjects.Components.Origin#setOriginFromFrame + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + setOriginFromFrame: function () + { + if (!this.frame || !this.frame.customPivot) + { + return this.setOrigin(); + } + else + { + this.originX = this.frame.pivotX; + this.originY = this.frame.pivotY; + } + + return this.updateDisplayOrigin(); + }, + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * + * @method Phaser.GameObjects.Components.Origin#setDisplayOrigin + * @since 3.0.0 + * + * @param {number} [x=0] - The horizontal display origin value. + * @param {number} [y=x] - The vertical display origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Game Object instance. + */ + setDisplayOrigin: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.displayOriginX = x; + this.displayOriginY = y; + + return this; + }, + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + * + * @method Phaser.GameObjects.Components.Origin#updateDisplayOrigin + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + updateDisplayOrigin: function () + { + this._displayOriginX = Math.round(this.originX * this.width); + this._displayOriginY = Math.round(this.originY * this.height); + + return this; + } + +}; + +module.exports = Origin; + + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class GeometryMask + * @memberOf Phaser.Display.Masks + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + */ +var GeometryMask = new Class({ + + initialize: + + function GeometryMask (scene, graphicsGeometry) + { + /** + * [description] + * + * @name Phaser.Display.Masks.GeometryMask#geometryMask + * @type {Phaser.GameObjects.Graphics} + * @since 3.0.0 + */ + this.geometryMask = graphicsGeometry; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#setShape + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + */ + setShape: function (graphicsGeometry) + { + this.geometryMask = graphicsGeometry; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL + * @since 3.0.0 + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + preRenderWebGL: function (renderer, mask, camera) + { + var gl = renderer.gl; + var geometryMask = this.geometryMask; + + // Force flushing before drawing to stencil buffer + renderer.flush(); + + // Enable and setup GL state to write to stencil buffer + gl.enable(gl.STENCIL_TEST); + gl.clear(gl.STENCIL_BUFFER_BIT); + gl.colorMask(false, false, false, false); + gl.stencilFunc(gl.NOTEQUAL, 1, 1); + gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE); + + // Write stencil buffer + geometryMask.renderWebGL(renderer, geometryMask, 0.0, camera); + renderer.flush(); + + // Use stencil buffer to affect next rendering object + gl.colorMask(true, true, true, true); + gl.stencilFunc(gl.EQUAL, 1, 1); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL + * @since 3.0.0 + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] + */ + postRenderWebGL: function (renderer) + { + var gl = renderer.gl; + + // Force flush before disabling stencil test + renderer.flush(); + gl.disable(gl.STENCIL_TEST); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas + * @since 3.0.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + */ + preRenderCanvas: function (renderer, mask, camera) + { + var geometryMask = this.geometryMask; + + renderer.currentContext.save(); + + geometryMask.renderCanvas(renderer, geometryMask, 0, camera, null, null, true); + + renderer.currentContext.clip(); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas + * @since 3.0.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - [description] + */ + postRenderCanvas: function (renderer) + { + renderer.currentContext.restore(); + }, + + /** + * Destroys this GeometryMask and nulls any references it holds. + * + * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, + * so be sure to call `clearMask` on any Game Object using it, before destroying it. + * + * @method Phaser.Display.Masks.GeometryMask#destroy + * @since 3.7.0 + */ + destroy: function () + { + this.geometryMask = null; + } + +}); + +module.exports = GeometryMask; + + +/***/ }), +/* 42 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * [description] + * + * @class BitmapMask + * @memberOf Phaser.Display.Masks + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. + */ +var BitmapMask = new Class({ + + initialize: + + function BitmapMask (scene, renderable) + { + var renderer = scene.sys.game.renderer; + + /** + * A reference to either the Canvas or WebGL Renderer that this Mask is using. + * + * @name Phaser.Display.Masks.BitmapMask#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.11.0 + */ + this.renderer = renderer; + + /** + * A renderable Game Object that uses a texture, such as a Sprite. + * + * @name Phaser.Display.Masks.BitmapMask#bitmapMask + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.bitmapMask = renderable; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#maskTexture + * @type {WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.maskTexture = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#mainTexture + * @type {WebGLTexture} + * @default null + * @since 3.0.0 + */ + this.mainTexture = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#dirty + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.dirty = true; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#mainFramebuffer + * @type {WebGLFramebuffer} + * @since 3.0.0 + */ + this.mainFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#maskFramebuffer + * @type {WebGLFramebuffer} + * @since 3.0.0 + */ + this.maskFramebuffer = null; + + /** + * [description] + * + * @name Phaser.Display.Masks.BitmapMask#invertAlpha + * @type {boolean} + * @since 3.1.2 + */ + this.invertAlpha = false; + + if (renderer && renderer.gl) + { + var width = renderer.width; + var height = renderer.height; + var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); + var gl = renderer.gl; + var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; + var filter = gl.LINEAR; + + this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); + this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); + + renderer.onContextRestored(function (renderer) + { + var width = renderer.width; + var height = renderer.height; + var pot = ((width & (width - 1)) === 0 && (height & (height - 1)) === 0); + var gl = renderer.gl; + var wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE; + var filter = gl.LINEAR; + + this.mainTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.maskTexture = renderer.createTexture2D(0, filter, filter, wrap, wrap, gl.RGBA, null, width, height); + this.mainFramebuffer = renderer.createFramebuffer(width, height, this.mainTexture, false); + this.maskFramebuffer = renderer.createFramebuffer(width, height, this.maskTexture, false); + + }, this); + } + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#setBitmap + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. + */ + setBitmap: function (renderable) + { + this.bitmapMask = renderable; + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#preRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} maskedObject - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. + */ + preRenderWebGL: function (renderer, maskedObject, camera) + { + renderer.pipelines.BitmapMaskPipeline.beginMask(this, maskedObject, camera); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#postRenderWebGL + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderWebGL: function (renderer) + { + renderer.pipelines.BitmapMaskPipeline.endMask(this); + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#preRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. + */ + preRenderCanvas: function () + { + // NOOP + }, + + /** + * [description] + * + * @method Phaser.Display.Masks.BitmapMask#postRenderCanvas + * @since 3.0.0 + * + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + */ + postRenderCanvas: function () + { + // NOOP + }, + + /** + * Destroys this BitmapMask and nulls any references it holds. + * + * Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it, + * so be sure to call `clearMask` on any Game Object using it, before destroying it. + * + * @method Phaser.Display.Masks.BitmapMask#destroy + * @since 3.7.0 + */ + destroy: function () + { + this.bitmapMask = null; + + var renderer = this.renderer; + + if (renderer && renderer.gl) + { + renderer.deleteTexture(this.mainTexture); + renderer.deleteTexture(this.maskTexture); + renderer.deleteFramebuffer(this.mainFramebuffer); + renderer.deleteFramebuffer(this.maskFramebuffer); + } + + this.mainTexture = null; + this.maskTexture = null; + this.mainFramebuffer = null; + this.maskFramebuffer = null; + this.renderer = null; + } + +}); + +module.exports = BitmapMask; + + +/***/ }), +/* 43 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BitmapMask = __webpack_require__(42); +var GeometryMask = __webpack_require__(41); + +/** + * Provides methods used for getting and setting the mask of a Game Object. + * + * @name Phaser.GameObjects.Components.Mask + * @since 3.0.0 + */ + +var Mask = { + + /** + * The Mask this Game Object is using during render. + * + * @name Phaser.GameObjects.Components.Mask#mask + * @type {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} + * @since 3.0.0 + */ + mask: null, + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * + * @method Phaser.GameObjects.Components.Mask#setMask + * @since 3.6.2 + * + * @param {Phaser.Display.Masks.BitmapMask|Phaser.Display.Masks.GeometryMask} mask - The mask this Game Object will use when rendering. + * + * @return {this} This Game Object instance. + */ + setMask: function (mask) + { + this.mask = mask; + + return this; + }, + + /** + * Clears the mask that this Game Object was using. + * + * @method Phaser.GameObjects.Components.Mask#clearMask + * @since 3.6.2 + * + * @param {boolean} [destroyMask=false] - Destroy the mask before clearing it? + * + * @return {this} This Game Object instance. + */ + clearMask: function (destroyMask) + { + if (destroyMask === undefined) { destroyMask = false; } + + if (destroyMask && this.mask) + { + this.mask.destroy(); + } + + this.mask = null; + + return this; + }, + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * + * @method Phaser.GameObjects.Components.Mask#createBitmapMask + * @since 3.6.2 + * + * @param {Phaser.GameObjects.GameObject} [renderable] - A renderable Game Object that uses a texture, such as a Sprite. + * + * @return {Phaser.Display.Masks.BitmapMask} This Bitmap Mask that was created. + */ + createBitmapMask: function (renderable) + { + if (renderable === undefined && this.texture) + { + // eslint-disable-next-line consistent-this + renderable = this; + } + + return new BitmapMask(this.scene, renderable); + }, + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * + * @method Phaser.GameObjects.Components.Mask#createGeometryMask + * @since 3.6.2 + * + * @param {Phaser.GameObjects.Graphics} [graphics] - A Graphics Game Object. The geometry within it will be used as the mask. + * + * @return {Phaser.Display.Masks.GeometryMask} This Geometry Mask that was created. + */ + createGeometryMask: function (graphics) + { + if (graphics === undefined && this.type === 'Graphics') + { + // eslint-disable-next-line consistent-this + graphics = this; + } + + return new GeometryMask(this.scene, graphics); + } + +}; + +module.exports = Mask; + + +/***/ }), +/* 44 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Rotate a `point` around `x` and `y` by the given `angle`. + * + * @function Phaser.Math.RotateAround + * @since 3.0.0 + * + * @param {(Phaser.Geom.Point|object)} point - The point to be rotated. + * @param {number} x - The horizontal coordinate to rotate around. + * @param {number} y - The vertical coordinate to rotate around. + * @param {number} angle - The angle of rotation in radians. + * + * @return {Phaser.Geom.Point} The given point, rotated by the given angle around the given coordinates. + */ +var RotateAround = function (point, x, y, angle) +{ + var c = Math.cos(angle); + var s = Math.sin(angle); + + var tx = point.x - x; + var ty = point.y - y; + + point.x = tx * c - ty * s + x; + point.y = tx * s + ty * c + y; + + return point; +}; + +module.exports = RotateAround; + + +/***/ }), +/* 45 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(1); + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Point} out - [description] + * + * @return {Phaser.Geom.Point} [description] + */ +var Random = function (rect, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = rect.x + (Math.random() * rect.width); + out.y = rect.y + (Math.random() * rect.height); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 46 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(1); + +/** + * Returns a random point on a given Line. + * + * @function Phaser.Geom.Line.Random + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The Line to calculate the random Point on. + * @param {(Phaser.Geom.Point|object)} [out] - An instance of a Point to be modified. + * + * @return {(Phaser.Geom.Point|object)} A random Point on the Line. + */ +var Random = function (line, out) +{ + if (out === undefined) { out = new Point(); } + + var t = Math.random(); + + out.x = line.x1 + t * (line.x2 - line.x1); + out.y = line.y1 + t * (line.y2 - line.y1); + + return out; +}; + +module.exports = Random; + + +/***/ }), +/* 47 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Calculate the length of the given line. + * + * @function Phaser.Geom.Line.Length + * @since 3.0.0 + * + * @param {Phaser.Geom.Line} line - The line to calculate the length of. + * + * @return {number} The length of the line. + */ +var Length = function (line) +{ + return Math.sqrt((line.x2 - line.x1) * (line.x2 - line.x1) + (line.y2 - line.y1) * (line.y2 - line.y1)); +}; + +module.exports = Length; + + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = __webpack_require__(47); +var Point = __webpack_require__(1); + +/** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * @function Phaser.Geom.Line.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line. + * @param {integer} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {number} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param {(array|Phaser.Geom.Point[])} [out] - An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * + * @return {(array|Phaser.Geom.Point[])} An array of Points, or point-like objects, containing the coordinates of the points on the line. + */ +var GetPoints = function (line, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Length(line) / stepRate; + } + + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + var x = x1 + (x2 - x1) * position; + var y = y1 + (y2 - y1) * position; + + out.push(new Point(x, y)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = __webpack_require__(1); + +/** + * Get a point on a line that's a given percentage along its length. + * + * @function Phaser.Geom.Line.GetPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line. + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point, or point-like object, to store the coordinates of the point on the line. + * + * @return {(Phaser.Geom.Point|object)} The point on the line. + */ +var GetPoint = function (line, position, out) +{ + if (out === undefined) { out = new Point(); } + + out.x = line.x1 + (line.x2 - line.x1) * position; + out.y = line.y1 + (line.y2 - line.y1) * position; + + return out; +}; + +module.exports = GetPoint; + + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var GetPoint = __webpack_require__(49); +var GetPoints = __webpack_require__(48); +var Random = __webpack_require__(46); +var Vector2 = __webpack_require__(3); + +/** + * @classdesc + * Defines a Line segment, a part of a line between two endpoints. + * + * @class Line + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x1=0] - The x coordinate of the lines starting point. + * @param {number} [y1=0] - The y coordinate of the lines starting point. + * @param {number} [x2=0] - The x coordinate of the lines ending point. + * @param {number} [y2=0] - The y coordinate of the lines ending point. + */ +var Line = new Class({ + + initialize: + + function Line (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + /** + * The x coordinate of the lines starting point. + * + * @name Phaser.Geom.Line#x1 + * @type {number} + * @since 3.0.0 + */ + this.x1 = x1; + + /** + * The y coordinate of the lines starting point. + * + * @name Phaser.Geom.Line#y1 + * @type {number} + * @since 3.0.0 + */ + this.y1 = y1; + + /** + * The x coordinate of the lines ending point. + * + * @name Phaser.Geom.Line#x2 + * @type {number} + * @since 3.0.0 + */ + this.x2 = x2; + + /** + * The y coordinate of the lines ending point. + * + * @name Phaser.Geom.Line#y2 + * @type {number} + * @since 3.0.0 + */ + this.y2 = y2; + }, + + /** + * Get a point on a line that's a given percentage along its length. + * + * @method Phaser.Geom.Line#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {number} position - A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param {(Phaser.Geom.Point|object)} [output] - An optional point, or point-like object, to store the coordinates of the point on the line. + * + * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point on the line. + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * + * @method Phaser.Geom.Line#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {integer} quantity - The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param {integer} [stepRate] - The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param {(array|Phaser.Geom.Point[])} [output] - An optional array of Points, or point-like objects, to store the coordinates of the points on the line. + * + * @return {(array|Phaser.Geom.Point[])} An array of Points, or point-like objects, containing the coordinates of the points on the line. + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * Get a random Point on the Line. + * + * @method Phaser.Geom.Line#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {(Phaser.Geom.Point|object)} [point] - An instance of a Point to be modified. + * + * @return {Phaser.Geom.Point} A random Point on the Line. + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * Set new coordinates for the line endpoints. + * + * @method Phaser.Geom.Line#setTo + * @since 3.0.0 + * + * @param {number} [x1=0] - The x coordinate of the lines starting point. + * @param {number} [y1=0] - The y coordinate of the lines starting point. + * @param {number} [x2=0] - The x coordinate of the lines ending point. + * @param {number} [y2=0] - The y coordinate of the lines ending point. + * + * @return {Phaser.Geom.Line} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 0; } + if (y2 === undefined) { y2 = 0; } + + this.x1 = x1; + this.y1 = y1; + + this.x2 = x2; + this.y2 = y2; + + return this; + }, + + /** + * Returns a Vector2 object that corresponds to the start of this Line. + * + * @method Phaser.Geom.Line#getPointA + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + */ + getPointA: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x1, this.y1); + + return vec2; + }, + + /** + * Returns a Vector2 object that corresponds to the end of this Line. + * + * @method Phaser.Geom.Line#getPointB + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [vec2,$return] + * + * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the end of this Line. + */ + getPointB: function (vec2) + { + if (vec2 === undefined) { vec2 = new Vector2(); } + + vec2.set(this.x2, this.y2); + + return vec2; + }, + + /** + * The left position of the Line. + * + * @name Phaser.Geom.Line#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return Math.min(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 <= this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The right position of the Line. + * + * @name Phaser.Geom.Line#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return Math.max(this.x1, this.x2); + }, + + set: function (value) + { + if (this.x1 > this.x2) + { + this.x1 = value; + } + else + { + this.x2 = value; + } + } + + }, + + /** + * The top position of the Line. + * + * @name Phaser.Geom.Line#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return Math.min(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 <= this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + }, + + /** + * The bottom position of the Line. + * + * @name Phaser.Geom.Line#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return Math.max(this.y1, this.y2); + }, + + set: function (value) + { + if (this.y1 > this.y2) + { + this.y1 = value; + } + else + { + this.y2 = value; + } + } + + } + +}); + +module.exports = Line; + + +/***/ }), +/* 51 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetPoint = __webpack_require__(10); +var Perimeter = __webpack_require__(9); + +// Return an array of points from the perimeter of the rectangle +// each spaced out based on the quantity or step required + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.GetPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [out,$return] + * + * @param {Phaser.Geom.Rectangle} rectangle - [description] + * @param {number} step - [description] + * @param {integer} quantity - [description] + * @param {(array|Phaser.Geom.Point[])} [out] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ +var GetPoints = function (rectangle, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = Perimeter(rectangle) / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var position = i / quantity; + + out.push(GetPoint(rectangle, position)); + } + + return out; +}; + +module.exports = GetPoints; + + +/***/ }), +/* 52 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * [description] + * + * @function Phaser.Geom.Rectangle.Contains + * @since 3.0.0 + * + * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ +var Contains = function (rect, x, y) +{ + if (rect.width <= 0 || rect.height <= 0) + { + return false; + } + + return (rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y); +}; + +module.exports = Contains; + + +/***/ }), +/* 53 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); +var Contains = __webpack_require__(52); +var GetPoint = __webpack_require__(10); +var GetPoints = __webpack_require__(51); +var Line = __webpack_require__(50); +var Random = __webpack_require__(45); + +/** + * @classdesc + * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) + * + * @class Rectangle + * @memberOf Phaser.Geom + * @constructor + * @since 3.0.0 + * + * @param {number} [x=0] - [description] + * @param {number} [y=0] - [description] + * @param {number} [width=0] - [description] + * @param {number} [height=0] - [description] + */ +var Rectangle = new Class({ + + initialize: + + function Rectangle (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = x; + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = y; + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#width + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.width = width; + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#height + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.height = height; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#contains + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * + * @return {boolean} [description] + */ + contains: function (x, y) + { + return Contains(this, x, y); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#getPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [output,$return] + * + * @param {number} position - [description] + * @param {(Phaser.Geom.Point|object)} [output] - [description] + * + * @return {(Phaser.Geom.Point|object)} [description] + */ + getPoint: function (position, output) + { + return GetPoint(this, position, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#getPoints + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point[]} O - [output,$return] + * + * @param {integer} quantity - [description] + * @param {number} [stepRate] - [description] + * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * + * @return {(array|Phaser.Geom.Point[])} [description] + */ + getPoints: function (quantity, stepRate, output) + { + return GetPoints(this, quantity, stepRate, output); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#getRandomPoint + * @since 3.0.0 + * + * @generic {Phaser.Geom.Point} O - [point,$return] + * + * @param {Phaser.Geom.Point} [point] - [description] + * + * @return {Phaser.Geom.Point} [description] + */ + getRandomPoint: function (point) + { + return Random(this, point); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setTo + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setTo: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setEmpty + * @since 3.0.0 + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setEmpty: function () + { + return this.setTo(0, 0, 0, 0); + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setPosition + * @since 3.0.0 + * + * @param {number} x - [description] + * @param {number} [y=x] - [description] + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#setSize + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} [height=width] - [description] + * + * @return {Phaser.Geom.Rectangle} This Rectangle object. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Geom.Rectangle#isEmpty + * @since 3.0.0 + * + * @return {boolean} [description] + */ + isEmpty: function () + { + return (this.width <= 0 || this.height <= 0); + }, + + /** + * Returns a Line object that corresponds to the top of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineA + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the top of this Rectangle. + */ + getLineA: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.y, this.right, this.y); + + return line; + }, + + /** + * Returns a Line object that corresponds to the right of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineB + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the right of this Rectangle. + */ + getLineB: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.y, this.right, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the bottom of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineC + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the bottom of this Rectangle. + */ + getLineC: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.right, this.bottom, this.x, this.bottom); + + return line; + }, + + /** + * Returns a Line object that corresponds to the left of this Rectangle. + * + * @method Phaser.Geom.Rectangle#getLineD + * @since 3.0.0 + * + * @generic {Phaser.Geom.Line} O - [line,$return] + * + * @param {Phaser.Geom.Line} [line] - A Line object to set the results in. If `undefined` a new Line will be created. + * + * @return {Phaser.Geom.Line} A Line object that corresponds to the left of this Rectangle. + */ + getLineD: function (line) + { + if (line === undefined) { line = new Line(); } + + line.setTo(this.x, this.bottom, this.x, this.y); + + return line; + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#left + * @type {number} + * @since 3.0.0 + */ + left: { + + get: function () + { + return this.x; + }, + + set: function (value) + { + if (value >= this.right) + { + this.width = 0; + } + else + { + this.width = this.right - value; + } + + this.x = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#right + * @type {number} + * @since 3.0.0 + */ + right: { + + get: function () + { + return this.x + this.width; + }, + + set: function (value) + { + if (value <= this.x) + { + this.width = 0; + } + else + { + this.width = value - this.x; + } + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#top + * @type {number} + * @since 3.0.0 + */ + top: { + + get: function () + { + return this.y; + }, + + set: function (value) + { + if (value >= this.bottom) + { + this.height = 0; + } + else + { + this.height = (this.bottom - value); + } + + this.y = value; + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#bottom + * @type {number} + * @since 3.0.0 + */ + bottom: { + + get: function () + { + return this.y + this.height; + }, + + set: function (value) + { + if (value <= this.y) + { + this.height = 0; + } + else + { + this.height = value - this.y; + } + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#centerX + * @type {number} + * @since 3.0.0 + */ + centerX: { + + get: function () + { + return this.x + (this.width / 2); + }, + + set: function (value) + { + this.x = value - (this.width / 2); + } + + }, + + /** + * [description] + * + * @name Phaser.Geom.Rectangle#centerY + * @type {number} + * @since 3.0.0 + */ + centerY: { + + get: function () + { + return this.y + (this.height / 2); + }, + + set: function (value) + { + this.y = value - (this.height / 2); + } + + } + +}); + +module.exports = Rectangle; + + +/***/ }), +/* 54 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = __webpack_require__(53); +var RotateAround = __webpack_require__(44); +var Vector2 = __webpack_require__(3); + +/** + * Provides methods used for obtaining the bounds of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.GetBounds + * @since 3.0.0 + */ + +var GetBounds = { + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getCenter + * @since 3.0.0 + * + * @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. + * + * @return {(Phaser.Math.Vector2|object)} The values stored in the output object. + */ + getCenter: function (output) + { + if (output === undefined) { output = new Vector2(); } + + output.x = this.x - (this.displayWidth * this.originX) + (this.displayWidth / 2); + output.y = this.y - (this.displayHeight * this.originY) + (this.displayHeight / 2); + + return output; + }, + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getTopLeft + * @since 3.0.0 + * + * @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, includeParent) + { + 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); + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getTopRight + * @since 3.0.0 + * + * @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, includeParent) + { + 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); + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomLeft + * @since 3.0.0 + * + * @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, includeParent) + { + 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; + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * + * @method Phaser.GameObjects.Components.GetBounds#getBottomRight + * @since 3.0.0 + * + * @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, includeParent) + { + 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; + + if (this.rotation !== 0) + { + 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; + }, + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * + * @method Phaser.GameObjects.Components.GetBounds#getBounds + * @since 3.0.0 + * + * @generic {Phaser.Geom.Rectangle} O - [output,$return] + * + * @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created. + * + * @return {(Phaser.Geom.Rectangle|object)} The values stored in the output object. + */ + getBounds: function (output) + { + if (output === undefined) { output = new Rectangle(); } + + // We can use the output object to temporarily store the x/y coords in: + + var TLx, TLy, TRx, TRy, BLx, BLy, BRx, BRy; + + // Instead of doing a check if parent container is + // defined per corner we only do it once. + if (this.parentContainer) + { + var parentMatrix = this.parentContainer.getBoundsTransformMatrix(); + + this.getTopLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + parentMatrix.transformPoint(output.x, output.y, output); + + BRx = output.x; + BRy = output.y; + } + else + { + this.getTopLeft(output); + + TLx = output.x; + TLy = output.y; + + this.getTopRight(output); + + TRx = output.x; + TRy = output.y; + + this.getBottomLeft(output); + + BLx = output.x; + BLy = output.y; + + this.getBottomRight(output); + + BRx = output.x; + BRy = output.y; + } + + output.x = Math.min(TLx, TRx, BLx, BRx); + output.y = Math.min(TLy, TRy, BLy, BRy); + output.width = Math.max(TLx, TRx, BLx, BRx) - output.x; + output.height = Math.max(TLy, TRy, BLy, BRy) - output.y; + + return output; + } + +}; + +module.exports = GetBounds; + + +/***/ }), +/* 55 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for visually flipping a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Flip + * @since 3.0.0 + */ + +var Flip = { + + /** + * The horizontally flipped state of the Game Object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipX: false, + + /** + * The vertically flipped state of the Game Object. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipY: false, + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipX + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipX: function () + { + this.flipX = !this.flipX; + + return this; + }, + + /** + * Toggles the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipY + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipY: function () + { + this.flipY = !this.flipY; + + return this; + }, + + /** + * Sets the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * + * @method Phaser.GameObjects.Components.Flip#resetFlip + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + } + +}; + +module.exports = Flip; + + +/***/ }), +/* 56 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Depth + * @since 3.0.0 + */ + +var Depth = { + + /** + * Private internal value. Holds the depth of the Game Object. + * + * @name Phaser.GameObjects.Components.Depth#_depth + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _depth: 0, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @name Phaser.GameObjects.Components.Depth#depth + * @type {number} + * @since 3.0.0 + */ + depth: { + + get: function () + { + return this._depth; + }, + + set: function (value) + { + this.scene.sys.queueDepthSort(); + this._depth = value; + } + + }, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @method Phaser.GameObjects.Components.Depth#setDepth + * @since 3.0.0 + * + * @param {integer} value - The depth of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDepth: function (value) + { + if (value === undefined) { value = 0; } + + this.depth = value; + + return this; + } + +}; + +module.exports = Depth; + + +/***/ }), +/* 57 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Crop + * @since 3.12.0 + */ + +var Crop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.Crop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.Crop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.Crop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = Crop; + + +/***/ }), +/* 58 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for calculating and setting the size of a non-Frame based Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.ComputedSize + * @since 3.0.0 + */ + +var ComputedSize = { + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#width + * @type {number} + * @since 3.0.0 + */ + width: 0, + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * + * @name Phaser.GameObjects.Components.ComputedSize#height + * @type {number} + * @since 3.0.0 + */ + height: 0, + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayWidth + * @type {number} + * @since 3.0.0 + */ + displayWidth: { + + get: function () + { + return this.scaleX * this.width; + }, + + set: function (value) + { + this.scaleX = value / this.width; + } + + }, + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + * + * @name Phaser.GameObjects.Components.ComputedSize#displayHeight + * @type {number} + * @since 3.0.0 + */ + displayHeight: { + + get: function () + { + return this.scaleY * this.height; + }, + + set: function (value) + { + this.scaleY = value / this.height; + } + + }, + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * + * @method Phaser.GameObjects.Components.ComputedSize#setSize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.width = width; + this.height = height; + + return this; + }, + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * + * @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize + * @since 3.4.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDisplaySize: function (width, height) + { + this.displayWidth = width; + this.displayHeight = height; + + return this; + } + +}; + +module.exports = ComputedSize; + + +/***/ }), +/* 59 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(18); + +/** + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.BlendMode + * @since 3.0.0 + */ + +var BlendMode = { + + /** + * Private internal value. Holds the current blend mode. + * + * @name Phaser.GameObjects.Components.BlendMode#_blendMode + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _blendMode: BlendModes.NORMAL, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @name Phaser.GameObjects.Components.BlendMode#blendMode + * @type {(Phaser.BlendModes|string)} + * @since 3.0.0 + */ + blendMode: { + + get: function () + { + return this._blendMode; + }, + + set: function (value) + { + if (typeof value === 'string') + { + value = BlendModes[value]; + } + + value |= 0; + + if (value >= -1) + { + this._blendMode = value; + } + } + + }, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @method Phaser.GameObjects.Components.BlendMode#setBlendMode + * @since 3.0.0 + * + * @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST. + * + * @return {this} This Game Object instance. + */ + setBlendMode: function (value) + { + this.blendMode = value; + + return this; + } + +}; + +module.exports = BlendMode; + + +/***/ }), +/* 60 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * This event is dispatched when an animation starts playing. + * + * @event Phaser.GameObjects.Components.Animation#onStartEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + */ + +/** + * This event is dispatched when an animation repeats. + * + * @event Phaser.GameObjects.Components.Animation#onRepeatEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {integer} repeatCount - The number of times this animation has repeated. + */ + +/** + * This event is dispatched when an animation updates. This happens when the animation frame changes, + * based on the animation frame rate and other factors like timeScale and delay. + * + * @event Phaser.GameObjects.Components.Animation#onUpdateEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + */ + +/** + * This event is dispatched when an animation completes playing, either naturally or via Animation.stop. + * + * @event Phaser.GameObjects.Components.Animation#onCompleteEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + */ + +/** + * @classdesc + * A Game Object Animation Controller. + * + * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. + * + * @class Animation + * @memberOf Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} parent - The Game Object to which this animation controller belongs. + */ +var Animation = new Class({ + + initialize: + + function Animation (parent) + { + /** + * The Game Object to which this animation controller belongs. + * + * @name Phaser.GameObjects.Components.Animation#parent + * @type {Phaser.GameObjects.GameObject} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * A reference to the global Animation Manager. + * + * @name Phaser.GameObjects.Components.Animation#animationManager + * @type {Phaser.Animations.AnimationManager} + * @since 3.0.0 + */ + this.animationManager = parent.scene.sys.anims; + + this.animationManager.once('remove', this.remove, this); + + /** + * Is an animation currently playing or not? + * + * @name Phaser.GameObjects.Components.Animation#isPlaying + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.isPlaying = false; + + /** + * The current Animation loaded into this Animation Controller. + * + * @name Phaser.GameObjects.Components.Animation#currentAnim + * @type {?Phaser.Animations.Animation} + * @default null + * @since 3.0.0 + */ + this.currentAnim = null; + + /** + * The current AnimationFrame being displayed by this Animation Controller. + * + * @name Phaser.GameObjects.Components.Animation#currentFrame + * @type {?Phaser.Animations.AnimationFrame} + * @default null + * @since 3.0.0 + */ + this.currentFrame = null; + + /** + * Time scale factor. + * + * @name Phaser.GameObjects.Components.Animation#_timeScale + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + this._timeScale = 1; + + /** + * The frame rate of playback in frames per second. + * The default is 24 if the `duration` property is `null`. + * + * @name Phaser.GameObjects.Components.Animation#frameRate + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.frameRate = 0; + + /** + * How long the animation should play for, in milliseconds. + * If the `frameRate` property has been set then it overrides this value, + * otherwise the `frameRate` is derived from `duration`. + * + * @name Phaser.GameObjects.Components.Animation#duration + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.duration = 0; + + /** + * ms per frame, not including frame specific modifiers that may be present in the Animation data. + * + * @name Phaser.GameObjects.Components.Animation#msPerFrame + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.msPerFrame = 0; + + /** + * Skip frames if the time lags, or always advanced anyway? + * + * @name Phaser.GameObjects.Components.Animation#skipMissedFrames + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.skipMissedFrames = true; + + /** + * A delay before starting playback, in milliseconds. + * + * @name Phaser.GameObjects.Components.Animation#_delay + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._delay = 0; + + /** + * Number of times to repeat the animation (-1 for infinity) + * + * @name Phaser.GameObjects.Components.Animation#_repeat + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._repeat = 0; + + /** + * Delay before the repeat starts, in milliseconds. + * + * @name Phaser.GameObjects.Components.Animation#_repeatDelay + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + this._repeatDelay = 0; + + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + * + * @name Phaser.GameObjects.Components.Animation#_yoyo + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._yoyo = false; + + /** + * Will the playhead move forwards (`true`) or in reverse (`false`). + * + * @name Phaser.GameObjects.Components.Animation#forward + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.forward = true; + + /** + * An Internal trigger that's play the animation in reverse mode ('true') or not ('false'), + * needed because forward can be changed by yoyo feature. + * + * @name Phaser.GameObjects.Components.Animation#forward + * @type {boolean} + * @default false + * @since 3.12.0 + */ + this._reverse = false; + + /** + * Internal time overflow accumulator. + * + * @name Phaser.GameObjects.Components.Animation#accumulator + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.accumulator = 0; + + /** + * The time point at which the next animation frame will change. + * + * @name Phaser.GameObjects.Components.Animation#nextTick + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.nextTick = 0; + + /** + * An internal counter keeping track of how many repeats are left to play. + * + * @name Phaser.GameObjects.Components.Animation#repeatCounter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.repeatCounter = 0; + + /** + * An internal flag keeping track of pending repeats. + * + * @name Phaser.GameObjects.Components.Animation#pendingRepeat + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.pendingRepeat = false; + + /** + * Is the Animation paused? + * + * @name Phaser.GameObjects.Components.Animation#_paused + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._paused = false; + + /** + * Was the animation previously playing before being paused? + * + * @name Phaser.GameObjects.Components.Animation#_wasPlaying + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._wasPlaying = false; + + /** + * Internal property tracking if this Animation is waiting to stop. + * + * 0 = No + * 1 = Waiting for ms to pass + * 2 = Waiting for repeat + * 3 = Waiting for specific frame + * + * @name Phaser.GameObjects.Components.Animation#_pendingStop + * @type {integer} + * @private + * @since 3.4.0 + */ + this._pendingStop = 0; + + /** + * Internal property used by _pendingStop. + * + * @name Phaser.GameObjects.Components.Animation#_pendingStopValue + * @type {any} + * @private + * @since 3.4.0 + */ + this._pendingStopValue; + }, + + /** + * Sets the amount of time, in milliseconds, that the animation will be delayed before starting playback. + * + * @method Phaser.GameObjects.Components.Animation#setDelay + * @since 3.4.0 + * + * @param {integer} [value=0] - The amount of time, in milliseconds, to wait before starting playback. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setDelay: function (value) + { + if (value === undefined) { value = 0; } + + this._delay = value; + + return this.parent; + }, + + /** + * Gets the amount of time, in milliseconds that the animation will be delayed before starting playback. + * + * @method Phaser.GameObjects.Components.Animation#getDelay + * @since 3.4.0 + * + * @return {integer} The amount of time, in milliseconds, the Animation will wait before starting playback. + */ + getDelay: function () + { + return this._delay; + }, + + /** + * Waits for the specified delay, in milliseconds, then starts playback of the requested animation. + * + * @method Phaser.GameObjects.Components.Animation#delayedPlay + * @since 3.0.0 + * + * @param {integer} delay - The delay, in milliseconds, to wait before starting the animation playing. + * @param {string} key - The key of the animation to play. + * @param {integer} [startFrame=0] - The frame of the animation to start from. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + delayedPlay: function (delay, key, startFrame) + { + this.play(key, true, startFrame); + + this.nextTick += delay; + + return this.parent; + }, + + /** + * Returns the key of the animation currently loaded into this component. + * + * @method Phaser.GameObjects.Components.Animation#getCurrentKey + * @since 3.0.0 + * + * @return {string} The key of the Animation loaded into this component. + */ + getCurrentKey: function () + { + if (this.currentAnim) + { + return this.currentAnim.key; + } + }, + + /** + * Internal method used to load an animation into this component. + * + * @method Phaser.GameObjects.Components.Animation#load + * @protected + * @since 3.0.0 + * + * @param {string} key - The key of the animation to load. + * @param {integer} [startFrame=0] - The start frame of the animation to load. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + load: function (key, startFrame) + { + if (startFrame === undefined) { startFrame = 0; } + + if (this.isPlaying) + { + this.stop(); + } + + // Load the new animation in + this.animationManager.load(this, key, startFrame); + + return this.parent; + }, + + /** + * Pause the current animation and set the `isPlaying` property to `false`. + * You can optionally pause it at a specific frame. + * + * @method Phaser.GameObjects.Components.Animation#pause + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} [atFrame] - An optional frame to set after pausing the animation. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + pause: function (atFrame) + { + if (!this._paused) + { + this._paused = true; + this._wasPlaying = this.isPlaying; + this.isPlaying = false; + } + + if (atFrame !== undefined) + { + this.updateFrame(atFrame); + } + + return this.parent; + }, + + /** + * Resumes playback of a paused animation and sets the `isPlaying` property to `true`. + * You can optionally tell it to start playback from a specific frame. + * + * @method Phaser.GameObjects.Components.Animation#resume + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} [fromFrame] - An optional frame to set before restarting playback. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + resume: function (fromFrame) + { + if (this._paused) + { + this._paused = false; + this.isPlaying = this._wasPlaying; + } + + if (fromFrame !== undefined) + { + this.updateFrame(fromFrame); + } + + return this.parent; + }, + + /** + * `true` if the current animation is paused, otherwise `false`. + * + * @name Phaser.GameObjects.Components.Animation#isPaused + * @readOnly + * @type {boolean} + * @since 3.4.0 + */ + isPaused: { + + get: function () + { + return this._paused; + } + + }, + + /** + * Plays an Animation on the Game Object that owns this Animation Component. + * + * @method Phaser.GameObjects.Components.Animation#play + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.0.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + play: function (key, ignoreIfPlaying, startFrame) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + if (startFrame === undefined) { startFrame = 0; } + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) + { + return this.parent; + } + + this.forward = true; + this._reverse = false; + return this._startAnimation(key, startFrame); + }, + + /** + * Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component. + * + * @method Phaser.GameObjects.Components.Animation#playReverse + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + playReverse: function (key, ignoreIfPlaying, startFrame) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + if (startFrame === undefined) { startFrame = 0; } + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) + { + return this.parent; + } + + this.forward = false; + this._reverse = true; + return this._startAnimation(key, startFrame); + }, + + /** + * Load an Animation and fires 'onStartEvent' event, + * extracted from 'play' method + * + * @method Phaser.GameObjects.Components.Animation#_startAnimation + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + _startAnimation: function (key, startFrame) + { + this.load(key, startFrame); + + var anim = this.currentAnim; + var gameObject = this.parent; + + // Should give us 9,007,199,254,740,991 safe repeats + this.repeatCounter = (this._repeat === -1) ? Number.MAX_VALUE : this._repeat; + + anim.getFirstTick(this); + + this.isPlaying = true; + this.pendingRepeat = false; + + if (anim.showOnStart) + { + gameObject.visible = true; + } + + gameObject.emit('animationstart', this.currentAnim, this.currentFrame); + + return gameObject; + }, + + /** + * Reverse an Animation that is already playing on the Game Object. + * + * @method Phaser.GameObjects.Components.Animation#reverse + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + reverse: function (key) + { + if (!this.isPlaying || this.currentAnim.key !== key) { return this.parent; } + this._reverse = !this._reverse; + this.forward = !this.forward; + + return this.parent; + }, + + /** + * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. + * If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different + * because `getProgress` doesn't include any repeats or repeat delays, whereas `getTotalProgress` does. + * + * @method Phaser.GameObjects.Components.Animation#getProgress + * @since 3.4.0 + * + * @return {number} The progress of the current animation, between 0 and 1. + */ + getProgress: function () + { + var p = this.currentFrame.progress; + + if (!this.forward) + { + p = 1 - p; + } + + return p; + }, + + /** + * Takes a value between 0 and 1 and uses it to set how far this animation is through playback. + * Does not factor in repeats or yoyos, but does handle playing forwards or backwards. + * + * @method Phaser.GameObjects.Components.Animation#setProgress + * @since 3.4.0 + * + * @param {number} [value=0] - The progress value, between 0 and 1. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setProgress: function (value) + { + if (!this.forward) + { + value = 1 - value; + } + + this.setCurrentFrame(this.currentAnim.getFrameByProgress(value)); + + return this.parent; + }, + + /** + * Handle the removal of an animation from the Animation Manager. + * + * @method Phaser.GameObjects.Components.Animation#remove + * @since 3.0.0 + * + * @param {string} [key] - The key of the removed Animation. + * @param {Phaser.Animations.Animation} [animation] - The removed Animation. + */ + remove: function (key, animation) + { + if (animation === undefined) { animation = this.currentAnim; } + + if (this.isPlaying && animation.key === this.currentAnim.key) + { + this.stop(); + + this.setCurrentFrame(this.currentAnim.frames[0]); + } + }, + + /** + * Gets the number of times that the animation will repeat + * after its first iteration. For example, if returns 1, the animation will + * play a total of twice (the initial play plus 1 repeat). + * A value of -1 means the animation will repeat indefinitely. + * + * @method Phaser.GameObjects.Components.Animation#getRepeat + * @since 3.4.0 + * + * @return {integer} The number of times that the animation will repeat. + */ + getRepeat: function () + { + return this._repeat; + }, + + /** + * Sets the number of times that the animation should repeat + * after its first iteration. For example, if repeat is 1, the animation will + * play a total of twice (the initial play plus 1 repeat). + * To repeat indefinitely, use -1. repeat should always be an integer. + * + * @method Phaser.GameObjects.Components.Animation#setRepeat + * @since 3.4.0 + * + * @param {integer} value - The number of times that the animation should repeat. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setRepeat: function (value) + { + this._repeat = value; + + this.repeatCounter = 0; + + return this.parent; + }, + + /** + * Gets the amount of delay between repeats, if any. + * + * @method Phaser.GameObjects.Components.Animation#getRepeatDelay + * @since 3.4.0 + * + * @return {number} The delay between repeats. + */ + getRepeatDelay: function () + { + return this._repeatDelay; + }, + + /** + * Sets the amount of time in seconds between repeats. + * For example, if `repeat` is 2 and `repeatDelay` is 10, the animation will play initially, + * then wait for 10 seconds before repeating, then play again, then wait another 10 seconds + * before doing its final repeat. + * + * @method Phaser.GameObjects.Components.Animation#setRepeatDelay + * @since 3.4.0 + * + * @param {number} value - The delay to wait between repeats, in seconds. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setRepeatDelay: function (value) + { + this._repeatDelay = value; + + return this.parent; + }, + + /** + * Restarts the current animation from its beginning, optionally including its delay value. + * + * @method Phaser.GameObjects.Components.Animation#restart + * @since 3.0.0 + * + * @param {boolean} [includeDelay=false] - Whether to include the delay value of the animation when restarting. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + restart: function (includeDelay) + { + if (includeDelay === undefined) { includeDelay = false; } + + this.currentAnim.getFirstTick(this, includeDelay); + + this.forward = true; + this.isPlaying = true; + this.pendingRepeat = false; + this._paused = false; + + // Set frame + this.updateFrame(this.currentAnim.frames[0]); + + return this.parent; + }, + + /** + * Immediately stops the current animation from playing and dispatches the `animationcomplete` event. + * + * @method Phaser.GameObjects.Components.Animation#stop + * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent + * @since 3.0.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stop: function () + { + this._pendingStop = 0; + + this.isPlaying = false; + + var gameObject = this.parent; + + gameObject.emit('animationcomplete', this.currentAnim, this.currentFrame); + + return gameObject; + }, + + /** + * Stops the current animation from playing after the specified time delay, given in milliseconds. + * + * @method Phaser.GameObjects.Components.Animation#stopAfterDelay + * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent + * @since 3.4.0 + * + * @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. + */ + stopAfterDelay: function (delay) + { + this._pendingStop = 1; + this._pendingStopValue = delay; + + return this.parent; + }, + + /** + * Stops the current animation from playing when it next repeats. + * + * @method Phaser.GameObjects.Components.Animation#stopOnRepeat + * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent + * @since 3.4.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stopOnRepeat: function () + { + this._pendingStop = 2; + + return this.parent; + }, + + /** + * Stops the current animation from playing when it next sets the given frame. + * If this frame doesn't exist within the animation it will not stop it from playing. + * + * @method Phaser.GameObjects.Components.Animation#stopOnFrame + * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent + * @since 3.4.0 + * + * @param {Phaser.Animations.AnimationFrame} delay - The frame to check before stopping this animation. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + stopOnFrame: function (frame) + { + this._pendingStop = 3; + this._pendingStopValue = frame; + + return this.parent; + }, + + /** + * Sets the Time Scale factor, allowing you to make the animation go go faster or slower than default. + * Where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. + * + * @method Phaser.GameObjects.Components.Animation#setTimeScale + * @since 3.4.0 + * + * @param {number} [value=1] - The time scale factor, where 1 is no change, 0.5 is half speed, etc. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + setTimeScale: function (value) + { + if (value === undefined) { value = 1; } + + this._timeScale = value; + + return this.parent; + }, + + /** + * Gets the Time Scale factor. + * + * @method Phaser.GameObjects.Components.Animation#getTimeScale + * @since 3.4.0 + * + * @return {number} The Time Scale value. + */ + getTimeScale: function () + { + return this._timeScale; + }, + + /** + * Returns the total number of frames in this animation. + * + * @method Phaser.GameObjects.Components.Animation#getTotalFrames + * @since 3.4.0 + * + * @return {integer} The total number of frames in this animation. + */ + getTotalFrames: function () + { + return this.currentAnim.frames.length; + }, + + /** + * The internal update loop for the Animation Component. + * + * @method Phaser.GameObjects.Components.Animation#update + * @since 3.0.0 + * + * @param {number} time - The current timestamp. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. + */ + update: function (time, delta) + { + if (!this.currentAnim || !this.isPlaying || this.currentAnim.paused) + { + return; + } + + this.accumulator += delta * this._timeScale; + + if (this._pendingStop === 1) + { + this._pendingStopValue -= delta; + + if (this._pendingStopValue <= 0) + { + return this.currentAnim.completeAnimation(this); + } + } + + if (this.accumulator >= this.nextTick) + { + this.currentAnim.setFrame(this); + } + }, + + /** + * Sets the given Animation Frame as being the current frame + * and applies it to the parent Game Object, adjusting its size and origin as needed. + * + * @method Phaser.GameObjects.Components.Animation#setCurrentFrame + * @since 3.4.0 + * + * @param {Phaser.Animations.AnimationFrame} animationFrame - The Animation Frame to set as being current. + * + * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. + */ + setCurrentFrame: function (animationFrame) + { + var gameObject = this.parent; + + this.currentFrame = animationFrame; + + gameObject.texture = animationFrame.frame.texture; + gameObject.frame = animationFrame.frame; + + gameObject.setSizeToFrame(); + + if (animationFrame.frame.customPivot) + { + gameObject.setOrigin(animationFrame.frame.pivotX, animationFrame.frame.pivotY); + } + else + { + gameObject.updateDisplayOrigin(); + } + + return gameObject; + }, + + /** + * Internal frame change handler. + * + * @method Phaser.GameObjects.Components.Animation#updateFrame + * @fires Phaser.GameObjects.Components.Animation#onUpdateEvent + * @private + * @since 3.0.0 + * + * @param {Phaser.Animations.AnimationFrame} animationFrame - The animation frame to change to. + */ + updateFrame: function (animationFrame) + { + var gameObject = this.setCurrentFrame(animationFrame); + + if (this.isPlaying) + { + if (animationFrame.setAlpha) + { + gameObject.alpha = animationFrame.alpha; + } + + var anim = this.currentAnim; + + gameObject.emit('animationupdate', anim, animationFrame); + + if (this._pendingStop === 3 && this._pendingStopValue === animationFrame) + { + this.currentAnim.completeAnimation(this); + } + } + }, + + /** + * Sets if the current Animation will yoyo when it reaches the end. + * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. + * + * @method Phaser.GameObjects.Components.Animation#setYoyo + * @since 3.4.0 + * + * @param {boolean} [value=false] - `true` if the animation should yoyo, `false` to not. + * + * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. + */ + setYoyo: function (value) + { + if (value === undefined) { value = false; } + + this._yoyo = value; + + return this.parent; + }, + + /** + * Gets if the current Animation will yoyo when it reaches the end. + * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. + * + * @method Phaser.GameObjects.Components.Animation#getYoyo + * @since 3.4.0 + * + * @return {boolean} `true` if the animation is set to yoyo, `false` if not. + */ + getYoyo: function () + { + return this._yoyo; + }, + + /** + * Destroy this Animation component. + * + * Unregisters event listeners and cleans up its references. + * + * @method Phaser.GameObjects.Components.Animation#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.animationManager.off('remove', this.remove, this); + + this.animationManager = null; + this.parent = null; + + this.currentAnim = null; + this.currentFrame = null; + } + +}); + +module.exports = Animation; + + +/***/ }), +/* 61 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Force a value within the boundaries by clamping it to the range `min`, `max`. + * + * @function Phaser.Math.Clamp + * @since 3.0.0 + * + * @param {number} value - The value to be clamped. + * @param {number} min - The minimum bounds. + * @param {number} max - The maximum bounds. + * + * @return {number} The clamped value. + */ +var Clamp = function (value, min, max) +{ + return Math.max(min, Math.min(max, value)); +}; + +module.exports = Clamp; + + +/***/ }), +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(61); + +// bitmask flag for GameObject.renderMask +var _FLAG = 2; // 0010 + +/** + * Provides methods used for setting the alpha properties of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Alpha + * @since 3.0.0 + */ + +var Alpha = { + + /** + * Private internal value. Holds the global alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alpha: 1, + + /** + * Private internal value. Holds the top-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTL: 1, + + /** + * Private internal value. Holds the top-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTR: 1, + + /** + * Private internal value. Holds the bottom-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBL: 1, + + /** + * Private internal value. Holds the bottom-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBR: 1, + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + * + * @method Phaser.GameObjects.Components.Alpha#clearAlpha + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearAlpha: function () + { + return this.setAlpha(1); + }, + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * + * @method Phaser.GameObjects.Components.Alpha#setAlpha + * @since 3.0.0 + * + * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * + * @return {this} This Game Object instance. + */ + setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 1; } + + // Treat as if there is only one alpha value for the whole Game Object + if (topRight === undefined) + { + this.alpha = topLeft; + } + else + { + this._alphaTL = Clamp(topLeft, 0, 1); + this._alphaTR = Clamp(topRight, 0, 1); + this._alphaBL = Clamp(bottomLeft, 0, 1); + this._alphaBR = Clamp(bottomRight, 0, 1); + } + + return this; + }, + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + * + * @name Phaser.GameObjects.Components.Alpha#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alpha = v; + this._alphaTL = v; + this._alphaTR = v; + this._alphaBL = v; + this._alphaBR = v; + + if (v === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopLeft: { + + get: function () + { + return this._alphaTL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopRight: { + + get: function () + { + return this._alphaTR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomLeft: { + + get: function () + { + return this._alphaBL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomRight: { + + get: function () + { + return this._alphaBR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + } + +}; + +module.exports = Alpha; + + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @callback EachSetCallback + * @generic E - [entry] + * + * @param {*} entry - [description] + * @param {number} index - [description] + * + * @return {?boolean} [description] + */ + +/** + * @classdesc + * A Set is a collection of unique elements. + * + * @class Set + * @memberOf Phaser.Structs + * @constructor + * @since 3.0.0 + * + * @generic T + * @genericUse {T[]} - [elements] + * + * @param {Array.<*>} [elements] - [description] + */ +var Set = new Class({ + + initialize: + + function Set (elements) + { + /** + * [description] + * + * @genericUse {T[]} - [$type] + * + * @name Phaser.Structs.Set#entries + * @type {Array.<*>} + * @default [] + * @since 3.0.0 + */ + this.entries = []; + + if (Array.isArray(elements)) + { + for (var i = 0; i < elements.length; i++) + { + this.set(elements[i]); + } + } + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#set + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {*} value - [description] + * + * @return {Phaser.Structs.Set} This Set object. + */ + set: function (value) + { + if (this.entries.indexOf(value) === -1) + { + this.entries.push(value); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#get + * @since 3.0.0 + * + * @genericUse {T} - [value,$return] + * + * @param {string} property - [description] + * @param {*} value - [description] + * + * @return {*} [description] + */ + get: function (property, value) + { + for (var i = 0; i < this.entries.length; i++) + { + var entry = this.entries[i]; + + if (entry[property] === value) + { + return entry; + } + } + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#getArray + * @since 3.0.0 + * + * @genericUse {T[]} - [$return] + * + * @return {Array.<*>} [description] + */ + getArray: function () + { + return this.entries.slice(0); + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#delete + * @since 3.0.0 + * + * @genericUse {T} - [value] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {*} value - [description] + * + * @return {Phaser.Structs.Set} This Set object. + */ + delete: function (value) + { + var index = this.entries.indexOf(value); + + if (index > -1) + { + this.entries.splice(index, 1); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#dump + * @since 3.0.0 + */ + dump: function () + { + // eslint-disable-next-line no-console + console.group('Set'); + + for (var i = 0; i < this.entries.length; i++) + { + var entry = this.entries[i]; + console.log(entry); + } + + // eslint-disable-next-line no-console + console.groupEnd(); + }, + + /** + * For when you know this Set will be modified during the iteration. + * + * @method Phaser.Structs.Set#each + * @since 3.0.0 + * + * @genericUse {EachSetCallback.} - [callback] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {EachSetCallback} callback - [description] + * @param {*} callbackScope - [description] + * + * @return {Phaser.Structs.Set} This Set object. + */ + each: function (callback, callbackScope) + { + var i; + var temp = this.entries.slice(); + var len = temp.length; + + if (callbackScope) + { + for (i = 0; i < len; i++) + { + if (callback.call(callbackScope, temp[i], i) === false) + { + break; + } + } + } + else + { + for (i = 0; i < len; i++) + { + if (callback(temp[i], i) === false) + { + break; + } + } + } + + return this; + }, + + /** + * For when you absolutely know this Set won't be modified during the iteration. + * + * @method Phaser.Structs.Set#iterate + * @since 3.0.0 + * + * @genericUse {EachSetCallback.} - [callback] + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {EachSetCallback} callback - [description] + * @param {*} [callbackScope] - [description] + * + * @return {Phaser.Structs.Set} This Set object. + */ + iterate: function (callback, callbackScope) + { + var i; + var len = this.entries.length; + + if (callbackScope) + { + for (i = 0; i < len; i++) + { + if (callback.call(callbackScope, this.entries[i], i) === false) + { + break; + } + } + } + else + { + for (i = 0; i < len; i++) + { + if (callback(this.entries[i], i) === false) + { + break; + } + } + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#iterateLocal + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @param {string} callbackKey - [description] + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * + * @return {Phaser.Structs.Set} This Set object. + */ + iterateLocal: function (callbackKey) + { + var i; + var args = []; + + for (i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + var len = this.entries.length; + + for (i = 0; i < len; i++) + { + var entry = this.entries[i]; + + entry[callbackKey].apply(entry, args); + } + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#clear + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [$return] + * + * @return {Phaser.Structs.Set} This Set object. + */ + clear: function () + { + this.entries.length = 0; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#contains + * @since 3.0.0 + * + * @genericUse {T} - [value] + * + * @param {*} value - [description] + * + * @return {boolean} [description] + */ + contains: function (value) + { + return (this.entries.indexOf(value) > -1); + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#union + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - [description] + * + * @return {Phaser.Structs.Set} [description] + */ + union: function (set) + { + var newSet = new Set(); + + set.entries.forEach(function (value) + { + newSet.set(value); + }); + + this.entries.forEach(function (value) + { + newSet.set(value); + }); + + return newSet; + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#intersect + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - [description] + * + * @return {Phaser.Structs.Set} [description] + */ + intersect: function (set) + { + var newSet = new Set(); + + this.entries.forEach(function (value) + { + if (set.contains(value)) + { + newSet.set(value); + } + }); + + return newSet; + }, + + /** + * [description] + * + * @method Phaser.Structs.Set#difference + * @since 3.0.0 + * + * @genericUse {Phaser.Structs.Set.} - [set,$return] + * + * @param {Phaser.Structs.Set} set - [description] + * + * @return {Phaser.Structs.Set} [description] + */ + difference: function (set) + { + var newSet = new Set(); + + this.entries.forEach(function (value) + { + if (!set.contains(value)) + { + newSet.set(value); + } + }); + + return newSet; + }, + + /** + * [description] + * + * @name Phaser.Structs.Set#size + * @type {integer} + * @since 3.0.0 + */ + size: { + + get: function () + { + return this.entries.length; + }, + + set: function (value) + { + return this.entries.length = value; + } + + } + +}); + +module.exports = Set; + + +/***/ }), +/* 64 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A three-dimensional matrix. + * + * Defaults to the identity matrix when instantiated. + * + * @class Matrix3 + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} [m] - Optional Matrix3 to copy values from. + */ +var Matrix3 = new Class({ + + initialize: + + function Matrix3 (m) + { + /** + * The matrix values. + * + * @name Phaser.Math.Matrix3#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(9); + + if (m) + { + // Assume Matrix3 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * Make a clone of this Matrix3. + * + * @method Phaser.Math.Matrix3#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} A clone of this Matrix3. + */ + clone: function () + { + return new Matrix3(this); + }, + + /** + * This method is an alias for `Matrix3.copy`. + * + * @method Phaser.Math.Matrix3#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to set the values of this Matrix's from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * Copy the values of a given Matrix into this Matrix. + * + * @method Phaser.Math.Matrix3#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * Copy the values of a given Matrix4 into this Matrix3. + * + * @method Phaser.Math.Matrix3#fromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - The Matrix4 to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromMat4: function (m) + { + var a = m.val; + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[4]; + out[4] = a[5]; + out[5] = a[6]; + out[6] = a[8]; + out[7] = a[9]; + out[8] = a[10]; + + return this; + }, + + /** + * Set the values of this Matrix from the given array. + * + * @method Phaser.Math.Matrix3#fromArray + * @since 3.0.0 + * + * @param {array} a - The array to copy the values from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + + return this; + }, + + /** + * Reset this Matrix to an identity (default) matrix. + * + * @method Phaser.Math.Matrix3#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 1; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 1; + + return this; + }, + + /** + * Transpose this Matrix. + * + * @method Phaser.Math.Matrix3#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + transpose: function () + { + var a = this.val; + var a01 = a[1]; + var a02 = a[2]; + var a12 = a[5]; + + a[1] = a[3]; + a[2] = a[6]; + a[3] = a01; + a[5] = a[7]; + a[6] = a02; + a[7] = a12; + + return this; + }, + + /** + * Invert this Matrix. + * + * @method Phaser.Math.Matrix3#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b01 = a22 * a11 - a12 * a21; + var b11 = -a22 * a10 + a12 * a20; + var b21 = a21 * a10 - a11 * a20; + + // Calculate the determinant + var det = a00 * b01 + a01 * b11 + a02 * b21; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = b01 * det; + a[1] = (-a22 * a01 + a02 * a21) * det; + a[2] = (a12 * a01 - a02 * a11) * det; + a[3] = b11 * det; + a[4] = (a22 * a00 - a02 * a20) * det; + a[5] = (-a12 * a00 + a02 * a10) * det; + a[6] = b21 * det; + a[7] = (-a21 * a00 + a01 * a20) * det; + a[8] = (a11 * a00 - a01 * a10) * det; + + return this; + }, + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + * + * @method Phaser.Math.Matrix3#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + a[0] = (a11 * a22 - a12 * a21); + a[1] = (a02 * a21 - a01 * a22); + a[2] = (a01 * a12 - a02 * a11); + a[3] = (a12 * a20 - a10 * a22); + a[4] = (a00 * a22 - a02 * a20); + a[5] = (a02 * a10 - a00 * a12); + a[6] = (a10 * a21 - a11 * a20); + a[7] = (a01 * a20 - a00 * a21); + a[8] = (a00 * a11 - a01 * a10); + + return this; + }, + + /** + * Calculate the determinant of this Matrix. + * + * @method Phaser.Math.Matrix3#determinant + * @since 3.0.0 + * + * @return {number} The determinant of this Matrix. + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * @method Phaser.Math.Matrix3#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} src - The Matrix to multiply this Matrix by. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + var a20 = a[6]; + var a21 = a[7]; + var a22 = a[8]; + + var b = src.val; + + var b00 = b[0]; + var b01 = b[1]; + var b02 = b[2]; + var b10 = b[3]; + var b11 = b[4]; + var b12 = b[5]; + var b20 = b[6]; + var b21 = b[7]; + var b22 = b[8]; + + a[0] = b00 * a00 + b01 * a10 + b02 * a20; + a[1] = b00 * a01 + b01 * a11 + b02 * a21; + a[2] = b00 * a02 + b01 * a12 + b02 * a22; + + a[3] = b10 * a00 + b11 * a10 + b12 * a20; + a[4] = b10 * a01 + b11 * a11 + b12 * a21; + a[5] = b10 * a02 + b11 * a12 + b12 * a22; + + a[6] = b20 * a00 + b21 * a10 + b22 * a20; + a[7] = b20 * a01 + b21 * a11 + b22 * a21; + a[8] = b20 * a02 + b21 * a12 + b22 * a22; + + return this; + }, + + /** + * Translate this Matrix using the given Vector. + * + * @method Phaser.Math.Matrix3#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + translate: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[6] = x * a[0] + y * a[3] + a[6]; + a[7] = x * a[1] + y * a[4] + a[7]; + a[8] = x * a[2] + y * a[5] + a[8]; + + return this; + }, + + /** + * Apply a rotation transformation to this Matrix. + * + * @method Phaser.Math.Matrix3#rotate + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + rotate: function (rad) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a10 = a[3]; + var a11 = a[4]; + var a12 = a[5]; + + var s = Math.sin(rad); + var c = Math.cos(rad); + + a[0] = c * a00 + s * a10; + a[1] = c * a01 + s * a11; + a[2] = c * a02 + s * a12; + + a[3] = c * a10 - s * a00; + a[4] = c * a11 - s * a01; + a[5] = c * a12 - s * a02; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x` and `y` components of the given Vector to scale the Matrix. + * + * @method Phaser.Math.Matrix3#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + scale: function (v) + { + var a = this.val; + var x = v.x; + var y = v.y; + + a[0] = x * a[0]; + a[1] = x * a[1]; + a[2] = x * a[2]; + + a[3] = y * a[3]; + a[4] = y * a[4]; + a[5] = y * a[5]; + + return this; + }, + + /** + * Set the values of this Matrix from the given Quaternion. + * + * @method Phaser.Math.Matrix3#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + fromQuat: function (q) + { + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + var out = this.val; + + out[0] = 1 - (yy + zz); + out[3] = xy + wz; + out[6] = xz - wy; + + out[1] = xy - wz; + out[4] = 1 - (xx + zz); + out[7] = yz + wx; + + out[2] = xz + wy; + out[5] = yz - wx; + out[8] = 1 - (xx + yy); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix3#normalFromMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} m - [description] + * + * @return {Phaser.Math.Matrix3} This Matrix3. + */ + normalFromMat4: function (m) + { + var a = m.val; + var out = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + + out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + + out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + + return this; + } + +}); + +module.exports = Matrix3; + + +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(2); +var Matrix3 = __webpack_require__(64); + +var EPSILON = 0.000001; + +// Some shared 'private' arrays +var siNext = new Int8Array([ 1, 2, 0 ]); +var tmp = new Float32Array([ 0, 0, 0 ]); + +var xUnitVec3 = new Vector3(1, 0, 0); +var yUnitVec3 = new Vector3(0, 1, 0); + +var tmpvec = new Vector3(); +var tmpMat3 = new Matrix3(); + +/** + * @classdesc + * A quaternion. + * + * @class Quaternion + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number} [x] - The x component. + * @param {number} [y] - The y component. + * @param {number} [z] - The z component. + * @param {number} [w] - The w component. + */ +var Quaternion = new Class({ + + initialize: + + function Quaternion (x, y, z, w) + { + /** + * The x component of this Quaternion. + * + * @name Phaser.Math.Quaternion#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The y component of this Quaternion. + * + * @name Phaser.Math.Quaternion#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The z component of this Quaternion. + * + * @name Phaser.Math.Quaternion#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + /** + * The w component of this Quaternion. + * + * @name Phaser.Math.Quaternion#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + }, + + /** + * Copy the components of a given Quaternion or Vector into this Quaternion. + * + * @method Phaser.Math.Quaternion#copy + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} src - The Quaternion or Vector to copy the components from. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + copy: function (src) + { + this.x = src.x; + this.y = src.y; + this.z = src.z; + this.w = src.w; + + return this; + }, + + /** + * Set the components of this Quaternion. + * + * @method Phaser.Math.Quaternion#set + * @since 3.0.0 + * + * @param {(number|object)} [x=0] - The x component, or an object containing x, y, z, and w components. + * @param {number} [y=0] - The y component. + * @param {number} [z=0] - The z component. + * @param {number} [w=0] - The w component. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + set: function (x, y, z, w) + { + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + this.z = x.z || 0; + this.w = x.w || 0; + } + else + { + this.x = x || 0; + this.y = y || 0; + this.z = z || 0; + this.w = w || 0; + } + + return this; + }, + + /** + * Add a given Quaternion or Vector to this Quaternion. Addition is component-wise. + * + * @method Phaser.Math.Quaternion#add + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to add to this Quaternion. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + add: function (v) + { + this.x += v.x; + this.y += v.y; + this.z += v.z; + this.w += v.w; + + return this; + }, + + /** + * Subtract a given Quaternion or Vector from this Quaternion. Subtraction is component-wise. + * + * @method Phaser.Math.Quaternion#subtract + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to subtract from this Quaternion. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + subtract: function (v) + { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + this.w -= v.w; + + return this; + }, + + /** + * Scale this Quaternion by the given value. + * + * @method Phaser.Math.Quaternion#scale + * @since 3.0.0 + * + * @param {number} scale - The value to scale this Quaternion by. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + scale: function (scale) + { + this.x *= scale; + this.y *= scale; + this.z *= scale; + this.w *= scale; + + return this; + }, + + /** + * Calculate the length of this Quaternion. + * + * @method Phaser.Math.Quaternion#length + * @since 3.0.0 + * + * @return {number} The length of this Quaternion. + */ + length: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return Math.sqrt(x * x + y * y + z * z + w * w); + }, + + /** + * Calculate the length of this Quaternion squared. + * + * @method Phaser.Math.Quaternion#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Quaternion, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + + return x * x + y * y + z * z + w * w; + }, + + /** + * Normalize this Quaternion. + * + * @method Phaser.Math.Quaternion#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + var w = this.w; + var len = x * x + y * y + z * z + w * w; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + this.z = z * len; + this.w = w * len; + } + + return this; + }, + + /** + * Calculate the dot product of this Quaternion and the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#dot + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to dot product with this Quaternion. + * + * @return {number} The dot product of this Quaternion and the given Quaternion or Vector. + */ + dot: function (v) + { + return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w; + }, + + /** + * Linearly interpolate this Quaternion towards the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#lerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} v - The Quaternion or Vector to interpolate towards. + * @param {number} [t=0] - The percentage of interpolation. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + lerp: function (v, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + this.x = ax + t * (v.x - ax); + this.y = ay + t * (v.y - ay); + this.z = az + t * (v.z - az); + this.w = aw + t * (v.w - aw); + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Quaternion#rotationTo + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} a - [description] + * @param {Phaser.Math.Vector3} b - [description] + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotationTo: function (a, b) + { + var dot = a.x * b.x + a.y * b.y + a.z * b.z; + + if (dot < -0.999999) + { + if (tmpvec.copy(xUnitVec3).cross(a).length() < EPSILON) + { + tmpvec.copy(yUnitVec3).cross(a); + } + + tmpvec.normalize(); + + return this.setAxisAngle(tmpvec, Math.PI); + + } + else if (dot > 0.999999) + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + } + else + { + tmpvec.copy(a).cross(b); + + this.x = tmpvec.x; + this.y = tmpvec.y; + this.z = tmpvec.z; + this.w = 1 + dot; + + return this.normalize(); + } + }, + + /** + * Set the axes of this Quaternion. + * + * @method Phaser.Math.Quaternion#setAxes + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} view - The view axis. + * @param {Phaser.Math.Vector3} right - The right axis. + * @param {Phaser.Math.Vector3} up - The upwards axis. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + setAxes: function (view, right, up) + { + var m = tmpMat3.val; + + m[0] = right.x; + m[3] = right.y; + m[6] = right.z; + + m[1] = up.x; + m[4] = up.y; + m[7] = up.z; + + m[2] = -view.x; + m[5] = -view.y; + m[8] = -view.z; + + return this.fromMat3(tmpMat3).normalize(); + }, + + /** + * Reset this Matrix to an identity (default) Quaternion. + * + * @method Phaser.Math.Quaternion#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + identity: function () + { + this.x = 0; + this.y = 0; + this.z = 0; + this.w = 1; + + return this; + }, + + /** + * Set the axis angle of this Quaternion. + * + * @method Phaser.Math.Quaternion#setAxisAngle + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} axis - The axis. + * @param {number} rad - The angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + setAxisAngle: function (axis, rad) + { + rad = rad * 0.5; + + var s = Math.sin(rad); + + this.x = s * axis.x; + this.y = s * axis.y; + this.z = s * axis.z; + this.w = Math.cos(rad); + + return this; + }, + + /** + * Multiply this Quaternion by the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#multiply + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to multiply this Quaternion by. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + multiply: function (b) + { + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + this.x = ax * bw + aw * bx + ay * bz - az * by; + this.y = ay * bw + aw * by + az * bx - ax * bz; + this.z = az * bw + aw * bz + ax * by - ay * bx; + this.w = aw * bw - ax * bx - ay * by - az * bz; + + return this; + }, + + /** + * Smoothly linearly interpolate this Quaternion towards the given Quaternion or Vector. + * + * @method Phaser.Math.Quaternion#slerp + * @since 3.0.0 + * + * @param {(Phaser.Math.Quaternion|Phaser.Math.Vector4)} b - The Quaternion or Vector to interpolate towards. + * @param {number} t - The percentage of interpolation. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + slerp: function (b, t) + { + // benchmarks: http://jsperf.com/quaternion-slerp-implementations + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = b.x; + var by = b.y; + var bz = b.z; + var bw = b.w; + + // calc cosine + var cosom = ax * bx + ay * by + az * bz + aw * bw; + + // adjust signs (if necessary) + if (cosom < 0) + { + cosom = -cosom; + bx = - bx; + by = - by; + bz = - bz; + bw = - bw; + } + + // "from" and "to" quaternions are very close + // ... so we can do a linear interpolation + var scale0 = 1 - t; + var scale1 = t; + + // calculate coefficients + if ((1 - cosom) > EPSILON) + { + // standard case (slerp) + var omega = Math.acos(cosom); + var sinom = Math.sin(omega); + + scale0 = Math.sin((1.0 - t) * omega) / sinom; + scale1 = Math.sin(t * omega) / sinom; + } + + // calculate final values + this.x = scale0 * ax + scale1 * bx; + this.y = scale0 * ay + scale1 * by; + this.z = scale0 * az + scale1 * bz; + this.w = scale0 * aw + scale1 * bw; + + return this; + }, + + /** + * Invert this Quaternion. + * + * @method Phaser.Math.Quaternion#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + invert: function () + { + var a0 = this.x; + var a1 = this.y; + var a2 = this.z; + var a3 = this.w; + + var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3; + var invDot = (dot) ? 1 / dot : 0; + + // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0 + + this.x = -a0 * invDot; + this.y = -a1 * invDot; + this.z = -a2 * invDot; + this.w = a3 * invDot; + + return this; + }, + + /** + * Convert this Quaternion into its conjugate. + * + * Sets the x, y and z components. + * + * @method Phaser.Math.Quaternion#conjugate + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + conjugate: function () + { + this.x = -this.x; + this.y = -this.y; + this.z = -this.z; + + return this; + }, + + /** + * Rotate this Quaternion on the X axis. + * + * @method Phaser.Math.Quaternion#rotateX + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateX: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bx = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + aw * bx; + this.y = ay * bw + az * bx; + this.z = az * bw - ay * bx; + this.w = aw * bw - ax * bx; + + return this; + }, + + /** + * Rotate this Quaternion on the Y axis. + * + * @method Phaser.Math.Quaternion#rotateY + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateY: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var by = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw - az * by; + this.y = ay * bw + aw * by; + this.z = az * bw + ax * by; + this.w = aw * bw - ay * by; + + return this; + }, + + /** + * Rotate this Quaternion on the Z axis. + * + * @method Phaser.Math.Quaternion#rotateZ + * @since 3.0.0 + * + * @param {number} rad - The rotation angle in radians. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + rotateZ: function (rad) + { + rad *= 0.5; + + var ax = this.x; + var ay = this.y; + var az = this.z; + var aw = this.w; + + var bz = Math.sin(rad); + var bw = Math.cos(rad); + + this.x = ax * bw + ay * bz; + this.y = ay * bw - ax * bz; + this.z = az * bw + aw * bz; + this.w = aw * bw - az * bz; + + return this; + }, + + /** + * Create a unit (or rotation) Quaternion from its x, y, and z components. + * + * Sets the w component. + * + * @method Phaser.Math.Quaternion#calculateW + * @since 3.0.0 + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + calculateW: function () + { + var x = this.x; + var y = this.y; + var z = this.z; + + this.w = -Math.sqrt(1.0 - x * x - y * y - z * z); + + return this; + }, + + /** + * Convert the given Matrix into this Quaternion. + * + * @method Phaser.Math.Quaternion#fromMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix to convert from. + * + * @return {Phaser.Math.Quaternion} This Quaternion. + */ + fromMat3: function (mat) + { + // benchmarks: + // http://jsperf.com/typed-array-access-speed + // http://jsperf.com/conversion-of-3x3-matrix-to-quaternion + + // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes + // article "Quaternion Calculus and Fast Animation". + var m = mat.val; + var fTrace = m[0] + m[4] + m[8]; + var fRoot; + + if (fTrace > 0) + { + // |w| > 1/2, may as well choose w > 1/2 + fRoot = Math.sqrt(fTrace + 1.0); // 2w + + this.w = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; // 1/(4w) + + this.x = (m[7] - m[5]) * fRoot; + this.y = (m[2] - m[6]) * fRoot; + this.z = (m[3] - m[1]) * fRoot; + } + else + { + // |w| <= 1/2 + var i = 0; + + if (m[4] > m[0]) + { + i = 1; + } + + if (m[8] > m[i * 3 + i]) + { + i = 2; + } + + var j = siNext[i]; + var k = siNext[j]; + + // This isn't quite as clean without array access + fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1); + tmp[i] = 0.5 * fRoot; + + fRoot = 0.5 / fRoot; + + tmp[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot; + tmp[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot; + + this.x = tmp[0]; + this.y = tmp[1]; + this.z = tmp[2]; + this.w = (m[k * 3 + j] - m[j * 3 + k]) * fRoot; + } + + return this; + } + +}); + +module.exports = Quaternion; + + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vector3 = __webpack_require__(2); +var Matrix4 = __webpack_require__(14); +var Quaternion = __webpack_require__(65); + +var tmpMat4 = new Matrix4(); +var tmpQuat = new Quaternion(); +var tmpVec3 = new Vector3(); + +/** + * Rotates a vector in place by axis angle. + * + * This is the same as transforming a point by an + * axis-angle quaternion, but it has higher precision. + * + * @function Phaser.Math.RotateVec3 + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec - The vector to be rotated. + * @param {Phaser.Math.Vector3} axis - The axis to rotate around. + * @param {number} radians - The angle of rotation in radians. + * + * @return {Phaser.Math.Vector3} The given vector. + */ +var RotateVec3 = function (vec, axis, radians) +{ + // Set the quaternion to our axis angle + tmpQuat.setAxisAngle(axis, radians); + + // Create a rotation matrix from the axis angle + tmpMat4.fromRotationTranslation(tmpQuat, tmpVec3.set(0, 0, 0)); + + // Multiply our vector by the rotation matrix + return vec.transformMat4(tmpMat4); +}; + +module.exports = RotateVec3; + + +/***/ }), +/* 67 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random four-dimensional vector. + * + * @function Phaser.Math.RandomXYZW + * @since 3.0.0 + * + * @param {Phaser.Math.Vector4} vec4 - The Vector to compute random values for. + * @param {number} [scale=1] - The scale of the random values. + * + * @return {Phaser.Math.Vector4} The given Vector. + */ +var RandomXYZW = function (vec4, scale) +{ + if (scale === undefined) { scale = 1; } + + // TODO: Not spherical; should fix this for more uniform distribution + vec4.x = (Math.random() * 2 - 1) * scale; + vec4.y = (Math.random() * 2 - 1) * scale; + vec4.z = (Math.random() * 2 - 1) * scale; + vec4.w = (Math.random() * 2 - 1) * scale; + + return vec4; +}; + +module.exports = RandomXYZW; + + +/***/ }), +/* 68 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Compute a random position vector in a spherical area, optionally defined by the given radius. + * + * @function Phaser.Math.RandomXYZ + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} vec3 - The Vector to compute random values for. + * @param {number} [radius=1] - The radius. + * + * @return {Phaser.Math.Vector3} The given Vector. + */ +var RandomXYZ = function (vec3, radius) +{ + if (radius === undefined) { radius = 1; } + + var r = Math.random() * 2 * Math.PI; + var z = (Math.random() * 2) - 1; + var zScale = Math.sqrt(1 - z * z) * radius; + + vec3.x = Math.cos(r) * zScale; + vec3.y = Math.sin(r) * zScale; + vec3.z = z * radius; + + return vec3; +}; + +module.exports = RandomXYZ; + + +/***/ }), +/* 69 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Camera = __webpack_require__(15); +var Class = __webpack_require__(0); +var Vector3 = __webpack_require__(2); + +// Local cache vars +var tmpVec3 = new Vector3(); + +/** + * @classdesc + * [description] + * + * @class OrthographicCamera + * @extends Phaser.Cameras.Sprite3D.Camera + * @memberOf Phaser.Cameras.Sprite3D + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + * @param {integer} [viewportWidth=0] - [description] + * @param {integer} [viewportHeight=0] - [description] + */ +var OrthographicCamera = new Class({ + + Extends: Camera, + + initialize: + + function OrthographicCamera (scene, viewportWidth, viewportHeight) + { + if (viewportWidth === undefined) { viewportWidth = 0; } + if (viewportHeight === undefined) { viewportHeight = 0; } + + Camera.call(this, scene); + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportWidth + * @type {integer} + * @since 3.0.0 + */ + this.viewportWidth = viewportWidth; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#viewportHeight + * @type {integer} + * @since 3.0.0 + */ + this.viewportHeight = viewportHeight; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom + * @type {number} + * @private + * @since 3.0.0 + */ + this._zoom = 1.0; + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#near + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.near = 0; + + this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.OrthographicCamera#setToOrtho + * @since 3.0.0 + * + * @param {number} yDown - [description] + * @param {number} [viewportWidth] - [description] + * @param {number} [viewportHeight] - [description] + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + setToOrtho: function (yDown, viewportWidth, viewportHeight) + { + if (viewportWidth === undefined) { viewportWidth = this.viewportWidth; } + if (viewportHeight === undefined) { viewportHeight = this.viewportHeight; } + + var zoom = this.zoom; + + this.up.set(0, (yDown) ? -1 : 1, 0); + this.direction.set(0, 0, (yDown) ? 1 : -1); + this.position.set(zoom * viewportWidth / 2, zoom * viewportHeight / 2, 0); + + this.viewportWidth = viewportWidth; + this.viewportHeight = viewportHeight; + + return this.update(); + }, + + /** + * [description] + * + * @method Phaser.Cameras.Sprite3D.OrthographicCamera#update + * @since 3.0.0 + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + update: function () + { + var w = this.viewportWidth; + var h = this.viewportHeight; + var near = Math.abs(this.near); + var far = Math.abs(this.far); + var zoom = this.zoom; + + if (w === 0 || h === 0) + { + // What to do here... hmm? + return this; + } + + this.projection.ortho( + zoom * -w / 2, zoom * w / 2, + zoom * -h / 2, zoom * h / 2, + near, + far + ); + + // Build the view matrix + tmpVec3.copy(this.position).add(this.direction); + + this.view.lookAt(this.position, tmpVec3, this.up); + + // Projection * view matrix + this.combined.copy(this.projection).multiply(this.view); + + // Invert combined matrix, used for unproject + this.invProjectionView.copy(this.combined).invert(); + + this.billboardMatrixDirty = true; + + this.updateChildren(); + + return this; + }, + + /** + * [description] + * + * @name Phaser.Cameras.Sprite3D.OrthographicCamera#zoom + * @type {number} + * @since 3.0.0 + */ + zoom: { + + get: function () + { + return this._zoom; + }, + + set: function (value) + { + this._zoom = value; + this.update(); + } + } + +}); + +module.exports = OrthographicCamera; + + +/***/ }), +/* 70 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetAdvancedValue = __webpack_require__(4); + +/** + * Adds an Animation component to a Sprite and populates it based on the given config. + * + * @function Phaser.GameObjects.BuildGameObjectAnimation + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Sprite} sprite - The sprite to add an Animation component to. + * @param {object} config - The animation config. + * + * @return {Phaser.GameObjects.Sprite} The updated Sprite. + */ +var BuildGameObjectAnimation = function (sprite, config) +{ + var animConfig = GetAdvancedValue(config, 'anims', null); + + if (animConfig === null) + { + return sprite; + } + + if (typeof animConfig === 'string') + { + // { anims: 'key' } + sprite.anims.play(animConfig); + } + else if (typeof animConfig === 'object') + { + // { anims: { + // key: string + // startFrame: [string|integer] + // delay: [float] + // repeat: [integer] + // repeatDelay: [float] + // yoyo: [boolean] + // play: [boolean] + // delayedPlay: [boolean] + // } + // } + + var anims = sprite.anims; + + var key = GetAdvancedValue(animConfig, 'key', undefined); + var startFrame = GetAdvancedValue(animConfig, 'startFrame', undefined); + + var delay = GetAdvancedValue(animConfig, 'delay', 0); + var repeat = GetAdvancedValue(animConfig, 'repeat', 0); + var repeatDelay = GetAdvancedValue(animConfig, 'repeatDelay', 0); + var yoyo = GetAdvancedValue(animConfig, 'yoyo', false); + + var play = GetAdvancedValue(animConfig, 'play', false); + var delayedPlay = GetAdvancedValue(animConfig, 'delayedPlay', 0); + + anims.setDelay(delay); + anims.setRepeat(repeat); + anims.setRepeatDelay(repeatDelay); + anims.setYoyo(yoyo); + + if (play) + { + anims.play(key, startFrame); + } + else if (delayedPlay > 0) + { + anims.delayedPlay(delayedPlay, key, startFrame); + } + else + { + anims.load(key); + } + } + + return sprite; +}; + +module.exports = BuildGameObjectAnimation; + + +/***/ }), +/* 71 */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Source object +// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' +// The default value to use if the key doesn't exist + +/** + * [description] + * + * @function Phaser.Utils.Objects.GetValue + * @since 3.0.0 + * + * @param {object} source - [description] + * @param {string} key - [description] + * @param {*} defaultValue - [description] + * + * @return {*} [description] + */ +var GetValue = function (source, key, defaultValue) +{ + if (!source || typeof source === 'number') + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else if (key.indexOf('.')) + { + var keys = key.split('.'); + var parent = source; + var value = defaultValue; + + // Use for loop here so we can break early + for (var i = 0; i < keys.length; i++) + { + if (parent.hasOwnProperty(keys[i])) + { + // Yes it has a key property, let's carry on down + value = parent[keys[i]]; + + parent = parent[keys[i]]; + } + else + { + // Can't go any further, so reset to default + value = defaultValue; + break; + } + } + + return value; + } + else + { + return defaultValue; + } +}; + +module.exports = GetValue; + + +/***/ }), +/* 72 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(0); + +/** + * @classdesc + * A seeded Random Data Generator. + * + * Access via `Phaser.Math.RND` which is an instance of this class pre-defined + * by Phaser. Or, create your own instance to use as you require. + * + * The `Math.RND` generator is seeded by the Game Config property value `seed`. + * If no such config property exists, a random number is used. + * + * If you create your own instance of this class you should provide a seed for it. + * If no seed is given it will use a 'random' one based on Date.now. + * + * @class RandomDataGenerator + * @memberOf Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {(string|string[])} [seeds] - The seeds to use for the random number generator. + */ +var RandomDataGenerator = new Class({ + + initialize: + + function RandomDataGenerator (seeds) + { + if (seeds === undefined) { seeds = [ (Date.now() * Math.random()).toString() ]; } + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#c + * @type {number} + * @default 1 + * @private + * @since 3.0.0 + */ + this.c = 1; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s0 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s0 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s1 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s1 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#s2 + * @type {number} + * @default 0 + * @private + * @since 3.0.0 + */ + this.s2 = 0; + + /** + * Internal var. + * + * @name Phaser.Math.RandomDataGenerator#n + * @type {number} + * @default 0 + * @private + * @since 3.2.0 + */ + this.n = 0; + + /** + * Signs to choose from. + * + * @name Phaser.Math.RandomDataGenerator#signs + * @type {number[]} + * @since 3.0.0 + */ + this.signs = [ -1, 1 ]; + + if (seeds) + { + this.init(seeds); + } + }, + + /** + * Private random helper. + * + * @method Phaser.Math.RandomDataGenerator#rnd + * @since 3.0.0 + * @private + * + * @return {number} A random number. + */ + rnd: function () + { + var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32 + + this.c = t | 0; + this.s0 = this.s1; + this.s1 = this.s2; + this.s2 = t - this.c; + + return this.s2; + }, + + /** + * Internal method that creates a seed hash. + * + * @method Phaser.Math.RandomDataGenerator#hash + * @since 3.0.0 + * @private + * + * @param {string} data - The value to hash. + * + * @return {number} The hashed value. + */ + hash: function (data) + { + var h; + var n = this.n; + + data = data.toString(); + + for (var i = 0; i < data.length; i++) + { + n += data.charCodeAt(i); + h = 0.02519603282416938 * n; + n = h >>> 0; + h -= n; + h *= n; + n = h >>> 0; + h -= n; + n += h * 0x100000000;// 2^32 + } + + this.n = n; + + return (n >>> 0) * 2.3283064365386963e-10;// 2^-32 + }, + + /** + * Initialize the state of the random data generator. + * + * @method Phaser.Math.RandomDataGenerator#init + * @since 3.0.0 + * + * @param {(string|string[])} seeds - The seeds to initialize the random data generator with. + */ + init: function (seeds) + { + if (typeof seeds === 'string') + { + this.state(seeds); + } + else + { + this.sow(seeds); + } + }, + + /** + * Reset the seed of the random data generator. + * + * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present. + * + * @method Phaser.Math.RandomDataGenerator#sow + * @since 3.0.0 + * + * @param {string[]} seeds - The array of seeds: the `toString()` of each value is used. + */ + sow: function (seeds) + { + // Always reset to default seed + this.n = 0xefc8249d; + this.s0 = this.hash(' '); + this.s1 = this.hash(' '); + this.s2 = this.hash(' '); + this.c = 1; + + if (!seeds) + { + return; + } + + // Apply any seeds + for (var i = 0; i < seeds.length && (seeds[i] != null); i++) + { + var seed = seeds[i]; + + this.s0 -= this.hash(seed); + this.s0 += ~~(this.s0 < 0); + this.s1 -= this.hash(seed); + this.s1 += ~~(this.s1 < 0); + this.s2 -= this.hash(seed); + this.s2 += ~~(this.s2 < 0); + } + }, + + /** + * Returns a random integer between 0 and 2^32. + * + * @method Phaser.Math.RandomDataGenerator#integer + * @since 3.0.0 + * + * @return {number} A random integer between 0 and 2^32. + */ + integer: function () + { + // 2^32 + return this.rnd() * 0x100000000; + }, + + /** + * Returns a random real number between 0 and 1. + * + * @method Phaser.Math.RandomDataGenerator#frac + * @since 3.0.0 + * + * @return {number} A random real number between 0 and 1. + */ + frac: function () + { + // 2^-53 + return this.rnd() + (this.rnd() * 0x200000 | 0) * 1.1102230246251565e-16; + }, + + /** + * Returns a random real number between 0 and 2^32. + * + * @method Phaser.Math.RandomDataGenerator#real + * @since 3.0.0 + * + * @return {number} A random real number between 0 and 2^32. + */ + real: function () + { + return this.integer() + this.frac(); + }, + + /** + * Returns a random integer between and including min and max. + * + * @method Phaser.Math.RandomDataGenerator#integerInRange + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + integerInRange: function (min, max) + { + return Math.floor(this.realInRange(0, max - min + 1) + min); + }, + + /** + * Returns a random integer between and including min and max. + * This method is an alias for RandomDataGenerator.integerInRange. + * + * @method Phaser.Math.RandomDataGenerator#between + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + between: function (min, max) + { + return Math.floor(this.realInRange(0, max - min + 1) + min); + }, + + /** + * Returns a random real number between min and max. + * + * @method Phaser.Math.RandomDataGenerator#realInRange + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random number between min and max. + */ + realInRange: function (min, max) + { + return this.frac() * (max - min) + min; + }, + + /** + * Returns a random real number between -1 and 1. + * + * @method Phaser.Math.RandomDataGenerator#normal + * @since 3.0.0 + * + * @return {number} A random real number between -1 and 1. + */ + normal: function () + { + return 1 - (2 * this.frac()); + }, + + /** + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 + * + * @method Phaser.Math.RandomDataGenerator#uuid + * @since 3.0.0 + * + * @return {string} A valid RFC4122 version4 ID hex string + */ + uuid: function () + { + var a = ''; + var b = ''; + + for (b = a = ''; a++ < 36; b += ~a % 5 | a * 3 & 4 ? (a ^ 15 ? 8 ^ this.frac() * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') + { + // eslint-disable-next-line no-empty + } + + return b; + }, + + /** + * Returns a random element from within the given array. + * + * @method Phaser.Math.RandomDataGenerator#pick + * @since 3.0.0 + * + * @param {array} array - The array to pick a random element from. + * + * @return {*} A random member of the array. + */ + pick: function (array) + { + return array[this.integerInRange(0, array.length - 1)]; + }, + + /** + * Returns a sign to be used with multiplication operator. + * + * @method Phaser.Math.RandomDataGenerator#sign + * @since 3.0.0 + * + * @return {number} -1 or +1. + */ + sign: function () + { + return this.pick(this.signs); + }, + + /** + * Returns a random element from within the given array, favoring the earlier entries. + * + * @method Phaser.Math.RandomDataGenerator#weightedPick + * @since 3.0.0 + * + * @param {array} array - The array to pick a random element from. + * + * @return {*} A random member of the array. + */ + weightedPick: function (array) + { + return array[~~(Math.pow(this.frac(), 2) * (array.length - 1) + 0.5)]; + }, + + /** + * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. + * + * @method Phaser.Math.RandomDataGenerator#timestamp + * @since 3.0.0 + * + * @param {number} min - The minimum value in the range. + * @param {number} max - The maximum value in the range. + * + * @return {number} A random timestamp between min and max. + */ + timestamp: function (min, max) + { + return this.realInRange(min || 946684800000, max || 1577862000000); + }, + + /** + * Returns a random angle between -180 and 180. + * + * @method Phaser.Math.RandomDataGenerator#angle + * @since 3.0.0 + * + * @return {number} A random number between -180 and 180. + */ + angle: function () + { + return this.integerInRange(-180, 180); + }, + + /** + * Returns a random rotation in radians, between -3.141 and 3.141 + * + * @method Phaser.Math.RandomDataGenerator#rotation + * @since 3.0.0 + * + * @return {number} A random number between -3.141 and 3.141 + */ + rotation: function () + { + return this.realInRange(-3.1415926, 3.1415926); + }, + + /** + * Gets or Sets the state of the generator. This allows you to retain the values + * that the generator is using between games, i.e. in a game save file. + * + * To seed this generator with a previously saved state you can pass it as the + * `seed` value in your game config, or call this method directly after Phaser has booted. + * + * Call this method with no parameters to return the current state. + * + * If providing a state it should match the same format that this method + * returns, which is a string with a header `!rnd` followed by the `c`, + * `s0`, `s1` and `s2` values respectively, each comma-delimited. + * + * @method Phaser.Math.RandomDataGenerator#state + * @since 3.0.0 + * + * @param {string} [state] - Generator state to be set. + * + * @return {string} The current state of the generator. + */ + state: function (state) + { + if (typeof state === 'string' && state.match(/^!rnd/)) + { + state = state.split(','); + + this.c = parseFloat(state[1]); + this.s0 = parseFloat(state[2]); + this.s1 = parseFloat(state[3]); + this.s2 = parseFloat(state[4]); + } + + return [ '!rnd', this.c, this.s0, this.s1, this.s2 ].join(','); + }, + + /** + * Shuffles the given array, using the current seed. + * + * @method Phaser.Math.RandomDataGenerator#shuffle + * @since 3.7.0 + * + * @param {array} [array] - The array to be shuffled. + * + * @return {array} The shuffled array. + */ + shuffle: function (array) + { + var len = array.length - 1; + + for (var i = len; i > 0; i--) + { + var randomIndex = Math.floor(this.frac() * (len + 1)); + var itemAtIndex = array[randomIndex]; + + array[randomIndex] = array[i]; + array[i] = itemAtIndex; + } + + return array; + } + +}); + +module.exports = RandomDataGenerator; + + +/***/ }), +/* 73 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(18); +var GetAdvancedValue = __webpack_require__(4); +var ScaleModes = __webpack_require__(16); + +/** + * @typedef {object} GameObjectConfig + * + * @property {number} [x=0] - The x position of the Game Object. + * @property {number} [y=0] - The y position of the Game Object. + * @property {number} [depth=0] - The depth of the GameObject. + * @property {boolean} [flipX=false] - The horizontally flipped state of the Game Object. + * @property {boolean} [flipY=false] - The vertically flipped state of the Game Object. + * @property {?(number|object)} [scale=null] - The scale of the GameObject. + * @property {?(number|object)} [scrollFactor=null] - The scroll factor of the GameObject. + * @property {number} [rotation=0] - The rotation angle of the Game Object, in radians. + * @property {?number} [angle=null] - The rotation angle of the Game Object, in degrees. + * @property {number} [alpha=1] - The alpha (opacity) of the Game Object. + * @property {?(number|object)} [origin=null] - The origin of the Game Object. + * @property {number} [scaleMode=ScaleModes.DEFAULT] - The scale mode of the GameObject. + * @property {number} [blendMode=BlendModes.DEFAULT] - The blend mode of the GameObject. + * @property {boolean} [visible=true] - The visible state of the Game Object. + * @property {boolean} [add=true] - Add the GameObject to the scene. + */ + +/** + * Builds a Game Object using the provided configuration object. + * + * @function Phaser.GameObjects.BuildGameObject + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene. + * @param {Phaser.GameObjects.GameObject} gameObject - The initial GameObject. + * @param {GameObjectConfig} config - The config to build the GameObject with. + * + * @return {Phaser.GameObjects.GameObject} The built Game Object. + */ +var BuildGameObject = function (scene, gameObject, config) +{ + // Position + + gameObject.x = GetAdvancedValue(config, 'x', 0); + gameObject.y = GetAdvancedValue(config, 'y', 0); + gameObject.depth = GetAdvancedValue(config, 'depth', 0); + + // Flip + + gameObject.flipX = GetAdvancedValue(config, 'flipX', false); + gameObject.flipY = GetAdvancedValue(config, 'flipY', false); + + // Scale + // Either: { scale: 2 } or { scale: { x: 2, y: 2 }} + + var scale = GetAdvancedValue(config, 'scale', null); + + if (typeof scale === 'number') + { + gameObject.setScale(scale); + } + else if (scale !== null) + { + gameObject.scaleX = GetAdvancedValue(scale, 'x', 1); + gameObject.scaleY = GetAdvancedValue(scale, 'y', 1); + } + + // ScrollFactor + // Either: { scrollFactor: 2 } or { scrollFactor: { x: 2, y: 2 }} + + var scrollFactor = GetAdvancedValue(config, 'scrollFactor', null); + + if (typeof scrollFactor === 'number') + { + gameObject.setScrollFactor(scrollFactor); + } + else if (scrollFactor !== null) + { + gameObject.scrollFactorX = GetAdvancedValue(scrollFactor, 'x', 1); + gameObject.scrollFactorY = GetAdvancedValue(scrollFactor, 'y', 1); + } + + // Rotation + + gameObject.rotation = GetAdvancedValue(config, 'rotation', 0); + + var angle = GetAdvancedValue(config, 'angle', null); + + if (angle !== null) + { + gameObject.angle = angle; + } + + // Alpha + + gameObject.alpha = GetAdvancedValue(config, 'alpha', 1); + + // Origin + // Either: { origin: 0.5 } or { origin: { x: 0.5, y: 0.5 }} + + var origin = GetAdvancedValue(config, 'origin', null); + + if (typeof origin === 'number') + { + gameObject.setOrigin(origin); + } + else if (origin !== null) + { + var ox = GetAdvancedValue(origin, 'x', 0.5); + var oy = GetAdvancedValue(origin, 'y', 0.5); + + gameObject.setOrigin(ox, oy); + } + + // ScaleMode + + gameObject.scaleMode = GetAdvancedValue(config, 'scaleMode', ScaleModes.DEFAULT); + + // BlendMode + + gameObject.blendMode = GetAdvancedValue(config, 'blendMode', BlendModes.NORMAL); + + // Visible + + gameObject.visible = GetAdvancedValue(config, 'visible', true); + + // Add to Scene + + var add = GetAdvancedValue(config, 'add', true); + + if (add) + { + scene.sys.displayList.add(gameObject); + } + + if (gameObject.preUpdate) + { + scene.sys.updateList.add(gameObject); + } + + return gameObject; +}; + +module.exports = BuildGameObject; + + +/***/ }), +/* 74 */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = __webpack_require__(73); +var BuildGameObjectAnimation = __webpack_require__(70); +var Class = __webpack_require__(0); +var GetAdvancedValue = __webpack_require__(4); +var OrthographicCamera = __webpack_require__(69); +var PerspectiveCamera = __webpack_require__(21); +var ScenePlugin = __webpack_require__(20); +var Sprite3D = __webpack_require__(13); + +/** + * @classdesc + * The Camera 3D Plugin adds a new Camera type to Phaser that allows for movement and rendering + * in 3D space. It displays a special type of Sprite called a Sprite3D that is a billboard sprite, + * with a z-axis allowing for perspective depth. + * + * This is an external plugin which you can include in your game by preloading it: + * + * ```javascript + * this.load.scenePlugin({ + * key: 'Camera3DPlugin', + * url: 'plugins/camera3d.min.js', + * sceneKey: 'cameras3d' + * }); + * ``` + * + * Once loaded you can create a 3D Camera using the `camera3d` property of a Scene: + * + * `var camera = this.cameras3d.add(85).setZ(500).setPixelScale(128);` + * + * See the examples for more information. + * + * @class Camera3DPlugin + * @constructor + * + * @param {Phaser.Scene} scene - The Scene to which this plugin is being installed. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var Camera3DPlugin = new Class({ + + Extends: ScenePlugin, + + initialize: + + function Camera3DPlugin (scene, pluginManager) + { + ScenePlugin.call(this, scene, pluginManager); + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * + * @name Camera3DPlugin#cameras + * @type {Phaser.Cameras.Sprite3D.Camera[]} + * @since 3.0.0 + */ + this.cameras = []; + + // Register the Sprite3D Game Object + pluginManager.registerGameObject('sprite3D', this.sprite3DFactory, this.sprite3DCreator); + }, + + /** + * Creates a new Sprite3D Game Object and adds it to the Scene. + * + * @method Phaser.GameObjects.GameObjectFactory#sprite3D + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object. + * @param {number} y - The vertical position of this Game Object. + * @param {number} z - The z position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. + */ + sprite3DFactory: function (x, y, z, key, frame) + { + var sprite = new Sprite3D(this.scene, x, y, z, key, frame); + + this.displayList.add(sprite.gameObject); + this.updateList.add(sprite.gameObject); + + return sprite; + }, + + /** + * Creates a new Sprite3D Game Object and returns it. + * + * @method Phaser.GameObjects.GameObjectCreator#sprite3D + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. + */ + sprite3DCreator: function (config, addToScene) + { + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var sprite = new Sprite3D(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, sprite, config); + + // Sprite specific config options: + + BuildGameObjectAnimation(sprite, config); + + return sprite; + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Cameras.Scene3D.CameraManager#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.systems.events.once('destroy', this.destroy, 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 Camera3DPlugin#start + * @private + * @since 3.5.0 + */ + start: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('update', this.update, this); + eventEmitter.once('shutdown', this.shutdown, this); + }, + + /** + * [description] + * + * @method Camera3DPlugin#add + * @since 3.0.0 + * + * @param {number} [fieldOfView=80] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + add: function (fieldOfView, width, height) + { + return this.addPerspectiveCamera(fieldOfView, width, height); + }, + + /** + * [description] + * + * @method Camera3DPlugin#addOrthographicCamera + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + addOrthographicCamera: function (width, height) + { + var config = this.scene.sys.game.config; + + if (width === undefined) { width = config.width; } + if (height === undefined) { height = config.height; } + + var camera = new OrthographicCamera(this.scene, width, height); + + this.cameras.push(camera); + + return camera; + }, + + /** + * [description] + * + * @method Camera3DPlugin#addPerspectiveCamera + * @since 3.0.0 + * + * @param {number} [fieldOfView=80] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + addPerspectiveCamera: function (fieldOfView, width, height) + { + var config = this.scene.sys.game.config; + + if (fieldOfView === undefined) { fieldOfView = 80; } + if (width === undefined) { width = config.width; } + if (height === undefined) { height = config.height; } + + var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height); + + this.cameras.push(camera); + + return camera; + }, + + /** + * [description] + * + * @method Camera3DPlugin#getCamera + * @since 3.0.0 + * + * @param {string} name - [description] + * + * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + */ + getCamera: function (name) + { + for (var i = 0; i < this.cameras.length; i++) + { + if (this.cameras[i].name === name) + { + return this.cameras[i]; + } + } + + return null; + }, + + /** + * [description] + * + * @method Camera3DPlugin#removeCamera + * @since 3.0.0 + * + * @param {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} camera - [description] + */ + removeCamera: function (camera) + { + var cameraIndex = this.cameras.indexOf(camera); + + if (cameraIndex !== -1) + { + this.cameras.splice(cameraIndex, 1); + } + }, + + /** + * [description] + * + * @method Camera3DPlugin#removeAll + * @since 3.0.0 + * + * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + */ + removeAll: function () + { + while (this.cameras.length > 0) + { + var camera = this.cameras.pop(); + + camera.destroy(); + } + + return this.main; + }, + + /** + * [description] + * + * @method Camera3DPlugin#update + * @since 3.0.0 + * + * @param {number} timestep - [description] + * @param {number} delta - [description] + */ + update: function (timestep, delta) + { + for (var i = 0, l = this.cameras.length; i < l; ++i) + { + this.cameras[i].update(timestep, delta); + } + }, + + /** + * 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 Camera3DPlugin#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(); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Camera3DPlugin#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.pluginManager = null; + this.game = null; + this.scene = null; + this.systems = null; + } + +}); + +module.exports = Camera3DPlugin; + + +/***/ }) +/******/ ]); \ No newline at end of file diff --git a/plugins/camera3d/dist/camera3d.min.js b/plugins/camera3d/dist/camera3d.min.js new file mode 100644 index 000000000..7162f2be1 --- /dev/null +++ b/plugins/camera3d/dist/camera3d.min.js @@ -0,0 +1 @@ +var Camera3DPlugin=function(t){var i={};function e(n){if(i[n])return i[n].exports;var s=i[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,e),s.l=!0,s.exports}return e.m=t,e.c=i,e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},e.p="",e(e.s=74)}([function(t,i){function e(t,i,e){var n=e?t[i]:Object.getOwnPropertyDescriptor(t,i);return!e&&n.value&&"object"==typeof n.value&&(n=n.value),!(!n||!function(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}(n))&&(void 0===n.enumerable&&(n.enumerable=!0),void 0===n.configurable&&(n.configurable=!0),n)}function n(t,i){var e=Object.getOwnPropertyDescriptor(t,i);return!!e&&(e.value&&"object"==typeof e.value&&(e=e.value),!1===e.configurable)}function s(t,i,s,r){for(var o in i)if(i.hasOwnProperty(o)){var a=e(i,o,s);if(!1!==a){if(n((r||t).prototype,o)){if(h.ignoreFinals)continue;throw new Error("cannot override final property '"+o+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,o,a)}else t.prototype[o]=i[o]}}function r(t,i){if(i){Array.isArray(i)||(i=[i]);for(var e=0;e0&&(n=1/Math.sqrt(n),this.x=t*n,this.y=i*n,this.z=e*n),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},cross:function(t){var i=this.x,e=this.y,n=this.z,s=t.x,r=t.y,h=t.z;return this.x=e*h-n*r,this.y=n*s-i*h,this.z=i*r-e*s,this},lerp:function(t,i){void 0===i&&(i=0);var e=this.x,n=this.y,s=this.z;return this.x=e+i*(t.x-e),this.y=n+i*(t.y-n),this.z=s+i*(t.z-s),this},transformMat3:function(t){var i=this.x,e=this.y,n=this.z,s=t.val;return this.x=i*s[0]+e*s[3]+n*s[6],this.y=i*s[1]+e*s[4]+n*s[7],this.z=i*s[2]+e*s[5]+n*s[8],this},transformMat4:function(t){var i=this.x,e=this.y,n=this.z,s=t.val;return this.x=s[0]*i+s[4]*e+s[8]*n+s[12],this.y=s[1]*i+s[5]*e+s[9]*n+s[13],this.z=s[2]*i+s[6]*e+s[10]*n+s[14],this},transformCoordinates:function(t){var i=this.x,e=this.y,n=this.z,s=t.val,r=i*s[0]+e*s[4]+n*s[8]+s[12],h=i*s[1]+e*s[5]+n*s[9]+s[13],o=i*s[2]+e*s[6]+n*s[10]+s[14],a=i*s[3]+e*s[7]+n*s[11]+s[15];return this.x=r/a,this.y=h/a,this.z=o/a,this},transformQuat:function(t){var i=this.x,e=this.y,n=this.z,s=t.x,r=t.y,h=t.z,o=t.w,a=o*i+r*n-h*e,u=o*e+h*i-s*n,c=o*n+s*e-r*i,f=-s*i-r*e-h*n;return this.x=a*o+f*-s+u*-h-c*-r,this.y=u*o+f*-r+c*-s-a*-h,this.z=c*o+f*-h+a*-r-u*-s,this},project:function(t){var i=this.x,e=this.y,n=this.z,s=t.val,r=s[0],h=s[1],o=s[2],a=s[3],u=s[4],c=s[5],f=s[6],l=s[7],p=s[8],d=s[9],y=s[10],v=s[11],x=s[12],m=s[13],g=s[14],w=1/(i*a+e*l+n*v+s[15]);return this.x=(i*r+e*u+n*p+x)*w,this.y=(i*h+e*c+n*d+m)*w,this.z=(i*o+e*f+n*y+g)*w,this},unproject:function(t,i){var e=t.x,n=t.y,s=t.z,r=t.w,h=this.x-e,o=r-this.y-1-n,a=this.z;return this.x=2*h/s-1,this.y=2*o/r-1,this.z=2*a-1,this.project(i)},reset:function(){return this.x=0,this.y=0,this.z=0,this}});t.exports=n},function(t,i,e){var n=new(e(0))({initialize:function(t,i){this.x=0,this.y=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0):(void 0===i&&(i=t),this.x=t||0,this.y=i||0)},clone:function(){return new n(this.x,this.y)},copy:function(t){return this.x=t.x||0,this.y=t.y||0,this},setFromObject:function(t){return this.x=t.x||0,this.y=t.y||0,this},set:function(t,i){return void 0===i&&(i=t),this.x=t,this.y=i,this},setTo:function(t,i){return this.set(t,i)},setToPolar:function(t,i){return null==i&&(i=1),this.x=Math.cos(t)*i,this.y=Math.sin(t)*i,this},equals:function(t){return this.x===t.x&&this.y===t.y},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},scale:function(t){return isFinite(t)?(this.x*=t,this.y*=t):(this.x=0,this.y=0),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},negate:function(){return this.x=-this.x,this.y=-this.y,this},distance:function(t){var i=t.x-this.x,e=t.y-this.y;return Math.sqrt(i*i+e*e)},distanceSq:function(t){var i=t.x-this.x,e=t.y-this.y;return i*i+e*e},length:function(){var t=this.x,i=this.y;return Math.sqrt(t*t+i*i)},lengthSq:function(){var t=this.x,i=this.y;return t*t+i*i},normalize:function(){var t=this.x,i=this.y,e=t*t+i*i;return e>0&&(e=1/Math.sqrt(e),this.x=t*e,this.y=i*e),this},normalizeRightHand:function(){var t=this.x;return this.x=-1*this.y,this.y=t,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lerp:function(t,i){void 0===i&&(i=0);var e=this.x,n=this.y;return this.x=e+i*(t.x-e),this.y=n+i*(t.y-n),this},transformMat3:function(t){var i=this.x,e=this.y,n=t.val;return this.x=n[0]*i+n[3]*e+n[6],this.y=n[1]*i+n[4]*e+n[7],this},transformMat4:function(t){var i=this.x,e=this.y,n=t.val;return this.x=n[0]*i+n[4]*e+n[12],this.y=n[1]*i+n[5]*e+n[13],this},reset:function(){return this.x=0,this.y=0,this}});n.ZERO=new n,t.exports=n},function(t,i,e){var n=e(17),s=e(71);t.exports=function(t,i,e){var r=s(t,i,null);if(null===r)return e;if(Array.isArray(r))return n.RND.pick(r);if("object"==typeof r){if(r.hasOwnProperty("randInt"))return n.RND.integerInRange(r.randInt[0],r.randInt[1]);if(r.hasOwnProperty("randFloat"))return n.RND.realInRange(r.randFloat[0],r.randFloat[1])}else if("function"==typeof r)return r(i);return r}},function(t,i,e){var n=new(e(0))({initialize:function(t,i,e,n){this.x=0,this.y=0,this.z=0,this.w=0,"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=i||0,this.z=e||0,this.w=n||0)},clone:function(){return new n(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this.w=t.w||0,this},equals:function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},set:function(t,i,e,n){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=i||0,this.z=e||0,this.w=n||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this.w+=t.w||0,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z||0,this.w-=t.w||0,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,i=this.y,e=this.z,n=this.w;return Math.sqrt(t*t+i*i+e*e+n*n)},lengthSq:function(){var t=this.x,i=this.y,e=this.z,n=this.w;return t*t+i*i+e*e+n*n},normalize:function(){var t=this.x,i=this.y,e=this.z,n=this.w,s=t*t+i*i+e*e+n*n;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=i*s,this.z=e*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,i){void 0===i&&(i=0);var e=this.x,n=this.y,s=this.z,r=this.w;return this.x=e+i*(t.x-e),this.y=n+i*(t.y-n),this.z=s+i*(t.z-s),this.w=r+i*(t.w-r),this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z||1,this.w*=t.w||1,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z||1,this.w/=t.w||1,this},distance:function(t){var i=t.x-this.x,e=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return Math.sqrt(i*i+e*e+n*n+s*s)},distanceSq:function(t){var i=t.x-this.x,e=t.y-this.y,n=t.z-this.z||0,s=t.w-this.w||0;return i*i+e*e+n*n+s*s},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},transformMat4:function(t){var i=this.x,e=this.y,n=this.z,s=this.w,r=t.val;return this.x=r[0]*i+r[4]*e+r[8]*n+r[12]*s,this.y=r[1]*i+r[5]*e+r[9]*n+r[13]*s,this.z=r[2]*i+r[6]*e+r[10]*n+r[14]*s,this.w=r[3]*i+r[7]*e+r[11]*n+r[15]*s,this},transformQuat:function(t){var i=this.x,e=this.y,n=this.z,s=t.x,r=t.y,h=t.z,o=t.w,a=o*i+r*n-h*e,u=o*e+h*i-s*n,c=o*n+s*e-r*i,f=-s*i-r*e-h*n;return this.x=a*o+f*-s+u*-h-c*-r,this.y=u*o+f*-r+c*-s-a*-h,this.z=c*o+f*-h+a*-r-u*-s,this},reset:function(){return this.x=0,this.y=0,this.z=0,this.w=0,this}});n.prototype.sub=n.prototype.subtract,n.prototype.mul=n.prototype.multiply,n.prototype.div=n.prototype.divide,n.prototype.dist=n.prototype.distance,n.prototype.distSq=n.prototype.distanceSq,n.prototype.len=n.prototype.length,n.prototype.lenSq=n.prototype.lengthSq,t.exports=n},function(t,i){t.exports=function(){}},function(t,i){t.exports=function(t,i,e){var n=e-i;return i+((t-i)%n+n)%n}},function(t,i,e){var n=new(e(0))({initialize:function(t,i,e,n,s,r){void 0===t&&(t=1),void 0===i&&(i=0),void 0===e&&(e=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===r&&(r=0),this.matrix=new Float32Array([t,i,e,n,s,r,0,0,1]),this.decomposedMatrix={translateX:0,translateY:0,scaleX:1,scaleY:1,rotation:0}},a:{get:function(){return this.matrix[0]},set:function(t){this.matrix[0]=t}},b:{get:function(){return this.matrix[1]},set:function(t){this.matrix[1]=t}},c:{get:function(){return this.matrix[2]},set:function(t){this.matrix[2]=t}},d:{get:function(){return this.matrix[3]},set:function(t){this.matrix[3]=t}},e:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},f:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},tx:{get:function(){return this.matrix[4]},set:function(t){this.matrix[4]=t}},ty:{get:function(){return this.matrix[5]},set:function(t){this.matrix[5]=t}},rotation:{get:function(){return Math.acos(this.a/this.scaleX)*(Math.atan(-this.c/this.a)<0?-1:1)}},scaleX:{get:function(){return Math.sqrt(this.a*this.a+this.c*this.c)}},scaleY:{get:function(){return Math.sqrt(this.b*this.b+this.d*this.d)}},loadIdentity:function(){var t=this.matrix;return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,this},translate:function(t,i){var e=this.matrix;return e[4]=e[0]*t+e[2]*i+e[4],e[5]=e[1]*t+e[3]*i+e[5],this},scale:function(t,i){var e=this.matrix;return e[0]*=t,e[1]*=t,e[2]*=i,e[3]*=i,this},rotate:function(t){var i=Math.sin(t),e=Math.cos(t),n=this.matrix,s=n[0],r=n[1],h=n[2],o=n[3];return n[0]=s*e+h*i,n[1]=r*e+o*i,n[2]=s*-i+h*e,n[3]=r*-i+o*e,this},multiply:function(t,i){var e=this.matrix,n=t.matrix,s=e[0],r=e[1],h=e[2],o=e[3],a=e[4],u=e[5],c=n[0],f=n[1],l=n[2],p=n[3],d=n[4],y=n[5],v=void 0===i?this:i;return v.a=c*s+f*h,v.b=c*r+f*o,v.c=l*s+p*h,v.d=l*r+p*o,v.e=d*s+y*h+a,v.f=d*r+y*o+u,v},multiplyWithOffset:function(t,i,e){var n=this.matrix,s=t.matrix,r=n[0],h=n[1],o=n[2],a=n[3],u=i*r+e*o+n[4],c=i*h+e*a+n[5],f=s[0],l=s[1],p=s[2],d=s[3],y=s[4],v=s[5];return n[0]=f*r+l*o,n[1]=f*h+l*a,n[2]=p*r+d*o,n[3]=p*h+d*a,n[4]=y*r+v*o+u,n[5]=y*h+v*a+c,this},transform:function(t,i,e,n,s,r){var h=this.matrix,o=h[0],a=h[1],u=h[2],c=h[3],f=h[4],l=h[5];return h[0]=t*o+i*u,h[1]=t*a+i*c,h[2]=e*o+n*u,h[3]=e*a+n*c,h[4]=s*o+r*u+f,h[5]=s*a+r*c+l,this},transformPoint:function(t,i,e){void 0===e&&(e={x:0,y:0});var n=this.matrix,s=n[0],r=n[1],h=n[2],o=n[3],a=n[4],u=n[5];return e.x=t*s+i*h+a,e.y=t*r+i*o+u,e},invert:function(){var t=this.matrix,i=t[0],e=t[1],n=t[2],s=t[3],r=t[4],h=t[5],o=i*s-e*n;return t[0]=s/o,t[1]=-e/o,t[2]=-n/o,t[3]=i/o,t[4]=(n*h-s*r)/o,t[5]=-(i*h-e*r)/o,this},copyFrom:function(t){var i=this.matrix;return i[0]=t.a,i[1]=t.b,i[2]=t.c,i[3]=t.d,i[4]=t.e,i[5]=t.f,this},copyFromArray:function(t){var i=this.matrix;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],this},copyToContext:function(t){var i=this.matrix;return t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),t},setToContext:function(t){var i=this.matrix;return t.setTransform(i[0],i[1],i[2],i[3],i[4],i[5]),t},copyToArray:function(t){var i=this.matrix;return void 0===t?t=[i[0],i[1],i[2],i[3],i[4],i[5]]:(t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5]),t},setTransform:function(t,i,e,n,s,r){var h=this.matrix;return h[0]=t,h[1]=i,h[2]=e,h[3]=n,h[4]=s,h[5]=r,this},decomposeMatrix:function(){var t=this.decomposedMatrix,i=this.matrix,e=i[0],n=i[1],s=i[2],r=i[3],h=e*e,o=n*n,a=s*s,u=r*r,c=Math.sqrt(h+a),f=Math.sqrt(o+u);return t.translateX=i[4],t.translateY=i[5],t.scaleX=c,t.scaleY=f,t.rotation=Math.acos(e/c)*(Math.atan(-s/e)<0?-1:1),t},applyITRS:function(t,i,e,n,s){var r=this.matrix,h=Math.sin(e),o=Math.cos(e);return r[4]=t,r[5]=i,r[0]=o*n,r[1]=h*n,r[2]=-h*s,r[3]=o*s,this},getX:function(t,i){return t*this.a+i*this.c+this.e},getY:function(t,i){return t*this.b+i*this.d+this.f},getCSSMatrix:function(){var t=this.matrix;return"matrix("+t[0]+","+t[1]+","+t[2]+","+t[3]+","+t[4]+","+t[5]+")"},destroy:function(){this.matrix=null,this.decomposedMatrix=null}});t.exports=n},function(t,i){t.exports=function(t){return 2*(t.width+t.height)}},function(t,i,e){var n=e(9),s=e(1);t.exports=function(t,i,e){if(void 0===e&&(e=new s),i<=0||i>=1)return e.x=t.x,e.y=t.y,e;var r=n(t)*i;return i>.5?(r-=t.width+t.height)<=t.width?(e.x=t.right-r,e.y=t.bottom):(e.x=t.x,e.y=t.bottom-(r-t.width)):r<=t.width?(e.x=t.x+r,e.y=t.y):(e.x=t.right,e.y=t.y+(r-t.width)),e}},function(t,i,e){t.exports={Alpha:e(62),Animation:e(60),BlendMode:e(59),ComputedSize:e(58),Crop:e(57),Depth:e(56),Flip:e(55),GetBounds:e(54),Mask:e(43),Origin:e(40),Pipeline:e(39),ScaleMode:e(38),ScrollFactor:e(37),Size:e(36),Texture:e(35),TextureCrop:e(34),Tint:e(33),ToJSON:e(32),Transform:e(31),TransformMatrix:e(8),Visible:e(28)}},function(t,i,e){var n=e(0),s=e(11),r=e(27),h=e(26),o=new n({Extends:h,initialize:function(t,i){h.call(this),this.scene=t,this.type=i,this.parentContainer=null,this.name="",this.active=!0,this.tabIndex=-1,this.data=null,this.renderFlags=15,this.cameraFilter=0,this.input=null,this.body=null,this.ignoreDestroy=!1,t.sys.queueDepthSort(),t.sys.events.once("shutdown",this.destroy,this)},setActive:function(t){return this.active=t,this},setName:function(t){return this.name=t,this},setDataEnabled:function(){return this.data||(this.data=new r(this)),this},setData:function(t,i){return this.data||(this.data=new r(this)),this.data.set(t,i),this},getData:function(t){return this.data||(this.data=new r(this)),this.data.get(t)},setInteractive:function(t,i,e){return this.scene.sys.input.enable(this,t,i,e),this},disableInteractive:function(){return this.input&&(this.input.enabled=!1),this},removeInteractive:function(){return this.scene.sys.input.clear(this),this.input=void 0,this},update:function(){},toJSON:function(){return s.ToJSON(this)},willRender:function(t){return!(o.RENDER_MASK!==this.renderFlags||this.cameraFilter>0&&this.cameraFilter&t.id)},getIndexList:function(){for(var t=this,i=this.parentContainer,e=[];i&&(e.unshift(i.getIndex(t)),t=i,i.parentContainer);)i=i.parentContainer;return e.unshift(this.scene.sys.displayList.getIndex(t)),e},destroy:function(){if(this.scene&&!this.ignoreDestroy){this.preDestroy&&this.preDestroy.call(this),this.emit("destroy",this);var t=this.scene.sys;t.displayList.remove(this),t.updateList.remove(this),this.input&&(t.input.clear(this),this.input=void 0),this.data&&(this.data.destroy(),this.data=void 0),this.body&&(this.body.destroy(),this.body=void 0),t.queueDepthSort(),this.active=!1,this.visible=!1,this.scene=void 0,this.parentContainer=void 0,this.removeAllListeners()}}});o.RENDER_MASK=15,t.exports=o},function(t,i,e){var n=e(0),s=e(12),r=e(25),h=e(3),o=e(5),a=new n({Extends:s,initialize:function(t,i,e,n,a,u){s.call(this,t,"Sprite3D"),this.gameObject=new r(t,0,0,a,u),this.position=new o(i,e,n),this.size=new h(this.gameObject.width,this.gameObject.height),this.scale=new h(1,1),this.adjustScaleX=!0,this.adjustScaleY=!0,this._visible=!0},project:function(t){var i=this.position,e=this.gameObject;t.project(i,e),t.getPointSize(i,this.size,this.scale),this.scale.x<=0||this.scale.y<=0?e.setVisible(!1):(e.visible||e.setVisible(!0),this.adjustScaleX&&(e.scaleX=this.scale.x),this.adjustScaleY&&(e.scaleY=this.scale.y),e.setDepth(-1*e.z))},setVisible:function(t){return this.visible=t,this},visible:{get:function(){return this._visible},set:function(t){this._visible=t,this.gameObject.visible=t}},x:{get:function(){return this.position.x},set:function(t){this.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.position.y=t}},z:{get:function(){return this.position.z},set:function(t){this.position.z=t}}});t.exports=a},function(t,i,e){var n=new(e(0))({initialize:function(t){this.val=new Float32Array(16),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var i=this.val,e=t.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],this},fromArray:function(t){var i=this.val;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],i[9]=t[9],i[10]=t[10],i[11]=t[11],i[12]=t[12],i[13]=t[13],i[14]=t[14],i[15]=t[15],this},zero:function(){var t=this.val;return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=0,this},xyz:function(t,i,e){this.identity();var n=this.val;return n[12]=t,n[13]=i,n[14]=e,this},scaling:function(t,i,e){this.zero();var n=this.val;return n[0]=t,n[5]=i,n[10]=e,n[15]=1,this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},transpose:function(){var t=this.val,i=t[1],e=t[2],n=t[3],s=t[6],r=t[7],h=t[11];return t[1]=t[4],t[2]=t[8],t[3]=t[12],t[4]=i,t[6]=t[9],t[7]=t[13],t[8]=e,t[9]=s,t[11]=t[14],t[12]=n,t[13]=r,t[14]=h,this},invert:function(){var t=this.val,i=t[0],e=t[1],n=t[2],s=t[3],r=t[4],h=t[5],o=t[6],a=t[7],u=t[8],c=t[9],f=t[10],l=t[11],p=t[12],d=t[13],y=t[14],v=t[15],x=i*h-e*r,m=i*o-n*r,g=i*a-s*r,w=e*o-n*h,z=e*a-s*h,M=n*a-s*o,_=u*d-c*p,b=u*y-f*p,T=u*v-l*p,A=c*y-f*d,F=c*v-l*d,P=f*v-l*y,O=x*P-m*F+g*A+w*T-z*b+M*_;return O?(O=1/O,t[0]=(h*P-o*F+a*A)*O,t[1]=(n*F-e*P-s*A)*O,t[2]=(d*M-y*z+v*w)*O,t[3]=(f*z-c*M-l*w)*O,t[4]=(o*T-r*P-a*b)*O,t[5]=(i*P-n*T+s*b)*O,t[6]=(y*g-p*M-v*m)*O,t[7]=(u*M-f*g+l*m)*O,t[8]=(r*F-h*T+a*_)*O,t[9]=(e*T-i*F-s*_)*O,t[10]=(p*z-d*g+v*x)*O,t[11]=(c*g-u*z-l*x)*O,t[12]=(h*b-r*A-o*_)*O,t[13]=(i*A-e*b+n*_)*O,t[14]=(d*m-p*w-y*x)*O,t[15]=(u*w-c*m+f*x)*O,this):null},adjoint:function(){var t=this.val,i=t[0],e=t[1],n=t[2],s=t[3],r=t[4],h=t[5],o=t[6],a=t[7],u=t[8],c=t[9],f=t[10],l=t[11],p=t[12],d=t[13],y=t[14],v=t[15];return t[0]=h*(f*v-l*y)-c*(o*v-a*y)+d*(o*l-a*f),t[1]=-(e*(f*v-l*y)-c*(n*v-s*y)+d*(n*l-s*f)),t[2]=e*(o*v-a*y)-h*(n*v-s*y)+d*(n*a-s*o),t[3]=-(e*(o*l-a*f)-h*(n*l-s*f)+c*(n*a-s*o)),t[4]=-(r*(f*v-l*y)-u*(o*v-a*y)+p*(o*l-a*f)),t[5]=i*(f*v-l*y)-u*(n*v-s*y)+p*(n*l-s*f),t[6]=-(i*(o*v-a*y)-r*(n*v-s*y)+p*(n*a-s*o)),t[7]=i*(o*l-a*f)-r*(n*l-s*f)+u*(n*a-s*o),t[8]=r*(c*v-l*d)-u*(h*v-a*d)+p*(h*l-a*c),t[9]=-(i*(c*v-l*d)-u*(e*v-s*d)+p*(e*l-s*c)),t[10]=i*(h*v-a*d)-r*(e*v-s*d)+p*(e*a-s*h),t[11]=-(i*(h*l-a*c)-r*(e*l-s*c)+u*(e*a-s*h)),t[12]=-(r*(c*y-f*d)-u*(h*y-o*d)+p*(h*f-o*c)),t[13]=i*(c*y-f*d)-u*(e*y-n*d)+p*(e*f-n*c),t[14]=-(i*(h*y-o*d)-r*(e*y-n*d)+p*(e*o-n*h)),t[15]=i*(h*f-o*c)-r*(e*f-n*c)+u*(e*o-n*h),this},determinant:function(){var t=this.val,i=t[0],e=t[1],n=t[2],s=t[3],r=t[4],h=t[5],o=t[6],a=t[7],u=t[8],c=t[9],f=t[10],l=t[11],p=t[12],d=t[13],y=t[14],v=t[15];return(i*h-e*r)*(f*v-l*y)-(i*o-n*r)*(c*v-l*d)+(i*a-s*r)*(c*y-f*d)+(e*o-n*h)*(u*v-l*p)-(e*a-s*h)*(u*y-f*p)+(n*a-s*o)*(u*d-c*p)},multiply:function(t){var i=this.val,e=i[0],n=i[1],s=i[2],r=i[3],h=i[4],o=i[5],a=i[6],u=i[7],c=i[8],f=i[9],l=i[10],p=i[11],d=i[12],y=i[13],v=i[14],x=i[15],m=t.val,g=m[0],w=m[1],z=m[2],M=m[3];return i[0]=g*e+w*h+z*c+M*d,i[1]=g*n+w*o+z*f+M*y,i[2]=g*s+w*a+z*l+M*v,i[3]=g*r+w*u+z*p+M*x,g=m[4],w=m[5],z=m[6],M=m[7],i[4]=g*e+w*h+z*c+M*d,i[5]=g*n+w*o+z*f+M*y,i[6]=g*s+w*a+z*l+M*v,i[7]=g*r+w*u+z*p+M*x,g=m[8],w=m[9],z=m[10],M=m[11],i[8]=g*e+w*h+z*c+M*d,i[9]=g*n+w*o+z*f+M*y,i[10]=g*s+w*a+z*l+M*v,i[11]=g*r+w*u+z*p+M*x,g=m[12],w=m[13],z=m[14],M=m[15],i[12]=g*e+w*h+z*c+M*d,i[13]=g*n+w*o+z*f+M*y,i[14]=g*s+w*a+z*l+M*v,i[15]=g*r+w*u+z*p+M*x,this},multiplyLocal:function(t){var i=[],e=this.val,n=t.val;return i[0]=e[0]*n[0]+e[1]*n[4]+e[2]*n[8]+e[3]*n[12],i[1]=e[0]*n[1]+e[1]*n[5]+e[2]*n[9]+e[3]*n[13],i[2]=e[0]*n[2]+e[1]*n[6]+e[2]*n[10]+e[3]*n[14],i[3]=e[0]*n[3]+e[1]*n[7]+e[2]*n[11]+e[3]*n[15],i[4]=e[4]*n[0]+e[5]*n[4]+e[6]*n[8]+e[7]*n[12],i[5]=e[4]*n[1]+e[5]*n[5]+e[6]*n[9]+e[7]*n[13],i[6]=e[4]*n[2]+e[5]*n[6]+e[6]*n[10]+e[7]*n[14],i[7]=e[4]*n[3]+e[5]*n[7]+e[6]*n[11]+e[7]*n[15],i[8]=e[8]*n[0]+e[9]*n[4]+e[10]*n[8]+e[11]*n[12],i[9]=e[8]*n[1]+e[9]*n[5]+e[10]*n[9]+e[11]*n[13],i[10]=e[8]*n[2]+e[9]*n[6]+e[10]*n[10]+e[11]*n[14],i[11]=e[8]*n[3]+e[9]*n[7]+e[10]*n[11]+e[11]*n[15],i[12]=e[12]*n[0]+e[13]*n[4]+e[14]*n[8]+e[15]*n[12],i[13]=e[12]*n[1]+e[13]*n[5]+e[14]*n[9]+e[15]*n[13],i[14]=e[12]*n[2]+e[13]*n[6]+e[14]*n[10]+e[15]*n[14],i[15]=e[12]*n[3]+e[13]*n[7]+e[14]*n[11]+e[15]*n[15],this.fromArray(i)},translate:function(t){var i=t.x,e=t.y,n=t.z,s=this.val;return s[12]=s[0]*i+s[4]*e+s[8]*n+s[12],s[13]=s[1]*i+s[5]*e+s[9]*n+s[13],s[14]=s[2]*i+s[6]*e+s[10]*n+s[14],s[15]=s[3]*i+s[7]*e+s[11]*n+s[15],this},scale:function(t){var i=t.x,e=t.y,n=t.z,s=this.val;return s[0]=s[0]*i,s[1]=s[1]*i,s[2]=s[2]*i,s[3]=s[3]*i,s[4]=s[4]*e,s[5]=s[5]*e,s[6]=s[6]*e,s[7]=s[7]*e,s[8]=s[8]*n,s[9]=s[9]*n,s[10]=s[10]*n,s[11]=s[11]*n,this},makeRotationAxis:function(t,i){var e=Math.cos(i),n=Math.sin(i),s=1-e,r=t.x,h=t.y,o=t.z,a=s*r,u=s*h;return this.fromArray([a*r+e,a*h-n*o,a*o+n*h,0,a*h+n*o,u*h+e,u*o-n*r,0,a*o-n*h,u*o+n*r,s*o*o+e,0,0,0,0,1]),this},rotate:function(t,i){var e=this.val,n=i.x,s=i.y,r=i.z,h=Math.sqrt(n*n+s*s+r*r);if(Math.abs(h)<1e-6)return null;n*=h=1/h,s*=h,r*=h;var o=Math.sin(t),a=Math.cos(t),u=1-a,c=e[0],f=e[1],l=e[2],p=e[3],d=e[4],y=e[5],v=e[6],x=e[7],m=e[8],g=e[9],w=e[10],z=e[11],M=n*n*u+a,_=s*n*u+r*o,b=r*n*u-s*o,T=n*s*u-r*o,A=s*s*u+a,F=r*s*u+n*o,P=n*r*u+s*o,O=s*r*u-n*o,R=r*r*u+a;return e[0]=c*M+d*_+m*b,e[1]=f*M+y*_+g*b,e[2]=l*M+v*_+w*b,e[3]=p*M+x*_+z*b,e[4]=c*T+d*A+m*F,e[5]=f*T+y*A+g*F,e[6]=l*T+v*A+w*F,e[7]=p*T+x*A+z*F,e[8]=c*P+d*O+m*R,e[9]=f*P+y*O+g*R,e[10]=l*P+v*O+w*R,e[11]=p*P+x*O+z*R,this},rotateX:function(t){var i=this.val,e=Math.sin(t),n=Math.cos(t),s=i[4],r=i[5],h=i[6],o=i[7],a=i[8],u=i[9],c=i[10],f=i[11];return i[4]=s*n+a*e,i[5]=r*n+u*e,i[6]=h*n+c*e,i[7]=o*n+f*e,i[8]=a*n-s*e,i[9]=u*n-r*e,i[10]=c*n-h*e,i[11]=f*n-o*e,this},rotateY:function(t){var i=this.val,e=Math.sin(t),n=Math.cos(t),s=i[0],r=i[1],h=i[2],o=i[3],a=i[8],u=i[9],c=i[10],f=i[11];return i[0]=s*n-a*e,i[1]=r*n-u*e,i[2]=h*n-c*e,i[3]=o*n-f*e,i[8]=s*e+a*n,i[9]=r*e+u*n,i[10]=h*e+c*n,i[11]=o*e+f*n,this},rotateZ:function(t){var i=this.val,e=Math.sin(t),n=Math.cos(t),s=i[0],r=i[1],h=i[2],o=i[3],a=i[4],u=i[5],c=i[6],f=i[7];return i[0]=s*n+a*e,i[1]=r*n+u*e,i[2]=h*n+c*e,i[3]=o*n+f*e,i[4]=a*n-s*e,i[5]=u*n-r*e,i[6]=c*n-h*e,i[7]=f*n-o*e,this},fromRotationTranslation:function(t,i){var e=this.val,n=t.x,s=t.y,r=t.z,h=t.w,o=n+n,a=s+s,u=r+r,c=n*o,f=n*a,l=n*u,p=s*a,d=s*u,y=r*u,v=h*o,x=h*a,m=h*u;return e[0]=1-(p+y),e[1]=f+m,e[2]=l-x,e[3]=0,e[4]=f-m,e[5]=1-(c+y),e[6]=d+v,e[7]=0,e[8]=l+x,e[9]=d-v,e[10]=1-(c+p),e[11]=0,e[12]=i.x,e[13]=i.y,e[14]=i.z,e[15]=1,this},fromQuat:function(t){var i=this.val,e=t.x,n=t.y,s=t.z,r=t.w,h=e+e,o=n+n,a=s+s,u=e*h,c=e*o,f=e*a,l=n*o,p=n*a,d=s*a,y=r*h,v=r*o,x=r*a;return i[0]=1-(l+d),i[1]=c+x,i[2]=f-v,i[3]=0,i[4]=c-x,i[5]=1-(u+d),i[6]=p+y,i[7]=0,i[8]=f+v,i[9]=p-y,i[10]=1-(u+l),i[11]=0,i[12]=0,i[13]=0,i[14]=0,i[15]=1,this},frustum:function(t,i,e,n,s,r){var h=this.val,o=1/(i-t),a=1/(n-e),u=1/(s-r);return h[0]=2*s*o,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=2*s*a,h[6]=0,h[7]=0,h[8]=(i+t)*o,h[9]=(n+e)*a,h[10]=(r+s)*u,h[11]=-1,h[12]=0,h[13]=0,h[14]=r*s*2*u,h[15]=0,this},perspective:function(t,i,e,n){var s=this.val,r=1/Math.tan(t/2),h=1/(e-n);return s[0]=r/i,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=r,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=(n+e)*h,s[11]=-1,s[12]=0,s[13]=0,s[14]=2*n*e*h,s[15]=0,this},perspectiveLH:function(t,i,e,n){var s=this.val;return s[0]=2*e/t,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=2*e/i,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=-n/(e-n),s[11]=1,s[12]=0,s[13]=0,s[14]=e*n/(e-n),s[15]=0,this},ortho:function(t,i,e,n,s,r){var h=this.val,o=t-i,a=e-n,u=s-r;return o=0===o?o:1/o,a=0===a?a:1/a,u=0===u?u:1/u,h[0]=-2*o,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=-2*a,h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[10]=2*u,h[11]=0,h[12]=(t+i)*o,h[13]=(n+e)*a,h[14]=(r+s)*u,h[15]=1,this},lookAt:function(t,i,e){var n=this.val,s=t.x,r=t.y,h=t.z,o=e.x,a=e.y,u=e.z,c=i.x,f=i.y,l=i.z;if(Math.abs(s-c)<1e-6&&Math.abs(r-f)<1e-6&&Math.abs(h-l)<1e-6)return this.identity();var p=s-c,d=r-f,y=h-l,v=1/Math.sqrt(p*p+d*d+y*y),x=a*(y*=v)-u*(d*=v),m=u*(p*=v)-o*y,g=o*d-a*p;(v=Math.sqrt(x*x+m*m+g*g))?(x*=v=1/v,m*=v,g*=v):(x=0,m=0,g=0);var w=d*g-y*m,z=y*x-p*g,M=p*m-d*x;return(v=Math.sqrt(w*w+z*z+M*M))?(w*=v=1/v,z*=v,M*=v):(w=0,z=0,M=0),n[0]=x,n[1]=w,n[2]=p,n[3]=0,n[4]=m,n[5]=z,n[6]=d,n[7]=0,n[8]=g,n[9]=M,n[10]=y,n[11]=0,n[12]=-(x*s+m*r+g*h),n[13]=-(w*s+z*r+M*h),n[14]=-(p*s+d*r+y*h),n[15]=1,this},yawPitchRoll:function(t,i,e){this.zero(),s.zero(),r.zero();var n=this.val,h=s.val,o=r.val,a=Math.sin(e),u=Math.cos(e);return n[10]=1,n[15]=1,n[0]=u,n[1]=a,n[4]=-a,n[5]=u,a=Math.sin(i),u=Math.cos(i),h[0]=1,h[15]=1,h[5]=u,h[10]=u,h[9]=-a,h[6]=a,a=Math.sin(t),u=Math.cos(t),o[5]=1,o[15]=1,o[0]=u,o[2]=-a,o[8]=a,o[10]=u,this.multiplyLocal(s),this.multiplyLocal(r),this},setWorldMatrix:function(t,i,e,n,h){return this.yawPitchRoll(t.y,t.x,t.z),s.scaling(e.x,e.y,e.z),r.xyz(i.x,i.y,i.z),this.multiplyLocal(s),this.multiplyLocal(r),void 0!==n&&this.multiplyLocal(n),void 0!==h&&this.multiplyLocal(h),this}}),s=new n,r=new n;t.exports=n},function(t,i,e){var n=e(0),s=e(14),r=e(68),h=e(67),o=e(66),a=e(63),u=e(13),c=e(3),f=e(2),l=e(5),p=new f,d=new l,y=new f,v=new f,x=new s,m=new n({initialize:function(t){this.scene=t,this.displayList=t.sys.displayList,this.updateList=t.sys.updateList,this.name="",this.direction=new f(0,0,-1),this.up=new f(0,1,0),this.position=new f,this.pixelScale=128,this.projection=new s,this.view=new s,this.combined=new s,this.invProjectionView=new s,this.near=1,this.far=100,this.ray={origin:new f,direction:new f},this.viewportWidth=0,this.viewportHeight=0,this.billboardMatrixDirty=!0,this.children=new a},setPosition:function(t,i,e){return this.position.set(t,i,e),this.update()},setScene:function(t){return this.scene=t,this},setPixelScale:function(t){return this.pixelScale=t,this.update()},add:function(t){return this.children.set(t),this.displayList.add(t.gameObject),this.updateList.add(t.gameObject),this.updateChildren(),t},remove:function(t){return this.displayList.remove(t.gameObject),this.updateList.remove(t.gameObject),this.children.delete(t),this},clear:function(){for(var t=this.getChildren(),i=0;i>16)+(65280&t)+((255&t)<<16)},n={_tintTL:16777215,_tintTR:16777215,_tintBL:16777215,_tintBR:16777215,_isTinted:!1,tintFill:!1,clearTint:function(){return this.setTint(16777215),this._isTinted=!1,this},setTint:function(t,i,n,s){return void 0===t&&(t=16777215),void 0===i&&(i=t,n=t,s=t),this._tintTL=e(t),this._tintTR=e(i),this._tintBL=e(n),this._tintBR=e(s),this._isTinted=!0,this.tintFill=!1,this},setTintFill:function(t,i,e,n){return this.setTint(t,i,e,n),this.tintFill=!0,this},tintTopLeft:{get:function(){return this._tintTL},set:function(t){this._tintTL=e(t),this._isTinted=!0}},tintTopRight:{get:function(){return this._tintTR},set:function(t){this._tintTR=e(t),this._isTinted=!0}},tintBottomLeft:{get:function(){return this._tintBL},set:function(t){this._tintBL=e(t),this._isTinted=!0}},tintBottomRight:{get:function(){return this._tintBR},set:function(t){this._tintBR=e(t),this._isTinted=!0}},tint:{set:function(t){this.setTint(t,t,t,t)}},isTinted:{get:function(){return this._isTinted}}};t.exports=n},function(t,i){var e={texture:null,frame:null,isCropped:!1,setCrop:function(t,i,e,n){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,i,e,n,this.flipX,this.flipY);else{var s=t;this.frame.setCropUVs(this._crop,s.x,s.y,s.width,s.height,this.flipX,this.flipY)}this.isCropped=!0}return this},setTexture:function(t,i){return this.texture=this.scene.sys.textures.get(t),this.setFrame(i)},setFrame:function(t,i,e){return void 0===i&&(i=!0),void 0===e&&(e=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&i&&this.setSizeToFrame(),this._originComponent&&e&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this.isCropped&&this.frame.updateCropUVs(this._crop,this.flipX,this.flipY),this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=e},function(t,i){var e={texture:null,frame:null,isCropped:!1,setTexture:function(t,i){return this.texture=this.scene.sys.textures.get(t),this.setFrame(i)},setFrame:function(t,i,e){return void 0===i&&(i=!0),void 0===e&&(e=!0),this.frame=this.texture.get(t),this.frame.cutWidth&&this.frame.cutHeight?this.renderFlags|=8:this.renderFlags&=-9,this._sizeComponent&&i&&this.setSizeToFrame(),this._originComponent&&e&&(this.frame.customPivot?this.setOrigin(this.frame.pivotX,this.frame.pivotY):this.updateDisplayOrigin()),this}};t.exports=e},function(t,i){var e={_sizeComponent:!0,width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.frame.realWidth},set:function(t){this.scaleX=t/this.frame.realWidth}},displayHeight:{get:function(){return this.scaleY*this.frame.realHeight},set:function(t){this.scaleY=t/this.frame.realHeight}},setSizeToFrame:function(t){return void 0===t&&(t=this.frame),this.width=t.realWidth,this.height=t.realHeight,this},setSize:function(t,i){return this.width=t,this.height=i,this},setDisplaySize:function(t,i){return this.displayWidth=t,this.displayHeight=i,this}};t.exports=e},function(t,i){var e={scrollFactorX:1,scrollFactorY:1,setScrollFactor:function(t,i){return void 0===i&&(i=t),this.scrollFactorX=t,this.scrollFactorY=i,this}};t.exports=e},function(t,i,e){var n=e(16),s={_scaleMode:n.DEFAULT,scaleMode:{get:function(){return this._scaleMode},set:function(t){t!==n.LINEAR&&t!==n.NEAREST||(this._scaleMode=t)}},setScaleMode:function(t){return this.scaleMode=t,this}};t.exports=s},function(t,i){t.exports={defaultPipeline:null,pipeline:null,initPipeline:function(t){var i=this.scene.sys.game.renderer;return!!(i&&i.gl&&i.hasPipeline(t))&&(this.defaultPipeline=i.getPipeline(t),this.pipeline=this.defaultPipeline,!0)},setPipeline:function(t){var i=this.scene.sys.game.renderer;return i&&i.gl&&i.hasPipeline(t)&&(this.pipeline=i.getPipeline(t)),this},resetPipeline:function(){return this.pipeline=this.defaultPipeline,null!==this.pipeline},getPipelineName:function(){return this.pipeline.name}}},function(t,i){var e={_originComponent:!0,originX:.5,originY:.5,_displayOriginX:0,_displayOriginY:0,displayOriginX:{get:function(){return this._displayOriginX},set:function(t){this._displayOriginX=t,this.originX=t/this.width}},displayOriginY:{get:function(){return this._displayOriginY},set:function(t){this._displayOriginY=t,this.originY=t/this.height}},setOrigin:function(t,i){return void 0===t&&(t=.5),void 0===i&&(i=t),this.originX=t,this.originY=i,this.updateDisplayOrigin()},setOriginFromFrame:function(){return this.frame&&this.frame.customPivot?(this.originX=this.frame.pivotX,this.originY=this.frame.pivotY,this.updateDisplayOrigin()):this.setOrigin()},setDisplayOrigin:function(t,i){return void 0===t&&(t=0),void 0===i&&(i=t),this.displayOriginX=t,this.displayOriginY=i,this},updateDisplayOrigin:function(){return this._displayOriginX=Math.round(this.originX*this.width),this._displayOriginY=Math.round(this.originY*this.height),this}};t.exports=e},function(t,i,e){var n=new(e(0))({initialize:function(t,i){this.geometryMask=i},setShape:function(t){this.geometryMask=t},preRenderWebGL:function(t,i,e){var n=t.gl,s=this.geometryMask;t.flush(),n.enable(n.STENCIL_TEST),n.clear(n.STENCIL_BUFFER_BIT),n.colorMask(!1,!1,!1,!1),n.stencilFunc(n.NOTEQUAL,1,1),n.stencilOp(n.REPLACE,n.REPLACE,n.REPLACE),s.renderWebGL(t,s,0,e),t.flush(),n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.EQUAL,1,1),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)},postRenderWebGL:function(t){var i=t.gl;t.flush(),i.disable(i.STENCIL_TEST)},preRenderCanvas:function(t,i,e){var n=this.geometryMask;t.currentContext.save(),n.renderCanvas(t,n,0,e,null,null,!0),t.currentContext.clip()},postRenderCanvas:function(t){t.currentContext.restore()},destroy:function(){this.geometryMask=null}});t.exports=n},function(t,i,e){var n=new(e(0))({initialize:function(t,i){var e=t.sys.game.renderer;if(this.renderer=e,this.bitmapMask=i,this.maskTexture=null,this.mainTexture=null,this.dirty=!0,this.mainFramebuffer=null,this.maskFramebuffer=null,this.invertAlpha=!1,e&&e.gl){var n=e.width,s=e.height,r=0==(n&n-1)&&0==(s&s-1),h=e.gl,o=r?h.REPEAT:h.CLAMP_TO_EDGE,a=h.LINEAR;this.mainTexture=e.createTexture2D(0,a,a,o,o,h.RGBA,null,n,s),this.maskTexture=e.createTexture2D(0,a,a,o,o,h.RGBA,null,n,s),this.mainFramebuffer=e.createFramebuffer(n,s,this.mainTexture,!1),this.maskFramebuffer=e.createFramebuffer(n,s,this.maskTexture,!1),e.onContextRestored(function(t){var i=t.width,e=t.height,n=0==(i&i-1)&&0==(e&e-1),s=t.gl,r=n?s.REPEAT:s.CLAMP_TO_EDGE,h=s.LINEAR;this.mainTexture=t.createTexture2D(0,h,h,r,r,s.RGBA,null,i,e),this.maskTexture=t.createTexture2D(0,h,h,r,r,s.RGBA,null,i,e),this.mainFramebuffer=t.createFramebuffer(i,e,this.mainTexture,!1),this.maskFramebuffer=t.createFramebuffer(i,e,this.maskTexture,!1)},this)}},setBitmap:function(t){this.bitmapMask=t},preRenderWebGL:function(t,i,e){t.pipelines.BitmapMaskPipeline.beginMask(this,i,e)},postRenderWebGL:function(t){t.pipelines.BitmapMaskPipeline.endMask(this)},preRenderCanvas:function(){},postRenderCanvas:function(){},destroy:function(){this.bitmapMask=null;var t=this.renderer;t&&t.gl&&(t.deleteTexture(this.mainTexture),t.deleteTexture(this.maskTexture),t.deleteFramebuffer(this.mainFramebuffer),t.deleteFramebuffer(this.maskFramebuffer)),this.mainTexture=null,this.maskTexture=null,this.mainFramebuffer=null,this.maskFramebuffer=null,this.renderer=null}});t.exports=n},function(t,i,e){var n=e(42),s=e(41),r={mask:null,setMask:function(t){return this.mask=t,this},clearMask:function(t){return void 0===t&&(t=!1),t&&this.mask&&this.mask.destroy(),this.mask=null,this},createBitmapMask:function(t){return void 0===t&&this.texture&&(t=this),new n(this.scene,t)},createGeometryMask:function(t){return void 0===t&&"Graphics"===this.type&&(t=this),new s(this.scene,t)}};t.exports=r},function(t,i){t.exports=function(t,i,e,n){var s=Math.cos(n),r=Math.sin(n),h=t.x-i,o=t.y-e;return t.x=h*s-o*r+i,t.y=h*r+o*s+e,t}},function(t,i,e){var n=e(1);t.exports=function(t,i){return void 0===i&&(i=new n),i.x=t.x+Math.random()*t.width,i.y=t.y+Math.random()*t.height,i}},function(t,i,e){var n=e(1);t.exports=function(t,i){void 0===i&&(i=new n);var e=Math.random();return i.x=t.x1+e*(t.x2-t.x1),i.y=t.y1+e*(t.y2-t.y1),i}},function(t,i){t.exports=function(t){return Math.sqrt((t.x2-t.x1)*(t.x2-t.x1)+(t.y2-t.y1)*(t.y2-t.y1))}},function(t,i,e){var n=e(47),s=e(1);t.exports=function(t,i,e,r){void 0===r&&(r=[]),i||(i=n(t)/e);for(var h=t.x1,o=t.y1,a=t.x2,u=t.y2,c=0;cthis.x2?this.x1=t:this.x2=t}},top:{get:function(){return Math.min(this.y1,this.y2)},set:function(t){this.y1<=this.y2?this.y1=t:this.y2=t}},bottom:{get:function(){return Math.max(this.y1,this.y2)},set:function(t){this.y1>this.y2?this.y1=t:this.y2=t}}});t.exports=a},function(t,i,e){var n=e(10),s=e(9);t.exports=function(t,i,e,r){void 0===r&&(r=[]),i||(i=s(t)/e);for(var h=0;h=i&&t.y<=e&&t.y+t.height>=e}},function(t,i,e){var n=e(0),s=e(52),r=e(10),h=e(51),o=e(50),a=e(45),u=new n({initialize:function(t,i,e,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===e&&(e=0),void 0===n&&(n=0),this.x=t,this.y=i,this.width=e,this.height=n},contains:function(t,i){return s(this,t,i)},getPoint:function(t,i){return r(this,t,i)},getPoints:function(t,i,e){return h(this,t,i,e)},getRandomPoint:function(t){return a(this,t)},setTo:function(t,i,e,n){return this.x=t,this.y=i,this.width=e,this.height=n,this},setEmpty:function(){return this.setTo(0,0,0,0)},setPosition:function(t,i){return void 0===i&&(i=t),this.x=t,this.y=i,this},setSize:function(t,i){return void 0===i&&(i=t),this.width=t,this.height=i,this},isEmpty:function(){return this.width<=0||this.height<=0},getLineA:function(t){return void 0===t&&(t=new o),t.setTo(this.x,this.y,this.right,this.y),t},getLineB:function(t){return void 0===t&&(t=new o),t.setTo(this.right,this.y,this.right,this.bottom),t},getLineC:function(t){return void 0===t&&(t=new o),t.setTo(this.right,this.bottom,this.x,this.bottom),t},getLineD:function(t){return void 0===t&&(t=new o),t.setTo(this.x,this.bottom,this.x,this.y),t},left:{get:function(){return this.x},set:function(t){t>=this.right?this.width=0:this.width=this.right-t,this.x=t}},right:{get:function(){return this.x+this.width},set:function(t){t<=this.x?this.width=0:this.width=t-this.x}},top:{get:function(){return this.y},set:function(t){t>=this.bottom?this.height=0:this.height=this.bottom-t,this.y=t}},bottom:{get:function(){return this.y+this.height},set:function(t){t<=this.y?this.height=0:this.height=t-this.y}},centerX:{get:function(){return this.x+this.width/2},set:function(t){this.x=t-this.width/2}},centerY:{get:function(){return this.y+this.height/2},set:function(t){this.y=t-this.height/2}}});t.exports=u},function(t,i,e){var n=e(53),s=e(44),r=e(3),h={getCenter:function(t){return void 0===t&&(t=new r),t.x=this.x-this.displayWidth*this.originX+this.displayWidth/2,t.y=this.y-this.displayHeight*this.originY+this.displayHeight/2,t},getTopLeft:function(t,i){(t||(t=new r),void 0===i&&(i=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),i&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getTopRight:function(t,i){(t||(t=new r),void 0===i&&(i=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY,0!==this.rotation&&s(t,this.x,this.y,this.rotation),i&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomLeft:function(t,i){(t||(t=new r),void 0===i&&(i=!1),t.x=this.x-this.displayWidth*this.originX,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),i&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBottomRight:function(t,i){(t||(t=new r),void 0===i&&(i=!1),t.x=this.x-this.displayWidth*this.originX+this.displayWidth,t.y=this.y-this.displayHeight*this.originY+this.displayHeight,0!==this.rotation&&s(t,this.x,this.y,this.rotation),i&&this.parentContainer)&&this.parentContainer.getBoundsTransformMatrix().transformPoint(t.x,t.y,t);return t},getBounds:function(t){var i,e,s,r,h,o,a,u;if(void 0===t&&(t=new n),this.parentContainer){var c=this.parentContainer.getBoundsTransformMatrix();this.getTopLeft(t),c.transformPoint(t.x,t.y,t),i=t.x,e=t.y,this.getTopRight(t),c.transformPoint(t.x,t.y,t),s=t.x,r=t.y,this.getBottomLeft(t),c.transformPoint(t.x,t.y,t),h=t.x,o=t.y,this.getBottomRight(t),c.transformPoint(t.x,t.y,t),a=t.x,u=t.y}else this.getTopLeft(t),i=t.x,e=t.y,this.getTopRight(t),s=t.x,r=t.y,this.getBottomLeft(t),h=t.x,o=t.y,this.getBottomRight(t),a=t.x,u=t.y;return t.x=Math.min(i,s,h,a),t.y=Math.min(e,r,o,u),t.width=Math.max(i,s,h,a)-t.x,t.height=Math.max(e,r,o,u)-t.y,t}};t.exports=h},function(t,i){t.exports={flipX:!1,flipY:!1,toggleFlipX:function(){return this.flipX=!this.flipX,this},toggleFlipY:function(){return this.flipY=!this.flipY,this},setFlipX:function(t){return this.flipX=t,this},setFlipY:function(t){return this.flipY=t,this},setFlip:function(t,i){return this.flipX=t,this.flipY=i,this},resetFlip:function(){return this.flipX=!1,this.flipY=!1,this}}},function(t,i){var e={_depth:0,depth:{get:function(){return this._depth},set:function(t){this.scene.sys.queueDepthSort(),this._depth=t}},setDepth:function(t){return void 0===t&&(t=0),this.depth=t,this}};t.exports=e},function(t,i){var e={texture:null,frame:null,isCropped:!1,setCrop:function(t,i,e,n){if(void 0===t)this.isCropped=!1;else if(this.frame){if("number"==typeof t)this.frame.setCropUVs(this._crop,t,i,e,n,this.flipX,this.flipY);else{var s=t;this.frame.setCropUVs(this._crop,s.x,s.y,s.width,s.height,this.flipX,this.flipY)}this.isCropped=!0}return this},resetCropObject:function(){return{u0:0,v0:0,u1:0,v1:0,width:0,height:0,x:0,y:0,flipX:!1,flipY:!1,cx:0,cy:0,cw:0,ch:0}}};t.exports=e},function(t,i){t.exports={width:0,height:0,displayWidth:{get:function(){return this.scaleX*this.width},set:function(t){this.scaleX=t/this.width}},displayHeight:{get:function(){return this.scaleY*this.height},set:function(t){this.scaleY=t/this.height}},setSize:function(t,i){return this.width=t,this.height=i,this},setDisplaySize:function(t,i){return this.displayWidth=t,this.displayHeight=i,this}}},function(t,i,e){var n=e(18),s={_blendMode:n.NORMAL,blendMode:{get:function(){return this._blendMode},set:function(t){"string"==typeof t&&(t=n[t]),(t|=0)>=-1&&(this._blendMode=t)}},setBlendMode:function(t){return this.blendMode=t,this}};t.exports=s},function(t,i,e){var n=new(e(0))({initialize:function(t){this.parent=t,this.animationManager=t.scene.sys.anims,this.animationManager.once("remove",this.remove,this),this.isPlaying=!1,this.currentAnim=null,this.currentFrame=null,this._timeScale=1,this.frameRate=0,this.duration=0,this.msPerFrame=0,this.skipMissedFrames=!0,this._delay=0,this._repeat=0,this._repeatDelay=0,this._yoyo=!1,this.forward=!0,this._reverse=!1,this.accumulator=0,this.nextTick=0,this.repeatCounter=0,this.pendingRepeat=!1,this._paused=!1,this._wasPlaying=!1,this._pendingStop=0,this._pendingStopValue},setDelay:function(t){return void 0===t&&(t=0),this._delay=t,this.parent},getDelay:function(){return this._delay},delayedPlay:function(t,i,e){return this.play(i,!0,e),this.nextTick+=t,this.parent},getCurrentKey:function(){if(this.currentAnim)return this.currentAnim.key},load:function(t,i){return void 0===i&&(i=0),this.isPlaying&&this.stop(),this.animationManager.load(this,t,i),this.parent},pause:function(t){return this._paused||(this._paused=!0,this._wasPlaying=this.isPlaying,this.isPlaying=!1),void 0!==t&&this.updateFrame(t),this.parent},resume:function(t){return this._paused&&(this._paused=!1,this.isPlaying=this._wasPlaying),void 0!==t&&this.updateFrame(t),this.parent},isPaused:{get:function(){return this._paused}},play:function(t,i,e){return void 0===i&&(i=!1),void 0===e&&(e=0),i&&this.isPlaying&&this.currentAnim.key===t?this.parent:(this.forward=!0,this._reverse=!1,this._startAnimation(t,e))},playReverse:function(t,i,e){return void 0===i&&(i=!1),void 0===e&&(e=0),i&&this.isPlaying&&this.currentAnim.key===t?this.parent:(this.forward=!1,this._reverse=!0,this._startAnimation(t,e))},_startAnimation:function(t,i){this.load(t,i);var e=this.currentAnim,n=this.parent;return this.repeatCounter=-1===this._repeat?Number.MAX_VALUE:this._repeat,e.getFirstTick(this),this.isPlaying=!0,this.pendingRepeat=!1,e.showOnStart&&(n.visible=!0),n.emit("animationstart",this.currentAnim,this.currentFrame),n},reverse:function(t){return this.isPlaying&&this.currentAnim.key===t?(this._reverse=!this._reverse,this.forward=!this.forward,this.parent):this.parent},getProgress:function(){var t=this.currentFrame.progress;return this.forward||(t=1-t),t},setProgress:function(t){return this.forward||(t=1-t),this.setCurrentFrame(this.currentAnim.getFrameByProgress(t)),this.parent},remove:function(t,i){void 0===i&&(i=this.currentAnim),this.isPlaying&&i.key===this.currentAnim.key&&(this.stop(),this.setCurrentFrame(this.currentAnim.frames[0]))},getRepeat:function(){return this._repeat},setRepeat:function(t){return this._repeat=t,this.repeatCounter=0,this.parent},getRepeatDelay:function(){return this._repeatDelay},setRepeatDelay:function(t){return this._repeatDelay=t,this.parent},restart:function(t){return void 0===t&&(t=!1),this.currentAnim.getFirstTick(this,t),this.forward=!0,this.isPlaying=!0,this.pendingRepeat=!1,this._paused=!1,this.updateFrame(this.currentAnim.frames[0]),this.parent},stop:function(){this._pendingStop=0,this.isPlaying=!1;var t=this.parent;return t.emit("animationcomplete",this.currentAnim,this.currentFrame),t},stopAfterDelay:function(t){return this._pendingStop=1,this._pendingStopValue=t,this.parent},stopOnRepeat:function(){return this._pendingStop=2,this.parent},stopOnFrame:function(t){return this._pendingStop=3,this._pendingStopValue=t,this.parent},setTimeScale:function(t){return void 0===t&&(t=1),this._timeScale=t,this.parent},getTimeScale:function(){return this._timeScale},getTotalFrames:function(){return this.currentAnim.frames.length},update:function(t,i){if(this.currentAnim&&this.isPlaying&&!this.currentAnim.paused){if(this.accumulator+=i*this._timeScale,1===this._pendingStop&&(this._pendingStopValue-=i,this._pendingStopValue<=0))return this.currentAnim.completeAnimation(this);this.accumulator>=this.nextTick&&this.currentAnim.setFrame(this)}},setCurrentFrame:function(t){var i=this.parent;return this.currentFrame=t,i.texture=t.frame.texture,i.frame=t.frame,i.setSizeToFrame(),t.frame.customPivot?i.setOrigin(t.frame.pivotX,t.frame.pivotY):i.updateDisplayOrigin(),i},updateFrame:function(t){var i=this.setCurrentFrame(t);if(this.isPlaying){t.setAlpha&&(i.alpha=t.alpha);var e=this.currentAnim;i.emit("animationupdate",e,t),3===this._pendingStop&&this._pendingStopValue===t&&this.currentAnim.completeAnimation(this)}},setYoyo:function(t){return void 0===t&&(t=!1),this._yoyo=t,this.parent},getYoyo:function(){return this._yoyo},destroy:function(){this.animationManager.off("remove",this.remove,this),this.animationManager=null,this.parent=null,this.currentAnim=null,this.currentFrame=null}});t.exports=n},function(t,i){t.exports=function(t,i,e){return Math.max(i,Math.min(e,t))}},function(t,i,e){var n=e(61),s={_alpha:1,_alphaTL:1,_alphaTR:1,_alphaBL:1,_alphaBR:1,clearAlpha:function(){return this.setAlpha(1)},setAlpha:function(t,i,e,s){return void 0===t&&(t=1),void 0===i?this.alpha=t:(this._alphaTL=n(t,0,1),this._alphaTR=n(i,0,1),this._alphaBL=n(e,0,1),this._alphaBR=n(s,0,1)),this},alpha:{get:function(){return this._alpha},set:function(t){var i=n(t,0,1);this._alpha=i,this._alphaTL=i,this._alphaTR=i,this._alphaBL=i,this._alphaBR=i,0===i?this.renderFlags&=-3:this.renderFlags|=2}},alphaTopLeft:{get:function(){return this._alphaTL},set:function(t){var i=n(t,0,1);this._alphaTL=i,0!==i&&(this.renderFlags|=2)}},alphaTopRight:{get:function(){return this._alphaTR},set:function(t){var i=n(t,0,1);this._alphaTR=i,0!==i&&(this.renderFlags|=2)}},alphaBottomLeft:{get:function(){return this._alphaBL},set:function(t){var i=n(t,0,1);this._alphaBL=i,0!==i&&(this.renderFlags|=2)}},alphaBottomRight:{get:function(){return this._alphaBR},set:function(t){var i=n(t,0,1);this._alphaBR=i,0!==i&&(this.renderFlags|=2)}}};t.exports=s},function(t,i,e){var n=new(e(0))({initialize:function(t){if(this.entries=[],Array.isArray(t))for(var i=0;i-1&&this.entries.splice(i,1),this},dump:function(){console.group("Set");for(var t=0;t-1},union:function(t){var i=new n;return t.entries.forEach(function(t){i.set(t)}),this.entries.forEach(function(t){i.set(t)}),i},intersect:function(t){var i=new n;return this.entries.forEach(function(e){t.contains(e)&&i.set(e)}),i},difference:function(t){var i=new n;return this.entries.forEach(function(e){t.contains(e)||i.set(e)}),i},size:{get:function(){return this.entries.length},set:function(t){return this.entries.length=t}}});t.exports=n},function(t,i,e){var n=new(e(0))({initialize:function(t){this.val=new Float32Array(9),t?this.copy(t):this.identity()},clone:function(){return new n(this)},set:function(t){return this.copy(t)},copy:function(t){var i=this.val,e=t.val;return i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7],i[8]=e[8],this},fromMat4:function(t){var i=t.val,e=this.val;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[4],e[4]=i[5],e[5]=i[6],e[6]=i[8],e[7]=i[9],e[8]=i[10],this},fromArray:function(t){var i=this.val;return i[0]=t[0],i[1]=t[1],i[2]=t[2],i[3]=t[3],i[4]=t[4],i[5]=t[5],i[6]=t[6],i[7]=t[7],i[8]=t[8],this},identity:function(){var t=this.val;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this},transpose:function(){var t=this.val,i=t[1],e=t[2],n=t[5];return t[1]=t[3],t[2]=t[6],t[3]=i,t[5]=t[7],t[6]=e,t[7]=n,this},invert:function(){var t=this.val,i=t[0],e=t[1],n=t[2],s=t[3],r=t[4],h=t[5],o=t[6],a=t[7],u=t[8],c=u*r-h*a,f=-u*s+h*o,l=a*s-r*o,p=i*c+e*f+n*l;return p?(p=1/p,t[0]=c*p,t[1]=(-u*e+n*a)*p,t[2]=(h*e-n*r)*p,t[3]=f*p,t[4]=(u*i-n*o)*p,t[5]=(-h*i+n*s)*p,t[6]=l*p,t[7]=(-a*i+e*o)*p,t[8]=(r*i-e*s)*p,this):null},adjoint:function(){var t=this.val,i=t[0],e=t[1],n=t[2],s=t[3],r=t[4],h=t[5],o=t[6],a=t[7],u=t[8];return t[0]=r*u-h*a,t[1]=n*a-e*u,t[2]=e*h-n*r,t[3]=h*o-s*u,t[4]=i*u-n*o,t[5]=n*s-i*h,t[6]=s*a-r*o,t[7]=e*o-i*a,t[8]=i*r-e*s,this},determinant:function(){var t=this.val,i=t[0],e=t[1],n=t[2],s=t[3],r=t[4],h=t[5],o=t[6],a=t[7],u=t[8];return i*(u*r-h*a)+e*(-u*s+h*o)+n*(a*s-r*o)},multiply:function(t){var i=this.val,e=i[0],n=i[1],s=i[2],r=i[3],h=i[4],o=i[5],a=i[6],u=i[7],c=i[8],f=t.val,l=f[0],p=f[1],d=f[2],y=f[3],v=f[4],x=f[5],m=f[6],g=f[7],w=f[8];return i[0]=l*e+p*r+d*a,i[1]=l*n+p*h+d*u,i[2]=l*s+p*o+d*c,i[3]=y*e+v*r+x*a,i[4]=y*n+v*h+x*u,i[5]=y*s+v*o+x*c,i[6]=m*e+g*r+w*a,i[7]=m*n+g*h+w*u,i[8]=m*s+g*o+w*c,this},translate:function(t){var i=this.val,e=t.x,n=t.y;return i[6]=e*i[0]+n*i[3]+i[6],i[7]=e*i[1]+n*i[4]+i[7],i[8]=e*i[2]+n*i[5]+i[8],this},rotate:function(t){var i=this.val,e=i[0],n=i[1],s=i[2],r=i[3],h=i[4],o=i[5],a=Math.sin(t),u=Math.cos(t);return i[0]=u*e+a*r,i[1]=u*n+a*h,i[2]=u*s+a*o,i[3]=u*r-a*e,i[4]=u*h-a*n,i[5]=u*o-a*s,this},scale:function(t){var i=this.val,e=t.x,n=t.y;return i[0]=e*i[0],i[1]=e*i[1],i[2]=e*i[2],i[3]=n*i[3],i[4]=n*i[4],i[5]=n*i[5],this},fromQuat:function(t){var i=t.x,e=t.y,n=t.z,s=t.w,r=i+i,h=e+e,o=n+n,a=i*r,u=i*h,c=i*o,f=e*h,l=e*o,p=n*o,d=s*r,y=s*h,v=s*o,x=this.val;return x[0]=1-(f+p),x[3]=u+v,x[6]=c-y,x[1]=u-v,x[4]=1-(a+p),x[7]=l+d,x[2]=c+y,x[5]=l-d,x[8]=1-(a+f),this},normalFromMat4:function(t){var i=t.val,e=this.val,n=i[0],s=i[1],r=i[2],h=i[3],o=i[4],a=i[5],u=i[6],c=i[7],f=i[8],l=i[9],p=i[10],d=i[11],y=i[12],v=i[13],x=i[14],m=i[15],g=n*a-s*o,w=n*u-r*o,z=n*c-h*o,M=s*u-r*a,_=s*c-h*a,b=r*c-h*u,T=f*v-l*y,A=f*x-p*y,F=f*m-d*y,P=l*x-p*v,O=l*m-d*v,R=p*m-d*x,C=g*R-w*O+z*P+M*F-_*A+b*T;return C?(C=1/C,e[0]=(a*R-u*O+c*P)*C,e[1]=(u*F-o*R-c*A)*C,e[2]=(o*O-a*F+c*T)*C,e[3]=(r*O-s*R-h*P)*C,e[4]=(n*R-r*F+h*A)*C,e[5]=(s*F-n*O-h*T)*C,e[6]=(v*b-x*_+m*M)*C,e[7]=(x*z-y*b-m*w)*C,e[8]=(y*_-v*z+m*g)*C,this):null}});t.exports=n},function(t,i,e){var n=e(0),s=e(2),r=e(64),h=new Int8Array([1,2,0]),o=new Float32Array([0,0,0]),a=new s(1,0,0),u=new s(0,1,0),c=new s,f=new r,l=new n({initialize:function(t,i,e,n){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=i||0,this.z=e||0,this.w=n||0)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},set:function(t,i,e,n){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0,this.z=t.z||0,this.w=t.w||0):(this.x=t||0,this.y=i||0,this.z=e||0,this.w=n||0),this},add:function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},subtract:function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},scale:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},length:function(){var t=this.x,i=this.y,e=this.z,n=this.w;return Math.sqrt(t*t+i*i+e*e+n*n)},lengthSq:function(){var t=this.x,i=this.y,e=this.z,n=this.w;return t*t+i*i+e*e+n*n},normalize:function(){var t=this.x,i=this.y,e=this.z,n=this.w,s=t*t+i*i+e*e+n*n;return s>0&&(s=1/Math.sqrt(s),this.x=t*s,this.y=i*s,this.z=e*s,this.w=n*s),this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lerp:function(t,i){void 0===i&&(i=0);var e=this.x,n=this.y,s=this.z,r=this.w;return this.x=e+i*(t.x-e),this.y=n+i*(t.y-n),this.z=s+i*(t.z-s),this.w=r+i*(t.w-r),this},rotationTo:function(t,i){var e=t.x*i.x+t.y*i.y+t.z*i.z;return e<-.999999?(c.copy(a).cross(t).length()<1e-6&&c.copy(u).cross(t),c.normalize(),this.setAxisAngle(c,Math.PI)):e>.999999?(this.x=0,this.y=0,this.z=0,this.w=1,this):(c.copy(t).cross(i),this.x=c.x,this.y=c.y,this.z=c.z,this.w=1+e,this.normalize())},setAxes:function(t,i,e){var n=f.val;return n[0]=i.x,n[3]=i.y,n[6]=i.z,n[1]=e.x,n[4]=e.y,n[7]=e.z,n[2]=-t.x,n[5]=-t.y,n[8]=-t.z,this.fromMat3(f).normalize()},identity:function(){return this.x=0,this.y=0,this.z=0,this.w=1,this},setAxisAngle:function(t,i){i*=.5;var e=Math.sin(i);return this.x=e*t.x,this.y=e*t.y,this.z=e*t.z,this.w=Math.cos(i),this},multiply:function(t){var i=this.x,e=this.y,n=this.z,s=this.w,r=t.x,h=t.y,o=t.z,a=t.w;return this.x=i*a+s*r+e*o-n*h,this.y=e*a+s*h+n*r-i*o,this.z=n*a+s*o+i*h-e*r,this.w=s*a-i*r-e*h-n*o,this},slerp:function(t,i){var e=this.x,n=this.y,s=this.z,r=this.w,h=t.x,o=t.y,a=t.z,u=t.w,c=e*h+n*o+s*a+r*u;c<0&&(c=-c,h=-h,o=-o,a=-a,u=-u);var f=1-i,l=i;if(1-c>1e-6){var p=Math.acos(c),d=Math.sin(p);f=Math.sin((1-i)*p)/d,l=Math.sin(i*p)/d}return this.x=f*e+l*h,this.y=f*n+l*o,this.z=f*s+l*a,this.w=f*r+l*u,this},invert:function(){var t=this.x,i=this.y,e=this.z,n=this.w,s=t*t+i*i+e*e+n*n,r=s?1/s:0;return this.x=-t*r,this.y=-i*r,this.z=-e*r,this.w=n*r,this},conjugate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},rotateX:function(t){t*=.5;var i=this.x,e=this.y,n=this.z,s=this.w,r=Math.sin(t),h=Math.cos(t);return this.x=i*h+s*r,this.y=e*h+n*r,this.z=n*h-e*r,this.w=s*h-i*r,this},rotateY:function(t){t*=.5;var i=this.x,e=this.y,n=this.z,s=this.w,r=Math.sin(t),h=Math.cos(t);return this.x=i*h-n*r,this.y=e*h+s*r,this.z=n*h+i*r,this.w=s*h-e*r,this},rotateZ:function(t){t*=.5;var i=this.x,e=this.y,n=this.z,s=this.w,r=Math.sin(t),h=Math.cos(t);return this.x=i*h+e*r,this.y=e*h-i*r,this.z=n*h+s*r,this.w=s*h-n*r,this},calculateW:function(){var t=this.x,i=this.y,e=this.z;return this.w=-Math.sqrt(1-t*t-i*i-e*e),this},fromMat3:function(t){var i,e=t.val,n=e[0]+e[4]+e[8];if(n>0)i=Math.sqrt(n+1),this.w=.5*i,i=.5/i,this.x=(e[7]-e[5])*i,this.y=(e[2]-e[6])*i,this.z=(e[3]-e[1])*i;else{var s=0;e[4]>e[0]&&(s=1),e[8]>e[3*s+s]&&(s=2);var r=h[s],a=h[r];i=Math.sqrt(e[3*s+s]-e[3*r+r]-e[3*a+a]+1),o[s]=.5*i,i=.5/i,o[r]=(e[3*r+s]+e[3*s+r])*i,o[a]=(e[3*a+s]+e[3*s+a])*i,this.x=o[0],this.y=o[1],this.z=o[2],this.w=(e[3*a+r]-e[3*r+a])*i}return this}});t.exports=l},function(t,i,e){var n=e(2),s=e(14),r=e(65),h=new s,o=new r,a=new n;t.exports=function(t,i,e){return o.setAxisAngle(i,e),h.fromRotationTranslation(o,a.set(0,0,0)),t.transformMat4(h)}},function(t,i){t.exports=function(t,i){return void 0===i&&(i=1),t.x=(2*Math.random()-1)*i,t.y=(2*Math.random()-1)*i,t.z=(2*Math.random()-1)*i,t.w=(2*Math.random()-1)*i,t}},function(t,i){t.exports=function(t,i){void 0===i&&(i=1);var e=2*Math.random()*Math.PI,n=2*Math.random()-1,s=Math.sqrt(1-n*n)*i;return t.x=Math.cos(e)*s,t.y=Math.sin(e)*s,t.z=n*i,t}},function(t,i,e){var n=e(15),s=e(0),r=new(e(2)),h=new s({Extends:n,initialize:function(t,i,e){void 0===i&&(i=0),void 0===e&&(e=0),n.call(this,t),this.viewportWidth=i,this.viewportHeight=e,this._zoom=1,this.near=0,this.update()},setToOrtho:function(t,i,e){void 0===i&&(i=this.viewportWidth),void 0===e&&(e=this.viewportHeight);var n=this.zoom;return this.up.set(0,t?-1:1,0),this.direction.set(0,0,t?1:-1),this.position.set(n*i/2,n*e/2,0),this.viewportWidth=i,this.viewportHeight=e,this.update()},update:function(){var t=this.viewportWidth,i=this.viewportHeight,e=Math.abs(this.near),n=Math.abs(this.far),s=this.zoom;return 0===t||0===i?this:(this.projection.ortho(s*-t/2,s*t/2,s*-i/2,s*i/2,e,n),r.copy(this.position).add(this.direction),this.view.lookAt(this.position,r,this.up),this.combined.copy(this.projection).multiply(this.view),this.invProjectionView.copy(this.combined).invert(),this.billboardMatrixDirty=!0,this.updateChildren(),this)},zoom:{get:function(){return this._zoom},set:function(t){this._zoom=t,this.update()}}});t.exports=h},function(t,i,e){var n=e(4);t.exports=function(t,i){var e=n(i,"anims",null);if(null===e)return t;if("string"==typeof e)t.anims.play(e);else if("object"==typeof e){var s=t.anims,r=n(e,"key",void 0),h=n(e,"startFrame",void 0),o=n(e,"delay",0),a=n(e,"repeat",0),u=n(e,"repeatDelay",0),c=n(e,"yoyo",!1),f=n(e,"play",!1),l=n(e,"delayedPlay",0);s.setDelay(o),s.setRepeat(a),s.setRepeatDelay(u),s.setYoyo(c),f?s.play(r,h):l>0?s.delayedPlay(l,r,h):s.load(r)}return t}},function(t,i){t.exports=function(t,i,e){if(t&&"number"!=typeof t){if(t.hasOwnProperty(i))return t[i];if(i.indexOf(".")){for(var n=i.split("."),s=t,r=e,h=0;h>>0,e=(i*=e)>>>0,e+=4294967296*(i-=e);return this.n=e,2.3283064365386963e-10*(e>>>0)},init:function(t){"string"==typeof t?this.state(t):this.sow(t)},sow:function(t){if(this.n=4022871197,this.s0=this.hash(" "),this.s1=this.hash(" "),this.s2=this.hash(" "),this.c=1,t)for(var i=0;i0;e--){var n=Math.floor(this.frac()*(i+1)),s=t[n];t[n]=t[e],t[e]=s}return t}});t.exports=n},function(t,i,e){var n=e(18),s=e(4),r=e(16);t.exports=function(t,i,e){i.x=s(e,"x",0),i.y=s(e,"y",0),i.depth=s(e,"depth",0),i.flipX=s(e,"flipX",!1),i.flipY=s(e,"flipY",!1);var h=s(e,"scale",null);"number"==typeof h?i.setScale(h):null!==h&&(i.scaleX=s(h,"x",1),i.scaleY=s(h,"y",1));var o=s(e,"scrollFactor",null);"number"==typeof o?i.setScrollFactor(o):null!==o&&(i.scrollFactorX=s(o,"x",1),i.scrollFactorY=s(o,"y",1)),i.rotation=s(e,"rotation",0);var a=s(e,"angle",null);null!==a&&(i.angle=a),i.alpha=s(e,"alpha",1);var u=s(e,"origin",null);if("number"==typeof u)i.setOrigin(u);else if(null!==u){var c=s(u,"x",.5),f=s(u,"y",.5);i.setOrigin(c,f)}return i.scaleMode=s(e,"scaleMode",r.DEFAULT),i.blendMode=s(e,"blendMode",n.NORMAL),i.visible=s(e,"visible",!0),s(e,"add",!0)&&t.sys.displayList.add(i),i.preUpdate&&t.sys.updateList.add(i),i}},function(t,i,e){var n=e(73),s=e(70),r=e(0),h=e(4),o=e(69),a=e(21),u=e(20),c=e(13),f=new r({Extends:u,initialize:function(t,i){u.call(this,t,i),this.cameras=[],i.registerGameObject("sprite3D",this.sprite3DFactory,this.sprite3DCreator)},sprite3DFactory:function(t,i,e,n,s){var r=new c(this.scene,t,i,e,n,s);return this.displayList.add(r.gameObject),this.updateList.add(r.gameObject),r},sprite3DCreator:function(t,i){void 0===t&&(t={});var e=h(t,"key",null),r=h(t,"frame",null),o=new c(this.scene,0,0,e,r);return void 0!==i&&(t.add=i),n(this.scene,o,t),s(o,t),o},boot:function(){this.systems.events.once("destroy",this.destroy,this)},start:function(){var t=this.systems.events;t.on("update",this.update,this),t.once("shutdown",this.shutdown,this)},add:function(t,i,e){return this.addPerspectiveCamera(t,i,e)},addOrthographicCamera:function(t,i){var e=this.scene.sys.game.config;void 0===t&&(t=e.width),void 0===i&&(i=e.height);var n=new o(this.scene,t,i);return this.cameras.push(n),n},addPerspectiveCamera:function(t,i,e){var n=this.scene.sys.game.config;void 0===t&&(t=80),void 0===i&&(i=n.width),void 0===e&&(e=n.height);var s=new a(this.scene,t,i,e);return this.cameras.push(s),s},getCamera:function(t){for(var i=0;i0;){this.cameras.pop().destroy()}return this.main},update:function(t,i){for(var e=0,n=this.cameras.length;e + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BuildGameObject = require('../../../src/gameobjects/BuildGameObject'); +var BuildGameObjectAnimation = require('../../../src/gameobjects/BuildGameObjectAnimation'); +var Class = require('../../../src/utils/Class'); +var GetAdvancedValue = require('../../../src/utils/object/GetAdvancedValue'); +var OrthographicCamera = require('./OrthographicCamera'); +var PerspectiveCamera = require('./PerspectiveCamera'); +var ScenePlugin = require('../../../src/plugins/ScenePlugin'); +var Sprite3D = require('./sprite3d/Sprite3D'); + +/** + * @classdesc + * The Camera 3D Plugin adds a new Camera type to Phaser that allows for movement and rendering + * in 3D space. It displays a special type of Sprite called a Sprite3D that is a billboard sprite, + * with a z-axis allowing for perspective depth. + * + * This is an external plugin which you can include in your game by preloading it: + * + * ```javascript + * this.load.scenePlugin({ + * key: 'Camera3DPlugin', + * url: 'plugins/camera3d.min.js', + * sceneKey: 'cameras3d' + * }); + * ``` + * + * Once loaded you can create a 3D Camera using the `camera3d` property of a Scene: + * + * `var camera = this.cameras3d.add(85).setZ(500).setPixelScale(128);` + * + * See the examples for more information. + * + * @class Camera3DPlugin + * @constructor + * + * @param {Phaser.Scene} scene - The Scene to which this plugin is being installed. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var Camera3DPlugin = new Class({ + + Extends: ScenePlugin, + + initialize: + + function Camera3DPlugin (scene, pluginManager) + { + ScenePlugin.call(this, scene, pluginManager); + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * + * @name Camera3DPlugin#cameras + * @type {Phaser.Cameras.Sprite3D.Camera[]} + * @since 3.0.0 + */ + this.cameras = []; + + // Register the Sprite3D Game Object + pluginManager.registerGameObject('sprite3D', this.sprite3DFactory, this.sprite3DCreator); + }, + + /** + * Creates a new Sprite3D Game Object and adds it to the Scene. + * + * @method Phaser.GameObjects.GameObjectFactory#sprite3D + * @since 3.0.0 + * + * @param {number} x - The horizontal position of this Game Object. + * @param {number} y - The vertical position of this Game Object. + * @param {number} z - The z position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. + */ + sprite3DFactory: function (x, y, z, key, frame) + { + var sprite = new Sprite3D(this.scene, x, y, z, key, frame); + + this.displayList.add(sprite.gameObject); + this.updateList.add(sprite.gameObject); + + return sprite; + }, + + /** + * Creates a new Sprite3D Game Object and returns it. + * + * @method Phaser.GameObjects.GameObjectCreator#sprite3D + * @since 3.0.0 + * + * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. + * + * @return {Phaser.GameObjects.Sprite3D} The Game Object that was created. + */ + sprite3DCreator: function (config, addToScene) + { + if (config === undefined) { config = {}; } + + var key = GetAdvancedValue(config, 'key', null); + var frame = GetAdvancedValue(config, 'frame', null); + + var sprite = new Sprite3D(this.scene, 0, 0, key, frame); + + if (addToScene !== undefined) + { + config.add = addToScene; + } + + BuildGameObject(this.scene, sprite, config); + + // Sprite specific config options: + + BuildGameObjectAnimation(sprite, config); + + return sprite; + }, + + /** + * This method is called automatically, only once, when the Scene is first created. + * Do not invoke it directly. + * + * @method Phaser.Cameras.Scene3D.CameraManager#boot + * @private + * @since 3.5.1 + */ + boot: function () + { + this.systems.events.once('destroy', this.destroy, 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 Camera3DPlugin#start + * @private + * @since 3.5.0 + */ + start: function () + { + var eventEmitter = this.systems.events; + + eventEmitter.on('update', this.update, this); + eventEmitter.once('shutdown', this.shutdown, this); + }, + + /** + * [description] + * + * @method Camera3DPlugin#add + * @since 3.0.0 + * + * @param {number} [fieldOfView=80] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + add: function (fieldOfView, width, height) + { + return this.addPerspectiveCamera(fieldOfView, width, height); + }, + + /** + * [description] + * + * @method Camera3DPlugin#addOrthographicCamera + * @since 3.0.0 + * + * @param {number} width - [description] + * @param {number} height - [description] + * + * @return {Phaser.Cameras.Sprite3D.OrthographicCamera} [description] + */ + addOrthographicCamera: function (width, height) + { + var config = this.scene.sys.game.config; + + if (width === undefined) { width = config.width; } + if (height === undefined) { height = config.height; } + + var camera = new OrthographicCamera(this.scene, width, height); + + this.cameras.push(camera); + + return camera; + }, + + /** + * [description] + * + * @method Camera3DPlugin#addPerspectiveCamera + * @since 3.0.0 + * + * @param {number} [fieldOfView=80] - [description] + * @param {number} [width] - [description] + * @param {number} [height] - [description] + * + * @return {Phaser.Cameras.Sprite3D.PerspectiveCamera} [description] + */ + addPerspectiveCamera: function (fieldOfView, width, height) + { + var config = this.scene.sys.game.config; + + if (fieldOfView === undefined) { fieldOfView = 80; } + if (width === undefined) { width = config.width; } + if (height === undefined) { height = config.height; } + + var camera = new PerspectiveCamera(this.scene, fieldOfView, width, height); + + this.cameras.push(camera); + + return camera; + }, + + /** + * [description] + * + * @method Camera3DPlugin#getCamera + * @since 3.0.0 + * + * @param {string} name - [description] + * + * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + */ + getCamera: function (name) + { + for (var i = 0; i < this.cameras.length; i++) + { + if (this.cameras[i].name === name) + { + return this.cameras[i]; + } + } + + return null; + }, + + /** + * [description] + * + * @method Camera3DPlugin#removeCamera + * @since 3.0.0 + * + * @param {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} camera - [description] + */ + removeCamera: function (camera) + { + var cameraIndex = this.cameras.indexOf(camera); + + if (cameraIndex !== -1) + { + this.cameras.splice(cameraIndex, 1); + } + }, + + /** + * [description] + * + * @method Camera3DPlugin#removeAll + * @since 3.0.0 + * + * @return {(Phaser.Cameras.Sprite3D.OrthographicCamera|Phaser.Cameras.Sprite3D.PerspectiveCamera)} [description] + */ + removeAll: function () + { + while (this.cameras.length > 0) + { + var camera = this.cameras.pop(); + + camera.destroy(); + } + + return this.main; + }, + + /** + * [description] + * + * @method Camera3DPlugin#update + * @since 3.0.0 + * + * @param {number} timestep - [description] + * @param {number} delta - [description] + */ + update: function (timestep, delta) + { + for (var i = 0, l = this.cameras.length; i < l; ++i) + { + this.cameras[i].update(timestep, delta); + } + }, + + /** + * 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 Camera3DPlugin#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(); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Camera3DPlugin#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.pluginManager = null; + this.game = null; + this.scene = null; + this.systems = null; + } + +}); + +module.exports = Camera3DPlugin; diff --git a/src/cameras/sprite3d/CameraManager.js b/plugins/camera3d/src/CameraManager.js similarity index 98% rename from src/cameras/sprite3d/CameraManager.js rename to plugins/camera3d/src/CameraManager.js index ba727e26d..c6ed0eebe 100644 --- a/src/cameras/sprite3d/CameraManager.js +++ b/plugins/camera3d/src/CameraManager.js @@ -4,10 +4,10 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = require('../../utils/Class'); +var Class = require('../../../src/utils/Class'); var OrthographicCamera = require('./OrthographicCamera'); var PerspectiveCamera = require('./PerspectiveCamera'); -var PluginCache = require('../../plugins/PluginCache'); +var PluginCache = require('../../../src/plugins/PluginCache'); /** * @classdesc @@ -57,7 +57,6 @@ var CameraManager = new Class({ scene.sys.events.on('start', this.start, this); }, - /** * This method is called automatically, only once, when the Scene is first created. * Do not invoke it directly. diff --git a/src/cameras/sprite3d/OrthographicCamera.js b/plugins/camera3d/src/OrthographicCamera.js similarity index 97% rename from src/cameras/sprite3d/OrthographicCamera.js rename to plugins/camera3d/src/OrthographicCamera.js index 0727ba9ba..fc7728013 100644 --- a/src/cameras/sprite3d/OrthographicCamera.js +++ b/plugins/camera3d/src/OrthographicCamera.js @@ -5,8 +5,8 @@ */ var Camera = require('./Camera'); -var Class = require('../../utils/Class'); -var Vector3 = require('../../math/Vector3'); +var Class = require('../../../src/utils/Class'); +var Vector3 = require('../../../src/math/Vector3'); // Local cache vars var tmpVec3 = new Vector3(); diff --git a/src/cameras/sprite3d/PerspectiveCamera.js b/plugins/camera3d/src/PerspectiveCamera.js similarity index 97% rename from src/cameras/sprite3d/PerspectiveCamera.js rename to plugins/camera3d/src/PerspectiveCamera.js index 20a5a263b..d22dbf028 100644 --- a/src/cameras/sprite3d/PerspectiveCamera.js +++ b/plugins/camera3d/src/PerspectiveCamera.js @@ -5,8 +5,8 @@ */ var Camera = require('./Camera'); -var Class = require('../../utils/Class'); -var Vector3 = require('../../math/Vector3'); +var Class = require('../../../src/utils/Class'); +var Vector3 = require('../../../src/math/Vector3'); // Local cache vars var tmpVec3 = new Vector3(); diff --git a/src/cameras/sprite3d/index.js b/plugins/camera3d/src/index.js similarity index 100% rename from src/cameras/sprite3d/index.js rename to plugins/camera3d/src/index.js diff --git a/src/gameobjects/sprite3d/Sprite3D.js b/plugins/camera3d/src/sprite3d/Sprite3D.js similarity index 95% rename from src/gameobjects/sprite3d/Sprite3D.js rename to plugins/camera3d/src/sprite3d/Sprite3D.js index 193335eb2..8bc530545 100644 --- a/src/gameobjects/sprite3d/Sprite3D.js +++ b/plugins/camera3d/src/sprite3d/Sprite3D.js @@ -4,11 +4,11 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Class = require('../../utils/Class'); -var GameObject = require('../GameObject'); -var Sprite = require('../sprite/Sprite'); -var Vector2 = require('../../math/Vector2'); -var Vector4 = require('../../math/Vector4'); +var Class = require('../../../../src/utils/Class'); +var GameObject = require('../../../../src/gameobjects/GameObject'); +var Sprite = require('../../../../src/gameobjects/sprite/Sprite'); +var Vector2 = require('../../../../src/math/Vector2'); +var Vector4 = require('../../../../src/math/Vector4'); /** * @classdesc diff --git a/src/gameobjects/sprite3d/Sprite3DCreator.js b/plugins/camera3d/src/sprite3d/Sprite3DCreator.js similarity index 81% rename from src/gameobjects/sprite3d/Sprite3DCreator.js rename to plugins/camera3d/src/sprite3d/Sprite3DCreator.js index 4c896ce88..33d3d524c 100644 --- a/src/gameobjects/sprite3d/Sprite3DCreator.js +++ b/plugins/camera3d/src/sprite3d/Sprite3DCreator.js @@ -4,10 +4,10 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BuildGameObject = require('../BuildGameObject'); -var BuildGameObjectAnimation = require('../BuildGameObjectAnimation'); -var GameObjectCreator = require('../GameObjectCreator'); -var GetAdvancedValue = require('../../utils/object/GetAdvancedValue'); +var BuildGameObject = require('../../../../src/gameobjects/BuildGameObject'); +var BuildGameObjectAnimation = require('../../../../src/gameobjects/BuildGameObjectAnimation'); +var GameObjectCreator = require('../../../../src/gameobjects/GameObjectCreator'); +var GetAdvancedValue = require('../../../../src/utils/object/GetAdvancedValue'); var Sprite3D = require('./Sprite3D'); /** diff --git a/src/gameobjects/sprite3d/Sprite3DFactory.js b/plugins/camera3d/src/sprite3d/Sprite3DFactory.js similarity index 95% rename from src/gameobjects/sprite3d/Sprite3DFactory.js rename to plugins/camera3d/src/sprite3d/Sprite3DFactory.js index 4a0f68754..c073f9705 100644 --- a/src/gameobjects/sprite3d/Sprite3DFactory.js +++ b/plugins/camera3d/src/sprite3d/Sprite3DFactory.js @@ -5,7 +5,7 @@ */ var Sprite3D = require('./Sprite3D'); -var GameObjectFactory = require('../GameObjectFactory'); +var GameObjectFactory = require('../../../../src/gameobjects/GameObjectFactory'); /** * Creates a new Sprite3D Game Object and adds it to the Scene. diff --git a/plugins/camera3d/webpack.config.js b/plugins/camera3d/webpack.config.js new file mode 100644 index 000000000..c5f8f5f9a --- /dev/null +++ b/plugins/camera3d/webpack.config.js @@ -0,0 +1,47 @@ +'use strict'; + +const webpack = require('webpack'); +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); + +module.exports = { + mode: 'production', + + context: `${__dirname}/src/`, + + entry: { + camera3d: './Camera3DPlugin.js', + 'camera3d.min': './Camera3DPlugin.js' + }, + + output: { + path: `${__dirname}/dist/`, + filename: '[name].js', + library: 'Camera3DPlugin', + libraryTarget: 'var' + }, + + performance: { hints: false }, + + optimization: { + minimizer: [ + new UglifyJSPlugin({ + include: /\.min\.js$/, + parallel: true, + sourceMap: false, + uglifyOptions: { + compress: true, + ie8: false, + ecma: 5, + output: {comments: false}, + warnings: false + }, + warningsFilter: () => false + }) + ] + }, + + plugins: [ + new CleanWebpackPlugin([ 'dist' ]) + ] +}; diff --git a/plugins/fbinstant/readme.md b/plugins/fbinstant/readme.md new file mode 100644 index 000000000..20d90d174 --- /dev/null +++ b/plugins/fbinstant/readme.md @@ -0,0 +1,84 @@ +Phaser 3 Facebook Instant Games Plugin +====================================== + +Starting with version 3.13 Phaser now has a dedicated plugin that provides complete support for Facebook Instant Games. + +If you are using the pre-built versions of Phaser then use the file `phaser-facebook-instant-games.js` which you'll find in the `dist` folder. + +If you are creating your own builds using Webpack then make sure you enable the plugin using the Webpack DefinePlugin control: + +``` +"typeof PLUGIN_FBINSTANT": JSON.stringify(true) +``` + +Building Phaser via Webpack with this set to `true` will include the plugin in the build. + +## Using the Plugin + +You need to include the Facebook SDK in your html and wait for the `initializeAsync` Promise to resolve before you should create your game instance: + +``` + + + + Phaser 3 Facebook Instant Games + + + + + + + FBInstant.initializeAsync().then(function() { + + var config = { + type: Phaser.AUTO, + width: window.innerWidth, + height: window.innerHeight, + scene: ... + }; + + new Phaser.Game(config); + + }); + + + +``` + +Now, when your game starts, you'll know that the FBInstant API is enabled and ready for use. To access the plugin use `this.facebook` from within any Scene, i.e.: + +``` +this.add.text(0, 0).setText(this.facebook.playerName); +``` + +### Preloader + +To hook your games preloader into the Facebook Instant Games loader you should use a Preloader Scene like below: + +``` +class Preloader extends Phaser.Scene { + + constructor () + { + super('Preloader'); + } + + preload () + { + this.facebook.showLoadProgress(this); + this.facebook.once('startgame', this.startGame, this); + + // Now load all of your assets + } + + startGame () + { + this.scene.start('MainMenu'); + } + +} +``` + +In the above Scene it has hooked the Facebook preloader with the Phaser Loader, so every file that loads (once you add some) will make the Facebook loader update. When the load is over it will call the `startGame` function that just changes the Scene to another one. + +Please look at the plugin documentation and the Facebook SDK documentation for more details about what features are available. diff --git a/plugins/fbinstant/src/AdInstance.js b/plugins/fbinstant/src/AdInstance.js new file mode 100644 index 000000000..fd26da692 --- /dev/null +++ b/plugins/fbinstant/src/AdInstance.js @@ -0,0 +1,26 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} AdInstance + * + * @property {any} instance - Represents an instance of an ad. + * @property {string} placementID - The Audience Network placement ID of this ad instance. + * @property {boolean} shown - Has this ad already been shown in-game? + * @property {boolean} video - Is this a video ad? + */ + +var AdInstance = function (placementID, instance, video) +{ + return { + instance: instance, + placementID: placementID, + shown: false, + video: video + }; +}; + +module.exports = AdInstance; diff --git a/plugins/fbinstant/src/FacebookInstantGamesPlugin.js b/plugins/fbinstant/src/FacebookInstantGamesPlugin.js new file mode 100644 index 000000000..21ce8c54d --- /dev/null +++ b/plugins/fbinstant/src/FacebookInstantGamesPlugin.js @@ -0,0 +1,2243 @@ +/* eslint no-console: 0 */ + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AdInstance = require('./AdInstance'); +var Class = require('../../../src/utils/Class'); +var DataManager = require('../../../src/data/DataManager'); +var EventEmitter = require('eventemitter3'); +var Leaderboard = require('./Leaderboard'); +var Product = require('./Product'); +var Purchase = require('./Purchase'); + +/** + * @classdesc + * The Facebook Instant Games Plugin for Phaser 3 provides a seamless bridge between Phaser + * and the Facebook Instant Games API version 6.2. + * + * You can access this plugin via the `facebook` property in a Scene, i.e: + * + * ```javascript + * this.facebook.getPlatform(); + * ``` + * + * If this is unavailable please check to make sure you're using a build of Phaser that has + * this plugin within it. You can quickly check this by looking at the dev tools console + * header - the Phaser version number will have `-FB` after it if this plugin is loaded. + * + * If you are building your own version of Phaser then use this Webpack DefinePlugin flag: + * + * `"typeof PLUGIN_FBINSTANT": JSON.stringify(true)` + * + * You will find that every Instant Games API method has a mapping in this plugin. + * For a full list please consult either the plugin documentation, or the 6.2 SDK documentation + * at https://developers.facebook.com/docs/games/instant-games/sdk/fbinstant6.2 + * + * Internally this plugin uses its own Data Manager to handle seamless user data updates and provides + * handy functions for advertisement displaying, opening share dialogs, logging, leaderboards, purchase API requests, + * loader integration and more. + * + * To get started with Facebook Instant Games you will need to register on Facebook and create a new Instant + * Game app that has its own unique app ID. Facebook have also provided a dashboard interface for setting up + * various features for your game, including leaderboards, ad requests and the payments API. There are lots + * of guides on the Facebook Developers portal to assist with setting these + * various systems up: https://developers.facebook.com/docs/games/instant-games/guides + * + * For more details follow the Quick Start guide here: https://developers.facebook.com/docs/games/instant-games + * + * @class FacebookInstantGamesPlugin + * @memberOf Phaser + * @constructor + * @extends Phaser.Events.EventEmitter + * @since 3.13.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance. + */ +var FacebookInstantGamesPlugin = new Class({ + + Extends: EventEmitter, + + initialize: + + function FacebookInstantGamesPlugin (game) + { + EventEmitter.call(this); + + /** + * A reference to the Phaser.Game instance. + * + * @name Phaser.FacebookInstantGamesPlugin#game + * @type {Phaser.Game} + * @readOnly + * @since 3.13.0 + */ + this.game = game; + + /** + * A Data Manager instance. + * It allows you to store, query and retrieve any key/value data you may need to store. + * It's also used internally by the plugin to store FBIG API data. + * + * @name Phaser.FacebookInstantGamesPlugin#data + * @type {Phaser.Data.DataManager} + * @since 3.13.0 + */ + this.data = new DataManager(this); + + this.on('setdata', this.setDataHandler, this); + this.on('changedata', this.changeDataHandler, this); + + /** + * Has the Facebook Instant Games API loaded yet? + * This is set automatically during the boot process. + * + * @name Phaser.FacebookInstantGamesPlugin#hasLoaded + * @type {boolean} + * @since 3.13.0 + */ + this.hasLoaded = false; + + /** + * Is the Data Manager currently locked? + * + * @name Phaser.FacebookInstantGamesPlugin#dataLocked + * @type {boolean} + * @since 3.13.0 + */ + this.dataLocked = false; + + /** + * A list of the Facebook Instant Games APIs that are available, + * based on the given platform, context and user privacy settings. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#supportedAPIs + * @type {string[]} + * @since 3.13.0 + */ + this.supportedAPIs = []; + + /** + * Holds the entry point that the game was launched from. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#entryPoint + * @type {string} + * @since 3.13.0 + */ + this.entryPoint = ''; + + /** + * An object that contains any data associated with the entry point that the game was launched from. + * The contents of the object are developer-defined, and can occur from entry points on different platforms. + * This will return null for older mobile clients, as well as when there is no data associated with the particular entry point. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#entryPointData + * @type {any} + * @since 3.13.0 + */ + this.entryPointData = null; + + /** + * A unique identifier for the current game context. This represents a specific context + * that the game is being played in (for example, a particular messenger conversation or facebook post). + * The identifier will be null if game is being played in a solo context. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#contextID + * @type {string} + * @since 3.13.0 + */ + this.contextID = null; + + /** + * The current context in which your game is running. This can be either `null` or + * one of: + * + * `POST` - The game is running inside of a Facebook post. + * `THREAD` - The game is running inside a Facebook Messenger thread. + * `GROUP` - The game is running inside a Facebook Group. + * `SOLO` - This is the default context, the player is the only participant. + * + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#contextType + * @type {?string} + * @since 3.13.0 + */ + this.contextType = null; + + /** + * The current locale. + * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. + * Use this to determine what languages the current game should be localized with. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#locale + * @type {?string} + * @since 3.13.0 + */ + this.locale = null; + + /** + * The platform on which the game is currently running, i.e. `IOS`. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#platform + * @type {?string} + * @since 3.13.0 + */ + this.platform = null; + + /** + * The string representation of the Facebook Instant Games SDK version being used. + * This value is populated automatically during boot. + * + * @name Phaser.FacebookInstantGamesPlugin#version + * @type {?string} + * @since 3.13.0 + */ + this.version = null; + + /** + * Holds the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. + * This value is populated automatically during boot if the API is supported. + * + * @name Phaser.FacebookInstantGamesPlugin#playerID + * @type {?string} + * @since 3.13.0 + */ + this.playerID = null; + + /** + * The player's localized display name. + * This value is populated automatically during boot if the API is supported. + * + * @name Phaser.FacebookInstantGamesPlugin#playerName + * @type {?string} + * @since 3.13.0 + */ + this.playerName = null; + + /** + * A url to the player's public profile photo. The photo will always be a square, and with dimensions + * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. + * It's recommended to always scale the image to a desired size before rendering. + * This value is populated automatically during boot if the API is supported. + * + * @name Phaser.FacebookInstantGamesPlugin#playerPhotoURL + * @type {?string} + * @since 3.13.0 + */ + this.playerPhotoURL = null; + + /** + * Whether a player can subscribe to the game bot or not. + * + * @name Phaser.FacebookInstantGamesPlugin#playerCanSubscribeBot + * @type {boolean} + * @since 3.13.0 + */ + this.playerCanSubscribeBot = false; + + /** + * Does the current platform and context allow for use of the payments API? + * Currently this is only available on Facebook.com and Android 6+. + * + * @name Phaser.FacebookInstantGamesPlugin#paymentsReady + * @type {boolean} + * @since 3.13.0 + */ + this.paymentsReady = false; + + /** + * The set of products that are registered to the game. + * + * @name Phaser.FacebookInstantGamesPlugin#catalog + * @type {Product[]} + * @since 3.13.0 + */ + this.catalog = []; + + /** + * Contains all of the player's unconsumed purchases. + * The game must fetch the current player's purchases as soon as the client indicates that it is ready to perform payments-related operations, + * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. + * + * @name Phaser.FacebookInstantGamesPlugin#purchases + * @type {Purchase[]} + * @since 3.13.0 + */ + this.purchases = []; + + /** + * Contains all of the leaderboard data, as populated by the `getLeaderboard()` method. + * + * @name Phaser.FacebookInstantGamesPlugin#leaderboards + * @type {Phaser.FacebookInstantGamesPlugin.Leaderboard[]} + * @since 3.13.0 + */ + this.leaderboards = {}; + + /** + * Contains AdInstance objects, as created by the `preloadAds()` method. + * + * @name Phaser.FacebookInstantGamesPlugin#ads + * @type {AdInstance[]} + * @since 3.13.0 + */ + this.ads = []; + }, + + /** + * Internal set data handler. + * + * @method Phaser.FacebookInstantGamesPlugin#setDataHandler + * @private + * @since 3.13.0 + * + * @param {Phaser.Data.DataManager} parent - The parent Data Manager instance. + * @param {string} key - The key of the data. + * @param {any} value - The value of the data. + */ + setDataHandler: function (parent, key, value) + { + if (this.dataLocked) + { + return; + } + + var data = {}; + + data[key] = value; + + var _this = this; + + FBInstant.player.setDataAsync(data).then(function () + { + _this.emit('savedata', data); + }); + }, + + /** + * Internal change data handler. + * + * @method Phaser.FacebookInstantGamesPlugin#changeDataHandler + * @private + * @since 3.13.0 + * + * @param {Phaser.Data.DataManager} parent - The parent Data Manager instance. + * @param {string} key - The key of the data. + * @param {any} value - The value of the data. + */ + changeDataHandler: function (parent, key, value) + { + if (this.dataLocked) + { + return; + } + + var data = {}; + + data[key] = value; + + var _this = this; + + FBInstant.player.setDataAsync(data).then(function () + { + _this.emit('savedata', data); + }); + }, + + /** + * Call this method from your `Scene.preload` in order to sync the load progress + * of the Phaser Loader with the Facebook Instant Games loader display, i.e.: + * + * ```javascript + * this.facebook.showLoadProgress(this); + * this.facebook.once('startgame', this.startGame, this); + * ``` + * + * @method Phaser.FacebookInstantGamesPlugin#showLoadProgress + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene for which you want to show loader progress for. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + showLoadProgress: function (scene) + { + scene.load.on('progress', function (value) + { + if (!this.hasLoaded) + { + FBInstant.setLoadingProgress(value * 100); + } + + }, this); + + scene.load.on('complete', function () + { + if (!this.hasLoaded) + { + this.hasLoaded = true; + + FBInstant.startGameAsync().then(this.gameStarted.bind(this)); + } + + }, this); + + return this; + }, + + /** + * This method is called automatically when the game has finished loading, + * if you used the `showLoadProgress` method. If your game doesn't need to + * load any assets, or you're managing the load yourself, then call this + * method directly to start the API running. + * + * When the API has finished starting this plugin will emit a `startgame` event + * which you should listen for. + * + * @method Phaser.FacebookInstantGamesPlugin#gameStarted + * @since 3.13.0 + */ + gameStarted: function () + { + var APIs = FBInstant.getSupportedAPIs(); + + var supported = {}; + + var dotToUpper = function (match) + { + return match[1].toUpperCase(); + }; + + APIs.forEach(function (api) + { + api = api.replace(/\../g, dotToUpper); + + supported[api] = true; + }); + + this.supportedAPIs = supported; + + this.getID(); + this.getType(); + this.getLocale(); + this.getPlatform(); + this.getSDKVersion(); + + this.getPlayerID(); + this.getPlayerName(); + this.getPlayerPhotoURL(); + + var _this = this; + + FBInstant.onPause(function () + { + _this.emit('pause'); + }); + + FBInstant.getEntryPointAsync().then(function (entrypoint) + { + _this.entryPoint = entrypoint; + _this.entryPointData = FBInstant.getEntryPointData(); + + _this.emit('startgame'); + + }).catch(function (e) + { + console.warn(e); + }); + + // Facebook.com and Android 6 only + if (this.supportedAPIs.paymentsPurchaseAsync) + { + FBInstant.payments.onReady(function () + { + _this.paymentsReady = true; + + }).catch(function (e) + { + console.warn(e); + }); + } + }, + + /** + * Checks to see if a given Facebook Instant Games API is available or not. + * + * @method Phaser.FacebookInstantGamesPlugin#checkAPI + * @since 3.13.0 + * + * @param {string} api - The API to check for, i.e. `player.getID`. + * + * @return {boolean} `true` if the API is supported, otherwise `false`. + */ + checkAPI: function (api) + { + if (!this.supportedAPIs[api]) + { + return false; + } + else + { + return true; + } + }, + + /** + * Returns the unique identifier for the current game context. This represents a specific context + * that the game is being played in (for example, a particular messenger conversation or facebook post). + * The identifier will be null if game is being played in a solo context. + * + * It is only populated if `contextGetID` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getID + * @since 3.13.0 + * + * @return {string} The context ID. + */ + getID: function () + { + if (!this.contextID && this.supportedAPIs.contextGetID) + { + this.contextID = FBInstant.context.getID(); + } + + return this.contextID; + }, + + /** + * Returns the current context in which your game is running. This can be either `null` or one of: + * + * `POST` - The game is running inside of a Facebook post. + * `THREAD` - The game is running inside a Facebook Messenger thread. + * `GROUP` - The game is running inside a Facebook Group. + * `SOLO` - This is the default context, the player is the only participant. + * + * It is only populated if `contextGetType` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getType + * @since 3.13.0 + * + * @return {?string} The context type. + */ + getType: function () + { + if (!this.contextType && this.supportedAPIs.contextGetType) + { + this.contextType = FBInstant.context.getType(); + } + + return this.contextType; + }, + + /** + * Returns the current locale. + * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. + * Use this to determine what languages the current game should be localized with. + * It is only populated if `getLocale` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getLocale + * @since 3.13.0 + * + * @return {?string} The current locale. + */ + getLocale: function () + { + if (!this.locale && this.supportedAPIs.getLocale) + { + this.locale = FBInstant.getLocale(); + } + + return this.locale; + }, + + /** + * Returns the platform on which the game is currently running, i.e. `IOS`. + * It is only populated if `getPlatform` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlatform + * @since 3.13.0 + * + * @return {?string} The current platform. + */ + getPlatform: function () + { + if (!this.platform && this.supportedAPIs.getPlatform) + { + this.platform = FBInstant.getPlatform(); + } + + return this.platform; + }, + + /** + * Returns the string representation of the Facebook Instant Games SDK version being used. + * It is only populated if `getSDKVersion` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getSDKVersion + * @since 3.13.0 + * + * @return {?string} The sdk version. + */ + getSDKVersion: function () + { + if (!this.version && this.supportedAPIs.getSDKVersion) + { + this.version = FBInstant.getSDKVersion(); + } + + return this.version; + }, + + /** + * Returns the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. + * It is only populated if `playerGetID` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlayerID + * @since 3.13.0 + * + * @return {?string} The player ID. + */ + getPlayerID: function () + { + if (!this.playerID && this.supportedAPIs.playerGetID) + { + this.playerID = FBInstant.player.getID(); + } + + return this.playerID; + }, + + /** + * Returns the player's localized display name. + * It is only populated if `playerGetName` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlayerName + * @since 3.13.0 + * + * @return {?string} The player's localized display name. + */ + getPlayerName: function () + { + if (!this.playerName && this.supportedAPIs.playerGetName) + { + this.playerName = FBInstant.player.getName(); + } + + return this.playerName; + }, + + /** + * Returns the url to the player's public profile photo. The photo will always be a square, and with dimensions + * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. + * It's recommended to always scale the image to a desired size before rendering. + * It is only populated if `playerGetPhoto` is in the list of supported APIs. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlayerPhotoURL + * @since 3.13.0 + * + * @return {?string} The player's photo url. + */ + getPlayerPhotoURL: function () + { + if (!this.playerPhotoURL && this.supportedAPIs.playerGetPhoto) + { + this.playerPhotoURL = FBInstant.player.getPhoto(); + } + + return this.playerPhotoURL; + }, + + /** + * Load the player's photo and store it in the Texture Manager, ready for use in-game. + * + * This method works by using a Scene Loader instance and then asking the Loader to + * retrieve the image. + * + * When complete the plugin will emit a `photocomplete` event, along with the key of the photo. + * + * ```javascript + * this.facebook.loadPlayerPhoto(this, 'player').once('photocomplete', function (key) { + * this.add.image(x, y, 'player); + * }, this); + * ``` + * + * @method Phaser.FacebookInstantGamesPlugin#loadPlayerPhoto + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene that will be responsible for loading this photo. + * @param {string} key - The key to use when storing the photo in the Texture Manager. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + loadPlayerPhoto: function (scene, key) + { + if (this.playerPhotoURL) + { + scene.load.setCORS('anonymous'); + + scene.load.image(key, this.playerPhotoURL); + + scene.load.once('filecomplete-image-' + key, function () + { + this.emit('photocomplete', key); + + }, this); + + scene.load.start(); + } + + return this; + }, + + /** + * Checks if the current player can subscribe to the game bot. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they can subscribe, the `playerCanSubscribeBot` property is set to `true` + * and this plugin will emit the `cansubscribebot` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `cansubscribebotfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#canSubscribeBot + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + canSubscribeBot: function () + { + if (this.supportedAPIs.playerCanSubscribeBotAsync) + { + var _this = this; + + FBInstant.player.canSubscribeBotAsync().then(function () + { + _this.playerCanSubscribeBot = true; + + _this.emit('cansubscribebot'); + + }).catch(function (e) + { + _this.emit('cansubscribebotfail', e); + }); + } + else + { + this.emit('cansubscribebotfail'); + } + + return this; + }, + + /** + * Subscribes the current player to the game bot. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `subscribebot` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `subscribebotfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#subscribeBot + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + subscribeBot: function () + { + if (this.playerCanSubscribeBot) + { + var _this = this; + + FBInstant.player.subscribeBotAsync().then(function () + { + _this.emit('subscribebot'); + + }).catch(function (e) + { + _this.emit('subscribebotfail', e); + }); + } + else + { + this.emit('subscribebotfail'); + } + + return this; + }, + + /** + * Gets the associated data from the player based on the given key, or array of keys. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the data is set into this plugins Data Manager and the + * `getdata` event will be emitted. + * + * @method Phaser.FacebookInstantGamesPlugin#getData + * @since 3.13.0 + * + * @param {(string|string[])} keys - The key/s of the data to retrieve. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getData: function (keys) + { + if (!this.checkAPI('playerGetDataAsync')) + { + return this; + } + + if (!Array.isArray(keys)) + { + keys = [ keys ]; + } + + var _this = this; + + FBInstant.player.getDataAsync(keys).then(function (data) + { + _this.dataLocked = true; + + for (var key in data) + { + _this.data.set(key, data[key]); + } + + _this.dataLocked = false; + + _this.emit('getdata', data); + }); + + return this; + }, + + /** + * Set data to be saved to the designated cloud storage of the current player. The game can store up to 1MB of data for each unique player. + * + * The data save is requested in an async call, so the result isn't available immediately. + * + * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this + * method directly if you need to replace the data object directly. + * + * When the APIs `setDataAsync` call resolves it will emit the `savedata` event from this plugin. If the call fails for some + * reason it will emit `savedatafail` instead. + * + * The call resolving does not necessarily mean that the input has already been persisted. Rather, it means that the data was valid and + * has been scheduled to be saved. It also guarantees that all values that were set are now available in `getData`. + * + * @method Phaser.FacebookInstantGamesPlugin#saveData + * @since 3.13.0 + * + * @param {object} data - An object containing a set of key-value pairs that should be persisted to cloud storage. + * The object must contain only serializable values - any non-serializable values will cause the entire modification to be rejected. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + saveData: function (data) + { + if (!this.checkAPI('playerSetDataAsync')) + { + return this; + } + + var _this = this; + + FBInstant.player.setDataAsync(data).then(function () + { + _this.emit('savedata', data); + + }).catch(function (e) + { + _this.emit('savedatafail', e); + }); + + return this; + }, + + /** + * Immediately flushes any changes to the player data to the designated cloud storage. + * This function is expensive, and should primarily be used for critical changes where persistence needs to be immediate + * and known by the game. Non-critical changes should rely on the platform to persist them in the background. + * NOTE: Calls to player.setDataAsync will be rejected while this function's result is pending. + * + * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this + * method directly if you need to flush the data directly. + * + * When the APIs `flushDataAsync` call resolves it will emit the `flushdata` event from this plugin. If the call fails for some + * reason it will emit `flushdatafail` instead. + * + * @method Phaser.FacebookInstantGamesPlugin#flushData + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + flushData: function () + { + if (!this.checkAPI('playerFlushDataAsync')) + { + return this; + } + + var _this = this; + + FBInstant.player.flushDataAsync().then(function () + { + _this.emit('flushdata'); + + }).catch(function (e) + { + _this.emit('flushdatafail', e); + }); + + return this; + }, + + /** + * Retrieve stats from the designated cloud storage of the current player. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `getstats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `getstatsfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#getStats + * @since 3.13.0 + * + * @param {string[]} [keys] - An optional array of unique keys to retrieve stats for. If the function is called without it, it will fetch all stats. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getStats: function (keys) + { + if (!this.checkAPI('playerGetStatsAsync')) + { + return this; + } + + var _this = this; + + FBInstant.player.getStatsAsync(keys).then(function (data) + { + _this.emit('getstats', data); + + }).catch(function (e) + { + _this.emit('getstatsfail', e); + }); + + return this; + }, + + /** + * Save the stats of the current player to the designated cloud storage. + * + * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, + * all other data types will be ignored. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `savestats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `savestatsfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#saveStats + * @since 3.13.0 + * + * @param {object} data - An object containing a set of key-value pairs that should be persisted to cloud storage as stats. Note that only numerical values are stored. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + saveStats: function (data) + { + if (!this.checkAPI('playerSetStatsAsync')) + { + return this; + } + + var output = {}; + + for (var key in data) + { + if (typeof data[key] === 'number') + { + output[key] = data[key]; + } + } + + var _this = this; + + FBInstant.player.setStatsAsync(output).then(function () + { + _this.emit('savestats', output); + + }).catch(function (e) + { + _this.emit('savestatsfail', e); + }); + + return this; + }, + + /** + * Increment the stats of the current player and save them to the designated cloud storage. + * + * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, + * all other data types will be ignored. + * + * The data object provided for this call should contain offsets for how much to modify the stats by: + * + * ```javascript + * this.facebook.incStats({ + * level: 1, + * zombiesSlain: 17, + * rank: -1 + * }); + * ``` + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `incstats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `incstatsfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#incStats + * @since 3.13.0 + * + * @param {object} data - An object containing a set of key-value pairs indicating how much to increment each stat in cloud storage. Note that only numerical values are processed. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + incStats: function (data) + { + if (!this.checkAPI('playerIncrementStatsAsync')) + { + return this; + } + + var output = {}; + + for (var key in data) + { + if (typeof data[key] === 'number') + { + output[key] = data[key]; + } + } + + var _this = this; + + FBInstant.player.incrementStatsAsync(output).then(function (stats) + { + _this.emit('incstats', stats); + + }).catch(function (e) + { + _this.emit('incstatsfail', e); + }); + + return this; + }, + + /** + * Sets the data associated with the individual gameplay session for the current context. + * + * This function should be called whenever the game would like to update the current session data. + * + * This session data may be used to populate a variety of payloads, such as game play webhooks. + * + * @method Phaser.FacebookInstantGamesPlugin#saveSession + * @since 3.13.0 + * + * @param {object} data - An arbitrary data object, which must be less than or equal to 1000 characters when stringified. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + saveSession: function (data) + { + if (!this.checkAPI('setSessionData')) + { + return this; + } + + var test = JSON.stringify(data); + + if (test.length <= 1000) + { + FBInstant.setSessionData(data); + } + else + { + console.warn('Session data too long. Max 1000 chars.'); + } + + return this; + }, + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * + * @method Phaser.FacebookInstantGamesPlugin#openShare + * @since 3.13.0 + * + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + openShare: function (text, key, frame, sessionData) + { + return this._share('SHARE', text, key, frame, sessionData); + }, + + /** + * This invokes a dialog to let the user invite a friend to play this game, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * + * @method Phaser.FacebookInstantGamesPlugin#openInvite + * @since 3.13.0 + * + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + openInvite: function (text, key, frame, sessionData) + { + return this._share('INVITE', text, key, frame, sessionData); + }, + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * + * @method Phaser.FacebookInstantGamesPlugin#openRequest + * @since 3.13.0 + * + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + openRequest: function (text, key, frame, sessionData) + { + return this._share('REQUEST', text, key, frame, sessionData); + }, + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * + * @method Phaser.FacebookInstantGamesPlugin#openChallenge + * @since 3.13.0 + * + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + openChallenge: function (text, key, frame, sessionData) + { + return this._share('CHALLENGE', text, key, frame, sessionData); + }, + + /** + * Internal share handler. + * + * @method Phaser.FacebookInstantGamesPlugin#_share + * @private + * @since 3.13.0 + * + * @param {string} intent - ("INVITE" | "REQUEST" | "CHALLENGE" | "SHARE") Indicates the intent of the share. + * @param {string} text - A text message to be shared. + * @param {string} key - The key of the texture to use as the share image. + * @param {string} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {object} [sessionData] - A blob of data to attach to the share. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + _share: function (intent, text, key, frame, sessionData) + { + if (!this.checkAPI('shareAsync')) + { + return this; + } + + if (sessionData === undefined) { sessionData = {}; } + + if (key) + { + var imageData = this.game.textures.getBase64(key, frame); + } + + // intent ("INVITE" | "REQUEST" | "CHALLENGE" | "SHARE") Indicates the intent of the share. + // image string A base64 encoded image to be shared. + // text string A text message to be shared. + // data Object? A blob of data to attach to the share. All game sessions launched from the share will be able to access this blob through FBInstant.getEntryPointData(). + + var payload = { + intent: intent, + image: imageData, + text: text, + data: sessionData + }; + + var _this = this; + + FBInstant.shareAsync(payload).then(function () + { + _this.emit('resume'); + }); + + return this; + }, + + /** + * This function determines whether the number of participants in the current game context is between a given minimum and maximum, inclusive. + * If one of the bounds is null only the other bound will be checked against. + * It will always return the original result for the first call made in a context in a given game play session. + * Subsequent calls, regardless of arguments, will return the answer to the original query until a context change occurs and the query result is reset. + * + * @method Phaser.FacebookInstantGamesPlugin#isSizeBetween + * @since 3.13.0 + * + * @param {integer} [min] - The minimum bound of the context size query. + * @param {integer} [max] - The maximum bound of the context size query. + * + * @return {object} The Context Size Response object in the format: `{answer: boolean, minSize: number?, maxSize: number?}`. + */ + isSizeBetween: function (min, max) + { + if (!this.checkAPI('contextIsSizeBetween')) + { + return this; + } + + return FBInstant.context.isSizeBetween(min, max); + }, + + /** + * Request a switch into a specific context. If the player does not have permission to enter that context, + * or if the player does not provide permission for the game to enter that context, this will emit a `switchfail` event. + * + * Otherwise, the plugin will emit the `switch` event when the game has switched into the specified context. + * + * @method Phaser.FacebookInstantGamesPlugin#switchContext + * @since 3.13.0 + * + * @param {string} contextID - The ID of the desired context. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + switchContext: function (contextID) + { + if (!this.checkAPI('contextSwitchAsync')) + { + return this; + } + + if (contextID !== this.contextID) + { + var _this = this; + + FBInstant.context.switchAsync(contextID).then(function () + { + _this.contextID = FBInstant.context.getID(); + + _this.emit('switch', _this.contextID); + + }).catch(function (e) + { + _this.emit('switchfail', e); + }); + } + + return this; + }, + + /** + * Opens a context selection dialog for the player. If the player selects an available context, + * the client will attempt to switch into that context, and emit the `choose` event if successful. + * Otherwise, if the player exits the menu or the client fails to switch into the new context, the `choosefail` event will be emitted. + * + * @method Phaser.FacebookInstantGamesPlugin#chooseContext + * @since 3.13.0 + * + * @param {string} contextID - The ID of the desired context. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + chooseContext: function (options) + { + if (!this.checkAPI('contextChoseAsync')) + { + return this; + } + + var _this = this; + + FBInstant.context.chooseAsync(options).then(function () + { + _this.contextID = FBInstant.context.getID(); + _this.emit('choose', _this.contextID); + + }).catch(function (e) + { + _this.emit('choosefail', e); + }); + + return this; + }, + + /** + * Attempts to create or switch into a context between a specified player and the current player. + * This plugin will emit the `create` event once the context switch is completed. + * If the API call fails, such as if the player listed is not a Connected Player of the current player or if the + * player does not provide permission to enter the new context, then the plugin will emit a 'createfail' event. + * + * @method Phaser.FacebookInstantGamesPlugin#createContext + * @since 3.13.0 + * + * @param {string} playerID - ID of the player. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + createContext: function (playerID) + { + if (!this.checkAPI('contextCreateAsync')) + { + return this; + } + + var _this = this; + + FBInstant.context.createAsync(playerID).then(function () + { + _this.contextID = FBInstant.context.getID(); + _this.emit('create', _this.contextID); + + }).catch(function (e) + { + _this.emit('createfail', e); + }); + + return this; + }, + + /** + * Fetches an array of ConnectedPlayer objects containing information about active players + * (people who played the game in the last 90 days) that are connected to the current player. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `players` event along + * with the player data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `playersfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#getPlayers + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getPlayers: function () + { + if (!this.checkAPI('playerGetConnectedPlayersAsync')) + { + return this; + } + + var _this = this; + + FBInstant.player.getConnectedPlayersAsync().then(function (players) + { + _this.emit('players', players); + + }).catch(function (e) + { + _this.emit('playersfail', e); + }); + + return this; + }, + + /** + * Fetches the game's product catalog. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `getcatalog` event along + * with the catalog data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `getcatalogfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#getCatalog + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getCatalog: function () + { + if (!this.paymentsReady) + { + return this; + } + + var _this = this; + var catalog = this.catalog; + + FBInstant.payments.getCatalogAsync().then(function (data) + { + catalog = []; + + data.forEach(function (item) + { + catalog.push(Product(item)); + }); + + _this.emit('getcatalog', catalog); + + }).catch(function (e) + { + _this.emit('getcatalogfail', e); + }); + + return this; + }, + + /** + * Begins the purchase flow for a specific product. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `purchase` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `purchasefail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#purchase + * @since 3.13.0 + * + * @param {string} productID - The identifier of the product to purchase. + * @param {string} [developerPayload] - An optional developer-specified payload, to be included in the returned purchase's signed request. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + purchase: function (productID, developerPayload) + { + if (!this.paymentsReady) + { + return this; + } + + var config = {productID: productID}; + + if (developerPayload) + { + config.developerPayload = developerPayload; + } + + var _this = this; + + FBInstant.payments.purchaseAsync(config).then(function (data) + { + var purchase = Purchase(data); + + _this.emit('purchase', purchase); + + }).catch(function (e) + { + _this.emit('purchasefail', e); + }); + + return this; + }, + + /** + * Fetches all of the player's unconsumed purchases. The game must fetch the current player's purchases + * as soon as the client indicates that it is ready to perform payments-related operations, + * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `getpurchases` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `getpurchasesfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#getPurchases + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getPurchases: function () + { + if (!this.paymentsReady) + { + return this; + } + + var _this = this; + var purchases = this.purchases; + + FBInstant.payments.getPurchasesAsync().then(function (data) + { + purchases = []; + + data.forEach(function (item) + { + purchases.push(Purchase(item)); + }); + + _this.emit('getpurchases', purchases); + + }).catch(function (e) + { + _this.emit('getpurchasesfail', e); + }); + + return this; + }, + + /** + * Consumes a specific purchase belonging to the current player. Before provisioning a product's effects to the player, + * the game should request the consumption of the purchased product. Once the purchase is successfully consumed, + * the game should immediately provide the player with the effects of their purchase. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `consumepurchase` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `consumepurchasefail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#consumePurchases + * @since 3.13.0 + * + * @param {string} purchaseToken - The purchase token of the purchase that should be consumed. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + consumePurchases: function (purchaseToken) + { + if (!this.paymentsReady) + { + return this; + } + + var _this = this; + + FBInstant.payments.consumePurchaseAsync(purchaseToken).then(function () + { + _this.emit('consumepurchase', purchaseToken); + + }).catch(function (e) + { + _this.emit('consumepurchasefail', e); + }); + + return this; + }, + + /** + * Informs Facebook of a custom update that occurred in the game. + * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. + * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * The `text` parameter is an update payload with the following structure: + * + * ``` + * text: { + * default: 'X just invaded Y\'s village!', + * localizations: { + * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + + * '\u0642\u0631\u064A\u0629 Y!', + * en_US: 'X just invaded Y\'s village!', + * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', + * } + * } + * ``` + * + * @method Phaser.FacebookInstantGamesPlugin#update + * @since 3.13.0 + * + * @param {string} cta - The call to action text. + * @param {object} text - The text object. + * @param {string} key - The key of the texture to use as the share image. + * @param {(string|integer)} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {string} template - The update template key. + * @param {object} updateData - The update data object payload. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + update: function (cta, text, key, frame, template, updateData) + { + return this._update('CUSTOM', cta, text, key, frame, template, updateData); + }, + + /** + * Informs Facebook of a leaderboard update that occurred in the game. + * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. + * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * The `text` parameter is an update payload with the following structure: + * + * ``` + * text: { + * default: 'X just invaded Y\'s village!', + * localizations: { + * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + + * '\u0642\u0631\u064A\u0629 Y!', + * en_US: 'X just invaded Y\'s village!', + * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', + * } + * } + * ``` + * + * @method Phaser.FacebookInstantGamesPlugin#updateLeaderboard + * @since 3.13.0 + * + * @param {string} cta - The call to action text. + * @param {object} text - The text object. + * @param {string} key - The key of the texture to use as the share image. + * @param {(string|integer)} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {string} template - The update template key. + * @param {object} updateData - The update data object payload. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + updateLeaderboard: function (cta, text, key, frame, template, updateData) + { + return this._update('LEADERBOARD', cta, text, key, frame, template, updateData); + }, + + /** + * Internal update handler. + * + * @method Phaser.FacebookInstantGamesPlugin#_update + * @private + * @since 3.13.0 + * + * @param {string} action - The update action. + * @param {string} cta - The call to action text. + * @param {object} text - The text object. + * @param {string} key - The key of the texture to use as the share image. + * @param {(string|integer)} [frame] - The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param {string} template - The update template key. + * @param {object} updateData - The update data object payload. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + _update: function (action, cta, text, key, frame, template, updateData) + { + if (!this.checkAPI('shareAsync')) + { + return this; + } + + if (cta === undefined) { cta = ''; } + + if (typeof text === 'string') + { + text = {default: text}; + } + + if (updateData === undefined) { updateData = {}; } + + if (key) + { + var imageData = this.game.textures.getBase64(key, frame); + } + + var payload = { + action: action, + cta: cta, + image: imageData, + text: text, + template: template, + data: updateData, + strategy: 'IMMEDIATE', + notification: 'NO_PUSH' + }; + + var _this = this; + + FBInstant.updateAsync(payload).then(function () + { + _this.emit('update'); + + }).catch(function (e) + { + _this.emit('updatefail', e); + }); + + return this; + }, + + /** + * Request that the client switch to a different Instant Game. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If the game switches successfully this plugin will emit the `switchgame` event and the client will load the new game. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `switchgamefail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#switchGame + * @since 3.13.0 + * + * @param {string} appID - The Application ID of the Instant Game to switch to. The application must be an Instant Game, and must belong to the same business as the current game. + * @param {object} [data] - An optional data payload. This will be set as the entrypoint data for the game being switched to. Must be less than or equal to 1000 characters when stringified. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + switchGame: function (appID, data) + { + if (!this.checkAPI('switchGameAsync')) + { + return this; + } + + if (data) + { + var test = JSON.stringify(data); + + if (test.length > 1000) + { + console.warn('Switch Game data too long. Max 1000 chars.'); + return this; + } + } + + var _this = this; + + FBInstant.switchGameAsync(appID, data).then(function () + { + _this.emit('switchgame', appID); + + }).catch(function (e) + { + _this.emit('switchgamefail', e); + }); + + return this; + }, + + /** + * Prompts the user to create a shortcut to the game if they are eligible to. + * Can only be called once per session. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If the user choose to create a shortcut this plugin will emit the `shortcutcreated` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `shortcutcreatedfail` event instead. + * + * @method Phaser.FacebookInstantGamesPlugin#createShortcut + * @since 3.13.0 + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + createShortcut: function () + { + var _this = this; + + FBInstant.canCreateShortcutAsync().then(function (canCreateShortcut) + { + if (canCreateShortcut) + { + FBInstant.createShortcutAsync().then(function () + { + _this.emit('shortcutcreated'); + + }).catch(function (e) + { + _this.emit('shortcutfailed', e); + }); + } + }); + + return this; + }, + + /** + * Quits the game. + * + * @method Phaser.FacebookInstantGamesPlugin#quit + * @since 3.13.0 + */ + quit: function () + { + FBInstant.quit(); + }, + + /** + * Log an app event with FB Analytics. + * + * See https://developers.facebook.com/docs/javascript/reference/v2.8#app_events for more details about FB Analytics. + * + * @method Phaser.FacebookInstantGamesPlugin#log + * @since 3.13.0 + * + * @param {string} name - Name of the event. Must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. + * @param {number} [value] - An optional numeric value that FB Analytics can calculate a sum with. + * @param {object} [params] - An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. Values must be less than 100 characters in length. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + log: function (name, value, params) + { + if (!this.checkAPI('logEvent')) + { + return this; + } + + if (params === undefined) { params = {}; } + + if (name.length >= 2 && name.length <= 40) + { + FBInstant.logEvent(name, parseFloat(value), params); + } + + return this; + }, + + /** + * Attempt to create an instance of an interstitial ad. + * + * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showAd()`. + * + * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter. + * + * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. + * + * @method Phaser.FacebookInstantGamesPlugin#preloadAds + * @since 3.13.0 + * + * @param {(string|string[])} placementID - The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + preloadAds: function (placementID) + { + if (!this.checkAPI('getInterstitialAdAsync')) + { + return this; + } + + if (!Array.isArray(placementID)) + { + placementID = [ placementID ]; + } + + var i; + var _this = this; + + var total = 0; + + for (i = 0; i < this.ads.length; i++) + { + if (!this.ads[i].shown) + { + total++; + } + } + + if (total + placementID.length >= 3) + { + console.warn('Too many AdInstances. Show an ad before loading more'); + return this; + } + + for (i = 0; i < placementID.length; i++) + { + var id = placementID[i]; + var data; + + FBInstant.getInterstitialAdAsync(id).then(function (interstitial) + { + data = interstitial; + + return interstitial.loadAsync(); + + }).then(function () + { + var ad = AdInstance(id, data, false); + + _this.ads.push(ad); + + _this.emit('adloaded', ad); + + }).catch(function (e) + { + if (e.code === 'ADS_NO_FILL') + { + _this.emit('adsnofill', id); + } + else if (e.code === 'ADS_FREQUENT_LOAD') + { + _this.emit('adsfrequentload', id); + } + else + { + console.warn(e); + } + }); + } + + return this; + }, + + /** + * Attempt to create an instance of an rewarded video ad. + * + * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showVideo()`. + * + * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter. + * + * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. + * + * @method Phaser.FacebookInstantGamesPlugin#preloadVideoAds + * @since 3.13.0 + * + * @param {(string|string[])} placementID - The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + preloadVideoAds: function (placementID) + { + if (!this.checkAPI('getRewardedVideoAsync')) + { + return this; + } + + if (!Array.isArray(placementID)) + { + placementID = [ placementID ]; + } + + var i; + var _this = this; + + var total = 0; + + for (i = 0; i < this.ads.length; i++) + { + if (!this.ads[i].shown) + { + total++; + } + } + + if (total + placementID.length >= 3) + { + console.warn('Too many AdInstances. Show an ad before loading more'); + return this; + } + + for (i = 0; i < placementID.length; i++) + { + var id = placementID[i]; + var data; + + FBInstant.getRewardedVideoAsync(id).then(function (reward) + { + data = reward; + + return reward.loadAsync(); + + }).then(function () + { + var ad = AdInstance(id, data, true); + + _this.ads.push(ad); + + _this.emit('adloaded', ad); + + }).catch(function (e) + { + if (e.code === 'ADS_NO_FILL') + { + _this.emit('adsnofill', id); + } + else if (e.code === 'ADS_FREQUENT_LOAD') + { + _this.emit('adsfrequentload', id); + } + else + { + console.warn(e); + } + }); + } + + return this; + }, + + /** + * Displays a previously loaded interstitial ad. + * + * If the ad is successfully displayed this plugin will emit the `adfinished` event, with the AdInstance object as its parameter. + * + * If the ad cannot be displayed, it will emit the `adsnotloaded` event. + * + * @method Phaser.FacebookInstantGamesPlugin#showAd + * @since 3.13.0 + * + * @param {string} placementID - The ad placement ID to display. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + showAd: function (placementID) + { + var _this = this; + + for (var i = 0; i < this.ads.length; i++) + { + var ad = this.ads[i]; + + if (ad.placementID === placementID) + { + ad.instance.showAsync().then(function () + { + ad.shown = true; + + _this.emit('adfinished', ad); + + }).catch(function (e) + { + if (e.code === 'ADS_NOT_LOADED') + { + _this.emit('adsnotloaded', ad); + } + else if (e.code === 'RATE_LIMITED') + { + _this.emit('adratelimited', ad); + } + + _this.emit('adshowerror', e, ad); + }); + } + } + + return this; + }, + + /** + * Displays a previously loaded interstitial video ad. + * + * If the ad is successfully displayed this plugin will emit the `adfinished` event, with the AdInstance object as its parameter. + * + * If the ad cannot be displayed, it will emit the `adsnotloaded` event. + * + * @method Phaser.FacebookInstantGamesPlugin#showVideo + * @since 3.13.0 + * + * @param {string} placementID - The ad placement ID to display. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + showVideo: function (placementID) + { + var _this = this; + + for (var i = 0; i < this.ads.length; i++) + { + var ad = this.ads[i]; + + if (ad.placementID === placementID && ad.video) + { + ad.instance.showAsync().then(function () + { + ad.shown = true; + + _this.emit('adfinished', ad); + + }).catch(function (e) + { + if (e.code === 'ADS_NOT_LOADED') + { + _this.emit('adsnotloaded', ad); + } + else if (e.code === 'RATE_LIMITED') + { + _this.emit('adratelimited', ad); + } + + _this.emit('adshowerror', e, ad); + }); + } + } + + return this; + }, + + /** + * Attempts to match the current player with other users looking for people to play with. + * If successful, a new Messenger group thread will be created containing the matched players and the player will + * be context switched to that thread. This plugin will also dispatch the `matchplayer` event, containing the new context ID and Type. + * + * The default minimum and maximum number of players in one matched thread are 2 and 20 respectively, + * depending on how many players are trying to get matched around the same time. + * + * The values can be changed in `fbapp-config.json`. See the Bundle Config documentation for documentation about `fbapp-config.json`. + * + * @method Phaser.FacebookInstantGamesPlugin#matchPlayer + * @since 3.13.0 + * + * @param {string} [matchTag] - Optional extra information about the player used to group them with similar players. Players will only be grouped with other players with exactly the same tag. The tag must only include letters, numbers, and underscores and be 100 characters or less in length. + * @param {boolean} [switchImmediately=false] - Optional extra parameter that specifies whether the player should be immediately switched to the new context when a match is found. By default this will be false which will mean the player needs explicitly press play after being matched to switch to the new context. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + matchPlayer: function (matchTag, switchImmediately) + { + if (matchTag === undefined) { matchTag = null; } + if (switchImmediately === undefined) { switchImmediately = false; } + + if (!this.checkAPI('matchPlayerAsync')) + { + return this; + } + + var _this = this; + + FBInstant.matchPlayerAsync(matchTag, switchImmediately).then(function () + { + _this.getID(); + _this.getType(); + + _this.emit('matchplayer', _this.contextID, _this.contextType); + }); + + return this; + }, + + /** + * Fetch a specific leaderboard belonging to this Instant Game. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `getleaderboard` event will be emitted along with a Leaderboard object instance. + * + * @method Phaser.FacebookInstantGamesPlugin#getLeaderboard + * @since 3.13.0 + * + * @param {string} name - The name of the leaderboard. Each leaderboard for an Instant Game must have its own distinct name. + * + * @return {this} This Facebook Instant Games Plugin instance. + */ + getLeaderboard: function (name) + { + if (!this.checkAPI('getLeaderboardAsync')) + { + return this; + } + + var _this = this; + + FBInstant.getLeaderboardAsync(name).then(function (data) + { + var leaderboard = new Leaderboard(_this, data); + + _this.leaderboards[name] = leaderboard; + + _this.emit('getleaderboard', leaderboard); + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + }, + + /** + * Quits the Facebook API and then destroys this plugin. + * + * @method Phaser.FacebookInstantGamesPlugin#destroy + * @since 3.13.0 + */ + destroy: function () + { + FBInstant.quit(); + + this.data.destroy(); + + this.removeAllListeners(); + + this.catalog = []; + this.purchases = []; + this.leaderboards = []; + this.ads = []; + + this.game = null; + } + +}); + +module.exports = FacebookInstantGamesPlugin; diff --git a/plugins/fbinstant/src/Leaderboard.js b/plugins/fbinstant/src/Leaderboard.js new file mode 100644 index 000000000..b20070766 --- /dev/null +++ b/plugins/fbinstant/src/Leaderboard.js @@ -0,0 +1,313 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../src/utils/Class'); +var EventEmitter = require('eventemitter3'); +var LeaderboardScore = require('./LeaderboardScore'); + +/** + * @classdesc + * This class represents one single Leaderboard that belongs to a Facebook Instant Game. + * + * You do not need to instantiate this class directly, it will be created when you use the + * `getLeaderboard()` method of the main plugin. + * + * @class Leaderboard + * @memberOf Phaser.FacebookInstantGamesPlugin + * @constructor + * @since 3.13.0 + * + * @param {Phaser.FacebookInstantGamesPlugin} plugin - A reference to the Facebook Instant Games Plugin. + * @param {any} data - An Instant Game leaderboard instance. + */ +var Leaderboard = new Class({ + + Extends: EventEmitter, + + initialize: + + function Leaderboard (plugin, data) + { + EventEmitter.call(this); + + /** + * A reference to the Facebook Instant Games Plugin. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#plugin + * @type {Phaser.FacebookInstantGamesPlugin} + * @since 3.13.0 + */ + this.plugin = plugin; + + /** + * An Instant Game leaderboard instance. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#ref + * @type {any} + * @since 3.13.0 + */ + this.ref = data; + + /** + * The name of the leaderboard. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#name + * @type {string} + * @since 3.13.0 + */ + this.name = data.getName(); + + /** + * The ID of the context that the leaderboard is associated with, or null if the leaderboard is not tied to a particular context. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#contextID + * @type {string} + * @since 3.13.0 + */ + this.contextID = data.getContextID(); + + /** + * The total number of player entries in the leaderboard. + * This value defaults to zero. Populate it via the `getEntryCount()` method. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#entryCount + * @type {integer} + * @since 3.13.0 + */ + this.entryCount = 0; + + /** + * The players score object. + * This value defaults to `null`. Populate it via the `getPlayerScore()` method. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#playerScore + * @type {LeaderboardScore} + * @since 3.13.0 + */ + this.playerScore = null; + + /** + * The scores in the Leaderboard from the currently requested range. + * This value defaults to an empty array. Populate it via the `getScores()` method. + * The contents of this array are reset each time `getScores()` is called. + * + * @name Phaser.FacebookInstantGamesPlugin.Leaderboard#scores + * @type {LeaderboardScore[]} + * @since 3.13.0 + */ + this.scores = []; + + this.getEntryCount(); + }, + + /** + * Fetches the total number of player entries in the leaderboard. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getentrycount` event along with the count and name of the Leaderboard. + * + * @method Phaser.FacebookInstantGamesPlugin.Leaderboard#getEntryCount + * @since 3.13.0 + * + * @return {this} This Leaderboard instance. + */ + getEntryCount: function () + { + var _this = this; + + this.ref.getEntryCountAsync().then(function (count) + { + _this.entryCount = count; + + _this.emit('getentrycount', count, _this.name); + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + }, + + /** + * Updates the player's score. If the player has an existing score, the old score will only be replaced if the new score is better than it. + * NOTE: If the leaderboard is associated with a specific context, the game must be in that context to set a score for the player. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `setscore` event along with the LeaderboardScore object and the name of the Leaderboard. + * + * If the save fails the event will send `null` as the score value. + * + * @method Phaser.FacebookInstantGamesPlugin.Leaderboard#setScore + * @since 3.13.0 + * + * @param {integer} score - The new score for the player. Must be a 64-bit integer number. + * @param {(string|any)} [data] - Metadata to associate with the stored score. Must be less than 2KB in size. If an object is given it will be passed to `JSON.stringify`. + * + * @return {this} This Leaderboard instance. + */ + setScore: function (score, data) + { + if (data === undefined) { data = ''; } + + if (typeof data === 'object') + { + data = JSON.stringify(data); + } + + var _this = this; + + this.ref.setScoreAsync(score, data).then(function (entry) + { + if (entry) + { + var score = LeaderboardScore(entry); + + _this.playerScore = score; + + _this.emit('setscore', score, _this.name); + } + else + { + _this.emit('setscore', null, _this.name); + } + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + }, + + /** + * Gets the players leaderboard entry and stores it in the `playerScore` property. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getplayerscore` event along with the score and the name of the Leaderboard. + * + * If the player has not yet saved a score, the event will send `null` as the score value, and `playerScore` will be set to `null` as well. + * + * @method Phaser.FacebookInstantGamesPlugin.Leaderboard#getPlayerScore + * @since 3.13.0 + * + * @return {this} This Leaderboard instance. + */ + getPlayerScore: function () + { + var _this = this; + + this.ref.getPlayerEntryAsync().then(function (entry) + { + if (entry) + { + var score = LeaderboardScore(entry); + + _this.playerScore = score; + + _this.emit('getplayerscore', score, _this.name); + } + else + { + _this.emit('getplayerscore', null, _this.name); + } + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + }, + + /** + * Retrieves a set of leaderboard entries, ordered by score ranking in the leaderboard. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard. + * + * @method Phaser.FacebookInstantGamesPlugin.Leaderboard#getScores + * @since 3.13.0 + * + * @param {integer} [count=10] - The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query. + * @param {integer} [offset=0] - The offset from the top of the leaderboard that entries will be fetched from. + * + * @return {this} This Leaderboard instance. + */ + getScores: function (count, offset) + { + if (count === undefined) { count = 10; } + if (offset === undefined) { offset = 0; } + + var _this = this; + + this.ref.getEntriesAsync().then(function (entries) + { + _this.scores = []; + + entries.forEach(function (entry) + { + _this.scores.push(LeaderboardScore(entry)); + }); + + _this.emit('getscores', _this.scores, _this.name); + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + }, + + /** + * Retrieves a set of leaderboard entries, based on the current player's connected players (including the current player), ordered by local rank within the set of connected players. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getconnectedscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard. + * + * @method Phaser.FacebookInstantGamesPlugin.Leaderboard#getConnectedScores + * @since 3.16.0 + * + * @param {integer} [count=10] - The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query. + * @param {integer} [offset=0] - The offset from the top of the leaderboard that entries will be fetched from. + * + * @return {this} This Leaderboard instance. + */ + getConnectedScores: function (count, offset) + { + if (count === undefined) { count = 10; } + if (offset === undefined) { offset = 0; } + + var _this = this; + + this.ref.getConnectedPlayerEntriesAsync().then(function (entries) + { + _this.scores = []; + + entries.forEach(function (entry) + { + _this.scores.push(LeaderboardScore(entry)); + }); + + _this.emit('getconnectedscores', _this.scores, _this.name); + + }).catch(function (e) + { + console.warn(e); + }); + + return this; + } + +}); + +module.exports = Leaderboard; diff --git a/plugins/fbinstant/src/LeaderboardScore.js b/plugins/fbinstant/src/LeaderboardScore.js new file mode 100644 index 000000000..4c0befb44 --- /dev/null +++ b/plugins/fbinstant/src/LeaderboardScore.js @@ -0,0 +1,34 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} LeaderboardScore + * + * @property {integer} score - An integer score value. + * @property {string} scoreFormatted - The score value, formatted with the score format associated with the leaderboard. + * @property {integer} timestamp - The Unix timestamp of when the leaderboard entry was last updated. + * @property {integer} rank - The entry's leaderboard ranking. + * @property {string} data - The developer-specified payload associated with the score, or null if one was not set. + * @property {string} playerName - The player's localized display name. + * @property {string} playerPhotoURL - A url to the player's public profile photo. + * @property {string} playerID - The game's unique identifier for the player. + */ + +var LeaderboardScore = function (entry) +{ + return { + score: entry.getScore(), + scoreFormatted: entry.getFormattedScore(), + timestamp: entry.getTimestamp(), + rank: entry.getRank(), + data: entry.getExtraData(), + playerName: entry.getPlayer().getName(), + playerPhotoURL: entry.getPlayer().getPhoto(), + playerID: entry.getPlayer().getID() + }; +}; + +module.exports = LeaderboardScore; diff --git a/plugins/fbinstant/src/Product.js b/plugins/fbinstant/src/Product.js new file mode 100644 index 000000000..3fc1e047c --- /dev/null +++ b/plugins/fbinstant/src/Product.js @@ -0,0 +1,32 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = require('../../../src/utils/object/GetFastValue'); + +/** + * @typedef {object} Product + * + * @property {string} [title] - The title of the product. + * @property {string} [productID] - The product's game-specified identifier. + * @property {string} [description] - The product description. + * @property {string} [imageURI] - A link to the product's associated image. + * @property {string} [price] - The price of the product. + * @property {string} [priceCurrencyCode] - The currency code for the product. + */ + +var Product = function (data) +{ + return { + title: GetFastValue(data, 'title', ''), + productID: GetFastValue(data, 'productID', ''), + description: GetFastValue(data, 'description', ''), + imageURI: GetFastValue(data, 'imageURI', ''), + price: GetFastValue(data, 'price', ''), + priceCurrencyCode: GetFastValue(data, 'priceCurrencyCode', '') + }; +}; + +module.exports = Product; diff --git a/plugins/fbinstant/src/Purchase.js b/plugins/fbinstant/src/Purchase.js new file mode 100644 index 000000000..da0a9d0a0 --- /dev/null +++ b/plugins/fbinstant/src/Purchase.js @@ -0,0 +1,32 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetFastValue = require('../../../src/utils/object/GetFastValue'); + +/** + * @typedef {object} Purchase + * + * @property {string} [developerPayload] - A developer-specified string, provided during the purchase of the product. + * @property {string} [paymentID] - The identifier for the purchase transaction. + * @property {string} [productID] - The product's game-specified identifier. + * @property {string} [purchaseTime] - Unix timestamp of when the purchase occurred. + * @property {string} [purchaseToken] - A token representing the purchase that may be used to consume the purchase. + * @property {string} [signedRequest] - Server-signed encoding of the purchase request. + */ + +var Purchase = function (data) +{ + return { + developerPayload: GetFastValue(data, 'developerPayload', ''), + paymentID: GetFastValue(data, 'paymentID', ''), + productID: GetFastValue(data, 'productID', ''), + purchaseTime: GetFastValue(data, 'purchaseTime', ''), + purchaseToken: GetFastValue(data, 'purchaseToken', ''), + signedRequest: GetFastValue(data, 'signedRequest', '') + }; +}; + +module.exports = Purchase; diff --git a/plugins/spine/copy-to-examples.js b/plugins/spine/copy-to-examples.js new file mode 100644 index 000000000..e4efae47b --- /dev/null +++ b/plugins/spine/copy-to-examples.js @@ -0,0 +1,13 @@ +var fs = require('fs-extra'); + +var source = './plugins/spine/dist/'; +var dest = '../phaser3-examples/public/plugins/'; + +if (fs.existsSync(dest)) +{ + fs.copySync(source, dest, { overwrite: true }); +} +else +{ + console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples'); +} diff --git a/plugins/spine/dist/SpineWebGLPlugin.js b/plugins/spine/dist/SpineWebGLPlugin.js new file mode 100644 index 000000000..1f028d3c2 --- /dev/null +++ b/plugins/spine/dist/SpineWebGLPlugin.js @@ -0,0 +1,19720 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define("SpineWebGLPlugin", [], factory); + else if(typeof exports === 'object') + exports["SpineWebGLPlugin"] = factory(); + else + root["SpineWebGLPlugin"] = factory(); +})(window, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./SpineWebGLPlugin.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "../../../node_modules/eventemitter3/index.js": +/*!*******************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/node_modules/eventemitter3/index.js ***! + \*******************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var has = Object.prototype.hasOwnProperty + , prefix = '~'; + +/** + * Constructor to create a storage for our `EE` objects. + * An `Events` instance is a plain object whose properties are event names. + * + * @constructor + * @private + */ +function Events() {} + +// +// We try to not inherit from `Object.prototype`. In some engines creating an +// instance in this way is faster than calling `Object.create(null)` directly. +// If `Object.create(null)` is not supported we prefix the event names with a +// character to make sure that the built-in object properties are not +// overridden or used as an attack vector. +// +if (Object.create) { + Events.prototype = Object.create(null); + + // + // This hack is needed because the `__proto__` property is still inherited in + // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. + // + if (!new Events().__proto__) prefix = false; +} + +/** + * Representation of a single event listener. + * + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} [once=false] Specify if the listener is a one-time listener. + * @constructor + * @private + */ +function EE(fn, context, once) { + this.fn = fn; + this.context = context; + this.once = once || false; +} + +/** + * Add a listener for a given event. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} context The context to invoke the listener with. + * @param {Boolean} once Specify if the listener is a one-time listener. + * @returns {EventEmitter} + * @private + */ +function addListener(emitter, event, fn, context, once) { + if (typeof fn !== 'function') { + throw new TypeError('The listener must be a function'); + } + + var listener = new EE(fn, context || emitter, once) + , evt = prefix ? prefix + event : event; + + if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++; + else if (!emitter._events[evt].fn) emitter._events[evt].push(listener); + else emitter._events[evt] = [emitter._events[evt], listener]; + + return emitter; +} + +/** + * Clear event by name. + * + * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. + * @param {(String|Symbol)} evt The Event name. + * @private + */ +function clearEvent(emitter, evt) { + if (--emitter._eventsCount === 0) emitter._events = new Events(); + else delete emitter._events[evt]; +} + +/** + * Minimal `EventEmitter` interface that is molded against the Node.js + * `EventEmitter` interface. + * + * @constructor + * @public + */ +function EventEmitter() { + this._events = new Events(); + this._eventsCount = 0; +} + +/** + * Return an array listing the events for which the emitter has registered + * listeners. + * + * @returns {Array} + * @public + */ +EventEmitter.prototype.eventNames = function eventNames() { + var names = [] + , events + , name; + + if (this._eventsCount === 0) return names; + + for (name in (events = this._events)) { + if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); + } + + if (Object.getOwnPropertySymbols) { + return names.concat(Object.getOwnPropertySymbols(events)); + } + + return names; +}; + +/** + * Return the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Array} The registered listeners. + * @public + */ +EventEmitter.prototype.listeners = function listeners(event) { + var evt = prefix ? prefix + event : event + , handlers = this._events[evt]; + + if (!handlers) return []; + if (handlers.fn) return [handlers.fn]; + + for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { + ee[i] = handlers[i].fn; + } + + return ee; +}; + +/** + * Return the number of listeners listening to a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Number} The number of listeners. + * @public + */ +EventEmitter.prototype.listenerCount = function listenerCount(event) { + var evt = prefix ? prefix + event : event + , listeners = this._events[evt]; + + if (!listeners) return 0; + if (listeners.fn) return 1; + return listeners.length; +}; + +/** + * Calls each of the listeners registered for a given event. + * + * @param {(String|Symbol)} event The event name. + * @returns {Boolean} `true` if the event had listeners, else `false`. + * @public + */ +EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return false; + + var listeners = this._events[evt] + , len = arguments.length + , args + , i; + + if (listeners.fn) { + if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); + + switch (len) { + case 1: return listeners.fn.call(listeners.context), true; + case 2: return listeners.fn.call(listeners.context, a1), true; + case 3: return listeners.fn.call(listeners.context, a1, a2), true; + case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; + case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; + case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; + } + + for (i = 1, args = new Array(len -1); i < len; i++) { + args[i - 1] = arguments[i]; + } + + listeners.fn.apply(listeners.context, args); + } else { + var length = listeners.length + , j; + + for (i = 0; i < length; i++) { + if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); + + switch (len) { + case 1: listeners[i].fn.call(listeners[i].context); break; + case 2: listeners[i].fn.call(listeners[i].context, a1); break; + case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; + case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; + default: + if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { + args[j - 1] = arguments[j]; + } + + listeners[i].fn.apply(listeners[i].context, args); + } + } + } + + return true; +}; + +/** + * Add a listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.on = function on(event, fn, context) { + return addListener(this, event, fn, context, false); +}; + +/** + * Add a one-time listener for a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn The listener function. + * @param {*} [context=this] The context to invoke the listener with. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.once = function once(event, fn, context) { + return addListener(this, event, fn, context, true); +}; + +/** + * Remove the listeners of a given event. + * + * @param {(String|Symbol)} event The event name. + * @param {Function} fn Only remove the listeners that match this function. + * @param {*} context Only remove the listeners that have this context. + * @param {Boolean} once Only remove one-time listeners. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { + var evt = prefix ? prefix + event : event; + + if (!this._events[evt]) return this; + if (!fn) { + clearEvent(this, evt); + return this; + } + + var listeners = this._events[evt]; + + if (listeners.fn) { + if ( + listeners.fn === fn && + (!once || listeners.once) && + (!context || listeners.context === context) + ) { + clearEvent(this, evt); + } + } else { + for (var i = 0, events = [], length = listeners.length; i < length; i++) { + if ( + listeners[i].fn !== fn || + (once && !listeners[i].once) || + (context && listeners[i].context !== context) + ) { + events.push(listeners[i]); + } + } + + // + // Reset the array, or remove it completely if we have no more listeners. + // + if (events.length) this._events[evt] = events.length === 1 ? events[0] : events; + else clearEvent(this, evt); + } + + return this; +}; + +/** + * Remove all listeners, or those of the specified event. + * + * @param {(String|Symbol)} [event] The event name. + * @returns {EventEmitter} `this`. + * @public + */ +EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { + var evt; + + if (event) { + evt = prefix ? prefix + event : event; + if (this._events[evt]) clearEvent(this, evt); + } else { + this._events = new Events(); + this._eventsCount = 0; + } + + return this; +}; + +// +// Alias methods names because people roll like that. +// +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; +EventEmitter.prototype.addListener = EventEmitter.prototype.on; + +// +// Expose the prefix. +// +EventEmitter.prefixed = prefix; + +// +// Allow `EventEmitter` to be imported as module namespace. +// +EventEmitter.EventEmitter = EventEmitter; + +// +// Expose the module. +// +if (true) { + module.exports = EventEmitter; +} + + +/***/ }), + +/***/ "../../../src/data/DataManager.js": +/*!*******************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/data/DataManager.js ***! + \*******************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../utils/Class */ "../../../src/utils/Class.js"); + +/** + * @callback DataEachCallback + * + * @param {*} parent - The parent object of the DataManager. + * @param {string} key - The key of the value. + * @param {*} value - The value. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + */ + +/** + * @classdesc + * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, + * or have a property called `events` that is an instance of it. + * + * @class DataManager + * @memberof Phaser.Data + * @constructor + * @since 3.0.0 + * + * @param {object} parent - The object that this DataManager belongs to. + * @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter. + */ +var DataManager = new Class({ + + initialize: + + function DataManager (parent, eventEmitter) + { + /** + * The object that this DataManager belongs to. + * + * @name Phaser.Data.DataManager#parent + * @type {*} + * @since 3.0.0 + */ + this.parent = parent; + + /** + * The DataManager's event emitter. + * + * @name Phaser.Data.DataManager#events + * @type {Phaser.Events.EventEmitter} + * @since 3.0.0 + */ + this.events = eventEmitter; + + if (!eventEmitter) + { + this.events = (parent.events) ? parent.events : parent; + } + + /** + * The data list. + * + * @name Phaser.Data.DataManager#list + * @type {Object.} + * @default {} + * @since 3.0.0 + */ + this.list = {}; + + /** + * The public values list. You can use this to access anything you have stored + * in this Data Manager. For example, if you set a value called `gold` you can + * access it via: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also modify it directly: + * + * ```javascript + * this.data.values.gold += 1000; + * ``` + * + * Doing so will emit a `setdata` event from the parent of this Data Manager. + * + * Do not modify this object directly. Adding properties directly to this object will not + * emit any events. Always use `DataManager.set` to create new items the first time around. + * + * @name Phaser.Data.DataManager#values + * @type {Object.} + * @default {} + * @since 3.10.0 + */ + this.values = {}; + + /** + * Whether setting data is frozen for this DataManager. + * + * @name Phaser.Data.DataManager#_frozen + * @type {boolean} + * @private + * @default false + * @since 3.0.0 + */ + this._frozen = false; + + if (!parent.hasOwnProperty('sys') && this.events) + { + this.events.once('destroy', this.destroy, this); + } + }, + + /** + * Retrieves the value for the given key, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * this.data.get('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * this.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * this.data.get([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.Data.DataManager#get + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + get: function (key) + { + var list = this.list; + + if (Array.isArray(key)) + { + var output = []; + + for (var i = 0; i < key.length; i++) + { + output.push(list[key[i]]); + } + + return output; + } + else + { + return list[key]; + } + }, + + /** + * Retrieves all data values in a new object. + * + * @method Phaser.Data.DataManager#getAll + * @since 3.0.0 + * + * @return {Object.} All data values. + */ + getAll: function () + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Queries the DataManager for the values of keys matching the given regular expression. + * + * @method Phaser.Data.DataManager#query + * @since 3.0.0 + * + * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj). + * + * @return {Object.} The values of the keys matching the search string. + */ + query: function (search) + { + var results = {}; + + for (var key in this.list) + { + if (this.list.hasOwnProperty(key) && key.match(search)) + { + results[key] = this.list[key]; + } + } + + return results; + }, + + /** + * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * data.set('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `get`: + * + * ```javascript + * data.get('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#set + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + set: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (typeof key === 'string') + { + return this.setValue(key, data); + } + else + { + for (var entry in key) + { + this.setValue(entry, key[entry]); + } + } + + return this; + }, + + /** + * Internal value setter, called automatically by the `set` method. + * + * @method Phaser.Data.DataManager#setValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * @param {*} data - The value to set. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setValue: function (key, data) + { + if (this._frozen) + { + return this; + } + + if (this.has(key)) + { + // Hit the key getter, which will in turn emit the events. + this.values[key] = data; + } + else + { + var _this = this; + var list = this.list; + var events = this.events; + var parent = this.parent; + + Object.defineProperty(this.values, key, { + + enumerable: true, + + configurable: true, + + get: function () + { + return list[key]; + }, + + set: function (value) + { + if (!_this._frozen) + { + var previousValue = list[key]; + list[key] = value; + + events.emit('changedata', parent, key, value, previousValue); + events.emit('changedata_' + key, parent, value, previousValue); + } + } + + }); + + list[key] = data; + + events.emit('setdata', parent, key, data); + } + + return this; + }, + + /** + * Passes all data entries to the given callback. + * + * @method Phaser.Data.DataManager#each + * @since 3.0.0 + * + * @param {DataEachCallback} callback - The function to call. + * @param {*} [context] - Value to use as `this` when executing callback. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + each: function (callback, context) + { + var args = [ this.parent, null, undefined ]; + + for (var i = 1; i < arguments.length; i++) + { + args.push(arguments[i]); + } + + for (var key in this.list) + { + args[1] = key; + args[2] = this.list[key]; + + callback.apply(context, args); + } + + return this; + }, + + /** + * Merge the given object of key value pairs into this DataManager. + * + * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument) + * will emit a `changedata` event. + * + * @method Phaser.Data.DataManager#merge + * @since 3.0.0 + * + * @param {Object.} data - The data to merge. + * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + merge: function (data, overwrite) + { + if (overwrite === undefined) { overwrite = true; } + + // Merge data from another component into this one + for (var key in data) + { + if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key)))) + { + this.setValue(key, data[key]); + } + } + + return this; + }, + + /** + * Remove the value for the given key. + * + * If the key is found in this Data Manager it is removed from the internal lists and a + * `removedata` event is emitted. + * + * You can also pass in an array of keys, in which case all keys in the array will be removed: + * + * ```javascript + * this.data.remove([ 'gold', 'armor', 'health' ]); + * ``` + * + * @method Phaser.Data.DataManager#remove + * @since 3.0.0 + * + * @param {(string|string[])} key - The key to remove, or an array of keys to remove. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + remove: function (key) + { + if (this._frozen) + { + return this; + } + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + this.removeValue(key[i]); + } + } + else + { + return this.removeValue(key); + } + + return this; + }, + + /** + * Internal value remover, called automatically by the `remove` method. + * + * @method Phaser.Data.DataManager#removeValue + * @private + * @since 3.10.0 + * + * @param {string} key - The key to set the value for. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + removeValue: function (key) + { + if (this.has(key)) + { + var data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this.parent, key, data); + } + + return this; + }, + + /** + * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it. + * + * @method Phaser.Data.DataManager#pop + * @since 3.0.0 + * + * @param {string} key - The key of the value to retrieve and delete. + * + * @return {*} The value of the given key. + */ + pop: function (key) + { + var data = undefined; + + if (!this._frozen && this.has(key)) + { + data = this.list[key]; + + delete this.list[key]; + delete this.values[key]; + + this.events.emit('removedata', this, key, data); + } + + return data; + }, + + /** + * Determines whether the given key is set in this Data Manager. + * + * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.Data.DataManager#has + * @since 3.0.0 + * + * @param {string} key - The key to check. + * + * @return {boolean} Returns `true` if the key exists, otherwise `false`. + */ + has: function (key) + { + return this.list.hasOwnProperty(key); + }, + + /** + * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts + * to create new values or update existing ones. + * + * @method Phaser.Data.DataManager#setFreeze + * @since 3.0.0 + * + * @param {boolean} value - Whether to freeze or unfreeze the Data Manager. + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + setFreeze: function (value) + { + this._frozen = value; + + return this; + }, + + /** + * Delete all data in this Data Manager and unfreeze it. + * + * @method Phaser.Data.DataManager#reset + * @since 3.0.0 + * + * @return {Phaser.Data.DataManager} This DataManager object. + */ + reset: function () + { + for (var key in this.list) + { + delete this.list[key]; + delete this.values[key]; + } + + this._frozen = false; + + return this; + }, + + /** + * Destroy this data manager. + * + * @method Phaser.Data.DataManager#destroy + * @since 3.0.0 + */ + destroy: function () + { + this.reset(); + + this.events.off('changedata'); + this.events.off('setdata'); + this.events.off('removedata'); + + this.parent = null; + }, + + /** + * Gets or sets the frozen state of this Data Manager. + * A frozen Data Manager will block all attempts to create new values or update existing ones. + * + * @name Phaser.Data.DataManager#freeze + * @type {boolean} + * @since 3.0.0 + */ + freeze: { + + get: function () + { + return this._frozen; + }, + + set: function (value) + { + this._frozen = (value) ? true : false; + } + + }, + + /** + * Return the total number of entries in this Data Manager. + * + * @name Phaser.Data.DataManager#count + * @type {integer} + * @since 3.0.0 + */ + count: { + + get: function () + { + var i = 0; + + for (var key in this.list) + { + if (this.list[key] !== undefined) + { + i++; + } + } + + return i; + } + + } + +}); + +module.exports = DataManager; + + +/***/ }), + +/***/ "../../../src/gameobjects/GameObject.js": +/*!*************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/GameObject.js ***! + \*************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../utils/Class */ "../../../src/utils/Class.js"); +var ComponentsToJSON = __webpack_require__(/*! ./components/ToJSON */ "../../../src/gameobjects/components/ToJSON.js"); +var DataManager = __webpack_require__(/*! ../data/DataManager */ "../../../src/data/DataManager.js"); +var EventEmitter = __webpack_require__(/*! eventemitter3 */ "../../../node_modules/eventemitter3/index.js"); + +/** + * @classdesc + * The base class that all Game Objects extend. + * You don't create GameObjects directly and they cannot be added to the display list. + * Instead, use them as the base for your own custom classes. + * + * @class GameObject + * @memberof Phaser.GameObjects + * @extends Phaser.Events.EventEmitter + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. + * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`. + */ +var GameObject = new Class({ + + Extends: EventEmitter, + + initialize: + + function GameObject (scene, type) + { + EventEmitter.call(this); + + /** + * The Scene to which this Game Object belongs. + * Game Objects can only belong to one Scene. + * + * @name Phaser.GameObjects.GameObject#scene + * @type {Phaser.Scene} + * @protected + * @since 3.0.0 + */ + this.scene = scene; + + /** + * A textual representation of this Game Object, i.e. `sprite`. + * Used internally by Phaser but is available for your own custom classes to populate. + * + * @name Phaser.GameObjects.GameObject#type + * @type {string} + * @since 3.0.0 + */ + this.type = type; + + /** + * The parent Container of this Game Object, if it has one. + * + * @name Phaser.GameObjects.GameObject#parentContainer + * @type {Phaser.GameObjects.Container} + * @since 3.4.0 + */ + this.parentContainer = null; + + /** + * The name of this Game Object. + * Empty by default and never populated by Phaser, this is left for developers to use. + * + * @name Phaser.GameObjects.GameObject#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The active state of this Game Object. + * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it. + * An active object is one which is having its logic and internal systems updated. + * + * @name Phaser.GameObjects.GameObject#active + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.active = true; + + /** + * The Tab Index of the Game Object. + * Reserved for future use by plugins and the Input Manager. + * + * @name Phaser.GameObjects.GameObject#tabIndex + * @type {integer} + * @default -1 + * @since 3.0.0 + */ + this.tabIndex = -1; + + /** + * A Data Manager. + * It allows you to store, query and get key/value paired information specific to this Game Object. + * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`. + * + * @name Phaser.GameObjects.GameObject#data + * @type {Phaser.Data.DataManager} + * @default null + * @since 3.0.0 + */ + this.data = null; + + /** + * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not. + * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively. + * If those components are not used by your custom class then you can use this bitmask as you wish. + * + * @name Phaser.GameObjects.GameObject#renderFlags + * @type {integer} + * @default 15 + * @since 3.0.0 + */ + this.renderFlags = 15; + + /** + * A bitmask that controls if this Game Object is drawn by a Camera or not. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + * + * @example + * this.cameraFilter |= camera.id + * + * @name Phaser.GameObjects.GameObject#cameraFilter + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.cameraFilter = 0; + + /** + * If this Game Object is enabled for input then this property will contain an InteractiveObject instance. + * Not usually set directly. Instead call `GameObject.setInteractive()`. + * + * @name Phaser.GameObjects.GameObject#input + * @type {?Phaser.Input.InteractiveObject} + * @default null + * @since 3.0.0 + */ + this.input = null; + + /** + * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. + * + * @name Phaser.GameObjects.GameObject#body + * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)} + * @default null + * @since 3.0.0 + */ + 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 + scene.sys.queueDepthSort(); + }, + + /** + * Sets the `active` property of this Game Object and returns this Game Object for further chaining. + * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. + * + * @method Phaser.GameObjects.GameObject#setActive + * @since 3.0.0 + * + * @param {boolean} value - True if this Game Object should be set as active, false if not. + * + * @return {this} This GameObject. + */ + setActive: function (value) + { + this.active = value; + + return this; + }, + + /** + * Sets the `name` property of this Game Object and returns this Game Object for further chaining. + * The `name` property is not populated by Phaser and is presented for your own use. + * + * @method Phaser.GameObjects.GameObject#setName + * @since 3.0.0 + * + * @param {string} value - The name to be given to this Game Object. + * + * @return {this} This GameObject. + */ + setName: function (value) + { + this.name = value; + + return this; + }, + + /** + * Adds a Data Manager component to this Game Object. + * + * @method Phaser.GameObjects.GameObject#setDataEnabled + * @since 3.0.0 + * @see Phaser.Data.DataManager + * + * @return {this} This GameObject. + */ + setDataEnabled: function () + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this; + }, + + /** + * Allows you to store a key value pair within this Game Objects Data Manager. + * + * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled + * before setting the value. + * + * If the key doesn't already exist in the Data Manager then it is created. + * + * ```javascript + * sprite.setData('name', 'Red Gem Stone'); + * ``` + * + * You can also pass in an object of key value pairs as the first argument: + * + * ```javascript + * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 }); + * ``` + * + * To get a value back again you can call `getData`: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or you can access the value directly via the `values` property, where it works like any other variable: + * + * ```javascript + * sprite.data.values.gold += 50; + * ``` + * + * When the value is first set, a `setdata` event is emitted from this Game Object. + * + * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. + * + * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. + * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager. + * + * @method Phaser.GameObjects.GameObject#setData + * @since 3.0.0 + * + * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored. + * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored. + * + * @return {this} This GameObject. + */ + setData: function (key, value) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + this.data.set(key, value); + + return this; + }, + + /** + * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. + * + * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: + * + * ```javascript + * sprite.getData('gold'); + * ``` + * + * Or access the value directly: + * + * ```javascript + * sprite.data.values.gold; + * ``` + * + * You can also pass in an array of keys, in which case an array of values will be returned: + * + * ```javascript + * sprite.getData([ 'gold', 'armor', 'health' ]); + * ``` + * + * This approach is useful for destructuring arrays in ES6. + * + * @method Phaser.GameObjects.GameObject#getData + * @since 3.0.0 + * + * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys. + * + * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array. + */ + getData: function (key) + { + if (!this.data) + { + this.data = new DataManager(this); + } + + return this.data.get(key); + }, + + /** + * Pass this Game Object to the Input Manager to enable it for Input. + * + * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area + * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced + * input detection. + * + * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If + * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific + * shape for it to use. + * + * You can also provide an Input Configuration Object as the only argument to this method. + * + * @method Phaser.GameObjects.GameObject#setInteractive + * @since 3.0.0 + * + * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. + * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target? + * + * @return {this} This GameObject. + */ + setInteractive: function (shape, callback, dropZone) + { + this.scene.sys.input.enable(this, shape, callback, dropZone); + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will disable it. + * + * An object that is disabled for input stops processing or being considered for + * input events, but can be turned back on again at any time by simply calling + * `setInteractive()` with no arguments provided. + * + * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. + * + * @method Phaser.GameObjects.GameObject#disableInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + disableInteractive: function () + { + if (this.input) + { + this.input.enabled = false; + } + + return this; + }, + + /** + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. + * + * The Interactive Object that was assigned to this Game Object will be destroyed, + * removed from the Input Manager and cleared from this Game Object. + * + * If you wish to re-enable this Game Object at a later date you will need to + * re-create its InteractiveObject by calling `setInteractive` again. + * + * If you wish to only temporarily stop an object from receiving input then use + * `disableInteractive` instead, as that toggles the interactive state, where-as + * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) + * + * @method Phaser.GameObjects.GameObject#removeInteractive + * @since 3.7.0 + * + * @return {this} This GameObject. + */ + removeInteractive: function () + { + this.scene.sys.input.clear(this); + + this.input = undefined; + + return this; + }, + + /** + * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. + * + * @method Phaser.GameObjects.GameObject#update + * @since 3.0.0 + * + * @param {...*} [args] - args + */ + update: function () + { + }, + + /** + * Returns a JSON representation of the Game Object. + * + * @method Phaser.GameObjects.GameObject#toJSON + * @since 3.0.0 + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ + toJSON: function () + { + return ComponentsToJSON(this); + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * + * @method Phaser.GameObjects.GameObject#willRender + * @since 3.0.0 + * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * + * @return {boolean} True if the Game Object should be rendered, otherwise false. + */ + willRender: function (camera) + { + return !(GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter > 0 && (this.cameraFilter & camera.id))); + }, + + /** + * Returns an array containing the display list index of either this Game Object, or if it has one, + * its parent Container. It then iterates up through all of the parent containers until it hits the + * root of the display list (which is index 0 in the returned array). + * + * Used internally by the InputPlugin but also useful if you wish to find out the display depth of + * this Game Object and all of its ancestors. + * + * @method Phaser.GameObjects.GameObject#getIndexList + * @since 3.4.0 + * + * @return {integer[]} An array of display list position indexes. + */ + getIndexList: function () + { + // eslint-disable-next-line consistent-this + var child = this; + var parent = this.parentContainer; + + var indexes = []; + + while (parent) + { + // indexes.unshift([parent.getIndex(child), parent.name]); + indexes.unshift(parent.getIndex(child)); + + child = parent; + + if (!parent.parentContainer) + { + break; + } + else + { + parent = parent.parentContainer; + } + } + + // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']); + indexes.unshift(this.scene.sys.displayList.getIndex(child)); + + return indexes; + }, + + /** + * Destroys this Game Object removing it from the Display List and Update List and + * severing all ties to parent resources. + * + * Also removes itself from the Input Manager and Physics Manager if previously enabled. + * + * Use this to remove a Game Object from your game if you don't ever plan to use it again. + * As long as no reference to it exists within your own code it should become free for + * garbage collection by the browser. + * + * If you just want to temporarily disable an object then look at using the + * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * + * @method Phaser.GameObjects.GameObject#destroy + * @since 3.0.0 + * + * @param {boolean} [fromScene=false] - Is this Game Object being destroyed as the result of a Scene shutdown? + */ + destroy: function (fromScene) + { + if (fromScene === undefined) { fromScene = false; } + + // This Game Object has already been destroyed + if (!this.scene || this.ignoreDestroy) + { + return; + } + + if (this.preDestroy) + { + this.preDestroy.call(this); + } + + this.emit('destroy', this); + + var sys = this.scene.sys; + + if (!fromScene) + { + sys.displayList.remove(this); + sys.updateList.remove(this); + } + + if (this.input) + { + sys.input.clear(this); + this.input = undefined; + } + + if (this.data) + { + this.data.destroy(); + + this.data = undefined; + } + + if (this.body) + { + this.body.destroy(); + this.body = undefined; + } + + // Tell the Scene to re-sort the children + if (!fromScene) + { + sys.queueDepthSort(); + } + + this.active = false; + this.visible = false; + + this.scene = undefined; + + this.parentContainer = undefined; + + this.removeAllListeners(); + } + +}); + +/** + * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. + * + * @constant {integer} RENDER_MASK + * @memberof Phaser.GameObjects.GameObject + * @default + */ +GameObject.RENDER_MASK = 15; + +module.exports = GameObject; + + +/***/ }), + +/***/ "../../../src/gameobjects/components/Alpha.js": +/*!*******************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Alpha.js ***! + \*******************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Clamp = __webpack_require__(/*! ../../math/Clamp */ "../../../src/math/Clamp.js"); + +// bitmask flag for GameObject.renderMask +var _FLAG = 2; // 0010 + +/** + * Provides methods used for setting the alpha properties of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Alpha + * @since 3.0.0 + */ + +var Alpha = { + + /** + * Private internal value. Holds the global alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alpha + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alpha: 1, + + /** + * Private internal value. Holds the top-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTL: 1, + + /** + * Private internal value. Holds the top-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaTR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaTR: 1, + + /** + * Private internal value. Holds the bottom-left alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBL + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBL: 1, + + /** + * Private internal value. Holds the bottom-right alpha value. + * + * @name Phaser.GameObjects.Components.Alpha#_alphaBR + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _alphaBR: 1, + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + * + * @method Phaser.GameObjects.Components.Alpha#clearAlpha + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + clearAlpha: function () + { + return this.setAlpha(1); + }, + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * + * @method Phaser.GameObjects.Components.Alpha#setAlpha + * @since 3.0.0 + * + * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * + * @return {this} This Game Object instance. + */ + setAlpha: function (topLeft, topRight, bottomLeft, bottomRight) + { + if (topLeft === undefined) { topLeft = 1; } + + // Treat as if there is only one alpha value for the whole Game Object + if (topRight === undefined) + { + this.alpha = topLeft; + } + else + { + this._alphaTL = Clamp(topLeft, 0, 1); + this._alphaTR = Clamp(topRight, 0, 1); + this._alphaBL = Clamp(bottomLeft, 0, 1); + this._alphaBR = Clamp(bottomRight, 0, 1); + } + + return this; + }, + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + * + * @name Phaser.GameObjects.Components.Alpha#alpha + * @type {number} + * @since 3.0.0 + */ + alpha: { + + get: function () + { + return this._alpha; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alpha = v; + this._alphaTL = v; + this._alphaTR = v; + this._alphaBL = v; + this._alphaBR = v; + + if (v === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopLeft: { + + get: function () + { + return this._alphaTL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaTopRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaTopRight: { + + get: function () + { + return this._alphaTR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaTR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomLeft: { + + get: function () + { + return this._alphaBL; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBL = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + * + * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight + * @type {number} + * @webglOnly + * @since 3.0.0 + */ + alphaBottomRight: { + + get: function () + { + return this._alphaBR; + }, + + set: function (value) + { + var v = Clamp(value, 0, 1); + + this._alphaBR = v; + + if (v !== 0) + { + this.renderFlags |= _FLAG; + } + } + + } + +}; + +module.exports = Alpha; + + +/***/ }), + +/***/ "../../../src/gameobjects/components/BlendMode.js": +/*!***********************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/components/BlendMode.js ***! + \***********************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var BlendModes = __webpack_require__(/*! ../../renderer/BlendModes */ "../../../src/renderer/BlendModes.js"); + +/** + * Provides methods used for setting the blend mode of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.BlendMode + * @since 3.0.0 + */ + +var BlendMode = { + + /** + * Private internal value. Holds the current blend mode. + * + * @name Phaser.GameObjects.Components.BlendMode#_blendMode + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _blendMode: BlendModes.NORMAL, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @name Phaser.GameObjects.Components.BlendMode#blendMode + * @type {(Phaser.BlendModes|string)} + * @since 3.0.0 + */ + blendMode: { + + get: function () + { + return this._blendMode; + }, + + set: function (value) + { + if (typeof value === 'string') + { + value = BlendModes[value]; + } + + value |= 0; + + if (value >= -1) + { + this._blendMode = value; + } + } + + }, + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + * + * @method Phaser.GameObjects.Components.BlendMode#setBlendMode + * @since 3.0.0 + * + * @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST. + * + * @return {this} This Game Object instance. + */ + setBlendMode: function (value) + { + this.blendMode = value; + + return this; + } + +}; + +module.exports = BlendMode; + + +/***/ }), + +/***/ "../../../src/gameobjects/components/Depth.js": +/*!*******************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Depth.js ***! + \*******************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for setting the depth of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Depth + * @since 3.0.0 + */ + +var Depth = { + + /** + * Private internal value. Holds the depth of the Game Object. + * + * @name Phaser.GameObjects.Components.Depth#_depth + * @type {integer} + * @private + * @default 0 + * @since 3.0.0 + */ + _depth: 0, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @name Phaser.GameObjects.Components.Depth#depth + * @type {number} + * @since 3.0.0 + */ + depth: { + + get: function () + { + return this._depth; + }, + + set: function (value) + { + this.scene.sys.queueDepthSort(); + this._depth = value; + } + + }, + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * + * @method Phaser.GameObjects.Components.Depth#setDepth + * @since 3.0.0 + * + * @param {integer} value - The depth of this Game Object. + * + * @return {this} This Game Object instance. + */ + setDepth: function (value) + { + if (value === undefined) { value = 0; } + + this.depth = value; + + return this; + } + +}; + +module.exports = Depth; + + +/***/ }), + +/***/ "../../../src/gameobjects/components/Flip.js": +/*!******************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Flip.js ***! + \******************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for visually flipping a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Flip + * @since 3.0.0 + */ + +var Flip = { + + /** + * The horizontally flipped state of the Game Object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipX + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipX: false, + + /** + * The vertically flipped state of the Game Object. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + * + * @name Phaser.GameObjects.Components.Flip#flipY + * @type {boolean} + * @default false + * @since 3.0.0 + */ + flipY: false, + + /** + * Toggles the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipX + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipX: function () + { + this.flipX = !this.flipX; + + return this; + }, + + /** + * Toggles the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#toggleFlipY + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + toggleFlipY: function () + { + this.flipY = !this.flipY; + + return this; + }, + + /** + * Sets the horizontal flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipX + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipX: function (value) + { + this.flipX = value; + + return this; + }, + + /** + * Sets the vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlipY + * @since 3.0.0 + * + * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlipY: function (value) + { + this.flipY = value; + + return this; + }, + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * + * @method Phaser.GameObjects.Components.Flip#setFlip + * @since 3.0.0 + * + * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * + * @return {this} This Game Object instance. + */ + setFlip: function (x, y) + { + this.flipX = x; + this.flipY = y; + + return this; + }, + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + * + * @method Phaser.GameObjects.Components.Flip#resetFlip + * @since 3.0.0 + * + * @return {this} This Game Object instance. + */ + resetFlip: function () + { + this.flipX = false; + this.flipY = false; + + return this; + } + +}; + +module.exports = Flip; + + +/***/ }), + +/***/ "../../../src/gameobjects/components/ScrollFactor.js": +/*!**************************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/components/ScrollFactor.js ***! + \**************************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the Scroll Factor of a Game Object. + * + * @name Phaser.GameObjects.Components.ScrollFactor + * @since 3.0.0 + */ + +var ScrollFactor = { + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorX: 1, + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scrollFactorY: 1, + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * + * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor + * @since 3.0.0 + * + * @param {number} x - The horizontal scroll factor of this Game Object. + * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScrollFactor: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollFactorX = x; + this.scrollFactorY = y; + + return this; + } + +}; + +module.exports = ScrollFactor; + + +/***/ }), + +/***/ "../../../src/gameobjects/components/ToJSON.js": +/*!********************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/components/ToJSON.js ***! + \********************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} JSONGameObject + * + * @property {string} name - The name of this Game Object. + * @property {string} type - A textual representation of this Game Object, i.e. `sprite`. + * @property {number} x - The x position of this Game Object. + * @property {number} y - The y position of this Game Object. + * @property {object} scale - The scale of this Game Object + * @property {number} scale.x - The horizontal scale of this Game Object. + * @property {number} scale.y - The vertical scale of this Game Object. + * @property {object} origin - The origin of this Game Object. + * @property {number} origin.x - The horizontal origin of this Game Object. + * @property {number} origin.y - The vertical origin of this Game Object. + * @property {boolean} flipX - The horizontally flipped state of the Game Object. + * @property {boolean} flipY - The vertically flipped state of the Game Object. + * @property {number} rotation - The angle of this Game Object in radians. + * @property {number} alpha - The alpha value of the Game Object. + * @property {boolean} visible - The visible state of the Game Object. + * @property {integer} scaleMode - The Scale Mode being used by this Game Object. + * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. + * @property {string} textureKey - The texture key of this Game Object. + * @property {string} frameKey - The frame key of this Game Object. + * @property {object} data - The data of this Game Object. + */ + +/** + * Build a JSON representation of the given Game Object. + * + * This is typically extended further by Game Object specific implementations. + * + * @method Phaser.GameObjects.Components.ToJSON + * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON. + * + * @return {JSONGameObject} A JSON representation of the Game Object. + */ +var ToJSON = function (gameObject) +{ + var out = { + name: gameObject.name, + type: gameObject.type, + x: gameObject.x, + y: gameObject.y, + depth: gameObject.depth, + scale: { + x: gameObject.scaleX, + y: gameObject.scaleY + }, + origin: { + x: gameObject.originX, + y: gameObject.originY + }, + flipX: gameObject.flipX, + flipY: gameObject.flipY, + rotation: gameObject.rotation, + alpha: gameObject.alpha, + visible: gameObject.visible, + scaleMode: gameObject.scaleMode, + blendMode: gameObject.blendMode, + textureKey: '', + frameKey: '', + data: {} + }; + + if (gameObject.texture) + { + out.textureKey = gameObject.texture.key; + out.frameKey = gameObject.frame.name; + } + + return out; +}; + +module.exports = ToJSON; + + +/***/ }), + +/***/ "../../../src/gameobjects/components/Transform.js": +/*!***********************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Transform.js ***! + \***********************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = __webpack_require__(/*! ../../math/const */ "../../../src/math/const.js"); +var TransformMatrix = __webpack_require__(/*! ./TransformMatrix */ "../../../src/gameobjects/components/TransformMatrix.js"); +var WrapAngle = __webpack_require__(/*! ../../math/angle/Wrap */ "../../../src/math/angle/Wrap.js"); +var WrapAngleDegrees = __webpack_require__(/*! ../../math/angle/WrapDegrees */ "../../../src/math/angle/WrapDegrees.js"); + +// global bitmask flag for GameObject.renderMask (used by Scale) +var _FLAG = 4; // 0100 + +/** + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. + * + * @name Phaser.GameObjects.Components.Transform + * @since 3.0.0 + */ + +var Transform = { + + /** + * Private internal value. Holds the horizontal scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleX + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleX: 1, + + /** + * Private internal value. Holds the vertical scale value. + * + * @name Phaser.GameObjects.Components.Transform#_scaleY + * @type {number} + * @private + * @default 1 + * @since 3.0.0 + */ + _scaleY: 1, + + /** + * Private internal value. Holds the rotation value in radians. + * + * @name Phaser.GameObjects.Components.Transform#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.0.0 + */ + _rotation: 0, + + /** + * The x position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + x: 0, + + /** + * The y position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + y: 0, + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + * + * @name Phaser.GameObjects.Components.Transform#z + * @type {number} + * @default 0 + * @since 3.0.0 + */ + z: 0, + + /** + * The w position of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#w + * @type {number} + * @default 0 + * @since 3.0.0 + */ + w: 0, + + /** + * The horizontal scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleX + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleX: { + + get: function () + { + return this._scaleX; + }, + + set: function (value) + { + this._scaleX = value; + + if (this._scaleX === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The vertical scale of this Game Object. + * + * @name Phaser.GameObjects.Components.Transform#scaleY + * @type {number} + * @default 1 + * @since 3.0.0 + */ + scaleY: { + + get: function () + { + return this._scaleY; + }, + + set: function (value) + { + this._scaleY = value; + + if (this._scaleY === 0) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + } + + }, + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + * + * @name Phaser.GameObjects.Components.Transform#angle + * @type {integer} + * @default 0 + * @since 3.0.0 + */ + angle: { + + get: function () + { + return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG); + }, + + set: function (value) + { + // value is in degrees + this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD; + } + }, + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + * + * @name Phaser.GameObjects.Components.Transform#rotation + * @type {number} + * @default 1 + * @since 3.0.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + // value is in radians + this._rotation = WrapAngle(value); + } + }, + + /** + * Sets the position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setPosition + * @since 3.0.0 + * + * @param {number} [x=0] - The x position of this Game Object. + * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value. + * @param {number} [z=0] - The z position of this Game Object. + * @param {number} [w=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setPosition: function (x, y, z, w) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + if (z === undefined) { z = 0; } + if (w === undefined) { w = 0; } + + this.x = x; + this.y = y; + this.z = z; + this.w = w; + + return this; + }, + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * + * @method Phaser.GameObjects.Components.Transform#setRandomPosition + * @since 3.8.0 + * + * @param {number} [x=0] - The x position of the top-left of the random area. + * @param {number} [y=0] - The y position of the top-left of the random area. + * @param {number} [width] - The width of the random area. + * @param {number} [height] - The height of the random area. + * + * @return {this} This Game Object instance. + */ + setRandomPosition: function (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.scene.sys.game.config.width; } + if (height === undefined) { height = this.scene.sys.game.config.height; } + + this.x = x + (Math.random() * width); + this.y = y + (Math.random() * height); + + return this; + }, + + /** + * Sets the rotation of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setRotation + * @since 3.0.0 + * + * @param {number} [radians=0] - The rotation of this Game Object, in radians. + * + * @return {this} This Game Object instance. + */ + setRotation: function (radians) + { + if (radians === undefined) { radians = 0; } + + this.rotation = radians; + + return this; + }, + + /** + * Sets the angle of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setAngle + * @since 3.0.0 + * + * @param {number} [degrees=0] - The rotation of this Game Object, in degrees. + * + * @return {this} This Game Object instance. + */ + setAngle: function (degrees) + { + if (degrees === undefined) { degrees = 0; } + + this.angle = degrees; + + return this; + }, + + /** + * Sets the scale of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setScale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value. + * + * @return {this} This Game Object instance. + */ + setScale: function (x, y) + { + if (x === undefined) { x = 1; } + if (y === undefined) { y = x; } + + this.scaleX = x; + this.scaleY = y; + + return this; + }, + + /** + * Sets the x position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setX + * @since 3.0.0 + * + * @param {number} [value=0] - The x position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setX: function (value) + { + if (value === undefined) { value = 0; } + + this.x = value; + + return this; + }, + + /** + * Sets the y position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setY + * @since 3.0.0 + * + * @param {number} [value=0] - The y position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setY: function (value) + { + if (value === undefined) { value = 0; } + + this.y = value; + + return this; + }, + + /** + * Sets the z position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setZ + * @since 3.0.0 + * + * @param {number} [value=0] - The z position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setZ: function (value) + { + if (value === undefined) { value = 0; } + + this.z = value; + + return this; + }, + + /** + * Sets the w position of this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#setW + * @since 3.0.0 + * + * @param {number} [value=0] - The w position of this Game Object. + * + * @return {this} This Game Object instance. + */ + setW: function (value) + { + if (value === undefined) { value = 0; } + + this.w = value; + + return this; + }, + + /** + * Gets the local transform matrix for this Game Object. + * + * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getLocalTransformMatrix: function (tempMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + + return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + }, + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * + * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix + * @since 3.4.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A temporary matrix to hold parent values during the calculations. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. + */ + getWorldTransformMatrix: function (tempMatrix, parentMatrix) + { + if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + if (parentMatrix === undefined) { parentMatrix = new TransformMatrix(); } + + var parent = this.parentContainer; + + if (!parent) + { + return this.getLocalTransformMatrix(tempMatrix); + } + + tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + + while (parent) + { + parentMatrix.applyITRS(parent.x, parent.y, parent._rotation, parent._scaleX, parent._scaleY); + + parentMatrix.multiply(tempMatrix, tempMatrix); + + parent = parent.parentContainer; + } + + return tempMatrix; + } + +}; + +module.exports = Transform; + + +/***/ }), + +/***/ "../../../src/gameobjects/components/TransformMatrix.js": +/*!*****************************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/components/TransformMatrix.js ***! + \*****************************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../../utils/Class */ "../../../src/utils/Class.js"); +var Vector2 = __webpack_require__(/*! ../../math/Vector2 */ "../../../src/math/Vector2.js"); + +/** + * @classdesc + * A Matrix used for display transformations for rendering. + * + * It is represented like so: + * + * ``` + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * ``` + * + * @class TransformMatrix + * @memberof Phaser.GameObjects.Components + * @constructor + * @since 3.0.0 + * + * @param {number} [a=1] - The Scale X value. + * @param {number} [b=0] - The Shear Y value. + * @param {number} [c=0] - The Shear X value. + * @param {number} [d=1] - The Scale Y value. + * @param {number} [tx=0] - The Translate X value. + * @param {number} [ty=0] - The Translate Y value. + */ +var TransformMatrix = new Class({ + + initialize: + + function TransformMatrix (a, b, c, d, tx, ty) + { + if (a === undefined) { a = 1; } + if (b === undefined) { b = 0; } + if (c === undefined) { c = 0; } + if (d === undefined) { d = 1; } + if (tx === undefined) { tx = 0; } + if (ty === undefined) { ty = 0; } + + /** + * The matrix values. + * + * @name Phaser.GameObjects.Components.TransformMatrix#matrix + * @type {Float32Array} + * @since 3.0.0 + */ + this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]); + + /** + * The decomposed matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix + * @type {object} + * @since 3.0.0 + */ + this.decomposedMatrix = { + translateX: 0, + translateY: 0, + scaleX: 1, + scaleY: 1, + rotation: 0 + }; + }, + + /** + * The Scale X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#a + * @type {number} + * @since 3.4.0 + */ + a: { + + get: function () + { + return this.matrix[0]; + }, + + set: function (value) + { + this.matrix[0] = value; + } + + }, + + /** + * The Shear Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#b + * @type {number} + * @since 3.4.0 + */ + b: { + + get: function () + { + return this.matrix[1]; + }, + + set: function (value) + { + this.matrix[1] = value; + } + + }, + + /** + * The Shear X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#c + * @type {number} + * @since 3.4.0 + */ + c: { + + get: function () + { + return this.matrix[2]; + }, + + set: function (value) + { + this.matrix[2] = value; + } + + }, + + /** + * The Scale Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#d + * @type {number} + * @since 3.4.0 + */ + d: { + + get: function () + { + return this.matrix[3]; + }, + + set: function (value) + { + this.matrix[3] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#e + * @type {number} + * @since 3.11.0 + */ + e: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#f + * @type {number} + * @since 3.11.0 + */ + f: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#tx + * @type {number} + * @since 3.4.0 + */ + tx: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#ty + * @type {number} + * @since 3.4.0 + */ + ty: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + + /** + * The rotation of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#rotation + * @type {number} + * @readonly + * @since 3.4.0 + */ + rotation: { + + get: function () + { + return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1); + } + + }, + + /** + * The horizontal scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleX + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleX: { + + get: function () + { + return Math.sqrt((this.a * this.a) + (this.c * this.c)); + } + + }, + + /** + * The vertical scale of the Matrix. + * + * @name Phaser.GameObjects.Components.TransformMatrix#scaleY + * @type {number} + * @readonly + * @since 3.4.0 + */ + scaleY: { + + get: function () + { + return Math.sqrt((this.b * this.b) + (this.d * this.d)); + } + + }, + + /** + * Reset the Matrix to an identity matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + loadIdentity: function () + { + var matrix = this.matrix; + + matrix[0] = 1; + matrix[1] = 0; + matrix[2] = 0; + matrix[3] = 1; + matrix[4] = 0; + matrix[5] = 0; + + return this; + }, + + /** + * Translate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#translate + * @since 3.0.0 + * + * @param {number} x - The horizontal translation value. + * @param {number} y - The vertical translation value. + * + * @return {this} This TransformMatrix. + */ + translate: function (x, y) + { + var matrix = this.matrix; + + matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4]; + matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5]; + + return this; + }, + + /** + * Scale the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#scale + * @since 3.0.0 + * + * @param {number} x - The horizontal scale value. + * @param {number} y - The vertical scale value. + * + * @return {this} This TransformMatrix. + */ + scale: function (x, y) + { + var matrix = this.matrix; + + matrix[0] *= x; + matrix[1] *= x; + matrix[2] *= y; + matrix[3] *= y; + + return this; + }, + + /** + * Rotate the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#rotate + * @since 3.0.0 + * + * @param {number} angle - The angle of rotation in radians. + * + * @return {this} This TransformMatrix. + */ + rotate: function (angle) + { + var sin = Math.sin(angle); + var cos = Math.cos(angle); + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + matrix[0] = a * cos + c * sin; + matrix[1] = b * cos + d * sin; + matrix[2] = a * -sin + c * cos; + matrix[3] = b * -sin + d * cos; + + return this; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiply + * @since 3.0.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - The Matrix to multiply by. + * @param {Phaser.GameObjects.Components.TransformMatrix} [out] - An optional Matrix to store the results in. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} Either this TransformMatrix, or the `out` Matrix, if given in the arguments. + */ + multiply: function (rhs, out) + { + var matrix = this.matrix; + var source = rhs.matrix; + + var localA = matrix[0]; + var localB = matrix[1]; + var localC = matrix[2]; + var localD = matrix[3]; + var localE = matrix[4]; + var localF = matrix[5]; + + var sourceA = source[0]; + var sourceB = source[1]; + var sourceC = source[2]; + var sourceD = source[3]; + var sourceE = source[4]; + var sourceF = source[5]; + + var destinationMatrix = (out === undefined) ? this : out; + + destinationMatrix.a = (sourceA * localA) + (sourceB * localC); + destinationMatrix.b = (sourceA * localB) + (sourceB * localD); + destinationMatrix.c = (sourceC * localA) + (sourceD * localC); + destinationMatrix.d = (sourceC * localB) + (sourceD * localD); + destinationMatrix.e = (sourceE * localA) + (sourceF * localC) + localE; + destinationMatrix.f = (sourceE * localB) + (sourceF * localD) + localF; + + return destinationMatrix; + }, + + /** + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiplyWithOffset + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * @param {number} offsetX - Horizontal offset to factor in to the multiplication. + * @param {number} offsetY - Vertical offset to factor in to the multiplication. + * + * @return {this} This TransformMatrix. + */ + multiplyWithOffset: function (src, offsetX, offsetY) + { + var matrix = this.matrix; + var otherMatrix = src.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + var pse = offsetX * a0 + offsetY * c0 + tx0; + var psf = offsetX * b0 + offsetY * d0 + ty0; + + var a1 = otherMatrix[0]; + var b1 = otherMatrix[1]; + var c1 = otherMatrix[2]; + var d1 = otherMatrix[3]; + var tx1 = otherMatrix[4]; + var ty1 = otherMatrix[5]; + + matrix[0] = a1 * a0 + b1 * c0; + matrix[1] = a1 * b0 + b1 * d0; + matrix[2] = c1 * a0 + d1 * c0; + matrix[3] = c1 * b0 + d1 * d0; + matrix[4] = tx1 * a0 + ty1 * c0 + pse; + matrix[5] = tx1 * b0 + ty1 * d0 + psf; + + return this; + }, + + /** + * Transform the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + transform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + var a0 = matrix[0]; + var b0 = matrix[1]; + var c0 = matrix[2]; + var d0 = matrix[3]; + var tx0 = matrix[4]; + var ty0 = matrix[5]; + + matrix[0] = a * a0 + b * c0; + matrix[1] = a * b0 + b * d0; + matrix[2] = c * a0 + d * c0; + matrix[3] = c * b0 + d * d0; + matrix[4] = tx * a0 + ty * c0 + tx0; + matrix[5] = tx * b0 + ty * d0 + ty0; + + return this; + }, + + /** + * Transform a point using this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the point to transform. + * @param {number} y - The y coordinate of the point to transform. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - The Point object to store the transformed coordinates. + * + * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} The Point containing the transformed coordinates. + */ + transformPoint: function (x, y, point) + { + if (point === undefined) { point = { x: 0, y: 0 }; } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + point.x = x * a + y * c + tx; + point.y = x * b + y * d + ty; + + return point; + }, + + /** + * Invert the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#invert + * @since 3.0.0 + * + * @return {this} This TransformMatrix. + */ + invert: function () + { + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var n = a * d - b * c; + + matrix[0] = d / n; + matrix[1] = -b / n; + matrix[2] = -c / n; + matrix[3] = a / n; + matrix[4] = (c * ty - d * tx) / n; + matrix[5] = -(a * ty - b * tx) / n; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the matrix given. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFrom + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * + * @return {this} This TransformMatrix. + */ + copyFrom: function (src) + { + var matrix = this.matrix; + + matrix[0] = src.a; + matrix[1] = src.b; + matrix[2] = src.c; + matrix[3] = src.d; + matrix[4] = src.e; + matrix[5] = src.f; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFromArray + * @since 3.11.0 + * + * @param {array} src - The array of values to set into this matrix. + * + * @return {this} This TransformMatrix. + */ + copyFromArray: function (src) + { + var matrix = this.matrix; + + matrix[0] = src[0]; + matrix[1] = src[1]; + matrix[2] = src[2]; + matrix[3] = src[3]; + matrix[4] = src[4]; + matrix[5] = src[5]; + + return this; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + copyToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + setToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToArray + * @since 3.12.0 + * + * @param {array} [out] - The array to copy the matrix values in to. + * + * @return {array} An array where elements 0 to 5 contain the values from this matrix. + */ + copyToArray: function (out) + { + var matrix = this.matrix; + + if (out === undefined) + { + out = [ matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] ]; + } + else + { + out[0] = matrix[0]; + out[1] = matrix[1]; + out[2] = matrix[2]; + out[3] = matrix[3]; + out[4] = matrix[4]; + out[5] = matrix[5]; + } + + return out; + }, + + /** + * Set the values of this Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setTransform + * @since 3.0.0 + * + * @param {number} a - The Scale X value. + * @param {number} b - The Shear Y value. + * @param {number} c - The Shear X value. + * @param {number} d - The Scale Y value. + * @param {number} tx - The Translate X value. + * @param {number} ty - The Translate Y value. + * + * @return {this} This TransformMatrix. + */ + setTransform: function (a, b, c, d, tx, ty) + { + var matrix = this.matrix; + + matrix[0] = a; + matrix[1] = b; + matrix[2] = c; + matrix[3] = d; + matrix[4] = tx; + matrix[5] = ty; + + return this; + }, + + /** + * Decompose this Matrix into its translation, scale and rotation values using QR decomposition. + * + * The result must be applied in the following order to reproduce the current matrix: + * + * translate -> rotate -> scale + * + * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix + * @since 3.0.0 + * + * @return {object} The decomposed Matrix. + */ + decomposeMatrix: function () + { + var decomposedMatrix = this.decomposedMatrix; + + var matrix = this.matrix; + + // a = scale X (1) + // b = shear Y (0) + // c = shear X (0) + // d = scale Y (1) + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + + var determ = a * d - b * c; + + decomposedMatrix.translateX = matrix[4]; + decomposedMatrix.translateY = matrix[5]; + + if (a || b) + { + var r = Math.sqrt(a * a + b * b); + + decomposedMatrix.rotation = (b > 0) ? Math.acos(a / r) : -Math.acos(a / r); + decomposedMatrix.scaleX = r; + decomposedMatrix.scaleY = determ / r; + } + else if (c || d) + { + var s = Math.sqrt(c * c + d * d); + + decomposedMatrix.rotation = Math.PI * 0.5 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s)); + decomposedMatrix.scaleX = determ / s; + decomposedMatrix.scaleY = s; + } + else + { + decomposedMatrix.rotation = 0; + decomposedMatrix.scaleX = 0; + decomposedMatrix.scaleY = 0; + } + + return decomposedMatrix; + }, + + /** + * Apply the identity, translate, rotate and scale operations on the Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS + * @since 3.0.0 + * + * @param {number} x - The horizontal translation. + * @param {number} y - The vertical translation. + * @param {number} rotation - The angle of rotation in radians. + * @param {number} scaleX - The horizontal scale. + * @param {number} scaleY - The vertical scale. + * + * @return {this} This TransformMatrix. + */ + applyITRS: function (x, y, rotation, scaleX, scaleY) + { + var matrix = this.matrix; + + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); + + // Translate + matrix[4] = x; + matrix[5] = y; + + // Rotate and Scale + matrix[0] = radianCos * scaleX; + matrix[1] = radianSin * scaleX; + matrix[2] = -radianSin * scaleY; + matrix[3] = radianCos * scaleY; + + return this; + }, + + /** + * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of + * the current matrix with its transformation applied. + * + * Can be used to translate points from world to local space. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyInverse + * @since 3.12.0 + * + * @param {number} x - The x position to translate. + * @param {number} y - The y position to translate. + * @param {Phaser.Math.Vector2} [output] - A Vector2, or point-like object, to store the results in. + * + * @return {Phaser.Math.Vector2} The coordinates, inverse-transformed through this matrix. + */ + applyInverse: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var id = 1 / ((a * d) + (c * -b)); + + output.x = (d * id * x) + (-c * id * y) + (((ty * c) - (tx * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-ty * a) + (tx * b)) * id); + + return output; + }, + + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getX + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated x value. + */ + getX: function (x, y) + { + return x * this.a + y * this.c + this.e; + }, + + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getY + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated y value. + */ + getY: function (x, y) + { + return x * this.b + y * this.d + this.f; + }, + + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getCSSMatrix + * @since 3.12.0 + * + * @return {string} A string containing the CSS Transform matrix values. + */ + getCSSMatrix: function () + { + var m = this.matrix; + + return 'matrix(' + m[0] + ',' + m[1] + ',' + m[2] + ',' + m[3] + ',' + m[4] + ',' + m[5] + ')'; + }, + + /** + * Destroys this Transform Matrix. + * + * @method Phaser.GameObjects.Components.TransformMatrix#destroy + * @since 3.4.0 + */ + destroy: function () + { + this.matrix = null; + this.decomposedMatrix = null; + } + +}); + +module.exports = TransformMatrix; + + +/***/ }), + +/***/ "../../../src/gameobjects/components/Visible.js": +/*!*********************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Visible.js ***! + \*********************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 1; // 0001 + +/** + * Provides methods used for setting the visibility of a Game Object. + * Should be applied as a mixin and not used directly. + * + * @name Phaser.GameObjects.Components.Visible + * @since 3.0.0 + */ + +var Visible = { + + /** + * Private internal value. Holds the visible value. + * + * @name Phaser.GameObjects.Components.Visible#_visible + * @type {boolean} + * @private + * @default true + * @since 3.0.0 + */ + _visible: true, + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @name Phaser.GameObjects.Components.Visible#visible + * @type {boolean} + * @since 3.0.0 + */ + visible: { + + get: function () + { + return this._visible; + }, + + set: function (value) + { + if (value) + { + this._visible = true; + this.renderFlags |= _FLAG; + } + else + { + this._visible = false; + this.renderFlags &= ~_FLAG; + } + } + + }, + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * + * @method Phaser.GameObjects.Components.Visible#setVisible + * @since 3.0.0 + * + * @param {boolean} value - The visible state of the Game Object. + * + * @return {this} This Game Object instance. + */ + setVisible: function (value) + { + this.visible = value; + + return this; + } +}; + +module.exports = Visible; + + +/***/ }), + +/***/ "../../../src/loader/File.js": +/*!**************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/File.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../utils/Class */ "../../../src/utils/Class.js"); +var CONST = __webpack_require__(/*! ./const */ "../../../src/loader/const.js"); +var GetFastValue = __webpack_require__(/*! ../utils/object/GetFastValue */ "../../../src/utils/object/GetFastValue.js"); +var GetURL = __webpack_require__(/*! ./GetURL */ "../../../src/loader/GetURL.js"); +var MergeXHRSettings = __webpack_require__(/*! ./MergeXHRSettings */ "../../../src/loader/MergeXHRSettings.js"); +var XHRLoader = __webpack_require__(/*! ./XHRLoader */ "../../../src/loader/XHRLoader.js"); +var XHRSettings = __webpack_require__(/*! ./XHRSettings */ "../../../src/loader/XHRSettings.js"); + +/** + * @typedef {object} FileConfig + * + * @property {string} type - The file type string (image, json, etc) for sorting within the Loader. + * @property {string} key - Unique cache key (unique within its file type) + * @property {string} [url] - The URL of the file, not including baseURL. + * @property {string} [path] - The path of the file, not including the baseURL. + * @property {string} [extension] - The default extension this file uses. + * @property {XMLHttpRequestResponseType} [responseType] - The responseType to be used by the XHR request. + * @property {(XHRSettingsObject|false)} [xhrSettings=false] - Custom XHR Settings specific to this file and merged with the Loader defaults. + * @property {any} [config] - A config object that can be used by file types to store transitional data. + */ + +/** + * @classdesc + * The base File class used by all File Types that the Loader can support. + * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. + * + * @class File + * @memberof Phaser.Loader + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. + * @param {FileConfig} fileConfig - The file configuration object, as created by the file type. + */ +var File = new Class({ + + initialize: + + function File (loader, fileConfig) + { + /** + * A reference to the Loader that is going to load this file. + * + * @name Phaser.Loader.File#loader + * @type {Phaser.Loader.LoaderPlugin} + * @since 3.0.0 + */ + this.loader = loader; + + /** + * A reference to the Cache, or Texture Manager, that is going to store this file if it loads. + * + * @name Phaser.Loader.File#cache + * @type {(Phaser.Cache.BaseCache|Phaser.Textures.TextureManager)} + * @since 3.7.0 + */ + this.cache = GetFastValue(fileConfig, 'cache', false); + + /** + * The file type string (image, json, etc) for sorting within the Loader. + * + * @name Phaser.Loader.File#type + * @type {string} + * @since 3.0.0 + */ + this.type = GetFastValue(fileConfig, 'type', false); + + /** + * Unique cache key (unique within its file type) + * + * @name Phaser.Loader.File#key + * @type {string} + * @since 3.0.0 + */ + this.key = GetFastValue(fileConfig, 'key', false); + + var loadKey = this.key; + + if (loader.prefix && loader.prefix !== '') + { + this.key = loader.prefix + loadKey; + } + + if (!this.type || !this.key) + { + throw new Error('Error calling \'Loader.' + this.type + '\' invalid key provided.'); + } + + /** + * The URL of the file, not including baseURL. + * Automatically has Loader.path prepended to it. + * + * @name Phaser.Loader.File#url + * @type {string} + * @since 3.0.0 + */ + this.url = GetFastValue(fileConfig, 'url'); + + if (this.url === undefined) + { + this.url = loader.path + loadKey + '.' + GetFastValue(fileConfig, 'extension', ''); + } + else if (typeof(this.url) !== 'function') + { + this.url = loader.path + this.url; + } + + /** + * The final URL this file will load from, including baseURL and path. + * Set automatically when the Loader calls 'load' on this file. + * + * @name Phaser.Loader.File#src + * @type {string} + * @since 3.0.0 + */ + this.src = ''; + + /** + * The merged XHRSettings for this file. + * + * @name Phaser.Loader.File#xhrSettings + * @type {XHRSettingsObject} + * @since 3.0.0 + */ + this.xhrSettings = XHRSettings(GetFastValue(fileConfig, 'responseType', undefined)); + + if (GetFastValue(fileConfig, 'xhrSettings', false)) + { + this.xhrSettings = MergeXHRSettings(this.xhrSettings, GetFastValue(fileConfig, 'xhrSettings', {})); + } + + /** + * The XMLHttpRequest instance (as created by XHR Loader) that is loading this File. + * + * @name Phaser.Loader.File#xhrLoader + * @type {?XMLHttpRequest} + * @since 3.0.0 + */ + this.xhrLoader = null; + + /** + * The current state of the file. One of the FILE_CONST values. + * + * @name Phaser.Loader.File#state + * @type {integer} + * @since 3.0.0 + */ + this.state = (typeof(this.url) === 'function') ? CONST.FILE_POPULATED : CONST.FILE_PENDING; + + /** + * The total size of this file. + * Set by onProgress and only if loading via XHR. + * + * @name Phaser.Loader.File#bytesTotal + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.bytesTotal = 0; + + /** + * Updated as the file loads. + * Only set if loading via XHR. + * + * @name Phaser.Loader.File#bytesLoaded + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.bytesLoaded = -1; + + /** + * A percentage value between 0 and 1 indicating how much of this file has loaded. + * Only set if loading via XHR. + * + * @name Phaser.Loader.File#percentComplete + * @type {number} + * @default -1 + * @since 3.0.0 + */ + this.percentComplete = -1; + + /** + * For CORs based loading. + * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set) + * + * @name Phaser.Loader.File#crossOrigin + * @type {(string|undefined)} + * @since 3.0.0 + */ + this.crossOrigin = undefined; + + /** + * The processed file data, stored here after the file has loaded. + * + * @name Phaser.Loader.File#data + * @type {*} + * @since 3.0.0 + */ + this.data = undefined; + + /** + * A config object that can be used by file types to store transitional data. + * + * @name Phaser.Loader.File#config + * @type {*} + * @since 3.0.0 + */ + this.config = GetFastValue(fileConfig, 'config', {}); + + /** + * If this is a multipart file, i.e. an atlas and its json together, then this is a reference + * to the parent MultiFile. Set and used internally by the Loader or specific file types. + * + * @name Phaser.Loader.File#multiFile + * @type {?Phaser.Loader.MultiFile} + * @since 3.7.0 + */ + this.multiFile; + + /** + * Does this file have an associated linked file? Such as an image and a normal map. + * Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't + * actually bound by data, where-as a linkFile is. + * + * @name Phaser.Loader.File#linkFile + * @type {?Phaser.Loader.File} + * @since 3.7.0 + */ + this.linkFile; + }, + + /** + * Links this File with another, so they depend upon each other for loading and processing. + * + * @method Phaser.Loader.File#setLink + * @since 3.7.0 + * + * @param {Phaser.Loader.File} fileB - The file to link to this one. + */ + setLink: function (fileB) + { + this.linkFile = fileB; + + fileB.linkFile = this; + }, + + /** + * Resets the XHRLoader instance this file is using. + * + * @method Phaser.Loader.File#resetXHR + * @since 3.0.0 + */ + resetXHR: function () + { + if (this.xhrLoader) + { + this.xhrLoader.onload = undefined; + this.xhrLoader.onerror = undefined; + this.xhrLoader.onprogress = undefined; + } + }, + + /** + * Called by the Loader, starts the actual file downloading. + * During the load the methods onLoad, onError and onProgress are called, based on the XHR events. + * You shouldn't normally call this method directly, it's meant to be invoked by the Loader. + * + * @method Phaser.Loader.File#load + * @since 3.0.0 + */ + load: function () + { + if (this.state === CONST.FILE_POPULATED) + { + // Can happen for example in a JSONFile if they've provided a JSON object instead of a URL + this.loader.nextFile(this, true); + } + else + { + this.src = GetURL(this, this.loader.baseURL); + + if (this.src.indexOf('data:') === 0) + { + console.warn('Local data URIs are not supported: ' + this.key); + } + else + { + // The creation of this XHRLoader starts the load process going. + // It will automatically call the following, based on the load outcome: + // + // xhr.onload = this.onLoad + // xhr.onerror = this.onError + // xhr.onprogress = this.onProgress + + this.xhrLoader = XHRLoader(this, this.loader.xhr); + } + } + }, + + /** + * Called when the file finishes loading, is sent a DOM ProgressEvent. + * + * @method Phaser.Loader.File#onLoad + * @since 3.0.0 + * + * @param {XMLHttpRequest} xhr - The XMLHttpRequest that caused this onload event. + * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this load. + */ + onLoad: function (xhr, event) + { + var success = !(event.target && event.target.status !== 200); + + // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called. + if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) + { + success = false; + } + + this.resetXHR(); + + this.loader.nextFile(this, success); + }, + + /** + * Called if the file errors while loading, is sent a DOM ProgressEvent. + * + * @method Phaser.Loader.File#onError + * @since 3.0.0 + * + * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this error. + */ + onError: function () + { + this.resetXHR(); + + this.loader.nextFile(this, false); + }, + + /** + * Called during the file load progress. Is sent a DOM ProgressEvent. + * + * @method Phaser.Loader.File#onProgress + * @since 3.0.0 + * + * @param {ProgressEvent} event - The DOM ProgressEvent. + */ + onProgress: function (event) + { + if (event.lengthComputable) + { + this.bytesLoaded = event.loaded; + this.bytesTotal = event.total; + + this.percentComplete = Math.min((this.bytesLoaded / this.bytesTotal), 1); + + this.loader.emit('fileprogress', this, this.percentComplete); + } + }, + + /** + * Usually overridden by the FileTypes and is called by Loader.nextFile. + * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage. + * + * @method Phaser.Loader.File#onProcess + * @since 3.0.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.onProcessComplete(); + }, + + /** + * Called when the File has completed processing. + * Checks on the state of its multifile, if set. + * + * @method Phaser.Loader.File#onProcessComplete + * @since 3.7.0 + */ + onProcessComplete: function () + { + this.state = CONST.FILE_COMPLETE; + + if (this.multiFile) + { + this.multiFile.onFileComplete(this); + } + + this.loader.fileProcessComplete(this); + }, + + /** + * Called when the File has completed processing but it generated an error. + * Checks on the state of its multifile, if set. + * + * @method Phaser.Loader.File#onProcessError + * @since 3.7.0 + */ + onProcessError: function () + { + this.state = CONST.FILE_ERRORED; + + if (this.multiFile) + { + this.multiFile.onFileFailed(this); + } + + this.loader.fileProcessComplete(this); + }, + + /** + * Checks if a key matching the one used by this file exists in the target Cache or not. + * This is called automatically by the LoaderPlugin to decide if the file can be safely + * loaded or will conflict. + * + * @method Phaser.Loader.File#hasCacheConflict + * @since 3.7.0 + * + * @return {boolean} `true` if adding this file will cause a conflict, otherwise `false`. + */ + hasCacheConflict: function () + { + return (this.cache && this.cache.exists(this.key)); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * This method is often overridden by specific file types. + * + * @method Phaser.Loader.File#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + if (this.cache) + { + this.cache.add(this.key, this.data); + } + + this.pendingDestroy(); + }, + + /** + * You can listen for this event from the LoaderPlugin. It is dispatched _every time_ + * a file loads and is sent 3 arguments, which allow you to identify the file: + * + * ```javascript + * this.load.on('filecomplete', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * @event Phaser.Loader.File#fileCompleteEvent + * @param {string} key - The key of the file that just loaded and finished processing. + * @param {string} type - The type of the file that just loaded and finished processing. + * @param {any} data - The data of the file. + */ + + /** + * You can listen for this event from the LoaderPlugin. It is dispatched only once per + * file and you have to use a special listener handle to pick it up. + * + * The string of the event is based on the file type and the key you gave it, split up + * using hyphens. + * + * For example, if you have loaded an image with a key of `monster`, you can listen for it + * using the following: + * + * ```javascript + * this.load.on('filecomplete-image-monster', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a texture atlas with a key of `Level1`: + * + * ```javascript + * this.load.on('filecomplete-atlas-Level1', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: + * + * ```javascript + * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * @event Phaser.Loader.File#singleFileCompleteEvent + * @param {any} data - The data of the file. + */ + + /** + * Called once the file has been added to its cache and is now ready for deletion from the Loader. + * It will emit a `filecomplete` event from the LoaderPlugin. + * + * @method Phaser.Loader.File#pendingDestroy + * @fires Phaser.Loader.File#fileCompleteEvent + * @fires Phaser.Loader.File#singleFileCompleteEvent + * @since 3.7.0 + */ + pendingDestroy: function (data) + { + if (data === undefined) { data = this.data; } + + var key = this.key; + var type = this.type; + + this.loader.emit('filecomplete', key, type, data); + this.loader.emit('filecomplete-' + type + '-' + key, key, type, data); + + this.loader.flagForRemoval(this); + }, + + /** + * Destroy this File and any references it holds. + * + * @method Phaser.Loader.File#destroy + * @since 3.7.0 + */ + destroy: function () + { + this.loader = null; + this.cache = null; + this.xhrSettings = null; + this.multiFile = null; + this.linkFile = null; + this.data = null; + } + +}); + +/** + * Static method for creating object URL using URL API and setting it as image 'src' attribute. + * If URL API is not supported (usually on old browsers) it falls back to creating Base64 encoded url using FileReader. + * + * @method Phaser.Loader.File.createObjectURL + * @static + * @param {HTMLImageElement} image - Image object which 'src' attribute should be set to object URL. + * @param {Blob} blob - A Blob object to create an object URL for. + * @param {string} defaultType - Default mime type used if blob type is not available. + */ +File.createObjectURL = function (image, blob, defaultType) +{ + if (typeof URL === 'function') + { + image.src = URL.createObjectURL(blob); + } + else + { + var reader = new FileReader(); + + reader.onload = function () + { + image.removeAttribute('crossOrigin'); + image.src = 'data:' + (blob.type || defaultType) + ';base64,' + reader.result.split(',')[1]; + }; + + reader.onerror = image.onerror; + + reader.readAsDataURL(blob); + } +}; + +/** + * Static method for releasing an existing object URL which was previously created + * by calling {@link File#createObjectURL} method. + * + * @method Phaser.Loader.File.revokeObjectURL + * @static + * @param {HTMLImageElement} image - Image object which 'src' attribute should be revoked. + */ +File.revokeObjectURL = function (image) +{ + if (typeof URL === 'function') + { + URL.revokeObjectURL(image.src); + } +}; + +module.exports = File; + + +/***/ }), + +/***/ "../../../src/loader/FileTypesManager.js": +/*!**************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/FileTypesManager.js ***! + \**************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var types = {}; + +var FileTypesManager = { + + /** + * Static method called when a LoaderPlugin is created. + * + * Loops through the local types object and injects all of them as + * properties into the LoaderPlugin instance. + * + * @method Phaser.Loader.FileTypesManager.register + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The LoaderPlugin to install the types into. + */ + install: function (loader) + { + for (var key in types) + { + loader[key] = types[key]; + } + }, + + /** + * Static method called directly by the File Types. + * + * The key is a reference to the function used to load the files via the Loader, i.e. `image`. + * + * @method Phaser.Loader.FileTypesManager.register + * @since 3.0.0 + * + * @param {string} key - The key that will be used as the method name in the LoaderPlugin. + * @param {function} factoryFunction - The function that will be called when LoaderPlugin.key is invoked. + */ + register: function (key, factoryFunction) + { + types[key] = factoryFunction; + }, + + /** + * Removed all associated file types. + * + * @method Phaser.Loader.FileTypesManager.destroy + * @since 3.0.0 + */ + destroy: function () + { + types = {}; + } + +}; + +module.exports = FileTypesManager; + + +/***/ }), + +/***/ "../../../src/loader/GetURL.js": +/*!****************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/GetURL.js ***! + \****************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Given a File and a baseURL value this returns the URL the File will use to download from. + * + * @function Phaser.Loader.GetURL + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File object. + * @param {string} baseURL - A default base URL. + * + * @return {string} The URL the File will use. + */ +var GetURL = function (file, baseURL) +{ + if (!file.url) + { + return false; + } + + if (file.url.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)) + { + return file.url; + } + else + { + return baseURL + file.url; + } +}; + +module.exports = GetURL; + + +/***/ }), + +/***/ "../../../src/loader/MergeXHRSettings.js": +/*!**************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/MergeXHRSettings.js ***! + \**************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extend = __webpack_require__(/*! ../utils/object/Extend */ "../../../src/utils/object/Extend.js"); +var XHRSettings = __webpack_require__(/*! ./XHRSettings */ "../../../src/loader/XHRSettings.js"); + +/** + * Takes two XHRSettings Objects and creates a new XHRSettings object from them. + * + * The new object is seeded by the values given in the global settings, but any setting in + * the local object overrides the global ones. + * + * @function Phaser.Loader.MergeXHRSettings + * @since 3.0.0 + * + * @param {XHRSettingsObject} global - The global XHRSettings object. + * @param {XHRSettingsObject} local - The local XHRSettings object. + * + * @return {XHRSettingsObject} A newly formed XHRSettings object. + */ +var MergeXHRSettings = function (global, local) +{ + var output = (global === undefined) ? XHRSettings() : Extend({}, global); + + if (local) + { + for (var setting in local) + { + if (local[setting] !== undefined) + { + output[setting] = local[setting]; + } + } + } + + return output; +}; + +module.exports = MergeXHRSettings; + + +/***/ }), + +/***/ "../../../src/loader/MultiFile.js": +/*!*******************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/MultiFile.js ***! + \*******************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../utils/Class */ "../../../src/utils/Class.js"); + +/** + * @classdesc + * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after + * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont. + * + * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. + * + * @class MultiFile + * @memberof Phaser.Loader + * @constructor + * @since 3.7.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File. + * @param {string} type - The file type string for sorting within the Loader. + * @param {string} key - The key of the file within the loader. + * @param {Phaser.Loader.File[]} files - An array of Files that make-up this MultiFile. + */ +var MultiFile = new Class({ + + initialize: + + function MultiFile (loader, type, key, files) + { + /** + * A reference to the Loader that is going to load this file. + * + * @name Phaser.Loader.MultiFile#loader + * @type {Phaser.Loader.LoaderPlugin} + * @since 3.7.0 + */ + this.loader = loader; + + /** + * The file type string for sorting within the Loader. + * + * @name Phaser.Loader.MultiFile#type + * @type {string} + * @since 3.7.0 + */ + this.type = type; + + /** + * Unique cache key (unique within its file type) + * + * @name Phaser.Loader.MultiFile#key + * @type {string} + * @since 3.7.0 + */ + this.key = key; + + /** + * Array of files that make up this MultiFile. + * + * @name Phaser.Loader.MultiFile#files + * @type {Phaser.Loader.File[]} + * @since 3.7.0 + */ + this.files = files; + + /** + * The completion status of this MultiFile. + * + * @name Phaser.Loader.MultiFile#complete + * @type {boolean} + * @default false + * @since 3.7.0 + */ + this.complete = false; + + /** + * The number of files to load. + * + * @name Phaser.Loader.MultiFile#pending + * @type {integer} + * @since 3.7.0 + */ + + this.pending = files.length; + + /** + * The number of files that failed to load. + * + * @name Phaser.Loader.MultiFile#failed + * @type {integer} + * @default 0 + * @since 3.7.0 + */ + this.failed = 0; + + /** + * A storage container for transient data that the loading files need. + * + * @name Phaser.Loader.MultiFile#config + * @type {any} + * @since 3.7.0 + */ + this.config = {}; + + // Link the files + for (var i = 0; i < files.length; i++) + { + files[i].multiFile = this; + } + }, + + /** + * Checks if this MultiFile is ready to process its children or not. + * + * @method Phaser.Loader.MultiFile#isReadyToProcess + * @since 3.7.0 + * + * @return {boolean} `true` if all children of this MultiFile have loaded, otherwise `false`. + */ + isReadyToProcess: function () + { + return (this.pending === 0 && this.failed === 0 && !this.complete); + }, + + /** + * Adds another child to this MultiFile, increases the pending count and resets the completion status. + * + * @method Phaser.Loader.MultiFile#addToMultiFile + * @since 3.7.0 + * + * @param {Phaser.Loader.File} files - The File to add to this MultiFile. + * + * @return {Phaser.Loader.MultiFile} This MultiFile instance. + */ + addToMultiFile: function (file) + { + this.files.push(file); + + file.multiFile = this; + + this.pending++; + + this.complete = false; + + return this; + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.MultiFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + } + }, + + /** + * Called by each File that fails to load. + * + * @method Phaser.Loader.MultiFile#onFileFailed + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has failed to load. + */ + onFileFailed: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.failed++; + } + } + +}); + +module.exports = MultiFile; + + +/***/ }), + +/***/ "../../../src/loader/XHRLoader.js": +/*!*******************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/XHRLoader.js ***! + \*******************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MergeXHRSettings = __webpack_require__(/*! ./MergeXHRSettings */ "../../../src/loader/MergeXHRSettings.js"); + +/** + * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings + * and starts the download of it. It uses the Files own XHRSettings and merges them + * with the global XHRSettings object to set the xhr values before download. + * + * @function Phaser.Loader.XHRLoader + * @since 3.0.0 + * + * @param {Phaser.Loader.File} file - The File to download. + * @param {XHRSettingsObject} globalXHRSettings - The global XHRSettings object. + * + * @return {XMLHttpRequest} The XHR object. + */ +var XHRLoader = function (file, globalXHRSettings) +{ + var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings); + + var xhr = new XMLHttpRequest(); + + xhr.open('GET', file.src, config.async, config.user, config.password); + + xhr.responseType = file.xhrSettings.responseType; + xhr.timeout = config.timeout; + + if (config.header && config.headerValue) + { + xhr.setRequestHeader(config.header, config.headerValue); + } + + if (config.requestedWith) + { + xhr.setRequestHeader('X-Requested-With', config.requestedWith); + } + + if (config.overrideMimeType) + { + xhr.overrideMimeType(config.overrideMimeType); + } + + // After a successful request, the xhr.response property will contain the requested data as a DOMString, ArrayBuffer, Blob, or Document (depending on what was set for responseType.) + + xhr.onload = file.onLoad.bind(file, xhr); + xhr.onerror = file.onError.bind(file); + xhr.onprogress = file.onProgress.bind(file); + + // This is the only standard method, the ones above are browser additions (maybe not universal?) + // xhr.onreadystatechange + + xhr.send(); + + return xhr; +}; + +module.exports = XHRLoader; + + +/***/ }), + +/***/ "../../../src/loader/XHRSettings.js": +/*!*********************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/XHRSettings.js ***! + \*********************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @typedef {object} XHRSettingsObject + * + * @property {XMLHttpRequestResponseType} responseType - The response type of the XHR request, i.e. `blob`, `text`, etc. + * @property {boolean} [async=true] - Should the XHR request use async or not? + * @property {string} [user=''] - Optional username for the XHR request. + * @property {string} [password=''] - Optional password for the XHR request. + * @property {integer} [timeout=0] - Optional XHR timeout value. + * @property {(string|undefined)} [header] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [headerValue] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [requestedWith] - This value is used to populate the XHR `setRequestHeader` and is undefined by default. + * @property {(string|undefined)} [overrideMimeType] - Provide a custom mime-type to use instead of the default. + */ + +/** + * Creates an XHRSettings Object with default values. + * + * @function Phaser.Loader.XHRSettings + * @since 3.0.0 + * + * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'. + * @param {boolean} [async=true] - Should the XHR request use async or not? + * @param {string} [user=''] - Optional username for the XHR request. + * @param {string} [password=''] - Optional password for the XHR request. + * @param {integer} [timeout=0] - Optional XHR timeout value. + * + * @return {XHRSettingsObject} The XHRSettings object as used by the Loader. + */ +var XHRSettings = function (responseType, async, user, password, timeout) +{ + if (responseType === undefined) { responseType = ''; } + if (async === undefined) { async = true; } + if (user === undefined) { user = ''; } + if (password === undefined) { password = ''; } + if (timeout === undefined) { timeout = 0; } + + // Before sending a request, set the xhr.responseType to "text", + // "arraybuffer", "blob", or "document", depending on your data needs. + // Note, setting xhr.responseType = '' (or omitting) will default the response to "text". + + return { + + // Ignored by the Loader, only used by File. + responseType: responseType, + + async: async, + + // credentials + user: user, + password: password, + + // timeout in ms (0 = no timeout) + timeout: timeout, + + // setRequestHeader + header: undefined, + headerValue: undefined, + requestedWith: false, + + // overrideMimeType + overrideMimeType: undefined + + }; +}; + +module.exports = XHRSettings; + + +/***/ }), + +/***/ "../../../src/loader/const.js": +/*!***************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/const.js ***! + \***************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FILE_CONST = { + + /** + * The Loader is idle. + * + * @name Phaser.Loader.LOADER_IDLE + * @type {integer} + * @since 3.0.0 + */ + LOADER_IDLE: 0, + + /** + * The Loader is actively loading. + * + * @name Phaser.Loader.LOADER_LOADING + * @type {integer} + * @since 3.0.0 + */ + LOADER_LOADING: 1, + + /** + * The Loader is processing files is has loaded. + * + * @name Phaser.Loader.LOADER_PROCESSING + * @type {integer} + * @since 3.0.0 + */ + LOADER_PROCESSING: 2, + + /** + * The Loader has completed loading and processing. + * + * @name Phaser.Loader.LOADER_COMPLETE + * @type {integer} + * @since 3.0.0 + */ + LOADER_COMPLETE: 3, + + /** + * The Loader is shutting down. + * + * @name Phaser.Loader.LOADER_SHUTDOWN + * @type {integer} + * @since 3.0.0 + */ + LOADER_SHUTDOWN: 4, + + /** + * The Loader has been destroyed. + * + * @name Phaser.Loader.LOADER_DESTROYED + * @type {integer} + * @since 3.0.0 + */ + LOADER_DESTROYED: 5, + + /** + * File is in the load queue but not yet started + * + * @name Phaser.Loader.FILE_PENDING + * @type {integer} + * @since 3.0.0 + */ + FILE_PENDING: 10, + + /** + * File has been started to load by the loader (onLoad called) + * + * @name Phaser.Loader.FILE_LOADING + * @type {integer} + * @since 3.0.0 + */ + FILE_LOADING: 11, + + /** + * File has loaded successfully, awaiting processing + * + * @name Phaser.Loader.FILE_LOADED + * @type {integer} + * @since 3.0.0 + */ + FILE_LOADED: 12, + + /** + * File failed to load + * + * @name Phaser.Loader.FILE_FAILED + * @type {integer} + * @since 3.0.0 + */ + FILE_FAILED: 13, + + /** + * File is being processed (onProcess callback) + * + * @name Phaser.Loader.FILE_PROCESSING + * @type {integer} + * @since 3.0.0 + */ + FILE_PROCESSING: 14, + + /** + * The File has errored somehow during processing. + * + * @name Phaser.Loader.FILE_ERRORED + * @type {integer} + * @since 3.0.0 + */ + FILE_ERRORED: 16, + + /** + * File has finished processing. + * + * @name Phaser.Loader.FILE_COMPLETE + * @type {integer} + * @since 3.0.0 + */ + FILE_COMPLETE: 17, + + /** + * File has been destroyed + * + * @name Phaser.Loader.FILE_DESTROYED + * @type {integer} + * @since 3.0.0 + */ + FILE_DESTROYED: 18, + + /** + * File was populated from local data and doesn't need an HTTP request + * + * @name Phaser.Loader.FILE_POPULATED + * @type {integer} + * @since 3.0.0 + */ + FILE_POPULATED: 19 + +}; + +module.exports = FILE_CONST; + + +/***/ }), + +/***/ "../../../src/loader/filetypes/ImageFile.js": +/*!*****************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/filetypes/ImageFile.js ***! + \*****************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../../utils/Class */ "../../../src/utils/Class.js"); +var CONST = __webpack_require__(/*! ../const */ "../../../src/loader/const.js"); +var File = __webpack_require__(/*! ../File */ "../../../src/loader/File.js"); +var FileTypesManager = __webpack_require__(/*! ../FileTypesManager */ "../../../src/loader/FileTypesManager.js"); +var GetFastValue = __webpack_require__(/*! ../../utils/object/GetFastValue */ "../../../src/utils/object/GetFastValue.js"); +var IsPlainObject = __webpack_require__(/*! ../../utils/object/IsPlainObject */ "../../../src/utils/object/IsPlainObject.js"); + +/** + * @typedef {object} Phaser.Loader.FileTypes.ImageFrameConfig + * + * @property {integer} frameWidth - The width of the frame in pixels. + * @property {integer} [frameHeight] - The height of the frame in pixels. Uses the `frameWidth` value if not provided. + * @property {integer} [startFrame=0] - The first frame to start parsing from. + * @property {integer} [endFrame] - The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions. + * @property {integer} [margin=0] - The margin in the image. This is the space around the edge of the frames. + * @property {integer} [spacing=0] - The spacing between each frame in the image. + */ + +/** + * @typedef {object} Phaser.Loader.FileTypes.ImageFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='png'] - The default file extension to use if no url is provided. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image. + * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Image File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image. + * + * @class ImageFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets. + */ +var ImageFile = new Class({ + + Extends: File, + + initialize: + + function ImageFile (loader, key, url, xhrSettings, frameConfig) + { + var extension = 'png'; + var normalMapURL; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + normalMapURL = GetFastValue(config, 'normalMap'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + frameConfig = GetFastValue(config, 'frameConfig'); + } + + if (Array.isArray(url)) + { + normalMapURL = url[1]; + url = url[0]; + } + + var fileConfig = { + type: 'image', + cache: loader.textureManager, + extension: extension, + responseType: 'blob', + key: key, + url: url, + xhrSettings: xhrSettings, + config: frameConfig + }; + + File.call(this, loader, fileConfig); + + // Do we have a normal map to load as well? + if (normalMapURL) + { + var normalMap = new ImageFile(loader, this.key, normalMapURL, xhrSettings, frameConfig); + + normalMap.type = 'normalMap'; + + this.setLink(normalMap); + + loader.addFile(normalMap); + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.ImageFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + var _this = this; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessError(); + }; + + File.createObjectURL(this.data, this.xhrLoader.response, 'image/png'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.ImageFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture; + var linkFile = this.linkFile; + + if (linkFile && linkFile.state === CONST.FILE_COMPLETE) + { + if (this.type === 'image') + { + texture = this.cache.addImage(this.key, this.data, linkFile.data); + } + else + { + texture = this.cache.addImage(linkFile.key, linkFile.data, this.data); + } + + this.pendingDestroy(texture); + + linkFile.pendingDestroy(texture); + } + else if (!linkFile) + { + texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + } + +}); + +/** + * Adds an Image, or array of Images, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.image('logo', 'images/phaserLogo.png'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback + * of animated gifs to Canvas elements. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.image({ + * key: 'logo', + * url: 'images/AtariLogo.png' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.image('logo', 'images/AtariLogo.png'); + * // and later in your game ... + * this.add.image(x, y, 'logo'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.image({ + * key: 'logo', + * url: 'images/AtariLogo.png', + * normalMap: 'images/AtariLogo-n.png' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#image + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('image', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new ImageFile(this, key[i])); + } + } + else + { + this.addFile(new ImageFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = ImageFile; + + +/***/ }), + +/***/ "../../../src/loader/filetypes/JSONFile.js": +/*!****************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/filetypes/JSONFile.js ***! + \****************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../../utils/Class */ "../../../src/utils/Class.js"); +var CONST = __webpack_require__(/*! ../const */ "../../../src/loader/const.js"); +var File = __webpack_require__(/*! ../File */ "../../../src/loader/File.js"); +var FileTypesManager = __webpack_require__(/*! ../FileTypesManager */ "../../../src/loader/FileTypesManager.js"); +var GetFastValue = __webpack_require__(/*! ../../utils/object/GetFastValue */ "../../../src/utils/object/GetFastValue.js"); +var GetValue = __webpack_require__(/*! ../../utils/object/GetValue */ "../../../src/utils/object/GetValue.js"); +var IsPlainObject = __webpack_require__(/*! ../../utils/object/IsPlainObject */ "../../../src/utils/object/IsPlainObject.js"); + +/** + * @typedef {object} Phaser.Loader.FileTypes.JSONFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the JSON Cache. + * @property {string|any} [url] - The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly added to the Cache. + * @property {string} [extension='json'] - The default file extension to use if no url is provided. + * @property {string} [dataKey] - If specified instead of the whole JSON file being parsed and added to the Cache, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single JSON File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#json method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#json. + * + * @class JSONFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + */ +var JSONFile = new Class({ + + Extends: File, + + initialize: + + // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object + // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing + + function JSONFile (loader, key, url, xhrSettings, dataKey) + { + var extension = 'json'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + dataKey = GetFastValue(config, 'dataKey', dataKey); + } + + var fileConfig = { + type: 'json', + cache: loader.cacheManager.json, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: dataKey + }; + + File.call(this, loader, fileConfig); + + if (IsPlainObject(url)) + { + // Object provided instead of a URL, so no need to actually load it (populate data with value) + if (dataKey) + { + this.data = GetValue(url, dataKey); + } + else + { + this.data = url; + } + + this.state = CONST.FILE_POPULATED; + } + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.JSONFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + if (this.state !== CONST.FILE_POPULATED) + { + this.state = CONST.FILE_PROCESSING; + + var json = JSON.parse(this.xhrLoader.responseText); + + var key = this.config; + + if (typeof key === 'string') + { + this.data = GetValue(json, key, json); + } + else + { + this.data = json; + } + } + + this.onProcessComplete(); + } + +}); + +/** + * Adds a JSON file, or array of JSON files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.json('wavedata', 'files/AlienWaveData.json'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the JSON Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the JSON Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.json({ + * key: 'wavedata', + * url: 'files/AlienWaveData.json' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.json('wavedata', 'files/AlienWaveData.json'); + * // and later in your game ... + * var data = this.cache.json.get('wavedata'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and + * this is what you would use to retrieve the text from the JSON Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "data" + * and no URL is given then the Loader will set the URL to be "data.json". It will always add `.json` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache, + * rather than the whole file. For example, if your JSON data had a structure like this: + * + * ```json + * { + * "level1": { + * "baddies": { + * "aliens": {}, + * "boss": {} + * } + * }, + * "level2": {}, + * "level3": {} + * } + * ``` + * + * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`. + * + * Note: The ability to load this type of file will only be available if the JSON File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#json + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig|Phaser.Loader.FileTypes.JSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was "alien" then the URL will be "alien.json". + * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('json', function (key, url, dataKey, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new JSONFile(this, key[i])); + } + } + else + { + this.addFile(new JSONFile(this, key, url, xhrSettings, dataKey)); + } + + return this; +}); + +module.exports = JSONFile; + + +/***/ }), + +/***/ "../../../src/loader/filetypes/TextFile.js": +/*!****************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/loader/filetypes/TextFile.js ***! + \****************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../../utils/Class */ "../../../src/utils/Class.js"); +var CONST = __webpack_require__(/*! ../const */ "../../../src/loader/const.js"); +var File = __webpack_require__(/*! ../File */ "../../../src/loader/File.js"); +var FileTypesManager = __webpack_require__(/*! ../FileTypesManager */ "../../../src/loader/FileTypesManager.js"); +var GetFastValue = __webpack_require__(/*! ../../utils/object/GetFastValue */ "../../../src/utils/object/GetFastValue.js"); +var IsPlainObject = __webpack_require__(/*! ../../utils/object/IsPlainObject */ "../../../src/utils/object/IsPlainObject.js"); + +/** + * @typedef {object} Phaser.Loader.FileTypes.TextFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='txt'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * A single Text File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. + * + * @class TextFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var TextFile = new Class({ + + Extends: File, + + initialize: + + function TextFile (loader, key, url, xhrSettings) + { + var extension = 'txt'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'text', + cache: loader.cacheManager.text, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.TextFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + } + +}); + +/** + * Adds a Text file, or array of Text files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.text('story', 'files/IntroStory.txt'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Text Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Text Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Text Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.text({ + * key: 'story', + * url: 'files/IntroStory.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.text('story', 'files/IntroStory.txt'); + * // and later in your game ... + * var data = this.cache.text.get('story'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the text from the Text Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.txt". It will always add `.txt` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Text File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#text + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.0.0 + * + * @param {(string|Phaser.Loader.FileTypes.TextFileConfig|Phaser.Loader.FileTypes.TextFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('text', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new TextFile(this, key[i])); + } + } + else + { + this.addFile(new TextFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = TextFile; + + +/***/ }), + +/***/ "../../../src/math/Clamp.js": +/*!*************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/math/Clamp.js ***! + \*************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Force a value within the boundaries by clamping it to the range `min`, `max`. + * + * @function Phaser.Math.Clamp + * @since 3.0.0 + * + * @param {number} value - The value to be clamped. + * @param {number} min - The minimum bounds. + * @param {number} max - The maximum bounds. + * + * @return {number} The clamped value. + */ +var Clamp = function (value, min, max) +{ + return Math.max(min, Math.min(max, value)); +}; + +module.exports = Clamp; + + +/***/ }), + +/***/ "../../../src/math/Matrix4.js": +/*!***************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/math/Matrix4.js ***! + \***************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(/*! ../utils/Class */ "../../../src/utils/Class.js"); + +var EPSILON = 0.000001; + +/** + * @classdesc + * A four-dimensional matrix. + * + * @class Matrix4 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} [m] - Optional Matrix4 to copy values from. + */ +var Matrix4 = new Class({ + + initialize: + + function Matrix4 (m) + { + /** + * The matrix values. + * + * @name Phaser.Math.Matrix4#val + * @type {Float32Array} + * @since 3.0.0 + */ + this.val = new Float32Array(16); + + if (m) + { + // Assume Matrix4 with val: + this.copy(m); + } + else + { + // Default to identity + this.identity(); + } + }, + + /** + * Make a clone of this Matrix4. + * + * @method Phaser.Math.Matrix4#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} A clone of this Matrix4. + */ + clone: function () + { + return new Matrix4(this); + }, + + // TODO - Should work with basic values + + /** + * This method is an alias for `Matrix4.copy`. + * + * @method Phaser.Math.Matrix4#set + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to set the values of this Matrix's from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + set: function (src) + { + return this.copy(src); + }, + + /** + * Copy the values of a given Matrix into this Matrix. + * + * @method Phaser.Math.Matrix4#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + copy: function (src) + { + var out = this.val; + var a = src.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Set the values of this Matrix from the given array. + * + * @method Phaser.Math.Matrix4#fromArray + * @since 3.0.0 + * + * @param {array} a - The array to copy the values from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromArray: function (a) + { + var out = this.val; + + out[0] = a[0]; + out[1] = a[1]; + out[2] = a[2]; + out[3] = a[3]; + out[4] = a[4]; + out[5] = a[5]; + out[6] = a[6]; + out[7] = a[7]; + out[8] = a[8]; + out[9] = a[9]; + out[10] = a[10]; + out[11] = a[11]; + out[12] = a[12]; + out[13] = a[13]; + out[14] = a[14]; + out[15] = a[15]; + + return this; + }, + + /** + * Reset this Matrix. + * + * Sets all values to `0`. + * + * @method Phaser.Math.Matrix4#zero + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + zero: function () + { + var out = this.val; + + out[0] = 0; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 0; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 0; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 0; + + return this; + }, + + /** + * Set the `x`, `y` and `z` values of this Matrix. + * + * @method Phaser.Math.Matrix4#xyz + * @since 3.0.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * @param {number} z - The z value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + xyz: function (x, y, z) + { + this.identity(); + + var out = this.val; + + out[12] = x; + out[13] = y; + out[14] = z; + + return this; + }, + + /** + * Set the scaling values of this Matrix. + * + * @method Phaser.Math.Matrix4#scaling + * @since 3.0.0 + * + * @param {number} x - The x scaling value. + * @param {number} y - The y scaling value. + * @param {number} z - The z scaling value. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scaling: function (x, y, z) + { + this.zero(); + + var out = this.val; + + out[0] = x; + out[5] = y; + out[10] = z; + out[15] = 1; + + return this; + }, + + /** + * Reset this Matrix to an identity (default) matrix. + * + * @method Phaser.Math.Matrix4#identity + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + identity: function () + { + var out = this.val; + + out[0] = 1; + out[1] = 0; + out[2] = 0; + out[3] = 0; + out[4] = 0; + out[5] = 1; + out[6] = 0; + out[7] = 0; + out[8] = 0; + out[9] = 0; + out[10] = 1; + out[11] = 0; + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Transpose this Matrix. + * + * @method Phaser.Math.Matrix4#transpose + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + transpose: function () + { + var a = this.val; + + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + var a12 = a[6]; + var a13 = a[7]; + var a23 = a[11]; + + a[1] = a[4]; + a[2] = a[8]; + a[3] = a[12]; + a[4] = a01; + a[6] = a[9]; + a[7] = a[13]; + a[8] = a02; + a[9] = a12; + a[11] = a[14]; + a[12] = a03; + a[13] = a13; + a[14] = a23; + + return this; + }, + + /** + * Invert this Matrix. + * + * @method Phaser.Math.Matrix4#invert + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + invert: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + + if (!det) + { + return null; + } + + det = 1 / det; + + a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; + a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; + a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; + a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; + a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; + a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; + a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; + a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; + a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; + a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; + a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; + a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; + a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; + a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; + a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; + a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; + + return this; + }, + + /** + * Calculate the adjoint, or adjugate, of this Matrix. + * + * @method Phaser.Math.Matrix4#adjoint + * @since 3.0.0 + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + adjoint: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22)); + a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22)); + a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12)); + a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12)); + a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22)); + a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22)); + a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12)); + a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12)); + a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21)); + a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21)); + a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11)); + a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11)); + a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21)); + a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21)); + a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11)); + a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11)); + + return this; + }, + + /** + * Calculate the determinant of this Matrix. + * + * @method Phaser.Math.Matrix4#determinant + * @since 3.0.0 + * + * @return {number} The determinant of this Matrix. + */ + determinant: function () + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b00 = a00 * a11 - a01 * a10; + var b01 = a00 * a12 - a02 * a10; + var b02 = a00 * a13 - a03 * a10; + var b03 = a01 * a12 - a02 * a11; + var b04 = a01 * a13 - a03 * a11; + var b05 = a02 * a13 - a03 * a12; + var b06 = a20 * a31 - a21 * a30; + var b07 = a20 * a32 - a22 * a30; + var b08 = a20 * a33 - a23 * a30; + var b09 = a21 * a32 - a22 * a31; + var b10 = a21 * a33 - a23 * a31; + var b11 = a22 * a33 - a23 * a32; + + // Calculate the determinant + return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; + }, + + /** + * Multiply this Matrix by the given Matrix. + * + * @method Phaser.Math.Matrix4#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - The Matrix to multiply this Matrix by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiply: function (src) + { + var a = this.val; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + var a30 = a[12]; + var a31 = a[13]; + var a32 = a[14]; + var a33 = a[15]; + + var b = src.val; + + // Cache only the current line of the second matrix + var b0 = b[0]; + var b1 = b[1]; + var b2 = b[2]; + var b3 = b[3]; + + a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[4]; + b1 = b[5]; + b2 = b[6]; + b3 = b[7]; + + a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[8]; + b1 = b[9]; + b2 = b[10]; + b3 = b[11]; + + a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + b0 = b[12]; + b1 = b[13]; + b2 = b[14]; + b3 = b[15]; + + a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; + a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; + a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; + a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; + + return this; + }, + + /** + * [description] + * + * @method Phaser.Math.Matrix4#multiplyLocal + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} src - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + multiplyLocal: function (src) + { + var a = []; + var m1 = this.val; + var m2 = src.val; + + a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12]; + a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13]; + a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14]; + a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15]; + + a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12]; + a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13]; + a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14]; + a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15]; + + a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12]; + a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13]; + a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14]; + a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15]; + + a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12]; + a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13]; + a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14]; + a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]; + + return this.fromArray(a); + }, + + /** + * Translate this Matrix using the given Vector. + * + * @method Phaser.Math.Matrix4#translate + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + translate: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + + return this; + }, + + /** + * Translate this Matrix using the given values. + * + * @method Phaser.Math.Matrix4#translateXYZ + * @since 3.16.0 + * + * @param {number} x - The x component. + * @param {number} y - The y component. + * @param {number} z - The z component. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + translateXYZ: function (x, y, z) + { + var a = this.val; + + a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix. + * + * @method Phaser.Math.Matrix4#scale + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scale: function (v) + { + var x = v.x; + var y = v.y; + var z = v.z; + var a = this.val; + + a[0] = a[0] * x; + a[1] = a[1] * x; + a[2] = a[2] * x; + a[3] = a[3] * x; + + a[4] = a[4] * y; + a[5] = a[5] * y; + a[6] = a[6] * y; + a[7] = a[7] * y; + + a[8] = a[8] * z; + a[9] = a[9] * z; + a[10] = a[10] * z; + a[11] = a[11] * z; + + return this; + }, + + /** + * Apply a scale transformation to this Matrix. + * + * @method Phaser.Math.Matrix4#scaleXYZ + * @since 3.16.0 + * + * @param {number} x - The x component. + * @param {number} y - The y component. + * @param {number} z - The z component. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scaleXYZ: function (x, y, z) + { + var a = this.val; + + a[0] = a[0] * x; + a[1] = a[1] * x; + a[2] = a[2] * x; + a[3] = a[3] * x; + + a[4] = a[4] * y; + a[5] = a[5] * y; + a[6] = a[6] * y; + a[7] = a[7] * y; + + a[8] = a[8] * z; + a[9] = a[9] * z; + a[10] = a[10] * z; + a[11] = a[11] * z; + + return this; + }, + + /** + * Derive a rotation matrix around the given axis. + * + * @method Phaser.Math.Matrix4#makeRotationAxis + * @since 3.0.0 + * + * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis. + * @param {number} angle - The rotation angle in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + makeRotationAxis: function (axis, angle) + { + // Based on http://www.gamedev.net/reference/articles/article1199.asp + + var c = Math.cos(angle); + var s = Math.sin(angle); + var t = 1 - c; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var tx = t * x; + var ty = t * y; + + this.fromArray([ + tx * x + c, tx * y - s * z, tx * z + s * y, 0, + tx * y + s * z, ty * y + c, ty * z - s * x, 0, + tx * z - s * y, ty * z + s * x, t * z * z + c, 0, + 0, 0, 0, 1 + ]); + + return this; + }, + + /** + * Apply a rotation transformation to this Matrix. + * + * @method Phaser.Math.Matrix4#rotate + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * @param {Phaser.Math.Vector3} axis - The axis to rotate upon. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotate: function (rad, axis) + { + var a = this.val; + var x = axis.x; + var y = axis.y; + var z = axis.z; + var len = Math.sqrt(x * x + y * y + z * z); + + if (Math.abs(len) < EPSILON) + { + return null; + } + + len = 1 / len; + x *= len; + y *= len; + z *= len; + + var s = Math.sin(rad); + var c = Math.cos(rad); + var t = 1 - c; + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Construct the elements of the rotation matrix + var b00 = x * x * t + c; + var b01 = y * x * t + z * s; + var b02 = z * x * t - y * s; + + var b10 = x * y * t - z * s; + var b11 = y * y * t + c; + var b12 = z * y * t + x * s; + + var b20 = x * z * t + y * s; + var b21 = y * z * t - x * s; + var b22 = z * z * t + c; + + // Perform rotation-specific matrix multiplication + a[0] = a00 * b00 + a10 * b01 + a20 * b02; + a[1] = a01 * b00 + a11 * b01 + a21 * b02; + a[2] = a02 * b00 + a12 * b01 + a22 * b02; + a[3] = a03 * b00 + a13 * b01 + a23 * b02; + a[4] = a00 * b10 + a10 * b11 + a20 * b12; + a[5] = a01 * b10 + a11 * b11 + a21 * b12; + a[6] = a02 * b10 + a12 * b11 + a22 * b12; + a[7] = a03 * b10 + a13 * b11 + a23 * b12; + a[8] = a00 * b20 + a10 * b21 + a20 * b22; + a[9] = a01 * b20 + a11 * b21 + a21 * b22; + a[10] = a02 * b20 + a12 * b21 + a22 * b22; + a[11] = a03 * b20 + a13 * b21 + a23 * b22; + + return this; + }, + + /** + * Rotate this matrix on its X axis. + * + * @method Phaser.Math.Matrix4#rotateX + * @since 3.0.0 + * + * @param {number} rad - The angle in radians to rotate by. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateX: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[4] = a10 * c + a20 * s; + a[5] = a11 * c + a21 * s; + a[6] = a12 * c + a22 * s; + a[7] = a13 * c + a23 * s; + a[8] = a20 * c - a10 * s; + a[9] = a21 * c - a11 * s; + a[10] = a22 * c - a12 * s; + a[11] = a23 * c - a13 * s; + + return this; + }, + + /** + * Rotate this matrix on its Y axis. + * + * @method Phaser.Math.Matrix4#rotateY + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateY: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a20 = a[8]; + var a21 = a[9]; + var a22 = a[10]; + var a23 = a[11]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c - a20 * s; + a[1] = a01 * c - a21 * s; + a[2] = a02 * c - a22 * s; + a[3] = a03 * c - a23 * s; + a[8] = a00 * s + a20 * c; + a[9] = a01 * s + a21 * c; + a[10] = a02 * s + a22 * c; + a[11] = a03 * s + a23 * c; + + return this; + }, + + /** + * Rotate this matrix on its Z axis. + * + * @method Phaser.Math.Matrix4#rotateZ + * @since 3.0.0 + * + * @param {number} rad - The angle to rotate by, in radians. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + rotateZ: function (rad) + { + var a = this.val; + var s = Math.sin(rad); + var c = Math.cos(rad); + + var a00 = a[0]; + var a01 = a[1]; + var a02 = a[2]; + var a03 = a[3]; + + var a10 = a[4]; + var a11 = a[5]; + var a12 = a[6]; + var a13 = a[7]; + + // Perform axis-specific matrix multiplication + a[0] = a00 * c + a10 * s; + a[1] = a01 * c + a11 * s; + a[2] = a02 * c + a12 * s; + a[3] = a03 * c + a13 * s; + a[4] = a10 * c - a00 * s; + a[5] = a11 * c - a01 * s; + a[6] = a12 * c - a02 * s; + a[7] = a13 * c - a03 * s; + + return this; + }, + + /** + * Set the values of this Matrix from the given rotation Quaternion and translation Vector. + * + * @method Phaser.Math.Matrix4#fromRotationTranslation + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set rotation from. + * @param {Phaser.Math.Vector3} v - The Vector to set translation from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromRotationTranslation: function (q, v) + { + // Quaternion math + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = v.x; + out[13] = v.y; + out[14] = v.z; + out[15] = 1; + + return this; + }, + + /** + * Set the values of this Matrix from the given Quaternion. + * + * @method Phaser.Math.Matrix4#fromQuat + * @since 3.0.0 + * + * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + fromQuat: function (q) + { + var out = this.val; + + var x = q.x; + var y = q.y; + var z = q.z; + var w = q.w; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x * x2; + var xy = x * y2; + var xz = x * z2; + + var yy = y * y2; + var yz = y * z2; + var zz = z * z2; + + var wx = w * x2; + var wy = w * y2; + var wz = w * z2; + + out[0] = 1 - (yy + zz); + out[1] = xy + wz; + out[2] = xz - wy; + out[3] = 0; + + out[4] = xy - wz; + out[5] = 1 - (xx + zz); + out[6] = yz + wx; + out[7] = 0; + + out[8] = xz + wy; + out[9] = yz - wx; + out[10] = 1 - (xx + yy); + out[11] = 0; + + out[12] = 0; + out[13] = 0; + out[14] = 0; + out[15] = 1; + + return this; + }, + + /** + * Generate a frustum matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#frustum + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + frustum: function (left, right, bottom, top, near, far) + { + var out = this.val; + + var rl = 1 / (right - left); + var tb = 1 / (top - bottom); + var nf = 1 / (near - far); + + out[0] = (near * 2) * rl; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (near * 2) * tb; + out[6] = 0; + out[7] = 0; + + out[8] = (right + left) * rl; + out[9] = (top + bottom) * tb; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (far * near * 2) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspective + * @since 3.0.0 + * + * @param {number} fovy - Vertical field of view in radians + * @param {number} aspect - Aspect ratio. Typically viewport width /height. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspective: function (fovy, aspect, near, far) + { + var out = this.val; + var f = 1.0 / Math.tan(fovy / 2); + var nf = 1 / (near - far); + + out[0] = f / aspect; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = f; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = (far + near) * nf; + out[11] = -1; + + out[12] = 0; + out[13] = 0; + out[14] = (2 * far * near) * nf; + out[15] = 0; + + return this; + }, + + /** + * Generate a perspective projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#perspectiveLH + * @since 3.0.0 + * + * @param {number} width - The width of the frustum. + * @param {number} height - The height of the frustum. + * @param {number} near - Near bound of the frustum. + * @param {number} far - Far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + perspectiveLH: function (width, height, near, far) + { + var out = this.val; + + out[0] = (2 * near) / width; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = (2 * near) / height; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = -far / (near - far); + out[11] = 1; + + out[12] = 0; + out[13] = 0; + out[14] = (near * far) / (near - far); + out[15] = 0; + + return this; + }, + + /** + * Generate an orthogonal projection matrix with the given bounds. + * + * @method Phaser.Math.Matrix4#ortho + * @since 3.0.0 + * + * @param {number} left - The left bound of the frustum. + * @param {number} right - The right bound of the frustum. + * @param {number} bottom - The bottom bound of the frustum. + * @param {number} top - The top bound of the frustum. + * @param {number} near - The near bound of the frustum. + * @param {number} far - The far bound of the frustum. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + ortho: function (left, right, bottom, top, near, far) + { + var out = this.val; + var lr = left - right; + var bt = bottom - top; + var nf = near - far; + + // Avoid division by zero + lr = (lr === 0) ? lr : 1 / lr; + bt = (bt === 0) ? bt : 1 / bt; + nf = (nf === 0) ? nf : 1 / nf; + + out[0] = -2 * lr; + out[1] = 0; + out[2] = 0; + out[3] = 0; + + out[4] = 0; + out[5] = -2 * bt; + out[6] = 0; + out[7] = 0; + + out[8] = 0; + out[9] = 0; + out[10] = 2 * nf; + out[11] = 0; + + out[12] = (left + right) * lr; + out[13] = (top + bottom) * bt; + out[14] = (far + near) * nf; + out[15] = 1; + + return this; + }, + + /** + * Generate a look-at matrix with the given eye position, focal point, and up axis. + * + * @method Phaser.Math.Matrix4#lookAt + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} eye - Position of the viewer + * @param {Phaser.Math.Vector3} center - Point the viewer is looking at + * @param {Phaser.Math.Vector3} up - vec3 pointing up. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + lookAt: function (eye, center, up) + { + var out = this.val; + + var eyex = eye.x; + var eyey = eye.y; + var eyez = eye.z; + + var upx = up.x; + var upy = up.y; + var upz = up.z; + + var centerx = center.x; + var centery = center.y; + var centerz = center.z; + + if (Math.abs(eyex - centerx) < EPSILON && + Math.abs(eyey - centery) < EPSILON && + Math.abs(eyez - centerz) < EPSILON) + { + return this.identity(); + } + + var z0 = eyex - centerx; + var z1 = eyey - centery; + var z2 = eyez - centerz; + + var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); + + z0 *= len; + z1 *= len; + z2 *= len; + + var x0 = upy * z2 - upz * z1; + var x1 = upz * z0 - upx * z2; + var x2 = upx * z1 - upy * z0; + + len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); + + if (!len) + { + x0 = 0; + x1 = 0; + x2 = 0; + } + else + { + len = 1 / len; + x0 *= len; + x1 *= len; + x2 *= len; + } + + var y0 = z1 * x2 - z2 * x1; + var y1 = z2 * x0 - z0 * x2; + var y2 = z0 * x1 - z1 * x0; + + len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); + + if (!len) + { + y0 = 0; + y1 = 0; + y2 = 0; + } + else + { + len = 1 / len; + y0 *= len; + y1 *= len; + y2 *= len; + } + + out[0] = x0; + out[1] = y0; + out[2] = z0; + out[3] = 0; + + out[4] = x1; + out[5] = y1; + out[6] = z1; + out[7] = 0; + + out[8] = x2; + out[9] = y2; + out[10] = z2; + out[11] = 0; + + out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); + out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); + out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); + out[15] = 1; + + return this; + }, + + /** + * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values. + * + * @method Phaser.Math.Matrix4#yawPitchRoll + * @since 3.0.0 + * + * @param {number} yaw - [description] + * @param {number} pitch - [description] + * @param {number} roll - [description] + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + yawPitchRoll: function (yaw, pitch, roll) + { + this.zero(); + _tempMat1.zero(); + _tempMat2.zero(); + + var m0 = this.val; + var m1 = _tempMat1.val; + var m2 = _tempMat2.val; + + // Rotate Z + var s = Math.sin(roll); + var c = Math.cos(roll); + + m0[10] = 1; + m0[15] = 1; + m0[0] = c; + m0[1] = s; + m0[4] = -s; + m0[5] = c; + + // Rotate X + s = Math.sin(pitch); + c = Math.cos(pitch); + + m1[0] = 1; + m1[15] = 1; + m1[5] = c; + m1[10] = c; + m1[9] = -s; + m1[6] = s; + + // Rotate Y + s = Math.sin(yaw); + c = Math.cos(yaw); + + m2[5] = 1; + m2[15] = 1; + m2[0] = c; + m2[2] = -s; + m2[8] = s; + m2[10] = c; + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + return this; + }, + + /** + * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix. + * + * @method Phaser.Math.Matrix4#setWorldMatrix + * @since 3.0.0 + * + * @param {Phaser.Math.Vector3} rotation - The rotation of the world matrix. + * @param {Phaser.Math.Vector3} position - The position of the world matrix. + * @param {Phaser.Math.Vector3} scale - The scale of the world matrix. + * @param {Phaser.Math.Matrix4} [viewMatrix] - The view matrix. + * @param {Phaser.Math.Matrix4} [projectionMatrix] - The projection matrix. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix) + { + this.yawPitchRoll(rotation.y, rotation.x, rotation.z); + + _tempMat1.scaling(scale.x, scale.y, scale.z); + _tempMat2.xyz(position.x, position.y, position.z); + + this.multiplyLocal(_tempMat1); + this.multiplyLocal(_tempMat2); + + if (viewMatrix !== undefined) + { + this.multiplyLocal(viewMatrix); + } + + if (projectionMatrix !== undefined) + { + this.multiplyLocal(projectionMatrix); + } + + return this; + } + +}); + +var _tempMat1 = new Matrix4(); +var _tempMat2 = new Matrix4(); + +module.exports = Matrix4; + + +/***/ }), + +/***/ "../../../src/math/Vector2.js": +/*!***************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/math/Vector2.js ***! + \***************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji +// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl + +var Class = __webpack_require__(/*! ../utils/Class */ "../../../src/utils/Class.js"); + +/** + * @typedef {object} Vector2Like + * + * @property {number} x - The x component. + * @property {number} y - The y component. + */ + +/** + * @classdesc + * A representation of a vector in 2D space. + * + * A two-component vector. + * + * @class Vector2 + * @memberof Phaser.Math + * @constructor + * @since 3.0.0 + * + * @param {number|Vector2Like} [x] - The x component, or an object with `x` and `y` properties. + * @param {number} [y] - The y component. + */ +var Vector2 = new Class({ + + initialize: + + function Vector2 (x, y) + { + /** + * The x component of this Vector. + * + * @name Phaser.Math.Vector2#x + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.x = 0; + + /** + * The y component of this Vector. + * + * @name Phaser.Math.Vector2#y + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.y = 0; + + if (typeof x === 'object') + { + this.x = x.x || 0; + this.y = x.y || 0; + } + else + { + if (y === undefined) { y = x; } + + this.x = x || 0; + this.y = y || 0; + } + }, + + /** + * Make a clone of this Vector2. + * + * @method Phaser.Math.Vector2#clone + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} A clone of this Vector2. + */ + clone: function () + { + return new Vector2(this.x, this.y); + }, + + /** + * Copy the components of a given Vector into this Vector. + * + * @method Phaser.Math.Vector2#copy + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to copy the components from. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + copy: function (src) + { + this.x = src.x || 0; + this.y = src.y || 0; + + return this; + }, + + /** + * Set the component values of this Vector from a given Vector2Like object. + * + * @method Phaser.Math.Vector2#setFromObject + * @since 3.0.0 + * + * @param {Vector2Like} obj - The object containing the component values to set for this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + setFromObject: function (obj) + { + this.x = obj.x || 0; + this.y = obj.y || 0; + + return this; + }, + + /** + * Set the `x` and `y` components of the this Vector to the given `x` and `y` values. + * + * @method Phaser.Math.Vector2#set + * @since 3.0.0 + * + * @param {number} x - The x value to set for this Vector. + * @param {number} [y=x] - The y value to set for this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + set: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * This method is an alias for `Vector2.set`. + * + * @method Phaser.Math.Vector2#setTo + * @since 3.4.0 + * + * @param {number} x - The x value to set for this Vector. + * @param {number} [y=x] - The y value to set for this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + setTo: function (x, y) + { + return this.set(x, y); + }, + + /** + * Sets the `x` and `y` values of this object from a given polar coordinate. + * + * @method Phaser.Math.Vector2#setToPolar + * @since 3.0.0 + * + * @param {number} azimuth - The angular coordinate, in radians. + * @param {number} [radius=1] - The radial coordinate (length). + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + setToPolar: function (azimuth, radius) + { + if (radius == null) { radius = 1; } + + this.x = Math.cos(azimuth) * radius; + this.y = Math.sin(azimuth) * radius; + + return this; + }, + + /** + * Check whether this Vector is equal to a given Vector. + * + * Performs a strict equality check against each Vector's components. + * + * @method Phaser.Math.Vector2#equals + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} v - The vector to compare with this Vector. + * + * @return {boolean} Whether the given Vector is equal to this Vector. + */ + equals: function (v) + { + return ((this.x === v.x) && (this.y === v.y)); + }, + + /** + * Calculate the angle between this Vector and the positive x-axis, in radians. + * + * @method Phaser.Math.Vector2#angle + * @since 3.0.0 + * + * @return {number} The angle between this Vector, and the positive x-axis, given in radians. + */ + angle: function () + { + // computes the angle in radians with respect to the positive x-axis + + var angle = Math.atan2(this.y, this.x); + + if (angle < 0) + { + angle += 2 * Math.PI; + } + + return angle; + }, + + /** + * Add a given Vector to this Vector. Addition is component-wise. + * + * @method Phaser.Math.Vector2#add + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to add to this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + add: function (src) + { + this.x += src.x; + this.y += src.y; + + return this; + }, + + /** + * Subtract the given Vector from this Vector. Subtraction is component-wise. + * + * @method Phaser.Math.Vector2#subtract + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to subtract from this Vector. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + subtract: function (src) + { + this.x -= src.x; + this.y -= src.y; + + return this; + }, + + /** + * Perform a component-wise multiplication between this Vector and the given Vector. + * + * Multiplies this Vector by the given Vector. + * + * @method Phaser.Math.Vector2#multiply + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to multiply this Vector by. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + multiply: function (src) + { + this.x *= src.x; + this.y *= src.y; + + return this; + }, + + /** + * Scale this Vector by the given value. + * + * @method Phaser.Math.Vector2#scale + * @since 3.0.0 + * + * @param {number} value - The value to scale this Vector by. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + scale: function (value) + { + if (isFinite(value)) + { + this.x *= value; + this.y *= value; + } + else + { + this.x = 0; + this.y = 0; + } + + return this; + }, + + /** + * Perform a component-wise division between this Vector and the given Vector. + * + * Divides this Vector by the given Vector. + * + * @method Phaser.Math.Vector2#divide + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to divide this Vector by. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + divide: function (src) + { + this.x /= src.x; + this.y /= src.y; + + return this; + }, + + /** + * Negate the `x` and `y` components of this Vector. + * + * @method Phaser.Math.Vector2#negate + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + negate: function () + { + this.x = -this.x; + this.y = -this.y; + + return this; + }, + + /** + * Calculate the distance between this Vector and the given Vector. + * + * @method Phaser.Math.Vector2#distance + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector. + */ + distance: function (src) + { + var dx = src.x - this.x; + var dy = src.y - this.y; + + return Math.sqrt(dx * dx + dy * dy); + }, + + /** + * Calculate the distance between this Vector and the given Vector, squared. + * + * @method Phaser.Math.Vector2#distanceSq + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to. + * + * @return {number} The distance from this Vector to the given Vector, squared. + */ + distanceSq: function (src) + { + var dx = src.x - this.x; + var dy = src.y - this.y; + + return dx * dx + dy * dy; + }, + + /** + * Calculate the length (or magnitude) of this Vector. + * + * @method Phaser.Math.Vector2#length + * @since 3.0.0 + * + * @return {number} The length of this Vector. + */ + length: function () + { + var x = this.x; + var y = this.y; + + return Math.sqrt(x * x + y * y); + }, + + /** + * Calculate the length of this Vector squared. + * + * @method Phaser.Math.Vector2#lengthSq + * @since 3.0.0 + * + * @return {number} The length of this Vector, squared. + */ + lengthSq: function () + { + var x = this.x; + var y = this.y; + + return x * x + y * y; + }, + + /** + * Normalize this Vector. + * + * Makes the vector a unit length vector (magnitude of 1) in the same direction. + * + * @method Phaser.Math.Vector2#normalize + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + normalize: function () + { + var x = this.x; + var y = this.y; + var len = x * x + y * y; + + if (len > 0) + { + len = 1 / Math.sqrt(len); + + this.x = x * len; + this.y = y * len; + } + + return this; + }, + + /** + * Right-hand normalize (make unit length) this Vector. + * + * @method Phaser.Math.Vector2#normalizeRightHand + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + normalizeRightHand: function () + { + var x = this.x; + + this.x = this.y * -1; + this.y = x; + + return this; + }, + + /** + * Calculate the dot product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector2#dot + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector2 to dot product with this Vector2. + * + * @return {number} The dot product of this Vector and the given Vector. + */ + dot: function (src) + { + return this.x * src.x + this.y * src.y; + }, + + /** + * Calculate the cross product of this Vector and the given Vector. + * + * @method Phaser.Math.Vector2#cross + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector2 to cross with this Vector2. + * + * @return {number} The cross product of this Vector and the given Vector. + */ + cross: function (src) + { + return this.x * src.y - this.y * src.x; + }, + + /** + * Linearly interpolate between this Vector and the given Vector. + * + * Interpolates this Vector towards the given Vector. + * + * @method Phaser.Math.Vector2#lerp + * @since 3.0.0 + * + * @param {Phaser.Math.Vector2} src - The Vector2 to interpolate towards. + * @param {number} [t=0] - The interpolation percentage, between 0 and 1. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + lerp: function (src, t) + { + if (t === undefined) { t = 0; } + + var ax = this.x; + var ay = this.y; + + this.x = ax + t * (src.x - ax); + this.y = ay + t * (src.y - ay); + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector2#transformMat3 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector2 with. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + transformMat3: function (mat) + { + var x = this.x; + var y = this.y; + var m = mat.val; + + this.x = m[0] * x + m[3] * y + m[6]; + this.y = m[1] * x + m[4] * y + m[7]; + + return this; + }, + + /** + * Transform this Vector with the given Matrix. + * + * @method Phaser.Math.Vector2#transformMat4 + * @since 3.0.0 + * + * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector2 with. + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + transformMat4: function (mat) + { + var x = this.x; + var y = this.y; + var m = mat.val; + + this.x = m[0] * x + m[4] * y + m[12]; + this.y = m[1] * x + m[5] * y + m[13]; + + return this; + }, + + /** + * Make this Vector the zero vector (0, 0). + * + * @method Phaser.Math.Vector2#reset + * @since 3.0.0 + * + * @return {Phaser.Math.Vector2} This Vector2. + */ + reset: function () + { + this.x = 0; + this.y = 0; + + return this; + } + +}); + +/** + * A static zero Vector2 for use by reference. + * + * @constant + * @name Phaser.Math.Vector2.ZERO + * @type {Vector2} + * @since 3.1.0 + */ +Vector2.ZERO = new Vector2(); + +module.exports = Vector2; + + +/***/ }), + +/***/ "../../../src/math/Wrap.js": +/*!************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/math/Wrap.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Wrap the given `value` between `min` and `max. + * + * @function Phaser.Math.Wrap + * @since 3.0.0 + * + * @param {number} value - The value to wrap. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. + * + * @return {number} The wrapped value. + */ +var Wrap = function (value, min, max) +{ + var range = max - min; + + return (min + ((((value - min) % range) + range) % range)); +}; + +module.exports = Wrap; + + +/***/ }), + +/***/ "../../../src/math/angle/CounterClockwise.js": +/*!******************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/math/angle/CounterClockwise.js ***! + \******************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = __webpack_require__(/*! ../const */ "../../../src/math/const.js"); + +/** + * Takes an angle in Phasers default clockwise format and converts it so that + * 0 is North, 90 is West, 180 is South and 270 is East, + * therefore running counter-clockwise instead of clockwise. + * + * You can pass in the angle from a Game Object using: + * + * ```javascript + * var converted = CounterClockwise(gameobject.rotation); + * ``` + * + * All values for this function are in radians. + * + * @function Phaser.Math.Angle.CounterClockwise + * @since 3.16.0 + * + * @param {number} angle - The angle to convert, in radians. + * + * @return {number} The converted angle, in radians. + */ +var CounterClockwise = function (angle) +{ + return Math.abs((((angle + CONST.TAU) % CONST.PI2) - CONST.PI2) % CONST.PI2); +}; + +module.exports = CounterClockwise; + + +/***/ }), + +/***/ "../../../src/math/angle/Wrap.js": +/*!******************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/math/angle/Wrap.js ***! + \******************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MathWrap = __webpack_require__(/*! ../Wrap */ "../../../src/math/Wrap.js"); + +/** + * Wrap an angle. + * + * Wraps the angle to a value in the range of -PI to PI. + * + * @function Phaser.Math.Angle.Wrap + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in radians. + * + * @return {number} The wrapped angle, in radians. + */ +var Wrap = function (angle) +{ + return MathWrap(angle, -Math.PI, Math.PI); +}; + +module.exports = Wrap; + + +/***/ }), + +/***/ "../../../src/math/angle/WrapDegrees.js": +/*!*************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/math/angle/WrapDegrees.js ***! + \*************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Wrap = __webpack_require__(/*! ../Wrap */ "../../../src/math/Wrap.js"); + +/** + * Wrap an angle in degrees. + * + * Wraps the angle to a value in the range of -180 to 180. + * + * @function Phaser.Math.Angle.WrapDegrees + * @since 3.0.0 + * + * @param {number} angle - The angle to wrap, in degrees. + * + * @return {number} The wrapped angle, in degrees. + */ +var WrapDegrees = function (angle) +{ + return Wrap(angle, -180, 180); +}; + +module.exports = WrapDegrees; + + +/***/ }), + +/***/ "../../../src/math/const.js": +/*!*************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/math/const.js ***! + \*************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var MATH_CONST = { + + /** + * The value of PI * 2. + * + * @name Phaser.Math.PI2 + * @type {number} + * @since 3.0.0 + */ + PI2: Math.PI * 2, + + /** + * The value of PI * 0.5. + * + * @name Phaser.Math.TAU + * @type {number} + * @since 3.0.0 + */ + TAU: Math.PI * 0.5, + + /** + * An epsilon value (1.0e-6) + * + * @name Phaser.Math.EPSILON + * @type {number} + * @since 3.0.0 + */ + EPSILON: 1.0e-6, + + /** + * For converting degrees to radians (PI / 180) + * + * @name Phaser.Math.DEG_TO_RAD + * @type {number} + * @since 3.0.0 + */ + DEG_TO_RAD: Math.PI / 180, + + /** + * For converting radians to degrees (180 / PI) + * + * @name Phaser.Math.RAD_TO_DEG + * @type {number} + * @since 3.0.0 + */ + RAD_TO_DEG: 180 / Math.PI, + + /** + * An instance of the Random Number Generator. + * + * @name Phaser.Math.RND + * @type {Phaser.Math.RandomDataGenerator} + * @since 3.0.0 + */ + RND: null + +}; + +module.exports = MATH_CONST; + + +/***/ }), + +/***/ "../../../src/plugins/BasePlugin.js": +/*!*********************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/plugins/BasePlugin.js ***! + \*********************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* @author Richard Davey +* @copyright 2018 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} +*/ + +var Class = __webpack_require__(/*! ../utils/Class */ "../../../src/utils/Class.js"); + +/** + * @classdesc + * A Global Plugin is installed just once into the Game owned Plugin Manager. + * It can listen for Game events and respond to them. + * + * @class BasePlugin + * @memberof Phaser.Plugins + * @constructor + * @since 3.8.0 + * + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager. + */ +var BasePlugin = new Class({ + + initialize: + + function BasePlugin (pluginManager) + { + /** + * A handy reference to the Plugin Manager that is responsible for this plugin. + * Can be used as a route to gain access to game systems and events. + * + * @name Phaser.Plugins.BasePlugin#pluginManager + * @type {Phaser.Plugins.PluginManager} + * @protected + * @since 3.8.0 + */ + this.pluginManager = pluginManager; + + /** + * A reference to the Game instance this plugin is running under. + * + * @name Phaser.Plugins.BasePlugin#game + * @type {Phaser.Game} + * @protected + * @since 3.8.0 + */ + this.game = pluginManager.game; + + /** + * A reference to the Scene that has installed this plugin. + * Only set if it's a Scene Plugin, otherwise `null`. + * This property is only set when the plugin is instantiated and added to the Scene, not before. + * You cannot use it during the `init` method, but you can during the `boot` method. + * + * @name Phaser.Plugins.BasePlugin#scene + * @type {?Phaser.Scene} + * @protected + * @since 3.8.0 + */ + this.scene; + + /** + * A reference to the Scene Systems of the Scene that has installed this plugin. + * Only set if it's a Scene Plugin, otherwise `null`. + * This property is only set when the plugin is instantiated and added to the Scene, not before. + * You cannot use it during the `init` method, but you can during the `boot` method. + * + * @name Phaser.Plugins.BasePlugin#systems + * @type {?Phaser.Scenes.Systems} + * @protected + * @since 3.8.0 + */ + this.systems; + }, + + /** + * Called by the PluginManager when this plugin is first instantiated. + * It will never be called again on this instance. + * In here you can set-up whatever you need for this plugin to run. + * If a plugin is set to automatically start then `BasePlugin.start` will be called immediately after this. + * + * @method Phaser.Plugins.BasePlugin#init + * @since 3.8.0 + * + * @param {?any} [data] - A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually). + */ + init: function () + { + }, + + /** + * Called by the PluginManager when this plugin is started. + * If a plugin is stopped, and then started again, this will get called again. + * Typically called immediately after `BasePlugin.init`. + * + * @method Phaser.Plugins.BasePlugin#start + * @since 3.8.0 + */ + start: function () + { + // Here are the game-level events you can listen to. + // At the very least you should offer a destroy handler for when the game closes down. + + // var eventEmitter = this.game.events; + + // eventEmitter.once('destroy', this.gameDestroy, this); + // eventEmitter.on('pause', this.gamePause, this); + // eventEmitter.on('resume', this.gameResume, this); + // eventEmitter.on('resize', this.gameResize, this); + // eventEmitter.on('prestep', this.gamePreStep, this); + // eventEmitter.on('step', this.gameStep, this); + // eventEmitter.on('poststep', this.gamePostStep, this); + // eventEmitter.on('prerender', this.gamePreRender, this); + // eventEmitter.on('postrender', this.gamePostRender, this); + }, + + /** + * Called by the PluginManager when this plugin is stopped. + * The game code has requested that your plugin stop doing whatever it does. + * It is now considered as 'inactive' by the PluginManager. + * Handle that process here (i.e. stop listening for events, etc) + * If the plugin is started again then `BasePlugin.start` will be called again. + * + * @method Phaser.Plugins.BasePlugin#stop + * @since 3.8.0 + */ + stop: function () + { + }, + + /** + * If this is a Scene Plugin (i.e. installed into a Scene) then this method is called when the Scene boots. + * By this point the plugin properties `scene` and `systems` will have already been set. + * In here you can listen for Scene events and set-up whatever you need for this plugin to run. + * + * @method Phaser.Plugins.BasePlugin#boot + * @since 3.8.0 + */ + boot: function () + { + // Here are the Scene events you can listen to. + // At the very least you should offer a destroy handler for when the Scene closes down. + + // var eventEmitter = this.systems.events; + + // eventEmitter.once('destroy', this.sceneDestroy, this); + // eventEmitter.on('start', this.sceneStart, this); + // eventEmitter.on('preupdate', this.scenePreUpdate, this); + // eventEmitter.on('update', this.sceneUpdate, this); + // eventEmitter.on('postupdate', this.scenePostUpdate, this); + // eventEmitter.on('pause', this.scenePause, this); + // eventEmitter.on('resume', this.sceneResume, this); + // eventEmitter.on('sleep', this.sceneSleep, this); + // eventEmitter.on('wake', this.sceneWake, this); + // eventEmitter.on('shutdown', this.sceneShutdown, this); + // eventEmitter.on('destroy', this.sceneDestroy, this); + }, + + /** + * Game instance has been destroyed. + * You must release everything in here, all references, all objects, free it all up. + * + * @method Phaser.Plugins.BasePlugin#destroy + * @since 3.8.0 + */ + destroy: function () + { + this.pluginManager = null; + this.game = null; + this.scene = null; + this.systems = null; + } + +}); + +module.exports = BasePlugin; + + +/***/ }), + +/***/ "../../../src/plugins/ScenePlugin.js": +/*!**********************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/plugins/ScenePlugin.js ***! + \**********************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** +* @author Richard Davey +* @copyright 2018 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License} +*/ + +var BasePlugin = __webpack_require__(/*! ./BasePlugin */ "../../../src/plugins/BasePlugin.js"); +var Class = __webpack_require__(/*! ../utils/Class */ "../../../src/utils/Class.js"); + +/** + * @classdesc + * A Scene Level Plugin is installed into every Scene and belongs to that Scene. + * It can listen for Scene events and respond to them. + * It can map itself to a Scene property, or into the Scene Systems, or both. + * + * @class ScenePlugin + * @memberof Phaser.Plugins + * @extends Phaser.Plugins.BasePlugin + * @constructor + * @since 3.8.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager. + */ +var ScenePlugin = new Class({ + + Extends: BasePlugin, + + initialize: + + function ScenePlugin (scene, pluginManager) + { + BasePlugin.call(this, pluginManager); + + this.scene = scene; + this.systems = scene.sys; + + scene.sys.events.once('boot', this.boot, this); + }, + + /** + * This method is called when the Scene boots. It is only ever called once. + * + * By this point the plugin properties `scene` and `systems` will have already been set. + * + * In here you can listen for Scene events and set-up whatever you need for this plugin to run. + * Here are the Scene events you can listen to: + * + * start + * ready + * preupdate + * update + * postupdate + * resize + * pause + * resume + * sleep + * wake + * transitioninit + * transitionstart + * transitioncomplete + * transitionout + * shutdown + * destroy + * + * At the very least you should offer a destroy handler for when the Scene closes down, i.e: + * + * ```javascript + * var eventEmitter = this.systems.events; + * eventEmitter.once('destroy', this.sceneDestroy, this); + * ``` + * + * @method Phaser.Plugins.ScenePlugin#boot + * @since 3.8.0 + */ + boot: function () + { + } + +}); + +module.exports = ScenePlugin; + + +/***/ }), + +/***/ "../../../src/renderer/BlendModes.js": +/*!**********************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/renderer/BlendModes.js ***! + \**********************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser Blend Modes. + * + * @name Phaser.BlendModes + * @enum {integer} + * @memberof Phaser + * @readonly + * @since 3.0.0 + */ + +module.exports = { + + /** + * Skips the Blend Mode check in the renderer. + * + * @name Phaser.BlendModes.SKIP_CHECK + */ + SKIP_CHECK: -1, + + /** + * Normal blend mode. + * + * @name Phaser.BlendModes.NORMAL + */ + NORMAL: 0, + + /** + * Add blend mode. + * + * @name Phaser.BlendModes.ADD + */ + ADD: 1, + + /** + * Multiply blend mode. + * + * @name Phaser.BlendModes.MULTIPLY + */ + MULTIPLY: 2, + + /** + * Screen blend mode. + * + * @name Phaser.BlendModes.SCREEN + */ + SCREEN: 3, + + /** + * Overlay blend mode. + * + * @name Phaser.BlendModes.OVERLAY + */ + OVERLAY: 4, + + /** + * Darken blend mode. + * + * @name Phaser.BlendModes.DARKEN + */ + DARKEN: 5, + + /** + * Lighten blend mode. + * + * @name Phaser.BlendModes.LIGHTEN + */ + LIGHTEN: 6, + + /** + * Color Dodge blend mode. + * + * @name Phaser.BlendModes.COLOR_DODGE + */ + COLOR_DODGE: 7, + + /** + * Color Burn blend mode. + * + * @name Phaser.BlendModes.COLOR_BURN + */ + COLOR_BURN: 8, + + /** + * Hard Light blend mode. + * + * @name Phaser.BlendModes.HARD_LIGHT + */ + HARD_LIGHT: 9, + + /** + * Soft Light blend mode. + * + * @name Phaser.BlendModes.SOFT_LIGHT + */ + SOFT_LIGHT: 10, + + /** + * Difference blend mode. + * + * @name Phaser.BlendModes.DIFFERENCE + */ + DIFFERENCE: 11, + + /** + * Exclusion blend mode. + * + * @name Phaser.BlendModes.EXCLUSION + */ + EXCLUSION: 12, + + /** + * Hue blend mode. + * + * @name Phaser.BlendModes.HUE + */ + HUE: 13, + + /** + * Saturation blend mode. + * + * @name Phaser.BlendModes.SATURATION + */ + SATURATION: 14, + + /** + * Color blend mode. + * + * @name Phaser.BlendModes.COLOR + */ + COLOR: 15, + + /** + * Luminosity blend mode. + * + * @name Phaser.BlendModes.LUMINOSITY + */ + LUMINOSITY: 16 + +}; + + +/***/ }), + +/***/ "../../../src/utils/Class.js": +/*!**************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/utils/Class.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Taken from klasse by mattdesl https://github.com/mattdesl/klasse + +function hasGetterOrSetter (def) +{ + return (!!def.get && typeof def.get === 'function') || (!!def.set && typeof def.set === 'function'); +} + +function getProperty (definition, k, isClassDescriptor) +{ + // This may be a lightweight object, OR it might be a property that was defined previously. + + // For simple class descriptors we can just assume its NOT previously defined. + var def = (isClassDescriptor) ? definition[k] : Object.getOwnPropertyDescriptor(definition, k); + + if (!isClassDescriptor && def.value && typeof def.value === 'object') + { + def = def.value; + } + + // This might be a regular property, or it may be a getter/setter the user defined in a class. + if (def && hasGetterOrSetter(def)) + { + if (typeof def.enumerable === 'undefined') + { + def.enumerable = true; + } + + if (typeof def.configurable === 'undefined') + { + def.configurable = true; + } + + return def; + } + else + { + return false; + } +} + +function hasNonConfigurable (obj, k) +{ + var prop = Object.getOwnPropertyDescriptor(obj, k); + + if (!prop) + { + return false; + } + + if (prop.value && typeof prop.value === 'object') + { + prop = prop.value; + } + + if (prop.configurable === false) + { + return true; + } + + return false; +} + +function extend (ctor, definition, isClassDescriptor, extend) +{ + for (var k in definition) + { + if (!definition.hasOwnProperty(k)) + { + continue; + } + + var def = getProperty(definition, k, isClassDescriptor); + + if (def !== false) + { + // If Extends is used, we will check its prototype to see if the final variable exists. + + var parent = extend || ctor; + + if (hasNonConfigurable(parent.prototype, k)) + { + // Just skip the final property + if (Class.ignoreFinals) + { + continue; + } + + // We cannot re-define a property that is configurable=false. + // So we will consider them final and throw an error. This is by + // default so it is clear to the developer what is happening. + // You can set ignoreFinals to true if you need to extend a class + // which has configurable=false; it will simply not re-define final properties. + throw new Error('cannot override final property \'' + k + '\', set Class.ignoreFinals = true to skip'); + } + + Object.defineProperty(ctor.prototype, k, def); + } + else + { + ctor.prototype[k] = definition[k]; + } + } +} + +function mixin (myClass, mixins) +{ + if (!mixins) + { + return; + } + + if (!Array.isArray(mixins)) + { + mixins = [ mixins ]; + } + + for (var i = 0; i < mixins.length; i++) + { + extend(myClass, mixins[i].prototype || mixins[i]); + } +} + +/** + * Creates a new class with the given descriptor. + * The constructor, defined by the name `initialize`, + * is an optional function. If unspecified, an anonymous + * function will be used which calls the parent class (if + * one exists). + * + * You can also use `Extends` and `Mixins` to provide subclassing + * and inheritance. + * + * @class Class + * @constructor + * @param {Object} definition a dictionary of functions for the class + * @example + * + * var MyClass = new Phaser.Class({ + * + * initialize: function() { + * this.foo = 2.0; + * }, + * + * bar: function() { + * return this.foo + 5; + * } + * }); + */ +function Class (definition) +{ + if (!definition) + { + definition = {}; + } + + // The variable name here dictates what we see in Chrome debugger + var initialize; + var Extends; + + if (definition.initialize) + { + if (typeof definition.initialize !== 'function') + { + throw new Error('initialize must be a function'); + } + + initialize = definition.initialize; + + // Usually we should avoid 'delete' in V8 at all costs. + // However, its unlikely to make any performance difference + // here since we only call this on class creation (i.e. not object creation). + delete definition.initialize; + } + else if (definition.Extends) + { + var base = definition.Extends; + + initialize = function () + { + base.apply(this, arguments); + }; + } + else + { + initialize = function () {}; + } + + if (definition.Extends) + { + initialize.prototype = Object.create(definition.Extends.prototype); + initialize.prototype.constructor = initialize; + + // For getOwnPropertyDescriptor to work, we need to act directly on the Extends (or Mixin) + + Extends = definition.Extends; + + delete definition.Extends; + } + else + { + initialize.prototype.constructor = initialize; + } + + // Grab the mixins, if they are specified... + var mixins = null; + + if (definition.Mixins) + { + mixins = definition.Mixins; + delete definition.Mixins; + } + + // First, mixin if we can. + mixin(initialize, mixins); + + // Now we grab the actual definition which defines the overrides. + extend(initialize, definition, true, Extends); + + return initialize; +} + +Class.extend = extend; +Class.mixin = mixin; +Class.ignoreFinals = false; + +module.exports = Class; + + +/***/ }), + +/***/ "../../../src/utils/NOOP.js": +/*!*************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/utils/NOOP.js ***! + \*************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * A NOOP (No Operation) callback function. + * + * Used internally by Phaser when it's more expensive to determine if a callback exists + * than it is to just invoke an empty function. + * + * @function Phaser.Utils.NOOP + * @since 3.0.0 + */ +var NOOP = function () +{ + // NOOP +}; + +module.exports = NOOP; + + +/***/ }), + +/***/ "../../../src/utils/object/Extend.js": +/*!**********************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/utils/object/Extend.js ***! + \**********************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsPlainObject = __webpack_require__(/*! ./IsPlainObject */ "../../../src/utils/object/IsPlainObject.js"); + +// @param {boolean} deep - Perform a deep copy? +// @param {object} target - The target object to copy to. +// @return {object} The extended object. + +/** + * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * + * @function Phaser.Utils.Objects.Extend + * @since 3.0.0 + * + * @return {object} The extended object. + */ +var Extend = function () +{ + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if (typeof target === 'boolean') + { + deep = target; + target = arguments[1] || {}; + + // skip the boolean and the target + i = 2; + } + + // extend Phaser if only one argument is passed + if (length === i) + { + target = this; + --i; + } + + for (; i < length; i++) + { + // Only deal with non-null/undefined values + if ((options = arguments[i]) != null) + { + // Extend the base object + for (name in options) + { + src = target[name]; + copy = options[name]; + + // Prevent never-ending loop + if (target === copy) + { + continue; + } + + // Recurse if we're merging plain objects or arrays + if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) + { + if (copyIsArray) + { + copyIsArray = false; + clone = src && Array.isArray(src) ? src : []; + } + else + { + clone = src && IsPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[name] = Extend(deep, clone, copy); + + // Don't bring in undefined values + } + else if (copy !== undefined) + { + target[name] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +module.exports = Extend; + + +/***/ }), + +/***/ "../../../src/utils/object/GetFastValue.js": +/*!****************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/utils/object/GetFastValue.js ***! + \****************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Finds the key within the top level of the {@link source} object, or returns {@link defaultValue} + * + * @function Phaser.Utils.Objects.GetFastValue + * @since 3.0.0 + * + * @param {object} source - The object to search + * @param {string} key - The key for the property on source. Must exist at the top level of the source object (no periods) + * @param {*} [defaultValue] - The default value to use if the key does not exist. + * + * @return {*} The value if found; otherwise, defaultValue (null if none provided) + */ +var GetFastValue = function (source, key, defaultValue) +{ + var t = typeof(source); + + if (!source || t === 'number' || t === 'string') + { + return defaultValue; + } + else if (source.hasOwnProperty(key) && source[key] !== undefined) + { + return source[key]; + } + else + { + return defaultValue; + } +}; + +module.exports = GetFastValue; + + +/***/ }), + +/***/ "../../../src/utils/object/GetValue.js": +/*!************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/utils/object/GetValue.js ***! + \************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// Source object +// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner' +// The default value to use if the key doesn't exist + +/** + * Retrieves a value from an object. + * + * @function Phaser.Utils.Objects.GetValue + * @since 3.0.0 + * + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param {*} defaultValue - The value to return if the `key` isn't found in the `source` object. + * + * @return {*} The value of the requested key. + */ +var GetValue = function (source, key, defaultValue) +{ + if (!source || typeof source === 'number') + { + return defaultValue; + } + else if (source.hasOwnProperty(key)) + { + return source[key]; + } + else if (key.indexOf('.')) + { + var keys = key.split('.'); + var parent = source; + var value = defaultValue; + + // Use for loop here so we can break early + for (var i = 0; i < keys.length; i++) + { + if (parent.hasOwnProperty(keys[i])) + { + // Yes it has a key property, let's carry on down + value = parent[keys[i]]; + + parent = parent[keys[i]]; + } + else + { + // Can't go any further, so reset to default + value = defaultValue; + break; + } + } + + return value; + } + else + { + return defaultValue; + } +}; + +module.exports = GetValue; + + +/***/ }), + +/***/ "../../../src/utils/object/IsPlainObject.js": +/*!*****************************************************************************!*\ + !*** /Users/rich/Documents/GitHub/phaser/src/utils/object/IsPlainObject.js ***! + \*****************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * This is a slightly modified version of jQuery.isPlainObject. + * A plain object is an object whose internal class property is [object Object]. + * + * @function Phaser.Utils.Objects.IsPlainObject + * @since 3.0.0 + * + * @param {object} obj - The object to inspect. + * + * @return {boolean} `true` if the object is plain, otherwise `false`. + */ +var IsPlainObject = function (obj) +{ + // Not plain objects: + // - Any object or value whose internal [[Class]] property is not "[object Object]" + // - DOM nodes + // - window + if (typeof(obj) !== 'object' || obj.nodeType || obj === obj.window) + { + return false; + } + + // Support: Firefox <20 + // The try/catch suppresses exceptions thrown when attempting to access + // the "constructor" property of certain host objects, ie. |window.location| + // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 + try + { + if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) + { + return false; + } + } + catch (e) + { + return false; + } + + // If the function hasn't returned already, we're confident that + // |obj| is a plain object, created by {} or constructed with new Object + return true; +}; + +module.exports = IsPlainObject; + + +/***/ }), + +/***/ "./BaseSpinePlugin.js": +/*!****************************!*\ + !*** ./BaseSpinePlugin.js ***! + \****************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../../../src/utils/Class */ "../../../src/utils/Class.js"); +var ScenePlugin = __webpack_require__(/*! ../../../src/plugins/ScenePlugin */ "../../../src/plugins/ScenePlugin.js"); +var SpineFile = __webpack_require__(/*! ./SpineFile */ "./SpineFile.js"); +var SpineGameObject = __webpack_require__(/*! ./gameobject/SpineGameObject */ "./gameobject/SpineGameObject.js"); + +var runtime; + +/** + * @classdesc + * TODO + * + * @class SpinePlugin + * @extends Phaser.Plugins.ScenePlugin + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var SpinePlugin = new Class({ + + Extends: ScenePlugin, + + initialize: + + function SpinePlugin (scene, pluginManager, SpineRuntime) + { + console.log('BaseSpinePlugin created'); + + ScenePlugin.call(this, scene, pluginManager); + + var game = pluginManager.game; + + // Create a custom cache to store the spine data (.atlas files) + this.cache = game.cache.addCustom('spine'); + + this.json = game.cache.json; + + this.textures = game.textures; + + this.skeletonRenderer; + + this.drawDebug = false; + + // Register our file type + pluginManager.registerFileType('spine', this.spineFileCallback, scene); + + // Register our game object + pluginManager.registerGameObject('spine', this.createSpineFactory(this)); + + runtime = SpineRuntime; + }, + + spineFileCallback: function (key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings) + { + var multifile; + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new SpineFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new SpineFile(this, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; + }, + + /** + * Creates a new Spine Game Object and adds it to the Scene. + * + * @method Phaser.GameObjects.GameObjectFactory#spineFactory + * @since 3.16.0 + * + * @param {number} x - The horizontal position of this Game Object. + * @param {number} y - The vertical position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Spine} The Game Object that was created. + */ + createSpineFactory: function (plugin) + { + var callback = function (x, y, key, animationName, loop) + { + var spineGO = new SpineGameObject(this.scene, plugin, x, y, key, animationName, loop); + + this.displayList.add(spineGO); + this.updateList.add(spineGO); + + return spineGO; + }; + + return callback; + }, + + getRuntime: function () + { + return runtime; + }, + + createSkeleton: function (key, skeletonJSON) + { + var atlas = this.getAtlas(key); + + var atlasLoader = new runtime.AtlasAttachmentLoader(atlas); + + var skeletonJson = new runtime.SkeletonJson(atlasLoader); + + var data = (skeletonJSON) ? skeletonJSON : this.json.get(key); + + var skeletonData = skeletonJson.readSkeletonData(data); + + var skeleton = new runtime.Skeleton(skeletonData); + + return { skeletonData: skeletonData, skeleton: skeleton }; + }, + + getBounds: function (skeleton) + { + var offset = new runtime.Vector2(); + var size = new runtime.Vector2(); + + skeleton.getBounds(offset, size, []); + + return { offset: offset, size: size }; + }, + + createAnimationState: function (skeleton) + { + var stateData = new runtime.AnimationStateData(skeleton.data); + + var state = new runtime.AnimationState(stateData); + + return { stateData: stateData, state: state }; + }, + + /** + * 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 Camera3DPlugin#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(); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Camera3DPlugin#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.pluginManager = null; + this.game = null; + this.scene = null; + this.systems = null; + } + +}); + +module.exports = SpinePlugin; + + +/***/ }), + +/***/ "./SpineFile.js": +/*!**********************!*\ + !*** ./SpineFile.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../../../src/utils/Class */ "../../../src/utils/Class.js"); +var GetFastValue = __webpack_require__(/*! ../../../src/utils/object/GetFastValue */ "../../../src/utils/object/GetFastValue.js"); +var ImageFile = __webpack_require__(/*! ../../../src/loader/filetypes/ImageFile.js */ "../../../src/loader/filetypes/ImageFile.js"); +var IsPlainObject = __webpack_require__(/*! ../../../src/utils/object/IsPlainObject */ "../../../src/utils/object/IsPlainObject.js"); +var JSONFile = __webpack_require__(/*! ../../../src/loader/filetypes/JSONFile.js */ "../../../src/loader/filetypes/JSONFile.js"); +var MultiFile = __webpack_require__(/*! ../../../src/loader/MultiFile.js */ "../../../src/loader/MultiFile.js"); +var TextFile = __webpack_require__(/*! ../../../src/loader/filetypes/TextFile.js */ "../../../src/loader/filetypes/TextFile.js"); + +/** + * @typedef {object} Phaser.Loader.FileTypes.SpineFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [atlasURL] - The absolute or relative URL to load the atlas data file from. + * @property {string} [atlasExtension='txt'] - The default file extension to use for the atlas data if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas data file. + */ + +/** + * @classdesc + * A Spine File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#spine method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spine. + * + * @class SpineFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + */ +var SpineFile = new Class({ + + Extends: MultiFile, + + initialize: + + function SpineFile (loader, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings) + { + var json; + var atlas; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + json = new JSONFile(loader, { + key: key, + url: GetFastValue(config, 'jsonURL'), + extension: GetFastValue(config, 'jsonExtension', 'json'), + xhrSettings: GetFastValue(config, 'jsonXhrSettings') + }); + + atlas = new TextFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'atlas'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + json = new JSONFile(loader, key, jsonURL, jsonXhrSettings); + atlas = new TextFile(loader, key, atlasURL, atlasXhrSettings); + } + + atlas.cache = loader.cacheManager.custom.spine; + + MultiFile.call(this, loader, 'spine', key, [ json, atlas ]); + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.MultiFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + + if (file.type === 'text') + { + // Inspect the data for the files to now load + var content = file.data.split('\n'); + + // Extract the textures + var textures = []; + + for (var t = 0; t < content.length; t++) + { + var line = content[t]; + + if (line.trim() === '' && t < content.length - 1) + { + line = content[t + 1]; + + textures.push(line); + } + } + + var config = this.config; + var loader = this.loader; + + var currentBaseURL = loader.baseURL; + var currentPath = loader.path; + var currentPrefix = loader.prefix; + + var baseURL = GetFastValue(config, 'baseURL', currentBaseURL); + var path = GetFastValue(config, 'path', currentPath); + var prefix = GetFastValue(config, 'prefix', currentPrefix); + var textureXhrSettings = GetFastValue(config, 'textureXhrSettings'); + + loader.setBaseURL(baseURL); + loader.setPath(path); + loader.setPrefix(prefix); + + for (var i = 0; i < textures.length; i++) + { + var textureURL = textures[i]; + + var key = '_SP_' + textureURL; + + var image = new ImageFile(loader, key, textureURL, textureXhrSettings); + + this.addToMultiFile(image); + + loader.addFile(image); + } + + // Reset the loader settings + loader.setBaseURL(currentBaseURL); + loader.setPath(currentPath); + loader.setPrefix(currentPrefix); + } + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.SpineFile#addToCache + * @since 3.16.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var fileJSON = this.files[0]; + + fileJSON.addToCache(); + + var fileText = this.files[1]; + + fileText.addToCache(); + + for (var i = 2; i < this.files.length; i++) + { + var file = this.files[i]; + + var key = file.key.substr(4).trim(); + + this.loader.textureManager.addImage(key, file.data); + + file.pendingDestroy(); + } + + this.complete = true; + } + } + +}); + +/** + * Adds a Unity YAML based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SpineFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Unity Atlas File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#spine + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.16.0 + * + * @param {(string|Phaser.Loader.FileTypes.SpineFileConfig|Phaser.Loader.FileTypes.SpineFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. +FileTypesManager.register('spine', function (key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new SpineFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new SpineFile(this, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + */ + +module.exports = SpineFile; + + +/***/ }), + +/***/ "./SpineWebGLPlugin.js": +/*!*****************************!*\ + !*** ./SpineWebGLPlugin.js ***! + \*****************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../../../src/utils/Class */ "../../../src/utils/Class.js"); +var BaseSpinePlugin = __webpack_require__(/*! ./BaseSpinePlugin */ "./BaseSpinePlugin.js"); +var SpineWebGL = __webpack_require__(/*! SpineWebGL */ "./runtimes/spine-webgl.js"); +var Matrix4 = __webpack_require__(/*! ../../../src/math/Matrix4 */ "../../../src/math/Matrix4.js"); + +/** + * @classdesc + * Just the WebGL Runtime. + * + * @class SpinePlugin + * @extends Phaser.Plugins.ScenePlugin + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var SpineWebGLPlugin = new Class({ + + Extends: BaseSpinePlugin, + + initialize: + + function SpineWebGLPlugin (scene, pluginManager) + { + console.log('SpineWebGLPlugin created'); + + BaseSpinePlugin.call(this, scene, pluginManager, SpineWebGL); + + this.gl; + this.mvp; + this.shader; + this.batcher; + this.debugRenderer; + this.debugShader; + }, + + boot: function () + { + var gl = this.game.renderer.gl; + + this.gl = gl; + + this.mvp = new Matrix4(); + + // Create a simple shader, mesh, model-view-projection matrix and SkeletonRenderer. + this.shader = SpineWebGL.webgl.Shader.newTwoColoredTextured(gl); + this.batcher = new SpineWebGL.webgl.PolygonBatcher(gl); + + this.skeletonRenderer = new SpineWebGL.webgl.SkeletonRenderer(gl); + this.skeletonRenderer.premultipliedAlpha = true; + + this.shapes = new SpineWebGL.webgl.ShapeRenderer(gl); + + this.debugRenderer = new SpineWebGL.webgl.SkeletonDebugRenderer(gl); + + this.debugShader = SpineWebGL.webgl.Shader.newColored(gl); + }, + + getAtlas: function (key) + { + var atlasData = this.cache.get(key); + + if (!atlasData) + { + console.warn('No atlas data for: ' + key); + return; + } + + var textures = this.textures; + + var gl = this.game.renderer.gl; + + var atlas = new SpineWebGL.TextureAtlas(atlasData, function (path) + { + return new SpineWebGL.webgl.GLTexture(gl, textures.get(path).getSourceImage()); + }); + + return atlas; + } + +}); + +module.exports = SpineWebGLPlugin; + + +/***/ }), + +/***/ "./gameobject/SpineGameObject.js": +/*!***************************************!*\ + !*** ./gameobject/SpineGameObject.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = __webpack_require__(/*! ../../../../src/utils/Class */ "../../../src/utils/Class.js"); +var ComponentsAlpha = __webpack_require__(/*! ../../../../src/gameobjects/components/Alpha */ "../../../src/gameobjects/components/Alpha.js"); +var ComponentsBlendMode = __webpack_require__(/*! ../../../../src/gameobjects/components/BlendMode */ "../../../src/gameobjects/components/BlendMode.js"); +var ComponentsDepth = __webpack_require__(/*! ../../../../src/gameobjects/components/Depth */ "../../../src/gameobjects/components/Depth.js"); +var ComponentsFlip = __webpack_require__(/*! ../../../../src/gameobjects/components/Flip */ "../../../src/gameobjects/components/Flip.js"); +var ComponentsScrollFactor = __webpack_require__(/*! ../../../../src/gameobjects/components/ScrollFactor */ "../../../src/gameobjects/components/ScrollFactor.js"); +var ComponentsTransform = __webpack_require__(/*! ../../../../src/gameobjects/components/Transform */ "../../../src/gameobjects/components/Transform.js"); +var ComponentsVisible = __webpack_require__(/*! ../../../../src/gameobjects/components/Visible */ "../../../src/gameobjects/components/Visible.js"); +var GameObject = __webpack_require__(/*! ../../../../src/gameobjects/GameObject */ "../../../src/gameobjects/GameObject.js"); +var SpineGameObjectRender = __webpack_require__(/*! ./SpineGameObjectRender */ "./gameobject/SpineGameObjectRender.js"); + +/** + * @classdesc + * TODO + * + * @class SpineGameObject + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var SpineGameObject = new Class({ + + Extends: GameObject, + + Mixins: [ + ComponentsAlpha, + ComponentsBlendMode, + ComponentsDepth, + ComponentsFlip, + ComponentsScrollFactor, + ComponentsTransform, + ComponentsVisible, + SpineGameObjectRender + ], + + initialize: + + function SpineGameObject (scene, plugin, x, y, key, animationName, loop) + { + GameObject.call(this, scene, 'Spine'); + + this.plugin = plugin; + + this.runtime = plugin.getRuntime(); + + this.skeleton = null; + this.skeletonData = null; + + this.state = null; + this.stateData = null; + + this.drawDebug = false; + + this.timeScale = 1; + + this.setPosition(x, y); + + if (key) + { + this.setSkeleton(key, animationName, loop); + } + }, + + setSkeletonFromJSON: function (atlasDataKey, skeletonJSON, animationName, loop) + { + return this.setSkeleton(atlasDataKey, skeletonJSON, animationName, loop); + }, + + setSkeleton: function (atlasDataKey, animationName, loop, skeletonJSON) + { + var data = this.plugin.createSkeleton(atlasDataKey, skeletonJSON); + + this.skeletonData = data.skeletonData; + + var skeleton = data.skeleton; + + skeleton.flipY = (this.scene.sys.game.config.renderType === 1); + + skeleton.setToSetupPose(); + + skeleton.updateWorldTransform(); + + skeleton.setSkinByName('default'); + + this.skeleton = skeleton; + + // AnimationState + data = this.plugin.createAnimationState(skeleton); + + if (this.state) + { + this.state.clearListeners(); + this.state.clearListenerNotifications(); + } + + this.state = data.state; + + this.stateData = data.stateData; + + var _this = this; + + this.state.addListener({ + event: function (trackIndex, event) + { + // Event on a Track + _this.emit('spine.event', _this, trackIndex, event); + }, + complete: function (trackIndex, loopCount) + { + // Animation on Track x completed, loop count + _this.emit('spine.complete', _this, trackIndex, loopCount); + }, + start: function (trackIndex) + { + // Animation on Track x started + _this.emit('spine.start', _this, trackIndex); + }, + end: function (trackIndex) + { + // Animation on Track x ended + _this.emit('spine.end', _this, trackIndex); + } + }); + + if (animationName) + { + this.setAnimation(0, animationName, loop); + } + + return this; + }, + + // http://esotericsoftware.com/spine-runtimes-guide + + getAnimationList: function () + { + var output = []; + + var skeletonData = this.skeletonData; + + if (skeletonData) + { + for (var i = 0; i < skeletonData.animations.length; i++) + { + output.push(skeletonData.animations[i].name); + } + } + + return output; + }, + + play: function (animationName, loop) + { + if (loop === undefined) + { + loop = false; + } + + return this.setAnimation(0, animationName, loop); + }, + + setAnimation: function (trackIndex, animationName, loop) + { + this.state.setAnimation(trackIndex, animationName, loop); + + return this; + }, + + addAnimation: function (trackIndex, animationName, loop, delay) + { + return this.state.addAnimation(trackIndex, animationName, loop, delay); + }, + + setEmptyAnimation: function (trackIndex, mixDuration) + { + this.state.setEmptyAnimation(trackIndex, mixDuration); + + return this; + }, + + clearTrack: function (trackIndex) + { + this.state.clearTrack(trackIndex); + + return this; + }, + + clearTracks: function () + { + this.state.clearTracks(); + + return this; + }, + + setSkinByName: function (skinName) + { + this.skeleton.setSkinByName(skinName); + + return this; + }, + + setSkin: function (newSkin) + { + var skeleton = this.skeleton; + + skeleton.setSkin(newSkin); + + skeleton.setSlotsToSetupPose(); + + this.state.apply(skeleton); + + return this; + }, + + setMix: function (fromName, toName, duration) + { + this.stateData.setMix(fromName, toName, duration); + + return this; + }, + + findBone: function (boneName) + { + return this.skeleton.findBone(boneName); + }, + + findBoneIndex: function (boneName) + { + return this.skeleton.findBoneIndex(boneName); + }, + + findSlot: function (slotName) + { + return this.skeleton.findSlot(slotName); + }, + + findSlotIndex: function (slotName) + { + return this.skeleton.findSlotIndex(slotName); + }, + + getBounds: function () + { + return this.plugin.getBounds(this.skeleton); + }, + + preUpdate: function (time, delta) + { + var skeleton = this.skeleton; + + skeleton.flipX = this.flipX; + skeleton.flipY = this.flipY; + + this.state.update((delta / 1000) * this.timeScale); + + this.state.apply(skeleton); + + this.emit('spine.update', skeleton); + + skeleton.updateWorldTransform(); + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.RenderTexture#preDestroy + * @protected + * @since 3.16.0 + */ + preDestroy: function () + { + if (this.state) + { + this.state.clearListeners(); + this.state.clearListenerNotifications(); + } + + this.plugin = null; + this.runtime = null; + + this.skeleton = null; + this.skeletonData = null; + + this.state = null; + this.stateData = null; + } + +}); + +module.exports = SpineGameObject; + + +/***/ }), + +/***/ "./gameobject/SpineGameObjectRender.js": +/*!*********************************************!*\ + !*** ./gameobject/SpineGameObjectRender.js ***! + \*********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = __webpack_require__(/*! ../../../../src/utils/NOOP */ "../../../src/utils/NOOP.js"); +var renderCanvas = __webpack_require__(/*! ../../../../src/utils/NOOP */ "../../../src/utils/NOOP.js"); + +if (true) +{ + renderWebGL = __webpack_require__(/*! ./SpineGameObjectWebGLRenderer */ "./gameobject/SpineGameObjectWebGLRenderer.js"); +} + +if (false) +{} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; + + +/***/ }), + +/***/ "./gameobject/SpineGameObjectWebGLRenderer.js": +/*!****************************************************!*\ + !*** ./gameobject/SpineGameObjectWebGLRenderer.js ***! + \****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CounterClockwise = __webpack_require__(/*! ../../../../src/math/angle/CounterClockwise */ "../../../src/math/angle/CounterClockwise.js"); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.SpineGameObject#renderCanvas + * @since 3.16.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.SpineGameObject} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = renderer.currentPipeline; + var plugin = src.plugin; + var mvp = plugin.mvp; + + var shader = plugin.shader; + var batcher = plugin.batcher; + var runtime = src.runtime; + var skeleton = src.skeleton; + var skeletonRenderer = plugin.skeletonRenderer; + + if (!skeleton) + { + return; + } + + renderer.clearPipeline(); + + var camMatrix = renderer._tempMatrix1; + var spriteMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + // - 90 degrees to account for the difference in Spine vs. Phaser rotation + spriteMatrix.applyITRS(src.x, src.y, src.rotation - 1.5707963267948966, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var width = renderer.width; + var height = renderer.height; + + var data = calcMatrix.decomposeMatrix(); + + mvp.ortho(0, width, 0, height, 0, 1); + mvp.translateXYZ(data.translateX, height - data.translateY, 0); + mvp.rotateZ(CounterClockwise(data.rotation)); + mvp.scaleXYZ(data.scaleX, data.scaleY, 1); + + // For a Stage 1 release we'll handle it like this: + shader.bind(); + shader.setUniformi(runtime.webgl.Shader.SAMPLER, 0); + shader.setUniform4x4f(runtime.webgl.Shader.MVP_MATRIX, mvp.val); + + // For Stage 2, we'll move to using a custom pipeline, so Spine objects are batched + + batcher.begin(shader); + + skeletonRenderer.premultipliedAlpha = true; + + skeletonRenderer.draw(batcher, skeleton); + + batcher.end(); + + shader.unbind(); + + if (plugin.drawDebug || src.drawDebug) + { + var debugShader = plugin.debugShader; + var debugRenderer = plugin.debugRenderer; + var shapes = plugin.shapes; + + debugShader.bind(); + debugShader.setUniform4x4f(runtime.webgl.Shader.MVP_MATRIX, mvp.val); + + shapes.begin(debugShader); + + debugRenderer.draw(shapes, skeleton); + + shapes.end(); + + debugShader.unbind(); + } + + renderer.rebindPipeline(pipeline); +}; + +module.exports = SpineGameObjectWebGLRenderer; + + +/***/ }), + +/***/ "./runtimes/spine-webgl.js": +/*!*********************************!*\ + !*** ./runtimes/spine-webgl.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +/*** IMPORTS FROM imports-loader ***/ +(function() { + +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var spine; +(function (spine) { + var Animation = (function () { + function Animation(name, timelines, duration) { + if (name == null) + throw new Error("name cannot be null."); + if (timelines == null) + throw new Error("timelines cannot be null."); + this.name = name; + this.timelines = timelines; + this.duration = duration; + } + Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) { + if (skeleton == null) + throw new Error("skeleton cannot be null."); + if (loop && this.duration != 0) { + time %= this.duration; + if (lastTime > 0) + lastTime %= this.duration; + } + var timelines = this.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction); + }; + Animation.binarySearch = function (values, target, step) { + if (step === void 0) { step = 1; } + var low = 0; + var high = values.length / step - 2; + if (high == 0) + return step; + var current = high >>> 1; + while (true) { + if (values[(current + 1) * step] <= target) + low = current + 1; + else + high = current; + if (low == high) + return (low + 1) * step; + current = (low + high) >>> 1; + } + }; + Animation.linearSearch = function (values, target, step) { + for (var i = 0, last = values.length - step; i <= last; i += step) + if (values[i] > target) + return i; + return -1; + }; + return Animation; + }()); + spine.Animation = Animation; + var MixPose; + (function (MixPose) { + MixPose[MixPose["setup"] = 0] = "setup"; + MixPose[MixPose["current"] = 1] = "current"; + MixPose[MixPose["currentLayered"] = 2] = "currentLayered"; + })(MixPose = spine.MixPose || (spine.MixPose = {})); + var MixDirection; + (function (MixDirection) { + MixDirection[MixDirection["in"] = 0] = "in"; + MixDirection[MixDirection["out"] = 1] = "out"; + })(MixDirection = spine.MixDirection || (spine.MixDirection = {})); + var TimelineType; + (function (TimelineType) { + TimelineType[TimelineType["rotate"] = 0] = "rotate"; + TimelineType[TimelineType["translate"] = 1] = "translate"; + TimelineType[TimelineType["scale"] = 2] = "scale"; + TimelineType[TimelineType["shear"] = 3] = "shear"; + TimelineType[TimelineType["attachment"] = 4] = "attachment"; + TimelineType[TimelineType["color"] = 5] = "color"; + TimelineType[TimelineType["deform"] = 6] = "deform"; + TimelineType[TimelineType["event"] = 7] = "event"; + TimelineType[TimelineType["drawOrder"] = 8] = "drawOrder"; + TimelineType[TimelineType["ikConstraint"] = 9] = "ikConstraint"; + TimelineType[TimelineType["transformConstraint"] = 10] = "transformConstraint"; + TimelineType[TimelineType["pathConstraintPosition"] = 11] = "pathConstraintPosition"; + TimelineType[TimelineType["pathConstraintSpacing"] = 12] = "pathConstraintSpacing"; + TimelineType[TimelineType["pathConstraintMix"] = 13] = "pathConstraintMix"; + TimelineType[TimelineType["twoColor"] = 14] = "twoColor"; + })(TimelineType = spine.TimelineType || (spine.TimelineType = {})); + var CurveTimeline = (function () { + function CurveTimeline(frameCount) { + if (frameCount <= 0) + throw new Error("frameCount must be > 0: " + frameCount); + this.curves = spine.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE); + } + CurveTimeline.prototype.getFrameCount = function () { + return this.curves.length / CurveTimeline.BEZIER_SIZE + 1; + }; + CurveTimeline.prototype.setLinear = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR; + }; + CurveTimeline.prototype.setStepped = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED; + }; + CurveTimeline.prototype.getCurveType = function (frameIndex) { + var index = frameIndex * CurveTimeline.BEZIER_SIZE; + if (index == this.curves.length) + return CurveTimeline.LINEAR; + var type = this.curves[index]; + if (type == CurveTimeline.LINEAR) + return CurveTimeline.LINEAR; + if (type == CurveTimeline.STEPPED) + return CurveTimeline.STEPPED; + return CurveTimeline.BEZIER; + }; + CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) { + var tmpx = (-cx1 * 2 + cx2) * 0.03, tmpy = (-cy1 * 2 + cy2) * 0.03; + var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006; + var ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy; + var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var curves = this.curves; + curves[i++] = CurveTimeline.BEZIER; + var x = dfx, y = dfy; + for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + curves[i] = x; + curves[i + 1] = y; + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + x += dfx; + y += dfy; + } + }; + CurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) { + percent = spine.MathUtils.clamp(percent, 0, 1); + var curves = this.curves; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var type = curves[i]; + if (type == CurveTimeline.LINEAR) + return percent; + if (type == CurveTimeline.STEPPED) + return 0; + i++; + var x = 0; + for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + x = curves[i]; + if (x >= percent) { + var prevX = void 0, prevY = void 0; + if (i == start) { + prevX = 0; + prevY = 0; + } + else { + prevX = curves[i - 2]; + prevY = curves[i - 1]; + } + return prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX); + } + } + var y = curves[i - 1]; + return y + (1 - y) * (percent - x) / (1 - x); + }; + CurveTimeline.LINEAR = 0; + CurveTimeline.STEPPED = 1; + CurveTimeline.BEZIER = 2; + CurveTimeline.BEZIER_SIZE = 10 * 2 - 1; + return CurveTimeline; + }()); + spine.CurveTimeline = CurveTimeline; + var RotateTimeline = (function (_super) { + __extends(RotateTimeline, _super); + function RotateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount << 1); + return _this; + } + RotateTimeline.prototype.getPropertyId = function () { + return (TimelineType.rotate << 24) + this.boneIndex; + }; + RotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) { + frameIndex <<= 1; + this.frames[frameIndex] = time; + this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; + }; + RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.rotation = bone.data.rotation; + return; + case MixPose.current: + var r_1 = bone.data.rotation - bone.rotation; + r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360; + bone.rotation += r_1 * alpha; + } + return; + } + if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { + if (pose == MixPose.setup) + bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha; + else { + var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation; + r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; + bone.rotation += r_2 * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES); + var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); + var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + r = prevRotation + r * percent; + if (pose == MixPose.setup) { + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.rotation = bone.data.rotation + r * alpha; + } + else { + r = bone.data.rotation + r - bone.rotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.rotation += r * alpha; + } + }; + RotateTimeline.ENTRIES = 2; + RotateTimeline.PREV_TIME = -2; + RotateTimeline.PREV_ROTATION = -1; + RotateTimeline.ROTATION = 1; + return RotateTimeline; + }(CurveTimeline)); + spine.RotateTimeline = RotateTimeline; + var TranslateTimeline = (function (_super) { + __extends(TranslateTimeline, _super); + function TranslateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES); + return _this; + } + TranslateTimeline.prototype.getPropertyId = function () { + return (TimelineType.translate << 24) + this.boneIndex; + }; + TranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) { + frameIndex *= TranslateTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TranslateTimeline.X] = x; + this.frames[frameIndex + TranslateTimeline.Y] = y; + }; + TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.x = bone.data.x; + bone.y = bone.data.y; + return; + case MixPose.current: + bone.x += (bone.data.x - bone.x) * alpha; + bone.y += (bone.data.y - bone.y) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { + x = frames[frames.length + TranslateTimeline.PREV_X]; + y = frames[frames.length + TranslateTimeline.PREV_Y]; + } + else { + var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES); + x = frames[frame + TranslateTimeline.PREV_X]; + y = frames[frame + TranslateTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime)); + x += (frames[frame + TranslateTimeline.X] - x) * percent; + y += (frames[frame + TranslateTimeline.Y] - y) * percent; + } + if (pose == MixPose.setup) { + bone.x = bone.data.x + x * alpha; + bone.y = bone.data.y + y * alpha; + } + else { + bone.x += (bone.data.x + x - bone.x) * alpha; + bone.y += (bone.data.y + y - bone.y) * alpha; + } + }; + TranslateTimeline.ENTRIES = 3; + TranslateTimeline.PREV_TIME = -3; + TranslateTimeline.PREV_X = -2; + TranslateTimeline.PREV_Y = -1; + TranslateTimeline.X = 1; + TranslateTimeline.Y = 2; + return TranslateTimeline; + }(CurveTimeline)); + spine.TranslateTimeline = TranslateTimeline; + var ScaleTimeline = (function (_super) { + __extends(ScaleTimeline, _super); + function ScaleTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ScaleTimeline.prototype.getPropertyId = function () { + return (TimelineType.scale << 24) + this.boneIndex; + }; + ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.scaleX = bone.data.scaleX; + bone.scaleY = bone.data.scaleY; + return; + case MixPose.current: + bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { + x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX; + y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY; + } + else { + var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES); + x = frames[frame + ScaleTimeline.PREV_X]; + y = frames[frame + ScaleTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime)); + x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX; + y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; + } + if (alpha == 1) { + bone.scaleX = x; + bone.scaleY = y; + } + else { + var bx = 0, by = 0; + if (pose == MixPose.setup) { + bx = bone.data.scaleX; + by = bone.data.scaleY; + } + else { + bx = bone.scaleX; + by = bone.scaleY; + } + if (direction == MixDirection.out) { + x = Math.abs(x) * spine.MathUtils.signum(bx); + y = Math.abs(y) * spine.MathUtils.signum(by); + } + else { + bx = Math.abs(bx) * spine.MathUtils.signum(x); + by = Math.abs(by) * spine.MathUtils.signum(y); + } + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + } + }; + return ScaleTimeline; + }(TranslateTimeline)); + spine.ScaleTimeline = ScaleTimeline; + var ShearTimeline = (function (_super) { + __extends(ShearTimeline, _super); + function ShearTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ShearTimeline.prototype.getPropertyId = function () { + return (TimelineType.shear << 24) + this.boneIndex; + }; + ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.shearX = bone.data.shearX; + bone.shearY = bone.data.shearY; + return; + case MixPose.current: + bone.shearX += (bone.data.shearX - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY - bone.shearY) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { + x = frames[frames.length + ShearTimeline.PREV_X]; + y = frames[frames.length + ShearTimeline.PREV_Y]; + } + else { + var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES); + x = frames[frame + ShearTimeline.PREV_X]; + y = frames[frame + ShearTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime)); + x = x + (frames[frame + ShearTimeline.X] - x) * percent; + y = y + (frames[frame + ShearTimeline.Y] - y) * percent; + } + if (pose == MixPose.setup) { + bone.shearX = bone.data.shearX + x * alpha; + bone.shearY = bone.data.shearY + y * alpha; + } + else { + bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; + } + }; + return ShearTimeline; + }(TranslateTimeline)); + spine.ShearTimeline = ShearTimeline; + var ColorTimeline = (function (_super) { + __extends(ColorTimeline, _super); + function ColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES); + return _this; + } + ColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.color << 24) + this.slotIndex; + }; + ColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) { + frameIndex *= ColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + ColorTimeline.R] = r; + this.frames[frameIndex + ColorTimeline.G] = g; + this.frames[frameIndex + ColorTimeline.B] = b; + this.frames[frameIndex + ColorTimeline.A] = a; + }; + ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + var frames = this.frames; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + slot.color.setFromColor(slot.data.color); + return; + case MixPose.current: + var color = slot.color, setup = slot.data.color; + color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); + } + return; + } + var r = 0, g = 0, b = 0, a = 0; + if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + ColorTimeline.PREV_R]; + g = frames[i + ColorTimeline.PREV_G]; + b = frames[i + ColorTimeline.PREV_B]; + a = frames[i + ColorTimeline.PREV_A]; + } + else { + var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES); + r = frames[frame + ColorTimeline.PREV_R]; + g = frames[frame + ColorTimeline.PREV_G]; + b = frames[frame + ColorTimeline.PREV_B]; + a = frames[frame + ColorTimeline.PREV_A]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime)); + r += (frames[frame + ColorTimeline.R] - r) * percent; + g += (frames[frame + ColorTimeline.G] - g) * percent; + b += (frames[frame + ColorTimeline.B] - b) * percent; + a += (frames[frame + ColorTimeline.A] - a) * percent; + } + if (alpha == 1) + slot.color.set(r, g, b, a); + else { + var color = slot.color; + if (pose == MixPose.setup) + color.setFromColor(slot.data.color); + color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); + } + }; + ColorTimeline.ENTRIES = 5; + ColorTimeline.PREV_TIME = -5; + ColorTimeline.PREV_R = -4; + ColorTimeline.PREV_G = -3; + ColorTimeline.PREV_B = -2; + ColorTimeline.PREV_A = -1; + ColorTimeline.R = 1; + ColorTimeline.G = 2; + ColorTimeline.B = 3; + ColorTimeline.A = 4; + return ColorTimeline; + }(CurveTimeline)); + spine.ColorTimeline = ColorTimeline; + var TwoColorTimeline = (function (_super) { + __extends(TwoColorTimeline, _super); + function TwoColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES); + return _this; + } + TwoColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.twoColor << 24) + this.slotIndex; + }; + TwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) { + frameIndex *= TwoColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TwoColorTimeline.R] = r; + this.frames[frameIndex + TwoColorTimeline.G] = g; + this.frames[frameIndex + TwoColorTimeline.B] = b; + this.frames[frameIndex + TwoColorTimeline.A] = a; + this.frames[frameIndex + TwoColorTimeline.R2] = r2; + this.frames[frameIndex + TwoColorTimeline.G2] = g2; + this.frames[frameIndex + TwoColorTimeline.B2] = b2; + }; + TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + var frames = this.frames; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + slot.color.setFromColor(slot.data.color); + slot.darkColor.setFromColor(slot.data.darkColor); + return; + case MixPose.current: + var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; + light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); + dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); + } + return; + } + var r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0; + if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + TwoColorTimeline.PREV_R]; + g = frames[i + TwoColorTimeline.PREV_G]; + b = frames[i + TwoColorTimeline.PREV_B]; + a = frames[i + TwoColorTimeline.PREV_A]; + r2 = frames[i + TwoColorTimeline.PREV_R2]; + g2 = frames[i + TwoColorTimeline.PREV_G2]; + b2 = frames[i + TwoColorTimeline.PREV_B2]; + } + else { + var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES); + r = frames[frame + TwoColorTimeline.PREV_R]; + g = frames[frame + TwoColorTimeline.PREV_G]; + b = frames[frame + TwoColorTimeline.PREV_B]; + a = frames[frame + TwoColorTimeline.PREV_A]; + r2 = frames[frame + TwoColorTimeline.PREV_R2]; + g2 = frames[frame + TwoColorTimeline.PREV_G2]; + b2 = frames[frame + TwoColorTimeline.PREV_B2]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime)); + r += (frames[frame + TwoColorTimeline.R] - r) * percent; + g += (frames[frame + TwoColorTimeline.G] - g) * percent; + b += (frames[frame + TwoColorTimeline.B] - b) * percent; + a += (frames[frame + TwoColorTimeline.A] - a) * percent; + r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent; + g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent; + b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent; + } + if (alpha == 1) { + slot.color.set(r, g, b, a); + slot.darkColor.set(r2, g2, b2, 1); + } + else { + var light = slot.color, dark = slot.darkColor; + if (pose == MixPose.setup) { + light.setFromColor(slot.data.color); + dark.setFromColor(slot.data.darkColor); + } + light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha); + dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0); + } + }; + TwoColorTimeline.ENTRIES = 8; + TwoColorTimeline.PREV_TIME = -8; + TwoColorTimeline.PREV_R = -7; + TwoColorTimeline.PREV_G = -6; + TwoColorTimeline.PREV_B = -5; + TwoColorTimeline.PREV_A = -4; + TwoColorTimeline.PREV_R2 = -3; + TwoColorTimeline.PREV_G2 = -2; + TwoColorTimeline.PREV_B2 = -1; + TwoColorTimeline.R = 1; + TwoColorTimeline.G = 2; + TwoColorTimeline.B = 3; + TwoColorTimeline.A = 4; + TwoColorTimeline.R2 = 5; + TwoColorTimeline.G2 = 6; + TwoColorTimeline.B2 = 7; + return TwoColorTimeline; + }(CurveTimeline)); + spine.TwoColorTimeline = TwoColorTimeline; + var AttachmentTimeline = (function () { + function AttachmentTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.attachmentNames = new Array(frameCount); + } + AttachmentTimeline.prototype.getPropertyId = function () { + return (TimelineType.attachment << 24) + this.slotIndex; + }; + AttachmentTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + AttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) { + this.frames[frameIndex] = time; + this.attachmentNames[frameIndex] = attachmentName; + }; + AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (direction == MixDirection.out && pose == MixPose.setup) { + var attachmentName_1 = slot.data.attachmentName; + slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1)); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (pose == MixPose.setup) { + var attachmentName_2 = slot.data.attachmentName; + slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); + } + return; + } + var frameIndex = 0; + if (time >= frames[frames.length - 1]) + frameIndex = frames.length - 1; + else + frameIndex = Animation.binarySearch(frames, time, 1) - 1; + var attachmentName = this.attachmentNames[frameIndex]; + skeleton.slots[this.slotIndex] + .setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName)); + }; + return AttachmentTimeline; + }()); + spine.AttachmentTimeline = AttachmentTimeline; + var zeros = null; + var DeformTimeline = (function (_super) { + __extends(DeformTimeline, _super); + function DeformTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount); + _this.frameVertices = new Array(frameCount); + if (zeros == null) + zeros = spine.Utils.newFloatArray(64); + return _this; + } + DeformTimeline.prototype.getPropertyId = function () { + return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex; + }; + DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) { + this.frames[frameIndex] = time; + this.frameVertices[frameIndex] = vertices; + }; + DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + var slotAttachment = slot.getAttachment(); + if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) + return; + var verticesArray = slot.attachmentVertices; + if (verticesArray.length == 0) + alpha = 1; + var frameVertices = this.frameVertices; + var vertexCount = frameVertices[0].length; + var frames = this.frames; + if (time < frames[0]) { + var vertexAttachment = slotAttachment; + switch (pose) { + case MixPose.setup: + verticesArray.length = 0; + return; + case MixPose.current: + if (alpha == 1) { + verticesArray.length = 0; + break; + } + var vertices_1 = spine.Utils.setArraySize(verticesArray, vertexCount); + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) + vertices_1[i] += (setupVertices[i] - vertices_1[i]) * alpha; + } + else { + alpha = 1 - alpha; + for (var i = 0; i < vertexCount; i++) + vertices_1[i] *= alpha; + } + } + return; + } + var vertices = spine.Utils.setArraySize(verticesArray, vertexCount); + if (time >= frames[frames.length - 1]) { + var lastVertices = frameVertices[frames.length - 1]; + if (alpha == 1) { + spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); + } + else if (pose == MixPose.setup) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices_1 = vertexAttachment.vertices; + for (var i_1 = 0; i_1 < vertexCount; i_1++) { + var setup = setupVertices_1[i_1]; + vertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha; + } + } + else { + for (var i_2 = 0; i_2 < vertexCount; i_2++) + vertices[i_2] = lastVertices[i_2] * alpha; + } + } + else { + for (var i_3 = 0; i_3 < vertexCount; i_3++) + vertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time); + var prevVertices = frameVertices[frame - 1]; + var nextVertices = frameVertices[frame]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); + if (alpha == 1) { + for (var i_4 = 0; i_4 < vertexCount; i_4++) { + var prev = prevVertices[i_4]; + vertices[i_4] = prev + (nextVertices[i_4] - prev) * percent; + } + } + else if (pose == MixPose.setup) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices_2 = vertexAttachment.vertices; + for (var i_5 = 0; i_5 < vertexCount; i_5++) { + var prev = prevVertices[i_5], setup = setupVertices_2[i_5]; + vertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha; + } + } + else { + for (var i_6 = 0; i_6 < vertexCount; i_6++) { + var prev = prevVertices[i_6]; + vertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha; + } + } + } + else { + for (var i_7 = 0; i_7 < vertexCount; i_7++) { + var prev = prevVertices[i_7]; + vertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha; + } + } + }; + return DeformTimeline; + }(CurveTimeline)); + spine.DeformTimeline = DeformTimeline; + var EventTimeline = (function () { + function EventTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.events = new Array(frameCount); + } + EventTimeline.prototype.getPropertyId = function () { + return TimelineType.event << 24; + }; + EventTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + EventTimeline.prototype.setFrame = function (frameIndex, event) { + this.frames[frameIndex] = event.time; + this.events[frameIndex] = event; + }; + EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + if (firedEvents == null) + return; + var frames = this.frames; + var frameCount = this.frames.length; + if (lastTime > time) { + this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction); + lastTime = -1; + } + else if (lastTime >= frames[frameCount - 1]) + return; + if (time < frames[0]) + return; + var frame = 0; + if (lastTime < frames[0]) + frame = 0; + else { + frame = Animation.binarySearch(frames, lastTime); + var frameTime = frames[frame]; + while (frame > 0) { + if (frames[frame - 1] != frameTime) + break; + frame--; + } + } + for (; frame < frameCount && time >= frames[frame]; frame++) + firedEvents.push(this.events[frame]); + }; + return EventTimeline; + }()); + spine.EventTimeline = EventTimeline; + var DrawOrderTimeline = (function () { + function DrawOrderTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.drawOrders = new Array(frameCount); + } + DrawOrderTimeline.prototype.getPropertyId = function () { + return TimelineType.drawOrder << 24; + }; + DrawOrderTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) { + this.frames[frameIndex] = time; + this.drawOrders[frameIndex] = drawOrder; + }; + DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var drawOrder = skeleton.drawOrder; + var slots = skeleton.slots; + if (direction == MixDirection.out && pose == MixPose.setup) { + spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (pose == MixPose.setup) + spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frame = 0; + if (time >= frames[frames.length - 1]) + frame = frames.length - 1; + else + frame = Animation.binarySearch(frames, time) - 1; + var drawOrderToSetupIndex = this.drawOrders[frame]; + if (drawOrderToSetupIndex == null) + spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length); + else { + for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++) + drawOrder[i] = slots[drawOrderToSetupIndex[i]]; + } + }; + return DrawOrderTimeline; + }()); + spine.DrawOrderTimeline = DrawOrderTimeline; + var IkConstraintTimeline = (function (_super) { + __extends(IkConstraintTimeline, _super); + function IkConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES); + return _this; + } + IkConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex; + }; + IkConstraintTimeline.prototype.setFrame = function (frameIndex, time, mix, bendDirection) { + frameIndex *= IkConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; + this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; + }; + IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.mix = constraint.data.mix; + constraint.bendDirection = constraint.data.bendDirection; + return; + case MixPose.current: + constraint.mix += (constraint.data.mix - constraint.mix) * alpha; + constraint.bendDirection = constraint.data.bendDirection; + } + return; + } + if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { + if (pose == MixPose.setup) { + constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha; + constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection + : frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + else { + constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha; + if (direction == MixDirection["in"]) + constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + return; + } + var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES); + var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); + if (pose == MixPose.setup) { + constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; + constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + else { + constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha; + if (direction == MixDirection["in"]) + constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + }; + IkConstraintTimeline.ENTRIES = 3; + IkConstraintTimeline.PREV_TIME = -3; + IkConstraintTimeline.PREV_MIX = -2; + IkConstraintTimeline.PREV_BEND_DIRECTION = -1; + IkConstraintTimeline.MIX = 1; + IkConstraintTimeline.BEND_DIRECTION = 2; + return IkConstraintTimeline; + }(CurveTimeline)); + spine.IkConstraintTimeline = IkConstraintTimeline; + var TransformConstraintTimeline = (function (_super) { + __extends(TransformConstraintTimeline, _super); + function TransformConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES); + return _this; + } + TransformConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex; + }; + TransformConstraintTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) { + frameIndex *= TransformConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix; + this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; + this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; + }; + TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; + if (time < frames[0]) { + var data = constraint.data; + switch (pose) { + case MixPose.setup: + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + return; + case MixPose.current: + constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; + constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; + constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha; + } + return; + } + var rotate = 0, translate = 0, scale = 0, shear = 0; + if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) { + var i = frames.length; + rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[i + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[i + TransformConstraintTimeline.PREV_SHEAR]; + } + else { + var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES); + rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[frame + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime)); + rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent; + scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; + shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; + } + if (pose == MixPose.setup) { + var data = constraint.data; + constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha; + constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha; + constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha; + constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha; + } + else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + constraint.scaleMix += (scale - constraint.scaleMix) * alpha; + constraint.shearMix += (shear - constraint.shearMix) * alpha; + } + }; + TransformConstraintTimeline.ENTRIES = 5; + TransformConstraintTimeline.PREV_TIME = -5; + TransformConstraintTimeline.PREV_ROTATE = -4; + TransformConstraintTimeline.PREV_TRANSLATE = -3; + TransformConstraintTimeline.PREV_SCALE = -2; + TransformConstraintTimeline.PREV_SHEAR = -1; + TransformConstraintTimeline.ROTATE = 1; + TransformConstraintTimeline.TRANSLATE = 2; + TransformConstraintTimeline.SCALE = 3; + TransformConstraintTimeline.SHEAR = 4; + return TransformConstraintTimeline; + }(CurveTimeline)); + spine.TransformConstraintTimeline = TransformConstraintTimeline; + var PathConstraintPositionTimeline = (function (_super) { + __extends(PathConstraintPositionTimeline, _super); + function PathConstraintPositionTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES); + return _this; + } + PathConstraintPositionTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex; + }; + PathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) { + frameIndex *= PathConstraintPositionTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; + }; + PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.position = constraint.data.position; + return; + case MixPose.current: + constraint.position += (constraint.data.position - constraint.position) * alpha; + } + return; + } + var position = 0; + if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES]) + position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES); + position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); + position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; + } + if (pose == MixPose.setup) + constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; + else + constraint.position += (position - constraint.position) * alpha; + }; + PathConstraintPositionTimeline.ENTRIES = 2; + PathConstraintPositionTimeline.PREV_TIME = -2; + PathConstraintPositionTimeline.PREV_VALUE = -1; + PathConstraintPositionTimeline.VALUE = 1; + return PathConstraintPositionTimeline; + }(CurveTimeline)); + spine.PathConstraintPositionTimeline = PathConstraintPositionTimeline; + var PathConstraintSpacingTimeline = (function (_super) { + __extends(PathConstraintSpacingTimeline, _super); + function PathConstraintSpacingTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + PathConstraintSpacingTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; + }; + PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.spacing = constraint.data.spacing; + return; + case MixPose.current: + constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; + } + return; + } + var spacing = 0; + if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES]) + spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES); + spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); + spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; + } + if (pose == MixPose.setup) + constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; + else + constraint.spacing += (spacing - constraint.spacing) * alpha; + }; + return PathConstraintSpacingTimeline; + }(PathConstraintPositionTimeline)); + spine.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline; + var PathConstraintMixTimeline = (function (_super) { + __extends(PathConstraintMixTimeline, _super); + function PathConstraintMixTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES); + return _this; + } + PathConstraintMixTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex; + }; + PathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) { + frameIndex *= PathConstraintMixTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; + }; + PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.rotateMix = constraint.data.rotateMix; + constraint.translateMix = constraint.data.translateMix; + return; + case MixPose.current: + constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; + } + return; + } + var rotate = 0, translate = 0; + if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { + rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE]; + } + else { + var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES); + rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime)); + rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; + } + if (pose == MixPose.setup) { + constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; + constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; + } + else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + } + }; + PathConstraintMixTimeline.ENTRIES = 3; + PathConstraintMixTimeline.PREV_TIME = -3; + PathConstraintMixTimeline.PREV_ROTATE = -2; + PathConstraintMixTimeline.PREV_TRANSLATE = -1; + PathConstraintMixTimeline.ROTATE = 1; + PathConstraintMixTimeline.TRANSLATE = 2; + return PathConstraintMixTimeline; + }(CurveTimeline)); + spine.PathConstraintMixTimeline = PathConstraintMixTimeline; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AnimationState = (function () { + function AnimationState(data) { + this.tracks = new Array(); + this.events = new Array(); + this.listeners = new Array(); + this.queue = new EventQueue(this); + this.propertyIDs = new spine.IntSet(); + this.mixingTo = new Array(); + this.animationsChanged = false; + this.timeScale = 1; + this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); }); + this.data = data; + } + AnimationState.prototype.update = function (delta) { + delta *= this.timeScale; + var tracks = this.tracks; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (current == null) + continue; + current.animationLast = current.nextAnimationLast; + current.trackLast = current.nextTrackLast; + var currentDelta = delta * current.timeScale; + if (current.delay > 0) { + current.delay -= currentDelta; + if (current.delay > 0) + continue; + currentDelta = -current.delay; + current.delay = 0; + } + var next = current.next; + if (next != null) { + var nextTime = current.trackLast - next.delay; + if (nextTime >= 0) { + next.delay = 0; + next.trackTime = nextTime + delta * next.timeScale; + current.trackTime += currentDelta; + this.setCurrent(i, next, true); + while (next.mixingFrom != null) { + next.mixTime += currentDelta; + next = next.mixingFrom; + } + continue; + } + } + else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) { + tracks[i] = null; + this.queue.end(current); + this.disposeNext(current); + continue; + } + if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) { + var from = current.mixingFrom; + current.mixingFrom = null; + while (from != null) { + this.queue.end(from); + from = from.mixingFrom; + } + } + current.trackTime += currentDelta; + } + this.queue.drain(); + }; + AnimationState.prototype.updateMixingFrom = function (to, delta) { + var from = to.mixingFrom; + if (from == null) + return true; + var finished = this.updateMixingFrom(from, delta); + from.animationLast = from.nextAnimationLast; + from.trackLast = from.nextTrackLast; + if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { + if (from.totalAlpha == 0 || to.mixDuration == 0) { + to.mixingFrom = from.mixingFrom; + to.interruptAlpha = from.interruptAlpha; + this.queue.end(from); + } + return finished; + } + from.trackTime += delta * from.timeScale; + to.mixTime += delta * to.timeScale; + return false; + }; + AnimationState.prototype.apply = function (skeleton) { + if (skeleton == null) + throw new Error("skeleton cannot be null."); + if (this.animationsChanged) + this._animationsChanged(); + var events = this.events; + var tracks = this.tracks; + var applied = false; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (current == null || current.delay > 0) + continue; + applied = true; + var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered; + var mix = current.alpha; + if (current.mixingFrom != null) + mix *= this.applyMixingFrom(current, skeleton, currentPose); + else if (current.trackTime >= current.trackEnd && current.next == null) + mix = 0; + var animationLast = current.animationLast, animationTime = current.getAnimationTime(); + var timelineCount = current.animation.timelines.length; + var timelines = current.animation.timelines; + if (mix == 1) { + for (var ii = 0; ii < timelineCount; ii++) + timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection["in"]); + } + else { + var timelineData = current.timelineData; + var firstFrame = current.timelinesRotation.length == 0; + if (firstFrame) + spine.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = current.timelinesRotation; + for (var ii = 0; ii < timelineCount; ii++) { + var timeline = timelines[ii]; + var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose; + if (timeline instanceof spine.RotateTimeline) { + this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); + } + else { + spine.Utils.webkit602BugfixHelper(mix, pose); + timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection["in"]); + } + } + } + this.queueEvents(current, animationTime); + events.length = 0; + current.nextAnimationLast = animationTime; + current.nextTrackLast = current.trackTime; + } + this.queue.drain(); + return applied; + }; + AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) { + var from = to.mixingFrom; + if (from.mixingFrom != null) + this.applyMixingFrom(from, skeleton, currentPose); + var mix = 0; + if (to.mixDuration == 0) { + mix = 1; + currentPose = spine.MixPose.setup; + } + else { + mix = to.mixTime / to.mixDuration; + if (mix > 1) + mix = 1; + } + var events = mix < from.eventThreshold ? this.events : null; + var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; + var animationLast = from.animationLast, animationTime = from.getAnimationTime(); + var timelineCount = from.animation.timelines.length; + var timelines = from.animation.timelines; + var timelineData = from.timelineData; + var timelineDipMix = from.timelineDipMix; + var firstFrame = from.timelinesRotation.length == 0; + if (firstFrame) + spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = from.timelinesRotation; + var pose; + var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0; + from.totalAlpha = 0; + for (var i = 0; i < timelineCount; i++) { + var timeline = timelines[i]; + switch (timelineData[i]) { + case AnimationState.SUBSEQUENT: + if (!attachments && timeline instanceof spine.AttachmentTimeline) + continue; + if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) + continue; + pose = currentPose; + alpha = alphaMix; + break; + case AnimationState.FIRST: + pose = spine.MixPose.setup; + alpha = alphaMix; + break; + case AnimationState.DIP: + pose = spine.MixPose.setup; + alpha = alphaDip; + break; + default: + pose = spine.MixPose.setup; + alpha = alphaDip; + var dipMix = timelineDipMix[i]; + alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration); + break; + } + from.totalAlpha += alpha; + if (timeline instanceof spine.RotateTimeline) + this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); + else { + spine.Utils.webkit602BugfixHelper(alpha, pose); + timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out); + } + } + if (to.mixDuration > 0) + this.queueEvents(from, animationTime); + this.events.length = 0; + from.nextAnimationLast = animationTime; + from.nextTrackLast = from.trackTime; + return mix; + }; + AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) { + if (firstFrame) + timelinesRotation[i] = 0; + if (alpha == 1) { + timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection["in"]); + return; + } + var rotateTimeline = timeline; + var frames = rotateTimeline.frames; + var bone = skeleton.bones[rotateTimeline.boneIndex]; + if (time < frames[0]) { + if (pose == spine.MixPose.setup) + bone.rotation = bone.data.rotation; + return; + } + var r2 = 0; + if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES]) + r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION]; + else { + var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES); + var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime)); + r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + r2 = prevRotation + r2 * percent + bone.data.rotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + } + var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation; + var total = 0, diff = r2 - r1; + if (diff == 0) { + total = timelinesRotation[i]; + } + else { + diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360; + var lastTotal = 0, lastDiff = 0; + if (firstFrame) { + lastTotal = 0; + lastDiff = diff; + } + else { + lastTotal = timelinesRotation[i]; + lastDiff = timelinesRotation[i + 1]; + } + var current = diff > 0, dir = lastTotal >= 0; + if (spine.MathUtils.signum(lastDiff) != spine.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) { + if (Math.abs(lastTotal) > 180) + lastTotal += 360 * spine.MathUtils.signum(lastTotal); + dir = current; + } + total = diff + lastTotal - lastTotal % 360; + if (dir != current) + total += 360 * spine.MathUtils.signum(lastTotal); + timelinesRotation[i] = total; + } + timelinesRotation[i + 1] = diff; + r1 += total * alpha; + bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360; + }; + AnimationState.prototype.queueEvents = function (entry, animationTime) { + var animationStart = entry.animationStart, animationEnd = entry.animationEnd; + var duration = animationEnd - animationStart; + var trackLastWrapped = entry.trackLast % duration; + var events = this.events; + var i = 0, n = events.length; + for (; i < n; i++) { + var event_1 = events[i]; + if (event_1.time < trackLastWrapped) + break; + if (event_1.time > animationEnd) + continue; + this.queue.event(entry, event_1); + } + var complete = false; + if (entry.loop) + complete = duration == 0 || trackLastWrapped > entry.trackTime % duration; + else + complete = animationTime >= animationEnd && entry.animationLast < animationEnd; + if (complete) + this.queue.complete(entry); + for (; i < n; i++) { + var event_2 = events[i]; + if (event_2.time < animationStart) + continue; + this.queue.event(entry, events[i]); + } + }; + AnimationState.prototype.clearTracks = function () { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) + this.clearTrack(i); + this.tracks.length = 0; + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.clearTrack = function (trackIndex) { + if (trackIndex >= this.tracks.length) + return; + var current = this.tracks[trackIndex]; + if (current == null) + return; + this.queue.end(current); + this.disposeNext(current); + var entry = current; + while (true) { + var from = entry.mixingFrom; + if (from == null) + break; + this.queue.end(from); + entry.mixingFrom = null; + entry = from; + } + this.tracks[current.trackIndex] = null; + this.queue.drain(); + }; + AnimationState.prototype.setCurrent = function (index, current, interrupt) { + var from = this.expandToIndex(index); + this.tracks[index] = current; + if (from != null) { + if (interrupt) + this.queue.interrupt(from); + current.mixingFrom = from; + current.mixTime = 0; + if (from.mixingFrom != null && from.mixDuration > 0) + current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration); + from.timelinesRotation.length = 0; + } + this.queue.start(current); + }; + AnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) + throw new Error("Animation not found: " + animationName); + return this.setAnimationWith(trackIndex, animation, loop); + }; + AnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) { + if (animation == null) + throw new Error("animation cannot be null."); + var interrupt = true; + var current = this.expandToIndex(trackIndex); + if (current != null) { + if (current.nextTrackLast == -1) { + this.tracks[trackIndex] = current.mixingFrom; + this.queue.interrupt(current); + this.queue.end(current); + this.disposeNext(current); + current = current.mixingFrom; + interrupt = false; + } + else + this.disposeNext(current); + } + var entry = this.trackEntry(trackIndex, animation, loop, current); + this.setCurrent(trackIndex, entry, interrupt); + this.queue.drain(); + return entry; + }; + AnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) + throw new Error("Animation not found: " + animationName); + return this.addAnimationWith(trackIndex, animation, loop, delay); + }; + AnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) { + if (animation == null) + throw new Error("animation cannot be null."); + var last = this.expandToIndex(trackIndex); + if (last != null) { + while (last.next != null) + last = last.next; + } + var entry = this.trackEntry(trackIndex, animation, loop, last); + if (last == null) { + this.setCurrent(trackIndex, entry, true); + this.queue.drain(); + } + else { + last.next = entry; + if (delay <= 0) { + var duration = last.animationEnd - last.animationStart; + if (duration != 0) { + if (last.loop) + delay += duration * (1 + ((last.trackTime / duration) | 0)); + else + delay += duration; + delay -= this.data.getMix(last.animation, animation); + } + else + delay = 0; + } + } + entry.delay = delay; + return entry; + }; + AnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) { + var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) { + if (delay <= 0) + delay -= mixDuration; + var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.setEmptyAnimations = function (mixDuration) { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) { + var current = this.tracks[i]; + if (current != null) + this.setEmptyAnimation(current.trackIndex, mixDuration); + } + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.expandToIndex = function (index) { + if (index < this.tracks.length) + return this.tracks[index]; + spine.Utils.ensureArrayCapacity(this.tracks, index - this.tracks.length + 1, null); + this.tracks.length = index + 1; + return null; + }; + AnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) { + var entry = this.trackEntryPool.obtain(); + entry.trackIndex = trackIndex; + entry.animation = animation; + entry.loop = loop; + entry.eventThreshold = 0; + entry.attachmentThreshold = 0; + entry.drawOrderThreshold = 0; + entry.animationStart = 0; + entry.animationEnd = animation.duration; + entry.animationLast = -1; + entry.nextAnimationLast = -1; + entry.delay = 0; + entry.trackTime = 0; + entry.trackLast = -1; + entry.nextTrackLast = -1; + entry.trackEnd = Number.MAX_VALUE; + entry.timeScale = 1; + entry.alpha = 1; + entry.interruptAlpha = 1; + entry.mixTime = 0; + entry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation); + return entry; + }; + AnimationState.prototype.disposeNext = function (entry) { + var next = entry.next; + while (next != null) { + this.queue.dispose(next); + next = next.next; + } + entry.next = null; + }; + AnimationState.prototype._animationsChanged = function () { + this.animationsChanged = false; + var propertyIDs = this.propertyIDs; + propertyIDs.clear(); + var mixingTo = this.mixingTo; + for (var i = 0, n = this.tracks.length; i < n; i++) { + var entry = this.tracks[i]; + if (entry != null) + entry.setTimelineData(null, mixingTo, propertyIDs); + } + }; + AnimationState.prototype.getCurrent = function (trackIndex) { + if (trackIndex >= this.tracks.length) + return null; + return this.tracks[trackIndex]; + }; + AnimationState.prototype.addListener = function (listener) { + if (listener == null) + throw new Error("listener cannot be null."); + this.listeners.push(listener); + }; + AnimationState.prototype.removeListener = function (listener) { + var index = this.listeners.indexOf(listener); + if (index >= 0) + this.listeners.splice(index, 1); + }; + AnimationState.prototype.clearListeners = function () { + this.listeners.length = 0; + }; + AnimationState.prototype.clearListenerNotifications = function () { + this.queue.clear(); + }; + AnimationState.emptyAnimation = new spine.Animation("", [], 0); + AnimationState.SUBSEQUENT = 0; + AnimationState.FIRST = 1; + AnimationState.DIP = 2; + AnimationState.DIP_MIX = 3; + return AnimationState; + }()); + spine.AnimationState = AnimationState; + var TrackEntry = (function () { + function TrackEntry() { + this.timelineData = new Array(); + this.timelineDipMix = new Array(); + this.timelinesRotation = new Array(); + } + TrackEntry.prototype.reset = function () { + this.next = null; + this.mixingFrom = null; + this.animation = null; + this.listener = null; + this.timelineData.length = 0; + this.timelineDipMix.length = 0; + this.timelinesRotation.length = 0; + }; + TrackEntry.prototype.setTimelineData = function (to, mixingToArray, propertyIDs) { + if (to != null) + mixingToArray.push(to); + var lastEntry = this.mixingFrom != null ? this.mixingFrom.setTimelineData(this, mixingToArray, propertyIDs) : this; + if (to != null) + mixingToArray.pop(); + var mixingTo = mixingToArray; + var mixingToLast = mixingToArray.length - 1; + var timelines = this.animation.timelines; + var timelinesCount = this.animation.timelines.length; + var timelineData = spine.Utils.setArraySize(this.timelineData, timelinesCount); + this.timelineDipMix.length = 0; + var timelineDipMix = spine.Utils.setArraySize(this.timelineDipMix, timelinesCount); + outer: for (var i = 0; i < timelinesCount; i++) { + var id = timelines[i].getPropertyId(); + if (!propertyIDs.add(id)) + timelineData[i] = AnimationState.SUBSEQUENT; + else if (to == null || !to.hasTimeline(id)) + timelineData[i] = AnimationState.FIRST; + else { + for (var ii = mixingToLast; ii >= 0; ii--) { + var entry = mixingTo[ii]; + if (!entry.hasTimeline(id)) { + if (entry.mixDuration > 0) { + timelineData[i] = AnimationState.DIP_MIX; + timelineDipMix[i] = entry; + continue outer; + } + } + } + timelineData[i] = AnimationState.DIP; + } + } + return lastEntry; + }; + TrackEntry.prototype.hasTimeline = function (id) { + var timelines = this.animation.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + if (timelines[i].getPropertyId() == id) + return true; + return false; + }; + TrackEntry.prototype.getAnimationTime = function () { + if (this.loop) { + var duration = this.animationEnd - this.animationStart; + if (duration == 0) + return this.animationStart; + return (this.trackTime % duration) + this.animationStart; + } + return Math.min(this.trackTime + this.animationStart, this.animationEnd); + }; + TrackEntry.prototype.setAnimationLast = function (animationLast) { + this.animationLast = animationLast; + this.nextAnimationLast = animationLast; + }; + TrackEntry.prototype.isComplete = function () { + return this.trackTime >= this.animationEnd - this.animationStart; + }; + TrackEntry.prototype.resetRotationDirections = function () { + this.timelinesRotation.length = 0; + }; + return TrackEntry; + }()); + spine.TrackEntry = TrackEntry; + var EventQueue = (function () { + function EventQueue(animState) { + this.objects = []; + this.drainDisabled = false; + this.animState = animState; + } + EventQueue.prototype.start = function (entry) { + this.objects.push(EventType.start); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.interrupt = function (entry) { + this.objects.push(EventType.interrupt); + this.objects.push(entry); + }; + EventQueue.prototype.end = function (entry) { + this.objects.push(EventType.end); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.dispose = function (entry) { + this.objects.push(EventType.dispose); + this.objects.push(entry); + }; + EventQueue.prototype.complete = function (entry) { + this.objects.push(EventType.complete); + this.objects.push(entry); + }; + EventQueue.prototype.event = function (entry, event) { + this.objects.push(EventType.event); + this.objects.push(entry); + this.objects.push(event); + }; + EventQueue.prototype.drain = function () { + if (this.drainDisabled) + return; + this.drainDisabled = true; + var objects = this.objects; + var listeners = this.animState.listeners; + for (var i = 0; i < objects.length; i += 2) { + var type = objects[i]; + var entry = objects[i + 1]; + switch (type) { + case EventType.start: + if (entry.listener != null && entry.listener.start) + entry.listener.start(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].start) + listeners[ii].start(entry); + break; + case EventType.interrupt: + if (entry.listener != null && entry.listener.interrupt) + entry.listener.interrupt(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].interrupt) + listeners[ii].interrupt(entry); + break; + case EventType.end: + if (entry.listener != null && entry.listener.end) + entry.listener.end(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].end) + listeners[ii].end(entry); + case EventType.dispose: + if (entry.listener != null && entry.listener.dispose) + entry.listener.dispose(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].dispose) + listeners[ii].dispose(entry); + this.animState.trackEntryPool.free(entry); + break; + case EventType.complete: + if (entry.listener != null && entry.listener.complete) + entry.listener.complete(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].complete) + listeners[ii].complete(entry); + break; + case EventType.event: + var event_3 = objects[i++ + 2]; + if (entry.listener != null && entry.listener.event) + entry.listener.event(entry, event_3); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].event) + listeners[ii].event(entry, event_3); + break; + } + } + this.clear(); + this.drainDisabled = false; + }; + EventQueue.prototype.clear = function () { + this.objects.length = 0; + }; + return EventQueue; + }()); + spine.EventQueue = EventQueue; + var EventType; + (function (EventType) { + EventType[EventType["start"] = 0] = "start"; + EventType[EventType["interrupt"] = 1] = "interrupt"; + EventType[EventType["end"] = 2] = "end"; + EventType[EventType["dispose"] = 3] = "dispose"; + EventType[EventType["complete"] = 4] = "complete"; + EventType[EventType["event"] = 5] = "event"; + })(EventType = spine.EventType || (spine.EventType = {})); + var AnimationStateAdapter2 = (function () { + function AnimationStateAdapter2() { + } + AnimationStateAdapter2.prototype.start = function (entry) { + }; + AnimationStateAdapter2.prototype.interrupt = function (entry) { + }; + AnimationStateAdapter2.prototype.end = function (entry) { + }; + AnimationStateAdapter2.prototype.dispose = function (entry) { + }; + AnimationStateAdapter2.prototype.complete = function (entry) { + }; + AnimationStateAdapter2.prototype.event = function (entry, event) { + }; + return AnimationStateAdapter2; + }()); + spine.AnimationStateAdapter2 = AnimationStateAdapter2; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AnimationStateData = (function () { + function AnimationStateData(skeletonData) { + this.animationToMixTime = {}; + this.defaultMix = 0; + if (skeletonData == null) + throw new Error("skeletonData cannot be null."); + this.skeletonData = skeletonData; + } + AnimationStateData.prototype.setMix = function (fromName, toName, duration) { + var from = this.skeletonData.findAnimation(fromName); + if (from == null) + throw new Error("Animation not found: " + fromName); + var to = this.skeletonData.findAnimation(toName); + if (to == null) + throw new Error("Animation not found: " + toName); + this.setMixWith(from, to, duration); + }; + AnimationStateData.prototype.setMixWith = function (from, to, duration) { + if (from == null) + throw new Error("from cannot be null."); + if (to == null) + throw new Error("to cannot be null."); + var key = from.name + "." + to.name; + this.animationToMixTime[key] = duration; + }; + AnimationStateData.prototype.getMix = function (from, to) { + var key = from.name + "." + to.name; + var value = this.animationToMixTime[key]; + return value === undefined ? this.defaultMix : value; + }; + return AnimationStateData; + }()); + spine.AnimationStateData = AnimationStateData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AssetManager = (function () { + function AssetManager(textureLoader, pathPrefix) { + if (pathPrefix === void 0) { pathPrefix = ""; } + this.assets = {}; + this.errors = {}; + this.toLoad = 0; + this.loaded = 0; + this.textureLoader = textureLoader; + this.pathPrefix = pathPrefix; + } + AssetManager.downloadText = function (url, success, error) { + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.onload = function () { + if (request.status == 200) { + success(request.responseText); + } + else { + error(request.status, request.responseText); + } + }; + request.onerror = function () { + error(request.status, request.responseText); + }; + request.send(); + }; + AssetManager.downloadBinary = function (url, success, error) { + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.responseType = "arraybuffer"; + request.onload = function () { + if (request.status == 200) { + success(new Uint8Array(request.response)); + } + else { + error(request.status, request.responseText); + } + }; + request.onerror = function () { + error(request.status, request.responseText); + }; + request.send(); + }; + AssetManager.prototype.loadText = function (path, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + path = this.pathPrefix + path; + this.toLoad++; + AssetManager.downloadText(path, function (data) { + _this.assets[path] = data; + if (success) + success(path, data); + _this.toLoad--; + _this.loaded++; + }, function (state, responseText) { + _this.errors[path] = "Couldn't load text " + path + ": status " + status + ", " + responseText; + if (error) + error(path, "Couldn't load text " + path + ": status " + status + ", " + responseText); + _this.toLoad--; + _this.loaded++; + }); + }; + AssetManager.prototype.loadTexture = function (path, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + path = this.pathPrefix + path; + this.toLoad++; + var img = new Image(); + img.crossOrigin = "anonymous"; + img.onload = function (ev) { + var texture = _this.textureLoader(img); + _this.assets[path] = texture; + _this.toLoad--; + _this.loaded++; + if (success) + success(path, img); + }; + img.onerror = function (ev) { + _this.errors[path] = "Couldn't load image " + path; + _this.toLoad--; + _this.loaded++; + if (error) + error(path, "Couldn't load image " + path); + }; + img.src = path; + }; + AssetManager.prototype.loadTextureData = function (path, data, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + path = this.pathPrefix + path; + this.toLoad++; + var img = new Image(); + img.onload = function (ev) { + var texture = _this.textureLoader(img); + _this.assets[path] = texture; + _this.toLoad--; + _this.loaded++; + if (success) + success(path, img); + }; + img.onerror = function (ev) { + _this.errors[path] = "Couldn't load image " + path; + _this.toLoad--; + _this.loaded++; + if (error) + error(path, "Couldn't load image " + path); + }; + img.src = data; + }; + AssetManager.prototype.loadTextureAtlas = function (path, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : ""; + path = this.pathPrefix + path; + this.toLoad++; + AssetManager.downloadText(path, function (atlasData) { + var pagesLoaded = { count: 0 }; + var atlasPages = new Array(); + try { + var atlas = new spine.TextureAtlas(atlasData, function (path) { + atlasPages.push(parent + "/" + path); + var image = document.createElement("img"); + image.width = 16; + image.height = 16; + return new spine.FakeTexture(image); + }); + } + catch (e) { + var ex = e; + _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message; + if (error) + error(path, "Couldn't load texture atlas " + path + ": " + ex.message); + _this.toLoad--; + _this.loaded++; + return; + } + var _loop_1 = function (atlasPage) { + var pageLoadError = false; + _this.loadTexture(atlasPage, function (imagePath, image) { + pagesLoaded.count++; + if (pagesLoaded.count == atlasPages.length) { + if (!pageLoadError) { + try { + var atlas = new spine.TextureAtlas(atlasData, function (path) { + return _this.get(parent + "/" + path); + }); + _this.assets[path] = atlas; + if (success) + success(path, atlas); + _this.toLoad--; + _this.loaded++; + } + catch (e) { + var ex = e; + _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message; + if (error) + error(path, "Couldn't load texture atlas " + path + ": " + ex.message); + _this.toLoad--; + _this.loaded++; + } + } + else { + _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path; + if (error) + error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path); + _this.toLoad--; + _this.loaded++; + } + } + }, function (imagePath, errorMessage) { + pageLoadError = true; + pagesLoaded.count++; + if (pagesLoaded.count == atlasPages.length) { + _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path; + if (error) + error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path); + _this.toLoad--; + _this.loaded++; + } + }); + }; + for (var _i = 0, atlasPages_1 = atlasPages; _i < atlasPages_1.length; _i++) { + var atlasPage = atlasPages_1[_i]; + _loop_1(atlasPage); + } + }, function (state, responseText) { + _this.errors[path] = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText; + if (error) + error(path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText); + _this.toLoad--; + _this.loaded++; + }); + }; + AssetManager.prototype.get = function (path) { + path = this.pathPrefix + path; + return this.assets[path]; + }; + AssetManager.prototype.remove = function (path) { + path = this.pathPrefix + path; + var asset = this.assets[path]; + if (asset.dispose) + asset.dispose(); + this.assets[path] = null; + }; + AssetManager.prototype.removeAll = function () { + for (var key in this.assets) { + var asset = this.assets[key]; + if (asset.dispose) + asset.dispose(); + } + this.assets = {}; + }; + AssetManager.prototype.isLoadingComplete = function () { + return this.toLoad == 0; + }; + AssetManager.prototype.getToLoad = function () { + return this.toLoad; + }; + AssetManager.prototype.getLoaded = function () { + return this.loaded; + }; + AssetManager.prototype.dispose = function () { + this.removeAll(); + }; + AssetManager.prototype.hasErrors = function () { + return Object.keys(this.errors).length > 0; + }; + AssetManager.prototype.getErrors = function () { + return this.errors; + }; + return AssetManager; + }()); + spine.AssetManager = AssetManager; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AtlasAttachmentLoader = (function () { + function AtlasAttachmentLoader(atlas) { + this.atlas = atlas; + } + AtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) + throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")"); + region.renderObject = region; + var attachment = new spine.RegionAttachment(name); + attachment.setRegion(region); + return attachment; + }; + AtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) + throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")"); + region.renderObject = region; + var attachment = new spine.MeshAttachment(name); + attachment.region = region; + return attachment; + }; + AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) { + return new spine.BoundingBoxAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) { + return new spine.PathAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) { + return new spine.PointAttachment(name); + }; + AtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) { + return new spine.ClippingAttachment(name); + }; + return AtlasAttachmentLoader; + }()); + spine.AtlasAttachmentLoader = AtlasAttachmentLoader; +})(spine || (spine = {})); +var spine; +(function (spine) { + var BlendMode; + (function (BlendMode) { + BlendMode[BlendMode["Normal"] = 0] = "Normal"; + BlendMode[BlendMode["Additive"] = 1] = "Additive"; + BlendMode[BlendMode["Multiply"] = 2] = "Multiply"; + BlendMode[BlendMode["Screen"] = 3] = "Screen"; + })(BlendMode = spine.BlendMode || (spine.BlendMode = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Bone = (function () { + function Bone(data, skeleton, parent) { + this.children = new Array(); + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 0; + this.scaleY = 0; + this.shearX = 0; + this.shearY = 0; + this.ax = 0; + this.ay = 0; + this.arotation = 0; + this.ascaleX = 0; + this.ascaleY = 0; + this.ashearX = 0; + this.ashearY = 0; + this.appliedValid = false; + this.a = 0; + this.b = 0; + this.worldX = 0; + this.c = 0; + this.d = 0; + this.worldY = 0; + this.sorted = false; + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.skeleton = skeleton; + this.parent = parent; + this.setToSetupPose(); + } + Bone.prototype.update = function () { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + Bone.prototype.updateWorldTransform = function () { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + Bone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) { + this.ax = x; + this.ay = y; + this.arotation = rotation; + this.ascaleX = scaleX; + this.ascaleY = scaleY; + this.ashearX = shearX; + this.ashearY = shearY; + this.appliedValid = true; + var parent = this.parent; + if (parent == null) { + var rotationY = rotation + 90 + shearY; + var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(rotationY) * scaleY; + var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(rotationY) * scaleY; + var skeleton = this.skeleton; + if (skeleton.flipX) { + x = -x; + la = -la; + lb = -lb; + } + if (skeleton.flipY) { + y = -y; + lc = -lc; + ld = -ld; + } + this.a = la; + this.b = lb; + this.c = lc; + this.d = ld; + this.worldX = x + skeleton.x; + this.worldY = y + skeleton.y; + return; + } + var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; + this.worldX = pa * x + pb * y + parent.worldX; + this.worldY = pc * x + pd * y + parent.worldY; + switch (this.data.transformMode) { + case spine.TransformMode.Normal: { + var rotationY = rotation + 90 + shearY; + var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(rotationY) * scaleY; + var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(rotationY) * scaleY; + this.a = pa * la + pb * lc; + this.b = pa * lb + pb * ld; + this.c = pc * la + pd * lc; + this.d = pc * lb + pd * ld; + return; + } + case spine.TransformMode.OnlyTranslation: { + var rotationY = rotation + 90 + shearY; + this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + this.b = spine.MathUtils.cosDeg(rotationY) * scaleY; + this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + this.d = spine.MathUtils.sinDeg(rotationY) * scaleY; + break; + } + case spine.TransformMode.NoRotationOrReflection: { + var s = pa * pa + pc * pc; + var prx = 0; + if (s > 0.0001) { + s = Math.abs(pa * pd - pb * pc) / s; + pb = pc * s; + pd = pa * s; + prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg; + } + else { + pa = 0; + pc = 0; + prx = 90 - Math.atan2(pd, pb) * spine.MathUtils.radDeg; + } + var rx = rotation + shearX - prx; + var ry = rotation + shearY - prx + 90; + var la = spine.MathUtils.cosDeg(rx) * scaleX; + var lb = spine.MathUtils.cosDeg(ry) * scaleY; + var lc = spine.MathUtils.sinDeg(rx) * scaleX; + var ld = spine.MathUtils.sinDeg(ry) * scaleY; + this.a = pa * la - pb * lc; + this.b = pa * lb - pb * ld; + this.c = pc * la + pd * lc; + this.d = pc * lb + pd * ld; + break; + } + case spine.TransformMode.NoScale: + case spine.TransformMode.NoScaleOrReflection: { + var cos = spine.MathUtils.cosDeg(rotation); + var sin = spine.MathUtils.sinDeg(rotation); + var za = pa * cos + pb * sin; + var zc = pc * cos + pd * sin; + var s = Math.sqrt(za * za + zc * zc); + if (s > 0.00001) + s = 1 / s; + za *= s; + zc *= s; + s = Math.sqrt(za * za + zc * zc); + var r = Math.PI / 2 + Math.atan2(zc, za); + var zb = Math.cos(r) * s; + var zd = Math.sin(r) * s; + var la = spine.MathUtils.cosDeg(shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(90 + shearY) * scaleY; + var lc = spine.MathUtils.sinDeg(shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(90 + shearY) * scaleY; + if (this.data.transformMode != spine.TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : this.skeleton.flipX != this.skeleton.flipY) { + zb = -zb; + zd = -zd; + } + this.a = za * la + zb * lc; + this.b = za * lb + zb * ld; + this.c = zc * la + zd * lc; + this.d = zc * lb + zd * ld; + return; + } + } + if (this.skeleton.flipX) { + this.a = -this.a; + this.b = -this.b; + } + if (this.skeleton.flipY) { + this.c = -this.c; + this.d = -this.d; + } + }; + Bone.prototype.setToSetupPose = function () { + var data = this.data; + this.x = data.x; + this.y = data.y; + this.rotation = data.rotation; + this.scaleX = data.scaleX; + this.scaleY = data.scaleY; + this.shearX = data.shearX; + this.shearY = data.shearY; + }; + Bone.prototype.getWorldRotationX = function () { + return Math.atan2(this.c, this.a) * spine.MathUtils.radDeg; + }; + Bone.prototype.getWorldRotationY = function () { + return Math.atan2(this.d, this.b) * spine.MathUtils.radDeg; + }; + Bone.prototype.getWorldScaleX = function () { + return Math.sqrt(this.a * this.a + this.c * this.c); + }; + Bone.prototype.getWorldScaleY = function () { + return Math.sqrt(this.b * this.b + this.d * this.d); + }; + Bone.prototype.updateAppliedTransform = function () { + this.appliedValid = true; + var parent = this.parent; + if (parent == null) { + this.ax = this.worldX; + this.ay = this.worldY; + this.arotation = Math.atan2(this.c, this.a) * spine.MathUtils.radDeg; + this.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c); + this.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d); + this.ashearX = 0; + this.ashearY = Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * spine.MathUtils.radDeg; + return; + } + var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; + var pid = 1 / (pa * pd - pb * pc); + var dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY; + this.ax = (dx * pd * pid - dy * pb * pid); + this.ay = (dy * pa * pid - dx * pc * pid); + var ia = pid * pd; + var id = pid * pa; + var ib = pid * pb; + var ic = pid * pc; + var ra = ia * this.a - ib * this.c; + var rb = ia * this.b - ib * this.d; + var rc = id * this.c - ic * this.a; + var rd = id * this.d - ic * this.b; + this.ashearX = 0; + this.ascaleX = Math.sqrt(ra * ra + rc * rc); + if (this.ascaleX > 0.0001) { + var det = ra * rd - rb * rc; + this.ascaleY = det / this.ascaleX; + this.ashearY = Math.atan2(ra * rb + rc * rd, det) * spine.MathUtils.radDeg; + this.arotation = Math.atan2(rc, ra) * spine.MathUtils.radDeg; + } + else { + this.ascaleX = 0; + this.ascaleY = Math.sqrt(rb * rb + rd * rd); + this.ashearY = 0; + this.arotation = 90 - Math.atan2(rd, rb) * spine.MathUtils.radDeg; + } + }; + Bone.prototype.worldToLocal = function (world) { + var a = this.a, b = this.b, c = this.c, d = this.d; + var invDet = 1 / (a * d - b * c); + var x = world.x - this.worldX, y = world.y - this.worldY; + world.x = (x * d * invDet - y * b * invDet); + world.y = (y * a * invDet - x * c * invDet); + return world; + }; + Bone.prototype.localToWorld = function (local) { + var x = local.x, y = local.y; + local.x = x * this.a + y * this.b + this.worldX; + local.y = x * this.c + y * this.d + this.worldY; + return local; + }; + Bone.prototype.worldToLocalRotation = function (worldRotation) { + var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation); + return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg; + }; + Bone.prototype.localToWorldRotation = function (localRotation) { + var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation); + return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg; + }; + Bone.prototype.rotateWorld = function (degrees) { + var a = this.a, b = this.b, c = this.c, d = this.d; + var cos = spine.MathUtils.cosDeg(degrees), sin = spine.MathUtils.sinDeg(degrees); + this.a = cos * a - sin * c; + this.b = cos * b - sin * d; + this.c = sin * a + cos * c; + this.d = sin * b + cos * d; + this.appliedValid = false; + }; + return Bone; + }()); + spine.Bone = Bone; +})(spine || (spine = {})); +var spine; +(function (spine) { + var BoneData = (function () { + function BoneData(index, name, parent) { + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 1; + this.scaleY = 1; + this.shearX = 0; + this.shearY = 0; + this.transformMode = TransformMode.Normal; + if (index < 0) + throw new Error("index must be >= 0."); + if (name == null) + throw new Error("name cannot be null."); + this.index = index; + this.name = name; + this.parent = parent; + } + return BoneData; + }()); + spine.BoneData = BoneData; + var TransformMode; + (function (TransformMode) { + TransformMode[TransformMode["Normal"] = 0] = "Normal"; + TransformMode[TransformMode["OnlyTranslation"] = 1] = "OnlyTranslation"; + TransformMode[TransformMode["NoRotationOrReflection"] = 2] = "NoRotationOrReflection"; + TransformMode[TransformMode["NoScale"] = 3] = "NoScale"; + TransformMode[TransformMode["NoScaleOrReflection"] = 4] = "NoScaleOrReflection"; + })(TransformMode = spine.TransformMode || (spine.TransformMode = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Event = (function () { + function Event(time, data) { + if (data == null) + throw new Error("data cannot be null."); + this.time = time; + this.data = data; + } + return Event; + }()); + spine.Event = Event; +})(spine || (spine = {})); +var spine; +(function (spine) { + var EventData = (function () { + function EventData(name) { + this.name = name; + } + return EventData; + }()); + spine.EventData = EventData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var IkConstraint = (function () { + function IkConstraint(data, skeleton) { + this.mix = 1; + this.bendDirection = 0; + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.mix = data.mix; + this.bendDirection = data.bendDirection; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + IkConstraint.prototype.getOrder = function () { + return this.data.order; + }; + IkConstraint.prototype.apply = function () { + this.update(); + }; + IkConstraint.prototype.update = function () { + var target = this.target; + var bones = this.bones; + switch (bones.length) { + case 1: + this.apply1(bones[0], target.worldX, target.worldY, this.mix); + break; + case 2: + this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.mix); + break; + } + }; + IkConstraint.prototype.apply1 = function (bone, targetX, targetY, alpha) { + if (!bone.appliedValid) + bone.updateAppliedTransform(); + var p = bone.parent; + var id = 1 / (p.a * p.d - p.b * p.c); + var x = targetX - p.worldX, y = targetY - p.worldY; + var tx = (x * p.d - y * p.b) * id - bone.ax, ty = (y * p.a - x * p.c) * id - bone.ay; + var rotationIK = Math.atan2(ty, tx) * spine.MathUtils.radDeg - bone.ashearX - bone.arotation; + if (bone.ascaleX < 0) + rotationIK += 180; + if (rotationIK > 180) + rotationIK -= 360; + else if (rotationIK < -180) + rotationIK += 360; + bone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, bone.ascaleX, bone.ascaleY, bone.ashearX, bone.ashearY); + }; + IkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, alpha) { + if (alpha == 0) { + child.updateWorldTransform(); + return; + } + if (!parent.appliedValid) + parent.updateAppliedTransform(); + if (!child.appliedValid) + child.updateAppliedTransform(); + var px = parent.ax, py = parent.ay, psx = parent.ascaleX, psy = parent.ascaleY, csx = child.ascaleX; + var os1 = 0, os2 = 0, s2 = 0; + if (psx < 0) { + psx = -psx; + os1 = 180; + s2 = -1; + } + else { + os1 = 0; + s2 = 1; + } + if (psy < 0) { + psy = -psy; + s2 = -s2; + } + if (csx < 0) { + csx = -csx; + os2 = 180; + } + else + os2 = 0; + var cx = child.ax, cy = 0, cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d; + var u = Math.abs(psx - psy) <= 0.0001; + if (!u) { + cy = 0; + cwx = a * cx + parent.worldX; + cwy = c * cx + parent.worldY; + } + else { + cy = child.ay; + cwx = a * cx + b * cy + parent.worldX; + cwy = c * cx + d * cy + parent.worldY; + } + var pp = parent.parent; + a = pp.a; + b = pp.b; + c = pp.c; + d = pp.d; + var id = 1 / (a * d - b * c), x = targetX - pp.worldX, y = targetY - pp.worldY; + var tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py; + x = cwx - pp.worldX; + y = cwy - pp.worldY; + var dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py; + var l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1 = 0, a2 = 0; + outer: if (u) { + l2 *= psx; + var cos = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2); + if (cos < -1) + cos = -1; + else if (cos > 1) + cos = 1; + a2 = Math.acos(cos) * bendDir; + a = l1 + l2 * cos; + b = l2 * Math.sin(a2); + a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b); + } + else { + a = psx * l2; + b = psy * l2; + var aa = a * a, bb = b * b, dd = tx * tx + ty * ty, ta = Math.atan2(ty, tx); + c = bb * l1 * l1 + aa * dd - aa * bb; + var c1 = -2 * bb * l1, c2 = bb - aa; + d = c1 * c1 - 4 * c2 * c; + if (d >= 0) { + var q = Math.sqrt(d); + if (c1 < 0) + q = -q; + q = -(c1 + q) / 2; + var r0 = q / c2, r1 = c / q; + var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1; + if (r * r <= dd) { + y = Math.sqrt(dd - r * r) * bendDir; + a1 = ta - Math.atan2(y, r); + a2 = Math.atan2(y / psy, (r - l1) / psx); + break outer; + } + } + var minAngle = spine.MathUtils.PI, minX = l1 - a, minDist = minX * minX, minY = 0; + var maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0; + c = -a * l1 / (aa - bb); + if (c >= -1 && c <= 1) { + c = Math.acos(c); + x = a * Math.cos(c) + l1; + y = b * Math.sin(c); + d = x * x + y * y; + if (d < minDist) { + minAngle = c; + minDist = d; + minX = x; + minY = y; + } + if (d > maxDist) { + maxAngle = c; + maxDist = d; + maxX = x; + maxY = y; + } + } + if (dd <= (minDist + maxDist) / 2) { + a1 = ta - Math.atan2(minY * bendDir, minX); + a2 = minAngle * bendDir; + } + else { + a1 = ta - Math.atan2(maxY * bendDir, maxX); + a2 = maxAngle * bendDir; + } + } + var os = Math.atan2(cy, cx) * s2; + var rotation = parent.arotation; + a1 = (a1 - os) * spine.MathUtils.radDeg + os1 - rotation; + if (a1 > 180) + a1 -= 360; + else if (a1 < -180) + a1 += 360; + parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, parent.ascaleX, parent.ascaleY, 0, 0); + rotation = child.arotation; + a2 = ((a2 + os) * spine.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation; + if (a2 > 180) + a2 -= 360; + else if (a2 < -180) + a2 += 360; + child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY); + }; + return IkConstraint; + }()); + spine.IkConstraint = IkConstraint; +})(spine || (spine = {})); +var spine; +(function (spine) { + var IkConstraintData = (function () { + function IkConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.bendDirection = 1; + this.mix = 1; + this.name = name; + } + return IkConstraintData; + }()); + spine.IkConstraintData = IkConstraintData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PathConstraint = (function () { + function PathConstraint(data, skeleton) { + this.position = 0; + this.spacing = 0; + this.rotateMix = 0; + this.translateMix = 0; + this.spaces = new Array(); + this.positions = new Array(); + this.world = new Array(); + this.curves = new Array(); + this.lengths = new Array(); + this.segments = new Array(); + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.bones = new Array(); + for (var i = 0, n = data.bones.length; i < n; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findSlot(data.target.name); + this.position = data.position; + this.spacing = data.spacing; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + } + PathConstraint.prototype.apply = function () { + this.update(); + }; + PathConstraint.prototype.update = function () { + var attachment = this.target.getAttachment(); + if (!(attachment instanceof spine.PathAttachment)) + return; + var rotateMix = this.rotateMix, translateMix = this.translateMix; + var translate = translateMix > 0, rotate = rotateMix > 0; + if (!translate && !rotate) + return; + var data = this.data; + var spacingMode = data.spacingMode; + var lengthSpacing = spacingMode == spine.SpacingMode.Length; + var rotateMode = data.rotateMode; + var tangents = rotateMode == spine.RotateMode.Tangent, scale = rotateMode == spine.RotateMode.ChainScale; + var boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1; + var bones = this.bones; + var spaces = spine.Utils.setArraySize(this.spaces, spacesCount), lengths = null; + var spacing = this.spacing; + if (scale || lengthSpacing) { + if (scale) + lengths = spine.Utils.setArraySize(this.lengths, boneCount); + for (var i = 0, n = spacesCount - 1; i < n;) { + var bone = bones[i]; + var setupLength = bone.data.length; + if (setupLength < PathConstraint.epsilon) { + if (scale) + lengths[i] = 0; + spaces[++i] = 0; + } + else { + var x = setupLength * bone.a, y = setupLength * bone.c; + var length_1 = Math.sqrt(x * x + y * y); + if (scale) + lengths[i] = length_1; + spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength; + } + } + } + else { + for (var i = 1; i < spacesCount; i++) + spaces[i] = spacing; + } + var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent); + var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation; + var tip = false; + if (offsetRotation == 0) + tip = rotateMode == spine.RotateMode.Chain; + else { + tip = false; + var p = this.target.bone; + offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + } + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + bone.worldX += (boneX - bone.worldX) * translateMix; + bone.worldY += (boneY - bone.worldY) * translateMix; + var x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY; + if (scale) { + var length_2 = lengths[i]; + if (length_2 != 0) { + var s = (Math.sqrt(dx * dx + dy * dy) / length_2 - 1) * rotateMix + 1; + bone.a *= s; + bone.c *= s; + } + } + boneX = x; + boneY = y; + if (rotate) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d, r = 0, cos = 0, sin = 0; + if (tangents) + r = positions[p - 1]; + else if (spaces[i + 1] == 0) + r = positions[p + 2]; + else + r = Math.atan2(dy, dx); + r -= Math.atan2(c, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_3 = bone.data.length; + boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix; + boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix; + } + else { + r += offsetRotation; + } + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + } + bone.appliedValid = false; + } + }; + PathConstraint.prototype.computeWorldPositions = function (path, spacesCount, tangents, percentPosition, percentSpacing) { + var target = this.target; + var position = this.position; + var spaces = this.spaces, out = spine.Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null; + var closed = path.closed; + var verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PathConstraint.NONE; + if (!path.constantSpeed) { + var lengths = path.lengths; + curveCount -= closed ? 1 : 2; + var pathLength_1 = lengths[curveCount]; + if (percentPosition) + position *= pathLength_1; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) + spaces[i] *= pathLength_1; + } + world = spine.Utils.setArraySize(this.world, 8); + for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength_1; + if (p < 0) + p += pathLength_1; + curve = 0; + } + else if (p < 0) { + if (prevCurve != PathConstraint.BEFORE) { + prevCurve = PathConstraint.BEFORE; + path.computeWorldVertices(target, 2, 4, world, 0, 2); + } + this.addBeforePosition(p, world, 0, out, o); + continue; + } + else if (p > pathLength_1) { + if (prevCurve != PathConstraint.AFTER) { + prevCurve = PathConstraint.AFTER; + path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2); + } + this.addAfterPosition(p - pathLength_1, world, 0, out, o); + continue; + } + for (;; curve++) { + var length_4 = lengths[curve]; + if (p > length_4) + continue; + if (curve == 0) + p /= length_4; + else { + var prev = lengths[curve - 1]; + p = (p - prev) / (length_4 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + if (closed && curve == curveCount) { + path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2); + path.computeWorldVertices(target, 0, 4, world, 4, 2); + } + else + path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2); + } + this.addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], out, o, tangents || (i > 0 && space == 0)); + } + return out; + } + if (closed) { + verticesLength += 2; + world = spine.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2); + path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); + world[verticesLength - 2] = world[0]; + world[verticesLength - 1] = world[1]; + } + else { + curveCount--; + verticesLength -= 4; + world = spine.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength, world, 0, 2); + } + var curves = spine.Utils.setArraySize(this.curves, curveCount); + var pathLength = 0; + var x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; + var tmpx = 0, tmpy = 0, dddfx = 0, dddfy = 0, ddfx = 0, ddfy = 0, dfx = 0, dfy = 0; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = world[w]; + cy1 = world[w + 1]; + cx2 = world[w + 2]; + cy2 = world[w + 3]; + x2 = world[w + 4]; + y2 = world[w + 5]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; + tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + if (percentPosition) + position *= pathLength; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) + spaces[i] *= pathLength; + } + var segments = this.segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength; + if (p < 0) + p += pathLength; + curve = 0; + } + else if (p < 0) { + this.addBeforePosition(p, world, 0, out, o); + continue; + } + else if (p > pathLength) { + this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o); + continue; + } + for (;; curve++) { + var length_5 = curves[curve]; + if (p > length_5) + continue; + if (curve == 0) + p /= length_5; + else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_5 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + var ii = curve * 6; + x1 = world[ii]; + y1 = world[ii + 1]; + cx1 = world[ii + 2]; + cy1 = world[ii + 3]; + cx2 = world[ii + 4]; + cy2 = world[ii + 5]; + x2 = world[ii + 6]; + y2 = world[ii + 7]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.03; + tmpy = (y1 - cy1 * 2 + cy2) * 0.03; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + p *= curveLength; + for (;; segment++) { + var length_6 = segments[segment]; + if (p > length_6) + continue; + if (segment == 0) + p /= length_6; + else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_6 - prev); + } + break; + } + this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0)); + } + return out; + }; + PathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) { + var x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) { + var x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) { + if (p == 0 || isNaN(p)) + p = 0.0001; + var tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u; + var ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p; + var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt; + out[o] = x; + out[o + 1] = y; + if (tangents) + out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt)); + }; + PathConstraint.prototype.getOrder = function () { + return this.data.order; + }; + PathConstraint.NONE = -1; + PathConstraint.BEFORE = -2; + PathConstraint.AFTER = -3; + PathConstraint.epsilon = 0.00001; + return PathConstraint; + }()); + spine.PathConstraint = PathConstraint; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PathConstraintData = (function () { + function PathConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.name = name; + } + return PathConstraintData; + }()); + spine.PathConstraintData = PathConstraintData; + var PositionMode; + (function (PositionMode) { + PositionMode[PositionMode["Fixed"] = 0] = "Fixed"; + PositionMode[PositionMode["Percent"] = 1] = "Percent"; + })(PositionMode = spine.PositionMode || (spine.PositionMode = {})); + var SpacingMode; + (function (SpacingMode) { + SpacingMode[SpacingMode["Length"] = 0] = "Length"; + SpacingMode[SpacingMode["Fixed"] = 1] = "Fixed"; + SpacingMode[SpacingMode["Percent"] = 2] = "Percent"; + })(SpacingMode = spine.SpacingMode || (spine.SpacingMode = {})); + var RotateMode; + (function (RotateMode) { + RotateMode[RotateMode["Tangent"] = 0] = "Tangent"; + RotateMode[RotateMode["Chain"] = 1] = "Chain"; + RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; + })(RotateMode = spine.RotateMode || (spine.RotateMode = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Assets = (function () { + function Assets(clientId) { + this.toLoad = new Array(); + this.assets = {}; + this.clientId = clientId; + } + Assets.prototype.loaded = function () { + var i = 0; + for (var v in this.assets) + i++; + return i; + }; + return Assets; + }()); + var SharedAssetManager = (function () { + function SharedAssetManager(pathPrefix) { + if (pathPrefix === void 0) { pathPrefix = ""; } + this.clientAssets = {}; + this.queuedAssets = {}; + this.rawAssets = {}; + this.errors = {}; + this.pathPrefix = pathPrefix; + } + SharedAssetManager.prototype.queueAsset = function (clientId, textureLoader, path) { + var clientAssets = this.clientAssets[clientId]; + if (clientAssets === null || clientAssets === undefined) { + clientAssets = new Assets(clientId); + this.clientAssets[clientId] = clientAssets; + } + if (textureLoader !== null) + clientAssets.textureLoader = textureLoader; + clientAssets.toLoad.push(path); + if (this.queuedAssets[path] === path) { + return false; + } + else { + this.queuedAssets[path] = path; + return true; + } + }; + SharedAssetManager.prototype.loadText = function (clientId, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, null, path)) + return; + var request = new XMLHttpRequest(); + request.onreadystatechange = function () { + if (request.readyState == XMLHttpRequest.DONE) { + if (request.status >= 200 && request.status < 300) { + _this.rawAssets[path] = request.responseText; + } + else { + _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText; + } + } + }; + request.open("GET", path, true); + request.send(); + }; + SharedAssetManager.prototype.loadJson = function (clientId, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, null, path)) + return; + var request = new XMLHttpRequest(); + request.onreadystatechange = function () { + if (request.readyState == XMLHttpRequest.DONE) { + if (request.status >= 200 && request.status < 300) { + _this.rawAssets[path] = JSON.parse(request.responseText); + } + else { + _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText; + } + } + }; + request.open("GET", path, true); + request.send(); + }; + SharedAssetManager.prototype.loadTexture = function (clientId, textureLoader, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, textureLoader, path)) + return; + var img = new Image(); + img.src = path; + img.crossOrigin = "anonymous"; + img.onload = function (ev) { + _this.rawAssets[path] = img; + }; + img.onerror = function (ev) { + _this.errors[path] = "Couldn't load image " + path; + }; + }; + SharedAssetManager.prototype.get = function (clientId, path) { + path = this.pathPrefix + path; + var clientAssets = this.clientAssets[clientId]; + if (clientAssets === null || clientAssets === undefined) + return true; + return clientAssets.assets[path]; + }; + SharedAssetManager.prototype.updateClientAssets = function (clientAssets) { + for (var i = 0; i < clientAssets.toLoad.length; i++) { + var path = clientAssets.toLoad[i]; + var asset = clientAssets.assets[path]; + if (asset === null || asset === undefined) { + var rawAsset = this.rawAssets[path]; + if (rawAsset === null || rawAsset === undefined) + continue; + if (rawAsset instanceof HTMLImageElement) { + clientAssets.assets[path] = clientAssets.textureLoader(rawAsset); + } + else { + clientAssets.assets[path] = rawAsset; + } + } + } + }; + SharedAssetManager.prototype.isLoadingComplete = function (clientId) { + var clientAssets = this.clientAssets[clientId]; + if (clientAssets === null || clientAssets === undefined) + return true; + this.updateClientAssets(clientAssets); + return clientAssets.toLoad.length == clientAssets.loaded(); + }; + SharedAssetManager.prototype.dispose = function () { + }; + SharedAssetManager.prototype.hasErrors = function () { + return Object.keys(this.errors).length > 0; + }; + SharedAssetManager.prototype.getErrors = function () { + return this.errors; + }; + return SharedAssetManager; + }()); + spine.SharedAssetManager = SharedAssetManager; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Skeleton = (function () { + function Skeleton(data) { + this._updateCache = new Array(); + this.updateCacheReset = new Array(); + this.time = 0; + this.flipX = false; + this.flipY = false; + this.x = 0; + this.y = 0; + if (data == null) + throw new Error("data cannot be null."); + this.data = data; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) { + var boneData = data.bones[i]; + var bone = void 0; + if (boneData.parent == null) + bone = new spine.Bone(boneData, this, null); + else { + var parent_1 = this.bones[boneData.parent.index]; + bone = new spine.Bone(boneData, this, parent_1); + parent_1.children.push(bone); + } + this.bones.push(bone); + } + this.slots = new Array(); + this.drawOrder = new Array(); + for (var i = 0; i < data.slots.length; i++) { + var slotData = data.slots[i]; + var bone = this.bones[slotData.boneData.index]; + var slot = new spine.Slot(slotData, bone); + this.slots.push(slot); + this.drawOrder.push(slot); + } + this.ikConstraints = new Array(); + for (var i = 0; i < data.ikConstraints.length; i++) { + var ikConstraintData = data.ikConstraints[i]; + this.ikConstraints.push(new spine.IkConstraint(ikConstraintData, this)); + } + this.transformConstraints = new Array(); + for (var i = 0; i < data.transformConstraints.length; i++) { + var transformConstraintData = data.transformConstraints[i]; + this.transformConstraints.push(new spine.TransformConstraint(transformConstraintData, this)); + } + this.pathConstraints = new Array(); + for (var i = 0; i < data.pathConstraints.length; i++) { + var pathConstraintData = data.pathConstraints[i]; + this.pathConstraints.push(new spine.PathConstraint(pathConstraintData, this)); + } + this.color = new spine.Color(1, 1, 1, 1); + this.updateCache(); + } + Skeleton.prototype.updateCache = function () { + var updateCache = this._updateCache; + updateCache.length = 0; + this.updateCacheReset.length = 0; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + bones[i].sorted = false; + var ikConstraints = this.ikConstraints; + var transformConstraints = this.transformConstraints; + var pathConstraints = this.pathConstraints; + var ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length; + var constraintCount = ikCount + transformCount + pathCount; + outer: for (var i = 0; i < constraintCount; i++) { + for (var ii = 0; ii < ikCount; ii++) { + var constraint = ikConstraints[ii]; + if (constraint.data.order == i) { + this.sortIkConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < transformCount; ii++) { + var constraint = transformConstraints[ii]; + if (constraint.data.order == i) { + this.sortTransformConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < pathCount; ii++) { + var constraint = pathConstraints[ii]; + if (constraint.data.order == i) { + this.sortPathConstraint(constraint); + continue outer; + } + } + } + for (var i = 0, n = bones.length; i < n; i++) + this.sortBone(bones[i]); + }; + Skeleton.prototype.sortIkConstraint = function (constraint) { + var target = constraint.target; + this.sortBone(target); + var constrained = constraint.bones; + var parent = constrained[0]; + this.sortBone(parent); + if (constrained.length > 1) { + var child = constrained[constrained.length - 1]; + if (!(this._updateCache.indexOf(child) > -1)) + this.updateCacheReset.push(child); + } + this._updateCache.push(constraint); + this.sortReset(parent.children); + constrained[constrained.length - 1].sorted = true; + }; + Skeleton.prototype.sortPathConstraint = function (constraint) { + var slot = constraint.target; + var slotIndex = slot.data.index; + var slotBone = slot.bone; + if (this.skin != null) + this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone); + if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin) + this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone); + for (var i = 0, n = this.data.skins.length; i < n; i++) + this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone); + var attachment = slot.getAttachment(); + if (attachment instanceof spine.PathAttachment) + this.sortPathConstraintAttachmentWith(attachment, slotBone); + var constrained = constraint.bones; + var boneCount = constrained.length; + for (var i = 0; i < boneCount; i++) + this.sortBone(constrained[i]); + this._updateCache.push(constraint); + for (var i = 0; i < boneCount; i++) + this.sortReset(constrained[i].children); + for (var i = 0; i < boneCount; i++) + constrained[i].sorted = true; + }; + Skeleton.prototype.sortTransformConstraint = function (constraint) { + this.sortBone(constraint.target); + var constrained = constraint.bones; + var boneCount = constrained.length; + if (constraint.data.local) { + for (var i = 0; i < boneCount; i++) { + var child = constrained[i]; + this.sortBone(child.parent); + if (!(this._updateCache.indexOf(child) > -1)) + this.updateCacheReset.push(child); + } + } + else { + for (var i = 0; i < boneCount; i++) { + this.sortBone(constrained[i]); + } + } + this._updateCache.push(constraint); + for (var ii = 0; ii < boneCount; ii++) + this.sortReset(constrained[ii].children); + for (var ii = 0; ii < boneCount; ii++) + constrained[ii].sorted = true; + }; + Skeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) { + var attachments = skin.attachments[slotIndex]; + if (!attachments) + return; + for (var key in attachments) { + this.sortPathConstraintAttachmentWith(attachments[key], slotBone); + } + }; + Skeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) { + if (!(attachment instanceof spine.PathAttachment)) + return; + var pathBones = attachment.bones; + if (pathBones == null) + this.sortBone(slotBone); + else { + var bones = this.bones; + var i = 0; + while (i < pathBones.length) { + var boneCount = pathBones[i++]; + for (var n = i + boneCount; i < n; i++) { + var boneIndex = pathBones[i]; + this.sortBone(bones[boneIndex]); + } + } + } + }; + Skeleton.prototype.sortBone = function (bone) { + if (bone.sorted) + return; + var parent = bone.parent; + if (parent != null) + this.sortBone(parent); + bone.sorted = true; + this._updateCache.push(bone); + }; + Skeleton.prototype.sortReset = function (bones) { + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.sorted) + this.sortReset(bone.children); + bone.sorted = false; + } + }; + Skeleton.prototype.updateWorldTransform = function () { + var updateCacheReset = this.updateCacheReset; + for (var i = 0, n = updateCacheReset.length; i < n; i++) { + var bone = updateCacheReset[i]; + bone.ax = bone.x; + bone.ay = bone.y; + bone.arotation = bone.rotation; + bone.ascaleX = bone.scaleX; + bone.ascaleY = bone.scaleY; + bone.ashearX = bone.shearX; + bone.ashearY = bone.shearY; + bone.appliedValid = true; + } + var updateCache = this._updateCache; + for (var i = 0, n = updateCache.length; i < n; i++) + updateCache[i].update(); + }; + Skeleton.prototype.setToSetupPose = function () { + this.setBonesToSetupPose(); + this.setSlotsToSetupPose(); + }; + Skeleton.prototype.setBonesToSetupPose = function () { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + bones[i].setToSetupPose(); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + constraint.bendDirection = constraint.data.bendDirection; + constraint.mix = constraint.data.mix; + } + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + var data = constraint.data; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + } + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + var data = constraint.data; + constraint.position = data.position; + constraint.spacing = data.spacing; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + } + }; + Skeleton.prototype.setSlotsToSetupPose = function () { + var slots = this.slots; + spine.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length); + for (var i = 0, n = slots.length; i < n; i++) + slots[i].setToSetupPose(); + }; + Skeleton.prototype.getRootBone = function () { + if (this.bones.length == 0) + return null; + return this.bones[0]; + }; + Skeleton.prototype.findBone = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.data.name == boneName) + return bone; + } + return null; + }; + Skeleton.prototype.findBoneIndex = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].data.name == boneName) + return i; + return -1; + }; + Skeleton.prototype.findSlot = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) + return slot; + } + return null; + }; + Skeleton.prototype.findSlotIndex = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + if (slots[i].data.name == slotName) + return i; + return -1; + }; + Skeleton.prototype.setSkinByName = function (skinName) { + var skin = this.data.findSkin(skinName); + if (skin == null) + throw new Error("Skin not found: " + skinName); + this.setSkin(skin); + }; + Skeleton.prototype.setSkin = function (newSkin) { + if (newSkin != null) { + if (this.skin != null) + newSkin.attachAll(this, this.skin); + else { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var name_1 = slot.data.attachmentName; + if (name_1 != null) { + var attachment = newSkin.getAttachment(i, name_1); + if (attachment != null) + slot.setAttachment(attachment); + } + } + } + } + this.skin = newSkin; + }; + Skeleton.prototype.getAttachmentByName = function (slotName, attachmentName) { + return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName); + }; + Skeleton.prototype.getAttachment = function (slotIndex, attachmentName) { + if (attachmentName == null) + throw new Error("attachmentName cannot be null."); + if (this.skin != null) { + var attachment = this.skin.getAttachment(slotIndex, attachmentName); + if (attachment != null) + return attachment; + } + if (this.data.defaultSkin != null) + return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); + return null; + }; + Skeleton.prototype.setAttachment = function (slotName, attachmentName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) { + var attachment = null; + if (attachmentName != null) { + attachment = this.getAttachment(i, attachmentName); + if (attachment == null) + throw new Error("Attachment not found: " + attachmentName + ", for slot: " + slotName); + } + slot.setAttachment(attachment); + return; + } + } + throw new Error("Slot not found: " + slotName); + }; + Skeleton.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var ikConstraint = ikConstraints[i]; + if (ikConstraint.data.name == constraintName) + return ikConstraint; + } + return null; + }; + Skeleton.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.data.name == constraintName) + return constraint; + } + return null; + }; + Skeleton.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.data.name == constraintName) + return constraint; + } + return null; + }; + Skeleton.prototype.getBounds = function (offset, size, temp) { + if (offset == null) + throw new Error("offset cannot be null."); + if (size == null) + throw new Error("size cannot be null."); + var drawOrder = this.drawOrder; + var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + var verticesLength = 0; + var vertices = null; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.RegionAttachment) { + verticesLength = 8; + vertices = spine.Utils.setArraySize(temp, verticesLength, 0); + attachment.computeWorldVertices(slot.bone, vertices, 0, 2); + } + else if (attachment instanceof spine.MeshAttachment) { + var mesh = attachment; + verticesLength = mesh.worldVerticesLength; + vertices = spine.Utils.setArraySize(temp, verticesLength, 0); + mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); + } + if (vertices != null) { + for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) { + var x = vertices[ii], y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + } + offset.set(minX, minY); + size.set(maxX - minX, maxY - minY); + }; + Skeleton.prototype.update = function (delta) { + this.time += delta; + }; + return Skeleton; + }()); + spine.Skeleton = Skeleton; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonBounds = (function () { + function SkeletonBounds() { + this.minX = 0; + this.minY = 0; + this.maxX = 0; + this.maxY = 0; + this.boundingBoxes = new Array(); + this.polygons = new Array(); + this.polygonPool = new spine.Pool(function () { + return spine.Utils.newFloatArray(16); + }); + } + SkeletonBounds.prototype.update = function (skeleton, updateAabb) { + if (skeleton == null) + throw new Error("skeleton cannot be null."); + var boundingBoxes = this.boundingBoxes; + var polygons = this.polygons; + var polygonPool = this.polygonPool; + var slots = skeleton.slots; + var slotCount = slots.length; + boundingBoxes.length = 0; + polygonPool.freeAll(polygons); + polygons.length = 0; + for (var i = 0; i < slotCount; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.BoundingBoxAttachment) { + var boundingBox = attachment; + boundingBoxes.push(boundingBox); + var polygon = polygonPool.obtain(); + if (polygon.length != boundingBox.worldVerticesLength) { + polygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength); + } + polygons.push(polygon); + boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2); + } + } + if (updateAabb) { + this.aabbCompute(); + } + else { + this.minX = Number.POSITIVE_INFINITY; + this.minY = Number.POSITIVE_INFINITY; + this.maxX = Number.NEGATIVE_INFINITY; + this.maxY = Number.NEGATIVE_INFINITY; + } + }; + SkeletonBounds.prototype.aabbCompute = function () { + var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) { + var polygon = polygons[i]; + var vertices = polygon; + for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) { + var x = vertices[ii]; + var y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + SkeletonBounds.prototype.aabbContainsPoint = function (x, y) { + return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; + }; + SkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY)) + return false; + var m = (y2 - y1) / (x2 - x1); + var y = m * (minX - x1) + y1; + if (y > minY && y < maxY) + return true; + y = m * (maxX - x1) + y1; + if (y > minY && y < maxY) + return true; + var x = (minY - y1) / m + x1; + if (x > minX && x < maxX) + return true; + x = (maxY - y1) / m + x1; + if (x > minX && x < maxX) + return true; + return false; + }; + SkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) { + return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; + }; + SkeletonBounds.prototype.containsPoint = function (x, y) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.containsPointPolygon(polygons[i], x, y)) + return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) { + var vertices = polygon; + var nn = polygon.length; + var prevIndex = nn - 2; + var inside = false; + for (var ii = 0; ii < nn; ii += 2) { + var vertexY = vertices[ii + 1]; + var prevY = vertices[prevIndex + 1]; + if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { + var vertexX = vertices[ii]; + if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x) + inside = !inside; + } + prevIndex = ii; + } + return inside; + }; + SkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2)) + return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) { + var vertices = polygon; + var nn = polygon.length; + var width12 = x1 - x2, height12 = y1 - y2; + var det1 = x1 * y2 - y1 * x2; + var x3 = vertices[nn - 2], y3 = vertices[nn - 1]; + for (var ii = 0; ii < nn; ii += 2) { + var x4 = vertices[ii], y4 = vertices[ii + 1]; + var det2 = x3 * y4 - y3 * x4; + var width34 = x3 - x4, height34 = y3 - y4; + var det3 = width12 * height34 - height12 * width34; + var x = (det1 * width34 - width12 * det2) / det3; + if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { + var y = (det1 * height34 - height12 * det2) / det3; + if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) + return true; + } + x3 = x4; + y3 = y4; + } + return false; + }; + SkeletonBounds.prototype.getPolygon = function (boundingBox) { + if (boundingBox == null) + throw new Error("boundingBox cannot be null."); + var index = this.boundingBoxes.indexOf(boundingBox); + return index == -1 ? null : this.polygons[index]; + }; + SkeletonBounds.prototype.getWidth = function () { + return this.maxX - this.minX; + }; + SkeletonBounds.prototype.getHeight = function () { + return this.maxY - this.minY; + }; + return SkeletonBounds; + }()); + spine.SkeletonBounds = SkeletonBounds; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonClipping = (function () { + function SkeletonClipping() { + this.triangulator = new spine.Triangulator(); + this.clippingPolygon = new Array(); + this.clipOutput = new Array(); + this.clippedVertices = new Array(); + this.clippedTriangles = new Array(); + this.scratch = new Array(); + } + SkeletonClipping.prototype.clipStart = function (slot, clip) { + if (this.clipAttachment != null) + return 0; + this.clipAttachment = clip; + var n = clip.worldVerticesLength; + var vertices = spine.Utils.setArraySize(this.clippingPolygon, n); + clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); + var clippingPolygon = this.clippingPolygon; + SkeletonClipping.makeClockwise(clippingPolygon); + var clippingPolygons = this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon)); + for (var i = 0, n_1 = clippingPolygons.length; i < n_1; i++) { + var polygon = clippingPolygons[i]; + SkeletonClipping.makeClockwise(polygon); + polygon.push(polygon[0]); + polygon.push(polygon[1]); + } + return clippingPolygons.length; + }; + SkeletonClipping.prototype.clipEndWithSlot = function (slot) { + if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data) + this.clipEnd(); + }; + SkeletonClipping.prototype.clipEnd = function () { + if (this.clipAttachment == null) + return; + this.clipAttachment = null; + this.clippingPolygons = null; + this.clippedVertices.length = 0; + this.clippedTriangles.length = 0; + this.clippingPolygon.length = 0; + }; + SkeletonClipping.prototype.isClipping = function () { + return this.clipAttachment != null; + }; + SkeletonClipping.prototype.clipTriangles = function (vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) { + var clipOutput = this.clipOutput, clippedVertices = this.clippedVertices; + var clippedTriangles = this.clippedTriangles; + var polygons = this.clippingPolygons; + var polygonsCount = this.clippingPolygons.length; + var vertexSize = twoColor ? 12 : 8; + var index = 0; + clippedVertices.length = 0; + clippedTriangles.length = 0; + outer: for (var i = 0; i < trianglesLength; i += 3) { + var vertexOffset = triangles[i] << 1; + var x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1]; + var u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 1] << 1; + var x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1]; + var u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 2] << 1; + var x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1]; + var u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1]; + for (var p = 0; p < polygonsCount; p++) { + var s = clippedVertices.length; + if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) { + var clipOutputLength = clipOutput.length; + if (clipOutputLength == 0) + continue; + var d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1; + var d = 1 / (d0 * d2 + d1 * (y1 - y3)); + var clipOutputCount = clipOutputLength >> 1; + var clipOutputItems = this.clipOutput; + var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize); + for (var ii = 0; ii < clipOutputLength; ii += 2) { + var x = clipOutputItems[ii], y = clipOutputItems[ii + 1]; + clippedVerticesItems[s] = x; + clippedVerticesItems[s + 1] = y; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + var c0 = x - x3, c1 = y - y3; + var a = (d0 * c0 + d1 * c1) * d; + var b = (d4 * c0 + d2 * c1) * d; + var c = 1 - a - b; + clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c; + clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c; + if (twoColor) { + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + } + s += vertexSize; + } + s = clippedTriangles.length; + var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2)); + clipOutputCount--; + for (var ii = 1; ii < clipOutputCount; ii++) { + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = (index + ii); + clippedTrianglesItems[s + 2] = (index + ii + 1); + s += 3; + } + index += clipOutputCount + 1; + } + else { + var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + 3 * vertexSize); + clippedVerticesItems[s] = x1; + clippedVerticesItems[s + 1] = y1; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + if (!twoColor) { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = x2; + clippedVerticesItems[s + 9] = y2; + clippedVerticesItems[s + 10] = light.r; + clippedVerticesItems[s + 11] = light.g; + clippedVerticesItems[s + 12] = light.b; + clippedVerticesItems[s + 13] = light.a; + clippedVerticesItems[s + 14] = u2; + clippedVerticesItems[s + 15] = v2; + clippedVerticesItems[s + 16] = x3; + clippedVerticesItems[s + 17] = y3; + clippedVerticesItems[s + 18] = light.r; + clippedVerticesItems[s + 19] = light.g; + clippedVerticesItems[s + 20] = light.b; + clippedVerticesItems[s + 21] = light.a; + clippedVerticesItems[s + 22] = u3; + clippedVerticesItems[s + 23] = v3; + } + else { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + clippedVerticesItems[s + 12] = x2; + clippedVerticesItems[s + 13] = y2; + clippedVerticesItems[s + 14] = light.r; + clippedVerticesItems[s + 15] = light.g; + clippedVerticesItems[s + 16] = light.b; + clippedVerticesItems[s + 17] = light.a; + clippedVerticesItems[s + 18] = u2; + clippedVerticesItems[s + 19] = v2; + clippedVerticesItems[s + 20] = dark.r; + clippedVerticesItems[s + 21] = dark.g; + clippedVerticesItems[s + 22] = dark.b; + clippedVerticesItems[s + 23] = dark.a; + clippedVerticesItems[s + 24] = x3; + clippedVerticesItems[s + 25] = y3; + clippedVerticesItems[s + 26] = light.r; + clippedVerticesItems[s + 27] = light.g; + clippedVerticesItems[s + 28] = light.b; + clippedVerticesItems[s + 29] = light.a; + clippedVerticesItems[s + 30] = u3; + clippedVerticesItems[s + 31] = v3; + clippedVerticesItems[s + 32] = dark.r; + clippedVerticesItems[s + 33] = dark.g; + clippedVerticesItems[s + 34] = dark.b; + clippedVerticesItems[s + 35] = dark.a; + } + s = clippedTriangles.length; + var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3); + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = (index + 1); + clippedTrianglesItems[s + 2] = (index + 2); + index += 3; + continue outer; + } + } + } + }; + SkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) { + var originalOutput = output; + var clipped = false; + var input = null; + if (clippingArea.length % 4 >= 2) { + input = output; + output = this.scratch; + } + else + input = this.scratch; + input.length = 0; + input.push(x1); + input.push(y1); + input.push(x2); + input.push(y2); + input.push(x3); + input.push(y3); + input.push(x1); + input.push(y1); + output.length = 0; + var clippingVertices = clippingArea; + var clippingVerticesLast = clippingArea.length - 4; + for (var i = 0;; i += 2) { + var edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1]; + var edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3]; + var deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2; + var inputVertices = input; + var inputVerticesLength = input.length - 2, outputStart = output.length; + for (var ii = 0; ii < inputVerticesLength; ii += 2) { + var inputX = inputVertices[ii], inputY = inputVertices[ii + 1]; + var inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3]; + var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0; + if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) { + if (side2) { + output.push(inputX2); + output.push(inputY2); + continue; + } + var c0 = inputY2 - inputY, c2 = inputX2 - inputX; + var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + } + else if (side2) { + var c0 = inputY2 - inputY, c2 = inputX2 - inputX; + var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + output.push(inputX2); + output.push(inputY2); + } + clipped = true; + } + if (outputStart == output.length) { + originalOutput.length = 0; + return true; + } + output.push(output[0]); + output.push(output[1]); + if (i == clippingVerticesLast) + break; + var temp = output; + output = input; + output.length = 0; + input = temp; + } + if (originalOutput != output) { + originalOutput.length = 0; + for (var i = 0, n = output.length - 2; i < n; i++) + originalOutput[i] = output[i]; + } + else + originalOutput.length = originalOutput.length - 2; + return clipped; + }; + SkeletonClipping.makeClockwise = function (polygon) { + var vertices = polygon; + var verticeslength = polygon.length; + var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x = 0, p1y = 0, p2x = 0, p2y = 0; + for (var i = 0, n = verticeslength - 3; i < n; i += 2) { + p1x = vertices[i]; + p1y = vertices[i + 1]; + p2x = vertices[i + 2]; + p2y = vertices[i + 3]; + area += p1x * p2y - p2x * p1y; + } + if (area < 0) + return; + for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) { + var x = vertices[i], y = vertices[i + 1]; + var other = lastX - i; + vertices[i] = vertices[other]; + vertices[i + 1] = vertices[other + 1]; + vertices[other] = x; + vertices[other + 1] = y; + } + }; + return SkeletonClipping; + }()); + spine.SkeletonClipping = SkeletonClipping; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonData = (function () { + function SkeletonData() { + this.bones = new Array(); + this.slots = new Array(); + this.skins = new Array(); + this.events = new Array(); + this.animations = new Array(); + this.ikConstraints = new Array(); + this.transformConstraints = new Array(); + this.pathConstraints = new Array(); + this.fps = 0; + } + SkeletonData.prototype.findBone = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.name == boneName) + return bone; + } + return null; + }; + SkeletonData.prototype.findBoneIndex = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].name == boneName) + return i; + return -1; + }; + SkeletonData.prototype.findSlot = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.name == slotName) + return slot; + } + return null; + }; + SkeletonData.prototype.findSlotIndex = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + if (slots[i].name == slotName) + return i; + return -1; + }; + SkeletonData.prototype.findSkin = function (skinName) { + if (skinName == null) + throw new Error("skinName cannot be null."); + var skins = this.skins; + for (var i = 0, n = skins.length; i < n; i++) { + var skin = skins[i]; + if (skin.name == skinName) + return skin; + } + return null; + }; + SkeletonData.prototype.findEvent = function (eventDataName) { + if (eventDataName == null) + throw new Error("eventDataName cannot be null."); + var events = this.events; + for (var i = 0, n = events.length; i < n; i++) { + var event_4 = events[i]; + if (event_4.name == eventDataName) + return event_4; + } + return null; + }; + SkeletonData.prototype.findAnimation = function (animationName) { + if (animationName == null) + throw new Error("animationName cannot be null."); + var animations = this.animations; + for (var i = 0, n = animations.length; i < n; i++) { + var animation = animations[i]; + if (animation.name == animationName) + return animation; + } + return null; + }; + SkeletonData.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + if (constraint.name == constraintName) + return constraint; + } + return null; + }; + SkeletonData.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.name == constraintName) + return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.name == constraintName) + return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) { + if (pathConstraintName == null) + throw new Error("pathConstraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) + if (pathConstraints[i].name == pathConstraintName) + return i; + return -1; + }; + return SkeletonData; + }()); + spine.SkeletonData = SkeletonData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonJson = (function () { + function SkeletonJson(attachmentLoader) { + this.scale = 1; + this.linkedMeshes = new Array(); + this.attachmentLoader = attachmentLoader; + } + SkeletonJson.prototype.readSkeletonData = function (json) { + var scale = this.scale; + var skeletonData = new spine.SkeletonData(); + var root = typeof (json) === "string" ? JSON.parse(json) : json; + var skeletonMap = root.skeleton; + if (skeletonMap != null) { + skeletonData.hash = skeletonMap.hash; + skeletonData.version = skeletonMap.spine; + skeletonData.width = skeletonMap.width; + skeletonData.height = skeletonMap.height; + skeletonData.fps = skeletonMap.fps; + skeletonData.imagesPath = skeletonMap.images; + } + if (root.bones) { + for (var i = 0; i < root.bones.length; i++) { + var boneMap = root.bones[i]; + var parent_2 = null; + var parentName = this.getValue(boneMap, "parent", null); + if (parentName != null) { + parent_2 = skeletonData.findBone(parentName); + if (parent_2 == null) + throw new Error("Parent bone not found: " + parentName); + } + var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_2); + data.length = this.getValue(boneMap, "length", 0) * scale; + data.x = this.getValue(boneMap, "x", 0) * scale; + data.y = this.getValue(boneMap, "y", 0) * scale; + data.rotation = this.getValue(boneMap, "rotation", 0); + data.scaleX = this.getValue(boneMap, "scaleX", 1); + data.scaleY = this.getValue(boneMap, "scaleY", 1); + data.shearX = this.getValue(boneMap, "shearX", 0); + data.shearY = this.getValue(boneMap, "shearY", 0); + data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, "transform", "normal")); + skeletonData.bones.push(data); + } + } + if (root.slots) { + for (var i = 0; i < root.slots.length; i++) { + var slotMap = root.slots[i]; + var slotName = slotMap.name; + var boneName = slotMap.bone; + var boneData = skeletonData.findBone(boneName); + if (boneData == null) + throw new Error("Slot bone not found: " + boneName); + var data = new spine.SlotData(skeletonData.slots.length, slotName, boneData); + var color = this.getValue(slotMap, "color", null); + if (color != null) + data.color.setFromString(color); + var dark = this.getValue(slotMap, "dark", null); + if (dark != null) { + data.darkColor = new spine.Color(1, 1, 1, 1); + data.darkColor.setFromString(dark); + } + data.attachmentName = this.getValue(slotMap, "attachment", null); + data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, "blend", "normal")); + skeletonData.slots.push(data); + } + } + if (root.ik) { + for (var i = 0; i < root.ik.length; i++) { + var constraintMap = root.ik[i]; + var data = new spine.IkConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) + throw new Error("IK bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) + throw new Error("IK target bone not found: " + targetName); + data.bendDirection = this.getValue(constraintMap, "bendPositive", true) ? 1 : -1; + data.mix = this.getValue(constraintMap, "mix", 1); + skeletonData.ikConstraints.push(data); + } + } + if (root.transform) { + for (var i = 0; i < root.transform.length; i++) { + var constraintMap = root.transform[i]; + var data = new spine.TransformConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) + throw new Error("Transform constraint bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) + throw new Error("Transform constraint target bone not found: " + targetName); + data.local = this.getValue(constraintMap, "local", false); + data.relative = this.getValue(constraintMap, "relative", false); + data.offsetRotation = this.getValue(constraintMap, "rotation", 0); + data.offsetX = this.getValue(constraintMap, "x", 0) * scale; + data.offsetY = this.getValue(constraintMap, "y", 0) * scale; + data.offsetScaleX = this.getValue(constraintMap, "scaleX", 0); + data.offsetScaleY = this.getValue(constraintMap, "scaleY", 0); + data.offsetShearY = this.getValue(constraintMap, "shearY", 0); + data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); + data.translateMix = this.getValue(constraintMap, "translateMix", 1); + data.scaleMix = this.getValue(constraintMap, "scaleMix", 1); + data.shearMix = this.getValue(constraintMap, "shearMix", 1); + skeletonData.transformConstraints.push(data); + } + } + if (root.path) { + for (var i = 0; i < root.path.length; i++) { + var constraintMap = root.path[i]; + var data = new spine.PathConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) + throw new Error("Transform constraint bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findSlot(targetName); + if (data.target == null) + throw new Error("Path target slot not found: " + targetName); + data.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, "positionMode", "percent")); + data.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, "spacingMode", "length")); + data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, "rotateMode", "tangent")); + data.offsetRotation = this.getValue(constraintMap, "rotation", 0); + data.position = this.getValue(constraintMap, "position", 0); + if (data.positionMode == spine.PositionMode.Fixed) + data.position *= scale; + data.spacing = this.getValue(constraintMap, "spacing", 0); + if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed) + data.spacing *= scale; + data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); + data.translateMix = this.getValue(constraintMap, "translateMix", 1); + skeletonData.pathConstraints.push(data); + } + } + if (root.skins) { + for (var skinName in root.skins) { + var skinMap = root.skins[skinName]; + var skin = new spine.Skin(skinName); + for (var slotName in skinMap) { + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) + throw new Error("Slot not found: " + slotName); + var slotMap = skinMap[slotName]; + for (var entryName in slotMap) { + var attachment = this.readAttachment(slotMap[entryName], skin, slotIndex, entryName, skeletonData); + if (attachment != null) + skin.addAttachment(slotIndex, entryName, attachment); + } + } + skeletonData.skins.push(skin); + if (skin.name == "default") + skeletonData.defaultSkin = skin; + } + } + for (var i = 0, n = this.linkedMeshes.length; i < n; i++) { + var linkedMesh = this.linkedMeshes[i]; + var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); + if (skin == null) + throw new Error("Skin not found: " + linkedMesh.skin); + var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); + if (parent_3 == null) + throw new Error("Parent mesh not found: " + linkedMesh.parent); + linkedMesh.mesh.setParentMesh(parent_3); + linkedMesh.mesh.updateUVs(); + } + this.linkedMeshes.length = 0; + if (root.events) { + for (var eventName in root.events) { + var eventMap = root.events[eventName]; + var data = new spine.EventData(eventName); + data.intValue = this.getValue(eventMap, "int", 0); + data.floatValue = this.getValue(eventMap, "float", 0); + data.stringValue = this.getValue(eventMap, "string", ""); + skeletonData.events.push(data); + } + } + if (root.animations) { + for (var animationName in root.animations) { + var animationMap = root.animations[animationName]; + this.readAnimation(animationMap, animationName, skeletonData); + } + } + return skeletonData; + }; + SkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) { + var scale = this.scale; + name = this.getValue(map, "name", name); + var type = this.getValue(map, "type", "region"); + switch (type) { + case "region": { + var path = this.getValue(map, "path", name); + var region = this.attachmentLoader.newRegionAttachment(skin, name, path); + if (region == null) + return null; + region.path = path; + region.x = this.getValue(map, "x", 0) * scale; + region.y = this.getValue(map, "y", 0) * scale; + region.scaleX = this.getValue(map, "scaleX", 1); + region.scaleY = this.getValue(map, "scaleY", 1); + region.rotation = this.getValue(map, "rotation", 0); + region.width = map.width * scale; + region.height = map.height * scale; + var color = this.getValue(map, "color", null); + if (color != null) + region.color.setFromString(color); + region.updateOffset(); + return region; + } + case "boundingbox": { + var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); + if (box == null) + return null; + this.readVertices(map, box, map.vertexCount << 1); + var color = this.getValue(map, "color", null); + if (color != null) + box.color.setFromString(color); + return box; + } + case "mesh": + case "linkedmesh": { + var path = this.getValue(map, "path", name); + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (mesh == null) + return null; + mesh.path = path; + var color = this.getValue(map, "color", null); + if (color != null) + mesh.color.setFromString(color); + var parent_4 = this.getValue(map, "parent", null); + if (parent_4 != null) { + mesh.inheritDeform = this.getValue(map, "deform", true); + this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4)); + return mesh; + } + var uvs = map.uvs; + this.readVertices(map, mesh, uvs.length); + mesh.triangles = map.triangles; + mesh.regionUVs = uvs; + mesh.updateUVs(); + mesh.hullLength = this.getValue(map, "hull", 0) * 2; + return mesh; + } + case "path": { + var path = this.attachmentLoader.newPathAttachment(skin, name); + if (path == null) + return null; + path.closed = this.getValue(map, "closed", false); + path.constantSpeed = this.getValue(map, "constantSpeed", true); + var vertexCount = map.vertexCount; + this.readVertices(map, path, vertexCount << 1); + var lengths = spine.Utils.newArray(vertexCount / 3, 0); + for (var i = 0; i < map.lengths.length; i++) + lengths[i] = map.lengths[i] * scale; + path.lengths = lengths; + var color = this.getValue(map, "color", null); + if (color != null) + path.color.setFromString(color); + return path; + } + case "point": { + var point = this.attachmentLoader.newPointAttachment(skin, name); + if (point == null) + return null; + point.x = this.getValue(map, "x", 0) * scale; + point.y = this.getValue(map, "y", 0) * scale; + point.rotation = this.getValue(map, "rotation", 0); + var color = this.getValue(map, "color", null); + if (color != null) + point.color.setFromString(color); + return point; + } + case "clipping": { + var clip = this.attachmentLoader.newClippingAttachment(skin, name); + if (clip == null) + return null; + var end = this.getValue(map, "end", null); + if (end != null) { + var slot = skeletonData.findSlot(end); + if (slot == null) + throw new Error("Clipping end slot not found: " + end); + clip.endSlot = slot; + } + var vertexCount = map.vertexCount; + this.readVertices(map, clip, vertexCount << 1); + var color = this.getValue(map, "color", null); + if (color != null) + clip.color.setFromString(color); + return clip; + } + } + return null; + }; + SkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) { + var scale = this.scale; + attachment.worldVerticesLength = verticesLength; + var vertices = map.vertices; + if (verticesLength == vertices.length) { + var scaledVertices = spine.Utils.toFloatArray(vertices); + if (scale != 1) { + for (var i = 0, n = vertices.length; i < n; i++) + scaledVertices[i] *= scale; + } + attachment.vertices = scaledVertices; + return; + } + var weights = new Array(); + var bones = new Array(); + for (var i = 0, n = vertices.length; i < n;) { + var boneCount = vertices[i++]; + bones.push(boneCount); + for (var nn = i + boneCount * 4; i < nn; i += 4) { + bones.push(vertices[i]); + weights.push(vertices[i + 1] * scale); + weights.push(vertices[i + 2] * scale); + weights.push(vertices[i + 3]); + } + } + attachment.bones = bones; + attachment.vertices = spine.Utils.toFloatArray(weights); + }; + SkeletonJson.prototype.readAnimation = function (map, name, skeletonData) { + var scale = this.scale; + var timelines = new Array(); + var duration = 0; + if (map.slots) { + for (var slotName in map.slots) { + var slotMap = map.slots[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) + throw new Error("Slot not found: " + slotName); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + if (timelineName == "attachment") { + var timeline = new spine.AttachmentTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex++, valueMap.time, valueMap.name); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + else if (timelineName == "color") { + var timeline = new spine.ColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var color = new spine.Color(); + color.setFromString(valueMap.color); + timeline.setFrame(frameIndex, valueMap.time, color.r, color.g, color.b, color.a); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.ColorTimeline.ENTRIES]); + } + else if (timelineName == "twoColor") { + var timeline = new spine.TwoColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var light = new spine.Color(); + var dark = new spine.Color(); + light.setFromString(valueMap.light); + dark.setFromString(valueMap.dark); + timeline.setFrame(frameIndex, valueMap.time, light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TwoColorTimeline.ENTRIES]); + } + else + throw new Error("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"); + } + } + } + if (map.bones) { + for (var boneName in map.bones) { + var boneMap = map.bones[boneName]; + var boneIndex = skeletonData.findBoneIndex(boneName); + if (boneIndex == -1) + throw new Error("Bone not found: " + boneName); + for (var timelineName in boneMap) { + var timelineMap = boneMap[timelineName]; + if (timelineName === "rotate") { + var timeline = new spine.RotateTimeline(timelineMap.length); + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, valueMap.angle); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.RotateTimeline.ENTRIES]); + } + else if (timelineName === "translate" || timelineName === "scale" || timelineName === "shear") { + var timeline = null; + var timelineScale = 1; + if (timelineName === "scale") + timeline = new spine.ScaleTimeline(timelineMap.length); + else if (timelineName === "shear") + timeline = new spine.ShearTimeline(timelineMap.length); + else { + timeline = new spine.TranslateTimeline(timelineMap.length); + timelineScale = scale; + } + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var x = this.getValue(valueMap, "x", 0), y = this.getValue(valueMap, "y", 0); + timeline.setFrame(frameIndex, valueMap.time, x * timelineScale, y * timelineScale); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TranslateTimeline.ENTRIES]); + } + else + throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"); + } + } + } + if (map.ik) { + for (var constraintName in map.ik) { + var constraintMap = map.ik[constraintName]; + var constraint = skeletonData.findIkConstraint(constraintName); + var timeline = new spine.IkConstraintTimeline(constraintMap.length); + timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "mix", 1), this.getValue(valueMap, "bendPositive", true) ? 1 : -1); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.IkConstraintTimeline.ENTRIES]); + } + } + if (map.transform) { + for (var constraintName in map.transform) { + var constraintMap = map.transform[constraintName]; + var constraint = skeletonData.findTransformConstraint(constraintName); + var timeline = new spine.TransformConstraintTimeline(constraintMap.length); + timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1), this.getValue(valueMap, "scaleMix", 1), this.getValue(valueMap, "shearMix", 1)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TransformConstraintTimeline.ENTRIES]); + } + } + if (map.paths) { + for (var constraintName in map.paths) { + var constraintMap = map.paths[constraintName]; + var index = skeletonData.findPathConstraintIndex(constraintName); + if (index == -1) + throw new Error("Path constraint not found: " + constraintName); + var data = skeletonData.pathConstraints[index]; + for (var timelineName in constraintMap) { + var timelineMap = constraintMap[timelineName]; + if (timelineName === "position" || timelineName === "spacing") { + var timeline = null; + var timelineScale = 1; + if (timelineName === "spacing") { + timeline = new spine.PathConstraintSpacingTimeline(timelineMap.length); + if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed) + timelineScale = scale; + } + else { + timeline = new spine.PathConstraintPositionTimeline(timelineMap.length); + if (data.positionMode == spine.PositionMode.Fixed) + timelineScale = scale; + } + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, timelineName, 0) * timelineScale); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintPositionTimeline.ENTRIES]); + } + else if (timelineName === "mix") { + var timeline = new spine.PathConstraintMixTimeline(timelineMap.length); + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintMixTimeline.ENTRIES]); + } + } + } + } + if (map.deform) { + for (var deformName in map.deform) { + var deformMap = map.deform[deformName]; + var skin = skeletonData.findSkin(deformName); + if (skin == null) + throw new Error("Skin not found: " + deformName); + for (var slotName in deformMap) { + var slotMap = deformMap[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) + throw new Error("Slot not found: " + slotMap.name); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + var attachment = skin.getAttachment(slotIndex, timelineName); + if (attachment == null) + throw new Error("Deform attachment not found: " + timelineMap.name); + var weighted = attachment.bones != null; + var vertices = attachment.vertices; + var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length; + var timeline = new spine.DeformTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + timeline.attachment = attachment; + var frameIndex = 0; + for (var j = 0; j < timelineMap.length; j++) { + var valueMap = timelineMap[j]; + var deform = void 0; + var verticesValue = this.getValue(valueMap, "vertices", null); + if (verticesValue == null) + deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices; + else { + deform = spine.Utils.newFloatArray(deformLength); + var start = this.getValue(valueMap, "offset", 0); + spine.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length); + if (scale != 1) { + for (var i = start, n = i + verticesValue.length; i < n; i++) + deform[i] *= scale; + } + if (!weighted) { + for (var i = 0; i < deformLength; i++) + deform[i] += vertices[i]; + } + } + timeline.setFrame(frameIndex, valueMap.time, deform); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + } + } + } + var drawOrderNode = map.drawOrder; + if (drawOrderNode == null) + drawOrderNode = map.draworder; + if (drawOrderNode != null) { + var timeline = new spine.DrawOrderTimeline(drawOrderNode.length); + var slotCount = skeletonData.slots.length; + var frameIndex = 0; + for (var j = 0; j < drawOrderNode.length; j++) { + var drawOrderMap = drawOrderNode[j]; + var drawOrder = null; + var offsets = this.getValue(drawOrderMap, "offsets", null); + if (offsets != null) { + drawOrder = spine.Utils.newArray(slotCount, -1); + var unchanged = spine.Utils.newArray(slotCount - offsets.length, 0); + var originalIndex = 0, unchangedIndex = 0; + for (var i = 0; i < offsets.length; i++) { + var offsetMap = offsets[i]; + var slotIndex = skeletonData.findSlotIndex(offsetMap.slot); + if (slotIndex == -1) + throw new Error("Slot not found: " + offsetMap.slot); + while (originalIndex != slotIndex) + unchanged[unchangedIndex++] = originalIndex++; + drawOrder[originalIndex + offsetMap.offset] = originalIndex++; + } + while (originalIndex < slotCount) + unchanged[unchangedIndex++] = originalIndex++; + for (var i = slotCount - 1; i >= 0; i--) + if (drawOrder[i] == -1) + drawOrder[i] = unchanged[--unchangedIndex]; + } + timeline.setFrame(frameIndex++, drawOrderMap.time, drawOrder); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (map.events) { + var timeline = new spine.EventTimeline(map.events.length); + var frameIndex = 0; + for (var i = 0; i < map.events.length; i++) { + var eventMap = map.events[i]; + var eventData = skeletonData.findEvent(eventMap.name); + if (eventData == null) + throw new Error("Event not found: " + eventMap.name); + var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData); + event_5.intValue = this.getValue(eventMap, "int", eventData.intValue); + event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue); + event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue); + timeline.setFrame(frameIndex++, event_5); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (isNaN(duration)) { + throw new Error("Error while parsing animation, duration is NaN"); + } + skeletonData.animations.push(new spine.Animation(name, timelines, duration)); + }; + SkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) { + if (!map.curve) + return; + if (map.curve === "stepped") + timeline.setStepped(frameIndex); + else if (Object.prototype.toString.call(map.curve) === '[object Array]') { + var curve = map.curve; + timeline.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]); + } + }; + SkeletonJson.prototype.getValue = function (map, prop, defaultValue) { + return map[prop] !== undefined ? map[prop] : defaultValue; + }; + SkeletonJson.blendModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "normal") + return spine.BlendMode.Normal; + if (str == "additive") + return spine.BlendMode.Additive; + if (str == "multiply") + return spine.BlendMode.Multiply; + if (str == "screen") + return spine.BlendMode.Screen; + throw new Error("Unknown blend mode: " + str); + }; + SkeletonJson.positionModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "fixed") + return spine.PositionMode.Fixed; + if (str == "percent") + return spine.PositionMode.Percent; + throw new Error("Unknown position mode: " + str); + }; + SkeletonJson.spacingModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "length") + return spine.SpacingMode.Length; + if (str == "fixed") + return spine.SpacingMode.Fixed; + if (str == "percent") + return spine.SpacingMode.Percent; + throw new Error("Unknown position mode: " + str); + }; + SkeletonJson.rotateModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "tangent") + return spine.RotateMode.Tangent; + if (str == "chain") + return spine.RotateMode.Chain; + if (str == "chainscale") + return spine.RotateMode.ChainScale; + throw new Error("Unknown rotate mode: " + str); + }; + SkeletonJson.transformModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "normal") + return spine.TransformMode.Normal; + if (str == "onlytranslation") + return spine.TransformMode.OnlyTranslation; + if (str == "norotationorreflection") + return spine.TransformMode.NoRotationOrReflection; + if (str == "noscale") + return spine.TransformMode.NoScale; + if (str == "noscaleorreflection") + return spine.TransformMode.NoScaleOrReflection; + throw new Error("Unknown transform mode: " + str); + }; + return SkeletonJson; + }()); + spine.SkeletonJson = SkeletonJson; + var LinkedMesh = (function () { + function LinkedMesh(mesh, skin, slotIndex, parent) { + this.mesh = mesh; + this.skin = skin; + this.slotIndex = slotIndex; + this.parent = parent; + } + return LinkedMesh; + }()); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Skin = (function () { + function Skin(name) { + this.attachments = new Array(); + if (name == null) + throw new Error("name cannot be null."); + this.name = name; + } + Skin.prototype.addAttachment = function (slotIndex, name, attachment) { + if (attachment == null) + throw new Error("attachment cannot be null."); + var attachments = this.attachments; + if (slotIndex >= attachments.length) + attachments.length = slotIndex + 1; + if (!attachments[slotIndex]) + attachments[slotIndex] = {}; + attachments[slotIndex][name] = attachment; + }; + Skin.prototype.getAttachment = function (slotIndex, name) { + var dictionary = this.attachments[slotIndex]; + return dictionary ? dictionary[name] : null; + }; + Skin.prototype.attachAll = function (skeleton, oldSkin) { + var slotIndex = 0; + for (var i = 0; i < skeleton.slots.length; i++) { + var slot = skeleton.slots[i]; + var slotAttachment = slot.getAttachment(); + if (slotAttachment && slotIndex < oldSkin.attachments.length) { + var dictionary = oldSkin.attachments[slotIndex]; + for (var key in dictionary) { + var skinAttachment = dictionary[key]; + if (slotAttachment == skinAttachment) { + var attachment = this.getAttachment(slotIndex, key); + if (attachment != null) + slot.setAttachment(attachment); + break; + } + } + } + slotIndex++; + } + }; + return Skin; + }()); + spine.Skin = Skin; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Slot = (function () { + function Slot(data, bone) { + this.attachmentVertices = new Array(); + if (data == null) + throw new Error("data cannot be null."); + if (bone == null) + throw new Error("bone cannot be null."); + this.data = data; + this.bone = bone; + this.color = new spine.Color(); + this.darkColor = data.darkColor == null ? null : new spine.Color(); + this.setToSetupPose(); + } + Slot.prototype.getAttachment = function () { + return this.attachment; + }; + Slot.prototype.setAttachment = function (attachment) { + if (this.attachment == attachment) + return; + this.attachment = attachment; + this.attachmentTime = this.bone.skeleton.time; + this.attachmentVertices.length = 0; + }; + Slot.prototype.setAttachmentTime = function (time) { + this.attachmentTime = this.bone.skeleton.time - time; + }; + Slot.prototype.getAttachmentTime = function () { + return this.bone.skeleton.time - this.attachmentTime; + }; + Slot.prototype.setToSetupPose = function () { + this.color.setFromColor(this.data.color); + if (this.darkColor != null) + this.darkColor.setFromColor(this.data.darkColor); + if (this.data.attachmentName == null) + this.attachment = null; + else { + this.attachment = null; + this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName)); + } + }; + return Slot; + }()); + spine.Slot = Slot; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SlotData = (function () { + function SlotData(index, name, boneData) { + this.color = new spine.Color(1, 1, 1, 1); + if (index < 0) + throw new Error("index must be >= 0."); + if (name == null) + throw new Error("name cannot be null."); + if (boneData == null) + throw new Error("boneData cannot be null."); + this.index = index; + this.name = name; + this.boneData = boneData; + } + return SlotData; + }()); + spine.SlotData = SlotData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Texture = (function () { + function Texture(image) { + this._image = image; + } + Texture.prototype.getImage = function () { + return this._image; + }; + Texture.filterFromString = function (text) { + switch (text.toLowerCase()) { + case "nearest": return TextureFilter.Nearest; + case "linear": return TextureFilter.Linear; + case "mipmap": return TextureFilter.MipMap; + case "mipmapnearestnearest": return TextureFilter.MipMapNearestNearest; + case "mipmaplinearnearest": return TextureFilter.MipMapLinearNearest; + case "mipmapnearestlinear": return TextureFilter.MipMapNearestLinear; + case "mipmaplinearlinear": return TextureFilter.MipMapLinearLinear; + default: throw new Error("Unknown texture filter " + text); + } + }; + Texture.wrapFromString = function (text) { + switch (text.toLowerCase()) { + case "mirroredtepeat": return TextureWrap.MirroredRepeat; + case "clamptoedge": return TextureWrap.ClampToEdge; + case "repeat": return TextureWrap.Repeat; + default: throw new Error("Unknown texture wrap " + text); + } + }; + return Texture; + }()); + spine.Texture = Texture; + var TextureFilter; + (function (TextureFilter) { + TextureFilter[TextureFilter["Nearest"] = 9728] = "Nearest"; + TextureFilter[TextureFilter["Linear"] = 9729] = "Linear"; + TextureFilter[TextureFilter["MipMap"] = 9987] = "MipMap"; + TextureFilter[TextureFilter["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest"; + TextureFilter[TextureFilter["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest"; + TextureFilter[TextureFilter["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear"; + TextureFilter[TextureFilter["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear"; + })(TextureFilter = spine.TextureFilter || (spine.TextureFilter = {})); + var TextureWrap; + (function (TextureWrap) { + TextureWrap[TextureWrap["MirroredRepeat"] = 33648] = "MirroredRepeat"; + TextureWrap[TextureWrap["ClampToEdge"] = 33071] = "ClampToEdge"; + TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat"; + })(TextureWrap = spine.TextureWrap || (spine.TextureWrap = {})); + var TextureRegion = (function () { + function TextureRegion() { + this.u = 0; + this.v = 0; + this.u2 = 0; + this.v2 = 0; + this.width = 0; + this.height = 0; + this.rotate = false; + this.offsetX = 0; + this.offsetY = 0; + this.originalWidth = 0; + this.originalHeight = 0; + } + return TextureRegion; + }()); + spine.TextureRegion = TextureRegion; + var FakeTexture = (function (_super) { + __extends(FakeTexture, _super); + function FakeTexture() { + return _super !== null && _super.apply(this, arguments) || this; + } + FakeTexture.prototype.setFilters = function (minFilter, magFilter) { }; + FakeTexture.prototype.setWraps = function (uWrap, vWrap) { }; + FakeTexture.prototype.dispose = function () { }; + return FakeTexture; + }(spine.Texture)); + spine.FakeTexture = FakeTexture; +})(spine || (spine = {})); +var spine; +(function (spine) { + var TextureAtlas = (function () { + function TextureAtlas(atlasText, textureLoader) { + this.pages = new Array(); + this.regions = new Array(); + this.load(atlasText, textureLoader); + } + TextureAtlas.prototype.load = function (atlasText, textureLoader) { + if (textureLoader == null) + throw new Error("textureLoader cannot be null."); + var reader = new TextureAtlasReader(atlasText); + var tuple = new Array(4); + var page = null; + while (true) { + var line = reader.readLine(); + if (line == null) + break; + line = line.trim(); + if (line.length == 0) + page = null; + else if (!page) { + page = new TextureAtlasPage(); + page.name = line; + if (reader.readTuple(tuple) == 2) { + page.width = parseInt(tuple[0]); + page.height = parseInt(tuple[1]); + reader.readTuple(tuple); + } + reader.readTuple(tuple); + page.minFilter = spine.Texture.filterFromString(tuple[0]); + page.magFilter = spine.Texture.filterFromString(tuple[1]); + var direction = reader.readValue(); + page.uWrap = spine.TextureWrap.ClampToEdge; + page.vWrap = spine.TextureWrap.ClampToEdge; + if (direction == "x") + page.uWrap = spine.TextureWrap.Repeat; + else if (direction == "y") + page.vWrap = spine.TextureWrap.Repeat; + else if (direction == "xy") + page.uWrap = page.vWrap = spine.TextureWrap.Repeat; + page.texture = textureLoader(line); + page.texture.setFilters(page.minFilter, page.magFilter); + page.texture.setWraps(page.uWrap, page.vWrap); + page.width = page.texture.getImage().width; + page.height = page.texture.getImage().height; + this.pages.push(page); + } + else { + var region = new TextureAtlasRegion(); + region.name = line; + region.page = page; + region.rotate = reader.readValue() == "true"; + reader.readTuple(tuple); + var x = parseInt(tuple[0]); + var y = parseInt(tuple[1]); + reader.readTuple(tuple); + var width = parseInt(tuple[0]); + var height = parseInt(tuple[1]); + region.u = x / page.width; + region.v = y / page.height; + if (region.rotate) { + region.u2 = (x + height) / page.width; + region.v2 = (y + width) / page.height; + } + else { + region.u2 = (x + width) / page.width; + region.v2 = (y + height) / page.height; + } + region.x = x; + region.y = y; + region.width = Math.abs(width); + region.height = Math.abs(height); + if (reader.readTuple(tuple) == 4) { + if (reader.readTuple(tuple) == 4) { + reader.readTuple(tuple); + } + } + region.originalWidth = parseInt(tuple[0]); + region.originalHeight = parseInt(tuple[1]); + reader.readTuple(tuple); + region.offsetX = parseInt(tuple[0]); + region.offsetY = parseInt(tuple[1]); + region.index = parseInt(reader.readValue()); + region.texture = page.texture; + this.regions.push(region); + } + } + }; + TextureAtlas.prototype.findRegion = function (name) { + for (var i = 0; i < this.regions.length; i++) { + if (this.regions[i].name == name) { + return this.regions[i]; + } + } + return null; + }; + TextureAtlas.prototype.dispose = function () { + for (var i = 0; i < this.pages.length; i++) { + this.pages[i].texture.dispose(); + } + }; + return TextureAtlas; + }()); + spine.TextureAtlas = TextureAtlas; + var TextureAtlasReader = (function () { + function TextureAtlasReader(text) { + this.index = 0; + this.lines = text.split(/\r\n|\r|\n/); + } + TextureAtlasReader.prototype.readLine = function () { + if (this.index >= this.lines.length) + return null; + return this.lines[this.index++]; + }; + TextureAtlasReader.prototype.readValue = function () { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (colon == -1) + throw new Error("Invalid line: " + line); + return line.substring(colon + 1).trim(); + }; + TextureAtlasReader.prototype.readTuple = function (tuple) { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (colon == -1) + throw new Error("Invalid line: " + line); + var i = 0, lastMatch = colon + 1; + for (; i < 3; i++) { + var comma = line.indexOf(",", lastMatch); + if (comma == -1) + break; + tuple[i] = line.substr(lastMatch, comma - lastMatch).trim(); + lastMatch = comma + 1; + } + tuple[i] = line.substring(lastMatch).trim(); + return i + 1; + }; + return TextureAtlasReader; + }()); + var TextureAtlasPage = (function () { + function TextureAtlasPage() { + } + return TextureAtlasPage; + }()); + spine.TextureAtlasPage = TextureAtlasPage; + var TextureAtlasRegion = (function (_super) { + __extends(TextureAtlasRegion, _super); + function TextureAtlasRegion() { + return _super !== null && _super.apply(this, arguments) || this; + } + return TextureAtlasRegion; + }(spine.TextureRegion)); + spine.TextureAtlasRegion = TextureAtlasRegion; +})(spine || (spine = {})); +var spine; +(function (spine) { + var TransformConstraint = (function () { + function TransformConstraint(data, skeleton) { + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.temp = new spine.Vector2(); + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + this.scaleMix = data.scaleMix; + this.shearMix = data.shearMix; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + TransformConstraint.prototype.apply = function () { + this.update(); + }; + TransformConstraint.prototype.update = function () { + if (this.data.local) { + if (this.data.relative) + this.applyRelativeLocal(); + else + this.applyAbsoluteLocal(); + } + else { + if (this.data.relative) + this.applyRelativeWorld(); + else + this.applyAbsoluteWorld(); + } + }; + TransformConstraint.prototype.applyAbsoluteWorld = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + var ta = target.a, tb = target.b, tc = target.c, td = target.d; + var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect; + var offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + if (rotateMix != 0) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation; + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + bone.worldX += (temp.x - bone.worldX) * translateMix; + bone.worldY += (temp.y - bone.worldY) * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = Math.sqrt(bone.a * bone.a + bone.c * bone.c); + var ts = Math.sqrt(ta * ta + tc * tc); + if (s > 0.00001) + s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s; + bone.a *= s; + bone.c *= s; + s = Math.sqrt(bone.b * bone.b + bone.d * bone.d); + ts = Math.sqrt(tb * tb + td * td); + if (s > 0.00001) + s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s; + bone.b *= s; + bone.d *= s; + modified = true; + } + if (shearMix > 0) { + var b = bone.b, d = bone.d; + var by = Math.atan2(d, b); + var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(bone.c, bone.a)); + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r = by + (r + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + bone.b = Math.cos(r) * s; + bone.d = Math.sin(r) * s; + modified = true; + } + if (modified) + bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyRelativeWorld = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + var ta = target.a, tb = target.b, tc = target.c, td = target.d; + var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect, offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + if (rotateMix != 0) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var r = Math.atan2(tc, ta) + offsetRotation; + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + bone.worldX += temp.x * translateMix; + bone.worldY += temp.y * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1; + bone.a *= s; + bone.c *= s; + s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1; + bone.b *= s; + bone.d *= s; + modified = true; + } + if (shearMix > 0) { + var r = Math.atan2(td, tb) - Math.atan2(tc, ta); + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + var b = bone.b, d = bone.d; + r = Math.atan2(d, b) + (r - spine.MathUtils.PI / 2 + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + bone.b = Math.cos(r) * s; + bone.d = Math.sin(r) * s; + modified = true; + } + if (modified) + bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyAbsoluteLocal = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) + target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) + bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) { + var r = target.arotation - rotation + this.data.offsetRotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + rotation += r * rotateMix; + } + var x = bone.ax, y = bone.ay; + if (translateMix != 0) { + x += (target.ax - x + this.data.offsetX) * translateMix; + y += (target.ay - y + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) + scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX; + if (scaleY > 0.00001) + scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY; + } + var shearY = bone.ashearY; + if (shearMix > 0) { + var r = target.ashearY - shearY + this.data.offsetShearY; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.shearY += r * shearMix; + } + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.applyRelativeLocal = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) + target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) + bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) + rotation += (target.arotation + this.data.offsetRotation) * rotateMix; + var x = bone.ax, y = bone.ay; + if (translateMix != 0) { + x += (target.ax + this.data.offsetX) * translateMix; + y += (target.ay + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) + scaleX *= ((target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix) + 1; + if (scaleY > 0.00001) + scaleY *= ((target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix) + 1; + } + var shearY = bone.ashearY; + if (shearMix > 0) + shearY += (target.ashearY + this.data.offsetShearY) * shearMix; + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.getOrder = function () { + return this.data.order; + }; + return TransformConstraint; + }()); + spine.TransformConstraint = TransformConstraint; +})(spine || (spine = {})); +var spine; +(function (spine) { + var TransformConstraintData = (function () { + function TransformConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.offsetRotation = 0; + this.offsetX = 0; + this.offsetY = 0; + this.offsetScaleX = 0; + this.offsetScaleY = 0; + this.offsetShearY = 0; + this.relative = false; + this.local = false; + if (name == null) + throw new Error("name cannot be null."); + this.name = name; + } + return TransformConstraintData; + }()); + spine.TransformConstraintData = TransformConstraintData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Triangulator = (function () { + function Triangulator() { + this.convexPolygons = new Array(); + this.convexPolygonsIndices = new Array(); + this.indicesArray = new Array(); + this.isConcaveArray = new Array(); + this.triangles = new Array(); + this.polygonPool = new spine.Pool(function () { + return new Array(); + }); + this.polygonIndicesPool = new spine.Pool(function () { + return new Array(); + }); + } + Triangulator.prototype.triangulate = function (verticesArray) { + var vertices = verticesArray; + var vertexCount = verticesArray.length >> 1; + var indices = this.indicesArray; + indices.length = 0; + for (var i = 0; i < vertexCount; i++) + indices[i] = i; + var isConcave = this.isConcaveArray; + isConcave.length = 0; + for (var i = 0, n = vertexCount; i < n; ++i) + isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices); + var triangles = this.triangles; + triangles.length = 0; + while (vertexCount > 3) { + var previous = vertexCount - 1, i = 0, next = 1; + while (true) { + outer: if (!isConcave[i]) { + var p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1; + var p1x = vertices[p1], p1y = vertices[p1 + 1]; + var p2x = vertices[p2], p2y = vertices[p2 + 1]; + var p3x = vertices[p3], p3y = vertices[p3 + 1]; + for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) { + if (!isConcave[ii]) + continue; + var v = indices[ii] << 1; + var vx = vertices[v], vy = vertices[v + 1]; + if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) { + if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) { + if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy)) + break outer; + } + } + } + break; + } + if (next == 0) { + do { + if (!isConcave[i]) + break; + i--; + } while (i > 0); + break; + } + previous = i; + i = next; + next = (next + 1) % vertexCount; + } + triangles.push(indices[(vertexCount + i - 1) % vertexCount]); + triangles.push(indices[i]); + triangles.push(indices[(i + 1) % vertexCount]); + indices.splice(i, 1); + isConcave.splice(i, 1); + vertexCount--; + var previousIndex = (vertexCount + i - 1) % vertexCount; + var nextIndex = i == vertexCount ? 0 : i; + isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices); + isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices); + } + if (vertexCount == 3) { + triangles.push(indices[2]); + triangles.push(indices[0]); + triangles.push(indices[1]); + } + return triangles; + }; + Triangulator.prototype.decompose = function (verticesArray, triangles) { + var vertices = verticesArray; + var convexPolygons = this.convexPolygons; + this.polygonPool.freeAll(convexPolygons); + convexPolygons.length = 0; + var convexPolygonsIndices = this.convexPolygonsIndices; + this.polygonIndicesPool.freeAll(convexPolygonsIndices); + convexPolygonsIndices.length = 0; + var polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + var polygon = this.polygonPool.obtain(); + polygon.length = 0; + var fanBaseIndex = -1, lastWinding = 0; + for (var i = 0, n = triangles.length; i < n; i += 3) { + var t1 = triangles[i] << 1, t2 = triangles[i + 1] << 1, t3 = triangles[i + 2] << 1; + var x1 = vertices[t1], y1 = vertices[t1 + 1]; + var x2 = vertices[t2], y2 = vertices[t2 + 1]; + var x3 = vertices[t3], y3 = vertices[t3 + 1]; + var merged = false; + if (fanBaseIndex == t1) { + var o = polygon.length - 4; + var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3); + var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]); + if (winding1 == lastWinding && winding2 == lastWinding) { + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(t3); + merged = true; + } + } + if (!merged) { + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } + else { + this.polygonPool.free(polygon); + this.polygonIndicesPool.free(polygonIndices); + } + polygon = this.polygonPool.obtain(); + polygon.length = 0; + polygon.push(x1); + polygon.push(y1); + polygon.push(x2); + polygon.push(y2); + polygon.push(x3); + polygon.push(y3); + polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + polygonIndices.push(t1); + polygonIndices.push(t2); + polygonIndices.push(t3); + lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3); + fanBaseIndex = t1; + } + } + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } + for (var i = 0, n = convexPolygons.length; i < n; i++) { + polygonIndices = convexPolygonsIndices[i]; + if (polygonIndices.length == 0) + continue; + var firstIndex = polygonIndices[0]; + var lastIndex = polygonIndices[polygonIndices.length - 1]; + polygon = convexPolygons[i]; + var o = polygon.length - 4; + var prevPrevX = polygon[o], prevPrevY = polygon[o + 1]; + var prevX = polygon[o + 2], prevY = polygon[o + 3]; + var firstX = polygon[0], firstY = polygon[1]; + var secondX = polygon[2], secondY = polygon[3]; + var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY); + for (var ii = 0; ii < n; ii++) { + if (ii == i) + continue; + var otherIndices = convexPolygonsIndices[ii]; + if (otherIndices.length != 3) + continue; + var otherFirstIndex = otherIndices[0]; + var otherSecondIndex = otherIndices[1]; + var otherLastIndex = otherIndices[2]; + var otherPoly = convexPolygons[ii]; + var x3 = otherPoly[otherPoly.length - 2], y3 = otherPoly[otherPoly.length - 1]; + if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) + continue; + var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3); + var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY); + if (winding1 == winding && winding2 == winding) { + otherPoly.length = 0; + otherIndices.length = 0; + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(otherLastIndex); + prevPrevX = prevX; + prevPrevY = prevY; + prevX = x3; + prevY = y3; + ii = 0; + } + } + } + for (var i = convexPolygons.length - 1; i >= 0; i--) { + polygon = convexPolygons[i]; + if (polygon.length == 0) { + convexPolygons.splice(i, 1); + this.polygonPool.free(polygon); + polygonIndices = convexPolygonsIndices[i]; + convexPolygonsIndices.splice(i, 1); + this.polygonIndicesPool.free(polygonIndices); + } + } + return convexPolygons; + }; + Triangulator.isConcave = function (index, vertexCount, vertices, indices) { + var previous = indices[(vertexCount + index - 1) % vertexCount] << 1; + var current = indices[index] << 1; + var next = indices[(index + 1) % vertexCount] << 1; + return !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]); + }; + Triangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) { + return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; + }; + Triangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) { + var px = p2x - p1x, py = p2y - p1y; + return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; + }; + return Triangulator; + }()); + spine.Triangulator = Triangulator; +})(spine || (spine = {})); +var spine; +(function (spine) { + var IntSet = (function () { + function IntSet() { + this.array = new Array(); + } + IntSet.prototype.add = function (value) { + var contains = this.contains(value); + this.array[value | 0] = value | 0; + return !contains; + }; + IntSet.prototype.contains = function (value) { + return this.array[value | 0] != undefined; + }; + IntSet.prototype.remove = function (value) { + this.array[value | 0] = undefined; + }; + IntSet.prototype.clear = function () { + this.array.length = 0; + }; + return IntSet; + }()); + spine.IntSet = IntSet; + var Color = (function () { + function Color(r, g, b, a) { + if (r === void 0) { r = 0; } + if (g === void 0) { g = 0; } + if (b === void 0) { b = 0; } + if (a === void 0) { a = 0; } + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + Color.prototype.set = function (r, g, b, a) { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + this.clamp(); + return this; + }; + Color.prototype.setFromColor = function (c) { + this.r = c.r; + this.g = c.g; + this.b = c.b; + this.a = c.a; + return this; + }; + Color.prototype.setFromString = function (hex) { + hex = hex.charAt(0) == '#' ? hex.substr(1) : hex; + this.r = parseInt(hex.substr(0, 2), 16) / 255.0; + this.g = parseInt(hex.substr(2, 2), 16) / 255.0; + this.b = parseInt(hex.substr(4, 2), 16) / 255.0; + this.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0; + return this; + }; + Color.prototype.add = function (r, g, b, a) { + this.r += r; + this.g += g; + this.b += b; + this.a += a; + this.clamp(); + return this; + }; + Color.prototype.clamp = function () { + if (this.r < 0) + this.r = 0; + else if (this.r > 1) + this.r = 1; + if (this.g < 0) + this.g = 0; + else if (this.g > 1) + this.g = 1; + if (this.b < 0) + this.b = 0; + else if (this.b > 1) + this.b = 1; + if (this.a < 0) + this.a = 0; + else if (this.a > 1) + this.a = 1; + return this; + }; + Color.WHITE = new Color(1, 1, 1, 1); + Color.RED = new Color(1, 0, 0, 1); + Color.GREEN = new Color(0, 1, 0, 1); + Color.BLUE = new Color(0, 0, 1, 1); + Color.MAGENTA = new Color(1, 0, 1, 1); + return Color; + }()); + spine.Color = Color; + var MathUtils = (function () { + function MathUtils() { + } + MathUtils.clamp = function (value, min, max) { + if (value < min) + return min; + if (value > max) + return max; + return value; + }; + MathUtils.cosDeg = function (degrees) { + return Math.cos(degrees * MathUtils.degRad); + }; + MathUtils.sinDeg = function (degrees) { + return Math.sin(degrees * MathUtils.degRad); + }; + MathUtils.signum = function (value) { + return value > 0 ? 1 : value < 0 ? -1 : 0; + }; + MathUtils.toInt = function (x) { + return x > 0 ? Math.floor(x) : Math.ceil(x); + }; + MathUtils.cbrt = function (x) { + var y = Math.pow(Math.abs(x), 1 / 3); + return x < 0 ? -y : y; + }; + MathUtils.randomTriangular = function (min, max) { + return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5); + }; + MathUtils.randomTriangularWith = function (min, max, mode) { + var u = Math.random(); + var d = max - min; + if (u <= (mode - min) / d) + return min + Math.sqrt(u * d * (mode - min)); + return max - Math.sqrt((1 - u) * d * (max - mode)); + }; + MathUtils.PI = 3.1415927; + MathUtils.PI2 = MathUtils.PI * 2; + MathUtils.radiansToDegrees = 180 / MathUtils.PI; + MathUtils.radDeg = MathUtils.radiansToDegrees; + MathUtils.degreesToRadians = MathUtils.PI / 180; + MathUtils.degRad = MathUtils.degreesToRadians; + return MathUtils; + }()); + spine.MathUtils = MathUtils; + var Interpolation = (function () { + function Interpolation() { + } + Interpolation.prototype.apply = function (start, end, a) { + return start + (end - start) * this.applyInternal(a); + }; + return Interpolation; + }()); + spine.Interpolation = Interpolation; + var Pow = (function (_super) { + __extends(Pow, _super); + function Pow(power) { + var _this = _super.call(this) || this; + _this.power = 2; + _this.power = power; + return _this; + } + Pow.prototype.applyInternal = function (a) { + if (a <= 0.5) + return Math.pow(a * 2, this.power) / 2; + return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1; + }; + return Pow; + }(Interpolation)); + spine.Pow = Pow; + var PowOut = (function (_super) { + __extends(PowOut, _super); + function PowOut(power) { + return _super.call(this, power) || this; + } + PowOut.prototype.applyInternal = function (a) { + return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; + }; + return PowOut; + }(Pow)); + spine.PowOut = PowOut; + var Utils = (function () { + function Utils() { + } + Utils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) { + for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) { + dest[j] = source[i]; + } + }; + Utils.setArraySize = function (array, size, value) { + if (value === void 0) { value = 0; } + var oldSize = array.length; + if (oldSize == size) + return array; + array.length = size; + if (oldSize < size) { + for (var i = oldSize; i < size; i++) + array[i] = value; + } + return array; + }; + Utils.ensureArrayCapacity = function (array, size, value) { + if (value === void 0) { value = 0; } + if (array.length >= size) + return array; + return Utils.setArraySize(array, size, value); + }; + Utils.newArray = function (size, defaultValue) { + var array = new Array(size); + for (var i = 0; i < size; i++) + array[i] = defaultValue; + return array; + }; + Utils.newFloatArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Float32Array(size); + } + else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) + array[i] = 0; + return array; + } + }; + Utils.newShortArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Int16Array(size); + } + else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) + array[i] = 0; + return array; + } + }; + Utils.toFloatArray = function (array) { + return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; + }; + Utils.toSinglePrecision = function (value) { + return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value; + }; + Utils.webkit602BugfixHelper = function (alpha, pose) { + }; + Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; + return Utils; + }()); + spine.Utils = Utils; + var DebugUtils = (function () { + function DebugUtils() { + } + DebugUtils.logBones = function (skeleton) { + for (var i = 0; i < skeleton.bones.length; i++) { + var bone = skeleton.bones[i]; + console.log(bone.data.name + ", " + bone.a + ", " + bone.b + ", " + bone.c + ", " + bone.d + ", " + bone.worldX + ", " + bone.worldY); + } + }; + return DebugUtils; + }()); + spine.DebugUtils = DebugUtils; + var Pool = (function () { + function Pool(instantiator) { + this.items = new Array(); + this.instantiator = instantiator; + } + Pool.prototype.obtain = function () { + return this.items.length > 0 ? this.items.pop() : this.instantiator(); + }; + Pool.prototype.free = function (item) { + if (item.reset) + item.reset(); + this.items.push(item); + }; + Pool.prototype.freeAll = function (items) { + for (var i = 0; i < items.length; i++) { + if (items[i].reset) + items[i].reset(); + this.items[i] = items[i]; + } + }; + Pool.prototype.clear = function () { + this.items.length = 0; + }; + return Pool; + }()); + spine.Pool = Pool; + var Vector2 = (function () { + function Vector2(x, y) { + if (x === void 0) { x = 0; } + if (y === void 0) { y = 0; } + this.x = x; + this.y = y; + } + Vector2.prototype.set = function (x, y) { + this.x = x; + this.y = y; + return this; + }; + Vector2.prototype.length = function () { + var x = this.x; + var y = this.y; + return Math.sqrt(x * x + y * y); + }; + Vector2.prototype.normalize = function () { + var len = this.length(); + if (len != 0) { + this.x /= len; + this.y /= len; + } + return this; + }; + return Vector2; + }()); + spine.Vector2 = Vector2; + var TimeKeeper = (function () { + function TimeKeeper() { + this.maxDelta = 0.064; + this.framesPerSecond = 0; + this.delta = 0; + this.totalTime = 0; + this.lastTime = Date.now() / 1000; + this.frameCount = 0; + this.frameTime = 0; + } + TimeKeeper.prototype.update = function () { + var now = Date.now() / 1000; + this.delta = now - this.lastTime; + this.frameTime += this.delta; + this.totalTime += this.delta; + if (this.delta > this.maxDelta) + this.delta = this.maxDelta; + this.lastTime = now; + this.frameCount++; + if (this.frameTime > 1) { + this.framesPerSecond = this.frameCount / this.frameTime; + this.frameTime = 0; + this.frameCount = 0; + } + }; + return TimeKeeper; + }()); + spine.TimeKeeper = TimeKeeper; + var WindowedMean = (function () { + function WindowedMean(windowSize) { + if (windowSize === void 0) { windowSize = 32; } + this.addedValues = 0; + this.lastValue = 0; + this.mean = 0; + this.dirty = true; + this.values = new Array(windowSize); + } + WindowedMean.prototype.hasEnoughData = function () { + return this.addedValues >= this.values.length; + }; + WindowedMean.prototype.addValue = function (value) { + if (this.addedValues < this.values.length) + this.addedValues++; + this.values[this.lastValue++] = value; + if (this.lastValue > this.values.length - 1) + this.lastValue = 0; + this.dirty = true; + }; + WindowedMean.prototype.getMean = function () { + if (this.hasEnoughData()) { + if (this.dirty) { + var mean = 0; + for (var i = 0; i < this.values.length; i++) { + mean += this.values[i]; + } + this.mean = mean / this.values.length; + this.dirty = false; + } + return this.mean; + } + else { + return 0; + } + }; + return WindowedMean; + }()); + spine.WindowedMean = WindowedMean; +})(spine || (spine = {})); +(function () { + if (!Math.fround) { + Math.fround = (function (array) { + return function (x) { + return array[0] = x, array[0]; + }; + })(new Float32Array(1)); + } +})(); +var spine; +(function (spine) { + var Attachment = (function () { + function Attachment(name) { + if (name == null) + throw new Error("name cannot be null."); + this.name = name; + } + return Attachment; + }()); + spine.Attachment = Attachment; + var VertexAttachment = (function (_super) { + __extends(VertexAttachment, _super); + function VertexAttachment(name) { + var _this = _super.call(this, name) || this; + _this.id = (VertexAttachment.nextID++ & 65535) << 11; + _this.worldVerticesLength = 0; + return _this; + } + VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) { + count = offset + (count >> 1) * stride; + var skeleton = slot.bone.skeleton; + var deformArray = slot.attachmentVertices; + var vertices = this.vertices; + var bones = this.bones; + if (bones == null) { + if (deformArray.length > 0) + vertices = deformArray; + var bone = slot.bone; + var x = bone.worldX; + var y = bone.worldY; + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) { + var vx = vertices[v_1], vy = vertices[v_1 + 1]; + worldVertices[w] = vx * a + vy * b + x; + worldVertices[w + 1] = vx * c + vy * d + y; + } + return; + } + var v = 0, skip = 0; + for (var i = 0; i < start; i += 2) { + var n = bones[v]; + v += n + 1; + skip += n; + } + var skeletonBones = skeleton.bones; + if (deformArray.length == 0) { + for (var w = offset, b = skip * 3; w < count; w += stride) { + var wx = 0, wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3) { + var bone = skeletonBones[bones[v]]; + var vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2]; + wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight; + wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } + else { + var deform = deformArray; + for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) { + var wx = 0, wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3, f += 2) { + var bone = skeletonBones[bones[v]]; + var vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2]; + wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight; + wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } + }; + VertexAttachment.prototype.applyDeform = function (sourceAttachment) { + return this == sourceAttachment; + }; + VertexAttachment.nextID = 0; + return VertexAttachment; + }(Attachment)); + spine.VertexAttachment = VertexAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AttachmentType; + (function (AttachmentType) { + AttachmentType[AttachmentType["Region"] = 0] = "Region"; + AttachmentType[AttachmentType["BoundingBox"] = 1] = "BoundingBox"; + AttachmentType[AttachmentType["Mesh"] = 2] = "Mesh"; + AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh"; + AttachmentType[AttachmentType["Path"] = 4] = "Path"; + AttachmentType[AttachmentType["Point"] = 5] = "Point"; + })(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var BoundingBoxAttachment = (function (_super) { + __extends(BoundingBoxAttachment, _super); + function BoundingBoxAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(1, 1, 1, 1); + return _this; + } + return BoundingBoxAttachment; + }(spine.VertexAttachment)); + spine.BoundingBoxAttachment = BoundingBoxAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var ClippingAttachment = (function (_super) { + __extends(ClippingAttachment, _super); + function ClippingAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(0.2275, 0.2275, 0.8078, 1); + return _this; + } + return ClippingAttachment; + }(spine.VertexAttachment)); + spine.ClippingAttachment = ClippingAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var MeshAttachment = (function (_super) { + __extends(MeshAttachment, _super); + function MeshAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(1, 1, 1, 1); + _this.inheritDeform = false; + _this.tempColor = new spine.Color(0, 0, 0, 0); + return _this; + } + MeshAttachment.prototype.updateUVs = function () { + var u = 0, v = 0, width = 0, height = 0; + if (this.region == null) { + u = v = 0; + width = height = 1; + } + else { + u = this.region.u; + v = this.region.v; + width = this.region.u2 - u; + height = this.region.v2 - v; + } + var regionUVs = this.regionUVs; + if (this.uvs == null || this.uvs.length != regionUVs.length) + this.uvs = spine.Utils.newFloatArray(regionUVs.length); + var uvs = this.uvs; + if (this.region.rotate) { + for (var i = 0, n = uvs.length; i < n; i += 2) { + uvs[i] = u + regionUVs[i + 1] * width; + uvs[i + 1] = v + height - regionUVs[i] * height; + } + } + else { + for (var i = 0, n = uvs.length; i < n; i += 2) { + uvs[i] = u + regionUVs[i] * width; + uvs[i + 1] = v + regionUVs[i + 1] * height; + } + } + }; + MeshAttachment.prototype.applyDeform = function (sourceAttachment) { + return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment); + }; + MeshAttachment.prototype.getParentMesh = function () { + return this.parentMesh; + }; + MeshAttachment.prototype.setParentMesh = function (parentMesh) { + this.parentMesh = parentMesh; + if (parentMesh != null) { + this.bones = parentMesh.bones; + this.vertices = parentMesh.vertices; + this.worldVerticesLength = parentMesh.worldVerticesLength; + this.regionUVs = parentMesh.regionUVs; + this.triangles = parentMesh.triangles; + this.hullLength = parentMesh.hullLength; + this.worldVerticesLength = parentMesh.worldVerticesLength; + } + }; + return MeshAttachment; + }(spine.VertexAttachment)); + spine.MeshAttachment = MeshAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PathAttachment = (function (_super) { + __extends(PathAttachment, _super); + function PathAttachment(name) { + var _this = _super.call(this, name) || this; + _this.closed = false; + _this.constantSpeed = false; + _this.color = new spine.Color(1, 1, 1, 1); + return _this; + } + return PathAttachment; + }(spine.VertexAttachment)); + spine.PathAttachment = PathAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PointAttachment = (function (_super) { + __extends(PointAttachment, _super); + function PointAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(0.38, 0.94, 0, 1); + return _this; + } + PointAttachment.prototype.computeWorldPosition = function (bone, point) { + point.x = this.x * bone.a + this.y * bone.b + bone.worldX; + point.y = this.x * bone.c + this.y * bone.d + bone.worldY; + return point; + }; + PointAttachment.prototype.computeWorldRotation = function (bone) { + var cos = spine.MathUtils.cosDeg(this.rotation), sin = spine.MathUtils.sinDeg(this.rotation); + var x = cos * bone.a + sin * bone.b; + var y = cos * bone.c + sin * bone.d; + return Math.atan2(y, x) * spine.MathUtils.radDeg; + }; + return PointAttachment; + }(spine.VertexAttachment)); + spine.PointAttachment = PointAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var RegionAttachment = (function (_super) { + __extends(RegionAttachment, _super); + function RegionAttachment(name) { + var _this = _super.call(this, name) || this; + _this.x = 0; + _this.y = 0; + _this.scaleX = 1; + _this.scaleY = 1; + _this.rotation = 0; + _this.width = 0; + _this.height = 0; + _this.color = new spine.Color(1, 1, 1, 1); + _this.offset = spine.Utils.newFloatArray(8); + _this.uvs = spine.Utils.newFloatArray(8); + _this.tempColor = new spine.Color(1, 1, 1, 1); + return _this; + } + RegionAttachment.prototype.updateOffset = function () { + var regionScaleX = this.width / this.region.originalWidth * this.scaleX; + var regionScaleY = this.height / this.region.originalHeight * this.scaleY; + var localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX; + var localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY; + var localX2 = localX + this.region.width * regionScaleX; + var localY2 = localY + this.region.height * regionScaleY; + var radians = this.rotation * Math.PI / 180; + var cos = Math.cos(radians); + var sin = Math.sin(radians); + var localXCos = localX * cos + this.x; + var localXSin = localX * sin; + var localYCos = localY * cos + this.y; + var localYSin = localY * sin; + var localX2Cos = localX2 * cos + this.x; + var localX2Sin = localX2 * sin; + var localY2Cos = localY2 * cos + this.y; + var localY2Sin = localY2 * sin; + var offset = this.offset; + offset[RegionAttachment.OX1] = localXCos - localYSin; + offset[RegionAttachment.OY1] = localYCos + localXSin; + offset[RegionAttachment.OX2] = localXCos - localY2Sin; + offset[RegionAttachment.OY2] = localY2Cos + localXSin; + offset[RegionAttachment.OX3] = localX2Cos - localY2Sin; + offset[RegionAttachment.OY3] = localY2Cos + localX2Sin; + offset[RegionAttachment.OX4] = localX2Cos - localYSin; + offset[RegionAttachment.OY4] = localYCos + localX2Sin; + }; + RegionAttachment.prototype.setRegion = function (region) { + this.region = region; + var uvs = this.uvs; + if (region.rotate) { + uvs[2] = region.u; + uvs[3] = region.v2; + uvs[4] = region.u; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v; + uvs[0] = region.u2; + uvs[1] = region.v2; + } + else { + uvs[0] = region.u; + uvs[1] = region.v2; + uvs[2] = region.u; + uvs[3] = region.v; + uvs[4] = region.u2; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v2; + } + }; + RegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) { + var vertexOffset = this.offset; + var x = bone.worldX, y = bone.worldY; + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var offsetX = 0, offsetY = 0; + offsetX = vertexOffset[RegionAttachment.OX1]; + offsetY = vertexOffset[RegionAttachment.OY1]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX2]; + offsetY = vertexOffset[RegionAttachment.OY2]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX3]; + offsetY = vertexOffset[RegionAttachment.OY3]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX4]; + offsetY = vertexOffset[RegionAttachment.OY4]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + }; + RegionAttachment.OX1 = 0; + RegionAttachment.OY1 = 1; + RegionAttachment.OX2 = 2; + RegionAttachment.OY2 = 3; + RegionAttachment.OX3 = 4; + RegionAttachment.OY3 = 5; + RegionAttachment.OX4 = 6; + RegionAttachment.OY4 = 7; + RegionAttachment.X1 = 0; + RegionAttachment.Y1 = 1; + RegionAttachment.C1R = 2; + RegionAttachment.C1G = 3; + RegionAttachment.C1B = 4; + RegionAttachment.C1A = 5; + RegionAttachment.U1 = 6; + RegionAttachment.V1 = 7; + RegionAttachment.X2 = 8; + RegionAttachment.Y2 = 9; + RegionAttachment.C2R = 10; + RegionAttachment.C2G = 11; + RegionAttachment.C2B = 12; + RegionAttachment.C2A = 13; + RegionAttachment.U2 = 14; + RegionAttachment.V2 = 15; + RegionAttachment.X3 = 16; + RegionAttachment.Y3 = 17; + RegionAttachment.C3R = 18; + RegionAttachment.C3G = 19; + RegionAttachment.C3B = 20; + RegionAttachment.C3A = 21; + RegionAttachment.U3 = 22; + RegionAttachment.V3 = 23; + RegionAttachment.X4 = 24; + RegionAttachment.Y4 = 25; + RegionAttachment.C4R = 26; + RegionAttachment.C4G = 27; + RegionAttachment.C4B = 28; + RegionAttachment.C4A = 29; + RegionAttachment.U4 = 30; + RegionAttachment.V4 = 31; + return RegionAttachment; + }(spine.Attachment)); + spine.RegionAttachment = RegionAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var JitterEffect = (function () { + function JitterEffect(jitterX, jitterY) { + this.jitterX = 0; + this.jitterY = 0; + this.jitterX = jitterX; + this.jitterY = jitterY; + } + JitterEffect.prototype.begin = function (skeleton) { + }; + JitterEffect.prototype.transform = function (position, uv, light, dark) { + position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + }; + JitterEffect.prototype.end = function () { + }; + return JitterEffect; + }()); + spine.JitterEffect = JitterEffect; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SwirlEffect = (function () { + function SwirlEffect(radius) { + this.centerX = 0; + this.centerY = 0; + this.radius = 0; + this.angle = 0; + this.worldX = 0; + this.worldY = 0; + this.radius = radius; + } + SwirlEffect.prototype.begin = function (skeleton) { + this.worldX = skeleton.x + this.centerX; + this.worldY = skeleton.y + this.centerY; + }; + SwirlEffect.prototype.transform = function (position, uv, light, dark) { + var radAngle = this.angle * spine.MathUtils.degreesToRadians; + var x = position.x - this.worldX; + var y = position.y - this.worldY; + var dist = Math.sqrt(x * x + y * y); + if (dist < this.radius) { + var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius); + var cos = Math.cos(theta); + var sin = Math.sin(theta); + position.x = cos * x - sin * y + this.worldX; + position.y = sin * x + cos * y + this.worldY; + } + }; + SwirlEffect.prototype.end = function () { + }; + SwirlEffect.interpolation = new spine.PowOut(2); + return SwirlEffect; + }()); + spine.SwirlEffect = SwirlEffect; +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var AssetManager = (function (_super) { + __extends(AssetManager, _super); + function AssetManager(context, pathPrefix) { + if (pathPrefix === void 0) { pathPrefix = ""; } + return _super.call(this, function (image) { + return new spine.webgl.GLTexture(context, image); + }, pathPrefix) || this; + } + return AssetManager; + }(spine.AssetManager)); + webgl.AssetManager = AssetManager; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var OrthoCamera = (function () { + function OrthoCamera(viewportWidth, viewportHeight) { + this.position = new webgl.Vector3(0, 0, 0); + this.direction = new webgl.Vector3(0, 0, -1); + this.up = new webgl.Vector3(0, 1, 0); + this.near = 0; + this.far = 100; + this.zoom = 1; + this.viewportWidth = 0; + this.viewportHeight = 0; + this.projectionView = new webgl.Matrix4(); + this.inverseProjectionView = new webgl.Matrix4(); + this.projection = new webgl.Matrix4(); + this.view = new webgl.Matrix4(); + this.tmp = new webgl.Vector3(); + this.viewportWidth = viewportWidth; + this.viewportHeight = viewportHeight; + this.update(); + } + OrthoCamera.prototype.update = function () { + var projection = this.projection; + var view = this.view; + var projectionView = this.projectionView; + var inverseProjectionView = this.inverseProjectionView; + var zoom = this.zoom, viewportWidth = this.viewportWidth, viewportHeight = this.viewportHeight; + projection.ortho(zoom * (-viewportWidth / 2), zoom * (viewportWidth / 2), zoom * (-viewportHeight / 2), zoom * (viewportHeight / 2), this.near, this.far); + view.lookAt(this.position, this.direction, this.up); + projectionView.set(projection.values); + projectionView.multiply(view); + inverseProjectionView.set(projectionView.values).invert(); + }; + OrthoCamera.prototype.screenToWorld = function (screenCoords, screenWidth, screenHeight) { + var x = screenCoords.x, y = screenHeight - screenCoords.y - 1; + var tmp = this.tmp; + tmp.x = (2 * x) / screenWidth - 1; + tmp.y = (2 * y) / screenHeight - 1; + tmp.z = (2 * screenCoords.z) - 1; + tmp.project(this.inverseProjectionView); + screenCoords.set(tmp.x, tmp.y, tmp.z); + return screenCoords; + }; + OrthoCamera.prototype.setViewport = function (viewportWidth, viewportHeight) { + this.viewportWidth = viewportWidth; + this.viewportHeight = viewportHeight; + }; + return OrthoCamera; + }()); + webgl.OrthoCamera = OrthoCamera; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var GLTexture = (function (_super) { + __extends(GLTexture, _super); + function GLTexture(context, image, useMipMaps) { + if (useMipMaps === void 0) { useMipMaps = false; } + var _this = _super.call(this, image) || this; + _this.texture = null; + _this.boundUnit = 0; + _this.useMipMaps = false; + _this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + _this.useMipMaps = useMipMaps; + _this.restore(); + _this.context.addRestorable(_this); + return _this; + } + GLTexture.prototype.setFilters = function (minFilter, magFilter) { + var gl = this.context.gl; + this.bind(); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); + }; + GLTexture.prototype.setWraps = function (uWrap, vWrap) { + var gl = this.context.gl; + this.bind(); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap); + }; + GLTexture.prototype.update = function (useMipMaps) { + var gl = this.context.gl; + if (!this.texture) { + this.texture = this.context.gl.createTexture(); + } + this.bind(); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + if (useMipMaps) + gl.generateMipmap(gl.TEXTURE_2D); + }; + GLTexture.prototype.restore = function () { + this.texture = null; + this.update(this.useMipMaps); + }; + GLTexture.prototype.bind = function (unit) { + if (unit === void 0) { unit = 0; } + var gl = this.context.gl; + this.boundUnit = unit; + gl.activeTexture(gl.TEXTURE0 + unit); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + }; + GLTexture.prototype.unbind = function () { + var gl = this.context.gl; + gl.activeTexture(gl.TEXTURE0 + this.boundUnit); + gl.bindTexture(gl.TEXTURE_2D, null); + }; + GLTexture.prototype.dispose = function () { + this.context.removeRestorable(this); + var gl = this.context.gl; + gl.deleteTexture(this.texture); + }; + return GLTexture; + }(spine.Texture)); + webgl.GLTexture = GLTexture; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Input = (function () { + function Input(element) { + this.lastX = 0; + this.lastY = 0; + this.buttonDown = false; + this.currTouch = null; + this.touchesPool = new spine.Pool(function () { + return new spine.webgl.Touch(0, 0, 0); + }); + this.listeners = new Array(); + this.element = element; + this.setupCallbacks(element); + } + Input.prototype.setupCallbacks = function (element) { + var _this = this; + element.addEventListener("mousedown", function (ev) { + if (ev instanceof MouseEvent) { + var rect = element.getBoundingClientRect(); + var x = ev.clientX - rect.left; + var y = ev.clientY - rect.top; + var listeners = _this.listeners; + for (var i = 0; i < listeners.length; i++) { + listeners[i].down(x, y); + } + _this.lastX = x; + _this.lastY = y; + _this.buttonDown = true; + } + }, true); + element.addEventListener("mousemove", function (ev) { + if (ev instanceof MouseEvent) { + var rect = element.getBoundingClientRect(); + var x = ev.clientX - rect.left; + var y = ev.clientY - rect.top; + var listeners = _this.listeners; + for (var i = 0; i < listeners.length; i++) { + if (_this.buttonDown) { + listeners[i].dragged(x, y); + } + else { + listeners[i].moved(x, y); + } + } + _this.lastX = x; + _this.lastY = y; + } + }, true); + element.addEventListener("mouseup", function (ev) { + if (ev instanceof MouseEvent) { + var rect = element.getBoundingClientRect(); + var x = ev.clientX - rect.left; + var y = ev.clientY - rect.top; + var listeners = _this.listeners; + for (var i = 0; i < listeners.length; i++) { + listeners[i].up(x, y); + } + _this.lastX = x; + _this.lastY = y; + _this.buttonDown = false; + } + }, true); + element.addEventListener("touchstart", function (ev) { + if (_this.currTouch != null) + return; + var touches = ev.changedTouches; + for (var i = 0; i < touches.length; i++) { + var touch = touches[i]; + var rect = element.getBoundingClientRect(); + var x = touch.clientX - rect.left; + var y = touch.clientY - rect.top; + _this.currTouch = _this.touchesPool.obtain(); + _this.currTouch.identifier = touch.identifier; + _this.currTouch.x = x; + _this.currTouch.y = y; + break; + } + var listeners = _this.listeners; + for (var i_8 = 0; i_8 < listeners.length; i_8++) { + listeners[i_8].down(_this.currTouch.x, _this.currTouch.y); + } + console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y); + _this.lastX = _this.currTouch.x; + _this.lastY = _this.currTouch.y; + _this.buttonDown = true; + ev.preventDefault(); + }, false); + element.addEventListener("touchend", function (ev) { + var touches = ev.changedTouches; + for (var i = 0; i < touches.length; i++) { + var touch = touches[i]; + if (_this.currTouch.identifier === touch.identifier) { + var rect = element.getBoundingClientRect(); + var x = _this.currTouch.x = touch.clientX - rect.left; + var y = _this.currTouch.y = touch.clientY - rect.top; + _this.touchesPool.free(_this.currTouch); + var listeners = _this.listeners; + for (var i_9 = 0; i_9 < listeners.length; i_9++) { + listeners[i_9].up(x, y); + } + console.log("End " + x + ", " + y); + _this.lastX = x; + _this.lastY = y; + _this.buttonDown = false; + _this.currTouch = null; + break; + } + } + ev.preventDefault(); + }, false); + element.addEventListener("touchcancel", function (ev) { + var touches = ev.changedTouches; + for (var i = 0; i < touches.length; i++) { + var touch = touches[i]; + if (_this.currTouch.identifier === touch.identifier) { + var rect = element.getBoundingClientRect(); + var x = _this.currTouch.x = touch.clientX - rect.left; + var y = _this.currTouch.y = touch.clientY - rect.top; + _this.touchesPool.free(_this.currTouch); + var listeners = _this.listeners; + for (var i_10 = 0; i_10 < listeners.length; i_10++) { + listeners[i_10].up(x, y); + } + console.log("End " + x + ", " + y); + _this.lastX = x; + _this.lastY = y; + _this.buttonDown = false; + _this.currTouch = null; + break; + } + } + ev.preventDefault(); + }, false); + element.addEventListener("touchmove", function (ev) { + if (_this.currTouch == null) + return; + var touches = ev.changedTouches; + for (var i = 0; i < touches.length; i++) { + var touch = touches[i]; + if (_this.currTouch.identifier === touch.identifier) { + var rect = element.getBoundingClientRect(); + var x = touch.clientX - rect.left; + var y = touch.clientY - rect.top; + var listeners = _this.listeners; + for (var i_11 = 0; i_11 < listeners.length; i_11++) { + listeners[i_11].dragged(x, y); + } + console.log("Drag " + x + ", " + y); + _this.lastX = _this.currTouch.x = x; + _this.lastY = _this.currTouch.y = y; + break; + } + } + ev.preventDefault(); + }, false); + }; + Input.prototype.addListener = function (listener) { + this.listeners.push(listener); + }; + Input.prototype.removeListener = function (listener) { + var idx = this.listeners.indexOf(listener); + if (idx > -1) { + this.listeners.splice(idx, 1); + } + }; + return Input; + }()); + webgl.Input = Input; + var Touch = (function () { + function Touch(identifier, x, y) { + this.identifier = identifier; + this.x = x; + this.y = y; + } + return Touch; + }()); + webgl.Touch = Touch; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var LoadingScreen = (function () { + function LoadingScreen(renderer) { + this.logo = null; + this.spinner = null; + this.angle = 0; + this.fadeOut = 0; + this.timeKeeper = new spine.TimeKeeper(); + this.backgroundColor = new spine.Color(0.135, 0.135, 0.135, 1); + this.tempColor = new spine.Color(); + this.firstDraw = 0; + this.renderer = renderer; + this.timeKeeper.maxDelta = 9; + if (LoadingScreen.logoImg === null) { + var isSafari = navigator.userAgent.indexOf("Safari") > -1; + LoadingScreen.logoImg = new Image(); + LoadingScreen.logoImg.src = LoadingScreen.SPINE_LOGO_DATA; + if (!isSafari) + LoadingScreen.logoImg.crossOrigin = "anonymous"; + LoadingScreen.logoImg.onload = function (ev) { + LoadingScreen.loaded++; + }; + LoadingScreen.spinnerImg = new Image(); + LoadingScreen.spinnerImg.src = LoadingScreen.SPINNER_DATA; + if (!isSafari) + LoadingScreen.spinnerImg.crossOrigin = "anonymous"; + LoadingScreen.spinnerImg.onload = function (ev) { + LoadingScreen.loaded++; + }; + } + } + LoadingScreen.prototype.draw = function (complete) { + if (complete === void 0) { complete = false; } + if (complete && this.fadeOut > LoadingScreen.FADE_SECONDS) + return; + this.timeKeeper.update(); + var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75)); + this.angle -= this.timeKeeper.delta * 360 * (1 + 1.5 * Math.pow(a, 5)); + var renderer = this.renderer; + var canvas = renderer.canvas; + var gl = renderer.context.gl; + var oldX = renderer.camera.position.x, oldY = renderer.camera.position.y; + renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0); + renderer.camera.viewportWidth = canvas.width; + renderer.camera.viewportHeight = canvas.height; + renderer.resize(webgl.ResizeMode.Stretch); + if (!complete) { + gl.clearColor(this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a); + gl.clear(gl.COLOR_BUFFER_BIT); + this.tempColor.a = 1; + } + else { + this.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1); + if (this.fadeOut > LoadingScreen.FADE_SECONDS) { + renderer.camera.position.set(oldX, oldY, 0); + return; + } + a = 1 - this.fadeOut / LoadingScreen.FADE_SECONDS; + this.tempColor.setFromColor(this.backgroundColor); + this.tempColor.a = 1 - (a - 1) * (a - 1); + renderer.begin(); + renderer.quad(true, 0, 0, canvas.width, 0, canvas.width, canvas.height, 0, canvas.height, this.tempColor, this.tempColor, this.tempColor, this.tempColor); + renderer.end(); + } + this.tempColor.set(1, 1, 1, this.tempColor.a); + if (LoadingScreen.loaded != 2) + return; + if (this.logo === null) { + this.logo = new webgl.GLTexture(renderer.context, LoadingScreen.logoImg); + this.spinner = new webgl.GLTexture(renderer.context, LoadingScreen.spinnerImg); + } + this.logo.update(false); + this.spinner.update(false); + var logoWidth = this.logo.getImage().width; + var logoHeight = this.logo.getImage().height; + var spinnerWidth = this.spinner.getImage().width; + var spinnerHeight = this.spinner.getImage().height; + renderer.batcher.setBlendMode(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); + renderer.begin(); + renderer.drawTexture(this.logo, (canvas.width - logoWidth) / 2, (canvas.height - logoHeight) / 2, logoWidth, logoHeight, this.tempColor); + renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerWidth) / 2, (canvas.height - spinnerHeight) / 2, spinnerWidth, spinnerHeight, spinnerWidth / 2, spinnerHeight / 2, this.angle, this.tempColor); + renderer.end(); + renderer.camera.position.set(oldX, oldY, 0); + }; + LoadingScreen.FADE_SECONDS = 1; + LoadingScreen.loaded = 0; + LoadingScreen.spinnerImg = null; + LoadingScreen.logoImg = null; + LoadingScreen.SPINNER_DATA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAChCAMAAAB3TUS6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAYNQTFRFAAAA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AAkTDRyAAAAIB0Uk5TAAABAgMEBQYHCAkKCwwODxAREhMUFRYXGBkaHB0eICEiIyQlJicoKSorLC0uLzAxMjM0Nzg5Ojs8PT4/QEFDRUlKS0xNTk9QUlRWWFlbXF1eYWJjZmhscHF0d3h5e3x+f4CIiYuMj5GSlJWXm56io6arr7rAxcjO0dXe6Onr8fmb5sOOAAADuElEQVQYGe3B+3vTVBwH4M/3nCRt13br2Lozhug2q25gYQubcxqVKYoMCYoKjEsUdSpeiBc0Kl7yp9t2za39pely7PF5zvuiQKc+/e2f8K+f9g2oyQ77Ag4VGX+HketQ0XYYe0JQ0CdhogwF+WFiBgr6JkxUoKCDMMGgoP0w9gdUtB3GfoCKVsPYAVQ0H8YuQUWVMHYGKuJhrAklPQkjJpT0bdj3O9S0FfZ9ADXxP8MjVSiqFfa8B2VVV8+df14QtB4iwn+BpuZEgyM38WMQHDYhnbkgukrIh5ygZ48glyn6KshlL+jbhVRcxCzk0ApiC5CI5kVsgTAy9jiI/WxBGmqIFBMjqwYphwRZaiLNwsjqQdoVSFISGRwjM4OMFUjBRcYCYWT0XZD2SwUS0LzIKCGH2SDja0LxKiJjCrm0gowVFI6aIs1CTouPg5QvUTgSKXMMuVUeBSmEopFITBPGwO8HCYbCTYtImTAWejuI3CMUjmZFT5NjbM/9GvQcMkhADdFRIxxD7aug4wGDFGSVTcLx0MzutQ2CpmmapmmapmmapmmapmmaphWBmGFV6rNNcaLC0GUuv3LROftUo8wJk0a10207sVED6IIf+9673LIwQeW2PaCEJX/A+xYmhTbtQUu46g96SJgQZg9Zwxf+EAMTwuwhm3jkD7EwIdweBn+YhQlh9pA2HvpDTEwIs4es4GN/CMekNOxBJ9D2B10nTAyfW7fT1hjYgZ/xYIUwUcycaiwuv2h3tOcZADr7ud/12c0ru2cWSwQ1UAcixIgImqZpmqZpmqZpmqZpmqZp2v8HMSIcF186t8oghbnlOJt1wnHwl7yOGxwSlHacrjWG8dVuej03OApn7jhHtiyMiZa9yD6haLYTebWOsbDXvQRHwchJWSTkV/rQS+EoWttJaTHkJe56KXcJRZt20jY48nnBy9hE4WjLSbvAkIfwMm5zFG/KyWgRRke3vYwGZDjpZHCMruJltCAFrTtpVYxu1ktzCHKwbSdlGqOreynXGGQpOylljI5uebFbBuSZc2IbhBxmvcj9GiSiZ52+HQO5nPb6TkIqajs9L5eQk7jnddxZgGT0jNOxYSI36+Kdj9oG5OPV6QpB6yJuGAYnqIrecLveYlDUKffIOtREl90+BiWV3cgMlNR0I09DSS030oaSttzILpT0phu5BBWRmyAoiLkJgoIMN8GgoJKb4FBQzU0YUFDdTRhQUNVNcCjIdBMEBdE7buQ8lFRz+97lUFN5fe+qu//aMkeB/gU2ae9y2HgbngAAAABJRU5ErkJggg=="; + LoadingScreen.SPINE_LOGO_DATA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFIAAAAZCAYAAACis3k0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtNJREFUaN7tmT2I1EAUxwN+oWgRT0HFKo0WCkJ6ObmAWFwZbCxsXGysLNJaiCyIoDaSwk4ETzvhmnBaCRbBWoQ01ho4PwotjP8cE337mMy8TLK757mBH3fLTWbe/PbN53neNniqZW8FvAVvQAqugwvgDDgO9niLRyTyJagM/ACPF6bsIl9ZRDac/Cc6tLn5xQdRQ496QlKPLxD5QCDxO9jtGM8QfYoIgUlgCipGCRJL5VvlyOdCU09iEXkCfLSIfCrs7Fab6nOsiafu06iDwES9w/uU1QnDC+ekkVS9vEaDsgVeB0d+z1VDtOGxRaYPboP3Gokb4GgXkZp4chZPJKgvZ3U0XkriK/TIt9YUDllFgTAjGwoaoHqfBhMI58yD4BQ4V6/aHYdfxToftvw9F2SiVroawU2/Cv5C4Thv0KB9S5nxlOd4STxjwUjzSdYlgrYijw2BsEfgsaFcM09lhiys94xXQQwugcvgJrgFLjrEE7WUiTuWCQzt/ZXN7FfqGwuGClyVy2xZAFmfDQvNtwFFSspMDGsD+UTWqu1KoVmVooFEJgKRXw0if85RpISEzwsjzeqWzkjkC4PIJ3MUmQgITAHlQwTFhnZhELkEntfZRwR+AvfAgXmJHOqU02XligWT8ppg67NXbdCXeq7afUQ6L8C2DalEZNt2YyQ94Qy8/ekjMpBMbfyl5iTjG7YAI8cNecROAb4kJmTjaXAF3AGvwQewOiuRxEtlSaT4j2h2lMsUueQEoMlIKpTvAmKhxPMtC876jEX6rE8l8TNx/KVbn6xlWU9NWcSDUsO4NGWpQOTZFpHPOooMXcswmW2XFk3ixb2v0Nq+XVKP00QNaffBLyWwBI/AkTlfMYZDXMf12kc6yjwEjoFdO/5me5oi/6tnyhlZX6OtgmX1c2Uh0k3khmbB2b9TRfpd/jfTUeRDJvHdYg5wE7kPXAN3wQ1weDvH+xufEgpi5qIl3QAAAABJRU5ErkJggg=="; + return LoadingScreen; + }()); + webgl.LoadingScreen = LoadingScreen; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + webgl.M00 = 0; + webgl.M01 = 4; + webgl.M02 = 8; + webgl.M03 = 12; + webgl.M10 = 1; + webgl.M11 = 5; + webgl.M12 = 9; + webgl.M13 = 13; + webgl.M20 = 2; + webgl.M21 = 6; + webgl.M22 = 10; + webgl.M23 = 14; + webgl.M30 = 3; + webgl.M31 = 7; + webgl.M32 = 11; + webgl.M33 = 15; + var Matrix4 = (function () { + function Matrix4() { + this.temp = new Float32Array(16); + this.values = new Float32Array(16); + var v = this.values; + v[webgl.M00] = 1; + v[webgl.M11] = 1; + v[webgl.M22] = 1; + v[webgl.M33] = 1; + } + Matrix4.prototype.set = function (values) { + this.values.set(values); + return this; + }; + Matrix4.prototype.transpose = function () { + var t = this.temp; + var v = this.values; + t[webgl.M00] = v[webgl.M00]; + t[webgl.M01] = v[webgl.M10]; + t[webgl.M02] = v[webgl.M20]; + t[webgl.M03] = v[webgl.M30]; + t[webgl.M10] = v[webgl.M01]; + t[webgl.M11] = v[webgl.M11]; + t[webgl.M12] = v[webgl.M21]; + t[webgl.M13] = v[webgl.M31]; + t[webgl.M20] = v[webgl.M02]; + t[webgl.M21] = v[webgl.M12]; + t[webgl.M22] = v[webgl.M22]; + t[webgl.M23] = v[webgl.M32]; + t[webgl.M30] = v[webgl.M03]; + t[webgl.M31] = v[webgl.M13]; + t[webgl.M32] = v[webgl.M23]; + t[webgl.M33] = v[webgl.M33]; + return this.set(t); + }; + Matrix4.prototype.identity = function () { + var v = this.values; + v[webgl.M00] = 1; + v[webgl.M01] = 0; + v[webgl.M02] = 0; + v[webgl.M03] = 0; + v[webgl.M10] = 0; + v[webgl.M11] = 1; + v[webgl.M12] = 0; + v[webgl.M13] = 0; + v[webgl.M20] = 0; + v[webgl.M21] = 0; + v[webgl.M22] = 1; + v[webgl.M23] = 0; + v[webgl.M30] = 0; + v[webgl.M31] = 0; + v[webgl.M32] = 0; + v[webgl.M33] = 1; + return this; + }; + Matrix4.prototype.invert = function () { + var v = this.values; + var t = this.temp; + var l_det = v[webgl.M30] * v[webgl.M21] * v[webgl.M12] * v[webgl.M03] - v[webgl.M20] * v[webgl.M31] * v[webgl.M12] * v[webgl.M03] - v[webgl.M30] * v[webgl.M11] * v[webgl.M22] * v[webgl.M03] + + v[webgl.M10] * v[webgl.M31] * v[webgl.M22] * v[webgl.M03] + v[webgl.M20] * v[webgl.M11] * v[webgl.M32] * v[webgl.M03] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32] * v[webgl.M03] + - v[webgl.M30] * v[webgl.M21] * v[webgl.M02] * v[webgl.M13] + v[webgl.M20] * v[webgl.M31] * v[webgl.M02] * v[webgl.M13] + v[webgl.M30] * v[webgl.M01] * v[webgl.M22] * v[webgl.M13] + - v[webgl.M00] * v[webgl.M31] * v[webgl.M22] * v[webgl.M13] - v[webgl.M20] * v[webgl.M01] * v[webgl.M32] * v[webgl.M13] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32] * v[webgl.M13] + + v[webgl.M30] * v[webgl.M11] * v[webgl.M02] * v[webgl.M23] - v[webgl.M10] * v[webgl.M31] * v[webgl.M02] * v[webgl.M23] - v[webgl.M30] * v[webgl.M01] * v[webgl.M12] * v[webgl.M23] + + v[webgl.M00] * v[webgl.M31] * v[webgl.M12] * v[webgl.M23] + v[webgl.M10] * v[webgl.M01] * v[webgl.M32] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32] * v[webgl.M23] + - v[webgl.M20] * v[webgl.M11] * v[webgl.M02] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M02] * v[webgl.M33] + v[webgl.M20] * v[webgl.M01] * v[webgl.M12] * v[webgl.M33] + - v[webgl.M00] * v[webgl.M21] * v[webgl.M12] * v[webgl.M33] - v[webgl.M10] * v[webgl.M01] * v[webgl.M22] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22] * v[webgl.M33]; + if (l_det == 0) + throw new Error("non-invertible matrix"); + var inv_det = 1.0 / l_det; + t[webgl.M00] = v[webgl.M12] * v[webgl.M23] * v[webgl.M31] - v[webgl.M13] * v[webgl.M22] * v[webgl.M31] + v[webgl.M13] * v[webgl.M21] * v[webgl.M32] + - v[webgl.M11] * v[webgl.M23] * v[webgl.M32] - v[webgl.M12] * v[webgl.M21] * v[webgl.M33] + v[webgl.M11] * v[webgl.M22] * v[webgl.M33]; + t[webgl.M01] = v[webgl.M03] * v[webgl.M22] * v[webgl.M31] - v[webgl.M02] * v[webgl.M23] * v[webgl.M31] - v[webgl.M03] * v[webgl.M21] * v[webgl.M32] + + v[webgl.M01] * v[webgl.M23] * v[webgl.M32] + v[webgl.M02] * v[webgl.M21] * v[webgl.M33] - v[webgl.M01] * v[webgl.M22] * v[webgl.M33]; + t[webgl.M02] = v[webgl.M02] * v[webgl.M13] * v[webgl.M31] - v[webgl.M03] * v[webgl.M12] * v[webgl.M31] + v[webgl.M03] * v[webgl.M11] * v[webgl.M32] + - v[webgl.M01] * v[webgl.M13] * v[webgl.M32] - v[webgl.M02] * v[webgl.M11] * v[webgl.M33] + v[webgl.M01] * v[webgl.M12] * v[webgl.M33]; + t[webgl.M03] = v[webgl.M03] * v[webgl.M12] * v[webgl.M21] - v[webgl.M02] * v[webgl.M13] * v[webgl.M21] - v[webgl.M03] * v[webgl.M11] * v[webgl.M22] + + v[webgl.M01] * v[webgl.M13] * v[webgl.M22] + v[webgl.M02] * v[webgl.M11] * v[webgl.M23] - v[webgl.M01] * v[webgl.M12] * v[webgl.M23]; + t[webgl.M10] = v[webgl.M13] * v[webgl.M22] * v[webgl.M30] - v[webgl.M12] * v[webgl.M23] * v[webgl.M30] - v[webgl.M13] * v[webgl.M20] * v[webgl.M32] + + v[webgl.M10] * v[webgl.M23] * v[webgl.M32] + v[webgl.M12] * v[webgl.M20] * v[webgl.M33] - v[webgl.M10] * v[webgl.M22] * v[webgl.M33]; + t[webgl.M11] = v[webgl.M02] * v[webgl.M23] * v[webgl.M30] - v[webgl.M03] * v[webgl.M22] * v[webgl.M30] + v[webgl.M03] * v[webgl.M20] * v[webgl.M32] + - v[webgl.M00] * v[webgl.M23] * v[webgl.M32] - v[webgl.M02] * v[webgl.M20] * v[webgl.M33] + v[webgl.M00] * v[webgl.M22] * v[webgl.M33]; + t[webgl.M12] = v[webgl.M03] * v[webgl.M12] * v[webgl.M30] - v[webgl.M02] * v[webgl.M13] * v[webgl.M30] - v[webgl.M03] * v[webgl.M10] * v[webgl.M32] + + v[webgl.M00] * v[webgl.M13] * v[webgl.M32] + v[webgl.M02] * v[webgl.M10] * v[webgl.M33] - v[webgl.M00] * v[webgl.M12] * v[webgl.M33]; + t[webgl.M13] = v[webgl.M02] * v[webgl.M13] * v[webgl.M20] - v[webgl.M03] * v[webgl.M12] * v[webgl.M20] + v[webgl.M03] * v[webgl.M10] * v[webgl.M22] + - v[webgl.M00] * v[webgl.M13] * v[webgl.M22] - v[webgl.M02] * v[webgl.M10] * v[webgl.M23] + v[webgl.M00] * v[webgl.M12] * v[webgl.M23]; + t[webgl.M20] = v[webgl.M11] * v[webgl.M23] * v[webgl.M30] - v[webgl.M13] * v[webgl.M21] * v[webgl.M30] + v[webgl.M13] * v[webgl.M20] * v[webgl.M31] + - v[webgl.M10] * v[webgl.M23] * v[webgl.M31] - v[webgl.M11] * v[webgl.M20] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M33]; + t[webgl.M21] = v[webgl.M03] * v[webgl.M21] * v[webgl.M30] - v[webgl.M01] * v[webgl.M23] * v[webgl.M30] - v[webgl.M03] * v[webgl.M20] * v[webgl.M31] + + v[webgl.M00] * v[webgl.M23] * v[webgl.M31] + v[webgl.M01] * v[webgl.M20] * v[webgl.M33] - v[webgl.M00] * v[webgl.M21] * v[webgl.M33]; + t[webgl.M22] = v[webgl.M01] * v[webgl.M13] * v[webgl.M30] - v[webgl.M03] * v[webgl.M11] * v[webgl.M30] + v[webgl.M03] * v[webgl.M10] * v[webgl.M31] + - v[webgl.M00] * v[webgl.M13] * v[webgl.M31] - v[webgl.M01] * v[webgl.M10] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M33]; + t[webgl.M23] = v[webgl.M03] * v[webgl.M11] * v[webgl.M20] - v[webgl.M01] * v[webgl.M13] * v[webgl.M20] - v[webgl.M03] * v[webgl.M10] * v[webgl.M21] + + v[webgl.M00] * v[webgl.M13] * v[webgl.M21] + v[webgl.M01] * v[webgl.M10] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M23]; + t[webgl.M30] = v[webgl.M12] * v[webgl.M21] * v[webgl.M30] - v[webgl.M11] * v[webgl.M22] * v[webgl.M30] - v[webgl.M12] * v[webgl.M20] * v[webgl.M31] + + v[webgl.M10] * v[webgl.M22] * v[webgl.M31] + v[webgl.M11] * v[webgl.M20] * v[webgl.M32] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32]; + t[webgl.M31] = v[webgl.M01] * v[webgl.M22] * v[webgl.M30] - v[webgl.M02] * v[webgl.M21] * v[webgl.M30] + v[webgl.M02] * v[webgl.M20] * v[webgl.M31] + - v[webgl.M00] * v[webgl.M22] * v[webgl.M31] - v[webgl.M01] * v[webgl.M20] * v[webgl.M32] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32]; + t[webgl.M32] = v[webgl.M02] * v[webgl.M11] * v[webgl.M30] - v[webgl.M01] * v[webgl.M12] * v[webgl.M30] - v[webgl.M02] * v[webgl.M10] * v[webgl.M31] + + v[webgl.M00] * v[webgl.M12] * v[webgl.M31] + v[webgl.M01] * v[webgl.M10] * v[webgl.M32] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32]; + t[webgl.M33] = v[webgl.M01] * v[webgl.M12] * v[webgl.M20] - v[webgl.M02] * v[webgl.M11] * v[webgl.M20] + v[webgl.M02] * v[webgl.M10] * v[webgl.M21] + - v[webgl.M00] * v[webgl.M12] * v[webgl.M21] - v[webgl.M01] * v[webgl.M10] * v[webgl.M22] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22]; + v[webgl.M00] = t[webgl.M00] * inv_det; + v[webgl.M01] = t[webgl.M01] * inv_det; + v[webgl.M02] = t[webgl.M02] * inv_det; + v[webgl.M03] = t[webgl.M03] * inv_det; + v[webgl.M10] = t[webgl.M10] * inv_det; + v[webgl.M11] = t[webgl.M11] * inv_det; + v[webgl.M12] = t[webgl.M12] * inv_det; + v[webgl.M13] = t[webgl.M13] * inv_det; + v[webgl.M20] = t[webgl.M20] * inv_det; + v[webgl.M21] = t[webgl.M21] * inv_det; + v[webgl.M22] = t[webgl.M22] * inv_det; + v[webgl.M23] = t[webgl.M23] * inv_det; + v[webgl.M30] = t[webgl.M30] * inv_det; + v[webgl.M31] = t[webgl.M31] * inv_det; + v[webgl.M32] = t[webgl.M32] * inv_det; + v[webgl.M33] = t[webgl.M33] * inv_det; + return this; + }; + Matrix4.prototype.determinant = function () { + var v = this.values; + return v[webgl.M30] * v[webgl.M21] * v[webgl.M12] * v[webgl.M03] - v[webgl.M20] * v[webgl.M31] * v[webgl.M12] * v[webgl.M03] - v[webgl.M30] * v[webgl.M11] * v[webgl.M22] * v[webgl.M03] + + v[webgl.M10] * v[webgl.M31] * v[webgl.M22] * v[webgl.M03] + v[webgl.M20] * v[webgl.M11] * v[webgl.M32] * v[webgl.M03] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32] * v[webgl.M03] + - v[webgl.M30] * v[webgl.M21] * v[webgl.M02] * v[webgl.M13] + v[webgl.M20] * v[webgl.M31] * v[webgl.M02] * v[webgl.M13] + v[webgl.M30] * v[webgl.M01] * v[webgl.M22] * v[webgl.M13] + - v[webgl.M00] * v[webgl.M31] * v[webgl.M22] * v[webgl.M13] - v[webgl.M20] * v[webgl.M01] * v[webgl.M32] * v[webgl.M13] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32] * v[webgl.M13] + + v[webgl.M30] * v[webgl.M11] * v[webgl.M02] * v[webgl.M23] - v[webgl.M10] * v[webgl.M31] * v[webgl.M02] * v[webgl.M23] - v[webgl.M30] * v[webgl.M01] * v[webgl.M12] * v[webgl.M23] + + v[webgl.M00] * v[webgl.M31] * v[webgl.M12] * v[webgl.M23] + v[webgl.M10] * v[webgl.M01] * v[webgl.M32] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32] * v[webgl.M23] + - v[webgl.M20] * v[webgl.M11] * v[webgl.M02] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M02] * v[webgl.M33] + v[webgl.M20] * v[webgl.M01] * v[webgl.M12] * v[webgl.M33] + - v[webgl.M00] * v[webgl.M21] * v[webgl.M12] * v[webgl.M33] - v[webgl.M10] * v[webgl.M01] * v[webgl.M22] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22] * v[webgl.M33]; + }; + Matrix4.prototype.translate = function (x, y, z) { + var v = this.values; + v[webgl.M03] += x; + v[webgl.M13] += y; + v[webgl.M23] += z; + return this; + }; + Matrix4.prototype.copy = function () { + return new Matrix4().set(this.values); + }; + Matrix4.prototype.projection = function (near, far, fovy, aspectRatio) { + this.identity(); + var l_fd = (1.0 / Math.tan((fovy * (Math.PI / 180)) / 2.0)); + var l_a1 = (far + near) / (near - far); + var l_a2 = (2 * far * near) / (near - far); + var v = this.values; + v[webgl.M00] = l_fd / aspectRatio; + v[webgl.M10] = 0; + v[webgl.M20] = 0; + v[webgl.M30] = 0; + v[webgl.M01] = 0; + v[webgl.M11] = l_fd; + v[webgl.M21] = 0; + v[webgl.M31] = 0; + v[webgl.M02] = 0; + v[webgl.M12] = 0; + v[webgl.M22] = l_a1; + v[webgl.M32] = -1; + v[webgl.M03] = 0; + v[webgl.M13] = 0; + v[webgl.M23] = l_a2; + v[webgl.M33] = 0; + return this; + }; + Matrix4.prototype.ortho2d = function (x, y, width, height) { + return this.ortho(x, x + width, y, y + height, 0, 1); + }; + Matrix4.prototype.ortho = function (left, right, bottom, top, near, far) { + this.identity(); + var x_orth = 2 / (right - left); + var y_orth = 2 / (top - bottom); + var z_orth = -2 / (far - near); + var tx = -(right + left) / (right - left); + var ty = -(top + bottom) / (top - bottom); + var tz = -(far + near) / (far - near); + var v = this.values; + v[webgl.M00] = x_orth; + v[webgl.M10] = 0; + v[webgl.M20] = 0; + v[webgl.M30] = 0; + v[webgl.M01] = 0; + v[webgl.M11] = y_orth; + v[webgl.M21] = 0; + v[webgl.M31] = 0; + v[webgl.M02] = 0; + v[webgl.M12] = 0; + v[webgl.M22] = z_orth; + v[webgl.M32] = 0; + v[webgl.M03] = tx; + v[webgl.M13] = ty; + v[webgl.M23] = tz; + v[webgl.M33] = 1; + return this; + }; + Matrix4.prototype.multiply = function (matrix) { + var t = this.temp; + var v = this.values; + var m = matrix.values; + t[webgl.M00] = v[webgl.M00] * m[webgl.M00] + v[webgl.M01] * m[webgl.M10] + v[webgl.M02] * m[webgl.M20] + v[webgl.M03] * m[webgl.M30]; + t[webgl.M01] = v[webgl.M00] * m[webgl.M01] + v[webgl.M01] * m[webgl.M11] + v[webgl.M02] * m[webgl.M21] + v[webgl.M03] * m[webgl.M31]; + t[webgl.M02] = v[webgl.M00] * m[webgl.M02] + v[webgl.M01] * m[webgl.M12] + v[webgl.M02] * m[webgl.M22] + v[webgl.M03] * m[webgl.M32]; + t[webgl.M03] = v[webgl.M00] * m[webgl.M03] + v[webgl.M01] * m[webgl.M13] + v[webgl.M02] * m[webgl.M23] + v[webgl.M03] * m[webgl.M33]; + t[webgl.M10] = v[webgl.M10] * m[webgl.M00] + v[webgl.M11] * m[webgl.M10] + v[webgl.M12] * m[webgl.M20] + v[webgl.M13] * m[webgl.M30]; + t[webgl.M11] = v[webgl.M10] * m[webgl.M01] + v[webgl.M11] * m[webgl.M11] + v[webgl.M12] * m[webgl.M21] + v[webgl.M13] * m[webgl.M31]; + t[webgl.M12] = v[webgl.M10] * m[webgl.M02] + v[webgl.M11] * m[webgl.M12] + v[webgl.M12] * m[webgl.M22] + v[webgl.M13] * m[webgl.M32]; + t[webgl.M13] = v[webgl.M10] * m[webgl.M03] + v[webgl.M11] * m[webgl.M13] + v[webgl.M12] * m[webgl.M23] + v[webgl.M13] * m[webgl.M33]; + t[webgl.M20] = v[webgl.M20] * m[webgl.M00] + v[webgl.M21] * m[webgl.M10] + v[webgl.M22] * m[webgl.M20] + v[webgl.M23] * m[webgl.M30]; + t[webgl.M21] = v[webgl.M20] * m[webgl.M01] + v[webgl.M21] * m[webgl.M11] + v[webgl.M22] * m[webgl.M21] + v[webgl.M23] * m[webgl.M31]; + t[webgl.M22] = v[webgl.M20] * m[webgl.M02] + v[webgl.M21] * m[webgl.M12] + v[webgl.M22] * m[webgl.M22] + v[webgl.M23] * m[webgl.M32]; + t[webgl.M23] = v[webgl.M20] * m[webgl.M03] + v[webgl.M21] * m[webgl.M13] + v[webgl.M22] * m[webgl.M23] + v[webgl.M23] * m[webgl.M33]; + t[webgl.M30] = v[webgl.M30] * m[webgl.M00] + v[webgl.M31] * m[webgl.M10] + v[webgl.M32] * m[webgl.M20] + v[webgl.M33] * m[webgl.M30]; + t[webgl.M31] = v[webgl.M30] * m[webgl.M01] + v[webgl.M31] * m[webgl.M11] + v[webgl.M32] * m[webgl.M21] + v[webgl.M33] * m[webgl.M31]; + t[webgl.M32] = v[webgl.M30] * m[webgl.M02] + v[webgl.M31] * m[webgl.M12] + v[webgl.M32] * m[webgl.M22] + v[webgl.M33] * m[webgl.M32]; + t[webgl.M33] = v[webgl.M30] * m[webgl.M03] + v[webgl.M31] * m[webgl.M13] + v[webgl.M32] * m[webgl.M23] + v[webgl.M33] * m[webgl.M33]; + return this.set(this.temp); + }; + Matrix4.prototype.multiplyLeft = function (matrix) { + var t = this.temp; + var v = this.values; + var m = matrix.values; + t[webgl.M00] = m[webgl.M00] * v[webgl.M00] + m[webgl.M01] * v[webgl.M10] + m[webgl.M02] * v[webgl.M20] + m[webgl.M03] * v[webgl.M30]; + t[webgl.M01] = m[webgl.M00] * v[webgl.M01] + m[webgl.M01] * v[webgl.M11] + m[webgl.M02] * v[webgl.M21] + m[webgl.M03] * v[webgl.M31]; + t[webgl.M02] = m[webgl.M00] * v[webgl.M02] + m[webgl.M01] * v[webgl.M12] + m[webgl.M02] * v[webgl.M22] + m[webgl.M03] * v[webgl.M32]; + t[webgl.M03] = m[webgl.M00] * v[webgl.M03] + m[webgl.M01] * v[webgl.M13] + m[webgl.M02] * v[webgl.M23] + m[webgl.M03] * v[webgl.M33]; + t[webgl.M10] = m[webgl.M10] * v[webgl.M00] + m[webgl.M11] * v[webgl.M10] + m[webgl.M12] * v[webgl.M20] + m[webgl.M13] * v[webgl.M30]; + t[webgl.M11] = m[webgl.M10] * v[webgl.M01] + m[webgl.M11] * v[webgl.M11] + m[webgl.M12] * v[webgl.M21] + m[webgl.M13] * v[webgl.M31]; + t[webgl.M12] = m[webgl.M10] * v[webgl.M02] + m[webgl.M11] * v[webgl.M12] + m[webgl.M12] * v[webgl.M22] + m[webgl.M13] * v[webgl.M32]; + t[webgl.M13] = m[webgl.M10] * v[webgl.M03] + m[webgl.M11] * v[webgl.M13] + m[webgl.M12] * v[webgl.M23] + m[webgl.M13] * v[webgl.M33]; + t[webgl.M20] = m[webgl.M20] * v[webgl.M00] + m[webgl.M21] * v[webgl.M10] + m[webgl.M22] * v[webgl.M20] + m[webgl.M23] * v[webgl.M30]; + t[webgl.M21] = m[webgl.M20] * v[webgl.M01] + m[webgl.M21] * v[webgl.M11] + m[webgl.M22] * v[webgl.M21] + m[webgl.M23] * v[webgl.M31]; + t[webgl.M22] = m[webgl.M20] * v[webgl.M02] + m[webgl.M21] * v[webgl.M12] + m[webgl.M22] * v[webgl.M22] + m[webgl.M23] * v[webgl.M32]; + t[webgl.M23] = m[webgl.M20] * v[webgl.M03] + m[webgl.M21] * v[webgl.M13] + m[webgl.M22] * v[webgl.M23] + m[webgl.M23] * v[webgl.M33]; + t[webgl.M30] = m[webgl.M30] * v[webgl.M00] + m[webgl.M31] * v[webgl.M10] + m[webgl.M32] * v[webgl.M20] + m[webgl.M33] * v[webgl.M30]; + t[webgl.M31] = m[webgl.M30] * v[webgl.M01] + m[webgl.M31] * v[webgl.M11] + m[webgl.M32] * v[webgl.M21] + m[webgl.M33] * v[webgl.M31]; + t[webgl.M32] = m[webgl.M30] * v[webgl.M02] + m[webgl.M31] * v[webgl.M12] + m[webgl.M32] * v[webgl.M22] + m[webgl.M33] * v[webgl.M32]; + t[webgl.M33] = m[webgl.M30] * v[webgl.M03] + m[webgl.M31] * v[webgl.M13] + m[webgl.M32] * v[webgl.M23] + m[webgl.M33] * v[webgl.M33]; + return this.set(this.temp); + }; + Matrix4.prototype.lookAt = function (position, direction, up) { + Matrix4.initTemps(); + var xAxis = Matrix4.xAxis, yAxis = Matrix4.yAxis, zAxis = Matrix4.zAxis; + zAxis.setFrom(direction).normalize(); + xAxis.setFrom(direction).normalize(); + xAxis.cross(up).normalize(); + yAxis.setFrom(xAxis).cross(zAxis).normalize(); + this.identity(); + var val = this.values; + val[webgl.M00] = xAxis.x; + val[webgl.M01] = xAxis.y; + val[webgl.M02] = xAxis.z; + val[webgl.M10] = yAxis.x; + val[webgl.M11] = yAxis.y; + val[webgl.M12] = yAxis.z; + val[webgl.M20] = -zAxis.x; + val[webgl.M21] = -zAxis.y; + val[webgl.M22] = -zAxis.z; + Matrix4.tmpMatrix.identity(); + Matrix4.tmpMatrix.values[webgl.M03] = -position.x; + Matrix4.tmpMatrix.values[webgl.M13] = -position.y; + Matrix4.tmpMatrix.values[webgl.M23] = -position.z; + this.multiply(Matrix4.tmpMatrix); + return this; + }; + Matrix4.initTemps = function () { + if (Matrix4.xAxis === null) + Matrix4.xAxis = new webgl.Vector3(); + if (Matrix4.yAxis === null) + Matrix4.yAxis = new webgl.Vector3(); + if (Matrix4.zAxis === null) + Matrix4.zAxis = new webgl.Vector3(); + }; + Matrix4.xAxis = null; + Matrix4.yAxis = null; + Matrix4.zAxis = null; + Matrix4.tmpMatrix = new Matrix4(); + return Matrix4; + }()); + webgl.Matrix4 = Matrix4; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Mesh = (function () { + function Mesh(context, attributes, maxVertices, maxIndices) { + this.attributes = attributes; + this.verticesLength = 0; + this.dirtyVertices = false; + this.indicesLength = 0; + this.dirtyIndices = false; + this.elementsPerVertex = 0; + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + this.elementsPerVertex = 0; + for (var i = 0; i < attributes.length; i++) { + this.elementsPerVertex += attributes[i].numElements; + } + this.vertices = new Float32Array(maxVertices * this.elementsPerVertex); + this.indices = new Uint16Array(maxIndices); + this.context.addRestorable(this); + } + Mesh.prototype.getAttributes = function () { return this.attributes; }; + Mesh.prototype.maxVertices = function () { return this.vertices.length / this.elementsPerVertex; }; + Mesh.prototype.numVertices = function () { return this.verticesLength / this.elementsPerVertex; }; + Mesh.prototype.setVerticesLength = function (length) { + this.dirtyVertices = true; + this.verticesLength = length; + }; + Mesh.prototype.getVertices = function () { return this.vertices; }; + Mesh.prototype.maxIndices = function () { return this.indices.length; }; + Mesh.prototype.numIndices = function () { return this.indicesLength; }; + Mesh.prototype.setIndicesLength = function (length) { + this.dirtyIndices = true; + this.indicesLength = length; + }; + Mesh.prototype.getIndices = function () { return this.indices; }; + ; + Mesh.prototype.getVertexSizeInFloats = function () { + var size = 0; + for (var i = 0; i < this.attributes.length; i++) { + var attribute = this.attributes[i]; + size += attribute.numElements; + } + return size; + }; + Mesh.prototype.setVertices = function (vertices) { + this.dirtyVertices = true; + if (vertices.length > this.vertices.length) + throw Error("Mesh can't store more than " + this.maxVertices() + " vertices"); + this.vertices.set(vertices, 0); + this.verticesLength = vertices.length; + }; + Mesh.prototype.setIndices = function (indices) { + this.dirtyIndices = true; + if (indices.length > this.indices.length) + throw Error("Mesh can't store more than " + this.maxIndices() + " indices"); + this.indices.set(indices, 0); + this.indicesLength = indices.length; + }; + Mesh.prototype.draw = function (shader, primitiveType) { + this.drawWithOffset(shader, primitiveType, 0, this.indicesLength > 0 ? this.indicesLength : this.verticesLength / this.elementsPerVertex); + }; + Mesh.prototype.drawWithOffset = function (shader, primitiveType, offset, count) { + var gl = this.context.gl; + if (this.dirtyVertices || this.dirtyIndices) + this.update(); + this.bind(shader); + if (this.indicesLength > 0) { + gl.drawElements(primitiveType, count, gl.UNSIGNED_SHORT, offset * 2); + } + else { + gl.drawArrays(primitiveType, offset, count); + } + this.unbind(shader); + }; + Mesh.prototype.bind = function (shader) { + var gl = this.context.gl; + gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer); + var offset = 0; + for (var i = 0; i < this.attributes.length; i++) { + var attrib = this.attributes[i]; + var location_1 = shader.getAttributeLocation(attrib.name); + gl.enableVertexAttribArray(location_1); + gl.vertexAttribPointer(location_1, attrib.numElements, gl.FLOAT, false, this.elementsPerVertex * 4, offset * 4); + offset += attrib.numElements; + } + if (this.indicesLength > 0) + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer); + }; + Mesh.prototype.unbind = function (shader) { + var gl = this.context.gl; + for (var i = 0; i < this.attributes.length; i++) { + var attrib = this.attributes[i]; + var location_2 = shader.getAttributeLocation(attrib.name); + gl.disableVertexAttribArray(location_2); + } + gl.bindBuffer(gl.ARRAY_BUFFER, null); + if (this.indicesLength > 0) + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); + }; + Mesh.prototype.update = function () { + var gl = this.context.gl; + if (this.dirtyVertices) { + if (!this.verticesBuffer) { + this.verticesBuffer = gl.createBuffer(); + } + gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices.subarray(0, this.verticesLength), gl.DYNAMIC_DRAW); + this.dirtyVertices = false; + } + if (this.dirtyIndices) { + if (!this.indicesBuffer) { + this.indicesBuffer = gl.createBuffer(); + } + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices.subarray(0, this.indicesLength), gl.DYNAMIC_DRAW); + this.dirtyIndices = false; + } + }; + Mesh.prototype.restore = function () { + this.verticesBuffer = null; + this.indicesBuffer = null; + this.update(); + }; + Mesh.prototype.dispose = function () { + this.context.removeRestorable(this); + var gl = this.context.gl; + gl.deleteBuffer(this.verticesBuffer); + gl.deleteBuffer(this.indicesBuffer); + }; + return Mesh; + }()); + webgl.Mesh = Mesh; + var VertexAttribute = (function () { + function VertexAttribute(name, type, numElements) { + this.name = name; + this.type = type; + this.numElements = numElements; + } + return VertexAttribute; + }()); + webgl.VertexAttribute = VertexAttribute; + var Position2Attribute = (function (_super) { + __extends(Position2Attribute, _super); + function Position2Attribute() { + return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 2) || this; + } + return Position2Attribute; + }(VertexAttribute)); + webgl.Position2Attribute = Position2Attribute; + var Position3Attribute = (function (_super) { + __extends(Position3Attribute, _super); + function Position3Attribute() { + return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 3) || this; + } + return Position3Attribute; + }(VertexAttribute)); + webgl.Position3Attribute = Position3Attribute; + var TexCoordAttribute = (function (_super) { + __extends(TexCoordAttribute, _super); + function TexCoordAttribute(unit) { + if (unit === void 0) { unit = 0; } + return _super.call(this, webgl.Shader.TEXCOORDS + (unit == 0 ? "" : unit), VertexAttributeType.Float, 2) || this; + } + return TexCoordAttribute; + }(VertexAttribute)); + webgl.TexCoordAttribute = TexCoordAttribute; + var ColorAttribute = (function (_super) { + __extends(ColorAttribute, _super); + function ColorAttribute() { + return _super.call(this, webgl.Shader.COLOR, VertexAttributeType.Float, 4) || this; + } + return ColorAttribute; + }(VertexAttribute)); + webgl.ColorAttribute = ColorAttribute; + var Color2Attribute = (function (_super) { + __extends(Color2Attribute, _super); + function Color2Attribute() { + return _super.call(this, webgl.Shader.COLOR2, VertexAttributeType.Float, 4) || this; + } + return Color2Attribute; + }(VertexAttribute)); + webgl.Color2Attribute = Color2Attribute; + var VertexAttributeType; + (function (VertexAttributeType) { + VertexAttributeType[VertexAttributeType["Float"] = 0] = "Float"; + })(VertexAttributeType = webgl.VertexAttributeType || (webgl.VertexAttributeType = {})); + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var PolygonBatcher = (function () { + function PolygonBatcher(context, twoColorTint, maxVertices) { + if (twoColorTint === void 0) { twoColorTint = true; } + if (maxVertices === void 0) { maxVertices = 10920; } + this.isDrawing = false; + this.shader = null; + this.lastTexture = null; + this.verticesLength = 0; + this.indicesLength = 0; + if (maxVertices > 10920) + throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices); + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + var attributes = twoColorTint ? + [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute(), new webgl.Color2Attribute()] : + [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute()]; + this.mesh = new webgl.Mesh(context, attributes, maxVertices, maxVertices * 3); + this.srcBlend = this.context.gl.SRC_ALPHA; + this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA; + } + PolygonBatcher.prototype.begin = function (shader) { + var gl = this.context.gl; + if (this.isDrawing) + throw new Error("PolygonBatch is already drawing. Call PolygonBatch.end() before calling PolygonBatch.begin()"); + this.drawCalls = 0; + this.shader = shader; + this.lastTexture = null; + this.isDrawing = true; + gl.enable(gl.BLEND); + gl.blendFunc(this.srcBlend, this.dstBlend); + }; + PolygonBatcher.prototype.setBlendMode = function (srcBlend, dstBlend) { + var gl = this.context.gl; + this.srcBlend = srcBlend; + this.dstBlend = dstBlend; + if (this.isDrawing) { + this.flush(); + gl.blendFunc(this.srcBlend, this.dstBlend); + } + }; + PolygonBatcher.prototype.draw = function (texture, vertices, indices) { + if (texture != this.lastTexture) { + this.flush(); + this.lastTexture = texture; + } + else if (this.verticesLength + vertices.length > this.mesh.getVertices().length || + this.indicesLength + indices.length > this.mesh.getIndices().length) { + this.flush(); + } + var indexStart = this.mesh.numVertices(); + this.mesh.getVertices().set(vertices, this.verticesLength); + this.verticesLength += vertices.length; + this.mesh.setVerticesLength(this.verticesLength); + var indicesArray = this.mesh.getIndices(); + for (var i = this.indicesLength, j = 0; j < indices.length; i++, j++) + indicesArray[i] = indices[j] + indexStart; + this.indicesLength += indices.length; + this.mesh.setIndicesLength(this.indicesLength); + }; + PolygonBatcher.prototype.flush = function () { + var gl = this.context.gl; + if (this.verticesLength == 0) + return; + this.lastTexture.bind(); + this.mesh.draw(this.shader, gl.TRIANGLES); + this.verticesLength = 0; + this.indicesLength = 0; + this.mesh.setVerticesLength(0); + this.mesh.setIndicesLength(0); + this.drawCalls++; + }; + PolygonBatcher.prototype.end = function () { + var gl = this.context.gl; + if (!this.isDrawing) + throw new Error("PolygonBatch is not drawing. Call PolygonBatch.begin() before calling PolygonBatch.end()"); + if (this.verticesLength > 0 || this.indicesLength > 0) + this.flush(); + this.shader = null; + this.lastTexture = null; + this.isDrawing = false; + gl.disable(gl.BLEND); + }; + PolygonBatcher.prototype.getDrawCalls = function () { return this.drawCalls; }; + PolygonBatcher.prototype.dispose = function () { + this.mesh.dispose(); + }; + return PolygonBatcher; + }()); + webgl.PolygonBatcher = PolygonBatcher; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var SceneRenderer = (function () { + function SceneRenderer(canvas, context, twoColorTint) { + if (twoColorTint === void 0) { twoColorTint = true; } + this.twoColorTint = false; + this.activeRenderer = null; + this.QUAD = [ + 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, + ]; + this.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0]; + this.WHITE = new spine.Color(1, 1, 1, 1); + this.canvas = canvas; + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + this.twoColorTint = twoColorTint; + this.camera = new webgl.OrthoCamera(canvas.width, canvas.height); + this.batcherShader = twoColorTint ? webgl.Shader.newTwoColoredTextured(this.context) : webgl.Shader.newColoredTextured(this.context); + this.batcher = new webgl.PolygonBatcher(this.context, twoColorTint); + this.shapesShader = webgl.Shader.newColored(this.context); + this.shapes = new webgl.ShapeRenderer(this.context); + this.skeletonRenderer = new webgl.SkeletonRenderer(this.context, twoColorTint); + this.skeletonDebugRenderer = new webgl.SkeletonDebugRenderer(this.context); + } + SceneRenderer.prototype.begin = function () { + this.camera.update(); + this.enableRenderer(this.batcher); + }; + SceneRenderer.prototype.drawSkeleton = function (skeleton, premultipliedAlpha, slotRangeStart, slotRangeEnd) { + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + if (slotRangeStart === void 0) { slotRangeStart = -1; } + if (slotRangeEnd === void 0) { slotRangeEnd = -1; } + this.enableRenderer(this.batcher); + this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha; + this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd); + }; + SceneRenderer.prototype.drawSkeletonDebug = function (skeleton, premultipliedAlpha, ignoredBones) { + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + if (ignoredBones === void 0) { ignoredBones = null; } + this.enableRenderer(this.shapes); + this.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha; + this.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones); + }; + SceneRenderer.prototype.drawTexture = function (texture, x, y, width, height, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.batcher); + if (color === null) + color = this.WHITE; + var quad = this.QUAD; + var i = 0; + quad[i++] = x; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 0; + quad[i++] = 1; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 1; + quad[i++] = 1; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 1; + quad[i++] = 0; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 0; + quad[i++] = 0; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + this.batcher.draw(texture, quad, this.QUAD_TRIANGLES); + }; + SceneRenderer.prototype.drawTextureUV = function (texture, x, y, width, height, u, v, u2, v2, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.batcher); + if (color === null) + color = this.WHITE; + var quad = this.QUAD; + var i = 0; + quad[i++] = x; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = u; + quad[i++] = v; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = u2; + quad[i++] = v; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = u2; + quad[i++] = v2; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = u; + quad[i++] = v2; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + this.batcher.draw(texture, quad, this.QUAD_TRIANGLES); + }; + SceneRenderer.prototype.drawTextureRotated = function (texture, x, y, width, height, pivotX, pivotY, angle, color, premultipliedAlpha) { + if (color === void 0) { color = null; } + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + this.enableRenderer(this.batcher); + if (color === null) + color = this.WHITE; + var quad = this.QUAD; + var worldOriginX = x + pivotX; + var worldOriginY = y + pivotY; + var fx = -pivotX; + var fy = -pivotY; + var fx2 = width - pivotX; + var fy2 = height - pivotY; + var p1x = fx; + var p1y = fy; + var p2x = fx; + var p2y = fy2; + var p3x = fx2; + var p3y = fy2; + var p4x = fx2; + var p4y = fy; + var x1 = 0; + var y1 = 0; + var x2 = 0; + var y2 = 0; + var x3 = 0; + var y3 = 0; + var x4 = 0; + var y4 = 0; + if (angle != 0) { + var cos = spine.MathUtils.cosDeg(angle); + var sin = spine.MathUtils.sinDeg(angle); + x1 = cos * p1x - sin * p1y; + y1 = sin * p1x + cos * p1y; + x4 = cos * p2x - sin * p2y; + y4 = sin * p2x + cos * p2y; + x3 = cos * p3x - sin * p3y; + y3 = sin * p3x + cos * p3y; + x2 = x3 + (x1 - x4); + y2 = y3 + (y1 - y4); + } + else { + x1 = p1x; + y1 = p1y; + x4 = p2x; + y4 = p2y; + x3 = p3x; + y3 = p3y; + x2 = p4x; + y2 = p4y; + } + x1 += worldOriginX; + y1 += worldOriginY; + x2 += worldOriginX; + y2 += worldOriginY; + x3 += worldOriginX; + y3 += worldOriginY; + x4 += worldOriginX; + y4 += worldOriginY; + var i = 0; + quad[i++] = x1; + quad[i++] = y1; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 0; + quad[i++] = 1; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x2; + quad[i++] = y2; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 1; + quad[i++] = 1; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x3; + quad[i++] = y3; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 1; + quad[i++] = 0; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x4; + quad[i++] = y4; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 0; + quad[i++] = 0; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + this.batcher.draw(texture, quad, this.QUAD_TRIANGLES); + }; + SceneRenderer.prototype.drawRegion = function (region, x, y, width, height, color, premultipliedAlpha) { + if (color === void 0) { color = null; } + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + this.enableRenderer(this.batcher); + if (color === null) + color = this.WHITE; + var quad = this.QUAD; + var i = 0; + quad[i++] = x; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = region.u; + quad[i++] = region.v2; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = region.u2; + quad[i++] = region.v2; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = region.u2; + quad[i++] = region.v; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = region.u; + quad[i++] = region.v; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + this.batcher.draw(region.texture, quad, this.QUAD_TRIANGLES); + }; + SceneRenderer.prototype.line = function (x, y, x2, y2, color, color2) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + this.enableRenderer(this.shapes); + this.shapes.line(x, y, x2, y2, color); + }; + SceneRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + if (color3 === void 0) { color3 = null; } + this.enableRenderer(this.shapes); + this.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3); + }; + SceneRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + if (color3 === void 0) { color3 = null; } + if (color4 === void 0) { color4 = null; } + this.enableRenderer(this.shapes); + this.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4); + }; + SceneRenderer.prototype.rect = function (filled, x, y, width, height, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.shapes); + this.shapes.rect(filled, x, y, width, height, color); + }; + SceneRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.shapes); + this.shapes.rectLine(filled, x1, y1, x2, y2, width, color); + }; + SceneRenderer.prototype.polygon = function (polygonVertices, offset, count, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.shapes); + this.shapes.polygon(polygonVertices, offset, count, color); + }; + SceneRenderer.prototype.circle = function (filled, x, y, radius, color, segments) { + if (color === void 0) { color = null; } + if (segments === void 0) { segments = 0; } + this.enableRenderer(this.shapes); + this.shapes.circle(filled, x, y, radius, color, segments); + }; + SceneRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.shapes); + this.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color); + }; + SceneRenderer.prototype.end = function () { + if (this.activeRenderer === this.batcher) + this.batcher.end(); + else if (this.activeRenderer === this.shapes) + this.shapes.end(); + this.activeRenderer = null; + }; + SceneRenderer.prototype.resize = function (resizeMode) { + var canvas = this.canvas; + var w = canvas.clientWidth; + var h = canvas.clientHeight; + if (canvas.width != w || canvas.height != h) { + canvas.width = w; + canvas.height = h; + } + this.context.gl.viewport(0, 0, canvas.width, canvas.height); + if (resizeMode === ResizeMode.Stretch) { + } + else if (resizeMode === ResizeMode.Expand) { + this.camera.setViewport(w, h); + } + else if (resizeMode === ResizeMode.Fit) { + var sourceWidth = canvas.width, sourceHeight = canvas.height; + var targetWidth = this.camera.viewportWidth, targetHeight = this.camera.viewportHeight; + var targetRatio = targetHeight / targetWidth; + var sourceRatio = sourceHeight / sourceWidth; + var scale = targetRatio < sourceRatio ? targetWidth / sourceWidth : targetHeight / sourceHeight; + this.camera.viewportWidth = sourceWidth * scale; + this.camera.viewportHeight = sourceHeight * scale; + } + this.camera.update(); + }; + SceneRenderer.prototype.enableRenderer = function (renderer) { + if (this.activeRenderer === renderer) + return; + this.end(); + if (renderer instanceof webgl.PolygonBatcher) { + this.batcherShader.bind(); + this.batcherShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values); + this.batcherShader.setUniformi("u_texture", 0); + this.batcher.begin(this.batcherShader); + this.activeRenderer = this.batcher; + } + else if (renderer instanceof webgl.ShapeRenderer) { + this.shapesShader.bind(); + this.shapesShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values); + this.shapes.begin(this.shapesShader); + this.activeRenderer = this.shapes; + } + else { + this.activeRenderer = this.skeletonDebugRenderer; + } + }; + SceneRenderer.prototype.dispose = function () { + this.batcher.dispose(); + this.batcherShader.dispose(); + this.shapes.dispose(); + this.shapesShader.dispose(); + this.skeletonDebugRenderer.dispose(); + }; + return SceneRenderer; + }()); + webgl.SceneRenderer = SceneRenderer; + var ResizeMode; + (function (ResizeMode) { + ResizeMode[ResizeMode["Stretch"] = 0] = "Stretch"; + ResizeMode[ResizeMode["Expand"] = 1] = "Expand"; + ResizeMode[ResizeMode["Fit"] = 2] = "Fit"; + })(ResizeMode = webgl.ResizeMode || (webgl.ResizeMode = {})); + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Shader = (function () { + function Shader(context, vertexShader, fragmentShader) { + this.vertexShader = vertexShader; + this.fragmentShader = fragmentShader; + this.vs = null; + this.fs = null; + this.program = null; + this.tmp2x2 = new Float32Array(2 * 2); + this.tmp3x3 = new Float32Array(3 * 3); + this.tmp4x4 = new Float32Array(4 * 4); + this.vsSource = vertexShader; + this.fsSource = fragmentShader; + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + this.context.addRestorable(this); + this.compile(); + } + Shader.prototype.getProgram = function () { return this.program; }; + Shader.prototype.getVertexShader = function () { return this.vertexShader; }; + Shader.prototype.getFragmentShader = function () { return this.fragmentShader; }; + Shader.prototype.getVertexShaderSource = function () { return this.vsSource; }; + Shader.prototype.getFragmentSource = function () { return this.fsSource; }; + Shader.prototype.compile = function () { + var gl = this.context.gl; + try { + this.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader); + this.fs = this.compileShader(gl.FRAGMENT_SHADER, this.fragmentShader); + this.program = this.compileProgram(this.vs, this.fs); + } + catch (e) { + this.dispose(); + throw e; + } + }; + Shader.prototype.compileShader = function (type, source) { + var gl = this.context.gl; + var shader = gl.createShader(type); + gl.shaderSource(shader, source); + gl.compileShader(shader); + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { + var error = "Couldn't compile shader: " + gl.getShaderInfoLog(shader); + gl.deleteShader(shader); + if (!gl.isContextLost()) + throw new Error(error); + } + return shader; + }; + Shader.prototype.compileProgram = function (vs, fs) { + var gl = this.context.gl; + var program = gl.createProgram(); + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.linkProgram(program); + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { + var error = "Couldn't compile shader program: " + gl.getProgramInfoLog(program); + gl.deleteProgram(program); + if (!gl.isContextLost()) + throw new Error(error); + } + return program; + }; + Shader.prototype.restore = function () { + this.compile(); + }; + Shader.prototype.bind = function () { + this.context.gl.useProgram(this.program); + }; + Shader.prototype.unbind = function () { + this.context.gl.useProgram(null); + }; + Shader.prototype.setUniformi = function (uniform, value) { + this.context.gl.uniform1i(this.getUniformLocation(uniform), value); + }; + Shader.prototype.setUniformf = function (uniform, value) { + this.context.gl.uniform1f(this.getUniformLocation(uniform), value); + }; + Shader.prototype.setUniform2f = function (uniform, value, value2) { + this.context.gl.uniform2f(this.getUniformLocation(uniform), value, value2); + }; + Shader.prototype.setUniform3f = function (uniform, value, value2, value3) { + this.context.gl.uniform3f(this.getUniformLocation(uniform), value, value2, value3); + }; + Shader.prototype.setUniform4f = function (uniform, value, value2, value3, value4) { + this.context.gl.uniform4f(this.getUniformLocation(uniform), value, value2, value3, value4); + }; + Shader.prototype.setUniform2x2f = function (uniform, value) { + var gl = this.context.gl; + this.tmp2x2.set(value); + gl.uniformMatrix2fv(this.getUniformLocation(uniform), false, this.tmp2x2); + }; + Shader.prototype.setUniform3x3f = function (uniform, value) { + var gl = this.context.gl; + this.tmp3x3.set(value); + gl.uniformMatrix3fv(this.getUniformLocation(uniform), false, this.tmp3x3); + }; + Shader.prototype.setUniform4x4f = function (uniform, value) { + var gl = this.context.gl; + this.tmp4x4.set(value); + gl.uniformMatrix4fv(this.getUniformLocation(uniform), false, this.tmp4x4); + }; + Shader.prototype.getUniformLocation = function (uniform) { + var gl = this.context.gl; + var location = gl.getUniformLocation(this.program, uniform); + if (!location && !gl.isContextLost()) + throw new Error("Couldn't find location for uniform " + uniform); + return location; + }; + Shader.prototype.getAttributeLocation = function (attribute) { + var gl = this.context.gl; + var location = gl.getAttribLocation(this.program, attribute); + if (location == -1 && !gl.isContextLost()) + throw new Error("Couldn't find location for attribute " + attribute); + return location; + }; + Shader.prototype.dispose = function () { + this.context.removeRestorable(this); + var gl = this.context.gl; + if (this.vs) { + gl.deleteShader(this.vs); + this.vs = null; + } + if (this.fs) { + gl.deleteShader(this.fs); + this.fs = null; + } + if (this.program) { + gl.deleteProgram(this.program); + this.program = null; + } + }; + Shader.newColoredTextured = function (context) { + var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_color;\n\t\t\t\tvarying vec2 v_texCoords;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_color = " + Shader.COLOR + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t"; + var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_color;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tgl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n\t\t\t\t}\n\t\t\t"; + return new Shader(context, vs, fs); + }; + Shader.newTwoColoredTextured = function (context) { + var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR2 + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_light;\n\t\t\t\tvarying vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_light = " + Shader.COLOR + ";\n\t\t\t\t\tv_dark = " + Shader.COLOR2 + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t"; + var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_light;\n\t\t\t\tvarying LOWP vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tvec4 texColor = texture2D(u_texture, v_texCoords);\n\t\t\t\t\tgl_FragColor.a = texColor.a * v_light.a;\n\t\t\t\t\tgl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n\t\t\t\t}\n\t\t\t"; + return new Shader(context, vs, fs); + }; + Shader.newColored = function (context) { + var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_color;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_color = " + Shader.COLOR + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t"; + var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_color;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tgl_FragColor = v_color;\n\t\t\t\t}\n\t\t\t"; + return new Shader(context, vs, fs); + }; + Shader.MVP_MATRIX = "u_projTrans"; + Shader.POSITION = "a_position"; + Shader.COLOR = "a_color"; + Shader.COLOR2 = "a_color2"; + Shader.TEXCOORDS = "a_texCoords"; + Shader.SAMPLER = "u_texture"; + return Shader; + }()); + webgl.Shader = Shader; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var ShapeRenderer = (function () { + function ShapeRenderer(context, maxVertices) { + if (maxVertices === void 0) { maxVertices = 10920; } + this.isDrawing = false; + this.shapeType = ShapeType.Filled; + this.color = new spine.Color(1, 1, 1, 1); + this.vertexIndex = 0; + this.tmp = new spine.Vector2(); + if (maxVertices > 10920) + throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices); + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + this.mesh = new webgl.Mesh(context, [new webgl.Position2Attribute(), new webgl.ColorAttribute()], maxVertices, 0); + this.srcBlend = this.context.gl.SRC_ALPHA; + this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA; + } + ShapeRenderer.prototype.begin = function (shader) { + if (this.isDrawing) + throw new Error("ShapeRenderer.begin() has already been called"); + this.shader = shader; + this.vertexIndex = 0; + this.isDrawing = true; + var gl = this.context.gl; + gl.enable(gl.BLEND); + gl.blendFunc(this.srcBlend, this.dstBlend); + }; + ShapeRenderer.prototype.setBlendMode = function (srcBlend, dstBlend) { + var gl = this.context.gl; + this.srcBlend = srcBlend; + this.dstBlend = dstBlend; + if (this.isDrawing) { + this.flush(); + gl.blendFunc(this.srcBlend, this.dstBlend); + } + }; + ShapeRenderer.prototype.setColor = function (color) { + this.color.setFromColor(color); + }; + ShapeRenderer.prototype.setColorWith = function (r, g, b, a) { + this.color.set(r, g, b, a); + }; + ShapeRenderer.prototype.point = function (x, y, color) { + if (color === void 0) { color = null; } + this.check(ShapeType.Point, 1); + if (color === null) + color = this.color; + this.vertex(x, y, color); + }; + ShapeRenderer.prototype.line = function (x, y, x2, y2, color) { + if (color === void 0) { color = null; } + this.check(ShapeType.Line, 2); + var vertices = this.mesh.getVertices(); + var idx = this.vertexIndex; + if (color === null) + color = this.color; + this.vertex(x, y, color); + this.vertex(x2, y2, color); + }; + ShapeRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + if (color3 === void 0) { color3 = null; } + this.check(filled ? ShapeType.Filled : ShapeType.Line, 3); + var vertices = this.mesh.getVertices(); + var idx = this.vertexIndex; + if (color === null) + color = this.color; + if (color2 === null) + color2 = this.color; + if (color3 === null) + color3 = this.color; + if (filled) { + this.vertex(x, y, color); + this.vertex(x2, y2, color2); + this.vertex(x3, y3, color3); + } + else { + this.vertex(x, y, color); + this.vertex(x2, y2, color2); + this.vertex(x2, y2, color); + this.vertex(x3, y3, color2); + this.vertex(x3, y3, color); + this.vertex(x, y, color2); + } + }; + ShapeRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + if (color3 === void 0) { color3 = null; } + if (color4 === void 0) { color4 = null; } + this.check(filled ? ShapeType.Filled : ShapeType.Line, 3); + var vertices = this.mesh.getVertices(); + var idx = this.vertexIndex; + if (color === null) + color = this.color; + if (color2 === null) + color2 = this.color; + if (color3 === null) + color3 = this.color; + if (color4 === null) + color4 = this.color; + if (filled) { + this.vertex(x, y, color); + this.vertex(x2, y2, color2); + this.vertex(x3, y3, color3); + this.vertex(x3, y3, color3); + this.vertex(x4, y4, color4); + this.vertex(x, y, color); + } + else { + this.vertex(x, y, color); + this.vertex(x2, y2, color2); + this.vertex(x2, y2, color2); + this.vertex(x3, y3, color3); + this.vertex(x3, y3, color3); + this.vertex(x4, y4, color4); + this.vertex(x4, y4, color4); + this.vertex(x, y, color); + } + }; + ShapeRenderer.prototype.rect = function (filled, x, y, width, height, color) { + if (color === void 0) { color = null; } + this.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color); + }; + ShapeRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) { + if (color === void 0) { color = null; } + this.check(filled ? ShapeType.Filled : ShapeType.Line, 8); + if (color === null) + color = this.color; + var t = this.tmp.set(y2 - y1, x1 - x2); + t.normalize(); + width *= 0.5; + var tx = t.x * width; + var ty = t.y * width; + if (!filled) { + this.vertex(x1 + tx, y1 + ty, color); + this.vertex(x1 - tx, y1 - ty, color); + this.vertex(x2 + tx, y2 + ty, color); + this.vertex(x2 - tx, y2 - ty, color); + this.vertex(x2 + tx, y2 + ty, color); + this.vertex(x1 + tx, y1 + ty, color); + this.vertex(x2 - tx, y2 - ty, color); + this.vertex(x1 - tx, y1 - ty, color); + } + else { + this.vertex(x1 + tx, y1 + ty, color); + this.vertex(x1 - tx, y1 - ty, color); + this.vertex(x2 + tx, y2 + ty, color); + this.vertex(x2 - tx, y2 - ty, color); + this.vertex(x2 + tx, y2 + ty, color); + this.vertex(x1 - tx, y1 - ty, color); + } + }; + ShapeRenderer.prototype.x = function (x, y, size) { + this.line(x - size, y - size, x + size, y + size); + this.line(x - size, y + size, x + size, y - size); + }; + ShapeRenderer.prototype.polygon = function (polygonVertices, offset, count, color) { + if (color === void 0) { color = null; } + if (count < 3) + throw new Error("Polygon must contain at least 3 vertices"); + this.check(ShapeType.Line, count * 2); + if (color === null) + color = this.color; + var vertices = this.mesh.getVertices(); + var idx = this.vertexIndex; + offset <<= 1; + count <<= 1; + var firstX = polygonVertices[offset]; + var firstY = polygonVertices[offset + 1]; + var last = offset + count; + for (var i = offset, n = offset + count - 2; i < n; i += 2) { + var x1 = polygonVertices[i]; + var y1 = polygonVertices[i + 1]; + var x2 = 0; + var y2 = 0; + if (i + 2 >= last) { + x2 = firstX; + y2 = firstY; + } + else { + x2 = polygonVertices[i + 2]; + y2 = polygonVertices[i + 3]; + } + this.vertex(x1, y1, color); + this.vertex(x2, y2, color); + } + }; + ShapeRenderer.prototype.circle = function (filled, x, y, radius, color, segments) { + if (color === void 0) { color = null; } + if (segments === void 0) { segments = 0; } + if (segments === 0) + segments = Math.max(1, (6 * spine.MathUtils.cbrt(radius)) | 0); + if (segments <= 0) + throw new Error("segments must be > 0."); + if (color === null) + color = this.color; + var angle = 2 * spine.MathUtils.PI / segments; + var cos = Math.cos(angle); + var sin = Math.sin(angle); + var cx = radius, cy = 0; + if (!filled) { + this.check(ShapeType.Line, segments * 2 + 2); + for (var i = 0; i < segments; i++) { + this.vertex(x + cx, y + cy, color); + var temp_1 = cx; + cx = cos * cx - sin * cy; + cy = sin * temp_1 + cos * cy; + this.vertex(x + cx, y + cy, color); + } + this.vertex(x + cx, y + cy, color); + } + else { + this.check(ShapeType.Filled, segments * 3 + 3); + segments--; + for (var i = 0; i < segments; i++) { + this.vertex(x, y, color); + this.vertex(x + cx, y + cy, color); + var temp_2 = cx; + cx = cos * cx - sin * cy; + cy = sin * temp_2 + cos * cy; + this.vertex(x + cx, y + cy, color); + } + this.vertex(x, y, color); + this.vertex(x + cx, y + cy, color); + } + var temp = cx; + cx = radius; + cy = 0; + this.vertex(x + cx, y + cy, color); + }; + ShapeRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) { + if (color === void 0) { color = null; } + this.check(ShapeType.Line, segments * 2 + 2); + if (color === null) + color = this.color; + var subdiv_step = 1 / segments; + var subdiv_step2 = subdiv_step * subdiv_step; + var subdiv_step3 = subdiv_step * subdiv_step * subdiv_step; + var pre1 = 3 * subdiv_step; + var pre2 = 3 * subdiv_step2; + var pre4 = 6 * subdiv_step2; + var pre5 = 6 * subdiv_step3; + var tmp1x = x1 - cx1 * 2 + cx2; + var tmp1y = y1 - cy1 * 2 + cy2; + var tmp2x = (cx1 - cx2) * 3 - x1 + x2; + var tmp2y = (cy1 - cy2) * 3 - y1 + y2; + var fx = x1; + var fy = y1; + var dfx = (cx1 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3; + var dfy = (cy1 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3; + var ddfx = tmp1x * pre4 + tmp2x * pre5; + var ddfy = tmp1y * pre4 + tmp2y * pre5; + var dddfx = tmp2x * pre5; + var dddfy = tmp2y * pre5; + while (segments-- > 0) { + this.vertex(fx, fy, color); + fx += dfx; + fy += dfy; + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + this.vertex(fx, fy, color); + } + this.vertex(fx, fy, color); + this.vertex(x2, y2, color); + }; + ShapeRenderer.prototype.vertex = function (x, y, color) { + var idx = this.vertexIndex; + var vertices = this.mesh.getVertices(); + vertices[idx++] = x; + vertices[idx++] = y; + vertices[idx++] = color.r; + vertices[idx++] = color.g; + vertices[idx++] = color.b; + vertices[idx++] = color.a; + this.vertexIndex = idx; + }; + ShapeRenderer.prototype.end = function () { + if (!this.isDrawing) + throw new Error("ShapeRenderer.begin() has not been called"); + this.flush(); + this.context.gl.disable(this.context.gl.BLEND); + this.isDrawing = false; + }; + ShapeRenderer.prototype.flush = function () { + if (this.vertexIndex == 0) + return; + this.mesh.setVerticesLength(this.vertexIndex); + this.mesh.draw(this.shader, this.shapeType); + this.vertexIndex = 0; + }; + ShapeRenderer.prototype.check = function (shapeType, numVertices) { + if (!this.isDrawing) + throw new Error("ShapeRenderer.begin() has not been called"); + if (this.shapeType == shapeType) { + if (this.mesh.maxVertices() - this.mesh.numVertices() < numVertices) + this.flush(); + else + return; + } + else { + this.flush(); + this.shapeType = shapeType; + } + }; + ShapeRenderer.prototype.dispose = function () { + this.mesh.dispose(); + }; + return ShapeRenderer; + }()); + webgl.ShapeRenderer = ShapeRenderer; + var ShapeType; + (function (ShapeType) { + ShapeType[ShapeType["Point"] = 0] = "Point"; + ShapeType[ShapeType["Line"] = 1] = "Line"; + ShapeType[ShapeType["Filled"] = 4] = "Filled"; + })(ShapeType = webgl.ShapeType || (webgl.ShapeType = {})); + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var SkeletonDebugRenderer = (function () { + function SkeletonDebugRenderer(context) { + this.boneLineColor = new spine.Color(1, 0, 0, 1); + this.boneOriginColor = new spine.Color(0, 1, 0, 1); + this.attachmentLineColor = new spine.Color(0, 0, 1, 0.5); + this.triangleLineColor = new spine.Color(1, 0.64, 0, 0.5); + this.pathColor = new spine.Color().setFromString("FF7F00"); + this.clipColor = new spine.Color(0.8, 0, 0, 2); + this.aabbColor = new spine.Color(0, 1, 0, 0.5); + this.drawBones = true; + this.drawRegionAttachments = true; + this.drawBoundingBoxes = true; + this.drawMeshHull = true; + this.drawMeshTriangles = true; + this.drawPaths = true; + this.drawSkeletonXY = false; + this.drawClipping = true; + this.premultipliedAlpha = false; + this.scale = 1; + this.boneWidth = 2; + this.bounds = new spine.SkeletonBounds(); + this.temp = new Array(); + this.vertices = spine.Utils.newFloatArray(2 * 1024); + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + } + SkeletonDebugRenderer.prototype.draw = function (shapes, skeleton, ignoredBones) { + if (ignoredBones === void 0) { ignoredBones = null; } + var skeletonX = skeleton.x; + var skeletonY = skeleton.y; + var gl = this.context.gl; + var srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA; + shapes.setBlendMode(srcFunc, gl.ONE_MINUS_SRC_ALPHA); + var bones = skeleton.bones; + if (this.drawBones) { + shapes.setColor(this.boneLineColor); + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1) + continue; + if (bone.parent == null) + continue; + var x = skeletonX + bone.data.length * bone.a + bone.worldX; + var y = skeletonY + bone.data.length * bone.c + bone.worldY; + shapes.rectLine(true, skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, this.boneWidth * this.scale); + } + if (this.drawSkeletonXY) + shapes.x(skeletonX, skeletonY, 4 * this.scale); + } + if (this.drawRegionAttachments) { + shapes.setColor(this.attachmentLineColor); + var slots = skeleton.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.RegionAttachment) { + var regionAttachment = attachment; + var vertices = this.vertices; + regionAttachment.computeWorldVertices(slot.bone, vertices, 0, 2); + shapes.line(vertices[0], vertices[1], vertices[2], vertices[3]); + shapes.line(vertices[2], vertices[3], vertices[4], vertices[5]); + shapes.line(vertices[4], vertices[5], vertices[6], vertices[7]); + shapes.line(vertices[6], vertices[7], vertices[0], vertices[1]); + } + } + } + if (this.drawMeshHull || this.drawMeshTriangles) { + var slots = skeleton.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (!(attachment instanceof spine.MeshAttachment)) + continue; + var mesh = attachment; + var vertices = this.vertices; + mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 2); + var triangles = mesh.triangles; + var hullLength = mesh.hullLength; + if (this.drawMeshTriangles) { + shapes.setColor(this.triangleLineColor); + for (var ii = 0, nn = triangles.length; ii < nn; ii += 3) { + var v1 = triangles[ii] * 2, v2 = triangles[ii + 1] * 2, v3 = triangles[ii + 2] * 2; + shapes.triangle(false, vertices[v1], vertices[v1 + 1], vertices[v2], vertices[v2 + 1], vertices[v3], vertices[v3 + 1]); + } + } + if (this.drawMeshHull && hullLength > 0) { + shapes.setColor(this.attachmentLineColor); + hullLength = (hullLength >> 1) * 2; + var lastX = vertices[hullLength - 2], lastY = vertices[hullLength - 1]; + for (var ii = 0, nn = hullLength; ii < nn; ii += 2) { + var x = vertices[ii], y = vertices[ii + 1]; + shapes.line(x, y, lastX, lastY); + lastX = x; + lastY = y; + } + } + } + } + if (this.drawBoundingBoxes) { + var bounds = this.bounds; + bounds.update(skeleton, true); + shapes.setColor(this.aabbColor); + shapes.rect(false, bounds.minX, bounds.minY, bounds.getWidth(), bounds.getHeight()); + var polygons = bounds.polygons; + var boxes = bounds.boundingBoxes; + for (var i = 0, n = polygons.length; i < n; i++) { + var polygon = polygons[i]; + shapes.setColor(boxes[i].color); + shapes.polygon(polygon, 0, polygon.length); + } + } + if (this.drawPaths) { + var slots = skeleton.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (!(attachment instanceof spine.PathAttachment)) + continue; + var path = attachment; + var nn = path.worldVerticesLength; + var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0); + path.computeWorldVertices(slot, 0, nn, world, 0, 2); + var color = this.pathColor; + var x1 = world[2], y1 = world[3], x2 = 0, y2 = 0; + if (path.closed) { + shapes.setColor(color); + var cx1 = world[0], cy1 = world[1], cx2 = world[nn - 2], cy2 = world[nn - 1]; + x2 = world[nn - 4]; + y2 = world[nn - 3]; + shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32); + shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY); + shapes.line(x1, y1, cx1, cy1); + shapes.line(x2, y2, cx2, cy2); + } + nn -= 4; + for (var ii = 4; ii < nn; ii += 6) { + var cx1 = world[ii], cy1 = world[ii + 1], cx2 = world[ii + 2], cy2 = world[ii + 3]; + x2 = world[ii + 4]; + y2 = world[ii + 5]; + shapes.setColor(color); + shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32); + shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY); + shapes.line(x1, y1, cx1, cy1); + shapes.line(x2, y2, cx2, cy2); + x1 = x2; + y1 = y2; + } + } + } + if (this.drawBones) { + shapes.setColor(this.boneOriginColor); + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1) + continue; + shapes.circle(true, skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * this.scale, SkeletonDebugRenderer.GREEN, 8); + } + } + if (this.drawClipping) { + var slots = skeleton.slots; + shapes.setColor(this.clipColor); + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (!(attachment instanceof spine.ClippingAttachment)) + continue; + var clip = attachment; + var nn = clip.worldVerticesLength; + var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0); + clip.computeWorldVertices(slot, 0, nn, world, 0, 2); + for (var i_12 = 0, n_2 = world.length; i_12 < n_2; i_12 += 2) { + var x = world[i_12]; + var y = world[i_12 + 1]; + var x2 = world[(i_12 + 2) % world.length]; + var y2 = world[(i_12 + 3) % world.length]; + shapes.line(x, y, x2, y2); + } + } + } + }; + SkeletonDebugRenderer.prototype.dispose = function () { + }; + SkeletonDebugRenderer.LIGHT_GRAY = new spine.Color(192 / 255, 192 / 255, 192 / 255, 1); + SkeletonDebugRenderer.GREEN = new spine.Color(0, 1, 0, 1); + return SkeletonDebugRenderer; + }()); + webgl.SkeletonDebugRenderer = SkeletonDebugRenderer; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Renderable = (function () { + function Renderable(vertices, numVertices, numFloats) { + this.vertices = vertices; + this.numVertices = numVertices; + this.numFloats = numFloats; + } + return Renderable; + }()); + ; + var SkeletonRenderer = (function () { + function SkeletonRenderer(context, twoColorTint) { + if (twoColorTint === void 0) { twoColorTint = true; } + this.premultipliedAlpha = false; + this.vertexEffect = null; + this.tempColor = new spine.Color(); + this.tempColor2 = new spine.Color(); + this.vertexSize = 2 + 2 + 4; + this.twoColorTint = false; + this.renderable = new Renderable(null, 0, 0); + this.clipper = new spine.SkeletonClipping(); + this.temp = new spine.Vector2(); + this.temp2 = new spine.Vector2(); + this.temp3 = new spine.Color(); + this.temp4 = new spine.Color(); + this.twoColorTint = twoColorTint; + if (twoColorTint) + this.vertexSize += 4; + this.vertices = spine.Utils.newFloatArray(this.vertexSize * 1024); + } + SkeletonRenderer.prototype.draw = function (batcher, skeleton, slotRangeStart, slotRangeEnd) { + if (slotRangeStart === void 0) { slotRangeStart = -1; } + if (slotRangeEnd === void 0) { slotRangeEnd = -1; } + var clipper = this.clipper; + var premultipliedAlpha = this.premultipliedAlpha; + var twoColorTint = this.twoColorTint; + var blendMode = null; + var tempPos = this.temp; + var tempUv = this.temp2; + var tempLight = this.temp3; + var tempDark = this.temp4; + var renderable = this.renderable; + var uvs = null; + var triangles = null; + var drawOrder = skeleton.drawOrder; + var attachmentColor = null; + var skeletonColor = skeleton.color; + var vertexSize = twoColorTint ? 12 : 8; + var inRange = false; + if (slotRangeStart == -1) + inRange = true; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var clippedVertexSize = clipper.isClipping() ? 2 : vertexSize; + var slot = drawOrder[i]; + if (slotRangeStart >= 0 && slotRangeStart == slot.data.index) { + inRange = true; + } + if (!inRange) { + clipper.clipEndWithSlot(slot); + continue; + } + if (slotRangeEnd >= 0 && slotRangeEnd == slot.data.index) { + inRange = false; + } + var attachment = slot.getAttachment(); + var texture = null; + if (attachment instanceof spine.RegionAttachment) { + var region = attachment; + renderable.vertices = this.vertices; + renderable.numVertices = 4; + renderable.numFloats = clippedVertexSize << 2; + region.computeWorldVertices(slot.bone, renderable.vertices, 0, clippedVertexSize); + triangles = SkeletonRenderer.QUAD_TRIANGLES; + uvs = region.uvs; + texture = region.region.renderObject.texture; + attachmentColor = region.color; + } + else if (attachment instanceof spine.MeshAttachment) { + var mesh = attachment; + renderable.vertices = this.vertices; + renderable.numVertices = (mesh.worldVerticesLength >> 1); + renderable.numFloats = renderable.numVertices * clippedVertexSize; + if (renderable.numFloats > renderable.vertices.length) { + renderable.vertices = this.vertices = spine.Utils.newFloatArray(renderable.numFloats); + } + mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, renderable.vertices, 0, clippedVertexSize); + triangles = mesh.triangles; + texture = mesh.region.renderObject.texture; + uvs = mesh.uvs; + attachmentColor = mesh.color; + } + else if (attachment instanceof spine.ClippingAttachment) { + var clip = (attachment); + clipper.clipStart(slot, clip); + continue; + } + else + continue; + if (texture != null) { + var slotColor = slot.color; + var finalColor = this.tempColor; + finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r; + finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g; + finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b; + finalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a; + if (premultipliedAlpha) { + finalColor.r *= finalColor.a; + finalColor.g *= finalColor.a; + finalColor.b *= finalColor.a; + } + var darkColor = this.tempColor2; + if (slot.darkColor == null) + darkColor.set(0, 0, 0, 1.0); + else { + if (premultipliedAlpha) { + darkColor.r = slot.darkColor.r * finalColor.a; + darkColor.g = slot.darkColor.g * finalColor.a; + darkColor.b = slot.darkColor.b * finalColor.a; + } + else { + darkColor.setFromColor(slot.darkColor); + } + darkColor.a = premultipliedAlpha ? 1.0 : 0.0; + } + var slotBlendMode = slot.data.blendMode; + if (slotBlendMode != blendMode) { + blendMode = slotBlendMode; + batcher.setBlendMode(webgl.WebGLBlendModeConverter.getSourceGLBlendMode(blendMode, premultipliedAlpha), webgl.WebGLBlendModeConverter.getDestGLBlendMode(blendMode)); + } + if (clipper.isClipping()) { + clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint); + var clippedVertices = new Float32Array(clipper.clippedVertices); + var clippedTriangles = clipper.clippedTriangles; + if (this.vertexEffect != null) { + var vertexEffect = this.vertexEffect; + var verts = clippedVertices; + if (!twoColorTint) { + for (var v = 0, n_3 = clippedVertices.length; v < n_3; v += vertexSize) { + tempPos.x = verts[v]; + tempPos.y = verts[v + 1]; + tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]); + tempUv.x = verts[v + 6]; + tempUv.y = verts[v + 7]; + tempDark.set(0, 0, 0, 0); + vertexEffect.transform(tempPos, tempUv, tempLight, tempDark); + verts[v] = tempPos.x; + verts[v + 1] = tempPos.y; + verts[v + 2] = tempLight.r; + verts[v + 3] = tempLight.g; + verts[v + 4] = tempLight.b; + verts[v + 5] = tempLight.a; + verts[v + 6] = tempUv.x; + verts[v + 7] = tempUv.y; + } + } + else { + for (var v = 0, n_4 = clippedVertices.length; v < n_4; v += vertexSize) { + tempPos.x = verts[v]; + tempPos.y = verts[v + 1]; + tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]); + tempUv.x = verts[v + 6]; + tempUv.y = verts[v + 7]; + tempDark.set(verts[v + 8], verts[v + 9], verts[v + 10], verts[v + 11]); + vertexEffect.transform(tempPos, tempUv, tempLight, tempDark); + verts[v] = tempPos.x; + verts[v + 1] = tempPos.y; + verts[v + 2] = tempLight.r; + verts[v + 3] = tempLight.g; + verts[v + 4] = tempLight.b; + verts[v + 5] = tempLight.a; + verts[v + 6] = tempUv.x; + verts[v + 7] = tempUv.y; + verts[v + 8] = tempDark.r; + verts[v + 9] = tempDark.g; + verts[v + 10] = tempDark.b; + verts[v + 11] = tempDark.a; + } + } + } + batcher.draw(texture, clippedVertices, clippedTriangles); + } + else { + var verts = renderable.vertices; + if (this.vertexEffect != null) { + var vertexEffect = this.vertexEffect; + if (!twoColorTint) { + for (var v = 0, u = 0, n_5 = renderable.numFloats; v < n_5; v += vertexSize, u += 2) { + tempPos.x = verts[v]; + tempPos.y = verts[v + 1]; + tempUv.x = uvs[u]; + tempUv.y = uvs[u + 1]; + tempLight.setFromColor(finalColor); + tempDark.set(0, 0, 0, 0); + vertexEffect.transform(tempPos, tempUv, tempLight, tempDark); + verts[v] = tempPos.x; + verts[v + 1] = tempPos.y; + verts[v + 2] = tempLight.r; + verts[v + 3] = tempLight.g; + verts[v + 4] = tempLight.b; + verts[v + 5] = tempLight.a; + verts[v + 6] = tempUv.x; + verts[v + 7] = tempUv.y; + } + } + else { + for (var v = 0, u = 0, n_6 = renderable.numFloats; v < n_6; v += vertexSize, u += 2) { + tempPos.x = verts[v]; + tempPos.y = verts[v + 1]; + tempUv.x = uvs[u]; + tempUv.y = uvs[u + 1]; + tempLight.setFromColor(finalColor); + tempDark.setFromColor(darkColor); + vertexEffect.transform(tempPos, tempUv, tempLight, tempDark); + verts[v] = tempPos.x; + verts[v + 1] = tempPos.y; + verts[v + 2] = tempLight.r; + verts[v + 3] = tempLight.g; + verts[v + 4] = tempLight.b; + verts[v + 5] = tempLight.a; + verts[v + 6] = tempUv.x; + verts[v + 7] = tempUv.y; + verts[v + 8] = tempDark.r; + verts[v + 9] = tempDark.g; + verts[v + 10] = tempDark.b; + verts[v + 11] = tempDark.a; + } + } + } + else { + if (!twoColorTint) { + for (var v = 2, u = 0, n_7 = renderable.numFloats; v < n_7; v += vertexSize, u += 2) { + verts[v] = finalColor.r; + verts[v + 1] = finalColor.g; + verts[v + 2] = finalColor.b; + verts[v + 3] = finalColor.a; + verts[v + 4] = uvs[u]; + verts[v + 5] = uvs[u + 1]; + } + } + else { + for (var v = 2, u = 0, n_8 = renderable.numFloats; v < n_8; v += vertexSize, u += 2) { + verts[v] = finalColor.r; + verts[v + 1] = finalColor.g; + verts[v + 2] = finalColor.b; + verts[v + 3] = finalColor.a; + verts[v + 4] = uvs[u]; + verts[v + 5] = uvs[u + 1]; + verts[v + 6] = darkColor.r; + verts[v + 7] = darkColor.g; + verts[v + 8] = darkColor.b; + verts[v + 9] = darkColor.a; + } + } + } + var view = renderable.vertices.subarray(0, renderable.numFloats); + batcher.draw(texture, view, triangles); + } + } + clipper.clipEndWithSlot(slot); + } + clipper.clipEnd(); + }; + SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0]; + return SkeletonRenderer; + }()); + webgl.SkeletonRenderer = SkeletonRenderer; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Vector3 = (function () { + function Vector3(x, y, z) { + if (x === void 0) { x = 0; } + if (y === void 0) { y = 0; } + if (z === void 0) { z = 0; } + this.x = 0; + this.y = 0; + this.z = 0; + this.x = x; + this.y = y; + this.z = z; + } + Vector3.prototype.setFrom = function (v) { + this.x = v.x; + this.y = v.y; + this.z = v.z; + return this; + }; + Vector3.prototype.set = function (x, y, z) { + this.x = x; + this.y = y; + this.z = z; + return this; + }; + Vector3.prototype.add = function (v) { + this.x += v.x; + this.y += v.y; + this.z += v.z; + return this; + }; + Vector3.prototype.sub = function (v) { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + return this; + }; + Vector3.prototype.scale = function (s) { + this.x *= s; + this.y *= s; + this.z *= s; + return this; + }; + Vector3.prototype.normalize = function () { + var len = this.length(); + if (len == 0) + return this; + len = 1 / len; + this.x *= len; + this.y *= len; + this.z *= len; + return this; + }; + Vector3.prototype.cross = function (v) { + return this.set(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * v.y - this.y * v.x); + }; + Vector3.prototype.multiply = function (matrix) { + var l_mat = matrix.values; + return this.set(this.x * l_mat[webgl.M00] + this.y * l_mat[webgl.M01] + this.z * l_mat[webgl.M02] + l_mat[webgl.M03], this.x * l_mat[webgl.M10] + this.y * l_mat[webgl.M11] + this.z * l_mat[webgl.M12] + l_mat[webgl.M13], this.x * l_mat[webgl.M20] + this.y * l_mat[webgl.M21] + this.z * l_mat[webgl.M22] + l_mat[webgl.M23]); + }; + Vector3.prototype.project = function (matrix) { + var l_mat = matrix.values; + var l_w = 1 / (this.x * l_mat[webgl.M30] + this.y * l_mat[webgl.M31] + this.z * l_mat[webgl.M32] + l_mat[webgl.M33]); + return this.set((this.x * l_mat[webgl.M00] + this.y * l_mat[webgl.M01] + this.z * l_mat[webgl.M02] + l_mat[webgl.M03]) * l_w, (this.x * l_mat[webgl.M10] + this.y * l_mat[webgl.M11] + this.z * l_mat[webgl.M12] + l_mat[webgl.M13]) * l_w, (this.x * l_mat[webgl.M20] + this.y * l_mat[webgl.M21] + this.z * l_mat[webgl.M22] + l_mat[webgl.M23]) * l_w); + }; + Vector3.prototype.dot = function (v) { + return this.x * v.x + this.y * v.y + this.z * v.z; + }; + Vector3.prototype.length = function () { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + }; + Vector3.prototype.distance = function (v) { + var a = v.x - this.x; + var b = v.y - this.y; + var c = v.z - this.z; + return Math.sqrt(a * a + b * b + c * c); + }; + return Vector3; + }()); + webgl.Vector3 = Vector3; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var ManagedWebGLRenderingContext = (function () { + function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) { + if (contextConfig === void 0) { contextConfig = { alpha: "true" }; } + var _this = this; + this.restorables = new Array(); + if (canvasOrContext instanceof HTMLCanvasElement) { + var canvas = canvasOrContext; + this.gl = (canvas.getContext("webgl", contextConfig) || canvas.getContext("experimental-webgl", contextConfig)); + this.canvas = canvas; + canvas.addEventListener("webglcontextlost", function (e) { + var event = e; + if (e) { + e.preventDefault(); + } + }); + canvas.addEventListener("webglcontextrestored", function (e) { + for (var i = 0, n = _this.restorables.length; i < n; i++) { + _this.restorables[i].restore(); + } + }); + } + else { + this.gl = canvasOrContext; + this.canvas = this.gl.canvas; + } + } + ManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) { + this.restorables.push(restorable); + }; + ManagedWebGLRenderingContext.prototype.removeRestorable = function (restorable) { + var index = this.restorables.indexOf(restorable); + if (index > -1) + this.restorables.splice(index, 1); + }; + return ManagedWebGLRenderingContext; + }()); + webgl.ManagedWebGLRenderingContext = ManagedWebGLRenderingContext; + var WebGLBlendModeConverter = (function () { + function WebGLBlendModeConverter() { + } + WebGLBlendModeConverter.getDestGLBlendMode = function (blendMode) { + switch (blendMode) { + case spine.BlendMode.Normal: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA; + case spine.BlendMode.Additive: return WebGLBlendModeConverter.ONE; + case spine.BlendMode.Multiply: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA; + case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA; + default: throw new Error("Unknown blend mode: " + blendMode); + } + }; + WebGLBlendModeConverter.getSourceGLBlendMode = function (blendMode, premultipliedAlpha) { + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + switch (blendMode) { + case spine.BlendMode.Normal: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA; + case spine.BlendMode.Additive: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA; + case spine.BlendMode.Multiply: return WebGLBlendModeConverter.DST_COLOR; + case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE; + default: throw new Error("Unknown blend mode: " + blendMode); + } + }; + WebGLBlendModeConverter.ZERO = 0; + WebGLBlendModeConverter.ONE = 1; + WebGLBlendModeConverter.SRC_COLOR = 0x0300; + WebGLBlendModeConverter.ONE_MINUS_SRC_COLOR = 0x0301; + WebGLBlendModeConverter.SRC_ALPHA = 0x0302; + WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA = 0x0303; + WebGLBlendModeConverter.DST_ALPHA = 0x0304; + WebGLBlendModeConverter.ONE_MINUS_DST_ALPHA = 0x0305; + WebGLBlendModeConverter.DST_COLOR = 0x0306; + return WebGLBlendModeConverter; + }()); + webgl.WebGLBlendModeConverter = WebGLBlendModeConverter; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +//# sourceMappingURL=spine-webgl.js.map + +/*** EXPORTS FROM exports-loader ***/ +module.exports = spine; +}.call(window)); + +/***/ }) + +/******/ }); +}); +//# sourceMappingURL=SpineWebGLPlugin.js.map \ No newline at end of file diff --git a/plugins/spine/dist/SpineWebGLPlugin.js.map b/plugins/spine/dist/SpineWebGLPlugin.js.map new file mode 100644 index 000000000..c1d754261 --- /dev/null +++ b/plugins/spine/dist/SpineWebGLPlugin.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:////Users/rich/Documents/GitHub/phaser/node_modules/eventemitter3/index.js","webpack:////Users/rich/Documents/GitHub/phaser/src/data/DataManager.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/GameObject.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Alpha.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/components/BlendMode.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Depth.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Flip.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/components/ScrollFactor.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/components/ToJSON.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Transform.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/components/TransformMatrix.js","webpack:////Users/rich/Documents/GitHub/phaser/src/gameobjects/components/Visible.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/File.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/FileTypesManager.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/GetURL.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/MergeXHRSettings.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/MultiFile.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/XHRLoader.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/XHRSettings.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/const.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/filetypes/ImageFile.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/filetypes/JSONFile.js","webpack:////Users/rich/Documents/GitHub/phaser/src/loader/filetypes/TextFile.js","webpack:////Users/rich/Documents/GitHub/phaser/src/math/Clamp.js","webpack:////Users/rich/Documents/GitHub/phaser/src/math/Matrix4.js","webpack:////Users/rich/Documents/GitHub/phaser/src/math/Vector2.js","webpack:////Users/rich/Documents/GitHub/phaser/src/math/Wrap.js","webpack:////Users/rich/Documents/GitHub/phaser/src/math/angle/CounterClockwise.js","webpack:////Users/rich/Documents/GitHub/phaser/src/math/angle/Wrap.js","webpack:////Users/rich/Documents/GitHub/phaser/src/math/angle/WrapDegrees.js","webpack:////Users/rich/Documents/GitHub/phaser/src/math/const.js","webpack:////Users/rich/Documents/GitHub/phaser/src/plugins/BasePlugin.js","webpack:////Users/rich/Documents/GitHub/phaser/src/plugins/ScenePlugin.js","webpack:////Users/rich/Documents/GitHub/phaser/src/renderer/BlendModes.js","webpack:////Users/rich/Documents/GitHub/phaser/src/utils/Class.js","webpack:////Users/rich/Documents/GitHub/phaser/src/utils/NOOP.js","webpack:////Users/rich/Documents/GitHub/phaser/src/utils/object/Extend.js","webpack:////Users/rich/Documents/GitHub/phaser/src/utils/object/GetFastValue.js","webpack:////Users/rich/Documents/GitHub/phaser/src/utils/object/GetValue.js","webpack:////Users/rich/Documents/GitHub/phaser/src/utils/object/IsPlainObject.js","webpack:///./BaseSpinePlugin.js","webpack:///./SpineFile.js","webpack:///./SpineWebGLPlugin.js","webpack:///./gameobject/SpineGameObject.js","webpack:///./gameobject/SpineGameObjectRender.js","webpack:///./gameobject/SpineGameObjectWebGLRenderer.js","webpack:///./runtimes/spine-webgl.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;AClFa;;AAEb;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,SAAS;AACpB,WAAW,EAAE;AACb,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,gBAAgB;AAC3B,WAAW,SAAS;AACpB,WAAW,EAAE;AACb,WAAW,QAAQ;AACnB,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,gBAAgB;AAC3B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,aAAa,MAAM;AACnB;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,yDAAyD,OAAO;AAChE;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,aAAa,OAAO;AACpB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,aAAa,QAAQ;AACrB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,yCAAyC,SAAS;AAClD;AACA;;AAEA;AACA,GAAG;AACH;AACA;;AAEA,eAAe,YAAY;AAC3B;;AAEA;AACA,2DAA2D;AAC3D,+DAA+D;AAC/D,mEAAmE;AACnE,uEAAuE;AACvE;AACA,0DAA0D,SAAS;AACnE;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,WAAW,SAAS;AACpB,WAAW,EAAE;AACb,aAAa,aAAa;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,WAAW,SAAS;AACpB,WAAW,EAAE;AACb,aAAa,aAAa;AAC1B;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,WAAW,SAAS;AACpB,WAAW,EAAE;AACb,WAAW,QAAQ;AACnB,aAAa,aAAa;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH,2DAA2D,YAAY;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,WAAW,gBAAgB;AAC3B,aAAa,aAAa;AAC1B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAI,IAA6B;AACjC;AACA;;;;;;;;;;;;AC/UA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,mDAAgB;;AAEpC;AACA;AACA;AACA,WAAW,EAAE;AACb,WAAW,OAAO;AAClB,WAAW,EAAE;AACb,WAAW,KAAK;AAChB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,2BAA2B;AACtC;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA,gBAAgB,EAAE;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,2BAA2B,gBAAgB;AAC3C;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,mBAAmB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,2DAA2D;AAC5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,eAAe,EAAE;AACjB;AACA,gBAAgB,wBAAwB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,EAAE;AACjB;AACA,gBAAgB,wBAAwB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,iBAAiB;;AAEjB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,aAAa;;AAEb;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,iBAAiB;AAChC,eAAe,EAAE;AACjB,eAAe,KAAK;AACpB;AACA,gBAAgB,wBAAwB;AACxC;AACA;AACA;AACA;;AAEA,uBAAuB,sBAAsB;AAC7C;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,mBAAmB;AAClC,eAAe,QAAQ;AACvB;AACA,gBAAgB,wBAAwB;AACxC;AACA;AACA;AACA,sCAAsC,kBAAkB;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA,gBAAgB,wBAAwB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,2BAA2B,gBAAgB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,wBAAwB;AACxC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,EAAE;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA,gBAAgB,wBAAwB;AACxC;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,wBAAwB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA,CAAC;;AAED;;;;;;;;;;;;AC7mBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,mDAAgB;AACpC,uBAAuB,mBAAO,CAAC,0EAAqB;AACpD,kBAAkB,mBAAO,CAAC,6DAAqB;AAC/C,mBAAmB,mBAAO,CAAC,mEAAe;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,OAAO;AAClB;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,2DAA2D;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,gBAAgB;AAC/B,eAAe,EAAE;AACjB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,kBAAkB;AACjC;AACA,gBAAgB,EAAE;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,sCAAsC;AACrD,eAAe,gBAAgB;AAC/B,eAAe,QAAQ;AACvB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,KAAK;AACpB;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,eAAe;AAC/B;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,8BAA8B;AAC7C;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,UAAU;AAC1B;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA;AACA,sCAAsC,mBAAmB;;AAEzD;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA,CAAC;;AAED;AACA;AACA;AACA,cAAc,QAAQ;AACtB;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;AChlBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,oDAAkB;;AAEtC;AACA,cAAc;;AAEd;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,oCAAoC,aAAa;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;;;;;;;;;;;AChSA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,iBAAiB,mBAAO,CAAC,sEAA2B;;AAEpD;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,2BAA2B;AAC1C;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;;;;;;;;;;;ACjHA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,kCAAkC,WAAW;;AAE7C;;AAEA;AACA;;AAEA;;AAEA;;;;;;;;;;;;ACtFA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB,eAAe,QAAQ;AACvB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;;;;;;;;;;;AC7IA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,8BAA8B,OAAO;;AAErC;AACA;;AAEA;AACA;;AAEA;;AAEA;;;;;;;;;;;;ACpGA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA,aAAa,OAAO;AACpB;AACA,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,iBAAiB;AAC/B,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,8BAA8B;AACzC;AACA,YAAY,eAAe;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;;;;AChFA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,iBAAiB,mBAAO,CAAC,oDAAkB;AAC3C,sBAAsB,mBAAO,CAAC,iFAAmB;AACjD,gBAAgB,mBAAO,CAAC,8DAAuB;AAC/C,uBAAuB,mBAAO,CAAC,4EAA8B;;AAE7D;AACA,cAAc;;AAEd;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,8BAA8B,OAAO;AACrC,8BAA8B,OAAO;AACrC,8BAA8B,OAAO;AACrC,8BAA8B,OAAO;;AAErC;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,8BAA8B,OAAO;AACrC,8BAA8B,OAAO;AACrC,kCAAkC,0CAA0C;AAC5E,mCAAmC,4CAA4C;;AAE/E;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,oCAAoC,aAAa;;AAEjD;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,oCAAoC,aAAa;;AAEjD;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,8BAA8B,OAAO;AACrC,8BAA8B,OAAO;;AAErC;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,kCAAkC,WAAW;;AAE7C;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,kCAAkC,WAAW;;AAE7C;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,kCAAkC,WAAW;;AAE7C;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA,kCAAkC,WAAW;;AAE7C;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,8CAA8C;AAC7D;AACA,gBAAgB,8CAA8C;AAC9D;AACA;AACA;AACA,uCAAuC,oCAAoC;;AAE3E;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,8CAA8C;AAC7D,eAAe,8CAA8C;AAC7D;AACA,gBAAgB,8CAA8C;AAC9D;AACA;AACA;AACA,uCAAuC,oCAAoC;AAC3E,yCAAyC,sCAAsC;;AAE/E;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;;;;;;;;;;;;AC7cA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,sDAAmB;AACvC,cAAc,mBAAO,CAAC,wDAAoB;;AAE1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA;;AAEA;;AAEA;AACA;AACA,8BAA8B,OAAO;AACrC,8BAA8B,OAAO;AACrC,8BAA8B,OAAO;AACrC,8BAA8B,OAAO;AACrC,+BAA+B,QAAQ;AACvC,+BAA+B,QAAQ;;AAEvC;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,8CAA8C;AAC7D,eAAe,8CAA8C;AAC7D;AACA,gBAAgB,8CAA8C;AAC9D;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,8CAA8C;AAC7D,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,+CAA+C;AAC9D;AACA,gBAAgB,+CAA+C;AAC/D;AACA;AACA;AACA,kCAAkC,UAAU,cAAc;;AAE1D;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,8CAA8C;AAC7D;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA,gBAAgB,yBAAyB;AACzC;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,yBAAyB;AACxC;AACA,gBAAgB,yBAAyB;AACzC;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA,gBAAgB,MAAM;AACtB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA,mCAAmC,wBAAwB;;AAE3D;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,CAAC;;AAED;;;;;;;;;;;;ACx5BA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA,cAAc;;AAEd;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA,gBAAgB,KAAK;AACrB;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;;;;AClFA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,mDAAgB;AACpC,YAAY,mBAAO,CAAC,6CAAS;AAC7B,mBAAmB,mBAAO,CAAC,+EAA8B;AACzD,aAAa,mBAAO,CAAC,+CAAU;AAC/B,uBAAuB,mBAAO,CAAC,mEAAoB;AACnD,gBAAgB,mBAAO,CAAC,qDAAa;AACrC,kBAAkB,mBAAO,CAAC,yDAAe;;AAEzC;AACA,aAAa,OAAO;AACpB;AACA,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,2BAA2B;AACzC,cAAc,0BAA0B;AACxC,cAAc,IAAI;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2BAA2B;AACtC,WAAW,WAAW;AACtB;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA,4GAA4G;AAC5G;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA,2DAA2D;;AAE3D;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,mBAAmB;AAClC;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,eAAe;AAC9B,eAAe,cAAc;AAC7B;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,cAAc;AAC7B;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,cAAc;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,IAAI;AACnB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR;AACA;AACA;AACA,eAAe,IAAI;AACnB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,kBAAkB;;AAEnD;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,iBAAiB;AAC5B,WAAW,KAAK;AAChB,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,iEAAiE;AACjE;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,eAAe,2BAA2B;AAC1C;AACA;AACA;AACA,WAAW,iBAAiB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;AC9kBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,2BAA2B;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;;;;;;;;;;;AC1DA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,mBAAmB;AAC9B,WAAW,OAAO;AAClB;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;AClCA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,aAAa,mBAAO,CAAC,mEAAwB;AAC7C,kBAAkB,mBAAO,CAAC,yDAAe;;AAEzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,kBAAkB;AAC7B,WAAW,kBAAkB;AAC7B;AACA,YAAY,kBAAkB;AAC9B;AACA;AACA;AACA,mEAAmE;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;;;;ACzCA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,mDAAgB;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2BAA2B;AACtC,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,qBAAqB;AAChC;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA,uBAAuB,kBAAkB;AACzC;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,mBAAmB;AAClC;AACA,gBAAgB,wBAAwB;AACxC;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,mBAAmB;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,mBAAmB;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,CAAC;;AAED;;;;;;;;;;;;AC3LA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,uBAAuB,mBAAO,CAAC,mEAAoB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,mBAAmB;AAC9B,WAAW,kBAAkB;AAC7B;AACA,YAAY,eAAe;AAC3B;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;;AAEA;;;;;;;;;;;;AC7DA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA,aAAa,OAAO;AACpB;AACA,cAAc,2BAA2B;AACzC,cAAc,QAAQ;AACtB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,QAAQ;AACtB,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2BAA2B;AACtC,WAAW,QAAQ;AACnB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,QAAQ;AACnB;AACA,YAAY,kBAAkB;AAC9B;AACA;AACA;AACA,qCAAqC,mBAAmB;AACxD,8BAA8B,cAAc;AAC5C,6BAA6B,WAAW;AACxC,iCAAiC,eAAe;AAChD,gCAAgC,aAAa;;AAE7C;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;;;;ACvEA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;;AAEA;;;;;;;;;;;;ACjJA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,sDAAmB;AACvC,YAAY,mBAAO,CAAC,8CAAU;AAC9B,WAAW,mBAAO,CAAC,4CAAS;AAC5B,uBAAuB,mBAAO,CAAC,oEAAqB;AACpD,mBAAmB,mBAAO,CAAC,kFAAiC;AAC5D,oBAAoB,mBAAO,CAAC,oFAAkC;;AAE9D;AACA,aAAa,OAAO;AACpB;AACA,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB,cAAc,QAAQ;AACtB;;AAEA;AACA,aAAa,OAAO;AACpB;AACA,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,yCAAyC;AACvD,cAAc,kBAAkB;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2BAA2B;AACtC,WAAW,iDAAiD;AAC5D,WAAW,gBAAgB;AAC3B,WAAW,kBAAkB;AAC7B,WAAW,yCAAyC;AACpD;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2FAA2F;AACtG,WAAW,gBAAgB;AAC3B,WAAW,kBAAkB;AAC7B;AACA,YAAY,2BAA2B;AACvC;AACA;AACA;AACA;AACA;AACA,uBAAuB,gBAAgB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,CAAC;;AAED;;;;;;;;;;;;ACjSA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,sDAAmB;AACvC,YAAY,mBAAO,CAAC,8CAAU;AAC9B,WAAW,mBAAO,CAAC,4CAAS;AAC5B,uBAAuB,mBAAO,CAAC,oEAAqB;AACpD,mBAAmB,mBAAO,CAAC,kFAAiC;AAC5D,eAAe,mBAAO,CAAC,0EAA6B;AACpD,oBAAoB,mBAAO,CAAC,oFAAkC;;AAE9D;AACA,aAAa,OAAO;AACpB;AACA,cAAc,OAAO;AACrB,cAAc,WAAW;AACzB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,kBAAkB;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2BAA2B;AACtC,WAAW,gDAAgD;AAC3D,WAAW,OAAO;AAClB,WAAW,kBAAkB;AAC7B,WAAW,OAAO;AAClB;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B;AAC3B;AACA;AACA,QAAQ;AACR,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,yFAAyF;AACpG,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,kBAAkB;AAC7B;AACA,YAAY,2BAA2B;AACvC;AACA;AACA;AACA;AACA;AACA,uBAAuB,gBAAgB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,CAAC;;AAED;;;;;;;;;;;;ACzOA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,sDAAmB;AACvC,YAAY,mBAAO,CAAC,8CAAU;AAC9B,WAAW,mBAAO,CAAC,4CAAS;AAC5B,uBAAuB,mBAAO,CAAC,oEAAqB;AACpD,mBAAmB,mBAAO,CAAC,kFAAiC;AAC5D,oBAAoB,mBAAO,CAAC,oFAAkC;;AAE9D;AACA,aAAa,OAAO;AACpB;AACA,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,kBAAkB;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2BAA2B;AACtC,WAAW,gDAAgD;AAC3D,WAAW,OAAO;AAClB,WAAW,kBAAkB;AAC7B;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,yFAAyF;AACpG,WAAW,OAAO;AAClB,WAAW,kBAAkB;AAC7B;AACA,YAAY,2BAA2B;AACvC;AACA;AACA;AACA;AACA;AACA,uBAAuB,gBAAgB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,CAAC;;AAED;;;;;;;;;;;;ACjLA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;ACvBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;;AAEA,YAAY,mBAAO,CAAC,mDAAgB;;AAEpC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,oBAAoB;AAC/B;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,MAAM;AACrB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,0CAA0C;AACzD;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,0CAA0C;AACzD;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,0CAA0C;AACzD,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,uBAAuB;AACtC,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,uBAAuB;AACtC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC,eAAe,oBAAoB;AACnC,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC,eAAe,oBAAoB;AACnC,eAAe,oBAAoB;AACnC,eAAe,oBAAoB;AACnC,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,CAAC;;AAED;AACA;;AAEA;;;;;;;;;;;;AC/6CA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;;AAEA,YAAY,mBAAO,CAAC,mDAAgB;;AAEpC;AACA,aAAa,OAAO;AACpB;AACA,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,mBAAmB;AAC9B,WAAW,OAAO;AAClB;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,OAAO;;AAEzC;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,YAAY;AAC3B;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA,8BAA8B,OAAO;;AAErC;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA,6BAA6B,YAAY;;AAEzC;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,QAAQ;AACxB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,OAAO;AACvB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC,eAAe,OAAO;AACtB;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA,8BAA8B,OAAO;;AAErC;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,oBAAoB;AACnC;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,gBAAgB,oBAAoB;AACpC;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;;AAEA;;;;;;;;;;;;ACjkBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;;;;ACzBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,4CAAU;;AAE9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;ACjCA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,eAAe,mBAAO,CAAC,0CAAS;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;ACzBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,WAAW,mBAAO,CAAC,0CAAS;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;ACzBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;;AAEA;;AAEA;;;;;;;;;;;;AChEA;AACA;AACA;AACA,iBAAiB;AACjB;;AAEA,YAAY,mBAAO,CAAC,mDAAgB;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,6BAA6B;AACxC;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB;AAClB;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,KAAK;AACpB;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,CAAC;;AAED;;;;;;;;;;;;AC9KA;AACA;AACA;AACA,iBAAiB;AACjB;;AAEA,iBAAiB,mBAAO,CAAC,wDAAc;AACvC,YAAY,mBAAO,CAAC,mDAAgB;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,6BAA6B;AACxC;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,CAAC;;AAED;;;;;;;;;;;;ACjFA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;AChJA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,iDAAiD;AACjD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;;;;ACvOA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;ACpBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,oBAAoB,mBAAO,CAAC,mEAAiB;;AAE7C,WAAW,QAAQ;AACnB,WAAW,OAAO;AAClB,YAAY,OAAO;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA,YAAY,OAAO;AACnB;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;;;;;;;;;;;AC5FA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA,8CAA8C,aAAa,qBAAqB;AAChF;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,EAAE;AACb;AACA,YAAY,EAAE,oBAAoB;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;ACpCA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB,WAAW,OAAO;AAClB,WAAW,EAAE;AACb;AACA,YAAY,EAAE;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,uBAAuB,iBAAiB;AACxC;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;;;;;;;;;;;AChEA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,6CAA6C;AAC7C;AACA;;AAEA;;;;;;;;;;;;ACjDA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,6DAA0B;AAC9C,kBAAkB,mBAAO,CAAC,6EAAkC;AAC5D,gBAAgB,mBAAO,CAAC,mCAAa;AACrC,sBAAsB,mBAAO,CAAC,qEAA8B;;AAE5D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,6BAA6B;AACxC;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA,2BAA2B,gBAAgB;AAC3C;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,OAAO;AACtB,eAAe,iBAAiB;AAChC;AACA,gBAAgB,yBAAyB;AACzC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA,gBAAgB;AAChB,KAAK;;AAEL;AACA;AACA;AACA;;AAEA;;AAEA,gBAAgB;AAChB,KAAK;;AAEL;AACA;AACA;;AAEA;;AAEA,gBAAgB;AAChB,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,CAAC;;AAED;;;;;;;;;;;;AC7LA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,6DAA0B;AAC9C,mBAAmB,mBAAO,CAAC,yFAAwC;AACnE,gBAAgB,mBAAO,CAAC,8FAA4C;AACpE,oBAAoB,mBAAO,CAAC,2FAAyC;AACrE,eAAe,mBAAO,CAAC,4FAA2C;AAClE,gBAAgB,mBAAO,CAAC,0EAAkC;AAC1D,eAAe,mBAAO,CAAC,4FAA2C;;AAElE;AACA,aAAa,OAAO;AACpB;AACA,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,kBAAkB;AAChC,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,OAAO;AACrB,cAAc,kBAAkB;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2BAA2B;AACtC,WAAW,sDAAsD;AACjE,WAAW,gBAAgB;AAC3B,WAAW,OAAO;AAClB,WAAW,kBAAkB;AAC7B,WAAW,kBAAkB;AAC7B;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa;;AAEb;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,mBAAmB;AAClC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA,+BAA+B,oBAAoB;AACnD;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,+BAA+B,qBAAqB;AACpD;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA,2BAA2B,uBAAuB;AAClD;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,2FAA2F;AACtG,WAAW,gBAAgB;AAC3B,WAAW,OAAO;AAClB,WAAW,kBAAkB;AAC7B,WAAW,kBAAkB;AAC7B;AACA,YAAY,2BAA2B;AACvC;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAuB,gBAAgB;AACvC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA,CAAC;AACD;;AAEA;;;;;;;;;;;;ACpUA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,6DAA0B;AAC9C,sBAAsB,mBAAO,CAAC,+CAAmB;AACjD,iBAAiB,mBAAO,CAAC,6CAAY;AACrC,cAAc,mBAAO,CAAC,+DAA2B;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,6BAA6B;AACxC;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA,SAAS;;AAET;AACA;;AAEA,CAAC;;AAED;;;;;;;;;;;;ACzFA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,YAAY,mBAAO,CAAC,gEAA6B;AACjD,sBAAsB,mBAAO,CAAC,kGAA8C;AAC5E,0BAA0B,mBAAO,CAAC,0GAAkD;AACpF,sBAAsB,mBAAO,CAAC,kGAA8C;AAC5E,qBAAqB,mBAAO,CAAC,gGAA6C;AAC1E,6BAA6B,mBAAO,CAAC,gHAAqD;AAC1F,0BAA0B,mBAAO,CAAC,0GAAkD;AACpF,wBAAwB,mBAAO,CAAC,sGAAgD;AAChF,iBAAiB,mBAAO,CAAC,sFAAwC;AACjE,4BAA4B,mBAAO,CAAC,sEAAyB;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,aAAa;AACxB,WAAW,6BAA6B;AACxC;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA,aAAa;AACb;AACA;AACA;AACA;AACA;AACA,SAAS;;AAET;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,2BAA2B,oCAAoC;AAC/D;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA,CAAC;;AAED;;;;;;;;;;;;ACzSA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,kBAAkB,mBAAO,CAAC,8DAA4B;AACtD,mBAAmB,mBAAO,CAAC,8DAA4B;;AAEvD,IAAI,IAAqB;AACzB;AACA,kBAAkB,mBAAO,CAAC,oFAAgC;AAC1D;;AAEA,IAAI,KAAsB;AAC1B,EAEC;;AAED;;AAEA;AACA;;AAEA;;;;;;;;;;;;ACxBA;AACA;AACA;AACA,kBAAkB;AAClB;;AAEA,uBAAuB,mBAAO,CAAC,gGAA6C;;AAE5E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW,sCAAsC;AACjD,WAAW,mCAAmC;AAC9C,WAAW,OAAO;AAClB,WAAW,8BAA8B;AACzC,WAAW,8CAA8C;AACzD;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;;AAEA;;AAEA;AACA;;AAEA;AACA;;AAEA;;;;;;;;;;;;ACxHA;AACA;;AAEA;AACA;AACA,IAAI,gBAAgB,sCAAsC,iBAAiB,EAAE;AAC7E,mBAAmB,uDAAuD;AAC1E;AACA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,OAAO;AAC/C;AACA;AACA;AACA,yBAAyB,UAAU;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,WAAW;AAC1D;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,gDAAgD;AAClD;AACA;AACA;AACA;AACA,EAAE,+DAA+D;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,+DAA+D;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kDAAkD,OAAO;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6DAA6D,OAAO;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,iBAAiB;AACvC;AACA;AACA;AACA;AACA,sBAAsB,iBAAiB;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,mBAAmB;AAC1C;AACA;AACA;AACA;AACA;AACA,uBAAuB,mBAAmB;AAC1C;AACA;AACA;AACA;AACA,sBAAsB,mBAAmB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,mBAAmB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,mBAAmB;AACzC;AACA;AACA;AACA;AACA;AACA,sBAAsB,mBAAmB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,mBAAmB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,6CAA6C;AACtD;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,OAAO;AAC5D;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,yBAAyB,EAAE;AAChF;AACA;AACA;AACA;AACA;AACA,qCAAqC,OAAO;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,OAAO;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,oBAAoB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,oBAAoB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,mBAAmB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,oBAAoB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,SAAS;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,OAAO;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,oBAAoB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uBAAuB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uBAAuB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uBAAuB;AAC7C;AACA;AACA;AACA;AACA;AACA,sBAAsB,uBAAuB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uBAAuB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uBAAuB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,sDAAsD;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,gBAAgB;AAC5C,0BAA0B,cAAc;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA,4BAA4B,gBAAgB;AAC5C,0BAA0B,cAAc;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,gBAAgB;AAC5C,0BAA0B,cAAc;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAA4B,gBAAgB;AAC5C,0BAA0B,cAAc;AACxC;AACA;AACA;AACA;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iFAAiF;AACjF;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;AACA;AACA,gFAAgF;AAChF;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,+CAA+C,0BAA0B;AACzE;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,sDAAsD;AACxD,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,kEAAkE;AACpE,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,uBAAuB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,OAAO;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,OAAO;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,eAAe;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,iBAAiB;AACrC;AACA;AACA;AACA,qCAAqC,iBAAiB;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,gBAAgB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA,iDAAiD,iBAAiB;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA,EAAE,+DAA+D;AACjE;AACA;AACA;AACA;AACA;AACA,EAAE,4DAA4D;AAC9D;AACA;AACA;AACA;AACA;AACA,EAAE,yDAAyD;AAC3D,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,gCAAgC;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,uBAAuB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,uBAAuB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,+BAA+B;AACjD;AACA;AACA;AACA;AACA,kBAAkB,sCAAsC;AACxD;AACA;AACA;AACA;AACA,kBAAkB,iCAAiC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,qBAAqB;AAC9C,oBAAoB,cAAc;AAClC;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,qBAAqB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,gBAAgB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,OAAO;AACrD;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,eAAe;AACjC;AACA;AACA,kBAAkB,eAAe;AACjC;AACA,kBAAkB,eAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,eAAe;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,eAAe;AAClC;AACA;AACA;AACA;AACA,mBAAmB,gBAAgB;AACnC;AACA,mBAAmB,gBAAgB;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,OAAO;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,OAAO;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA,4CAA4C,OAAO;AACnD;AACA;AACA;AACA;AACA;AACA,mDAAmD,OAAO;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,OAAO;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C,OAAO;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,OAAO;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,OAAO;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,OAAO;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,SAAS;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,eAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC,OAAO;AAC9C;AACA;AACA,yCAAyC,SAAS;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC,OAAO;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC,OAAO;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAiD,SAAS;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,qBAAqB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,mBAAmB;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,uBAAuB;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,sBAAsB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB;AACnB;AACA;AACA;AACA;AACA;AACA,oBAAoB,0BAA0B;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,OAAO;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uEAAuE,OAAO;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,OAAO;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,OAAO;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C,OAAO;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAAmD,OAAO;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,OAAO;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,OAAO;AACrD;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,uBAAuB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,uBAAuB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,oBAAoB;AACvC;AACA;AACA;AACA,oBAAoB,gCAAgC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,2BAA2B;AAC9C;AACA;AACA;AACA,oBAAoB,gCAAgC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,sBAAsB;AACzC;AACA;AACA;AACA,oBAAoB,gCAAgC;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,OAAO;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,wBAAwB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,OAAO;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC,OAAO;AAC9C;AACA;AACA,oCAAoC,QAAQ;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,0BAA0B;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,0BAA0B;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2DAA2D,OAAO;AAClE;AACA;AACA;AACA,yBAAyB,kBAAkB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,0BAA0B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,oBAAoB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,QAAQ;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,uBAAuB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,2BAA2B;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,kEAAkE;AACpE;AACA;AACA;AACA;AACA;AACA,EAAE,4DAA4D;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA,sEAAsE;AACtE,4DAA4D;AAC5D,+CAA+C;AAC/C;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,yBAAyB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,uBAAuB;AACzC;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,OAAO;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,uBAAuB;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,OAAO;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,iBAAiB;AACnC;AACA;AACA;AACA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C,gBAAgB;AAC7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,OAAO;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,6CAA6C,OAAO;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,QAAQ;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0CAA0C,QAAQ;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA,sBAAsB,OAAO;AAC7B,sBAAsB,OAAO;AAC7B,sBAAsB,OAAO;AAC7B,sBAAsB,OAAO;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA,2CAA2C,+BAA+B;AAC1E;AACA;AACA;AACA;AACA,0BAA0B,WAAW;AACrC;AACA;AACA;AACA;AACA;AACA,yBAAyB,UAAU;AACnC;AACA;AACA;AACA;AACA;AACA,0BAA0B,WAAW;AACrC;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,UAAU;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA,kBAAkB,2BAA2B;AAC7C;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,kBAAkB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA,sBAAsB,OAAO;AAC7B,sBAAsB,OAAO;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA,+BAA+B,iBAAiB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,wBAAwB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qCAAqC,WAAW;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,WAAW;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,WAAW;AACjD;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qDAAqD,WAAW;AAChE;AACA;AACA;AACA,WAAW,OAAO;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,qEAAqE;AACvE,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;AACA;AACA,mCAAmC,OAAO;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE;AACF;AACA,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,iBAAiB;AACjD;AACA;AACA,KAAK;AACL;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,oBAAoB;AACpD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAA0B,UAAU;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,sBAAsB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,sBAAsB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,sBAAsB;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,oBAAoB,oBAAoB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,wBAAwB;AAC9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,oBAAoB,oBAAoB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB,wBAAwB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,oBAAoB,oBAAoB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,yBAAyB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,oBAAoB,oBAAoB;AACxC;AACA;AACA;AACA;AACA;AACA;AACA,yBAAyB,yBAAyB;AAClD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8BAA8B,kBAAkB;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD;AAChD,mDAAmD;AACnD;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,uBAAuB;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C,wBAAwB;AACvE,6CAA6C,sDAAsD;AACnG,6CAA6C,qDAAqD;AAClG;AACA;AACA;AACA;AACA,6CAA6C,sBAAsB;AACnE,4CAA4C,4BAA4B;AACxE,4CAA4C,2BAA2B;AACvE;AACA;AACA;AACA;AACA,4CAA4C,qBAAqB;AACjE;AACA;AACA;AACA,mBAAmB,4BAA4B;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,4BAA4B;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mBAAmB,4BAA4B;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,0BAA0B,UAAU;AACpC;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA,GAAG,oFAAoF;AACvF,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,qBAAqB;AACvD,iCAAiC,qBAAqB;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2C,oBAAoB;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wDAAwD,uBAAuB;AAC/E;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,qBAAqB;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,4BAA4B;AACpE,oCAAoC,qBAAqB;AACzD,kCAAkC,mBAAmB;AACrD;AACA;AACA;AACA;AACA;AACA,wCAAwC,4BAA4B;AACpE,kCAAkC,qBAAqB;AACvD;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC,wCAAwC,4BAA4B;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC,wCAAwC,4BAA4B;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC,4BAA4B,eAAe;AAC3C;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC,4BAA4B,eAAe;AAC3C,4BAA4B,eAAe;AAC3C;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC,4BAA4B,eAAe;AAC3C,4BAA4B,eAAe;AAC3C,4BAA4B,eAAe;AAC3C;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC,8BAA8B,cAAc;AAC5C;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,yDAAyD;AAC5D,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,qBAAqB;AACnE,mDAAmD,0BAA0B;AAC7E,qDAAqD,4BAA4B;AACjF,yDAAyD,sBAAsB;AAC/E,qDAAqD,sBAAsB;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+DAA+D,8CAA8C,kDAAkD,iDAAiD,+BAA+B,mCAAmC,0BAA0B,2CAA2C,mDAAmD,8EAA8E,WAAW;AACne,qGAAqG,2FAA2F,mCAAmC,sCAAsC,0BAA0B,uEAAuE,WAAW;AACrX;AACA;AACA;AACA,+DAA+D,8CAA8C,+CAA+C,kDAAkD,iDAAiD,+BAA+B,8BAA8B,mCAAmC,0BAA0B,2CAA2C,2CAA2C,mDAAmD,8EAA8E,WAAW;AAC3lB,qGAAqG,2FAA2F,mCAAmC,mCAAmC,sCAAsC,0BAA0B,8DAA8D,oDAAoD,8HAA8H,WAAW;AACjkB;AACA;AACA;AACA,+DAA+D,8CAA8C,iDAAiD,+BAA+B,0BAA0B,2CAA2C,8EAA8E,WAAW;AAC3V,qGAAqG,2FAA2F,0BAA0B,mCAAmC,WAAW;AACxQ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,iCAAiC,qBAAqB;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC,4BAA4B,eAAe;AAC3C,4BAA4B,eAAe;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC,4BAA4B,eAAe;AAC3C,4BAA4B,eAAe;AAC3C,4BAA4B,eAAe;AAC3C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gDAAgD,OAAO;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC,8BAA8B,cAAc;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,cAAc;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,cAAc;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2BAA2B,cAAc;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,sDAAsD;AACzD,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,qBAAqB;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8CAA8C,SAAS;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,SAAS;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,OAAO;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsB,SAAS;AAC/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,OAAO;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4CAA4C,YAAY;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA,kCAAkC,qBAAqB;AACvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,qBAAqB;AACzD,kCAAkC,mBAAmB;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yCAAyC,OAAO;AAChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD,SAAS;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sDAAsD,SAAS;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2DAA2D,SAAS;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2DAA2D,SAAS;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2DAA2D,SAAS;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2DAA2D,SAAS;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAC9B,uBAAuB,OAAO;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC,kBAAkB,iBAAiB;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA,mDAAmD,OAAO;AAC1D;AACA;AACA,MAAM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wCAAwC,4BAA4B;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA,EAAE,0CAA0C;AAC5C,CAAC,sBAAsB;AACvB;;AAEA;AACA;AACA,CAAC,e","file":"SpineWebGLPlugin.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SpineWebGLPlugin\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SpineWebGLPlugin\"] = factory();\n\telse\n\t\troot[\"SpineWebGLPlugin\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./SpineWebGLPlugin.js\");\n","'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../utils/Class');\n\n/**\n * @callback DataEachCallback\n *\n * @param {*} parent - The parent object of the DataManager.\n * @param {string} key - The key of the value.\n * @param {*} value - The value.\n * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data.\n */\n\n/**\n * @classdesc\n * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin.\n * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter,\n * or have a property called `events` that is an instance of it.\n *\n * @class DataManager\n * @memberof Phaser.Data\n * @constructor\n * @since 3.0.0\n *\n * @param {object} parent - The object that this DataManager belongs to.\n * @param {Phaser.Events.EventEmitter} eventEmitter - The DataManager's event emitter.\n */\nvar DataManager = new Class({\n\n initialize:\n\n function DataManager (parent, eventEmitter)\n {\n /**\n * The object that this DataManager belongs to.\n *\n * @name Phaser.Data.DataManager#parent\n * @type {*}\n * @since 3.0.0\n */\n this.parent = parent;\n\n /**\n * The DataManager's event emitter.\n *\n * @name Phaser.Data.DataManager#events\n * @type {Phaser.Events.EventEmitter}\n * @since 3.0.0\n */\n this.events = eventEmitter;\n\n if (!eventEmitter)\n {\n this.events = (parent.events) ? parent.events : parent;\n }\n\n /**\n * The data list.\n *\n * @name Phaser.Data.DataManager#list\n * @type {Object.}\n * @default {}\n * @since 3.0.0\n */\n this.list = {};\n\n /**\n * The public values list. You can use this to access anything you have stored\n * in this Data Manager. For example, if you set a value called `gold` you can\n * access it via:\n *\n * ```javascript\n * this.data.values.gold;\n * ```\n *\n * You can also modify it directly:\n * \n * ```javascript\n * this.data.values.gold += 1000;\n * ```\n *\n * Doing so will emit a `setdata` event from the parent of this Data Manager.\n * \n * Do not modify this object directly. Adding properties directly to this object will not\n * emit any events. Always use `DataManager.set` to create new items the first time around.\n *\n * @name Phaser.Data.DataManager#values\n * @type {Object.}\n * @default {}\n * @since 3.10.0\n */\n this.values = {};\n\n /**\n * Whether setting data is frozen for this DataManager.\n *\n * @name Phaser.Data.DataManager#_frozen\n * @type {boolean}\n * @private\n * @default false\n * @since 3.0.0\n */\n this._frozen = false;\n\n if (!parent.hasOwnProperty('sys') && this.events)\n {\n this.events.once('destroy', this.destroy, this);\n }\n },\n\n /**\n * Retrieves the value for the given key, or undefined if it doesn't exist.\n *\n * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either:\n * \n * ```javascript\n * this.data.get('gold');\n * ```\n *\n * Or access the value directly:\n * \n * ```javascript\n * this.data.values.gold;\n * ```\n *\n * You can also pass in an array of keys, in which case an array of values will be returned:\n * \n * ```javascript\n * this.data.get([ 'gold', 'armor', 'health' ]);\n * ```\n *\n * This approach is useful for destructuring arrays in ES6.\n *\n * @method Phaser.Data.DataManager#get\n * @since 3.0.0\n *\n * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys.\n *\n * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array.\n */\n get: function (key)\n {\n var list = this.list;\n\n if (Array.isArray(key))\n {\n var output = [];\n\n for (var i = 0; i < key.length; i++)\n {\n output.push(list[key[i]]);\n }\n\n return output;\n }\n else\n {\n return list[key];\n }\n },\n\n /**\n * Retrieves all data values in a new object.\n *\n * @method Phaser.Data.DataManager#getAll\n * @since 3.0.0\n *\n * @return {Object.} All data values.\n */\n getAll: function ()\n {\n var results = {};\n\n for (var key in this.list)\n {\n if (this.list.hasOwnProperty(key))\n {\n results[key] = this.list[key];\n }\n }\n\n return results;\n },\n\n /**\n * Queries the DataManager for the values of keys matching the given regular expression.\n *\n * @method Phaser.Data.DataManager#query\n * @since 3.0.0\n *\n * @param {RegExp} search - A regular expression object. If a non-RegExp object obj is passed, it is implicitly converted to a RegExp by using new RegExp(obj).\n *\n * @return {Object.} The values of the keys matching the search string.\n */\n query: function (search)\n {\n var results = {};\n\n for (var key in this.list)\n {\n if (this.list.hasOwnProperty(key) && key.match(search))\n {\n results[key] = this.list[key];\n }\n }\n\n return results;\n },\n\n /**\n * Sets a value for the given key. If the key doesn't already exist in the Data Manager then it is created.\n * \n * ```javascript\n * data.set('name', 'Red Gem Stone');\n * ```\n *\n * You can also pass in an object of key value pairs as the first argument:\n *\n * ```javascript\n * data.set({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 });\n * ```\n *\n * To get a value back again you can call `get`:\n * \n * ```javascript\n * data.get('gold');\n * ```\n * \n * Or you can access the value directly via the `values` property, where it works like any other variable:\n * \n * ```javascript\n * data.values.gold += 50;\n * ```\n *\n * When the value is first set, a `setdata` event is emitted.\n *\n * If the key already exists, a `changedata` event is emitted instead, along an event named after the key.\n * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`.\n * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter.\n *\n * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings.\n * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager.\n *\n * @method Phaser.Data.DataManager#set\n * @since 3.0.0\n *\n * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored.\n * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored.\n *\n * @return {Phaser.Data.DataManager} This DataManager object.\n */\n set: function (key, data)\n {\n if (this._frozen)\n {\n return this;\n }\n\n if (typeof key === 'string')\n {\n return this.setValue(key, data);\n }\n else\n {\n for (var entry in key)\n {\n this.setValue(entry, key[entry]);\n }\n }\n\n return this;\n },\n\n /**\n * Internal value setter, called automatically by the `set` method.\n *\n * @method Phaser.Data.DataManager#setValue\n * @private\n * @since 3.10.0\n *\n * @param {string} key - The key to set the value for.\n * @param {*} data - The value to set.\n *\n * @return {Phaser.Data.DataManager} This DataManager object.\n */\n setValue: function (key, data)\n {\n if (this._frozen)\n {\n return this;\n }\n\n if (this.has(key))\n {\n // Hit the key getter, which will in turn emit the events.\n this.values[key] = data;\n }\n else\n {\n var _this = this;\n var list = this.list;\n var events = this.events;\n var parent = this.parent;\n\n Object.defineProperty(this.values, key, {\n\n enumerable: true,\n \n configurable: true,\n\n get: function ()\n {\n return list[key];\n },\n\n set: function (value)\n {\n if (!_this._frozen)\n {\n var previousValue = list[key];\n list[key] = value;\n\n events.emit('changedata', parent, key, value, previousValue);\n events.emit('changedata_' + key, parent, value, previousValue);\n }\n }\n\n });\n\n list[key] = data;\n\n events.emit('setdata', parent, key, data);\n }\n\n return this;\n },\n\n /**\n * Passes all data entries to the given callback.\n *\n * @method Phaser.Data.DataManager#each\n * @since 3.0.0\n *\n * @param {DataEachCallback} callback - The function to call.\n * @param {*} [context] - Value to use as `this` when executing callback.\n * @param {...*} [args] - Additional arguments that will be passed to the callback, after the game object, key, and data.\n *\n * @return {Phaser.Data.DataManager} This DataManager object.\n */\n each: function (callback, context)\n {\n var args = [ this.parent, null, undefined ];\n\n for (var i = 1; i < arguments.length; i++)\n {\n args.push(arguments[i]);\n }\n\n for (var key in this.list)\n {\n args[1] = key;\n args[2] = this.list[key];\n\n callback.apply(context, args);\n }\n\n return this;\n },\n\n /**\n * Merge the given object of key value pairs into this DataManager.\n *\n * Any newly created values will emit a `setdata` event. Any updated values (see the `overwrite` argument)\n * will emit a `changedata` event.\n *\n * @method Phaser.Data.DataManager#merge\n * @since 3.0.0\n *\n * @param {Object.} data - The data to merge.\n * @param {boolean} [overwrite=true] - Whether to overwrite existing data. Defaults to true.\n *\n * @return {Phaser.Data.DataManager} This DataManager object.\n */\n merge: function (data, overwrite)\n {\n if (overwrite === undefined) { overwrite = true; }\n\n // Merge data from another component into this one\n for (var key in data)\n {\n if (data.hasOwnProperty(key) && (overwrite || (!overwrite && !this.has(key))))\n {\n this.setValue(key, data[key]);\n }\n }\n\n return this;\n },\n\n /**\n * Remove the value for the given key.\n *\n * If the key is found in this Data Manager it is removed from the internal lists and a\n * `removedata` event is emitted.\n * \n * You can also pass in an array of keys, in which case all keys in the array will be removed:\n * \n * ```javascript\n * this.data.remove([ 'gold', 'armor', 'health' ]);\n * ```\n *\n * @method Phaser.Data.DataManager#remove\n * @since 3.0.0\n *\n * @param {(string|string[])} key - The key to remove, or an array of keys to remove.\n *\n * @return {Phaser.Data.DataManager} This DataManager object.\n */\n remove: function (key)\n {\n if (this._frozen)\n {\n return this;\n }\n\n if (Array.isArray(key))\n {\n for (var i = 0; i < key.length; i++)\n {\n this.removeValue(key[i]);\n }\n }\n else\n {\n return this.removeValue(key);\n }\n\n return this;\n },\n\n /**\n * Internal value remover, called automatically by the `remove` method.\n *\n * @method Phaser.Data.DataManager#removeValue\n * @private\n * @since 3.10.0\n *\n * @param {string} key - The key to set the value for.\n *\n * @return {Phaser.Data.DataManager} This DataManager object.\n */\n removeValue: function (key)\n {\n if (this.has(key))\n {\n var data = this.list[key];\n\n delete this.list[key];\n delete this.values[key];\n\n this.events.emit('removedata', this.parent, key, data);\n }\n\n return this;\n },\n\n /**\n * Retrieves the data associated with the given 'key', deletes it from this Data Manager, then returns it.\n *\n * @method Phaser.Data.DataManager#pop\n * @since 3.0.0\n *\n * @param {string} key - The key of the value to retrieve and delete.\n *\n * @return {*} The value of the given key.\n */\n pop: function (key)\n {\n var data = undefined;\n\n if (!this._frozen && this.has(key))\n {\n data = this.list[key];\n\n delete this.list[key];\n delete this.values[key];\n\n this.events.emit('removedata', this, key, data);\n }\n\n return data;\n },\n\n /**\n * Determines whether the given key is set in this Data Manager.\n * \n * Please note that the keys are case-sensitive and must be valid JavaScript Object property strings.\n * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager.\n *\n * @method Phaser.Data.DataManager#has\n * @since 3.0.0\n *\n * @param {string} key - The key to check.\n *\n * @return {boolean} Returns `true` if the key exists, otherwise `false`.\n */\n has: function (key)\n {\n return this.list.hasOwnProperty(key);\n },\n\n /**\n * Freeze or unfreeze this Data Manager. A frozen Data Manager will block all attempts\n * to create new values or update existing ones.\n *\n * @method Phaser.Data.DataManager#setFreeze\n * @since 3.0.0\n *\n * @param {boolean} value - Whether to freeze or unfreeze the Data Manager.\n *\n * @return {Phaser.Data.DataManager} This DataManager object.\n */\n setFreeze: function (value)\n {\n this._frozen = value;\n\n return this;\n },\n\n /**\n * Delete all data in this Data Manager and unfreeze it.\n *\n * @method Phaser.Data.DataManager#reset\n * @since 3.0.0\n *\n * @return {Phaser.Data.DataManager} This DataManager object.\n */\n reset: function ()\n {\n for (var key in this.list)\n {\n delete this.list[key];\n delete this.values[key];\n }\n\n this._frozen = false;\n\n return this;\n },\n\n /**\n * Destroy this data manager.\n *\n * @method Phaser.Data.DataManager#destroy\n * @since 3.0.0\n */\n destroy: function ()\n {\n this.reset();\n\n this.events.off('changedata');\n this.events.off('setdata');\n this.events.off('removedata');\n\n this.parent = null;\n },\n\n /**\n * Gets or sets the frozen state of this Data Manager.\n * A frozen Data Manager will block all attempts to create new values or update existing ones.\n *\n * @name Phaser.Data.DataManager#freeze\n * @type {boolean}\n * @since 3.0.0\n */\n freeze: {\n\n get: function ()\n {\n return this._frozen;\n },\n\n set: function (value)\n {\n this._frozen = (value) ? true : false;\n }\n\n },\n\n /**\n * Return the total number of entries in this Data Manager.\n *\n * @name Phaser.Data.DataManager#count\n * @type {integer}\n * @since 3.0.0\n */\n count: {\n\n get: function ()\n {\n var i = 0;\n\n for (var key in this.list)\n {\n if (this.list[key] !== undefined)\n {\n i++;\n }\n }\n\n return i;\n }\n\n }\n\n});\n\nmodule.exports = DataManager;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../utils/Class');\nvar ComponentsToJSON = require('./components/ToJSON');\nvar DataManager = require('../data/DataManager');\nvar EventEmitter = require('eventemitter3');\n\n/**\n * @classdesc\n * The base class that all Game Objects extend.\n * You don't create GameObjects directly and they cannot be added to the display list.\n * Instead, use them as the base for your own custom classes.\n *\n * @class GameObject\n * @memberof Phaser.GameObjects\n * @extends Phaser.Events.EventEmitter\n * @constructor\n * @since 3.0.0\n *\n * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs.\n * @param {string} type - A textual representation of the type of Game Object, i.e. `sprite`.\n */\nvar GameObject = new Class({\n\n Extends: EventEmitter,\n\n initialize:\n\n function GameObject (scene, type)\n {\n EventEmitter.call(this);\n\n /**\n * The Scene to which this Game Object belongs.\n * Game Objects can only belong to one Scene.\n *\n * @name Phaser.GameObjects.GameObject#scene\n * @type {Phaser.Scene}\n * @protected\n * @since 3.0.0\n */\n this.scene = scene;\n\n /**\n * A textual representation of this Game Object, i.e. `sprite`.\n * Used internally by Phaser but is available for your own custom classes to populate.\n *\n * @name Phaser.GameObjects.GameObject#type\n * @type {string}\n * @since 3.0.0\n */\n this.type = type;\n\n /**\n * The parent Container of this Game Object, if it has one.\n *\n * @name Phaser.GameObjects.GameObject#parentContainer\n * @type {Phaser.GameObjects.Container}\n * @since 3.4.0\n */\n this.parentContainer = null;\n\n /**\n * The name of this Game Object.\n * Empty by default and never populated by Phaser, this is left for developers to use.\n *\n * @name Phaser.GameObjects.GameObject#name\n * @type {string}\n * @default ''\n * @since 3.0.0\n */\n this.name = '';\n\n /**\n * The active state of this Game Object.\n * A Game Object with an active state of `true` is processed by the Scenes UpdateList, if added to it.\n * An active object is one which is having its logic and internal systems updated.\n *\n * @name Phaser.GameObjects.GameObject#active\n * @type {boolean}\n * @default true\n * @since 3.0.0\n */\n this.active = true;\n\n /**\n * The Tab Index of the Game Object.\n * Reserved for future use by plugins and the Input Manager.\n *\n * @name Phaser.GameObjects.GameObject#tabIndex\n * @type {integer}\n * @default -1\n * @since 3.0.0\n */\n this.tabIndex = -1;\n\n /**\n * A Data Manager.\n * It allows you to store, query and get key/value paired information specific to this Game Object.\n * `null` by default. Automatically created if you use `getData` or `setData` or `setDataEnabled`.\n *\n * @name Phaser.GameObjects.GameObject#data\n * @type {Phaser.Data.DataManager}\n * @default null\n * @since 3.0.0\n */\n this.data = null;\n\n /**\n * The flags that are compared against `RENDER_MASK` to determine if this Game Object will render or not.\n * The bits are 0001 | 0010 | 0100 | 1000 set by the components Visible, Alpha, Transform and Texture respectively.\n * If those components are not used by your custom class then you can use this bitmask as you wish.\n *\n * @name Phaser.GameObjects.GameObject#renderFlags\n * @type {integer}\n * @default 15\n * @since 3.0.0\n */\n this.renderFlags = 15;\n\n /**\n * A bitmask that controls if this Game Object is drawn by a Camera or not.\n * Not usually set directly, instead call `Camera.ignore`, however you can\n * set this property directly using the Camera.id property:\n *\n * @example\n * this.cameraFilter |= camera.id\n *\n * @name Phaser.GameObjects.GameObject#cameraFilter\n * @type {number}\n * @default 0\n * @since 3.0.0\n */\n this.cameraFilter = 0;\n\n /**\n * If this Game Object is enabled for input then this property will contain an InteractiveObject instance.\n * Not usually set directly. Instead call `GameObject.setInteractive()`.\n *\n * @name Phaser.GameObjects.GameObject#input\n * @type {?Phaser.Input.InteractiveObject}\n * @default null\n * @since 3.0.0\n */\n this.input = null;\n\n /**\n * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body.\n *\n * @name Phaser.GameObjects.GameObject#body\n * @type {?(object|Phaser.Physics.Arcade.Body|Phaser.Physics.Impact.Body)}\n * @default null\n * @since 3.0.0\n */\n this.body = null;\n\n /**\n * This Game Object will ignore all calls made to its destroy method if this flag is set to `true`.\n * This includes calls that may come from a Group, Container or the Scene itself.\n * While it allows you to persist a Game Object across Scenes, please understand you are entirely\n * responsible for managing references to and from this Game Object.\n *\n * @name Phaser.GameObjects.GameObject#ignoreDestroy\n * @type {boolean}\n * @default false\n * @since 3.5.0\n */\n this.ignoreDestroy = false;\n\n // Tell the Scene to re-sort the children\n scene.sys.queueDepthSort();\n },\n\n /**\n * Sets the `active` property of this Game Object and returns this Game Object for further chaining.\n * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList.\n *\n * @method Phaser.GameObjects.GameObject#setActive\n * @since 3.0.0\n *\n * @param {boolean} value - True if this Game Object should be set as active, false if not.\n *\n * @return {this} This GameObject.\n */\n setActive: function (value)\n {\n this.active = value;\n\n return this;\n },\n\n /**\n * Sets the `name` property of this Game Object and returns this Game Object for further chaining.\n * The `name` property is not populated by Phaser and is presented for your own use.\n *\n * @method Phaser.GameObjects.GameObject#setName\n * @since 3.0.0\n *\n * @param {string} value - The name to be given to this Game Object.\n *\n * @return {this} This GameObject.\n */\n setName: function (value)\n {\n this.name = value;\n\n return this;\n },\n\n /**\n * Adds a Data Manager component to this Game Object.\n *\n * @method Phaser.GameObjects.GameObject#setDataEnabled\n * @since 3.0.0\n * @see Phaser.Data.DataManager\n *\n * @return {this} This GameObject.\n */\n setDataEnabled: function ()\n {\n if (!this.data)\n {\n this.data = new DataManager(this);\n }\n\n return this;\n },\n\n /**\n * Allows you to store a key value pair within this Game Objects Data Manager.\n *\n * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled\n * before setting the value.\n *\n * If the key doesn't already exist in the Data Manager then it is created.\n *\n * ```javascript\n * sprite.setData('name', 'Red Gem Stone');\n * ```\n *\n * You can also pass in an object of key value pairs as the first argument:\n *\n * ```javascript\n * sprite.setData({ name: 'Red Gem Stone', level: 2, owner: 'Link', gold: 50 });\n * ```\n *\n * To get a value back again you can call `getData`:\n *\n * ```javascript\n * sprite.getData('gold');\n * ```\n *\n * Or you can access the value directly via the `values` property, where it works like any other variable:\n *\n * ```javascript\n * sprite.data.values.gold += 50;\n * ```\n *\n * When the value is first set, a `setdata` event is emitted from this Game Object.\n *\n * If the key already exists, a `changedata` event is emitted instead, along an event named after the key.\n * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`.\n * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter.\n *\n * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings.\n * This means the keys `gold` and `Gold` are treated as two unique values within the Data Manager.\n *\n * @method Phaser.GameObjects.GameObject#setData\n * @since 3.0.0\n *\n * @param {(string|object)} key - The key to set the value for. Or an object or key value pairs. If an object the `data` argument is ignored.\n * @param {*} data - The value to set for the given key. If an object is provided as the key this argument is ignored.\n *\n * @return {this} This GameObject.\n */\n setData: function (key, value)\n {\n if (!this.data)\n {\n this.data = new DataManager(this);\n }\n\n this.data.set(key, value);\n\n return this;\n },\n\n /**\n * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist.\n *\n * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either:\n *\n * ```javascript\n * sprite.getData('gold');\n * ```\n *\n * Or access the value directly:\n *\n * ```javascript\n * sprite.data.values.gold;\n * ```\n *\n * You can also pass in an array of keys, in which case an array of values will be returned:\n *\n * ```javascript\n * sprite.getData([ 'gold', 'armor', 'health' ]);\n * ```\n *\n * This approach is useful for destructuring arrays in ES6.\n *\n * @method Phaser.GameObjects.GameObject#getData\n * @since 3.0.0\n *\n * @param {(string|string[])} key - The key of the value to retrieve, or an array of keys.\n *\n * @return {*} The value belonging to the given key, or an array of values, the order of which will match the input array.\n */\n getData: function (key)\n {\n if (!this.data)\n {\n this.data = new DataManager(this);\n }\n\n return this.data.get(key);\n },\n\n /**\n * Pass this Game Object to the Input Manager to enable it for Input.\n *\n * Input works by using hit areas, these are nearly always geometric shapes, such as rectangles or circles, that act as the hit area\n * for the Game Object. However, you can provide your own hit area shape and callback, should you wish to handle some more advanced\n * input detection.\n *\n * If no arguments are provided it will try and create a rectangle hit area based on the texture frame the Game Object is using. If\n * this isn't a texture-bound object, such as a Graphics or BitmapText object, this will fail, and you'll need to provide a specific\n * shape for it to use.\n *\n * You can also provide an Input Configuration Object as the only argument to this method.\n *\n * @method Phaser.GameObjects.GameObject#setInteractive\n * @since 3.0.0\n *\n * @param {(Phaser.Input.InputConfiguration|any)} [shape] - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.\n * @param {HitAreaCallback} [callback] - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.\n * @param {boolean} [dropZone=false] - Should this Game Object be treated as a drop zone target?\n *\n * @return {this} This GameObject.\n */\n setInteractive: function (shape, callback, dropZone)\n {\n this.scene.sys.input.enable(this, shape, callback, dropZone);\n\n return this;\n },\n\n /**\n * If this Game Object has previously been enabled for input, this will disable it.\n *\n * An object that is disabled for input stops processing or being considered for\n * input events, but can be turned back on again at any time by simply calling\n * `setInteractive()` with no arguments provided.\n *\n * If want to completely remove interaction from this Game Object then use `removeInteractive` instead.\n *\n * @method Phaser.GameObjects.GameObject#disableInteractive\n * @since 3.7.0\n *\n * @return {this} This GameObject.\n */\n disableInteractive: function ()\n {\n if (this.input)\n {\n this.input.enabled = false;\n }\n\n return this;\n },\n\n /**\n * If this Game Object has previously been enabled for input, this will queue it\n * for removal, causing it to no longer be interactive. The removal happens on\n * the next game step, it is not immediate.\n *\n * The Interactive Object that was assigned to this Game Object will be destroyed,\n * removed from the Input Manager and cleared from this Game Object.\n *\n * If you wish to re-enable this Game Object at a later date you will need to\n * re-create its InteractiveObject by calling `setInteractive` again.\n *\n * If you wish to only temporarily stop an object from receiving input then use\n * `disableInteractive` instead, as that toggles the interactive state, where-as\n * this erases it completely.\n * \n * If you wish to resize a hit area, don't remove and then set it as being\n * interactive. Instead, access the hitarea object directly and resize the shape\n * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the\n * shape is a Rectangle, which it is by default.)\n *\n * @method Phaser.GameObjects.GameObject#removeInteractive\n * @since 3.7.0\n *\n * @return {this} This GameObject.\n */\n removeInteractive: function ()\n {\n this.scene.sys.input.clear(this);\n\n this.input = undefined;\n\n return this;\n },\n\n /**\n * To be overridden by custom GameObjects. Allows base objects to be used in a Pool.\n *\n * @method Phaser.GameObjects.GameObject#update\n * @since 3.0.0\n *\n * @param {...*} [args] - args\n */\n update: function ()\n {\n },\n\n /**\n * Returns a JSON representation of the Game Object.\n *\n * @method Phaser.GameObjects.GameObject#toJSON\n * @since 3.0.0\n *\n * @return {JSONGameObject} A JSON representation of the Game Object.\n */\n toJSON: function ()\n {\n return ComponentsToJSON(this);\n },\n\n /**\n * Compares the renderMask with the renderFlags to see if this Game Object will render or not.\n * Also checks the Game Object against the given Cameras exclusion list.\n *\n * @method Phaser.GameObjects.GameObject#willRender\n * @since 3.0.0\n *\n * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object.\n *\n * @return {boolean} True if the Game Object should be rendered, otherwise false.\n */\n willRender: function (camera)\n {\n return !(GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter > 0 && (this.cameraFilter & camera.id)));\n },\n\n /**\n * Returns an array containing the display list index of either this Game Object, or if it has one,\n * its parent Container. It then iterates up through all of the parent containers until it hits the\n * root of the display list (which is index 0 in the returned array).\n *\n * Used internally by the InputPlugin but also useful if you wish to find out the display depth of\n * this Game Object and all of its ancestors.\n *\n * @method Phaser.GameObjects.GameObject#getIndexList\n * @since 3.4.0\n *\n * @return {integer[]} An array of display list position indexes.\n */\n getIndexList: function ()\n {\n // eslint-disable-next-line consistent-this\n var child = this;\n var parent = this.parentContainer;\n\n var indexes = [];\n\n while (parent)\n {\n // indexes.unshift([parent.getIndex(child), parent.name]);\n indexes.unshift(parent.getIndex(child));\n\n child = parent;\n\n if (!parent.parentContainer)\n {\n break;\n }\n else\n {\n parent = parent.parentContainer;\n }\n }\n\n // indexes.unshift([this.scene.sys.displayList.getIndex(child), 'root']);\n indexes.unshift(this.scene.sys.displayList.getIndex(child));\n\n return indexes;\n },\n\n /**\n * Destroys this Game Object removing it from the Display List and Update List and\n * severing all ties to parent resources.\n *\n * Also removes itself from the Input Manager and Physics Manager if previously enabled.\n *\n * Use this to remove a Game Object from your game if you don't ever plan to use it again.\n * As long as no reference to it exists within your own code it should become free for\n * garbage collection by the browser.\n *\n * If you just want to temporarily disable an object then look at using the\n * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected.\n *\n * @method Phaser.GameObjects.GameObject#destroy\n * @since 3.0.0\n * \n * @param {boolean} [fromScene=false] - Is this Game Object being destroyed as the result of a Scene shutdown?\n */\n destroy: function (fromScene)\n {\n if (fromScene === undefined) { fromScene = false; }\n\n // This Game Object has already been destroyed\n if (!this.scene || this.ignoreDestroy)\n {\n return;\n }\n\n if (this.preDestroy)\n {\n this.preDestroy.call(this);\n }\n\n this.emit('destroy', this);\n\n var sys = this.scene.sys;\n\n if (!fromScene)\n {\n sys.displayList.remove(this);\n sys.updateList.remove(this);\n }\n\n if (this.input)\n {\n sys.input.clear(this);\n this.input = undefined;\n }\n\n if (this.data)\n {\n this.data.destroy();\n\n this.data = undefined;\n }\n\n if (this.body)\n {\n this.body.destroy();\n this.body = undefined;\n }\n\n // Tell the Scene to re-sort the children\n if (!fromScene)\n {\n sys.queueDepthSort();\n }\n\n this.active = false;\n this.visible = false;\n\n this.scene = undefined;\n\n this.parentContainer = undefined;\n\n this.removeAllListeners();\n }\n\n});\n\n/**\n * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not.\n *\n * @constant {integer} RENDER_MASK\n * @memberof Phaser.GameObjects.GameObject\n * @default\n */\nGameObject.RENDER_MASK = 15;\n\nmodule.exports = GameObject;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Clamp = require('../../math/Clamp');\n\n// bitmask flag for GameObject.renderMask\nvar _FLAG = 2; // 0010\n\n/**\n * Provides methods used for setting the alpha properties of a Game Object.\n * Should be applied as a mixin and not used directly.\n *\n * @name Phaser.GameObjects.Components.Alpha\n * @since 3.0.0\n */\n\nvar Alpha = {\n\n /**\n * Private internal value. Holds the global alpha value.\n *\n * @name Phaser.GameObjects.Components.Alpha#_alpha\n * @type {number}\n * @private\n * @default 1\n * @since 3.0.0\n */\n _alpha: 1,\n\n /**\n * Private internal value. Holds the top-left alpha value.\n *\n * @name Phaser.GameObjects.Components.Alpha#_alphaTL\n * @type {number}\n * @private\n * @default 1\n * @since 3.0.0\n */\n _alphaTL: 1,\n\n /**\n * Private internal value. Holds the top-right alpha value.\n *\n * @name Phaser.GameObjects.Components.Alpha#_alphaTR\n * @type {number}\n * @private\n * @default 1\n * @since 3.0.0\n */\n _alphaTR: 1,\n\n /**\n * Private internal value. Holds the bottom-left alpha value.\n *\n * @name Phaser.GameObjects.Components.Alpha#_alphaBL\n * @type {number}\n * @private\n * @default 1\n * @since 3.0.0\n */\n _alphaBL: 1,\n\n /**\n * Private internal value. Holds the bottom-right alpha value.\n *\n * @name Phaser.GameObjects.Components.Alpha#_alphaBR\n * @type {number}\n * @private\n * @default 1\n * @since 3.0.0\n */\n _alphaBR: 1,\n\n /**\n * Clears all alpha values associated with this Game Object.\n *\n * Immediately sets the alpha levels back to 1 (fully opaque).\n *\n * @method Phaser.GameObjects.Components.Alpha#clearAlpha\n * @since 3.0.0\n *\n * @return {this} This Game Object instance.\n */\n clearAlpha: function ()\n {\n return this.setAlpha(1);\n },\n\n /**\n * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders.\n * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque.\n *\n * If your game is running under WebGL you can optionally specify four different alpha values, each of which\n * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used.\n *\n * @method Phaser.GameObjects.Components.Alpha#setAlpha\n * @since 3.0.0\n *\n * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object.\n * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only.\n * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only.\n * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only.\n *\n * @return {this} This Game Object instance.\n */\n setAlpha: function (topLeft, topRight, bottomLeft, bottomRight)\n {\n if (topLeft === undefined) { topLeft = 1; }\n\n // Treat as if there is only one alpha value for the whole Game Object\n if (topRight === undefined)\n {\n this.alpha = topLeft;\n }\n else\n {\n this._alphaTL = Clamp(topLeft, 0, 1);\n this._alphaTR = Clamp(topRight, 0, 1);\n this._alphaBL = Clamp(bottomLeft, 0, 1);\n this._alphaBR = Clamp(bottomRight, 0, 1);\n }\n\n return this;\n },\n\n /**\n * The alpha value of the Game Object.\n *\n * This is a global value, impacting the entire Game Object, not just a region of it.\n *\n * @name Phaser.GameObjects.Components.Alpha#alpha\n * @type {number}\n * @since 3.0.0\n */\n alpha: {\n\n get: function ()\n {\n return this._alpha;\n },\n\n set: function (value)\n {\n var v = Clamp(value, 0, 1);\n\n this._alpha = v;\n this._alphaTL = v;\n this._alphaTR = v;\n this._alphaBL = v;\n this._alphaBR = v;\n\n if (v === 0)\n {\n this.renderFlags &= ~_FLAG;\n }\n else\n {\n this.renderFlags |= _FLAG;\n }\n }\n\n },\n\n /**\n * The alpha value starting from the top-left of the Game Object.\n * This value is interpolated from the corner to the center of the Game Object.\n *\n * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft\n * @type {number}\n * @webglOnly\n * @since 3.0.0\n */\n alphaTopLeft: {\n\n get: function ()\n {\n return this._alphaTL;\n },\n\n set: function (value)\n {\n var v = Clamp(value, 0, 1);\n\n this._alphaTL = v;\n\n if (v !== 0)\n {\n this.renderFlags |= _FLAG;\n }\n }\n\n },\n\n /**\n * The alpha value starting from the top-right of the Game Object.\n * This value is interpolated from the corner to the center of the Game Object.\n *\n * @name Phaser.GameObjects.Components.Alpha#alphaTopRight\n * @type {number}\n * @webglOnly\n * @since 3.0.0\n */\n alphaTopRight: {\n\n get: function ()\n {\n return this._alphaTR;\n },\n\n set: function (value)\n {\n var v = Clamp(value, 0, 1);\n\n this._alphaTR = v;\n\n if (v !== 0)\n {\n this.renderFlags |= _FLAG;\n }\n }\n\n },\n\n /**\n * The alpha value starting from the bottom-left of the Game Object.\n * This value is interpolated from the corner to the center of the Game Object.\n *\n * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft\n * @type {number}\n * @webglOnly\n * @since 3.0.0\n */\n alphaBottomLeft: {\n\n get: function ()\n {\n return this._alphaBL;\n },\n\n set: function (value)\n {\n var v = Clamp(value, 0, 1);\n\n this._alphaBL = v;\n\n if (v !== 0)\n {\n this.renderFlags |= _FLAG;\n }\n }\n\n },\n\n /**\n * The alpha value starting from the bottom-right of the Game Object.\n * This value is interpolated from the corner to the center of the Game Object.\n *\n * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight\n * @type {number}\n * @webglOnly\n * @since 3.0.0\n */\n alphaBottomRight: {\n\n get: function ()\n {\n return this._alphaBR;\n },\n\n set: function (value)\n {\n var v = Clamp(value, 0, 1);\n\n this._alphaBR = v;\n\n if (v !== 0)\n {\n this.renderFlags |= _FLAG;\n }\n }\n\n }\n\n};\n\nmodule.exports = Alpha;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar BlendModes = require('../../renderer/BlendModes');\n\n/**\n * Provides methods used for setting the blend mode of a Game Object.\n * Should be applied as a mixin and not used directly.\n *\n * @name Phaser.GameObjects.Components.BlendMode\n * @since 3.0.0\n */\n\nvar BlendMode = {\n\n /**\n * Private internal value. Holds the current blend mode.\n * \n * @name Phaser.GameObjects.Components.BlendMode#_blendMode\n * @type {integer}\n * @private\n * @default 0\n * @since 3.0.0\n */\n _blendMode: BlendModes.NORMAL,\n\n /**\n * Sets the Blend Mode being used by this Game Object.\n *\n * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)\n *\n * Under WebGL only the following Blend Modes are available:\n *\n * * ADD\n * * MULTIPLY\n * * SCREEN\n *\n * Canvas has more available depending on browser support.\n *\n * You can also create your own custom Blend Modes in WebGL.\n *\n * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending\n * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these\n * reasons try to be careful about the construction of your Scene and the frequency of which blend modes\n * are used.\n *\n * @name Phaser.GameObjects.Components.BlendMode#blendMode\n * @type {(Phaser.BlendModes|string)}\n * @since 3.0.0\n */\n blendMode: {\n\n get: function ()\n {\n return this._blendMode;\n },\n\n set: function (value)\n {\n if (typeof value === 'string')\n {\n value = BlendModes[value];\n }\n\n value |= 0;\n\n if (value >= -1)\n {\n this._blendMode = value;\n }\n }\n\n },\n\n /**\n * Sets the Blend Mode being used by this Game Object.\n *\n * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)\n *\n * Under WebGL only the following Blend Modes are available:\n *\n * * ADD\n * * MULTIPLY\n * * SCREEN\n *\n * Canvas has more available depending on browser support.\n *\n * You can also create your own custom Blend Modes in WebGL.\n *\n * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending\n * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these\n * reasons try to be careful about the construction of your Scene and the frequency of which blend modes\n * are used.\n *\n * @method Phaser.GameObjects.Components.BlendMode#setBlendMode\n * @since 3.0.0\n *\n * @param {(string|Phaser.BlendModes)} value - The BlendMode value. Either a string or a CONST.\n *\n * @return {this} This Game Object instance.\n */\n setBlendMode: function (value)\n {\n this.blendMode = value;\n\n return this;\n }\n\n};\n\nmodule.exports = BlendMode;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * Provides methods used for setting the depth of a Game Object.\n * Should be applied as a mixin and not used directly.\n * \n * @name Phaser.GameObjects.Components.Depth\n * @since 3.0.0\n */\n\nvar Depth = {\n\n /**\n * Private internal value. Holds the depth of the Game Object.\n * \n * @name Phaser.GameObjects.Components.Depth#_depth\n * @type {integer}\n * @private\n * @default 0\n * @since 3.0.0\n */\n _depth: 0,\n\n /**\n * The depth of this Game Object within the Scene.\n * \n * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order\n * of Game Objects, without actually moving their position in the display list.\n *\n * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth\n * value will always render in front of one with a lower value.\n *\n * Setting the depth will queue a depth sort event within the Scene.\n * \n * @name Phaser.GameObjects.Components.Depth#depth\n * @type {number}\n * @since 3.0.0\n */\n depth: {\n\n get: function ()\n {\n return this._depth;\n },\n\n set: function (value)\n {\n this.scene.sys.queueDepthSort();\n this._depth = value;\n }\n\n },\n\n /**\n * The depth of this Game Object within the Scene.\n * \n * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order\n * of Game Objects, without actually moving their position in the display list.\n *\n * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth\n * value will always render in front of one with a lower value.\n *\n * Setting the depth will queue a depth sort event within the Scene.\n * \n * @method Phaser.GameObjects.Components.Depth#setDepth\n * @since 3.0.0\n *\n * @param {integer} value - The depth of this Game Object.\n * \n * @return {this} This Game Object instance.\n */\n setDepth: function (value)\n {\n if (value === undefined) { value = 0; }\n\n this.depth = value;\n\n return this;\n }\n\n};\n\nmodule.exports = Depth;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * Provides methods used for visually flipping a Game Object.\n * Should be applied as a mixin and not used directly.\n * \n * @name Phaser.GameObjects.Components.Flip\n * @since 3.0.0\n */\n\nvar Flip = {\n\n /**\n * The horizontally flipped state of the Game Object.\n * A Game Object that is flipped horizontally will render inversed on the horizontal axis.\n * Flipping always takes place from the middle of the texture and does not impact the scale value.\n * \n * @name Phaser.GameObjects.Components.Flip#flipX\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n flipX: false,\n\n /**\n * The vertically flipped state of the Game Object.\n * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down)\n * Flipping always takes place from the middle of the texture and does not impact the scale value.\n * \n * @name Phaser.GameObjects.Components.Flip#flipY\n * @type {boolean}\n * @default false\n * @since 3.0.0\n */\n flipY: false,\n\n /**\n * Toggles the horizontal flipped state of this Game Object.\n * \n * @method Phaser.GameObjects.Components.Flip#toggleFlipX\n * @since 3.0.0\n * \n * @return {this} This Game Object instance.\n */\n toggleFlipX: function ()\n {\n this.flipX = !this.flipX;\n\n return this;\n },\n\n /**\n * Toggles the vertical flipped state of this Game Object.\n * \n * @method Phaser.GameObjects.Components.Flip#toggleFlipY\n * @since 3.0.0\n * \n * @return {this} This Game Object instance.\n */\n toggleFlipY: function ()\n {\n this.flipY = !this.flipY;\n\n return this;\n },\n\n /**\n * Sets the horizontal flipped state of this Game Object.\n * \n * @method Phaser.GameObjects.Components.Flip#setFlipX\n * @since 3.0.0\n *\n * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped.\n * \n * @return {this} This Game Object instance.\n */\n setFlipX: function (value)\n {\n this.flipX = value;\n\n return this;\n },\n\n /**\n * Sets the vertical flipped state of this Game Object.\n * \n * @method Phaser.GameObjects.Components.Flip#setFlipY\n * @since 3.0.0\n *\n * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped.\n * \n * @return {this} This Game Object instance.\n */\n setFlipY: function (value)\n {\n this.flipY = value;\n\n return this;\n },\n\n /**\n * Sets the horizontal and vertical flipped state of this Game Object.\n * \n * @method Phaser.GameObjects.Components.Flip#setFlip\n * @since 3.0.0\n *\n * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped.\n * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped.\n * \n * @return {this} This Game Object instance.\n */\n setFlip: function (x, y)\n {\n this.flipX = x;\n this.flipY = y;\n\n return this;\n },\n\n /**\n * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state.\n * \n * @method Phaser.GameObjects.Components.Flip#resetFlip\n * @since 3.0.0\n *\n * @return {this} This Game Object instance.\n */\n resetFlip: function ()\n {\n this.flipX = false;\n this.flipY = false;\n\n return this;\n }\n\n};\n\nmodule.exports = Flip;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * Provides methods used for getting and setting the Scroll Factor of a Game Object.\n *\n * @name Phaser.GameObjects.Components.ScrollFactor\n * @since 3.0.0\n */\n\nvar ScrollFactor = {\n\n /**\n * The horizontal scroll factor of this Game Object.\n *\n * The scroll factor controls the influence of the movement of a Camera upon this Game Object.\n *\n * When a camera scrolls it will change the location at which this Game Object is rendered on-screen.\n * It does not change the Game Objects actual position values.\n *\n * A value of 1 means it will move exactly in sync with a camera.\n * A value of 0 means it will not move at all, even if the camera moves.\n * Other values control the degree to which the camera movement is mapped to this Game Object.\n * \n * Please be aware that scroll factor values other than 1 are not taken in to consideration when\n * calculating physics collisions. Bodies always collide based on their world position, but changing\n * the scroll factor is a visual adjustment to where the textures are rendered, which can offset\n * them from physics bodies if not accounted for in your code.\n *\n * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX\n * @type {number}\n * @default 1\n * @since 3.0.0\n */\n scrollFactorX: 1,\n\n /**\n * The vertical scroll factor of this Game Object.\n *\n * The scroll factor controls the influence of the movement of a Camera upon this Game Object.\n *\n * When a camera scrolls it will change the location at which this Game Object is rendered on-screen.\n * It does not change the Game Objects actual position values.\n *\n * A value of 1 means it will move exactly in sync with a camera.\n * A value of 0 means it will not move at all, even if the camera moves.\n * Other values control the degree to which the camera movement is mapped to this Game Object.\n * \n * Please be aware that scroll factor values other than 1 are not taken in to consideration when\n * calculating physics collisions. Bodies always collide based on their world position, but changing\n * the scroll factor is a visual adjustment to where the textures are rendered, which can offset\n * them from physics bodies if not accounted for in your code.\n *\n * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY\n * @type {number}\n * @default 1\n * @since 3.0.0\n */\n scrollFactorY: 1,\n\n /**\n * Sets the scroll factor of this Game Object.\n *\n * The scroll factor controls the influence of the movement of a Camera upon this Game Object.\n *\n * When a camera scrolls it will change the location at which this Game Object is rendered on-screen.\n * It does not change the Game Objects actual position values.\n *\n * A value of 1 means it will move exactly in sync with a camera.\n * A value of 0 means it will not move at all, even if the camera moves.\n * Other values control the degree to which the camera movement is mapped to this Game Object.\n * \n * Please be aware that scroll factor values other than 1 are not taken in to consideration when\n * calculating physics collisions. Bodies always collide based on their world position, but changing\n * the scroll factor is a visual adjustment to where the textures are rendered, which can offset\n * them from physics bodies if not accounted for in your code.\n *\n * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor\n * @since 3.0.0\n *\n * @param {number} x - The horizontal scroll factor of this Game Object.\n * @param {number} [y=x] - The vertical scroll factor of this Game Object. If not set it will use the `x` value.\n *\n * @return {this} This Game Object instance.\n */\n setScrollFactor: function (x, y)\n {\n if (y === undefined) { y = x; }\n\n this.scrollFactorX = x;\n this.scrollFactorY = y;\n\n return this;\n }\n\n};\n\nmodule.exports = ScrollFactor;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * @typedef {object} JSONGameObject\n *\n * @property {string} name - The name of this Game Object.\n * @property {string} type - A textual representation of this Game Object, i.e. `sprite`.\n * @property {number} x - The x position of this Game Object.\n * @property {number} y - The y position of this Game Object.\n * @property {object} scale - The scale of this Game Object\n * @property {number} scale.x - The horizontal scale of this Game Object.\n * @property {number} scale.y - The vertical scale of this Game Object.\n * @property {object} origin - The origin of this Game Object.\n * @property {number} origin.x - The horizontal origin of this Game Object.\n * @property {number} origin.y - The vertical origin of this Game Object.\n * @property {boolean} flipX - The horizontally flipped state of the Game Object.\n * @property {boolean} flipY - The vertically flipped state of the Game Object.\n * @property {number} rotation - The angle of this Game Object in radians.\n * @property {number} alpha - The alpha value of the Game Object.\n * @property {boolean} visible - The visible state of the Game Object.\n * @property {integer} scaleMode - The Scale Mode being used by this Game Object.\n * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object.\n * @property {string} textureKey - The texture key of this Game Object.\n * @property {string} frameKey - The frame key of this Game Object.\n * @property {object} data - The data of this Game Object.\n */\n\n/**\n * Build a JSON representation of the given Game Object.\n *\n * This is typically extended further by Game Object specific implementations.\n *\n * @method Phaser.GameObjects.Components.ToJSON\n * @since 3.0.0\n *\n * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to export as JSON.\n *\n * @return {JSONGameObject} A JSON representation of the Game Object.\n */\nvar ToJSON = function (gameObject)\n{\n var out = {\n name: gameObject.name,\n type: gameObject.type,\n x: gameObject.x,\n y: gameObject.y,\n depth: gameObject.depth,\n scale: {\n x: gameObject.scaleX,\n y: gameObject.scaleY\n },\n origin: {\n x: gameObject.originX,\n y: gameObject.originY\n },\n flipX: gameObject.flipX,\n flipY: gameObject.flipY,\n rotation: gameObject.rotation,\n alpha: gameObject.alpha,\n visible: gameObject.visible,\n scaleMode: gameObject.scaleMode,\n blendMode: gameObject.blendMode,\n textureKey: '',\n frameKey: '',\n data: {}\n };\n\n if (gameObject.texture)\n {\n out.textureKey = gameObject.texture.key;\n out.frameKey = gameObject.frame.name;\n }\n\n return out;\n};\n\nmodule.exports = ToJSON;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar MATH_CONST = require('../../math/const');\nvar TransformMatrix = require('./TransformMatrix');\nvar WrapAngle = require('../../math/angle/Wrap');\nvar WrapAngleDegrees = require('../../math/angle/WrapDegrees');\n\n// global bitmask flag for GameObject.renderMask (used by Scale)\nvar _FLAG = 4; // 0100\n\n/**\n * Provides methods used for getting and setting the position, scale and rotation of a Game Object.\n *\n * @name Phaser.GameObjects.Components.Transform\n * @since 3.0.0\n */\n\nvar Transform = {\n\n /**\n * Private internal value. Holds the horizontal scale value.\n * \n * @name Phaser.GameObjects.Components.Transform#_scaleX\n * @type {number}\n * @private\n * @default 1\n * @since 3.0.0\n */\n _scaleX: 1,\n\n /**\n * Private internal value. Holds the vertical scale value.\n * \n * @name Phaser.GameObjects.Components.Transform#_scaleY\n * @type {number}\n * @private\n * @default 1\n * @since 3.0.0\n */\n _scaleY: 1,\n\n /**\n * Private internal value. Holds the rotation value in radians.\n * \n * @name Phaser.GameObjects.Components.Transform#_rotation\n * @type {number}\n * @private\n * @default 0\n * @since 3.0.0\n */\n _rotation: 0,\n\n /**\n * The x position of this Game Object.\n *\n * @name Phaser.GameObjects.Components.Transform#x\n * @type {number}\n * @default 0\n * @since 3.0.0\n */\n x: 0,\n\n /**\n * The y position of this Game Object.\n *\n * @name Phaser.GameObjects.Components.Transform#y\n * @type {number}\n * @default 0\n * @since 3.0.0\n */\n y: 0,\n\n /**\n * The z position of this Game Object.\n * Note: Do not use this value to set the z-index, instead see the `depth` property.\n *\n * @name Phaser.GameObjects.Components.Transform#z\n * @type {number}\n * @default 0\n * @since 3.0.0\n */\n z: 0,\n\n /**\n * The w position of this Game Object.\n *\n * @name Phaser.GameObjects.Components.Transform#w\n * @type {number}\n * @default 0\n * @since 3.0.0\n */\n w: 0,\n\n /**\n * The horizontal scale of this Game Object.\n *\n * @name Phaser.GameObjects.Components.Transform#scaleX\n * @type {number}\n * @default 1\n * @since 3.0.0\n */\n scaleX: {\n\n get: function ()\n {\n return this._scaleX;\n },\n\n set: function (value)\n {\n this._scaleX = value;\n\n if (this._scaleX === 0)\n {\n this.renderFlags &= ~_FLAG;\n }\n else\n {\n this.renderFlags |= _FLAG;\n }\n }\n\n },\n\n /**\n * The vertical scale of this Game Object.\n *\n * @name Phaser.GameObjects.Components.Transform#scaleY\n * @type {number}\n * @default 1\n * @since 3.0.0\n */\n scaleY: {\n\n get: function ()\n {\n return this._scaleY;\n },\n\n set: function (value)\n {\n this._scaleY = value;\n\n if (this._scaleY === 0)\n {\n this.renderFlags &= ~_FLAG;\n }\n else\n {\n this.renderFlags |= _FLAG;\n }\n }\n\n },\n\n /**\n * The angle of this Game Object as expressed in degrees.\n *\n * Where 0 is to the right, 90 is down, 180 is left.\n *\n * If you prefer to work in radians, see the `rotation` property instead.\n *\n * @name Phaser.GameObjects.Components.Transform#angle\n * @type {integer}\n * @default 0\n * @since 3.0.0\n */\n angle: {\n\n get: function ()\n {\n return WrapAngleDegrees(this._rotation * MATH_CONST.RAD_TO_DEG);\n },\n\n set: function (value)\n {\n // value is in degrees\n this.rotation = WrapAngleDegrees(value) * MATH_CONST.DEG_TO_RAD;\n }\n },\n\n /**\n * The angle of this Game Object in radians.\n *\n * If you prefer to work in degrees, see the `angle` property instead.\n *\n * @name Phaser.GameObjects.Components.Transform#rotation\n * @type {number}\n * @default 1\n * @since 3.0.0\n */\n rotation: {\n\n get: function ()\n {\n return this._rotation;\n },\n\n set: function (value)\n {\n // value is in radians\n this._rotation = WrapAngle(value);\n }\n },\n\n /**\n * Sets the position of this Game Object.\n *\n * @method Phaser.GameObjects.Components.Transform#setPosition\n * @since 3.0.0\n *\n * @param {number} [x=0] - The x position of this Game Object.\n * @param {number} [y=x] - The y position of this Game Object. If not set it will use the `x` value.\n * @param {number} [z=0] - The z position of this Game Object.\n * @param {number} [w=0] - The w position of this Game Object.\n *\n * @return {this} This Game Object instance.\n */\n setPosition: function (x, y, z, w)\n {\n if (x === undefined) { x = 0; }\n if (y === undefined) { y = x; }\n if (z === undefined) { z = 0; }\n if (w === undefined) { w = 0; }\n\n this.x = x;\n this.y = y;\n this.z = z;\n this.w = w;\n\n return this;\n },\n\n /**\n * Sets the position of this Game Object to be a random position within the confines of\n * the given area.\n * \n * If no area is specified a random position between 0 x 0 and the game width x height is used instead.\n *\n * The position does not factor in the size of this Game Object, meaning that only the origin is\n * guaranteed to be within the area.\n *\n * @method Phaser.GameObjects.Components.Transform#setRandomPosition\n * @since 3.8.0\n *\n * @param {number} [x=0] - The x position of the top-left of the random area.\n * @param {number} [y=0] - The y position of the top-left of the random area.\n * @param {number} [width] - The width of the random area.\n * @param {number} [height] - The height of the random area.\n *\n * @return {this} This Game Object instance.\n */\n setRandomPosition: function (x, y, width, height)\n {\n if (x === undefined) { x = 0; }\n if (y === undefined) { y = 0; }\n if (width === undefined) { width = this.scene.sys.game.config.width; }\n if (height === undefined) { height = this.scene.sys.game.config.height; }\n\n this.x = x + (Math.random() * width);\n this.y = y + (Math.random() * height);\n\n return this;\n },\n\n /**\n * Sets the rotation of this Game Object.\n *\n * @method Phaser.GameObjects.Components.Transform#setRotation\n * @since 3.0.0\n *\n * @param {number} [radians=0] - The rotation of this Game Object, in radians.\n *\n * @return {this} This Game Object instance.\n */\n setRotation: function (radians)\n {\n if (radians === undefined) { radians = 0; }\n\n this.rotation = radians;\n\n return this;\n },\n\n /**\n * Sets the angle of this Game Object.\n *\n * @method Phaser.GameObjects.Components.Transform#setAngle\n * @since 3.0.0\n *\n * @param {number} [degrees=0] - The rotation of this Game Object, in degrees.\n *\n * @return {this} This Game Object instance.\n */\n setAngle: function (degrees)\n {\n if (degrees === undefined) { degrees = 0; }\n\n this.angle = degrees;\n\n return this;\n },\n\n /**\n * Sets the scale of this Game Object.\n *\n * @method Phaser.GameObjects.Components.Transform#setScale\n * @since 3.0.0\n *\n * @param {number} x - The horizontal scale of this Game Object.\n * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the `x` value.\n *\n * @return {this} This Game Object instance.\n */\n setScale: function (x, y)\n {\n if (x === undefined) { x = 1; }\n if (y === undefined) { y = x; }\n\n this.scaleX = x;\n this.scaleY = y;\n\n return this;\n },\n\n /**\n * Sets the x position of this Game Object.\n *\n * @method Phaser.GameObjects.Components.Transform#setX\n * @since 3.0.0\n *\n * @param {number} [value=0] - The x position of this Game Object.\n *\n * @return {this} This Game Object instance.\n */\n setX: function (value)\n {\n if (value === undefined) { value = 0; }\n\n this.x = value;\n\n return this;\n },\n\n /**\n * Sets the y position of this Game Object.\n *\n * @method Phaser.GameObjects.Components.Transform#setY\n * @since 3.0.0\n *\n * @param {number} [value=0] - The y position of this Game Object.\n *\n * @return {this} This Game Object instance.\n */\n setY: function (value)\n {\n if (value === undefined) { value = 0; }\n\n this.y = value;\n\n return this;\n },\n\n /**\n * Sets the z position of this Game Object.\n *\n * @method Phaser.GameObjects.Components.Transform#setZ\n * @since 3.0.0\n *\n * @param {number} [value=0] - The z position of this Game Object.\n *\n * @return {this} This Game Object instance.\n */\n setZ: function (value)\n {\n if (value === undefined) { value = 0; }\n\n this.z = value;\n\n return this;\n },\n\n /**\n * Sets the w position of this Game Object.\n *\n * @method Phaser.GameObjects.Components.Transform#setW\n * @since 3.0.0\n *\n * @param {number} [value=0] - The w position of this Game Object.\n *\n * @return {this} This Game Object instance.\n */\n setW: function (value)\n {\n if (value === undefined) { value = 0; }\n\n this.w = value;\n\n return this;\n },\n\n /**\n * Gets the local transform matrix for this Game Object.\n *\n * @method Phaser.GameObjects.Components.Transform#getLocalTransformMatrix\n * @since 3.4.0\n *\n * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object.\n *\n * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix.\n */\n getLocalTransformMatrix: function (tempMatrix)\n {\n if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); }\n\n return tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY);\n },\n\n /**\n * Gets the world transform matrix for this Game Object, factoring in any parent Containers.\n *\n * @method Phaser.GameObjects.Components.Transform#getWorldTransformMatrix\n * @since 3.4.0\n *\n * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object.\n * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A temporary matrix to hold parent values during the calculations.\n *\n * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix.\n */\n getWorldTransformMatrix: function (tempMatrix, parentMatrix)\n {\n if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); }\n if (parentMatrix === undefined) { parentMatrix = new TransformMatrix(); }\n\n var parent = this.parentContainer;\n\n if (!parent)\n {\n return this.getLocalTransformMatrix(tempMatrix);\n }\n\n tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY);\n\n while (parent)\n {\n parentMatrix.applyITRS(parent.x, parent.y, parent._rotation, parent._scaleX, parent._scaleY);\n\n parentMatrix.multiply(tempMatrix, tempMatrix);\n\n parent = parent.parentContainer;\n }\n\n return tempMatrix;\n }\n\n};\n\nmodule.exports = Transform;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../../utils/Class');\nvar Vector2 = require('../../math/Vector2');\n\n/**\n * @classdesc\n * A Matrix used for display transformations for rendering.\n *\n * It is represented like so:\n *\n * ```\n * | a | c | tx |\n * | b | d | ty |\n * | 0 | 0 | 1 |\n * ```\n *\n * @class TransformMatrix\n * @memberof Phaser.GameObjects.Components\n * @constructor\n * @since 3.0.0\n *\n * @param {number} [a=1] - The Scale X value.\n * @param {number} [b=0] - The Shear Y value.\n * @param {number} [c=0] - The Shear X value.\n * @param {number} [d=1] - The Scale Y value.\n * @param {number} [tx=0] - The Translate X value.\n * @param {number} [ty=0] - The Translate Y value.\n */\nvar TransformMatrix = new Class({\n\n initialize:\n\n function TransformMatrix (a, b, c, d, tx, ty)\n {\n if (a === undefined) { a = 1; }\n if (b === undefined) { b = 0; }\n if (c === undefined) { c = 0; }\n if (d === undefined) { d = 1; }\n if (tx === undefined) { tx = 0; }\n if (ty === undefined) { ty = 0; }\n\n /**\n * The matrix values.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#matrix\n * @type {Float32Array}\n * @since 3.0.0\n */\n this.matrix = new Float32Array([ a, b, c, d, tx, ty, 0, 0, 1 ]);\n\n /**\n * The decomposed matrix.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#decomposedMatrix\n * @type {object}\n * @since 3.0.0\n */\n this.decomposedMatrix = {\n translateX: 0,\n translateY: 0,\n scaleX: 1,\n scaleY: 1,\n rotation: 0\n };\n },\n\n /**\n * The Scale X value.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#a\n * @type {number}\n * @since 3.4.0\n */\n a: {\n\n get: function ()\n {\n return this.matrix[0];\n },\n\n set: function (value)\n {\n this.matrix[0] = value;\n }\n\n },\n\n /**\n * The Shear Y value.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#b\n * @type {number}\n * @since 3.4.0\n */\n b: {\n\n get: function ()\n {\n return this.matrix[1];\n },\n\n set: function (value)\n {\n this.matrix[1] = value;\n }\n\n },\n\n /**\n * The Shear X value.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#c\n * @type {number}\n * @since 3.4.0\n */\n c: {\n\n get: function ()\n {\n return this.matrix[2];\n },\n\n set: function (value)\n {\n this.matrix[2] = value;\n }\n\n },\n\n /**\n * The Scale Y value.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#d\n * @type {number}\n * @since 3.4.0\n */\n d: {\n\n get: function ()\n {\n return this.matrix[3];\n },\n\n set: function (value)\n {\n this.matrix[3] = value;\n }\n\n },\n\n /**\n * The Translate X value.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#e\n * @type {number}\n * @since 3.11.0\n */\n e: {\n\n get: function ()\n {\n return this.matrix[4];\n },\n\n set: function (value)\n {\n this.matrix[4] = value;\n }\n\n },\n\n /**\n * The Translate Y value.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#f\n * @type {number}\n * @since 3.11.0\n */\n f: {\n\n get: function ()\n {\n return this.matrix[5];\n },\n\n set: function (value)\n {\n this.matrix[5] = value;\n }\n\n },\n\n /**\n * The Translate X value.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#tx\n * @type {number}\n * @since 3.4.0\n */\n tx: {\n\n get: function ()\n {\n return this.matrix[4];\n },\n\n set: function (value)\n {\n this.matrix[4] = value;\n }\n\n },\n\n /**\n * The Translate Y value.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#ty\n * @type {number}\n * @since 3.4.0\n */\n ty: {\n\n get: function ()\n {\n return this.matrix[5];\n },\n\n set: function (value)\n {\n this.matrix[5] = value;\n }\n\n },\n\n /**\n * The rotation of the Matrix.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#rotation\n * @type {number}\n * @readonly\n * @since 3.4.0\n */\n rotation: {\n\n get: function ()\n {\n return Math.acos(this.a / this.scaleX) * (Math.atan(-this.c / this.a) < 0 ? -1 : 1);\n }\n\n },\n\n /**\n * The horizontal scale of the Matrix.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#scaleX\n * @type {number}\n * @readonly\n * @since 3.4.0\n */\n scaleX: {\n\n get: function ()\n {\n return Math.sqrt((this.a * this.a) + (this.c * this.c));\n }\n\n },\n\n /**\n * The vertical scale of the Matrix.\n *\n * @name Phaser.GameObjects.Components.TransformMatrix#scaleY\n * @type {number}\n * @readonly\n * @since 3.4.0\n */\n scaleY: {\n\n get: function ()\n {\n return Math.sqrt((this.b * this.b) + (this.d * this.d));\n }\n\n },\n\n /**\n * Reset the Matrix to an identity matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#loadIdentity\n * @since 3.0.0\n *\n * @return {this} This TransformMatrix.\n */\n loadIdentity: function ()\n {\n var matrix = this.matrix;\n\n matrix[0] = 1;\n matrix[1] = 0;\n matrix[2] = 0;\n matrix[3] = 1;\n matrix[4] = 0;\n matrix[5] = 0;\n\n return this;\n },\n\n /**\n * Translate the Matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#translate\n * @since 3.0.0\n *\n * @param {number} x - The horizontal translation value.\n * @param {number} y - The vertical translation value.\n *\n * @return {this} This TransformMatrix.\n */\n translate: function (x, y)\n {\n var matrix = this.matrix;\n\n matrix[4] = matrix[0] * x + matrix[2] * y + matrix[4];\n matrix[5] = matrix[1] * x + matrix[3] * y + matrix[5];\n\n return this;\n },\n\n /**\n * Scale the Matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#scale\n * @since 3.0.0\n *\n * @param {number} x - The horizontal scale value.\n * @param {number} y - The vertical scale value.\n *\n * @return {this} This TransformMatrix.\n */\n scale: function (x, y)\n {\n var matrix = this.matrix;\n\n matrix[0] *= x;\n matrix[1] *= x;\n matrix[2] *= y;\n matrix[3] *= y;\n\n return this;\n },\n\n /**\n * Rotate the Matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#rotate\n * @since 3.0.0\n *\n * @param {number} angle - The angle of rotation in radians.\n *\n * @return {this} This TransformMatrix.\n */\n rotate: function (angle)\n {\n var sin = Math.sin(angle);\n var cos = Math.cos(angle);\n\n var matrix = this.matrix;\n\n var a = matrix[0];\n var b = matrix[1];\n var c = matrix[2];\n var d = matrix[3];\n\n matrix[0] = a * cos + c * sin;\n matrix[1] = b * cos + d * sin;\n matrix[2] = a * -sin + c * cos;\n matrix[3] = b * -sin + d * cos;\n\n return this;\n },\n\n /**\n * Multiply this Matrix by the given Matrix.\n * \n * If an `out` Matrix is given then the results will be stored in it.\n * If it is not given, this matrix will be updated in place instead.\n * Use an `out` Matrix if you do not wish to mutate this matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#multiply\n * @since 3.0.0\n *\n * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - The Matrix to multiply by.\n * @param {Phaser.GameObjects.Components.TransformMatrix} [out] - An optional Matrix to store the results in.\n *\n * @return {Phaser.GameObjects.Components.TransformMatrix} Either this TransformMatrix, or the `out` Matrix, if given in the arguments.\n */\n multiply: function (rhs, out)\n {\n var matrix = this.matrix;\n var source = rhs.matrix;\n\n var localA = matrix[0];\n var localB = matrix[1];\n var localC = matrix[2];\n var localD = matrix[3];\n var localE = matrix[4];\n var localF = matrix[5];\n\n var sourceA = source[0];\n var sourceB = source[1];\n var sourceC = source[2];\n var sourceD = source[3];\n var sourceE = source[4];\n var sourceF = source[5];\n\n var destinationMatrix = (out === undefined) ? this : out;\n\n destinationMatrix.a = (sourceA * localA) + (sourceB * localC);\n destinationMatrix.b = (sourceA * localB) + (sourceB * localD);\n destinationMatrix.c = (sourceC * localA) + (sourceD * localC);\n destinationMatrix.d = (sourceC * localB) + (sourceD * localD);\n destinationMatrix.e = (sourceE * localA) + (sourceF * localC) + localE;\n destinationMatrix.f = (sourceE * localB) + (sourceF * localD) + localF;\n\n return destinationMatrix;\n },\n\n /**\n * Multiply this Matrix by the matrix given, including the offset.\n * \n * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`.\n * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#multiplyWithOffset\n * @since 3.11.0\n *\n * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from.\n * @param {number} offsetX - Horizontal offset to factor in to the multiplication.\n * @param {number} offsetY - Vertical offset to factor in to the multiplication.\n *\n * @return {this} This TransformMatrix.\n */\n multiplyWithOffset: function (src, offsetX, offsetY)\n {\n var matrix = this.matrix;\n var otherMatrix = src.matrix;\n\n var a0 = matrix[0];\n var b0 = matrix[1];\n var c0 = matrix[2];\n var d0 = matrix[3];\n var tx0 = matrix[4];\n var ty0 = matrix[5];\n\n var pse = offsetX * a0 + offsetY * c0 + tx0;\n var psf = offsetX * b0 + offsetY * d0 + ty0;\n\n var a1 = otherMatrix[0];\n var b1 = otherMatrix[1];\n var c1 = otherMatrix[2];\n var d1 = otherMatrix[3];\n var tx1 = otherMatrix[4];\n var ty1 = otherMatrix[5];\n\n matrix[0] = a1 * a0 + b1 * c0;\n matrix[1] = a1 * b0 + b1 * d0;\n matrix[2] = c1 * a0 + d1 * c0;\n matrix[3] = c1 * b0 + d1 * d0;\n matrix[4] = tx1 * a0 + ty1 * c0 + pse;\n matrix[5] = tx1 * b0 + ty1 * d0 + psf;\n\n return this;\n },\n\n /**\n * Transform the Matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#transform\n * @since 3.0.0\n *\n * @param {number} a - The Scale X value.\n * @param {number} b - The Shear Y value.\n * @param {number} c - The Shear X value.\n * @param {number} d - The Scale Y value.\n * @param {number} tx - The Translate X value.\n * @param {number} ty - The Translate Y value.\n *\n * @return {this} This TransformMatrix.\n */\n transform: function (a, b, c, d, tx, ty)\n {\n var matrix = this.matrix;\n\n var a0 = matrix[0];\n var b0 = matrix[1];\n var c0 = matrix[2];\n var d0 = matrix[3];\n var tx0 = matrix[4];\n var ty0 = matrix[5];\n\n matrix[0] = a * a0 + b * c0;\n matrix[1] = a * b0 + b * d0;\n matrix[2] = c * a0 + d * c0;\n matrix[3] = c * b0 + d * d0;\n matrix[4] = tx * a0 + ty * c0 + tx0;\n matrix[5] = tx * b0 + ty * d0 + ty0;\n\n return this;\n },\n\n /**\n * Transform a point using this Matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#transformPoint\n * @since 3.0.0\n *\n * @param {number} x - The x coordinate of the point to transform.\n * @param {number} y - The y coordinate of the point to transform.\n * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} point - The Point object to store the transformed coordinates.\n *\n * @return {(Phaser.Geom.Point|Phaser.Math.Vector2|object)} The Point containing the transformed coordinates.\n */\n transformPoint: function (x, y, point)\n {\n if (point === undefined) { point = { x: 0, y: 0 }; }\n\n var matrix = this.matrix;\n\n var a = matrix[0];\n var b = matrix[1];\n var c = matrix[2];\n var d = matrix[3];\n var tx = matrix[4];\n var ty = matrix[5];\n\n point.x = x * a + y * c + tx;\n point.y = x * b + y * d + ty;\n\n return point;\n },\n\n /**\n * Invert the Matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#invert\n * @since 3.0.0\n *\n * @return {this} This TransformMatrix.\n */\n invert: function ()\n {\n var matrix = this.matrix;\n\n var a = matrix[0];\n var b = matrix[1];\n var c = matrix[2];\n var d = matrix[3];\n var tx = matrix[4];\n var ty = matrix[5];\n\n var n = a * d - b * c;\n\n matrix[0] = d / n;\n matrix[1] = -b / n;\n matrix[2] = -c / n;\n matrix[3] = a / n;\n matrix[4] = (c * ty - d * tx) / n;\n matrix[5] = -(a * ty - b * tx) / n;\n\n return this;\n },\n\n /**\n * Set the values of this Matrix to copy those of the matrix given.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#copyFrom\n * @since 3.11.0\n *\n * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from.\n *\n * @return {this} This TransformMatrix.\n */\n copyFrom: function (src)\n {\n var matrix = this.matrix;\n\n matrix[0] = src.a;\n matrix[1] = src.b;\n matrix[2] = src.c;\n matrix[3] = src.d;\n matrix[4] = src.e;\n matrix[5] = src.f;\n\n return this;\n },\n\n /**\n * Set the values of this Matrix to copy those of the array given.\n * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#copyFromArray\n * @since 3.11.0\n *\n * @param {array} src - The array of values to set into this matrix.\n *\n * @return {this} This TransformMatrix.\n */\n copyFromArray: function (src)\n {\n var matrix = this.matrix;\n\n matrix[0] = src[0];\n matrix[1] = src[1];\n matrix[2] = src[2];\n matrix[3] = src[3];\n matrix[4] = src[4];\n matrix[5] = src[5];\n\n return this;\n },\n\n /**\n * Copy the values from this Matrix to the given Canvas Rendering Context.\n * This will use the Context.transform method.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#copyToContext\n * @since 3.12.0\n *\n * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to.\n *\n * @return {CanvasRenderingContext2D} The Canvas Rendering Context.\n */\n copyToContext: function (ctx)\n {\n var matrix = this.matrix;\n\n ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);\n\n return ctx;\n },\n\n /**\n * Copy the values from this Matrix to the given Canvas Rendering Context.\n * This will use the Context.setTransform method.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#setToContext\n * @since 3.12.0\n *\n * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to.\n *\n * @return {CanvasRenderingContext2D} The Canvas Rendering Context.\n */\n setToContext: function (ctx)\n {\n var matrix = this.matrix;\n\n ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);\n\n return ctx;\n },\n\n /**\n * Copy the values in this Matrix to the array given.\n * \n * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#copyToArray\n * @since 3.12.0\n *\n * @param {array} [out] - The array to copy the matrix values in to.\n *\n * @return {array} An array where elements 0 to 5 contain the values from this matrix.\n */\n copyToArray: function (out)\n {\n var matrix = this.matrix;\n\n if (out === undefined)\n {\n out = [ matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] ];\n }\n else\n {\n out[0] = matrix[0];\n out[1] = matrix[1];\n out[2] = matrix[2];\n out[3] = matrix[3];\n out[4] = matrix[4];\n out[5] = matrix[5];\n }\n\n return out;\n },\n\n /**\n * Set the values of this Matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#setTransform\n * @since 3.0.0\n *\n * @param {number} a - The Scale X value.\n * @param {number} b - The Shear Y value.\n * @param {number} c - The Shear X value.\n * @param {number} d - The Scale Y value.\n * @param {number} tx - The Translate X value.\n * @param {number} ty - The Translate Y value.\n *\n * @return {this} This TransformMatrix.\n */\n setTransform: function (a, b, c, d, tx, ty)\n {\n var matrix = this.matrix;\n\n matrix[0] = a;\n matrix[1] = b;\n matrix[2] = c;\n matrix[3] = d;\n matrix[4] = tx;\n matrix[5] = ty;\n\n return this;\n },\n\n /**\n * Decompose this Matrix into its translation, scale and rotation values using QR decomposition.\n * \n * The result must be applied in the following order to reproduce the current matrix:\n * \n * translate -> rotate -> scale\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix\n * @since 3.0.0\n *\n * @return {object} The decomposed Matrix.\n */\n decomposeMatrix: function ()\n {\n var decomposedMatrix = this.decomposedMatrix;\n\n var matrix = this.matrix;\n\n // a = scale X (1)\n // b = shear Y (0)\n // c = shear X (0)\n // d = scale Y (1)\n\n var a = matrix[0];\n var b = matrix[1];\n var c = matrix[2];\n var d = matrix[3];\n\n var determ = a * d - b * c;\n\n decomposedMatrix.translateX = matrix[4];\n decomposedMatrix.translateY = matrix[5];\n\n if (a || b)\n {\n var r = Math.sqrt(a * a + b * b);\n\n decomposedMatrix.rotation = (b > 0) ? Math.acos(a / r) : -Math.acos(a / r);\n decomposedMatrix.scaleX = r;\n decomposedMatrix.scaleY = determ / r;\n }\n else if (c || d)\n {\n var s = Math.sqrt(c * c + d * d);\n\n decomposedMatrix.rotation = Math.PI * 0.5 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s));\n decomposedMatrix.scaleX = determ / s;\n decomposedMatrix.scaleY = s;\n }\n else\n {\n decomposedMatrix.rotation = 0;\n decomposedMatrix.scaleX = 0;\n decomposedMatrix.scaleY = 0;\n }\n\n return decomposedMatrix;\n },\n\n /**\n * Apply the identity, translate, rotate and scale operations on the Matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#applyITRS\n * @since 3.0.0\n *\n * @param {number} x - The horizontal translation.\n * @param {number} y - The vertical translation.\n * @param {number} rotation - The angle of rotation in radians.\n * @param {number} scaleX - The horizontal scale.\n * @param {number} scaleY - The vertical scale.\n *\n * @return {this} This TransformMatrix.\n */\n applyITRS: function (x, y, rotation, scaleX, scaleY)\n {\n var matrix = this.matrix;\n\n var radianSin = Math.sin(rotation);\n var radianCos = Math.cos(rotation);\n\n // Translate\n matrix[4] = x;\n matrix[5] = y;\n\n // Rotate and Scale\n matrix[0] = radianCos * scaleX;\n matrix[1] = radianSin * scaleX;\n matrix[2] = -radianSin * scaleY;\n matrix[3] = radianCos * scaleY;\n\n return this;\n },\n\n /**\n * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of\n * the current matrix with its transformation applied.\n * \n * Can be used to translate points from world to local space.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#applyInverse\n * @since 3.12.0\n *\n * @param {number} x - The x position to translate.\n * @param {number} y - The y position to translate.\n * @param {Phaser.Math.Vector2} [output] - A Vector2, or point-like object, to store the results in.\n *\n * @return {Phaser.Math.Vector2} The coordinates, inverse-transformed through this matrix.\n */\n applyInverse: function (x, y, output)\n {\n if (output === undefined) { output = new Vector2(); }\n\n var matrix = this.matrix;\n\n var a = matrix[0];\n var b = matrix[1];\n var c = matrix[2];\n var d = matrix[3];\n var tx = matrix[4];\n var ty = matrix[5];\n\n var id = 1 / ((a * d) + (c * -b));\n\n output.x = (d * id * x) + (-c * id * y) + (((ty * c) - (tx * d)) * id);\n output.y = (a * id * y) + (-b * id * x) + (((-ty * a) + (tx * b)) * id);\n\n return output;\n },\n\n /**\n * Returns the X component of this matrix multiplied by the given values.\n * This is the same as `x * a + y * c + e`.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#getX\n * @since 3.12.0\n * \n * @param {number} x - The x value.\n * @param {number} y - The y value.\n *\n * @return {number} The calculated x value.\n */\n getX: function (x, y)\n {\n return x * this.a + y * this.c + this.e;\n },\n\n /**\n * Returns the Y component of this matrix multiplied by the given values.\n * This is the same as `x * b + y * d + f`.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#getY\n * @since 3.12.0\n * \n * @param {number} x - The x value.\n * @param {number} y - The y value.\n *\n * @return {number} The calculated y value.\n */\n getY: function (x, y)\n {\n return x * this.b + y * this.d + this.f;\n },\n\n /**\n * Returns a string that can be used in a CSS Transform call as a `matrix` property.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#getCSSMatrix\n * @since 3.12.0\n *\n * @return {string} A string containing the CSS Transform matrix values.\n */\n getCSSMatrix: function ()\n {\n var m = this.matrix;\n\n return 'matrix(' + m[0] + ',' + m[1] + ',' + m[2] + ',' + m[3] + ',' + m[4] + ',' + m[5] + ')';\n },\n\n /**\n * Destroys this Transform Matrix.\n *\n * @method Phaser.GameObjects.Components.TransformMatrix#destroy\n * @since 3.4.0\n */\n destroy: function ()\n {\n this.matrix = null;\n this.decomposedMatrix = null;\n }\n\n});\n\nmodule.exports = TransformMatrix;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n// bitmask flag for GameObject.renderMask\nvar _FLAG = 1; // 0001\n\n/**\n * Provides methods used for setting the visibility of a Game Object.\n * Should be applied as a mixin and not used directly.\n * \n * @name Phaser.GameObjects.Components.Visible\n * @since 3.0.0\n */\n\nvar Visible = {\n\n /**\n * Private internal value. Holds the visible value.\n * \n * @name Phaser.GameObjects.Components.Visible#_visible\n * @type {boolean}\n * @private\n * @default true\n * @since 3.0.0\n */\n _visible: true,\n\n /**\n * The visible state of the Game Object.\n * \n * An invisible Game Object will skip rendering, but will still process update logic.\n * \n * @name Phaser.GameObjects.Components.Visible#visible\n * @type {boolean}\n * @since 3.0.0\n */\n visible: {\n\n get: function ()\n {\n return this._visible;\n },\n\n set: function (value)\n {\n if (value)\n {\n this._visible = true;\n this.renderFlags |= _FLAG;\n }\n else\n {\n this._visible = false;\n this.renderFlags &= ~_FLAG;\n }\n }\n\n },\n\n /**\n * Sets the visibility of this Game Object.\n * \n * An invisible Game Object will skip rendering, but will still process update logic.\n *\n * @method Phaser.GameObjects.Components.Visible#setVisible\n * @since 3.0.0\n *\n * @param {boolean} value - The visible state of the Game Object.\n * \n * @return {this} This Game Object instance.\n */\n setVisible: function (value)\n {\n this.visible = value;\n\n return this;\n }\n};\n\nmodule.exports = Visible;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../utils/Class');\nvar CONST = require('./const');\nvar GetFastValue = require('../utils/object/GetFastValue');\nvar GetURL = require('./GetURL');\nvar MergeXHRSettings = require('./MergeXHRSettings');\nvar XHRLoader = require('./XHRLoader');\nvar XHRSettings = require('./XHRSettings');\n\n/**\n * @typedef {object} FileConfig\n *\n * @property {string} type - The file type string (image, json, etc) for sorting within the Loader.\n * @property {string} key - Unique cache key (unique within its file type)\n * @property {string} [url] - The URL of the file, not including baseURL.\n * @property {string} [path] - The path of the file, not including the baseURL.\n * @property {string} [extension] - The default extension this file uses.\n * @property {XMLHttpRequestResponseType} [responseType] - The responseType to be used by the XHR request.\n * @property {(XHRSettingsObject|false)} [xhrSettings=false] - Custom XHR Settings specific to this file and merged with the Loader defaults.\n * @property {any} [config] - A config object that can be used by file types to store transitional data.\n */\n\n/**\n * @classdesc\n * The base File class used by all File Types that the Loader can support.\n * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods.\n *\n * @class File\n * @memberof Phaser.Loader\n * @constructor\n * @since 3.0.0\n *\n * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File.\n * @param {FileConfig} fileConfig - The file configuration object, as created by the file type.\n */\nvar File = new Class({\n\n initialize:\n\n function File (loader, fileConfig)\n {\n /**\n * A reference to the Loader that is going to load this file.\n *\n * @name Phaser.Loader.File#loader\n * @type {Phaser.Loader.LoaderPlugin}\n * @since 3.0.0\n */\n this.loader = loader;\n\n /**\n * A reference to the Cache, or Texture Manager, that is going to store this file if it loads.\n *\n * @name Phaser.Loader.File#cache\n * @type {(Phaser.Cache.BaseCache|Phaser.Textures.TextureManager)}\n * @since 3.7.0\n */\n this.cache = GetFastValue(fileConfig, 'cache', false);\n\n /**\n * The file type string (image, json, etc) for sorting within the Loader.\n *\n * @name Phaser.Loader.File#type\n * @type {string}\n * @since 3.0.0\n */\n this.type = GetFastValue(fileConfig, 'type', false);\n\n /**\n * Unique cache key (unique within its file type)\n *\n * @name Phaser.Loader.File#key\n * @type {string}\n * @since 3.0.0\n */\n this.key = GetFastValue(fileConfig, 'key', false);\n\n var loadKey = this.key;\n\n if (loader.prefix && loader.prefix !== '')\n {\n this.key = loader.prefix + loadKey;\n }\n\n if (!this.type || !this.key)\n {\n throw new Error('Error calling \\'Loader.' + this.type + '\\' invalid key provided.');\n }\n\n /**\n * The URL of the file, not including baseURL.\n * Automatically has Loader.path prepended to it.\n *\n * @name Phaser.Loader.File#url\n * @type {string}\n * @since 3.0.0\n */\n this.url = GetFastValue(fileConfig, 'url');\n\n if (this.url === undefined)\n {\n this.url = loader.path + loadKey + '.' + GetFastValue(fileConfig, 'extension', '');\n }\n else if (typeof(this.url) !== 'function')\n {\n this.url = loader.path + this.url;\n }\n\n /**\n * The final URL this file will load from, including baseURL and path.\n * Set automatically when the Loader calls 'load' on this file.\n *\n * @name Phaser.Loader.File#src\n * @type {string}\n * @since 3.0.0\n */\n this.src = '';\n\n /**\n * The merged XHRSettings for this file.\n *\n * @name Phaser.Loader.File#xhrSettings\n * @type {XHRSettingsObject}\n * @since 3.0.0\n */\n this.xhrSettings = XHRSettings(GetFastValue(fileConfig, 'responseType', undefined));\n\n if (GetFastValue(fileConfig, 'xhrSettings', false))\n {\n this.xhrSettings = MergeXHRSettings(this.xhrSettings, GetFastValue(fileConfig, 'xhrSettings', {}));\n }\n\n /**\n * The XMLHttpRequest instance (as created by XHR Loader) that is loading this File.\n *\n * @name Phaser.Loader.File#xhrLoader\n * @type {?XMLHttpRequest}\n * @since 3.0.0\n */\n this.xhrLoader = null;\n\n /**\n * The current state of the file. One of the FILE_CONST values.\n *\n * @name Phaser.Loader.File#state\n * @type {integer}\n * @since 3.0.0\n */\n this.state = (typeof(this.url) === 'function') ? CONST.FILE_POPULATED : CONST.FILE_PENDING;\n\n /**\n * The total size of this file.\n * Set by onProgress and only if loading via XHR.\n *\n * @name Phaser.Loader.File#bytesTotal\n * @type {number}\n * @default 0\n * @since 3.0.0\n */\n this.bytesTotal = 0;\n\n /**\n * Updated as the file loads.\n * Only set if loading via XHR.\n *\n * @name Phaser.Loader.File#bytesLoaded\n * @type {number}\n * @default -1\n * @since 3.0.0\n */\n this.bytesLoaded = -1;\n\n /**\n * A percentage value between 0 and 1 indicating how much of this file has loaded.\n * Only set if loading via XHR.\n *\n * @name Phaser.Loader.File#percentComplete\n * @type {number}\n * @default -1\n * @since 3.0.0\n */\n this.percentComplete = -1;\n\n /**\n * For CORs based loading.\n * If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set)\n *\n * @name Phaser.Loader.File#crossOrigin\n * @type {(string|undefined)}\n * @since 3.0.0\n */\n this.crossOrigin = undefined;\n\n /**\n * The processed file data, stored here after the file has loaded.\n *\n * @name Phaser.Loader.File#data\n * @type {*}\n * @since 3.0.0\n */\n this.data = undefined;\n\n /**\n * A config object that can be used by file types to store transitional data.\n *\n * @name Phaser.Loader.File#config\n * @type {*}\n * @since 3.0.0\n */\n this.config = GetFastValue(fileConfig, 'config', {});\n\n /**\n * If this is a multipart file, i.e. an atlas and its json together, then this is a reference\n * to the parent MultiFile. Set and used internally by the Loader or specific file types.\n *\n * @name Phaser.Loader.File#multiFile\n * @type {?Phaser.Loader.MultiFile}\n * @since 3.7.0\n */\n this.multiFile;\n\n /**\n * Does this file have an associated linked file? Such as an image and a normal map.\n * Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't\n * actually bound by data, where-as a linkFile is.\n *\n * @name Phaser.Loader.File#linkFile\n * @type {?Phaser.Loader.File}\n * @since 3.7.0\n */\n this.linkFile;\n },\n\n /**\n * Links this File with another, so they depend upon each other for loading and processing.\n *\n * @method Phaser.Loader.File#setLink\n * @since 3.7.0\n *\n * @param {Phaser.Loader.File} fileB - The file to link to this one.\n */\n setLink: function (fileB)\n {\n this.linkFile = fileB;\n\n fileB.linkFile = this;\n },\n\n /**\n * Resets the XHRLoader instance this file is using.\n *\n * @method Phaser.Loader.File#resetXHR\n * @since 3.0.0\n */\n resetXHR: function ()\n {\n if (this.xhrLoader)\n {\n this.xhrLoader.onload = undefined;\n this.xhrLoader.onerror = undefined;\n this.xhrLoader.onprogress = undefined;\n }\n },\n\n /**\n * Called by the Loader, starts the actual file downloading.\n * During the load the methods onLoad, onError and onProgress are called, based on the XHR events.\n * You shouldn't normally call this method directly, it's meant to be invoked by the Loader.\n *\n * @method Phaser.Loader.File#load\n * @since 3.0.0\n */\n load: function ()\n {\n if (this.state === CONST.FILE_POPULATED)\n {\n // Can happen for example in a JSONFile if they've provided a JSON object instead of a URL\n this.loader.nextFile(this, true);\n }\n else\n {\n this.src = GetURL(this, this.loader.baseURL);\n\n if (this.src.indexOf('data:') === 0)\n {\n console.warn('Local data URIs are not supported: ' + this.key);\n }\n else\n {\n // The creation of this XHRLoader starts the load process going.\n // It will automatically call the following, based on the load outcome:\n // \n // xhr.onload = this.onLoad\n // xhr.onerror = this.onError\n // xhr.onprogress = this.onProgress\n\n this.xhrLoader = XHRLoader(this, this.loader.xhr);\n }\n }\n },\n\n /**\n * Called when the file finishes loading, is sent a DOM ProgressEvent.\n *\n * @method Phaser.Loader.File#onLoad\n * @since 3.0.0\n *\n * @param {XMLHttpRequest} xhr - The XMLHttpRequest that caused this onload event.\n * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this load.\n */\n onLoad: function (xhr, event)\n {\n var success = !(event.target && event.target.status !== 200);\n\n // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.\n if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599)\n {\n success = false;\n }\n\n this.resetXHR();\n\n this.loader.nextFile(this, success);\n },\n\n /**\n * Called if the file errors while loading, is sent a DOM ProgressEvent.\n *\n * @method Phaser.Loader.File#onError\n * @since 3.0.0\n *\n * @param {ProgressEvent} event - The DOM ProgressEvent that resulted from this error.\n */\n onError: function ()\n {\n this.resetXHR();\n\n this.loader.nextFile(this, false);\n },\n\n /**\n * Called during the file load progress. Is sent a DOM ProgressEvent.\n *\n * @method Phaser.Loader.File#onProgress\n * @since 3.0.0\n *\n * @param {ProgressEvent} event - The DOM ProgressEvent.\n */\n onProgress: function (event)\n {\n if (event.lengthComputable)\n {\n this.bytesLoaded = event.loaded;\n this.bytesTotal = event.total;\n\n this.percentComplete = Math.min((this.bytesLoaded / this.bytesTotal), 1);\n\n this.loader.emit('fileprogress', this, this.percentComplete);\n }\n },\n\n /**\n * Usually overridden by the FileTypes and is called by Loader.nextFile.\n * This method controls what extra work this File does with its loaded data, for example a JSON file will parse itself during this stage.\n *\n * @method Phaser.Loader.File#onProcess\n * @since 3.0.0\n */\n onProcess: function ()\n {\n this.state = CONST.FILE_PROCESSING;\n\n this.onProcessComplete();\n },\n\n /**\n * Called when the File has completed processing.\n * Checks on the state of its multifile, if set.\n *\n * @method Phaser.Loader.File#onProcessComplete\n * @since 3.7.0\n */\n onProcessComplete: function ()\n {\n this.state = CONST.FILE_COMPLETE;\n\n if (this.multiFile)\n {\n this.multiFile.onFileComplete(this);\n }\n\n this.loader.fileProcessComplete(this);\n },\n\n /**\n * Called when the File has completed processing but it generated an error.\n * Checks on the state of its multifile, if set.\n *\n * @method Phaser.Loader.File#onProcessError\n * @since 3.7.0\n */\n onProcessError: function ()\n {\n this.state = CONST.FILE_ERRORED;\n\n if (this.multiFile)\n {\n this.multiFile.onFileFailed(this);\n }\n\n this.loader.fileProcessComplete(this);\n },\n\n /**\n * Checks if a key matching the one used by this file exists in the target Cache or not.\n * This is called automatically by the LoaderPlugin to decide if the file can be safely\n * loaded or will conflict.\n *\n * @method Phaser.Loader.File#hasCacheConflict\n * @since 3.7.0\n *\n * @return {boolean} `true` if adding this file will cause a conflict, otherwise `false`.\n */\n hasCacheConflict: function ()\n {\n return (this.cache && this.cache.exists(this.key));\n },\n\n /**\n * Adds this file to its target cache upon successful loading and processing.\n * This method is often overridden by specific file types.\n *\n * @method Phaser.Loader.File#addToCache\n * @since 3.7.0\n */\n addToCache: function ()\n {\n if (this.cache)\n {\n this.cache.add(this.key, this.data);\n }\n\n this.pendingDestroy();\n },\n\n /**\n * You can listen for this event from the LoaderPlugin. It is dispatched _every time_\n * a file loads and is sent 3 arguments, which allow you to identify the file:\n *\n * ```javascript\n * this.load.on('filecomplete', function (key, type, data) {\n * // Your handler code\n * });\n * ```\n * \n * @event Phaser.Loader.File#fileCompleteEvent\n * @param {string} key - The key of the file that just loaded and finished processing.\n * @param {string} type - The type of the file that just loaded and finished processing.\n * @param {any} data - The data of the file.\n */\n\n /**\n * You can listen for this event from the LoaderPlugin. It is dispatched only once per\n * file and you have to use a special listener handle to pick it up.\n * \n * The string of the event is based on the file type and the key you gave it, split up\n * using hyphens.\n * \n * For example, if you have loaded an image with a key of `monster`, you can listen for it\n * using the following:\n *\n * ```javascript\n * this.load.on('filecomplete-image-monster', function (key, type, data) {\n * // Your handler code\n * });\n * ```\n *\n * Or, if you have loaded a texture atlas with a key of `Level1`:\n * \n * ```javascript\n * this.load.on('filecomplete-atlas-Level1', function (key, type, data) {\n * // Your handler code\n * });\n * ```\n * \n * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`:\n * \n * ```javascript\n * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) {\n * // Your handler code\n * });\n * ```\n * \n * @event Phaser.Loader.File#singleFileCompleteEvent\n * @param {any} data - The data of the file.\n */\n\n /**\n * Called once the file has been added to its cache and is now ready for deletion from the Loader.\n * It will emit a `filecomplete` event from the LoaderPlugin.\n *\n * @method Phaser.Loader.File#pendingDestroy\n * @fires Phaser.Loader.File#fileCompleteEvent\n * @fires Phaser.Loader.File#singleFileCompleteEvent\n * @since 3.7.0\n */\n pendingDestroy: function (data)\n {\n if (data === undefined) { data = this.data; }\n\n var key = this.key;\n var type = this.type;\n\n this.loader.emit('filecomplete', key, type, data);\n this.loader.emit('filecomplete-' + type + '-' + key, key, type, data);\n\n this.loader.flagForRemoval(this);\n },\n\n /**\n * Destroy this File and any references it holds.\n *\n * @method Phaser.Loader.File#destroy\n * @since 3.7.0\n */\n destroy: function ()\n {\n this.loader = null;\n this.cache = null;\n this.xhrSettings = null;\n this.multiFile = null;\n this.linkFile = null;\n this.data = null;\n }\n\n});\n\n/**\n * Static method for creating object URL using URL API and setting it as image 'src' attribute.\n * If URL API is not supported (usually on old browsers) it falls back to creating Base64 encoded url using FileReader.\n *\n * @method Phaser.Loader.File.createObjectURL\n * @static\n * @param {HTMLImageElement} image - Image object which 'src' attribute should be set to object URL.\n * @param {Blob} blob - A Blob object to create an object URL for.\n * @param {string} defaultType - Default mime type used if blob type is not available.\n */\nFile.createObjectURL = function (image, blob, defaultType)\n{\n if (typeof URL === 'function')\n {\n image.src = URL.createObjectURL(blob);\n }\n else\n {\n var reader = new FileReader();\n\n reader.onload = function ()\n {\n image.removeAttribute('crossOrigin');\n image.src = 'data:' + (blob.type || defaultType) + ';base64,' + reader.result.split(',')[1];\n };\n\n reader.onerror = image.onerror;\n\n reader.readAsDataURL(blob);\n }\n};\n\n/**\n * Static method for releasing an existing object URL which was previously created\n * by calling {@link File#createObjectURL} method.\n *\n * @method Phaser.Loader.File.revokeObjectURL\n * @static\n * @param {HTMLImageElement} image - Image object which 'src' attribute should be revoked.\n */\nFile.revokeObjectURL = function (image)\n{\n if (typeof URL === 'function')\n {\n URL.revokeObjectURL(image.src);\n }\n};\n\nmodule.exports = File;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar types = {};\n\nvar FileTypesManager = {\n\n /**\n * Static method called when a LoaderPlugin is created.\n * \n * Loops through the local types object and injects all of them as\n * properties into the LoaderPlugin instance.\n *\n * @method Phaser.Loader.FileTypesManager.register\n * @since 3.0.0\n * \n * @param {Phaser.Loader.LoaderPlugin} loader - The LoaderPlugin to install the types into.\n */\n install: function (loader)\n {\n for (var key in types)\n {\n loader[key] = types[key];\n }\n },\n\n /**\n * Static method called directly by the File Types.\n * \n * The key is a reference to the function used to load the files via the Loader, i.e. `image`.\n *\n * @method Phaser.Loader.FileTypesManager.register\n * @since 3.0.0\n * \n * @param {string} key - The key that will be used as the method name in the LoaderPlugin.\n * @param {function} factoryFunction - The function that will be called when LoaderPlugin.key is invoked.\n */\n register: function (key, factoryFunction)\n {\n types[key] = factoryFunction;\n },\n\n /**\n * Removed all associated file types.\n *\n * @method Phaser.Loader.FileTypesManager.destroy\n * @since 3.0.0\n */\n destroy: function ()\n {\n types = {};\n }\n\n};\n\nmodule.exports = FileTypesManager;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * Given a File and a baseURL value this returns the URL the File will use to download from.\n *\n * @function Phaser.Loader.GetURL\n * @since 3.0.0\n *\n * @param {Phaser.Loader.File} file - The File object.\n * @param {string} baseURL - A default base URL.\n *\n * @return {string} The URL the File will use.\n */\nvar GetURL = function (file, baseURL)\n{\n if (!file.url)\n {\n return false;\n }\n\n if (file.url.match(/^(?:blob:|data:|http:\\/\\/|https:\\/\\/|\\/\\/)/))\n {\n return file.url;\n }\n else\n {\n return baseURL + file.url;\n }\n};\n\nmodule.exports = GetURL;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Extend = require('../utils/object/Extend');\nvar XHRSettings = require('./XHRSettings');\n\n/**\n * Takes two XHRSettings Objects and creates a new XHRSettings object from them.\n *\n * The new object is seeded by the values given in the global settings, but any setting in\n * the local object overrides the global ones.\n *\n * @function Phaser.Loader.MergeXHRSettings\n * @since 3.0.0\n *\n * @param {XHRSettingsObject} global - The global XHRSettings object.\n * @param {XHRSettingsObject} local - The local XHRSettings object.\n *\n * @return {XHRSettingsObject} A newly formed XHRSettings object.\n */\nvar MergeXHRSettings = function (global, local)\n{\n var output = (global === undefined) ? XHRSettings() : Extend({}, global);\n\n if (local)\n {\n for (var setting in local)\n {\n if (local[setting] !== undefined)\n {\n output[setting] = local[setting];\n }\n }\n }\n\n return output;\n};\n\nmodule.exports = MergeXHRSettings;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../utils/Class');\n\n/**\n * @classdesc\n * A MultiFile is a special kind of parent that contains two, or more, Files as children and looks after\n * the loading and processing of them all. It is commonly extended and used as a base class for file types such as AtlasJSON or BitmapFont.\n * \n * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods.\n *\n * @class MultiFile\n * @memberof Phaser.Loader\n * @constructor\n * @since 3.7.0\n *\n * @param {Phaser.Loader.LoaderPlugin} loader - The Loader that is going to load this File.\n * @param {string} type - The file type string for sorting within the Loader.\n * @param {string} key - The key of the file within the loader.\n * @param {Phaser.Loader.File[]} files - An array of Files that make-up this MultiFile.\n */\nvar MultiFile = new Class({\n\n initialize:\n\n function MultiFile (loader, type, key, files)\n {\n /**\n * A reference to the Loader that is going to load this file.\n *\n * @name Phaser.Loader.MultiFile#loader\n * @type {Phaser.Loader.LoaderPlugin}\n * @since 3.7.0\n */\n this.loader = loader;\n\n /**\n * The file type string for sorting within the Loader.\n *\n * @name Phaser.Loader.MultiFile#type\n * @type {string}\n * @since 3.7.0\n */\n this.type = type;\n\n /**\n * Unique cache key (unique within its file type)\n *\n * @name Phaser.Loader.MultiFile#key\n * @type {string}\n * @since 3.7.0\n */\n this.key = key;\n\n /**\n * Array of files that make up this MultiFile.\n *\n * @name Phaser.Loader.MultiFile#files\n * @type {Phaser.Loader.File[]}\n * @since 3.7.0\n */\n this.files = files;\n\n /**\n * The completion status of this MultiFile.\n *\n * @name Phaser.Loader.MultiFile#complete\n * @type {boolean}\n * @default false\n * @since 3.7.0\n */\n this.complete = false;\n\n /**\n * The number of files to load.\n *\n * @name Phaser.Loader.MultiFile#pending\n * @type {integer}\n * @since 3.7.0\n */\n\n this.pending = files.length;\n\n /**\n * The number of files that failed to load.\n *\n * @name Phaser.Loader.MultiFile#failed\n * @type {integer}\n * @default 0\n * @since 3.7.0\n */\n this.failed = 0;\n\n /**\n * A storage container for transient data that the loading files need.\n *\n * @name Phaser.Loader.MultiFile#config\n * @type {any}\n * @since 3.7.0\n */\n this.config = {};\n\n // Link the files\n for (var i = 0; i < files.length; i++)\n {\n files[i].multiFile = this;\n }\n },\n\n /**\n * Checks if this MultiFile is ready to process its children or not.\n *\n * @method Phaser.Loader.MultiFile#isReadyToProcess\n * @since 3.7.0\n *\n * @return {boolean} `true` if all children of this MultiFile have loaded, otherwise `false`.\n */\n isReadyToProcess: function ()\n {\n return (this.pending === 0 && this.failed === 0 && !this.complete);\n },\n\n /**\n * Adds another child to this MultiFile, increases the pending count and resets the completion status.\n *\n * @method Phaser.Loader.MultiFile#addToMultiFile\n * @since 3.7.0\n *\n * @param {Phaser.Loader.File} files - The File to add to this MultiFile.\n *\n * @return {Phaser.Loader.MultiFile} This MultiFile instance.\n */\n addToMultiFile: function (file)\n {\n this.files.push(file);\n\n file.multiFile = this;\n\n this.pending++;\n\n this.complete = false;\n\n return this;\n },\n\n /**\n * Called by each File when it finishes loading.\n *\n * @method Phaser.Loader.MultiFile#onFileComplete\n * @since 3.7.0\n *\n * @param {Phaser.Loader.File} file - The File that has completed processing.\n */\n onFileComplete: function (file)\n {\n var index = this.files.indexOf(file);\n\n if (index !== -1)\n {\n this.pending--;\n }\n },\n\n /**\n * Called by each File that fails to load.\n *\n * @method Phaser.Loader.MultiFile#onFileFailed\n * @since 3.7.0\n *\n * @param {Phaser.Loader.File} file - The File that has failed to load.\n */\n onFileFailed: function (file)\n {\n var index = this.files.indexOf(file);\n\n if (index !== -1)\n {\n this.failed++;\n }\n }\n\n});\n\nmodule.exports = MultiFile;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar MergeXHRSettings = require('./MergeXHRSettings');\n\n/**\n * Creates a new XMLHttpRequest (xhr) object based on the given File and XHRSettings\n * and starts the download of it. It uses the Files own XHRSettings and merges them\n * with the global XHRSettings object to set the xhr values before download.\n *\n * @function Phaser.Loader.XHRLoader\n * @since 3.0.0\n *\n * @param {Phaser.Loader.File} file - The File to download.\n * @param {XHRSettingsObject} globalXHRSettings - The global XHRSettings object.\n *\n * @return {XMLHttpRequest} The XHR object.\n */\nvar XHRLoader = function (file, globalXHRSettings)\n{\n var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings);\n\n var xhr = new XMLHttpRequest();\n\n xhr.open('GET', file.src, config.async, config.user, config.password);\n\n xhr.responseType = file.xhrSettings.responseType;\n xhr.timeout = config.timeout;\n\n if (config.header && config.headerValue)\n {\n xhr.setRequestHeader(config.header, config.headerValue);\n }\n\n if (config.requestedWith)\n {\n xhr.setRequestHeader('X-Requested-With', config.requestedWith);\n }\n\n if (config.overrideMimeType)\n {\n xhr.overrideMimeType(config.overrideMimeType);\n }\n\n // After a successful request, the xhr.response property will contain the requested data as a DOMString, ArrayBuffer, Blob, or Document (depending on what was set for responseType.)\n\n xhr.onload = file.onLoad.bind(file, xhr);\n xhr.onerror = file.onError.bind(file);\n xhr.onprogress = file.onProgress.bind(file);\n\n // This is the only standard method, the ones above are browser additions (maybe not universal?)\n // xhr.onreadystatechange\n\n xhr.send();\n\n return xhr;\n};\n\nmodule.exports = XHRLoader;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * @typedef {object} XHRSettingsObject\n *\n * @property {XMLHttpRequestResponseType} responseType - The response type of the XHR request, i.e. `blob`, `text`, etc.\n * @property {boolean} [async=true] - Should the XHR request use async or not?\n * @property {string} [user=''] - Optional username for the XHR request.\n * @property {string} [password=''] - Optional password for the XHR request.\n * @property {integer} [timeout=0] - Optional XHR timeout value.\n * @property {(string|undefined)} [header] - This value is used to populate the XHR `setRequestHeader` and is undefined by default.\n * @property {(string|undefined)} [headerValue] - This value is used to populate the XHR `setRequestHeader` and is undefined by default.\n * @property {(string|undefined)} [requestedWith] - This value is used to populate the XHR `setRequestHeader` and is undefined by default.\n * @property {(string|undefined)} [overrideMimeType] - Provide a custom mime-type to use instead of the default.\n */\n\n/**\n * Creates an XHRSettings Object with default values.\n *\n * @function Phaser.Loader.XHRSettings\n * @since 3.0.0\n *\n * @param {XMLHttpRequestResponseType} [responseType=''] - The responseType, such as 'text'.\n * @param {boolean} [async=true] - Should the XHR request use async or not?\n * @param {string} [user=''] - Optional username for the XHR request.\n * @param {string} [password=''] - Optional password for the XHR request.\n * @param {integer} [timeout=0] - Optional XHR timeout value.\n *\n * @return {XHRSettingsObject} The XHRSettings object as used by the Loader.\n */\nvar XHRSettings = function (responseType, async, user, password, timeout)\n{\n if (responseType === undefined) { responseType = ''; }\n if (async === undefined) { async = true; }\n if (user === undefined) { user = ''; }\n if (password === undefined) { password = ''; }\n if (timeout === undefined) { timeout = 0; }\n\n // Before sending a request, set the xhr.responseType to \"text\",\n // \"arraybuffer\", \"blob\", or \"document\", depending on your data needs.\n // Note, setting xhr.responseType = '' (or omitting) will default the response to \"text\".\n\n return {\n\n // Ignored by the Loader, only used by File.\n responseType: responseType,\n\n async: async,\n\n // credentials\n user: user,\n password: password,\n\n // timeout in ms (0 = no timeout)\n timeout: timeout,\n\n // setRequestHeader\n header: undefined,\n headerValue: undefined,\n requestedWith: false,\n\n // overrideMimeType\n overrideMimeType: undefined\n\n };\n};\n\nmodule.exports = XHRSettings;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar FILE_CONST = {\n\n /**\n * The Loader is idle.\n * \n * @name Phaser.Loader.LOADER_IDLE\n * @type {integer}\n * @since 3.0.0\n */\n LOADER_IDLE: 0,\n\n /**\n * The Loader is actively loading.\n * \n * @name Phaser.Loader.LOADER_LOADING\n * @type {integer}\n * @since 3.0.0\n */\n LOADER_LOADING: 1,\n\n /**\n * The Loader is processing files is has loaded.\n * \n * @name Phaser.Loader.LOADER_PROCESSING\n * @type {integer}\n * @since 3.0.0\n */\n LOADER_PROCESSING: 2,\n\n /**\n * The Loader has completed loading and processing.\n * \n * @name Phaser.Loader.LOADER_COMPLETE\n * @type {integer}\n * @since 3.0.0\n */\n LOADER_COMPLETE: 3,\n\n /**\n * The Loader is shutting down.\n * \n * @name Phaser.Loader.LOADER_SHUTDOWN\n * @type {integer}\n * @since 3.0.0\n */\n LOADER_SHUTDOWN: 4,\n\n /**\n * The Loader has been destroyed.\n * \n * @name Phaser.Loader.LOADER_DESTROYED\n * @type {integer}\n * @since 3.0.0\n */\n LOADER_DESTROYED: 5,\n\n /**\n * File is in the load queue but not yet started\n * \n * @name Phaser.Loader.FILE_PENDING\n * @type {integer}\n * @since 3.0.0\n */\n FILE_PENDING: 10,\n\n /**\n * File has been started to load by the loader (onLoad called)\n * \n * @name Phaser.Loader.FILE_LOADING\n * @type {integer}\n * @since 3.0.0\n */\n FILE_LOADING: 11,\n\n /**\n * File has loaded successfully, awaiting processing \n * \n * @name Phaser.Loader.FILE_LOADED\n * @type {integer}\n * @since 3.0.0\n */\n FILE_LOADED: 12,\n\n /**\n * File failed to load\n * \n * @name Phaser.Loader.FILE_FAILED\n * @type {integer}\n * @since 3.0.0\n */\n FILE_FAILED: 13,\n\n /**\n * File is being processed (onProcess callback)\n * \n * @name Phaser.Loader.FILE_PROCESSING\n * @type {integer}\n * @since 3.0.0\n */\n FILE_PROCESSING: 14,\n\n /**\n * The File has errored somehow during processing.\n * \n * @name Phaser.Loader.FILE_ERRORED\n * @type {integer}\n * @since 3.0.0\n */\n FILE_ERRORED: 16,\n\n /**\n * File has finished processing.\n * \n * @name Phaser.Loader.FILE_COMPLETE\n * @type {integer}\n * @since 3.0.0\n */\n FILE_COMPLETE: 17,\n\n /**\n * File has been destroyed\n * \n * @name Phaser.Loader.FILE_DESTROYED\n * @type {integer}\n * @since 3.0.0\n */\n FILE_DESTROYED: 18,\n\n /**\n * File was populated from local data and doesn't need an HTTP request\n * \n * @name Phaser.Loader.FILE_POPULATED\n * @type {integer}\n * @since 3.0.0\n */\n FILE_POPULATED: 19\n\n};\n\nmodule.exports = FILE_CONST;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../../utils/Class');\nvar CONST = require('../const');\nvar File = require('../File');\nvar FileTypesManager = require('../FileTypesManager');\nvar GetFastValue = require('../../utils/object/GetFastValue');\nvar IsPlainObject = require('../../utils/object/IsPlainObject');\n\n/**\n * @typedef {object} Phaser.Loader.FileTypes.ImageFrameConfig\n *\n * @property {integer} frameWidth - The width of the frame in pixels.\n * @property {integer} [frameHeight] - The height of the frame in pixels. Uses the `frameWidth` value if not provided.\n * @property {integer} [startFrame=0] - The first frame to start parsing from.\n * @property {integer} [endFrame] - The frame to stop parsing at. If not provided it will calculate the value based on the image and frame dimensions.\n * @property {integer} [margin=0] - The margin in the image. This is the space around the edge of the frames.\n * @property {integer} [spacing=0] - The spacing between each frame in the image.\n */\n\n/**\n * @typedef {object} Phaser.Loader.FileTypes.ImageFileConfig\n *\n * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager.\n * @property {string} [url] - The absolute or relative URL to load the file from.\n * @property {string} [extension='png'] - The default file extension to use if no url is provided.\n * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the image.\n * @property {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets.\n * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file.\n */\n\n/**\n * @classdesc\n * A single Image File suitable for loading by the Loader.\n *\n * These are created when you use the Phaser.Loader.LoaderPlugin#image method and are not typically created directly.\n * \n * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#image.\n *\n * @class ImageFile\n * @extends Phaser.Loader.File\n * @memberof Phaser.Loader.FileTypes\n * @constructor\n * @since 3.0.0\n *\n * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file.\n * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig)} key - The key to use for this file, or a file configuration object.\n * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was \"alien\" then the URL will be \"alien.png\".\n * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file.\n * @param {Phaser.Loader.FileTypes.ImageFrameConfig} [frameConfig] - The frame configuration object. Only provided for, and used by, Sprite Sheets.\n */\nvar ImageFile = new Class({\n\n Extends: File,\n\n initialize:\n\n function ImageFile (loader, key, url, xhrSettings, frameConfig)\n {\n var extension = 'png';\n var normalMapURL;\n\n if (IsPlainObject(key))\n {\n var config = key;\n\n key = GetFastValue(config, 'key');\n url = GetFastValue(config, 'url');\n normalMapURL = GetFastValue(config, 'normalMap');\n xhrSettings = GetFastValue(config, 'xhrSettings');\n extension = GetFastValue(config, 'extension', extension);\n frameConfig = GetFastValue(config, 'frameConfig');\n }\n\n if (Array.isArray(url))\n {\n normalMapURL = url[1];\n url = url[0];\n }\n\n var fileConfig = {\n type: 'image',\n cache: loader.textureManager,\n extension: extension,\n responseType: 'blob',\n key: key,\n url: url,\n xhrSettings: xhrSettings,\n config: frameConfig\n };\n\n File.call(this, loader, fileConfig);\n\n // Do we have a normal map to load as well?\n if (normalMapURL)\n {\n var normalMap = new ImageFile(loader, this.key, normalMapURL, xhrSettings, frameConfig);\n\n normalMap.type = 'normalMap';\n\n this.setLink(normalMap);\n\n loader.addFile(normalMap);\n }\n },\n\n /**\n * Called automatically by Loader.nextFile.\n * This method controls what extra work this File does with its loaded data.\n *\n * @method Phaser.Loader.FileTypes.ImageFile#onProcess\n * @since 3.7.0\n */\n onProcess: function ()\n {\n this.state = CONST.FILE_PROCESSING;\n\n this.data = new Image();\n\n this.data.crossOrigin = this.crossOrigin;\n\n var _this = this;\n\n this.data.onload = function ()\n {\n File.revokeObjectURL(_this.data);\n\n _this.onProcessComplete();\n };\n\n this.data.onerror = function ()\n {\n File.revokeObjectURL(_this.data);\n\n _this.onProcessError();\n };\n\n File.createObjectURL(this.data, this.xhrLoader.response, 'image/png');\n },\n\n /**\n * Adds this file to its target cache upon successful loading and processing.\n *\n * @method Phaser.Loader.FileTypes.ImageFile#addToCache\n * @since 3.7.0\n */\n addToCache: function ()\n {\n var texture;\n var linkFile = this.linkFile;\n\n if (linkFile && linkFile.state === CONST.FILE_COMPLETE)\n {\n if (this.type === 'image')\n {\n texture = this.cache.addImage(this.key, this.data, linkFile.data);\n }\n else\n {\n texture = this.cache.addImage(linkFile.key, linkFile.data, this.data);\n }\n\n this.pendingDestroy(texture);\n\n linkFile.pendingDestroy(texture);\n }\n else if (!linkFile)\n {\n texture = this.cache.addImage(this.key, this.data);\n\n this.pendingDestroy(texture);\n }\n }\n\n});\n\n/**\n * Adds an Image, or array of Images, to the current load queue.\n *\n * You can call this method from within your Scene's `preload`, along with any other files you wish to load:\n * \n * ```javascript\n * function preload ()\n * {\n * this.load.image('logo', 'images/phaserLogo.png');\n * }\n * ```\n *\n * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts,\n * or if it's already running, when the next free load slot becomes available. This happens automatically if you\n * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued\n * it means you cannot use the file immediately after calling this method, but must wait for the file to complete.\n * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the\n * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been\n * loaded.\n * \n * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle.\n * If you try to load an animated gif only the first frame will be rendered. Browsers do not natively support playback\n * of animated gifs to Canvas elements.\n *\n * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load.\n * The key should be unique both in terms of files being loaded and files already present in the Texture Manager.\n * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file\n * then remove it from the Texture Manager first, before loading a new one.\n *\n * Instead of passing arguments you can pass a configuration object, such as:\n * \n * ```javascript\n * this.load.image({\n * key: 'logo',\n * url: 'images/AtariLogo.png'\n * });\n * ```\n *\n * See the documentation for `Phaser.Loader.FileTypes.ImageFileConfig` for more details.\n *\n * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key:\n * \n * ```javascript\n * this.load.image('logo', 'images/AtariLogo.png');\n * // and later in your game ...\n * this.add.image(x, y, 'logo');\n * ```\n *\n * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files\n * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and\n * this is what you would use to retrieve the image from the Texture Manager.\n *\n * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.\n *\n * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is \"alien\"\n * and no URL is given then the Loader will set the URL to be \"alien.png\". It will always add `.png` as the extension, although\n * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL.\n *\n * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image,\n * then you can specify it by providing an array as the `url` where the second element is the normal map:\n * \n * ```javascript\n * this.load.image('logo', [ 'images/AtariLogo.png', 'images/AtariLogo-n.png' ]);\n * ```\n *\n * Or, if you are using a config object use the `normalMap` property:\n * \n * ```javascript\n * this.load.image({\n * key: 'logo',\n * url: 'images/AtariLogo.png',\n * normalMap: 'images/AtariLogo-n.png'\n * });\n * ```\n *\n * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings.\n * Normal maps are a WebGL only feature.\n *\n * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser.\n * It is available in the default build but can be excluded from custom builds.\n *\n * @method Phaser.Loader.LoaderPlugin#image\n * @fires Phaser.Loader.LoaderPlugin#addFileEvent\n * @since 3.0.0\n *\n * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them.\n * @param {string|string[]} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was \"alien\" then the URL will be \"alien.png\".\n * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings.\n *\n * @return {Phaser.Loader.LoaderPlugin} The Loader instance.\n */\nFileTypesManager.register('image', function (key, url, xhrSettings)\n{\n if (Array.isArray(key))\n {\n for (var i = 0; i < key.length; i++)\n {\n // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object\n this.addFile(new ImageFile(this, key[i]));\n }\n }\n else\n {\n this.addFile(new ImageFile(this, key, url, xhrSettings));\n }\n\n return this;\n});\n\nmodule.exports = ImageFile;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../../utils/Class');\nvar CONST = require('../const');\nvar File = require('../File');\nvar FileTypesManager = require('../FileTypesManager');\nvar GetFastValue = require('../../utils/object/GetFastValue');\nvar GetValue = require('../../utils/object/GetValue');\nvar IsPlainObject = require('../../utils/object/IsPlainObject');\n\n/**\n * @typedef {object} Phaser.Loader.FileTypes.JSONFileConfig\n *\n * @property {string} key - The key of the file. Must be unique within both the Loader and the JSON Cache.\n * @property {string|any} [url] - The absolute or relative URL to load the file from. Or can be a ready formed JSON object, in which case it will be directly added to the Cache.\n * @property {string} [extension='json'] - The default file extension to use if no url is provided.\n * @property {string} [dataKey] - If specified instead of the whole JSON file being parsed and added to the Cache, only the section corresponding to this property key will be added. If the property you want to extract is nested, use periods to divide it.\n * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file.\n */\n\n/**\n * @classdesc\n * A single JSON File suitable for loading by the Loader.\n *\n * These are created when you use the Phaser.Loader.LoaderPlugin#json method and are not typically created directly.\n * \n * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#json.\n *\n * @class JSONFile\n * @extends Phaser.Loader.File\n * @memberof Phaser.Loader.FileTypes\n * @constructor\n * @since 3.0.0\n *\n * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file.\n * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig)} key - The key to use for this file, or a file configuration object.\n * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was \"alien\" then the URL will be \"alien.json\".\n * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file.\n * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache.\n */\nvar JSONFile = new Class({\n\n Extends: File,\n\n initialize:\n\n // url can either be a string, in which case it is treated like a proper url, or an object, in which case it is treated as a ready-made JS Object\n // dataKey allows you to pluck a specific object out of the JSON and put just that into the cache, rather than the whole thing\n\n function JSONFile (loader, key, url, xhrSettings, dataKey)\n {\n var extension = 'json';\n\n if (IsPlainObject(key))\n {\n var config = key;\n\n key = GetFastValue(config, 'key');\n url = GetFastValue(config, 'url');\n xhrSettings = GetFastValue(config, 'xhrSettings');\n extension = GetFastValue(config, 'extension', extension);\n dataKey = GetFastValue(config, 'dataKey', dataKey);\n }\n\n var fileConfig = {\n type: 'json',\n cache: loader.cacheManager.json,\n extension: extension,\n responseType: 'text',\n key: key,\n url: url,\n xhrSettings: xhrSettings,\n config: dataKey\n };\n\n File.call(this, loader, fileConfig);\n\n if (IsPlainObject(url))\n {\n // Object provided instead of a URL, so no need to actually load it (populate data with value)\n if (dataKey)\n {\n this.data = GetValue(url, dataKey);\n }\n else\n {\n this.data = url;\n }\n\n this.state = CONST.FILE_POPULATED;\n }\n },\n\n /**\n * Called automatically by Loader.nextFile.\n * This method controls what extra work this File does with its loaded data.\n *\n * @method Phaser.Loader.FileTypes.JSONFile#onProcess\n * @since 3.7.0\n */\n onProcess: function ()\n {\n if (this.state !== CONST.FILE_POPULATED)\n {\n this.state = CONST.FILE_PROCESSING;\n\n var json = JSON.parse(this.xhrLoader.responseText);\n\n var key = this.config;\n\n if (typeof key === 'string')\n {\n this.data = GetValue(json, key, json);\n }\n else\n {\n this.data = json;\n }\n }\n\n this.onProcessComplete();\n }\n\n});\n\n/**\n * Adds a JSON file, or array of JSON files, to the current load queue.\n *\n * You can call this method from within your Scene's `preload`, along with any other files you wish to load:\n * \n * ```javascript\n * function preload ()\n * {\n * this.load.json('wavedata', 'files/AlienWaveData.json');\n * }\n * ```\n *\n * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts,\n * or if it's already running, when the next free load slot becomes available. This happens automatically if you\n * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued\n * it means you cannot use the file immediately after calling this method, but must wait for the file to complete.\n * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the\n * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been\n * loaded.\n * \n * The key must be a unique String. It is used to add the file to the global JSON Cache upon a successful load.\n * The key should be unique both in terms of files being loaded and files already present in the JSON Cache.\n * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file\n * then remove it from the JSON Cache first, before loading a new one.\n *\n * Instead of passing arguments you can pass a configuration object, such as:\n * \n * ```javascript\n * this.load.json({\n * key: 'wavedata',\n * url: 'files/AlienWaveData.json'\n * });\n * ```\n *\n * See the documentation for `Phaser.Loader.FileTypes.JSONFileConfig` for more details.\n *\n * Once the file has finished loading you can access it from its Cache using its key:\n * \n * ```javascript\n * this.load.json('wavedata', 'files/AlienWaveData.json');\n * // and later in your game ...\n * var data = this.cache.json.get('wavedata');\n * ```\n *\n * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files\n * key. For example, if the prefix was `LEVEL1.` and the key was `Waves` the final key will be `LEVEL1.Waves` and\n * this is what you would use to retrieve the text from the JSON Cache.\n *\n * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.\n *\n * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is \"data\"\n * and no URL is given then the Loader will set the URL to be \"data.json\". It will always add `.json` as the extension, although\n * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL.\n *\n * You can also optionally provide a `dataKey` to use. This allows you to extract only a part of the JSON and store it in the Cache,\n * rather than the whole file. For example, if your JSON data had a structure like this:\n * \n * ```json\n * {\n * \"level1\": {\n * \"baddies\": {\n * \"aliens\": {},\n * \"boss\": {}\n * }\n * },\n * \"level2\": {},\n * \"level3\": {}\n * }\n * ```\n *\n * And you only wanted to store the `boss` data in the Cache, then you could pass `level1.baddies.boss`as the `dataKey`.\n *\n * Note: The ability to load this type of file will only be available if the JSON File type has been built into Phaser.\n * It is available in the default build but can be excluded from custom builds.\n *\n * @method Phaser.Loader.LoaderPlugin#json\n * @fires Phaser.Loader.LoaderPlugin#addFileEvent\n * @since 3.0.0\n *\n * @param {(string|Phaser.Loader.FileTypes.JSONFileConfig|Phaser.Loader.FileTypes.JSONFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them.\n * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.json`, i.e. if `key` was \"alien\" then the URL will be \"alien.json\".\n * @param {string} [dataKey] - When the JSON file loads only this property will be stored in the Cache.\n * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings.\n *\n * @return {Phaser.Loader.LoaderPlugin} The Loader instance.\n */\nFileTypesManager.register('json', function (key, url, dataKey, xhrSettings)\n{\n if (Array.isArray(key))\n {\n for (var i = 0; i < key.length; i++)\n {\n // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object\n this.addFile(new JSONFile(this, key[i]));\n }\n }\n else\n {\n this.addFile(new JSONFile(this, key, url, xhrSettings, dataKey));\n }\n\n return this;\n});\n\nmodule.exports = JSONFile;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../../utils/Class');\nvar CONST = require('../const');\nvar File = require('../File');\nvar FileTypesManager = require('../FileTypesManager');\nvar GetFastValue = require('../../utils/object/GetFastValue');\nvar IsPlainObject = require('../../utils/object/IsPlainObject');\n\n/**\n * @typedef {object} Phaser.Loader.FileTypes.TextFileConfig\n *\n * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache.\n * @property {string} [url] - The absolute or relative URL to load the file from.\n * @property {string} [extension='txt'] - The default file extension to use if no url is provided.\n * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file.\n */\n\n/**\n * @classdesc\n * A single Text File suitable for loading by the Loader.\n *\n * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly.\n *\n * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text.\n *\n * @class TextFile\n * @extends Phaser.Loader.File\n * @memberof Phaser.Loader.FileTypes\n * @constructor\n * @since 3.0.0\n *\n * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file.\n * @param {(string|Phaser.Loader.FileTypes.TextFileConfig)} key - The key to use for this file, or a file configuration object.\n * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was \"alien\" then the URL will be \"alien.txt\".\n * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file.\n */\nvar TextFile = new Class({\n\n Extends: File,\n\n initialize:\n\n function TextFile (loader, key, url, xhrSettings)\n {\n var extension = 'txt';\n\n if (IsPlainObject(key))\n {\n var config = key;\n\n key = GetFastValue(config, 'key');\n url = GetFastValue(config, 'url');\n xhrSettings = GetFastValue(config, 'xhrSettings');\n extension = GetFastValue(config, 'extension', extension);\n }\n\n var fileConfig = {\n type: 'text',\n cache: loader.cacheManager.text,\n extension: extension,\n responseType: 'text',\n key: key,\n url: url,\n xhrSettings: xhrSettings\n };\n\n File.call(this, loader, fileConfig);\n },\n\n /**\n * Called automatically by Loader.nextFile.\n * This method controls what extra work this File does with its loaded data.\n *\n * @method Phaser.Loader.FileTypes.TextFile#onProcess\n * @since 3.7.0\n */\n onProcess: function ()\n {\n this.state = CONST.FILE_PROCESSING;\n\n this.data = this.xhrLoader.responseText;\n\n this.onProcessComplete();\n }\n\n});\n\n/**\n * Adds a Text file, or array of Text files, to the current load queue.\n *\n * You can call this method from within your Scene's `preload`, along with any other files you wish to load:\n *\n * ```javascript\n * function preload ()\n * {\n * this.load.text('story', 'files/IntroStory.txt');\n * }\n * ```\n *\n * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts,\n * or if it's already running, when the next free load slot becomes available. This happens automatically if you\n * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued\n * it means you cannot use the file immediately after calling this method, but must wait for the file to complete.\n * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the\n * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been\n * loaded.\n *\n * The key must be a unique String. It is used to add the file to the global Text Cache upon a successful load.\n * The key should be unique both in terms of files being loaded and files already present in the Text Cache.\n * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file\n * then remove it from the Text Cache first, before loading a new one.\n *\n * Instead of passing arguments you can pass a configuration object, such as:\n *\n * ```javascript\n * this.load.text({\n * key: 'story',\n * url: 'files/IntroStory.txt'\n * });\n * ```\n *\n * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details.\n *\n * Once the file has finished loading you can access it from its Cache using its key:\n *\n * ```javascript\n * this.load.text('story', 'files/IntroStory.txt');\n * // and later in your game ...\n * var data = this.cache.text.get('story');\n * ```\n *\n * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files\n * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and\n * this is what you would use to retrieve the text from the Text Cache.\n *\n * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.\n *\n * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is \"story\"\n * and no URL is given then the Loader will set the URL to be \"story.txt\". It will always add `.txt` as the extension, although\n * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL.\n *\n * Note: The ability to load this type of file will only be available if the Text File type has been built into Phaser.\n * It is available in the default build but can be excluded from custom builds.\n *\n * @method Phaser.Loader.LoaderPlugin#text\n * @fires Phaser.Loader.LoaderPlugin#addFileEvent\n * @since 3.0.0\n *\n * @param {(string|Phaser.Loader.FileTypes.TextFileConfig|Phaser.Loader.FileTypes.TextFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them.\n * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was \"alien\" then the URL will be \"alien.txt\".\n * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings.\n *\n * @return {Phaser.Loader.LoaderPlugin} The Loader instance.\n */\nFileTypesManager.register('text', function (key, url, xhrSettings)\n{\n if (Array.isArray(key))\n {\n for (var i = 0; i < key.length; i++)\n {\n // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object\n this.addFile(new TextFile(this, key[i]));\n }\n }\n else\n {\n this.addFile(new TextFile(this, key, url, xhrSettings));\n }\n\n return this;\n});\n\nmodule.exports = TextFile;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * Force a value within the boundaries by clamping it to the range `min`, `max`.\n *\n * @function Phaser.Math.Clamp\n * @since 3.0.0\n *\n * @param {number} value - The value to be clamped.\n * @param {number} min - The minimum bounds.\n * @param {number} max - The maximum bounds.\n *\n * @return {number} The clamped value.\n */\nvar Clamp = function (value, min, max)\n{\n return Math.max(min, Math.min(max, value));\n};\n\nmodule.exports = Clamp;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji\n// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl\n\nvar Class = require('../utils/Class');\n\nvar EPSILON = 0.000001;\n\n/**\n * @classdesc\n * A four-dimensional matrix.\n *\n * @class Matrix4\n * @memberof Phaser.Math\n * @constructor\n * @since 3.0.0\n *\n * @param {Phaser.Math.Matrix4} [m] - Optional Matrix4 to copy values from.\n */\nvar Matrix4 = new Class({\n\n initialize:\n\n function Matrix4 (m)\n {\n /**\n * The matrix values.\n *\n * @name Phaser.Math.Matrix4#val\n * @type {Float32Array}\n * @since 3.0.0\n */\n this.val = new Float32Array(16);\n\n if (m)\n {\n // Assume Matrix4 with val:\n this.copy(m);\n }\n else\n {\n // Default to identity\n this.identity();\n }\n },\n\n /**\n * Make a clone of this Matrix4.\n *\n * @method Phaser.Math.Matrix4#clone\n * @since 3.0.0\n *\n * @return {Phaser.Math.Matrix4} A clone of this Matrix4.\n */\n clone: function ()\n {\n return new Matrix4(this);\n },\n\n // TODO - Should work with basic values\n\n /**\n * This method is an alias for `Matrix4.copy`.\n *\n * @method Phaser.Math.Matrix4#set\n * @since 3.0.0\n *\n * @param {Phaser.Math.Matrix4} src - The Matrix to set the values of this Matrix's from.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n set: function (src)\n {\n return this.copy(src);\n },\n\n /**\n * Copy the values of a given Matrix into this Matrix.\n *\n * @method Phaser.Math.Matrix4#copy\n * @since 3.0.0\n *\n * @param {Phaser.Math.Matrix4} src - The Matrix to copy the values from.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n copy: function (src)\n {\n var out = this.val;\n var a = src.val;\n\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n\n return this;\n },\n\n /**\n * Set the values of this Matrix from the given array.\n *\n * @method Phaser.Math.Matrix4#fromArray\n * @since 3.0.0\n *\n * @param {array} a - The array to copy the values from.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n fromArray: function (a)\n {\n var out = this.val;\n\n out[0] = a[0];\n out[1] = a[1];\n out[2] = a[2];\n out[3] = a[3];\n out[4] = a[4];\n out[5] = a[5];\n out[6] = a[6];\n out[7] = a[7];\n out[8] = a[8];\n out[9] = a[9];\n out[10] = a[10];\n out[11] = a[11];\n out[12] = a[12];\n out[13] = a[13];\n out[14] = a[14];\n out[15] = a[15];\n\n return this;\n },\n\n /**\n * Reset this Matrix.\n *\n * Sets all values to `0`.\n *\n * @method Phaser.Math.Matrix4#zero\n * @since 3.0.0\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n zero: function ()\n {\n var out = this.val;\n\n out[0] = 0;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 0;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 0;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 0;\n\n return this;\n },\n\n /**\n * Set the `x`, `y` and `z` values of this Matrix.\n *\n * @method Phaser.Math.Matrix4#xyz\n * @since 3.0.0\n *\n * @param {number} x - The x value.\n * @param {number} y - The y value.\n * @param {number} z - The z value.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n xyz: function (x, y, z)\n {\n this.identity();\n\n var out = this.val;\n\n out[12] = x;\n out[13] = y;\n out[14] = z;\n\n return this;\n },\n\n /**\n * Set the scaling values of this Matrix.\n *\n * @method Phaser.Math.Matrix4#scaling\n * @since 3.0.0\n *\n * @param {number} x - The x scaling value.\n * @param {number} y - The y scaling value.\n * @param {number} z - The z scaling value.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n scaling: function (x, y, z)\n {\n this.zero();\n\n var out = this.val;\n\n out[0] = x;\n out[5] = y;\n out[10] = z;\n out[15] = 1;\n\n return this;\n },\n\n /**\n * Reset this Matrix to an identity (default) matrix.\n *\n * @method Phaser.Math.Matrix4#identity\n * @since 3.0.0\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n identity: function ()\n {\n var out = this.val;\n\n out[0] = 1;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n out[4] = 0;\n out[5] = 1;\n out[6] = 0;\n out[7] = 0;\n out[8] = 0;\n out[9] = 0;\n out[10] = 1;\n out[11] = 0;\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n\n return this;\n },\n\n /**\n * Transpose this Matrix.\n *\n * @method Phaser.Math.Matrix4#transpose\n * @since 3.0.0\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n transpose: function ()\n {\n var a = this.val;\n\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n var a12 = a[6];\n var a13 = a[7];\n var a23 = a[11];\n\n a[1] = a[4];\n a[2] = a[8];\n a[3] = a[12];\n a[4] = a01;\n a[6] = a[9];\n a[7] = a[13];\n a[8] = a02;\n a[9] = a12;\n a[11] = a[14];\n a[12] = a03;\n a[13] = a13;\n a[14] = a23;\n\n return this;\n },\n\n /**\n * Invert this Matrix.\n *\n * @method Phaser.Math.Matrix4#invert\n * @since 3.0.0\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n invert: function ()\n {\n var a = this.val;\n\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n var a30 = a[12];\n var a31 = a[13];\n var a32 = a[14];\n var a33 = a[15];\n\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32;\n\n // Calculate the determinant\n var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n\n if (!det)\n {\n return null;\n }\n\n det = 1 / det;\n\n a[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;\n a[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;\n a[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;\n a[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;\n a[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;\n a[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;\n a[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;\n a[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;\n a[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;\n a[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;\n a[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;\n a[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;\n a[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;\n a[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;\n a[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;\n a[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;\n\n return this;\n },\n\n /**\n * Calculate the adjoint, or adjugate, of this Matrix.\n *\n * @method Phaser.Math.Matrix4#adjoint\n * @since 3.0.0\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n adjoint: function ()\n {\n var a = this.val;\n\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n var a30 = a[12];\n var a31 = a[13];\n var a32 = a[14];\n var a33 = a[15];\n\n a[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22));\n a[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));\n a[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12));\n a[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));\n a[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));\n a[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22));\n a[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));\n a[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12));\n a[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21));\n a[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));\n a[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11));\n a[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));\n a[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));\n a[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21));\n a[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));\n a[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11));\n\n return this;\n },\n\n /**\n * Calculate the determinant of this Matrix.\n *\n * @method Phaser.Math.Matrix4#determinant\n * @since 3.0.0\n *\n * @return {number} The determinant of this Matrix.\n */\n determinant: function ()\n {\n var a = this.val;\n\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n var a30 = a[12];\n var a31 = a[13];\n var a32 = a[14];\n var a33 = a[15];\n\n var b00 = a00 * a11 - a01 * a10;\n var b01 = a00 * a12 - a02 * a10;\n var b02 = a00 * a13 - a03 * a10;\n var b03 = a01 * a12 - a02 * a11;\n var b04 = a01 * a13 - a03 * a11;\n var b05 = a02 * a13 - a03 * a12;\n var b06 = a20 * a31 - a21 * a30;\n var b07 = a20 * a32 - a22 * a30;\n var b08 = a20 * a33 - a23 * a30;\n var b09 = a21 * a32 - a22 * a31;\n var b10 = a21 * a33 - a23 * a31;\n var b11 = a22 * a33 - a23 * a32;\n\n // Calculate the determinant\n return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n },\n\n /**\n * Multiply this Matrix by the given Matrix.\n *\n * @method Phaser.Math.Matrix4#multiply\n * @since 3.0.0\n *\n * @param {Phaser.Math.Matrix4} src - The Matrix to multiply this Matrix by.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n multiply: function (src)\n {\n var a = this.val;\n\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n var a30 = a[12];\n var a31 = a[13];\n var a32 = a[14];\n var a33 = a[15];\n\n var b = src.val;\n\n // Cache only the current line of the second matrix\n var b0 = b[0];\n var b1 = b[1];\n var b2 = b[2];\n var b3 = b[3];\n\n a[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n a[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n a[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n a[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n\n b0 = b[4];\n b1 = b[5];\n b2 = b[6];\n b3 = b[7];\n\n a[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n a[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n a[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n a[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n\n b0 = b[8];\n b1 = b[9];\n b2 = b[10];\n b3 = b[11];\n\n a[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n a[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n a[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n a[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n\n b0 = b[12];\n b1 = b[13];\n b2 = b[14];\n b3 = b[15];\n\n a[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;\n a[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;\n a[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;\n a[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;\n\n return this;\n },\n\n /**\n * [description]\n *\n * @method Phaser.Math.Matrix4#multiplyLocal\n * @since 3.0.0\n *\n * @param {Phaser.Math.Matrix4} src - [description]\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n multiplyLocal: function (src)\n {\n var a = [];\n var m1 = this.val;\n var m2 = src.val;\n\n a[0] = m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12];\n a[1] = m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13];\n a[2] = m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14];\n a[3] = m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15];\n\n a[4] = m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12];\n a[5] = m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13];\n a[6] = m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14];\n a[7] = m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15];\n\n a[8] = m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12];\n a[9] = m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13];\n a[10] = m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14];\n a[11] = m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15];\n\n a[12] = m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12];\n a[13] = m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13];\n a[14] = m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14];\n a[15] = m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15];\n\n return this.fromArray(a);\n },\n\n /**\n * Translate this Matrix using the given Vector.\n *\n * @method Phaser.Math.Matrix4#translate\n * @since 3.0.0\n *\n * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to translate this Matrix with.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n translate: function (v)\n {\n var x = v.x;\n var y = v.y;\n var z = v.z;\n var a = this.val;\n\n a[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\n a[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\n a[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\n a[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\n\n return this;\n },\n\n /**\n * Translate this Matrix using the given values.\n *\n * @method Phaser.Math.Matrix4#translateXYZ\n * @since 3.16.0\n *\n * @param {number} x - The x component.\n * @param {number} y - The y component.\n * @param {number} z - The z component.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n translateXYZ: function (x, y, z)\n {\n var a = this.val;\n\n a[12] = a[0] * x + a[4] * y + a[8] * z + a[12];\n a[13] = a[1] * x + a[5] * y + a[9] * z + a[13];\n a[14] = a[2] * x + a[6] * y + a[10] * z + a[14];\n a[15] = a[3] * x + a[7] * y + a[11] * z + a[15];\n\n return this;\n },\n\n /**\n * Apply a scale transformation to this Matrix.\n *\n * Uses the `x`, `y` and `z` components of the given Vector to scale the Matrix.\n *\n * @method Phaser.Math.Matrix4#scale\n * @since 3.0.0\n *\n * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to scale this Matrix with.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n scale: function (v)\n {\n var x = v.x;\n var y = v.y;\n var z = v.z;\n var a = this.val;\n\n a[0] = a[0] * x;\n a[1] = a[1] * x;\n a[2] = a[2] * x;\n a[3] = a[3] * x;\n\n a[4] = a[4] * y;\n a[5] = a[5] * y;\n a[6] = a[6] * y;\n a[7] = a[7] * y;\n\n a[8] = a[8] * z;\n a[9] = a[9] * z;\n a[10] = a[10] * z;\n a[11] = a[11] * z;\n\n return this;\n },\n\n /**\n * Apply a scale transformation to this Matrix.\n *\n * @method Phaser.Math.Matrix4#scaleXYZ\n * @since 3.16.0\n *\n * @param {number} x - The x component.\n * @param {number} y - The y component.\n * @param {number} z - The z component.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n scaleXYZ: function (x, y, z)\n {\n var a = this.val;\n\n a[0] = a[0] * x;\n a[1] = a[1] * x;\n a[2] = a[2] * x;\n a[3] = a[3] * x;\n\n a[4] = a[4] * y;\n a[5] = a[5] * y;\n a[6] = a[6] * y;\n a[7] = a[7] * y;\n\n a[8] = a[8] * z;\n a[9] = a[9] * z;\n a[10] = a[10] * z;\n a[11] = a[11] * z;\n\n return this;\n },\n\n /**\n * Derive a rotation matrix around the given axis.\n *\n * @method Phaser.Math.Matrix4#makeRotationAxis\n * @since 3.0.0\n *\n * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis.\n * @param {number} angle - The rotation angle in radians.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n makeRotationAxis: function (axis, angle)\n {\n // Based on http://www.gamedev.net/reference/articles/article1199.asp\n\n var c = Math.cos(angle);\n var s = Math.sin(angle);\n var t = 1 - c;\n var x = axis.x;\n var y = axis.y;\n var z = axis.z;\n var tx = t * x;\n var ty = t * y;\n\n this.fromArray([\n tx * x + c, tx * y - s * z, tx * z + s * y, 0,\n tx * y + s * z, ty * y + c, ty * z - s * x, 0,\n tx * z - s * y, ty * z + s * x, t * z * z + c, 0,\n 0, 0, 0, 1\n ]);\n\n return this;\n },\n\n /**\n * Apply a rotation transformation to this Matrix.\n *\n * @method Phaser.Math.Matrix4#rotate\n * @since 3.0.0\n *\n * @param {number} rad - The angle in radians to rotate by.\n * @param {Phaser.Math.Vector3} axis - The axis to rotate upon.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n rotate: function (rad, axis)\n {\n var a = this.val;\n var x = axis.x;\n var y = axis.y;\n var z = axis.z;\n var len = Math.sqrt(x * x + y * y + z * z);\n\n if (Math.abs(len) < EPSILON)\n {\n return null;\n }\n\n len = 1 / len;\n x *= len;\n y *= len;\n z *= len;\n\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n var t = 1 - c;\n\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n // Construct the elements of the rotation matrix\n var b00 = x * x * t + c;\n var b01 = y * x * t + z * s;\n var b02 = z * x * t - y * s;\n\n var b10 = x * y * t - z * s;\n var b11 = y * y * t + c;\n var b12 = z * y * t + x * s;\n\n var b20 = x * z * t + y * s;\n var b21 = y * z * t - x * s;\n var b22 = z * z * t + c;\n\n // Perform rotation-specific matrix multiplication\n a[0] = a00 * b00 + a10 * b01 + a20 * b02;\n a[1] = a01 * b00 + a11 * b01 + a21 * b02;\n a[2] = a02 * b00 + a12 * b01 + a22 * b02;\n a[3] = a03 * b00 + a13 * b01 + a23 * b02;\n a[4] = a00 * b10 + a10 * b11 + a20 * b12;\n a[5] = a01 * b10 + a11 * b11 + a21 * b12;\n a[6] = a02 * b10 + a12 * b11 + a22 * b12;\n a[7] = a03 * b10 + a13 * b11 + a23 * b12;\n a[8] = a00 * b20 + a10 * b21 + a20 * b22;\n a[9] = a01 * b20 + a11 * b21 + a21 * b22;\n a[10] = a02 * b20 + a12 * b21 + a22 * b22;\n a[11] = a03 * b20 + a13 * b21 + a23 * b22;\n\n return this;\n },\n\n /**\n * Rotate this matrix on its X axis.\n *\n * @method Phaser.Math.Matrix4#rotateX\n * @since 3.0.0\n *\n * @param {number} rad - The angle in radians to rotate by.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n rotateX: function (rad)\n {\n var a = this.val;\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n // Perform axis-specific matrix multiplication\n a[4] = a10 * c + a20 * s;\n a[5] = a11 * c + a21 * s;\n a[6] = a12 * c + a22 * s;\n a[7] = a13 * c + a23 * s;\n a[8] = a20 * c - a10 * s;\n a[9] = a21 * c - a11 * s;\n a[10] = a22 * c - a12 * s;\n a[11] = a23 * c - a13 * s;\n\n return this;\n },\n\n /**\n * Rotate this matrix on its Y axis.\n *\n * @method Phaser.Math.Matrix4#rotateY\n * @since 3.0.0\n *\n * @param {number} rad - The angle to rotate by, in radians.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n rotateY: function (rad)\n {\n var a = this.val;\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n\n var a20 = a[8];\n var a21 = a[9];\n var a22 = a[10];\n var a23 = a[11];\n\n // Perform axis-specific matrix multiplication\n a[0] = a00 * c - a20 * s;\n a[1] = a01 * c - a21 * s;\n a[2] = a02 * c - a22 * s;\n a[3] = a03 * c - a23 * s;\n a[8] = a00 * s + a20 * c;\n a[9] = a01 * s + a21 * c;\n a[10] = a02 * s + a22 * c;\n a[11] = a03 * s + a23 * c;\n\n return this;\n },\n\n /**\n * Rotate this matrix on its Z axis.\n *\n * @method Phaser.Math.Matrix4#rotateZ\n * @since 3.0.0\n *\n * @param {number} rad - The angle to rotate by, in radians.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n rotateZ: function (rad)\n {\n var a = this.val;\n var s = Math.sin(rad);\n var c = Math.cos(rad);\n\n var a00 = a[0];\n var a01 = a[1];\n var a02 = a[2];\n var a03 = a[3];\n\n var a10 = a[4];\n var a11 = a[5];\n var a12 = a[6];\n var a13 = a[7];\n\n // Perform axis-specific matrix multiplication\n a[0] = a00 * c + a10 * s;\n a[1] = a01 * c + a11 * s;\n a[2] = a02 * c + a12 * s;\n a[3] = a03 * c + a13 * s;\n a[4] = a10 * c - a00 * s;\n a[5] = a11 * c - a01 * s;\n a[6] = a12 * c - a02 * s;\n a[7] = a13 * c - a03 * s;\n\n return this;\n },\n\n /**\n * Set the values of this Matrix from the given rotation Quaternion and translation Vector.\n *\n * @method Phaser.Math.Matrix4#fromRotationTranslation\n * @since 3.0.0\n *\n * @param {Phaser.Math.Quaternion} q - The Quaternion to set rotation from.\n * @param {Phaser.Math.Vector3} v - The Vector to set translation from.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n fromRotationTranslation: function (q, v)\n {\n // Quaternion math\n var out = this.val;\n\n var x = q.x;\n var y = q.y;\n var z = q.z;\n var w = q.w;\n\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n\n out[0] = 1 - (yy + zz);\n out[1] = xy + wz;\n out[2] = xz - wy;\n out[3] = 0;\n\n out[4] = xy - wz;\n out[5] = 1 - (xx + zz);\n out[6] = yz + wx;\n out[7] = 0;\n\n out[8] = xz + wy;\n out[9] = yz - wx;\n out[10] = 1 - (xx + yy);\n out[11] = 0;\n\n out[12] = v.x;\n out[13] = v.y;\n out[14] = v.z;\n out[15] = 1;\n\n return this;\n },\n\n /**\n * Set the values of this Matrix from the given Quaternion.\n *\n * @method Phaser.Math.Matrix4#fromQuat\n * @since 3.0.0\n *\n * @param {Phaser.Math.Quaternion} q - The Quaternion to set the values of this Matrix from.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n fromQuat: function (q)\n {\n var out = this.val;\n\n var x = q.x;\n var y = q.y;\n var z = q.z;\n var w = q.w;\n\n var x2 = x + x;\n var y2 = y + y;\n var z2 = z + z;\n\n var xx = x * x2;\n var xy = x * y2;\n var xz = x * z2;\n\n var yy = y * y2;\n var yz = y * z2;\n var zz = z * z2;\n\n var wx = w * x2;\n var wy = w * y2;\n var wz = w * z2;\n\n out[0] = 1 - (yy + zz);\n out[1] = xy + wz;\n out[2] = xz - wy;\n out[3] = 0;\n\n out[4] = xy - wz;\n out[5] = 1 - (xx + zz);\n out[6] = yz + wx;\n out[7] = 0;\n\n out[8] = xz + wy;\n out[9] = yz - wx;\n out[10] = 1 - (xx + yy);\n out[11] = 0;\n\n out[12] = 0;\n out[13] = 0;\n out[14] = 0;\n out[15] = 1;\n\n return this;\n },\n\n /**\n * Generate a frustum matrix with the given bounds.\n *\n * @method Phaser.Math.Matrix4#frustum\n * @since 3.0.0\n *\n * @param {number} left - The left bound of the frustum.\n * @param {number} right - The right bound of the frustum.\n * @param {number} bottom - The bottom bound of the frustum.\n * @param {number} top - The top bound of the frustum.\n * @param {number} near - The near bound of the frustum.\n * @param {number} far - The far bound of the frustum.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n frustum: function (left, right, bottom, top, near, far)\n {\n var out = this.val;\n\n var rl = 1 / (right - left);\n var tb = 1 / (top - bottom);\n var nf = 1 / (near - far);\n\n out[0] = (near * 2) * rl;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n\n out[4] = 0;\n out[5] = (near * 2) * tb;\n out[6] = 0;\n out[7] = 0;\n\n out[8] = (right + left) * rl;\n out[9] = (top + bottom) * tb;\n out[10] = (far + near) * nf;\n out[11] = -1;\n\n out[12] = 0;\n out[13] = 0;\n out[14] = (far * near * 2) * nf;\n out[15] = 0;\n\n return this;\n },\n\n /**\n * Generate a perspective projection matrix with the given bounds.\n *\n * @method Phaser.Math.Matrix4#perspective\n * @since 3.0.0\n *\n * @param {number} fovy - Vertical field of view in radians\n * @param {number} aspect - Aspect ratio. Typically viewport width /height.\n * @param {number} near - Near bound of the frustum.\n * @param {number} far - Far bound of the frustum.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n perspective: function (fovy, aspect, near, far)\n {\n var out = this.val;\n var f = 1.0 / Math.tan(fovy / 2);\n var nf = 1 / (near - far);\n\n out[0] = f / aspect;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n\n out[4] = 0;\n out[5] = f;\n out[6] = 0;\n out[7] = 0;\n\n out[8] = 0;\n out[9] = 0;\n out[10] = (far + near) * nf;\n out[11] = -1;\n\n out[12] = 0;\n out[13] = 0;\n out[14] = (2 * far * near) * nf;\n out[15] = 0;\n\n return this;\n },\n\n /**\n * Generate a perspective projection matrix with the given bounds.\n *\n * @method Phaser.Math.Matrix4#perspectiveLH\n * @since 3.0.0\n *\n * @param {number} width - The width of the frustum.\n * @param {number} height - The height of the frustum.\n * @param {number} near - Near bound of the frustum.\n * @param {number} far - Far bound of the frustum.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n perspectiveLH: function (width, height, near, far)\n {\n var out = this.val;\n\n out[0] = (2 * near) / width;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n\n out[4] = 0;\n out[5] = (2 * near) / height;\n out[6] = 0;\n out[7] = 0;\n\n out[8] = 0;\n out[9] = 0;\n out[10] = -far / (near - far);\n out[11] = 1;\n\n out[12] = 0;\n out[13] = 0;\n out[14] = (near * far) / (near - far);\n out[15] = 0;\n\n return this;\n },\n\n /**\n * Generate an orthogonal projection matrix with the given bounds.\n *\n * @method Phaser.Math.Matrix4#ortho\n * @since 3.0.0\n *\n * @param {number} left - The left bound of the frustum.\n * @param {number} right - The right bound of the frustum.\n * @param {number} bottom - The bottom bound of the frustum.\n * @param {number} top - The top bound of the frustum.\n * @param {number} near - The near bound of the frustum.\n * @param {number} far - The far bound of the frustum.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n ortho: function (left, right, bottom, top, near, far)\n {\n var out = this.val;\n var lr = left - right;\n var bt = bottom - top;\n var nf = near - far;\n\n // Avoid division by zero\n lr = (lr === 0) ? lr : 1 / lr;\n bt = (bt === 0) ? bt : 1 / bt;\n nf = (nf === 0) ? nf : 1 / nf;\n\n out[0] = -2 * lr;\n out[1] = 0;\n out[2] = 0;\n out[3] = 0;\n\n out[4] = 0;\n out[5] = -2 * bt;\n out[6] = 0;\n out[7] = 0;\n\n out[8] = 0;\n out[9] = 0;\n out[10] = 2 * nf;\n out[11] = 0;\n\n out[12] = (left + right) * lr;\n out[13] = (top + bottom) * bt;\n out[14] = (far + near) * nf;\n out[15] = 1;\n\n return this;\n },\n\n /**\n * Generate a look-at matrix with the given eye position, focal point, and up axis.\n *\n * @method Phaser.Math.Matrix4#lookAt\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector3} eye - Position of the viewer\n * @param {Phaser.Math.Vector3} center - Point the viewer is looking at\n * @param {Phaser.Math.Vector3} up - vec3 pointing up.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n lookAt: function (eye, center, up)\n {\n var out = this.val;\n\n var eyex = eye.x;\n var eyey = eye.y;\n var eyez = eye.z;\n\n var upx = up.x;\n var upy = up.y;\n var upz = up.z;\n\n var centerx = center.x;\n var centery = center.y;\n var centerz = center.z;\n\n if (Math.abs(eyex - centerx) < EPSILON &&\n Math.abs(eyey - centery) < EPSILON &&\n Math.abs(eyez - centerz) < EPSILON)\n {\n return this.identity();\n }\n\n var z0 = eyex - centerx;\n var z1 = eyey - centery;\n var z2 = eyez - centerz;\n\n var len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);\n\n z0 *= len;\n z1 *= len;\n z2 *= len;\n\n var x0 = upy * z2 - upz * z1;\n var x1 = upz * z0 - upx * z2;\n var x2 = upx * z1 - upy * z0;\n\n len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);\n\n if (!len)\n {\n x0 = 0;\n x1 = 0;\n x2 = 0;\n }\n else\n {\n len = 1 / len;\n x0 *= len;\n x1 *= len;\n x2 *= len;\n }\n\n var y0 = z1 * x2 - z2 * x1;\n var y1 = z2 * x0 - z0 * x2;\n var y2 = z0 * x1 - z1 * x0;\n\n len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);\n\n if (!len)\n {\n y0 = 0;\n y1 = 0;\n y2 = 0;\n }\n else\n {\n len = 1 / len;\n y0 *= len;\n y1 *= len;\n y2 *= len;\n }\n\n out[0] = x0;\n out[1] = y0;\n out[2] = z0;\n out[3] = 0;\n\n out[4] = x1;\n out[5] = y1;\n out[6] = z1;\n out[7] = 0;\n\n out[8] = x2;\n out[9] = y2;\n out[10] = z2;\n out[11] = 0;\n\n out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);\n out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);\n out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);\n out[15] = 1;\n\n return this;\n },\n\n /**\n * Set the values of this matrix from the given `yaw`, `pitch` and `roll` values.\n *\n * @method Phaser.Math.Matrix4#yawPitchRoll\n * @since 3.0.0\n *\n * @param {number} yaw - [description]\n * @param {number} pitch - [description]\n * @param {number} roll - [description]\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n yawPitchRoll: function (yaw, pitch, roll)\n {\n this.zero();\n _tempMat1.zero();\n _tempMat2.zero();\n\n var m0 = this.val;\n var m1 = _tempMat1.val;\n var m2 = _tempMat2.val;\n\n // Rotate Z\n var s = Math.sin(roll);\n var c = Math.cos(roll);\n\n m0[10] = 1;\n m0[15] = 1;\n m0[0] = c;\n m0[1] = s;\n m0[4] = -s;\n m0[5] = c;\n\n // Rotate X\n s = Math.sin(pitch);\n c = Math.cos(pitch);\n\n m1[0] = 1;\n m1[15] = 1;\n m1[5] = c;\n m1[10] = c;\n m1[9] = -s;\n m1[6] = s;\n\n // Rotate Y\n s = Math.sin(yaw);\n c = Math.cos(yaw);\n\n m2[5] = 1;\n m2[15] = 1;\n m2[0] = c;\n m2[2] = -s;\n m2[8] = s;\n m2[10] = c;\n\n this.multiplyLocal(_tempMat1);\n this.multiplyLocal(_tempMat2);\n\n return this;\n },\n\n /**\n * Generate a world matrix from the given rotation, position, scale, view matrix and projection matrix.\n *\n * @method Phaser.Math.Matrix4#setWorldMatrix\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector3} rotation - The rotation of the world matrix.\n * @param {Phaser.Math.Vector3} position - The position of the world matrix.\n * @param {Phaser.Math.Vector3} scale - The scale of the world matrix.\n * @param {Phaser.Math.Matrix4} [viewMatrix] - The view matrix.\n * @param {Phaser.Math.Matrix4} [projectionMatrix] - The projection matrix.\n *\n * @return {Phaser.Math.Matrix4} This Matrix4.\n */\n setWorldMatrix: function (rotation, position, scale, viewMatrix, projectionMatrix)\n {\n this.yawPitchRoll(rotation.y, rotation.x, rotation.z);\n\n _tempMat1.scaling(scale.x, scale.y, scale.z);\n _tempMat2.xyz(position.x, position.y, position.z);\n\n this.multiplyLocal(_tempMat1);\n this.multiplyLocal(_tempMat2);\n\n if (viewMatrix !== undefined)\n {\n this.multiplyLocal(viewMatrix);\n }\n\n if (projectionMatrix !== undefined)\n {\n this.multiplyLocal(projectionMatrix);\n }\n\n return this;\n }\n\n});\n\nvar _tempMat1 = new Matrix4();\nvar _tempMat2 = new Matrix4();\n\nmodule.exports = Matrix4;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n// Adapted from [gl-matrix](https://github.com/toji/gl-matrix) by toji\n// and [vecmath](https://github.com/mattdesl/vecmath) by mattdesl\n\nvar Class = require('../utils/Class');\n\n/**\n * @typedef {object} Vector2Like\n *\n * @property {number} x - The x component.\n * @property {number} y - The y component.\n */\n\n/**\n * @classdesc\n * A representation of a vector in 2D space.\n *\n * A two-component vector.\n *\n * @class Vector2\n * @memberof Phaser.Math\n * @constructor\n * @since 3.0.0\n *\n * @param {number|Vector2Like} [x] - The x component, or an object with `x` and `y` properties.\n * @param {number} [y] - The y component.\n */\nvar Vector2 = new Class({\n\n initialize:\n\n function Vector2 (x, y)\n {\n /**\n * The x component of this Vector.\n *\n * @name Phaser.Math.Vector2#x\n * @type {number}\n * @default 0\n * @since 3.0.0\n */\n this.x = 0;\n\n /**\n * The y component of this Vector.\n *\n * @name Phaser.Math.Vector2#y\n * @type {number}\n * @default 0\n * @since 3.0.0\n */\n this.y = 0;\n\n if (typeof x === 'object')\n {\n this.x = x.x || 0;\n this.y = x.y || 0;\n }\n else\n {\n if (y === undefined) { y = x; }\n\n this.x = x || 0;\n this.y = y || 0;\n }\n },\n\n /**\n * Make a clone of this Vector2.\n *\n * @method Phaser.Math.Vector2#clone\n * @since 3.0.0\n *\n * @return {Phaser.Math.Vector2} A clone of this Vector2.\n */\n clone: function ()\n {\n return new Vector2(this.x, this.y);\n },\n\n /**\n * Copy the components of a given Vector into this Vector.\n *\n * @method Phaser.Math.Vector2#copy\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector to copy the components from.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n copy: function (src)\n {\n this.x = src.x || 0;\n this.y = src.y || 0;\n\n return this;\n },\n\n /**\n * Set the component values of this Vector from a given Vector2Like object.\n *\n * @method Phaser.Math.Vector2#setFromObject\n * @since 3.0.0\n *\n * @param {Vector2Like} obj - The object containing the component values to set for this Vector.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n setFromObject: function (obj)\n {\n this.x = obj.x || 0;\n this.y = obj.y || 0;\n\n return this;\n },\n\n /**\n * Set the `x` and `y` components of the this Vector to the given `x` and `y` values.\n *\n * @method Phaser.Math.Vector2#set\n * @since 3.0.0\n *\n * @param {number} x - The x value to set for this Vector.\n * @param {number} [y=x] - The y value to set for this Vector.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n set: function (x, y)\n {\n if (y === undefined) { y = x; }\n\n this.x = x;\n this.y = y;\n\n return this;\n },\n\n /**\n * This method is an alias for `Vector2.set`.\n *\n * @method Phaser.Math.Vector2#setTo\n * @since 3.4.0\n *\n * @param {number} x - The x value to set for this Vector.\n * @param {number} [y=x] - The y value to set for this Vector.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n setTo: function (x, y)\n {\n return this.set(x, y);\n },\n\n /**\n * Sets the `x` and `y` values of this object from a given polar coordinate.\n *\n * @method Phaser.Math.Vector2#setToPolar\n * @since 3.0.0\n *\n * @param {number} azimuth - The angular coordinate, in radians.\n * @param {number} [radius=1] - The radial coordinate (length).\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n setToPolar: function (azimuth, radius)\n {\n if (radius == null) { radius = 1; }\n\n this.x = Math.cos(azimuth) * radius;\n this.y = Math.sin(azimuth) * radius;\n\n return this;\n },\n\n /**\n * Check whether this Vector is equal to a given Vector.\n *\n * Performs a strict equality check against each Vector's components.\n *\n * @method Phaser.Math.Vector2#equals\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} v - The vector to compare with this Vector.\n *\n * @return {boolean} Whether the given Vector is equal to this Vector.\n */\n equals: function (v)\n {\n return ((this.x === v.x) && (this.y === v.y));\n },\n\n /**\n * Calculate the angle between this Vector and the positive x-axis, in radians.\n *\n * @method Phaser.Math.Vector2#angle\n * @since 3.0.0\n *\n * @return {number} The angle between this Vector, and the positive x-axis, given in radians.\n */\n angle: function ()\n {\n // computes the angle in radians with respect to the positive x-axis\n\n var angle = Math.atan2(this.y, this.x);\n\n if (angle < 0)\n {\n angle += 2 * Math.PI;\n }\n\n return angle;\n },\n\n /**\n * Add a given Vector to this Vector. Addition is component-wise.\n *\n * @method Phaser.Math.Vector2#add\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector to add to this Vector.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n add: function (src)\n {\n this.x += src.x;\n this.y += src.y;\n\n return this;\n },\n\n /**\n * Subtract the given Vector from this Vector. Subtraction is component-wise.\n *\n * @method Phaser.Math.Vector2#subtract\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector to subtract from this Vector.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n subtract: function (src)\n {\n this.x -= src.x;\n this.y -= src.y;\n\n return this;\n },\n\n /**\n * Perform a component-wise multiplication between this Vector and the given Vector.\n *\n * Multiplies this Vector by the given Vector.\n *\n * @method Phaser.Math.Vector2#multiply\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector to multiply this Vector by.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n multiply: function (src)\n {\n this.x *= src.x;\n this.y *= src.y;\n\n return this;\n },\n\n /**\n * Scale this Vector by the given value.\n *\n * @method Phaser.Math.Vector2#scale\n * @since 3.0.0\n *\n * @param {number} value - The value to scale this Vector by.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n scale: function (value)\n {\n if (isFinite(value))\n {\n this.x *= value;\n this.y *= value;\n }\n else\n {\n this.x = 0;\n this.y = 0;\n }\n\n return this;\n },\n\n /**\n * Perform a component-wise division between this Vector and the given Vector.\n *\n * Divides this Vector by the given Vector.\n *\n * @method Phaser.Math.Vector2#divide\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector to divide this Vector by.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n divide: function (src)\n {\n this.x /= src.x;\n this.y /= src.y;\n\n return this;\n },\n\n /**\n * Negate the `x` and `y` components of this Vector.\n *\n * @method Phaser.Math.Vector2#negate\n * @since 3.0.0\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n negate: function ()\n {\n this.x = -this.x;\n this.y = -this.y;\n\n return this;\n },\n\n /**\n * Calculate the distance between this Vector and the given Vector.\n *\n * @method Phaser.Math.Vector2#distance\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to.\n *\n * @return {number} The distance from this Vector to the given Vector.\n */\n distance: function (src)\n {\n var dx = src.x - this.x;\n var dy = src.y - this.y;\n\n return Math.sqrt(dx * dx + dy * dy);\n },\n\n /**\n * Calculate the distance between this Vector and the given Vector, squared.\n *\n * @method Phaser.Math.Vector2#distanceSq\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector to calculate the distance to.\n *\n * @return {number} The distance from this Vector to the given Vector, squared.\n */\n distanceSq: function (src)\n {\n var dx = src.x - this.x;\n var dy = src.y - this.y;\n\n return dx * dx + dy * dy;\n },\n\n /**\n * Calculate the length (or magnitude) of this Vector.\n *\n * @method Phaser.Math.Vector2#length\n * @since 3.0.0\n *\n * @return {number} The length of this Vector.\n */\n length: function ()\n {\n var x = this.x;\n var y = this.y;\n\n return Math.sqrt(x * x + y * y);\n },\n\n /**\n * Calculate the length of this Vector squared.\n *\n * @method Phaser.Math.Vector2#lengthSq\n * @since 3.0.0\n *\n * @return {number} The length of this Vector, squared.\n */\n lengthSq: function ()\n {\n var x = this.x;\n var y = this.y;\n\n return x * x + y * y;\n },\n\n /**\n * Normalize this Vector.\n *\n * Makes the vector a unit length vector (magnitude of 1) in the same direction.\n *\n * @method Phaser.Math.Vector2#normalize\n * @since 3.0.0\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n normalize: function ()\n {\n var x = this.x;\n var y = this.y;\n var len = x * x + y * y;\n\n if (len > 0)\n {\n len = 1 / Math.sqrt(len);\n\n this.x = x * len;\n this.y = y * len;\n }\n\n return this;\n },\n\n /**\n * Right-hand normalize (make unit length) this Vector.\n *\n * @method Phaser.Math.Vector2#normalizeRightHand\n * @since 3.0.0\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n normalizeRightHand: function ()\n {\n var x = this.x;\n\n this.x = this.y * -1;\n this.y = x;\n\n return this;\n },\n\n /**\n * Calculate the dot product of this Vector and the given Vector.\n *\n * @method Phaser.Math.Vector2#dot\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector2 to dot product with this Vector2.\n *\n * @return {number} The dot product of this Vector and the given Vector.\n */\n dot: function (src)\n {\n return this.x * src.x + this.y * src.y;\n },\n\n /**\n * Calculate the cross product of this Vector and the given Vector.\n *\n * @method Phaser.Math.Vector2#cross\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector2 to cross with this Vector2.\n *\n * @return {number} The cross product of this Vector and the given Vector.\n */\n cross: function (src)\n {\n return this.x * src.y - this.y * src.x;\n },\n\n /**\n * Linearly interpolate between this Vector and the given Vector.\n *\n * Interpolates this Vector towards the given Vector.\n *\n * @method Phaser.Math.Vector2#lerp\n * @since 3.0.0\n *\n * @param {Phaser.Math.Vector2} src - The Vector2 to interpolate towards.\n * @param {number} [t=0] - The interpolation percentage, between 0 and 1.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n lerp: function (src, t)\n {\n if (t === undefined) { t = 0; }\n\n var ax = this.x;\n var ay = this.y;\n\n this.x = ax + t * (src.x - ax);\n this.y = ay + t * (src.y - ay);\n\n return this;\n },\n\n /**\n * Transform this Vector with the given Matrix.\n *\n * @method Phaser.Math.Vector2#transformMat3\n * @since 3.0.0\n *\n * @param {Phaser.Math.Matrix3} mat - The Matrix3 to transform this Vector2 with.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n transformMat3: function (mat)\n {\n var x = this.x;\n var y = this.y;\n var m = mat.val;\n\n this.x = m[0] * x + m[3] * y + m[6];\n this.y = m[1] * x + m[4] * y + m[7];\n\n return this;\n },\n\n /**\n * Transform this Vector with the given Matrix.\n *\n * @method Phaser.Math.Vector2#transformMat4\n * @since 3.0.0\n *\n * @param {Phaser.Math.Matrix4} mat - The Matrix4 to transform this Vector2 with.\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n transformMat4: function (mat)\n {\n var x = this.x;\n var y = this.y;\n var m = mat.val;\n\n this.x = m[0] * x + m[4] * y + m[12];\n this.y = m[1] * x + m[5] * y + m[13];\n\n return this;\n },\n\n /**\n * Make this Vector the zero vector (0, 0).\n *\n * @method Phaser.Math.Vector2#reset\n * @since 3.0.0\n *\n * @return {Phaser.Math.Vector2} This Vector2.\n */\n reset: function ()\n {\n this.x = 0;\n this.y = 0;\n\n return this;\n }\n\n});\n\n/**\n * A static zero Vector2 for use by reference.\n *\n * @constant\n * @name Phaser.Math.Vector2.ZERO\n * @type {Vector2}\n * @since 3.1.0\n */\nVector2.ZERO = new Vector2();\n\nmodule.exports = Vector2;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * Wrap the given `value` between `min` and `max.\n *\n * @function Phaser.Math.Wrap\n * @since 3.0.0\n *\n * @param {number} value - The value to wrap.\n * @param {number} min - The minimum value.\n * @param {number} max - The maximum value.\n *\n * @return {number} The wrapped value.\n */\nvar Wrap = function (value, min, max)\n{\n var range = max - min;\n\n return (min + ((((value - min) % range) + range) % range));\n};\n\nmodule.exports = Wrap;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar CONST = require('../const');\n\n/**\n * Takes an angle in Phasers default clockwise format and converts it so that\n * 0 is North, 90 is West, 180 is South and 270 is East,\n * therefore running counter-clockwise instead of clockwise.\n * \n * You can pass in the angle from a Game Object using:\n * \n * ```javascript\n * var converted = CounterClockwise(gameobject.rotation);\n * ```\n * \n * All values for this function are in radians.\n *\n * @function Phaser.Math.Angle.CounterClockwise\n * @since 3.16.0\n *\n * @param {number} angle - The angle to convert, in radians.\n *\n * @return {number} The converted angle, in radians.\n */\nvar CounterClockwise = function (angle)\n{\n return Math.abs((((angle + CONST.TAU) % CONST.PI2) - CONST.PI2) % CONST.PI2);\n};\n\nmodule.exports = CounterClockwise;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar MathWrap = require('../Wrap');\n\n/**\n * Wrap an angle.\n *\n * Wraps the angle to a value in the range of -PI to PI.\n *\n * @function Phaser.Math.Angle.Wrap\n * @since 3.0.0\n *\n * @param {number} angle - The angle to wrap, in radians.\n *\n * @return {number} The wrapped angle, in radians.\n */\nvar Wrap = function (angle)\n{\n return MathWrap(angle, -Math.PI, Math.PI);\n};\n\nmodule.exports = Wrap;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Wrap = require('../Wrap');\n\n/**\n * Wrap an angle in degrees.\n *\n * Wraps the angle to a value in the range of -180 to 180.\n *\n * @function Phaser.Math.Angle.WrapDegrees\n * @since 3.0.0\n *\n * @param {number} angle - The angle to wrap, in degrees.\n *\n * @return {number} The wrapped angle, in degrees.\n */\nvar WrapDegrees = function (angle)\n{\n return Wrap(angle, -180, 180);\n};\n\nmodule.exports = WrapDegrees;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar MATH_CONST = {\n\n /**\n * The value of PI * 2.\n * \n * @name Phaser.Math.PI2\n * @type {number}\n * @since 3.0.0\n */\n PI2: Math.PI * 2,\n\n /**\n * The value of PI * 0.5.\n * \n * @name Phaser.Math.TAU\n * @type {number}\n * @since 3.0.0\n */\n TAU: Math.PI * 0.5,\n\n /**\n * An epsilon value (1.0e-6)\n * \n * @name Phaser.Math.EPSILON\n * @type {number}\n * @since 3.0.0\n */\n EPSILON: 1.0e-6,\n\n /**\n * For converting degrees to radians (PI / 180)\n * \n * @name Phaser.Math.DEG_TO_RAD\n * @type {number}\n * @since 3.0.0\n */\n DEG_TO_RAD: Math.PI / 180,\n\n /**\n * For converting radians to degrees (180 / PI)\n * \n * @name Phaser.Math.RAD_TO_DEG\n * @type {number}\n * @since 3.0.0\n */\n RAD_TO_DEG: 180 / Math.PI,\n\n /**\n * An instance of the Random Number Generator.\n * \n * @name Phaser.Math.RND\n * @type {Phaser.Math.RandomDataGenerator}\n * @since 3.0.0\n */\n RND: null\n\n};\n\nmodule.exports = MATH_CONST;\n","/**\n* @author Richard Davey \n* @copyright 2018 Photon Storm Ltd.\n* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License}\n*/\n\nvar Class = require('../utils/Class');\n\n/**\n * @classdesc\n * A Global Plugin is installed just once into the Game owned Plugin Manager.\n * It can listen for Game events and respond to them.\n *\n * @class BasePlugin\n * @memberof Phaser.Plugins\n * @constructor\n * @since 3.8.0\n *\n * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager.\n */\nvar BasePlugin = new Class({\n\n initialize:\n\n function BasePlugin (pluginManager)\n {\n /**\n * A handy reference to the Plugin Manager that is responsible for this plugin.\n * Can be used as a route to gain access to game systems and events.\n *\n * @name Phaser.Plugins.BasePlugin#pluginManager\n * @type {Phaser.Plugins.PluginManager}\n * @protected\n * @since 3.8.0\n */\n this.pluginManager = pluginManager;\n\n /**\n * A reference to the Game instance this plugin is running under.\n *\n * @name Phaser.Plugins.BasePlugin#game\n * @type {Phaser.Game}\n * @protected\n * @since 3.8.0\n */\n this.game = pluginManager.game;\n\n /**\n * A reference to the Scene that has installed this plugin.\n * Only set if it's a Scene Plugin, otherwise `null`.\n * This property is only set when the plugin is instantiated and added to the Scene, not before.\n * You cannot use it during the `init` method, but you can during the `boot` method.\n *\n * @name Phaser.Plugins.BasePlugin#scene\n * @type {?Phaser.Scene}\n * @protected\n * @since 3.8.0\n */\n this.scene;\n\n /**\n * A reference to the Scene Systems of the Scene that has installed this plugin.\n * Only set if it's a Scene Plugin, otherwise `null`.\n * This property is only set when the plugin is instantiated and added to the Scene, not before.\n * You cannot use it during the `init` method, but you can during the `boot` method.\n *\n * @name Phaser.Plugins.BasePlugin#systems\n * @type {?Phaser.Scenes.Systems}\n * @protected\n * @since 3.8.0\n */\n this.systems;\n },\n\n /**\n * Called by the PluginManager when this plugin is first instantiated.\n * It will never be called again on this instance.\n * In here you can set-up whatever you need for this plugin to run.\n * If a plugin is set to automatically start then `BasePlugin.start` will be called immediately after this.\n *\n * @method Phaser.Plugins.BasePlugin#init\n * @since 3.8.0\n *\n * @param {?any} [data] - A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually).\n */\n init: function ()\n {\n },\n\n /**\n * Called by the PluginManager when this plugin is started.\n * If a plugin is stopped, and then started again, this will get called again.\n * Typically called immediately after `BasePlugin.init`.\n *\n * @method Phaser.Plugins.BasePlugin#start\n * @since 3.8.0\n */\n start: function ()\n {\n // Here are the game-level events you can listen to.\n // At the very least you should offer a destroy handler for when the game closes down.\n\n // var eventEmitter = this.game.events;\n\n // eventEmitter.once('destroy', this.gameDestroy, this);\n // eventEmitter.on('pause', this.gamePause, this);\n // eventEmitter.on('resume', this.gameResume, this);\n // eventEmitter.on('resize', this.gameResize, this);\n // eventEmitter.on('prestep', this.gamePreStep, this);\n // eventEmitter.on('step', this.gameStep, this);\n // eventEmitter.on('poststep', this.gamePostStep, this);\n // eventEmitter.on('prerender', this.gamePreRender, this);\n // eventEmitter.on('postrender', this.gamePostRender, this);\n },\n\n /**\n * Called by the PluginManager when this plugin is stopped.\n * The game code has requested that your plugin stop doing whatever it does.\n * It is now considered as 'inactive' by the PluginManager.\n * Handle that process here (i.e. stop listening for events, etc)\n * If the plugin is started again then `BasePlugin.start` will be called again.\n *\n * @method Phaser.Plugins.BasePlugin#stop\n * @since 3.8.0\n */\n stop: function ()\n {\n },\n\n /**\n * If this is a Scene Plugin (i.e. installed into a Scene) then this method is called when the Scene boots.\n * By this point the plugin properties `scene` and `systems` will have already been set.\n * In here you can listen for Scene events and set-up whatever you need for this plugin to run.\n *\n * @method Phaser.Plugins.BasePlugin#boot\n * @since 3.8.0\n */\n boot: function ()\n {\n // Here are the Scene events you can listen to.\n // At the very least you should offer a destroy handler for when the Scene closes down.\n\n // var eventEmitter = this.systems.events;\n\n // eventEmitter.once('destroy', this.sceneDestroy, this);\n // eventEmitter.on('start', this.sceneStart, this);\n // eventEmitter.on('preupdate', this.scenePreUpdate, this);\n // eventEmitter.on('update', this.sceneUpdate, this);\n // eventEmitter.on('postupdate', this.scenePostUpdate, this);\n // eventEmitter.on('pause', this.scenePause, this);\n // eventEmitter.on('resume', this.sceneResume, this);\n // eventEmitter.on('sleep', this.sceneSleep, this);\n // eventEmitter.on('wake', this.sceneWake, this);\n // eventEmitter.on('shutdown', this.sceneShutdown, this);\n // eventEmitter.on('destroy', this.sceneDestroy, this);\n },\n\n /**\n * Game instance has been destroyed.\n * You must release everything in here, all references, all objects, free it all up.\n *\n * @method Phaser.Plugins.BasePlugin#destroy\n * @since 3.8.0\n */\n destroy: function ()\n {\n this.pluginManager = null;\n this.game = null;\n this.scene = null;\n this.systems = null;\n }\n\n});\n\nmodule.exports = BasePlugin;\n","/**\n* @author Richard Davey \n* @copyright 2018 Photon Storm Ltd.\n* @license {@link https://github.com/photonstorm/phaser3-plugin-template/blob/master/LICENSE|MIT License}\n*/\n\nvar BasePlugin = require('./BasePlugin');\nvar Class = require('../utils/Class');\n\n/**\n * @classdesc\n * A Scene Level Plugin is installed into every Scene and belongs to that Scene.\n * It can listen for Scene events and respond to them.\n * It can map itself to a Scene property, or into the Scene Systems, or both.\n *\n * @class ScenePlugin\n * @memberof Phaser.Plugins\n * @extends Phaser.Plugins.BasePlugin\n * @constructor\n * @since 3.8.0\n *\n * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin.\n * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Plugin Manager.\n */\nvar ScenePlugin = new Class({\n\n Extends: BasePlugin,\n\n initialize:\n\n function ScenePlugin (scene, pluginManager)\n {\n BasePlugin.call(this, pluginManager);\n\n this.scene = scene;\n this.systems = scene.sys;\n\n scene.sys.events.once('boot', this.boot, this);\n },\n\n /**\n * This method is called when the Scene boots. It is only ever called once.\n * \n * By this point the plugin properties `scene` and `systems` will have already been set.\n * \n * In here you can listen for Scene events and set-up whatever you need for this plugin to run.\n * Here are the Scene events you can listen to:\n * \n * start\n * ready\n * preupdate\n * update\n * postupdate\n * resize\n * pause\n * resume\n * sleep\n * wake\n * transitioninit\n * transitionstart\n * transitioncomplete\n * transitionout\n * shutdown\n * destroy\n * \n * At the very least you should offer a destroy handler for when the Scene closes down, i.e:\n *\n * ```javascript\n * var eventEmitter = this.systems.events;\n * eventEmitter.once('destroy', this.sceneDestroy, this);\n * ```\n *\n * @method Phaser.Plugins.ScenePlugin#boot\n * @since 3.8.0\n */\n boot: function ()\n {\n }\n\n});\n\nmodule.exports = ScenePlugin;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * Phaser Blend Modes.\n * \n * @name Phaser.BlendModes\n * @enum {integer}\n * @memberof Phaser\n * @readonly\n * @since 3.0.0\n */\n\nmodule.exports = {\n\n /**\n * Skips the Blend Mode check in the renderer.\n * \n * @name Phaser.BlendModes.SKIP_CHECK\n */\n SKIP_CHECK: -1,\n\n /**\n * Normal blend mode.\n * \n * @name Phaser.BlendModes.NORMAL\n */\n NORMAL: 0,\n\n /**\n * Add blend mode.\n * \n * @name Phaser.BlendModes.ADD\n */\n ADD: 1,\n\n /**\n * Multiply blend mode.\n * \n * @name Phaser.BlendModes.MULTIPLY\n */\n MULTIPLY: 2,\n\n /**\n * Screen blend mode.\n * \n * @name Phaser.BlendModes.SCREEN\n */\n SCREEN: 3,\n\n /**\n * Overlay blend mode.\n * \n * @name Phaser.BlendModes.OVERLAY\n */\n OVERLAY: 4,\n\n /**\n * Darken blend mode.\n * \n * @name Phaser.BlendModes.DARKEN\n */\n DARKEN: 5,\n\n /**\n * Lighten blend mode.\n * \n * @name Phaser.BlendModes.LIGHTEN\n */\n LIGHTEN: 6,\n\n /**\n * Color Dodge blend mode.\n * \n * @name Phaser.BlendModes.COLOR_DODGE\n */\n COLOR_DODGE: 7,\n\n /**\n * Color Burn blend mode.\n * \n * @name Phaser.BlendModes.COLOR_BURN\n */\n COLOR_BURN: 8,\n\n /**\n * Hard Light blend mode.\n * \n * @name Phaser.BlendModes.HARD_LIGHT\n */\n HARD_LIGHT: 9,\n\n /**\n * Soft Light blend mode.\n * \n * @name Phaser.BlendModes.SOFT_LIGHT\n */\n SOFT_LIGHT: 10,\n\n /**\n * Difference blend mode.\n * \n * @name Phaser.BlendModes.DIFFERENCE\n */\n DIFFERENCE: 11,\n\n /**\n * Exclusion blend mode.\n * \n * @name Phaser.BlendModes.EXCLUSION\n */\n EXCLUSION: 12,\n\n /**\n * Hue blend mode.\n * \n * @name Phaser.BlendModes.HUE\n */\n HUE: 13,\n\n /**\n * Saturation blend mode.\n * \n * @name Phaser.BlendModes.SATURATION\n */\n SATURATION: 14,\n\n /**\n * Color blend mode.\n * \n * @name Phaser.BlendModes.COLOR\n */\n COLOR: 15,\n\n /**\n * Luminosity blend mode.\n * \n * @name Phaser.BlendModes.LUMINOSITY\n */\n LUMINOSITY: 16\n\n};\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n// Taken from klasse by mattdesl https://github.com/mattdesl/klasse\n\nfunction hasGetterOrSetter (def)\n{\n return (!!def.get && typeof def.get === 'function') || (!!def.set && typeof def.set === 'function');\n}\n\nfunction getProperty (definition, k, isClassDescriptor)\n{\n // This may be a lightweight object, OR it might be a property that was defined previously.\n\n // For simple class descriptors we can just assume its NOT previously defined.\n var def = (isClassDescriptor) ? definition[k] : Object.getOwnPropertyDescriptor(definition, k);\n\n if (!isClassDescriptor && def.value && typeof def.value === 'object')\n {\n def = def.value;\n }\n\n // This might be a regular property, or it may be a getter/setter the user defined in a class.\n if (def && hasGetterOrSetter(def))\n {\n if (typeof def.enumerable === 'undefined')\n {\n def.enumerable = true;\n }\n\n if (typeof def.configurable === 'undefined')\n {\n def.configurable = true;\n }\n\n return def;\n }\n else\n {\n return false;\n }\n}\n\nfunction hasNonConfigurable (obj, k)\n{\n var prop = Object.getOwnPropertyDescriptor(obj, k);\n\n if (!prop)\n {\n return false;\n }\n\n if (prop.value && typeof prop.value === 'object')\n {\n prop = prop.value;\n }\n\n if (prop.configurable === false)\n {\n return true;\n }\n\n return false;\n}\n\nfunction extend (ctor, definition, isClassDescriptor, extend)\n{\n for (var k in definition)\n {\n if (!definition.hasOwnProperty(k))\n {\n continue;\n }\n\n var def = getProperty(definition, k, isClassDescriptor);\n\n if (def !== false)\n {\n // If Extends is used, we will check its prototype to see if the final variable exists.\n\n var parent = extend || ctor;\n\n if (hasNonConfigurable(parent.prototype, k))\n {\n // Just skip the final property\n if (Class.ignoreFinals)\n {\n continue;\n }\n\n // We cannot re-define a property that is configurable=false.\n // So we will consider them final and throw an error. This is by\n // default so it is clear to the developer what is happening.\n // You can set ignoreFinals to true if you need to extend a class\n // which has configurable=false; it will simply not re-define final properties.\n throw new Error('cannot override final property \\'' + k + '\\', set Class.ignoreFinals = true to skip');\n }\n\n Object.defineProperty(ctor.prototype, k, def);\n }\n else\n {\n ctor.prototype[k] = definition[k];\n }\n }\n}\n\nfunction mixin (myClass, mixins)\n{\n if (!mixins)\n {\n return;\n }\n\n if (!Array.isArray(mixins))\n {\n mixins = [ mixins ];\n }\n\n for (var i = 0; i < mixins.length; i++)\n {\n extend(myClass, mixins[i].prototype || mixins[i]);\n }\n}\n\n/**\n * Creates a new class with the given descriptor.\n * The constructor, defined by the name `initialize`,\n * is an optional function. If unspecified, an anonymous\n * function will be used which calls the parent class (if\n * one exists).\n *\n * You can also use `Extends` and `Mixins` to provide subclassing\n * and inheritance.\n *\n * @class Class\n * @constructor\n * @param {Object} definition a dictionary of functions for the class\n * @example\n *\n * var MyClass = new Phaser.Class({\n *\n * initialize: function() {\n * this.foo = 2.0;\n * },\n *\n * bar: function() {\n * return this.foo + 5;\n * }\n * });\n */\nfunction Class (definition)\n{\n if (!definition)\n {\n definition = {};\n }\n\n // The variable name here dictates what we see in Chrome debugger\n var initialize;\n var Extends;\n\n if (definition.initialize)\n {\n if (typeof definition.initialize !== 'function')\n {\n throw new Error('initialize must be a function');\n }\n\n initialize = definition.initialize;\n\n // Usually we should avoid 'delete' in V8 at all costs.\n // However, its unlikely to make any performance difference\n // here since we only call this on class creation (i.e. not object creation).\n delete definition.initialize;\n }\n else if (definition.Extends)\n {\n var base = definition.Extends;\n\n initialize = function ()\n {\n base.apply(this, arguments);\n };\n }\n else\n {\n initialize = function () {};\n }\n\n if (definition.Extends)\n {\n initialize.prototype = Object.create(definition.Extends.prototype);\n initialize.prototype.constructor = initialize;\n\n // For getOwnPropertyDescriptor to work, we need to act directly on the Extends (or Mixin)\n\n Extends = definition.Extends;\n\n delete definition.Extends;\n }\n else\n {\n initialize.prototype.constructor = initialize;\n }\n\n // Grab the mixins, if they are specified...\n var mixins = null;\n\n if (definition.Mixins)\n {\n mixins = definition.Mixins;\n delete definition.Mixins;\n }\n\n // First, mixin if we can.\n mixin(initialize, mixins);\n\n // Now we grab the actual definition which defines the overrides.\n extend(initialize, definition, true, Extends);\n\n return initialize;\n}\n\nClass.extend = extend;\nClass.mixin = mixin;\nClass.ignoreFinals = false;\n\nmodule.exports = Class;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * A NOOP (No Operation) callback function.\n *\n * Used internally by Phaser when it's more expensive to determine if a callback exists\n * than it is to just invoke an empty function.\n *\n * @function Phaser.Utils.NOOP\n * @since 3.0.0\n */\nvar NOOP = function ()\n{\n // NOOP\n};\n\nmodule.exports = NOOP;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar IsPlainObject = require('./IsPlainObject');\n\n// @param {boolean} deep - Perform a deep copy?\n// @param {object} target - The target object to copy to.\n// @return {object} The extended object.\n\n/**\n * This is a slightly modified version of http://api.jquery.com/jQuery.extend/\n *\n * @function Phaser.Utils.Objects.Extend\n * @since 3.0.0\n *\n * @return {object} The extended object.\n */\nvar Extend = function ()\n{\n var options, name, src, copy, copyIsArray, clone,\n target = arguments[0] || {},\n i = 1,\n length = arguments.length,\n deep = false;\n\n // Handle a deep copy situation\n if (typeof target === 'boolean')\n {\n deep = target;\n target = arguments[1] || {};\n\n // skip the boolean and the target\n i = 2;\n }\n\n // extend Phaser if only one argument is passed\n if (length === i)\n {\n target = this;\n --i;\n }\n\n for (; i < length; i++)\n {\n // Only deal with non-null/undefined values\n if ((options = arguments[i]) != null)\n {\n // Extend the base object\n for (name in options)\n {\n src = target[name];\n copy = options[name];\n\n // Prevent never-ending loop\n if (target === copy)\n {\n continue;\n }\n\n // Recurse if we're merging plain objects or arrays\n if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy))))\n {\n if (copyIsArray)\n {\n copyIsArray = false;\n clone = src && Array.isArray(src) ? src : [];\n }\n else\n {\n clone = src && IsPlainObject(src) ? src : {};\n }\n\n // Never move original objects, clone them\n target[name] = Extend(deep, clone, copy);\n\n // Don't bring in undefined values\n }\n else if (copy !== undefined)\n {\n target[name] = copy;\n }\n }\n }\n }\n\n // Return the modified object\n return target;\n};\n\nmodule.exports = Extend;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * Finds the key within the top level of the {@link source} object, or returns {@link defaultValue}\n *\n * @function Phaser.Utils.Objects.GetFastValue\n * @since 3.0.0\n *\n * @param {object} source - The object to search\n * @param {string} key - The key for the property on source. Must exist at the top level of the source object (no periods)\n * @param {*} [defaultValue] - The default value to use if the key does not exist.\n *\n * @return {*} The value if found; otherwise, defaultValue (null if none provided)\n */\nvar GetFastValue = function (source, key, defaultValue)\n{\n var t = typeof(source);\n\n if (!source || t === 'number' || t === 'string')\n {\n return defaultValue;\n }\n else if (source.hasOwnProperty(key) && source[key] !== undefined)\n {\n return source[key];\n }\n else\n {\n return defaultValue;\n }\n};\n\nmodule.exports = GetFastValue;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n// Source object\n// The key as a string, or an array of keys, i.e. 'banner', or 'banner.hideBanner'\n// The default value to use if the key doesn't exist\n\n/**\n * Retrieves a value from an object.\n *\n * @function Phaser.Utils.Objects.GetValue\n * @since 3.0.0\n *\n * @param {object} source - The object to retrieve the value from.\n * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object.\n * @param {*} defaultValue - The value to return if the `key` isn't found in the `source` object.\n *\n * @return {*} The value of the requested key.\n */\nvar GetValue = function (source, key, defaultValue)\n{\n if (!source || typeof source === 'number')\n {\n return defaultValue;\n }\n else if (source.hasOwnProperty(key))\n {\n return source[key];\n }\n else if (key.indexOf('.'))\n {\n var keys = key.split('.');\n var parent = source;\n var value = defaultValue;\n\n // Use for loop here so we can break early\n for (var i = 0; i < keys.length; i++)\n {\n if (parent.hasOwnProperty(keys[i]))\n {\n // Yes it has a key property, let's carry on down\n value = parent[keys[i]];\n\n parent = parent[keys[i]];\n }\n else\n {\n // Can't go any further, so reset to default\n value = defaultValue;\n break;\n }\n }\n\n return value;\n }\n else\n {\n return defaultValue;\n }\n};\n\nmodule.exports = GetValue;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\n/**\n * This is a slightly modified version of jQuery.isPlainObject.\n * A plain object is an object whose internal class property is [object Object].\n *\n * @function Phaser.Utils.Objects.IsPlainObject\n * @since 3.0.0\n *\n * @param {object} obj - The object to inspect.\n *\n * @return {boolean} `true` if the object is plain, otherwise `false`.\n */\nvar IsPlainObject = function (obj)\n{\n // Not plain objects:\n // - Any object or value whose internal [[Class]] property is not \"[object Object]\"\n // - DOM nodes\n // - window\n if (typeof(obj) !== 'object' || obj.nodeType || obj === obj.window)\n {\n return false;\n }\n\n // Support: Firefox <20\n // The try/catch suppresses exceptions thrown when attempting to access\n // the \"constructor\" property of certain host objects, ie. |window.location|\n // https://bugzilla.mozilla.org/show_bug.cgi?id=814622\n try\n {\n if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf'))\n {\n return false;\n }\n }\n catch (e)\n {\n return false;\n }\n\n // If the function hasn't returned already, we're confident that\n // |obj| is a plain object, created by {} or constructed with new Object\n return true;\n};\n\nmodule.exports = IsPlainObject;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../../../src/utils/Class');\nvar ScenePlugin = require('../../../src/plugins/ScenePlugin');\nvar SpineFile = require('./SpineFile');\nvar SpineGameObject = require('./gameobject/SpineGameObject');\n\nvar runtime;\n\n/**\n * @classdesc\n * TODO\n *\n * @class SpinePlugin\n * @extends Phaser.Plugins.ScenePlugin\n * @constructor\n * @since 3.16.0\n *\n * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin.\n * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager.\n */\nvar SpinePlugin = new Class({\n\n Extends: ScenePlugin,\n\n initialize:\n\n function SpinePlugin (scene, pluginManager, SpineRuntime)\n {\n console.log('BaseSpinePlugin created');\n\n ScenePlugin.call(this, scene, pluginManager);\n\n var game = pluginManager.game;\n\n // Create a custom cache to store the spine data (.atlas files)\n this.cache = game.cache.addCustom('spine');\n\n this.json = game.cache.json;\n\n this.textures = game.textures;\n\n this.skeletonRenderer;\n\n this.drawDebug = false;\n\n // Register our file type\n pluginManager.registerFileType('spine', this.spineFileCallback, scene);\n\n // Register our game object\n pluginManager.registerGameObject('spine', this.createSpineFactory(this));\n\n runtime = SpineRuntime;\n },\n\n spineFileCallback: function (key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings)\n {\n var multifile;\n \n if (Array.isArray(key))\n {\n for (var i = 0; i < key.length; i++)\n {\n multifile = new SpineFile(this, key[i]);\n \n this.addFile(multifile.files);\n }\n }\n else\n {\n multifile = new SpineFile(this, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings);\n\n this.addFile(multifile.files);\n }\n \n return this;\n },\n\n /**\n * Creates a new Spine Game Object and adds it to the Scene.\n *\n * @method Phaser.GameObjects.GameObjectFactory#spineFactory\n * @since 3.16.0\n * \n * @param {number} x - The horizontal position of this Game Object.\n * @param {number} y - The vertical position of this Game Object.\n * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.\n * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.\n *\n * @return {Phaser.GameObjects.Spine} The Game Object that was created.\n */\n createSpineFactory: function (plugin)\n {\n var callback = function (x, y, key, animationName, loop)\n {\n var spineGO = new SpineGameObject(this.scene, plugin, x, y, key, animationName, loop);\n\n this.displayList.add(spineGO);\n this.updateList.add(spineGO);\n \n return spineGO;\n };\n\n return callback;\n },\n\n getRuntime: function ()\n {\n return runtime;\n },\n\n createSkeleton: function (key, skeletonJSON)\n {\n var atlas = this.getAtlas(key);\n\n var atlasLoader = new runtime.AtlasAttachmentLoader(atlas);\n \n var skeletonJson = new runtime.SkeletonJson(atlasLoader);\n\n var data = (skeletonJSON) ? skeletonJSON : this.json.get(key);\n\n var skeletonData = skeletonJson.readSkeletonData(data);\n\n var skeleton = new runtime.Skeleton(skeletonData);\n \n return { skeletonData: skeletonData, skeleton: skeleton };\n },\n\n getBounds: function (skeleton)\n {\n var offset = new runtime.Vector2();\n var size = new runtime.Vector2();\n\n skeleton.getBounds(offset, size, []);\n\n return { offset: offset, size: size };\n },\n\n createAnimationState: function (skeleton)\n {\n var stateData = new runtime.AnimationStateData(skeleton.data);\n\n var state = new runtime.AnimationState(stateData);\n\n return { stateData: stateData, state: state };\n },\n\n /**\n * The Scene that owns this plugin is shutting down.\n * We need to kill and reset all internal properties as well as stop listening to Scene events.\n *\n * @method Camera3DPlugin#shutdown\n * @private\n * @since 3.0.0\n */\n shutdown: function ()\n {\n var eventEmitter = this.systems.events;\n\n eventEmitter.off('update', this.update, this);\n eventEmitter.off('shutdown', this.shutdown, this);\n\n this.removeAll();\n },\n\n /**\n * The Scene that owns this plugin is being destroyed.\n * We need to shutdown and then kill off all external references.\n *\n * @method Camera3DPlugin#destroy\n * @private\n * @since 3.0.0\n */\n destroy: function ()\n {\n this.shutdown();\n\n this.pluginManager = null;\n this.game = null;\n this.scene = null;\n this.systems = null;\n }\n\n});\n\nmodule.exports = SpinePlugin;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../../../src/utils/Class');\nvar GetFastValue = require('../../../src/utils/object/GetFastValue');\nvar ImageFile = require('../../../src/loader/filetypes/ImageFile.js');\nvar IsPlainObject = require('../../../src/utils/object/IsPlainObject');\nvar JSONFile = require('../../../src/loader/filetypes/JSONFile.js');\nvar MultiFile = require('../../../src/loader/MultiFile.js');\nvar TextFile = require('../../../src/loader/filetypes/TextFile.js');\n\n/**\n * @typedef {object} Phaser.Loader.FileTypes.SpineFileConfig\n *\n * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager.\n * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from.\n * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided.\n * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file.\n * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image.\n * @property {string} [atlasURL] - The absolute or relative URL to load the atlas data file from.\n * @property {string} [atlasExtension='txt'] - The default file extension to use for the atlas data if no url is provided.\n * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas data file.\n */\n\n/**\n * @classdesc\n * A Spine File suitable for loading by the Loader.\n *\n * These are created when you use the Phaser.Loader.LoaderPlugin#spine method and are not typically created directly.\n * \n * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spine.\n *\n * @class SpineFile\n * @extends Phaser.Loader.MultiFile\n * @memberof Phaser.Loader.FileTypes\n * @constructor\n *\n * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file.\n * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig)} key - The key to use for this file, or a file configuration object.\n * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was \"alien\" then the URL will be \"alien.png\".\n * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was \"alien\" then the URL will be \"alien.txt\".\n * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings.\n * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings.\n */\nvar SpineFile = new Class({\n\n Extends: MultiFile,\n\n initialize:\n\n function SpineFile (loader, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings)\n {\n var json;\n var atlas;\n\n if (IsPlainObject(key))\n {\n var config = key;\n\n key = GetFastValue(config, 'key');\n\n json = new JSONFile(loader, {\n key: key,\n url: GetFastValue(config, 'jsonURL'),\n extension: GetFastValue(config, 'jsonExtension', 'json'),\n xhrSettings: GetFastValue(config, 'jsonXhrSettings')\n });\n\n atlas = new TextFile(loader, {\n key: key,\n url: GetFastValue(config, 'atlasURL'),\n extension: GetFastValue(config, 'atlasExtension', 'atlas'),\n xhrSettings: GetFastValue(config, 'atlasXhrSettings')\n });\n }\n else\n {\n json = new JSONFile(loader, key, jsonURL, jsonXhrSettings);\n atlas = new TextFile(loader, key, atlasURL, atlasXhrSettings);\n }\n \n atlas.cache = loader.cacheManager.custom.spine;\n\n MultiFile.call(this, loader, 'spine', key, [ json, atlas ]);\n },\n\n /**\n * Called by each File when it finishes loading.\n *\n * @method Phaser.Loader.MultiFile#onFileComplete\n * @since 3.7.0\n *\n * @param {Phaser.Loader.File} file - The File that has completed processing.\n */\n onFileComplete: function (file)\n {\n var index = this.files.indexOf(file);\n\n if (index !== -1)\n {\n this.pending--;\n\n if (file.type === 'text')\n {\n // Inspect the data for the files to now load\n var content = file.data.split('\\n');\n\n // Extract the textures\n var textures = [];\n\n for (var t = 0; t < content.length; t++)\n {\n var line = content[t];\n\n if (line.trim() === '' && t < content.length - 1)\n {\n line = content[t + 1];\n\n textures.push(line);\n }\n }\n\n var config = this.config;\n var loader = this.loader;\n\n var currentBaseURL = loader.baseURL;\n var currentPath = loader.path;\n var currentPrefix = loader.prefix;\n\n var baseURL = GetFastValue(config, 'baseURL', currentBaseURL);\n var path = GetFastValue(config, 'path', currentPath);\n var prefix = GetFastValue(config, 'prefix', currentPrefix);\n var textureXhrSettings = GetFastValue(config, 'textureXhrSettings');\n\n loader.setBaseURL(baseURL);\n loader.setPath(path);\n loader.setPrefix(prefix);\n\n for (var i = 0; i < textures.length; i++)\n {\n var textureURL = textures[i];\n\n var key = '_SP_' + textureURL;\n\n var image = new ImageFile(loader, key, textureURL, textureXhrSettings);\n\n this.addToMultiFile(image);\n\n loader.addFile(image);\n }\n\n // Reset the loader settings\n loader.setBaseURL(currentBaseURL);\n loader.setPath(currentPath);\n loader.setPrefix(currentPrefix);\n }\n }\n },\n\n /**\n * Adds this file to its target cache upon successful loading and processing.\n *\n * @method Phaser.Loader.FileTypes.SpineFile#addToCache\n * @since 3.16.0\n */\n addToCache: function ()\n {\n if (this.isReadyToProcess())\n {\n var fileJSON = this.files[0];\n\n fileJSON.addToCache();\n\n var fileText = this.files[1];\n\n fileText.addToCache();\n\n for (var i = 2; i < this.files.length; i++)\n {\n var file = this.files[i];\n\n var key = file.key.substr(4).trim();\n\n this.loader.textureManager.addImage(key, file.data);\n\n file.pendingDestroy();\n }\n\n this.complete = true;\n }\n }\n\n});\n\n/**\n * Adds a Unity YAML based Texture Atlas, or array of atlases, to the current load queue.\n *\n * You can call this method from within your Scene's `preload`, along with any other files you wish to load:\n * \n * ```javascript\n * function preload ()\n * {\n * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt');\n * }\n * ```\n *\n * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts,\n * or if it's already running, when the next free load slot becomes available. This happens automatically if you\n * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued\n * it means you cannot use the file immediately after calling this method, but must wait for the file to complete.\n * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the\n * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been\n * loaded.\n * \n * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring\n * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details.\n *\n * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity.\n * \n * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle.\n *\n * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load.\n * The key should be unique both in terms of files being loaded and files already present in the Texture Manager.\n * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file\n * then remove it from the Texture Manager first, before loading a new one.\n *\n * Instead of passing arguments you can pass a configuration object, such as:\n * \n * ```javascript\n * this.load.unityAtlas({\n * key: 'mainmenu',\n * textureURL: 'images/MainMenu.png',\n * atlasURL: 'images/MainMenu.txt'\n * });\n * ```\n *\n * See the documentation for `Phaser.Loader.FileTypes.SpineFileConfig` for more details.\n *\n * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key:\n * \n * ```javascript\n * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json');\n * // and later in your game ...\n * this.add.image(x, y, 'mainmenu', 'background');\n * ```\n *\n * To get a list of all available frames within an atlas please consult your Texture Atlas software.\n *\n * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files\n * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and\n * this is what you would use to retrieve the image from the Texture Manager.\n *\n * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it.\n *\n * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is \"alien\"\n * and no URL is given then the Loader will set the URL to be \"alien.png\". It will always add `.png` as the extension, although\n * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL.\n *\n * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image,\n * then you can specify it by providing an array as the `url` where the second element is the normal map:\n * \n * ```javascript\n * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt');\n * ```\n *\n * Or, if you are using a config object use the `normalMap` property:\n * \n * ```javascript\n * this.load.unityAtlas({\n * key: 'mainmenu',\n * textureURL: 'images/MainMenu.png',\n * normalMap: 'images/MainMenu-n.png',\n * atlasURL: 'images/MainMenu.txt'\n * });\n * ```\n *\n * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings.\n * Normal maps are a WebGL only feature.\n *\n * Note: The ability to load this type of file will only be available if the Unity Atlas File type has been built into Phaser.\n * It is available in the default build but can be excluded from custom builds.\n *\n * @method Phaser.Loader.LoaderPlugin#spine\n * @fires Phaser.Loader.LoaderPlugin#addFileEvent\n * @since 3.16.0\n *\n * @param {(string|Phaser.Loader.FileTypes.SpineFileConfig|Phaser.Loader.FileTypes.SpineFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them.\n * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was \"alien\" then the URL will be \"alien.png\".\n * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was \"alien\" then the URL will be \"alien.txt\".\n * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings.\n * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings.\n *\n * @return {Phaser.Loader.LoaderPlugin} The Loader instance.\nFileTypesManager.register('spine', function (key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings)\n{\n var multifile;\n\n // Supports an Object file definition in the key argument\n // Or an array of objects in the key argument\n // Or a single entry where all arguments have been defined\n\n if (Array.isArray(key))\n {\n for (var i = 0; i < key.length; i++)\n {\n multifile = new SpineFile(this, key[i]);\n\n this.addFile(multifile.files);\n }\n }\n else\n {\n multifile = new SpineFile(this, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings);\n\n this.addFile(multifile.files);\n }\n\n return this;\n});\n */\n\nmodule.exports = SpineFile;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../../../src/utils/Class');\nvar BaseSpinePlugin = require('./BaseSpinePlugin');\nvar SpineWebGL = require('SpineWebGL');\nvar Matrix4 = require('../../../src/math/Matrix4');\n\n/**\n * @classdesc\n * Just the WebGL Runtime.\n *\n * @class SpinePlugin\n * @extends Phaser.Plugins.ScenePlugin\n * @constructor\n * @since 3.16.0\n *\n * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin.\n * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager.\n */\nvar SpineWebGLPlugin = new Class({\n\n Extends: BaseSpinePlugin,\n\n initialize:\n\n function SpineWebGLPlugin (scene, pluginManager)\n {\n console.log('SpineWebGLPlugin created');\n\n BaseSpinePlugin.call(this, scene, pluginManager, SpineWebGL);\n\n this.gl;\n this.mvp;\n this.shader;\n this.batcher;\n this.debugRenderer;\n this.debugShader;\n },\n\n boot: function ()\n {\n var gl = this.game.renderer.gl;\n\n this.gl = gl;\n\n this.mvp = new Matrix4();\n\n // Create a simple shader, mesh, model-view-projection matrix and SkeletonRenderer.\n this.shader = SpineWebGL.webgl.Shader.newTwoColoredTextured(gl);\n this.batcher = new SpineWebGL.webgl.PolygonBatcher(gl);\n\n this.skeletonRenderer = new SpineWebGL.webgl.SkeletonRenderer(gl);\n this.skeletonRenderer.premultipliedAlpha = true;\n\n this.shapes = new SpineWebGL.webgl.ShapeRenderer(gl);\n\n this.debugRenderer = new SpineWebGL.webgl.SkeletonDebugRenderer(gl);\n\n this.debugShader = SpineWebGL.webgl.Shader.newColored(gl);\n },\n\n getAtlas: function (key)\n {\n var atlasData = this.cache.get(key);\n\n if (!atlasData)\n {\n console.warn('No atlas data for: ' + key);\n return;\n }\n\n var textures = this.textures;\n\n var gl = this.game.renderer.gl;\n\n var atlas = new SpineWebGL.TextureAtlas(atlasData, function (path)\n {\n return new SpineWebGL.webgl.GLTexture(gl, textures.get(path).getSourceImage());\n });\n\n return atlas;\n }\n\n});\n\nmodule.exports = SpineWebGLPlugin;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar Class = require('../../../../src/utils/Class');\nvar ComponentsAlpha = require('../../../../src/gameobjects/components/Alpha');\nvar ComponentsBlendMode = require('../../../../src/gameobjects/components/BlendMode');\nvar ComponentsDepth = require('../../../../src/gameobjects/components/Depth');\nvar ComponentsFlip = require('../../../../src/gameobjects/components/Flip');\nvar ComponentsScrollFactor = require('../../../../src/gameobjects/components/ScrollFactor');\nvar ComponentsTransform = require('../../../../src/gameobjects/components/Transform');\nvar ComponentsVisible = require('../../../../src/gameobjects/components/Visible');\nvar GameObject = require('../../../../src/gameobjects/GameObject');\nvar SpineGameObjectRender = require('./SpineGameObjectRender');\n\n/**\n * @classdesc\n * TODO\n *\n * @class SpineGameObject\n * @constructor\n * @since 3.16.0\n *\n * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin.\n * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager.\n */\nvar SpineGameObject = new Class({\n\n Extends: GameObject,\n\n Mixins: [\n ComponentsAlpha,\n ComponentsBlendMode,\n ComponentsDepth,\n ComponentsFlip,\n ComponentsScrollFactor,\n ComponentsTransform,\n ComponentsVisible,\n SpineGameObjectRender\n ],\n\n initialize:\n\n function SpineGameObject (scene, plugin, x, y, key, animationName, loop)\n {\n GameObject.call(this, scene, 'Spine');\n\n this.plugin = plugin;\n\n this.runtime = plugin.getRuntime();\n\n this.skeleton = null;\n this.skeletonData = null;\n\n this.state = null;\n this.stateData = null;\n\n this.drawDebug = false;\n\n this.timeScale = 1;\n\n this.setPosition(x, y);\n\n if (key)\n {\n this.setSkeleton(key, animationName, loop);\n }\n },\n\n setSkeletonFromJSON: function (atlasDataKey, skeletonJSON, animationName, loop)\n {\n return this.setSkeleton(atlasDataKey, skeletonJSON, animationName, loop);\n },\n\n setSkeleton: function (atlasDataKey, animationName, loop, skeletonJSON)\n {\n var data = this.plugin.createSkeleton(atlasDataKey, skeletonJSON);\n\n this.skeletonData = data.skeletonData;\n\n var skeleton = data.skeleton;\n\n skeleton.flipY = (this.scene.sys.game.config.renderType === 1);\n\n skeleton.setToSetupPose();\n\n skeleton.updateWorldTransform();\n\n skeleton.setSkinByName('default');\n\n this.skeleton = skeleton;\n\n // AnimationState\n data = this.plugin.createAnimationState(skeleton);\n\n if (this.state)\n {\n this.state.clearListeners();\n this.state.clearListenerNotifications();\n }\n\n this.state = data.state;\n\n this.stateData = data.stateData;\n\n var _this = this;\n\n this.state.addListener({\n event: function (trackIndex, event)\n {\n // Event on a Track\n _this.emit('spine.event', _this, trackIndex, event);\n },\n complete: function (trackIndex, loopCount)\n {\n // Animation on Track x completed, loop count\n _this.emit('spine.complete', _this, trackIndex, loopCount);\n },\n start: function (trackIndex)\n {\n // Animation on Track x started\n _this.emit('spine.start', _this, trackIndex);\n },\n end: function (trackIndex)\n {\n // Animation on Track x ended\n _this.emit('spine.end', _this, trackIndex);\n }\n });\n\n if (animationName)\n {\n this.setAnimation(0, animationName, loop);\n }\n\n return this;\n },\n\n // http://esotericsoftware.com/spine-runtimes-guide\n\n getAnimationList: function ()\n {\n var output = [];\n\n var skeletonData = this.skeletonData;\n\n if (skeletonData)\n {\n for (var i = 0; i < skeletonData.animations.length; i++)\n {\n output.push(skeletonData.animations[i].name);\n }\n }\n\n return output;\n },\n\n play: function (animationName, loop)\n {\n if (loop === undefined)\n {\n loop = false;\n }\n\n return this.setAnimation(0, animationName, loop);\n },\n\n setAnimation: function (trackIndex, animationName, loop)\n {\n this.state.setAnimation(trackIndex, animationName, loop);\n\n return this;\n },\n\n addAnimation: function (trackIndex, animationName, loop, delay)\n {\n return this.state.addAnimation(trackIndex, animationName, loop, delay);\n },\n\n setEmptyAnimation: function (trackIndex, mixDuration)\n {\n this.state.setEmptyAnimation(trackIndex, mixDuration);\n\n return this;\n },\n\n clearTrack: function (trackIndex)\n {\n this.state.clearTrack(trackIndex);\n\n return this;\n },\n \n clearTracks: function ()\n {\n this.state.clearTracks();\n\n return this;\n },\n\n setSkinByName: function (skinName)\n {\n this.skeleton.setSkinByName(skinName);\n\n return this;\n },\n\n setSkin: function (newSkin)\n {\n var skeleton = this.skeleton;\n\n skeleton.setSkin(newSkin);\n\n skeleton.setSlotsToSetupPose();\n\n this.state.apply(skeleton);\n\n return this;\n },\n\n setMix: function (fromName, toName, duration)\n {\n this.stateData.setMix(fromName, toName, duration);\n\n return this;\n },\n\n findBone: function (boneName)\n {\n return this.skeleton.findBone(boneName);\n },\n\n findBoneIndex: function (boneName)\n {\n return this.skeleton.findBoneIndex(boneName);\n },\n\n findSlot: function (slotName)\n {\n return this.skeleton.findSlot(slotName);\n },\n\n findSlotIndex: function (slotName)\n {\n return this.skeleton.findSlotIndex(slotName);\n },\n\n getBounds: function ()\n {\n return this.plugin.getBounds(this.skeleton);\n },\n\n preUpdate: function (time, delta)\n {\n var skeleton = this.skeleton;\n\n skeleton.flipX = this.flipX;\n skeleton.flipY = this.flipY;\n\n this.state.update((delta / 1000) * this.timeScale);\n\n this.state.apply(skeleton);\n\n this.emit('spine.update', skeleton);\n\n skeleton.updateWorldTransform();\n },\n\n /**\n * Internal destroy handler, called as part of the destroy process.\n *\n * @method Phaser.GameObjects.RenderTexture#preDestroy\n * @protected\n * @since 3.16.0\n */\n preDestroy: function ()\n {\n if (this.state)\n {\n this.state.clearListeners();\n this.state.clearListenerNotifications();\n }\n\n this.plugin = null;\n this.runtime = null;\n\n this.skeleton = null;\n this.skeletonData = null;\n\n this.state = null;\n this.stateData = null;\n }\n\n});\n\nmodule.exports = SpineGameObject;\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar renderWebGL = require('../../../../src/utils/NOOP');\nvar renderCanvas = require('../../../../src/utils/NOOP');\n\nif (typeof WEBGL_RENDERER)\n{\n renderWebGL = require('./SpineGameObjectWebGLRenderer');\n}\n\nif (typeof CANVAS_RENDERER)\n{\n renderCanvas = require('./SpineGameObjectCanvasRenderer');\n}\n\nmodule.exports = {\n\n renderWebGL: renderWebGL,\n renderCanvas: renderCanvas\n\n};\n","/**\n * @author Richard Davey \n * @copyright 2018 Photon Storm Ltd.\n * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}\n */\n\nvar CounterClockwise = require('../../../../src/math/angle/CounterClockwise');\n\n/**\n * Renders this Game Object with the Canvas Renderer to the given Camera.\n * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.\n * This method should not be called directly. It is a utility function of the Render module.\n *\n * @method Phaser.GameObjects.SpineGameObject#renderCanvas\n * @since 3.16.0\n * @private\n *\n * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer.\n * @param {Phaser.GameObjects.SpineGameObject} src - The Game Object being rendered in this call.\n * @param {number} interpolationPercentage - Reserved for future use and custom pipelines.\n * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.\n * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested\n */\nvar SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)\n{\n var pipeline = renderer.currentPipeline;\n var plugin = src.plugin;\n var mvp = plugin.mvp;\n\n var shader = plugin.shader;\n var batcher = plugin.batcher;\n var runtime = src.runtime;\n var skeleton = src.skeleton;\n var skeletonRenderer = plugin.skeletonRenderer;\n\n if (!skeleton)\n {\n return;\n }\n\n renderer.clearPipeline();\n\n var camMatrix = renderer._tempMatrix1;\n var spriteMatrix = renderer._tempMatrix2;\n var calcMatrix = renderer._tempMatrix3;\n\n // - 90 degrees to account for the difference in Spine vs. Phaser rotation\n spriteMatrix.applyITRS(src.x, src.y, src.rotation - 1.5707963267948966, src.scaleX, src.scaleY);\n\n camMatrix.copyFrom(camera.matrix);\n\n if (parentMatrix)\n {\n // Multiply the camera by the parent matrix\n camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY);\n\n // Undo the camera scroll\n spriteMatrix.e = src.x;\n spriteMatrix.f = src.y;\n\n // Multiply by the Sprite matrix, store result in calcMatrix\n camMatrix.multiply(spriteMatrix, calcMatrix);\n }\n else\n {\n spriteMatrix.e -= camera.scrollX * src.scrollFactorX;\n spriteMatrix.f -= camera.scrollY * src.scrollFactorY;\n\n // Multiply by the Sprite matrix, store result in calcMatrix\n camMatrix.multiply(spriteMatrix, calcMatrix);\n }\n\n var width = renderer.width;\n var height = renderer.height;\n\n var data = calcMatrix.decomposeMatrix();\n\n mvp.ortho(0, width, 0, height, 0, 1);\n mvp.translateXYZ(data.translateX, height - data.translateY, 0);\n mvp.rotateZ(CounterClockwise(data.rotation));\n mvp.scaleXYZ(data.scaleX, data.scaleY, 1);\n\n // For a Stage 1 release we'll handle it like this:\n shader.bind();\n shader.setUniformi(runtime.webgl.Shader.SAMPLER, 0);\n shader.setUniform4x4f(runtime.webgl.Shader.MVP_MATRIX, mvp.val);\n\n // For Stage 2, we'll move to using a custom pipeline, so Spine objects are batched\n\n batcher.begin(shader);\n\n skeletonRenderer.premultipliedAlpha = true;\n\n skeletonRenderer.draw(batcher, skeleton);\n\n batcher.end();\n\n shader.unbind();\n\n if (plugin.drawDebug || src.drawDebug)\n {\n var debugShader = plugin.debugShader;\n var debugRenderer = plugin.debugRenderer;\n var shapes = plugin.shapes;\n\n debugShader.bind();\n debugShader.setUniform4x4f(runtime.webgl.Shader.MVP_MATRIX, mvp.val);\n\n shapes.begin(debugShader);\n\n debugRenderer.draw(shapes, skeleton);\n\n shapes.end();\n\n debugShader.unbind();\n }\n\n renderer.rebindPipeline(pipeline);\n};\n\nmodule.exports = SpineGameObjectWebGLRenderer;\n","/*** IMPORTS FROM imports-loader ***/\n(function() {\n\nvar __extends = (this && this.__extends) || (function () {\n\tvar extendStatics = Object.setPrototypeOf ||\n\t\t({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n\t\tfunction (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n\treturn function (d, b) {\n\t\textendStatics(d, b);\n\t\tfunction __() { this.constructor = d; }\n\t\td.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n\t};\n})();\nvar spine;\n(function (spine) {\n\tvar Animation = (function () {\n\t\tfunction Animation(name, timelines, duration) {\n\t\t\tif (name == null)\n\t\t\t\tthrow new Error(\"name cannot be null.\");\n\t\t\tif (timelines == null)\n\t\t\t\tthrow new Error(\"timelines cannot be null.\");\n\t\t\tthis.name = name;\n\t\t\tthis.timelines = timelines;\n\t\t\tthis.duration = duration;\n\t\t}\n\t\tAnimation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) {\n\t\t\tif (skeleton == null)\n\t\t\t\tthrow new Error(\"skeleton cannot be null.\");\n\t\t\tif (loop && this.duration != 0) {\n\t\t\t\ttime %= this.duration;\n\t\t\t\tif (lastTime > 0)\n\t\t\t\t\tlastTime %= this.duration;\n\t\t\t}\n\t\t\tvar timelines = this.timelines;\n\t\t\tfor (var i = 0, n = timelines.length; i < n; i++)\n\t\t\t\ttimelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction);\n\t\t};\n\t\tAnimation.binarySearch = function (values, target, step) {\n\t\t\tif (step === void 0) { step = 1; }\n\t\t\tvar low = 0;\n\t\t\tvar high = values.length / step - 2;\n\t\t\tif (high == 0)\n\t\t\t\treturn step;\n\t\t\tvar current = high >>> 1;\n\t\t\twhile (true) {\n\t\t\t\tif (values[(current + 1) * step] <= target)\n\t\t\t\t\tlow = current + 1;\n\t\t\t\telse\n\t\t\t\t\thigh = current;\n\t\t\t\tif (low == high)\n\t\t\t\t\treturn (low + 1) * step;\n\t\t\t\tcurrent = (low + high) >>> 1;\n\t\t\t}\n\t\t};\n\t\tAnimation.linearSearch = function (values, target, step) {\n\t\t\tfor (var i = 0, last = values.length - step; i <= last; i += step)\n\t\t\t\tif (values[i] > target)\n\t\t\t\t\treturn i;\n\t\t\treturn -1;\n\t\t};\n\t\treturn Animation;\n\t}());\n\tspine.Animation = Animation;\n\tvar MixPose;\n\t(function (MixPose) {\n\t\tMixPose[MixPose[\"setup\"] = 0] = \"setup\";\n\t\tMixPose[MixPose[\"current\"] = 1] = \"current\";\n\t\tMixPose[MixPose[\"currentLayered\"] = 2] = \"currentLayered\";\n\t})(MixPose = spine.MixPose || (spine.MixPose = {}));\n\tvar MixDirection;\n\t(function (MixDirection) {\n\t\tMixDirection[MixDirection[\"in\"] = 0] = \"in\";\n\t\tMixDirection[MixDirection[\"out\"] = 1] = \"out\";\n\t})(MixDirection = spine.MixDirection || (spine.MixDirection = {}));\n\tvar TimelineType;\n\t(function (TimelineType) {\n\t\tTimelineType[TimelineType[\"rotate\"] = 0] = \"rotate\";\n\t\tTimelineType[TimelineType[\"translate\"] = 1] = \"translate\";\n\t\tTimelineType[TimelineType[\"scale\"] = 2] = \"scale\";\n\t\tTimelineType[TimelineType[\"shear\"] = 3] = \"shear\";\n\t\tTimelineType[TimelineType[\"attachment\"] = 4] = \"attachment\";\n\t\tTimelineType[TimelineType[\"color\"] = 5] = \"color\";\n\t\tTimelineType[TimelineType[\"deform\"] = 6] = \"deform\";\n\t\tTimelineType[TimelineType[\"event\"] = 7] = \"event\";\n\t\tTimelineType[TimelineType[\"drawOrder\"] = 8] = \"drawOrder\";\n\t\tTimelineType[TimelineType[\"ikConstraint\"] = 9] = \"ikConstraint\";\n\t\tTimelineType[TimelineType[\"transformConstraint\"] = 10] = \"transformConstraint\";\n\t\tTimelineType[TimelineType[\"pathConstraintPosition\"] = 11] = \"pathConstraintPosition\";\n\t\tTimelineType[TimelineType[\"pathConstraintSpacing\"] = 12] = \"pathConstraintSpacing\";\n\t\tTimelineType[TimelineType[\"pathConstraintMix\"] = 13] = \"pathConstraintMix\";\n\t\tTimelineType[TimelineType[\"twoColor\"] = 14] = \"twoColor\";\n\t})(TimelineType = spine.TimelineType || (spine.TimelineType = {}));\n\tvar CurveTimeline = (function () {\n\t\tfunction CurveTimeline(frameCount) {\n\t\t\tif (frameCount <= 0)\n\t\t\t\tthrow new Error(\"frameCount must be > 0: \" + frameCount);\n\t\t\tthis.curves = spine.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE);\n\t\t}\n\t\tCurveTimeline.prototype.getFrameCount = function () {\n\t\t\treturn this.curves.length / CurveTimeline.BEZIER_SIZE + 1;\n\t\t};\n\t\tCurveTimeline.prototype.setLinear = function (frameIndex) {\n\t\t\tthis.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR;\n\t\t};\n\t\tCurveTimeline.prototype.setStepped = function (frameIndex) {\n\t\t\tthis.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED;\n\t\t};\n\t\tCurveTimeline.prototype.getCurveType = function (frameIndex) {\n\t\t\tvar index = frameIndex * CurveTimeline.BEZIER_SIZE;\n\t\t\tif (index == this.curves.length)\n\t\t\t\treturn CurveTimeline.LINEAR;\n\t\t\tvar type = this.curves[index];\n\t\t\tif (type == CurveTimeline.LINEAR)\n\t\t\t\treturn CurveTimeline.LINEAR;\n\t\t\tif (type == CurveTimeline.STEPPED)\n\t\t\t\treturn CurveTimeline.STEPPED;\n\t\t\treturn CurveTimeline.BEZIER;\n\t\t};\n\t\tCurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) {\n\t\t\tvar tmpx = (-cx1 * 2 + cx2) * 0.03, tmpy = (-cy1 * 2 + cy2) * 0.03;\n\t\t\tvar dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006;\n\t\t\tvar ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy;\n\t\t\tvar dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667;\n\t\t\tvar i = frameIndex * CurveTimeline.BEZIER_SIZE;\n\t\t\tvar curves = this.curves;\n\t\t\tcurves[i++] = CurveTimeline.BEZIER;\n\t\t\tvar x = dfx, y = dfy;\n\t\t\tfor (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {\n\t\t\t\tcurves[i] = x;\n\t\t\t\tcurves[i + 1] = y;\n\t\t\t\tdfx += ddfx;\n\t\t\t\tdfy += ddfy;\n\t\t\t\tddfx += dddfx;\n\t\t\t\tddfy += dddfy;\n\t\t\t\tx += dfx;\n\t\t\t\ty += dfy;\n\t\t\t}\n\t\t};\n\t\tCurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) {\n\t\t\tpercent = spine.MathUtils.clamp(percent, 0, 1);\n\t\t\tvar curves = this.curves;\n\t\t\tvar i = frameIndex * CurveTimeline.BEZIER_SIZE;\n\t\t\tvar type = curves[i];\n\t\t\tif (type == CurveTimeline.LINEAR)\n\t\t\t\treturn percent;\n\t\t\tif (type == CurveTimeline.STEPPED)\n\t\t\t\treturn 0;\n\t\t\ti++;\n\t\t\tvar x = 0;\n\t\t\tfor (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) {\n\t\t\t\tx = curves[i];\n\t\t\t\tif (x >= percent) {\n\t\t\t\t\tvar prevX = void 0, prevY = void 0;\n\t\t\t\t\tif (i == start) {\n\t\t\t\t\t\tprevX = 0;\n\t\t\t\t\t\tprevY = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tprevX = curves[i - 2];\n\t\t\t\t\t\tprevY = curves[i - 1];\n\t\t\t\t\t}\n\t\t\t\t\treturn prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX);\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar y = curves[i - 1];\n\t\t\treturn y + (1 - y) * (percent - x) / (1 - x);\n\t\t};\n\t\tCurveTimeline.LINEAR = 0;\n\t\tCurveTimeline.STEPPED = 1;\n\t\tCurveTimeline.BEZIER = 2;\n\t\tCurveTimeline.BEZIER_SIZE = 10 * 2 - 1;\n\t\treturn CurveTimeline;\n\t}());\n\tspine.CurveTimeline = CurveTimeline;\n\tvar RotateTimeline = (function (_super) {\n\t\t__extends(RotateTimeline, _super);\n\t\tfunction RotateTimeline(frameCount) {\n\t\t\tvar _this = _super.call(this, frameCount) || this;\n\t\t\t_this.frames = spine.Utils.newFloatArray(frameCount << 1);\n\t\t\treturn _this;\n\t\t}\n\t\tRotateTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.rotate << 24) + this.boneIndex;\n\t\t};\n\t\tRotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) {\n\t\t\tframeIndex <<= 1;\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.frames[frameIndex + RotateTimeline.ROTATION] = degrees;\n\t\t};\n\t\tRotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {\n\t\t\tvar frames = this.frames;\n\t\t\tvar bone = skeleton.bones[this.boneIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tbone.rotation = bone.data.rotation;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tvar r_1 = bone.data.rotation - bone.rotation;\n\t\t\t\t\t\tr_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360;\n\t\t\t\t\t\tbone.rotation += r_1 * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (time >= frames[frames.length - RotateTimeline.ENTRIES]) {\n\t\t\t\tif (pose == MixPose.setup)\n\t\t\t\t\tbone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha;\n\t\t\t\telse {\n\t\t\t\t\tvar r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation;\n\t\t\t\t\tr_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360;\n\t\t\t\t\tbone.rotation += r_2 * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES);\n\t\t\tvar prevRotation = frames[frame + RotateTimeline.PREV_ROTATION];\n\t\t\tvar frameTime = frames[frame];\n\t\t\tvar percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime));\n\t\t\tvar r = frames[frame + RotateTimeline.ROTATION] - prevRotation;\n\t\t\tr -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;\n\t\t\tr = prevRotation + r * percent;\n\t\t\tif (pose == MixPose.setup) {\n\t\t\t\tr -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;\n\t\t\t\tbone.rotation = bone.data.rotation + r * alpha;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tr = bone.data.rotation + r - bone.rotation;\n\t\t\t\tr -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;\n\t\t\t\tbone.rotation += r * alpha;\n\t\t\t}\n\t\t};\n\t\tRotateTimeline.ENTRIES = 2;\n\t\tRotateTimeline.PREV_TIME = -2;\n\t\tRotateTimeline.PREV_ROTATION = -1;\n\t\tRotateTimeline.ROTATION = 1;\n\t\treturn RotateTimeline;\n\t}(CurveTimeline));\n\tspine.RotateTimeline = RotateTimeline;\n\tvar TranslateTimeline = (function (_super) {\n\t\t__extends(TranslateTimeline, _super);\n\t\tfunction TranslateTimeline(frameCount) {\n\t\t\tvar _this = _super.call(this, frameCount) || this;\n\t\t\t_this.frames = spine.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES);\n\t\t\treturn _this;\n\t\t}\n\t\tTranslateTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.translate << 24) + this.boneIndex;\n\t\t};\n\t\tTranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) {\n\t\t\tframeIndex *= TranslateTimeline.ENTRIES;\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.frames[frameIndex + TranslateTimeline.X] = x;\n\t\t\tthis.frames[frameIndex + TranslateTimeline.Y] = y;\n\t\t};\n\t\tTranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {\n\t\t\tvar frames = this.frames;\n\t\t\tvar bone = skeleton.bones[this.boneIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tbone.x = bone.data.x;\n\t\t\t\t\t\tbone.y = bone.data.y;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tbone.x += (bone.data.x - bone.x) * alpha;\n\t\t\t\t\t\tbone.y += (bone.data.y - bone.y) * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar x = 0, y = 0;\n\t\t\tif (time >= frames[frames.length - TranslateTimeline.ENTRIES]) {\n\t\t\t\tx = frames[frames.length + TranslateTimeline.PREV_X];\n\t\t\t\ty = frames[frames.length + TranslateTimeline.PREV_Y];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES);\n\t\t\t\tx = frames[frame + TranslateTimeline.PREV_X];\n\t\t\t\ty = frames[frame + TranslateTimeline.PREV_Y];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime));\n\t\t\t\tx += (frames[frame + TranslateTimeline.X] - x) * percent;\n\t\t\t\ty += (frames[frame + TranslateTimeline.Y] - y) * percent;\n\t\t\t}\n\t\t\tif (pose == MixPose.setup) {\n\t\t\t\tbone.x = bone.data.x + x * alpha;\n\t\t\t\tbone.y = bone.data.y + y * alpha;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbone.x += (bone.data.x + x - bone.x) * alpha;\n\t\t\t\tbone.y += (bone.data.y + y - bone.y) * alpha;\n\t\t\t}\n\t\t};\n\t\tTranslateTimeline.ENTRIES = 3;\n\t\tTranslateTimeline.PREV_TIME = -3;\n\t\tTranslateTimeline.PREV_X = -2;\n\t\tTranslateTimeline.PREV_Y = -1;\n\t\tTranslateTimeline.X = 1;\n\t\tTranslateTimeline.Y = 2;\n\t\treturn TranslateTimeline;\n\t}(CurveTimeline));\n\tspine.TranslateTimeline = TranslateTimeline;\n\tvar ScaleTimeline = (function (_super) {\n\t\t__extends(ScaleTimeline, _super);\n\t\tfunction ScaleTimeline(frameCount) {\n\t\t\treturn _super.call(this, frameCount) || this;\n\t\t}\n\t\tScaleTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.scale << 24) + this.boneIndex;\n\t\t};\n\t\tScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {\n\t\t\tvar frames = this.frames;\n\t\t\tvar bone = skeleton.bones[this.boneIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tbone.scaleX = bone.data.scaleX;\n\t\t\t\t\t\tbone.scaleY = bone.data.scaleY;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tbone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha;\n\t\t\t\t\t\tbone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar x = 0, y = 0;\n\t\t\tif (time >= frames[frames.length - ScaleTimeline.ENTRIES]) {\n\t\t\t\tx = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX;\n\t\t\t\ty = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES);\n\t\t\t\tx = frames[frame + ScaleTimeline.PREV_X];\n\t\t\t\ty = frames[frame + ScaleTimeline.PREV_Y];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime));\n\t\t\t\tx = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX;\n\t\t\t\ty = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY;\n\t\t\t}\n\t\t\tif (alpha == 1) {\n\t\t\t\tbone.scaleX = x;\n\t\t\t\tbone.scaleY = y;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar bx = 0, by = 0;\n\t\t\t\tif (pose == MixPose.setup) {\n\t\t\t\t\tbx = bone.data.scaleX;\n\t\t\t\t\tby = bone.data.scaleY;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbx = bone.scaleX;\n\t\t\t\t\tby = bone.scaleY;\n\t\t\t\t}\n\t\t\t\tif (direction == MixDirection.out) {\n\t\t\t\t\tx = Math.abs(x) * spine.MathUtils.signum(bx);\n\t\t\t\t\ty = Math.abs(y) * spine.MathUtils.signum(by);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbx = Math.abs(bx) * spine.MathUtils.signum(x);\n\t\t\t\t\tby = Math.abs(by) * spine.MathUtils.signum(y);\n\t\t\t\t}\n\t\t\t\tbone.scaleX = bx + (x - bx) * alpha;\n\t\t\t\tbone.scaleY = by + (y - by) * alpha;\n\t\t\t}\n\t\t};\n\t\treturn ScaleTimeline;\n\t}(TranslateTimeline));\n\tspine.ScaleTimeline = ScaleTimeline;\n\tvar ShearTimeline = (function (_super) {\n\t\t__extends(ShearTimeline, _super);\n\t\tfunction ShearTimeline(frameCount) {\n\t\t\treturn _super.call(this, frameCount) || this;\n\t\t}\n\t\tShearTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.shear << 24) + this.boneIndex;\n\t\t};\n\t\tShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {\n\t\t\tvar frames = this.frames;\n\t\t\tvar bone = skeleton.bones[this.boneIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tbone.shearX = bone.data.shearX;\n\t\t\t\t\t\tbone.shearY = bone.data.shearY;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tbone.shearX += (bone.data.shearX - bone.shearX) * alpha;\n\t\t\t\t\t\tbone.shearY += (bone.data.shearY - bone.shearY) * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar x = 0, y = 0;\n\t\t\tif (time >= frames[frames.length - ShearTimeline.ENTRIES]) {\n\t\t\t\tx = frames[frames.length + ShearTimeline.PREV_X];\n\t\t\t\ty = frames[frames.length + ShearTimeline.PREV_Y];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES);\n\t\t\t\tx = frames[frame + ShearTimeline.PREV_X];\n\t\t\t\ty = frames[frame + ShearTimeline.PREV_Y];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime));\n\t\t\t\tx = x + (frames[frame + ShearTimeline.X] - x) * percent;\n\t\t\t\ty = y + (frames[frame + ShearTimeline.Y] - y) * percent;\n\t\t\t}\n\t\t\tif (pose == MixPose.setup) {\n\t\t\t\tbone.shearX = bone.data.shearX + x * alpha;\n\t\t\t\tbone.shearY = bone.data.shearY + y * alpha;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbone.shearX += (bone.data.shearX + x - bone.shearX) * alpha;\n\t\t\t\tbone.shearY += (bone.data.shearY + y - bone.shearY) * alpha;\n\t\t\t}\n\t\t};\n\t\treturn ShearTimeline;\n\t}(TranslateTimeline));\n\tspine.ShearTimeline = ShearTimeline;\n\tvar ColorTimeline = (function (_super) {\n\t\t__extends(ColorTimeline, _super);\n\t\tfunction ColorTimeline(frameCount) {\n\t\t\tvar _this = _super.call(this, frameCount) || this;\n\t\t\t_this.frames = spine.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES);\n\t\t\treturn _this;\n\t\t}\n\t\tColorTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.color << 24) + this.slotIndex;\n\t\t};\n\t\tColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) {\n\t\t\tframeIndex *= ColorTimeline.ENTRIES;\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.frames[frameIndex + ColorTimeline.R] = r;\n\t\t\tthis.frames[frameIndex + ColorTimeline.G] = g;\n\t\t\tthis.frames[frameIndex + ColorTimeline.B] = b;\n\t\t\tthis.frames[frameIndex + ColorTimeline.A] = a;\n\t\t};\n\t\tColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {\n\t\t\tvar slot = skeleton.slots[this.slotIndex];\n\t\t\tvar frames = this.frames;\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tslot.color.setFromColor(slot.data.color);\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tvar color = slot.color, setup = slot.data.color;\n\t\t\t\t\t\tcolor.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar r = 0, g = 0, b = 0, a = 0;\n\t\t\tif (time >= frames[frames.length - ColorTimeline.ENTRIES]) {\n\t\t\t\tvar i = frames.length;\n\t\t\t\tr = frames[i + ColorTimeline.PREV_R];\n\t\t\t\tg = frames[i + ColorTimeline.PREV_G];\n\t\t\t\tb = frames[i + ColorTimeline.PREV_B];\n\t\t\t\ta = frames[i + ColorTimeline.PREV_A];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES);\n\t\t\t\tr = frames[frame + ColorTimeline.PREV_R];\n\t\t\t\tg = frames[frame + ColorTimeline.PREV_G];\n\t\t\t\tb = frames[frame + ColorTimeline.PREV_B];\n\t\t\t\ta = frames[frame + ColorTimeline.PREV_A];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime));\n\t\t\t\tr += (frames[frame + ColorTimeline.R] - r) * percent;\n\t\t\t\tg += (frames[frame + ColorTimeline.G] - g) * percent;\n\t\t\t\tb += (frames[frame + ColorTimeline.B] - b) * percent;\n\t\t\t\ta += (frames[frame + ColorTimeline.A] - a) * percent;\n\t\t\t}\n\t\t\tif (alpha == 1)\n\t\t\t\tslot.color.set(r, g, b, a);\n\t\t\telse {\n\t\t\t\tvar color = slot.color;\n\t\t\t\tif (pose == MixPose.setup)\n\t\t\t\t\tcolor.setFromColor(slot.data.color);\n\t\t\t\tcolor.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);\n\t\t\t}\n\t\t};\n\t\tColorTimeline.ENTRIES = 5;\n\t\tColorTimeline.PREV_TIME = -5;\n\t\tColorTimeline.PREV_R = -4;\n\t\tColorTimeline.PREV_G = -3;\n\t\tColorTimeline.PREV_B = -2;\n\t\tColorTimeline.PREV_A = -1;\n\t\tColorTimeline.R = 1;\n\t\tColorTimeline.G = 2;\n\t\tColorTimeline.B = 3;\n\t\tColorTimeline.A = 4;\n\t\treturn ColorTimeline;\n\t}(CurveTimeline));\n\tspine.ColorTimeline = ColorTimeline;\n\tvar TwoColorTimeline = (function (_super) {\n\t\t__extends(TwoColorTimeline, _super);\n\t\tfunction TwoColorTimeline(frameCount) {\n\t\t\tvar _this = _super.call(this, frameCount) || this;\n\t\t\t_this.frames = spine.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES);\n\t\t\treturn _this;\n\t\t}\n\t\tTwoColorTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.twoColor << 24) + this.slotIndex;\n\t\t};\n\t\tTwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) {\n\t\t\tframeIndex *= TwoColorTimeline.ENTRIES;\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.frames[frameIndex + TwoColorTimeline.R] = r;\n\t\t\tthis.frames[frameIndex + TwoColorTimeline.G] = g;\n\t\t\tthis.frames[frameIndex + TwoColorTimeline.B] = b;\n\t\t\tthis.frames[frameIndex + TwoColorTimeline.A] = a;\n\t\t\tthis.frames[frameIndex + TwoColorTimeline.R2] = r2;\n\t\t\tthis.frames[frameIndex + TwoColorTimeline.G2] = g2;\n\t\t\tthis.frames[frameIndex + TwoColorTimeline.B2] = b2;\n\t\t};\n\t\tTwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {\n\t\t\tvar slot = skeleton.slots[this.slotIndex];\n\t\t\tvar frames = this.frames;\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tslot.color.setFromColor(slot.data.color);\n\t\t\t\t\t\tslot.darkColor.setFromColor(slot.data.darkColor);\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tvar light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor;\n\t\t\t\t\t\tlight.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha);\n\t\t\t\t\t\tdark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0;\n\t\t\tif (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) {\n\t\t\t\tvar i = frames.length;\n\t\t\t\tr = frames[i + TwoColorTimeline.PREV_R];\n\t\t\t\tg = frames[i + TwoColorTimeline.PREV_G];\n\t\t\t\tb = frames[i + TwoColorTimeline.PREV_B];\n\t\t\t\ta = frames[i + TwoColorTimeline.PREV_A];\n\t\t\t\tr2 = frames[i + TwoColorTimeline.PREV_R2];\n\t\t\t\tg2 = frames[i + TwoColorTimeline.PREV_G2];\n\t\t\t\tb2 = frames[i + TwoColorTimeline.PREV_B2];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES);\n\t\t\t\tr = frames[frame + TwoColorTimeline.PREV_R];\n\t\t\t\tg = frames[frame + TwoColorTimeline.PREV_G];\n\t\t\t\tb = frames[frame + TwoColorTimeline.PREV_B];\n\t\t\t\ta = frames[frame + TwoColorTimeline.PREV_A];\n\t\t\t\tr2 = frames[frame + TwoColorTimeline.PREV_R2];\n\t\t\t\tg2 = frames[frame + TwoColorTimeline.PREV_G2];\n\t\t\t\tb2 = frames[frame + TwoColorTimeline.PREV_B2];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime));\n\t\t\t\tr += (frames[frame + TwoColorTimeline.R] - r) * percent;\n\t\t\t\tg += (frames[frame + TwoColorTimeline.G] - g) * percent;\n\t\t\t\tb += (frames[frame + TwoColorTimeline.B] - b) * percent;\n\t\t\t\ta += (frames[frame + TwoColorTimeline.A] - a) * percent;\n\t\t\t\tr2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent;\n\t\t\t\tg2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent;\n\t\t\t\tb2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent;\n\t\t\t}\n\t\t\tif (alpha == 1) {\n\t\t\t\tslot.color.set(r, g, b, a);\n\t\t\t\tslot.darkColor.set(r2, g2, b2, 1);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar light = slot.color, dark = slot.darkColor;\n\t\t\t\tif (pose == MixPose.setup) {\n\t\t\t\t\tlight.setFromColor(slot.data.color);\n\t\t\t\t\tdark.setFromColor(slot.data.darkColor);\n\t\t\t\t}\n\t\t\t\tlight.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha);\n\t\t\t\tdark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0);\n\t\t\t}\n\t\t};\n\t\tTwoColorTimeline.ENTRIES = 8;\n\t\tTwoColorTimeline.PREV_TIME = -8;\n\t\tTwoColorTimeline.PREV_R = -7;\n\t\tTwoColorTimeline.PREV_G = -6;\n\t\tTwoColorTimeline.PREV_B = -5;\n\t\tTwoColorTimeline.PREV_A = -4;\n\t\tTwoColorTimeline.PREV_R2 = -3;\n\t\tTwoColorTimeline.PREV_G2 = -2;\n\t\tTwoColorTimeline.PREV_B2 = -1;\n\t\tTwoColorTimeline.R = 1;\n\t\tTwoColorTimeline.G = 2;\n\t\tTwoColorTimeline.B = 3;\n\t\tTwoColorTimeline.A = 4;\n\t\tTwoColorTimeline.R2 = 5;\n\t\tTwoColorTimeline.G2 = 6;\n\t\tTwoColorTimeline.B2 = 7;\n\t\treturn TwoColorTimeline;\n\t}(CurveTimeline));\n\tspine.TwoColorTimeline = TwoColorTimeline;\n\tvar AttachmentTimeline = (function () {\n\t\tfunction AttachmentTimeline(frameCount) {\n\t\t\tthis.frames = spine.Utils.newFloatArray(frameCount);\n\t\t\tthis.attachmentNames = new Array(frameCount);\n\t\t}\n\t\tAttachmentTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.attachment << 24) + this.slotIndex;\n\t\t};\n\t\tAttachmentTimeline.prototype.getFrameCount = function () {\n\t\t\treturn this.frames.length;\n\t\t};\n\t\tAttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) {\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.attachmentNames[frameIndex] = attachmentName;\n\t\t};\n\t\tAttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) {\n\t\t\tvar slot = skeleton.slots[this.slotIndex];\n\t\t\tif (direction == MixDirection.out && pose == MixPose.setup) {\n\t\t\t\tvar attachmentName_1 = slot.data.attachmentName;\n\t\t\t\tslot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar frames = this.frames;\n\t\t\tif (time < frames[0]) {\n\t\t\t\tif (pose == MixPose.setup) {\n\t\t\t\t\tvar attachmentName_2 = slot.data.attachmentName;\n\t\t\t\t\tslot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2));\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar frameIndex = 0;\n\t\t\tif (time >= frames[frames.length - 1])\n\t\t\t\tframeIndex = frames.length - 1;\n\t\t\telse\n\t\t\t\tframeIndex = Animation.binarySearch(frames, time, 1) - 1;\n\t\t\tvar attachmentName = this.attachmentNames[frameIndex];\n\t\t\tskeleton.slots[this.slotIndex]\n\t\t\t\t.setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName));\n\t\t};\n\t\treturn AttachmentTimeline;\n\t}());\n\tspine.AttachmentTimeline = AttachmentTimeline;\n\tvar zeros = null;\n\tvar DeformTimeline = (function (_super) {\n\t\t__extends(DeformTimeline, _super);\n\t\tfunction DeformTimeline(frameCount) {\n\t\t\tvar _this = _super.call(this, frameCount) || this;\n\t\t\t_this.frames = spine.Utils.newFloatArray(frameCount);\n\t\t\t_this.frameVertices = new Array(frameCount);\n\t\t\tif (zeros == null)\n\t\t\t\tzeros = spine.Utils.newFloatArray(64);\n\t\t\treturn _this;\n\t\t}\n\t\tDeformTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex;\n\t\t};\n\t\tDeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) {\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.frameVertices[frameIndex] = vertices;\n\t\t};\n\t\tDeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {\n\t\t\tvar slot = skeleton.slots[this.slotIndex];\n\t\t\tvar slotAttachment = slot.getAttachment();\n\t\t\tif (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment))\n\t\t\t\treturn;\n\t\t\tvar verticesArray = slot.attachmentVertices;\n\t\t\tif (verticesArray.length == 0)\n\t\t\t\talpha = 1;\n\t\t\tvar frameVertices = this.frameVertices;\n\t\t\tvar vertexCount = frameVertices[0].length;\n\t\t\tvar frames = this.frames;\n\t\t\tif (time < frames[0]) {\n\t\t\t\tvar vertexAttachment = slotAttachment;\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tverticesArray.length = 0;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tif (alpha == 1) {\n\t\t\t\t\t\t\tverticesArray.length = 0;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar vertices_1 = spine.Utils.setArraySize(verticesArray, vertexCount);\n\t\t\t\t\t\tif (vertexAttachment.bones == null) {\n\t\t\t\t\t\t\tvar setupVertices = vertexAttachment.vertices;\n\t\t\t\t\t\t\tfor (var i = 0; i < vertexCount; i++)\n\t\t\t\t\t\t\t\tvertices_1[i] += (setupVertices[i] - vertices_1[i]) * alpha;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\talpha = 1 - alpha;\n\t\t\t\t\t\t\tfor (var i = 0; i < vertexCount; i++)\n\t\t\t\t\t\t\t\tvertices_1[i] *= alpha;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar vertices = spine.Utils.setArraySize(verticesArray, vertexCount);\n\t\t\tif (time >= frames[frames.length - 1]) {\n\t\t\t\tvar lastVertices = frameVertices[frames.length - 1];\n\t\t\t\tif (alpha == 1) {\n\t\t\t\t\tspine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount);\n\t\t\t\t}\n\t\t\t\telse if (pose == MixPose.setup) {\n\t\t\t\t\tvar vertexAttachment = slotAttachment;\n\t\t\t\t\tif (vertexAttachment.bones == null) {\n\t\t\t\t\t\tvar setupVertices_1 = vertexAttachment.vertices;\n\t\t\t\t\t\tfor (var i_1 = 0; i_1 < vertexCount; i_1++) {\n\t\t\t\t\t\t\tvar setup = setupVertices_1[i_1];\n\t\t\t\t\t\t\tvertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tfor (var i_2 = 0; i_2 < vertexCount; i_2++)\n\t\t\t\t\t\t\tvertices[i_2] = lastVertices[i_2] * alpha;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfor (var i_3 = 0; i_3 < vertexCount; i_3++)\n\t\t\t\t\t\tvertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar frame = Animation.binarySearch(frames, time);\n\t\t\tvar prevVertices = frameVertices[frame - 1];\n\t\t\tvar nextVertices = frameVertices[frame];\n\t\t\tvar frameTime = frames[frame];\n\t\t\tvar percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));\n\t\t\tif (alpha == 1) {\n\t\t\t\tfor (var i_4 = 0; i_4 < vertexCount; i_4++) {\n\t\t\t\t\tvar prev = prevVertices[i_4];\n\t\t\t\t\tvertices[i_4] = prev + (nextVertices[i_4] - prev) * percent;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (pose == MixPose.setup) {\n\t\t\t\tvar vertexAttachment = slotAttachment;\n\t\t\t\tif (vertexAttachment.bones == null) {\n\t\t\t\t\tvar setupVertices_2 = vertexAttachment.vertices;\n\t\t\t\t\tfor (var i_5 = 0; i_5 < vertexCount; i_5++) {\n\t\t\t\t\t\tvar prev = prevVertices[i_5], setup = setupVertices_2[i_5];\n\t\t\t\t\t\tvertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfor (var i_6 = 0; i_6 < vertexCount; i_6++) {\n\t\t\t\t\t\tvar prev = prevVertices[i_6];\n\t\t\t\t\t\tvertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (var i_7 = 0; i_7 < vertexCount; i_7++) {\n\t\t\t\t\tvar prev = prevVertices[i_7];\n\t\t\t\t\tvertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\treturn DeformTimeline;\n\t}(CurveTimeline));\n\tspine.DeformTimeline = DeformTimeline;\n\tvar EventTimeline = (function () {\n\t\tfunction EventTimeline(frameCount) {\n\t\t\tthis.frames = spine.Utils.newFloatArray(frameCount);\n\t\t\tthis.events = new Array(frameCount);\n\t\t}\n\t\tEventTimeline.prototype.getPropertyId = function () {\n\t\t\treturn TimelineType.event << 24;\n\t\t};\n\t\tEventTimeline.prototype.getFrameCount = function () {\n\t\t\treturn this.frames.length;\n\t\t};\n\t\tEventTimeline.prototype.setFrame = function (frameIndex, event) {\n\t\t\tthis.frames[frameIndex] = event.time;\n\t\t\tthis.events[frameIndex] = event;\n\t\t};\n\t\tEventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {\n\t\t\tif (firedEvents == null)\n\t\t\t\treturn;\n\t\t\tvar frames = this.frames;\n\t\t\tvar frameCount = this.frames.length;\n\t\t\tif (lastTime > time) {\n\t\t\t\tthis.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction);\n\t\t\t\tlastTime = -1;\n\t\t\t}\n\t\t\telse if (lastTime >= frames[frameCount - 1])\n\t\t\t\treturn;\n\t\t\tif (time < frames[0])\n\t\t\t\treturn;\n\t\t\tvar frame = 0;\n\t\t\tif (lastTime < frames[0])\n\t\t\t\tframe = 0;\n\t\t\telse {\n\t\t\t\tframe = Animation.binarySearch(frames, lastTime);\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\twhile (frame > 0) {\n\t\t\t\t\tif (frames[frame - 1] != frameTime)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tframe--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (; frame < frameCount && time >= frames[frame]; frame++)\n\t\t\t\tfiredEvents.push(this.events[frame]);\n\t\t};\n\t\treturn EventTimeline;\n\t}());\n\tspine.EventTimeline = EventTimeline;\n\tvar DrawOrderTimeline = (function () {\n\t\tfunction DrawOrderTimeline(frameCount) {\n\t\t\tthis.frames = spine.Utils.newFloatArray(frameCount);\n\t\t\tthis.drawOrders = new Array(frameCount);\n\t\t}\n\t\tDrawOrderTimeline.prototype.getPropertyId = function () {\n\t\t\treturn TimelineType.drawOrder << 24;\n\t\t};\n\t\tDrawOrderTimeline.prototype.getFrameCount = function () {\n\t\t\treturn this.frames.length;\n\t\t};\n\t\tDrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) {\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.drawOrders[frameIndex] = drawOrder;\n\t\t};\n\t\tDrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {\n\t\t\tvar drawOrder = skeleton.drawOrder;\n\t\t\tvar slots = skeleton.slots;\n\t\t\tif (direction == MixDirection.out && pose == MixPose.setup) {\n\t\t\t\tspine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar frames = this.frames;\n\t\t\tif (time < frames[0]) {\n\t\t\t\tif (pose == MixPose.setup)\n\t\t\t\t\tspine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar frame = 0;\n\t\t\tif (time >= frames[frames.length - 1])\n\t\t\t\tframe = frames.length - 1;\n\t\t\telse\n\t\t\t\tframe = Animation.binarySearch(frames, time) - 1;\n\t\t\tvar drawOrderToSetupIndex = this.drawOrders[frame];\n\t\t\tif (drawOrderToSetupIndex == null)\n\t\t\t\tspine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length);\n\t\t\telse {\n\t\t\t\tfor (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++)\n\t\t\t\t\tdrawOrder[i] = slots[drawOrderToSetupIndex[i]];\n\t\t\t}\n\t\t};\n\t\treturn DrawOrderTimeline;\n\t}());\n\tspine.DrawOrderTimeline = DrawOrderTimeline;\n\tvar IkConstraintTimeline = (function (_super) {\n\t\t__extends(IkConstraintTimeline, _super);\n\t\tfunction IkConstraintTimeline(frameCount) {\n\t\t\tvar _this = _super.call(this, frameCount) || this;\n\t\t\t_this.frames = spine.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES);\n\t\t\treturn _this;\n\t\t}\n\t\tIkConstraintTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.ikConstraint << 24) + this.ikConstraintIndex;\n\t\t};\n\t\tIkConstraintTimeline.prototype.setFrame = function (frameIndex, time, mix, bendDirection) {\n\t\t\tframeIndex *= IkConstraintTimeline.ENTRIES;\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.frames[frameIndex + IkConstraintTimeline.MIX] = mix;\n\t\t\tthis.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection;\n\t\t};\n\t\tIkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {\n\t\t\tvar frames = this.frames;\n\t\t\tvar constraint = skeleton.ikConstraints[this.ikConstraintIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tconstraint.mix = constraint.data.mix;\n\t\t\t\t\t\tconstraint.bendDirection = constraint.data.bendDirection;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tconstraint.mix += (constraint.data.mix - constraint.mix) * alpha;\n\t\t\t\t\t\tconstraint.bendDirection = constraint.data.bendDirection;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) {\n\t\t\t\tif (pose == MixPose.setup) {\n\t\t\t\t\tconstraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha;\n\t\t\t\t\tconstraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection\n\t\t\t\t\t\t: frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tconstraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha;\n\t\t\t\t\tif (direction == MixDirection[\"in\"])\n\t\t\t\t\t\tconstraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION];\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES);\n\t\t\tvar mix = frames[frame + IkConstraintTimeline.PREV_MIX];\n\t\t\tvar frameTime = frames[frame];\n\t\t\tvar percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime));\n\t\t\tif (pose == MixPose.setup) {\n\t\t\t\tconstraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha;\n\t\t\t\tconstraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconstraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha;\n\t\t\t\tif (direction == MixDirection[\"in\"])\n\t\t\t\t\tconstraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION];\n\t\t\t}\n\t\t};\n\t\tIkConstraintTimeline.ENTRIES = 3;\n\t\tIkConstraintTimeline.PREV_TIME = -3;\n\t\tIkConstraintTimeline.PREV_MIX = -2;\n\t\tIkConstraintTimeline.PREV_BEND_DIRECTION = -1;\n\t\tIkConstraintTimeline.MIX = 1;\n\t\tIkConstraintTimeline.BEND_DIRECTION = 2;\n\t\treturn IkConstraintTimeline;\n\t}(CurveTimeline));\n\tspine.IkConstraintTimeline = IkConstraintTimeline;\n\tvar TransformConstraintTimeline = (function (_super) {\n\t\t__extends(TransformConstraintTimeline, _super);\n\t\tfunction TransformConstraintTimeline(frameCount) {\n\t\t\tvar _this = _super.call(this, frameCount) || this;\n\t\t\t_this.frames = spine.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES);\n\t\t\treturn _this;\n\t\t}\n\t\tTransformConstraintTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.transformConstraint << 24) + this.transformConstraintIndex;\n\t\t};\n\t\tTransformConstraintTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) {\n\t\t\tframeIndex *= TransformConstraintTimeline.ENTRIES;\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix;\n\t\t\tthis.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix;\n\t\t\tthis.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix;\n\t\t\tthis.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix;\n\t\t};\n\t\tTransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {\n\t\t\tvar frames = this.frames;\n\t\t\tvar constraint = skeleton.transformConstraints[this.transformConstraintIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tvar data = constraint.data;\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tconstraint.rotateMix = data.rotateMix;\n\t\t\t\t\t\tconstraint.translateMix = data.translateMix;\n\t\t\t\t\t\tconstraint.scaleMix = data.scaleMix;\n\t\t\t\t\t\tconstraint.shearMix = data.shearMix;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tconstraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha;\n\t\t\t\t\t\tconstraint.translateMix += (data.translateMix - constraint.translateMix) * alpha;\n\t\t\t\t\t\tconstraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha;\n\t\t\t\t\t\tconstraint.shearMix += (data.shearMix - constraint.shearMix) * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar rotate = 0, translate = 0, scale = 0, shear = 0;\n\t\t\tif (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) {\n\t\t\t\tvar i = frames.length;\n\t\t\t\trotate = frames[i + TransformConstraintTimeline.PREV_ROTATE];\n\t\t\t\ttranslate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE];\n\t\t\t\tscale = frames[i + TransformConstraintTimeline.PREV_SCALE];\n\t\t\t\tshear = frames[i + TransformConstraintTimeline.PREV_SHEAR];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES);\n\t\t\t\trotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE];\n\t\t\t\ttranslate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE];\n\t\t\t\tscale = frames[frame + TransformConstraintTimeline.PREV_SCALE];\n\t\t\t\tshear = frames[frame + TransformConstraintTimeline.PREV_SHEAR];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime));\n\t\t\t\trotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent;\n\t\t\t\ttranslate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent;\n\t\t\t\tscale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent;\n\t\t\t\tshear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent;\n\t\t\t}\n\t\t\tif (pose == MixPose.setup) {\n\t\t\t\tvar data = constraint.data;\n\t\t\t\tconstraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha;\n\t\t\t\tconstraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha;\n\t\t\t\tconstraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha;\n\t\t\t\tconstraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconstraint.rotateMix += (rotate - constraint.rotateMix) * alpha;\n\t\t\t\tconstraint.translateMix += (translate - constraint.translateMix) * alpha;\n\t\t\t\tconstraint.scaleMix += (scale - constraint.scaleMix) * alpha;\n\t\t\t\tconstraint.shearMix += (shear - constraint.shearMix) * alpha;\n\t\t\t}\n\t\t};\n\t\tTransformConstraintTimeline.ENTRIES = 5;\n\t\tTransformConstraintTimeline.PREV_TIME = -5;\n\t\tTransformConstraintTimeline.PREV_ROTATE = -4;\n\t\tTransformConstraintTimeline.PREV_TRANSLATE = -3;\n\t\tTransformConstraintTimeline.PREV_SCALE = -2;\n\t\tTransformConstraintTimeline.PREV_SHEAR = -1;\n\t\tTransformConstraintTimeline.ROTATE = 1;\n\t\tTransformConstraintTimeline.TRANSLATE = 2;\n\t\tTransformConstraintTimeline.SCALE = 3;\n\t\tTransformConstraintTimeline.SHEAR = 4;\n\t\treturn TransformConstraintTimeline;\n\t}(CurveTimeline));\n\tspine.TransformConstraintTimeline = TransformConstraintTimeline;\n\tvar PathConstraintPositionTimeline = (function (_super) {\n\t\t__extends(PathConstraintPositionTimeline, _super);\n\t\tfunction PathConstraintPositionTimeline(frameCount) {\n\t\t\tvar _this = _super.call(this, frameCount) || this;\n\t\t\t_this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES);\n\t\t\treturn _this;\n\t\t}\n\t\tPathConstraintPositionTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex;\n\t\t};\n\t\tPathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) {\n\t\t\tframeIndex *= PathConstraintPositionTimeline.ENTRIES;\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value;\n\t\t};\n\t\tPathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {\n\t\t\tvar frames = this.frames;\n\t\t\tvar constraint = skeleton.pathConstraints[this.pathConstraintIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tconstraint.position = constraint.data.position;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tconstraint.position += (constraint.data.position - constraint.position) * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar position = 0;\n\t\t\tif (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES])\n\t\t\t\tposition = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE];\n\t\t\telse {\n\t\t\t\tvar frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES);\n\t\t\t\tposition = frames[frame + PathConstraintPositionTimeline.PREV_VALUE];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime));\n\t\t\t\tposition += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent;\n\t\t\t}\n\t\t\tif (pose == MixPose.setup)\n\t\t\t\tconstraint.position = constraint.data.position + (position - constraint.data.position) * alpha;\n\t\t\telse\n\t\t\t\tconstraint.position += (position - constraint.position) * alpha;\n\t\t};\n\t\tPathConstraintPositionTimeline.ENTRIES = 2;\n\t\tPathConstraintPositionTimeline.PREV_TIME = -2;\n\t\tPathConstraintPositionTimeline.PREV_VALUE = -1;\n\t\tPathConstraintPositionTimeline.VALUE = 1;\n\t\treturn PathConstraintPositionTimeline;\n\t}(CurveTimeline));\n\tspine.PathConstraintPositionTimeline = PathConstraintPositionTimeline;\n\tvar PathConstraintSpacingTimeline = (function (_super) {\n\t\t__extends(PathConstraintSpacingTimeline, _super);\n\t\tfunction PathConstraintSpacingTimeline(frameCount) {\n\t\t\treturn _super.call(this, frameCount) || this;\n\t\t}\n\t\tPathConstraintSpacingTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex;\n\t\t};\n\t\tPathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {\n\t\t\tvar frames = this.frames;\n\t\t\tvar constraint = skeleton.pathConstraints[this.pathConstraintIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tconstraint.spacing = constraint.data.spacing;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tconstraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar spacing = 0;\n\t\t\tif (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES])\n\t\t\t\tspacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE];\n\t\t\telse {\n\t\t\t\tvar frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES);\n\t\t\t\tspacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime));\n\t\t\t\tspacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent;\n\t\t\t}\n\t\t\tif (pose == MixPose.setup)\n\t\t\t\tconstraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha;\n\t\t\telse\n\t\t\t\tconstraint.spacing += (spacing - constraint.spacing) * alpha;\n\t\t};\n\t\treturn PathConstraintSpacingTimeline;\n\t}(PathConstraintPositionTimeline));\n\tspine.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline;\n\tvar PathConstraintMixTimeline = (function (_super) {\n\t\t__extends(PathConstraintMixTimeline, _super);\n\t\tfunction PathConstraintMixTimeline(frameCount) {\n\t\t\tvar _this = _super.call(this, frameCount) || this;\n\t\t\t_this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES);\n\t\t\treturn _this;\n\t\t}\n\t\tPathConstraintMixTimeline.prototype.getPropertyId = function () {\n\t\t\treturn (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex;\n\t\t};\n\t\tPathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) {\n\t\t\tframeIndex *= PathConstraintMixTimeline.ENTRIES;\n\t\t\tthis.frames[frameIndex] = time;\n\t\t\tthis.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix;\n\t\t\tthis.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix;\n\t\t};\n\t\tPathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) {\n\t\t\tvar frames = this.frames;\n\t\t\tvar constraint = skeleton.pathConstraints[this.pathConstraintIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tswitch (pose) {\n\t\t\t\t\tcase MixPose.setup:\n\t\t\t\t\t\tconstraint.rotateMix = constraint.data.rotateMix;\n\t\t\t\t\t\tconstraint.translateMix = constraint.data.translateMix;\n\t\t\t\t\t\treturn;\n\t\t\t\t\tcase MixPose.current:\n\t\t\t\t\t\tconstraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha;\n\t\t\t\t\t\tconstraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar rotate = 0, translate = 0;\n\t\t\tif (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) {\n\t\t\t\trotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE];\n\t\t\t\ttranslate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES);\n\t\t\t\trotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE];\n\t\t\t\ttranslate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime));\n\t\t\t\trotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent;\n\t\t\t\ttranslate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent;\n\t\t\t}\n\t\t\tif (pose == MixPose.setup) {\n\t\t\t\tconstraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha;\n\t\t\t\tconstraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconstraint.rotateMix += (rotate - constraint.rotateMix) * alpha;\n\t\t\t\tconstraint.translateMix += (translate - constraint.translateMix) * alpha;\n\t\t\t}\n\t\t};\n\t\tPathConstraintMixTimeline.ENTRIES = 3;\n\t\tPathConstraintMixTimeline.PREV_TIME = -3;\n\t\tPathConstraintMixTimeline.PREV_ROTATE = -2;\n\t\tPathConstraintMixTimeline.PREV_TRANSLATE = -1;\n\t\tPathConstraintMixTimeline.ROTATE = 1;\n\t\tPathConstraintMixTimeline.TRANSLATE = 2;\n\t\treturn PathConstraintMixTimeline;\n\t}(CurveTimeline));\n\tspine.PathConstraintMixTimeline = PathConstraintMixTimeline;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar AnimationState = (function () {\n\t\tfunction AnimationState(data) {\n\t\t\tthis.tracks = new Array();\n\t\t\tthis.events = new Array();\n\t\t\tthis.listeners = new Array();\n\t\t\tthis.queue = new EventQueue(this);\n\t\t\tthis.propertyIDs = new spine.IntSet();\n\t\t\tthis.mixingTo = new Array();\n\t\t\tthis.animationsChanged = false;\n\t\t\tthis.timeScale = 1;\n\t\t\tthis.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });\n\t\t\tthis.data = data;\n\t\t}\n\t\tAnimationState.prototype.update = function (delta) {\n\t\t\tdelta *= this.timeScale;\n\t\t\tvar tracks = this.tracks;\n\t\t\tfor (var i = 0, n = tracks.length; i < n; i++) {\n\t\t\t\tvar current = tracks[i];\n\t\t\t\tif (current == null)\n\t\t\t\t\tcontinue;\n\t\t\t\tcurrent.animationLast = current.nextAnimationLast;\n\t\t\t\tcurrent.trackLast = current.nextTrackLast;\n\t\t\t\tvar currentDelta = delta * current.timeScale;\n\t\t\t\tif (current.delay > 0) {\n\t\t\t\t\tcurrent.delay -= currentDelta;\n\t\t\t\t\tif (current.delay > 0)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tcurrentDelta = -current.delay;\n\t\t\t\t\tcurrent.delay = 0;\n\t\t\t\t}\n\t\t\t\tvar next = current.next;\n\t\t\t\tif (next != null) {\n\t\t\t\t\tvar nextTime = current.trackLast - next.delay;\n\t\t\t\t\tif (nextTime >= 0) {\n\t\t\t\t\t\tnext.delay = 0;\n\t\t\t\t\t\tnext.trackTime = nextTime + delta * next.timeScale;\n\t\t\t\t\t\tcurrent.trackTime += currentDelta;\n\t\t\t\t\t\tthis.setCurrent(i, next, true);\n\t\t\t\t\t\twhile (next.mixingFrom != null) {\n\t\t\t\t\t\t\tnext.mixTime += currentDelta;\n\t\t\t\t\t\t\tnext = next.mixingFrom;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (current.trackLast >= current.trackEnd && current.mixingFrom == null) {\n\t\t\t\t\ttracks[i] = null;\n\t\t\t\t\tthis.queue.end(current);\n\t\t\t\t\tthis.disposeNext(current);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (current.mixingFrom != null && this.updateMixingFrom(current, delta)) {\n\t\t\t\t\tvar from = current.mixingFrom;\n\t\t\t\t\tcurrent.mixingFrom = null;\n\t\t\t\t\twhile (from != null) {\n\t\t\t\t\t\tthis.queue.end(from);\n\t\t\t\t\t\tfrom = from.mixingFrom;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcurrent.trackTime += currentDelta;\n\t\t\t}\n\t\t\tthis.queue.drain();\n\t\t};\n\t\tAnimationState.prototype.updateMixingFrom = function (to, delta) {\n\t\t\tvar from = to.mixingFrom;\n\t\t\tif (from == null)\n\t\t\t\treturn true;\n\t\t\tvar finished = this.updateMixingFrom(from, delta);\n\t\t\tfrom.animationLast = from.nextAnimationLast;\n\t\t\tfrom.trackLast = from.nextTrackLast;\n\t\t\tif (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {\n\t\t\t\tif (from.totalAlpha == 0 || to.mixDuration == 0) {\n\t\t\t\t\tto.mixingFrom = from.mixingFrom;\n\t\t\t\t\tto.interruptAlpha = from.interruptAlpha;\n\t\t\t\t\tthis.queue.end(from);\n\t\t\t\t}\n\t\t\t\treturn finished;\n\t\t\t}\n\t\t\tfrom.trackTime += delta * from.timeScale;\n\t\t\tto.mixTime += delta * to.timeScale;\n\t\t\treturn false;\n\t\t};\n\t\tAnimationState.prototype.apply = function (skeleton) {\n\t\t\tif (skeleton == null)\n\t\t\t\tthrow new Error(\"skeleton cannot be null.\");\n\t\t\tif (this.animationsChanged)\n\t\t\t\tthis._animationsChanged();\n\t\t\tvar events = this.events;\n\t\t\tvar tracks = this.tracks;\n\t\t\tvar applied = false;\n\t\t\tfor (var i = 0, n = tracks.length; i < n; i++) {\n\t\t\t\tvar current = tracks[i];\n\t\t\t\tif (current == null || current.delay > 0)\n\t\t\t\t\tcontinue;\n\t\t\t\tapplied = true;\n\t\t\t\tvar currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered;\n\t\t\t\tvar mix = current.alpha;\n\t\t\t\tif (current.mixingFrom != null)\n\t\t\t\t\tmix *= this.applyMixingFrom(current, skeleton, currentPose);\n\t\t\t\telse if (current.trackTime >= current.trackEnd && current.next == null)\n\t\t\t\t\tmix = 0;\n\t\t\t\tvar animationLast = current.animationLast, animationTime = current.getAnimationTime();\n\t\t\t\tvar timelineCount = current.animation.timelines.length;\n\t\t\t\tvar timelines = current.animation.timelines;\n\t\t\t\tif (mix == 1) {\n\t\t\t\t\tfor (var ii = 0; ii < timelineCount; ii++)\n\t\t\t\t\t\ttimelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection[\"in\"]);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tvar timelineData = current.timelineData;\n\t\t\t\t\tvar firstFrame = current.timelinesRotation.length == 0;\n\t\t\t\t\tif (firstFrame)\n\t\t\t\t\t\tspine.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null);\n\t\t\t\t\tvar timelinesRotation = current.timelinesRotation;\n\t\t\t\t\tfor (var ii = 0; ii < timelineCount; ii++) {\n\t\t\t\t\t\tvar timeline = timelines[ii];\n\t\t\t\t\t\tvar pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose;\n\t\t\t\t\t\tif (timeline instanceof spine.RotateTimeline) {\n\t\t\t\t\t\t\tthis.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tspine.Utils.webkit602BugfixHelper(mix, pose);\n\t\t\t\t\t\t\ttimeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection[\"in\"]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.queueEvents(current, animationTime);\n\t\t\t\tevents.length = 0;\n\t\t\t\tcurrent.nextAnimationLast = animationTime;\n\t\t\t\tcurrent.nextTrackLast = current.trackTime;\n\t\t\t}\n\t\t\tthis.queue.drain();\n\t\t\treturn applied;\n\t\t};\n\t\tAnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) {\n\t\t\tvar from = to.mixingFrom;\n\t\t\tif (from.mixingFrom != null)\n\t\t\t\tthis.applyMixingFrom(from, skeleton, currentPose);\n\t\t\tvar mix = 0;\n\t\t\tif (to.mixDuration == 0) {\n\t\t\t\tmix = 1;\n\t\t\t\tcurrentPose = spine.MixPose.setup;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmix = to.mixTime / to.mixDuration;\n\t\t\t\tif (mix > 1)\n\t\t\t\t\tmix = 1;\n\t\t\t}\n\t\t\tvar events = mix < from.eventThreshold ? this.events : null;\n\t\t\tvar attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold;\n\t\t\tvar animationLast = from.animationLast, animationTime = from.getAnimationTime();\n\t\t\tvar timelineCount = from.animation.timelines.length;\n\t\t\tvar timelines = from.animation.timelines;\n\t\t\tvar timelineData = from.timelineData;\n\t\t\tvar timelineDipMix = from.timelineDipMix;\n\t\t\tvar firstFrame = from.timelinesRotation.length == 0;\n\t\t\tif (firstFrame)\n\t\t\t\tspine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);\n\t\t\tvar timelinesRotation = from.timelinesRotation;\n\t\t\tvar pose;\n\t\t\tvar alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0;\n\t\t\tfrom.totalAlpha = 0;\n\t\t\tfor (var i = 0; i < timelineCount; i++) {\n\t\t\t\tvar timeline = timelines[i];\n\t\t\t\tswitch (timelineData[i]) {\n\t\t\t\t\tcase AnimationState.SUBSEQUENT:\n\t\t\t\t\t\tif (!attachments && timeline instanceof spine.AttachmentTimeline)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif (!drawOrder && timeline instanceof spine.DrawOrderTimeline)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tpose = currentPose;\n\t\t\t\t\t\talpha = alphaMix;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase AnimationState.FIRST:\n\t\t\t\t\t\tpose = spine.MixPose.setup;\n\t\t\t\t\t\talpha = alphaMix;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase AnimationState.DIP:\n\t\t\t\t\t\tpose = spine.MixPose.setup;\n\t\t\t\t\t\talpha = alphaDip;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tpose = spine.MixPose.setup;\n\t\t\t\t\t\talpha = alphaDip;\n\t\t\t\t\t\tvar dipMix = timelineDipMix[i];\n\t\t\t\t\t\talpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tfrom.totalAlpha += alpha;\n\t\t\t\tif (timeline instanceof spine.RotateTimeline)\n\t\t\t\t\tthis.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame);\n\t\t\t\telse {\n\t\t\t\t\tspine.Utils.webkit602BugfixHelper(alpha, pose);\n\t\t\t\t\ttimeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (to.mixDuration > 0)\n\t\t\t\tthis.queueEvents(from, animationTime);\n\t\t\tthis.events.length = 0;\n\t\t\tfrom.nextAnimationLast = animationTime;\n\t\t\tfrom.nextTrackLast = from.trackTime;\n\t\t\treturn mix;\n\t\t};\n\t\tAnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) {\n\t\t\tif (firstFrame)\n\t\t\t\ttimelinesRotation[i] = 0;\n\t\t\tif (alpha == 1) {\n\t\t\t\ttimeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection[\"in\"]);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar rotateTimeline = timeline;\n\t\t\tvar frames = rotateTimeline.frames;\n\t\t\tvar bone = skeleton.bones[rotateTimeline.boneIndex];\n\t\t\tif (time < frames[0]) {\n\t\t\t\tif (pose == spine.MixPose.setup)\n\t\t\t\t\tbone.rotation = bone.data.rotation;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar r2 = 0;\n\t\t\tif (time >= frames[frames.length - spine.RotateTimeline.ENTRIES])\n\t\t\t\tr2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION];\n\t\t\telse {\n\t\t\t\tvar frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES);\n\t\t\t\tvar prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION];\n\t\t\t\tvar frameTime = frames[frame];\n\t\t\t\tvar percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime));\n\t\t\t\tr2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation;\n\t\t\t\tr2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;\n\t\t\t\tr2 = prevRotation + r2 * percent + bone.data.rotation;\n\t\t\t\tr2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360;\n\t\t\t}\n\t\t\tvar r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation;\n\t\t\tvar total = 0, diff = r2 - r1;\n\t\t\tif (diff == 0) {\n\t\t\t\ttotal = timelinesRotation[i];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdiff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360;\n\t\t\t\tvar lastTotal = 0, lastDiff = 0;\n\t\t\t\tif (firstFrame) {\n\t\t\t\t\tlastTotal = 0;\n\t\t\t\t\tlastDiff = diff;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlastTotal = timelinesRotation[i];\n\t\t\t\t\tlastDiff = timelinesRotation[i + 1];\n\t\t\t\t}\n\t\t\t\tvar current = diff > 0, dir = lastTotal >= 0;\n\t\t\t\tif (spine.MathUtils.signum(lastDiff) != spine.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) {\n\t\t\t\t\tif (Math.abs(lastTotal) > 180)\n\t\t\t\t\t\tlastTotal += 360 * spine.MathUtils.signum(lastTotal);\n\t\t\t\t\tdir = current;\n\t\t\t\t}\n\t\t\t\ttotal = diff + lastTotal - lastTotal % 360;\n\t\t\t\tif (dir != current)\n\t\t\t\t\ttotal += 360 * spine.MathUtils.signum(lastTotal);\n\t\t\t\ttimelinesRotation[i] = total;\n\t\t\t}\n\t\t\ttimelinesRotation[i + 1] = diff;\n\t\t\tr1 += total * alpha;\n\t\t\tbone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360;\n\t\t};\n\t\tAnimationState.prototype.queueEvents = function (entry, animationTime) {\n\t\t\tvar animationStart = entry.animationStart, animationEnd = entry.animationEnd;\n\t\t\tvar duration = animationEnd - animationStart;\n\t\t\tvar trackLastWrapped = entry.trackLast % duration;\n\t\t\tvar events = this.events;\n\t\t\tvar i = 0, n = events.length;\n\t\t\tfor (; i < n; i++) {\n\t\t\t\tvar event_1 = events[i];\n\t\t\t\tif (event_1.time < trackLastWrapped)\n\t\t\t\t\tbreak;\n\t\t\t\tif (event_1.time > animationEnd)\n\t\t\t\t\tcontinue;\n\t\t\t\tthis.queue.event(entry, event_1);\n\t\t\t}\n\t\t\tvar complete = false;\n\t\t\tif (entry.loop)\n\t\t\t\tcomplete = duration == 0 || trackLastWrapped > entry.trackTime % duration;\n\t\t\telse\n\t\t\t\tcomplete = animationTime >= animationEnd && entry.animationLast < animationEnd;\n\t\t\tif (complete)\n\t\t\t\tthis.queue.complete(entry);\n\t\t\tfor (; i < n; i++) {\n\t\t\t\tvar event_2 = events[i];\n\t\t\t\tif (event_2.time < animationStart)\n\t\t\t\t\tcontinue;\n\t\t\t\tthis.queue.event(entry, events[i]);\n\t\t\t}\n\t\t};\n\t\tAnimationState.prototype.clearTracks = function () {\n\t\t\tvar oldDrainDisabled = this.queue.drainDisabled;\n\t\t\tthis.queue.drainDisabled = true;\n\t\t\tfor (var i = 0, n = this.tracks.length; i < n; i++)\n\t\t\t\tthis.clearTrack(i);\n\t\t\tthis.tracks.length = 0;\n\t\t\tthis.queue.drainDisabled = oldDrainDisabled;\n\t\t\tthis.queue.drain();\n\t\t};\n\t\tAnimationState.prototype.clearTrack = function (trackIndex) {\n\t\t\tif (trackIndex >= this.tracks.length)\n\t\t\t\treturn;\n\t\t\tvar current = this.tracks[trackIndex];\n\t\t\tif (current == null)\n\t\t\t\treturn;\n\t\t\tthis.queue.end(current);\n\t\t\tthis.disposeNext(current);\n\t\t\tvar entry = current;\n\t\t\twhile (true) {\n\t\t\t\tvar from = entry.mixingFrom;\n\t\t\t\tif (from == null)\n\t\t\t\t\tbreak;\n\t\t\t\tthis.queue.end(from);\n\t\t\t\tentry.mixingFrom = null;\n\t\t\t\tentry = from;\n\t\t\t}\n\t\t\tthis.tracks[current.trackIndex] = null;\n\t\t\tthis.queue.drain();\n\t\t};\n\t\tAnimationState.prototype.setCurrent = function (index, current, interrupt) {\n\t\t\tvar from = this.expandToIndex(index);\n\t\t\tthis.tracks[index] = current;\n\t\t\tif (from != null) {\n\t\t\t\tif (interrupt)\n\t\t\t\t\tthis.queue.interrupt(from);\n\t\t\t\tcurrent.mixingFrom = from;\n\t\t\t\tcurrent.mixTime = 0;\n\t\t\t\tif (from.mixingFrom != null && from.mixDuration > 0)\n\t\t\t\t\tcurrent.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration);\n\t\t\t\tfrom.timelinesRotation.length = 0;\n\t\t\t}\n\t\t\tthis.queue.start(current);\n\t\t};\n\t\tAnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) {\n\t\t\tvar animation = this.data.skeletonData.findAnimation(animationName);\n\t\t\tif (animation == null)\n\t\t\t\tthrow new Error(\"Animation not found: \" + animationName);\n\t\t\treturn this.setAnimationWith(trackIndex, animation, loop);\n\t\t};\n\t\tAnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) {\n\t\t\tif (animation == null)\n\t\t\t\tthrow new Error(\"animation cannot be null.\");\n\t\t\tvar interrupt = true;\n\t\t\tvar current = this.expandToIndex(trackIndex);\n\t\t\tif (current != null) {\n\t\t\t\tif (current.nextTrackLast == -1) {\n\t\t\t\t\tthis.tracks[trackIndex] = current.mixingFrom;\n\t\t\t\t\tthis.queue.interrupt(current);\n\t\t\t\t\tthis.queue.end(current);\n\t\t\t\t\tthis.disposeNext(current);\n\t\t\t\t\tcurrent = current.mixingFrom;\n\t\t\t\t\tinterrupt = false;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tthis.disposeNext(current);\n\t\t\t}\n\t\t\tvar entry = this.trackEntry(trackIndex, animation, loop, current);\n\t\t\tthis.setCurrent(trackIndex, entry, interrupt);\n\t\t\tthis.queue.drain();\n\t\t\treturn entry;\n\t\t};\n\t\tAnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) {\n\t\t\tvar animation = this.data.skeletonData.findAnimation(animationName);\n\t\t\tif (animation == null)\n\t\t\t\tthrow new Error(\"Animation not found: \" + animationName);\n\t\t\treturn this.addAnimationWith(trackIndex, animation, loop, delay);\n\t\t};\n\t\tAnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) {\n\t\t\tif (animation == null)\n\t\t\t\tthrow new Error(\"animation cannot be null.\");\n\t\t\tvar last = this.expandToIndex(trackIndex);\n\t\t\tif (last != null) {\n\t\t\t\twhile (last.next != null)\n\t\t\t\t\tlast = last.next;\n\t\t\t}\n\t\t\tvar entry = this.trackEntry(trackIndex, animation, loop, last);\n\t\t\tif (last == null) {\n\t\t\t\tthis.setCurrent(trackIndex, entry, true);\n\t\t\t\tthis.queue.drain();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlast.next = entry;\n\t\t\t\tif (delay <= 0) {\n\t\t\t\t\tvar duration = last.animationEnd - last.animationStart;\n\t\t\t\t\tif (duration != 0) {\n\t\t\t\t\t\tif (last.loop)\n\t\t\t\t\t\t\tdelay += duration * (1 + ((last.trackTime / duration) | 0));\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdelay += duration;\n\t\t\t\t\t\tdelay -= this.data.getMix(last.animation, animation);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tdelay = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tentry.delay = delay;\n\t\t\treturn entry;\n\t\t};\n\t\tAnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) {\n\t\t\tvar entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false);\n\t\t\tentry.mixDuration = mixDuration;\n\t\t\tentry.trackEnd = mixDuration;\n\t\t\treturn entry;\n\t\t};\n\t\tAnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) {\n\t\t\tif (delay <= 0)\n\t\t\t\tdelay -= mixDuration;\n\t\t\tvar entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay);\n\t\t\tentry.mixDuration = mixDuration;\n\t\t\tentry.trackEnd = mixDuration;\n\t\t\treturn entry;\n\t\t};\n\t\tAnimationState.prototype.setEmptyAnimations = function (mixDuration) {\n\t\t\tvar oldDrainDisabled = this.queue.drainDisabled;\n\t\t\tthis.queue.drainDisabled = true;\n\t\t\tfor (var i = 0, n = this.tracks.length; i < n; i++) {\n\t\t\t\tvar current = this.tracks[i];\n\t\t\t\tif (current != null)\n\t\t\t\t\tthis.setEmptyAnimation(current.trackIndex, mixDuration);\n\t\t\t}\n\t\t\tthis.queue.drainDisabled = oldDrainDisabled;\n\t\t\tthis.queue.drain();\n\t\t};\n\t\tAnimationState.prototype.expandToIndex = function (index) {\n\t\t\tif (index < this.tracks.length)\n\t\t\t\treturn this.tracks[index];\n\t\t\tspine.Utils.ensureArrayCapacity(this.tracks, index - this.tracks.length + 1, null);\n\t\t\tthis.tracks.length = index + 1;\n\t\t\treturn null;\n\t\t};\n\t\tAnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) {\n\t\t\tvar entry = this.trackEntryPool.obtain();\n\t\t\tentry.trackIndex = trackIndex;\n\t\t\tentry.animation = animation;\n\t\t\tentry.loop = loop;\n\t\t\tentry.eventThreshold = 0;\n\t\t\tentry.attachmentThreshold = 0;\n\t\t\tentry.drawOrderThreshold = 0;\n\t\t\tentry.animationStart = 0;\n\t\t\tentry.animationEnd = animation.duration;\n\t\t\tentry.animationLast = -1;\n\t\t\tentry.nextAnimationLast = -1;\n\t\t\tentry.delay = 0;\n\t\t\tentry.trackTime = 0;\n\t\t\tentry.trackLast = -1;\n\t\t\tentry.nextTrackLast = -1;\n\t\t\tentry.trackEnd = Number.MAX_VALUE;\n\t\t\tentry.timeScale = 1;\n\t\t\tentry.alpha = 1;\n\t\t\tentry.interruptAlpha = 1;\n\t\t\tentry.mixTime = 0;\n\t\t\tentry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation);\n\t\t\treturn entry;\n\t\t};\n\t\tAnimationState.prototype.disposeNext = function (entry) {\n\t\t\tvar next = entry.next;\n\t\t\twhile (next != null) {\n\t\t\t\tthis.queue.dispose(next);\n\t\t\t\tnext = next.next;\n\t\t\t}\n\t\t\tentry.next = null;\n\t\t};\n\t\tAnimationState.prototype._animationsChanged = function () {\n\t\t\tthis.animationsChanged = false;\n\t\t\tvar propertyIDs = this.propertyIDs;\n\t\t\tpropertyIDs.clear();\n\t\t\tvar mixingTo = this.mixingTo;\n\t\t\tfor (var i = 0, n = this.tracks.length; i < n; i++) {\n\t\t\t\tvar entry = this.tracks[i];\n\t\t\t\tif (entry != null)\n\t\t\t\t\tentry.setTimelineData(null, mixingTo, propertyIDs);\n\t\t\t}\n\t\t};\n\t\tAnimationState.prototype.getCurrent = function (trackIndex) {\n\t\t\tif (trackIndex >= this.tracks.length)\n\t\t\t\treturn null;\n\t\t\treturn this.tracks[trackIndex];\n\t\t};\n\t\tAnimationState.prototype.addListener = function (listener) {\n\t\t\tif (listener == null)\n\t\t\t\tthrow new Error(\"listener cannot be null.\");\n\t\t\tthis.listeners.push(listener);\n\t\t};\n\t\tAnimationState.prototype.removeListener = function (listener) {\n\t\t\tvar index = this.listeners.indexOf(listener);\n\t\t\tif (index >= 0)\n\t\t\t\tthis.listeners.splice(index, 1);\n\t\t};\n\t\tAnimationState.prototype.clearListeners = function () {\n\t\t\tthis.listeners.length = 0;\n\t\t};\n\t\tAnimationState.prototype.clearListenerNotifications = function () {\n\t\t\tthis.queue.clear();\n\t\t};\n\t\tAnimationState.emptyAnimation = new spine.Animation(\"\", [], 0);\n\t\tAnimationState.SUBSEQUENT = 0;\n\t\tAnimationState.FIRST = 1;\n\t\tAnimationState.DIP = 2;\n\t\tAnimationState.DIP_MIX = 3;\n\t\treturn AnimationState;\n\t}());\n\tspine.AnimationState = AnimationState;\n\tvar TrackEntry = (function () {\n\t\tfunction TrackEntry() {\n\t\t\tthis.timelineData = new Array();\n\t\t\tthis.timelineDipMix = new Array();\n\t\t\tthis.timelinesRotation = new Array();\n\t\t}\n\t\tTrackEntry.prototype.reset = function () {\n\t\t\tthis.next = null;\n\t\t\tthis.mixingFrom = null;\n\t\t\tthis.animation = null;\n\t\t\tthis.listener = null;\n\t\t\tthis.timelineData.length = 0;\n\t\t\tthis.timelineDipMix.length = 0;\n\t\t\tthis.timelinesRotation.length = 0;\n\t\t};\n\t\tTrackEntry.prototype.setTimelineData = function (to, mixingToArray, propertyIDs) {\n\t\t\tif (to != null)\n\t\t\t\tmixingToArray.push(to);\n\t\t\tvar lastEntry = this.mixingFrom != null ? this.mixingFrom.setTimelineData(this, mixingToArray, propertyIDs) : this;\n\t\t\tif (to != null)\n\t\t\t\tmixingToArray.pop();\n\t\t\tvar mixingTo = mixingToArray;\n\t\t\tvar mixingToLast = mixingToArray.length - 1;\n\t\t\tvar timelines = this.animation.timelines;\n\t\t\tvar timelinesCount = this.animation.timelines.length;\n\t\t\tvar timelineData = spine.Utils.setArraySize(this.timelineData, timelinesCount);\n\t\t\tthis.timelineDipMix.length = 0;\n\t\t\tvar timelineDipMix = spine.Utils.setArraySize(this.timelineDipMix, timelinesCount);\n\t\t\touter: for (var i = 0; i < timelinesCount; i++) {\n\t\t\t\tvar id = timelines[i].getPropertyId();\n\t\t\t\tif (!propertyIDs.add(id))\n\t\t\t\t\ttimelineData[i] = AnimationState.SUBSEQUENT;\n\t\t\t\telse if (to == null || !to.hasTimeline(id))\n\t\t\t\t\ttimelineData[i] = AnimationState.FIRST;\n\t\t\t\telse {\n\t\t\t\t\tfor (var ii = mixingToLast; ii >= 0; ii--) {\n\t\t\t\t\t\tvar entry = mixingTo[ii];\n\t\t\t\t\t\tif (!entry.hasTimeline(id)) {\n\t\t\t\t\t\t\tif (entry.mixDuration > 0) {\n\t\t\t\t\t\t\t\ttimelineData[i] = AnimationState.DIP_MIX;\n\t\t\t\t\t\t\t\ttimelineDipMix[i] = entry;\n\t\t\t\t\t\t\t\tcontinue outer;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttimelineData[i] = AnimationState.DIP;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn lastEntry;\n\t\t};\n\t\tTrackEntry.prototype.hasTimeline = function (id) {\n\t\t\tvar timelines = this.animation.timelines;\n\t\t\tfor (var i = 0, n = timelines.length; i < n; i++)\n\t\t\t\tif (timelines[i].getPropertyId() == id)\n\t\t\t\t\treturn true;\n\t\t\treturn false;\n\t\t};\n\t\tTrackEntry.prototype.getAnimationTime = function () {\n\t\t\tif (this.loop) {\n\t\t\t\tvar duration = this.animationEnd - this.animationStart;\n\t\t\t\tif (duration == 0)\n\t\t\t\t\treturn this.animationStart;\n\t\t\t\treturn (this.trackTime % duration) + this.animationStart;\n\t\t\t}\n\t\t\treturn Math.min(this.trackTime + this.animationStart, this.animationEnd);\n\t\t};\n\t\tTrackEntry.prototype.setAnimationLast = function (animationLast) {\n\t\t\tthis.animationLast = animationLast;\n\t\t\tthis.nextAnimationLast = animationLast;\n\t\t};\n\t\tTrackEntry.prototype.isComplete = function () {\n\t\t\treturn this.trackTime >= this.animationEnd - this.animationStart;\n\t\t};\n\t\tTrackEntry.prototype.resetRotationDirections = function () {\n\t\t\tthis.timelinesRotation.length = 0;\n\t\t};\n\t\treturn TrackEntry;\n\t}());\n\tspine.TrackEntry = TrackEntry;\n\tvar EventQueue = (function () {\n\t\tfunction EventQueue(animState) {\n\t\t\tthis.objects = [];\n\t\t\tthis.drainDisabled = false;\n\t\t\tthis.animState = animState;\n\t\t}\n\t\tEventQueue.prototype.start = function (entry) {\n\t\t\tthis.objects.push(EventType.start);\n\t\t\tthis.objects.push(entry);\n\t\t\tthis.animState.animationsChanged = true;\n\t\t};\n\t\tEventQueue.prototype.interrupt = function (entry) {\n\t\t\tthis.objects.push(EventType.interrupt);\n\t\t\tthis.objects.push(entry);\n\t\t};\n\t\tEventQueue.prototype.end = function (entry) {\n\t\t\tthis.objects.push(EventType.end);\n\t\t\tthis.objects.push(entry);\n\t\t\tthis.animState.animationsChanged = true;\n\t\t};\n\t\tEventQueue.prototype.dispose = function (entry) {\n\t\t\tthis.objects.push(EventType.dispose);\n\t\t\tthis.objects.push(entry);\n\t\t};\n\t\tEventQueue.prototype.complete = function (entry) {\n\t\t\tthis.objects.push(EventType.complete);\n\t\t\tthis.objects.push(entry);\n\t\t};\n\t\tEventQueue.prototype.event = function (entry, event) {\n\t\t\tthis.objects.push(EventType.event);\n\t\t\tthis.objects.push(entry);\n\t\t\tthis.objects.push(event);\n\t\t};\n\t\tEventQueue.prototype.drain = function () {\n\t\t\tif (this.drainDisabled)\n\t\t\t\treturn;\n\t\t\tthis.drainDisabled = true;\n\t\t\tvar objects = this.objects;\n\t\t\tvar listeners = this.animState.listeners;\n\t\t\tfor (var i = 0; i < objects.length; i += 2) {\n\t\t\t\tvar type = objects[i];\n\t\t\t\tvar entry = objects[i + 1];\n\t\t\t\tswitch (type) {\n\t\t\t\t\tcase EventType.start:\n\t\t\t\t\t\tif (entry.listener != null && entry.listener.start)\n\t\t\t\t\t\t\tentry.listener.start(entry);\n\t\t\t\t\t\tfor (var ii = 0; ii < listeners.length; ii++)\n\t\t\t\t\t\t\tif (listeners[ii].start)\n\t\t\t\t\t\t\t\tlisteners[ii].start(entry);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase EventType.interrupt:\n\t\t\t\t\t\tif (entry.listener != null && entry.listener.interrupt)\n\t\t\t\t\t\t\tentry.listener.interrupt(entry);\n\t\t\t\t\t\tfor (var ii = 0; ii < listeners.length; ii++)\n\t\t\t\t\t\t\tif (listeners[ii].interrupt)\n\t\t\t\t\t\t\t\tlisteners[ii].interrupt(entry);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase EventType.end:\n\t\t\t\t\t\tif (entry.listener != null && entry.listener.end)\n\t\t\t\t\t\t\tentry.listener.end(entry);\n\t\t\t\t\t\tfor (var ii = 0; ii < listeners.length; ii++)\n\t\t\t\t\t\t\tif (listeners[ii].end)\n\t\t\t\t\t\t\t\tlisteners[ii].end(entry);\n\t\t\t\t\tcase EventType.dispose:\n\t\t\t\t\t\tif (entry.listener != null && entry.listener.dispose)\n\t\t\t\t\t\t\tentry.listener.dispose(entry);\n\t\t\t\t\t\tfor (var ii = 0; ii < listeners.length; ii++)\n\t\t\t\t\t\t\tif (listeners[ii].dispose)\n\t\t\t\t\t\t\t\tlisteners[ii].dispose(entry);\n\t\t\t\t\t\tthis.animState.trackEntryPool.free(entry);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase EventType.complete:\n\t\t\t\t\t\tif (entry.listener != null && entry.listener.complete)\n\t\t\t\t\t\t\tentry.listener.complete(entry);\n\t\t\t\t\t\tfor (var ii = 0; ii < listeners.length; ii++)\n\t\t\t\t\t\t\tif (listeners[ii].complete)\n\t\t\t\t\t\t\t\tlisteners[ii].complete(entry);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase EventType.event:\n\t\t\t\t\t\tvar event_3 = objects[i++ + 2];\n\t\t\t\t\t\tif (entry.listener != null && entry.listener.event)\n\t\t\t\t\t\t\tentry.listener.event(entry, event_3);\n\t\t\t\t\t\tfor (var ii = 0; ii < listeners.length; ii++)\n\t\t\t\t\t\t\tif (listeners[ii].event)\n\t\t\t\t\t\t\t\tlisteners[ii].event(entry, event_3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.clear();\n\t\t\tthis.drainDisabled = false;\n\t\t};\n\t\tEventQueue.prototype.clear = function () {\n\t\t\tthis.objects.length = 0;\n\t\t};\n\t\treturn EventQueue;\n\t}());\n\tspine.EventQueue = EventQueue;\n\tvar EventType;\n\t(function (EventType) {\n\t\tEventType[EventType[\"start\"] = 0] = \"start\";\n\t\tEventType[EventType[\"interrupt\"] = 1] = \"interrupt\";\n\t\tEventType[EventType[\"end\"] = 2] = \"end\";\n\t\tEventType[EventType[\"dispose\"] = 3] = \"dispose\";\n\t\tEventType[EventType[\"complete\"] = 4] = \"complete\";\n\t\tEventType[EventType[\"event\"] = 5] = \"event\";\n\t})(EventType = spine.EventType || (spine.EventType = {}));\n\tvar AnimationStateAdapter2 = (function () {\n\t\tfunction AnimationStateAdapter2() {\n\t\t}\n\t\tAnimationStateAdapter2.prototype.start = function (entry) {\n\t\t};\n\t\tAnimationStateAdapter2.prototype.interrupt = function (entry) {\n\t\t};\n\t\tAnimationStateAdapter2.prototype.end = function (entry) {\n\t\t};\n\t\tAnimationStateAdapter2.prototype.dispose = function (entry) {\n\t\t};\n\t\tAnimationStateAdapter2.prototype.complete = function (entry) {\n\t\t};\n\t\tAnimationStateAdapter2.prototype.event = function (entry, event) {\n\t\t};\n\t\treturn AnimationStateAdapter2;\n\t}());\n\tspine.AnimationStateAdapter2 = AnimationStateAdapter2;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar AnimationStateData = (function () {\n\t\tfunction AnimationStateData(skeletonData) {\n\t\t\tthis.animationToMixTime = {};\n\t\t\tthis.defaultMix = 0;\n\t\t\tif (skeletonData == null)\n\t\t\t\tthrow new Error(\"skeletonData cannot be null.\");\n\t\t\tthis.skeletonData = skeletonData;\n\t\t}\n\t\tAnimationStateData.prototype.setMix = function (fromName, toName, duration) {\n\t\t\tvar from = this.skeletonData.findAnimation(fromName);\n\t\t\tif (from == null)\n\t\t\t\tthrow new Error(\"Animation not found: \" + fromName);\n\t\t\tvar to = this.skeletonData.findAnimation(toName);\n\t\t\tif (to == null)\n\t\t\t\tthrow new Error(\"Animation not found: \" + toName);\n\t\t\tthis.setMixWith(from, to, duration);\n\t\t};\n\t\tAnimationStateData.prototype.setMixWith = function (from, to, duration) {\n\t\t\tif (from == null)\n\t\t\t\tthrow new Error(\"from cannot be null.\");\n\t\t\tif (to == null)\n\t\t\t\tthrow new Error(\"to cannot be null.\");\n\t\t\tvar key = from.name + \".\" + to.name;\n\t\t\tthis.animationToMixTime[key] = duration;\n\t\t};\n\t\tAnimationStateData.prototype.getMix = function (from, to) {\n\t\t\tvar key = from.name + \".\" + to.name;\n\t\t\tvar value = this.animationToMixTime[key];\n\t\t\treturn value === undefined ? this.defaultMix : value;\n\t\t};\n\t\treturn AnimationStateData;\n\t}());\n\tspine.AnimationStateData = AnimationStateData;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar AssetManager = (function () {\n\t\tfunction AssetManager(textureLoader, pathPrefix) {\n\t\t\tif (pathPrefix === void 0) { pathPrefix = \"\"; }\n\t\t\tthis.assets = {};\n\t\t\tthis.errors = {};\n\t\t\tthis.toLoad = 0;\n\t\t\tthis.loaded = 0;\n\t\t\tthis.textureLoader = textureLoader;\n\t\t\tthis.pathPrefix = pathPrefix;\n\t\t}\n\t\tAssetManager.downloadText = function (url, success, error) {\n\t\t\tvar request = new XMLHttpRequest();\n\t\t\trequest.open(\"GET\", url, true);\n\t\t\trequest.onload = function () {\n\t\t\t\tif (request.status == 200) {\n\t\t\t\t\tsuccess(request.responseText);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\terror(request.status, request.responseText);\n\t\t\t\t}\n\t\t\t};\n\t\t\trequest.onerror = function () {\n\t\t\t\terror(request.status, request.responseText);\n\t\t\t};\n\t\t\trequest.send();\n\t\t};\n\t\tAssetManager.downloadBinary = function (url, success, error) {\n\t\t\tvar request = new XMLHttpRequest();\n\t\t\trequest.open(\"GET\", url, true);\n\t\t\trequest.responseType = \"arraybuffer\";\n\t\t\trequest.onload = function () {\n\t\t\t\tif (request.status == 200) {\n\t\t\t\t\tsuccess(new Uint8Array(request.response));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\terror(request.status, request.responseText);\n\t\t\t\t}\n\t\t\t};\n\t\t\trequest.onerror = function () {\n\t\t\t\terror(request.status, request.responseText);\n\t\t\t};\n\t\t\trequest.send();\n\t\t};\n\t\tAssetManager.prototype.loadText = function (path, success, error) {\n\t\t\tvar _this = this;\n\t\t\tif (success === void 0) { success = null; }\n\t\t\tif (error === void 0) { error = null; }\n\t\t\tpath = this.pathPrefix + path;\n\t\t\tthis.toLoad++;\n\t\t\tAssetManager.downloadText(path, function (data) {\n\t\t\t\t_this.assets[path] = data;\n\t\t\t\tif (success)\n\t\t\t\t\tsuccess(path, data);\n\t\t\t\t_this.toLoad--;\n\t\t\t\t_this.loaded++;\n\t\t\t}, function (state, responseText) {\n\t\t\t\t_this.errors[path] = \"Couldn't load text \" + path + \": status \" + status + \", \" + responseText;\n\t\t\t\tif (error)\n\t\t\t\t\terror(path, \"Couldn't load text \" + path + \": status \" + status + \", \" + responseText);\n\t\t\t\t_this.toLoad--;\n\t\t\t\t_this.loaded++;\n\t\t\t});\n\t\t};\n\t\tAssetManager.prototype.loadTexture = function (path, success, error) {\n\t\t\tvar _this = this;\n\t\t\tif (success === void 0) { success = null; }\n\t\t\tif (error === void 0) { error = null; }\n\t\t\tpath = this.pathPrefix + path;\n\t\t\tthis.toLoad++;\n\t\t\tvar img = new Image();\n\t\t\timg.crossOrigin = \"anonymous\";\n\t\t\timg.onload = function (ev) {\n\t\t\t\tvar texture = _this.textureLoader(img);\n\t\t\t\t_this.assets[path] = texture;\n\t\t\t\t_this.toLoad--;\n\t\t\t\t_this.loaded++;\n\t\t\t\tif (success)\n\t\t\t\t\tsuccess(path, img);\n\t\t\t};\n\t\t\timg.onerror = function (ev) {\n\t\t\t\t_this.errors[path] = \"Couldn't load image \" + path;\n\t\t\t\t_this.toLoad--;\n\t\t\t\t_this.loaded++;\n\t\t\t\tif (error)\n\t\t\t\t\terror(path, \"Couldn't load image \" + path);\n\t\t\t};\n\t\t\timg.src = path;\n\t\t};\n\t\tAssetManager.prototype.loadTextureData = function (path, data, success, error) {\n\t\t\tvar _this = this;\n\t\t\tif (success === void 0) { success = null; }\n\t\t\tif (error === void 0) { error = null; }\n\t\t\tpath = this.pathPrefix + path;\n\t\t\tthis.toLoad++;\n\t\t\tvar img = new Image();\n\t\t\timg.onload = function (ev) {\n\t\t\t\tvar texture = _this.textureLoader(img);\n\t\t\t\t_this.assets[path] = texture;\n\t\t\t\t_this.toLoad--;\n\t\t\t\t_this.loaded++;\n\t\t\t\tif (success)\n\t\t\t\t\tsuccess(path, img);\n\t\t\t};\n\t\t\timg.onerror = function (ev) {\n\t\t\t\t_this.errors[path] = \"Couldn't load image \" + path;\n\t\t\t\t_this.toLoad--;\n\t\t\t\t_this.loaded++;\n\t\t\t\tif (error)\n\t\t\t\t\terror(path, \"Couldn't load image \" + path);\n\t\t\t};\n\t\t\timg.src = data;\n\t\t};\n\t\tAssetManager.prototype.loadTextureAtlas = function (path, success, error) {\n\t\t\tvar _this = this;\n\t\t\tif (success === void 0) { success = null; }\n\t\t\tif (error === void 0) { error = null; }\n\t\t\tvar parent = path.lastIndexOf(\"/\") >= 0 ? path.substring(0, path.lastIndexOf(\"/\")) : \"\";\n\t\t\tpath = this.pathPrefix + path;\n\t\t\tthis.toLoad++;\n\t\t\tAssetManager.downloadText(path, function (atlasData) {\n\t\t\t\tvar pagesLoaded = { count: 0 };\n\t\t\t\tvar atlasPages = new Array();\n\t\t\t\ttry {\n\t\t\t\t\tvar atlas = new spine.TextureAtlas(atlasData, function (path) {\n\t\t\t\t\t\tatlasPages.push(parent + \"/\" + path);\n\t\t\t\t\t\tvar image = document.createElement(\"img\");\n\t\t\t\t\t\timage.width = 16;\n\t\t\t\t\t\timage.height = 16;\n\t\t\t\t\t\treturn new spine.FakeTexture(image);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tvar ex = e;\n\t\t\t\t\t_this.errors[path] = \"Couldn't load texture atlas \" + path + \": \" + ex.message;\n\t\t\t\t\tif (error)\n\t\t\t\t\t\terror(path, \"Couldn't load texture atlas \" + path + \": \" + ex.message);\n\t\t\t\t\t_this.toLoad--;\n\t\t\t\t\t_this.loaded++;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tvar _loop_1 = function (atlasPage) {\n\t\t\t\t\tvar pageLoadError = false;\n\t\t\t\t\t_this.loadTexture(atlasPage, function (imagePath, image) {\n\t\t\t\t\t\tpagesLoaded.count++;\n\t\t\t\t\t\tif (pagesLoaded.count == atlasPages.length) {\n\t\t\t\t\t\t\tif (!pageLoadError) {\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tvar atlas = new spine.TextureAtlas(atlasData, function (path) {\n\t\t\t\t\t\t\t\t\t\treturn _this.get(parent + \"/\" + path);\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t_this.assets[path] = atlas;\n\t\t\t\t\t\t\t\t\tif (success)\n\t\t\t\t\t\t\t\t\t\tsuccess(path, atlas);\n\t\t\t\t\t\t\t\t\t_this.toLoad--;\n\t\t\t\t\t\t\t\t\t_this.loaded++;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\t\t\tvar ex = e;\n\t\t\t\t\t\t\t\t\t_this.errors[path] = \"Couldn't load texture atlas \" + path + \": \" + ex.message;\n\t\t\t\t\t\t\t\t\tif (error)\n\t\t\t\t\t\t\t\t\t\terror(path, \"Couldn't load texture atlas \" + path + \": \" + ex.message);\n\t\t\t\t\t\t\t\t\t_this.toLoad--;\n\t\t\t\t\t\t\t\t\t_this.loaded++;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t_this.errors[path] = \"Couldn't load texture atlas page \" + imagePath + \"} of atlas \" + path;\n\t\t\t\t\t\t\t\tif (error)\n\t\t\t\t\t\t\t\t\terror(path, \"Couldn't load texture atlas page \" + imagePath + \" of atlas \" + path);\n\t\t\t\t\t\t\t\t_this.toLoad--;\n\t\t\t\t\t\t\t\t_this.loaded++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}, function (imagePath, errorMessage) {\n\t\t\t\t\t\tpageLoadError = true;\n\t\t\t\t\t\tpagesLoaded.count++;\n\t\t\t\t\t\tif (pagesLoaded.count == atlasPages.length) {\n\t\t\t\t\t\t\t_this.errors[path] = \"Couldn't load texture atlas page \" + imagePath + \"} of atlas \" + path;\n\t\t\t\t\t\t\tif (error)\n\t\t\t\t\t\t\t\terror(path, \"Couldn't load texture atlas page \" + imagePath + \" of atlas \" + path);\n\t\t\t\t\t\t\t_this.toLoad--;\n\t\t\t\t\t\t\t_this.loaded++;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t};\n\t\t\t\tfor (var _i = 0, atlasPages_1 = atlasPages; _i < atlasPages_1.length; _i++) {\n\t\t\t\t\tvar atlasPage = atlasPages_1[_i];\n\t\t\t\t\t_loop_1(atlasPage);\n\t\t\t\t}\n\t\t\t}, function (state, responseText) {\n\t\t\t\t_this.errors[path] = \"Couldn't load texture atlas \" + path + \": status \" + status + \", \" + responseText;\n\t\t\t\tif (error)\n\t\t\t\t\terror(path, \"Couldn't load texture atlas \" + path + \": status \" + status + \", \" + responseText);\n\t\t\t\t_this.toLoad--;\n\t\t\t\t_this.loaded++;\n\t\t\t});\n\t\t};\n\t\tAssetManager.prototype.get = function (path) {\n\t\t\tpath = this.pathPrefix + path;\n\t\t\treturn this.assets[path];\n\t\t};\n\t\tAssetManager.prototype.remove = function (path) {\n\t\t\tpath = this.pathPrefix + path;\n\t\t\tvar asset = this.assets[path];\n\t\t\tif (asset.dispose)\n\t\t\t\tasset.dispose();\n\t\t\tthis.assets[path] = null;\n\t\t};\n\t\tAssetManager.prototype.removeAll = function () {\n\t\t\tfor (var key in this.assets) {\n\t\t\t\tvar asset = this.assets[key];\n\t\t\t\tif (asset.dispose)\n\t\t\t\t\tasset.dispose();\n\t\t\t}\n\t\t\tthis.assets = {};\n\t\t};\n\t\tAssetManager.prototype.isLoadingComplete = function () {\n\t\t\treturn this.toLoad == 0;\n\t\t};\n\t\tAssetManager.prototype.getToLoad = function () {\n\t\t\treturn this.toLoad;\n\t\t};\n\t\tAssetManager.prototype.getLoaded = function () {\n\t\t\treturn this.loaded;\n\t\t};\n\t\tAssetManager.prototype.dispose = function () {\n\t\t\tthis.removeAll();\n\t\t};\n\t\tAssetManager.prototype.hasErrors = function () {\n\t\t\treturn Object.keys(this.errors).length > 0;\n\t\t};\n\t\tAssetManager.prototype.getErrors = function () {\n\t\t\treturn this.errors;\n\t\t};\n\t\treturn AssetManager;\n\t}());\n\tspine.AssetManager = AssetManager;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar AtlasAttachmentLoader = (function () {\n\t\tfunction AtlasAttachmentLoader(atlas) {\n\t\t\tthis.atlas = atlas;\n\t\t}\n\t\tAtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) {\n\t\t\tvar region = this.atlas.findRegion(path);\n\t\t\tif (region == null)\n\t\t\t\tthrow new Error(\"Region not found in atlas: \" + path + \" (region attachment: \" + name + \")\");\n\t\t\tregion.renderObject = region;\n\t\t\tvar attachment = new spine.RegionAttachment(name);\n\t\t\tattachment.setRegion(region);\n\t\t\treturn attachment;\n\t\t};\n\t\tAtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) {\n\t\t\tvar region = this.atlas.findRegion(path);\n\t\t\tif (region == null)\n\t\t\t\tthrow new Error(\"Region not found in atlas: \" + path + \" (mesh attachment: \" + name + \")\");\n\t\t\tregion.renderObject = region;\n\t\t\tvar attachment = new spine.MeshAttachment(name);\n\t\t\tattachment.region = region;\n\t\t\treturn attachment;\n\t\t};\n\t\tAtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) {\n\t\t\treturn new spine.BoundingBoxAttachment(name);\n\t\t};\n\t\tAtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) {\n\t\t\treturn new spine.PathAttachment(name);\n\t\t};\n\t\tAtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) {\n\t\t\treturn new spine.PointAttachment(name);\n\t\t};\n\t\tAtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) {\n\t\t\treturn new spine.ClippingAttachment(name);\n\t\t};\n\t\treturn AtlasAttachmentLoader;\n\t}());\n\tspine.AtlasAttachmentLoader = AtlasAttachmentLoader;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar BlendMode;\n\t(function (BlendMode) {\n\t\tBlendMode[BlendMode[\"Normal\"] = 0] = \"Normal\";\n\t\tBlendMode[BlendMode[\"Additive\"] = 1] = \"Additive\";\n\t\tBlendMode[BlendMode[\"Multiply\"] = 2] = \"Multiply\";\n\t\tBlendMode[BlendMode[\"Screen\"] = 3] = \"Screen\";\n\t})(BlendMode = spine.BlendMode || (spine.BlendMode = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar Bone = (function () {\n\t\tfunction Bone(data, skeleton, parent) {\n\t\t\tthis.children = new Array();\n\t\t\tthis.x = 0;\n\t\t\tthis.y = 0;\n\t\t\tthis.rotation = 0;\n\t\t\tthis.scaleX = 0;\n\t\t\tthis.scaleY = 0;\n\t\t\tthis.shearX = 0;\n\t\t\tthis.shearY = 0;\n\t\t\tthis.ax = 0;\n\t\t\tthis.ay = 0;\n\t\t\tthis.arotation = 0;\n\t\t\tthis.ascaleX = 0;\n\t\t\tthis.ascaleY = 0;\n\t\t\tthis.ashearX = 0;\n\t\t\tthis.ashearY = 0;\n\t\t\tthis.appliedValid = false;\n\t\t\tthis.a = 0;\n\t\t\tthis.b = 0;\n\t\t\tthis.worldX = 0;\n\t\t\tthis.c = 0;\n\t\t\tthis.d = 0;\n\t\t\tthis.worldY = 0;\n\t\t\tthis.sorted = false;\n\t\t\tif (data == null)\n\t\t\t\tthrow new Error(\"data cannot be null.\");\n\t\t\tif (skeleton == null)\n\t\t\t\tthrow new Error(\"skeleton cannot be null.\");\n\t\t\tthis.data = data;\n\t\t\tthis.skeleton = skeleton;\n\t\t\tthis.parent = parent;\n\t\t\tthis.setToSetupPose();\n\t\t}\n\t\tBone.prototype.update = function () {\n\t\t\tthis.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);\n\t\t};\n\t\tBone.prototype.updateWorldTransform = function () {\n\t\t\tthis.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY);\n\t\t};\n\t\tBone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) {\n\t\t\tthis.ax = x;\n\t\t\tthis.ay = y;\n\t\t\tthis.arotation = rotation;\n\t\t\tthis.ascaleX = scaleX;\n\t\t\tthis.ascaleY = scaleY;\n\t\t\tthis.ashearX = shearX;\n\t\t\tthis.ashearY = shearY;\n\t\t\tthis.appliedValid = true;\n\t\t\tvar parent = this.parent;\n\t\t\tif (parent == null) {\n\t\t\t\tvar rotationY = rotation + 90 + shearY;\n\t\t\t\tvar la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX;\n\t\t\t\tvar lb = spine.MathUtils.cosDeg(rotationY) * scaleY;\n\t\t\t\tvar lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX;\n\t\t\t\tvar ld = spine.MathUtils.sinDeg(rotationY) * scaleY;\n\t\t\t\tvar skeleton = this.skeleton;\n\t\t\t\tif (skeleton.flipX) {\n\t\t\t\t\tx = -x;\n\t\t\t\t\tla = -la;\n\t\t\t\t\tlb = -lb;\n\t\t\t\t}\n\t\t\t\tif (skeleton.flipY) {\n\t\t\t\t\ty = -y;\n\t\t\t\t\tlc = -lc;\n\t\t\t\t\tld = -ld;\n\t\t\t\t}\n\t\t\t\tthis.a = la;\n\t\t\t\tthis.b = lb;\n\t\t\t\tthis.c = lc;\n\t\t\t\tthis.d = ld;\n\t\t\t\tthis.worldX = x + skeleton.x;\n\t\t\t\tthis.worldY = y + skeleton.y;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;\n\t\t\tthis.worldX = pa * x + pb * y + parent.worldX;\n\t\t\tthis.worldY = pc * x + pd * y + parent.worldY;\n\t\t\tswitch (this.data.transformMode) {\n\t\t\t\tcase spine.TransformMode.Normal: {\n\t\t\t\t\tvar rotationY = rotation + 90 + shearY;\n\t\t\t\t\tvar la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX;\n\t\t\t\t\tvar lb = spine.MathUtils.cosDeg(rotationY) * scaleY;\n\t\t\t\t\tvar lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX;\n\t\t\t\t\tvar ld = spine.MathUtils.sinDeg(rotationY) * scaleY;\n\t\t\t\t\tthis.a = pa * la + pb * lc;\n\t\t\t\t\tthis.b = pa * lb + pb * ld;\n\t\t\t\t\tthis.c = pc * la + pd * lc;\n\t\t\t\t\tthis.d = pc * lb + pd * ld;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase spine.TransformMode.OnlyTranslation: {\n\t\t\t\t\tvar rotationY = rotation + 90 + shearY;\n\t\t\t\t\tthis.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX;\n\t\t\t\t\tthis.b = spine.MathUtils.cosDeg(rotationY) * scaleY;\n\t\t\t\t\tthis.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX;\n\t\t\t\t\tthis.d = spine.MathUtils.sinDeg(rotationY) * scaleY;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase spine.TransformMode.NoRotationOrReflection: {\n\t\t\t\t\tvar s = pa * pa + pc * pc;\n\t\t\t\t\tvar prx = 0;\n\t\t\t\t\tif (s > 0.0001) {\n\t\t\t\t\t\ts = Math.abs(pa * pd - pb * pc) / s;\n\t\t\t\t\t\tpb = pc * s;\n\t\t\t\t\t\tpd = pa * s;\n\t\t\t\t\t\tprx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tpa = 0;\n\t\t\t\t\t\tpc = 0;\n\t\t\t\t\t\tprx = 90 - Math.atan2(pd, pb) * spine.MathUtils.radDeg;\n\t\t\t\t\t}\n\t\t\t\t\tvar rx = rotation + shearX - prx;\n\t\t\t\t\tvar ry = rotation + shearY - prx + 90;\n\t\t\t\t\tvar la = spine.MathUtils.cosDeg(rx) * scaleX;\n\t\t\t\t\tvar lb = spine.MathUtils.cosDeg(ry) * scaleY;\n\t\t\t\t\tvar lc = spine.MathUtils.sinDeg(rx) * scaleX;\n\t\t\t\t\tvar ld = spine.MathUtils.sinDeg(ry) * scaleY;\n\t\t\t\t\tthis.a = pa * la - pb * lc;\n\t\t\t\t\tthis.b = pa * lb - pb * ld;\n\t\t\t\t\tthis.c = pc * la + pd * lc;\n\t\t\t\t\tthis.d = pc * lb + pd * ld;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase spine.TransformMode.NoScale:\n\t\t\t\tcase spine.TransformMode.NoScaleOrReflection: {\n\t\t\t\t\tvar cos = spine.MathUtils.cosDeg(rotation);\n\t\t\t\t\tvar sin = spine.MathUtils.sinDeg(rotation);\n\t\t\t\t\tvar za = pa * cos + pb * sin;\n\t\t\t\t\tvar zc = pc * cos + pd * sin;\n\t\t\t\t\tvar s = Math.sqrt(za * za + zc * zc);\n\t\t\t\t\tif (s > 0.00001)\n\t\t\t\t\t\ts = 1 / s;\n\t\t\t\t\tza *= s;\n\t\t\t\t\tzc *= s;\n\t\t\t\t\ts = Math.sqrt(za * za + zc * zc);\n\t\t\t\t\tvar r = Math.PI / 2 + Math.atan2(zc, za);\n\t\t\t\t\tvar zb = Math.cos(r) * s;\n\t\t\t\t\tvar zd = Math.sin(r) * s;\n\t\t\t\t\tvar la = spine.MathUtils.cosDeg(shearX) * scaleX;\n\t\t\t\t\tvar lb = spine.MathUtils.cosDeg(90 + shearY) * scaleY;\n\t\t\t\t\tvar lc = spine.MathUtils.sinDeg(shearX) * scaleX;\n\t\t\t\t\tvar ld = spine.MathUtils.sinDeg(90 + shearY) * scaleY;\n\t\t\t\t\tif (this.data.transformMode != spine.TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : this.skeleton.flipX != this.skeleton.flipY) {\n\t\t\t\t\t\tzb = -zb;\n\t\t\t\t\t\tzd = -zd;\n\t\t\t\t\t}\n\t\t\t\t\tthis.a = za * la + zb * lc;\n\t\t\t\t\tthis.b = za * lb + zb * ld;\n\t\t\t\t\tthis.c = zc * la + zd * lc;\n\t\t\t\t\tthis.d = zc * lb + zd * ld;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.skeleton.flipX) {\n\t\t\t\tthis.a = -this.a;\n\t\t\t\tthis.b = -this.b;\n\t\t\t}\n\t\t\tif (this.skeleton.flipY) {\n\t\t\t\tthis.c = -this.c;\n\t\t\t\tthis.d = -this.d;\n\t\t\t}\n\t\t};\n\t\tBone.prototype.setToSetupPose = function () {\n\t\t\tvar data = this.data;\n\t\t\tthis.x = data.x;\n\t\t\tthis.y = data.y;\n\t\t\tthis.rotation = data.rotation;\n\t\t\tthis.scaleX = data.scaleX;\n\t\t\tthis.scaleY = data.scaleY;\n\t\t\tthis.shearX = data.shearX;\n\t\t\tthis.shearY = data.shearY;\n\t\t};\n\t\tBone.prototype.getWorldRotationX = function () {\n\t\t\treturn Math.atan2(this.c, this.a) * spine.MathUtils.radDeg;\n\t\t};\n\t\tBone.prototype.getWorldRotationY = function () {\n\t\t\treturn Math.atan2(this.d, this.b) * spine.MathUtils.radDeg;\n\t\t};\n\t\tBone.prototype.getWorldScaleX = function () {\n\t\t\treturn Math.sqrt(this.a * this.a + this.c * this.c);\n\t\t};\n\t\tBone.prototype.getWorldScaleY = function () {\n\t\t\treturn Math.sqrt(this.b * this.b + this.d * this.d);\n\t\t};\n\t\tBone.prototype.updateAppliedTransform = function () {\n\t\t\tthis.appliedValid = true;\n\t\t\tvar parent = this.parent;\n\t\t\tif (parent == null) {\n\t\t\t\tthis.ax = this.worldX;\n\t\t\t\tthis.ay = this.worldY;\n\t\t\t\tthis.arotation = Math.atan2(this.c, this.a) * spine.MathUtils.radDeg;\n\t\t\t\tthis.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c);\n\t\t\t\tthis.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d);\n\t\t\t\tthis.ashearX = 0;\n\t\t\t\tthis.ashearY = Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * spine.MathUtils.radDeg;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d;\n\t\t\tvar pid = 1 / (pa * pd - pb * pc);\n\t\t\tvar dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY;\n\t\t\tthis.ax = (dx * pd * pid - dy * pb * pid);\n\t\t\tthis.ay = (dy * pa * pid - dx * pc * pid);\n\t\t\tvar ia = pid * pd;\n\t\t\tvar id = pid * pa;\n\t\t\tvar ib = pid * pb;\n\t\t\tvar ic = pid * pc;\n\t\t\tvar ra = ia * this.a - ib * this.c;\n\t\t\tvar rb = ia * this.b - ib * this.d;\n\t\t\tvar rc = id * this.c - ic * this.a;\n\t\t\tvar rd = id * this.d - ic * this.b;\n\t\t\tthis.ashearX = 0;\n\t\t\tthis.ascaleX = Math.sqrt(ra * ra + rc * rc);\n\t\t\tif (this.ascaleX > 0.0001) {\n\t\t\t\tvar det = ra * rd - rb * rc;\n\t\t\t\tthis.ascaleY = det / this.ascaleX;\n\t\t\t\tthis.ashearY = Math.atan2(ra * rb + rc * rd, det) * spine.MathUtils.radDeg;\n\t\t\t\tthis.arotation = Math.atan2(rc, ra) * spine.MathUtils.radDeg;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.ascaleX = 0;\n\t\t\t\tthis.ascaleY = Math.sqrt(rb * rb + rd * rd);\n\t\t\t\tthis.ashearY = 0;\n\t\t\t\tthis.arotation = 90 - Math.atan2(rd, rb) * spine.MathUtils.radDeg;\n\t\t\t}\n\t\t};\n\t\tBone.prototype.worldToLocal = function (world) {\n\t\t\tvar a = this.a, b = this.b, c = this.c, d = this.d;\n\t\t\tvar invDet = 1 / (a * d - b * c);\n\t\t\tvar x = world.x - this.worldX, y = world.y - this.worldY;\n\t\t\tworld.x = (x * d * invDet - y * b * invDet);\n\t\t\tworld.y = (y * a * invDet - x * c * invDet);\n\t\t\treturn world;\n\t\t};\n\t\tBone.prototype.localToWorld = function (local) {\n\t\t\tvar x = local.x, y = local.y;\n\t\t\tlocal.x = x * this.a + y * this.b + this.worldX;\n\t\t\tlocal.y = x * this.c + y * this.d + this.worldY;\n\t\t\treturn local;\n\t\t};\n\t\tBone.prototype.worldToLocalRotation = function (worldRotation) {\n\t\t\tvar sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation);\n\t\t\treturn Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg;\n\t\t};\n\t\tBone.prototype.localToWorldRotation = function (localRotation) {\n\t\t\tvar sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation);\n\t\t\treturn Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg;\n\t\t};\n\t\tBone.prototype.rotateWorld = function (degrees) {\n\t\t\tvar a = this.a, b = this.b, c = this.c, d = this.d;\n\t\t\tvar cos = spine.MathUtils.cosDeg(degrees), sin = spine.MathUtils.sinDeg(degrees);\n\t\t\tthis.a = cos * a - sin * c;\n\t\t\tthis.b = cos * b - sin * d;\n\t\t\tthis.c = sin * a + cos * c;\n\t\t\tthis.d = sin * b + cos * d;\n\t\t\tthis.appliedValid = false;\n\t\t};\n\t\treturn Bone;\n\t}());\n\tspine.Bone = Bone;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar BoneData = (function () {\n\t\tfunction BoneData(index, name, parent) {\n\t\t\tthis.x = 0;\n\t\t\tthis.y = 0;\n\t\t\tthis.rotation = 0;\n\t\t\tthis.scaleX = 1;\n\t\t\tthis.scaleY = 1;\n\t\t\tthis.shearX = 0;\n\t\t\tthis.shearY = 0;\n\t\t\tthis.transformMode = TransformMode.Normal;\n\t\t\tif (index < 0)\n\t\t\t\tthrow new Error(\"index must be >= 0.\");\n\t\t\tif (name == null)\n\t\t\t\tthrow new Error(\"name cannot be null.\");\n\t\t\tthis.index = index;\n\t\t\tthis.name = name;\n\t\t\tthis.parent = parent;\n\t\t}\n\t\treturn BoneData;\n\t}());\n\tspine.BoneData = BoneData;\n\tvar TransformMode;\n\t(function (TransformMode) {\n\t\tTransformMode[TransformMode[\"Normal\"] = 0] = \"Normal\";\n\t\tTransformMode[TransformMode[\"OnlyTranslation\"] = 1] = \"OnlyTranslation\";\n\t\tTransformMode[TransformMode[\"NoRotationOrReflection\"] = 2] = \"NoRotationOrReflection\";\n\t\tTransformMode[TransformMode[\"NoScale\"] = 3] = \"NoScale\";\n\t\tTransformMode[TransformMode[\"NoScaleOrReflection\"] = 4] = \"NoScaleOrReflection\";\n\t})(TransformMode = spine.TransformMode || (spine.TransformMode = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar Event = (function () {\n\t\tfunction Event(time, data) {\n\t\t\tif (data == null)\n\t\t\t\tthrow new Error(\"data cannot be null.\");\n\t\t\tthis.time = time;\n\t\t\tthis.data = data;\n\t\t}\n\t\treturn Event;\n\t}());\n\tspine.Event = Event;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar EventData = (function () {\n\t\tfunction EventData(name) {\n\t\t\tthis.name = name;\n\t\t}\n\t\treturn EventData;\n\t}());\n\tspine.EventData = EventData;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar IkConstraint = (function () {\n\t\tfunction IkConstraint(data, skeleton) {\n\t\t\tthis.mix = 1;\n\t\t\tthis.bendDirection = 0;\n\t\t\tif (data == null)\n\t\t\t\tthrow new Error(\"data cannot be null.\");\n\t\t\tif (skeleton == null)\n\t\t\t\tthrow new Error(\"skeleton cannot be null.\");\n\t\t\tthis.data = data;\n\t\t\tthis.mix = data.mix;\n\t\t\tthis.bendDirection = data.bendDirection;\n\t\t\tthis.bones = new Array();\n\t\t\tfor (var i = 0; i < data.bones.length; i++)\n\t\t\t\tthis.bones.push(skeleton.findBone(data.bones[i].name));\n\t\t\tthis.target = skeleton.findBone(data.target.name);\n\t\t}\n\t\tIkConstraint.prototype.getOrder = function () {\n\t\t\treturn this.data.order;\n\t\t};\n\t\tIkConstraint.prototype.apply = function () {\n\t\t\tthis.update();\n\t\t};\n\t\tIkConstraint.prototype.update = function () {\n\t\t\tvar target = this.target;\n\t\t\tvar bones = this.bones;\n\t\t\tswitch (bones.length) {\n\t\t\t\tcase 1:\n\t\t\t\t\tthis.apply1(bones[0], target.worldX, target.worldY, this.mix);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 2:\n\t\t\t\t\tthis.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.mix);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\t\tIkConstraint.prototype.apply1 = function (bone, targetX, targetY, alpha) {\n\t\t\tif (!bone.appliedValid)\n\t\t\t\tbone.updateAppliedTransform();\n\t\t\tvar p = bone.parent;\n\t\t\tvar id = 1 / (p.a * p.d - p.b * p.c);\n\t\t\tvar x = targetX - p.worldX, y = targetY - p.worldY;\n\t\t\tvar tx = (x * p.d - y * p.b) * id - bone.ax, ty = (y * p.a - x * p.c) * id - bone.ay;\n\t\t\tvar rotationIK = Math.atan2(ty, tx) * spine.MathUtils.radDeg - bone.ashearX - bone.arotation;\n\t\t\tif (bone.ascaleX < 0)\n\t\t\t\trotationIK += 180;\n\t\t\tif (rotationIK > 180)\n\t\t\t\trotationIK -= 360;\n\t\t\telse if (rotationIK < -180)\n\t\t\t\trotationIK += 360;\n\t\t\tbone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, bone.ascaleX, bone.ascaleY, bone.ashearX, bone.ashearY);\n\t\t};\n\t\tIkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, alpha) {\n\t\t\tif (alpha == 0) {\n\t\t\t\tchild.updateWorldTransform();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!parent.appliedValid)\n\t\t\t\tparent.updateAppliedTransform();\n\t\t\tif (!child.appliedValid)\n\t\t\t\tchild.updateAppliedTransform();\n\t\t\tvar px = parent.ax, py = parent.ay, psx = parent.ascaleX, psy = parent.ascaleY, csx = child.ascaleX;\n\t\t\tvar os1 = 0, os2 = 0, s2 = 0;\n\t\t\tif (psx < 0) {\n\t\t\t\tpsx = -psx;\n\t\t\t\tos1 = 180;\n\t\t\t\ts2 = -1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tos1 = 0;\n\t\t\t\ts2 = 1;\n\t\t\t}\n\t\t\tif (psy < 0) {\n\t\t\t\tpsy = -psy;\n\t\t\t\ts2 = -s2;\n\t\t\t}\n\t\t\tif (csx < 0) {\n\t\t\t\tcsx = -csx;\n\t\t\t\tos2 = 180;\n\t\t\t}\n\t\t\telse\n\t\t\t\tos2 = 0;\n\t\t\tvar cx = child.ax, cy = 0, cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d;\n\t\t\tvar u = Math.abs(psx - psy) <= 0.0001;\n\t\t\tif (!u) {\n\t\t\t\tcy = 0;\n\t\t\t\tcwx = a * cx + parent.worldX;\n\t\t\t\tcwy = c * cx + parent.worldY;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcy = child.ay;\n\t\t\t\tcwx = a * cx + b * cy + parent.worldX;\n\t\t\t\tcwy = c * cx + d * cy + parent.worldY;\n\t\t\t}\n\t\t\tvar pp = parent.parent;\n\t\t\ta = pp.a;\n\t\t\tb = pp.b;\n\t\t\tc = pp.c;\n\t\t\td = pp.d;\n\t\t\tvar id = 1 / (a * d - b * c), x = targetX - pp.worldX, y = targetY - pp.worldY;\n\t\t\tvar tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py;\n\t\t\tx = cwx - pp.worldX;\n\t\t\ty = cwy - pp.worldY;\n\t\t\tvar dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;\n\t\t\tvar l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1 = 0, a2 = 0;\n\t\t\touter: if (u) {\n\t\t\t\tl2 *= psx;\n\t\t\t\tvar cos = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2);\n\t\t\t\tif (cos < -1)\n\t\t\t\t\tcos = -1;\n\t\t\t\telse if (cos > 1)\n\t\t\t\t\tcos = 1;\n\t\t\t\ta2 = Math.acos(cos) * bendDir;\n\t\t\t\ta = l1 + l2 * cos;\n\t\t\t\tb = l2 * Math.sin(a2);\n\t\t\t\ta1 = Math.atan2(ty * a - tx * b, tx * a + ty * b);\n\t\t\t}\n\t\t\telse {\n\t\t\t\ta = psx * l2;\n\t\t\t\tb = psy * l2;\n\t\t\t\tvar aa = a * a, bb = b * b, dd = tx * tx + ty * ty, ta = Math.atan2(ty, tx);\n\t\t\t\tc = bb * l1 * l1 + aa * dd - aa * bb;\n\t\t\t\tvar c1 = -2 * bb * l1, c2 = bb - aa;\n\t\t\t\td = c1 * c1 - 4 * c2 * c;\n\t\t\t\tif (d >= 0) {\n\t\t\t\t\tvar q = Math.sqrt(d);\n\t\t\t\t\tif (c1 < 0)\n\t\t\t\t\t\tq = -q;\n\t\t\t\t\tq = -(c1 + q) / 2;\n\t\t\t\t\tvar r0 = q / c2, r1 = c / q;\n\t\t\t\t\tvar r = Math.abs(r0) < Math.abs(r1) ? r0 : r1;\n\t\t\t\t\tif (r * r <= dd) {\n\t\t\t\t\t\ty = Math.sqrt(dd - r * r) * bendDir;\n\t\t\t\t\t\ta1 = ta - Math.atan2(y, r);\n\t\t\t\t\t\ta2 = Math.atan2(y / psy, (r - l1) / psx);\n\t\t\t\t\t\tbreak outer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tvar minAngle = spine.MathUtils.PI, minX = l1 - a, minDist = minX * minX, minY = 0;\n\t\t\t\tvar maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0;\n\t\t\t\tc = -a * l1 / (aa - bb);\n\t\t\t\tif (c >= -1 && c <= 1) {\n\t\t\t\t\tc = Math.acos(c);\n\t\t\t\t\tx = a * Math.cos(c) + l1;\n\t\t\t\t\ty = b * Math.sin(c);\n\t\t\t\t\td = x * x + y * y;\n\t\t\t\t\tif (d < minDist) {\n\t\t\t\t\t\tminAngle = c;\n\t\t\t\t\t\tminDist = d;\n\t\t\t\t\t\tminX = x;\n\t\t\t\t\t\tminY = y;\n\t\t\t\t\t}\n\t\t\t\t\tif (d > maxDist) {\n\t\t\t\t\t\tmaxAngle = c;\n\t\t\t\t\t\tmaxDist = d;\n\t\t\t\t\t\tmaxX = x;\n\t\t\t\t\t\tmaxY = y;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (dd <= (minDist + maxDist) / 2) {\n\t\t\t\t\ta1 = ta - Math.atan2(minY * bendDir, minX);\n\t\t\t\t\ta2 = minAngle * bendDir;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ta1 = ta - Math.atan2(maxY * bendDir, maxX);\n\t\t\t\t\ta2 = maxAngle * bendDir;\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar os = Math.atan2(cy, cx) * s2;\n\t\t\tvar rotation = parent.arotation;\n\t\t\ta1 = (a1 - os) * spine.MathUtils.radDeg + os1 - rotation;\n\t\t\tif (a1 > 180)\n\t\t\t\ta1 -= 360;\n\t\t\telse if (a1 < -180)\n\t\t\t\ta1 += 360;\n\t\t\tparent.updateWorldTransformWith(px, py, rotation + a1 * alpha, parent.ascaleX, parent.ascaleY, 0, 0);\n\t\t\trotation = child.arotation;\n\t\t\ta2 = ((a2 + os) * spine.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation;\n\t\t\tif (a2 > 180)\n\t\t\t\ta2 -= 360;\n\t\t\telse if (a2 < -180)\n\t\t\t\ta2 += 360;\n\t\t\tchild.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY);\n\t\t};\n\t\treturn IkConstraint;\n\t}());\n\tspine.IkConstraint = IkConstraint;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar IkConstraintData = (function () {\n\t\tfunction IkConstraintData(name) {\n\t\t\tthis.order = 0;\n\t\t\tthis.bones = new Array();\n\t\t\tthis.bendDirection = 1;\n\t\t\tthis.mix = 1;\n\t\t\tthis.name = name;\n\t\t}\n\t\treturn IkConstraintData;\n\t}());\n\tspine.IkConstraintData = IkConstraintData;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar PathConstraint = (function () {\n\t\tfunction PathConstraint(data, skeleton) {\n\t\t\tthis.position = 0;\n\t\t\tthis.spacing = 0;\n\t\t\tthis.rotateMix = 0;\n\t\t\tthis.translateMix = 0;\n\t\t\tthis.spaces = new Array();\n\t\t\tthis.positions = new Array();\n\t\t\tthis.world = new Array();\n\t\t\tthis.curves = new Array();\n\t\t\tthis.lengths = new Array();\n\t\t\tthis.segments = new Array();\n\t\t\tif (data == null)\n\t\t\t\tthrow new Error(\"data cannot be null.\");\n\t\t\tif (skeleton == null)\n\t\t\t\tthrow new Error(\"skeleton cannot be null.\");\n\t\t\tthis.data = data;\n\t\t\tthis.bones = new Array();\n\t\t\tfor (var i = 0, n = data.bones.length; i < n; i++)\n\t\t\t\tthis.bones.push(skeleton.findBone(data.bones[i].name));\n\t\t\tthis.target = skeleton.findSlot(data.target.name);\n\t\t\tthis.position = data.position;\n\t\t\tthis.spacing = data.spacing;\n\t\t\tthis.rotateMix = data.rotateMix;\n\t\t\tthis.translateMix = data.translateMix;\n\t\t}\n\t\tPathConstraint.prototype.apply = function () {\n\t\t\tthis.update();\n\t\t};\n\t\tPathConstraint.prototype.update = function () {\n\t\t\tvar attachment = this.target.getAttachment();\n\t\t\tif (!(attachment instanceof spine.PathAttachment))\n\t\t\t\treturn;\n\t\t\tvar rotateMix = this.rotateMix, translateMix = this.translateMix;\n\t\t\tvar translate = translateMix > 0, rotate = rotateMix > 0;\n\t\t\tif (!translate && !rotate)\n\t\t\t\treturn;\n\t\t\tvar data = this.data;\n\t\t\tvar spacingMode = data.spacingMode;\n\t\t\tvar lengthSpacing = spacingMode == spine.SpacingMode.Length;\n\t\t\tvar rotateMode = data.rotateMode;\n\t\t\tvar tangents = rotateMode == spine.RotateMode.Tangent, scale = rotateMode == spine.RotateMode.ChainScale;\n\t\t\tvar boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1;\n\t\t\tvar bones = this.bones;\n\t\t\tvar spaces = spine.Utils.setArraySize(this.spaces, spacesCount), lengths = null;\n\t\t\tvar spacing = this.spacing;\n\t\t\tif (scale || lengthSpacing) {\n\t\t\t\tif (scale)\n\t\t\t\t\tlengths = spine.Utils.setArraySize(this.lengths, boneCount);\n\t\t\t\tfor (var i = 0, n = spacesCount - 1; i < n;) {\n\t\t\t\t\tvar bone = bones[i];\n\t\t\t\t\tvar setupLength = bone.data.length;\n\t\t\t\t\tif (setupLength < PathConstraint.epsilon) {\n\t\t\t\t\t\tif (scale)\n\t\t\t\t\t\t\tlengths[i] = 0;\n\t\t\t\t\t\tspaces[++i] = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tvar x = setupLength * bone.a, y = setupLength * bone.c;\n\t\t\t\t\t\tvar length_1 = Math.sqrt(x * x + y * y);\n\t\t\t\t\t\tif (scale)\n\t\t\t\t\t\t\tlengths[i] = length_1;\n\t\t\t\t\t\tspaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (var i = 1; i < spacesCount; i++)\n\t\t\t\t\tspaces[i] = spacing;\n\t\t\t}\n\t\t\tvar positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent);\n\t\t\tvar boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;\n\t\t\tvar tip = false;\n\t\t\tif (offsetRotation == 0)\n\t\t\t\ttip = rotateMode == spine.RotateMode.Chain;\n\t\t\telse {\n\t\t\t\ttip = false;\n\t\t\t\tvar p = this.target.bone;\n\t\t\t\toffsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;\n\t\t\t}\n\t\t\tfor (var i = 0, p = 3; i < boneCount; i++, p += 3) {\n\t\t\t\tvar bone = bones[i];\n\t\t\t\tbone.worldX += (boneX - bone.worldX) * translateMix;\n\t\t\t\tbone.worldY += (boneY - bone.worldY) * translateMix;\n\t\t\t\tvar x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY;\n\t\t\t\tif (scale) {\n\t\t\t\t\tvar length_2 = lengths[i];\n\t\t\t\t\tif (length_2 != 0) {\n\t\t\t\t\t\tvar s = (Math.sqrt(dx * dx + dy * dy) / length_2 - 1) * rotateMix + 1;\n\t\t\t\t\t\tbone.a *= s;\n\t\t\t\t\t\tbone.c *= s;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tboneX = x;\n\t\t\t\tboneY = y;\n\t\t\t\tif (rotate) {\n\t\t\t\t\tvar a = bone.a, b = bone.b, c = bone.c, d = bone.d, r = 0, cos = 0, sin = 0;\n\t\t\t\t\tif (tangents)\n\t\t\t\t\t\tr = positions[p - 1];\n\t\t\t\t\telse if (spaces[i + 1] == 0)\n\t\t\t\t\t\tr = positions[p + 2];\n\t\t\t\t\telse\n\t\t\t\t\t\tr = Math.atan2(dy, dx);\n\t\t\t\t\tr -= Math.atan2(c, a);\n\t\t\t\t\tif (tip) {\n\t\t\t\t\t\tcos = Math.cos(r);\n\t\t\t\t\t\tsin = Math.sin(r);\n\t\t\t\t\t\tvar length_3 = bone.data.length;\n\t\t\t\t\t\tboneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix;\n\t\t\t\t\t\tboneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tr += offsetRotation;\n\t\t\t\t\t}\n\t\t\t\t\tif (r > spine.MathUtils.PI)\n\t\t\t\t\t\tr -= spine.MathUtils.PI2;\n\t\t\t\t\telse if (r < -spine.MathUtils.PI)\n\t\t\t\t\t\tr += spine.MathUtils.PI2;\n\t\t\t\t\tr *= rotateMix;\n\t\t\t\t\tcos = Math.cos(r);\n\t\t\t\t\tsin = Math.sin(r);\n\t\t\t\t\tbone.a = cos * a - sin * c;\n\t\t\t\t\tbone.b = cos * b - sin * d;\n\t\t\t\t\tbone.c = sin * a + cos * c;\n\t\t\t\t\tbone.d = sin * b + cos * d;\n\t\t\t\t}\n\t\t\t\tbone.appliedValid = false;\n\t\t\t}\n\t\t};\n\t\tPathConstraint.prototype.computeWorldPositions = function (path, spacesCount, tangents, percentPosition, percentSpacing) {\n\t\t\tvar target = this.target;\n\t\t\tvar position = this.position;\n\t\t\tvar spaces = this.spaces, out = spine.Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null;\n\t\t\tvar closed = path.closed;\n\t\t\tvar verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PathConstraint.NONE;\n\t\t\tif (!path.constantSpeed) {\n\t\t\t\tvar lengths = path.lengths;\n\t\t\t\tcurveCount -= closed ? 1 : 2;\n\t\t\t\tvar pathLength_1 = lengths[curveCount];\n\t\t\t\tif (percentPosition)\n\t\t\t\t\tposition *= pathLength_1;\n\t\t\t\tif (percentSpacing) {\n\t\t\t\t\tfor (var i = 0; i < spacesCount; i++)\n\t\t\t\t\t\tspaces[i] *= pathLength_1;\n\t\t\t\t}\n\t\t\t\tworld = spine.Utils.setArraySize(this.world, 8);\n\t\t\t\tfor (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) {\n\t\t\t\t\tvar space = spaces[i];\n\t\t\t\t\tposition += space;\n\t\t\t\t\tvar p = position;\n\t\t\t\t\tif (closed) {\n\t\t\t\t\t\tp %= pathLength_1;\n\t\t\t\t\t\tif (p < 0)\n\t\t\t\t\t\t\tp += pathLength_1;\n\t\t\t\t\t\tcurve = 0;\n\t\t\t\t\t}\n\t\t\t\t\telse if (p < 0) {\n\t\t\t\t\t\tif (prevCurve != PathConstraint.BEFORE) {\n\t\t\t\t\t\t\tprevCurve = PathConstraint.BEFORE;\n\t\t\t\t\t\t\tpath.computeWorldVertices(target, 2, 4, world, 0, 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.addBeforePosition(p, world, 0, out, o);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\telse if (p > pathLength_1) {\n\t\t\t\t\t\tif (prevCurve != PathConstraint.AFTER) {\n\t\t\t\t\t\t\tprevCurve = PathConstraint.AFTER;\n\t\t\t\t\t\t\tpath.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.addAfterPosition(p - pathLength_1, world, 0, out, o);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tfor (;; curve++) {\n\t\t\t\t\t\tvar length_4 = lengths[curve];\n\t\t\t\t\t\tif (p > length_4)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif (curve == 0)\n\t\t\t\t\t\t\tp /= length_4;\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tvar prev = lengths[curve - 1];\n\t\t\t\t\t\t\tp = (p - prev) / (length_4 - prev);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (curve != prevCurve) {\n\t\t\t\t\t\tprevCurve = curve;\n\t\t\t\t\t\tif (closed && curve == curveCount) {\n\t\t\t\t\t\t\tpath.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2);\n\t\t\t\t\t\t\tpath.computeWorldVertices(target, 0, 4, world, 4, 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tpath.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2);\n\t\t\t\t\t}\n\t\t\t\t\tthis.addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], out, o, tangents || (i > 0 && space == 0));\n\t\t\t\t}\n\t\t\t\treturn out;\n\t\t\t}\n\t\t\tif (closed) {\n\t\t\t\tverticesLength += 2;\n\t\t\t\tworld = spine.Utils.setArraySize(this.world, verticesLength);\n\t\t\t\tpath.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2);\n\t\t\t\tpath.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2);\n\t\t\t\tworld[verticesLength - 2] = world[0];\n\t\t\t\tworld[verticesLength - 1] = world[1];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcurveCount--;\n\t\t\t\tverticesLength -= 4;\n\t\t\t\tworld = spine.Utils.setArraySize(this.world, verticesLength);\n\t\t\t\tpath.computeWorldVertices(target, 2, verticesLength, world, 0, 2);\n\t\t\t}\n\t\t\tvar curves = spine.Utils.setArraySize(this.curves, curveCount);\n\t\t\tvar pathLength = 0;\n\t\t\tvar x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0;\n\t\t\tvar tmpx = 0, tmpy = 0, dddfx = 0, dddfy = 0, ddfx = 0, ddfy = 0, dfx = 0, dfy = 0;\n\t\t\tfor (var i = 0, w = 2; i < curveCount; i++, w += 6) {\n\t\t\t\tcx1 = world[w];\n\t\t\t\tcy1 = world[w + 1];\n\t\t\t\tcx2 = world[w + 2];\n\t\t\t\tcy2 = world[w + 3];\n\t\t\t\tx2 = world[w + 4];\n\t\t\t\ty2 = world[w + 5];\n\t\t\t\ttmpx = (x1 - cx1 * 2 + cx2) * 0.1875;\n\t\t\t\ttmpy = (y1 - cy1 * 2 + cy2) * 0.1875;\n\t\t\t\tdddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375;\n\t\t\t\tdddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375;\n\t\t\t\tddfx = tmpx * 2 + dddfx;\n\t\t\t\tddfy = tmpy * 2 + dddfy;\n\t\t\t\tdfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667;\n\t\t\t\tdfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667;\n\t\t\t\tpathLength += Math.sqrt(dfx * dfx + dfy * dfy);\n\t\t\t\tdfx += ddfx;\n\t\t\t\tdfy += ddfy;\n\t\t\t\tddfx += dddfx;\n\t\t\t\tddfy += dddfy;\n\t\t\t\tpathLength += Math.sqrt(dfx * dfx + dfy * dfy);\n\t\t\t\tdfx += ddfx;\n\t\t\t\tdfy += ddfy;\n\t\t\t\tpathLength += Math.sqrt(dfx * dfx + dfy * dfy);\n\t\t\t\tdfx += ddfx + dddfx;\n\t\t\t\tdfy += ddfy + dddfy;\n\t\t\t\tpathLength += Math.sqrt(dfx * dfx + dfy * dfy);\n\t\t\t\tcurves[i] = pathLength;\n\t\t\t\tx1 = x2;\n\t\t\t\ty1 = y2;\n\t\t\t}\n\t\t\tif (percentPosition)\n\t\t\t\tposition *= pathLength;\n\t\t\tif (percentSpacing) {\n\t\t\t\tfor (var i = 0; i < spacesCount; i++)\n\t\t\t\t\tspaces[i] *= pathLength;\n\t\t\t}\n\t\t\tvar segments = this.segments;\n\t\t\tvar curveLength = 0;\n\t\t\tfor (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) {\n\t\t\t\tvar space = spaces[i];\n\t\t\t\tposition += space;\n\t\t\t\tvar p = position;\n\t\t\t\tif (closed) {\n\t\t\t\t\tp %= pathLength;\n\t\t\t\t\tif (p < 0)\n\t\t\t\t\t\tp += pathLength;\n\t\t\t\t\tcurve = 0;\n\t\t\t\t}\n\t\t\t\telse if (p < 0) {\n\t\t\t\t\tthis.addBeforePosition(p, world, 0, out, o);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\telse if (p > pathLength) {\n\t\t\t\t\tthis.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (;; curve++) {\n\t\t\t\t\tvar length_5 = curves[curve];\n\t\t\t\t\tif (p > length_5)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (curve == 0)\n\t\t\t\t\t\tp /= length_5;\n\t\t\t\t\telse {\n\t\t\t\t\t\tvar prev = curves[curve - 1];\n\t\t\t\t\t\tp = (p - prev) / (length_5 - prev);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (curve != prevCurve) {\n\t\t\t\t\tprevCurve = curve;\n\t\t\t\t\tvar ii = curve * 6;\n\t\t\t\t\tx1 = world[ii];\n\t\t\t\t\ty1 = world[ii + 1];\n\t\t\t\t\tcx1 = world[ii + 2];\n\t\t\t\t\tcy1 = world[ii + 3];\n\t\t\t\t\tcx2 = world[ii + 4];\n\t\t\t\t\tcy2 = world[ii + 5];\n\t\t\t\t\tx2 = world[ii + 6];\n\t\t\t\t\ty2 = world[ii + 7];\n\t\t\t\t\ttmpx = (x1 - cx1 * 2 + cx2) * 0.03;\n\t\t\t\t\ttmpy = (y1 - cy1 * 2 + cy2) * 0.03;\n\t\t\t\t\tdddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006;\n\t\t\t\t\tdddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006;\n\t\t\t\t\tddfx = tmpx * 2 + dddfx;\n\t\t\t\t\tddfy = tmpy * 2 + dddfy;\n\t\t\t\t\tdfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667;\n\t\t\t\t\tdfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667;\n\t\t\t\t\tcurveLength = Math.sqrt(dfx * dfx + dfy * dfy);\n\t\t\t\t\tsegments[0] = curveLength;\n\t\t\t\t\tfor (ii = 1; ii < 8; ii++) {\n\t\t\t\t\t\tdfx += ddfx;\n\t\t\t\t\t\tdfy += ddfy;\n\t\t\t\t\t\tddfx += dddfx;\n\t\t\t\t\t\tddfy += dddfy;\n\t\t\t\t\t\tcurveLength += Math.sqrt(dfx * dfx + dfy * dfy);\n\t\t\t\t\t\tsegments[ii] = curveLength;\n\t\t\t\t\t}\n\t\t\t\t\tdfx += ddfx;\n\t\t\t\t\tdfy += ddfy;\n\t\t\t\t\tcurveLength += Math.sqrt(dfx * dfx + dfy * dfy);\n\t\t\t\t\tsegments[8] = curveLength;\n\t\t\t\t\tdfx += ddfx + dddfx;\n\t\t\t\t\tdfy += ddfy + dddfy;\n\t\t\t\t\tcurveLength += Math.sqrt(dfx * dfx + dfy * dfy);\n\t\t\t\t\tsegments[9] = curveLength;\n\t\t\t\t\tsegment = 0;\n\t\t\t\t}\n\t\t\t\tp *= curveLength;\n\t\t\t\tfor (;; segment++) {\n\t\t\t\t\tvar length_6 = segments[segment];\n\t\t\t\t\tif (p > length_6)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (segment == 0)\n\t\t\t\t\t\tp /= length_6;\n\t\t\t\t\telse {\n\t\t\t\t\t\tvar prev = segments[segment - 1];\n\t\t\t\t\t\tp = segment + (p - prev) / (length_6 - prev);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthis.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0));\n\t\t\t}\n\t\t\treturn out;\n\t\t};\n\t\tPathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) {\n\t\t\tvar x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx);\n\t\t\tout[o] = x1 + p * Math.cos(r);\n\t\t\tout[o + 1] = y1 + p * Math.sin(r);\n\t\t\tout[o + 2] = r;\n\t\t};\n\t\tPathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) {\n\t\t\tvar x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx);\n\t\t\tout[o] = x1 + p * Math.cos(r);\n\t\t\tout[o + 1] = y1 + p * Math.sin(r);\n\t\t\tout[o + 2] = r;\n\t\t};\n\t\tPathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) {\n\t\t\tif (p == 0 || isNaN(p))\n\t\t\t\tp = 0.0001;\n\t\t\tvar tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u;\n\t\t\tvar ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p;\n\t\t\tvar x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;\n\t\t\tout[o] = x;\n\t\t\tout[o + 1] = y;\n\t\t\tif (tangents)\n\t\t\t\tout[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));\n\t\t};\n\t\tPathConstraint.prototype.getOrder = function () {\n\t\t\treturn this.data.order;\n\t\t};\n\t\tPathConstraint.NONE = -1;\n\t\tPathConstraint.BEFORE = -2;\n\t\tPathConstraint.AFTER = -3;\n\t\tPathConstraint.epsilon = 0.00001;\n\t\treturn PathConstraint;\n\t}());\n\tspine.PathConstraint = PathConstraint;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar PathConstraintData = (function () {\n\t\tfunction PathConstraintData(name) {\n\t\t\tthis.order = 0;\n\t\t\tthis.bones = new Array();\n\t\t\tthis.name = name;\n\t\t}\n\t\treturn PathConstraintData;\n\t}());\n\tspine.PathConstraintData = PathConstraintData;\n\tvar PositionMode;\n\t(function (PositionMode) {\n\t\tPositionMode[PositionMode[\"Fixed\"] = 0] = \"Fixed\";\n\t\tPositionMode[PositionMode[\"Percent\"] = 1] = \"Percent\";\n\t})(PositionMode = spine.PositionMode || (spine.PositionMode = {}));\n\tvar SpacingMode;\n\t(function (SpacingMode) {\n\t\tSpacingMode[SpacingMode[\"Length\"] = 0] = \"Length\";\n\t\tSpacingMode[SpacingMode[\"Fixed\"] = 1] = \"Fixed\";\n\t\tSpacingMode[SpacingMode[\"Percent\"] = 2] = \"Percent\";\n\t})(SpacingMode = spine.SpacingMode || (spine.SpacingMode = {}));\n\tvar RotateMode;\n\t(function (RotateMode) {\n\t\tRotateMode[RotateMode[\"Tangent\"] = 0] = \"Tangent\";\n\t\tRotateMode[RotateMode[\"Chain\"] = 1] = \"Chain\";\n\t\tRotateMode[RotateMode[\"ChainScale\"] = 2] = \"ChainScale\";\n\t})(RotateMode = spine.RotateMode || (spine.RotateMode = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar Assets = (function () {\n\t\tfunction Assets(clientId) {\n\t\t\tthis.toLoad = new Array();\n\t\t\tthis.assets = {};\n\t\t\tthis.clientId = clientId;\n\t\t}\n\t\tAssets.prototype.loaded = function () {\n\t\t\tvar i = 0;\n\t\t\tfor (var v in this.assets)\n\t\t\t\ti++;\n\t\t\treturn i;\n\t\t};\n\t\treturn Assets;\n\t}());\n\tvar SharedAssetManager = (function () {\n\t\tfunction SharedAssetManager(pathPrefix) {\n\t\t\tif (pathPrefix === void 0) { pathPrefix = \"\"; }\n\t\t\tthis.clientAssets = {};\n\t\t\tthis.queuedAssets = {};\n\t\t\tthis.rawAssets = {};\n\t\t\tthis.errors = {};\n\t\t\tthis.pathPrefix = pathPrefix;\n\t\t}\n\t\tSharedAssetManager.prototype.queueAsset = function (clientId, textureLoader, path) {\n\t\t\tvar clientAssets = this.clientAssets[clientId];\n\t\t\tif (clientAssets === null || clientAssets === undefined) {\n\t\t\t\tclientAssets = new Assets(clientId);\n\t\t\t\tthis.clientAssets[clientId] = clientAssets;\n\t\t\t}\n\t\t\tif (textureLoader !== null)\n\t\t\t\tclientAssets.textureLoader = textureLoader;\n\t\t\tclientAssets.toLoad.push(path);\n\t\t\tif (this.queuedAssets[path] === path) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.queuedAssets[path] = path;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t};\n\t\tSharedAssetManager.prototype.loadText = function (clientId, path) {\n\t\t\tvar _this = this;\n\t\t\tpath = this.pathPrefix + path;\n\t\t\tif (!this.queueAsset(clientId, null, path))\n\t\t\t\treturn;\n\t\t\tvar request = new XMLHttpRequest();\n\t\t\trequest.onreadystatechange = function () {\n\t\t\t\tif (request.readyState == XMLHttpRequest.DONE) {\n\t\t\t\t\tif (request.status >= 200 && request.status < 300) {\n\t\t\t\t\t\t_this.rawAssets[path] = request.responseText;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t_this.errors[path] = \"Couldn't load text \" + path + \": status \" + request.status + \", \" + request.responseText;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\trequest.open(\"GET\", path, true);\n\t\t\trequest.send();\n\t\t};\n\t\tSharedAssetManager.prototype.loadJson = function (clientId, path) {\n\t\t\tvar _this = this;\n\t\t\tpath = this.pathPrefix + path;\n\t\t\tif (!this.queueAsset(clientId, null, path))\n\t\t\t\treturn;\n\t\t\tvar request = new XMLHttpRequest();\n\t\t\trequest.onreadystatechange = function () {\n\t\t\t\tif (request.readyState == XMLHttpRequest.DONE) {\n\t\t\t\t\tif (request.status >= 200 && request.status < 300) {\n\t\t\t\t\t\t_this.rawAssets[path] = JSON.parse(request.responseText);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\t_this.errors[path] = \"Couldn't load text \" + path + \": status \" + request.status + \", \" + request.responseText;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\trequest.open(\"GET\", path, true);\n\t\t\trequest.send();\n\t\t};\n\t\tSharedAssetManager.prototype.loadTexture = function (clientId, textureLoader, path) {\n\t\t\tvar _this = this;\n\t\t\tpath = this.pathPrefix + path;\n\t\t\tif (!this.queueAsset(clientId, textureLoader, path))\n\t\t\t\treturn;\n\t\t\tvar img = new Image();\n\t\t\timg.src = path;\n\t\t\timg.crossOrigin = \"anonymous\";\n\t\t\timg.onload = function (ev) {\n\t\t\t\t_this.rawAssets[path] = img;\n\t\t\t};\n\t\t\timg.onerror = function (ev) {\n\t\t\t\t_this.errors[path] = \"Couldn't load image \" + path;\n\t\t\t};\n\t\t};\n\t\tSharedAssetManager.prototype.get = function (clientId, path) {\n\t\t\tpath = this.pathPrefix + path;\n\t\t\tvar clientAssets = this.clientAssets[clientId];\n\t\t\tif (clientAssets === null || clientAssets === undefined)\n\t\t\t\treturn true;\n\t\t\treturn clientAssets.assets[path];\n\t\t};\n\t\tSharedAssetManager.prototype.updateClientAssets = function (clientAssets) {\n\t\t\tfor (var i = 0; i < clientAssets.toLoad.length; i++) {\n\t\t\t\tvar path = clientAssets.toLoad[i];\n\t\t\t\tvar asset = clientAssets.assets[path];\n\t\t\t\tif (asset === null || asset === undefined) {\n\t\t\t\t\tvar rawAsset = this.rawAssets[path];\n\t\t\t\t\tif (rawAsset === null || rawAsset === undefined)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (rawAsset instanceof HTMLImageElement) {\n\t\t\t\t\t\tclientAssets.assets[path] = clientAssets.textureLoader(rawAsset);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tclientAssets.assets[path] = rawAsset;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tSharedAssetManager.prototype.isLoadingComplete = function (clientId) {\n\t\t\tvar clientAssets = this.clientAssets[clientId];\n\t\t\tif (clientAssets === null || clientAssets === undefined)\n\t\t\t\treturn true;\n\t\t\tthis.updateClientAssets(clientAssets);\n\t\t\treturn clientAssets.toLoad.length == clientAssets.loaded();\n\t\t};\n\t\tSharedAssetManager.prototype.dispose = function () {\n\t\t};\n\t\tSharedAssetManager.prototype.hasErrors = function () {\n\t\t\treturn Object.keys(this.errors).length > 0;\n\t\t};\n\t\tSharedAssetManager.prototype.getErrors = function () {\n\t\t\treturn this.errors;\n\t\t};\n\t\treturn SharedAssetManager;\n\t}());\n\tspine.SharedAssetManager = SharedAssetManager;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar Skeleton = (function () {\n\t\tfunction Skeleton(data) {\n\t\t\tthis._updateCache = new Array();\n\t\t\tthis.updateCacheReset = new Array();\n\t\t\tthis.time = 0;\n\t\t\tthis.flipX = false;\n\t\t\tthis.flipY = false;\n\t\t\tthis.x = 0;\n\t\t\tthis.y = 0;\n\t\t\tif (data == null)\n\t\t\t\tthrow new Error(\"data cannot be null.\");\n\t\t\tthis.data = data;\n\t\t\tthis.bones = new Array();\n\t\t\tfor (var i = 0; i < data.bones.length; i++) {\n\t\t\t\tvar boneData = data.bones[i];\n\t\t\t\tvar bone = void 0;\n\t\t\t\tif (boneData.parent == null)\n\t\t\t\t\tbone = new spine.Bone(boneData, this, null);\n\t\t\t\telse {\n\t\t\t\t\tvar parent_1 = this.bones[boneData.parent.index];\n\t\t\t\t\tbone = new spine.Bone(boneData, this, parent_1);\n\t\t\t\t\tparent_1.children.push(bone);\n\t\t\t\t}\n\t\t\t\tthis.bones.push(bone);\n\t\t\t}\n\t\t\tthis.slots = new Array();\n\t\t\tthis.drawOrder = new Array();\n\t\t\tfor (var i = 0; i < data.slots.length; i++) {\n\t\t\t\tvar slotData = data.slots[i];\n\t\t\t\tvar bone = this.bones[slotData.boneData.index];\n\t\t\t\tvar slot = new spine.Slot(slotData, bone);\n\t\t\t\tthis.slots.push(slot);\n\t\t\t\tthis.drawOrder.push(slot);\n\t\t\t}\n\t\t\tthis.ikConstraints = new Array();\n\t\t\tfor (var i = 0; i < data.ikConstraints.length; i++) {\n\t\t\t\tvar ikConstraintData = data.ikConstraints[i];\n\t\t\t\tthis.ikConstraints.push(new spine.IkConstraint(ikConstraintData, this));\n\t\t\t}\n\t\t\tthis.transformConstraints = new Array();\n\t\t\tfor (var i = 0; i < data.transformConstraints.length; i++) {\n\t\t\t\tvar transformConstraintData = data.transformConstraints[i];\n\t\t\t\tthis.transformConstraints.push(new spine.TransformConstraint(transformConstraintData, this));\n\t\t\t}\n\t\t\tthis.pathConstraints = new Array();\n\t\t\tfor (var i = 0; i < data.pathConstraints.length; i++) {\n\t\t\t\tvar pathConstraintData = data.pathConstraints[i];\n\t\t\t\tthis.pathConstraints.push(new spine.PathConstraint(pathConstraintData, this));\n\t\t\t}\n\t\t\tthis.color = new spine.Color(1, 1, 1, 1);\n\t\t\tthis.updateCache();\n\t\t}\n\t\tSkeleton.prototype.updateCache = function () {\n\t\t\tvar updateCache = this._updateCache;\n\t\t\tupdateCache.length = 0;\n\t\t\tthis.updateCacheReset.length = 0;\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++)\n\t\t\t\tbones[i].sorted = false;\n\t\t\tvar ikConstraints = this.ikConstraints;\n\t\t\tvar transformConstraints = this.transformConstraints;\n\t\t\tvar pathConstraints = this.pathConstraints;\n\t\t\tvar ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length;\n\t\t\tvar constraintCount = ikCount + transformCount + pathCount;\n\t\t\touter: for (var i = 0; i < constraintCount; i++) {\n\t\t\t\tfor (var ii = 0; ii < ikCount; ii++) {\n\t\t\t\t\tvar constraint = ikConstraints[ii];\n\t\t\t\t\tif (constraint.data.order == i) {\n\t\t\t\t\t\tthis.sortIkConstraint(constraint);\n\t\t\t\t\t\tcontinue outer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (var ii = 0; ii < transformCount; ii++) {\n\t\t\t\t\tvar constraint = transformConstraints[ii];\n\t\t\t\t\tif (constraint.data.order == i) {\n\t\t\t\t\t\tthis.sortTransformConstraint(constraint);\n\t\t\t\t\t\tcontinue outer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (var ii = 0; ii < pathCount; ii++) {\n\t\t\t\t\tvar constraint = pathConstraints[ii];\n\t\t\t\t\tif (constraint.data.order == i) {\n\t\t\t\t\t\tthis.sortPathConstraint(constraint);\n\t\t\t\t\t\tcontinue outer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++)\n\t\t\t\tthis.sortBone(bones[i]);\n\t\t};\n\t\tSkeleton.prototype.sortIkConstraint = function (constraint) {\n\t\t\tvar target = constraint.target;\n\t\t\tthis.sortBone(target);\n\t\t\tvar constrained = constraint.bones;\n\t\t\tvar parent = constrained[0];\n\t\t\tthis.sortBone(parent);\n\t\t\tif (constrained.length > 1) {\n\t\t\t\tvar child = constrained[constrained.length - 1];\n\t\t\t\tif (!(this._updateCache.indexOf(child) > -1))\n\t\t\t\t\tthis.updateCacheReset.push(child);\n\t\t\t}\n\t\t\tthis._updateCache.push(constraint);\n\t\t\tthis.sortReset(parent.children);\n\t\t\tconstrained[constrained.length - 1].sorted = true;\n\t\t};\n\t\tSkeleton.prototype.sortPathConstraint = function (constraint) {\n\t\t\tvar slot = constraint.target;\n\t\t\tvar slotIndex = slot.data.index;\n\t\t\tvar slotBone = slot.bone;\n\t\t\tif (this.skin != null)\n\t\t\t\tthis.sortPathConstraintAttachment(this.skin, slotIndex, slotBone);\n\t\t\tif (this.data.defaultSkin != null && this.data.defaultSkin != this.skin)\n\t\t\t\tthis.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone);\n\t\t\tfor (var i = 0, n = this.data.skins.length; i < n; i++)\n\t\t\t\tthis.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone);\n\t\t\tvar attachment = slot.getAttachment();\n\t\t\tif (attachment instanceof spine.PathAttachment)\n\t\t\t\tthis.sortPathConstraintAttachmentWith(attachment, slotBone);\n\t\t\tvar constrained = constraint.bones;\n\t\t\tvar boneCount = constrained.length;\n\t\t\tfor (var i = 0; i < boneCount; i++)\n\t\t\t\tthis.sortBone(constrained[i]);\n\t\t\tthis._updateCache.push(constraint);\n\t\t\tfor (var i = 0; i < boneCount; i++)\n\t\t\t\tthis.sortReset(constrained[i].children);\n\t\t\tfor (var i = 0; i < boneCount; i++)\n\t\t\t\tconstrained[i].sorted = true;\n\t\t};\n\t\tSkeleton.prototype.sortTransformConstraint = function (constraint) {\n\t\t\tthis.sortBone(constraint.target);\n\t\t\tvar constrained = constraint.bones;\n\t\t\tvar boneCount = constrained.length;\n\t\t\tif (constraint.data.local) {\n\t\t\t\tfor (var i = 0; i < boneCount; i++) {\n\t\t\t\t\tvar child = constrained[i];\n\t\t\t\t\tthis.sortBone(child.parent);\n\t\t\t\t\tif (!(this._updateCache.indexOf(child) > -1))\n\t\t\t\t\t\tthis.updateCacheReset.push(child);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (var i = 0; i < boneCount; i++) {\n\t\t\t\t\tthis.sortBone(constrained[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._updateCache.push(constraint);\n\t\t\tfor (var ii = 0; ii < boneCount; ii++)\n\t\t\t\tthis.sortReset(constrained[ii].children);\n\t\t\tfor (var ii = 0; ii < boneCount; ii++)\n\t\t\t\tconstrained[ii].sorted = true;\n\t\t};\n\t\tSkeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) {\n\t\t\tvar attachments = skin.attachments[slotIndex];\n\t\t\tif (!attachments)\n\t\t\t\treturn;\n\t\t\tfor (var key in attachments) {\n\t\t\t\tthis.sortPathConstraintAttachmentWith(attachments[key], slotBone);\n\t\t\t}\n\t\t};\n\t\tSkeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) {\n\t\t\tif (!(attachment instanceof spine.PathAttachment))\n\t\t\t\treturn;\n\t\t\tvar pathBones = attachment.bones;\n\t\t\tif (pathBones == null)\n\t\t\t\tthis.sortBone(slotBone);\n\t\t\telse {\n\t\t\t\tvar bones = this.bones;\n\t\t\t\tvar i = 0;\n\t\t\t\twhile (i < pathBones.length) {\n\t\t\t\t\tvar boneCount = pathBones[i++];\n\t\t\t\t\tfor (var n = i + boneCount; i < n; i++) {\n\t\t\t\t\t\tvar boneIndex = pathBones[i];\n\t\t\t\t\t\tthis.sortBone(bones[boneIndex]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tSkeleton.prototype.sortBone = function (bone) {\n\t\t\tif (bone.sorted)\n\t\t\t\treturn;\n\t\t\tvar parent = bone.parent;\n\t\t\tif (parent != null)\n\t\t\t\tthis.sortBone(parent);\n\t\t\tbone.sorted = true;\n\t\t\tthis._updateCache.push(bone);\n\t\t};\n\t\tSkeleton.prototype.sortReset = function (bones) {\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++) {\n\t\t\t\tvar bone = bones[i];\n\t\t\t\tif (bone.sorted)\n\t\t\t\t\tthis.sortReset(bone.children);\n\t\t\t\tbone.sorted = false;\n\t\t\t}\n\t\t};\n\t\tSkeleton.prototype.updateWorldTransform = function () {\n\t\t\tvar updateCacheReset = this.updateCacheReset;\n\t\t\tfor (var i = 0, n = updateCacheReset.length; i < n; i++) {\n\t\t\t\tvar bone = updateCacheReset[i];\n\t\t\t\tbone.ax = bone.x;\n\t\t\t\tbone.ay = bone.y;\n\t\t\t\tbone.arotation = bone.rotation;\n\t\t\t\tbone.ascaleX = bone.scaleX;\n\t\t\t\tbone.ascaleY = bone.scaleY;\n\t\t\t\tbone.ashearX = bone.shearX;\n\t\t\t\tbone.ashearY = bone.shearY;\n\t\t\t\tbone.appliedValid = true;\n\t\t\t}\n\t\t\tvar updateCache = this._updateCache;\n\t\t\tfor (var i = 0, n = updateCache.length; i < n; i++)\n\t\t\t\tupdateCache[i].update();\n\t\t};\n\t\tSkeleton.prototype.setToSetupPose = function () {\n\t\t\tthis.setBonesToSetupPose();\n\t\t\tthis.setSlotsToSetupPose();\n\t\t};\n\t\tSkeleton.prototype.setBonesToSetupPose = function () {\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++)\n\t\t\t\tbones[i].setToSetupPose();\n\t\t\tvar ikConstraints = this.ikConstraints;\n\t\t\tfor (var i = 0, n = ikConstraints.length; i < n; i++) {\n\t\t\t\tvar constraint = ikConstraints[i];\n\t\t\t\tconstraint.bendDirection = constraint.data.bendDirection;\n\t\t\t\tconstraint.mix = constraint.data.mix;\n\t\t\t}\n\t\t\tvar transformConstraints = this.transformConstraints;\n\t\t\tfor (var i = 0, n = transformConstraints.length; i < n; i++) {\n\t\t\t\tvar constraint = transformConstraints[i];\n\t\t\t\tvar data = constraint.data;\n\t\t\t\tconstraint.rotateMix = data.rotateMix;\n\t\t\t\tconstraint.translateMix = data.translateMix;\n\t\t\t\tconstraint.scaleMix = data.scaleMix;\n\t\t\t\tconstraint.shearMix = data.shearMix;\n\t\t\t}\n\t\t\tvar pathConstraints = this.pathConstraints;\n\t\t\tfor (var i = 0, n = pathConstraints.length; i < n; i++) {\n\t\t\t\tvar constraint = pathConstraints[i];\n\t\t\t\tvar data = constraint.data;\n\t\t\t\tconstraint.position = data.position;\n\t\t\t\tconstraint.spacing = data.spacing;\n\t\t\t\tconstraint.rotateMix = data.rotateMix;\n\t\t\t\tconstraint.translateMix = data.translateMix;\n\t\t\t}\n\t\t};\n\t\tSkeleton.prototype.setSlotsToSetupPose = function () {\n\t\t\tvar slots = this.slots;\n\t\t\tspine.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length);\n\t\t\tfor (var i = 0, n = slots.length; i < n; i++)\n\t\t\t\tslots[i].setToSetupPose();\n\t\t};\n\t\tSkeleton.prototype.getRootBone = function () {\n\t\t\tif (this.bones.length == 0)\n\t\t\t\treturn null;\n\t\t\treturn this.bones[0];\n\t\t};\n\t\tSkeleton.prototype.findBone = function (boneName) {\n\t\t\tif (boneName == null)\n\t\t\t\tthrow new Error(\"boneName cannot be null.\");\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++) {\n\t\t\t\tvar bone = bones[i];\n\t\t\t\tif (bone.data.name == boneName)\n\t\t\t\t\treturn bone;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeleton.prototype.findBoneIndex = function (boneName) {\n\t\t\tif (boneName == null)\n\t\t\t\tthrow new Error(\"boneName cannot be null.\");\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++)\n\t\t\t\tif (bones[i].data.name == boneName)\n\t\t\t\t\treturn i;\n\t\t\treturn -1;\n\t\t};\n\t\tSkeleton.prototype.findSlot = function (slotName) {\n\t\t\tif (slotName == null)\n\t\t\t\tthrow new Error(\"slotName cannot be null.\");\n\t\t\tvar slots = this.slots;\n\t\t\tfor (var i = 0, n = slots.length; i < n; i++) {\n\t\t\t\tvar slot = slots[i];\n\t\t\t\tif (slot.data.name == slotName)\n\t\t\t\t\treturn slot;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeleton.prototype.findSlotIndex = function (slotName) {\n\t\t\tif (slotName == null)\n\t\t\t\tthrow new Error(\"slotName cannot be null.\");\n\t\t\tvar slots = this.slots;\n\t\t\tfor (var i = 0, n = slots.length; i < n; i++)\n\t\t\t\tif (slots[i].data.name == slotName)\n\t\t\t\t\treturn i;\n\t\t\treturn -1;\n\t\t};\n\t\tSkeleton.prototype.setSkinByName = function (skinName) {\n\t\t\tvar skin = this.data.findSkin(skinName);\n\t\t\tif (skin == null)\n\t\t\t\tthrow new Error(\"Skin not found: \" + skinName);\n\t\t\tthis.setSkin(skin);\n\t\t};\n\t\tSkeleton.prototype.setSkin = function (newSkin) {\n\t\t\tif (newSkin != null) {\n\t\t\t\tif (this.skin != null)\n\t\t\t\t\tnewSkin.attachAll(this, this.skin);\n\t\t\t\telse {\n\t\t\t\t\tvar slots = this.slots;\n\t\t\t\t\tfor (var i = 0, n = slots.length; i < n; i++) {\n\t\t\t\t\t\tvar slot = slots[i];\n\t\t\t\t\t\tvar name_1 = slot.data.attachmentName;\n\t\t\t\t\t\tif (name_1 != null) {\n\t\t\t\t\t\t\tvar attachment = newSkin.getAttachment(i, name_1);\n\t\t\t\t\t\t\tif (attachment != null)\n\t\t\t\t\t\t\t\tslot.setAttachment(attachment);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.skin = newSkin;\n\t\t};\n\t\tSkeleton.prototype.getAttachmentByName = function (slotName, attachmentName) {\n\t\t\treturn this.getAttachment(this.data.findSlotIndex(slotName), attachmentName);\n\t\t};\n\t\tSkeleton.prototype.getAttachment = function (slotIndex, attachmentName) {\n\t\t\tif (attachmentName == null)\n\t\t\t\tthrow new Error(\"attachmentName cannot be null.\");\n\t\t\tif (this.skin != null) {\n\t\t\t\tvar attachment = this.skin.getAttachment(slotIndex, attachmentName);\n\t\t\t\tif (attachment != null)\n\t\t\t\t\treturn attachment;\n\t\t\t}\n\t\t\tif (this.data.defaultSkin != null)\n\t\t\t\treturn this.data.defaultSkin.getAttachment(slotIndex, attachmentName);\n\t\t\treturn null;\n\t\t};\n\t\tSkeleton.prototype.setAttachment = function (slotName, attachmentName) {\n\t\t\tif (slotName == null)\n\t\t\t\tthrow new Error(\"slotName cannot be null.\");\n\t\t\tvar slots = this.slots;\n\t\t\tfor (var i = 0, n = slots.length; i < n; i++) {\n\t\t\t\tvar slot = slots[i];\n\t\t\t\tif (slot.data.name == slotName) {\n\t\t\t\t\tvar attachment = null;\n\t\t\t\t\tif (attachmentName != null) {\n\t\t\t\t\t\tattachment = this.getAttachment(i, attachmentName);\n\t\t\t\t\t\tif (attachment == null)\n\t\t\t\t\t\t\tthrow new Error(\"Attachment not found: \" + attachmentName + \", for slot: \" + slotName);\n\t\t\t\t\t}\n\t\t\t\t\tslot.setAttachment(attachment);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new Error(\"Slot not found: \" + slotName);\n\t\t};\n\t\tSkeleton.prototype.findIkConstraint = function (constraintName) {\n\t\t\tif (constraintName == null)\n\t\t\t\tthrow new Error(\"constraintName cannot be null.\");\n\t\t\tvar ikConstraints = this.ikConstraints;\n\t\t\tfor (var i = 0, n = ikConstraints.length; i < n; i++) {\n\t\t\t\tvar ikConstraint = ikConstraints[i];\n\t\t\t\tif (ikConstraint.data.name == constraintName)\n\t\t\t\t\treturn ikConstraint;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeleton.prototype.findTransformConstraint = function (constraintName) {\n\t\t\tif (constraintName == null)\n\t\t\t\tthrow new Error(\"constraintName cannot be null.\");\n\t\t\tvar transformConstraints = this.transformConstraints;\n\t\t\tfor (var i = 0, n = transformConstraints.length; i < n; i++) {\n\t\t\t\tvar constraint = transformConstraints[i];\n\t\t\t\tif (constraint.data.name == constraintName)\n\t\t\t\t\treturn constraint;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeleton.prototype.findPathConstraint = function (constraintName) {\n\t\t\tif (constraintName == null)\n\t\t\t\tthrow new Error(\"constraintName cannot be null.\");\n\t\t\tvar pathConstraints = this.pathConstraints;\n\t\t\tfor (var i = 0, n = pathConstraints.length; i < n; i++) {\n\t\t\t\tvar constraint = pathConstraints[i];\n\t\t\t\tif (constraint.data.name == constraintName)\n\t\t\t\t\treturn constraint;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeleton.prototype.getBounds = function (offset, size, temp) {\n\t\t\tif (offset == null)\n\t\t\t\tthrow new Error(\"offset cannot be null.\");\n\t\t\tif (size == null)\n\t\t\t\tthrow new Error(\"size cannot be null.\");\n\t\t\tvar drawOrder = this.drawOrder;\n\t\t\tvar minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;\n\t\t\tfor (var i = 0, n = drawOrder.length; i < n; i++) {\n\t\t\t\tvar slot = drawOrder[i];\n\t\t\t\tvar verticesLength = 0;\n\t\t\t\tvar vertices = null;\n\t\t\t\tvar attachment = slot.getAttachment();\n\t\t\t\tif (attachment instanceof spine.RegionAttachment) {\n\t\t\t\t\tverticesLength = 8;\n\t\t\t\t\tvertices = spine.Utils.setArraySize(temp, verticesLength, 0);\n\t\t\t\t\tattachment.computeWorldVertices(slot.bone, vertices, 0, 2);\n\t\t\t\t}\n\t\t\t\telse if (attachment instanceof spine.MeshAttachment) {\n\t\t\t\t\tvar mesh = attachment;\n\t\t\t\t\tverticesLength = mesh.worldVerticesLength;\n\t\t\t\t\tvertices = spine.Utils.setArraySize(temp, verticesLength, 0);\n\t\t\t\t\tmesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);\n\t\t\t\t}\n\t\t\t\tif (vertices != null) {\n\t\t\t\t\tfor (var ii = 0, nn = vertices.length; ii < nn; ii += 2) {\n\t\t\t\t\t\tvar x = vertices[ii], y = vertices[ii + 1];\n\t\t\t\t\t\tminX = Math.min(minX, x);\n\t\t\t\t\t\tminY = Math.min(minY, y);\n\t\t\t\t\t\tmaxX = Math.max(maxX, x);\n\t\t\t\t\t\tmaxY = Math.max(maxY, y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\toffset.set(minX, minY);\n\t\t\tsize.set(maxX - minX, maxY - minY);\n\t\t};\n\t\tSkeleton.prototype.update = function (delta) {\n\t\t\tthis.time += delta;\n\t\t};\n\t\treturn Skeleton;\n\t}());\n\tspine.Skeleton = Skeleton;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar SkeletonBounds = (function () {\n\t\tfunction SkeletonBounds() {\n\t\t\tthis.minX = 0;\n\t\t\tthis.minY = 0;\n\t\t\tthis.maxX = 0;\n\t\t\tthis.maxY = 0;\n\t\t\tthis.boundingBoxes = new Array();\n\t\t\tthis.polygons = new Array();\n\t\t\tthis.polygonPool = new spine.Pool(function () {\n\t\t\t\treturn spine.Utils.newFloatArray(16);\n\t\t\t});\n\t\t}\n\t\tSkeletonBounds.prototype.update = function (skeleton, updateAabb) {\n\t\t\tif (skeleton == null)\n\t\t\t\tthrow new Error(\"skeleton cannot be null.\");\n\t\t\tvar boundingBoxes = this.boundingBoxes;\n\t\t\tvar polygons = this.polygons;\n\t\t\tvar polygonPool = this.polygonPool;\n\t\t\tvar slots = skeleton.slots;\n\t\t\tvar slotCount = slots.length;\n\t\t\tboundingBoxes.length = 0;\n\t\t\tpolygonPool.freeAll(polygons);\n\t\t\tpolygons.length = 0;\n\t\t\tfor (var i = 0; i < slotCount; i++) {\n\t\t\t\tvar slot = slots[i];\n\t\t\t\tvar attachment = slot.getAttachment();\n\t\t\t\tif (attachment instanceof spine.BoundingBoxAttachment) {\n\t\t\t\t\tvar boundingBox = attachment;\n\t\t\t\t\tboundingBoxes.push(boundingBox);\n\t\t\t\t\tvar polygon = polygonPool.obtain();\n\t\t\t\t\tif (polygon.length != boundingBox.worldVerticesLength) {\n\t\t\t\t\t\tpolygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength);\n\t\t\t\t\t}\n\t\t\t\t\tpolygons.push(polygon);\n\t\t\t\t\tboundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (updateAabb) {\n\t\t\t\tthis.aabbCompute();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.minX = Number.POSITIVE_INFINITY;\n\t\t\t\tthis.minY = Number.POSITIVE_INFINITY;\n\t\t\t\tthis.maxX = Number.NEGATIVE_INFINITY;\n\t\t\t\tthis.maxY = Number.NEGATIVE_INFINITY;\n\t\t\t}\n\t\t};\n\t\tSkeletonBounds.prototype.aabbCompute = function () {\n\t\t\tvar minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;\n\t\t\tvar polygons = this.polygons;\n\t\t\tfor (var i = 0, n = polygons.length; i < n; i++) {\n\t\t\t\tvar polygon = polygons[i];\n\t\t\t\tvar vertices = polygon;\n\t\t\t\tfor (var ii = 0, nn = polygon.length; ii < nn; ii += 2) {\n\t\t\t\t\tvar x = vertices[ii];\n\t\t\t\t\tvar y = vertices[ii + 1];\n\t\t\t\t\tminX = Math.min(minX, x);\n\t\t\t\t\tminY = Math.min(minY, y);\n\t\t\t\t\tmaxX = Math.max(maxX, x);\n\t\t\t\t\tmaxY = Math.max(maxY, y);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.minX = minX;\n\t\t\tthis.minY = minY;\n\t\t\tthis.maxX = maxX;\n\t\t\tthis.maxY = maxY;\n\t\t};\n\t\tSkeletonBounds.prototype.aabbContainsPoint = function (x, y) {\n\t\t\treturn x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY;\n\t\t};\n\t\tSkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) {\n\t\t\tvar minX = this.minX;\n\t\t\tvar minY = this.minY;\n\t\t\tvar maxX = this.maxX;\n\t\t\tvar maxY = this.maxY;\n\t\t\tif ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY))\n\t\t\t\treturn false;\n\t\t\tvar m = (y2 - y1) / (x2 - x1);\n\t\t\tvar y = m * (minX - x1) + y1;\n\t\t\tif (y > minY && y < maxY)\n\t\t\t\treturn true;\n\t\t\ty = m * (maxX - x1) + y1;\n\t\t\tif (y > minY && y < maxY)\n\t\t\t\treturn true;\n\t\t\tvar x = (minY - y1) / m + x1;\n\t\t\tif (x > minX && x < maxX)\n\t\t\t\treturn true;\n\t\t\tx = (maxY - y1) / m + x1;\n\t\t\tif (x > minX && x < maxX)\n\t\t\t\treturn true;\n\t\t\treturn false;\n\t\t};\n\t\tSkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) {\n\t\t\treturn this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY;\n\t\t};\n\t\tSkeletonBounds.prototype.containsPoint = function (x, y) {\n\t\t\tvar polygons = this.polygons;\n\t\t\tfor (var i = 0, n = polygons.length; i < n; i++)\n\t\t\t\tif (this.containsPointPolygon(polygons[i], x, y))\n\t\t\t\t\treturn this.boundingBoxes[i];\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) {\n\t\t\tvar vertices = polygon;\n\t\t\tvar nn = polygon.length;\n\t\t\tvar prevIndex = nn - 2;\n\t\t\tvar inside = false;\n\t\t\tfor (var ii = 0; ii < nn; ii += 2) {\n\t\t\t\tvar vertexY = vertices[ii + 1];\n\t\t\t\tvar prevY = vertices[prevIndex + 1];\n\t\t\t\tif ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) {\n\t\t\t\t\tvar vertexX = vertices[ii];\n\t\t\t\t\tif (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x)\n\t\t\t\t\t\tinside = !inside;\n\t\t\t\t}\n\t\t\t\tprevIndex = ii;\n\t\t\t}\n\t\t\treturn inside;\n\t\t};\n\t\tSkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) {\n\t\t\tvar polygons = this.polygons;\n\t\t\tfor (var i = 0, n = polygons.length; i < n; i++)\n\t\t\t\tif (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2))\n\t\t\t\t\treturn this.boundingBoxes[i];\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) {\n\t\t\tvar vertices = polygon;\n\t\t\tvar nn = polygon.length;\n\t\t\tvar width12 = x1 - x2, height12 = y1 - y2;\n\t\t\tvar det1 = x1 * y2 - y1 * x2;\n\t\t\tvar x3 = vertices[nn - 2], y3 = vertices[nn - 1];\n\t\t\tfor (var ii = 0; ii < nn; ii += 2) {\n\t\t\t\tvar x4 = vertices[ii], y4 = vertices[ii + 1];\n\t\t\t\tvar det2 = x3 * y4 - y3 * x4;\n\t\t\t\tvar width34 = x3 - x4, height34 = y3 - y4;\n\t\t\t\tvar det3 = width12 * height34 - height12 * width34;\n\t\t\t\tvar x = (det1 * width34 - width12 * det2) / det3;\n\t\t\t\tif (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) {\n\t\t\t\t\tvar y = (det1 * height34 - height12 * det2) / det3;\n\t\t\t\t\tif (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1)))\n\t\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tx3 = x4;\n\t\t\t\ty3 = y4;\n\t\t\t}\n\t\t\treturn false;\n\t\t};\n\t\tSkeletonBounds.prototype.getPolygon = function (boundingBox) {\n\t\t\tif (boundingBox == null)\n\t\t\t\tthrow new Error(\"boundingBox cannot be null.\");\n\t\t\tvar index = this.boundingBoxes.indexOf(boundingBox);\n\t\t\treturn index == -1 ? null : this.polygons[index];\n\t\t};\n\t\tSkeletonBounds.prototype.getWidth = function () {\n\t\t\treturn this.maxX - this.minX;\n\t\t};\n\t\tSkeletonBounds.prototype.getHeight = function () {\n\t\t\treturn this.maxY - this.minY;\n\t\t};\n\t\treturn SkeletonBounds;\n\t}());\n\tspine.SkeletonBounds = SkeletonBounds;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar SkeletonClipping = (function () {\n\t\tfunction SkeletonClipping() {\n\t\t\tthis.triangulator = new spine.Triangulator();\n\t\t\tthis.clippingPolygon = new Array();\n\t\t\tthis.clipOutput = new Array();\n\t\t\tthis.clippedVertices = new Array();\n\t\t\tthis.clippedTriangles = new Array();\n\t\t\tthis.scratch = new Array();\n\t\t}\n\t\tSkeletonClipping.prototype.clipStart = function (slot, clip) {\n\t\t\tif (this.clipAttachment != null)\n\t\t\t\treturn 0;\n\t\t\tthis.clipAttachment = clip;\n\t\t\tvar n = clip.worldVerticesLength;\n\t\t\tvar vertices = spine.Utils.setArraySize(this.clippingPolygon, n);\n\t\t\tclip.computeWorldVertices(slot, 0, n, vertices, 0, 2);\n\t\t\tvar clippingPolygon = this.clippingPolygon;\n\t\t\tSkeletonClipping.makeClockwise(clippingPolygon);\n\t\t\tvar clippingPolygons = this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon));\n\t\t\tfor (var i = 0, n_1 = clippingPolygons.length; i < n_1; i++) {\n\t\t\t\tvar polygon = clippingPolygons[i];\n\t\t\t\tSkeletonClipping.makeClockwise(polygon);\n\t\t\t\tpolygon.push(polygon[0]);\n\t\t\t\tpolygon.push(polygon[1]);\n\t\t\t}\n\t\t\treturn clippingPolygons.length;\n\t\t};\n\t\tSkeletonClipping.prototype.clipEndWithSlot = function (slot) {\n\t\t\tif (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data)\n\t\t\t\tthis.clipEnd();\n\t\t};\n\t\tSkeletonClipping.prototype.clipEnd = function () {\n\t\t\tif (this.clipAttachment == null)\n\t\t\t\treturn;\n\t\t\tthis.clipAttachment = null;\n\t\t\tthis.clippingPolygons = null;\n\t\t\tthis.clippedVertices.length = 0;\n\t\t\tthis.clippedTriangles.length = 0;\n\t\t\tthis.clippingPolygon.length = 0;\n\t\t};\n\t\tSkeletonClipping.prototype.isClipping = function () {\n\t\t\treturn this.clipAttachment != null;\n\t\t};\n\t\tSkeletonClipping.prototype.clipTriangles = function (vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) {\n\t\t\tvar clipOutput = this.clipOutput, clippedVertices = this.clippedVertices;\n\t\t\tvar clippedTriangles = this.clippedTriangles;\n\t\t\tvar polygons = this.clippingPolygons;\n\t\t\tvar polygonsCount = this.clippingPolygons.length;\n\t\t\tvar vertexSize = twoColor ? 12 : 8;\n\t\t\tvar index = 0;\n\t\t\tclippedVertices.length = 0;\n\t\t\tclippedTriangles.length = 0;\n\t\t\touter: for (var i = 0; i < trianglesLength; i += 3) {\n\t\t\t\tvar vertexOffset = triangles[i] << 1;\n\t\t\t\tvar x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];\n\t\t\t\tvar u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];\n\t\t\t\tvertexOffset = triangles[i + 1] << 1;\n\t\t\t\tvar x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1];\n\t\t\t\tvar u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1];\n\t\t\t\tvertexOffset = triangles[i + 2] << 1;\n\t\t\t\tvar x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];\n\t\t\t\tvar u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];\n\t\t\t\tfor (var p = 0; p < polygonsCount; p++) {\n\t\t\t\t\tvar s = clippedVertices.length;\n\t\t\t\t\tif (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) {\n\t\t\t\t\t\tvar clipOutputLength = clipOutput.length;\n\t\t\t\t\t\tif (clipOutputLength == 0)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tvar d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;\n\t\t\t\t\t\tvar d = 1 / (d0 * d2 + d1 * (y1 - y3));\n\t\t\t\t\t\tvar clipOutputCount = clipOutputLength >> 1;\n\t\t\t\t\t\tvar clipOutputItems = this.clipOutput;\n\t\t\t\t\t\tvar clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize);\n\t\t\t\t\t\tfor (var ii = 0; ii < clipOutputLength; ii += 2) {\n\t\t\t\t\t\t\tvar x = clipOutputItems[ii], y = clipOutputItems[ii + 1];\n\t\t\t\t\t\t\tclippedVerticesItems[s] = x;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 1] = y;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 2] = light.r;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 3] = light.g;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 4] = light.b;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 5] = light.a;\n\t\t\t\t\t\t\tvar c0 = x - x3, c1 = y - y3;\n\t\t\t\t\t\t\tvar a = (d0 * c0 + d1 * c1) * d;\n\t\t\t\t\t\t\tvar b = (d4 * c0 + d2 * c1) * d;\n\t\t\t\t\t\t\tvar c = 1 - a - b;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c;\n\t\t\t\t\t\t\tif (twoColor) {\n\t\t\t\t\t\t\t\tclippedVerticesItems[s + 8] = dark.r;\n\t\t\t\t\t\t\t\tclippedVerticesItems[s + 9] = dark.g;\n\t\t\t\t\t\t\t\tclippedVerticesItems[s + 10] = dark.b;\n\t\t\t\t\t\t\t\tclippedVerticesItems[s + 11] = dark.a;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ts += vertexSize;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ts = clippedTriangles.length;\n\t\t\t\t\t\tvar clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2));\n\t\t\t\t\t\tclipOutputCount--;\n\t\t\t\t\t\tfor (var ii = 1; ii < clipOutputCount; ii++) {\n\t\t\t\t\t\t\tclippedTrianglesItems[s] = index;\n\t\t\t\t\t\t\tclippedTrianglesItems[s + 1] = (index + ii);\n\t\t\t\t\t\t\tclippedTrianglesItems[s + 2] = (index + ii + 1);\n\t\t\t\t\t\t\ts += 3;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tindex += clipOutputCount + 1;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tvar clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + 3 * vertexSize);\n\t\t\t\t\t\tclippedVerticesItems[s] = x1;\n\t\t\t\t\t\tclippedVerticesItems[s + 1] = y1;\n\t\t\t\t\t\tclippedVerticesItems[s + 2] = light.r;\n\t\t\t\t\t\tclippedVerticesItems[s + 3] = light.g;\n\t\t\t\t\t\tclippedVerticesItems[s + 4] = light.b;\n\t\t\t\t\t\tclippedVerticesItems[s + 5] = light.a;\n\t\t\t\t\t\tif (!twoColor) {\n\t\t\t\t\t\t\tclippedVerticesItems[s + 6] = u1;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 7] = v1;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 8] = x2;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 9] = y2;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 10] = light.r;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 11] = light.g;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 12] = light.b;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 13] = light.a;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 14] = u2;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 15] = v2;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 16] = x3;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 17] = y3;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 18] = light.r;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 19] = light.g;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 20] = light.b;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 21] = light.a;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 22] = u3;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 23] = v3;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tclippedVerticesItems[s + 6] = u1;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 7] = v1;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 8] = dark.r;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 9] = dark.g;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 10] = dark.b;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 11] = dark.a;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 12] = x2;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 13] = y2;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 14] = light.r;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 15] = light.g;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 16] = light.b;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 17] = light.a;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 18] = u2;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 19] = v2;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 20] = dark.r;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 21] = dark.g;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 22] = dark.b;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 23] = dark.a;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 24] = x3;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 25] = y3;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 26] = light.r;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 27] = light.g;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 28] = light.b;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 29] = light.a;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 30] = u3;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 31] = v3;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 32] = dark.r;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 33] = dark.g;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 34] = dark.b;\n\t\t\t\t\t\t\tclippedVerticesItems[s + 35] = dark.a;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ts = clippedTriangles.length;\n\t\t\t\t\t\tvar clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3);\n\t\t\t\t\t\tclippedTrianglesItems[s] = index;\n\t\t\t\t\t\tclippedTrianglesItems[s + 1] = (index + 1);\n\t\t\t\t\t\tclippedTrianglesItems[s + 2] = (index + 2);\n\t\t\t\t\t\tindex += 3;\n\t\t\t\t\t\tcontinue outer;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tSkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) {\n\t\t\tvar originalOutput = output;\n\t\t\tvar clipped = false;\n\t\t\tvar input = null;\n\t\t\tif (clippingArea.length % 4 >= 2) {\n\t\t\t\tinput = output;\n\t\t\t\toutput = this.scratch;\n\t\t\t}\n\t\t\telse\n\t\t\t\tinput = this.scratch;\n\t\t\tinput.length = 0;\n\t\t\tinput.push(x1);\n\t\t\tinput.push(y1);\n\t\t\tinput.push(x2);\n\t\t\tinput.push(y2);\n\t\t\tinput.push(x3);\n\t\t\tinput.push(y3);\n\t\t\tinput.push(x1);\n\t\t\tinput.push(y1);\n\t\t\toutput.length = 0;\n\t\t\tvar clippingVertices = clippingArea;\n\t\t\tvar clippingVerticesLast = clippingArea.length - 4;\n\t\t\tfor (var i = 0;; i += 2) {\n\t\t\t\tvar edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1];\n\t\t\t\tvar edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3];\n\t\t\t\tvar deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;\n\t\t\t\tvar inputVertices = input;\n\t\t\t\tvar inputVerticesLength = input.length - 2, outputStart = output.length;\n\t\t\t\tfor (var ii = 0; ii < inputVerticesLength; ii += 2) {\n\t\t\t\t\tvar inputX = inputVertices[ii], inputY = inputVertices[ii + 1];\n\t\t\t\t\tvar inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];\n\t\t\t\t\tvar side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0;\n\t\t\t\t\tif (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) {\n\t\t\t\t\t\tif (side2) {\n\t\t\t\t\t\t\toutput.push(inputX2);\n\t\t\t\t\t\t\toutput.push(inputY2);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar c0 = inputY2 - inputY, c2 = inputX2 - inputX;\n\t\t\t\t\t\tvar ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY));\n\t\t\t\t\t\toutput.push(edgeX + (edgeX2 - edgeX) * ua);\n\t\t\t\t\t\toutput.push(edgeY + (edgeY2 - edgeY) * ua);\n\t\t\t\t\t}\n\t\t\t\t\telse if (side2) {\n\t\t\t\t\t\tvar c0 = inputY2 - inputY, c2 = inputX2 - inputX;\n\t\t\t\t\t\tvar ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY));\n\t\t\t\t\t\toutput.push(edgeX + (edgeX2 - edgeX) * ua);\n\t\t\t\t\t\toutput.push(edgeY + (edgeY2 - edgeY) * ua);\n\t\t\t\t\t\toutput.push(inputX2);\n\t\t\t\t\t\toutput.push(inputY2);\n\t\t\t\t\t}\n\t\t\t\t\tclipped = true;\n\t\t\t\t}\n\t\t\t\tif (outputStart == output.length) {\n\t\t\t\t\toriginalOutput.length = 0;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\toutput.push(output[0]);\n\t\t\t\toutput.push(output[1]);\n\t\t\t\tif (i == clippingVerticesLast)\n\t\t\t\t\tbreak;\n\t\t\t\tvar temp = output;\n\t\t\t\toutput = input;\n\t\t\t\toutput.length = 0;\n\t\t\t\tinput = temp;\n\t\t\t}\n\t\t\tif (originalOutput != output) {\n\t\t\t\toriginalOutput.length = 0;\n\t\t\t\tfor (var i = 0, n = output.length - 2; i < n; i++)\n\t\t\t\t\toriginalOutput[i] = output[i];\n\t\t\t}\n\t\t\telse\n\t\t\t\toriginalOutput.length = originalOutput.length - 2;\n\t\t\treturn clipped;\n\t\t};\n\t\tSkeletonClipping.makeClockwise = function (polygon) {\n\t\t\tvar vertices = polygon;\n\t\t\tvar verticeslength = polygon.length;\n\t\t\tvar area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x = 0, p1y = 0, p2x = 0, p2y = 0;\n\t\t\tfor (var i = 0, n = verticeslength - 3; i < n; i += 2) {\n\t\t\t\tp1x = vertices[i];\n\t\t\t\tp1y = vertices[i + 1];\n\t\t\t\tp2x = vertices[i + 2];\n\t\t\t\tp2y = vertices[i + 3];\n\t\t\t\tarea += p1x * p2y - p2x * p1y;\n\t\t\t}\n\t\t\tif (area < 0)\n\t\t\t\treturn;\n\t\t\tfor (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) {\n\t\t\t\tvar x = vertices[i], y = vertices[i + 1];\n\t\t\t\tvar other = lastX - i;\n\t\t\t\tvertices[i] = vertices[other];\n\t\t\t\tvertices[i + 1] = vertices[other + 1];\n\t\t\t\tvertices[other] = x;\n\t\t\t\tvertices[other + 1] = y;\n\t\t\t}\n\t\t};\n\t\treturn SkeletonClipping;\n\t}());\n\tspine.SkeletonClipping = SkeletonClipping;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar SkeletonData = (function () {\n\t\tfunction SkeletonData() {\n\t\t\tthis.bones = new Array();\n\t\t\tthis.slots = new Array();\n\t\t\tthis.skins = new Array();\n\t\t\tthis.events = new Array();\n\t\t\tthis.animations = new Array();\n\t\t\tthis.ikConstraints = new Array();\n\t\t\tthis.transformConstraints = new Array();\n\t\t\tthis.pathConstraints = new Array();\n\t\t\tthis.fps = 0;\n\t\t}\n\t\tSkeletonData.prototype.findBone = function (boneName) {\n\t\t\tif (boneName == null)\n\t\t\t\tthrow new Error(\"boneName cannot be null.\");\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++) {\n\t\t\t\tvar bone = bones[i];\n\t\t\t\tif (bone.name == boneName)\n\t\t\t\t\treturn bone;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonData.prototype.findBoneIndex = function (boneName) {\n\t\t\tif (boneName == null)\n\t\t\t\tthrow new Error(\"boneName cannot be null.\");\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++)\n\t\t\t\tif (bones[i].name == boneName)\n\t\t\t\t\treturn i;\n\t\t\treturn -1;\n\t\t};\n\t\tSkeletonData.prototype.findSlot = function (slotName) {\n\t\t\tif (slotName == null)\n\t\t\t\tthrow new Error(\"slotName cannot be null.\");\n\t\t\tvar slots = this.slots;\n\t\t\tfor (var i = 0, n = slots.length; i < n; i++) {\n\t\t\t\tvar slot = slots[i];\n\t\t\t\tif (slot.name == slotName)\n\t\t\t\t\treturn slot;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonData.prototype.findSlotIndex = function (slotName) {\n\t\t\tif (slotName == null)\n\t\t\t\tthrow new Error(\"slotName cannot be null.\");\n\t\t\tvar slots = this.slots;\n\t\t\tfor (var i = 0, n = slots.length; i < n; i++)\n\t\t\t\tif (slots[i].name == slotName)\n\t\t\t\t\treturn i;\n\t\t\treturn -1;\n\t\t};\n\t\tSkeletonData.prototype.findSkin = function (skinName) {\n\t\t\tif (skinName == null)\n\t\t\t\tthrow new Error(\"skinName cannot be null.\");\n\t\t\tvar skins = this.skins;\n\t\t\tfor (var i = 0, n = skins.length; i < n; i++) {\n\t\t\t\tvar skin = skins[i];\n\t\t\t\tif (skin.name == skinName)\n\t\t\t\t\treturn skin;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonData.prototype.findEvent = function (eventDataName) {\n\t\t\tif (eventDataName == null)\n\t\t\t\tthrow new Error(\"eventDataName cannot be null.\");\n\t\t\tvar events = this.events;\n\t\t\tfor (var i = 0, n = events.length; i < n; i++) {\n\t\t\t\tvar event_4 = events[i];\n\t\t\t\tif (event_4.name == eventDataName)\n\t\t\t\t\treturn event_4;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonData.prototype.findAnimation = function (animationName) {\n\t\t\tif (animationName == null)\n\t\t\t\tthrow new Error(\"animationName cannot be null.\");\n\t\t\tvar animations = this.animations;\n\t\t\tfor (var i = 0, n = animations.length; i < n; i++) {\n\t\t\t\tvar animation = animations[i];\n\t\t\t\tif (animation.name == animationName)\n\t\t\t\t\treturn animation;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonData.prototype.findIkConstraint = function (constraintName) {\n\t\t\tif (constraintName == null)\n\t\t\t\tthrow new Error(\"constraintName cannot be null.\");\n\t\t\tvar ikConstraints = this.ikConstraints;\n\t\t\tfor (var i = 0, n = ikConstraints.length; i < n; i++) {\n\t\t\t\tvar constraint = ikConstraints[i];\n\t\t\t\tif (constraint.name == constraintName)\n\t\t\t\t\treturn constraint;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonData.prototype.findTransformConstraint = function (constraintName) {\n\t\t\tif (constraintName == null)\n\t\t\t\tthrow new Error(\"constraintName cannot be null.\");\n\t\t\tvar transformConstraints = this.transformConstraints;\n\t\t\tfor (var i = 0, n = transformConstraints.length; i < n; i++) {\n\t\t\t\tvar constraint = transformConstraints[i];\n\t\t\t\tif (constraint.name == constraintName)\n\t\t\t\t\treturn constraint;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonData.prototype.findPathConstraint = function (constraintName) {\n\t\t\tif (constraintName == null)\n\t\t\t\tthrow new Error(\"constraintName cannot be null.\");\n\t\t\tvar pathConstraints = this.pathConstraints;\n\t\t\tfor (var i = 0, n = pathConstraints.length; i < n; i++) {\n\t\t\t\tvar constraint = pathConstraints[i];\n\t\t\t\tif (constraint.name == constraintName)\n\t\t\t\t\treturn constraint;\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) {\n\t\t\tif (pathConstraintName == null)\n\t\t\t\tthrow new Error(\"pathConstraintName cannot be null.\");\n\t\t\tvar pathConstraints = this.pathConstraints;\n\t\t\tfor (var i = 0, n = pathConstraints.length; i < n; i++)\n\t\t\t\tif (pathConstraints[i].name == pathConstraintName)\n\t\t\t\t\treturn i;\n\t\t\treturn -1;\n\t\t};\n\t\treturn SkeletonData;\n\t}());\n\tspine.SkeletonData = SkeletonData;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar SkeletonJson = (function () {\n\t\tfunction SkeletonJson(attachmentLoader) {\n\t\t\tthis.scale = 1;\n\t\t\tthis.linkedMeshes = new Array();\n\t\t\tthis.attachmentLoader = attachmentLoader;\n\t\t}\n\t\tSkeletonJson.prototype.readSkeletonData = function (json) {\n\t\t\tvar scale = this.scale;\n\t\t\tvar skeletonData = new spine.SkeletonData();\n\t\t\tvar root = typeof (json) === \"string\" ? JSON.parse(json) : json;\n\t\t\tvar skeletonMap = root.skeleton;\n\t\t\tif (skeletonMap != null) {\n\t\t\t\tskeletonData.hash = skeletonMap.hash;\n\t\t\t\tskeletonData.version = skeletonMap.spine;\n\t\t\t\tskeletonData.width = skeletonMap.width;\n\t\t\t\tskeletonData.height = skeletonMap.height;\n\t\t\t\tskeletonData.fps = skeletonMap.fps;\n\t\t\t\tskeletonData.imagesPath = skeletonMap.images;\n\t\t\t}\n\t\t\tif (root.bones) {\n\t\t\t\tfor (var i = 0; i < root.bones.length; i++) {\n\t\t\t\t\tvar boneMap = root.bones[i];\n\t\t\t\t\tvar parent_2 = null;\n\t\t\t\t\tvar parentName = this.getValue(boneMap, \"parent\", null);\n\t\t\t\t\tif (parentName != null) {\n\t\t\t\t\t\tparent_2 = skeletonData.findBone(parentName);\n\t\t\t\t\t\tif (parent_2 == null)\n\t\t\t\t\t\t\tthrow new Error(\"Parent bone not found: \" + parentName);\n\t\t\t\t\t}\n\t\t\t\t\tvar data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_2);\n\t\t\t\t\tdata.length = this.getValue(boneMap, \"length\", 0) * scale;\n\t\t\t\t\tdata.x = this.getValue(boneMap, \"x\", 0) * scale;\n\t\t\t\t\tdata.y = this.getValue(boneMap, \"y\", 0) * scale;\n\t\t\t\t\tdata.rotation = this.getValue(boneMap, \"rotation\", 0);\n\t\t\t\t\tdata.scaleX = this.getValue(boneMap, \"scaleX\", 1);\n\t\t\t\t\tdata.scaleY = this.getValue(boneMap, \"scaleY\", 1);\n\t\t\t\t\tdata.shearX = this.getValue(boneMap, \"shearX\", 0);\n\t\t\t\t\tdata.shearY = this.getValue(boneMap, \"shearY\", 0);\n\t\t\t\t\tdata.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, \"transform\", \"normal\"));\n\t\t\t\t\tskeletonData.bones.push(data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (root.slots) {\n\t\t\t\tfor (var i = 0; i < root.slots.length; i++) {\n\t\t\t\t\tvar slotMap = root.slots[i];\n\t\t\t\t\tvar slotName = slotMap.name;\n\t\t\t\t\tvar boneName = slotMap.bone;\n\t\t\t\t\tvar boneData = skeletonData.findBone(boneName);\n\t\t\t\t\tif (boneData == null)\n\t\t\t\t\t\tthrow new Error(\"Slot bone not found: \" + boneName);\n\t\t\t\t\tvar data = new spine.SlotData(skeletonData.slots.length, slotName, boneData);\n\t\t\t\t\tvar color = this.getValue(slotMap, \"color\", null);\n\t\t\t\t\tif (color != null)\n\t\t\t\t\t\tdata.color.setFromString(color);\n\t\t\t\t\tvar dark = this.getValue(slotMap, \"dark\", null);\n\t\t\t\t\tif (dark != null) {\n\t\t\t\t\t\tdata.darkColor = new spine.Color(1, 1, 1, 1);\n\t\t\t\t\t\tdata.darkColor.setFromString(dark);\n\t\t\t\t\t}\n\t\t\t\t\tdata.attachmentName = this.getValue(slotMap, \"attachment\", null);\n\t\t\t\t\tdata.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, \"blend\", \"normal\"));\n\t\t\t\t\tskeletonData.slots.push(data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (root.ik) {\n\t\t\t\tfor (var i = 0; i < root.ik.length; i++) {\n\t\t\t\t\tvar constraintMap = root.ik[i];\n\t\t\t\t\tvar data = new spine.IkConstraintData(constraintMap.name);\n\t\t\t\t\tdata.order = this.getValue(constraintMap, \"order\", 0);\n\t\t\t\t\tfor (var j = 0; j < constraintMap.bones.length; j++) {\n\t\t\t\t\t\tvar boneName = constraintMap.bones[j];\n\t\t\t\t\t\tvar bone = skeletonData.findBone(boneName);\n\t\t\t\t\t\tif (bone == null)\n\t\t\t\t\t\t\tthrow new Error(\"IK bone not found: \" + boneName);\n\t\t\t\t\t\tdata.bones.push(bone);\n\t\t\t\t\t}\n\t\t\t\t\tvar targetName = constraintMap.target;\n\t\t\t\t\tdata.target = skeletonData.findBone(targetName);\n\t\t\t\t\tif (data.target == null)\n\t\t\t\t\t\tthrow new Error(\"IK target bone not found: \" + targetName);\n\t\t\t\t\tdata.bendDirection = this.getValue(constraintMap, \"bendPositive\", true) ? 1 : -1;\n\t\t\t\t\tdata.mix = this.getValue(constraintMap, \"mix\", 1);\n\t\t\t\t\tskeletonData.ikConstraints.push(data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (root.transform) {\n\t\t\t\tfor (var i = 0; i < root.transform.length; i++) {\n\t\t\t\t\tvar constraintMap = root.transform[i];\n\t\t\t\t\tvar data = new spine.TransformConstraintData(constraintMap.name);\n\t\t\t\t\tdata.order = this.getValue(constraintMap, \"order\", 0);\n\t\t\t\t\tfor (var j = 0; j < constraintMap.bones.length; j++) {\n\t\t\t\t\t\tvar boneName = constraintMap.bones[j];\n\t\t\t\t\t\tvar bone = skeletonData.findBone(boneName);\n\t\t\t\t\t\tif (bone == null)\n\t\t\t\t\t\t\tthrow new Error(\"Transform constraint bone not found: \" + boneName);\n\t\t\t\t\t\tdata.bones.push(bone);\n\t\t\t\t\t}\n\t\t\t\t\tvar targetName = constraintMap.target;\n\t\t\t\t\tdata.target = skeletonData.findBone(targetName);\n\t\t\t\t\tif (data.target == null)\n\t\t\t\t\t\tthrow new Error(\"Transform constraint target bone not found: \" + targetName);\n\t\t\t\t\tdata.local = this.getValue(constraintMap, \"local\", false);\n\t\t\t\t\tdata.relative = this.getValue(constraintMap, \"relative\", false);\n\t\t\t\t\tdata.offsetRotation = this.getValue(constraintMap, \"rotation\", 0);\n\t\t\t\t\tdata.offsetX = this.getValue(constraintMap, \"x\", 0) * scale;\n\t\t\t\t\tdata.offsetY = this.getValue(constraintMap, \"y\", 0) * scale;\n\t\t\t\t\tdata.offsetScaleX = this.getValue(constraintMap, \"scaleX\", 0);\n\t\t\t\t\tdata.offsetScaleY = this.getValue(constraintMap, \"scaleY\", 0);\n\t\t\t\t\tdata.offsetShearY = this.getValue(constraintMap, \"shearY\", 0);\n\t\t\t\t\tdata.rotateMix = this.getValue(constraintMap, \"rotateMix\", 1);\n\t\t\t\t\tdata.translateMix = this.getValue(constraintMap, \"translateMix\", 1);\n\t\t\t\t\tdata.scaleMix = this.getValue(constraintMap, \"scaleMix\", 1);\n\t\t\t\t\tdata.shearMix = this.getValue(constraintMap, \"shearMix\", 1);\n\t\t\t\t\tskeletonData.transformConstraints.push(data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (root.path) {\n\t\t\t\tfor (var i = 0; i < root.path.length; i++) {\n\t\t\t\t\tvar constraintMap = root.path[i];\n\t\t\t\t\tvar data = new spine.PathConstraintData(constraintMap.name);\n\t\t\t\t\tdata.order = this.getValue(constraintMap, \"order\", 0);\n\t\t\t\t\tfor (var j = 0; j < constraintMap.bones.length; j++) {\n\t\t\t\t\t\tvar boneName = constraintMap.bones[j];\n\t\t\t\t\t\tvar bone = skeletonData.findBone(boneName);\n\t\t\t\t\t\tif (bone == null)\n\t\t\t\t\t\t\tthrow new Error(\"Transform constraint bone not found: \" + boneName);\n\t\t\t\t\t\tdata.bones.push(bone);\n\t\t\t\t\t}\n\t\t\t\t\tvar targetName = constraintMap.target;\n\t\t\t\t\tdata.target = skeletonData.findSlot(targetName);\n\t\t\t\t\tif (data.target == null)\n\t\t\t\t\t\tthrow new Error(\"Path target slot not found: \" + targetName);\n\t\t\t\t\tdata.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, \"positionMode\", \"percent\"));\n\t\t\t\t\tdata.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, \"spacingMode\", \"length\"));\n\t\t\t\t\tdata.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, \"rotateMode\", \"tangent\"));\n\t\t\t\t\tdata.offsetRotation = this.getValue(constraintMap, \"rotation\", 0);\n\t\t\t\t\tdata.position = this.getValue(constraintMap, \"position\", 0);\n\t\t\t\t\tif (data.positionMode == spine.PositionMode.Fixed)\n\t\t\t\t\t\tdata.position *= scale;\n\t\t\t\t\tdata.spacing = this.getValue(constraintMap, \"spacing\", 0);\n\t\t\t\t\tif (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)\n\t\t\t\t\t\tdata.spacing *= scale;\n\t\t\t\t\tdata.rotateMix = this.getValue(constraintMap, \"rotateMix\", 1);\n\t\t\t\t\tdata.translateMix = this.getValue(constraintMap, \"translateMix\", 1);\n\t\t\t\t\tskeletonData.pathConstraints.push(data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (root.skins) {\n\t\t\t\tfor (var skinName in root.skins) {\n\t\t\t\t\tvar skinMap = root.skins[skinName];\n\t\t\t\t\tvar skin = new spine.Skin(skinName);\n\t\t\t\t\tfor (var slotName in skinMap) {\n\t\t\t\t\t\tvar slotIndex = skeletonData.findSlotIndex(slotName);\n\t\t\t\t\t\tif (slotIndex == -1)\n\t\t\t\t\t\t\tthrow new Error(\"Slot not found: \" + slotName);\n\t\t\t\t\t\tvar slotMap = skinMap[slotName];\n\t\t\t\t\t\tfor (var entryName in slotMap) {\n\t\t\t\t\t\t\tvar attachment = this.readAttachment(slotMap[entryName], skin, slotIndex, entryName, skeletonData);\n\t\t\t\t\t\t\tif (attachment != null)\n\t\t\t\t\t\t\t\tskin.addAttachment(slotIndex, entryName, attachment);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tskeletonData.skins.push(skin);\n\t\t\t\t\tif (skin.name == \"default\")\n\t\t\t\t\t\tskeletonData.defaultSkin = skin;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (var i = 0, n = this.linkedMeshes.length; i < n; i++) {\n\t\t\t\tvar linkedMesh = this.linkedMeshes[i];\n\t\t\t\tvar skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin);\n\t\t\t\tif (skin == null)\n\t\t\t\t\tthrow new Error(\"Skin not found: \" + linkedMesh.skin);\n\t\t\t\tvar parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent);\n\t\t\t\tif (parent_3 == null)\n\t\t\t\t\tthrow new Error(\"Parent mesh not found: \" + linkedMesh.parent);\n\t\t\t\tlinkedMesh.mesh.setParentMesh(parent_3);\n\t\t\t\tlinkedMesh.mesh.updateUVs();\n\t\t\t}\n\t\t\tthis.linkedMeshes.length = 0;\n\t\t\tif (root.events) {\n\t\t\t\tfor (var eventName in root.events) {\n\t\t\t\t\tvar eventMap = root.events[eventName];\n\t\t\t\t\tvar data = new spine.EventData(eventName);\n\t\t\t\t\tdata.intValue = this.getValue(eventMap, \"int\", 0);\n\t\t\t\t\tdata.floatValue = this.getValue(eventMap, \"float\", 0);\n\t\t\t\t\tdata.stringValue = this.getValue(eventMap, \"string\", \"\");\n\t\t\t\t\tskeletonData.events.push(data);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (root.animations) {\n\t\t\t\tfor (var animationName in root.animations) {\n\t\t\t\t\tvar animationMap = root.animations[animationName];\n\t\t\t\t\tthis.readAnimation(animationMap, animationName, skeletonData);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn skeletonData;\n\t\t};\n\t\tSkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) {\n\t\t\tvar scale = this.scale;\n\t\t\tname = this.getValue(map, \"name\", name);\n\t\t\tvar type = this.getValue(map, \"type\", \"region\");\n\t\t\tswitch (type) {\n\t\t\t\tcase \"region\": {\n\t\t\t\t\tvar path = this.getValue(map, \"path\", name);\n\t\t\t\t\tvar region = this.attachmentLoader.newRegionAttachment(skin, name, path);\n\t\t\t\t\tif (region == null)\n\t\t\t\t\t\treturn null;\n\t\t\t\t\tregion.path = path;\n\t\t\t\t\tregion.x = this.getValue(map, \"x\", 0) * scale;\n\t\t\t\t\tregion.y = this.getValue(map, \"y\", 0) * scale;\n\t\t\t\t\tregion.scaleX = this.getValue(map, \"scaleX\", 1);\n\t\t\t\t\tregion.scaleY = this.getValue(map, \"scaleY\", 1);\n\t\t\t\t\tregion.rotation = this.getValue(map, \"rotation\", 0);\n\t\t\t\t\tregion.width = map.width * scale;\n\t\t\t\t\tregion.height = map.height * scale;\n\t\t\t\t\tvar color = this.getValue(map, \"color\", null);\n\t\t\t\t\tif (color != null)\n\t\t\t\t\t\tregion.color.setFromString(color);\n\t\t\t\t\tregion.updateOffset();\n\t\t\t\t\treturn region;\n\t\t\t\t}\n\t\t\t\tcase \"boundingbox\": {\n\t\t\t\t\tvar box = this.attachmentLoader.newBoundingBoxAttachment(skin, name);\n\t\t\t\t\tif (box == null)\n\t\t\t\t\t\treturn null;\n\t\t\t\t\tthis.readVertices(map, box, map.vertexCount << 1);\n\t\t\t\t\tvar color = this.getValue(map, \"color\", null);\n\t\t\t\t\tif (color != null)\n\t\t\t\t\t\tbox.color.setFromString(color);\n\t\t\t\t\treturn box;\n\t\t\t\t}\n\t\t\t\tcase \"mesh\":\n\t\t\t\tcase \"linkedmesh\": {\n\t\t\t\t\tvar path = this.getValue(map, \"path\", name);\n\t\t\t\t\tvar mesh = this.attachmentLoader.newMeshAttachment(skin, name, path);\n\t\t\t\t\tif (mesh == null)\n\t\t\t\t\t\treturn null;\n\t\t\t\t\tmesh.path = path;\n\t\t\t\t\tvar color = this.getValue(map, \"color\", null);\n\t\t\t\t\tif (color != null)\n\t\t\t\t\t\tmesh.color.setFromString(color);\n\t\t\t\t\tvar parent_4 = this.getValue(map, \"parent\", null);\n\t\t\t\t\tif (parent_4 != null) {\n\t\t\t\t\t\tmesh.inheritDeform = this.getValue(map, \"deform\", true);\n\t\t\t\t\t\tthis.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, \"skin\", null), slotIndex, parent_4));\n\t\t\t\t\t\treturn mesh;\n\t\t\t\t\t}\n\t\t\t\t\tvar uvs = map.uvs;\n\t\t\t\t\tthis.readVertices(map, mesh, uvs.length);\n\t\t\t\t\tmesh.triangles = map.triangles;\n\t\t\t\t\tmesh.regionUVs = uvs;\n\t\t\t\t\tmesh.updateUVs();\n\t\t\t\t\tmesh.hullLength = this.getValue(map, \"hull\", 0) * 2;\n\t\t\t\t\treturn mesh;\n\t\t\t\t}\n\t\t\t\tcase \"path\": {\n\t\t\t\t\tvar path = this.attachmentLoader.newPathAttachment(skin, name);\n\t\t\t\t\tif (path == null)\n\t\t\t\t\t\treturn null;\n\t\t\t\t\tpath.closed = this.getValue(map, \"closed\", false);\n\t\t\t\t\tpath.constantSpeed = this.getValue(map, \"constantSpeed\", true);\n\t\t\t\t\tvar vertexCount = map.vertexCount;\n\t\t\t\t\tthis.readVertices(map, path, vertexCount << 1);\n\t\t\t\t\tvar lengths = spine.Utils.newArray(vertexCount / 3, 0);\n\t\t\t\t\tfor (var i = 0; i < map.lengths.length; i++)\n\t\t\t\t\t\tlengths[i] = map.lengths[i] * scale;\n\t\t\t\t\tpath.lengths = lengths;\n\t\t\t\t\tvar color = this.getValue(map, \"color\", null);\n\t\t\t\t\tif (color != null)\n\t\t\t\t\t\tpath.color.setFromString(color);\n\t\t\t\t\treturn path;\n\t\t\t\t}\n\t\t\t\tcase \"point\": {\n\t\t\t\t\tvar point = this.attachmentLoader.newPointAttachment(skin, name);\n\t\t\t\t\tif (point == null)\n\t\t\t\t\t\treturn null;\n\t\t\t\t\tpoint.x = this.getValue(map, \"x\", 0) * scale;\n\t\t\t\t\tpoint.y = this.getValue(map, \"y\", 0) * scale;\n\t\t\t\t\tpoint.rotation = this.getValue(map, \"rotation\", 0);\n\t\t\t\t\tvar color = this.getValue(map, \"color\", null);\n\t\t\t\t\tif (color != null)\n\t\t\t\t\t\tpoint.color.setFromString(color);\n\t\t\t\t\treturn point;\n\t\t\t\t}\n\t\t\t\tcase \"clipping\": {\n\t\t\t\t\tvar clip = this.attachmentLoader.newClippingAttachment(skin, name);\n\t\t\t\t\tif (clip == null)\n\t\t\t\t\t\treturn null;\n\t\t\t\t\tvar end = this.getValue(map, \"end\", null);\n\t\t\t\t\tif (end != null) {\n\t\t\t\t\t\tvar slot = skeletonData.findSlot(end);\n\t\t\t\t\t\tif (slot == null)\n\t\t\t\t\t\t\tthrow new Error(\"Clipping end slot not found: \" + end);\n\t\t\t\t\t\tclip.endSlot = slot;\n\t\t\t\t\t}\n\t\t\t\t\tvar vertexCount = map.vertexCount;\n\t\t\t\t\tthis.readVertices(map, clip, vertexCount << 1);\n\t\t\t\t\tvar color = this.getValue(map, \"color\", null);\n\t\t\t\t\tif (color != null)\n\t\t\t\t\t\tclip.color.setFromString(color);\n\t\t\t\t\treturn clip;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tSkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) {\n\t\t\tvar scale = this.scale;\n\t\t\tattachment.worldVerticesLength = verticesLength;\n\t\t\tvar vertices = map.vertices;\n\t\t\tif (verticesLength == vertices.length) {\n\t\t\t\tvar scaledVertices = spine.Utils.toFloatArray(vertices);\n\t\t\t\tif (scale != 1) {\n\t\t\t\t\tfor (var i = 0, n = vertices.length; i < n; i++)\n\t\t\t\t\t\tscaledVertices[i] *= scale;\n\t\t\t\t}\n\t\t\t\tattachment.vertices = scaledVertices;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar weights = new Array();\n\t\t\tvar bones = new Array();\n\t\t\tfor (var i = 0, n = vertices.length; i < n;) {\n\t\t\t\tvar boneCount = vertices[i++];\n\t\t\t\tbones.push(boneCount);\n\t\t\t\tfor (var nn = i + boneCount * 4; i < nn; i += 4) {\n\t\t\t\t\tbones.push(vertices[i]);\n\t\t\t\t\tweights.push(vertices[i + 1] * scale);\n\t\t\t\t\tweights.push(vertices[i + 2] * scale);\n\t\t\t\t\tweights.push(vertices[i + 3]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tattachment.bones = bones;\n\t\t\tattachment.vertices = spine.Utils.toFloatArray(weights);\n\t\t};\n\t\tSkeletonJson.prototype.readAnimation = function (map, name, skeletonData) {\n\t\t\tvar scale = this.scale;\n\t\t\tvar timelines = new Array();\n\t\t\tvar duration = 0;\n\t\t\tif (map.slots) {\n\t\t\t\tfor (var slotName in map.slots) {\n\t\t\t\t\tvar slotMap = map.slots[slotName];\n\t\t\t\t\tvar slotIndex = skeletonData.findSlotIndex(slotName);\n\t\t\t\t\tif (slotIndex == -1)\n\t\t\t\t\t\tthrow new Error(\"Slot not found: \" + slotName);\n\t\t\t\t\tfor (var timelineName in slotMap) {\n\t\t\t\t\t\tvar timelineMap = slotMap[timelineName];\n\t\t\t\t\t\tif (timelineName == \"attachment\") {\n\t\t\t\t\t\t\tvar timeline = new spine.AttachmentTimeline(timelineMap.length);\n\t\t\t\t\t\t\ttimeline.slotIndex = slotIndex;\n\t\t\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\t\t\tfor (var i = 0; i < timelineMap.length; i++) {\n\t\t\t\t\t\t\t\tvar valueMap = timelineMap[i];\n\t\t\t\t\t\t\t\ttimeline.setFrame(frameIndex++, valueMap.time, valueMap.name);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\t\t\tduration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (timelineName == \"color\") {\n\t\t\t\t\t\t\tvar timeline = new spine.ColorTimeline(timelineMap.length);\n\t\t\t\t\t\t\ttimeline.slotIndex = slotIndex;\n\t\t\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\t\t\tfor (var i = 0; i < timelineMap.length; i++) {\n\t\t\t\t\t\t\t\tvar valueMap = timelineMap[i];\n\t\t\t\t\t\t\t\tvar color = new spine.Color();\n\t\t\t\t\t\t\t\tcolor.setFromString(valueMap.color);\n\t\t\t\t\t\t\t\ttimeline.setFrame(frameIndex, valueMap.time, color.r, color.g, color.b, color.a);\n\t\t\t\t\t\t\t\tthis.readCurve(valueMap, timeline, frameIndex);\n\t\t\t\t\t\t\t\tframeIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\t\t\tduration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.ColorTimeline.ENTRIES]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (timelineName == \"twoColor\") {\n\t\t\t\t\t\t\tvar timeline = new spine.TwoColorTimeline(timelineMap.length);\n\t\t\t\t\t\t\ttimeline.slotIndex = slotIndex;\n\t\t\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\t\t\tfor (var i = 0; i < timelineMap.length; i++) {\n\t\t\t\t\t\t\t\tvar valueMap = timelineMap[i];\n\t\t\t\t\t\t\t\tvar light = new spine.Color();\n\t\t\t\t\t\t\t\tvar dark = new spine.Color();\n\t\t\t\t\t\t\t\tlight.setFromString(valueMap.light);\n\t\t\t\t\t\t\t\tdark.setFromString(valueMap.dark);\n\t\t\t\t\t\t\t\ttimeline.setFrame(frameIndex, valueMap.time, light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b);\n\t\t\t\t\t\t\t\tthis.readCurve(valueMap, timeline, frameIndex);\n\t\t\t\t\t\t\t\tframeIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\t\t\tduration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TwoColorTimeline.ENTRIES]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tthrow new Error(\"Invalid timeline type for a slot: \" + timelineName + \" (\" + slotName + \")\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (map.bones) {\n\t\t\t\tfor (var boneName in map.bones) {\n\t\t\t\t\tvar boneMap = map.bones[boneName];\n\t\t\t\t\tvar boneIndex = skeletonData.findBoneIndex(boneName);\n\t\t\t\t\tif (boneIndex == -1)\n\t\t\t\t\t\tthrow new Error(\"Bone not found: \" + boneName);\n\t\t\t\t\tfor (var timelineName in boneMap) {\n\t\t\t\t\t\tvar timelineMap = boneMap[timelineName];\n\t\t\t\t\t\tif (timelineName === \"rotate\") {\n\t\t\t\t\t\t\tvar timeline = new spine.RotateTimeline(timelineMap.length);\n\t\t\t\t\t\t\ttimeline.boneIndex = boneIndex;\n\t\t\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\t\t\tfor (var i = 0; i < timelineMap.length; i++) {\n\t\t\t\t\t\t\t\tvar valueMap = timelineMap[i];\n\t\t\t\t\t\t\t\ttimeline.setFrame(frameIndex, valueMap.time, valueMap.angle);\n\t\t\t\t\t\t\t\tthis.readCurve(valueMap, timeline, frameIndex);\n\t\t\t\t\t\t\t\tframeIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\t\t\tduration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.RotateTimeline.ENTRIES]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (timelineName === \"translate\" || timelineName === \"scale\" || timelineName === \"shear\") {\n\t\t\t\t\t\t\tvar timeline = null;\n\t\t\t\t\t\t\tvar timelineScale = 1;\n\t\t\t\t\t\t\tif (timelineName === \"scale\")\n\t\t\t\t\t\t\t\ttimeline = new spine.ScaleTimeline(timelineMap.length);\n\t\t\t\t\t\t\telse if (timelineName === \"shear\")\n\t\t\t\t\t\t\t\ttimeline = new spine.ShearTimeline(timelineMap.length);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\ttimeline = new spine.TranslateTimeline(timelineMap.length);\n\t\t\t\t\t\t\t\ttimelineScale = scale;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimeline.boneIndex = boneIndex;\n\t\t\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\t\t\tfor (var i = 0; i < timelineMap.length; i++) {\n\t\t\t\t\t\t\t\tvar valueMap = timelineMap[i];\n\t\t\t\t\t\t\t\tvar x = this.getValue(valueMap, \"x\", 0), y = this.getValue(valueMap, \"y\", 0);\n\t\t\t\t\t\t\t\ttimeline.setFrame(frameIndex, valueMap.time, x * timelineScale, y * timelineScale);\n\t\t\t\t\t\t\t\tthis.readCurve(valueMap, timeline, frameIndex);\n\t\t\t\t\t\t\t\tframeIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\t\t\tduration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TranslateTimeline.ENTRIES]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tthrow new Error(\"Invalid timeline type for a bone: \" + timelineName + \" (\" + boneName + \")\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (map.ik) {\n\t\t\t\tfor (var constraintName in map.ik) {\n\t\t\t\t\tvar constraintMap = map.ik[constraintName];\n\t\t\t\t\tvar constraint = skeletonData.findIkConstraint(constraintName);\n\t\t\t\t\tvar timeline = new spine.IkConstraintTimeline(constraintMap.length);\n\t\t\t\t\ttimeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint);\n\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\tfor (var i = 0; i < constraintMap.length; i++) {\n\t\t\t\t\t\tvar valueMap = constraintMap[i];\n\t\t\t\t\t\ttimeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, \"mix\", 1), this.getValue(valueMap, \"bendPositive\", true) ? 1 : -1);\n\t\t\t\t\t\tthis.readCurve(valueMap, timeline, frameIndex);\n\t\t\t\t\t\tframeIndex++;\n\t\t\t\t\t}\n\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\tduration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.IkConstraintTimeline.ENTRIES]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (map.transform) {\n\t\t\t\tfor (var constraintName in map.transform) {\n\t\t\t\t\tvar constraintMap = map.transform[constraintName];\n\t\t\t\t\tvar constraint = skeletonData.findTransformConstraint(constraintName);\n\t\t\t\t\tvar timeline = new spine.TransformConstraintTimeline(constraintMap.length);\n\t\t\t\t\ttimeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint);\n\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\tfor (var i = 0; i < constraintMap.length; i++) {\n\t\t\t\t\t\tvar valueMap = constraintMap[i];\n\t\t\t\t\t\ttimeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, \"rotateMix\", 1), this.getValue(valueMap, \"translateMix\", 1), this.getValue(valueMap, \"scaleMix\", 1), this.getValue(valueMap, \"shearMix\", 1));\n\t\t\t\t\t\tthis.readCurve(valueMap, timeline, frameIndex);\n\t\t\t\t\t\tframeIndex++;\n\t\t\t\t\t}\n\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\tduration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TransformConstraintTimeline.ENTRIES]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (map.paths) {\n\t\t\t\tfor (var constraintName in map.paths) {\n\t\t\t\t\tvar constraintMap = map.paths[constraintName];\n\t\t\t\t\tvar index = skeletonData.findPathConstraintIndex(constraintName);\n\t\t\t\t\tif (index == -1)\n\t\t\t\t\t\tthrow new Error(\"Path constraint not found: \" + constraintName);\n\t\t\t\t\tvar data = skeletonData.pathConstraints[index];\n\t\t\t\t\tfor (var timelineName in constraintMap) {\n\t\t\t\t\t\tvar timelineMap = constraintMap[timelineName];\n\t\t\t\t\t\tif (timelineName === \"position\" || timelineName === \"spacing\") {\n\t\t\t\t\t\t\tvar timeline = null;\n\t\t\t\t\t\t\tvar timelineScale = 1;\n\t\t\t\t\t\t\tif (timelineName === \"spacing\") {\n\t\t\t\t\t\t\t\ttimeline = new spine.PathConstraintSpacingTimeline(timelineMap.length);\n\t\t\t\t\t\t\t\tif (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed)\n\t\t\t\t\t\t\t\t\ttimelineScale = scale;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\ttimeline = new spine.PathConstraintPositionTimeline(timelineMap.length);\n\t\t\t\t\t\t\t\tif (data.positionMode == spine.PositionMode.Fixed)\n\t\t\t\t\t\t\t\t\ttimelineScale = scale;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimeline.pathConstraintIndex = index;\n\t\t\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\t\t\tfor (var i = 0; i < timelineMap.length; i++) {\n\t\t\t\t\t\t\t\tvar valueMap = timelineMap[i];\n\t\t\t\t\t\t\t\ttimeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, timelineName, 0) * timelineScale);\n\t\t\t\t\t\t\t\tthis.readCurve(valueMap, timeline, frameIndex);\n\t\t\t\t\t\t\t\tframeIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\t\t\tduration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintPositionTimeline.ENTRIES]);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (timelineName === \"mix\") {\n\t\t\t\t\t\t\tvar timeline = new spine.PathConstraintMixTimeline(timelineMap.length);\n\t\t\t\t\t\t\ttimeline.pathConstraintIndex = index;\n\t\t\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\t\t\tfor (var i = 0; i < timelineMap.length; i++) {\n\t\t\t\t\t\t\t\tvar valueMap = timelineMap[i];\n\t\t\t\t\t\t\t\ttimeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, \"rotateMix\", 1), this.getValue(valueMap, \"translateMix\", 1));\n\t\t\t\t\t\t\t\tthis.readCurve(valueMap, timeline, frameIndex);\n\t\t\t\t\t\t\t\tframeIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\t\t\tduration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintMixTimeline.ENTRIES]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (map.deform) {\n\t\t\t\tfor (var deformName in map.deform) {\n\t\t\t\t\tvar deformMap = map.deform[deformName];\n\t\t\t\t\tvar skin = skeletonData.findSkin(deformName);\n\t\t\t\t\tif (skin == null)\n\t\t\t\t\t\tthrow new Error(\"Skin not found: \" + deformName);\n\t\t\t\t\tfor (var slotName in deformMap) {\n\t\t\t\t\t\tvar slotMap = deformMap[slotName];\n\t\t\t\t\t\tvar slotIndex = skeletonData.findSlotIndex(slotName);\n\t\t\t\t\t\tif (slotIndex == -1)\n\t\t\t\t\t\t\tthrow new Error(\"Slot not found: \" + slotMap.name);\n\t\t\t\t\t\tfor (var timelineName in slotMap) {\n\t\t\t\t\t\t\tvar timelineMap = slotMap[timelineName];\n\t\t\t\t\t\t\tvar attachment = skin.getAttachment(slotIndex, timelineName);\n\t\t\t\t\t\t\tif (attachment == null)\n\t\t\t\t\t\t\t\tthrow new Error(\"Deform attachment not found: \" + timelineMap.name);\n\t\t\t\t\t\t\tvar weighted = attachment.bones != null;\n\t\t\t\t\t\t\tvar vertices = attachment.vertices;\n\t\t\t\t\t\t\tvar deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;\n\t\t\t\t\t\t\tvar timeline = new spine.DeformTimeline(timelineMap.length);\n\t\t\t\t\t\t\ttimeline.slotIndex = slotIndex;\n\t\t\t\t\t\t\ttimeline.attachment = attachment;\n\t\t\t\t\t\t\tvar frameIndex = 0;\n\t\t\t\t\t\t\tfor (var j = 0; j < timelineMap.length; j++) {\n\t\t\t\t\t\t\t\tvar valueMap = timelineMap[j];\n\t\t\t\t\t\t\t\tvar deform = void 0;\n\t\t\t\t\t\t\t\tvar verticesValue = this.getValue(valueMap, \"vertices\", null);\n\t\t\t\t\t\t\t\tif (verticesValue == null)\n\t\t\t\t\t\t\t\t\tdeform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices;\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tdeform = spine.Utils.newFloatArray(deformLength);\n\t\t\t\t\t\t\t\t\tvar start = this.getValue(valueMap, \"offset\", 0);\n\t\t\t\t\t\t\t\t\tspine.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length);\n\t\t\t\t\t\t\t\t\tif (scale != 1) {\n\t\t\t\t\t\t\t\t\t\tfor (var i = start, n = i + verticesValue.length; i < n; i++)\n\t\t\t\t\t\t\t\t\t\t\tdeform[i] *= scale;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (!weighted) {\n\t\t\t\t\t\t\t\t\t\tfor (var i = 0; i < deformLength; i++)\n\t\t\t\t\t\t\t\t\t\t\tdeform[i] += vertices[i];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ttimeline.setFrame(frameIndex, valueMap.time, deform);\n\t\t\t\t\t\t\t\tthis.readCurve(valueMap, timeline, frameIndex);\n\t\t\t\t\t\t\t\tframeIndex++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ttimelines.push(timeline);\n\t\t\t\t\t\t\tduration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar drawOrderNode = map.drawOrder;\n\t\t\tif (drawOrderNode == null)\n\t\t\t\tdrawOrderNode = map.draworder;\n\t\t\tif (drawOrderNode != null) {\n\t\t\t\tvar timeline = new spine.DrawOrderTimeline(drawOrderNode.length);\n\t\t\t\tvar slotCount = skeletonData.slots.length;\n\t\t\t\tvar frameIndex = 0;\n\t\t\t\tfor (var j = 0; j < drawOrderNode.length; j++) {\n\t\t\t\t\tvar drawOrderMap = drawOrderNode[j];\n\t\t\t\t\tvar drawOrder = null;\n\t\t\t\t\tvar offsets = this.getValue(drawOrderMap, \"offsets\", null);\n\t\t\t\t\tif (offsets != null) {\n\t\t\t\t\t\tdrawOrder = spine.Utils.newArray(slotCount, -1);\n\t\t\t\t\t\tvar unchanged = spine.Utils.newArray(slotCount - offsets.length, 0);\n\t\t\t\t\t\tvar originalIndex = 0, unchangedIndex = 0;\n\t\t\t\t\t\tfor (var i = 0; i < offsets.length; i++) {\n\t\t\t\t\t\t\tvar offsetMap = offsets[i];\n\t\t\t\t\t\t\tvar slotIndex = skeletonData.findSlotIndex(offsetMap.slot);\n\t\t\t\t\t\t\tif (slotIndex == -1)\n\t\t\t\t\t\t\t\tthrow new Error(\"Slot not found: \" + offsetMap.slot);\n\t\t\t\t\t\t\twhile (originalIndex != slotIndex)\n\t\t\t\t\t\t\t\tunchanged[unchangedIndex++] = originalIndex++;\n\t\t\t\t\t\t\tdrawOrder[originalIndex + offsetMap.offset] = originalIndex++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\twhile (originalIndex < slotCount)\n\t\t\t\t\t\t\tunchanged[unchangedIndex++] = originalIndex++;\n\t\t\t\t\t\tfor (var i = slotCount - 1; i >= 0; i--)\n\t\t\t\t\t\t\tif (drawOrder[i] == -1)\n\t\t\t\t\t\t\t\tdrawOrder[i] = unchanged[--unchangedIndex];\n\t\t\t\t\t}\n\t\t\t\t\ttimeline.setFrame(frameIndex++, drawOrderMap.time, drawOrder);\n\t\t\t\t}\n\t\t\t\ttimelines.push(timeline);\n\t\t\t\tduration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);\n\t\t\t}\n\t\t\tif (map.events) {\n\t\t\t\tvar timeline = new spine.EventTimeline(map.events.length);\n\t\t\t\tvar frameIndex = 0;\n\t\t\t\tfor (var i = 0; i < map.events.length; i++) {\n\t\t\t\t\tvar eventMap = map.events[i];\n\t\t\t\t\tvar eventData = skeletonData.findEvent(eventMap.name);\n\t\t\t\t\tif (eventData == null)\n\t\t\t\t\t\tthrow new Error(\"Event not found: \" + eventMap.name);\n\t\t\t\t\tvar event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData);\n\t\t\t\t\tevent_5.intValue = this.getValue(eventMap, \"int\", eventData.intValue);\n\t\t\t\t\tevent_5.floatValue = this.getValue(eventMap, \"float\", eventData.floatValue);\n\t\t\t\t\tevent_5.stringValue = this.getValue(eventMap, \"string\", eventData.stringValue);\n\t\t\t\t\ttimeline.setFrame(frameIndex++, event_5);\n\t\t\t\t}\n\t\t\t\ttimelines.push(timeline);\n\t\t\t\tduration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]);\n\t\t\t}\n\t\t\tif (isNaN(duration)) {\n\t\t\t\tthrow new Error(\"Error while parsing animation, duration is NaN\");\n\t\t\t}\n\t\t\tskeletonData.animations.push(new spine.Animation(name, timelines, duration));\n\t\t};\n\t\tSkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) {\n\t\t\tif (!map.curve)\n\t\t\t\treturn;\n\t\t\tif (map.curve === \"stepped\")\n\t\t\t\ttimeline.setStepped(frameIndex);\n\t\t\telse if (Object.prototype.toString.call(map.curve) === '[object Array]') {\n\t\t\t\tvar curve = map.curve;\n\t\t\t\ttimeline.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]);\n\t\t\t}\n\t\t};\n\t\tSkeletonJson.prototype.getValue = function (map, prop, defaultValue) {\n\t\t\treturn map[prop] !== undefined ? map[prop] : defaultValue;\n\t\t};\n\t\tSkeletonJson.blendModeFromString = function (str) {\n\t\t\tstr = str.toLowerCase();\n\t\t\tif (str == \"normal\")\n\t\t\t\treturn spine.BlendMode.Normal;\n\t\t\tif (str == \"additive\")\n\t\t\t\treturn spine.BlendMode.Additive;\n\t\t\tif (str == \"multiply\")\n\t\t\t\treturn spine.BlendMode.Multiply;\n\t\t\tif (str == \"screen\")\n\t\t\t\treturn spine.BlendMode.Screen;\n\t\t\tthrow new Error(\"Unknown blend mode: \" + str);\n\t\t};\n\t\tSkeletonJson.positionModeFromString = function (str) {\n\t\t\tstr = str.toLowerCase();\n\t\t\tif (str == \"fixed\")\n\t\t\t\treturn spine.PositionMode.Fixed;\n\t\t\tif (str == \"percent\")\n\t\t\t\treturn spine.PositionMode.Percent;\n\t\t\tthrow new Error(\"Unknown position mode: \" + str);\n\t\t};\n\t\tSkeletonJson.spacingModeFromString = function (str) {\n\t\t\tstr = str.toLowerCase();\n\t\t\tif (str == \"length\")\n\t\t\t\treturn spine.SpacingMode.Length;\n\t\t\tif (str == \"fixed\")\n\t\t\t\treturn spine.SpacingMode.Fixed;\n\t\t\tif (str == \"percent\")\n\t\t\t\treturn spine.SpacingMode.Percent;\n\t\t\tthrow new Error(\"Unknown position mode: \" + str);\n\t\t};\n\t\tSkeletonJson.rotateModeFromString = function (str) {\n\t\t\tstr = str.toLowerCase();\n\t\t\tif (str == \"tangent\")\n\t\t\t\treturn spine.RotateMode.Tangent;\n\t\t\tif (str == \"chain\")\n\t\t\t\treturn spine.RotateMode.Chain;\n\t\t\tif (str == \"chainscale\")\n\t\t\t\treturn spine.RotateMode.ChainScale;\n\t\t\tthrow new Error(\"Unknown rotate mode: \" + str);\n\t\t};\n\t\tSkeletonJson.transformModeFromString = function (str) {\n\t\t\tstr = str.toLowerCase();\n\t\t\tif (str == \"normal\")\n\t\t\t\treturn spine.TransformMode.Normal;\n\t\t\tif (str == \"onlytranslation\")\n\t\t\t\treturn spine.TransformMode.OnlyTranslation;\n\t\t\tif (str == \"norotationorreflection\")\n\t\t\t\treturn spine.TransformMode.NoRotationOrReflection;\n\t\t\tif (str == \"noscale\")\n\t\t\t\treturn spine.TransformMode.NoScale;\n\t\t\tif (str == \"noscaleorreflection\")\n\t\t\t\treturn spine.TransformMode.NoScaleOrReflection;\n\t\t\tthrow new Error(\"Unknown transform mode: \" + str);\n\t\t};\n\t\treturn SkeletonJson;\n\t}());\n\tspine.SkeletonJson = SkeletonJson;\n\tvar LinkedMesh = (function () {\n\t\tfunction LinkedMesh(mesh, skin, slotIndex, parent) {\n\t\t\tthis.mesh = mesh;\n\t\t\tthis.skin = skin;\n\t\t\tthis.slotIndex = slotIndex;\n\t\t\tthis.parent = parent;\n\t\t}\n\t\treturn LinkedMesh;\n\t}());\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar Skin = (function () {\n\t\tfunction Skin(name) {\n\t\t\tthis.attachments = new Array();\n\t\t\tif (name == null)\n\t\t\t\tthrow new Error(\"name cannot be null.\");\n\t\t\tthis.name = name;\n\t\t}\n\t\tSkin.prototype.addAttachment = function (slotIndex, name, attachment) {\n\t\t\tif (attachment == null)\n\t\t\t\tthrow new Error(\"attachment cannot be null.\");\n\t\t\tvar attachments = this.attachments;\n\t\t\tif (slotIndex >= attachments.length)\n\t\t\t\tattachments.length = slotIndex + 1;\n\t\t\tif (!attachments[slotIndex])\n\t\t\t\tattachments[slotIndex] = {};\n\t\t\tattachments[slotIndex][name] = attachment;\n\t\t};\n\t\tSkin.prototype.getAttachment = function (slotIndex, name) {\n\t\t\tvar dictionary = this.attachments[slotIndex];\n\t\t\treturn dictionary ? dictionary[name] : null;\n\t\t};\n\t\tSkin.prototype.attachAll = function (skeleton, oldSkin) {\n\t\t\tvar slotIndex = 0;\n\t\t\tfor (var i = 0; i < skeleton.slots.length; i++) {\n\t\t\t\tvar slot = skeleton.slots[i];\n\t\t\t\tvar slotAttachment = slot.getAttachment();\n\t\t\t\tif (slotAttachment && slotIndex < oldSkin.attachments.length) {\n\t\t\t\t\tvar dictionary = oldSkin.attachments[slotIndex];\n\t\t\t\t\tfor (var key in dictionary) {\n\t\t\t\t\t\tvar skinAttachment = dictionary[key];\n\t\t\t\t\t\tif (slotAttachment == skinAttachment) {\n\t\t\t\t\t\t\tvar attachment = this.getAttachment(slotIndex, key);\n\t\t\t\t\t\t\tif (attachment != null)\n\t\t\t\t\t\t\t\tslot.setAttachment(attachment);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tslotIndex++;\n\t\t\t}\n\t\t};\n\t\treturn Skin;\n\t}());\n\tspine.Skin = Skin;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar Slot = (function () {\n\t\tfunction Slot(data, bone) {\n\t\t\tthis.attachmentVertices = new Array();\n\t\t\tif (data == null)\n\t\t\t\tthrow new Error(\"data cannot be null.\");\n\t\t\tif (bone == null)\n\t\t\t\tthrow new Error(\"bone cannot be null.\");\n\t\t\tthis.data = data;\n\t\t\tthis.bone = bone;\n\t\t\tthis.color = new spine.Color();\n\t\t\tthis.darkColor = data.darkColor == null ? null : new spine.Color();\n\t\t\tthis.setToSetupPose();\n\t\t}\n\t\tSlot.prototype.getAttachment = function () {\n\t\t\treturn this.attachment;\n\t\t};\n\t\tSlot.prototype.setAttachment = function (attachment) {\n\t\t\tif (this.attachment == attachment)\n\t\t\t\treturn;\n\t\t\tthis.attachment = attachment;\n\t\t\tthis.attachmentTime = this.bone.skeleton.time;\n\t\t\tthis.attachmentVertices.length = 0;\n\t\t};\n\t\tSlot.prototype.setAttachmentTime = function (time) {\n\t\t\tthis.attachmentTime = this.bone.skeleton.time - time;\n\t\t};\n\t\tSlot.prototype.getAttachmentTime = function () {\n\t\t\treturn this.bone.skeleton.time - this.attachmentTime;\n\t\t};\n\t\tSlot.prototype.setToSetupPose = function () {\n\t\t\tthis.color.setFromColor(this.data.color);\n\t\t\tif (this.darkColor != null)\n\t\t\t\tthis.darkColor.setFromColor(this.data.darkColor);\n\t\t\tif (this.data.attachmentName == null)\n\t\t\t\tthis.attachment = null;\n\t\t\telse {\n\t\t\t\tthis.attachment = null;\n\t\t\t\tthis.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName));\n\t\t\t}\n\t\t};\n\t\treturn Slot;\n\t}());\n\tspine.Slot = Slot;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar SlotData = (function () {\n\t\tfunction SlotData(index, name, boneData) {\n\t\t\tthis.color = new spine.Color(1, 1, 1, 1);\n\t\t\tif (index < 0)\n\t\t\t\tthrow new Error(\"index must be >= 0.\");\n\t\t\tif (name == null)\n\t\t\t\tthrow new Error(\"name cannot be null.\");\n\t\t\tif (boneData == null)\n\t\t\t\tthrow new Error(\"boneData cannot be null.\");\n\t\t\tthis.index = index;\n\t\t\tthis.name = name;\n\t\t\tthis.boneData = boneData;\n\t\t}\n\t\treturn SlotData;\n\t}());\n\tspine.SlotData = SlotData;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar Texture = (function () {\n\t\tfunction Texture(image) {\n\t\t\tthis._image = image;\n\t\t}\n\t\tTexture.prototype.getImage = function () {\n\t\t\treturn this._image;\n\t\t};\n\t\tTexture.filterFromString = function (text) {\n\t\t\tswitch (text.toLowerCase()) {\n\t\t\t\tcase \"nearest\": return TextureFilter.Nearest;\n\t\t\t\tcase \"linear\": return TextureFilter.Linear;\n\t\t\t\tcase \"mipmap\": return TextureFilter.MipMap;\n\t\t\t\tcase \"mipmapnearestnearest\": return TextureFilter.MipMapNearestNearest;\n\t\t\t\tcase \"mipmaplinearnearest\": return TextureFilter.MipMapLinearNearest;\n\t\t\t\tcase \"mipmapnearestlinear\": return TextureFilter.MipMapNearestLinear;\n\t\t\t\tcase \"mipmaplinearlinear\": return TextureFilter.MipMapLinearLinear;\n\t\t\t\tdefault: throw new Error(\"Unknown texture filter \" + text);\n\t\t\t}\n\t\t};\n\t\tTexture.wrapFromString = function (text) {\n\t\t\tswitch (text.toLowerCase()) {\n\t\t\t\tcase \"mirroredtepeat\": return TextureWrap.MirroredRepeat;\n\t\t\t\tcase \"clamptoedge\": return TextureWrap.ClampToEdge;\n\t\t\t\tcase \"repeat\": return TextureWrap.Repeat;\n\t\t\t\tdefault: throw new Error(\"Unknown texture wrap \" + text);\n\t\t\t}\n\t\t};\n\t\treturn Texture;\n\t}());\n\tspine.Texture = Texture;\n\tvar TextureFilter;\n\t(function (TextureFilter) {\n\t\tTextureFilter[TextureFilter[\"Nearest\"] = 9728] = \"Nearest\";\n\t\tTextureFilter[TextureFilter[\"Linear\"] = 9729] = \"Linear\";\n\t\tTextureFilter[TextureFilter[\"MipMap\"] = 9987] = \"MipMap\";\n\t\tTextureFilter[TextureFilter[\"MipMapNearestNearest\"] = 9984] = \"MipMapNearestNearest\";\n\t\tTextureFilter[TextureFilter[\"MipMapLinearNearest\"] = 9985] = \"MipMapLinearNearest\";\n\t\tTextureFilter[TextureFilter[\"MipMapNearestLinear\"] = 9986] = \"MipMapNearestLinear\";\n\t\tTextureFilter[TextureFilter[\"MipMapLinearLinear\"] = 9987] = \"MipMapLinearLinear\";\n\t})(TextureFilter = spine.TextureFilter || (spine.TextureFilter = {}));\n\tvar TextureWrap;\n\t(function (TextureWrap) {\n\t\tTextureWrap[TextureWrap[\"MirroredRepeat\"] = 33648] = \"MirroredRepeat\";\n\t\tTextureWrap[TextureWrap[\"ClampToEdge\"] = 33071] = \"ClampToEdge\";\n\t\tTextureWrap[TextureWrap[\"Repeat\"] = 10497] = \"Repeat\";\n\t})(TextureWrap = spine.TextureWrap || (spine.TextureWrap = {}));\n\tvar TextureRegion = (function () {\n\t\tfunction TextureRegion() {\n\t\t\tthis.u = 0;\n\t\t\tthis.v = 0;\n\t\t\tthis.u2 = 0;\n\t\t\tthis.v2 = 0;\n\t\t\tthis.width = 0;\n\t\t\tthis.height = 0;\n\t\t\tthis.rotate = false;\n\t\t\tthis.offsetX = 0;\n\t\t\tthis.offsetY = 0;\n\t\t\tthis.originalWidth = 0;\n\t\t\tthis.originalHeight = 0;\n\t\t}\n\t\treturn TextureRegion;\n\t}());\n\tspine.TextureRegion = TextureRegion;\n\tvar FakeTexture = (function (_super) {\n\t\t__extends(FakeTexture, _super);\n\t\tfunction FakeTexture() {\n\t\t\treturn _super !== null && _super.apply(this, arguments) || this;\n\t\t}\n\t\tFakeTexture.prototype.setFilters = function (minFilter, magFilter) { };\n\t\tFakeTexture.prototype.setWraps = function (uWrap, vWrap) { };\n\t\tFakeTexture.prototype.dispose = function () { };\n\t\treturn FakeTexture;\n\t}(spine.Texture));\n\tspine.FakeTexture = FakeTexture;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar TextureAtlas = (function () {\n\t\tfunction TextureAtlas(atlasText, textureLoader) {\n\t\t\tthis.pages = new Array();\n\t\t\tthis.regions = new Array();\n\t\t\tthis.load(atlasText, textureLoader);\n\t\t}\n\t\tTextureAtlas.prototype.load = function (atlasText, textureLoader) {\n\t\t\tif (textureLoader == null)\n\t\t\t\tthrow new Error(\"textureLoader cannot be null.\");\n\t\t\tvar reader = new TextureAtlasReader(atlasText);\n\t\t\tvar tuple = new Array(4);\n\t\t\tvar page = null;\n\t\t\twhile (true) {\n\t\t\t\tvar line = reader.readLine();\n\t\t\t\tif (line == null)\n\t\t\t\t\tbreak;\n\t\t\t\tline = line.trim();\n\t\t\t\tif (line.length == 0)\n\t\t\t\t\tpage = null;\n\t\t\t\telse if (!page) {\n\t\t\t\t\tpage = new TextureAtlasPage();\n\t\t\t\t\tpage.name = line;\n\t\t\t\t\tif (reader.readTuple(tuple) == 2) {\n\t\t\t\t\t\tpage.width = parseInt(tuple[0]);\n\t\t\t\t\t\tpage.height = parseInt(tuple[1]);\n\t\t\t\t\t\treader.readTuple(tuple);\n\t\t\t\t\t}\n\t\t\t\t\treader.readTuple(tuple);\n\t\t\t\t\tpage.minFilter = spine.Texture.filterFromString(tuple[0]);\n\t\t\t\t\tpage.magFilter = spine.Texture.filterFromString(tuple[1]);\n\t\t\t\t\tvar direction = reader.readValue();\n\t\t\t\t\tpage.uWrap = spine.TextureWrap.ClampToEdge;\n\t\t\t\t\tpage.vWrap = spine.TextureWrap.ClampToEdge;\n\t\t\t\t\tif (direction == \"x\")\n\t\t\t\t\t\tpage.uWrap = spine.TextureWrap.Repeat;\n\t\t\t\t\telse if (direction == \"y\")\n\t\t\t\t\t\tpage.vWrap = spine.TextureWrap.Repeat;\n\t\t\t\t\telse if (direction == \"xy\")\n\t\t\t\t\t\tpage.uWrap = page.vWrap = spine.TextureWrap.Repeat;\n\t\t\t\t\tpage.texture = textureLoader(line);\n\t\t\t\t\tpage.texture.setFilters(page.minFilter, page.magFilter);\n\t\t\t\t\tpage.texture.setWraps(page.uWrap, page.vWrap);\n\t\t\t\t\tpage.width = page.texture.getImage().width;\n\t\t\t\t\tpage.height = page.texture.getImage().height;\n\t\t\t\t\tthis.pages.push(page);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tvar region = new TextureAtlasRegion();\n\t\t\t\t\tregion.name = line;\n\t\t\t\t\tregion.page = page;\n\t\t\t\t\tregion.rotate = reader.readValue() == \"true\";\n\t\t\t\t\treader.readTuple(tuple);\n\t\t\t\t\tvar x = parseInt(tuple[0]);\n\t\t\t\t\tvar y = parseInt(tuple[1]);\n\t\t\t\t\treader.readTuple(tuple);\n\t\t\t\t\tvar width = parseInt(tuple[0]);\n\t\t\t\t\tvar height = parseInt(tuple[1]);\n\t\t\t\t\tregion.u = x / page.width;\n\t\t\t\t\tregion.v = y / page.height;\n\t\t\t\t\tif (region.rotate) {\n\t\t\t\t\t\tregion.u2 = (x + height) / page.width;\n\t\t\t\t\t\tregion.v2 = (y + width) / page.height;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tregion.u2 = (x + width) / page.width;\n\t\t\t\t\t\tregion.v2 = (y + height) / page.height;\n\t\t\t\t\t}\n\t\t\t\t\tregion.x = x;\n\t\t\t\t\tregion.y = y;\n\t\t\t\t\tregion.width = Math.abs(width);\n\t\t\t\t\tregion.height = Math.abs(height);\n\t\t\t\t\tif (reader.readTuple(tuple) == 4) {\n\t\t\t\t\t\tif (reader.readTuple(tuple) == 4) {\n\t\t\t\t\t\t\treader.readTuple(tuple);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tregion.originalWidth = parseInt(tuple[0]);\n\t\t\t\t\tregion.originalHeight = parseInt(tuple[1]);\n\t\t\t\t\treader.readTuple(tuple);\n\t\t\t\t\tregion.offsetX = parseInt(tuple[0]);\n\t\t\t\t\tregion.offsetY = parseInt(tuple[1]);\n\t\t\t\t\tregion.index = parseInt(reader.readValue());\n\t\t\t\t\tregion.texture = page.texture;\n\t\t\t\t\tthis.regions.push(region);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tTextureAtlas.prototype.findRegion = function (name) {\n\t\t\tfor (var i = 0; i < this.regions.length; i++) {\n\t\t\t\tif (this.regions[i].name == name) {\n\t\t\t\t\treturn this.regions[i];\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t};\n\t\tTextureAtlas.prototype.dispose = function () {\n\t\t\tfor (var i = 0; i < this.pages.length; i++) {\n\t\t\t\tthis.pages[i].texture.dispose();\n\t\t\t}\n\t\t};\n\t\treturn TextureAtlas;\n\t}());\n\tspine.TextureAtlas = TextureAtlas;\n\tvar TextureAtlasReader = (function () {\n\t\tfunction TextureAtlasReader(text) {\n\t\t\tthis.index = 0;\n\t\t\tthis.lines = text.split(/\\r\\n|\\r|\\n/);\n\t\t}\n\t\tTextureAtlasReader.prototype.readLine = function () {\n\t\t\tif (this.index >= this.lines.length)\n\t\t\t\treturn null;\n\t\t\treturn this.lines[this.index++];\n\t\t};\n\t\tTextureAtlasReader.prototype.readValue = function () {\n\t\t\tvar line = this.readLine();\n\t\t\tvar colon = line.indexOf(\":\");\n\t\t\tif (colon == -1)\n\t\t\t\tthrow new Error(\"Invalid line: \" + line);\n\t\t\treturn line.substring(colon + 1).trim();\n\t\t};\n\t\tTextureAtlasReader.prototype.readTuple = function (tuple) {\n\t\t\tvar line = this.readLine();\n\t\t\tvar colon = line.indexOf(\":\");\n\t\t\tif (colon == -1)\n\t\t\t\tthrow new Error(\"Invalid line: \" + line);\n\t\t\tvar i = 0, lastMatch = colon + 1;\n\t\t\tfor (; i < 3; i++) {\n\t\t\t\tvar comma = line.indexOf(\",\", lastMatch);\n\t\t\t\tif (comma == -1)\n\t\t\t\t\tbreak;\n\t\t\t\ttuple[i] = line.substr(lastMatch, comma - lastMatch).trim();\n\t\t\t\tlastMatch = comma + 1;\n\t\t\t}\n\t\t\ttuple[i] = line.substring(lastMatch).trim();\n\t\t\treturn i + 1;\n\t\t};\n\t\treturn TextureAtlasReader;\n\t}());\n\tvar TextureAtlasPage = (function () {\n\t\tfunction TextureAtlasPage() {\n\t\t}\n\t\treturn TextureAtlasPage;\n\t}());\n\tspine.TextureAtlasPage = TextureAtlasPage;\n\tvar TextureAtlasRegion = (function (_super) {\n\t\t__extends(TextureAtlasRegion, _super);\n\t\tfunction TextureAtlasRegion() {\n\t\t\treturn _super !== null && _super.apply(this, arguments) || this;\n\t\t}\n\t\treturn TextureAtlasRegion;\n\t}(spine.TextureRegion));\n\tspine.TextureAtlasRegion = TextureAtlasRegion;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar TransformConstraint = (function () {\n\t\tfunction TransformConstraint(data, skeleton) {\n\t\t\tthis.rotateMix = 0;\n\t\t\tthis.translateMix = 0;\n\t\t\tthis.scaleMix = 0;\n\t\t\tthis.shearMix = 0;\n\t\t\tthis.temp = new spine.Vector2();\n\t\t\tif (data == null)\n\t\t\t\tthrow new Error(\"data cannot be null.\");\n\t\t\tif (skeleton == null)\n\t\t\t\tthrow new Error(\"skeleton cannot be null.\");\n\t\t\tthis.data = data;\n\t\t\tthis.rotateMix = data.rotateMix;\n\t\t\tthis.translateMix = data.translateMix;\n\t\t\tthis.scaleMix = data.scaleMix;\n\t\t\tthis.shearMix = data.shearMix;\n\t\t\tthis.bones = new Array();\n\t\t\tfor (var i = 0; i < data.bones.length; i++)\n\t\t\t\tthis.bones.push(skeleton.findBone(data.bones[i].name));\n\t\t\tthis.target = skeleton.findBone(data.target.name);\n\t\t}\n\t\tTransformConstraint.prototype.apply = function () {\n\t\t\tthis.update();\n\t\t};\n\t\tTransformConstraint.prototype.update = function () {\n\t\t\tif (this.data.local) {\n\t\t\t\tif (this.data.relative)\n\t\t\t\t\tthis.applyRelativeLocal();\n\t\t\t\telse\n\t\t\t\t\tthis.applyAbsoluteLocal();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this.data.relative)\n\t\t\t\t\tthis.applyRelativeWorld();\n\t\t\t\telse\n\t\t\t\t\tthis.applyAbsoluteWorld();\n\t\t\t}\n\t\t};\n\t\tTransformConstraint.prototype.applyAbsoluteWorld = function () {\n\t\t\tvar rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;\n\t\t\tvar target = this.target;\n\t\t\tvar ta = target.a, tb = target.b, tc = target.c, td = target.d;\n\t\t\tvar degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;\n\t\t\tvar offsetRotation = this.data.offsetRotation * degRadReflect;\n\t\t\tvar offsetShearY = this.data.offsetShearY * degRadReflect;\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++) {\n\t\t\t\tvar bone = bones[i];\n\t\t\t\tvar modified = false;\n\t\t\t\tif (rotateMix != 0) {\n\t\t\t\t\tvar a = bone.a, b = bone.b, c = bone.c, d = bone.d;\n\t\t\t\t\tvar r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation;\n\t\t\t\t\tif (r > spine.MathUtils.PI)\n\t\t\t\t\t\tr -= spine.MathUtils.PI2;\n\t\t\t\t\telse if (r < -spine.MathUtils.PI)\n\t\t\t\t\t\tr += spine.MathUtils.PI2;\n\t\t\t\t\tr *= rotateMix;\n\t\t\t\t\tvar cos = Math.cos(r), sin = Math.sin(r);\n\t\t\t\t\tbone.a = cos * a - sin * c;\n\t\t\t\t\tbone.b = cos * b - sin * d;\n\t\t\t\t\tbone.c = sin * a + cos * c;\n\t\t\t\t\tbone.d = sin * b + cos * d;\n\t\t\t\t\tmodified = true;\n\t\t\t\t}\n\t\t\t\tif (translateMix != 0) {\n\t\t\t\t\tvar temp = this.temp;\n\t\t\t\t\ttarget.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));\n\t\t\t\t\tbone.worldX += (temp.x - bone.worldX) * translateMix;\n\t\t\t\t\tbone.worldY += (temp.y - bone.worldY) * translateMix;\n\t\t\t\t\tmodified = true;\n\t\t\t\t}\n\t\t\t\tif (scaleMix > 0) {\n\t\t\t\t\tvar s = Math.sqrt(bone.a * bone.a + bone.c * bone.c);\n\t\t\t\t\tvar ts = Math.sqrt(ta * ta + tc * tc);\n\t\t\t\t\tif (s > 0.00001)\n\t\t\t\t\t\ts = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s;\n\t\t\t\t\tbone.a *= s;\n\t\t\t\t\tbone.c *= s;\n\t\t\t\t\ts = Math.sqrt(bone.b * bone.b + bone.d * bone.d);\n\t\t\t\t\tts = Math.sqrt(tb * tb + td * td);\n\t\t\t\t\tif (s > 0.00001)\n\t\t\t\t\t\ts = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s;\n\t\t\t\t\tbone.b *= s;\n\t\t\t\t\tbone.d *= s;\n\t\t\t\t\tmodified = true;\n\t\t\t\t}\n\t\t\t\tif (shearMix > 0) {\n\t\t\t\t\tvar b = bone.b, d = bone.d;\n\t\t\t\t\tvar by = Math.atan2(d, b);\n\t\t\t\t\tvar r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(bone.c, bone.a));\n\t\t\t\t\tif (r > spine.MathUtils.PI)\n\t\t\t\t\t\tr -= spine.MathUtils.PI2;\n\t\t\t\t\telse if (r < -spine.MathUtils.PI)\n\t\t\t\t\t\tr += spine.MathUtils.PI2;\n\t\t\t\t\tr = by + (r + offsetShearY) * shearMix;\n\t\t\t\t\tvar s = Math.sqrt(b * b + d * d);\n\t\t\t\t\tbone.b = Math.cos(r) * s;\n\t\t\t\t\tbone.d = Math.sin(r) * s;\n\t\t\t\t\tmodified = true;\n\t\t\t\t}\n\t\t\t\tif (modified)\n\t\t\t\t\tbone.appliedValid = false;\n\t\t\t}\n\t\t};\n\t\tTransformConstraint.prototype.applyRelativeWorld = function () {\n\t\t\tvar rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;\n\t\t\tvar target = this.target;\n\t\t\tvar ta = target.a, tb = target.b, tc = target.c, td = target.d;\n\t\t\tvar degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad;\n\t\t\tvar offsetRotation = this.data.offsetRotation * degRadReflect, offsetShearY = this.data.offsetShearY * degRadReflect;\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++) {\n\t\t\t\tvar bone = bones[i];\n\t\t\t\tvar modified = false;\n\t\t\t\tif (rotateMix != 0) {\n\t\t\t\t\tvar a = bone.a, b = bone.b, c = bone.c, d = bone.d;\n\t\t\t\t\tvar r = Math.atan2(tc, ta) + offsetRotation;\n\t\t\t\t\tif (r > spine.MathUtils.PI)\n\t\t\t\t\t\tr -= spine.MathUtils.PI2;\n\t\t\t\t\telse if (r < -spine.MathUtils.PI)\n\t\t\t\t\t\tr += spine.MathUtils.PI2;\n\t\t\t\t\tr *= rotateMix;\n\t\t\t\t\tvar cos = Math.cos(r), sin = Math.sin(r);\n\t\t\t\t\tbone.a = cos * a - sin * c;\n\t\t\t\t\tbone.b = cos * b - sin * d;\n\t\t\t\t\tbone.c = sin * a + cos * c;\n\t\t\t\t\tbone.d = sin * b + cos * d;\n\t\t\t\t\tmodified = true;\n\t\t\t\t}\n\t\t\t\tif (translateMix != 0) {\n\t\t\t\t\tvar temp = this.temp;\n\t\t\t\t\ttarget.localToWorld(temp.set(this.data.offsetX, this.data.offsetY));\n\t\t\t\t\tbone.worldX += temp.x * translateMix;\n\t\t\t\t\tbone.worldY += temp.y * translateMix;\n\t\t\t\t\tmodified = true;\n\t\t\t\t}\n\t\t\t\tif (scaleMix > 0) {\n\t\t\t\t\tvar s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1;\n\t\t\t\t\tbone.a *= s;\n\t\t\t\t\tbone.c *= s;\n\t\t\t\t\ts = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1;\n\t\t\t\t\tbone.b *= s;\n\t\t\t\t\tbone.d *= s;\n\t\t\t\t\tmodified = true;\n\t\t\t\t}\n\t\t\t\tif (shearMix > 0) {\n\t\t\t\t\tvar r = Math.atan2(td, tb) - Math.atan2(tc, ta);\n\t\t\t\t\tif (r > spine.MathUtils.PI)\n\t\t\t\t\t\tr -= spine.MathUtils.PI2;\n\t\t\t\t\telse if (r < -spine.MathUtils.PI)\n\t\t\t\t\t\tr += spine.MathUtils.PI2;\n\t\t\t\t\tvar b = bone.b, d = bone.d;\n\t\t\t\t\tr = Math.atan2(d, b) + (r - spine.MathUtils.PI / 2 + offsetShearY) * shearMix;\n\t\t\t\t\tvar s = Math.sqrt(b * b + d * d);\n\t\t\t\t\tbone.b = Math.cos(r) * s;\n\t\t\t\t\tbone.d = Math.sin(r) * s;\n\t\t\t\t\tmodified = true;\n\t\t\t\t}\n\t\t\t\tif (modified)\n\t\t\t\t\tbone.appliedValid = false;\n\t\t\t}\n\t\t};\n\t\tTransformConstraint.prototype.applyAbsoluteLocal = function () {\n\t\t\tvar rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;\n\t\t\tvar target = this.target;\n\t\t\tif (!target.appliedValid)\n\t\t\t\ttarget.updateAppliedTransform();\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++) {\n\t\t\t\tvar bone = bones[i];\n\t\t\t\tif (!bone.appliedValid)\n\t\t\t\t\tbone.updateAppliedTransform();\n\t\t\t\tvar rotation = bone.arotation;\n\t\t\t\tif (rotateMix != 0) {\n\t\t\t\t\tvar r = target.arotation - rotation + this.data.offsetRotation;\n\t\t\t\t\tr -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;\n\t\t\t\t\trotation += r * rotateMix;\n\t\t\t\t}\n\t\t\t\tvar x = bone.ax, y = bone.ay;\n\t\t\t\tif (translateMix != 0) {\n\t\t\t\t\tx += (target.ax - x + this.data.offsetX) * translateMix;\n\t\t\t\t\ty += (target.ay - y + this.data.offsetY) * translateMix;\n\t\t\t\t}\n\t\t\t\tvar scaleX = bone.ascaleX, scaleY = bone.ascaleY;\n\t\t\t\tif (scaleMix > 0) {\n\t\t\t\t\tif (scaleX > 0.00001)\n\t\t\t\t\t\tscaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX;\n\t\t\t\t\tif (scaleY > 0.00001)\n\t\t\t\t\t\tscaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY;\n\t\t\t\t}\n\t\t\t\tvar shearY = bone.ashearY;\n\t\t\t\tif (shearMix > 0) {\n\t\t\t\t\tvar r = target.ashearY - shearY + this.data.offsetShearY;\n\t\t\t\t\tr -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360;\n\t\t\t\t\tbone.shearY += r * shearMix;\n\t\t\t\t}\n\t\t\t\tbone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);\n\t\t\t}\n\t\t};\n\t\tTransformConstraint.prototype.applyRelativeLocal = function () {\n\t\t\tvar rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix;\n\t\t\tvar target = this.target;\n\t\t\tif (!target.appliedValid)\n\t\t\t\ttarget.updateAppliedTransform();\n\t\t\tvar bones = this.bones;\n\t\t\tfor (var i = 0, n = bones.length; i < n; i++) {\n\t\t\t\tvar bone = bones[i];\n\t\t\t\tif (!bone.appliedValid)\n\t\t\t\t\tbone.updateAppliedTransform();\n\t\t\t\tvar rotation = bone.arotation;\n\t\t\t\tif (rotateMix != 0)\n\t\t\t\t\trotation += (target.arotation + this.data.offsetRotation) * rotateMix;\n\t\t\t\tvar x = bone.ax, y = bone.ay;\n\t\t\t\tif (translateMix != 0) {\n\t\t\t\t\tx += (target.ax + this.data.offsetX) * translateMix;\n\t\t\t\t\ty += (target.ay + this.data.offsetY) * translateMix;\n\t\t\t\t}\n\t\t\t\tvar scaleX = bone.ascaleX, scaleY = bone.ascaleY;\n\t\t\t\tif (scaleMix > 0) {\n\t\t\t\t\tif (scaleX > 0.00001)\n\t\t\t\t\t\tscaleX *= ((target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix) + 1;\n\t\t\t\t\tif (scaleY > 0.00001)\n\t\t\t\t\t\tscaleY *= ((target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix) + 1;\n\t\t\t\t}\n\t\t\t\tvar shearY = bone.ashearY;\n\t\t\t\tif (shearMix > 0)\n\t\t\t\t\tshearY += (target.ashearY + this.data.offsetShearY) * shearMix;\n\t\t\t\tbone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY);\n\t\t\t}\n\t\t};\n\t\tTransformConstraint.prototype.getOrder = function () {\n\t\t\treturn this.data.order;\n\t\t};\n\t\treturn TransformConstraint;\n\t}());\n\tspine.TransformConstraint = TransformConstraint;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar TransformConstraintData = (function () {\n\t\tfunction TransformConstraintData(name) {\n\t\t\tthis.order = 0;\n\t\t\tthis.bones = new Array();\n\t\t\tthis.rotateMix = 0;\n\t\t\tthis.translateMix = 0;\n\t\t\tthis.scaleMix = 0;\n\t\t\tthis.shearMix = 0;\n\t\t\tthis.offsetRotation = 0;\n\t\t\tthis.offsetX = 0;\n\t\t\tthis.offsetY = 0;\n\t\t\tthis.offsetScaleX = 0;\n\t\t\tthis.offsetScaleY = 0;\n\t\t\tthis.offsetShearY = 0;\n\t\t\tthis.relative = false;\n\t\t\tthis.local = false;\n\t\t\tif (name == null)\n\t\t\t\tthrow new Error(\"name cannot be null.\");\n\t\t\tthis.name = name;\n\t\t}\n\t\treturn TransformConstraintData;\n\t}());\n\tspine.TransformConstraintData = TransformConstraintData;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar Triangulator = (function () {\n\t\tfunction Triangulator() {\n\t\t\tthis.convexPolygons = new Array();\n\t\t\tthis.convexPolygonsIndices = new Array();\n\t\t\tthis.indicesArray = new Array();\n\t\t\tthis.isConcaveArray = new Array();\n\t\t\tthis.triangles = new Array();\n\t\t\tthis.polygonPool = new spine.Pool(function () {\n\t\t\t\treturn new Array();\n\t\t\t});\n\t\t\tthis.polygonIndicesPool = new spine.Pool(function () {\n\t\t\t\treturn new Array();\n\t\t\t});\n\t\t}\n\t\tTriangulator.prototype.triangulate = function (verticesArray) {\n\t\t\tvar vertices = verticesArray;\n\t\t\tvar vertexCount = verticesArray.length >> 1;\n\t\t\tvar indices = this.indicesArray;\n\t\t\tindices.length = 0;\n\t\t\tfor (var i = 0; i < vertexCount; i++)\n\t\t\t\tindices[i] = i;\n\t\t\tvar isConcave = this.isConcaveArray;\n\t\t\tisConcave.length = 0;\n\t\t\tfor (var i = 0, n = vertexCount; i < n; ++i)\n\t\t\t\tisConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices);\n\t\t\tvar triangles = this.triangles;\n\t\t\ttriangles.length = 0;\n\t\t\twhile (vertexCount > 3) {\n\t\t\t\tvar previous = vertexCount - 1, i = 0, next = 1;\n\t\t\t\twhile (true) {\n\t\t\t\t\touter: if (!isConcave[i]) {\n\t\t\t\t\t\tvar p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1;\n\t\t\t\t\t\tvar p1x = vertices[p1], p1y = vertices[p1 + 1];\n\t\t\t\t\t\tvar p2x = vertices[p2], p2y = vertices[p2 + 1];\n\t\t\t\t\t\tvar p3x = vertices[p3], p3y = vertices[p3 + 1];\n\t\t\t\t\t\tfor (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) {\n\t\t\t\t\t\t\tif (!isConcave[ii])\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\tvar v = indices[ii] << 1;\n\t\t\t\t\t\t\tvar vx = vertices[v], vy = vertices[v + 1];\n\t\t\t\t\t\t\tif (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) {\n\t\t\t\t\t\t\t\tif (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) {\n\t\t\t\t\t\t\t\t\tif (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy))\n\t\t\t\t\t\t\t\t\t\tbreak outer;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (next == 0) {\n\t\t\t\t\t\tdo {\n\t\t\t\t\t\t\tif (!isConcave[i])\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\ti--;\n\t\t\t\t\t\t} while (i > 0);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tprevious = i;\n\t\t\t\t\ti = next;\n\t\t\t\t\tnext = (next + 1) % vertexCount;\n\t\t\t\t}\n\t\t\t\ttriangles.push(indices[(vertexCount + i - 1) % vertexCount]);\n\t\t\t\ttriangles.push(indices[i]);\n\t\t\t\ttriangles.push(indices[(i + 1) % vertexCount]);\n\t\t\t\tindices.splice(i, 1);\n\t\t\t\tisConcave.splice(i, 1);\n\t\t\t\tvertexCount--;\n\t\t\t\tvar previousIndex = (vertexCount + i - 1) % vertexCount;\n\t\t\t\tvar nextIndex = i == vertexCount ? 0 : i;\n\t\t\t\tisConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices);\n\t\t\t\tisConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices);\n\t\t\t}\n\t\t\tif (vertexCount == 3) {\n\t\t\t\ttriangles.push(indices[2]);\n\t\t\t\ttriangles.push(indices[0]);\n\t\t\t\ttriangles.push(indices[1]);\n\t\t\t}\n\t\t\treturn triangles;\n\t\t};\n\t\tTriangulator.prototype.decompose = function (verticesArray, triangles) {\n\t\t\tvar vertices = verticesArray;\n\t\t\tvar convexPolygons = this.convexPolygons;\n\t\t\tthis.polygonPool.freeAll(convexPolygons);\n\t\t\tconvexPolygons.length = 0;\n\t\t\tvar convexPolygonsIndices = this.convexPolygonsIndices;\n\t\t\tthis.polygonIndicesPool.freeAll(convexPolygonsIndices);\n\t\t\tconvexPolygonsIndices.length = 0;\n\t\t\tvar polygonIndices = this.polygonIndicesPool.obtain();\n\t\t\tpolygonIndices.length = 0;\n\t\t\tvar polygon = this.polygonPool.obtain();\n\t\t\tpolygon.length = 0;\n\t\t\tvar fanBaseIndex = -1, lastWinding = 0;\n\t\t\tfor (var i = 0, n = triangles.length; i < n; i += 3) {\n\t\t\t\tvar t1 = triangles[i] << 1, t2 = triangles[i + 1] << 1, t3 = triangles[i + 2] << 1;\n\t\t\t\tvar x1 = vertices[t1], y1 = vertices[t1 + 1];\n\t\t\t\tvar x2 = vertices[t2], y2 = vertices[t2 + 1];\n\t\t\t\tvar x3 = vertices[t3], y3 = vertices[t3 + 1];\n\t\t\t\tvar merged = false;\n\t\t\t\tif (fanBaseIndex == t1) {\n\t\t\t\t\tvar o = polygon.length - 4;\n\t\t\t\t\tvar winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3);\n\t\t\t\t\tvar winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]);\n\t\t\t\t\tif (winding1 == lastWinding && winding2 == lastWinding) {\n\t\t\t\t\t\tpolygon.push(x3);\n\t\t\t\t\t\tpolygon.push(y3);\n\t\t\t\t\t\tpolygonIndices.push(t3);\n\t\t\t\t\t\tmerged = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!merged) {\n\t\t\t\t\tif (polygon.length > 0) {\n\t\t\t\t\t\tconvexPolygons.push(polygon);\n\t\t\t\t\t\tconvexPolygonsIndices.push(polygonIndices);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.polygonPool.free(polygon);\n\t\t\t\t\t\tthis.polygonIndicesPool.free(polygonIndices);\n\t\t\t\t\t}\n\t\t\t\t\tpolygon = this.polygonPool.obtain();\n\t\t\t\t\tpolygon.length = 0;\n\t\t\t\t\tpolygon.push(x1);\n\t\t\t\t\tpolygon.push(y1);\n\t\t\t\t\tpolygon.push(x2);\n\t\t\t\t\tpolygon.push(y2);\n\t\t\t\t\tpolygon.push(x3);\n\t\t\t\t\tpolygon.push(y3);\n\t\t\t\t\tpolygonIndices = this.polygonIndicesPool.obtain();\n\t\t\t\t\tpolygonIndices.length = 0;\n\t\t\t\t\tpolygonIndices.push(t1);\n\t\t\t\t\tpolygonIndices.push(t2);\n\t\t\t\t\tpolygonIndices.push(t3);\n\t\t\t\t\tlastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3);\n\t\t\t\t\tfanBaseIndex = t1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (polygon.length > 0) {\n\t\t\t\tconvexPolygons.push(polygon);\n\t\t\t\tconvexPolygonsIndices.push(polygonIndices);\n\t\t\t}\n\t\t\tfor (var i = 0, n = convexPolygons.length; i < n; i++) {\n\t\t\t\tpolygonIndices = convexPolygonsIndices[i];\n\t\t\t\tif (polygonIndices.length == 0)\n\t\t\t\t\tcontinue;\n\t\t\t\tvar firstIndex = polygonIndices[0];\n\t\t\t\tvar lastIndex = polygonIndices[polygonIndices.length - 1];\n\t\t\t\tpolygon = convexPolygons[i];\n\t\t\t\tvar o = polygon.length - 4;\n\t\t\t\tvar prevPrevX = polygon[o], prevPrevY = polygon[o + 1];\n\t\t\t\tvar prevX = polygon[o + 2], prevY = polygon[o + 3];\n\t\t\t\tvar firstX = polygon[0], firstY = polygon[1];\n\t\t\t\tvar secondX = polygon[2], secondY = polygon[3];\n\t\t\t\tvar winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY);\n\t\t\t\tfor (var ii = 0; ii < n; ii++) {\n\t\t\t\t\tif (ii == i)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tvar otherIndices = convexPolygonsIndices[ii];\n\t\t\t\t\tif (otherIndices.length != 3)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tvar otherFirstIndex = otherIndices[0];\n\t\t\t\t\tvar otherSecondIndex = otherIndices[1];\n\t\t\t\t\tvar otherLastIndex = otherIndices[2];\n\t\t\t\t\tvar otherPoly = convexPolygons[ii];\n\t\t\t\t\tvar x3 = otherPoly[otherPoly.length - 2], y3 = otherPoly[otherPoly.length - 1];\n\t\t\t\t\tif (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tvar winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3);\n\t\t\t\t\tvar winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY);\n\t\t\t\t\tif (winding1 == winding && winding2 == winding) {\n\t\t\t\t\t\totherPoly.length = 0;\n\t\t\t\t\t\totherIndices.length = 0;\n\t\t\t\t\t\tpolygon.push(x3);\n\t\t\t\t\t\tpolygon.push(y3);\n\t\t\t\t\t\tpolygonIndices.push(otherLastIndex);\n\t\t\t\t\t\tprevPrevX = prevX;\n\t\t\t\t\t\tprevPrevY = prevY;\n\t\t\t\t\t\tprevX = x3;\n\t\t\t\t\t\tprevY = y3;\n\t\t\t\t\t\tii = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (var i = convexPolygons.length - 1; i >= 0; i--) {\n\t\t\t\tpolygon = convexPolygons[i];\n\t\t\t\tif (polygon.length == 0) {\n\t\t\t\t\tconvexPolygons.splice(i, 1);\n\t\t\t\t\tthis.polygonPool.free(polygon);\n\t\t\t\t\tpolygonIndices = convexPolygonsIndices[i];\n\t\t\t\t\tconvexPolygonsIndices.splice(i, 1);\n\t\t\t\t\tthis.polygonIndicesPool.free(polygonIndices);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn convexPolygons;\n\t\t};\n\t\tTriangulator.isConcave = function (index, vertexCount, vertices, indices) {\n\t\t\tvar previous = indices[(vertexCount + index - 1) % vertexCount] << 1;\n\t\t\tvar current = indices[index] << 1;\n\t\t\tvar next = indices[(index + 1) % vertexCount] << 1;\n\t\t\treturn !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]);\n\t\t};\n\t\tTriangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) {\n\t\t\treturn p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0;\n\t\t};\n\t\tTriangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) {\n\t\t\tvar px = p2x - p1x, py = p2y - p1y;\n\t\t\treturn p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1;\n\t\t};\n\t\treturn Triangulator;\n\t}());\n\tspine.Triangulator = Triangulator;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar IntSet = (function () {\n\t\tfunction IntSet() {\n\t\t\tthis.array = new Array();\n\t\t}\n\t\tIntSet.prototype.add = function (value) {\n\t\t\tvar contains = this.contains(value);\n\t\t\tthis.array[value | 0] = value | 0;\n\t\t\treturn !contains;\n\t\t};\n\t\tIntSet.prototype.contains = function (value) {\n\t\t\treturn this.array[value | 0] != undefined;\n\t\t};\n\t\tIntSet.prototype.remove = function (value) {\n\t\t\tthis.array[value | 0] = undefined;\n\t\t};\n\t\tIntSet.prototype.clear = function () {\n\t\t\tthis.array.length = 0;\n\t\t};\n\t\treturn IntSet;\n\t}());\n\tspine.IntSet = IntSet;\n\tvar Color = (function () {\n\t\tfunction Color(r, g, b, a) {\n\t\t\tif (r === void 0) { r = 0; }\n\t\t\tif (g === void 0) { g = 0; }\n\t\t\tif (b === void 0) { b = 0; }\n\t\t\tif (a === void 0) { a = 0; }\n\t\t\tthis.r = r;\n\t\t\tthis.g = g;\n\t\t\tthis.b = b;\n\t\t\tthis.a = a;\n\t\t}\n\t\tColor.prototype.set = function (r, g, b, a) {\n\t\t\tthis.r = r;\n\t\t\tthis.g = g;\n\t\t\tthis.b = b;\n\t\t\tthis.a = a;\n\t\t\tthis.clamp();\n\t\t\treturn this;\n\t\t};\n\t\tColor.prototype.setFromColor = function (c) {\n\t\t\tthis.r = c.r;\n\t\t\tthis.g = c.g;\n\t\t\tthis.b = c.b;\n\t\t\tthis.a = c.a;\n\t\t\treturn this;\n\t\t};\n\t\tColor.prototype.setFromString = function (hex) {\n\t\t\thex = hex.charAt(0) == '#' ? hex.substr(1) : hex;\n\t\t\tthis.r = parseInt(hex.substr(0, 2), 16) / 255.0;\n\t\t\tthis.g = parseInt(hex.substr(2, 2), 16) / 255.0;\n\t\t\tthis.b = parseInt(hex.substr(4, 2), 16) / 255.0;\n\t\t\tthis.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0;\n\t\t\treturn this;\n\t\t};\n\t\tColor.prototype.add = function (r, g, b, a) {\n\t\t\tthis.r += r;\n\t\t\tthis.g += g;\n\t\t\tthis.b += b;\n\t\t\tthis.a += a;\n\t\t\tthis.clamp();\n\t\t\treturn this;\n\t\t};\n\t\tColor.prototype.clamp = function () {\n\t\t\tif (this.r < 0)\n\t\t\t\tthis.r = 0;\n\t\t\telse if (this.r > 1)\n\t\t\t\tthis.r = 1;\n\t\t\tif (this.g < 0)\n\t\t\t\tthis.g = 0;\n\t\t\telse if (this.g > 1)\n\t\t\t\tthis.g = 1;\n\t\t\tif (this.b < 0)\n\t\t\t\tthis.b = 0;\n\t\t\telse if (this.b > 1)\n\t\t\t\tthis.b = 1;\n\t\t\tif (this.a < 0)\n\t\t\t\tthis.a = 0;\n\t\t\telse if (this.a > 1)\n\t\t\t\tthis.a = 1;\n\t\t\treturn this;\n\t\t};\n\t\tColor.WHITE = new Color(1, 1, 1, 1);\n\t\tColor.RED = new Color(1, 0, 0, 1);\n\t\tColor.GREEN = new Color(0, 1, 0, 1);\n\t\tColor.BLUE = new Color(0, 0, 1, 1);\n\t\tColor.MAGENTA = new Color(1, 0, 1, 1);\n\t\treturn Color;\n\t}());\n\tspine.Color = Color;\n\tvar MathUtils = (function () {\n\t\tfunction MathUtils() {\n\t\t}\n\t\tMathUtils.clamp = function (value, min, max) {\n\t\t\tif (value < min)\n\t\t\t\treturn min;\n\t\t\tif (value > max)\n\t\t\t\treturn max;\n\t\t\treturn value;\n\t\t};\n\t\tMathUtils.cosDeg = function (degrees) {\n\t\t\treturn Math.cos(degrees * MathUtils.degRad);\n\t\t};\n\t\tMathUtils.sinDeg = function (degrees) {\n\t\t\treturn Math.sin(degrees * MathUtils.degRad);\n\t\t};\n\t\tMathUtils.signum = function (value) {\n\t\t\treturn value > 0 ? 1 : value < 0 ? -1 : 0;\n\t\t};\n\t\tMathUtils.toInt = function (x) {\n\t\t\treturn x > 0 ? Math.floor(x) : Math.ceil(x);\n\t\t};\n\t\tMathUtils.cbrt = function (x) {\n\t\t\tvar y = Math.pow(Math.abs(x), 1 / 3);\n\t\t\treturn x < 0 ? -y : y;\n\t\t};\n\t\tMathUtils.randomTriangular = function (min, max) {\n\t\t\treturn MathUtils.randomTriangularWith(min, max, (min + max) * 0.5);\n\t\t};\n\t\tMathUtils.randomTriangularWith = function (min, max, mode) {\n\t\t\tvar u = Math.random();\n\t\t\tvar d = max - min;\n\t\t\tif (u <= (mode - min) / d)\n\t\t\t\treturn min + Math.sqrt(u * d * (mode - min));\n\t\t\treturn max - Math.sqrt((1 - u) * d * (max - mode));\n\t\t};\n\t\tMathUtils.PI = 3.1415927;\n\t\tMathUtils.PI2 = MathUtils.PI * 2;\n\t\tMathUtils.radiansToDegrees = 180 / MathUtils.PI;\n\t\tMathUtils.radDeg = MathUtils.radiansToDegrees;\n\t\tMathUtils.degreesToRadians = MathUtils.PI / 180;\n\t\tMathUtils.degRad = MathUtils.degreesToRadians;\n\t\treturn MathUtils;\n\t}());\n\tspine.MathUtils = MathUtils;\n\tvar Interpolation = (function () {\n\t\tfunction Interpolation() {\n\t\t}\n\t\tInterpolation.prototype.apply = function (start, end, a) {\n\t\t\treturn start + (end - start) * this.applyInternal(a);\n\t\t};\n\t\treturn Interpolation;\n\t}());\n\tspine.Interpolation = Interpolation;\n\tvar Pow = (function (_super) {\n\t\t__extends(Pow, _super);\n\t\tfunction Pow(power) {\n\t\t\tvar _this = _super.call(this) || this;\n\t\t\t_this.power = 2;\n\t\t\t_this.power = power;\n\t\t\treturn _this;\n\t\t}\n\t\tPow.prototype.applyInternal = function (a) {\n\t\t\tif (a <= 0.5)\n\t\t\t\treturn Math.pow(a * 2, this.power) / 2;\n\t\t\treturn Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1;\n\t\t};\n\t\treturn Pow;\n\t}(Interpolation));\n\tspine.Pow = Pow;\n\tvar PowOut = (function (_super) {\n\t\t__extends(PowOut, _super);\n\t\tfunction PowOut(power) {\n\t\t\treturn _super.call(this, power) || this;\n\t\t}\n\t\tPowOut.prototype.applyInternal = function (a) {\n\t\t\treturn Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1;\n\t\t};\n\t\treturn PowOut;\n\t}(Pow));\n\tspine.PowOut = PowOut;\n\tvar Utils = (function () {\n\t\tfunction Utils() {\n\t\t}\n\t\tUtils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) {\n\t\t\tfor (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) {\n\t\t\t\tdest[j] = source[i];\n\t\t\t}\n\t\t};\n\t\tUtils.setArraySize = function (array, size, value) {\n\t\t\tif (value === void 0) { value = 0; }\n\t\t\tvar oldSize = array.length;\n\t\t\tif (oldSize == size)\n\t\t\t\treturn array;\n\t\t\tarray.length = size;\n\t\t\tif (oldSize < size) {\n\t\t\t\tfor (var i = oldSize; i < size; i++)\n\t\t\t\t\tarray[i] = value;\n\t\t\t}\n\t\t\treturn array;\n\t\t};\n\t\tUtils.ensureArrayCapacity = function (array, size, value) {\n\t\t\tif (value === void 0) { value = 0; }\n\t\t\tif (array.length >= size)\n\t\t\t\treturn array;\n\t\t\treturn Utils.setArraySize(array, size, value);\n\t\t};\n\t\tUtils.newArray = function (size, defaultValue) {\n\t\t\tvar array = new Array(size);\n\t\t\tfor (var i = 0; i < size; i++)\n\t\t\t\tarray[i] = defaultValue;\n\t\t\treturn array;\n\t\t};\n\t\tUtils.newFloatArray = function (size) {\n\t\t\tif (Utils.SUPPORTS_TYPED_ARRAYS) {\n\t\t\t\treturn new Float32Array(size);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar array = new Array(size);\n\t\t\t\tfor (var i = 0; i < array.length; i++)\n\t\t\t\t\tarray[i] = 0;\n\t\t\t\treturn array;\n\t\t\t}\n\t\t};\n\t\tUtils.newShortArray = function (size) {\n\t\t\tif (Utils.SUPPORTS_TYPED_ARRAYS) {\n\t\t\t\treturn new Int16Array(size);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar array = new Array(size);\n\t\t\t\tfor (var i = 0; i < array.length; i++)\n\t\t\t\t\tarray[i] = 0;\n\t\t\t\treturn array;\n\t\t\t}\n\t\t};\n\t\tUtils.toFloatArray = function (array) {\n\t\t\treturn Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;\n\t\t};\n\t\tUtils.toSinglePrecision = function (value) {\n\t\t\treturn Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;\n\t\t};\n\t\tUtils.webkit602BugfixHelper = function (alpha, pose) {\n\t\t};\n\t\tUtils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== \"undefined\";\n\t\treturn Utils;\n\t}());\n\tspine.Utils = Utils;\n\tvar DebugUtils = (function () {\n\t\tfunction DebugUtils() {\n\t\t}\n\t\tDebugUtils.logBones = function (skeleton) {\n\t\t\tfor (var i = 0; i < skeleton.bones.length; i++) {\n\t\t\t\tvar bone = skeleton.bones[i];\n\t\t\t\tconsole.log(bone.data.name + \", \" + bone.a + \", \" + bone.b + \", \" + bone.c + \", \" + bone.d + \", \" + bone.worldX + \", \" + bone.worldY);\n\t\t\t}\n\t\t};\n\t\treturn DebugUtils;\n\t}());\n\tspine.DebugUtils = DebugUtils;\n\tvar Pool = (function () {\n\t\tfunction Pool(instantiator) {\n\t\t\tthis.items = new Array();\n\t\t\tthis.instantiator = instantiator;\n\t\t}\n\t\tPool.prototype.obtain = function () {\n\t\t\treturn this.items.length > 0 ? this.items.pop() : this.instantiator();\n\t\t};\n\t\tPool.prototype.free = function (item) {\n\t\t\tif (item.reset)\n\t\t\t\titem.reset();\n\t\t\tthis.items.push(item);\n\t\t};\n\t\tPool.prototype.freeAll = function (items) {\n\t\t\tfor (var i = 0; i < items.length; i++) {\n\t\t\t\tif (items[i].reset)\n\t\t\t\t\titems[i].reset();\n\t\t\t\tthis.items[i] = items[i];\n\t\t\t}\n\t\t};\n\t\tPool.prototype.clear = function () {\n\t\t\tthis.items.length = 0;\n\t\t};\n\t\treturn Pool;\n\t}());\n\tspine.Pool = Pool;\n\tvar Vector2 = (function () {\n\t\tfunction Vector2(x, y) {\n\t\t\tif (x === void 0) { x = 0; }\n\t\t\tif (y === void 0) { y = 0; }\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t}\n\t\tVector2.prototype.set = function (x, y) {\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t\treturn this;\n\t\t};\n\t\tVector2.prototype.length = function () {\n\t\t\tvar x = this.x;\n\t\t\tvar y = this.y;\n\t\t\treturn Math.sqrt(x * x + y * y);\n\t\t};\n\t\tVector2.prototype.normalize = function () {\n\t\t\tvar len = this.length();\n\t\t\tif (len != 0) {\n\t\t\t\tthis.x /= len;\n\t\t\t\tthis.y /= len;\n\t\t\t}\n\t\t\treturn this;\n\t\t};\n\t\treturn Vector2;\n\t}());\n\tspine.Vector2 = Vector2;\n\tvar TimeKeeper = (function () {\n\t\tfunction TimeKeeper() {\n\t\t\tthis.maxDelta = 0.064;\n\t\t\tthis.framesPerSecond = 0;\n\t\t\tthis.delta = 0;\n\t\t\tthis.totalTime = 0;\n\t\t\tthis.lastTime = Date.now() / 1000;\n\t\t\tthis.frameCount = 0;\n\t\t\tthis.frameTime = 0;\n\t\t}\n\t\tTimeKeeper.prototype.update = function () {\n\t\t\tvar now = Date.now() / 1000;\n\t\t\tthis.delta = now - this.lastTime;\n\t\t\tthis.frameTime += this.delta;\n\t\t\tthis.totalTime += this.delta;\n\t\t\tif (this.delta > this.maxDelta)\n\t\t\t\tthis.delta = this.maxDelta;\n\t\t\tthis.lastTime = now;\n\t\t\tthis.frameCount++;\n\t\t\tif (this.frameTime > 1) {\n\t\t\t\tthis.framesPerSecond = this.frameCount / this.frameTime;\n\t\t\t\tthis.frameTime = 0;\n\t\t\t\tthis.frameCount = 0;\n\t\t\t}\n\t\t};\n\t\treturn TimeKeeper;\n\t}());\n\tspine.TimeKeeper = TimeKeeper;\n\tvar WindowedMean = (function () {\n\t\tfunction WindowedMean(windowSize) {\n\t\t\tif (windowSize === void 0) { windowSize = 32; }\n\t\t\tthis.addedValues = 0;\n\t\t\tthis.lastValue = 0;\n\t\t\tthis.mean = 0;\n\t\t\tthis.dirty = true;\n\t\t\tthis.values = new Array(windowSize);\n\t\t}\n\t\tWindowedMean.prototype.hasEnoughData = function () {\n\t\t\treturn this.addedValues >= this.values.length;\n\t\t};\n\t\tWindowedMean.prototype.addValue = function (value) {\n\t\t\tif (this.addedValues < this.values.length)\n\t\t\t\tthis.addedValues++;\n\t\t\tthis.values[this.lastValue++] = value;\n\t\t\tif (this.lastValue > this.values.length - 1)\n\t\t\t\tthis.lastValue = 0;\n\t\t\tthis.dirty = true;\n\t\t};\n\t\tWindowedMean.prototype.getMean = function () {\n\t\t\tif (this.hasEnoughData()) {\n\t\t\t\tif (this.dirty) {\n\t\t\t\t\tvar mean = 0;\n\t\t\t\t\tfor (var i = 0; i < this.values.length; i++) {\n\t\t\t\t\t\tmean += this.values[i];\n\t\t\t\t\t}\n\t\t\t\t\tthis.mean = mean / this.values.length;\n\t\t\t\t\tthis.dirty = false;\n\t\t\t\t}\n\t\t\t\treturn this.mean;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t};\n\t\treturn WindowedMean;\n\t}());\n\tspine.WindowedMean = WindowedMean;\n})(spine || (spine = {}));\n(function () {\n\tif (!Math.fround) {\n\t\tMath.fround = (function (array) {\n\t\t\treturn function (x) {\n\t\t\t\treturn array[0] = x, array[0];\n\t\t\t};\n\t\t})(new Float32Array(1));\n\t}\n})();\nvar spine;\n(function (spine) {\n\tvar Attachment = (function () {\n\t\tfunction Attachment(name) {\n\t\t\tif (name == null)\n\t\t\t\tthrow new Error(\"name cannot be null.\");\n\t\t\tthis.name = name;\n\t\t}\n\t\treturn Attachment;\n\t}());\n\tspine.Attachment = Attachment;\n\tvar VertexAttachment = (function (_super) {\n\t\t__extends(VertexAttachment, _super);\n\t\tfunction VertexAttachment(name) {\n\t\t\tvar _this = _super.call(this, name) || this;\n\t\t\t_this.id = (VertexAttachment.nextID++ & 65535) << 11;\n\t\t\t_this.worldVerticesLength = 0;\n\t\t\treturn _this;\n\t\t}\n\t\tVertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) {\n\t\t\tcount = offset + (count >> 1) * stride;\n\t\t\tvar skeleton = slot.bone.skeleton;\n\t\t\tvar deformArray = slot.attachmentVertices;\n\t\t\tvar vertices = this.vertices;\n\t\t\tvar bones = this.bones;\n\t\t\tif (bones == null) {\n\t\t\t\tif (deformArray.length > 0)\n\t\t\t\t\tvertices = deformArray;\n\t\t\t\tvar bone = slot.bone;\n\t\t\t\tvar x = bone.worldX;\n\t\t\t\tvar y = bone.worldY;\n\t\t\t\tvar a = bone.a, b = bone.b, c = bone.c, d = bone.d;\n\t\t\t\tfor (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) {\n\t\t\t\t\tvar vx = vertices[v_1], vy = vertices[v_1 + 1];\n\t\t\t\t\tworldVertices[w] = vx * a + vy * b + x;\n\t\t\t\t\tworldVertices[w + 1] = vx * c + vy * d + y;\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvar v = 0, skip = 0;\n\t\t\tfor (var i = 0; i < start; i += 2) {\n\t\t\t\tvar n = bones[v];\n\t\t\t\tv += n + 1;\n\t\t\t\tskip += n;\n\t\t\t}\n\t\t\tvar skeletonBones = skeleton.bones;\n\t\t\tif (deformArray.length == 0) {\n\t\t\t\tfor (var w = offset, b = skip * 3; w < count; w += stride) {\n\t\t\t\t\tvar wx = 0, wy = 0;\n\t\t\t\t\tvar n = bones[v++];\n\t\t\t\t\tn += v;\n\t\t\t\t\tfor (; v < n; v++, b += 3) {\n\t\t\t\t\t\tvar bone = skeletonBones[bones[v]];\n\t\t\t\t\t\tvar vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2];\n\t\t\t\t\t\twx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;\n\t\t\t\t\t\twy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;\n\t\t\t\t\t}\n\t\t\t\t\tworldVertices[w] = wx;\n\t\t\t\t\tworldVertices[w + 1] = wy;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvar deform = deformArray;\n\t\t\t\tfor (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) {\n\t\t\t\t\tvar wx = 0, wy = 0;\n\t\t\t\t\tvar n = bones[v++];\n\t\t\t\t\tn += v;\n\t\t\t\t\tfor (; v < n; v++, b += 3, f += 2) {\n\t\t\t\t\t\tvar bone = skeletonBones[bones[v]];\n\t\t\t\t\t\tvar vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2];\n\t\t\t\t\t\twx += (vx * bone.a + vy * bone.b + bone.worldX) * weight;\n\t\t\t\t\t\twy += (vx * bone.c + vy * bone.d + bone.worldY) * weight;\n\t\t\t\t\t}\n\t\t\t\t\tworldVertices[w] = wx;\n\t\t\t\t\tworldVertices[w + 1] = wy;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tVertexAttachment.prototype.applyDeform = function (sourceAttachment) {\n\t\t\treturn this == sourceAttachment;\n\t\t};\n\t\tVertexAttachment.nextID = 0;\n\t\treturn VertexAttachment;\n\t}(Attachment));\n\tspine.VertexAttachment = VertexAttachment;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar AttachmentType;\n\t(function (AttachmentType) {\n\t\tAttachmentType[AttachmentType[\"Region\"] = 0] = \"Region\";\n\t\tAttachmentType[AttachmentType[\"BoundingBox\"] = 1] = \"BoundingBox\";\n\t\tAttachmentType[AttachmentType[\"Mesh\"] = 2] = \"Mesh\";\n\t\tAttachmentType[AttachmentType[\"LinkedMesh\"] = 3] = \"LinkedMesh\";\n\t\tAttachmentType[AttachmentType[\"Path\"] = 4] = \"Path\";\n\t\tAttachmentType[AttachmentType[\"Point\"] = 5] = \"Point\";\n\t})(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar BoundingBoxAttachment = (function (_super) {\n\t\t__extends(BoundingBoxAttachment, _super);\n\t\tfunction BoundingBoxAttachment(name) {\n\t\t\tvar _this = _super.call(this, name) || this;\n\t\t\t_this.color = new spine.Color(1, 1, 1, 1);\n\t\t\treturn _this;\n\t\t}\n\t\treturn BoundingBoxAttachment;\n\t}(spine.VertexAttachment));\n\tspine.BoundingBoxAttachment = BoundingBoxAttachment;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar ClippingAttachment = (function (_super) {\n\t\t__extends(ClippingAttachment, _super);\n\t\tfunction ClippingAttachment(name) {\n\t\t\tvar _this = _super.call(this, name) || this;\n\t\t\t_this.color = new spine.Color(0.2275, 0.2275, 0.8078, 1);\n\t\t\treturn _this;\n\t\t}\n\t\treturn ClippingAttachment;\n\t}(spine.VertexAttachment));\n\tspine.ClippingAttachment = ClippingAttachment;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar MeshAttachment = (function (_super) {\n\t\t__extends(MeshAttachment, _super);\n\t\tfunction MeshAttachment(name) {\n\t\t\tvar _this = _super.call(this, name) || this;\n\t\t\t_this.color = new spine.Color(1, 1, 1, 1);\n\t\t\t_this.inheritDeform = false;\n\t\t\t_this.tempColor = new spine.Color(0, 0, 0, 0);\n\t\t\treturn _this;\n\t\t}\n\t\tMeshAttachment.prototype.updateUVs = function () {\n\t\t\tvar u = 0, v = 0, width = 0, height = 0;\n\t\t\tif (this.region == null) {\n\t\t\t\tu = v = 0;\n\t\t\t\twidth = height = 1;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tu = this.region.u;\n\t\t\t\tv = this.region.v;\n\t\t\t\twidth = this.region.u2 - u;\n\t\t\t\theight = this.region.v2 - v;\n\t\t\t}\n\t\t\tvar regionUVs = this.regionUVs;\n\t\t\tif (this.uvs == null || this.uvs.length != regionUVs.length)\n\t\t\t\tthis.uvs = spine.Utils.newFloatArray(regionUVs.length);\n\t\t\tvar uvs = this.uvs;\n\t\t\tif (this.region.rotate) {\n\t\t\t\tfor (var i = 0, n = uvs.length; i < n; i += 2) {\n\t\t\t\t\tuvs[i] = u + regionUVs[i + 1] * width;\n\t\t\t\t\tuvs[i + 1] = v + height - regionUVs[i] * height;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tfor (var i = 0, n = uvs.length; i < n; i += 2) {\n\t\t\t\t\tuvs[i] = u + regionUVs[i] * width;\n\t\t\t\t\tuvs[i + 1] = v + regionUVs[i + 1] * height;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tMeshAttachment.prototype.applyDeform = function (sourceAttachment) {\n\t\t\treturn this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment);\n\t\t};\n\t\tMeshAttachment.prototype.getParentMesh = function () {\n\t\t\treturn this.parentMesh;\n\t\t};\n\t\tMeshAttachment.prototype.setParentMesh = function (parentMesh) {\n\t\t\tthis.parentMesh = parentMesh;\n\t\t\tif (parentMesh != null) {\n\t\t\t\tthis.bones = parentMesh.bones;\n\t\t\t\tthis.vertices = parentMesh.vertices;\n\t\t\t\tthis.worldVerticesLength = parentMesh.worldVerticesLength;\n\t\t\t\tthis.regionUVs = parentMesh.regionUVs;\n\t\t\t\tthis.triangles = parentMesh.triangles;\n\t\t\t\tthis.hullLength = parentMesh.hullLength;\n\t\t\t\tthis.worldVerticesLength = parentMesh.worldVerticesLength;\n\t\t\t}\n\t\t};\n\t\treturn MeshAttachment;\n\t}(spine.VertexAttachment));\n\tspine.MeshAttachment = MeshAttachment;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar PathAttachment = (function (_super) {\n\t\t__extends(PathAttachment, _super);\n\t\tfunction PathAttachment(name) {\n\t\t\tvar _this = _super.call(this, name) || this;\n\t\t\t_this.closed = false;\n\t\t\t_this.constantSpeed = false;\n\t\t\t_this.color = new spine.Color(1, 1, 1, 1);\n\t\t\treturn _this;\n\t\t}\n\t\treturn PathAttachment;\n\t}(spine.VertexAttachment));\n\tspine.PathAttachment = PathAttachment;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar PointAttachment = (function (_super) {\n\t\t__extends(PointAttachment, _super);\n\t\tfunction PointAttachment(name) {\n\t\t\tvar _this = _super.call(this, name) || this;\n\t\t\t_this.color = new spine.Color(0.38, 0.94, 0, 1);\n\t\t\treturn _this;\n\t\t}\n\t\tPointAttachment.prototype.computeWorldPosition = function (bone, point) {\n\t\t\tpoint.x = this.x * bone.a + this.y * bone.b + bone.worldX;\n\t\t\tpoint.y = this.x * bone.c + this.y * bone.d + bone.worldY;\n\t\t\treturn point;\n\t\t};\n\t\tPointAttachment.prototype.computeWorldRotation = function (bone) {\n\t\t\tvar cos = spine.MathUtils.cosDeg(this.rotation), sin = spine.MathUtils.sinDeg(this.rotation);\n\t\t\tvar x = cos * bone.a + sin * bone.b;\n\t\t\tvar y = cos * bone.c + sin * bone.d;\n\t\t\treturn Math.atan2(y, x) * spine.MathUtils.radDeg;\n\t\t};\n\t\treturn PointAttachment;\n\t}(spine.VertexAttachment));\n\tspine.PointAttachment = PointAttachment;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar RegionAttachment = (function (_super) {\n\t\t__extends(RegionAttachment, _super);\n\t\tfunction RegionAttachment(name) {\n\t\t\tvar _this = _super.call(this, name) || this;\n\t\t\t_this.x = 0;\n\t\t\t_this.y = 0;\n\t\t\t_this.scaleX = 1;\n\t\t\t_this.scaleY = 1;\n\t\t\t_this.rotation = 0;\n\t\t\t_this.width = 0;\n\t\t\t_this.height = 0;\n\t\t\t_this.color = new spine.Color(1, 1, 1, 1);\n\t\t\t_this.offset = spine.Utils.newFloatArray(8);\n\t\t\t_this.uvs = spine.Utils.newFloatArray(8);\n\t\t\t_this.tempColor = new spine.Color(1, 1, 1, 1);\n\t\t\treturn _this;\n\t\t}\n\t\tRegionAttachment.prototype.updateOffset = function () {\n\t\t\tvar regionScaleX = this.width / this.region.originalWidth * this.scaleX;\n\t\t\tvar regionScaleY = this.height / this.region.originalHeight * this.scaleY;\n\t\t\tvar localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX;\n\t\t\tvar localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY;\n\t\t\tvar localX2 = localX + this.region.width * regionScaleX;\n\t\t\tvar localY2 = localY + this.region.height * regionScaleY;\n\t\t\tvar radians = this.rotation * Math.PI / 180;\n\t\t\tvar cos = Math.cos(radians);\n\t\t\tvar sin = Math.sin(radians);\n\t\t\tvar localXCos = localX * cos + this.x;\n\t\t\tvar localXSin = localX * sin;\n\t\t\tvar localYCos = localY * cos + this.y;\n\t\t\tvar localYSin = localY * sin;\n\t\t\tvar localX2Cos = localX2 * cos + this.x;\n\t\t\tvar localX2Sin = localX2 * sin;\n\t\t\tvar localY2Cos = localY2 * cos + this.y;\n\t\t\tvar localY2Sin = localY2 * sin;\n\t\t\tvar offset = this.offset;\n\t\t\toffset[RegionAttachment.OX1] = localXCos - localYSin;\n\t\t\toffset[RegionAttachment.OY1] = localYCos + localXSin;\n\t\t\toffset[RegionAttachment.OX2] = localXCos - localY2Sin;\n\t\t\toffset[RegionAttachment.OY2] = localY2Cos + localXSin;\n\t\t\toffset[RegionAttachment.OX3] = localX2Cos - localY2Sin;\n\t\t\toffset[RegionAttachment.OY3] = localY2Cos + localX2Sin;\n\t\t\toffset[RegionAttachment.OX4] = localX2Cos - localYSin;\n\t\t\toffset[RegionAttachment.OY4] = localYCos + localX2Sin;\n\t\t};\n\t\tRegionAttachment.prototype.setRegion = function (region) {\n\t\t\tthis.region = region;\n\t\t\tvar uvs = this.uvs;\n\t\t\tif (region.rotate) {\n\t\t\t\tuvs[2] = region.u;\n\t\t\t\tuvs[3] = region.v2;\n\t\t\t\tuvs[4] = region.u;\n\t\t\t\tuvs[5] = region.v;\n\t\t\t\tuvs[6] = region.u2;\n\t\t\t\tuvs[7] = region.v;\n\t\t\t\tuvs[0] = region.u2;\n\t\t\t\tuvs[1] = region.v2;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tuvs[0] = region.u;\n\t\t\t\tuvs[1] = region.v2;\n\t\t\t\tuvs[2] = region.u;\n\t\t\t\tuvs[3] = region.v;\n\t\t\t\tuvs[4] = region.u2;\n\t\t\t\tuvs[5] = region.v;\n\t\t\t\tuvs[6] = region.u2;\n\t\t\t\tuvs[7] = region.v2;\n\t\t\t}\n\t\t};\n\t\tRegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) {\n\t\t\tvar vertexOffset = this.offset;\n\t\t\tvar x = bone.worldX, y = bone.worldY;\n\t\t\tvar a = bone.a, b = bone.b, c = bone.c, d = bone.d;\n\t\t\tvar offsetX = 0, offsetY = 0;\n\t\t\toffsetX = vertexOffset[RegionAttachment.OX1];\n\t\t\toffsetY = vertexOffset[RegionAttachment.OY1];\n\t\t\tworldVertices[offset] = offsetX * a + offsetY * b + x;\n\t\t\tworldVertices[offset + 1] = offsetX * c + offsetY * d + y;\n\t\t\toffset += stride;\n\t\t\toffsetX = vertexOffset[RegionAttachment.OX2];\n\t\t\toffsetY = vertexOffset[RegionAttachment.OY2];\n\t\t\tworldVertices[offset] = offsetX * a + offsetY * b + x;\n\t\t\tworldVertices[offset + 1] = offsetX * c + offsetY * d + y;\n\t\t\toffset += stride;\n\t\t\toffsetX = vertexOffset[RegionAttachment.OX3];\n\t\t\toffsetY = vertexOffset[RegionAttachment.OY3];\n\t\t\tworldVertices[offset] = offsetX * a + offsetY * b + x;\n\t\t\tworldVertices[offset + 1] = offsetX * c + offsetY * d + y;\n\t\t\toffset += stride;\n\t\t\toffsetX = vertexOffset[RegionAttachment.OX4];\n\t\t\toffsetY = vertexOffset[RegionAttachment.OY4];\n\t\t\tworldVertices[offset] = offsetX * a + offsetY * b + x;\n\t\t\tworldVertices[offset + 1] = offsetX * c + offsetY * d + y;\n\t\t};\n\t\tRegionAttachment.OX1 = 0;\n\t\tRegionAttachment.OY1 = 1;\n\t\tRegionAttachment.OX2 = 2;\n\t\tRegionAttachment.OY2 = 3;\n\t\tRegionAttachment.OX3 = 4;\n\t\tRegionAttachment.OY3 = 5;\n\t\tRegionAttachment.OX4 = 6;\n\t\tRegionAttachment.OY4 = 7;\n\t\tRegionAttachment.X1 = 0;\n\t\tRegionAttachment.Y1 = 1;\n\t\tRegionAttachment.C1R = 2;\n\t\tRegionAttachment.C1G = 3;\n\t\tRegionAttachment.C1B = 4;\n\t\tRegionAttachment.C1A = 5;\n\t\tRegionAttachment.U1 = 6;\n\t\tRegionAttachment.V1 = 7;\n\t\tRegionAttachment.X2 = 8;\n\t\tRegionAttachment.Y2 = 9;\n\t\tRegionAttachment.C2R = 10;\n\t\tRegionAttachment.C2G = 11;\n\t\tRegionAttachment.C2B = 12;\n\t\tRegionAttachment.C2A = 13;\n\t\tRegionAttachment.U2 = 14;\n\t\tRegionAttachment.V2 = 15;\n\t\tRegionAttachment.X3 = 16;\n\t\tRegionAttachment.Y3 = 17;\n\t\tRegionAttachment.C3R = 18;\n\t\tRegionAttachment.C3G = 19;\n\t\tRegionAttachment.C3B = 20;\n\t\tRegionAttachment.C3A = 21;\n\t\tRegionAttachment.U3 = 22;\n\t\tRegionAttachment.V3 = 23;\n\t\tRegionAttachment.X4 = 24;\n\t\tRegionAttachment.Y4 = 25;\n\t\tRegionAttachment.C4R = 26;\n\t\tRegionAttachment.C4G = 27;\n\t\tRegionAttachment.C4B = 28;\n\t\tRegionAttachment.C4A = 29;\n\t\tRegionAttachment.U4 = 30;\n\t\tRegionAttachment.V4 = 31;\n\t\treturn RegionAttachment;\n\t}(spine.Attachment));\n\tspine.RegionAttachment = RegionAttachment;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar JitterEffect = (function () {\n\t\tfunction JitterEffect(jitterX, jitterY) {\n\t\t\tthis.jitterX = 0;\n\t\t\tthis.jitterY = 0;\n\t\t\tthis.jitterX = jitterX;\n\t\t\tthis.jitterY = jitterY;\n\t\t}\n\t\tJitterEffect.prototype.begin = function (skeleton) {\n\t\t};\n\t\tJitterEffect.prototype.transform = function (position, uv, light, dark) {\n\t\t\tposition.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);\n\t\t\tposition.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY);\n\t\t};\n\t\tJitterEffect.prototype.end = function () {\n\t\t};\n\t\treturn JitterEffect;\n\t}());\n\tspine.JitterEffect = JitterEffect;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar SwirlEffect = (function () {\n\t\tfunction SwirlEffect(radius) {\n\t\t\tthis.centerX = 0;\n\t\t\tthis.centerY = 0;\n\t\t\tthis.radius = 0;\n\t\t\tthis.angle = 0;\n\t\t\tthis.worldX = 0;\n\t\t\tthis.worldY = 0;\n\t\t\tthis.radius = radius;\n\t\t}\n\t\tSwirlEffect.prototype.begin = function (skeleton) {\n\t\t\tthis.worldX = skeleton.x + this.centerX;\n\t\t\tthis.worldY = skeleton.y + this.centerY;\n\t\t};\n\t\tSwirlEffect.prototype.transform = function (position, uv, light, dark) {\n\t\t\tvar radAngle = this.angle * spine.MathUtils.degreesToRadians;\n\t\t\tvar x = position.x - this.worldX;\n\t\t\tvar y = position.y - this.worldY;\n\t\t\tvar dist = Math.sqrt(x * x + y * y);\n\t\t\tif (dist < this.radius) {\n\t\t\t\tvar theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius);\n\t\t\t\tvar cos = Math.cos(theta);\n\t\t\t\tvar sin = Math.sin(theta);\n\t\t\t\tposition.x = cos * x - sin * y + this.worldX;\n\t\t\t\tposition.y = sin * x + cos * y + this.worldY;\n\t\t\t}\n\t\t};\n\t\tSwirlEffect.prototype.end = function () {\n\t\t};\n\t\tSwirlEffect.interpolation = new spine.PowOut(2);\n\t\treturn SwirlEffect;\n\t}());\n\tspine.SwirlEffect = SwirlEffect;\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar AssetManager = (function (_super) {\n\t\t\t__extends(AssetManager, _super);\n\t\t\tfunction AssetManager(context, pathPrefix) {\n\t\t\t\tif (pathPrefix === void 0) { pathPrefix = \"\"; }\n\t\t\t\treturn _super.call(this, function (image) {\n\t\t\t\t\treturn new spine.webgl.GLTexture(context, image);\n\t\t\t\t}, pathPrefix) || this;\n\t\t\t}\n\t\t\treturn AssetManager;\n\t\t}(spine.AssetManager));\n\t\twebgl.AssetManager = AssetManager;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar OrthoCamera = (function () {\n\t\t\tfunction OrthoCamera(viewportWidth, viewportHeight) {\n\t\t\t\tthis.position = new webgl.Vector3(0, 0, 0);\n\t\t\t\tthis.direction = new webgl.Vector3(0, 0, -1);\n\t\t\t\tthis.up = new webgl.Vector3(0, 1, 0);\n\t\t\t\tthis.near = 0;\n\t\t\t\tthis.far = 100;\n\t\t\t\tthis.zoom = 1;\n\t\t\t\tthis.viewportWidth = 0;\n\t\t\t\tthis.viewportHeight = 0;\n\t\t\t\tthis.projectionView = new webgl.Matrix4();\n\t\t\t\tthis.inverseProjectionView = new webgl.Matrix4();\n\t\t\t\tthis.projection = new webgl.Matrix4();\n\t\t\t\tthis.view = new webgl.Matrix4();\n\t\t\t\tthis.tmp = new webgl.Vector3();\n\t\t\t\tthis.viewportWidth = viewportWidth;\n\t\t\t\tthis.viewportHeight = viewportHeight;\n\t\t\t\tthis.update();\n\t\t\t}\n\t\t\tOrthoCamera.prototype.update = function () {\n\t\t\t\tvar projection = this.projection;\n\t\t\t\tvar view = this.view;\n\t\t\t\tvar projectionView = this.projectionView;\n\t\t\t\tvar inverseProjectionView = this.inverseProjectionView;\n\t\t\t\tvar zoom = this.zoom, viewportWidth = this.viewportWidth, viewportHeight = this.viewportHeight;\n\t\t\t\tprojection.ortho(zoom * (-viewportWidth / 2), zoom * (viewportWidth / 2), zoom * (-viewportHeight / 2), zoom * (viewportHeight / 2), this.near, this.far);\n\t\t\t\tview.lookAt(this.position, this.direction, this.up);\n\t\t\t\tprojectionView.set(projection.values);\n\t\t\t\tprojectionView.multiply(view);\n\t\t\t\tinverseProjectionView.set(projectionView.values).invert();\n\t\t\t};\n\t\t\tOrthoCamera.prototype.screenToWorld = function (screenCoords, screenWidth, screenHeight) {\n\t\t\t\tvar x = screenCoords.x, y = screenHeight - screenCoords.y - 1;\n\t\t\t\tvar tmp = this.tmp;\n\t\t\t\ttmp.x = (2 * x) / screenWidth - 1;\n\t\t\t\ttmp.y = (2 * y) / screenHeight - 1;\n\t\t\t\ttmp.z = (2 * screenCoords.z) - 1;\n\t\t\t\ttmp.project(this.inverseProjectionView);\n\t\t\t\tscreenCoords.set(tmp.x, tmp.y, tmp.z);\n\t\t\t\treturn screenCoords;\n\t\t\t};\n\t\t\tOrthoCamera.prototype.setViewport = function (viewportWidth, viewportHeight) {\n\t\t\t\tthis.viewportWidth = viewportWidth;\n\t\t\t\tthis.viewportHeight = viewportHeight;\n\t\t\t};\n\t\t\treturn OrthoCamera;\n\t\t}());\n\t\twebgl.OrthoCamera = OrthoCamera;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar GLTexture = (function (_super) {\n\t\t\t__extends(GLTexture, _super);\n\t\t\tfunction GLTexture(context, image, useMipMaps) {\n\t\t\t\tif (useMipMaps === void 0) { useMipMaps = false; }\n\t\t\t\tvar _this = _super.call(this, image) || this;\n\t\t\t\t_this.texture = null;\n\t\t\t\t_this.boundUnit = 0;\n\t\t\t\t_this.useMipMaps = false;\n\t\t\t\t_this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);\n\t\t\t\t_this.useMipMaps = useMipMaps;\n\t\t\t\t_this.restore();\n\t\t\t\t_this.context.addRestorable(_this);\n\t\t\t\treturn _this;\n\t\t\t}\n\t\t\tGLTexture.prototype.setFilters = function (minFilter, magFilter) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tthis.bind();\n\t\t\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter);\n\t\t\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter);\n\t\t\t};\n\t\t\tGLTexture.prototype.setWraps = function (uWrap, vWrap) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tthis.bind();\n\t\t\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap);\n\t\t\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap);\n\t\t\t};\n\t\t\tGLTexture.prototype.update = function (useMipMaps) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tif (!this.texture) {\n\t\t\t\t\tthis.texture = this.context.gl.createTexture();\n\t\t\t\t}\n\t\t\t\tthis.bind();\n\t\t\t\tgl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image);\n\t\t\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n\t\t\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);\n\t\t\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\n\t\t\t\tgl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n\t\t\t\tif (useMipMaps)\n\t\t\t\t\tgl.generateMipmap(gl.TEXTURE_2D);\n\t\t\t};\n\t\t\tGLTexture.prototype.restore = function () {\n\t\t\t\tthis.texture = null;\n\t\t\t\tthis.update(this.useMipMaps);\n\t\t\t};\n\t\t\tGLTexture.prototype.bind = function (unit) {\n\t\t\t\tif (unit === void 0) { unit = 0; }\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tthis.boundUnit = unit;\n\t\t\t\tgl.activeTexture(gl.TEXTURE0 + unit);\n\t\t\t\tgl.bindTexture(gl.TEXTURE_2D, this.texture);\n\t\t\t};\n\t\t\tGLTexture.prototype.unbind = function () {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tgl.activeTexture(gl.TEXTURE0 + this.boundUnit);\n\t\t\t\tgl.bindTexture(gl.TEXTURE_2D, null);\n\t\t\t};\n\t\t\tGLTexture.prototype.dispose = function () {\n\t\t\t\tthis.context.removeRestorable(this);\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tgl.deleteTexture(this.texture);\n\t\t\t};\n\t\t\treturn GLTexture;\n\t\t}(spine.Texture));\n\t\twebgl.GLTexture = GLTexture;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar Input = (function () {\n\t\t\tfunction Input(element) {\n\t\t\t\tthis.lastX = 0;\n\t\t\t\tthis.lastY = 0;\n\t\t\t\tthis.buttonDown = false;\n\t\t\t\tthis.currTouch = null;\n\t\t\t\tthis.touchesPool = new spine.Pool(function () {\n\t\t\t\t\treturn new spine.webgl.Touch(0, 0, 0);\n\t\t\t\t});\n\t\t\t\tthis.listeners = new Array();\n\t\t\t\tthis.element = element;\n\t\t\t\tthis.setupCallbacks(element);\n\t\t\t}\n\t\t\tInput.prototype.setupCallbacks = function (element) {\n\t\t\t\tvar _this = this;\n\t\t\t\telement.addEventListener(\"mousedown\", function (ev) {\n\t\t\t\t\tif (ev instanceof MouseEvent) {\n\t\t\t\t\t\tvar rect = element.getBoundingClientRect();\n\t\t\t\t\t\tvar x = ev.clientX - rect.left;\n\t\t\t\t\t\tvar y = ev.clientY - rect.top;\n\t\t\t\t\t\tvar listeners = _this.listeners;\n\t\t\t\t\t\tfor (var i = 0; i < listeners.length; i++) {\n\t\t\t\t\t\t\tlisteners[i].down(x, y);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t_this.lastX = x;\n\t\t\t\t\t\t_this.lastY = y;\n\t\t\t\t\t\t_this.buttonDown = true;\n\t\t\t\t\t}\n\t\t\t\t}, true);\n\t\t\t\telement.addEventListener(\"mousemove\", function (ev) {\n\t\t\t\t\tif (ev instanceof MouseEvent) {\n\t\t\t\t\t\tvar rect = element.getBoundingClientRect();\n\t\t\t\t\t\tvar x = ev.clientX - rect.left;\n\t\t\t\t\t\tvar y = ev.clientY - rect.top;\n\t\t\t\t\t\tvar listeners = _this.listeners;\n\t\t\t\t\t\tfor (var i = 0; i < listeners.length; i++) {\n\t\t\t\t\t\t\tif (_this.buttonDown) {\n\t\t\t\t\t\t\t\tlisteners[i].dragged(x, y);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tlisteners[i].moved(x, y);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t_this.lastX = x;\n\t\t\t\t\t\t_this.lastY = y;\n\t\t\t\t\t}\n\t\t\t\t}, true);\n\t\t\t\telement.addEventListener(\"mouseup\", function (ev) {\n\t\t\t\t\tif (ev instanceof MouseEvent) {\n\t\t\t\t\t\tvar rect = element.getBoundingClientRect();\n\t\t\t\t\t\tvar x = ev.clientX - rect.left;\n\t\t\t\t\t\tvar y = ev.clientY - rect.top;\n\t\t\t\t\t\tvar listeners = _this.listeners;\n\t\t\t\t\t\tfor (var i = 0; i < listeners.length; i++) {\n\t\t\t\t\t\t\tlisteners[i].up(x, y);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t_this.lastX = x;\n\t\t\t\t\t\t_this.lastY = y;\n\t\t\t\t\t\t_this.buttonDown = false;\n\t\t\t\t\t}\n\t\t\t\t}, true);\n\t\t\t\telement.addEventListener(\"touchstart\", function (ev) {\n\t\t\t\t\tif (_this.currTouch != null)\n\t\t\t\t\t\treturn;\n\t\t\t\t\tvar touches = ev.changedTouches;\n\t\t\t\t\tfor (var i = 0; i < touches.length; i++) {\n\t\t\t\t\t\tvar touch = touches[i];\n\t\t\t\t\t\tvar rect = element.getBoundingClientRect();\n\t\t\t\t\t\tvar x = touch.clientX - rect.left;\n\t\t\t\t\t\tvar y = touch.clientY - rect.top;\n\t\t\t\t\t\t_this.currTouch = _this.touchesPool.obtain();\n\t\t\t\t\t\t_this.currTouch.identifier = touch.identifier;\n\t\t\t\t\t\t_this.currTouch.x = x;\n\t\t\t\t\t\t_this.currTouch.y = y;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tvar listeners = _this.listeners;\n\t\t\t\t\tfor (var i_8 = 0; i_8 < listeners.length; i_8++) {\n\t\t\t\t\t\tlisteners[i_8].down(_this.currTouch.x, _this.currTouch.y);\n\t\t\t\t\t}\n\t\t\t\t\tconsole.log(\"Start \" + _this.currTouch.x + \", \" + _this.currTouch.y);\n\t\t\t\t\t_this.lastX = _this.currTouch.x;\n\t\t\t\t\t_this.lastY = _this.currTouch.y;\n\t\t\t\t\t_this.buttonDown = true;\n\t\t\t\t\tev.preventDefault();\n\t\t\t\t}, false);\n\t\t\t\telement.addEventListener(\"touchend\", function (ev) {\n\t\t\t\t\tvar touches = ev.changedTouches;\n\t\t\t\t\tfor (var i = 0; i < touches.length; i++) {\n\t\t\t\t\t\tvar touch = touches[i];\n\t\t\t\t\t\tif (_this.currTouch.identifier === touch.identifier) {\n\t\t\t\t\t\t\tvar rect = element.getBoundingClientRect();\n\t\t\t\t\t\t\tvar x = _this.currTouch.x = touch.clientX - rect.left;\n\t\t\t\t\t\t\tvar y = _this.currTouch.y = touch.clientY - rect.top;\n\t\t\t\t\t\t\t_this.touchesPool.free(_this.currTouch);\n\t\t\t\t\t\t\tvar listeners = _this.listeners;\n\t\t\t\t\t\t\tfor (var i_9 = 0; i_9 < listeners.length; i_9++) {\n\t\t\t\t\t\t\t\tlisteners[i_9].up(x, y);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconsole.log(\"End \" + x + \", \" + y);\n\t\t\t\t\t\t\t_this.lastX = x;\n\t\t\t\t\t\t\t_this.lastY = y;\n\t\t\t\t\t\t\t_this.buttonDown = false;\n\t\t\t\t\t\t\t_this.currTouch = null;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tev.preventDefault();\n\t\t\t\t}, false);\n\t\t\t\telement.addEventListener(\"touchcancel\", function (ev) {\n\t\t\t\t\tvar touches = ev.changedTouches;\n\t\t\t\t\tfor (var i = 0; i < touches.length; i++) {\n\t\t\t\t\t\tvar touch = touches[i];\n\t\t\t\t\t\tif (_this.currTouch.identifier === touch.identifier) {\n\t\t\t\t\t\t\tvar rect = element.getBoundingClientRect();\n\t\t\t\t\t\t\tvar x = _this.currTouch.x = touch.clientX - rect.left;\n\t\t\t\t\t\t\tvar y = _this.currTouch.y = touch.clientY - rect.top;\n\t\t\t\t\t\t\t_this.touchesPool.free(_this.currTouch);\n\t\t\t\t\t\t\tvar listeners = _this.listeners;\n\t\t\t\t\t\t\tfor (var i_10 = 0; i_10 < listeners.length; i_10++) {\n\t\t\t\t\t\t\t\tlisteners[i_10].up(x, y);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconsole.log(\"End \" + x + \", \" + y);\n\t\t\t\t\t\t\t_this.lastX = x;\n\t\t\t\t\t\t\t_this.lastY = y;\n\t\t\t\t\t\t\t_this.buttonDown = false;\n\t\t\t\t\t\t\t_this.currTouch = null;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tev.preventDefault();\n\t\t\t\t}, false);\n\t\t\t\telement.addEventListener(\"touchmove\", function (ev) {\n\t\t\t\t\tif (_this.currTouch == null)\n\t\t\t\t\t\treturn;\n\t\t\t\t\tvar touches = ev.changedTouches;\n\t\t\t\t\tfor (var i = 0; i < touches.length; i++) {\n\t\t\t\t\t\tvar touch = touches[i];\n\t\t\t\t\t\tif (_this.currTouch.identifier === touch.identifier) {\n\t\t\t\t\t\t\tvar rect = element.getBoundingClientRect();\n\t\t\t\t\t\t\tvar x = touch.clientX - rect.left;\n\t\t\t\t\t\t\tvar y = touch.clientY - rect.top;\n\t\t\t\t\t\t\tvar listeners = _this.listeners;\n\t\t\t\t\t\t\tfor (var i_11 = 0; i_11 < listeners.length; i_11++) {\n\t\t\t\t\t\t\t\tlisteners[i_11].dragged(x, y);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconsole.log(\"Drag \" + x + \", \" + y);\n\t\t\t\t\t\t\t_this.lastX = _this.currTouch.x = x;\n\t\t\t\t\t\t\t_this.lastY = _this.currTouch.y = y;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tev.preventDefault();\n\t\t\t\t}, false);\n\t\t\t};\n\t\t\tInput.prototype.addListener = function (listener) {\n\t\t\t\tthis.listeners.push(listener);\n\t\t\t};\n\t\t\tInput.prototype.removeListener = function (listener) {\n\t\t\t\tvar idx = this.listeners.indexOf(listener);\n\t\t\t\tif (idx > -1) {\n\t\t\t\t\tthis.listeners.splice(idx, 1);\n\t\t\t\t}\n\t\t\t};\n\t\t\treturn Input;\n\t\t}());\n\t\twebgl.Input = Input;\n\t\tvar Touch = (function () {\n\t\t\tfunction Touch(identifier, x, y) {\n\t\t\t\tthis.identifier = identifier;\n\t\t\t\tthis.x = x;\n\t\t\t\tthis.y = y;\n\t\t\t}\n\t\t\treturn Touch;\n\t\t}());\n\t\twebgl.Touch = Touch;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar LoadingScreen = (function () {\n\t\t\tfunction LoadingScreen(renderer) {\n\t\t\t\tthis.logo = null;\n\t\t\t\tthis.spinner = null;\n\t\t\t\tthis.angle = 0;\n\t\t\t\tthis.fadeOut = 0;\n\t\t\t\tthis.timeKeeper = new spine.TimeKeeper();\n\t\t\t\tthis.backgroundColor = new spine.Color(0.135, 0.135, 0.135, 1);\n\t\t\t\tthis.tempColor = new spine.Color();\n\t\t\t\tthis.firstDraw = 0;\n\t\t\t\tthis.renderer = renderer;\n\t\t\t\tthis.timeKeeper.maxDelta = 9;\n\t\t\t\tif (LoadingScreen.logoImg === null) {\n\t\t\t\t\tvar isSafari = navigator.userAgent.indexOf(\"Safari\") > -1;\n\t\t\t\t\tLoadingScreen.logoImg = new Image();\n\t\t\t\t\tLoadingScreen.logoImg.src = LoadingScreen.SPINE_LOGO_DATA;\n\t\t\t\t\tif (!isSafari)\n\t\t\t\t\t\tLoadingScreen.logoImg.crossOrigin = \"anonymous\";\n\t\t\t\t\tLoadingScreen.logoImg.onload = function (ev) {\n\t\t\t\t\t\tLoadingScreen.loaded++;\n\t\t\t\t\t};\n\t\t\t\t\tLoadingScreen.spinnerImg = new Image();\n\t\t\t\t\tLoadingScreen.spinnerImg.src = LoadingScreen.SPINNER_DATA;\n\t\t\t\t\tif (!isSafari)\n\t\t\t\t\t\tLoadingScreen.spinnerImg.crossOrigin = \"anonymous\";\n\t\t\t\t\tLoadingScreen.spinnerImg.onload = function (ev) {\n\t\t\t\t\t\tLoadingScreen.loaded++;\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tLoadingScreen.prototype.draw = function (complete) {\n\t\t\t\tif (complete === void 0) { complete = false; }\n\t\t\t\tif (complete && this.fadeOut > LoadingScreen.FADE_SECONDS)\n\t\t\t\t\treturn;\n\t\t\t\tthis.timeKeeper.update();\n\t\t\t\tvar a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75));\n\t\t\t\tthis.angle -= this.timeKeeper.delta * 360 * (1 + 1.5 * Math.pow(a, 5));\n\t\t\t\tvar renderer = this.renderer;\n\t\t\t\tvar canvas = renderer.canvas;\n\t\t\t\tvar gl = renderer.context.gl;\n\t\t\t\tvar oldX = renderer.camera.position.x, oldY = renderer.camera.position.y;\n\t\t\t\trenderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0);\n\t\t\t\trenderer.camera.viewportWidth = canvas.width;\n\t\t\t\trenderer.camera.viewportHeight = canvas.height;\n\t\t\t\trenderer.resize(webgl.ResizeMode.Stretch);\n\t\t\t\tif (!complete) {\n\t\t\t\t\tgl.clearColor(this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a);\n\t\t\t\t\tgl.clear(gl.COLOR_BUFFER_BIT);\n\t\t\t\t\tthis.tempColor.a = 1;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1);\n\t\t\t\t\tif (this.fadeOut > LoadingScreen.FADE_SECONDS) {\n\t\t\t\t\t\trenderer.camera.position.set(oldX, oldY, 0);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\ta = 1 - this.fadeOut / LoadingScreen.FADE_SECONDS;\n\t\t\t\t\tthis.tempColor.setFromColor(this.backgroundColor);\n\t\t\t\t\tthis.tempColor.a = 1 - (a - 1) * (a - 1);\n\t\t\t\t\trenderer.begin();\n\t\t\t\t\trenderer.quad(true, 0, 0, canvas.width, 0, canvas.width, canvas.height, 0, canvas.height, this.tempColor, this.tempColor, this.tempColor, this.tempColor);\n\t\t\t\t\trenderer.end();\n\t\t\t\t}\n\t\t\t\tthis.tempColor.set(1, 1, 1, this.tempColor.a);\n\t\t\t\tif (LoadingScreen.loaded != 2)\n\t\t\t\t\treturn;\n\t\t\t\tif (this.logo === null) {\n\t\t\t\t\tthis.logo = new webgl.GLTexture(renderer.context, LoadingScreen.logoImg);\n\t\t\t\t\tthis.spinner = new webgl.GLTexture(renderer.context, LoadingScreen.spinnerImg);\n\t\t\t\t}\n\t\t\t\tthis.logo.update(false);\n\t\t\t\tthis.spinner.update(false);\n\t\t\t\tvar logoWidth = this.logo.getImage().width;\n\t\t\t\tvar logoHeight = this.logo.getImage().height;\n\t\t\t\tvar spinnerWidth = this.spinner.getImage().width;\n\t\t\t\tvar spinnerHeight = this.spinner.getImage().height;\n\t\t\t\trenderer.batcher.setBlendMode(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);\n\t\t\t\trenderer.begin();\n\t\t\t\trenderer.drawTexture(this.logo, (canvas.width - logoWidth) / 2, (canvas.height - logoHeight) / 2, logoWidth, logoHeight, this.tempColor);\n\t\t\t\trenderer.drawTextureRotated(this.spinner, (canvas.width - spinnerWidth) / 2, (canvas.height - spinnerHeight) / 2, spinnerWidth, spinnerHeight, spinnerWidth / 2, spinnerHeight / 2, this.angle, this.tempColor);\n\t\t\t\trenderer.end();\n\t\t\t\trenderer.camera.position.set(oldX, oldY, 0);\n\t\t\t};\n\t\t\tLoadingScreen.FADE_SECONDS = 1;\n\t\t\tLoadingScreen.loaded = 0;\n\t\t\tLoadingScreen.spinnerImg = null;\n\t\t\tLoadingScreen.logoImg = null;\n\t\t\tLoadingScreen.SPINNER_DATA = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAChCAMAAAB3TUS6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAYNQTFRFAAAA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AAkTDRyAAAAIB0Uk5TAAABAgMEBQYHCAkKCwwODxAREhMUFRYXGBkaHB0eICEiIyQlJicoKSorLC0uLzAxMjM0Nzg5Ojs8PT4/QEFDRUlKS0xNTk9QUlRWWFlbXF1eYWJjZmhscHF0d3h5e3x+f4CIiYuMj5GSlJWXm56io6arr7rAxcjO0dXe6Onr8fmb5sOOAAADuElEQVQYGe3B+3vTVBwH4M/3nCRt13br2Lozhug2q25gYQubcxqVKYoMCYoKjEsUdSpeiBc0Kl7yp9t2za39pely7PF5zvuiQKc+/e2f8K+f9g2oyQ77Ag4VGX+HketQ0XYYe0JQ0CdhogwF+WFiBgr6JkxUoKCDMMGgoP0w9gdUtB3GfoCKVsPYAVQ0H8YuQUWVMHYGKuJhrAklPQkjJpT0bdj3O9S0FfZ9ADXxP8MjVSiqFfa8B2VVV8+df14QtB4iwn+BpuZEgyM38WMQHDYhnbkgukrIh5ygZ48glyn6KshlL+jbhVRcxCzk0ApiC5CI5kVsgTAy9jiI/WxBGmqIFBMjqwYphwRZaiLNwsjqQdoVSFISGRwjM4OMFUjBRcYCYWT0XZD2SwUS0LzIKCGH2SDja0LxKiJjCrm0gowVFI6aIs1CTouPg5QvUTgSKXMMuVUeBSmEopFITBPGwO8HCYbCTYtImTAWejuI3CMUjmZFT5NjbM/9GvQcMkhADdFRIxxD7aug4wGDFGSVTcLx0MzutQ2CpmmapmmapmmapmmapmmaphWBmGFV6rNNcaLC0GUuv3LROftUo8wJk0a10207sVED6IIf+9673LIwQeW2PaCEJX/A+xYmhTbtQUu46g96SJgQZg9Zwxf+EAMTwuwhm3jkD7EwIdweBn+YhQlh9pA2HvpDTEwIs4es4GN/CMekNOxBJ9D2B10nTAyfW7fT1hjYgZ/xYIUwUcycaiwuv2h3tOcZADr7ud/12c0ru2cWSwQ1UAcixIgImqZpmqZpmqZpmqZpmqZp2v8HMSIcF186t8oghbnlOJt1wnHwl7yOGxwSlHacrjWG8dVuej03OApn7jhHtiyMiZa9yD6haLYTebWOsbDXvQRHwchJWSTkV/rQS+EoWttJaTHkJe56KXcJRZt20jY48nnBy9hE4WjLSbvAkIfwMm5zFG/KyWgRRke3vYwGZDjpZHCMruJltCAFrTtpVYxu1ktzCHKwbSdlGqOreynXGGQpOylljI5uebFbBuSZc2IbhBxmvcj9GiSiZ52+HQO5nPb6TkIqajs9L5eQk7jnddxZgGT0jNOxYSI36+Kdj9oG5OPV6QpB6yJuGAYnqIrecLveYlDUKffIOtREl90+BiWV3cgMlNR0I09DSS030oaSttzILpT0phu5BBWRmyAoiLkJgoIMN8GgoJKb4FBQzU0YUFDdTRhQUNVNcCjIdBMEBdE7buQ8lFRz+97lUFN5fe+qu//aMkeB/gU2ae9y2HgbngAAAABJRU5ErkJggg==\";\n\t\t\tLoadingScreen.SPINE_LOGO_DATA = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFIAAAAZCAYAAACis3k0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtNJREFUaN7tmT2I1EAUxwN+oWgRT0HFKo0WCkJ6ObmAWFwZbCxsXGysLNJaiCyIoDaSwk4ETzvhmnBaCRbBWoQ01ho4PwotjP8cE337mMy8TLK757mBH3fLTWbe/PbN53neNniqZW8FvAVvQAqugwvgDDgO9niLRyTyJagM/ACPF6bsIl9ZRDac/Cc6tLn5xQdRQ496QlKPLxD5QCDxO9jtGM8QfYoIgUlgCipGCRJL5VvlyOdCU09iEXkCfLSIfCrs7Fab6nOsiafu06iDwES9w/uU1QnDC+ekkVS9vEaDsgVeB0d+z1VDtOGxRaYPboP3Gokb4GgXkZp4chZPJKgvZ3U0XkriK/TIt9YUDllFgTAjGwoaoHqfBhMI58yD4BQ4V6/aHYdfxToftvw9F2SiVroawU2/Cv5C4Thv0KB9S5nxlOd4STxjwUjzSdYlgrYijw2BsEfgsaFcM09lhiys94xXQQwugcvgJrgFLjrEE7WUiTuWCQzt/ZXN7FfqGwuGClyVy2xZAFmfDQvNtwFFSspMDGsD+UTWqu1KoVmVooFEJgKRXw0if85RpISEzwsjzeqWzkjkC4PIJ3MUmQgITAHlQwTFhnZhELkEntfZRwR+AvfAgXmJHOqU02XligWT8ppg67NXbdCXeq7afUQ6L8C2DalEZNt2YyQ94Qy8/ekjMpBMbfyl5iTjG7YAI8cNecROAb4kJmTjaXAF3AGvwQewOiuRxEtlSaT4j2h2lMsUueQEoMlIKpTvAmKhxPMtC876jEX6rE8l8TNx/KVbn6xlWU9NWcSDUsO4NGWpQOTZFpHPOooMXcswmW2XFk3ixb2v0Nq+XVKP00QNaffBLyWwBI/AkTlfMYZDXMf12kc6yjwEjoFdO/5me5oi/6tnyhlZX6OtgmX1c2Uh0k3khmbB2b9TRfpd/jfTUeRDJvHdYg5wE7kPXAN3wQ1weDvH+xufEgpi5qIl3QAAAABJRU5ErkJggg==\";\n\t\t\treturn LoadingScreen;\n\t\t}());\n\t\twebgl.LoadingScreen = LoadingScreen;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\twebgl.M00 = 0;\n\t\twebgl.M01 = 4;\n\t\twebgl.M02 = 8;\n\t\twebgl.M03 = 12;\n\t\twebgl.M10 = 1;\n\t\twebgl.M11 = 5;\n\t\twebgl.M12 = 9;\n\t\twebgl.M13 = 13;\n\t\twebgl.M20 = 2;\n\t\twebgl.M21 = 6;\n\t\twebgl.M22 = 10;\n\t\twebgl.M23 = 14;\n\t\twebgl.M30 = 3;\n\t\twebgl.M31 = 7;\n\t\twebgl.M32 = 11;\n\t\twebgl.M33 = 15;\n\t\tvar Matrix4 = (function () {\n\t\t\tfunction Matrix4() {\n\t\t\t\tthis.temp = new Float32Array(16);\n\t\t\t\tthis.values = new Float32Array(16);\n\t\t\t\tvar v = this.values;\n\t\t\t\tv[webgl.M00] = 1;\n\t\t\t\tv[webgl.M11] = 1;\n\t\t\t\tv[webgl.M22] = 1;\n\t\t\t\tv[webgl.M33] = 1;\n\t\t\t}\n\t\t\tMatrix4.prototype.set = function (values) {\n\t\t\t\tthis.values.set(values);\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tMatrix4.prototype.transpose = function () {\n\t\t\t\tvar t = this.temp;\n\t\t\t\tvar v = this.values;\n\t\t\t\tt[webgl.M00] = v[webgl.M00];\n\t\t\t\tt[webgl.M01] = v[webgl.M10];\n\t\t\t\tt[webgl.M02] = v[webgl.M20];\n\t\t\t\tt[webgl.M03] = v[webgl.M30];\n\t\t\t\tt[webgl.M10] = v[webgl.M01];\n\t\t\t\tt[webgl.M11] = v[webgl.M11];\n\t\t\t\tt[webgl.M12] = v[webgl.M21];\n\t\t\t\tt[webgl.M13] = v[webgl.M31];\n\t\t\t\tt[webgl.M20] = v[webgl.M02];\n\t\t\t\tt[webgl.M21] = v[webgl.M12];\n\t\t\t\tt[webgl.M22] = v[webgl.M22];\n\t\t\t\tt[webgl.M23] = v[webgl.M32];\n\t\t\t\tt[webgl.M30] = v[webgl.M03];\n\t\t\t\tt[webgl.M31] = v[webgl.M13];\n\t\t\t\tt[webgl.M32] = v[webgl.M23];\n\t\t\t\tt[webgl.M33] = v[webgl.M33];\n\t\t\t\treturn this.set(t);\n\t\t\t};\n\t\t\tMatrix4.prototype.identity = function () {\n\t\t\t\tvar v = this.values;\n\t\t\t\tv[webgl.M00] = 1;\n\t\t\t\tv[webgl.M01] = 0;\n\t\t\t\tv[webgl.M02] = 0;\n\t\t\t\tv[webgl.M03] = 0;\n\t\t\t\tv[webgl.M10] = 0;\n\t\t\t\tv[webgl.M11] = 1;\n\t\t\t\tv[webgl.M12] = 0;\n\t\t\t\tv[webgl.M13] = 0;\n\t\t\t\tv[webgl.M20] = 0;\n\t\t\t\tv[webgl.M21] = 0;\n\t\t\t\tv[webgl.M22] = 1;\n\t\t\t\tv[webgl.M23] = 0;\n\t\t\t\tv[webgl.M30] = 0;\n\t\t\t\tv[webgl.M31] = 0;\n\t\t\t\tv[webgl.M32] = 0;\n\t\t\t\tv[webgl.M33] = 1;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tMatrix4.prototype.invert = function () {\n\t\t\t\tvar v = this.values;\n\t\t\t\tvar t = this.temp;\n\t\t\t\tvar l_det = v[webgl.M30] * v[webgl.M21] * v[webgl.M12] * v[webgl.M03] - v[webgl.M20] * v[webgl.M31] * v[webgl.M12] * v[webgl.M03] - v[webgl.M30] * v[webgl.M11] * v[webgl.M22] * v[webgl.M03]\n\t\t\t\t\t+ v[webgl.M10] * v[webgl.M31] * v[webgl.M22] * v[webgl.M03] + v[webgl.M20] * v[webgl.M11] * v[webgl.M32] * v[webgl.M03] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32] * v[webgl.M03]\n\t\t\t\t\t- v[webgl.M30] * v[webgl.M21] * v[webgl.M02] * v[webgl.M13] + v[webgl.M20] * v[webgl.M31] * v[webgl.M02] * v[webgl.M13] + v[webgl.M30] * v[webgl.M01] * v[webgl.M22] * v[webgl.M13]\n\t\t\t\t\t- v[webgl.M00] * v[webgl.M31] * v[webgl.M22] * v[webgl.M13] - v[webgl.M20] * v[webgl.M01] * v[webgl.M32] * v[webgl.M13] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32] * v[webgl.M13]\n\t\t\t\t\t+ v[webgl.M30] * v[webgl.M11] * v[webgl.M02] * v[webgl.M23] - v[webgl.M10] * v[webgl.M31] * v[webgl.M02] * v[webgl.M23] - v[webgl.M30] * v[webgl.M01] * v[webgl.M12] * v[webgl.M23]\n\t\t\t\t\t+ v[webgl.M00] * v[webgl.M31] * v[webgl.M12] * v[webgl.M23] + v[webgl.M10] * v[webgl.M01] * v[webgl.M32] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32] * v[webgl.M23]\n\t\t\t\t\t- v[webgl.M20] * v[webgl.M11] * v[webgl.M02] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M02] * v[webgl.M33] + v[webgl.M20] * v[webgl.M01] * v[webgl.M12] * v[webgl.M33]\n\t\t\t\t\t- v[webgl.M00] * v[webgl.M21] * v[webgl.M12] * v[webgl.M33] - v[webgl.M10] * v[webgl.M01] * v[webgl.M22] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22] * v[webgl.M33];\n\t\t\t\tif (l_det == 0)\n\t\t\t\t\tthrow new Error(\"non-invertible matrix\");\n\t\t\t\tvar inv_det = 1.0 / l_det;\n\t\t\t\tt[webgl.M00] = v[webgl.M12] * v[webgl.M23] * v[webgl.M31] - v[webgl.M13] * v[webgl.M22] * v[webgl.M31] + v[webgl.M13] * v[webgl.M21] * v[webgl.M32]\n\t\t\t\t\t- v[webgl.M11] * v[webgl.M23] * v[webgl.M32] - v[webgl.M12] * v[webgl.M21] * v[webgl.M33] + v[webgl.M11] * v[webgl.M22] * v[webgl.M33];\n\t\t\t\tt[webgl.M01] = v[webgl.M03] * v[webgl.M22] * v[webgl.M31] - v[webgl.M02] * v[webgl.M23] * v[webgl.M31] - v[webgl.M03] * v[webgl.M21] * v[webgl.M32]\n\t\t\t\t\t+ v[webgl.M01] * v[webgl.M23] * v[webgl.M32] + v[webgl.M02] * v[webgl.M21] * v[webgl.M33] - v[webgl.M01] * v[webgl.M22] * v[webgl.M33];\n\t\t\t\tt[webgl.M02] = v[webgl.M02] * v[webgl.M13] * v[webgl.M31] - v[webgl.M03] * v[webgl.M12] * v[webgl.M31] + v[webgl.M03] * v[webgl.M11] * v[webgl.M32]\n\t\t\t\t\t- v[webgl.M01] * v[webgl.M13] * v[webgl.M32] - v[webgl.M02] * v[webgl.M11] * v[webgl.M33] + v[webgl.M01] * v[webgl.M12] * v[webgl.M33];\n\t\t\t\tt[webgl.M03] = v[webgl.M03] * v[webgl.M12] * v[webgl.M21] - v[webgl.M02] * v[webgl.M13] * v[webgl.M21] - v[webgl.M03] * v[webgl.M11] * v[webgl.M22]\n\t\t\t\t\t+ v[webgl.M01] * v[webgl.M13] * v[webgl.M22] + v[webgl.M02] * v[webgl.M11] * v[webgl.M23] - v[webgl.M01] * v[webgl.M12] * v[webgl.M23];\n\t\t\t\tt[webgl.M10] = v[webgl.M13] * v[webgl.M22] * v[webgl.M30] - v[webgl.M12] * v[webgl.M23] * v[webgl.M30] - v[webgl.M13] * v[webgl.M20] * v[webgl.M32]\n\t\t\t\t\t+ v[webgl.M10] * v[webgl.M23] * v[webgl.M32] + v[webgl.M12] * v[webgl.M20] * v[webgl.M33] - v[webgl.M10] * v[webgl.M22] * v[webgl.M33];\n\t\t\t\tt[webgl.M11] = v[webgl.M02] * v[webgl.M23] * v[webgl.M30] - v[webgl.M03] * v[webgl.M22] * v[webgl.M30] + v[webgl.M03] * v[webgl.M20] * v[webgl.M32]\n\t\t\t\t\t- v[webgl.M00] * v[webgl.M23] * v[webgl.M32] - v[webgl.M02] * v[webgl.M20] * v[webgl.M33] + v[webgl.M00] * v[webgl.M22] * v[webgl.M33];\n\t\t\t\tt[webgl.M12] = v[webgl.M03] * v[webgl.M12] * v[webgl.M30] - v[webgl.M02] * v[webgl.M13] * v[webgl.M30] - v[webgl.M03] * v[webgl.M10] * v[webgl.M32]\n\t\t\t\t\t+ v[webgl.M00] * v[webgl.M13] * v[webgl.M32] + v[webgl.M02] * v[webgl.M10] * v[webgl.M33] - v[webgl.M00] * v[webgl.M12] * v[webgl.M33];\n\t\t\t\tt[webgl.M13] = v[webgl.M02] * v[webgl.M13] * v[webgl.M20] - v[webgl.M03] * v[webgl.M12] * v[webgl.M20] + v[webgl.M03] * v[webgl.M10] * v[webgl.M22]\n\t\t\t\t\t- v[webgl.M00] * v[webgl.M13] * v[webgl.M22] - v[webgl.M02] * v[webgl.M10] * v[webgl.M23] + v[webgl.M00] * v[webgl.M12] * v[webgl.M23];\n\t\t\t\tt[webgl.M20] = v[webgl.M11] * v[webgl.M23] * v[webgl.M30] - v[webgl.M13] * v[webgl.M21] * v[webgl.M30] + v[webgl.M13] * v[webgl.M20] * v[webgl.M31]\n\t\t\t\t\t- v[webgl.M10] * v[webgl.M23] * v[webgl.M31] - v[webgl.M11] * v[webgl.M20] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M33];\n\t\t\t\tt[webgl.M21] = v[webgl.M03] * v[webgl.M21] * v[webgl.M30] - v[webgl.M01] * v[webgl.M23] * v[webgl.M30] - v[webgl.M03] * v[webgl.M20] * v[webgl.M31]\n\t\t\t\t\t+ v[webgl.M00] * v[webgl.M23] * v[webgl.M31] + v[webgl.M01] * v[webgl.M20] * v[webgl.M33] - v[webgl.M00] * v[webgl.M21] * v[webgl.M33];\n\t\t\t\tt[webgl.M22] = v[webgl.M01] * v[webgl.M13] * v[webgl.M30] - v[webgl.M03] * v[webgl.M11] * v[webgl.M30] + v[webgl.M03] * v[webgl.M10] * v[webgl.M31]\n\t\t\t\t\t- v[webgl.M00] * v[webgl.M13] * v[webgl.M31] - v[webgl.M01] * v[webgl.M10] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M33];\n\t\t\t\tt[webgl.M23] = v[webgl.M03] * v[webgl.M11] * v[webgl.M20] - v[webgl.M01] * v[webgl.M13] * v[webgl.M20] - v[webgl.M03] * v[webgl.M10] * v[webgl.M21]\n\t\t\t\t\t+ v[webgl.M00] * v[webgl.M13] * v[webgl.M21] + v[webgl.M01] * v[webgl.M10] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M23];\n\t\t\t\tt[webgl.M30] = v[webgl.M12] * v[webgl.M21] * v[webgl.M30] - v[webgl.M11] * v[webgl.M22] * v[webgl.M30] - v[webgl.M12] * v[webgl.M20] * v[webgl.M31]\n\t\t\t\t\t+ v[webgl.M10] * v[webgl.M22] * v[webgl.M31] + v[webgl.M11] * v[webgl.M20] * v[webgl.M32] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32];\n\t\t\t\tt[webgl.M31] = v[webgl.M01] * v[webgl.M22] * v[webgl.M30] - v[webgl.M02] * v[webgl.M21] * v[webgl.M30] + v[webgl.M02] * v[webgl.M20] * v[webgl.M31]\n\t\t\t\t\t- v[webgl.M00] * v[webgl.M22] * v[webgl.M31] - v[webgl.M01] * v[webgl.M20] * v[webgl.M32] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32];\n\t\t\t\tt[webgl.M32] = v[webgl.M02] * v[webgl.M11] * v[webgl.M30] - v[webgl.M01] * v[webgl.M12] * v[webgl.M30] - v[webgl.M02] * v[webgl.M10] * v[webgl.M31]\n\t\t\t\t\t+ v[webgl.M00] * v[webgl.M12] * v[webgl.M31] + v[webgl.M01] * v[webgl.M10] * v[webgl.M32] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32];\n\t\t\t\tt[webgl.M33] = v[webgl.M01] * v[webgl.M12] * v[webgl.M20] - v[webgl.M02] * v[webgl.M11] * v[webgl.M20] + v[webgl.M02] * v[webgl.M10] * v[webgl.M21]\n\t\t\t\t\t- v[webgl.M00] * v[webgl.M12] * v[webgl.M21] - v[webgl.M01] * v[webgl.M10] * v[webgl.M22] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22];\n\t\t\t\tv[webgl.M00] = t[webgl.M00] * inv_det;\n\t\t\t\tv[webgl.M01] = t[webgl.M01] * inv_det;\n\t\t\t\tv[webgl.M02] = t[webgl.M02] * inv_det;\n\t\t\t\tv[webgl.M03] = t[webgl.M03] * inv_det;\n\t\t\t\tv[webgl.M10] = t[webgl.M10] * inv_det;\n\t\t\t\tv[webgl.M11] = t[webgl.M11] * inv_det;\n\t\t\t\tv[webgl.M12] = t[webgl.M12] * inv_det;\n\t\t\t\tv[webgl.M13] = t[webgl.M13] * inv_det;\n\t\t\t\tv[webgl.M20] = t[webgl.M20] * inv_det;\n\t\t\t\tv[webgl.M21] = t[webgl.M21] * inv_det;\n\t\t\t\tv[webgl.M22] = t[webgl.M22] * inv_det;\n\t\t\t\tv[webgl.M23] = t[webgl.M23] * inv_det;\n\t\t\t\tv[webgl.M30] = t[webgl.M30] * inv_det;\n\t\t\t\tv[webgl.M31] = t[webgl.M31] * inv_det;\n\t\t\t\tv[webgl.M32] = t[webgl.M32] * inv_det;\n\t\t\t\tv[webgl.M33] = t[webgl.M33] * inv_det;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tMatrix4.prototype.determinant = function () {\n\t\t\t\tvar v = this.values;\n\t\t\t\treturn v[webgl.M30] * v[webgl.M21] * v[webgl.M12] * v[webgl.M03] - v[webgl.M20] * v[webgl.M31] * v[webgl.M12] * v[webgl.M03] - v[webgl.M30] * v[webgl.M11] * v[webgl.M22] * v[webgl.M03]\n\t\t\t\t\t+ v[webgl.M10] * v[webgl.M31] * v[webgl.M22] * v[webgl.M03] + v[webgl.M20] * v[webgl.M11] * v[webgl.M32] * v[webgl.M03] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32] * v[webgl.M03]\n\t\t\t\t\t- v[webgl.M30] * v[webgl.M21] * v[webgl.M02] * v[webgl.M13] + v[webgl.M20] * v[webgl.M31] * v[webgl.M02] * v[webgl.M13] + v[webgl.M30] * v[webgl.M01] * v[webgl.M22] * v[webgl.M13]\n\t\t\t\t\t- v[webgl.M00] * v[webgl.M31] * v[webgl.M22] * v[webgl.M13] - v[webgl.M20] * v[webgl.M01] * v[webgl.M32] * v[webgl.M13] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32] * v[webgl.M13]\n\t\t\t\t\t+ v[webgl.M30] * v[webgl.M11] * v[webgl.M02] * v[webgl.M23] - v[webgl.M10] * v[webgl.M31] * v[webgl.M02] * v[webgl.M23] - v[webgl.M30] * v[webgl.M01] * v[webgl.M12] * v[webgl.M23]\n\t\t\t\t\t+ v[webgl.M00] * v[webgl.M31] * v[webgl.M12] * v[webgl.M23] + v[webgl.M10] * v[webgl.M01] * v[webgl.M32] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32] * v[webgl.M23]\n\t\t\t\t\t- v[webgl.M20] * v[webgl.M11] * v[webgl.M02] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M02] * v[webgl.M33] + v[webgl.M20] * v[webgl.M01] * v[webgl.M12] * v[webgl.M33]\n\t\t\t\t\t- v[webgl.M00] * v[webgl.M21] * v[webgl.M12] * v[webgl.M33] - v[webgl.M10] * v[webgl.M01] * v[webgl.M22] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22] * v[webgl.M33];\n\t\t\t};\n\t\t\tMatrix4.prototype.translate = function (x, y, z) {\n\t\t\t\tvar v = this.values;\n\t\t\t\tv[webgl.M03] += x;\n\t\t\t\tv[webgl.M13] += y;\n\t\t\t\tv[webgl.M23] += z;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tMatrix4.prototype.copy = function () {\n\t\t\t\treturn new Matrix4().set(this.values);\n\t\t\t};\n\t\t\tMatrix4.prototype.projection = function (near, far, fovy, aspectRatio) {\n\t\t\t\tthis.identity();\n\t\t\t\tvar l_fd = (1.0 / Math.tan((fovy * (Math.PI / 180)) / 2.0));\n\t\t\t\tvar l_a1 = (far + near) / (near - far);\n\t\t\t\tvar l_a2 = (2 * far * near) / (near - far);\n\t\t\t\tvar v = this.values;\n\t\t\t\tv[webgl.M00] = l_fd / aspectRatio;\n\t\t\t\tv[webgl.M10] = 0;\n\t\t\t\tv[webgl.M20] = 0;\n\t\t\t\tv[webgl.M30] = 0;\n\t\t\t\tv[webgl.M01] = 0;\n\t\t\t\tv[webgl.M11] = l_fd;\n\t\t\t\tv[webgl.M21] = 0;\n\t\t\t\tv[webgl.M31] = 0;\n\t\t\t\tv[webgl.M02] = 0;\n\t\t\t\tv[webgl.M12] = 0;\n\t\t\t\tv[webgl.M22] = l_a1;\n\t\t\t\tv[webgl.M32] = -1;\n\t\t\t\tv[webgl.M03] = 0;\n\t\t\t\tv[webgl.M13] = 0;\n\t\t\t\tv[webgl.M23] = l_a2;\n\t\t\t\tv[webgl.M33] = 0;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tMatrix4.prototype.ortho2d = function (x, y, width, height) {\n\t\t\t\treturn this.ortho(x, x + width, y, y + height, 0, 1);\n\t\t\t};\n\t\t\tMatrix4.prototype.ortho = function (left, right, bottom, top, near, far) {\n\t\t\t\tthis.identity();\n\t\t\t\tvar x_orth = 2 / (right - left);\n\t\t\t\tvar y_orth = 2 / (top - bottom);\n\t\t\t\tvar z_orth = -2 / (far - near);\n\t\t\t\tvar tx = -(right + left) / (right - left);\n\t\t\t\tvar ty = -(top + bottom) / (top - bottom);\n\t\t\t\tvar tz = -(far + near) / (far - near);\n\t\t\t\tvar v = this.values;\n\t\t\t\tv[webgl.M00] = x_orth;\n\t\t\t\tv[webgl.M10] = 0;\n\t\t\t\tv[webgl.M20] = 0;\n\t\t\t\tv[webgl.M30] = 0;\n\t\t\t\tv[webgl.M01] = 0;\n\t\t\t\tv[webgl.M11] = y_orth;\n\t\t\t\tv[webgl.M21] = 0;\n\t\t\t\tv[webgl.M31] = 0;\n\t\t\t\tv[webgl.M02] = 0;\n\t\t\t\tv[webgl.M12] = 0;\n\t\t\t\tv[webgl.M22] = z_orth;\n\t\t\t\tv[webgl.M32] = 0;\n\t\t\t\tv[webgl.M03] = tx;\n\t\t\t\tv[webgl.M13] = ty;\n\t\t\t\tv[webgl.M23] = tz;\n\t\t\t\tv[webgl.M33] = 1;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tMatrix4.prototype.multiply = function (matrix) {\n\t\t\t\tvar t = this.temp;\n\t\t\t\tvar v = this.values;\n\t\t\t\tvar m = matrix.values;\n\t\t\t\tt[webgl.M00] = v[webgl.M00] * m[webgl.M00] + v[webgl.M01] * m[webgl.M10] + v[webgl.M02] * m[webgl.M20] + v[webgl.M03] * m[webgl.M30];\n\t\t\t\tt[webgl.M01] = v[webgl.M00] * m[webgl.M01] + v[webgl.M01] * m[webgl.M11] + v[webgl.M02] * m[webgl.M21] + v[webgl.M03] * m[webgl.M31];\n\t\t\t\tt[webgl.M02] = v[webgl.M00] * m[webgl.M02] + v[webgl.M01] * m[webgl.M12] + v[webgl.M02] * m[webgl.M22] + v[webgl.M03] * m[webgl.M32];\n\t\t\t\tt[webgl.M03] = v[webgl.M00] * m[webgl.M03] + v[webgl.M01] * m[webgl.M13] + v[webgl.M02] * m[webgl.M23] + v[webgl.M03] * m[webgl.M33];\n\t\t\t\tt[webgl.M10] = v[webgl.M10] * m[webgl.M00] + v[webgl.M11] * m[webgl.M10] + v[webgl.M12] * m[webgl.M20] + v[webgl.M13] * m[webgl.M30];\n\t\t\t\tt[webgl.M11] = v[webgl.M10] * m[webgl.M01] + v[webgl.M11] * m[webgl.M11] + v[webgl.M12] * m[webgl.M21] + v[webgl.M13] * m[webgl.M31];\n\t\t\t\tt[webgl.M12] = v[webgl.M10] * m[webgl.M02] + v[webgl.M11] * m[webgl.M12] + v[webgl.M12] * m[webgl.M22] + v[webgl.M13] * m[webgl.M32];\n\t\t\t\tt[webgl.M13] = v[webgl.M10] * m[webgl.M03] + v[webgl.M11] * m[webgl.M13] + v[webgl.M12] * m[webgl.M23] + v[webgl.M13] * m[webgl.M33];\n\t\t\t\tt[webgl.M20] = v[webgl.M20] * m[webgl.M00] + v[webgl.M21] * m[webgl.M10] + v[webgl.M22] * m[webgl.M20] + v[webgl.M23] * m[webgl.M30];\n\t\t\t\tt[webgl.M21] = v[webgl.M20] * m[webgl.M01] + v[webgl.M21] * m[webgl.M11] + v[webgl.M22] * m[webgl.M21] + v[webgl.M23] * m[webgl.M31];\n\t\t\t\tt[webgl.M22] = v[webgl.M20] * m[webgl.M02] + v[webgl.M21] * m[webgl.M12] + v[webgl.M22] * m[webgl.M22] + v[webgl.M23] * m[webgl.M32];\n\t\t\t\tt[webgl.M23] = v[webgl.M20] * m[webgl.M03] + v[webgl.M21] * m[webgl.M13] + v[webgl.M22] * m[webgl.M23] + v[webgl.M23] * m[webgl.M33];\n\t\t\t\tt[webgl.M30] = v[webgl.M30] * m[webgl.M00] + v[webgl.M31] * m[webgl.M10] + v[webgl.M32] * m[webgl.M20] + v[webgl.M33] * m[webgl.M30];\n\t\t\t\tt[webgl.M31] = v[webgl.M30] * m[webgl.M01] + v[webgl.M31] * m[webgl.M11] + v[webgl.M32] * m[webgl.M21] + v[webgl.M33] * m[webgl.M31];\n\t\t\t\tt[webgl.M32] = v[webgl.M30] * m[webgl.M02] + v[webgl.M31] * m[webgl.M12] + v[webgl.M32] * m[webgl.M22] + v[webgl.M33] * m[webgl.M32];\n\t\t\t\tt[webgl.M33] = v[webgl.M30] * m[webgl.M03] + v[webgl.M31] * m[webgl.M13] + v[webgl.M32] * m[webgl.M23] + v[webgl.M33] * m[webgl.M33];\n\t\t\t\treturn this.set(this.temp);\n\t\t\t};\n\t\t\tMatrix4.prototype.multiplyLeft = function (matrix) {\n\t\t\t\tvar t = this.temp;\n\t\t\t\tvar v = this.values;\n\t\t\t\tvar m = matrix.values;\n\t\t\t\tt[webgl.M00] = m[webgl.M00] * v[webgl.M00] + m[webgl.M01] * v[webgl.M10] + m[webgl.M02] * v[webgl.M20] + m[webgl.M03] * v[webgl.M30];\n\t\t\t\tt[webgl.M01] = m[webgl.M00] * v[webgl.M01] + m[webgl.M01] * v[webgl.M11] + m[webgl.M02] * v[webgl.M21] + m[webgl.M03] * v[webgl.M31];\n\t\t\t\tt[webgl.M02] = m[webgl.M00] * v[webgl.M02] + m[webgl.M01] * v[webgl.M12] + m[webgl.M02] * v[webgl.M22] + m[webgl.M03] * v[webgl.M32];\n\t\t\t\tt[webgl.M03] = m[webgl.M00] * v[webgl.M03] + m[webgl.M01] * v[webgl.M13] + m[webgl.M02] * v[webgl.M23] + m[webgl.M03] * v[webgl.M33];\n\t\t\t\tt[webgl.M10] = m[webgl.M10] * v[webgl.M00] + m[webgl.M11] * v[webgl.M10] + m[webgl.M12] * v[webgl.M20] + m[webgl.M13] * v[webgl.M30];\n\t\t\t\tt[webgl.M11] = m[webgl.M10] * v[webgl.M01] + m[webgl.M11] * v[webgl.M11] + m[webgl.M12] * v[webgl.M21] + m[webgl.M13] * v[webgl.M31];\n\t\t\t\tt[webgl.M12] = m[webgl.M10] * v[webgl.M02] + m[webgl.M11] * v[webgl.M12] + m[webgl.M12] * v[webgl.M22] + m[webgl.M13] * v[webgl.M32];\n\t\t\t\tt[webgl.M13] = m[webgl.M10] * v[webgl.M03] + m[webgl.M11] * v[webgl.M13] + m[webgl.M12] * v[webgl.M23] + m[webgl.M13] * v[webgl.M33];\n\t\t\t\tt[webgl.M20] = m[webgl.M20] * v[webgl.M00] + m[webgl.M21] * v[webgl.M10] + m[webgl.M22] * v[webgl.M20] + m[webgl.M23] * v[webgl.M30];\n\t\t\t\tt[webgl.M21] = m[webgl.M20] * v[webgl.M01] + m[webgl.M21] * v[webgl.M11] + m[webgl.M22] * v[webgl.M21] + m[webgl.M23] * v[webgl.M31];\n\t\t\t\tt[webgl.M22] = m[webgl.M20] * v[webgl.M02] + m[webgl.M21] * v[webgl.M12] + m[webgl.M22] * v[webgl.M22] + m[webgl.M23] * v[webgl.M32];\n\t\t\t\tt[webgl.M23] = m[webgl.M20] * v[webgl.M03] + m[webgl.M21] * v[webgl.M13] + m[webgl.M22] * v[webgl.M23] + m[webgl.M23] * v[webgl.M33];\n\t\t\t\tt[webgl.M30] = m[webgl.M30] * v[webgl.M00] + m[webgl.M31] * v[webgl.M10] + m[webgl.M32] * v[webgl.M20] + m[webgl.M33] * v[webgl.M30];\n\t\t\t\tt[webgl.M31] = m[webgl.M30] * v[webgl.M01] + m[webgl.M31] * v[webgl.M11] + m[webgl.M32] * v[webgl.M21] + m[webgl.M33] * v[webgl.M31];\n\t\t\t\tt[webgl.M32] = m[webgl.M30] * v[webgl.M02] + m[webgl.M31] * v[webgl.M12] + m[webgl.M32] * v[webgl.M22] + m[webgl.M33] * v[webgl.M32];\n\t\t\t\tt[webgl.M33] = m[webgl.M30] * v[webgl.M03] + m[webgl.M31] * v[webgl.M13] + m[webgl.M32] * v[webgl.M23] + m[webgl.M33] * v[webgl.M33];\n\t\t\t\treturn this.set(this.temp);\n\t\t\t};\n\t\t\tMatrix4.prototype.lookAt = function (position, direction, up) {\n\t\t\t\tMatrix4.initTemps();\n\t\t\t\tvar xAxis = Matrix4.xAxis, yAxis = Matrix4.yAxis, zAxis = Matrix4.zAxis;\n\t\t\t\tzAxis.setFrom(direction).normalize();\n\t\t\t\txAxis.setFrom(direction).normalize();\n\t\t\t\txAxis.cross(up).normalize();\n\t\t\t\tyAxis.setFrom(xAxis).cross(zAxis).normalize();\n\t\t\t\tthis.identity();\n\t\t\t\tvar val = this.values;\n\t\t\t\tval[webgl.M00] = xAxis.x;\n\t\t\t\tval[webgl.M01] = xAxis.y;\n\t\t\t\tval[webgl.M02] = xAxis.z;\n\t\t\t\tval[webgl.M10] = yAxis.x;\n\t\t\t\tval[webgl.M11] = yAxis.y;\n\t\t\t\tval[webgl.M12] = yAxis.z;\n\t\t\t\tval[webgl.M20] = -zAxis.x;\n\t\t\t\tval[webgl.M21] = -zAxis.y;\n\t\t\t\tval[webgl.M22] = -zAxis.z;\n\t\t\t\tMatrix4.tmpMatrix.identity();\n\t\t\t\tMatrix4.tmpMatrix.values[webgl.M03] = -position.x;\n\t\t\t\tMatrix4.tmpMatrix.values[webgl.M13] = -position.y;\n\t\t\t\tMatrix4.tmpMatrix.values[webgl.M23] = -position.z;\n\t\t\t\tthis.multiply(Matrix4.tmpMatrix);\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tMatrix4.initTemps = function () {\n\t\t\t\tif (Matrix4.xAxis === null)\n\t\t\t\t\tMatrix4.xAxis = new webgl.Vector3();\n\t\t\t\tif (Matrix4.yAxis === null)\n\t\t\t\t\tMatrix4.yAxis = new webgl.Vector3();\n\t\t\t\tif (Matrix4.zAxis === null)\n\t\t\t\t\tMatrix4.zAxis = new webgl.Vector3();\n\t\t\t};\n\t\t\tMatrix4.xAxis = null;\n\t\t\tMatrix4.yAxis = null;\n\t\t\tMatrix4.zAxis = null;\n\t\t\tMatrix4.tmpMatrix = new Matrix4();\n\t\t\treturn Matrix4;\n\t\t}());\n\t\twebgl.Matrix4 = Matrix4;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar Mesh = (function () {\n\t\t\tfunction Mesh(context, attributes, maxVertices, maxIndices) {\n\t\t\t\tthis.attributes = attributes;\n\t\t\t\tthis.verticesLength = 0;\n\t\t\t\tthis.dirtyVertices = false;\n\t\t\t\tthis.indicesLength = 0;\n\t\t\t\tthis.dirtyIndices = false;\n\t\t\t\tthis.elementsPerVertex = 0;\n\t\t\t\tthis.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);\n\t\t\t\tthis.elementsPerVertex = 0;\n\t\t\t\tfor (var i = 0; i < attributes.length; i++) {\n\t\t\t\t\tthis.elementsPerVertex += attributes[i].numElements;\n\t\t\t\t}\n\t\t\t\tthis.vertices = new Float32Array(maxVertices * this.elementsPerVertex);\n\t\t\t\tthis.indices = new Uint16Array(maxIndices);\n\t\t\t\tthis.context.addRestorable(this);\n\t\t\t}\n\t\t\tMesh.prototype.getAttributes = function () { return this.attributes; };\n\t\t\tMesh.prototype.maxVertices = function () { return this.vertices.length / this.elementsPerVertex; };\n\t\t\tMesh.prototype.numVertices = function () { return this.verticesLength / this.elementsPerVertex; };\n\t\t\tMesh.prototype.setVerticesLength = function (length) {\n\t\t\t\tthis.dirtyVertices = true;\n\t\t\t\tthis.verticesLength = length;\n\t\t\t};\n\t\t\tMesh.prototype.getVertices = function () { return this.vertices; };\n\t\t\tMesh.prototype.maxIndices = function () { return this.indices.length; };\n\t\t\tMesh.prototype.numIndices = function () { return this.indicesLength; };\n\t\t\tMesh.prototype.setIndicesLength = function (length) {\n\t\t\t\tthis.dirtyIndices = true;\n\t\t\t\tthis.indicesLength = length;\n\t\t\t};\n\t\t\tMesh.prototype.getIndices = function () { return this.indices; };\n\t\t\t;\n\t\t\tMesh.prototype.getVertexSizeInFloats = function () {\n\t\t\t\tvar size = 0;\n\t\t\t\tfor (var i = 0; i < this.attributes.length; i++) {\n\t\t\t\t\tvar attribute = this.attributes[i];\n\t\t\t\t\tsize += attribute.numElements;\n\t\t\t\t}\n\t\t\t\treturn size;\n\t\t\t};\n\t\t\tMesh.prototype.setVertices = function (vertices) {\n\t\t\t\tthis.dirtyVertices = true;\n\t\t\t\tif (vertices.length > this.vertices.length)\n\t\t\t\t\tthrow Error(\"Mesh can't store more than \" + this.maxVertices() + \" vertices\");\n\t\t\t\tthis.vertices.set(vertices, 0);\n\t\t\t\tthis.verticesLength = vertices.length;\n\t\t\t};\n\t\t\tMesh.prototype.setIndices = function (indices) {\n\t\t\t\tthis.dirtyIndices = true;\n\t\t\t\tif (indices.length > this.indices.length)\n\t\t\t\t\tthrow Error(\"Mesh can't store more than \" + this.maxIndices() + \" indices\");\n\t\t\t\tthis.indices.set(indices, 0);\n\t\t\t\tthis.indicesLength = indices.length;\n\t\t\t};\n\t\t\tMesh.prototype.draw = function (shader, primitiveType) {\n\t\t\t\tthis.drawWithOffset(shader, primitiveType, 0, this.indicesLength > 0 ? this.indicesLength : this.verticesLength / this.elementsPerVertex);\n\t\t\t};\n\t\t\tMesh.prototype.drawWithOffset = function (shader, primitiveType, offset, count) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tif (this.dirtyVertices || this.dirtyIndices)\n\t\t\t\t\tthis.update();\n\t\t\t\tthis.bind(shader);\n\t\t\t\tif (this.indicesLength > 0) {\n\t\t\t\t\tgl.drawElements(primitiveType, count, gl.UNSIGNED_SHORT, offset * 2);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tgl.drawArrays(primitiveType, offset, count);\n\t\t\t\t}\n\t\t\t\tthis.unbind(shader);\n\t\t\t};\n\t\t\tMesh.prototype.bind = function (shader) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);\n\t\t\t\tvar offset = 0;\n\t\t\t\tfor (var i = 0; i < this.attributes.length; i++) {\n\t\t\t\t\tvar attrib = this.attributes[i];\n\t\t\t\t\tvar location_1 = shader.getAttributeLocation(attrib.name);\n\t\t\t\t\tgl.enableVertexAttribArray(location_1);\n\t\t\t\t\tgl.vertexAttribPointer(location_1, attrib.numElements, gl.FLOAT, false, this.elementsPerVertex * 4, offset * 4);\n\t\t\t\t\toffset += attrib.numElements;\n\t\t\t\t}\n\t\t\t\tif (this.indicesLength > 0)\n\t\t\t\t\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);\n\t\t\t};\n\t\t\tMesh.prototype.unbind = function (shader) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tfor (var i = 0; i < this.attributes.length; i++) {\n\t\t\t\t\tvar attrib = this.attributes[i];\n\t\t\t\t\tvar location_2 = shader.getAttributeLocation(attrib.name);\n\t\t\t\t\tgl.disableVertexAttribArray(location_2);\n\t\t\t\t}\n\t\t\t\tgl.bindBuffer(gl.ARRAY_BUFFER, null);\n\t\t\t\tif (this.indicesLength > 0)\n\t\t\t\t\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);\n\t\t\t};\n\t\t\tMesh.prototype.update = function () {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tif (this.dirtyVertices) {\n\t\t\t\t\tif (!this.verticesBuffer) {\n\t\t\t\t\t\tthis.verticesBuffer = gl.createBuffer();\n\t\t\t\t\t}\n\t\t\t\t\tgl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer);\n\t\t\t\t\tgl.bufferData(gl.ARRAY_BUFFER, this.vertices.subarray(0, this.verticesLength), gl.DYNAMIC_DRAW);\n\t\t\t\t\tthis.dirtyVertices = false;\n\t\t\t\t}\n\t\t\t\tif (this.dirtyIndices) {\n\t\t\t\t\tif (!this.indicesBuffer) {\n\t\t\t\t\t\tthis.indicesBuffer = gl.createBuffer();\n\t\t\t\t\t}\n\t\t\t\t\tgl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);\n\t\t\t\t\tgl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices.subarray(0, this.indicesLength), gl.DYNAMIC_DRAW);\n\t\t\t\t\tthis.dirtyIndices = false;\n\t\t\t\t}\n\t\t\t};\n\t\t\tMesh.prototype.restore = function () {\n\t\t\t\tthis.verticesBuffer = null;\n\t\t\t\tthis.indicesBuffer = null;\n\t\t\t\tthis.update();\n\t\t\t};\n\t\t\tMesh.prototype.dispose = function () {\n\t\t\t\tthis.context.removeRestorable(this);\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tgl.deleteBuffer(this.verticesBuffer);\n\t\t\t\tgl.deleteBuffer(this.indicesBuffer);\n\t\t\t};\n\t\t\treturn Mesh;\n\t\t}());\n\t\twebgl.Mesh = Mesh;\n\t\tvar VertexAttribute = (function () {\n\t\t\tfunction VertexAttribute(name, type, numElements) {\n\t\t\t\tthis.name = name;\n\t\t\t\tthis.type = type;\n\t\t\t\tthis.numElements = numElements;\n\t\t\t}\n\t\t\treturn VertexAttribute;\n\t\t}());\n\t\twebgl.VertexAttribute = VertexAttribute;\n\t\tvar Position2Attribute = (function (_super) {\n\t\t\t__extends(Position2Attribute, _super);\n\t\t\tfunction Position2Attribute() {\n\t\t\t\treturn _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 2) || this;\n\t\t\t}\n\t\t\treturn Position2Attribute;\n\t\t}(VertexAttribute));\n\t\twebgl.Position2Attribute = Position2Attribute;\n\t\tvar Position3Attribute = (function (_super) {\n\t\t\t__extends(Position3Attribute, _super);\n\t\t\tfunction Position3Attribute() {\n\t\t\t\treturn _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 3) || this;\n\t\t\t}\n\t\t\treturn Position3Attribute;\n\t\t}(VertexAttribute));\n\t\twebgl.Position3Attribute = Position3Attribute;\n\t\tvar TexCoordAttribute = (function (_super) {\n\t\t\t__extends(TexCoordAttribute, _super);\n\t\t\tfunction TexCoordAttribute(unit) {\n\t\t\t\tif (unit === void 0) { unit = 0; }\n\t\t\t\treturn _super.call(this, webgl.Shader.TEXCOORDS + (unit == 0 ? \"\" : unit), VertexAttributeType.Float, 2) || this;\n\t\t\t}\n\t\t\treturn TexCoordAttribute;\n\t\t}(VertexAttribute));\n\t\twebgl.TexCoordAttribute = TexCoordAttribute;\n\t\tvar ColorAttribute = (function (_super) {\n\t\t\t__extends(ColorAttribute, _super);\n\t\t\tfunction ColorAttribute() {\n\t\t\t\treturn _super.call(this, webgl.Shader.COLOR, VertexAttributeType.Float, 4) || this;\n\t\t\t}\n\t\t\treturn ColorAttribute;\n\t\t}(VertexAttribute));\n\t\twebgl.ColorAttribute = ColorAttribute;\n\t\tvar Color2Attribute = (function (_super) {\n\t\t\t__extends(Color2Attribute, _super);\n\t\t\tfunction Color2Attribute() {\n\t\t\t\treturn _super.call(this, webgl.Shader.COLOR2, VertexAttributeType.Float, 4) || this;\n\t\t\t}\n\t\t\treturn Color2Attribute;\n\t\t}(VertexAttribute));\n\t\twebgl.Color2Attribute = Color2Attribute;\n\t\tvar VertexAttributeType;\n\t\t(function (VertexAttributeType) {\n\t\t\tVertexAttributeType[VertexAttributeType[\"Float\"] = 0] = \"Float\";\n\t\t})(VertexAttributeType = webgl.VertexAttributeType || (webgl.VertexAttributeType = {}));\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar PolygonBatcher = (function () {\n\t\t\tfunction PolygonBatcher(context, twoColorTint, maxVertices) {\n\t\t\t\tif (twoColorTint === void 0) { twoColorTint = true; }\n\t\t\t\tif (maxVertices === void 0) { maxVertices = 10920; }\n\t\t\t\tthis.isDrawing = false;\n\t\t\t\tthis.shader = null;\n\t\t\t\tthis.lastTexture = null;\n\t\t\t\tthis.verticesLength = 0;\n\t\t\t\tthis.indicesLength = 0;\n\t\t\t\tif (maxVertices > 10920)\n\t\t\t\t\tthrow new Error(\"Can't have more than 10920 triangles per batch: \" + maxVertices);\n\t\t\t\tthis.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);\n\t\t\t\tvar attributes = twoColorTint ?\n\t\t\t\t\t[new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute(), new webgl.Color2Attribute()] :\n\t\t\t\t\t[new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute()];\n\t\t\t\tthis.mesh = new webgl.Mesh(context, attributes, maxVertices, maxVertices * 3);\n\t\t\t\tthis.srcBlend = this.context.gl.SRC_ALPHA;\n\t\t\t\tthis.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;\n\t\t\t}\n\t\t\tPolygonBatcher.prototype.begin = function (shader) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tif (this.isDrawing)\n\t\t\t\t\tthrow new Error(\"PolygonBatch is already drawing. Call PolygonBatch.end() before calling PolygonBatch.begin()\");\n\t\t\t\tthis.drawCalls = 0;\n\t\t\t\tthis.shader = shader;\n\t\t\t\tthis.lastTexture = null;\n\t\t\t\tthis.isDrawing = true;\n\t\t\t\tgl.enable(gl.BLEND);\n\t\t\t\tgl.blendFunc(this.srcBlend, this.dstBlend);\n\t\t\t};\n\t\t\tPolygonBatcher.prototype.setBlendMode = function (srcBlend, dstBlend) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tthis.srcBlend = srcBlend;\n\t\t\t\tthis.dstBlend = dstBlend;\n\t\t\t\tif (this.isDrawing) {\n\t\t\t\t\tthis.flush();\n\t\t\t\t\tgl.blendFunc(this.srcBlend, this.dstBlend);\n\t\t\t\t}\n\t\t\t};\n\t\t\tPolygonBatcher.prototype.draw = function (texture, vertices, indices) {\n\t\t\t\tif (texture != this.lastTexture) {\n\t\t\t\t\tthis.flush();\n\t\t\t\t\tthis.lastTexture = texture;\n\t\t\t\t}\n\t\t\t\telse if (this.verticesLength + vertices.length > this.mesh.getVertices().length ||\n\t\t\t\t\tthis.indicesLength + indices.length > this.mesh.getIndices().length) {\n\t\t\t\t\tthis.flush();\n\t\t\t\t}\n\t\t\t\tvar indexStart = this.mesh.numVertices();\n\t\t\t\tthis.mesh.getVertices().set(vertices, this.verticesLength);\n\t\t\t\tthis.verticesLength += vertices.length;\n\t\t\t\tthis.mesh.setVerticesLength(this.verticesLength);\n\t\t\t\tvar indicesArray = this.mesh.getIndices();\n\t\t\t\tfor (var i = this.indicesLength, j = 0; j < indices.length; i++, j++)\n\t\t\t\t\tindicesArray[i] = indices[j] + indexStart;\n\t\t\t\tthis.indicesLength += indices.length;\n\t\t\t\tthis.mesh.setIndicesLength(this.indicesLength);\n\t\t\t};\n\t\t\tPolygonBatcher.prototype.flush = function () {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tif (this.verticesLength == 0)\n\t\t\t\t\treturn;\n\t\t\t\tthis.lastTexture.bind();\n\t\t\t\tthis.mesh.draw(this.shader, gl.TRIANGLES);\n\t\t\t\tthis.verticesLength = 0;\n\t\t\t\tthis.indicesLength = 0;\n\t\t\t\tthis.mesh.setVerticesLength(0);\n\t\t\t\tthis.mesh.setIndicesLength(0);\n\t\t\t\tthis.drawCalls++;\n\t\t\t};\n\t\t\tPolygonBatcher.prototype.end = function () {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tif (!this.isDrawing)\n\t\t\t\t\tthrow new Error(\"PolygonBatch is not drawing. Call PolygonBatch.begin() before calling PolygonBatch.end()\");\n\t\t\t\tif (this.verticesLength > 0 || this.indicesLength > 0)\n\t\t\t\t\tthis.flush();\n\t\t\t\tthis.shader = null;\n\t\t\t\tthis.lastTexture = null;\n\t\t\t\tthis.isDrawing = false;\n\t\t\t\tgl.disable(gl.BLEND);\n\t\t\t};\n\t\t\tPolygonBatcher.prototype.getDrawCalls = function () { return this.drawCalls; };\n\t\t\tPolygonBatcher.prototype.dispose = function () {\n\t\t\t\tthis.mesh.dispose();\n\t\t\t};\n\t\t\treturn PolygonBatcher;\n\t\t}());\n\t\twebgl.PolygonBatcher = PolygonBatcher;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar SceneRenderer = (function () {\n\t\t\tfunction SceneRenderer(canvas, context, twoColorTint) {\n\t\t\t\tif (twoColorTint === void 0) { twoColorTint = true; }\n\t\t\t\tthis.twoColorTint = false;\n\t\t\t\tthis.activeRenderer = null;\n\t\t\t\tthis.QUAD = [\n\t\t\t\t\t0, 0, 1, 1, 1, 1, 0, 0,\n\t\t\t\t\t0, 0, 1, 1, 1, 1, 0, 0,\n\t\t\t\t\t0, 0, 1, 1, 1, 1, 0, 0,\n\t\t\t\t\t0, 0, 1, 1, 1, 1, 0, 0,\n\t\t\t\t];\n\t\t\t\tthis.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];\n\t\t\t\tthis.WHITE = new spine.Color(1, 1, 1, 1);\n\t\t\t\tthis.canvas = canvas;\n\t\t\t\tthis.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);\n\t\t\t\tthis.twoColorTint = twoColorTint;\n\t\t\t\tthis.camera = new webgl.OrthoCamera(canvas.width, canvas.height);\n\t\t\t\tthis.batcherShader = twoColorTint ? webgl.Shader.newTwoColoredTextured(this.context) : webgl.Shader.newColoredTextured(this.context);\n\t\t\t\tthis.batcher = new webgl.PolygonBatcher(this.context, twoColorTint);\n\t\t\t\tthis.shapesShader = webgl.Shader.newColored(this.context);\n\t\t\t\tthis.shapes = new webgl.ShapeRenderer(this.context);\n\t\t\t\tthis.skeletonRenderer = new webgl.SkeletonRenderer(this.context, twoColorTint);\n\t\t\t\tthis.skeletonDebugRenderer = new webgl.SkeletonDebugRenderer(this.context);\n\t\t\t}\n\t\t\tSceneRenderer.prototype.begin = function () {\n\t\t\t\tthis.camera.update();\n\t\t\t\tthis.enableRenderer(this.batcher);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.drawSkeleton = function (skeleton, premultipliedAlpha, slotRangeStart, slotRangeEnd) {\n\t\t\t\tif (premultipliedAlpha === void 0) { premultipliedAlpha = false; }\n\t\t\t\tif (slotRangeStart === void 0) { slotRangeStart = -1; }\n\t\t\t\tif (slotRangeEnd === void 0) { slotRangeEnd = -1; }\n\t\t\t\tthis.enableRenderer(this.batcher);\n\t\t\t\tthis.skeletonRenderer.premultipliedAlpha = premultipliedAlpha;\n\t\t\t\tthis.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.drawSkeletonDebug = function (skeleton, premultipliedAlpha, ignoredBones) {\n\t\t\t\tif (premultipliedAlpha === void 0) { premultipliedAlpha = false; }\n\t\t\t\tif (ignoredBones === void 0) { ignoredBones = null; }\n\t\t\t\tthis.enableRenderer(this.shapes);\n\t\t\t\tthis.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha;\n\t\t\t\tthis.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.drawTexture = function (texture, x, y, width, height, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.enableRenderer(this.batcher);\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.WHITE;\n\t\t\t\tvar quad = this.QUAD;\n\t\t\t\tvar i = 0;\n\t\t\t\tquad[i++] = x;\n\t\t\t\tquad[i++] = y;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = 0;\n\t\t\t\tquad[i++] = 1;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x + width;\n\t\t\t\tquad[i++] = y;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = 1;\n\t\t\t\tquad[i++] = 1;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x + width;\n\t\t\t\tquad[i++] = y + height;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = 1;\n\t\t\t\tquad[i++] = 0;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x;\n\t\t\t\tquad[i++] = y + height;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = 0;\n\t\t\t\tquad[i++] = 0;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tthis.batcher.draw(texture, quad, this.QUAD_TRIANGLES);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.drawTextureUV = function (texture, x, y, width, height, u, v, u2, v2, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.enableRenderer(this.batcher);\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.WHITE;\n\t\t\t\tvar quad = this.QUAD;\n\t\t\t\tvar i = 0;\n\t\t\t\tquad[i++] = x;\n\t\t\t\tquad[i++] = y;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = u;\n\t\t\t\tquad[i++] = v;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x + width;\n\t\t\t\tquad[i++] = y;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = u2;\n\t\t\t\tquad[i++] = v;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x + width;\n\t\t\t\tquad[i++] = y + height;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = u2;\n\t\t\t\tquad[i++] = v2;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x;\n\t\t\t\tquad[i++] = y + height;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = u;\n\t\t\t\tquad[i++] = v2;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tthis.batcher.draw(texture, quad, this.QUAD_TRIANGLES);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.drawTextureRotated = function (texture, x, y, width, height, pivotX, pivotY, angle, color, premultipliedAlpha) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (premultipliedAlpha === void 0) { premultipliedAlpha = false; }\n\t\t\t\tthis.enableRenderer(this.batcher);\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.WHITE;\n\t\t\t\tvar quad = this.QUAD;\n\t\t\t\tvar worldOriginX = x + pivotX;\n\t\t\t\tvar worldOriginY = y + pivotY;\n\t\t\t\tvar fx = -pivotX;\n\t\t\t\tvar fy = -pivotY;\n\t\t\t\tvar fx2 = width - pivotX;\n\t\t\t\tvar fy2 = height - pivotY;\n\t\t\t\tvar p1x = fx;\n\t\t\t\tvar p1y = fy;\n\t\t\t\tvar p2x = fx;\n\t\t\t\tvar p2y = fy2;\n\t\t\t\tvar p3x = fx2;\n\t\t\t\tvar p3y = fy2;\n\t\t\t\tvar p4x = fx2;\n\t\t\t\tvar p4y = fy;\n\t\t\t\tvar x1 = 0;\n\t\t\t\tvar y1 = 0;\n\t\t\t\tvar x2 = 0;\n\t\t\t\tvar y2 = 0;\n\t\t\t\tvar x3 = 0;\n\t\t\t\tvar y3 = 0;\n\t\t\t\tvar x4 = 0;\n\t\t\t\tvar y4 = 0;\n\t\t\t\tif (angle != 0) {\n\t\t\t\t\tvar cos = spine.MathUtils.cosDeg(angle);\n\t\t\t\t\tvar sin = spine.MathUtils.sinDeg(angle);\n\t\t\t\t\tx1 = cos * p1x - sin * p1y;\n\t\t\t\t\ty1 = sin * p1x + cos * p1y;\n\t\t\t\t\tx4 = cos * p2x - sin * p2y;\n\t\t\t\t\ty4 = sin * p2x + cos * p2y;\n\t\t\t\t\tx3 = cos * p3x - sin * p3y;\n\t\t\t\t\ty3 = sin * p3x + cos * p3y;\n\t\t\t\t\tx2 = x3 + (x1 - x4);\n\t\t\t\t\ty2 = y3 + (y1 - y4);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tx1 = p1x;\n\t\t\t\t\ty1 = p1y;\n\t\t\t\t\tx4 = p2x;\n\t\t\t\t\ty4 = p2y;\n\t\t\t\t\tx3 = p3x;\n\t\t\t\t\ty3 = p3y;\n\t\t\t\t\tx2 = p4x;\n\t\t\t\t\ty2 = p4y;\n\t\t\t\t}\n\t\t\t\tx1 += worldOriginX;\n\t\t\t\ty1 += worldOriginY;\n\t\t\t\tx2 += worldOriginX;\n\t\t\t\ty2 += worldOriginY;\n\t\t\t\tx3 += worldOriginX;\n\t\t\t\ty3 += worldOriginY;\n\t\t\t\tx4 += worldOriginX;\n\t\t\t\ty4 += worldOriginY;\n\t\t\t\tvar i = 0;\n\t\t\t\tquad[i++] = x1;\n\t\t\t\tquad[i++] = y1;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = 0;\n\t\t\t\tquad[i++] = 1;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x2;\n\t\t\t\tquad[i++] = y2;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = 1;\n\t\t\t\tquad[i++] = 1;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x3;\n\t\t\t\tquad[i++] = y3;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = 1;\n\t\t\t\tquad[i++] = 0;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x4;\n\t\t\t\tquad[i++] = y4;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = 0;\n\t\t\t\tquad[i++] = 0;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tthis.batcher.draw(texture, quad, this.QUAD_TRIANGLES);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.drawRegion = function (region, x, y, width, height, color, premultipliedAlpha) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (premultipliedAlpha === void 0) { premultipliedAlpha = false; }\n\t\t\t\tthis.enableRenderer(this.batcher);\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.WHITE;\n\t\t\t\tvar quad = this.QUAD;\n\t\t\t\tvar i = 0;\n\t\t\t\tquad[i++] = x;\n\t\t\t\tquad[i++] = y;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = region.u;\n\t\t\t\tquad[i++] = region.v2;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x + width;\n\t\t\t\tquad[i++] = y;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = region.u2;\n\t\t\t\tquad[i++] = region.v2;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x + width;\n\t\t\t\tquad[i++] = y + height;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = region.u2;\n\t\t\t\tquad[i++] = region.v;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tquad[i++] = x;\n\t\t\t\tquad[i++] = y + height;\n\t\t\t\tquad[i++] = color.r;\n\t\t\t\tquad[i++] = color.g;\n\t\t\t\tquad[i++] = color.b;\n\t\t\t\tquad[i++] = color.a;\n\t\t\t\tquad[i++] = region.u;\n\t\t\t\tquad[i++] = region.v;\n\t\t\t\tif (this.twoColorTint) {\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t\tquad[i++] = 0;\n\t\t\t\t}\n\t\t\t\tthis.batcher.draw(region.texture, quad, this.QUAD_TRIANGLES);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.line = function (x, y, x2, y2, color, color2) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (color2 === void 0) { color2 = null; }\n\t\t\t\tthis.enableRenderer(this.shapes);\n\t\t\t\tthis.shapes.line(x, y, x2, y2, color);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (color2 === void 0) { color2 = null; }\n\t\t\t\tif (color3 === void 0) { color3 = null; }\n\t\t\t\tthis.enableRenderer(this.shapes);\n\t\t\t\tthis.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (color2 === void 0) { color2 = null; }\n\t\t\t\tif (color3 === void 0) { color3 = null; }\n\t\t\t\tif (color4 === void 0) { color4 = null; }\n\t\t\t\tthis.enableRenderer(this.shapes);\n\t\t\t\tthis.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.rect = function (filled, x, y, width, height, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.enableRenderer(this.shapes);\n\t\t\t\tthis.shapes.rect(filled, x, y, width, height, color);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.enableRenderer(this.shapes);\n\t\t\t\tthis.shapes.rectLine(filled, x1, y1, x2, y2, width, color);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.polygon = function (polygonVertices, offset, count, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.enableRenderer(this.shapes);\n\t\t\t\tthis.shapes.polygon(polygonVertices, offset, count, color);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.circle = function (filled, x, y, radius, color, segments) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (segments === void 0) { segments = 0; }\n\t\t\t\tthis.enableRenderer(this.shapes);\n\t\t\t\tthis.shapes.circle(filled, x, y, radius, color, segments);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.enableRenderer(this.shapes);\n\t\t\t\tthis.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color);\n\t\t\t};\n\t\t\tSceneRenderer.prototype.end = function () {\n\t\t\t\tif (this.activeRenderer === this.batcher)\n\t\t\t\t\tthis.batcher.end();\n\t\t\t\telse if (this.activeRenderer === this.shapes)\n\t\t\t\t\tthis.shapes.end();\n\t\t\t\tthis.activeRenderer = null;\n\t\t\t};\n\t\t\tSceneRenderer.prototype.resize = function (resizeMode) {\n\t\t\t\tvar canvas = this.canvas;\n\t\t\t\tvar w = canvas.clientWidth;\n\t\t\t\tvar h = canvas.clientHeight;\n\t\t\t\tif (canvas.width != w || canvas.height != h) {\n\t\t\t\t\tcanvas.width = w;\n\t\t\t\t\tcanvas.height = h;\n\t\t\t\t}\n\t\t\t\tthis.context.gl.viewport(0, 0, canvas.width, canvas.height);\n\t\t\t\tif (resizeMode === ResizeMode.Stretch) {\n\t\t\t\t}\n\t\t\t\telse if (resizeMode === ResizeMode.Expand) {\n\t\t\t\t\tthis.camera.setViewport(w, h);\n\t\t\t\t}\n\t\t\t\telse if (resizeMode === ResizeMode.Fit) {\n\t\t\t\t\tvar sourceWidth = canvas.width, sourceHeight = canvas.height;\n\t\t\t\t\tvar targetWidth = this.camera.viewportWidth, targetHeight = this.camera.viewportHeight;\n\t\t\t\t\tvar targetRatio = targetHeight / targetWidth;\n\t\t\t\t\tvar sourceRatio = sourceHeight / sourceWidth;\n\t\t\t\t\tvar scale = targetRatio < sourceRatio ? targetWidth / sourceWidth : targetHeight / sourceHeight;\n\t\t\t\t\tthis.camera.viewportWidth = sourceWidth * scale;\n\t\t\t\t\tthis.camera.viewportHeight = sourceHeight * scale;\n\t\t\t\t}\n\t\t\t\tthis.camera.update();\n\t\t\t};\n\t\t\tSceneRenderer.prototype.enableRenderer = function (renderer) {\n\t\t\t\tif (this.activeRenderer === renderer)\n\t\t\t\t\treturn;\n\t\t\t\tthis.end();\n\t\t\t\tif (renderer instanceof webgl.PolygonBatcher) {\n\t\t\t\t\tthis.batcherShader.bind();\n\t\t\t\t\tthis.batcherShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values);\n\t\t\t\t\tthis.batcherShader.setUniformi(\"u_texture\", 0);\n\t\t\t\t\tthis.batcher.begin(this.batcherShader);\n\t\t\t\t\tthis.activeRenderer = this.batcher;\n\t\t\t\t}\n\t\t\t\telse if (renderer instanceof webgl.ShapeRenderer) {\n\t\t\t\t\tthis.shapesShader.bind();\n\t\t\t\t\tthis.shapesShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values);\n\t\t\t\t\tthis.shapes.begin(this.shapesShader);\n\t\t\t\t\tthis.activeRenderer = this.shapes;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.activeRenderer = this.skeletonDebugRenderer;\n\t\t\t\t}\n\t\t\t};\n\t\t\tSceneRenderer.prototype.dispose = function () {\n\t\t\t\tthis.batcher.dispose();\n\t\t\t\tthis.batcherShader.dispose();\n\t\t\t\tthis.shapes.dispose();\n\t\t\t\tthis.shapesShader.dispose();\n\t\t\t\tthis.skeletonDebugRenderer.dispose();\n\t\t\t};\n\t\t\treturn SceneRenderer;\n\t\t}());\n\t\twebgl.SceneRenderer = SceneRenderer;\n\t\tvar ResizeMode;\n\t\t(function (ResizeMode) {\n\t\t\tResizeMode[ResizeMode[\"Stretch\"] = 0] = \"Stretch\";\n\t\t\tResizeMode[ResizeMode[\"Expand\"] = 1] = \"Expand\";\n\t\t\tResizeMode[ResizeMode[\"Fit\"] = 2] = \"Fit\";\n\t\t})(ResizeMode = webgl.ResizeMode || (webgl.ResizeMode = {}));\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar Shader = (function () {\n\t\t\tfunction Shader(context, vertexShader, fragmentShader) {\n\t\t\t\tthis.vertexShader = vertexShader;\n\t\t\t\tthis.fragmentShader = fragmentShader;\n\t\t\t\tthis.vs = null;\n\t\t\t\tthis.fs = null;\n\t\t\t\tthis.program = null;\n\t\t\t\tthis.tmp2x2 = new Float32Array(2 * 2);\n\t\t\t\tthis.tmp3x3 = new Float32Array(3 * 3);\n\t\t\t\tthis.tmp4x4 = new Float32Array(4 * 4);\n\t\t\t\tthis.vsSource = vertexShader;\n\t\t\t\tthis.fsSource = fragmentShader;\n\t\t\t\tthis.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);\n\t\t\t\tthis.context.addRestorable(this);\n\t\t\t\tthis.compile();\n\t\t\t}\n\t\t\tShader.prototype.getProgram = function () { return this.program; };\n\t\t\tShader.prototype.getVertexShader = function () { return this.vertexShader; };\n\t\t\tShader.prototype.getFragmentShader = function () { return this.fragmentShader; };\n\t\t\tShader.prototype.getVertexShaderSource = function () { return this.vsSource; };\n\t\t\tShader.prototype.getFragmentSource = function () { return this.fsSource; };\n\t\t\tShader.prototype.compile = function () {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\ttry {\n\t\t\t\t\tthis.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader);\n\t\t\t\t\tthis.fs = this.compileShader(gl.FRAGMENT_SHADER, this.fragmentShader);\n\t\t\t\t\tthis.program = this.compileProgram(this.vs, this.fs);\n\t\t\t\t}\n\t\t\t\tcatch (e) {\n\t\t\t\t\tthis.dispose();\n\t\t\t\t\tthrow e;\n\t\t\t\t}\n\t\t\t};\n\t\t\tShader.prototype.compileShader = function (type, source) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tvar shader = gl.createShader(type);\n\t\t\t\tgl.shaderSource(shader, source);\n\t\t\t\tgl.compileShader(shader);\n\t\t\t\tif (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n\t\t\t\t\tvar error = \"Couldn't compile shader: \" + gl.getShaderInfoLog(shader);\n\t\t\t\t\tgl.deleteShader(shader);\n\t\t\t\t\tif (!gl.isContextLost())\n\t\t\t\t\t\tthrow new Error(error);\n\t\t\t\t}\n\t\t\t\treturn shader;\n\t\t\t};\n\t\t\tShader.prototype.compileProgram = function (vs, fs) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tvar program = gl.createProgram();\n\t\t\t\tgl.attachShader(program, vs);\n\t\t\t\tgl.attachShader(program, fs);\n\t\t\t\tgl.linkProgram(program);\n\t\t\t\tif (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n\t\t\t\t\tvar error = \"Couldn't compile shader program: \" + gl.getProgramInfoLog(program);\n\t\t\t\t\tgl.deleteProgram(program);\n\t\t\t\t\tif (!gl.isContextLost())\n\t\t\t\t\t\tthrow new Error(error);\n\t\t\t\t}\n\t\t\t\treturn program;\n\t\t\t};\n\t\t\tShader.prototype.restore = function () {\n\t\t\t\tthis.compile();\n\t\t\t};\n\t\t\tShader.prototype.bind = function () {\n\t\t\t\tthis.context.gl.useProgram(this.program);\n\t\t\t};\n\t\t\tShader.prototype.unbind = function () {\n\t\t\t\tthis.context.gl.useProgram(null);\n\t\t\t};\n\t\t\tShader.prototype.setUniformi = function (uniform, value) {\n\t\t\t\tthis.context.gl.uniform1i(this.getUniformLocation(uniform), value);\n\t\t\t};\n\t\t\tShader.prototype.setUniformf = function (uniform, value) {\n\t\t\t\tthis.context.gl.uniform1f(this.getUniformLocation(uniform), value);\n\t\t\t};\n\t\t\tShader.prototype.setUniform2f = function (uniform, value, value2) {\n\t\t\t\tthis.context.gl.uniform2f(this.getUniformLocation(uniform), value, value2);\n\t\t\t};\n\t\t\tShader.prototype.setUniform3f = function (uniform, value, value2, value3) {\n\t\t\t\tthis.context.gl.uniform3f(this.getUniformLocation(uniform), value, value2, value3);\n\t\t\t};\n\t\t\tShader.prototype.setUniform4f = function (uniform, value, value2, value3, value4) {\n\t\t\t\tthis.context.gl.uniform4f(this.getUniformLocation(uniform), value, value2, value3, value4);\n\t\t\t};\n\t\t\tShader.prototype.setUniform2x2f = function (uniform, value) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tthis.tmp2x2.set(value);\n\t\t\t\tgl.uniformMatrix2fv(this.getUniformLocation(uniform), false, this.tmp2x2);\n\t\t\t};\n\t\t\tShader.prototype.setUniform3x3f = function (uniform, value) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tthis.tmp3x3.set(value);\n\t\t\t\tgl.uniformMatrix3fv(this.getUniformLocation(uniform), false, this.tmp3x3);\n\t\t\t};\n\t\t\tShader.prototype.setUniform4x4f = function (uniform, value) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tthis.tmp4x4.set(value);\n\t\t\t\tgl.uniformMatrix4fv(this.getUniformLocation(uniform), false, this.tmp4x4);\n\t\t\t};\n\t\t\tShader.prototype.getUniformLocation = function (uniform) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tvar location = gl.getUniformLocation(this.program, uniform);\n\t\t\t\tif (!location && !gl.isContextLost())\n\t\t\t\t\tthrow new Error(\"Couldn't find location for uniform \" + uniform);\n\t\t\t\treturn location;\n\t\t\t};\n\t\t\tShader.prototype.getAttributeLocation = function (attribute) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tvar location = gl.getAttribLocation(this.program, attribute);\n\t\t\t\tif (location == -1 && !gl.isContextLost())\n\t\t\t\t\tthrow new Error(\"Couldn't find location for attribute \" + attribute);\n\t\t\t\treturn location;\n\t\t\t};\n\t\t\tShader.prototype.dispose = function () {\n\t\t\t\tthis.context.removeRestorable(this);\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tif (this.vs) {\n\t\t\t\t\tgl.deleteShader(this.vs);\n\t\t\t\t\tthis.vs = null;\n\t\t\t\t}\n\t\t\t\tif (this.fs) {\n\t\t\t\t\tgl.deleteShader(this.fs);\n\t\t\t\t\tthis.fs = null;\n\t\t\t\t}\n\t\t\t\tif (this.program) {\n\t\t\t\t\tgl.deleteProgram(this.program);\n\t\t\t\t\tthis.program = null;\n\t\t\t\t}\n\t\t\t};\n\t\t\tShader.newColoredTextured = function (context) {\n\t\t\t\tvar vs = \"\\n\\t\\t\\t\\tattribute vec4 \" + Shader.POSITION + \";\\n\\t\\t\\t\\tattribute vec4 \" + Shader.COLOR + \";\\n\\t\\t\\t\\tattribute vec2 \" + Shader.TEXCOORDS + \";\\n\\t\\t\\t\\tuniform mat4 \" + Shader.MVP_MATRIX + \";\\n\\t\\t\\t\\tvarying vec4 v_color;\\n\\t\\t\\t\\tvarying vec2 v_texCoords;\\n\\n\\t\\t\\t\\tvoid main () {\\n\\t\\t\\t\\t\\tv_color = \" + Shader.COLOR + \";\\n\\t\\t\\t\\t\\tv_texCoords = \" + Shader.TEXCOORDS + \";\\n\\t\\t\\t\\t\\tgl_Position = \" + Shader.MVP_MATRIX + \" * \" + Shader.POSITION + \";\\n\\t\\t\\t\\t}\\n\\t\\t\\t\";\n\t\t\t\tvar fs = \"\\n\\t\\t\\t\\t#ifdef GL_ES\\n\\t\\t\\t\\t\\t#define LOWP lowp\\n\\t\\t\\t\\t\\tprecision mediump float;\\n\\t\\t\\t\\t#else\\n\\t\\t\\t\\t\\t#define LOWP\\n\\t\\t\\t\\t#endif\\n\\t\\t\\t\\tvarying LOWP vec4 v_color;\\n\\t\\t\\t\\tvarying vec2 v_texCoords;\\n\\t\\t\\t\\tuniform sampler2D u_texture;\\n\\n\\t\\t\\t\\tvoid main () {\\n\\t\\t\\t\\t\\tgl_FragColor = v_color * texture2D(u_texture, v_texCoords);\\n\\t\\t\\t\\t}\\n\\t\\t\\t\";\n\t\t\t\treturn new Shader(context, vs, fs);\n\t\t\t};\n\t\t\tShader.newTwoColoredTextured = function (context) {\n\t\t\t\tvar vs = \"\\n\\t\\t\\t\\tattribute vec4 \" + Shader.POSITION + \";\\n\\t\\t\\t\\tattribute vec4 \" + Shader.COLOR + \";\\n\\t\\t\\t\\tattribute vec4 \" + Shader.COLOR2 + \";\\n\\t\\t\\t\\tattribute vec2 \" + Shader.TEXCOORDS + \";\\n\\t\\t\\t\\tuniform mat4 \" + Shader.MVP_MATRIX + \";\\n\\t\\t\\t\\tvarying vec4 v_light;\\n\\t\\t\\t\\tvarying vec4 v_dark;\\n\\t\\t\\t\\tvarying vec2 v_texCoords;\\n\\n\\t\\t\\t\\tvoid main () {\\n\\t\\t\\t\\t\\tv_light = \" + Shader.COLOR + \";\\n\\t\\t\\t\\t\\tv_dark = \" + Shader.COLOR2 + \";\\n\\t\\t\\t\\t\\tv_texCoords = \" + Shader.TEXCOORDS + \";\\n\\t\\t\\t\\t\\tgl_Position = \" + Shader.MVP_MATRIX + \" * \" + Shader.POSITION + \";\\n\\t\\t\\t\\t}\\n\\t\\t\\t\";\n\t\t\t\tvar fs = \"\\n\\t\\t\\t\\t#ifdef GL_ES\\n\\t\\t\\t\\t\\t#define LOWP lowp\\n\\t\\t\\t\\t\\tprecision mediump float;\\n\\t\\t\\t\\t#else\\n\\t\\t\\t\\t\\t#define LOWP\\n\\t\\t\\t\\t#endif\\n\\t\\t\\t\\tvarying LOWP vec4 v_light;\\n\\t\\t\\t\\tvarying LOWP vec4 v_dark;\\n\\t\\t\\t\\tvarying vec2 v_texCoords;\\n\\t\\t\\t\\tuniform sampler2D u_texture;\\n\\n\\t\\t\\t\\tvoid main () {\\n\\t\\t\\t\\t\\tvec4 texColor = texture2D(u_texture, v_texCoords);\\n\\t\\t\\t\\t\\tgl_FragColor.a = texColor.a * v_light.a;\\n\\t\\t\\t\\t\\tgl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\";\n\t\t\t\treturn new Shader(context, vs, fs);\n\t\t\t};\n\t\t\tShader.newColored = function (context) {\n\t\t\t\tvar vs = \"\\n\\t\\t\\t\\tattribute vec4 \" + Shader.POSITION + \";\\n\\t\\t\\t\\tattribute vec4 \" + Shader.COLOR + \";\\n\\t\\t\\t\\tuniform mat4 \" + Shader.MVP_MATRIX + \";\\n\\t\\t\\t\\tvarying vec4 v_color;\\n\\n\\t\\t\\t\\tvoid main () {\\n\\t\\t\\t\\t\\tv_color = \" + Shader.COLOR + \";\\n\\t\\t\\t\\t\\tgl_Position = \" + Shader.MVP_MATRIX + \" * \" + Shader.POSITION + \";\\n\\t\\t\\t\\t}\\n\\t\\t\\t\";\n\t\t\t\tvar fs = \"\\n\\t\\t\\t\\t#ifdef GL_ES\\n\\t\\t\\t\\t\\t#define LOWP lowp\\n\\t\\t\\t\\t\\tprecision mediump float;\\n\\t\\t\\t\\t#else\\n\\t\\t\\t\\t\\t#define LOWP\\n\\t\\t\\t\\t#endif\\n\\t\\t\\t\\tvarying LOWP vec4 v_color;\\n\\n\\t\\t\\t\\tvoid main () {\\n\\t\\t\\t\\t\\tgl_FragColor = v_color;\\n\\t\\t\\t\\t}\\n\\t\\t\\t\";\n\t\t\t\treturn new Shader(context, vs, fs);\n\t\t\t};\n\t\t\tShader.MVP_MATRIX = \"u_projTrans\";\n\t\t\tShader.POSITION = \"a_position\";\n\t\t\tShader.COLOR = \"a_color\";\n\t\t\tShader.COLOR2 = \"a_color2\";\n\t\t\tShader.TEXCOORDS = \"a_texCoords\";\n\t\t\tShader.SAMPLER = \"u_texture\";\n\t\t\treturn Shader;\n\t\t}());\n\t\twebgl.Shader = Shader;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar ShapeRenderer = (function () {\n\t\t\tfunction ShapeRenderer(context, maxVertices) {\n\t\t\t\tif (maxVertices === void 0) { maxVertices = 10920; }\n\t\t\t\tthis.isDrawing = false;\n\t\t\t\tthis.shapeType = ShapeType.Filled;\n\t\t\t\tthis.color = new spine.Color(1, 1, 1, 1);\n\t\t\t\tthis.vertexIndex = 0;\n\t\t\t\tthis.tmp = new spine.Vector2();\n\t\t\t\tif (maxVertices > 10920)\n\t\t\t\t\tthrow new Error(\"Can't have more than 10920 triangles per batch: \" + maxVertices);\n\t\t\t\tthis.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);\n\t\t\t\tthis.mesh = new webgl.Mesh(context, [new webgl.Position2Attribute(), new webgl.ColorAttribute()], maxVertices, 0);\n\t\t\t\tthis.srcBlend = this.context.gl.SRC_ALPHA;\n\t\t\t\tthis.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA;\n\t\t\t}\n\t\t\tShapeRenderer.prototype.begin = function (shader) {\n\t\t\t\tif (this.isDrawing)\n\t\t\t\t\tthrow new Error(\"ShapeRenderer.begin() has already been called\");\n\t\t\t\tthis.shader = shader;\n\t\t\t\tthis.vertexIndex = 0;\n\t\t\t\tthis.isDrawing = true;\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tgl.enable(gl.BLEND);\n\t\t\t\tgl.blendFunc(this.srcBlend, this.dstBlend);\n\t\t\t};\n\t\t\tShapeRenderer.prototype.setBlendMode = function (srcBlend, dstBlend) {\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tthis.srcBlend = srcBlend;\n\t\t\t\tthis.dstBlend = dstBlend;\n\t\t\t\tif (this.isDrawing) {\n\t\t\t\t\tthis.flush();\n\t\t\t\t\tgl.blendFunc(this.srcBlend, this.dstBlend);\n\t\t\t\t}\n\t\t\t};\n\t\t\tShapeRenderer.prototype.setColor = function (color) {\n\t\t\t\tthis.color.setFromColor(color);\n\t\t\t};\n\t\t\tShapeRenderer.prototype.setColorWith = function (r, g, b, a) {\n\t\t\t\tthis.color.set(r, g, b, a);\n\t\t\t};\n\t\t\tShapeRenderer.prototype.point = function (x, y, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.check(ShapeType.Point, 1);\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.color;\n\t\t\t\tthis.vertex(x, y, color);\n\t\t\t};\n\t\t\tShapeRenderer.prototype.line = function (x, y, x2, y2, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.check(ShapeType.Line, 2);\n\t\t\t\tvar vertices = this.mesh.getVertices();\n\t\t\t\tvar idx = this.vertexIndex;\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.color;\n\t\t\t\tthis.vertex(x, y, color);\n\t\t\t\tthis.vertex(x2, y2, color);\n\t\t\t};\n\t\t\tShapeRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (color2 === void 0) { color2 = null; }\n\t\t\t\tif (color3 === void 0) { color3 = null; }\n\t\t\t\tthis.check(filled ? ShapeType.Filled : ShapeType.Line, 3);\n\t\t\t\tvar vertices = this.mesh.getVertices();\n\t\t\t\tvar idx = this.vertexIndex;\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.color;\n\t\t\t\tif (color2 === null)\n\t\t\t\t\tcolor2 = this.color;\n\t\t\t\tif (color3 === null)\n\t\t\t\t\tcolor3 = this.color;\n\t\t\t\tif (filled) {\n\t\t\t\t\tthis.vertex(x, y, color);\n\t\t\t\t\tthis.vertex(x2, y2, color2);\n\t\t\t\t\tthis.vertex(x3, y3, color3);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.vertex(x, y, color);\n\t\t\t\t\tthis.vertex(x2, y2, color2);\n\t\t\t\t\tthis.vertex(x2, y2, color);\n\t\t\t\t\tthis.vertex(x3, y3, color2);\n\t\t\t\t\tthis.vertex(x3, y3, color);\n\t\t\t\t\tthis.vertex(x, y, color2);\n\t\t\t\t}\n\t\t\t};\n\t\t\tShapeRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (color2 === void 0) { color2 = null; }\n\t\t\t\tif (color3 === void 0) { color3 = null; }\n\t\t\t\tif (color4 === void 0) { color4 = null; }\n\t\t\t\tthis.check(filled ? ShapeType.Filled : ShapeType.Line, 3);\n\t\t\t\tvar vertices = this.mesh.getVertices();\n\t\t\t\tvar idx = this.vertexIndex;\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.color;\n\t\t\t\tif (color2 === null)\n\t\t\t\t\tcolor2 = this.color;\n\t\t\t\tif (color3 === null)\n\t\t\t\t\tcolor3 = this.color;\n\t\t\t\tif (color4 === null)\n\t\t\t\t\tcolor4 = this.color;\n\t\t\t\tif (filled) {\n\t\t\t\t\tthis.vertex(x, y, color);\n\t\t\t\t\tthis.vertex(x2, y2, color2);\n\t\t\t\t\tthis.vertex(x3, y3, color3);\n\t\t\t\t\tthis.vertex(x3, y3, color3);\n\t\t\t\t\tthis.vertex(x4, y4, color4);\n\t\t\t\t\tthis.vertex(x, y, color);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.vertex(x, y, color);\n\t\t\t\t\tthis.vertex(x2, y2, color2);\n\t\t\t\t\tthis.vertex(x2, y2, color2);\n\t\t\t\t\tthis.vertex(x3, y3, color3);\n\t\t\t\t\tthis.vertex(x3, y3, color3);\n\t\t\t\t\tthis.vertex(x4, y4, color4);\n\t\t\t\t\tthis.vertex(x4, y4, color4);\n\t\t\t\t\tthis.vertex(x, y, color);\n\t\t\t\t}\n\t\t\t};\n\t\t\tShapeRenderer.prototype.rect = function (filled, x, y, width, height, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color);\n\t\t\t};\n\t\t\tShapeRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.check(filled ? ShapeType.Filled : ShapeType.Line, 8);\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.color;\n\t\t\t\tvar t = this.tmp.set(y2 - y1, x1 - x2);\n\t\t\t\tt.normalize();\n\t\t\t\twidth *= 0.5;\n\t\t\t\tvar tx = t.x * width;\n\t\t\t\tvar ty = t.y * width;\n\t\t\t\tif (!filled) {\n\t\t\t\t\tthis.vertex(x1 + tx, y1 + ty, color);\n\t\t\t\t\tthis.vertex(x1 - tx, y1 - ty, color);\n\t\t\t\t\tthis.vertex(x2 + tx, y2 + ty, color);\n\t\t\t\t\tthis.vertex(x2 - tx, y2 - ty, color);\n\t\t\t\t\tthis.vertex(x2 + tx, y2 + ty, color);\n\t\t\t\t\tthis.vertex(x1 + tx, y1 + ty, color);\n\t\t\t\t\tthis.vertex(x2 - tx, y2 - ty, color);\n\t\t\t\t\tthis.vertex(x1 - tx, y1 - ty, color);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.vertex(x1 + tx, y1 + ty, color);\n\t\t\t\t\tthis.vertex(x1 - tx, y1 - ty, color);\n\t\t\t\t\tthis.vertex(x2 + tx, y2 + ty, color);\n\t\t\t\t\tthis.vertex(x2 - tx, y2 - ty, color);\n\t\t\t\t\tthis.vertex(x2 + tx, y2 + ty, color);\n\t\t\t\t\tthis.vertex(x1 - tx, y1 - ty, color);\n\t\t\t\t}\n\t\t\t};\n\t\t\tShapeRenderer.prototype.x = function (x, y, size) {\n\t\t\t\tthis.line(x - size, y - size, x + size, y + size);\n\t\t\t\tthis.line(x - size, y + size, x + size, y - size);\n\t\t\t};\n\t\t\tShapeRenderer.prototype.polygon = function (polygonVertices, offset, count, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (count < 3)\n\t\t\t\t\tthrow new Error(\"Polygon must contain at least 3 vertices\");\n\t\t\t\tthis.check(ShapeType.Line, count * 2);\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.color;\n\t\t\t\tvar vertices = this.mesh.getVertices();\n\t\t\t\tvar idx = this.vertexIndex;\n\t\t\t\toffset <<= 1;\n\t\t\t\tcount <<= 1;\n\t\t\t\tvar firstX = polygonVertices[offset];\n\t\t\t\tvar firstY = polygonVertices[offset + 1];\n\t\t\t\tvar last = offset + count;\n\t\t\t\tfor (var i = offset, n = offset + count - 2; i < n; i += 2) {\n\t\t\t\t\tvar x1 = polygonVertices[i];\n\t\t\t\t\tvar y1 = polygonVertices[i + 1];\n\t\t\t\t\tvar x2 = 0;\n\t\t\t\t\tvar y2 = 0;\n\t\t\t\t\tif (i + 2 >= last) {\n\t\t\t\t\t\tx2 = firstX;\n\t\t\t\t\t\ty2 = firstY;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tx2 = polygonVertices[i + 2];\n\t\t\t\t\t\ty2 = polygonVertices[i + 3];\n\t\t\t\t\t}\n\t\t\t\t\tthis.vertex(x1, y1, color);\n\t\t\t\t\tthis.vertex(x2, y2, color);\n\t\t\t\t}\n\t\t\t};\n\t\t\tShapeRenderer.prototype.circle = function (filled, x, y, radius, color, segments) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tif (segments === void 0) { segments = 0; }\n\t\t\t\tif (segments === 0)\n\t\t\t\t\tsegments = Math.max(1, (6 * spine.MathUtils.cbrt(radius)) | 0);\n\t\t\t\tif (segments <= 0)\n\t\t\t\t\tthrow new Error(\"segments must be > 0.\");\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.color;\n\t\t\t\tvar angle = 2 * spine.MathUtils.PI / segments;\n\t\t\t\tvar cos = Math.cos(angle);\n\t\t\t\tvar sin = Math.sin(angle);\n\t\t\t\tvar cx = radius, cy = 0;\n\t\t\t\tif (!filled) {\n\t\t\t\t\tthis.check(ShapeType.Line, segments * 2 + 2);\n\t\t\t\t\tfor (var i = 0; i < segments; i++) {\n\t\t\t\t\t\tthis.vertex(x + cx, y + cy, color);\n\t\t\t\t\t\tvar temp_1 = cx;\n\t\t\t\t\t\tcx = cos * cx - sin * cy;\n\t\t\t\t\t\tcy = sin * temp_1 + cos * cy;\n\t\t\t\t\t\tthis.vertex(x + cx, y + cy, color);\n\t\t\t\t\t}\n\t\t\t\t\tthis.vertex(x + cx, y + cy, color);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.check(ShapeType.Filled, segments * 3 + 3);\n\t\t\t\t\tsegments--;\n\t\t\t\t\tfor (var i = 0; i < segments; i++) {\n\t\t\t\t\t\tthis.vertex(x, y, color);\n\t\t\t\t\t\tthis.vertex(x + cx, y + cy, color);\n\t\t\t\t\t\tvar temp_2 = cx;\n\t\t\t\t\t\tcx = cos * cx - sin * cy;\n\t\t\t\t\t\tcy = sin * temp_2 + cos * cy;\n\t\t\t\t\t\tthis.vertex(x + cx, y + cy, color);\n\t\t\t\t\t}\n\t\t\t\t\tthis.vertex(x, y, color);\n\t\t\t\t\tthis.vertex(x + cx, y + cy, color);\n\t\t\t\t}\n\t\t\t\tvar temp = cx;\n\t\t\t\tcx = radius;\n\t\t\t\tcy = 0;\n\t\t\t\tthis.vertex(x + cx, y + cy, color);\n\t\t\t};\n\t\t\tShapeRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) {\n\t\t\t\tif (color === void 0) { color = null; }\n\t\t\t\tthis.check(ShapeType.Line, segments * 2 + 2);\n\t\t\t\tif (color === null)\n\t\t\t\t\tcolor = this.color;\n\t\t\t\tvar subdiv_step = 1 / segments;\n\t\t\t\tvar subdiv_step2 = subdiv_step * subdiv_step;\n\t\t\t\tvar subdiv_step3 = subdiv_step * subdiv_step * subdiv_step;\n\t\t\t\tvar pre1 = 3 * subdiv_step;\n\t\t\t\tvar pre2 = 3 * subdiv_step2;\n\t\t\t\tvar pre4 = 6 * subdiv_step2;\n\t\t\t\tvar pre5 = 6 * subdiv_step3;\n\t\t\t\tvar tmp1x = x1 - cx1 * 2 + cx2;\n\t\t\t\tvar tmp1y = y1 - cy1 * 2 + cy2;\n\t\t\t\tvar tmp2x = (cx1 - cx2) * 3 - x1 + x2;\n\t\t\t\tvar tmp2y = (cy1 - cy2) * 3 - y1 + y2;\n\t\t\t\tvar fx = x1;\n\t\t\t\tvar fy = y1;\n\t\t\t\tvar dfx = (cx1 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3;\n\t\t\t\tvar dfy = (cy1 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3;\n\t\t\t\tvar ddfx = tmp1x * pre4 + tmp2x * pre5;\n\t\t\t\tvar ddfy = tmp1y * pre4 + tmp2y * pre5;\n\t\t\t\tvar dddfx = tmp2x * pre5;\n\t\t\t\tvar dddfy = tmp2y * pre5;\n\t\t\t\twhile (segments-- > 0) {\n\t\t\t\t\tthis.vertex(fx, fy, color);\n\t\t\t\t\tfx += dfx;\n\t\t\t\t\tfy += dfy;\n\t\t\t\t\tdfx += ddfx;\n\t\t\t\t\tdfy += ddfy;\n\t\t\t\t\tddfx += dddfx;\n\t\t\t\t\tddfy += dddfy;\n\t\t\t\t\tthis.vertex(fx, fy, color);\n\t\t\t\t}\n\t\t\t\tthis.vertex(fx, fy, color);\n\t\t\t\tthis.vertex(x2, y2, color);\n\t\t\t};\n\t\t\tShapeRenderer.prototype.vertex = function (x, y, color) {\n\t\t\t\tvar idx = this.vertexIndex;\n\t\t\t\tvar vertices = this.mesh.getVertices();\n\t\t\t\tvertices[idx++] = x;\n\t\t\t\tvertices[idx++] = y;\n\t\t\t\tvertices[idx++] = color.r;\n\t\t\t\tvertices[idx++] = color.g;\n\t\t\t\tvertices[idx++] = color.b;\n\t\t\t\tvertices[idx++] = color.a;\n\t\t\t\tthis.vertexIndex = idx;\n\t\t\t};\n\t\t\tShapeRenderer.prototype.end = function () {\n\t\t\t\tif (!this.isDrawing)\n\t\t\t\t\tthrow new Error(\"ShapeRenderer.begin() has not been called\");\n\t\t\t\tthis.flush();\n\t\t\t\tthis.context.gl.disable(this.context.gl.BLEND);\n\t\t\t\tthis.isDrawing = false;\n\t\t\t};\n\t\t\tShapeRenderer.prototype.flush = function () {\n\t\t\t\tif (this.vertexIndex == 0)\n\t\t\t\t\treturn;\n\t\t\t\tthis.mesh.setVerticesLength(this.vertexIndex);\n\t\t\t\tthis.mesh.draw(this.shader, this.shapeType);\n\t\t\t\tthis.vertexIndex = 0;\n\t\t\t};\n\t\t\tShapeRenderer.prototype.check = function (shapeType, numVertices) {\n\t\t\t\tif (!this.isDrawing)\n\t\t\t\t\tthrow new Error(\"ShapeRenderer.begin() has not been called\");\n\t\t\t\tif (this.shapeType == shapeType) {\n\t\t\t\t\tif (this.mesh.maxVertices() - this.mesh.numVertices() < numVertices)\n\t\t\t\t\t\tthis.flush();\n\t\t\t\t\telse\n\t\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.flush();\n\t\t\t\t\tthis.shapeType = shapeType;\n\t\t\t\t}\n\t\t\t};\n\t\t\tShapeRenderer.prototype.dispose = function () {\n\t\t\t\tthis.mesh.dispose();\n\t\t\t};\n\t\t\treturn ShapeRenderer;\n\t\t}());\n\t\twebgl.ShapeRenderer = ShapeRenderer;\n\t\tvar ShapeType;\n\t\t(function (ShapeType) {\n\t\t\tShapeType[ShapeType[\"Point\"] = 0] = \"Point\";\n\t\t\tShapeType[ShapeType[\"Line\"] = 1] = \"Line\";\n\t\t\tShapeType[ShapeType[\"Filled\"] = 4] = \"Filled\";\n\t\t})(ShapeType = webgl.ShapeType || (webgl.ShapeType = {}));\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar SkeletonDebugRenderer = (function () {\n\t\t\tfunction SkeletonDebugRenderer(context) {\n\t\t\t\tthis.boneLineColor = new spine.Color(1, 0, 0, 1);\n\t\t\t\tthis.boneOriginColor = new spine.Color(0, 1, 0, 1);\n\t\t\t\tthis.attachmentLineColor = new spine.Color(0, 0, 1, 0.5);\n\t\t\t\tthis.triangleLineColor = new spine.Color(1, 0.64, 0, 0.5);\n\t\t\t\tthis.pathColor = new spine.Color().setFromString(\"FF7F00\");\n\t\t\t\tthis.clipColor = new spine.Color(0.8, 0, 0, 2);\n\t\t\t\tthis.aabbColor = new spine.Color(0, 1, 0, 0.5);\n\t\t\t\tthis.drawBones = true;\n\t\t\t\tthis.drawRegionAttachments = true;\n\t\t\t\tthis.drawBoundingBoxes = true;\n\t\t\t\tthis.drawMeshHull = true;\n\t\t\t\tthis.drawMeshTriangles = true;\n\t\t\t\tthis.drawPaths = true;\n\t\t\t\tthis.drawSkeletonXY = false;\n\t\t\t\tthis.drawClipping = true;\n\t\t\t\tthis.premultipliedAlpha = false;\n\t\t\t\tthis.scale = 1;\n\t\t\t\tthis.boneWidth = 2;\n\t\t\t\tthis.bounds = new spine.SkeletonBounds();\n\t\t\t\tthis.temp = new Array();\n\t\t\t\tthis.vertices = spine.Utils.newFloatArray(2 * 1024);\n\t\t\t\tthis.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context);\n\t\t\t}\n\t\t\tSkeletonDebugRenderer.prototype.draw = function (shapes, skeleton, ignoredBones) {\n\t\t\t\tif (ignoredBones === void 0) { ignoredBones = null; }\n\t\t\t\tvar skeletonX = skeleton.x;\n\t\t\t\tvar skeletonY = skeleton.y;\n\t\t\t\tvar gl = this.context.gl;\n\t\t\t\tvar srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA;\n\t\t\t\tshapes.setBlendMode(srcFunc, gl.ONE_MINUS_SRC_ALPHA);\n\t\t\t\tvar bones = skeleton.bones;\n\t\t\t\tif (this.drawBones) {\n\t\t\t\t\tshapes.setColor(this.boneLineColor);\n\t\t\t\t\tfor (var i = 0, n = bones.length; i < n; i++) {\n\t\t\t\t\t\tvar bone = bones[i];\n\t\t\t\t\t\tif (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tif (bone.parent == null)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tvar x = skeletonX + bone.data.length * bone.a + bone.worldX;\n\t\t\t\t\t\tvar y = skeletonY + bone.data.length * bone.c + bone.worldY;\n\t\t\t\t\t\tshapes.rectLine(true, skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, this.boneWidth * this.scale);\n\t\t\t\t\t}\n\t\t\t\t\tif (this.drawSkeletonXY)\n\t\t\t\t\t\tshapes.x(skeletonX, skeletonY, 4 * this.scale);\n\t\t\t\t}\n\t\t\t\tif (this.drawRegionAttachments) {\n\t\t\t\t\tshapes.setColor(this.attachmentLineColor);\n\t\t\t\t\tvar slots = skeleton.slots;\n\t\t\t\t\tfor (var i = 0, n = slots.length; i < n; i++) {\n\t\t\t\t\t\tvar slot = slots[i];\n\t\t\t\t\t\tvar attachment = slot.getAttachment();\n\t\t\t\t\t\tif (attachment instanceof spine.RegionAttachment) {\n\t\t\t\t\t\t\tvar regionAttachment = attachment;\n\t\t\t\t\t\t\tvar vertices = this.vertices;\n\t\t\t\t\t\t\tregionAttachment.computeWorldVertices(slot.bone, vertices, 0, 2);\n\t\t\t\t\t\t\tshapes.line(vertices[0], vertices[1], vertices[2], vertices[3]);\n\t\t\t\t\t\t\tshapes.line(vertices[2], vertices[3], vertices[4], vertices[5]);\n\t\t\t\t\t\t\tshapes.line(vertices[4], vertices[5], vertices[6], vertices[7]);\n\t\t\t\t\t\t\tshapes.line(vertices[6], vertices[7], vertices[0], vertices[1]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (this.drawMeshHull || this.drawMeshTriangles) {\n\t\t\t\t\tvar slots = skeleton.slots;\n\t\t\t\t\tfor (var i = 0, n = slots.length; i < n; i++) {\n\t\t\t\t\t\tvar slot = slots[i];\n\t\t\t\t\t\tvar attachment = slot.getAttachment();\n\t\t\t\t\t\tif (!(attachment instanceof spine.MeshAttachment))\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tvar mesh = attachment;\n\t\t\t\t\t\tvar vertices = this.vertices;\n\t\t\t\t\t\tmesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 2);\n\t\t\t\t\t\tvar triangles = mesh.triangles;\n\t\t\t\t\t\tvar hullLength = mesh.hullLength;\n\t\t\t\t\t\tif (this.drawMeshTriangles) {\n\t\t\t\t\t\t\tshapes.setColor(this.triangleLineColor);\n\t\t\t\t\t\t\tfor (var ii = 0, nn = triangles.length; ii < nn; ii += 3) {\n\t\t\t\t\t\t\t\tvar v1 = triangles[ii] * 2, v2 = triangles[ii + 1] * 2, v3 = triangles[ii + 2] * 2;\n\t\t\t\t\t\t\t\tshapes.triangle(false, vertices[v1], vertices[v1 + 1], vertices[v2], vertices[v2 + 1], vertices[v3], vertices[v3 + 1]);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (this.drawMeshHull && hullLength > 0) {\n\t\t\t\t\t\t\tshapes.setColor(this.attachmentLineColor);\n\t\t\t\t\t\t\thullLength = (hullLength >> 1) * 2;\n\t\t\t\t\t\t\tvar lastX = vertices[hullLength - 2], lastY = vertices[hullLength - 1];\n\t\t\t\t\t\t\tfor (var ii = 0, nn = hullLength; ii < nn; ii += 2) {\n\t\t\t\t\t\t\t\tvar x = vertices[ii], y = vertices[ii + 1];\n\t\t\t\t\t\t\t\tshapes.line(x, y, lastX, lastY);\n\t\t\t\t\t\t\t\tlastX = x;\n\t\t\t\t\t\t\t\tlastY = y;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (this.drawBoundingBoxes) {\n\t\t\t\t\tvar bounds = this.bounds;\n\t\t\t\t\tbounds.update(skeleton, true);\n\t\t\t\t\tshapes.setColor(this.aabbColor);\n\t\t\t\t\tshapes.rect(false, bounds.minX, bounds.minY, bounds.getWidth(), bounds.getHeight());\n\t\t\t\t\tvar polygons = bounds.polygons;\n\t\t\t\t\tvar boxes = bounds.boundingBoxes;\n\t\t\t\t\tfor (var i = 0, n = polygons.length; i < n; i++) {\n\t\t\t\t\t\tvar polygon = polygons[i];\n\t\t\t\t\t\tshapes.setColor(boxes[i].color);\n\t\t\t\t\t\tshapes.polygon(polygon, 0, polygon.length);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (this.drawPaths) {\n\t\t\t\t\tvar slots = skeleton.slots;\n\t\t\t\t\tfor (var i = 0, n = slots.length; i < n; i++) {\n\t\t\t\t\t\tvar slot = slots[i];\n\t\t\t\t\t\tvar attachment = slot.getAttachment();\n\t\t\t\t\t\tif (!(attachment instanceof spine.PathAttachment))\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tvar path = attachment;\n\t\t\t\t\t\tvar nn = path.worldVerticesLength;\n\t\t\t\t\t\tvar world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);\n\t\t\t\t\t\tpath.computeWorldVertices(slot, 0, nn, world, 0, 2);\n\t\t\t\t\t\tvar color = this.pathColor;\n\t\t\t\t\t\tvar x1 = world[2], y1 = world[3], x2 = 0, y2 = 0;\n\t\t\t\t\t\tif (path.closed) {\n\t\t\t\t\t\t\tshapes.setColor(color);\n\t\t\t\t\t\t\tvar cx1 = world[0], cy1 = world[1], cx2 = world[nn - 2], cy2 = world[nn - 1];\n\t\t\t\t\t\t\tx2 = world[nn - 4];\n\t\t\t\t\t\t\ty2 = world[nn - 3];\n\t\t\t\t\t\t\tshapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);\n\t\t\t\t\t\t\tshapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);\n\t\t\t\t\t\t\tshapes.line(x1, y1, cx1, cy1);\n\t\t\t\t\t\t\tshapes.line(x2, y2, cx2, cy2);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnn -= 4;\n\t\t\t\t\t\tfor (var ii = 4; ii < nn; ii += 6) {\n\t\t\t\t\t\t\tvar cx1 = world[ii], cy1 = world[ii + 1], cx2 = world[ii + 2], cy2 = world[ii + 3];\n\t\t\t\t\t\t\tx2 = world[ii + 4];\n\t\t\t\t\t\t\ty2 = world[ii + 5];\n\t\t\t\t\t\t\tshapes.setColor(color);\n\t\t\t\t\t\t\tshapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32);\n\t\t\t\t\t\t\tshapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY);\n\t\t\t\t\t\t\tshapes.line(x1, y1, cx1, cy1);\n\t\t\t\t\t\t\tshapes.line(x2, y2, cx2, cy2);\n\t\t\t\t\t\t\tx1 = x2;\n\t\t\t\t\t\t\ty1 = y2;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (this.drawBones) {\n\t\t\t\t\tshapes.setColor(this.boneOriginColor);\n\t\t\t\t\tfor (var i = 0, n = bones.length; i < n; i++) {\n\t\t\t\t\t\tvar bone = bones[i];\n\t\t\t\t\t\tif (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tshapes.circle(true, skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * this.scale, SkeletonDebugRenderer.GREEN, 8);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (this.drawClipping) {\n\t\t\t\t\tvar slots = skeleton.slots;\n\t\t\t\t\tshapes.setColor(this.clipColor);\n\t\t\t\t\tfor (var i = 0, n = slots.length; i < n; i++) {\n\t\t\t\t\t\tvar slot = slots[i];\n\t\t\t\t\t\tvar attachment = slot.getAttachment();\n\t\t\t\t\t\tif (!(attachment instanceof spine.ClippingAttachment))\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tvar clip = attachment;\n\t\t\t\t\t\tvar nn = clip.worldVerticesLength;\n\t\t\t\t\t\tvar world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0);\n\t\t\t\t\t\tclip.computeWorldVertices(slot, 0, nn, world, 0, 2);\n\t\t\t\t\t\tfor (var i_12 = 0, n_2 = world.length; i_12 < n_2; i_12 += 2) {\n\t\t\t\t\t\t\tvar x = world[i_12];\n\t\t\t\t\t\t\tvar y = world[i_12 + 1];\n\t\t\t\t\t\t\tvar x2 = world[(i_12 + 2) % world.length];\n\t\t\t\t\t\t\tvar y2 = world[(i_12 + 3) % world.length];\n\t\t\t\t\t\t\tshapes.line(x, y, x2, y2);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t\tSkeletonDebugRenderer.prototype.dispose = function () {\n\t\t\t};\n\t\t\tSkeletonDebugRenderer.LIGHT_GRAY = new spine.Color(192 / 255, 192 / 255, 192 / 255, 1);\n\t\t\tSkeletonDebugRenderer.GREEN = new spine.Color(0, 1, 0, 1);\n\t\t\treturn SkeletonDebugRenderer;\n\t\t}());\n\t\twebgl.SkeletonDebugRenderer = SkeletonDebugRenderer;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar Renderable = (function () {\n\t\t\tfunction Renderable(vertices, numVertices, numFloats) {\n\t\t\t\tthis.vertices = vertices;\n\t\t\t\tthis.numVertices = numVertices;\n\t\t\t\tthis.numFloats = numFloats;\n\t\t\t}\n\t\t\treturn Renderable;\n\t\t}());\n\t\t;\n\t\tvar SkeletonRenderer = (function () {\n\t\t\tfunction SkeletonRenderer(context, twoColorTint) {\n\t\t\t\tif (twoColorTint === void 0) { twoColorTint = true; }\n\t\t\t\tthis.premultipliedAlpha = false;\n\t\t\t\tthis.vertexEffect = null;\n\t\t\t\tthis.tempColor = new spine.Color();\n\t\t\t\tthis.tempColor2 = new spine.Color();\n\t\t\t\tthis.vertexSize = 2 + 2 + 4;\n\t\t\t\tthis.twoColorTint = false;\n\t\t\t\tthis.renderable = new Renderable(null, 0, 0);\n\t\t\t\tthis.clipper = new spine.SkeletonClipping();\n\t\t\t\tthis.temp = new spine.Vector2();\n\t\t\t\tthis.temp2 = new spine.Vector2();\n\t\t\t\tthis.temp3 = new spine.Color();\n\t\t\t\tthis.temp4 = new spine.Color();\n\t\t\t\tthis.twoColorTint = twoColorTint;\n\t\t\t\tif (twoColorTint)\n\t\t\t\t\tthis.vertexSize += 4;\n\t\t\t\tthis.vertices = spine.Utils.newFloatArray(this.vertexSize * 1024);\n\t\t\t}\n\t\t\tSkeletonRenderer.prototype.draw = function (batcher, skeleton, slotRangeStart, slotRangeEnd) {\n\t\t\t\tif (slotRangeStart === void 0) { slotRangeStart = -1; }\n\t\t\t\tif (slotRangeEnd === void 0) { slotRangeEnd = -1; }\n\t\t\t\tvar clipper = this.clipper;\n\t\t\t\tvar premultipliedAlpha = this.premultipliedAlpha;\n\t\t\t\tvar twoColorTint = this.twoColorTint;\n\t\t\t\tvar blendMode = null;\n\t\t\t\tvar tempPos = this.temp;\n\t\t\t\tvar tempUv = this.temp2;\n\t\t\t\tvar tempLight = this.temp3;\n\t\t\t\tvar tempDark = this.temp4;\n\t\t\t\tvar renderable = this.renderable;\n\t\t\t\tvar uvs = null;\n\t\t\t\tvar triangles = null;\n\t\t\t\tvar drawOrder = skeleton.drawOrder;\n\t\t\t\tvar attachmentColor = null;\n\t\t\t\tvar skeletonColor = skeleton.color;\n\t\t\t\tvar vertexSize = twoColorTint ? 12 : 8;\n\t\t\t\tvar inRange = false;\n\t\t\t\tif (slotRangeStart == -1)\n\t\t\t\t\tinRange = true;\n\t\t\t\tfor (var i = 0, n = drawOrder.length; i < n; i++) {\n\t\t\t\t\tvar clippedVertexSize = clipper.isClipping() ? 2 : vertexSize;\n\t\t\t\t\tvar slot = drawOrder[i];\n\t\t\t\t\tif (slotRangeStart >= 0 && slotRangeStart == slot.data.index) {\n\t\t\t\t\t\tinRange = true;\n\t\t\t\t\t}\n\t\t\t\t\tif (!inRange) {\n\t\t\t\t\t\tclipper.clipEndWithSlot(slot);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (slotRangeEnd >= 0 && slotRangeEnd == slot.data.index) {\n\t\t\t\t\t\tinRange = false;\n\t\t\t\t\t}\n\t\t\t\t\tvar attachment = slot.getAttachment();\n\t\t\t\t\tvar texture = null;\n\t\t\t\t\tif (attachment instanceof spine.RegionAttachment) {\n\t\t\t\t\t\tvar region = attachment;\n\t\t\t\t\t\trenderable.vertices = this.vertices;\n\t\t\t\t\t\trenderable.numVertices = 4;\n\t\t\t\t\t\trenderable.numFloats = clippedVertexSize << 2;\n\t\t\t\t\t\tregion.computeWorldVertices(slot.bone, renderable.vertices, 0, clippedVertexSize);\n\t\t\t\t\t\ttriangles = SkeletonRenderer.QUAD_TRIANGLES;\n\t\t\t\t\t\tuvs = region.uvs;\n\t\t\t\t\t\ttexture = region.region.renderObject.texture;\n\t\t\t\t\t\tattachmentColor = region.color;\n\t\t\t\t\t}\n\t\t\t\t\telse if (attachment instanceof spine.MeshAttachment) {\n\t\t\t\t\t\tvar mesh = attachment;\n\t\t\t\t\t\trenderable.vertices = this.vertices;\n\t\t\t\t\t\trenderable.numVertices = (mesh.worldVerticesLength >> 1);\n\t\t\t\t\t\trenderable.numFloats = renderable.numVertices * clippedVertexSize;\n\t\t\t\t\t\tif (renderable.numFloats > renderable.vertices.length) {\n\t\t\t\t\t\t\trenderable.vertices = this.vertices = spine.Utils.newFloatArray(renderable.numFloats);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, renderable.vertices, 0, clippedVertexSize);\n\t\t\t\t\t\ttriangles = mesh.triangles;\n\t\t\t\t\t\ttexture = mesh.region.renderObject.texture;\n\t\t\t\t\t\tuvs = mesh.uvs;\n\t\t\t\t\t\tattachmentColor = mesh.color;\n\t\t\t\t\t}\n\t\t\t\t\telse if (attachment instanceof spine.ClippingAttachment) {\n\t\t\t\t\t\tvar clip = (attachment);\n\t\t\t\t\t\tclipper.clipStart(slot, clip);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tif (texture != null) {\n\t\t\t\t\t\tvar slotColor = slot.color;\n\t\t\t\t\t\tvar finalColor = this.tempColor;\n\t\t\t\t\t\tfinalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r;\n\t\t\t\t\t\tfinalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g;\n\t\t\t\t\t\tfinalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b;\n\t\t\t\t\t\tfinalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a;\n\t\t\t\t\t\tif (premultipliedAlpha) {\n\t\t\t\t\t\t\tfinalColor.r *= finalColor.a;\n\t\t\t\t\t\t\tfinalColor.g *= finalColor.a;\n\t\t\t\t\t\t\tfinalColor.b *= finalColor.a;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar darkColor = this.tempColor2;\n\t\t\t\t\t\tif (slot.darkColor == null)\n\t\t\t\t\t\t\tdarkColor.set(0, 0, 0, 1.0);\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tif (premultipliedAlpha) {\n\t\t\t\t\t\t\t\tdarkColor.r = slot.darkColor.r * finalColor.a;\n\t\t\t\t\t\t\t\tdarkColor.g = slot.darkColor.g * finalColor.a;\n\t\t\t\t\t\t\t\tdarkColor.b = slot.darkColor.b * finalColor.a;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tdarkColor.setFromColor(slot.darkColor);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tdarkColor.a = premultipliedAlpha ? 1.0 : 0.0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvar slotBlendMode = slot.data.blendMode;\n\t\t\t\t\t\tif (slotBlendMode != blendMode) {\n\t\t\t\t\t\t\tblendMode = slotBlendMode;\n\t\t\t\t\t\t\tbatcher.setBlendMode(webgl.WebGLBlendModeConverter.getSourceGLBlendMode(blendMode, premultipliedAlpha), webgl.WebGLBlendModeConverter.getDestGLBlendMode(blendMode));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (clipper.isClipping()) {\n\t\t\t\t\t\t\tclipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint);\n\t\t\t\t\t\t\tvar clippedVertices = new Float32Array(clipper.clippedVertices);\n\t\t\t\t\t\t\tvar clippedTriangles = clipper.clippedTriangles;\n\t\t\t\t\t\t\tif (this.vertexEffect != null) {\n\t\t\t\t\t\t\t\tvar vertexEffect = this.vertexEffect;\n\t\t\t\t\t\t\t\tvar verts = clippedVertices;\n\t\t\t\t\t\t\t\tif (!twoColorTint) {\n\t\t\t\t\t\t\t\t\tfor (var v = 0, n_3 = clippedVertices.length; v < n_3; v += vertexSize) {\n\t\t\t\t\t\t\t\t\t\ttempPos.x = verts[v];\n\t\t\t\t\t\t\t\t\t\ttempPos.y = verts[v + 1];\n\t\t\t\t\t\t\t\t\t\ttempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);\n\t\t\t\t\t\t\t\t\t\ttempUv.x = verts[v + 6];\n\t\t\t\t\t\t\t\t\t\ttempUv.y = verts[v + 7];\n\t\t\t\t\t\t\t\t\t\ttempDark.set(0, 0, 0, 0);\n\t\t\t\t\t\t\t\t\t\tvertexEffect.transform(tempPos, tempUv, tempLight, tempDark);\n\t\t\t\t\t\t\t\t\t\tverts[v] = tempPos.x;\n\t\t\t\t\t\t\t\t\t\tverts[v + 1] = tempPos.y;\n\t\t\t\t\t\t\t\t\t\tverts[v + 2] = tempLight.r;\n\t\t\t\t\t\t\t\t\t\tverts[v + 3] = tempLight.g;\n\t\t\t\t\t\t\t\t\t\tverts[v + 4] = tempLight.b;\n\t\t\t\t\t\t\t\t\t\tverts[v + 5] = tempLight.a;\n\t\t\t\t\t\t\t\t\t\tverts[v + 6] = tempUv.x;\n\t\t\t\t\t\t\t\t\t\tverts[v + 7] = tempUv.y;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tfor (var v = 0, n_4 = clippedVertices.length; v < n_4; v += vertexSize) {\n\t\t\t\t\t\t\t\t\t\ttempPos.x = verts[v];\n\t\t\t\t\t\t\t\t\t\ttempPos.y = verts[v + 1];\n\t\t\t\t\t\t\t\t\t\ttempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]);\n\t\t\t\t\t\t\t\t\t\ttempUv.x = verts[v + 6];\n\t\t\t\t\t\t\t\t\t\ttempUv.y = verts[v + 7];\n\t\t\t\t\t\t\t\t\t\ttempDark.set(verts[v + 8], verts[v + 9], verts[v + 10], verts[v + 11]);\n\t\t\t\t\t\t\t\t\t\tvertexEffect.transform(tempPos, tempUv, tempLight, tempDark);\n\t\t\t\t\t\t\t\t\t\tverts[v] = tempPos.x;\n\t\t\t\t\t\t\t\t\t\tverts[v + 1] = tempPos.y;\n\t\t\t\t\t\t\t\t\t\tverts[v + 2] = tempLight.r;\n\t\t\t\t\t\t\t\t\t\tverts[v + 3] = tempLight.g;\n\t\t\t\t\t\t\t\t\t\tverts[v + 4] = tempLight.b;\n\t\t\t\t\t\t\t\t\t\tverts[v + 5] = tempLight.a;\n\t\t\t\t\t\t\t\t\t\tverts[v + 6] = tempUv.x;\n\t\t\t\t\t\t\t\t\t\tverts[v + 7] = tempUv.y;\n\t\t\t\t\t\t\t\t\t\tverts[v + 8] = tempDark.r;\n\t\t\t\t\t\t\t\t\t\tverts[v + 9] = tempDark.g;\n\t\t\t\t\t\t\t\t\t\tverts[v + 10] = tempDark.b;\n\t\t\t\t\t\t\t\t\t\tverts[v + 11] = tempDark.a;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbatcher.draw(texture, clippedVertices, clippedTriangles);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tvar verts = renderable.vertices;\n\t\t\t\t\t\t\tif (this.vertexEffect != null) {\n\t\t\t\t\t\t\t\tvar vertexEffect = this.vertexEffect;\n\t\t\t\t\t\t\t\tif (!twoColorTint) {\n\t\t\t\t\t\t\t\t\tfor (var v = 0, u = 0, n_5 = renderable.numFloats; v < n_5; v += vertexSize, u += 2) {\n\t\t\t\t\t\t\t\t\t\ttempPos.x = verts[v];\n\t\t\t\t\t\t\t\t\t\ttempPos.y = verts[v + 1];\n\t\t\t\t\t\t\t\t\t\ttempUv.x = uvs[u];\n\t\t\t\t\t\t\t\t\t\ttempUv.y = uvs[u + 1];\n\t\t\t\t\t\t\t\t\t\ttempLight.setFromColor(finalColor);\n\t\t\t\t\t\t\t\t\t\ttempDark.set(0, 0, 0, 0);\n\t\t\t\t\t\t\t\t\t\tvertexEffect.transform(tempPos, tempUv, tempLight, tempDark);\n\t\t\t\t\t\t\t\t\t\tverts[v] = tempPos.x;\n\t\t\t\t\t\t\t\t\t\tverts[v + 1] = tempPos.y;\n\t\t\t\t\t\t\t\t\t\tverts[v + 2] = tempLight.r;\n\t\t\t\t\t\t\t\t\t\tverts[v + 3] = tempLight.g;\n\t\t\t\t\t\t\t\t\t\tverts[v + 4] = tempLight.b;\n\t\t\t\t\t\t\t\t\t\tverts[v + 5] = tempLight.a;\n\t\t\t\t\t\t\t\t\t\tverts[v + 6] = tempUv.x;\n\t\t\t\t\t\t\t\t\t\tverts[v + 7] = tempUv.y;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tfor (var v = 0, u = 0, n_6 = renderable.numFloats; v < n_6; v += vertexSize, u += 2) {\n\t\t\t\t\t\t\t\t\t\ttempPos.x = verts[v];\n\t\t\t\t\t\t\t\t\t\ttempPos.y = verts[v + 1];\n\t\t\t\t\t\t\t\t\t\ttempUv.x = uvs[u];\n\t\t\t\t\t\t\t\t\t\ttempUv.y = uvs[u + 1];\n\t\t\t\t\t\t\t\t\t\ttempLight.setFromColor(finalColor);\n\t\t\t\t\t\t\t\t\t\ttempDark.setFromColor(darkColor);\n\t\t\t\t\t\t\t\t\t\tvertexEffect.transform(tempPos, tempUv, tempLight, tempDark);\n\t\t\t\t\t\t\t\t\t\tverts[v] = tempPos.x;\n\t\t\t\t\t\t\t\t\t\tverts[v + 1] = tempPos.y;\n\t\t\t\t\t\t\t\t\t\tverts[v + 2] = tempLight.r;\n\t\t\t\t\t\t\t\t\t\tverts[v + 3] = tempLight.g;\n\t\t\t\t\t\t\t\t\t\tverts[v + 4] = tempLight.b;\n\t\t\t\t\t\t\t\t\t\tverts[v + 5] = tempLight.a;\n\t\t\t\t\t\t\t\t\t\tverts[v + 6] = tempUv.x;\n\t\t\t\t\t\t\t\t\t\tverts[v + 7] = tempUv.y;\n\t\t\t\t\t\t\t\t\t\tverts[v + 8] = tempDark.r;\n\t\t\t\t\t\t\t\t\t\tverts[v + 9] = tempDark.g;\n\t\t\t\t\t\t\t\t\t\tverts[v + 10] = tempDark.b;\n\t\t\t\t\t\t\t\t\t\tverts[v + 11] = tempDark.a;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (!twoColorTint) {\n\t\t\t\t\t\t\t\t\tfor (var v = 2, u = 0, n_7 = renderable.numFloats; v < n_7; v += vertexSize, u += 2) {\n\t\t\t\t\t\t\t\t\t\tverts[v] = finalColor.r;\n\t\t\t\t\t\t\t\t\t\tverts[v + 1] = finalColor.g;\n\t\t\t\t\t\t\t\t\t\tverts[v + 2] = finalColor.b;\n\t\t\t\t\t\t\t\t\t\tverts[v + 3] = finalColor.a;\n\t\t\t\t\t\t\t\t\t\tverts[v + 4] = uvs[u];\n\t\t\t\t\t\t\t\t\t\tverts[v + 5] = uvs[u + 1];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tfor (var v = 2, u = 0, n_8 = renderable.numFloats; v < n_8; v += vertexSize, u += 2) {\n\t\t\t\t\t\t\t\t\t\tverts[v] = finalColor.r;\n\t\t\t\t\t\t\t\t\t\tverts[v + 1] = finalColor.g;\n\t\t\t\t\t\t\t\t\t\tverts[v + 2] = finalColor.b;\n\t\t\t\t\t\t\t\t\t\tverts[v + 3] = finalColor.a;\n\t\t\t\t\t\t\t\t\t\tverts[v + 4] = uvs[u];\n\t\t\t\t\t\t\t\t\t\tverts[v + 5] = uvs[u + 1];\n\t\t\t\t\t\t\t\t\t\tverts[v + 6] = darkColor.r;\n\t\t\t\t\t\t\t\t\t\tverts[v + 7] = darkColor.g;\n\t\t\t\t\t\t\t\t\t\tverts[v + 8] = darkColor.b;\n\t\t\t\t\t\t\t\t\t\tverts[v + 9] = darkColor.a;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvar view = renderable.vertices.subarray(0, renderable.numFloats);\n\t\t\t\t\t\t\tbatcher.draw(texture, view, triangles);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tclipper.clipEndWithSlot(slot);\n\t\t\t\t}\n\t\t\t\tclipper.clipEnd();\n\t\t\t};\n\t\t\tSkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0];\n\t\t\treturn SkeletonRenderer;\n\t\t}());\n\t\twebgl.SkeletonRenderer = SkeletonRenderer;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar Vector3 = (function () {\n\t\t\tfunction Vector3(x, y, z) {\n\t\t\t\tif (x === void 0) { x = 0; }\n\t\t\t\tif (y === void 0) { y = 0; }\n\t\t\t\tif (z === void 0) { z = 0; }\n\t\t\t\tthis.x = 0;\n\t\t\t\tthis.y = 0;\n\t\t\t\tthis.z = 0;\n\t\t\t\tthis.x = x;\n\t\t\t\tthis.y = y;\n\t\t\t\tthis.z = z;\n\t\t\t}\n\t\t\tVector3.prototype.setFrom = function (v) {\n\t\t\t\tthis.x = v.x;\n\t\t\t\tthis.y = v.y;\n\t\t\t\tthis.z = v.z;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tVector3.prototype.set = function (x, y, z) {\n\t\t\t\tthis.x = x;\n\t\t\t\tthis.y = y;\n\t\t\t\tthis.z = z;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tVector3.prototype.add = function (v) {\n\t\t\t\tthis.x += v.x;\n\t\t\t\tthis.y += v.y;\n\t\t\t\tthis.z += v.z;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tVector3.prototype.sub = function (v) {\n\t\t\t\tthis.x -= v.x;\n\t\t\t\tthis.y -= v.y;\n\t\t\t\tthis.z -= v.z;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tVector3.prototype.scale = function (s) {\n\t\t\t\tthis.x *= s;\n\t\t\t\tthis.y *= s;\n\t\t\t\tthis.z *= s;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tVector3.prototype.normalize = function () {\n\t\t\t\tvar len = this.length();\n\t\t\t\tif (len == 0)\n\t\t\t\t\treturn this;\n\t\t\t\tlen = 1 / len;\n\t\t\t\tthis.x *= len;\n\t\t\t\tthis.y *= len;\n\t\t\t\tthis.z *= len;\n\t\t\t\treturn this;\n\t\t\t};\n\t\t\tVector3.prototype.cross = function (v) {\n\t\t\t\treturn this.set(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * v.y - this.y * v.x);\n\t\t\t};\n\t\t\tVector3.prototype.multiply = function (matrix) {\n\t\t\t\tvar l_mat = matrix.values;\n\t\t\t\treturn this.set(this.x * l_mat[webgl.M00] + this.y * l_mat[webgl.M01] + this.z * l_mat[webgl.M02] + l_mat[webgl.M03], this.x * l_mat[webgl.M10] + this.y * l_mat[webgl.M11] + this.z * l_mat[webgl.M12] + l_mat[webgl.M13], this.x * l_mat[webgl.M20] + this.y * l_mat[webgl.M21] + this.z * l_mat[webgl.M22] + l_mat[webgl.M23]);\n\t\t\t};\n\t\t\tVector3.prototype.project = function (matrix) {\n\t\t\t\tvar l_mat = matrix.values;\n\t\t\t\tvar l_w = 1 / (this.x * l_mat[webgl.M30] + this.y * l_mat[webgl.M31] + this.z * l_mat[webgl.M32] + l_mat[webgl.M33]);\n\t\t\t\treturn this.set((this.x * l_mat[webgl.M00] + this.y * l_mat[webgl.M01] + this.z * l_mat[webgl.M02] + l_mat[webgl.M03]) * l_w, (this.x * l_mat[webgl.M10] + this.y * l_mat[webgl.M11] + this.z * l_mat[webgl.M12] + l_mat[webgl.M13]) * l_w, (this.x * l_mat[webgl.M20] + this.y * l_mat[webgl.M21] + this.z * l_mat[webgl.M22] + l_mat[webgl.M23]) * l_w);\n\t\t\t};\n\t\t\tVector3.prototype.dot = function (v) {\n\t\t\t\treturn this.x * v.x + this.y * v.y + this.z * v.z;\n\t\t\t};\n\t\t\tVector3.prototype.length = function () {\n\t\t\t\treturn Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);\n\t\t\t};\n\t\t\tVector3.prototype.distance = function (v) {\n\t\t\t\tvar a = v.x - this.x;\n\t\t\t\tvar b = v.y - this.y;\n\t\t\t\tvar c = v.z - this.z;\n\t\t\t\treturn Math.sqrt(a * a + b * b + c * c);\n\t\t\t};\n\t\t\treturn Vector3;\n\t\t}());\n\t\twebgl.Vector3 = Vector3;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\nvar spine;\n(function (spine) {\n\tvar webgl;\n\t(function (webgl) {\n\t\tvar ManagedWebGLRenderingContext = (function () {\n\t\t\tfunction ManagedWebGLRenderingContext(canvasOrContext, contextConfig) {\n\t\t\t\tif (contextConfig === void 0) { contextConfig = { alpha: \"true\" }; }\n\t\t\t\tvar _this = this;\n\t\t\t\tthis.restorables = new Array();\n\t\t\t\tif (canvasOrContext instanceof HTMLCanvasElement) {\n\t\t\t\t\tvar canvas = canvasOrContext;\n\t\t\t\t\tthis.gl = (canvas.getContext(\"webgl\", contextConfig) || canvas.getContext(\"experimental-webgl\", contextConfig));\n\t\t\t\t\tthis.canvas = canvas;\n\t\t\t\t\tcanvas.addEventListener(\"webglcontextlost\", function (e) {\n\t\t\t\t\t\tvar event = e;\n\t\t\t\t\t\tif (e) {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tcanvas.addEventListener(\"webglcontextrestored\", function (e) {\n\t\t\t\t\t\tfor (var i = 0, n = _this.restorables.length; i < n; i++) {\n\t\t\t\t\t\t\t_this.restorables[i].restore();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.gl = canvasOrContext;\n\t\t\t\t\tthis.canvas = this.gl.canvas;\n\t\t\t\t}\n\t\t\t}\n\t\t\tManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) {\n\t\t\t\tthis.restorables.push(restorable);\n\t\t\t};\n\t\t\tManagedWebGLRenderingContext.prototype.removeRestorable = function (restorable) {\n\t\t\t\tvar index = this.restorables.indexOf(restorable);\n\t\t\t\tif (index > -1)\n\t\t\t\t\tthis.restorables.splice(index, 1);\n\t\t\t};\n\t\t\treturn ManagedWebGLRenderingContext;\n\t\t}());\n\t\twebgl.ManagedWebGLRenderingContext = ManagedWebGLRenderingContext;\n\t\tvar WebGLBlendModeConverter = (function () {\n\t\t\tfunction WebGLBlendModeConverter() {\n\t\t\t}\n\t\t\tWebGLBlendModeConverter.getDestGLBlendMode = function (blendMode) {\n\t\t\t\tswitch (blendMode) {\n\t\t\t\t\tcase spine.BlendMode.Normal: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;\n\t\t\t\t\tcase spine.BlendMode.Additive: return WebGLBlendModeConverter.ONE;\n\t\t\t\t\tcase spine.BlendMode.Multiply: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;\n\t\t\t\t\tcase spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA;\n\t\t\t\t\tdefault: throw new Error(\"Unknown blend mode: \" + blendMode);\n\t\t\t\t}\n\t\t\t};\n\t\t\tWebGLBlendModeConverter.getSourceGLBlendMode = function (blendMode, premultipliedAlpha) {\n\t\t\t\tif (premultipliedAlpha === void 0) { premultipliedAlpha = false; }\n\t\t\t\tswitch (blendMode) {\n\t\t\t\t\tcase spine.BlendMode.Normal: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA;\n\t\t\t\t\tcase spine.BlendMode.Additive: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA;\n\t\t\t\t\tcase spine.BlendMode.Multiply: return WebGLBlendModeConverter.DST_COLOR;\n\t\t\t\t\tcase spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE;\n\t\t\t\t\tdefault: throw new Error(\"Unknown blend mode: \" + blendMode);\n\t\t\t\t}\n\t\t\t};\n\t\t\tWebGLBlendModeConverter.ZERO = 0;\n\t\t\tWebGLBlendModeConverter.ONE = 1;\n\t\t\tWebGLBlendModeConverter.SRC_COLOR = 0x0300;\n\t\t\tWebGLBlendModeConverter.ONE_MINUS_SRC_COLOR = 0x0301;\n\t\t\tWebGLBlendModeConverter.SRC_ALPHA = 0x0302;\n\t\t\tWebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA = 0x0303;\n\t\t\tWebGLBlendModeConverter.DST_ALPHA = 0x0304;\n\t\t\tWebGLBlendModeConverter.ONE_MINUS_DST_ALPHA = 0x0305;\n\t\t\tWebGLBlendModeConverter.DST_COLOR = 0x0306;\n\t\t\treturn WebGLBlendModeConverter;\n\t\t}());\n\t\twebgl.WebGLBlendModeConverter = WebGLBlendModeConverter;\n\t})(webgl = spine.webgl || (spine.webgl = {}));\n})(spine || (spine = {}));\n//# sourceMappingURL=spine-webgl.js.map\n\n/*** EXPORTS FROM exports-loader ***/\nmodule.exports = spine;\n}.call(window));"],"sourceRoot":""} \ No newline at end of file diff --git a/plugins/spine/src/BaseSpinePlugin.js b/plugins/spine/src/BaseSpinePlugin.js new file mode 100644 index 000000000..2b4c5b7ad --- /dev/null +++ b/plugins/spine/src/BaseSpinePlugin.js @@ -0,0 +1,190 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../src/utils/Class'); +var ScenePlugin = require('../../../src/plugins/ScenePlugin'); +var SpineFile = require('./SpineFile'); +var SpineGameObject = require('./gameobject/SpineGameObject'); + +var runtime; + +/** + * @classdesc + * TODO + * + * @class SpinePlugin + * @extends Phaser.Plugins.ScenePlugin + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var SpinePlugin = new Class({ + + Extends: ScenePlugin, + + initialize: + + function SpinePlugin (scene, pluginManager, SpineRuntime) + { + console.log('BaseSpinePlugin created'); + + ScenePlugin.call(this, scene, pluginManager); + + var game = pluginManager.game; + + // Create a custom cache to store the spine data (.atlas files) + this.cache = game.cache.addCustom('spine'); + + this.json = game.cache.json; + + this.textures = game.textures; + + this.skeletonRenderer; + + this.drawDebug = false; + + // Register our file type + pluginManager.registerFileType('spine', this.spineFileCallback, scene); + + // Register our game object + pluginManager.registerGameObject('spine', this.createSpineFactory(this)); + + runtime = SpineRuntime; + }, + + spineFileCallback: function (key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings) + { + var multifile; + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new SpineFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new SpineFile(this, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; + }, + + /** + * Creates a new Spine Game Object and adds it to the Scene. + * + * @method Phaser.GameObjects.GameObjectFactory#spineFactory + * @since 3.16.0 + * + * @param {number} x - The horizontal position of this Game Object. + * @param {number} y - The vertical position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Spine} The Game Object that was created. + */ + createSpineFactory: function (plugin) + { + var callback = function (x, y, key, animationName, loop) + { + var spineGO = new SpineGameObject(this.scene, plugin, x, y, key, animationName, loop); + + this.displayList.add(spineGO); + this.updateList.add(spineGO); + + return spineGO; + }; + + return callback; + }, + + getRuntime: function () + { + return runtime; + }, + + createSkeleton: function (key, skeletonJSON) + { + var atlas = this.getAtlas(key); + + var atlasLoader = new runtime.AtlasAttachmentLoader(atlas); + + var skeletonJson = new runtime.SkeletonJson(atlasLoader); + + var data = (skeletonJSON) ? skeletonJSON : this.json.get(key); + + var skeletonData = skeletonJson.readSkeletonData(data); + + var skeleton = new runtime.Skeleton(skeletonData); + + return { skeletonData: skeletonData, skeleton: skeleton }; + }, + + getBounds: function (skeleton) + { + var offset = new runtime.Vector2(); + var size = new runtime.Vector2(); + + skeleton.getBounds(offset, size, []); + + return { offset: offset, size: size }; + }, + + createAnimationState: function (skeleton) + { + var stateData = new runtime.AnimationStateData(skeleton.data); + + var state = new runtime.AnimationState(stateData); + + return { stateData: stateData, state: state }; + }, + + /** + * 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 Camera3DPlugin#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(); + }, + + /** + * The Scene that owns this plugin is being destroyed. + * We need to shutdown and then kill off all external references. + * + * @method Camera3DPlugin#destroy + * @private + * @since 3.0.0 + */ + destroy: function () + { + this.shutdown(); + + this.pluginManager = null; + this.game = null; + this.scene = null; + this.systems = null; + } + +}); + +module.exports = SpinePlugin; diff --git a/plugins/spine/src/SpineCanvasPlugin.js b/plugins/spine/src/SpineCanvasPlugin.js new file mode 100644 index 000000000..ef74e00e7 --- /dev/null +++ b/plugins/spine/src/SpineCanvasPlugin.js @@ -0,0 +1,63 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../src/utils/Class'); +var BaseSpinePlugin = require('./BaseSpinePlugin'); +var SpineCanvas = require('SpineCanvas'); + +/** + * @classdesc + * Just the Canvas Runtime. + * + * @class SpinePlugin + * @extends Phaser.Plugins.ScenePlugin + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var SpineCanvasPlugin = new Class({ + + Extends: BaseSpinePlugin, + + initialize: + + function SpineCanvasPlugin (scene, pluginManager) + { + console.log('SpineCanvasPlugin created'); + + BaseSpinePlugin.call(this, scene, pluginManager, SpineCanvas); + }, + + boot: function () + { + this.skeletonRenderer = new SpineCanvas.canvas.SkeletonRenderer(this.game.context); + }, + + getAtlas: function (key) + { + var atlasData = this.cache.get(key); + + if (!atlasData) + { + console.warn('No atlas data for: ' + key); + return; + } + + var textures = this.textures; + + var atlas = new SpineCanvas.TextureAtlas(atlasData, function (path) + { + return new SpineCanvas.canvas.CanvasTexture(textures.get(path).getSourceImage()); + }); + + return atlas; + } + +}); + +module.exports = SpineCanvasPlugin; diff --git a/plugins/spine/src/SpineFile.js b/plugins/spine/src/SpineFile.js new file mode 100644 index 000000000..e3924a877 --- /dev/null +++ b/plugins/spine/src/SpineFile.js @@ -0,0 +1,325 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../src/utils/Class'); +var GetFastValue = require('../../../src/utils/object/GetFastValue'); +var ImageFile = require('../../../src/loader/filetypes/ImageFile.js'); +var IsPlainObject = require('../../../src/utils/object/IsPlainObject'); +var JSONFile = require('../../../src/loader/filetypes/JSONFile.js'); +var MultiFile = require('../../../src/loader/MultiFile.js'); +var TextFile = require('../../../src/loader/filetypes/TextFile.js'); + +/** + * @typedef {object} Phaser.Loader.FileTypes.SpineFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [textureURL] - The absolute or relative URL to load the texture image file from. + * @property {string} [textureExtension='png'] - The default file extension to use for the image texture if no url is provided. + * @property {XHRSettingsObject} [textureXhrSettings] - Extra XHR Settings specifically for the texture image file. + * @property {string} [normalMap] - The filename of an associated normal map. It uses the same path and url to load as the texture image. + * @property {string} [atlasURL] - The absolute or relative URL to load the atlas data file from. + * @property {string} [atlasExtension='txt'] - The default file extension to use for the atlas data if no url is provided. + * @property {XHRSettingsObject} [atlasXhrSettings] - Extra XHR Settings specifically for the atlas data file. + */ + +/** + * @classdesc + * A Spine File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#spine method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#spine. + * + * @class SpineFile + * @extends Phaser.Loader.MultiFile + * @memberof Phaser.Loader.FileTypes + * @constructor + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.UnityAtlasFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + */ +var SpineFile = new Class({ + + Extends: MultiFile, + + initialize: + + function SpineFile (loader, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings) + { + var json; + var atlas; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + + json = new JSONFile(loader, { + key: key, + url: GetFastValue(config, 'jsonURL'), + extension: GetFastValue(config, 'jsonExtension', 'json'), + xhrSettings: GetFastValue(config, 'jsonXhrSettings') + }); + + atlas = new TextFile(loader, { + key: key, + url: GetFastValue(config, 'atlasURL'), + extension: GetFastValue(config, 'atlasExtension', 'atlas'), + xhrSettings: GetFastValue(config, 'atlasXhrSettings') + }); + } + else + { + json = new JSONFile(loader, key, jsonURL, jsonXhrSettings); + atlas = new TextFile(loader, key, atlasURL, atlasXhrSettings); + } + + atlas.cache = loader.cacheManager.custom.spine; + + MultiFile.call(this, loader, 'spine', key, [ json, atlas ]); + }, + + /** + * Called by each File when it finishes loading. + * + * @method Phaser.Loader.MultiFile#onFileComplete + * @since 3.7.0 + * + * @param {Phaser.Loader.File} file - The File that has completed processing. + */ + onFileComplete: function (file) + { + var index = this.files.indexOf(file); + + if (index !== -1) + { + this.pending--; + + if (file.type === 'text') + { + // Inspect the data for the files to now load + var content = file.data.split('\n'); + + // Extract the textures + var textures = []; + + for (var t = 0; t < content.length; t++) + { + var line = content[t]; + + if (line.trim() === '' && t < content.length - 1) + { + line = content[t + 1]; + + textures.push(line); + } + } + + var config = this.config; + var loader = this.loader; + + var currentBaseURL = loader.baseURL; + var currentPath = loader.path; + var currentPrefix = loader.prefix; + + var baseURL = GetFastValue(config, 'baseURL', currentBaseURL); + var path = GetFastValue(config, 'path', currentPath); + var prefix = GetFastValue(config, 'prefix', currentPrefix); + var textureXhrSettings = GetFastValue(config, 'textureXhrSettings'); + + loader.setBaseURL(baseURL); + loader.setPath(path); + loader.setPrefix(prefix); + + for (var i = 0; i < textures.length; i++) + { + var textureURL = textures[i]; + + var key = '_SP_' + textureURL; + + var image = new ImageFile(loader, key, textureURL, textureXhrSettings); + + this.addToMultiFile(image); + + loader.addFile(image); + } + + // Reset the loader settings + loader.setBaseURL(currentBaseURL); + loader.setPath(currentPath); + loader.setPrefix(currentPrefix); + } + } + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.SpineFile#addToCache + * @since 3.16.0 + */ + addToCache: function () + { + if (this.isReadyToProcess()) + { + var fileJSON = this.files[0]; + + fileJSON.addToCache(); + + var fileText = this.files[1]; + + fileText.addToCache(); + + for (var i = 2; i < this.files.length; i++) + { + var file = this.files[i]; + + var key = file.key.substr(4).trim(); + + this.loader.textureManager.addImage(key, file.data); + + file.pendingDestroy(); + } + + this.complete = true; + } + } + +}); + +/** + * Adds a Unity YAML based Texture Atlas, or array of atlases, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.txt'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * If you call this from outside of `preload` then you are responsible for starting the Loader afterwards and monitoring + * its events to know when it's safe to use the asset. Please see the Phaser.Loader.LoaderPlugin class for more details. + * + * Phaser expects the atlas data to be provided in a YAML formatted text file as exported from Unity. + * + * Phaser can load all common image types: png, jpg, gif and any other format the browser can natively handle. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SpineFileConfig` for more details. + * + * Once the atlas has finished loading you can use frames from it as textures for a Game Object by referencing its key: + * + * ```javascript + * this.load.unityAtlas('mainmenu', 'images/MainMenu.png', 'images/MainMenu.json'); + * // and later in your game ... + * this.add.image(x, y, 'mainmenu', 'background'); + * ``` + * + * To get a list of all available frames within an atlas please consult your Texture Atlas software. + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.png". It will always add `.png` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Phaser also supports the automatic loading of associated normal maps. If you have a normal map to go with this image, + * then you can specify it by providing an array as the `url` where the second element is the normal map: + * + * ```javascript + * this.load.unityAtlas('mainmenu', [ 'images/MainMenu.png', 'images/MainMenu-n.png' ], 'images/MainMenu.txt'); + * ``` + * + * Or, if you are using a config object use the `normalMap` property: + * + * ```javascript + * this.load.unityAtlas({ + * key: 'mainmenu', + * textureURL: 'images/MainMenu.png', + * normalMap: 'images/MainMenu-n.png', + * atlasURL: 'images/MainMenu.txt' + * }); + * ``` + * + * The normal map file is subject to the same conditions as the image file with regard to the path, baseURL, CORs and XHR Settings. + * Normal maps are a WebGL only feature. + * + * Note: The ability to load this type of file will only be available if the Unity Atlas File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#spine + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.16.0 + * + * @param {(string|Phaser.Loader.FileTypes.SpineFileConfig|Phaser.Loader.FileTypes.SpineFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string|string[]} [textureURL] - The absolute or relative URL to load the texture image file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {string} [atlasURL] - The absolute or relative URL to load the texture atlas data file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.txt". + * @param {XHRSettingsObject} [textureXhrSettings] - An XHR Settings configuration object for the atlas image file. Used in replacement of the Loaders default XHR Settings. + * @param {XHRSettingsObject} [atlasXhrSettings] - An XHR Settings configuration object for the atlas data file. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. +FileTypesManager.register('spine', function (key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings) +{ + var multifile; + + // Supports an Object file definition in the key argument + // Or an array of objects in the key argument + // Or a single entry where all arguments have been defined + + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + multifile = new SpineFile(this, key[i]); + + this.addFile(multifile.files); + } + } + else + { + multifile = new SpineFile(this, key, jsonURL, atlasURL, jsonXhrSettings, atlasXhrSettings); + + this.addFile(multifile.files); + } + + return this; +}); + */ + +module.exports = SpineFile; diff --git a/plugins/spine/src/SpinePlugin.js b/plugins/spine/src/SpinePlugin.js new file mode 100644 index 000000000..cf63049ad --- /dev/null +++ b/plugins/spine/src/SpinePlugin.js @@ -0,0 +1,111 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../src/utils/Class'); +var BaseSpinePlugin = require('./BaseSpinePlugin'); +var SpineCanvas = require('SpineCanvas'); +var SpineWebGL = require('SpineWebGL'); + +var runtime; + +/** + * @classdesc + * Both Canvas and WebGL Runtimes together in a single plugin. + * + * @class SpinePlugin + * @extends Phaser.Plugins.ScenePlugin + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var SpineCanvasPlugin = new Class({ + + Extends: BaseSpinePlugin, + + initialize: + + function SpineCanvasPlugin (scene, pluginManager) + { + console.log('SpinePlugin created'); + + BaseSpinePlugin.call(this, scene, pluginManager); + + var game = pluginManager.game; + + runtime = (game.config.renderType === 1) ? SpineCanvas : SpineWebGL; + }, + + boot: function () + { + this.skeletonRenderer = (this.game.config.renderType === 1) ? SpineCanvas.canvas.SkeletonRenderer(this.game.context) : SpineWebGL; + }, + + getRuntime: function () + { + return runtime; + }, + + createSkeleton: function (key) + { + var atlasData = this.cache.get(key); + + if (!atlasData) + { + console.warn('No skeleton data for: ' + key); + return; + } + + var textures = this.textures; + + var useWebGL = this.game.config.renderType; + + var atlas = new runtime.TextureAtlas(atlasData, function (path) + { + if (useWebGL) + { + // return new SpineCanvas.canvas.CanvasTexture(textures.get(path).getSourceImage()); + } + else + { + return new SpineCanvas.canvas.CanvasTexture(textures.get(path).getSourceImage()); + } + }); + + var atlasLoader = new runtime.AtlasAttachmentLoader(atlas); + + var skeletonJson = new runtime.SkeletonJson(atlasLoader); + + var skeletonData = skeletonJson.readSkeletonData(this.json.get(key)); + + var skeleton = new runtime.Skeleton(skeletonData); + + return { skeletonData: skeletonData, skeleton: skeleton }; + }, + + getBounds: function (skeleton) + { + var offset = new runtime.Vector2(); + var size = new runtime.Vector2(); + + skeleton.getBounds(offset, size, []); + + return { offset: offset, size: size }; + }, + + createAnimationState: function (skeleton) + { + var stateData = new runtime.AnimationStateData(skeleton.data); + + var state = new runtime.AnimationState(stateData); + + return { stateData: stateData, state: state }; + } + +}); + +module.exports = SpineCanvasPlugin; diff --git a/plugins/spine/src/SpineWebGLPlugin.js b/plugins/spine/src/SpineWebGLPlugin.js new file mode 100644 index 000000000..0eeb810b5 --- /dev/null +++ b/plugins/spine/src/SpineWebGLPlugin.js @@ -0,0 +1,90 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../src/utils/Class'); +var BaseSpinePlugin = require('./BaseSpinePlugin'); +var SpineWebGL = require('SpineWebGL'); +var Matrix4 = require('../../../src/math/Matrix4'); + +/** + * @classdesc + * Just the WebGL Runtime. + * + * @class SpinePlugin + * @extends Phaser.Plugins.ScenePlugin + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var SpineWebGLPlugin = new Class({ + + Extends: BaseSpinePlugin, + + initialize: + + function SpineWebGLPlugin (scene, pluginManager) + { + console.log('SpineWebGLPlugin created'); + + BaseSpinePlugin.call(this, scene, pluginManager, SpineWebGL); + + this.gl; + this.mvp; + this.shader; + this.batcher; + this.debugRenderer; + this.debugShader; + }, + + boot: function () + { + var gl = this.game.renderer.gl; + + this.gl = gl; + + this.mvp = new Matrix4(); + + // Create a simple shader, mesh, model-view-projection matrix and SkeletonRenderer. + this.shader = SpineWebGL.webgl.Shader.newTwoColoredTextured(gl); + this.batcher = new SpineWebGL.webgl.PolygonBatcher(gl); + + this.skeletonRenderer = new SpineWebGL.webgl.SkeletonRenderer(gl); + this.skeletonRenderer.premultipliedAlpha = true; + + this.shapes = new SpineWebGL.webgl.ShapeRenderer(gl); + + this.debugRenderer = new SpineWebGL.webgl.SkeletonDebugRenderer(gl); + + this.debugShader = SpineWebGL.webgl.Shader.newColored(gl); + }, + + getAtlas: function (key) + { + var atlasData = this.cache.get(key); + + if (!atlasData) + { + console.warn('No atlas data for: ' + key); + return; + } + + var textures = this.textures; + + var gl = this.game.renderer.gl; + + var atlas = new SpineWebGL.TextureAtlas(atlasData, function (path) + { + return new SpineWebGL.webgl.GLTexture(gl, textures.get(path).getSourceImage()); + }); + + return atlas; + } + +}); + +module.exports = SpineWebGLPlugin; diff --git a/plugins/spine/src/gameobject/SpineGameObject.js b/plugins/spine/src/gameobject/SpineGameObject.js new file mode 100644 index 000000000..1372820b7 --- /dev/null +++ b/plugins/spine/src/gameobject/SpineGameObject.js @@ -0,0 +1,298 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../../src/utils/Class'); +var ComponentsAlpha = require('../../../../src/gameobjects/components/Alpha'); +var ComponentsBlendMode = require('../../../../src/gameobjects/components/BlendMode'); +var ComponentsDepth = require('../../../../src/gameobjects/components/Depth'); +var ComponentsFlip = require('../../../../src/gameobjects/components/Flip'); +var ComponentsScrollFactor = require('../../../../src/gameobjects/components/ScrollFactor'); +var ComponentsTransform = require('../../../../src/gameobjects/components/Transform'); +var ComponentsVisible = require('../../../../src/gameobjects/components/Visible'); +var GameObject = require('../../../../src/gameobjects/GameObject'); +var SpineGameObjectRender = require('./SpineGameObjectRender'); + +/** + * @classdesc + * TODO + * + * @class SpineGameObject + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Scene} scene - A reference to the Scene that has installed this plugin. + * @param {Phaser.Plugins.PluginManager} pluginManager - A reference to the Phaser Plugin Manager. + */ +var SpineGameObject = new Class({ + + Extends: GameObject, + + Mixins: [ + ComponentsAlpha, + ComponentsBlendMode, + ComponentsDepth, + ComponentsFlip, + ComponentsScrollFactor, + ComponentsTransform, + ComponentsVisible, + SpineGameObjectRender + ], + + initialize: + + function SpineGameObject (scene, plugin, x, y, key, animationName, loop) + { + GameObject.call(this, scene, 'Spine'); + + this.plugin = plugin; + + this.runtime = plugin.getRuntime(); + + this.skeleton = null; + this.skeletonData = null; + + this.state = null; + this.stateData = null; + + this.drawDebug = false; + + this.timeScale = 1; + + this.setPosition(x, y); + + if (key) + { + this.setSkeleton(key, animationName, loop); + } + }, + + setSkeletonFromJSON: function (atlasDataKey, skeletonJSON, animationName, loop) + { + return this.setSkeleton(atlasDataKey, skeletonJSON, animationName, loop); + }, + + setSkeleton: function (atlasDataKey, animationName, loop, skeletonJSON) + { + var data = this.plugin.createSkeleton(atlasDataKey, skeletonJSON); + + this.skeletonData = data.skeletonData; + + var skeleton = data.skeleton; + + skeleton.flipY = (this.scene.sys.game.config.renderType === 1); + + skeleton.setToSetupPose(); + + skeleton.updateWorldTransform(); + + skeleton.setSkinByName('default'); + + this.skeleton = skeleton; + + // AnimationState + data = this.plugin.createAnimationState(skeleton); + + if (this.state) + { + this.state.clearListeners(); + this.state.clearListenerNotifications(); + } + + this.state = data.state; + + this.stateData = data.stateData; + + var _this = this; + + this.state.addListener({ + event: function (trackIndex, event) + { + // Event on a Track + _this.emit('spine.event', _this, trackIndex, event); + }, + complete: function (trackIndex, loopCount) + { + // Animation on Track x completed, loop count + _this.emit('spine.complete', _this, trackIndex, loopCount); + }, + start: function (trackIndex) + { + // Animation on Track x started + _this.emit('spine.start', _this, trackIndex); + }, + end: function (trackIndex) + { + // Animation on Track x ended + _this.emit('spine.end', _this, trackIndex); + } + }); + + if (animationName) + { + this.setAnimation(0, animationName, loop); + } + + return this; + }, + + // http://esotericsoftware.com/spine-runtimes-guide + + getAnimationList: function () + { + var output = []; + + var skeletonData = this.skeletonData; + + if (skeletonData) + { + for (var i = 0; i < skeletonData.animations.length; i++) + { + output.push(skeletonData.animations[i].name); + } + } + + return output; + }, + + play: function (animationName, loop) + { + if (loop === undefined) + { + loop = false; + } + + return this.setAnimation(0, animationName, loop); + }, + + setAnimation: function (trackIndex, animationName, loop) + { + this.state.setAnimation(trackIndex, animationName, loop); + + return this; + }, + + addAnimation: function (trackIndex, animationName, loop, delay) + { + return this.state.addAnimation(trackIndex, animationName, loop, delay); + }, + + setEmptyAnimation: function (trackIndex, mixDuration) + { + this.state.setEmptyAnimation(trackIndex, mixDuration); + + return this; + }, + + clearTrack: function (trackIndex) + { + this.state.clearTrack(trackIndex); + + return this; + }, + + clearTracks: function () + { + this.state.clearTracks(); + + return this; + }, + + setSkinByName: function (skinName) + { + this.skeleton.setSkinByName(skinName); + + return this; + }, + + setSkin: function (newSkin) + { + var skeleton = this.skeleton; + + skeleton.setSkin(newSkin); + + skeleton.setSlotsToSetupPose(); + + this.state.apply(skeleton); + + return this; + }, + + setMix: function (fromName, toName, duration) + { + this.stateData.setMix(fromName, toName, duration); + + return this; + }, + + findBone: function (boneName) + { + return this.skeleton.findBone(boneName); + }, + + findBoneIndex: function (boneName) + { + return this.skeleton.findBoneIndex(boneName); + }, + + findSlot: function (slotName) + { + return this.skeleton.findSlot(slotName); + }, + + findSlotIndex: function (slotName) + { + return this.skeleton.findSlotIndex(slotName); + }, + + getBounds: function () + { + return this.plugin.getBounds(this.skeleton); + }, + + preUpdate: function (time, delta) + { + var skeleton = this.skeleton; + + skeleton.flipX = this.flipX; + skeleton.flipY = this.flipY; + + this.state.update((delta / 1000) * this.timeScale); + + this.state.apply(skeleton); + + this.emit('spine.update', skeleton); + + skeleton.updateWorldTransform(); + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.RenderTexture#preDestroy + * @protected + * @since 3.16.0 + */ + preDestroy: function () + { + if (this.state) + { + this.state.clearListeners(); + this.state.clearListenerNotifications(); + } + + this.plugin = null; + this.runtime = null; + + this.skeleton = null; + this.skeletonData = null; + + this.state = null; + this.stateData = null; + } + +}); + +module.exports = SpineGameObject; diff --git a/plugins/spine/src/gameobject/SpineGameObjectCanvasRenderer.js b/plugins/spine/src/gameobject/SpineGameObjectCanvasRenderer.js new file mode 100644 index 000000000..bb7baa308 --- /dev/null +++ b/plugins/spine/src/gameobject/SpineGameObjectCanvasRenderer.js @@ -0,0 +1,57 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SetTransform = require('../../../../src/renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.SpineGameObject#renderCanvas + * @since 3.16.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.SpineGameObject} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpineGameObjectCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var context = renderer.currentContext; + + var plugin = src.plugin; + var skeleton = src.skeleton; + var skeletonRenderer = plugin.skeletonRenderer; + + if (!skeleton || !SetTransform(renderer, context, src, camera, parentMatrix)) + { + return; + } + + skeletonRenderer.ctx = context; + + context.save(); + + skeletonRenderer.draw(skeleton); + + if (plugin.drawDebug || src.drawDebug) + { + context.strokeStyle = '#00ff00'; + context.beginPath(); + context.moveTo(-1000, 0); + context.lineTo(1000, 0); + context.moveTo(0, -1000); + context.lineTo(0, 1000); + context.stroke(); + } + + context.restore(); +}; + +module.exports = SpineGameObjectCanvasRenderer; diff --git a/plugins/spine/src/gameobject/SpineGameObjectFactory.js b/plugins/spine/src/gameobject/SpineGameObjectFactory.js new file mode 100644 index 000000000..36a454548 --- /dev/null +++ b/plugins/spine/src/gameobject/SpineGameObjectFactory.js @@ -0,0 +1,33 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var SpineGameObject = require('./SpineGameObject'); +var GameObjectFactory = require('../../../../src/gameobjects/GameObjectFactory'); + +/** + * Creates a new Spine Game Object Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Spine Plugin has been built or loaded into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#spine + * @since 3.16.0 + * + * @param {number} x - The horizontal position of this Game Object. + * @param {number} y - The vertical position of this Game Object. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.SpineGameObject} The Game Object that was created. + */ +GameObjectFactory.register('spine', function (x, y, key, animation) +{ + var spine = new SpineGameObject(this.scene, x, y, key, animation); + + this.displayList.add(spine); + this.updateList.add(spine); + + return spine; +}); diff --git a/plugins/spine/src/gameobject/SpineGameObjectRender.js b/plugins/spine/src/gameobject/SpineGameObjectRender.js new file mode 100644 index 000000000..d355e60cb --- /dev/null +++ b/plugins/spine/src/gameobject/SpineGameObjectRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../../src/utils/NOOP'); +var renderCanvas = require('../../../../src/utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./SpineGameObjectWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./SpineGameObjectCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/plugins/spine/src/gameobject/SpineGameObjectWebGLRenderer.js b/plugins/spine/src/gameobject/SpineGameObjectWebGLRenderer.js new file mode 100644 index 000000000..7bda2613f --- /dev/null +++ b/plugins/spine/src/gameobject/SpineGameObjectWebGLRenderer.js @@ -0,0 +1,121 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CounterClockwise = require('../../../../src/math/angle/CounterClockwise'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.SpineGameObject#renderCanvas + * @since 3.16.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.SpineGameObject} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var SpineGameObjectWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = renderer.currentPipeline; + var plugin = src.plugin; + var mvp = plugin.mvp; + + var shader = plugin.shader; + var batcher = plugin.batcher; + var runtime = src.runtime; + var skeleton = src.skeleton; + var skeletonRenderer = plugin.skeletonRenderer; + + if (!skeleton) + { + return; + } + + renderer.clearPipeline(); + + var camMatrix = renderer._tempMatrix1; + var spriteMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + // - 90 degrees to account for the difference in Spine vs. Phaser rotation + spriteMatrix.applyITRS(src.x, src.y, src.rotation - 1.5707963267948966, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var width = renderer.width; + var height = renderer.height; + + var data = calcMatrix.decomposeMatrix(); + + mvp.ortho(0, width, 0, height, 0, 1); + mvp.translateXYZ(data.translateX, height - data.translateY, 0); + mvp.rotateZ(CounterClockwise(data.rotation)); + mvp.scaleXYZ(data.scaleX, data.scaleY, 1); + + // For a Stage 1 release we'll handle it like this: + shader.bind(); + shader.setUniformi(runtime.webgl.Shader.SAMPLER, 0); + shader.setUniform4x4f(runtime.webgl.Shader.MVP_MATRIX, mvp.val); + + // For Stage 2, we'll move to using a custom pipeline, so Spine objects are batched + + batcher.begin(shader); + + skeletonRenderer.premultipliedAlpha = true; + + skeletonRenderer.draw(batcher, skeleton); + + batcher.end(); + + shader.unbind(); + + if (plugin.drawDebug || src.drawDebug) + { + var debugShader = plugin.debugShader; + var debugRenderer = plugin.debugRenderer; + var shapes = plugin.shapes; + + debugShader.bind(); + debugShader.setUniform4x4f(runtime.webgl.Shader.MVP_MATRIX, mvp.val); + + shapes.begin(debugShader); + + debugRenderer.draw(shapes, skeleton); + + shapes.end(); + + debugShader.unbind(); + } + + renderer.rebindPipeline(pipeline); +}; + +module.exports = SpineGameObjectWebGLRenderer; diff --git a/plugins/spine/src/runtimes/LICENSE b/plugins/spine/src/runtimes/LICENSE new file mode 100644 index 000000000..daceab94a --- /dev/null +++ b/plugins/spine/src/runtimes/LICENSE @@ -0,0 +1,27 @@ +Spine Runtimes Software License v2.5 + +Copyright (c) 2013-2016, Esoteric Software +All rights reserved. + +You are granted a perpetual, non-exclusive, non-sublicensable, and +non-transferable license to use, install, execute, and perform the Spine +Runtimes software and derivative works solely for personal or internal +use. Without the written permission of Esoteric Software (see Section 2 of +the Spine Software License Agreement), you may not (a) modify, translate, +adapt, or develop new applications using the Spine Runtimes or otherwise +create derivative works or improvements of the Spine Runtimes or (b) remove, +delete, alter, or obscure any trademarks or any copyright, trademark, patent, +or other intellectual property or proprietary rights notices on or in the +Software, including any copy thereof. Redistributions in binary or source +form must include this license and terms. + +THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF +USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/plugins/spine/src/runtimes/spine-canvas.js b/plugins/spine/src/runtimes/spine-canvas.js new file mode 100644 index 000000000..1dc5765cc --- /dev/null +++ b/plugins/spine/src/runtimes/spine-canvas.js @@ -0,0 +1,6860 @@ +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var spine; +(function (spine) { + var Animation = (function () { + function Animation(name, timelines, duration) { + if (name == null) + throw new Error("name cannot be null."); + if (timelines == null) + throw new Error("timelines cannot be null."); + this.name = name; + this.timelines = timelines; + this.duration = duration; + } + Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) { + if (skeleton == null) + throw new Error("skeleton cannot be null."); + if (loop && this.duration != 0) { + time %= this.duration; + if (lastTime > 0) + lastTime %= this.duration; + } + var timelines = this.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction); + }; + Animation.binarySearch = function (values, target, step) { + if (step === void 0) { step = 1; } + var low = 0; + var high = values.length / step - 2; + if (high == 0) + return step; + var current = high >>> 1; + while (true) { + if (values[(current + 1) * step] <= target) + low = current + 1; + else + high = current; + if (low == high) + return (low + 1) * step; + current = (low + high) >>> 1; + } + }; + Animation.linearSearch = function (values, target, step) { + for (var i = 0, last = values.length - step; i <= last; i += step) + if (values[i] > target) + return i; + return -1; + }; + return Animation; + }()); + spine.Animation = Animation; + var MixPose; + (function (MixPose) { + MixPose[MixPose["setup"] = 0] = "setup"; + MixPose[MixPose["current"] = 1] = "current"; + MixPose[MixPose["currentLayered"] = 2] = "currentLayered"; + })(MixPose = spine.MixPose || (spine.MixPose = {})); + var MixDirection; + (function (MixDirection) { + MixDirection[MixDirection["in"] = 0] = "in"; + MixDirection[MixDirection["out"] = 1] = "out"; + })(MixDirection = spine.MixDirection || (spine.MixDirection = {})); + var TimelineType; + (function (TimelineType) { + TimelineType[TimelineType["rotate"] = 0] = "rotate"; + TimelineType[TimelineType["translate"] = 1] = "translate"; + TimelineType[TimelineType["scale"] = 2] = "scale"; + TimelineType[TimelineType["shear"] = 3] = "shear"; + TimelineType[TimelineType["attachment"] = 4] = "attachment"; + TimelineType[TimelineType["color"] = 5] = "color"; + TimelineType[TimelineType["deform"] = 6] = "deform"; + TimelineType[TimelineType["event"] = 7] = "event"; + TimelineType[TimelineType["drawOrder"] = 8] = "drawOrder"; + TimelineType[TimelineType["ikConstraint"] = 9] = "ikConstraint"; + TimelineType[TimelineType["transformConstraint"] = 10] = "transformConstraint"; + TimelineType[TimelineType["pathConstraintPosition"] = 11] = "pathConstraintPosition"; + TimelineType[TimelineType["pathConstraintSpacing"] = 12] = "pathConstraintSpacing"; + TimelineType[TimelineType["pathConstraintMix"] = 13] = "pathConstraintMix"; + TimelineType[TimelineType["twoColor"] = 14] = "twoColor"; + })(TimelineType = spine.TimelineType || (spine.TimelineType = {})); + var CurveTimeline = (function () { + function CurveTimeline(frameCount) { + if (frameCount <= 0) + throw new Error("frameCount must be > 0: " + frameCount); + this.curves = spine.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE); + } + CurveTimeline.prototype.getFrameCount = function () { + return this.curves.length / CurveTimeline.BEZIER_SIZE + 1; + }; + CurveTimeline.prototype.setLinear = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR; + }; + CurveTimeline.prototype.setStepped = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED; + }; + CurveTimeline.prototype.getCurveType = function (frameIndex) { + var index = frameIndex * CurveTimeline.BEZIER_SIZE; + if (index == this.curves.length) + return CurveTimeline.LINEAR; + var type = this.curves[index]; + if (type == CurveTimeline.LINEAR) + return CurveTimeline.LINEAR; + if (type == CurveTimeline.STEPPED) + return CurveTimeline.STEPPED; + return CurveTimeline.BEZIER; + }; + CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) { + var tmpx = (-cx1 * 2 + cx2) * 0.03, tmpy = (-cy1 * 2 + cy2) * 0.03; + var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006; + var ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy; + var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var curves = this.curves; + curves[i++] = CurveTimeline.BEZIER; + var x = dfx, y = dfy; + for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + curves[i] = x; + curves[i + 1] = y; + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + x += dfx; + y += dfy; + } + }; + CurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) { + percent = spine.MathUtils.clamp(percent, 0, 1); + var curves = this.curves; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var type = curves[i]; + if (type == CurveTimeline.LINEAR) + return percent; + if (type == CurveTimeline.STEPPED) + return 0; + i++; + var x = 0; + for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + x = curves[i]; + if (x >= percent) { + var prevX = void 0, prevY = void 0; + if (i == start) { + prevX = 0; + prevY = 0; + } + else { + prevX = curves[i - 2]; + prevY = curves[i - 1]; + } + return prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX); + } + } + var y = curves[i - 1]; + return y + (1 - y) * (percent - x) / (1 - x); + }; + CurveTimeline.LINEAR = 0; + CurveTimeline.STEPPED = 1; + CurveTimeline.BEZIER = 2; + CurveTimeline.BEZIER_SIZE = 10 * 2 - 1; + return CurveTimeline; + }()); + spine.CurveTimeline = CurveTimeline; + var RotateTimeline = (function (_super) { + __extends(RotateTimeline, _super); + function RotateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount << 1); + return _this; + } + RotateTimeline.prototype.getPropertyId = function () { + return (TimelineType.rotate << 24) + this.boneIndex; + }; + RotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) { + frameIndex <<= 1; + this.frames[frameIndex] = time; + this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; + }; + RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.rotation = bone.data.rotation; + return; + case MixPose.current: + var r_1 = bone.data.rotation - bone.rotation; + r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360; + bone.rotation += r_1 * alpha; + } + return; + } + if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { + if (pose == MixPose.setup) + bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha; + else { + var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation; + r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; + bone.rotation += r_2 * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES); + var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); + var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + r = prevRotation + r * percent; + if (pose == MixPose.setup) { + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.rotation = bone.data.rotation + r * alpha; + } + else { + r = bone.data.rotation + r - bone.rotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.rotation += r * alpha; + } + }; + RotateTimeline.ENTRIES = 2; + RotateTimeline.PREV_TIME = -2; + RotateTimeline.PREV_ROTATION = -1; + RotateTimeline.ROTATION = 1; + return RotateTimeline; + }(CurveTimeline)); + spine.RotateTimeline = RotateTimeline; + var TranslateTimeline = (function (_super) { + __extends(TranslateTimeline, _super); + function TranslateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES); + return _this; + } + TranslateTimeline.prototype.getPropertyId = function () { + return (TimelineType.translate << 24) + this.boneIndex; + }; + TranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) { + frameIndex *= TranslateTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TranslateTimeline.X] = x; + this.frames[frameIndex + TranslateTimeline.Y] = y; + }; + TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.x = bone.data.x; + bone.y = bone.data.y; + return; + case MixPose.current: + bone.x += (bone.data.x - bone.x) * alpha; + bone.y += (bone.data.y - bone.y) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { + x = frames[frames.length + TranslateTimeline.PREV_X]; + y = frames[frames.length + TranslateTimeline.PREV_Y]; + } + else { + var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES); + x = frames[frame + TranslateTimeline.PREV_X]; + y = frames[frame + TranslateTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime)); + x += (frames[frame + TranslateTimeline.X] - x) * percent; + y += (frames[frame + TranslateTimeline.Y] - y) * percent; + } + if (pose == MixPose.setup) { + bone.x = bone.data.x + x * alpha; + bone.y = bone.data.y + y * alpha; + } + else { + bone.x += (bone.data.x + x - bone.x) * alpha; + bone.y += (bone.data.y + y - bone.y) * alpha; + } + }; + TranslateTimeline.ENTRIES = 3; + TranslateTimeline.PREV_TIME = -3; + TranslateTimeline.PREV_X = -2; + TranslateTimeline.PREV_Y = -1; + TranslateTimeline.X = 1; + TranslateTimeline.Y = 2; + return TranslateTimeline; + }(CurveTimeline)); + spine.TranslateTimeline = TranslateTimeline; + var ScaleTimeline = (function (_super) { + __extends(ScaleTimeline, _super); + function ScaleTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ScaleTimeline.prototype.getPropertyId = function () { + return (TimelineType.scale << 24) + this.boneIndex; + }; + ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.scaleX = bone.data.scaleX; + bone.scaleY = bone.data.scaleY; + return; + case MixPose.current: + bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { + x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX; + y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY; + } + else { + var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES); + x = frames[frame + ScaleTimeline.PREV_X]; + y = frames[frame + ScaleTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime)); + x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX; + y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; + } + if (alpha == 1) { + bone.scaleX = x; + bone.scaleY = y; + } + else { + var bx = 0, by = 0; + if (pose == MixPose.setup) { + bx = bone.data.scaleX; + by = bone.data.scaleY; + } + else { + bx = bone.scaleX; + by = bone.scaleY; + } + if (direction == MixDirection.out) { + x = Math.abs(x) * spine.MathUtils.signum(bx); + y = Math.abs(y) * spine.MathUtils.signum(by); + } + else { + bx = Math.abs(bx) * spine.MathUtils.signum(x); + by = Math.abs(by) * spine.MathUtils.signum(y); + } + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + } + }; + return ScaleTimeline; + }(TranslateTimeline)); + spine.ScaleTimeline = ScaleTimeline; + var ShearTimeline = (function (_super) { + __extends(ShearTimeline, _super); + function ShearTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ShearTimeline.prototype.getPropertyId = function () { + return (TimelineType.shear << 24) + this.boneIndex; + }; + ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.shearX = bone.data.shearX; + bone.shearY = bone.data.shearY; + return; + case MixPose.current: + bone.shearX += (bone.data.shearX - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY - bone.shearY) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { + x = frames[frames.length + ShearTimeline.PREV_X]; + y = frames[frames.length + ShearTimeline.PREV_Y]; + } + else { + var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES); + x = frames[frame + ShearTimeline.PREV_X]; + y = frames[frame + ShearTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime)); + x = x + (frames[frame + ShearTimeline.X] - x) * percent; + y = y + (frames[frame + ShearTimeline.Y] - y) * percent; + } + if (pose == MixPose.setup) { + bone.shearX = bone.data.shearX + x * alpha; + bone.shearY = bone.data.shearY + y * alpha; + } + else { + bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; + } + }; + return ShearTimeline; + }(TranslateTimeline)); + spine.ShearTimeline = ShearTimeline; + var ColorTimeline = (function (_super) { + __extends(ColorTimeline, _super); + function ColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES); + return _this; + } + ColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.color << 24) + this.slotIndex; + }; + ColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) { + frameIndex *= ColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + ColorTimeline.R] = r; + this.frames[frameIndex + ColorTimeline.G] = g; + this.frames[frameIndex + ColorTimeline.B] = b; + this.frames[frameIndex + ColorTimeline.A] = a; + }; + ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + var frames = this.frames; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + slot.color.setFromColor(slot.data.color); + return; + case MixPose.current: + var color = slot.color, setup = slot.data.color; + color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); + } + return; + } + var r = 0, g = 0, b = 0, a = 0; + if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + ColorTimeline.PREV_R]; + g = frames[i + ColorTimeline.PREV_G]; + b = frames[i + ColorTimeline.PREV_B]; + a = frames[i + ColorTimeline.PREV_A]; + } + else { + var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES); + r = frames[frame + ColorTimeline.PREV_R]; + g = frames[frame + ColorTimeline.PREV_G]; + b = frames[frame + ColorTimeline.PREV_B]; + a = frames[frame + ColorTimeline.PREV_A]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime)); + r += (frames[frame + ColorTimeline.R] - r) * percent; + g += (frames[frame + ColorTimeline.G] - g) * percent; + b += (frames[frame + ColorTimeline.B] - b) * percent; + a += (frames[frame + ColorTimeline.A] - a) * percent; + } + if (alpha == 1) + slot.color.set(r, g, b, a); + else { + var color = slot.color; + if (pose == MixPose.setup) + color.setFromColor(slot.data.color); + color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); + } + }; + ColorTimeline.ENTRIES = 5; + ColorTimeline.PREV_TIME = -5; + ColorTimeline.PREV_R = -4; + ColorTimeline.PREV_G = -3; + ColorTimeline.PREV_B = -2; + ColorTimeline.PREV_A = -1; + ColorTimeline.R = 1; + ColorTimeline.G = 2; + ColorTimeline.B = 3; + ColorTimeline.A = 4; + return ColorTimeline; + }(CurveTimeline)); + spine.ColorTimeline = ColorTimeline; + var TwoColorTimeline = (function (_super) { + __extends(TwoColorTimeline, _super); + function TwoColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES); + return _this; + } + TwoColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.twoColor << 24) + this.slotIndex; + }; + TwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) { + frameIndex *= TwoColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TwoColorTimeline.R] = r; + this.frames[frameIndex + TwoColorTimeline.G] = g; + this.frames[frameIndex + TwoColorTimeline.B] = b; + this.frames[frameIndex + TwoColorTimeline.A] = a; + this.frames[frameIndex + TwoColorTimeline.R2] = r2; + this.frames[frameIndex + TwoColorTimeline.G2] = g2; + this.frames[frameIndex + TwoColorTimeline.B2] = b2; + }; + TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + var frames = this.frames; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + slot.color.setFromColor(slot.data.color); + slot.darkColor.setFromColor(slot.data.darkColor); + return; + case MixPose.current: + var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; + light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); + dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); + } + return; + } + var r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0; + if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + TwoColorTimeline.PREV_R]; + g = frames[i + TwoColorTimeline.PREV_G]; + b = frames[i + TwoColorTimeline.PREV_B]; + a = frames[i + TwoColorTimeline.PREV_A]; + r2 = frames[i + TwoColorTimeline.PREV_R2]; + g2 = frames[i + TwoColorTimeline.PREV_G2]; + b2 = frames[i + TwoColorTimeline.PREV_B2]; + } + else { + var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES); + r = frames[frame + TwoColorTimeline.PREV_R]; + g = frames[frame + TwoColorTimeline.PREV_G]; + b = frames[frame + TwoColorTimeline.PREV_B]; + a = frames[frame + TwoColorTimeline.PREV_A]; + r2 = frames[frame + TwoColorTimeline.PREV_R2]; + g2 = frames[frame + TwoColorTimeline.PREV_G2]; + b2 = frames[frame + TwoColorTimeline.PREV_B2]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime)); + r += (frames[frame + TwoColorTimeline.R] - r) * percent; + g += (frames[frame + TwoColorTimeline.G] - g) * percent; + b += (frames[frame + TwoColorTimeline.B] - b) * percent; + a += (frames[frame + TwoColorTimeline.A] - a) * percent; + r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent; + g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent; + b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent; + } + if (alpha == 1) { + slot.color.set(r, g, b, a); + slot.darkColor.set(r2, g2, b2, 1); + } + else { + var light = slot.color, dark = slot.darkColor; + if (pose == MixPose.setup) { + light.setFromColor(slot.data.color); + dark.setFromColor(slot.data.darkColor); + } + light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha); + dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0); + } + }; + TwoColorTimeline.ENTRIES = 8; + TwoColorTimeline.PREV_TIME = -8; + TwoColorTimeline.PREV_R = -7; + TwoColorTimeline.PREV_G = -6; + TwoColorTimeline.PREV_B = -5; + TwoColorTimeline.PREV_A = -4; + TwoColorTimeline.PREV_R2 = -3; + TwoColorTimeline.PREV_G2 = -2; + TwoColorTimeline.PREV_B2 = -1; + TwoColorTimeline.R = 1; + TwoColorTimeline.G = 2; + TwoColorTimeline.B = 3; + TwoColorTimeline.A = 4; + TwoColorTimeline.R2 = 5; + TwoColorTimeline.G2 = 6; + TwoColorTimeline.B2 = 7; + return TwoColorTimeline; + }(CurveTimeline)); + spine.TwoColorTimeline = TwoColorTimeline; + var AttachmentTimeline = (function () { + function AttachmentTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.attachmentNames = new Array(frameCount); + } + AttachmentTimeline.prototype.getPropertyId = function () { + return (TimelineType.attachment << 24) + this.slotIndex; + }; + AttachmentTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + AttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) { + this.frames[frameIndex] = time; + this.attachmentNames[frameIndex] = attachmentName; + }; + AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (direction == MixDirection.out && pose == MixPose.setup) { + var attachmentName_1 = slot.data.attachmentName; + slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1)); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (pose == MixPose.setup) { + var attachmentName_2 = slot.data.attachmentName; + slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); + } + return; + } + var frameIndex = 0; + if (time >= frames[frames.length - 1]) + frameIndex = frames.length - 1; + else + frameIndex = Animation.binarySearch(frames, time, 1) - 1; + var attachmentName = this.attachmentNames[frameIndex]; + skeleton.slots[this.slotIndex] + .setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName)); + }; + return AttachmentTimeline; + }()); + spine.AttachmentTimeline = AttachmentTimeline; + var zeros = null; + var DeformTimeline = (function (_super) { + __extends(DeformTimeline, _super); + function DeformTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount); + _this.frameVertices = new Array(frameCount); + if (zeros == null) + zeros = spine.Utils.newFloatArray(64); + return _this; + } + DeformTimeline.prototype.getPropertyId = function () { + return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex; + }; + DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) { + this.frames[frameIndex] = time; + this.frameVertices[frameIndex] = vertices; + }; + DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + var slotAttachment = slot.getAttachment(); + if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) + return; + var verticesArray = slot.attachmentVertices; + if (verticesArray.length == 0) + alpha = 1; + var frameVertices = this.frameVertices; + var vertexCount = frameVertices[0].length; + var frames = this.frames; + if (time < frames[0]) { + var vertexAttachment = slotAttachment; + switch (pose) { + case MixPose.setup: + verticesArray.length = 0; + return; + case MixPose.current: + if (alpha == 1) { + verticesArray.length = 0; + break; + } + var vertices_1 = spine.Utils.setArraySize(verticesArray, vertexCount); + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) + vertices_1[i] += (setupVertices[i] - vertices_1[i]) * alpha; + } + else { + alpha = 1 - alpha; + for (var i = 0; i < vertexCount; i++) + vertices_1[i] *= alpha; + } + } + return; + } + var vertices = spine.Utils.setArraySize(verticesArray, vertexCount); + if (time >= frames[frames.length - 1]) { + var lastVertices = frameVertices[frames.length - 1]; + if (alpha == 1) { + spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); + } + else if (pose == MixPose.setup) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices_1 = vertexAttachment.vertices; + for (var i_1 = 0; i_1 < vertexCount; i_1++) { + var setup = setupVertices_1[i_1]; + vertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha; + } + } + else { + for (var i_2 = 0; i_2 < vertexCount; i_2++) + vertices[i_2] = lastVertices[i_2] * alpha; + } + } + else { + for (var i_3 = 0; i_3 < vertexCount; i_3++) + vertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time); + var prevVertices = frameVertices[frame - 1]; + var nextVertices = frameVertices[frame]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); + if (alpha == 1) { + for (var i_4 = 0; i_4 < vertexCount; i_4++) { + var prev = prevVertices[i_4]; + vertices[i_4] = prev + (nextVertices[i_4] - prev) * percent; + } + } + else if (pose == MixPose.setup) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices_2 = vertexAttachment.vertices; + for (var i_5 = 0; i_5 < vertexCount; i_5++) { + var prev = prevVertices[i_5], setup = setupVertices_2[i_5]; + vertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha; + } + } + else { + for (var i_6 = 0; i_6 < vertexCount; i_6++) { + var prev = prevVertices[i_6]; + vertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha; + } + } + } + else { + for (var i_7 = 0; i_7 < vertexCount; i_7++) { + var prev = prevVertices[i_7]; + vertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha; + } + } + }; + return DeformTimeline; + }(CurveTimeline)); + spine.DeformTimeline = DeformTimeline; + var EventTimeline = (function () { + function EventTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.events = new Array(frameCount); + } + EventTimeline.prototype.getPropertyId = function () { + return TimelineType.event << 24; + }; + EventTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + EventTimeline.prototype.setFrame = function (frameIndex, event) { + this.frames[frameIndex] = event.time; + this.events[frameIndex] = event; + }; + EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + if (firedEvents == null) + return; + var frames = this.frames; + var frameCount = this.frames.length; + if (lastTime > time) { + this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction); + lastTime = -1; + } + else if (lastTime >= frames[frameCount - 1]) + return; + if (time < frames[0]) + return; + var frame = 0; + if (lastTime < frames[0]) + frame = 0; + else { + frame = Animation.binarySearch(frames, lastTime); + var frameTime = frames[frame]; + while (frame > 0) { + if (frames[frame - 1] != frameTime) + break; + frame--; + } + } + for (; frame < frameCount && time >= frames[frame]; frame++) + firedEvents.push(this.events[frame]); + }; + return EventTimeline; + }()); + spine.EventTimeline = EventTimeline; + var DrawOrderTimeline = (function () { + function DrawOrderTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.drawOrders = new Array(frameCount); + } + DrawOrderTimeline.prototype.getPropertyId = function () { + return TimelineType.drawOrder << 24; + }; + DrawOrderTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) { + this.frames[frameIndex] = time; + this.drawOrders[frameIndex] = drawOrder; + }; + DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var drawOrder = skeleton.drawOrder; + var slots = skeleton.slots; + if (direction == MixDirection.out && pose == MixPose.setup) { + spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (pose == MixPose.setup) + spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frame = 0; + if (time >= frames[frames.length - 1]) + frame = frames.length - 1; + else + frame = Animation.binarySearch(frames, time) - 1; + var drawOrderToSetupIndex = this.drawOrders[frame]; + if (drawOrderToSetupIndex == null) + spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length); + else { + for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++) + drawOrder[i] = slots[drawOrderToSetupIndex[i]]; + } + }; + return DrawOrderTimeline; + }()); + spine.DrawOrderTimeline = DrawOrderTimeline; + var IkConstraintTimeline = (function (_super) { + __extends(IkConstraintTimeline, _super); + function IkConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES); + return _this; + } + IkConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex; + }; + IkConstraintTimeline.prototype.setFrame = function (frameIndex, time, mix, bendDirection) { + frameIndex *= IkConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; + this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; + }; + IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.mix = constraint.data.mix; + constraint.bendDirection = constraint.data.bendDirection; + return; + case MixPose.current: + constraint.mix += (constraint.data.mix - constraint.mix) * alpha; + constraint.bendDirection = constraint.data.bendDirection; + } + return; + } + if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { + if (pose == MixPose.setup) { + constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha; + constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection + : frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + else { + constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha; + if (direction == MixDirection["in"]) + constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + return; + } + var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES); + var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); + if (pose == MixPose.setup) { + constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; + constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + else { + constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha; + if (direction == MixDirection["in"]) + constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + }; + IkConstraintTimeline.ENTRIES = 3; + IkConstraintTimeline.PREV_TIME = -3; + IkConstraintTimeline.PREV_MIX = -2; + IkConstraintTimeline.PREV_BEND_DIRECTION = -1; + IkConstraintTimeline.MIX = 1; + IkConstraintTimeline.BEND_DIRECTION = 2; + return IkConstraintTimeline; + }(CurveTimeline)); + spine.IkConstraintTimeline = IkConstraintTimeline; + var TransformConstraintTimeline = (function (_super) { + __extends(TransformConstraintTimeline, _super); + function TransformConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES); + return _this; + } + TransformConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex; + }; + TransformConstraintTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) { + frameIndex *= TransformConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix; + this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; + this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; + }; + TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; + if (time < frames[0]) { + var data = constraint.data; + switch (pose) { + case MixPose.setup: + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + return; + case MixPose.current: + constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; + constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; + constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha; + } + return; + } + var rotate = 0, translate = 0, scale = 0, shear = 0; + if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) { + var i = frames.length; + rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[i + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[i + TransformConstraintTimeline.PREV_SHEAR]; + } + else { + var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES); + rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[frame + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime)); + rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent; + scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; + shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; + } + if (pose == MixPose.setup) { + var data = constraint.data; + constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha; + constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha; + constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha; + constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha; + } + else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + constraint.scaleMix += (scale - constraint.scaleMix) * alpha; + constraint.shearMix += (shear - constraint.shearMix) * alpha; + } + }; + TransformConstraintTimeline.ENTRIES = 5; + TransformConstraintTimeline.PREV_TIME = -5; + TransformConstraintTimeline.PREV_ROTATE = -4; + TransformConstraintTimeline.PREV_TRANSLATE = -3; + TransformConstraintTimeline.PREV_SCALE = -2; + TransformConstraintTimeline.PREV_SHEAR = -1; + TransformConstraintTimeline.ROTATE = 1; + TransformConstraintTimeline.TRANSLATE = 2; + TransformConstraintTimeline.SCALE = 3; + TransformConstraintTimeline.SHEAR = 4; + return TransformConstraintTimeline; + }(CurveTimeline)); + spine.TransformConstraintTimeline = TransformConstraintTimeline; + var PathConstraintPositionTimeline = (function (_super) { + __extends(PathConstraintPositionTimeline, _super); + function PathConstraintPositionTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES); + return _this; + } + PathConstraintPositionTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex; + }; + PathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) { + frameIndex *= PathConstraintPositionTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; + }; + PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.position = constraint.data.position; + return; + case MixPose.current: + constraint.position += (constraint.data.position - constraint.position) * alpha; + } + return; + } + var position = 0; + if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES]) + position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES); + position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); + position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; + } + if (pose == MixPose.setup) + constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; + else + constraint.position += (position - constraint.position) * alpha; + }; + PathConstraintPositionTimeline.ENTRIES = 2; + PathConstraintPositionTimeline.PREV_TIME = -2; + PathConstraintPositionTimeline.PREV_VALUE = -1; + PathConstraintPositionTimeline.VALUE = 1; + return PathConstraintPositionTimeline; + }(CurveTimeline)); + spine.PathConstraintPositionTimeline = PathConstraintPositionTimeline; + var PathConstraintSpacingTimeline = (function (_super) { + __extends(PathConstraintSpacingTimeline, _super); + function PathConstraintSpacingTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + PathConstraintSpacingTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; + }; + PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.spacing = constraint.data.spacing; + return; + case MixPose.current: + constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; + } + return; + } + var spacing = 0; + if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES]) + spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES); + spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); + spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; + } + if (pose == MixPose.setup) + constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; + else + constraint.spacing += (spacing - constraint.spacing) * alpha; + }; + return PathConstraintSpacingTimeline; + }(PathConstraintPositionTimeline)); + spine.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline; + var PathConstraintMixTimeline = (function (_super) { + __extends(PathConstraintMixTimeline, _super); + function PathConstraintMixTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES); + return _this; + } + PathConstraintMixTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex; + }; + PathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) { + frameIndex *= PathConstraintMixTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; + }; + PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.rotateMix = constraint.data.rotateMix; + constraint.translateMix = constraint.data.translateMix; + return; + case MixPose.current: + constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; + } + return; + } + var rotate = 0, translate = 0; + if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { + rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE]; + } + else { + var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES); + rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime)); + rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; + } + if (pose == MixPose.setup) { + constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; + constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; + } + else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + } + }; + PathConstraintMixTimeline.ENTRIES = 3; + PathConstraintMixTimeline.PREV_TIME = -3; + PathConstraintMixTimeline.PREV_ROTATE = -2; + PathConstraintMixTimeline.PREV_TRANSLATE = -1; + PathConstraintMixTimeline.ROTATE = 1; + PathConstraintMixTimeline.TRANSLATE = 2; + return PathConstraintMixTimeline; + }(CurveTimeline)); + spine.PathConstraintMixTimeline = PathConstraintMixTimeline; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AnimationState = (function () { + function AnimationState(data) { + this.tracks = new Array(); + this.events = new Array(); + this.listeners = new Array(); + this.queue = new EventQueue(this); + this.propertyIDs = new spine.IntSet(); + this.mixingTo = new Array(); + this.animationsChanged = false; + this.timeScale = 1; + this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); }); + this.data = data; + } + AnimationState.prototype.update = function (delta) { + delta *= this.timeScale; + var tracks = this.tracks; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (current == null) + continue; + current.animationLast = current.nextAnimationLast; + current.trackLast = current.nextTrackLast; + var currentDelta = delta * current.timeScale; + if (current.delay > 0) { + current.delay -= currentDelta; + if (current.delay > 0) + continue; + currentDelta = -current.delay; + current.delay = 0; + } + var next = current.next; + if (next != null) { + var nextTime = current.trackLast - next.delay; + if (nextTime >= 0) { + next.delay = 0; + next.trackTime = nextTime + delta * next.timeScale; + current.trackTime += currentDelta; + this.setCurrent(i, next, true); + while (next.mixingFrom != null) { + next.mixTime += currentDelta; + next = next.mixingFrom; + } + continue; + } + } + else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) { + tracks[i] = null; + this.queue.end(current); + this.disposeNext(current); + continue; + } + if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) { + var from = current.mixingFrom; + current.mixingFrom = null; + while (from != null) { + this.queue.end(from); + from = from.mixingFrom; + } + } + current.trackTime += currentDelta; + } + this.queue.drain(); + }; + AnimationState.prototype.updateMixingFrom = function (to, delta) { + var from = to.mixingFrom; + if (from == null) + return true; + var finished = this.updateMixingFrom(from, delta); + from.animationLast = from.nextAnimationLast; + from.trackLast = from.nextTrackLast; + if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { + if (from.totalAlpha == 0 || to.mixDuration == 0) { + to.mixingFrom = from.mixingFrom; + to.interruptAlpha = from.interruptAlpha; + this.queue.end(from); + } + return finished; + } + from.trackTime += delta * from.timeScale; + to.mixTime += delta * to.timeScale; + return false; + }; + AnimationState.prototype.apply = function (skeleton) { + if (skeleton == null) + throw new Error("skeleton cannot be null."); + if (this.animationsChanged) + this._animationsChanged(); + var events = this.events; + var tracks = this.tracks; + var applied = false; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (current == null || current.delay > 0) + continue; + applied = true; + var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered; + var mix = current.alpha; + if (current.mixingFrom != null) + mix *= this.applyMixingFrom(current, skeleton, currentPose); + else if (current.trackTime >= current.trackEnd && current.next == null) + mix = 0; + var animationLast = current.animationLast, animationTime = current.getAnimationTime(); + var timelineCount = current.animation.timelines.length; + var timelines = current.animation.timelines; + if (mix == 1) { + for (var ii = 0; ii < timelineCount; ii++) + timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection["in"]); + } + else { + var timelineData = current.timelineData; + var firstFrame = current.timelinesRotation.length == 0; + if (firstFrame) + spine.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = current.timelinesRotation; + for (var ii = 0; ii < timelineCount; ii++) { + var timeline = timelines[ii]; + var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose; + if (timeline instanceof spine.RotateTimeline) { + this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); + } + else { + spine.Utils.webkit602BugfixHelper(mix, pose); + timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection["in"]); + } + } + } + this.queueEvents(current, animationTime); + events.length = 0; + current.nextAnimationLast = animationTime; + current.nextTrackLast = current.trackTime; + } + this.queue.drain(); + return applied; + }; + AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) { + var from = to.mixingFrom; + if (from.mixingFrom != null) + this.applyMixingFrom(from, skeleton, currentPose); + var mix = 0; + if (to.mixDuration == 0) { + mix = 1; + currentPose = spine.MixPose.setup; + } + else { + mix = to.mixTime / to.mixDuration; + if (mix > 1) + mix = 1; + } + var events = mix < from.eventThreshold ? this.events : null; + var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; + var animationLast = from.animationLast, animationTime = from.getAnimationTime(); + var timelineCount = from.animation.timelines.length; + var timelines = from.animation.timelines; + var timelineData = from.timelineData; + var timelineDipMix = from.timelineDipMix; + var firstFrame = from.timelinesRotation.length == 0; + if (firstFrame) + spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = from.timelinesRotation; + var pose; + var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0; + from.totalAlpha = 0; + for (var i = 0; i < timelineCount; i++) { + var timeline = timelines[i]; + switch (timelineData[i]) { + case AnimationState.SUBSEQUENT: + if (!attachments && timeline instanceof spine.AttachmentTimeline) + continue; + if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) + continue; + pose = currentPose; + alpha = alphaMix; + break; + case AnimationState.FIRST: + pose = spine.MixPose.setup; + alpha = alphaMix; + break; + case AnimationState.DIP: + pose = spine.MixPose.setup; + alpha = alphaDip; + break; + default: + pose = spine.MixPose.setup; + alpha = alphaDip; + var dipMix = timelineDipMix[i]; + alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration); + break; + } + from.totalAlpha += alpha; + if (timeline instanceof spine.RotateTimeline) + this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); + else { + spine.Utils.webkit602BugfixHelper(alpha, pose); + timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out); + } + } + if (to.mixDuration > 0) + this.queueEvents(from, animationTime); + this.events.length = 0; + from.nextAnimationLast = animationTime; + from.nextTrackLast = from.trackTime; + return mix; + }; + AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) { + if (firstFrame) + timelinesRotation[i] = 0; + if (alpha == 1) { + timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection["in"]); + return; + } + var rotateTimeline = timeline; + var frames = rotateTimeline.frames; + var bone = skeleton.bones[rotateTimeline.boneIndex]; + if (time < frames[0]) { + if (pose == spine.MixPose.setup) + bone.rotation = bone.data.rotation; + return; + } + var r2 = 0; + if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES]) + r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION]; + else { + var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES); + var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime)); + r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + r2 = prevRotation + r2 * percent + bone.data.rotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + } + var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation; + var total = 0, diff = r2 - r1; + if (diff == 0) { + total = timelinesRotation[i]; + } + else { + diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360; + var lastTotal = 0, lastDiff = 0; + if (firstFrame) { + lastTotal = 0; + lastDiff = diff; + } + else { + lastTotal = timelinesRotation[i]; + lastDiff = timelinesRotation[i + 1]; + } + var current = diff > 0, dir = lastTotal >= 0; + if (spine.MathUtils.signum(lastDiff) != spine.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) { + if (Math.abs(lastTotal) > 180) + lastTotal += 360 * spine.MathUtils.signum(lastTotal); + dir = current; + } + total = diff + lastTotal - lastTotal % 360; + if (dir != current) + total += 360 * spine.MathUtils.signum(lastTotal); + timelinesRotation[i] = total; + } + timelinesRotation[i + 1] = diff; + r1 += total * alpha; + bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360; + }; + AnimationState.prototype.queueEvents = function (entry, animationTime) { + var animationStart = entry.animationStart, animationEnd = entry.animationEnd; + var duration = animationEnd - animationStart; + var trackLastWrapped = entry.trackLast % duration; + var events = this.events; + var i = 0, n = events.length; + for (; i < n; i++) { + var event_1 = events[i]; + if (event_1.time < trackLastWrapped) + break; + if (event_1.time > animationEnd) + continue; + this.queue.event(entry, event_1); + } + var complete = false; + if (entry.loop) + complete = duration == 0 || trackLastWrapped > entry.trackTime % duration; + else + complete = animationTime >= animationEnd && entry.animationLast < animationEnd; + if (complete) + this.queue.complete(entry); + for (; i < n; i++) { + var event_2 = events[i]; + if (event_2.time < animationStart) + continue; + this.queue.event(entry, events[i]); + } + }; + AnimationState.prototype.clearTracks = function () { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) + this.clearTrack(i); + this.tracks.length = 0; + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.clearTrack = function (trackIndex) { + if (trackIndex >= this.tracks.length) + return; + var current = this.tracks[trackIndex]; + if (current == null) + return; + this.queue.end(current); + this.disposeNext(current); + var entry = current; + while (true) { + var from = entry.mixingFrom; + if (from == null) + break; + this.queue.end(from); + entry.mixingFrom = null; + entry = from; + } + this.tracks[current.trackIndex] = null; + this.queue.drain(); + }; + AnimationState.prototype.setCurrent = function (index, current, interrupt) { + var from = this.expandToIndex(index); + this.tracks[index] = current; + if (from != null) { + if (interrupt) + this.queue.interrupt(from); + current.mixingFrom = from; + current.mixTime = 0; + if (from.mixingFrom != null && from.mixDuration > 0) + current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration); + from.timelinesRotation.length = 0; + } + this.queue.start(current); + }; + AnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) + throw new Error("Animation not found: " + animationName); + return this.setAnimationWith(trackIndex, animation, loop); + }; + AnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) { + if (animation == null) + throw new Error("animation cannot be null."); + var interrupt = true; + var current = this.expandToIndex(trackIndex); + if (current != null) { + if (current.nextTrackLast == -1) { + this.tracks[trackIndex] = current.mixingFrom; + this.queue.interrupt(current); + this.queue.end(current); + this.disposeNext(current); + current = current.mixingFrom; + interrupt = false; + } + else + this.disposeNext(current); + } + var entry = this.trackEntry(trackIndex, animation, loop, current); + this.setCurrent(trackIndex, entry, interrupt); + this.queue.drain(); + return entry; + }; + AnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) + throw new Error("Animation not found: " + animationName); + return this.addAnimationWith(trackIndex, animation, loop, delay); + }; + AnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) { + if (animation == null) + throw new Error("animation cannot be null."); + var last = this.expandToIndex(trackIndex); + if (last != null) { + while (last.next != null) + last = last.next; + } + var entry = this.trackEntry(trackIndex, animation, loop, last); + if (last == null) { + this.setCurrent(trackIndex, entry, true); + this.queue.drain(); + } + else { + last.next = entry; + if (delay <= 0) { + var duration = last.animationEnd - last.animationStart; + if (duration != 0) { + if (last.loop) + delay += duration * (1 + ((last.trackTime / duration) | 0)); + else + delay += duration; + delay -= this.data.getMix(last.animation, animation); + } + else + delay = 0; + } + } + entry.delay = delay; + return entry; + }; + AnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) { + var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) { + if (delay <= 0) + delay -= mixDuration; + var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.setEmptyAnimations = function (mixDuration) { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) { + var current = this.tracks[i]; + if (current != null) + this.setEmptyAnimation(current.trackIndex, mixDuration); + } + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.expandToIndex = function (index) { + if (index < this.tracks.length) + return this.tracks[index]; + spine.Utils.ensureArrayCapacity(this.tracks, index - this.tracks.length + 1, null); + this.tracks.length = index + 1; + return null; + }; + AnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) { + var entry = this.trackEntryPool.obtain(); + entry.trackIndex = trackIndex; + entry.animation = animation; + entry.loop = loop; + entry.eventThreshold = 0; + entry.attachmentThreshold = 0; + entry.drawOrderThreshold = 0; + entry.animationStart = 0; + entry.animationEnd = animation.duration; + entry.animationLast = -1; + entry.nextAnimationLast = -1; + entry.delay = 0; + entry.trackTime = 0; + entry.trackLast = -1; + entry.nextTrackLast = -1; + entry.trackEnd = Number.MAX_VALUE; + entry.timeScale = 1; + entry.alpha = 1; + entry.interruptAlpha = 1; + entry.mixTime = 0; + entry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation); + return entry; + }; + AnimationState.prototype.disposeNext = function (entry) { + var next = entry.next; + while (next != null) { + this.queue.dispose(next); + next = next.next; + } + entry.next = null; + }; + AnimationState.prototype._animationsChanged = function () { + this.animationsChanged = false; + var propertyIDs = this.propertyIDs; + propertyIDs.clear(); + var mixingTo = this.mixingTo; + for (var i = 0, n = this.tracks.length; i < n; i++) { + var entry = this.tracks[i]; + if (entry != null) + entry.setTimelineData(null, mixingTo, propertyIDs); + } + }; + AnimationState.prototype.getCurrent = function (trackIndex) { + if (trackIndex >= this.tracks.length) + return null; + return this.tracks[trackIndex]; + }; + AnimationState.prototype.addListener = function (listener) { + if (listener == null) + throw new Error("listener cannot be null."); + this.listeners.push(listener); + }; + AnimationState.prototype.removeListener = function (listener) { + var index = this.listeners.indexOf(listener); + if (index >= 0) + this.listeners.splice(index, 1); + }; + AnimationState.prototype.clearListeners = function () { + this.listeners.length = 0; + }; + AnimationState.prototype.clearListenerNotifications = function () { + this.queue.clear(); + }; + AnimationState.emptyAnimation = new spine.Animation("", [], 0); + AnimationState.SUBSEQUENT = 0; + AnimationState.FIRST = 1; + AnimationState.DIP = 2; + AnimationState.DIP_MIX = 3; + return AnimationState; + }()); + spine.AnimationState = AnimationState; + var TrackEntry = (function () { + function TrackEntry() { + this.timelineData = new Array(); + this.timelineDipMix = new Array(); + this.timelinesRotation = new Array(); + } + TrackEntry.prototype.reset = function () { + this.next = null; + this.mixingFrom = null; + this.animation = null; + this.listener = null; + this.timelineData.length = 0; + this.timelineDipMix.length = 0; + this.timelinesRotation.length = 0; + }; + TrackEntry.prototype.setTimelineData = function (to, mixingToArray, propertyIDs) { + if (to != null) + mixingToArray.push(to); + var lastEntry = this.mixingFrom != null ? this.mixingFrom.setTimelineData(this, mixingToArray, propertyIDs) : this; + if (to != null) + mixingToArray.pop(); + var mixingTo = mixingToArray; + var mixingToLast = mixingToArray.length - 1; + var timelines = this.animation.timelines; + var timelinesCount = this.animation.timelines.length; + var timelineData = spine.Utils.setArraySize(this.timelineData, timelinesCount); + this.timelineDipMix.length = 0; + var timelineDipMix = spine.Utils.setArraySize(this.timelineDipMix, timelinesCount); + outer: for (var i = 0; i < timelinesCount; i++) { + var id = timelines[i].getPropertyId(); + if (!propertyIDs.add(id)) + timelineData[i] = AnimationState.SUBSEQUENT; + else if (to == null || !to.hasTimeline(id)) + timelineData[i] = AnimationState.FIRST; + else { + for (var ii = mixingToLast; ii >= 0; ii--) { + var entry = mixingTo[ii]; + if (!entry.hasTimeline(id)) { + if (entry.mixDuration > 0) { + timelineData[i] = AnimationState.DIP_MIX; + timelineDipMix[i] = entry; + continue outer; + } + } + } + timelineData[i] = AnimationState.DIP; + } + } + return lastEntry; + }; + TrackEntry.prototype.hasTimeline = function (id) { + var timelines = this.animation.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + if (timelines[i].getPropertyId() == id) + return true; + return false; + }; + TrackEntry.prototype.getAnimationTime = function () { + if (this.loop) { + var duration = this.animationEnd - this.animationStart; + if (duration == 0) + return this.animationStart; + return (this.trackTime % duration) + this.animationStart; + } + return Math.min(this.trackTime + this.animationStart, this.animationEnd); + }; + TrackEntry.prototype.setAnimationLast = function (animationLast) { + this.animationLast = animationLast; + this.nextAnimationLast = animationLast; + }; + TrackEntry.prototype.isComplete = function () { + return this.trackTime >= this.animationEnd - this.animationStart; + }; + TrackEntry.prototype.resetRotationDirections = function () { + this.timelinesRotation.length = 0; + }; + return TrackEntry; + }()); + spine.TrackEntry = TrackEntry; + var EventQueue = (function () { + function EventQueue(animState) { + this.objects = []; + this.drainDisabled = false; + this.animState = animState; + } + EventQueue.prototype.start = function (entry) { + this.objects.push(EventType.start); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.interrupt = function (entry) { + this.objects.push(EventType.interrupt); + this.objects.push(entry); + }; + EventQueue.prototype.end = function (entry) { + this.objects.push(EventType.end); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.dispose = function (entry) { + this.objects.push(EventType.dispose); + this.objects.push(entry); + }; + EventQueue.prototype.complete = function (entry) { + this.objects.push(EventType.complete); + this.objects.push(entry); + }; + EventQueue.prototype.event = function (entry, event) { + this.objects.push(EventType.event); + this.objects.push(entry); + this.objects.push(event); + }; + EventQueue.prototype.drain = function () { + if (this.drainDisabled) + return; + this.drainDisabled = true; + var objects = this.objects; + var listeners = this.animState.listeners; + for (var i = 0; i < objects.length; i += 2) { + var type = objects[i]; + var entry = objects[i + 1]; + switch (type) { + case EventType.start: + if (entry.listener != null && entry.listener.start) + entry.listener.start(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].start) + listeners[ii].start(entry); + break; + case EventType.interrupt: + if (entry.listener != null && entry.listener.interrupt) + entry.listener.interrupt(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].interrupt) + listeners[ii].interrupt(entry); + break; + case EventType.end: + if (entry.listener != null && entry.listener.end) + entry.listener.end(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].end) + listeners[ii].end(entry); + case EventType.dispose: + if (entry.listener != null && entry.listener.dispose) + entry.listener.dispose(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].dispose) + listeners[ii].dispose(entry); + this.animState.trackEntryPool.free(entry); + break; + case EventType.complete: + if (entry.listener != null && entry.listener.complete) + entry.listener.complete(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].complete) + listeners[ii].complete(entry); + break; + case EventType.event: + var event_3 = objects[i++ + 2]; + if (entry.listener != null && entry.listener.event) + entry.listener.event(entry, event_3); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].event) + listeners[ii].event(entry, event_3); + break; + } + } + this.clear(); + this.drainDisabled = false; + }; + EventQueue.prototype.clear = function () { + this.objects.length = 0; + }; + return EventQueue; + }()); + spine.EventQueue = EventQueue; + var EventType; + (function (EventType) { + EventType[EventType["start"] = 0] = "start"; + EventType[EventType["interrupt"] = 1] = "interrupt"; + EventType[EventType["end"] = 2] = "end"; + EventType[EventType["dispose"] = 3] = "dispose"; + EventType[EventType["complete"] = 4] = "complete"; + EventType[EventType["event"] = 5] = "event"; + })(EventType = spine.EventType || (spine.EventType = {})); + var AnimationStateAdapter2 = (function () { + function AnimationStateAdapter2() { + } + AnimationStateAdapter2.prototype.start = function (entry) { + }; + AnimationStateAdapter2.prototype.interrupt = function (entry) { + }; + AnimationStateAdapter2.prototype.end = function (entry) { + }; + AnimationStateAdapter2.prototype.dispose = function (entry) { + }; + AnimationStateAdapter2.prototype.complete = function (entry) { + }; + AnimationStateAdapter2.prototype.event = function (entry, event) { + }; + return AnimationStateAdapter2; + }()); + spine.AnimationStateAdapter2 = AnimationStateAdapter2; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AnimationStateData = (function () { + function AnimationStateData(skeletonData) { + this.animationToMixTime = {}; + this.defaultMix = 0; + if (skeletonData == null) + throw new Error("skeletonData cannot be null."); + this.skeletonData = skeletonData; + } + AnimationStateData.prototype.setMix = function (fromName, toName, duration) { + var from = this.skeletonData.findAnimation(fromName); + if (from == null) + throw new Error("Animation not found: " + fromName); + var to = this.skeletonData.findAnimation(toName); + if (to == null) + throw new Error("Animation not found: " + toName); + this.setMixWith(from, to, duration); + }; + AnimationStateData.prototype.setMixWith = function (from, to, duration) { + if (from == null) + throw new Error("from cannot be null."); + if (to == null) + throw new Error("to cannot be null."); + var key = from.name + "." + to.name; + this.animationToMixTime[key] = duration; + }; + AnimationStateData.prototype.getMix = function (from, to) { + var key = from.name + "." + to.name; + var value = this.animationToMixTime[key]; + return value === undefined ? this.defaultMix : value; + }; + return AnimationStateData; + }()); + spine.AnimationStateData = AnimationStateData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AssetManager = (function () { + function AssetManager(textureLoader, pathPrefix) { + if (pathPrefix === void 0) { pathPrefix = ""; } + this.assets = {}; + this.errors = {}; + this.toLoad = 0; + this.loaded = 0; + this.textureLoader = textureLoader; + this.pathPrefix = pathPrefix; + } + AssetManager.downloadText = function (url, success, error) { + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.onload = function () { + if (request.status == 200) { + success(request.responseText); + } + else { + error(request.status, request.responseText); + } + }; + request.onerror = function () { + error(request.status, request.responseText); + }; + request.send(); + }; + AssetManager.downloadBinary = function (url, success, error) { + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.responseType = "arraybuffer"; + request.onload = function () { + if (request.status == 200) { + success(new Uint8Array(request.response)); + } + else { + error(request.status, request.responseText); + } + }; + request.onerror = function () { + error(request.status, request.responseText); + }; + request.send(); + }; + AssetManager.prototype.loadText = function (path, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + path = this.pathPrefix + path; + this.toLoad++; + AssetManager.downloadText(path, function (data) { + _this.assets[path] = data; + if (success) + success(path, data); + _this.toLoad--; + _this.loaded++; + }, function (state, responseText) { + _this.errors[path] = "Couldn't load text " + path + ": status " + status + ", " + responseText; + if (error) + error(path, "Couldn't load text " + path + ": status " + status + ", " + responseText); + _this.toLoad--; + _this.loaded++; + }); + }; + AssetManager.prototype.loadTexture = function (path, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + path = this.pathPrefix + path; + this.toLoad++; + var img = new Image(); + img.crossOrigin = "anonymous"; + img.onload = function (ev) { + var texture = _this.textureLoader(img); + _this.assets[path] = texture; + _this.toLoad--; + _this.loaded++; + if (success) + success(path, img); + }; + img.onerror = function (ev) { + _this.errors[path] = "Couldn't load image " + path; + _this.toLoad--; + _this.loaded++; + if (error) + error(path, "Couldn't load image " + path); + }; + img.src = path; + }; + AssetManager.prototype.loadTextureData = function (path, data, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + path = this.pathPrefix + path; + this.toLoad++; + var img = new Image(); + img.onload = function (ev) { + var texture = _this.textureLoader(img); + _this.assets[path] = texture; + _this.toLoad--; + _this.loaded++; + if (success) + success(path, img); + }; + img.onerror = function (ev) { + _this.errors[path] = "Couldn't load image " + path; + _this.toLoad--; + _this.loaded++; + if (error) + error(path, "Couldn't load image " + path); + }; + img.src = data; + }; + AssetManager.prototype.loadTextureAtlas = function (path, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : ""; + path = this.pathPrefix + path; + this.toLoad++; + AssetManager.downloadText(path, function (atlasData) { + var pagesLoaded = { count: 0 }; + var atlasPages = new Array(); + try { + var atlas = new spine.TextureAtlas(atlasData, function (path) { + atlasPages.push(parent + "/" + path); + var image = document.createElement("img"); + image.width = 16; + image.height = 16; + return new spine.FakeTexture(image); + }); + } + catch (e) { + var ex = e; + _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message; + if (error) + error(path, "Couldn't load texture atlas " + path + ": " + ex.message); + _this.toLoad--; + _this.loaded++; + return; + } + var _loop_1 = function (atlasPage) { + var pageLoadError = false; + _this.loadTexture(atlasPage, function (imagePath, image) { + pagesLoaded.count++; + if (pagesLoaded.count == atlasPages.length) { + if (!pageLoadError) { + try { + var atlas = new spine.TextureAtlas(atlasData, function (path) { + return _this.get(parent + "/" + path); + }); + _this.assets[path] = atlas; + if (success) + success(path, atlas); + _this.toLoad--; + _this.loaded++; + } + catch (e) { + var ex = e; + _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message; + if (error) + error(path, "Couldn't load texture atlas " + path + ": " + ex.message); + _this.toLoad--; + _this.loaded++; + } + } + else { + _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path; + if (error) + error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path); + _this.toLoad--; + _this.loaded++; + } + } + }, function (imagePath, errorMessage) { + pageLoadError = true; + pagesLoaded.count++; + if (pagesLoaded.count == atlasPages.length) { + _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path; + if (error) + error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path); + _this.toLoad--; + _this.loaded++; + } + }); + }; + for (var _i = 0, atlasPages_1 = atlasPages; _i < atlasPages_1.length; _i++) { + var atlasPage = atlasPages_1[_i]; + _loop_1(atlasPage); + } + }, function (state, responseText) { + _this.errors[path] = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText; + if (error) + error(path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText); + _this.toLoad--; + _this.loaded++; + }); + }; + AssetManager.prototype.get = function (path) { + path = this.pathPrefix + path; + return this.assets[path]; + }; + AssetManager.prototype.remove = function (path) { + path = this.pathPrefix + path; + var asset = this.assets[path]; + if (asset.dispose) + asset.dispose(); + this.assets[path] = null; + }; + AssetManager.prototype.removeAll = function () { + for (var key in this.assets) { + var asset = this.assets[key]; + if (asset.dispose) + asset.dispose(); + } + this.assets = {}; + }; + AssetManager.prototype.isLoadingComplete = function () { + return this.toLoad == 0; + }; + AssetManager.prototype.getToLoad = function () { + return this.toLoad; + }; + AssetManager.prototype.getLoaded = function () { + return this.loaded; + }; + AssetManager.prototype.dispose = function () { + this.removeAll(); + }; + AssetManager.prototype.hasErrors = function () { + return Object.keys(this.errors).length > 0; + }; + AssetManager.prototype.getErrors = function () { + return this.errors; + }; + return AssetManager; + }()); + spine.AssetManager = AssetManager; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AtlasAttachmentLoader = (function () { + function AtlasAttachmentLoader(atlas) { + this.atlas = atlas; + } + AtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) + throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")"); + region.renderObject = region; + var attachment = new spine.RegionAttachment(name); + attachment.setRegion(region); + return attachment; + }; + AtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) + throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")"); + region.renderObject = region; + var attachment = new spine.MeshAttachment(name); + attachment.region = region; + return attachment; + }; + AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) { + return new spine.BoundingBoxAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) { + return new spine.PathAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) { + return new spine.PointAttachment(name); + }; + AtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) { + return new spine.ClippingAttachment(name); + }; + return AtlasAttachmentLoader; + }()); + spine.AtlasAttachmentLoader = AtlasAttachmentLoader; +})(spine || (spine = {})); +var spine; +(function (spine) { + var BlendMode; + (function (BlendMode) { + BlendMode[BlendMode["Normal"] = 0] = "Normal"; + BlendMode[BlendMode["Additive"] = 1] = "Additive"; + BlendMode[BlendMode["Multiply"] = 2] = "Multiply"; + BlendMode[BlendMode["Screen"] = 3] = "Screen"; + })(BlendMode = spine.BlendMode || (spine.BlendMode = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Bone = (function () { + function Bone(data, skeleton, parent) { + this.children = new Array(); + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 0; + this.scaleY = 0; + this.shearX = 0; + this.shearY = 0; + this.ax = 0; + this.ay = 0; + this.arotation = 0; + this.ascaleX = 0; + this.ascaleY = 0; + this.ashearX = 0; + this.ashearY = 0; + this.appliedValid = false; + this.a = 0; + this.b = 0; + this.worldX = 0; + this.c = 0; + this.d = 0; + this.worldY = 0; + this.sorted = false; + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.skeleton = skeleton; + this.parent = parent; + this.setToSetupPose(); + } + Bone.prototype.update = function () { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + Bone.prototype.updateWorldTransform = function () { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + Bone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) { + this.ax = x; + this.ay = y; + this.arotation = rotation; + this.ascaleX = scaleX; + this.ascaleY = scaleY; + this.ashearX = shearX; + this.ashearY = shearY; + this.appliedValid = true; + var parent = this.parent; + if (parent == null) { + var rotationY = rotation + 90 + shearY; + var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(rotationY) * scaleY; + var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(rotationY) * scaleY; + var skeleton = this.skeleton; + if (skeleton.flipX) { + x = -x; + la = -la; + lb = -lb; + } + if (skeleton.flipY) { + y = -y; + lc = -lc; + ld = -ld; + } + this.a = la; + this.b = lb; + this.c = lc; + this.d = ld; + this.worldX = x + skeleton.x; + this.worldY = y + skeleton.y; + return; + } + var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; + this.worldX = pa * x + pb * y + parent.worldX; + this.worldY = pc * x + pd * y + parent.worldY; + switch (this.data.transformMode) { + case spine.TransformMode.Normal: { + var rotationY = rotation + 90 + shearY; + var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(rotationY) * scaleY; + var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(rotationY) * scaleY; + this.a = pa * la + pb * lc; + this.b = pa * lb + pb * ld; + this.c = pc * la + pd * lc; + this.d = pc * lb + pd * ld; + return; + } + case spine.TransformMode.OnlyTranslation: { + var rotationY = rotation + 90 + shearY; + this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + this.b = spine.MathUtils.cosDeg(rotationY) * scaleY; + this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + this.d = spine.MathUtils.sinDeg(rotationY) * scaleY; + break; + } + case spine.TransformMode.NoRotationOrReflection: { + var s = pa * pa + pc * pc; + var prx = 0; + if (s > 0.0001) { + s = Math.abs(pa * pd - pb * pc) / s; + pb = pc * s; + pd = pa * s; + prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg; + } + else { + pa = 0; + pc = 0; + prx = 90 - Math.atan2(pd, pb) * spine.MathUtils.radDeg; + } + var rx = rotation + shearX - prx; + var ry = rotation + shearY - prx + 90; + var la = spine.MathUtils.cosDeg(rx) * scaleX; + var lb = spine.MathUtils.cosDeg(ry) * scaleY; + var lc = spine.MathUtils.sinDeg(rx) * scaleX; + var ld = spine.MathUtils.sinDeg(ry) * scaleY; + this.a = pa * la - pb * lc; + this.b = pa * lb - pb * ld; + this.c = pc * la + pd * lc; + this.d = pc * lb + pd * ld; + break; + } + case spine.TransformMode.NoScale: + case spine.TransformMode.NoScaleOrReflection: { + var cos = spine.MathUtils.cosDeg(rotation); + var sin = spine.MathUtils.sinDeg(rotation); + var za = pa * cos + pb * sin; + var zc = pc * cos + pd * sin; + var s = Math.sqrt(za * za + zc * zc); + if (s > 0.00001) + s = 1 / s; + za *= s; + zc *= s; + s = Math.sqrt(za * za + zc * zc); + var r = Math.PI / 2 + Math.atan2(zc, za); + var zb = Math.cos(r) * s; + var zd = Math.sin(r) * s; + var la = spine.MathUtils.cosDeg(shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(90 + shearY) * scaleY; + var lc = spine.MathUtils.sinDeg(shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(90 + shearY) * scaleY; + if (this.data.transformMode != spine.TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : this.skeleton.flipX != this.skeleton.flipY) { + zb = -zb; + zd = -zd; + } + this.a = za * la + zb * lc; + this.b = za * lb + zb * ld; + this.c = zc * la + zd * lc; + this.d = zc * lb + zd * ld; + return; + } + } + if (this.skeleton.flipX) { + this.a = -this.a; + this.b = -this.b; + } + if (this.skeleton.flipY) { + this.c = -this.c; + this.d = -this.d; + } + }; + Bone.prototype.setToSetupPose = function () { + var data = this.data; + this.x = data.x; + this.y = data.y; + this.rotation = data.rotation; + this.scaleX = data.scaleX; + this.scaleY = data.scaleY; + this.shearX = data.shearX; + this.shearY = data.shearY; + }; + Bone.prototype.getWorldRotationX = function () { + return Math.atan2(this.c, this.a) * spine.MathUtils.radDeg; + }; + Bone.prototype.getWorldRotationY = function () { + return Math.atan2(this.d, this.b) * spine.MathUtils.radDeg; + }; + Bone.prototype.getWorldScaleX = function () { + return Math.sqrt(this.a * this.a + this.c * this.c); + }; + Bone.prototype.getWorldScaleY = function () { + return Math.sqrt(this.b * this.b + this.d * this.d); + }; + Bone.prototype.updateAppliedTransform = function () { + this.appliedValid = true; + var parent = this.parent; + if (parent == null) { + this.ax = this.worldX; + this.ay = this.worldY; + this.arotation = Math.atan2(this.c, this.a) * spine.MathUtils.radDeg; + this.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c); + this.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d); + this.ashearX = 0; + this.ashearY = Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * spine.MathUtils.radDeg; + return; + } + var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; + var pid = 1 / (pa * pd - pb * pc); + var dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY; + this.ax = (dx * pd * pid - dy * pb * pid); + this.ay = (dy * pa * pid - dx * pc * pid); + var ia = pid * pd; + var id = pid * pa; + var ib = pid * pb; + var ic = pid * pc; + var ra = ia * this.a - ib * this.c; + var rb = ia * this.b - ib * this.d; + var rc = id * this.c - ic * this.a; + var rd = id * this.d - ic * this.b; + this.ashearX = 0; + this.ascaleX = Math.sqrt(ra * ra + rc * rc); + if (this.ascaleX > 0.0001) { + var det = ra * rd - rb * rc; + this.ascaleY = det / this.ascaleX; + this.ashearY = Math.atan2(ra * rb + rc * rd, det) * spine.MathUtils.radDeg; + this.arotation = Math.atan2(rc, ra) * spine.MathUtils.radDeg; + } + else { + this.ascaleX = 0; + this.ascaleY = Math.sqrt(rb * rb + rd * rd); + this.ashearY = 0; + this.arotation = 90 - Math.atan2(rd, rb) * spine.MathUtils.radDeg; + } + }; + Bone.prototype.worldToLocal = function (world) { + var a = this.a, b = this.b, c = this.c, d = this.d; + var invDet = 1 / (a * d - b * c); + var x = world.x - this.worldX, y = world.y - this.worldY; + world.x = (x * d * invDet - y * b * invDet); + world.y = (y * a * invDet - x * c * invDet); + return world; + }; + Bone.prototype.localToWorld = function (local) { + var x = local.x, y = local.y; + local.x = x * this.a + y * this.b + this.worldX; + local.y = x * this.c + y * this.d + this.worldY; + return local; + }; + Bone.prototype.worldToLocalRotation = function (worldRotation) { + var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation); + return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg; + }; + Bone.prototype.localToWorldRotation = function (localRotation) { + var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation); + return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg; + }; + Bone.prototype.rotateWorld = function (degrees) { + var a = this.a, b = this.b, c = this.c, d = this.d; + var cos = spine.MathUtils.cosDeg(degrees), sin = spine.MathUtils.sinDeg(degrees); + this.a = cos * a - sin * c; + this.b = cos * b - sin * d; + this.c = sin * a + cos * c; + this.d = sin * b + cos * d; + this.appliedValid = false; + }; + return Bone; + }()); + spine.Bone = Bone; +})(spine || (spine = {})); +var spine; +(function (spine) { + var BoneData = (function () { + function BoneData(index, name, parent) { + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 1; + this.scaleY = 1; + this.shearX = 0; + this.shearY = 0; + this.transformMode = TransformMode.Normal; + if (index < 0) + throw new Error("index must be >= 0."); + if (name == null) + throw new Error("name cannot be null."); + this.index = index; + this.name = name; + this.parent = parent; + } + return BoneData; + }()); + spine.BoneData = BoneData; + var TransformMode; + (function (TransformMode) { + TransformMode[TransformMode["Normal"] = 0] = "Normal"; + TransformMode[TransformMode["OnlyTranslation"] = 1] = "OnlyTranslation"; + TransformMode[TransformMode["NoRotationOrReflection"] = 2] = "NoRotationOrReflection"; + TransformMode[TransformMode["NoScale"] = 3] = "NoScale"; + TransformMode[TransformMode["NoScaleOrReflection"] = 4] = "NoScaleOrReflection"; + })(TransformMode = spine.TransformMode || (spine.TransformMode = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Event = (function () { + function Event(time, data) { + if (data == null) + throw new Error("data cannot be null."); + this.time = time; + this.data = data; + } + return Event; + }()); + spine.Event = Event; +})(spine || (spine = {})); +var spine; +(function (spine) { + var EventData = (function () { + function EventData(name) { + this.name = name; + } + return EventData; + }()); + spine.EventData = EventData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var IkConstraint = (function () { + function IkConstraint(data, skeleton) { + this.mix = 1; + this.bendDirection = 0; + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.mix = data.mix; + this.bendDirection = data.bendDirection; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + IkConstraint.prototype.getOrder = function () { + return this.data.order; + }; + IkConstraint.prototype.apply = function () { + this.update(); + }; + IkConstraint.prototype.update = function () { + var target = this.target; + var bones = this.bones; + switch (bones.length) { + case 1: + this.apply1(bones[0], target.worldX, target.worldY, this.mix); + break; + case 2: + this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.mix); + break; + } + }; + IkConstraint.prototype.apply1 = function (bone, targetX, targetY, alpha) { + if (!bone.appliedValid) + bone.updateAppliedTransform(); + var p = bone.parent; + var id = 1 / (p.a * p.d - p.b * p.c); + var x = targetX - p.worldX, y = targetY - p.worldY; + var tx = (x * p.d - y * p.b) * id - bone.ax, ty = (y * p.a - x * p.c) * id - bone.ay; + var rotationIK = Math.atan2(ty, tx) * spine.MathUtils.radDeg - bone.ashearX - bone.arotation; + if (bone.ascaleX < 0) + rotationIK += 180; + if (rotationIK > 180) + rotationIK -= 360; + else if (rotationIK < -180) + rotationIK += 360; + bone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, bone.ascaleX, bone.ascaleY, bone.ashearX, bone.ashearY); + }; + IkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, alpha) { + if (alpha == 0) { + child.updateWorldTransform(); + return; + } + if (!parent.appliedValid) + parent.updateAppliedTransform(); + if (!child.appliedValid) + child.updateAppliedTransform(); + var px = parent.ax, py = parent.ay, psx = parent.ascaleX, psy = parent.ascaleY, csx = child.ascaleX; + var os1 = 0, os2 = 0, s2 = 0; + if (psx < 0) { + psx = -psx; + os1 = 180; + s2 = -1; + } + else { + os1 = 0; + s2 = 1; + } + if (psy < 0) { + psy = -psy; + s2 = -s2; + } + if (csx < 0) { + csx = -csx; + os2 = 180; + } + else + os2 = 0; + var cx = child.ax, cy = 0, cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d; + var u = Math.abs(psx - psy) <= 0.0001; + if (!u) { + cy = 0; + cwx = a * cx + parent.worldX; + cwy = c * cx + parent.worldY; + } + else { + cy = child.ay; + cwx = a * cx + b * cy + parent.worldX; + cwy = c * cx + d * cy + parent.worldY; + } + var pp = parent.parent; + a = pp.a; + b = pp.b; + c = pp.c; + d = pp.d; + var id = 1 / (a * d - b * c), x = targetX - pp.worldX, y = targetY - pp.worldY; + var tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py; + x = cwx - pp.worldX; + y = cwy - pp.worldY; + var dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py; + var l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1 = 0, a2 = 0; + outer: if (u) { + l2 *= psx; + var cos = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2); + if (cos < -1) + cos = -1; + else if (cos > 1) + cos = 1; + a2 = Math.acos(cos) * bendDir; + a = l1 + l2 * cos; + b = l2 * Math.sin(a2); + a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b); + } + else { + a = psx * l2; + b = psy * l2; + var aa = a * a, bb = b * b, dd = tx * tx + ty * ty, ta = Math.atan2(ty, tx); + c = bb * l1 * l1 + aa * dd - aa * bb; + var c1 = -2 * bb * l1, c2 = bb - aa; + d = c1 * c1 - 4 * c2 * c; + if (d >= 0) { + var q = Math.sqrt(d); + if (c1 < 0) + q = -q; + q = -(c1 + q) / 2; + var r0 = q / c2, r1 = c / q; + var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1; + if (r * r <= dd) { + y = Math.sqrt(dd - r * r) * bendDir; + a1 = ta - Math.atan2(y, r); + a2 = Math.atan2(y / psy, (r - l1) / psx); + break outer; + } + } + var minAngle = spine.MathUtils.PI, minX = l1 - a, minDist = minX * minX, minY = 0; + var maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0; + c = -a * l1 / (aa - bb); + if (c >= -1 && c <= 1) { + c = Math.acos(c); + x = a * Math.cos(c) + l1; + y = b * Math.sin(c); + d = x * x + y * y; + if (d < minDist) { + minAngle = c; + minDist = d; + minX = x; + minY = y; + } + if (d > maxDist) { + maxAngle = c; + maxDist = d; + maxX = x; + maxY = y; + } + } + if (dd <= (minDist + maxDist) / 2) { + a1 = ta - Math.atan2(minY * bendDir, minX); + a2 = minAngle * bendDir; + } + else { + a1 = ta - Math.atan2(maxY * bendDir, maxX); + a2 = maxAngle * bendDir; + } + } + var os = Math.atan2(cy, cx) * s2; + var rotation = parent.arotation; + a1 = (a1 - os) * spine.MathUtils.radDeg + os1 - rotation; + if (a1 > 180) + a1 -= 360; + else if (a1 < -180) + a1 += 360; + parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, parent.ascaleX, parent.ascaleY, 0, 0); + rotation = child.arotation; + a2 = ((a2 + os) * spine.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation; + if (a2 > 180) + a2 -= 360; + else if (a2 < -180) + a2 += 360; + child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY); + }; + return IkConstraint; + }()); + spine.IkConstraint = IkConstraint; +})(spine || (spine = {})); +var spine; +(function (spine) { + var IkConstraintData = (function () { + function IkConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.bendDirection = 1; + this.mix = 1; + this.name = name; + } + return IkConstraintData; + }()); + spine.IkConstraintData = IkConstraintData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PathConstraint = (function () { + function PathConstraint(data, skeleton) { + this.position = 0; + this.spacing = 0; + this.rotateMix = 0; + this.translateMix = 0; + this.spaces = new Array(); + this.positions = new Array(); + this.world = new Array(); + this.curves = new Array(); + this.lengths = new Array(); + this.segments = new Array(); + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.bones = new Array(); + for (var i = 0, n = data.bones.length; i < n; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findSlot(data.target.name); + this.position = data.position; + this.spacing = data.spacing; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + } + PathConstraint.prototype.apply = function () { + this.update(); + }; + PathConstraint.prototype.update = function () { + var attachment = this.target.getAttachment(); + if (!(attachment instanceof spine.PathAttachment)) + return; + var rotateMix = this.rotateMix, translateMix = this.translateMix; + var translate = translateMix > 0, rotate = rotateMix > 0; + if (!translate && !rotate) + return; + var data = this.data; + var spacingMode = data.spacingMode; + var lengthSpacing = spacingMode == spine.SpacingMode.Length; + var rotateMode = data.rotateMode; + var tangents = rotateMode == spine.RotateMode.Tangent, scale = rotateMode == spine.RotateMode.ChainScale; + var boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1; + var bones = this.bones; + var spaces = spine.Utils.setArraySize(this.spaces, spacesCount), lengths = null; + var spacing = this.spacing; + if (scale || lengthSpacing) { + if (scale) + lengths = spine.Utils.setArraySize(this.lengths, boneCount); + for (var i = 0, n = spacesCount - 1; i < n;) { + var bone = bones[i]; + var setupLength = bone.data.length; + if (setupLength < PathConstraint.epsilon) { + if (scale) + lengths[i] = 0; + spaces[++i] = 0; + } + else { + var x = setupLength * bone.a, y = setupLength * bone.c; + var length_1 = Math.sqrt(x * x + y * y); + if (scale) + lengths[i] = length_1; + spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength; + } + } + } + else { + for (var i = 1; i < spacesCount; i++) + spaces[i] = spacing; + } + var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent); + var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation; + var tip = false; + if (offsetRotation == 0) + tip = rotateMode == spine.RotateMode.Chain; + else { + tip = false; + var p = this.target.bone; + offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + } + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + bone.worldX += (boneX - bone.worldX) * translateMix; + bone.worldY += (boneY - bone.worldY) * translateMix; + var x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY; + if (scale) { + var length_2 = lengths[i]; + if (length_2 != 0) { + var s = (Math.sqrt(dx * dx + dy * dy) / length_2 - 1) * rotateMix + 1; + bone.a *= s; + bone.c *= s; + } + } + boneX = x; + boneY = y; + if (rotate) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d, r = 0, cos = 0, sin = 0; + if (tangents) + r = positions[p - 1]; + else if (spaces[i + 1] == 0) + r = positions[p + 2]; + else + r = Math.atan2(dy, dx); + r -= Math.atan2(c, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_3 = bone.data.length; + boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix; + boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix; + } + else { + r += offsetRotation; + } + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + } + bone.appliedValid = false; + } + }; + PathConstraint.prototype.computeWorldPositions = function (path, spacesCount, tangents, percentPosition, percentSpacing) { + var target = this.target; + var position = this.position; + var spaces = this.spaces, out = spine.Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null; + var closed = path.closed; + var verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PathConstraint.NONE; + if (!path.constantSpeed) { + var lengths = path.lengths; + curveCount -= closed ? 1 : 2; + var pathLength_1 = lengths[curveCount]; + if (percentPosition) + position *= pathLength_1; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) + spaces[i] *= pathLength_1; + } + world = spine.Utils.setArraySize(this.world, 8); + for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength_1; + if (p < 0) + p += pathLength_1; + curve = 0; + } + else if (p < 0) { + if (prevCurve != PathConstraint.BEFORE) { + prevCurve = PathConstraint.BEFORE; + path.computeWorldVertices(target, 2, 4, world, 0, 2); + } + this.addBeforePosition(p, world, 0, out, o); + continue; + } + else if (p > pathLength_1) { + if (prevCurve != PathConstraint.AFTER) { + prevCurve = PathConstraint.AFTER; + path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2); + } + this.addAfterPosition(p - pathLength_1, world, 0, out, o); + continue; + } + for (;; curve++) { + var length_4 = lengths[curve]; + if (p > length_4) + continue; + if (curve == 0) + p /= length_4; + else { + var prev = lengths[curve - 1]; + p = (p - prev) / (length_4 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + if (closed && curve == curveCount) { + path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2); + path.computeWorldVertices(target, 0, 4, world, 4, 2); + } + else + path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2); + } + this.addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], out, o, tangents || (i > 0 && space == 0)); + } + return out; + } + if (closed) { + verticesLength += 2; + world = spine.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2); + path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); + world[verticesLength - 2] = world[0]; + world[verticesLength - 1] = world[1]; + } + else { + curveCount--; + verticesLength -= 4; + world = spine.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength, world, 0, 2); + } + var curves = spine.Utils.setArraySize(this.curves, curveCount); + var pathLength = 0; + var x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; + var tmpx = 0, tmpy = 0, dddfx = 0, dddfy = 0, ddfx = 0, ddfy = 0, dfx = 0, dfy = 0; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = world[w]; + cy1 = world[w + 1]; + cx2 = world[w + 2]; + cy2 = world[w + 3]; + x2 = world[w + 4]; + y2 = world[w + 5]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; + tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + if (percentPosition) + position *= pathLength; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) + spaces[i] *= pathLength; + } + var segments = this.segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength; + if (p < 0) + p += pathLength; + curve = 0; + } + else if (p < 0) { + this.addBeforePosition(p, world, 0, out, o); + continue; + } + else if (p > pathLength) { + this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o); + continue; + } + for (;; curve++) { + var length_5 = curves[curve]; + if (p > length_5) + continue; + if (curve == 0) + p /= length_5; + else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_5 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + var ii = curve * 6; + x1 = world[ii]; + y1 = world[ii + 1]; + cx1 = world[ii + 2]; + cy1 = world[ii + 3]; + cx2 = world[ii + 4]; + cy2 = world[ii + 5]; + x2 = world[ii + 6]; + y2 = world[ii + 7]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.03; + tmpy = (y1 - cy1 * 2 + cy2) * 0.03; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + p *= curveLength; + for (;; segment++) { + var length_6 = segments[segment]; + if (p > length_6) + continue; + if (segment == 0) + p /= length_6; + else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_6 - prev); + } + break; + } + this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0)); + } + return out; + }; + PathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) { + var x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) { + var x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) { + if (p == 0 || isNaN(p)) + p = 0.0001; + var tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u; + var ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p; + var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt; + out[o] = x; + out[o + 1] = y; + if (tangents) + out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt)); + }; + PathConstraint.prototype.getOrder = function () { + return this.data.order; + }; + PathConstraint.NONE = -1; + PathConstraint.BEFORE = -2; + PathConstraint.AFTER = -3; + PathConstraint.epsilon = 0.00001; + return PathConstraint; + }()); + spine.PathConstraint = PathConstraint; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PathConstraintData = (function () { + function PathConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.name = name; + } + return PathConstraintData; + }()); + spine.PathConstraintData = PathConstraintData; + var PositionMode; + (function (PositionMode) { + PositionMode[PositionMode["Fixed"] = 0] = "Fixed"; + PositionMode[PositionMode["Percent"] = 1] = "Percent"; + })(PositionMode = spine.PositionMode || (spine.PositionMode = {})); + var SpacingMode; + (function (SpacingMode) { + SpacingMode[SpacingMode["Length"] = 0] = "Length"; + SpacingMode[SpacingMode["Fixed"] = 1] = "Fixed"; + SpacingMode[SpacingMode["Percent"] = 2] = "Percent"; + })(SpacingMode = spine.SpacingMode || (spine.SpacingMode = {})); + var RotateMode; + (function (RotateMode) { + RotateMode[RotateMode["Tangent"] = 0] = "Tangent"; + RotateMode[RotateMode["Chain"] = 1] = "Chain"; + RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; + })(RotateMode = spine.RotateMode || (spine.RotateMode = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Assets = (function () { + function Assets(clientId) { + this.toLoad = new Array(); + this.assets = {}; + this.clientId = clientId; + } + Assets.prototype.loaded = function () { + var i = 0; + for (var v in this.assets) + i++; + return i; + }; + return Assets; + }()); + var SharedAssetManager = (function () { + function SharedAssetManager(pathPrefix) { + if (pathPrefix === void 0) { pathPrefix = ""; } + this.clientAssets = {}; + this.queuedAssets = {}; + this.rawAssets = {}; + this.errors = {}; + this.pathPrefix = pathPrefix; + } + SharedAssetManager.prototype.queueAsset = function (clientId, textureLoader, path) { + var clientAssets = this.clientAssets[clientId]; + if (clientAssets === null || clientAssets === undefined) { + clientAssets = new Assets(clientId); + this.clientAssets[clientId] = clientAssets; + } + if (textureLoader !== null) + clientAssets.textureLoader = textureLoader; + clientAssets.toLoad.push(path); + if (this.queuedAssets[path] === path) { + return false; + } + else { + this.queuedAssets[path] = path; + return true; + } + }; + SharedAssetManager.prototype.loadText = function (clientId, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, null, path)) + return; + var request = new XMLHttpRequest(); + request.onreadystatechange = function () { + if (request.readyState == XMLHttpRequest.DONE) { + if (request.status >= 200 && request.status < 300) { + _this.rawAssets[path] = request.responseText; + } + else { + _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText; + } + } + }; + request.open("GET", path, true); + request.send(); + }; + SharedAssetManager.prototype.loadJson = function (clientId, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, null, path)) + return; + var request = new XMLHttpRequest(); + request.onreadystatechange = function () { + if (request.readyState == XMLHttpRequest.DONE) { + if (request.status >= 200 && request.status < 300) { + _this.rawAssets[path] = JSON.parse(request.responseText); + } + else { + _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText; + } + } + }; + request.open("GET", path, true); + request.send(); + }; + SharedAssetManager.prototype.loadTexture = function (clientId, textureLoader, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, textureLoader, path)) + return; + var img = new Image(); + img.src = path; + img.crossOrigin = "anonymous"; + img.onload = function (ev) { + _this.rawAssets[path] = img; + }; + img.onerror = function (ev) { + _this.errors[path] = "Couldn't load image " + path; + }; + }; + SharedAssetManager.prototype.get = function (clientId, path) { + path = this.pathPrefix + path; + var clientAssets = this.clientAssets[clientId]; + if (clientAssets === null || clientAssets === undefined) + return true; + return clientAssets.assets[path]; + }; + SharedAssetManager.prototype.updateClientAssets = function (clientAssets) { + for (var i = 0; i < clientAssets.toLoad.length; i++) { + var path = clientAssets.toLoad[i]; + var asset = clientAssets.assets[path]; + if (asset === null || asset === undefined) { + var rawAsset = this.rawAssets[path]; + if (rawAsset === null || rawAsset === undefined) + continue; + if (rawAsset instanceof HTMLImageElement) { + clientAssets.assets[path] = clientAssets.textureLoader(rawAsset); + } + else { + clientAssets.assets[path] = rawAsset; + } + } + } + }; + SharedAssetManager.prototype.isLoadingComplete = function (clientId) { + var clientAssets = this.clientAssets[clientId]; + if (clientAssets === null || clientAssets === undefined) + return true; + this.updateClientAssets(clientAssets); + return clientAssets.toLoad.length == clientAssets.loaded(); + }; + SharedAssetManager.prototype.dispose = function () { + }; + SharedAssetManager.prototype.hasErrors = function () { + return Object.keys(this.errors).length > 0; + }; + SharedAssetManager.prototype.getErrors = function () { + return this.errors; + }; + return SharedAssetManager; + }()); + spine.SharedAssetManager = SharedAssetManager; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Skeleton = (function () { + function Skeleton(data) { + this._updateCache = new Array(); + this.updateCacheReset = new Array(); + this.time = 0; + this.flipX = false; + this.flipY = false; + this.x = 0; + this.y = 0; + if (data == null) + throw new Error("data cannot be null."); + this.data = data; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) { + var boneData = data.bones[i]; + var bone = void 0; + if (boneData.parent == null) + bone = new spine.Bone(boneData, this, null); + else { + var parent_1 = this.bones[boneData.parent.index]; + bone = new spine.Bone(boneData, this, parent_1); + parent_1.children.push(bone); + } + this.bones.push(bone); + } + this.slots = new Array(); + this.drawOrder = new Array(); + for (var i = 0; i < data.slots.length; i++) { + var slotData = data.slots[i]; + var bone = this.bones[slotData.boneData.index]; + var slot = new spine.Slot(slotData, bone); + this.slots.push(slot); + this.drawOrder.push(slot); + } + this.ikConstraints = new Array(); + for (var i = 0; i < data.ikConstraints.length; i++) { + var ikConstraintData = data.ikConstraints[i]; + this.ikConstraints.push(new spine.IkConstraint(ikConstraintData, this)); + } + this.transformConstraints = new Array(); + for (var i = 0; i < data.transformConstraints.length; i++) { + var transformConstraintData = data.transformConstraints[i]; + this.transformConstraints.push(new spine.TransformConstraint(transformConstraintData, this)); + } + this.pathConstraints = new Array(); + for (var i = 0; i < data.pathConstraints.length; i++) { + var pathConstraintData = data.pathConstraints[i]; + this.pathConstraints.push(new spine.PathConstraint(pathConstraintData, this)); + } + this.color = new spine.Color(1, 1, 1, 1); + this.updateCache(); + } + Skeleton.prototype.updateCache = function () { + var updateCache = this._updateCache; + updateCache.length = 0; + this.updateCacheReset.length = 0; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + bones[i].sorted = false; + var ikConstraints = this.ikConstraints; + var transformConstraints = this.transformConstraints; + var pathConstraints = this.pathConstraints; + var ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length; + var constraintCount = ikCount + transformCount + pathCount; + outer: for (var i = 0; i < constraintCount; i++) { + for (var ii = 0; ii < ikCount; ii++) { + var constraint = ikConstraints[ii]; + if (constraint.data.order == i) { + this.sortIkConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < transformCount; ii++) { + var constraint = transformConstraints[ii]; + if (constraint.data.order == i) { + this.sortTransformConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < pathCount; ii++) { + var constraint = pathConstraints[ii]; + if (constraint.data.order == i) { + this.sortPathConstraint(constraint); + continue outer; + } + } + } + for (var i = 0, n = bones.length; i < n; i++) + this.sortBone(bones[i]); + }; + Skeleton.prototype.sortIkConstraint = function (constraint) { + var target = constraint.target; + this.sortBone(target); + var constrained = constraint.bones; + var parent = constrained[0]; + this.sortBone(parent); + if (constrained.length > 1) { + var child = constrained[constrained.length - 1]; + if (!(this._updateCache.indexOf(child) > -1)) + this.updateCacheReset.push(child); + } + this._updateCache.push(constraint); + this.sortReset(parent.children); + constrained[constrained.length - 1].sorted = true; + }; + Skeleton.prototype.sortPathConstraint = function (constraint) { + var slot = constraint.target; + var slotIndex = slot.data.index; + var slotBone = slot.bone; + if (this.skin != null) + this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone); + if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin) + this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone); + for (var i = 0, n = this.data.skins.length; i < n; i++) + this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone); + var attachment = slot.getAttachment(); + if (attachment instanceof spine.PathAttachment) + this.sortPathConstraintAttachmentWith(attachment, slotBone); + var constrained = constraint.bones; + var boneCount = constrained.length; + for (var i = 0; i < boneCount; i++) + this.sortBone(constrained[i]); + this._updateCache.push(constraint); + for (var i = 0; i < boneCount; i++) + this.sortReset(constrained[i].children); + for (var i = 0; i < boneCount; i++) + constrained[i].sorted = true; + }; + Skeleton.prototype.sortTransformConstraint = function (constraint) { + this.sortBone(constraint.target); + var constrained = constraint.bones; + var boneCount = constrained.length; + if (constraint.data.local) { + for (var i = 0; i < boneCount; i++) { + var child = constrained[i]; + this.sortBone(child.parent); + if (!(this._updateCache.indexOf(child) > -1)) + this.updateCacheReset.push(child); + } + } + else { + for (var i = 0; i < boneCount; i++) { + this.sortBone(constrained[i]); + } + } + this._updateCache.push(constraint); + for (var ii = 0; ii < boneCount; ii++) + this.sortReset(constrained[ii].children); + for (var ii = 0; ii < boneCount; ii++) + constrained[ii].sorted = true; + }; + Skeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) { + var attachments = skin.attachments[slotIndex]; + if (!attachments) + return; + for (var key in attachments) { + this.sortPathConstraintAttachmentWith(attachments[key], slotBone); + } + }; + Skeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) { + if (!(attachment instanceof spine.PathAttachment)) + return; + var pathBones = attachment.bones; + if (pathBones == null) + this.sortBone(slotBone); + else { + var bones = this.bones; + var i = 0; + while (i < pathBones.length) { + var boneCount = pathBones[i++]; + for (var n = i + boneCount; i < n; i++) { + var boneIndex = pathBones[i]; + this.sortBone(bones[boneIndex]); + } + } + } + }; + Skeleton.prototype.sortBone = function (bone) { + if (bone.sorted) + return; + var parent = bone.parent; + if (parent != null) + this.sortBone(parent); + bone.sorted = true; + this._updateCache.push(bone); + }; + Skeleton.prototype.sortReset = function (bones) { + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.sorted) + this.sortReset(bone.children); + bone.sorted = false; + } + }; + Skeleton.prototype.updateWorldTransform = function () { + var updateCacheReset = this.updateCacheReset; + for (var i = 0, n = updateCacheReset.length; i < n; i++) { + var bone = updateCacheReset[i]; + bone.ax = bone.x; + bone.ay = bone.y; + bone.arotation = bone.rotation; + bone.ascaleX = bone.scaleX; + bone.ascaleY = bone.scaleY; + bone.ashearX = bone.shearX; + bone.ashearY = bone.shearY; + bone.appliedValid = true; + } + var updateCache = this._updateCache; + for (var i = 0, n = updateCache.length; i < n; i++) + updateCache[i].update(); + }; + Skeleton.prototype.setToSetupPose = function () { + this.setBonesToSetupPose(); + this.setSlotsToSetupPose(); + }; + Skeleton.prototype.setBonesToSetupPose = function () { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + bones[i].setToSetupPose(); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + constraint.bendDirection = constraint.data.bendDirection; + constraint.mix = constraint.data.mix; + } + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + var data = constraint.data; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + } + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + var data = constraint.data; + constraint.position = data.position; + constraint.spacing = data.spacing; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + } + }; + Skeleton.prototype.setSlotsToSetupPose = function () { + var slots = this.slots; + spine.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length); + for (var i = 0, n = slots.length; i < n; i++) + slots[i].setToSetupPose(); + }; + Skeleton.prototype.getRootBone = function () { + if (this.bones.length == 0) + return null; + return this.bones[0]; + }; + Skeleton.prototype.findBone = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.data.name == boneName) + return bone; + } + return null; + }; + Skeleton.prototype.findBoneIndex = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].data.name == boneName) + return i; + return -1; + }; + Skeleton.prototype.findSlot = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) + return slot; + } + return null; + }; + Skeleton.prototype.findSlotIndex = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + if (slots[i].data.name == slotName) + return i; + return -1; + }; + Skeleton.prototype.setSkinByName = function (skinName) { + var skin = this.data.findSkin(skinName); + if (skin == null) + throw new Error("Skin not found: " + skinName); + this.setSkin(skin); + }; + Skeleton.prototype.setSkin = function (newSkin) { + if (newSkin != null) { + if (this.skin != null) + newSkin.attachAll(this, this.skin); + else { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var name_1 = slot.data.attachmentName; + if (name_1 != null) { + var attachment = newSkin.getAttachment(i, name_1); + if (attachment != null) + slot.setAttachment(attachment); + } + } + } + } + this.skin = newSkin; + }; + Skeleton.prototype.getAttachmentByName = function (slotName, attachmentName) { + return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName); + }; + Skeleton.prototype.getAttachment = function (slotIndex, attachmentName) { + if (attachmentName == null) + throw new Error("attachmentName cannot be null."); + if (this.skin != null) { + var attachment = this.skin.getAttachment(slotIndex, attachmentName); + if (attachment != null) + return attachment; + } + if (this.data.defaultSkin != null) + return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); + return null; + }; + Skeleton.prototype.setAttachment = function (slotName, attachmentName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) { + var attachment = null; + if (attachmentName != null) { + attachment = this.getAttachment(i, attachmentName); + if (attachment == null) + throw new Error("Attachment not found: " + attachmentName + ", for slot: " + slotName); + } + slot.setAttachment(attachment); + return; + } + } + throw new Error("Slot not found: " + slotName); + }; + Skeleton.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var ikConstraint = ikConstraints[i]; + if (ikConstraint.data.name == constraintName) + return ikConstraint; + } + return null; + }; + Skeleton.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.data.name == constraintName) + return constraint; + } + return null; + }; + Skeleton.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.data.name == constraintName) + return constraint; + } + return null; + }; + Skeleton.prototype.getBounds = function (offset, size, temp) { + if (offset == null) + throw new Error("offset cannot be null."); + if (size == null) + throw new Error("size cannot be null."); + var drawOrder = this.drawOrder; + var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + var verticesLength = 0; + var vertices = null; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.RegionAttachment) { + verticesLength = 8; + vertices = spine.Utils.setArraySize(temp, verticesLength, 0); + attachment.computeWorldVertices(slot.bone, vertices, 0, 2); + } + else if (attachment instanceof spine.MeshAttachment) { + var mesh = attachment; + verticesLength = mesh.worldVerticesLength; + vertices = spine.Utils.setArraySize(temp, verticesLength, 0); + mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); + } + if (vertices != null) { + for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) { + var x = vertices[ii], y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + } + offset.set(minX, minY); + size.set(maxX - minX, maxY - minY); + }; + Skeleton.prototype.update = function (delta) { + this.time += delta; + }; + return Skeleton; + }()); + spine.Skeleton = Skeleton; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonBounds = (function () { + function SkeletonBounds() { + this.minX = 0; + this.minY = 0; + this.maxX = 0; + this.maxY = 0; + this.boundingBoxes = new Array(); + this.polygons = new Array(); + this.polygonPool = new spine.Pool(function () { + return spine.Utils.newFloatArray(16); + }); + } + SkeletonBounds.prototype.update = function (skeleton, updateAabb) { + if (skeleton == null) + throw new Error("skeleton cannot be null."); + var boundingBoxes = this.boundingBoxes; + var polygons = this.polygons; + var polygonPool = this.polygonPool; + var slots = skeleton.slots; + var slotCount = slots.length; + boundingBoxes.length = 0; + polygonPool.freeAll(polygons); + polygons.length = 0; + for (var i = 0; i < slotCount; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.BoundingBoxAttachment) { + var boundingBox = attachment; + boundingBoxes.push(boundingBox); + var polygon = polygonPool.obtain(); + if (polygon.length != boundingBox.worldVerticesLength) { + polygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength); + } + polygons.push(polygon); + boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2); + } + } + if (updateAabb) { + this.aabbCompute(); + } + else { + this.minX = Number.POSITIVE_INFINITY; + this.minY = Number.POSITIVE_INFINITY; + this.maxX = Number.NEGATIVE_INFINITY; + this.maxY = Number.NEGATIVE_INFINITY; + } + }; + SkeletonBounds.prototype.aabbCompute = function () { + var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) { + var polygon = polygons[i]; + var vertices = polygon; + for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) { + var x = vertices[ii]; + var y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + SkeletonBounds.prototype.aabbContainsPoint = function (x, y) { + return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; + }; + SkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY)) + return false; + var m = (y2 - y1) / (x2 - x1); + var y = m * (minX - x1) + y1; + if (y > minY && y < maxY) + return true; + y = m * (maxX - x1) + y1; + if (y > minY && y < maxY) + return true; + var x = (minY - y1) / m + x1; + if (x > minX && x < maxX) + return true; + x = (maxY - y1) / m + x1; + if (x > minX && x < maxX) + return true; + return false; + }; + SkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) { + return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; + }; + SkeletonBounds.prototype.containsPoint = function (x, y) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.containsPointPolygon(polygons[i], x, y)) + return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) { + var vertices = polygon; + var nn = polygon.length; + var prevIndex = nn - 2; + var inside = false; + for (var ii = 0; ii < nn; ii += 2) { + var vertexY = vertices[ii + 1]; + var prevY = vertices[prevIndex + 1]; + if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { + var vertexX = vertices[ii]; + if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x) + inside = !inside; + } + prevIndex = ii; + } + return inside; + }; + SkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2)) + return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) { + var vertices = polygon; + var nn = polygon.length; + var width12 = x1 - x2, height12 = y1 - y2; + var det1 = x1 * y2 - y1 * x2; + var x3 = vertices[nn - 2], y3 = vertices[nn - 1]; + for (var ii = 0; ii < nn; ii += 2) { + var x4 = vertices[ii], y4 = vertices[ii + 1]; + var det2 = x3 * y4 - y3 * x4; + var width34 = x3 - x4, height34 = y3 - y4; + var det3 = width12 * height34 - height12 * width34; + var x = (det1 * width34 - width12 * det2) / det3; + if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { + var y = (det1 * height34 - height12 * det2) / det3; + if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) + return true; + } + x3 = x4; + y3 = y4; + } + return false; + }; + SkeletonBounds.prototype.getPolygon = function (boundingBox) { + if (boundingBox == null) + throw new Error("boundingBox cannot be null."); + var index = this.boundingBoxes.indexOf(boundingBox); + return index == -1 ? null : this.polygons[index]; + }; + SkeletonBounds.prototype.getWidth = function () { + return this.maxX - this.minX; + }; + SkeletonBounds.prototype.getHeight = function () { + return this.maxY - this.minY; + }; + return SkeletonBounds; + }()); + spine.SkeletonBounds = SkeletonBounds; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonClipping = (function () { + function SkeletonClipping() { + this.triangulator = new spine.Triangulator(); + this.clippingPolygon = new Array(); + this.clipOutput = new Array(); + this.clippedVertices = new Array(); + this.clippedTriangles = new Array(); + this.scratch = new Array(); + } + SkeletonClipping.prototype.clipStart = function (slot, clip) { + if (this.clipAttachment != null) + return 0; + this.clipAttachment = clip; + var n = clip.worldVerticesLength; + var vertices = spine.Utils.setArraySize(this.clippingPolygon, n); + clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); + var clippingPolygon = this.clippingPolygon; + SkeletonClipping.makeClockwise(clippingPolygon); + var clippingPolygons = this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon)); + for (var i = 0, n_1 = clippingPolygons.length; i < n_1; i++) { + var polygon = clippingPolygons[i]; + SkeletonClipping.makeClockwise(polygon); + polygon.push(polygon[0]); + polygon.push(polygon[1]); + } + return clippingPolygons.length; + }; + SkeletonClipping.prototype.clipEndWithSlot = function (slot) { + if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data) + this.clipEnd(); + }; + SkeletonClipping.prototype.clipEnd = function () { + if (this.clipAttachment == null) + return; + this.clipAttachment = null; + this.clippingPolygons = null; + this.clippedVertices.length = 0; + this.clippedTriangles.length = 0; + this.clippingPolygon.length = 0; + }; + SkeletonClipping.prototype.isClipping = function () { + return this.clipAttachment != null; + }; + SkeletonClipping.prototype.clipTriangles = function (vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) { + var clipOutput = this.clipOutput, clippedVertices = this.clippedVertices; + var clippedTriangles = this.clippedTriangles; + var polygons = this.clippingPolygons; + var polygonsCount = this.clippingPolygons.length; + var vertexSize = twoColor ? 12 : 8; + var index = 0; + clippedVertices.length = 0; + clippedTriangles.length = 0; + outer: for (var i = 0; i < trianglesLength; i += 3) { + var vertexOffset = triangles[i] << 1; + var x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1]; + var u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 1] << 1; + var x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1]; + var u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 2] << 1; + var x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1]; + var u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1]; + for (var p = 0; p < polygonsCount; p++) { + var s = clippedVertices.length; + if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) { + var clipOutputLength = clipOutput.length; + if (clipOutputLength == 0) + continue; + var d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1; + var d = 1 / (d0 * d2 + d1 * (y1 - y3)); + var clipOutputCount = clipOutputLength >> 1; + var clipOutputItems = this.clipOutput; + var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize); + for (var ii = 0; ii < clipOutputLength; ii += 2) { + var x = clipOutputItems[ii], y = clipOutputItems[ii + 1]; + clippedVerticesItems[s] = x; + clippedVerticesItems[s + 1] = y; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + var c0 = x - x3, c1 = y - y3; + var a = (d0 * c0 + d1 * c1) * d; + var b = (d4 * c0 + d2 * c1) * d; + var c = 1 - a - b; + clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c; + clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c; + if (twoColor) { + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + } + s += vertexSize; + } + s = clippedTriangles.length; + var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2)); + clipOutputCount--; + for (var ii = 1; ii < clipOutputCount; ii++) { + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = (index + ii); + clippedTrianglesItems[s + 2] = (index + ii + 1); + s += 3; + } + index += clipOutputCount + 1; + } + else { + var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + 3 * vertexSize); + clippedVerticesItems[s] = x1; + clippedVerticesItems[s + 1] = y1; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + if (!twoColor) { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = x2; + clippedVerticesItems[s + 9] = y2; + clippedVerticesItems[s + 10] = light.r; + clippedVerticesItems[s + 11] = light.g; + clippedVerticesItems[s + 12] = light.b; + clippedVerticesItems[s + 13] = light.a; + clippedVerticesItems[s + 14] = u2; + clippedVerticesItems[s + 15] = v2; + clippedVerticesItems[s + 16] = x3; + clippedVerticesItems[s + 17] = y3; + clippedVerticesItems[s + 18] = light.r; + clippedVerticesItems[s + 19] = light.g; + clippedVerticesItems[s + 20] = light.b; + clippedVerticesItems[s + 21] = light.a; + clippedVerticesItems[s + 22] = u3; + clippedVerticesItems[s + 23] = v3; + } + else { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + clippedVerticesItems[s + 12] = x2; + clippedVerticesItems[s + 13] = y2; + clippedVerticesItems[s + 14] = light.r; + clippedVerticesItems[s + 15] = light.g; + clippedVerticesItems[s + 16] = light.b; + clippedVerticesItems[s + 17] = light.a; + clippedVerticesItems[s + 18] = u2; + clippedVerticesItems[s + 19] = v2; + clippedVerticesItems[s + 20] = dark.r; + clippedVerticesItems[s + 21] = dark.g; + clippedVerticesItems[s + 22] = dark.b; + clippedVerticesItems[s + 23] = dark.a; + clippedVerticesItems[s + 24] = x3; + clippedVerticesItems[s + 25] = y3; + clippedVerticesItems[s + 26] = light.r; + clippedVerticesItems[s + 27] = light.g; + clippedVerticesItems[s + 28] = light.b; + clippedVerticesItems[s + 29] = light.a; + clippedVerticesItems[s + 30] = u3; + clippedVerticesItems[s + 31] = v3; + clippedVerticesItems[s + 32] = dark.r; + clippedVerticesItems[s + 33] = dark.g; + clippedVerticesItems[s + 34] = dark.b; + clippedVerticesItems[s + 35] = dark.a; + } + s = clippedTriangles.length; + var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3); + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = (index + 1); + clippedTrianglesItems[s + 2] = (index + 2); + index += 3; + continue outer; + } + } + } + }; + SkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) { + var originalOutput = output; + var clipped = false; + var input = null; + if (clippingArea.length % 4 >= 2) { + input = output; + output = this.scratch; + } + else + input = this.scratch; + input.length = 0; + input.push(x1); + input.push(y1); + input.push(x2); + input.push(y2); + input.push(x3); + input.push(y3); + input.push(x1); + input.push(y1); + output.length = 0; + var clippingVertices = clippingArea; + var clippingVerticesLast = clippingArea.length - 4; + for (var i = 0;; i += 2) { + var edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1]; + var edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3]; + var deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2; + var inputVertices = input; + var inputVerticesLength = input.length - 2, outputStart = output.length; + for (var ii = 0; ii < inputVerticesLength; ii += 2) { + var inputX = inputVertices[ii], inputY = inputVertices[ii + 1]; + var inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3]; + var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0; + if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) { + if (side2) { + output.push(inputX2); + output.push(inputY2); + continue; + } + var c0 = inputY2 - inputY, c2 = inputX2 - inputX; + var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + } + else if (side2) { + var c0 = inputY2 - inputY, c2 = inputX2 - inputX; + var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + output.push(inputX2); + output.push(inputY2); + } + clipped = true; + } + if (outputStart == output.length) { + originalOutput.length = 0; + return true; + } + output.push(output[0]); + output.push(output[1]); + if (i == clippingVerticesLast) + break; + var temp = output; + output = input; + output.length = 0; + input = temp; + } + if (originalOutput != output) { + originalOutput.length = 0; + for (var i = 0, n = output.length - 2; i < n; i++) + originalOutput[i] = output[i]; + } + else + originalOutput.length = originalOutput.length - 2; + return clipped; + }; + SkeletonClipping.makeClockwise = function (polygon) { + var vertices = polygon; + var verticeslength = polygon.length; + var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x = 0, p1y = 0, p2x = 0, p2y = 0; + for (var i = 0, n = verticeslength - 3; i < n; i += 2) { + p1x = vertices[i]; + p1y = vertices[i + 1]; + p2x = vertices[i + 2]; + p2y = vertices[i + 3]; + area += p1x * p2y - p2x * p1y; + } + if (area < 0) + return; + for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) { + var x = vertices[i], y = vertices[i + 1]; + var other = lastX - i; + vertices[i] = vertices[other]; + vertices[i + 1] = vertices[other + 1]; + vertices[other] = x; + vertices[other + 1] = y; + } + }; + return SkeletonClipping; + }()); + spine.SkeletonClipping = SkeletonClipping; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonData = (function () { + function SkeletonData() { + this.bones = new Array(); + this.slots = new Array(); + this.skins = new Array(); + this.events = new Array(); + this.animations = new Array(); + this.ikConstraints = new Array(); + this.transformConstraints = new Array(); + this.pathConstraints = new Array(); + this.fps = 0; + } + SkeletonData.prototype.findBone = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.name == boneName) + return bone; + } + return null; + }; + SkeletonData.prototype.findBoneIndex = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].name == boneName) + return i; + return -1; + }; + SkeletonData.prototype.findSlot = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.name == slotName) + return slot; + } + return null; + }; + SkeletonData.prototype.findSlotIndex = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + if (slots[i].name == slotName) + return i; + return -1; + }; + SkeletonData.prototype.findSkin = function (skinName) { + if (skinName == null) + throw new Error("skinName cannot be null."); + var skins = this.skins; + for (var i = 0, n = skins.length; i < n; i++) { + var skin = skins[i]; + if (skin.name == skinName) + return skin; + } + return null; + }; + SkeletonData.prototype.findEvent = function (eventDataName) { + if (eventDataName == null) + throw new Error("eventDataName cannot be null."); + var events = this.events; + for (var i = 0, n = events.length; i < n; i++) { + var event_4 = events[i]; + if (event_4.name == eventDataName) + return event_4; + } + return null; + }; + SkeletonData.prototype.findAnimation = function (animationName) { + if (animationName == null) + throw new Error("animationName cannot be null."); + var animations = this.animations; + for (var i = 0, n = animations.length; i < n; i++) { + var animation = animations[i]; + if (animation.name == animationName) + return animation; + } + return null; + }; + SkeletonData.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + if (constraint.name == constraintName) + return constraint; + } + return null; + }; + SkeletonData.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.name == constraintName) + return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.name == constraintName) + return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) { + if (pathConstraintName == null) + throw new Error("pathConstraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) + if (pathConstraints[i].name == pathConstraintName) + return i; + return -1; + }; + return SkeletonData; + }()); + spine.SkeletonData = SkeletonData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonJson = (function () { + function SkeletonJson(attachmentLoader) { + this.scale = 1; + this.linkedMeshes = new Array(); + this.attachmentLoader = attachmentLoader; + } + SkeletonJson.prototype.readSkeletonData = function (json) { + var scale = this.scale; + var skeletonData = new spine.SkeletonData(); + var root = typeof (json) === "string" ? JSON.parse(json) : json; + var skeletonMap = root.skeleton; + if (skeletonMap != null) { + skeletonData.hash = skeletonMap.hash; + skeletonData.version = skeletonMap.spine; + skeletonData.width = skeletonMap.width; + skeletonData.height = skeletonMap.height; + skeletonData.fps = skeletonMap.fps; + skeletonData.imagesPath = skeletonMap.images; + } + if (root.bones) { + for (var i = 0; i < root.bones.length; i++) { + var boneMap = root.bones[i]; + var parent_2 = null; + var parentName = this.getValue(boneMap, "parent", null); + if (parentName != null) { + parent_2 = skeletonData.findBone(parentName); + if (parent_2 == null) + throw new Error("Parent bone not found: " + parentName); + } + var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_2); + data.length = this.getValue(boneMap, "length", 0) * scale; + data.x = this.getValue(boneMap, "x", 0) * scale; + data.y = this.getValue(boneMap, "y", 0) * scale; + data.rotation = this.getValue(boneMap, "rotation", 0); + data.scaleX = this.getValue(boneMap, "scaleX", 1); + data.scaleY = this.getValue(boneMap, "scaleY", 1); + data.shearX = this.getValue(boneMap, "shearX", 0); + data.shearY = this.getValue(boneMap, "shearY", 0); + data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, "transform", "normal")); + skeletonData.bones.push(data); + } + } + if (root.slots) { + for (var i = 0; i < root.slots.length; i++) { + var slotMap = root.slots[i]; + var slotName = slotMap.name; + var boneName = slotMap.bone; + var boneData = skeletonData.findBone(boneName); + if (boneData == null) + throw new Error("Slot bone not found: " + boneName); + var data = new spine.SlotData(skeletonData.slots.length, slotName, boneData); + var color = this.getValue(slotMap, "color", null); + if (color != null) + data.color.setFromString(color); + var dark = this.getValue(slotMap, "dark", null); + if (dark != null) { + data.darkColor = new spine.Color(1, 1, 1, 1); + data.darkColor.setFromString(dark); + } + data.attachmentName = this.getValue(slotMap, "attachment", null); + data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, "blend", "normal")); + skeletonData.slots.push(data); + } + } + if (root.ik) { + for (var i = 0; i < root.ik.length; i++) { + var constraintMap = root.ik[i]; + var data = new spine.IkConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) + throw new Error("IK bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) + throw new Error("IK target bone not found: " + targetName); + data.bendDirection = this.getValue(constraintMap, "bendPositive", true) ? 1 : -1; + data.mix = this.getValue(constraintMap, "mix", 1); + skeletonData.ikConstraints.push(data); + } + } + if (root.transform) { + for (var i = 0; i < root.transform.length; i++) { + var constraintMap = root.transform[i]; + var data = new spine.TransformConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) + throw new Error("Transform constraint bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) + throw new Error("Transform constraint target bone not found: " + targetName); + data.local = this.getValue(constraintMap, "local", false); + data.relative = this.getValue(constraintMap, "relative", false); + data.offsetRotation = this.getValue(constraintMap, "rotation", 0); + data.offsetX = this.getValue(constraintMap, "x", 0) * scale; + data.offsetY = this.getValue(constraintMap, "y", 0) * scale; + data.offsetScaleX = this.getValue(constraintMap, "scaleX", 0); + data.offsetScaleY = this.getValue(constraintMap, "scaleY", 0); + data.offsetShearY = this.getValue(constraintMap, "shearY", 0); + data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); + data.translateMix = this.getValue(constraintMap, "translateMix", 1); + data.scaleMix = this.getValue(constraintMap, "scaleMix", 1); + data.shearMix = this.getValue(constraintMap, "shearMix", 1); + skeletonData.transformConstraints.push(data); + } + } + if (root.path) { + for (var i = 0; i < root.path.length; i++) { + var constraintMap = root.path[i]; + var data = new spine.PathConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) + throw new Error("Transform constraint bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findSlot(targetName); + if (data.target == null) + throw new Error("Path target slot not found: " + targetName); + data.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, "positionMode", "percent")); + data.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, "spacingMode", "length")); + data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, "rotateMode", "tangent")); + data.offsetRotation = this.getValue(constraintMap, "rotation", 0); + data.position = this.getValue(constraintMap, "position", 0); + if (data.positionMode == spine.PositionMode.Fixed) + data.position *= scale; + data.spacing = this.getValue(constraintMap, "spacing", 0); + if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed) + data.spacing *= scale; + data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); + data.translateMix = this.getValue(constraintMap, "translateMix", 1); + skeletonData.pathConstraints.push(data); + } + } + if (root.skins) { + for (var skinName in root.skins) { + var skinMap = root.skins[skinName]; + var skin = new spine.Skin(skinName); + for (var slotName in skinMap) { + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) + throw new Error("Slot not found: " + slotName); + var slotMap = skinMap[slotName]; + for (var entryName in slotMap) { + var attachment = this.readAttachment(slotMap[entryName], skin, slotIndex, entryName, skeletonData); + if (attachment != null) + skin.addAttachment(slotIndex, entryName, attachment); + } + } + skeletonData.skins.push(skin); + if (skin.name == "default") + skeletonData.defaultSkin = skin; + } + } + for (var i = 0, n = this.linkedMeshes.length; i < n; i++) { + var linkedMesh = this.linkedMeshes[i]; + var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); + if (skin == null) + throw new Error("Skin not found: " + linkedMesh.skin); + var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); + if (parent_3 == null) + throw new Error("Parent mesh not found: " + linkedMesh.parent); + linkedMesh.mesh.setParentMesh(parent_3); + linkedMesh.mesh.updateUVs(); + } + this.linkedMeshes.length = 0; + if (root.events) { + for (var eventName in root.events) { + var eventMap = root.events[eventName]; + var data = new spine.EventData(eventName); + data.intValue = this.getValue(eventMap, "int", 0); + data.floatValue = this.getValue(eventMap, "float", 0); + data.stringValue = this.getValue(eventMap, "string", ""); + skeletonData.events.push(data); + } + } + if (root.animations) { + for (var animationName in root.animations) { + var animationMap = root.animations[animationName]; + this.readAnimation(animationMap, animationName, skeletonData); + } + } + return skeletonData; + }; + SkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) { + var scale = this.scale; + name = this.getValue(map, "name", name); + var type = this.getValue(map, "type", "region"); + switch (type) { + case "region": { + var path = this.getValue(map, "path", name); + var region = this.attachmentLoader.newRegionAttachment(skin, name, path); + if (region == null) + return null; + region.path = path; + region.x = this.getValue(map, "x", 0) * scale; + region.y = this.getValue(map, "y", 0) * scale; + region.scaleX = this.getValue(map, "scaleX", 1); + region.scaleY = this.getValue(map, "scaleY", 1); + region.rotation = this.getValue(map, "rotation", 0); + region.width = map.width * scale; + region.height = map.height * scale; + var color = this.getValue(map, "color", null); + if (color != null) + region.color.setFromString(color); + region.updateOffset(); + return region; + } + case "boundingbox": { + var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); + if (box == null) + return null; + this.readVertices(map, box, map.vertexCount << 1); + var color = this.getValue(map, "color", null); + if (color != null) + box.color.setFromString(color); + return box; + } + case "mesh": + case "linkedmesh": { + var path = this.getValue(map, "path", name); + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (mesh == null) + return null; + mesh.path = path; + var color = this.getValue(map, "color", null); + if (color != null) + mesh.color.setFromString(color); + var parent_4 = this.getValue(map, "parent", null); + if (parent_4 != null) { + mesh.inheritDeform = this.getValue(map, "deform", true); + this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4)); + return mesh; + } + var uvs = map.uvs; + this.readVertices(map, mesh, uvs.length); + mesh.triangles = map.triangles; + mesh.regionUVs = uvs; + mesh.updateUVs(); + mesh.hullLength = this.getValue(map, "hull", 0) * 2; + return mesh; + } + case "path": { + var path = this.attachmentLoader.newPathAttachment(skin, name); + if (path == null) + return null; + path.closed = this.getValue(map, "closed", false); + path.constantSpeed = this.getValue(map, "constantSpeed", true); + var vertexCount = map.vertexCount; + this.readVertices(map, path, vertexCount << 1); + var lengths = spine.Utils.newArray(vertexCount / 3, 0); + for (var i = 0; i < map.lengths.length; i++) + lengths[i] = map.lengths[i] * scale; + path.lengths = lengths; + var color = this.getValue(map, "color", null); + if (color != null) + path.color.setFromString(color); + return path; + } + case "point": { + var point = this.attachmentLoader.newPointAttachment(skin, name); + if (point == null) + return null; + point.x = this.getValue(map, "x", 0) * scale; + point.y = this.getValue(map, "y", 0) * scale; + point.rotation = this.getValue(map, "rotation", 0); + var color = this.getValue(map, "color", null); + if (color != null) + point.color.setFromString(color); + return point; + } + case "clipping": { + var clip = this.attachmentLoader.newClippingAttachment(skin, name); + if (clip == null) + return null; + var end = this.getValue(map, "end", null); + if (end != null) { + var slot = skeletonData.findSlot(end); + if (slot == null) + throw new Error("Clipping end slot not found: " + end); + clip.endSlot = slot; + } + var vertexCount = map.vertexCount; + this.readVertices(map, clip, vertexCount << 1); + var color = this.getValue(map, "color", null); + if (color != null) + clip.color.setFromString(color); + return clip; + } + } + return null; + }; + SkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) { + var scale = this.scale; + attachment.worldVerticesLength = verticesLength; + var vertices = map.vertices; + if (verticesLength == vertices.length) { + var scaledVertices = spine.Utils.toFloatArray(vertices); + if (scale != 1) { + for (var i = 0, n = vertices.length; i < n; i++) + scaledVertices[i] *= scale; + } + attachment.vertices = scaledVertices; + return; + } + var weights = new Array(); + var bones = new Array(); + for (var i = 0, n = vertices.length; i < n;) { + var boneCount = vertices[i++]; + bones.push(boneCount); + for (var nn = i + boneCount * 4; i < nn; i += 4) { + bones.push(vertices[i]); + weights.push(vertices[i + 1] * scale); + weights.push(vertices[i + 2] * scale); + weights.push(vertices[i + 3]); + } + } + attachment.bones = bones; + attachment.vertices = spine.Utils.toFloatArray(weights); + }; + SkeletonJson.prototype.readAnimation = function (map, name, skeletonData) { + var scale = this.scale; + var timelines = new Array(); + var duration = 0; + if (map.slots) { + for (var slotName in map.slots) { + var slotMap = map.slots[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) + throw new Error("Slot not found: " + slotName); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + if (timelineName == "attachment") { + var timeline = new spine.AttachmentTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex++, valueMap.time, valueMap.name); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + else if (timelineName == "color") { + var timeline = new spine.ColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var color = new spine.Color(); + color.setFromString(valueMap.color); + timeline.setFrame(frameIndex, valueMap.time, color.r, color.g, color.b, color.a); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.ColorTimeline.ENTRIES]); + } + else if (timelineName == "twoColor") { + var timeline = new spine.TwoColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var light = new spine.Color(); + var dark = new spine.Color(); + light.setFromString(valueMap.light); + dark.setFromString(valueMap.dark); + timeline.setFrame(frameIndex, valueMap.time, light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TwoColorTimeline.ENTRIES]); + } + else + throw new Error("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"); + } + } + } + if (map.bones) { + for (var boneName in map.bones) { + var boneMap = map.bones[boneName]; + var boneIndex = skeletonData.findBoneIndex(boneName); + if (boneIndex == -1) + throw new Error("Bone not found: " + boneName); + for (var timelineName in boneMap) { + var timelineMap = boneMap[timelineName]; + if (timelineName === "rotate") { + var timeline = new spine.RotateTimeline(timelineMap.length); + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, valueMap.angle); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.RotateTimeline.ENTRIES]); + } + else if (timelineName === "translate" || timelineName === "scale" || timelineName === "shear") { + var timeline = null; + var timelineScale = 1; + if (timelineName === "scale") + timeline = new spine.ScaleTimeline(timelineMap.length); + else if (timelineName === "shear") + timeline = new spine.ShearTimeline(timelineMap.length); + else { + timeline = new spine.TranslateTimeline(timelineMap.length); + timelineScale = scale; + } + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var x = this.getValue(valueMap, "x", 0), y = this.getValue(valueMap, "y", 0); + timeline.setFrame(frameIndex, valueMap.time, x * timelineScale, y * timelineScale); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TranslateTimeline.ENTRIES]); + } + else + throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"); + } + } + } + if (map.ik) { + for (var constraintName in map.ik) { + var constraintMap = map.ik[constraintName]; + var constraint = skeletonData.findIkConstraint(constraintName); + var timeline = new spine.IkConstraintTimeline(constraintMap.length); + timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "mix", 1), this.getValue(valueMap, "bendPositive", true) ? 1 : -1); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.IkConstraintTimeline.ENTRIES]); + } + } + if (map.transform) { + for (var constraintName in map.transform) { + var constraintMap = map.transform[constraintName]; + var constraint = skeletonData.findTransformConstraint(constraintName); + var timeline = new spine.TransformConstraintTimeline(constraintMap.length); + timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1), this.getValue(valueMap, "scaleMix", 1), this.getValue(valueMap, "shearMix", 1)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TransformConstraintTimeline.ENTRIES]); + } + } + if (map.paths) { + for (var constraintName in map.paths) { + var constraintMap = map.paths[constraintName]; + var index = skeletonData.findPathConstraintIndex(constraintName); + if (index == -1) + throw new Error("Path constraint not found: " + constraintName); + var data = skeletonData.pathConstraints[index]; + for (var timelineName in constraintMap) { + var timelineMap = constraintMap[timelineName]; + if (timelineName === "position" || timelineName === "spacing") { + var timeline = null; + var timelineScale = 1; + if (timelineName === "spacing") { + timeline = new spine.PathConstraintSpacingTimeline(timelineMap.length); + if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed) + timelineScale = scale; + } + else { + timeline = new spine.PathConstraintPositionTimeline(timelineMap.length); + if (data.positionMode == spine.PositionMode.Fixed) + timelineScale = scale; + } + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, timelineName, 0) * timelineScale); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintPositionTimeline.ENTRIES]); + } + else if (timelineName === "mix") { + var timeline = new spine.PathConstraintMixTimeline(timelineMap.length); + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintMixTimeline.ENTRIES]); + } + } + } + } + if (map.deform) { + for (var deformName in map.deform) { + var deformMap = map.deform[deformName]; + var skin = skeletonData.findSkin(deformName); + if (skin == null) + throw new Error("Skin not found: " + deformName); + for (var slotName in deformMap) { + var slotMap = deformMap[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) + throw new Error("Slot not found: " + slotMap.name); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + var attachment = skin.getAttachment(slotIndex, timelineName); + if (attachment == null) + throw new Error("Deform attachment not found: " + timelineMap.name); + var weighted = attachment.bones != null; + var vertices = attachment.vertices; + var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length; + var timeline = new spine.DeformTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + timeline.attachment = attachment; + var frameIndex = 0; + for (var j = 0; j < timelineMap.length; j++) { + var valueMap = timelineMap[j]; + var deform = void 0; + var verticesValue = this.getValue(valueMap, "vertices", null); + if (verticesValue == null) + deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices; + else { + deform = spine.Utils.newFloatArray(deformLength); + var start = this.getValue(valueMap, "offset", 0); + spine.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length); + if (scale != 1) { + for (var i = start, n = i + verticesValue.length; i < n; i++) + deform[i] *= scale; + } + if (!weighted) { + for (var i = 0; i < deformLength; i++) + deform[i] += vertices[i]; + } + } + timeline.setFrame(frameIndex, valueMap.time, deform); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + } + } + } + var drawOrderNode = map.drawOrder; + if (drawOrderNode == null) + drawOrderNode = map.draworder; + if (drawOrderNode != null) { + var timeline = new spine.DrawOrderTimeline(drawOrderNode.length); + var slotCount = skeletonData.slots.length; + var frameIndex = 0; + for (var j = 0; j < drawOrderNode.length; j++) { + var drawOrderMap = drawOrderNode[j]; + var drawOrder = null; + var offsets = this.getValue(drawOrderMap, "offsets", null); + if (offsets != null) { + drawOrder = spine.Utils.newArray(slotCount, -1); + var unchanged = spine.Utils.newArray(slotCount - offsets.length, 0); + var originalIndex = 0, unchangedIndex = 0; + for (var i = 0; i < offsets.length; i++) { + var offsetMap = offsets[i]; + var slotIndex = skeletonData.findSlotIndex(offsetMap.slot); + if (slotIndex == -1) + throw new Error("Slot not found: " + offsetMap.slot); + while (originalIndex != slotIndex) + unchanged[unchangedIndex++] = originalIndex++; + drawOrder[originalIndex + offsetMap.offset] = originalIndex++; + } + while (originalIndex < slotCount) + unchanged[unchangedIndex++] = originalIndex++; + for (var i = slotCount - 1; i >= 0; i--) + if (drawOrder[i] == -1) + drawOrder[i] = unchanged[--unchangedIndex]; + } + timeline.setFrame(frameIndex++, drawOrderMap.time, drawOrder); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (map.events) { + var timeline = new spine.EventTimeline(map.events.length); + var frameIndex = 0; + for (var i = 0; i < map.events.length; i++) { + var eventMap = map.events[i]; + var eventData = skeletonData.findEvent(eventMap.name); + if (eventData == null) + throw new Error("Event not found: " + eventMap.name); + var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData); + event_5.intValue = this.getValue(eventMap, "int", eventData.intValue); + event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue); + event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue); + timeline.setFrame(frameIndex++, event_5); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (isNaN(duration)) { + throw new Error("Error while parsing animation, duration is NaN"); + } + skeletonData.animations.push(new spine.Animation(name, timelines, duration)); + }; + SkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) { + if (!map.curve) + return; + if (map.curve === "stepped") + timeline.setStepped(frameIndex); + else if (Object.prototype.toString.call(map.curve) === '[object Array]') { + var curve = map.curve; + timeline.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]); + } + }; + SkeletonJson.prototype.getValue = function (map, prop, defaultValue) { + return map[prop] !== undefined ? map[prop] : defaultValue; + }; + SkeletonJson.blendModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "normal") + return spine.BlendMode.Normal; + if (str == "additive") + return spine.BlendMode.Additive; + if (str == "multiply") + return spine.BlendMode.Multiply; + if (str == "screen") + return spine.BlendMode.Screen; + throw new Error("Unknown blend mode: " + str); + }; + SkeletonJson.positionModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "fixed") + return spine.PositionMode.Fixed; + if (str == "percent") + return spine.PositionMode.Percent; + throw new Error("Unknown position mode: " + str); + }; + SkeletonJson.spacingModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "length") + return spine.SpacingMode.Length; + if (str == "fixed") + return spine.SpacingMode.Fixed; + if (str == "percent") + return spine.SpacingMode.Percent; + throw new Error("Unknown position mode: " + str); + }; + SkeletonJson.rotateModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "tangent") + return spine.RotateMode.Tangent; + if (str == "chain") + return spine.RotateMode.Chain; + if (str == "chainscale") + return spine.RotateMode.ChainScale; + throw new Error("Unknown rotate mode: " + str); + }; + SkeletonJson.transformModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "normal") + return spine.TransformMode.Normal; + if (str == "onlytranslation") + return spine.TransformMode.OnlyTranslation; + if (str == "norotationorreflection") + return spine.TransformMode.NoRotationOrReflection; + if (str == "noscale") + return spine.TransformMode.NoScale; + if (str == "noscaleorreflection") + return spine.TransformMode.NoScaleOrReflection; + throw new Error("Unknown transform mode: " + str); + }; + return SkeletonJson; + }()); + spine.SkeletonJson = SkeletonJson; + var LinkedMesh = (function () { + function LinkedMesh(mesh, skin, slotIndex, parent) { + this.mesh = mesh; + this.skin = skin; + this.slotIndex = slotIndex; + this.parent = parent; + } + return LinkedMesh; + }()); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Skin = (function () { + function Skin(name) { + this.attachments = new Array(); + if (name == null) + throw new Error("name cannot be null."); + this.name = name; + } + Skin.prototype.addAttachment = function (slotIndex, name, attachment) { + if (attachment == null) + throw new Error("attachment cannot be null."); + var attachments = this.attachments; + if (slotIndex >= attachments.length) + attachments.length = slotIndex + 1; + if (!attachments[slotIndex]) + attachments[slotIndex] = {}; + attachments[slotIndex][name] = attachment; + }; + Skin.prototype.getAttachment = function (slotIndex, name) { + var dictionary = this.attachments[slotIndex]; + return dictionary ? dictionary[name] : null; + }; + Skin.prototype.attachAll = function (skeleton, oldSkin) { + var slotIndex = 0; + for (var i = 0; i < skeleton.slots.length; i++) { + var slot = skeleton.slots[i]; + var slotAttachment = slot.getAttachment(); + if (slotAttachment && slotIndex < oldSkin.attachments.length) { + var dictionary = oldSkin.attachments[slotIndex]; + for (var key in dictionary) { + var skinAttachment = dictionary[key]; + if (slotAttachment == skinAttachment) { + var attachment = this.getAttachment(slotIndex, key); + if (attachment != null) + slot.setAttachment(attachment); + break; + } + } + } + slotIndex++; + } + }; + return Skin; + }()); + spine.Skin = Skin; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Slot = (function () { + function Slot(data, bone) { + this.attachmentVertices = new Array(); + if (data == null) + throw new Error("data cannot be null."); + if (bone == null) + throw new Error("bone cannot be null."); + this.data = data; + this.bone = bone; + this.color = new spine.Color(); + this.darkColor = data.darkColor == null ? null : new spine.Color(); + this.setToSetupPose(); + } + Slot.prototype.getAttachment = function () { + return this.attachment; + }; + Slot.prototype.setAttachment = function (attachment) { + if (this.attachment == attachment) + return; + this.attachment = attachment; + this.attachmentTime = this.bone.skeleton.time; + this.attachmentVertices.length = 0; + }; + Slot.prototype.setAttachmentTime = function (time) { + this.attachmentTime = this.bone.skeleton.time - time; + }; + Slot.prototype.getAttachmentTime = function () { + return this.bone.skeleton.time - this.attachmentTime; + }; + Slot.prototype.setToSetupPose = function () { + this.color.setFromColor(this.data.color); + if (this.darkColor != null) + this.darkColor.setFromColor(this.data.darkColor); + if (this.data.attachmentName == null) + this.attachment = null; + else { + this.attachment = null; + this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName)); + } + }; + return Slot; + }()); + spine.Slot = Slot; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SlotData = (function () { + function SlotData(index, name, boneData) { + this.color = new spine.Color(1, 1, 1, 1); + if (index < 0) + throw new Error("index must be >= 0."); + if (name == null) + throw new Error("name cannot be null."); + if (boneData == null) + throw new Error("boneData cannot be null."); + this.index = index; + this.name = name; + this.boneData = boneData; + } + return SlotData; + }()); + spine.SlotData = SlotData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Texture = (function () { + function Texture(image) { + this._image = image; + } + Texture.prototype.getImage = function () { + return this._image; + }; + Texture.filterFromString = function (text) { + switch (text.toLowerCase()) { + case "nearest": return TextureFilter.Nearest; + case "linear": return TextureFilter.Linear; + case "mipmap": return TextureFilter.MipMap; + case "mipmapnearestnearest": return TextureFilter.MipMapNearestNearest; + case "mipmaplinearnearest": return TextureFilter.MipMapLinearNearest; + case "mipmapnearestlinear": return TextureFilter.MipMapNearestLinear; + case "mipmaplinearlinear": return TextureFilter.MipMapLinearLinear; + default: throw new Error("Unknown texture filter " + text); + } + }; + Texture.wrapFromString = function (text) { + switch (text.toLowerCase()) { + case "mirroredtepeat": return TextureWrap.MirroredRepeat; + case "clamptoedge": return TextureWrap.ClampToEdge; + case "repeat": return TextureWrap.Repeat; + default: throw new Error("Unknown texture wrap " + text); + } + }; + return Texture; + }()); + spine.Texture = Texture; + var TextureFilter; + (function (TextureFilter) { + TextureFilter[TextureFilter["Nearest"] = 9728] = "Nearest"; + TextureFilter[TextureFilter["Linear"] = 9729] = "Linear"; + TextureFilter[TextureFilter["MipMap"] = 9987] = "MipMap"; + TextureFilter[TextureFilter["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest"; + TextureFilter[TextureFilter["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest"; + TextureFilter[TextureFilter["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear"; + TextureFilter[TextureFilter["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear"; + })(TextureFilter = spine.TextureFilter || (spine.TextureFilter = {})); + var TextureWrap; + (function (TextureWrap) { + TextureWrap[TextureWrap["MirroredRepeat"] = 33648] = "MirroredRepeat"; + TextureWrap[TextureWrap["ClampToEdge"] = 33071] = "ClampToEdge"; + TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat"; + })(TextureWrap = spine.TextureWrap || (spine.TextureWrap = {})); + var TextureRegion = (function () { + function TextureRegion() { + this.u = 0; + this.v = 0; + this.u2 = 0; + this.v2 = 0; + this.width = 0; + this.height = 0; + this.rotate = false; + this.offsetX = 0; + this.offsetY = 0; + this.originalWidth = 0; + this.originalHeight = 0; + } + return TextureRegion; + }()); + spine.TextureRegion = TextureRegion; + var FakeTexture = (function (_super) { + __extends(FakeTexture, _super); + function FakeTexture() { + return _super !== null && _super.apply(this, arguments) || this; + } + FakeTexture.prototype.setFilters = function (minFilter, magFilter) { }; + FakeTexture.prototype.setWraps = function (uWrap, vWrap) { }; + FakeTexture.prototype.dispose = function () { }; + return FakeTexture; + }(spine.Texture)); + spine.FakeTexture = FakeTexture; +})(spine || (spine = {})); +var spine; +(function (spine) { + var TextureAtlas = (function () { + function TextureAtlas(atlasText, textureLoader) { + this.pages = new Array(); + this.regions = new Array(); + this.load(atlasText, textureLoader); + } + TextureAtlas.prototype.load = function (atlasText, textureLoader) { + if (textureLoader == null) + throw new Error("textureLoader cannot be null."); + var reader = new TextureAtlasReader(atlasText); + var tuple = new Array(4); + var page = null; + while (true) { + var line = reader.readLine(); + if (line == null) + break; + line = line.trim(); + if (line.length == 0) + page = null; + else if (!page) { + page = new TextureAtlasPage(); + page.name = line; + if (reader.readTuple(tuple) == 2) { + page.width = parseInt(tuple[0]); + page.height = parseInt(tuple[1]); + reader.readTuple(tuple); + } + reader.readTuple(tuple); + page.minFilter = spine.Texture.filterFromString(tuple[0]); + page.magFilter = spine.Texture.filterFromString(tuple[1]); + var direction = reader.readValue(); + page.uWrap = spine.TextureWrap.ClampToEdge; + page.vWrap = spine.TextureWrap.ClampToEdge; + if (direction == "x") + page.uWrap = spine.TextureWrap.Repeat; + else if (direction == "y") + page.vWrap = spine.TextureWrap.Repeat; + else if (direction == "xy") + page.uWrap = page.vWrap = spine.TextureWrap.Repeat; + page.texture = textureLoader(line); + page.texture.setFilters(page.minFilter, page.magFilter); + page.texture.setWraps(page.uWrap, page.vWrap); + page.width = page.texture.getImage().width; + page.height = page.texture.getImage().height; + this.pages.push(page); + } + else { + var region = new TextureAtlasRegion(); + region.name = line; + region.page = page; + region.rotate = reader.readValue() == "true"; + reader.readTuple(tuple); + var x = parseInt(tuple[0]); + var y = parseInt(tuple[1]); + reader.readTuple(tuple); + var width = parseInt(tuple[0]); + var height = parseInt(tuple[1]); + region.u = x / page.width; + region.v = y / page.height; + if (region.rotate) { + region.u2 = (x + height) / page.width; + region.v2 = (y + width) / page.height; + } + else { + region.u2 = (x + width) / page.width; + region.v2 = (y + height) / page.height; + } + region.x = x; + region.y = y; + region.width = Math.abs(width); + region.height = Math.abs(height); + if (reader.readTuple(tuple) == 4) { + if (reader.readTuple(tuple) == 4) { + reader.readTuple(tuple); + } + } + region.originalWidth = parseInt(tuple[0]); + region.originalHeight = parseInt(tuple[1]); + reader.readTuple(tuple); + region.offsetX = parseInt(tuple[0]); + region.offsetY = parseInt(tuple[1]); + region.index = parseInt(reader.readValue()); + region.texture = page.texture; + this.regions.push(region); + } + } + }; + TextureAtlas.prototype.findRegion = function (name) { + for (var i = 0; i < this.regions.length; i++) { + if (this.regions[i].name == name) { + return this.regions[i]; + } + } + return null; + }; + TextureAtlas.prototype.dispose = function () { + for (var i = 0; i < this.pages.length; i++) { + this.pages[i].texture.dispose(); + } + }; + return TextureAtlas; + }()); + spine.TextureAtlas = TextureAtlas; + var TextureAtlasReader = (function () { + function TextureAtlasReader(text) { + this.index = 0; + this.lines = text.split(/\r\n|\r|\n/); + } + TextureAtlasReader.prototype.readLine = function () { + if (this.index >= this.lines.length) + return null; + return this.lines[this.index++]; + }; + TextureAtlasReader.prototype.readValue = function () { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (colon == -1) + throw new Error("Invalid line: " + line); + return line.substring(colon + 1).trim(); + }; + TextureAtlasReader.prototype.readTuple = function (tuple) { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (colon == -1) + throw new Error("Invalid line: " + line); + var i = 0, lastMatch = colon + 1; + for (; i < 3; i++) { + var comma = line.indexOf(",", lastMatch); + if (comma == -1) + break; + tuple[i] = line.substr(lastMatch, comma - lastMatch).trim(); + lastMatch = comma + 1; + } + tuple[i] = line.substring(lastMatch).trim(); + return i + 1; + }; + return TextureAtlasReader; + }()); + var TextureAtlasPage = (function () { + function TextureAtlasPage() { + } + return TextureAtlasPage; + }()); + spine.TextureAtlasPage = TextureAtlasPage; + var TextureAtlasRegion = (function (_super) { + __extends(TextureAtlasRegion, _super); + function TextureAtlasRegion() { + return _super !== null && _super.apply(this, arguments) || this; + } + return TextureAtlasRegion; + }(spine.TextureRegion)); + spine.TextureAtlasRegion = TextureAtlasRegion; +})(spine || (spine = {})); +var spine; +(function (spine) { + var TransformConstraint = (function () { + function TransformConstraint(data, skeleton) { + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.temp = new spine.Vector2(); + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + this.scaleMix = data.scaleMix; + this.shearMix = data.shearMix; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + TransformConstraint.prototype.apply = function () { + this.update(); + }; + TransformConstraint.prototype.update = function () { + if (this.data.local) { + if (this.data.relative) + this.applyRelativeLocal(); + else + this.applyAbsoluteLocal(); + } + else { + if (this.data.relative) + this.applyRelativeWorld(); + else + this.applyAbsoluteWorld(); + } + }; + TransformConstraint.prototype.applyAbsoluteWorld = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + var ta = target.a, tb = target.b, tc = target.c, td = target.d; + var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect; + var offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + if (rotateMix != 0) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation; + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + bone.worldX += (temp.x - bone.worldX) * translateMix; + bone.worldY += (temp.y - bone.worldY) * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = Math.sqrt(bone.a * bone.a + bone.c * bone.c); + var ts = Math.sqrt(ta * ta + tc * tc); + if (s > 0.00001) + s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s; + bone.a *= s; + bone.c *= s; + s = Math.sqrt(bone.b * bone.b + bone.d * bone.d); + ts = Math.sqrt(tb * tb + td * td); + if (s > 0.00001) + s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s; + bone.b *= s; + bone.d *= s; + modified = true; + } + if (shearMix > 0) { + var b = bone.b, d = bone.d; + var by = Math.atan2(d, b); + var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(bone.c, bone.a)); + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r = by + (r + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + bone.b = Math.cos(r) * s; + bone.d = Math.sin(r) * s; + modified = true; + } + if (modified) + bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyRelativeWorld = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + var ta = target.a, tb = target.b, tc = target.c, td = target.d; + var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect, offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + if (rotateMix != 0) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var r = Math.atan2(tc, ta) + offsetRotation; + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + bone.worldX += temp.x * translateMix; + bone.worldY += temp.y * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1; + bone.a *= s; + bone.c *= s; + s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1; + bone.b *= s; + bone.d *= s; + modified = true; + } + if (shearMix > 0) { + var r = Math.atan2(td, tb) - Math.atan2(tc, ta); + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + var b = bone.b, d = bone.d; + r = Math.atan2(d, b) + (r - spine.MathUtils.PI / 2 + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + bone.b = Math.cos(r) * s; + bone.d = Math.sin(r) * s; + modified = true; + } + if (modified) + bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyAbsoluteLocal = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) + target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) + bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) { + var r = target.arotation - rotation + this.data.offsetRotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + rotation += r * rotateMix; + } + var x = bone.ax, y = bone.ay; + if (translateMix != 0) { + x += (target.ax - x + this.data.offsetX) * translateMix; + y += (target.ay - y + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) + scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX; + if (scaleY > 0.00001) + scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY; + } + var shearY = bone.ashearY; + if (shearMix > 0) { + var r = target.ashearY - shearY + this.data.offsetShearY; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.shearY += r * shearMix; + } + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.applyRelativeLocal = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) + target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) + bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) + rotation += (target.arotation + this.data.offsetRotation) * rotateMix; + var x = bone.ax, y = bone.ay; + if (translateMix != 0) { + x += (target.ax + this.data.offsetX) * translateMix; + y += (target.ay + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) + scaleX *= ((target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix) + 1; + if (scaleY > 0.00001) + scaleY *= ((target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix) + 1; + } + var shearY = bone.ashearY; + if (shearMix > 0) + shearY += (target.ashearY + this.data.offsetShearY) * shearMix; + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.getOrder = function () { + return this.data.order; + }; + return TransformConstraint; + }()); + spine.TransformConstraint = TransformConstraint; +})(spine || (spine = {})); +var spine; +(function (spine) { + var TransformConstraintData = (function () { + function TransformConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.offsetRotation = 0; + this.offsetX = 0; + this.offsetY = 0; + this.offsetScaleX = 0; + this.offsetScaleY = 0; + this.offsetShearY = 0; + this.relative = false; + this.local = false; + if (name == null) + throw new Error("name cannot be null."); + this.name = name; + } + return TransformConstraintData; + }()); + spine.TransformConstraintData = TransformConstraintData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Triangulator = (function () { + function Triangulator() { + this.convexPolygons = new Array(); + this.convexPolygonsIndices = new Array(); + this.indicesArray = new Array(); + this.isConcaveArray = new Array(); + this.triangles = new Array(); + this.polygonPool = new spine.Pool(function () { + return new Array(); + }); + this.polygonIndicesPool = new spine.Pool(function () { + return new Array(); + }); + } + Triangulator.prototype.triangulate = function (verticesArray) { + var vertices = verticesArray; + var vertexCount = verticesArray.length >> 1; + var indices = this.indicesArray; + indices.length = 0; + for (var i = 0; i < vertexCount; i++) + indices[i] = i; + var isConcave = this.isConcaveArray; + isConcave.length = 0; + for (var i = 0, n = vertexCount; i < n; ++i) + isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices); + var triangles = this.triangles; + triangles.length = 0; + while (vertexCount > 3) { + var previous = vertexCount - 1, i = 0, next = 1; + while (true) { + outer: if (!isConcave[i]) { + var p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1; + var p1x = vertices[p1], p1y = vertices[p1 + 1]; + var p2x = vertices[p2], p2y = vertices[p2 + 1]; + var p3x = vertices[p3], p3y = vertices[p3 + 1]; + for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) { + if (!isConcave[ii]) + continue; + var v = indices[ii] << 1; + var vx = vertices[v], vy = vertices[v + 1]; + if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) { + if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) { + if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy)) + break outer; + } + } + } + break; + } + if (next == 0) { + do { + if (!isConcave[i]) + break; + i--; + } while (i > 0); + break; + } + previous = i; + i = next; + next = (next + 1) % vertexCount; + } + triangles.push(indices[(vertexCount + i - 1) % vertexCount]); + triangles.push(indices[i]); + triangles.push(indices[(i + 1) % vertexCount]); + indices.splice(i, 1); + isConcave.splice(i, 1); + vertexCount--; + var previousIndex = (vertexCount + i - 1) % vertexCount; + var nextIndex = i == vertexCount ? 0 : i; + isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices); + isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices); + } + if (vertexCount == 3) { + triangles.push(indices[2]); + triangles.push(indices[0]); + triangles.push(indices[1]); + } + return triangles; + }; + Triangulator.prototype.decompose = function (verticesArray, triangles) { + var vertices = verticesArray; + var convexPolygons = this.convexPolygons; + this.polygonPool.freeAll(convexPolygons); + convexPolygons.length = 0; + var convexPolygonsIndices = this.convexPolygonsIndices; + this.polygonIndicesPool.freeAll(convexPolygonsIndices); + convexPolygonsIndices.length = 0; + var polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + var polygon = this.polygonPool.obtain(); + polygon.length = 0; + var fanBaseIndex = -1, lastWinding = 0; + for (var i = 0, n = triangles.length; i < n; i += 3) { + var t1 = triangles[i] << 1, t2 = triangles[i + 1] << 1, t3 = triangles[i + 2] << 1; + var x1 = vertices[t1], y1 = vertices[t1 + 1]; + var x2 = vertices[t2], y2 = vertices[t2 + 1]; + var x3 = vertices[t3], y3 = vertices[t3 + 1]; + var merged = false; + if (fanBaseIndex == t1) { + var o = polygon.length - 4; + var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3); + var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]); + if (winding1 == lastWinding && winding2 == lastWinding) { + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(t3); + merged = true; + } + } + if (!merged) { + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } + else { + this.polygonPool.free(polygon); + this.polygonIndicesPool.free(polygonIndices); + } + polygon = this.polygonPool.obtain(); + polygon.length = 0; + polygon.push(x1); + polygon.push(y1); + polygon.push(x2); + polygon.push(y2); + polygon.push(x3); + polygon.push(y3); + polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + polygonIndices.push(t1); + polygonIndices.push(t2); + polygonIndices.push(t3); + lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3); + fanBaseIndex = t1; + } + } + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } + for (var i = 0, n = convexPolygons.length; i < n; i++) { + polygonIndices = convexPolygonsIndices[i]; + if (polygonIndices.length == 0) + continue; + var firstIndex = polygonIndices[0]; + var lastIndex = polygonIndices[polygonIndices.length - 1]; + polygon = convexPolygons[i]; + var o = polygon.length - 4; + var prevPrevX = polygon[o], prevPrevY = polygon[o + 1]; + var prevX = polygon[o + 2], prevY = polygon[o + 3]; + var firstX = polygon[0], firstY = polygon[1]; + var secondX = polygon[2], secondY = polygon[3]; + var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY); + for (var ii = 0; ii < n; ii++) { + if (ii == i) + continue; + var otherIndices = convexPolygonsIndices[ii]; + if (otherIndices.length != 3) + continue; + var otherFirstIndex = otherIndices[0]; + var otherSecondIndex = otherIndices[1]; + var otherLastIndex = otherIndices[2]; + var otherPoly = convexPolygons[ii]; + var x3 = otherPoly[otherPoly.length - 2], y3 = otherPoly[otherPoly.length - 1]; + if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) + continue; + var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3); + var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY); + if (winding1 == winding && winding2 == winding) { + otherPoly.length = 0; + otherIndices.length = 0; + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(otherLastIndex); + prevPrevX = prevX; + prevPrevY = prevY; + prevX = x3; + prevY = y3; + ii = 0; + } + } + } + for (var i = convexPolygons.length - 1; i >= 0; i--) { + polygon = convexPolygons[i]; + if (polygon.length == 0) { + convexPolygons.splice(i, 1); + this.polygonPool.free(polygon); + polygonIndices = convexPolygonsIndices[i]; + convexPolygonsIndices.splice(i, 1); + this.polygonIndicesPool.free(polygonIndices); + } + } + return convexPolygons; + }; + Triangulator.isConcave = function (index, vertexCount, vertices, indices) { + var previous = indices[(vertexCount + index - 1) % vertexCount] << 1; + var current = indices[index] << 1; + var next = indices[(index + 1) % vertexCount] << 1; + return !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]); + }; + Triangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) { + return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; + }; + Triangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) { + var px = p2x - p1x, py = p2y - p1y; + return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; + }; + return Triangulator; + }()); + spine.Triangulator = Triangulator; +})(spine || (spine = {})); +var spine; +(function (spine) { + var IntSet = (function () { + function IntSet() { + this.array = new Array(); + } + IntSet.prototype.add = function (value) { + var contains = this.contains(value); + this.array[value | 0] = value | 0; + return !contains; + }; + IntSet.prototype.contains = function (value) { + return this.array[value | 0] != undefined; + }; + IntSet.prototype.remove = function (value) { + this.array[value | 0] = undefined; + }; + IntSet.prototype.clear = function () { + this.array.length = 0; + }; + return IntSet; + }()); + spine.IntSet = IntSet; + var Color = (function () { + function Color(r, g, b, a) { + if (r === void 0) { r = 0; } + if (g === void 0) { g = 0; } + if (b === void 0) { b = 0; } + if (a === void 0) { a = 0; } + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + Color.prototype.set = function (r, g, b, a) { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + this.clamp(); + return this; + }; + Color.prototype.setFromColor = function (c) { + this.r = c.r; + this.g = c.g; + this.b = c.b; + this.a = c.a; + return this; + }; + Color.prototype.setFromString = function (hex) { + hex = hex.charAt(0) == '#' ? hex.substr(1) : hex; + this.r = parseInt(hex.substr(0, 2), 16) / 255.0; + this.g = parseInt(hex.substr(2, 2), 16) / 255.0; + this.b = parseInt(hex.substr(4, 2), 16) / 255.0; + this.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0; + return this; + }; + Color.prototype.add = function (r, g, b, a) { + this.r += r; + this.g += g; + this.b += b; + this.a += a; + this.clamp(); + return this; + }; + Color.prototype.clamp = function () { + if (this.r < 0) + this.r = 0; + else if (this.r > 1) + this.r = 1; + if (this.g < 0) + this.g = 0; + else if (this.g > 1) + this.g = 1; + if (this.b < 0) + this.b = 0; + else if (this.b > 1) + this.b = 1; + if (this.a < 0) + this.a = 0; + else if (this.a > 1) + this.a = 1; + return this; + }; + Color.WHITE = new Color(1, 1, 1, 1); + Color.RED = new Color(1, 0, 0, 1); + Color.GREEN = new Color(0, 1, 0, 1); + Color.BLUE = new Color(0, 0, 1, 1); + Color.MAGENTA = new Color(1, 0, 1, 1); + return Color; + }()); + spine.Color = Color; + var MathUtils = (function () { + function MathUtils() { + } + MathUtils.clamp = function (value, min, max) { + if (value < min) + return min; + if (value > max) + return max; + return value; + }; + MathUtils.cosDeg = function (degrees) { + return Math.cos(degrees * MathUtils.degRad); + }; + MathUtils.sinDeg = function (degrees) { + return Math.sin(degrees * MathUtils.degRad); + }; + MathUtils.signum = function (value) { + return value > 0 ? 1 : value < 0 ? -1 : 0; + }; + MathUtils.toInt = function (x) { + return x > 0 ? Math.floor(x) : Math.ceil(x); + }; + MathUtils.cbrt = function (x) { + var y = Math.pow(Math.abs(x), 1 / 3); + return x < 0 ? -y : y; + }; + MathUtils.randomTriangular = function (min, max) { + return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5); + }; + MathUtils.randomTriangularWith = function (min, max, mode) { + var u = Math.random(); + var d = max - min; + if (u <= (mode - min) / d) + return min + Math.sqrt(u * d * (mode - min)); + return max - Math.sqrt((1 - u) * d * (max - mode)); + }; + MathUtils.PI = 3.1415927; + MathUtils.PI2 = MathUtils.PI * 2; + MathUtils.radiansToDegrees = 180 / MathUtils.PI; + MathUtils.radDeg = MathUtils.radiansToDegrees; + MathUtils.degreesToRadians = MathUtils.PI / 180; + MathUtils.degRad = MathUtils.degreesToRadians; + return MathUtils; + }()); + spine.MathUtils = MathUtils; + var Interpolation = (function () { + function Interpolation() { + } + Interpolation.prototype.apply = function (start, end, a) { + return start + (end - start) * this.applyInternal(a); + }; + return Interpolation; + }()); + spine.Interpolation = Interpolation; + var Pow = (function (_super) { + __extends(Pow, _super); + function Pow(power) { + var _this = _super.call(this) || this; + _this.power = 2; + _this.power = power; + return _this; + } + Pow.prototype.applyInternal = function (a) { + if (a <= 0.5) + return Math.pow(a * 2, this.power) / 2; + return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1; + }; + return Pow; + }(Interpolation)); + spine.Pow = Pow; + var PowOut = (function (_super) { + __extends(PowOut, _super); + function PowOut(power) { + return _super.call(this, power) || this; + } + PowOut.prototype.applyInternal = function (a) { + return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; + }; + return PowOut; + }(Pow)); + spine.PowOut = PowOut; + var Utils = (function () { + function Utils() { + } + Utils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) { + for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) { + dest[j] = source[i]; + } + }; + Utils.setArraySize = function (array, size, value) { + if (value === void 0) { value = 0; } + var oldSize = array.length; + if (oldSize == size) + return array; + array.length = size; + if (oldSize < size) { + for (var i = oldSize; i < size; i++) + array[i] = value; + } + return array; + }; + Utils.ensureArrayCapacity = function (array, size, value) { + if (value === void 0) { value = 0; } + if (array.length >= size) + return array; + return Utils.setArraySize(array, size, value); + }; + Utils.newArray = function (size, defaultValue) { + var array = new Array(size); + for (var i = 0; i < size; i++) + array[i] = defaultValue; + return array; + }; + Utils.newFloatArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Float32Array(size); + } + else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) + array[i] = 0; + return array; + } + }; + Utils.newShortArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Int16Array(size); + } + else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) + array[i] = 0; + return array; + } + }; + Utils.toFloatArray = function (array) { + return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; + }; + Utils.toSinglePrecision = function (value) { + return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value; + }; + Utils.webkit602BugfixHelper = function (alpha, pose) { + }; + Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; + return Utils; + }()); + spine.Utils = Utils; + var DebugUtils = (function () { + function DebugUtils() { + } + DebugUtils.logBones = function (skeleton) { + for (var i = 0; i < skeleton.bones.length; i++) { + var bone = skeleton.bones[i]; + console.log(bone.data.name + ", " + bone.a + ", " + bone.b + ", " + bone.c + ", " + bone.d + ", " + bone.worldX + ", " + bone.worldY); + } + }; + return DebugUtils; + }()); + spine.DebugUtils = DebugUtils; + var Pool = (function () { + function Pool(instantiator) { + this.items = new Array(); + this.instantiator = instantiator; + } + Pool.prototype.obtain = function () { + return this.items.length > 0 ? this.items.pop() : this.instantiator(); + }; + Pool.prototype.free = function (item) { + if (item.reset) + item.reset(); + this.items.push(item); + }; + Pool.prototype.freeAll = function (items) { + for (var i = 0; i < items.length; i++) { + if (items[i].reset) + items[i].reset(); + this.items[i] = items[i]; + } + }; + Pool.prototype.clear = function () { + this.items.length = 0; + }; + return Pool; + }()); + spine.Pool = Pool; + var Vector2 = (function () { + function Vector2(x, y) { + if (x === void 0) { x = 0; } + if (y === void 0) { y = 0; } + this.x = x; + this.y = y; + } + Vector2.prototype.set = function (x, y) { + this.x = x; + this.y = y; + return this; + }; + Vector2.prototype.length = function () { + var x = this.x; + var y = this.y; + return Math.sqrt(x * x + y * y); + }; + Vector2.prototype.normalize = function () { + var len = this.length(); + if (len != 0) { + this.x /= len; + this.y /= len; + } + return this; + }; + return Vector2; + }()); + spine.Vector2 = Vector2; + var TimeKeeper = (function () { + function TimeKeeper() { + this.maxDelta = 0.064; + this.framesPerSecond = 0; + this.delta = 0; + this.totalTime = 0; + this.lastTime = Date.now() / 1000; + this.frameCount = 0; + this.frameTime = 0; + } + TimeKeeper.prototype.update = function () { + var now = Date.now() / 1000; + this.delta = now - this.lastTime; + this.frameTime += this.delta; + this.totalTime += this.delta; + if (this.delta > this.maxDelta) + this.delta = this.maxDelta; + this.lastTime = now; + this.frameCount++; + if (this.frameTime > 1) { + this.framesPerSecond = this.frameCount / this.frameTime; + this.frameTime = 0; + this.frameCount = 0; + } + }; + return TimeKeeper; + }()); + spine.TimeKeeper = TimeKeeper; + var WindowedMean = (function () { + function WindowedMean(windowSize) { + if (windowSize === void 0) { windowSize = 32; } + this.addedValues = 0; + this.lastValue = 0; + this.mean = 0; + this.dirty = true; + this.values = new Array(windowSize); + } + WindowedMean.prototype.hasEnoughData = function () { + return this.addedValues >= this.values.length; + }; + WindowedMean.prototype.addValue = function (value) { + if (this.addedValues < this.values.length) + this.addedValues++; + this.values[this.lastValue++] = value; + if (this.lastValue > this.values.length - 1) + this.lastValue = 0; + this.dirty = true; + }; + WindowedMean.prototype.getMean = function () { + if (this.hasEnoughData()) { + if (this.dirty) { + var mean = 0; + for (var i = 0; i < this.values.length; i++) { + mean += this.values[i]; + } + this.mean = mean / this.values.length; + this.dirty = false; + } + return this.mean; + } + else { + return 0; + } + }; + return WindowedMean; + }()); + spine.WindowedMean = WindowedMean; +})(spine || (spine = {})); +(function () { + if (!Math.fround) { + Math.fround = (function (array) { + return function (x) { + return array[0] = x, array[0]; + }; + })(new Float32Array(1)); + } +})(); +var spine; +(function (spine) { + var Attachment = (function () { + function Attachment(name) { + if (name == null) + throw new Error("name cannot be null."); + this.name = name; + } + return Attachment; + }()); + spine.Attachment = Attachment; + var VertexAttachment = (function (_super) { + __extends(VertexAttachment, _super); + function VertexAttachment(name) { + var _this = _super.call(this, name) || this; + _this.id = (VertexAttachment.nextID++ & 65535) << 11; + _this.worldVerticesLength = 0; + return _this; + } + VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) { + count = offset + (count >> 1) * stride; + var skeleton = slot.bone.skeleton; + var deformArray = slot.attachmentVertices; + var vertices = this.vertices; + var bones = this.bones; + if (bones == null) { + if (deformArray.length > 0) + vertices = deformArray; + var bone = slot.bone; + var x = bone.worldX; + var y = bone.worldY; + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) { + var vx = vertices[v_1], vy = vertices[v_1 + 1]; + worldVertices[w] = vx * a + vy * b + x; + worldVertices[w + 1] = vx * c + vy * d + y; + } + return; + } + var v = 0, skip = 0; + for (var i = 0; i < start; i += 2) { + var n = bones[v]; + v += n + 1; + skip += n; + } + var skeletonBones = skeleton.bones; + if (deformArray.length == 0) { + for (var w = offset, b = skip * 3; w < count; w += stride) { + var wx = 0, wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3) { + var bone = skeletonBones[bones[v]]; + var vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2]; + wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight; + wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } + else { + var deform = deformArray; + for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) { + var wx = 0, wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3, f += 2) { + var bone = skeletonBones[bones[v]]; + var vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2]; + wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight; + wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } + }; + VertexAttachment.prototype.applyDeform = function (sourceAttachment) { + return this == sourceAttachment; + }; + VertexAttachment.nextID = 0; + return VertexAttachment; + }(Attachment)); + spine.VertexAttachment = VertexAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AttachmentType; + (function (AttachmentType) { + AttachmentType[AttachmentType["Region"] = 0] = "Region"; + AttachmentType[AttachmentType["BoundingBox"] = 1] = "BoundingBox"; + AttachmentType[AttachmentType["Mesh"] = 2] = "Mesh"; + AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh"; + AttachmentType[AttachmentType["Path"] = 4] = "Path"; + AttachmentType[AttachmentType["Point"] = 5] = "Point"; + })(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var BoundingBoxAttachment = (function (_super) { + __extends(BoundingBoxAttachment, _super); + function BoundingBoxAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(1, 1, 1, 1); + return _this; + } + return BoundingBoxAttachment; + }(spine.VertexAttachment)); + spine.BoundingBoxAttachment = BoundingBoxAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var ClippingAttachment = (function (_super) { + __extends(ClippingAttachment, _super); + function ClippingAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(0.2275, 0.2275, 0.8078, 1); + return _this; + } + return ClippingAttachment; + }(spine.VertexAttachment)); + spine.ClippingAttachment = ClippingAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var MeshAttachment = (function (_super) { + __extends(MeshAttachment, _super); + function MeshAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(1, 1, 1, 1); + _this.inheritDeform = false; + _this.tempColor = new spine.Color(0, 0, 0, 0); + return _this; + } + MeshAttachment.prototype.updateUVs = function () { + var u = 0, v = 0, width = 0, height = 0; + if (this.region == null) { + u = v = 0; + width = height = 1; + } + else { + u = this.region.u; + v = this.region.v; + width = this.region.u2 - u; + height = this.region.v2 - v; + } + var regionUVs = this.regionUVs; + if (this.uvs == null || this.uvs.length != regionUVs.length) + this.uvs = spine.Utils.newFloatArray(regionUVs.length); + var uvs = this.uvs; + if (this.region.rotate) { + for (var i = 0, n = uvs.length; i < n; i += 2) { + uvs[i] = u + regionUVs[i + 1] * width; + uvs[i + 1] = v + height - regionUVs[i] * height; + } + } + else { + for (var i = 0, n = uvs.length; i < n; i += 2) { + uvs[i] = u + regionUVs[i] * width; + uvs[i + 1] = v + regionUVs[i + 1] * height; + } + } + }; + MeshAttachment.prototype.applyDeform = function (sourceAttachment) { + return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment); + }; + MeshAttachment.prototype.getParentMesh = function () { + return this.parentMesh; + }; + MeshAttachment.prototype.setParentMesh = function (parentMesh) { + this.parentMesh = parentMesh; + if (parentMesh != null) { + this.bones = parentMesh.bones; + this.vertices = parentMesh.vertices; + this.worldVerticesLength = parentMesh.worldVerticesLength; + this.regionUVs = parentMesh.regionUVs; + this.triangles = parentMesh.triangles; + this.hullLength = parentMesh.hullLength; + this.worldVerticesLength = parentMesh.worldVerticesLength; + } + }; + return MeshAttachment; + }(spine.VertexAttachment)); + spine.MeshAttachment = MeshAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PathAttachment = (function (_super) { + __extends(PathAttachment, _super); + function PathAttachment(name) { + var _this = _super.call(this, name) || this; + _this.closed = false; + _this.constantSpeed = false; + _this.color = new spine.Color(1, 1, 1, 1); + return _this; + } + return PathAttachment; + }(spine.VertexAttachment)); + spine.PathAttachment = PathAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PointAttachment = (function (_super) { + __extends(PointAttachment, _super); + function PointAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(0.38, 0.94, 0, 1); + return _this; + } + PointAttachment.prototype.computeWorldPosition = function (bone, point) { + point.x = this.x * bone.a + this.y * bone.b + bone.worldX; + point.y = this.x * bone.c + this.y * bone.d + bone.worldY; + return point; + }; + PointAttachment.prototype.computeWorldRotation = function (bone) { + var cos = spine.MathUtils.cosDeg(this.rotation), sin = spine.MathUtils.sinDeg(this.rotation); + var x = cos * bone.a + sin * bone.b; + var y = cos * bone.c + sin * bone.d; + return Math.atan2(y, x) * spine.MathUtils.radDeg; + }; + return PointAttachment; + }(spine.VertexAttachment)); + spine.PointAttachment = PointAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var RegionAttachment = (function (_super) { + __extends(RegionAttachment, _super); + function RegionAttachment(name) { + var _this = _super.call(this, name) || this; + _this.x = 0; + _this.y = 0; + _this.scaleX = 1; + _this.scaleY = 1; + _this.rotation = 0; + _this.width = 0; + _this.height = 0; + _this.color = new spine.Color(1, 1, 1, 1); + _this.offset = spine.Utils.newFloatArray(8); + _this.uvs = spine.Utils.newFloatArray(8); + _this.tempColor = new spine.Color(1, 1, 1, 1); + return _this; + } + RegionAttachment.prototype.updateOffset = function () { + var regionScaleX = this.width / this.region.originalWidth * this.scaleX; + var regionScaleY = this.height / this.region.originalHeight * this.scaleY; + var localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX; + var localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY; + var localX2 = localX + this.region.width * regionScaleX; + var localY2 = localY + this.region.height * regionScaleY; + var radians = this.rotation * Math.PI / 180; + var cos = Math.cos(radians); + var sin = Math.sin(radians); + var localXCos = localX * cos + this.x; + var localXSin = localX * sin; + var localYCos = localY * cos + this.y; + var localYSin = localY * sin; + var localX2Cos = localX2 * cos + this.x; + var localX2Sin = localX2 * sin; + var localY2Cos = localY2 * cos + this.y; + var localY2Sin = localY2 * sin; + var offset = this.offset; + offset[RegionAttachment.OX1] = localXCos - localYSin; + offset[RegionAttachment.OY1] = localYCos + localXSin; + offset[RegionAttachment.OX2] = localXCos - localY2Sin; + offset[RegionAttachment.OY2] = localY2Cos + localXSin; + offset[RegionAttachment.OX3] = localX2Cos - localY2Sin; + offset[RegionAttachment.OY3] = localY2Cos + localX2Sin; + offset[RegionAttachment.OX4] = localX2Cos - localYSin; + offset[RegionAttachment.OY4] = localYCos + localX2Sin; + }; + RegionAttachment.prototype.setRegion = function (region) { + this.region = region; + var uvs = this.uvs; + if (region.rotate) { + uvs[2] = region.u; + uvs[3] = region.v2; + uvs[4] = region.u; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v; + uvs[0] = region.u2; + uvs[1] = region.v2; + } + else { + uvs[0] = region.u; + uvs[1] = region.v2; + uvs[2] = region.u; + uvs[3] = region.v; + uvs[4] = region.u2; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v2; + } + }; + RegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) { + var vertexOffset = this.offset; + var x = bone.worldX, y = bone.worldY; + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var offsetX = 0, offsetY = 0; + offsetX = vertexOffset[RegionAttachment.OX1]; + offsetY = vertexOffset[RegionAttachment.OY1]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX2]; + offsetY = vertexOffset[RegionAttachment.OY2]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX3]; + offsetY = vertexOffset[RegionAttachment.OY3]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX4]; + offsetY = vertexOffset[RegionAttachment.OY4]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + }; + RegionAttachment.OX1 = 0; + RegionAttachment.OY1 = 1; + RegionAttachment.OX2 = 2; + RegionAttachment.OY2 = 3; + RegionAttachment.OX3 = 4; + RegionAttachment.OY3 = 5; + RegionAttachment.OX4 = 6; + RegionAttachment.OY4 = 7; + RegionAttachment.X1 = 0; + RegionAttachment.Y1 = 1; + RegionAttachment.C1R = 2; + RegionAttachment.C1G = 3; + RegionAttachment.C1B = 4; + RegionAttachment.C1A = 5; + RegionAttachment.U1 = 6; + RegionAttachment.V1 = 7; + RegionAttachment.X2 = 8; + RegionAttachment.Y2 = 9; + RegionAttachment.C2R = 10; + RegionAttachment.C2G = 11; + RegionAttachment.C2B = 12; + RegionAttachment.C2A = 13; + RegionAttachment.U2 = 14; + RegionAttachment.V2 = 15; + RegionAttachment.X3 = 16; + RegionAttachment.Y3 = 17; + RegionAttachment.C3R = 18; + RegionAttachment.C3G = 19; + RegionAttachment.C3B = 20; + RegionAttachment.C3A = 21; + RegionAttachment.U3 = 22; + RegionAttachment.V3 = 23; + RegionAttachment.X4 = 24; + RegionAttachment.Y4 = 25; + RegionAttachment.C4R = 26; + RegionAttachment.C4G = 27; + RegionAttachment.C4B = 28; + RegionAttachment.C4A = 29; + RegionAttachment.U4 = 30; + RegionAttachment.V4 = 31; + return RegionAttachment; + }(spine.Attachment)); + spine.RegionAttachment = RegionAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var JitterEffect = (function () { + function JitterEffect(jitterX, jitterY) { + this.jitterX = 0; + this.jitterY = 0; + this.jitterX = jitterX; + this.jitterY = jitterY; + } + JitterEffect.prototype.begin = function (skeleton) { + }; + JitterEffect.prototype.transform = function (position, uv, light, dark) { + position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + }; + JitterEffect.prototype.end = function () { + }; + return JitterEffect; + }()); + spine.JitterEffect = JitterEffect; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SwirlEffect = (function () { + function SwirlEffect(radius) { + this.centerX = 0; + this.centerY = 0; + this.radius = 0; + this.angle = 0; + this.worldX = 0; + this.worldY = 0; + this.radius = radius; + } + SwirlEffect.prototype.begin = function (skeleton) { + this.worldX = skeleton.x + this.centerX; + this.worldY = skeleton.y + this.centerY; + }; + SwirlEffect.prototype.transform = function (position, uv, light, dark) { + var radAngle = this.angle * spine.MathUtils.degreesToRadians; + var x = position.x - this.worldX; + var y = position.y - this.worldY; + var dist = Math.sqrt(x * x + y * y); + if (dist < this.radius) { + var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius); + var cos = Math.cos(theta); + var sin = Math.sin(theta); + position.x = cos * x - sin * y + this.worldX; + position.y = sin * x + cos * y + this.worldY; + } + }; + SwirlEffect.prototype.end = function () { + }; + SwirlEffect.interpolation = new spine.PowOut(2); + return SwirlEffect; + }()); + spine.SwirlEffect = SwirlEffect; +})(spine || (spine = {})); +var spine; +(function (spine) { + var canvas; + (function (canvas) { + var AssetManager = (function (_super) { + __extends(AssetManager, _super); + function AssetManager(pathPrefix) { + if (pathPrefix === void 0) { pathPrefix = ""; } + return _super.call(this, function (image) { return new spine.canvas.CanvasTexture(image); }, pathPrefix) || this; + } + return AssetManager; + }(spine.AssetManager)); + canvas.AssetManager = AssetManager; + })(canvas = spine.canvas || (spine.canvas = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var canvas; + (function (canvas) { + var CanvasTexture = (function (_super) { + __extends(CanvasTexture, _super); + function CanvasTexture(image) { + return _super.call(this, image) || this; + } + CanvasTexture.prototype.setFilters = function (minFilter, magFilter) { }; + CanvasTexture.prototype.setWraps = function (uWrap, vWrap) { }; + CanvasTexture.prototype.dispose = function () { }; + return CanvasTexture; + }(spine.Texture)); + canvas.CanvasTexture = CanvasTexture; + })(canvas = spine.canvas || (spine.canvas = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var canvas; + (function (canvas) { + var SkeletonRenderer = (function () { + function SkeletonRenderer(context) { + this.triangleRendering = false; + this.debugRendering = false; + this.vertices = spine.Utils.newFloatArray(8 * 1024); + this.tempColor = new spine.Color(); + this.ctx = context; + } + SkeletonRenderer.prototype.draw = function (skeleton) { + if (this.triangleRendering) + this.drawTriangles(skeleton); + else + this.drawImages(skeleton); + }; + SkeletonRenderer.prototype.drawImages = function (skeleton) { + var ctx = this.ctx; + var drawOrder = skeleton.drawOrder; + if (this.debugRendering) + ctx.strokeStyle = "green"; + ctx.save(); + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + var attachment = slot.getAttachment(); + var regionAttachment = null; + var region = null; + var image = null; + if (attachment instanceof spine.RegionAttachment) { + regionAttachment = attachment; + region = regionAttachment.region; + image = region.texture.getImage(); + } + else + continue; + var skeleton_1 = slot.bone.skeleton; + var skeletonColor = skeleton_1.color; + var slotColor = slot.color; + var regionColor = regionAttachment.color; + var alpha = skeletonColor.a * slotColor.a * regionColor.a; + var color = this.tempColor; + color.set(skeletonColor.r * slotColor.r * regionColor.r, skeletonColor.g * slotColor.g * regionColor.g, skeletonColor.b * slotColor.b * regionColor.b, alpha); + var att = attachment; + var bone = slot.bone; + var w = region.width; + var h = region.height; + ctx.save(); + ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY); + ctx.translate(attachment.offset[0], attachment.offset[1]); + ctx.rotate(attachment.rotation * Math.PI / 180); + var atlasScale = att.width / w; + ctx.scale(atlasScale * attachment.scaleX, atlasScale * attachment.scaleY); + ctx.translate(w / 2, h / 2); + if (attachment.region.rotate) { + var t = w; + w = h; + h = t; + ctx.rotate(-Math.PI / 2); + } + ctx.scale(1, -1); + ctx.translate(-w / 2, -h / 2); + if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) { + ctx.globalAlpha = color.a; + } + ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h); + if (this.debugRendering) + ctx.strokeRect(0, 0, w, h); + ctx.restore(); + } + ctx.restore(); + }; + SkeletonRenderer.prototype.drawTriangles = function (skeleton) { + var blendMode = null; + var vertices = this.vertices; + var triangles = null; + var drawOrder = skeleton.drawOrder; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + var attachment = slot.getAttachment(); + var texture = null; + var region = null; + if (attachment instanceof spine.RegionAttachment) { + var regionAttachment = attachment; + vertices = this.computeRegionVertices(slot, regionAttachment, false); + triangles = SkeletonRenderer.QUAD_TRIANGLES; + region = regionAttachment.region; + texture = region.texture.getImage(); + } + else if (attachment instanceof spine.MeshAttachment) { + var mesh = attachment; + vertices = this.computeMeshVertices(slot, mesh, false); + triangles = mesh.triangles; + texture = mesh.region.renderObject.texture.getImage(); + } + else + continue; + if (texture != null) { + var slotBlendMode = slot.data.blendMode; + if (slotBlendMode != blendMode) { + blendMode = slotBlendMode; + } + var skeleton_2 = slot.bone.skeleton; + var skeletonColor = skeleton_2.color; + var slotColor = slot.color; + var attachmentColor = attachment.color; + var alpha = skeletonColor.a * slotColor.a * attachmentColor.a; + var color = this.tempColor; + color.set(skeletonColor.r * slotColor.r * attachmentColor.r, skeletonColor.g * slotColor.g * attachmentColor.g, skeletonColor.b * slotColor.b * attachmentColor.b, alpha); + var ctx = this.ctx; + if (color.r != 1 || color.g != 1 || color.b != 1 || color.a != 1) { + ctx.globalAlpha = color.a; + } + for (var j = 0; j < triangles.length; j += 3) { + var t1 = triangles[j] * 8, t2 = triangles[j + 1] * 8, t3 = triangles[j + 2] * 8; + var x0 = vertices[t1], y0 = vertices[t1 + 1], u0 = vertices[t1 + 6], v0 = vertices[t1 + 7]; + var x1 = vertices[t2], y1 = vertices[t2 + 1], u1 = vertices[t2 + 6], v1 = vertices[t2 + 7]; + var x2 = vertices[t3], y2 = vertices[t3 + 1], u2 = vertices[t3 + 6], v2 = vertices[t3 + 7]; + this.drawTriangle(texture, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2); + if (this.debugRendering) { + ctx.strokeStyle = "green"; + ctx.beginPath(); + ctx.moveTo(x0, y0); + ctx.lineTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.lineTo(x0, y0); + ctx.stroke(); + } + } + } + } + this.ctx.globalAlpha = 1; + }; + SkeletonRenderer.prototype.drawTriangle = function (img, x0, y0, u0, v0, x1, y1, u1, v1, x2, y2, u2, v2) { + var ctx = this.ctx; + u0 *= img.width; + v0 *= img.height; + u1 *= img.width; + v1 *= img.height; + u2 *= img.width; + v2 *= img.height; + ctx.beginPath(); + ctx.moveTo(x0, y0); + ctx.lineTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.closePath(); + x1 -= x0; + y1 -= y0; + x2 -= x0; + y2 -= y0; + u1 -= u0; + v1 -= v0; + u2 -= u0; + v2 -= v0; + var det = 1 / (u1 * v2 - u2 * v1), a = (v2 * x1 - v1 * x2) * det, b = (v2 * y1 - v1 * y2) * det, c = (u1 * x2 - u2 * x1) * det, d = (u1 * y2 - u2 * y1) * det, e = x0 - a * u0 - c * v0, f = y0 - b * u0 - d * v0; + ctx.save(); + ctx.transform(a, b, c, d, e, f); + ctx.clip(); + ctx.drawImage(img, 0, 0); + ctx.restore(); + }; + SkeletonRenderer.prototype.computeRegionVertices = function (slot, region, pma) { + var skeleton = slot.bone.skeleton; + var skeletonColor = skeleton.color; + var slotColor = slot.color; + var regionColor = region.color; + var alpha = skeletonColor.a * slotColor.a * regionColor.a; + var multiplier = pma ? alpha : 1; + var color = this.tempColor; + color.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha); + region.computeWorldVertices(slot.bone, this.vertices, 0, SkeletonRenderer.VERTEX_SIZE); + var vertices = this.vertices; + var uvs = region.uvs; + vertices[spine.RegionAttachment.C1R] = color.r; + vertices[spine.RegionAttachment.C1G] = color.g; + vertices[spine.RegionAttachment.C1B] = color.b; + vertices[spine.RegionAttachment.C1A] = color.a; + vertices[spine.RegionAttachment.U1] = uvs[0]; + vertices[spine.RegionAttachment.V1] = uvs[1]; + vertices[spine.RegionAttachment.C2R] = color.r; + vertices[spine.RegionAttachment.C2G] = color.g; + vertices[spine.RegionAttachment.C2B] = color.b; + vertices[spine.RegionAttachment.C2A] = color.a; + vertices[spine.RegionAttachment.U2] = uvs[2]; + vertices[spine.RegionAttachment.V2] = uvs[3]; + vertices[spine.RegionAttachment.C3R] = color.r; + vertices[spine.RegionAttachment.C3G] = color.g; + vertices[spine.RegionAttachment.C3B] = color.b; + vertices[spine.RegionAttachment.C3A] = color.a; + vertices[spine.RegionAttachment.U3] = uvs[4]; + vertices[spine.RegionAttachment.V3] = uvs[5]; + vertices[spine.RegionAttachment.C4R] = color.r; + vertices[spine.RegionAttachment.C4G] = color.g; + vertices[spine.RegionAttachment.C4B] = color.b; + vertices[spine.RegionAttachment.C4A] = color.a; + vertices[spine.RegionAttachment.U4] = uvs[6]; + vertices[spine.RegionAttachment.V4] = uvs[7]; + return vertices; + }; + SkeletonRenderer.prototype.computeMeshVertices = function (slot, mesh, pma) { + var skeleton = slot.bone.skeleton; + var skeletonColor = skeleton.color; + var slotColor = slot.color; + var regionColor = mesh.color; + var alpha = skeletonColor.a * slotColor.a * regionColor.a; + var multiplier = pma ? alpha : 1; + var color = this.tempColor; + color.set(skeletonColor.r * slotColor.r * regionColor.r * multiplier, skeletonColor.g * slotColor.g * regionColor.g * multiplier, skeletonColor.b * slotColor.b * regionColor.b * multiplier, alpha); + var numVertices = mesh.worldVerticesLength / 2; + if (this.vertices.length < mesh.worldVerticesLength) { + this.vertices = spine.Utils.newFloatArray(mesh.worldVerticesLength); + } + var vertices = this.vertices; + mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, SkeletonRenderer.VERTEX_SIZE); + var uvs = mesh.uvs; + for (var i = 0, n = numVertices, u = 0, v = 2; i < n; i++) { + vertices[v++] = color.r; + vertices[v++] = color.g; + vertices[v++] = color.b; + vertices[v++] = color.a; + vertices[v++] = uvs[u++]; + vertices[v++] = uvs[u++]; + v += 2; + } + return vertices; + }; + SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0]; + SkeletonRenderer.VERTEX_SIZE = 2 + 2 + 4; + return SkeletonRenderer; + }()); + canvas.SkeletonRenderer = SkeletonRenderer; + })(canvas = spine.canvas || (spine.canvas = {})); +})(spine || (spine = {})); +//# sourceMappingURL=spine-canvas.js.map \ No newline at end of file diff --git a/plugins/spine/src/runtimes/spine-webgl.js b/plugins/spine/src/runtimes/spine-webgl.js new file mode 100644 index 000000000..d79b64283 --- /dev/null +++ b/plugins/spine/src/runtimes/spine-webgl.js @@ -0,0 +1,9185 @@ +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var spine; +(function (spine) { + var Animation = (function () { + function Animation(name, timelines, duration) { + if (name == null) + throw new Error("name cannot be null."); + if (timelines == null) + throw new Error("timelines cannot be null."); + this.name = name; + this.timelines = timelines; + this.duration = duration; + } + Animation.prototype.apply = function (skeleton, lastTime, time, loop, events, alpha, pose, direction) { + if (skeleton == null) + throw new Error("skeleton cannot be null."); + if (loop && this.duration != 0) { + time %= this.duration; + if (lastTime > 0) + lastTime %= this.duration; + } + var timelines = this.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + timelines[i].apply(skeleton, lastTime, time, events, alpha, pose, direction); + }; + Animation.binarySearch = function (values, target, step) { + if (step === void 0) { step = 1; } + var low = 0; + var high = values.length / step - 2; + if (high == 0) + return step; + var current = high >>> 1; + while (true) { + if (values[(current + 1) * step] <= target) + low = current + 1; + else + high = current; + if (low == high) + return (low + 1) * step; + current = (low + high) >>> 1; + } + }; + Animation.linearSearch = function (values, target, step) { + for (var i = 0, last = values.length - step; i <= last; i += step) + if (values[i] > target) + return i; + return -1; + }; + return Animation; + }()); + spine.Animation = Animation; + var MixPose; + (function (MixPose) { + MixPose[MixPose["setup"] = 0] = "setup"; + MixPose[MixPose["current"] = 1] = "current"; + MixPose[MixPose["currentLayered"] = 2] = "currentLayered"; + })(MixPose = spine.MixPose || (spine.MixPose = {})); + var MixDirection; + (function (MixDirection) { + MixDirection[MixDirection["in"] = 0] = "in"; + MixDirection[MixDirection["out"] = 1] = "out"; + })(MixDirection = spine.MixDirection || (spine.MixDirection = {})); + var TimelineType; + (function (TimelineType) { + TimelineType[TimelineType["rotate"] = 0] = "rotate"; + TimelineType[TimelineType["translate"] = 1] = "translate"; + TimelineType[TimelineType["scale"] = 2] = "scale"; + TimelineType[TimelineType["shear"] = 3] = "shear"; + TimelineType[TimelineType["attachment"] = 4] = "attachment"; + TimelineType[TimelineType["color"] = 5] = "color"; + TimelineType[TimelineType["deform"] = 6] = "deform"; + TimelineType[TimelineType["event"] = 7] = "event"; + TimelineType[TimelineType["drawOrder"] = 8] = "drawOrder"; + TimelineType[TimelineType["ikConstraint"] = 9] = "ikConstraint"; + TimelineType[TimelineType["transformConstraint"] = 10] = "transformConstraint"; + TimelineType[TimelineType["pathConstraintPosition"] = 11] = "pathConstraintPosition"; + TimelineType[TimelineType["pathConstraintSpacing"] = 12] = "pathConstraintSpacing"; + TimelineType[TimelineType["pathConstraintMix"] = 13] = "pathConstraintMix"; + TimelineType[TimelineType["twoColor"] = 14] = "twoColor"; + })(TimelineType = spine.TimelineType || (spine.TimelineType = {})); + var CurveTimeline = (function () { + function CurveTimeline(frameCount) { + if (frameCount <= 0) + throw new Error("frameCount must be > 0: " + frameCount); + this.curves = spine.Utils.newFloatArray((frameCount - 1) * CurveTimeline.BEZIER_SIZE); + } + CurveTimeline.prototype.getFrameCount = function () { + return this.curves.length / CurveTimeline.BEZIER_SIZE + 1; + }; + CurveTimeline.prototype.setLinear = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.LINEAR; + }; + CurveTimeline.prototype.setStepped = function (frameIndex) { + this.curves[frameIndex * CurveTimeline.BEZIER_SIZE] = CurveTimeline.STEPPED; + }; + CurveTimeline.prototype.getCurveType = function (frameIndex) { + var index = frameIndex * CurveTimeline.BEZIER_SIZE; + if (index == this.curves.length) + return CurveTimeline.LINEAR; + var type = this.curves[index]; + if (type == CurveTimeline.LINEAR) + return CurveTimeline.LINEAR; + if (type == CurveTimeline.STEPPED) + return CurveTimeline.STEPPED; + return CurveTimeline.BEZIER; + }; + CurveTimeline.prototype.setCurve = function (frameIndex, cx1, cy1, cx2, cy2) { + var tmpx = (-cx1 * 2 + cx2) * 0.03, tmpy = (-cy1 * 2 + cy2) * 0.03; + var dddfx = ((cx1 - cx2) * 3 + 1) * 0.006, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006; + var ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy; + var dfx = cx1 * 0.3 + tmpx + dddfx * 0.16666667, dfy = cy1 * 0.3 + tmpy + dddfy * 0.16666667; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var curves = this.curves; + curves[i++] = CurveTimeline.BEZIER; + var x = dfx, y = dfy; + for (var n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + curves[i] = x; + curves[i + 1] = y; + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + x += dfx; + y += dfy; + } + }; + CurveTimeline.prototype.getCurvePercent = function (frameIndex, percent) { + percent = spine.MathUtils.clamp(percent, 0, 1); + var curves = this.curves; + var i = frameIndex * CurveTimeline.BEZIER_SIZE; + var type = curves[i]; + if (type == CurveTimeline.LINEAR) + return percent; + if (type == CurveTimeline.STEPPED) + return 0; + i++; + var x = 0; + for (var start = i, n = i + CurveTimeline.BEZIER_SIZE - 1; i < n; i += 2) { + x = curves[i]; + if (x >= percent) { + var prevX = void 0, prevY = void 0; + if (i == start) { + prevX = 0; + prevY = 0; + } + else { + prevX = curves[i - 2]; + prevY = curves[i - 1]; + } + return prevY + (curves[i + 1] - prevY) * (percent - prevX) / (x - prevX); + } + } + var y = curves[i - 1]; + return y + (1 - y) * (percent - x) / (1 - x); + }; + CurveTimeline.LINEAR = 0; + CurveTimeline.STEPPED = 1; + CurveTimeline.BEZIER = 2; + CurveTimeline.BEZIER_SIZE = 10 * 2 - 1; + return CurveTimeline; + }()); + spine.CurveTimeline = CurveTimeline; + var RotateTimeline = (function (_super) { + __extends(RotateTimeline, _super); + function RotateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount << 1); + return _this; + } + RotateTimeline.prototype.getPropertyId = function () { + return (TimelineType.rotate << 24) + this.boneIndex; + }; + RotateTimeline.prototype.setFrame = function (frameIndex, time, degrees) { + frameIndex <<= 1; + this.frames[frameIndex] = time; + this.frames[frameIndex + RotateTimeline.ROTATION] = degrees; + }; + RotateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.rotation = bone.data.rotation; + return; + case MixPose.current: + var r_1 = bone.data.rotation - bone.rotation; + r_1 -= (16384 - ((16384.499999999996 - r_1 / 360) | 0)) * 360; + bone.rotation += r_1 * alpha; + } + return; + } + if (time >= frames[frames.length - RotateTimeline.ENTRIES]) { + if (pose == MixPose.setup) + bone.rotation = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] * alpha; + else { + var r_2 = bone.data.rotation + frames[frames.length + RotateTimeline.PREV_ROTATION] - bone.rotation; + r_2 -= (16384 - ((16384.499999999996 - r_2 / 360) | 0)) * 360; + bone.rotation += r_2 * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time, RotateTimeline.ENTRIES); + var prevRotation = frames[frame + RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + RotateTimeline.PREV_TIME] - frameTime)); + var r = frames[frame + RotateTimeline.ROTATION] - prevRotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + r = prevRotation + r * percent; + if (pose == MixPose.setup) { + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.rotation = bone.data.rotation + r * alpha; + } + else { + r = bone.data.rotation + r - bone.rotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.rotation += r * alpha; + } + }; + RotateTimeline.ENTRIES = 2; + RotateTimeline.PREV_TIME = -2; + RotateTimeline.PREV_ROTATION = -1; + RotateTimeline.ROTATION = 1; + return RotateTimeline; + }(CurveTimeline)); + spine.RotateTimeline = RotateTimeline; + var TranslateTimeline = (function (_super) { + __extends(TranslateTimeline, _super); + function TranslateTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TranslateTimeline.ENTRIES); + return _this; + } + TranslateTimeline.prototype.getPropertyId = function () { + return (TimelineType.translate << 24) + this.boneIndex; + }; + TranslateTimeline.prototype.setFrame = function (frameIndex, time, x, y) { + frameIndex *= TranslateTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TranslateTimeline.X] = x; + this.frames[frameIndex + TranslateTimeline.Y] = y; + }; + TranslateTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.x = bone.data.x; + bone.y = bone.data.y; + return; + case MixPose.current: + bone.x += (bone.data.x - bone.x) * alpha; + bone.y += (bone.data.y - bone.y) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - TranslateTimeline.ENTRIES]) { + x = frames[frames.length + TranslateTimeline.PREV_X]; + y = frames[frames.length + TranslateTimeline.PREV_Y]; + } + else { + var frame = Animation.binarySearch(frames, time, TranslateTimeline.ENTRIES); + x = frames[frame + TranslateTimeline.PREV_X]; + y = frames[frame + TranslateTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TranslateTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TranslateTimeline.PREV_TIME] - frameTime)); + x += (frames[frame + TranslateTimeline.X] - x) * percent; + y += (frames[frame + TranslateTimeline.Y] - y) * percent; + } + if (pose == MixPose.setup) { + bone.x = bone.data.x + x * alpha; + bone.y = bone.data.y + y * alpha; + } + else { + bone.x += (bone.data.x + x - bone.x) * alpha; + bone.y += (bone.data.y + y - bone.y) * alpha; + } + }; + TranslateTimeline.ENTRIES = 3; + TranslateTimeline.PREV_TIME = -3; + TranslateTimeline.PREV_X = -2; + TranslateTimeline.PREV_Y = -1; + TranslateTimeline.X = 1; + TranslateTimeline.Y = 2; + return TranslateTimeline; + }(CurveTimeline)); + spine.TranslateTimeline = TranslateTimeline; + var ScaleTimeline = (function (_super) { + __extends(ScaleTimeline, _super); + function ScaleTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ScaleTimeline.prototype.getPropertyId = function () { + return (TimelineType.scale << 24) + this.boneIndex; + }; + ScaleTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.scaleX = bone.data.scaleX; + bone.scaleY = bone.data.scaleY; + return; + case MixPose.current: + bone.scaleX += (bone.data.scaleX - bone.scaleX) * alpha; + bone.scaleY += (bone.data.scaleY - bone.scaleY) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - ScaleTimeline.ENTRIES]) { + x = frames[frames.length + ScaleTimeline.PREV_X] * bone.data.scaleX; + y = frames[frames.length + ScaleTimeline.PREV_Y] * bone.data.scaleY; + } + else { + var frame = Animation.binarySearch(frames, time, ScaleTimeline.ENTRIES); + x = frames[frame + ScaleTimeline.PREV_X]; + y = frames[frame + ScaleTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ScaleTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ScaleTimeline.PREV_TIME] - frameTime)); + x = (x + (frames[frame + ScaleTimeline.X] - x) * percent) * bone.data.scaleX; + y = (y + (frames[frame + ScaleTimeline.Y] - y) * percent) * bone.data.scaleY; + } + if (alpha == 1) { + bone.scaleX = x; + bone.scaleY = y; + } + else { + var bx = 0, by = 0; + if (pose == MixPose.setup) { + bx = bone.data.scaleX; + by = bone.data.scaleY; + } + else { + bx = bone.scaleX; + by = bone.scaleY; + } + if (direction == MixDirection.out) { + x = Math.abs(x) * spine.MathUtils.signum(bx); + y = Math.abs(y) * spine.MathUtils.signum(by); + } + else { + bx = Math.abs(bx) * spine.MathUtils.signum(x); + by = Math.abs(by) * spine.MathUtils.signum(y); + } + bone.scaleX = bx + (x - bx) * alpha; + bone.scaleY = by + (y - by) * alpha; + } + }; + return ScaleTimeline; + }(TranslateTimeline)); + spine.ScaleTimeline = ScaleTimeline; + var ShearTimeline = (function (_super) { + __extends(ShearTimeline, _super); + function ShearTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + ShearTimeline.prototype.getPropertyId = function () { + return (TimelineType.shear << 24) + this.boneIndex; + }; + ShearTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var frames = this.frames; + var bone = skeleton.bones[this.boneIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + bone.shearX = bone.data.shearX; + bone.shearY = bone.data.shearY; + return; + case MixPose.current: + bone.shearX += (bone.data.shearX - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY - bone.shearY) * alpha; + } + return; + } + var x = 0, y = 0; + if (time >= frames[frames.length - ShearTimeline.ENTRIES]) { + x = frames[frames.length + ShearTimeline.PREV_X]; + y = frames[frames.length + ShearTimeline.PREV_Y]; + } + else { + var frame = Animation.binarySearch(frames, time, ShearTimeline.ENTRIES); + x = frames[frame + ShearTimeline.PREV_X]; + y = frames[frame + ShearTimeline.PREV_Y]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ShearTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ShearTimeline.PREV_TIME] - frameTime)); + x = x + (frames[frame + ShearTimeline.X] - x) * percent; + y = y + (frames[frame + ShearTimeline.Y] - y) * percent; + } + if (pose == MixPose.setup) { + bone.shearX = bone.data.shearX + x * alpha; + bone.shearY = bone.data.shearY + y * alpha; + } + else { + bone.shearX += (bone.data.shearX + x - bone.shearX) * alpha; + bone.shearY += (bone.data.shearY + y - bone.shearY) * alpha; + } + }; + return ShearTimeline; + }(TranslateTimeline)); + spine.ShearTimeline = ShearTimeline; + var ColorTimeline = (function (_super) { + __extends(ColorTimeline, _super); + function ColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * ColorTimeline.ENTRIES); + return _this; + } + ColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.color << 24) + this.slotIndex; + }; + ColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a) { + frameIndex *= ColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + ColorTimeline.R] = r; + this.frames[frameIndex + ColorTimeline.G] = g; + this.frames[frameIndex + ColorTimeline.B] = b; + this.frames[frameIndex + ColorTimeline.A] = a; + }; + ColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + var frames = this.frames; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + slot.color.setFromColor(slot.data.color); + return; + case MixPose.current: + var color = slot.color, setup = slot.data.color; + color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha, (setup.a - color.a) * alpha); + } + return; + } + var r = 0, g = 0, b = 0, a = 0; + if (time >= frames[frames.length - ColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + ColorTimeline.PREV_R]; + g = frames[i + ColorTimeline.PREV_G]; + b = frames[i + ColorTimeline.PREV_B]; + a = frames[i + ColorTimeline.PREV_A]; + } + else { + var frame = Animation.binarySearch(frames, time, ColorTimeline.ENTRIES); + r = frames[frame + ColorTimeline.PREV_R]; + g = frames[frame + ColorTimeline.PREV_G]; + b = frames[frame + ColorTimeline.PREV_B]; + a = frames[frame + ColorTimeline.PREV_A]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / ColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + ColorTimeline.PREV_TIME] - frameTime)); + r += (frames[frame + ColorTimeline.R] - r) * percent; + g += (frames[frame + ColorTimeline.G] - g) * percent; + b += (frames[frame + ColorTimeline.B] - b) * percent; + a += (frames[frame + ColorTimeline.A] - a) * percent; + } + if (alpha == 1) + slot.color.set(r, g, b, a); + else { + var color = slot.color; + if (pose == MixPose.setup) + color.setFromColor(slot.data.color); + color.add((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha); + } + }; + ColorTimeline.ENTRIES = 5; + ColorTimeline.PREV_TIME = -5; + ColorTimeline.PREV_R = -4; + ColorTimeline.PREV_G = -3; + ColorTimeline.PREV_B = -2; + ColorTimeline.PREV_A = -1; + ColorTimeline.R = 1; + ColorTimeline.G = 2; + ColorTimeline.B = 3; + ColorTimeline.A = 4; + return ColorTimeline; + }(CurveTimeline)); + spine.ColorTimeline = ColorTimeline; + var TwoColorTimeline = (function (_super) { + __extends(TwoColorTimeline, _super); + function TwoColorTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TwoColorTimeline.ENTRIES); + return _this; + } + TwoColorTimeline.prototype.getPropertyId = function () { + return (TimelineType.twoColor << 24) + this.slotIndex; + }; + TwoColorTimeline.prototype.setFrame = function (frameIndex, time, r, g, b, a, r2, g2, b2) { + frameIndex *= TwoColorTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TwoColorTimeline.R] = r; + this.frames[frameIndex + TwoColorTimeline.G] = g; + this.frames[frameIndex + TwoColorTimeline.B] = b; + this.frames[frameIndex + TwoColorTimeline.A] = a; + this.frames[frameIndex + TwoColorTimeline.R2] = r2; + this.frames[frameIndex + TwoColorTimeline.G2] = g2; + this.frames[frameIndex + TwoColorTimeline.B2] = b2; + }; + TwoColorTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + var frames = this.frames; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + slot.color.setFromColor(slot.data.color); + slot.darkColor.setFromColor(slot.data.darkColor); + return; + case MixPose.current: + var light = slot.color, dark = slot.darkColor, setupLight = slot.data.color, setupDark = slot.data.darkColor; + light.add((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); + dark.add((setupDark.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, (setupDark.b - dark.b) * alpha, 0); + } + return; + } + var r = 0, g = 0, b = 0, a = 0, r2 = 0, g2 = 0, b2 = 0; + if (time >= frames[frames.length - TwoColorTimeline.ENTRIES]) { + var i = frames.length; + r = frames[i + TwoColorTimeline.PREV_R]; + g = frames[i + TwoColorTimeline.PREV_G]; + b = frames[i + TwoColorTimeline.PREV_B]; + a = frames[i + TwoColorTimeline.PREV_A]; + r2 = frames[i + TwoColorTimeline.PREV_R2]; + g2 = frames[i + TwoColorTimeline.PREV_G2]; + b2 = frames[i + TwoColorTimeline.PREV_B2]; + } + else { + var frame = Animation.binarySearch(frames, time, TwoColorTimeline.ENTRIES); + r = frames[frame + TwoColorTimeline.PREV_R]; + g = frames[frame + TwoColorTimeline.PREV_G]; + b = frames[frame + TwoColorTimeline.PREV_B]; + a = frames[frame + TwoColorTimeline.PREV_A]; + r2 = frames[frame + TwoColorTimeline.PREV_R2]; + g2 = frames[frame + TwoColorTimeline.PREV_G2]; + b2 = frames[frame + TwoColorTimeline.PREV_B2]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TwoColorTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TwoColorTimeline.PREV_TIME] - frameTime)); + r += (frames[frame + TwoColorTimeline.R] - r) * percent; + g += (frames[frame + TwoColorTimeline.G] - g) * percent; + b += (frames[frame + TwoColorTimeline.B] - b) * percent; + a += (frames[frame + TwoColorTimeline.A] - a) * percent; + r2 += (frames[frame + TwoColorTimeline.R2] - r2) * percent; + g2 += (frames[frame + TwoColorTimeline.G2] - g2) * percent; + b2 += (frames[frame + TwoColorTimeline.B2] - b2) * percent; + } + if (alpha == 1) { + slot.color.set(r, g, b, a); + slot.darkColor.set(r2, g2, b2, 1); + } + else { + var light = slot.color, dark = slot.darkColor; + if (pose == MixPose.setup) { + light.setFromColor(slot.data.color); + dark.setFromColor(slot.data.darkColor); + } + light.add((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha); + dark.add((r2 - dark.r) * alpha, (g2 - dark.g) * alpha, (b2 - dark.b) * alpha, 0); + } + }; + TwoColorTimeline.ENTRIES = 8; + TwoColorTimeline.PREV_TIME = -8; + TwoColorTimeline.PREV_R = -7; + TwoColorTimeline.PREV_G = -6; + TwoColorTimeline.PREV_B = -5; + TwoColorTimeline.PREV_A = -4; + TwoColorTimeline.PREV_R2 = -3; + TwoColorTimeline.PREV_G2 = -2; + TwoColorTimeline.PREV_B2 = -1; + TwoColorTimeline.R = 1; + TwoColorTimeline.G = 2; + TwoColorTimeline.B = 3; + TwoColorTimeline.A = 4; + TwoColorTimeline.R2 = 5; + TwoColorTimeline.G2 = 6; + TwoColorTimeline.B2 = 7; + return TwoColorTimeline; + }(CurveTimeline)); + spine.TwoColorTimeline = TwoColorTimeline; + var AttachmentTimeline = (function () { + function AttachmentTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.attachmentNames = new Array(frameCount); + } + AttachmentTimeline.prototype.getPropertyId = function () { + return (TimelineType.attachment << 24) + this.slotIndex; + }; + AttachmentTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + AttachmentTimeline.prototype.setFrame = function (frameIndex, time, attachmentName) { + this.frames[frameIndex] = time; + this.attachmentNames[frameIndex] = attachmentName; + }; + AttachmentTimeline.prototype.apply = function (skeleton, lastTime, time, events, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + if (direction == MixDirection.out && pose == MixPose.setup) { + var attachmentName_1 = slot.data.attachmentName; + slot.setAttachment(attachmentName_1 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_1)); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (pose == MixPose.setup) { + var attachmentName_2 = slot.data.attachmentName; + slot.setAttachment(attachmentName_2 == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName_2)); + } + return; + } + var frameIndex = 0; + if (time >= frames[frames.length - 1]) + frameIndex = frames.length - 1; + else + frameIndex = Animation.binarySearch(frames, time, 1) - 1; + var attachmentName = this.attachmentNames[frameIndex]; + skeleton.slots[this.slotIndex] + .setAttachment(attachmentName == null ? null : skeleton.getAttachment(this.slotIndex, attachmentName)); + }; + return AttachmentTimeline; + }()); + spine.AttachmentTimeline = AttachmentTimeline; + var zeros = null; + var DeformTimeline = (function (_super) { + __extends(DeformTimeline, _super); + function DeformTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount); + _this.frameVertices = new Array(frameCount); + if (zeros == null) + zeros = spine.Utils.newFloatArray(64); + return _this; + } + DeformTimeline.prototype.getPropertyId = function () { + return (TimelineType.deform << 27) + +this.attachment.id + this.slotIndex; + }; + DeformTimeline.prototype.setFrame = function (frameIndex, time, vertices) { + this.frames[frameIndex] = time; + this.frameVertices[frameIndex] = vertices; + }; + DeformTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var slot = skeleton.slots[this.slotIndex]; + var slotAttachment = slot.getAttachment(); + if (!(slotAttachment instanceof spine.VertexAttachment) || !slotAttachment.applyDeform(this.attachment)) + return; + var verticesArray = slot.attachmentVertices; + if (verticesArray.length == 0) + alpha = 1; + var frameVertices = this.frameVertices; + var vertexCount = frameVertices[0].length; + var frames = this.frames; + if (time < frames[0]) { + var vertexAttachment = slotAttachment; + switch (pose) { + case MixPose.setup: + verticesArray.length = 0; + return; + case MixPose.current: + if (alpha == 1) { + verticesArray.length = 0; + break; + } + var vertices_1 = spine.Utils.setArraySize(verticesArray, vertexCount); + if (vertexAttachment.bones == null) { + var setupVertices = vertexAttachment.vertices; + for (var i = 0; i < vertexCount; i++) + vertices_1[i] += (setupVertices[i] - vertices_1[i]) * alpha; + } + else { + alpha = 1 - alpha; + for (var i = 0; i < vertexCount; i++) + vertices_1[i] *= alpha; + } + } + return; + } + var vertices = spine.Utils.setArraySize(verticesArray, vertexCount); + if (time >= frames[frames.length - 1]) { + var lastVertices = frameVertices[frames.length - 1]; + if (alpha == 1) { + spine.Utils.arrayCopy(lastVertices, 0, vertices, 0, vertexCount); + } + else if (pose == MixPose.setup) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices_1 = vertexAttachment.vertices; + for (var i_1 = 0; i_1 < vertexCount; i_1++) { + var setup = setupVertices_1[i_1]; + vertices[i_1] = setup + (lastVertices[i_1] - setup) * alpha; + } + } + else { + for (var i_2 = 0; i_2 < vertexCount; i_2++) + vertices[i_2] = lastVertices[i_2] * alpha; + } + } + else { + for (var i_3 = 0; i_3 < vertexCount; i_3++) + vertices[i_3] += (lastVertices[i_3] - vertices[i_3]) * alpha; + } + return; + } + var frame = Animation.binarySearch(frames, time); + var prevVertices = frameVertices[frame - 1]; + var nextVertices = frameVertices[frame]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime)); + if (alpha == 1) { + for (var i_4 = 0; i_4 < vertexCount; i_4++) { + var prev = prevVertices[i_4]; + vertices[i_4] = prev + (nextVertices[i_4] - prev) * percent; + } + } + else if (pose == MixPose.setup) { + var vertexAttachment = slotAttachment; + if (vertexAttachment.bones == null) { + var setupVertices_2 = vertexAttachment.vertices; + for (var i_5 = 0; i_5 < vertexCount; i_5++) { + var prev = prevVertices[i_5], setup = setupVertices_2[i_5]; + vertices[i_5] = setup + (prev + (nextVertices[i_5] - prev) * percent - setup) * alpha; + } + } + else { + for (var i_6 = 0; i_6 < vertexCount; i_6++) { + var prev = prevVertices[i_6]; + vertices[i_6] = (prev + (nextVertices[i_6] - prev) * percent) * alpha; + } + } + } + else { + for (var i_7 = 0; i_7 < vertexCount; i_7++) { + var prev = prevVertices[i_7]; + vertices[i_7] += (prev + (nextVertices[i_7] - prev) * percent - vertices[i_7]) * alpha; + } + } + }; + return DeformTimeline; + }(CurveTimeline)); + spine.DeformTimeline = DeformTimeline; + var EventTimeline = (function () { + function EventTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.events = new Array(frameCount); + } + EventTimeline.prototype.getPropertyId = function () { + return TimelineType.event << 24; + }; + EventTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + EventTimeline.prototype.setFrame = function (frameIndex, event) { + this.frames[frameIndex] = event.time; + this.events[frameIndex] = event; + }; + EventTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + if (firedEvents == null) + return; + var frames = this.frames; + var frameCount = this.frames.length; + if (lastTime > time) { + this.apply(skeleton, lastTime, Number.MAX_VALUE, firedEvents, alpha, pose, direction); + lastTime = -1; + } + else if (lastTime >= frames[frameCount - 1]) + return; + if (time < frames[0]) + return; + var frame = 0; + if (lastTime < frames[0]) + frame = 0; + else { + frame = Animation.binarySearch(frames, lastTime); + var frameTime = frames[frame]; + while (frame > 0) { + if (frames[frame - 1] != frameTime) + break; + frame--; + } + } + for (; frame < frameCount && time >= frames[frame]; frame++) + firedEvents.push(this.events[frame]); + }; + return EventTimeline; + }()); + spine.EventTimeline = EventTimeline; + var DrawOrderTimeline = (function () { + function DrawOrderTimeline(frameCount) { + this.frames = spine.Utils.newFloatArray(frameCount); + this.drawOrders = new Array(frameCount); + } + DrawOrderTimeline.prototype.getPropertyId = function () { + return TimelineType.drawOrder << 24; + }; + DrawOrderTimeline.prototype.getFrameCount = function () { + return this.frames.length; + }; + DrawOrderTimeline.prototype.setFrame = function (frameIndex, time, drawOrder) { + this.frames[frameIndex] = time; + this.drawOrders[frameIndex] = drawOrder; + }; + DrawOrderTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var drawOrder = skeleton.drawOrder; + var slots = skeleton.slots; + if (direction == MixDirection.out && pose == MixPose.setup) { + spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frames = this.frames; + if (time < frames[0]) { + if (pose == MixPose.setup) + spine.Utils.arrayCopy(skeleton.slots, 0, skeleton.drawOrder, 0, skeleton.slots.length); + return; + } + var frame = 0; + if (time >= frames[frames.length - 1]) + frame = frames.length - 1; + else + frame = Animation.binarySearch(frames, time) - 1; + var drawOrderToSetupIndex = this.drawOrders[frame]; + if (drawOrderToSetupIndex == null) + spine.Utils.arrayCopy(slots, 0, drawOrder, 0, slots.length); + else { + for (var i = 0, n = drawOrderToSetupIndex.length; i < n; i++) + drawOrder[i] = slots[drawOrderToSetupIndex[i]]; + } + }; + return DrawOrderTimeline; + }()); + spine.DrawOrderTimeline = DrawOrderTimeline; + var IkConstraintTimeline = (function (_super) { + __extends(IkConstraintTimeline, _super); + function IkConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * IkConstraintTimeline.ENTRIES); + return _this; + } + IkConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.ikConstraint << 24) + this.ikConstraintIndex; + }; + IkConstraintTimeline.prototype.setFrame = function (frameIndex, time, mix, bendDirection) { + frameIndex *= IkConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + IkConstraintTimeline.MIX] = mix; + this.frames[frameIndex + IkConstraintTimeline.BEND_DIRECTION] = bendDirection; + }; + IkConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.ikConstraints[this.ikConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.mix = constraint.data.mix; + constraint.bendDirection = constraint.data.bendDirection; + return; + case MixPose.current: + constraint.mix += (constraint.data.mix - constraint.mix) * alpha; + constraint.bendDirection = constraint.data.bendDirection; + } + return; + } + if (time >= frames[frames.length - IkConstraintTimeline.ENTRIES]) { + if (pose == MixPose.setup) { + constraint.mix = constraint.data.mix + (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.data.mix) * alpha; + constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection + : frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + else { + constraint.mix += (frames[frames.length + IkConstraintTimeline.PREV_MIX] - constraint.mix) * alpha; + if (direction == MixDirection["in"]) + constraint.bendDirection = frames[frames.length + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + return; + } + var frame = Animation.binarySearch(frames, time, IkConstraintTimeline.ENTRIES); + var mix = frames[frame + IkConstraintTimeline.PREV_MIX]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / IkConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + IkConstraintTimeline.PREV_TIME] - frameTime)); + if (pose == MixPose.setup) { + constraint.mix = constraint.data.mix + (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.data.mix) * alpha; + constraint.bendDirection = direction == MixDirection.out ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + else { + constraint.mix += (mix + (frames[frame + IkConstraintTimeline.MIX] - mix) * percent - constraint.mix) * alpha; + if (direction == MixDirection["in"]) + constraint.bendDirection = frames[frame + IkConstraintTimeline.PREV_BEND_DIRECTION]; + } + }; + IkConstraintTimeline.ENTRIES = 3; + IkConstraintTimeline.PREV_TIME = -3; + IkConstraintTimeline.PREV_MIX = -2; + IkConstraintTimeline.PREV_BEND_DIRECTION = -1; + IkConstraintTimeline.MIX = 1; + IkConstraintTimeline.BEND_DIRECTION = 2; + return IkConstraintTimeline; + }(CurveTimeline)); + spine.IkConstraintTimeline = IkConstraintTimeline; + var TransformConstraintTimeline = (function (_super) { + __extends(TransformConstraintTimeline, _super); + function TransformConstraintTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * TransformConstraintTimeline.ENTRIES); + return _this; + } + TransformConstraintTimeline.prototype.getPropertyId = function () { + return (TimelineType.transformConstraint << 24) + this.transformConstraintIndex; + }; + TransformConstraintTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix, scaleMix, shearMix) { + frameIndex *= TransformConstraintTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + TransformConstraintTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + TransformConstraintTimeline.TRANSLATE] = translateMix; + this.frames[frameIndex + TransformConstraintTimeline.SCALE] = scaleMix; + this.frames[frameIndex + TransformConstraintTimeline.SHEAR] = shearMix; + }; + TransformConstraintTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.transformConstraints[this.transformConstraintIndex]; + if (time < frames[0]) { + var data = constraint.data; + switch (pose) { + case MixPose.setup: + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + return; + case MixPose.current: + constraint.rotateMix += (data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (data.translateMix - constraint.translateMix) * alpha; + constraint.scaleMix += (data.scaleMix - constraint.scaleMix) * alpha; + constraint.shearMix += (data.shearMix - constraint.shearMix) * alpha; + } + return; + } + var rotate = 0, translate = 0, scale = 0, shear = 0; + if (time >= frames[frames.length - TransformConstraintTimeline.ENTRIES]) { + var i = frames.length; + rotate = frames[i + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[i + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[i + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[i + TransformConstraintTimeline.PREV_SHEAR]; + } + else { + var frame = Animation.binarySearch(frames, time, TransformConstraintTimeline.ENTRIES); + rotate = frames[frame + TransformConstraintTimeline.PREV_ROTATE]; + translate = frames[frame + TransformConstraintTimeline.PREV_TRANSLATE]; + scale = frames[frame + TransformConstraintTimeline.PREV_SCALE]; + shear = frames[frame + TransformConstraintTimeline.PREV_SHEAR]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / TransformConstraintTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + TransformConstraintTimeline.PREV_TIME] - frameTime)); + rotate += (frames[frame + TransformConstraintTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + TransformConstraintTimeline.TRANSLATE] - translate) * percent; + scale += (frames[frame + TransformConstraintTimeline.SCALE] - scale) * percent; + shear += (frames[frame + TransformConstraintTimeline.SHEAR] - shear) * percent; + } + if (pose == MixPose.setup) { + var data = constraint.data; + constraint.rotateMix = data.rotateMix + (rotate - data.rotateMix) * alpha; + constraint.translateMix = data.translateMix + (translate - data.translateMix) * alpha; + constraint.scaleMix = data.scaleMix + (scale - data.scaleMix) * alpha; + constraint.shearMix = data.shearMix + (shear - data.shearMix) * alpha; + } + else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + constraint.scaleMix += (scale - constraint.scaleMix) * alpha; + constraint.shearMix += (shear - constraint.shearMix) * alpha; + } + }; + TransformConstraintTimeline.ENTRIES = 5; + TransformConstraintTimeline.PREV_TIME = -5; + TransformConstraintTimeline.PREV_ROTATE = -4; + TransformConstraintTimeline.PREV_TRANSLATE = -3; + TransformConstraintTimeline.PREV_SCALE = -2; + TransformConstraintTimeline.PREV_SHEAR = -1; + TransformConstraintTimeline.ROTATE = 1; + TransformConstraintTimeline.TRANSLATE = 2; + TransformConstraintTimeline.SCALE = 3; + TransformConstraintTimeline.SHEAR = 4; + return TransformConstraintTimeline; + }(CurveTimeline)); + spine.TransformConstraintTimeline = TransformConstraintTimeline; + var PathConstraintPositionTimeline = (function (_super) { + __extends(PathConstraintPositionTimeline, _super); + function PathConstraintPositionTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintPositionTimeline.ENTRIES); + return _this; + } + PathConstraintPositionTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintPosition << 24) + this.pathConstraintIndex; + }; + PathConstraintPositionTimeline.prototype.setFrame = function (frameIndex, time, value) { + frameIndex *= PathConstraintPositionTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintPositionTimeline.VALUE] = value; + }; + PathConstraintPositionTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.position = constraint.data.position; + return; + case MixPose.current: + constraint.position += (constraint.data.position - constraint.position) * alpha; + } + return; + } + var position = 0; + if (time >= frames[frames.length - PathConstraintPositionTimeline.ENTRIES]) + position = frames[frames.length + PathConstraintPositionTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintPositionTimeline.ENTRIES); + position = frames[frame + PathConstraintPositionTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintPositionTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintPositionTimeline.PREV_TIME] - frameTime)); + position += (frames[frame + PathConstraintPositionTimeline.VALUE] - position) * percent; + } + if (pose == MixPose.setup) + constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; + else + constraint.position += (position - constraint.position) * alpha; + }; + PathConstraintPositionTimeline.ENTRIES = 2; + PathConstraintPositionTimeline.PREV_TIME = -2; + PathConstraintPositionTimeline.PREV_VALUE = -1; + PathConstraintPositionTimeline.VALUE = 1; + return PathConstraintPositionTimeline; + }(CurveTimeline)); + spine.PathConstraintPositionTimeline = PathConstraintPositionTimeline; + var PathConstraintSpacingTimeline = (function (_super) { + __extends(PathConstraintSpacingTimeline, _super); + function PathConstraintSpacingTimeline(frameCount) { + return _super.call(this, frameCount) || this; + } + PathConstraintSpacingTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintSpacing << 24) + this.pathConstraintIndex; + }; + PathConstraintSpacingTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.spacing = constraint.data.spacing; + return; + case MixPose.current: + constraint.spacing += (constraint.data.spacing - constraint.spacing) * alpha; + } + return; + } + var spacing = 0; + if (time >= frames[frames.length - PathConstraintSpacingTimeline.ENTRIES]) + spacing = frames[frames.length + PathConstraintSpacingTimeline.PREV_VALUE]; + else { + var frame = Animation.binarySearch(frames, time, PathConstraintSpacingTimeline.ENTRIES); + spacing = frames[frame + PathConstraintSpacingTimeline.PREV_VALUE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintSpacingTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintSpacingTimeline.PREV_TIME] - frameTime)); + spacing += (frames[frame + PathConstraintSpacingTimeline.VALUE] - spacing) * percent; + } + if (pose == MixPose.setup) + constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; + else + constraint.spacing += (spacing - constraint.spacing) * alpha; + }; + return PathConstraintSpacingTimeline; + }(PathConstraintPositionTimeline)); + spine.PathConstraintSpacingTimeline = PathConstraintSpacingTimeline; + var PathConstraintMixTimeline = (function (_super) { + __extends(PathConstraintMixTimeline, _super); + function PathConstraintMixTimeline(frameCount) { + var _this = _super.call(this, frameCount) || this; + _this.frames = spine.Utils.newFloatArray(frameCount * PathConstraintMixTimeline.ENTRIES); + return _this; + } + PathConstraintMixTimeline.prototype.getPropertyId = function () { + return (TimelineType.pathConstraintMix << 24) + this.pathConstraintIndex; + }; + PathConstraintMixTimeline.prototype.setFrame = function (frameIndex, time, rotateMix, translateMix) { + frameIndex *= PathConstraintMixTimeline.ENTRIES; + this.frames[frameIndex] = time; + this.frames[frameIndex + PathConstraintMixTimeline.ROTATE] = rotateMix; + this.frames[frameIndex + PathConstraintMixTimeline.TRANSLATE] = translateMix; + }; + PathConstraintMixTimeline.prototype.apply = function (skeleton, lastTime, time, firedEvents, alpha, pose, direction) { + var frames = this.frames; + var constraint = skeleton.pathConstraints[this.pathConstraintIndex]; + if (time < frames[0]) { + switch (pose) { + case MixPose.setup: + constraint.rotateMix = constraint.data.rotateMix; + constraint.translateMix = constraint.data.translateMix; + return; + case MixPose.current: + constraint.rotateMix += (constraint.data.rotateMix - constraint.rotateMix) * alpha; + constraint.translateMix += (constraint.data.translateMix - constraint.translateMix) * alpha; + } + return; + } + var rotate = 0, translate = 0; + if (time >= frames[frames.length - PathConstraintMixTimeline.ENTRIES]) { + rotate = frames[frames.length + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frames.length + PathConstraintMixTimeline.PREV_TRANSLATE]; + } + else { + var frame = Animation.binarySearch(frames, time, PathConstraintMixTimeline.ENTRIES); + rotate = frames[frame + PathConstraintMixTimeline.PREV_ROTATE]; + translate = frames[frame + PathConstraintMixTimeline.PREV_TRANSLATE]; + var frameTime = frames[frame]; + var percent = this.getCurvePercent(frame / PathConstraintMixTimeline.ENTRIES - 1, 1 - (time - frameTime) / (frames[frame + PathConstraintMixTimeline.PREV_TIME] - frameTime)); + rotate += (frames[frame + PathConstraintMixTimeline.ROTATE] - rotate) * percent; + translate += (frames[frame + PathConstraintMixTimeline.TRANSLATE] - translate) * percent; + } + if (pose == MixPose.setup) { + constraint.rotateMix = constraint.data.rotateMix + (rotate - constraint.data.rotateMix) * alpha; + constraint.translateMix = constraint.data.translateMix + (translate - constraint.data.translateMix) * alpha; + } + else { + constraint.rotateMix += (rotate - constraint.rotateMix) * alpha; + constraint.translateMix += (translate - constraint.translateMix) * alpha; + } + }; + PathConstraintMixTimeline.ENTRIES = 3; + PathConstraintMixTimeline.PREV_TIME = -3; + PathConstraintMixTimeline.PREV_ROTATE = -2; + PathConstraintMixTimeline.PREV_TRANSLATE = -1; + PathConstraintMixTimeline.ROTATE = 1; + PathConstraintMixTimeline.TRANSLATE = 2; + return PathConstraintMixTimeline; + }(CurveTimeline)); + spine.PathConstraintMixTimeline = PathConstraintMixTimeline; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AnimationState = (function () { + function AnimationState(data) { + this.tracks = new Array(); + this.events = new Array(); + this.listeners = new Array(); + this.queue = new EventQueue(this); + this.propertyIDs = new spine.IntSet(); + this.mixingTo = new Array(); + this.animationsChanged = false; + this.timeScale = 1; + this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); }); + this.data = data; + } + AnimationState.prototype.update = function (delta) { + delta *= this.timeScale; + var tracks = this.tracks; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (current == null) + continue; + current.animationLast = current.nextAnimationLast; + current.trackLast = current.nextTrackLast; + var currentDelta = delta * current.timeScale; + if (current.delay > 0) { + current.delay -= currentDelta; + if (current.delay > 0) + continue; + currentDelta = -current.delay; + current.delay = 0; + } + var next = current.next; + if (next != null) { + var nextTime = current.trackLast - next.delay; + if (nextTime >= 0) { + next.delay = 0; + next.trackTime = nextTime + delta * next.timeScale; + current.trackTime += currentDelta; + this.setCurrent(i, next, true); + while (next.mixingFrom != null) { + next.mixTime += currentDelta; + next = next.mixingFrom; + } + continue; + } + } + else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) { + tracks[i] = null; + this.queue.end(current); + this.disposeNext(current); + continue; + } + if (current.mixingFrom != null && this.updateMixingFrom(current, delta)) { + var from = current.mixingFrom; + current.mixingFrom = null; + while (from != null) { + this.queue.end(from); + from = from.mixingFrom; + } + } + current.trackTime += currentDelta; + } + this.queue.drain(); + }; + AnimationState.prototype.updateMixingFrom = function (to, delta) { + var from = to.mixingFrom; + if (from == null) + return true; + var finished = this.updateMixingFrom(from, delta); + from.animationLast = from.nextAnimationLast; + from.trackLast = from.nextTrackLast; + if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { + if (from.totalAlpha == 0 || to.mixDuration == 0) { + to.mixingFrom = from.mixingFrom; + to.interruptAlpha = from.interruptAlpha; + this.queue.end(from); + } + return finished; + } + from.trackTime += delta * from.timeScale; + to.mixTime += delta * to.timeScale; + return false; + }; + AnimationState.prototype.apply = function (skeleton) { + if (skeleton == null) + throw new Error("skeleton cannot be null."); + if (this.animationsChanged) + this._animationsChanged(); + var events = this.events; + var tracks = this.tracks; + var applied = false; + for (var i = 0, n = tracks.length; i < n; i++) { + var current = tracks[i]; + if (current == null || current.delay > 0) + continue; + applied = true; + var currentPose = i == 0 ? spine.MixPose.current : spine.MixPose.currentLayered; + var mix = current.alpha; + if (current.mixingFrom != null) + mix *= this.applyMixingFrom(current, skeleton, currentPose); + else if (current.trackTime >= current.trackEnd && current.next == null) + mix = 0; + var animationLast = current.animationLast, animationTime = current.getAnimationTime(); + var timelineCount = current.animation.timelines.length; + var timelines = current.animation.timelines; + if (mix == 1) { + for (var ii = 0; ii < timelineCount; ii++) + timelines[ii].apply(skeleton, animationLast, animationTime, events, 1, spine.MixPose.setup, spine.MixDirection["in"]); + } + else { + var timelineData = current.timelineData; + var firstFrame = current.timelinesRotation.length == 0; + if (firstFrame) + spine.Utils.setArraySize(current.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = current.timelinesRotation; + for (var ii = 0; ii < timelineCount; ii++) { + var timeline = timelines[ii]; + var pose = timelineData[ii] >= AnimationState.FIRST ? spine.MixPose.setup : currentPose; + if (timeline instanceof spine.RotateTimeline) { + this.applyRotateTimeline(timeline, skeleton, animationTime, mix, pose, timelinesRotation, ii << 1, firstFrame); + } + else { + spine.Utils.webkit602BugfixHelper(mix, pose); + timeline.apply(skeleton, animationLast, animationTime, events, mix, pose, spine.MixDirection["in"]); + } + } + } + this.queueEvents(current, animationTime); + events.length = 0; + current.nextAnimationLast = animationTime; + current.nextTrackLast = current.trackTime; + } + this.queue.drain(); + return applied; + }; + AnimationState.prototype.applyMixingFrom = function (to, skeleton, currentPose) { + var from = to.mixingFrom; + if (from.mixingFrom != null) + this.applyMixingFrom(from, skeleton, currentPose); + var mix = 0; + if (to.mixDuration == 0) { + mix = 1; + currentPose = spine.MixPose.setup; + } + else { + mix = to.mixTime / to.mixDuration; + if (mix > 1) + mix = 1; + } + var events = mix < from.eventThreshold ? this.events : null; + var attachments = mix < from.attachmentThreshold, drawOrder = mix < from.drawOrderThreshold; + var animationLast = from.animationLast, animationTime = from.getAnimationTime(); + var timelineCount = from.animation.timelines.length; + var timelines = from.animation.timelines; + var timelineData = from.timelineData; + var timelineDipMix = from.timelineDipMix; + var firstFrame = from.timelinesRotation.length == 0; + if (firstFrame) + spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null); + var timelinesRotation = from.timelinesRotation; + var pose; + var alphaDip = from.alpha * to.interruptAlpha, alphaMix = alphaDip * (1 - mix), alpha = 0; + from.totalAlpha = 0; + for (var i = 0; i < timelineCount; i++) { + var timeline = timelines[i]; + switch (timelineData[i]) { + case AnimationState.SUBSEQUENT: + if (!attachments && timeline instanceof spine.AttachmentTimeline) + continue; + if (!drawOrder && timeline instanceof spine.DrawOrderTimeline) + continue; + pose = currentPose; + alpha = alphaMix; + break; + case AnimationState.FIRST: + pose = spine.MixPose.setup; + alpha = alphaMix; + break; + case AnimationState.DIP: + pose = spine.MixPose.setup; + alpha = alphaDip; + break; + default: + pose = spine.MixPose.setup; + alpha = alphaDip; + var dipMix = timelineDipMix[i]; + alpha *= Math.max(0, 1 - dipMix.mixTime / dipMix.mixDuration); + break; + } + from.totalAlpha += alpha; + if (timeline instanceof spine.RotateTimeline) + this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, pose, timelinesRotation, i << 1, firstFrame); + else { + spine.Utils.webkit602BugfixHelper(alpha, pose); + timeline.apply(skeleton, animationLast, animationTime, events, alpha, pose, spine.MixDirection.out); + } + } + if (to.mixDuration > 0) + this.queueEvents(from, animationTime); + this.events.length = 0; + from.nextAnimationLast = animationTime; + from.nextTrackLast = from.trackTime; + return mix; + }; + AnimationState.prototype.applyRotateTimeline = function (timeline, skeleton, time, alpha, pose, timelinesRotation, i, firstFrame) { + if (firstFrame) + timelinesRotation[i] = 0; + if (alpha == 1) { + timeline.apply(skeleton, 0, time, null, 1, pose, spine.MixDirection["in"]); + return; + } + var rotateTimeline = timeline; + var frames = rotateTimeline.frames; + var bone = skeleton.bones[rotateTimeline.boneIndex]; + if (time < frames[0]) { + if (pose == spine.MixPose.setup) + bone.rotation = bone.data.rotation; + return; + } + var r2 = 0; + if (time >= frames[frames.length - spine.RotateTimeline.ENTRIES]) + r2 = bone.data.rotation + frames[frames.length + spine.RotateTimeline.PREV_ROTATION]; + else { + var frame = spine.Animation.binarySearch(frames, time, spine.RotateTimeline.ENTRIES); + var prevRotation = frames[frame + spine.RotateTimeline.PREV_ROTATION]; + var frameTime = frames[frame]; + var percent = rotateTimeline.getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame + spine.RotateTimeline.PREV_TIME] - frameTime)); + r2 = frames[frame + spine.RotateTimeline.ROTATION] - prevRotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + r2 = prevRotation + r2 * percent + bone.data.rotation; + r2 -= (16384 - ((16384.499999999996 - r2 / 360) | 0)) * 360; + } + var r1 = pose == spine.MixPose.setup ? bone.data.rotation : bone.rotation; + var total = 0, diff = r2 - r1; + if (diff == 0) { + total = timelinesRotation[i]; + } + else { + diff -= (16384 - ((16384.499999999996 - diff / 360) | 0)) * 360; + var lastTotal = 0, lastDiff = 0; + if (firstFrame) { + lastTotal = 0; + lastDiff = diff; + } + else { + lastTotal = timelinesRotation[i]; + lastDiff = timelinesRotation[i + 1]; + } + var current = diff > 0, dir = lastTotal >= 0; + if (spine.MathUtils.signum(lastDiff) != spine.MathUtils.signum(diff) && Math.abs(lastDiff) <= 90) { + if (Math.abs(lastTotal) > 180) + lastTotal += 360 * spine.MathUtils.signum(lastTotal); + dir = current; + } + total = diff + lastTotal - lastTotal % 360; + if (dir != current) + total += 360 * spine.MathUtils.signum(lastTotal); + timelinesRotation[i] = total; + } + timelinesRotation[i + 1] = diff; + r1 += total * alpha; + bone.rotation = r1 - (16384 - ((16384.499999999996 - r1 / 360) | 0)) * 360; + }; + AnimationState.prototype.queueEvents = function (entry, animationTime) { + var animationStart = entry.animationStart, animationEnd = entry.animationEnd; + var duration = animationEnd - animationStart; + var trackLastWrapped = entry.trackLast % duration; + var events = this.events; + var i = 0, n = events.length; + for (; i < n; i++) { + var event_1 = events[i]; + if (event_1.time < trackLastWrapped) + break; + if (event_1.time > animationEnd) + continue; + this.queue.event(entry, event_1); + } + var complete = false; + if (entry.loop) + complete = duration == 0 || trackLastWrapped > entry.trackTime % duration; + else + complete = animationTime >= animationEnd && entry.animationLast < animationEnd; + if (complete) + this.queue.complete(entry); + for (; i < n; i++) { + var event_2 = events[i]; + if (event_2.time < animationStart) + continue; + this.queue.event(entry, events[i]); + } + }; + AnimationState.prototype.clearTracks = function () { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) + this.clearTrack(i); + this.tracks.length = 0; + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.clearTrack = function (trackIndex) { + if (trackIndex >= this.tracks.length) + return; + var current = this.tracks[trackIndex]; + if (current == null) + return; + this.queue.end(current); + this.disposeNext(current); + var entry = current; + while (true) { + var from = entry.mixingFrom; + if (from == null) + break; + this.queue.end(from); + entry.mixingFrom = null; + entry = from; + } + this.tracks[current.trackIndex] = null; + this.queue.drain(); + }; + AnimationState.prototype.setCurrent = function (index, current, interrupt) { + var from = this.expandToIndex(index); + this.tracks[index] = current; + if (from != null) { + if (interrupt) + this.queue.interrupt(from); + current.mixingFrom = from; + current.mixTime = 0; + if (from.mixingFrom != null && from.mixDuration > 0) + current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration); + from.timelinesRotation.length = 0; + } + this.queue.start(current); + }; + AnimationState.prototype.setAnimation = function (trackIndex, animationName, loop) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) + throw new Error("Animation not found: " + animationName); + return this.setAnimationWith(trackIndex, animation, loop); + }; + AnimationState.prototype.setAnimationWith = function (trackIndex, animation, loop) { + if (animation == null) + throw new Error("animation cannot be null."); + var interrupt = true; + var current = this.expandToIndex(trackIndex); + if (current != null) { + if (current.nextTrackLast == -1) { + this.tracks[trackIndex] = current.mixingFrom; + this.queue.interrupt(current); + this.queue.end(current); + this.disposeNext(current); + current = current.mixingFrom; + interrupt = false; + } + else + this.disposeNext(current); + } + var entry = this.trackEntry(trackIndex, animation, loop, current); + this.setCurrent(trackIndex, entry, interrupt); + this.queue.drain(); + return entry; + }; + AnimationState.prototype.addAnimation = function (trackIndex, animationName, loop, delay) { + var animation = this.data.skeletonData.findAnimation(animationName); + if (animation == null) + throw new Error("Animation not found: " + animationName); + return this.addAnimationWith(trackIndex, animation, loop, delay); + }; + AnimationState.prototype.addAnimationWith = function (trackIndex, animation, loop, delay) { + if (animation == null) + throw new Error("animation cannot be null."); + var last = this.expandToIndex(trackIndex); + if (last != null) { + while (last.next != null) + last = last.next; + } + var entry = this.trackEntry(trackIndex, animation, loop, last); + if (last == null) { + this.setCurrent(trackIndex, entry, true); + this.queue.drain(); + } + else { + last.next = entry; + if (delay <= 0) { + var duration = last.animationEnd - last.animationStart; + if (duration != 0) { + if (last.loop) + delay += duration * (1 + ((last.trackTime / duration) | 0)); + else + delay += duration; + delay -= this.data.getMix(last.animation, animation); + } + else + delay = 0; + } + } + entry.delay = delay; + return entry; + }; + AnimationState.prototype.setEmptyAnimation = function (trackIndex, mixDuration) { + var entry = this.setAnimationWith(trackIndex, AnimationState.emptyAnimation, false); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.addEmptyAnimation = function (trackIndex, mixDuration, delay) { + if (delay <= 0) + delay -= mixDuration; + var entry = this.addAnimationWith(trackIndex, AnimationState.emptyAnimation, false, delay); + entry.mixDuration = mixDuration; + entry.trackEnd = mixDuration; + return entry; + }; + AnimationState.prototype.setEmptyAnimations = function (mixDuration) { + var oldDrainDisabled = this.queue.drainDisabled; + this.queue.drainDisabled = true; + for (var i = 0, n = this.tracks.length; i < n; i++) { + var current = this.tracks[i]; + if (current != null) + this.setEmptyAnimation(current.trackIndex, mixDuration); + } + this.queue.drainDisabled = oldDrainDisabled; + this.queue.drain(); + }; + AnimationState.prototype.expandToIndex = function (index) { + if (index < this.tracks.length) + return this.tracks[index]; + spine.Utils.ensureArrayCapacity(this.tracks, index - this.tracks.length + 1, null); + this.tracks.length = index + 1; + return null; + }; + AnimationState.prototype.trackEntry = function (trackIndex, animation, loop, last) { + var entry = this.trackEntryPool.obtain(); + entry.trackIndex = trackIndex; + entry.animation = animation; + entry.loop = loop; + entry.eventThreshold = 0; + entry.attachmentThreshold = 0; + entry.drawOrderThreshold = 0; + entry.animationStart = 0; + entry.animationEnd = animation.duration; + entry.animationLast = -1; + entry.nextAnimationLast = -1; + entry.delay = 0; + entry.trackTime = 0; + entry.trackLast = -1; + entry.nextTrackLast = -1; + entry.trackEnd = Number.MAX_VALUE; + entry.timeScale = 1; + entry.alpha = 1; + entry.interruptAlpha = 1; + entry.mixTime = 0; + entry.mixDuration = last == null ? 0 : this.data.getMix(last.animation, animation); + return entry; + }; + AnimationState.prototype.disposeNext = function (entry) { + var next = entry.next; + while (next != null) { + this.queue.dispose(next); + next = next.next; + } + entry.next = null; + }; + AnimationState.prototype._animationsChanged = function () { + this.animationsChanged = false; + var propertyIDs = this.propertyIDs; + propertyIDs.clear(); + var mixingTo = this.mixingTo; + for (var i = 0, n = this.tracks.length; i < n; i++) { + var entry = this.tracks[i]; + if (entry != null) + entry.setTimelineData(null, mixingTo, propertyIDs); + } + }; + AnimationState.prototype.getCurrent = function (trackIndex) { + if (trackIndex >= this.tracks.length) + return null; + return this.tracks[trackIndex]; + }; + AnimationState.prototype.addListener = function (listener) { + if (listener == null) + throw new Error("listener cannot be null."); + this.listeners.push(listener); + }; + AnimationState.prototype.removeListener = function (listener) { + var index = this.listeners.indexOf(listener); + if (index >= 0) + this.listeners.splice(index, 1); + }; + AnimationState.prototype.clearListeners = function () { + this.listeners.length = 0; + }; + AnimationState.prototype.clearListenerNotifications = function () { + this.queue.clear(); + }; + AnimationState.emptyAnimation = new spine.Animation("", [], 0); + AnimationState.SUBSEQUENT = 0; + AnimationState.FIRST = 1; + AnimationState.DIP = 2; + AnimationState.DIP_MIX = 3; + return AnimationState; + }()); + spine.AnimationState = AnimationState; + var TrackEntry = (function () { + function TrackEntry() { + this.timelineData = new Array(); + this.timelineDipMix = new Array(); + this.timelinesRotation = new Array(); + } + TrackEntry.prototype.reset = function () { + this.next = null; + this.mixingFrom = null; + this.animation = null; + this.listener = null; + this.timelineData.length = 0; + this.timelineDipMix.length = 0; + this.timelinesRotation.length = 0; + }; + TrackEntry.prototype.setTimelineData = function (to, mixingToArray, propertyIDs) { + if (to != null) + mixingToArray.push(to); + var lastEntry = this.mixingFrom != null ? this.mixingFrom.setTimelineData(this, mixingToArray, propertyIDs) : this; + if (to != null) + mixingToArray.pop(); + var mixingTo = mixingToArray; + var mixingToLast = mixingToArray.length - 1; + var timelines = this.animation.timelines; + var timelinesCount = this.animation.timelines.length; + var timelineData = spine.Utils.setArraySize(this.timelineData, timelinesCount); + this.timelineDipMix.length = 0; + var timelineDipMix = spine.Utils.setArraySize(this.timelineDipMix, timelinesCount); + outer: for (var i = 0; i < timelinesCount; i++) { + var id = timelines[i].getPropertyId(); + if (!propertyIDs.add(id)) + timelineData[i] = AnimationState.SUBSEQUENT; + else if (to == null || !to.hasTimeline(id)) + timelineData[i] = AnimationState.FIRST; + else { + for (var ii = mixingToLast; ii >= 0; ii--) { + var entry = mixingTo[ii]; + if (!entry.hasTimeline(id)) { + if (entry.mixDuration > 0) { + timelineData[i] = AnimationState.DIP_MIX; + timelineDipMix[i] = entry; + continue outer; + } + } + } + timelineData[i] = AnimationState.DIP; + } + } + return lastEntry; + }; + TrackEntry.prototype.hasTimeline = function (id) { + var timelines = this.animation.timelines; + for (var i = 0, n = timelines.length; i < n; i++) + if (timelines[i].getPropertyId() == id) + return true; + return false; + }; + TrackEntry.prototype.getAnimationTime = function () { + if (this.loop) { + var duration = this.animationEnd - this.animationStart; + if (duration == 0) + return this.animationStart; + return (this.trackTime % duration) + this.animationStart; + } + return Math.min(this.trackTime + this.animationStart, this.animationEnd); + }; + TrackEntry.prototype.setAnimationLast = function (animationLast) { + this.animationLast = animationLast; + this.nextAnimationLast = animationLast; + }; + TrackEntry.prototype.isComplete = function () { + return this.trackTime >= this.animationEnd - this.animationStart; + }; + TrackEntry.prototype.resetRotationDirections = function () { + this.timelinesRotation.length = 0; + }; + return TrackEntry; + }()); + spine.TrackEntry = TrackEntry; + var EventQueue = (function () { + function EventQueue(animState) { + this.objects = []; + this.drainDisabled = false; + this.animState = animState; + } + EventQueue.prototype.start = function (entry) { + this.objects.push(EventType.start); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.interrupt = function (entry) { + this.objects.push(EventType.interrupt); + this.objects.push(entry); + }; + EventQueue.prototype.end = function (entry) { + this.objects.push(EventType.end); + this.objects.push(entry); + this.animState.animationsChanged = true; + }; + EventQueue.prototype.dispose = function (entry) { + this.objects.push(EventType.dispose); + this.objects.push(entry); + }; + EventQueue.prototype.complete = function (entry) { + this.objects.push(EventType.complete); + this.objects.push(entry); + }; + EventQueue.prototype.event = function (entry, event) { + this.objects.push(EventType.event); + this.objects.push(entry); + this.objects.push(event); + }; + EventQueue.prototype.drain = function () { + if (this.drainDisabled) + return; + this.drainDisabled = true; + var objects = this.objects; + var listeners = this.animState.listeners; + for (var i = 0; i < objects.length; i += 2) { + var type = objects[i]; + var entry = objects[i + 1]; + switch (type) { + case EventType.start: + if (entry.listener != null && entry.listener.start) + entry.listener.start(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].start) + listeners[ii].start(entry); + break; + case EventType.interrupt: + if (entry.listener != null && entry.listener.interrupt) + entry.listener.interrupt(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].interrupt) + listeners[ii].interrupt(entry); + break; + case EventType.end: + if (entry.listener != null && entry.listener.end) + entry.listener.end(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].end) + listeners[ii].end(entry); + case EventType.dispose: + if (entry.listener != null && entry.listener.dispose) + entry.listener.dispose(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].dispose) + listeners[ii].dispose(entry); + this.animState.trackEntryPool.free(entry); + break; + case EventType.complete: + if (entry.listener != null && entry.listener.complete) + entry.listener.complete(entry); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].complete) + listeners[ii].complete(entry); + break; + case EventType.event: + var event_3 = objects[i++ + 2]; + if (entry.listener != null && entry.listener.event) + entry.listener.event(entry, event_3); + for (var ii = 0; ii < listeners.length; ii++) + if (listeners[ii].event) + listeners[ii].event(entry, event_3); + break; + } + } + this.clear(); + this.drainDisabled = false; + }; + EventQueue.prototype.clear = function () { + this.objects.length = 0; + }; + return EventQueue; + }()); + spine.EventQueue = EventQueue; + var EventType; + (function (EventType) { + EventType[EventType["start"] = 0] = "start"; + EventType[EventType["interrupt"] = 1] = "interrupt"; + EventType[EventType["end"] = 2] = "end"; + EventType[EventType["dispose"] = 3] = "dispose"; + EventType[EventType["complete"] = 4] = "complete"; + EventType[EventType["event"] = 5] = "event"; + })(EventType = spine.EventType || (spine.EventType = {})); + var AnimationStateAdapter2 = (function () { + function AnimationStateAdapter2() { + } + AnimationStateAdapter2.prototype.start = function (entry) { + }; + AnimationStateAdapter2.prototype.interrupt = function (entry) { + }; + AnimationStateAdapter2.prototype.end = function (entry) { + }; + AnimationStateAdapter2.prototype.dispose = function (entry) { + }; + AnimationStateAdapter2.prototype.complete = function (entry) { + }; + AnimationStateAdapter2.prototype.event = function (entry, event) { + }; + return AnimationStateAdapter2; + }()); + spine.AnimationStateAdapter2 = AnimationStateAdapter2; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AnimationStateData = (function () { + function AnimationStateData(skeletonData) { + this.animationToMixTime = {}; + this.defaultMix = 0; + if (skeletonData == null) + throw new Error("skeletonData cannot be null."); + this.skeletonData = skeletonData; + } + AnimationStateData.prototype.setMix = function (fromName, toName, duration) { + var from = this.skeletonData.findAnimation(fromName); + if (from == null) + throw new Error("Animation not found: " + fromName); + var to = this.skeletonData.findAnimation(toName); + if (to == null) + throw new Error("Animation not found: " + toName); + this.setMixWith(from, to, duration); + }; + AnimationStateData.prototype.setMixWith = function (from, to, duration) { + if (from == null) + throw new Error("from cannot be null."); + if (to == null) + throw new Error("to cannot be null."); + var key = from.name + "." + to.name; + this.animationToMixTime[key] = duration; + }; + AnimationStateData.prototype.getMix = function (from, to) { + var key = from.name + "." + to.name; + var value = this.animationToMixTime[key]; + return value === undefined ? this.defaultMix : value; + }; + return AnimationStateData; + }()); + spine.AnimationStateData = AnimationStateData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AssetManager = (function () { + function AssetManager(textureLoader, pathPrefix) { + if (pathPrefix === void 0) { pathPrefix = ""; } + this.assets = {}; + this.errors = {}; + this.toLoad = 0; + this.loaded = 0; + this.textureLoader = textureLoader; + this.pathPrefix = pathPrefix; + } + AssetManager.downloadText = function (url, success, error) { + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.onload = function () { + if (request.status == 200) { + success(request.responseText); + } + else { + error(request.status, request.responseText); + } + }; + request.onerror = function () { + error(request.status, request.responseText); + }; + request.send(); + }; + AssetManager.downloadBinary = function (url, success, error) { + var request = new XMLHttpRequest(); + request.open("GET", url, true); + request.responseType = "arraybuffer"; + request.onload = function () { + if (request.status == 200) { + success(new Uint8Array(request.response)); + } + else { + error(request.status, request.responseText); + } + }; + request.onerror = function () { + error(request.status, request.responseText); + }; + request.send(); + }; + AssetManager.prototype.loadText = function (path, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + path = this.pathPrefix + path; + this.toLoad++; + AssetManager.downloadText(path, function (data) { + _this.assets[path] = data; + if (success) + success(path, data); + _this.toLoad--; + _this.loaded++; + }, function (state, responseText) { + _this.errors[path] = "Couldn't load text " + path + ": status " + status + ", " + responseText; + if (error) + error(path, "Couldn't load text " + path + ": status " + status + ", " + responseText); + _this.toLoad--; + _this.loaded++; + }); + }; + AssetManager.prototype.loadTexture = function (path, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + path = this.pathPrefix + path; + this.toLoad++; + var img = new Image(); + img.crossOrigin = "anonymous"; + img.onload = function (ev) { + var texture = _this.textureLoader(img); + _this.assets[path] = texture; + _this.toLoad--; + _this.loaded++; + if (success) + success(path, img); + }; + img.onerror = function (ev) { + _this.errors[path] = "Couldn't load image " + path; + _this.toLoad--; + _this.loaded++; + if (error) + error(path, "Couldn't load image " + path); + }; + img.src = path; + }; + AssetManager.prototype.loadTextureData = function (path, data, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + path = this.pathPrefix + path; + this.toLoad++; + var img = new Image(); + img.onload = function (ev) { + var texture = _this.textureLoader(img); + _this.assets[path] = texture; + _this.toLoad--; + _this.loaded++; + if (success) + success(path, img); + }; + img.onerror = function (ev) { + _this.errors[path] = "Couldn't load image " + path; + _this.toLoad--; + _this.loaded++; + if (error) + error(path, "Couldn't load image " + path); + }; + img.src = data; + }; + AssetManager.prototype.loadTextureAtlas = function (path, success, error) { + var _this = this; + if (success === void 0) { success = null; } + if (error === void 0) { error = null; } + var parent = path.lastIndexOf("/") >= 0 ? path.substring(0, path.lastIndexOf("/")) : ""; + path = this.pathPrefix + path; + this.toLoad++; + AssetManager.downloadText(path, function (atlasData) { + var pagesLoaded = { count: 0 }; + var atlasPages = new Array(); + try { + var atlas = new spine.TextureAtlas(atlasData, function (path) { + atlasPages.push(parent + "/" + path); + var image = document.createElement("img"); + image.width = 16; + image.height = 16; + return new spine.FakeTexture(image); + }); + } + catch (e) { + var ex = e; + _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message; + if (error) + error(path, "Couldn't load texture atlas " + path + ": " + ex.message); + _this.toLoad--; + _this.loaded++; + return; + } + var _loop_1 = function (atlasPage) { + var pageLoadError = false; + _this.loadTexture(atlasPage, function (imagePath, image) { + pagesLoaded.count++; + if (pagesLoaded.count == atlasPages.length) { + if (!pageLoadError) { + try { + var atlas = new spine.TextureAtlas(atlasData, function (path) { + return _this.get(parent + "/" + path); + }); + _this.assets[path] = atlas; + if (success) + success(path, atlas); + _this.toLoad--; + _this.loaded++; + } + catch (e) { + var ex = e; + _this.errors[path] = "Couldn't load texture atlas " + path + ": " + ex.message; + if (error) + error(path, "Couldn't load texture atlas " + path + ": " + ex.message); + _this.toLoad--; + _this.loaded++; + } + } + else { + _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path; + if (error) + error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path); + _this.toLoad--; + _this.loaded++; + } + } + }, function (imagePath, errorMessage) { + pageLoadError = true; + pagesLoaded.count++; + if (pagesLoaded.count == atlasPages.length) { + _this.errors[path] = "Couldn't load texture atlas page " + imagePath + "} of atlas " + path; + if (error) + error(path, "Couldn't load texture atlas page " + imagePath + " of atlas " + path); + _this.toLoad--; + _this.loaded++; + } + }); + }; + for (var _i = 0, atlasPages_1 = atlasPages; _i < atlasPages_1.length; _i++) { + var atlasPage = atlasPages_1[_i]; + _loop_1(atlasPage); + } + }, function (state, responseText) { + _this.errors[path] = "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText; + if (error) + error(path, "Couldn't load texture atlas " + path + ": status " + status + ", " + responseText); + _this.toLoad--; + _this.loaded++; + }); + }; + AssetManager.prototype.get = function (path) { + path = this.pathPrefix + path; + return this.assets[path]; + }; + AssetManager.prototype.remove = function (path) { + path = this.pathPrefix + path; + var asset = this.assets[path]; + if (asset.dispose) + asset.dispose(); + this.assets[path] = null; + }; + AssetManager.prototype.removeAll = function () { + for (var key in this.assets) { + var asset = this.assets[key]; + if (asset.dispose) + asset.dispose(); + } + this.assets = {}; + }; + AssetManager.prototype.isLoadingComplete = function () { + return this.toLoad == 0; + }; + AssetManager.prototype.getToLoad = function () { + return this.toLoad; + }; + AssetManager.prototype.getLoaded = function () { + return this.loaded; + }; + AssetManager.prototype.dispose = function () { + this.removeAll(); + }; + AssetManager.prototype.hasErrors = function () { + return Object.keys(this.errors).length > 0; + }; + AssetManager.prototype.getErrors = function () { + return this.errors; + }; + return AssetManager; + }()); + spine.AssetManager = AssetManager; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AtlasAttachmentLoader = (function () { + function AtlasAttachmentLoader(atlas) { + this.atlas = atlas; + } + AtlasAttachmentLoader.prototype.newRegionAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) + throw new Error("Region not found in atlas: " + path + " (region attachment: " + name + ")"); + region.renderObject = region; + var attachment = new spine.RegionAttachment(name); + attachment.setRegion(region); + return attachment; + }; + AtlasAttachmentLoader.prototype.newMeshAttachment = function (skin, name, path) { + var region = this.atlas.findRegion(path); + if (region == null) + throw new Error("Region not found in atlas: " + path + " (mesh attachment: " + name + ")"); + region.renderObject = region; + var attachment = new spine.MeshAttachment(name); + attachment.region = region; + return attachment; + }; + AtlasAttachmentLoader.prototype.newBoundingBoxAttachment = function (skin, name) { + return new spine.BoundingBoxAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPathAttachment = function (skin, name) { + return new spine.PathAttachment(name); + }; + AtlasAttachmentLoader.prototype.newPointAttachment = function (skin, name) { + return new spine.PointAttachment(name); + }; + AtlasAttachmentLoader.prototype.newClippingAttachment = function (skin, name) { + return new spine.ClippingAttachment(name); + }; + return AtlasAttachmentLoader; + }()); + spine.AtlasAttachmentLoader = AtlasAttachmentLoader; +})(spine || (spine = {})); +var spine; +(function (spine) { + var BlendMode; + (function (BlendMode) { + BlendMode[BlendMode["Normal"] = 0] = "Normal"; + BlendMode[BlendMode["Additive"] = 1] = "Additive"; + BlendMode[BlendMode["Multiply"] = 2] = "Multiply"; + BlendMode[BlendMode["Screen"] = 3] = "Screen"; + })(BlendMode = spine.BlendMode || (spine.BlendMode = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Bone = (function () { + function Bone(data, skeleton, parent) { + this.children = new Array(); + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 0; + this.scaleY = 0; + this.shearX = 0; + this.shearY = 0; + this.ax = 0; + this.ay = 0; + this.arotation = 0; + this.ascaleX = 0; + this.ascaleY = 0; + this.ashearX = 0; + this.ashearY = 0; + this.appliedValid = false; + this.a = 0; + this.b = 0; + this.worldX = 0; + this.c = 0; + this.d = 0; + this.worldY = 0; + this.sorted = false; + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.skeleton = skeleton; + this.parent = parent; + this.setToSetupPose(); + } + Bone.prototype.update = function () { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + Bone.prototype.updateWorldTransform = function () { + this.updateWorldTransformWith(this.x, this.y, this.rotation, this.scaleX, this.scaleY, this.shearX, this.shearY); + }; + Bone.prototype.updateWorldTransformWith = function (x, y, rotation, scaleX, scaleY, shearX, shearY) { + this.ax = x; + this.ay = y; + this.arotation = rotation; + this.ascaleX = scaleX; + this.ascaleY = scaleY; + this.ashearX = shearX; + this.ashearY = shearY; + this.appliedValid = true; + var parent = this.parent; + if (parent == null) { + var rotationY = rotation + 90 + shearY; + var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(rotationY) * scaleY; + var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(rotationY) * scaleY; + var skeleton = this.skeleton; + if (skeleton.flipX) { + x = -x; + la = -la; + lb = -lb; + } + if (skeleton.flipY) { + y = -y; + lc = -lc; + ld = -ld; + } + this.a = la; + this.b = lb; + this.c = lc; + this.d = ld; + this.worldX = x + skeleton.x; + this.worldY = y + skeleton.y; + return; + } + var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; + this.worldX = pa * x + pb * y + parent.worldX; + this.worldY = pc * x + pd * y + parent.worldY; + switch (this.data.transformMode) { + case spine.TransformMode.Normal: { + var rotationY = rotation + 90 + shearY; + var la = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(rotationY) * scaleY; + var lc = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(rotationY) * scaleY; + this.a = pa * la + pb * lc; + this.b = pa * lb + pb * ld; + this.c = pc * la + pd * lc; + this.d = pc * lb + pd * ld; + return; + } + case spine.TransformMode.OnlyTranslation: { + var rotationY = rotation + 90 + shearY; + this.a = spine.MathUtils.cosDeg(rotation + shearX) * scaleX; + this.b = spine.MathUtils.cosDeg(rotationY) * scaleY; + this.c = spine.MathUtils.sinDeg(rotation + shearX) * scaleX; + this.d = spine.MathUtils.sinDeg(rotationY) * scaleY; + break; + } + case spine.TransformMode.NoRotationOrReflection: { + var s = pa * pa + pc * pc; + var prx = 0; + if (s > 0.0001) { + s = Math.abs(pa * pd - pb * pc) / s; + pb = pc * s; + pd = pa * s; + prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg; + } + else { + pa = 0; + pc = 0; + prx = 90 - Math.atan2(pd, pb) * spine.MathUtils.radDeg; + } + var rx = rotation + shearX - prx; + var ry = rotation + shearY - prx + 90; + var la = spine.MathUtils.cosDeg(rx) * scaleX; + var lb = spine.MathUtils.cosDeg(ry) * scaleY; + var lc = spine.MathUtils.sinDeg(rx) * scaleX; + var ld = spine.MathUtils.sinDeg(ry) * scaleY; + this.a = pa * la - pb * lc; + this.b = pa * lb - pb * ld; + this.c = pc * la + pd * lc; + this.d = pc * lb + pd * ld; + break; + } + case spine.TransformMode.NoScale: + case spine.TransformMode.NoScaleOrReflection: { + var cos = spine.MathUtils.cosDeg(rotation); + var sin = spine.MathUtils.sinDeg(rotation); + var za = pa * cos + pb * sin; + var zc = pc * cos + pd * sin; + var s = Math.sqrt(za * za + zc * zc); + if (s > 0.00001) + s = 1 / s; + za *= s; + zc *= s; + s = Math.sqrt(za * za + zc * zc); + var r = Math.PI / 2 + Math.atan2(zc, za); + var zb = Math.cos(r) * s; + var zd = Math.sin(r) * s; + var la = spine.MathUtils.cosDeg(shearX) * scaleX; + var lb = spine.MathUtils.cosDeg(90 + shearY) * scaleY; + var lc = spine.MathUtils.sinDeg(shearX) * scaleX; + var ld = spine.MathUtils.sinDeg(90 + shearY) * scaleY; + if (this.data.transformMode != spine.TransformMode.NoScaleOrReflection ? pa * pd - pb * pc < 0 : this.skeleton.flipX != this.skeleton.flipY) { + zb = -zb; + zd = -zd; + } + this.a = za * la + zb * lc; + this.b = za * lb + zb * ld; + this.c = zc * la + zd * lc; + this.d = zc * lb + zd * ld; + return; + } + } + if (this.skeleton.flipX) { + this.a = -this.a; + this.b = -this.b; + } + if (this.skeleton.flipY) { + this.c = -this.c; + this.d = -this.d; + } + }; + Bone.prototype.setToSetupPose = function () { + var data = this.data; + this.x = data.x; + this.y = data.y; + this.rotation = data.rotation; + this.scaleX = data.scaleX; + this.scaleY = data.scaleY; + this.shearX = data.shearX; + this.shearY = data.shearY; + }; + Bone.prototype.getWorldRotationX = function () { + return Math.atan2(this.c, this.a) * spine.MathUtils.radDeg; + }; + Bone.prototype.getWorldRotationY = function () { + return Math.atan2(this.d, this.b) * spine.MathUtils.radDeg; + }; + Bone.prototype.getWorldScaleX = function () { + return Math.sqrt(this.a * this.a + this.c * this.c); + }; + Bone.prototype.getWorldScaleY = function () { + return Math.sqrt(this.b * this.b + this.d * this.d); + }; + Bone.prototype.updateAppliedTransform = function () { + this.appliedValid = true; + var parent = this.parent; + if (parent == null) { + this.ax = this.worldX; + this.ay = this.worldY; + this.arotation = Math.atan2(this.c, this.a) * spine.MathUtils.radDeg; + this.ascaleX = Math.sqrt(this.a * this.a + this.c * this.c); + this.ascaleY = Math.sqrt(this.b * this.b + this.d * this.d); + this.ashearX = 0; + this.ashearY = Math.atan2(this.a * this.b + this.c * this.d, this.a * this.d - this.b * this.c) * spine.MathUtils.radDeg; + return; + } + var pa = parent.a, pb = parent.b, pc = parent.c, pd = parent.d; + var pid = 1 / (pa * pd - pb * pc); + var dx = this.worldX - parent.worldX, dy = this.worldY - parent.worldY; + this.ax = (dx * pd * pid - dy * pb * pid); + this.ay = (dy * pa * pid - dx * pc * pid); + var ia = pid * pd; + var id = pid * pa; + var ib = pid * pb; + var ic = pid * pc; + var ra = ia * this.a - ib * this.c; + var rb = ia * this.b - ib * this.d; + var rc = id * this.c - ic * this.a; + var rd = id * this.d - ic * this.b; + this.ashearX = 0; + this.ascaleX = Math.sqrt(ra * ra + rc * rc); + if (this.ascaleX > 0.0001) { + var det = ra * rd - rb * rc; + this.ascaleY = det / this.ascaleX; + this.ashearY = Math.atan2(ra * rb + rc * rd, det) * spine.MathUtils.radDeg; + this.arotation = Math.atan2(rc, ra) * spine.MathUtils.radDeg; + } + else { + this.ascaleX = 0; + this.ascaleY = Math.sqrt(rb * rb + rd * rd); + this.ashearY = 0; + this.arotation = 90 - Math.atan2(rd, rb) * spine.MathUtils.radDeg; + } + }; + Bone.prototype.worldToLocal = function (world) { + var a = this.a, b = this.b, c = this.c, d = this.d; + var invDet = 1 / (a * d - b * c); + var x = world.x - this.worldX, y = world.y - this.worldY; + world.x = (x * d * invDet - y * b * invDet); + world.y = (y * a * invDet - x * c * invDet); + return world; + }; + Bone.prototype.localToWorld = function (local) { + var x = local.x, y = local.y; + local.x = x * this.a + y * this.b + this.worldX; + local.y = x * this.c + y * this.d + this.worldY; + return local; + }; + Bone.prototype.worldToLocalRotation = function (worldRotation) { + var sin = spine.MathUtils.sinDeg(worldRotation), cos = spine.MathUtils.cosDeg(worldRotation); + return Math.atan2(this.a * sin - this.c * cos, this.d * cos - this.b * sin) * spine.MathUtils.radDeg; + }; + Bone.prototype.localToWorldRotation = function (localRotation) { + var sin = spine.MathUtils.sinDeg(localRotation), cos = spine.MathUtils.cosDeg(localRotation); + return Math.atan2(cos * this.c + sin * this.d, cos * this.a + sin * this.b) * spine.MathUtils.radDeg; + }; + Bone.prototype.rotateWorld = function (degrees) { + var a = this.a, b = this.b, c = this.c, d = this.d; + var cos = spine.MathUtils.cosDeg(degrees), sin = spine.MathUtils.sinDeg(degrees); + this.a = cos * a - sin * c; + this.b = cos * b - sin * d; + this.c = sin * a + cos * c; + this.d = sin * b + cos * d; + this.appliedValid = false; + }; + return Bone; + }()); + spine.Bone = Bone; +})(spine || (spine = {})); +var spine; +(function (spine) { + var BoneData = (function () { + function BoneData(index, name, parent) { + this.x = 0; + this.y = 0; + this.rotation = 0; + this.scaleX = 1; + this.scaleY = 1; + this.shearX = 0; + this.shearY = 0; + this.transformMode = TransformMode.Normal; + if (index < 0) + throw new Error("index must be >= 0."); + if (name == null) + throw new Error("name cannot be null."); + this.index = index; + this.name = name; + this.parent = parent; + } + return BoneData; + }()); + spine.BoneData = BoneData; + var TransformMode; + (function (TransformMode) { + TransformMode[TransformMode["Normal"] = 0] = "Normal"; + TransformMode[TransformMode["OnlyTranslation"] = 1] = "OnlyTranslation"; + TransformMode[TransformMode["NoRotationOrReflection"] = 2] = "NoRotationOrReflection"; + TransformMode[TransformMode["NoScale"] = 3] = "NoScale"; + TransformMode[TransformMode["NoScaleOrReflection"] = 4] = "NoScaleOrReflection"; + })(TransformMode = spine.TransformMode || (spine.TransformMode = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Event = (function () { + function Event(time, data) { + if (data == null) + throw new Error("data cannot be null."); + this.time = time; + this.data = data; + } + return Event; + }()); + spine.Event = Event; +})(spine || (spine = {})); +var spine; +(function (spine) { + var EventData = (function () { + function EventData(name) { + this.name = name; + } + return EventData; + }()); + spine.EventData = EventData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var IkConstraint = (function () { + function IkConstraint(data, skeleton) { + this.mix = 1; + this.bendDirection = 0; + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.mix = data.mix; + this.bendDirection = data.bendDirection; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + IkConstraint.prototype.getOrder = function () { + return this.data.order; + }; + IkConstraint.prototype.apply = function () { + this.update(); + }; + IkConstraint.prototype.update = function () { + var target = this.target; + var bones = this.bones; + switch (bones.length) { + case 1: + this.apply1(bones[0], target.worldX, target.worldY, this.mix); + break; + case 2: + this.apply2(bones[0], bones[1], target.worldX, target.worldY, this.bendDirection, this.mix); + break; + } + }; + IkConstraint.prototype.apply1 = function (bone, targetX, targetY, alpha) { + if (!bone.appliedValid) + bone.updateAppliedTransform(); + var p = bone.parent; + var id = 1 / (p.a * p.d - p.b * p.c); + var x = targetX - p.worldX, y = targetY - p.worldY; + var tx = (x * p.d - y * p.b) * id - bone.ax, ty = (y * p.a - x * p.c) * id - bone.ay; + var rotationIK = Math.atan2(ty, tx) * spine.MathUtils.radDeg - bone.ashearX - bone.arotation; + if (bone.ascaleX < 0) + rotationIK += 180; + if (rotationIK > 180) + rotationIK -= 360; + else if (rotationIK < -180) + rotationIK += 360; + bone.updateWorldTransformWith(bone.ax, bone.ay, bone.arotation + rotationIK * alpha, bone.ascaleX, bone.ascaleY, bone.ashearX, bone.ashearY); + }; + IkConstraint.prototype.apply2 = function (parent, child, targetX, targetY, bendDir, alpha) { + if (alpha == 0) { + child.updateWorldTransform(); + return; + } + if (!parent.appliedValid) + parent.updateAppliedTransform(); + if (!child.appliedValid) + child.updateAppliedTransform(); + var px = parent.ax, py = parent.ay, psx = parent.ascaleX, psy = parent.ascaleY, csx = child.ascaleX; + var os1 = 0, os2 = 0, s2 = 0; + if (psx < 0) { + psx = -psx; + os1 = 180; + s2 = -1; + } + else { + os1 = 0; + s2 = 1; + } + if (psy < 0) { + psy = -psy; + s2 = -s2; + } + if (csx < 0) { + csx = -csx; + os2 = 180; + } + else + os2 = 0; + var cx = child.ax, cy = 0, cwx = 0, cwy = 0, a = parent.a, b = parent.b, c = parent.c, d = parent.d; + var u = Math.abs(psx - psy) <= 0.0001; + if (!u) { + cy = 0; + cwx = a * cx + parent.worldX; + cwy = c * cx + parent.worldY; + } + else { + cy = child.ay; + cwx = a * cx + b * cy + parent.worldX; + cwy = c * cx + d * cy + parent.worldY; + } + var pp = parent.parent; + a = pp.a; + b = pp.b; + c = pp.c; + d = pp.d; + var id = 1 / (a * d - b * c), x = targetX - pp.worldX, y = targetY - pp.worldY; + var tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py; + x = cwx - pp.worldX; + y = cwy - pp.worldY; + var dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py; + var l1 = Math.sqrt(dx * dx + dy * dy), l2 = child.data.length * csx, a1 = 0, a2 = 0; + outer: if (u) { + l2 *= psx; + var cos = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2); + if (cos < -1) + cos = -1; + else if (cos > 1) + cos = 1; + a2 = Math.acos(cos) * bendDir; + a = l1 + l2 * cos; + b = l2 * Math.sin(a2); + a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b); + } + else { + a = psx * l2; + b = psy * l2; + var aa = a * a, bb = b * b, dd = tx * tx + ty * ty, ta = Math.atan2(ty, tx); + c = bb * l1 * l1 + aa * dd - aa * bb; + var c1 = -2 * bb * l1, c2 = bb - aa; + d = c1 * c1 - 4 * c2 * c; + if (d >= 0) { + var q = Math.sqrt(d); + if (c1 < 0) + q = -q; + q = -(c1 + q) / 2; + var r0 = q / c2, r1 = c / q; + var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1; + if (r * r <= dd) { + y = Math.sqrt(dd - r * r) * bendDir; + a1 = ta - Math.atan2(y, r); + a2 = Math.atan2(y / psy, (r - l1) / psx); + break outer; + } + } + var minAngle = spine.MathUtils.PI, minX = l1 - a, minDist = minX * minX, minY = 0; + var maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0; + c = -a * l1 / (aa - bb); + if (c >= -1 && c <= 1) { + c = Math.acos(c); + x = a * Math.cos(c) + l1; + y = b * Math.sin(c); + d = x * x + y * y; + if (d < minDist) { + minAngle = c; + minDist = d; + minX = x; + minY = y; + } + if (d > maxDist) { + maxAngle = c; + maxDist = d; + maxX = x; + maxY = y; + } + } + if (dd <= (minDist + maxDist) / 2) { + a1 = ta - Math.atan2(minY * bendDir, minX); + a2 = minAngle * bendDir; + } + else { + a1 = ta - Math.atan2(maxY * bendDir, maxX); + a2 = maxAngle * bendDir; + } + } + var os = Math.atan2(cy, cx) * s2; + var rotation = parent.arotation; + a1 = (a1 - os) * spine.MathUtils.radDeg + os1 - rotation; + if (a1 > 180) + a1 -= 360; + else if (a1 < -180) + a1 += 360; + parent.updateWorldTransformWith(px, py, rotation + a1 * alpha, parent.ascaleX, parent.ascaleY, 0, 0); + rotation = child.arotation; + a2 = ((a2 + os) * spine.MathUtils.radDeg - child.ashearX) * s2 + os2 - rotation; + if (a2 > 180) + a2 -= 360; + else if (a2 < -180) + a2 += 360; + child.updateWorldTransformWith(cx, cy, rotation + a2 * alpha, child.ascaleX, child.ascaleY, child.ashearX, child.ashearY); + }; + return IkConstraint; + }()); + spine.IkConstraint = IkConstraint; +})(spine || (spine = {})); +var spine; +(function (spine) { + var IkConstraintData = (function () { + function IkConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.bendDirection = 1; + this.mix = 1; + this.name = name; + } + return IkConstraintData; + }()); + spine.IkConstraintData = IkConstraintData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PathConstraint = (function () { + function PathConstraint(data, skeleton) { + this.position = 0; + this.spacing = 0; + this.rotateMix = 0; + this.translateMix = 0; + this.spaces = new Array(); + this.positions = new Array(); + this.world = new Array(); + this.curves = new Array(); + this.lengths = new Array(); + this.segments = new Array(); + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.bones = new Array(); + for (var i = 0, n = data.bones.length; i < n; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findSlot(data.target.name); + this.position = data.position; + this.spacing = data.spacing; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + } + PathConstraint.prototype.apply = function () { + this.update(); + }; + PathConstraint.prototype.update = function () { + var attachment = this.target.getAttachment(); + if (!(attachment instanceof spine.PathAttachment)) + return; + var rotateMix = this.rotateMix, translateMix = this.translateMix; + var translate = translateMix > 0, rotate = rotateMix > 0; + if (!translate && !rotate) + return; + var data = this.data; + var spacingMode = data.spacingMode; + var lengthSpacing = spacingMode == spine.SpacingMode.Length; + var rotateMode = data.rotateMode; + var tangents = rotateMode == spine.RotateMode.Tangent, scale = rotateMode == spine.RotateMode.ChainScale; + var boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1; + var bones = this.bones; + var spaces = spine.Utils.setArraySize(this.spaces, spacesCount), lengths = null; + var spacing = this.spacing; + if (scale || lengthSpacing) { + if (scale) + lengths = spine.Utils.setArraySize(this.lengths, boneCount); + for (var i = 0, n = spacesCount - 1; i < n;) { + var bone = bones[i]; + var setupLength = bone.data.length; + if (setupLength < PathConstraint.epsilon) { + if (scale) + lengths[i] = 0; + spaces[++i] = 0; + } + else { + var x = setupLength * bone.a, y = setupLength * bone.c; + var length_1 = Math.sqrt(x * x + y * y); + if (scale) + lengths[i] = length_1; + spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength; + } + } + } + else { + for (var i = 1; i < spacesCount; i++) + spaces[i] = spacing; + } + var positions = this.computeWorldPositions(attachment, spacesCount, tangents, data.positionMode == spine.PositionMode.Percent, spacingMode == spine.SpacingMode.Percent); + var boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation; + var tip = false; + if (offsetRotation == 0) + tip = rotateMode == spine.RotateMode.Chain; + else { + tip = false; + var p = this.target.bone; + offsetRotation *= p.a * p.d - p.b * p.c > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + } + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + bone.worldX += (boneX - bone.worldX) * translateMix; + bone.worldY += (boneY - bone.worldY) * translateMix; + var x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY; + if (scale) { + var length_2 = lengths[i]; + if (length_2 != 0) { + var s = (Math.sqrt(dx * dx + dy * dy) / length_2 - 1) * rotateMix + 1; + bone.a *= s; + bone.c *= s; + } + } + boneX = x; + boneY = y; + if (rotate) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d, r = 0, cos = 0, sin = 0; + if (tangents) + r = positions[p - 1]; + else if (spaces[i + 1] == 0) + r = positions[p + 2]; + else + r = Math.atan2(dy, dx); + r -= Math.atan2(c, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_3 = bone.data.length; + boneX += (length_3 * (cos * a - sin * c) - dx) * rotateMix; + boneY += (length_3 * (sin * a + cos * c) - dy) * rotateMix; + } + else { + r += offsetRotation; + } + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + } + bone.appliedValid = false; + } + }; + PathConstraint.prototype.computeWorldPositions = function (path, spacesCount, tangents, percentPosition, percentSpacing) { + var target = this.target; + var position = this.position; + var spaces = this.spaces, out = spine.Utils.setArraySize(this.positions, spacesCount * 3 + 2), world = null; + var closed = path.closed; + var verticesLength = path.worldVerticesLength, curveCount = verticesLength / 6, prevCurve = PathConstraint.NONE; + if (!path.constantSpeed) { + var lengths = path.lengths; + curveCount -= closed ? 1 : 2; + var pathLength_1 = lengths[curveCount]; + if (percentPosition) + position *= pathLength_1; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) + spaces[i] *= pathLength_1; + } + world = spine.Utils.setArraySize(this.world, 8); + for (var i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength_1; + if (p < 0) + p += pathLength_1; + curve = 0; + } + else if (p < 0) { + if (prevCurve != PathConstraint.BEFORE) { + prevCurve = PathConstraint.BEFORE; + path.computeWorldVertices(target, 2, 4, world, 0, 2); + } + this.addBeforePosition(p, world, 0, out, o); + continue; + } + else if (p > pathLength_1) { + if (prevCurve != PathConstraint.AFTER) { + prevCurve = PathConstraint.AFTER; + path.computeWorldVertices(target, verticesLength - 6, 4, world, 0, 2); + } + this.addAfterPosition(p - pathLength_1, world, 0, out, o); + continue; + } + for (;; curve++) { + var length_4 = lengths[curve]; + if (p > length_4) + continue; + if (curve == 0) + p /= length_4; + else { + var prev = lengths[curve - 1]; + p = (p - prev) / (length_4 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + if (closed && curve == curveCount) { + path.computeWorldVertices(target, verticesLength - 4, 4, world, 0, 2); + path.computeWorldVertices(target, 0, 4, world, 4, 2); + } + else + path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2); + } + this.addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], out, o, tangents || (i > 0 && space == 0)); + } + return out; + } + if (closed) { + verticesLength += 2; + world = spine.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2); + path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); + world[verticesLength - 2] = world[0]; + world[verticesLength - 1] = world[1]; + } + else { + curveCount--; + verticesLength -= 4; + world = spine.Utils.setArraySize(this.world, verticesLength); + path.computeWorldVertices(target, 2, verticesLength, world, 0, 2); + } + var curves = spine.Utils.setArraySize(this.curves, curveCount); + var pathLength = 0; + var x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; + var tmpx = 0, tmpy = 0, dddfx = 0, dddfy = 0, ddfx = 0, ddfy = 0, dfx = 0, dfy = 0; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = world[w]; + cy1 = world[w + 1]; + cx2 = world[w + 2]; + cy2 = world[w + 3]; + x2 = world[w + 4]; + y2 = world[w + 5]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; + tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + if (percentPosition) + position *= pathLength; + if (percentSpacing) { + for (var i = 0; i < spacesCount; i++) + spaces[i] *= pathLength; + } + var segments = this.segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (closed) { + p %= pathLength; + if (p < 0) + p += pathLength; + curve = 0; + } + else if (p < 0) { + this.addBeforePosition(p, world, 0, out, o); + continue; + } + else if (p > pathLength) { + this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o); + continue; + } + for (;; curve++) { + var length_5 = curves[curve]; + if (p > length_5) + continue; + if (curve == 0) + p /= length_5; + else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_5 - prev); + } + break; + } + if (curve != prevCurve) { + prevCurve = curve; + var ii = curve * 6; + x1 = world[ii]; + y1 = world[ii + 1]; + cx1 = world[ii + 2]; + cy1 = world[ii + 3]; + cx2 = world[ii + 4]; + cy2 = world[ii + 5]; + x2 = world[ii + 6]; + y2 = world[ii + 7]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.03; + tmpy = (y1 - cy1 * 2 + cy2) * 0.03; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + p *= curveLength; + for (;; segment++) { + var length_6 = segments[segment]; + if (p > length_6) + continue; + if (segment == 0) + p /= length_6; + else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_6 - prev); + } + break; + } + this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0)); + } + return out; + }; + PathConstraint.prototype.addBeforePosition = function (p, temp, i, out, o) { + var x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addAfterPosition = function (p, temp, i, out, o) { + var x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx); + out[o] = x1 + p * Math.cos(r); + out[o + 1] = y1 + p * Math.sin(r); + out[o + 2] = r; + }; + PathConstraint.prototype.addCurvePosition = function (p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) { + if (p == 0 || isNaN(p)) + p = 0.0001; + var tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u; + var ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p; + var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt; + out[o] = x; + out[o + 1] = y; + if (tangents) + out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt)); + }; + PathConstraint.prototype.getOrder = function () { + return this.data.order; + }; + PathConstraint.NONE = -1; + PathConstraint.BEFORE = -2; + PathConstraint.AFTER = -3; + PathConstraint.epsilon = 0.00001; + return PathConstraint; + }()); + spine.PathConstraint = PathConstraint; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PathConstraintData = (function () { + function PathConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.name = name; + } + return PathConstraintData; + }()); + spine.PathConstraintData = PathConstraintData; + var PositionMode; + (function (PositionMode) { + PositionMode[PositionMode["Fixed"] = 0] = "Fixed"; + PositionMode[PositionMode["Percent"] = 1] = "Percent"; + })(PositionMode = spine.PositionMode || (spine.PositionMode = {})); + var SpacingMode; + (function (SpacingMode) { + SpacingMode[SpacingMode["Length"] = 0] = "Length"; + SpacingMode[SpacingMode["Fixed"] = 1] = "Fixed"; + SpacingMode[SpacingMode["Percent"] = 2] = "Percent"; + })(SpacingMode = spine.SpacingMode || (spine.SpacingMode = {})); + var RotateMode; + (function (RotateMode) { + RotateMode[RotateMode["Tangent"] = 0] = "Tangent"; + RotateMode[RotateMode["Chain"] = 1] = "Chain"; + RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; + })(RotateMode = spine.RotateMode || (spine.RotateMode = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Assets = (function () { + function Assets(clientId) { + this.toLoad = new Array(); + this.assets = {}; + this.clientId = clientId; + } + Assets.prototype.loaded = function () { + var i = 0; + for (var v in this.assets) + i++; + return i; + }; + return Assets; + }()); + var SharedAssetManager = (function () { + function SharedAssetManager(pathPrefix) { + if (pathPrefix === void 0) { pathPrefix = ""; } + this.clientAssets = {}; + this.queuedAssets = {}; + this.rawAssets = {}; + this.errors = {}; + this.pathPrefix = pathPrefix; + } + SharedAssetManager.prototype.queueAsset = function (clientId, textureLoader, path) { + var clientAssets = this.clientAssets[clientId]; + if (clientAssets === null || clientAssets === undefined) { + clientAssets = new Assets(clientId); + this.clientAssets[clientId] = clientAssets; + } + if (textureLoader !== null) + clientAssets.textureLoader = textureLoader; + clientAssets.toLoad.push(path); + if (this.queuedAssets[path] === path) { + return false; + } + else { + this.queuedAssets[path] = path; + return true; + } + }; + SharedAssetManager.prototype.loadText = function (clientId, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, null, path)) + return; + var request = new XMLHttpRequest(); + request.onreadystatechange = function () { + if (request.readyState == XMLHttpRequest.DONE) { + if (request.status >= 200 && request.status < 300) { + _this.rawAssets[path] = request.responseText; + } + else { + _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText; + } + } + }; + request.open("GET", path, true); + request.send(); + }; + SharedAssetManager.prototype.loadJson = function (clientId, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, null, path)) + return; + var request = new XMLHttpRequest(); + request.onreadystatechange = function () { + if (request.readyState == XMLHttpRequest.DONE) { + if (request.status >= 200 && request.status < 300) { + _this.rawAssets[path] = JSON.parse(request.responseText); + } + else { + _this.errors[path] = "Couldn't load text " + path + ": status " + request.status + ", " + request.responseText; + } + } + }; + request.open("GET", path, true); + request.send(); + }; + SharedAssetManager.prototype.loadTexture = function (clientId, textureLoader, path) { + var _this = this; + path = this.pathPrefix + path; + if (!this.queueAsset(clientId, textureLoader, path)) + return; + var img = new Image(); + img.src = path; + img.crossOrigin = "anonymous"; + img.onload = function (ev) { + _this.rawAssets[path] = img; + }; + img.onerror = function (ev) { + _this.errors[path] = "Couldn't load image " + path; + }; + }; + SharedAssetManager.prototype.get = function (clientId, path) { + path = this.pathPrefix + path; + var clientAssets = this.clientAssets[clientId]; + if (clientAssets === null || clientAssets === undefined) + return true; + return clientAssets.assets[path]; + }; + SharedAssetManager.prototype.updateClientAssets = function (clientAssets) { + for (var i = 0; i < clientAssets.toLoad.length; i++) { + var path = clientAssets.toLoad[i]; + var asset = clientAssets.assets[path]; + if (asset === null || asset === undefined) { + var rawAsset = this.rawAssets[path]; + if (rawAsset === null || rawAsset === undefined) + continue; + if (rawAsset instanceof HTMLImageElement) { + clientAssets.assets[path] = clientAssets.textureLoader(rawAsset); + } + else { + clientAssets.assets[path] = rawAsset; + } + } + } + }; + SharedAssetManager.prototype.isLoadingComplete = function (clientId) { + var clientAssets = this.clientAssets[clientId]; + if (clientAssets === null || clientAssets === undefined) + return true; + this.updateClientAssets(clientAssets); + return clientAssets.toLoad.length == clientAssets.loaded(); + }; + SharedAssetManager.prototype.dispose = function () { + }; + SharedAssetManager.prototype.hasErrors = function () { + return Object.keys(this.errors).length > 0; + }; + SharedAssetManager.prototype.getErrors = function () { + return this.errors; + }; + return SharedAssetManager; + }()); + spine.SharedAssetManager = SharedAssetManager; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Skeleton = (function () { + function Skeleton(data) { + this._updateCache = new Array(); + this.updateCacheReset = new Array(); + this.time = 0; + this.flipX = false; + this.flipY = false; + this.x = 0; + this.y = 0; + if (data == null) + throw new Error("data cannot be null."); + this.data = data; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) { + var boneData = data.bones[i]; + var bone = void 0; + if (boneData.parent == null) + bone = new spine.Bone(boneData, this, null); + else { + var parent_1 = this.bones[boneData.parent.index]; + bone = new spine.Bone(boneData, this, parent_1); + parent_1.children.push(bone); + } + this.bones.push(bone); + } + this.slots = new Array(); + this.drawOrder = new Array(); + for (var i = 0; i < data.slots.length; i++) { + var slotData = data.slots[i]; + var bone = this.bones[slotData.boneData.index]; + var slot = new spine.Slot(slotData, bone); + this.slots.push(slot); + this.drawOrder.push(slot); + } + this.ikConstraints = new Array(); + for (var i = 0; i < data.ikConstraints.length; i++) { + var ikConstraintData = data.ikConstraints[i]; + this.ikConstraints.push(new spine.IkConstraint(ikConstraintData, this)); + } + this.transformConstraints = new Array(); + for (var i = 0; i < data.transformConstraints.length; i++) { + var transformConstraintData = data.transformConstraints[i]; + this.transformConstraints.push(new spine.TransformConstraint(transformConstraintData, this)); + } + this.pathConstraints = new Array(); + for (var i = 0; i < data.pathConstraints.length; i++) { + var pathConstraintData = data.pathConstraints[i]; + this.pathConstraints.push(new spine.PathConstraint(pathConstraintData, this)); + } + this.color = new spine.Color(1, 1, 1, 1); + this.updateCache(); + } + Skeleton.prototype.updateCache = function () { + var updateCache = this._updateCache; + updateCache.length = 0; + this.updateCacheReset.length = 0; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + bones[i].sorted = false; + var ikConstraints = this.ikConstraints; + var transformConstraints = this.transformConstraints; + var pathConstraints = this.pathConstraints; + var ikCount = ikConstraints.length, transformCount = transformConstraints.length, pathCount = pathConstraints.length; + var constraintCount = ikCount + transformCount + pathCount; + outer: for (var i = 0; i < constraintCount; i++) { + for (var ii = 0; ii < ikCount; ii++) { + var constraint = ikConstraints[ii]; + if (constraint.data.order == i) { + this.sortIkConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < transformCount; ii++) { + var constraint = transformConstraints[ii]; + if (constraint.data.order == i) { + this.sortTransformConstraint(constraint); + continue outer; + } + } + for (var ii = 0; ii < pathCount; ii++) { + var constraint = pathConstraints[ii]; + if (constraint.data.order == i) { + this.sortPathConstraint(constraint); + continue outer; + } + } + } + for (var i = 0, n = bones.length; i < n; i++) + this.sortBone(bones[i]); + }; + Skeleton.prototype.sortIkConstraint = function (constraint) { + var target = constraint.target; + this.sortBone(target); + var constrained = constraint.bones; + var parent = constrained[0]; + this.sortBone(parent); + if (constrained.length > 1) { + var child = constrained[constrained.length - 1]; + if (!(this._updateCache.indexOf(child) > -1)) + this.updateCacheReset.push(child); + } + this._updateCache.push(constraint); + this.sortReset(parent.children); + constrained[constrained.length - 1].sorted = true; + }; + Skeleton.prototype.sortPathConstraint = function (constraint) { + var slot = constraint.target; + var slotIndex = slot.data.index; + var slotBone = slot.bone; + if (this.skin != null) + this.sortPathConstraintAttachment(this.skin, slotIndex, slotBone); + if (this.data.defaultSkin != null && this.data.defaultSkin != this.skin) + this.sortPathConstraintAttachment(this.data.defaultSkin, slotIndex, slotBone); + for (var i = 0, n = this.data.skins.length; i < n; i++) + this.sortPathConstraintAttachment(this.data.skins[i], slotIndex, slotBone); + var attachment = slot.getAttachment(); + if (attachment instanceof spine.PathAttachment) + this.sortPathConstraintAttachmentWith(attachment, slotBone); + var constrained = constraint.bones; + var boneCount = constrained.length; + for (var i = 0; i < boneCount; i++) + this.sortBone(constrained[i]); + this._updateCache.push(constraint); + for (var i = 0; i < boneCount; i++) + this.sortReset(constrained[i].children); + for (var i = 0; i < boneCount; i++) + constrained[i].sorted = true; + }; + Skeleton.prototype.sortTransformConstraint = function (constraint) { + this.sortBone(constraint.target); + var constrained = constraint.bones; + var boneCount = constrained.length; + if (constraint.data.local) { + for (var i = 0; i < boneCount; i++) { + var child = constrained[i]; + this.sortBone(child.parent); + if (!(this._updateCache.indexOf(child) > -1)) + this.updateCacheReset.push(child); + } + } + else { + for (var i = 0; i < boneCount; i++) { + this.sortBone(constrained[i]); + } + } + this._updateCache.push(constraint); + for (var ii = 0; ii < boneCount; ii++) + this.sortReset(constrained[ii].children); + for (var ii = 0; ii < boneCount; ii++) + constrained[ii].sorted = true; + }; + Skeleton.prototype.sortPathConstraintAttachment = function (skin, slotIndex, slotBone) { + var attachments = skin.attachments[slotIndex]; + if (!attachments) + return; + for (var key in attachments) { + this.sortPathConstraintAttachmentWith(attachments[key], slotBone); + } + }; + Skeleton.prototype.sortPathConstraintAttachmentWith = function (attachment, slotBone) { + if (!(attachment instanceof spine.PathAttachment)) + return; + var pathBones = attachment.bones; + if (pathBones == null) + this.sortBone(slotBone); + else { + var bones = this.bones; + var i = 0; + while (i < pathBones.length) { + var boneCount = pathBones[i++]; + for (var n = i + boneCount; i < n; i++) { + var boneIndex = pathBones[i]; + this.sortBone(bones[boneIndex]); + } + } + } + }; + Skeleton.prototype.sortBone = function (bone) { + if (bone.sorted) + return; + var parent = bone.parent; + if (parent != null) + this.sortBone(parent); + bone.sorted = true; + this._updateCache.push(bone); + }; + Skeleton.prototype.sortReset = function (bones) { + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.sorted) + this.sortReset(bone.children); + bone.sorted = false; + } + }; + Skeleton.prototype.updateWorldTransform = function () { + var updateCacheReset = this.updateCacheReset; + for (var i = 0, n = updateCacheReset.length; i < n; i++) { + var bone = updateCacheReset[i]; + bone.ax = bone.x; + bone.ay = bone.y; + bone.arotation = bone.rotation; + bone.ascaleX = bone.scaleX; + bone.ascaleY = bone.scaleY; + bone.ashearX = bone.shearX; + bone.ashearY = bone.shearY; + bone.appliedValid = true; + } + var updateCache = this._updateCache; + for (var i = 0, n = updateCache.length; i < n; i++) + updateCache[i].update(); + }; + Skeleton.prototype.setToSetupPose = function () { + this.setBonesToSetupPose(); + this.setSlotsToSetupPose(); + }; + Skeleton.prototype.setBonesToSetupPose = function () { + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + bones[i].setToSetupPose(); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + constraint.bendDirection = constraint.data.bendDirection; + constraint.mix = constraint.data.mix; + } + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + var data = constraint.data; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + constraint.scaleMix = data.scaleMix; + constraint.shearMix = data.shearMix; + } + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + var data = constraint.data; + constraint.position = data.position; + constraint.spacing = data.spacing; + constraint.rotateMix = data.rotateMix; + constraint.translateMix = data.translateMix; + } + }; + Skeleton.prototype.setSlotsToSetupPose = function () { + var slots = this.slots; + spine.Utils.arrayCopy(slots, 0, this.drawOrder, 0, slots.length); + for (var i = 0, n = slots.length; i < n; i++) + slots[i].setToSetupPose(); + }; + Skeleton.prototype.getRootBone = function () { + if (this.bones.length == 0) + return null; + return this.bones[0]; + }; + Skeleton.prototype.findBone = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.data.name == boneName) + return bone; + } + return null; + }; + Skeleton.prototype.findBoneIndex = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].data.name == boneName) + return i; + return -1; + }; + Skeleton.prototype.findSlot = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) + return slot; + } + return null; + }; + Skeleton.prototype.findSlotIndex = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + if (slots[i].data.name == slotName) + return i; + return -1; + }; + Skeleton.prototype.setSkinByName = function (skinName) { + var skin = this.data.findSkin(skinName); + if (skin == null) + throw new Error("Skin not found: " + skinName); + this.setSkin(skin); + }; + Skeleton.prototype.setSkin = function (newSkin) { + if (newSkin != null) { + if (this.skin != null) + newSkin.attachAll(this, this.skin); + else { + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var name_1 = slot.data.attachmentName; + if (name_1 != null) { + var attachment = newSkin.getAttachment(i, name_1); + if (attachment != null) + slot.setAttachment(attachment); + } + } + } + } + this.skin = newSkin; + }; + Skeleton.prototype.getAttachmentByName = function (slotName, attachmentName) { + return this.getAttachment(this.data.findSlotIndex(slotName), attachmentName); + }; + Skeleton.prototype.getAttachment = function (slotIndex, attachmentName) { + if (attachmentName == null) + throw new Error("attachmentName cannot be null."); + if (this.skin != null) { + var attachment = this.skin.getAttachment(slotIndex, attachmentName); + if (attachment != null) + return attachment; + } + if (this.data.defaultSkin != null) + return this.data.defaultSkin.getAttachment(slotIndex, attachmentName); + return null; + }; + Skeleton.prototype.setAttachment = function (slotName, attachmentName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.data.name == slotName) { + var attachment = null; + if (attachmentName != null) { + attachment = this.getAttachment(i, attachmentName); + if (attachment == null) + throw new Error("Attachment not found: " + attachmentName + ", for slot: " + slotName); + } + slot.setAttachment(attachment); + return; + } + } + throw new Error("Slot not found: " + slotName); + }; + Skeleton.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var ikConstraint = ikConstraints[i]; + if (ikConstraint.data.name == constraintName) + return ikConstraint; + } + return null; + }; + Skeleton.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.data.name == constraintName) + return constraint; + } + return null; + }; + Skeleton.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.data.name == constraintName) + return constraint; + } + return null; + }; + Skeleton.prototype.getBounds = function (offset, size, temp) { + if (offset == null) + throw new Error("offset cannot be null."); + if (size == null) + throw new Error("size cannot be null."); + var drawOrder = this.drawOrder; + var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var slot = drawOrder[i]; + var verticesLength = 0; + var vertices = null; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.RegionAttachment) { + verticesLength = 8; + vertices = spine.Utils.setArraySize(temp, verticesLength, 0); + attachment.computeWorldVertices(slot.bone, vertices, 0, 2); + } + else if (attachment instanceof spine.MeshAttachment) { + var mesh = attachment; + verticesLength = mesh.worldVerticesLength; + vertices = spine.Utils.setArraySize(temp, verticesLength, 0); + mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); + } + if (vertices != null) { + for (var ii = 0, nn = vertices.length; ii < nn; ii += 2) { + var x = vertices[ii], y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + } + offset.set(minX, minY); + size.set(maxX - minX, maxY - minY); + }; + Skeleton.prototype.update = function (delta) { + this.time += delta; + }; + return Skeleton; + }()); + spine.Skeleton = Skeleton; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonBounds = (function () { + function SkeletonBounds() { + this.minX = 0; + this.minY = 0; + this.maxX = 0; + this.maxY = 0; + this.boundingBoxes = new Array(); + this.polygons = new Array(); + this.polygonPool = new spine.Pool(function () { + return spine.Utils.newFloatArray(16); + }); + } + SkeletonBounds.prototype.update = function (skeleton, updateAabb) { + if (skeleton == null) + throw new Error("skeleton cannot be null."); + var boundingBoxes = this.boundingBoxes; + var polygons = this.polygons; + var polygonPool = this.polygonPool; + var slots = skeleton.slots; + var slotCount = slots.length; + boundingBoxes.length = 0; + polygonPool.freeAll(polygons); + polygons.length = 0; + for (var i = 0; i < slotCount; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.BoundingBoxAttachment) { + var boundingBox = attachment; + boundingBoxes.push(boundingBox); + var polygon = polygonPool.obtain(); + if (polygon.length != boundingBox.worldVerticesLength) { + polygon = spine.Utils.newFloatArray(boundingBox.worldVerticesLength); + } + polygons.push(polygon); + boundingBox.computeWorldVertices(slot, 0, boundingBox.worldVerticesLength, polygon, 0, 2); + } + } + if (updateAabb) { + this.aabbCompute(); + } + else { + this.minX = Number.POSITIVE_INFINITY; + this.minY = Number.POSITIVE_INFINITY; + this.maxX = Number.NEGATIVE_INFINITY; + this.maxY = Number.NEGATIVE_INFINITY; + } + }; + SkeletonBounds.prototype.aabbCompute = function () { + var minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY; + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) { + var polygon = polygons[i]; + var vertices = polygon; + for (var ii = 0, nn = polygon.length; ii < nn; ii += 2) { + var x = vertices[ii]; + var y = vertices[ii + 1]; + minX = Math.min(minX, x); + minY = Math.min(minY, y); + maxX = Math.max(maxX, x); + maxY = Math.max(maxY, y); + } + } + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + }; + SkeletonBounds.prototype.aabbContainsPoint = function (x, y) { + return x >= this.minX && x <= this.maxX && y >= this.minY && y <= this.maxY; + }; + SkeletonBounds.prototype.aabbIntersectsSegment = function (x1, y1, x2, y2) { + var minX = this.minX; + var minY = this.minY; + var maxX = this.maxX; + var maxY = this.maxY; + if ((x1 <= minX && x2 <= minX) || (y1 <= minY && y2 <= minY) || (x1 >= maxX && x2 >= maxX) || (y1 >= maxY && y2 >= maxY)) + return false; + var m = (y2 - y1) / (x2 - x1); + var y = m * (minX - x1) + y1; + if (y > minY && y < maxY) + return true; + y = m * (maxX - x1) + y1; + if (y > minY && y < maxY) + return true; + var x = (minY - y1) / m + x1; + if (x > minX && x < maxX) + return true; + x = (maxY - y1) / m + x1; + if (x > minX && x < maxX) + return true; + return false; + }; + SkeletonBounds.prototype.aabbIntersectsSkeleton = function (bounds) { + return this.minX < bounds.maxX && this.maxX > bounds.minX && this.minY < bounds.maxY && this.maxY > bounds.minY; + }; + SkeletonBounds.prototype.containsPoint = function (x, y) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.containsPointPolygon(polygons[i], x, y)) + return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.containsPointPolygon = function (polygon, x, y) { + var vertices = polygon; + var nn = polygon.length; + var prevIndex = nn - 2; + var inside = false; + for (var ii = 0; ii < nn; ii += 2) { + var vertexY = vertices[ii + 1]; + var prevY = vertices[prevIndex + 1]; + if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) { + var vertexX = vertices[ii]; + if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x) + inside = !inside; + } + prevIndex = ii; + } + return inside; + }; + SkeletonBounds.prototype.intersectsSegment = function (x1, y1, x2, y2) { + var polygons = this.polygons; + for (var i = 0, n = polygons.length; i < n; i++) + if (this.intersectsSegmentPolygon(polygons[i], x1, y1, x2, y2)) + return this.boundingBoxes[i]; + return null; + }; + SkeletonBounds.prototype.intersectsSegmentPolygon = function (polygon, x1, y1, x2, y2) { + var vertices = polygon; + var nn = polygon.length; + var width12 = x1 - x2, height12 = y1 - y2; + var det1 = x1 * y2 - y1 * x2; + var x3 = vertices[nn - 2], y3 = vertices[nn - 1]; + for (var ii = 0; ii < nn; ii += 2) { + var x4 = vertices[ii], y4 = vertices[ii + 1]; + var det2 = x3 * y4 - y3 * x4; + var width34 = x3 - x4, height34 = y3 - y4; + var det3 = width12 * height34 - height12 * width34; + var x = (det1 * width34 - width12 * det2) / det3; + if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) { + var y = (det1 * height34 - height12 * det2) / det3; + if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) + return true; + } + x3 = x4; + y3 = y4; + } + return false; + }; + SkeletonBounds.prototype.getPolygon = function (boundingBox) { + if (boundingBox == null) + throw new Error("boundingBox cannot be null."); + var index = this.boundingBoxes.indexOf(boundingBox); + return index == -1 ? null : this.polygons[index]; + }; + SkeletonBounds.prototype.getWidth = function () { + return this.maxX - this.minX; + }; + SkeletonBounds.prototype.getHeight = function () { + return this.maxY - this.minY; + }; + return SkeletonBounds; + }()); + spine.SkeletonBounds = SkeletonBounds; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonClipping = (function () { + function SkeletonClipping() { + this.triangulator = new spine.Triangulator(); + this.clippingPolygon = new Array(); + this.clipOutput = new Array(); + this.clippedVertices = new Array(); + this.clippedTriangles = new Array(); + this.scratch = new Array(); + } + SkeletonClipping.prototype.clipStart = function (slot, clip) { + if (this.clipAttachment != null) + return 0; + this.clipAttachment = clip; + var n = clip.worldVerticesLength; + var vertices = spine.Utils.setArraySize(this.clippingPolygon, n); + clip.computeWorldVertices(slot, 0, n, vertices, 0, 2); + var clippingPolygon = this.clippingPolygon; + SkeletonClipping.makeClockwise(clippingPolygon); + var clippingPolygons = this.clippingPolygons = this.triangulator.decompose(clippingPolygon, this.triangulator.triangulate(clippingPolygon)); + for (var i = 0, n_1 = clippingPolygons.length; i < n_1; i++) { + var polygon = clippingPolygons[i]; + SkeletonClipping.makeClockwise(polygon); + polygon.push(polygon[0]); + polygon.push(polygon[1]); + } + return clippingPolygons.length; + }; + SkeletonClipping.prototype.clipEndWithSlot = function (slot) { + if (this.clipAttachment != null && this.clipAttachment.endSlot == slot.data) + this.clipEnd(); + }; + SkeletonClipping.prototype.clipEnd = function () { + if (this.clipAttachment == null) + return; + this.clipAttachment = null; + this.clippingPolygons = null; + this.clippedVertices.length = 0; + this.clippedTriangles.length = 0; + this.clippingPolygon.length = 0; + }; + SkeletonClipping.prototype.isClipping = function () { + return this.clipAttachment != null; + }; + SkeletonClipping.prototype.clipTriangles = function (vertices, verticesLength, triangles, trianglesLength, uvs, light, dark, twoColor) { + var clipOutput = this.clipOutput, clippedVertices = this.clippedVertices; + var clippedTriangles = this.clippedTriangles; + var polygons = this.clippingPolygons; + var polygonsCount = this.clippingPolygons.length; + var vertexSize = twoColor ? 12 : 8; + var index = 0; + clippedVertices.length = 0; + clippedTriangles.length = 0; + outer: for (var i = 0; i < trianglesLength; i += 3) { + var vertexOffset = triangles[i] << 1; + var x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1]; + var u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 1] << 1; + var x2 = vertices[vertexOffset], y2 = vertices[vertexOffset + 1]; + var u2 = uvs[vertexOffset], v2 = uvs[vertexOffset + 1]; + vertexOffset = triangles[i + 2] << 1; + var x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1]; + var u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1]; + for (var p = 0; p < polygonsCount; p++) { + var s = clippedVertices.length; + if (this.clip(x1, y1, x2, y2, x3, y3, polygons[p], clipOutput)) { + var clipOutputLength = clipOutput.length; + if (clipOutputLength == 0) + continue; + var d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1; + var d = 1 / (d0 * d2 + d1 * (y1 - y3)); + var clipOutputCount = clipOutputLength >> 1; + var clipOutputItems = this.clipOutput; + var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + clipOutputCount * vertexSize); + for (var ii = 0; ii < clipOutputLength; ii += 2) { + var x = clipOutputItems[ii], y = clipOutputItems[ii + 1]; + clippedVerticesItems[s] = x; + clippedVerticesItems[s + 1] = y; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + var c0 = x - x3, c1 = y - y3; + var a = (d0 * c0 + d1 * c1) * d; + var b = (d4 * c0 + d2 * c1) * d; + var c = 1 - a - b; + clippedVerticesItems[s + 6] = u1 * a + u2 * b + u3 * c; + clippedVerticesItems[s + 7] = v1 * a + v2 * b + v3 * c; + if (twoColor) { + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + } + s += vertexSize; + } + s = clippedTriangles.length; + var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3 * (clipOutputCount - 2)); + clipOutputCount--; + for (var ii = 1; ii < clipOutputCount; ii++) { + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = (index + ii); + clippedTrianglesItems[s + 2] = (index + ii + 1); + s += 3; + } + index += clipOutputCount + 1; + } + else { + var clippedVerticesItems = spine.Utils.setArraySize(clippedVertices, s + 3 * vertexSize); + clippedVerticesItems[s] = x1; + clippedVerticesItems[s + 1] = y1; + clippedVerticesItems[s + 2] = light.r; + clippedVerticesItems[s + 3] = light.g; + clippedVerticesItems[s + 4] = light.b; + clippedVerticesItems[s + 5] = light.a; + if (!twoColor) { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = x2; + clippedVerticesItems[s + 9] = y2; + clippedVerticesItems[s + 10] = light.r; + clippedVerticesItems[s + 11] = light.g; + clippedVerticesItems[s + 12] = light.b; + clippedVerticesItems[s + 13] = light.a; + clippedVerticesItems[s + 14] = u2; + clippedVerticesItems[s + 15] = v2; + clippedVerticesItems[s + 16] = x3; + clippedVerticesItems[s + 17] = y3; + clippedVerticesItems[s + 18] = light.r; + clippedVerticesItems[s + 19] = light.g; + clippedVerticesItems[s + 20] = light.b; + clippedVerticesItems[s + 21] = light.a; + clippedVerticesItems[s + 22] = u3; + clippedVerticesItems[s + 23] = v3; + } + else { + clippedVerticesItems[s + 6] = u1; + clippedVerticesItems[s + 7] = v1; + clippedVerticesItems[s + 8] = dark.r; + clippedVerticesItems[s + 9] = dark.g; + clippedVerticesItems[s + 10] = dark.b; + clippedVerticesItems[s + 11] = dark.a; + clippedVerticesItems[s + 12] = x2; + clippedVerticesItems[s + 13] = y2; + clippedVerticesItems[s + 14] = light.r; + clippedVerticesItems[s + 15] = light.g; + clippedVerticesItems[s + 16] = light.b; + clippedVerticesItems[s + 17] = light.a; + clippedVerticesItems[s + 18] = u2; + clippedVerticesItems[s + 19] = v2; + clippedVerticesItems[s + 20] = dark.r; + clippedVerticesItems[s + 21] = dark.g; + clippedVerticesItems[s + 22] = dark.b; + clippedVerticesItems[s + 23] = dark.a; + clippedVerticesItems[s + 24] = x3; + clippedVerticesItems[s + 25] = y3; + clippedVerticesItems[s + 26] = light.r; + clippedVerticesItems[s + 27] = light.g; + clippedVerticesItems[s + 28] = light.b; + clippedVerticesItems[s + 29] = light.a; + clippedVerticesItems[s + 30] = u3; + clippedVerticesItems[s + 31] = v3; + clippedVerticesItems[s + 32] = dark.r; + clippedVerticesItems[s + 33] = dark.g; + clippedVerticesItems[s + 34] = dark.b; + clippedVerticesItems[s + 35] = dark.a; + } + s = clippedTriangles.length; + var clippedTrianglesItems = spine.Utils.setArraySize(clippedTriangles, s + 3); + clippedTrianglesItems[s] = index; + clippedTrianglesItems[s + 1] = (index + 1); + clippedTrianglesItems[s + 2] = (index + 2); + index += 3; + continue outer; + } + } + } + }; + SkeletonClipping.prototype.clip = function (x1, y1, x2, y2, x3, y3, clippingArea, output) { + var originalOutput = output; + var clipped = false; + var input = null; + if (clippingArea.length % 4 >= 2) { + input = output; + output = this.scratch; + } + else + input = this.scratch; + input.length = 0; + input.push(x1); + input.push(y1); + input.push(x2); + input.push(y2); + input.push(x3); + input.push(y3); + input.push(x1); + input.push(y1); + output.length = 0; + var clippingVertices = clippingArea; + var clippingVerticesLast = clippingArea.length - 4; + for (var i = 0;; i += 2) { + var edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1]; + var edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3]; + var deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2; + var inputVertices = input; + var inputVerticesLength = input.length - 2, outputStart = output.length; + for (var ii = 0; ii < inputVerticesLength; ii += 2) { + var inputX = inputVertices[ii], inputY = inputVertices[ii + 1]; + var inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3]; + var side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0; + if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) { + if (side2) { + output.push(inputX2); + output.push(inputY2); + continue; + } + var c0 = inputY2 - inputY, c2 = inputX2 - inputX; + var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + } + else if (side2) { + var c0 = inputY2 - inputY, c2 = inputX2 - inputX; + var ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY)); + output.push(edgeX + (edgeX2 - edgeX) * ua); + output.push(edgeY + (edgeY2 - edgeY) * ua); + output.push(inputX2); + output.push(inputY2); + } + clipped = true; + } + if (outputStart == output.length) { + originalOutput.length = 0; + return true; + } + output.push(output[0]); + output.push(output[1]); + if (i == clippingVerticesLast) + break; + var temp = output; + output = input; + output.length = 0; + input = temp; + } + if (originalOutput != output) { + originalOutput.length = 0; + for (var i = 0, n = output.length - 2; i < n; i++) + originalOutput[i] = output[i]; + } + else + originalOutput.length = originalOutput.length - 2; + return clipped; + }; + SkeletonClipping.makeClockwise = function (polygon) { + var vertices = polygon; + var verticeslength = polygon.length; + var area = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1], p1x = 0, p1y = 0, p2x = 0, p2y = 0; + for (var i = 0, n = verticeslength - 3; i < n; i += 2) { + p1x = vertices[i]; + p1y = vertices[i + 1]; + p2x = vertices[i + 2]; + p2y = vertices[i + 3]; + area += p1x * p2y - p2x * p1y; + } + if (area < 0) + return; + for (var i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) { + var x = vertices[i], y = vertices[i + 1]; + var other = lastX - i; + vertices[i] = vertices[other]; + vertices[i + 1] = vertices[other + 1]; + vertices[other] = x; + vertices[other + 1] = y; + } + }; + return SkeletonClipping; + }()); + spine.SkeletonClipping = SkeletonClipping; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonData = (function () { + function SkeletonData() { + this.bones = new Array(); + this.slots = new Array(); + this.skins = new Array(); + this.events = new Array(); + this.animations = new Array(); + this.ikConstraints = new Array(); + this.transformConstraints = new Array(); + this.pathConstraints = new Array(); + this.fps = 0; + } + SkeletonData.prototype.findBone = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (bone.name == boneName) + return bone; + } + return null; + }; + SkeletonData.prototype.findBoneIndex = function (boneName) { + if (boneName == null) + throw new Error("boneName cannot be null."); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) + if (bones[i].name == boneName) + return i; + return -1; + }; + SkeletonData.prototype.findSlot = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + if (slot.name == slotName) + return slot; + } + return null; + }; + SkeletonData.prototype.findSlotIndex = function (slotName) { + if (slotName == null) + throw new Error("slotName cannot be null."); + var slots = this.slots; + for (var i = 0, n = slots.length; i < n; i++) + if (slots[i].name == slotName) + return i; + return -1; + }; + SkeletonData.prototype.findSkin = function (skinName) { + if (skinName == null) + throw new Error("skinName cannot be null."); + var skins = this.skins; + for (var i = 0, n = skins.length; i < n; i++) { + var skin = skins[i]; + if (skin.name == skinName) + return skin; + } + return null; + }; + SkeletonData.prototype.findEvent = function (eventDataName) { + if (eventDataName == null) + throw new Error("eventDataName cannot be null."); + var events = this.events; + for (var i = 0, n = events.length; i < n; i++) { + var event_4 = events[i]; + if (event_4.name == eventDataName) + return event_4; + } + return null; + }; + SkeletonData.prototype.findAnimation = function (animationName) { + if (animationName == null) + throw new Error("animationName cannot be null."); + var animations = this.animations; + for (var i = 0, n = animations.length; i < n; i++) { + var animation = animations[i]; + if (animation.name == animationName) + return animation; + } + return null; + }; + SkeletonData.prototype.findIkConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var ikConstraints = this.ikConstraints; + for (var i = 0, n = ikConstraints.length; i < n; i++) { + var constraint = ikConstraints[i]; + if (constraint.name == constraintName) + return constraint; + } + return null; + }; + SkeletonData.prototype.findTransformConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var transformConstraints = this.transformConstraints; + for (var i = 0, n = transformConstraints.length; i < n; i++) { + var constraint = transformConstraints[i]; + if (constraint.name == constraintName) + return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraint = function (constraintName) { + if (constraintName == null) + throw new Error("constraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) { + var constraint = pathConstraints[i]; + if (constraint.name == constraintName) + return constraint; + } + return null; + }; + SkeletonData.prototype.findPathConstraintIndex = function (pathConstraintName) { + if (pathConstraintName == null) + throw new Error("pathConstraintName cannot be null."); + var pathConstraints = this.pathConstraints; + for (var i = 0, n = pathConstraints.length; i < n; i++) + if (pathConstraints[i].name == pathConstraintName) + return i; + return -1; + }; + return SkeletonData; + }()); + spine.SkeletonData = SkeletonData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SkeletonJson = (function () { + function SkeletonJson(attachmentLoader) { + this.scale = 1; + this.linkedMeshes = new Array(); + this.attachmentLoader = attachmentLoader; + } + SkeletonJson.prototype.readSkeletonData = function (json) { + var scale = this.scale; + var skeletonData = new spine.SkeletonData(); + var root = typeof (json) === "string" ? JSON.parse(json) : json; + var skeletonMap = root.skeleton; + if (skeletonMap != null) { + skeletonData.hash = skeletonMap.hash; + skeletonData.version = skeletonMap.spine; + skeletonData.width = skeletonMap.width; + skeletonData.height = skeletonMap.height; + skeletonData.fps = skeletonMap.fps; + skeletonData.imagesPath = skeletonMap.images; + } + if (root.bones) { + for (var i = 0; i < root.bones.length; i++) { + var boneMap = root.bones[i]; + var parent_2 = null; + var parentName = this.getValue(boneMap, "parent", null); + if (parentName != null) { + parent_2 = skeletonData.findBone(parentName); + if (parent_2 == null) + throw new Error("Parent bone not found: " + parentName); + } + var data = new spine.BoneData(skeletonData.bones.length, boneMap.name, parent_2); + data.length = this.getValue(boneMap, "length", 0) * scale; + data.x = this.getValue(boneMap, "x", 0) * scale; + data.y = this.getValue(boneMap, "y", 0) * scale; + data.rotation = this.getValue(boneMap, "rotation", 0); + data.scaleX = this.getValue(boneMap, "scaleX", 1); + data.scaleY = this.getValue(boneMap, "scaleY", 1); + data.shearX = this.getValue(boneMap, "shearX", 0); + data.shearY = this.getValue(boneMap, "shearY", 0); + data.transformMode = SkeletonJson.transformModeFromString(this.getValue(boneMap, "transform", "normal")); + skeletonData.bones.push(data); + } + } + if (root.slots) { + for (var i = 0; i < root.slots.length; i++) { + var slotMap = root.slots[i]; + var slotName = slotMap.name; + var boneName = slotMap.bone; + var boneData = skeletonData.findBone(boneName); + if (boneData == null) + throw new Error("Slot bone not found: " + boneName); + var data = new spine.SlotData(skeletonData.slots.length, slotName, boneData); + var color = this.getValue(slotMap, "color", null); + if (color != null) + data.color.setFromString(color); + var dark = this.getValue(slotMap, "dark", null); + if (dark != null) { + data.darkColor = new spine.Color(1, 1, 1, 1); + data.darkColor.setFromString(dark); + } + data.attachmentName = this.getValue(slotMap, "attachment", null); + data.blendMode = SkeletonJson.blendModeFromString(this.getValue(slotMap, "blend", "normal")); + skeletonData.slots.push(data); + } + } + if (root.ik) { + for (var i = 0; i < root.ik.length; i++) { + var constraintMap = root.ik[i]; + var data = new spine.IkConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) + throw new Error("IK bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) + throw new Error("IK target bone not found: " + targetName); + data.bendDirection = this.getValue(constraintMap, "bendPositive", true) ? 1 : -1; + data.mix = this.getValue(constraintMap, "mix", 1); + skeletonData.ikConstraints.push(data); + } + } + if (root.transform) { + for (var i = 0; i < root.transform.length; i++) { + var constraintMap = root.transform[i]; + var data = new spine.TransformConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) + throw new Error("Transform constraint bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findBone(targetName); + if (data.target == null) + throw new Error("Transform constraint target bone not found: " + targetName); + data.local = this.getValue(constraintMap, "local", false); + data.relative = this.getValue(constraintMap, "relative", false); + data.offsetRotation = this.getValue(constraintMap, "rotation", 0); + data.offsetX = this.getValue(constraintMap, "x", 0) * scale; + data.offsetY = this.getValue(constraintMap, "y", 0) * scale; + data.offsetScaleX = this.getValue(constraintMap, "scaleX", 0); + data.offsetScaleY = this.getValue(constraintMap, "scaleY", 0); + data.offsetShearY = this.getValue(constraintMap, "shearY", 0); + data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); + data.translateMix = this.getValue(constraintMap, "translateMix", 1); + data.scaleMix = this.getValue(constraintMap, "scaleMix", 1); + data.shearMix = this.getValue(constraintMap, "shearMix", 1); + skeletonData.transformConstraints.push(data); + } + } + if (root.path) { + for (var i = 0; i < root.path.length; i++) { + var constraintMap = root.path[i]; + var data = new spine.PathConstraintData(constraintMap.name); + data.order = this.getValue(constraintMap, "order", 0); + for (var j = 0; j < constraintMap.bones.length; j++) { + var boneName = constraintMap.bones[j]; + var bone = skeletonData.findBone(boneName); + if (bone == null) + throw new Error("Transform constraint bone not found: " + boneName); + data.bones.push(bone); + } + var targetName = constraintMap.target; + data.target = skeletonData.findSlot(targetName); + if (data.target == null) + throw new Error("Path target slot not found: " + targetName); + data.positionMode = SkeletonJson.positionModeFromString(this.getValue(constraintMap, "positionMode", "percent")); + data.spacingMode = SkeletonJson.spacingModeFromString(this.getValue(constraintMap, "spacingMode", "length")); + data.rotateMode = SkeletonJson.rotateModeFromString(this.getValue(constraintMap, "rotateMode", "tangent")); + data.offsetRotation = this.getValue(constraintMap, "rotation", 0); + data.position = this.getValue(constraintMap, "position", 0); + if (data.positionMode == spine.PositionMode.Fixed) + data.position *= scale; + data.spacing = this.getValue(constraintMap, "spacing", 0); + if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed) + data.spacing *= scale; + data.rotateMix = this.getValue(constraintMap, "rotateMix", 1); + data.translateMix = this.getValue(constraintMap, "translateMix", 1); + skeletonData.pathConstraints.push(data); + } + } + if (root.skins) { + for (var skinName in root.skins) { + var skinMap = root.skins[skinName]; + var skin = new spine.Skin(skinName); + for (var slotName in skinMap) { + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) + throw new Error("Slot not found: " + slotName); + var slotMap = skinMap[slotName]; + for (var entryName in slotMap) { + var attachment = this.readAttachment(slotMap[entryName], skin, slotIndex, entryName, skeletonData); + if (attachment != null) + skin.addAttachment(slotIndex, entryName, attachment); + } + } + skeletonData.skins.push(skin); + if (skin.name == "default") + skeletonData.defaultSkin = skin; + } + } + for (var i = 0, n = this.linkedMeshes.length; i < n; i++) { + var linkedMesh = this.linkedMeshes[i]; + var skin = linkedMesh.skin == null ? skeletonData.defaultSkin : skeletonData.findSkin(linkedMesh.skin); + if (skin == null) + throw new Error("Skin not found: " + linkedMesh.skin); + var parent_3 = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); + if (parent_3 == null) + throw new Error("Parent mesh not found: " + linkedMesh.parent); + linkedMesh.mesh.setParentMesh(parent_3); + linkedMesh.mesh.updateUVs(); + } + this.linkedMeshes.length = 0; + if (root.events) { + for (var eventName in root.events) { + var eventMap = root.events[eventName]; + var data = new spine.EventData(eventName); + data.intValue = this.getValue(eventMap, "int", 0); + data.floatValue = this.getValue(eventMap, "float", 0); + data.stringValue = this.getValue(eventMap, "string", ""); + skeletonData.events.push(data); + } + } + if (root.animations) { + for (var animationName in root.animations) { + var animationMap = root.animations[animationName]; + this.readAnimation(animationMap, animationName, skeletonData); + } + } + return skeletonData; + }; + SkeletonJson.prototype.readAttachment = function (map, skin, slotIndex, name, skeletonData) { + var scale = this.scale; + name = this.getValue(map, "name", name); + var type = this.getValue(map, "type", "region"); + switch (type) { + case "region": { + var path = this.getValue(map, "path", name); + var region = this.attachmentLoader.newRegionAttachment(skin, name, path); + if (region == null) + return null; + region.path = path; + region.x = this.getValue(map, "x", 0) * scale; + region.y = this.getValue(map, "y", 0) * scale; + region.scaleX = this.getValue(map, "scaleX", 1); + region.scaleY = this.getValue(map, "scaleY", 1); + region.rotation = this.getValue(map, "rotation", 0); + region.width = map.width * scale; + region.height = map.height * scale; + var color = this.getValue(map, "color", null); + if (color != null) + region.color.setFromString(color); + region.updateOffset(); + return region; + } + case "boundingbox": { + var box = this.attachmentLoader.newBoundingBoxAttachment(skin, name); + if (box == null) + return null; + this.readVertices(map, box, map.vertexCount << 1); + var color = this.getValue(map, "color", null); + if (color != null) + box.color.setFromString(color); + return box; + } + case "mesh": + case "linkedmesh": { + var path = this.getValue(map, "path", name); + var mesh = this.attachmentLoader.newMeshAttachment(skin, name, path); + if (mesh == null) + return null; + mesh.path = path; + var color = this.getValue(map, "color", null); + if (color != null) + mesh.color.setFromString(color); + var parent_4 = this.getValue(map, "parent", null); + if (parent_4 != null) { + mesh.inheritDeform = this.getValue(map, "deform", true); + this.linkedMeshes.push(new LinkedMesh(mesh, this.getValue(map, "skin", null), slotIndex, parent_4)); + return mesh; + } + var uvs = map.uvs; + this.readVertices(map, mesh, uvs.length); + mesh.triangles = map.triangles; + mesh.regionUVs = uvs; + mesh.updateUVs(); + mesh.hullLength = this.getValue(map, "hull", 0) * 2; + return mesh; + } + case "path": { + var path = this.attachmentLoader.newPathAttachment(skin, name); + if (path == null) + return null; + path.closed = this.getValue(map, "closed", false); + path.constantSpeed = this.getValue(map, "constantSpeed", true); + var vertexCount = map.vertexCount; + this.readVertices(map, path, vertexCount << 1); + var lengths = spine.Utils.newArray(vertexCount / 3, 0); + for (var i = 0; i < map.lengths.length; i++) + lengths[i] = map.lengths[i] * scale; + path.lengths = lengths; + var color = this.getValue(map, "color", null); + if (color != null) + path.color.setFromString(color); + return path; + } + case "point": { + var point = this.attachmentLoader.newPointAttachment(skin, name); + if (point == null) + return null; + point.x = this.getValue(map, "x", 0) * scale; + point.y = this.getValue(map, "y", 0) * scale; + point.rotation = this.getValue(map, "rotation", 0); + var color = this.getValue(map, "color", null); + if (color != null) + point.color.setFromString(color); + return point; + } + case "clipping": { + var clip = this.attachmentLoader.newClippingAttachment(skin, name); + if (clip == null) + return null; + var end = this.getValue(map, "end", null); + if (end != null) { + var slot = skeletonData.findSlot(end); + if (slot == null) + throw new Error("Clipping end slot not found: " + end); + clip.endSlot = slot; + } + var vertexCount = map.vertexCount; + this.readVertices(map, clip, vertexCount << 1); + var color = this.getValue(map, "color", null); + if (color != null) + clip.color.setFromString(color); + return clip; + } + } + return null; + }; + SkeletonJson.prototype.readVertices = function (map, attachment, verticesLength) { + var scale = this.scale; + attachment.worldVerticesLength = verticesLength; + var vertices = map.vertices; + if (verticesLength == vertices.length) { + var scaledVertices = spine.Utils.toFloatArray(vertices); + if (scale != 1) { + for (var i = 0, n = vertices.length; i < n; i++) + scaledVertices[i] *= scale; + } + attachment.vertices = scaledVertices; + return; + } + var weights = new Array(); + var bones = new Array(); + for (var i = 0, n = vertices.length; i < n;) { + var boneCount = vertices[i++]; + bones.push(boneCount); + for (var nn = i + boneCount * 4; i < nn; i += 4) { + bones.push(vertices[i]); + weights.push(vertices[i + 1] * scale); + weights.push(vertices[i + 2] * scale); + weights.push(vertices[i + 3]); + } + } + attachment.bones = bones; + attachment.vertices = spine.Utils.toFloatArray(weights); + }; + SkeletonJson.prototype.readAnimation = function (map, name, skeletonData) { + var scale = this.scale; + var timelines = new Array(); + var duration = 0; + if (map.slots) { + for (var slotName in map.slots) { + var slotMap = map.slots[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) + throw new Error("Slot not found: " + slotName); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + if (timelineName == "attachment") { + var timeline = new spine.AttachmentTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex++, valueMap.time, valueMap.name); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + else if (timelineName == "color") { + var timeline = new spine.ColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var color = new spine.Color(); + color.setFromString(valueMap.color); + timeline.setFrame(frameIndex, valueMap.time, color.r, color.g, color.b, color.a); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.ColorTimeline.ENTRIES]); + } + else if (timelineName == "twoColor") { + var timeline = new spine.TwoColorTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var light = new spine.Color(); + var dark = new spine.Color(); + light.setFromString(valueMap.light); + dark.setFromString(valueMap.dark); + timeline.setFrame(frameIndex, valueMap.time, light.r, light.g, light.b, light.a, dark.r, dark.g, dark.b); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TwoColorTimeline.ENTRIES]); + } + else + throw new Error("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")"); + } + } + } + if (map.bones) { + for (var boneName in map.bones) { + var boneMap = map.bones[boneName]; + var boneIndex = skeletonData.findBoneIndex(boneName); + if (boneIndex == -1) + throw new Error("Bone not found: " + boneName); + for (var timelineName in boneMap) { + var timelineMap = boneMap[timelineName]; + if (timelineName === "rotate") { + var timeline = new spine.RotateTimeline(timelineMap.length); + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, valueMap.angle); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.RotateTimeline.ENTRIES]); + } + else if (timelineName === "translate" || timelineName === "scale" || timelineName === "shear") { + var timeline = null; + var timelineScale = 1; + if (timelineName === "scale") + timeline = new spine.ScaleTimeline(timelineMap.length); + else if (timelineName === "shear") + timeline = new spine.ShearTimeline(timelineMap.length); + else { + timeline = new spine.TranslateTimeline(timelineMap.length); + timelineScale = scale; + } + timeline.boneIndex = boneIndex; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + var x = this.getValue(valueMap, "x", 0), y = this.getValue(valueMap, "y", 0); + timeline.setFrame(frameIndex, valueMap.time, x * timelineScale, y * timelineScale); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TranslateTimeline.ENTRIES]); + } + else + throw new Error("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")"); + } + } + } + if (map.ik) { + for (var constraintName in map.ik) { + var constraintMap = map.ik[constraintName]; + var constraint = skeletonData.findIkConstraint(constraintName); + var timeline = new spine.IkConstraintTimeline(constraintMap.length); + timeline.ikConstraintIndex = skeletonData.ikConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "mix", 1), this.getValue(valueMap, "bendPositive", true) ? 1 : -1); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.IkConstraintTimeline.ENTRIES]); + } + } + if (map.transform) { + for (var constraintName in map.transform) { + var constraintMap = map.transform[constraintName]; + var constraint = skeletonData.findTransformConstraint(constraintName); + var timeline = new spine.TransformConstraintTimeline(constraintMap.length); + timeline.transformConstraintIndex = skeletonData.transformConstraints.indexOf(constraint); + var frameIndex = 0; + for (var i = 0; i < constraintMap.length; i++) { + var valueMap = constraintMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1), this.getValue(valueMap, "scaleMix", 1), this.getValue(valueMap, "shearMix", 1)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.TransformConstraintTimeline.ENTRIES]); + } + } + if (map.paths) { + for (var constraintName in map.paths) { + var constraintMap = map.paths[constraintName]; + var index = skeletonData.findPathConstraintIndex(constraintName); + if (index == -1) + throw new Error("Path constraint not found: " + constraintName); + var data = skeletonData.pathConstraints[index]; + for (var timelineName in constraintMap) { + var timelineMap = constraintMap[timelineName]; + if (timelineName === "position" || timelineName === "spacing") { + var timeline = null; + var timelineScale = 1; + if (timelineName === "spacing") { + timeline = new spine.PathConstraintSpacingTimeline(timelineMap.length); + if (data.spacingMode == spine.SpacingMode.Length || data.spacingMode == spine.SpacingMode.Fixed) + timelineScale = scale; + } + else { + timeline = new spine.PathConstraintPositionTimeline(timelineMap.length); + if (data.positionMode == spine.PositionMode.Fixed) + timelineScale = scale; + } + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, timelineName, 0) * timelineScale); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintPositionTimeline.ENTRIES]); + } + else if (timelineName === "mix") { + var timeline = new spine.PathConstraintMixTimeline(timelineMap.length); + timeline.pathConstraintIndex = index; + var frameIndex = 0; + for (var i = 0; i < timelineMap.length; i++) { + var valueMap = timelineMap[i]; + timeline.setFrame(frameIndex, valueMap.time, this.getValue(valueMap, "rotateMix", 1), this.getValue(valueMap, "translateMix", 1)); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[(timeline.getFrameCount() - 1) * spine.PathConstraintMixTimeline.ENTRIES]); + } + } + } + } + if (map.deform) { + for (var deformName in map.deform) { + var deformMap = map.deform[deformName]; + var skin = skeletonData.findSkin(deformName); + if (skin == null) + throw new Error("Skin not found: " + deformName); + for (var slotName in deformMap) { + var slotMap = deformMap[slotName]; + var slotIndex = skeletonData.findSlotIndex(slotName); + if (slotIndex == -1) + throw new Error("Slot not found: " + slotMap.name); + for (var timelineName in slotMap) { + var timelineMap = slotMap[timelineName]; + var attachment = skin.getAttachment(slotIndex, timelineName); + if (attachment == null) + throw new Error("Deform attachment not found: " + timelineMap.name); + var weighted = attachment.bones != null; + var vertices = attachment.vertices; + var deformLength = weighted ? vertices.length / 3 * 2 : vertices.length; + var timeline = new spine.DeformTimeline(timelineMap.length); + timeline.slotIndex = slotIndex; + timeline.attachment = attachment; + var frameIndex = 0; + for (var j = 0; j < timelineMap.length; j++) { + var valueMap = timelineMap[j]; + var deform = void 0; + var verticesValue = this.getValue(valueMap, "vertices", null); + if (verticesValue == null) + deform = weighted ? spine.Utils.newFloatArray(deformLength) : vertices; + else { + deform = spine.Utils.newFloatArray(deformLength); + var start = this.getValue(valueMap, "offset", 0); + spine.Utils.arrayCopy(verticesValue, 0, deform, start, verticesValue.length); + if (scale != 1) { + for (var i = start, n = i + verticesValue.length; i < n; i++) + deform[i] *= scale; + } + if (!weighted) { + for (var i = 0; i < deformLength; i++) + deform[i] += vertices[i]; + } + } + timeline.setFrame(frameIndex, valueMap.time, deform); + this.readCurve(valueMap, timeline, frameIndex); + frameIndex++; + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + } + } + } + var drawOrderNode = map.drawOrder; + if (drawOrderNode == null) + drawOrderNode = map.draworder; + if (drawOrderNode != null) { + var timeline = new spine.DrawOrderTimeline(drawOrderNode.length); + var slotCount = skeletonData.slots.length; + var frameIndex = 0; + for (var j = 0; j < drawOrderNode.length; j++) { + var drawOrderMap = drawOrderNode[j]; + var drawOrder = null; + var offsets = this.getValue(drawOrderMap, "offsets", null); + if (offsets != null) { + drawOrder = spine.Utils.newArray(slotCount, -1); + var unchanged = spine.Utils.newArray(slotCount - offsets.length, 0); + var originalIndex = 0, unchangedIndex = 0; + for (var i = 0; i < offsets.length; i++) { + var offsetMap = offsets[i]; + var slotIndex = skeletonData.findSlotIndex(offsetMap.slot); + if (slotIndex == -1) + throw new Error("Slot not found: " + offsetMap.slot); + while (originalIndex != slotIndex) + unchanged[unchangedIndex++] = originalIndex++; + drawOrder[originalIndex + offsetMap.offset] = originalIndex++; + } + while (originalIndex < slotCount) + unchanged[unchangedIndex++] = originalIndex++; + for (var i = slotCount - 1; i >= 0; i--) + if (drawOrder[i] == -1) + drawOrder[i] = unchanged[--unchangedIndex]; + } + timeline.setFrame(frameIndex++, drawOrderMap.time, drawOrder); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (map.events) { + var timeline = new spine.EventTimeline(map.events.length); + var frameIndex = 0; + for (var i = 0; i < map.events.length; i++) { + var eventMap = map.events[i]; + var eventData = skeletonData.findEvent(eventMap.name); + if (eventData == null) + throw new Error("Event not found: " + eventMap.name); + var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData); + event_5.intValue = this.getValue(eventMap, "int", eventData.intValue); + event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue); + event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue); + timeline.setFrame(frameIndex++, event_5); + } + timelines.push(timeline); + duration = Math.max(duration, timeline.frames[timeline.getFrameCount() - 1]); + } + if (isNaN(duration)) { + throw new Error("Error while parsing animation, duration is NaN"); + } + skeletonData.animations.push(new spine.Animation(name, timelines, duration)); + }; + SkeletonJson.prototype.readCurve = function (map, timeline, frameIndex) { + if (!map.curve) + return; + if (map.curve === "stepped") + timeline.setStepped(frameIndex); + else if (Object.prototype.toString.call(map.curve) === '[object Array]') { + var curve = map.curve; + timeline.setCurve(frameIndex, curve[0], curve[1], curve[2], curve[3]); + } + }; + SkeletonJson.prototype.getValue = function (map, prop, defaultValue) { + return map[prop] !== undefined ? map[prop] : defaultValue; + }; + SkeletonJson.blendModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "normal") + return spine.BlendMode.Normal; + if (str == "additive") + return spine.BlendMode.Additive; + if (str == "multiply") + return spine.BlendMode.Multiply; + if (str == "screen") + return spine.BlendMode.Screen; + throw new Error("Unknown blend mode: " + str); + }; + SkeletonJson.positionModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "fixed") + return spine.PositionMode.Fixed; + if (str == "percent") + return spine.PositionMode.Percent; + throw new Error("Unknown position mode: " + str); + }; + SkeletonJson.spacingModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "length") + return spine.SpacingMode.Length; + if (str == "fixed") + return spine.SpacingMode.Fixed; + if (str == "percent") + return spine.SpacingMode.Percent; + throw new Error("Unknown position mode: " + str); + }; + SkeletonJson.rotateModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "tangent") + return spine.RotateMode.Tangent; + if (str == "chain") + return spine.RotateMode.Chain; + if (str == "chainscale") + return spine.RotateMode.ChainScale; + throw new Error("Unknown rotate mode: " + str); + }; + SkeletonJson.transformModeFromString = function (str) { + str = str.toLowerCase(); + if (str == "normal") + return spine.TransformMode.Normal; + if (str == "onlytranslation") + return spine.TransformMode.OnlyTranslation; + if (str == "norotationorreflection") + return spine.TransformMode.NoRotationOrReflection; + if (str == "noscale") + return spine.TransformMode.NoScale; + if (str == "noscaleorreflection") + return spine.TransformMode.NoScaleOrReflection; + throw new Error("Unknown transform mode: " + str); + }; + return SkeletonJson; + }()); + spine.SkeletonJson = SkeletonJson; + var LinkedMesh = (function () { + function LinkedMesh(mesh, skin, slotIndex, parent) { + this.mesh = mesh; + this.skin = skin; + this.slotIndex = slotIndex; + this.parent = parent; + } + return LinkedMesh; + }()); +})(spine || (spine = {})); +var spine; +(function (spine) { + var Skin = (function () { + function Skin(name) { + this.attachments = new Array(); + if (name == null) + throw new Error("name cannot be null."); + this.name = name; + } + Skin.prototype.addAttachment = function (slotIndex, name, attachment) { + if (attachment == null) + throw new Error("attachment cannot be null."); + var attachments = this.attachments; + if (slotIndex >= attachments.length) + attachments.length = slotIndex + 1; + if (!attachments[slotIndex]) + attachments[slotIndex] = {}; + attachments[slotIndex][name] = attachment; + }; + Skin.prototype.getAttachment = function (slotIndex, name) { + var dictionary = this.attachments[slotIndex]; + return dictionary ? dictionary[name] : null; + }; + Skin.prototype.attachAll = function (skeleton, oldSkin) { + var slotIndex = 0; + for (var i = 0; i < skeleton.slots.length; i++) { + var slot = skeleton.slots[i]; + var slotAttachment = slot.getAttachment(); + if (slotAttachment && slotIndex < oldSkin.attachments.length) { + var dictionary = oldSkin.attachments[slotIndex]; + for (var key in dictionary) { + var skinAttachment = dictionary[key]; + if (slotAttachment == skinAttachment) { + var attachment = this.getAttachment(slotIndex, key); + if (attachment != null) + slot.setAttachment(attachment); + break; + } + } + } + slotIndex++; + } + }; + return Skin; + }()); + spine.Skin = Skin; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Slot = (function () { + function Slot(data, bone) { + this.attachmentVertices = new Array(); + if (data == null) + throw new Error("data cannot be null."); + if (bone == null) + throw new Error("bone cannot be null."); + this.data = data; + this.bone = bone; + this.color = new spine.Color(); + this.darkColor = data.darkColor == null ? null : new spine.Color(); + this.setToSetupPose(); + } + Slot.prototype.getAttachment = function () { + return this.attachment; + }; + Slot.prototype.setAttachment = function (attachment) { + if (this.attachment == attachment) + return; + this.attachment = attachment; + this.attachmentTime = this.bone.skeleton.time; + this.attachmentVertices.length = 0; + }; + Slot.prototype.setAttachmentTime = function (time) { + this.attachmentTime = this.bone.skeleton.time - time; + }; + Slot.prototype.getAttachmentTime = function () { + return this.bone.skeleton.time - this.attachmentTime; + }; + Slot.prototype.setToSetupPose = function () { + this.color.setFromColor(this.data.color); + if (this.darkColor != null) + this.darkColor.setFromColor(this.data.darkColor); + if (this.data.attachmentName == null) + this.attachment = null; + else { + this.attachment = null; + this.setAttachment(this.bone.skeleton.getAttachment(this.data.index, this.data.attachmentName)); + } + }; + return Slot; + }()); + spine.Slot = Slot; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SlotData = (function () { + function SlotData(index, name, boneData) { + this.color = new spine.Color(1, 1, 1, 1); + if (index < 0) + throw new Error("index must be >= 0."); + if (name == null) + throw new Error("name cannot be null."); + if (boneData == null) + throw new Error("boneData cannot be null."); + this.index = index; + this.name = name; + this.boneData = boneData; + } + return SlotData; + }()); + spine.SlotData = SlotData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Texture = (function () { + function Texture(image) { + this._image = image; + } + Texture.prototype.getImage = function () { + return this._image; + }; + Texture.filterFromString = function (text) { + switch (text.toLowerCase()) { + case "nearest": return TextureFilter.Nearest; + case "linear": return TextureFilter.Linear; + case "mipmap": return TextureFilter.MipMap; + case "mipmapnearestnearest": return TextureFilter.MipMapNearestNearest; + case "mipmaplinearnearest": return TextureFilter.MipMapLinearNearest; + case "mipmapnearestlinear": return TextureFilter.MipMapNearestLinear; + case "mipmaplinearlinear": return TextureFilter.MipMapLinearLinear; + default: throw new Error("Unknown texture filter " + text); + } + }; + Texture.wrapFromString = function (text) { + switch (text.toLowerCase()) { + case "mirroredtepeat": return TextureWrap.MirroredRepeat; + case "clamptoedge": return TextureWrap.ClampToEdge; + case "repeat": return TextureWrap.Repeat; + default: throw new Error("Unknown texture wrap " + text); + } + }; + return Texture; + }()); + spine.Texture = Texture; + var TextureFilter; + (function (TextureFilter) { + TextureFilter[TextureFilter["Nearest"] = 9728] = "Nearest"; + TextureFilter[TextureFilter["Linear"] = 9729] = "Linear"; + TextureFilter[TextureFilter["MipMap"] = 9987] = "MipMap"; + TextureFilter[TextureFilter["MipMapNearestNearest"] = 9984] = "MipMapNearestNearest"; + TextureFilter[TextureFilter["MipMapLinearNearest"] = 9985] = "MipMapLinearNearest"; + TextureFilter[TextureFilter["MipMapNearestLinear"] = 9986] = "MipMapNearestLinear"; + TextureFilter[TextureFilter["MipMapLinearLinear"] = 9987] = "MipMapLinearLinear"; + })(TextureFilter = spine.TextureFilter || (spine.TextureFilter = {})); + var TextureWrap; + (function (TextureWrap) { + TextureWrap[TextureWrap["MirroredRepeat"] = 33648] = "MirroredRepeat"; + TextureWrap[TextureWrap["ClampToEdge"] = 33071] = "ClampToEdge"; + TextureWrap[TextureWrap["Repeat"] = 10497] = "Repeat"; + })(TextureWrap = spine.TextureWrap || (spine.TextureWrap = {})); + var TextureRegion = (function () { + function TextureRegion() { + this.u = 0; + this.v = 0; + this.u2 = 0; + this.v2 = 0; + this.width = 0; + this.height = 0; + this.rotate = false; + this.offsetX = 0; + this.offsetY = 0; + this.originalWidth = 0; + this.originalHeight = 0; + } + return TextureRegion; + }()); + spine.TextureRegion = TextureRegion; + var FakeTexture = (function (_super) { + __extends(FakeTexture, _super); + function FakeTexture() { + return _super !== null && _super.apply(this, arguments) || this; + } + FakeTexture.prototype.setFilters = function (minFilter, magFilter) { }; + FakeTexture.prototype.setWraps = function (uWrap, vWrap) { }; + FakeTexture.prototype.dispose = function () { }; + return FakeTexture; + }(spine.Texture)); + spine.FakeTexture = FakeTexture; +})(spine || (spine = {})); +var spine; +(function (spine) { + var TextureAtlas = (function () { + function TextureAtlas(atlasText, textureLoader) { + this.pages = new Array(); + this.regions = new Array(); + this.load(atlasText, textureLoader); + } + TextureAtlas.prototype.load = function (atlasText, textureLoader) { + if (textureLoader == null) + throw new Error("textureLoader cannot be null."); + var reader = new TextureAtlasReader(atlasText); + var tuple = new Array(4); + var page = null; + while (true) { + var line = reader.readLine(); + if (line == null) + break; + line = line.trim(); + if (line.length == 0) + page = null; + else if (!page) { + page = new TextureAtlasPage(); + page.name = line; + if (reader.readTuple(tuple) == 2) { + page.width = parseInt(tuple[0]); + page.height = parseInt(tuple[1]); + reader.readTuple(tuple); + } + reader.readTuple(tuple); + page.minFilter = spine.Texture.filterFromString(tuple[0]); + page.magFilter = spine.Texture.filterFromString(tuple[1]); + var direction = reader.readValue(); + page.uWrap = spine.TextureWrap.ClampToEdge; + page.vWrap = spine.TextureWrap.ClampToEdge; + if (direction == "x") + page.uWrap = spine.TextureWrap.Repeat; + else if (direction == "y") + page.vWrap = spine.TextureWrap.Repeat; + else if (direction == "xy") + page.uWrap = page.vWrap = spine.TextureWrap.Repeat; + page.texture = textureLoader(line); + page.texture.setFilters(page.minFilter, page.magFilter); + page.texture.setWraps(page.uWrap, page.vWrap); + page.width = page.texture.getImage().width; + page.height = page.texture.getImage().height; + this.pages.push(page); + } + else { + var region = new TextureAtlasRegion(); + region.name = line; + region.page = page; + region.rotate = reader.readValue() == "true"; + reader.readTuple(tuple); + var x = parseInt(tuple[0]); + var y = parseInt(tuple[1]); + reader.readTuple(tuple); + var width = parseInt(tuple[0]); + var height = parseInt(tuple[1]); + region.u = x / page.width; + region.v = y / page.height; + if (region.rotate) { + region.u2 = (x + height) / page.width; + region.v2 = (y + width) / page.height; + } + else { + region.u2 = (x + width) / page.width; + region.v2 = (y + height) / page.height; + } + region.x = x; + region.y = y; + region.width = Math.abs(width); + region.height = Math.abs(height); + if (reader.readTuple(tuple) == 4) { + if (reader.readTuple(tuple) == 4) { + reader.readTuple(tuple); + } + } + region.originalWidth = parseInt(tuple[0]); + region.originalHeight = parseInt(tuple[1]); + reader.readTuple(tuple); + region.offsetX = parseInt(tuple[0]); + region.offsetY = parseInt(tuple[1]); + region.index = parseInt(reader.readValue()); + region.texture = page.texture; + this.regions.push(region); + } + } + }; + TextureAtlas.prototype.findRegion = function (name) { + for (var i = 0; i < this.regions.length; i++) { + if (this.regions[i].name == name) { + return this.regions[i]; + } + } + return null; + }; + TextureAtlas.prototype.dispose = function () { + for (var i = 0; i < this.pages.length; i++) { + this.pages[i].texture.dispose(); + } + }; + return TextureAtlas; + }()); + spine.TextureAtlas = TextureAtlas; + var TextureAtlasReader = (function () { + function TextureAtlasReader(text) { + this.index = 0; + this.lines = text.split(/\r\n|\r|\n/); + } + TextureAtlasReader.prototype.readLine = function () { + if (this.index >= this.lines.length) + return null; + return this.lines[this.index++]; + }; + TextureAtlasReader.prototype.readValue = function () { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (colon == -1) + throw new Error("Invalid line: " + line); + return line.substring(colon + 1).trim(); + }; + TextureAtlasReader.prototype.readTuple = function (tuple) { + var line = this.readLine(); + var colon = line.indexOf(":"); + if (colon == -1) + throw new Error("Invalid line: " + line); + var i = 0, lastMatch = colon + 1; + for (; i < 3; i++) { + var comma = line.indexOf(",", lastMatch); + if (comma == -1) + break; + tuple[i] = line.substr(lastMatch, comma - lastMatch).trim(); + lastMatch = comma + 1; + } + tuple[i] = line.substring(lastMatch).trim(); + return i + 1; + }; + return TextureAtlasReader; + }()); + var TextureAtlasPage = (function () { + function TextureAtlasPage() { + } + return TextureAtlasPage; + }()); + spine.TextureAtlasPage = TextureAtlasPage; + var TextureAtlasRegion = (function (_super) { + __extends(TextureAtlasRegion, _super); + function TextureAtlasRegion() { + return _super !== null && _super.apply(this, arguments) || this; + } + return TextureAtlasRegion; + }(spine.TextureRegion)); + spine.TextureAtlasRegion = TextureAtlasRegion; +})(spine || (spine = {})); +var spine; +(function (spine) { + var TransformConstraint = (function () { + function TransformConstraint(data, skeleton) { + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.temp = new spine.Vector2(); + if (data == null) + throw new Error("data cannot be null."); + if (skeleton == null) + throw new Error("skeleton cannot be null."); + this.data = data; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + this.scaleMix = data.scaleMix; + this.shearMix = data.shearMix; + this.bones = new Array(); + for (var i = 0; i < data.bones.length; i++) + this.bones.push(skeleton.findBone(data.bones[i].name)); + this.target = skeleton.findBone(data.target.name); + } + TransformConstraint.prototype.apply = function () { + this.update(); + }; + TransformConstraint.prototype.update = function () { + if (this.data.local) { + if (this.data.relative) + this.applyRelativeLocal(); + else + this.applyAbsoluteLocal(); + } + else { + if (this.data.relative) + this.applyRelativeWorld(); + else + this.applyAbsoluteWorld(); + } + }; + TransformConstraint.prototype.applyAbsoluteWorld = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + var ta = target.a, tb = target.b, tc = target.c, td = target.d; + var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect; + var offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + if (rotateMix != 0) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var r = Math.atan2(tc, ta) - Math.atan2(c, a) + offsetRotation; + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + bone.worldX += (temp.x - bone.worldX) * translateMix; + bone.worldY += (temp.y - bone.worldY) * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = Math.sqrt(bone.a * bone.a + bone.c * bone.c); + var ts = Math.sqrt(ta * ta + tc * tc); + if (s > 0.00001) + s = (s + (ts - s + this.data.offsetScaleX) * scaleMix) / s; + bone.a *= s; + bone.c *= s; + s = Math.sqrt(bone.b * bone.b + bone.d * bone.d); + ts = Math.sqrt(tb * tb + td * td); + if (s > 0.00001) + s = (s + (ts - s + this.data.offsetScaleY) * scaleMix) / s; + bone.b *= s; + bone.d *= s; + modified = true; + } + if (shearMix > 0) { + var b = bone.b, d = bone.d; + var by = Math.atan2(d, b); + var r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(bone.c, bone.a)); + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r = by + (r + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + bone.b = Math.cos(r) * s; + bone.d = Math.sin(r) * s; + modified = true; + } + if (modified) + bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyRelativeWorld = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + var ta = target.a, tb = target.b, tc = target.c, td = target.d; + var degRadReflect = ta * td - tb * tc > 0 ? spine.MathUtils.degRad : -spine.MathUtils.degRad; + var offsetRotation = this.data.offsetRotation * degRadReflect, offsetShearY = this.data.offsetShearY * degRadReflect; + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + var modified = false; + if (rotateMix != 0) { + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var r = Math.atan2(tc, ta) + offsetRotation; + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + r *= rotateMix; + var cos = Math.cos(r), sin = Math.sin(r); + bone.a = cos * a - sin * c; + bone.b = cos * b - sin * d; + bone.c = sin * a + cos * c; + bone.d = sin * b + cos * d; + modified = true; + } + if (translateMix != 0) { + var temp = this.temp; + target.localToWorld(temp.set(this.data.offsetX, this.data.offsetY)); + bone.worldX += temp.x * translateMix; + bone.worldY += temp.y * translateMix; + modified = true; + } + if (scaleMix > 0) { + var s = (Math.sqrt(ta * ta + tc * tc) - 1 + this.data.offsetScaleX) * scaleMix + 1; + bone.a *= s; + bone.c *= s; + s = (Math.sqrt(tb * tb + td * td) - 1 + this.data.offsetScaleY) * scaleMix + 1; + bone.b *= s; + bone.d *= s; + modified = true; + } + if (shearMix > 0) { + var r = Math.atan2(td, tb) - Math.atan2(tc, ta); + if (r > spine.MathUtils.PI) + r -= spine.MathUtils.PI2; + else if (r < -spine.MathUtils.PI) + r += spine.MathUtils.PI2; + var b = bone.b, d = bone.d; + r = Math.atan2(d, b) + (r - spine.MathUtils.PI / 2 + offsetShearY) * shearMix; + var s = Math.sqrt(b * b + d * d); + bone.b = Math.cos(r) * s; + bone.d = Math.sin(r) * s; + modified = true; + } + if (modified) + bone.appliedValid = false; + } + }; + TransformConstraint.prototype.applyAbsoluteLocal = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) + target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) + bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) { + var r = target.arotation - rotation + this.data.offsetRotation; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + rotation += r * rotateMix; + } + var x = bone.ax, y = bone.ay; + if (translateMix != 0) { + x += (target.ax - x + this.data.offsetX) * translateMix; + y += (target.ay - y + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) + scaleX = (scaleX + (target.ascaleX - scaleX + this.data.offsetScaleX) * scaleMix) / scaleX; + if (scaleY > 0.00001) + scaleY = (scaleY + (target.ascaleY - scaleY + this.data.offsetScaleY) * scaleMix) / scaleY; + } + var shearY = bone.ashearY; + if (shearMix > 0) { + var r = target.ashearY - shearY + this.data.offsetShearY; + r -= (16384 - ((16384.499999999996 - r / 360) | 0)) * 360; + bone.shearY += r * shearMix; + } + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.applyRelativeLocal = function () { + var rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + var target = this.target; + if (!target.appliedValid) + target.updateAppliedTransform(); + var bones = this.bones; + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (!bone.appliedValid) + bone.updateAppliedTransform(); + var rotation = bone.arotation; + if (rotateMix != 0) + rotation += (target.arotation + this.data.offsetRotation) * rotateMix; + var x = bone.ax, y = bone.ay; + if (translateMix != 0) { + x += (target.ax + this.data.offsetX) * translateMix; + y += (target.ay + this.data.offsetY) * translateMix; + } + var scaleX = bone.ascaleX, scaleY = bone.ascaleY; + if (scaleMix > 0) { + if (scaleX > 0.00001) + scaleX *= ((target.ascaleX - 1 + this.data.offsetScaleX) * scaleMix) + 1; + if (scaleY > 0.00001) + scaleY *= ((target.ascaleY - 1 + this.data.offsetScaleY) * scaleMix) + 1; + } + var shearY = bone.ashearY; + if (shearMix > 0) + shearY += (target.ashearY + this.data.offsetShearY) * shearMix; + bone.updateWorldTransformWith(x, y, rotation, scaleX, scaleY, bone.ashearX, shearY); + } + }; + TransformConstraint.prototype.getOrder = function () { + return this.data.order; + }; + return TransformConstraint; + }()); + spine.TransformConstraint = TransformConstraint; +})(spine || (spine = {})); +var spine; +(function (spine) { + var TransformConstraintData = (function () { + function TransformConstraintData(name) { + this.order = 0; + this.bones = new Array(); + this.rotateMix = 0; + this.translateMix = 0; + this.scaleMix = 0; + this.shearMix = 0; + this.offsetRotation = 0; + this.offsetX = 0; + this.offsetY = 0; + this.offsetScaleX = 0; + this.offsetScaleY = 0; + this.offsetShearY = 0; + this.relative = false; + this.local = false; + if (name == null) + throw new Error("name cannot be null."); + this.name = name; + } + return TransformConstraintData; + }()); + spine.TransformConstraintData = TransformConstraintData; +})(spine || (spine = {})); +var spine; +(function (spine) { + var Triangulator = (function () { + function Triangulator() { + this.convexPolygons = new Array(); + this.convexPolygonsIndices = new Array(); + this.indicesArray = new Array(); + this.isConcaveArray = new Array(); + this.triangles = new Array(); + this.polygonPool = new spine.Pool(function () { + return new Array(); + }); + this.polygonIndicesPool = new spine.Pool(function () { + return new Array(); + }); + } + Triangulator.prototype.triangulate = function (verticesArray) { + var vertices = verticesArray; + var vertexCount = verticesArray.length >> 1; + var indices = this.indicesArray; + indices.length = 0; + for (var i = 0; i < vertexCount; i++) + indices[i] = i; + var isConcave = this.isConcaveArray; + isConcave.length = 0; + for (var i = 0, n = vertexCount; i < n; ++i) + isConcave[i] = Triangulator.isConcave(i, vertexCount, vertices, indices); + var triangles = this.triangles; + triangles.length = 0; + while (vertexCount > 3) { + var previous = vertexCount - 1, i = 0, next = 1; + while (true) { + outer: if (!isConcave[i]) { + var p1 = indices[previous] << 1, p2 = indices[i] << 1, p3 = indices[next] << 1; + var p1x = vertices[p1], p1y = vertices[p1 + 1]; + var p2x = vertices[p2], p2y = vertices[p2 + 1]; + var p3x = vertices[p3], p3y = vertices[p3 + 1]; + for (var ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) { + if (!isConcave[ii]) + continue; + var v = indices[ii] << 1; + var vx = vertices[v], vy = vertices[v + 1]; + if (Triangulator.positiveArea(p3x, p3y, p1x, p1y, vx, vy)) { + if (Triangulator.positiveArea(p1x, p1y, p2x, p2y, vx, vy)) { + if (Triangulator.positiveArea(p2x, p2y, p3x, p3y, vx, vy)) + break outer; + } + } + } + break; + } + if (next == 0) { + do { + if (!isConcave[i]) + break; + i--; + } while (i > 0); + break; + } + previous = i; + i = next; + next = (next + 1) % vertexCount; + } + triangles.push(indices[(vertexCount + i - 1) % vertexCount]); + triangles.push(indices[i]); + triangles.push(indices[(i + 1) % vertexCount]); + indices.splice(i, 1); + isConcave.splice(i, 1); + vertexCount--; + var previousIndex = (vertexCount + i - 1) % vertexCount; + var nextIndex = i == vertexCount ? 0 : i; + isConcave[previousIndex] = Triangulator.isConcave(previousIndex, vertexCount, vertices, indices); + isConcave[nextIndex] = Triangulator.isConcave(nextIndex, vertexCount, vertices, indices); + } + if (vertexCount == 3) { + triangles.push(indices[2]); + triangles.push(indices[0]); + triangles.push(indices[1]); + } + return triangles; + }; + Triangulator.prototype.decompose = function (verticesArray, triangles) { + var vertices = verticesArray; + var convexPolygons = this.convexPolygons; + this.polygonPool.freeAll(convexPolygons); + convexPolygons.length = 0; + var convexPolygonsIndices = this.convexPolygonsIndices; + this.polygonIndicesPool.freeAll(convexPolygonsIndices); + convexPolygonsIndices.length = 0; + var polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + var polygon = this.polygonPool.obtain(); + polygon.length = 0; + var fanBaseIndex = -1, lastWinding = 0; + for (var i = 0, n = triangles.length; i < n; i += 3) { + var t1 = triangles[i] << 1, t2 = triangles[i + 1] << 1, t3 = triangles[i + 2] << 1; + var x1 = vertices[t1], y1 = vertices[t1 + 1]; + var x2 = vertices[t2], y2 = vertices[t2 + 1]; + var x3 = vertices[t3], y3 = vertices[t3 + 1]; + var merged = false; + if (fanBaseIndex == t1) { + var o = polygon.length - 4; + var winding1 = Triangulator.winding(polygon[o], polygon[o + 1], polygon[o + 2], polygon[o + 3], x3, y3); + var winding2 = Triangulator.winding(x3, y3, polygon[0], polygon[1], polygon[2], polygon[3]); + if (winding1 == lastWinding && winding2 == lastWinding) { + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(t3); + merged = true; + } + } + if (!merged) { + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } + else { + this.polygonPool.free(polygon); + this.polygonIndicesPool.free(polygonIndices); + } + polygon = this.polygonPool.obtain(); + polygon.length = 0; + polygon.push(x1); + polygon.push(y1); + polygon.push(x2); + polygon.push(y2); + polygon.push(x3); + polygon.push(y3); + polygonIndices = this.polygonIndicesPool.obtain(); + polygonIndices.length = 0; + polygonIndices.push(t1); + polygonIndices.push(t2); + polygonIndices.push(t3); + lastWinding = Triangulator.winding(x1, y1, x2, y2, x3, y3); + fanBaseIndex = t1; + } + } + if (polygon.length > 0) { + convexPolygons.push(polygon); + convexPolygonsIndices.push(polygonIndices); + } + for (var i = 0, n = convexPolygons.length; i < n; i++) { + polygonIndices = convexPolygonsIndices[i]; + if (polygonIndices.length == 0) + continue; + var firstIndex = polygonIndices[0]; + var lastIndex = polygonIndices[polygonIndices.length - 1]; + polygon = convexPolygons[i]; + var o = polygon.length - 4; + var prevPrevX = polygon[o], prevPrevY = polygon[o + 1]; + var prevX = polygon[o + 2], prevY = polygon[o + 3]; + var firstX = polygon[0], firstY = polygon[1]; + var secondX = polygon[2], secondY = polygon[3]; + var winding = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY); + for (var ii = 0; ii < n; ii++) { + if (ii == i) + continue; + var otherIndices = convexPolygonsIndices[ii]; + if (otherIndices.length != 3) + continue; + var otherFirstIndex = otherIndices[0]; + var otherSecondIndex = otherIndices[1]; + var otherLastIndex = otherIndices[2]; + var otherPoly = convexPolygons[ii]; + var x3 = otherPoly[otherPoly.length - 2], y3 = otherPoly[otherPoly.length - 1]; + if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) + continue; + var winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3); + var winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY); + if (winding1 == winding && winding2 == winding) { + otherPoly.length = 0; + otherIndices.length = 0; + polygon.push(x3); + polygon.push(y3); + polygonIndices.push(otherLastIndex); + prevPrevX = prevX; + prevPrevY = prevY; + prevX = x3; + prevY = y3; + ii = 0; + } + } + } + for (var i = convexPolygons.length - 1; i >= 0; i--) { + polygon = convexPolygons[i]; + if (polygon.length == 0) { + convexPolygons.splice(i, 1); + this.polygonPool.free(polygon); + polygonIndices = convexPolygonsIndices[i]; + convexPolygonsIndices.splice(i, 1); + this.polygonIndicesPool.free(polygonIndices); + } + } + return convexPolygons; + }; + Triangulator.isConcave = function (index, vertexCount, vertices, indices) { + var previous = indices[(vertexCount + index - 1) % vertexCount] << 1; + var current = indices[index] << 1; + var next = indices[(index + 1) % vertexCount] << 1; + return !this.positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1], vertices[next], vertices[next + 1]); + }; + Triangulator.positiveArea = function (p1x, p1y, p2x, p2y, p3x, p3y) { + return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; + }; + Triangulator.winding = function (p1x, p1y, p2x, p2y, p3x, p3y) { + var px = p2x - p1x, py = p2y - p1y; + return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; + }; + return Triangulator; + }()); + spine.Triangulator = Triangulator; +})(spine || (spine = {})); +var spine; +(function (spine) { + var IntSet = (function () { + function IntSet() { + this.array = new Array(); + } + IntSet.prototype.add = function (value) { + var contains = this.contains(value); + this.array[value | 0] = value | 0; + return !contains; + }; + IntSet.prototype.contains = function (value) { + return this.array[value | 0] != undefined; + }; + IntSet.prototype.remove = function (value) { + this.array[value | 0] = undefined; + }; + IntSet.prototype.clear = function () { + this.array.length = 0; + }; + return IntSet; + }()); + spine.IntSet = IntSet; + var Color = (function () { + function Color(r, g, b, a) { + if (r === void 0) { r = 0; } + if (g === void 0) { g = 0; } + if (b === void 0) { b = 0; } + if (a === void 0) { a = 0; } + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + Color.prototype.set = function (r, g, b, a) { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + this.clamp(); + return this; + }; + Color.prototype.setFromColor = function (c) { + this.r = c.r; + this.g = c.g; + this.b = c.b; + this.a = c.a; + return this; + }; + Color.prototype.setFromString = function (hex) { + hex = hex.charAt(0) == '#' ? hex.substr(1) : hex; + this.r = parseInt(hex.substr(0, 2), 16) / 255.0; + this.g = parseInt(hex.substr(2, 2), 16) / 255.0; + this.b = parseInt(hex.substr(4, 2), 16) / 255.0; + this.a = (hex.length != 8 ? 255 : parseInt(hex.substr(6, 2), 16)) / 255.0; + return this; + }; + Color.prototype.add = function (r, g, b, a) { + this.r += r; + this.g += g; + this.b += b; + this.a += a; + this.clamp(); + return this; + }; + Color.prototype.clamp = function () { + if (this.r < 0) + this.r = 0; + else if (this.r > 1) + this.r = 1; + if (this.g < 0) + this.g = 0; + else if (this.g > 1) + this.g = 1; + if (this.b < 0) + this.b = 0; + else if (this.b > 1) + this.b = 1; + if (this.a < 0) + this.a = 0; + else if (this.a > 1) + this.a = 1; + return this; + }; + Color.WHITE = new Color(1, 1, 1, 1); + Color.RED = new Color(1, 0, 0, 1); + Color.GREEN = new Color(0, 1, 0, 1); + Color.BLUE = new Color(0, 0, 1, 1); + Color.MAGENTA = new Color(1, 0, 1, 1); + return Color; + }()); + spine.Color = Color; + var MathUtils = (function () { + function MathUtils() { + } + MathUtils.clamp = function (value, min, max) { + if (value < min) + return min; + if (value > max) + return max; + return value; + }; + MathUtils.cosDeg = function (degrees) { + return Math.cos(degrees * MathUtils.degRad); + }; + MathUtils.sinDeg = function (degrees) { + return Math.sin(degrees * MathUtils.degRad); + }; + MathUtils.signum = function (value) { + return value > 0 ? 1 : value < 0 ? -1 : 0; + }; + MathUtils.toInt = function (x) { + return x > 0 ? Math.floor(x) : Math.ceil(x); + }; + MathUtils.cbrt = function (x) { + var y = Math.pow(Math.abs(x), 1 / 3); + return x < 0 ? -y : y; + }; + MathUtils.randomTriangular = function (min, max) { + return MathUtils.randomTriangularWith(min, max, (min + max) * 0.5); + }; + MathUtils.randomTriangularWith = function (min, max, mode) { + var u = Math.random(); + var d = max - min; + if (u <= (mode - min) / d) + return min + Math.sqrt(u * d * (mode - min)); + return max - Math.sqrt((1 - u) * d * (max - mode)); + }; + MathUtils.PI = 3.1415927; + MathUtils.PI2 = MathUtils.PI * 2; + MathUtils.radiansToDegrees = 180 / MathUtils.PI; + MathUtils.radDeg = MathUtils.radiansToDegrees; + MathUtils.degreesToRadians = MathUtils.PI / 180; + MathUtils.degRad = MathUtils.degreesToRadians; + return MathUtils; + }()); + spine.MathUtils = MathUtils; + var Interpolation = (function () { + function Interpolation() { + } + Interpolation.prototype.apply = function (start, end, a) { + return start + (end - start) * this.applyInternal(a); + }; + return Interpolation; + }()); + spine.Interpolation = Interpolation; + var Pow = (function (_super) { + __extends(Pow, _super); + function Pow(power) { + var _this = _super.call(this) || this; + _this.power = 2; + _this.power = power; + return _this; + } + Pow.prototype.applyInternal = function (a) { + if (a <= 0.5) + return Math.pow(a * 2, this.power) / 2; + return Math.pow((a - 1) * 2, this.power) / (this.power % 2 == 0 ? -2 : 2) + 1; + }; + return Pow; + }(Interpolation)); + spine.Pow = Pow; + var PowOut = (function (_super) { + __extends(PowOut, _super); + function PowOut(power) { + return _super.call(this, power) || this; + } + PowOut.prototype.applyInternal = function (a) { + return Math.pow(a - 1, this.power) * (this.power % 2 == 0 ? -1 : 1) + 1; + }; + return PowOut; + }(Pow)); + spine.PowOut = PowOut; + var Utils = (function () { + function Utils() { + } + Utils.arrayCopy = function (source, sourceStart, dest, destStart, numElements) { + for (var i = sourceStart, j = destStart; i < sourceStart + numElements; i++, j++) { + dest[j] = source[i]; + } + }; + Utils.setArraySize = function (array, size, value) { + if (value === void 0) { value = 0; } + var oldSize = array.length; + if (oldSize == size) + return array; + array.length = size; + if (oldSize < size) { + for (var i = oldSize; i < size; i++) + array[i] = value; + } + return array; + }; + Utils.ensureArrayCapacity = function (array, size, value) { + if (value === void 0) { value = 0; } + if (array.length >= size) + return array; + return Utils.setArraySize(array, size, value); + }; + Utils.newArray = function (size, defaultValue) { + var array = new Array(size); + for (var i = 0; i < size; i++) + array[i] = defaultValue; + return array; + }; + Utils.newFloatArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Float32Array(size); + } + else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) + array[i] = 0; + return array; + } + }; + Utils.newShortArray = function (size) { + if (Utils.SUPPORTS_TYPED_ARRAYS) { + return new Int16Array(size); + } + else { + var array = new Array(size); + for (var i = 0; i < array.length; i++) + array[i] = 0; + return array; + } + }; + Utils.toFloatArray = function (array) { + return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; + }; + Utils.toSinglePrecision = function (value) { + return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value; + }; + Utils.webkit602BugfixHelper = function (alpha, pose) { + }; + Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; + return Utils; + }()); + spine.Utils = Utils; + var DebugUtils = (function () { + function DebugUtils() { + } + DebugUtils.logBones = function (skeleton) { + for (var i = 0; i < skeleton.bones.length; i++) { + var bone = skeleton.bones[i]; + console.log(bone.data.name + ", " + bone.a + ", " + bone.b + ", " + bone.c + ", " + bone.d + ", " + bone.worldX + ", " + bone.worldY); + } + }; + return DebugUtils; + }()); + spine.DebugUtils = DebugUtils; + var Pool = (function () { + function Pool(instantiator) { + this.items = new Array(); + this.instantiator = instantiator; + } + Pool.prototype.obtain = function () { + return this.items.length > 0 ? this.items.pop() : this.instantiator(); + }; + Pool.prototype.free = function (item) { + if (item.reset) + item.reset(); + this.items.push(item); + }; + Pool.prototype.freeAll = function (items) { + for (var i = 0; i < items.length; i++) { + if (items[i].reset) + items[i].reset(); + this.items[i] = items[i]; + } + }; + Pool.prototype.clear = function () { + this.items.length = 0; + }; + return Pool; + }()); + spine.Pool = Pool; + var Vector2 = (function () { + function Vector2(x, y) { + if (x === void 0) { x = 0; } + if (y === void 0) { y = 0; } + this.x = x; + this.y = y; + } + Vector2.prototype.set = function (x, y) { + this.x = x; + this.y = y; + return this; + }; + Vector2.prototype.length = function () { + var x = this.x; + var y = this.y; + return Math.sqrt(x * x + y * y); + }; + Vector2.prototype.normalize = function () { + var len = this.length(); + if (len != 0) { + this.x /= len; + this.y /= len; + } + return this; + }; + return Vector2; + }()); + spine.Vector2 = Vector2; + var TimeKeeper = (function () { + function TimeKeeper() { + this.maxDelta = 0.064; + this.framesPerSecond = 0; + this.delta = 0; + this.totalTime = 0; + this.lastTime = Date.now() / 1000; + this.frameCount = 0; + this.frameTime = 0; + } + TimeKeeper.prototype.update = function () { + var now = Date.now() / 1000; + this.delta = now - this.lastTime; + this.frameTime += this.delta; + this.totalTime += this.delta; + if (this.delta > this.maxDelta) + this.delta = this.maxDelta; + this.lastTime = now; + this.frameCount++; + if (this.frameTime > 1) { + this.framesPerSecond = this.frameCount / this.frameTime; + this.frameTime = 0; + this.frameCount = 0; + } + }; + return TimeKeeper; + }()); + spine.TimeKeeper = TimeKeeper; + var WindowedMean = (function () { + function WindowedMean(windowSize) { + if (windowSize === void 0) { windowSize = 32; } + this.addedValues = 0; + this.lastValue = 0; + this.mean = 0; + this.dirty = true; + this.values = new Array(windowSize); + } + WindowedMean.prototype.hasEnoughData = function () { + return this.addedValues >= this.values.length; + }; + WindowedMean.prototype.addValue = function (value) { + if (this.addedValues < this.values.length) + this.addedValues++; + this.values[this.lastValue++] = value; + if (this.lastValue > this.values.length - 1) + this.lastValue = 0; + this.dirty = true; + }; + WindowedMean.prototype.getMean = function () { + if (this.hasEnoughData()) { + if (this.dirty) { + var mean = 0; + for (var i = 0; i < this.values.length; i++) { + mean += this.values[i]; + } + this.mean = mean / this.values.length; + this.dirty = false; + } + return this.mean; + } + else { + return 0; + } + }; + return WindowedMean; + }()); + spine.WindowedMean = WindowedMean; +})(spine || (spine = {})); +(function () { + if (!Math.fround) { + Math.fround = (function (array) { + return function (x) { + return array[0] = x, array[0]; + }; + })(new Float32Array(1)); + } +})(); +var spine; +(function (spine) { + var Attachment = (function () { + function Attachment(name) { + if (name == null) + throw new Error("name cannot be null."); + this.name = name; + } + return Attachment; + }()); + spine.Attachment = Attachment; + var VertexAttachment = (function (_super) { + __extends(VertexAttachment, _super); + function VertexAttachment(name) { + var _this = _super.call(this, name) || this; + _this.id = (VertexAttachment.nextID++ & 65535) << 11; + _this.worldVerticesLength = 0; + return _this; + } + VertexAttachment.prototype.computeWorldVertices = function (slot, start, count, worldVertices, offset, stride) { + count = offset + (count >> 1) * stride; + var skeleton = slot.bone.skeleton; + var deformArray = slot.attachmentVertices; + var vertices = this.vertices; + var bones = this.bones; + if (bones == null) { + if (deformArray.length > 0) + vertices = deformArray; + var bone = slot.bone; + var x = bone.worldX; + var y = bone.worldY; + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + for (var v_1 = start, w = offset; w < count; v_1 += 2, w += stride) { + var vx = vertices[v_1], vy = vertices[v_1 + 1]; + worldVertices[w] = vx * a + vy * b + x; + worldVertices[w + 1] = vx * c + vy * d + y; + } + return; + } + var v = 0, skip = 0; + for (var i = 0; i < start; i += 2) { + var n = bones[v]; + v += n + 1; + skip += n; + } + var skeletonBones = skeleton.bones; + if (deformArray.length == 0) { + for (var w = offset, b = skip * 3; w < count; w += stride) { + var wx = 0, wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3) { + var bone = skeletonBones[bones[v]]; + var vx = vertices[b], vy = vertices[b + 1], weight = vertices[b + 2]; + wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight; + wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } + else { + var deform = deformArray; + for (var w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) { + var wx = 0, wy = 0; + var n = bones[v++]; + n += v; + for (; v < n; v++, b += 3, f += 2) { + var bone = skeletonBones[bones[v]]; + var vx = vertices[b] + deform[f], vy = vertices[b + 1] + deform[f + 1], weight = vertices[b + 2]; + wx += (vx * bone.a + vy * bone.b + bone.worldX) * weight; + wy += (vx * bone.c + vy * bone.d + bone.worldY) * weight; + } + worldVertices[w] = wx; + worldVertices[w + 1] = wy; + } + } + }; + VertexAttachment.prototype.applyDeform = function (sourceAttachment) { + return this == sourceAttachment; + }; + VertexAttachment.nextID = 0; + return VertexAttachment; + }(Attachment)); + spine.VertexAttachment = VertexAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var AttachmentType; + (function (AttachmentType) { + AttachmentType[AttachmentType["Region"] = 0] = "Region"; + AttachmentType[AttachmentType["BoundingBox"] = 1] = "BoundingBox"; + AttachmentType[AttachmentType["Mesh"] = 2] = "Mesh"; + AttachmentType[AttachmentType["LinkedMesh"] = 3] = "LinkedMesh"; + AttachmentType[AttachmentType["Path"] = 4] = "Path"; + AttachmentType[AttachmentType["Point"] = 5] = "Point"; + })(AttachmentType = spine.AttachmentType || (spine.AttachmentType = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var BoundingBoxAttachment = (function (_super) { + __extends(BoundingBoxAttachment, _super); + function BoundingBoxAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(1, 1, 1, 1); + return _this; + } + return BoundingBoxAttachment; + }(spine.VertexAttachment)); + spine.BoundingBoxAttachment = BoundingBoxAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var ClippingAttachment = (function (_super) { + __extends(ClippingAttachment, _super); + function ClippingAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(0.2275, 0.2275, 0.8078, 1); + return _this; + } + return ClippingAttachment; + }(spine.VertexAttachment)); + spine.ClippingAttachment = ClippingAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var MeshAttachment = (function (_super) { + __extends(MeshAttachment, _super); + function MeshAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(1, 1, 1, 1); + _this.inheritDeform = false; + _this.tempColor = new spine.Color(0, 0, 0, 0); + return _this; + } + MeshAttachment.prototype.updateUVs = function () { + var u = 0, v = 0, width = 0, height = 0; + if (this.region == null) { + u = v = 0; + width = height = 1; + } + else { + u = this.region.u; + v = this.region.v; + width = this.region.u2 - u; + height = this.region.v2 - v; + } + var regionUVs = this.regionUVs; + if (this.uvs == null || this.uvs.length != regionUVs.length) + this.uvs = spine.Utils.newFloatArray(regionUVs.length); + var uvs = this.uvs; + if (this.region.rotate) { + for (var i = 0, n = uvs.length; i < n; i += 2) { + uvs[i] = u + regionUVs[i + 1] * width; + uvs[i + 1] = v + height - regionUVs[i] * height; + } + } + else { + for (var i = 0, n = uvs.length; i < n; i += 2) { + uvs[i] = u + regionUVs[i] * width; + uvs[i + 1] = v + regionUVs[i + 1] * height; + } + } + }; + MeshAttachment.prototype.applyDeform = function (sourceAttachment) { + return this == sourceAttachment || (this.inheritDeform && this.parentMesh == sourceAttachment); + }; + MeshAttachment.prototype.getParentMesh = function () { + return this.parentMesh; + }; + MeshAttachment.prototype.setParentMesh = function (parentMesh) { + this.parentMesh = parentMesh; + if (parentMesh != null) { + this.bones = parentMesh.bones; + this.vertices = parentMesh.vertices; + this.worldVerticesLength = parentMesh.worldVerticesLength; + this.regionUVs = parentMesh.regionUVs; + this.triangles = parentMesh.triangles; + this.hullLength = parentMesh.hullLength; + this.worldVerticesLength = parentMesh.worldVerticesLength; + } + }; + return MeshAttachment; + }(spine.VertexAttachment)); + spine.MeshAttachment = MeshAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PathAttachment = (function (_super) { + __extends(PathAttachment, _super); + function PathAttachment(name) { + var _this = _super.call(this, name) || this; + _this.closed = false; + _this.constantSpeed = false; + _this.color = new spine.Color(1, 1, 1, 1); + return _this; + } + return PathAttachment; + }(spine.VertexAttachment)); + spine.PathAttachment = PathAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var PointAttachment = (function (_super) { + __extends(PointAttachment, _super); + function PointAttachment(name) { + var _this = _super.call(this, name) || this; + _this.color = new spine.Color(0.38, 0.94, 0, 1); + return _this; + } + PointAttachment.prototype.computeWorldPosition = function (bone, point) { + point.x = this.x * bone.a + this.y * bone.b + bone.worldX; + point.y = this.x * bone.c + this.y * bone.d + bone.worldY; + return point; + }; + PointAttachment.prototype.computeWorldRotation = function (bone) { + var cos = spine.MathUtils.cosDeg(this.rotation), sin = spine.MathUtils.sinDeg(this.rotation); + var x = cos * bone.a + sin * bone.b; + var y = cos * bone.c + sin * bone.d; + return Math.atan2(y, x) * spine.MathUtils.radDeg; + }; + return PointAttachment; + }(spine.VertexAttachment)); + spine.PointAttachment = PointAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var RegionAttachment = (function (_super) { + __extends(RegionAttachment, _super); + function RegionAttachment(name) { + var _this = _super.call(this, name) || this; + _this.x = 0; + _this.y = 0; + _this.scaleX = 1; + _this.scaleY = 1; + _this.rotation = 0; + _this.width = 0; + _this.height = 0; + _this.color = new spine.Color(1, 1, 1, 1); + _this.offset = spine.Utils.newFloatArray(8); + _this.uvs = spine.Utils.newFloatArray(8); + _this.tempColor = new spine.Color(1, 1, 1, 1); + return _this; + } + RegionAttachment.prototype.updateOffset = function () { + var regionScaleX = this.width / this.region.originalWidth * this.scaleX; + var regionScaleY = this.height / this.region.originalHeight * this.scaleY; + var localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX; + var localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY; + var localX2 = localX + this.region.width * regionScaleX; + var localY2 = localY + this.region.height * regionScaleY; + var radians = this.rotation * Math.PI / 180; + var cos = Math.cos(radians); + var sin = Math.sin(radians); + var localXCos = localX * cos + this.x; + var localXSin = localX * sin; + var localYCos = localY * cos + this.y; + var localYSin = localY * sin; + var localX2Cos = localX2 * cos + this.x; + var localX2Sin = localX2 * sin; + var localY2Cos = localY2 * cos + this.y; + var localY2Sin = localY2 * sin; + var offset = this.offset; + offset[RegionAttachment.OX1] = localXCos - localYSin; + offset[RegionAttachment.OY1] = localYCos + localXSin; + offset[RegionAttachment.OX2] = localXCos - localY2Sin; + offset[RegionAttachment.OY2] = localY2Cos + localXSin; + offset[RegionAttachment.OX3] = localX2Cos - localY2Sin; + offset[RegionAttachment.OY3] = localY2Cos + localX2Sin; + offset[RegionAttachment.OX4] = localX2Cos - localYSin; + offset[RegionAttachment.OY4] = localYCos + localX2Sin; + }; + RegionAttachment.prototype.setRegion = function (region) { + this.region = region; + var uvs = this.uvs; + if (region.rotate) { + uvs[2] = region.u; + uvs[3] = region.v2; + uvs[4] = region.u; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v; + uvs[0] = region.u2; + uvs[1] = region.v2; + } + else { + uvs[0] = region.u; + uvs[1] = region.v2; + uvs[2] = region.u; + uvs[3] = region.v; + uvs[4] = region.u2; + uvs[5] = region.v; + uvs[6] = region.u2; + uvs[7] = region.v2; + } + }; + RegionAttachment.prototype.computeWorldVertices = function (bone, worldVertices, offset, stride) { + var vertexOffset = this.offset; + var x = bone.worldX, y = bone.worldY; + var a = bone.a, b = bone.b, c = bone.c, d = bone.d; + var offsetX = 0, offsetY = 0; + offsetX = vertexOffset[RegionAttachment.OX1]; + offsetY = vertexOffset[RegionAttachment.OY1]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX2]; + offsetY = vertexOffset[RegionAttachment.OY2]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX3]; + offsetY = vertexOffset[RegionAttachment.OY3]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + offset += stride; + offsetX = vertexOffset[RegionAttachment.OX4]; + offsetY = vertexOffset[RegionAttachment.OY4]; + worldVertices[offset] = offsetX * a + offsetY * b + x; + worldVertices[offset + 1] = offsetX * c + offsetY * d + y; + }; + RegionAttachment.OX1 = 0; + RegionAttachment.OY1 = 1; + RegionAttachment.OX2 = 2; + RegionAttachment.OY2 = 3; + RegionAttachment.OX3 = 4; + RegionAttachment.OY3 = 5; + RegionAttachment.OX4 = 6; + RegionAttachment.OY4 = 7; + RegionAttachment.X1 = 0; + RegionAttachment.Y1 = 1; + RegionAttachment.C1R = 2; + RegionAttachment.C1G = 3; + RegionAttachment.C1B = 4; + RegionAttachment.C1A = 5; + RegionAttachment.U1 = 6; + RegionAttachment.V1 = 7; + RegionAttachment.X2 = 8; + RegionAttachment.Y2 = 9; + RegionAttachment.C2R = 10; + RegionAttachment.C2G = 11; + RegionAttachment.C2B = 12; + RegionAttachment.C2A = 13; + RegionAttachment.U2 = 14; + RegionAttachment.V2 = 15; + RegionAttachment.X3 = 16; + RegionAttachment.Y3 = 17; + RegionAttachment.C3R = 18; + RegionAttachment.C3G = 19; + RegionAttachment.C3B = 20; + RegionAttachment.C3A = 21; + RegionAttachment.U3 = 22; + RegionAttachment.V3 = 23; + RegionAttachment.X4 = 24; + RegionAttachment.Y4 = 25; + RegionAttachment.C4R = 26; + RegionAttachment.C4G = 27; + RegionAttachment.C4B = 28; + RegionAttachment.C4A = 29; + RegionAttachment.U4 = 30; + RegionAttachment.V4 = 31; + return RegionAttachment; + }(spine.Attachment)); + spine.RegionAttachment = RegionAttachment; +})(spine || (spine = {})); +var spine; +(function (spine) { + var JitterEffect = (function () { + function JitterEffect(jitterX, jitterY) { + this.jitterX = 0; + this.jitterY = 0; + this.jitterX = jitterX; + this.jitterY = jitterY; + } + JitterEffect.prototype.begin = function (skeleton) { + }; + JitterEffect.prototype.transform = function (position, uv, light, dark) { + position.x += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + position.y += spine.MathUtils.randomTriangular(-this.jitterX, this.jitterY); + }; + JitterEffect.prototype.end = function () { + }; + return JitterEffect; + }()); + spine.JitterEffect = JitterEffect; +})(spine || (spine = {})); +var spine; +(function (spine) { + var SwirlEffect = (function () { + function SwirlEffect(radius) { + this.centerX = 0; + this.centerY = 0; + this.radius = 0; + this.angle = 0; + this.worldX = 0; + this.worldY = 0; + this.radius = radius; + } + SwirlEffect.prototype.begin = function (skeleton) { + this.worldX = skeleton.x + this.centerX; + this.worldY = skeleton.y + this.centerY; + }; + SwirlEffect.prototype.transform = function (position, uv, light, dark) { + var radAngle = this.angle * spine.MathUtils.degreesToRadians; + var x = position.x - this.worldX; + var y = position.y - this.worldY; + var dist = Math.sqrt(x * x + y * y); + if (dist < this.radius) { + var theta = SwirlEffect.interpolation.apply(0, radAngle, (this.radius - dist) / this.radius); + var cos = Math.cos(theta); + var sin = Math.sin(theta); + position.x = cos * x - sin * y + this.worldX; + position.y = sin * x + cos * y + this.worldY; + } + }; + SwirlEffect.prototype.end = function () { + }; + SwirlEffect.interpolation = new spine.PowOut(2); + return SwirlEffect; + }()); + spine.SwirlEffect = SwirlEffect; +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var AssetManager = (function (_super) { + __extends(AssetManager, _super); + function AssetManager(context, pathPrefix) { + if (pathPrefix === void 0) { pathPrefix = ""; } + return _super.call(this, function (image) { + return new spine.webgl.GLTexture(context, image); + }, pathPrefix) || this; + } + return AssetManager; + }(spine.AssetManager)); + webgl.AssetManager = AssetManager; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var OrthoCamera = (function () { + function OrthoCamera(viewportWidth, viewportHeight) { + this.position = new webgl.Vector3(0, 0, 0); + this.direction = new webgl.Vector3(0, 0, -1); + this.up = new webgl.Vector3(0, 1, 0); + this.near = 0; + this.far = 100; + this.zoom = 1; + this.viewportWidth = 0; + this.viewportHeight = 0; + this.projectionView = new webgl.Matrix4(); + this.inverseProjectionView = new webgl.Matrix4(); + this.projection = new webgl.Matrix4(); + this.view = new webgl.Matrix4(); + this.tmp = new webgl.Vector3(); + this.viewportWidth = viewportWidth; + this.viewportHeight = viewportHeight; + this.update(); + } + OrthoCamera.prototype.update = function () { + var projection = this.projection; + var view = this.view; + var projectionView = this.projectionView; + var inverseProjectionView = this.inverseProjectionView; + var zoom = this.zoom, viewportWidth = this.viewportWidth, viewportHeight = this.viewportHeight; + projection.ortho(zoom * (-viewportWidth / 2), zoom * (viewportWidth / 2), zoom * (-viewportHeight / 2), zoom * (viewportHeight / 2), this.near, this.far); + view.lookAt(this.position, this.direction, this.up); + projectionView.set(projection.values); + projectionView.multiply(view); + inverseProjectionView.set(projectionView.values).invert(); + }; + OrthoCamera.prototype.screenToWorld = function (screenCoords, screenWidth, screenHeight) { + var x = screenCoords.x, y = screenHeight - screenCoords.y - 1; + var tmp = this.tmp; + tmp.x = (2 * x) / screenWidth - 1; + tmp.y = (2 * y) / screenHeight - 1; + tmp.z = (2 * screenCoords.z) - 1; + tmp.project(this.inverseProjectionView); + screenCoords.set(tmp.x, tmp.y, tmp.z); + return screenCoords; + }; + OrthoCamera.prototype.setViewport = function (viewportWidth, viewportHeight) { + this.viewportWidth = viewportWidth; + this.viewportHeight = viewportHeight; + }; + return OrthoCamera; + }()); + webgl.OrthoCamera = OrthoCamera; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var GLTexture = (function (_super) { + __extends(GLTexture, _super); + function GLTexture(context, image, useMipMaps) { + if (useMipMaps === void 0) { useMipMaps = false; } + var _this = _super.call(this, image) || this; + _this.texture = null; + _this.boundUnit = 0; + _this.useMipMaps = false; + _this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + _this.useMipMaps = useMipMaps; + _this.restore(); + _this.context.addRestorable(_this); + return _this; + } + GLTexture.prototype.setFilters = function (minFilter, magFilter) { + var gl = this.context.gl; + this.bind(); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, magFilter); + }; + GLTexture.prototype.setWraps = function (uWrap, vWrap) { + var gl = this.context.gl; + this.bind(); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, uWrap); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, vWrap); + }; + GLTexture.prototype.update = function (useMipMaps) { + var gl = this.context.gl; + if (!this.texture) { + this.texture = this.context.gl.createTexture(); + } + this.bind(); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._image); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, useMipMaps ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + if (useMipMaps) + gl.generateMipmap(gl.TEXTURE_2D); + }; + GLTexture.prototype.restore = function () { + this.texture = null; + this.update(this.useMipMaps); + }; + GLTexture.prototype.bind = function (unit) { + if (unit === void 0) { unit = 0; } + var gl = this.context.gl; + this.boundUnit = unit; + gl.activeTexture(gl.TEXTURE0 + unit); + gl.bindTexture(gl.TEXTURE_2D, this.texture); + }; + GLTexture.prototype.unbind = function () { + var gl = this.context.gl; + gl.activeTexture(gl.TEXTURE0 + this.boundUnit); + gl.bindTexture(gl.TEXTURE_2D, null); + }; + GLTexture.prototype.dispose = function () { + this.context.removeRestorable(this); + var gl = this.context.gl; + gl.deleteTexture(this.texture); + }; + return GLTexture; + }(spine.Texture)); + webgl.GLTexture = GLTexture; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Input = (function () { + function Input(element) { + this.lastX = 0; + this.lastY = 0; + this.buttonDown = false; + this.currTouch = null; + this.touchesPool = new spine.Pool(function () { + return new spine.webgl.Touch(0, 0, 0); + }); + this.listeners = new Array(); + this.element = element; + this.setupCallbacks(element); + } + Input.prototype.setupCallbacks = function (element) { + var _this = this; + element.addEventListener("mousedown", function (ev) { + if (ev instanceof MouseEvent) { + var rect = element.getBoundingClientRect(); + var x = ev.clientX - rect.left; + var y = ev.clientY - rect.top; + var listeners = _this.listeners; + for (var i = 0; i < listeners.length; i++) { + listeners[i].down(x, y); + } + _this.lastX = x; + _this.lastY = y; + _this.buttonDown = true; + } + }, true); + element.addEventListener("mousemove", function (ev) { + if (ev instanceof MouseEvent) { + var rect = element.getBoundingClientRect(); + var x = ev.clientX - rect.left; + var y = ev.clientY - rect.top; + var listeners = _this.listeners; + for (var i = 0; i < listeners.length; i++) { + if (_this.buttonDown) { + listeners[i].dragged(x, y); + } + else { + listeners[i].moved(x, y); + } + } + _this.lastX = x; + _this.lastY = y; + } + }, true); + element.addEventListener("mouseup", function (ev) { + if (ev instanceof MouseEvent) { + var rect = element.getBoundingClientRect(); + var x = ev.clientX - rect.left; + var y = ev.clientY - rect.top; + var listeners = _this.listeners; + for (var i = 0; i < listeners.length; i++) { + listeners[i].up(x, y); + } + _this.lastX = x; + _this.lastY = y; + _this.buttonDown = false; + } + }, true); + element.addEventListener("touchstart", function (ev) { + if (_this.currTouch != null) + return; + var touches = ev.changedTouches; + for (var i = 0; i < touches.length; i++) { + var touch = touches[i]; + var rect = element.getBoundingClientRect(); + var x = touch.clientX - rect.left; + var y = touch.clientY - rect.top; + _this.currTouch = _this.touchesPool.obtain(); + _this.currTouch.identifier = touch.identifier; + _this.currTouch.x = x; + _this.currTouch.y = y; + break; + } + var listeners = _this.listeners; + for (var i_8 = 0; i_8 < listeners.length; i_8++) { + listeners[i_8].down(_this.currTouch.x, _this.currTouch.y); + } + console.log("Start " + _this.currTouch.x + ", " + _this.currTouch.y); + _this.lastX = _this.currTouch.x; + _this.lastY = _this.currTouch.y; + _this.buttonDown = true; + ev.preventDefault(); + }, false); + element.addEventListener("touchend", function (ev) { + var touches = ev.changedTouches; + for (var i = 0; i < touches.length; i++) { + var touch = touches[i]; + if (_this.currTouch.identifier === touch.identifier) { + var rect = element.getBoundingClientRect(); + var x = _this.currTouch.x = touch.clientX - rect.left; + var y = _this.currTouch.y = touch.clientY - rect.top; + _this.touchesPool.free(_this.currTouch); + var listeners = _this.listeners; + for (var i_9 = 0; i_9 < listeners.length; i_9++) { + listeners[i_9].up(x, y); + } + console.log("End " + x + ", " + y); + _this.lastX = x; + _this.lastY = y; + _this.buttonDown = false; + _this.currTouch = null; + break; + } + } + ev.preventDefault(); + }, false); + element.addEventListener("touchcancel", function (ev) { + var touches = ev.changedTouches; + for (var i = 0; i < touches.length; i++) { + var touch = touches[i]; + if (_this.currTouch.identifier === touch.identifier) { + var rect = element.getBoundingClientRect(); + var x = _this.currTouch.x = touch.clientX - rect.left; + var y = _this.currTouch.y = touch.clientY - rect.top; + _this.touchesPool.free(_this.currTouch); + var listeners = _this.listeners; + for (var i_10 = 0; i_10 < listeners.length; i_10++) { + listeners[i_10].up(x, y); + } + console.log("End " + x + ", " + y); + _this.lastX = x; + _this.lastY = y; + _this.buttonDown = false; + _this.currTouch = null; + break; + } + } + ev.preventDefault(); + }, false); + element.addEventListener("touchmove", function (ev) { + if (_this.currTouch == null) + return; + var touches = ev.changedTouches; + for (var i = 0; i < touches.length; i++) { + var touch = touches[i]; + if (_this.currTouch.identifier === touch.identifier) { + var rect = element.getBoundingClientRect(); + var x = touch.clientX - rect.left; + var y = touch.clientY - rect.top; + var listeners = _this.listeners; + for (var i_11 = 0; i_11 < listeners.length; i_11++) { + listeners[i_11].dragged(x, y); + } + console.log("Drag " + x + ", " + y); + _this.lastX = _this.currTouch.x = x; + _this.lastY = _this.currTouch.y = y; + break; + } + } + ev.preventDefault(); + }, false); + }; + Input.prototype.addListener = function (listener) { + this.listeners.push(listener); + }; + Input.prototype.removeListener = function (listener) { + var idx = this.listeners.indexOf(listener); + if (idx > -1) { + this.listeners.splice(idx, 1); + } + }; + return Input; + }()); + webgl.Input = Input; + var Touch = (function () { + function Touch(identifier, x, y) { + this.identifier = identifier; + this.x = x; + this.y = y; + } + return Touch; + }()); + webgl.Touch = Touch; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var LoadingScreen = (function () { + function LoadingScreen(renderer) { + this.logo = null; + this.spinner = null; + this.angle = 0; + this.fadeOut = 0; + this.timeKeeper = new spine.TimeKeeper(); + this.backgroundColor = new spine.Color(0.135, 0.135, 0.135, 1); + this.tempColor = new spine.Color(); + this.firstDraw = 0; + this.renderer = renderer; + this.timeKeeper.maxDelta = 9; + if (LoadingScreen.logoImg === null) { + var isSafari = navigator.userAgent.indexOf("Safari") > -1; + LoadingScreen.logoImg = new Image(); + LoadingScreen.logoImg.src = LoadingScreen.SPINE_LOGO_DATA; + if (!isSafari) + LoadingScreen.logoImg.crossOrigin = "anonymous"; + LoadingScreen.logoImg.onload = function (ev) { + LoadingScreen.loaded++; + }; + LoadingScreen.spinnerImg = new Image(); + LoadingScreen.spinnerImg.src = LoadingScreen.SPINNER_DATA; + if (!isSafari) + LoadingScreen.spinnerImg.crossOrigin = "anonymous"; + LoadingScreen.spinnerImg.onload = function (ev) { + LoadingScreen.loaded++; + }; + } + } + LoadingScreen.prototype.draw = function (complete) { + if (complete === void 0) { complete = false; } + if (complete && this.fadeOut > LoadingScreen.FADE_SECONDS) + return; + this.timeKeeper.update(); + var a = Math.abs(Math.sin(this.timeKeeper.totalTime + 0.75)); + this.angle -= this.timeKeeper.delta * 360 * (1 + 1.5 * Math.pow(a, 5)); + var renderer = this.renderer; + var canvas = renderer.canvas; + var gl = renderer.context.gl; + var oldX = renderer.camera.position.x, oldY = renderer.camera.position.y; + renderer.camera.position.set(canvas.width / 2, canvas.height / 2, 0); + renderer.camera.viewportWidth = canvas.width; + renderer.camera.viewportHeight = canvas.height; + renderer.resize(webgl.ResizeMode.Stretch); + if (!complete) { + gl.clearColor(this.backgroundColor.r, this.backgroundColor.g, this.backgroundColor.b, this.backgroundColor.a); + gl.clear(gl.COLOR_BUFFER_BIT); + this.tempColor.a = 1; + } + else { + this.fadeOut += this.timeKeeper.delta * (this.timeKeeper.totalTime < 1 ? 2 : 1); + if (this.fadeOut > LoadingScreen.FADE_SECONDS) { + renderer.camera.position.set(oldX, oldY, 0); + return; + } + a = 1 - this.fadeOut / LoadingScreen.FADE_SECONDS; + this.tempColor.setFromColor(this.backgroundColor); + this.tempColor.a = 1 - (a - 1) * (a - 1); + renderer.begin(); + renderer.quad(true, 0, 0, canvas.width, 0, canvas.width, canvas.height, 0, canvas.height, this.tempColor, this.tempColor, this.tempColor, this.tempColor); + renderer.end(); + } + this.tempColor.set(1, 1, 1, this.tempColor.a); + if (LoadingScreen.loaded != 2) + return; + if (this.logo === null) { + this.logo = new webgl.GLTexture(renderer.context, LoadingScreen.logoImg); + this.spinner = new webgl.GLTexture(renderer.context, LoadingScreen.spinnerImg); + } + this.logo.update(false); + this.spinner.update(false); + var logoWidth = this.logo.getImage().width; + var logoHeight = this.logo.getImage().height; + var spinnerWidth = this.spinner.getImage().width; + var spinnerHeight = this.spinner.getImage().height; + renderer.batcher.setBlendMode(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); + renderer.begin(); + renderer.drawTexture(this.logo, (canvas.width - logoWidth) / 2, (canvas.height - logoHeight) / 2, logoWidth, logoHeight, this.tempColor); + renderer.drawTextureRotated(this.spinner, (canvas.width - spinnerWidth) / 2, (canvas.height - spinnerHeight) / 2, spinnerWidth, spinnerHeight, spinnerWidth / 2, spinnerHeight / 2, this.angle, this.tempColor); + renderer.end(); + renderer.camera.position.set(oldX, oldY, 0); + }; + LoadingScreen.FADE_SECONDS = 1; + LoadingScreen.loaded = 0; + LoadingScreen.spinnerImg = null; + LoadingScreen.logoImg = null; + LoadingScreen.SPINNER_DATA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAChCAMAAAB3TUS6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAYNQTFRFAAAA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AA/0AAkTDRyAAAAIB0Uk5TAAABAgMEBQYHCAkKCwwODxAREhMUFRYXGBkaHB0eICEiIyQlJicoKSorLC0uLzAxMjM0Nzg5Ojs8PT4/QEFDRUlKS0xNTk9QUlRWWFlbXF1eYWJjZmhscHF0d3h5e3x+f4CIiYuMj5GSlJWXm56io6arr7rAxcjO0dXe6Onr8fmb5sOOAAADuElEQVQYGe3B+3vTVBwH4M/3nCRt13br2Lozhug2q25gYQubcxqVKYoMCYoKjEsUdSpeiBc0Kl7yp9t2za39pely7PF5zvuiQKc+/e2f8K+f9g2oyQ77Ag4VGX+HketQ0XYYe0JQ0CdhogwF+WFiBgr6JkxUoKCDMMGgoP0w9gdUtB3GfoCKVsPYAVQ0H8YuQUWVMHYGKuJhrAklPQkjJpT0bdj3O9S0FfZ9ADXxP8MjVSiqFfa8B2VVV8+df14QtB4iwn+BpuZEgyM38WMQHDYhnbkgukrIh5ygZ48glyn6KshlL+jbhVRcxCzk0ApiC5CI5kVsgTAy9jiI/WxBGmqIFBMjqwYphwRZaiLNwsjqQdoVSFISGRwjM4OMFUjBRcYCYWT0XZD2SwUS0LzIKCGH2SDja0LxKiJjCrm0gowVFI6aIs1CTouPg5QvUTgSKXMMuVUeBSmEopFITBPGwO8HCYbCTYtImTAWejuI3CMUjmZFT5NjbM/9GvQcMkhADdFRIxxD7aug4wGDFGSVTcLx0MzutQ2CpmmapmmapmmapmmapmmaphWBmGFV6rNNcaLC0GUuv3LROftUo8wJk0a10207sVED6IIf+9673LIwQeW2PaCEJX/A+xYmhTbtQUu46g96SJgQZg9Zwxf+EAMTwuwhm3jkD7EwIdweBn+YhQlh9pA2HvpDTEwIs4es4GN/CMekNOxBJ9D2B10nTAyfW7fT1hjYgZ/xYIUwUcycaiwuv2h3tOcZADr7ud/12c0ru2cWSwQ1UAcixIgImqZpmqZpmqZpmqZpmqZp2v8HMSIcF186t8oghbnlOJt1wnHwl7yOGxwSlHacrjWG8dVuej03OApn7jhHtiyMiZa9yD6haLYTebWOsbDXvQRHwchJWSTkV/rQS+EoWttJaTHkJe56KXcJRZt20jY48nnBy9hE4WjLSbvAkIfwMm5zFG/KyWgRRke3vYwGZDjpZHCMruJltCAFrTtpVYxu1ktzCHKwbSdlGqOreynXGGQpOylljI5uebFbBuSZc2IbhBxmvcj9GiSiZ52+HQO5nPb6TkIqajs9L5eQk7jnddxZgGT0jNOxYSI36+Kdj9oG5OPV6QpB6yJuGAYnqIrecLveYlDUKffIOtREl90+BiWV3cgMlNR0I09DSS030oaSttzILpT0phu5BBWRmyAoiLkJgoIMN8GgoJKb4FBQzU0YUFDdTRhQUNVNcCjIdBMEBdE7buQ8lFRz+97lUFN5fe+qu//aMkeB/gU2ae9y2HgbngAAAABJRU5ErkJggg=="; + LoadingScreen.SPINE_LOGO_DATA = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFIAAAAZCAYAAACis3k0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtNJREFUaN7tmT2I1EAUxwN+oWgRT0HFKo0WCkJ6ObmAWFwZbCxsXGysLNJaiCyIoDaSwk4ETzvhmnBaCRbBWoQ01ho4PwotjP8cE337mMy8TLK757mBH3fLTWbe/PbN53neNniqZW8FvAVvQAqugwvgDDgO9niLRyTyJagM/ACPF6bsIl9ZRDac/Cc6tLn5xQdRQ496QlKPLxD5QCDxO9jtGM8QfYoIgUlgCipGCRJL5VvlyOdCU09iEXkCfLSIfCrs7Fab6nOsiafu06iDwES9w/uU1QnDC+ekkVS9vEaDsgVeB0d+z1VDtOGxRaYPboP3Gokb4GgXkZp4chZPJKgvZ3U0XkriK/TIt9YUDllFgTAjGwoaoHqfBhMI58yD4BQ4V6/aHYdfxToftvw9F2SiVroawU2/Cv5C4Thv0KB9S5nxlOd4STxjwUjzSdYlgrYijw2BsEfgsaFcM09lhiys94xXQQwugcvgJrgFLjrEE7WUiTuWCQzt/ZXN7FfqGwuGClyVy2xZAFmfDQvNtwFFSspMDGsD+UTWqu1KoVmVooFEJgKRXw0if85RpISEzwsjzeqWzkjkC4PIJ3MUmQgITAHlQwTFhnZhELkEntfZRwR+AvfAgXmJHOqU02XligWT8ppg67NXbdCXeq7afUQ6L8C2DalEZNt2YyQ94Qy8/ekjMpBMbfyl5iTjG7YAI8cNecROAb4kJmTjaXAF3AGvwQewOiuRxEtlSaT4j2h2lMsUueQEoMlIKpTvAmKhxPMtC876jEX6rE8l8TNx/KVbn6xlWU9NWcSDUsO4NGWpQOTZFpHPOooMXcswmW2XFk3ixb2v0Nq+XVKP00QNaffBLyWwBI/AkTlfMYZDXMf12kc6yjwEjoFdO/5me5oi/6tnyhlZX6OtgmX1c2Uh0k3khmbB2b9TRfpd/jfTUeRDJvHdYg5wE7kPXAN3wQ1weDvH+xufEgpi5qIl3QAAAABJRU5ErkJggg=="; + return LoadingScreen; + }()); + webgl.LoadingScreen = LoadingScreen; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + webgl.M00 = 0; + webgl.M01 = 4; + webgl.M02 = 8; + webgl.M03 = 12; + webgl.M10 = 1; + webgl.M11 = 5; + webgl.M12 = 9; + webgl.M13 = 13; + webgl.M20 = 2; + webgl.M21 = 6; + webgl.M22 = 10; + webgl.M23 = 14; + webgl.M30 = 3; + webgl.M31 = 7; + webgl.M32 = 11; + webgl.M33 = 15; + var Matrix4 = (function () { + function Matrix4() { + this.temp = new Float32Array(16); + this.values = new Float32Array(16); + var v = this.values; + v[webgl.M00] = 1; + v[webgl.M11] = 1; + v[webgl.M22] = 1; + v[webgl.M33] = 1; + } + Matrix4.prototype.set = function (values) { + this.values.set(values); + return this; + }; + Matrix4.prototype.transpose = function () { + var t = this.temp; + var v = this.values; + t[webgl.M00] = v[webgl.M00]; + t[webgl.M01] = v[webgl.M10]; + t[webgl.M02] = v[webgl.M20]; + t[webgl.M03] = v[webgl.M30]; + t[webgl.M10] = v[webgl.M01]; + t[webgl.M11] = v[webgl.M11]; + t[webgl.M12] = v[webgl.M21]; + t[webgl.M13] = v[webgl.M31]; + t[webgl.M20] = v[webgl.M02]; + t[webgl.M21] = v[webgl.M12]; + t[webgl.M22] = v[webgl.M22]; + t[webgl.M23] = v[webgl.M32]; + t[webgl.M30] = v[webgl.M03]; + t[webgl.M31] = v[webgl.M13]; + t[webgl.M32] = v[webgl.M23]; + t[webgl.M33] = v[webgl.M33]; + return this.set(t); + }; + Matrix4.prototype.identity = function () { + var v = this.values; + v[webgl.M00] = 1; + v[webgl.M01] = 0; + v[webgl.M02] = 0; + v[webgl.M03] = 0; + v[webgl.M10] = 0; + v[webgl.M11] = 1; + v[webgl.M12] = 0; + v[webgl.M13] = 0; + v[webgl.M20] = 0; + v[webgl.M21] = 0; + v[webgl.M22] = 1; + v[webgl.M23] = 0; + v[webgl.M30] = 0; + v[webgl.M31] = 0; + v[webgl.M32] = 0; + v[webgl.M33] = 1; + return this; + }; + Matrix4.prototype.invert = function () { + var v = this.values; + var t = this.temp; + var l_det = v[webgl.M30] * v[webgl.M21] * v[webgl.M12] * v[webgl.M03] - v[webgl.M20] * v[webgl.M31] * v[webgl.M12] * v[webgl.M03] - v[webgl.M30] * v[webgl.M11] * v[webgl.M22] * v[webgl.M03] + + v[webgl.M10] * v[webgl.M31] * v[webgl.M22] * v[webgl.M03] + v[webgl.M20] * v[webgl.M11] * v[webgl.M32] * v[webgl.M03] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32] * v[webgl.M03] + - v[webgl.M30] * v[webgl.M21] * v[webgl.M02] * v[webgl.M13] + v[webgl.M20] * v[webgl.M31] * v[webgl.M02] * v[webgl.M13] + v[webgl.M30] * v[webgl.M01] * v[webgl.M22] * v[webgl.M13] + - v[webgl.M00] * v[webgl.M31] * v[webgl.M22] * v[webgl.M13] - v[webgl.M20] * v[webgl.M01] * v[webgl.M32] * v[webgl.M13] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32] * v[webgl.M13] + + v[webgl.M30] * v[webgl.M11] * v[webgl.M02] * v[webgl.M23] - v[webgl.M10] * v[webgl.M31] * v[webgl.M02] * v[webgl.M23] - v[webgl.M30] * v[webgl.M01] * v[webgl.M12] * v[webgl.M23] + + v[webgl.M00] * v[webgl.M31] * v[webgl.M12] * v[webgl.M23] + v[webgl.M10] * v[webgl.M01] * v[webgl.M32] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32] * v[webgl.M23] + - v[webgl.M20] * v[webgl.M11] * v[webgl.M02] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M02] * v[webgl.M33] + v[webgl.M20] * v[webgl.M01] * v[webgl.M12] * v[webgl.M33] + - v[webgl.M00] * v[webgl.M21] * v[webgl.M12] * v[webgl.M33] - v[webgl.M10] * v[webgl.M01] * v[webgl.M22] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22] * v[webgl.M33]; + if (l_det == 0) + throw new Error("non-invertible matrix"); + var inv_det = 1.0 / l_det; + t[webgl.M00] = v[webgl.M12] * v[webgl.M23] * v[webgl.M31] - v[webgl.M13] * v[webgl.M22] * v[webgl.M31] + v[webgl.M13] * v[webgl.M21] * v[webgl.M32] + - v[webgl.M11] * v[webgl.M23] * v[webgl.M32] - v[webgl.M12] * v[webgl.M21] * v[webgl.M33] + v[webgl.M11] * v[webgl.M22] * v[webgl.M33]; + t[webgl.M01] = v[webgl.M03] * v[webgl.M22] * v[webgl.M31] - v[webgl.M02] * v[webgl.M23] * v[webgl.M31] - v[webgl.M03] * v[webgl.M21] * v[webgl.M32] + + v[webgl.M01] * v[webgl.M23] * v[webgl.M32] + v[webgl.M02] * v[webgl.M21] * v[webgl.M33] - v[webgl.M01] * v[webgl.M22] * v[webgl.M33]; + t[webgl.M02] = v[webgl.M02] * v[webgl.M13] * v[webgl.M31] - v[webgl.M03] * v[webgl.M12] * v[webgl.M31] + v[webgl.M03] * v[webgl.M11] * v[webgl.M32] + - v[webgl.M01] * v[webgl.M13] * v[webgl.M32] - v[webgl.M02] * v[webgl.M11] * v[webgl.M33] + v[webgl.M01] * v[webgl.M12] * v[webgl.M33]; + t[webgl.M03] = v[webgl.M03] * v[webgl.M12] * v[webgl.M21] - v[webgl.M02] * v[webgl.M13] * v[webgl.M21] - v[webgl.M03] * v[webgl.M11] * v[webgl.M22] + + v[webgl.M01] * v[webgl.M13] * v[webgl.M22] + v[webgl.M02] * v[webgl.M11] * v[webgl.M23] - v[webgl.M01] * v[webgl.M12] * v[webgl.M23]; + t[webgl.M10] = v[webgl.M13] * v[webgl.M22] * v[webgl.M30] - v[webgl.M12] * v[webgl.M23] * v[webgl.M30] - v[webgl.M13] * v[webgl.M20] * v[webgl.M32] + + v[webgl.M10] * v[webgl.M23] * v[webgl.M32] + v[webgl.M12] * v[webgl.M20] * v[webgl.M33] - v[webgl.M10] * v[webgl.M22] * v[webgl.M33]; + t[webgl.M11] = v[webgl.M02] * v[webgl.M23] * v[webgl.M30] - v[webgl.M03] * v[webgl.M22] * v[webgl.M30] + v[webgl.M03] * v[webgl.M20] * v[webgl.M32] + - v[webgl.M00] * v[webgl.M23] * v[webgl.M32] - v[webgl.M02] * v[webgl.M20] * v[webgl.M33] + v[webgl.M00] * v[webgl.M22] * v[webgl.M33]; + t[webgl.M12] = v[webgl.M03] * v[webgl.M12] * v[webgl.M30] - v[webgl.M02] * v[webgl.M13] * v[webgl.M30] - v[webgl.M03] * v[webgl.M10] * v[webgl.M32] + + v[webgl.M00] * v[webgl.M13] * v[webgl.M32] + v[webgl.M02] * v[webgl.M10] * v[webgl.M33] - v[webgl.M00] * v[webgl.M12] * v[webgl.M33]; + t[webgl.M13] = v[webgl.M02] * v[webgl.M13] * v[webgl.M20] - v[webgl.M03] * v[webgl.M12] * v[webgl.M20] + v[webgl.M03] * v[webgl.M10] * v[webgl.M22] + - v[webgl.M00] * v[webgl.M13] * v[webgl.M22] - v[webgl.M02] * v[webgl.M10] * v[webgl.M23] + v[webgl.M00] * v[webgl.M12] * v[webgl.M23]; + t[webgl.M20] = v[webgl.M11] * v[webgl.M23] * v[webgl.M30] - v[webgl.M13] * v[webgl.M21] * v[webgl.M30] + v[webgl.M13] * v[webgl.M20] * v[webgl.M31] + - v[webgl.M10] * v[webgl.M23] * v[webgl.M31] - v[webgl.M11] * v[webgl.M20] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M33]; + t[webgl.M21] = v[webgl.M03] * v[webgl.M21] * v[webgl.M30] - v[webgl.M01] * v[webgl.M23] * v[webgl.M30] - v[webgl.M03] * v[webgl.M20] * v[webgl.M31] + + v[webgl.M00] * v[webgl.M23] * v[webgl.M31] + v[webgl.M01] * v[webgl.M20] * v[webgl.M33] - v[webgl.M00] * v[webgl.M21] * v[webgl.M33]; + t[webgl.M22] = v[webgl.M01] * v[webgl.M13] * v[webgl.M30] - v[webgl.M03] * v[webgl.M11] * v[webgl.M30] + v[webgl.M03] * v[webgl.M10] * v[webgl.M31] + - v[webgl.M00] * v[webgl.M13] * v[webgl.M31] - v[webgl.M01] * v[webgl.M10] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M33]; + t[webgl.M23] = v[webgl.M03] * v[webgl.M11] * v[webgl.M20] - v[webgl.M01] * v[webgl.M13] * v[webgl.M20] - v[webgl.M03] * v[webgl.M10] * v[webgl.M21] + + v[webgl.M00] * v[webgl.M13] * v[webgl.M21] + v[webgl.M01] * v[webgl.M10] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M23]; + t[webgl.M30] = v[webgl.M12] * v[webgl.M21] * v[webgl.M30] - v[webgl.M11] * v[webgl.M22] * v[webgl.M30] - v[webgl.M12] * v[webgl.M20] * v[webgl.M31] + + v[webgl.M10] * v[webgl.M22] * v[webgl.M31] + v[webgl.M11] * v[webgl.M20] * v[webgl.M32] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32]; + t[webgl.M31] = v[webgl.M01] * v[webgl.M22] * v[webgl.M30] - v[webgl.M02] * v[webgl.M21] * v[webgl.M30] + v[webgl.M02] * v[webgl.M20] * v[webgl.M31] + - v[webgl.M00] * v[webgl.M22] * v[webgl.M31] - v[webgl.M01] * v[webgl.M20] * v[webgl.M32] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32]; + t[webgl.M32] = v[webgl.M02] * v[webgl.M11] * v[webgl.M30] - v[webgl.M01] * v[webgl.M12] * v[webgl.M30] - v[webgl.M02] * v[webgl.M10] * v[webgl.M31] + + v[webgl.M00] * v[webgl.M12] * v[webgl.M31] + v[webgl.M01] * v[webgl.M10] * v[webgl.M32] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32]; + t[webgl.M33] = v[webgl.M01] * v[webgl.M12] * v[webgl.M20] - v[webgl.M02] * v[webgl.M11] * v[webgl.M20] + v[webgl.M02] * v[webgl.M10] * v[webgl.M21] + - v[webgl.M00] * v[webgl.M12] * v[webgl.M21] - v[webgl.M01] * v[webgl.M10] * v[webgl.M22] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22]; + v[webgl.M00] = t[webgl.M00] * inv_det; + v[webgl.M01] = t[webgl.M01] * inv_det; + v[webgl.M02] = t[webgl.M02] * inv_det; + v[webgl.M03] = t[webgl.M03] * inv_det; + v[webgl.M10] = t[webgl.M10] * inv_det; + v[webgl.M11] = t[webgl.M11] * inv_det; + v[webgl.M12] = t[webgl.M12] * inv_det; + v[webgl.M13] = t[webgl.M13] * inv_det; + v[webgl.M20] = t[webgl.M20] * inv_det; + v[webgl.M21] = t[webgl.M21] * inv_det; + v[webgl.M22] = t[webgl.M22] * inv_det; + v[webgl.M23] = t[webgl.M23] * inv_det; + v[webgl.M30] = t[webgl.M30] * inv_det; + v[webgl.M31] = t[webgl.M31] * inv_det; + v[webgl.M32] = t[webgl.M32] * inv_det; + v[webgl.M33] = t[webgl.M33] * inv_det; + return this; + }; + Matrix4.prototype.determinant = function () { + var v = this.values; + return v[webgl.M30] * v[webgl.M21] * v[webgl.M12] * v[webgl.M03] - v[webgl.M20] * v[webgl.M31] * v[webgl.M12] * v[webgl.M03] - v[webgl.M30] * v[webgl.M11] * v[webgl.M22] * v[webgl.M03] + + v[webgl.M10] * v[webgl.M31] * v[webgl.M22] * v[webgl.M03] + v[webgl.M20] * v[webgl.M11] * v[webgl.M32] * v[webgl.M03] - v[webgl.M10] * v[webgl.M21] * v[webgl.M32] * v[webgl.M03] + - v[webgl.M30] * v[webgl.M21] * v[webgl.M02] * v[webgl.M13] + v[webgl.M20] * v[webgl.M31] * v[webgl.M02] * v[webgl.M13] + v[webgl.M30] * v[webgl.M01] * v[webgl.M22] * v[webgl.M13] + - v[webgl.M00] * v[webgl.M31] * v[webgl.M22] * v[webgl.M13] - v[webgl.M20] * v[webgl.M01] * v[webgl.M32] * v[webgl.M13] + v[webgl.M00] * v[webgl.M21] * v[webgl.M32] * v[webgl.M13] + + v[webgl.M30] * v[webgl.M11] * v[webgl.M02] * v[webgl.M23] - v[webgl.M10] * v[webgl.M31] * v[webgl.M02] * v[webgl.M23] - v[webgl.M30] * v[webgl.M01] * v[webgl.M12] * v[webgl.M23] + + v[webgl.M00] * v[webgl.M31] * v[webgl.M12] * v[webgl.M23] + v[webgl.M10] * v[webgl.M01] * v[webgl.M32] * v[webgl.M23] - v[webgl.M00] * v[webgl.M11] * v[webgl.M32] * v[webgl.M23] + - v[webgl.M20] * v[webgl.M11] * v[webgl.M02] * v[webgl.M33] + v[webgl.M10] * v[webgl.M21] * v[webgl.M02] * v[webgl.M33] + v[webgl.M20] * v[webgl.M01] * v[webgl.M12] * v[webgl.M33] + - v[webgl.M00] * v[webgl.M21] * v[webgl.M12] * v[webgl.M33] - v[webgl.M10] * v[webgl.M01] * v[webgl.M22] * v[webgl.M33] + v[webgl.M00] * v[webgl.M11] * v[webgl.M22] * v[webgl.M33]; + }; + Matrix4.prototype.translate = function (x, y, z) { + var v = this.values; + v[webgl.M03] += x; + v[webgl.M13] += y; + v[webgl.M23] += z; + return this; + }; + Matrix4.prototype.copy = function () { + return new Matrix4().set(this.values); + }; + Matrix4.prototype.projection = function (near, far, fovy, aspectRatio) { + this.identity(); + var l_fd = (1.0 / Math.tan((fovy * (Math.PI / 180)) / 2.0)); + var l_a1 = (far + near) / (near - far); + var l_a2 = (2 * far * near) / (near - far); + var v = this.values; + v[webgl.M00] = l_fd / aspectRatio; + v[webgl.M10] = 0; + v[webgl.M20] = 0; + v[webgl.M30] = 0; + v[webgl.M01] = 0; + v[webgl.M11] = l_fd; + v[webgl.M21] = 0; + v[webgl.M31] = 0; + v[webgl.M02] = 0; + v[webgl.M12] = 0; + v[webgl.M22] = l_a1; + v[webgl.M32] = -1; + v[webgl.M03] = 0; + v[webgl.M13] = 0; + v[webgl.M23] = l_a2; + v[webgl.M33] = 0; + return this; + }; + Matrix4.prototype.ortho2d = function (x, y, width, height) { + return this.ortho(x, x + width, y, y + height, 0, 1); + }; + Matrix4.prototype.ortho = function (left, right, bottom, top, near, far) { + this.identity(); + var x_orth = 2 / (right - left); + var y_orth = 2 / (top - bottom); + var z_orth = -2 / (far - near); + var tx = -(right + left) / (right - left); + var ty = -(top + bottom) / (top - bottom); + var tz = -(far + near) / (far - near); + var v = this.values; + v[webgl.M00] = x_orth; + v[webgl.M10] = 0; + v[webgl.M20] = 0; + v[webgl.M30] = 0; + v[webgl.M01] = 0; + v[webgl.M11] = y_orth; + v[webgl.M21] = 0; + v[webgl.M31] = 0; + v[webgl.M02] = 0; + v[webgl.M12] = 0; + v[webgl.M22] = z_orth; + v[webgl.M32] = 0; + v[webgl.M03] = tx; + v[webgl.M13] = ty; + v[webgl.M23] = tz; + v[webgl.M33] = 1; + return this; + }; + Matrix4.prototype.multiply = function (matrix) { + var t = this.temp; + var v = this.values; + var m = matrix.values; + t[webgl.M00] = v[webgl.M00] * m[webgl.M00] + v[webgl.M01] * m[webgl.M10] + v[webgl.M02] * m[webgl.M20] + v[webgl.M03] * m[webgl.M30]; + t[webgl.M01] = v[webgl.M00] * m[webgl.M01] + v[webgl.M01] * m[webgl.M11] + v[webgl.M02] * m[webgl.M21] + v[webgl.M03] * m[webgl.M31]; + t[webgl.M02] = v[webgl.M00] * m[webgl.M02] + v[webgl.M01] * m[webgl.M12] + v[webgl.M02] * m[webgl.M22] + v[webgl.M03] * m[webgl.M32]; + t[webgl.M03] = v[webgl.M00] * m[webgl.M03] + v[webgl.M01] * m[webgl.M13] + v[webgl.M02] * m[webgl.M23] + v[webgl.M03] * m[webgl.M33]; + t[webgl.M10] = v[webgl.M10] * m[webgl.M00] + v[webgl.M11] * m[webgl.M10] + v[webgl.M12] * m[webgl.M20] + v[webgl.M13] * m[webgl.M30]; + t[webgl.M11] = v[webgl.M10] * m[webgl.M01] + v[webgl.M11] * m[webgl.M11] + v[webgl.M12] * m[webgl.M21] + v[webgl.M13] * m[webgl.M31]; + t[webgl.M12] = v[webgl.M10] * m[webgl.M02] + v[webgl.M11] * m[webgl.M12] + v[webgl.M12] * m[webgl.M22] + v[webgl.M13] * m[webgl.M32]; + t[webgl.M13] = v[webgl.M10] * m[webgl.M03] + v[webgl.M11] * m[webgl.M13] + v[webgl.M12] * m[webgl.M23] + v[webgl.M13] * m[webgl.M33]; + t[webgl.M20] = v[webgl.M20] * m[webgl.M00] + v[webgl.M21] * m[webgl.M10] + v[webgl.M22] * m[webgl.M20] + v[webgl.M23] * m[webgl.M30]; + t[webgl.M21] = v[webgl.M20] * m[webgl.M01] + v[webgl.M21] * m[webgl.M11] + v[webgl.M22] * m[webgl.M21] + v[webgl.M23] * m[webgl.M31]; + t[webgl.M22] = v[webgl.M20] * m[webgl.M02] + v[webgl.M21] * m[webgl.M12] + v[webgl.M22] * m[webgl.M22] + v[webgl.M23] * m[webgl.M32]; + t[webgl.M23] = v[webgl.M20] * m[webgl.M03] + v[webgl.M21] * m[webgl.M13] + v[webgl.M22] * m[webgl.M23] + v[webgl.M23] * m[webgl.M33]; + t[webgl.M30] = v[webgl.M30] * m[webgl.M00] + v[webgl.M31] * m[webgl.M10] + v[webgl.M32] * m[webgl.M20] + v[webgl.M33] * m[webgl.M30]; + t[webgl.M31] = v[webgl.M30] * m[webgl.M01] + v[webgl.M31] * m[webgl.M11] + v[webgl.M32] * m[webgl.M21] + v[webgl.M33] * m[webgl.M31]; + t[webgl.M32] = v[webgl.M30] * m[webgl.M02] + v[webgl.M31] * m[webgl.M12] + v[webgl.M32] * m[webgl.M22] + v[webgl.M33] * m[webgl.M32]; + t[webgl.M33] = v[webgl.M30] * m[webgl.M03] + v[webgl.M31] * m[webgl.M13] + v[webgl.M32] * m[webgl.M23] + v[webgl.M33] * m[webgl.M33]; + return this.set(this.temp); + }; + Matrix4.prototype.multiplyLeft = function (matrix) { + var t = this.temp; + var v = this.values; + var m = matrix.values; + t[webgl.M00] = m[webgl.M00] * v[webgl.M00] + m[webgl.M01] * v[webgl.M10] + m[webgl.M02] * v[webgl.M20] + m[webgl.M03] * v[webgl.M30]; + t[webgl.M01] = m[webgl.M00] * v[webgl.M01] + m[webgl.M01] * v[webgl.M11] + m[webgl.M02] * v[webgl.M21] + m[webgl.M03] * v[webgl.M31]; + t[webgl.M02] = m[webgl.M00] * v[webgl.M02] + m[webgl.M01] * v[webgl.M12] + m[webgl.M02] * v[webgl.M22] + m[webgl.M03] * v[webgl.M32]; + t[webgl.M03] = m[webgl.M00] * v[webgl.M03] + m[webgl.M01] * v[webgl.M13] + m[webgl.M02] * v[webgl.M23] + m[webgl.M03] * v[webgl.M33]; + t[webgl.M10] = m[webgl.M10] * v[webgl.M00] + m[webgl.M11] * v[webgl.M10] + m[webgl.M12] * v[webgl.M20] + m[webgl.M13] * v[webgl.M30]; + t[webgl.M11] = m[webgl.M10] * v[webgl.M01] + m[webgl.M11] * v[webgl.M11] + m[webgl.M12] * v[webgl.M21] + m[webgl.M13] * v[webgl.M31]; + t[webgl.M12] = m[webgl.M10] * v[webgl.M02] + m[webgl.M11] * v[webgl.M12] + m[webgl.M12] * v[webgl.M22] + m[webgl.M13] * v[webgl.M32]; + t[webgl.M13] = m[webgl.M10] * v[webgl.M03] + m[webgl.M11] * v[webgl.M13] + m[webgl.M12] * v[webgl.M23] + m[webgl.M13] * v[webgl.M33]; + t[webgl.M20] = m[webgl.M20] * v[webgl.M00] + m[webgl.M21] * v[webgl.M10] + m[webgl.M22] * v[webgl.M20] + m[webgl.M23] * v[webgl.M30]; + t[webgl.M21] = m[webgl.M20] * v[webgl.M01] + m[webgl.M21] * v[webgl.M11] + m[webgl.M22] * v[webgl.M21] + m[webgl.M23] * v[webgl.M31]; + t[webgl.M22] = m[webgl.M20] * v[webgl.M02] + m[webgl.M21] * v[webgl.M12] + m[webgl.M22] * v[webgl.M22] + m[webgl.M23] * v[webgl.M32]; + t[webgl.M23] = m[webgl.M20] * v[webgl.M03] + m[webgl.M21] * v[webgl.M13] + m[webgl.M22] * v[webgl.M23] + m[webgl.M23] * v[webgl.M33]; + t[webgl.M30] = m[webgl.M30] * v[webgl.M00] + m[webgl.M31] * v[webgl.M10] + m[webgl.M32] * v[webgl.M20] + m[webgl.M33] * v[webgl.M30]; + t[webgl.M31] = m[webgl.M30] * v[webgl.M01] + m[webgl.M31] * v[webgl.M11] + m[webgl.M32] * v[webgl.M21] + m[webgl.M33] * v[webgl.M31]; + t[webgl.M32] = m[webgl.M30] * v[webgl.M02] + m[webgl.M31] * v[webgl.M12] + m[webgl.M32] * v[webgl.M22] + m[webgl.M33] * v[webgl.M32]; + t[webgl.M33] = m[webgl.M30] * v[webgl.M03] + m[webgl.M31] * v[webgl.M13] + m[webgl.M32] * v[webgl.M23] + m[webgl.M33] * v[webgl.M33]; + return this.set(this.temp); + }; + Matrix4.prototype.lookAt = function (position, direction, up) { + Matrix4.initTemps(); + var xAxis = Matrix4.xAxis, yAxis = Matrix4.yAxis, zAxis = Matrix4.zAxis; + zAxis.setFrom(direction).normalize(); + xAxis.setFrom(direction).normalize(); + xAxis.cross(up).normalize(); + yAxis.setFrom(xAxis).cross(zAxis).normalize(); + this.identity(); + var val = this.values; + val[webgl.M00] = xAxis.x; + val[webgl.M01] = xAxis.y; + val[webgl.M02] = xAxis.z; + val[webgl.M10] = yAxis.x; + val[webgl.M11] = yAxis.y; + val[webgl.M12] = yAxis.z; + val[webgl.M20] = -zAxis.x; + val[webgl.M21] = -zAxis.y; + val[webgl.M22] = -zAxis.z; + Matrix4.tmpMatrix.identity(); + Matrix4.tmpMatrix.values[webgl.M03] = -position.x; + Matrix4.tmpMatrix.values[webgl.M13] = -position.y; + Matrix4.tmpMatrix.values[webgl.M23] = -position.z; + this.multiply(Matrix4.tmpMatrix); + return this; + }; + Matrix4.initTemps = function () { + if (Matrix4.xAxis === null) + Matrix4.xAxis = new webgl.Vector3(); + if (Matrix4.yAxis === null) + Matrix4.yAxis = new webgl.Vector3(); + if (Matrix4.zAxis === null) + Matrix4.zAxis = new webgl.Vector3(); + }; + Matrix4.xAxis = null; + Matrix4.yAxis = null; + Matrix4.zAxis = null; + Matrix4.tmpMatrix = new Matrix4(); + return Matrix4; + }()); + webgl.Matrix4 = Matrix4; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Mesh = (function () { + function Mesh(context, attributes, maxVertices, maxIndices) { + this.attributes = attributes; + this.verticesLength = 0; + this.dirtyVertices = false; + this.indicesLength = 0; + this.dirtyIndices = false; + this.elementsPerVertex = 0; + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + this.elementsPerVertex = 0; + for (var i = 0; i < attributes.length; i++) { + this.elementsPerVertex += attributes[i].numElements; + } + this.vertices = new Float32Array(maxVertices * this.elementsPerVertex); + this.indices = new Uint16Array(maxIndices); + this.context.addRestorable(this); + } + Mesh.prototype.getAttributes = function () { return this.attributes; }; + Mesh.prototype.maxVertices = function () { return this.vertices.length / this.elementsPerVertex; }; + Mesh.prototype.numVertices = function () { return this.verticesLength / this.elementsPerVertex; }; + Mesh.prototype.setVerticesLength = function (length) { + this.dirtyVertices = true; + this.verticesLength = length; + }; + Mesh.prototype.getVertices = function () { return this.vertices; }; + Mesh.prototype.maxIndices = function () { return this.indices.length; }; + Mesh.prototype.numIndices = function () { return this.indicesLength; }; + Mesh.prototype.setIndicesLength = function (length) { + this.dirtyIndices = true; + this.indicesLength = length; + }; + Mesh.prototype.getIndices = function () { return this.indices; }; + ; + Mesh.prototype.getVertexSizeInFloats = function () { + var size = 0; + for (var i = 0; i < this.attributes.length; i++) { + var attribute = this.attributes[i]; + size += attribute.numElements; + } + return size; + }; + Mesh.prototype.setVertices = function (vertices) { + this.dirtyVertices = true; + if (vertices.length > this.vertices.length) + throw Error("Mesh can't store more than " + this.maxVertices() + " vertices"); + this.vertices.set(vertices, 0); + this.verticesLength = vertices.length; + }; + Mesh.prototype.setIndices = function (indices) { + this.dirtyIndices = true; + if (indices.length > this.indices.length) + throw Error("Mesh can't store more than " + this.maxIndices() + " indices"); + this.indices.set(indices, 0); + this.indicesLength = indices.length; + }; + Mesh.prototype.draw = function (shader, primitiveType) { + this.drawWithOffset(shader, primitiveType, 0, this.indicesLength > 0 ? this.indicesLength : this.verticesLength / this.elementsPerVertex); + }; + Mesh.prototype.drawWithOffset = function (shader, primitiveType, offset, count) { + var gl = this.context.gl; + if (this.dirtyVertices || this.dirtyIndices) + this.update(); + this.bind(shader); + if (this.indicesLength > 0) { + gl.drawElements(primitiveType, count, gl.UNSIGNED_SHORT, offset * 2); + } + else { + gl.drawArrays(primitiveType, offset, count); + } + this.unbind(shader); + }; + Mesh.prototype.bind = function (shader) { + var gl = this.context.gl; + gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer); + var offset = 0; + for (var i = 0; i < this.attributes.length; i++) { + var attrib = this.attributes[i]; + var location_1 = shader.getAttributeLocation(attrib.name); + gl.enableVertexAttribArray(location_1); + gl.vertexAttribPointer(location_1, attrib.numElements, gl.FLOAT, false, this.elementsPerVertex * 4, offset * 4); + offset += attrib.numElements; + } + if (this.indicesLength > 0) + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer); + }; + Mesh.prototype.unbind = function (shader) { + var gl = this.context.gl; + for (var i = 0; i < this.attributes.length; i++) { + var attrib = this.attributes[i]; + var location_2 = shader.getAttributeLocation(attrib.name); + gl.disableVertexAttribArray(location_2); + } + gl.bindBuffer(gl.ARRAY_BUFFER, null); + if (this.indicesLength > 0) + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null); + }; + Mesh.prototype.update = function () { + var gl = this.context.gl; + if (this.dirtyVertices) { + if (!this.verticesBuffer) { + this.verticesBuffer = gl.createBuffer(); + } + gl.bindBuffer(gl.ARRAY_BUFFER, this.verticesBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.vertices.subarray(0, this.verticesLength), gl.DYNAMIC_DRAW); + this.dirtyVertices = false; + } + if (this.dirtyIndices) { + if (!this.indicesBuffer) { + this.indicesBuffer = gl.createBuffer(); + } + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices.subarray(0, this.indicesLength), gl.DYNAMIC_DRAW); + this.dirtyIndices = false; + } + }; + Mesh.prototype.restore = function () { + this.verticesBuffer = null; + this.indicesBuffer = null; + this.update(); + }; + Mesh.prototype.dispose = function () { + this.context.removeRestorable(this); + var gl = this.context.gl; + gl.deleteBuffer(this.verticesBuffer); + gl.deleteBuffer(this.indicesBuffer); + }; + return Mesh; + }()); + webgl.Mesh = Mesh; + var VertexAttribute = (function () { + function VertexAttribute(name, type, numElements) { + this.name = name; + this.type = type; + this.numElements = numElements; + } + return VertexAttribute; + }()); + webgl.VertexAttribute = VertexAttribute; + var Position2Attribute = (function (_super) { + __extends(Position2Attribute, _super); + function Position2Attribute() { + return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 2) || this; + } + return Position2Attribute; + }(VertexAttribute)); + webgl.Position2Attribute = Position2Attribute; + var Position3Attribute = (function (_super) { + __extends(Position3Attribute, _super); + function Position3Attribute() { + return _super.call(this, webgl.Shader.POSITION, VertexAttributeType.Float, 3) || this; + } + return Position3Attribute; + }(VertexAttribute)); + webgl.Position3Attribute = Position3Attribute; + var TexCoordAttribute = (function (_super) { + __extends(TexCoordAttribute, _super); + function TexCoordAttribute(unit) { + if (unit === void 0) { unit = 0; } + return _super.call(this, webgl.Shader.TEXCOORDS + (unit == 0 ? "" : unit), VertexAttributeType.Float, 2) || this; + } + return TexCoordAttribute; + }(VertexAttribute)); + webgl.TexCoordAttribute = TexCoordAttribute; + var ColorAttribute = (function (_super) { + __extends(ColorAttribute, _super); + function ColorAttribute() { + return _super.call(this, webgl.Shader.COLOR, VertexAttributeType.Float, 4) || this; + } + return ColorAttribute; + }(VertexAttribute)); + webgl.ColorAttribute = ColorAttribute; + var Color2Attribute = (function (_super) { + __extends(Color2Attribute, _super); + function Color2Attribute() { + return _super.call(this, webgl.Shader.COLOR2, VertexAttributeType.Float, 4) || this; + } + return Color2Attribute; + }(VertexAttribute)); + webgl.Color2Attribute = Color2Attribute; + var VertexAttributeType; + (function (VertexAttributeType) { + VertexAttributeType[VertexAttributeType["Float"] = 0] = "Float"; + })(VertexAttributeType = webgl.VertexAttributeType || (webgl.VertexAttributeType = {})); + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var PolygonBatcher = (function () { + function PolygonBatcher(context, twoColorTint, maxVertices) { + if (twoColorTint === void 0) { twoColorTint = true; } + if (maxVertices === void 0) { maxVertices = 10920; } + this.isDrawing = false; + this.shader = null; + this.lastTexture = null; + this.verticesLength = 0; + this.indicesLength = 0; + if (maxVertices > 10920) + throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices); + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + var attributes = twoColorTint ? + [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute(), new webgl.Color2Attribute()] : + [new webgl.Position2Attribute(), new webgl.ColorAttribute(), new webgl.TexCoordAttribute()]; + this.mesh = new webgl.Mesh(context, attributes, maxVertices, maxVertices * 3); + this.srcBlend = this.context.gl.SRC_ALPHA; + this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA; + } + PolygonBatcher.prototype.begin = function (shader) { + var gl = this.context.gl; + if (this.isDrawing) + throw new Error("PolygonBatch is already drawing. Call PolygonBatch.end() before calling PolygonBatch.begin()"); + this.drawCalls = 0; + this.shader = shader; + this.lastTexture = null; + this.isDrawing = true; + gl.enable(gl.BLEND); + gl.blendFunc(this.srcBlend, this.dstBlend); + }; + PolygonBatcher.prototype.setBlendMode = function (srcBlend, dstBlend) { + var gl = this.context.gl; + this.srcBlend = srcBlend; + this.dstBlend = dstBlend; + if (this.isDrawing) { + this.flush(); + gl.blendFunc(this.srcBlend, this.dstBlend); + } + }; + PolygonBatcher.prototype.draw = function (texture, vertices, indices) { + if (texture != this.lastTexture) { + this.flush(); + this.lastTexture = texture; + } + else if (this.verticesLength + vertices.length > this.mesh.getVertices().length || + this.indicesLength + indices.length > this.mesh.getIndices().length) { + this.flush(); + } + var indexStart = this.mesh.numVertices(); + this.mesh.getVertices().set(vertices, this.verticesLength); + this.verticesLength += vertices.length; + this.mesh.setVerticesLength(this.verticesLength); + var indicesArray = this.mesh.getIndices(); + for (var i = this.indicesLength, j = 0; j < indices.length; i++, j++) + indicesArray[i] = indices[j] + indexStart; + this.indicesLength += indices.length; + this.mesh.setIndicesLength(this.indicesLength); + }; + PolygonBatcher.prototype.flush = function () { + var gl = this.context.gl; + if (this.verticesLength == 0) + return; + this.lastTexture.bind(); + this.mesh.draw(this.shader, gl.TRIANGLES); + this.verticesLength = 0; + this.indicesLength = 0; + this.mesh.setVerticesLength(0); + this.mesh.setIndicesLength(0); + this.drawCalls++; + }; + PolygonBatcher.prototype.end = function () { + var gl = this.context.gl; + if (!this.isDrawing) + throw new Error("PolygonBatch is not drawing. Call PolygonBatch.begin() before calling PolygonBatch.end()"); + if (this.verticesLength > 0 || this.indicesLength > 0) + this.flush(); + this.shader = null; + this.lastTexture = null; + this.isDrawing = false; + gl.disable(gl.BLEND); + }; + PolygonBatcher.prototype.getDrawCalls = function () { return this.drawCalls; }; + PolygonBatcher.prototype.dispose = function () { + this.mesh.dispose(); + }; + return PolygonBatcher; + }()); + webgl.PolygonBatcher = PolygonBatcher; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var SceneRenderer = (function () { + function SceneRenderer(canvas, context, twoColorTint) { + if (twoColorTint === void 0) { twoColorTint = true; } + this.twoColorTint = false; + this.activeRenderer = null; + this.QUAD = [ + 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, + ]; + this.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0]; + this.WHITE = new spine.Color(1, 1, 1, 1); + this.canvas = canvas; + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + this.twoColorTint = twoColorTint; + this.camera = new webgl.OrthoCamera(canvas.width, canvas.height); + this.batcherShader = twoColorTint ? webgl.Shader.newTwoColoredTextured(this.context) : webgl.Shader.newColoredTextured(this.context); + this.batcher = new webgl.PolygonBatcher(this.context, twoColorTint); + this.shapesShader = webgl.Shader.newColored(this.context); + this.shapes = new webgl.ShapeRenderer(this.context); + this.skeletonRenderer = new webgl.SkeletonRenderer(this.context, twoColorTint); + this.skeletonDebugRenderer = new webgl.SkeletonDebugRenderer(this.context); + } + SceneRenderer.prototype.begin = function () { + this.camera.update(); + this.enableRenderer(this.batcher); + }; + SceneRenderer.prototype.drawSkeleton = function (skeleton, premultipliedAlpha, slotRangeStart, slotRangeEnd) { + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + if (slotRangeStart === void 0) { slotRangeStart = -1; } + if (slotRangeEnd === void 0) { slotRangeEnd = -1; } + this.enableRenderer(this.batcher); + this.skeletonRenderer.premultipliedAlpha = premultipliedAlpha; + this.skeletonRenderer.draw(this.batcher, skeleton, slotRangeStart, slotRangeEnd); + }; + SceneRenderer.prototype.drawSkeletonDebug = function (skeleton, premultipliedAlpha, ignoredBones) { + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + if (ignoredBones === void 0) { ignoredBones = null; } + this.enableRenderer(this.shapes); + this.skeletonDebugRenderer.premultipliedAlpha = premultipliedAlpha; + this.skeletonDebugRenderer.draw(this.shapes, skeleton, ignoredBones); + }; + SceneRenderer.prototype.drawTexture = function (texture, x, y, width, height, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.batcher); + if (color === null) + color = this.WHITE; + var quad = this.QUAD; + var i = 0; + quad[i++] = x; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 0; + quad[i++] = 1; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 1; + quad[i++] = 1; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 1; + quad[i++] = 0; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 0; + quad[i++] = 0; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + this.batcher.draw(texture, quad, this.QUAD_TRIANGLES); + }; + SceneRenderer.prototype.drawTextureUV = function (texture, x, y, width, height, u, v, u2, v2, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.batcher); + if (color === null) + color = this.WHITE; + var quad = this.QUAD; + var i = 0; + quad[i++] = x; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = u; + quad[i++] = v; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = u2; + quad[i++] = v; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = u2; + quad[i++] = v2; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = u; + quad[i++] = v2; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + this.batcher.draw(texture, quad, this.QUAD_TRIANGLES); + }; + SceneRenderer.prototype.drawTextureRotated = function (texture, x, y, width, height, pivotX, pivotY, angle, color, premultipliedAlpha) { + if (color === void 0) { color = null; } + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + this.enableRenderer(this.batcher); + if (color === null) + color = this.WHITE; + var quad = this.QUAD; + var worldOriginX = x + pivotX; + var worldOriginY = y + pivotY; + var fx = -pivotX; + var fy = -pivotY; + var fx2 = width - pivotX; + var fy2 = height - pivotY; + var p1x = fx; + var p1y = fy; + var p2x = fx; + var p2y = fy2; + var p3x = fx2; + var p3y = fy2; + var p4x = fx2; + var p4y = fy; + var x1 = 0; + var y1 = 0; + var x2 = 0; + var y2 = 0; + var x3 = 0; + var y3 = 0; + var x4 = 0; + var y4 = 0; + if (angle != 0) { + var cos = spine.MathUtils.cosDeg(angle); + var sin = spine.MathUtils.sinDeg(angle); + x1 = cos * p1x - sin * p1y; + y1 = sin * p1x + cos * p1y; + x4 = cos * p2x - sin * p2y; + y4 = sin * p2x + cos * p2y; + x3 = cos * p3x - sin * p3y; + y3 = sin * p3x + cos * p3y; + x2 = x3 + (x1 - x4); + y2 = y3 + (y1 - y4); + } + else { + x1 = p1x; + y1 = p1y; + x4 = p2x; + y4 = p2y; + x3 = p3x; + y3 = p3y; + x2 = p4x; + y2 = p4y; + } + x1 += worldOriginX; + y1 += worldOriginY; + x2 += worldOriginX; + y2 += worldOriginY; + x3 += worldOriginX; + y3 += worldOriginY; + x4 += worldOriginX; + y4 += worldOriginY; + var i = 0; + quad[i++] = x1; + quad[i++] = y1; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 0; + quad[i++] = 1; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x2; + quad[i++] = y2; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 1; + quad[i++] = 1; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x3; + quad[i++] = y3; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 1; + quad[i++] = 0; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x4; + quad[i++] = y4; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = 0; + quad[i++] = 0; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + this.batcher.draw(texture, quad, this.QUAD_TRIANGLES); + }; + SceneRenderer.prototype.drawRegion = function (region, x, y, width, height, color, premultipliedAlpha) { + if (color === void 0) { color = null; } + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + this.enableRenderer(this.batcher); + if (color === null) + color = this.WHITE; + var quad = this.QUAD; + var i = 0; + quad[i++] = x; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = region.u; + quad[i++] = region.v2; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = region.u2; + quad[i++] = region.v2; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x + width; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = region.u2; + quad[i++] = region.v; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + quad[i++] = x; + quad[i++] = y + height; + quad[i++] = color.r; + quad[i++] = color.g; + quad[i++] = color.b; + quad[i++] = color.a; + quad[i++] = region.u; + quad[i++] = region.v; + if (this.twoColorTint) { + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + quad[i++] = 0; + } + this.batcher.draw(region.texture, quad, this.QUAD_TRIANGLES); + }; + SceneRenderer.prototype.line = function (x, y, x2, y2, color, color2) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + this.enableRenderer(this.shapes); + this.shapes.line(x, y, x2, y2, color); + }; + SceneRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + if (color3 === void 0) { color3 = null; } + this.enableRenderer(this.shapes); + this.shapes.triangle(filled, x, y, x2, y2, x3, y3, color, color2, color3); + }; + SceneRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + if (color3 === void 0) { color3 = null; } + if (color4 === void 0) { color4 = null; } + this.enableRenderer(this.shapes); + this.shapes.quad(filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4); + }; + SceneRenderer.prototype.rect = function (filled, x, y, width, height, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.shapes); + this.shapes.rect(filled, x, y, width, height, color); + }; + SceneRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.shapes); + this.shapes.rectLine(filled, x1, y1, x2, y2, width, color); + }; + SceneRenderer.prototype.polygon = function (polygonVertices, offset, count, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.shapes); + this.shapes.polygon(polygonVertices, offset, count, color); + }; + SceneRenderer.prototype.circle = function (filled, x, y, radius, color, segments) { + if (color === void 0) { color = null; } + if (segments === void 0) { segments = 0; } + this.enableRenderer(this.shapes); + this.shapes.circle(filled, x, y, radius, color, segments); + }; + SceneRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) { + if (color === void 0) { color = null; } + this.enableRenderer(this.shapes); + this.shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color); + }; + SceneRenderer.prototype.end = function () { + if (this.activeRenderer === this.batcher) + this.batcher.end(); + else if (this.activeRenderer === this.shapes) + this.shapes.end(); + this.activeRenderer = null; + }; + SceneRenderer.prototype.resize = function (resizeMode) { + var canvas = this.canvas; + var w = canvas.clientWidth; + var h = canvas.clientHeight; + if (canvas.width != w || canvas.height != h) { + canvas.width = w; + canvas.height = h; + } + this.context.gl.viewport(0, 0, canvas.width, canvas.height); + if (resizeMode === ResizeMode.Stretch) { + } + else if (resizeMode === ResizeMode.Expand) { + this.camera.setViewport(w, h); + } + else if (resizeMode === ResizeMode.Fit) { + var sourceWidth = canvas.width, sourceHeight = canvas.height; + var targetWidth = this.camera.viewportWidth, targetHeight = this.camera.viewportHeight; + var targetRatio = targetHeight / targetWidth; + var sourceRatio = sourceHeight / sourceWidth; + var scale = targetRatio < sourceRatio ? targetWidth / sourceWidth : targetHeight / sourceHeight; + this.camera.viewportWidth = sourceWidth * scale; + this.camera.viewportHeight = sourceHeight * scale; + } + this.camera.update(); + }; + SceneRenderer.prototype.enableRenderer = function (renderer) { + if (this.activeRenderer === renderer) + return; + this.end(); + if (renderer instanceof webgl.PolygonBatcher) { + this.batcherShader.bind(); + this.batcherShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values); + this.batcherShader.setUniformi("u_texture", 0); + this.batcher.begin(this.batcherShader); + this.activeRenderer = this.batcher; + } + else if (renderer instanceof webgl.ShapeRenderer) { + this.shapesShader.bind(); + this.shapesShader.setUniform4x4f(webgl.Shader.MVP_MATRIX, this.camera.projectionView.values); + this.shapes.begin(this.shapesShader); + this.activeRenderer = this.shapes; + } + else { + this.activeRenderer = this.skeletonDebugRenderer; + } + }; + SceneRenderer.prototype.dispose = function () { + this.batcher.dispose(); + this.batcherShader.dispose(); + this.shapes.dispose(); + this.shapesShader.dispose(); + this.skeletonDebugRenderer.dispose(); + }; + return SceneRenderer; + }()); + webgl.SceneRenderer = SceneRenderer; + var ResizeMode; + (function (ResizeMode) { + ResizeMode[ResizeMode["Stretch"] = 0] = "Stretch"; + ResizeMode[ResizeMode["Expand"] = 1] = "Expand"; + ResizeMode[ResizeMode["Fit"] = 2] = "Fit"; + })(ResizeMode = webgl.ResizeMode || (webgl.ResizeMode = {})); + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Shader = (function () { + function Shader(context, vertexShader, fragmentShader) { + this.vertexShader = vertexShader; + this.fragmentShader = fragmentShader; + this.vs = null; + this.fs = null; + this.program = null; + this.tmp2x2 = new Float32Array(2 * 2); + this.tmp3x3 = new Float32Array(3 * 3); + this.tmp4x4 = new Float32Array(4 * 4); + this.vsSource = vertexShader; + this.fsSource = fragmentShader; + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + this.context.addRestorable(this); + this.compile(); + } + Shader.prototype.getProgram = function () { return this.program; }; + Shader.prototype.getVertexShader = function () { return this.vertexShader; }; + Shader.prototype.getFragmentShader = function () { return this.fragmentShader; }; + Shader.prototype.getVertexShaderSource = function () { return this.vsSource; }; + Shader.prototype.getFragmentSource = function () { return this.fsSource; }; + Shader.prototype.compile = function () { + var gl = this.context.gl; + try { + this.vs = this.compileShader(gl.VERTEX_SHADER, this.vertexShader); + this.fs = this.compileShader(gl.FRAGMENT_SHADER, this.fragmentShader); + this.program = this.compileProgram(this.vs, this.fs); + } + catch (e) { + this.dispose(); + throw e; + } + }; + Shader.prototype.compileShader = function (type, source) { + var gl = this.context.gl; + var shader = gl.createShader(type); + gl.shaderSource(shader, source); + gl.compileShader(shader); + if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { + var error = "Couldn't compile shader: " + gl.getShaderInfoLog(shader); + gl.deleteShader(shader); + if (!gl.isContextLost()) + throw new Error(error); + } + return shader; + }; + Shader.prototype.compileProgram = function (vs, fs) { + var gl = this.context.gl; + var program = gl.createProgram(); + gl.attachShader(program, vs); + gl.attachShader(program, fs); + gl.linkProgram(program); + if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { + var error = "Couldn't compile shader program: " + gl.getProgramInfoLog(program); + gl.deleteProgram(program); + if (!gl.isContextLost()) + throw new Error(error); + } + return program; + }; + Shader.prototype.restore = function () { + this.compile(); + }; + Shader.prototype.bind = function () { + this.context.gl.useProgram(this.program); + }; + Shader.prototype.unbind = function () { + this.context.gl.useProgram(null); + }; + Shader.prototype.setUniformi = function (uniform, value) { + this.context.gl.uniform1i(this.getUniformLocation(uniform), value); + }; + Shader.prototype.setUniformf = function (uniform, value) { + this.context.gl.uniform1f(this.getUniformLocation(uniform), value); + }; + Shader.prototype.setUniform2f = function (uniform, value, value2) { + this.context.gl.uniform2f(this.getUniformLocation(uniform), value, value2); + }; + Shader.prototype.setUniform3f = function (uniform, value, value2, value3) { + this.context.gl.uniform3f(this.getUniformLocation(uniform), value, value2, value3); + }; + Shader.prototype.setUniform4f = function (uniform, value, value2, value3, value4) { + this.context.gl.uniform4f(this.getUniformLocation(uniform), value, value2, value3, value4); + }; + Shader.prototype.setUniform2x2f = function (uniform, value) { + var gl = this.context.gl; + this.tmp2x2.set(value); + gl.uniformMatrix2fv(this.getUniformLocation(uniform), false, this.tmp2x2); + }; + Shader.prototype.setUniform3x3f = function (uniform, value) { + var gl = this.context.gl; + this.tmp3x3.set(value); + gl.uniformMatrix3fv(this.getUniformLocation(uniform), false, this.tmp3x3); + }; + Shader.prototype.setUniform4x4f = function (uniform, value) { + var gl = this.context.gl; + this.tmp4x4.set(value); + gl.uniformMatrix4fv(this.getUniformLocation(uniform), false, this.tmp4x4); + }; + Shader.prototype.getUniformLocation = function (uniform) { + var gl = this.context.gl; + var location = gl.getUniformLocation(this.program, uniform); + if (!location && !gl.isContextLost()) + throw new Error("Couldn't find location for uniform " + uniform); + return location; + }; + Shader.prototype.getAttributeLocation = function (attribute) { + var gl = this.context.gl; + var location = gl.getAttribLocation(this.program, attribute); + if (location == -1 && !gl.isContextLost()) + throw new Error("Couldn't find location for attribute " + attribute); + return location; + }; + Shader.prototype.dispose = function () { + this.context.removeRestorable(this); + var gl = this.context.gl; + if (this.vs) { + gl.deleteShader(this.vs); + this.vs = null; + } + if (this.fs) { + gl.deleteShader(this.fs); + this.fs = null; + } + if (this.program) { + gl.deleteProgram(this.program); + this.program = null; + } + }; + Shader.newColoredTextured = function (context) { + var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_color;\n\t\t\t\tvarying vec2 v_texCoords;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_color = " + Shader.COLOR + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t"; + var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_color;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tgl_FragColor = v_color * texture2D(u_texture, v_texCoords);\n\t\t\t\t}\n\t\t\t"; + return new Shader(context, vs, fs); + }; + Shader.newTwoColoredTextured = function (context) { + var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR2 + ";\n\t\t\t\tattribute vec2 " + Shader.TEXCOORDS + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_light;\n\t\t\t\tvarying vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_light = " + Shader.COLOR + ";\n\t\t\t\t\tv_dark = " + Shader.COLOR2 + ";\n\t\t\t\t\tv_texCoords = " + Shader.TEXCOORDS + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t"; + var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_light;\n\t\t\t\tvarying LOWP vec4 v_dark;\n\t\t\t\tvarying vec2 v_texCoords;\n\t\t\t\tuniform sampler2D u_texture;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tvec4 texColor = texture2D(u_texture, v_texCoords);\n\t\t\t\t\tgl_FragColor.a = texColor.a * v_light.a;\n\t\t\t\t\tgl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n\t\t\t\t}\n\t\t\t"; + return new Shader(context, vs, fs); + }; + Shader.newColored = function (context) { + var vs = "\n\t\t\t\tattribute vec4 " + Shader.POSITION + ";\n\t\t\t\tattribute vec4 " + Shader.COLOR + ";\n\t\t\t\tuniform mat4 " + Shader.MVP_MATRIX + ";\n\t\t\t\tvarying vec4 v_color;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tv_color = " + Shader.COLOR + ";\n\t\t\t\t\tgl_Position = " + Shader.MVP_MATRIX + " * " + Shader.POSITION + ";\n\t\t\t\t}\n\t\t\t"; + var fs = "\n\t\t\t\t#ifdef GL_ES\n\t\t\t\t\t#define LOWP lowp\n\t\t\t\t\tprecision mediump float;\n\t\t\t\t#else\n\t\t\t\t\t#define LOWP\n\t\t\t\t#endif\n\t\t\t\tvarying LOWP vec4 v_color;\n\n\t\t\t\tvoid main () {\n\t\t\t\t\tgl_FragColor = v_color;\n\t\t\t\t}\n\t\t\t"; + return new Shader(context, vs, fs); + }; + Shader.MVP_MATRIX = "u_projTrans"; + Shader.POSITION = "a_position"; + Shader.COLOR = "a_color"; + Shader.COLOR2 = "a_color2"; + Shader.TEXCOORDS = "a_texCoords"; + Shader.SAMPLER = "u_texture"; + return Shader; + }()); + webgl.Shader = Shader; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var ShapeRenderer = (function () { + function ShapeRenderer(context, maxVertices) { + if (maxVertices === void 0) { maxVertices = 10920; } + this.isDrawing = false; + this.shapeType = ShapeType.Filled; + this.color = new spine.Color(1, 1, 1, 1); + this.vertexIndex = 0; + this.tmp = new spine.Vector2(); + if (maxVertices > 10920) + throw new Error("Can't have more than 10920 triangles per batch: " + maxVertices); + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + this.mesh = new webgl.Mesh(context, [new webgl.Position2Attribute(), new webgl.ColorAttribute()], maxVertices, 0); + this.srcBlend = this.context.gl.SRC_ALPHA; + this.dstBlend = this.context.gl.ONE_MINUS_SRC_ALPHA; + } + ShapeRenderer.prototype.begin = function (shader) { + if (this.isDrawing) + throw new Error("ShapeRenderer.begin() has already been called"); + this.shader = shader; + this.vertexIndex = 0; + this.isDrawing = true; + var gl = this.context.gl; + gl.enable(gl.BLEND); + gl.blendFunc(this.srcBlend, this.dstBlend); + }; + ShapeRenderer.prototype.setBlendMode = function (srcBlend, dstBlend) { + var gl = this.context.gl; + this.srcBlend = srcBlend; + this.dstBlend = dstBlend; + if (this.isDrawing) { + this.flush(); + gl.blendFunc(this.srcBlend, this.dstBlend); + } + }; + ShapeRenderer.prototype.setColor = function (color) { + this.color.setFromColor(color); + }; + ShapeRenderer.prototype.setColorWith = function (r, g, b, a) { + this.color.set(r, g, b, a); + }; + ShapeRenderer.prototype.point = function (x, y, color) { + if (color === void 0) { color = null; } + this.check(ShapeType.Point, 1); + if (color === null) + color = this.color; + this.vertex(x, y, color); + }; + ShapeRenderer.prototype.line = function (x, y, x2, y2, color) { + if (color === void 0) { color = null; } + this.check(ShapeType.Line, 2); + var vertices = this.mesh.getVertices(); + var idx = this.vertexIndex; + if (color === null) + color = this.color; + this.vertex(x, y, color); + this.vertex(x2, y2, color); + }; + ShapeRenderer.prototype.triangle = function (filled, x, y, x2, y2, x3, y3, color, color2, color3) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + if (color3 === void 0) { color3 = null; } + this.check(filled ? ShapeType.Filled : ShapeType.Line, 3); + var vertices = this.mesh.getVertices(); + var idx = this.vertexIndex; + if (color === null) + color = this.color; + if (color2 === null) + color2 = this.color; + if (color3 === null) + color3 = this.color; + if (filled) { + this.vertex(x, y, color); + this.vertex(x2, y2, color2); + this.vertex(x3, y3, color3); + } + else { + this.vertex(x, y, color); + this.vertex(x2, y2, color2); + this.vertex(x2, y2, color); + this.vertex(x3, y3, color2); + this.vertex(x3, y3, color); + this.vertex(x, y, color2); + } + }; + ShapeRenderer.prototype.quad = function (filled, x, y, x2, y2, x3, y3, x4, y4, color, color2, color3, color4) { + if (color === void 0) { color = null; } + if (color2 === void 0) { color2 = null; } + if (color3 === void 0) { color3 = null; } + if (color4 === void 0) { color4 = null; } + this.check(filled ? ShapeType.Filled : ShapeType.Line, 3); + var vertices = this.mesh.getVertices(); + var idx = this.vertexIndex; + if (color === null) + color = this.color; + if (color2 === null) + color2 = this.color; + if (color3 === null) + color3 = this.color; + if (color4 === null) + color4 = this.color; + if (filled) { + this.vertex(x, y, color); + this.vertex(x2, y2, color2); + this.vertex(x3, y3, color3); + this.vertex(x3, y3, color3); + this.vertex(x4, y4, color4); + this.vertex(x, y, color); + } + else { + this.vertex(x, y, color); + this.vertex(x2, y2, color2); + this.vertex(x2, y2, color2); + this.vertex(x3, y3, color3); + this.vertex(x3, y3, color3); + this.vertex(x4, y4, color4); + this.vertex(x4, y4, color4); + this.vertex(x, y, color); + } + }; + ShapeRenderer.prototype.rect = function (filled, x, y, width, height, color) { + if (color === void 0) { color = null; } + this.quad(filled, x, y, x + width, y, x + width, y + height, x, y + height, color, color, color, color); + }; + ShapeRenderer.prototype.rectLine = function (filled, x1, y1, x2, y2, width, color) { + if (color === void 0) { color = null; } + this.check(filled ? ShapeType.Filled : ShapeType.Line, 8); + if (color === null) + color = this.color; + var t = this.tmp.set(y2 - y1, x1 - x2); + t.normalize(); + width *= 0.5; + var tx = t.x * width; + var ty = t.y * width; + if (!filled) { + this.vertex(x1 + tx, y1 + ty, color); + this.vertex(x1 - tx, y1 - ty, color); + this.vertex(x2 + tx, y2 + ty, color); + this.vertex(x2 - tx, y2 - ty, color); + this.vertex(x2 + tx, y2 + ty, color); + this.vertex(x1 + tx, y1 + ty, color); + this.vertex(x2 - tx, y2 - ty, color); + this.vertex(x1 - tx, y1 - ty, color); + } + else { + this.vertex(x1 + tx, y1 + ty, color); + this.vertex(x1 - tx, y1 - ty, color); + this.vertex(x2 + tx, y2 + ty, color); + this.vertex(x2 - tx, y2 - ty, color); + this.vertex(x2 + tx, y2 + ty, color); + this.vertex(x1 - tx, y1 - ty, color); + } + }; + ShapeRenderer.prototype.x = function (x, y, size) { + this.line(x - size, y - size, x + size, y + size); + this.line(x - size, y + size, x + size, y - size); + }; + ShapeRenderer.prototype.polygon = function (polygonVertices, offset, count, color) { + if (color === void 0) { color = null; } + if (count < 3) + throw new Error("Polygon must contain at least 3 vertices"); + this.check(ShapeType.Line, count * 2); + if (color === null) + color = this.color; + var vertices = this.mesh.getVertices(); + var idx = this.vertexIndex; + offset <<= 1; + count <<= 1; + var firstX = polygonVertices[offset]; + var firstY = polygonVertices[offset + 1]; + var last = offset + count; + for (var i = offset, n = offset + count - 2; i < n; i += 2) { + var x1 = polygonVertices[i]; + var y1 = polygonVertices[i + 1]; + var x2 = 0; + var y2 = 0; + if (i + 2 >= last) { + x2 = firstX; + y2 = firstY; + } + else { + x2 = polygonVertices[i + 2]; + y2 = polygonVertices[i + 3]; + } + this.vertex(x1, y1, color); + this.vertex(x2, y2, color); + } + }; + ShapeRenderer.prototype.circle = function (filled, x, y, radius, color, segments) { + if (color === void 0) { color = null; } + if (segments === void 0) { segments = 0; } + if (segments === 0) + segments = Math.max(1, (6 * spine.MathUtils.cbrt(radius)) | 0); + if (segments <= 0) + throw new Error("segments must be > 0."); + if (color === null) + color = this.color; + var angle = 2 * spine.MathUtils.PI / segments; + var cos = Math.cos(angle); + var sin = Math.sin(angle); + var cx = radius, cy = 0; + if (!filled) { + this.check(ShapeType.Line, segments * 2 + 2); + for (var i = 0; i < segments; i++) { + this.vertex(x + cx, y + cy, color); + var temp_1 = cx; + cx = cos * cx - sin * cy; + cy = sin * temp_1 + cos * cy; + this.vertex(x + cx, y + cy, color); + } + this.vertex(x + cx, y + cy, color); + } + else { + this.check(ShapeType.Filled, segments * 3 + 3); + segments--; + for (var i = 0; i < segments; i++) { + this.vertex(x, y, color); + this.vertex(x + cx, y + cy, color); + var temp_2 = cx; + cx = cos * cx - sin * cy; + cy = sin * temp_2 + cos * cy; + this.vertex(x + cx, y + cy, color); + } + this.vertex(x, y, color); + this.vertex(x + cx, y + cy, color); + } + var temp = cx; + cx = radius; + cy = 0; + this.vertex(x + cx, y + cy, color); + }; + ShapeRenderer.prototype.curve = function (x1, y1, cx1, cy1, cx2, cy2, x2, y2, segments, color) { + if (color === void 0) { color = null; } + this.check(ShapeType.Line, segments * 2 + 2); + if (color === null) + color = this.color; + var subdiv_step = 1 / segments; + var subdiv_step2 = subdiv_step * subdiv_step; + var subdiv_step3 = subdiv_step * subdiv_step * subdiv_step; + var pre1 = 3 * subdiv_step; + var pre2 = 3 * subdiv_step2; + var pre4 = 6 * subdiv_step2; + var pre5 = 6 * subdiv_step3; + var tmp1x = x1 - cx1 * 2 + cx2; + var tmp1y = y1 - cy1 * 2 + cy2; + var tmp2x = (cx1 - cx2) * 3 - x1 + x2; + var tmp2y = (cy1 - cy2) * 3 - y1 + y2; + var fx = x1; + var fy = y1; + var dfx = (cx1 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdiv_step3; + var dfy = (cy1 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdiv_step3; + var ddfx = tmp1x * pre4 + tmp2x * pre5; + var ddfy = tmp1y * pre4 + tmp2y * pre5; + var dddfx = tmp2x * pre5; + var dddfy = tmp2y * pre5; + while (segments-- > 0) { + this.vertex(fx, fy, color); + fx += dfx; + fy += dfy; + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + this.vertex(fx, fy, color); + } + this.vertex(fx, fy, color); + this.vertex(x2, y2, color); + }; + ShapeRenderer.prototype.vertex = function (x, y, color) { + var idx = this.vertexIndex; + var vertices = this.mesh.getVertices(); + vertices[idx++] = x; + vertices[idx++] = y; + vertices[idx++] = color.r; + vertices[idx++] = color.g; + vertices[idx++] = color.b; + vertices[idx++] = color.a; + this.vertexIndex = idx; + }; + ShapeRenderer.prototype.end = function () { + if (!this.isDrawing) + throw new Error("ShapeRenderer.begin() has not been called"); + this.flush(); + this.context.gl.disable(this.context.gl.BLEND); + this.isDrawing = false; + }; + ShapeRenderer.prototype.flush = function () { + if (this.vertexIndex == 0) + return; + this.mesh.setVerticesLength(this.vertexIndex); + this.mesh.draw(this.shader, this.shapeType); + this.vertexIndex = 0; + }; + ShapeRenderer.prototype.check = function (shapeType, numVertices) { + if (!this.isDrawing) + throw new Error("ShapeRenderer.begin() has not been called"); + if (this.shapeType == shapeType) { + if (this.mesh.maxVertices() - this.mesh.numVertices() < numVertices) + this.flush(); + else + return; + } + else { + this.flush(); + this.shapeType = shapeType; + } + }; + ShapeRenderer.prototype.dispose = function () { + this.mesh.dispose(); + }; + return ShapeRenderer; + }()); + webgl.ShapeRenderer = ShapeRenderer; + var ShapeType; + (function (ShapeType) { + ShapeType[ShapeType["Point"] = 0] = "Point"; + ShapeType[ShapeType["Line"] = 1] = "Line"; + ShapeType[ShapeType["Filled"] = 4] = "Filled"; + })(ShapeType = webgl.ShapeType || (webgl.ShapeType = {})); + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var SkeletonDebugRenderer = (function () { + function SkeletonDebugRenderer(context) { + this.boneLineColor = new spine.Color(1, 0, 0, 1); + this.boneOriginColor = new spine.Color(0, 1, 0, 1); + this.attachmentLineColor = new spine.Color(0, 0, 1, 0.5); + this.triangleLineColor = new spine.Color(1, 0.64, 0, 0.5); + this.pathColor = new spine.Color().setFromString("FF7F00"); + this.clipColor = new spine.Color(0.8, 0, 0, 2); + this.aabbColor = new spine.Color(0, 1, 0, 0.5); + this.drawBones = true; + this.drawRegionAttachments = true; + this.drawBoundingBoxes = true; + this.drawMeshHull = true; + this.drawMeshTriangles = true; + this.drawPaths = true; + this.drawSkeletonXY = false; + this.drawClipping = true; + this.premultipliedAlpha = false; + this.scale = 1; + this.boneWidth = 2; + this.bounds = new spine.SkeletonBounds(); + this.temp = new Array(); + this.vertices = spine.Utils.newFloatArray(2 * 1024); + this.context = context instanceof webgl.ManagedWebGLRenderingContext ? context : new webgl.ManagedWebGLRenderingContext(context); + } + SkeletonDebugRenderer.prototype.draw = function (shapes, skeleton, ignoredBones) { + if (ignoredBones === void 0) { ignoredBones = null; } + var skeletonX = skeleton.x; + var skeletonY = skeleton.y; + var gl = this.context.gl; + var srcFunc = this.premultipliedAlpha ? gl.ONE : gl.SRC_ALPHA; + shapes.setBlendMode(srcFunc, gl.ONE_MINUS_SRC_ALPHA); + var bones = skeleton.bones; + if (this.drawBones) { + shapes.setColor(this.boneLineColor); + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1) + continue; + if (bone.parent == null) + continue; + var x = skeletonX + bone.data.length * bone.a + bone.worldX; + var y = skeletonY + bone.data.length * bone.c + bone.worldY; + shapes.rectLine(true, skeletonX + bone.worldX, skeletonY + bone.worldY, x, y, this.boneWidth * this.scale); + } + if (this.drawSkeletonXY) + shapes.x(skeletonX, skeletonY, 4 * this.scale); + } + if (this.drawRegionAttachments) { + shapes.setColor(this.attachmentLineColor); + var slots = skeleton.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (attachment instanceof spine.RegionAttachment) { + var regionAttachment = attachment; + var vertices = this.vertices; + regionAttachment.computeWorldVertices(slot.bone, vertices, 0, 2); + shapes.line(vertices[0], vertices[1], vertices[2], vertices[3]); + shapes.line(vertices[2], vertices[3], vertices[4], vertices[5]); + shapes.line(vertices[4], vertices[5], vertices[6], vertices[7]); + shapes.line(vertices[6], vertices[7], vertices[0], vertices[1]); + } + } + } + if (this.drawMeshHull || this.drawMeshTriangles) { + var slots = skeleton.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (!(attachment instanceof spine.MeshAttachment)) + continue; + var mesh = attachment; + var vertices = this.vertices; + mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, vertices, 0, 2); + var triangles = mesh.triangles; + var hullLength = mesh.hullLength; + if (this.drawMeshTriangles) { + shapes.setColor(this.triangleLineColor); + for (var ii = 0, nn = triangles.length; ii < nn; ii += 3) { + var v1 = triangles[ii] * 2, v2 = triangles[ii + 1] * 2, v3 = triangles[ii + 2] * 2; + shapes.triangle(false, vertices[v1], vertices[v1 + 1], vertices[v2], vertices[v2 + 1], vertices[v3], vertices[v3 + 1]); + } + } + if (this.drawMeshHull && hullLength > 0) { + shapes.setColor(this.attachmentLineColor); + hullLength = (hullLength >> 1) * 2; + var lastX = vertices[hullLength - 2], lastY = vertices[hullLength - 1]; + for (var ii = 0, nn = hullLength; ii < nn; ii += 2) { + var x = vertices[ii], y = vertices[ii + 1]; + shapes.line(x, y, lastX, lastY); + lastX = x; + lastY = y; + } + } + } + } + if (this.drawBoundingBoxes) { + var bounds = this.bounds; + bounds.update(skeleton, true); + shapes.setColor(this.aabbColor); + shapes.rect(false, bounds.minX, bounds.minY, bounds.getWidth(), bounds.getHeight()); + var polygons = bounds.polygons; + var boxes = bounds.boundingBoxes; + for (var i = 0, n = polygons.length; i < n; i++) { + var polygon = polygons[i]; + shapes.setColor(boxes[i].color); + shapes.polygon(polygon, 0, polygon.length); + } + } + if (this.drawPaths) { + var slots = skeleton.slots; + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (!(attachment instanceof spine.PathAttachment)) + continue; + var path = attachment; + var nn = path.worldVerticesLength; + var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0); + path.computeWorldVertices(slot, 0, nn, world, 0, 2); + var color = this.pathColor; + var x1 = world[2], y1 = world[3], x2 = 0, y2 = 0; + if (path.closed) { + shapes.setColor(color); + var cx1 = world[0], cy1 = world[1], cx2 = world[nn - 2], cy2 = world[nn - 1]; + x2 = world[nn - 4]; + y2 = world[nn - 3]; + shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32); + shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY); + shapes.line(x1, y1, cx1, cy1); + shapes.line(x2, y2, cx2, cy2); + } + nn -= 4; + for (var ii = 4; ii < nn; ii += 6) { + var cx1 = world[ii], cy1 = world[ii + 1], cx2 = world[ii + 2], cy2 = world[ii + 3]; + x2 = world[ii + 4]; + y2 = world[ii + 5]; + shapes.setColor(color); + shapes.curve(x1, y1, cx1, cy1, cx2, cy2, x2, y2, 32); + shapes.setColor(SkeletonDebugRenderer.LIGHT_GRAY); + shapes.line(x1, y1, cx1, cy1); + shapes.line(x2, y2, cx2, cy2); + x1 = x2; + y1 = y2; + } + } + } + if (this.drawBones) { + shapes.setColor(this.boneOriginColor); + for (var i = 0, n = bones.length; i < n; i++) { + var bone = bones[i]; + if (ignoredBones && ignoredBones.indexOf(bone.data.name) > -1) + continue; + shapes.circle(true, skeletonX + bone.worldX, skeletonY + bone.worldY, 3 * this.scale, SkeletonDebugRenderer.GREEN, 8); + } + } + if (this.drawClipping) { + var slots = skeleton.slots; + shapes.setColor(this.clipColor); + for (var i = 0, n = slots.length; i < n; i++) { + var slot = slots[i]; + var attachment = slot.getAttachment(); + if (!(attachment instanceof spine.ClippingAttachment)) + continue; + var clip = attachment; + var nn = clip.worldVerticesLength; + var world = this.temp = spine.Utils.setArraySize(this.temp, nn, 0); + clip.computeWorldVertices(slot, 0, nn, world, 0, 2); + for (var i_12 = 0, n_2 = world.length; i_12 < n_2; i_12 += 2) { + var x = world[i_12]; + var y = world[i_12 + 1]; + var x2 = world[(i_12 + 2) % world.length]; + var y2 = world[(i_12 + 3) % world.length]; + shapes.line(x, y, x2, y2); + } + } + } + }; + SkeletonDebugRenderer.prototype.dispose = function () { + }; + SkeletonDebugRenderer.LIGHT_GRAY = new spine.Color(192 / 255, 192 / 255, 192 / 255, 1); + SkeletonDebugRenderer.GREEN = new spine.Color(0, 1, 0, 1); + return SkeletonDebugRenderer; + }()); + webgl.SkeletonDebugRenderer = SkeletonDebugRenderer; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Renderable = (function () { + function Renderable(vertices, numVertices, numFloats) { + this.vertices = vertices; + this.numVertices = numVertices; + this.numFloats = numFloats; + } + return Renderable; + }()); + ; + var SkeletonRenderer = (function () { + function SkeletonRenderer(context, twoColorTint) { + if (twoColorTint === void 0) { twoColorTint = true; } + this.premultipliedAlpha = false; + this.vertexEffect = null; + this.tempColor = new spine.Color(); + this.tempColor2 = new spine.Color(); + this.vertexSize = 2 + 2 + 4; + this.twoColorTint = false; + this.renderable = new Renderable(null, 0, 0); + this.clipper = new spine.SkeletonClipping(); + this.temp = new spine.Vector2(); + this.temp2 = new spine.Vector2(); + this.temp3 = new spine.Color(); + this.temp4 = new spine.Color(); + this.twoColorTint = twoColorTint; + if (twoColorTint) + this.vertexSize += 4; + this.vertices = spine.Utils.newFloatArray(this.vertexSize * 1024); + } + SkeletonRenderer.prototype.draw = function (batcher, skeleton, slotRangeStart, slotRangeEnd) { + if (slotRangeStart === void 0) { slotRangeStart = -1; } + if (slotRangeEnd === void 0) { slotRangeEnd = -1; } + var clipper = this.clipper; + var premultipliedAlpha = this.premultipliedAlpha; + var twoColorTint = this.twoColorTint; + var blendMode = null; + var tempPos = this.temp; + var tempUv = this.temp2; + var tempLight = this.temp3; + var tempDark = this.temp4; + var renderable = this.renderable; + var uvs = null; + var triangles = null; + var drawOrder = skeleton.drawOrder; + var attachmentColor = null; + var skeletonColor = skeleton.color; + var vertexSize = twoColorTint ? 12 : 8; + var inRange = false; + if (slotRangeStart == -1) + inRange = true; + for (var i = 0, n = drawOrder.length; i < n; i++) { + var clippedVertexSize = clipper.isClipping() ? 2 : vertexSize; + var slot = drawOrder[i]; + if (slotRangeStart >= 0 && slotRangeStart == slot.data.index) { + inRange = true; + } + if (!inRange) { + clipper.clipEndWithSlot(slot); + continue; + } + if (slotRangeEnd >= 0 && slotRangeEnd == slot.data.index) { + inRange = false; + } + var attachment = slot.getAttachment(); + var texture = null; + if (attachment instanceof spine.RegionAttachment) { + var region = attachment; + renderable.vertices = this.vertices; + renderable.numVertices = 4; + renderable.numFloats = clippedVertexSize << 2; + region.computeWorldVertices(slot.bone, renderable.vertices, 0, clippedVertexSize); + triangles = SkeletonRenderer.QUAD_TRIANGLES; + uvs = region.uvs; + texture = region.region.renderObject.texture; + attachmentColor = region.color; + } + else if (attachment instanceof spine.MeshAttachment) { + var mesh = attachment; + renderable.vertices = this.vertices; + renderable.numVertices = (mesh.worldVerticesLength >> 1); + renderable.numFloats = renderable.numVertices * clippedVertexSize; + if (renderable.numFloats > renderable.vertices.length) { + renderable.vertices = this.vertices = spine.Utils.newFloatArray(renderable.numFloats); + } + mesh.computeWorldVertices(slot, 0, mesh.worldVerticesLength, renderable.vertices, 0, clippedVertexSize); + triangles = mesh.triangles; + texture = mesh.region.renderObject.texture; + uvs = mesh.uvs; + attachmentColor = mesh.color; + } + else if (attachment instanceof spine.ClippingAttachment) { + var clip = (attachment); + clipper.clipStart(slot, clip); + continue; + } + else + continue; + if (texture != null) { + var slotColor = slot.color; + var finalColor = this.tempColor; + finalColor.r = skeletonColor.r * slotColor.r * attachmentColor.r; + finalColor.g = skeletonColor.g * slotColor.g * attachmentColor.g; + finalColor.b = skeletonColor.b * slotColor.b * attachmentColor.b; + finalColor.a = skeletonColor.a * slotColor.a * attachmentColor.a; + if (premultipliedAlpha) { + finalColor.r *= finalColor.a; + finalColor.g *= finalColor.a; + finalColor.b *= finalColor.a; + } + var darkColor = this.tempColor2; + if (slot.darkColor == null) + darkColor.set(0, 0, 0, 1.0); + else { + if (premultipliedAlpha) { + darkColor.r = slot.darkColor.r * finalColor.a; + darkColor.g = slot.darkColor.g * finalColor.a; + darkColor.b = slot.darkColor.b * finalColor.a; + } + else { + darkColor.setFromColor(slot.darkColor); + } + darkColor.a = premultipliedAlpha ? 1.0 : 0.0; + } + var slotBlendMode = slot.data.blendMode; + if (slotBlendMode != blendMode) { + blendMode = slotBlendMode; + batcher.setBlendMode(webgl.WebGLBlendModeConverter.getSourceGLBlendMode(blendMode, premultipliedAlpha), webgl.WebGLBlendModeConverter.getDestGLBlendMode(blendMode)); + } + if (clipper.isClipping()) { + clipper.clipTriangles(renderable.vertices, renderable.numFloats, triangles, triangles.length, uvs, finalColor, darkColor, twoColorTint); + var clippedVertices = new Float32Array(clipper.clippedVertices); + var clippedTriangles = clipper.clippedTriangles; + if (this.vertexEffect != null) { + var vertexEffect = this.vertexEffect; + var verts = clippedVertices; + if (!twoColorTint) { + for (var v = 0, n_3 = clippedVertices.length; v < n_3; v += vertexSize) { + tempPos.x = verts[v]; + tempPos.y = verts[v + 1]; + tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]); + tempUv.x = verts[v + 6]; + tempUv.y = verts[v + 7]; + tempDark.set(0, 0, 0, 0); + vertexEffect.transform(tempPos, tempUv, tempLight, tempDark); + verts[v] = tempPos.x; + verts[v + 1] = tempPos.y; + verts[v + 2] = tempLight.r; + verts[v + 3] = tempLight.g; + verts[v + 4] = tempLight.b; + verts[v + 5] = tempLight.a; + verts[v + 6] = tempUv.x; + verts[v + 7] = tempUv.y; + } + } + else { + for (var v = 0, n_4 = clippedVertices.length; v < n_4; v += vertexSize) { + tempPos.x = verts[v]; + tempPos.y = verts[v + 1]; + tempLight.set(verts[v + 2], verts[v + 3], verts[v + 4], verts[v + 5]); + tempUv.x = verts[v + 6]; + tempUv.y = verts[v + 7]; + tempDark.set(verts[v + 8], verts[v + 9], verts[v + 10], verts[v + 11]); + vertexEffect.transform(tempPos, tempUv, tempLight, tempDark); + verts[v] = tempPos.x; + verts[v + 1] = tempPos.y; + verts[v + 2] = tempLight.r; + verts[v + 3] = tempLight.g; + verts[v + 4] = tempLight.b; + verts[v + 5] = tempLight.a; + verts[v + 6] = tempUv.x; + verts[v + 7] = tempUv.y; + verts[v + 8] = tempDark.r; + verts[v + 9] = tempDark.g; + verts[v + 10] = tempDark.b; + verts[v + 11] = tempDark.a; + } + } + } + batcher.draw(texture, clippedVertices, clippedTriangles); + } + else { + var verts = renderable.vertices; + if (this.vertexEffect != null) { + var vertexEffect = this.vertexEffect; + if (!twoColorTint) { + for (var v = 0, u = 0, n_5 = renderable.numFloats; v < n_5; v += vertexSize, u += 2) { + tempPos.x = verts[v]; + tempPos.y = verts[v + 1]; + tempUv.x = uvs[u]; + tempUv.y = uvs[u + 1]; + tempLight.setFromColor(finalColor); + tempDark.set(0, 0, 0, 0); + vertexEffect.transform(tempPos, tempUv, tempLight, tempDark); + verts[v] = tempPos.x; + verts[v + 1] = tempPos.y; + verts[v + 2] = tempLight.r; + verts[v + 3] = tempLight.g; + verts[v + 4] = tempLight.b; + verts[v + 5] = tempLight.a; + verts[v + 6] = tempUv.x; + verts[v + 7] = tempUv.y; + } + } + else { + for (var v = 0, u = 0, n_6 = renderable.numFloats; v < n_6; v += vertexSize, u += 2) { + tempPos.x = verts[v]; + tempPos.y = verts[v + 1]; + tempUv.x = uvs[u]; + tempUv.y = uvs[u + 1]; + tempLight.setFromColor(finalColor); + tempDark.setFromColor(darkColor); + vertexEffect.transform(tempPos, tempUv, tempLight, tempDark); + verts[v] = tempPos.x; + verts[v + 1] = tempPos.y; + verts[v + 2] = tempLight.r; + verts[v + 3] = tempLight.g; + verts[v + 4] = tempLight.b; + verts[v + 5] = tempLight.a; + verts[v + 6] = tempUv.x; + verts[v + 7] = tempUv.y; + verts[v + 8] = tempDark.r; + verts[v + 9] = tempDark.g; + verts[v + 10] = tempDark.b; + verts[v + 11] = tempDark.a; + } + } + } + else { + if (!twoColorTint) { + for (var v = 2, u = 0, n_7 = renderable.numFloats; v < n_7; v += vertexSize, u += 2) { + verts[v] = finalColor.r; + verts[v + 1] = finalColor.g; + verts[v + 2] = finalColor.b; + verts[v + 3] = finalColor.a; + verts[v + 4] = uvs[u]; + verts[v + 5] = uvs[u + 1]; + } + } + else { + for (var v = 2, u = 0, n_8 = renderable.numFloats; v < n_8; v += vertexSize, u += 2) { + verts[v] = finalColor.r; + verts[v + 1] = finalColor.g; + verts[v + 2] = finalColor.b; + verts[v + 3] = finalColor.a; + verts[v + 4] = uvs[u]; + verts[v + 5] = uvs[u + 1]; + verts[v + 6] = darkColor.r; + verts[v + 7] = darkColor.g; + verts[v + 8] = darkColor.b; + verts[v + 9] = darkColor.a; + } + } + } + var view = renderable.vertices.subarray(0, renderable.numFloats); + batcher.draw(texture, view, triangles); + } + } + clipper.clipEndWithSlot(slot); + } + clipper.clipEnd(); + }; + SkeletonRenderer.QUAD_TRIANGLES = [0, 1, 2, 2, 3, 0]; + return SkeletonRenderer; + }()); + webgl.SkeletonRenderer = SkeletonRenderer; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var Vector3 = (function () { + function Vector3(x, y, z) { + if (x === void 0) { x = 0; } + if (y === void 0) { y = 0; } + if (z === void 0) { z = 0; } + this.x = 0; + this.y = 0; + this.z = 0; + this.x = x; + this.y = y; + this.z = z; + } + Vector3.prototype.setFrom = function (v) { + this.x = v.x; + this.y = v.y; + this.z = v.z; + return this; + }; + Vector3.prototype.set = function (x, y, z) { + this.x = x; + this.y = y; + this.z = z; + return this; + }; + Vector3.prototype.add = function (v) { + this.x += v.x; + this.y += v.y; + this.z += v.z; + return this; + }; + Vector3.prototype.sub = function (v) { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + return this; + }; + Vector3.prototype.scale = function (s) { + this.x *= s; + this.y *= s; + this.z *= s; + return this; + }; + Vector3.prototype.normalize = function () { + var len = this.length(); + if (len == 0) + return this; + len = 1 / len; + this.x *= len; + this.y *= len; + this.z *= len; + return this; + }; + Vector3.prototype.cross = function (v) { + return this.set(this.y * v.z - this.z * v.y, this.z * v.x - this.x * v.z, this.x * v.y - this.y * v.x); + }; + Vector3.prototype.multiply = function (matrix) { + var l_mat = matrix.values; + return this.set(this.x * l_mat[webgl.M00] + this.y * l_mat[webgl.M01] + this.z * l_mat[webgl.M02] + l_mat[webgl.M03], this.x * l_mat[webgl.M10] + this.y * l_mat[webgl.M11] + this.z * l_mat[webgl.M12] + l_mat[webgl.M13], this.x * l_mat[webgl.M20] + this.y * l_mat[webgl.M21] + this.z * l_mat[webgl.M22] + l_mat[webgl.M23]); + }; + Vector3.prototype.project = function (matrix) { + var l_mat = matrix.values; + var l_w = 1 / (this.x * l_mat[webgl.M30] + this.y * l_mat[webgl.M31] + this.z * l_mat[webgl.M32] + l_mat[webgl.M33]); + return this.set((this.x * l_mat[webgl.M00] + this.y * l_mat[webgl.M01] + this.z * l_mat[webgl.M02] + l_mat[webgl.M03]) * l_w, (this.x * l_mat[webgl.M10] + this.y * l_mat[webgl.M11] + this.z * l_mat[webgl.M12] + l_mat[webgl.M13]) * l_w, (this.x * l_mat[webgl.M20] + this.y * l_mat[webgl.M21] + this.z * l_mat[webgl.M22] + l_mat[webgl.M23]) * l_w); + }; + Vector3.prototype.dot = function (v) { + return this.x * v.x + this.y * v.y + this.z * v.z; + }; + Vector3.prototype.length = function () { + return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + }; + Vector3.prototype.distance = function (v) { + var a = v.x - this.x; + var b = v.y - this.y; + var c = v.z - this.z; + return Math.sqrt(a * a + b * b + c * c); + }; + return Vector3; + }()); + webgl.Vector3 = Vector3; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +var spine; +(function (spine) { + var webgl; + (function (webgl) { + var ManagedWebGLRenderingContext = (function () { + function ManagedWebGLRenderingContext(canvasOrContext, contextConfig) { + if (contextConfig === void 0) { contextConfig = { alpha: "true" }; } + var _this = this; + this.restorables = new Array(); + if (canvasOrContext instanceof HTMLCanvasElement) { + var canvas = canvasOrContext; + this.gl = (canvas.getContext("webgl", contextConfig) || canvas.getContext("experimental-webgl", contextConfig)); + this.canvas = canvas; + canvas.addEventListener("webglcontextlost", function (e) { + var event = e; + if (e) { + e.preventDefault(); + } + }); + canvas.addEventListener("webglcontextrestored", function (e) { + for (var i = 0, n = _this.restorables.length; i < n; i++) { + _this.restorables[i].restore(); + } + }); + } + else { + this.gl = canvasOrContext; + this.canvas = this.gl.canvas; + } + } + ManagedWebGLRenderingContext.prototype.addRestorable = function (restorable) { + this.restorables.push(restorable); + }; + ManagedWebGLRenderingContext.prototype.removeRestorable = function (restorable) { + var index = this.restorables.indexOf(restorable); + if (index > -1) + this.restorables.splice(index, 1); + }; + return ManagedWebGLRenderingContext; + }()); + webgl.ManagedWebGLRenderingContext = ManagedWebGLRenderingContext; + var WebGLBlendModeConverter = (function () { + function WebGLBlendModeConverter() { + } + WebGLBlendModeConverter.getDestGLBlendMode = function (blendMode) { + switch (blendMode) { + case spine.BlendMode.Normal: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA; + case spine.BlendMode.Additive: return WebGLBlendModeConverter.ONE; + case spine.BlendMode.Multiply: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA; + case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA; + default: throw new Error("Unknown blend mode: " + blendMode); + } + }; + WebGLBlendModeConverter.getSourceGLBlendMode = function (blendMode, premultipliedAlpha) { + if (premultipliedAlpha === void 0) { premultipliedAlpha = false; } + switch (blendMode) { + case spine.BlendMode.Normal: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA; + case spine.BlendMode.Additive: return premultipliedAlpha ? WebGLBlendModeConverter.ONE : WebGLBlendModeConverter.SRC_ALPHA; + case spine.BlendMode.Multiply: return WebGLBlendModeConverter.DST_COLOR; + case spine.BlendMode.Screen: return WebGLBlendModeConverter.ONE; + default: throw new Error("Unknown blend mode: " + blendMode); + } + }; + WebGLBlendModeConverter.ZERO = 0; + WebGLBlendModeConverter.ONE = 1; + WebGLBlendModeConverter.SRC_COLOR = 0x0300; + WebGLBlendModeConverter.ONE_MINUS_SRC_COLOR = 0x0301; + WebGLBlendModeConverter.SRC_ALPHA = 0x0302; + WebGLBlendModeConverter.ONE_MINUS_SRC_ALPHA = 0x0303; + WebGLBlendModeConverter.DST_ALPHA = 0x0304; + WebGLBlendModeConverter.ONE_MINUS_DST_ALPHA = 0x0305; + WebGLBlendModeConverter.DST_COLOR = 0x0306; + return WebGLBlendModeConverter; + }()); + webgl.WebGLBlendModeConverter = WebGLBlendModeConverter; + })(webgl = spine.webgl || (spine.webgl = {})); +})(spine || (spine = {})); +//# sourceMappingURL=spine-webgl.js.map \ No newline at end of file diff --git a/plugins/spine/webpack.auto.config.js b/plugins/spine/webpack.auto.config.js new file mode 100644 index 000000000..677df325d --- /dev/null +++ b/plugins/spine/webpack.auto.config.js @@ -0,0 +1,76 @@ +'use strict'; + +const webpack = require('webpack'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); +const exec = require('child_process').exec; + +module.exports = { + mode: 'development', + + context: `${__dirname}/src/`, + + entry: { + 'SpinePlugin': './SpinePlugin.js' + }, + + output: { + path: `${__dirname}/dist/`, + filename: '[name].js', + library: 'SpinePlugin', + libraryTarget: 'umd', + sourceMapFilename: '[file].map', + devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string + devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string + umdNamedDefine: true + }, + + performance: { hints: false }, + + module: { + rules: [ + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'exports-loader?spine' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'exports-loader?spine' + } + ] + }, + + resolve: { + alias: { + 'SpineCanvas': './runtimes/spine-canvas.js', + 'SpineWebGL': './runtimes/spine-webgl.js' + }, + }, + + plugins: [ + new webpack.DefinePlugin({ + "typeof CANVAS_RENDERER": JSON.stringify(true), + "typeof WEBGL_RENDERER": JSON.stringify(true) + }), + new CleanWebpackPlugin([ 'dist' ]), + { + apply: (compiler) => { + compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => { + exec('node plugins/spine/copy-to-examples.js', (err, stdout, stderr) => { + if (stdout) process.stdout.write(stdout); + if (stderr) process.stderr.write(stderr); + }); + }); + } + } + ], + + devtool: 'source-map' +}; diff --git a/plugins/spine/webpack.auto.dist.config.js b/plugins/spine/webpack.auto.dist.config.js new file mode 100644 index 000000000..ab9851722 --- /dev/null +++ b/plugins/spine/webpack.auto.dist.config.js @@ -0,0 +1,94 @@ +'use strict'; + +const webpack = require('webpack'); +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); +const exec = require('child_process').exec; + +module.exports = { + mode: 'production', + + context: `${__dirname}/src/`, + + entry: { + 'SpinePlugin': './SpineWebGLPlugin.js', + 'SpinePlugin.min': './SpineWebGLPlugin.js' + }, + + output: { + path: `${__dirname}/dist/`, + filename: '[name].js', + library: 'SpinePlugin', + libraryTarget: 'umd', + sourceMapFilename: '[file].map', + devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string + devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string + umdNamedDefine: true + }, + + performance: { hints: false }, + + module: { + rules: [ + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'exports-loader?spine' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'exports-loader?spine' + } + ] + }, + + resolve: { + alias: { + 'SpineCanvas': './runtimes/spine-canvas.js', + 'SpineWebGL': './runtimes/spine-webgl.js' + }, + }, + + optimization: { + minimizer: [ + new UglifyJSPlugin({ + include: /\.min\.js$/, + parallel: true, + sourceMap: false, + uglifyOptions: { + compress: true, + ie8: false, + ecma: 5, + output: {comments: false}, + warnings: false + }, + warningsFilter: () => false + }) + ] + }, + + plugins: [ + new webpack.DefinePlugin({ + "typeof CANVAS_RENDERER": JSON.stringify(true), + "typeof WEBGL_RENDERER": JSON.stringify(true) + }), + new CleanWebpackPlugin([ 'dist' ]), + { + apply: (compiler) => { + compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => { + exec('node plugins/spine/copy-to-examples.js', (err, stdout, stderr) => { + if (stdout) process.stdout.write(stdout); + if (stderr) process.stderr.write(stderr); + }); + }); + } + } + ] +}; diff --git a/plugins/spine/webpack.canvas.config.js b/plugins/spine/webpack.canvas.config.js new file mode 100644 index 000000000..ead98a894 --- /dev/null +++ b/plugins/spine/webpack.canvas.config.js @@ -0,0 +1,76 @@ +'use strict'; + +const webpack = require('webpack'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); +const exec = require('child_process').exec; + +module.exports = { + mode: 'development', + + context: `${__dirname}/src/`, + + entry: { + 'SpineCanvasPlugin': './SpineCanvasPlugin.js' + }, + + output: { + path: `${__dirname}/dist/`, + filename: '[name].js', + library: 'SpineCanvasPlugin', + libraryTarget: 'umd', + sourceMapFilename: '[file].map', + devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string + devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string + umdNamedDefine: true + }, + + performance: { hints: false }, + + module: { + rules: [ + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'exports-loader?spine' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'exports-loader?spine' + } + ] + }, + + resolve: { + alias: { + 'SpineCanvas': './runtimes/spine-canvas.js', + 'SpineWebGL': './runtimes/spine-webgl.js' + }, + }, + + plugins: [ + new webpack.DefinePlugin({ + "typeof CANVAS_RENDERER": JSON.stringify(true), + "typeof WEBGL_RENDERER": JSON.stringify(false) + }), + new CleanWebpackPlugin([ 'dist' ]), + { + apply: (compiler) => { + compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => { + exec('node plugins/spine/copy-to-examples.js', (err, stdout, stderr) => { + if (stdout) process.stdout.write(stdout); + if (stderr) process.stderr.write(stderr); + }); + }); + } + } + ], + + devtool: 'source-map' +}; diff --git a/plugins/spine/webpack.canvas.dist.config.js b/plugins/spine/webpack.canvas.dist.config.js new file mode 100644 index 000000000..4e275c6f8 --- /dev/null +++ b/plugins/spine/webpack.canvas.dist.config.js @@ -0,0 +1,94 @@ +'use strict'; + +const webpack = require('webpack'); +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); +const exec = require('child_process').exec; + +module.exports = { + mode: 'production', + + context: `${__dirname}/src/`, + + entry: { + 'SpineCanvasPlugin': './SpineCanvasPlugin.js', + 'SpineCanvasPlugin.min': './SpineCanvasPlugin.js' + }, + + output: { + path: `${__dirname}/dist/`, + filename: '[name].js', + library: 'SpineCanvasPlugin', + libraryTarget: 'umd', + sourceMapFilename: '[file].map', + devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string + devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string + umdNamedDefine: true + }, + + performance: { hints: false }, + + module: { + rules: [ + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'exports-loader?spine' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'exports-loader?spine' + } + ] + }, + + resolve: { + alias: { + 'SpineCanvas': './runtimes/spine-canvas.js', + 'SpineWebGL': './runtimes/spine-webgl.js' + }, + }, + + optimization: { + minimizer: [ + new UglifyJSPlugin({ + include: /\.min\.js$/, + parallel: true, + sourceMap: false, + uglifyOptions: { + compress: true, + ie8: false, + ecma: 5, + output: {comments: false}, + warnings: false + }, + warningsFilter: () => false + }) + ] + }, + + plugins: [ + new webpack.DefinePlugin({ + "typeof CANVAS_RENDERER": JSON.stringify(true), + "typeof WEBGL_RENDERER": JSON.stringify(false) + }), + new CleanWebpackPlugin([ 'dist' ]), + { + apply: (compiler) => { + compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => { + exec('node plugins/spine/copy-to-examples.js', (err, stdout, stderr) => { + if (stdout) process.stdout.write(stdout); + if (stderr) process.stderr.write(stderr); + }); + }); + } + } + ] +}; diff --git a/plugins/spine/webpack.webgl.config.js b/plugins/spine/webpack.webgl.config.js new file mode 100644 index 000000000..22d66647e --- /dev/null +++ b/plugins/spine/webpack.webgl.config.js @@ -0,0 +1,76 @@ +'use strict'; + +const webpack = require('webpack'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); +const exec = require('child_process').exec; + +module.exports = { + mode: 'development', + + context: `${__dirname}/src/`, + + entry: { + 'SpineWebGLPlugin': './SpineWebGLPlugin.js' + }, + + output: { + path: `${__dirname}/dist/`, + filename: '[name].js', + library: 'SpineWebGLPlugin', + libraryTarget: 'umd', + sourceMapFilename: '[file].map', + devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string + devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string + umdNamedDefine: true + }, + + performance: { hints: false }, + + module: { + rules: [ + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'exports-loader?spine' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'exports-loader?spine' + } + ] + }, + + resolve: { + alias: { + 'SpineCanvas': './runtimes/spine-canvas.js', + 'SpineWebGL': './runtimes/spine-webgl.js' + }, + }, + + plugins: [ + new webpack.DefinePlugin({ + "typeof CANVAS_RENDERER": JSON.stringify(false), + "typeof WEBGL_RENDERER": JSON.stringify(true) + }), + new CleanWebpackPlugin([ 'dist' ]), + { + apply: (compiler) => { + compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => { + exec('node plugins/spine/copy-to-examples.js', (err, stdout, stderr) => { + if (stdout) process.stdout.write(stdout); + if (stderr) process.stderr.write(stderr); + }); + }); + } + } + ], + + devtool: 'source-map' +}; diff --git a/plugins/spine/webpack.webgl.dist.config.js b/plugins/spine/webpack.webgl.dist.config.js new file mode 100644 index 000000000..35cf199e6 --- /dev/null +++ b/plugins/spine/webpack.webgl.dist.config.js @@ -0,0 +1,94 @@ +'use strict'; + +const webpack = require('webpack'); +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); +const exec = require('child_process').exec; + +module.exports = { + mode: 'production', + + context: `${__dirname}/src/`, + + entry: { + 'SpineWebGLPlugin': './SpineWebGLPlugin.js', + 'SpineWebGLPlugin.min': './SpineWebGLPlugin.js' + }, + + output: { + path: `${__dirname}/dist/`, + filename: '[name].js', + library: 'SpineWebGLPlugin', + libraryTarget: 'umd', + sourceMapFilename: '[file].map', + devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string + devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string + umdNamedDefine: true + }, + + performance: { hints: false }, + + module: { + rules: [ + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-canvas.js'), + use: 'exports-loader?spine' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'imports-loader?this=>window' + }, + { + test: require.resolve('./src/runtimes/spine-webgl.js'), + use: 'exports-loader?spine' + } + ] + }, + + resolve: { + alias: { + 'SpineCanvas': './runtimes/spine-canvas.js', + 'SpineWebGL': './runtimes/spine-webgl.js' + }, + }, + + optimization: { + minimizer: [ + new UglifyJSPlugin({ + include: /\.min\.js$/, + parallel: true, + sourceMap: false, + uglifyOptions: { + compress: true, + ie8: false, + ecma: 5, + output: {comments: false}, + warnings: false + }, + warningsFilter: () => false + }) + ] + }, + + plugins: [ + new webpack.DefinePlugin({ + "typeof CANVAS_RENDERER": JSON.stringify(false), + "typeof WEBGL_RENDERER": JSON.stringify(true) + }), + new CleanWebpackPlugin([ 'dist' ]), + { + apply: (compiler) => { + compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => { + exec('node plugins/spine/copy-to-examples.js', (err, stdout, stderr) => { + if (stdout) process.stdout.write(stdout); + if (stderr) process.stderr.write(stderr); + }); + }); + } + } + ] +}; diff --git a/scripts/bundle-shaders.js b/scripts/bundle-shaders.js index c25056b34..7a7bec1d5 100644 --- a/scripts/bundle-shaders.js +++ b/scripts/bundle-shaders.js @@ -5,8 +5,6 @@ BitmapMask.frag BitmapMask.vert DeferredDiffuse.frag DeferredDiffuse.vert -FlatTint.frag -FlatTint.vert ForwardDiffuse.frag GBuffer.frag TextureTint.frag diff --git a/scripts/copy-to-examples-fb.js b/scripts/copy-to-examples-fb.js new file mode 100644 index 000000000..113183fcf --- /dev/null +++ b/scripts/copy-to-examples-fb.js @@ -0,0 +1,30 @@ +let fs = require('fs-extra'); + +let source = './build/phaser-facebook-instant-games.js'; +let sourceMap = './build/phaser-facebook-instant-games.js.map'; +let destFolder = '../fbtest1/lib/'; +let dest = '../fbtest1/lib/phaser-facebook-instant-games.js'; +let destMap = '../fbtest1/lib/phaser-facebook-instant-games.js.map'; + +if (fs.existsSync(destFolder)) +{ + fs.copy(sourceMap, destMap, function (err) { + + if (err) + { + return console.error(err); + } + + }); + + fs.copy(source, dest, function (err) { + + if (err) + { + return console.error(err); + } + + console.log('Build copied to ' + dest); + + }); +} diff --git a/scripts/copy-to-examples.js b/scripts/copy-to-examples.js index 1ba9773b8..a8dfe1a6a 100644 --- a/scripts/copy-to-examples.js +++ b/scripts/copy-to-examples.js @@ -1,38 +1,43 @@ let fs = require('fs-extra'); -// let sloc = require('node-sloc'); +let sloc = require('node-sloc'); let source = './build/phaser.js'; 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'; +let sourceFB = './build/phaser-facebook-instant-games.js'; +let sourceFBMap = './build/phaser-facebook-instant-games.js.map'; +let destFB = '../fbtest1/lib/dev.js'; +let destFBMap = '../fbtest1/lib/phaser.js.map'; + +/* +if (fs.existsSync(destFB)) +{ + fs.copy(source, destFB, function (err) { + + if (err) + { + return console.error(err); + } + + console.log('Build copied to ' + destFB); + + }); + + fs.copy(sourceMap, destFBMap, function (err) { + + if (err) + { + return console.error(err); + } + + }); +} +*/ 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); - } - - console.log('Build copied to ' + destCore); - - }); - fs.copy(sourceMap, destMap, function (err) { if (err) @@ -56,13 +61,13 @@ if (fs.existsSync(dest)) extensions: [ '.js' ] }; - // sloc(options).then((res) => { - // console.log('Source files: ' + res.sloc.files + '\nLines of code: ' + res.sloc.sloc); - // }); + sloc(options).then((res) => { + console.log('Source files: ' + res.sloc.files + '\nLines of code: ' + res.sloc.sloc); + }); }); } else { - console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples'); + // console.log('Copy-to-Examples failed: Phaser 3 Examples not present at ../phaser3-examples'); } diff --git a/scripts/help.js b/scripts/help.js index 54a2510a0..3a6f248bd 100644 --- a/scripts/help.js +++ b/scripts/help.js @@ -9,11 +9,17 @@ v.log('{bgYellow}{black} \\/ \\/ \\/ \\/ v.log('{bgYellow}{black} Available commands: '); v.log('{white}* npm run {green}build {cyan} Build dev version of Phaser with Webpack'); -v.log('{white}* npm run {green}watch {cyan} Build dev & put Webpack into watch mode'); -v.log('{white}* npm run {green}dist {cyan} Build dist & min versions of Phaser'); +v.log('{white}* npm run {green}watch {cyan} Build dev & put Webpack in watch mode'); +v.log('{white}* npm run {green}dist {cyan} Build dist versions of Phaser'); v.log('{white}* npm run {green}lint {cyan} ESLint check Phaser source'); v.log('{white}* npm run {green}lintfix {cyan} ESLint check and fix Phaser source'); v.log('{white}* npm run {green}sloc {cyan} Get source code & comments line count'); v.log('{white}* npm run {green}bundleshaders {cyan} Convert vert/frag shaders to js'); +v.log('{white}* npm run {green}plugin.cam3d {cyan} Build Camera3D Plugin'); +v.log('{white}Facebook Instant Games:'); +v.log('{white}* npm run {green}buildfb {cyan} Build dev Phaser FB with Webpack'); +v.log('{white}* npm run {green}watchfb {cyan} Build FB dev in Webpack watch mode'); +v.log('{white}* npm run {green}distfb {cyan} Build dist versions of Phaser FB'); +v.log('{white}* npm run {green}distfull {cyan} Build dist versions of Phaser + FB'); v.log('{bgYellow}{black} https://phaser.io https://labs.phaser.io '); diff --git a/src/actions/Call.js b/src/actions/Call.js index d67bd0f77..d07c5381f 100644 --- a/src/actions/Call.js +++ b/src/actions/Call.js @@ -7,7 +7,7 @@ /** * @callback CallCallback * - * @param {Phaser.GameObjects.GameObject} item - [description] + * @param {Phaser.GameObjects.GameObject} item - The Game Object to run the callback on. */ /** diff --git a/src/actions/PlaceOnCircle.js b/src/actions/PlaceOnCircle.js index 1d5fd0b76..5bdfd5a8d 100644 --- a/src/actions/PlaceOnCircle.js +++ b/src/actions/PlaceOnCircle.js @@ -5,7 +5,9 @@ */ /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnCircle * @since 3.0.0 @@ -13,9 +15,9 @@ * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/PlaceOnEllipse.js b/src/actions/PlaceOnEllipse.js index 0b20abc5f..d16cc0225 100644 --- a/src/actions/PlaceOnEllipse.js +++ b/src/actions/PlaceOnEllipse.js @@ -5,7 +5,9 @@ */ /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnEllipse * @since 3.0.0 @@ -13,9 +15,9 @@ * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] - * @param {number} [startAngle=0] - [description] - * @param {number} [endAngle=6.28] - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects on. + * @param {number} [startAngle=0] - Optional angle to start position from, in radians. + * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/PlaceOnLine.js b/src/actions/PlaceOnLine.js index 6bf9c68e2..1d6881fe4 100644 --- a/src/actions/PlaceOnLine.js +++ b/src/actions/PlaceOnLine.js @@ -7,7 +7,7 @@ var GetPoints = require('../geom/line/GetPoints'); /** - * [description] + * Positions an array of Game Objects on evenly spaced points of a Line. * * @function Phaser.Actions.PlaceOnLine * @since 3.0.0 @@ -15,7 +15,7 @@ var GetPoints = require('../geom/line/GetPoints'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects on. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/PlaceOnRectangle.js b/src/actions/PlaceOnRectangle.js index 71ffe8934..9a112a9cb 100644 --- a/src/actions/PlaceOnRectangle.js +++ b/src/actions/PlaceOnRectangle.js @@ -8,14 +8,11 @@ var MarchingAnts = require('../geom/rectangle/MarchingAnts'); var RotateLeft = require('../utils/array/RotateLeft'); var RotateRight = require('../utils/array/RotateRight'); -// Place the items in the array around the perimeter of the given rectangle. - -// Placement starts from the top-left of the rectangle, and proceeds in a -// clockwise direction. If the shift parameter is given you can offset where -// placement begins. - /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. + * + * Placement starts from the top-left of the rectangle, and proceeds in a clockwise direction. + * If the `shift` parameter is given you can offset where placement begins. * * @function Phaser.Actions.PlaceOnRectangle * @since 3.0.0 @@ -23,8 +20,8 @@ var RotateRight = require('../utils/array/RotateRight'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {integer} [shift=1] - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects on. + * @param {integer} [shift=1] - An optional positional offset. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/PlaceOnTriangle.js b/src/actions/PlaceOnTriangle.js index 0be4676fb..028a1cef0 100644 --- a/src/actions/PlaceOnTriangle.js +++ b/src/actions/PlaceOnTriangle.js @@ -4,11 +4,12 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// var GetPointsOnLine = require('../geom/line/GetPointsOnLine'); var BresenhamPoints = require('../geom/line/BresenhamPoints'); /** - * [description] + * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.PlaceOnTriangle * @since 3.0.0 @@ -16,8 +17,8 @@ var BresenhamPoints = require('../geom/line/BresenhamPoints'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} [stepRate=1] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects on. + * @param {number} [stepRate=1] - An optional step rate, to increase or decrease the packing of the Game Objects on the lines. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/RandomCircle.js b/src/actions/RandomCircle.js index ffe17d93b..c49b15358 100644 --- a/src/actions/RandomCircle.js +++ b/src/actions/RandomCircle.js @@ -7,7 +7,9 @@ var Random = require('../geom/circle/Random'); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Circle. + * + * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomCircle * @since 3.0.0 @@ -15,7 +17,7 @@ var Random = require('../geom/circle/Random'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/RandomEllipse.js b/src/actions/RandomEllipse.js index 466038550..1f3397be0 100644 --- a/src/actions/RandomEllipse.js +++ b/src/actions/RandomEllipse.js @@ -7,7 +7,9 @@ var Random = require('../geom/ellipse/Random'); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Ellipse. + * + * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomEllipse * @since 3.0.0 @@ -15,7 +17,7 @@ var Random = require('../geom/ellipse/Random'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Ellipse} ellipse - [description] + * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/RandomLine.js b/src/actions/RandomLine.js index 461f4c869..52e2c5209 100644 --- a/src/actions/RandomLine.js +++ b/src/actions/RandomLine.js @@ -7,7 +7,9 @@ var Random = require('../geom/line/Random'); /** - * [description] + * Takes an array of Game Objects and positions them at random locations on the Line. + * + * If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomLine * @since 3.0.0 @@ -15,7 +17,7 @@ var Random = require('../geom/line/Random'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The Line to position the Game Objects randomly on. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/RandomRectangle.js b/src/actions/RandomRectangle.js index 0b4e753a8..687afc3fd 100644 --- a/src/actions/RandomRectangle.js +++ b/src/actions/RandomRectangle.js @@ -7,7 +7,7 @@ var Random = require('../geom/rectangle/Random'); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Ellipse. * * @function Phaser.Actions.RandomRectangle * @since 3.0.0 @@ -15,7 +15,7 @@ var Random = require('../geom/rectangle/Random'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/RandomTriangle.js b/src/actions/RandomTriangle.js index 38728ca77..e8e0492d3 100644 --- a/src/actions/RandomTriangle.js +++ b/src/actions/RandomTriangle.js @@ -7,7 +7,9 @@ var Random = require('../geom/triangle/Random'); /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Triangle. + * + * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * * @function Phaser.Actions.RandomTriangle * @since 3.0.0 @@ -15,7 +17,7 @@ var Random = require('../geom/triangle/Random'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects within. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/RotateAroundDistance.js b/src/actions/RotateAroundDistance.js index 1b010d5a4..c503ffbd2 100644 --- a/src/actions/RotateAroundDistance.js +++ b/src/actions/RotateAroundDistance.js @@ -7,7 +7,7 @@ var MathRotateAroundDistance = require('../math/RotateAroundDistance'); /** - * [description] + * Rotates an array of Game Objects around a point by the given angle and distance. * * @function Phaser.Actions.RotateAroundDistance * @since 3.0.0 diff --git a/src/actions/SetHitArea.js b/src/actions/SetHitArea.js index 1a6074e6e..870330b67 100644 --- a/src/actions/SetHitArea.js +++ b/src/actions/SetHitArea.js @@ -5,7 +5,9 @@ */ /** - * [description] + * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. + * + * @see {@link Phaser.GameObjects.GameObject#setInteractive} * * @function Phaser.Actions.SetHitArea * @since 3.0.0 @@ -13,8 +15,8 @@ * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {*} hitArea - [description] - * @param {HitAreaCallback} hitAreaCallback - [description] + * @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. + * @param {HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/SetTint.js b/src/actions/SetTint.js index 9bf1d9059..02a90772b 100644 --- a/src/actions/SetTint.js +++ b/src/actions/SetTint.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Takes an array of Game Objects, or any objects that have the public method setTint() and then updates it to the given value(s). You can specify tint color per corner or provide only one color value for `topLeft` parameter, in which case whole item will be tinted with that color. * * @function Phaser.Actions.SetTint * @since 3.0.0 @@ -13,10 +13,10 @@ * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} topLeft - [description] - * @param {number} [topRight] - [description] - * @param {number} [bottomLeft] - [description] - * @param {number} [bottomRight] - [description] + * @param {number} topLeft - The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. + * @param {number} [topRight] - The tint to be applied to top-right corner of item. + * @param {number} [bottomLeft] - The tint to be applied to the bottom-left corner of item. + * @param {number} [bottomRight] - The tint to be applied to the bottom-right corner of item. * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/ShiftPosition.js b/src/actions/ShiftPosition.js index dbd8ba33c..9ea29f67b 100644 --- a/src/actions/ShiftPosition.js +++ b/src/actions/ShiftPosition.js @@ -7,9 +7,11 @@ var Vector2 = require('../math/Vector2'); /** - * Iterate through items changing the position of each element to - * be that of the element that came before it in the array (or after it if direction = 1) + * Iterate through the items array changing the position of each element to be that of the element that came before + * it in the array (or after it if direction = 1) + * * The first items position is set to x/y. + * * The final x/y coords are returned * * @function Phaser.Actions.ShiftPosition @@ -19,10 +21,10 @@ var Vector2 = require('../math/Vector2'); * @generic {Phaser.Math.Vector2} O - [output,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {number} x - [description] - * @param {number} y - [description] - * @param {integer} [direction=0] - [description] - * @param {(Phaser.Math.Vector2|object)} [output] - [description] + * @param {number} x - The x coordinate to place the first item in the array at. + * @param {number} y - The y coordinate to place the first item in the array at. + * @param {integer} [direction=0] - The iteration direction. 0 = first to last and 1 = last to first. + * @param {(Phaser.Math.Vector2|object)} [output] - An optional objec to store the final objects position in. * * @return {Phaser.Math.Vector2} The output vector. */ diff --git a/src/actions/SmoothStep.js b/src/actions/SmoothStep.js index 6c920e35a..ba341f2b4 100644 --- a/src/actions/SmoothStep.js +++ b/src/actions/SmoothStep.js @@ -7,7 +7,9 @@ var MathSmoothStep = require('../math/SmoothStep'); /** - * [description] + * Smoothstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * * @function Phaser.Actions.SmoothStep * @since 3.0.0 @@ -15,10 +17,10 @@ var MathSmoothStep = require('../math/SmoothStep'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The minimum interpolation value. + * @param {number} max - The maximum interpolation value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/SmootherStep.js b/src/actions/SmootherStep.js index dea70d376..d70b56c46 100644 --- a/src/actions/SmootherStep.js +++ b/src/actions/SmootherStep.js @@ -7,7 +7,9 @@ var MathSmootherStep = require('../math/SmootherStep'); /** - * [description] + * Smootherstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * * @function Phaser.Actions.SmootherStep * @since 3.0.0 @@ -15,10 +17,10 @@ var MathSmootherStep = require('../math/SmootherStep'); * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} inc - [description] + * @param {string} property - The property of the Game Object to interpolate. + * @param {number} min - The minimum interpolation value. + * @param {number} max - The maximum interpolation value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. */ diff --git a/src/actions/Spread.js b/src/actions/Spread.js index e20a72cec..040e7ea49 100644 --- a/src/actions/Spread.js +++ b/src/actions/Spread.js @@ -5,7 +5,16 @@ */ /** - * [description] + * Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, the + * calculated spread value. + * + * The spread value is derived from the given `min` and `max` values and the total number of items in the array.//#endregion + * + * For example, to cause an array of Sprites to change in alpha from 0 to 1 you could call: + * + * ```javascript + * Phaser.Actions.Spread(itemsArray, 'alpha', 0, 1); + * ``` * * @function Phaser.Actions.Spread * @since 3.0.0 @@ -13,12 +22,12 @@ * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. - * @param {string} property - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} [inc=false] - [description] + * @param {string} property - The property of the Game Object to spread. + * @param {number} min - The minimum value. + * @param {number} max - The maximum value. + * @param {boolean} [inc=false] - Should the values be incremented? `true` or set (`false`) * - * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. + * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that were passed to this Action. */ var Spread = function (items, property, min, max, inc) { diff --git a/src/actions/ToggleVisible.js b/src/actions/ToggleVisible.js index f02eb98b9..e6cd15be9 100644 --- a/src/actions/ToggleVisible.js +++ b/src/actions/ToggleVisible.js @@ -5,7 +5,8 @@ */ /** - * [description] + * Takes an array of Game Objects and toggles the visibility of each one. + * Those previously `visible = false` will become `visible = true`, and vice versa. * * @function Phaser.Actions.ToggleVisible * @since 3.0.0 diff --git a/src/animations/Animation.js b/src/animations/Animation.js index c6f83bf8b..1465d64e2 100644 --- a/src/animations/Animation.js +++ b/src/animations/Animation.js @@ -6,6 +6,7 @@ var Clamp = require('../math/Clamp'); var Class = require('../utils/Class'); +var EventEmitter = require('eventemitter3'); var FindClosestInSorted = require('../utils/array/FindClosestInSorted'); var Frame = require('./AnimationFrame'); var GetValue = require('../utils/object/GetValue'); @@ -64,7 +65,8 @@ var GetValue = require('../utils/object/GetValue'); * So multiple Game Objects can have playheads all pointing to this one Animation instance. * * @class Animation - * @memberOf Phaser.Animations + * @memberof Phaser.Animations + * @extends Phaser.Events.EventEmitter * @constructor * @since 3.0.0 * @@ -74,10 +76,14 @@ var GetValue = require('../utils/object/GetValue'); */ var Animation = new Class({ + Extends: EventEmitter, + initialize: function Animation (manager, key, config) { + EventEmitter.call(this); + /** * A reference to the global Animation Manager * @@ -529,14 +535,20 @@ var Animation = new Class({ component.msPerFrame = this.msPerFrame; component.skipMissedFrames = this.skipMissedFrames; - component._timeScale = 1; component._delay = this.delay; component._repeat = this.repeat; component._repeatDelay = this.repeatDelay; component._yoyo = this.yoyo; } - component.updateFrame(this.frames[startFrame]); + var frame = this.frames[startFrame]; + + if (startFrame === 0 && !component.forward) + { + frame = this.getLastFrame(); + } + + component.updateFrame(frame); }, /** @@ -577,17 +589,20 @@ var Animation = new Class({ // Yoyo? (happens before repeat) if (component._yoyo) { - component.forward = false; - - component.updateFrame(frame.prevFrame); - - // Delay for the current frame - this.getNextTick(component); + this.handleYoyoFrame(component, false); } else if (component.repeatCounter > 0) { // Repeat (happens before complete) - this.repeatAnimation(component); + + if (component._reverse && component.forward) + { + component.forward = false; + } + else + { + this.repeatAnimation(component); + } } else { @@ -596,12 +611,60 @@ var Animation = new Class({ } else { - component.updateFrame(frame.nextFrame); - - this.getNextTick(component); + this.updateAndGetNextTick(component, frame.nextFrame); } }, + /** + * Handle the yoyo functionality in nextFrame and previousFrame methods. + * + * @method Phaser.Animations.Animation#handleYoyoFrame + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.Components.Animation} component - The Animation Component to advance. + * @param {boolean} isReverse - Is animation in reverse mode? (Default: false) + */ + handleYoyoFrame: function (component, isReverse) + { + if (!isReverse) { isReverse = false; } + + if (component._reverse === !isReverse && component.repeatCounter > 0) + { + component.forward = isReverse; + + this.repeatAnimation(component); + + return; + } + + if (component._reverse !== isReverse && component.repeatCounter === 0) + { + this.completeAnimation(component); + + return; + } + + component.forward = isReverse; + + var frame = (isReverse) ? component.currentFrame.nextFrame : component.currentFrame.prevFrame; + + this.updateAndGetNextTick(component, frame); + }, + + /** + * Returns the animation last frame. + * + * @method Phaser.Animations.Animation#getLastFrame + * @since 3.12.0 + * + * @return {Phaser.Animations.AnimationFrame} component - The Animation Last Frame. + */ + getLastFrame: function () + { + return this.frames[this.frames.length - 1]; + }, + /** * [description] * @@ -620,10 +683,23 @@ var Animation = new Class({ { // We're at the start of the animation - if (component.repeatCounter > 0) + if (component._yoyo) { - // Repeat (happens before complete) - this.repeatAnimation(component); + this.handleYoyoFrame(component, true); + } + else if (component.repeatCounter > 0) + { + if (component._reverse && !component.forward) + { + component.currentFrame = this.getLastFrame(); + this.repeatAnimation(component); + } + else + { + // Repeat (happens before complete) + component.forward = true; + this.repeatAnimation(component); + } } else { @@ -632,12 +708,26 @@ var Animation = new Class({ } else { - component.updateFrame(frame.prevFrame); - - this.getNextTick(component); + this.updateAndGetNextTick(component, frame.prevFrame); } }, + /** + * Update Frame and Wait next tick. + * + * @method Phaser.Animations.Animation#updateAndGetNextTick + * @private + * @since 3.12.0 + * + * @param {Phaser.Animations.AnimationFrame} frame - An Animation frame. + */ + updateAndGetNextTick: function (component, frame) + { + component.updateFrame(frame); + + this.getNextTick(component); + }, + /** * [description] * @@ -705,9 +795,7 @@ var Animation = new Class({ { component.repeatCounter--; - component.forward = true; - - component.updateFrame(component.currentFrame.nextFrame); + component.updateFrame(component.currentFrame[(component.forward) ? 'nextFrame' : 'prevFrame']); if (component.isPlaying) { @@ -715,13 +803,20 @@ var Animation = new Class({ component.pendingRepeat = false; - component.parent.emit('animationrepeat', this, component.currentFrame, component.repeatCounter); + var frame = component.currentFrame; + var parent = component.parent; + + this.emit('repeat', this, frame); + + parent.emit('animationrepeat-' + this.key, this, frame, component.repeatCounter, parent); + + parent.emit('animationrepeat', this, frame, component.repeatCounter, parent); } } }, /** - * [description] + * Sets the texture frame the animation uses for rendering. * * @method Phaser.Animations.Animation#setFrame * @since 3.0.0 @@ -742,7 +837,7 @@ var Animation = new Class({ }, /** - * [description] + * Converts the animation data to JSON. * * @method Phaser.Animations.Animation#toJSON * @since 3.0.0 @@ -857,6 +952,8 @@ var Animation = new Class({ */ destroy: function () { + this.removeAllListeners(); + this.manager.off('pauseall', this.pause, this); this.manager.off('resumeall', this.resume, this); diff --git a/src/animations/AnimationFrame.js b/src/animations/AnimationFrame.js index bfcb532e7..f0994a31f 100644 --- a/src/animations/AnimationFrame.js +++ b/src/animations/AnimationFrame.js @@ -19,13 +19,12 @@ var Class = require('../utils/Class'); * A single frame in an Animation sequence. * * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other - * frames in the animation, and index data. It also has the ability to fire its own `onUpdate` callback - * and modify the animation timing. + * frames in the animation, and index data. It also has the ability to modify the animation timing. * * AnimationFrames are generated automatically by the Animation class. * * @class AnimationFrame - * @memberOf Phaser.Animations + * @memberof Phaser.Animations * @constructor * @since 3.0.0 * @@ -82,7 +81,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#isFirst * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isFirst = false; @@ -93,7 +92,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#isLast * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isLast = false; @@ -104,7 +103,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#prevFrame * @type {?Phaser.Animations.AnimationFrame} * @default null - * @readOnly + * @readonly * @since 3.0.0 */ this.prevFrame = null; @@ -115,7 +114,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#nextFrame * @type {?Phaser.Animations.AnimationFrame} * @default null - * @readOnly + * @readonly * @since 3.0.0 */ this.nextFrame = null; @@ -138,7 +137,7 @@ var AnimationFrame = new Class({ * @name Phaser.Animations.AnimationFrame#progress * @type {number} * @default 0 - * @readOnly + * @readonly * @since 3.0.0 */ this.progress = 0; diff --git a/src/animations/AnimationManager.js b/src/animations/AnimationManager.js index 61eb8b67b..3f7d4055f 100644 --- a/src/animations/AnimationManager.js +++ b/src/animations/AnimationManager.js @@ -14,8 +14,8 @@ var Pad = require('../utils/string/Pad'); /** * @typedef {object} JSONAnimationManager * - * @property {JSONAnimation[]} anims - [description] - * @property {number} globalTimeScale - [description] + * @property {JSONAnimation[]} anims - An array of all Animations added to the Animation Manager. + * @property {number} globalTimeScale - The global time scale of the Animation Manager. */ /** @@ -30,11 +30,11 @@ var Pad = require('../utils/string/Pad'); * * @class AnimationManager * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Animations + * @memberof Phaser.Animations * @constructor * @since 3.0.0 * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - A reference to the Phaser.Game instance. */ var AnimationManager = new Class({ @@ -47,7 +47,7 @@ var AnimationManager = new Class({ EventEmitter.call(this); /** - * [description] + * A reference to the Phaser.Game instance. * * @name Phaser.Animations.AnimationManager#game * @type {Phaser.Game} @@ -57,7 +57,7 @@ var AnimationManager = new Class({ this.game = game; /** - * [description] + * A reference to the Texture Manager. * * @name Phaser.Animations.AnimationManager#textureManager * @type {Phaser.Textures.TextureManager} @@ -67,7 +67,9 @@ var AnimationManager = new Class({ this.textureManager = null; /** - * [description] + * The global time scale of the Animation Manager. + * + * This scales the time delta between two frames, thus influencing the speed of time for the Animation Manager. * * @name Phaser.Animations.AnimationManager#globalTimeScale * @type {number} @@ -77,7 +79,9 @@ var AnimationManager = new Class({ this.globalTimeScale = 1; /** - * [description] + * The Animations registered in the Animation Manager. + * + * This map should be modified with the {@link #add} and {@link #create} methods of the Animation Manager. * * @name Phaser.Animations.AnimationManager#anims * @type {Phaser.Structs.Map.} @@ -87,7 +91,7 @@ var AnimationManager = new Class({ this.anims = new CustomMap(); /** - * [description] + * Whether the Animation Manager is paused along with all of its Animations. * * @name Phaser.Animations.AnimationManager#paused * @type {boolean} @@ -97,7 +101,7 @@ var AnimationManager = new Class({ this.paused = false; /** - * [description] + * The name of this Animation Manager. * * @name Phaser.Animations.AnimationManager#name * @type {string} @@ -109,7 +113,7 @@ var AnimationManager = new Class({ }, /** - * [description] + * Registers event listeners after the Game boots. * * @method Phaser.Animations.AnimationManager#boot * @since 3.0.0 @@ -122,14 +126,14 @@ var AnimationManager = new Class({ }, /** - * [description] + * Adds an existing Animation to the Animation Manager. * * @method Phaser.Animations.AnimationManager#add * @fires AddAnimationEvent * @since 3.0.0 * - * @param {string} key - [description] - * @param {Phaser.Animations.Animation} animation - [description] + * @param {string} key - The key under which the Animation should be added. The Animation will be updated with it. Must be unique. + * @param {Phaser.Animations.Animation} animation - The Animation which should be added to the Animation Manager. * * @return {Phaser.Animations.AnimationManager} This Animation Manager. */ @@ -151,43 +155,74 @@ var AnimationManager = new Class({ }, /** - * [description] + * Checks to see if the given key is already in use within the Animation Manager or not. + * + * Animations are global. Keys created in one scene can be used from any other Scene in your game. They are not Scene specific. + * + * @method Phaser.Animations.AnimationManager#exists + * @since 3.16.0 + * + * @param {string} key - The key of the Animation to check. + * + * @return {boolean} `true` if the Animation already exists in the Animation Manager, or `false` if the key is available. + */ + exists: function (key) + { + return this.anims.has(key); + }, + + /** + * Creates a new Animation and adds it to the Animation Manager. + * + * Animations are global. Once created, you can use them in any Scene in your game. They are not Scene specific. + * + * If an invalid key is given this method will return `false`. + * + * If you pass the key of an animation that already exists in the Animation Manager, that animation will be returned. + * + * A brand new animation is only created if the key is valid and not already in use. + * + * If you wish to re-use an existing key, call `AnimationManager.remove` first, then this method. * * @method Phaser.Animations.AnimationManager#create * @fires AddAnimationEvent * @since 3.0.0 * - * @param {AnimationConfig} config - [description] + * @param {AnimationConfig} config - The configuration settings for the Animation. * - * @return {Phaser.Animations.Animation} The Animation that was created. + * @return {(Phaser.Animations.Animation|false)} The Animation that was created, or `false` is the key is already in use. */ create: function (config) { var key = config.key; - if (!key || this.anims.has(key)) + var anim = false; + + if (key) { - console.warn('Invalid Animation Key, or Key already in use: ' + key); - return; + anim = this.get(key); + + if (!anim) + { + anim = new Animation(this, key, config); + + this.anims.set(key, anim); + + this.emit('add', key, anim); + } } - var anim = new Animation(this, key, config); - - this.anims.set(key, anim); - - this.emit('add', key, anim); - return anim; }, /** - * [description] + * Loads this Animation Manager's Animations and settings from a JSON object. * * @method Phaser.Animations.AnimationManager#fromJSON * @since 3.0.0 * - * @param {(string|JSONAnimationManager|JSONAnimation)} data - [description] - * @param {boolean} [clearCurrentAnimations=false] - [description] + * @param {(string|JSONAnimationManager|JSONAnimation)} data - The JSON object to parse. + * @param {boolean} [clearCurrentAnimations=false] - If set to `true`, the current animations will be removed (`anims.clear()`). If set to `false` (default), the animations in `data` will be added. * * @return {Phaser.Animations.Animation[]} An array containing all of the Animation objects that were created as a result of this call. */ @@ -232,13 +267,13 @@ var AnimationManager = new Class({ /** * @typedef {object} GenerateFrameNamesConfig * - * @property {string} [prefix=''] - [description] - * @property {integer} [start=0] - [description] - * @property {integer} [end=0] - [description] - * @property {string} [suffix=''] - [description] - * @property {integer} [zeroPad=0] - [description] - * @property {AnimationFrameConfig[]} [outputArray=[]] - [description] - * @property {boolean} [frames=false] - [description] + * @property {string} [prefix=''] - The string to append to every resulting frame name if using a range or an array of `frames`. + * @property {integer} [start=0] - If `frames` is not provided, the number of the first frame to return. + * @property {integer} [end=0] - If `frames` is not provided, the number of the last frame to return. + * @property {string} [suffix=''] - The string to append to every resulting frame name if using a range or an array of `frames`. + * @property {integer} [zeroPad=0] - The minimum expected lengths of each resulting frame's number. Numbers will be left-padded with zeroes until they are this long, then prepended and appended to create the resulting frame name. + * @property {AnimationFrameConfig[]} [outputArray=[]] - The array to append the created configuration objects to. + * @property {boolean} [frames=false] - If provided as an array, the range defined by `start` and `end` will be ignored and these frame numbers will be used. */ /** @@ -247,10 +282,10 @@ var AnimationManager = new Class({ * @method Phaser.Animations.AnimationManager#generateFrameNames * @since 3.0.0 * - * @param {string} key - [description] - * @param {GenerateFrameNamesConfig} [config] - [description] + * @param {string} key - The key for the texture containing the animation frames. + * @param {GenerateFrameNamesConfig} [config] - The configuration object for the animation frame names. * - * @return {AnimationFrameConfig[]} [description] + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects. */ generateFrameNames: function (key, config) { @@ -319,23 +354,25 @@ var AnimationManager = new Class({ /** * @typedef {object} GenerateFrameNumbersConfig * - * @property {integer} [start=0] - [description] - * @property {integer} [end=-1] - [description] - * @property {boolean} [first=false] - [description] - * @property {AnimationFrameConfig[]} [outputArray=[]] - [description] - * @property {boolean} [frames=false] - [description] + * @property {integer} [start=0] - The starting frame of the animation. + * @property {integer} [end=-1] - The ending frame of the animation. + * @property {(boolean|integer)} [first=false] - A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. + * @property {AnimationFrameConfig[]} [outputArray=[]] - An array to concatenate the output onto. + * @property {(boolean|integer[])} [frames=false] - A custom sequence of frames. */ /** - * [description] + * Generate an array of {@link AnimationFrameConfig} objects from a texture key and configuration object. + * + * Generates objects with numbered frame names, as configured by the given {@link GenerateFrameNumbersConfig}. * * @method Phaser.Animations.AnimationManager#generateFrameNumbers * @since 3.0.0 * - * @param {string} key - [description] - * @param {GenerateFrameNumbersConfig} config - [description] + * @param {string} key - The key for the texture containing the animation frames. + * @param {GenerateFrameNumbersConfig} config - The configuration object for the animation frames. * - * @return {AnimationFrameConfig[]} [description] + * @return {AnimationFrameConfig[]} The array of {@link AnimationFrameConfig} objects. */ generateFrameNumbers: function (key, config) { @@ -391,14 +428,14 @@ var AnimationManager = new Class({ }, /** - * [description] + * Get an Animation. * * @method Phaser.Animations.AnimationManager#get * @since 3.0.0 * - * @param {string} key - [description] + * @param {string} key - The key of the Animation to retrieve. * - * @return {Phaser.Animations.Animation} [description] + * @return {Phaser.Animations.Animation} The Animation. */ get: function (key) { @@ -406,16 +443,16 @@ var AnimationManager = new Class({ }, /** - * Load an Animation into a Game Objects Animation Component. + * Load an Animation into a Game Object's Animation Component. * * @method Phaser.Animations.AnimationManager#load * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] - * @param {string} key - [description] - * @param {(string|integer)} [startFrame] - [description] + * @param {Phaser.GameObjects.GameObject} child - The Game Object to load the animation into. + * @param {string} key - The key of the animation to load. + * @param {(string|integer)} [startFrame] - The name of a start frame to set on the loaded animation. * - * @return {Phaser.GameObjects.GameObject} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object with the animation loaded into it. */ load: function (child, key, startFrame) { @@ -430,7 +467,7 @@ var AnimationManager = new Class({ }, /** - * [description] + * Pause all animations. * * @method Phaser.Animations.AnimationManager#pauseAll * @fires PauseAllAnimationEvent @@ -451,13 +488,13 @@ var AnimationManager = new Class({ }, /** - * [description] + * Play an animation on the given Game Objects that have an Animation Component. * * @method Phaser.Animations.AnimationManager#play * @since 3.0.0 * - * @param {string} key - [description] - * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {string} key - The key of the animation to play on the Game Object. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} child - The Game Objects to play the animation on. * * @return {Phaser.Animations.AnimationManager} This Animation Manager. */ @@ -484,13 +521,13 @@ var AnimationManager = new Class({ }, /** - * [description] + * Remove an animation. * * @method Phaser.Animations.AnimationManager#remove * @fires RemoveAnimationEvent * @since 3.0.0 * - * @param {string} key - [description] + * @param {string} key - The key of the animation to remove. * * @return {Phaser.Animations.Animation} [description] */ @@ -509,7 +546,7 @@ var AnimationManager = new Class({ }, /** - * [description] + * Resume all paused animations. * * @method Phaser.Animations.AnimationManager#resumeAll * @fires ResumeAllAnimationEvent @@ -530,17 +567,17 @@ var AnimationManager = new Class({ }, /** - * Takes an array of Game Objects that have the Animation Component and then + * Takes an array of Game Objects that have an Animation Component and then * starts the given animation playing on them, each one offset by the * `stagger` amount given to this method. * * @method Phaser.Animations.AnimationManager#staggerPlay * @since 3.0.0 - * + * * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * * @param {string} key - The key of the animation to play on the Game Objects. - * @param {Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have the Animation Component. + * @param {Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]} children - An array of Game Objects to play the animation on. They must have an Animation Component. * @param {number} [stagger=0] - The amount of time, in milliseconds, to offset each play time by. * * @return {Phaser.Animations.AnimationManager} This Animation Manager. @@ -570,7 +607,7 @@ var AnimationManager = new Class({ }, /** - * [description] + * Get the animation data as javascript object by giving key, or get the data of all animations as array of objects, if key wasn't provided. * * @method Phaser.Animations.AnimationManager#toJSON * @since 3.0.0 @@ -602,7 +639,8 @@ var AnimationManager = new Class({ }, /** - * [description] + * Destroy this Animation Manager and clean up animation definitions and references to other objects. + * This method should not be called directly. It will be called automatically as a response to a `destroy` event from the Phaser.Game instance. * * @method Phaser.Animations.AnimationManager#destroy * @since 3.0.0 diff --git a/src/boot/Config.js b/src/boot/Config.js index 7211a1756..5502ba94e 100644 --- a/src/boot/Config.js +++ b/src/boot/Config.js @@ -6,10 +6,11 @@ var Class = require('../utils/Class'); var CONST = require('../const'); +var Device = require('../device'); var GetFastValue = require('../utils/object/GetFastValue'); var GetValue = require('../utils/object/GetValue'); var IsPlainObject = require('../utils/object/IsPlainObject'); -var MATH = require('../math/const'); +var PhaserMath = require('../math/'); var NOOP = require('../utils/NOOP'); var DefaultPlugins = require('../plugins/DefaultPlugins'); var ValueToColor = require('../display/color/ValueToColor'); @@ -23,98 +24,224 @@ var ValueToColor = require('../display/color/ValueToColor'); /** * @callback BootCallback * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - The game. + */ + +/** + * Config object containing various sound settings. + * + * @typedef {object} AudioConfig + * + * @property {boolean} [disableWebAudio=false] - Use HTML5 Audio instead of Web Audio. + * @property {AudioContext} [context] - An existing Web Audio context. + * @property {boolean} [noAudio=false] - Disable all audio output. + * + * @see Phaser.Sound.SoundManagerCreator + */ + +/** + * @typedef {object} InputConfig + * + * @property {(boolean|KeyboardInputConfig)} [keyboard=true] - Keyboard input configuration. `true` uses the default configuration and `false` disables keyboard input. + * @property {(boolean|MouseInputConfig)} [mouse=true] - Mouse input configuration. `true` uses the default configuration and `false` disables mouse input. + * @property {(boolean|TouchInputConfig)} [touch=true] - Touch input configuration. `true` uses the default configuration and `false` disables touch input. + * @property {(boolean|GamepadInputConfig)} [gamepad=false] - Gamepad input configuration. `true` enables gamepad input. + * @property {integer} [activePointers=1] - The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}. + * @property {number} [smoothFactor=0] - The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. + */ + +/** + * @typedef {object} MouseInputConfig + * + * @property {*} [target=null] - Where the Mouse Manager listens for mouse input events. The default is the game canvas. + * @property {boolean} [capture=true] - Whether mouse input events have `preventDefault` called on them. + */ + +/** + * @typedef {object} KeyboardInputConfig + * + * @property {*} [target=window] - Where the Keyboard Manager listens for keyboard input events. + * @property {?integer} [capture] - `preventDefault` will be called on every non-modified key which has a key code in this array. By default it is empty. + */ + +/** + * @typedef {object} TouchInputConfig + * + * @property {*} [target=null] - Where the Touch Manager listens for touch input events. The default is the game canvas. + * @property {boolean} [capture=true] - Whether touch input events have preventDefault() called on them. + */ + +/** + * @typedef {object} GamepadInputConfig + * + * @property {*} [target=window] - Where the Gamepad Manager listens for gamepad input events. + */ + +/** + * @typedef {object} BannerConfig + * + * @property {boolean} [hidePhaser=false] - Omit Phaser's name and version from the banner. + * @property {string} [text='#ffffff'] - The color of the banner text. + * @property {string[]} [background] - The background colors of the banner. */ /** * @typedef {object} FPSConfig * - * @property {integer} [min=10] - [description] - * @property {integer} [target=60] - [description] - * @property {boolean} [forceSetTimeOut=false] - [description] - * @property {integer} [deltaHistory=10] - [description] - * @property {integer} [panicMax=120] - [description] + * @property {integer} [min=5] - The minimum acceptable rendering rate, in frames per second. + * @property {integer} [target=60] - The optimum rendering rate, in frames per second. + * @property {boolean} [forceSetTimeOut=false] - Use setTimeout instead of requestAnimationFrame to run the game loop. + * @property {integer} [deltaHistory=10] - Calculate the average frame delta from this many consecutive frame intervals. + * @property {integer} [panicMax=120] - The amount of frames the time step counts before we trust the delta values again. + */ + +/** + * @typedef {object} RenderConfig + * + * @property {boolean} [antialias=true] - When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. + * @property {boolean} [pixelArt=false] - Sets `antialias` and `roundPixels` to true. This is the best setting for pixel-art games. + * @property {boolean} [autoResize=true] - Automatically resize the Game Canvas if you resize the renderer. + * @property {boolean} [roundPixels=false] - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. + * @property {boolean} [transparent=false] - Whether the game canvas will be transparent. + * @property {boolean} [clearBeforeRender=true] - Whether the game canvas will be cleared between each rendering frame. + * @property {boolean} [premultipliedAlpha=true] - In WebGL mode, the drawing buffer contains colors with pre-multiplied alpha. + * @property {boolean} [failIfMajorPerformanceCaveat=false] - Let the browser abort creating a WebGL context if it judges performance would be unacceptable. + * @property {string} [powerPreference='default'] - "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. + * @property {integer} [batchSize=2000] - The default WebGL batch size. + * @property {integer} [maxLights=10] - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + +/** + * @typedef {object} ScaleConfig + * + * @property {(integer|string)} [width=1024] - The base width of your game. + * @property {(integer|string)} [height=768] - The base height of your game. + * @property {integer} [zoom=1] - The zoom value of the game canvas. + * @property {number} [resolution=1] - The rendering resolution of the canvas. + * @property {(HTMLElement|string)} [parent] - The DOM element that will contain the game canvas, or its `id`. If null (the default) or if the named element doesn't exist, the game canvas is inserted directly into the document body. + * @property {integer} [mode=0] - The scale mode to apply to the canvas. SHOW_ALL, EXACT_FIT, USER_SCALE, or RESIZE. + * @property {integer} [minWidth] - The minimum width the canvas can be scaled down to. + * @property {integer} [minHeight] - The minimum height the canvas can be scaled down to. + * @property {integer} [maxWidth] - The maximum width the canvas can be scaled up to. + * @property {integer} [maxHeight] - The maximum height the canvas can be scaled up to. + */ + +/** + * @typedef {object} CallbacksConfig + * + * @property {BootCallback} [preBoot=NOOP] - A function to run at the start of the boot sequence. + * @property {BootCallback} [postBoot=NOOP] - A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. */ /** * @typedef {object} LoaderConfig * - * @property {string} [baseURL] - [description] - * @property {string} [path] - [description] - * @property {integer} [maxParallelDownloads=32] - [description] - * @property {(string|undefined)} [crossOrigin=undefined] - [description] - * @property {string} [responseType] - [description] - * @property {boolean} [async=true] - [description] - * @property {string} [user] - [description] - * @property {string} [password] - [description] - * @property {integer} [timeout=0] - [description] + * @property {string} [baseURL] - A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. + * @property {string} [path] - A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. + * @property {integer} [maxParallelDownloads=32] - The maximum number of resources the loader will start loading at once. + * @property {(string|undefined)} [crossOrigin=undefined] - 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. + * @property {string} [responseType] - The response type of the XHR request, e.g. `blob`, `text`, etc. + * @property {boolean} [async=true] - Should the XHR request use async or not? + * @property {string} [user] - Optional username for all XHR requests. + * @property {string} [password] - Optional password for all XHR requests. + * @property {integer} [timeout=0] - Optional XHR timeout value, in ms. + */ + +/** + * @typedef {object} DOMContainerConfig + * + * @property {boolean} [createContainer=false] - Create a div element in which DOM Elements will be contained. You must also provide a parent. + * @property {boolean} [behindCanvas=false] - Place the DOM Container behind the Phaser Canvas. The default is to place it over the Canvas. + */ + +/** + * @typedef {object} ImagesConfig + * + * @property {string} [default] - URL to use for the 'default' texture. + * @property {string} [missing] - URL to use for the 'missing' texture. + */ + +/** + * @typedef {object} PhysicsConfig + * + * @property {string} [default] - The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'. + * @property {ArcadeWorldConfig} [arcade] - Arcade Physics configuration. + * @property {Phaser.Physics.Impact.WorldConfig} [impact] - Impact Physics configuration. + * @property {object} [matter] - Matter Physics configuration. + */ + +/** + * @typedef {object} PluginObjectItem + * + * @property {string} [key] - A key to identify the plugin in the Plugin Manager. + * @property {*} [plugin] - The plugin itself. Usually a class/constructor. + * @property {boolean} [start] - Whether the plugin should be started automatically. + * @property {string} [systemKey] - For a scene plugin, add the plugin to the scene's systems object under this key (`this.sys.KEY`, from the scene). + * @property {string} [sceneKey] - For a scene plugin, add the plugin to the scene object under this key (`this.KEY`, from the scene). + * @property {string} [mapping] - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @property {*} [data] - Arbitrary data passed to the plugin's init() method. + * + * @example + * // Global plugin + * { key: 'BankPlugin', plugin: BankPluginV3, start: true, data: { gold: 5000 } } + * @example + * // Scene plugin + * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } + */ + +/** + * @typedef {object} PluginObject + * + * @property {?PluginObjectItem[]} [global] - Global plugins to install. + * @property {?PluginObjectItem[]} [scene] - Scene plugins to install. + * @property {string[]} [default] - The default set of scene plugins (names). + * @property {string[]} [defaultMerge] - Plugins to *add* to the default set of scene plugins. */ /** * @typedef {object} GameConfig * - * @property {(integer|string)} [width=1024] - [description] - * @property {(integer|string)} [height=768] - [description] - * @property {number} [zoom=1] - [description] - * @property {number} [resolution=1] - [description] - * @property {number} [type=CONST.AUTO] - [description] - * @property {*} [parent=null] - [description] + * @property {(integer|string)} [width=1024] - The width of the game, in game pixels. + * @property {(integer|string)} [height=768] - The height of the game, in game pixels. + * @property {number} [zoom=1] - Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc. + * @property {number} [resolution=1] - The size of each game pixel, in canvas pixels. Values larger than 1 are "high" resolution. + * @property {number} [type=CONST.AUTO] - Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS. + * @property {(HTMLElement|string)} [parent=null] - The DOM element that will contain the game canvas, or its `id`. If null (the default) or if the named element doesn't exist, the game canvas is inserted directly into the document body. * @property {HTMLCanvasElement} [canvas=null] - Provide your own Canvas element for Phaser to use instead of creating one. - * @property {string} [canvasStyle=null] - [description] + * @property {string} [canvasStyle=null] - CSS styles to apply to the game canvas instead of Phaser's default styles. * @property {CanvasRenderingContext2D} [context] - Provide your own Canvas Context for Phaser to use, instead of creating one. - * @property {object} [scene=null] - [description] - * @property {string[]} [seed] - [description] - * @property {string} [title=''] - [description] - * @property {string} [url='http://phaser.io'] - [description] - * @property {string} [version=''] - [description] - * @property {boolean} [autoFocus=true] - Automatically call window.focus() when the game boots. - * @property {(boolean|object)} [input] - [description] - * @property {boolean} [input.keyboard=true] - [description] - * @property {*} [input.keyboard.target=window] - [description] - * @property {(boolean|object)} [input.mouse=true] - [description] - * @property {*} [input.mouse.target=null] - [description] - * @property {boolean} [input.touch=true] - [description] - * @property {integer} [input.activePointers=1] - [description] - * @property {*} [input.touch.target=null] - [description] - * @property {boolean} [input.touch.capture=true] - [description] - * @property {(boolean|object)} [input.gamepad=false] - [description] - * @property {boolean} [disableContextMenu=false] - [description] - * @property {(boolean|object)} [banner=false] - [description] - * @property {boolean} [banner.hidePhaser=false] - [description] - * @property {string} [banner.text='#ffffff'] - [description] - * @property {string[]} [banner.background] - [description] - * @property {FPSConfig} [fps] - [description] - * @property {boolean} [render.antialias=true] - [description] - * @property {boolean} [render.pixelArt=false] - [description] - * @property {boolean} [render.autoResize=false] - [description] - * @property {boolean} [render.roundPixels=false] - [description] - * @property {boolean} [render.transparent=false] - [description] - * @property {boolean} [render.clearBeforeRender=true] - [description] - * @property {boolean} [render.premultipliedAlpha=true] - [description] - * @property {boolean} [render.preserveDrawingBuffer=false] - [description] - * @property {boolean} [render.failIfMajorPerformanceCaveat=false] - [description] - * @property {string} [render.powerPreference='default'] - "high-performance", "low-power" or "default" - * @property {(string|number)} [backgroundColor=0x000000] - [description] - * @property {object} [callbacks] - [description] - * @property {BootCallback} [callbacks.preBoot=NOOP] - [description] - * @property {BootCallback} [callbacks.postBoot=NOOP] - [description] - * @property {LoaderConfig} [loader] - [description] - * @property {object} [images] - [description] - * @property {string} [images.default] - [description] - * @property {string} [images.missing] - [description] - * @property {object} [physics] - [description] + * @property {object} [scene=null] - A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have { active: true }. + * @property {string[]} [seed] - Seed for the random number generator. + * @property {string} [title=''] - The title of the game. Shown in the browser console. + * @property {string} [url='http://phaser.io'] - The URL of the game. Shown in the browser console. + * @property {string} [version=''] - The version of the game. Shown in the browser console. + * @property {boolean} [autoFocus=true] - Automatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame. + * @property {(boolean|InputConfig)} [input] - Input configuration, or `false` to disable all game input. + * @property {boolean} [disableContextMenu=false] - Disable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click). + * @property {(boolean|BannerConfig)} [banner=false] - Configuration for the banner printed in the browser console when the game starts. + * @property {DOMContainerConfig} [dom] - The DOM Container configuration object. + * @property {FPSConfig} [fps] - Game loop configuration. + * @property {RenderConfig} [render] - Game renderer configuration. + * @property {(string|number)} [backgroundColor=0x000000] - The background color of the game canvas. The default is black. + * @property {CallbacksConfig} [callbacks] - Optional callbacks to run before or after game boot. + * @property {LoaderConfig} [loader] - Loader configuration. + * @property {ImagesConfig} [images] - Images configuration. + * @property {object} [physics] - Physics configuration. + * @property {PluginObject|PluginObjectItem[]} [plugins] - Plugins to install. */ /** * @classdesc - * [description] + * The active game configuration settings, parsed from a {@link GameConfig} object. * * @class Config - * @memberOf Phaser.Boot + * @memberof Phaser.Boot * @constructor * @since 3.0.0 * * @param {GameConfig} [GameConfig] - The configuration object for your Phaser Game instance. + * + * @see Phaser.Game#config */ var Config = new Class({ @@ -135,35 +262,84 @@ var Config = new Class({ var defaultBannerTextColor = '#ffffff'; /** - * @const {(integer|string)} Phaser.Boot.Config#width - [description] + * @const {(integer|string)} Phaser.Boot.Config#width - The width of the underlying canvas, in pixels. */ this.width = GetValue(config, 'width', 1024); /** - * @const {(integer|string)} Phaser.Boot.Config#height - [description] + * @const {(integer|string)} Phaser.Boot.Config#height - The height of the underlying canvas, in pixels. */ this.height = GetValue(config, 'height', 768); /** - * @const {number} Phaser.Boot.Config#zoom - [description] + * @const {number} Phaser.Boot.Config#zoom - The zoom factor, as used by the Scale Manager. */ this.zoom = GetValue(config, 'zoom', 1); /** - * @const {number} Phaser.Boot.Config#resolution - [description] + * @const {number} Phaser.Boot.Config#resolution - The canvas device pixel resolution. */ this.resolution = GetValue(config, 'resolution', 1); /** - * @const {number} Phaser.Boot.Config#renderType - [description] - */ - this.renderType = GetValue(config, 'type', CONST.AUTO); - - /** - * @const {?*} Phaser.Boot.Config#parent - [description] + * @const {?*} Phaser.Boot.Config#parent - A parent DOM element into which the canvas created by the renderer will be injected. */ this.parent = GetValue(config, 'parent', null); + /** + * @const {integer} Phaser.Boot.Config#scaleMode - The scale mode as used by the Scale Manager. The default is zero, which is no scaling. + */ + this.scaleMode = GetValue(config, 'scaleMode', 0); + + /** + * @const {boolean} Phaser.Boot.Config#expandParent - Is the Scale Manager allowed to adjust the size of the parent container? + */ + this.expandParent = GetValue(config, 'expandParent', false); + + /** + * @const {integer} Phaser.Boot.Config#minWidth - The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum. + */ + this.minWidth = GetValue(config, 'minWidth', 0); + + /** + * @const {integer} Phaser.Boot.Config#maxWidth - The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum. + */ + this.maxWidth = GetValue(config, 'maxWidth', 0); + + /** + * @const {integer} Phaser.Boot.Config#minHeight - The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum. + */ + this.minHeight = GetValue(config, 'minHeight', 0); + + /** + * @const {integer} Phaser.Boot.Config#maxHeight - The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum. + */ + this.maxHeight = GetValue(config, 'maxHeight', 0); + + // Scale Manager - Anything set in here over-rides anything set above + + var scaleConfig = GetValue(config, 'scale', null); + + if (scaleConfig) + { + this.width = GetValue(scaleConfig, 'width', this.width); + this.height = GetValue(scaleConfig, 'height', this.height); + this.zoom = GetValue(scaleConfig, 'zoom', this.zoom); + this.resolution = GetValue(scaleConfig, 'resolution', this.resolution); + this.parent = GetValue(scaleConfig, 'parent', this.parent); + this.scaleMode = GetValue(scaleConfig, 'mode', this.scaleMode); + this.expandParent = GetValue(scaleConfig, 'mode', this.expandParent); + this.minWidth = GetValue(scaleConfig, 'min.width', this.minWidth); + this.maxWidth = GetValue(scaleConfig, 'max.width', this.maxWidth); + this.minHeight = GetValue(scaleConfig, 'min.height', this.minHeight); + this.maxHeight = GetValue(scaleConfig, 'max.height', this.maxHeight); + } + + /** + * @const {number} Phaser.Boot.Config#renderType - Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) + */ + this.renderType = GetValue(config, 'type', CONST.AUTO); + /** * @const {?HTMLCanvasElement} Phaser.Boot.Config#canvas - Force Phaser to use your own Canvas element instead of creating one. */ @@ -175,128 +351,155 @@ var Config = new Class({ this.context = GetValue(config, 'context', null); /** - * @const {?string} Phaser.Boot.Config#canvasStyle - [description] + * @const {?string} Phaser.Boot.Config#canvasStyle - Optional CSS attributes to be set on the canvas object created by the renderer. */ this.canvasStyle = GetValue(config, 'canvasStyle', null); /** - * @const {?object} Phaser.Boot.Config#sceneConfig - [description] + * @const {boolean} Phaser.Boot.Config#customEnvironment - Is Phaser running under a custom (non-native web) environment? If so, set this to `true` to skip internal Feature detection. If `true` the `renderType` cannot be left as `AUTO`. + */ + this.customEnvironment = GetValue(config, 'customEnvironment', false); + + /** + * @const {?object} Phaser.Boot.Config#sceneConfig - The default Scene configuration object. */ this.sceneConfig = GetValue(config, 'scene', null); /** - * @const {string[]} Phaser.Boot.Config#seed - [description] + * @const {string[]} Phaser.Boot.Config#seed - A seed which the Random Data Generator will use. If not given, a dynamic seed based on the time is used. */ this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]); - MATH.RND.init(this.seed); + PhaserMath.RND = new PhaserMath.RandomDataGenerator(this.seed); /** - * @const {string} Phaser.Boot.Config#gameTitle - [description] + * @const {string} Phaser.Boot.Config#gameTitle - The title of the game. */ this.gameTitle = GetValue(config, 'title', ''); /** - * @const {string} Phaser.Boot.Config#gameURL - [description] + * @const {string} Phaser.Boot.Config#gameURL - The URL of the game. */ this.gameURL = GetValue(config, 'url', 'https://phaser.io'); /** - * @const {string} Phaser.Boot.Config#gameVersion - [description] + * @const {string} Phaser.Boot.Config#gameVersion - The version of the game. */ this.gameVersion = GetValue(config, 'version', ''); /** - * @const {boolean} Phaser.Boot.Config#autoFocus - [description] + * @const {boolean} Phaser.Boot.Config#autoFocus - If `true` the window will automatically be given focus immediately and on any future mousedown event. */ this.autoFocus = GetValue(config, 'autoFocus', true); + // DOM Element Container + + /** + * @const {?boolean} Phaser.Boot.Config#domCreateContainer - EXPERIMENTAL: Do not currently use. + */ + this.domCreateContainer = GetValue(config, 'dom.createContainer', false); + + /** + * @const {?boolean} Phaser.Boot.Config#domBehindCanvas - EXPERIMENTAL: Do not currently use. + */ + this.domBehindCanvas = GetValue(config, 'dom.behindCanvas', false); + // Input /** - * @const {boolean} Phaser.Boot.Config#inputKeyboard - [description] + * @const {boolean} Phaser.Boot.Config#inputKeyboard - Enable the Keyboard Plugin. This can be disabled in games that don't need keyboard input. */ this.inputKeyboard = GetValue(config, 'input.keyboard', true); /** - * @const {*} Phaser.Boot.Config#inputKeyboardEventTarget - [description] + * @const {*} Phaser.Boot.Config#inputKeyboardEventTarget - The DOM Target to listen for keyboard events on. Defaults to `window` if not specified. */ this.inputKeyboardEventTarget = GetValue(config, 'input.keyboard.target', window); /** - * @const {(boolean|object)} Phaser.Boot.Config#inputMouse - [description] + * @const {?integer[]} Phaser.Boot.Config#inputKeyboardCapture - `preventDefault` will be called on every non-modified key which has a key code in this array. By default, it is empty. + */ + this.inputKeyboardCapture = GetValue(config, 'input.keyboard.capture', []); + + /** + * @const {(boolean|object)} Phaser.Boot.Config#inputMouse - Enable the Mouse Plugin. This can be disabled in games that don't need mouse input. */ this.inputMouse = GetValue(config, 'input.mouse', true); /** - * @const {?*} Phaser.Boot.Config#inputMouseEventTarget - [description] + * @const {?*} Phaser.Boot.Config#inputMouseEventTarget - The DOM Target to listen for mouse events on. Defaults to the game canvas if not specified. */ this.inputMouseEventTarget = GetValue(config, 'input.mouse.target', null); /** - * @const {boolean} Phaser.Boot.Config#inputMouseCapture - [description] + * @const {boolean} Phaser.Boot.Config#inputMouseCapture - Should mouse events be captured? I.e. have prevent default called on them. */ this.inputMouseCapture = GetValue(config, 'input.mouse.capture', true); /** - * @const {boolean} Phaser.Boot.Config#inputTouch - [description] + * @const {boolean} Phaser.Boot.Config#inputTouch - Enable the Touch Plugin. This can be disabled in games that don't need touch input. */ - this.inputTouch = GetValue(config, 'input.touch', true); + this.inputTouch = GetValue(config, 'input.touch', Device.input.touch); /** - * @const {?*} Phaser.Boot.Config#inputTouchEventTarget - [description] + * @const {?*} Phaser.Boot.Config#inputTouchEventTarget - The DOM Target to listen for touch events on. Defaults to the game canvas if not specified. */ this.inputTouchEventTarget = GetValue(config, 'input.touch.target', null); /** - * @const {boolean} Phaser.Boot.Config#inputTouchCapture - [description] + * @const {boolean} Phaser.Boot.Config#inputTouchCapture - Should touch events be captured? I.e. have prevent default called on them. */ this.inputTouchCapture = GetValue(config, 'input.touch.capture', true); /** - * @const {integer} Phaser.Boot.Config#inputActivePointers - [description] + * @const {integer} Phaser.Boot.Config#inputActivePointers - The number of Pointer objects created by default. In a mouse-only, or non-multi touch game, you can leave this as 1. */ this.inputActivePointers = GetValue(config, 'input.activePointers', 1); /** - * @const {boolean} Phaser.Boot.Config#inputGamepad - [description] + * @const {integer} Phaser.Boot.Config#inputSmoothFactor - The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. + */ + this.inputSmoothFactor = GetValue(config, 'input.smoothFactor', 0); + + /** + * @const {boolean} Phaser.Boot.Config#inputGamepad - Enable the Gamepad Plugin. This can be disabled in games that don't need gamepad input. */ this.inputGamepad = GetValue(config, 'input.gamepad', false); /** - * @const {*} Phaser.Boot.Config#inputGamepadEventTarget - [description] + * @const {*} Phaser.Boot.Config#inputGamepadEventTarget - The DOM Target to listen for gamepad events on. Defaults to `window` if not specified. */ this.inputGamepadEventTarget = GetValue(config, 'input.gamepad.target', window); /** - * @const {boolean} Phaser.Boot.Config#disableContextMenu - [description] + * @const {boolean} Phaser.Boot.Config#disableContextMenu - Set to `true` to disable the right-click context menu. */ this.disableContextMenu = GetValue(config, 'disableContextMenu', false); /** - * @const {any} Phaser.Boot.Config#audio - [description] + * @const {AudioConfig} Phaser.Boot.Config#audio - The Audio Configuration object. */ this.audio = GetValue(config, 'audio'); // If you do: { banner: false } it won't display any banner at all /** - * @const {boolean} Phaser.Boot.Config#hideBanner - [description] + * @const {boolean} Phaser.Boot.Config#hideBanner - Don't write the banner line to the console.log. */ this.hideBanner = (GetValue(config, 'banner', null) === false); /** - * @const {boolean} Phaser.Boot.Config#hidePhaser - [description] + * @const {boolean} Phaser.Boot.Config#hidePhaser - Omit Phaser's name and version from the banner. */ this.hidePhaser = GetValue(config, 'banner.hidePhaser', false); /** - * @const {string} Phaser.Boot.Config#bannerTextColor - [description] + * @const {string} Phaser.Boot.Config#bannerTextColor - The color of the banner text. */ this.bannerTextColor = GetValue(config, 'banner.text', defaultBannerTextColor); /** - * @const {string[]} Phaser.Boot.Config#bannerBackgroundColor - [description] + * @const {string[]} Phaser.Boot.Config#bannerBackgroundColor - The background colors of the banner. */ this.bannerBackgroundColor = GetValue(config, 'banner.background', defaultBannerColor); @@ -305,16 +508,8 @@ var Config = new Class({ this.hideBanner = true; } - // Frame Rate config - // fps: { - // min: 10, - // target: 60, - // forceSetTimeOut: false, - // deltaHistory: 10 - // } - /** - * @const {?FPSConfig} Phaser.Boot.Config#fps - [description] + * @const {?FPSConfig} Phaser.Boot.Config#fps - The Frame Rate Configuration object, as parsed by the Timestep class. */ this.fps = GetValue(config, 'fps', null); @@ -324,22 +519,22 @@ var Config = new Class({ var renderConfig = GetValue(config, 'render', config); /** - * @const {boolean} Phaser.Boot.Config#autoResize - [description] + * @const {boolean} Phaser.Boot.Config#autoResize - Automatically resize the Game Canvas if you resize the renderer. */ - this.autoResize = GetValue(renderConfig, 'autoResize', false); + this.autoResize = GetValue(renderConfig, 'autoResize', true); /** - * @const {boolean} Phaser.Boot.Config#antialias - [description] + * @const {boolean} Phaser.Boot.Config#antialias - When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. */ this.antialias = GetValue(renderConfig, 'antialias', true); /** - * @const {boolean} Phaser.Boot.Config#roundPixels - [description] + * @const {boolean} Phaser.Boot.Config#roundPixels - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. */ this.roundPixels = GetValue(renderConfig, 'roundPixels', false); /** - * @const {boolean} Phaser.Boot.Config#pixelArt - [description] + * @const {boolean} Phaser.Boot.Config#pixelArt - Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode). */ this.pixelArt = GetValue(renderConfig, 'pixelArt', false); @@ -350,39 +545,44 @@ var Config = new Class({ } /** - * @const {boolean} Phaser.Boot.Config#transparent - [description] + * @const {boolean} Phaser.Boot.Config#transparent - Whether the game canvas will have a transparent background. */ this.transparent = GetValue(renderConfig, 'transparent', false); /** - * @const {boolean} Phaser.Boot.Config#zoclearBeforeRenderom - [description] + * @const {boolean} Phaser.Boot.Config#clearBeforeRender - Whether the game canvas will be cleared between each rendering frame. You can disable this if you have a full-screen background image or game object. */ this.clearBeforeRender = GetValue(renderConfig, 'clearBeforeRender', true); /** - * @const {boolean} Phaser.Boot.Config#premultipliedAlpha - [description] + * @const {boolean} Phaser.Boot.Config#premultipliedAlpha - In WebGL mode, sets the drawing buffer to contain colors with pre-multiplied alpha. */ this.premultipliedAlpha = GetValue(renderConfig, 'premultipliedAlpha', true); /** - * @const {boolean} Phaser.Boot.Config#preserveDrawingBuffer - [description] - */ - this.preserveDrawingBuffer = GetValue(renderConfig, 'preserveDrawingBuffer', false); - - /** - * @const {boolean} Phaser.Boot.Config#failIfMajorPerformanceCaveat - [description] + * @const {boolean} Phaser.Boot.Config#failIfMajorPerformanceCaveat - Let the browser abort creating a WebGL context if it judges performance would be unacceptable. */ this.failIfMajorPerformanceCaveat = GetValue(renderConfig, 'failIfMajorPerformanceCaveat', false); /** - * @const {string} Phaser.Boot.Config#powerPreference - [description] + * @const {string} Phaser.Boot.Config#powerPreference - "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. */ this.powerPreference = GetValue(renderConfig, 'powerPreference', 'default'); + /** + * @const {integer} Phaser.Boot.Config#batchSize - The default WebGL Batch size. + */ + this.batchSize = GetValue(renderConfig, 'batchSize', 2000); + + /** + * @const {integer} Phaser.Boot.Config#maxLights - The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + this.maxLights = GetValue(renderConfig, 'maxLights', 10); + var bgc = GetValue(config, 'backgroundColor', 0); /** - * @const {Phaser.Display.Color} Phaser.Boot.Config#backgroundColor - [description] + * @const {Phaser.Display.Color} Phaser.Boot.Config#backgroundColor - The background color of the game canvas. The default is black. This value is ignored if `transparent` is set to `true`. */ this.backgroundColor = ValueToColor(bgc); @@ -391,110 +591,96 @@ var Config = new Class({ this.backgroundColor.alpha = 0; } - // Callbacks - /** - * @const {BootCallback} Phaser.Boot.Config#preBoot - [description] + * @const {BootCallback} Phaser.Boot.Config#preBoot - Called before Phaser boots. Useful for initializing anything not related to Phaser that Phaser may require while booting. */ this.preBoot = GetValue(config, 'callbacks.preBoot', NOOP); /** - * @const {BootCallback} Phaser.Boot.Config#postBoot - [description] + * @const {BootCallback} Phaser.Boot.Config#postBoot - A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. */ this.postBoot = GetValue(config, 'callbacks.postBoot', NOOP); - // Physics - // physics: { - // system: 'impact', - // setBounds: true, - // gravity: 0, - // cellSize: 64 - // } - /** - * @const {object} Phaser.Boot.Config#physics - [description] + * @const {PhysicsConfig} Phaser.Boot.Config#physics - The Physics Configuration object. */ this.physics = GetValue(config, 'physics', {}); /** - * @const {boolean} Phaser.Boot.Config#defaultPhysicsSystem - [description] + * @const {(boolean|string)} Phaser.Boot.Config#defaultPhysicsSystem - The default physics system. It will be started for each scene. Either 'arcade', 'impact' or 'matter'. */ this.defaultPhysicsSystem = GetValue(this.physics, 'default', false); - // Loader Defaults - /** - * @const {string} Phaser.Boot.Config#loaderBaseURL - [description] + * @const {string} Phaser.Boot.Config#loaderBaseURL - A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. */ this.loaderBaseURL = GetValue(config, 'loader.baseURL', ''); /** - * @const {string} Phaser.Boot.Config#loaderPath - [description] + * @const {string} Phaser.Boot.Config#loaderPath - A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. */ this.loaderPath = GetValue(config, 'loader.path', ''); /** - * @const {integer} Phaser.Boot.Config#loaderMaxParallelDownloads - [description] + * @const {integer} Phaser.Boot.Config#loaderMaxParallelDownloads - Maximum parallel downloads allowed for resources (Default to 32). */ this.loaderMaxParallelDownloads = GetValue(config, 'loader.maxParallelDownloads', 32); /** - * @const {(string|undefined)} Phaser.Boot.Config#loaderCrossOrigin - [description] + * @const {(string|undefined)} Phaser.Boot.Config#loaderCrossOrigin - 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. */ this.loaderCrossOrigin = GetValue(config, 'loader.crossOrigin', undefined); /** - * @const {string} Phaser.Boot.Config#loaderResponseType - [description] + * @const {string} Phaser.Boot.Config#loaderResponseType - The response type of the XHR request, e.g. `blob`, `text`, etc. */ this.loaderResponseType = GetValue(config, 'loader.responseType', ''); /** - * @const {boolean} Phaser.Boot.Config#loaderAsync - [description] + * @const {boolean} Phaser.Boot.Config#loaderAsync - Should the XHR request use async or not? */ this.loaderAsync = GetValue(config, 'loader.async', true); /** - * @const {string} Phaser.Boot.Config#loaderUser - [description] + * @const {string} Phaser.Boot.Config#loaderUser - Optional username for all XHR requests. */ this.loaderUser = GetValue(config, 'loader.user', ''); /** - * @const {string} Phaser.Boot.Config#loaderPassword - [description] + * @const {string} Phaser.Boot.Config#loaderPassword - Optional password for all XHR requests. */ this.loaderPassword = GetValue(config, 'loader.password', ''); /** - * @const {integer} Phaser.Boot.Config#loaderTimeout - [description] + * @const {integer} Phaser.Boot.Config#loaderTimeout - Optional XHR timeout value, in ms. */ this.loaderTimeout = GetValue(config, 'loader.timeout', 0); - // Plugins - /* * Allows `plugins` property to either be an array, in which case it just replaces * the default plugins like previously, or a config object. * * plugins: { * global: [ - * { key: 'TestPlugin', plugin: TestPlugin, start: true }, + * { key: 'TestPlugin', plugin: TestPlugin, start: true, data: { msg: 'The plugin is alive' } }, * ], * scene: [ * { key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' } * ], * default: [], OR - * defaultMerge: { + * defaultMerge: [ * 'ModPlayer' - * } + * ] * } */ /** - * @const {any} Phaser.Boot.Config#installGlobalPlugins - [description] + * @const {any} Phaser.Boot.Config#installGlobalPlugins - An array of global plugins to be installed. */ this.installGlobalPlugins = []; /** - * @const {any} Phaser.Boot.Config#installScenePlugins - [description] + * @const {any} Phaser.Boot.Config#installScenePlugins - An array of Scene level plugins to be installed. */ this.installScenePlugins = []; @@ -533,14 +719,26 @@ var Config = new Class({ var pngPrefix = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAg'; /** - * @const {string} Phaser.Boot.Config#defaultImage - [description] + * @const {string} Phaser.Boot.Config#defaultImage - A base64 encoded PNG that will be used as the default blank texture. */ this.defaultImage = GetValue(config, 'images.default', pngPrefix + 'AQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg=='); - + /** - * @const {string} Phaser.Boot.Config#missingImage - [description] + * @const {string} Phaser.Boot.Config#missingImage - A base64 encoded PNG that will be used as the default texture when a texture is assigned that is missing or not loaded. */ this.missingImage = GetValue(config, 'images.missing', pngPrefix + 'CAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=='); + + if (window) + { + if (window.FORCE_WEBGL) + { + this.renderType = CONST.WEBGL; + } + else if (window.FORCE_CANVAS) + { + this.renderType = CONST.CANVAS; + } + } } }); diff --git a/src/boot/CreateDOMContainer.js b/src/boot/CreateDOMContainer.js new file mode 100644 index 000000000..923d689e5 --- /dev/null +++ b/src/boot/CreateDOMContainer.js @@ -0,0 +1,36 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var AddToDOM = require('../dom/AddToDOM'); + +var CreateDOMContainer = function (game) +{ + var config = game.config; + + if (!config.parent || !config.domCreateContainer) + { + return; + } + + // DOM Element Container + var div = document.createElement('div'); + + div.style = [ + 'display: block;', + 'width: ' + game.canvas.width + 'px;', + 'height: ' + game.canvas.height + 'px;', + 'padding: 0; margin: 0;', + 'position: absolute;', + 'overflow: hidden;', + 'pointer-events: none;' + ].join(' '); + + game.domContainer = div; + + AddToDOM(div, config.parent); +}; + +module.exports = CreateDOMContainer; diff --git a/src/boot/CreateRenderer.js b/src/boot/CreateRenderer.js index b45ab8de3..76c37eb82 100644 --- a/src/boot/CreateRenderer.js +++ b/src/boot/CreateRenderer.js @@ -23,10 +23,13 @@ var CreateRenderer = function (game) { var config = game.config; - // Game either requested Canvas, - // or requested AUTO or WEBGL but the browser doesn't support it, so fall back to Canvas + if ((config.customEnvironment || config.canvas) && config.renderType === CONST.AUTO) + { + throw new Error('Must set explicit renderType in custom environment'); + } - if (config.renderType !== CONST.HEADLESS) + // Not a custom environment, didn't provide their own canvas and not headless, so determine the renderer: + if (!config.customEnvironment && !config.canvas && config.renderType !== CONST.HEADLESS) { if (config.renderType === CONST.CANVAS || (config.renderType !== CONST.CANVAS && !Features.webGL)) { @@ -57,10 +60,13 @@ var CreateRenderer = function (game) if (config.canvas) { game.canvas = config.canvas; + + game.canvas.width = game.scale.canvasWidth; + game.canvas.height = game.scale.canvasHeight; } else { - game.canvas = CanvasPool.create(game, config.width, config.height, config.renderType); + game.canvas = CanvasPool.create(game, game.scale.canvasWidth, game.scale.canvasHeight, config.renderType); } // Does the game config provide some canvas css styles to use? @@ -75,13 +81,6 @@ var CreateRenderer = function (game) CanvasInterpolation.setCrisp(game.canvas); } - // Zoomed? - if (config.zoom !== 1) - { - game.canvas.style.width = (config.width * config.zoom).toString() + 'px'; - game.canvas.style.height = (config.height * config.zoom).toString() + 'px'; - } - if (config.renderType === CONST.HEADLESS) { // Nothing more to do here @@ -100,9 +99,6 @@ var CreateRenderer = function (game) if (config.renderType === CONST.WEBGL) { game.renderer = new WebGLRenderer(game); - - // The WebGL Renderer sets this value during its init, not on construction - game.context = null; } else { @@ -119,9 +115,6 @@ var CreateRenderer = function (game) config.renderType = CONST.WEBGL; game.renderer = new WebGLRenderer(game); - - // The WebGL Renderer sets this value during its init, not on construction - game.context = null; } if (!typeof WEBGL_RENDERER && typeof CANVAS_RENDERER) diff --git a/src/boot/DebugHeader.js b/src/boot/DebugHeader.js index 0554ef773..cd3cc37fb 100644 --- a/src/boot/DebugHeader.js +++ b/src/boot/DebugHeader.js @@ -101,9 +101,11 @@ var DebugHeader = function (game) } } + var fb = (typeof PLUGIN_FBINSTANT) ? '-FB' : ''; + if (!config.hidePhaser) { - c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); + c = c.concat('Phaser v' + CONST.VERSION + fb + ' (' + renderType + ' | ' + audioType + ')'); } c = c.concat(' %c ' + config.gameURL); diff --git a/src/boot/Game.js b/src/boot/Game.js index f6b333c5a..a286c8d65 100644 --- a/src/boot/Game.js +++ b/src/boot/Game.js @@ -17,13 +17,25 @@ var Device = require('../device'); var DOMContentLoaded = require('../dom/DOMContentLoaded'); var EventEmitter = require('eventemitter3'); var InputManager = require('../input/InputManager'); +var PluginCache = require('../plugins/PluginCache'); var PluginManager = require('../plugins/PluginManager'); +var ScaleManager = require('../dom/ScaleManager'); var SceneManager = require('../scene/SceneManager'); var SoundManagerCreator = require('../sound/SoundManagerCreator'); var TextureManager = require('../textures/TextureManager'); var TimeStep = require('./TimeStep'); var VisibilityHandler = require('./VisibilityHandler'); +if (typeof EXPERIMENTAL) +{ + var CreateDOMContainer = require('./CreateDOMContainer'); +} + +if (typeof PLUGIN_FBINSTANT) +{ + var FacebookInstantGamesPlugin = require('../../plugins/fbinstant/src/FacebookInstantGamesPlugin'); +} + /** * @classdesc * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible @@ -35,7 +47,7 @@ var VisibilityHandler = require('./VisibilityHandler'); * made available to you via the Phaser.Scene Systems class instead. * * @class Game - * @memberOf Phaser + * @memberof Phaser * @constructor * @since 3.0.0 * @@ -54,7 +66,7 @@ var Game = new Class({ * * @name Phaser.Game#config * @type {Phaser.Boot.Config} - * @readOnly + * @readonly * @since 3.0.0 */ this.config = new Config(config); @@ -68,6 +80,23 @@ var Game = new Class({ */ this.renderer = null; + if (typeof EXPERIMENTAL) + { + /** + * A reference to an HTML Div Element used as a DOM Element Container. + * + * Only set if `createDOMContainer` is `true` in the game config (by default it is `false`) and + * if you provide a parent element to insert the Phaser Game inside. + * + * See the DOM Element Game Object for more details. + * + * @name Phaser.Game#domContainer + * @type {HTMLDivElement} + * @since 3.12.0 + */ + this.domContainer = null; + } + /** * A reference to the HTML Canvas Element that Phaser uses to render the game. * This is created automatically by Phaser unless you provide a `canvas` property @@ -97,7 +126,7 @@ var Game = new Class({ * * @name Phaser.Game#isBooted * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ this.isBooted = false; @@ -107,7 +136,7 @@ var Game = new Class({ * * @name Phaser.Game#isRunning * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ this.isRunning = false; @@ -197,6 +226,17 @@ var Game = new Class({ */ this.device = Device; + /** + * An instance of the Scale Manager. + * + * The Scale Manager is a global system responsible for handling game scaling events. + * + * @name Phaser.Game#scale + * @type {Phaser.Boot.ScaleManager} + * @since 3.15.0 + */ + this.scale = new ScaleManager(this, this.config); + /** * An instance of the base Sound Manager. * @@ -232,6 +272,21 @@ var Game = new Class({ */ this.plugins = new PluginManager(this, this.config); + if (typeof PLUGIN_FBINSTANT) + { + /** + * An instance of the Facebook Instant Games Plugin. + * + * This will only be available if the plugin has been built into Phaser, + * or you're using the special Facebook Instant Games custom build. + * + * @name Phaser.Game#facebook + * @type {Phaser.FacebookInstantGamesPlugin} + * @since 3.13.0 + */ + this.facebook = new FacebookInstantGamesPlugin(this); + } + /** * Is this Game pending destruction at the start of the next frame? * @@ -252,28 +307,28 @@ var Game = new Class({ */ this.removeCanvas = false; + /** + * Remove everything when the game is destroyed. + * You cannot create a new Phaser instance on the same web page after doing this. + * + * @name Phaser.Game#noReturn + * @type {boolean} + * @private + * @since 3.12.0 + */ + this.noReturn = false; + /** * Does the window the game is running in currently have focus or not? * This is modified by the VisibilityHandler. * * @name Phaser.Game#hasFocus * @type {boolean} - * @readOnly + * @readonly * @since 3.9.0 */ this.hasFocus = false; - /** - * Is the mouse pointer currently over the game canvas or not? - * This is modified by the VisibilityHandler. - * - * @name Phaser.Game#isOver - * @type {boolean} - * @readOnly - * @since 3.10.0 - */ - this.isOver = true; - // Wait for the DOM Ready event, then call boot. DOMContentLoaded(this.boot.bind(this)); }, @@ -299,20 +354,51 @@ var Game = new Class({ */ boot: function () { + if (!PluginCache.hasCore('EventEmitter')) + { + console.warn('Aborting. Core Plugins missing.'); + return; + } + this.isBooted = true; this.config.preBoot(this); + this.scale.preBoot(); + CreateRenderer(this); + if (typeof EXPERIMENTAL) + { + CreateDOMContainer(this); + } + DebugHeader(this); AddToDOM(this.canvas, this.config.parent); this.events.emit('boot'); - // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready, so it will emit this event - this.events.once('ready', this.start, this); + // The Texture Manager has to wait on a couple of non-blocking events before it's fully ready. + // So it will emit this internal event when done: + this.events.once('texturesready', this.texturesReady, this); + }, + + /** + * Called automatically when the Texture Manager has finished setting up and preparing the + * default textures. + * + * @method Phaser.Game#texturesReady + * @private + * @fires Phaser.Game#ready + * @since 3.12.0 + */ + texturesReady: function () + { + // Start all the other systems + this.events.emit('ready'); + + this.start(); }, /** @@ -351,40 +437,48 @@ var Game = new Class({ /** * Game Pre-Step event. + * + * Listen for it using the event type `prestep`. * * This event is dispatched before the main Step starts. * By this point none of the Scene updates have happened. * Hook into it from plugins or systems that need to update before the Scene Manager does. * * @event Phaser.Game#prestepEvent - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ /** * Game Step event. + * + * Listen for it using the event type `step`. * * This event is dispatched after Pre-Step and before the Scene Manager steps. * Hook into it from plugins or systems that need to update before the Scene Manager does, but after core Systems. * * @event Phaser.Game#stepEvent - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ /** * Game Post-Step event. + * + * Listen for it using the event type `poststep`. * * This event is dispatched after the Scene Manager has updated. * Hook into it from plugins or systems that need to do things before the render starts. * * @event Phaser.Game#poststepEvent - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ /** * Game Pre-Render event. + * + * Listen for it using the event type `prerender`. * * This event is dispatched immediately before any of the Scenes have started to render. * The renderer will already have been initialized this frame, clearing itself and preparing to receive @@ -396,6 +490,8 @@ var Game = new Class({ /** * Game Post-Render event. + * + * Listen for it using the event type `postrender`. * * This event is dispatched right at the end of the render process. * Every Scene will have rendered and drawn to the canvas. @@ -420,8 +516,8 @@ var Game = new Class({ * @fires Phaser.Game#postrenderEvent * @since 3.0.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. + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ step: function (time, delta) { @@ -484,8 +580,8 @@ var Game = new Class({ * @fires Phaser.Game#postrenderEvent * @since 3.2.0 * - * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {number} delta - The delta time elapsed since the last frame. + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ headlessStep: function (time, delta) { @@ -512,6 +608,8 @@ var Game = new Class({ /** * Game Pause event. + * + * Listen for it using the event type `pause`. * * This event is dispatched when the game loop enters a paused state, usually as a result of the Visibility Handler. * @@ -536,6 +634,8 @@ var Game = new Class({ /** * Game Resume event. + * + * Listen for it using the event type `resume`. * * This event is dispatched when the game loop leaves a paused state and resumes running. * @@ -590,6 +690,8 @@ var Game = new Class({ /** * Game Resize event. + * + * Listen for it using the event type `resize`. * * @event Phaser.Game#resizeEvent * @param {number} width - The new width of the Game. @@ -601,6 +703,7 @@ var Game = new Class({ * Then resizes the Renderer and Input Manager scale. * * @method Phaser.Game#resize + * @fires Phaser.Game#resizeEvent * @since 3.2.0 * * @param {number} width - The new width of the game. @@ -611,6 +714,15 @@ var Game = new Class({ this.config.width = width; this.config.height = height; + if (typeof EXPERIMENTAL) + { + if (this.domContainer) + { + this.domContainer.style.width = width + 'px'; + this.domContainer.style.height = height + 'px'; + } + } + this.renderer.resize(width, height); this.input.resize(); @@ -620,20 +732,64 @@ var Game = new Class({ this.events.emit('resize', width, height); }, + /** + * Returns the current game frame. + * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. + * + * @method Phaser.Game#getFrame + * @since 3.16.0 + * + * @return {number} The current game frame. + */ + getFrame: function () + { + return this.loop.frame; + }, + + /** + * Returns the current game timestamp. + * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. + * + * @method Phaser.Game#getTime + * @since 3.16.0 + * + * @return {number} The current game timestamp. + */ + getTime: function () + { + return this.loop.frame.time; + }, + + /** + * Game Destroy event. + * + * Listen for it using the event type `destroy`. + * + * @event Phaser.Game#destroyEvent + */ + /** * Flags this Game instance as needing to be destroyed on the next frame. * It will wait until the current frame has completed and then call `runDestroy` internally. + * + * If you **do not** need to run Phaser again on the same web page you can set the `noReturn` argument to `true` and it will free-up + * memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as `false`. * * @method Phaser.Game#destroy + * @fires Phaser.Game#destroyEvent * @since 3.0.0 * * @param {boolean} removeCanvas - Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. + * @param {boolean} [noReturn=false] - If `true` all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this. */ - destroy: function (removeCanvas) + destroy: function (removeCanvas, noReturn) { + if (noReturn === undefined) { noReturn = false; } + this.pendingDestroy = true; this.removeCanvas = removeCanvas; + this.noReturn = noReturn; }, /** @@ -666,11 +822,23 @@ var Game = new Class({ } } - this.loop.destroy(); + if (typeof EXPERIMENTAL) + { + if (this.domContainer) + { + this.domContainer.parentNode.removeChild(this.domContainer); + } + } + this.loop.destroy(); + this.pendingDestroy = false; } }); +/** + * "Computers are good at following instructions, but not at reading your mind." - Donald Knuth + */ + module.exports = Game; diff --git a/src/boot/TimeStep.js b/src/boot/TimeStep.js index 7d639c5c2..e3da9403f 100644 --- a/src/boot/TimeStep.js +++ b/src/boot/TimeStep.js @@ -33,7 +33,7 @@ var RequestAnimationFrame = require('../dom/RequestAnimationFrame'); * [description] * * @class TimeStep - * @memberOf Phaser.Boot + * @memberof Phaser.Boot * @constructor * @since 3.0.0 * @@ -51,7 +51,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#game * @type {Phaser.Game} - * @readOnly + * @readonly * @since 3.0.0 */ this.game = game; @@ -61,7 +61,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#raf * @type {Phaser.DOM.RequestAnimationFrame} - * @readOnly + * @readonly * @since 3.0.0 */ this.raf = new RequestAnimationFrame(); @@ -71,7 +71,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#started * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.0.0 */ @@ -85,7 +85,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#running * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.0.0 */ @@ -142,7 +142,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#actualFps * @type {integer} - * @readOnly + * @readonly * @default 60 * @since 3.0.0 */ @@ -153,7 +153,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#nextFpsUpdate * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.0.0 */ @@ -164,7 +164,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#framesThisSecond * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.0.0 */ @@ -186,7 +186,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#forceSetTimeOut * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.0.0 */ @@ -227,7 +227,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#frame * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.0.0 */ @@ -238,7 +238,7 @@ var TimeStep = new Class({ * * @name Phaser.Boot.TimeStep#inFocus * @type {boolean} - * @readOnly + * @readonly * @default true * @since 3.0.0 */ @@ -445,13 +445,11 @@ var TimeStep = new Class({ * * @method Phaser.Boot.TimeStep#step * @since 3.0.0 - * + * * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. */ step: function (time) { - this.frame++; - var before = time - this.lastTime; if (before < 0) @@ -561,6 +559,8 @@ var TimeStep = new Class({ // Shift time value over this.lastTime = time; + + this.frame++; }, /** @@ -607,7 +607,7 @@ var TimeStep = new Class({ } else if (seamless) { - this.startTime += -this.lastTime + (this.lastTime = window.performance.now()); + this.startTime += -this.lastTime + (this.lastTime + window.performance.now()); } this.raf.start(this.step.bind(this), this.useRAF); diff --git a/src/boot/VisibilityHandler.js b/src/boot/VisibilityHandler.js index 189eeaede..35413c259 100644 --- a/src/boot/VisibilityHandler.js +++ b/src/boot/VisibilityHandler.js @@ -109,26 +109,6 @@ var VisibilityHandler = function (game) if (window.focus && game.config.autoFocus) { window.focus(); - - game.canvas.addEventListener('mousedown', function () - { - window.focus(); - }, { passive: true }); - } - - if (game.canvas) - { - game.canvas.onmouseout = function () - { - game.isOver = false; - eventEmitter.emit('mouseout'); - }; - - game.canvas.onmouseover = function () - { - game.isOver = true; - eventEmitter.emit('mouseover'); - }; } }; diff --git a/src/cache/BaseCache.js b/src/cache/BaseCache.js index 9cf4dcc56..e87d7e514 100644 --- a/src/cache/BaseCache.js +++ b/src/cache/BaseCache.js @@ -17,7 +17,7 @@ var EventEmitter = require('eventemitter3'); * Keys are string-based. * * @class BaseCache - * @memberOf Phaser.Cache + * @memberof Phaser.Cache * @constructor * @since 3.0.0 */ diff --git a/src/cache/CacheManager.js b/src/cache/CacheManager.js index f55852183..08981c353 100644 --- a/src/cache/CacheManager.js +++ b/src/cache/CacheManager.js @@ -16,7 +16,7 @@ var Class = require('../utils/Class'); * instances, one per type of file. You can also add your own custom caches. * * @class CacheManager - * @memberOf Phaser.Cache + * @memberof Phaser.Cache * @constructor * @since 3.0.0 * @@ -102,6 +102,15 @@ var CacheManager = new Class({ */ this.text = new BaseCache(); + /** + * A Cache storing all html files, typically added via the Loader. + * + * @name Phaser.Cache.CacheManager#html + * @type {Phaser.Cache.BaseCache} + * @since 3.12.0 + */ + this.html = new BaseCache(); + /** * A Cache storing all WaveFront OBJ files, typically added via the Loader. * @@ -181,6 +190,7 @@ var CacheManager = new Class({ 'shader', 'audio', 'text', + 'html', 'obj', 'tilemap', 'xml' diff --git a/src/cameras/2d/BaseCamera.js b/src/cameras/2d/BaseCamera.js new file mode 100644 index 000000000..a72025e33 --- /dev/null +++ b/src/cameras/2d/BaseCamera.js @@ -0,0 +1,1855 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../utils/Class'); +var Components = require('../../gameobjects/components'); +var DegToRad = require('../../math/DegToRad'); +var EventEmitter = require('eventemitter3'); +var Rectangle = require('../../geom/rectangle/Rectangle'); +var TransformMatrix = require('../../gameobjects/components/TransformMatrix'); +var ValueToColor = require('../../display/color/ValueToColor'); +var Vector2 = require('../../math/Vector2'); + +/** + * @typedef {object} JSONCameraBounds + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + */ + +/** + * @typedef {object} JSONCamera + * + * @property {string} name - The name of the camera + * @property {number} x - The horizontal position of camera + * @property {number} y - The vertical position of camera + * @property {number} width - The width size of camera + * @property {number} height - The height size of camera + * @property {number} zoom - The zoom of camera + * @property {number} rotation - The rotation of camera + * @property {boolean} roundPixels - The round pixels st status of camera + * @property {number} scrollX - The horizontal scroll of camera + * @property {number} scrollY - The vertical scroll of camera + * @property {string} backgroundColor - The background color of camera + * @property {(JSONCameraBounds|undefined)} [bounds] - The bounds of camera + */ + +/** + * @classdesc + * A Base Camera class. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * The Base Camera is extended by the Camera class, which adds in special effects including Fade, + * Flash and Camera Shake, as well as the ability to follow Game Objects. + * + * The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow + * you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate + * to when they were added to the Camera class. + * + * @class BaseCamera + * @memberof Phaser.Cameras.Scene2D + * @constructor + * @since 3.12.0 + * + * @extends Phaser.Events.EventEmitter + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.Visible + * + * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. + * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. + * @param {number} width - The width of the Camera, in pixels. + * @param {number} height - The height of the Camera, in pixels. + */ +var BaseCamera = new Class({ + + Extends: EventEmitter, + + Mixins: [ + Components.Alpha, + Components.Visible + ], + + initialize: + + function BaseCamera (x, y, width, height) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 0; } + if (height === undefined) { height = 0; } + + EventEmitter.call(this); + + /** + * A reference to the Scene this camera belongs to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ + this.scene; + + /** + * A reference to the Game Scene Manager. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#sceneManager + * @type {Phaser.Scenes.SceneManager} + * @since 3.12.0 + */ + this.sceneManager; + + /** + * A reference to the Game Config. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#config + * @type {object} + * @readonly + * @since 3.12.0 + */ + this.config; + + /** + * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * This value is a bitmask. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#id + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.id = 0; + + /** + * The name of the Camera. This is left empty for your own use. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#name + * @type {string} + * @default '' + * @since 3.0.0 + */ + this.name = ''; + + /** + * The resolution of the Game, used in most Camera calculations. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#resolution + * @type {number} + * @readonly + * @since 3.12.0 + */ + this.resolution = 1; + + /** + * Should this camera round its pixel values to integers? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#roundPixels + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.roundPixels = false; + + /** + * Is this Camera visible or not? + * + * A visible camera will render and perform input tests. + * An invisible camera will not render anything and will skip input tests. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#visible + * @type {boolean} + * @default true + * @since 3.10.0 + */ + + /** + * Is this Camera using a bounds to restrict scrolling movement? + * + * Set this property along with the bounds via `Camera.setBounds`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#useBounds + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.useBounds = false; + + /** + * The World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. + * This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. + * If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. + * You can use it for culling or intersection checks. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#worldView + * @type {Phaser.Geom.Rectangle} + * @readonly + * @since 3.11.0 + */ + this.worldView = new Rectangle(); + + /** + * Is this Camera dirty? + * + * A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. + * + * This flag is cleared during the `postRenderCamera` method of the renderer. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#dirty + * @type {boolean} + * @default true + * @since 3.11.0 + */ + this.dirty = true; + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#x + * @type {number} + * @private + * @since 3.0.0 + */ + this._x = x; + + /** + * The y position of the Camera, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#y + * @type {number} + * @private + * @since 3.0.0 + */ + this._y = y; + + /** + * Internal Camera X value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cx + * @type {number} + * @private + * @since 3.12.0 + */ + this._cx = 0; + + /** + * Internal Camera Y value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cy + * @type {number} + * @private + * @since 3.12.0 + */ + this._cy = 0; + + /** + * Internal Camera Width value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_cw + * @type {number} + * @private + * @since 3.12.0 + */ + this._cw = 0; + + /** + * Internal Camera Height value multiplied by the resolution. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_ch + * @type {number} + * @private + * @since 3.12.0 + */ + this._ch = 0; + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_width + * @type {number} + * @private + * @since 3.11.0 + */ + this._width = width; + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_height + * @type {number} + * @private + * @since 3.11.0 + */ + this._height = height; + + /** + * The bounds the camera is restrained to during scrolling. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_bounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.0.0 + */ + this._bounds = new Rectangle(); + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollX + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollX = 0; + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_scrollY + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._scrollY = 0; + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_zoom + * @type {number} + * @private + * @default 1 + * @since 3.11.0 + */ + this._zoom = 1; + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + this._rotation = 0; + + /** + * A local transform matrix used for internal calculations. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#matrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.0.0 + */ + this.matrix = new TransformMatrix(); + + /** + * Does this Camera have a transparent background? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#transparent + * @type {boolean} + * @default true + * @since 3.0.0 + */ + this.transparent = true; + + /** + * The background color of this Camera. Only used if `transparent` is `false`. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#backgroundColor + * @type {Phaser.Display.Color} + * @since 3.0.0 + */ + this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); + + /** + * The Camera alpha value. Setting this property impacts every single object that this Camera + * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, + * or via the chainable `setAlpha` method instead. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#alpha + * @type {number} + * @default 1 + * @since 3.11.0 + */ + + /** + * Should the camera cull Game Objects before checking them for input hit tests? + * In some special cases it may be beneficial to disable this. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#disableCull + * @type {boolean} + * @default false + * @since 3.0.0 + */ + this.disableCull = false; + + /** + * A temporary array of culled objects. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#culledObjects + * @type {Phaser.GameObjects.GameObject[]} + * @default [] + * @private + * @since 3.0.0 + */ + this.culledObjects = []; + + /** + * The mid-point of the Camera in 'world' coordinates. + * + * Use it to obtain exactly where in the world the center of the camera is currently looking. + * + * This value is updated in the preRender method, after the scroll values and follower + * have been processed. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#midPoint + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.11.0 + */ + this.midPoint = new Vector2(width / 2, height / 2); + + /** + * The horizontal origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originX + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originX = 0.5; + + /** + * The vertical origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#originY + * @type {number} + * @default 0.5 + * @since 3.11.0 + */ + this.originY = 0.5; + + /** + * Does this Camera have a custom viewport? + * + * @name Phaser.Cameras.Scene2D.BaseCamera#_customViewport + * @type {boolean} + * @private + * @default false + * @since 3.12.0 + */ + this._customViewport = false; + }, + + /** + * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAlpha + * @since 3.11.0 + * + * @param {number} [value=1] - The Camera alpha value. + * + * @return {this} This Camera instance. + */ + + /** + * Sets the rotation origin of this Camera. + * + * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setOrigin + * @since 3.11.0 + * + * @param {number} [x=0.5] - The horizontal origin value. + * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. + * + * @return {this} This Camera instance. + */ + setOrigin: function (x, y) + { + if (x === undefined) { x = 0.5; } + if (y === undefined) { y = x; } + + this.originX = x; + this.originY = y; + + return this; + }, + + /** + * Calculates what the Camera.scrollX and scrollY values would need to be in order to move + * the Camera so it is centered on the given x and y coordinates, without actually moving + * the Camera there. The results are clamped based on the Camera bounds, if set. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getScroll + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {Phaser.Math.Vector2} [out] - A Vec2 to store the values in. If not given a new Vec2 is created. + * + * @return {Phaser.Math.Vector2} The scroll coordinates stored in the `x` and `y` properties. + */ + getScroll: function (x, y, out) + { + if (out === undefined) { out = new Vector2(); } + + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + out.x = x - originX; + out.y = y - originY; + + if (this.useBounds) + { + out.x = this.clampX(out.x); + out.y = this.clampY(out.y); + } + + return out; + }, + + /** + * Moves the Camera horizontally so that it is centered on the given x coordinate, bounds allowing. + * Calling this does not change the scrollY value. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerOnX + * @since 3.16.0 + * + * @param {number} x - The horizontal coordinate to center on. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerOnX: function (x) + { + var originX = this.width * 0.5; + + this.midPoint.x = x; + + this.scrollX = x - originX; + + if (this.useBounds) + { + this.scrollX = this.clampX(this.scrollX); + } + + return this; + }, + + /** + * Moves the Camera vertically so that it is centered on the given y coordinate, bounds allowing. + * Calling this does not change the scrollX value. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerOnY + * @since 3.16.0 + * + * @param {number} y - The vertical coordinate to center on. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerOnY: function (y) + { + var originY = this.height * 0.5; + + this.midPoint.y = y; + + this.scrollY = y - originY; + + if (this.useBounds) + { + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Moves the Camera so that it is centered on the given coordinates, bounds allowing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerOn + * @since 3.11.0 + * + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerOn: function (x, y) + { + this.centerOnX(x); + this.centerOnY(y); + + return this; + }, + + /** + * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerToBounds: function () + { + if (this.useBounds) + { + var bounds = this._bounds; + var originX = this.width * 0.5; + var originY = this.height * 0.5; + + this.midPoint.set(bounds.centerX, bounds.centerY); + + this.scrollX = bounds.centerX - originX; + this.scrollY = bounds.centerY - originY; + } + + return this; + }, + + /** + * Moves the Camera so that it is re-centered based on its viewport size. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#centerToSize + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + centerToSize: function () + { + this.scrollX = this.width * 0.5; + this.scrollY = this.height * 0.5; + + return this; + }, + + /** + * Takes an array of Game Objects and returns a new array featuring only those objects + * visible by this camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#cull + * @since 3.0.0 + * + * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] + * + * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. + * + * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. + */ + cull: function (renderableObjects) + { + if (this.disableCull) + { + return renderableObjects; + } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + + /* First Invert Matrix */ + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + return renderableObjects; + } + + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + var cameraW = this.width; + var cameraH = this.height; + var culledObjects = this.culledObjects; + var length = renderableObjects.length; + + determinant = 1 / determinant; + + culledObjects.length = 0; + + for (var index = 0; index < length; ++index) + { + var object = renderableObjects[index]; + + if (!object.hasOwnProperty('width') || object.parentContainer) + { + culledObjects.push(object); + continue; + } + + var objectW = object.width; + var objectH = object.height; + var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); + var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); + var tx = (objectX * mva + objectY * mvc + mve); + var ty = (objectX * mvb + objectY * mvd + mvf); + var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); + var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); + var cullTop = this.y; + var cullBottom = cullTop + cameraH; + var cullLeft = this.x; + var cullRight = cullLeft + cameraW; + + if ((tw > cullLeft && tx < cullRight) && (th > cullTop && ty < cullBottom)) + { + culledObjects.push(object); + } + } + + return culledObjects; + }, + + /** + * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. + * You can optionally provide a Vector2, or similar object, to store the results in. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getWorldPoint + * @since 3.0.0 + * + * @generic {Phaser.Math.Vector2} O - [output,$return] + * + * @param {number} x - The x position to convert to world space. + * @param {number} y - The y position to convert to world space. + * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. + * + * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. + */ + getWorldPoint: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var cameraMatrix = this.matrix.matrix; + + var mva = cameraMatrix[0]; + var mvb = cameraMatrix[1]; + var mvc = cameraMatrix[2]; + var mvd = cameraMatrix[3]; + var mve = cameraMatrix[4]; + var mvf = cameraMatrix[5]; + + // Invert Matrix + var determinant = (mva * mvd) - (mvb * mvc); + + if (!determinant) + { + output.x = x; + output.y = y; + + return output; + } + + determinant = 1 / determinant; + + var ima = mvd * determinant; + var imb = -mvb * determinant; + var imc = -mvc * determinant; + var imd = mva * determinant; + var ime = (mvc * mvf - mvd * mve) * determinant; + var imf = (mvb * mve - mva * mvf) * determinant; + + var c = Math.cos(this.rotation); + var s = Math.sin(this.rotation); + + var zoom = this.zoom; + var res = this.resolution; + + var scrollX = this.scrollX; + var scrollY = this.scrollY; + + // Works for zoom of 1 with any resolution, but resolution > 1 and zoom !== 1 breaks + var sx = x + ((scrollX * c - scrollY * s) * zoom); + var sy = y + ((scrollX * s + scrollY * c) * zoom); + + // Apply transform to point + output.x = (sx * ima + sy * imc) * res + ime; + output.y = (sx * imb + sy * imd) * res + imf; + + return output; + }, + + /** + * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings + * so that they are ignored by this Camera. This means they will not be rendered by this Camera. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#ignore + * @since 3.0.0 + * + * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[]|Phaser.GameObjects.Group)} entries - The Game Object, or array of Game Objects, to be ignored by this Camera. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + ignore: function (entries) + { + var id = this.id; + + if (!Array.isArray(entries)) + { + entries = [ entries ]; + } + + for (var i = 0; i < entries.length; i++) + { + var entry = entries[i]; + + if (Array.isArray(entry)) + { + this.ignore(entry); + } + else if (entry.isParent) + { + this.ignore(entry.getChildren()); + } + else + { + entry.cameraFilter |= id; + } + } + + return this; + }, + + /** + * Internal preRender step. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#preRender + * @protected + * @since 3.0.0 + * + * @param {number} baseScale - The base scale, as set in the Camera Manager. + * @param {number} resolution - The game resolution. + */ + preRender: function (baseScale, resolution) + { + var width = this.width; + var height = this.height; + + var halfWidth = width * 0.5; + var halfHeight = height * 0.5; + + var zoom = this.zoom * baseScale; + var matrix = this.matrix; + + var originX = width * this.originX; + var originY = height * this.originY; + + var sx = this.scrollX; + var sy = this.scrollY; + + if (this.useBounds) + { + sx = this.clampX(sx); + sy = this.clampY(sy); + } + + if (this.roundPixels) + { + originX = Math.round(originX); + originY = Math.round(originY); + } + + // Values are in pixels and not impacted by zooming the Camera + this.scrollX = sx; + this.scrollY = sy; + + var midX = sx + halfWidth; + var midY = sy + halfHeight; + + // The center of the camera, in world space, so taking zoom into account + // Basically the pixel value of what it's looking at in the middle of the cam + this.midPoint.set(midX, midY); + + var displayWidth = width / zoom; + var displayHeight = height / zoom; + + this.worldView.setTo( + midX - (displayWidth / 2), + midY - (displayHeight / 2), + displayWidth, + displayHeight + ); + + matrix.loadIdentity(); + matrix.scale(resolution, resolution); + matrix.translate(this.x + originX, this.y + originY); + matrix.rotate(this.rotation); + matrix.scale(zoom, zoom); + matrix.translate(-originX, -originY); + }, + + /** + * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampX + * @since 3.11.0 + * + * @param {number} x - The value to horizontally scroll clamp. + * + * @return {number} The adjusted value to use as scrollX. + */ + clampX: function (x) + { + var bounds = this._bounds; + + var dw = this.displayWidth; + + var bx = bounds.x + ((dw - this.width) / 2); + var bw = Math.max(bx, bx + bounds.width - dw); + + if (x < bx) + { + x = bx; + } + else if (x > bw) + { + x = bw; + } + + return x; + }, + + /** + * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#clampY + * @since 3.11.0 + * + * @param {number} y - The value to vertically scroll clamp. + * + * @return {number} The adjusted value to use as scrollY. + */ + clampY: function (y) + { + var bounds = this._bounds; + + var dh = this.displayHeight; + + var by = bounds.y + ((dh - this.height) / 2); + var bh = Math.max(by, by + bounds.height - dh); + + if (y < by) + { + y = by; + } + else if (y > bh) + { + y = bh; + } + + return y; + }, + + /* + var gap = this._zoomInversed; + return gap * Math.round((src.x - this.scrollX * src.scrollFactorX) / gap); + */ + + /** + * If this Camera has previously had movement bounds set on it, this will remove them. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#removeBounds + * @since 3.0.0 + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + removeBounds: function () + { + this.useBounds = false; + + this.dirty = true; + + this._bounds.setEmpty(); + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setAngle + * @since 3.0.0 + * + * @param {number} [value=0] - The cameras angle of rotation, given in degrees. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setAngle: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = DegToRad(value); + + return this; + }, + + /** + * Sets the background color for this Camera. + * + * By default a Camera has a transparent background but it can be given a solid color, with any level + * of transparency, via this method. + * + * The color value can be specified using CSS color notation, hex or numbers. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBackgroundColor + * @since 3.0.0 + * + * @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setBackgroundColor: function (color) + { + if (color === undefined) { color = 'rgba(0,0,0,0)'; } + + this.backgroundColor = ValueToColor(color); + + this.transparent = (this.backgroundColor.alpha === 0); + + return this; + }, + + /** + * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. + * + * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the + * edges and into blank space. It does not limit the placement of Game Objects, or where + * the Camera viewport can be positioned. + * + * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. + * + * Clear the bounds entirely by calling `Camera.removeBounds`. + * + * If you set bounds that are smaller than the viewport it will stop the Camera from being + * able to scroll. The bounds can be positioned where-ever you wish. By default they are from + * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of + * the Camera bounds. However, you can position them anywhere. So if you wanted a game world + * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y + * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find + * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setBounds + * @since 3.0.0 + * + * @param {integer} x - The top-left x coordinate of the bounds. + * @param {integer} y - The top-left y coordinate of the bounds. + * @param {integer} width - The width of the bounds, in pixels. + * @param {integer} height - The height of the bounds, in pixels. + * @param {boolean} [centerOn=false] - If `true` the Camera will automatically be centered on the new bounds. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setBounds: function (x, y, width, height, centerOn) + { + if (centerOn === undefined) { centerOn = false; } + + this._bounds.setTo(x, y, width, height); + + this.dirty = true; + this.useBounds = true; + + if (centerOn) + { + this.centerToBounds(); + } + else + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + + return this; + }, + + /** + * Returns a rectangle containing the bounds of the Camera. + * + * If the Camera does not have any bounds the rectangle will be empty. + * + * The rectangle is a copy of the bounds, so is safe to modify. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#getBounds + * @since 3.16.0 + * + * @param {Phaser.Geom.Rectangle} [out] - An optional Rectangle to store the bounds in. If not given, a new Rectangle will be created. + * + * @return {Phaser.Geom.Rectangle} A rectangle containing the bounds of this Camera. + */ + getBounds: function (out) + { + if (out === undefined) { out = new Rectangle(); } + + var source = this._bounds; + + out.setTo(source.x, source.y, source.width, source.height); + + return out; + }, + + /** + * Sets the name of this Camera. + * This value is for your own use and isn't used internally. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setName + * @since 3.0.0 + * + * @param {string} [value=''] - The name of the Camera. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setName: function (value) + { + if (value === undefined) { value = ''; } + + this.name = value; + + return this; + }, + + /** + * Set the position of the Camera viewport within the game. + * + * This does not change where the camera is 'looking'. See `setScroll` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setPosition + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setPosition: function (x, y) + { + if (y === undefined) { y = x; } + + this.x = x; + this.y = y; + + return this; + }, + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRotation + * @since 3.0.0 + * + * @param {number} [value=0] - The rotation of the Camera, in radians. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setRotation: function (value) + { + if (value === undefined) { value = 0; } + + this.rotation = value; + + return this; + }, + + /** + * Should the Camera round pixel values to whole integers when rendering Game Objects? + * + * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setRoundPixels + * @since 3.0.0 + * + * @param {boolean} value - `true` to round Camera pixels, `false` to not. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setRoundPixels: function (value) + { + this.roundPixels = value; + + return this; + }, + + /** + * Sets the Scene the Camera is bound to. + * + * Also populates the `resolution` property and updates the internal size values. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScene + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - The Scene the camera is bound to. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setScene: function (scene) + { + if (this.scene && this._customViewport) + { + this.sceneManager.customViewports--; + } + + this.scene = scene; + + this.config = scene.sys.game.config; + this.sceneManager = scene.sys.game.scene; + + var res = this.config.resolution; + + this.resolution = res; + + this._cx = this._x * res; + this._cy = this._y * res; + this._cw = this._width * res; + this._ch = this._height * res; + + this.updateSystem(); + + return this; + }, + + /** + * Set the position of where the Camera is looking within the game. + * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. + * Use this method, or the scroll properties, to move your camera around the game world. + * + * This does not change where the camera viewport is placed. See `setPosition` to control that. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setScroll + * @since 3.0.0 + * + * @param {number} x - The x coordinate of the Camera in the game world. + * @param {number} [y=x] - The y coordinate of the Camera in the game world. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setScroll: function (x, y) + { + if (y === undefined) { y = x; } + + this.scrollX = x; + this.scrollY = y; + + return this; + }, + + /** + * Set the size of the Camera viewport. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setSize + * @since 3.0.0 + * + * @param {integer} width - The width of the Camera viewport. + * @param {integer} [height=width] - The height of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setSize: function (width, height) + { + if (height === undefined) { height = width; } + + this.width = width; + this.height = height; + + return this; + }, + + /** + * This method sets the position and size of the Camera viewport in a single call. + * + * If you're trying to change where the Camera is looking at in your game, then see + * the method `Camera.setScroll` instead. This method is for changing the viewport + * itself, not what the camera can see. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setViewport + * @since 3.0.0 + * + * @param {number} x - The top-left x coordinate of the Camera viewport. + * @param {number} y - The top-left y coordinate of the Camera viewport. + * @param {integer} width - The width of the Camera viewport. + * @param {integer} [height=width] - The height of the Camera viewport. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setViewport: function (x, y, width, height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + + return this; + }, + + /** + * Set the zoom value of the Camera. + * + * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. + * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. + * + * A value of 1 means 'no zoom' and is the default. + * + * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setZoom + * @since 3.0.0 + * + * @param {number} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001. + * + * @return {Phaser.Cameras.Scene2D.BaseCamera} This Camera instance. + */ + setZoom: function (value) + { + if (value === undefined) { value = 1; } + + if (value === 0) + { + value = 0.001; + } + + this.zoom = value; + + return this; + }, + + /** + * Sets the visibility of this Camera. + * + * An invisible Camera will skip rendering and input tests of everything it can see. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#setVisible + * @since 3.10.0 + * + * @param {boolean} value - The visible state of the Camera. + * + * @return {this} This Camera instance. + */ + + /** + * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#toJSON + * @since 3.0.0 + * + * @return {JSONCamera} A well-formed object suitable for conversion to JSON. + */ + toJSON: function () + { + var output = { + name: this.name, + x: this.x, + y: this.y, + width: this.width, + height: this.height, + zoom: this.zoom, + rotation: this.rotation, + roundPixels: this.roundPixels, + scrollX: this.scrollX, + scrollY: this.scrollY, + backgroundColor: this.backgroundColor.rgba + }; + + if (this.useBounds) + { + output['bounds'] = { + x: this._bounds.x, + y: this._bounds.y, + width: this._bounds.width, + height: this._bounds.height + }; + } + + return output; + }, + + /** + * Internal method called automatically by the Camera Manager. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#update + * @protected + * @since 3.0.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 () + { + // NOOP + }, + + /** + * Internal method called automatically when the viewport changes. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#updateSystem + * @private + * @since 3.12.0 + */ + updateSystem: function () + { + if (!this.config) + { + return; + } + + var custom = (this._x !== 0 || this._y !== 0 || this.config.width !== this._width || this.config.height !== this._height); + + var sceneManager = this.sceneManager; + + if (custom && !this._customViewport) + { + // We need a custom viewport for this Camera + sceneManager.customViewports++; + } + else if (!custom && this._customViewport) + { + // We're turning off a custom viewport for this Camera + sceneManager.customViewports--; + } + + this.dirty = true; + this._customViewport = custom; + }, + + /** + * This event is fired when a camera is destroyed by the Camera Manager. + * + * @event CameraDestroyEvent + * @param {Phaser.Cameras.Scene2D.BaseCamera} camera - The camera that was destroyed. + */ + + /** + * Destroys this Camera instance and its internal properties and references. + * Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager. + * + * This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default. + * + * Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction, + * rather than calling this method directly. + * + * @method Phaser.Cameras.Scene2D.BaseCamera#destroy + * @fires CameraDestroyEvent + * @since 3.0.0 + */ + destroy: function () + { + this.emit('cameradestroy', this); + + this.removeAllListeners(); + + this.matrix.destroy(); + + this.culledObjects = []; + + if (this._customViewport) + { + // We're turning off a custom viewport for this Camera + this.sceneManager.customViewports--; + } + + this._bounds = null; + + this.scene = null; + this.config = null; + this.sceneManager = null; + }, + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#x + * @type {number} + * @since 3.0.0 + */ + x: { + + get: function () + { + return this._x; + }, + + set: function (value) + { + this._x = value; + this._cx = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The y position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#y + * @type {number} + * @since 3.0.0 + */ + y: { + + get: function () + { + return this._y; + }, + + set: function (value) + { + this._y = value; + this._cy = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#width + * @type {number} + * @since 3.0.0 + */ + width: { + + get: function () + { + return this._width; + }, + + set: function (value) + { + this._width = value; + this._cw = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#height + * @type {number} + * @since 3.0.0 + */ + height: { + + get: function () + { + return this._height; + }, + + set: function (value) + { + this._height = value; + this._ch = value * this.resolution; + this.updateSystem(); + } + + }, + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollX: { + + get: function () + { + return this._scrollX; + }, + + set: function (value) + { + this._scrollX = value; + this.dirty = true; + } + + }, + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#scrollY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + scrollY: { + + get: function () + { + return this._scrollY; + }, + + set: function (value) + { + this._scrollY = value; + this.dirty = true; + } + + }, + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#zoom + * @type {number} + * @default 1 + * @since 3.0.0 + */ + zoom: { + + get: function () + { + return this._zoom; + }, + + set: function (value) + { + this._zoom = value; + this.dirty = true; + } + + }, + + /** + * The rotation of the Camera in radians. + * + * Camera rotation always takes place based on the Camera viewport. By default, rotation happens + * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. + * + * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not + * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#rotation + * @type {number} + * @private + * @default 0 + * @since 3.11.0 + */ + rotation: { + + get: function () + { + return this._rotation; + }, + + set: function (value) + { + this._rotation = value; + this.dirty = true; + } + + }, + + /** + * The horizontal position of the center of the Camera's viewport, relative to the left of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerX + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerX: { + + get: function () + { + return this.x + (0.5 * this.width); + } + + }, + + /** + * The vertical position of the center of the Camera's viewport, relative to the top of the game canvas. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#centerY + * @type {number} + * @readonly + * @since 3.10.0 + */ + centerY: { + + get: function () + { + return this.y + (0.5 * this.height); + } + + }, + + /** + * The displayed width of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width + * would be 1600, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a width of 800 and zoom of 2 would have a display width + * of 400 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayWidth + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayWidth: { + + get: function () + { + return this.width / this.zoom; + } + + }, + + /** + * The displayed height of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height + * would be 1200, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a height of 600 and zoom of 2 would have a display height + * of 300 pixels. + * + * @name Phaser.Cameras.Scene2D.BaseCamera#displayHeight + * @type {number} + * @readonly + * @since 3.11.0 + */ + displayHeight: { + + get: function () + { + return this.height / this.zoom; + } + + } + +}); + +module.exports = BaseCamera; diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index 980be2549..4712ae217 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -4,43 +4,17 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var BaseCamera = require('./BaseCamera'); +var CanvasPool = require('../../display/canvas/CanvasPool'); var CenterOn = require('../../geom/rectangle/CenterOn'); var Clamp = require('../../math/Clamp'); var Class = require('../../utils/Class'); -var DegToRad = require('../../math/DegToRad'); +var Components = require('../../gameobjects/components'); var Effects = require('./effects'); -var EventEmitter = require('eventemitter3'); var Linear = require('../../math/Linear'); var Rectangle = require('../../geom/rectangle/Rectangle'); -var TransformMatrix = require('../../gameobjects/components/TransformMatrix'); -var ValueToColor = require('../../display/color/ValueToColor'); var Vector2 = require('../../math/Vector2'); -/** - * @typedef {object} JSONCameraBounds - * @property {number} x - The horizontal position of camera - * @property {number} y - The vertical position of camera - * @property {number} width - The width size of camera - * @property {number} height - The height size of camera - */ - -/** - * @typedef {object} JSONCamera - * - * @property {string} name - The name of the camera - * @property {number} x - The horizontal position of camera - * @property {number} y - The vertical position of camera - * @property {number} width - The width size of camera - * @property {number} height - The height size of camera - * @property {number} zoom - The zoom of camera - * @property {number} rotation - The rotation of camera - * @property {boolean} roundPixels - The round pixels st status of camera - * @property {number} scrollX - The horizontal scroll of camera - * @property {number} scrollY - The vertical scroll of camera - * @property {string} backgroundColor - The background color of camera - * @property {(JSONCameraBounds|undefined)} [bounds] - The bounds of camera - */ - /** * @classdesc * A Camera. @@ -65,10 +39,13 @@ var Vector2 = require('../../math/Vector2'); * A Camera also has built-in special effects including Fade, Flash and Camera Shake. * * @class Camera - * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Cameras.Scene2D + * @memberof Phaser.Cameras.Scene2D * @constructor * @since 3.0.0 + * + * @extends Phaser.Cameras.Scene2D.BaseCamera + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.Tint * * @param {number} x - The x position of the Camera, relative to the top-left of the game canvas. * @param {number} y - The y position of the Camera, relative to the top-left of the game canvas. @@ -77,134 +54,18 @@ var Vector2 = require('../../math/Vector2'); */ var Camera = new Class({ - Extends: EventEmitter, + Extends: BaseCamera, + + Mixins: [ + Components.Flip, + Components.Tint + ], initialize: function Camera (x, y, width, height) { - EventEmitter.call(this); - - /** - * A reference to the Scene this camera belongs to. - * - * @name Phaser.Cameras.Scene2D.Camera#scene - * @type {Phaser.Scene} - * @since 3.0.0 - */ - this.scene; - - /** - * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. - * This value is a bitmask. - * - * @name Phaser.Cameras.Scene2D.Camera#id - * @type {integer} - * @readOnly - * @since 3.11.0 - */ - this.id = 0; - - /** - * The name of the Camera. This is left empty for your own use. - * - * @name Phaser.Cameras.Scene2D.Camera#name - * @type {string} - * @default '' - * @since 3.0.0 - */ - this.name = ''; - - /** - * The x position of the Camera viewport, relative to the top-left of the game canvas. - * The viewport is the area into which the camera renders. - * To adjust the position the camera is looking at in the game world, see the `scrollX` value. - * - * @name Phaser.Cameras.Scene2D.Camera#x - * @type {number} - * @since 3.0.0 - */ - this.x = x; - - /** - * The y position of the Camera, relative to the top-left of the game canvas. - * The viewport is the area into which the camera renders. - * To adjust the position the camera is looking at in the game world, see the `scrollY` value. - * - * @name Phaser.Cameras.Scene2D.Camera#y - * @type {number} - * @since 3.0.0 - */ - this.y = y; - - /** - * The width of the Camera viewport, in pixels. - * - * The viewport is the area into which the Camera renders. Setting the viewport does - * not restrict where the Camera can scroll to. - * - * @name Phaser.Cameras.Scene2D.Camera#width - * @type {number} - * @since 3.0.0 - */ - this.width = width; - - /** - * The height of the Camera viewport, in pixels. - * - * The viewport is the area into which the Camera renders. Setting the viewport does - * not restrict where the Camera can scroll to. - * - * @name Phaser.Cameras.Scene2D.Camera#height - * @type {number} - * @since 3.0.0 - */ - this.height = height; - - /** - * Should this camera round its pixel values to integers? - * - * @name Phaser.Cameras.Scene2D.Camera#roundPixels - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.roundPixels = false; - - /** - * Is this Camera visible or not? - * - * A visible camera will render and perform input tests. - * An invisible camera will not render anything and will skip input tests. - * - * @name Phaser.Cameras.Scene2D.Camera#visible - * @type {boolean} - * @default true - * @since 3.10.0 - */ - this.visible = true; - - /** - * Is this Camera using a bounds to restrict scrolling movement? - * - * Set this property along with the bounds via `Camera.setBounds`. - * - * @name Phaser.Cameras.Scene2D.Camera#useBounds - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.useBounds = false; - - /** - * The bounds the camera is restrained to during scrolling. - * - * @name Phaser.Cameras.Scene2D.Camera#_bounds - * @type {Phaser.Geom.Rectangle} - * @private - * @since 3.0.0 - */ - this._bounds = new Rectangle(); + BaseCamera.call(this, x, y, width, height); /** * Does this Camera allow the Game Objects it renders to receive input events? @@ -216,115 +77,6 @@ var Camera = new Class({ */ this.inputEnabled = true; - /** - * The horizontal scroll position of this Camera. - * - * Change this value to cause the Camera to scroll around your Scene. - * - * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, - * will automatically adjust the Camera scroll values accordingly. - * - * You can set the bounds within which the Camera can scroll via the `setBounds` method. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollX = 0; - - /** - * The vertical scroll position of this Camera. - * - * Change this value to cause the Camera to scroll around your Scene. - * - * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, - * will automatically adjust the Camera scroll values accordingly. - * - * You can set the bounds within which the Camera can scroll via the `setBounds` method. - * - * @name Phaser.Cameras.Scene2D.Camera#scrollY - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.scrollY = 0; - - /** - * The Camera zoom value. Change this value to zoom in, or out of, a Scene. - * - * A value of 0.5 would zoom the Camera out, so you can now see twice as much - * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel - * now takes up 2 pixels when rendered. - * - * Set to 1 to return to the default zoom level. - * - * Be careful to never set this value to zero. - * - * @name Phaser.Cameras.Scene2D.Camera#zoom - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.zoom = 1; - - /** - * The rotation of the Camera in radians. - * - * Camera rotation always takes place based on the Camera viewport. By default, rotation happens - * in the center of the viewport. You can adjust this with the `originX` and `originY` properties. - * - * Rotation influences the rendering of _all_ Game Objects visible by this Camera. However, it does not - * rotate the Camera viewport itself, which always remains an axis-aligned rectangle. - * - * @name Phaser.Cameras.Scene2D.Camera#rotation - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.rotation = 0; - - /** - * A local transform matrix used for internal calculations. - * - * @name Phaser.Cameras.Scene2D.Camera#matrix - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @private - * @since 3.0.0 - */ - this.matrix = new TransformMatrix(1, 0, 0, 1, 0, 0); - - /** - * Does this Camera have a transparent background? - * - * @name Phaser.Cameras.Scene2D.Camera#transparent - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.transparent = true; - - /** - * The background color of this Camera. Only used if `transparent` is `false`. - * - * @name Phaser.Cameras.Scene2D.Camera#backgroundColor - * @type {Phaser.Display.Color} - * @since 3.0.0 - */ - this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); - - /** - * The Camera alpha value. Setting this property impacts every single object that this Camera - * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, - * or via the chainable `setAlpha` method instead. - * - * @name Phaser.Cameras.Scene2D.Camera#alpha - * @type {number} - * @default 1 - * @since 3.11.0 - */ - this.alpha = 1; - /** * The Camera Fade effect handler. * To fade this camera see the `Camera.fade` methods. @@ -375,28 +127,6 @@ var Camera = new Class({ */ this.zoomEffect = new Effects.Zoom(this); - /** - * Should the camera cull Game Objects before checking them for input hit tests? - * In some special cases it may be beneficial to disable this. - * - * @name Phaser.Cameras.Scene2D.Camera#disableCull - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.disableCull = false; - - /** - * A temporary array of culled objects. - * - * @name Phaser.Cameras.Scene2D.Camera#culledObjects - * @type {Phaser.GameObjects.GameObject[]} - * @default [] - * @private - * @since 3.0.0 - */ - this.culledObjects = []; - /** * The linear interpolation value to use when following a target. * @@ -426,55 +156,6 @@ var Camera = new Class({ */ this.followOffset = new Vector2(); - /** - * The mid-point of the Camera in 'world' coordinates. - * - * Use it to obtain exactly where in the world the center of the camera is currently looking. - * - * This value is updated in the preRender method, after the scroll values and follower - * have been processed. - * - * @name Phaser.Cameras.Scene2D.Camera#midPoint - * @type {Phaser.Math.Vector2} - * @readOnly - * @since 3.11.0 - */ - this.midPoint = new Vector2(width / 2, height / 2); - - /** - * The horizontal origin of rotation for this Camera. - * - * By default the camera rotates around the center of the viewport. - * - * Changing the origin allows you to adjust the point in the viewport from which rotation happens. - * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. - * - * See `setOrigin` to set both origins in a single, chainable call. - * - * @name Phaser.Cameras.Scene2D.Camera#originX - * @type {number} - * @default 0.5 - * @since 3.11.0 - */ - this.originX = 0.5; - - /** - * The vertical origin of rotation for this Camera. - * - * By default the camera rotates around the center of the viewport. - * - * Changing the origin allows you to adjust the point in the viewport from which rotation happens. - * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. - * - * See `setOrigin` to set both origins in a single, chainable call. - * - * @name Phaser.Cameras.Scene2D.Camera#originY - * @type {number} - * @default 0.5 - * @since 3.11.0 - */ - this.originY = 0.5; - /** * The Camera dead zone. * @@ -510,53 +191,231 @@ var Camera = new Class({ * @since 3.0.0 */ this._follow = null; + + /** + * Is this Camera rendering directly to the canvas or to a texture? + * + * Enable rendering to texture with the method `setRenderToTexture` (just enabling this boolean won't be enough) + * + * Once enabled you can toggle it by switching this property. + * + * To properly remove a render texture you should call the `clearRenderToTexture()` method. + * + * @name Phaser.Cameras.Scene2D.Camera#renderToTexture + * @type {boolean} + * @default false + * @since 3.13.0 + */ + this.renderToTexture = false; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the HTML Canvas Element that the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#canvas + * @type {HTMLCanvasElement} + * @since 3.13.0 + */ + this.canvas = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the Rendering Context belonging to the Canvas element the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#context + * @type {CanvasRenderingContext2D} + * @since 3.13.0 + */ + this.context = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Texture belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#framebuffer + * @type {?WebGLTexture} + * @since 3.13.0 + */ + this.glTexture = null; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Frame Buffer belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#framebuffer + * @type {?WebGLFramebuffer} + * @since 3.13.0 + */ + this.framebuffer = null; + + /** + * If this Camera has been set to render to a texture and to use a custom pipeline, + * then this holds a reference to the pipeline the Camera is drawing with. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + * + * @name Phaser.Cameras.Scene2D.Camera#pipeline + * @type {any} + * @since 3.13.0 + */ + this.pipeline = null; }, /** - * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * Sets the Camera to render to a texture instead of to the main canvas. + * + * The Camera will redirect all Game Objects it's asked to render to this texture. + * + * During the render sequence, the texture itself will then be rendered to the main canvas. + * + * Doing this gives you the ability to modify the texture before this happens, + * allowing for special effects such as Camera specific shaders, or post-processing + * on the texture. + * + * If running under Canvas the Camera will render to its `canvas` property. + * + * If running under WebGL the Camera will create a frame buffer, which is stored in its `framebuffer` and `glTexture` properties. + * + * If you set a camera to render to a texture then it will emit 2 events during the render loop: + * + * First, it will emit the event `prerender`. This happens right before any Game Object's are drawn to the Camera texture. + * + * Then, it will emit the event `postrender`. This happens after all Game Object's have been drawn, but right before the + * Camera texture is rendered to the main game canvas. It's the final point at which you can manipulate the texture before + * it appears in-game. + * + * You should not enable this unless you plan on actually using the texture it creates + * somehow, otherwise you're just doubling the work required to render your game. + * + * To temporarily disable rendering to a texture, toggle the `renderToTexture` boolean. + * + * If you no longer require the Camera to render to a texture, call the `clearRenderToTexture` method, + * which will delete the respective textures and free-up resources. * - * @method Phaser.GameObjects.Components.Origin#setAlpha - * @since 3.11.0 + * @method Phaser.Cameras.Scene2D.Camera#setRenderToTexture + * @since 3.13.0 * - * @param {number} [value=1] - The Camera alpha value. + * @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} [pipeline] - An optional WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. * - * @return {this} This Camera instance. + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. */ - setAlpha: function (value) + setRenderToTexture: function (pipeline) { - if (value === undefined) { value = 1; } + var renderer = this.scene.sys.game.renderer; - this.alpha = value; + if (renderer.gl) + { + this.glTexture = renderer.createTextureFromSource(null, this.width, this.height, 0); + this.framebuffer = renderer.createFramebuffer(this.width, this.height, this.glTexture, false); + } + else + { + this.canvas = CanvasPool.create2D(this, this.width, this.height); + this.context = this.canvas.getContext('2d'); + } + + this.renderToTexture = true; + + if (pipeline) + { + this.setPipeline(pipeline); + } return this; }, /** - * Sets the rotation origin of this Camera. + * Sets the WebGL pipeline this Camera is using when rendering to a texture. + * + * You can pass either the string-based name of the pipeline, or a reference to the pipeline itself. + * + * Call this method with no arguments to clear any previously set pipeline. * - * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. + * @method Phaser.Cameras.Scene2D.Camera#setPipeline + * @since 3.13.0 * - * By default the camera rotates around the center of the viewport. + * @param {(string|Phaser.Renderer.WebGL.WebGLPipeline)} [pipeline] - The WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. Or if left empty it will clear the pipeline. * - * Changing the origin allows you to adjust the point in the viewport from which rotation happens. - * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. - * - * @method Phaser.GameObjects.Components.Origin#setOrigin - * @since 3.11.0 - * - * @param {number} [x=0.5] - The horizontal origin value. - * @param {number} [y=x] - The vertical origin value. If not defined it will be set to the value of `x`. - * - * @return {this} This Camera instance. + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. */ - setOrigin: function (x, y) + setPipeline: function (pipeline) { - if (x === undefined) { x = 0.5; } - if (y === undefined) { y = x; } + if (typeof pipeline === 'string') + { + var renderer = this.scene.sys.game.renderer; - this.originX = x; - this.originY = y; + if (renderer.gl && renderer.hasPipeline(pipeline)) + { + this.pipeline = renderer.getPipeline(pipeline); + } + } + else + { + this.pipeline = pipeline; + } + + return this; + }, + + /** + * If this Camera was set to render to a texture, this will clear the resources it was using and + * redirect it to render back to the primary Canvas again. + * + * If you only wish to temporarily disable rendering to a texture then you can toggle the + * property `renderToTexture` instead. + * + * @method Phaser.Cameras.Scene2D.Camera#clearRenderToTexture + * @since 3.13.0 + * + * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. + */ + clearRenderToTexture: function () + { + var renderer = this.scene.sys.game.renderer; + + if (renderer.gl) + { + if (this.framebuffer) + { + renderer.deleteFramebuffer(this.framebuffer); + } + + if (this.glTexture) + { + renderer.deleteTexture(this.glTexture); + } + + this.framebuffer = null; + this.glTexture = null; + this.pipeline = null; + } + else + { + CanvasPool.remove(this); + + this.canvas = null; + this.context = null; + } + + this.renderToTexture = false; return this; }, @@ -623,190 +482,6 @@ var Camera = new Class({ return this; }, - /** - * Calculates what the Camera.scrollX and scrollY values would need to be in order to move - * the Camera so it is centered on the given x and y coordinates, without actually moving - * the Camera there. The results are clamped based on the Camera bounds, if set. - * - * @method Phaser.Cameras.Scene2D.Camera#getScroll - * @since 3.11.0 - * - * @param {number} x - The horizontal coordinate to center on. - * @param {number} y - The vertical coordinate to center on. - * @param {Phaser.Math.Vector2} [out] - A Vec2 to store the values in. If not given a new Vec2 is created. - * - * @return {Phaser.Math.Vector2} The scroll coordinates stored in the `x` abd `y` properties. - */ - getScroll: function (x, y, out) - { - if (out === undefined) { out = new Vector2(); } - - var originX = this.width * 0.5; - var originY = this.height * 0.5; - - out.x = x - originX; - out.y = y - originY; - - if (this.useBounds) - { - out.x = this.clampX(out.x); - out.y = this.clampY(out.y); - } - - return out; - }, - - /** - * Moves the Camera so that it is centered on the given coordinates, bounds allowing. - * - * @method Phaser.Cameras.Scene2D.Camera#centerOn - * @since 3.11.0 - * - * @param {number} x - The horizontal coordinate to center on. - * @param {number} y - The vertical coordinate to center on. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerOn: function (x, y) - { - var originX = this.width * 0.5; - var originY = this.height * 0.5; - - this.midPoint.set(x, y); - - this.scrollX = x - originX; - this.scrollY = y - originY; - - if (this.useBounds) - { - this.scrollX = this.clampX(this.scrollX); - this.scrollY = this.clampY(this.scrollY); - } - - return this; - }, - - /** - * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. - * - * @method Phaser.Cameras.Scene2D.Camera#centerToBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToBounds: function () - { - if (this.useBounds) - { - var bounds = this._bounds; - var originX = this.width * 0.5; - var originY = this.height * 0.5; - - this.midPoint.set(bounds.centerX, bounds.centerY); - - this.scrollX = bounds.centerX - originX; - this.scrollY = bounds.centerY - originY; - } - - return this; - }, - - /** - * Moves the Camera so that it is re-centered based on its viewport size. - * - * @method Phaser.Cameras.Scene2D.Camera#centerToSize - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - centerToSize: function () - { - this.scrollX = this.width * 0.5; - this.scrollY = this.height * 0.5; - - return this; - }, - - /** - * Takes an array of Game Objects and returns a new array featuring only those objects - * visible by this camera. - * - * @method Phaser.Cameras.Scene2D.Camera#cull - * @since 3.0.0 - * - * @generic {Phaser.GameObjects.GameObject[]} G - [renderableObjects,$return] - * - * @param {Phaser.GameObjects.GameObject[]} renderableObjects - An array of Game Objects to cull. - * - * @return {Phaser.GameObjects.GameObject[]} An array of Game Objects visible to this Camera. - */ - cull: function (renderableObjects) - { - if (this.disableCull) - { - return renderableObjects; - } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - return renderableObjects; - } - - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - var cameraW = this.width; - var cameraH = this.height; - var culledObjects = this.culledObjects; - var length = renderableObjects.length; - - determinant = 1 / determinant; - - culledObjects.length = 0; - - for (var index = 0; index < length; ++index) - { - var object = renderableObjects[index]; - - if (!object.hasOwnProperty('width') || object.parentContainer) - { - culledObjects.push(object); - continue; - } - - var objectW = object.width; - var objectH = object.height; - var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX); - var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY); - var tx = (objectX * mva + objectY * mvc + mve); - var ty = (objectX * mvb + objectY * mvd + mvf); - var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); - var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); - var cullW = cameraW + objectW; - var cullH = cameraH + objectH; - - if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH && - tw > -objectW && th > -objectH && tw < cullW && th < cullH) - { - culledObjects.push(object); - } - } - - return culledObjects; - }, - /** * Fades the Camera in from the given color over the duration specified. * @@ -982,102 +657,6 @@ var Camera = new Class({ return this.zoomEffect.start(zoom, duration, ease, force, callback, context); }, - /** - * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. - * You can optionally provide a Vector2, or similar object, to store the results in. - * - * @method Phaser.Cameras.Scene2D.Camera#getWorldPoint - * @since 3.0.0 - * - * @generic {Phaser.Math.Vector2} O - [output,$return] - * - * @param {number} x - The x position to convert to world space. - * @param {number} y - The y position to convert to world space. - * @param {(object|Phaser.Math.Vector2)} [output] - An optional object to store the results in. If not provided a new Vector2 will be created. - * - * @return {Phaser.Math.Vector2} An object holding the converted values in its `x` and `y` properties. - */ - getWorldPoint: function (x, y, output) - { - if (output === undefined) { output = new Vector2(); } - - var cameraMatrix = this.matrix.matrix; - - var mva = cameraMatrix[0]; - var mvb = cameraMatrix[1]; - var mvc = cameraMatrix[2]; - var mvd = cameraMatrix[3]; - var mve = cameraMatrix[4]; - var mvf = cameraMatrix[5]; - - /* First Invert Matrix */ - var determinant = (mva * mvd) - (mvb * mvc); - - if (!determinant) - { - output.x = x; - output.y = y; - - return output; - } - - determinant = 1 / determinant; - - var ima = mvd * determinant; - var imb = -mvb * determinant; - var imc = -mvc * determinant; - var imd = mva * determinant; - var ime = (mvc * mvf - mvd * mve) * determinant; - var imf = (mvb * mve - mva * mvf) * determinant; - - var c = Math.cos(this.rotation); - var s = Math.sin(this.rotation); - - var zoom = this.zoom; - - var scrollX = this.scrollX; - var scrollY = this.scrollY; - - var sx = x + ((scrollX * c - scrollY * s) * zoom); - var sy = y + ((scrollX * s + scrollY * c) * zoom); - - /* Apply transform to point */ - output.x = (sx * ima + sy * imc + ime); - output.y = (sx * imb + sy * imd + imf); - - return output; - }, - - /** - * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings - * so that they are ignored by this Camera. This means they will not be rendered by this Camera. - * - * @method Phaser.Cameras.Scene2D.Camera#ignore - * @since 3.0.0 - * - * @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObject - The Game Object, or array of Game Objects, to be ignored by this Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - ignore: function (gameObject) - { - var id = this.id; - - if (Array.isArray(gameObject)) - { - for (var i = 0; i < gameObject.length; i++) - { - gameObject[i].cameraFilter |= id; - } - } - else - { - gameObject.cameraFilter |= id; - } - - return this; - }, - /** * Internal preRender step. * @@ -1092,12 +671,19 @@ var Camera = new Class({ { var width = this.width; var height = this.height; + + var halfWidth = width * 0.5; + var halfHeight = height * 0.5; + var zoom = this.zoom * baseScale; var matrix = this.matrix; + var originX = width * this.originX; var originY = height * this.originY; + var follow = this._follow; var deadzone = this.deadzone; + var sx = this.scrollX; var sy = this.scrollY; @@ -1150,10 +736,26 @@ var Camera = new Class({ originY = Math.round(originY); } + // Values are in pixels and not impacted by zooming the Camera this.scrollX = sx; this.scrollY = sy; - this.midPoint.set(sx + (width * 0.5), sy + (height * 0.5)); + var midX = sx + halfWidth; + var midY = sy + halfHeight; + + // The center of the camera, in world space, so taking zoom into account + // Basically the pixel value of what it's looking at in the middle of the cam + this.midPoint.set(midX, midY); + + var displayWidth = width / zoom; + var displayHeight = height / zoom; + + this.worldView.setTo( + midX - (displayWidth / 2), + midY - (displayHeight / 2), + displayWidth, + displayHeight + ); matrix.loadIdentity(); matrix.scale(resolution, resolution); @@ -1165,113 +767,6 @@ var Camera = new Class({ this.shakeEffect.preRender(); }, - /** - * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. - * Do not call this method if you are not using camera bounds. - * - * @method Phaser.Cameras.Scene2D.Camera#clampX - * @since 3.11.0 - * - * @param {number} x - The value to horizontally scroll clamp. - * - * @return {number} The adjusted value to use as scrollX. - */ - clampX: function (x) - { - var bounds = this._bounds; - - var dw = this.displayWidth; - - var bx = bounds.x + ((dw - this.width) / 2); - var bw = Math.max(bx, bx + bounds.width - dw); - - if (x < bx) - { - x = bx; - } - else if (x > bw) - { - x = bw; - } - - return x; - }, - - /** - * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. - * Do not call this method if you are not using camera bounds. - * - * @method Phaser.Cameras.Scene2D.Camera#clampY - * @since 3.11.0 - * - * @param {number} y - The value to vertically scroll clamp. - * - * @return {number} The adjusted value to use as scrollY. - */ - clampY: function (y) - { - var bounds = this._bounds; - - var dh = this.displayHeight; - - var by = bounds.y + ((dh - this.height) / 2); - var bh = Math.max(by, by + bounds.height - dh); - - if (y < by) - { - y = by; - } - else if (y > bh) - { - y = bh; - } - - return y; - }, - - /* - var gap = this._zoomInversed; - return gap * Math.round((src.x - this.scrollX * src.scrollFactorX) / gap); - */ - - /** - * If this Camera has previously had movement bounds set on it, this will remove them. - * - * @method Phaser.Cameras.Scene2D.Camera#removeBounds - * @since 3.0.0 - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - removeBounds: function () - { - this.useBounds = false; - - this._bounds.setEmpty(); - - return this; - }, - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setAngle - * @since 3.0.0 - * - * @param {number} [value=0] - The cameras angle of rotation, given in degrees. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setAngle: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = DegToRad(value); - - return this; - }, - /** * Sets the linear interpolation value to use when following a target. * @@ -1322,312 +817,6 @@ var Camera = new Class({ return this; }, - /** - * Sets the background color for this Camera. - * - * By default a Camera has a transparent background but it can be given a solid color, with any level - * of transparency, via this method. - * - * The color value can be specified using CSS color notation, hex or numbers. - * - * @method Phaser.Cameras.Scene2D.Camera#setBackgroundColor - * @since 3.0.0 - * - * @param {(string|number|InputColorObject)} [color='rgba(0,0,0,0)'] - The color value. In CSS, hex or numeric color notation. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBackgroundColor: function (color) - { - if (color === undefined) { color = 'rgba(0,0,0,0)'; } - - this.backgroundColor = ValueToColor(color); - - this.transparent = (this.backgroundColor.alpha === 0); - - return this; - }, - - /** - * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. - * - * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the - * edges and into blank space. It does not limit the placement of Game Objects, or where - * the Camera viewport can be positioned. - * - * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. - * - * Clear the bounds entirely by calling `Camera.removeBounds`. - * - * If you set bounds that are smaller than the viewport it will stop the Camera from being - * able to scroll. The bounds can be positioned where-ever you wish. By default they are from - * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of - * the Camera bounds. However, you can position them anywhere. So if you wanted a game world - * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y - * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find - * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. - * - * @method Phaser.Cameras.Scene2D.Camera#setBounds - * @since 3.0.0 - * - * @param {integer} x - The top-left x coordinate of the bounds. - * @param {integer} y - The top-left y coordinate of the bounds. - * @param {integer} width - The width of the bounds, in pixels. - * @param {integer} height - The height of the bounds, in pixels. - * @param {boolean} [centerOn] - If `true` the Camera will automatically be centered on the new bounds. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setBounds: function (x, y, width, height, centerOn) - { - this._bounds.setTo(x, y, width, height); - - this.useBounds = true; - - if (centerOn) - { - this.centerToBounds(); - } - else - { - this.scrollX = this.clampX(this.scrollX); - this.scrollY = this.clampY(this.scrollY); - } - - return this; - }, - - /** - * Sets the name of this Camera. - * This value is for your own use and isn't used internally. - * - * @method Phaser.Cameras.Scene2D.Camera#setName - * @since 3.0.0 - * - * @param {string} [value=''] - The name of the Camera. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setName: function (value) - { - if (value === undefined) { value = ''; } - - this.name = value; - - return this; - }, - - /** - * Set the position of the Camera viewport within the game. - * - * This does not change where the camera is 'looking'. See `setScroll` to control that. - * - * @method Phaser.Cameras.Scene2D.Camera#setPosition - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the Camera viewport. - * @param {number} [y=x] - The top-left y coordinate of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setPosition: function (x, y) - { - if (y === undefined) { y = x; } - - this.x = x; - this.y = y; - - return this; - }, - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setRotation - * @since 3.0.0 - * - * @param {number} [value=0] - The rotation of the Camera, in radians. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRotation: function (value) - { - if (value === undefined) { value = 0; } - - this.rotation = value; - - return this; - }, - - /** - * Should the Camera round pixel values to whole integers when rendering Game Objects? - * - * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. - * - * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels - * @since 3.0.0 - * - * @param {boolean} value - `true` to round Camera pixels, `false` to not. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setRoundPixels: function (value) - { - this.roundPixels = value; - - return this; - }, - - /** - * Sets the Scene the Camera is bound to. - * - * @method Phaser.Cameras.Scene2D.Camera#setScene - * @since 3.0.0 - * - * @param {Phaser.Scene} scene - The Scene the camera is bound to. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScene: function (scene) - { - this.scene = scene; - - return this; - }, - - /** - * Set the position of where the Camera is looking within the game. - * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. - * Use this method, or the scroll properties, to move your camera around the game world. - * - * This does not change where the camera viewport is placed. See `setPosition` to control that. - * - * @method Phaser.Cameras.Scene2D.Camera#setScroll - * @since 3.0.0 - * - * @param {number} x - The x coordinate of the Camera in the game world. - * @param {number} [y=x] - The y coordinate of the Camera in the game world. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setScroll: function (x, y) - { - if (y === undefined) { y = x; } - - this.scrollX = x; - this.scrollY = y; - - return this; - }, - - /** - * Set the size of the Camera viewport. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setSize - * @since 3.0.0 - * - * @param {integer} width - The width of the Camera viewport. - * @param {integer} [height=width] - The height of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setSize: function (width, height) - { - if (height === undefined) { height = width; } - - this.width = width; - this.height = height; - - return this; - }, - - /** - * This method sets the position and size of the Camera viewport in a single call. - * - * If you're trying to change where the Camera is looking at in your game, then see - * the method `Camera.setScroll` instead. This method is for changing the viewport - * itself, not what the camera can see. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * - * @method Phaser.Cameras.Scene2D.Camera#setViewport - * @since 3.0.0 - * - * @param {number} x - The top-left x coordinate of the Camera viewport. - * @param {number} y - The top-left y coordinate of the Camera viewport. - * @param {integer} width - The width of the Camera viewport. - * @param {integer} [height=width] - The height of the Camera viewport. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setViewport: function (x, y, width, height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - - return this; - }, - - /** - * Set the zoom value of the Camera. - * - * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. - * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. - * - * A value of 1 means 'no zoom' and is the default. - * - * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. - * - * @method Phaser.Cameras.Scene2D.Camera#setZoom - * @since 3.0.0 - * - * @param {number} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001. - * - * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. - */ - setZoom: function (value) - { - if (value === undefined) { value = 1; } - - if (value === 0) - { - value = 0.001; - } - - this.zoom = value; - - return this; - }, - - /** - * Sets the visibility of this Camera. - * - * An invisible Camera will skip rendering and input tests of everything it can see. - * - * @method Phaser.Cameras.Scene2D.Camera#setVisible - * @since 3.10.0 - * - * @param {boolean} value - The visible state of the Camera. - * - * @return {this} This Camera instance. - */ - setVisible: function (value) - { - this.visible = value; - - return this; - }, - /** * Sets the Camera to follow a Game Object. * @@ -1702,43 +891,6 @@ var Camera = new Class({ return this; }, - /** - * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. - * - * @method Phaser.Cameras.Scene2D.Camera#toJSON - * @since 3.0.0 - * - * @return {JSONCamera} A well-formed object suitable for conversion to JSON. - */ - toJSON: function () - { - var output = { - name: this.name, - x: this.x, - y: this.y, - width: this.width, - height: this.height, - zoom: this.zoom, - rotation: this.rotation, - roundPixels: this.roundPixels, - scrollX: this.scrollX, - scrollY: this.scrollY, - backgroundColor: this.backgroundColor.rgba - }; - - if (this.useBounds) - { - output['bounds'] = { - x: this._bounds.x, - y: this._bounds.y, - width: this._bounds.width, - height: this._bounds.height - }; - } - - return output; - }, - /** * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to * remove the fade. @@ -1780,13 +932,6 @@ var Camera = new Class({ } }, - /** - * This event is fired when a camera is destroyed by the Camera Manager. - * - * @event CameraDestroyEvent - * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that was destroyed. - */ - /** * Destroys this Camera instance. You rarely need to call this directly. * @@ -1799,100 +944,15 @@ var Camera = new Class({ */ destroy: function () { - this.emit('cameradestroy', this); - - this.removeAllListeners(); + this.clearRenderToTexture(); this.resetFX(); - this.matrix.destroy(); - - this.culledObjects = []; + BaseCamera.prototype.destroy.call(this); this._follow = null; - this._bounds = null; - this.scene = null; + this.deadzone = null; - }, - - /** - * The x position of the center of the Camera's viewport, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#centerX - * @type {number} - * @readOnly - * @since 3.10.0 - */ - centerX: { - - get: function () - { - return this.x + (0.5 * this.width); - } - - }, - - /** - * The y position of the center of the Camera's viewport, relative to the top-left of the game canvas. - * - * @name Phaser.Cameras.Scene2D.Camera#centerY - * @type {number} - * @readOnly - * @since 3.10.0 - */ - centerY: { - - get: function () - { - return this.y + (0.5 * this.height); - } - - }, - - /** - * The displayed width of the camera viewport, factoring in the camera zoom level. - * - * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width - * would be 1600, as it's displaying twice as many pixels as zoom level 1. - * - * Equally, a camera with a width of 800 and zoom of 2 would have a display width - * of 400 pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#displayWidth - * @type {number} - * @readOnly - * @since 3.11.0 - */ - displayWidth: { - - get: function () - { - return this.width / this.zoom; - } - - }, - - /** - * The displayed height of the camera viewport, factoring in the camera zoom level. - * - * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height - * would be 1200, as it's displaying twice as many pixels as zoom level 1. - * - * Equally, a camera with a height of 600 and zoom of 2 would have a display height - * of 300 pixels. - * - * @name Phaser.Cameras.Scene2D.Camera#displayHeight - * @type {number} - * @readOnly - * @since 3.11.0 - */ - displayHeight: { - - get: function () - { - return this.height / this.zoom; - } - } }); diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 45d19824b..12ded64d3 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -63,7 +63,7 @@ var RectangleContains = require('../../geom/rectangle/Contains'); * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. * * @class CameraManager - * @memberOf Phaser.Cameras.Scene2D + * @memberof Phaser.Cameras.Scene2D * @constructor * @since 3.0.0 * @@ -188,7 +188,20 @@ var CameraManager = new Class({ { if (!this.main) { - this.boot(); + 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 = this.systems.events; @@ -209,7 +222,7 @@ var CameraManager = new Class({ * By default Cameras are transparent and will render anything that they can see based on their `scrollX` * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. * - * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change * it after creation if required. * * See the Camera class documentation for more details. @@ -258,7 +271,7 @@ var CameraManager = new Class({ * * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. * - * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change * it after addition if required. * * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the @@ -518,18 +531,22 @@ var CameraManager = new Class({ * If found in the Camera Manager it will be immediately removed from the local cameras array. * If also currently the 'main' camera, 'main' will be reset to be camera 0. * - * The removed Camera is not destroyed. If you also wish to destroy the Camera, you should call - * `Camera.destroy` on it, so that it clears all references to the Camera Manager. + * The removed Cameras are automatically destroyed if the `runDestroy` argument is `true`, which is the default. + * If you wish to re-use the cameras then set this to `false`, but know that they will retain their references + * and internal data until destroyed or re-added to a Camera Manager. * * @method Phaser.Cameras.Scene2D.CameraManager#remove * @since 3.0.0 * * @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager. + * @param {boolean} [runDestroy=true] - Automatically call `Camera.destroy` on each Camera removed from this Camera Manager. * * @return {integer} The total number of Cameras removed. */ - remove: function (camera) + remove: function (camera, runDestroy) { + if (runDestroy === undefined) { runDestroy = true; } + if (!Array.isArray(camera)) { camera = [ camera ]; @@ -544,12 +561,18 @@ var CameraManager = new Class({ if (index !== -1) { + if (runDestroy) + { + cameras[index].destroy(); + } + cameras.splice(index, 1); + total++; } } - if (!this.main) + if (!this.main && cameras[0]) { this.main = cameras[0]; } diff --git a/src/cameras/2d/effects/Fade.js b/src/cameras/2d/effects/Fade.js index d4ecc44d3..e87c21c7e 100644 --- a/src/cameras/2d/effects/Fade.js +++ b/src/cameras/2d/effects/Fade.js @@ -20,7 +20,7 @@ var Class = require('../../../utils/Class'); * which is invoked each frame for the duration of the effect, if required. * * @class Fade - * @memberOf Phaser.Cameras.Scene2D.Effects + * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.5.0 * @@ -37,7 +37,7 @@ var Fade = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Fade#camera * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly + * @readonly * @since 3.5.0 */ this.camera = camera; @@ -47,7 +47,7 @@ var Fade = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Fade#isRunning * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.5.0 */ @@ -61,7 +61,7 @@ var Fade = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Fade#isComplete * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.5.0 */ @@ -73,7 +73,7 @@ var Fade = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Fade#direction * @type {boolean} - * @readOnly + * @readonly * @since 3.5.0 */ this.direction = true; @@ -83,7 +83,7 @@ var Fade = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Fade#duration * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.5.0 */ @@ -337,7 +337,7 @@ var Fade = new Class({ 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); + ctx.fillRect(camera._cx, camera._cy, camera._cw, camera._ch); return true; }, @@ -348,7 +348,7 @@ var Fade = new Class({ * @method Phaser.Cameras.Scene2D.Effects.Fade#postRenderWebGL * @since 3.5.0 * - * @param {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} pipeline - The WebGL Pipeline to render to. + * @param {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} 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`. @@ -365,13 +365,10 @@ var Fade = new Class({ 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, + pipeline.drawFillRect( + camera._cx, camera._cy, camera._cw, camera._ch, getTintFunction(red, green, blue, 1), - this.alpha, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] + this.alpha ); return true; diff --git a/src/cameras/2d/effects/Flash.js b/src/cameras/2d/effects/Flash.js index f314e5bee..bc30d261d 100644 --- a/src/cameras/2d/effects/Flash.js +++ b/src/cameras/2d/effects/Flash.js @@ -20,7 +20,7 @@ var Class = require('../../../utils/Class'); * which is invoked each frame for the duration of the effect, if required. * * @class Flash - * @memberOf Phaser.Cameras.Scene2D.Effects + * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.5.0 * @@ -37,7 +37,7 @@ var Flash = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Flash#camera * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly + * @readonly * @since 3.5.0 */ this.camera = camera; @@ -47,7 +47,7 @@ var Flash = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Flash#isRunning * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.5.0 */ @@ -58,7 +58,7 @@ var Flash = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Flash#duration * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.5.0 */ @@ -284,7 +284,7 @@ var Flash = new Class({ 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); + ctx.fillRect(camera._cx, camera._cy, camera._cw, camera._ch); return true; }, @@ -295,7 +295,7 @@ var Flash = new Class({ * @method Phaser.Cameras.Scene2D.Effects.Flash#postRenderWebGL * @since 3.5.0 * - * @param {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} pipeline - The WebGL Pipeline to render to. + * @param {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} 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`. @@ -312,13 +312,10 @@ var Flash = new Class({ 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, + pipeline.drawFillRect( + camera._cx, camera._cy, camera._cw, camera._ch, getTintFunction(red, green, blue, 1), - this.alpha, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] + this.alpha ); return true; diff --git a/src/cameras/2d/effects/Pan.js b/src/cameras/2d/effects/Pan.js index a55bdd690..655bd0ad9 100644 --- a/src/cameras/2d/effects/Pan.js +++ b/src/cameras/2d/effects/Pan.js @@ -23,7 +23,7 @@ var EaseMap = require('../../../math/easing/EaseMap'); * which is invoked each frame for the duration of the effect if required. * * @class Pan - * @memberOf Phaser.Cameras.Scene2D.Effects + * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.11.0 * @@ -40,7 +40,7 @@ var Pan = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Pan#camera * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly + * @readonly * @since 3.11.0 */ this.camera = camera; @@ -50,7 +50,7 @@ var Pan = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Pan#isRunning * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.11.0 */ @@ -61,7 +61,7 @@ var Pan = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Pan#duration * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.11.0 */ diff --git a/src/cameras/2d/effects/Shake.js b/src/cameras/2d/effects/Shake.js index d809f69f1..009064a47 100644 --- a/src/cameras/2d/effects/Shake.js +++ b/src/cameras/2d/effects/Shake.js @@ -21,7 +21,7 @@ var Vector2 = require('../../../math/Vector2'); * which is invoked each frame for the duration of the effect if required. * * @class Shake - * @memberOf Phaser.Cameras.Scene2D.Effects + * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.5.0 * @@ -38,7 +38,7 @@ var Shake = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Shake#camera * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly + * @readonly * @since 3.5.0 */ this.camera = camera; @@ -48,7 +48,7 @@ var Shake = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Shake#isRunning * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.5.0 */ @@ -59,7 +59,7 @@ var Shake = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Shake#duration * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.5.0 */ @@ -261,8 +261,8 @@ var Shake = new Class({ if (this._elapsed < this.duration) { var intensity = this.intensity; - var width = this.camera.width; - var height = this.camera.height; + var width = this.camera._cw; + var height = this.camera._ch; var zoom = this.camera.zoom; this._offsetX = (Math.random() * intensity.x * width * 2 - intensity.x * width) * zoom; @@ -270,8 +270,8 @@ var Shake = new Class({ if (this.camera.roundPixels) { - this._offsetX |= 0; - this._offsetY |= 0; + this._offsetX = Math.round(this._offsetX); + this._offsetY = Math.round(this._offsetY); } } else diff --git a/src/cameras/2d/effects/Zoom.js b/src/cameras/2d/effects/Zoom.js index 15289aca9..4ff38bfc5 100644 --- a/src/cameras/2d/effects/Zoom.js +++ b/src/cameras/2d/effects/Zoom.js @@ -18,7 +18,7 @@ var EaseMap = require('../../../math/easing/EaseMap'); * which is invoked each frame for the duration of the effect if required. * * @class Zoom - * @memberOf Phaser.Cameras.Scene2D.Effects + * @memberof Phaser.Cameras.Scene2D.Effects * @constructor * @since 3.11.0 * @@ -35,7 +35,7 @@ var Zoom = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Zoom#camera * @type {Phaser.Cameras.Scene2D.Camera} - * @readOnly + * @readonly * @since 3.11.0 */ this.camera = camera; @@ -45,7 +45,7 @@ var Zoom = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Zoom#isRunning * @type {boolean} - * @readOnly + * @readonly * @default false * @since 3.11.0 */ @@ -56,7 +56,7 @@ var Zoom = new Class({ * * @name Phaser.Cameras.Scene2D.Effects.Zoom#duration * @type {integer} - * @readOnly + * @readonly * @default 0 * @since 3.11.0 */ diff --git a/src/cameras/controls/FixedKeyControl.js b/src/cameras/controls/FixedKeyControl.js index cb2ec29db..9fc25858a 100644 --- a/src/cameras/controls/FixedKeyControl.js +++ b/src/cameras/controls/FixedKeyControl.js @@ -7,13 +7,6 @@ var Class = require('../../utils/Class'); var GetValue = require('../../utils/object/GetValue'); -// var camControl = new CameraControl({ -// camera: this.cameras.main, -// left: cursors.left, -// right: cursors.right, -// speed: float OR { x: 0, y: 0 } -// }) - /** * @typedef {object} FixedKeyControlConfig * @@ -21,6 +14,7 @@ var GetValue = require('../../utils/object/GetValue'); * @property {Phaser.Input.Keyboard.Key} [left] - The Key to be pressed that will move the Camera left. * @property {Phaser.Input.Keyboard.Key} [right] - The Key to be pressed that will move the Camera right. * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. + * @property {Phaser.Input.Keyboard.Key} [down] - The Key to be pressed that will move the Camera down. * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. @@ -29,14 +23,29 @@ var GetValue = require('../../utils/object/GetValue'); /** * @classdesc - * [description] + * A Fixed Key Camera Control. + * + * This allows you to control the movement and zoom of a camera using the defined keys. + * + * ```javascript + * var camControl = new FixedKeyControl({ + * camera: this.cameras.main, + * left: cursors.left, + * right: cursors.right, + * speed: float OR { x: 0, y: 0 } + * }); + * ``` + * + * Movement is precise and has no 'smoothing' applied to it. + * + * You must call the `update` method of this controller every frame. * * @class FixedKeyControl - * @memberOf Phaser.Cameras.Controls + * @memberof Phaser.Cameras.Controls * @constructor * @since 3.0.0 * - * @param {FixedKeyControlConfig} config - [description] + * @param {FixedKeyControlConfig} config - The Fixed Key Control configuration object. */ var FixedKeyControl = new Class({ @@ -158,7 +167,7 @@ var FixedKeyControl = new Class({ } /** - * [description] + * Internal property to track the current zoom level. * * @name Phaser.Cameras.Controls.FixedKeyControl#_zoom * @type {number} @@ -226,12 +235,14 @@ var FixedKeyControl = new Class({ }, /** - * [description] + * Applies the results of pressing the control keys to the Camera. + * + * You must call this every step, it is not called automatically. * * @method Phaser.Cameras.Controls.FixedKeyControl#update * @since 3.0.0 * - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (delta) { diff --git a/src/cameras/controls/SmoothedKeyControl.js b/src/cameras/controls/SmoothedKeyControl.js index b3724b581..3a0115777 100644 --- a/src/cameras/controls/SmoothedKeyControl.js +++ b/src/cameras/controls/SmoothedKeyControl.js @@ -7,20 +7,6 @@ var Class = require('../../utils/Class'); var GetValue = require('../../utils/object/GetValue'); -// var controlConfig = { -// camera: this.cameras.main, -// left: cursors.left, -// right: cursors.right, -// up: cursors.up, -// down: cursors.down, -// zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), -// zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), -// zoomSpeed: 0.02, -// acceleration: 0.06, -// drag: 0.0005, -// maxSpeed: 1.0 -// }; - /** * @typedef {object} SmoothedKeyControlConfig * @@ -38,14 +24,36 @@ var GetValue = require('../../utils/object/GetValue'); /** * @classdesc - * [description] + * A Smoothed Key Camera Control. + * + * This allows you to control the movement and zoom of a camera using the defined keys. + * Unlike the Fixed Camera Control you can also provide physics values for acceleration, drag and maxSpeed for smoothing effects. + * + * ```javascript + * + * var controlConfig = { + * camera: this.cameras.main, + * left: cursors.left, + * right: cursors.right, + * up: cursors.up, + * down: cursors.down, + * zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), + * zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), + * zoomSpeed: 0.02, + * acceleration: 0.06, + * drag: 0.0005, + * maxSpeed: 1.0 + * }; + * ``` + * + * You must call the `update` method of this controller every frame. * * @class SmoothedKeyControl - * @memberOf Phaser.Cameras.Controls + * @memberof Phaser.Cameras.Controls * @constructor * @since 3.0.0 * - * @param {SmoothedKeyControlConfig} config - [description] + * @param {SmoothedKeyControlConfig} config - The Smoothed Key Control configuration object. */ var SmoothedKeyControl = new Class({ @@ -233,7 +241,7 @@ var SmoothedKeyControl = new Class({ } /** - * [description] + * Internal property to track the speed of the control. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedX * @type {number} @@ -244,7 +252,7 @@ var SmoothedKeyControl = new Class({ this._speedX = 0; /** - * [description] + * Internal property to track the speed of the control. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#_speedY * @type {number} @@ -255,7 +263,7 @@ var SmoothedKeyControl = new Class({ this._speedY = 0; /** - * [description] + * Internal property to track the zoom of the control. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#_zoom * @type {number} @@ -323,12 +331,14 @@ var SmoothedKeyControl = new Class({ }, /** - * [description] + * Applies the results of pressing the control keys to the Camera. + * + * You must call this every step, it is not called automatically. * * @method Phaser.Cameras.Controls.SmoothedKeyControl#update * @since 3.0.0 * - * @param {number} delta - The delta time, in ms, elapsed since the last frame. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (delta) { diff --git a/src/cameras/index.js b/src/cameras/index.js index 88d064195..31f161f3a 100644 --- a/src/cameras/index.js +++ b/src/cameras/index.js @@ -11,7 +11,6 @@ module.exports = { Controls: require('./controls'), - Scene2D: require('./2d'), - Sprite3D: require('./sprite3d') + Scene2D: require('./2d') }; diff --git a/src/const.js b/src/const.js index cb7fd58d5..c2060cd7c 100644 --- a/src/const.js +++ b/src/const.js @@ -16,11 +16,11 @@ var CONST = { * Phaser Release Version * * @name Phaser.VERSION - * @readOnly + * @readonly * @type {string} * @since 3.0.0 */ - VERSION: '3.11.0-beta1', + VERSION: '3.16.0 Beta 4', BlendModes: require('./renderer/BlendModes'), @@ -30,7 +30,7 @@ var CONST = { * AUTO Detect Renderer. * * @name Phaser.AUTO - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -40,7 +40,7 @@ var CONST = { * Canvas Renderer. * * @name Phaser.CANVAS - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -50,7 +50,7 @@ var CONST = { * WebGL Renderer. * * @name Phaser.WEBGL - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -60,7 +60,7 @@ var CONST = { * Headless Renderer. * * @name Phaser.HEADLESS - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -71,7 +71,7 @@ var CONST = { * to help you remember what the value is doing in your code. * * @name Phaser.FOREVER - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -81,7 +81,7 @@ var CONST = { * Direction constant. * * @name Phaser.NONE - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -91,7 +91,7 @@ var CONST = { * Direction constant. * * @name Phaser.UP - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -101,7 +101,7 @@ var CONST = { * Direction constant. * * @name Phaser.DOWN - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -111,7 +111,7 @@ var CONST = { * Direction constant. * * @name Phaser.LEFT - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -121,7 +121,7 @@ var CONST = { * Direction constant. * * @name Phaser.RIGHT - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ diff --git a/src/create/GenerateTexture.js b/src/create/GenerateTexture.js index 6fcf940fc..6c02aff22 100644 --- a/src/create/GenerateTexture.js +++ b/src/create/GenerateTexture.js @@ -21,8 +21,8 @@ var GetValue = require('../utils/object/GetValue'); * @property {array} [data=[]] - [description] * @property {HTMLCanvasElement} [canvas=null] - [description] * @property {Palette} [palette=Arne16] - [description] - * @property {number} [pixelWidth=1] - [description] - * @property {number} [pixelHeight=1] - [description] + * @property {number} [pixelWidth=1] - The width of each 'pixel' in the generated texture. + * @property {number} [pixelHeight=1] - The height of each 'pixel' in the generated texture. * @property {boolean} [resizeCanvas=true] - [description] * @property {boolean} [clearCanvas=true] - [description] * @property {GenerateTextureRendererCallback} [preRender] - [description] diff --git a/src/curves/CubicBezierCurve.js b/src/curves/CubicBezierCurve.js index d4ae536f2..87e187307 100644 --- a/src/curves/CubicBezierCurve.js +++ b/src/curves/CubicBezierCurve.js @@ -13,11 +13,11 @@ var Vector2 = require('../math/Vector2'); /** * @classdesc - * [description] + * A higher-order Bézier curve constructed of four points. * * @class CubicBezier * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * @@ -45,7 +45,7 @@ var CubicBezierCurve = new Class({ } /** - * [description] + * The start point of this curve. * * @name Phaser.Curves.CubicBezier#p0 * @type {Phaser.Math.Vector2} @@ -54,7 +54,7 @@ var CubicBezierCurve = new Class({ this.p0 = p0; /** - * [description] + * The first control point of this curve. * * @name Phaser.Curves.CubicBezier#p1 * @type {Phaser.Math.Vector2} @@ -63,7 +63,7 @@ var CubicBezierCurve = new Class({ this.p1 = p1; /** - * [description] + * The second control point of this curve. * * @name Phaser.Curves.CubicBezier#p2 * @type {Phaser.Math.Vector2} @@ -72,7 +72,7 @@ var CubicBezierCurve = new Class({ this.p2 = p2; /** - * [description] + * The end point of this curve. * * @name Phaser.Curves.CubicBezier#p3 * @type {Phaser.Math.Vector2} @@ -101,7 +101,7 @@ var CubicBezierCurve = new Class({ }, /** - * [description] + * Returns the resolution of this curve. * * @method Phaser.Curves.CubicBezier#getResolution * @since 3.0.0 @@ -141,17 +141,17 @@ var CubicBezierCurve = new Class({ }, /** - * [description] + * Draws this curve to the specified graphics object. * * @method Phaser.Curves.CubicBezier#draw * @since 3.0.0 * * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] + * @param {Phaser.GameObjects.Graphics} graphics - The graphics object this curve should be drawn to. + * @param {integer} [pointsTotal=32] - The number of intermediary points that make up this curve. A higher number of points will result in a smoother curve. * - * @return {Phaser.GameObjects.Graphics} [description] + * @return {Phaser.GameObjects.Graphics} The graphics object this curve was drawn to. Useful for method chaining. */ draw: function (graphics, pointsTotal) { @@ -174,7 +174,7 @@ var CubicBezierCurve = new Class({ }, /** - * [description] + * Returns a JSON object that describes this curve. * * @method Phaser.Curves.CubicBezier#toJSON * @since 3.0.0 @@ -197,14 +197,14 @@ var CubicBezierCurve = new Class({ }); /** - * [description] + * Generates a curve from a JSON object. * * @function Phaser.Curves.CubicBezier.fromJSON * @since 3.0.0 * * @param {JSONCurve} data - The JSON object containing this curve data. * - * @return {Phaser.Curves.CubicBezier} [description] + * @return {Phaser.Curves.CubicBezier} The curve generated from the JSON object. */ CubicBezierCurve.fromJSON = function (data) { diff --git a/src/curves/Curve.js b/src/curves/Curve.js index 66115a756..9e6d672c1 100644 --- a/src/curves/Curve.js +++ b/src/curves/Curve.js @@ -16,7 +16,7 @@ var Vector2 = require('../math/Vector2'); * Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog) * * @class Curve - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * @@ -131,7 +131,7 @@ var Curve = new Class({ // So you can chain graphics calls return graphics.strokePoints(this.getPoints(pointsTotal)); }, - + /** * Returns a Rectangle where the position and dimensions match the bounds of this Curve. * @@ -192,9 +192,9 @@ var Curve = new Class({ * @method Phaser.Curves.Curve#getEndPoint * @since 3.0.0 * - * @param {Phaser.Math.Vector2} out - [description] + * @param {Phaser.Math.Vector2} [out] - Optional Vector object to store the result in. * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} Vector2 containing the coordinates of the curves end point. */ getEndPoint: function (out) { @@ -398,7 +398,7 @@ var Curve = new Class({ * @param {number} t - [description] * @param {Phaser.Math.Vector2} [out] - [description] * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} Vector approximating the tangent line at the point t (delta +/- 0.0001) */ getTangent: function (t, out) { diff --git a/src/curves/EllipseCurve.js b/src/curves/EllipseCurve.js index 352843775..a08e10f26 100644 --- a/src/curves/EllipseCurve.js +++ b/src/curves/EllipseCurve.js @@ -17,47 +17,49 @@ var Vector2 = require('../math/Vector2'); * @typedef {object} JSONEllipseCurve * * @property {string} type - The of the curve. - * @property {number} x - [description] - * @property {number} y - [description] + * @property {number} x - The x coordinate of the ellipse. + * @property {number} y - The y coordinate of the ellipse. * @property {number} xRadius - The horizontal radius of ellipse. * @property {number} yRadius - The vertical radius of ellipse. - * @property {integer} startAngle - The start angle of ellipse. - * @property {integer} endAngle - The end angle of ellipse. - * @property {boolean} clockwise - The clockwise of ellipse. - * @property {integer} rotation - The rotation of ellipse. + * @property {integer} startAngle - The start angle of the ellipse, in degrees. + * @property {integer} endAngle - The end angle of the ellipse, in degrees. + * @property {boolean} clockwise - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @property {integer} rotation - The rotation of ellipse, in degrees. */ /** * @typedef {object} EllipseCurveConfig * - * @property {number} [x=0] - [description] - * @property {number} [y=0] - [description] - * @property {number} [xRadius=0] - [description] - * @property {number} [yRadius=0] - [description] - * @property {integer} [startAngle=0] - [description] - * @property {integer} [endAngle=360] - [description] - * @property {boolean} [clockwise=false] - [description] - * @property {integer} [rotation=0] - [description] + * @property {number} [x=0] - The x coordinate of the ellipse. + * @property {number} [y=0] - The y coordinate of the ellipse. + * @property {number} [xRadius=0] - The horizontal radius of the ellipse. + * @property {number} [yRadius=0] - The vertical radius of the ellipse. + * @property {integer} [startAngle=0] - The start angle of the ellipse, in degrees. + * @property {integer} [endAngle=360] - The end angle of the ellipse, in degrees. + * @property {boolean} [clockwise=false] - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @property {integer} [rotation=0] - The rotation of the ellipse, in degrees. */ /** * @classdesc - * [description] + * An Elliptical Curve derived from the Base Curve class. + * + * See https://en.wikipedia.org/wiki/Elliptic_curve for more details. * * @class Ellipse * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * - * @param {(number|EllipseCurveConfig)} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [xRadius=0] - [description] - * @param {number} [yRadius=0] - [description] - * @param {integer} [startAngle=0] - [description] - * @param {integer} [endAngle=360] - [description] - * @param {boolean} [clockwise=false] - [description] - * @param {integer} [rotation=0] - [description] + * @param {(number|EllipseCurveConfig)} [x=0] - The x coordinate of the ellipse, or an Ellipse Curve configuration object. + * @param {number} [y=0] - The y coordinate of the ellipse. + * @param {number} [xRadius=0] - The horizontal radius of ellipse. + * @param {number} [yRadius=0] - The vertical radius of ellipse. + * @param {integer} [startAngle=0] - The start angle of the ellipse, in degrees. + * @param {integer} [endAngle=360] - The end angle of the ellipse, in degrees. + * @param {boolean} [clockwise=false] - Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) + * @param {integer} [rotation=0] - The rotation of the ellipse, in degrees. */ var EllipseCurve = new Class({ @@ -94,7 +96,7 @@ var EllipseCurve = new Class({ // Center point /** - * [description] + * The center point of the ellipse. Used for calculating rotation. * * @name Phaser.Curves.Ellipse#p0 * @type {Phaser.Math.Vector2} @@ -103,7 +105,7 @@ var EllipseCurve = new Class({ this.p0 = new Vector2(x, y); /** - * [description] + * The horizontal radius of the ellipse. * * @name Phaser.Curves.Ellipse#_xRadius * @type {number} @@ -113,7 +115,7 @@ var EllipseCurve = new Class({ this._xRadius = xRadius; /** - * [description] + * The vertical radius of the ellipse. * * @name Phaser.Curves.Ellipse#_yRadius * @type {number} @@ -125,7 +127,7 @@ var EllipseCurve = new Class({ // Radians /** - * [description] + * The starting angle of the ellipse in radians. * * @name Phaser.Curves.Ellipse#_startAngle * @type {number} @@ -135,7 +137,7 @@ var EllipseCurve = new Class({ this._startAngle = DegToRad(startAngle); /** - * [description] + * The end angle of the ellipse in radians. * * @name Phaser.Curves.Ellipse#_endAngle * @type {number} @@ -412,7 +414,7 @@ var EllipseCurve = new Class({ }, /** - * [description] + * The x coordinate of the center of the ellipse. * * @name Phaser.Curves.Ellipse#x * @type {number} @@ -433,7 +435,7 @@ var EllipseCurve = new Class({ }, /** - * [description] + * The y coordinate of the center of the ellipse. * * @name Phaser.Curves.Ellipse#y * @type {number} @@ -454,7 +456,7 @@ var EllipseCurve = new Class({ }, /** - * [description] + * The horizontal radius of the ellipse. * * @name Phaser.Curves.Ellipse#xRadius * @type {number} @@ -475,7 +477,7 @@ var EllipseCurve = new Class({ }, /** - * [description] + * The vertical radius of the ellipse. * * @name Phaser.Curves.Ellipse#yRadius * @type {number} @@ -496,7 +498,7 @@ var EllipseCurve = new Class({ }, /** - * [description] + * The start angle of the ellipse in degrees. * * @name Phaser.Curves.Ellipse#startAngle * @type {number} @@ -517,7 +519,7 @@ var EllipseCurve = new Class({ }, /** - * [description] + * The end angle of the ellipse in degrees. * * @name Phaser.Curves.Ellipse#endAngle * @type {number} @@ -538,7 +540,7 @@ var EllipseCurve = new Class({ }, /** - * [description] + * `true` if the ellipse rotation is clockwise or `false` if anti-clockwise. * * @name Phaser.Curves.Ellipse#clockwise * @type {boolean} @@ -559,7 +561,28 @@ var EllipseCurve = new Class({ }, /** - * [description] + * The rotation of the ellipse, relative to the center, in degrees. + * + * @name Phaser.Curves.Ellipse#angle + * @type {number} + * @since 3.14.0 + */ + angle: { + + get: function () + { + return RadToDeg(this._rotation); + }, + + set: function (value) + { + this._rotation = DegToRad(value); + } + + }, + + /** + * The rotation of the ellipse, relative to the center, in radians. * * @name Phaser.Curves.Ellipse#rotation * @type {number} @@ -574,13 +597,13 @@ var EllipseCurve = new Class({ set: function (value) { - this._rotation = DegToRad(value); + this._rotation = value; } }, /** - * [description] + * JSON serialization of the curve. * * @method Phaser.Curves.Ellipse#toJSON * @since 3.0.0 @@ -605,14 +628,14 @@ var EllipseCurve = new Class({ }); /** - * [description] + * Creates a curve from the provided Ellipse Curve Configuration object. * * @function Phaser.Curves.Ellipse.fromJSON * @since 3.0.0 * * @param {JSONEllipseCurve} data - The JSON object containing this curve data. * - * @return {Phaser.Curves.Ellipse} [description] + * @return {Phaser.Curves.Ellipse} The ellipse curve constructed from the configuration object. */ EllipseCurve.fromJSON = function (data) { diff --git a/src/curves/LineCurve.js b/src/curves/LineCurve.js index 2d8a874b4..c5d53e2de 100644 --- a/src/curves/LineCurve.js +++ b/src/curves/LineCurve.js @@ -16,16 +16,16 @@ var tmpVec2 = new Vector2(); /** * @classdesc - * [description] + * A LineCurve is a "curve" comprising exactly two points (a line segment). * * @class Line * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * - * @param {(Phaser.Math.Vector2|number[])} p0 - [description] - * @param {Phaser.Math.Vector2} [p1] - [description] + * @param {(Phaser.Math.Vector2|number[])} p0 - The first endpoint. + * @param {Phaser.Math.Vector2} [p1] - The second endpoint. */ var LineCurve = new Class({ @@ -45,7 +45,7 @@ var LineCurve = new Class({ } /** - * [description] + * The first endpoint. * * @name Phaser.Curves.Line#p0 * @type {Phaser.Math.Vector2} @@ -54,7 +54,7 @@ var LineCurve = new Class({ this.p0 = p0; /** - * [description] + * The second endpoint. * * @name Phaser.Curves.Line#p1 * @type {Phaser.Math.Vector2} @@ -102,14 +102,14 @@ var LineCurve = new Class({ }, /** - * [description] + * Gets the resolution of the line. * * @method Phaser.Curves.Line#getResolution * @since 3.0.0 * - * @param {number} [divisions=1] - [description] + * @param {number} [divisions=1] - The number of divisions to consider. * - * @return {number} [description] + * @return {number} The resolution. Equal to the number of divisions. */ getResolution: function (divisions) { @@ -148,7 +148,7 @@ var LineCurve = new Class({ // Line curve is linear, so we can overwrite default getPointAt /** - * [description] + * Gets a point at a given position on the line. * * @method Phaser.Curves.Line#getPointAt * @since 3.0.0 @@ -166,14 +166,14 @@ var LineCurve = new Class({ }, /** - * [description] + * Gets the slope of the line as a unit vector. * * @method Phaser.Curves.Line#getTangent * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} The tangent vector. */ getTangent: function () { @@ -208,7 +208,7 @@ var LineCurve = new Class({ }, /** - * [description] + * Gets a JSON representation of the line. * * @method Phaser.Curves.Line#toJSON * @since 3.0.0 @@ -229,14 +229,14 @@ var LineCurve = new Class({ }); /** - * [description] + * Configures this line from a JSON representation. * * @function Phaser.Curves.Line.fromJSON * @since 3.0.0 * * @param {JSONCurve} data - The JSON object containing this curve data. * - * @return {Phaser.Curves.Line} [description] + * @return {Phaser.Curves.Line} A new LineCurve object. */ LineCurve.fromJSON = function (data) { diff --git a/src/curves/QuadraticBezierCurve.js b/src/curves/QuadraticBezierCurve.js index 3028330b7..d33d97211 100644 --- a/src/curves/QuadraticBezierCurve.js +++ b/src/curves/QuadraticBezierCurve.js @@ -15,7 +15,7 @@ var Vector2 = require('../math/Vector2'); * * @class QuadraticBezier * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.2.0 * @@ -137,10 +137,10 @@ var QuadraticBezier = new Class({ * * @generic {Phaser.GameObjects.Graphics} G - [graphics,$return] * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] + * @param {Phaser.GameObjects.Graphics} graphics - `Graphics` object to draw onto. + * @param {integer} [pointsTotal=32] - Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. * - * @return {Phaser.GameObjects.Graphics} [description] + * @return {Phaser.GameObjects.Graphics} `Graphics` object that was drawn to. */ draw: function (graphics, pointsTotal) { @@ -163,7 +163,7 @@ var QuadraticBezier = new Class({ }, /** - * [description] + * Converts the curve into a JSON compatible object. * * @method Phaser.Curves.QuadraticBezier#toJSON * @since 3.2.0 @@ -185,14 +185,14 @@ var QuadraticBezier = new Class({ }); /** - * [description] + * Creates a curve from a JSON object, e. g. created by `toJSON`. * * @function Phaser.Curves.QuadraticBezier.fromJSON * @since 3.2.0 * * @param {JSONCurve} data - The JSON object containing this curve data. * - * @return {Phaser.Curves.QuadraticBezier} [description] + * @return {Phaser.Curves.QuadraticBezier} The created curve instance. */ QuadraticBezier.fromJSON = function (data) { diff --git a/src/curves/SplineCurve.js b/src/curves/SplineCurve.js index 55cf98b64..d7411944a 100644 --- a/src/curves/SplineCurve.js +++ b/src/curves/SplineCurve.js @@ -17,7 +17,7 @@ var Vector2 = require('../math/Vector2'); * * @class Spline * @extends Phaser.Curves.Curve - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * diff --git a/src/curves/path/MoveTo.js b/src/curves/path/MoveTo.js index 50388b23a..635868efb 100644 --- a/src/curves/path/MoveTo.js +++ b/src/curves/path/MoveTo.js @@ -9,15 +9,15 @@ var Vector2 = require('../../math/Vector2'); /** * @classdesc - * [description] + * A MoveTo Curve is a very simple curve consisting of only a single point. Its intended use is to move the ending point in a Path. * * @class MoveTo - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * - * @param {number} [x] - [description] - * @param {number} [y] - [description] + * @param {number} [x] - `x` pixel coordinate. + * @param {number} [y] - `y` pixel coordinate. */ var MoveTo = new Class({ @@ -28,7 +28,7 @@ var MoveTo = new Class({ // Skip length calcs in paths /** - * [description] + * Denotes that this Curve does not influence the bounds, points, and drawing of its parent Path. Must be `false` or some methods in the parent Path will throw errors. * * @name Phaser.Curves.MoveTo#active * @type {boolean} @@ -38,7 +38,7 @@ var MoveTo = new Class({ this.active = false; /** - * [description] + * The lone point which this curve consists of. * * @name Phaser.Curves.MoveTo#p0 * @type {Phaser.Math.Vector2} @@ -68,17 +68,17 @@ var MoveTo = new Class({ }, /** - * [description] + * Retrieves the point at given position in the curve. This will always return this curve's only point. * * @method Phaser.Curves.MoveTo#getPointAt * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {number} u - [description] - * @param {Phaser.Math.Vector2} [out] - [description] + * @param {number} u - The position in the path to retrieve, between 0 and 1. Not used. + * @param {Phaser.Math.Vector2} [out] - An optional vector in which to store the point. * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} The modified `out` vector, or a new `Vector2` if none was provided. */ getPointAt: function (u, out) { @@ -112,12 +112,12 @@ var MoveTo = new Class({ }, /** - * [description] + * Converts this curve into a JSON-serializable object. * * @method Phaser.Curves.MoveTo#toJSON * @since 3.0.0 * - * @return {JSONCurve} [description] + * @return {JSONCurve} A primitive object with the curve's type and only point. */ toJSON: function () { diff --git a/src/curves/path/Path.js b/src/curves/path/Path.js index 6c653a1b8..a97ef3a48 100644 --- a/src/curves/path/Path.js +++ b/src/curves/path/Path.js @@ -21,23 +21,25 @@ var Vector2 = require('../../math/Vector2'); * @typedef {object} JSONPath * * @property {string} type - The of the curve. - * @property {number} x - [description] - * @property {number} y - [description] + * @property {number} x - The X coordinate of the curve's starting point. + * @property {number} y - The Y coordinate of the path's starting point. * @property {boolean} autoClose - The path is auto closed. * @property {JSONCurve[]} curves - The list of the curves */ /** * @classdesc - * [description] + * A Path combines multiple Curves into one continuous compound curve. It does not matter how many Curves are in the Path or what type they are. + * + * A Curve in a Path does not have to start where the previous Curve ends - that is to say, a Path does not have to be an uninterrupted curve. Only the order of the Curves influences the actual points on the Path. * * @class Path - * @memberOf Phaser.Curves + * @memberof Phaser.Curves * @constructor * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] + * @param {number} [x=0] - The X coordinate of the Path's starting point or a {@link JSONPath}. + * @param {number} [y=0] - The Y coordinate of the Path's starting point. */ var Path = new Class({ @@ -49,7 +51,8 @@ var Path = new Class({ if (y === undefined) { y = 0; } /** - * [description] + * The name of this Path. + * Empty by default and never populated by Phaser, this is left for developers to use. * * @name Phaser.Curves.Path#name * @type {string} @@ -59,7 +62,7 @@ var Path = new Class({ this.name = ''; /** - * [description] + * The list of Curves which make up this Path. * * @name Phaser.Curves.Path#curves * @type {Phaser.Curves.Curve[]} @@ -69,7 +72,9 @@ var Path = new Class({ this.curves = []; /** - * [description] + * The cached length of each Curve in the Path. + * + * Used internally by {@link #getCurveLengths}. * * @name Phaser.Curves.Path#cacheLengths * @type {number[]} @@ -89,7 +94,9 @@ var Path = new Class({ this.autoClose = false; /** - * [description] + * The starting point of the Path. + * + * This is not necessarily equivalent to the starting point of the first Curve in the Path. In an empty Path, it's also treated as the ending point. * * @name Phaser.Curves.Path#startPoint * @type {Phaser.Math.Vector2} @@ -98,7 +105,7 @@ var Path = new Class({ this.startPoint = new Vector2(); /** - * [description] + * A temporary vector used to avoid object creation when adding a Curve to the Path. * * @name Phaser.Curves.Path#_tmpVec2A * @type {Phaser.Math.Vector2} @@ -108,7 +115,7 @@ var Path = new Class({ this._tmpVec2A = new Vector2(); /** - * [description] + * A temporary vector used to avoid object creation when adding a Curve to the Path. * * @name Phaser.Curves.Path#_tmpVec2B * @type {Phaser.Math.Vector2} @@ -128,14 +135,16 @@ var Path = new Class({ }, /** - * [description] + * Appends a Curve to the end of the Path. + * + * The Curve does not have to start where the Path ends or, for an empty Path, at its defined starting point. * * @method Phaser.Curves.Path#add * @since 3.0.0 * - * @param {Phaser.Curves.Curve} curve - [description] + * @param {Phaser.Curves.Curve} curve - The Curve to append. * - * @return {Phaser.Curves.Path} [description] + * @return {Phaser.Curves.Path} This Path object. */ add: function (curve) { @@ -145,16 +154,16 @@ var Path = new Class({ }, /** - * [description] + * Creates a circular Ellipse Curve positioned at the end of the Path. * * @method Phaser.Curves.Path#circleTo * @since 3.0.0 * - * @param {number} radius - [description] - * @param {boolean} [clockwise=false] - [description] - * @param {number} [rotation=0] - [description] + * @param {number} radius - The radius of the circle. + * @param {boolean} [clockwise=false] - `true` to create a clockwise circle as opposed to a counter-clockwise circle. + * @param {number} [rotation=0] - The rotation of the circle in degrees. * - * @return {Phaser.Curves.Path} [description] + * @return {Phaser.Curves.Path} This Path object. */ circleTo: function (radius, clockwise, rotation) { @@ -164,12 +173,16 @@ var Path = new Class({ }, /** - * [description] + * Ensures that the Path is closed. + * + * A closed Path starts and ends at the same point. If the Path is not closed, a straight Line Curve will be created from the ending point directly to the starting point. During the check, the actual starting point of the Path, i.e. the starting point of the first Curve, will be used as opposed to the Path's defined {@link startPoint}, which could differ. + * + * Calling this method on an empty Path will result in an error. * * @method Phaser.Curves.Path#closePath * @since 3.0.0 * - * @return {Phaser.Curves.Path} [description] + * @return {Phaser.Curves.Path} This Path object. */ closePath: function () { @@ -199,7 +212,7 @@ var Path = new Class({ * @param {number} [control2X] - The x coordinate of the second control point. Not used if vec2s are provided as the first 3 arguments. * @param {number} [control2Y] - The y coordinate of the second control point. Not used if vec2s are provided as the first 3 arguments. * - * @return {Phaser.Curves.Path} [description] + * @return {Phaser.Curves.Path} This Path object. */ cubicBezierTo: function (x, y, control1X, control1Y, control2X, control2Y) { @@ -228,17 +241,17 @@ var Path = new Class({ // Creates a quadratic bezier curve starting at the previous end point and ending at p2, using p1 as a control point /** - * [description] + * Creates a Quadratic Bezier Curve starting at the ending point of the Path. * * @method Phaser.Curves.Path#quadraticBezierTo * @since 3.2.0 * - * @param {(number|Phaser.Math.Vector2[])} x - [description] - * @param {number} [y] - [description] - * @param {number} [controlX] - [description] - * @param {number} [controlY] - [description] + * @param {(number|Phaser.Math.Vector2[])} x - The X coordinate of the second control point or, if it's a `Vector2`, the first control point. + * @param {number} [y] - The Y coordinate of the second control point or, if `x` is a `Vector2`, the second control point. + * @param {number} [controlX] - If `x` is not a `Vector2`, the X coordinate of the first control point. + * @param {number} [controlY] - If `x` is not a `Vector2`, the Y coordinate of the first control point. * - * @return {Phaser.Curves.Path} [description] + * @return {Phaser.Curves.Path} This Path object. */ quadraticBezierTo: function (x, y, controlX, controlY) { @@ -262,17 +275,17 @@ var Path = new Class({ }, /** - * [description] + * Draws all Curves in the Path to a Graphics Game Object. * * @method Phaser.Curves.Path#draw * @since 3.0.0 * * @generic {Phaser.GameObjects.Graphics} G - [out,$return] * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {integer} [pointsTotal=32] - [description] + * @param {Phaser.GameObjects.Graphics} graphics - The Graphics Game Object to draw to. + * @param {integer} [pointsTotal=32] - The number of points to draw for each Curve. Higher numbers result in a smoother curve but require more processing. * - * @return {Phaser.GameObjects.Graphics} [description] + * @return {Phaser.GameObjects.Graphics} The Graphics object which was drawn to. */ draw: function (graphics, pointsTotal) { @@ -297,14 +310,14 @@ var Path = new Class({ * @method Phaser.Curves.Path#ellipseTo * @since 3.0.0 * - * @param {number} xRadius - [description] - * @param {number} yRadius - [description] - * @param {number} startAngle - [description] - * @param {number} endAngle - [description] - * @param {boolean} clockwise - [description] - * @param {number} rotation - [description] + * @param {number} xRadius - The horizontal radius of the ellipse. + * @param {number} yRadius - The vertical radius of the ellipse. + * @param {number} startAngle - The start angle of the ellipse, in degrees. + * @param {number} endAngle - The end angle of the ellipse, in degrees. + * @param {boolean} clockwise - Whether the ellipse should be rotated clockwise (`true`) or counter-clockwise (`false`). + * @param {number} rotation - The rotation of the ellipse, in degrees. * - * @return {Phaser.Curves.Path} [description] + * @return {Phaser.Curves.Path} This Path object. */ ellipseTo: function (xRadius, yRadius, startAngle, endAngle, clockwise, rotation) { @@ -324,14 +337,16 @@ var Path = new Class({ }, /** - * [description] + * Creates a Path from a Path Configuration object. + * + * The provided object should be a {@link JSONPath}, as returned by {@link #toJSON}. Providing a malformed object may cause errors. * * @method Phaser.Curves.Path#fromJSON * @since 3.0.0 * - * @param {object} data - [description] + * @param {object} data - The JSON object containing the Path data. * - * @return {Phaser.Curves.Path} [description] + * @return {Phaser.Curves.Path} This Path object. */ fromJSON: function (data) { @@ -376,17 +391,17 @@ var Path = new Class({ }, /** - * [description] + * Returns a Rectangle with a position and size matching the bounds of this Path. * * @method Phaser.Curves.Path#getBounds * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} [out] - [description] - * @param {integer} [accuracy=16] - [description] + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the bounds in. + * @param {integer} [accuracy=16] - The accuracy of the bounds calculations. Higher values are more accurate at the cost of calculation speed. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The modified `out` Rectangle, or a new Rectangle if none was provided. */ getBounds: function (out, accuracy) { @@ -425,12 +440,14 @@ var Path = new Class({ }, /** - * [description] + * Returns an array containing the length of the Path at the end of each Curve. + * + * The result of this method will be cached to avoid recalculating it in subsequent calls. The cache is only invalidated when the {@link #curves} array changes in length, leading to potential inaccuracies if a Curve in the Path is changed, or if a Curve is removed and another is added in its place. * * @method Phaser.Curves.Path#getCurveLengths * @since 3.0.0 * - * @return {number[]} [description] + * @return {number[]} An array containing the length of the Path at the end of each one of its Curves. */ getCurveLengths: function () { @@ -460,16 +477,18 @@ var Path = new Class({ }, /** - * [description] + * Returns the ending point of the Path. + * + * A Path's ending point is equivalent to the ending point of the last Curve in the Path. For an empty Path, the ending point is at the Path's defined {@link #startPoint}. * * @method Phaser.Curves.Path#getEndPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {Phaser.Math.Vector2} [out] - [description] + * @param {Phaser.Math.Vector2} [out] - The object to store the point in. * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} The modified `out` object, or a new Vector2 if none was provided. */ getEndPoint: function (out) { @@ -488,12 +507,14 @@ var Path = new Class({ }, /** - * [description] + * Returns the total length of the Path. + * + * @see {@link #getCurveLengths} * * @method Phaser.Curves.Path#getLength * @since 3.0.0 * - * @return {number} [description] + * @return {number} The total length of the Path. */ getLength: function () { @@ -512,17 +533,19 @@ var Path = new Class({ // 4. Return curve.getPointAt(t') /** - * [description] + * Calculates the coordinates of the point at the given normalized location (between 0 and 1) on the Path. + * + * The location is relative to the entire Path, not to an individual Curve. A location of 0.5 is always in the middle of the Path and is thus an equal distance away from both its starting and ending points. In a Path with one Curve, it would be in the middle of the Curve; in a Path with two Curves, it could be anywhere on either one of them depending on their lengths. * * @method Phaser.Curves.Path#getPoint * @since 3.0.0 * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {number} t - [description] - * @param {Phaser.Math.Vector2} [out] - [description] + * @param {number} t - The location of the point to return, between 0 and 1. + * @param {Phaser.Math.Vector2} [out] - The object in which to store the calculated point. * - * @return {?Phaser.Math.Vector2} [description] + * @return {?Phaser.Math.Vector2} The modified `out` object, or a new `Vector2` if none was provided. */ getPoint: function (t, out) { @@ -553,14 +576,16 @@ var Path = new Class({ }, /** - * [description] + * Returns the defined starting point of the Path. + * + * This is not necessarily equal to the starting point of the first Curve if it differs from {@link startPoint}. * * @method Phaser.Curves.Path#getPoints * @since 3.0.0 * - * @param {integer} [divisions=12] - [description] + * @param {integer} [divisions=12] - The number of points to divide the path in to. * - * @return {Phaser.Math.Vector2[]} [description] + * @return {Phaser.Math.Vector2[]} An array of Vector2 objects that containing the points along the Path. */ getPoints: function (divisions) { @@ -614,7 +639,7 @@ var Path = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {Phaser.Math.Vector2} [out] - [description] + * @param {Phaser.Math.Vector2} [out] - `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. * * @return {Phaser.Math.Vector2} [description] */ @@ -626,12 +651,12 @@ var Path = new Class({ }, /** - * [description] + * Creates a straight Line Curve from the ending point of the Path to the given coordinates. * * @method Phaser.Curves.Path#getSpacedPoints * @since 3.0.0 * - * @param {integer} [divisions=40] - [description] + * @param {integer} [divisions=40] - The X coordinate of the line's ending point, or the line's ending point as a `Vector2`. * * @return {Phaser.Math.Vector2[]} [description] */ diff --git a/src/data/DataManager.js b/src/data/DataManager.js index efc10ebaa..59d7927eb 100644 --- a/src/data/DataManager.js +++ b/src/data/DataManager.js @@ -22,7 +22,7 @@ var Class = require('../utils/Class'); * or have a property called `events` that is an instance of it. * * @class DataManager - * @memberOf Phaser.Data + * @memberof Phaser.Data * @constructor * @since 3.0.0 * @@ -84,6 +84,9 @@ var DataManager = new Class({ * ``` * * Doing so will emit a `setdata` event from the parent of this Data Manager. + * + * Do not modify this object directly. Adding properties directly to this object will not + * emit any events. Always use `DataManager.set` to create new items the first time around. * * @name Phaser.Data.DataManager#values * @type {Object.} @@ -306,6 +309,8 @@ var DataManager = new Class({ Object.defineProperty(this.values, key, { enumerable: true, + + configurable: true, get: function () { @@ -316,10 +321,11 @@ var DataManager = new Class({ { if (!_this._frozen) { + var previousValue = list[key]; list[key] = value; - events.emit('changedata', parent, key, value); - events.emit('changedata_' + key, parent, value); + events.emit('changedata', parent, key, value, previousValue); + events.emit('changedata_' + key, parent, value, previousValue); } } diff --git a/src/data/DataManagerPlugin.js b/src/data/DataManagerPlugin.js index 5508f2692..0c261f09e 100644 --- a/src/data/DataManagerPlugin.js +++ b/src/data/DataManagerPlugin.js @@ -16,7 +16,7 @@ var PluginCache = require('../plugins/PluginCache'); * * @class DataManagerPlugin * @extends Phaser.Data.DataManager - * @memberOf Phaser.Data + * @memberof Phaser.Data * @constructor * @since 3.0.0 * diff --git a/src/device/OS.js b/src/device/OS.js index a721c3cef..9cbe11aca 100644 --- a/src/device/OS.js +++ b/src/device/OS.js @@ -71,7 +71,7 @@ function init () { OS.windows = true; } - else if (/Mac OS/.test(ua)) + else if (/Mac OS/.test(ua) && !(/like Mac OS/.test(ua))) { OS.macOS = true; } @@ -86,8 +86,13 @@ function init () else if (/iP[ao]d|iPhone/i.test(ua)) { OS.iOS = true; + (navigator.appVersion).match(/OS (\d+)/); + OS.iOSVersion = parseInt(RegExp.$1, 10); + + OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; + OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; } else if (/Kindle/.test(ua) || (/\bKF[A-Z][A-Z]+/).test(ua) || (/Silk.*Mobile Safari/).test(ua)) { @@ -134,7 +139,7 @@ function init () OS.cordova = true; } - if (process && process.versions && process.versions.node) + if (typeof process !== 'undefined' && process.versions && process.versions.node) { OS.node = true; } @@ -170,9 +175,6 @@ function init () OS.crosswalk = true; } - OS.iPhone = ua.toLowerCase().indexOf('iphone') !== -1; - OS.iPad = ua.toLowerCase().indexOf('ipad') !== -1; - OS.pixelRatio = window['devicePixelRatio'] || 1; return OS; diff --git a/src/display/canvas/CanvasPool.js b/src/display/canvas/CanvasPool.js index 3572717ee..1c4e23856 100644 --- a/src/display/canvas/CanvasPool.js +++ b/src/display/canvas/CanvasPool.js @@ -38,7 +38,7 @@ var CanvasPool = function () * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. * @param {boolean} [selfParent=false] - Use the generated Canvas element as the parent? * - * @return {HTMLCanvasElement} [description] + * @return {HTMLCanvasElement} The canvas element that was created or pulled from the pool */ var create = function (parent, width, height, canvasType, selfParent) { @@ -98,7 +98,7 @@ var CanvasPool = function () * @param {integer} [width=1] - The width of the Canvas. * @param {integer} [height=1] - The height of the Canvas. * - * @return {HTMLCanvasElement} [description] + * @return {HTMLCanvasElement} The created canvas. */ var create2D = function (parent, width, height) { @@ -115,7 +115,7 @@ var CanvasPool = function () * @param {integer} [width=1] - The width of the Canvas. * @param {integer} [height=1] - The height of the Canvas. * - * @return {HTMLCanvasElement} [description] + * @return {HTMLCanvasElement} The created WebGL canvas. */ var createWebGL = function (parent, width, height) { @@ -130,7 +130,7 @@ var CanvasPool = function () * * @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`. * - * @return {HTMLCanvasElement} [description] + * @return {HTMLCanvasElement} The first free canvas, or `null` if a WebGL canvas was requested or if the pool doesn't have free canvases. */ var first = function (canvasType) { @@ -161,7 +161,7 @@ var CanvasPool = function () * @function Phaser.Display.Canvas.CanvasPool.remove * @since 3.0.0 * - * @param {*} parent - [description] + * @param {*} parent - The canvas or the parent of the canvas to free. */ var remove = function (parent) { @@ -185,7 +185,7 @@ var CanvasPool = function () * @function Phaser.Display.Canvas.CanvasPool.total * @since 3.0.0 * - * @return {integer} [description] + * @return {integer} The number of used canvases. */ var total = function () { @@ -208,7 +208,7 @@ var CanvasPool = function () * @function Phaser.Display.Canvas.CanvasPool.free * @since 3.0.0 * - * @return {integer} [description] + * @return {integer} The number of free canvases. */ var free = function () { diff --git a/src/display/canvas/Smoothing.js b/src/display/canvas/Smoothing.js index 4f1cfe10a..f85e21c96 100644 --- a/src/display/canvas/Smoothing.js +++ b/src/display/canvas/Smoothing.js @@ -19,9 +19,9 @@ var Smoothing = function () * @function Phaser.Display.Canvas.Smoothing.getPrefix * @since 3.0.0 * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - The canvas context to check. * - * @return {string} [description] + * @return {string} The name of the property on the context which controls image smoothing (either `imageSmoothingEnabled` or a vendor-prefixed version thereof), or `null` if not supported. */ var getPrefix = function (context) { @@ -50,9 +50,9 @@ var Smoothing = function () * @function Phaser.Display.Canvas.Smoothing.enable * @since 3.0.0 * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - The context on which to enable smoothing. * - * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} The provided context. */ var enable = function (context) { @@ -79,9 +79,9 @@ var Smoothing = function () * @function Phaser.Display.Canvas.Smoothing.disable * @since 3.0.0 * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - The context on which to disable smoothing. * - * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} [description] + * @return {(CanvasRenderingContext2D|WebGLRenderingContext)} The provided context. */ var disable = function (context) { @@ -105,9 +105,9 @@ var Smoothing = function () * @function Phaser.Display.Canvas.Smoothing.isEnabled * @since 3.0.0 * - * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - [description] + * @param {(CanvasRenderingContext2D|WebGLRenderingContext)} context - The context to check. * - * @return {?boolean} [description] + * @return {?boolean} `true` if smoothing is enabled on the context, otherwise `false`. `null` if not supported. */ var isEnabled = function (context) { diff --git a/src/display/canvas/index.js b/src/display/canvas/index.js index 1343deb37..e01a74626 100644 --- a/src/display/canvas/index.js +++ b/src/display/canvas/index.js @@ -10,8 +10,8 @@ module.exports = { - Interpolation: require('./CanvasInterpolation'), - Pool: require('./CanvasPool'), + CanvasInterpolation: require('./CanvasInterpolation'), + CanvasPool: require('./CanvasPool'), Smoothing: require('./Smoothing'), TouchAction: require('./TouchAction'), UserSelect: require('./UserSelect') diff --git a/src/display/color/Color.js b/src/display/color/Color.js index 827c38620..bdb25d499 100644 --- a/src/display/color/Color.js +++ b/src/display/color/Color.js @@ -7,13 +7,15 @@ var Class = require('../../utils/Class'); var GetColor = require('./GetColor'); var GetColor32 = require('./GetColor32'); +var HSVToRGB = require('./HSVToRGB'); +var RGBToHSV = require('./RGBToHSV'); /** * @classdesc * The Color class holds a single color value and allows for easy modification and reading of it. * * @class Color - * @memberOf Phaser.Display + * @memberof Phaser.Display * @constructor * @since 3.0.0 * @@ -77,6 +79,52 @@ var Color = new Class({ */ this.a = 255; + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#_h + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._h = 0; + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#_s + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._s = 0; + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @name Phaser.Display.Color#_v + * @type {number} + * @default 0 + * @private + * @since 3.13.0 + */ + this._v = 0; + + /** + * Is this color update locked? + * + * @name Phaser.Display.Color#_locked + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._locked = false; + /** * An array containing the calculated color values for WebGL use. * @@ -132,12 +180,16 @@ var Color = new Class({ */ transparent: function () { + this._locked = true; + this.red = 0; this.green = 0; this.blue = 0; this.alpha = 0; - return this.update(); + this._locked = false; + + return this.update(true); }, /** @@ -150,19 +202,25 @@ var Color = new Class({ * @param {integer} green - The green color value. A number between 0 and 255. * @param {integer} blue - The blue color value. A number between 0 and 255. * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + * @param {boolean} [updateHSV=true] - Update the HSV values after setting the RGB values? * * @return {Phaser.Display.Color} This Color object. */ - setTo: function (red, green, blue, alpha) + setTo: function (red, green, blue, alpha, updateHSV) { if (alpha === undefined) { alpha = 255; } + if (updateHSV === undefined) { updateHSV = true; } + + this._locked = true; this.red = red; this.green = green; this.blue = blue; this.alpha = alpha; - return this.update(); + this._locked = false; + + return this.update(updateHSV); }, /** @@ -182,12 +240,16 @@ var Color = new Class({ { if (alpha === undefined) { alpha = 1; } + this._locked = true; + this.redGL = red; this.greenGL = green; this.blueGL = blue; this.alphaGL = alpha; - return this.update(); + this._locked = false; + + return this.update(true); }, /** @@ -202,6 +264,8 @@ var Color = new Class({ */ setFromRGB: function (color) { + this._locked = true; + this.red = color.r; this.green = color.g; this.blue = color.b; @@ -211,22 +275,79 @@ var Color = new Class({ this.alpha = color.a; } - return this.update(); + this._locked = false; + + return this.update(true); + }, + + /** + * Sets the color based on the hue, saturation and lightness values given. + * + * @method Phaser.Display.Color#setFromHSV + * @since 3.13.0 + * + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @return {Phaser.Display.Color} This Color object. + */ + setFromHSV: function (h, s, v) + { + return HSVToRGB(h, s, v, this); }, /** * Updates the internal cache values. * * @method Phaser.Display.Color#update + * @private * @since 3.0.0 * * @return {Phaser.Display.Color} This Color object. */ - update: function () + update: function (updateHSV) { - this._color = GetColor(this.r, this.g, this.b); - this._color32 = GetColor32(this.r, this.g, this.b, this.a); - this._rgba = 'rgba(' + this.r + ',' + this.g + ',' + this.b + ',' + (this.a / 255) + ')'; + if (updateHSV === undefined) { updateHSV = false; } + + if (this._locked) + { + return this; + } + + var r = this.r; + var g = this.g; + var b = this.b; + var a = this.a; + + this._color = GetColor(r, g, b); + this._color32 = GetColor32(r, g, b, a); + this._rgba = 'rgba(' + r + ',' + g + ',' + b + ',' + (a / 255) + ')'; + + if (updateHSV) + { + RGBToHSV(r, g, b, this); + } + + return this; + }, + + /** + * Updates the internal hsv cache values. + * + * @method Phaser.Display.Color#updateHSV + * @private + * @since 3.13.0 + * + * @return {Phaser.Display.Color} This Color object. + */ + updateHSV: function () + { + var r = this.r; + var g = this.g; + var b = this.b; + + RGBToHSV(r, g, b, this); return this; }, @@ -244,12 +365,164 @@ var Color = new Class({ return new Color(this.r, this.g, this.b, this.a); }, + /** + * Sets this Color object to be grayscaled based on the shade value given. + * + * @method Phaser.Display.Color#gray + * @since 3.13.0 + * + * @param {integer} shade - A value between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + gray: function (shade) + { + return this.setTo(shade, shade, shade); + }, + + /** + * Sets this Color object to be a random color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#random + * @since 3.13.0 + * + * @param {integer} [min=0] - The minimum random color value. Between 0 and 255. + * @param {integer} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + random: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var r = Math.floor(min + Math.random() * (max - min)); + var g = Math.floor(min + Math.random() * (max - min)); + var b = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(r, g, b); + }, + + /** + * Sets this Color object to be a random grayscale color between the `min` and `max` values given. + * + * @method Phaser.Display.Color#randomGray + * @since 3.13.0 + * + * @param {integer} [min=0] - The minimum random color value. Between 0 and 255. + * @param {integer} [max=255] - The maximum random color value. Between 0 and 255. + * + * @return {Phaser.Display.Color} This Color object. + */ + randomGray: function (min, max) + { + if (min === undefined) { min = 0; } + if (max === undefined) { max = 255; } + + var s = Math.floor(min + Math.random() * (max - min)); + + return this.setTo(s, s, s); + }, + + /** + * Increase the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#saturate + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + saturate: function (amount) + { + this.s += amount / 100; + + return this; + }, + + /** + * Decrease the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * + * @method Phaser.Display.Color#desaturate + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + desaturate: function (amount) + { + this.s -= amount / 100; + + return this; + }, + + /** + * Increase the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#lighten + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + lighten: function (amount) + { + this.v += amount / 100; + + return this; + }, + + /** + * Decrease the lightness of this Color by the percentage amount given. + * + * @method Phaser.Display.Color#darken + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + darken: function (amount) + { + this.v -= amount / 100; + + return this; + }, + + /** + * Brighten this Color by the percentage amount given. + * + * @method Phaser.Display.Color#brighten + * @since 3.13.0 + * + * @param {integer} amount - The percentage amount to change this color by. A value between 0 and 100. + * + * @return {Phaser.Display.Color} This Color object. + */ + brighten: function (amount) + { + var r = this.r; + var g = this.g; + var b = this.b; + + r = Math.max(0, Math.min(255, r - Math.round(255 * - (amount / 100)))); + g = Math.max(0, Math.min(255, g - Math.round(255 * - (amount / 100)))); + b = Math.max(0, Math.min(255, b - Math.round(255 * - (amount / 100)))); + + return this.setTo(r, g, b); + }, + /** * The color of this Color component, not including the alpha channel. * * @name Phaser.Display.Color#color * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ color: { @@ -266,7 +539,7 @@ var Color = new Class({ * * @name Phaser.Display.Color#color32 * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ color32: { @@ -283,7 +556,7 @@ var Color = new Class({ * * @name Phaser.Display.Color#rgba * @type {string} - * @readOnly + * @readonly * @since 3.0.0 */ rgba: { @@ -315,7 +588,7 @@ var Color = new Class({ this.r = Math.floor(this.gl[0] * 255); - this.update(); + this.update(true); } }, @@ -340,7 +613,7 @@ var Color = new Class({ this.g = Math.floor(this.gl[1] * 255); - this.update(); + this.update(true); } }, @@ -365,7 +638,7 @@ var Color = new Class({ this.b = Math.floor(this.gl[2] * 255); - this.update(); + this.update(true); } }, @@ -417,7 +690,7 @@ var Color = new Class({ this.gl[0] = value / 255; - this.update(); + this.update(true); } }, @@ -444,7 +717,7 @@ var Color = new Class({ this.gl[1] = value / 255; - this.update(); + this.update(true); } }, @@ -471,7 +744,7 @@ var Color = new Class({ this.gl[2] = value / 255; - this.update(); + this.update(true); } }, @@ -501,6 +774,78 @@ var Color = new Class({ this.update(); } + }, + + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + * + * @name Phaser.Display.Color#h + * @type {number} + * @since 3.13.0 + */ + h: { + + get: function () + { + return this._h; + }, + + set: function (value) + { + this._h = value; + + HSVToRGB(value, this._s, this._v, this); + } + + }, + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * + * @name Phaser.Display.Color#s + * @type {number} + * @since 3.13.0 + */ + s: { + + get: function () + { + return this._s; + }, + + set: function (value) + { + this._s = value; + + HSVToRGB(this._h, value, this._v, this); + } + + }, + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * + * @name Phaser.Display.Color#v + * @type {number} + * @since 3.13.0 + */ + v: { + + get: function () + { + return this._v; + }, + + set: function (value) + { + this._v = value; + + HSVToRGB(this._h, this._s, value, this); + } + } }); diff --git a/src/display/color/HSVToRGB.js b/src/display/color/HSVToRGB.js index cd5757e7f..84e7c63cb 100644 --- a/src/display/color/HSVToRGB.js +++ b/src/display/color/HSVToRGB.js @@ -15,13 +15,14 @@ var GetColor = require('./GetColor'); * @function Phaser.Display.Color.HSVToRGB * @since 3.0.0 * - * @param {number} h - The hue, in the range 0 - 1. - * @param {number} s - The saturation, in the range 0 - 1. - * @param {number} v - The value, in the range 0 - 1. + * @param {number} h - The hue, in the range 0 - 1. This is the base color. + * @param {number} s - The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param {number} v - The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * @param {(ColorObject|Phaser.Display.Color)} [out] - A Color object to store the results in. If not given a new ColorObject will be created. * - * @return {ColorObject} An object with the red, green and blue values set in the r, g and b properties. + * @return {(ColorObject|Phaser.Display.Color)} An object with the red, green and blue values set in the r, g and b properties. */ -var HSVToRGB = function (h, s, v) +var HSVToRGB = function (h, s, v, out) { if (s === undefined) { s = 1; } if (v === undefined) { v = 1; } @@ -35,44 +36,60 @@ var HSVToRGB = function (h, s, v) v = Math.floor(v *= 255); - var output = { r: v, g: v, b: v, color: 0 }; + var r = v; + var g = v; + var b = v; - var r = i % 6; + var c = i % 6; - if (r === 0) + if (c === 0) { - output.g = t; - output.b = p; + g = t; + b = p; } - else if (r === 1) + else if (c === 1) { - output.r = q; - output.b = p; + r = q; + b = p; } - else if (r === 2) + else if (c === 2) { - output.r = p; - output.b = t; + r = p; + b = t; } - else if (r === 3) + else if (c === 3) { - output.r = p; - output.g = q; + r = p; + g = q; } - else if (r === 4) + else if (c === 4) { - output.r = t; - output.g = p; + r = t; + g = p; } - else if (r === 5) + else if (c === 5) { - output.g = p; - output.b = q; + g = p; + b = q; } - output.color = GetColor(output.r, output.g, output.b); + if (!out) + { + return { r: r, g: g, b: b, color: GetColor(r, g, b) }; + } + else if (out.setTo) + { + return out.setTo(r, g, b, out.alpha, false); + } + else + { + out.r = r; + out.g = g; + out.b = b; + out.color = GetColor(r, g, b); - return output; + return out; + } }; module.exports = HSVToRGB; diff --git a/src/display/color/RGBToHSV.js b/src/display/color/RGBToHSV.js index 2013472c6..d7f0ef5a8 100644 --- a/src/display/color/RGBToHSV.js +++ b/src/display/color/RGBToHSV.js @@ -5,11 +5,11 @@ */ /** - * @typedef {object} HSLColorObject + * @typedef {object} HSVColorObject * * @property {number} h - The hue color value. A number between 0 and 1 * @property {number} s - The saturation color value. A number between 0 and 1 - * @property {number} l - The lightness color value. A number between 0 and 1 + * @property {number} v - The lightness color value. A number between 0 and 1 */ /** @@ -24,11 +24,14 @@ * @param {integer} r - The red color value. A number between 0 and 255. * @param {integer} g - The green color value. A number between 0 and 255. * @param {integer} b - The blue color value. A number between 0 and 255. + * @param {(HSVColorObject|Phaser.Display.Color)} [out] - An object to store the color values in. If not given an HSV Color Object will be created. * - * @return {HSLColorObject} An object with the properties `h`, `s` and `v`. + * @return {(HSVColorObject|Phaser.Display.Color)} An object with the properties `h`, `s` and `v` set. */ -var RGBToHSV = function (r, g, b) +var RGBToHSV = function (r, g, b, out) { + if (out === undefined) { out = { h: 0, s: 0, v: 0 }; } + r /= 255; g /= 255; b /= 255; @@ -60,7 +63,20 @@ var RGBToHSV = function (r, g, b) h /= 6; } - return { h: h, s: s, v: v }; + if (out.hasOwnProperty('_h')) + { + out._h = h; + out._s = s; + out._v = v; + } + else + { + out.h = h; + out.s = s; + out.v = v; + } + + return out; }; module.exports = RGBToHSV; diff --git a/src/display/mask/BitmapMask.js b/src/display/mask/BitmapMask.js index 6e8b88097..c05829fe1 100644 --- a/src/display/mask/BitmapMask.js +++ b/src/display/mask/BitmapMask.js @@ -8,14 +8,22 @@ var Class = require('../../utils/Class'); /** * @classdesc - * [description] + * A Bitmap Mask combines the alpha (opacity) of a masked pixel with the alpha of another pixel. Unlike the Geometry Mask, which is a clipping path, a Bitmask Mask behaves like an alpha mask, not a clipping path. It is only available when using the WebGL Renderer. + * + * A Bitmap Mask can use any Game Object to determine the alpha of each pixel of the masked Game Object(s). For any given point of a masked Game Object's texture, the pixel's alpha will be multiplied by the alpha of the pixel at the same position in the Bitmap Mask's Game Object. The color of the pixel from the Bitmap Mask doesn't matter. + * + * For example, if a pure blue pixel with an alpha of 0.95 is masked with a pure red pixel with an alpha of 0.5, the resulting pixel will be pure blue with an alpha of 0.475. Naturally, this means that a pixel in the mask with an alpha of 0 will hide the corresponding pixel in all masked Game Objects. A pixel with an alpha of 1 in the masked Game Object will receive the same alpha as the corresponding pixel in the mask. + * + * The Bitmap Mask's location matches the location of its Game Object, not the location of the masked objects. Moving or transforming the underlying Game Object will change the mask (and affect the visibility of any masked objects), whereas moving or transforming a masked object will not affect the mask. + * + * The Bitmap Mask will not render its Game Object by itself. If the Game Object is not in a Scene's display list, it will only be used for the mask and its full texture will not be directly visible. Adding the underlying Game Object to a Scene will not cause any problems - it will render as a normal Game Object and will also serve as a mask. * * @class BitmapMask - * @memberOf Phaser.Display.Masks + * @memberof Phaser.Display.Masks * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene which this Bitmap Mask will be used in. * @param {Phaser.GameObjects.GameObject} renderable - A renderable Game Object that uses a texture, such as a Sprite. */ var BitmapMask = new Class({ @@ -26,6 +34,15 @@ var BitmapMask = new Class({ { var renderer = scene.sys.game.renderer; + /** + * A reference to either the Canvas or WebGL Renderer that this Mask is using. + * + * @name Phaser.Display.Masks.BitmapMask#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.11.0 + */ + this.renderer = renderer; + /** * A renderable Game Object that uses a texture, such as a Sprite. * @@ -36,7 +53,7 @@ var BitmapMask = new Class({ this.bitmapMask = renderable; /** - * [description] + * The texture used for the mask's framebuffer. * * @name Phaser.Display.Masks.BitmapMask#maskTexture * @type {WebGLTexture} @@ -46,7 +63,7 @@ var BitmapMask = new Class({ this.maskTexture = null; /** - * [description] + * The texture used for the main framebuffer. * * @name Phaser.Display.Masks.BitmapMask#mainTexture * @type {WebGLTexture} @@ -56,7 +73,7 @@ var BitmapMask = new Class({ this.mainTexture = null; /** - * [description] + * Whether the Bitmap Mask is dirty and needs to be updated. * * @name Phaser.Display.Masks.BitmapMask#dirty * @type {boolean} @@ -66,7 +83,7 @@ var BitmapMask = new Class({ this.dirty = true; /** - * [description] + * The framebuffer to which a masked Game Object is rendered. * * @name Phaser.Display.Masks.BitmapMask#mainFramebuffer * @type {WebGLFramebuffer} @@ -75,7 +92,7 @@ var BitmapMask = new Class({ this.mainFramebuffer = null; /** - * [description] + * The framebuffer to which the Bitmap Mask's masking Game Object is rendered. * * @name Phaser.Display.Masks.BitmapMask#maskFramebuffer * @type {WebGLFramebuffer} @@ -84,7 +101,9 @@ var BitmapMask = new Class({ this.maskFramebuffer = null; /** - * [description] + * Whether to invert the mask's alpha. + * + * If `true`, the alpha of the masking pixel will be inverted before it's multiplied with the masked pixel. Essentially, this means that a masked area will be visible only if the corresponding area in the mask is invisible. * * @name Phaser.Display.Masks.BitmapMask#invertAlpha * @type {boolean} @@ -125,7 +144,7 @@ var BitmapMask = new Class({ }, /** - * [description] + * Sets a new masking Game Object for the Bitmap Mask. * * @method Phaser.Display.Masks.BitmapMask#setBitmap * @since 3.0.0 @@ -138,13 +157,15 @@ var BitmapMask = new Class({ }, /** - * [description] + * Prepares the WebGL Renderer to render a Game Object with this mask applied. + * + * This renders the masking Game Object to the mask framebuffer and switches to the main framebuffer so that the masked Game Object will be rendered to it instead of being rendered directly to the frame. * * @method Phaser.Display.Masks.BitmapMask#preRenderWebGL * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} maskedObject - [description] + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The WebGL Renderer to prepare. + * @param {Phaser.GameObjects.GameObject} maskedObject - The masked Game Object which will be drawn. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. */ preRenderWebGL: function (renderer, maskedObject, camera) @@ -153,12 +174,14 @@ var BitmapMask = new Class({ }, /** - * [description] + * Finalizes rendering of a masked Game Object. + * + * This resets the previously bound framebuffer and switches the WebGL Renderer to the Bitmap Mask Pipeline, which uses a special fragment shader to apply the masking effect. * * @method Phaser.Display.Masks.BitmapMask#postRenderWebGL * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The WebGL Renderer to clean up. */ postRenderWebGL: function (renderer) { @@ -166,13 +189,13 @@ var BitmapMask = new Class({ }, /** - * [description] + * This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer. * * @method Phaser.Display.Masks.BitmapMask#preRenderCanvas * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Canvas Renderer which would be rendered to. + * @param {Phaser.GameObjects.GameObject} mask - The masked Game Object which would be rendered. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to render to. */ preRenderCanvas: function () @@ -181,12 +204,12 @@ var BitmapMask = new Class({ }, /** - * [description] + * This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer. * * @method Phaser.Display.Masks.BitmapMask#postRenderCanvas * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Canvas Renderer which would be rendered to. */ postRenderCanvas: function () { @@ -205,10 +228,22 @@ var BitmapMask = new Class({ destroy: function () { this.bitmapMask = null; + + var renderer = this.renderer; + + if (renderer && renderer.gl) + { + renderer.deleteTexture(this.mainTexture); + renderer.deleteTexture(this.maskTexture); + renderer.deleteFramebuffer(this.mainFramebuffer); + renderer.deleteFramebuffer(this.maskFramebuffer); + } + this.mainTexture = null; this.maskTexture = null; this.mainFramebuffer = null; this.maskFramebuffer = null; + this.renderer = null; } }); diff --git a/src/display/mask/GeometryMask.js b/src/display/mask/GeometryMask.js index f3d249062..017643949 100644 --- a/src/display/mask/GeometryMask.js +++ b/src/display/mask/GeometryMask.js @@ -8,15 +8,19 @@ var Class = require('../../utils/Class'); /** * @classdesc - * [description] + * A Geometry Mask can be applied to a Game Object to hide any pixels of it which don't intersect a visible pixel from the geometry mask. The mask is essentially a clipping path which can only make a masked pixel fully visible or fully invisible without changing its alpha (opacity). + * + * A Geometry Mask uses a Graphics Game Object to determine which pixels of the masked Game Object(s) should be clipped. For any given point of a masked Game Object's texture, the pixel will only be displayed if the Graphics Game Object of the Geometry Mask has a visible pixel at the same position. The color and alpha of the pixel from the Geometry Mask do not matter. + * + * The Geometry Mask's location matches the location of its Graphics object, not the location of the masked objects. Moving or transforming the underlying Graphics object will change the mask (and affect the visibility of any masked objects), whereas moving or transforming a masked object will not affect the mask. You can think of the Geometry Mask (or rather, of the its Graphics object) as an invisible curtain placed in front of all masked objects which has its own visual properties and, naturally, respects the camera's visual properties, but isn't affected by and doesn't follow the masked objects by itself. * * @class GeometryMask - * @memberOf Phaser.Display.Masks + * @memberof Phaser.Display.Masks * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + * @param {Phaser.Scene} scene - This parameter is not used. + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics Game Object to use for the Geometry Mask. Doesn't have to be in the Display List. */ var GeometryMask = new Class({ @@ -25,7 +29,7 @@ var GeometryMask = new Class({ function GeometryMask (scene, graphicsGeometry) { /** - * [description] + * The Graphics object which describes the Geometry Mask. * * @name Phaser.Display.Masks.GeometryMask#geometryMask * @type {Phaser.GameObjects.Graphics} @@ -35,12 +39,12 @@ var GeometryMask = new Class({ }, /** - * [description] + * Sets a new Graphics object for the Geometry Mask. * * @method Phaser.Display.Masks.GeometryMask#setShape * @since 3.0.0 * - * @param {Phaser.GameObjects.Graphics} graphicsGeometry - [description] + * @param {Phaser.GameObjects.Graphics} graphicsGeometry - The Graphics object which will be used for the Geometry Mask. */ setShape: function (graphicsGeometry) { @@ -48,14 +52,14 @@ var GeometryMask = new Class({ }, /** - * [description] + * Renders the Geometry Mask's underlying Graphics object to the OpenGL stencil buffer and enables the stencil test, which clips rendered pixels according to the mask. * * @method Phaser.Display.Masks.GeometryMask#preRenderWebGL * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to draw to. + * @param {Phaser.GameObjects.GameObject} mask - The Game Object being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the Game Object is being rendered through. */ preRenderWebGL: function (renderer, mask, camera) { @@ -79,16 +83,16 @@ var GeometryMask = new Class({ // Use stencil buffer to affect next rendering object gl.colorMask(true, true, true, true); gl.stencilFunc(gl.EQUAL, 1, 1); - gl.stencilOp(gl.INVERT, gl.INVERT, gl.INVERT); + gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); }, /** - * [description] + * Flushes all rendered pixels and disables the stencil test of a WebGL context, thus disabling the mask for it. * * @method Phaser.Display.Masks.GeometryMask#postRenderWebGL * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer instance to draw flush. */ postRenderWebGL: function (renderer) { @@ -96,18 +100,19 @@ var GeometryMask = new Class({ // Force flush before disabling stencil test renderer.flush(); + gl.disable(gl.STENCIL_TEST); }, /** - * [description] + * Sets the clipping path of a 2D canvas context to the Geometry Mask's underlying Graphics object. * * @method Phaser.Display.Masks.GeometryMask#preRenderCanvas * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] - * @param {Phaser.GameObjects.GameObject} mask - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance to set the clipping path on. + * @param {Phaser.GameObjects.GameObject} mask - The Game Object being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the Game Object is being rendered through. */ preRenderCanvas: function (renderer, mask, camera) { @@ -115,18 +120,18 @@ var GeometryMask = new Class({ renderer.currentContext.save(); - geometryMask.renderCanvas(renderer, geometryMask, 0.0, camera, undefined, null, true); + geometryMask.renderCanvas(renderer, geometryMask, 0, camera, null, null, true); renderer.currentContext.clip(); }, /** - * [description] + * Restore the canvas context's previous clipping path, thus turning off the mask for it. * * @method Phaser.Display.Masks.GeometryMask#postRenderCanvas * @since 3.0.0 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - The Canvas Renderer instance being restored. */ postRenderCanvas: function (renderer) { diff --git a/src/dom/AddToDOM.js b/src/dom/AddToDOM.js index 15ba358c0..934887b14 100644 --- a/src/dom/AddToDOM.js +++ b/src/dom/AddToDOM.js @@ -6,7 +6,7 @@ /** * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. - * If no parent was given or falls back to using `document.body`. + * If no parent was given it falls back to using `document.body`. * * @function Phaser.DOM.AddToDOM * @since 3.0.0 @@ -32,7 +32,7 @@ var AddToDOM = function (element, parent, overflowHidden) } else if (typeof parent === 'object' && parent.nodeType === 1) { - // Quick test for a HTMLelement + // Quick test for a HTMLElement target = parent; } } @@ -41,7 +41,7 @@ var AddToDOM = function (element, parent, overflowHidden) return element; } - // Fallback, covers an invalid ID and a non HTMLelement object + // Fallback, covers an invalid ID and a non HTMLElement object if (!target) { target = document.body; diff --git a/src/dom/Calibrate.js b/src/dom/Calibrate.js new file mode 100644 index 000000000..bc3395262 --- /dev/null +++ b/src/dom/Calibrate.js @@ -0,0 +1,26 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Calibrate = function (coords, cushion) +{ + if (cushion === undefined) { cushion = 0; } + + var output = { + width: 0, + height: 0, + left: 0, + right: 0, + top: 0, + bottom: 0 + }; + + output.width = (output.right = coords.right + cushion) - (output.left = coords.left - cushion); + output.height = (output.bottom = coords.bottom + cushion) - (output.top = coords.top - cushion); + + return output; +}; + +module.exports = Calibrate; diff --git a/src/dom/ClientHeight.js b/src/dom/ClientHeight.js new file mode 100644 index 000000000..614bc6337 --- /dev/null +++ b/src/dom/ClientHeight.js @@ -0,0 +1,12 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ClientHeight = function () +{ + return Math.max(window.innerHeight, document.documentElement.clientHeight); +}; + +module.exports = ClientHeight; diff --git a/src/dom/ClientWidth.js b/src/dom/ClientWidth.js new file mode 100644 index 000000000..a3d94709d --- /dev/null +++ b/src/dom/ClientWidth.js @@ -0,0 +1,12 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ClientWidth = function () +{ + return Math.max(window.innerWidth, document.documentElement.clientWidth); +}; + +module.exports = ClientWidth; diff --git a/src/dom/DocumentBounds.js b/src/dom/DocumentBounds.js new file mode 100644 index 000000000..89a2680a8 --- /dev/null +++ b/src/dom/DocumentBounds.js @@ -0,0 +1,41 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../utils/Class'); +var Rectangle = require('../geom/rectangle/Rectangle'); + +var DocumentBounds = new Class({ + + Extends: Rectangle, + + initialize: + + function DocumentBounds () + { + Rectangle.call(this); + }, + + width: { + get: function () + { + var d = document.documentElement; + + return Math.max(d.clientWidth, d.offsetWidth, d.scrollWidth); + } + }, + + height: { + get: function () + { + var d = document.documentElement; + + return Math.max(d.clientHeight, d.offsetHeight, d.scrollHeight); + } + } + +}); + +module.exports = new DocumentBounds(); diff --git a/src/dom/GetAspectRatio.js b/src/dom/GetAspectRatio.js new file mode 100644 index 000000000..347076009 --- /dev/null +++ b/src/dom/GetAspectRatio.js @@ -0,0 +1,30 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBounds = require('./GetBounds'); +var VisualBounds = require('./VisualBounds'); + +var GetAspectRatio = function (object) +{ + object = (object === null) ? VisualBounds : (object.nodeType === 1) ? GetBounds(object) : object; + + var w = object.width; + var h = object.height; + + if (typeof w === 'function') + { + w = w.call(object); + } + + if (typeof h === 'function') + { + h = h.call(object); + } + + return w / h; +}; + +module.exports = GetAspectRatio; diff --git a/src/dom/GetBounds.js b/src/dom/GetBounds.js new file mode 100644 index 000000000..697ab4004 --- /dev/null +++ b/src/dom/GetBounds.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Calibrate = require('./Calibrate'); + +var GetBounds = function (element, cushion) +{ + if (cushion === undefined) { cushion = 0; } + + element = (element && !element.nodeType) ? element[0] : element; + + if (!element || element.nodeType !== 1) + { + return false; + } + else + { + return Calibrate(element.getBoundingClientRect(), cushion); + } +}; + +module.exports = GetBounds; diff --git a/src/dom/GetOffset.js b/src/dom/GetOffset.js new file mode 100644 index 000000000..9e21f4ce9 --- /dev/null +++ b/src/dom/GetOffset.js @@ -0,0 +1,28 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Vec2 = require('../math/Vector2'); +var VisualBounds = require('./VisualBounds'); + +var GetOffset = function (element, point) +{ + if (point === undefined) { point = new Vec2(); } + + var box = element.getBoundingClientRect(); + + var scrollTop = VisualBounds.y; + var scrollLeft = VisualBounds.x; + + var clientTop = document.documentElement.clientTop; + var clientLeft = document.documentElement.clientLeft; + + point.x = box.left + scrollLeft - clientLeft; + point.y = box.top + scrollTop - clientTop; + + return point; +}; + +module.exports = GetOffset; diff --git a/src/dom/GetScreenOrientation.js b/src/dom/GetScreenOrientation.js new file mode 100644 index 000000000..e1961a89b --- /dev/null +++ b/src/dom/GetScreenOrientation.js @@ -0,0 +1,56 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var VisualBounds = require('./VisualBounds'); + +var GetScreenOrientation = function (primaryFallback) +{ + var screen = window.screen; + var orientation = screen.orientation || screen.mozOrientation || screen.msOrientation; + + if (orientation && typeof orientation.type === 'string') + { + // Screen Orientation API specification + return orientation.type; + } + else if (typeof orientation === 'string') + { + // moz / ms-orientation are strings + return orientation; + } + + var PORTRAIT = 'portrait-primary'; + var LANDSCAPE = 'landscape-primary'; + + if (primaryFallback === 'screen') + { + return (screen.height > screen.width) ? PORTRAIT : LANDSCAPE; + } + else if (primaryFallback === 'viewport') + { + return (VisualBounds.height > VisualBounds.width) ? PORTRAIT : LANDSCAPE; + } + else if (primaryFallback === 'window.orientation' && typeof window.orientation === 'number') + { + // This may change by device based on "natural" orientation. + return (window.orientation === 0 || window.orientation === 180) ? PORTRAIT : LANDSCAPE; + } + else if (window.matchMedia) + { + if (window.matchMedia('(orientation: portrait)').matches) + { + return PORTRAIT; + } + else if (window.matchMedia('(orientation: landscape)').matches) + { + return LANDSCAPE; + } + } + + return (VisualBounds.height > VisualBounds.width) ? PORTRAIT : LANDSCAPE; +}; + +module.exports = GetScreenOrientation; diff --git a/src/dom/InLayoutViewport.js b/src/dom/InLayoutViewport.js new file mode 100644 index 000000000..6b7de36b5 --- /dev/null +++ b/src/dom/InLayoutViewport.js @@ -0,0 +1,17 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GetBounds = require('./GetBounds'); +var LayoutBounds = require('./LayoutBounds'); + +var InLayoutViewport = function (element, cushion) +{ + var r = GetBounds(element, cushion); + + return !!r && r.bottom >= 0 && r.right >= 0 && r.top <= LayoutBounds.width && r.left <= LayoutBounds.height; +}; + +module.exports = InLayoutViewport; diff --git a/src/dom/LayoutBounds.js b/src/dom/LayoutBounds.js new file mode 100644 index 000000000..ef710b57f --- /dev/null +++ b/src/dom/LayoutBounds.js @@ -0,0 +1,56 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../utils/Class'); +var ClientHeight = require('./ClientHeight'); +var ClientWidth = require('./ClientWidth'); +var Rectangle = require('../geom/rectangle/Rectangle'); + +var LayoutBounds = new Class({ + + Extends: Rectangle, + + initialize: + + function LayoutBounds () + { + Rectangle.call(this); + }, + + init: function (isDesktop) + { + if (isDesktop) + { + Object.defineProperty(this, 'width', { get: ClientWidth }); + Object.defineProperty(this, 'height', { get: ClientHeight }); + } + else + { + Object.defineProperty(this, 'width', { + get: function () + { + var a = document.documentElement.clientWidth; + var b = window.innerWidth; + + return a < b ? b : a; // max + } + }); + + Object.defineProperty(this, 'height', { + get: function () + { + var a = document.documentElement.clientHeight; + var b = window.innerHeight; + + return a < b ? b : a; // max + } + }); + } + } + +}); + +module.exports = new LayoutBounds(); diff --git a/src/dom/RequestAnimationFrame.js b/src/dom/RequestAnimationFrame.js index ae480881f..e101a0e8c 100644 --- a/src/dom/RequestAnimationFrame.js +++ b/src/dom/RequestAnimationFrame.js @@ -13,7 +13,7 @@ var NOOP = require('../utils/NOOP'); * This is invoked automatically by the Phaser.Game instance. * * @class RequestAnimationFrame - * @memberOf Phaser.DOM + * @memberof Phaser.DOM * @constructor * @since 3.0.0 */ @@ -92,9 +92,12 @@ var RequestAnimationFrame = new Class({ * @type {FrameRequestCallback} * @since 3.0.0 */ - this.step = function step (timestamp) + this.step = function step () { - // DOMHighResTimeStamp + // Because we cannot trust the time passed to this callback from the browser and need it kept in sync with event times + var timestamp = window.performance.now(); + + // DOMHighResTimeStamp _this.lastTime = _this.tick; _this.tick = timestamp; diff --git a/src/dom/ScaleManager.js b/src/dom/ScaleManager.js new file mode 100644 index 000000000..e73061802 --- /dev/null +++ b/src/dom/ScaleManager.js @@ -0,0 +1,387 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../utils/Class'); +var CONST = require('./const'); +var NOOP = require('../utils/NOOP'); +var Rectangle = require('../geom/rectangle/Rectangle'); +var Size = require('../structs/Size'); +var SnapFloor = require('../math/snap/SnapFloor'); +var Vec2 = require('../math/Vector2'); + +/** + * @classdesc + * TODO + * + * @class ScaleManager + * @memberof Phaser.DOM + * @constructor + * @since 3.15.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance. + * @param {any} config + */ +var ScaleManager = new Class({ + + initialize: + + function ScaleManager (game) + { + /** + * A reference to the Phaser.Game instance. + * + * @name Phaser.DOM.ScaleManager#game + * @type {Phaser.Game} + * @readonly + * @since 3.15.0 + */ + this.game = game; + + this.scaleMode = 0; + + // The base game size, as requested in the game config + this.gameSize = new Size(); + + // The canvas size, which is the base game size * zoom * resolution + this.canvasSize = new Size(); + + // this.width = 0; + // this.height = 0; + + // this.canvasWidth = 0; + // this.canvasHeight = 0; + + this.resolution = 1; + this.zoom = 1; + + // The actual displayed canvas size (after refactoring in CSS depending on the scale mode, parent, etc) + this.displaySize = new Size(); + + // this.displayWidth = 0; + // this.displayHeight = 0; + + // The scale factor between the base game size and the displayed size + this.scale = new Vec2(1); + + this.parent; + this.parentIsWindow; + this.parentScale = new Vec2(1); + this.parentBounds = new Rectangle(); + + this.minSize = new Vec2(); + this.maxSize = new Vec2(); + + this.trackParent = false; + this.canExpandParent = false; + + this.allowFullScreen = false; + + this.snap = new Vec2(1, 1); + + this.listeners = { + + orientationChange: NOOP, + windowResize: NOOP, + fullScreenChange: NOOP, + fullScreenError: NOOP + + }; + + }, + + preBoot: function () + { + // Parse the config to get the scaling values we need + // console.log('preBoot'); + + this.setParent(this.game.config.parent); + + this.parseConfig(this.game.config); + + this.game.events.once('boot', this.boot, this); + }, + + boot: function () + { + // console.log('boot'); + + this.setScaleMode(this.scaleMode); + + this.game.events.on('prestep', this.step, this); + }, + + parseConfig: function (config) + { + var width = config.width; + var height = config.height; + var resolution = config.resolution; + var scaleMode = config.scaleMode; + var zoom = config.zoom; + + if (typeof width === 'string') + { + this.parentScale.x = parseInt(width, 10) / 100; + width = this.parentBounds.width * this.parentScale.x; + } + + if (typeof height === 'string') + { + this.parentScale.y = parseInt(height, 10) / 100; + height = this.parentBounds.height * this.parentScale.y; + } + + this.width = width; + this.height = height; + + this.canvasWidth = (width * zoom) * resolution; + this.canvasHeight = (height * zoom) * resolution; + + this.resolution = resolution; + + this.zoom = zoom; + + this.canExpandParent = config.expandParent; + + this.scaleMode = scaleMode; + + // console.log(config); + + this.minSize.set(config.minWidth, config.minHeight); + this.maxSize.set(config.maxWidth, config.maxHeight); + }, + + setScaleMode: function (scaleMode) + { + this.scaleMode = scaleMode; + + if (scaleMode === CONST.EXACT) + { + return; + } + + var canvas = this.game.canvas; + var gameStyle = canvas.style; + + var parent = this.parent; + var parentStyle = parent.style; + + + switch (scaleMode) + { + case CONST.FILL: + + gameStyle.objectFit = 'fill'; + gameStyle.width = '100%'; + gameStyle.height = '100%'; + + if (this.canExpandParent) + { + parentStyle.height = '100%'; + + if (this.parentIsWindow) + { + document.getElementsByTagName('html')[0].style.height = '100%'; + } + } + + break; + + case CONST.CONTAIN: + + gameStyle.objectFit = 'contain'; + gameStyle.width = '100%'; + gameStyle.height = '100%'; + + if (this.canExpandParent) + { + parentStyle.height = '100%'; + + if (this.parentIsWindow) + { + document.getElementsByTagName('html')[0].style.height = '100%'; + } + } + + break; + } + + var min = this.minSize; + var max = this.maxSize; + + if (min.x > 0) + { + gameStyle.minWidth = min.x.toString() + 'px'; + } + + if (min.y > 0) + { + gameStyle.minHeight = min.y.toString() + 'px'; + } + + if (max.x > 0) + { + gameStyle.maxWidth = max.x.toString() + 'px'; + } + + if (max.y > 0) + { + gameStyle.maxHeight = max.y.toString() + 'px'; + } + }, + + setParent: function (parent) + { + var target; + + if (parent !== '') + { + if (typeof parent === 'string') + { + // Hopefully an element ID + target = document.getElementById(parent); + } + else if (parent && parent.nodeType === 1) + { + // Quick test for a HTMLElement + target = parent; + } + } + + // Fallback to the document body. Covers an invalid ID and a non HTMLElement object. + if (!target) + { + // Use the full window + this.parent = document.body; + this.parentIsWindow = true; + } + else + { + this.parent = target; + this.parentIsWindow = false; + } + + this.getParentBounds(); + }, + + getParentBounds: function () + { + var DOMRect = this.parent.getBoundingClientRect(); + + this.parentBounds.setSize(DOMRect.width, DOMRect.height); + }, + + startListeners: function () + { + var _this = this; + var listeners = this.listeners; + + listeners.orientationChange = function (event) + { + return _this.onOrientationChange(event); + }; + + listeners.windowResize = function (event) + { + return _this.onWindowResize(event); + }; + + window.addEventListener('orientationchange', listeners.orientationChange, false); + window.addEventListener('resize', listeners.windowResize, false); + + if (this.allowFullScreen) + { + listeners.fullScreenChange = function (event) + { + return _this.onFullScreenChange(event); + }; + + listeners.fullScreenError = function (event) + { + return _this.onFullScreenError(event); + }; + + var vendors = [ 'webkit', 'moz', '' ]; + + vendors.forEach(function (prefix) + { + document.addEventListener(prefix + 'fullscreenchange', listeners.fullScreenChange, false); + document.addEventListener(prefix + 'fullscreenerror', listeners.fullScreenError, false); + }); + + // MS Specific + document.addEventListener('MSFullscreenChange', listeners.fullScreenChange, false); + document.addEventListener('MSFullscreenError', listeners.fullScreenError, false); + } + }, + + getInnerHeight: function () + { + // Based on code by @tylerjpeterson + + if (!this.game.device.os.iOS) + { + return window.innerHeight; + } + + var axis = Math.abs(window.orientation); + + var size = { w: 0, h: 0 }; + + var ruler = document.createElement('div'); + + ruler.setAttribute('style', 'position: fixed; height: 100vh; width: 0; top: 0'); + + document.documentElement.appendChild(ruler); + + size.w = (axis === 90) ? ruler.offsetHeight : window.innerWidth; + size.h = (axis === 90) ? window.innerWidth : ruler.offsetHeight; + + document.documentElement.removeChild(ruler); + + ruler = null; + + if (Math.abs(window.orientation) !== 90) + { + return size.h; + } + else + { + return size.w; + } + }, + + step: function () + { + // canvas.clientWidth and clientHeight = canvas size when scaled with 100% object-fit, ignoring borders, margin, etc + }, + + stopListeners: function () + { + var listeners = this.listeners; + + window.removeEventListener('orientationchange', listeners.orientationChange, false); + window.removeEventListener('resize', listeners.windowResize, false); + + var vendors = [ 'webkit', 'moz', '' ]; + + vendors.forEach(function (prefix) + { + document.removeEventListener(prefix + 'fullscreenchange', listeners.fullScreenChange, false); + document.removeEventListener(prefix + 'fullscreenerror', listeners.fullScreenError, false); + }); + + // MS Specific + document.removeEventListener('MSFullscreenChange', listeners.fullScreenChange, false); + document.removeEventListener('MSFullscreenError', listeners.fullScreenError, false); + }, + + destroy: function () + { + } + +}); + +module.exports = ScaleManager; diff --git a/src/dom/VisualBounds.js b/src/dom/VisualBounds.js new file mode 100644 index 000000000..52971998f --- /dev/null +++ b/src/dom/VisualBounds.js @@ -0,0 +1,62 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../utils/Class'); +var ClientHeight = require('./ClientHeight'); +var ClientWidth = require('./ClientWidth'); +var Rectangle = require('../geom/rectangle/Rectangle'); + +// All target browsers should support page[XY]Offset. +var ScrollX = (window && ('pageXOffset' in window)) ? function () { return window.pageXOffset; } : function () { return document.documentElement.scrollLeft; }; +var ScrollY = (window && ('pageYOffset' in window)) ? function () { return window.pageYOffset; } : function () { return document.documentElement.scrollTop; }; + +var VisualBounds = new Class({ + + Extends: Rectangle, + + initialize: + + function VisualBounds () + { + Rectangle.call(this); + }, + + x: { + get: ScrollX + }, + + y: { + get: ScrollY + }, + + init: function (isDesktop) + { + if (isDesktop) + { + Object.defineProperty(this, 'width', { get: ClientWidth }); + Object.defineProperty(this, 'height', { get: ClientHeight }); + } + else + { + Object.defineProperty(this, 'width', { + get: function () + { + return window.innerWidth; + } + }); + + Object.defineProperty(this, 'height', { + get: function () + { + return window.innerHeight; + } + }); + } + } + +}); + +module.exports = new VisualBounds(); diff --git a/src/dom/_ScaleManager.js b/src/dom/_ScaleManager.js new file mode 100644 index 000000000..4148c381e --- /dev/null +++ b/src/dom/_ScaleManager.js @@ -0,0 +1,1447 @@ +/** + * @author Richard Davey + * @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 CONST = require('./const'); +var GetOffset = require('./GetOffset'); +var GetScreenOrientation = require('./GetScreenOrientation'); +var LayoutBounds = require('./LayoutBounds'); +var Rectangle = require('../geom/rectangle/Rectangle'); +var SameDimensions = require('../geom/rectangle/SameDimensions'); +var Vec2 = require('../math/Vector2'); +var VisualBounds = require('./VisualBounds'); + +/** + * @classdesc + * TODO + * + * @class ScaleManager + * @memberof Phaser.DOM + * @constructor + * @since 3.15.0 + * + * @param {Phaser.Game} game - A reference to the Phaser.Game instance. + * @param {any} config + */ +var ScaleManager = new Class({ + + initialize: + + function ScaleManager (game, config) + { + /** + * A reference to the Phaser.Game instance. + * + * @name Phaser.DOM.ScaleManager#game + * @type {Phaser.Game} + * @readonly + * @since 3.15.0 + */ + this.game = game; + + this.config = config; + + this.width = 0; + + this.height = 0; + + this.minWidth = null; + + this.maxWidth = null; + + this.minHeight = null; + + this.maxHeight = null; + + this.offset = new Vec2(); + + this.forceLandscape = false; + + this.forcePortrait = false; + + this.incorrectOrientation = false; + + this._pageAlignHorizontally = false; + + this._pageAlignVertically = false; + + this.hasPhaserSetFullScreen = false; + + this.fullScreenTarget = null; + + this._createdFullScreenTarget = null; + + this.screenOrientation; + + this.scaleFactor = new Vec2(1, 1); + + this.scaleFactorInversed = new Vec2(1, 1); + + this.margin = { left: 0, top: 0, right: 0, bottom: 0, x: 0, y: 0 }; + + this.bounds = new Rectangle(); + + this.aspectRatio = 0; + + this.sourceAspectRatio = 0; + + this.event = null; + + this.windowConstraints = { + right: 'layout', + bottom: '' + }; + + this.compatibility = { + supportsFullScreen: false, + orientationFallback: null, + noMargins: false, + scrollTo: null, + canExpandParent: true, + clickTrampoline: '' + }; + + this._scaleMode = Phaser.ScaleManager.NO_SCALE; + + this._fullScreenScaleMode = Phaser.ScaleManager.NO_SCALE; + + this.parentIsWindow = false; + + this.parentNode = null; + + this.parentScaleFactor = new Vec2(1, 1); + + this.trackParentInterval = 2000; + + this.onResize = null; + + this.onResizeContext = null; + + this._pendingScaleMode = game.config.scaleMode; + + this._fullScreenRestore = null; + + this._gameSize = new Rectangle(); + + this._userScaleFactor = new Vec2(1, 1); + + this._userScaleTrim = new Vec2(0, 0); + + this._lastUpdate = 0; + + this._updateThrottle = 0; + + this._updateThrottleReset = 1000; + + this._parentBounds = new Rectangle(); + + this._tempBounds = new Rectangle(); + + this._lastReportedCanvasSize = new Rectangle(); + + this._lastReportedGameSize = new Rectangle(); + + this._booted = false; + }, + + preBoot: function () + { + console.log('%c preBoot ', 'background: #000; color: #ffff00'); + + // Configure device-dependent compatibility + + var game = this.game; + var device = game.device; + var os = game.device.os; + var compat = this.compatibility; + + compat.supportsFullScreen = device.fullscreen.available && !os.cocoonJS; + + // We can't do anything about the status bars in iPads, web apps or desktops + if (!os.iPad && !os.webApp && !os.desktop) + { + if (os.android && !device.browser.chrome) + { + compat.scrollTo = new Vec2(0, 1); + } + else + { + compat.scrollTo = new Vec2(0, 0); + } + } + + if (os.desktop) + { + compat.orientationFallback = 'screen'; + compat.clickTrampoline = 'when-not-mouse'; + } + else + { + compat.orientationFallback = ''; + compat.clickTrampoline = ''; + } + + // Configure event listeners + + var _this = this; + + this._orientationChange = function (event) + { + return _this.orientationChange(event); + }; + + this._windowResize = function (event) + { + return _this.windowResize(event); + }; + + window.addEventListener('orientationchange', this._orientationChange, false); + window.addEventListener('resize', this._windowResize, false); + + if (compat.supportsFullScreen) + { + this._fullScreenChange = function (event) + { + return _this.fullScreenChange(event); + }; + + this._fullScreenError = function (event) + { + return _this.fullScreenError(event); + }; + + var vendors = [ 'webkit', 'moz', '' ]; + + vendors.forEach(function (prefix) + { + document.addEventListener(prefix + 'fullscreenchange', this._fullScreenChange, false); + document.addEventListener(prefix + 'fullscreenerror', this._fullScreenError, false); + }); + + // MS Specific + document.addEventListener('MSFullscreenChange', this._fullScreenChange, false); + document.addEventListener('MSFullscreenError', this._fullScreenError, false); + } + + // Set-up the Bounds + var isDesktop = os.desktop && (document.documentElement.clientWidth <= window.innerWidth) && (document.documentElement.clientHeight <= window.innerHeight); + + console.log('isDesktop', isDesktop, os.desktop); + + VisualBounds.init(isDesktop); + LayoutBounds.init(isDesktop); + + this.setupScale(game.config.width, game.config.height); + + // Same as calling setGameSize: + this._gameSize.setTo(0, 0, game.config.width, game.config.height); + + game.events.once('boot', this.boot, this); + }, + + // Called once added to the DOM, not before + boot: function () + { + console.log('%c boot ', 'background: #000; color: #ffff00', this.width, this.height); + + var game = this.game; + var compat = this.compatibility; + + // Initialize core bounds + + GetOffset(game.canvas, this.offset); + + this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height); + + // Don't use updateOrientationState so events are not fired + this.screenOrientation = GetScreenOrientation(compat.orientationFallback); + + this._booted = true; + + if (this._pendingScaleMode !== null) + { + this.scaleMode = this._pendingScaleMode; + + this._pendingScaleMode = null; + } + + this.updateLayout(); + + this.signalSizeChange(); + + // Make sure to sync the parent bounds to the current local rect, or we'll expand forever + this.getParentBounds(this._parentBounds); + + game.events.on('resume', this.gameResumed, this); + game.events.on('prestep', this.step, this); + }, + + setupScale: function (width, height) + { + console.log('%c setupScale ', 'background: #000; color: #ffff00', width, height); + + var target; + var rect = new Rectangle(); + + var parent = this.config.parent; + + if (parent !== '') + { + if (typeof parent === 'string') + { + // Hopefully an element ID + target = document.getElementById(parent); + } + else if (parent && parent.nodeType === 1) + { + // Quick test for a HTMLElement + target = parent; + } + } + + // Fallback, covers an invalid ID and a non HTMLElement object + if (!target) + { + // Use the full window + this.parentNode = null; + this.parentIsWindow = true; + + rect.width = VisualBounds.width; + rect.height = VisualBounds.height; + + console.log('parentIsWindow', VisualBounds.width, VisualBounds.height); + + this.offset.set(0, 0); + } + else + { + this.parentNode = target; + this.parentIsWindow = false; + + this.getParentBounds(this._parentBounds, this.parentNode); + + rect.width = this._parentBounds.width; + rect.height = this._parentBounds.height; + + this.offset.set(this._parentBounds.x, this._parentBounds.y); + } + + var newWidth = 0; + var newHeight = 0; + + if (typeof width === 'number') + { + newWidth = width; + } + else + { + // Percentage based + this.parentScaleFactor.x = parseInt(width, 10) / 100; + + newWidth = rect.width * this.parentScaleFactor.x; + } + + if (typeof height === 'number') + { + newHeight = height; + } + else + { + // Percentage based + this.parentScaleFactor.y = parseInt(height, 10) / 100; + + newHeight = rect.height * this.parentScaleFactor.y; + } + + newWidth = Math.floor(newWidth); + newHeight = Math.floor(newHeight); + + this._gameSize.setTo(0, 0, newWidth, newHeight); + + this.updateDimensions(newWidth, newHeight, false); + + console.log('pn', this.parentNode); + console.log('pw', this.parentIsWindow); + console.log('pb', this._parentBounds); + console.log('new size', newWidth, newHeight); + }, + + setGameSize: function (width, height) + { + console.log('%c setGameSize ', 'background: #000; color: #ffff00', width, height); + + this._gameSize.setTo(0, 0, width, height); + + if (this.currentScaleMode !== CONST.RESIZE) + { + this.updateDimensions(width, height, true); + } + + this.queueUpdate(true); + }, + + setUserScale: function (hScale, vScale, hTrim, vTrim, queueUpdate, force) + { + if (hTrim === undefined) { hTrim = 0; } + if (vTrim === undefined) { vTrim = 0; } + if (queueUpdate === undefined) { queueUpdate = true; } + if (force === undefined) { force = true; } + + this._userScaleFactor.setTo(hScale, vScale); + this._userScaleTrim.setTo(hTrim, vTrim); + + if (queueUpdate) + { + this.queueUpdate(force); + } + }, + + gameResumed: function () + { + this.queueUpdate(true); + }, + + setResizeCallback: function (callback, context) + { + this.onResize = callback; + this.onResizeContext = context; + }, + + signalSizeChange: function () + { + if (!SameDimensions(this, this._lastReportedCanvasSize) || !SameDimensions(this.game, this._lastReportedGameSize)) + { + var width = this.width; + var height = this.height; + + this._lastReportedCanvasSize.setTo(0, 0, width, height); + this._lastReportedGameSize.setTo(0, 0, this.game.config.width, this.game.config.height); + + // this.onSizeChange.dispatch(this, width, height); + + // Per StateManager#onResizeCallback, it only occurs when in RESIZE mode. + if (this.currentScaleMode === CONST.RESIZE) + { + this.game.resize(width, height); + } + } + }, + + setMinMax: function (minWidth, minHeight, maxWidth, maxHeight) + { + this.minWidth = minWidth; + this.minHeight = minHeight; + + if (maxWidth) + { + this.maxWidth = maxWidth; + } + + if (maxHeight) + { + this.maxHeight = maxHeight; + } + }, + + step: function (time) + { + if (time < (this._lastUpdate + this._updateThrottle)) + { + return; + } + + var prevThrottle = this._updateThrottle; + + this._updateThrottleReset = (prevThrottle >= 400) ? 0 : 100; + + GetOffset(this.game.canvas, this.offset); + + var prevWidth = this._parentBounds.width; + var prevHeight = this._parentBounds.height; + + var bounds = this.getParentBounds(this._parentBounds); + + var boundsChanged = (bounds.width !== prevWidth || bounds.height !== prevHeight); + + // Always invalidate on a newly detected orientation change + var orientationChanged = this.updateOrientationState(); + + if (boundsChanged || orientationChanged) + { + console.log('%c bc ', 'background: #000; color: #ffff00', boundsChanged, bounds.width, prevWidth, bounds.height, prevHeight); + + if (this.onResize) + { + this.onResize.call(this.onResizeContext, this, bounds); + } + + this.updateLayout(); + + this.signalSizeChange(); + + // Make sure to sync the parent bounds to the current local rect, or we'll expand forever + this.getParentBounds(this._parentBounds); + + console.log('%c new bounds ', 'background: #000; color: #ffff00', this._parentBounds.width, this._parentBounds.height); + } + + // Next throttle, eg. 25, 50, 100, 200... + var throttle = this._updateThrottle * 2; + + // Don't let an update be too eager about resetting the throttle. + if (this._updateThrottle < prevThrottle) + { + throttle = Math.min(prevThrottle, this._updateThrottleReset); + } + + this._updateThrottle = Clamp(throttle, 25, this.trackParentInterval); + + this._lastUpdate = time; + }, + + updateDimensions: function (width, height, resize) + { + this.width = width * this.parentScaleFactor.x; + this.height = height * this.parentScaleFactor.y; + + this.config.width = this.width; + this.config.height = this.height; + + this.sourceAspectRatio = this.width / this.height; + + this.updateScalingAndBounds(); + + if (resize) + { + this.game.resize(this.width, this.height); + } + }, + + updateScalingAndBounds: function () + { + var game = this.game; + var config = this.config; + + this.scaleFactor.x = config.width / this.width; + this.scaleFactor.y = config.height / this.height; + + this.scaleFactorInversed.x = this.width / config.width; + this.scaleFactorInversed.y = this.height / config.height; + + this.aspectRatio = this.width / this.height; + + // This can be invoked in boot pre-canvas + if (game.canvas) + { + GetOffset(game.canvas, this.offset); + } + + this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height); + + // Can be invoked in boot pre-input + if (game.input && game.input.scale) + { + // game.input.scale.setTo(this.scaleFactor.x, this.scaleFactor.y); + } + }, + + forceLandscape: function () + { + this.forceLandscape = true; + this.forcePortrait = false; + + this.queueUpdate(true); + }, + + forcePortrait: function () + { + this.forceLandscape = false; + this.forcePortrait = true; + + this.queueUpdate(true); + + }, + + classifyOrientation: function (orientation) + { + if (orientation === 'portrait-primary' || orientation === 'portrait-secondary') + { + return 'portrait'; + } + else if (orientation === 'landscape-primary' || orientation === 'landscape-secondary') + { + return 'landscape'; + } + else + { + return null; + } + }, + + updateOrientationState: function () + { + var previousOrientation = this.screenOrientation; + var previouslyIncorrect = this.incorrectOrientation; + + this.screenOrientation = GetScreenOrientation(this.compatibility.orientationFallback); + + this.incorrectOrientation = (this.forceLandscape && !this.isLandscape) || (this.forcePortrait && !this.isPortrait); + + var changed = (previousOrientation !== this.screenOrientation); + var correctnessChanged = (previouslyIncorrect !== this.incorrectOrientation); + + if (correctnessChanged) + { + if (this.incorrectOrientation) + { + // this.enterIncorrectOrientation.dispatch(); + } + else + { + // this.leaveIncorrectOrientation.dispatch(); + } + } + + if (changed || correctnessChanged) + { + // this.onOrientationChange.dispatch(this, previousOrientation, previouslyIncorrect); + } + + return (changed || correctnessChanged); + }, + + orientationChange: function (event) + { + this.event = event; + + this.queueUpdate(true); + }, + + windowResize: function (event) + { + this.event = event; + + this.queueUpdate(true); + }, + + scrollTop: function () + { + var scrollTo = this.compatibility.scrollTo; + + if (scrollTo) + { + window.scrollTo(scrollTo.x, scrollTo.y); + } + }, + + refresh: function () + { + this.scrollTop(); + + this.queueUpdate(true); + }, + + updateLayout: function () + { + var scaleMode = this.currentScaleMode; + + if (scaleMode === CONST.RESIZE) + { + this.reflowGame(); + return; + } + + this.scrollTop(); + + if (this.incorrectOrientation) + { + this.setMaximum(); + } + else if (scaleMode === CONST.EXACT_FIT) + { + this.setExactFit(); + } + else if (scaleMode === CONST.SHOW_ALL) + { + if (!this.isFullScreen && this.boundingParent && this.compatibility.canExpandParent) + { + // Try to expand parent out, but choosing maximizing dimensions. + // Then select minimize dimensions which should then honor parent maximum bound applications. + this.setShowAll(true); + this.resetCanvas(); + this.setShowAll(); + } + else + { + this.setShowAll(); + } + } + else if (scaleMode === CONST.NO_SCALE) + { + this.width = this.config.width; + this.height = this.config.height; + } + else if (scaleMode === CONST.USER_SCALE) + { + this.width = (this.config.width * this._userScaleFactor.x) - this._userScaleTrim.x; + this.height = (this.config.height * this._userScaleFactor.y) - this._userScaleTrim.y; + } + + if (!this.compatibility.canExpandParent && (scaleMode === CONST.SHOW_ALL || scaleMode === CONST.USER_SCALE)) + { + var bounds = this.getParentBounds(this._tempBounds); + + this.width = Math.min(this.width, bounds.width); + this.height = Math.min(this.height, bounds.height); + } + + // Always truncate / force to integer + this.width = this.width | 0; + this.height = this.height | 0; + + this.reflowCanvas(); + }, + + getParentBounds: function (bounds, parentNode) + { + // console.log('%c getParentBounds ', 'background: #000; color: #ff00ff'); + + if (bounds === undefined) { bounds = new Rectangle(); } + if (parentNode === undefined) { parentNode = this.boundingParent; } + + var visualBounds = VisualBounds; + var layoutBounds = LayoutBounds; + + if (!parentNode) + { + bounds.setTo(0, 0, visualBounds.width, visualBounds.height); + // console.log('b1', bounds); + } + else + { + // Ref. http://msdn.microsoft.com/en-us/library/hh781509(v=vs.85).aspx for getBoundingClientRect + var clientRect = parentNode.getBoundingClientRect(); + var parentRect = (parentNode.offsetParent) ? parentNode.offsetParent.getBoundingClientRect() : parentNode.getBoundingClientRect(); + + bounds.setTo(clientRect.left - parentRect.left, clientRect.top - parentRect.top, clientRect.width, clientRect.height); + + var wc = this.windowConstraints; + var windowBounds; + + if (wc.right) + { + windowBounds = (wc.right === 'layout') ? layoutBounds : visualBounds; + bounds.right = Math.min(bounds.right, windowBounds.width); + } + + if (wc.bottom) + { + windowBounds = (wc.bottom === 'layout') ? layoutBounds : visualBounds; + bounds.bottom = Math.min(bounds.bottom, windowBounds.height); + } + } + + bounds.setTo(Math.round(bounds.x), Math.round(bounds.y), Math.round(bounds.width), Math.round(bounds.height)); + + // console.log(parentNode.offsetParent); + // console.log(clientRect); + // console.log(parentRect); + // console.log(clientRect.left - parentRect.left, clientRect.top - parentRect.top, clientRect.width, clientRect.height); + // console.log('gpb', bounds); + + return bounds; + }, + + align: function (horizontal, vertical) + { + if (horizontal !== null) + { + this.pageAlignHorizontally = horizontal; + } + + if (vertical !== null) + { + this.pageAlignVertically = vertical; + } + }, + + alignCanvas: function (horizontal, vertical) + { + var parentBounds = this.getParentBounds(this._tempBounds); + var canvas = this.game.canvas; + var margin = this.margin; + + var canvasBounds; + var currentEdge; + var targetEdge; + var offset; + + if (horizontal) + { + margin.left = margin.right = 0; + + canvasBounds = canvas.getBoundingClientRect(); + + if (this.width < parentBounds.width && !this.incorrectOrientation) + { + currentEdge = canvasBounds.left - parentBounds.x; + targetEdge = (parentBounds.width / 2) - (this.width / 2); + + targetEdge = Math.max(targetEdge, 0); + + offset = targetEdge - currentEdge; + + margin.left = Math.round(offset); + } + + canvas.style.marginLeft = margin.left + 'px'; + + if (margin.left !== 0) + { + margin.right = -(parentBounds.width - canvasBounds.width - margin.left); + canvas.style.marginRight = margin.right + 'px'; + } + } + + if (vertical) + { + margin.top = margin.bottom = 0; + + canvasBounds = canvas.getBoundingClientRect(); + + if (this.height < parentBounds.height && !this.incorrectOrientation) + { + currentEdge = canvasBounds.top - parentBounds.y; + targetEdge = (parentBounds.height / 2) - (this.height / 2); + + targetEdge = Math.max(targetEdge, 0); + + offset = targetEdge - currentEdge; + + margin.top = Math.round(offset); + } + + canvas.style.marginTop = margin.top + 'px'; + + if (margin.top !== 0) + { + margin.bottom = -(parentBounds.height - canvasBounds.height - margin.top); + canvas.style.marginBottom = margin.bottom + 'px'; + } + } + + // margin.x = margin.left; + // margin.y = margin.top; + }, + + reflowGame: function () + { + this.resetCanvas('', ''); + + var bounds = this.getParentBounds(this._tempBounds); + + this.updateDimensions(bounds.width, bounds.height, true); + }, + + reflowCanvas: function () + { + if (!this.incorrectOrientation) + { + this.width = Clamp(this.width, this.minWidth || 0, this.maxWidth || this.width); + this.height = Clamp(this.height, this.minHeight || 0, this.maxHeight || this.height); + } + + this.resetCanvas(); + + if (!this.compatibility.noMargins) + { + if (this.isFullScreen && this._createdFullScreenTarget) + { + this.alignCanvas(true, true); + } + else + { + this.alignCanvas(this.pageAlignHorizontally, this.pageAlignVertically); + } + } + + this.updateScalingAndBounds(); + }, + + resetCanvas: function (cssWidth, cssHeight) + { + if (cssWidth === undefined) { cssWidth = this.width + 'px'; } + if (cssHeight === undefined) { cssHeight = this.height + 'px'; } + + var canvas = this.game.canvas; + + if (!this.compatibility.noMargins) + { + canvas.style.marginLeft = ''; + canvas.style.marginTop = ''; + canvas.style.marginRight = ''; + canvas.style.marginBottom = ''; + } + + canvas.style.width = cssWidth; + canvas.style.height = cssHeight; + }, + + queueUpdate: function (force) + { + if (force) + { + this._parentBounds.width = 0; + this._parentBounds.height = 0; + this._lastUpdate = 0; + } + + this._updateThrottle = this._updateThrottleReset; + }, + + setMaximum: function () + { + this.width = VisualBounds.width; + this.height = VisualBounds.height; + }, + + setShowAll: function (expanding) + { + var bounds = this.getParentBounds(this._tempBounds); + + var width = bounds.width; + var height = bounds.height; + + var multiplier; + + if (expanding) + { + multiplier = Math.max((height / this.game.height), (width / this.game.width)); + } + else + { + multiplier = Math.min((height / this.game.height), (width / this.game.width)); + } + + this.width = Math.round(this.game.width * multiplier); + this.height = Math.round(this.game.height * multiplier); + }, + + setExactFit: function () + { + var bounds = this.getParentBounds(this._tempBounds); + + this.width = bounds.width; + this.height = bounds.height; + + if (this.isFullScreen) + { + // Max/min not honored fullscreen + return; + } + + if (this.maxWidth) + { + this.width = Math.min(this.width, this.maxWidth); + } + + if (this.maxHeight) + { + this.height = Math.min(this.height, this.maxHeight); + } + }, + + createFullScreenTarget: function () + { + var fsTarget = document.createElement('div'); + + fsTarget.style.margin = '0'; + fsTarget.style.padding = '0'; + fsTarget.style.background = '#000'; + + return fsTarget; + }, + + startFullScreen: function (antialias, allowTrampoline) + { + if (this.isFullScreen) + { + return false; + } + + if (!this.compatibility.supportsFullScreen) + { + // Error is called in timeout to emulate the real fullscreenerror event better + var _this = this; + + setTimeout(function () + { + _this.fullScreenError(); + }, 10); + + return; + } + + if (this.compatibility.clickTrampoline === 'when-not-mouse') + { + var input = this.game.input; + + /* + if (input.activePointer && + input.activePointer !== input.mousePointer && + (allowTrampoline || allowTrampoline !== false)) + { + input.activePointer.addClickTrampoline('startFullScreen', this.startFullScreen, this, [ antialias, false ]); + return; + } + */ + } + + /* + if (antialias !== undefined && this.game.renderType === CONST.CANVAS) + { + this.game.stage.smoothed = antialias; + } + */ + + var fsTarget = this.fullScreenTarget; + + if (!fsTarget) + { + this.cleanupCreatedTarget(); + + this._createdFullScreenTarget = this.createFullScreenTarget(); + + fsTarget = this._createdFullScreenTarget; + } + + var initData = { targetElement: fsTarget }; + + this.hasPhaserSetFullScreen = true; + + // this.onFullScreenInit.dispatch(this, initData); + + if (this._createdFullScreenTarget) + { + // Move the Display canvas inside of the target and add the target to the DOM + // (the target has to be added for the Fullscreen API to work) + var canvas = this.game.canvas; + var parent = canvas.parentNode; + + parent.insertBefore(fsTarget, canvas); + + fsTarget.appendChild(canvas); + } + + if (this.game.device.fullscreen.keyboard) + { + fsTarget[this.game.device.fullscreen.request](Element.ALLOW_KEYBOARD_INPUT); + } + else + { + fsTarget[this.game.device.fullscreen.request](); + } + + return true; + }, + + stopFullScreen: function () + { + if (!this.isFullScreen || !this.compatibility.supportsFullScreen) + { + return false; + } + + this.hasPhaserSetFullScreen = false; + + document[this.game.device.fullscreen.cancel](); + + return true; + }, + + cleanupCreatedTarget: function () + { + var fsTarget = this._createdFullScreenTarget; + + if (fsTarget && fsTarget.parentNode) + { + // Make sure to cleanup synthetic target for sure; + // swap the canvas back to the parent. + var parent = fsTarget.parentNode; + + parent.insertBefore(this.game.canvas, fsTarget); + + parent.removeChild(fsTarget); + } + + this._createdFullScreenTarget = null; + }, + + prepScreenMode: function (enteringFullscreen) + { + var createdTarget = !!this._createdFullScreenTarget; + var fsTarget = this._createdFullScreenTarget || this.fullScreenTarget; + + if (enteringFullscreen) + { + if (createdTarget || this.fullScreenScaleMode === Phaser.ScaleManager.EXACT_FIT) + { + // Resize target, as long as it's not the canvas + if (fsTarget !== this.game.canvas) + { + this._fullScreenRestore = { + targetWidth: fsTarget.style.width, + targetHeight: fsTarget.style.height + }; + + fsTarget.style.width = '100%'; + fsTarget.style.height = '100%'; + } + } + } + else + { + // Have restore information + if (this._fullScreenRestore) + { + fsTarget.style.width = this._fullScreenRestore.targetWidth; + fsTarget.style.height = this._fullScreenRestore.targetHeight; + + this._fullScreenRestore = null; + } + + // Always reset to game size + this.updateDimensions(this._gameSize.width, this._gameSize.height, true); + + this.resetCanvas(); + } + }, + + fullScreenChange: function (event) + { + this.event = event; + + if (this.isFullScreen) + { + this.prepScreenMode(true); + + this.updateLayout(); + this.queueUpdate(true); + } + else + { + this.prepScreenMode(false); + + this.cleanupCreatedTarget(); + + this.updateLayout(); + this.queueUpdate(true); + } + + // this.onFullScreenChange.dispatch(this, this.width, this.height); + }, + + fullScreenError: function (event) + { + this.event = event; + + this.cleanupCreatedTarget(); + + console.warn('ScaleManager: requestFullscreen call or browser failed'); + + // this.onFullScreenError.dispatch(this); + }, + + /* + centerDisplay: function () + { + var height = this.height; + var gameWidth = 0; + var gameHeight = 0; + + this.parentNode.style.display = 'flex'; + this.parentNode.style.height = height + 'px'; + + this.canvas.style.margin = 'auto'; + this.canvas.style.width = gameWidth + 'px'; + this.canvas.style.height = gameHeight + 'px'; + }, + */ + + /* + iOS10 Resize hack. Thanks, Apple. + + I._onWindowResize = function(a) { + if (this._lastReportedWidth != document.body.offsetWidth) { + this._lastReportedWidth = document.body.offsetWidth; + if (this._isAutoPlaying && this._cancelAutoPlayOnInteraction) { + this.stopAutoPlay(a) + } + window.clearTimeout(this._onResizeDebouncedTimeout); + this._onResizeDebouncedTimeout = setTimeout(this._onResizeDebounced, 500); + aj._onWindowResize.call(this, a) + } + }; + */ + + /* + resize: function () + { + let scale = Math.min(window.innerWidth / canvas.width, window.innerHeight / canvas.height); + let orientation = 'left'; + let extra = (this.mobile) ? 'margin-left: -50%': ''; + let margin = window.innerWidth / 2 - (canvas.width / 2) * scale; + + canvas.setAttribute('style', '-ms-transform-origin: ' + orientation + ' top; -webkit-transform-origin: ' + orientation + ' top;' + + ' -moz-transform-origin: ' + orientation + ' top; -o-transform-origin: ' + orientation + ' top; transform-origin: ' + orientation + ' top;' + + ' -ms-transform: scale(' + scale + '); -webkit-transform: scale3d(' + scale + ', 1);' + + ' -moz-transform: scale(' + scale + '); -o-transform: scale(' + scale + '); transform: scale(' + scale + ');' + + ' display: block; margin-left: ' + margin + 'px;' + ); + }, + */ + + getInnerHeight: function () + { + // Based on code by @tylerjpeterson + + if (!this.game.device.os.iOS) + { + return window.innerHeight; + } + + var axis = Math.abs(window.orientation); + + var size = { w: 0, h: 0 }; + + var ruler = document.createElement('div'); + + ruler.setAttribute('style', 'position: fixed; height: 100vh; width: 0; top: 0'); + + document.documentElement.appendChild(ruler); + + size.w = (axis === 90) ? ruler.offsetHeight : window.innerWidth; + size.h = (axis === 90) ? window.innerWidth : ruler.offsetHeight; + + document.documentElement.removeChild(ruler); + + ruler = null; + + if (Math.abs(window.orientation) !== 90) + { + return size.h; + } + else + { + return size.w; + } + }, + + /** + * Destroys the ScaleManager. + * + * @method Phaser.DOM.ScaleManager#destroy + * @since 3.15.0 + */ + destroy: function () + { + this.game.events.off('resume', this.gameResumed, this); + + window.removeEventListener('orientationchange', this._orientationChange, false); + window.removeEventListener('resize', this._windowResize, false); + + if (this.compatibility.supportsFullScreen) + { + var vendors = [ 'webkit', 'moz', '' ]; + + vendors.forEach(function (prefix) + { + document.removeEventListener(prefix + 'fullscreenchange', this._fullScreenChange, false); + document.removeEventListener(prefix + 'fullscreenerror', this._fullScreenError, false); + }); + + // MS Specific + document.removeEventListener('MSFullscreenChange', this._fullScreenChange, false); + document.removeEventListener('MSFullscreenError', this._fullScreenError, false); + } + + this.game = null; + }, + + boundingParent: { + + get: function () + { + if (this.parentIsWindow || (this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget)) + { + return null; + } + + var parentNode = this.game.canvas && this.game.canvas.parentNode; + + return parentNode || null; + } + }, + + scaleMode: { + + get: function () + { + return this._scaleMode; + }, + + set: function (value) + { + if (value !== this._scaleMode) + { + if (!this.isFullScreen) + { + this.updateDimensions(this._gameSize.width, this._gameSize.height, true); + this.queueUpdate(true); + } + + this._scaleMode = value; + } + + return this._scaleMode; + } + + }, + + fullScreenScaleMode: { + + get: function () + { + return this._fullScreenScaleMode; + }, + + set: function (value) + { + if (value !== this._fullScreenScaleMode) + { + // If in fullscreen then need a wee bit more work + if (this.isFullScreen) + { + this.prepScreenMode(false); + + this._fullScreenScaleMode = value; + + this.prepScreenMode(true); + + this.queueUpdate(true); + } + else + { + this._fullScreenScaleMode = value; + } + } + + return this._fullScreenScaleMode; + } + + }, + + currentScaleMode: { + + get: function () + { + return (this.isFullScreen) ? this._fullScreenScaleMode : this._scaleMode; + } + + }, + + pageAlignHorizontally: { + + get: function () + { + return this._pageAlignHorizontally; + }, + + set: function (value) + { + + if (value !== this._pageAlignHorizontally) + { + this._pageAlignHorizontally = value; + + this.queueUpdate(true); + } + + } + + }, + + pageAlignVertically: { + + get: function () + { + return this._pageAlignVertically; + }, + + set: function (value) + { + if (value !== this._pageAlignVertically) + { + this._pageAlignVertically = value; + this.queueUpdate(true); + } + + } + + }, + + isFullScreen: { + + get: function () + { + return !!(document.fullscreenElement || + document.webkitFullscreenElement || + document.mozFullScreenElement || + document.msFullscreenElement); + } + + }, + + isPortrait: { + + get: function () + { + return (this.classifyOrientation(this.screenOrientation) === 'portrait'); + } + + }, + + isLandscape: { + + get: function () + { + return (this.classifyOrientation(this.screenOrientation) === 'landscape'); + } + + }, + + isGamePortrait: { + + get: function () + { + return (this.height > this.width); + } + + }, + + isGameLandscape: { + + get: function () + { + return (this.width > this.height); + } + + } + +}); + +module.exports = ScaleManager; diff --git a/src/dom/const.js b/src/dom/const.js new file mode 100644 index 000000000..591849fe0 --- /dev/null +++ b/src/dom/const.js @@ -0,0 +1,51 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser ScaleManager Modes. + * + * @name Phaser.DOM.ScaleModes + * @enum {integer} + * @memberof Phaser + * @readonly + * @since 3.15.0 + */ + +module.exports = { + + /** + * + * + * @name Phaser.DOM.EXACT + * @since 3.15.0 + */ + EXACT: 0, + + /** + * + * + * @name Phaser.DOM.FILL + * @since 3.15.0 + */ + FILL: 1, + + /** + * + * + * @name Phaser.DOM.CONTAIN + * @since 3.15.0 + */ + CONTAIN: 2, + + /** + * + * + * @name Phaser.DOM.RESIZE + * @since 3.15.0 + */ + RESIZE: 3 + +}; diff --git a/src/dom/index.js b/src/dom/index.js index c1ca3ce2d..0a685cfef 100644 --- a/src/dom/index.js +++ b/src/dom/index.js @@ -4,16 +4,36 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Extend = require('../utils/object/Extend'); +var ScaleModes = require('./const'); + /** * @namespace Phaser.DOM */ -module.exports = { +var Dom = { AddToDOM: require('./AddToDOM'), + Calibrate: require('./Calibrate'), + ClientHeight: require('./ClientHeight'), + ClientWidth: require('./ClientWidth'), + DocumentBounds: require('./DocumentBounds'), DOMContentLoaded: require('./DOMContentLoaded'), + GetAspectRatio: require('./GetAspectRatio'), + GetBounds: require('./GetBounds'), + GetOffset: require('./GetOffset'), + GetScreenOrientation: require('./GetScreenOrientation'), + InLayoutViewport: require('./InLayoutViewport'), ParseXML: require('./ParseXML'), RemoveFromDOM: require('./RemoveFromDOM'), - RequestAnimationFrame: require('./RequestAnimationFrame') + RequestAnimationFrame: require('./RequestAnimationFrame'), + ScaleManager: require('./ScaleManager'), + VisualBounds: require('./VisualBounds'), + + ScaleModes: ScaleModes }; + +Dom = Extend(false, Dom, ScaleModes); + +module.exports = Dom; diff --git a/src/events/EventEmitter.js b/src/events/EventEmitter.js index 165a73ce5..1150c7c57 100644 --- a/src/events/EventEmitter.js +++ b/src/events/EventEmitter.js @@ -13,7 +13,7 @@ var PluginCache = require('../plugins/PluginCache'); * EventEmitter is a Scene Systems plugin compatible version of eventemitter3. * * @class EventEmitter - * @memberOf Phaser.Events + * @memberof Phaser.Events * @constructor * @since 3.0.0 */ @@ -141,9 +141,9 @@ var EventEmitter = new Class({ * @since 3.0.0 * * @param {(string|symbol)} event - The event name. - * @param {function} fn - Only remove the listeners that match this function. - * @param {*} context - Only remove the listeners that have this context. - * @param {boolean} once - Only remove one-time listeners. + * @param {function} [fn] - Only remove the listeners that match this function. + * @param {*} [context] - Only remove the listeners that have this context. + * @param {boolean} [once] - Only remove one-time listeners. * * @return {Phaser.Events.EventEmitter} `this`. */ @@ -155,9 +155,9 @@ var EventEmitter = new Class({ * @since 3.0.0 * * @param {(string|symbol)} event - The event name. - * @param {function} fn - Only remove the listeners that match this function. - * @param {*} context - Only remove the listeners that have this context. - * @param {boolean} once - Only remove one-time listeners. + * @param {function} [fn] - Only remove the listeners that match this function. + * @param {*} [context] - Only remove the listeners that have this context. + * @param {boolean} [once] - Only remove one-time listeners. * * @return {Phaser.Events.EventEmitter} `this`. */ diff --git a/src/gameobjects/DisplayList.js b/src/gameobjects/DisplayList.js index f6fa9204a..cd748104f 100644 --- a/src/gameobjects/DisplayList.js +++ b/src/gameobjects/DisplayList.js @@ -19,7 +19,7 @@ var StableSort = require('../utils/array/StableSort'); * * @class DisplayList * @extends Phaser.Structs.List. - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -138,42 +138,17 @@ var DisplayList = new Class({ }, /** - * Given an array of Game Objects, sort the array and return it, so that - * the objects are in index order with the lowest at the bottom. + * Returns an array which contains all objects currently on the Display List. + * This is a reference to the main list array, not a copy of it, so be careful not to modify it. * - * @method Phaser.GameObjects.DisplayList#sortGameObjects - * @since 3.0.0 + * @method Phaser.GameObjects.DisplayList#getChildren + * @since 3.12.0 * - * @param {Phaser.GameObjects.GameObject[]} gameObjects - The array of Game Objects to sort. - * - * @return {array} The sorted array of Game Objects. + * @return {Phaser.GameObjects.GameObject[]} The group members. */ - sortGameObjects: function (gameObjects) + getChildren: function () { - if (gameObjects === undefined) { gameObjects = this.list; } - - this.scene.sys.depthSort(); - - return gameObjects.sort(this.sortIndexHandler.bind(this)); - }, - - /** - * Get the top-most Game Object in the given array of Game Objects, after sorting it. - * - * Note that the given array is sorted in place, even though it isn't returned directly it will still be updated. - * - * @method Phaser.GameObjects.DisplayList#getTopGameObject - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject[]} gameObjects - The array of Game Objects. - * - * @return {Phaser.GameObjects.GameObject} The top-most Game Object in the array of Game Objects. - */ - getTopGameObject: function (gameObjects) - { - this.sortGameObjects(gameObjects); - - return gameObjects[gameObjects.length - 1]; + return this.list; }, /** @@ -186,7 +161,14 @@ var DisplayList = new Class({ */ shutdown: function () { - this.removeAll(); + var i = this.list.length; + + while (i--) + { + this.list[i].destroy(true); + } + + this.list.length = 0; this.systems.events.off('shutdown', this.shutdown, this); }, diff --git a/src/gameobjects/GameObject.js b/src/gameobjects/GameObject.js index 64eb7f726..c2f168223 100644 --- a/src/gameobjects/GameObject.js +++ b/src/gameobjects/GameObject.js @@ -5,7 +5,7 @@ */ var Class = require('../utils/Class'); -var Components = require('./components'); +var ComponentsToJSON = require('./components/ToJSON'); var DataManager = require('../data/DataManager'); var EventEmitter = require('eventemitter3'); @@ -16,7 +16,7 @@ var EventEmitter = require('eventemitter3'); * Instead, use them as the base for your own custom classes. * * @class GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @extends Phaser.Events.EventEmitter * @constructor * @since 3.0.0 @@ -55,6 +55,22 @@ var GameObject = new Class({ */ this.type = type; + /** + * The current state of this Game Object. + * + * Phaser itself will never modify this value, although plugins may do so. + * + * Use this property to track the state of a Game Object during its lifetime. For example, it could move from + * a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant + * in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + * + * @name Phaser.GameObjects.GameObject#state + * @type {{integer|string}} + * @since 3.16.0 + */ + this.state = 0; + /** * The parent Container of this Game Object, if it has one. * @@ -126,7 +142,7 @@ var GameObject = new Class({ * A bitmask that controls if this Game Object is drawn by a Camera or not. * Not usually set directly, instead call `Camera.ignore`, however you can * set this property directly using the Camera.id property: - * + * * @example * this.cameraFilter |= camera.id * @@ -173,8 +189,6 @@ var GameObject = new Class({ // Tell the Scene to re-sort the children scene.sys.queueDepthSort(); - - scene.sys.events.once('shutdown', this.destroy, this); }, /** @@ -213,6 +227,30 @@ var GameObject = new Class({ return this; }, + /** + * Sets the current state of this Game Object. + * + * Phaser itself will never modify the State of a Game Object, although plugins may do so. + * + * For example, a Game Object could change from a state of 'moving', to 'attacking', to 'dead'. + * The state value should typically be an integer (ideally mapped to a constant + * in your game code), but could also be a string. It is recommended to keep it light and simple. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + * + * @method Phaser.GameObjects.GameObject#setState + * @since 3.16.0 + * + * @param {(integer|string)} value - The state of the Game Object. + * + * @return {this} This GameObject. + */ + setState: function (value) + { + this.state = value; + + return this; + }, + /** * Adds a Data Manager component to this Game Object. * @@ -234,12 +272,12 @@ var GameObject = new Class({ /** * Allows you to store a key value pair within this Game Objects Data Manager. - * + * * If the Game Object has not been enabled for data (via `setDataEnabled`) then it will be enabled * before setting the value. - * + * * If the key doesn't already exist in the Data Manager then it is created. - * + * * ```javascript * sprite.setData('name', 'Red Gem Stone'); * ``` @@ -251,13 +289,13 @@ var GameObject = new Class({ * ``` * * To get a value back again you can call `getData`: - * + * * ```javascript * sprite.getData('gold'); * ``` - * + * * Or you can access the value directly via the `values` property, where it works like any other variable: - * + * * ```javascript * sprite.data.values.gold += 50; * ``` @@ -295,19 +333,19 @@ var GameObject = new Class({ * Retrieves the value for the given key in this Game Objects Data Manager, or undefined if it doesn't exist. * * You can also access values via the `values` object. For example, if you had a key called `gold` you can do either: - * + * * ```javascript * sprite.getData('gold'); * ``` * * Or access the value directly: - * + * * ```javascript * sprite.data.values.gold; * ``` * * You can also pass in an array of keys, in which case an array of values will be returned: - * + * * ```javascript * sprite.getData([ 'gold', 'armor', 'health' ]); * ``` @@ -385,17 +423,24 @@ var GameObject = new Class({ }, /** - * If this Game Object has previously been enabled for input, this will remove it. + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. * * The Interactive Object that was assigned to this Game Object will be destroyed, * removed from the Input Manager and cleared from this Game Object. * * If you wish to re-enable this Game Object at a later date you will need to - * re-create its InteractiveOobject by calling `setInteractive` again. + * re-create its InteractiveObject by calling `setInteractive` again. * * If you wish to only temporarily stop an object from receiving input then use * `disableInteractive` instead, as that toggles the interactive state, where-as * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) * * @method Phaser.GameObjects.GameObject#removeInteractive * @since 3.7.0 @@ -416,6 +461,8 @@ var GameObject = new Class({ * * @method Phaser.GameObjects.GameObject#update * @since 3.0.0 + * + * @param {...*} [args] - args */ update: function () { @@ -431,20 +478,23 @@ var GameObject = new Class({ */ toJSON: function () { - return Components.ToJSON(this); + return ComponentsToJSON(this); }, /** * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. * * @method Phaser.GameObjects.GameObject#willRender * @since 3.0.0 * + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to check against this Game Object. + * * @return {boolean} True if the Game Object should be rendered, otherwise false. */ - willRender: function () + willRender: function (camera) { - return (GameObject.RENDER_MASK === this.renderFlags); + return !(GameObject.RENDER_MASK !== this.renderFlags || (this.cameraFilter !== 0 && (this.cameraFilter & camera.id))); }, /** @@ -505,11 +555,16 @@ var GameObject = new Class({ * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. * * @method Phaser.GameObjects.GameObject#destroy + * @fires Phaser.GameObjects.GameObject#destroyEvent * @since 3.0.0 + * + * @param {boolean} [fromScene=false] - Is this Game Object being destroyed as the result of a Scene shutdown? */ - destroy: function () + destroy: function (fromScene) { - // This Game Object had already been destroyed + if (fromScene === undefined) { fromScene = false; } + + // This Game Object has already been destroyed if (!this.scene || this.ignoreDestroy) { return; @@ -524,8 +579,11 @@ var GameObject = new Class({ var sys = this.scene.sys; - sys.displayList.remove(this); - sys.updateList.remove(this); + if (!fromScene) + { + sys.displayList.remove(this); + sys.updateList.remove(this); + } if (this.input) { @@ -547,7 +605,10 @@ var GameObject = new Class({ } // Tell the Scene to re-sort the children - sys.queueDepthSort(); + if (!fromScene) + { + sys.queueDepthSort(); + } this.active = false; this.visible = false; @@ -565,9 +626,14 @@ var GameObject = new Class({ * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. * * @constant {integer} RENDER_MASK - * @memberOf Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects.GameObject * @default */ GameObject.RENDER_MASK = 15; module.exports = GameObject; + +/** + * The Game Object will be destroyed. + * @event Phaser.GameObjects.GameObject#destroyEvent + */ diff --git a/src/gameobjects/GameObjectCreator.js b/src/gameobjects/GameObjectCreator.js index 2f52858e7..a37932c38 100644 --- a/src/gameobjects/GameObjectCreator.js +++ b/src/gameobjects/GameObjectCreator.js @@ -17,7 +17,7 @@ var PluginCache = require('../plugins/PluginCache'); * methods into the class. * * @class GameObjectCreator - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * diff --git a/src/gameobjects/GameObjectFactory.js b/src/gameobjects/GameObjectFactory.js index 335589062..6303fe0b9 100644 --- a/src/gameobjects/GameObjectFactory.js +++ b/src/gameobjects/GameObjectFactory.js @@ -16,7 +16,7 @@ var PluginCache = require('../plugins/PluginCache'); * methods into the class. * * @class GameObjectFactory - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * diff --git a/src/gameobjects/UpdateList.js b/src/gameobjects/UpdateList.js index 7513d3887..101f5a932 100644 --- a/src/gameobjects/UpdateList.js +++ b/src/gameobjects/UpdateList.js @@ -16,7 +16,7 @@ var PluginCache = require('../plugins/PluginCache'); * Some or all of these Game Objects may also be part of the Scene's [Display List]{@link Phaser.GameObjects.DisplayList}, for Rendering. * * @class UpdateList - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -254,7 +254,26 @@ var UpdateList = new Class({ */ shutdown: function () { - this.removeAll(); + var i = this._list.length; + + while (i--) + { + this._list[i].destroy(true); + } + + i = this._pendingRemoval.length; + + while (i--) + { + this._pendingRemoval[i].destroy(true); + } + + i = this._pendingInsertion.length; + + while (i--) + { + this._pendingInsertion[i].destroy(true); + } this._list.length = 0; this._pendingRemoval.length = 0; @@ -289,7 +308,7 @@ var UpdateList = new Class({ * * @name Phaser.GameObjects.UpdateList#length * @type {integer} - * @readOnly + * @readonly * @since 3.10.0 */ length: { diff --git a/src/gameobjects/bitmaptext/GetBitmapTextSize.js b/src/gameobjects/bitmaptext/GetBitmapTextSize.js index 88aec1e2c..852afa350 100644 --- a/src/gameobjects/bitmaptext/GetBitmapTextSize.js +++ b/src/gameobjects/bitmaptext/GetBitmapTextSize.js @@ -49,11 +49,35 @@ * * @param {(Phaser.GameObjects.DynamicBitmapText|Phaser.GameObjects.BitmapText)} src - The BitmapText to calculate the position, width and height of. * @param {boolean} [round] - Whether to round the results to the nearest integer. + * @param {object} [out] - Optional object to store the results in, to save constant object creation. * * @return {BitmapTextSize} The calculated position, width and height of the BitmapText. */ -var GetBitmapTextSize = function (src, round) +var GetBitmapTextSize = function (src, round, out) { + if (out === undefined) + { + out = { + local: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + global: { + x: 0, + y: 0, + width: 0, + height: 0 + }, + lines: { + shortest: 0, + longest: 0, + lengths: null + } + }; + } + var text = src.text; var textLength = text.length; @@ -69,29 +93,49 @@ var GetBitmapTextSize = function (src, round) var xAdvance = 0; var yAdvance = 0; - var indexCount = 0; var charCode = 0; var glyph = null; - var glyphW = 0; - var glyphH = 0; var x = 0; var y = 0; + var scale = (src.fontSize / src.fontData.size); + var sx = scale * src.scaleX; + var sy = scale * src.scaleY; + var lastGlyph = null; var lastCharCode = 0; + var lineWidths = []; + var shortestLine = Number.MAX_VALUE; + var longestLine = 0; + var currentLine = 0; + var currentLineWidth = 0; - for (var index = 0; index < textLength; ++index) + for (var i = 0; i < textLength; i++) { - charCode = text.charCodeAt(index); + charCode = text.charCodeAt(i); if (charCode === 10) { xAdvance = 0; - indexCount = 0; yAdvance += lineHeight; lastGlyph = null; + + lineWidths[currentLine] = currentLineWidth; + + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + currentLine++; + currentLineWidth = 0; continue; } @@ -102,11 +146,8 @@ var GetBitmapTextSize = function (src, round) continue; } - glyphW = glyph.width; - glyphH = glyph.height; - - x = indexCount + glyph.xOffset + xAdvance; - y = glyph.yOffset + yAdvance; + x = xAdvance; + y = yAdvance; if (lastGlyph !== null) { @@ -124,8 +165,8 @@ var GetBitmapTextSize = function (src, round) by = y; } - var gw = x + glyphW - bx; - var gh = y + glyphH - by; + var gw = x + glyph.xAdvance; + var gh = y + lineHeight; if (bw < gw) { @@ -138,41 +179,55 @@ var GetBitmapTextSize = function (src, round) } xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; lastGlyph = glyph; lastCharCode = charCode; + currentLineWidth = gw * scale; } - var scale = (src.fontSize / src.fontData.size); - var sx = scale * src.scaleX; - var sy = scale * src.scaleY; + lineWidths[currentLine] = currentLineWidth; - var out = { - local: { - x: bx * scale, - y: by * scale, - width: bw * scale, - height: bh * scale - }, - global: { - x: src.x + (bx * sx), - y: src.y + (by * sy), - width: bw * sx, - height: bh * sy - } - }; + if (currentLineWidth > longestLine) + { + longestLine = currentLineWidth; + } + + if (currentLineWidth < shortestLine) + { + shortestLine = currentLineWidth; + } + + var local = out.local; + var global = out.global; + var lines = out.lines; + + local.x = bx * scale; + local.y = by * scale; + local.width = bw * scale; + local.height = bh * scale; + + global.x = (src.x - src.displayOriginX) + (bx * sx); + global.y = (src.y - src.displayOriginY) + (by * sy); + global.width = bw * sx; + global.height = bh * sy; + + lines.shortest = shortestLine; + lines.longest = longestLine; + lines.lengths = lineWidths; if (round) { - out.local.x = Math.round(out.local.x); - out.local.y = Math.round(out.local.y); - out.local.width = Math.round(out.local.width); - out.local.height = Math.round(out.local.height); + local.x = Math.round(local.x); + local.y = Math.round(local.y); + local.width = Math.round(local.width); + local.height = Math.round(local.height); - out.global.x = Math.round(out.global.x); - out.global.y = Math.round(out.global.y); - out.global.width = Math.round(out.global.width); - out.global.height = Math.round(out.global.height); + global.x = Math.round(global.x); + global.y = Math.round(global.y); + global.width = Math.round(global.width); + global.height = Math.round(global.height); + + lines.shortest = Math.round(shortestLine); + lines.longest = Math.round(longestLine); } return out; diff --git a/src/gameobjects/bitmaptext/ParseRetroFont.js b/src/gameobjects/bitmaptext/ParseRetroFont.js index a72b597a4..7aeb4c2ea 100644 --- a/src/gameobjects/bitmaptext/ParseRetroFont.js +++ b/src/gameobjects/bitmaptext/ParseRetroFont.js @@ -36,6 +36,7 @@ var ParseRetroFont = function (scene, config) var offsetY = GetValue(config, 'offset.y', 0); var spacingX = GetValue(config, 'spacing.x', 0); var spacingY = GetValue(config, 'spacing.y', 0); + var lineSpacing = GetValue(config, 'lineSpacing', 0); var charsPerRow = GetValue(config, 'charsPerRow', null); @@ -56,7 +57,7 @@ var ParseRetroFont = function (scene, config) retroFont: true, font: key, size: w, - lineHeight: h, + lineHeight: h + lineSpacing, chars: {} }; diff --git a/src/gameobjects/bitmaptext/RetroFont.js b/src/gameobjects/bitmaptext/RetroFont.js index 7caa02926..a54ddb67a 100644 --- a/src/gameobjects/bitmaptext/RetroFont.js +++ b/src/gameobjects/bitmaptext/RetroFont.js @@ -19,6 +19,7 @@ var Extend = require('../../utils/object/Extend'); * @property {number} charsPerRow - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth. * @property {number} spacing.x - If the characters in the font set have horizontal spacing between them set the required amount here. * @property {number} spacing.y - If the characters in the font set have vertical spacing between them set the required amount here. + * @property {number} lineSpacing - The amount of vertical space to add to the line height of the font. */ /** diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js index 710197a60..150978ba2 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapText.js @@ -4,15 +4,15 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var BitmapText = require('../static/BitmapText'); var Class = require('../../../utils/Class'); -var Components = require('../../components'); -var GameObject = require('../../GameObject'); -var GetBitmapTextSize = require('../GetBitmapTextSize'); var Render = require('./DynamicBitmapTextRender'); /** * @typedef {object} DisplayCallbackConfig - * @property {{topLeft:number,topRight:number,bottomLeft:number,bottomRight:number}} tint - The tint of the character being rendered. + * + * @property {Phaser.GameObjects.DynamicBitmapText} parent - The Dynamic Bitmap Text object that owns this character being rendered. + * @property {{topLeft:number, topRight:number, bottomLeft:number, bottomRight:number}} tint - The tint of the character being rendered. Always zero in Canvas. * @property {number} index - The index of the character being rendered. * @property {number} charCode - The character code of the character being rendered. * @property {number} x - The x position of the character being rendered. @@ -32,124 +32,61 @@ var Render = require('./DynamicBitmapTextRender'); /** * @classdesc - * [description] + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson * * @class DynamicBitmapText - * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @extends Phaser.GameObjects.BitmapText + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Alpha - * @extends Phaser.GameObjects.Components.BlendMode - * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin - * @extends Phaser.GameObjects.Components.Pipeline - * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Texture - * @extends Phaser.GameObjects.Components.Tint - * @extends Phaser.GameObjects.Components.Transform - * @extends Phaser.GameObjects.Components.Visible - * * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. * @param {number} x - The x coordinate of this Game Object in world space. * @param {number} y - The y coordinate of this Game Object in world space. * @param {string} font - The key of the font to use from the Bitmap Font cache. * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. * @param {number} [size] - The font size of this Bitmap Text. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. */ var DynamicBitmapText = new Class({ - Extends: GameObject, + Extends: BitmapText, Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Origin, - Components.Pipeline, - Components.ScrollFactor, - Components.Texture, - Components.Tint, - Components.Transform, - Components.Visible, Render ], initialize: - function DynamicBitmapText (scene, x, y, font, text, size) + function DynamicBitmapText (scene, x, y, font, text, size, align) { - if (text === undefined) { text = ''; } + BitmapText.call(this, scene, x, y, font, text, size, align); - GameObject.call(this, scene, 'DynamicBitmapText'); - - /** - * The key of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#font - * @type {string} - * @since 3.0.0 - */ - this.font = font; - - var entry = this.scene.sys.cache.bitmapFont.get(font); - - /** - * The data of the Bitmap Font used by this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#fontData - * @type {BitmapFontData} - * @since 3.0.0 - */ - this.fontData = entry.data; - - /** - * The text that this Bitmap Text object displays. - * - * @name Phaser.GameObjects.DynamicBitmapText#text - * @type {string} - * @since 3.0.0 - */ - this.text = ''; - - /** - * The font size of this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#fontSize - * @type {number} - * @since 3.0.0 - */ - 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.setText(text); - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); - - /** - * An object that describes the size of this BitmapText. - * - * @name Phaser.GameObjects.DynamicBitmapText#_bounds - * @type {BitmapTextSize} - * @private - * @since 3.0.0 - */ - this._bounds = this.getTextBounds(); + this.type = 'DynamicBitmapText'; /** * The horizontal scroll position of the Bitmap Text. @@ -194,11 +131,41 @@ var DynamicBitmapText = new Class({ /** * A callback that alters how each character of the Bitmap Text is rendered. * - * @name Phaser.GameObjects.DynamicBitmapText#displayCallback; + * @name Phaser.GameObjects.DynamicBitmapText#displayCallback * @type {DisplayCallback} * @since 3.0.0 */ this.displayCallback; + + /** + * The data object that is populated during rendering, then passed to the displayCallback. + * You should modify this object then return it back from the callback. It's updated values + * will be used to render the specific glyph. + * + * Please note that if you need a reference to this object locally in your game code then you + * should shallow copy it, as it's updated and re-used for every glyph in the text. + * + * @name Phaser.GameObjects.DynamicBitmapText#callbackData + * @type {DisplayCallbackConfig} + * @since 3.11.0 + */ + this.callbackData = { + parent: this, + color: 0, + tint: { + topLeft: 0, + topRight: 0, + bottomLeft: 0, + bottomRight: 0 + }, + index: 0, + charCode: 0, + x: 0, + y: 0, + scale: 0, + rotation: 0, + data: 0 + }; }, /** @@ -243,57 +210,6 @@ var DynamicBitmapText = new Class({ return this; }, - /** - * Set the font size of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setFontSize - * @since 3.0.0 - * - * @param {number} size - The font size to set. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setFontSize: function (size) - { - this.fontSize = size; - - return this; - }, - - /** - * Set the content of this BitmapText. - * - * An array of strings will be converted multi-line text. - * - * @method Phaser.GameObjects.DynamicBitmapText#setText - * @since 3.0.0 - * - * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. - * - * @return {Phaser.GameObjects.DynamicBitmapText} This Game Object. - */ - setText: function (value) - { - if (!value && value !== 0) - { - value = ''; - } - - if (Array.isArray(value)) - { - value = value.join('\n'); - } - - if (value !== this.text) - { - this.text = value.toString(); - - this.updateDisplayOrigin(); - } - - return this; - }, - /** * Set the horizontal scroll position of this Bitmap Text. * @@ -326,94 +242,6 @@ var DynamicBitmapText = new Class({ this.scrollY = value; return this; - }, - - /** - * Calculate the bounds of this Bitmap Text. - * - * An object is returned that contains the position, width and height of the Bitmap Text in local and global - * contexts. - * - * Local size is based on just the font size and a [0, 0] position. - * - * Global size takes into account the Game Object's scale and world position. - * - * @method Phaser.GameObjects.DynamicBitmapText#getTextBounds - * @since 3.0.0 - * - * @param {boolean} [round] - Whether to round the results to the nearest integer. - * - * @return {BitmapTextSize} An object that describes the size of this Bitmap Text. - */ - getTextBounds: function (round) - { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position - - this._bounds = GetBitmapTextSize(this, round); - - return this._bounds; - }, - - /** - * The width of this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#width - * @type {number} - * @readOnly - * @since 3.0.0 - */ - width: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.width; - } - - }, - - /** - * The height of this Bitmap Text. - * - * @name Phaser.GameObjects.DynamicBitmapText#height - * @type {number} - * @readOnly - * @since 3.0.0 - */ - height: { - - get: function () - { - this.getTextBounds(false); - return this._bounds.global.height; - } - - }, - - /** - * Build a JSON representation of this Bitmap Text. - * - * @method Phaser.GameObjects.DynamicBitmapText#toJSON - * @since 3.0.0 - * - * @return {JSONBitmapText} A JSON representation of this Bitmap Text. - */ - toJSON: function () - { - var out = Components.ToJSON(this); - - // Extra data is added here - - var data = { - font: this.font, - text: this.text, - fontSize: this.fontSize - }; - - out.data = data; - - return out; } }); diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js index 31874a262..e1a053256 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../GameObject'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -26,7 +26,9 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc var text = src.text; var textLength = text.length; - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) { return; } @@ -34,6 +36,7 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc var textureFrame = src.frame; var displayCallback = src.displayCallback; + var callbackData = src.callbackData; var cameraScrollX = camera.scrollX * src.scrollFactorX; var cameraScrollY = camera.scrollY * src.scrollFactorY; @@ -59,7 +62,6 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc var lastGlyph = null; var lastCharCode = 0; - var ctx = renderer.currentContext; var image = src.frame.source.image; var textureX = textureFrame.cutX; @@ -68,60 +70,8 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc var rotation = 0; var scale = (src.fontSize / src.fontData.size); - // Alpha - - var alpha = camera.alpha * src.alpha; - - if (alpha === 0) - { - // Nothing to see, so abort early - return; - } - else if (renderer.currentAlpha !== alpha) - { - renderer.currentAlpha = alpha; - ctx.globalAlpha = alpha; - } - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(src.x, src.y); - - ctx.rotate(src.rotation); - - ctx.translate(-src.displayOriginX, -src.displayOriginY); - - ctx.scale(src.scaleX, src.scaleY); - if (src.cropWidth > 0 && src.cropHeight > 0) { - ctx.save(); ctx.beginPath(); ctx.rect(0, 0, src.cropWidth, src.cropHeight); ctx.clip(); @@ -170,7 +120,15 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc if (displayCallback) { - var output = displayCallback({ tint: { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 }, index: index, charCode: charCode, x: x, y: y, scale: scale, rotation: 0, data: glyph.data }); + callbackData.index = index; + callbackData.charCode = charCode; + callbackData.x = x; + callbackData.y = y; + callbackData.scale = scale; + callbackData.rotation = rotation; + callbackData.data = glyph.data; + + var output = displayCallback(callbackData); x = output.x; y = output.y; @@ -186,8 +144,8 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc if (camera.roundPixels) { - x |= 0; - y |= 0; + x = Math.round(x); + y = Math.round(y); } ctx.save(); @@ -208,11 +166,7 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc lastCharCode = charCode; } - if (src.cropWidth > 0 && src.cropHeight > 0) - { - ctx.restore(); - } - + // Restore the context saved in SetTransform ctx.restore(); }; diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js index ae478d6c7..a72bc2b27 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextFactory.js @@ -9,6 +9,32 @@ var GameObjectFactory = require('../../GameObjectFactory'); /** * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson * * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. * diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextWebGLRenderer.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextWebGLRenderer.js index e1f566f11..1dfa986f5 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextWebGLRenderer.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextWebGLRenderer.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../GameObject'); +var Utils = require('../../../renderer/webgl/Utils'); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -16,22 +16,285 @@ var GameObject = require('../../GameObject'); * @private * * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.DynamicBitmapText} gameObject - The Game Object being rendered in this call. + * @param {Phaser.GameObjects.DynamicBitmapText} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var DynamicBitmapTextWebGLRenderer = function (renderer, bitmapText, interpolationPercentage, camera, parentMatrix) +var DynamicBitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - var text = bitmapText.text; + var text = src.text; var textLength = text.length; - if (GameObject.RENDER_MASK !== bitmapText.renderFlags || textLength === 0 || (bitmapText.cameraFilter > 0 && (bitmapText.cameraFilter & camera._id))) + if (textLength === 0) { return; } - this.pipeline.batchDynamicBitmapText(bitmapText, camera, parentMatrix); + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var crop = (src.cropWidth > 0 || src.cropHeight > 0); + + if (crop) + { + pipeline.flush(); + + renderer.pushScissor( + src.x, + src.y, + src.cropWidth * src.scaleX, + src.cropHeight * src.scaleY + ); + } + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + var fontMatrix = pipeline._tempMatrix4; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = texture.width; + var textureHeight = texture.height; + + var tintEffect = (src._isTinted && src.tintFill); + var tintTL = Utils.getTintAppendFloatAlpha(src._tintTL, camera.alpha * src._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(src._tintTR, camera.alpha * src._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, camera.alpha * src._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, camera.alpha * src._alphaBR); + + pipeline.setTexture2D(texture, 0); + + var xAdvance = 0; + var yAdvance = 0; + var charCode = 0; + var lastCharCode = 0; + var letterSpacing = src.letterSpacing; + var glyph; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + var lastGlyph; + var scrollX = src.scrollX; + var scrollY = src.scrollY; + + var fontData = src.fontData; + var chars = fontData.chars; + var lineHeight = fontData.lineHeight; + var scale = (src.fontSize / fontData.size); + var rotation = 0; + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + var roundPixels = camera.roundPixels; + var displayCallback = src.displayCallback; + var callbackData = src.callbackData; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + // Carriage-return + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + var x = (glyph.xOffset + xAdvance) - scrollX; + var y = (glyph.yOffset + yAdvance) - scrollY; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + scale = (src.fontSize / src.fontData.size); + rotation = 0; + + if (displayCallback) + { + callbackData.color = 0; + callbackData.tint.topLeft = tintTL; + callbackData.tint.topRight = tintTR; + callbackData.tint.bottomLeft = tintBL; + callbackData.tint.bottomRight = tintBR; + callbackData.index = i; + callbackData.charCode = charCode; + callbackData.x = x; + callbackData.y = y; + callbackData.scale = scale; + callbackData.rotation = rotation; + callbackData.data = glyph.data; + + var output = displayCallback(callbackData); + + x = output.x; + y = output.y; + scale = output.scale; + rotation = output.rotation; + + if (output.color) + { + tintTL = output.color; + tintTR = output.color; + tintBL = output.color; + tintBR = output.color; + } + else + { + tintTL = output.tint.topLeft; + tintTR = output.tint.topRight; + tintBL = output.tint.bottomLeft; + tintBR = output.tint.bottomRight; + } + + tintTL = Utils.getTintAppendFloatAlpha(tintTL, camera.alpha * src._alphaTL); + tintTR = Utils.getTintAppendFloatAlpha(tintTR, camera.alpha * src._alphaTR); + tintBL = Utils.getTintAppendFloatAlpha(tintBL, camera.alpha * src._alphaBL); + tintBR = Utils.getTintAppendFloatAlpha(tintBR, camera.alpha * src._alphaBR); + } + + x *= scale; + y *= scale; + + x -= src.displayOriginX; + y -= src.displayOriginY; + + x += lineOffsetX; + + fontMatrix.applyITRS(x, y, rotation, scale, scale); + + calcMatrix.multiply(fontMatrix, spriteMatrix); + + var u0 = glyphX / textureWidth; + var v0 = glyphY / textureHeight; + var u1 = (glyphX + glyphW) / textureWidth; + var v1 = (glyphY + glyphH) / textureHeight; + + var xw = glyphW; + var yh = glyphH; + + var tx0 = spriteMatrix.e; + var ty0 = spriteMatrix.f; + + var tx1 = yh * spriteMatrix.c + spriteMatrix.e; + var ty1 = yh * spriteMatrix.d + spriteMatrix.f; + + var tx2 = xw * spriteMatrix.a + yh * spriteMatrix.c + spriteMatrix.e; + var ty2 = xw * spriteMatrix.b + yh * spriteMatrix.d + spriteMatrix.f; + + var tx3 = xw * spriteMatrix.a + spriteMatrix.e; + var ty3 = xw * spriteMatrix.b + spriteMatrix.f; + + if (roundPixels) + { + tx0 = Math.round(tx0); + ty0 = Math.round(ty0); + + tx1 = Math.round(tx1); + ty1 = Math.round(ty1); + + tx2 = Math.round(tx2); + ty2 = Math.round(ty2); + + tx3 = Math.round(tx3); + ty3 = Math.round(ty3); + } + + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0); + } + + if (crop) + { + pipeline.flush(); + + renderer.popScissor(); + } }; module.exports = DynamicBitmapTextWebGLRenderer; diff --git a/src/gameobjects/bitmaptext/static/BitmapText.js b/src/gameobjects/bitmaptext/static/BitmapText.js index d0cf95dc2..93cb0c7ba 100644 --- a/src/gameobjects/bitmaptext/static/BitmapText.js +++ b/src/gameobjects/bitmaptext/static/BitmapText.js @@ -49,16 +49,35 @@ var Render = require('./BitmapTextRender'); * @property {string} font - The name of the font. * @property {string} text - The text that this Bitmap Text displays. * @property {number} fontSize - The size of the font. - * @property {number} letterSpacing - Adds/Removes spacing between characters + * @property {number} letterSpacing - Adds / Removes spacing between characters. + * @property {integer} align - The alignment of the text in a multi-line BitmapText object. */ /** * @classdesc - * [description] + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} + * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} + * Littera (Web-based, free): {@link http://kvazars.com/littera/|http://kvazars.com/littera/} + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} * * @class BitmapText * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -81,6 +100,7 @@ var Render = require('./BitmapTextRender'); * @param {string} font - The key of the font to use from the Bitmap Font cache. * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. * @param {number} [size] - The font size of this Bitmap Text. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. */ var BitmapText = new Class({ @@ -104,17 +124,20 @@ var BitmapText = new Class({ initialize: - function BitmapText (scene, x, y, font, text, size) + function BitmapText (scene, x, y, font, text, size, align) { if (text === undefined) { text = ''; } + if (align === undefined) { align = 0; } GameObject.call(this, scene, 'BitmapText'); /** * The key of the Bitmap Font used by this Bitmap Text. + * To change the font after creation please use `setFont`. * * @name Phaser.GameObjects.BitmapText#font * @type {string} + * @readonly * @since 3.0.0 */ this.font = font; @@ -126,6 +149,7 @@ var BitmapText = new Class({ * * @name Phaser.GameObjects.BitmapText#fontData * @type {BitmapFontData} + * @readonly * @since 3.0.0 */ this.fontData = entry.data; @@ -133,38 +157,54 @@ var BitmapText = new Class({ /** * The text that this Bitmap Text object displays. * - * @name Phaser.GameObjects.BitmapText#text + * @name Phaser.GameObjects.BitmapText#_text * @type {string} + * @private * @since 3.0.0 */ - this.text = ''; + this._text = ''; /** * The font size of this Bitmap Text. * - * @name Phaser.GameObjects.BitmapText#fontSize + * @name Phaser.GameObjects.BitmapText#_fontSize * @type {number} + * @private * @since 3.0.0 */ - this.fontSize = size || this.fontData.size; + this._fontSize = size || this.fontData.size; /** - * Adds/Removes spacing between characters. + * Adds / Removes spacing between characters. * * Can be a negative or positive number. * - * @name Phaser.GameObjects.BitmapText#letterSpacing + * @name Phaser.GameObjects.BitmapText#_letterSpacing * @type {number} + * @private * @since 3.4.0 */ - this.letterSpacing = 0; + this._letterSpacing = 0; - this.setText(text); - - this.setTexture(entry.texture, entry.frame); - this.setPosition(x, y); - this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); + /** + * Controls the alignment of each line of text in this BitmapText object. + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#_align + * @type {integer} + * @private + * @since 3.11.0 + */ + this._align = align; /** * An object that describes the size of this Bitmap Text. @@ -174,7 +214,78 @@ var BitmapText = new Class({ * @private * @since 3.0.0 */ - this._bounds = this.getTextBounds(); + this._bounds = GetBitmapTextSize(this, false, this._bounds); + + /** + * An internal dirty flag for bounds calculation. + * + * @name Phaser.GameObjects.BitmapText#_dirty + * @type {boolean} + * @private + * @since 3.11.0 + */ + this._dirty = false; + + this.setTexture(entry.texture, entry.frame); + this.setPosition(x, y); + this.setOrigin(0, 0); + this.initPipeline(); + + this.setText(text); + }, + + /** + * Set the lines of text in this BitmapText to be left-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setLeftAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setLeftAlign: function () + { + this._align = BitmapText.ALIGN_LEFT; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be center-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setCenterAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setCenterAlign: function () + { + this._align = BitmapText.ALIGN_CENTER; + + this._dirty = true; + + return this; + }, + + /** + * Set the lines of text in this BitmapText to be right-aligned. + * This only has any effect if this BitmapText contains more than one line of text. + * + * @method Phaser.GameObjects.BitmapText#setRightAlign + * @since 3.11.0 + * + * @return {this} This BitmapText Object. + */ + setRightAlign: function () + { + this._align = BitmapText.ALIGN_RIGHT; + + this._dirty = true; + + return this; }, /** @@ -185,11 +296,13 @@ var BitmapText = new Class({ * * @param {number} size - The font size to set. * - * @return {Phaser.GameObjects.BitmapText} This Game Object. + * @return {this} This BitmapText Object. */ setFontSize: function (size) { - this.fontSize = size; + this._fontSize = size; + + this._dirty = true; return this; }, @@ -204,28 +317,30 @@ var BitmapText = new Class({ * * @param {number} [spacing=0] - The amount of horizontal space to add between each character. * - * @return {Phaser.GameObjects.BitmapText} This Game Object. + * @return {this} This BitmapText Object. */ setLetterSpacing: function (spacing) { if (spacing === undefined) { spacing = 0; } - this.letterSpacing = spacing; + this._letterSpacing = spacing; + + this._dirty = true; return this; }, /** - * Set the content of this BitmapText. + * Set the textual content of this BitmapText. * - * An array of strings will be converted multi-line text. + * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. * * @method Phaser.GameObjects.BitmapText#setText * @since 3.0.0 * * @param {(string|string[])} value - The string, or array of strings, to be set as the content of this BitmapText. * - * @return {Phaser.GameObjects.BitmapText} This Game Object. + * @return {this} This BitmapText Object. */ setText: function (value) { @@ -241,7 +356,9 @@ var BitmapText = new Class({ if (value !== this.text) { - this.text = value.toString(); + this._text = value.toString(); + + this._dirty = true; this.updateDisplayOrigin(); } @@ -257,7 +374,9 @@ var BitmapText = new Class({ * * Local size is based on just the font size and a [0, 0] position. * - * Global size takes into account the Game Object's scale and world position. + * Global size takes into account the Game Object's scale, world position and display origin. + * + * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. * * @method Phaser.GameObjects.BitmapText#getTextBounds * @since 3.0.0 @@ -268,20 +387,170 @@ var BitmapText = new Class({ */ getTextBounds: function (round) { - // local = the BitmapText based on fontSize and 0x0 coords - // global = the BitmapText, taking into account scale and world position + // local = The BitmapText based on fontSize and 0x0 coords + // global = The BitmapText, taking into account scale and world position + // lines = The BitmapText line data - this._bounds = GetBitmapTextSize(this, round); + if (this._dirty) + { + GetBitmapTextSize(this, round, this._bounds); + } return this._bounds; }, + /** + * Changes the font this BitmapText is using to render. + * + * The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved, + * unless overridden via the arguments. + * + * @method Phaser.GameObjects.BitmapText#setFont + * @since 3.11.0 + * + * @param {string} font - The key of the font to use from the Bitmap Font cache. + * @param {number} [size] - The font size of this Bitmap Text. If not specified the current size will be used. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. + * + * @return {this} This BitmapText Object. + */ + setFont: function (key, size, align) + { + if (size === undefined) { size = this._fontSize; } + if (align === undefined) { align = this._align; } + + if (key !== this.font) + { + var entry = this.scene.sys.cache.bitmapFont.get(key); + + if (entry) + { + this.font = key; + this.fontData = entry.data; + this._fontSize = size; + this._align = align; + + this.setTexture(entry.texture, entry.frame); + + GetBitmapTextSize(this, false, this._bounds); + } + } + + return this; + }, + + /** + * Controls the alignment of each line of text in this BitmapText object. + * + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + * + * @name Phaser.GameObjects.BitmapText#align + * @type {integer} + * @since 3.11.0 + */ + align: { + + set: function (value) + { + this._align = value; + this._dirty = true; + }, + + get: function () + { + return this._align; + } + + }, + + /** + * The text that this Bitmap Text object displays. + * + * You can also use the method `setText` if you want a chainable way to change the text content. + * + * @name Phaser.GameObjects.BitmapText#text + * @type {string} + * @since 3.0.0 + */ + text: { + + set: function (value) + { + this.setText(value); + }, + + get: function () + { + return this._text; + } + + }, + + /** + * The font size of this Bitmap Text. + * + * You can also use the method `setFontSize` if you want a chainable way to change the font size. + * + * @name Phaser.GameObjects.BitmapText#fontSize + * @type {number} + * @since 3.0.0 + */ + fontSize: { + + set: function (value) + { + this._fontSize = value; + this._dirty = true; + }, + + get: function () + { + return this._fontSize; + } + + }, + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. + * + * @name Phaser.GameObjects.BitmapText#letterSpacing + * @type {number} + * @since 3.0.0 + */ + letterSpacing: { + + set: function (value) + { + this._letterSpacing = value; + this._dirty = true; + }, + + get: function () + { + return this._letterSpacing; + } + + }, + /** * The width of this Bitmap Text. * * @name Phaser.GameObjects.BitmapText#width * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ width: { @@ -300,7 +569,7 @@ var BitmapText = new Class({ * * @name Phaser.GameObjects.BitmapText#height * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ height: { @@ -332,7 +601,8 @@ var BitmapText = new Class({ font: this.font, text: this.text, fontSize: this.fontSize, - letterSpacing: this.letterSpacing + letterSpacing: this.letterSpacing, + align: this.align }; out.data = data; @@ -342,6 +612,33 @@ var BitmapText = new Class({ }); +/** + * Left align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_LEFT + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_LEFT = 0; + +/** + * Center align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_CENTER + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_CENTER = 1; + +/** + * Right align the text characters in a multi-line BitmapText object. + * + * @name Phaser.GameObjects.BitmapText.ALIGN_RIGHT + * @type {integer} + * @since 3.11.0 + */ +BitmapText.ALIGN_RIGHT = 2; + BitmapText.ParseFromAtlas = ParseFromAtlas; module.exports = BitmapText; diff --git a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js index 047054bc9..366da02b5 100644 --- a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../GameObject'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -23,10 +23,12 @@ var GameObject = require('../../GameObject'); */ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - var text = src.text; + var text = src._text; var textLength = text.length; - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) + var ctx = renderer.currentContext; + + if (textLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) { return; } @@ -35,12 +37,11 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, var chars = src.fontData.chars; var lineHeight = src.fontData.lineHeight; - var letterSpacing = src.letterSpacing; + var letterSpacing = src._letterSpacing; var xAdvance = 0; var yAdvance = 0; - var indexCount = 0; var charCode = 0; var glyph = null; @@ -55,77 +56,56 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, var lastGlyph = null; var lastCharCode = 0; - var ctx = renderer.currentContext; var image = src.frame.source.image; var textureX = textureFrame.cutX; var textureY = textureFrame.cutY; - var scale = (src.fontSize / src.fontData.size); + var scale = (src._fontSize / src.fontData.size); - // Alpha + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; - var alpha = camera.alpha * src.alpha; + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); - if (alpha === 0) + var lineData = src._bounds.lines; + + if (align === 1) { - // Nothing to see, so abort early - return; + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; } - else if (renderer.currentAlpha !== alpha) + else if (align === 2) { - renderer.currentAlpha = alpha; - ctx.globalAlpha = alpha; + lineOffsetX = (lineData.longest - lineData.lengths[0]); } - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var tx = (src.x - camera.scrollX * src.scrollFactorX) + src.frame.x; - var ty = (src.y - camera.scrollY * src.scrollFactorY) + src.frame.y; - - if (camera.roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - ctx.translate(-src.displayOriginX, -src.displayOriginY); - ctx.scale(src.scaleX, src.scaleY); + var roundPixels = camera.roundPixels; - for (var index = 0; index < textLength; ++index) + for (var i = 0; i < textLength; i++) { - charCode = text.charCodeAt(index); + charCode = text.charCodeAt(i); if (charCode === 10) { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + xAdvance = 0; - indexCount = 0; yAdvance += lineHeight; lastGlyph = null; + continue; } @@ -142,7 +122,7 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, glyphW = glyph.width; glyphH = glyph.height; - x = indexCount + glyph.xOffset + xAdvance; + x = glyph.xOffset + xAdvance; y = glyph.yOffset + yAdvance; if (lastGlyph !== null) @@ -154,8 +134,9 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, x *= scale; y *= scale; + x += lineOffsetX; + xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; lastGlyph = glyph; lastCharCode = charCode; @@ -165,10 +146,10 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, continue; } - if (camera.roundPixels) + if (roundPixels) { - x |= 0; - y |= 0; + x = Math.round(x); + y = Math.round(y); } ctx.save(); diff --git a/src/gameobjects/bitmaptext/static/BitmapTextCreator.js b/src/gameobjects/bitmaptext/static/BitmapTextCreator.js index 9aee6df1b..dee0c9618 100644 --- a/src/gameobjects/bitmaptext/static/BitmapTextCreator.js +++ b/src/gameobjects/bitmaptext/static/BitmapTextCreator.js @@ -30,10 +30,9 @@ GameObjectCreator.register('bitmapText', function (config, addToScene) var font = GetValue(config, 'font', ''); var text = GetAdvancedValue(config, 'text', ''); var size = GetAdvancedValue(config, 'size', false); + var align = GetValue(config, 'align', 0); - // var align = GetValue(config, 'align', 'left'); - - var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size); + var bitmapText = new BitmapText(this.scene, 0, 0, font, text, size, align); if (addToScene !== undefined) { diff --git a/src/gameobjects/bitmaptext/static/BitmapTextFactory.js b/src/gameobjects/bitmaptext/static/BitmapTextFactory.js index f722ec9cb..9d95d525b 100644 --- a/src/gameobjects/bitmaptext/static/BitmapTextFactory.js +++ b/src/gameobjects/bitmaptext/static/BitmapTextFactory.js @@ -9,6 +9,26 @@ var GameObjectFactory = require('../../GameObjectFactory'); /** * Creates a new Bitmap Text Game Object and adds it to the Scene. + * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson * * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. * @@ -20,12 +40,13 @@ var GameObjectFactory = require('../../GameObjectFactory'); * @param {string} font - The key of the font to use from the BitmapFont cache. * @param {(string|string[])} [text] - The string, or array of strings, to be set as the content of this Bitmap Text. * @param {number} [size] - The font size to set. + * @param {integer} [align=0] - The alignment of the text in a multi-line BitmapText object. * * @return {Phaser.GameObjects.BitmapText} The Game Object that was created. */ -GameObjectFactory.register('bitmapText', function (x, y, font, text, size) +GameObjectFactory.register('bitmapText', function (x, y, font, text, size, align) { - return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size)); + return this.displayList.add(new BitmapText(this.scene, x, y, font, text, size, align)); }); // When registering a factory function 'this' refers to the GameObjectFactory context. diff --git a/src/gameobjects/bitmaptext/static/BitmapTextWebGLRenderer.js b/src/gameobjects/bitmaptext/static/BitmapTextWebGLRenderer.js index ee025936a..8d95f99b0 100644 --- a/src/gameobjects/bitmaptext/static/BitmapTextWebGLRenderer.js +++ b/src/gameobjects/bitmaptext/static/BitmapTextWebGLRenderer.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../GameObject'); +var Utils = require('../../../renderer/webgl/Utils'); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -16,22 +16,208 @@ var GameObject = require('../../GameObject'); * @private * * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.BitmapText} gameObject - The Game Object being rendered in this call. + * @param {Phaser.GameObjects.BitmapText} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var BitmapTextWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera, parentMatrix) +var BitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - var text = gameObject.text; + var text = src._text; var textLength = text.length; - if (GameObject.RENDER_MASK !== gameObject.renderFlags || textLength === 0 || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) + if (textLength === 0) { return; } + + var pipeline = this.pipeline; - this.pipeline.batchBitmapText(this, camera, parentMatrix); + renderer.setPipeline(pipeline, src); + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var frame = src.frame; + var texture = frame.glTexture; + var textureX = frame.cutX; + var textureY = frame.cutY; + var textureWidth = texture.width; + var textureHeight = texture.height; + + var tintEffect = (src._isTinted && src.tintFill); + var tintTL = Utils.getTintAppendFloatAlpha(src._tintTL, camera.alpha * src._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(src._tintTR, camera.alpha * src._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, camera.alpha * src._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, camera.alpha * src._alphaBR); + + pipeline.setTexture2D(texture, 0); + + var xAdvance = 0; + var yAdvance = 0; + var charCode = 0; + var lastCharCode = 0; + var letterSpacing = src._letterSpacing; + var glyph; + var glyphX = 0; + var glyphY = 0; + var glyphW = 0; + var glyphH = 0; + var lastGlyph; + + var fontData = src.fontData; + var chars = fontData.chars; + var lineHeight = fontData.lineHeight; + var scale = (src._fontSize / fontData.size); + + var align = src._align; + var currentLine = 0; + var lineOffsetX = 0; + + // Update the bounds - skipped internally if not dirty + src.getTextBounds(false); + + var lineData = src._bounds.lines; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[0]); + } + + var roundPixels = camera.roundPixels; + + for (var i = 0; i < textLength; i++) + { + charCode = text.charCodeAt(i); + + // Carriage-return + if (charCode === 10) + { + currentLine++; + + if (align === 1) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]) / 2; + } + else if (align === 2) + { + lineOffsetX = (lineData.longest - lineData.lengths[currentLine]); + } + + xAdvance = 0; + yAdvance += lineHeight; + lastGlyph = null; + + continue; + } + + glyph = chars[charCode]; + + if (!glyph) + { + continue; + } + + glyphX = textureX + glyph.x; + glyphY = textureY + glyph.y; + + glyphW = glyph.width; + glyphH = glyph.height; + + var x = glyph.xOffset + xAdvance; + var y = glyph.yOffset + yAdvance; + + if (lastGlyph !== null) + { + var kerningOffset = glyph.kerning[lastCharCode]; + x += (kerningOffset !== undefined) ? kerningOffset : 0; + } + + xAdvance += glyph.xAdvance + letterSpacing; + lastGlyph = glyph; + lastCharCode = charCode; + + // Nothing to render or a space? Then skip to the next glyph + if (glyphW === 0 || glyphH === 0 || charCode === 32) + { + continue; + } + + x *= scale; + y *= scale; + + x -= src.displayOriginX; + y -= src.displayOriginY; + + x += lineOffsetX; + + var u0 = glyphX / textureWidth; + var v0 = glyphY / textureHeight; + var u1 = (glyphX + glyphW) / textureWidth; + var v1 = (glyphY + glyphH) / textureHeight; + + var xw = x + (glyphW * scale); + var yh = y + (glyphH * scale); + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (roundPixels) + { + tx0 = Math.round(tx0); + ty0 = Math.round(ty0); + + tx1 = Math.round(tx1); + ty1 = Math.round(ty1); + + tx2 = Math.round(tx2); + ty2 = Math.round(ty2); + + tx3 = Math.round(tx3); + ty3 = Math.round(ty3); + } + + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0); + } }; module.exports = BitmapTextWebGLRenderer; diff --git a/src/gameobjects/blitter/Blitter.js b/src/gameobjects/blitter/Blitter.js index 0bf9d088b..f774bff65 100644 --- a/src/gameobjects/blitter/Blitter.js +++ b/src/gameobjects/blitter/Blitter.js @@ -37,7 +37,7 @@ var List = require('../../structs/List'); * * @class Blitter * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -86,7 +86,7 @@ var Blitter = new Class({ this.setTexture(texture, frame); this.setPosition(x, y); - this.initPipeline('TextureTintPipeline'); + this.initPipeline(); /** * The children of this Blitter. diff --git a/src/gameobjects/blitter/BlitterCanvasRenderer.js b/src/gameobjects/blitter/BlitterCanvasRenderer.js index 515e54c3d..09ee942a0 100644 --- a/src/gameobjects/blitter/BlitterCanvasRenderer.js +++ b/src/gameobjects/blitter/BlitterCanvasRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -25,14 +23,12 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca { var list = src.getRenderList(); - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id)) || list.length === 0) + if (list.length === 0) { return; } - var ctx = renderer.gameContext; - - // Alpha + var ctx = renderer.currentContext; var alpha = camera.alpha * src.alpha; @@ -41,27 +37,22 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca // Nothing to see, so abort early return; } - else if (renderer.currentAlpha !== alpha) - { - renderer.currentAlpha = alpha; - ctx.globalAlpha = alpha; - } // Blend Mode - - renderer.setBlendMode(src.blendMode); + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; ctx.save(); - if (parentMatrix !== undefined) + if (parentMatrix) { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + parentMatrix.copyToContext(ctx); } + var roundPixels = camera.roundPixels; + // Render bobs for (var i = 0; i < list.length; i++) { @@ -80,34 +71,47 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca { continue; } - else if (renderer.currentAlpha !== bobAlpha) - { - renderer.currentAlpha = bobAlpha; - ctx.globalAlpha = bobAlpha; - } + + ctx.globalAlpha = bobAlpha; if (!flip) { - renderer.blitImage(dx + bob.x + cameraScrollX, dy + bob.y + cameraScrollY, bob.frame); + if (roundPixels) + { + dx = Math.round(dx); + dy = Math.round(dy); + } + + ctx.drawImage( + frame.source.image, + cd.x, + cd.y, + cd.width, + cd.height, + dx + bob.x + cameraScrollX, + dy + bob.y + cameraScrollY, + cd.width, + cd.height + ); } else { if (bob.flipX) { fx = -1; - dx -= cd.dWidth; + dx -= cd.width; } if (bob.flipY) { fy = -1; - dy -= cd.dHeight; + dy -= cd.height; } ctx.save(); ctx.translate(bob.x + cameraScrollX, bob.y + cameraScrollY); ctx.scale(fx, fy); - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, dx, dy, cd.width, cd.height); ctx.restore(); } } diff --git a/src/gameobjects/blitter/BlitterWebGLRenderer.js b/src/gameobjects/blitter/BlitterWebGLRenderer.js index 5bd8bffc1..cd9c3cbf9 100644 --- a/src/gameobjects/blitter/BlitterWebGLRenderer.js +++ b/src/gameobjects/blitter/BlitterWebGLRenderer.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); +var Utils = require('../../renderer/webgl/Utils'); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -16,19 +16,109 @@ var GameObject = require('../GameObject'); * @private * * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Blitter} gameObject - The Game Object being rendered in this call. + * @param {Phaser.GameObjects.Blitter} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var BlitterWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera, parentMatrix) +var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== gameObject.renderFlags || (gameObject.cameraFilter > 0 && (gameObject.cameraFilter & camera._id))) + var list = src.getRenderList(); + + if (list.length === 0) { return; } - this.pipeline.drawBlitter(gameObject, camera, parentMatrix); + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var cameraScrollX = camera.scrollX * src.scrollFactorX; + var cameraScrollY = camera.scrollY * src.scrollFactorY; + + var calcMatrix = pipeline._tempMatrix1; + + calcMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + calcMatrix.multiplyWithOffset(parentMatrix, -cameraScrollX, -cameraScrollY); + + cameraScrollX = 0; + cameraScrollY = 0; + } + + var blitterX = src.x - cameraScrollX; + var blitterY = src.y - cameraScrollY; + var prevTextureSourceIndex = -1; + var tintEffect = false; + var alpha = camera.alpha * src.alpha; + var roundPixels = camera.roundPixels; + + for (var index = 0; index < list.length; index++) + { + var bob = list[index]; + var frame = bob.frame; + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + + var width = frame.width; + var height = frame.height; + + var x = blitterX + bob.x + frame.x; + var y = blitterY + bob.y + frame.y; + + if (bob.flipX) + { + width *= -1; + x += frame.width; + } + + if (bob.flipY) + { + height *= -1; + y += frame.height; + } + + var xw = x + width; + var yh = y + height; + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(xw, yh); + var ty1 = calcMatrix.getY(xw, yh); + + var tint = Utils.getTintAppendFloatAlpha(0xffffff, bobAlpha); + + // Bind texture only if the Texture Source is different from before + if (frame.sourceIndex !== prevTextureSourceIndex) + { + pipeline.setTexture2D(frame.glTexture, 0); + + prevTextureSourceIndex = frame.sourceIndex; + } + + if (roundPixels) + { + tx0 = Math.round(tx0); + ty0 = Math.round(ty0); + + tx1 = Math.round(tx1); + ty1 = Math.round(ty1); + } + + // TL x/y, BL x/y, BR x/y, TR x/y + if (pipeline.batchQuad(tx0, ty0, tx0, ty1, tx1, ty1, tx1, ty0, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect, frame.glTexture, 0)) + { + prevTextureSourceIndex = -1; + } + } }; module.exports = BlitterWebGLRenderer; diff --git a/src/gameobjects/blitter/Bob.js b/src/gameobjects/blitter/Bob.js index d4dd9cab5..008aa8ae9 100644 --- a/src/gameobjects/blitter/Bob.js +++ b/src/gameobjects/blitter/Bob.js @@ -23,7 +23,7 @@ var Class = require('../../utils/Class'); * handled via the Blitter parent. * * @class Bob - * @memberOf Phaser.GameObjects.Blitter + * @memberof Phaser.GameObjects.Blitter * @constructor * @since 3.0.0 * diff --git a/src/gameobjects/components/Animation.js b/src/gameobjects/components/Animation.js index 97285362e..eda08efb2 100644 --- a/src/gameobjects/components/Animation.js +++ b/src/gameobjects/components/Animation.js @@ -4,40 +4,85 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var BaseAnimation = require('../../animations/Animation'); var Class = require('../../utils/Class'); /** * This event is dispatched when an animation starts playing. + * + * Listen for it on the Game Object: `sprite.on('animationstart', listener)` + * + * You can also listen for a specific animation by appending a hyphen and its key to the event name. For example, + * if you have an animation called `explode`, you can listen for `sprite.on('animationstart-explode', listener)`. + * + * You can also listen for the `start` event from the Animation itself: `animation.on('start', listener)`. * * @event Phaser.GameObjects.Components.Animation#onStartEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. + */ + +/** + * This event is dispatched when an animation restarts. + * + * Listen for it on the Game Object: `sprite.on('animationrestart', listener)` + * + * You can also listen for a specific animation by appending a hyphen and its key to the event name. For example, + * if you have an animation called `explode`, you can listen for `sprite.on('animationrestart-explode', listener)`. + * + * You can also listen for the `restart` event from the Animation itself: `animation.on('restart', listener)`. + * + * @event Phaser.GameObjects.Components.Animation#onRestartEvent + * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. + * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** * This event is dispatched when an animation repeats. + * + * Listen for it on the Game Object: `sprite.on('animationrepeat', listener)` + * + * You can also listen for a specific animation by appending a hyphen and its key to the event name. For example, + * if you have an animation called `explode`, you can listen for `sprite.on('animationrepeat-explode', listener)`. * * @event Phaser.GameObjects.Components.Animation#onRepeatEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. * @param {integer} repeatCount - The number of times this animation has repeated. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** * This event is dispatched when an animation updates. This happens when the animation frame changes, * based on the animation frame rate and other factors like timeScale and delay. + * + * Listen for it on the Game Object: `sprite.on('animationupdate', listener)` + * + * You can also listen for a specific animation by appending a hyphen and its key to the event name. For example, + * if you have an animation called `explode`, you can listen for `sprite.on('animationupdate-explode', listener)`. * * @event Phaser.GameObjects.Components.Animation#onUpdateEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** * This event is dispatched when an animation completes playing, either naturally or via Animation.stop. + * + * Listen for it on the Game Object: `sprite.on('animationcomplete', listener)` + * + * You can also listen for a specific animation by appending a hyphen and its key to the event name. For example, + * if you have an animation called `explode`, you can listen for `sprite.on('animationcomplete-explode', listener)`. + * + * You can also listen for the `complete` event from the Animation itself: `animation.on('complete', listener)`. * * @event Phaser.GameObjects.Components.Animation#onCompleteEvent * @param {Phaser.Animations.Animation} animation - Reference to the currently playing animation. * @param {Phaser.Animations.AnimationFrame} frame - Reference to the current Animation Frame. + * @param {Phaser.GameObjects.Sprite} gameObject - Reference to the Game Object on which the event occurred. */ /** @@ -47,7 +92,7 @@ var Class = require('../../utils/Class'); * This controller lives as an instance within a Game Object, accessible as `sprite.anims`. * * @class Animation - * @memberOf Phaser.GameObjects.Components + * @memberof Phaser.GameObjects.Components * @constructor * @since 3.0.0 * @@ -109,6 +154,16 @@ var Animation = new Class({ */ this.currentFrame = null; + /** + * The key of the next Animation to be loaded into this Animation Controller when the current animation completes. + * + * @name Phaser.GameObjects.Components.Animation#nextAnim + * @type {?string} + * @default null + * @since 3.16.0 + */ + this.nextAnim = null; + /** * Time scale factor. * @@ -208,7 +263,7 @@ var Animation = new Class({ this._yoyo = false; /** - * Will the playhead move forwards (`true`) or in reverse (`false`) + * Will the playhead move forwards (`true`) or in reverse (`false`). * * @name Phaser.GameObjects.Components.Animation#forward * @type {boolean} @@ -217,6 +272,17 @@ var Animation = new Class({ */ this.forward = true; + /** + * An Internal trigger that's play the animation in reverse mode ('true') or not ('false'), + * needed because forward can be changed by yoyo feature. + * + * @name Phaser.GameObjects.Components.Animation#forward + * @type {boolean} + * @default false + * @since 3.12.0 + */ + this._reverse = false; + /** * Internal time overflow accumulator. * @@ -305,6 +371,37 @@ var Animation = new Class({ this._pendingStopValue; }, + /** + * Sets an animation to be played immediately after the current one completes. + * + * The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, or have the `stop` method called directly on it. + * + * An animation set to repeat forever will never enter a completed state. + * + * You can chain a new animation at any point, including before the current one starts playing, during it, or when it ends (via its `animationcomplete` callback). + * Chained animations are specific to a Game Object, meaning different Game Objects can have different chained animations without impacting the global animation they're playing. + * + * Call this method with no arguments to reset the chained animation. + * + * @method Phaser.GameObjects.Components.Animation#chain + * @since 3.16.0 + * + * @param {(string|Phaser.Animations.Animation)} [key] - The string-based key of the animation to play next, as defined previously in the Animation Manager. Or an Animation instance. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + chain: function (key) + { + if (key instanceof BaseAnimation) + { + key = key.key; + } + + this.nextAnim = key; + + return this.parent; + }, + /** * Sets the amount of time, in milliseconds, that the animation will be delayed before starting playback. * @@ -460,7 +557,7 @@ var Animation = new Class({ * `true` if the current animation is paused, otherwise `false`. * * @name Phaser.GameObjects.Components.Animation#isPaused - * @readOnly + * @readonly * @type {boolean} * @since 3.4.0 */ @@ -474,13 +571,15 @@ var Animation = new Class({ }, /** - * Plays an Animation on the Game Object that owns this Animation Component. + * Plays an Animation on a Game Object that has the Animation component, such as a Sprite. + * + * Animations are stored in the global Animation Manager and are referenced by a unique string-based key. * * @method Phaser.GameObjects.Components.Animation#play * @fires Phaser.GameObjects.Components.Animation#onStartEvent * @since 3.0.0 * - * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {(string|Phaser.Animations.Animation)} key - The string-based key of the animation to play, as defined previously in the Animation Manager. Or an Animation instance. * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. * @@ -491,11 +590,70 @@ var Animation = new Class({ if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } if (startFrame === undefined) { startFrame = 0; } + if (key instanceof BaseAnimation) + { + key = key.key; + } + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) { return this.parent; } + this.forward = true; + this._reverse = false; + + return this._startAnimation(key, startFrame); + }, + + /** + * Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component. + * + * @method Phaser.GameObjects.Components.Animation#playReverse + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {(string|Phaser.Animations.Animation)} key - The string-based key of the animation to play, as defined previously in the Animation Manager. Or an Animation instance. + * @param {boolean} [ignoreIfPlaying=false] - If an animation is already playing then ignore this call. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + playReverse: function (key, ignoreIfPlaying, startFrame) + { + if (ignoreIfPlaying === undefined) { ignoreIfPlaying = false; } + if (startFrame === undefined) { startFrame = 0; } + + if (key instanceof BaseAnimation) + { + key = key.key; + } + + if (ignoreIfPlaying && this.isPlaying && this.currentAnim.key === key) + { + return this.parent; + } + + this.forward = false; + this._reverse = true; + + return this._startAnimation(key, startFrame); + }, + + /** + * Load an Animation and fires 'onStartEvent' event, extracted from 'play' method. + * + * @method Phaser.GameObjects.Components.Animation#_startAnimation + * @fires Phaser.GameObjects.Components.Animation#onStartEvent + * @since 3.12.0 + * + * @param {string} key - The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param {integer} [startFrame=0] - Optionally start the animation playing from this frame index. + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + _startAnimation: function (key, startFrame) + { this.load(key, startFrame); var anim = this.currentAnim; @@ -506,7 +664,6 @@ var Animation = new Class({ anim.getFirstTick(this); - this.forward = true; this.isPlaying = true; this.pendingRepeat = false; @@ -515,11 +672,37 @@ var Animation = new Class({ gameObject.visible = true; } - gameObject.emit('animationstart', this.currentAnim, this.currentFrame); + var frame = this.currentFrame; + + anim.emit('start', anim, frame); + + gameObject.emit('animationstart-' + key, anim, frame, gameObject); + + gameObject.emit('animationstart', anim, frame, gameObject); return gameObject; }, + /** + * Reverse the Animation that is already playing on the Game Object. + * + * @method Phaser.GameObjects.Components.Animation#reverse + * @since 3.12.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. + */ + reverse: function () + { + if (this.isPlaying) + { + this._reverse = !this._reverse; + + this.forward = !this.forward; + } + + return this.parent; + }, + /** * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. * If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different @@ -661,6 +844,7 @@ var Animation = new Class({ * Restarts the current animation from its beginning, optionally including its delay value. * * @method Phaser.GameObjects.Components.Animation#restart + * @fires Phaser.GameObjects.Components.Animation#onRestartEvent * @since 3.0.0 * * @param {boolean} [includeDelay=false] - Whether to include the delay value of the animation when restarting. @@ -671,7 +855,9 @@ var Animation = new Class({ { if (includeDelay === undefined) { includeDelay = false; } - this.currentAnim.getFirstTick(this, includeDelay); + var anim = this.currentAnim; + + anim.getFirstTick(this, includeDelay); this.forward = true; this.isPlaying = true; @@ -679,13 +865,26 @@ var Animation = new Class({ this._paused = false; // Set frame - this.updateFrame(this.currentAnim.frames[0]); + this.updateFrame(anim.frames[0]); + + var gameObject = this.parent; + var frame = this.currentFrame; + + anim.emit('restart', anim, frame); + + gameObject.emit('animationrestart-' + anim.key, anim, frame, gameObject); + + gameObject.emit('animationrestart', anim, frame, gameObject); return this.parent; }, /** * Immediately stops the current animation from playing and dispatches the `animationcomplete` event. + * + * If no animation is set, no event will be dispatched. + * + * If there is another animation queued (via the `chain` method) then it will start playing immediately. * * @method Phaser.GameObjects.Components.Animation#stop * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent @@ -700,8 +899,26 @@ var Animation = new Class({ this.isPlaying = false; var gameObject = this.parent; + var anim = this.currentAnim; + var frame = this.currentFrame; - gameObject.emit('animationcomplete', this.currentAnim, this.currentFrame); + if (anim) + { + anim.emit('complete', anim, frame); + + gameObject.emit('animationcomplete-' + anim.key, anim, frame, gameObject); + + gameObject.emit('animationcomplete', anim, frame, gameObject); + } + + if (this.nextAnim) + { + var key = this.nextAnim; + + this.nextAnim = null; + + this.play(key); + } return gameObject; }, @@ -749,7 +966,7 @@ var Animation = new Class({ * @fires Phaser.GameObjects.Components.Animation#onCompleteEvent * @since 3.4.0 * - * @param {Phaser.Animations.AnimationFrame} delay - The frame to check before stopping this animation. + * @param {Phaser.Animations.AnimationFrame} frame - The frame to check before stopping this animation. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ @@ -861,6 +1078,11 @@ var Animation = new Class({ gameObject.texture = animationFrame.frame.texture; gameObject.frame = animationFrame.frame; + if (gameObject.isCropped) + { + gameObject.frame.updateCropUVs(gameObject._crop, gameObject.flipX, gameObject.flipY); + } + gameObject.setSizeToFrame(); if (animationFrame.frame.customPivot) @@ -898,7 +1120,9 @@ var Animation = new Class({ var anim = this.currentAnim; - gameObject.emit('animationupdate', anim, animationFrame); + gameObject.emit('animationupdate-' + anim.key, anim, animationFrame, gameObject); + + gameObject.emit('animationupdate', anim, animationFrame, gameObject); if (this._pendingStop === 3 && this._pendingStopValue === animationFrame) { @@ -907,6 +1131,50 @@ var Animation = new Class({ } }, + /** + * Advances the animation to the next frame, regardless of the time or animation state. + * If the animation is set to repeat, or yoyo, this will still take effect. + * + * Calling this does not change the direction of the animation. I.e. if it was currently + * playing in reverse, calling this method doesn't then change the direction to forwards. + * + * @method Phaser.GameObjects.Components.Animation#nextFrame + * @since 3.16.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. + */ + nextFrame: function () + { + if (this.currentAnim) + { + this.currentAnim.nextFrame(this); + } + + return this.parent; + }, + + /** + * Advances the animation to the previous frame, regardless of the time or animation state. + * If the animation is set to repeat, or yoyo, this will still take effect. + * + * Calling this does not change the direction of the animation. I.e. if it was currently + * playing in forwards, calling this method doesn't then change the direction to backwards. + * + * @method Phaser.GameObjects.Components.Animation#previousFrame + * @since 3.16.0 + * + * @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to. + */ + previousFrame: function () + { + if (this.currentAnim) + { + this.currentAnim.previousFrame(this); + } + + return this.parent; + }, + /** * Sets if the current Animation will yoyo when it reaches the end. * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. diff --git a/src/gameobjects/components/BlendMode.js b/src/gameobjects/components/BlendMode.js index 75ed94bb0..f535a15ab 100644 --- a/src/gameobjects/components/BlendMode.js +++ b/src/gameobjects/components/BlendMode.js @@ -37,6 +37,7 @@ var BlendMode = { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -67,7 +68,7 @@ var BlendMode = { value |= 0; - if (value >= 0) + if (value >= -1) { this._blendMode = value; } @@ -85,6 +86,7 @@ var BlendMode = { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -92,7 +94,7 @@ var BlendMode = { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * * @method Phaser.GameObjects.Components.BlendMode#setBlendMode diff --git a/src/gameobjects/components/ComputedSize.js b/src/gameobjects/components/ComputedSize.js index 9000d474f..0b37a71d4 100644 --- a/src/gameobjects/components/ComputedSize.js +++ b/src/gameobjects/components/ComputedSize.js @@ -17,6 +17,10 @@ var ComputedSize = { /** * The native (un-scaled) width of this Game Object. * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * * @name Phaser.GameObjects.Components.ComputedSize#width * @type {number} * @since 3.0.0 @@ -26,6 +30,10 @@ var ComputedSize = { /** * The native (un-scaled) height of this Game Object. * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * * @name Phaser.GameObjects.Components.ComputedSize#height * @type {number} * @since 3.0.0 @@ -34,8 +42,11 @@ var ComputedSize = { /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. * + * Setting this value will adjust the Game Object's scale property. + * * @name Phaser.GameObjects.Components.ComputedSize#displayWidth * @type {number} * @since 3.0.0 @@ -56,8 +67,11 @@ var ComputedSize = { /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. * + * Setting this value will adjust the Game Object's scale property. + * * @name Phaser.GameObjects.Components.ComputedSize#displayHeight * @type {number} * @since 3.0.0 @@ -77,7 +91,15 @@ var ComputedSize = { }, /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * * @method Phaser.GameObjects.Components.ComputedSize#setSize * @since 3.4.0 @@ -97,6 +119,7 @@ var ComputedSize = { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * * @method Phaser.GameObjects.Components.ComputedSize#setDisplaySize diff --git a/src/gameobjects/components/Crop.js b/src/gameobjects/components/Crop.js new file mode 100644 index 000000000..daf70baba --- /dev/null +++ b/src/gameobjects/components/Crop.js @@ -0,0 +1,119 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.Crop + * @since 3.12.0 + */ + +var Crop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.Crop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.Crop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.Crop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.Crop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = Crop; diff --git a/src/gameobjects/components/Mask.js b/src/gameobjects/components/Mask.js index aea9dd1c7..edbf03e3a 100644 --- a/src/gameobjects/components/Mask.js +++ b/src/gameobjects/components/Mask.js @@ -28,12 +28,16 @@ var Mask = { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * * @method Phaser.GameObjects.Components.Mask#setMask * @since 3.6.2 @@ -63,7 +67,7 @@ var Mask = { { if (destroyMask === undefined) { destroyMask = false; } - if (destroyMask) + if (destroyMask && this.mask) { this.mask.destroy(); } diff --git a/src/gameobjects/components/MatrixStack.js b/src/gameobjects/components/MatrixStack.js deleted file mode 100644 index 7857aef00..000000000 --- a/src/gameobjects/components/MatrixStack.js +++ /dev/null @@ -1,282 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Provides methods used for getting and setting the transform values of a Game Object. - * Should be applied as a mixin and not used directly. - * - * @name Phaser.GameObjects.Components.MatrixStack - * @since 3.2.0 - */ - -var MatrixStack = { - - /** - * The matrix stack. - * - * @name Phaser.GameObjects.Components.MatrixStack#matrixStack - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - matrixStack: null, - - /** - * The current matrix. - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrix - * @type {Float32Array} - * @private - * @since 3.2.0 - */ - currentMatrix: null, - - /** - * The current index of the top of the matrix stack. - * - * @name Phaser.GameObjects.Components.MatrixStack#currentMatrixIndex - * @type {integer} - * @private - * @since 3.2.0 - */ - currentMatrixIndex: 0, - - /** - * Initialize the matrix stack. - * - * @method Phaser.GameObjects.Components.MatrixStack#initMatrixStack - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - initMatrixStack: function () - { - this.matrixStack = new Float32Array(6000); // up to 1000 matrices - this.currentMatrix = new Float32Array([ 1, 0, 0, 1, 0, 0 ]); - this.currentMatrixIndex = 0; - - return this; - }, - - /** - * Push the current matrix onto the matrix stack. - * - * @method Phaser.GameObjects.Components.MatrixStack#save - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - save: function () - { - if (this.currentMatrixIndex >= this.matrixStack.length) { return this; } - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - this.currentMatrixIndex += 6; - - matrixStack[currentMatrixIndex + 0] = currentMatrix[0]; - matrixStack[currentMatrixIndex + 1] = currentMatrix[1]; - matrixStack[currentMatrixIndex + 2] = currentMatrix[2]; - matrixStack[currentMatrixIndex + 3] = currentMatrix[3]; - matrixStack[currentMatrixIndex + 4] = currentMatrix[4]; - matrixStack[currentMatrixIndex + 5] = currentMatrix[5]; - - return this; - }, - - /** - * Pop the top of the matrix stack into the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#restore - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - restore: function () - { - if (this.currentMatrixIndex <= 0) { return this; } - - this.currentMatrixIndex -= 6; - - var matrixStack = this.matrixStack; - var currentMatrix = this.currentMatrix; - var currentMatrixIndex = this.currentMatrixIndex; - - currentMatrix[0] = matrixStack[currentMatrixIndex + 0]; - currentMatrix[1] = matrixStack[currentMatrixIndex + 1]; - currentMatrix[2] = matrixStack[currentMatrixIndex + 2]; - currentMatrix[3] = matrixStack[currentMatrixIndex + 3]; - currentMatrix[4] = matrixStack[currentMatrixIndex + 4]; - currentMatrix[5] = matrixStack[currentMatrixIndex + 5]; - - return this; - }, - - /** - * Reset the current matrix to the identity matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#loadIdentity - * @since 3.2.0 - * - * @return {this} This Game Object instance. - */ - loadIdentity: function () - { - this.setTransform(1, 0, 0, 1, 0, 0); - - return this; - }, - - /** - * Transform the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#transform - * @since 3.2.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This Game Object instance. - */ - transform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[0] = m0 * a + m2 * b; - currentMatrix[1] = m1 * a + m3 * b; - currentMatrix[2] = m0 * c + m2 * d; - currentMatrix[3] = m1 * c + m3 * d; - currentMatrix[4] = m0 * tx + m2 * ty + m4; - currentMatrix[5] = m1 * tx + m3 * ty + m5; - - return this; - }, - - /** - * Set a transform matrix as the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#setTransform - * @since 3.2.0 - * - * @param {number} a - The Scale X value. - * @param {number} b - The Shear Y value. - * @param {number} c - The Shear X value. - * @param {number} d - The Scale Y value. - * @param {number} tx - The Translate X value. - * @param {number} ty - The Translate Y value. - * - * @return {this} This Game Object instance. - */ - setTransform: function (a, b, c, d, tx, ty) - { - var currentMatrix = this.currentMatrix; - - currentMatrix[0] = a; - currentMatrix[1] = b; - currentMatrix[2] = c; - currentMatrix[3] = d; - currentMatrix[4] = tx; - currentMatrix[5] = ty; - - return this; - }, - - /** - * Translate the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#translate - * @since 3.2.0 - * - * @param {number} x - The horizontal translation value. - * @param {number} y - The vertical translation value. - * - * @return {this} This Game Object instance. - */ - translate: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var m4 = currentMatrix[4]; - var m5 = currentMatrix[5]; - - currentMatrix[4] = m0 * x + m2 * y + m4; - currentMatrix[5] = m1 * x + m3 * y + m5; - - return this; - }, - - /** - * Scale the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#scale - * @since 3.2.0 - * - * @param {number} x - The horizontal scale value. - * @param {number} y - The vertical scale value. - * - * @return {this} This Game Object instance. - */ - scale: function (x, y) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - - currentMatrix[0] = m0 * x; - currentMatrix[1] = m1 * x; - currentMatrix[2] = m2 * y; - currentMatrix[3] = m3 * y; - - return this; - }, - - /** - * Rotate the current matrix. - * - * @method Phaser.GameObjects.Components.MatrixStack#rotate - * @since 3.2.0 - * - * @param {number} t - The angle of rotation in radians. - * - * @return {this} This Game Object instance. - */ - rotate: function (t) - { - var currentMatrix = this.currentMatrix; - var m0 = currentMatrix[0]; - var m1 = currentMatrix[1]; - var m2 = currentMatrix[2]; - var m3 = currentMatrix[3]; - var st = Math.sin(t); - var ct = Math.cos(t); - - currentMatrix[0] = m0 * ct + m2 * st; - currentMatrix[1] = m1 * ct + m3 * st; - currentMatrix[2] = m0 * -st + m2 * ct; - currentMatrix[3] = m1 * -st + m3 * ct; - - return this; - } - -}; - -module.exports = MatrixStack; diff --git a/src/gameobjects/components/Pipeline.js b/src/gameobjects/components/Pipeline.js index 58f7bb058..ecf550dff 100644 --- a/src/gameobjects/components/Pipeline.js +++ b/src/gameobjects/components/Pipeline.js @@ -44,12 +44,14 @@ var Pipeline = { * @webglOnly * @since 3.0.0 * - * @param {string} pipelineName - The name of the pipeline to set on this Game Object. + * @param {string} [pipelineName=TextureTintPipeline] - The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. * * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. */ initPipeline: function (pipelineName) { + if (pipelineName === undefined) { pipelineName = 'TextureTintPipeline'; } + var renderer = this.scene.sys.game.renderer; if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) @@ -72,7 +74,7 @@ var Pipeline = { * * @param {string} pipelineName - The name of the pipeline to set on this Game Object. * - * @return {boolean} `true` if the pipeline was set successfully, otherwise `false`. + * @return {this} This Game Object instance. */ setPipeline: function (pipelineName) { @@ -81,11 +83,9 @@ var Pipeline = { if (renderer && renderer.gl && renderer.hasPipeline(pipelineName)) { this.pipeline = renderer.getPipeline(pipelineName); - - return true; } - return false; + return this; }, /** diff --git a/src/gameobjects/components/ScrollFactor.js b/src/gameobjects/components/ScrollFactor.js index 3f3cc7eef..a90fe7861 100644 --- a/src/gameobjects/components/ScrollFactor.js +++ b/src/gameobjects/components/ScrollFactor.js @@ -24,6 +24,11 @@ var ScrollFactor = { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorX * @type {number} @@ -43,6 +48,11 @@ var ScrollFactor = { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * * @name Phaser.GameObjects.Components.ScrollFactor#scrollFactorY * @type {number} @@ -62,6 +72,11 @@ var ScrollFactor = { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * * @method Phaser.GameObjects.Components.ScrollFactor#setScrollFactor * @since 3.0.0 diff --git a/src/gameobjects/components/Size.js b/src/gameobjects/components/Size.js index 06d9d8bf7..c9850bb1d 100644 --- a/src/gameobjects/components/Size.js +++ b/src/gameobjects/components/Size.js @@ -27,6 +27,10 @@ var Size = { /** * The native (un-scaled) width of this Game Object. * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + * * @name Phaser.GameObjects.Components.Size#width * @type {number} * @since 3.0.0 @@ -36,6 +40,10 @@ var Size = { /** * The native (un-scaled) height of this Game Object. * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + * * @name Phaser.GameObjects.Components.Size#height * @type {number} * @since 3.0.0 @@ -44,8 +52,11 @@ var Size = { /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. * + * Setting this value will adjust the Game Object's scale property. + * * @name Phaser.GameObjects.Components.Size#displayWidth * @type {number} * @since 3.0.0 @@ -66,8 +77,11 @@ var Size = { /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. * + * Setting this value will adjust the Game Object's scale property. + * * @name Phaser.GameObjects.Components.Size#displayHeight * @type {number} * @since 3.0.0 @@ -89,6 +103,14 @@ var Size = { /** * Sets the size of this Game Object to be that of the given Frame. * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * * @method Phaser.GameObjects.Components.Size#setSizeToFrame * @since 3.0.0 * @@ -107,7 +129,15 @@ var Size = { }, /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * * @method Phaser.GameObjects.Components.Size#setSize * @since 3.0.0 @@ -127,6 +157,7 @@ var Size = { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * * @method Phaser.GameObjects.Components.Size#setDisplaySize diff --git a/src/gameobjects/components/Texture.js b/src/gameobjects/components/Texture.js index 8c07e6c44..e887fa496 100644 --- a/src/gameobjects/components/Texture.js +++ b/src/gameobjects/components/Texture.js @@ -34,6 +34,16 @@ var Texture = { */ frame: null, + /** + * Internal flag. Not to be set by this Game Object. + * + * @name Phaser.GameObjects.Components.Texture#isCropped + * @type {boolean} + * @private + * @since 3.11.0 + */ + isCropped: false, + /** * Sets the texture and frame this Game Object will use to render with. * diff --git a/src/gameobjects/components/TextureCrop.js b/src/gameobjects/components/TextureCrop.js new file mode 100644 index 000000000..273e2cbba --- /dev/null +++ b/src/gameobjects/components/TextureCrop.js @@ -0,0 +1,202 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 + +/** + * Provides methods used for getting and setting the texture of a Game Object. + * + * @name Phaser.GameObjects.Components.TextureCrop + * @since 3.0.0 + */ + +var TextureCrop = { + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + texture: null, + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.Components.TextureCrop#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + frame: null, + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + * + * @name Phaser.GameObjects.Components.TextureCrop#isCropped + * @type {boolean} + * @since 3.11.0 + */ + isCropped: false, + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * + * @method Phaser.GameObjects.Components.TextureCrop#setCrop + * @since 3.11.0 + * + * @param {(number|Phaser.Geom.Rectangle)} [x] - The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param {number} [y] - The y coordinate to start the crop from. + * @param {number} [width] - The width of the crop rectangle in pixels. + * @param {number} [height] - The height of the crop rectangle in pixels. + * + * @return {this} This Game Object instance. + */ + setCrop: function (x, y, width, height) + { + if (x === undefined) + { + this.isCropped = false; + } + else if (this.frame) + { + if (typeof x === 'number') + { + this.frame.setCropUVs(this._crop, x, y, width, height, this.flipX, this.flipY); + } + else + { + var rect = x; + + this.frame.setCropUVs(this._crop, rect.x, rect.y, rect.width, rect.height, this.flipX, this.flipY); + } + + this.isCropped = true; + } + + return this; + }, + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.Components.TextureCrop#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.texture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Components.TextureCrop#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * @param {boolean} [updateSize=true] - Should this call adjust the size of the Game Object? + * @param {boolean} [updateOrigin=true] - Should this call adjust the origin of the Game Object? + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame, updateSize, updateOrigin) + { + if (updateSize === undefined) { updateSize = true; } + if (updateOrigin === undefined) { updateOrigin = true; } + + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + if (this._sizeComponent && updateSize) + { + this.setSizeToFrame(); + } + + if (this._originComponent && updateOrigin) + { + if (this.frame.customPivot) + { + this.setOrigin(this.frame.pivotX, this.frame.pivotY); + } + else + { + this.updateDisplayOrigin(); + } + } + + if (this.isCropped) + { + this.frame.updateCropUVs(this._crop, this.flipX, this.flipY); + } + + return this; + }, + + /** + * Internal method that returns a blank, well-formed crop object for use by a Game Object. + * + * @method Phaser.GameObjects.Components.TextureCrop#resetCropObject + * @private + * @since 3.12.0 + * + * @return {object} The crop object. + */ + resetCropObject: function () + { + return { u0: 0, v0: 0, u1: 0, v1: 0, width: 0, height: 0, x: 0, y: 0, flipX: false, flipY: false, cx: 0, cy: 0, cw: 0, ch: 0 }; + } + +}; + +module.exports = TextureCrop; diff --git a/src/gameobjects/components/Tint.js b/src/gameobjects/components/Tint.js index cd49fcf88..478172ece 100644 --- a/src/gameobjects/components/Tint.js +++ b/src/gameobjects/components/Tint.js @@ -69,9 +69,32 @@ var Tint = { */ _tintBR: 16777215, + /** + * Private internal value. Holds if the Game Object is tinted or not. + * + * @name Phaser.GameObjects.Components.Tint#_isTinted + * @type {boolean} + * @private + * @default false + * @since 3.11.0 + */ + _isTinted: false, + + /** + * Fill or additive? + * + * @name Phaser.GameObjects.Components.Tint#tintFill + * @type {boolean} + * @default false + * @since 3.11.0 + */ + tintFill: false, + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. * * @method Phaser.GameObjects.Components.Tint#clearTint * @webglOnly @@ -83,17 +106,32 @@ var Tint = { { this.setTint(0xffffff); + this._isTinted = false; + return this; }, /** - * Sets the tint values for this Game Object. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. * * @method Phaser.GameObjects.Components.Tint#setTint * @webglOnly * @since 3.0.0 * - * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. @@ -116,6 +154,47 @@ var Tint = { this._tintBL = GetColor(bottomLeft); this._tintBR = GetColor(bottomRight); + this._isTinted = true; + + this.tintFill = false; + + return this; + }, + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * + * @method Phaser.GameObjects.Components.Tint#setTintFill + * @webglOnly + * @since 3.11.0 + * + * @param {integer} [topLeft=0xffffff] - The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. + * @param {integer} [topRight] - The tint being applied to the top-right of the Game Object. + * @param {integer} [bottomLeft] - The tint being applied to the bottom-left of the Game Object. + * @param {integer} [bottomRight] - The tint being applied to the bottom-right of the Game Object. + * + * @return {this} This Game Object instance. + */ + setTintFill: function (topLeft, topRight, bottomLeft, bottomRight) + { + this.setTint(topLeft, topRight, bottomLeft, bottomRight); + + this.tintFill = true; + return this; }, @@ -138,6 +217,7 @@ var Tint = { set: function (value) { this._tintTL = GetColor(value); + this._isTinted = true; } }, @@ -161,6 +241,7 @@ var Tint = { set: function (value) { this._tintTR = GetColor(value); + this._isTinted = true; } }, @@ -184,6 +265,7 @@ var Tint = { set: function (value) { this._tintBL = GetColor(value); + this._isTinted = true; } }, @@ -207,6 +289,7 @@ var Tint = { set: function (value) { this._tintBR = GetColor(value); + this._isTinted = true; } }, @@ -225,6 +308,24 @@ var Tint = { { this.setTint(value, value, value, value); } + }, + + /** + * Does this Game Object have a tint applied to it or not? + * + * @name Phaser.GameObjects.Components.Tint#isTinted + * @type {boolean} + * @webglOnly + * @readonly + * @since 3.11.0 + */ + isTinted: { + + get: function () + { + return this._isTinted; + } + } }; diff --git a/src/gameobjects/components/Transform.js b/src/gameobjects/components/Transform.js index b974c203b..89b5629aa 100644 --- a/src/gameobjects/components/Transform.js +++ b/src/gameobjects/components/Transform.js @@ -427,12 +427,14 @@ var Transform = { * @since 3.4.0 * * @param {Phaser.GameObjects.Components.TransformMatrix} [tempMatrix] - The matrix to populate with the values from this Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A temporary matrix to hold parent values during the calculations. * * @return {Phaser.GameObjects.Components.TransformMatrix} The populated Transform Matrix. */ - getWorldTransformMatrix: function (tempMatrix) + getWorldTransformMatrix: function (tempMatrix, parentMatrix) { if (tempMatrix === undefined) { tempMatrix = new TransformMatrix(); } + if (parentMatrix === undefined) { parentMatrix = new TransformMatrix(); } var parent = this.parentContainer; @@ -441,31 +443,17 @@ var Transform = { return this.getLocalTransformMatrix(tempMatrix); } - var parents = []; - + tempMatrix.applyITRS(this.x, this.y, this._rotation, this._scaleX, this._scaleY); + while (parent) { - parents.unshift(parent); + parentMatrix.applyITRS(parent.x, parent.y, parent._rotation, parent._scaleX, parent._scaleY); + + parentMatrix.multiply(tempMatrix, tempMatrix); + parent = parent.parentContainer; } - tempMatrix.loadIdentity(); - - var length = parents.length; - - for (var i = 0; i < length; ++i) - { - parent = parents[i]; - - tempMatrix.translate(parent.x, parent.y); - tempMatrix.rotate(parent.rotation); - tempMatrix.scale(parent.scaleX, parent.scaleY); - } - - tempMatrix.translate(this.x, this.y); - tempMatrix.rotate(this._rotation); - tempMatrix.scale(this._scaleX, this._scaleY); - return tempMatrix; } diff --git a/src/gameobjects/components/TransformMatrix.js b/src/gameobjects/components/TransformMatrix.js index 805c2614f..ab9ac0c02 100644 --- a/src/gameobjects/components/TransformMatrix.js +++ b/src/gameobjects/components/TransformMatrix.js @@ -5,6 +5,7 @@ */ var Class = require('../../utils/Class'); +var Vector2 = require('../../math/Vector2'); /** * @classdesc @@ -19,7 +20,7 @@ var Class = require('../../utils/Class'); * ``` * * @class TransformMatrix - * @memberOf Phaser.GameObjects.Components + * @memberof Phaser.GameObjects.Components * @constructor * @since 3.0.0 * @@ -152,6 +153,48 @@ var TransformMatrix = new Class({ }, + /** + * The Translate X value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#e + * @type {number} + * @since 3.11.0 + */ + e: { + + get: function () + { + return this.matrix[4]; + }, + + set: function (value) + { + this.matrix[4] = value; + } + + }, + + /** + * The Translate Y value. + * + * @name Phaser.GameObjects.Components.TransformMatrix#f + * @type {number} + * @since 3.11.0 + */ + f: { + + get: function () + { + return this.matrix[5]; + }, + + set: function (value) + { + this.matrix[5] = value; + } + + }, + /** * The Translate X value. * @@ -199,7 +242,7 @@ var TransformMatrix = new Class({ * * @name Phaser.GameObjects.Components.TransformMatrix#rotation * @type {number} - * @readOnly + * @readonly * @since 3.4.0 */ rotation: { @@ -216,7 +259,7 @@ var TransformMatrix = new Class({ * * @name Phaser.GameObjects.Components.TransformMatrix#scaleX * @type {number} - * @readOnly + * @readonly * @since 3.4.0 */ scaleX: { @@ -233,7 +276,7 @@ var TransformMatrix = new Class({ * * @name Phaser.GameObjects.Components.TransformMatrix#scaleY * @type {number} - * @readOnly + * @readonly * @since 3.4.0 */ scaleY: { @@ -317,42 +360,95 @@ var TransformMatrix = new Class({ * @method Phaser.GameObjects.Components.TransformMatrix#rotate * @since 3.0.0 * - * @param {number} radian - The angle of rotation in radians. + * @param {number} angle - The angle of rotation in radians. * * @return {this} This TransformMatrix. */ - rotate: function (radian) + rotate: function (angle) { - var radianSin = Math.sin(radian); - var radianCos = Math.cos(radian); + var sin = Math.sin(angle); + var cos = Math.cos(angle); + var matrix = this.matrix; + var a = matrix[0]; var b = matrix[1]; var c = matrix[2]; var d = matrix[3]; - matrix[0] = a * radianCos + c * radianSin; - matrix[1] = b * radianCos + d * radianSin; - matrix[2] = a * -radianSin + c * radianCos; - matrix[3] = b * -radianSin + d * radianCos; + matrix[0] = a * cos + c * sin; + matrix[1] = b * cos + d * sin; + matrix[2] = a * -sin + c * cos; + matrix[3] = b * -sin + d * cos; return this; }, /** * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. * * @method Phaser.GameObjects.Components.TransformMatrix#multiply * @since 3.0.0 * * @param {Phaser.GameObjects.Components.TransformMatrix} rhs - The Matrix to multiply by. + * @param {Phaser.GameObjects.Components.TransformMatrix} [out] - An optional Matrix to store the results in. + * + * @return {Phaser.GameObjects.Components.TransformMatrix} Either this TransformMatrix, or the `out` Matrix, if given in the arguments. + */ + multiply: function (rhs, out) + { + var matrix = this.matrix; + var source = rhs.matrix; + + var localA = matrix[0]; + var localB = matrix[1]; + var localC = matrix[2]; + var localD = matrix[3]; + var localE = matrix[4]; + var localF = matrix[5]; + + var sourceA = source[0]; + var sourceB = source[1]; + var sourceC = source[2]; + var sourceD = source[3]; + var sourceE = source[4]; + var sourceF = source[5]; + + var destinationMatrix = (out === undefined) ? this : out; + + destinationMatrix.a = (sourceA * localA) + (sourceB * localC); + destinationMatrix.b = (sourceA * localB) + (sourceB * localD); + destinationMatrix.c = (sourceC * localA) + (sourceD * localC); + destinationMatrix.d = (sourceC * localB) + (sourceD * localD); + destinationMatrix.e = (sourceE * localA) + (sourceF * localC) + localE; + destinationMatrix.f = (sourceE * localB) + (sourceF * localD) + localF; + + return destinationMatrix; + }, + + /** + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#multiplyWithOffset + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * @param {number} offsetX - Horizontal offset to factor in to the multiplication. + * @param {number} offsetY - Vertical offset to factor in to the multiplication. * * @return {this} This TransformMatrix. */ - multiply: function (rhs) + multiplyWithOffset: function (src, offsetX, offsetY) { var matrix = this.matrix; - var otherMatrix = rhs.matrix; + var otherMatrix = src.matrix; var a0 = matrix[0]; var b0 = matrix[1]; @@ -361,6 +457,9 @@ var TransformMatrix = new Class({ var tx0 = matrix[4]; var ty0 = matrix[5]; + var pse = offsetX * a0 + offsetY * c0 + tx0; + var psf = offsetX * b0 + offsetY * d0 + ty0; + var a1 = otherMatrix[0]; var b1 = otherMatrix[1]; var c1 = otherMatrix[2]; @@ -372,8 +471,8 @@ var TransformMatrix = new Class({ matrix[1] = a1 * b0 + b1 * d0; matrix[2] = c1 * a0 + d1 * c0; matrix[3] = c1 * b0 + d1 * d0; - matrix[4] = tx1 * a0 + ty1 * c0 + tx0; - matrix[5] = tx1 * b0 + ty1 * d0 + ty0; + matrix[4] = tx1 * a0 + ty1 * c0 + pse; + matrix[5] = tx1 * b0 + ty1 * d0 + psf; return this; }, @@ -476,6 +575,128 @@ var TransformMatrix = new Class({ return this; }, + /** + * Set the values of this Matrix to copy those of the matrix given. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFrom + * @since 3.11.0 + * + * @param {Phaser.GameObjects.Components.TransformMatrix} src - The source Matrix to copy from. + * + * @return {this} This TransformMatrix. + */ + copyFrom: function (src) + { + var matrix = this.matrix; + + matrix[0] = src.a; + matrix[1] = src.b; + matrix[2] = src.c; + matrix[3] = src.d; + matrix[4] = src.e; + matrix[5] = src.f; + + return this; + }, + + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyFromArray + * @since 3.11.0 + * + * @param {array} src - The array of values to set into this matrix. + * + * @return {this} This TransformMatrix. + */ + copyFromArray: function (src) + { + var matrix = this.matrix; + + matrix[0] = src[0]; + matrix[1] = src[1]; + matrix[2] = src[2]; + matrix[3] = src[3]; + matrix[4] = src[4]; + matrix[5] = src[5]; + + return this; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + copyToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * + * @method Phaser.GameObjects.Components.TransformMatrix#setToContext + * @since 3.12.0 + * + * @param {CanvasRenderingContext2D} ctx - The Canvas Rendering Context to copy the matrix values to. + * + * @return {CanvasRenderingContext2D} The Canvas Rendering Context. + */ + setToContext: function (ctx) + { + var matrix = this.matrix; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + return ctx; + }, + + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * + * @method Phaser.GameObjects.Components.TransformMatrix#copyToArray + * @since 3.12.0 + * + * @param {array} [out] - The array to copy the matrix values in to. + * + * @return {array} An array where elements 0 to 5 contain the values from this matrix. + */ + copyToArray: function (out) + { + var matrix = this.matrix; + + if (out === undefined) + { + out = [ matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5] ]; + } + else + { + out[0] = matrix[0]; + out[1] = matrix[1]; + out[2] = matrix[2]; + out[3] = matrix[3]; + out[4] = matrix[4]; + out[5] = matrix[5]; + } + + return out; + }, + /** * Set the values of this Matrix. * @@ -506,7 +727,11 @@ var TransformMatrix = new Class({ }, /** - * Decompose this Matrix into its translation, scale and rotation values. + * Decompose this Matrix into its translation, scale and rotation values using QR decomposition. + * + * The result must be applied in the following order to reproduce the current matrix: + * + * translate -> rotate -> scale * * @method Phaser.GameObjects.Components.TransformMatrix#decomposeMatrix * @since 3.0.0 @@ -529,21 +754,33 @@ var TransformMatrix = new Class({ var c = matrix[2]; var d = matrix[3]; - var a2 = a * a; - var b2 = b * b; - var c2 = c * c; - var d2 = d * d; - - var sx = Math.sqrt(a2 + c2); - var sy = Math.sqrt(b2 + d2); + var determ = a * d - b * c; decomposedMatrix.translateX = matrix[4]; decomposedMatrix.translateY = matrix[5]; - decomposedMatrix.scaleX = sx; - decomposedMatrix.scaleY = sy; + if (a || b) + { + var r = Math.sqrt(a * a + b * b); - decomposedMatrix.rotation = Math.acos(a / sx) * (Math.atan(-c / a) < 0 ? -1 : 1); + decomposedMatrix.rotation = (b > 0) ? Math.acos(a / r) : -Math.acos(a / r); + decomposedMatrix.scaleX = r; + decomposedMatrix.scaleY = determ / r; + } + else if (c || d) + { + var s = Math.sqrt(c * c + d * d); + + decomposedMatrix.rotation = Math.PI * 0.5 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s)); + decomposedMatrix.scaleX = determ / s; + decomposedMatrix.scaleY = s; + } + else + { + decomposedMatrix.rotation = 0; + decomposedMatrix.scaleX = 0; + decomposedMatrix.scaleY = 0; + } return decomposedMatrix; }, @@ -582,6 +819,91 @@ var TransformMatrix = new Class({ return this; }, + /** + * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of + * the current matrix with its transformation applied. + * + * Can be used to translate points from world to local space. + * + * @method Phaser.GameObjects.Components.TransformMatrix#applyInverse + * @since 3.12.0 + * + * @param {number} x - The x position to translate. + * @param {number} y - The y position to translate. + * @param {Phaser.Math.Vector2} [output] - A Vector2, or point-like object, to store the results in. + * + * @return {Phaser.Math.Vector2} The coordinates, inverse-transformed through this matrix. + */ + applyInverse: function (x, y, output) + { + if (output === undefined) { output = new Vector2(); } + + var matrix = this.matrix; + + var a = matrix[0]; + var b = matrix[1]; + var c = matrix[2]; + var d = matrix[3]; + var tx = matrix[4]; + var ty = matrix[5]; + + var id = 1 / ((a * d) + (c * -b)); + + output.x = (d * id * x) + (-c * id * y) + (((ty * c) - (tx * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-ty * a) + (tx * b)) * id); + + return output; + }, + + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getX + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated x value. + */ + getX: function (x, y) + { + return x * this.a + y * this.c + this.e; + }, + + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getY + * @since 3.12.0 + * + * @param {number} x - The x value. + * @param {number} y - The y value. + * + * @return {number} The calculated y value. + */ + getY: function (x, y) + { + return x * this.b + y * this.d + this.f; + }, + + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + * + * @method Phaser.GameObjects.Components.TransformMatrix#getCSSMatrix + * @since 3.12.0 + * + * @return {string} A string containing the CSS Transform matrix values. + */ + getCSSMatrix: function () + { + var m = this.matrix; + + return 'matrix(' + m[0] + ',' + m[1] + ',' + m[2] + ',' + m[3] + ',' + m[4] + ',' + m[5] + ')'; + }, + /** * Destroys this Transform Matrix. * diff --git a/src/gameobjects/components/index.js b/src/gameobjects/components/index.js index 6885423c5..b6b038642 100644 --- a/src/gameobjects/components/index.js +++ b/src/gameobjects/components/index.js @@ -14,17 +14,18 @@ module.exports = { Animation: require('./Animation'), BlendMode: require('./BlendMode'), ComputedSize: require('./ComputedSize'), + Crop: require('./Crop'), Depth: require('./Depth'), Flip: require('./Flip'), GetBounds: require('./GetBounds'), Mask: require('./Mask'), - MatrixStack: require('./MatrixStack'), Origin: require('./Origin'), Pipeline: require('./Pipeline'), ScaleMode: require('./ScaleMode'), ScrollFactor: require('./ScrollFactor'), Size: require('./Size'), Texture: require('./Texture'), + TextureCrop: require('./TextureCrop'), Tint: require('./Tint'), ToJSON: require('./ToJSON'), Transform: require('./Transform'), diff --git a/src/gameobjects/container/Container.js b/src/gameobjects/container/Container.js index 67b2de884..61396731c 100644 --- a/src/gameobjects/container/Container.js +++ b/src/gameobjects/container/Container.js @@ -6,6 +6,7 @@ */ var ArrayUtils = require('../../utils/array'); +var BlendModes = require('../../renderer/BlendModes'); var Class = require('../../utils/Class'); var Components = require('../components'); var GameObject = require('../GameObject'); @@ -52,7 +53,7 @@ var Vector2 = require('../../math/Vector2'); * * @class Container * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.4.0 * @@ -195,6 +196,8 @@ var Container = new Class({ this.clearAlpha(); + this.setBlendMode(BlendModes.SKIP_CHECK); + if (children) { this.add(children); @@ -207,7 +210,7 @@ var Container = new Class({ * * @name Phaser.GameObjects.Container#originX * @type {number} - * @readOnly + * @readonly * @since 3.4.0 */ originX: { @@ -225,7 +228,7 @@ var Container = new Class({ * * @name Phaser.GameObjects.Container#originY * @type {number} - * @readOnly + * @readonly * @since 3.4.0 */ originY: { @@ -243,7 +246,7 @@ var Container = new Class({ * * @name Phaser.GameObjects.Container#displayOriginX * @type {number} - * @readOnly + * @readonly * @since 3.4.0 */ displayOriginX: { @@ -261,7 +264,7 @@ var Container = new Class({ * * @name Phaser.GameObjects.Container#displayOriginY * @type {number} - * @readOnly + * @readonly * @since 3.4.0 */ displayOriginY: { @@ -373,10 +376,6 @@ var Container = new Class({ gameObject.parentContainer = this; } - - // Game Objects automatically listen to the Scene shutdown event, but - // we don't need this if they're in a Container - this._sysEvents.off('shutdown', gameObject.destroy, gameObject); }, /** @@ -395,8 +394,6 @@ var Container = new Class({ if (this.exclusive) { gameObject.parentContainer = null; - - this._sysEvents.once('shutdown', gameObject.destroy, gameObject); } }, @@ -435,6 +432,7 @@ var Container = new Class({ /** * Returns the world transform matrix as used for Bounds checks. + * * The returned matrix is temporal and shouldn't be stored. * * @method Phaser.GameObjects.Container#getBoundsTransformMatrix @@ -444,7 +442,7 @@ var Container = new Class({ */ getBoundsTransformMatrix: function () { - return this.getWorldTransformMatrix(this.tempTransformMatrix); + return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform); }, /** @@ -612,7 +610,7 @@ var Container = new Class({ */ getFirst: function (property, value, startIndex, endIndex) { - return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); + return ArrayUtils.GetFirst(this.list, property, value, startIndex, endIndex); }, /** @@ -1086,7 +1084,7 @@ var Container = new Class({ * * @name Phaser.GameObjects.Container#length * @type {integer} - * @readOnly + * @readonly * @since 3.4.0 */ length: { @@ -1105,7 +1103,7 @@ var Container = new Class({ * * @name Phaser.GameObjects.Container#first * @type {?Phaser.GameObjects.GameObject} - * @readOnly + * @readonly * @since 3.4.0 */ first: { @@ -1133,7 +1131,7 @@ var Container = new Class({ * * @name Phaser.GameObjects.Container#last * @type {?Phaser.GameObjects.GameObject} - * @readOnly + * @readonly * @since 3.4.0 */ last: { @@ -1161,7 +1159,7 @@ var Container = new Class({ * * @name Phaser.GameObjects.Container#next * @type {?Phaser.GameObjects.GameObject} - * @readOnly + * @readonly * @since 3.4.0 */ next: { @@ -1189,7 +1187,7 @@ var Container = new Class({ * * @name Phaser.GameObjects.Container#previous * @type {?Phaser.GameObjects.GameObject} - * @readOnly + * @readonly * @since 3.4.0 */ previous: { diff --git a/src/gameobjects/container/ContainerCanvasRenderer.js b/src/gameobjects/container/ContainerCanvasRenderer.js index 434581252..02bafdaf2 100644 --- a/src/gameobjects/container/ContainerCanvasRenderer.js +++ b/src/gameobjects/container/ContainerCanvasRenderer.js @@ -5,8 +5,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -24,19 +22,16 @@ var GameObject = require('../GameObject'); */ var ContainerCanvasRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== container.renderFlags || (container.cameraFilter > 0 && (container.cameraFilter & camera._id))) + var children = container.list; + + if (children.length === 0) { return; } - var children = container.list; var transformMatrix = container.localTransform; - if (parentMatrix === undefined) - { - transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); - } - else + if (parentMatrix) { transformMatrix.loadIdentity(); transformMatrix.multiply(parentMatrix); @@ -44,23 +39,53 @@ var ContainerCanvasRenderer = function (renderer, container, interpolationPercen transformMatrix.rotate(container.rotation); transformMatrix.scale(container.scaleX, container.scaleY); } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode) + { + // If Container is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } var alpha = container._alpha; var scrollFactorX = container.scrollFactorX; var scrollFactorY = container.scrollFactorY; - for (var index = 0; index < children.length; ++index) + for (var i = 0; i < children.length; i++) { - var child = children[index]; + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + var childAlpha = child._alpha; + var childBlendMode = child._blendMode; var childScrollFactorX = child.scrollFactorX; var childScrollFactorY = child.scrollFactorY; + // Set parent values child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); child.setAlpha(childAlpha * alpha); + + if (containerHasBlendMode) + { + child.setBlendMode(container._blendMode); + } + + // Render child.renderCanvas(renderer, child, interpolationPercentage, camera, transformMatrix); + + // Restore original values child.setAlpha(childAlpha); child.setScrollFactor(childScrollFactorX, childScrollFactorY); + child.setBlendMode(childBlendMode); } }; diff --git a/src/gameobjects/container/ContainerWebGLRenderer.js b/src/gameobjects/container/ContainerWebGLRenderer.js index 19e114d1a..f59066313 100644 --- a/src/gameobjects/container/ContainerWebGLRenderer.js +++ b/src/gameobjects/container/ContainerWebGLRenderer.js @@ -5,8 +5,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the WebGL Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -24,19 +22,16 @@ var GameObject = require('../GameObject'); */ var ContainerWebGLRenderer = function (renderer, container, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== container.renderFlags || (container.cameraFilter > 0 && (container.cameraFilter & camera._id))) + var children = container.list; + + if (children.length === 0) { return; } - var children = container.list; var transformMatrix = container.localTransform; - if (parentMatrix === undefined) - { - transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); - } - else + if (parentMatrix) { transformMatrix.loadIdentity(); transformMatrix.multiply(parentMatrix); @@ -44,21 +39,50 @@ var ContainerWebGLRenderer = function (renderer, container, interpolationPercent transformMatrix.rotate(container.rotation); transformMatrix.scale(container.scaleX, container.scaleY); } + else + { + transformMatrix.applyITRS(container.x, container.y, container.rotation, container.scaleX, container.scaleY); + } + + var containerHasBlendMode = (container.blendMode !== -1); + + if (!containerHasBlendMode) + { + // If Container is SKIP_TEST then set blend mode to be Normal + renderer.setBlendMode(0); + } var alpha = container._alpha; var scrollFactorX = container.scrollFactorX; var scrollFactorY = container.scrollFactorY; - for (var index = 0; index < children.length; ++index) + for (var i = 0; i < children.length; i++) { - var child = children[index]; + var child = children[i]; + + if (!child.willRender(camera)) + { + continue; + } + var childAlpha = child._alpha; var childScrollFactorX = child.scrollFactorX; var childScrollFactorY = child.scrollFactorY; + if (!containerHasBlendMode && child.blendMode !== renderer.currentBlendMode) + { + // If Container doesn't have its own blend mode, then a child can have one + renderer.setBlendMode(child.blendMode); + } + + // Set parent values child.setScrollFactor(childScrollFactorX * scrollFactorX, childScrollFactorY * scrollFactorY); child.setAlpha(childAlpha * alpha); + + // Render child.renderWebGL(renderer, child, interpolationPercentage, camera, transformMatrix); + + // Restore original values child.setAlpha(childAlpha); child.setScrollFactor(childScrollFactorX, childScrollFactorY); } diff --git a/src/gameobjects/domelement/CSSBlendModes.js b/src/gameobjects/domelement/CSSBlendModes.js new file mode 100644 index 000000000..ea33d0fb2 --- /dev/null +++ b/src/gameobjects/domelement/CSSBlendModes.js @@ -0,0 +1,35 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Phaser Blend Modes to CSS Blend Modes Map. + * + * @name Phaser.CSSBlendModes + * @enum {string} + * @memberof Phaser + * @readonly + * @since 3.12.0 + */ + +module.exports = [ + 'normal', + 'multiply', + 'multiply', + 'screen', + 'overlay', + 'darken', + 'lighten', + 'color-dodge', + 'color-burn', + 'hard-light', + 'soft-light', + 'difference', + 'exclusion', + 'hue', + 'saturation', + 'color', + 'luminosity' +]; diff --git a/src/gameobjects/domelement/DOMElement.js b/src/gameobjects/domelement/DOMElement.js new file mode 100644 index 000000000..2e40120cc --- /dev/null +++ b/src/gameobjects/domelement/DOMElement.js @@ -0,0 +1,304 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../utils/Class'); +var Components = require('../components'); +var DOMElementRender = require('./DOMElementRender'); +var GameObject = require('../GameObject'); +var RemoveFromDOM = require('../../dom/RemoveFromDOM'); +var Vector4 = require('../../math/Vector4'); + +/** + * @classdesc + * [description] + * + * @class DOMElement + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.12.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {(string|HTMLElement)} [element] - The DOM Element to use. + */ +var DOMElement = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.Origin, + Components.ScrollFactor, + Components.Transform, + Components.Visible, + DOMElementRender + ], + + initialize: + + function DOMElement (scene, x, y, element) + { + GameObject.call(this, scene, 'DOMElement'); + + this.parent = scene.sys.game.domContainer; + + this.cache = scene.sys.cache.html; + + this.node; + + this.skewX = 0; + this.skewY = 0; + + // https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/rotate3d + this.rotate3d = new Vector4(); + this.rotate3dAngle = 'deg'; + + this.handler = this.dispatchNativeEvent.bind(this); + + this.setPosition(x, y); + + if (element) + { + this.setElement(element); + } + }, + + setSkew: function (x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = x; } + + this.skewX = x; + this.skewY = y; + + return this; + }, + + perspective: { + + get: function () + { + return parseFloat(this.parent.style.perspective); + }, + + set: function (value) + { + this.parent.style.perspective = value + 'px'; + } + + }, + + setPerspective: function (value) + { + // Sets it on the DOM Container! + this.parent.style.perspective = value + 'px'; + + return this; + }, + + addListener: function (events) + { + if (this.node) + { + events = events.split(' '); + + for (var i = 0; i < events.length; i++) + { + this.node.addEventListener(events[i], this.handler, false); + } + } + + return this; + }, + + removeListener: function (events) + { + if (this.node) + { + events = events.split(' '); + + for (var i = 0; i < events.length; i++) + { + this.node.removeEventListener(events[i], this.handler); + } + } + + return this; + }, + + dispatchNativeEvent: function (event) + { + this.emit(event.type, event); + }, + + setElement: function (element) + { + var target; + + if (typeof element === 'string') + { + target = document.getElementById(element); + } + else if (typeof element === 'object' && element.nodeType === 1) + { + target = element; + } + + if (!target) + { + return; + } + + this.node = target; + + target.style.zIndex = '0'; + target.style.display = 'inline'; + target.style.position = 'absolute'; + + // Node handler + + target.phaser = this; + + if (this.parent) + { + this.parent.appendChild(target); + } + + var nodeBounds = target.getBoundingClientRect(); + + this.setSize(nodeBounds.width || 0, nodeBounds.height || 0); + + return this; + }, + + createFromCache: function (key, elementType) + { + return this.createFromHTML(this.cache.get(key), elementType); + }, + + createFromHTML: function (html, elementType) + { + if (elementType === undefined) { elementType = 'div'; } + + var element = document.createElement(elementType); + + this.node = element; + + element.style.zIndex = '0'; + element.style.display = 'inline'; + element.style.position = 'absolute'; + + // Node handler + + element.phaser = this; + + if (this.parent) + { + this.parent.appendChild(element); + } + + element.innerHTML = html; + + var nodeBounds = element.getBoundingClientRect(); + + this.setSize(nodeBounds.width || 0, nodeBounds.height || 0); + + return this; + }, + + getChildByProperty: function (property, value) + { + if (this.node) + { + var children = this.node.querySelectorAll('*'); + + for (var i = 0; i < children.length; i++) + { + if (children[i][property] === value) + { + return children[i]; + } + } + } + + return null; + }, + + getChildByID: function (id) + { + return this.getChildByProperty('id', id); + }, + + getChildByName: function (name) + { + return this.getChildByProperty('name', name); + }, + + setText: function (text) + { + if (this.node) + { + this.node.innerText = text; + + var nodeBounds = this.node.getBoundingClientRect(); + + this.setSize(nodeBounds.width, nodeBounds.height); + } + + return this; + }, + + setHTML: function (html) + { + if (this.node) + { + this.node.innerHTML = html; + + var nodeBounds = this.node.getBoundingClientRect(); + + this.setSize(nodeBounds.width, nodeBounds.height); + } + + return this; + }, + + /** + * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * + * DOMElements always return `true` as they need to still set values during the render pass, even if not visible. + * + * @method Phaser.GameObjects.DOMElement#willRender + * @since 3.12.0 + * + * @return {boolean} True if the Game Object should be rendered, otherwise false. + */ + willRender: function () + { + return true; + }, + + destroy: function () + { + RemoveFromDOM(this.node); + } + +}); + +module.exports = DOMElement; diff --git a/src/gameobjects/domelement/DOMElementCSSRenderer.js b/src/gameobjects/domelement/DOMElementCSSRenderer.js new file mode 100644 index 000000000..9d006574d --- /dev/null +++ b/src/gameobjects/domelement/DOMElementCSSRenderer.js @@ -0,0 +1,69 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CSSBlendModes = require('./CSSBlendModes'); +var GameObject = require('../GameObject'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.DOMElement#renderWebGL + * @since 3.12.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active renderer. + * @param {Phaser.GameObjects.DOMElement} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + */ +var DOMElementCSSRenderer = function (renderer, src, interpolationPercentage, camera) +{ + var node = src.node; + + if (!node || GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter !== 0 && (src.cameraFilter & camera.id))) + { + if (node) + { + node.style.display = 'none'; + } + + return; + } + + var camMatrix = renderer._tempMatrix1; + var spriteMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + var x = src.originX * src.width; + var y = src.originY * src.height; + + spriteMatrix.applyITRS(src.x - x - (camera.scrollX * src.scrollFactorX), src.y - y - (camera.scrollY * src.scrollFactorY), src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + camMatrix.multiply(spriteMatrix, calcMatrix); + + node.style.display = 'block'; + node.style.opacity = src.alpha; + node.style.zIndex = src._depth; + node.style.pointerEvents = 'auto'; + node.style.mixBlendMode = CSSBlendModes[src._blendMode]; + + // https://developer.mozilla.org/en-US/docs/Web/CSS/transform + + node.style.transform = + calcMatrix.getCSSMatrix() + + ' skew(' + src.skewX + 'rad, ' + src.skewY + 'rad)' + + ' rotate3d(' + src.rotate3d.x + ',' + src.rotate3d.y + ',' + src.rotate3d.z + ',' + src.rotate3d.w + src.rotate3dAngle + ')'; + + // node.style.transform = calcMatrix.getCSSMatrix(); + + node.style.transformOrigin = (100 * src.originX) + '% ' + (100 * src.originY) + '%'; +}; + +module.exports = DOMElementCSSRenderer; diff --git a/src/gameobjects/domelement/DOMElementFactory.js b/src/gameobjects/domelement/DOMElementFactory.js new file mode 100644 index 000000000..4d46fc994 --- /dev/null +++ b/src/gameobjects/domelement/DOMElementFactory.js @@ -0,0 +1,35 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DOMElement = require('./DOMElement'); +var GameObjectFactory = require('../GameObjectFactory'); + +/** + * Creates a new Image Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Image Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#dom + * @since 3.12.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} element - The DOM element. + * + * @return {Phaser.GameObjects.DOMElement} The Game Object that was created. + */ +GameObjectFactory.register('dom', function (x, y, element) +{ + return this.displayList.add(new DOMElement(this.scene, x, y, element)); +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns diff --git a/src/gameobjects/domelement/DOMElementRender.js b/src/gameobjects/domelement/DOMElementRender.js new file mode 100644 index 000000000..8dd2c34fc --- /dev/null +++ b/src/gameobjects/domelement/DOMElementRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../utils/NOOP'); +var renderCanvas = require('../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./DOMElementCSSRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./DOMElementCSSRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/extern/Extern.js b/src/gameobjects/extern/Extern.js new file mode 100644 index 000000000..f39a7d2f6 --- /dev/null +++ b/src/gameobjects/extern/Extern.js @@ -0,0 +1,78 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../utils/Class'); +var Components = require('../components'); +var GameObject = require('../GameObject'); +var ExternRender = require('./ExternRender'); + +/** + * @classdesc + * An Extern Game Object. + * + * @class Extern + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.16.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Flip + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Size + * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.Tint + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + */ +var Extern = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.Depth, + Components.Flip, + Components.Origin, + Components.ScaleMode, + Components.ScrollFactor, + Components.Size, + Components.Texture, + Components.Tint, + Components.Transform, + Components.Visible, + ExternRender + ], + + initialize: + + function Extern (scene) + { + GameObject.call(this, scene, 'Extern'); + }, + + preUpdate: function () + { + // override this! + // Arguments: time, delta + }, + + render: function () + { + // override this! + // Arguments: renderer, camera, calcMatrix + } + +}); + +module.exports = Extern; diff --git a/src/gameobjects/extern/ExternCanvasRenderer.js b/src/gameobjects/extern/ExternCanvasRenderer.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/gameobjects/extern/ExternFactory.js b/src/gameobjects/extern/ExternFactory.js new file mode 100644 index 000000000..1f064d6ba --- /dev/null +++ b/src/gameobjects/extern/ExternFactory.js @@ -0,0 +1,41 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Extern = require('./Extern'); +var GameObjectFactory = require('../GameObjectFactory'); + +/** + * Creates a new Extern Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Extern Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#extern + * @since 3.16.0 + * + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @return {Phaser.GameObjects.Extern} The Game Object that was created. + */ +GameObjectFactory.register('extern', function () +{ + var extern = new Extern(this.scene); + + this.displayList.add(extern); + this.updateList.add(extern); + + return extern; +}); + +// When registering a factory function 'this' refers to the GameObjectFactory context. +// +// There are several properties available to use: +// +// this.scene - a reference to the Scene that owns the GameObjectFactory +// this.displayList - a reference to the Display List the Scene owns +// this.updateList - a reference to the Update List the Scene owns diff --git a/src/gameobjects/extern/ExternRender.js b/src/gameobjects/extern/ExternRender.js new file mode 100644 index 000000000..3d1da6bdd --- /dev/null +++ b/src/gameobjects/extern/ExternRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../utils/NOOP'); +var renderCanvas = require('../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./ExternWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./ExternCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/extern/ExternWebGLRenderer.js b/src/gameobjects/extern/ExternWebGLRenderer.js new file mode 100644 index 000000000..313bc68b8 --- /dev/null +++ b/src/gameobjects/extern/ExternWebGLRenderer.js @@ -0,0 +1,63 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Extern#renderWebGL + * @since 3.16.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Extern} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ExternWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = renderer.currentPipeline; + + renderer.clearPipeline(); + + var camMatrix = renderer._tempMatrix1; + var spriteMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + // Callback + src.render.call(src, renderer, camera, calcMatrix); + + renderer.rebindPipeline(pipeline); +}; + +module.exports = ExternWebGLRenderer; diff --git a/src/gameobjects/graphics/Commands.js b/src/gameobjects/graphics/Commands.js index 6eb68709b..f74fb3d18 100644 --- a/src/gameobjects/graphics/Commands.js +++ b/src/gameobjects/graphics/Commands.js @@ -28,6 +28,10 @@ module.exports = { RESTORE: 15, TRANSLATE: 16, SCALE: 17, - ROTATE: 18 + ROTATE: 18, + SET_TEXTURE: 19, + CLEAR_TEXTURE: 20, + GRADIENT_FILL_STYLE: 21, + GRADIENT_LINE_STYLE: 22 }; diff --git a/src/gameobjects/graphics/Graphics.js b/src/gameobjects/graphics/Graphics.js index 22e797b60..2d6399838 100644 --- a/src/gameobjects/graphics/Graphics.js +++ b/src/gameobjects/graphics/Graphics.js @@ -4,11 +4,19 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var Camera = require('../../cameras/2d/Camera.js'); +var BaseCamera = require('../../cameras/2d/BaseCamera.js'); var Class = require('../../utils/Class'); var Commands = require('./Commands'); -var Components = require('../components'); -var Ellipse = require('../../geom/ellipse/'); +var ComponentsAlpha = require('../components/Alpha'); +var ComponentsBlendMode = require('../components/BlendMode'); +var ComponentsDepth = require('../components/Depth'); +var ComponentsMask = require('../components/Mask'); +var ComponentsPipeline = require('../components/Pipeline'); +var ComponentsTransform = require('../components/Transform'); +var ComponentsVisible = require('../components/Visible'); +var ComponentsScrollFactor = require('../components/ScrollFactor'); + +var Ellipse = require('../../geom/ellipse/Ellipse'); var GameObject = require('../GameObject'); var GetFastValue = require('../../utils/object/GetFastValue'); var GetValue = require('../../utils/object/GetValue'); @@ -55,7 +63,7 @@ var Render = require('./GraphicsRender'); /** * @classdesc - * A Graphics object is a way to draw primitive shapes to you game. Primitives include forms of geometry, such as + * A Graphics object is a way to draw primitive shapes to your game. Primitives include forms of geometry, such as * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics * object it will be empty. * @@ -96,7 +104,7 @@ var Render = require('./GraphicsRender'); * * @class Graphics * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -117,14 +125,14 @@ var Graphics = new Class({ Extends: GameObject, Mixins: [ - Components.Alpha, - Components.BlendMode, - Components.Depth, - Components.Mask, - Components.Pipeline, - Components.Transform, - Components.Visible, - Components.ScrollFactor, + ComponentsAlpha, + ComponentsBlendMode, + ComponentsDepth, + ComponentsMask, + ComponentsPipeline, + ComponentsTransform, + ComponentsVisible, + ComponentsScrollFactor, Render ], @@ -138,7 +146,7 @@ var Graphics = new Class({ GameObject.call(this, scene, 'Graphics'); this.setPosition(x, y); - this.initPipeline('FlatTintPipeline'); + this.initPipeline(); /** * The horizontal display origin of the Graphics. @@ -314,6 +322,139 @@ var Graphics = new Class({ return this; }, + /** + * Sets a gradient fill style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all filled shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. + * + * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. + * + * This feature is best used only on rectangles and triangles. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#fillGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {integer} topLeft - The tint being applied to the top-left of the Game Object. + * @param {integer} topRight - The tint being applied to the top-right of the Game Object. + * @param {integer} bottomLeft - The tint being applied to the bottom-left of the Game Object. + * @param {integer} bottomRight - The tint being applied to the bottom-right of the Game Object. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fillGradientStyle: function (topLeft, topRight, bottomLeft, bottomRight, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.GRADIENT_FILL_STYLE, + alpha, topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Sets a gradient line style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all stroked shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. + * + * This feature is best used only on single lines. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single + * entity at this time. + * + * @method Phaser.GameObjects.Graphics#lineGradientStyle + * @webglOnly + * @since 3.12.0 + * + * @param {number} lineWidth - The stroke width. + * @param {integer} topLeft - The tint being applied to the top-left of the Game Object. + * @param {integer} topRight - The tint being applied to the top-right of the Game Object. + * @param {integer} bottomLeft - The tint being applied to the bottom-left of the Game Object. + * @param {integer} bottomRight - The tint being applied to the bottom-right of the Game Object. + * @param {number} [alpha=1] - The fill alpha. + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + lineGradientStyle: function (lineWidth, topLeft, topRight, bottomLeft, bottomRight, alpha) + { + if (alpha === undefined) { alpha = 1; } + + this.commandBuffer.push( + Commands.GRADIENT_LINE_STYLE, + lineWidth, alpha, topLeft, topRight, bottomLeft, bottomRight + ); + + return this; + }, + + /** + * Sets the texture frame this Graphics Object will use when drawing all shapes defined after calling this. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Once set, all shapes will use this texture. Call this method with no arguments to clear it. + * + * The textures are not tiled. They are stretched to the dimensions of the shapes being rendered. For this reason, + * it works best with seamless / tileable textures. + * + * The mode argument controls how the textures are combined with the fill colors. The default value (0) will + * multiply the texture by the fill color. A value of 1 will use just the fill color, but the alpha data from the texture, + * and a value of 2 will use just the texture and no fill color at all. + * + * @method Phaser.GameObjects.Graphics#setTexture + * @since 3.12.0 + * @webglOnly + * + * @param {string} [key] - The key of the texture to be used, as stored in the Texture Manager. Leave blank to clear a previously set texture. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} [mode=0] - The texture tint mode. 0 is multiply, 1 is alpha only and 2 is texture only. + * + * @return {this} This Game Object. + */ + setTexture: function (key, frame, mode) + { + if (mode === undefined) { mode = 0; } + + if (key === undefined) + { + this.commandBuffer.push( + Commands.CLEAR_TEXTURE + ); + } + else + { + var textureFrame = this.scene.sys.textures.getFrame(key, frame); + + if (textureFrame) + { + if (mode === 2) + { + mode = 3; + } + + this.commandBuffer.push( + Commands.SET_TEXTURE, + textureFrame, + mode + ); + } + } + + return this; + }, + /** * Start a new shape path. * @@ -365,6 +506,26 @@ var Graphics = new Class({ return this; }, + /** + * Fill the current path. + * + * This is an alias for `Graphics.fillPath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. + * + * @method Phaser.GameObjects.Graphics#fill + * @since 3.16.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + fill: function () + { + this.commandBuffer.push( + Commands.FILL_PATH + ); + + return this; + }, + /** * Stroke the current path. * @@ -382,6 +543,26 @@ var Graphics = new Class({ return this; }, + /** + * Stroke the current path. + * + * This is an alias for `Graphics.strokePath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. + * + * @method Phaser.GameObjects.Graphics#stroke + * @since 3.16.0 + * + * @return {Phaser.GameObjects.Graphics} This Game Object. + */ + stroke: function () + { + this.commandBuffer.push( + Commands.STROKE_PATH + ); + + return this; + }, + /** * Fill the given circle. * @@ -864,15 +1045,15 @@ var Graphics = new Class({ }, /** - * [description] + * Draw a line from the current drawing position to the given position with a specific width and color. * * @method Phaser.GameObjects.Graphics#lineFxTo * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} rgb - [description] + * @param {number} x - The x coordinate to draw the line to. + * @param {number} y - The y coordinate to draw the line to. + * @param {number} width - The width of the stroke. + * @param {number} rgb - The color of the stroke. * * @return {Phaser.GameObjects.Graphics} This Game Object. */ @@ -887,15 +1068,15 @@ var Graphics = new Class({ }, /** - * [description] + * Move the current drawing position to the given position and change the pen width and color. * * @method Phaser.GameObjects.Graphics#moveFxTo * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} rgb - [description] + * @param {number} x - The x coordinate to move to. + * @param {number} y - The y coordinate to move to. + * @param {number} width - The new stroke width. + * @param {number} rgb - The new stroke color. * * @return {Phaser.GameObjects.Graphics} This Game Object. */ @@ -1079,6 +1260,13 @@ var Graphics = new Class({ * Draw an arc. * * This method can be used to create circles, or parts of circles. + * + * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically + * close when filled or stroked. + * + * Use the optional `overshoot` argument increase the number of iterations that take place when + * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, + * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. * * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling * this method to draw the arc. @@ -1092,14 +1280,18 @@ var Graphics = new Class({ * @param {number} startAngle - The starting angle, in radians. * @param {number} endAngle - The ending angle, in radians. * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. * * @return {Phaser.GameObjects.Graphics} This Game Object. */ - arc: function (x, y, radius, startAngle, endAngle, anticlockwise) + arc: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) { + if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } + this.commandBuffer.push( Commands.ARC, - x, y, radius, startAngle, endAngle, anticlockwise + x, y, radius, startAngle, endAngle, anticlockwise, overshoot ); return this; @@ -1123,19 +1315,21 @@ var Graphics = new Class({ * @param {number} radius - The radius of the slice. * @param {number} startAngle - The start angle of the slice, given in radians. * @param {number} endAngle - The end angle of the slice, given in radians. - * @param {boolean} [anticlockwise=false] - Draw the slice piece anticlockwise or clockwise? + * @param {boolean} [anticlockwise=false] - Whether the drawing should be anticlockwise or clockwise. + * @param {number} [overshoot=0] - This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. * * @return {Phaser.GameObjects.Graphics} This Game Object. */ - slice: function (x, y, radius, startAngle, endAngle, anticlockwise) + slice: function (x, y, radius, startAngle, endAngle, anticlockwise, overshoot) { if (anticlockwise === undefined) { anticlockwise = false; } + if (overshoot === undefined) { overshoot = 0; } this.commandBuffer.push(Commands.BEGIN_PATH); this.commandBuffer.push(Commands.MOVE_TO, x, y); - this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise); + this.commandBuffer.push(Commands.ARC, x, y, radius, startAngle, endAngle, anticlockwise, overshoot); this.commandBuffer.push(Commands.CLOSE_PATH); @@ -1290,10 +1484,12 @@ var Graphics = new Class({ generateTexture: function (key, width, height) { var sys = this.scene.sys; + var renderer = sys.game.renderer; if (width === undefined) { width = sys.game.config.width; } if (height === undefined) { height = sys.game.config.height; } + Graphics.TargetCamera.setScene(this.scene); Graphics.TargetCamera.setViewport(0, 0, width, height); Graphics.TargetCamera.scrollX = this.x; Graphics.TargetCamera.scrollY = this.y; @@ -1334,11 +1530,12 @@ var Graphics = new Class({ if (ctx) { - this.renderCanvas(sys.game.renderer, this, 0.0, Graphics.TargetCamera, null, ctx); + // var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) + this.renderCanvas(renderer, this, 0, Graphics.TargetCamera, null, ctx, false); - if (sys.game.renderer.gl && texture) + if (texture) { - texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture); + texture.refresh(); } } @@ -1366,6 +1563,6 @@ var Graphics = new Class({ * @type {Phaser.Cameras.Scene2D.Camera} * @since 3.1.0 */ -Graphics.TargetCamera = new Camera(0, 0, 0, 0); +Graphics.TargetCamera = new BaseCamera(); module.exports = Graphics; diff --git a/src/gameobjects/graphics/GraphicsCanvasRenderer.js b/src/gameobjects/graphics/GraphicsCanvasRenderer.js index 01a49c430..40f438790 100644 --- a/src/gameobjects/graphics/GraphicsCanvasRenderer.js +++ b/src/gameobjects/graphics/GraphicsCanvasRenderer.js @@ -5,7 +5,7 @@ */ var Commands = require('./Commands'); -var GameObject = require('../GameObject'); +var SetTransform = require('../../renderer/canvas/utils/SetTransform'); /** * Renders this Game Object with the Canvas Renderer to the given Camera. @@ -22,77 +22,33 @@ var GameObject = require('../GameObject'); * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested * @param {CanvasRenderingContext2D} [renderTargetCtx] - The target rendering context. - * @param {boolean} allowClip - [description] + * @param {boolean} allowClip - If `true` then path operations will be used instead of fill operations. */ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) + var commandBuffer = src.commandBuffer; + var commandBufferLength = commandBuffer.length; + + var ctx = renderTargetCtx || renderer.currentContext; + + if (commandBufferLength === 0 || !SetTransform(renderer, ctx, src, camera, parentMatrix)) { return; } - var cameraScrollX = camera.scrollX * src.scrollFactorX; - var cameraScrollY = camera.scrollY * src.scrollFactorY; - var srcX = src.x; - var srcY = src.y; - var srcScaleX = src.scaleX; - var srcScaleY = src.scaleY; - var srcRotation = src.rotation; - var commandBuffer = src.commandBuffer; - var ctx = renderTargetCtx || renderer.currentContext; - var lineAlpha = 1.0; - var fillAlpha = 1.0; + var lineAlpha = 1; + var fillAlpha = 1; var lineColor = 0; var fillColor = 0; - var lineWidth = 1.0; + var lineWidth = 1; var red = 0; var green = 0; var blue = 0; - // Alpha + // Reset any currently active paths + ctx.beginPath(); - var alpha = camera.alpha * src.alpha; - - if (alpha === 0) - { - // Nothing to see, so abort early - return; - } - else if (renderer.currentAlpha !== alpha) - { - renderer.currentAlpha = alpha; - ctx.globalAlpha = alpha; - } - - // Blend Mode - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Smoothing - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - ctx.save(); - - if (parentMatrix) - { - var matrix = parentMatrix.matrix; - - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); - ctx.rotate(srcRotation); - ctx.scale(srcScaleX, srcScaleY); - ctx.fillStyle = '#fff'; - ctx.globalAlpha = src.alpha; - - for (var index = 0, length = commandBuffer.length; index < length; ++index) + for (var index = 0; index < commandBufferLength; ++index) { var commandID = commandBuffer[index]; @@ -107,7 +63,9 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c commandBuffer[index + 5], commandBuffer[index + 6] ); - index += 6; + + // +7 because overshoot is the 7th value, not used in Canvas + index += 7; break; case Commands.LINE_STYLE: @@ -264,9 +222,22 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c ); index += 1; break; + + case Commands.GRADIENT_FILL_STYLE: + index += 5; + break; + + case Commands.GRADIENT_LINE_STYLE: + index += 6; + break; + + case Commands.SET_TEXTURE: + index += 2; + break; } } + // Restore the context saved in SetTransform ctx.restore(); }; diff --git a/src/gameobjects/graphics/GraphicsWebGLRenderer.js b/src/gameobjects/graphics/GraphicsWebGLRenderer.js index dbd2bf0a6..a5495f928 100644 --- a/src/gameobjects/graphics/GraphicsWebGLRenderer.js +++ b/src/gameobjects/graphics/GraphicsWebGLRenderer.js @@ -4,7 +4,26 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); +var Commands = require('./Commands'); +var Utils = require('../../renderer/webgl/Utils'); + +// TODO: Remove the use of this +var Point = function (x, y, width) +{ + this.x = x; + this.y = y; + this.width = width; +}; + +// TODO: Remove the use of this +var Path = function (x, y, width) +{ + this.points = []; + this.pointsLength = 1; + this.points[0] = new Point(x, y, width); +}; + +var matrixStack = []; /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -16,19 +35,325 @@ var GameObject = require('../GameObject'); * @private * * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. - * @param {Phaser.GameObjects.Graphics} graphics - The Game Object being rendered in this call. + * @param {Phaser.GameObjects.Graphics} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var GraphicsWebGLRenderer = function (renderer, graphics, interpolationPercentage, camera, parentMatrix) +var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== graphics.renderFlags || (graphics.cameraFilter > 0 && (graphics.cameraFilter & camera._id))) + if (src.commandBuffer.length === 0) { return; } - this.pipeline.batchGraphics(this, camera, parentMatrix); + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var graphicsMatrix = pipeline._tempMatrix2; + var currentMatrix = pipeline._tempMatrix4; + + renderer.setPipeline(pipeline); + + currentMatrix.loadIdentity(); + + graphicsMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + graphicsMatrix.e = src.x; + graphicsMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(graphicsMatrix); + } + else + { + graphicsMatrix.e -= camera.scrollX * src.scrollFactorX; + graphicsMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(graphicsMatrix); + } + + var commands = src.commandBuffer; + var alpha = camera.alpha * src.alpha; + + var lineWidth = 1; + var fillTint = pipeline.fillTint; + var strokeTint = pipeline.strokeTint; + + var tx = 0; + var ty = 0; + var ta = 0; + var iterStep = 0.01; + var PI2 = Math.PI * 2; + + var cmd; + + var path = []; + var pathIndex = 0; + var pathOpen = false; + var lastPath = null; + + var getTint = Utils.getTintAppendFloatAlphaAndSwap; + + var currentTexture = renderer.blankTexture.glTexture; + + for (var cmdIndex = 0; cmdIndex < commands.length; cmdIndex++) + { + cmd = commands[cmdIndex]; + + switch (cmd) + { + case Commands.BEGIN_PATH: + + path.length = 0; + lastPath = null; + pathOpen = true; + break; + + case Commands.CLOSE_PATH: + + pathOpen = false; + + if (lastPath && lastPath.points.length) + { + lastPath.points.push(lastPath.points[0]); + } + break; + + case Commands.FILL_PATH: + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + pipeline.setTexture2D(currentTexture); + + pipeline.batchFillPath( + path[pathIndex].points, + currentMatrix, + camMatrix + ); + } + break; + + case Commands.STROKE_PATH: + for (pathIndex = 0; pathIndex < path.length; pathIndex++) + { + pipeline.setTexture2D(currentTexture); + + pipeline.batchStrokePath( + path[pathIndex].points, + lineWidth, + pathOpen, + currentMatrix, + camMatrix + ); + } + break; + + case Commands.LINE_STYLE: + lineWidth = commands[++cmdIndex]; + var strokeColor = commands[++cmdIndex]; + var strokeAlpha = commands[++cmdIndex] * alpha; + var strokeTintColor = getTint(strokeColor, strokeAlpha); + strokeTint.TL = strokeTintColor; + strokeTint.TR = strokeTintColor; + strokeTint.BL = strokeTintColor; + strokeTint.BR = strokeTintColor; + break; + + case Commands.FILL_STYLE: + var fillColor = commands[++cmdIndex]; + var fillAlpha = commands[++cmdIndex] * alpha; + var fillTintColor = getTint(fillColor, fillAlpha); + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + break; + + case Commands.GRADIENT_FILL_STYLE: + var gradientFillAlpha = commands[++cmdIndex] * alpha; + fillTint.TL = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.TR = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.BL = getTint(commands[++cmdIndex], gradientFillAlpha); + fillTint.BR = getTint(commands[++cmdIndex], gradientFillAlpha); + break; + + case Commands.GRADIENT_LINE_STYLE: + lineWidth = commands[++cmdIndex]; + var gradientLineAlpha = commands[++cmdIndex] * alpha; + strokeTint.TL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.TR = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BL = getTint(commands[++cmdIndex], gradientLineAlpha); + strokeTint.BR = getTint(commands[++cmdIndex], gradientLineAlpha); + break; + + case Commands.ARC: + var iteration = 0; + var x = commands[++cmdIndex]; + var y = commands[++cmdIndex]; + var radius = commands[++cmdIndex]; + var startAngle = commands[++cmdIndex]; + var endAngle = commands[++cmdIndex]; + var anticlockwise = commands[++cmdIndex]; + var overshoot = commands[++cmdIndex]; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -PI2) + { + endAngle = -PI2; + } + else if (endAngle > 0) + { + endAngle = -PI2 + endAngle % PI2; + } + } + else if (endAngle > PI2) + { + endAngle = PI2; + } + else if (endAngle < 0) + { + endAngle = PI2 + endAngle % PI2; + } + + if (lastPath === null) + { + lastPath = new Path(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius, lineWidth); + path.push(lastPath); + iteration += iterStep; + } + + while (iteration < 1 + overshoot) + { + ta = endAngle * iteration + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.points.push(new Point(tx, ty, lineWidth)); + + iteration += iterStep; + } + + ta = endAngle + startAngle; + tx = x + Math.cos(ta) * radius; + ty = y + Math.sin(ta) * radius; + + lastPath.points.push(new Point(tx, ty, lineWidth)); + + break; + + case Commands.FILL_RECT: + pipeline.setTexture2D(currentTexture); + pipeline.batchFillRect( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + currentMatrix, + camMatrix + ); + break; + + case Commands.FILL_TRIANGLE: + pipeline.setTexture2D(currentTexture); + pipeline.batchFillTriangle( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + currentMatrix, + camMatrix + ); + break; + + case Commands.STROKE_TRIANGLE: + pipeline.setTexture2D(currentTexture); + pipeline.batchStrokeTriangle( + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + commands[++cmdIndex], + lineWidth, + currentMatrix, + camMatrix + ); + break; + + case Commands.LINE_TO: + if (lastPath !== null) + { + lastPath.points.push(new Point(commands[++cmdIndex], commands[++cmdIndex], lineWidth)); + } + else + { + lastPath = new Path(commands[++cmdIndex], commands[++cmdIndex], lineWidth); + path.push(lastPath); + } + break; + + case Commands.MOVE_TO: + lastPath = new Path(commands[++cmdIndex], commands[++cmdIndex], lineWidth); + path.push(lastPath); + break; + + case Commands.SAVE: + matrixStack.push(currentMatrix.copyToArray()); + break; + + case Commands.RESTORE: + currentMatrix.copyFromArray(matrixStack.pop()); + break; + + case Commands.TRANSLATE: + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.translate(x, y); + break; + + case Commands.SCALE: + x = commands[++cmdIndex]; + y = commands[++cmdIndex]; + currentMatrix.scale(x, y); + break; + + case Commands.ROTATE: + currentMatrix.rotate(commands[++cmdIndex]); + break; + + case Commands.SET_TEXTURE: + var frame = commands[++cmdIndex]; + var mode = commands[++cmdIndex]; + + pipeline.currentFrame = frame; + pipeline.setTexture2D(frame.glTexture, 0); + pipeline.tintEffect = mode; + + currentTexture = frame.glTexture; + + break; + + case Commands.CLEAR_TEXTURE: + pipeline.currentFrame = renderer.blankTexture; + pipeline.tintEffect = 2; + currentTexture = renderer.blankTexture.glTexture; + break; + } + } }; module.exports = GraphicsWebGLRenderer; diff --git a/src/gameobjects/group/Group.js b/src/gameobjects/group/Group.js index 5f49e28d6..57f2ebc05 100644 --- a/src/gameobjects/group/Group.js +++ b/src/gameobjects/group/Group.js @@ -8,6 +8,7 @@ var Actions = require('../../actions/'); var Class = require('../../utils/Class'); var GetFastValue = require('../../utils/object/GetFastValue'); var GetValue = require('../../utils/object/GetValue'); +var IsPlainObject = require('../../utils/object/IsPlainObject'); var Range = require('../../utils/array/Range'); var Set = require('../../structs/Set'); var Sprite = require('../sprite/Sprite'); @@ -27,7 +28,7 @@ var Sprite = require('../sprite/Sprite'); /** * @typedef {object} GroupConfig * - * @property {?object} [classType=Sprite] - Sets {@link Phaser.GameObjects.Group#classType}. + * @property {?GroupClassTypeConstructor} [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}. @@ -51,7 +52,7 @@ var Sprite = require('../sprite/Sprite'); * * `key` is required. {@link Phaser.GameObjects.Group#defaultKey} is not used. * - * @property {?object} [classType] - The class of each new Game Object. + * @property {?GroupClassTypeConstructor} [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. @@ -92,6 +93,18 @@ var Sprite = require('../sprite/Sprite'); * @see Phaser.Utils.Array.Range */ +/** + * A constructor function (class) that can be assigned to `classType`. + * @callback GroupClassTypeConstructor + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * + * @see Phaser.GameObjects.Group#classType + */ + /** * @classdesc A Group is a way for you to create, manipulate, or recycle similar Game Objects. * @@ -100,11 +113,11 @@ var Sprite = require('../sprite/Sprite'); * Groups themselves aren't displayable, and can't be positioned, rotated, scaled, or hidden. * * @class Group - * @memberOf Phaser.GameObjects + * @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 {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [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. * * @see Phaser.Physics.Arcade.Group @@ -116,8 +129,38 @@ var Group = new Class({ function Group (scene, children, config) { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') + // They can pass in any of the following as the first argument: + + // 1) A single child + // 2) An array of children + // 3) A config object + // 4) An array of config objects + + // Or they can pass in a child, or array of children AND a config object + + if (config) { + // config has been set, are the children an array? + + if (children && !Array.isArray(children)) + { + children = [ children ]; + } + } + else if (Array.isArray(children)) + { + // No config, so let's check the children argument + + if (IsPlainObject(children[0])) + { + // It's an array of plain config objects + config = children; + children = null; + } + } + else if (IsPlainObject(children)) + { + // Children isn't an array. Is it a config object though? config = children; children = null; } @@ -154,7 +197,7 @@ var Group = new Class({ * The class to create new group members from. * * @name Phaser.GameObjects.Group#classType - * @type {object} + * @type {GroupClassTypeConstructor} * @since 3.0.0 * @default Phaser.GameObjects.Sprite */ @@ -320,18 +363,16 @@ var Group = new Class({ config = [ config ]; } - if (config[0].key === undefined) - { - return []; - } - var output = []; - for (var i = 0; i < config.length; i++) + if (config[0].key) { - var entries = this.createFromConfig(config[i]); - - output = output.concat(entries); + for (var i = 0; i < config.length; i++) + { + var entries = this.createFromConfig(config[i]); + + output = output.concat(entries); + } } return output; diff --git a/src/gameobjects/group/GroupCreator.js b/src/gameobjects/group/GroupCreator.js index de5ba9816..0569852ea 100644 --- a/src/gameobjects/group/GroupCreator.js +++ b/src/gameobjects/group/GroupCreator.js @@ -15,7 +15,7 @@ var Group = require('./Group'); * @method Phaser.GameObjects.GameObjectCreator#group * @since 3.0.0 * - * @param {GroupConfig} config - The configuration object this Game Object will use to create itself. + * @param {GroupConfig|GroupCreateConfig} config - The configuration object this Game Object will use to create itself. * * @return {Phaser.GameObjects.Group} The Game Object that was created. */ diff --git a/src/gameobjects/group/GroupFactory.js b/src/gameobjects/group/GroupFactory.js index 7f357ef87..3367ba1e7 100644 --- a/src/gameobjects/group/GroupFactory.js +++ b/src/gameobjects/group/GroupFactory.js @@ -15,18 +15,12 @@ var GameObjectFactory = require('../GameObjectFactory'); * @method Phaser.GameObjects.GameObjectFactory#group * @since 3.0.0 * - * @param {(Phaser.GameObjects.GameObject[]|GroupConfig)} [children] - Game Objects to add to this Group; or the `config` argument. - * @param {GroupConfig} [config] - A Group Configuration object. + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupConfig[])} [children] - Game Objects to add to this Group; or the `config` argument. + * @param {GroupConfig|GroupCreateConfig} [config] - A Group Configuration object. * * @return {Phaser.GameObjects.Group} The Game Object that was created. */ GameObjectFactory.register('group', function (children, config) { - if (typeof children === 'object' && config === undefined) - { - config = children; - children = []; - } - return this.updateList.add(new Group(this.scene, children, config)); }); diff --git a/src/gameobjects/image/Image.js b/src/gameobjects/image/Image.js index d58fe405f..ba209160d 100644 --- a/src/gameobjects/image/Image.js +++ b/src/gameobjects/image/Image.js @@ -20,7 +20,7 @@ var ImageRender = require('./ImageRender'); * * @class Image * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -35,7 +35,7 @@ var ImageRender = require('./ImageRender'); * @extends Phaser.GameObjects.Components.ScaleMode * @extends Phaser.GameObjects.Components.ScrollFactor * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.TextureCrop * @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible @@ -62,7 +62,7 @@ var Image = new Class({ Components.ScaleMode, Components.ScrollFactor, Components.Size, - Components.Texture, + Components.TextureCrop, Components.Tint, Components.Transform, Components.Visible, @@ -75,11 +75,21 @@ var Image = new Class({ { GameObject.call(this, scene, 'Image'); + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Image#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + this.setTexture(texture, frame); this.setPosition(x, y); this.setSizeToFrame(); this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); + this.initPipeline(); } }); diff --git a/src/gameobjects/image/ImageCanvasRenderer.js b/src/gameobjects/image/ImageCanvasRenderer.js index 269c78129..9e1661dd0 100644 --- a/src/gameobjects/image/ImageCanvasRenderer.js +++ b/src/gameobjects/image/ImageCanvasRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -23,12 +21,7 @@ var GameObject = require('../GameObject'); */ var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) - { - return; - } - - renderer.drawImage(src, camera, parentMatrix); + renderer.batchSprite(src, src.frame, camera, parentMatrix); }; module.exports = ImageCanvasRenderer; diff --git a/src/gameobjects/image/ImageWebGLRenderer.js b/src/gameobjects/image/ImageWebGLRenderer.js index 99c12f2fc..107630c80 100644 --- a/src/gameobjects/image/ImageWebGLRenderer.js +++ b/src/gameobjects/image/ImageWebGLRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the WebGL Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -23,11 +21,6 @@ var GameObject = require('../GameObject'); */ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) - { - return; - } - this.pipeline.batchSprite(src, camera, parentMatrix); }; diff --git a/src/gameobjects/index.js b/src/gameobjects/index.js index 4cde5c322..1b2bff03c 100644 --- a/src/gameobjects/index.js +++ b/src/gameobjects/index.js @@ -24,6 +24,7 @@ var GameObjects = { Blitter: require('./blitter/Blitter'), Container: require('./container/Container'), DynamicBitmapText: require('./bitmaptext/dynamic/DynamicBitmapText'), + Extern: require('./extern/Extern.js'), Graphics: require('./graphics/Graphics.js'), Group: require('./group/Group'), Image: require('./image/Image'), @@ -31,30 +32,57 @@ var GameObjects = { PathFollower: require('./pathfollower/PathFollower'), RenderTexture: require('./rendertexture/RenderTexture'), RetroFont: require('./bitmaptext/RetroFont'), - Sprite3D: require('./sprite3d/Sprite3D'), Sprite: require('./sprite/Sprite'), Text: require('./text/static/Text'), TileSprite: require('./tilesprite/TileSprite'), Zone: require('./zone/Zone'), + // Shapes + + Shape: require('./shape/Shape'), + Arc: require('./shape/arc/Arc'), + Curve: require('./shape/curve/Curve'), + Ellipse: require('./shape/ellipse/Ellipse'), + Grid: require('./shape/grid/Grid'), + IsoBox: require('./shape/isobox/IsoBox'), + IsoTriangle: require('./shape/isotriangle/IsoTriangle'), + Line: require('./shape/line/Line'), + Polygon: require('./shape/polygon/Polygon'), + Rectangle: require('./shape/rectangle/Rectangle'), + Star: require('./shape/star/Star'), + Triangle: require('./shape/triangle/Triangle'), + // Game Object Factories Factories: { Blitter: require('./blitter/BlitterFactory'), Container: require('./container/ContainerFactory'), DynamicBitmapText: require('./bitmaptext/dynamic/DynamicBitmapTextFactory'), + Extern: require('./extern/ExternFactory'), Graphics: require('./graphics/GraphicsFactory'), Group: require('./group/GroupFactory'), Image: require('./image/ImageFactory'), Particles: require('./particles/ParticleManagerFactory'), PathFollower: require('./pathfollower/PathFollowerFactory'), RenderTexture: require('./rendertexture/RenderTextureFactory'), - Sprite3D: require('./sprite3d/Sprite3DFactory'), Sprite: require('./sprite/SpriteFactory'), StaticBitmapText: require('./bitmaptext/static/BitmapTextFactory'), Text: require('./text/static/TextFactory'), TileSprite: require('./tilesprite/TileSpriteFactory'), - Zone: require('./zone/ZoneFactory') + Zone: require('./zone/ZoneFactory'), + + // Shapes + Arc: require('./shape/arc/ArcFactory'), + Curve: require('./shape/curve/CurveFactory'), + Ellipse: require('./shape/ellipse/EllipseFactory'), + Grid: require('./shape/grid/GridFactory'), + IsoBox: require('./shape/isobox/IsoBoxFactory'), + IsoTriangle: require('./shape/isotriangle/IsoTriangleFactory'), + Line: require('./shape/line/LineFactory'), + Polygon: require('./shape/polygon/PolygonFactory'), + Rectangle: require('./shape/rectangle/RectangleFactory'), + Star: require('./shape/star/StarFactory'), + Triangle: require('./shape/triangle/TriangleFactory') }, Creators: { @@ -66,7 +94,6 @@ var GameObjects = { Image: require('./image/ImageCreator'), Particles: require('./particles/ParticleManagerCreator'), RenderTexture: require('./rendertexture/RenderTextureCreator'), - Sprite3D: require('./sprite3d/Sprite3DCreator'), Sprite: require('./sprite/SpriteCreator'), StaticBitmapText: require('./bitmaptext/static/BitmapTextCreator'), Text: require('./text/static/TextCreator'), @@ -76,6 +103,12 @@ var GameObjects = { }; +if (typeof EXPERIMENTAL) +{ + GameObjects.DOMElement = require('./domelement/DOMElement'); + GameObjects.Factories.DOMElement = require('./domelement/DOMElementFactory'); +} + if (typeof WEBGL_RENDERER) { // WebGL only Game Objects diff --git a/src/gameobjects/lights/Light.js b/src/gameobjects/lights/Light.js index b9e855a33..09cff68db 100644 --- a/src/gameobjects/lights/Light.js +++ b/src/gameobjects/lights/Light.js @@ -18,7 +18,7 @@ var Utils = require('../../renderer/webgl/Utils'); * They can also simply be used to represent a point light for your own purposes. * * @class Light - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * diff --git a/src/gameobjects/lights/LightsManager.js b/src/gameobjects/lights/LightsManager.js index 788439f39..7333af5ae 100644 --- a/src/gameobjects/lights/LightsManager.js +++ b/src/gameobjects/lights/LightsManager.js @@ -6,7 +6,6 @@ var Class = require('../../utils/Class'); var Light = require('./Light'); -var LightPipeline = require('../../renderer/webgl/pipelines/ForwardDiffuseLightPipeline'); var Utils = require('../../renderer/webgl/Utils'); /** @@ -22,7 +21,7 @@ var Utils = require('../../renderer/webgl/Utils'); * Affects the rendering of Game Objects using the `Light2D` pipeline. * * @class LightsManager - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 */ @@ -84,6 +83,17 @@ var LightsManager = new Class({ * @since 3.0.0 */ this.active = false; + + /** + * The maximum number of lights that a single Camera and the lights shader can process. + * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. + * + * @name Phaser.GameObjects.LightsManager#maxLights + * @type {integer} + * @readonly + * @since 3.15.0 + */ + this.maxLights = -1; }, /** @@ -96,6 +106,11 @@ var LightsManager = new Class({ */ enable: function () { + if (this.maxLights === -1) + { + this.maxLights = this.scene.sys.game.renderer.config.maxLights; + } + this.active = true; return this; @@ -142,14 +157,13 @@ var LightsManager = new Class({ culledLights.length = 0; - for (var index = 0; index < length && culledLights.length < LightPipeline.LIGHT_COUNT; ++index) + for (var index = 0; index < length && culledLights.length < this.maxLights; index++) { var light = lights[index]; cameraMatrix.transformPoint(light.x, light.y, point); - // We'll just use bounding spheres to test - // if lights should be rendered + // We'll just use bounding spheres to test if lights should be rendered var dx = cameraCenterX - (point.x - (camera.scrollX * light.scrollFactorX * camera.zoom)); var dy = cameraCenterY - (viewportHeight - (point.y - (camera.scrollY * light.scrollFactorY) * camera.zoom)); var distance = Math.sqrt(dx * dx + dy * dy); @@ -244,11 +258,11 @@ var LightsManager = new Class({ * @method Phaser.GameObjects.LightsManager#addLight * @since 3.0.0 * - * @param {number} x - The horizontal position of the Light. - * @param {number} y - The vertical position of the Light. - * @param {number} radius - The radius of the Light. - * @param {number} rgb - The integer RGB color of the light. - * @param {number} intensity - The intensity of the Light. + * @param {number} [x=0] - The horizontal position of the Light. + * @param {number} [y=0] - The vertical position of the Light. + * @param {number} [radius=100] - The radius of the Light. + * @param {number} [rgb=0xffffff] - The integer RGB color of the light. + * @param {number} [intensity=1] - The intensity of the Light. * * @return {Phaser.GameObjects.Light} The Light that was added. */ diff --git a/src/gameobjects/lights/LightsPlugin.js b/src/gameobjects/lights/LightsPlugin.js index 02da4cf78..5eb3fcbaf 100644 --- a/src/gameobjects/lights/LightsPlugin.js +++ b/src/gameobjects/lights/LightsPlugin.js @@ -32,7 +32,7 @@ var PluginCache = require('../../plugins/PluginCache'); * * @class LightsPlugin * @extends Phaser.GameObjects.LightsManager - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * diff --git a/src/gameobjects/mesh/Mesh.js b/src/gameobjects/mesh/Mesh.js index e6e1cec43..5094b7785 100644 --- a/src/gameobjects/mesh/Mesh.js +++ b/src/gameobjects/mesh/Mesh.js @@ -15,18 +15,15 @@ var MeshRender = require('./MeshRender'); * * @class Mesh * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @webglOnly * @since 3.0.0 * - * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.BlendMode * @extends Phaser.GameObjects.Components.Depth - * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.GetBounds * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.Origin * @extends Phaser.GameObjects.Components.Pipeline * @extends Phaser.GameObjects.Components.ScaleMode * @extends Phaser.GameObjects.Components.Size @@ -50,13 +47,10 @@ var Mesh = new Class({ Extends: GameObject, Mixins: [ - Components.Alpha, Components.BlendMode, Components.Depth, - Components.Flip, Components.GetBounds, Components.Mask, - Components.Origin, Components.Pipeline, Components.ScaleMode, Components.Size, @@ -73,12 +67,6 @@ var Mesh = new Class({ { GameObject.call(this, scene, 'Mesh'); - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSizeToFrame(); - this.setOrigin(); - this.initPipeline('TextureTintPipeline'); - if (vertices.length !== uv.length) { throw new Error('Mesh Vertex count must match UV count'); @@ -149,6 +137,21 @@ var Mesh = new Class({ * @since 3.0.0 */ this.alphas = new Float32Array(alphas); + + /** + * Fill or additive mode used when blending the color values? + * + * @name Phaser.GameObjects.Mesh#tintFill + * @type {boolean} + * @default false + * @since 3.11.0 + */ + this.tintFill = false; + + this.setTexture(texture, frame); + this.setPosition(x, y); + this.setSizeToFrame(); + this.initPipeline(); } }); diff --git a/src/gameobjects/mesh/MeshWebGLRenderer.js b/src/gameobjects/mesh/MeshWebGLRenderer.js index 9f815ecc8..434f1877d 100644 --- a/src/gameobjects/mesh/MeshWebGLRenderer.js +++ b/src/gameobjects/mesh/MeshWebGLRenderer.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); +var Utils = require('../../renderer/webgl/Utils'); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -23,12 +23,90 @@ var GameObject = require('../GameObject'); */ var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) + var pipeline = this.pipeline; + + renderer.setPipeline(pipeline, src); + + var camMatrix = pipeline._tempMatrix1; + var spriteMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + spriteMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) { - return; + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = src.x; + spriteMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * src.scrollFactorX; + spriteMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); } - this.pipeline.batchMesh(src, camera, parentMatrix); + var frame = src.frame; + var texture = frame.glTexture; + + var vertices = src.vertices; + var uvs = src.uv; + var colors = src.colors; + var alphas = src.alphas; + + var meshVerticesLength = vertices.length; + var vertexCount = Math.floor(meshVerticesLength * 0.5); + + if (pipeline.vertexCount + vertexCount > pipeline.vertexCapacity) + { + pipeline.flush(); + } + + pipeline.setTexture2D(texture, 0); + + var vertexViewF32 = pipeline.vertexViewF32; + var vertexViewU32 = pipeline.vertexViewU32; + + var vertexOffset = (pipeline.vertexCount * pipeline.vertexComponentCount) - 1; + + var colorIndex = 0; + var tintEffect = src.tintFill; + + for (var i = 0; i < meshVerticesLength; i += 2) + { + var x = vertices[i + 0]; + var y = vertices[i + 1]; + + var tx = x * calcMatrix.a + y * calcMatrix.c + calcMatrix.e; + var ty = x * calcMatrix.b + y * calcMatrix.d + calcMatrix.f; + + if (camera.roundPixels) + { + tx = Math.round(tx); + ty = Math.round(ty); + } + + vertexViewF32[++vertexOffset] = tx; + vertexViewF32[++vertexOffset] = ty; + vertexViewF32[++vertexOffset] = uvs[i + 0]; + vertexViewF32[++vertexOffset] = uvs[i + 1]; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = Utils.getTintAppendFloatAlpha(colors[colorIndex], camera.alpha * alphas[colorIndex]); + + colorIndex++; + } + + pipeline.vertexCount += vertexCount; }; module.exports = MeshWebGLRenderer; diff --git a/src/gameobjects/particles/EmitterOp.js b/src/gameobjects/particles/EmitterOp.js index 1a3a7bc67..92b597070 100644 --- a/src/gameobjects/particles/EmitterOp.js +++ b/src/gameobjects/particles/EmitterOp.js @@ -78,14 +78,14 @@ var Wrap = require('../../math/Wrap'); /** * @typedef {object} EmitterOpCustomEmitConfig * - * @property {EmitterOpOnEmitCallback} onEmit - [description] + * @property {EmitterOpOnEmitCallback} onEmit - A callback that is invoked each time the emitter emits a particle. */ /** * @typedef {object} EmitterOpCustomUpdateConfig * - * @property {EmitterOpOnEmitCallback} [onEmit] - [description] - * @property {EmitterOpOnUpdateCallback} onUpdate - [description] + * @property {EmitterOpOnEmitCallback} [onEmit] - A callback that is invoked each time the emitter emits a particle. + * @property {EmitterOpOnUpdateCallback} onUpdate - A callback that is invoked each time the emitter updates. */ /** @@ -95,7 +95,7 @@ var Wrap = require('../../math/Wrap'); * Facilitates changing Particle properties as they are emitted and throughout their lifetime. * * @class EmitterOp - * @memberOf Phaser.GameObjects.Particles + * @memberof Phaser.GameObjects.Particles * @constructor * @since 3.0.0 * diff --git a/src/gameobjects/particles/GravityWell.js b/src/gameobjects/particles/GravityWell.js index 82b5818e2..3f21466e4 100644 --- a/src/gameobjects/particles/GravityWell.js +++ b/src/gameobjects/particles/GravityWell.js @@ -12,24 +12,28 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * * @property {number} [x=0] - The x coordinate of the Gravity Well, in world space. * @property {number} [y=0] - The y coordinate of the Gravity Well, in world space. - * @property {number} [power=0] - The power of the Gravity Well. - * @property {number} [epsilon=100] - [description] + * @property {number} [power=0] - The strength of the gravity force - larger numbers produce a stronger force. + * @property {number} [epsilon=100] - The minimum distance for which the gravity force is calculated. * @property {number} [gravity=50] - The gravitational force of this Gravity Well. */ /** * @classdesc - * [description] + * The GravityWell action applies a force on the particle to draw it towards, or repel it from, a single point. + * + * The force applied is inversely proportional to the square of the distance from the particle to the point, in accordance with Newton's law of gravity. + * + * This simulates the effect of gravity over large distances (as between planets, for example). * * @class GravityWell - * @memberOf Phaser.GameObjects.Particles + * @memberof Phaser.GameObjects.Particles * @constructor * @since 3.0.0 * * @param {(number|GravityWellConfig)} [x=0] - The x coordinate of the Gravity Well, in world space. * @param {number} [y=0] - The y coordinate of the Gravity Well, in world space. - * @param {number} [power=0] - The power of the Gravity Well. - * @param {number} [epsilon=100] - [description] + * @param {number} [power=0] - The strength of the gravity force - larger numbers produce a stronger force. + * @param {number} [epsilon=100] - The minimum distance for which the gravity force is calculated. * @param {number} [gravity=50] - The gravitational force of this Gravity Well. */ var GravityWell = new Class({ @@ -118,7 +122,7 @@ var GravityWell = new Class({ this._epsilon = 0; /** - * The power of the Gravity Well. + * The strength of the gravity force - larger numbers produce a stronger force. * * @name Phaser.GameObjects.Particles.GravityWell#power * @type {number} @@ -127,7 +131,7 @@ var GravityWell = new Class({ this.power = power; /** - * [description] + * The minimum distance for which the gravity force is calculated. * * @name Phaser.GameObjects.Particles.GravityWell#epsilon * @type {number} diff --git a/src/gameobjects/particles/Particle.js b/src/gameobjects/particles/Particle.js index 538fd1055..cfdd5e800 100644 --- a/src/gameobjects/particles/Particle.js +++ b/src/gameobjects/particles/Particle.js @@ -8,18 +8,13 @@ var Class = require('../../utils/Class'); var DegToRad = require('../../math/DegToRad'); var DistanceBetween = require('../../math/distance/DistanceBetween'); -var GetColor = function (value) -{ - return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16); -}; - /** * @classdesc * A Particle is a simple Game Object controlled by a Particle Emitter and Manager, and rendered by the Manager. * It uses its own lightweight physics system, and can interact only with its Emitter's bounds and zones. * * @class Particle - * @memberOf Phaser.GameObjects.Particles + * @memberof Phaser.GameObjects.Particles * @constructor * @since 3.0.0 * @@ -52,16 +47,6 @@ var Particle = new Class({ */ this.frame = null; - /** - * The position of this Particle within its Emitter's particle pool. - * - * @name Phaser.GameObjects.Particles.Particle#index - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.index = 0; - /** * The x coordinate of this Particle. * @@ -212,15 +197,6 @@ var Particle = new Class({ */ this.tint = 0xffffff; - /** - * The full color of this Particle, computed from its alpha and tint. - * - * @name Phaser.GameObjects.Particles.Particle#color - * @type {integer} - * @since 3.0.0 - */ - this.color = 16777215; - /** * The lifespan of this Particle in ms. * @@ -290,6 +266,18 @@ var Particle = new Class({ return (this.lifeCurrent > 0); }, + /** + * Resets the position of this particle back to zero. + * + * @method Phaser.GameObjects.Particles.Particle#resetPosition + * @since 3.16.0 + */ + resetPosition: function () + { + this.x = 0; + this.y = 0; + }, + /** * Starts this Particle from the given coordinates. * @@ -396,12 +384,6 @@ var Particle = new Class({ this.alpha = emitter.alpha.onEmit(this, 'alpha'); this.tint = emitter.tint.onEmit(this, 'tint'); - - var ua = ((this.alpha * 255) | 0) & 0xFF; - - this.color = ((ua << 24) | GetColor(this.tint)) >>> 0; - - this.index = emitter.alive.length; }, /** @@ -571,10 +553,6 @@ var Particle = new Class({ this.tint = emitter.tint.onUpdate(this, 'tint', t, this.tint); - var ua = ((this.alpha * 255) | 0) & 0xFF; - - this.color = ((ua << 24) | GetColor(this.tint)) >>> 0; - this.lifeCurrent -= delta; return (this.lifeCurrent <= 0); diff --git a/src/gameobjects/particles/ParticleEmitter.js b/src/gameobjects/particles/ParticleEmitter.js index 585eb181b..71b3f3567 100644 --- a/src/gameobjects/particles/ParticleEmitter.js +++ b/src/gameobjects/particles/ParticleEmitter.js @@ -152,7 +152,7 @@ var Wrap = require('../../math/Wrap'); * It controls a pool of {@link Phaser.GameObjects.Particles.Particle Particles} and is controlled by a {@link Phaser.GameObjects.Particles.ParticleEmitterManager Particle Emitter Manager}. * * @class ParticleEmitter - * @memberOf Phaser.GameObjects.Particles + * @memberof Phaser.GameObjects.Particles * @constructor * @since 3.0.0 * @@ -2012,13 +2012,9 @@ var ParticleEmitter = new Class({ for (var i = 0; i < count; i++) { - var particle; + var particle = dead.pop(); - if (dead.length > 0) - { - particle = dead.pop(); - } - else + if (!particle) { particle = new this.particleClass(this); } @@ -2073,47 +2069,49 @@ var ParticleEmitter = new Class({ var processors = this.manager.getProcessors(); var particles = this.alive; + var dead = this.dead; + + var i = 0; + var rip = []; var length = particles.length; - for (var index = 0; index < length; index++) + for (i = 0; i < length; i++) { - var particle = particles[index]; + var particle = particles[i]; - // update returns `true` if the particle is now dead (lifeStep < 0) + // update returns `true` if the particle is now dead (lifeCurrent <= 0) if (particle.update(delta, step, processors)) { - // Moves the dead particle to the end of the particles array (ready for splicing out later) - var last = particles[length - 1]; - - particles[length - 1] = particle; - particles[index] = last; - - index -= 1; - length -= 1; + rip.push({ index: i, particle: particle }); } } // Move dead particles to the dead array - var deadLength = particles.length - length; + length = rip.length; - if (deadLength > 0) + if (length > 0) { - var rip = particles.splice(particles.length - deadLength, deadLength); - var deathCallback = this.deathCallback; var deathCallbackScope = this.deathCallbackScope; - if (deathCallback) + for (i = length - 1; i >= 0; i--) { - for (var i = 0; i < rip.length; i++) + var entry = rip[i]; + + // Remove from particles array + particles.splice(entry.index, 1); + + // Add to dead array + dead.push(entry.particle); + + // Callback + if (deathCallback) { - deathCallback.call(deathCallbackScope, rip[i]); + deathCallback.call(deathCallbackScope, entry.particle); } + + entry.particle.resetPosition(); } - - this.dead.concat(rip); - - StableSort.inplace(particles, this.indexSortCallback); } if (!this.on) @@ -2153,22 +2151,6 @@ var ParticleEmitter = new Class({ depthSortCallback: function (a, b) { return a.y - b.y; - }, - - /** - * Calculates the difference of two particles, for sorting them by index. - * - * @method Phaser.GameObjects.Particles.ParticleEmitter#indexSortCallback - * @since 3.0.0 - * - * @param {object} a - The first particle. - * @param {object} b - The second particle. - * - * @return {integer} The difference of a and b's `index` properties. - */ - indexSortCallback: function (a, b) - { - return a.index - b.index; } }); diff --git a/src/gameobjects/particles/ParticleEmitterManager.js b/src/gameobjects/particles/ParticleEmitterManager.js index 7e65efb81..9b50a5973 100644 --- a/src/gameobjects/particles/ParticleEmitterManager.js +++ b/src/gameobjects/particles/ParticleEmitterManager.js @@ -18,13 +18,14 @@ var Render = require('./ParticleManagerRender'); * * @class ParticleEmitterManager * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects.Particles + * @memberof Phaser.GameObjects.Particles * @constructor * @since 3.0.0 * - * @extends Phaser.GameObjects.Particles.Components.Depth - * @extends Phaser.GameObjects.Particles.Components.Pipeline - * @extends Phaser.GameObjects.Particles.Components.Visible + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible * * @param {Phaser.Scene} scene - The Scene to which this Emitter Manager belongs. * @param {string} texture - The key of the Texture this Emitter Manager will use to render particles, as stored in the Texture Manager. @@ -38,6 +39,7 @@ var ParticleEmitterManager = new Class({ Mixins: [ Components.Depth, Components.Pipeline, + Components.Transform, Components.Visible, Render ], @@ -110,7 +112,7 @@ var ParticleEmitterManager = new Class({ this.setTexture(texture, frame); - this.initPipeline('TextureTintPipeline'); + this.initPipeline(); /** * A list of Emitters being managed by this Emitter Manager. @@ -183,7 +185,16 @@ var ParticleEmitterManager = new Class({ { this.frame = this.texture.get(frame); - this.frameNames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); + var frames = this.texture.getFramesFromTextureSource(this.frame.sourceIndex); + + var names = []; + + frames.forEach(function (sourceFrame) + { + names.push(sourceFrame.name); + }); + + this.frameNames = names; this.defaultFrame = this.frame; @@ -436,6 +447,18 @@ var ParticleEmitterManager = new Class({ */ setScrollFactor: function () { + }, + + /** + * A NOOP method so you can pass an EmitterManager to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Particles.ParticleEmitterManager#setBlendMode + * @private + * @since 3.15.0 + */ + setBlendMode: function () + { } }); diff --git a/src/gameobjects/particles/ParticleManagerCanvasRenderer.js b/src/gameobjects/particles/ParticleManagerCanvasRenderer.js index 1a8df0b35..0772e03dd 100644 --- a/src/gameobjects/particles/ParticleManagerCanvasRenderer.js +++ b/src/gameobjects/particles/ParticleManagerCanvasRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -24,92 +22,91 @@ var GameObject = require('../GameObject'); var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) { var emitters = emitterManager.emitters.list; + var emittersLength = emitters.length; - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) + if (emittersLength === 0) { return; } + var camMatrix = renderer._tempMatrix1.copyFrom(camera.matrix); + var calcMatrix = renderer._tempMatrix2; + var particleMatrix = renderer._tempMatrix3; + var managerMatrix = renderer._tempMatrix4.applyITRS(emitterManager.x, emitterManager.y, emitterManager.rotation, emitterManager.scaleX, emitterManager.scaleY); + + camMatrix.multiply(managerMatrix); + + var roundPixels = camera.roundPixels; + var ctx = renderer.currentContext; ctx.save(); - if (parentMatrix !== undefined) + for (var e = 0; e < emittersLength; e++) { - var matrix = parentMatrix.matrix; - - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - for (var i = 0; i < emitters.length; i++) - { - var emitter = emitters[i]; - + var emitter = emitters[e]; var particles = emitter.alive; - var length = particles.length; + var particleCount = particles.length; - if (!emitter.visible || length === 0) + if (!emitter.visible || particleCount === 0) { continue; } - var lastAlpha = ctx.globalAlpha; + var scrollX = camera.scrollX * emitter.scrollFactorX; + var scrollY = camera.scrollY * emitter.scrollFactorY; - var cameraScrollX = camera.scrollX * emitter.scrollFactorX; - var cameraScrollY = camera.scrollY * emitter.scrollFactorY; - - if (renderer.currentBlendMode !== emitter.blendMode) + if (parentMatrix) { - renderer.currentBlendMode = emitter.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -scrollX, -scrollY); + + scrollX = 0; + scrollY = 0; } - for (var index = 0; index < length; ++index) + ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; + + for (var i = 0; i < particleCount; i++) { - var particle = particles[index]; + var particle = particles[i]; - var particleAlpha = camera.alpha * ((particle.color >> 24) & 0xFF) / 255; + var alpha = particle.alpha * camera.alpha; - if (particleAlpha <= 0) + if (alpha <= 0) { continue; } var frame = particle.frame; - var width = frame.width; - var height = frame.height; - var ox = width * 0.5; - var oy = height * 0.5; var cd = frame.canvasData; - var x = -ox; - var y = -oy; + var x = -(frame.halfWidth); + var y = -(frame.halfHeight); - var tx = particle.x - cameraScrollX; - var ty = particle.y - cameraScrollY; + particleMatrix.applyITRS(0, 0, particle.rotation, particle.scaleX, particle.scaleY); - if (camera.roundPixels) - { - tx |= 0; - ty |= 0; - } + particleMatrix.e = particle.x - scrollX; + particleMatrix.f = particle.y - scrollY; - ctx.globalAlpha = particleAlpha; + camMatrix.multiply(particleMatrix, calcMatrix); + + ctx.globalAlpha = alpha; ctx.save(); - ctx.translate(tx, ty); + calcMatrix.copyToContext(ctx); - ctx.rotate(particle.rotation); + if (roundPixels) + { + x = Math.round(x); + y = Math.round(y); + } - ctx.scale(particle.scaleX, particle.scaleY); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); + ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height); ctx.restore(); } - - ctx.globalAlpha = lastAlpha; } ctx.restore(); diff --git a/src/gameobjects/particles/ParticleManagerWebGLRenderer.js b/src/gameobjects/particles/ParticleManagerWebGLRenderer.js index ef0d76df2..809e07e66 100644 --- a/src/gameobjects/particles/ParticleManagerWebGLRenderer.js +++ b/src/gameobjects/particles/ParticleManagerWebGLRenderer.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); +var Utils = require('../../renderer/webgl/Utils'); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -23,14 +23,119 @@ var GameObject = require('../GameObject'); */ var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpolationPercentage, camera, parentMatrix) { - var emitters = emitterManager.emitters; + var emitters = emitterManager.emitters.list; + var emittersLength = emitters.length; - if (emitters.length === 0 || GameObject.RENDER_MASK !== emitterManager.renderFlags || (emitterManager.cameraFilter > 0 && (emitterManager.cameraFilter & camera._id))) + if (emittersLength === 0) { return; } - this.pipeline.drawEmitterManager(emitterManager, camera, parentMatrix); + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1.copyFrom(camera.matrix); + var calcMatrix = pipeline._tempMatrix2; + var particleMatrix = pipeline._tempMatrix3; + var managerMatrix = pipeline._tempMatrix4.applyITRS(emitterManager.x, emitterManager.y, emitterManager.rotation, emitterManager.scaleX, emitterManager.scaleY); + + camMatrix.multiply(managerMatrix); + + renderer.setPipeline(pipeline); + + var roundPixels = camera.roundPixels; + var texture = emitterManager.defaultFrame.glTexture; + var getTint = Utils.getTintAppendFloatAlphaAndSwap; + + pipeline.setTexture2D(texture, 0); + + for (var e = 0; e < emittersLength; e++) + { + var emitter = emitters[e]; + var particles = emitter.alive; + var particleCount = particles.length; + + if (!emitter.visible || particleCount === 0) + { + continue; + } + + var scrollX = camera.scrollX * emitter.scrollFactorX; + var scrollY = camera.scrollY * emitter.scrollFactorY; + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -scrollX, -scrollY); + + scrollX = 0; + scrollY = 0; + } + + if (renderer.setBlendMode(emitter.blendMode)) + { + // Rebind the texture if we've flushed + pipeline.setTexture2D(texture, 0); + } + + var tintEffect = 0; + + for (var i = 0; i < particleCount; i++) + { + var particle = particles[i]; + + var alpha = particle.alpha * camera.alpha; + + if (alpha <= 0) + { + continue; + } + + var frame = particle.frame; + + var x = -(frame.halfWidth); + var y = -(frame.halfHeight); + var xw = x + frame.width; + var yh = y + frame.height; + + particleMatrix.applyITRS(0, 0, particle.rotation, particle.scaleX, particle.scaleY); + + particleMatrix.e = particle.x - scrollX; + particleMatrix.f = particle.y - scrollY; + + camMatrix.multiply(particleMatrix, calcMatrix); + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (roundPixels) + { + tx0 = Math.round(tx0); + ty0 = Math.round(ty0); + + tx1 = Math.round(tx1); + ty1 = Math.round(ty1); + + tx2 = Math.round(tx2); + ty2 = Math.round(ty2); + + tx3 = Math.round(tx3); + ty3 = Math.round(ty3); + } + + var tint = getTint(particle.tint, alpha); + + pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect, texture, 0); + } + } }; module.exports = ParticleManagerWebGLRenderer; diff --git a/src/gameobjects/particles/zones/DeathZone.js b/src/gameobjects/particles/zones/DeathZone.js index 22fc59918..fa18e68e1 100644 --- a/src/gameobjects/particles/zones/DeathZone.js +++ b/src/gameobjects/particles/zones/DeathZone.js @@ -37,7 +37,7 @@ var Class = require('../../../utils/Class'); * object as long as it includes a `contains` method for which the Particles can be tested against. * * @class DeathZone - * @memberOf Phaser.GameObjects.Particles.Zones + * @memberof Phaser.GameObjects.Particles.Zones * @constructor * @since 3.0.0 * diff --git a/src/gameobjects/particles/zones/EdgeZone.js b/src/gameobjects/particles/zones/EdgeZone.js index 9644751a8..05ae162f2 100644 --- a/src/gameobjects/particles/zones/EdgeZone.js +++ b/src/gameobjects/particles/zones/EdgeZone.js @@ -35,7 +35,7 @@ var Class = require('../../../utils/Class'); * A zone that places particles on a shape's edges. * * @class EdgeZone - * @memberOf Phaser.GameObjects.Particles.Zones + * @memberof Phaser.GameObjects.Particles.Zones * @constructor * @since 3.0.0 * diff --git a/src/gameobjects/particles/zones/RandomZone.js b/src/gameobjects/particles/zones/RandomZone.js index c381aec3a..34f8d33a7 100644 --- a/src/gameobjects/particles/zones/RandomZone.js +++ b/src/gameobjects/particles/zones/RandomZone.js @@ -31,7 +31,7 @@ var Vector2 = require('../../../math/Vector2'); * A zone that places particles randomly within a shape's area. * * @class RandomZone - * @memberOf Phaser.GameObjects.Particles.Zones + * @memberof Phaser.GameObjects.Particles.Zones * @constructor * @since 3.0.0 * diff --git a/src/gameobjects/pathfollower/PathFollower.js b/src/gameobjects/pathfollower/PathFollower.js index 00d69e754..07c9c6706 100644 --- a/src/gameobjects/pathfollower/PathFollower.js +++ b/src/gameobjects/pathfollower/PathFollower.js @@ -23,7 +23,7 @@ var Vector2 = require('../../math/Vector2'); * @property {boolean} [positionOnPath=false] - Whether to position the PathFollower on the Path using its path offset. * @property {boolean} [rotateToPath=false] - Should the PathFollower automatically rotate to point in the direction of the Path? * @property {number} [rotationOffset=0] - If the PathFollower is rotating to match the Path, this value is added to the rotation value. This allows you to rotate objects to a path but control the angle of the rotation as well. - * @property {boolean} [verticalAdjust=false] - [description] + * @property {number} [startAt=0] - Current start position of the path follow, between 0 and 1. */ /** @@ -41,7 +41,7 @@ var Vector2 = require('../../math/Vector2'); * * @class PathFollower * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -81,16 +81,6 @@ var PathFollower = new Class({ */ this.rotateToPath = false; - /** - * [description] - * - * @name Phaser.GameObjects.PathFollower#pathRotationVerticalAdjust - * @type {boolean} - * @default false - * @since 3.0.0 - */ - this.pathRotationVerticalAdjust = false; - /** * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) * this value is added to the rotation value. This allows you to rotate objects to a path but control @@ -114,7 +104,7 @@ var PathFollower = new Class({ this.pathOffset = new Vector2(x, y); /** - * [description] + * A Vector2 that stores the current point of the path the follower is on. * * @name Phaser.GameObjects.PathFollower#pathVector * @type {Phaser.Math.Vector2} @@ -194,19 +184,16 @@ var PathFollower = new Class({ * * @param {boolean} value - Whether the PathFollower should automatically rotate to point in the direction of the Path. * @param {number} [offset=0] - Rotation offset in degrees. - * @param {boolean} [verticalAdjust=false] - [description] * * @return {Phaser.GameObjects.PathFollower} This Game Object. */ - setRotateToPath: function (value, offset, verticalAdjust) + setRotateToPath: function (value, offset) { if (offset === undefined) { offset = 0; } - if (verticalAdjust === undefined) { verticalAdjust = false; } this.rotateToPath = value; this.pathRotationOffset = offset; - this.pathRotationVerticalAdjust = verticalAdjust; return this; }, @@ -266,7 +253,22 @@ var PathFollower = new Class({ this.rotateToPath = GetBoolean(config, 'rotateToPath', false); this.pathRotationOffset = GetValue(config, 'rotationOffset', 0); - this.pathRotationVerticalAdjust = GetBoolean(config, 'verticalAdjust', false); + + // This works, but it's not an ideal way of doing it as the follower jumps position + var seek = GetValue(config, 'startAt', startAt); + + if (seek) + { + config.onStart = function (tween) + { + var tweenData = tween.data[0]; + tweenData.progress = seek; + tweenData.elapsed = tweenData.duration * seek; + var v = tweenData.ease(tweenData.progress); + tweenData.current = tweenData.start + ((tweenData.end - tweenData.start) * v); + tweenData.target[tweenData.key] = tweenData.current; + }; + } this.pathTween = this.scene.sys.tweens.addCounter(config); @@ -421,11 +423,6 @@ var PathFollower = new Class({ if (this.rotateToPath) { this.rotation = Math.atan2(speedY, speedX) + DegToRad(this.pathRotationOffset); - - if (this.pathRotationVerticalAdjust) - { - this.flipY = (this.rotation !== 0 && tweenData.state === TWEEN_CONST.PLAYING_BACKWARD); - } } } } diff --git a/src/gameobjects/quad/Quad.js b/src/gameobjects/quad/Quad.js index 5d9e3b009..955e778a2 100644 --- a/src/gameobjects/quad/Quad.js +++ b/src/gameobjects/quad/Quad.js @@ -19,7 +19,7 @@ var Mesh = require('../mesh/Mesh'); * * @class Quad * @extends Phaser.GameObjects.Mesh - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @webglOnly * @since 3.0.0 @@ -54,6 +54,7 @@ var Quad = new Class({ 0, 0, // br 0, 0 // tr ]; + var uv = [ 0, 0, // tl 0, 1, // bl @@ -62,6 +63,7 @@ var Quad = new Class({ 1, 1, // br 1, 0 // tr ]; + var colors = [ 0xffffff, // tl 0xffffff, // bl @@ -70,6 +72,7 @@ var Quad = new Class({ 0xffffff, // br 0xffffff // tr ]; + var alphas = [ 1, // tl 1, // bl @@ -84,6 +87,65 @@ var Quad = new Class({ this.resetPosition(); }, + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * + * @method Phaser.GameObjects.Quad#setFrame + * @since 3.11.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame) + { + this.frame = this.texture.get(frame); + + if (!this.frame.cutWidth || !this.frame.cutHeight) + { + this.renderFlags &= ~8; + } + else + { + this.renderFlags |= 8; + } + + frame = this.frame; + + // TL + this.uv[0] = frame.u0; + this.uv[1] = frame.v0; + + // BL + this.uv[2] = frame.u0; + this.uv[3] = frame.v1; + + // BR + this.uv[4] = frame.u1; + this.uv[5] = frame.v1; + + // TL + this.uv[6] = frame.u0; + this.uv[7] = frame.v0; + + // BR + this.uv[8] = frame.u1; + this.uv[9] = frame.v1; + + // TR + this.uv[10] = frame.u1; + this.uv[11] = frame.v0; + + return this; + }, + /** * The top-left x vertex of this Quad. * diff --git a/src/gameobjects/rendertexture/RenderTexture.js b/src/gameobjects/rendertexture/RenderTexture.js index 2772b8e97..173824565 100644 --- a/src/gameobjects/rendertexture/RenderTexture.js +++ b/src/gameobjects/rendertexture/RenderTexture.js @@ -4,22 +4,29 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var BlendModes = require('../../renderer/BlendModes'); +var Camera = require('../../cameras/2d/BaseCamera'); var CanvasPool = require('../../display/canvas/CanvasPool'); var Class = require('../../utils/Class'); var Components = require('../components'); var CONST = require('../../const'); +var Frame = require('../../textures/Frame'); var GameObject = require('../GameObject'); var Render = require('./RenderTextureRender'); -var RenderTextureCanvas = require('./RenderTextureCanvas'); -var RenderTextureWebGL = require('./RenderTextureWebGL'); +var Utils = require('../../renderer/webgl/Utils'); +var UUID = require('../../utils/string/UUID'); /** * @classdesc * A Render Texture. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. * * @class RenderTexture * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.2.0 * @@ -30,7 +37,6 @@ var RenderTextureWebGL = require('./RenderTextureWebGL'); * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.GetBounds * @extends Phaser.GameObjects.Components.Mask - * @extends Phaser.GameObjects.Components.MatrixStack * @extends Phaser.GameObjects.Components.Origin * @extends Phaser.GameObjects.Components.Pipeline * @extends Phaser.GameObjects.Components.ScaleMode @@ -40,8 +46,8 @@ var RenderTextureWebGL = require('./RenderTextureWebGL'); * @extends Phaser.GameObjects.Components.Visible * * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param {number} x - The horizontal position of this Game Object in the world. - * @param {number} y - The vertical position of this Game Object in the world. + * @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 {integer} [width=32] - The width of the Render Texture. * @param {integer} [height=32] - The height of the Render Texture. */ @@ -53,11 +59,11 @@ var RenderTexture = new Class({ Components.Alpha, Components.BlendMode, Components.ComputedSize, + Components.Crop, Components.Depth, Components.Flip, Components.GetBounds, Components.Mask, - Components.MatrixStack, Components.Origin, Components.Pipeline, Components.ScaleMode, @@ -72,13 +78,13 @@ var RenderTexture = new Class({ function RenderTexture (scene, x, y, width, height) { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } if (width === undefined) { width = 32; } if (height === undefined) { height = 32; } GameObject.call(this, scene, 'RenderTexture'); - this.initMatrixStack(); - /** * A reference to either the Canvas or WebGL Renderer that the Game instance is using. * @@ -88,6 +94,15 @@ var RenderTexture = new Class({ */ this.renderer = scene.sys.game.renderer; + /** + * A reference to the Texture Manager. + * + * @name Phaser.GameObjects.RenderTexture#textureManager + * @type {Phaser.Textures.TextureManager} + * @since 3.12.0 + */ + this.textureManager = scene.sys.textures; + /** * The tint of the Render Texture when rendered. * @@ -109,24 +124,22 @@ var RenderTexture = new Class({ this.globalAlpha = 1; /** - * The HTML Canvas Element that the Render Texture is drawing to. - * This is only set if Phaser is running with the Canvas Renderer. + * The HTML Canvas Element that the Render Texture is drawing to when using the Canvas Renderer. * * @name Phaser.GameObjects.RenderTexture#canvas - * @type {?HTMLCanvasElement} + * @type {HTMLCanvasElement} * @since 3.2.0 */ - this.canvas = null; + this.canvas = CanvasPool.create2D(this, width, height); /** * A reference to the Rendering Context belonging to the Canvas Element this Render Texture is drawing to. - * This is only set if Phaser is running with the Canvas Renderer. * * @name Phaser.GameObjects.RenderTexture#context - * @type {?CanvasRenderingContext2D} + * @type {CanvasRenderingContext2D} * @since 3.2.0 */ - this.context = null; + this.context = this.canvas.getContext('2d'); /** * A reference to the GL Frame Buffer this Render Texture is drawing to. @@ -138,31 +151,121 @@ var RenderTexture = new Class({ */ this.framebuffer = null; - if (this.renderer.type === CONST.WEBGL) + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.RenderTexture#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Texture corresponding to this Render Texture. + * + * @name Phaser.GameObjects.RenderTexture#texture + * @type {Phaser.Textures.Texture} + * @since 3.12.0 + */ + this.texture = scene.sys.textures.addCanvas(UUID(), this.canvas); + + /** + * The Frame corresponding to this Render Texture. + * + * @name Phaser.GameObjects.RenderTexture#frame + * @type {Phaser.Textures.Frame} + * @since 3.12.0 + */ + this.frame = this.texture.get(); + + /** + * Internal saved texture flag. + * + * @name Phaser.GameObjects.RenderTexture#_saved + * @type {boolean} + * @private + * @since 3.12.0 + */ + this._saved = false; + + /** + * Internal erase mode flag. + * + * @name Phaser.GameObjects.RenderTexture#_eraseMode + * @type {boolean} + * @private + * @since 3.16.0 + */ + this._eraseMode = false; + + /** + * An internal Camera that can be used to move around the Render Texture. + * Control it just like you would any Scene Camera. The difference is that it only impacts the placement of what + * is drawn to the Render Texture. You can scroll, zoom and rotate this Camera. + * + * @name Phaser.GameObjects.RenderTexture#camera + * @type {Phaser.Cameras.Scene2D.BaseCamera} + * @since 3.12.0 + */ + this.camera = new Camera(0, 0, width, height); + + /** + * Is this Render Texture dirty or not? If not it won't spend time clearing or filling itself. + * + * @name Phaser.GameObjects.RenderTexture#dirty + * @type {boolean} + * @since 3.12.0 + */ + this.dirty = false; + + /** + * A reference to the WebGL Rendering Context. + * + * @name Phaser.GameObjects.RenderTexture#gl + * @type {WebGLRenderingContext} + * @default null + * @since 3.0.0 + */ + this.gl = null; + + var renderer = this.renderer; + + if (renderer.type === CONST.WEBGL) { - var gl = this.renderer.gl; + var gl = renderer.gl; this.gl = gl; - this.fill = RenderTextureWebGL.fill; - this.clear = RenderTextureWebGL.clear; - this.draw = RenderTextureWebGL.draw; - this.drawFrame = RenderTextureWebGL.drawFrame; - this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); - this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); + this.drawGameObject = this.batchGameObjectWebGL; + this.framebuffer = renderer.createFramebuffer(width, height, this.frame.source.glTexture, false); } - else if (this.renderer.type === CONST.CANVAS) + else if (renderer.type === CONST.CANVAS) { - this.fill = RenderTextureCanvas.fill; - this.clear = RenderTextureCanvas.clear; - this.draw = RenderTextureCanvas.draw; - this.drawFrame = RenderTextureCanvas.drawFrame; - this.canvas = CanvasPool.create2D(this, width, height); - this.context = this.canvas.getContext('2d'); + this.drawGameObject = this.batchGameObjectCanvas; } + this.camera.setScene(scene); + this.setPosition(x, y); this.setSize(width, height); - this.initPipeline('TextureTintPipeline'); + this.setOrigin(0, 0); + this.initPipeline(); + }, + + /** + * Sets the size of this Game Object. + * + * @method Phaser.GameObjects.Components.Size#setSize + * @since 3.0.0 + * + * @param {number} width - The width of this Game Object. + * @param {number} height - The height of this Game Object. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + return this.resize(width, height); }, /** @@ -188,23 +291,31 @@ var RenderTexture = new Class({ if (width !== this.width || height !== this.height) { - if (this.canvas) + this.canvas.width = width; + this.canvas.height = height; + + if (this.gl) { - this.canvas.width = width; - this.canvas.height = height; - } - else - { - this.renderer.deleteTexture(this.texture); + var gl = this.gl; + + this.renderer.deleteTexture(this.frame.source.glTexture); this.renderer.deleteFramebuffer(this.framebuffer); - var gl = this.renderer.gl; + this.frame.source.glTexture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); + this.framebuffer = this.renderer.createFramebuffer(width, height, this.frame.source.glTexture, false); - this.texture = this.renderer.createTexture2D(0, gl.NEAREST, gl.NEAREST, gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE, gl.RGBA, null, width, height, false); - this.framebuffer = this.renderer.createFramebuffer(width, height, this.texture, false); + this.frame.glTexture = this.frame.source.glTexture; } - this.setSize(width, height); + this.frame.source.width = width; + this.frame.source.height = height; + + this.camera.setSize(width, height); + + this.frame.setSize(width, height); + + this.width = width; + this.height = height; } return this; @@ -245,20 +356,44 @@ var RenderTexture = new Class({ }, /** - * Internal destroy handler, called as part of the destroy process. + * Stores a copy of this Render Texture in the Texture Manager using the given key. + * + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this + * Render Texture by using the texture key: + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 128, 128); + * + * // Draw something to the Render Texture + * + * rt.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Updating the contents of this Render Texture will automatically update _any_ Game Object + * that is using it as a texture. Calling `saveTexture` again will not save another copy + * of the same texture, it will just rename the key of the existing copy. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. * - * @method Phaser.GameObjects.RenderTexture#preDestroy - * @protected - * @since 3.9.0 + * @method Phaser.GameObjects.RenderTexture#saveTexture + * @since 3.12.0 + * + * @param {string} key - The unique key to store the texture as within the global Texture Manager. + * + * @return {Phaser.Textures.Texture} The Texture that was saved. */ - preDestroy: function () + saveTexture: function (key) { - if (this.renderer && this.renderer.gl) - { - this.renderer.deleteTexture(this.texture); - this.renderer.deleteFramebuffer(this.framebuffer); - } - } + this.textureManager.renameTexture(this.texture.key, key); + + this._saved = true; + + return this.texture; + }, /** * Fills the Render Texture with the given color. @@ -267,9 +402,44 @@ var RenderTexture = new Class({ * @since 3.2.0 * * @param {number} rgb - The color to fill the Render Texture with. + * @param {number} [alpha=1] - The alpha value used by the fill. * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. + * @return {this} This Render Texture instance. */ + fill: function (rgb, alpha) + { + if (alpha === undefined) { alpha = 1; } + + var r = ((rgb >> 16) | 0) & 0xff; + var g = ((rgb >> 8) | 0) & 0xff; + var b = (rgb | 0) & 0xff; + + var gl = this.gl; + + if (gl) + { + var renderer = this.renderer; + + var bounds = this.getBounds(); + + renderer.setFramebuffer(this.framebuffer, true); + + renderer.pipelines.TextureTintPipeline.drawFillRect( + bounds.x, bounds.y, bounds.right, bounds.bottom, + Utils.getTintFromFloats(r / 255, g / 255, b / 255, 1), + alpha + ); + + renderer.setFramebuffer(null, true); + } + else + { + this.context.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + alpha + ')'; + this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); + } + + return this; + }, /** * Clears the Render Texture. @@ -277,22 +447,547 @@ var RenderTexture = new Class({ * @method Phaser.GameObjects.RenderTexture#clear * @since 3.2.0 * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. + * @return {this} This Render Texture instance. */ + clear: function () + { + if (this.dirty) + { + var gl = this.gl; + + if (gl) + { + var renderer = this.renderer; + + renderer.setFramebuffer(this.framebuffer, true); + + gl.clearColor(0, 0, 0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); + + renderer.setFramebuffer(null, true); + } + else + { + var ctx = this.context; + + ctx.save(); + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + ctx.restore(); + } + + this.dirty = false; + } + + return this; + }, /** - * Draws a texture frame to the Render Texture at the given position. + * Draws the given object, or an array of objects, to this Render Texture using a blend mode of ERASE. + * This has the effect of erasing any filled pixels in the objects from this Render Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Dynamic and Static Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. + * * Another Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot erase a Render Texture from itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * + * @method Phaser.GameObjects.RenderTexture#erase + * @since 3.16.0 + * + * @param {any} entries - Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param {number} [x] - The x position to draw the Frame at, or the offset applied to the object. + * @param {number} [y] - The y position to draw the Frame at, or the offset applied to the object. + * + * @return {this} This Render Texture instance. + */ + erase: function (entries, x, y) + { + this._eraseMode = true; + + var blendMode = this.renderer.currentBlendMode; + + this.renderer.setBlendMode(BlendModes.ERASE); + + this.draw(entries, x, y, 1, 16777215); + + this.renderer.setBlendMode(blendMode); + + this._eraseMode = false; + + return this; + }, + + /** + * Draws the given object, or an array of objects, to this Render Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Dynamic and Static Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. + * * Another Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot draw a Render Texture to itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. * * @method Phaser.GameObjects.RenderTexture#draw * @since 3.2.0 * - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. - * @param {number} x - The x position to draw the frame at. - * @param {number} y - The y position to draw the frame at. + * @param {any} entries - Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param {number} [x] - The x position to draw the Frame at, or the offset applied to the object. + * @param {number} [y] - The y position to draw the Frame at, or the offset applied to the object. + * @param {number} [alpha] - The alpha value. Only used for Texture Frames and if not specified defaults to the `globalAlpha` property. Game Objects use their own current alpha value. + * @param {number} [tint] - WebGL only. The tint color value. Only used for Texture Frames and if not specified defaults to the `globalTint` property. Game Objects use their own current tint value. * - * @return {Phaser.GameObjects.RenderTexture} This Game Object. + * @return {this} This Render Texture instance. */ + draw: function (entries, x, y, alpha, tint) + { + if (alpha === undefined) { alpha = this.globalAlpha; } + + if (tint === undefined) + { + tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + } + else + { + tint = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16); + } + + if (!Array.isArray(entries)) + { + entries = [ entries ]; + } + + var gl = this.gl; + + this.camera.preRender(1, 1); + + if (gl) + { + var cx = this.camera._cx; + var cy = this.camera._cy; + var cw = this.camera._cw; + var ch = this.camera._ch; + + this.renderer.setFramebuffer(this.framebuffer, false); + + this.renderer.pushScissor(cx, cy, cw, ch, ch); + + var pipeline = this.pipeline; + + pipeline.projOrtho(0, this.width, 0, this.height, -1000.0, 1000.0); + + this.batchList(entries, x, y, alpha, tint); + + pipeline.flush(); + + this.renderer.setFramebuffer(null, false); + + this.renderer.popScissor(); + + pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000.0, 1000.0); + } + else + { + this.renderer.setContext(this.context); + + this.batchList(entries, x, y, alpha, tint); + + this.renderer.setContext(); + } + + this.dirty = true; + + return this; + }, + + /** + * Draws the Texture Frame to the Render Texture at the given position. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 800, 600); + * rt.drawFrame(key, frame); + * ``` + * + * You can optionally provide a position, alpha and tint value to apply to the frame + * before it is drawn. + * + * Calling this method will cause a batch flush, so if you've got a stack of things to draw + * in a tight loop, try using the `draw` method instead. + * + * If you need to draw a Sprite to this Render Texture, use the `draw` method instead. + * + * @method Phaser.GameObjects.RenderTexture#drawFrame + * @since 3.12.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} [x=0] - The x position to draw the frame at. + * @param {number} [y=0] - The y position to draw the frame at. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - WebGL only. The tint color to use. If not specified it uses the `globalTint` property. + * + * @return {this} This Render Texture instance. + */ + drawFrame: function (key, frame, x, y, alpha, tint) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (alpha === undefined) { alpha = this.globalAlpha; } + + if (tint === undefined) + { + tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); + } + else + { + tint = (tint >> 16) + (tint & 0xff00) + ((tint & 0xff) << 16); + } + + var gl = this.gl; + var textureFrame = this.textureManager.getFrame(key, frame); + + if (textureFrame) + { + this.camera.preRender(1, 1); + + if (gl) + { + var cx = this.camera._cx; + var cy = this.camera._cy; + var cw = this.camera._cw; + var ch = this.camera._ch; + + this.renderer.setFramebuffer(this.framebuffer, false); + + this.renderer.pushScissor(cx, cy, cw, ch, ch); + + var pipeline = this.pipeline; + + pipeline.projOrtho(0, this.width, 0, this.height, -1000.0, 1000.0); + + pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null); + + pipeline.flush(); + + this.renderer.setFramebuffer(null, false); + + this.renderer.popScissor(); + + pipeline.projOrtho(0, pipeline.width, pipeline.height, 0, -1000.0, 1000.0); + } + else + { + this.batchTextureFrame(textureFrame, x, y, alpha, tint); + } + + this.dirty = true; + } + + return this; + }, + + /** + * Internal method that handles the drawing of an array of children. + * + * @method Phaser.GameObjects.RenderTexture#batchList + * @private + * @since 3.12.0 + * + * @param {array} children - The array of Game Objects to draw. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - The tint color to use. If not specified it uses the `globalTint` property. + */ + batchList: function (children, x, y, alpha, tint) + { + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (!entry || entry === this) + { + continue; + } + + if (entry.renderWebGL || entry.renderCanvas) + { + // Game Objects + this.drawGameObject(entry, x, y); + } + else if (entry.isParent || entry.list) + { + // Groups / Display Lists + this.batchGroup(entry.getChildren(), x, y); + } + else if (typeof entry === 'string') + { + // Texture key + this.batchTextureFrameKey(entry, null, x, y, alpha, tint); + } + else if (entry instanceof Frame) + { + // Texture Frame instance + this.batchTextureFrame(entry, x, y, alpha, tint); + } + else if (Array.isArray(entry)) + { + // Another Array + this.batchList(entry, x, y, alpha, tint); + } + } + }, + + /** + * Internal method that handles the drawing a Phaser Group contents. + * + * @method Phaser.GameObjects.RenderTexture#batchGroup + * @private + * @since 3.12.0 + * + * @param {array} children - The array of Game Objects to draw. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + */ + batchGroup: function (children, x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + for (var i = 0; i < children.length; i++) + { + var entry = children[i]; + + if (entry.willRender()) + { + var tx = entry.x + x; + var ty = entry.y + y; + + this.drawGameObject(entry, tx, ty); + } + } + }, + + /** + * Internal method that handles drawing a single Phaser Game Object to this Render Texture using WebGL. + * + * @method Phaser.GameObjects.RenderTexture#batchGameObjectWebGL + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to draw. + * @param {number} x - The x position to draw the Game Object at. + * @param {number} y - The y position to draw the Game Object at. + */ + batchGameObjectWebGL: function (gameObject, x, y) + { + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + var prevX = gameObject.x; + var prevY = gameObject.y; + + if (!this._eraseMode) + { + this.renderer.setBlendMode(gameObject.blendMode); + } + + gameObject.setPosition(x, y); + + gameObject.renderWebGL(this.renderer, gameObject, 0, this.camera, null); + + gameObject.setPosition(prevX, prevY); + }, + + /** + * Internal method that handles drawing a single Phaser Game Object to this Render Texture using Canvas. + * + * @method Phaser.GameObjects.RenderTexture#batchGameObjectCanvas + * @private + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to draw. + * @param {number} x - The x position to draw the Game Object at. + * @param {number} y - The y position to draw the Game Object at. + */ + batchGameObjectCanvas: function (gameObject, x, y) + { + if (x === undefined) { x = gameObject.x; } + if (y === undefined) { y = gameObject.y; } + + var prevX = gameObject.x; + var prevY = gameObject.y; + + if (this._eraseMode) + { + var blendMode = gameObject.blendMode; + + gameObject.blendMode = BlendModes.ERASE; + } + + gameObject.setPosition(x, y); + + gameObject.renderCanvas(this.renderer, gameObject, 0, this.camera, null); + + gameObject.setPosition(prevX, prevY); + + if (this._eraseMode) + { + gameObject.blendMode = blendMode; + } + }, + + /** + * Internal method that handles the drawing of an array of children. + * + * @method Phaser.GameObjects.RenderTexture#batchTextureFrameKey + * @private + * @since 3.12.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * @param {number} x - The x position to offset the Game Object by. + * @param {number} y - The y position to offset the Game Object by. + * @param {number} [alpha] - The alpha to use. If not specified it uses the `globalAlpha` property. + * @param {number} [tint] - The tint color to use. If not specified it uses the `globalTint` property. + * + * @return {boolean} `true` if the frame was found and drawn, otherwise `false`. + */ + batchTextureFrameKey: function (key, frame, x, y, alpha, tint) + { + var textureFrame = this.textureManager.getFrame(key, frame); + + if (textureFrame) + { + this.batchTextureFrame(textureFrame, x, y, alpha, tint); + } + }, + + /** + * Internal method that handles the drawing of a Texture Frame to this Render Texture. + * + * @method Phaser.GameObjects.RenderTexture#batchTextureFrame + * @private + * @since 3.12.0 + * + * @param {Phaser.Textures.Frame} textureFrame - The Texture Frame to draw. + * @param {number} x - The x position to draw the Frame at. + * @param {number} y - The y position to draw the Frame at. + * @param {number} [tint] - A tint color to be applied to the frame drawn to the Render Texture. + */ + batchTextureFrame: function (textureFrame, x, y, alpha, tint) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + if (this.gl) + { + this.pipeline.batchTextureFrame(textureFrame, x, y, tint, alpha, this.camera.matrix, null); + } + else + { + var ctx = this.context; + var cd = textureFrame.canvasData; + var source = textureFrame.source.image; + + var matrix = this.camera.matrix; + + ctx.globalAlpha = this.globalAlpha; + + ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); + + ctx.drawImage(source, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height); + } + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.RenderTexture#preDestroy + * @protected + * @since 3.9.0 + */ + preDestroy: function () + { + if (!this._saved) + { + CanvasPool.remove(this.canvas); + + if (this.gl) + { + this.renderer.deleteFramebuffer(this.framebuffer); + } + + this.texture.destroy(); + this.camera.destroy(); + + this.canvas = null; + this.context = null; + this.framebuffer = null; + this.texture = null; + } + } }); diff --git a/src/gameobjects/rendertexture/RenderTextureCanvas.js b/src/gameobjects/rendertexture/RenderTextureCanvas.js deleted file mode 100644 index 750532e8e..000000000 --- a/src/gameobjects/rendertexture/RenderTextureCanvas.js +++ /dev/null @@ -1,41 +0,0 @@ -var RenderTextureCanvas = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.context.fillStyle = 'rgb(' + ur + ',' + ug + ',' + ub + ')'; - this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); - - return this; - }, - - clear: function () - { - this.context.save(); - this.context.setTransform(1, 0, 0, 1, 0, 0); - this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); - this.context.restore(); - - return this; - }, - - draw: function (texture, frame, x, y) - { - var cd = frame.canvasData; - var source = frame.source.image; - - var matrix = this.currentMatrix; - - this.context.globalAlpha = this.globalAlpha; - this.context.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - this.context.drawImage(source, cd.sx, cd.sy, cd.sWidth, cd.sHeight, x, y, cd.dWidth, cd.dHeight); - - return this; - } - -}; - -module.exports = RenderTextureCanvas; diff --git a/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js b/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js index 3e77d0352..ea7e7c2ee 100644 --- a/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js +++ b/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -16,91 +14,14 @@ var GameObject = require('../GameObject'); * @private * * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolationPercentage, camera, parentMatrix) +var RenderTextureCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } - - var ctx = renderer.currentContext; - - // Alpha - - var alpha = camera.alpha * renderTexture.alpha; - - if (alpha === 0) - { - // Nothing to see, so abort early - return; - } - else if (renderer.currentAlpha !== alpha) - { - renderer.currentAlpha = alpha; - ctx.globalAlpha = alpha; - } - - // Blend Mode - - if (renderer.currentBlendMode !== renderTexture.blendMode) - { - renderer.currentBlendMode = renderTexture.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; - } - - // Scale Mode - - if (renderer.currentScaleMode !== renderTexture.scaleMode) - { - renderer.currentScaleMode = renderTexture.scaleMode; - } - - var dx = 0; - var dy = 0; - - var fx = 1; - var fy = 1; - - if (renderTexture.flipX) - { - fx = -1; - dx -= renderTexture.canvas.width - renderTexture.displayOriginX; - } - else - { - dx -= renderTexture.displayOriginX; - } - - if (renderTexture.flipY) - { - fy = -1; - dy -= renderTexture.canvas.height - renderTexture.displayOriginY; - } - else - { - dy -= renderTexture.displayOriginY; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY); - ctx.rotate(renderTexture.rotation); - ctx.scale(renderTexture.scaleX, renderTexture.scaleY); - ctx.scale(fx, fy); - ctx.drawImage(renderTexture.canvas, dx, dy); - ctx.restore(); + renderer.batchSprite(src, src.frame, camera, parentMatrix); }; module.exports = RenderTextureCanvasRenderer; diff --git a/src/gameobjects/rendertexture/RenderTextureFactory.js b/src/gameobjects/rendertexture/RenderTextureFactory.js index c4cfc0435..98a5b496a 100644 --- a/src/gameobjects/rendertexture/RenderTextureFactory.js +++ b/src/gameobjects/rendertexture/RenderTextureFactory.js @@ -11,6 +11,10 @@ var RenderTexture = require('./RenderTexture'); * Creates a new Render Texture Game Object and adds it to the Scene. * * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. * * @method Phaser.GameObjects.GameObjectFactory#renderTexture * @since 3.2.0 diff --git a/src/gameobjects/rendertexture/RenderTextureWebGL.js b/src/gameobjects/rendertexture/RenderTextureWebGL.js deleted file mode 100644 index 94d5b5a34..000000000 --- a/src/gameobjects/rendertexture/RenderTextureWebGL.js +++ /dev/null @@ -1,50 +0,0 @@ -var RenderTextureWebGL = { - - fill: function (rgb) - { - var ur = ((rgb >> 16)|0) & 0xff; - var ug = ((rgb >> 8)|0) & 0xff; - var ub = (rgb|0) & 0xff; - - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(ur / 255.0, ug / 255.0, ub / 255.0, 1); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - clear: function () - { - this.renderer.setFramebuffer(this.framebuffer); - var gl = this.gl; - gl.clearColor(0, 0, 0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); - this.renderer.setFramebuffer(null); - return this; - }, - - draw: function (texture, frame, x, y) - { - var glTexture = texture.source[frame.sourceIndex].glTexture; - - var tint = (this.globalTint >> 16) + (this.globalTint & 0xff00) + ((this.globalTint & 0xff) << 16); - - this.renderer.setFramebuffer(this.framebuffer); - - var ttp = this.renderer.pipelines.TextureTintPipeline; - - ttp.projOrtho(0, ttp.width, 0, ttp.height, -1000.0, 1000.0); - - ttp.drawTexture(glTexture, x, y, tint, this.globalAlpha, frame.cutX, frame.cutY, frame.cutWidth, frame.cutHeight, this.currentMatrix, null, this); - - this.renderer.setFramebuffer(null); - - ttp.projOrtho(0, ttp.width, ttp.height, 0, -1000.0, 1000.0); - - return this; - } - -}; - -module.exports = RenderTextureWebGL; diff --git a/src/gameobjects/rendertexture/RenderTextureWebGLRenderer.js b/src/gameobjects/rendertexture/RenderTextureWebGLRenderer.js index 74ec6a027..e3343b6ac 100644 --- a/src/gameobjects/rendertexture/RenderTextureWebGLRenderer.js +++ b/src/gameobjects/rendertexture/RenderTextureWebGLRenderer.js @@ -4,48 +4,54 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); var Utils = require('../../renderer/webgl/Utils'); /** - * Renders this Game Object with the Canvas Renderer to the given Camera. + * Renders this Game Object with the WebGL Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. * This method should not be called directly. It is a utility function of the Render module. * - * @method Phaser.GameObjects.RenderTexture#renderWebgl + * @method Phaser.GameObjects.RenderTexture#renderWebGL * @since 3.2.0 * @private * * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active Canvas renderer. - * @param {Phaser.GameObjects.RenderTexture} renderTexture - The Game Object being rendered in this call. + * @param {Phaser.GameObjects.RenderTexture} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var RenderTextureWebGLRenderer = function (renderer, renderTexture, interpolationPercentage, camera, parentMatrix) +var RenderTextureWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== renderTexture.renderFlags || (renderTexture.cameraFilter > 0 && (renderTexture.cameraFilter & camera._id))) - { - return; - } + var frame = src.frame; + var width = frame.width; + var height = frame.height; + var getTint = Utils.getTintAppendFloatAlpha; this.pipeline.batchTexture( - renderTexture, - renderTexture.texture, - renderTexture.texture.width, renderTexture.texture.height, - renderTexture.x, renderTexture.y, - renderTexture.width, renderTexture.height, - renderTexture.scaleX, renderTexture.scaleY, - renderTexture.rotation, - renderTexture.flipX, !renderTexture.flipY, - renderTexture.scrollFactorX, renderTexture.scrollFactorY, - renderTexture.displayOriginX, renderTexture.displayOriginY, - 0, 0, renderTexture.texture.width, renderTexture.texture.height, - Utils.getTintAppendFloatAlpha(renderTexture.tintTopLeft, renderTexture.alphaTopLeft), Utils.getTintAppendFloatAlpha(renderTexture.tintTopRight, renderTexture.alphaTopRight), Utils.getTintAppendFloatAlpha(renderTexture.tintBottomLeft, renderTexture.alphaBottomLeft), Utils.getTintAppendFloatAlpha(renderTexture.tintBottomRight, renderTexture.alphaBottomRight), + src, + frame.glTexture, + width, height, + src.x, src.y, + width, height, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, !src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.displayOriginX, src.displayOriginY, + 0, 0, width, height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), 0, 0, camera, parentMatrix ); + + // Force clear the current texture so that items next in the batch (like Graphics) don't try and use it + renderer.setBlankTexture(true); }; module.exports = RenderTextureWebGLRenderer; diff --git a/src/gameobjects/shape/FillPathWebGL.js b/src/gameobjects/shape/FillPathWebGL.js new file mode 100644 index 000000000..ff7b10835 --- /dev/null +++ b/src/gameobjects/shape/FillPathWebGL.js @@ -0,0 +1,58 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = require('../../renderer/webgl/Utils'); + +/** + * Renders a filled path for the given Shape. + * + * @method Phaser.GameObjects.Shape#FillPathWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The WebGL Pipeline used to render this Shape. + * @param {Phaser.GameObjects.Components.TransformMatrix} calcMatrix - The transform matrix used to get the position values. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. + */ +var FillPathWebGL = function (pipeline, calcMatrix, src, alpha, dx, dy) +{ + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + var path = src.pathData; + var pathIndexes = src.pathIndexes; + + for (var i = 0; i < pathIndexes.length; i += 3) + { + var p0 = pathIndexes[i] * 2; + var p1 = pathIndexes[i + 1] * 2; + var p2 = pathIndexes[i + 2] * 2; + + var x0 = path[p0 + 0] - dx; + var y0 = path[p0 + 1] - dy; + var x1 = path[p1 + 0] - dx; + var y1 = path[p1 + 1] - dy; + var x2 = path[p2 + 0] - dx; + var y2 = path[p2 + 1] - dy; + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + pipeline.setTexture2D(); + + pipeline.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, 0, 0, 1, 1, fillTintColor, fillTintColor, fillTintColor, pipeline.tintEffect); + } +}; + +module.exports = FillPathWebGL; diff --git a/src/gameobjects/shape/FillStyleCanvas.js b/src/gameobjects/shape/FillStyleCanvas.js new file mode 100644 index 000000000..e00efa68a --- /dev/null +++ b/src/gameobjects/shape/FillStyleCanvas.js @@ -0,0 +1,29 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the fillStyle on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#FillStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the fill style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the fill style from. + */ +var FillStyleCanvas = function (ctx, src, altColor) +{ + var fillColor = (altColor) ? altColor : src.fillColor; + var fillAlpha = src.fillAlpha; + + var red = ((fillColor & 0xFF0000) >>> 16); + var green = ((fillColor & 0xFF00) >>> 8); + var blue = (fillColor & 0xFF); + + ctx.fillStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + fillAlpha + ')'; +}; + +module.exports = FillStyleCanvas; diff --git a/src/gameobjects/shape/LineStyleCanvas.js b/src/gameobjects/shape/LineStyleCanvas.js new file mode 100644 index 000000000..8d72787f8 --- /dev/null +++ b/src/gameobjects/shape/LineStyleCanvas.js @@ -0,0 +1,30 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Sets the strokeStyle and lineWidth on the target context based on the given Shape. + * + * @method Phaser.GameObjects.Shape#LineStyleCanvas + * @since 3.13.0 + * @private + * + * @param {CanvasRenderingContext2D} ctx - The context to set the stroke style on. + * @param {Phaser.GameObjects.Shape} src - The Game Object to set the stroke style from. + */ +var LineStyleCanvas = function (ctx, src) +{ + var strokeColor = src.strokeColor; + var strokeAlpha = src.strokeAlpha; + + var red = ((strokeColor & 0xFF0000) >>> 16); + var green = ((strokeColor & 0xFF00) >>> 8); + var blue = (strokeColor & 0xFF); + + ctx.strokeStyle = 'rgba(' + red + ',' + green + ',' + blue + ',' + strokeAlpha + ')'; + ctx.lineWidth = src.lineWidth; +}; + +module.exports = LineStyleCanvas; diff --git a/src/gameobjects/shape/Shape.js b/src/gameobjects/shape/Shape.js new file mode 100644 index 000000000..c30870331 --- /dev/null +++ b/src/gameobjects/shape/Shape.js @@ -0,0 +1,296 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../utils/Class'); +var Components = require('../components'); +var GameObject = require('../GameObject'); +var Line = require('../../geom/line/Line'); + +/** + * @classdesc + * The Shape Game Object is a base class for the various different shapes, such as the Arc, Star or Polygon. + * You cannot add a Shape directly to your Scene, it is meant as a base for your own custom Shape classes. + * + * @class Shape + * @extends Phaser.GameObjects.GameObject + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @extends Phaser.GameObjects.Components.Alpha + * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Depth + * @extends Phaser.GameObjects.Components.GetBounds + * @extends Phaser.GameObjects.Components.Mask + * @extends Phaser.GameObjects.Components.Origin + * @extends Phaser.GameObjects.Components.Pipeline + * @extends Phaser.GameObjects.Components.ScaleMode + * @extends Phaser.GameObjects.Components.ScrollFactor + * @extends Phaser.GameObjects.Components.Transform + * @extends Phaser.GameObjects.Components.Visible + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {string} [type] - The internal type of the Shape. + * @param {any} [data] - The data of the source shape geometry, if any. + */ +var Shape = new Class({ + + Extends: GameObject, + + Mixins: [ + Components.Alpha, + Components.BlendMode, + Components.ComputedSize, + Components.Depth, + Components.GetBounds, + Components.Mask, + Components.Origin, + Components.Pipeline, + Components.ScaleMode, + Components.ScrollFactor, + Components.Transform, + Components.Visible + ], + + initialize: + + function Shape (scene, type, data) + { + if (type === undefined) { type = 'Shape'; } + + GameObject.call(this, scene, type); + + /** + * The source Shape data. Typically a geometry object. + * You should not manipulate this directly. + * + * @name Phaser.GameObjects.Shape#data + * @type {any} + * @readonly + * @since 3.13.0 + */ + this.geom = data; + + /** + * Holds the polygon path data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathData + * @type {number[]} + * @readonly + * @since 3.13.0 + */ + this.pathData = []; + + /** + * Holds the earcut polygon path index data for filled rendering. + * + * @name Phaser.GameObjects.Shape#pathIndexes + * @type {integer[]} + * @readonly + * @since 3.13.0 + */ + this.pathIndexes = []; + + /** + * The fill color used by this Shape. + * + * @name Phaser.GameObjects.Shape#fillColor + * @type {number} + * @since 3.13.0 + */ + this.fillColor = 0xffffff; + + /** + * The fill alpha value used by this Shape. + * + * @name Phaser.GameObjects.Shape#fillAlpha + * @type {number} + * @since 3.13.0 + */ + this.fillAlpha = 1; + + /** + * The stroke color used by this Shape. + * + * @name Phaser.GameObjects.Shape#strokeColor + * @type {number} + * @since 3.13.0 + */ + this.strokeColor = 0xffffff; + + /** + * The stroke alpha value used by this Shape. + * + * @name Phaser.GameObjects.Shape#strokeAlpha + * @type {number} + * @since 3.13.0 + */ + this.strokeAlpha = 1; + + /** + * The stroke line width used by this Shape. + * + * @name Phaser.GameObjects.Shape#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Controls if this Shape is filled or not. + * Note that some Shapes do not support being filled (such as Line shapes) + * + * @name Phaser.GameObjects.Shape#isFilled + * @type {boolean} + * @since 3.13.0 + */ + this.isFilled = false; + + /** + * Controls if this Shape is stroked or not. + * Note that some Shapes do not support being stroked (such as Iso Box shapes) + * + * @name Phaser.GameObjects.Shape#isStroked + * @type {boolean} + * @since 3.13.0 + */ + this.isStroked = false; + + /** + * Controls if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * @name Phaser.GameObjects.Shape#closePath + * @type {boolean} + * @since 3.13.0 + */ + this.closePath = true; + + /** + * Private internal value. + * A Line used when parsing internal path data to avoid constant object re-creation. + * + * @name Phaser.GameObjects.Curve#_tempLine + * @type {Phaser.Geom.Line} + * @private + * @since 3.13.0 + */ + this._tempLine = new Line(); + + this.initPipeline(); + }, + + /** + * Sets the fill color and alpha for this Shape. + * + * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. + * + * Note that some Shapes do not support fill colors, such as the Line shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setFillStyle + * @since 3.13.0 + * + * @param {number} [color] - The color used to fill this shape. If not provided the Shape will not be filled. + * @param {number} [alpha=1] - The alpha value used when filling this shape, if a fill color is given. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (color === undefined) + { + this.isFilled = false; + } + else + { + this.fillColor = color; + this.fillAlpha = alpha; + this.isFilled = true; + } + + return this; + }, + + /** + * Sets the stroke color and alpha for this Shape. + * + * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. + * + * Note that some Shapes do not support being stroked, such as the Iso Box shape. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setStrokeStyle + * @since 3.13.0 + * + * @param {number} [lineWidth] - The width of line to stroke with. If not provided or undefined the Shape will not be stroked. + * @param {number} [color] - The color used to stroke this shape. If not provided the Shape will not be stroked. + * @param {number} [alpha=1] - The alpha value used when stroking this shape, if a stroke color is given. + * + * @return {this} This Game Object instance. + */ + setStrokeStyle: function (lineWidth, color, alpha) + { + if (alpha === undefined) { alpha = 1; } + + if (lineWidth === undefined) + { + this.isStroked = false; + } + else + { + this.lineWidth = lineWidth; + this.strokeColor = color; + this.strokeAlpha = alpha; + this.isStroked = true; + } + + return this; + }, + + /** + * Sets if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * This call can be chained. + * + * @method Phaser.GameObjects.Shape#setClosePath + * @since 3.13.0 + * + * @param {boolean} value - Set to `true` if the Shape should be closed when stroked, otherwise `false`. + * + * @return {this} This Game Object instance. + */ + setClosePath: function (value) + { + this.closePath = value; + + return this; + }, + + /** + * Internal destroy handler, called as part of the destroy process. + * + * @method Phaser.GameObjects.Shape#preDestroy + * @protected + * @since 3.13.0 + */ + preDestroy: function () + { + this.geom = null; + this._tempLine = null; + this.pathData = []; + this.pathIndexes = []; + } + +}); + +module.exports = Shape; diff --git a/src/gameobjects/shape/StrokePathWebGL.js b/src/gameobjects/shape/StrokePathWebGL.js new file mode 100644 index 000000000..1039e123a --- /dev/null +++ b/src/gameobjects/shape/StrokePathWebGL.js @@ -0,0 +1,69 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = require('../../renderer/webgl/Utils'); + +/** + * Renders a stroke outline around the given Shape. + * + * @method Phaser.GameObjects.Shape#StrokePathWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipeline - The WebGL Pipeline used to render this Shape. + * @param {Phaser.GameObjects.Shape} src - The Game Object shape being rendered in this call. + * @param {number} alpha - The base alpha value. + * @param {number} dx - The source displayOriginX. + * @param {number} dy - The source displayOriginY. + */ +var StrokePathWebGL = function (pipeline, src, alpha, dx, dy) +{ + var strokeTint = pipeline.strokeTint; + var strokeTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.strokeColor, src.strokeAlpha * alpha); + + strokeTint.TL = strokeTintColor; + strokeTint.TR = strokeTintColor; + strokeTint.BL = strokeTintColor; + strokeTint.BR = strokeTintColor; + + var path = src.pathData; + var pathLength = path.length - 1; + var lineWidth = src.lineWidth; + var halfLineWidth = lineWidth / 2; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + pipeline.setTexture2D(); + + pipeline.batchLine( + px1, + py1, + px2, + py2, + halfLineWidth, + halfLineWidth, + lineWidth, + i - 2, + (src.closePath) ? (i === pathLength - 1) : false + ); + + px1 = px2; + py1 = py2; + } +}; + +module.exports = StrokePathWebGL; diff --git a/src/gameobjects/shape/arc/Arc.js b/src/gameobjects/shape/arc/Arc.js new file mode 100644 index 000000000..9bd229661 --- /dev/null +++ b/src/gameobjects/shape/arc/Arc.js @@ -0,0 +1,398 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArcRender = require('./ArcRender'); +var Class = require('../../../utils/Class'); +var DegToRad = require('../../../math/DegToRad'); +var Earcut = require('../../../geom/polygon/Earcut'); +var GeomCircle = require('../../../geom/circle/Circle'); +var MATH_CONST = require('../../../math/const'); +var Shape = require('../Shape'); + +/** + * @classdesc + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows + * you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. + * + * @class Arc + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [radius=128] - The radius of the arc. + * @param {integer} [startAngle=0] - The start angle of the arc, in degrees. + * @param {integer} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - The winding order of the start and end angles. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Arc = new Class({ + + Extends: Shape, + + Mixins: [ + ArcRender + ], + + initialize: + + function Arc (scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (radius === undefined) { radius = 128; } + if (startAngle === undefined) { startAngle = 0; } + if (endAngle === undefined) { endAngle = 360; } + if (anticlockwise === undefined) { anticlockwise = false; } + + Shape.call(this, scene, 'Arc', new GeomCircle(0, 0, radius)); + + /** + * Private internal value. Holds the start angle in degrees. + * + * @name Phaser.GameObjects.Arc#_startAngle + * @type {integer} + * @private + * @since 3.13.0 + */ + this._startAngle = startAngle; + + /** + * Private internal value. Holds the end angle in degrees. + * + * @name Phaser.GameObjects.Arc#_endAngle + * @type {integer} + * @private + * @since 3.13.0 + */ + this._endAngle = endAngle; + + /** + * Private internal value. Holds the winding order of the start and end angles. + * + * @name Phaser.GameObjects.Arc#_anticlockwise + * @type {boolean} + * @private + * @since 3.13.0 + */ + this._anticlockwise = anticlockwise; + + /** + * Private internal value. Holds the number of iterations used when drawing the arc. + * + * @name Phaser.GameObjects.Arc#_iterations + * @type {number} + * @default 0.01 + * @private + * @since 3.13.0 + */ + this._iterations = 0.01; + + this.setPosition(x, y); + this.setSize(this.geom.radius, this.geom.radius); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * + * @name Phaser.GameObjects.Arc#iterations + * @type {number} + * @default 0.01 + * @since 3.13.0 + */ + iterations: { + + get: function () + { + return this._iterations; + }, + + set: function (value) + { + this._iterations = value; + + this.updateData(); + } + + }, + + /** + * The radius of the arc. + * + * @name Phaser.GameObjects.Arc#radius + * @type {number} + * @since 3.13.0 + */ + radius: { + + get: function () + { + return this.geom.radius; + }, + + set: function (value) + { + this.geom.radius = value; + + this.updateData(); + } + + }, + + /** + * The start angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#startAngle + * @type {integer} + * @since 3.13.0 + */ + startAngle: { + + get: function () + { + return this._startAngle; + }, + + set: function (value) + { + this._startAngle = value; + + this.updateData(); + } + + }, + + /** + * The end angle of the arc, in degrees. + * + * @name Phaser.GameObjects.Arc#endAngle + * @type {integer} + * @since 3.13.0 + */ + endAngle: { + + get: function () + { + return this._endAngle; + }, + + set: function (value) + { + this._endAngle = value; + + this.updateData(); + } + + }, + + /** + * The winding order of the start and end angles. + * + * @name Phaser.GameObjects.Arc#anticlockwise + * @type {boolean} + * @since 3.13.0 + */ + anticlockwise: { + + get: function () + { + return this._anticlockwise; + }, + + set: function (value) + { + this._anticlockwise = value; + + this.updateData(); + } + + }, + + /** + * Sets the radius of the arc. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setRadius + * @since 3.13.0 + * + * @param {number} value - The value to set the radius to. + * + * @return {this} This Game Object instance. + */ + setRadius: function (value) + { + this.radius = value; + + return this; + }, + + /** + * Sets the number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setIterations + * @since 3.13.0 + * + * @param {number} value - The value to set the iterations to. + * + * @return {this} This Game Object instance. + */ + setIterations: function (value) + { + if (value === undefined) { value = 0.01; } + + this.iterations = value; + + return this; + }, + + /** + * Sets the starting angle of the arc, in degrees. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setStartAngle + * @since 3.13.0 + * + * @param {integer} value - The value to set the starting angle to. + * + * @return {this} This Game Object instance. + */ + setStartAngle: function (angle, anticlockwise) + { + this._startAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Sets the ending angle of the arc, in degrees. + * This call can be chained. + * + * @method Phaser.GameObjects.Arc#setEndAngle + * @since 3.13.0 + * + * @param {integer} value - The value to set the ending angle to. + * + * @return {this} This Game Object instance. + */ + setEndAngle: function (angle, anticlockwise) + { + this._endAngle = angle; + + if (anticlockwise !== undefined) + { + this._anticlockwise = anticlockwise; + } + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Arc#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var step = this._iterations; + var iteration = step; + + var radius = this.geom.radius; + var startAngle = DegToRad(this._startAngle); + var endAngle = DegToRad(this._endAngle); + var anticlockwise = this._anticlockwise; + + var x = radius / 2; + var y = radius / 2; + + endAngle -= startAngle; + + if (anticlockwise) + { + if (endAngle < -MATH_CONST.PI2) + { + endAngle = -MATH_CONST.PI2; + } + else if (endAngle > 0) + { + endAngle = -MATH_CONST.PI2 + endAngle % MATH_CONST.PI2; + } + } + else if (endAngle > MATH_CONST.PI2) + { + endAngle = MATH_CONST.PI2; + } + else if (endAngle < 0) + { + endAngle = MATH_CONST.PI2 + endAngle % MATH_CONST.PI2; + } + + var path = [ x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius ]; + + var ta; + + while (iteration < 1) + { + ta = endAngle * iteration + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + iteration += step; + } + + ta = endAngle + startAngle; + + path.push(x + Math.cos(ta) * radius, y + Math.sin(ta) * radius); + + path.push(x + Math.cos(startAngle) * radius, y + Math.sin(startAngle) * radius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Arc; diff --git a/src/gameobjects/shape/arc/ArcCanvasRenderer.js b/src/gameobjects/shape/arc/ArcCanvasRenderer.js new file mode 100644 index 000000000..188410c0b --- /dev/null +++ b/src/gameobjects/shape/arc/ArcCanvasRenderer.js @@ -0,0 +1,70 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var DegToRad = require('../../../math/DegToRad'); +var FillStyleCanvas = require('../FillStyleCanvas'); +var LineStyleCanvas = require('../LineStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var radius = src.radius; + + ctx.beginPath(); + + ctx.arc( + (radius) - src.originX * (radius * 2), + (radius) - src.originY * (radius * 2), + radius, + DegToRad(src._startAngle), + DegToRad(src._endAngle), + src.anticlockwise + ); + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = ArcCanvasRenderer; diff --git a/src/gameobjects/shape/arc/ArcFactory.js b/src/gameobjects/shape/arc/ArcFactory.js new file mode 100644 index 000000000..0a1e905f3 --- /dev/null +++ b/src/gameobjects/shape/arc/ArcFactory.js @@ -0,0 +1,67 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Arc = require('./Arc'); +var GameObjectFactory = require('../../GameObjectFactory'); + +/** + * Creates a new Arc Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * @method Phaser.GameObjects.GameObjectFactory#arc + * @since 3.13.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 {number} [radius=128] - The radius of the arc. + * @param {integer} [startAngle=0] - The start angle of the arc, in degrees. + * @param {integer} [endAngle=360] - The end angle of the arc, in degrees. + * @param {boolean} [anticlockwise=false] - The winding order of the start and end angles. + * @param {number} [fillColor] - The color the arc will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('arc', function (x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, startAngle, endAngle, anticlockwise, fillColor, fillAlpha)); +}); + +/** + * Creates a new Circle Shape Game Object and adds it to the Scene. + * + * A Circle is an Arc with no defined start and end angle, making it render as a complete circle. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * @method Phaser.GameObjects.GameObjectFactory#circle + * @since 3.13.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 {number} [radius=128] - The radius of the circle. + * @param {number} [fillColor] - The color the circle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Arc} The Game Object that was created. + */ +GameObjectFactory.register('circle', function (x, y, radius, fillColor, fillAlpha) +{ + return this.displayList.add(new Arc(this.scene, x, y, radius, 0, 360, false, fillColor, fillAlpha)); +}); diff --git a/src/gameobjects/shape/arc/ArcRender.js b/src/gameobjects/shape/arc/ArcRender.js new file mode 100644 index 000000000..99d67f98a --- /dev/null +++ b/src/gameobjects/shape/arc/ArcRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./ArcWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./ArcCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/arc/ArcWebGLRenderer.js b/src/gameobjects/shape/arc/ArcWebGLRenderer.js new file mode 100644 index 000000000..900303cf9 --- /dev/null +++ b/src/gameobjects/shape/arc/ArcWebGLRenderer.js @@ -0,0 +1,72 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = require('../FillPathWebGL'); +var StrokePathWebGL = require('../StrokePathWebGL'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Arc#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Arc} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var ArcWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = ArcWebGLRenderer; diff --git a/src/gameobjects/shape/curve/Curve.js b/src/gameobjects/shape/curve/Curve.js new file mode 100644 index 000000000..75e8579d3 --- /dev/null +++ b/src/gameobjects/shape/curve/Curve.js @@ -0,0 +1,176 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../utils/Class'); +var CurveRender = require('./CurveRender'); +var Earcut = require('../../../geom/polygon/Earcut'); +var Rectangle = require('../../../geom/rectangle/Rectangle'); +var Shape = require('../Shape'); + +/** + * @classdesc + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @class Curve + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Curve = new Class({ + + Extends: Shape, + + Mixins: [ + CurveRender + ], + + initialize: + + function Curve (scene, x, y, curve, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Curve', curve); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Curve#_smoothness + * @type {integer} + * @private + * @since 3.13.0 + */ + this._smoothness = 32; + + /** + * Private internal value. + * The Curve bounds rectangle. + * + * @name Phaser.GameObjects.Curve#_curveBounds + * @type {Phaser.Geom.Rectangle} + * @private + * @since 3.13.0 + */ + this._curveBounds = new Rectangle(); + + this.closePath = false; + + this.setPosition(x, y); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateData(); + }, + + /** + * The smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Curve#smoothness + * @type {integer} + * @default 32 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Curve#setSmoothness + * @since 3.13.0 + * + * @param {integer} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Curve#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var bounds = this._curveBounds; + var smoothness = this._smoothness; + + // Update the bounds in case the underlying data has changed + this.geom.getBounds(bounds, smoothness); + + this.setSize(bounds.width, bounds.height); + this.updateDisplayOrigin(); + + var path = []; + var points = this.geom.getPoints(smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Curve; diff --git a/src/gameobjects/shape/curve/CurveCanvasRenderer.js b/src/gameobjects/shape/curve/CurveCanvasRenderer.js new file mode 100644 index 000000000..05a2e4a65 --- /dev/null +++ b/src/gameobjects/shape/curve/CurveCanvasRenderer.js @@ -0,0 +1,82 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = require('../FillStyleCanvas'); +var LineStyleCanvas = require('../LineStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + if (src.closePath) + { + ctx.closePath(); + } + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = CurveCanvasRenderer; diff --git a/src/gameobjects/shape/curve/CurveFactory.js b/src/gameobjects/shape/curve/CurveFactory.js new file mode 100644 index 000000000..b39443974 --- /dev/null +++ b/src/gameobjects/shape/curve/CurveFactory.js @@ -0,0 +1,44 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = require('../../GameObjectFactory'); +var Curve = require('./Curve'); + +/** + * Creates a new Curve Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Curve Game Object has been built into Phaser. + * + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#curve + * @since 3.13.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 {Phaser.Curves.Curve} [curve] - The Curve object to use to create the Shape. + * @param {number} [fillColor] - The color the curve will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Curve} The Game Object that was created. + */ +GameObjectFactory.register('curve', function (x, y, curve, fillColor, fillAlpha) +{ + return this.displayList.add(new Curve(this.scene, x, y, curve, fillColor, fillAlpha)); +}); diff --git a/src/gameobjects/shape/curve/CurveRender.js b/src/gameobjects/shape/curve/CurveRender.js new file mode 100644 index 000000000..3b132d2bd --- /dev/null +++ b/src/gameobjects/shape/curve/CurveRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./CurveWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./CurveCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/curve/CurveWebGLRenderer.js b/src/gameobjects/shape/curve/CurveWebGLRenderer.js new file mode 100644 index 000000000..810d7eee5 --- /dev/null +++ b/src/gameobjects/shape/curve/CurveWebGLRenderer.js @@ -0,0 +1,72 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = require('../FillPathWebGL'); +var StrokePathWebGL = require('../StrokePathWebGL'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Curve#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Curve} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var CurveWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX + src._curveBounds.x; + var dy = src._displayOriginY + src._curveBounds.y; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = CurveWebGLRenderer; diff --git a/src/gameobjects/shape/ellipse/Ellipse.js b/src/gameobjects/shape/ellipse/Ellipse.js new file mode 100644 index 000000000..7d7878772 --- /dev/null +++ b/src/gameobjects/shape/ellipse/Ellipse.js @@ -0,0 +1,181 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../utils/Class'); +var Earcut = require('../../../geom/polygon/Earcut'); +var EllipseRender = require('./EllipseRender'); +var GeomEllipse = require('../../../geom/ellipse/Ellipse'); +var Shape = require('../Shape'); + +/** + * @classdesc + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @class Ellipse + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Ellipse = new Class({ + + Extends: Shape, + + Mixins: [ + EllipseRender + ], + + initialize: + + function Ellipse (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Ellipse', new GeomEllipse(width / 2, height / 2, width, height)); + + /** + * Private internal value. + * The number of points used to draw the curve. Higher values create smoother renders at the cost of more triangles being drawn. + * + * @name Phaser.GameObjects.Ellipse#_smoothness + * @type {integer} + * @private + * @since 3.13.0 + */ + this._smoothness = 64; + + this.setPosition(x, y); + + this.width = width; + this.height = height; + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * The smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * + * @name Phaser.GameObjects.Ellipse#smoothness + * @type {integer} + * @default 64 + * @since 3.13.0 + */ + smoothness: { + + get: function () + { + return this._smoothness; + }, + + set: function (value) + { + this._smoothness = value; + + this.updateData(); + } + + }, + + /** + * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSize + * @since 3.13.0 + * + * @param {number} width - The width of the ellipse. + * @param {number} height - The height of the ellipse. + * + * @return {this} This Game Object instance. + */ + setSize: function (width, height) + { + this.geom.setSize(width, height); + + return this.updateData(); + }, + + /** + * Sets the smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.Ellipse#setSmoothness + * @since 3.13.0 + * + * @param {integer} value - The value to set the smoothness to. + * + * @return {this} This Game Object instance. + */ + setSmoothness: function (value) + { + this._smoothness = value; + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Ellipse#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.getPoints(this._smoothness); + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Ellipse; diff --git a/src/gameobjects/shape/ellipse/EllipseCanvasRenderer.js b/src/gameobjects/shape/ellipse/EllipseCanvasRenderer.js new file mode 100644 index 000000000..5336a0518 --- /dev/null +++ b/src/gameobjects/shape/ellipse/EllipseCanvasRenderer.js @@ -0,0 +1,79 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = require('../FillStyleCanvas'); +var LineStyleCanvas = require('../LineStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = EllipseCanvasRenderer; diff --git a/src/gameobjects/shape/ellipse/EllipseFactory.js b/src/gameobjects/shape/ellipse/EllipseFactory.js new file mode 100644 index 000000000..405805b6f --- /dev/null +++ b/src/gameobjects/shape/ellipse/EllipseFactory.js @@ -0,0 +1,46 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Ellipse = require('./Ellipse'); +var GameObjectFactory = require('../../GameObjectFactory'); + +/** + * Creates a new Ellipse Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. + * + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#ellipse + * @since 3.13.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 {number} [width=128] - The width of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [height=128] - The height of the ellipse. An ellipse with equal width and height renders as a circle. + * @param {number} [fillColor] - The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Ellipse} The Game Object that was created. + */ +GameObjectFactory.register('ellipse', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Ellipse(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); diff --git a/src/gameobjects/shape/ellipse/EllipseRender.js b/src/gameobjects/shape/ellipse/EllipseRender.js new file mode 100644 index 000000000..a1b587318 --- /dev/null +++ b/src/gameobjects/shape/ellipse/EllipseRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./EllipseWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./EllipseCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/ellipse/EllipseWebGLRenderer.js b/src/gameobjects/shape/ellipse/EllipseWebGLRenderer.js new file mode 100644 index 000000000..bc184dd0d --- /dev/null +++ b/src/gameobjects/shape/ellipse/EllipseWebGLRenderer.js @@ -0,0 +1,72 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = require('../FillPathWebGL'); +var StrokePathWebGL = require('../StrokePathWebGL'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Ellipse#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Ellipse} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var EllipseWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = EllipseWebGLRenderer; diff --git a/src/gameobjects/shape/grid/Grid.js b/src/gameobjects/shape/grid/Grid.js new file mode 100644 index 000000000..357e066b7 --- /dev/null +++ b/src/gameobjects/shape/grid/Grid.js @@ -0,0 +1,276 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../utils/Class'); +var Shape = require('../Shape'); +var GridRender = require('./GridRender'); + +/** + * @classdesc + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @class Grid + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [outlineFillColor] - The color of the lines between the grid cells. See the `setOutline` method. + * @param {number} [outlineFillAlpha] - The alpha of the lines between the grid cells. + */ +var Grid = new Class({ + + Extends: Shape, + + Mixins: [ + GridRender + ], + + initialize: + + function Grid (scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + if (cellWidth === undefined) { cellWidth = 32; } + if (cellHeight === undefined) { cellHeight = 32; } + + Shape.call(this, scene, 'Grid', null); + + /** + * The width of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellWidth + * @type {number} + * @since 3.13.0 + */ + this.cellWidth = cellWidth; + + /** + * The height of each grid cell. + * Must be a positive value. + * + * @name Phaser.GameObjects.Grid#cellHeight + * @type {number} + * @since 3.13.0 + */ + this.cellHeight = cellHeight; + + /** + * Will the grid render its cells in the `fillColor`? + * + * @name Phaser.GameObjects.Grid#showCells + * @type {boolean} + * @since 3.13.0 + */ + this.showCells = true; + + /** + * The color of the lines between each grid cell. + * + * @name Phaser.GameObjects.Grid#outlineFillColor + * @type {number} + * @since 3.13.0 + */ + this.outlineFillColor = 0; + + /** + * The alpha value for the color of the lines between each grid cell. + * + * @name Phaser.GameObjects.Grid#outlineFillAlpha + * @type {number} + * @since 3.13.0 + */ + this.outlineFillAlpha = 0; + + /** + * Will the grid display the lines between each cell when it renders? + * + * @name Phaser.GameObjects.Grid#showOutline + * @type {boolean} + * @since 3.13.0 + */ + this.showOutline = true; + + /** + * Will the grid render the alternating cells in the `altFillColor`? + * + * @name Phaser.GameObjects.Grid#showAltCells + * @type {boolean} + * @since 3.13.0 + */ + this.showAltCells = false; + + /** + * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * + * @name Phaser.GameObjects.Grid#altFillColor + * @type {number} + * @since 3.13.0 + */ + this.altFillColor; + + /** + * The alpha the alternating grid cells will be filled with. + * You can also set the alpha of the overall Shape using its `alpha` property. + * + * @name Phaser.GameObjects.Grid#altFillAlpha + * @type {number} + * @since 3.13.0 + */ + this.altFillAlpha; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + if (outlineFillColor !== undefined) + { + this.setOutlineStyle(outlineFillColor, outlineFillAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the fill color and alpha level the grid cells will use when rendering. + * + * If this method is called with no values then the grid cells will not be rendered, + * however the grid lines and alternating cells may still be. + * + * Also see the `setOutlineStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showCells = false; + } + else + { + this.fillColor = fillColor; + this.fillAlpha = fillAlpha; + this.showCells = true; + } + + return this; + }, + + /** + * Sets the fill color and alpha level that the alternating grid cells will use. + * + * If this method is called with no values then alternating grid cells will not be rendered in a different color. + * + * Also see the `setOutlineStyle` and `setFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setAltFillStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setAltFillStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showAltCells = false; + } + else + { + this.altFillColor = fillColor; + this.altFillAlpha = fillAlpha; + this.showAltCells = true; + } + + return this; + }, + + /** + * Sets the fill color and alpha level that the lines between each grid cell will use. + * + * If this method is called with no values then the grid lines will not be rendered at all, however + * the cells themselves may still be if they have colors set. + * + * Also see the `setFillStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Grid#setOutlineStyle + * @since 3.13.0 + * + * @param {number} [fillColor] - The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha=1] - The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {this} This Game Object instance. + */ + setOutlineStyle: function (fillColor, fillAlpha) + { + if (fillAlpha === undefined) { fillAlpha = 1; } + + if (fillColor === undefined) + { + this.showOutline = false; + } + else + { + this.outlineFillColor = fillColor; + this.outlineFillAlpha = fillAlpha; + this.showOutline = true; + } + + return this; + } + +}); + +module.exports = Grid; diff --git a/src/gameobjects/shape/grid/GridCanvasRenderer.js b/src/gameobjects/shape/grid/GridCanvasRenderer.js new file mode 100644 index 000000000..3f4ceeb7a --- /dev/null +++ b/src/gameobjects/shape/grid/GridCanvasRenderer.js @@ -0,0 +1,68 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = require('../FillStyleCanvas'); +var LineStyleCanvas = require('../LineStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.rect( + -dx, + -dy, + src.width, + src.height + ); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = RectangleCanvasRenderer; diff --git a/src/gameobjects/shape/grid/GridFactory.js b/src/gameobjects/shape/grid/GridFactory.js new file mode 100644 index 000000000..1e1d63d67 --- /dev/null +++ b/src/gameobjects/shape/grid/GridFactory.js @@ -0,0 +1,49 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = require('../../GameObjectFactory'); +var Grid = require('./Grid'); + +/** + * Creates a new Grid Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Grid Game Object has been built into Phaser. + * + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * + * @method Phaser.GameObjects.GameObjectFactory#grid + * @since 3.13.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 {number} [width=128] - The width of the grid. + * @param {number} [height=128] - The height of the grid. + * @param {number} [cellWidth=32] - The width of one cell in the grid. + * @param {number} [cellHeight=32] - The height of one cell in the grid. + * @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param {number} [outlineFillColor] - The color of the lines between the grid cells. + * @param {number} [outlineFillAlpha] - The alpha of the lines between the grid cells. + * + * @return {Phaser.GameObjects.Grid} The Game Object that was created. + */ +GameObjectFactory.register('grid', function (x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha) +{ + return this.displayList.add(new Grid(this.scene, x, y, width, height, cellWidth, cellHeight, fillColor, fillAlpha, outlineFillColor, outlineFillAlpha)); +}); diff --git a/src/gameobjects/shape/grid/GridRender.js b/src/gameobjects/shape/grid/GridRender.js new file mode 100644 index 000000000..4da95f739 --- /dev/null +++ b/src/gameobjects/shape/grid/GridRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./GridWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./GridCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/grid/GridWebGLRenderer.js b/src/gameobjects/shape/grid/GridWebGLRenderer.js new file mode 100644 index 000000000..5b0041599 --- /dev/null +++ b/src/gameobjects/shape/grid/GridWebGLRenderer.js @@ -0,0 +1,220 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = require('../../../renderer/webgl/Utils'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Grid#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Grid} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + calcMatrix.translate(-src._displayOriginX, -src._displayOriginY); + + var alpha = camera.alpha * src.alpha; + + // Work out the grid size + + var width = src.width; + var height = src.height; + + var cellWidth = src.cellWidth; + var cellHeight = src.cellHeight; + + var gridWidth = Math.ceil(width / cellWidth); + var gridHeight = Math.ceil(height / cellHeight); + + var cellWidthA = cellWidth; + var cellHeightA = cellHeight; + + var cellWidthB = cellWidth - ((gridWidth * cellWidth) - width); + var cellHeightB = cellHeight - ((gridHeight * cellHeight) - height); + + var fillTint; + var fillTintColor; + + var showCells = src.showCells; + var showAltCells = src.showAltCells; + var showOutline = src.showOutline; + + var x = 0; + var y = 0; + var r = 0; + var cw = 0; + var ch = 0; + + if (showOutline) + { + // To make room for the grid lines (in case alpha < 1) + cellWidthA--; + cellHeightA--; + + if (cellWidthB === cellWidth) + { + cellWidthB--; + } + + if (cellHeightB === cellHeight) + { + cellHeightB--; + } + } + + if (showCells && src.fillAlpha > 0) + { + fillTint = pipeline.fillTint; + fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && r) + { + r = 0; + continue; + } + + r++; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + pipeline.setTexture2D(); + + pipeline.batchFillRect( + x * cellWidth, + y * cellHeight, + cw, + ch + ); + } + } + } + + if (showAltCells && src.altFillAlpha > 0) + { + fillTint = pipeline.fillTint; + fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.altFillColor, src.altFillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + for (y = 0; y < gridHeight; y++) + { + if (showAltCells) + { + r = y % 2; + } + + for (x = 0; x < gridWidth; x++) + { + if (showAltCells && !r) + { + r = 1; + continue; + } + + r = 0; + + cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB; + ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB; + + pipeline.setTexture2D(); + + pipeline.batchFillRect( + x * cellWidth, + y * cellHeight, + cw, + ch + ); + } + } + } + + if (showOutline && src.outlineFillAlpha > 0) + { + var strokeTint = pipeline.strokeTint; + var color = Utils.getTintAppendFloatAlphaAndSwap(src.outlineFillColor, src.outlineFillAlpha * alpha); + + strokeTint.TL = color; + strokeTint.TR = color; + strokeTint.BL = color; + strokeTint.BR = color; + + for (x = 1; x < gridWidth; x++) + { + var x1 = x * cellWidth; + + pipeline.setTexture2D(); + + pipeline.batchLine(x1, 0, x1, height, 1, 1, 1, 0, false); + } + + for (y = 1; y < gridHeight; y++) + { + var y1 = y * cellHeight; + + pipeline.setTexture2D(); + + pipeline.batchLine(0, y1, width, y1, 1, 1, 1, 0, false); + } + } +}; + +module.exports = GridWebGLRenderer; diff --git a/src/gameobjects/shape/isobox/IsoBox.js b/src/gameobjects/shape/isobox/IsoBox.js new file mode 100644 index 000000000..c03238cc1 --- /dev/null +++ b/src/gameobjects/shape/isobox/IsoBox.js @@ -0,0 +1,209 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var IsoBoxRender = require('./IsoBoxRender'); +var Class = require('../../../utils/Class'); +var Shape = require('../Shape'); + +/** + * @classdesc + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * + * @class IsoBox + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + */ +var IsoBox = new Class({ + + Extends: Shape, + + Mixins: [ + IsoBoxRender + ], + + initialize: + + function IsoBox (scene, x, y, size, height, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoBox', null); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * + * @name Phaser.GameObjects.IsoBox#projection + * @type {integer} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso box. + * + * @name Phaser.GameObjects.IsoBox#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls if the top-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls if the left-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls if the right-face of the iso box be rendered. + * + * @name Phaser.GameObjects.IsoBox#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setProjection + * @since 3.13.0 + * + * @param {integer} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets which faces of the iso box will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso box. + * @param {boolean} [showLeft=true] - Show the left-face of the iso box. + * @param {boolean} [showRight=true] - Show the right-face of the iso box. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso box. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoBox#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso box. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso box. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso box. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoBox; diff --git a/src/gameobjects/shape/isobox/IsoBoxCanvasRenderer.js b/src/gameobjects/shape/isobox/IsoBoxCanvasRenderer.js new file mode 100644 index 000000000..f94dc0d80 --- /dev/null +++ b/src/gameobjects/shape/isobox/IsoBoxCanvasRenderer.js @@ -0,0 +1,95 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = require('../FillStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + // Top Face + + if (src.showTop) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, -1); + ctx.lineTo(0, sizeB - 1); + ctx.lineTo(-sizeA, -1); + ctx.lineTo(-sizeA, -height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(-sizeA, -height); + ctx.lineTo(-sizeA, 0); + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(sizeA, 0); + + ctx.fill(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = IsoBoxCanvasRenderer; diff --git a/src/gameobjects/shape/isobox/IsoBoxFactory.js b/src/gameobjects/shape/isobox/IsoBoxFactory.js new file mode 100644 index 000000000..4a1ad7aa8 --- /dev/null +++ b/src/gameobjects/shape/isobox/IsoBoxFactory.js @@ -0,0 +1,45 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = require('../../GameObjectFactory'); +var IsoBox = require('./IsoBox'); + +/** + * Creates a new IsoBox Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. + * + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * + * @method Phaser.GameObjects.GameObjectFactory#isobox + * @since 3.13.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 {number} [size=48] - The width of the iso box in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso box. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso box. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso box. + * + * @return {Phaser.GameObjects.IsoBox} The Game Object that was created. + */ +GameObjectFactory.register('isobox', function (x, y, size, height, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoBox(this.scene, x, y, size, height, fillTop, fillLeft, fillRight)); +}); diff --git a/src/gameobjects/shape/isobox/IsoBoxRender.js b/src/gameobjects/shape/isobox/IsoBoxRender.js new file mode 100644 index 000000000..670611434 --- /dev/null +++ b/src/gameobjects/shape/isobox/IsoBoxRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./IsoBoxWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./IsoBoxCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/isobox/IsoBoxWebGLRenderer.js b/src/gameobjects/shape/isobox/IsoBoxWebGLRenderer.js new file mode 100644 index 000000000..42489779c --- /dev/null +++ b/src/gameobjects/shape/isobox/IsoBoxWebGLRenderer.js @@ -0,0 +1,152 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = require('../../../renderer/webgl/Utils'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoBox#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoBox} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var alpha = camera.alpha * src.alpha; + + if (!src.isFilled) + { + return; + } + + var tint; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + var x3; + var y3; + + // Top Face + + if (src.showTop) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillTop, alpha); + + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, -sizeB - height); + y1 = calcMatrix.getY(0, -sizeB - height); + + x2 = calcMatrix.getX(sizeA, -height); + y2 = calcMatrix.getY(sizeA, -height); + + x3 = calcMatrix.getX(0, sizeB - height); + y3 = calcMatrix.getY(0, sizeB - height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillLeft, alpha); + + x0 = calcMatrix.getX(-sizeA, 0); + y0 = calcMatrix.getY(-sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + + x3 = calcMatrix.getX(-sizeA, -height); + y3 = calcMatrix.getY(-sizeA, -height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillRight, alpha); + + x0 = calcMatrix.getX(sizeA, 0); + y0 = calcMatrix.getY(sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + + x3 = calcMatrix.getX(sizeA, -height); + y3 = calcMatrix.getY(sizeA, -height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } +}; + +module.exports = IsoBoxWebGLRenderer; diff --git a/src/gameobjects/shape/isotriangle/IsoTriangle.js b/src/gameobjects/shape/isotriangle/IsoTriangle.js new file mode 100644 index 000000000..e71b96de0 --- /dev/null +++ b/src/gameobjects/shape/isotriangle/IsoTriangle.js @@ -0,0 +1,240 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../utils/Class'); +var IsoTriangleRender = require('./IsoTriangleRender'); +var Shape = require('../Shape'); + +/** + * @classdesc + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @class IsoTriangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + */ +var IsoTriangle = new Class({ + + Extends: Shape, + + Mixins: [ + IsoTriangleRender + ], + + initialize: + + function IsoTriangle (scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (size === undefined) { size = 48; } + if (height === undefined) { height = 32; } + if (reversed === undefined) { reversed = false; } + if (fillTop === undefined) { fillTop = 0xeeeeee; } + if (fillLeft === undefined) { fillLeft = 0x999999; } + if (fillRight === undefined) { fillRight = 0xcccccc; } + + Shape.call(this, scene, 'IsoTriangle', null); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * + * @name Phaser.GameObjects.IsoTriangle#projection + * @type {integer} + * @default 4 + * @since 3.13.0 + */ + this.projection = 4; + + /** + * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. + * + * @name Phaser.GameObjects.IsoTriangle#fillTop + * @type {number} + * @since 3.13.0 + */ + this.fillTop = fillTop; + + /** + * The color used to fill in the left-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillLeft + * @type {number} + * @since 3.13.0 + */ + this.fillLeft = fillLeft; + + /** + * The color used to fill in the right-facing side of the iso triangle. + * + * @name Phaser.GameObjects.IsoTriangle#fillRight + * @type {number} + * @since 3.13.0 + */ + this.fillRight = fillRight; + + /** + * Controls if the top-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showTop + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showTop = true; + + /** + * Controls if the left-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showLeft + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showLeft = true; + + /** + * Controls if the right-face of the iso triangle be rendered. + * + * @name Phaser.GameObjects.IsoTriangle#showRight + * @type {boolean} + * @default true + * @since 3.13.0 + */ + this.showRight = true; + + /** + * Sets if the iso triangle will be rendered upside down or not. + * + * @name Phaser.GameObjects.IsoTriangle#isReversed + * @type {boolean} + * @default false + * @since 3.13.0 + */ + this.isReversed = reversed; + + this.isFilled = true; + + this.setPosition(x, y); + this.setSize(size, height); + + this.updateDisplayOrigin(); + }, + + /** + * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setProjection + * @since 3.13.0 + * + * @param {integer} value - The value to set the projection to. + * + * @return {this} This Game Object instance. + */ + setProjection: function (value) + { + this.projection = value; + + return this; + }, + + /** + * Sets if the iso triangle will be rendered upside down or not. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setReversed + * @since 3.13.0 + * + * @param {boolean} reversed - Sets if the iso triangle will be rendered upside down or not. + * + * @return {this} This Game Object instance. + */ + setReversed: function (reversed) + { + this.isReversed = reversed; + + return this; + }, + + /** + * Sets which faces of the iso triangle will be rendered. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFaces + * @since 3.13.0 + * + * @param {boolean} [showTop=true] - Show the top-face of the iso triangle (only if `reversed` is true) + * @param {boolean} [showLeft=true] - Show the left-face of the iso triangle. + * @param {boolean} [showRight=true] - Show the right-face of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFaces: function (showTop, showLeft, showRight) + { + if (showTop === undefined) { showTop = true; } + if (showLeft === undefined) { showLeft = true; } + if (showRight === undefined) { showRight = true; } + + this.showTop = showTop; + this.showLeft = showLeft; + this.showRight = showRight; + + return this; + }, + + /** + * Sets the fill colors for each face of the iso triangle. + * This call can be chained. + * + * @method Phaser.GameObjects.IsoTriangle#setFillStyle + * @since 3.13.0 + * + * @param {number} [fillTop] - The color used to fill the top of the iso triangle. + * @param {number} [fillLeft] - The color used to fill in the left-facing side of the iso triangle. + * @param {number} [fillRight] - The color used to fill in the right-facing side of the iso triangle. + * + * @return {this} This Game Object instance. + */ + setFillStyle: function (fillTop, fillLeft, fillRight) + { + this.fillTop = fillTop; + this.fillLeft = fillLeft; + this.fillRight = fillRight; + + this.isFilled = true; + + return this; + } + +}); + +module.exports = IsoTriangle; diff --git a/src/gameobjects/shape/isotriangle/IsoTriangleCanvasRenderer.js b/src/gameobjects/shape/isotriangle/IsoTriangleCanvasRenderer.js new file mode 100644 index 000000000..cbd1a64e5 --- /dev/null +++ b/src/gameobjects/shape/isotriangle/IsoTriangleCanvasRenderer.js @@ -0,0 +1,108 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = require('../FillStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix) && src.isFilled) + { + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + // Top Face + + if (src.showTop && reversed) + { + FillStyleCanvas(ctx, src, src.fillTop); + + ctx.beginPath(); + + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, -sizeB - height); + ctx.lineTo(sizeA, -height); + ctx.lineTo(0, sizeB - height); + + ctx.fill(); + } + + // Left Face + + if (src.showLeft) + { + FillStyleCanvas(ctx, src, src.fillLeft); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(-sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(-sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + + // Right Face + + if (src.showRight) + { + FillStyleCanvas(ctx, src, src.fillRight); + + ctx.beginPath(); + + if (reversed) + { + ctx.moveTo(sizeA, -height); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + else + { + ctx.moveTo(sizeA, 0); + ctx.lineTo(0, sizeB); + ctx.lineTo(0, sizeB - height); + } + + ctx.fill(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = IsoTriangleCanvasRenderer; diff --git a/src/gameobjects/shape/isotriangle/IsoTriangleFactory.js b/src/gameobjects/shape/isotriangle/IsoTriangleFactory.js new file mode 100644 index 000000000..17b99dde7 --- /dev/null +++ b/src/gameobjects/shape/isotriangle/IsoTriangleFactory.js @@ -0,0 +1,47 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = require('../../GameObjectFactory'); +var IsoTriangle = require('./IsoTriangle'); + +/** + * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. + * + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * + * @method Phaser.GameObjects.GameObjectFactory#isotriangle + * @since 3.13.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 {number} [size=48] - The width of the iso triangle in pixels. The left and right faces will be exactly half this value. + * @param {number} [height=32] - The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. + * @param {boolean} [reversed=false] - Is the iso triangle upside down? + * @param {number} [fillTop=0xeeeeee] - The fill color of the top face of the iso triangle. + * @param {number} [fillLeft=0x999999] - The fill color of the left face of the iso triangle. + * @param {number} [fillRight=0xcccccc] - The fill color of the right face of the iso triangle. + * + * @return {Phaser.GameObjects.IsoTriangle} The Game Object that was created. + */ +GameObjectFactory.register('isotriangle', function (x, y, size, height, reversed, fillTop, fillLeft, fillRight) +{ + return this.displayList.add(new IsoTriangle(this.scene, x, y, size, height, reversed, fillTop, fillLeft, fillRight)); +}); diff --git a/src/gameobjects/shape/isotriangle/IsoTriangleRender.js b/src/gameobjects/shape/isotriangle/IsoTriangleRender.js new file mode 100644 index 000000000..ded1fc5d0 --- /dev/null +++ b/src/gameobjects/shape/isotriangle/IsoTriangleRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./IsoTriangleWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./IsoTriangleCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/isotriangle/IsoTriangleWebGLRenderer.js b/src/gameobjects/shape/isotriangle/IsoTriangleWebGLRenderer.js new file mode 100644 index 000000000..a6fa0d04b --- /dev/null +++ b/src/gameobjects/shape/isotriangle/IsoTriangleWebGLRenderer.js @@ -0,0 +1,171 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = require('../../../renderer/webgl/Utils'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.IsoTriangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.IsoTriangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var size = src.width; + var height = src.height; + + var sizeA = size / 2; + var sizeB = size / src.projection; + + var reversed = src.isReversed; + + var alpha = camera.alpha * src.alpha; + + if (!src.isFilled) + { + return; + } + + var tint; + + var x0; + var y0; + + var x1; + var y1; + + var x2; + var y2; + + // Top Face + + if (src.showTop && reversed) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillTop, alpha); + + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, -sizeB - height); + y1 = calcMatrix.getY(0, -sizeB - height); + + x2 = calcMatrix.getX(sizeA, -height); + y2 = calcMatrix.getY(sizeA, -height); + + var x3 = calcMatrix.getX(0, sizeB - height); + var y3 = calcMatrix.getY(0, sizeB - height); + + pipeline.setTexture2D(); + + pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2); + } + + // Left Face + + if (src.showLeft) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillLeft, alpha); + + if (reversed) + { + x0 = calcMatrix.getX(-sizeA, -height); + y0 = calcMatrix.getY(-sizeA, -height); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + else + { + x0 = calcMatrix.getX(-sizeA, 0); + y0 = calcMatrix.getY(-sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + + pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2); + } + + // Right Face + + if (src.showRight) + { + tint = Utils.getTintAppendFloatAlphaAndSwap(src.fillRight, alpha); + + if (reversed) + { + x0 = calcMatrix.getX(sizeA, -height); + y0 = calcMatrix.getY(sizeA, -height); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + else + { + x0 = calcMatrix.getX(sizeA, 0); + y0 = calcMatrix.getY(sizeA, 0); + + x1 = calcMatrix.getX(0, sizeB); + y1 = calcMatrix.getY(0, sizeB); + + x2 = calcMatrix.getX(0, sizeB - height); + y2 = calcMatrix.getY(0, sizeB - height); + } + + pipeline.setTexture2D(); + + pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2); + } +}; + +module.exports = IsoTriangleWebGLRenderer; diff --git a/src/gameobjects/shape/line/Line.js b/src/gameobjects/shape/line/Line.js new file mode 100644 index 000000000..e639d9a72 --- /dev/null +++ b/src/gameobjects/shape/line/Line.js @@ -0,0 +1,158 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../utils/Class'); +var Shape = require('../Shape'); +var GeomLine = require('../../../geom/line/Line'); +var LineRender = require('./LineRender'); + +/** + * @classdesc + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * @class Line + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Line = new Class({ + + Extends: Shape, + + Mixins: [ + LineRender + ], + + initialize: + + function Line (scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 0; } + if (x2 === undefined) { x2 = 128; } + if (y2 === undefined) { y2 = 0; } + + Shape.call(this, scene, 'Line', new GeomLine(x1, y1, x2, y2)); + + var width = this.geom.right - this.geom.left; + var height = this.geom.bottom - this.geom.top; + + /** + * The width (or thickness) of the line. + * See the setLineWidth method for extra details on changing this on WebGL. + * + * @name Phaser.GameObjects.Line#lineWidth + * @type {number} + * @since 3.13.0 + */ + this.lineWidth = 1; + + /** + * Private internal value. Holds the start width of the line. + * + * @name Phaser.GameObjects.Line#_startWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._startWidth = 1; + + /** + * Private internal value. Holds the end width of the line. + * + * @name Phaser.GameObjects.Line#_endWidth + * @type {number} + * @private + * @since 3.13.0 + */ + this._endWidth = 1; + + this.setPosition(x, y); + this.setSize(width, height); + + if (strokeColor !== undefined) + { + this.setStrokeStyle(1, strokeColor, strokeAlpha); + } + + this.updateDisplayOrigin(); + }, + + /** + * Sets the width of the line. + * + * When using the WebGL renderer you can have different start and end widths. + * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. + * + * This call can be chained. + * + * @method Phaser.GameObjects.Line#setLineWidth + * @since 3.13.0 + * + * @param {number} startWidth - The start width of the line. + * @param {number} [endWidth] - The end width of the line. Only used in WebGL. + * + * @return {this} This Game Object instance. + */ + setLineWidth: function (startWidth, endWidth) + { + if (endWidth === undefined) { endWidth = startWidth; } + + this._startWidth = startWidth; + this._endWidth = endWidth; + + this.lineWidth = startWidth; + + return this; + }, + + /** + * Sets the start and end coordinates of this Line. + * + * @method Phaser.GameObjects.Line#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=0] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * + * @return {this} This Line object. + */ + setTo: function (x1, y1, x2, y2) + { + this.geom.setTo(x1, y1, x2, y2); + + return this; + } + +}); + +module.exports = Line; diff --git a/src/gameobjects/shape/line/LineCanvasRenderer.js b/src/gameobjects/shape/line/LineCanvasRenderer.js new file mode 100644 index 000000000..231d4d0dc --- /dev/null +++ b/src/gameobjects/shape/line/LineCanvasRenderer.js @@ -0,0 +1,51 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var LineStyleCanvas = require('../LineStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.moveTo(src.geom.x1 - dx, src.geom.y1 - dy); + ctx.lineTo(src.geom.x2 - dx, src.geom.y2 - dy); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = LineCanvasRenderer; diff --git a/src/gameobjects/shape/line/LineFactory.js b/src/gameobjects/shape/line/LineFactory.js new file mode 100644 index 000000000..90c0e7d5c --- /dev/null +++ b/src/gameobjects/shape/line/LineFactory.js @@ -0,0 +1,45 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = require('../../GameObjectFactory'); +var Line = require('./Line'); + +/** + * Creates a new Line Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Line Game Object has been built into Phaser. + * + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * + * @method Phaser.GameObjects.GameObjectFactory#line + * @since 3.13.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 {number} [x1=0] - The horizontal position of the start of the line. + * @param {number} [y1=0] - The vertical position of the start of the line. + * @param {number} [x2=128] - The horizontal position of the end of the line. + * @param {number} [y2=0] - The vertical position of the end of the line. + * @param {number} [strokeColor] - The color the line will be drawn in, i.e. 0xff0000 for red. + * @param {number} [strokeAlpha] - The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Line} The Game Object that was created. + */ +GameObjectFactory.register('line', function (x, y, x1, y1, x2, y2, strokeColor, strokeAlpha) +{ + return this.displayList.add(new Line(this.scene, x, y, x1, y1, x2, y2, strokeColor, strokeAlpha)); +}); diff --git a/src/gameobjects/shape/line/LineRender.js b/src/gameobjects/shape/line/LineRender.js new file mode 100644 index 000000000..38051e196 --- /dev/null +++ b/src/gameobjects/shape/line/LineRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./LineWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./LineCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/line/LineWebGLRenderer.js b/src/gameobjects/shape/line/LineWebGLRenderer.js new file mode 100644 index 000000000..21ad80026 --- /dev/null +++ b/src/gameobjects/shape/line/LineWebGLRenderer.js @@ -0,0 +1,87 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Utils = require('../../../renderer/webgl/Utils'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Line#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Line} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var LineWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isStroked) + { + var strokeTint = pipeline.strokeTint; + var color = Utils.getTintAppendFloatAlphaAndSwap(src.strokeColor, src.strokeAlpha * alpha); + + strokeTint.TL = color; + strokeTint.TR = color; + strokeTint.BL = color; + strokeTint.BR = color; + + var startWidth = src._startWidth; + var endWidth = src._endWidth; + + pipeline.setTexture2D(); + + pipeline.batchLine( + src.geom.x1 - dx, + src.geom.y1 - dy, + src.geom.x2 - dx, + src.geom.y2 - dy, + startWidth, + endWidth, + 1, + 0, + false, + shapeMatrix, + camMatrix + ); + } +}; + +module.exports = LineWebGLRenderer; diff --git a/src/gameobjects/shape/polygon/Polygon.js b/src/gameobjects/shape/polygon/Polygon.js new file mode 100644 index 000000000..bbbe48ba9 --- /dev/null +++ b/src/gameobjects/shape/polygon/Polygon.js @@ -0,0 +1,133 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var PolygonRender = require('./PolygonRender'); +var Class = require('../../../utils/Class'); +var Earcut = require('../../../geom/polygon/Earcut'); +var GetAABB = require('../../../geom/polygon/GetAABB'); +var GeomPolygon = require('../../../geom/polygon/Polygon'); +var Shape = require('../Shape'); +var Smooth = require('../../../geom/polygon/Smooth'); + +/** + * @classdesc + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * @class Polygon + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Polygon = new Class({ + + Extends: Shape, + + Mixins: [ + PolygonRender + ], + + initialize: + + function Polygon (scene, x, y, points, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + Shape.call(this, scene, 'Polygon', new GeomPolygon(points)); + + var bounds = GetAABB(this.geom); + + this.setPosition(x, y); + this.setSize(bounds.width, bounds.height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Smooths the polygon over the number of iterations specified. + * The base polygon data will be updated and replaced with the smoothed values. + * This call can be chained. + * + * @method Phaser.GameObjects.Polygon#smooth + * @since 3.13.0 + * + * @param {integer} [iterations=1] - The number of times to apply the polygon smoothing. + * + * @return {this} This Game Object instance. + */ + smooth: function (iterations) + { + if (iterations === undefined) { iterations = 1; } + + for (var i = 0; i < iterations; i++) + { + Smooth(this.geom); + } + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Polygon#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var points = this.geom.points; + + for (var i = 0; i < points.length; i++) + { + path.push(points[i].x, points[i].y); + } + + path.push(points[0].x, points[0].y); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Polygon; diff --git a/src/gameobjects/shape/polygon/PolygonCanvasRenderer.js b/src/gameobjects/shape/polygon/PolygonCanvasRenderer.js new file mode 100644 index 000000000..bf447b96e --- /dev/null +++ b/src/gameobjects/shape/polygon/PolygonCanvasRenderer.js @@ -0,0 +1,79 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = require('../FillStyleCanvas'); +var LineStyleCanvas = require('../LineStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = PolygonCanvasRenderer; diff --git a/src/gameobjects/shape/polygon/PolygonFactory.js b/src/gameobjects/shape/polygon/PolygonFactory.js new file mode 100644 index 000000000..bf886a8fb --- /dev/null +++ b/src/gameobjects/shape/polygon/PolygonFactory.js @@ -0,0 +1,47 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = require('../../GameObjectFactory'); +var Polygon = require('./Polygon'); + +/** + * Creates a new Polygon Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Polygon Game Object has been built into Phaser. + * + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * + * @method Phaser.GameObjects.GameObjectFactory#polygon + * @since 3.13.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 {any} [points] - The points that make up the polygon. + * @param {number} [fillColor] - The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Polygon} The Game Object that was created. + */ +GameObjectFactory.register('polygon', function (x, y, points, fillColor, fillAlpha) +{ + return this.displayList.add(new Polygon(this.scene, x, y, points, fillColor, fillAlpha)); +}); diff --git a/src/gameobjects/shape/polygon/PolygonRender.js b/src/gameobjects/shape/polygon/PolygonRender.js new file mode 100644 index 000000000..f764840bc --- /dev/null +++ b/src/gameobjects/shape/polygon/PolygonRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./PolygonWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./PolygonCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/polygon/PolygonWebGLRenderer.js b/src/gameobjects/shape/polygon/PolygonWebGLRenderer.js new file mode 100644 index 000000000..8bc09d393 --- /dev/null +++ b/src/gameobjects/shape/polygon/PolygonWebGLRenderer.js @@ -0,0 +1,72 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = require('../FillPathWebGL'); +var StrokePathWebGL = require('../StrokePathWebGL'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Polygon#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Polygon} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var PolygonWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = PolygonWebGLRenderer; diff --git a/src/gameobjects/shape/rectangle/Rectangle.js b/src/gameobjects/shape/rectangle/Rectangle.js new file mode 100644 index 000000000..9254034b9 --- /dev/null +++ b/src/gameobjects/shape/rectangle/Rectangle.js @@ -0,0 +1,106 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../utils/Class'); +var GeomRectangle = require('../../../geom/rectangle/Rectangle'); +var Shape = require('../Shape'); +var RectangleRender = require('./RectangleRender'); + +/** + * @classdesc + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @class Rectangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} x - The horizontal position of this Game Object in the world. + * @param {number} y - The vertical position of this Game Object in the world. + * @param {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Rectangle = new Class({ + + Extends: Shape, + + Mixins: [ + RectangleRender + ], + + initialize: + + function Rectangle (scene, x, y, width, height, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = 128; } + if (height === undefined) { height = 128; } + + Shape.call(this, scene, 'Rectangle', new GeomRectangle(0, 0, width, height)); + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Rectangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var rect = this.geom; + var line = this._tempLine; + + rect.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + rect.getLineB(line); + + path.push(line.x2, line.y2); + + rect.getLineC(line); + + path.push(line.x2, line.y2); + + rect.getLineD(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + } + +}); + +module.exports = Rectangle; diff --git a/src/gameobjects/shape/rectangle/RectangleCanvasRenderer.js b/src/gameobjects/shape/rectangle/RectangleCanvasRenderer.js new file mode 100644 index 000000000..3f4ceeb7a --- /dev/null +++ b/src/gameobjects/shape/rectangle/RectangleCanvasRenderer.js @@ -0,0 +1,68 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = require('../FillStyleCanvas'); +var LineStyleCanvas = require('../LineStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.beginPath(); + + ctx.rect( + -dx, + -dy, + src.width, + src.height + ); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = RectangleCanvasRenderer; diff --git a/src/gameobjects/shape/rectangle/RectangleFactory.js b/src/gameobjects/shape/rectangle/RectangleFactory.js new file mode 100644 index 000000000..01960308b --- /dev/null +++ b/src/gameobjects/shape/rectangle/RectangleFactory.js @@ -0,0 +1,39 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = require('../../GameObjectFactory'); +var Rectangle = require('./Rectangle'); + +/** + * Creates a new Rectangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. + * + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * + * @method Phaser.GameObjects.GameObjectFactory#rectangle + * @since 3.13.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 {number} [width=128] - The width of the rectangle. + * @param {number} [height=128] - The height of the rectangle. + * @param {number} [fillColor] - The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Rectangle} The Game Object that was created. + */ +GameObjectFactory.register('rectangle', function (x, y, width, height, fillColor, fillAlpha) +{ + return this.displayList.add(new Rectangle(this.scene, x, y, width, height, fillColor, fillAlpha)); +}); diff --git a/src/gameobjects/shape/rectangle/RectangleRender.js b/src/gameobjects/shape/rectangle/RectangleRender.js new file mode 100644 index 000000000..d6203ed39 --- /dev/null +++ b/src/gameobjects/shape/rectangle/RectangleRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./RectangleWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./RectangleCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/rectangle/RectangleWebGLRenderer.js b/src/gameobjects/shape/rectangle/RectangleWebGLRenderer.js new file mode 100644 index 000000000..c04729c79 --- /dev/null +++ b/src/gameobjects/shape/rectangle/RectangleWebGLRenderer.js @@ -0,0 +1,86 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StrokePathWebGL = require('../StrokePathWebGL'); +var Utils = require('../../../renderer/webgl/Utils'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Rectangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Rectangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var RectangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + var fillTint = pipeline.fillTint; + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + pipeline.setTexture2D(); + + pipeline.batchFillRect( + -dx, + -dy, + src.width, + src.height + ); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = RectangleWebGLRenderer; diff --git a/src/gameobjects/shape/star/Star.js b/src/gameobjects/shape/star/Star.js new file mode 100644 index 000000000..38b648f2c --- /dev/null +++ b/src/gameobjects/shape/star/Star.js @@ -0,0 +1,282 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StarRender = require('./StarRender'); +var Class = require('../../../utils/Class'); +var Earcut = require('../../../geom/polygon/Earcut'); +var Shape = require('../Shape'); + +/** + * @classdesc + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @class Star + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star. + * @param {number} [outerRadius=64] - The outer radius of the star. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Star = new Class({ + + Extends: Shape, + + Mixins: [ + StarRender + ], + + initialize: + + function Star (scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (points === undefined) { points = 5; } + if (innerRadius === undefined) { innerRadius = 32; } + if (outerRadius === undefined) { outerRadius = 64; } + + Shape.call(this, scene, 'Star', null); + + /** + * Private internal value. + * The number of points in the star. + * + * @name Phaser.GameObjects.Star#_points + * @type {integer} + * @private + * @since 3.13.0 + */ + this._points = points; + + /** + * Private internal value. + * The inner radius of the star. + * + * @name Phaser.GameObjects.Star#_innerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._innerRadius = innerRadius; + + /** + * Private internal value. + * The outer radius of the star. + * + * @name Phaser.GameObjects.Star#_outerRadius + * @type {number} + * @private + * @since 3.13.0 + */ + this._outerRadius = outerRadius; + + this.setPosition(x, y); + this.setSize(outerRadius * 2, outerRadius * 2); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the number of points that make up the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setPoints + * @since 3.13.0 + * + * @param {integer} value - The amount of points the Star will have. + * + * @return {this} This Game Object instance. + */ + setPoints: function (value) + { + this._points = value; + + return this.updateData(); + }, + + /** + * Sets the inner radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setInnerRadius + * @since 3.13.0 + * + * @param {number} value - The amount to set the inner radius to. + * + * @return {this} This Game Object instance. + */ + setInnerRadius: function (value) + { + this._innerRadius = value; + + return this.updateData(); + }, + + /** + * Sets the outer radius of the Star shape. + * This call can be chained. + * + * @method Phaser.GameObjects.Star#setOuterRadius + * @since 3.13.0 + * + * @param {number} value - The amount to set the outer radius to. + * + * @return {this} This Game Object instance. + */ + setOuterRadius: function (value) + { + this._outerRadius = value; + + return this.updateData(); + }, + + /** + * The number of points that make up the Star shape. + * + * @name Phaser.GameObjects.Star#points + * @type {integer} + * @default 5 + * @since 3.13.0 + */ + points: { + + get: function () + { + return this._points; + }, + + set: function (value) + { + this._points = value; + + this.updateData(); + } + + }, + + /** + * The inner radius of the Star shape. + * + * @name Phaser.GameObjects.Star#innerRadius + * @type {number} + * @default 32 + * @since 3.13.0 + */ + innerRadius: { + + get: function () + { + return this._innerRadius; + }, + + set: function (value) + { + this._innerRadius = value; + + this.updateData(); + } + + }, + + /** + * The outer radius of the Star shape. + * + * @name Phaser.GameObjects.Star#outerRadius + * @type {number} + * @default 64 + * @since 3.13.0 + */ + outerRadius: { + + get: function () + { + return this._outerRadius; + }, + + set: function (value) + { + this._outerRadius = value; + + this.updateData(); + } + + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Star#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + + var points = this._points; + var innerRadius = this._innerRadius; + var outerRadius = this._outerRadius; + + var rot = Math.PI / 2 * 3; + var step = Math.PI / points; + + // So origin 0.5 = the center of the star + var x = outerRadius; + var y = outerRadius; + + path.push(x, y + -outerRadius); + + for (var i = 0; i < points; i++) + { + path.push(x + Math.cos(rot) * outerRadius, y + Math.sin(rot) * outerRadius); + + rot += step; + + path.push(x + Math.cos(rot) * innerRadius, y + Math.sin(rot) * innerRadius); + + rot += step; + } + + path.push(x, y + -outerRadius); + + this.pathIndexes = Earcut(path); + this.pathData = path; + + return this; + } + +}); + +module.exports = Star; diff --git a/src/gameobjects/shape/star/StarCanvasRenderer.js b/src/gameobjects/shape/star/StarCanvasRenderer.js new file mode 100644 index 000000000..287976bc6 --- /dev/null +++ b/src/gameobjects/shape/star/StarCanvasRenderer.js @@ -0,0 +1,79 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = require('../FillStyleCanvas'); +var LineStyleCanvas = require('../LineStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var path = src.pathData; + var pathLength = path.length - 1; + + var px1 = path[0] - dx; + var py1 = path[1] - dy; + + ctx.beginPath(); + + ctx.moveTo(px1, py1); + + if (!src.closePath) + { + pathLength -= 2; + } + + for (var i = 2; i < pathLength; i += 2) + { + var px2 = path[i] - dx; + var py2 = path[i + 1] - dy; + + ctx.lineTo(px2, py2); + } + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = StarCanvasRenderer; diff --git a/src/gameobjects/shape/star/StarFactory.js b/src/gameobjects/shape/star/StarFactory.js new file mode 100644 index 000000000..9910605f2 --- /dev/null +++ b/src/gameobjects/shape/star/StarFactory.js @@ -0,0 +1,46 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Star = require('./Star'); +var GameObjectFactory = require('../../GameObjectFactory'); + +/** + * Creates a new Star Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Star Game Object has been built into Phaser. + * + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * + * @method Phaser.GameObjects.GameObjectFactory#star + * @since 3.13.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 {number} [points=5] - The number of points on the star. + * @param {number} [innerRadius=32] - The inner radius of the star. + * @param {number} [outerRadius=64] - The outer radius of the star. + * @param {number} [fillColor] - The color the star will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Star} The Game Object that was created. + */ +GameObjectFactory.register('star', function (x, y, points, innerRadius, outerRadius, fillColor, fillAlpha) +{ + return this.displayList.add(new Star(this.scene, x, y, points, innerRadius, outerRadius, fillColor, fillAlpha)); +}); diff --git a/src/gameobjects/shape/star/StarRender.js b/src/gameobjects/shape/star/StarRender.js new file mode 100644 index 000000000..189d9d6f6 --- /dev/null +++ b/src/gameobjects/shape/star/StarRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./StarWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./StarCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/star/StarWebGLRenderer.js b/src/gameobjects/shape/star/StarWebGLRenderer.js new file mode 100644 index 000000000..1cfee8e3f --- /dev/null +++ b/src/gameobjects/shape/star/StarWebGLRenderer.js @@ -0,0 +1,72 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillPathWebGL = require('../FillPathWebGL'); +var StrokePathWebGL = require('../StrokePathWebGL'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Star#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Star} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var StarWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + FillPathWebGL(pipeline, calcMatrix, src, alpha, dx, dy); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = StarWebGLRenderer; diff --git a/src/gameobjects/shape/triangle/Triangle.js b/src/gameobjects/shape/triangle/Triangle.js new file mode 100644 index 000000000..5b09ee332 --- /dev/null +++ b/src/gameobjects/shape/triangle/Triangle.js @@ -0,0 +1,137 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../../utils/Class'); +var Shape = require('../Shape'); +var GeomTriangle = require('../../../geom/triangle/Triangle'); +var TriangleRender = require('./TriangleRender'); + +/** + * @classdesc + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @class Triangle + * @extends Phaser.GameObjects.Shape + * @memberof Phaser.GameObjects + * @constructor + * @since 3.13.0 + * + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param {number} [x=0] - The horizontal position of this Game Object in the world. + * @param {number} [y=0] - The vertical position of this Game Object in the world. + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ +var Triangle = new Class({ + + Extends: Shape, + + Mixins: [ + TriangleRender + ], + + initialize: + + function Triangle (scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (x1 === undefined) { x1 = 0; } + if (y1 === undefined) { y1 = 128; } + if (x2 === undefined) { x2 = 64; } + if (y2 === undefined) { y2 = 0; } + if (x3 === undefined) { x3 = 128; } + if (y3 === undefined) { y3 = 128; } + + Shape.call(this, scene, 'Triangle', new GeomTriangle(x1, y1, x2, y2, x3, y3)); + + var width = this.geom.right - this.geom.left; + var height = this.geom.bottom - this.geom.top; + + this.setPosition(x, y); + this.setSize(width, height); + + if (fillColor !== undefined) + { + this.setFillStyle(fillColor, fillAlpha); + } + + this.updateDisplayOrigin(); + this.updateData(); + }, + + /** + * Sets the data for the lines that make up this Triangle shape. + * + * @method Phaser.GameObjects.Triangle#setTo + * @since 3.13.0 + * + * @param {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=0] - The vertical position of the first point in the triangle. + * @param {number} [x2=0] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=0] - The horizontal position of the third point in the triangle. + * @param {number} [y3=0] - The vertical position of the third point in the triangle. + * + * @return {this} This Game Object instance. + */ + setTo: function (x1, y1, x2, y2, x3, y3) + { + this.geom.setTo(x1, y1, x2, y2, x3, y3); + + return this.updateData(); + }, + + /** + * Internal method that updates the data and path values. + * + * @method Phaser.GameObjects.Triangle#updateData + * @private + * @since 3.13.0 + * + * @return {this} This Game Object instance. + */ + updateData: function () + { + var path = []; + var rect = this.geom; + var line = this._tempLine; + + rect.getLineA(line); + + path.push(line.x1, line.y1, line.x2, line.y2); + + rect.getLineB(line); + + path.push(line.x2, line.y2); + + rect.getLineC(line); + + path.push(line.x2, line.y2); + + this.pathData = path; + + return this; + } + +}); + +module.exports = Triangle; diff --git a/src/gameobjects/shape/triangle/TriangleCanvasRenderer.js b/src/gameobjects/shape/triangle/TriangleCanvasRenderer.js new file mode 100644 index 000000000..25bc48a67 --- /dev/null +++ b/src/gameobjects/shape/triangle/TriangleCanvasRenderer.js @@ -0,0 +1,69 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var FillStyleCanvas = require('../FillStyleCanvas'); +var LineStyleCanvas = require('../LineStyleCanvas'); +var SetTransform = require('../../../renderer/canvas/utils/SetTransform'); + +/** + * Renders this Game Object with the Canvas Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderCanvas + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var ctx = renderer.currentContext; + + if (SetTransform(renderer, ctx, src, camera, parentMatrix)) + { + var dx = src._displayOriginX; + var dy = src._displayOriginY; + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + ctx.beginPath(); + + ctx.moveTo(x1, y1); + ctx.lineTo(x2, y2); + ctx.lineTo(x3, y3); + + ctx.closePath(); + + if (src.isFilled) + { + FillStyleCanvas(ctx, src); + + ctx.fill(); + } + + if (src.isStroked) + { + LineStyleCanvas(ctx, src); + + ctx.stroke(); + } + + // Restore the context saved in SetTransform + ctx.restore(); + } +}; + +module.exports = TriangleCanvasRenderer; diff --git a/src/gameobjects/shape/triangle/TriangleFactory.js b/src/gameobjects/shape/triangle/TriangleFactory.js new file mode 100644 index 000000000..0d92e65ec --- /dev/null +++ b/src/gameobjects/shape/triangle/TriangleFactory.js @@ -0,0 +1,45 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var GameObjectFactory = require('../../GameObjectFactory'); +var Triangle = require('./Triangle'); + +/** + * Creates a new Triangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Triangle Game Object has been built into Phaser. + * + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * + * @method Phaser.GameObjects.GameObjectFactory#triangle + * @since 3.13.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 {number} [x1=0] - The horizontal position of the first point in the triangle. + * @param {number} [y1=128] - The vertical position of the first point in the triangle. + * @param {number} [x2=64] - The horizontal position of the second point in the triangle. + * @param {number} [y2=0] - The vertical position of the second point in the triangle. + * @param {number} [x3=128] - The horizontal position of the third point in the triangle. + * @param {number} [y3=128] - The vertical position of the third point in the triangle. + * @param {number} [fillColor] - The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param {number} [fillAlpha] - The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * + * @return {Phaser.GameObjects.Triangle} The Game Object that was created. + */ +GameObjectFactory.register('triangle', function (x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha) +{ + return this.displayList.add(new Triangle(this.scene, x, y, x1, y1, x2, y2, x3, y3, fillColor, fillAlpha)); +}); diff --git a/src/gameobjects/shape/triangle/TriangleRender.js b/src/gameobjects/shape/triangle/TriangleRender.js new file mode 100644 index 000000000..9f78d38db --- /dev/null +++ b/src/gameobjects/shape/triangle/TriangleRender.js @@ -0,0 +1,25 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var renderWebGL = require('../../../utils/NOOP'); +var renderCanvas = require('../../../utils/NOOP'); + +if (typeof WEBGL_RENDERER) +{ + renderWebGL = require('./TriangleWebGLRenderer'); +} + +if (typeof CANVAS_RENDERER) +{ + renderCanvas = require('./TriangleCanvasRenderer'); +} + +module.exports = { + + renderWebGL: renderWebGL, + renderCanvas: renderCanvas + +}; diff --git a/src/gameobjects/shape/triangle/TriangleWebGLRenderer.js b/src/gameobjects/shape/triangle/TriangleWebGLRenderer.js new file mode 100644 index 000000000..eb4c43e6c --- /dev/null +++ b/src/gameobjects/shape/triangle/TriangleWebGLRenderer.js @@ -0,0 +1,97 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var StrokePathWebGL = require('../StrokePathWebGL'); +var Utils = require('../../../renderer/webgl/Utils'); + +/** + * Renders this Game Object with the WebGL Renderer to the given Camera. + * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. + * This method should not be called directly. It is a utility function of the Render module. + * + * @method Phaser.GameObjects.Triangle#renderWebGL + * @since 3.13.0 + * @private + * + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - A reference to the current active WebGL renderer. + * @param {Phaser.GameObjects.Triangle} src - The Game Object being rendered in this call. + * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested + */ +var TriangleWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) +{ + var pipeline = this.pipeline; + + var camMatrix = pipeline._tempMatrix1; + var shapeMatrix = pipeline._tempMatrix2; + var calcMatrix = pipeline._tempMatrix3; + + renderer.setPipeline(pipeline); + + shapeMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + shapeMatrix.e = src.x; + shapeMatrix.f = src.y; + } + else + { + shapeMatrix.e -= camera.scrollX * src.scrollFactorX; + shapeMatrix.f -= camera.scrollY * src.scrollFactorY; + } + + camMatrix.multiply(shapeMatrix, calcMatrix); + + var dx = src._displayOriginX; + var dy = src._displayOriginY; + var alpha = camera.alpha * src.alpha; + + if (src.isFilled) + { + var fillTint = pipeline.fillTint; + var fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha); + + fillTint.TL = fillTintColor; + fillTint.TR = fillTintColor; + fillTint.BL = fillTintColor; + fillTint.BR = fillTintColor; + + var x1 = src.geom.x1 - dx; + var y1 = src.geom.y1 - dy; + var x2 = src.geom.x2 - dx; + var y2 = src.geom.y2 - dy; + var x3 = src.geom.x3 - dx; + var y3 = src.geom.y3 - dy; + + pipeline.setTexture2D(); + + pipeline.batchFillTriangle( + x1, + y1, + x2, + y2, + x3, + y3, + shapeMatrix, + camMatrix + ); + } + + if (src.isStroked) + { + StrokePathWebGL(pipeline, src, alpha, dx, dy); + } +}; + +module.exports = TriangleWebGLRenderer; diff --git a/src/gameobjects/sprite/Sprite.js b/src/gameobjects/sprite/Sprite.js index e36d93d24..04f922573 100644 --- a/src/gameobjects/sprite/Sprite.js +++ b/src/gameobjects/sprite/Sprite.js @@ -23,7 +23,7 @@ var SpriteRender = require('./SpriteRender'); * * @class Sprite * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -38,7 +38,7 @@ var SpriteRender = require('./SpriteRender'); * @extends Phaser.GameObjects.Components.ScaleMode * @extends Phaser.GameObjects.Components.ScrollFactor * @extends Phaser.GameObjects.Components.Size - * @extends Phaser.GameObjects.Components.Texture + * @extends Phaser.GameObjects.Components.TextureCrop * @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible @@ -65,7 +65,7 @@ var Sprite = new Class({ Components.ScaleMode, Components.ScrollFactor, Components.Size, - Components.Texture, + Components.TextureCrop, Components.Tint, Components.Transform, Components.Visible, @@ -78,6 +78,16 @@ var Sprite = new Class({ { GameObject.call(this, scene, 'Sprite'); + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Sprite#_crop + * @type {object} + * @private + * @since 3.11.0 + */ + this._crop = this.resetCropObject(); + /** * The Animation Controller of this Sprite. * @@ -91,7 +101,7 @@ var Sprite = new Class({ this.setPosition(x, y); this.setSizeToFrame(); this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); + this.initPipeline(); }, /** @@ -143,6 +153,20 @@ var Sprite = new Class({ // Extra Sprite data is added here return data; + }, + + /** + * Handles the pre-destroy step for the Sprite, which removes the Animation component. + * + * @method Phaser.GameObjects.Sprite#preDestroy + * @private + * @since 3.14.0 + */ + preDestroy: function () + { + this.anims.destroy(); + + this.anims = undefined; } }); diff --git a/src/gameobjects/sprite/SpriteCanvasRenderer.js b/src/gameobjects/sprite/SpriteCanvasRenderer.js index 9263ef104..9bc589bba 100644 --- a/src/gameobjects/sprite/SpriteCanvasRenderer.js +++ b/src/gameobjects/sprite/SpriteCanvasRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -23,12 +21,7 @@ var GameObject = require('../GameObject'); */ var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) - { - return; - } - - renderer.drawImage(src, camera, parentMatrix); + renderer.batchSprite(src, src.frame, camera, parentMatrix); }; module.exports = SpriteCanvasRenderer; diff --git a/src/gameobjects/sprite/SpriteCreator.js b/src/gameobjects/sprite/SpriteCreator.js index 3643ed240..af40df5b3 100644 --- a/src/gameobjects/sprite/SpriteCreator.js +++ b/src/gameobjects/sprite/SpriteCreator.js @@ -10,6 +10,14 @@ var GameObjectCreator = require('../GameObjectCreator'); var GetAdvancedValue = require('../../utils/object/GetAdvancedValue'); var Sprite = require('./Sprite'); +/** + * @typedef {object} SpriteConfig + * @extends GameObjectConfig + * + * @property {string} [key] - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @property {(number|string)} [frame] - An optional frame from the Texture this Game Object is rendering with. + */ + /** * Creates a new Sprite Game Object and returns it. * @@ -18,7 +26,7 @@ var Sprite = require('./Sprite'); * @method Phaser.GameObjects.GameObjectCreator#sprite * @since 3.0.0 * - * @param {object} config - The configuration object this Game Object will use to create itself. + * @param {SpriteConfig} config - The configuration object this Game Object will use to create itself. * @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. * * @return {Phaser.GameObjects.Sprite} The Game Object that was created. diff --git a/src/gameobjects/sprite/SpriteWebGLRenderer.js b/src/gameobjects/sprite/SpriteWebGLRenderer.js index a9c850fba..aa114612d 100644 --- a/src/gameobjects/sprite/SpriteWebGLRenderer.js +++ b/src/gameobjects/sprite/SpriteWebGLRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the WebGL Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -23,11 +21,6 @@ var GameObject = require('../GameObject'); */ var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) - { - return; - } - this.pipeline.batchSprite(src, camera, parentMatrix); }; diff --git a/src/gameobjects/text/GetTextSize.js b/src/gameobjects/text/GetTextSize.js index db8361bdf..333eb95f6 100644 --- a/src/gameobjects/text/GetTextSize.js +++ b/src/gameobjects/text/GetTextSize.js @@ -11,7 +11,7 @@ * @since 3.0.0 * * @param {Phaser.GameObjects.Text} text - The Text object to calculate the size from. - * @param {TextMetrics} size - The Text metrics to use when calculating the size. + * @param {BitmapTextMetrics} size - The Text metrics to use when calculating the size. * @param {array} lines - The lines of text to calculate the size from. * * @return {object} An object containing dimensions of the Text object. @@ -55,17 +55,12 @@ var GetTextSize = function (text, size, lines) var lineHeight = size.fontSize + style.strokeThickness; var height = lineHeight * drawnLines; - var lineSpacing = text._lineSpacing || 0; - - if (lineSpacing < 0 && Math.abs(lineSpacing) > lineHeight) - { - lineSpacing = -lineHeight; - } + var lineSpacing = text.lineSpacing; // Adjust for line spacing - if (lineSpacing !== 0) + if (lines.length > 1) { - height += (lineSpacing > 0) ? lineSpacing * lines.length : lineSpacing * (lines.length - 1); + height += lineSpacing * (lines.length - 1); } return { diff --git a/src/gameobjects/text/TextStyle.js b/src/gameobjects/text/TextStyle.js index 95ded0112..bb9ab95b8 100644 --- a/src/gameobjects/text/TextStyle.js +++ b/src/gameobjects/text/TextStyle.js @@ -40,6 +40,7 @@ var propertyMap = { maxLines: [ 'maxLines', 0 ], fixedWidth: [ 'fixedWidth', 0 ], fixedHeight: [ 'fixedHeight', 0 ], + resolution: [ 'resolution', 0 ], rtl: [ 'rtl', false ], testString: [ 'testString', '|MÉqgy' ], baselineX: [ 'baselineX', 1.2 ], @@ -53,7 +54,7 @@ var propertyMap = { /** * Font metrics for a Text Style object. * - * @typedef {object} TextMetrics + * @typedef {object} BitmapTextMetrics * * @property {number} ascent - The ascent of the font. * @property {number} descent - The descent of the font. @@ -65,7 +66,7 @@ var propertyMap = { * Style settings for a Text object. * * @class TextStyle - * @memberOf Phaser.GameObjects.Text + * @memberof Phaser.GameObjects.Text * @constructor * @since 3.0.0 * @@ -259,6 +260,17 @@ var TextStyle = new Class({ */ this.fixedHeight; + /** + * The resolution the text is rendered to its internal canvas at. + * The default is 0, which means it will use the resolution set in the Game Config. + * + * @name Phaser.GameObjects.Text.TextStyle#resolution + * @type {number} + * @default 0 + * @since 3.12.0 + */ + this.resolution; + /** * Whether the text should render right to left. * @@ -310,7 +322,7 @@ var TextStyle = new Class({ this._font; // Set to defaults + user style - this.setStyle(style, false); + this.setStyle(style, false, true); var metrics = GetValue(style, 'metrics', false); @@ -347,12 +359,14 @@ var TextStyle = new Class({ * * @param {object} style - The style settings to set. * @param {boolean} [updateText=true] - Whether to update the text immediately. + * @param {boolean} [setDefaults=false] - Use the default values is not set, or the local values. * * @return {Phaser.GameObjects.Text} The parent Text object. */ - setStyle: function (style, updateText) + setStyle: function (style, updateText, setDefaults) { if (updateText === undefined) { updateText = true; } + if (setDefaults === undefined) { setDefaults = false; } // Avoid type mutation if (style && style.hasOwnProperty('fontSize') && typeof style.fontSize === 'number') @@ -362,29 +376,29 @@ var TextStyle = new Class({ for (var key in propertyMap) { + var value = (setDefaults) ? propertyMap[key][1] : this[key]; + if (key === 'wordWrapCallback' || key === 'wordWrapCallbackScope') { // Callback & scope should be set without processing the values - this[key] = GetValue(style, propertyMap[key][0], propertyMap[key][1]); + this[key] = GetValue(style, propertyMap[key][0], value); } else { - this[key] = GetAdvancedValue(style, propertyMap[key][0], propertyMap[key][1]); + this[key] = GetAdvancedValue(style, propertyMap[key][0], value); } } // Allow for 'font' override var font = GetValue(style, 'font', null); - if (font === null) + if (font !== null) { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); - } - else - { - this._font = font; + this.setFont(font, false); } + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); + // Allow for 'fill' to be used in place of 'color' var fill = GetValue(style, 'fill', null); @@ -479,7 +493,7 @@ var TextStyle = new Class({ { if (recalculateMetrics) { - this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' '); + this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim(); this.metrics = MeasureText(this); } @@ -499,25 +513,48 @@ var TextStyle = new Class({ * @since 3.0.0 * * @param {(string|object)} font - The font family or font settings to set. + * @param {boolean} [updateText=true] - Whether to update the text immediately. * * @return {Phaser.GameObjects.Text} The parent Text object. */ - setFont: function (font) + setFont: function (font, updateText) { - if (typeof font === 'string') + if (updateText === undefined) { updateText = true; } + + var fontFamily = font; + var fontSize = ''; + var fontStyle = ''; + + if (typeof font !== 'string') { - this.fontFamily = font; - this.fontSize = ''; - this.fontStyle = ''; + fontFamily = GetValue(font, 'fontFamily', 'Courier'); + fontSize = GetValue(font, 'fontSize', '16px'); + fontStyle = GetValue(font, 'fontStyle', ''); } else { - this.fontFamily = GetValue(font, 'fontFamily', 'Courier'); - this.fontSize = GetValue(font, 'fontSize', '16px'); - this.fontStyle = GetValue(font, 'fontStyle', ''); + var fontSplit = font.split(' '); + + var i = 0; + + fontStyle = (fontSplit.length > 2) ? fontSplit[i++] : ''; + fontSize = fontSplit[i++] || '16px'; + fontFamily = fontSplit[i++] || 'Courier'; } - return this.update(true); + if (fontFamily !== this.fontFamily || fontSize !== this.fontSize || fontStyle !== this.fontStyle) + { + this.fontFamily = fontFamily; + this.fontSize = fontSize; + this.fontStyle = fontStyle; + + if (updateText) + { + this.update(true); + } + } + + return this.parent; }, /** @@ -532,9 +569,14 @@ var TextStyle = new Class({ */ setFontFamily: function (family) { - this.fontFamily = family; + if (this.fontFamily !== family) + { + this.fontFamily = family; - return this.update(true); + this.update(true); + } + + return this.parent; }, /** @@ -549,9 +591,14 @@ var TextStyle = new Class({ */ setFontStyle: function (style) { - this.fontStyle = style; + if (this.fontStyle !== style) + { + this.fontStyle = style; - return this.update(true); + this.update(true); + } + + return this.parent; }, /** @@ -571,9 +618,14 @@ var TextStyle = new Class({ size = size.toString() + 'px'; } - this.fontSize = size; + if (this.fontSize !== size) + { + this.fontSize = size; - return this.update(true); + this.update(true); + } + + return this.parent; }, /** @@ -675,6 +727,29 @@ var TextStyle = new Class({ return this.update(false); }, + /** + * Set the resolution used by the Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method. It allows for much clearer text on High DPI devices, + * at the cost of memory because it uses larger internal Canvas textures for the Text. + * + * Please use with caution, as the more high res Text you have, the more memory it uses up. + * + * @method Phaser.GameObjects.Text.TextStyle#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use. + * + * @return {Phaser.GameObjects.Text} The parent Text object. + */ + setResolution: function (value) + { + this.resolution = value; + + return this.update(false); + }, + /** * Set the stroke settings. * @@ -688,24 +763,31 @@ var TextStyle = new Class({ */ setStroke: function (color, thickness) { - if (color === undefined) + if (thickness === undefined) { thickness = this.strokeThickness; } + + if (color === undefined && this.strokeThickness !== 0) { // Reset the stroke to zero (disabling it) this.strokeThickness = 0; - } - else - { - if (thickness === undefined) { thickness = this.strokeThickness; } + this.update(true); + } + else if (this.stroke !== color || this.strokeThickness !== thickness) + { this.stroke = color; this.strokeThickness = thickness; + + this.update(true); } - return this.update(true); + return this.parent; }, /** * Set the shadow settings. + * + * Calling this method always re-measures the parent Text object, + * so only call it when you actually change the shadow settings. * * @method Phaser.GameObjects.Text.TextStyle#setShadow * @since 3.0.0 @@ -929,7 +1011,7 @@ var TextStyle = new Class({ * @method Phaser.GameObjects.Text.TextStyle#getTextMetrics * @since 3.0.0 * - * @return {TextMetrics} The text metrics. + * @return {BitmapTextMetrics} The text metrics. */ getTextMetrics: function () { diff --git a/src/gameobjects/text/static/Text.js b/src/gameobjects/text/static/Text.js index 1af5dcfee..023b2b18f 100644 --- a/src/gameobjects/text/static/Text.js +++ b/src/gameobjects/text/static/Text.js @@ -18,17 +18,39 @@ var TextStyle = require('../TextStyle'); /** * @classdesc - * [description] + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. * * @class Text * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.BlendMode * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Crop * @extends Phaser.GameObjects.Components.Depth * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.GetBounds @@ -55,6 +77,7 @@ var Text = new Class({ Components.Alpha, Components.BlendMode, Components.ComputedSize, + Components.Crop, Components.Depth, Components.Flip, Components.GetBounds, @@ -78,9 +101,18 @@ var Text = new Class({ GameObject.call(this, scene, 'Text'); + /** + * The renderer in use by this Text object. + * + * @name Phaser.GameObjects.Text#renderer + * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} + * @since 3.12.0 + */ + this.renderer = scene.sys.game.renderer; + this.setPosition(x, y); this.setOrigin(0, 0); - this.initPipeline('TextureTintPipeline'); + this.initPipeline(); /** * The canvas element that the text is rendered to. @@ -135,21 +167,12 @@ var Text = new Class({ /** * The text to display. * - * @name Phaser.GameObjects.Text#text + * @name Phaser.GameObjects.Text#_text * @type {string} - * @since 3.0.0 + * @private + * @since 3.12.0 */ - this.text = ''; - - /** - * The resolution of the text. - * - * @name Phaser.GameObjects.Text#resolution - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.resolution = 1; + this._text = ''; /** * Specify a padding value which is added to the line width and height when calculating the Text size. @@ -182,14 +205,18 @@ var Text = new Class({ this.height = 1; /** - * The Canvas Texture that the text is rendered to for WebGL rendering. + * The line spacing value. + * This value is added to the font height to calculate the overall line height. + * Only has an effect if this Text object contains multiple lines of text. + * + * If you update this property directly, instead of using the `setLineSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. * - * @name Phaser.GameObjects.Text#canvasTexture - * @type {HTMLCanvasElement} - * @default null - * @since 3.0.0 + * @name Phaser.GameObjects.Text#lineSpacing + * @type {number} + * @since 3.13.0 */ - this.canvasTexture = null; + this.lineSpacing = 0; /** * Whether the text or its settings have changed and need updating. @@ -201,6 +228,39 @@ var Text = new Class({ */ this.dirty = false; + // If resolution wasn't set, then we get it from the game config + if (this.style.resolution === 0) + { + this.style.resolution = scene.sys.game.config.resolution; + } + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.Text#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + // Create a Texture for this Text object + this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + + // Get the frame + this.frame = this.texture.get(); + + // Set the resolution + this.frame.source.resolution = this.style.resolution; + + if (this.renderer && this.renderer.gl) + { + // Clear the default 1x1 glTexture, as we override it later + this.renderer.deleteTexture(this.frame.source.glTexture); + + this.frame.source.glTexture = null; + } + this.initRTL(); if (style && style.padding) @@ -210,7 +270,7 @@ var Text = new Class({ if (style && style.lineSpacing) { - this._lineSpacing = style.lineSpacing; + this.lineSpacing = style.lineSpacing; } this.setText(text); @@ -219,7 +279,6 @@ var Text = new Class({ { scene.sys.game.renderer.onContextRestored(function () { - this.canvasTexture = null; this.dirty = true; }, this); } @@ -496,7 +555,7 @@ var Text = new Class({ */ getWrappedText: function (text) { - if (text === undefined) { text = this.text; } + if (text === undefined) { text = this._text; } this.style.syncFont(this.canvas, this.context); @@ -529,9 +588,9 @@ var Text = new Class({ value = value.join('\n'); } - if (value !== this.text) + if (value !== this._text) { - this.text = value.toString(); + this._text = value.toString(); this.updateText(); } @@ -662,18 +721,23 @@ var Text = new Class({ }, /** - * Set the text fill color. + * Set the fill style to be used by the Text object. + * + * This can be any valid CanvasRenderingContext2D fillStyle value, such as + * a color (in hex, rgb, rgba, hsl or named values), a gradient or a pattern. + * + * See the [MDN fillStyle docs](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle) for more details. * * @method Phaser.GameObjects.Text#setFill * @since 3.0.0 * - * @param {string} color - The text fill color. + * @param {(string|any)} color - The text fill style. Can be any valid CanvasRenderingContext `fillStyle` value. * * @return {Phaser.GameObjects.Text} This Text object. */ - setFill: function (color) + setFill: function (fillStyle) { - return this.style.setFill(color); + return this.style.setFill(fillStyle); }, /** @@ -857,6 +921,49 @@ var Text = new Class({ return this.style.setAlign(align); }, + /** + * Set the resolution used by this Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method, or by specifying it in the Text style configuration object. + * + * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger + * internal Canvas textures for the Text. + * + * Therefore, please use with caution, as the more high res Text you have, the more memory it uses. + * + * @method Phaser.GameObjects.Text#setResolution + * @since 3.12.0 + * + * @param {number} value - The resolution for this Text object to use. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setResolution: function (value) + { + return this.style.setResolution(value); + }, + + /** + * Sets the line spacing value. + * + * This value is _added_ to the height of the font when calculating the overall line height. + * This only has an effect if this Text object consists of multiple lines of text. + * + * @method Phaser.GameObjects.Text#setLineSpacing + * @since 3.13.0 + * + * @param {number} value - The amount to add to the font height to achieve the overall line height. + * + * @return {Phaser.GameObjects.Text} This Text object. + */ + setLineSpacing: function (value) + { + this.lineSpacing = value; + + return this.updateText(); + }, + /** * Set the text padding. * @@ -951,16 +1058,16 @@ var Text = new Class({ var canvas = this.canvas; var context = this.context; var style = this.style; - var resolution = this.resolution; + var resolution = style.resolution; var size = style.metrics; style.syncFont(canvas, context); - var outputText = this.text; + var outputText = this._text; if (style.wordWrapWidth || style.wordWrapCallback) { - outputText = this.runWordWrap(this.text); + outputText = this.runWordWrap(this._text); } // Split text into lines @@ -995,6 +1102,9 @@ var Text = new Class({ { canvas.width = w; canvas.height = h; + + this.frame.setSize(w, h); + style.syncFont(canvas, context); // Resizing resets the context } else @@ -1004,7 +1114,7 @@ var Text = new Class({ context.save(); - // context.scale(resolution, resolution); + context.scale(resolution, resolution); if (style.backgroundColor) { @@ -1069,6 +1179,13 @@ var Text = new Class({ context.restore(); + if (this.renderer.gl) + { + this.frame.source.glTexture = this.renderer.canvasToTexture(canvas, this.frame.source.glTexture, true); + + this.frame.glTexture = this.frame.source.glTexture; + } + this.dirty = true; return this; @@ -1087,6 +1204,27 @@ var Text = new Class({ return this.style.getTextMetrics(); }, + /** + * The text string being rendered by this Text Game Object. + * + * @name Phaser.GameObjects.Text#text + * @type {string} + * @since 3.0.0 + */ + text: { + + get: function () + { + return this._text; + }, + + set: function (value) + { + this.setText(value); + } + + }, + /** * Build a JSON representation of the Text object. * @@ -1103,9 +1241,8 @@ var Text = new Class({ var data = { autoRound: this.autoRound, - text: this.text, + text: this._text, style: this.style.toJSON(), - resolution: this.resolution, padding: { left: this.padding.left, right: this.padding.right, @@ -1134,6 +1271,8 @@ var Text = new Class({ } CanvasPool.remove(this.canvas); + + this.texture.destroy(); } }); diff --git a/src/gameobjects/text/static/TextCanvasRenderer.js b/src/gameobjects/text/static/TextCanvasRenderer.js index 1fb2b37a3..81dda0128 100644 --- a/src/gameobjects/text/static/TextCanvasRenderer.js +++ b/src/gameobjects/text/static/TextCanvasRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -23,75 +21,10 @@ var GameObject = require('../../GameObject'); */ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id)) || src.text === '') + if (src.text !== '') { - return; + renderer.batchSprite(src, src.frame, camera, parentMatrix); } - - var ctx = renderer.currentContext; - - // Alpha - - var alpha = camera.alpha * src.alpha; - - if (alpha === 0) - { - // Nothing to see, so abort early - return; - } - else if (renderer.currentAlpha !== alpha) - { - renderer.currentAlpha = alpha; - ctx.globalAlpha = alpha; - } - - // Blend Mode - - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Smoothing - - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var canvas = src.canvas; - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (camera.roundPixels) - { - tx |= 0; - ty |= 0; - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - - ctx.translate(canvas.width * (src.flipX ? 1 : 0), canvas.height * (src.flipY ? 1 : 0)); - - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - - ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, -src.displayOriginX, -src.displayOriginY, canvas.width, canvas.height); - - ctx.restore(); }; module.exports = TextCanvasRenderer; diff --git a/src/gameobjects/text/static/TextFactory.js b/src/gameobjects/text/static/TextFactory.js index 0e43d058d..2d9909ea7 100644 --- a/src/gameobjects/text/static/TextFactory.js +++ b/src/gameobjects/text/static/TextFactory.js @@ -9,6 +9,29 @@ var GameObjectFactory = require('../../GameObjectFactory'); /** * Creates a new Text Game Object and adds it to the Scene. + * + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. * * Note: This method will only be available if the Text Game Object has been built into Phaser. * diff --git a/src/gameobjects/text/static/TextWebGLRenderer.js b/src/gameobjects/text/static/TextWebGLRenderer.js index eaad5be48..a7fdafef8 100644 --- a/src/gameobjects/text/static/TextWebGLRenderer.js +++ b/src/gameobjects/text/static/TextWebGLRenderer.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../GameObject'); +var Utils = require('../../../renderer/webgl/Utils'); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -23,18 +23,37 @@ var GameObject = require('../../GameObject'); */ var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id)) || src.text === '') + if (src.text === '') { return; } - - if (src.dirty) - { - src.canvasTexture = renderer.canvasToTexture(src.canvas, src.canvasTexture); - src.dirty = false; - } - this.pipeline.batchText(this, camera, parentMatrix); + var frame = src.frame; + var width = frame.width; + var height = frame.height; + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + frame.glTexture, + width, height, + src.x, src.y, + width / src.style.resolution, height / src.style.resolution, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.displayOriginX, src.displayOriginY, + 0, 0, width, height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src._isTinted && src.tintFill), + 0, 0, + camera, + parentMatrix + ); }; module.exports = TextWebGLRenderer; diff --git a/src/gameobjects/tilesprite/TileSprite.js b/src/gameobjects/tilesprite/TileSprite.js index 2ae4734e2..2efc54e20 100644 --- a/src/gameobjects/tilesprite/TileSprite.js +++ b/src/gameobjects/tilesprite/TileSprite.js @@ -10,7 +10,12 @@ var Components = require('../components'); var CONST = require('../../const'); var GameObject = require('../GameObject'); var GetPowerOfTwo = require('../../math/pow2/GetPowerOfTwo'); +var Smoothing = require('../../display/canvas/Smoothing'); var TileSpriteRender = require('./TileSpriteRender'); +var Vector2 = require('../../math/Vector2'); + +// bitmask flag for GameObject.renderMask +var _FLAG = 8; // 1000 /** * @classdesc @@ -37,13 +42,14 @@ var TileSpriteRender = require('./TileSpriteRender'); * * @class TileSprite * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.BlendMode * @extends Phaser.GameObjects.Components.ComputedSize + * @extends Phaser.GameObjects.Components.Crop * @extends Phaser.GameObjects.Components.Depth * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.GetBounds @@ -52,7 +58,6 @@ var TileSpriteRender = require('./TileSpriteRender'); * @extends Phaser.GameObjects.Components.Pipeline * @extends Phaser.GameObjects.Components.ScaleMode * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Texture * @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible @@ -60,10 +65,10 @@ var TileSpriteRender = require('./TileSpriteRender'); * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param {number} x - The horizontal position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world. - * @param {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. - * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. + * @param {integer} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {integer} height - The height of the Game Object. If zero it will use the size of the texture frame. + * @param {string} textureKey - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param {(string|integer)} [frameKey] - An optional frame from the Texture this Game Object is rendering with. */ var TileSprite = new Class({ @@ -73,6 +78,7 @@ var TileSprite = new Class({ Components.Alpha, Components.BlendMode, Components.ComputedSize, + Components.Crop, Components.Depth, Components.Flip, Components.GetBounds, @@ -81,7 +87,6 @@ var TileSprite = new Class({ Components.Pipeline, Components.ScaleMode, Components.ScrollFactor, - Components.Texture, Components.Tint, Components.Transform, Components.Visible, @@ -90,51 +95,45 @@ var TileSprite = new Class({ initialize: - function TileSprite (scene, x, y, width, height, texture, frame) + function TileSprite (scene, x, y, width, height, textureKey, frameKey) { var renderer = scene.sys.game.renderer; GameObject.call(this, scene, 'TileSprite'); - /** - * The horizontal scroll position of the Tile Sprite. - * - * @name Phaser.GameObjects.TileSprite#tilePositionX - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.tilePositionX = 0; + var displayTexture = scene.sys.textures.get(textureKey); + var displayFrame = displayTexture.get(frameKey); + + if (!width || !height) + { + width = displayFrame.width; + height = displayFrame.height; + } + else + { + width = Math.floor(width); + height = Math.floor(height); + } /** - * The vertical scroll position of the Tile Sprite. + * Internal tile position vector. * - * @name Phaser.GameObjects.TileSprite#tilePositionY - * @type {number} - * @default 0 - * @since 3.0.0 + * @name Phaser.GameObjects.TileSprite#_tilePosition + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 */ - this.tilePositionY = 0; + this._tilePosition = new Vector2(); /** - * The horizontal scale of the Tile Sprite texture. + * Internal tile scale vector. * - * @name Phaser.GameObjects.TileSprite#tileScaleX - * @type {number} - * @default 1 - * @since 3.11.0 + * @name Phaser.GameObjects.TileSprite#_tileScale + * @type {Phaser.Math.Vector2} + * @private + * @since 3.12.0 */ - this.tileScaleX = 1; - - /** - * The vertical scale of the Tile Sprite texture. - * - * @name Phaser.GameObjects.TileSprite#tileScaleY - * @type {number} - * @default 1 - * @since 3.11.0 - */ - this.tileScaleY = 1; + this._tileScale = new Vector2(1, 1); /** * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. @@ -143,21 +142,10 @@ var TileSprite = new Class({ * * @name Phaser.GameObjects.TileSprite#dirty * @type {boolean} - * @default true + * @default false * @since 3.0.0 */ - this.dirty = true; - - /** - * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. - * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. - * - * @name Phaser.GameObjects.TileSprite#tileTexture - * @type {?(WebGLTexture|CanvasPattern)} - * @default null - * @since 3.0.0 - */ - this.tileTexture = null; + this.dirty = false; /** * The renderer in use by this Tile Sprite. @@ -168,69 +156,126 @@ var TileSprite = new Class({ */ this.renderer = renderer; - this.setTexture(texture, frame); - this.setPosition(x, y); - this.setSize(width, height); - this.setOriginFromFrame(); - this.initPipeline('TextureTintPipeline'); + /** + * The Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#canvas + * @type {?HTMLCanvasElement} + * @since 3.12.0 + */ + this.canvas = CanvasPool.create(this, width, height); /** - * The next power of two value from the width of the Frame. + * The Context of the Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + * + * @name Phaser.GameObjects.TileSprite#context + * @type {CanvasRenderingContext2D} + * @since 3.12.0 + */ + this.context = this.canvas.getContext('2d'); + + /** + * The Texture the TileSprite is using as its fill pattern. + * + * @name Phaser.GameObjects.TileSprite#displayTexture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @private + * @since 3.12.0 + */ + this.displayTexture = displayTexture; + + /** + * The Frame the TileSprite is using as its fill pattern. + * + * @name Phaser.GameObjects.TileSprite#displayFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.12.0 + */ + this.displayFrame = displayFrame; + + /** + * The internal crop data object, as used by `setCrop` and passed to the `Frame.setCropUVs` method. + * + * @name Phaser.GameObjects.TileSprite#_crop + * @type {object} + * @private + * @since 3.12.0 + */ + this._crop = this.resetCropObject(); + + /** + * The Texture this Game Object is using to render with. + * + * @name Phaser.GameObjects.TileSprite#texture + * @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture} + * @since 3.0.0 + */ + this.texture = scene.sys.textures.addCanvas(null, this.canvas, true); + + /** + * The Texture Frame this Game Object is using to render with. + * + * @name Phaser.GameObjects.TileSprite#frame + * @type {Phaser.Textures.Frame} + * @since 3.0.0 + */ + this.frame = this.texture.get(); + + /** + * The next power of two value from the width of the Fill Pattern frame. * * @name Phaser.GameObjects.TileSprite#potWidth * @type {integer} * @since 3.0.0 */ - this.potWidth = GetPowerOfTwo(this.frame.width); + this.potWidth = GetPowerOfTwo(displayFrame.width); /** - * The next power of two value from the height of the Frame. + * The next power of two value from the height of the Fill Pattern frame. * * @name Phaser.GameObjects.TileSprite#potHeight * @type {integer} * @since 3.0.0 */ - this.potHeight = GetPowerOfTwo(this.frame.height); + this.potHeight = GetPowerOfTwo(displayFrame.height); /** - * The Canvas Pattern used to repeat the TileSprite's texture. + * The Canvas that the TileSprites texture is rendered to. + * This is used to create a WebGL texture from. * - * @name Phaser.GameObjects.TileSprite#canvasPattern - * @type {?CanvasPattern} - * @default null - * @since 3.0.0 - */ - // this.canvasPattern = null; - - /** - * The Canvas that the TileSprite's texture is rendered to. - * - * @name Phaser.GameObjects.TileSprite#canvasBuffer + * @name Phaser.GameObjects.TileSprite#fillCanvas * @type {HTMLCanvasElement} - * @since 3.0.0 + * @since 3.12.0 */ - this.canvasBuffer = CanvasPool.create2D(this, this.potWidth, this.potHeight); + this.fillCanvas = CanvasPool.create2D(this, this.potWidth, this.potHeight); /** - * The Canvas Context used to render the TileSprite's texture. + * The Canvas Context used to render the TileSprites texture. * - * @name Phaser.GameObjects.TileSprite#canvasBufferCtx + * @name Phaser.GameObjects.TileSprite#fillContext * @type {CanvasRenderingContext2D} - * @since 3.0.0 + * @since 3.12.0 */ - this.canvasBufferCtx = this.canvasBuffer.getContext('2d'); + this.fillContext = this.fillCanvas.getContext('2d'); /** - * The previous Texture Frame being used. + * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. * - * @name Phaser.GameObjects.Components.Texture#oldFrame - * @type {Phaser.Textures.Frame} - * @private - * @since 3.0.0 + * @name Phaser.GameObjects.TileSprite#fillPattern + * @type {?(WebGLTexture|CanvasPattern)} + * @since 3.12.0 */ - this.oldFrame = null; + this.fillPattern = null; - this.updateTileTexture(); + this.setPosition(x, y); + this.setSize(width, height); + this.setFrame(frameKey); + this.setOriginFromFrame(); + this.initPipeline(); if (scene.sys.game.config.renderType === CONST.WEBGL) { @@ -238,13 +283,67 @@ var TileSprite = new Class({ { var gl = renderer.gl; - this.tileTexture = null; this.dirty = true; - this.tileTexture = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.canvasBuffer, this.potWidth, this.potHeight); + this.fillPattern = null; + this.fillPattern = renderer.createTexture2D(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.fillCanvas, this.potWidth, this.potHeight); }, this); } }, + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * @method Phaser.GameObjects.TileSprite#setTexture + * @since 3.0.0 + * + * @param {string} key - The key of the texture to be used, as stored in the Texture Manager. + * @param {(string|integer)} [frame] - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setTexture: function (key, frame) + { + this.displayTexture = this.scene.sys.textures.get(key); + + return this.setFrame(frame); + }, + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * @method Phaser.GameObjects.TileSprite#setFrame + * @since 3.0.0 + * + * @param {(string|integer)} frame - The name or index of the frame within the Texture. + * + * @return {this} This Game Object instance. + */ + setFrame: function (frame) + { + this.displayFrame = this.displayTexture.get(frame); + + if (!this.displayFrame.cutWidth || !this.displayFrame.cutHeight) + { + this.renderFlags &= ~_FLAG; + } + else + { + this.renderFlags |= _FLAG; + } + + this.dirty = true; + + this.updateTileTexture(); + + return this; + }, + /** * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. * @@ -254,7 +353,7 @@ var TileSprite = new Class({ * @param {number} [x] - The x position of this sprite's tiling texture. * @param {number} [y] - The y position of this sprite's tiling texture. * - * @return {Phaser.GameObjects.TileSprite} This Tile Sprite instance. + * @return {this} This Tile Sprite instance. */ setTilePosition: function (x, y) { @@ -271,25 +370,52 @@ var TileSprite = new Class({ return this; }, + /** + * Sets {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. + * + * @method Phaser.GameObjects.TileSprite#setTileScale + * @since 3.12.0 + * + * @param {number} [x] - The horizontal scale of the tiling texture. + * @param {number} [y] - The vertical scale of the tiling texture. + * + * @return {this} This Tile Sprite instance. + */ + setTileScale: function (x, y) + { + if (x !== undefined) + { + this.tileScaleX = x; + } + + if (y !== undefined) + { + this.tileScaleY = y; + } + + return this; + }, + /** * Render the tile texture if it is dirty, or if the frame has changed. * * @method Phaser.GameObjects.TileSprite#updateTileTexture + * @private * @since 3.0.0 */ updateTileTexture: function () { - var frame = this.frame; - - if (!this.dirty && this.oldFrame === frame) + if (!this.dirty) { return; } - this.oldFrame = frame; + // Draw the displayTexture to our fillCanvas - var ctx = this.canvasBufferCtx; - var canvas = this.canvasBuffer; + var frame = this.displayFrame; + + var ctx = this.fillContext; + var canvas = this.fillCanvas; var fw = this.potWidth; var fh = this.potHeight; @@ -300,7 +426,7 @@ var TileSprite = new Class({ fh = frame.cutHeight; } - ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.clearRect(0, 0, fw, fh); canvas.width = fw; canvas.height = fh; @@ -313,7 +439,74 @@ var TileSprite = new Class({ fw, fh ); - this.tileTexture = (this.renderer.gl) ? this.renderer.canvasToTexture(canvas, this.tileTexture) : ctx.createPattern(canvas, 'repeat'); + if (this.renderer.gl) + { + this.fillPattern = this.renderer.canvasToTexture(canvas, this.fillPattern); + } + else + { + this.fillPattern = ctx.createPattern(canvas, 'repeat'); + } + + this.updateCanvas(); + + this.dirty = false; + }, + + /** + * Draw the fill pattern to the internal canvas. + * + * @method Phaser.GameObjects.TileSprite#updateCanvas + * @private + * @since 3.12.0 + */ + updateCanvas: function () + { + var canvas = this.canvas; + + if (canvas.width !== this.width || canvas.height !== this.height) + { + canvas.width = this.width; + canvas.height = this.height; + + this.frame.setSize(this.width, this.height); + this.updateDisplayOrigin(); + + this.dirty = true; + } + + if (!this.dirty || this.renderer && this.renderer.gl) + { + this.dirty = false; + return; + } + + var ctx = this.context; + + if (!this.scene.sys.game.config.antialias) + { + Smoothing.disable(ctx); + } + + var scaleX = this._tileScale.x; + var scaleY = this._tileScale.y; + + var positionX = this._tilePosition.x; + var positionY = this._tilePosition.y; + + ctx.clearRect(0, 0, this.width, this.height); + + ctx.save(); + + ctx.scale(scaleX, scaleY); + + ctx.translate(-positionX, -positionY); + + ctx.fillStyle = this.fillPattern; + + ctx.fillRect(positionX, positionY, this.width / scaleX, this.height / scaleY); + + ctx.restore(); this.dirty = false; }, @@ -329,16 +522,114 @@ var TileSprite = new Class({ { if (this.renderer && this.renderer.gl) { - this.renderer.deleteTexture(this.tileTexture); + this.renderer.deleteTexture(this.fillPattern); } - CanvasPool.remove(this.canvasBuffer); + CanvasPool.remove(this.canvas); + CanvasPool.remove(this.fillCanvas); - this.tileTexture = null; - this.canvasBufferCtx = null; - this.canvasBuffer = null; + this.fillPattern = null; + this.fillContext = null; + this.fillCanvas = null; + + this.displayTexture = null; + this.displayFrame = null; + + this.texture.destroy(); this.renderer = null; + }, + + /** + * The horizontal scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionX + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionX: { + + get: function () + { + return this._tilePosition.x; + }, + + set: function (value) + { + this._tilePosition.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scroll position of the Tile Sprite. + * + * @name Phaser.GameObjects.TileSprite#tilePositionY + * @type {number} + * @default 0 + * @since 3.0.0 + */ + tilePositionY: { + + get: function () + { + return this._tilePosition.y; + }, + + set: function (value) + { + this._tilePosition.y = value; + this.dirty = true; + } + + }, + + /** + * The horizontal scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleX + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleX: { + + get: function () + { + return this._tileScale.x; + }, + + set: function (value) + { + this._tileScale.x = value; + this.dirty = true; + } + + }, + + /** + * The vertical scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleY + * @type {number} + * @default 1 + * @since 3.11.0 + */ + tileScaleY: { + + get: function () + { + return this._tileScale.y; + }, + + set: function (value) + { + this._tileScale.y = value; + this.dirty = true; + } + } }); diff --git a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js index c744a5504..f412d9b99 100644 --- a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -23,108 +21,9 @@ var GameObject = require('../GameObject'); */ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) - { - return; - } + src.updateCanvas(); - var ctx = renderer.currentContext; - var frame = src.frame; - - src.updateTileTexture(); - - // Alpha - - var alpha = camera.alpha * src.alpha; - - if (alpha === 0) - { - // Nothing to see, so abort early - return; - } - else if (renderer.currentAlpha !== alpha) - { - renderer.currentAlpha = alpha; - ctx.globalAlpha = alpha; - } - - // Blend Mode - - if (renderer.currentBlendMode !== src.blendMode) - { - renderer.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; - } - - // Smoothing - - if (renderer.currentScaleMode !== src.scaleMode) - { - renderer.currentScaleMode = src.scaleMode; - } - - var dx = frame.x - (src.originX * src.width); - var dy = frame.y - (src.originY * src.height); - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - var fx = 1; - var fy = 1; - - // Flipping - - if (src.flipX) - { - fx = -1; - dx += src.width; - } - - if (src.flipY) - { - fy = -1; - dy += src.height; - } - - if (camera.roundPixels) - { - dx |= 0; - dy |= 0; - tx |= 0; - ty |= 0; - } - - ctx.save(); - - if (parentMatrix !== undefined) - { - var matrix = parentMatrix.matrix; - - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(dx, dy); - - ctx.translate(tx, ty); - - // Flip - ctx.scale(fx, fy); - - // Rotate and scale around center - ctx.translate((src.originX * src.width), (src.originY * src.height)); - ctx.rotate(fx * fy * src.rotation); - ctx.scale(this.scaleX, this.scaleY); - ctx.translate(-(src.originX * src.width), -(src.originY * src.height)); - - // Draw - - ctx.scale(src.tileScaleX, src.tileScaleY); - - ctx.translate(-this.tilePositionX, -this.tilePositionY); - ctx.fillStyle = src.tileTexture; - ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width / src.tileScaleX, src.height / src.tileScaleY); - - ctx.restore(); + renderer.batchSprite(src, src.frame, camera, parentMatrix); }; module.exports = TileSpriteCanvasRenderer; diff --git a/src/gameobjects/tilesprite/TileSpriteCreator.js b/src/gameobjects/tilesprite/TileSpriteCreator.js index e122c2928..cb29ef0d5 100644 --- a/src/gameobjects/tilesprite/TileSpriteCreator.js +++ b/src/gameobjects/tilesprite/TileSpriteCreator.js @@ -15,8 +15,8 @@ var TileSprite = require('./TileSprite'); * * @property {number} [x=0] - The x coordinate of the Tile Sprite. * @property {number} [y=0] - The y coordinate of the Tile Sprite. - * @property {number} [width=512] - The width of the Tile Sprite. - * @property {number} [height=512] - The height of the Tile Sprite. + * @property {integer} [width=512] - The width of the Tile Sprite. If zero it will use the size of the texture frame. + * @property {integer} [height=512] - The height of the Tile Sprite. If zero it will use the size of the texture frame. * @property {string} [key=''] - The key of the Texture this Tile Sprite will use to render with, as stored in the Texture Manager. * @property {string} [frame=''] - An optional frame from the Texture this Tile Sprite is rendering with. */ diff --git a/src/gameobjects/tilesprite/TileSpriteFactory.js b/src/gameobjects/tilesprite/TileSpriteFactory.js index 7ef38402b..4b4795792 100644 --- a/src/gameobjects/tilesprite/TileSpriteFactory.js +++ b/src/gameobjects/tilesprite/TileSpriteFactory.js @@ -17,8 +17,8 @@ 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 {number} width - The width of the Game Object. - * @param {number} height - The height of the Game Object. + * @param {integer} width - The width of the Game Object. If zero it will use the size of the texture frame. + * @param {integer} height - The height of the Game Object. If zero it will use the size of the texture frame. * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. * diff --git a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js index a73ed4f51..171a055c1 100644 --- a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js @@ -4,7 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../GameObject'); var Utils = require('../../renderer/webgl/Utils'); /** @@ -24,19 +23,14 @@ var Utils = require('../../renderer/webgl/Utils'); */ var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) - { - return; - } - - src.updateTileTexture(); + src.updateCanvas(); var getTint = Utils.getTintAppendFloatAlpha; this.pipeline.batchTexture( src, - src.tileTexture, - src.frame.width * src.tileScaleX, src.frame.height * src.tileScaleY, + src.fillPattern, + src.displayFrame.width * src.tileScaleX, src.displayFrame.height * src.tileScaleY, src.x, src.y, src.width, src.height, src.scaleX, src.scaleY, @@ -49,8 +43,9 @@ var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, getTint(src._tintTR, camera.alpha * src._alphaTR), getTint(src._tintBL, camera.alpha * src._alphaBL), getTint(src._tintBR, camera.alpha * src._alphaBR), - (src.tilePositionX % src.frame.width) / src.frame.width, - (src.tilePositionY % src.frame.height) / src.frame.height, + (src._isTinted && src.tintFill), + (src.tilePositionX % src.displayFrame.width) / src.displayFrame.width, + (src.tilePositionY % src.displayFrame.height) / src.displayFrame.height, camera, parentMatrix ); diff --git a/src/gameobjects/zone/Zone.js b/src/gameobjects/zone/Zone.js index b6870640a..674b3e600 100644 --- a/src/gameobjects/zone/Zone.js +++ b/src/gameobjects/zone/Zone.js @@ -29,7 +29,7 @@ var RectangleContains = require('../../geom/rectangle/Contains'); * * @class Zone * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.GameObjects + * @memberof Phaser.GameObjects * @constructor * @since 3.0.0 * @@ -100,6 +100,8 @@ var Zone = new Class({ * @since 3.0.0 */ this.blendMode = BlendModes.NORMAL; + + this.updateDisplayOrigin(); }, /** @@ -224,10 +226,7 @@ var Zone = new Class({ */ setRectangleDropZone: function (width, height) { - var x = -(width / 2); - var y = -(height / 2); - - return this.setDropZone(new Rectangle(x, y, width, height), RectangleContains); + return this.setDropZone(new Rectangle(0, 0, width, height), RectangleContains); }, /** @@ -247,8 +246,7 @@ var Zone = new Class({ { this.setRectangleDropZone(this.width, this.height); } - else - if (!this.input) + else if (!this.input) { this.setInteractive(shape, callback, true); } @@ -256,6 +254,18 @@ var Zone = new Class({ return this; }, + /** + * A NOOP method so you can pass a Zone to a Container. + * Calling this method will do nothing. It is intentionally empty. + * + * @method Phaser.GameObjects.Zone#setAlpha + * @private + * @since 3.11.0 + */ + setAlpha: function () + { + }, + /** * A Zone does not render. * diff --git a/src/geom/circle/Circle.js b/src/geom/circle/Circle.js index 6c147dc35..6e3ddb503 100644 --- a/src/geom/circle/Circle.js +++ b/src/geom/circle/Circle.js @@ -19,7 +19,7 @@ var Random = require('./Random'); * To render a Circle you should look at the capabilities of the Graphics class. * * @class Circle - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * diff --git a/src/geom/ellipse/Ellipse.js b/src/geom/ellipse/Ellipse.js index 5dd277b94..558fd53d4 100644 --- a/src/geom/ellipse/Ellipse.js +++ b/src/geom/ellipse/Ellipse.js @@ -19,7 +19,7 @@ var Random = require('./Random'); * To render an Ellipse you should look at the capabilities of the Graphics class. * * @class Ellipse - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * diff --git a/src/geom/intersects/CircleToCircle.js b/src/geom/intersects/CircleToCircle.js index 5e73c3d74..50490db71 100644 --- a/src/geom/intersects/CircleToCircle.js +++ b/src/geom/intersects/CircleToCircle.js @@ -7,15 +7,15 @@ var DistanceBetween = require('../../math/distance/DistanceBetween'); /** - * [description] + * Checks if two Circles intersect. * * @function Phaser.Geom.Intersects.CircleToCircle * @since 3.0.0 * - * @param {Phaser.Geom.Circle} circleA - [description] - * @param {Phaser.Geom.Circle} circleB - [description] + * @param {Phaser.Geom.Circle} circleA - The first Circle to check for intersection. + * @param {Phaser.Geom.Circle} circleB - The second Circle to check for intersection. * - * @return {boolean} [description] + * @return {boolean} `true` if the two Circles intersect, otherwise `false`. */ var CircleToCircle = function (circleA, circleB) { diff --git a/src/geom/intersects/CircleToRectangle.js b/src/geom/intersects/CircleToRectangle.js index 8510d5893..bc734ab57 100644 --- a/src/geom/intersects/CircleToRectangle.js +++ b/src/geom/intersects/CircleToRectangle.js @@ -5,15 +5,15 @@ */ /** - * [description] + * Checks for intersection between a circle and a rectangle. * * @function Phaser.Geom.Intersects.CircleToRectangle * @since 3.0.0 * - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Circle} circle - The circle to be checked. + * @param {Phaser.Geom.Rectangle} rect - The rectangle to be checked. * - * @return {boolean} [description] + * @return {boolean} `true` if the two objects intersect, otherwise `false`. */ var CircleToRectangle = function (circle, rect) { diff --git a/src/geom/intersects/GetRectangleIntersection.js b/src/geom/intersects/GetRectangleIntersection.js index 854e042cf..d4a001d45 100644 --- a/src/geom/intersects/GetRectangleIntersection.js +++ b/src/geom/intersects/GetRectangleIntersection.js @@ -8,18 +8,22 @@ var Rectangle = require('../rectangle/Rectangle'); var RectangleToRectangle = require('./RectangleToRectangle'); /** - * [description] + * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. + * + * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it wil be empty Rectangle (all values set to zero). + * + * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersetion, it will be returned without any change. * * @function Phaser.Geom.Intersects.GetRectangleIntersection * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [output,$return] * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [output] - [description] + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle object. + * @param {Phaser.Geom.Rectangle} [output] - Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} A rectangle object with intersection data. */ var GetRectangleIntersection = function (rectA, rectB, output) { diff --git a/src/geom/intersects/LineToCircle.js b/src/geom/intersects/LineToCircle.js index 1aecbb25f..de0425ddd 100644 --- a/src/geom/intersects/LineToCircle.js +++ b/src/geom/intersects/LineToCircle.js @@ -4,25 +4,24 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Based on code by Matt DesLauriers -// https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md - var Contains = require('../circle/Contains'); var Point = require('../point/Point'); var tmp = new Point(); /** - * [description] + * Checks for intersection between the line segment and circle. + * + * Based on code by [Matt DesLauriers](https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md). * * @function Phaser.Geom.Intersects.LineToCircle * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {Phaser.Geom.Circle} circle - [description] - * @param {Phaser.Geom.Point} [nearest] - [description] + * @param {Phaser.Geom.Line} line - The line segment to check. + * @param {Phaser.Geom.Circle} circle - The circle to check against the line. + * @param {(Phaser.Geom.Point|any)} [nearest] - An optional Point-like object. If given the closest point on the Line where the circle intersects will be stored in this object. * - * @return {boolean} [description] + * @return {boolean} `true` if the two objects intersect, otherwise `false`. */ var LineToCircle = function (line, circle, nearest) { diff --git a/src/geom/intersects/LineToLine.js b/src/geom/intersects/LineToLine.js index e0d250926..1b00b05ad 100644 --- a/src/geom/intersects/LineToLine.js +++ b/src/geom/intersects/LineToLine.js @@ -10,16 +10,16 @@ var Point = require('../point/Point'); // See http:'local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ /** - * [description] + * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. * * @function Phaser.Geom.Intersects.LineToLine * @since 3.0.0 * - * @param {Phaser.Geom.Line} line1 - [description] - * @param {Phaser.Geom.Line} line2 - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {Phaser.Geom.Line} line1 - The first Line to check. + * @param {Phaser.Geom.Line} line2 - The second Line to check. + * @param {Phaser.Geom.Point} [out] - A Point in which to optionally store the point of intersection. * - * @return {boolean} [description] + * @return {boolean} `true` if the two Lines intersect, and the `out` object will be populated, if given. Otherwise, `false`. */ var LineToLine = function (line1, line2, out) { diff --git a/src/geom/intersects/LineToRectangle.js b/src/geom/intersects/LineToRectangle.js index b56d2c30e..f28b420e6 100644 --- a/src/geom/intersects/LineToRectangle.js +++ b/src/geom/intersects/LineToRectangle.js @@ -18,10 +18,10 @@ * @function Phaser.Geom.Intersects.LineToRectangle * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] - * @param {(Phaser.Geom.Rectangle|object)} rect - [description] + * @param {Phaser.Geom.Line} line - The Line to check for intersection. + * @param {(Phaser.Geom.Rectangle|object)} rect - The Rectangle to check for intersection. * - * @return {boolean} [description] + * @return {boolean} `true` if the Line and the Rectangle intersect, `false` otherwise. */ var LineToRectangle = function (line, rect) { diff --git a/src/geom/intersects/PointToLine.js b/src/geom/intersects/PointToLine.js index b29357c0f..c29a6ed11 100644 --- a/src/geom/intersects/PointToLine.js +++ b/src/geom/intersects/PointToLine.js @@ -1,23 +1,64 @@ /** * @author Richard Davey + * @author Florian Mertens * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * [description] + * Checks if the a Point falls between the two end-points of a Line, based on the given line thickness. + * + * Assumes that the line end points are circular, not square. * * @function Phaser.Geom.Intersects.PointToLine * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Line} line - [description] + * @param {(Phaser.Geom.Point|any)} point - The point, or point-like object to check. + * @param {Phaser.Geom.Line} line - The line segment to test for intersection on. + * @param {number} [lineThickness=1] - The line thickness. Assumes that the line end points are circular. * - * @return {boolean} [description] + * @return {boolean} `true` if the Point falls on the Line, otherwise `false`. */ -var PointToLine = function (point, line) +var PointToLine = function (point, line, lineThickness) { - return ((point.x - line.x1) * (line.y2 - line.y1) === (line.x2 - line.x1) * (point.y - line.y1)); + if (lineThickness === undefined) { lineThickness = 1; } + + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var px = point.x; + var py = point.y; + + var L2 = (((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))); + + if (L2 === 0) + { + return false; + } + + var r = (((px - x1) * (x2 - x1)) + ((py - y1) * (y2 - y1))) / L2; + + // Assume line thickness is circular + if (r < 0) + { + // Outside line1 + return (Math.sqrt(((x1 - px) * (x1 - px)) + ((y1 - py) * (y1 - py))) <= lineThickness); + } + else if ((r >= 0) && (r <= 1)) + { + // On the line segment + var s = (((y1 - py) * (x2 - x1)) - ((x1 - px) * (y2 - y1))) / L2; + + return (Math.abs(s) * Math.sqrt(L2) <= lineThickness); + } + else + { + // Outside line2 + return (Math.sqrt(((x2 - px) * (x2 - px)) + ((y2 - py) * (y2 - py))) <= lineThickness); + } }; module.exports = PointToLine; diff --git a/src/geom/intersects/PointToLineSegment.js b/src/geom/intersects/PointToLineSegment.js index 2472442e8..70c5d1030 100644 --- a/src/geom/intersects/PointToLineSegment.js +++ b/src/geom/intersects/PointToLineSegment.js @@ -7,15 +7,15 @@ var PointToLine = require('./PointToLine'); /** - * [description] + * Checks if a Point is located on the given line segment. * * @function Phaser.Geom.Intersects.PointToLineSegment * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Point} point - The Point to check for intersection. + * @param {Phaser.Geom.Line} line - The line segment to check for intersection. * - * @return {boolean} [description] + * @return {boolean} `true` if the Point is on the given line segment, otherwise `false`. */ var PointToLineSegment = function (point, line) { diff --git a/src/geom/intersects/RectangleToRectangle.js b/src/geom/intersects/RectangleToRectangle.js index f10c8b4cc..b9b0d5422 100644 --- a/src/geom/intersects/RectangleToRectangle.js +++ b/src/geom/intersects/RectangleToRectangle.js @@ -5,15 +5,17 @@ */ /** - * [description] + * Checks if two Rectangles intersect. + * + * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. As such, the two Rectangles are considered "solid". A Rectangle with no width or no height will never intersect another Rectangle. * * @function Phaser.Geom.Intersects.RectangleToRectangle * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to check for intersection. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to check for intersection. * - * @return {boolean} [description] + * @return {boolean} `true` if the two Rectangles intersect, otherwise `false`. */ var RectangleToRectangle = function (rectA, rectB) { diff --git a/src/geom/intersects/RectangleToTriangle.js b/src/geom/intersects/RectangleToTriangle.js index b2670393e..45833b43c 100644 --- a/src/geom/intersects/RectangleToTriangle.js +++ b/src/geom/intersects/RectangleToTriangle.js @@ -10,15 +10,15 @@ var ContainsArray = require('../triangle/ContainsArray'); var Decompose = require('../rectangle/Decompose'); /** - * [description] + * Checks for intersection between Rectangle shape and Triangle shape. * * @function Phaser.Geom.Intersects.RectangleToTriangle * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Rectangle} rect - Rectangle object to test. + * @param {Phaser.Geom.Triangle} triangle - Triangle object to test. * - * @return {boolean} [description] + * @return {boolean} A value of `true` if objects intersect; otherwise `false`. */ var RectangleToTriangle = function (rect, triangle) { diff --git a/src/geom/intersects/RectangleToValues.js b/src/geom/intersects/RectangleToValues.js index 7409f15d5..75b592fb1 100644 --- a/src/geom/intersects/RectangleToValues.js +++ b/src/geom/intersects/RectangleToValues.js @@ -5,19 +5,19 @@ */ /** - * [description] + * Check if rectangle intersects with values. * * @function Phaser.Geom.Intersects.RectangleToValues * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} left - [description] - * @param {number} right - [description] - * @param {number} top - [description] - * @param {number} bottom - [description] - * @param {number} [tolerance=0] - [description] + * @param {Phaser.Geom.Rectangle} rect - The rectangle object + * @param {number} left - The x coordinate of the left of the Rectangle. + * @param {number} right - The x coordinate of the right of the Rectangle. + * @param {number} top - The y coordinate of the top of the Rectangle. + * @param {number} bottom - The y coordinate of the bottom of the Rectangle. + * @param {number} [tolerance=0] - Tolerance allowed in the calculation, expressed in pixels. * - * @return {boolean} [description] + * @return {boolean} Returns true if there is an intersection. */ var RectangleToValues = function (rect, left, right, top, bottom, tolerance) { diff --git a/src/geom/intersects/TriangleToCircle.js b/src/geom/intersects/TriangleToCircle.js index ee6de1513..76a811a54 100644 --- a/src/geom/intersects/TriangleToCircle.js +++ b/src/geom/intersects/TriangleToCircle.js @@ -8,15 +8,17 @@ var LineToCircle = require('./LineToCircle'); var Contains = require('../triangle/Contains'); /** - * [description] + * Checks if a Triangle and a Circle intersect. + * + * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. * * @function Phaser.Geom.Intersects.TriangleToCircle * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} circle - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check for intersection. + * @param {Phaser.Geom.Circle} circle - The Circle to check for intersection. * - * @return {boolean} [description] + * @return {boolean} `true` if the Triangle and the `Circle` intersect, otherwise `false`. */ var TriangleToCircle = function (triangle, circle) { diff --git a/src/geom/intersects/TriangleToLine.js b/src/geom/intersects/TriangleToLine.js index 9478ab5a9..e5c649bb0 100644 --- a/src/geom/intersects/TriangleToLine.js +++ b/src/geom/intersects/TriangleToLine.js @@ -8,15 +8,17 @@ var Contains = require('../triangle/Contains'); var LineToLine = require('./LineToLine'); /** - * [description] + * Checks if a Triangle and a Line intersect. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". * * @function Phaser.Geom.Intersects.TriangleToLine * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check with. + * @param {Phaser.Geom.Line} line - The Line to check with. * - * @return {boolean} [description] + * @return {boolean} `true` if the Triangle and the Line intersect, otherwise `false`. */ var TriangleToLine = function (triangle, line) { diff --git a/src/geom/intersects/TriangleToTriangle.js b/src/geom/intersects/TriangleToTriangle.js index 0b2f69ba2..f4846c475 100644 --- a/src/geom/intersects/TriangleToTriangle.js +++ b/src/geom/intersects/TriangleToTriangle.js @@ -9,15 +9,17 @@ var Decompose = require('../triangle/Decompose'); var LineToLine = require('./LineToLine'); /** - * [description] + * Checks if two Triangles intersect. + * + * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". * * @function Phaser.Geom.Intersects.TriangleToTriangle * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangleA - [description] - * @param {Phaser.Geom.Triangle} triangleB - [description] + * @param {Phaser.Geom.Triangle} triangleA - The first Triangle to check for intersection. + * @param {Phaser.Geom.Triangle} triangleB - The second Triangle to check for intersection. * - * @return {boolean} [description] + * @return {boolean} `true` if the Triangles intersect, otherwise `false`. */ var TriangleToTriangle = function (triangleA, triangleB) { diff --git a/src/geom/line/GetNearestPoint.js b/src/geom/line/GetNearestPoint.js new file mode 100644 index 000000000..a42c48048 --- /dev/null +++ b/src/geom/line/GetNearestPoint.js @@ -0,0 +1,49 @@ +/** + * @author Richard Davey + * @author Florian Mertens + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Point = require('../point/Point'); + +/** + * Get the nearest point on a line perpendicular to the given point. + * + * @function Phaser.Geom.Line.GetNearestPoint + * @since 3.16.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to get the nearest point on. + * @param {(Phaser.Geom.Point|object)} point - The point to get the nearest point to. + * @param {(Phaser.Geom.Point|object)} [out] - An optional point, or point-like object, to store the coordinates of the nearest point on the line. + * + * @return {(Phaser.Geom.Point|object)} The nearest point on the line. + */ +var GetNearestPoint = function (line, point, out) +{ + if (out === undefined) { out = new Point(); } + + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var L2 = (((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))); + + if (L2 === 0) + { + return out; + } + + var r = (((point.x - x1) * (x2 - x1)) + ((point.y - y1) * (y2 - y1))) / L2; + + out.x = x1 + (r * (x2 - x1)); + out.y = y1 + (r * (y2 - y1)); + + return out; +}; + +module.exports = GetNearestPoint; diff --git a/src/geom/line/GetShortestDistance.js b/src/geom/line/GetShortestDistance.js new file mode 100644 index 000000000..74b9c2adf --- /dev/null +++ b/src/geom/line/GetShortestDistance.js @@ -0,0 +1,41 @@ +/** + * @author Richard Davey + * @author Florian Mertens + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Get the shortest distance from a Line to the given Point. + * + * @function Phaser.Geom.Line.GetShortestDistance + * @since 3.16.0 + * + * @generic {Phaser.Geom.Point} O - [out,$return] + * + * @param {Phaser.Geom.Line} line - The line to get the distance from. + * @param {(Phaser.Geom.Point|object)} point - The point to get the shortest distance to. + * + * @return {number} The shortest distance from the line to the point. + */ +var GetShortestDistance = function (line, point) +{ + var x1 = line.x1; + var y1 = line.y1; + + var x2 = line.x2; + var y2 = line.y2; + + var L2 = (((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1))); + + if (L2 === 0) + { + return false; + } + + var s = (((y1 - point.y) * (x2 - x1)) - ((x1 - point.x) * (y2 - y1))) / L2; + + return Math.abs(s) * Math.sqrt(L2); +}; + +module.exports = GetShortestDistance; diff --git a/src/geom/line/Line.js b/src/geom/line/Line.js index fd0038254..16d20635d 100644 --- a/src/geom/line/Line.js +++ b/src/geom/line/Line.js @@ -15,7 +15,7 @@ var Vector2 = require('../../math/Vector2'); * Defines a Line segment, a part of a line between two endpoints. * * @class Line - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * diff --git a/src/geom/line/NormalX.js b/src/geom/line/NormalX.js index 07f3b8e23..58d97dc04 100644 --- a/src/geom/line/NormalX.js +++ b/src/geom/line/NormalX.js @@ -13,7 +13,7 @@ var Angle = require('./Angle'); * @function Phaser.Geom.Line.NormalX * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The Line object to get the normal value from. * * @return {number} [description] */ diff --git a/src/geom/line/NormalY.js b/src/geom/line/NormalY.js index 80a173750..ae7960ce5 100644 --- a/src/geom/line/NormalY.js +++ b/src/geom/line/NormalY.js @@ -8,14 +8,15 @@ var MATH_CONST = require('../../math/const'); var Angle = require('./Angle'); /** - * [description] + * The Y value of the normal of the given line. + * The normal of a line is a vector that points perpendicular from it. * * @function Phaser.Geom.Line.NormalY * @since 3.0.0 * - * @param {Phaser.Geom.Line} line - [description] + * @param {Phaser.Geom.Line} line - The line to calculate the normal of. * - * @return {number} [description] + * @return {number} The Y value of the normal of the Line. */ var NormalY = function (line) { diff --git a/src/geom/line/index.js b/src/geom/line/index.js index d0b34c470..9097da263 100644 --- a/src/geom/line/index.js +++ b/src/geom/line/index.js @@ -13,9 +13,11 @@ Line.Clone = require('./Clone'); Line.CopyFrom = require('./CopyFrom'); Line.Equals = require('./Equals'); Line.GetMidPoint = require('./GetMidPoint'); +Line.GetNearestPoint = require('./GetNearestPoint'); Line.GetNormal = require('./GetNormal'); Line.GetPoint = require('./GetPoint'); Line.GetPoints = require('./GetPoints'); +Line.GetShortestDistance = require('./GetShortestDistance'); Line.Height = require('./Height'); Line.Length = require('./Length'); Line.NormalAngle = require('./NormalAngle'); diff --git a/src/geom/point/Equals.js b/src/geom/point/Equals.js index dbfa80803..31fc7a568 100644 --- a/src/geom/point/Equals.js +++ b/src/geom/point/Equals.js @@ -5,15 +5,15 @@ */ /** - * [description] + * A comparison of two `Point` objects to see if they are equal. * * @function Phaser.Geom.Point.Equals * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} toCompare - [description] + * @param {Phaser.Geom.Point} point - The original `Point` to compare against. + * @param {Phaser.Geom.Point} toCompare - The second `Point` to compare. * - * @return {boolean} [description] + * @return {boolean} Returns true if the both `Point` objects are equal. */ var Equals = function (point, toCompare) { diff --git a/src/geom/point/GetCentroid.js b/src/geom/point/GetCentroid.js index aa395579e..6c7c3e1eb 100644 --- a/src/geom/point/GetCentroid.js +++ b/src/geom/point/GetCentroid.js @@ -7,7 +7,8 @@ var Point = require('./Point'); /** - * [description] + * Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure). + * Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin. * * @function Phaser.Geom.Point.GetCentroid * @since 3.0.0 diff --git a/src/geom/point/GetMagnitude.js b/src/geom/point/GetMagnitude.js index 3230ce8b3..56f84d7a2 100644 --- a/src/geom/point/GetMagnitude.js +++ b/src/geom/point/GetMagnitude.js @@ -5,14 +5,14 @@ */ /** - * [description] + * Calculate the magnitude of the point, which equivalent to the length of the line from the origin to this point. * * @function Phaser.Geom.Point.GetMagnitude * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} point - The point to calculate the magnitude for * - * @return {number} [description] + * @return {number} The resulting magnitude */ var GetMagnitude = function (point) { diff --git a/src/geom/point/GetMagnitudeSq.js b/src/geom/point/GetMagnitudeSq.js index 3cae4408d..7e8997f70 100644 --- a/src/geom/point/GetMagnitudeSq.js +++ b/src/geom/point/GetMagnitudeSq.js @@ -5,14 +5,14 @@ */ /** - * [description] + * Calculates the square of magnitude of given point.(Can be used for fast magnitude calculation of point) * * @function Phaser.Geom.Point.GetMagnitudeSq * @since 3.0.0 * - * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} point - Returns square of the magnitude/length of given point. * - * @return {number} [description] + * @return {number} Returns square of the magnitude of given point. */ var GetMagnitudeSq = function (point) { diff --git a/src/geom/point/Interpolate.js b/src/geom/point/Interpolate.js index 2b7fa5893..f474cc3c2 100644 --- a/src/geom/point/Interpolate.js +++ b/src/geom/point/Interpolate.js @@ -14,12 +14,12 @@ var Point = require('./Point'); * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Point} pointA - [description] - * @param {Phaser.Geom.Point} pointB - [description] - * @param {number} [t=0] - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] + * @param {Phaser.Geom.Point} pointA - The starting `Point` for the interpolation. + * @param {Phaser.Geom.Point} pointB - The target `Point` for the interpolation. + * @param {number} [t=0] - The amount to interpolate between the two points. Generally, a value between 0 (returns the starting `Point`) and 1 (returns the target `Point`). If omitted, 0 is used. + * @param {(Phaser.Geom.Point|object)} [out] - An optional `Point` object whose `x` and `y` values will be set to the result of the interpolation (can also be any object with `x` and `y` properties). If omitted, a new `Point` created and returned. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} Either the object from the `out` argument with the properties `x` and `y` set to the result of the interpolation or a newly created `Point` object. */ var Interpolate = function (pointA, pointB, t, out) { diff --git a/src/geom/point/Invert.js b/src/geom/point/Invert.js index 7ab527dd5..92fb3ac36 100644 --- a/src/geom/point/Invert.js +++ b/src/geom/point/Invert.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Swaps the X and the Y coordinate of a point. * * @function Phaser.Geom.Point.Invert * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [point,$return] * - * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Point} point - The Point to modify. * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Point} The modified `point`. */ var Invert = function (point) { diff --git a/src/geom/point/Negative.js b/src/geom/point/Negative.js index f3b3f9860..8790b179d 100644 --- a/src/geom/point/Negative.js +++ b/src/geom/point/Negative.js @@ -7,17 +7,17 @@ var Point = require('./Point'); /** - * [description] + * Inverts a Point's coordinates. * * @function Phaser.Geom.Point.Negative * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Point} point - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {Phaser.Geom.Point} point - The Point to invert. + * @param {Phaser.Geom.Point} [out] - The Point to return the inverted coordinates in. * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Point} The modified `out` Point, or a new Point if none was provided. */ var Negative = function (point, out) { diff --git a/src/geom/point/Point.js b/src/geom/point/Point.js index 79fc20c33..db6a4e289 100644 --- a/src/geom/point/Point.js +++ b/src/geom/point/Point.js @@ -11,7 +11,7 @@ var Class = require('../../utils/Class'); * Defines a Point in 2D space, with an x and y component. * * @class Point - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * diff --git a/src/geom/point/SetMagnitude.js b/src/geom/point/SetMagnitude.js index 622236eb6..8b0332536 100644 --- a/src/geom/point/SetMagnitude.js +++ b/src/geom/point/SetMagnitude.js @@ -7,17 +7,17 @@ var GetMagnitude = require('./GetMagnitude'); /** - * [description] + * Changes the magnitude (length) of a two-dimensional vector without changing its direction. * * @function Phaser.Geom.Point.SetMagnitude * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [point,$return] * - * @param {Phaser.Geom.Point} point - [description] - * @param {number} magnitude - [description] + * @param {Phaser.Geom.Point} point - The Point to treat as the end point of the vector. + * @param {number} magnitude - The new magnitude of the vector. * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Point} The modified Point. */ var SetMagnitude = function (point, magnitude) { diff --git a/src/geom/polygon/Clone.js b/src/geom/polygon/Clone.js index 101b98547..4519c5d23 100644 --- a/src/geom/polygon/Clone.js +++ b/src/geom/polygon/Clone.js @@ -7,14 +7,14 @@ var Polygon = require('./Polygon'); /** - * [description] + * Create a new polygon which is a copy of the specified polygon * * @function Phaser.Geom.Polygon.Clone * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {Phaser.Geom.Polygon} polygon - The polygon to create a clone of * - * @return {Phaser.Geom.Polygon} [description] + * @return {Phaser.Geom.Polygon} A new separate Polygon cloned from the specified polygon, based on the same points. */ var Clone = function (polygon) { diff --git a/src/geom/polygon/Contains.js b/src/geom/polygon/Contains.js index 0ce6b67f8..d8bf485ee 100644 --- a/src/geom/polygon/Contains.js +++ b/src/geom/polygon/Contains.js @@ -8,16 +8,16 @@ // Adapted from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html by Jonas Raoni Soares Silva /** - * [description] + * Checks if a point is within the bounds of a Polygon. * * @function Phaser.Geom.Polygon.Contains * @since 3.0.0 * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {Phaser.Geom.Polygon} polygon - The Polygon to check against. + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the point is within the bounds of the Polygon, otherwise `false`. */ var Contains = function (polygon, x, y) { diff --git a/src/geom/polygon/Earcut.js b/src/geom/polygon/Earcut.js index 31f1f8b96..9a190b56c 100644 --- a/src/geom/polygon/Earcut.js +++ b/src/geom/polygon/Earcut.js @@ -4,37 +4,30 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// 2.1.1 (Mar 17, 2016) +// Earcut 2.1.4 (December 4th 2018) /* -ISC License - -Copyright (c) 2016, Mapbox - -Permission to use, copy, modify, and/or distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright notice -and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. + * ISC License + * + * Copyright (c) 2016, Mapbox + * + * Permission to use, copy, modify, and/or distribute this software for any purpose + * with or without fee is hereby granted, provided that the above copyright notice + * and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + * THIS SOFTWARE. */ 'use strict'; module.exports = earcut; -/* -vertices is a flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...]. -holes is an array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). -dimensions is the number of coordinates per vertice in the input array (2 by default). -Each group of three vertice indices in the resulting array forms a triangle. - */ - function earcut(data, holeIndices, dim) { dim = dim || 2; @@ -44,9 +37,9 @@ function earcut(data, holeIndices, dim) { outerNode = linkedList(data, 0, outerLen, dim, true), triangles = []; - if (!outerNode) return triangles; + if (!outerNode || outerNode.next === outerNode.prev) return triangles; - var minX, minY, maxX, maxY, x, y, size; + var minX, minY, maxX, maxY, x, y, invSize; if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); @@ -64,11 +57,12 @@ function earcut(data, holeIndices, dim) { if (y > maxY) maxY = y; } - // minX, minY and size are later used to transform coords into integers for z-order calculation - size = Math.max(maxX - minX, maxY - minY); + // minX, minY and invSize are later used to transform coords into integers for z-order calculation + invSize = Math.max(maxX - minX, maxY - minY); + invSize = invSize !== 0 ? 1 / invSize : 0; } - earcutLinked(outerNode, triangles, dim, minX, minY, size); + earcutLinked(outerNode, triangles, dim, minX, minY, invSize); return triangles; } @@ -104,7 +98,7 @@ function filterPoints(start, end) { if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) { removeNode(p); p = end = p.prev; - if (p === p.next) return null; + if (p === p.next) break; again = true; } else { @@ -116,11 +110,11 @@ function filterPoints(start, end) { } // main ear slicing loop which triangulates a polygon (given as a linked list) -function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { +function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) { if (!ear) return; // interlink polygon nodes in z-order - if (!pass && size) indexCurve(ear, minX, minY, size); + if (!pass && invSize) indexCurve(ear, minX, minY, invSize); var stop = ear, prev, next; @@ -130,7 +124,7 @@ function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { prev = ear.prev; next = ear.next; - if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) { + if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) { // cut off the triangle triangles.push(prev.i / dim); triangles.push(ear.i / dim); @@ -138,7 +132,7 @@ function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { removeNode(ear); - // skipping the next vertice leads to less sliver triangles + // skipping the next vertex leads to less sliver triangles ear = next.next; stop = next.next; @@ -151,16 +145,16 @@ function earcutLinked(ear, triangles, dim, minX, minY, size, pass) { if (ear === stop) { // try filtering points and slicing again if (!pass) { - earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1); + earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1); // if this didn't work, try curing all small self-intersections locally } else if (pass === 1) { ear = cureLocalIntersections(ear, triangles, dim); - earcutLinked(ear, triangles, dim, minX, minY, size, 2); + earcutLinked(ear, triangles, dim, minX, minY, invSize, 2); // as a last resort, try splitting the remaining polygon into two } else if (pass === 2) { - splitEarcut(ear, triangles, dim, minX, minY, size); + splitEarcut(ear, triangles, dim, minX, minY, invSize); } break; @@ -188,7 +182,7 @@ function isEar(ear) { return true; } -function isEarHashed(ear, minX, minY, size) { +function isEarHashed(ear, minX, minY, invSize) { var a = ear.prev, b = ear, c = ear.next; @@ -202,22 +196,26 @@ function isEarHashed(ear, minX, minY, size) { maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y); // z-order range for the current triangle bbox; - var minZ = zOrder(minTX, minTY, minX, minY, size), - maxZ = zOrder(maxTX, maxTY, minX, minY, size); + var minZ = zOrder(minTX, minTY, minX, minY, invSize), + maxZ = zOrder(maxTX, maxTY, minX, minY, invSize); - // first look for points inside the triangle in increasing z-order - var p = ear.nextZ; + var p = ear.prevZ, + n = ear.nextZ; - while (p && p.z <= maxZ) { + // look for points inside the triangle in both directions + while (p && p.z >= minZ && n && n.z <= maxZ) { if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false; - p = p.nextZ; + p = p.prevZ; + + if (n !== ear.prev && n !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && + area(n.prev, n, n.next) >= 0) return false; + n = n.nextZ; } - // then look for points in decreasing z-order - p = ear.prevZ; - + // look for remaining points in decreasing z-order while (p && p.z >= minZ) { if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && @@ -225,6 +223,14 @@ function isEarHashed(ear, minX, minY, size) { p = p.prevZ; } + // look for remaining points in increasing z-order + while (n && n.z <= maxZ) { + if (n !== ear.prev && n !== ear.next && + pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && + area(n.prev, n, n.next) >= 0) return false; + n = n.nextZ; + } + return true; } @@ -254,7 +260,7 @@ function cureLocalIntersections(start, triangles, dim) { } // try splitting polygon into two and triangulate them independently -function splitEarcut(start, triangles, dim, minX, minY, size) { +function splitEarcut(start, triangles, dim, minX, minY, invSize) { // look for a valid diagonal that divides the polygon into two var a = start; do { @@ -269,8 +275,8 @@ function splitEarcut(start, triangles, dim, minX, minY, size) { c = filterPoints(c, c.next); // run earcut on each half - earcutLinked(a, triangles, dim, minX, minY, size); - earcutLinked(c, triangles, dim, minX, minY, size); + earcutLinked(a, triangles, dim, minX, minY, invSize); + earcutLinked(c, triangles, dim, minX, minY, invSize); return; } b = b.next; @@ -376,10 +382,10 @@ function findHoleBridge(hole, outerNode) { } // interlink polygon nodes in z-order -function indexCurve(start, minX, minY, size) { +function indexCurve(start, minX, minY, invSize) { var p = start; do { - if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size); + if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize); p.prevZ = p.prev; p.nextZ = p.next; p = p.next; @@ -444,11 +450,11 @@ function sortLinked(list) { return list; } -// z-order of a point given coords and size of the data bounding box -function zOrder(x, y, minX, minY, size) { +// z-order of a point given coords and inverse of the longer side of data bbox +function zOrder(x, y, minX, minY, invSize) { // coords are transformed into non-negative 15-bit integer range - x = 32767 * (x - minX) / size; - y = 32767 * (y - minY) / size; + x = 32767 * (x - minX) * invSize; + y = 32767 * (y - minY) * invSize; x = (x | (x << 8)) & 0x00FF00FF; x = (x | (x << 4)) & 0x0F0F0F0F; @@ -590,14 +596,14 @@ function removeNode(p) { } function Node(i, x, y) { - // vertice index in coordinates array + // vertex index in coordinates array this.i = i; // vertex coordinates this.x = x; this.y = y; - // previous and next vertice nodes in a polygon ring + // previous and next vertex nodes in a polygon ring this.prev = null; this.next = null; @@ -666,4 +672,4 @@ earcut.flatten = function (data) { } } return result; -}; \ No newline at end of file +}; diff --git a/src/geom/polygon/GetAABB.js b/src/geom/polygon/GetAABB.js index 6678261b3..9a00558c3 100644 --- a/src/geom/polygon/GetAABB.js +++ b/src/geom/polygon/GetAABB.js @@ -7,17 +7,17 @@ var Rectangle = require('../rectangle/Rectangle'); /** - * [description] + * Calculates the bounding AABB rectangle of a polygon. * * @function Phaser.Geom.Polygon.GetAABB * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [out,$return] * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {(Phaser.Geom.Rectangle|object)} [out] - [description] + * @param {Phaser.Geom.Polygon} polygon - The polygon that should be calculated. + * @param {(Phaser.Geom.Rectangle|object)} [out] - The rectangle or object that has x, y, width, and height properties to store the result. Optional. * - * @return {(Phaser.Geom.Rectangle|object)} [description] + * @return {(Phaser.Geom.Rectangle|object)} The resulting rectangle or object that is passed in with position and dimensions of the polygon's AABB. */ var GetAABB = function (polygon, out) { diff --git a/src/geom/polygon/GetNumberArray.js b/src/geom/polygon/GetNumberArray.js index 576dea4dc..939894fe8 100644 --- a/src/geom/polygon/GetNumberArray.js +++ b/src/geom/polygon/GetNumberArray.js @@ -7,17 +7,19 @@ // Export the points as an array of flat numbers, following the sequence [ x,y, x,y, x,y ] /** - * [description] + * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], + * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant + * array for the point's X and Y coordinate. * * @function Phaser.Geom.Polygon.GetNumberArray * @since 3.0.0 * * @generic {number[]} O - [output,$return] * - * @param {Phaser.Geom.Polygon} polygon - [description] - * @param {(array|number[])} [output] - [description] + * @param {Phaser.Geom.Polygon} polygon - The Polygon whose points to export. + * @param {(array|number[])} [output] - An array to which the points' coordinates should be appended. * - * @return {(array|number[])} [description] + * @return {(array|number[])} The modified `output` array, or a new array if none was given. */ var GetNumberArray = function (polygon, output) { diff --git a/src/geom/polygon/GetPoints.js b/src/geom/polygon/GetPoints.js new file mode 100644 index 000000000..b085de8bb --- /dev/null +++ b/src/geom/polygon/GetPoints.js @@ -0,0 +1,71 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = require('../line/Length'); +var Line = require('../line/Line'); +var Perimeter = require('./Perimeter'); + +/** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @function Phaser.Geom.Polygon.GetPoints + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the points from. + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the perimeter of the Polygon. + */ +var GetPoints = function (polygon, quantity, stepRate, out) +{ + if (out === undefined) { out = []; } + + var points = polygon.points; + var perimeter = Perimeter(polygon); + + // If quantity is a falsey value (false, null, 0, undefined, etc) then we calculate it based on the stepRate instead. + if (!quantity) + { + quantity = perimeter / stepRate; + } + + for (var i = 0; i < quantity; i++) + { + var position = perimeter * (i / quantity); + var accumulatedPerimeter = 0; + + for (var j = 0; j < points.length; j++) + { + var pointA = points[j]; + var pointB = points[(j + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + var length = Length(line); + + if (position < accumulatedPerimeter || position > accumulatedPerimeter + length) + { + accumulatedPerimeter += length; + continue; + } + + var point = line.getPoint((position - accumulatedPerimeter) / length); + out.push(point); + + break; + } + } + + return out; +}; + +module.exports = GetPoints; diff --git a/src/geom/polygon/Perimeter.js b/src/geom/polygon/Perimeter.js new file mode 100644 index 000000000..b72faf4b8 --- /dev/null +++ b/src/geom/polygon/Perimeter.js @@ -0,0 +1,42 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Length = require('../line/Length'); +var Line = require('../line/Line'); + +/** + * Returns the perimeter of the given Polygon. + * + * @function Phaser.Geom.Polygon.Perimeter + * @since 3.12.0 + * + * @param {Phaser.Geom.Polygon} polygon - The Polygon to get the perimeter of. + * + * @return {number} The perimeter of the Polygon. + */ +var Perimeter = function (polygon) +{ + var points = polygon.points; + var perimeter = 0; + + for (var i = 0; i < points.length; i++) + { + var pointA = points[i]; + var pointB = points[(i + 1) % points.length]; + var line = new Line( + pointA.x, + pointA.y, + pointB.x, + pointB.y + ); + + perimeter += Length(line); + } + + return perimeter; +}; + +module.exports = Perimeter; diff --git a/src/geom/polygon/Polygon.js b/src/geom/polygon/Polygon.js index a59aa5358..48a59072a 100644 --- a/src/geom/polygon/Polygon.js +++ b/src/geom/polygon/Polygon.js @@ -6,17 +6,30 @@ var Class = require('../../utils/Class'); var Contains = require('./Contains'); +var GetPoints = require('./GetPoints'); /** * @classdesc - * [description] + * A Polygon object + * + + * The polygon is a closed shape consists of a series of connected straight lines defined by list of ordered points. + * Several formats are supported to define the list of points, check the setTo method for details. + * This is a geometry object allowing you to define and inspect the shape. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Polygon you should look at the capabilities of the Graphics class. * * @class Polygon - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * - * @param {Phaser.Geom.Point[]} [points] - [description] + * @param {Phaser.Geom.Point[]} [points] - List of points defining the perimeter of this Polygon. Several formats are supported: + * - A string containing paired x y values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` */ var Polygon = new Class({ @@ -50,15 +63,15 @@ var Polygon = new Class({ }, /** - * [description] + * Check to see if the Polygon contains the given x / y coordinates. * * @method Phaser.Geom.Polygon#contains * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The x coordinate to check within the polygon. + * @param {number} y - The y coordinate to check within the polygon. * - * @return {boolean} [description] + * @return {boolean} `true` if the coordinates are within the polygon, otherwise `false`. */ contains: function (x, y) { @@ -70,6 +83,7 @@ var Polygon = new Class({ * * The points can be set from a variety of formats: * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` * - An array of objects with public x/y properties: `[obj1, obj2, ...]` * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` @@ -80,7 +94,7 @@ var Polygon = new Class({ * @method Phaser.Geom.Polygon#setTo * @since 3.0.0 * - * @param {array} points - [description] + * @param {array} points - Points defining the perimeter of this polygon. Please check function description above for the different supported formats. * * @return {Phaser.Geom.Polygon} This Polygon object. */ @@ -89,6 +103,11 @@ var Polygon = new Class({ this.area = 0; this.points = []; + if (typeof points === 'string') + { + points = points.split(' '); + } + if (!Array.isArray(points)) { return this; @@ -102,10 +121,10 @@ var Polygon = new Class({ { p = { x: 0, y: 0 }; - if (typeof points[i] === 'number') + if (typeof points[i] === 'number' || typeof points[i] === 'string') { - p.x = points[i]; - p.y = points[i + 1]; + p.x = parseFloat(points[i]); + p.y = parseFloat(points[i + 1]); i++; } else if (Array.isArray(points[i])) @@ -140,7 +159,7 @@ var Polygon = new Class({ * @method Phaser.Geom.Polygon#calculateArea * @since 3.0.0 * - * @return {number} [description] + * @return {number} The area of the polygon. */ calculateArea: function () { @@ -171,6 +190,24 @@ var Polygon = new Class({ this.area = -sum * 0.5; return this.area; + }, + + /** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * + * @method Phaser.Geom.Polygon#getPoints + * @since 3.12.0 + * + * @param {integer} quantity - The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param {number} [stepRate] - Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param {array} [output] - An array to insert the points in to. If not provided a new array will be created. + * + * @return {Phaser.Geom.Point[]} An array of Point objects pertaining to the points around the perimeter of the Polygon. + */ + getPoints: function (quantity, step, output) + { + return GetPoints(this, quantity, step, output); } }); diff --git a/src/geom/polygon/Reverse.js b/src/geom/polygon/Reverse.js index 5b5e26aec..8cbee3ba5 100644 --- a/src/geom/polygon/Reverse.js +++ b/src/geom/polygon/Reverse.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Reverses the order of the points of a Polygon. * * @function Phaser.Geom.Polygon.Reverse * @since 3.0.0 * * @generic {Phaser.Geom.Polygon} O - [polygon,$return] * - * @param {Phaser.Geom.Polygon} polygon - [description] + * @param {Phaser.Geom.Polygon} polygon - The Polygon to modify. * - * @return {Phaser.Geom.Polygon} [description] + * @return {Phaser.Geom.Polygon} The modified Polygon. */ var Reverse = function (polygon) { diff --git a/src/geom/polygon/Smooth.js b/src/geom/polygon/Smooth.js new file mode 100644 index 000000000..3577b1135 --- /dev/null +++ b/src/geom/polygon/Smooth.js @@ -0,0 +1,67 @@ +/** + * @author Richard Davey + * @author Igor Ognichenko + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var copy = function (out, a) +{ + out[0] = a[0]; + out[1] = a[1]; + + return out; +}; + +/** + * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. + * + * @function Phaser.Geom.Polygon.Smooth + * @since 3.13.0 + * + * @generic {Phaser.Geom.Polygon} O - [polygon,$return] + * + * @param {Phaser.Geom.Polygon} polygon - The polygon to be smoothed. The polygon will be modified in-place and returned. + * + * @return {Phaser.Geom.Polygon} The input polygon. + */ +var Smooth = function (polygon) +{ + var i; + var points = []; + var data = polygon.points; + + for (i = 0; i < data.length; i++) + { + points.push([ data[i].x, data[i].y ]); + } + + var output = []; + + if (points.length > 0) + { + output.push(copy([ 0, 0 ], points[0])); + } + + for (i = 0; i < points.length - 1; i++) + { + var p0 = points[i]; + var p1 = points[i + 1]; + var p0x = p0[0]; + var p0y = p0[1]; + var p1x = p1[0]; + var p1y = p1[1]; + + output.push([ 0.85 * p0x + 0.15 * p1x, 0.85 * p0y + 0.15 * p1y ]); + output.push([ 0.15 * p0x + 0.85 * p1x, 0.15 * p0y + 0.85 * p1y ]); + } + + if (points.length > 1) + { + output.push(copy([ 0, 0 ], points[points.length - 1])); + } + + return polygon.setTo(output); +}; + +module.exports = Smooth; diff --git a/src/geom/polygon/index.js b/src/geom/polygon/index.js index 3b8ee41ca..09d0901ee 100644 --- a/src/geom/polygon/index.js +++ b/src/geom/polygon/index.js @@ -11,5 +11,9 @@ Polygon.Contains = require('./Contains'); Polygon.ContainsPoint = require('./ContainsPoint'); Polygon.GetAABB = require('./GetAABB'); Polygon.GetNumberArray = require('./GetNumberArray'); +Polygon.GetPoints = require('./GetPoints'); +Polygon.Perimeter = require('./Perimeter'); +Polygon.Reverse = require('./Reverse'); +Polygon.Smooth = require('./Smooth'); module.exports = Polygon; diff --git a/src/geom/rectangle/Area.js b/src/geom/rectangle/Area.js index 80909723f..e90f8d7a1 100644 --- a/src/geom/rectangle/Area.js +++ b/src/geom/rectangle/Area.js @@ -5,14 +5,14 @@ */ /** - * [description] + * Calculates the area of the given Rectangle object. * * @function Phaser.Geom.Rectangle.Area * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The rectangle to calculate the area of. * - * @return {number} [description] + * @return {number} The area of the Rectangle object. */ var Area = function (rect) { diff --git a/src/geom/rectangle/Ceil.js b/src/geom/rectangle/Ceil.js index 8bb33a368..024a6df57 100644 --- a/src/geom/rectangle/Ceil.js +++ b/src/geom/rectangle/Ceil.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. * * @function Phaser.Geom.Rectangle.Ceil * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. */ var Ceil = function (rect) { diff --git a/src/geom/rectangle/CeilAll.js b/src/geom/rectangle/CeilAll.js index 5ae015118..2da4ec7ce 100644 --- a/src/geom/rectangle/CeilAll.js +++ b/src/geom/rectangle/CeilAll.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Rounds a Rectangle's position and size up to the smallest integer greater than or equal to each respective value. * * @function Phaser.Geom.Rectangle.CeilAll * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to modify. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The modified Rectangle. */ var CeilAll = function (rect) { diff --git a/src/geom/rectangle/CenterOn.js b/src/geom/rectangle/CenterOn.js index f91c5e252..77f6993ec 100644 --- a/src/geom/rectangle/CenterOn.js +++ b/src/geom/rectangle/CenterOn.js @@ -7,18 +7,18 @@ // Centers this Rectangle so that the center coordinates match the given x and y values. /** - * [description] + * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. * * @function Phaser.Geom.Rectangle.CenterOn * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to be centered. + * @param {number} x - The X coordinate of the Rectangle's center. + * @param {number} y - The Y coordinate of the Rectangle's center. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The centered rectangle. */ var CenterOn = function (rect, x, y) { diff --git a/src/geom/rectangle/Clone.js b/src/geom/rectangle/Clone.js index 721b7ee0d..3b849e3b8 100644 --- a/src/geom/rectangle/Clone.js +++ b/src/geom/rectangle/Clone.js @@ -7,14 +7,14 @@ var Rectangle = require('./Rectangle'); /** - * [description] + * Creates a new Rectangle which is identical to the given one. * * @function Phaser.Geom.Rectangle.Clone * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {Phaser.Geom.Rectangle} source - The Rectangle to clone. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The newly created Rectangle, which is separate from the given one. */ var Clone = function (source) { diff --git a/src/geom/rectangle/Contains.js b/src/geom/rectangle/Contains.js index 0a85787a1..ec91694a1 100644 --- a/src/geom/rectangle/Contains.js +++ b/src/geom/rectangle/Contains.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Checks if a given point is inside a Rectangle's bounds. * * @function Phaser.Geom.Rectangle.Contains * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to check. + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the point is within the Rectangle's bounds, otherwise `false`. */ var Contains = function (rect, x, y) { diff --git a/src/geom/rectangle/ContainsPoint.js b/src/geom/rectangle/ContainsPoint.js index aa06db346..b67d57804 100644 --- a/src/geom/rectangle/ContainsPoint.js +++ b/src/geom/rectangle/ContainsPoint.js @@ -7,15 +7,15 @@ var Contains = require('./Contains'); /** - * [description] + * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. * * @function Phaser.Geom.Rectangle.ContainsPoint * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object. + * @param {Phaser.Geom.Point} point - The point object to be checked. Can be a Phaser Point object or any object with x and y values. * - * @return {boolean} [description] + * @return {boolean} A value of true if the Rectangle object contains the specified point, otherwise false. */ var ContainsPoint = function (rect, point) { diff --git a/src/geom/rectangle/ContainsRect.js b/src/geom/rectangle/ContainsRect.js index ea9cc67ba..3733890bd 100644 --- a/src/geom/rectangle/ContainsRect.js +++ b/src/geom/rectangle/ContainsRect.js @@ -4,18 +4,16 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Checks if rectB is fully contained within rectA - /** - * [description] + * Tests if one rectangle fully contains another. * * @function Phaser.Geom.Rectangle.ContainsRect * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {Phaser.Geom.Rectangle} rectA - The first rectangle. + * @param {Phaser.Geom.Rectangle} rectB - The second rectangle. * - * @return {boolean} [description] + * @return {boolean} True only if rectA fully contains rectB. */ var ContainsRect = function (rectA, rectB) { diff --git a/src/geom/rectangle/Decompose.js b/src/geom/rectangle/Decompose.js index 602e62e8a..3e819290a 100644 --- a/src/geom/rectangle/Decompose.js +++ b/src/geom/rectangle/Decompose.js @@ -5,15 +5,16 @@ */ /** - * [description] + * Create an array of points for each corner of a Rectangle + * If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created. * * @function Phaser.Geom.Rectangle.Decompose * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {array} [out] - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle object to be decomposed. + * @param {array} [out] - If provided, each point will be added to this array. * - * @return {array} [description] + * @return {array} Will return the array you specified or a new array containing the points of the Rectangle. */ var Decompose = function (rect, out) { diff --git a/src/geom/rectangle/Equals.js b/src/geom/rectangle/Equals.js index 91b78d084..51f7957ef 100644 --- a/src/geom/rectangle/Equals.js +++ b/src/geom/rectangle/Equals.js @@ -5,15 +5,15 @@ */ /** - * [description] + * Compares the `x`, `y`, `width` and `height` properties of two rectangles. * * @function Phaser.Geom.Rectangle.Equals * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Rectangle} toCompare - [description] + * @param {Phaser.Geom.Rectangle} rect - Rectangle A + * @param {Phaser.Geom.Rectangle} toCompare - Rectangle B * - * @return {boolean} [description] + * @return {boolean} `true` if the rectangles' properties are an exact match, otherwise `false`. */ var Equals = function (rect, toCompare) { diff --git a/src/geom/rectangle/Floor.js b/src/geom/rectangle/Floor.js index 0cf4f2aee..24bfa9a39 100644 --- a/src/geom/rectangle/Floor.js +++ b/src/geom/rectangle/Floor.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Rounds down (floors) the top left X and Y co-ordinates of the given Rectangle to the largest integer less than or equal to them * * @function Phaser.Geom.Rectangle.Floor * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The rectangle to floor the top left X and Y co-ordinates of * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The rectangle that was passed to this function with its co-ordinates floored. */ var Floor = function (rect) { diff --git a/src/geom/rectangle/FloorAll.js b/src/geom/rectangle/FloorAll.js index e6df1eb23..0083257ac 100644 --- a/src/geom/rectangle/FloorAll.js +++ b/src/geom/rectangle/FloorAll.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. * * @function Phaser.Geom.Rectangle.FloorAll * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. */ var FloorAll = function (rect) { diff --git a/src/geom/rectangle/FromPoints.js b/src/geom/rectangle/FromPoints.js index 64f075520..c7312d5c8 100644 --- a/src/geom/rectangle/FromPoints.js +++ b/src/geom/rectangle/FromPoints.js @@ -15,17 +15,17 @@ var Rectangle = require('./Rectangle'); // ] /** - * [description] + * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. * * @function Phaser.Geom.Rectangle.FromPoints * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [out,$return] * - * @param {array} points - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] + * @param {array} points - An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. + * @param {Phaser.Geom.Rectangle} [out] - Optional Rectangle to adjust. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The adjusted `out` Rectangle, or a new Rectangle if none was provided. */ var FromPoints = function (points, out) { diff --git a/src/geom/rectangle/GetAspectRatio.js b/src/geom/rectangle/GetAspectRatio.js index bb92d4d55..96050b7ba 100644 --- a/src/geom/rectangle/GetAspectRatio.js +++ b/src/geom/rectangle/GetAspectRatio.js @@ -5,14 +5,14 @@ */ /** - * [description] + * Calculates the width/height ratio of a rectangle. * * @function Phaser.Geom.Rectangle.GetAspectRatio * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The rectangle. * - * @return {number} [description] + * @return {number} The width/height ratio of the rectangle. */ var GetAspectRatio = function (rect) { diff --git a/src/geom/rectangle/GetCenter.js b/src/geom/rectangle/GetCenter.js index 93dcf3fc6..e0d425fdc 100644 --- a/src/geom/rectangle/GetCenter.js +++ b/src/geom/rectangle/GetCenter.js @@ -6,20 +6,18 @@ var Point = require('../point/Point'); -// The center of the Rectangle object, expressed as a Point object - /** - * [description] + * Returns the center of a Rectangle as a Point. * * @function Phaser.Geom.Rectangle.GetCenter * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to get the center of. + * @param {(Phaser.Geom.Point|object)} [out] - Optional point-like object to update with the center coordinates. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} The modified `out` object, or a new Point if none was provided. */ var GetCenter = function (rect, out) { diff --git a/src/geom/rectangle/GetPoints.js b/src/geom/rectangle/GetPoints.js index 9f26d4da2..a4b4c63f1 100644 --- a/src/geom/rectangle/GetPoints.js +++ b/src/geom/rectangle/GetPoints.js @@ -11,19 +11,19 @@ var Perimeter = require('./Perimeter'); // each spaced out based on the quantity or step required /** - * [description] + * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. * * @function Phaser.Geom.Rectangle.GetPoints * @since 3.0.0 * * @generic {Phaser.Geom.Point[]} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {number} step - [description] - * @param {integer} quantity - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] + * @param {Phaser.Geom.Rectangle} rectangle - The Rectangle object to get the points from. + * @param {number} step - Step between points. Used to calculate the number of points to return when quantity is falsy. Ignored if quantity is positive. + * @param {integer} quantity - The number of evenly spaced points from the rectangles perimeter to return. If falsy, step param will be used to calculate the number of points. + * @param {(array|Phaser.Geom.Point[])} [out] - An optional array to store the points in. * - * @return {(array|Phaser.Geom.Point[])} [description] + * @return {(array|Phaser.Geom.Point[])} An array of Points from the perimeter of the rectangle. */ var GetPoints = function (rectangle, quantity, stepRate, out) { diff --git a/src/geom/rectangle/Inflate.js b/src/geom/rectangle/Inflate.js index 1d98cf936..13ad813ae 100644 --- a/src/geom/rectangle/Inflate.js +++ b/src/geom/rectangle/Inflate.js @@ -6,23 +6,22 @@ var CenterOn = require('./CenterOn'); -// Increases the size of the Rectangle object by the specified amounts. -// The center point of the Rectangle object stays the same, and its size increases -// to the left and right by the x value, and to the top and the bottom by the y value. /** - * [description] + * Increases the size of a Rectangle by a specified amount. + * + * The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument. * * @function Phaser.Geom.Rectangle.Inflate * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to inflate. + * @param {number} x - How many pixels the left and the right side should be moved by horizontally. + * @param {number} y - How many pixels the top and the bottom side should be moved by vertically. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The inflated Rectangle. */ var Inflate = function (rect, x, y) { diff --git a/src/geom/rectangle/Intersection.js b/src/geom/rectangle/Intersection.js new file mode 100644 index 000000000..f39bdd48b --- /dev/null +++ b/src/geom/rectangle/Intersection.js @@ -0,0 +1,45 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Rectangle = require('./Rectangle'); +var Intersects = require('../intersects/RectangleToRectangle'); + +/** + * Takes two Rectangles and first checks to see if they intersect. + * If they intersect it will return the area of intersection in the `out` Rectangle. + * If they do not intersect, the `out` Rectangle will have a width and height of zero. + * + * @function Phaser.Geom.Rectangle.Intersection + * @since 3.11.0 + * + * @generic {Phaser.Geom.Rectangle} O - [rect,$return] + * + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to get the intersection from. + * @param {Phaser.Geom.Rectangle} [out] - A Rectangle to store the intersection results in. + * + * @return {Phaser.Geom.Rectangle} The intersection result. If the width and height are zero, no intersection occurred. + */ +var Intersection = function (rectA, rectB, out) +{ + if (out === undefined) { out = new Rectangle(); } + + if (Intersects(rectA, rectB)) + { + out.x = Math.max(rectA.x, rectB.x); + out.y = Math.max(rectA.y, rectB.y); + out.width = Math.min(rectA.right, rectB.right) - out.x; + out.height = Math.min(rectA.bottom, rectB.bottom) - out.y; + } + else + { + out.setEmpty(); + } + + return out; +}; + +module.exports = Intersection; diff --git a/src/geom/rectangle/MergePoints.js b/src/geom/rectangle/MergePoints.js index 78752268b..d9eb01650 100644 --- a/src/geom/rectangle/MergePoints.js +++ b/src/geom/rectangle/MergePoints.js @@ -4,21 +4,18 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Merges the target Rectangle with a list of points. -// The points is an array of objects with public x/y properties. - /** - * [description] + * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. * * @function Phaser.Geom.Rectangle.MergePoints * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [target,$return] * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Point[]} points - [description] + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged. + * @param {Phaser.Geom.Point[]} points - An array of Points (or any object with public `x` and `y` properties) which should be merged with the Rectangle. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The modified Rectangle. */ var MergePoints = function (target, points) { diff --git a/src/geom/rectangle/MergeRect.js b/src/geom/rectangle/MergeRect.js index 1cd710f10..6b45e6d60 100644 --- a/src/geom/rectangle/MergeRect.js +++ b/src/geom/rectangle/MergeRect.js @@ -8,17 +8,18 @@ // Neither rect should have negative widths or heights /** - * [description] + * Merges the source rectangle into the target rectangle and returns the target. + * Neither rectangle should have a negative width or height. * * @function Phaser.Geom.Rectangle.MergeRect * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [target,$return] * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {Phaser.Geom.Rectangle} source - [description] + * @param {Phaser.Geom.Rectangle} target - Target rectangle. Will be modified to include source rectangle. + * @param {Phaser.Geom.Rectangle} source - Rectangle that will be merged into target rectangle. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} Modified target rectangle that contains source rectangle. */ var MergeRect = function (target, source) { diff --git a/src/geom/rectangle/MergeXY.js b/src/geom/rectangle/MergeXY.js index ebb1d6efe..d8fbecbcc 100644 --- a/src/geom/rectangle/MergeXY.js +++ b/src/geom/rectangle/MergeXY.js @@ -5,18 +5,18 @@ */ /** - * [description] + * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. * * @function Phaser.Geom.Rectangle.MergeXY * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [target,$return] * - * @param {Phaser.Geom.Rectangle} target - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {Phaser.Geom.Rectangle} target - The Rectangle which should be merged and modified. + * @param {number} x - The X coordinate of the point which should be merged. + * @param {number} y - The Y coordinate of the point which should be merged. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The modified `target` Rectangle. */ var MergeXY = function (target, x, y) { diff --git a/src/geom/rectangle/Offset.js b/src/geom/rectangle/Offset.js index 0353cdd54..452527db4 100644 --- a/src/geom/rectangle/Offset.js +++ b/src/geom/rectangle/Offset.js @@ -5,18 +5,18 @@ */ /** - * [description] + * Nudges (translates) the top left corner of a Rectangle by a given offset. * * @function Phaser.Geom.Rectangle.Offset * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {number} x - The distance to move the Rectangle horizontally. + * @param {number} y - The distance to move the Rectangle vertically. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. */ var Offset = function (rect, x, y) { diff --git a/src/geom/rectangle/OffsetPoint.js b/src/geom/rectangle/OffsetPoint.js index 29805fafd..09862a794 100644 --- a/src/geom/rectangle/OffsetPoint.js +++ b/src/geom/rectangle/OffsetPoint.js @@ -5,17 +5,17 @@ */ /** - * [description] + * Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector). * * @function Phaser.Geom.Rectangle.OffsetPoint * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to adjust. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2)} point - The point whose coordinates should be used as an offset. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The adjusted Rectangle. */ var OffsetPoint = function (rect, point) { diff --git a/src/geom/rectangle/Overlaps.js b/src/geom/rectangle/Overlaps.js index 1fbb93116..cae6a6eaa 100644 --- a/src/geom/rectangle/Overlaps.js +++ b/src/geom/rectangle/Overlaps.js @@ -5,15 +5,15 @@ */ /** - * [description] + * Checks if two Rectangles overlap. If a Rectangle is within another Rectangle, the two will be considered overlapping. Thus, the Rectangles are treated as "solid". * * @function Phaser.Geom.Rectangle.Overlaps * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to check. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the two Rectangles overlap, `false` otherwise. */ var Overlaps = function (rectA, rectB) { diff --git a/src/geom/rectangle/Perimeter.js b/src/geom/rectangle/Perimeter.js index f556043ed..859ad0ef1 100644 --- a/src/geom/rectangle/Perimeter.js +++ b/src/geom/rectangle/Perimeter.js @@ -5,14 +5,14 @@ */ /** - * [description] + * Calculates the perimeter of a Rectangle. * * @function Phaser.Geom.Rectangle.Perimeter * @since 3.0.0 * - * @param {Phaser.Geom.Rectangle} rect - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to use. * - * @return {number} [description] + * @return {number} The perimeter of the Rectangle, equal to `(width * 2) + (height * 2)`. */ var Perimeter = function (rect) { diff --git a/src/geom/rectangle/Random.js b/src/geom/rectangle/Random.js index 70ce537e3..248a69dc5 100644 --- a/src/geom/rectangle/Random.js +++ b/src/geom/rectangle/Random.js @@ -7,17 +7,17 @@ var Point = require('../point/Point'); /** - * [description] + * Returns a random point within a Rectangle. * * @function Phaser.Geom.Rectangle.Random * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {Phaser.Geom.Point} out - [description] + * @param {Phaser.Geom.Rectangle} rect - The Rectangle to return a point from. + * @param {Phaser.Geom.Point} out - The object to update with the point's coordinates. * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Point} The modified `out` object, or a new Point if none was provided. */ var Random = function (rect, out) { diff --git a/src/geom/rectangle/Rectangle.js b/src/geom/rectangle/Rectangle.js index 13f714c36..86caaf565 100644 --- a/src/geom/rectangle/Rectangle.js +++ b/src/geom/rectangle/Rectangle.js @@ -16,14 +16,14 @@ var Random = require('./Random'); * Encapsulates a 2D rectangle defined by its corner point in the top-left and its extends in x (width) and y (height) * * @class Rectangle - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width=0] - [description] - * @param {number} [height=0] - [description] + * @param {number} [x=0] - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=0] - The Y coordinate of the top left corner of the Rectangle. + * @param {number} [width=0] - The width of the Rectangle. + * @param {number} [height=0] - The height of the Rectangle. */ var Rectangle = new Class({ @@ -37,7 +37,7 @@ var Rectangle = new Class({ if (height === undefined) { height = 0; } /** - * [description] + * The X coordinate of the top left corner of the Rectangle. * * @name Phaser.Geom.Rectangle#x * @type {number} @@ -47,7 +47,7 @@ var Rectangle = new Class({ this.x = x; /** - * [description] + * The Y coordinate of the top left corner of the Rectangle. * * @name Phaser.Geom.Rectangle#y * @type {number} @@ -57,7 +57,7 @@ var Rectangle = new Class({ this.y = y; /** - * [description] + * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. * * @name Phaser.Geom.Rectangle#width * @type {number} @@ -67,7 +67,7 @@ var Rectangle = new Class({ this.width = width; /** - * [description] + * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. * * @name Phaser.Geom.Rectangle#height * @type {number} @@ -78,15 +78,15 @@ var Rectangle = new Class({ }, /** - * [description] + * Checks if the given point is inside the Rectangle's bounds. * * @method Phaser.Geom.Rectangle#contains * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the point is within the Rectangle's bounds, otherwise `false`. */ contains: function (x, y) { @@ -94,17 +94,21 @@ var Rectangle = new Class({ }, /** - * [description] + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. + * + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. + * + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. * * @method Phaser.Geom.Rectangle#getPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [output,$return] * - * @param {number} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] + * @param {number} position - The normalized distance into the Rectangle's perimeter to return. + * @param {(Phaser.Geom.Point|object)} [output] - An object to update with the `x` and `y` coordinates of the point. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} The updated `output` object, or a new Point if no `output` object was given. */ getPoint: function (position, output) { @@ -112,18 +116,18 @@ var Rectangle = new Class({ }, /** - * [description] + * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. * * @method Phaser.Geom.Rectangle#getPoints * @since 3.0.0 * * @generic {Phaser.Geom.Point[]} O - [output,$return] * - * @param {integer} quantity - [description] - * @param {number} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * @param {integer} quantity - The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. + * @param {number} [stepRate] - If `quantity` is 0, determines the normalized distance between each returned point. + * @param {(array|Phaser.Geom.Point[])} [output] - An array to which to append the points. * - * @return {(array|Phaser.Geom.Point[])} [description] + * @return {(array|Phaser.Geom.Point[])} The modified `output` array, or a new array if none was provided. */ getPoints: function (quantity, stepRate, output) { @@ -131,16 +135,16 @@ var Rectangle = new Class({ }, /** - * [description] + * Returns a random point within the Rectangle's bounds. * * @method Phaser.Geom.Rectangle#getRandomPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [point,$return] * - * @param {Phaser.Geom.Point} [point] - [description] + * @param {Phaser.Geom.Point} [point] - The object in which to store the `x` and `y` coordinates of the point. * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Point} The updated `point`, or a new Point if none was provided. */ getRandomPoint: function (point) { @@ -148,15 +152,15 @@ var Rectangle = new Class({ }, /** - * [description] + * Sets the position, width, and height of the Rectangle. * * @method Phaser.Geom.Rectangle#setTo * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} y - The Y coordinate of the top left corner of the Rectangle. + * @param {number} width - The width of the Rectangle. + * @param {number} height - The height of the Rectangle. * * @return {Phaser.Geom.Rectangle} This Rectangle object. */ @@ -171,7 +175,7 @@ var Rectangle = new Class({ }, /** - * [description] + * Resets the position, width, and height of the Rectangle to 0. * * @method Phaser.Geom.Rectangle#setEmpty * @since 3.0.0 @@ -184,13 +188,13 @@ var Rectangle = new Class({ }, /** - * [description] + * Sets the position of the Rectangle. * * @method Phaser.Geom.Rectangle#setPosition * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The X coordinate of the top left corner of the Rectangle. + * @param {number} [y=x] - The Y coordinate of the top left corner of the Rectangle. * * @return {Phaser.Geom.Rectangle} This Rectangle object. */ @@ -205,13 +209,13 @@ var Rectangle = new Class({ }, /** - * [description] + * Sets the width and height of the Rectangle. * * @method Phaser.Geom.Rectangle#setSize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} [height=width] - [description] + * @param {number} width - The width to set the Rectangle to. + * @param {number} [height=width] - The height to set the Rectangle to. * * @return {Phaser.Geom.Rectangle} This Rectangle object. */ @@ -226,12 +230,12 @@ var Rectangle = new Class({ }, /** - * [description] + * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. * * @method Phaser.Geom.Rectangle#isEmpty * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if the Rectangle is empty. A Rectangle object is empty if its width or height is less than or equal to 0. */ isEmpty: function () { @@ -323,7 +327,8 @@ var Rectangle = new Class({ }, /** - * [description] + * The x coordinate of the left of the Rectangle. + * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. * * @name Phaser.Geom.Rectangle#left * @type {number} @@ -353,7 +358,8 @@ var Rectangle = new Class({ }, /** - * [description] + * The sum of the x and width properties. + * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. * * @name Phaser.Geom.Rectangle#right * @type {number} @@ -381,7 +387,8 @@ var Rectangle = new Class({ }, /** - * [description] + * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. + * However it does affect the height property, whereas changing the y value does not affect the height property. * * @name Phaser.Geom.Rectangle#top * @type {number} @@ -411,7 +418,8 @@ var Rectangle = new Class({ }, /** - * [description] + * The sum of the y and height properties. + * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. * * @name Phaser.Geom.Rectangle#bottom * @type {number} @@ -439,7 +447,7 @@ var Rectangle = new Class({ }, /** - * [description] + * The x coordinate of the center of the Rectangle. * * @name Phaser.Geom.Rectangle#centerX * @type {number} @@ -460,7 +468,7 @@ var Rectangle = new Class({ }, /** - * [description] + * The y coordinate of the center of the Rectangle. * * @name Phaser.Geom.Rectangle#centerY * @type {number} diff --git a/src/geom/rectangle/SameDimensions.js b/src/geom/rectangle/SameDimensions.js new file mode 100644 index 000000000..98b7a0f06 --- /dev/null +++ b/src/geom/rectangle/SameDimensions.js @@ -0,0 +1,23 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. + * + * @function Phaser.Geom.Rectangle.SameDimensions + * @since 3.15.0 + * + * @param {Phaser.Geom.Rectangle} rect - The first Rectangle object. + * @param {Phaser.Geom.Rectangle} toCompare - The second Rectangle object. + * + * @return {boolean} `true` if the objects have equivalent values for the `width` and `height` properties, otherwise `false`. + */ +var SameDimensions = function (rect, toCompare) +{ + return (rect.width === toCompare.width && rect.height === toCompare.height); +}; + +module.exports = SameDimensions; diff --git a/src/geom/rectangle/Scale.js b/src/geom/rectangle/Scale.js index 4072a65f0..69dfd007c 100644 --- a/src/geom/rectangle/Scale.js +++ b/src/geom/rectangle/Scale.js @@ -7,18 +7,18 @@ // Scales the width and height of this Rectangle by the given amounts. /** - * [description] + * Scales the width and height of this Rectangle by the given amounts. * * @function Phaser.Geom.Rectangle.Scale * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [rect,$return] * - * @param {Phaser.Geom.Rectangle} rect - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {Phaser.Geom.Rectangle} rect - The `Rectangle` object that will be scaled by the specified amount(s). + * @param {number} x - The factor by which to scale the rectangle horizontally. + * @param {number} y - The amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor `x` in both directions. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The rectangle object with updated `width` and `height` properties as calculated from the scaling factor(s). */ var Scale = function (rect, x, y) { diff --git a/src/geom/rectangle/Union.js b/src/geom/rectangle/Union.js index f9fdaebb6..a082e1963 100644 --- a/src/geom/rectangle/Union.js +++ b/src/geom/rectangle/Union.js @@ -7,18 +7,18 @@ var Rectangle = require('./Rectangle'); /** - * [description] + * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. * * @function Phaser.Geom.Rectangle.Union * @since 3.0.0 * * @generic {Phaser.Geom.Rectangle} O - [out,$return] * - * @param {Phaser.Geom.Rectangle} rectA - [description] - * @param {Phaser.Geom.Rectangle} rectB - [description] - * @param {Phaser.Geom.Rectangle} [out] - [description] + * @param {Phaser.Geom.Rectangle} rectA - The first Rectangle to use. + * @param {Phaser.Geom.Rectangle} rectB - The second Rectangle to use. + * @param {Phaser.Geom.Rectangle} [out] - The Rectangle to store the union in. * - * @return {Phaser.Geom.Rectangle} [description] + * @return {Phaser.Geom.Rectangle} The modified `out` Rectangle, or a new Rectangle if none was provided. */ var Union = function (rectA, rectB, out) { diff --git a/src/geom/rectangle/index.js b/src/geom/rectangle/index.js index 4836e2755..93b7db954 100644 --- a/src/geom/rectangle/index.js +++ b/src/geom/rectangle/index.js @@ -28,6 +28,7 @@ Rectangle.GetPoint = require('./GetPoint'); Rectangle.GetPoints = require('./GetPoints'); Rectangle.GetSize = require('./GetSize'); Rectangle.Inflate = require('./Inflate'); +Rectangle.Intersection = require('./Intersection'); Rectangle.MarchingAnts = require('./MarchingAnts'); Rectangle.MergePoints = require('./MergePoints'); Rectangle.MergeRect = require('./MergeRect'); @@ -39,6 +40,7 @@ Rectangle.Perimeter = require('./Perimeter'); Rectangle.PerimeterPoint = require('./PerimeterPoint'); Rectangle.Random = require('./Random'); Rectangle.RandomOutside = require('./RandomOutside'); +Rectangle.SameDimensions = require('./SameDimensions'); Rectangle.Scale = require('./Scale'); Rectangle.Union = require('./Union'); diff --git a/src/geom/triangle/Area.js b/src/geom/triangle/Area.js index 344589b3c..83c255fdd 100644 --- a/src/geom/triangle/Area.js +++ b/src/geom/triangle/Area.js @@ -7,14 +7,14 @@ // The 2D area of a triangle. The area value is always non-negative. /** - * [description] + * Returns the area of a Triangle. * * @function Phaser.Geom.Triangle.Area * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to use. * - * @return {number} [description] + * @return {number} The area of the Triangle, always non-negative. */ var Area = function (triangle) { diff --git a/src/geom/triangle/BuildEquilateral.js b/src/geom/triangle/BuildEquilateral.js index 5dc47ecec..d869452ef 100644 --- a/src/geom/triangle/BuildEquilateral.js +++ b/src/geom/triangle/BuildEquilateral.js @@ -6,24 +6,18 @@ var Triangle = require('./Triangle'); -// Builds an equilateral triangle. -// In the equilateral triangle, all the sides are the same length (congruent) -// and all the angles are the same size (congruent). - -// The x/y specifies the top-middle of the triangle (x1/y1) and length -// is the length of each side - /** - * [description] + * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). + * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. * * @function Phaser.Geom.Triangle.BuildEquilateral * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} length - [description] + * @param {number} x - x coordinate of the top point of the triangle. + * @param {number} y - y coordinate of the top point of the triangle. + * @param {number} length - Length of each side of the triangle. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Triangle} The Triangle object of the given size. */ var BuildEquilateral = function (x, y, length) { diff --git a/src/geom/triangle/BuildRight.js b/src/geom/triangle/BuildRight.js index 3cb04b2cd..6a0beaec2 100644 --- a/src/geom/triangle/BuildRight.js +++ b/src/geom/triangle/BuildRight.js @@ -11,17 +11,17 @@ var Triangle = require('./Triangle'); // w/h can be positive or negative and represent the length of each side /** - * [description] + * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. * * @function Phaser.Geom.Triangle.BuildRight * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} x - The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. + * @param {number} y - The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. + * @param {number} width - The length of the side which is to the left or to the right of the right angle. + * @param {number} height - The length of the side which is above or below the right angle. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Triangle} The constructed right Triangle. */ var BuildRight = function (x, y, width, height) { diff --git a/src/geom/triangle/CenterOn.js b/src/geom/triangle/CenterOn.js index 71ebe67e6..0337ef4e0 100644 --- a/src/geom/triangle/CenterOn.js +++ b/src/geom/triangle/CenterOn.js @@ -10,25 +10,25 @@ var Offset = require('./Offset'); /** * @callback CenterFunction * - * @param {Phaser.Geom.Triangle} triangle - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to return the center coordinates of. * - * @return {Phaser.Math.Vector2} [description] + * @return {Phaser.Math.Vector2} The center point of the Triangle according to the function. */ /** - * [description] + * Positions the Triangle so that it is centered on the given coordinates. * * @function Phaser.Geom.Triangle.CenterOn * @since 3.0.0 * * @generic {Phaser.Geom.Triangle} O - [triangle,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {CenterFunction} [centerFunc] - [description] + * @param {Phaser.Geom.Triangle} triangle - The triangle to be positioned. + * @param {number} x - The horizontal coordinate to center on. + * @param {number} y - The vertical coordinate to center on. + * @param {CenterFunction} [centerFunc] - The function used to center the triangle. Defaults to Centroid centering. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Triangle} The Triangle that was centered. */ var CenterOn = function (triangle, x, y, centerFunc) { diff --git a/src/geom/triangle/Centroid.js b/src/geom/triangle/Centroid.js index 299bbd2d9..14378be58 100644 --- a/src/geom/triangle/Centroid.js +++ b/src/geom/triangle/Centroid.js @@ -11,17 +11,19 @@ var Point = require('../point/Point'); // The centroid divides each median in a ratio of 2:1 /** - * [description] + * Calculates the position of a Triangle's centroid, which is also its center of mass (center of gravity). + * + * The centroid is the point in a Triangle at which its three medians (the lines drawn from the vertices to the bisectors of the opposite sides) meet. It divides each one in a 2:1 ratio. * * @function Phaser.Geom.Triangle.Centroid * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to use. + * @param {(Phaser.Geom.Point|object)} [out] - An object to store the coordinates in. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} The `out` object with modified `x` and `y` properties, or a new Point if none was provided. */ var Centroid = function (triangle, out) { diff --git a/src/geom/triangle/CircumCircle.js b/src/geom/triangle/CircumCircle.js index b1c04225f..ce7e8e28d 100644 --- a/src/geom/triangle/CircumCircle.js +++ b/src/geom/triangle/CircumCircle.js @@ -9,17 +9,17 @@ var Circle = require('../circle/Circle'); // Adapted from https://gist.github.com/mutoo/5617691 /** - * [description] + * Finds the circumscribed circle (circumcircle) of a Triangle object. The circumcircle is the circle which touches all of the triangle's vertices. * * @function Phaser.Geom.Triangle.CircumCircle * @since 3.0.0 * * @generic {Phaser.Geom.Circle} O - [out,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Circle} [out] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to use as input. + * @param {Phaser.Geom.Circle} [out] - An optional Circle to store the result in. * - * @return {Phaser.Geom.Circle} [description] + * @return {Phaser.Geom.Circle} The updated `out` Circle, or a new Circle if none was provided. */ var CircumCircle = function (triangle, out) { diff --git a/src/geom/triangle/Clone.js b/src/geom/triangle/Clone.js index ed1b1c42e..cb2489f27 100644 --- a/src/geom/triangle/Clone.js +++ b/src/geom/triangle/Clone.js @@ -7,14 +7,14 @@ var Triangle = require('./Triangle'); /** - * [description] + * Clones a Triangle object. * * @function Phaser.Geom.Triangle.Clone * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} source - [description] + * @param {Phaser.Geom.Triangle} source - The Triangle to clone. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Triangle} A new Triangle identical to the given one but separate from it. */ var Clone = function (source) { diff --git a/src/geom/triangle/Contains.js b/src/geom/triangle/Contains.js index 0b48d189d..529863ccf 100644 --- a/src/geom/triangle/Contains.js +++ b/src/geom/triangle/Contains.js @@ -7,16 +7,16 @@ // http://www.blackpawn.com/texts/pointinpoly/ /** - * [description] + * Checks if a point (as a pair of coordinates) is inside a Triangle's bounds. * * @function Phaser.Geom.Triangle.Contains * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to check. + * @param {number} x - The X coordinate of the point to check. + * @param {number} y - The Y coordinate of the point to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the point is inside the Triangle, otherwise `false`. */ var Contains = function (triangle, x, y) { diff --git a/src/geom/triangle/ContainsArray.js b/src/geom/triangle/ContainsArray.js index d9a039c61..54b7de23a 100644 --- a/src/geom/triangle/ContainsArray.js +++ b/src/geom/triangle/ContainsArray.js @@ -11,17 +11,18 @@ // if 'returnFirst' is true it will return after the first point within the triangle is found /** - * [description] + * Filters an array of point-like objects to only those contained within a triangle. + * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). * * @function Phaser.Geom.Triangle.ContainsArray * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point[]} points - [description] - * @param {boolean} [returnFirst] - [description] - * @param {array} [out] - [description] + * @param {Phaser.Geom.Triangle} triangle - The triangle that the points are being checked in. + * @param {Phaser.Geom.Point[]} points - An array of point-like objects (objects that have an `x` and `y` property) + * @param {boolean} [returnFirst=false] - If `true`, return an array containing only the first point found that is within the triangle. + * @param {array} [out] - If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. * - * @return {Phaser.Geom.Point[]} [description] + * @return {Phaser.Geom.Point[]} An array containing all the points from `points` that are within the triangle, if an array was provided as `out`, points will be appended to that array and it will also be returned here. */ var ContainsArray = function (triangle, points, returnFirst, out) { diff --git a/src/geom/triangle/ContainsPoint.js b/src/geom/triangle/ContainsPoint.js index 9c60fcc55..d01f366ff 100644 --- a/src/geom/triangle/ContainsPoint.js +++ b/src/geom/triangle/ContainsPoint.js @@ -7,15 +7,15 @@ var Contains = require('./Contains'); /** - * [description] + * Tests if a triangle contains a point. * * @function Phaser.Geom.Triangle.ContainsPoint * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] + * @param {Phaser.Geom.Triangle} triangle - The triangle. + * @param {(Phaser.Geom.Point|Phaser.Math.Vector2|any)} point - The point to test, or any point-like object with public `x` and `y` properties. * - * @return {boolean} [description] + * @return {boolean} `true` if the point is within the triangle, otherwise `false`. */ var ContainsPoint = function (triangle, point) { diff --git a/src/geom/triangle/Decompose.js b/src/geom/triangle/Decompose.js index f0fe5be29..45e7dcc1b 100644 --- a/src/geom/triangle/Decompose.js +++ b/src/geom/triangle/Decompose.js @@ -5,15 +5,15 @@ */ /** - * [description] + * Decomposes a Triangle into an array of its points. * * @function Phaser.Geom.Triangle.Decompose * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {array} [out] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to decompose. + * @param {array} [out] - An array to store the points into. * - * @return {array} [description] + * @return {array} The provided `out` array, or a new array if none was provided, with three objects with `x` and `y` properties representing each point of the Triangle appended to it. */ var Decompose = function (triangle, out) { diff --git a/src/geom/triangle/Equals.js b/src/geom/triangle/Equals.js index 25a5c238a..1e90b0d2a 100644 --- a/src/geom/triangle/Equals.js +++ b/src/geom/triangle/Equals.js @@ -5,15 +5,15 @@ */ /** - * [description] + * Returns true if two triangles have the same coordinates. * * @function Phaser.Geom.Triangle.Equals * @since 3.0.0 * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Triangle} toCompare - [description] + * @param {Phaser.Geom.Triangle} triangle - The first triangle to check. + * @param {Phaser.Geom.Triangle} toCompare - The second triangle to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the two given triangles have the exact same coordinates, otherwise `false`. */ var Equals = function (triangle, toCompare) { diff --git a/src/geom/triangle/GetPoint.js b/src/geom/triangle/GetPoint.js index 6e25faed8..bebb585cb 100644 --- a/src/geom/triangle/GetPoint.js +++ b/src/geom/triangle/GetPoint.js @@ -7,20 +7,19 @@ var Point = require('../point/Point'); var Length = require('../line/Length'); -// Position is a value between 0 and 1 /** - * [description] + * Returns a Point from around the perimeter of a Triangle. * * @function Phaser.Geom.Triangle.GetPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} position - [description] - * @param {(Phaser.Geom.Point|object)} [out] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the point on its perimeter from. + * @param {number} position - The position along the perimeter of the triangle. A value between 0 and 1. + * @param {(Phaser.Geom.Point|object)} [out] - An option Point, or Point-like object to store the value in. If not given a new Point will be created. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} A Point object containing the given position from the perimeter of the triangle. */ var GetPoint = function (triangle, position, out) { diff --git a/src/geom/triangle/GetPoints.js b/src/geom/triangle/GetPoints.js index 28cc70485..1cca3f016 100644 --- a/src/geom/triangle/GetPoints.js +++ b/src/geom/triangle/GetPoints.js @@ -8,19 +8,19 @@ var Length = require('../line/Length'); var Point = require('../point/Point'); /** - * [description] + * Returns an array of evenly spaced points on the perimeter of a Triangle. * * @function Phaser.Geom.Triangle.GetPoints * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {integer} quantity - [description] - * @param {number} stepRate - [description] - * @param {(array|Phaser.Geom.Point[])} [out] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to get the points from. + * @param {integer} quantity - The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. + * @param {number} stepRate - If `quantity` is 0, the distance between each returned point. + * @param {(array|Phaser.Geom.Point[])} [out] - An array to which the points should be appended. * - * @return {(array|Phaser.Geom.Point[])} [description] + * @return {(array|Phaser.Geom.Point[])} The modified `out` array, or a new array if none was provided. */ var GetPoints = function (triangle, quantity, stepRate, out) { diff --git a/src/geom/triangle/InCenter.js b/src/geom/triangle/InCenter.js index dd32726dc..9032d7db2 100644 --- a/src/geom/triangle/InCenter.js +++ b/src/geom/triangle/InCenter.js @@ -19,17 +19,17 @@ function getLength (x1, y1, x2, y2) } /** - * [description] + * Calculates the position of the incenter of a Triangle object. This is the point where its three angle bisectors meet and it's also the center of the incircle, which is the circle inscribed in the triangle. * * @function Phaser.Geom.Triangle.InCenter * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} [out] - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to find the incenter of. + * @param {Phaser.Geom.Point} [out] - An optional Point in which to store the coordinates. * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Point} Point (x, y) of the center pixel of the triangle. */ var InCenter = function (triangle, out) { diff --git a/src/geom/triangle/Offset.js b/src/geom/triangle/Offset.js index 78150f552..59a2b1a2a 100644 --- a/src/geom/triangle/Offset.js +++ b/src/geom/triangle/Offset.js @@ -5,18 +5,18 @@ */ /** - * [description] + * Moves each point (vertex) of a Triangle by a given offset, thus moving the entire Triangle by that offset. * * @function Phaser.Geom.Triangle.Offset * @since 3.0.0 * * @generic {Phaser.Geom.Triangle} O - [triangle,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to move. + * @param {number} x - The horizontal offset (distance) by which to move each point. Can be positive or negative. + * @param {number} y - The vertical offset (distance) by which to move each point. Can be positive or negative. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Triangle} The modified Triangle. */ var Offset = function (triangle, x, y) { diff --git a/src/geom/triangle/Perimeter.js b/src/geom/triangle/Perimeter.js index c516750ee..1464b024c 100644 --- a/src/geom/triangle/Perimeter.js +++ b/src/geom/triangle/Perimeter.js @@ -9,7 +9,7 @@ var Length = require('../line/Length'); // The 2D area of a triangle. The area value is always non-negative. /** - * [description] + * Gets the length of the perimeter of the given triangle. * * @function Phaser.Geom.Triangle.Perimeter * @since 3.0.0 diff --git a/src/geom/triangle/Rotate.js b/src/geom/triangle/Rotate.js index 3bd7476e3..ce346325b 100644 --- a/src/geom/triangle/Rotate.js +++ b/src/geom/triangle/Rotate.js @@ -8,17 +8,17 @@ var RotateAroundXY = require('./RotateAroundXY'); var InCenter = require('./InCenter'); /** - * [description] + * Rotates a Triangle about its incenter, which is the point at which its three angle bisectors meet. * * @function Phaser.Geom.Triangle.Rotate * @since 3.0.0 * * @generic {Phaser.Geom.Triangle} O - [triangle,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} angle - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to rotate. + * @param {number} angle - The angle by which to rotate the Triangle, in radians. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Triangle} The rotated Triangle. */ var Rotate = function (triangle, angle) { diff --git a/src/geom/triangle/RotateAroundPoint.js b/src/geom/triangle/RotateAroundPoint.js index 928fda594..2ce76f027 100644 --- a/src/geom/triangle/RotateAroundPoint.js +++ b/src/geom/triangle/RotateAroundPoint.js @@ -7,18 +7,18 @@ var RotateAroundXY = require('./RotateAroundXY'); /** - * [description] + * Rotates a Triangle at a certain angle about a given Point or object with public `x` and `y` properties. * * @function Phaser.Geom.Triangle.RotateAroundPoint * @since 3.0.0 * * @generic {Phaser.Geom.Triangle} O - [triangle,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {Phaser.Geom.Point} point - [description] - * @param {number} angle - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to rotate. + * @param {Phaser.Geom.Point} point - The Point to rotate the Triangle about. + * @param {number} angle - The angle by which to rotate the Triangle, in radians. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Triangle} The rotated Triangle. */ var RotateAroundPoint = function (triangle, point, angle) { diff --git a/src/geom/triangle/RotateAroundXY.js b/src/geom/triangle/RotateAroundXY.js index a9b1cf33d..1a82350c4 100644 --- a/src/geom/triangle/RotateAroundXY.js +++ b/src/geom/triangle/RotateAroundXY.js @@ -5,19 +5,19 @@ */ /** - * [description] + * Rotates an entire Triangle at a given angle about a specific point. * * @function Phaser.Geom.Triangle.RotateAroundXY * @since 3.0.0 * * @generic {Phaser.Geom.Triangle} O - [triangle,$return] * - * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} angle - [description] + * @param {Phaser.Geom.Triangle} triangle - The Triangle to rotate. + * @param {number} x - The X coordinate of the point to rotate the Triangle about. + * @param {number} y - The Y coordinate of the point to rotate the Triangle about. + * @param {number} angle - The angle by which to rotate the Triangle, in radians. * - * @return {Phaser.Geom.Triangle} [description] + * @return {Phaser.Geom.Triangle} The rotated Triangle. */ var RotateAroundXY = function (triangle, x, y, angle) { diff --git a/src/geom/triangle/Triangle.js b/src/geom/triangle/Triangle.js index 643c6494e..e7127e361 100644 --- a/src/geom/triangle/Triangle.js +++ b/src/geom/triangle/Triangle.js @@ -18,16 +18,16 @@ var Random = require('./Random'); * specify the second point, and the last two arguments specify the third point. * * @class Triangle - * @memberOf Phaser.Geom + * @memberof Phaser.Geom * @constructor * @since 3.0.0 * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. */ var Triangle = new Class({ @@ -43,7 +43,7 @@ var Triangle = new Class({ if (y3 === undefined) { y3 = 0; } /** - * [description] + * `x` coordinate of the first point. * * @name Phaser.Geom.Triangle#x1 * @type {number} @@ -53,7 +53,7 @@ var Triangle = new Class({ this.x1 = x1; /** - * [description] + * `y` coordinate of the first point. * * @name Phaser.Geom.Triangle#y1 * @type {number} @@ -63,7 +63,7 @@ var Triangle = new Class({ this.y1 = y1; /** - * [description] + * `x` coordinate of the second point. * * @name Phaser.Geom.Triangle#x2 * @type {number} @@ -73,7 +73,7 @@ var Triangle = new Class({ this.x2 = x2; /** - * [description] + * `y` coordinate of the second point. * * @name Phaser.Geom.Triangle#y2 * @type {number} @@ -83,7 +83,7 @@ var Triangle = new Class({ this.y2 = y2; /** - * [description] + * `x` coordinate of the third point. * * @name Phaser.Geom.Triangle#x3 * @type {number} @@ -93,7 +93,7 @@ var Triangle = new Class({ this.x3 = x3; /** - * [description] + * `y` coordinate of the third point. * * @name Phaser.Geom.Triangle#y3 * @type {number} @@ -104,15 +104,15 @@ var Triangle = new Class({ }, /** - * [description] + * Checks whether a given points lies within the triangle. * * @method Phaser.Geom.Triangle#contains * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The x coordinate of the point to check. + * @param {number} y - The y coordinate of the point to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the coordinate pair is within the triangle, otherwise `false`. */ contains: function (x, y) { @@ -120,17 +120,17 @@ var Triangle = new Class({ }, /** - * [description] + * Returns a specific point on the triangle. * * @method Phaser.Geom.Triangle#getPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [output,$return] * - * @param {number} position - [description] - * @param {(Phaser.Geom.Point|object)} [output] - [description] + * @param {number} position - Position as float within `0` and `1`. `0` equals the first point. + * @param {(Phaser.Geom.Point|object)} [output] - Optional Point, or point-like object, that the calculated point will be written to. * - * @return {(Phaser.Geom.Point|object)} [description] + * @return {(Phaser.Geom.Point|object)} Calculated `Point` that represents the requested position. It is the same as `output` when this parameter has been given. */ getPoint: function (position, output) { @@ -138,18 +138,18 @@ var Triangle = new Class({ }, /** - * [description] + * Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (`quantity`) or the distance between two points (`stepRate`). * * @method Phaser.Geom.Triangle#getPoints * @since 3.0.0 * * @generic {Phaser.Geom.Point[]} O - [output,$return] * - * @param {integer} quantity - [description] - * @param {number} [stepRate] - [description] - * @param {(array|Phaser.Geom.Point[])} [output] - [description] + * @param {integer} quantity - Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. + * @param {number} [stepRate] - Distance between two points. Will only be used when `quantity` is falsey. + * @param {(array|Phaser.Geom.Point[])} [output] - Optional Array for writing the calculated points into. Otherwise a new array will be created. * - * @return {(array|Phaser.Geom.Point[])} [description] + * @return {(array|Phaser.Geom.Point[])} Returns a list of calculated `Point` instances or the filled array passed as parameter `output`. */ getPoints: function (quantity, stepRate, output) { @@ -157,16 +157,16 @@ var Triangle = new Class({ }, /** - * [description] + * Returns a random point along the triangle. * * @method Phaser.Geom.Triangle#getRandomPoint * @since 3.0.0 * * @generic {Phaser.Geom.Point} O - [point,$return] * - * @param {Phaser.Geom.Point} [point] - [description] + * @param {Phaser.Geom.Point} [point] - Optional `Point` that should be modified. Otherwise a new one will be created. * - * @return {Phaser.Geom.Point} [description] + * @return {Phaser.Geom.Point} Random `Point`. When parameter `point` has been provided it will be returned. */ getRandomPoint: function (point) { @@ -174,17 +174,17 @@ var Triangle = new Class({ }, /** - * [description] + * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. * * @method Phaser.Geom.Triangle#setTo * @since 3.0.0 * - * @param {number} [x1=0] - [description] - * @param {number} [y1=0] - [description] - * @param {number} [x2=0] - [description] - * @param {number} [y2=0] - [description] - * @param {number} [x3=0] - [description] - * @param {number} [y3=0] - [description] + * @param {number} [x1=0] - `x` coordinate of the first point. + * @param {number} [y1=0] - `y` coordinate of the first point. + * @param {number} [x2=0] - `x` coordinate of the second point. + * @param {number} [y2=0] - `y` coordinate of the second point. + * @param {number} [x3=0] - `x` coordinate of the third point. + * @param {number} [y3=0] - `y` coordinate of the third point. * * @return {Phaser.Geom.Triangle} This Triangle object. */ @@ -273,7 +273,7 @@ var Triangle = new Class({ }, /** - * [description] + * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. * * @name Phaser.Geom.Triangle#left * @type {number} @@ -311,7 +311,7 @@ var Triangle = new Class({ }, /** - * [description] + * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. * * @name Phaser.Geom.Triangle#right * @type {number} @@ -349,7 +349,7 @@ var Triangle = new Class({ }, /** - * [description] + * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. * * @name Phaser.Geom.Triangle#top * @type {number} @@ -387,7 +387,7 @@ var Triangle = new Class({ }, /** - * [description] + * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. * * @name Phaser.Geom.Triangle#bottom * @type {number} diff --git a/src/input/CreatePixelPerfectHandler.js b/src/input/CreatePixelPerfectHandler.js index c91b63182..983727510 100644 --- a/src/input/CreatePixelPerfectHandler.js +++ b/src/input/CreatePixelPerfectHandler.js @@ -21,7 +21,7 @@ var CreatePixelPerfectHandler = function (textureManager, alphaTolerance) { return function (hitArea, x, y, gameObject) { - var alpha = textureManager.getPixelAlpha(x, y, gameObject.texture.key, gameObject.frame.key); + var alpha = textureManager.getPixelAlpha(x, y, gameObject.texture.key, gameObject.frame.name); return (alpha && alpha >= alphaTolerance); }; diff --git a/src/input/InputManager.js b/src/input/InputManager.js index ec2ae3f37..f968fe9df 100644 --- a/src/input/InputManager.js +++ b/src/input/InputManager.js @@ -7,6 +7,7 @@ var Class = require('../utils/Class'); var CONST = require('./const'); var EventEmitter = require('eventemitter3'); +var Keyboard = require('./keyboard/KeyboardManager'); var Mouse = require('./mouse/MouseManager'); var Pointer = require('./Pointer'); var Rectangle = require('../geom/rectangle/Rectangle'); @@ -29,7 +30,7 @@ var TransformXY = require('../math/TransformXY'); * for dealing with all input events for a Scene. * * @class InputManager - * @memberOf Phaser.Input + * @memberof Phaser.Input * @constructor * @since 3.0.0 * @@ -48,7 +49,7 @@ var InputManager = new Class({ * * @name Phaser.Input.InputManager#game * @type {Phaser.Game} - * @readOnly + * @readonly * @since 3.0.0 */ this.game = game; @@ -63,10 +64,10 @@ var InputManager = new Class({ this.canvas; /** - * The Input Configuration object, as set in the Game Config. + * The Game Configuration object, as set during the game boot. * * @name Phaser.Input.InputManager#config - * @type {object} + * @type {Phaser.Boot.Config} * @since 3.0.0 */ this.config = config; @@ -110,6 +111,27 @@ var InputManager = new Class({ */ this.domCallbacks = { up: [], down: [], move: [], upOnce: [], downOnce: [], moveOnce: [] }; + /** + * Are any mouse or touch pointers currently over the game canvas? + * This is updated automatically by the canvas over and out handlers. + * + * @name Phaser.Input.InputManager#isOver + * @type {boolean} + * @readonly + * @since 3.16.0 + */ + this.isOver = true; + + /** + * isOver state change property. + * + * @name Phaser.Input.InputManager#_emitIsOverEvent + * @type {boolean} + * @private + * @since 3.16.0 + */ + this._emitIsOverEvent = false; + /** * Are there any up callbacks defined? * @@ -175,6 +197,15 @@ var InputManager = new Class({ */ this.defaultCursor = ''; + /** + * A reference to the Keyboard Manager class, if enabled via the `input.keyboard` Game Config property. + * + * @name Phaser.Input.InputManager#keyboard + * @type {?Phaser.Input.Keyboard.KeyboardManager} + * @since 3.16.0 + */ + this.keyboard = (config.inputKeyboard) ? new Keyboard(this) : null; + /** * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. * @@ -214,7 +245,7 @@ var InputManager = new Class({ * * @name Phaser.Input.InputManager#pointersTotal * @type {integer} - * @readOnly + * @readonly * @since 3.10.0 */ this.pointersTotal = config.inputActivePointers; @@ -226,7 +257,11 @@ var InputManager = new Class({ for (var i = 0; i <= this.pointersTotal; i++) { - this.pointers.push(new Pointer(this, i)); + var pointer = new Pointer(this, i); + + pointer.smoothFactor = config.inputSmoothFactor; + + this.pointers.push(pointer); } /** @@ -336,6 +371,16 @@ var InputManager = new Class({ */ this._tempMatrix = new TransformMatrix(); + /** + * A re-cycled matrix used in hit test calculations. + * + * @name Phaser.Input.InputManager#_tempMatrix2 + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + game.events.once('boot', this.boot, this); }, @@ -402,6 +447,38 @@ var InputManager = new Class({ this.scale.y = gh / bh; }, + /** + * Internal canvas state change, called automatically by the Mouse Manager. + * + * @method Phaser.Input.InputManager#setCanvasOver + * @private + * @since 3.16.0 + * + * @param {number} event - The DOM Event. + */ + setCanvasOver: function (event) + { + this.isOver = true; + + this._emitIsOverEvent = event; + }, + + /** + * Internal canvas state change, called automatically by the Mouse Manager. + * + * @method Phaser.Input.InputManager#setCanvasOut + * @private + * @since 3.16.0 + * + * @param {number} event - The DOM Event. + */ + setCanvasOut: function (event) + { + this.isOver = false; + + this._emitIsOverEvent = event; + }, + /** * Internal update loop, called automatically by the Game Step. * @@ -429,11 +506,16 @@ var InputManager = new Class({ for (i = 0; i < this.pointersTotal; i++) { - pointers[i].reset(); + pointers[i].reset(time); } if (!this.enabled || len === 0) { + for (i = 0; i < this.pointersTotal; i++) + { + pointers[i].updateMotion(); + } + return; } @@ -481,11 +563,20 @@ var InputManager = new Class({ this.stopPointer(event, time); break; + case CONST.TOUCH_CANCEL: + this.cancelPointer(event, time); + break; + case CONST.POINTER_LOCK_CHANGE: this.events.emit('pointerlockchange', event, this.mouse.locked); break; } } + + for (i = 0; i < this.pointersTotal; i++) + { + pointers[i].updateMotion(); + } }, /** @@ -505,6 +596,9 @@ var InputManager = new Class({ { this.canvas.style.cursor = this.defaultCursor; } + + // Reset the isOver event + this._emitIsOverEvent = null; }, /** @@ -686,6 +780,37 @@ var InputManager = new Class({ } }, + /** + * Called by the main update loop when a Touch Cancel Event is received. + * + * @method Phaser.Input.InputManager#cancelPointer + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The native DOM event to be processed. + * @param {number} time - The time stamp value of this game step. + */ + cancelPointer: function (event, time) + { + var pointers = this.pointers; + + for (var c = 0; c < event.changedTouches.length; c++) + { + var changedTouch = event.changedTouches[c]; + + for (var i = 1; i < this.pointersTotal; i++) + { + var pointer = pointers[i]; + + if (pointer.active && pointer.identifier === changedTouch.identifier) + { + pointer.touchend(changedTouch, time); + break; + } + } + } + }, + /** * Adds new Pointer objects to the Input Manager. * @@ -721,6 +846,8 @@ var InputManager = new Class({ var pointer = new Pointer(this, id); + pointer.smoothFactor = this.config.inputSmoothFactor; + this.pointers.push(pointer); this.pointersTotal++; @@ -829,6 +956,21 @@ var InputManager = new Class({ } }, + /** + * Queues a touch cancel event, as passed in by the TouchManager. + * Also dispatches any DOM callbacks for this event. + * + * @method Phaser.Input.InputManager#queueTouchCancel + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The native DOM Touch event. + */ + queueTouchCancel: function (event) + { + this.queue.push(CONST.TOUCH_CANCEL, event); + }, + /** * Queues a mouse down event, as passed in by the MouseManager. * Also dispatches any DOM callbacks for this event. @@ -1050,14 +1192,15 @@ var InputManager = new Class({ * @since 3.10.0 * * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to test. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera which is being tested against. * * @return {boolean} `true` if the Game Object should be considered for input, otherwise `false`. */ - inputCandidate: function (gameObject) + inputCandidate: function (gameObject, camera) { var input = gameObject.input; - if (!input || !input.enabled || !gameObject.willRender()) + if (!input || !input.enabled || !gameObject.willRender(camera)) { return false; } @@ -1069,7 +1212,7 @@ var InputManager = new Class({ { do { - if (!parent.visible) + if (!parent.willRender(camera)) { visible = false; break; @@ -1108,17 +1251,19 @@ var InputManager = new Class({ if (output === undefined) { output = this._tempHitTest; } var tempPoint = this._tempPoint; - var cameraW = camera.width; - var cameraH = camera.height; + + var csx = camera.scrollX; + var csy = camera.scrollY; output.length = 0; var x = pointer.x; var y = pointer.y; - if (!(x >= camera.x && y >= camera.y && x <= camera.x + cameraW && y <= camera.y + cameraH)) + if (camera.resolution !== 1) { - return output; + x += camera._x; + y += camera._y; } // Stores the world point inside of tempPoint @@ -1127,38 +1272,36 @@ var InputManager = new Class({ pointer.worldX = tempPoint.x; pointer.worldY = tempPoint.y; - // Disable until fixed. - // var culledGameObjects = camera.cull(gameObjects); - var point = { x: 0, y: 0 }; - var res = this.game.config.resolution; - var matrix = this._tempMatrix; + var parentMatrix = this._tempMatrix2; for (var i = 0; i < gameObjects.length; i++) { var gameObject = gameObjects[i]; - if (!this.inputCandidate(gameObject)) + // Checks if the Game Object can receive input (isn't being ignored by the camera, invisible, etc) + // and also checks all of its parents, if any + if (!this.inputCandidate(gameObject, camera)) { continue; } - var px = tempPoint.x * res + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX; - var py = tempPoint.y * res + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY; + var px = tempPoint.x + (csx * gameObject.scrollFactorX) - csx; + var py = tempPoint.y + (csy * gameObject.scrollFactorY) - csy; if (gameObject.parentContainer) { - gameObject.getWorldTransformMatrix(matrix); + gameObject.getWorldTransformMatrix(matrix, parentMatrix); - TransformXY(px, py, matrix.tx, matrix.ty, matrix.rotation, matrix.scaleX, matrix.scaleY, point); + matrix.applyInverse(px, py, point); } else { TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point); } - + if (this.pointWithinHitArea(gameObject, point.x, point.y)) { output.push(gameObject); @@ -1245,13 +1388,37 @@ var InputManager = new Class({ * @since 3.10.0 * * @param {Phaser.Input.Pointer} pointer - The Pointer to transform the values for. - * - * @return {number} The translated value. + * @param {number} pageX - The Page X value. + * @param {number} pageY - The Page Y value. + * @param {boolean} wasMove - Are we transforming the Pointer from a move event, or an up / down event? */ - transformPointer: function (pointer, pageX, pageY) + transformPointer: function (pointer, pageX, pageY, wasMove) { - pointer.x = (pageX - this.bounds.left) * this.scale.x; - pointer.y = (pageY - this.bounds.top) * this.scale.y; + var p0 = pointer.position; + var p1 = pointer.prevPosition; + + // Store previous position + p1.x = p0.x; + p1.y = p0.y; + + // Translate coordinates + var x = (pageX - this.bounds.left) * this.scale.x; + var y = (pageY - this.bounds.top) * this.scale.y; + + var a = pointer.smoothFactor; + + if (!wasMove || a === 0) + { + // Set immediately + p0.x = x; + p0.y = y; + } + else + { + // Apply smoothing + p0.x = x * a + p1.x * (1 - a); + p0.y = y * a + p1.y * (1 - a); + } }, /** @@ -1348,6 +1515,11 @@ var InputManager = new Class({ { this.events.removeAllListeners(); + if (this.keyboard) + { + this.keyboard.destroy(); + } + if (this.mouse) { this.mouse.destroy(); diff --git a/src/input/InputPlugin.js b/src/input/InputPlugin.js index 497cc981f..46c698604 100644 --- a/src/input/InputPlugin.js +++ b/src/input/InputPlugin.js @@ -49,7 +49,7 @@ var TriangleContains = require('../geom/triangle/Contains'); * * @class InputPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input + * @memberof Phaser.Input * @constructor * @since 3.0.0 * @@ -201,6 +201,33 @@ var InputPlugin = new Class({ */ this._pollTimer = 0; + var _eventData = { cancelled: false }; + + /** + * Internal event propagation callback container. + * + * @name Phaser.Input.InputPlugin#_eventContainer + * @type {object} + * @private + * @since 3.13.0 + */ + this._eventContainer = { + stopPropagation: function () + { + _eventData.cancelled = true; + } + }; + + /** + * Internal event propagation data object. + * + * @name Phaser.Input.InputPlugin#_eventData + * @type {object} + * @private + * @since 3.13.0 + */ + this._eventData = _eventData; + /** * The distance, in pixels, a pointer has to move while being held down, before it thinks it is being dragged. * @@ -379,7 +406,7 @@ var InputPlugin = new Class({ preUpdate: function () { // Registered input plugins listen for this - this.pluginEvents.emit('preUpdate'); + this.pluginEvents.emit('preupdate'); var removeList = this._pendingRemoval; var insertList = this._pendingInsertion; @@ -449,16 +476,23 @@ var InputPlugin = new Class({ return; } - this.pluginEvents.emit('update', time, delta); - var manager = this.manager; + this.pluginEvents.emit('update', time, delta); + // Another Scene above this one has already consumed the input events, or we're in transition if (manager.globalTopOnly && manager.ignoreEvents) { return; } + if (manager._emitIsOverEvent) + { + var event = (manager.isOver) ? 'gameover' : 'gameout'; + + this.emit(event, time, manager._emitIsOverEvent); + } + var runUpdate = (manager.dirty || this.pollRate === 0); if (this.pollRate > -1) @@ -521,16 +555,16 @@ var InputPlugin = new Class({ total += this.processDownEvents(pointer); } - if (pointer.justUp) - { - total += this.processUpEvents(pointer); - } - if (pointer.justMoved) { total += this.processMoveEvents(pointer); } + if (pointer.justUp) + { + total += this.processUpEvents(pointer); + } + if (total > 0 && manager.globalTopOnly) { // We interacted with an event in this Scene, so block any Scenes below us from doing the same this frame @@ -568,6 +602,8 @@ var InputPlugin = new Class({ input.hitAreaCallback = undefined; input.callbackContext = undefined; + this.manager.resetCursor(input); + gameObject.input = null; // Clear from _draggable, _drag and _over @@ -719,6 +755,10 @@ var InputPlugin = new Class({ * * @method Phaser.Input.InputPlugin#processDownEvents * @private + * @fires Phaser.GameObjects.GameObject#pointerdownEvent + * @fires Phaser.Input.InputPlugin#gameobjectdownEvent + * @fires Phaser.Input.InputPlugin#pointerdownEvent + * @fires Phaser.Input.InputPlugin#pointerdownoutsideEvent * @since 3.0.0 * * @param {Phaser.Input.Pointer} pointer - The Pointer being tested. @@ -727,12 +767,15 @@ var InputPlugin = new Class({ */ processDownEvents: function (pointer) { + var total = 0; var currentlyOver = this._temp; - // Contains ALL Game Objects currently over in the array - this.emit('pointerdown', pointer, currentlyOver); + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; - var total = 0; + _eventData.cancelled = false; + + var aborted = false; // Go through all objects the pointer was over and fire their events / callbacks for (var i = 0; i < currentlyOver.length; i++) @@ -746,9 +789,30 @@ var InputPlugin = new Class({ total++; - gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, pointer.camera); + gameObject.emit('pointerdown', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); - this.emit('gameobjectdown', pointer, gameObject); + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectdown', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + // If they released outside the canvas, but pressed down inside it, we'll still dispatch the event. + if (!aborted) + { + var type = (pointer.downElement === this.manager.game.canvas) ? 'pointerdown' : 'pointerdownoutside'; + + // Contains ALL Game Objects currently up in the array + this.emit(type, pointer, currentlyOver); } return total; @@ -759,6 +823,20 @@ var InputPlugin = new Class({ * * @method Phaser.Input.InputPlugin#processDragEvents * @private + * @fires Phaser.GameObjects.GameObject#dragendEvent + * @fires Phaser.GameObjects.GameObject#dragenterEvent + * @fires Phaser.GameObjects.GameObject#dragEvent + * @fires Phaser.GameObjects.GameObject#dragleaveEvent + * @fires Phaser.GameObjects.GameObject#dragoverEvent + * @fires Phaser.GameObjects.GameObject#dragstartEvent + * @fires Phaser.GameObjects.GameObject#dropEvent + * @fires Phaser.Input.InputPlugin#dragendEvent + * @fires Phaser.Input.InputPlugin#dragenterEvent + * @fires Phaser.Input.InputPlugin#dragEvent + * @fires Phaser.Input.InputPlugin#dragleaveEvent + * @fires Phaser.Input.InputPlugin#dragoverEvent + * @fires Phaser.Input.InputPlugin#dragstartEvent + * @fires Phaser.Input.InputPlugin#dropEvent * @since 3.0.0 * * @param {Phaser.Input.Pointer} pointer - The Pointer to check against the Game Objects. @@ -1027,6 +1105,8 @@ var InputPlugin = new Class({ * * @method Phaser.Input.InputPlugin#processMoveEvents * @private + * @fires Phaser.GameObjects.GameObject#pointermoveEvent + * @fires Phaser.Input.InputPlugin#gameobjectmoveEvent * @since 3.0.0 * * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. @@ -1035,11 +1115,15 @@ var InputPlugin = new Class({ */ processMoveEvents: function (pointer) { + var total = 0; var currentlyOver = this._temp; - this.emit('pointermove', pointer, currentlyOver); + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; - var total = 0; + _eventData.cancelled = false; + + var aborted = false; // Go through all objects the pointer was over and fire their events / callbacks for (var i = 0; i < currentlyOver.length; i++) @@ -1053,9 +1137,21 @@ var InputPlugin = new Class({ total++; - gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY); + gameObject.emit('pointermove', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); - this.emit('gameobjectmove', pointer, gameObject); + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectmove', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } if (this.topOnly) { @@ -1063,6 +1159,11 @@ var InputPlugin = new Class({ } } + if (!aborted) + { + this.emit('pointermove', pointer, currentlyOver); + } + return total; }, @@ -1071,6 +1172,10 @@ var InputPlugin = new Class({ * * @method Phaser.Input.InputPlugin#processOverOutEvents * @private + * @fires Phaser.GameObjects.GameObject#pointeroutEvent + * @fires Phaser.GameObjects.GameObject#pointeroverEvent + * @fires Phaser.Input.InputPlugin#gameobjectoutEvent + * @fires Phaser.Input.InputPlugin#gameobjectoverEvent * @since 3.0.0 * * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. @@ -1131,12 +1236,17 @@ var InputPlugin = new Class({ var totalInteracted = 0; + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; + if (total > 0) { this.sortGameObjects(justOut); - this.emit('pointerout', pointer, justOut); - // Call onOut for everything in the justOut array for (i = 0; i < total; i++) { @@ -1147,25 +1257,44 @@ var InputPlugin = new Class({ continue; } - this.emit('gameobjectout', pointer, gameObject); - - gameObject.emit('pointerout', pointer); + gameObject.emit('pointerout', pointer, _eventContainer); manager.resetCursor(gameObject.input); totalInteracted++; + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectout', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + this.emit('pointerout', pointer, justOut); } } // Process the Just Over objects total = justOver.length; + _eventData.cancelled = false; + + aborted = false; + if (total > 0) { this.sortGameObjects(justOver); - this.emit('pointerover', pointer, justOver); - // Call onOver for everything in the justOver array for (i = 0; i < total; i++) { @@ -1176,13 +1305,30 @@ var InputPlugin = new Class({ continue; } - this.emit('gameobjectover', pointer, gameObject); - - gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY); + gameObject.emit('pointerover', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); manager.setCursor(gameObject.input); totalInteracted++; + + if (_eventData.cancelled) + { + aborted = true; + break; + } + + this.emit('gameobjectover', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + if (!aborted) + { + this.emit('pointerover', pointer, justOver); } } @@ -1200,6 +1346,9 @@ var InputPlugin = new Class({ * * @method Phaser.Input.InputPlugin#processUpEvents * @private + * @fires Phaser.GameObjects.GameObject#pointerupEvent + * @fires Phaser.Input.InputPlugin#gameobjectupEvent + * @fires Phaser.Input.InputPlugin#gameobjectupoutsideEvent * @since 3.0.0 * * @param {Phaser.Input.Pointer} pointer - The pointer to check for events against. @@ -1210,8 +1359,12 @@ var InputPlugin = new Class({ { var currentlyOver = this._temp; - // Contains ALL Game Objects currently up in the array - this.emit('pointerup', pointer, currentlyOver); + var _eventData = this._eventData; + var _eventContainer = this._eventContainer; + + _eventData.cancelled = false; + + var aborted = false; // Go through all objects the pointer was over and fire their events / callbacks for (var i = 0; i < currentlyOver.length; i++) @@ -1223,11 +1376,30 @@ var InputPlugin = new Class({ continue; } - // pointerupoutside + gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY, _eventContainer); - gameObject.emit('pointerup', pointer, gameObject.input.localX, gameObject.input.localY); + if (_eventData.cancelled) + { + aborted = true; + break; + } - this.emit('gameobjectup', pointer, gameObject); + this.emit('gameobjectup', pointer, gameObject, _eventContainer); + + if (_eventData.cancelled) + { + aborted = true; + break; + } + } + + // If they released outside the canvas, but pressed down inside it, we'll still dispatch the event. + if (!aborted) + { + var type = (pointer.upElement === this.manager.game.canvas) ? 'pointerup' : 'pointerupoutside'; + + // Contains ALL Game Objects currently up in the array + this.emit(type, pointer, currentlyOver); } return currentlyOver.length; @@ -1545,20 +1717,20 @@ var InputPlugin = new Class({ var width = 0; var height = 0; - if (frame) - { - width = frame.realWidth; - height = frame.realHeight; - } - else if (gameObject.width) + if (gameObject.width) { width = gameObject.width; height = gameObject.height; } + else if (frame) + { + width = frame.realWidth; + height = frame.realHeight; + } if (gameObject.type === 'Container' && (width === 0 || height === 0)) { - console.warn('Container.setInteractive() must specify a Shape or call setSize() first'); + console.warn('Container.setInteractive must specify a Shape or call setSize() first'); continue; } @@ -2108,7 +2280,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#x * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ x: { @@ -2126,7 +2298,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#y * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ y: { @@ -2138,6 +2310,23 @@ var InputPlugin = new Class({ }, + /** + * Are any mouse or touch pointers currently over the game canvas? + * + * @name Phaser.Input.InputPlugin#isOver + * @type {boolean} + * @readonly + * @since 3.16.0 + */ + isOver: { + + get: function () + { + return this.manager.isOver; + } + + }, + /** * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` @@ -2145,7 +2334,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#mousePointer * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ mousePointer: { @@ -2162,7 +2351,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#activePointer * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.0.0 */ activePointer: { @@ -2180,7 +2369,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer1 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer1: { @@ -2198,7 +2387,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer2 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer2: { @@ -2216,7 +2405,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer3 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer3: { @@ -2234,7 +2423,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer4 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer4: { @@ -2252,7 +2441,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer5 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer5: { @@ -2270,7 +2459,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer6 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer6: { @@ -2288,7 +2477,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer7 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer7: { @@ -2306,7 +2495,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer8 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer8: { @@ -2324,7 +2513,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer9 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer9: { @@ -2342,7 +2531,7 @@ var InputPlugin = new Class({ * * @name Phaser.Input.InputPlugin#pointer10 * @type {Phaser.Input.Pointer} - * @readOnly + * @readonly * @since 3.10.0 */ pointer10: { @@ -2359,3 +2548,171 @@ var InputPlugin = new Class({ PluginCache.register('InputPlugin', InputPlugin, 'input'); module.exports = InputPlugin; + +/** + * A Pointer stopped dragging the Game Object. + * @event Phaser.GameObjects.GameObject#dragendEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer that was dragging this Game Object. + * @param {number} dragX - The x coordinate where the Pointer is dragging the object, in world space. + * @param {number} dragY - The y coordinate where the Pointer is dragging the object, in world space. + * @param {boolean} dropped - True if the object was dropped within its drop target. (In that case, 'drop' was emitted before this.) + * + * The Game Object entered its drop target, while being dragged. + * @event Phaser.GameObjects.GameObject#dragenterEvent + * @param {Phaser.Input.Pointer} pointer - The pointer dragging this Game Object. + * @param {Phaser.GameObjects.GameObject} target - The Game Object's drop target. + * + * The Game Object is being dragged by a Pointer. + * @event Phaser.GameObjects.GameObject#dragEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object. + * @param {number} dragX - The x coordinate where the Pointer is dragging the object, in world space. + * @param {number} dragY - The y coordinate where the Pointer is dragging the object, in world space. + * + * The Game Object left its drop target, while being dragged. + * @event Phaser.GameObjects.GameObject#dragleaveEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object. + * @param {Phaser.GameObjects.GameObject} target - The Game Object's drop target. + * + * The Game Object is within its drop target, while being dragged. + * @event Phaser.GameObjects.GameObject#dragoverEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object. + * @param {Phaser.GameObjects.GameObject} target - The Game Object's drop target. + * + * A Pointer began dragging the Game Object. + * @event Phaser.GameObjects.GameObject#dragstartEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object. + * @param {number} dragX - The x coordinate where the Pointer is dragging the object, in world space. + * @param {number} dragY - The y coordinate where the Pointer is dragging the object, in world space. + * + * The Game Object was released on its drop target, after being dragged. + * @event Phaser.GameObjects.GameObject#dropEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer dragging this Game Object. + * @param {Phaser.GameObjects.GameObject} target - The Game Object's drop target. + * + * A Pointer was pressed on the Game Object. + * @event Phaser.GameObjects.GameObject#pointerdownEvent + * @param {Phaser.Input.Pointer} + * @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {object} eventContainer + * + * A Pointer moved while over the Game Object. + * @event Phaser.GameObjects.GameObject#pointermoveEvent + * @param {Phaser.Input.Pointer} + * @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {object} eventContainer + * + * A Pointer left the Game Object, after being over it. + * @event Phaser.GameObjects.GameObject#pointeroutEvent + * @param {Phaser.Input.Pointer} - The Pointer. + * @param {object} eventContainer + * + * A Pointer entered the Game Object, after being outside it. + * @event Phaser.GameObjects.GameObject#pointeroverEvent + * @param {Phaser.Input.Pointer} - The Pointer. + * @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {object} eventContainer + * + * A Pointer was released while over the Game Object, after being pressed on the Game Object. + * @event Phaser.GameObjects.GameObject#pointerupEvent + * @param {Phaser.Input.Pointer} - The Pointer. + * @param {number} localX - The x coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {number} localY - The y coordinate that the Pointer interacted with this object on, relative to the Game Object's top-left position. + * @param {object} eventContainer + */ + +/** + * A Game Object was released, after being dragged. + * @event Phaser.Input.InputPlugin#dragendEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {boolean} dropped - True if the Game Object was dropped onto its drop target. + * + * A dragged Game Object entered it drop target. + * @event Phaser.Input.InputPlugin#dragenterEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {Phaser.GameObjects.GameObject} target - The drop target. + * + * A Game Object is being dragged by a Pointer. + * @event Phaser.Input.InputPlugin#dragEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {number} dragX - The x coordinate where the Pointer is dragging the object, in world space. + * @param {number} dragY - The y coordinate where the Pointer is dragging the object, in world space. + * + * A dragged Game Object left its drop target. + * @event Phaser.Input.InputPlugin#dragleaveEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {?Phaser.GameObjects.GameObject} target - The drop target. + * + * A dragged Game Object is within its drop target. + * @event Phaser.Input.InputPlugin#dragoverEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {?Phaser.GameObjects.GameObject} target - The drop target. + * + * A Pointer started dragging a Game Object. + * @event Phaser.Input.InputPlugin#dragstartEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * + * A Game Object was dropped within its drop target. + * @event Phaser.Input.InputPlugin#dropEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {?Phaser.GameObjects.GameObject} target - The drop target. + * + * A Pointer was pressed while over a Game Object. + * @event Phaser.Input.InputPlugin#gameobjectdownEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {object} eventContainer + * + * A Pointer moved while over a Game Object. + * @event Phaser.Input.InputPlugin#gameobjectmoveEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {object} eventContainer + * + * A Pointer moved off of a Game Object, after being over it. + * @event Phaser.Input.InputPlugin#gameobjectoutEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {object} eventContainer + * + * A Pointer moved onto a Game Object, after being off it. + * @event Phaser.Input.InputPlugin#gameobjectoverEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {object} eventContainer + * + * A Pointer was released while over a Game Object, after being pressed on the Game Object. + * @event Phaser.Input.InputPlugin#gameobjectupEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object. + * @param {object} eventContainer + * + * A Pointer was pressed down. + * @event Phaser.Input.InputPlugin#pointerdownEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject[]} currentlyOver - All the Game Objects currently under the Pointer. + * + * A Pointer was released, after being pressed down. + * @event Phaser.Input.InputPlugin#pointerupEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject[]} currentlyOver - All the Game Objects currently under the Pointer. + * + * A Pointer was pressed down outside of the game canvas. + * @event Phaser.Input.InputPlugin#pointerdownoutsideEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject[]} currentlyOver - All the Game Objects currently under the Pointer. + * + * A Pointer was released outside of the game canvas. + * @event Phaser.Input.InputPlugin#pointerupoutsideEvent + * @param {Phaser.Input.Pointer} pointer - The Pointer. + * @param {Phaser.GameObjects.GameObject[]} currentlyOver - All the Game Objects currently under the Pointer. + */ diff --git a/src/input/Pointer.js b/src/input/Pointer.js index e21121238..020135c81 100644 --- a/src/input/Pointer.js +++ b/src/input/Pointer.js @@ -4,7 +4,11 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var Angle = require('../math/angle/Between'); var Class = require('../utils/Class'); +var Distance = require('../math/distance/DistanceBetween'); +var FuzzyEqual = require('../math/fuzzy/Equal'); +var SmoothStepInterpolation = require('../math/interpolation/SmoothStepInterpolation'); var Vector2 = require('../math/Vector2'); /** @@ -23,7 +27,7 @@ var Vector2 = require('../math/Vector2'); * callbacks. * * @class Pointer - * @memberOf Phaser.Input + * @memberof Phaser.Input * @constructor * @since 3.0.0 * @@ -50,7 +54,7 @@ var Pointer = new Class({ * * @name Phaser.Input.Pointer#id * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.id = id; @@ -64,6 +68,26 @@ var Pointer = new Class({ */ this.event; + /** + * The DOM element the Pointer was pressed down on, taken from the DOM event. + * + * @name Phaser.Input.Pointer#downElement + * @type {any} + * @readonly + * @since 3.16.0 + */ + this.downElement; + + /** + * The DOM element the Pointer was released on, taken from the DOM event. + * + * @name Phaser.Input.Pointer#upElement + * @type {any} + * @readonly + * @since 3.16.0 + */ + this.upElement; + /** * The camera the Pointer interacted with during its last update. * @@ -100,10 +124,119 @@ var Pointer = new Class({ * * @name Phaser.Input.Pointer#position * @type {Phaser.Math.Vector2} + * @readonly * @since 3.0.0 */ this.position = new Vector2(); + /** + * The previous position of the Pointer in screen space. + * + * The old x and y values are stored in here during the InputManager.transformPointer call. + * + * Use the properties `velocity`, `angle` and `distance` to create your own gesture recognition. + * + * @name Phaser.Input.Pointer#prevPosition + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.11.0 + */ + this.prevPosition = new Vector2(); + + /** + * An internal vector used for calculations of the pointer speed and angle. + * + * @name Phaser.Input.Pointer#midPoint + * @type {Phaser.Math.Vector2} + * @private + * @since 3.16.0 + */ + this.midPoint = new Vector2(-1, -1); + + /** + * The current velocity of the Pointer, based on its current and previous positions. + * + * This value is smoothed out each frame, according to the `motionFactor` property. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + * + * @name Phaser.Input.Pointer#velocity + * @type {Phaser.Math.Vector2} + * @readonly + * @since 3.16.0 + */ + this.velocity = new Vector2(); + + /** + * The current angle the Pointer is moving, in radians, based on its previous and current position. + * + * The angle is based on the old position facing to the current position. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + * + * @name Phaser.Input.Pointer#angle + * @type {number} + * @readonly + * @since 3.16.0 + */ + this.angle = 0; + + /** + * The distance the Pointer has moved, based on its previous and current position. + * + * This value is smoothed out each frame, according to the `motionFactor` property. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + * + * If you need the total distance travelled since the primary buttons was pressed down, + * then use the `Pointer.getDistance` method. + * + * @name Phaser.Input.Pointer#distance + * @type {number} + * @readonly + * @since 3.16.0 + */ + this.distance = 0; + + /** + * The smoothing factor to apply to the Pointer position. + * + * Due to their nature, pointer positions are inherently noisy. While this is fine for lots of games, if you need cleaner positions + * then you can set this value to apply an automatic smoothing to the positions as they are recorded. + * + * The default value of zero means 'no smoothing'. + * Set to a small value, such as 0.2, to apply an average level of smoothing between positions. You can do this by changing this + * value directly, or by setting the `input.smoothFactor` property in the Game Config. + * + * Positions are only smoothed when the pointer moves. If the primary button on this Pointer enters an Up or Down state, then the position + * is always precise, and not smoothed. + * + * @name Phaser.Input.Pointer#smoothFactor + * @type {number} + * @default 0 + * @since 3.16.0 + */ + this.smoothFactor = 0; + + /** + * The factor applied to the motion smoothing each frame. + * + * This value is passed to the Smooth Step Interpolation that is used to calculate the velocity, + * angle and distance of the Pointer. It's applied every frame, until the midPoint reaches the current + * position of the Pointer. 0.2 provides a good average but can be increased if you need a + * quicker update and are working in a high performance environment. Never set this value to + * zero. + * + * @name Phaser.Input.Pointer#motionFactor + * @type {number} + * @default 0.2 + * @since 3.16.0 + */ + this.motionFactor = 0.2; + /** * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. * @@ -124,6 +257,16 @@ var Pointer = new Class({ */ this.worldY = 0; + /** + * Time when this Pointer was most recently moved (regardless of the state of its buttons, if any) + * + * @name Phaser.Input.Pointer#moveTime + * @type {number} + * @default 0 + * @since 3.0.0 + */ + this.moveTime = 0; + /** * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. * @@ -268,6 +411,18 @@ var Pointer = new Class({ */ this.wasTouch = false; + /** + * Did this Pointer get canceled by a touchcancel event? + * + * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! + * + * @name Phaser.Input.Pointer#wasCanceled + * @type {boolean} + * @default false + * @since 3.15.0 + */ + this.wasCanceled = false; + /** * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. * @@ -316,6 +471,15 @@ var Pointer = new Class({ * @since 3.10.0 */ this.active = (id === 0) ? true : false; + + /** + * Time when this Pointer was most recently updated by the Game step. + * + * @name Phaser.Input.Pointer#time + * @type {number} + * @since 3.16.0 + */ + this.time = 0; }, /** @@ -337,13 +501,13 @@ var Pointer = new Class({ /** * Resets the temporal properties of this Pointer. - * Called automatically by the Input Plugin each update. + * This method is called automatically each frame by the Input Manager. * * @method Phaser.Input.Pointer#reset * @private * @since 3.0.0 */ - reset: function () + reset: function (time) { this.dirty = false; @@ -351,10 +515,60 @@ var Pointer = new Class({ this.justUp = false; this.justMoved = false; + this.time = time; + this.movementX = 0; this.movementY = 0; }, + /** + * Calculates the motion of this Pointer, including its velocity and angle of movement. + * This method is called automatically each frame by the Input Manager. + * + * @method Phaser.Input.Pointer#updateMotion + * @private + * @since 3.16.0 + */ + updateMotion: function () + { + var cx = this.position.x; + var cy = this.position.y; + + var mx = this.midPoint.x; + var my = this.midPoint.y; + + if (cx === mx && cy === my) + { + // Nothing to do here + return; + } + + // Moving towards our goal ... + var vx = SmoothStepInterpolation(this.motionFactor, mx, cx); + var vy = SmoothStepInterpolation(this.motionFactor, my, cy); + + if (FuzzyEqual(vx, cx, 0.1)) + { + vx = cx; + } + + if (FuzzyEqual(vy, cy, 0.1)) + { + vy = cy; + } + + this.midPoint.set(vx, vy); + + var dx = cx - vx; + var dy = cy - vy; + + this.velocity.set(dx, dy); + + this.angle = Angle(vx, vy, cx, cy); + + this.distance = Math.sqrt(dx * dx + dy * dy); + }, + /** * Internal method to handle a Mouse Up Event. * @@ -374,8 +588,10 @@ var Pointer = new Class({ this.event = event; + this.upElement = event.target; + // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); + this.manager.transformPointer(this, event.pageX, event.pageY, false); // 0: Main button pressed, usually the left button or the un-initialized state if (event.button === 0) @@ -413,8 +629,10 @@ var Pointer = new Class({ this.event = event; + this.downElement = event.target; + // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); + this.manager.transformPointer(this, event.pageX, event.pageY, false); // 0: Main button pressed, usually the left button or the un-initialized state if (event.button === 0) @@ -443,7 +661,7 @@ var Pointer = new Class({ * @param {MouseEvent} event - The Mouse Event to process. * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - move: function (event) + move: function (event, time) { if (event.buttons) { @@ -453,7 +671,7 @@ var Pointer = new Class({ this.event = event; // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); + this.manager.transformPointer(this, event.pageX, event.pageY, true); if (this.manager.mouse.locked) { @@ -464,6 +682,8 @@ var Pointer = new Class({ this.justMoved = true; + this.moveTime = time; + this.dirty = true; this.wasTouch = false; @@ -494,8 +714,10 @@ var Pointer = new Class({ this.event = event; + this.downElement = event.target; + // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); + this.manager.transformPointer(this, event.pageX, event.pageY, false); this.primaryDown = true; this.downX = this.x; @@ -508,6 +730,7 @@ var Pointer = new Class({ this.dirty = true; this.wasTouch = true; + this.wasCanceled = false; }, /** @@ -520,15 +743,17 @@ var Pointer = new Class({ * @param {TouchEvent} event - The Touch Event to process. * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. */ - touchmove: function (event) + touchmove: function (event, time) { this.event = event; // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); + this.manager.transformPointer(this, event.pageX, event.pageY, true); this.justMoved = true; + this.moveTime = time; + this.dirty = true; this.wasTouch = true; @@ -550,8 +775,10 @@ var Pointer = new Class({ this.event = event; + this.upElement = event.target; + // Sets the local x/y properties - this.manager.transformPointer(this, event.pageX, event.pageY); + this.manager.transformPointer(this, event.pageX, event.pageY, false); this.primaryDown = false; this.upX = this.x; @@ -564,6 +791,35 @@ var Pointer = new Class({ this.dirty = true; this.wasTouch = true; + this.wasCanceled = false; + + this.active = false; + }, + + /** + * Internal method to handle a Touch Cancel Event. + * + * @method Phaser.Input.Pointer#touchcancel + * @private + * @since 3.15.0 + * + * @param {TouchEvent} event - The Touch Event to process. + */ + touchcancel: function (event) + { + this.buttons = 0; + + this.event = event; + + this.primaryDown = false; + + this.justUp = false; + this.isDown = false; + + this.dirty = true; + + this.wasTouch = true; + this.wasCanceled = true; this.active = false; }, @@ -646,6 +902,185 @@ var Pointer = new Class({ return (this.buttons & 16); }, + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded distance, based on where + * the Pointer was when the button was released. + * + * If you wish to get the distance being travelled currently, based on the velocity of the Pointer, + * then see the `Pointer.distance` property. + * + * @method Phaser.Input.Pointer#getDistance + * @since 3.13.0 + * + * @return {number} The distance the Pointer moved. + */ + getDistance: function () + { + if (this.isDown) + { + return Distance(this.downX, this.downY, this.x, this.y); + } + else + { + return Distance(this.downX, this.downY, this.upX, this.upY); + } + }, + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * horizontal distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded horizontal distance, based on where + * the Pointer was when the button was released. + * + * @method Phaser.Input.Pointer#getDistanceX + * @since 3.16.0 + * + * @return {number} The horizontal distance the Pointer moved. + */ + getDistanceX: function () + { + if (this.isDown) + { + return Math.abs(this.downX - this.x); + } + else + { + return Math.abs(this.downX - this.upX); + } + }, + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * vertical distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded vertical distance, based on where + * the Pointer was when the button was released. + * + * @method Phaser.Input.Pointer#getDistanceY + * @since 3.16.0 + * + * @return {number} The vertical distance the Pointer moved. + */ + getDistanceY: function () + { + if (this.isDown) + { + return Math.abs(this.downY - this.y); + } + else + { + return Math.abs(this.downY - this.upY); + } + }, + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * duration since the Pointer's was pressed down. + * + * If no button is held down, it will return the last recorded duration, based on the time + * the Pointer button was released. + * + * @method Phaser.Input.Pointer#getDuration + * @since 3.16.0 + * + * @return {number} The duration the Pointer was held down for in milliseconds. + */ + getDuration: function () + { + if (this.isDown) + { + return (this.time - this.downTime); + } + else + { + return (this.upTime - this.downTime); + } + }, + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * angle between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded angle, based on where + * the Pointer was when the button was released. + * + * The angle is based on the old position facing to the current position. + * + * If you wish to get the current angle, based on the velocity of the Pointer, then + * see the `Pointer.angle` property. + * + * @method Phaser.Input.Pointer#getAngle + * @since 3.16.0 + * + * @return {number} The angle between the Pointer's coordinates in radians. + */ + getAngle: function () + { + if (this.isDown) + { + return Angle(this.downX, this.downY, this.x, this.y); + } + else + { + return Angle(this.downX, this.downY, this.upX, this.upY); + } + }, + + /** + * Takes the previous and current Pointer positions and then generates an array of interpolated values between + * the two. The array will be populated up to the size of the `steps` argument. + * + * ```javaScript + * var points = pointer.getInterpolatedPosition(4); + * + * // points[0] = { x: 0, y: 0 } + * // points[1] = { x: 2, y: 1 } + * // points[2] = { x: 3, y: 2 } + * // points[3] = { x: 6, y: 3 } + * ``` + * + * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer + * events can often fire faster than the main browser loop, and this will help you avoid janky movement + * especially if you have an object following a Pointer. + * + * Note that if you provide an output array it will only be populated up to the number of steps provided. + * It will not clear any previous data that may have existed beyond the range of the steps count. + * + * Internally it uses the Smooth Step interpolation calculation. + * + * @method Phaser.Input.Pointer#getInterpolatedPosition + * @since 3.11.0 + * + * @param {integer} [steps=10] - The number of interpolation steps to use. + * @param {array} [out] - An array to store the results in. If not provided a new one will be created. + * + * @return {array} An array of interpolated values. + */ + getInterpolatedPosition: function (steps, out) + { + if (steps === undefined) { steps = 10; } + if (out === undefined) { out = []; } + + var prevX = this.prevPosition.x; + var prevY = this.prevPosition.y; + + var curX = this.position.x; + var curY = this.position.y; + + for (var i = 0; i < steps; i++) + { + var t = (1 / steps) * i; + + out[i] = { x: SmoothStepInterpolation(t, prevX, curX), y: SmoothStepInterpolation(t, prevY, curY) }; + } + + return out; + }, + /** * Destroys this Pointer instance and resets its external references. * diff --git a/src/input/const.js b/src/input/const.js index 4ac8f363c..0558dde41 100644 --- a/src/input/const.js +++ b/src/input/const.js @@ -60,6 +60,15 @@ var INPUT_CONST = { */ TOUCH_END: 5, + /** + * A touch pointer has been been cancelled by the browser. + * + * @name Phaser.Input.TOUCH_CANCEL + * @type {integer} + * @since 3.15.0 + */ + TOUCH_CANCEL: 7, + /** * The pointer lock has changed. * diff --git a/src/input/gamepad/Axis.js b/src/input/gamepad/Axis.js index 2d4fcb616..2d39cf8b0 100644 --- a/src/input/gamepad/Axis.js +++ b/src/input/gamepad/Axis.js @@ -12,7 +12,7 @@ var Class = require('../../utils/Class'); * Axis objects are created automatically by the Gamepad as they are needed. * * @class Axis - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.0.0 * diff --git a/src/input/gamepad/Button.js b/src/input/gamepad/Button.js index 9a1682bcf..2184be2a3 100644 --- a/src/input/gamepad/Button.js +++ b/src/input/gamepad/Button.js @@ -12,7 +12,7 @@ var Class = require('../../utils/Class'); * Button objects are created automatically by the Gamepad as they are needed. * * @class Button - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.0.0 * diff --git a/src/input/gamepad/Gamepad.js b/src/input/gamepad/Gamepad.js index ba4f477c9..02354b75b 100644 --- a/src/input/gamepad/Gamepad.js +++ b/src/input/gamepad/Gamepad.js @@ -18,7 +18,7 @@ var Vector2 = require('../../math/Vector2'); * * @class Gamepad * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.0.0 * diff --git a/src/input/gamepad/GamepadPlugin.js b/src/input/gamepad/GamepadPlugin.js index 9c0511d05..e8cc597e1 100644 --- a/src/input/gamepad/GamepadPlugin.js +++ b/src/input/gamepad/GamepadPlugin.js @@ -54,7 +54,7 @@ var InputPluginCache = require('../InputPluginCache'); * * @class GamepadPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Gamepad + * @memberof Phaser.Input.Gamepad * @constructor * @since 3.10.0 * diff --git a/src/input/keyboard/KeyboardManager.js b/src/input/keyboard/KeyboardManager.js new file mode 100644 index 000000000..270dfb5ce --- /dev/null +++ b/src/input/keyboard/KeyboardManager.js @@ -0,0 +1,432 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var ArrayRemove = require('../../utils/array/Remove'); +var Class = require('../../utils/Class'); +var KeyCodes = require('../../input/keyboard/keys/KeyCodes'); +var NOOP = require('../../utils/Class'); + +/** + * @classdesc + * The Keyboard Manager is a helper class that belongs to the global Input Manager. + * + * Its role is to listen for native DOM Keyboard Events and then store them for further processing by the Keyboard Plugin. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically if keyboard + * input has been enabled in the Game Config. + * + * @class KeyboardManager + * @memberof Phaser.Input.Keyboard + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Input.InputManager} inputManager - A reference to the Input Manager. + */ +var KeyboardManager = new Class({ + + initialize: + + function KeyboardManager (inputManager) + { + /** + * A reference to the Input Manager. + * + * @name Phaser.Input.Keyboard.KeyboardManager#manager + * @type {Phaser.Input.InputManager} + * @since 3.16.0 + */ + this.manager = inputManager; + + /** + * An internal event queue. + * + * @name Phaser.Input.Keyboard.KeyboardManager#queue + * @type {KeyboardEvent[]} + * @private + * @since 3.16.0 + */ + this.queue = []; + + /** + * A flag that controls if the non-modified keys, matching those stored in the `captures` array, + * have `preventDefault` called on them or not. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle this property at run-time. + * + * @name Phaser.Input.Keyboard.KeyboardManager#preventDefault + * @type {boolean} + * @since 3.16.0 + */ + this.preventDefault = true; + + /** + * An array of Key Code values that will automatically have `preventDefault` called on them, + * as long as the `KeyboardManager.preventDefault` boolean is set to `true`. + * + * By default the array contains: The Space Key, the Cursor Keys, 0 to 9 and A to Z. + * + * The key must be non-modified when pressed in order to be captured. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle the `KeyboardManager.preventDefault` boolean at run-time. + * + * If you need more specific control, you can create Key objects and set the flag on each of those instead. + * + * This array can be populated via the Game Config by setting the `input.keyboard.capture` array, or you + * can call the `addCapture` method. See also `removeCapture` and `clearCaptures`. + * + * @name Phaser.Input.Keyboard.KeyboardManager#captures + * @type {integer[]} + * @since 3.16.0 + */ + this.captures = []; + + /** + * A boolean that controls if the Keyboard Manager is enabled or not. + * Can be toggled on the fly. + * + * @name Phaser.Input.Keyboard.KeyboardManager#enabled + * @type {boolean} + * @default false + * @since 3.16.0 + */ + this.enabled = false; + + /** + * The Keyboard Event target, as defined in the Game Config. + * Typically the window in which the game is rendering, but can be any interactive DOM element. + * + * @name Phaser.Input.Keyboard.KeyboardManager#target + * @type {any} + * @since 3.16.0 + */ + this.target; + + /** + * The Key Down Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Keyboard.KeyboardManager#onKeyDown + * @type {function} + * @since 3.16.00 + */ + this.onKeyDown = NOOP; + + /** + * The Key Up Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Keyboard.KeyboardManager#onKeyUp + * @type {function} + * @since 3.16.00 + */ + this.onKeyUp = NOOP; + + inputManager.events.once('boot', this.boot, this); + }, + + /** + * The Keyboard Manager boot process. + * + * @method Phaser.Input.Keyboard.KeyboardManager#boot + * @private + * @since 3.16.0 + */ + boot: function () + { + var config = this.manager.config; + + this.enabled = config.inputKeyboard; + this.target = config.inputKeyboardEventTarget; + + this.addCapture(config.inputKeyboardCapture); + + if (!this.target && window) + { + this.target = window; + } + + if (this.enabled && this.target) + { + this.startListeners(); + } + + this.manager.game.events.on('poststep', this.postUpdate, this); + }, + + /** + * Starts the Keyboard Event listeners running. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Keyboard.KeyboardManager#startListeners + * @since 3.16.0 + */ + startListeners: function () + { + var _this = this; + + this.onKeyDown = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.queue.push(event); + + var modified = (event.altKey || event.ctrlKey || event.shiftKey || event.metaKey); + + if (_this.preventDefault && !modified && _this.captures.indexOf(event.keyCode) > -1) + { + event.preventDefault(); + } + }; + + this.onKeyUp = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.queue.push(event); + + var modified = (event.altKey || event.ctrlKey || event.shiftKey || event.metaKey); + + if (_this.preventDefault && !modified && _this.captures.indexOf(event.keyCode) > -1) + { + event.preventDefault(); + } + }; + + var target = this.target; + + if (target) + { + target.addEventListener('keydown', this.onKeyDown, false); + target.addEventListener('keyup', this.onKeyUp, false); + + this.enabled = true; + } + }, + + /** + * Stops the Key Event listeners. + * This is called automatically and does not need to be manually invoked. + * + * @method Phaser.Input.Keyboard.KeyboardManager#stopListeners + * @since 3.16.0 + */ + stopListeners: function () + { + var target = this.target; + + target.removeEventListener('keydown', this.onKeyDown, false); + target.removeEventListener('keyup', this.onKeyUp, false); + + this.enabled = false; + }, + + /** + * Clears the event queue. + * Called automatically by the Input Manager. + * + * @method Phaser.Input.Keyboard.KeyboardManager#postUpdate + * @private + * @since 3.16.0 + */ + postUpdate: function () + { + this.queue = []; + }, + + /** + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * This `addCapture` method enables consuming keyboard event for specific keys so it doesn't bubble up to the the browser + * and cause the default browser behavior. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are active captures after calling this method, the `preventDefault` property is set to `true`. + * + * @method Phaser.Input.Keyboard.KeyboardManager#addCapture + * @since 3.16.0 + * + * @param {(string|integer|integer[]|any[])} keycode - The Key Codes to enable capture for, preventing them reaching the browser. + */ + addCapture: function (keycode) + { + if (typeof keycode === 'string') + { + keycode = keycode.split(','); + } + + if (!Array.isArray(keycode)) + { + keycode = [ keycode ]; + } + + var captures = this.captures; + + for (var i = 0; i < keycode.length; i++) + { + var code = keycode[i]; + + if (typeof code === 'string') + { + code = KeyCodes[code.toUpperCase()]; + } + + if (captures.indexOf(code) === -1) + { + captures.push(code); + } + } + + this.preventDefault = captures.length > 0; + }, + + /** + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are no captures left after calling this method, the `preventDefault` property is set to `false`. + * + * @method Phaser.Input.Keyboard.KeyboardManager#removeCapture + * @since 3.16.0 + * + * @param {(string|integer|integer[]|any[])} keycode - The Key Codes to disable capture for, allowing them reaching the browser again. + */ + removeCapture: function (keycode) + { + if (typeof keycode === 'string') + { + keycode = keycode.split(','); + } + + if (!Array.isArray(keycode)) + { + keycode = [ keycode ]; + } + + var captures = this.captures; + + for (var i = 0; i < keycode.length; i++) + { + var code = keycode[i]; + + if (typeof code === 'string') + { + code = KeyCodes[code.toUpperCase()]; + } + + ArrayRemove(captures, code); + } + + this.preventDefault = captures.length > 0; + }, + + /** + * Removes all keyboard captures and sets the `preventDefault` property to `false`. + * + * @method Phaser.Input.Keyboard.KeyboardManager#clearCaptures + * @since 3.16.0 + */ + clearCaptures: function () + { + this.captures = []; + + this.preventDefault = false; + }, + + /** + * Destroys this Keyboard Manager instance. + * + * @method Phaser.Input.Keyboard.KeyboardManager#destroy + * @since 3.16.0 + */ + destroy: function () + { + this.stopListeners(); + + this.clearCaptures(); + + this.queue = []; + + this.manager.game.events.off('poststep', this.postUpdate, this); + + this.target = null; + this.enabled = false; + this.manager = null; + } + +}); + +module.exports = KeyboardManager; diff --git a/src/input/keyboard/KeyboardPlugin.js b/src/input/keyboard/KeyboardPlugin.js index c3311d52b..69fda30b0 100644 --- a/src/input/keyboard/KeyboardPlugin.js +++ b/src/input/keyboard/KeyboardPlugin.js @@ -12,8 +12,7 @@ var Key = require('./keys/Key'); var KeyCodes = require('./keys/KeyCodes'); var KeyCombo = require('./combo/KeyCombo'); var KeyMap = require('./keys/KeyMap'); -var ProcessKeyDown = require('./keys/ProcessKeyDown'); -var ProcessKeyUp = require('./keys/ProcessKeyUp'); +var SnapFloor = require('../../math/snap/SnapFloor'); /** * @classdesc @@ -40,6 +39,10 @@ var ProcessKeyUp = require('./keys/ProcessKeyUp'); * ```javascript * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); * ``` + * + * If you have multiple parallel Scenes, each trying to get keyboard input, be sure to disable capture on them to stop them from + * stealing input from another Scene in the list. You can do this with `this.input.keyboard.enabled = false` within the + * Scene to stop all input, or `this.input.keyboard.preventDefault = false` to stop a Scene halting input on another Scene. * * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. @@ -50,7 +53,7 @@ var ProcessKeyUp = require('./keys/ProcessKeyUp'); * * @class KeyboardPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Input.Keyboard + * @memberof Phaser.Input.Keyboard * @constructor * @since 3.10.0 * @@ -94,7 +97,16 @@ var KeyboardPlugin = new Class({ this.sceneInputPlugin = sceneInputPlugin; /** - * A boolean that controls if the Keyboard Plugin is enabled or not. + * A reference to the global Keyboard Manager. + * + * @name Phaser.Input.Keyboard.KeyboardPlugin#manager + * @type {Phaser.Input.InputPlugin} + * @since 3.16.0 + */ + this.manager = sceneInputPlugin.manager.keyboard; + + /** + * A boolean that controls if this Keyboard Plugin is enabled or not. * Can be toggled on the fly. * * @name Phaser.Input.Keyboard.KeyboardPlugin#enabled @@ -104,16 +116,6 @@ var KeyboardPlugin = new Class({ */ this.enabled = true; - /** - * The Keyboard Event target, as defined in the Scene or Game Config. - * Typically the browser window, but can be any interactive DOM element. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#target - * @type {any} - * @since 3.10.0 - */ - this.target; - /** * An array of Key objects to process. * @@ -133,24 +135,14 @@ var KeyboardPlugin = new Class({ this.combos = []; /** - * An internal event queue. + * Internal time value. * - * @name Phaser.Input.Keyboard.KeyboardPlugin#queue - * @type {KeyboardEvent[]} + * @name Phaser.Input.Keyboard.KeyboardPlugin#time + * @type {number} * @private - * @since 3.10.0 + * @since 3.11.0 */ - this.queue = []; - - /** - * Internal event handler. - * - * @name Phaser.Input.Keyboard.KeyboardPlugin#onKeyHandler - * @type {function} - * @private - * @since 3.10.0 - */ - this.onKeyHandler; + this.time = 0; sceneInputPlugin.pluginEvents.once('boot', this.boot, this); sceneInputPlugin.pluginEvents.on('start', this.start, this); @@ -167,10 +159,15 @@ var KeyboardPlugin = new Class({ boot: function () { var settings = this.settings.input; - var config = this.scene.sys.game.config; - this.enabled = GetValue(settings, 'keyboard', config.inputKeyboard); - this.target = GetValue(settings, 'keyboard.target', config.inputKeyboardEventTarget); + this.enabled = GetValue(settings, 'keyboard', true); + + var captures = GetValue(settings, 'keyboard.capture', null); + + if (captures) + { + this.addCaptures(captures); + } this.sceneInputPlugin.pluginEvents.once('destroy', this.destroy, this); }, @@ -186,10 +183,7 @@ var KeyboardPlugin = new Class({ */ start: function () { - if (this.enabled) - { - this.startListeners(); - } + this.startListeners(); this.sceneInputPlugin.pluginEvents.once('shutdown', this.shutdown, this); }, @@ -217,33 +211,6 @@ var KeyboardPlugin = new Class({ */ startListeners: function () { - var _this = this; - - var handler = function (event) - { - if (event.defaultPrevented || !_this.isActive()) - { - // Do nothing if event already handled - return; - } - - _this.queue.push(event); - - var key = _this.keys[event.keyCode]; - - if (key && key.preventDefault) - { - event.preventDefault(); - } - - }; - - this.onKeyHandler = handler; - - this.target.addEventListener('keydown', handler, false); - this.target.addEventListener('keyup', handler, false); - - // Finally, listen for an update event from the Input Plugin this.sceneInputPlugin.pluginEvents.on('update', this.update, this); }, @@ -257,15 +224,163 @@ var KeyboardPlugin = new Class({ */ stopListeners: function () { - this.target.removeEventListener('keydown', this.onKeyHandler); - this.target.removeEventListener('keyup', this.onKeyHandler); - this.sceneInputPlugin.pluginEvents.off('update', this.update); }, /** - * @typedef {object} CursorKeys + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. * + * This `addCapture` method enables consuming keyboard events for specific keys, so they don't bubble up the browser + * and cause the default behaviors. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#addCapture + * @since 3.16.0 + * + * @param {(string|integer|integer[]|any[])} keycode - The Key Codes to enable event capture for. + * + * @return {Phaser.Input.Keyboard.KeyboardPlugin} This KeyboardPlugin object. + */ + addCapture: function (keycode) + { + this.manager.addCapture(keycode); + + return this; + }, + + /** + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#removeCapture + * @since 3.16.0 + * + * @param {(string|integer|integer[]|any[])} keycode - The Key Codes to disable event capture for. + * + * @return {Phaser.Input.Keyboard.KeyboardPlugin} This KeyboardPlugin object. + */ + removeCapture: function (keycode) + { + this.manager.removeCapture(keycode); + + return this; + }, + + /** + * Returns an array that contains all of the keyboard captures currently enabled. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#getCaptures + * @since 3.16.0 + * + * @return {integer[]} An array of all the currently capturing key codes. + */ + getCaptures: function () + { + return this.manager.captures; + }, + + /** + * Allows Phaser to prevent any key captures you may have defined from bubbling up the browser. + * You can use this to re-enable event capturing if you had paused it via `disableGlobalCapture`. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#enableGlobalCapture + * @since 3.16.0 + * + * @return {Phaser.Input.Keyboard.KeyboardPlugin} This KeyboardPlugin object. + */ + enableGlobalCapture: function () + { + this.manager.preventDefault = true; + + return this; + }, + + /** + * Disables Phaser from preventing any key captures you may have defined, without actually removing them. + * You can use this to temporarily disable event capturing if, for example, you swap to a DOM element. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#disableGlobalCapture + * @since 3.16.0 + * + * @return {Phaser.Input.Keyboard.KeyboardPlugin} This KeyboardPlugin object. + */ + disableGlobalCapture: function () + { + this.manager.preventDefault = false; + + return this; + }, + + /** + * Removes all keyboard captures. + * + * Note that this is a global change. It will clear all event captures across your game, not just for this specific Scene. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#clearCaptures + * @since 3.16.0 + * + * @return {Phaser.Input.Keyboard.KeyboardPlugin} This KeyboardPlugin object. + */ + clearCaptures: function () + { + this.manager.clearCaptures(); + + return this; + }, + + /** + * @typedef {object} CursorKeys + * @memberof Phaser.Input.Keyboard + * * @property {Phaser.Input.Keyboard.Key} [up] - A Key object mapping to the UP arrow key. * @property {Phaser.Input.Keyboard.Key} [down] - A Key object mapping to the DOWN arrow key. * @property {Phaser.Input.Keyboard.Key} [left] - A Key object mapping to the LEFT arrow key. @@ -319,11 +434,16 @@ var KeyboardPlugin = new Class({ * @since 3.10.0 * * @param {(object|string)} keys - An object containing Key Codes, or a comma-separated string. + * @param {boolean} [enableCapture=true] - Automatically call `preventDefault` on the native DOM browser event for the key codes being added. + * @param {boolean} [emitOnRepeat=false] - Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). * * @return {object} An object containing Key objects mapped to the input properties. */ - addKeys: function (keys) + addKeys: function (keys, enableCapture, emitOnRepeat) { + if (enableCapture === undefined) { enableCapture = true; } + if (emitOnRepeat === undefined) { emitOnRepeat = false; } + var output = {}; if (typeof keys === 'string') @@ -332,14 +452,19 @@ var KeyboardPlugin = new Class({ for (var i = 0; i < keys.length; i++) { - output[keys[i]] = this.addKey(keys[i]); + var currentKey = keys[i].trim(); + + if (currentKey) + { + output[currentKey] = this.addKey(currentKey, enableCapture, emitOnRepeat); + } } } else { for (var key in keys) { - output[key] = this.addKey(keys[key]); + output[key] = this.addKey(keys[key], enableCapture, emitOnRepeat); } } @@ -357,11 +482,16 @@ var KeyboardPlugin = new Class({ * @since 3.10.0 * * @param {(Phaser.Input.Keyboard.Key|string|integer)} key - Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * @param {boolean} [enableCapture=true] - Automatically call `preventDefault` on the native DOM browser event for the key codes being added. + * @param {boolean} [emitOnRepeat=false] - Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). * * @return {Phaser.Input.Keyboard.Key} The newly created Key object, or a reference to it if it already existed in the keys array. */ - addKey: function (key) + addKey: function (key, enableCapture, emitOnRepeat) { + if (enableCapture === undefined) { enableCapture = true; } + if (emitOnRepeat === undefined) { emitOnRepeat = false; } + var keys = this.keys; if (key instanceof Key) @@ -377,6 +507,13 @@ var KeyboardPlugin = new Class({ keys[key.keyCode] = key; } + if (enableCapture) + { + this.addCapture(key.keyCode); + } + + key.setEmitOnRepeat(emitOnRepeat); + return key; } @@ -388,6 +525,13 @@ var KeyboardPlugin = new Class({ if (!keys[key]) { keys[key] = new Key(key); + + if (enableCapture) + { + this.addCapture(key); + } + + keys[key].setEmitOnRepeat(emitOnRepeat); } return keys[key]; @@ -402,6 +546,8 @@ var KeyboardPlugin = new Class({ * @since 3.10.0 * * @param {(Phaser.Input.Keyboard.Key|string|integer)} key - Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * + * @return {Phaser.Input.Keyboard.KeyboardPlugin} This KeyboardPlugin object. */ removeKey: function (key) { @@ -425,6 +571,8 @@ var KeyboardPlugin = new Class({ { keys[key] = undefined; } + + return this; }, /** @@ -439,11 +587,11 @@ var KeyboardPlugin = new Class({ * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); @@ -470,25 +618,61 @@ var KeyboardPlugin = new Class({ }, /** - * Internal update handler called by the Input Manager, which is in turn invoked by the Game step. + * Checks if the given Key object is currently being held down. + * + * The difference between this method and checking the `Key.isDown` property directly is that you can provide + * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted + * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it + * will only return `true` every 100ms. + * + * If the Keyboard Plugin has been disabled, this method will always return `false`. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#checkDown + * @since 3.11.0 + * + * @param {Phaser.Input.Keyboard.Key} key - A Key object. + * @param {number} [duration=0] - The duration which must have elapsed before this Key is considered as being down. + * + * @return {boolean} `True` if the Key is down within the duration specified, otherwise `false`. + */ + checkDown: function (key, duration) + { + if (this.enabled && key.isDown) + { + var t = SnapFloor(this.time - key.timeDown, duration); + + if (t > key._tick) + { + key._tick = t; + + return true; + } + } + + return false; + }, + + /** + * Internal update handler called by the Input Plugin, which is in turn invoked by the Game step. * * @method Phaser.Input.Keyboard.KeyboardPlugin#update * @private * @since 3.10.0 + * + * @param {number} time - The game loop time value. */ - update: function () + update: function (time) { - var len = this.queue.length; + this.time = time; - if (!this.enabled || len === 0) + var queue = this.manager.queue; + var len = queue.length; + + if (!this.isActive() || len === 0) { return; } - // Clears the queue array, and also means we don't work on array data that could potentially - // be modified during the processing phase - var queue = this.queue.splice(0, len); - var keys = this.keys; // Process the event queue, dispatching all of the events that have stored up @@ -496,40 +680,126 @@ var KeyboardPlugin = new Class({ { var event = queue[i]; var code = event.keyCode; + var key = keys[code]; + var repeat = false; + + // Override the default functions (it's too late for the browser to use them anyway, so we may as well) + if (event.cancelled === undefined) + { + // Event allowed to flow across all handlers in this Scene, and any other Scene in the Scene list + event.cancelled = 0; + + // Won't reach any more local (Scene level) handlers + event.stopImmediatePropagation = function () + { + event.cancelled = 1; + }; + + // Won't reach any more handlers in any Scene further down the Scene list + event.stopPropagation = function () + { + event.cancelled = -1; + }; + } + + if (event.cancelled === -1) + { + // This event has been stopped from broadcasting to any other Scene, so abort. + continue; + } if (event.type === 'keydown') { - if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false)) + // Key specific callback first + if (key) { - // Will emit a keyboard or keyup event - this.emit(event.type, event); + repeat = key.isDown; - this.emit('keydown_' + KeyMap[code], event); + key.onDown(event); } - if (keys[code]) + if (!event.cancelled && (!key || !repeat)) { - ProcessKeyDown(keys[code], event); + // keydown_code event + if (KeyMap[code]) + { + this.emit('keydown_' + KeyMap[code], event); + } + + if (!event.cancelled) + { + // keydown event + this.emit(event.type, event); + } } } else { - // Will emit a keyboard or keyup event - this.emit(event.type, event); - - this.emit('keyup_' + KeyMap[code], event); - - if (keys[code]) + // Key specific callback first + if (key) { - ProcessKeyUp(keys[code], event); + key.onUp(event); } + + if (!event.cancelled) + { + // keyup_code event + if (KeyMap[code]) + { + this.emit('keyup_' + KeyMap[code], event); + } + + if (!event.cancelled) + { + // keyup event + this.emit(event.type, event); + } + } + } + + // Reset the cancel state for other Scenes to use + if (event.cancelled === 1) + { + event.cancelled = 0; } } }, /** - * Shuts the Keyboard Plugin down. - * All this does is remove any listeners bound to it. + * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. + * This can only reset keys created via the `addKey`, `addKeys` or `createCursors` methods. + * If you have created a Key object directly you'll need to reset it yourself. + * + * This method is called automatically when the Keyboard Plugin shuts down, but can be + * invoked directly at any time you require. + * + * @method Phaser.Input.Keyboard.KeyboardPlugin#resetKeys + * @since 3.15.0 + * + * @return {Phaser.Input.Keyboard.KeyboardPlugin} This KeyboardPlugin object. + */ + resetKeys: function () + { + var keys = this.keys; + + for (var i = 0; i < keys.length; i++) + { + // Because it's a sparsely populated array + if (keys[i]) + { + keys[i].reset(); + } + } + + return this; + }, + + /** + * Shuts this Keyboard Plugin down. This performs the following tasks: + * + * 1 - Resets all keys created by this Keyboard plugin. + * 2 - Stops and removes the keyboard event listeners. + * 3 - Clears out any pending requests in the queue, without processing them. * * @method Phaser.Input.Keyboard.KeyboardPlugin#shutdown * @private @@ -537,9 +807,13 @@ var KeyboardPlugin = new Class({ */ shutdown: function () { + this.resetKeys(); + this.stopListeners(); this.removeAllListeners(); + + this.queue = []; }, /** @@ -553,6 +827,17 @@ var KeyboardPlugin = new Class({ { this.shutdown(); + var keys = this.keys; + + for (var i = 0; i < keys.length; i++) + { + // Because it's a sparsely populated array + if (keys[i]) + { + keys[i].destroy(); + } + } + this.keys = []; this.combos = []; this.queue = []; @@ -560,7 +845,7 @@ var KeyboardPlugin = new Class({ this.scene = null; this.settings = null; this.sceneInputPlugin = null; - this.target = null; + this.manager = null; } }); diff --git a/src/input/keyboard/combo/KeyCombo.js b/src/input/keyboard/combo/KeyCombo.js index ea09a9ac5..f3e6a6321 100644 --- a/src/input/keyboard/combo/KeyCombo.js +++ b/src/input/keyboard/combo/KeyCombo.js @@ -35,11 +35,11 @@ var ResetKeyCombo = require('./ResetKeyCombo'); * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); @@ -53,7 +53,7 @@ var ResetKeyCombo = require('./ResetKeyCombo'); * ``` * * @class KeyCombo - * @memberOf Phaser.Input.Keyboard + * @memberof Phaser.Input.Keyboard * @constructor * @since 3.0.0 * @@ -266,7 +266,7 @@ var KeyCombo = new Class({ * * @name Phaser.Input.Keyboard.KeyCombo#progress * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ progress: { diff --git a/src/input/keyboard/index.js b/src/input/keyboard/index.js index e41a27b20..2aad578fd 100644 --- a/src/input/keyboard/index.js +++ b/src/input/keyboard/index.js @@ -10,6 +10,7 @@ module.exports = { + KeyboardManager: require('./KeyboardManager'), KeyboardPlugin: require('./KeyboardPlugin'), Key: require('./keys/Key'), diff --git a/src/input/keyboard/keys/Key.js b/src/input/keyboard/keys/Key.js index 93de33302..da337a0fe 100644 --- a/src/input/keyboard/keys/Key.js +++ b/src/input/keyboard/keys/Key.js @@ -5,6 +5,7 @@ */ var Class = require('../../../utils/Class'); +var EventEmitter = require('eventemitter3'); /** * @classdesc @@ -12,7 +13,8 @@ var Class = require('../../../utils/Class'); * keycode must be an integer * * @class Key - * @memberOf Phaser.Input.Keyboard + * @extends Phaser.Events.EventEmitter + * @memberof Phaser.Input.Keyboard * @constructor * @since 3.0.0 * @@ -20,10 +22,14 @@ var Class = require('../../../utils/Class'); */ var Key = new Class({ + Extends: EventEmitter, + initialize: function Key (keyCode) { + EventEmitter.call(this); + /** * The keycode of this key. * @@ -42,16 +48,6 @@ var Key = new Class({ */ this.originalEvent = undefined; - /** - * Should this Key prevent event propagation? - * - * @name Phaser.Input.Keyboard.Key#preventDefault - * @type {boolean} - * @default true - * @since 3.0.0 - */ - this.preventDefault = true; - /** * Can this Key be processed? * @@ -112,6 +108,17 @@ var Key = new Class({ */ this.shiftKey = false; + /** + * The down state of the Meta key, if pressed at the same time as this key. + * On a Mac the Meta Key is the Command key. On Windows keyboards, it's the Windows key. + * + * @name Phaser.Input.Keyboard.Key#metaKey + * @type {boolean} + * @default false + * @since 3.16.0 + */ + this.metaKey = false; + /** * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. * @@ -133,9 +140,7 @@ var Key = new Class({ this.timeDown = 0; /** - * The number of milliseconds this key has been held down for. - * If the key is down this value holds the duration of that key press and is constantly updated. - * If the key is up it holds the duration of the previous down session. + * The number of milliseconds this key was held down for in the previous down - up sequence. * * @name Phaser.Input.Keyboard.Key#duration * @type {number} @@ -154,6 +159,19 @@ var Key = new Class({ */ this.timeUp = 0; + /** + * When a key is held down should it continuously fire the `down` event each time it repeats? + * + * By default it will emit the `down` event just once, but if you wish to receive the event + * for each repeat as well, enable this property. + * + * @name Phaser.Input.Keyboard.Key#emitOnRepeat + * @type {boolean} + * @default false + * @since 3.16.0 + */ + this.emitOnRepeat = false; + /** * If a key is held down this holds down the number of times the key has 'repeated'. * @@ -185,12 +203,114 @@ var Key = new Class({ * @since 3.0.0 */ this._justUp = false; + + /** + * Internal tick counter. + * + * @name Phaser.Input.Keyboard.Key#_tick + * @type {number} + * @private + * @since 3.11.0 + */ + this._tick = -1; + }, + + /** + * Controls if this Key will continuously emit a `down` event while being held down (true), + * or emit the event just once, on first press, and then skip future events (false). + * + * @method Phaser.Input.Keyboard.Key#setEmitOnRepeat + * @since 3.16.0 + * + * @param {boolean} value - Emit `down` events on repeated key down actions, or just once? + * + * @return {Phaser.Input.Keyboard.Key} This Key instance. + */ + setEmitOnRepeat: function (value) + { + this.emitOnRepeat = value; + + return this; + }, + + /** + * Processes the Key Down action for this Key. + * Called automatically by the Keyboard Plugin. + * + * @method Phaser.Input.Keyboard.Key#onDown + * @since 3.16.0 + * + * @param {KeyboardEvent} event - The native DOM Keyboard event. + */ + onDown: function (event) + { + this.originalEvent = event; + + if (!this.enabled) + { + return; + } + + this.altKey = event.altKey; + this.ctrlKey = event.ctrlKey; + this.shiftKey = event.shiftKey; + this.metaKey = event.metaKey; + this.location = event.location; + + this.repeats++; + + if (!this.isDown) + { + this.isDown = true; + this.isUp = false; + this.timeDown = event.timeStamp; + this.duration = 0; + this._justDown = true; + this._justUp = false; + + this.emit('down', this, event); + } + else if (this.emitOnRepeat) + { + this.emit('down', this, event); + } + }, + + /** + * Processes the Key Up action for this Key. + * Called automatically by the Keyboard Plugin. + * + * @method Phaser.Input.Keyboard.Key#onUp + * @since 3.16.0 + * + * @param {KeyboardEvent} event - The native DOM Keyboard event. + */ + onUp: function (event) + { + this.originalEvent = event; + + if (!this.enabled) + { + return; + } + + this.isDown = false; + this.isUp = true; + this.timeUp = event.timeStamp; + this.duration = this.timeUp - this.timeDown; + this.repeats = 0; + + this._justDown = false; + this._justUp = true; + this._tick = -1; + + this.emit('up', this, event); }, /** * Resets this Key object back to its default un-pressed state. * - * @method Phaser.Input.Keyboard.Key.reset + * @method Phaser.Input.Keyboard.Key#reset * @since 3.6.0 * * @return {Phaser.Input.Keyboard.Key} This Key instance. @@ -204,14 +324,29 @@ var Key = new Class({ this.altKey = false; this.ctrlKey = false; this.shiftKey = false; + this.metaKey = false; this.timeDown = 0; this.duration = 0; this.timeUp = 0; this.repeats = 0; this._justDown = false; this._justUp = false; + this._tick = -1; return this; + }, + + /** + * Removes any bound event handlers and removes local references. + * + * @method Phaser.Input.Keyboard.Key#destroy + * @since 3.16.0 + */ + destroy: function () + { + this.removeAllListeners(); + + this.originalEvent = null; } }); diff --git a/src/input/keyboard/keys/KeyCodes.js b/src/input/keyboard/keys/KeyCodes.js index 2a17b10f0..e09c91922 100644 --- a/src/input/keyboard/keys/KeyCodes.js +++ b/src/input/keyboard/keys/KeyCodes.js @@ -6,11 +6,11 @@ /** * Keyboard Codes. - * + * * @name Phaser.Input.Keyboard.KeyCodes * @enum {integer} - * @memberOf Phaser.Input.Keyboard - * @readOnly + * @memberof Phaser.Input.Keyboard + * @readonly * @since 3.0.0 */ @@ -464,8 +464,37 @@ var KeyCodes = { /** * @name Phaser.Input.Keyboard.KeyCodes.CLOSED_BRACKET */ - CLOSED_BRACKET: 221 + CLOSED_BRACKET: 221, + /** + * @name Phaser.Input.Keyboard.KeyCodes.SEMICOLON_FIREFOX + */ + SEMICOLON_FIREFOX: 59, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.COLON + */ + COLON: 58, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.COMMA_FIREFOX_WINDOWS + */ + COMMA_FIREFOX_WINDOWS: 60, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.COMMA_FIREFOX + */ + COMMA_FIREFOX: 62, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BRACKET_RIGHT_FIREFOX + */ + BRACKET_RIGHT_FIREFOX: 174, + + /** + * @name Phaser.Input.Keyboard.KeyCodes.BRACKET_LEFT_FIREFOX + */ + BRACKET_LEFT_FIREFOX: 175 }; module.exports = KeyCodes; diff --git a/src/input/keyboard/keys/ProcessKeyDown.js b/src/input/keyboard/keys/ProcessKeyDown.js deleted file mode 100644 index 702fc889b..000000000 --- a/src/input/keyboard/keys/ProcessKeyDown.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the Keyboard Plugin. - * - * @function Phaser.Input.Keyboard.ProcessKeyDown - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - The Key to process the event for. - * @param {KeyboardEvent} event - The native Keyboard event. - * - * @return {Phaser.Input.Keyboard.Key} The Key that was processed. - */ -var ProcessKeyDown = function (key, event) -{ - key.originalEvent = event; - - if (key.preventDefault) - { - event.preventDefault(); - } - - if (!key.enabled) - { - return; - } - - key.altKey = event.altKey; - key.ctrlKey = event.ctrlKey; - key.shiftKey = event.shiftKey; - key.location = event.location; - - if (key.isDown === false) - { - key.isDown = true; - key.isUp = false; - key.timeDown = event.timeStamp; - key.duration = 0; - key._justDown = true; - key._justUp = false; - } - - key.repeats++; - - return key; -}; - -module.exports = ProcessKeyDown; diff --git a/src/input/keyboard/keys/ProcessKeyUp.js b/src/input/keyboard/keys/ProcessKeyUp.js deleted file mode 100644 index 0ddf5b11e..000000000 --- a/src/input/keyboard/keys/ProcessKeyUp.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * Used internally by the Keyboard Plugin. - * - * @function Phaser.Input.Keyboard.ProcessKeyUp - * @private - * @since 3.0.0 - * - * @param {Phaser.Input.Keyboard.Key} key - The Key to process the event for. - * @param {KeyboardEvent} event - The native Keyboard event. - * - * @return {Phaser.Input.Keyboard.Key} The Key that was processed. - */ -var ProcessKeyUp = function (key, event) -{ - key.originalEvent = event; - - if (key.preventDefault) - { - event.preventDefault(); - } - - if (!key.enabled) - { - return; - } - - key.isDown = false; - key.isUp = true; - key.timeUp = event.timeStamp; - key.duration = key.timeUp - key.timeDown; - key.repeats = 0; - - key._justDown = false; - key._justUp = true; - - return key; -}; - -module.exports = ProcessKeyUp; diff --git a/src/input/mouse/MouseManager.js b/src/input/mouse/MouseManager.js index 08ff99e77..882f39a9a 100644 --- a/src/input/mouse/MouseManager.js +++ b/src/input/mouse/MouseManager.js @@ -6,6 +6,7 @@ var Class = require('../../utils/Class'); var Features = require('../../device/Features'); +var NOOP = require('../../utils/Class'); // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent // https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md @@ -19,7 +20,7 @@ var Features = require('../../device/Features'); * You do not need to create this class directly, the Input Manager will create an instance of it automatically. * * @class MouseManager - * @memberOf Phaser.Input.Mouse + * @memberof Phaser.Input.Mouse * @constructor * @since 3.0.0 * @@ -81,6 +82,72 @@ var MouseManager = new Class({ */ this.locked = false; + /** + * The Mouse Move Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseMove + * @type {function} + * @since 3.10.0 + */ + this.onMouseMove = NOOP; + + /** + * The Mouse Down Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseDown + * @type {function} + * @since 3.10.0 + */ + this.onMouseDown = NOOP; + + /** + * The Mouse Up Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseUp + * @type {function} + * @since 3.10.0 + */ + this.onMouseUp = NOOP; + + /** + * The Mouse Over Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseOver + * @type {function} + * @since 3.16.0 + */ + this.onMouseOver = NOOP; + + /** + * The Mouse Out Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#onMouseOut + * @type {function} + * @since 3.16.0 + */ + this.onMouseOut = NOOP; + + /** + * Internal pointerLockChange handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Mouse.MouseManager#pointerLockChange + * @type {function} + * @since 3.0.0 + */ + this.pointerLockChange = NOOP; + inputManager.events.once('boot', this.boot, this); }, @@ -109,7 +176,7 @@ var MouseManager = new Class({ this.disableContextMenu(); } - if (this.enabled) + if (this.enabled && this.target) { this.startListeners(); } @@ -159,28 +226,13 @@ var MouseManager = new Class({ if (Features.pointerLock) { var element = this.target; + element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; + element.requestPointerLock(); } }, - /** - * Internal pointerLockChange handler. - * - * @method Phaser.Input.Mouse.MouseManager#pointerLockChange - * @since 3.0.0 - * - * @param {MouseEvent} event - The native event from the browser. - */ - pointerLockChange: function (event) - { - var element = this.target; - - this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; - - this.manager.queue.push(event); - }, - /** * If the browser supports pointer lock, this will request that the pointer lock is released. If * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be @@ -198,78 +250,6 @@ var MouseManager = new Class({ } }, - /** - * The Mouse Move Event Handler. - * - * @method Phaser.Input.Mouse.MouseManager#onMouseMove - * @since 3.10.0 - * - * @param {MouseEvent} event - The native DOM Mouse Move Event. - */ - onMouseMove: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueMouseMove(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Mouse Down Event Handler. - * - * @method Phaser.Input.Mouse.MouseManager#onMouseDown - * @since 3.10.0 - * - * @param {MouseEvent} event - The native DOM Mouse Down Event. - */ - onMouseDown: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueMouseDown(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Mouse Up Event Handler. - * - * @method Phaser.Input.Mouse.MouseManager#onMouseUp - * @since 3.10.0 - * - * @param {MouseEvent} event - The native DOM Mouse Up Event. - */ - onMouseUp: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueMouseUp(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - /** * Starts the Mouse Event listeners running. * This is called automatically and does not need to be manually invoked. @@ -279,32 +259,124 @@ var MouseManager = new Class({ */ startListeners: function () { + var _this = this; + var canvas = this.manager.canvas; + var autoFocus = (window && window.focus && this.manager.game.config.autoFocus); + + this.onMouseMove = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseMove(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onMouseDown = function (event) + { + if (autoFocus) + { + window.focus(); + } + + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseDown(event); + + if (_this.capture && event.target === canvas) + { + event.preventDefault(); + } + }; + + this.onMouseUp = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueMouseUp(event); + + if (_this.capture && event.target === canvas) + { + event.preventDefault(); + } + }; + + this.onMouseOver = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.setCanvasOver(event); + }; + + this.onMouseOut = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.setCanvasOut(event); + }; + var target = this.target; + if (!target) + { + return; + } + var passive = { passive: true }; var nonPassive = { passive: false }; - if (this.capture) + target.addEventListener('mousemove', this.onMouseMove, (this.capture) ? nonPassive : passive); + target.addEventListener('mousedown', this.onMouseDown, (this.capture) ? nonPassive : passive); + target.addEventListener('mouseup', this.onMouseUp, (this.capture) ? nonPassive : passive); + target.addEventListener('mouseover', this.onMouseOver, (this.capture) ? nonPassive : passive); + target.addEventListener('mouseout', this.onMouseOut, (this.capture) ? nonPassive : passive); + + if (window) { - target.addEventListener('mousemove', this.onMouseMove.bind(this), nonPassive); - target.addEventListener('mousedown', this.onMouseDown.bind(this), nonPassive); - target.addEventListener('mouseup', this.onMouseUp.bind(this), nonPassive); - } - else - { - target.addEventListener('mousemove', this.onMouseMove.bind(this), passive); - target.addEventListener('mousedown', this.onMouseDown.bind(this), passive); - target.addEventListener('mouseup', this.onMouseUp.bind(this), passive); + window.addEventListener('mousedown', this.onMouseDown, nonPassive); + window.addEventListener('mouseup', this.onMouseUp, nonPassive); } if (Features.pointerLock) { - this.pointerLockChange = this.pointerLockChange.bind(this); + this.pointerLockChange = function (event) + { + var element = _this.target; + + _this.locked = (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element) ? true : false; + + _this.manager.queue.push(event); + }; document.addEventListener('pointerlockchange', this.pointerLockChange, true); document.addEventListener('mozpointerlockchange', this.pointerLockChange, true); document.addEventListener('webkitpointerlockchange', this.pointerLockChange, true); } + + this.enabled = true; }, /** @@ -321,6 +393,14 @@ var MouseManager = new Class({ target.removeEventListener('mousemove', this.onMouseMove); target.removeEventListener('mousedown', this.onMouseDown); target.removeEventListener('mouseup', this.onMouseUp); + target.removeEventListener('mouseover', this.onMouseOver); + target.removeEventListener('mouseout', this.onMouseOut); + + if (window) + { + window.removeEventListener('mousedown', this.onMouseDown); + window.removeEventListener('mouseup', this.onMouseUp); + } if (Features.pointerLock) { @@ -341,6 +421,7 @@ var MouseManager = new Class({ this.stopListeners(); this.target = null; + this.enabled = false; this.manager = null; } diff --git a/src/input/touch/TouchManager.js b/src/input/touch/TouchManager.js index e3ee506b9..eb5d8761a 100644 --- a/src/input/touch/TouchManager.js +++ b/src/input/touch/TouchManager.js @@ -5,6 +5,7 @@ */ var Class = require('../../utils/Class'); +var NOOP = require('../../utils/NOOP'); // https://developer.mozilla.org/en-US/docs/Web/API/Touch_events // https://patrickhlauke.github.io/touch/tests/results/ @@ -19,7 +20,7 @@ var Class = require('../../utils/Class'); * You do not need to create this class directly, the Input Manager will create an instance of it automatically. * * @class TouchManager - * @memberOf Phaser.Input.Touch + * @memberof Phaser.Input.Touch * @constructor * @since 3.0.0 * @@ -71,6 +72,66 @@ var TouchManager = new Class({ */ this.target; + /** + * The Touch Start event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchStart + * @type {function} + * @since 3.0.0 + */ + this.onTouchStart = NOOP; + + /** + * The Touch Move event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchMove + * @type {function} + * @since 3.0.0 + */ + this.onTouchMove = NOOP; + + /** + * The Touch End event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchEnd + * @type {function} + * @since 3.0.0 + */ + this.onTouchEnd = NOOP; + + /** + * The Touch Cancel event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchCancel + * @type {function} + * @since 3.15.0 + */ + this.onTouchCancel = NOOP; + + /** + * The Touch Over event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchOver + * @type {function} + * @since 3.16.0 + */ + this.onTouchOver = NOOP; + + /** + * The Touch Out event handler function. + * Initially empty and bound in the `startListeners` method. + * + * @name Phaser.Input.Touch.TouchManager#onTouchOut + * @type {function} + * @since 3.16.0 + */ + this.onTouchOut = NOOP; + inputManager.events.once('boot', this.boot, this); }, @@ -94,110 +155,143 @@ var TouchManager = new Class({ this.target = this.manager.game.canvas; } - if (this.enabled) + if (this.enabled && this.target) { this.startListeners(); } }, /** - * The Touch Start Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchStart - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch Start Event. - */ - onTouchStart: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchStart(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Touch Move Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchMove - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch Move Event. - */ - onTouchMove: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchMove(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * The Touch End Event Handler. - * - * @method Phaser.Input.Touch.TouchManager#onTouchEnd - * @since 3.10.0 - * - * @param {TouchEvent} event - The native DOM Touch End Event. - */ - onTouchEnd: function (event) - { - if (event.defaultPrevented || !this.enabled) - { - // Do nothing if event already handled - return; - } - - this.manager.queueTouchEnd(event); - - if (this.capture) - { - event.preventDefault(); - } - }, - - /** - * Starts the Touch Event listeners running. - * This is called automatically and does not need to be manually invoked. + * Starts the Touch Event listeners running as long as an input target is set. + * + * This method is called automatically if Touch Input is enabled in the game config, + * which it is by default. However, you can call it manually should you need to + * delay input capturing until later in the game. * * @method Phaser.Input.Touch.TouchManager#startListeners * @since 3.0.0 */ startListeners: function () { + var _this = this; + var canvas = this.manager.canvas; + var autoFocus = (window && window.focus && this.manager.game.config.autoFocus); + + this.onTouchStart = function (event) + { + if (autoFocus) + { + window.focus(); + } + + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchStart(event); + + if (_this.capture && event.target === canvas) + { + event.preventDefault(); + } + }; + + this.onTouchMove = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchMove(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchEnd = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchEnd(event); + + if (_this.capture && event.target === canvas) + { + event.preventDefault(); + } + }; + + this.onTouchCancel = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.queueTouchCancel(event); + + if (_this.capture) + { + event.preventDefault(); + } + }; + + this.onTouchOver = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.setCanvasOver(event); + }; + + this.onTouchOut = function (event) + { + if (event.defaultPrevented || !_this.enabled || !_this.manager) + { + // Do nothing if event already handled + return; + } + + _this.manager.setCanvasOut(event); + }; + var target = this.target; + if (!target) + { + return; + } + var passive = { passive: true }; var nonPassive = { passive: false }; - if (this.capture) + target.addEventListener('touchstart', this.onTouchStart, (this.capture) ? nonPassive : passive); + target.addEventListener('touchmove', this.onTouchMove, (this.capture) ? nonPassive : passive); + target.addEventListener('touchend', this.onTouchEnd, (this.capture) ? nonPassive : passive); + target.addEventListener('touchcancel', this.onTouchCancel, (this.capture) ? nonPassive : passive); + target.addEventListener('touchover', this.onTouchOver, (this.capture) ? nonPassive : passive); + target.addEventListener('touchout', this.onTouchOut, (this.capture) ? nonPassive : passive); + + if (window) { - target.addEventListener('touchstart', this.onTouchStart.bind(this), nonPassive); - target.addEventListener('touchmove', this.onTouchMove.bind(this), nonPassive); - target.addEventListener('touchend', this.onTouchEnd.bind(this), nonPassive); - } - else - { - target.addEventListener('touchstart', this.onTouchStart.bind(this), passive); - target.addEventListener('touchmove', this.onTouchMove.bind(this), passive); - target.addEventListener('touchend', this.onTouchEnd.bind(this), passive); + window.addEventListener('touchstart', this.onTouchStart, nonPassive); + window.addEventListener('touchend', this.onTouchEnd, nonPassive); } + + this.enabled = true; }, /** @@ -214,6 +308,15 @@ var TouchManager = new Class({ target.removeEventListener('touchstart', this.onTouchStart); target.removeEventListener('touchmove', this.onTouchMove); target.removeEventListener('touchend', this.onTouchEnd); + target.removeEventListener('touchcancel', this.onTouchCancel); + target.removeEventListener('touchover', this.onTouchOver); + target.removeEventListener('touchout', this.onTouchOut); + + if (window) + { + window.removeEventListener('touchstart', this.onTouchStart); + window.removeEventListener('touchend', this.onTouchEnd); + } }, /** @@ -227,6 +330,7 @@ var TouchManager = new Class({ this.stopListeners(); this.target = null; + this.enabled = false; this.manager = null; } diff --git a/src/loader/File.js b/src/loader/File.js index e2daa724e..c4564eaab 100644 --- a/src/loader/File.js +++ b/src/loader/File.js @@ -31,7 +31,7 @@ var XHRSettings = require('./XHRSettings'); * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. * * @class File - * @memberOf Phaser.Loader + * @memberof Phaser.Loader * @constructor * @since 3.0.0 * diff --git a/src/loader/LoaderPlugin.js b/src/loader/LoaderPlugin.js index 167bc9ead..062ea7013 100644 --- a/src/loader/LoaderPlugin.js +++ b/src/loader/LoaderPlugin.js @@ -41,7 +41,7 @@ var XHRSettings = require('./XHRSettings'); * * @class LoaderPlugin * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Loader + * @memberof Phaser.Loader * @constructor * @since 3.0.0 * @@ -65,7 +65,6 @@ var LoaderPlugin = new Class({ * * @name Phaser.Loader.LoaderPlugin#scene * @type {Phaser.Scene} - * @protected * @since 3.0.0 */ this.scene = scene; @@ -75,7 +74,6 @@ var LoaderPlugin = new Class({ * * @name Phaser.Loader.LoaderPlugin#systems * @type {Phaser.Scenes.Systems} - * @protected * @since 3.0.0 */ this.systems = scene.sys; @@ -85,7 +83,6 @@ var LoaderPlugin = new Class({ * * @name Phaser.Loader.LoaderPlugin#cacheManager * @type {Phaser.Cache.CacheManager} - * @protected * @since 3.7.0 */ this.cacheManager = scene.sys.cache; @@ -95,11 +92,20 @@ var LoaderPlugin = new Class({ * * @name Phaser.Loader.LoaderPlugin#textureManager * @type {Phaser.Textures.TextureManager} - * @protected * @since 3.7.0 */ this.textureManager = scene.sys.textures; + /** + * A reference to the global Scene Manager. + * + * @name Phaser.Loader.LoaderPlugin#sceneManager + * @type {Phaser.Scenes.SceneManager} + * @protected + * @since 3.16.0 + */ + this.sceneManager = scene.sys.game.scene; + // Inject the available filetypes into the Loader FileTypesManager.install(this); @@ -300,7 +306,7 @@ var LoaderPlugin = new Class({ * * @name Phaser.Loader.LoaderPlugin#state * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.state = CONST.LOADER_IDLE; @@ -827,6 +833,12 @@ var LoaderPlugin = new Class({ */ nextFile: function (file, success) { + // Has the game been destroyed during load? If so, bail out now. + if (!this.inflight) + { + return; + } + this.inflight.delete(file); this.updateProgress(); @@ -867,6 +879,12 @@ var LoaderPlugin = new Class({ */ fileProcessComplete: function (file) { + // Has the game been destroyed during load? If so, bail out now. + if (!this.scene || !this.systems || !this.systems.game || this.systems.game.pendingDestroy) + { + return; + } + // This file has failed, so move it to the failed Set if (file.state === CONST.FILE_ERRORED) { @@ -1077,6 +1095,7 @@ var LoaderPlugin = new Class({ this.systems = null; this.textureManager = null; this.cacheManager = null; + this.sceneManager = null; } }); diff --git a/src/loader/MultiFile.js b/src/loader/MultiFile.js index bf0b9b689..b38d4b4d7 100644 --- a/src/loader/MultiFile.js +++ b/src/loader/MultiFile.js @@ -14,7 +14,7 @@ var Class = require('../utils/Class'); * You shouldn't create an instance of a MultiFile directly, but should extend it with your own class, setting a custom type and processing methods. * * @class MultiFile - * @memberOf Phaser.Loader + * @memberof Phaser.Loader * @constructor * @since 3.7.0 * diff --git a/src/loader/filetypes/AnimationJSONFile.js b/src/loader/filetypes/AnimationJSONFile.js index e7e3b23a1..e424f97b5 100644 --- a/src/loader/filetypes/AnimationJSONFile.js +++ b/src/loader/filetypes/AnimationJSONFile.js @@ -18,7 +18,7 @@ var JSONFile = require('./JSONFile.js'); * * @class AnimationJSONFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/AtlasJSONFile.js b/src/loader/filetypes/AtlasJSONFile.js index a4d50cc06..f404a4358 100644 --- a/src/loader/filetypes/AtlasJSONFile.js +++ b/src/loader/filetypes/AtlasJSONFile.js @@ -37,7 +37,7 @@ var MultiFile = require('../MultiFile.js'); * * @class AtlasJSONFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/AtlasXMLFile.js b/src/loader/filetypes/AtlasXMLFile.js index 466c3c474..9360ee4c9 100644 --- a/src/loader/filetypes/AtlasXMLFile.js +++ b/src/loader/filetypes/AtlasXMLFile.js @@ -35,7 +35,7 @@ var XMLFile = require('./XMLFile.js'); * * @class AtlasXMLFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. diff --git a/src/loader/filetypes/AudioFile.js b/src/loader/filetypes/AudioFile.js index aabc6e0b5..9fa9695f5 100644 --- a/src/loader/filetypes/AudioFile.js +++ b/src/loader/filetypes/AudioFile.js @@ -31,7 +31,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * * @class AudioFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -97,7 +97,7 @@ var AudioFile = new Class({ function (e) { // eslint-disable-next-line no-console - console.error('Error decoding audio: ' + this.key + ' - ', e.message); + console.error('Error decoding audio: ' + this.key + ' - ', e ? e.message : null); _this.onProcessError(); } diff --git a/src/loader/filetypes/AudioSpriteFile.js b/src/loader/filetypes/AudioSpriteFile.js index 1bb2ebaf2..fef54a680 100644 --- a/src/loader/filetypes/AudioSpriteFile.js +++ b/src/loader/filetypes/AudioSpriteFile.js @@ -18,7 +18,7 @@ var MultiFile = require('../MultiFile.js'); * @property {string} key - The key of the file. Must be unique within both the Loader and the Audio Cache. * @property {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. * @property {XHRSettingsObject} [jsonXhrSettings] - Extra XHR Settings specifically for the json file. - * @property {string} [audioURL] - The absolute or relative URL to load the audio file from. + * @property {{(string|string[])}} [audioURL] - The absolute or relative URL to load the audio file from. * @property {any} [audioConfig] - The audio configuration options. * @property {XHRSettingsObject} [audioXhrSettings] - Extra XHR Settings specifically for the audio file. */ @@ -33,14 +33,14 @@ var MultiFile = require('../MultiFile.js'); * * @class AudioSpriteFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.7.0 * * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig)} key - The key to use for this file, or a file configuration object. * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param {string} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {{(string|string[])}} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. * @param {any} [audioConfig] - The audio configuration options. * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. @@ -244,7 +244,7 @@ var AudioSpriteFile = new Class({ * * @param {(string|Phaser.Loader.FileTypes.AudioSpriteFileConfig|Phaser.Loader.FileTypes.AudioSpriteFileConfig[])} key - The key to use for this file, or a file configuration object, or an array of objects. * @param {string} jsonURL - The absolute or relative URL to load the json file from. Or a well formed JSON object to use instead. - * @param {string} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. + * @param {(string|string[])} [audioURL] - The absolute or relative URL to load the audio file from. If empty it will be obtained by parsing the JSON file. * @param {any} [audioConfig] - The audio configuration options. * @param {XHRSettingsObject} [audioXhrSettings] - An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. * @param {XHRSettingsObject} [jsonXhrSettings] - An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. diff --git a/src/loader/filetypes/BinaryFile.js b/src/loader/filetypes/BinaryFile.js index ebe1f9b31..a39665a8b 100644 --- a/src/loader/filetypes/BinaryFile.js +++ b/src/loader/filetypes/BinaryFile.js @@ -31,7 +31,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * * @class BinaryFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/BitmapFontFile.js b/src/loader/filetypes/BitmapFontFile.js index 838277986..3c32a09c9 100644 --- a/src/loader/filetypes/BitmapFontFile.js +++ b/src/loader/filetypes/BitmapFontFile.js @@ -36,7 +36,7 @@ var XMLFile = require('./XMLFile.js'); * * @class BitmapFontFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/GLSLFile.js b/src/loader/filetypes/GLSLFile.js index ebdb4bac9..077978d60 100644 --- a/src/loader/filetypes/GLSLFile.js +++ b/src/loader/filetypes/GLSLFile.js @@ -30,7 +30,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * * @class GLSLFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/HTML5AudioFile.js b/src/loader/filetypes/HTML5AudioFile.js index ee5420944..16cdb3924 100644 --- a/src/loader/filetypes/HTML5AudioFile.js +++ b/src/loader/filetypes/HTML5AudioFile.js @@ -20,7 +20,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * * @class HTML5AudioFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/HTMLFile.js b/src/loader/filetypes/HTMLFile.js index 372d57231..f7865f481 100644 --- a/src/loader/filetypes/HTMLFile.js +++ b/src/loader/filetypes/HTMLFile.js @@ -14,12 +14,10 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); /** * @typedef {object} Phaser.Loader.FileTypes.HTMLFileConfig * - * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. * @property {string} [url] - The absolute or relative URL to load the file from. * @property {string} [extension='html'] - The default file extension to use if no url is provided. * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. - * @property {integer} [width=512] - The width of the texture the HTML will be rendered to. - * @property {integer} [height=512] - The height of the texture the HTML will be rendered to. */ /** @@ -27,20 +25,18 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * A single HTML File suitable for loading by the Loader. * * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. - * + * * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. * * @class HTMLFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor - * @since 3.0.0 + * @since 3.12.0 * * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig)} key - The key to use for this file, or a file configuration object. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {integer} [width] - The width of the texture the HTML will be rendered to. - * @param {integer} [height] - The height of the texture the HTML will be rendered to. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.html". * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. */ var HTMLFile = new Class({ @@ -49,11 +45,8 @@ var HTMLFile = new Class({ initialize: - function HTMLFile (loader, key, url, width, height, xhrSettings) + function HTMLFile (loader, key, url, xhrSettings) { - if (width === undefined) { width = 512; } - if (height === undefined) { height = 512; } - var extension = 'html'; if (IsPlainObject(key)) @@ -64,22 +57,16 @@ var HTMLFile = new Class({ url = GetFastValue(config, 'url'); xhrSettings = GetFastValue(config, 'xhrSettings'); extension = GetFastValue(config, 'extension', extension); - width = GetFastValue(config, 'width', width); - height = GetFastValue(config, 'height', height); } var fileConfig = { - type: 'html', - cache: loader.textureManager, + type: 'text', + cache: loader.cacheManager.html, extension: extension, responseType: 'text', key: key, url: url, - xhrSettings: xhrSettings, - config: { - width: width, - height: height - } + xhrSettings: xhrSettings }; File.call(this, loader, fileConfig); @@ -96,80 +83,22 @@ var HTMLFile = new Class({ { this.state = CONST.FILE_PROCESSING; - var w = this.config.width; - var h = this.config.height; + this.data = this.xhrLoader.responseText; - var data = []; - - data.push(''); - data.push(''); - data.push(''); - data.push(this.xhrLoader.responseText); - data.push(''); - data.push(''); - data.push(''); - - var svg = [ data.join('\n') ]; - var _this = this; - - try - { - var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); - } - catch (e) - { - _this.state = CONST.FILE_ERRORED; - - _this.onProcessComplete(); - - return; - } - - this.data = new Image(); - - this.data.crossOrigin = this.crossOrigin; - - this.data.onload = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessComplete(); - }; - - this.data.onerror = function () - { - File.revokeObjectURL(_this.data); - - _this.onProcessError(); - }; - - File.createObjectURL(this.data, blob, 'image/svg+xml'); - }, - - /** - * Adds this file to its target cache upon successful loading and processing. - * - * @method Phaser.Loader.FileTypes.HTMLFile#addToCache - * @since 3.7.0 - */ - addToCache: function () - { - var texture = this.cache.addImage(this.key, this.data); - - this.pendingDestroy(texture); + this.onProcessComplete(); } }); /** - * Adds an HTML File, or array of HTML Files, to the current load queue. + * Adds an HTML file, or array of HTML files, to the current load queue. * * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * + * * ```javascript * function preload () * { - * this.load.html('instructions', 'content/intro.html', 256, 512); + * this.load.html('story', 'files/LoginForm.html'); * } * ``` * @@ -181,67 +110,54 @@ var HTMLFile = new Class({ * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been * loaded. * - * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. - * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * The key must be a unique String. It is used to add the file to the global HTML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the HTML Cache. * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file - * then remove it from the Texture Manager first, before loading a new one. + * then remove it from the HTML Cache first, before loading a new one. * * Instead of passing arguments you can pass a configuration object, such as: - * + * * ```javascript * this.load.html({ - * key: 'instructions', - * url: 'content/intro.html', - * width: 256, - * height: 512 + * key: 'login', + * url: 'files/LoginForm.html' * }); * ``` * * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. * - * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * + * Once the file has finished loading you can access it from its Cache using its key: + * * ```javascript - * this.load.html('instructions', 'content/intro.html', 256, 512); + * this.load.html('login', 'files/LoginForm.html'); * // and later in your game ... - * this.add.image(x, y, 'instructions'); + * var data = this.cache.html.get('login'); * ``` * * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files - * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and - * this is what you would use to retrieve the image from the Texture Manager. + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the html from the HTML Cache. * * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. * - * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" - * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.html". It will always add `.html` as the extension, although * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. * - * The width and height are the size of the texture to which the HTML will be rendered. It's not possible to determine these - * automatically, so you will need to provide them, either as arguments or in the file config object. - * When the HTML file has loaded a new SVG element is created with a size and viewbox set to the width and height given. - * The SVG file has a body tag added to it, with the HTML file contents included. It then calls `window.Blob` on the SVG, - * and if successful is added to the Texture Manager, otherwise it fails processing. The overall quality of the rendered - * HTML depends on your browser, and some of them may not even support the svg / blob process used. Be aware that there are - * limitations on what HTML can be inside an SVG. You can find out more details in this - * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). - * - * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. + * Note: The ability to load this type of file will only be available if the HTML File type has been built into Phaser. * It is available in the default build but can be excluded from custom builds. * * @method Phaser.Loader.LoaderPlugin#html * @fires Phaser.Loader.LoaderPlugin#addFileEvent - * @since 3.0.0 + * @since 3.12.0 * - * @param {(string|Phaser.Loader.FileTypes.ImageFileConfig|Phaser.Loader.FileTypes.ImageFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. - * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". - * @param {integer} [width=512] - The width of the texture the HTML will be rendered to. - * @param {integer} [height=512] - The height of the texture the HTML will be rendered to. + * @param {(string|Phaser.Loader.FileTypes.HTMLFileConfig|Phaser.Loader.FileTypes.HTMLFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. * * @return {Phaser.Loader.LoaderPlugin} The Loader instance. */ -FileTypesManager.register('html', function (key, url, width, height, xhrSettings) +FileTypesManager.register('html', function (key, url, xhrSettings) { if (Array.isArray(key)) { @@ -253,7 +169,7 @@ FileTypesManager.register('html', function (key, url, width, height, xhrSettings } else { - this.addFile(new HTMLFile(this, key, url, width, height, xhrSettings)); + this.addFile(new HTMLFile(this, key, url, xhrSettings)); } return this; diff --git a/src/loader/filetypes/HTMLTextureFile.js b/src/loader/filetypes/HTMLTextureFile.js new file mode 100644 index 000000000..0fd876b65 --- /dev/null +++ b/src/loader/filetypes/HTMLTextureFile.js @@ -0,0 +1,263 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../utils/Class'); +var CONST = require('../const'); +var File = require('../File'); +var FileTypesManager = require('../FileTypesManager'); +var GetFastValue = require('../../utils/object/GetFastValue'); +var IsPlainObject = require('../../utils/object/IsPlainObject'); + +/** + * @typedef {object} Phaser.Loader.FileTypes.HTMLTextureFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Texture Manager. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='html'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {integer} [width=512] - The width of the texture the HTML will be rendered to. + * @property {integer} [height=512] - The height of the texture the HTML will be rendered to. + */ + +/** + * @classdesc + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#htmlTexture method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#htmlTexture. + * + * @class HTMLTextureFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.12.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.HTMLTextureFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param {integer} [width] - The width of the texture the HTML will be rendered to. + * @param {integer} [height] - The height of the texture the HTML will be rendered to. + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var HTMLTextureFile = new Class({ + + Extends: File, + + initialize: + + function HTMLTextureFile (loader, key, url, width, height, xhrSettings) + { + if (width === undefined) { width = 512; } + if (height === undefined) { height = 512; } + + var extension = 'html'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + width = GetFastValue(config, 'width', width); + height = GetFastValue(config, 'height', height); + } + + var fileConfig = { + type: 'html', + cache: loader.textureManager, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings, + config: { + width: width, + height: height + } + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.HTMLTextureFile#onProcess + * @since 3.7.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + var w = this.config.width; + var h = this.config.height; + + var data = []; + + data.push(''); + data.push(''); + data.push(''); + data.push(this.xhrLoader.responseText); + data.push(''); + data.push(''); + data.push(''); + + var svg = [ data.join('\n') ]; + var _this = this; + + try + { + var blob = new window.Blob(svg, { type: 'image/svg+xml;charset=utf-8' }); + } + catch (e) + { + _this.state = CONST.FILE_ERRORED; + + _this.onProcessComplete(); + + return; + } + + this.data = new Image(); + + this.data.crossOrigin = this.crossOrigin; + + this.data.onload = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessComplete(); + }; + + this.data.onerror = function () + { + File.revokeObjectURL(_this.data); + + _this.onProcessError(); + }; + + File.createObjectURL(this.data, blob, 'image/svg+xml'); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.HTMLTextureFile#addToCache + * @since 3.7.0 + */ + addToCache: function () + { + var texture = this.cache.addImage(this.key, this.data); + + this.pendingDestroy(texture); + } + +}); + +/** + * Adds an HTML File, or array of HTML Files, to the current load queue. When the files are loaded they + * will be rendered to textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Texture Manager upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the Texture Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Texture Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.htmlTexture({ + * key: 'instructions', + * url: 'content/intro.html', + * width: 256, + * height: 512 + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLTextureFileConfig` for more details. + * + * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: + * + * ```javascript + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); + * // and later in your game ... + * this.add.image(x, y, 'instructions'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `MENU.` and the key was `Background` the final key will be `MENU.Background` and + * this is what you would use to retrieve the image from the Texture Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" + * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * The width and height are the size of the texture to which the HTML will be rendered. It's not possible to determine these + * automatically, so you will need to provide them, either as arguments or in the file config object. + * When the HTML file has loaded a new SVG element is created with a size and viewbox set to the width and height given. + * The SVG file has a body tag added to it, with the HTML file contents included. It then calls `window.Blob` on the SVG, + * and if successful is added to the Texture Manager, otherwise it fails processing. The overall quality of the rendered + * HTML depends on your browser, and some of them may not even support the svg / blob process used. Be aware that there are + * limitations on what HTML can be inside an SVG. You can find out more details in this + * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). + * + * Note: The ability to load this type of file will only be available if the HTMLTextureFile File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#htmlTexture + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.12.0 + * + * @param {(string|Phaser.Loader.FileTypes.HTMLTextureFileConfig|Phaser.Loader.FileTypes.HTMLTextureFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param {integer} [width=512] - The width of the texture the HTML will be rendered to. + * @param {integer} [height=512] - The height of the texture the HTML will be rendered to. + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('htmlTexture', function (key, url, width, height, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new HTMLTextureFile(this, key[i])); + } + } + else + { + this.addFile(new HTMLTextureFile(this, key, url, width, height, xhrSettings)); + } + + return this; +}); + +module.exports = HTMLTextureFile; diff --git a/src/loader/filetypes/ImageFile.js b/src/loader/filetypes/ImageFile.js index 166f3baa4..e6d737871 100644 --- a/src/loader/filetypes/ImageFile.js +++ b/src/loader/filetypes/ImageFile.js @@ -43,7 +43,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * * @class ImageFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/JSONFile.js b/src/loader/filetypes/JSONFile.js index 6444acd98..26649fcaa 100644 --- a/src/loader/filetypes/JSONFile.js +++ b/src/loader/filetypes/JSONFile.js @@ -32,7 +32,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * * @class JSONFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/MultiAtlasFile.js b/src/loader/filetypes/MultiAtlasFile.js index 76c2c4956..ed26ab296 100644 --- a/src/loader/filetypes/MultiAtlasFile.js +++ b/src/loader/filetypes/MultiAtlasFile.js @@ -34,7 +34,7 @@ var MultiFile = require('../MultiFile.js'); * * @class MultiAtlasFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.7.0 * diff --git a/src/loader/filetypes/PackFile.js b/src/loader/filetypes/PackFile.js index 5155d07cb..0339e23f2 100644 --- a/src/loader/filetypes/PackFile.js +++ b/src/loader/filetypes/PackFile.js @@ -29,7 +29,7 @@ var JSONFile = require('./JSONFile.js'); * * @class PackFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.7.0 * diff --git a/src/loader/filetypes/PluginFile.js b/src/loader/filetypes/PluginFile.js index 008913ba8..5daaeb0ef 100644 --- a/src/loader/filetypes/PluginFile.js +++ b/src/loader/filetypes/PluginFile.js @@ -32,7 +32,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * * @class PluginFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -122,7 +122,14 @@ var PluginFile = new Class({ document.head.appendChild(this.data); - pluginManager.install(this.key, window[this.key], start, mapping); + var plugin = pluginManager.install(this.key, window[this.key], start, mapping); + + if (start || mapping) + { + // Install into the current Scene Systems and Scene + this.loader.systems[mapping] = plugin; + this.loader.scene[mapping] = plugin; + } } this.onProcessComplete(); @@ -183,7 +190,7 @@ var PluginFile = new Class({ * * @param {(string|Phaser.Loader.FileTypes.PluginFileConfig|Phaser.Loader.FileTypes.PluginFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. * @param {(string|function)} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, a plugin function. - * @param {boolean} [start] - The plugin mapping configuration object. + * @param {boolean} [start] - Automatically start the plugin after loading? * @param {string} [mapping] - If this plugin is to be injected into the Scene, this is the property key used. * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. * diff --git a/src/loader/filetypes/SVGFile.js b/src/loader/filetypes/SVGFile.js index 5af85409e..f150e6ec8 100644 --- a/src/loader/filetypes/SVGFile.js +++ b/src/loader/filetypes/SVGFile.js @@ -11,6 +11,14 @@ var FileTypesManager = require('../FileTypesManager'); var GetFastValue = require('../../utils/object/GetFastValue'); var IsPlainObject = require('../../utils/object/IsPlainObject'); +/** + * @typedef {object} Phaser.Loader.FileTypes.SVGSizeConfig + * + * @property {integer} [width] - An optional width. The SVG will be resized to this size before being rendered to a texture. + * @property {integer} [height] - An optional height. The SVG will be resized to this size before being rendered to a texture. + * @property {number} [scale] - An optional scale. If given it overrides the width / height properties. The SVG is scaled by the scale factor before being rendered to a texture. + */ + /** * @typedef {object} Phaser.Loader.FileTypes.SVGFileConfig * @@ -18,6 +26,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * @property {string} [url] - The absolute or relative URL to load the file from. * @property {string} [extension='svg'] - The default file extension to use if no url is provided. * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + * @property {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. */ /** @@ -25,18 +34,19 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * A single SVG File suitable for loading by the Loader. * * These are created when you use the Phaser.Loader.LoaderPlugin#svg method and are not typically created directly. - * + * * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#svg. * * @class SVGFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig)} key - The key to use for this file, or a file configuration object. * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. */ var SVGFile = new Class({ @@ -45,7 +55,7 @@ var SVGFile = new Class({ initialize: - function SVGFile (loader, key, url, xhrSettings) + function SVGFile (loader, key, url, svgConfig, xhrSettings) { var extension = 'svg'; @@ -55,6 +65,7 @@ var SVGFile = new Class({ key = GetFastValue(config, 'key'); url = GetFastValue(config, 'url'); + svgConfig = GetFastValue(config, 'svgConfig', {}); xhrSettings = GetFastValue(config, 'xhrSettings'); extension = GetFastValue(config, 'extension', extension); } @@ -66,7 +77,12 @@ var SVGFile = new Class({ responseType: 'text', key: key, url: url, - xhrSettings: xhrSettings + xhrSettings: xhrSettings, + config: { + width: GetFastValue(svgConfig, 'width'), + height: GetFastValue(svgConfig, 'height'), + scale: GetFastValue(svgConfig, 'scale') + } }; File.call(this, loader, fileConfig); @@ -83,7 +99,55 @@ var SVGFile = new Class({ { this.state = CONST.FILE_PROCESSING; - var svg = [ this.xhrLoader.responseText ]; + var text = this.xhrLoader.responseText; + var svg = [ text ]; + var width = this.config.width; + var height = this.config.height; + var scale = this.config.scale; + + resize: if (width && height || scale) + { + var xml = null; + var parser = new DOMParser(); + xml = parser.parseFromString(text, 'text/xml'); + var svgXML = xml.getElementsByTagName('svg')[0]; + + var hasViewBox = svgXML.hasAttribute('viewBox'); + var svgWidth = parseFloat(svgXML.getAttribute('width')); + var svgHeight = parseFloat(svgXML.getAttribute('height')); + + if (!hasViewBox && svgWidth && svgHeight) + { + // If there's no viewBox attribute, set one + svgXML.setAttribute('viewBox', '0 0 ' + svgWidth + ' ' + svgHeight); + } + else if (hasViewBox && !svgWidth && !svgHeight) + { + // Get the w/h from the viewbox + var viewBox = svgXML.getAttribute('viewBox').split(/\s+|,/); + + svgWidth = viewBox[2]; + svgHeight = viewBox[3]; + } + + if (scale) + { + if (svgWidth && svgHeight) + { + width = svgWidth * scale; + height = svgHeight * scale; + } + else + { + break resize; + } + } + + svgXML.setAttribute('width', width.toString() + 'px'); + svgXML.setAttribute('height', height.toString() + 'px'); + + svg = [ (new XMLSerializer()).serializeToString(svgXML) ]; + } try { @@ -149,10 +213,11 @@ var SVGFile = new Class({ }); /** - * Adds an SVG File, or array of SVG Files, to the current load queue. + * Adds an SVG File, or array of SVG Files, to the current load queue. When the files are loaded they + * will be rendered to bitmap textures and stored in the Texture Manager. * * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * + * * ```javascript * function preload () * { @@ -174,7 +239,7 @@ var SVGFile = new Class({ * then remove it from the Texture Manager first, before loading a new one. * * Instead of passing arguments you can pass a configuration object, such as: - * + * * ```javascript * this.load.svg({ * key: 'morty', @@ -185,7 +250,7 @@ var SVGFile = new Class({ * See the documentation for `Phaser.Loader.FileTypes.SVGFileConfig` for more details. * * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: - * + * * ```javascript * this.load.svg('morty', 'images/Morty.svg'); * // and later in your game ... @@ -201,6 +266,54 @@ var SVGFile = new Class({ * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien" * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * You can optionally pass an SVG Resize Configuration object when you load an SVG file. By default the SVG will be rendered to a texture + * at the same size defined in the SVG file attributes. However, this isn't always desirable. You may wish to resize the SVG (either down + * or up) to improve texture clarity, or reduce texture memory consumption. You can either specify an exact width and height to resize + * the SVG to: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { width: 300, height: 600 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * width: 300, + * height: 600 + * } + * }); + * ``` + * + * Alternatively, you can just provide a scale factor instead: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { scale: 2.5 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * scale: 2.5 + * } + * }); + * ``` + * + * If scale, width and height values are all given, the scale has priority and the width and height values are ignored. * * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. * It is available in the default build but can be excluded from custom builds. @@ -211,11 +324,12 @@ var SVGFile = new Class({ * * @param {(string|Phaser.Loader.FileTypes.SVGFileConfig|Phaser.Loader.FileTypes.SVGFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param {Phaser.Loader.FileTypes.SVGSizeConfig} [svgConfig] - The svg size configuration object. * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. * * @return {Phaser.Loader.LoaderPlugin} The Loader instance. */ -FileTypesManager.register('svg', function (key, url, xhrSettings) +FileTypesManager.register('svg', function (key, url, svgConfig, xhrSettings) { if (Array.isArray(key)) { @@ -227,10 +341,11 @@ FileTypesManager.register('svg', function (key, url, xhrSettings) } else { - this.addFile(new SVGFile(this, key, url, xhrSettings)); + this.addFile(new SVGFile(this, key, url, svgConfig, xhrSettings)); } return this; }); module.exports = SVGFile; + diff --git a/src/loader/filetypes/SceneFile.js b/src/loader/filetypes/SceneFile.js new file mode 100644 index 000000000..c33f79e1d --- /dev/null +++ b/src/loader/filetypes/SceneFile.js @@ -0,0 +1,221 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var Class = require('../../utils/Class'); +var CONST = require('../const'); +var File = require('../File'); +var FileTypesManager = require('../FileTypesManager'); +var GetFastValue = require('../../utils/object/GetFastValue'); +var IsPlainObject = require('../../utils/object/IsPlainObject'); + +/** + * @typedef {object} Phaser.Loader.FileTypes.SceneFileConfig + * + * @property {string} key - The key of the file. Must be unique within both the Loader and the Text Cache. + * @property {string} [url] - The absolute or relative URL to load the file from. + * @property {string} [extension='txt'] - The default file extension to use if no url is provided. + * @property {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ + +/** + * @classdesc + * An external Scene JavaScript File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#sceneFile method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#sceneFile. + * + * @class SceneFile + * @extends Phaser.Loader.File + * @memberof Phaser.Loader.FileTypes + * @constructor + * @since 3.16.0 + * + * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. + * @param {(string|Phaser.Loader.FileTypes.SceneFileConfig)} key - The key to use for this file, or a file configuration object. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param {XHRSettingsObject} [xhrSettings] - Extra XHR Settings specifically for this file. + */ +var SceneFile = new Class({ + + Extends: File, + + initialize: + + function SceneFile (loader, key, url, xhrSettings) + { + var extension = 'js'; + + if (IsPlainObject(key)) + { + var config = key; + + key = GetFastValue(config, 'key'); + url = GetFastValue(config, 'url'); + xhrSettings = GetFastValue(config, 'xhrSettings'); + extension = GetFastValue(config, 'extension', extension); + } + + var fileConfig = { + type: 'text', + cache: loader.cacheManager.text, + extension: extension, + responseType: 'text', + key: key, + url: url, + xhrSettings: xhrSettings + }; + + File.call(this, loader, fileConfig); + }, + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + * + * @method Phaser.Loader.FileTypes.SceneFile#onProcess + * @since 3.16.0 + */ + onProcess: function () + { + this.state = CONST.FILE_PROCESSING; + + this.data = this.xhrLoader.responseText; + + this.onProcessComplete(); + }, + + /** + * Adds this file to its target cache upon successful loading and processing. + * + * @method Phaser.Loader.FileTypes.SceneFile#addToCache + * @since 3.16.0 + */ + addToCache: function () + { + var code = this.data.concat('(function(){\n' + 'return new ' + this.key + '();\n' + '}).call(this);'); + + this.loader.sceneManager.add(this.key, eval(code)); + + this.complete = true; + } + +}); + +/** + * Adds an external Scene file, or array of Scene files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.sceneFile('Level1', 'src/Level1.js'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Scene Manager upon a successful load. + * + * For a Scene File it's vitally important that the key matches the class name in the JavaScript file. + * + * For example here is the source file: + * + * ```javascript + * class ExternalScene extends Phaser.Scene { + * + * constructor () + * { + * super('myScene'); + * } + * + * } + * ``` + * + * Because the class is called `ExternalScene` that is the exact same key you must use when loading it: + * + * ```javascript + * function preload () + * { + * this.load.sceneFile('ExternalScene', 'src/yourScene.js'); + * } + * ``` + * + * The key that is used within the Scene Manager can either be set to the same, or you can override it in the Scene + * constructor, as we've done in the example above, where the Scene key was changed to `myScene`. + * + * The key should be unique both in terms of files being loaded and Scenes already present in the Scene Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Scene Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.sceneFile({ + * key: 'Level1', + * url: 'src/Level1.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SceneFileConfig` for more details. + * + * Once the file has finished loading it will be added to the Scene Manager. + * + * ```javascript + * this.load.sceneFile('Level1', 'src/Level1.js'); + * // and later in your game ... + * this.scene.start('Level1'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `WORLD1.` and the key was `Story` the final key will be `WORLD1.Story` and + * this is what you would use to retrieve the text from the Scene Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.js". It will always add `.js` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Scene File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * + * @method Phaser.Loader.LoaderPlugin#sceneFile + * @fires Phaser.Loader.LoaderPlugin#addFileEvent + * @since 3.16.0 + * + * @param {(string|Phaser.Loader.FileTypes.SceneFileConfig|Phaser.Loader.FileTypes.SceneFileConfig[])} key - The key to use for this file, or a file configuration object, or array of them. + * @param {string} [url] - The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param {XHRSettingsObject} [xhrSettings] - An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + * + * @return {Phaser.Loader.LoaderPlugin} The Loader instance. + */ +FileTypesManager.register('sceneFile', function (key, url, xhrSettings) +{ + if (Array.isArray(key)) + { + for (var i = 0; i < key.length; i++) + { + // If it's an array it has to be an array of Objects, so we get everything out of the 'key' object + this.addFile(new SceneFile(this, key[i])); + } + } + else + { + this.addFile(new SceneFile(this, key, url, xhrSettings)); + } + + return this; +}); + +module.exports = SceneFile; diff --git a/src/loader/filetypes/ScenePluginFile.js b/src/loader/filetypes/ScenePluginFile.js index bed2bb042..a0832070d 100644 --- a/src/loader/filetypes/ScenePluginFile.js +++ b/src/loader/filetypes/ScenePluginFile.js @@ -32,7 +32,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * * @class ScenePluginFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.8.0 * diff --git a/src/loader/filetypes/ScriptFile.js b/src/loader/filetypes/ScriptFile.js index bff91a282..e7a378aef 100644 --- a/src/loader/filetypes/ScriptFile.js +++ b/src/loader/filetypes/ScriptFile.js @@ -30,7 +30,7 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * * @class ScriptFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/SpriteSheetFile.js b/src/loader/filetypes/SpriteSheetFile.js index 08b834fad..e57717e54 100644 --- a/src/loader/filetypes/SpriteSheetFile.js +++ b/src/loader/filetypes/SpriteSheetFile.js @@ -29,7 +29,7 @@ var ImageFile = require('./ImageFile.js'); * * @class SpriteSheetFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/TextFile.js b/src/loader/filetypes/TextFile.js index 214a37410..c52538287 100644 --- a/src/loader/filetypes/TextFile.js +++ b/src/loader/filetypes/TextFile.js @@ -25,12 +25,12 @@ var IsPlainObject = require('../../utils/object/IsPlainObject'); * A single Text File suitable for loading by the Loader. * * These are created when you use the Phaser.Loader.LoaderPlugin#text method and are not typically created directly. - * + * * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#text. * * @class TextFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -94,11 +94,11 @@ var TextFile = new Class({ * Adds a Text file, or array of Text files, to the current load queue. * * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * + * * ```javascript * function preload () * { - * this.load.text('story', files/IntroStory.txt'); + * this.load.text('story', 'files/IntroStory.txt'); * } * ``` * @@ -109,14 +109,14 @@ var TextFile = new Class({ * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been * loaded. - * + * * The key must be a unique String. It is used to add the file to the global Text Cache upon a successful load. * The key should be unique both in terms of files being loaded and files already present in the Text Cache. * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file * then remove it from the Text Cache first, before loading a new one. * * Instead of passing arguments you can pass a configuration object, such as: - * + * * ```javascript * this.load.text({ * key: 'story', @@ -127,9 +127,9 @@ var TextFile = new Class({ * See the documentation for `Phaser.Loader.FileTypes.TextFileConfig` for more details. * * Once the file has finished loading you can access it from its Cache using its key: - * + * * ```javascript - * this.load.image('story', 'files/IntroStory.txt'); + * this.load.text('story', 'files/IntroStory.txt'); * // and later in your game ... * var data = this.cache.text.get('story'); * ``` diff --git a/src/loader/filetypes/TilemapCSVFile.js b/src/loader/filetypes/TilemapCSVFile.js index da8979ffe..ad9e4689f 100644 --- a/src/loader/filetypes/TilemapCSVFile.js +++ b/src/loader/filetypes/TilemapCSVFile.js @@ -26,12 +26,12 @@ var TILEMAP_FORMATS = require('../../tilemaps/Formats'); * A single Tilemap CSV File suitable for loading by the Loader. * * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapCSV method and are not typically created directly. - * + * * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapCSV. * * @class TilemapCSVFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -112,11 +112,11 @@ var TilemapCSVFile = new Class({ * Adds a CSV Tilemap file, or array of CSV files, to the current load queue. * * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * + * * ```javascript * function preload () * { - * this.load.tilemapCSV('level1', maps/Level1.csv'); + * this.load.tilemapCSV('level1', 'maps/Level1.csv'); * } * ``` * @@ -129,14 +129,14 @@ var TilemapCSVFile = new Class({ * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been * loaded. - * + * * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file * then remove it from the Text Cache first, before loading a new one. * * Instead of passing arguments you can pass a configuration object, such as: - * + * * ```javascript * this.load.tilemapCSV({ * key: 'level1', @@ -147,7 +147,7 @@ var TilemapCSVFile = new Class({ * See the documentation for `Phaser.Loader.FileTypes.TilemapCSVFileConfig` for more details. * * Once the file has finished loading you can access it from its Cache using its key: - * + * * ```javascript * this.load.tilemapCSV('level1', 'maps/Level1.csv'); * // and later in your game ... diff --git a/src/loader/filetypes/TilemapImpactFile.js b/src/loader/filetypes/TilemapImpactFile.js index 4ba60f90b..d3afccb5e 100644 --- a/src/loader/filetypes/TilemapImpactFile.js +++ b/src/loader/filetypes/TilemapImpactFile.js @@ -23,12 +23,12 @@ var TILEMAP_FORMATS = require('../../tilemaps/Formats'); * A single Impact.js Tilemap JSON File suitable for loading by the Loader. * * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapImpact method and are not typically created directly. - * + * * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapImpact. * * @class TilemapImpactFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.7.0 * @@ -73,11 +73,11 @@ var TilemapImpactFile = new Class({ * Adds an Impact.js Tilemap file, or array of map files, to the current load queue. * * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * + * * ```javascript * function preload () * { - * this.load.tilemapImpact('level1', maps/Level1.json'); + * this.load.tilemapImpact('level1', 'maps/Level1.json'); * } * ``` * @@ -90,14 +90,14 @@ var TilemapImpactFile = new Class({ * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been * loaded. - * + * * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file * then remove it from the Text Cache first, before loading a new one. * * Instead of passing arguments you can pass a configuration object, such as: - * + * * ```javascript * this.load.tilemapImpact({ * key: 'level1', @@ -108,7 +108,7 @@ var TilemapImpactFile = new Class({ * See the documentation for `Phaser.Loader.FileTypes.TilemapImpactFileConfig` for more details. * * Once the file has finished loading you can access it from its Cache using its key: - * + * * ```javascript * this.load.tilemapImpact('level1', 'maps/Level1.json'); * // and later in your game ... diff --git a/src/loader/filetypes/TilemapJSONFile.js b/src/loader/filetypes/TilemapJSONFile.js index e25a61884..7b500c047 100644 --- a/src/loader/filetypes/TilemapJSONFile.js +++ b/src/loader/filetypes/TilemapJSONFile.js @@ -23,12 +23,12 @@ var TILEMAP_FORMATS = require('../../tilemaps/Formats'); * A single Tiled Tilemap JSON File suitable for loading by the Loader. * * These are created when you use the Phaser.Loader.LoaderPlugin#tilemapTiledJSON method and are not typically created directly. - * + * * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#tilemapTiledJSON. * * @class TilemapJSONFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * @@ -73,11 +73,11 @@ var TilemapJSONFile = new Class({ * Adds a Tiled JSON Tilemap file, or array of map files, to the current load queue. * * You can call this method from within your Scene's `preload`, along with any other files you wish to load: - * + * * ```javascript * function preload () * { - * this.load.tilemapTiledJSON('level1', maps/Level1.json'); + * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); * } * ``` * @@ -90,14 +90,14 @@ var TilemapJSONFile = new Class({ * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been * loaded. - * + * * The key must be a unique String. It is used to add the file to the global Tilemap Cache upon a successful load. * The key should be unique both in terms of files being loaded and files already present in the Tilemap Cache. * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file * then remove it from the Text Cache first, before loading a new one. * * Instead of passing arguments you can pass a configuration object, such as: - * + * * ```javascript * this.load.tilemapTiledJSON({ * key: 'level1', @@ -108,7 +108,7 @@ var TilemapJSONFile = new Class({ * See the documentation for `Phaser.Loader.FileTypes.TilemapJSONFileConfig` for more details. * * Once the file has finished loading you can access it from its Cache using its key: - * + * * ```javascript * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); * // and later in your game ... diff --git a/src/loader/filetypes/UnityAtlasFile.js b/src/loader/filetypes/UnityAtlasFile.js index afcf60940..39b6f7179 100644 --- a/src/loader/filetypes/UnityAtlasFile.js +++ b/src/loader/filetypes/UnityAtlasFile.js @@ -35,7 +35,7 @@ var TextFile = require('./TextFile.js'); * * @class UnityAtlasFile * @extends Phaser.Loader.MultiFile - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * * @param {Phaser.Loader.LoaderPlugin} loader - A reference to the Loader that is responsible for this file. @@ -60,6 +60,8 @@ var UnityAtlasFile = new Class({ { var config = key; + key = GetFastValue(config, 'key'); + image = new ImageFile(loader, { key: key, url: GetFastValue(config, 'textureURL'), @@ -100,7 +102,7 @@ var UnityAtlasFile = new Class({ */ addToCache: function () { - if (this.failed === 0 && !this.complete) + if (this.isReadyToProcess()) { var image = this.files[0]; var text = this.files[1]; diff --git a/src/loader/filetypes/XMLFile.js b/src/loader/filetypes/XMLFile.js index 05e41cc9c..a87f49e7c 100644 --- a/src/loader/filetypes/XMLFile.js +++ b/src/loader/filetypes/XMLFile.js @@ -31,7 +31,7 @@ var ParseXML = require('../../dom/ParseXML'); * * @class XMLFile * @extends Phaser.Loader.File - * @memberOf Phaser.Loader.FileTypes + * @memberof Phaser.Loader.FileTypes * @constructor * @since 3.0.0 * diff --git a/src/loader/filetypes/index.js b/src/loader/filetypes/index.js index 432b1f3cf..c804a5db3 100644 --- a/src/loader/filetypes/index.js +++ b/src/loader/filetypes/index.js @@ -20,11 +20,13 @@ module.exports = { GLSLFile: require('./GLSLFile'), HTML5AudioFile: require('./HTML5AudioFile'), HTMLFile: require('./HTMLFile'), + HTMLTextureFile: require('./HTMLTextureFile'), ImageFile: require('./ImageFile'), JSONFile: require('./JSONFile'), MultiAtlasFile: require('./MultiAtlasFile'), PackFile: require('./PackFile'), PluginFile: require('./PluginFile'), + SceneFile: require('./SceneFile'), ScenePluginFile: require('./ScenePluginFile'), ScriptFile: require('./ScriptFile'), SpriteSheetFile: require('./SpriteSheetFile'), diff --git a/src/math/Matrix3.js b/src/math/Matrix3.js index 3c0686bc7..081a0133d 100644 --- a/src/math/Matrix3.js +++ b/src/math/Matrix3.js @@ -16,7 +16,7 @@ var Class = require('../utils/Class'); * Defaults to the identity matrix when instantiated. * * @class Matrix3 - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * diff --git a/src/math/Matrix4.js b/src/math/Matrix4.js index e4338ec17..f6cccf63e 100644 --- a/src/math/Matrix4.js +++ b/src/math/Matrix4.js @@ -16,7 +16,7 @@ var EPSILON = 0.000001; * A four-dimensional matrix. * * @class Matrix4 - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * @@ -622,6 +622,30 @@ var Matrix4 = new Class({ return this; }, + /** + * Translate this Matrix using the given values. + * + * @method Phaser.Math.Matrix4#translateXYZ + * @since 3.16.0 + * + * @param {number} x - The x component. + * @param {number} y - The y component. + * @param {number} z - The z component. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + translateXYZ: function (x, y, z) + { + var a = this.val; + + a[12] = a[0] * x + a[4] * y + a[8] * z + a[12]; + a[13] = a[1] * x + a[5] * y + a[9] * z + a[13]; + a[14] = a[2] * x + a[6] * y + a[10] * z + a[14]; + a[15] = a[3] * x + a[7] * y + a[11] * z + a[15]; + + return this; + }, + /** * Apply a scale transformation to this Matrix. * @@ -659,6 +683,40 @@ var Matrix4 = new Class({ return this; }, + /** + * Apply a scale transformation to this Matrix. + * + * @method Phaser.Math.Matrix4#scaleXYZ + * @since 3.16.0 + * + * @param {number} x - The x component. + * @param {number} y - The y component. + * @param {number} z - The z component. + * + * @return {Phaser.Math.Matrix4} This Matrix4. + */ + scaleXYZ: function (x, y, z) + { + var a = this.val; + + a[0] = a[0] * x; + a[1] = a[1] * x; + a[2] = a[2] * x; + a[3] = a[3] * x; + + a[4] = a[4] * y; + a[5] = a[5] * y; + a[6] = a[6] * y; + a[7] = a[7] * y; + + a[8] = a[8] * z; + a[9] = a[9] * z; + a[10] = a[10] * z; + a[11] = a[11] * z; + + return this; + }, + /** * Derive a rotation matrix around the given axis. * diff --git a/src/math/Quaternion.js b/src/math/Quaternion.js index b3c496261..89f900954 100644 --- a/src/math/Quaternion.js +++ b/src/math/Quaternion.js @@ -28,7 +28,7 @@ var tmpMat3 = new Matrix3(); * A quaternion. * * @class Quaternion - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * diff --git a/src/math/RotateAroundDistance.js b/src/math/RotateAroundDistance.js index 02b582645..4eaf00791 100644 --- a/src/math/RotateAroundDistance.js +++ b/src/math/RotateAroundDistance.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Rotate a `point` around `x` and `y` by the given `angle` and `distance`. * * @function Phaser.Math.RotateAroundDistance * @since 3.0.0 @@ -14,7 +14,7 @@ * @param {number} x - The horizontal coordinate to rotate around. * @param {number} y - The vertical coordinate to rotate around. * @param {number} angle - The angle of rotation in radians. - * @param {number} distance - [description] + * @param {number} distance - The distance from (x, y) to place the point at. * * @return {Phaser.Geom.Point} The given point. */ diff --git a/src/math/TransformXY.js b/src/math/TransformXY.js index 2b098242c..7e7622526 100644 --- a/src/math/TransformXY.js +++ b/src/math/TransformXY.js @@ -28,31 +28,20 @@ var TransformXY = function (x, y, positionX, positionY, rotation, scaleX, scaleY { if (output === undefined) { output = new Vector2(); } - // ITRS + var radianSin = Math.sin(rotation); + var radianCos = Math.cos(rotation); - var sr = Math.sin(-rotation); - var cr = Math.cos(-rotation); - - var a = cr * scaleX; - var b = -sr * scaleX; - var c = sr * scaleY; - var d = cr * scaleY; + // Rotate and Scale + var a = radianCos * scaleX; + var b = radianSin * scaleX; + var c = -radianSin * scaleY; + var d = radianCos * scaleY; // Invert + var id = 1 / ((a * d) + (c * -b)); - var n = a * d - b * c; - - var m0 = d / n; - var m1 = -b / n; - var m2 = -c / n; - var m3 = a / n; - var m4 = (c * positionY - d * positionX) / n; - var m5 = -(a * positionY - b * positionX) / n; - - // Transform - - output.x = x * m0 + y * m2 + m4; - output.y = x * m1 + y * m3 + m5; + output.x = (d * id * x) + (-c * id * y) + (((positionY * c) - (positionX * d)) * id); + output.y = (a * id * y) + (-b * id * x) + (((-positionY * a) + (positionX * b)) * id); return output; }; diff --git a/src/math/Vector2.js b/src/math/Vector2.js index 54aa8efd7..48cb0a663 100644 --- a/src/math/Vector2.js +++ b/src/math/Vector2.js @@ -23,11 +23,11 @@ var Class = require('../utils/Class'); * A two-component vector. * * @class Vector2 - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * - * @param {number} [x] - The x component. + * @param {number|Vector2Like} [x] - The x component, or an object with `x` and `y` properties. * @param {number} [y] - The y component. */ var Vector2 = new Class({ @@ -463,14 +463,14 @@ var Vector2 = new Class({ }, /** - * [description] + * Calculate the cross product of this Vector and the given Vector. * * @method Phaser.Math.Vector2#cross * @since 3.0.0 * - * @param {Phaser.Math.Vector2} src - [description] + * @param {Phaser.Math.Vector2} src - The Vector2 to cross with this Vector2. * - * @return {number} [description] + * @return {number} The cross product of this Vector and the given Vector. */ cross: function (src) { @@ -568,7 +568,9 @@ var Vector2 = new Class({ /** * A static zero Vector2 for use by reference. * - * @method Phaser.Math.Vector2.ZERO + * @constant + * @name Phaser.Math.Vector2.ZERO + * @type {Vector2} * @since 3.1.0 */ Vector2.ZERO = new Vector2(); diff --git a/src/math/Vector3.js b/src/math/Vector3.js index ed4c4ae2e..a73745e09 100644 --- a/src/math/Vector3.js +++ b/src/math/Vector3.js @@ -16,7 +16,7 @@ var Class = require('../utils/Class'); * A three-component vector. * * @class Vector3 - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * @@ -107,13 +107,13 @@ var Vector3 = new Class({ }, /** - * [description] + * Calculate the cross (vector) product of two given Vectors. * * @method Phaser.Math.Vector3#crossVectors * @since 3.0.0 * - * @param {Phaser.Math.Vector3} a - [description] - * @param {Phaser.Math.Vector3} b - [description] + * @param {Phaser.Math.Vector3} a - The first Vector to multiply. + * @param {Phaser.Math.Vector3} b - The second Vector to multiply. * * @return {Phaser.Math.Vector3} This Vector3. */ @@ -433,7 +433,7 @@ var Vector3 = new Class({ * * @param {Phaser.Math.Vector3} v - The Vector3 to dot product with this Vector3. * - * @return {number} [description] + * @return {number} The dot product of this Vector and `v`. */ dot: function (v) { @@ -441,12 +441,12 @@ var Vector3 = new Class({ }, /** - * [description] + * Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector. * * @method Phaser.Math.Vector3#cross * @since 3.0.0 * - * @param {Phaser.Math.Vector3} v - [description] + * @param {Phaser.Math.Vector3} v - The Vector to cross product with. * * @return {Phaser.Math.Vector3} This Vector3. */ @@ -543,7 +543,7 @@ var Vector3 = new Class({ }, /** - * [description] + * Transforms the coordinates of this Vector3 with the given Matrix4. * * @method Phaser.Math.Vector3#transformCoordinates * @since 3.0.0 diff --git a/src/math/Vector4.js b/src/math/Vector4.js index fb4fa63de..14e7d9d8c 100644 --- a/src/math/Vector4.js +++ b/src/math/Vector4.js @@ -16,7 +16,7 @@ var Class = require('../utils/Class'); * A four-component vector. * * @class Vector4 - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * @@ -128,9 +128,9 @@ var Vector4 = new Class({ * @method Phaser.Math.Vector4#equals * @since 3.0.0 * - * @param {Phaser.Math.Vector4} v - [description] + * @param {Phaser.Math.Vector4} v - The vector to check equality with. * - * @return {boolean} [description] + * @return {boolean} A boolean indicating whether the two Vectors are equal or not. */ equals: function (v) { @@ -392,7 +392,7 @@ var Vector4 = new Class({ * @method Phaser.Math.Vector4#distance * @since 3.0.0 * - * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - [description] + * @param {(Phaser.Math.Vector2|Phaser.Math.Vector3|Phaser.Math.Vector4)} v - The Vector to calculate the distance to. * * @return {number} The distance from this Vector to the given Vector. */ diff --git a/src/math/angle/CounterClockwise.js b/src/math/angle/CounterClockwise.js new file mode 100644 index 000000000..cb9a0899c --- /dev/null +++ b/src/math/angle/CounterClockwise.js @@ -0,0 +1,34 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +var CONST = require('../const'); + +/** + * Takes an angle in Phasers default clockwise format and converts it so that + * 0 is North, 90 is West, 180 is South and 270 is East, + * therefore running counter-clockwise instead of clockwise. + * + * You can pass in the angle from a Game Object using: + * + * ```javascript + * var converted = CounterClockwise(gameobject.rotation); + * ``` + * + * All values for this function are in radians. + * + * @function Phaser.Math.Angle.CounterClockwise + * @since 3.16.0 + * + * @param {number} angle - The angle to convert, in radians. + * + * @return {number} The converted angle, in radians. + */ +var CounterClockwise = function (angle) +{ + return Math.abs((((angle + CONST.TAU) % CONST.PI2) - CONST.PI2) % CONST.PI2); +}; + +module.exports = CounterClockwise; diff --git a/src/math/angle/index.js b/src/math/angle/index.js index 936bcb64f..bc8ca3c27 100644 --- a/src/math/angle/index.js +++ b/src/math/angle/index.js @@ -11,13 +11,14 @@ module.exports = { Between: require('./Between'), - BetweenY: require('./BetweenY'), BetweenPoints: require('./BetweenPoints'), BetweenPointsY: require('./BetweenPointsY'), + BetweenY: require('./BetweenY'), + CounterClockwise: require('./CounterClockwise'), + Normalize: require('./Normalize'), Reverse: require('./Reverse'), RotateTo: require('./RotateTo'), ShortestBetween: require('./ShortestBetween'), - Normalize: require('./Normalize'), Wrap: require('./Wrap'), WrapDegrees: require('./WrapDegrees') diff --git a/src/math/const.js b/src/math/const.js index 63bd6ba06..25ba01033 100644 --- a/src/math/const.js +++ b/src/math/const.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var RND = require('./random-data-generator/RandomDataGenerator'); - var MATH_CONST = { /** @@ -55,12 +53,13 @@ var MATH_CONST = { /** * An instance of the Random Number Generator. + * This is not set until the Game boots. * * @name Phaser.Math.RND * @type {Phaser.Math.RandomDataGenerator} * @since 3.0.0 */ - RND: new RND() + RND: null }; diff --git a/src/math/easing/elastic/In.js b/src/math/easing/elastic/In.js index 8e095c437..04a183a7e 100644 --- a/src/math/easing/elastic/In.js +++ b/src/math/easing/elastic/In.js @@ -12,7 +12,7 @@ * * @param {number} v - The value to be tweened. * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {number} [period=0.1] - [description] + * @param {number} [period=0.1] - Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. * * @return {number} The tweened value. */ diff --git a/src/math/easing/elastic/InOut.js b/src/math/easing/elastic/InOut.js index 3de98c6f1..90853e086 100644 --- a/src/math/easing/elastic/InOut.js +++ b/src/math/easing/elastic/InOut.js @@ -12,7 +12,7 @@ * * @param {number} v - The value to be tweened. * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {number} [period=0.1] - [description] + * @param {number} [period=0.1] - Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. * * @return {number} The tweened value. */ diff --git a/src/math/easing/elastic/Out.js b/src/math/easing/elastic/Out.js index c30596d3f..3e4bc3824 100644 --- a/src/math/easing/elastic/Out.js +++ b/src/math/easing/elastic/Out.js @@ -12,7 +12,7 @@ * * @param {number} v - The value to be tweened. * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {number} [period=0.1] - [description] + * @param {number} [period=0.1] - Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. * * @return {number} The tweened value. */ diff --git a/src/math/interpolation/LinearInterpolation.js b/src/math/interpolation/LinearInterpolation.js index ae46d8d26..1fce7a2ab 100644 --- a/src/math/interpolation/LinearInterpolation.js +++ b/src/math/interpolation/LinearInterpolation.js @@ -28,13 +28,14 @@ var LinearInterpolation = function (v, k) { return Linear(v[0], v[1], f); } - - if (k > 1) + else if (k > 1) { return Linear(v[m], v[m - 1], m - f); } - - return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); + else + { + return Linear(v[i], v[(i + 1 > m) ? m : i + 1], f - i); + } }; module.exports = LinearInterpolation; diff --git a/src/math/random-data-generator/RandomDataGenerator.js b/src/math/random-data-generator/RandomDataGenerator.js index b4ce79c16..5b1e6efe4 100644 --- a/src/math/random-data-generator/RandomDataGenerator.js +++ b/src/math/random-data-generator/RandomDataGenerator.js @@ -8,14 +8,23 @@ var Class = require('../../utils/Class'); /** * @classdesc - * A seeded random data generator. + * A seeded Random Data Generator. + * + * Access via `Phaser.Math.RND` which is an instance of this class pre-defined + * by Phaser. Or, create your own instance to use as you require. + * + * The `Math.RND` generator is seeded by the Game Config property value `seed`. + * If no such config property exists, a random number is used. + * + * If you create your own instance of this class you should provide a seed for it. + * If no seed is given it will use a 'random' one based on Date.now. * * @class RandomDataGenerator - * @memberOf Phaser.Math + * @memberof Phaser.Math * @constructor * @since 3.0.0 * - * @param {string[]} [seeds] - The seeds. + * @param {(string|string[])} [seeds] - The seeds to use for the random number generator. */ var RandomDataGenerator = new Class({ @@ -23,6 +32,8 @@ var RandomDataGenerator = new Class({ function RandomDataGenerator (seeds) { + if (seeds === undefined) { seeds = [ (Date.now() * Math.random()).toString() ]; } + /** * Internal var. * @@ -467,7 +478,7 @@ var RandomDataGenerator = new Class({ for (var i = len; i > 0; i--) { - var randomIndex = Math.floor(this.frac() * (len + 1)); + var randomIndex = Math.floor(this.frac() * (i + 1)); var itemAtIndex = array[randomIndex]; array[randomIndex] = array[i]; diff --git a/src/math/snap/SnapCeil.js b/src/math/snap/SnapCeil.js index 37dc40758..35a09c386 100644 --- a/src/math/snap/SnapCeil.js +++ b/src/math/snap/SnapCeil.js @@ -16,10 +16,11 @@ * @param {number} value - The value to snap. * @param {number} gap - The interval gap of the grid. * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. * * @return {number} The snapped value. */ -var SnapCeil = function (value, gap, start) +var SnapCeil = function (value, gap, start, divide) { if (start === undefined) { start = 0; } @@ -31,7 +32,7 @@ var SnapCeil = function (value, gap, start) value -= start; value = gap * Math.ceil(value / gap); - return start + value; + return (divide) ? (start + value) / gap : start + value; }; module.exports = SnapCeil; diff --git a/src/math/snap/SnapFloor.js b/src/math/snap/SnapFloor.js index 9770b8413..a25b7c99a 100644 --- a/src/math/snap/SnapFloor.js +++ b/src/math/snap/SnapFloor.js @@ -16,10 +16,11 @@ * @param {number} value - The value to snap. * @param {number} gap - The interval gap of the grid. * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. * * @return {number} The snapped value. */ -var SnapFloor = function (value, gap, start) +var SnapFloor = function (value, gap, start, divide) { if (start === undefined) { start = 0; } @@ -31,7 +32,7 @@ var SnapFloor = function (value, gap, start) value -= start; value = gap * Math.floor(value / gap); - return start + value; + return (divide) ? (start + value) / gap : start + value; }; module.exports = SnapFloor; diff --git a/src/math/snap/SnapTo.js b/src/math/snap/SnapTo.js index 05716d9c6..f441dd34c 100644 --- a/src/math/snap/SnapTo.js +++ b/src/math/snap/SnapTo.js @@ -15,10 +15,11 @@ * @param {number} value - The value to snap. * @param {number} gap - The interval gap of the grid. * @param {number} [start=0] - Optional starting offset for gap. + * @param {boolean} [divide=false] - If `true` it will divide the snapped value by the gap before returning. * * @return {number} The snapped value. */ -var SnapTo = function (value, gap, start) +var SnapTo = function (value, gap, start, divide) { if (start === undefined) { start = 0; } @@ -30,7 +31,7 @@ var SnapTo = function (value, gap, start) value -= start; value = gap * Math.round(value / gap); - return start + value; + return (divide) ? (start + value) / gap : start + value; }; module.exports = SnapTo; diff --git a/src/phaser.js b/src/phaser.js index 69002f963..177a65114 100644 --- a/src/phaser.js +++ b/src/phaser.js @@ -47,6 +47,21 @@ var Phaser = { }; +// Merge in the optional plugins + +if (typeof PLUGIN_CAMERA3D) +{ + Phaser.Cameras.Sprite3D = require('../plugins/camera3d/src'); + Phaser.GameObjects.Sprite3D = require('../plugins/camera3d/src/sprite3d/Sprite3D'); + Phaser.GameObjects.Factories.Sprite3D = require('../plugins/camera3d/src/sprite3d/Sprite3DFactory'); + Phaser.GameObjects.Creators.Sprite3D = require('../plugins/camera3d/src/sprite3d/Sprite3DCreator'); +} + +if (typeof PLUGIN_FBINSTANT) +{ + Phaser.FacebookInstantGamesPlugin = require('../plugins/fbinstant/src/FacebookInstantGamesPlugin'); +} + // Merge in the consts Phaser = Extend(false, Phaser, CONST); diff --git a/src/physics/arcade/ArcadeImage.js b/src/physics/arcade/ArcadeImage.js index 828f3d9da..13e7ae587 100644 --- a/src/physics/arcade/ArcadeImage.js +++ b/src/physics/arcade/ArcadeImage.js @@ -10,16 +10,14 @@ var Image = require('../../gameobjects/image/Image'); /** * @classdesc - * An Arcade Physics Image Game Object. + * An Arcade Physics Image is an Image with an Arcade Physics body and related components. + * The body can be dynamic or static. * - * An Image is a light-weight Game Object useful for the display of static images in your game, - * such as logos, backgrounds, scenery or other non-animated elements. Images can have input - * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an - * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. + * The main difference between an Arcade Image and an Arcade Sprite is that you cannot animate an Arcade Image. * * @class Image * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * @@ -80,6 +78,16 @@ var ArcadeImage = new Class({ function ArcadeImage (scene, x, y, texture, frame) { Image.call(this, scene, x, y, texture, frame); + + /** + * This Game Object's Physics Body. + * + * @name Phaser.Physics.Arcade.Image#body + * @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} + * @default null + * @since 3.0.0 + */ + this.body = null; } }); diff --git a/src/physics/arcade/ArcadePhysics.js b/src/physics/arcade/ArcadePhysics.js index 17b962384..fe16c44b5 100644 --- a/src/physics/arcade/ArcadePhysics.js +++ b/src/physics/arcade/ArcadePhysics.js @@ -7,6 +7,7 @@ var Class = require('../../utils/Class'); var DegToRad = require('../../math/DegToRad'); var DistanceBetween = require('../../math/distance/DistanceBetween'); +var DistanceSquared = require('../../math/distance/DistanceSquared'); var Factory = require('./Factory'); var GetFastValue = require('../../utils/object/GetFastValue'); var Merge = require('../../utils/object/Merge'); @@ -14,18 +15,19 @@ var PluginCache = require('../../plugins/PluginCache'); var Vector2 = require('../../math/Vector2'); var World = require('./World'); -// All methods in this class are available under `this.physics` in a Scene. - /** * @classdesc - * [description] + * The Arcade Physics Plugin belongs to a Scene and sets up and manages the Scene's physics simulation. + * It also holds some useful methods for moving and rotating Arcade Physics Bodies. + * + * You can access it from within a Scene using `this.physics`. * * @class ArcadePhysics - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene that this Plugin belongs to. */ var ArcadePhysics = new Class({ @@ -34,7 +36,7 @@ var ArcadePhysics = new Class({ function ArcadePhysics (scene) { /** - * [description] + * The Scene that this Plugin belongs to. * * @name Phaser.Physics.Arcade.ArcadePhysics#scene * @type {Phaser.Scene} @@ -43,7 +45,7 @@ var ArcadePhysics = new Class({ this.scene = scene; /** - * [description] + * The Scene's Systems. * * @name Phaser.Physics.Arcade.ArcadePhysics#systems * @type {Phaser.Scenes.Systems} @@ -52,7 +54,7 @@ var ArcadePhysics = new Class({ this.systems = scene.sys; /** - * [description] + * A configuration object. Union of the `physics.arcade.*` properties of the GameConfig and SceneConfig objects. * * @name Phaser.Physics.Arcade.ArcadePhysics#config * @type {object} @@ -61,7 +63,7 @@ var ArcadePhysics = new Class({ this.config = this.getConfig(); /** - * [description] + * The physics simulation. * * @name Phaser.Physics.Arcade.ArcadePhysics#world * @type {Phaser.Physics.Arcade.World} @@ -70,7 +72,7 @@ var ArcadePhysics = new Class({ this.world; /** - * [description] + * An object holding the Arcade Physics factory methods. * * @name Phaser.Physics.Arcade.ArcadePhysics#add * @type {Phaser.Physics.Arcade.Factory} @@ -123,12 +125,12 @@ var ArcadePhysics = new Class({ }, /** - * [description] + * Creates the physics configuration for the current Scene. * * @method Phaser.Physics.Arcade.ArcadePhysics#getConfig * @since 3.0.0 * - * @return {object} [description] + * @return {object} The physics configuration. */ getConfig: function () { @@ -144,31 +146,20 @@ var ArcadePhysics = new Class({ }, /** - * Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body. - * - * Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. - * - * Both the first and second parameter can be arrays of objects, of differing types. - * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. - * - * ##### Tilemaps - * - * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. - * - * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). - * - * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. + * Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap} * * @method Phaser.Physics.Arcade.ArcadePhysics#overlap * @since 3.0.0 * - * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {ArcadePhysicsCallback} [overlapCallback=null] - An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `collideCallback` will only be called if this callback returns `true`. * @param {*} [callbackContext] - The context in which to run the callbacks. * - * @return {boolean} True if an overlap occurred otherwise false. + * @return {boolean} True if at least one Game Object overlaps another. + * + * @see Phaser.Physics.Arcade.World#overlap */ overlap: function (object1, object2, overlapCallback, processCallback, callbackContext) { @@ -180,18 +171,20 @@ var ArcadePhysics = new Class({ }, /** - * [description] + * Tests if Game Objects overlap and separates them (if possible). See {@link Phaser.Physics.Arcade.World#collide}. * * @method Phaser.Physics.Arcade.ArcadePhysics#collide * @since 3.0.0 * - * @param {(Phaser.GameObjects.GameObject|array)} object1 - The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {(Phaser.GameObjects.GameObject|array)} object2 - The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param {ArcadePhysicsCallback} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. - * @param {ArcadePhysicsCallback} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. * @param {*} [callbackContext] - The context in which to run the callbacks. * - * @return {boolean} True if a collision occurred otherwise false. + * @return {boolean} True if any overlapping Game Objects were separated, otherwise false. + * + * @see Phaser.Physics.Arcade.World#collide */ collide: function (object1, object2, collideCallback, processCallback, callbackContext) { @@ -203,12 +196,12 @@ var ArcadePhysics = new Class({ }, /** - * [description] + * Pauses the simulation. * * @method Phaser.Physics.Arcade.ArcadePhysics#pause * @since 3.0.0 * - * @return {Phaser.Physics.Arcade.World} [description] + * @return {Phaser.Physics.Arcade.World} The simulation. */ pause: function () { @@ -216,12 +209,12 @@ var ArcadePhysics = new Class({ }, /** - * [description] + * Resumes the simulation (if paused). * * @method Phaser.Physics.Arcade.ArcadePhysics#resume * @since 3.0.0 * - * @return {Phaser.Physics.Arcade.World} [description] + * @return {Phaser.Physics.Arcade.World} The simulation. */ resume: function () { @@ -300,7 +293,7 @@ var ArcadePhysics = new Class({ */ closest: function (source) { - var bodies = this.tree.all(); + var bodies = this.world.tree.all(); var min = Number.MAX_VALUE; var closest = null; @@ -310,7 +303,7 @@ var ArcadePhysics = new Class({ for (var i = bodies.length - 1; i >= 0; i--) { var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); + var distance = DistanceSquared(x, y, target.x, target.y); if (distance < min) { @@ -334,7 +327,7 @@ var ArcadePhysics = new Class({ */ furthest: function (source) { - var bodies = this.tree.all(); + var bodies = this.world.tree.all(); var max = -1; var farthest = null; @@ -344,7 +337,7 @@ var ArcadePhysics = new Class({ for (var i = bodies.length - 1; i >= 0; i--) { var target = bodies[i]; - var distance = DistanceBetween(x, y, target.x, target.y); + var distance = DistanceSquared(x, y, target.x, target.y); if (distance > max) { @@ -467,6 +460,12 @@ var ArcadePhysics = new Class({ */ shutdown: function () { + if (!this.world) + { + // Already destroyed + return; + } + var eventEmitter = this.systems.events; eventEmitter.off('update', this.world.update, this.world); diff --git a/src/physics/arcade/ArcadeSprite.js b/src/physics/arcade/ArcadeSprite.js index 39a465fb5..cd5954ae6 100644 --- a/src/physics/arcade/ArcadeSprite.js +++ b/src/physics/arcade/ArcadeSprite.js @@ -10,19 +10,15 @@ var Sprite = require('../../gameobjects/sprite/Sprite'); /** * @classdesc - * An Arcade Physics Sprite Game Object. + * An Arcade Physics Sprite is a Sprite with an Arcade Physics body and related components. + * The body can be dynamic or static. * - * A Sprite Game Object is used for the display of both static and animated images in your game. - * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled - * and animated. - * - * The main difference between a Sprite and an Image Game Object is that you cannot animate Images. - * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation - * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. + * The main difference between an Arcade Sprite and an Arcade Image is that you cannot animate an Arcade Image. + * If you do not require animation then you can safely use Arcade Images instead of Arcade Sprites. * * @class Sprite * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * @@ -85,10 +81,10 @@ var ArcadeSprite = new Class({ Sprite.call(this, scene, x, y, texture, frame); /** - * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. + * This Game Object's Physics Body. * * @name Phaser.Physics.Arcade.Sprite#body - * @type {?Phaser.Physics.Arcade.Body} + * @type {?(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} * @default null * @since 3.0.0 */ diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 415f8ea69..524c23dde 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -10,7 +10,6 @@ var CONST = require('./const'); var RadToDeg = require('../../math/RadToDeg'); var Rectangle = require('../../geom/rectangle/Rectangle'); var RectangleContains = require('../../geom/rectangle/Contains'); -var TransformMatrix = require('../../gameobjects/components/TransformMatrix'); var Vector2 = require('../../math/Vector2'); /** @@ -36,8 +35,10 @@ var Vector2 = require('../../math/Vector2'); * @classdesc * A Dynamic Arcade Body. * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticBody}. + * * @class Body - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * @@ -137,8 +138,8 @@ var Body = new Class({ this.isCircle = false; /** - * The unscaled radius of this Body's boundary (if circular), as set by setCircle, in source pixels. - * The true radius (if circular) is equal to halfWidth. + * If this Body is circular, this is the unscaled radius of the Body's boundary, as set by setCircle(), in source pixels. + * The true radius is equal to `halfWidth`. * * @name Phaser.Physics.Arcade.Body#radius * @type {number} @@ -177,7 +178,7 @@ var Body = new Class({ this.prev = new Vector2(gameObject.x, gameObject.y); /** - * Whether this Body's rotation is affected by its angular acceleration and velocity. + * Whether this Body's `rotation` is affected by its angular acceleration and angular velocity. * * @name Phaser.Physics.Arcade.Body#allowRotation * @type {boolean} @@ -187,7 +188,7 @@ var Body = new Class({ this.allowRotation = true; /** - * This body's rotation, in degrees, based on its angular acceleration and velocity. + * This body's rotation, in degrees, based on its angular acceleration and angular velocity. * The Body's rotation controls the `angle` of its Game Object. * It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle. * @@ -207,7 +208,8 @@ var Body = new Class({ this.preRotation = gameObject.angle; /** - * The width of the Body's boundary. If circular, this is also the Body's diameter. + * The width of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. * * @name Phaser.Physics.Arcade.Body#width * @type {number} @@ -217,7 +219,8 @@ var Body = new Class({ this.width = width; /** - * The height of the Body's boundary. If circular, this is also the Body's diameter. + * The height of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. * * @name Phaser.Physics.Arcade.Body#height * @type {number} @@ -227,7 +230,8 @@ var Body = new Class({ this.height = height; /** - * The unscaled width of the Body, in source pixels. The default is the width of the Body's Game Object's texture frame. + * The unscaled width of the Body, in source pixels, as set by setSize(). + * The default is the width of the Body's Game Object's texture frame. * * @name Phaser.Physics.Arcade.Body#sourceWidth * @type {number} @@ -237,7 +241,8 @@ var Body = new Class({ this.sourceWidth = width; /** - * The unscaled height of the Body, in source pixels. The default is the height of the Body's Game Object's texture frame. + * The unscaled height of the Body, in source pixels, as set by setSize(). + * The default is the height of the Body's Game Object's texture frame. * * @name Phaser.Physics.Arcade.Body#sourceHeight * @type {number} @@ -253,7 +258,7 @@ var Body = new Class({ } /** - * Half the Body's width. + * Half the Body's width, in pixels. * * @name Phaser.Physics.Arcade.Body#halfWidth * @type {number} @@ -262,7 +267,7 @@ var Body = new Class({ this.halfWidth = Math.abs(width / 2); /** - * Half the Body's height. + * Half the Body's height, in pixels. * * @name Phaser.Physics.Arcade.Body#halfHeight * @type {number} @@ -271,7 +276,8 @@ var Body = new Class({ this.halfHeight = Math.abs(height / 2); /** - * The center of the Body's boundary. The midpoint of its `position` (top-left corner) and its bottom-right corner. + * The center of the Body's boundary. + * The midpoint of its `position` (top-left corner) and its bottom-right corner. * * @name Phaser.Physics.Arcade.Body#center * @type {Phaser.Math.Vector2} @@ -280,7 +286,7 @@ var Body = new Class({ this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); /** - * The Body's change in position, in pixels per second. + * The Body's velocity, in pixels per second. * * @name Phaser.Physics.Arcade.Body#velocity * @type {Phaser.Math.Vector2} @@ -289,11 +295,11 @@ var Body = new Class({ this.velocity = new Vector2(); /** - * The Body's calculated change in position, in pixels, at the last step. + * The Body's calculated velocity, in pixels per second, at the last step. * * @name Phaser.Physics.Arcade.Body#newVelocity * @type {Phaser.Math.Vector2} - * @readOnly + * @readonly * @since 3.0.0 */ this.newVelocity = new Vector2(); @@ -317,7 +323,7 @@ var Body = new Class({ this.acceleration = new Vector2(); /** - * Whether this Body's velocity is affected by its drag vector. + * Whether this Body's velocity is affected by its `drag`. * * @name Phaser.Physics.Arcade.Body#allowDrag * @type {boolean} @@ -328,20 +334,30 @@ var Body = new Class({ /** * Absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. * * @name Phaser.Physics.Arcade.Body#drag - * @type {Phaser.Math.Vector2} + * @type {(Phaser.Math.Vector2|number)} * @since 3.0.0 */ this.drag = new Vector2(); /** - * Whether this Body's position is affected by its gravity vector. + * Whether this Body's position is affected by gravity (local or world). * * @name Phaser.Physics.Arcade.Body#allowGravity * @type {boolean} * @default true * @since 3.0.0 + * @see Phaser.Physics.Arcade.Body#gravity + * @see Phaser.Physics.Arcade.World#gravity */ this.allowGravity = true; @@ -352,6 +368,7 @@ var Body = new Class({ * @name Phaser.Physics.Arcade.Body#gravity * @type {Phaser.Math.Vector2} * @since 3.0.0 + * @see Phaser.Physics.Arcade.World#gravity */ this.gravity = new Vector2(); @@ -366,7 +383,7 @@ var Body = new Class({ /** * Rebound following a collision with the world boundary, relative to 1. - * If empty, `bounce` is used instead. + * If null, `bounce` is used instead. * * @name Phaser.Physics.Arcade.Body#worldBounce * @type {?Phaser.Math.Vector2} @@ -384,7 +401,7 @@ var Body = new Class({ * @type {boolean} * @default false * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#event:worldbounds + * @see Phaser.Physics.Arcade.World#worldboundsEvent */ this.onWorldBounds = false; @@ -395,7 +412,7 @@ var Body = new Class({ * @type {boolean} * @default false * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#event:collide + * @see Phaser.Physics.Arcade.World#collideEvent */ this.onCollide = false; @@ -406,14 +423,13 @@ var Body = new Class({ * @type {boolean} * @default false * @since 3.0.0 - * @see Phaser.Physics.Arcade.World#event:overlap + * @see Phaser.Physics.Arcade.World#overlapEvent */ this.onOverlap = false; /** - * The Body's absolute maximum velocity. - * - * This limits the Body's rate of movement but not its `velocity` values (which can still exceed `maxVelocity`). + * The Body's absolute maximum velocity, in pixels per second. + * The horizontal and vertical components are applied separately. * * @name Phaser.Physics.Arcade.Body#maxVelocity * @type {Phaser.Math.Vector2} @@ -422,8 +438,10 @@ var Body = new Class({ this.maxVelocity = new Vector2(10000, 10000); /** - * If this Body is `immovable` and in motion, this the proportion of this Body's movement received by the riding body on each axis, relative to 1. - * The default value (1, 0) moves the riding body horizontally in equal proportion and vertically not at all. + * If this Body is `immovable` and in motion, `friction` is the proportion of this Body's motion received by the riding Body on each axis, relative to 1. + * The default value (1, 0) moves the riding Body horizontally in equal proportion to this Body and vertically not at all. + * The horizontal component (x) is applied only when two colliding Bodies are separated vertically. + * The vertical component (y) is applied only when two colliding Bodies are separated horizontally. * * @name Phaser.Physics.Arcade.Body#friction * @type {Phaser.Math.Vector2} @@ -450,7 +468,7 @@ var Body = new Class({ this.useDamping = false; /** - * The rate of change of this Body's rotation, in degrees per second. + * The rate of change of this Body's `rotation`, in degrees per second. * * @name Phaser.Physics.Arcade.Body#angularVelocity * @type {number} @@ -460,7 +478,7 @@ var Body = new Class({ this.angularVelocity = 0; /** - * The rate of change of this Body's angular velocity, in degrees per second squared. + * The Body's angular acceleration (change in angular velocity), in degrees per second squared. * * @name Phaser.Physics.Arcade.Body#angularAcceleration * @type {number} @@ -472,6 +490,8 @@ var Body = new Class({ /** * Loss of angular velocity due to angular movement, in degrees per second. * + * Angular drag is applied only when angular acceleration is zero. + * * @name Phaser.Physics.Arcade.Body#angularDrag * @type {number} * @default 0 @@ -501,7 +521,7 @@ var Body = new Class({ this.mass = 1; /** - * The angle of this Body's velocity vector, in degrees. + * The calculated angle of this Body's velocity vector, in degrees, during the last step. * * @name Phaser.Physics.Arcade.Body#angle * @type {number} @@ -511,7 +531,7 @@ var Body = new Class({ this.angle = 0; /** - * The magnitude of the Body's velocity, as calculated during the last update. + * The calculated magnitude of the Body's velocity, in pixels per second, during the last step. * * @name Phaser.Physics.Arcade.Body#speed * @type {number} @@ -521,7 +541,8 @@ var Body = new Class({ this.speed = 0; /** - * The calculated direction of the Body's velocity. + * The direction of the Body's velocity, as calculated during the last step. + * If the Body is moving on both axes (diagonally), this describes motion on the vertical axis only. * * @name Phaser.Physics.Arcade.Body#facing * @type {integer} @@ -530,7 +551,7 @@ var Body = new Class({ this.facing = CONST.FACING_NONE; /** - * Whether this object can be moved by collisions with another body. + * Whether this Body can be moved by collisions with another Body. * * @name Phaser.Physics.Arcade.Body#immovable * @type {boolean} @@ -550,7 +571,8 @@ var Body = new Class({ this.moves = true; /** - * A flag disabling the default horizontal separation of colliding bodies. Pass your own `processHandler` to the collider. + * A flag disabling the default horizontal separation of colliding bodies. + * Pass your own `collideCallback` to the collider. * * @name Phaser.Physics.Arcade.Body#customSeparateX * @type {boolean} @@ -560,7 +582,8 @@ var Body = new Class({ this.customSeparateX = false; /** - * A flag disabling the default vertical separation of colliding bodies. Pass your own `processHandler` to the collider. + * A flag disabling the default vertical separation of colliding bodies. + * Pass your own `collideCallback` to the collider. * * @name Phaser.Physics.Arcade.Body#customSeparateY * @type {boolean} @@ -600,7 +623,7 @@ var Body = new Class({ this.overlapR = 0; /** - * Whether this Body is overlapped with another and both have zero velocity. + * Whether this Body is overlapped with another and both are not moving. * * @name Phaser.Physics.Arcade.Body#embedded * @type {boolean} @@ -621,7 +644,7 @@ var Body = new Class({ /** * Whether this Body is checked for collisions and for which directions. - * You can set `checkCollision.none = false` to disable collision checks. + * You can set `checkCollision.none = true` to disable collision checks. * * @name Phaser.Physics.Arcade.Body#checkCollision * @type {ArcadeBodyCollision} @@ -694,7 +717,8 @@ var Body = new Class({ * * @name Phaser.Physics.Arcade.Body#physicsType * @type {integer} - * @readOnly + * @readonly + * @default Phaser.Physics.Arcade.DYNAMIC_BODY * @since 3.0.0 */ this.physicsType = CONST.DYNAMIC_BODY; @@ -731,7 +755,7 @@ var Body = new Class({ this._sy = gameObject.scaleY; /** - * The calculated change in the Body's horizontal position during the current step. + * The calculated change in the Body's horizontal position during the last step. * * @name Phaser.Physics.Arcade.Body#_dx * @type {number} @@ -742,7 +766,7 @@ var Body = new Class({ this._dx = 0; /** - * The calculated change in the Body's vertical position during the current step. + * The calculated change in the Body's vertical position during the last step. * * @name Phaser.Physics.Arcade.Body#_dy * @type {number} @@ -761,12 +785,11 @@ var Body = new Class({ * @since 3.0.0 */ this._bounds = new Rectangle(); - - this._tempMatrix = new TransformMatrix(); }, /** - * Updates this Body's transform, dimensions, and position from its Game Object. + * Updates the Body's `transform`, `width`, `height`, and `center` from its Game Object. + * The Body's `position` isn't changed. * * @method Phaser.Physics.Arcade.Body#updateBounds * @since 3.0.0 @@ -781,13 +804,15 @@ var Body = new Class({ if (sprite.parentContainer) { - var matrix = sprite.getWorldTransformMatrix(this._tempMatrix); + var matrix = sprite.getWorldTransformMatrix(this.world._tempMatrix, this.world._tempMatrix2); transform.x = matrix.tx; transform.y = matrix.ty; transform.rotation = RadToDeg(matrix.rotation); transform.scaleX = matrix.scaleX; transform.scaleY = matrix.scaleY; + transform.displayOriginX = sprite.displayOriginX; + transform.displayOriginY = sprite.displayOriginY; } else { @@ -796,6 +821,8 @@ var Body = new Class({ transform.rotation = sprite.angle; transform.scaleX = sprite.scaleX; transform.scaleY = sprite.scaleY; + transform.displayOriginX = sprite.displayOriginX; + transform.displayOriginY = sprite.displayOriginY; } var recalc = false; @@ -832,7 +859,7 @@ var Body = new Class({ }, /** - * Updates the Body's `center` from its `position` and dimensions. + * Updates the Body's `center` from its `position`, `width`, and `height`. * * @method Phaser.Physics.Arcade.Body#updateCenter * @since 3.0.0 @@ -849,7 +876,7 @@ var Body = new Class({ * @fires Phaser.Physics.Arcade.World#worldbounds * @since 3.0.0 * - * @param {number} delta - The delta time, in ms, elapsed since the last frame. + * @param {number} delta - The delta time, in seconds, elapsed since the last frame. */ update: function (delta) { @@ -923,8 +950,8 @@ var Body = new Class({ } } - this._dx = this.deltaX(); - this._dy = this.deltaY(); + this._dx = this.position.x - this.prev.x; + this._dy = this.position.y - this.prev.y; }, /** @@ -937,8 +964,8 @@ var Body = new Class({ */ postUpdate: function () { - this._dx = this.deltaX(); - this._dy = this.deltaY(); + this._dx = this.position.x - this.prev.x; + this._dy = this.position.y - this.prev.y; if (this.moves) { @@ -1071,14 +1098,15 @@ var Body = new Class({ /** * Sizes and positions this Body's boundary, as a rectangle. - * Modifies the Body's `offset` if `center` is true (the default). + * Modifies the Body `offset` if `center` is true (the default). + * Resets the width and height to match current frame, if no width and height provided and a frame is found. * * @method Phaser.Physics.Arcade.Body#setSize * @since 3.0.0 * - * @param {number} width - The width of the Body, in source pixels. - * @param {number} height - The height of the Body, in source pixels. - * @param {boolean} [center=true] - Modify the Body's `offset`, placing the Body's center on its Game Object's center. + * @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param {boolean} [center=true] - Modify the Body's `offset`, placing the Body's center on its Game Object's center. Only works if the Game Object has the `getCenter` method. * * @return {Phaser.Physics.Arcade.Body} This Body object. */ @@ -1088,6 +1116,16 @@ var Body = new Class({ var gameObject = this.gameObject; + if (!width && gameObject.frame) + { + width = gameObject.frame.realWidth; + } + + if (!height && gameObject.frame) + { + height = gameObject.frame.realHeight; + } + this.sourceWidth = width; this.sourceHeight = height; @@ -1319,7 +1357,7 @@ var Body = new Class({ */ deltaX: function () { - return this.position.x - this.prev.x; + return this._dx; }, /** @@ -1333,7 +1371,7 @@ var Body = new Class({ */ deltaY: function () { - return this.position.y - this.prev.y; + return this._dy; }, /** @@ -1359,7 +1397,10 @@ var Body = new Class({ { this.enable = false; - this.world.pendingDestroy.set(this); + if (this.world) + { + this.world.pendingDestroy.set(this); + } }, /** @@ -1373,12 +1414,13 @@ var Body = new Class({ drawDebug: function (graphic) { var pos = this.position; + var x = pos.x + this.halfWidth; var y = pos.y + this.halfHeight; if (this.debugShowBody) { - graphic.lineStyle(1, this.debugBodyColor); + graphic.lineStyle(graphic.defaultStrokeWidth, this.debugBodyColor); if (this.isCircle) { @@ -1392,7 +1434,7 @@ var Body = new Class({ if (this.debugShowVelocity) { - graphic.lineStyle(1, this.world.defaults.velocityDebugColor, 1); + graphic.lineStyle(graphic.defaultStrokeWidth, this.world.defaults.velocityDebugColor, 1); graphic.lineBetween(x, y, x + this.velocity.x / 2, y + this.velocity.y / 2); } }, @@ -1444,6 +1486,8 @@ var Body = new Class({ { this.velocity.set(x, y); + this.speed = Math.sqrt(x * x + y * y); + return this; }, @@ -1461,6 +1505,11 @@ var Body = new Class({ { this.velocity.x = value; + var vx = value; + var vy = this.velocity.y; + + this.speed = Math.sqrt(vx * vx + vy * vy); + return this; }, @@ -1478,6 +1527,11 @@ var Body = new Class({ { this.velocity.y = value; + var vx = this.velocity.x; + var vy = value; + + this.speed = Math.sqrt(vx * vx + vy * vy); + return this; }, @@ -1906,6 +1960,25 @@ var Body = new Class({ return this; }, + /** + * Sets the Body's `enable` property. + * + * @method Phaser.Physics.Arcade.Body#setEnable + * @since 3.15.0 + * + * @param {boolean} [value=true] - The value to assign to `enable`. + * + * @return {Phaser.Physics.Arcade.Body} This Body object. + */ + setEnable: function (value) + { + if (value === undefined) { value = true; } + + this.enable = value; + + return this; + }, + /** * The Body's horizontal position (left edge). * @@ -1953,7 +2026,7 @@ var Body = new Class({ * * @name Phaser.Physics.Arcade.Body#left * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ left: { @@ -1970,7 +2043,7 @@ var Body = new Class({ * * @name Phaser.Physics.Arcade.Body#right * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ right: { @@ -1987,7 +2060,7 @@ var Body = new Class({ * * @name Phaser.Physics.Arcade.Body#top * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ top: { @@ -2004,7 +2077,7 @@ var Body = new Class({ * * @name Phaser.Physics.Arcade.Body#bottom * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ bottom: { diff --git a/src/physics/arcade/Collider.js b/src/physics/arcade/Collider.js index d340b5974..5a35ecbc7 100644 --- a/src/physics/arcade/Collider.js +++ b/src/physics/arcade/Collider.js @@ -8,15 +8,16 @@ var Class = require('../../utils/Class'); /** * @classdesc - * [description] + * An Arcade Physics Collider will automatically check for collision, or overlaps, between two objects + * every step. If a collision, or overlap, occurs it will invoke the given callbacks. * * @class Collider - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.Physics.Arcade.World} world - The Arcade physics World that will manage the collisions. + * @param {boolean} overlapOnly - Whether to check for collisions or overlap. * @param {ArcadeColliderType} object1 - The first object to check for collision. * @param {ArcadeColliderType} object2 - The second object to check for collision. * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. @@ -30,7 +31,7 @@ var Collider = new Class({ function Collider (world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) { /** - * [description] + * The world in which the bodies will collide. * * @name Phaser.Physics.Arcade.Collider#world * @type {Phaser.Physics.Arcade.World} @@ -39,7 +40,7 @@ var Collider = new Class({ this.world = world; /** - * [description] + * The name of the collider (unused by Phaser). * * @name Phaser.Physics.Arcade.Collider#name * @type {string} @@ -48,7 +49,7 @@ var Collider = new Class({ this.name = ''; /** - * [description] + * Whether the collider is active. * * @name Phaser.Physics.Arcade.Collider#active * @type {boolean} @@ -58,7 +59,7 @@ var Collider = new Class({ this.active = true; /** - * [description] + * Whether to check for collisions or overlaps. * * @name Phaser.Physics.Arcade.Collider#overlapOnly * @type {boolean} @@ -67,7 +68,7 @@ var Collider = new Class({ this.overlapOnly = overlapOnly; /** - * [description] + * The first object to check for collision. * * @name Phaser.Physics.Arcade.Collider#object1 * @type {ArcadeColliderType} @@ -76,7 +77,7 @@ var Collider = new Class({ this.object1 = object1; /** - * [description] + * The second object to check for collision. * * @name Phaser.Physics.Arcade.Collider#object2 * @type {ArcadeColliderType} @@ -85,7 +86,7 @@ var Collider = new Class({ this.object2 = object2; /** - * [description] + * The callback to invoke when the two objects collide. * * @name Phaser.Physics.Arcade.Collider#collideCallback * @type {ArcadePhysicsCallback} @@ -94,7 +95,7 @@ var Collider = new Class({ this.collideCallback = collideCallback; /** - * [description] + * If a processCallback exists it must return true or collision checking will be skipped. * * @name Phaser.Physics.Arcade.Collider#processCallback * @type {ArcadePhysicsCallback} @@ -103,7 +104,7 @@ var Collider = new Class({ this.processCallback = processCallback; /** - * [description] + * The context the collideCallback and processCallback will run in. * * @name Phaser.Physics.Arcade.Collider#callbackContext * @type {object} @@ -113,14 +114,16 @@ var Collider = new Class({ }, /** - * [description] + * A name for the Collider. + * + * Phaser does not use this value, it's for your own reference. * * @method Phaser.Physics.Arcade.Collider#setName * @since 3.1.0 * - * @param {string} name - [description] + * @param {string} name - The name to assign to the Collider. * - * @return {Phaser.Physics.Arcade.Collider} [description] + * @return {Phaser.Physics.Arcade.Collider} This Collider instance. */ setName: function (name) { @@ -130,7 +133,7 @@ var Collider = new Class({ }, /** - * [description] + * Called by World as part of its step processing, initial operation of collision checking. * * @method Phaser.Physics.Arcade.Collider#update * @since 3.0.0 @@ -148,7 +151,7 @@ var Collider = new Class({ }, /** - * [description] + * Removes Collider from World and disposes of its resources. * * @method Phaser.Physics.Arcade.Collider#destroy * @since 3.0.0 diff --git a/src/physics/arcade/Factory.js b/src/physics/arcade/Factory.js index f12bdd4f6..ac87f1005 100644 --- a/src/physics/arcade/Factory.js +++ b/src/physics/arcade/Factory.js @@ -17,7 +17,7 @@ var StaticPhysicsGroup = require('./StaticPhysicsGroup'); * Objects that are created by this Factory are automatically added to the physics world. * * @class Factory - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * @@ -58,7 +58,7 @@ var Factory = new Class({ }, /** - * Create a new Arcade Physics Collider object. + * Creates a new Arcade Physics Collider object. * * @method Phaser.Physics.Arcade.Factory#collider * @since 3.0.0 @@ -77,7 +77,7 @@ var Factory = new Class({ }, /** - * Create a new Arcade Physics Collider Overlap object. + * Creates a new Arcade Physics Collider Overlap object. * * @method Phaser.Physics.Arcade.Factory#overlap * @since 3.0.0 @@ -101,8 +101,8 @@ var Factory = new Class({ * @method Phaser.Physics.Arcade.Factory#existing * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {boolean} [isStatic=false] - Set to true to create a Static body, otherwise it will create a Dynamic body. + * @param {Phaser.GameObjects.GameObject} gameObject - A Game Object. + * @param {boolean} [isStatic=false] - Create a Static body (true) or Dynamic body (false). * * @return {Phaser.GameObjects.GameObject} The Game Object. */ @@ -220,8 +220,8 @@ var Factory = new Class({ * @method Phaser.Physics.Arcade.Factory#staticGroup * @since 3.0.0 * - * @param {object|object[]} [children] - [description] - * @param {GroupConfig} [config] - [description] + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. * * @return {Phaser.Physics.Arcade.StaticGroup} The Static Group object that was created. */ @@ -237,8 +237,8 @@ var Factory = new Class({ * @method Phaser.Physics.Arcade.Factory#group * @since 3.0.0 * - * @param {object|object[]} [children] - [description] - * @param {PhysicsGroupConfig} [config] - [description] + * @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group. * * @return {Phaser.Physics.Arcade.Group} The Group object that was created. */ diff --git a/src/physics/arcade/GetOverlapX.js b/src/physics/arcade/GetOverlapX.js index 6103dff60..15283c24f 100644 --- a/src/physics/arcade/GetOverlapX.js +++ b/src/physics/arcade/GetOverlapX.js @@ -7,17 +7,18 @@ var CONST = require('./const'); /** - * [description] + * Calculates and returns the horizontal overlap between two arcade physics bodies and sets their properties + * accordingly, including: `touching.left`, `touching.right`, `touching.none` and `overlapX'. * * @function Phaser.Physics.Arcade.GetOverlapX * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to separate. + * @param {boolean} overlapOnly - Is this an overlap only check, or part of separation? + * @param {number} bias - A value added to the delta values during collision checks. Increase it to prevent sprite tunneling(sprites passing through another instead of colliding). * - * @return {number} [description] + * @return {number} The amount of overlap. */ var GetOverlapX = function (body1, body2, overlapOnly, bias) { diff --git a/src/physics/arcade/GetOverlapY.js b/src/physics/arcade/GetOverlapY.js index b0b41a91c..03f8ca31f 100644 --- a/src/physics/arcade/GetOverlapY.js +++ b/src/physics/arcade/GetOverlapY.js @@ -7,17 +7,18 @@ var CONST = require('./const'); /** - * [description] + * Calculates and returns the vertical overlap between two arcade physics bodies and sets their properties + * accordingly, including: `touching.up`, `touching.down`, `touching.none` and `overlapY'. * * @function Phaser.Physics.Arcade.GetOverlapY * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to separate. + * @param {boolean} overlapOnly - Is this an overlap only check, or part of separation? + * @param {number} bias - A value added to the delta values during collision checks. Increase it to prevent sprite tunneling(sprites passing through another instead of colliding). * - * @return {number} [description] + * @return {number} The amount of overlap. */ var GetOverlapY = function (body1, body2, overlapOnly, bias) { diff --git a/src/physics/arcade/PhysicsGroup.js b/src/physics/arcade/PhysicsGroup.js index 8808fcab0..5d090b823 100644 --- a/src/physics/arcade/PhysicsGroup.js +++ b/src/physics/arcade/PhysicsGroup.js @@ -9,6 +9,7 @@ var Class = require('../../utils/Class'); var CONST = require('./const'); var GetFastValue = require('../../utils/object/GetFastValue'); var Group = require('../../gameobjects/group/Group'); +var IsPlainObject = require('../../utils/object/IsPlainObject'); /** * @typedef {object} PhysicsGroupConfig @@ -24,6 +25,7 @@ var Group = require('../../gameobjects/group/Group'); * @property {number} [bounceY=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.y}. * @property {number} [dragX=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.x}. * @property {number} [dragY=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.y}. + * @property {boolean} [enable=true] - Sets {@link Phaser.Physics.Arcade.Body#enable enable}. * @property {number} [gravityX=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.x}. * @property {number} [gravityY=0] - Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.y}. * @property {number} [frictionX=0] - Sets {@link Phaser.Physics.Arcade.Body#friction friction.x}. @@ -40,45 +42,48 @@ var Group = require('../../gameobjects/group/Group'); /** * @typedef {object} PhysicsGroupDefaults * - * @property {boolean} setCollideWorldBounds - [description] - * @property {number} setAccelerationX - [description] - * @property {number} setAccelerationY - [description] - * @property {boolean} setAllowDrag - [description] - * @property {boolean} setAllowGravity - [description] - * @property {boolean} setAllowRotation - [description] - * @property {number} setBounceX - [description] - * @property {number} setBounceY - [description] - * @property {number} setDragX - [description] - * @property {number} setDragY - [description] - * @property {number} setGravityX - [description] - * @property {number} setGravityY - [description] - * @property {number} setFrictionX - [description] - * @property {number} setFrictionY - [description] - * @property {number} setVelocityX - [description] - * @property {number} setVelocityY - [description] - * @property {number} setAngularVelocity - [description] - * @property {number} setAngularAcceleration - [description] - * @property {number} setAngularDrag - [description] - * @property {number} setMass - [description] - * @property {boolean} setImmovable - [description] + * @property {boolean} setCollideWorldBounds - As {@link Phaser.Physics.Arcade.Body#setCollideWorldBounds}. + * @property {number} setAccelerationX - As {@link Phaser.Physics.Arcade.Body#setAccelerationX}. + * @property {number} setAccelerationY - As {@link Phaser.Physics.Arcade.Body#setAccelerationY}. + * @property {boolean} setAllowDrag - As {@link Phaser.Physics.Arcade.Body#setAllowDrag}. + * @property {boolean} setAllowGravity - As {@link Phaser.Physics.Arcade.Body#setAllowGravity}. + * @property {boolean} setAllowRotation - As {@link Phaser.Physics.Arcade.Body#setAllowRotation}. + * @property {number} setBounceX - As {@link Phaser.Physics.Arcade.Body#setBounceX}. + * @property {number} setBounceY - As {@link Phaser.Physics.Arcade.Body#setBounceY}. + * @property {number} setDragX - As {@link Phaser.Physics.Arcade.Body#setDragX}. + * @property {number} setDragY - As {@link Phaser.Physics.Arcade.Body#setDragY}. + * @property {boolean} setEnable - As {@link Phaser.Physics.Arcade.Body#setEnable}. + * @property {number} setGravityX - As {@link Phaser.Physics.Arcade.Body#setGravityX}. + * @property {number} setGravityY - As {@link Phaser.Physics.Arcade.Body#setGravityY}. + * @property {number} setFrictionX - As {@link Phaser.Physics.Arcade.Body#setFrictionX}. + * @property {number} setFrictionY - As {@link Phaser.Physics.Arcade.Body#setFrictionY}. + * @property {number} setVelocityX - As {@link Phaser.Physics.Arcade.Body#setVelocityX}. + * @property {number} setVelocityY - As {@link Phaser.Physics.Arcade.Body#setVelocityY}. + * @property {number} setAngularVelocity - As {@link Phaser.Physics.Arcade.Body#setAngularVelocity}. + * @property {number} setAngularAcceleration - As {@link Phaser.Physics.Arcade.Body#setAngularAcceleration}. + * @property {number} setAngularDrag - As {@link Phaser.Physics.Arcade.Body#setAngularDrag}. + * @property {number} setMass - As {@link Phaser.Physics.Arcade.Body#setMass}. + * @property {boolean} setImmovable - As {@link Phaser.Physics.Arcade.Body#setImmovable}. */ /** * @classdesc * An Arcade Physics Group object. * - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * All Game Objects created by this Group will automatically be given dynamic Arcade Physics bodies. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticGroup}. * * @class Group * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {PhysicsGroupConfig} [config] - [description] + * @param {Phaser.Physics.Arcade.World} world - The physics simulation. + * @param {Phaser.Scene} scene - The scene this group belongs to. + * @param {(Phaser.GameObjects.GameObject[]|PhysicsGroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {PhysicsGroupConfig|GroupCreateConfig} [config] - Settings for this group. */ var PhysicsGroup = new Class({ @@ -88,18 +93,45 @@ var PhysicsGroup = new Class({ function PhysicsGroup (world, scene, children, config) { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') + if (!children && !config) { + config = { + createCallback: this.createCallbackHandler, + removeCallback: this.removeCallbackHandler + }; + } + else if (IsPlainObject(children)) + { + // children is a plain object, so swizzle them: config = children; children = null; + + config.createCallback = this.createCallbackHandler; + config.removeCallback = this.removeCallbackHandler; } - else if (config === undefined) + else if (Array.isArray(children) && IsPlainObject(children[0])) { - config = {}; + // children is an array of plain objects + config = children; + children = null; + + config.forEach(function (singleConfig) + { + singleConfig.createCallback = this.createCallbackHandler; + singleConfig.removeCallback = this.removeCallbackHandler; + }); + } + else + { + // config is not defined and children is not a plain object nor an array of plain objects + config = { + createCallback: this.createCallbackHandler, + removeCallback: this.removeCallbackHandler + }; } /** - * [description] + * The physics simulation. * * @name Phaser.Physics.Arcade.Group#world * @type {Phaser.Physics.Arcade.World} @@ -107,29 +139,28 @@ var PhysicsGroup = new Class({ */ this.world = world; - config.createCallback = this.createCallbackHandler; - config.removeCallback = this.removeCallbackHandler; - /** * The class to create new group members from. + * This should be ArcadeImage, ArcadeSprite, or a class extending one of those. * * @name Phaser.Physics.Arcade.Group#classType - * @type {Phaser.Physics.Arcade.Sprite} + * @type {(Phaser.Physics.Arcade.Image|Phaser.Physics.Arcade.Sprite)} * @default ArcadeSprite */ config.classType = GetFastValue(config, 'classType', ArcadeSprite); /** - * [description] + * The physics type of the Group's members. * * @name Phaser.Physics.Arcade.Group#physicsType * @type {integer} + * @default Phaser.Physics.Arcade.DYNAMIC_BODY * @since 3.0.0 */ this.physicsType = CONST.DYNAMIC_BODY; /** - * [description] + * Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument. * * @name Phaser.Physics.Arcade.Group#defaults * @type {PhysicsGroupDefaults} @@ -146,6 +177,7 @@ var PhysicsGroup = new Class({ setBounceY: GetFastValue(config, 'bounceY', 0), setDragX: GetFastValue(config, 'dragX', 0), setDragY: GetFastValue(config, 'dragY', 0), + setEnable: GetFastValue(config, 'enable', true), setGravityX: GetFastValue(config, 'gravityX', 0), setGravityY: GetFastValue(config, 'gravityY', 0), setFrictionX: GetFastValue(config, 'frictionX', 0), @@ -163,12 +195,12 @@ var PhysicsGroup = new Class({ }, /** - * [description] + * Enables a Game Object's Body and assigns `defaults`. Called when a Group member is added or created. * * @method Phaser.Physics.Arcade.Group#createCallbackHandler * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {Phaser.GameObjects.GameObject} child - The Game Object being added. */ createCallbackHandler: function (child) { @@ -186,12 +218,12 @@ var PhysicsGroup = new Class({ }, /** - * [description] + * Disables a Game Object's Body. Called when a Group member is removed. * * @method Phaser.Physics.Arcade.Group#removeCallbackHandler * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {Phaser.GameObjects.GameObject} child - The Game Object being removed. */ removeCallbackHandler: function (child) { @@ -202,14 +234,14 @@ var PhysicsGroup = new Class({ }, /** - * [description] + * Sets the velocity of each Group member. * * @method Phaser.Physics.Arcade.Group#setVelocity * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} step - [description] + * @param {number} x - The horizontal velocity. + * @param {number} y - The vertical velocity. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x, y), the second (x + step, y + step), and so on. * * @return {Phaser.Physics.Arcade.Group} This Physics Group object. */ @@ -228,13 +260,13 @@ var PhysicsGroup = new Class({ }, /** - * [description] + * Sets the horizontal velocity of each Group member. * * @method Phaser.Physics.Arcade.Group#setVelocityX * @since 3.0.0 * - * @param {number} value - [description] - * @param {number} step - [description] + * @param {number} value - The velocity value. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (x), the second (x + step), and so on. * * @return {Phaser.Physics.Arcade.Group} This Physics Group object. */ @@ -253,13 +285,13 @@ var PhysicsGroup = new Class({ }, /** - * [description] + * Sets the vertical velocity of each Group member. * * @method Phaser.Physics.Arcade.Group#setVelocityY * @since 3.0.0 * - * @param {number} value - [description] - * @param {number} step - [description] + * @param {number} value - The velocity value. + * @param {number} [step=0] - The velocity increment. When set, the first member receives velocity (y), the second (y + step), and so on. * * @return {Phaser.Physics.Arcade.Group} This Physics Group object. */ diff --git a/src/physics/arcade/SeparateX.js b/src/physics/arcade/SeparateX.js index 14be9c070..923cc791f 100644 --- a/src/physics/arcade/SeparateX.js +++ b/src/physics/arcade/SeparateX.js @@ -7,17 +7,21 @@ var GetOverlapX = require('./GetOverlapX'); /** - * [description] + * Separates two overlapping bodies on the X-axis (horizontally). + * + * Separation involves moving two overlapping bodies so they don't overlap anymore and adjusting their velocities based on their mass. This is a core part of collision detection. + * + * The bodies won't be separated if there is no horizontal overlap between them, if they are static, or if either one uses custom logic for its separation. * * @function Phaser.Physics.Arcade.SeparateX * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to separate. + * @param {boolean} overlapOnly - If `true`, the bodies will only have their overlap data set and no separation will take place. + * @param {number} bias - A value to add to the delta value during overlap checking. Used to prevent sprite tunneling. * - * @return {boolean} [description] + * @return {boolean} `true` if the two bodies overlap horizontally, otherwise `false`. */ var SeparateX = function (body1, body2, overlapOnly, bias) { diff --git a/src/physics/arcade/SeparateY.js b/src/physics/arcade/SeparateY.js index 0f9666360..a244c96b6 100644 --- a/src/physics/arcade/SeparateY.js +++ b/src/physics/arcade/SeparateY.js @@ -7,17 +7,21 @@ var GetOverlapY = require('./GetOverlapY'); /** - * [description] + * Separates two overlapping bodies on the Y-axis (vertically). + * + * Separation involves moving two overlapping bodies so they don't overlap anymore and adjusting their velocities based on their mass. This is a core part of collision detection. + * + * The bodies won't be separated if there is no vertical overlap between them, if they are static, or if either one uses custom logic for its separation. * * @function Phaser.Physics.Arcade.SeparateY * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.Body} body1 - [description] - * @param {Phaser.Physics.Arcade.Body} body2 - [description] - * @param {boolean} overlapOnly - [description] - * @param {number} bias - [description] + * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to separate. + * @param {boolean} overlapOnly - If `true`, the bodies will only have their overlap data set and no separation will take place. + * @param {number} bias - A value to add to the delta value during overlap checking. Used to prevent sprite tunneling. * - * @return {boolean} [description] + * @return {boolean} `true` if the two bodies overlap vertically, otherwise `false`. */ var SeparateY = function (body1, body2, overlapOnly, bias) { diff --git a/src/physics/arcade/StaticBody.js b/src/physics/arcade/StaticBody.js index e4ce9fbab..d03aeaa8f 100644 --- a/src/physics/arcade/StaticBody.js +++ b/src/physics/arcade/StaticBody.js @@ -12,15 +12,22 @@ var Vector2 = require('../../math/Vector2'); /** * @classdesc - * [description] + * A Static Arcade Physics Body. + * + * A Static Body never moves, and isn't automatically synchronized with its parent Game Object. + * That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually. + * + * A Static Body can collide with other Bodies, but is never moved by collisions. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Body}. * * @class StaticBody - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {Phaser.Physics.Arcade.World} world - The Arcade Physics simulation this Static Body belongs to. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object this Static Body belongs to. */ var StaticBody = new Class({ @@ -32,7 +39,7 @@ var StaticBody = new Class({ var height = (gameObject.height) ? gameObject.height : 64; /** - * [description] + * The Arcade Physics simulation this Static Body belongs to. * * @name Phaser.Physics.Arcade.StaticBody#world * @type {Phaser.Physics.Arcade.World} @@ -41,7 +48,7 @@ var StaticBody = new Class({ this.world = world; /** - * [description] + * The Game Object this Static Body belongs to. * * @name Phaser.Physics.Arcade.StaticBody#gameObject * @type {Phaser.GameObjects.GameObject} @@ -50,7 +57,7 @@ var StaticBody = new Class({ this.gameObject = gameObject; /** - * [description] + * Whether the Static Body's boundary is drawn to the debug display. * * @name Phaser.Physics.Arcade.StaticBody#debugShowBody * @type {boolean} @@ -59,7 +66,7 @@ var StaticBody = new Class({ this.debugShowBody = world.defaults.debugShowStaticBody; /** - * [description] + * The color of this Static Body on the debug display. * * @name Phaser.Physics.Arcade.StaticBody#debugBodyColor * @type {integer} @@ -68,7 +75,7 @@ var StaticBody = new Class({ this.debugBodyColor = world.defaults.staticBodyDebugColor; /** - * [description] + * Whether this Static Body is updated by the physics simulation. * * @name Phaser.Physics.Arcade.StaticBody#enable * @type {boolean} @@ -78,7 +85,7 @@ var StaticBody = new Class({ this.enable = true; /** - * [description] + * Whether this Static Body's boundary is circular (`true`) or rectangular (`false`). * * @name Phaser.Physics.Arcade.StaticBody#isCircle * @type {boolean} @@ -88,7 +95,8 @@ var StaticBody = new Class({ this.isCircle = false; /** - * [description] + * If this Static Body is circular, this is the unscaled radius of the Static Body's boundary, as set by {@link #setCircle}, in source pixels. + * The true radius is equal to `halfWidth`. * * @name Phaser.Physics.Arcade.StaticBody#radius * @type {number} @@ -98,7 +106,9 @@ var StaticBody = new Class({ this.radius = 0; /** - * [description] + * The offset of this Static Body's actual position from any updated position. + * + * Unlike a dynamic Body, a Static Body does not follow its Game Object. As such, this offset is only applied when resizing the Static Body. * * @name Phaser.Physics.Arcade.StaticBody#offset * @type {Phaser.Math.Vector2} @@ -107,7 +117,7 @@ var StaticBody = new Class({ this.offset = new Vector2(); /** - * [description] + * The position of this Static Body within the simulation. * * @name Phaser.Physics.Arcade.StaticBody#position * @type {Phaser.Math.Vector2} @@ -116,7 +126,8 @@ var StaticBody = new Class({ this.position = new Vector2(gameObject.x - gameObject.displayOriginX, gameObject.y - gameObject.displayOriginY); /** - * [description] + * The width of the Static Body's boundary, in pixels. + * If the Static Body is circular, this is also the Static Body's diameter. * * @name Phaser.Physics.Arcade.StaticBody#width * @type {number} @@ -125,7 +136,8 @@ var StaticBody = new Class({ this.width = width; /** - * [description] + * The height of the Static Body's boundary, in pixels. + * If the Static Body is circular, this is also the Static Body's diameter. * * @name Phaser.Physics.Arcade.StaticBody#height * @type {number} @@ -134,7 +146,8 @@ var StaticBody = new Class({ this.height = height; /** - * [description] + * Half the Static Body's width, in pixels. + * If the Static Body is circular, this is also the Static Body's radius. * * @name Phaser.Physics.Arcade.StaticBody#halfWidth * @type {number} @@ -143,7 +156,8 @@ var StaticBody = new Class({ this.halfWidth = Math.abs(this.width / 2); /** - * [description] + * Half the Static Body's height, in pixels. + * If the Static Body is circular, this is also the Static Body's radius. * * @name Phaser.Physics.Arcade.StaticBody#halfHeight * @type {number} @@ -152,7 +166,8 @@ var StaticBody = new Class({ this.halfHeight = Math.abs(this.height / 2); /** - * [description] + * The center of the Static Body's boundary. + * This is the midpoint of its `position` (top-left corner) and its bottom-right corner. * * @name Phaser.Physics.Arcade.StaticBody#center * @type {Phaser.Math.Vector2} @@ -161,38 +176,42 @@ var StaticBody = new Class({ this.center = new Vector2(gameObject.x + this.halfWidth, gameObject.y + this.halfHeight); /** - * [description] + * A constant zero velocity used by the Arcade Physics simulation for calculations. * * @name Phaser.Physics.Arcade.StaticBody#velocity * @type {Phaser.Math.Vector2} + * @readonly * @since 3.0.0 */ this.velocity = Vector2.ZERO; /** - * [description] + * A constant `false` value expected by the Arcade Physics simulation. * * @name Phaser.Physics.Arcade.StaticBody#allowGravity * @type {boolean} + * @readonly * @default false * @since 3.0.0 */ this.allowGravity = false; /** - * [description] + * Gravitational force applied specifically to this Body. Values are in pixels per second squared. Always zero for a Static Body. * * @name Phaser.Physics.Arcade.StaticBody#gravity * @type {Phaser.Math.Vector2} + * @readonly * @since 3.0.0 */ this.gravity = Vector2.ZERO; /** - * [description] + * Rebound, or restitution, following a collision, relative to 1. Always zero for a Static Body. * * @name Phaser.Physics.Arcade.StaticBody#bounce * @type {Phaser.Math.Vector2} + * @readonly * @since 3.0.0 */ this.bounce = Vector2.ZERO; @@ -200,17 +219,19 @@ var StaticBody = new Class({ // If true this Body will dispatch events /** - * [description] + * Whether the simulation emits a `worldbounds` event when this StaticBody collides with the world boundary. + * Always false for a Static Body. (Static Bodies never collide with the world boundary and never trigger a `worldbounds` event.) * * @name Phaser.Physics.Arcade.StaticBody#onWorldBounds * @type {boolean} + * @readonly * @default false * @since 3.0.0 */ this.onWorldBounds = false; /** - * [description] + * Whether the simulation emits a `collide` event when this StaticBody collides with another. * * @name Phaser.Physics.Arcade.StaticBody#onCollide * @type {boolean} @@ -220,7 +241,7 @@ var StaticBody = new Class({ this.onCollide = false; /** - * [description] + * Whether the simulation emits an `overlap` event when this StaticBody overlaps with another. * * @name Phaser.Physics.Arcade.StaticBody#onOverlap * @type {boolean} @@ -230,7 +251,7 @@ var StaticBody = new Class({ this.onOverlap = false; /** - * [description] + * The StaticBody's inertia, relative to a default unit (1). With `bounce`, this affects the exchange of momentum (velocities) during collisions. * * @name Phaser.Physics.Arcade.StaticBody#mass * @type {number} @@ -240,7 +261,7 @@ var StaticBody = new Class({ this.mass = 1; /** - * [description] + * Whether this object can be moved by collisions with another body. * * @name Phaser.Physics.Arcade.StaticBody#immovable * @type {boolean} @@ -250,7 +271,7 @@ var StaticBody = new Class({ this.immovable = true; /** - * [description] + * A flag disabling the default horizontal separation of colliding bodies. Pass your own `collideHandler` to the collider. * * @name Phaser.Physics.Arcade.StaticBody#customSeparateX * @type {boolean} @@ -260,7 +281,7 @@ var StaticBody = new Class({ this.customSeparateX = false; /** - * [description] + * A flag disabling the default vertical separation of colliding bodies. Pass your own `collideHandler` to the collider. * * @name Phaser.Physics.Arcade.StaticBody#customSeparateY * @type {boolean} @@ -270,7 +291,7 @@ var StaticBody = new Class({ this.customSeparateY = false; /** - * [description] + * The amount of horizontal overlap (before separation), if this Body is colliding with another. * * @name Phaser.Physics.Arcade.StaticBody#overlapX * @type {number} @@ -280,7 +301,7 @@ var StaticBody = new Class({ this.overlapX = 0; /** - * [description] + * The amount of vertical overlap (before separation), if this Body is colliding with another. * * @name Phaser.Physics.Arcade.StaticBody#overlapY * @type {number} @@ -290,7 +311,7 @@ var StaticBody = new Class({ this.overlapY = 0; /** - * [description] + * The amount of overlap (before separation), if this StaticBody is circular and colliding with another circular body. * * @name Phaser.Physics.Arcade.StaticBody#overlapR * @type {number} @@ -300,7 +321,7 @@ var StaticBody = new Class({ this.overlapR = 0; /** - * [description] + * Whether this StaticBody has ever overlapped with another while both were not moving. * * @name Phaser.Physics.Arcade.StaticBody#embedded * @type {boolean} @@ -310,17 +331,19 @@ var StaticBody = new Class({ this.embedded = false; /** - * [description] + * Whether this StaticBody interacts with the world boundary. + * Always false for a Static Body. (Static Bodies never collide with the world boundary.) * * @name Phaser.Physics.Arcade.StaticBody#collideWorldBounds * @type {boolean} + * @readonly * @default false * @since 3.0.0 */ this.collideWorldBounds = false; /** - * [description] + * Whether this StaticBody is checked for collisions and for which directions. You can set `checkCollision.none = false` to disable collision checks. * * @name Phaser.Physics.Arcade.StaticBody#checkCollision * @type {ArcadeBodyCollision} @@ -329,7 +352,7 @@ var StaticBody = new Class({ this.checkCollision = { none: false, up: true, down: true, left: true, right: true }; /** - * [description] + * Whether this StaticBody has ever collided with another body and in which direction. * * @name Phaser.Physics.Arcade.StaticBody#touching * @type {ArcadeBodyCollision} @@ -338,7 +361,7 @@ var StaticBody = new Class({ this.touching = { none: true, up: false, down: false, left: false, right: false }; /** - * [description] + * Whether this StaticBody was colliding with another body during the last step or any previous step, and in which direction. * * @name Phaser.Physics.Arcade.StaticBody#wasTouching * @type {ArcadeBodyCollision} @@ -347,7 +370,7 @@ var StaticBody = new Class({ this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; /** - * [description] + * Whether this StaticBody has ever collided with a tile or the world boundary. * * @name Phaser.Physics.Arcade.StaticBody#blocked * @type {ArcadeBodyCollision} @@ -356,10 +379,11 @@ var StaticBody = new Class({ this.blocked = { none: true, up: false, down: false, left: false, right: false }; /** - * [description] + * The StaticBody's physics type (static by default). * * @name Phaser.Physics.Arcade.StaticBody#physicsType * @type {integer} + * @default Phaser.Physics.Arcade.STATIC_BODY * @since 3.0.0 */ this.physicsType = CONST.STATIC_BODY; @@ -401,6 +425,8 @@ var StaticBody = new Class({ * @param {boolean} [update=true] - Reposition and resize this Body to match the new Game Object? * * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. + * + * @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject */ setGameObject: function (gameObject, update) { @@ -454,13 +480,13 @@ var StaticBody = new Class({ }, /** - * [description] + * Sets the offset of the body. * * @method Phaser.Physics.Arcade.StaticBody#setOffset * @since 3.4.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The horizontal offset of the Body from the Game Object's center. + * @param {number} y - The vertical offset of the Body from the Game Object's center. * * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ @@ -486,15 +512,16 @@ var StaticBody = new Class({ }, /** - * [description] + * Sets the size of the body. + * Resets the width and height to match current frame, if no width and height provided and a frame is found. * * @method Phaser.Physics.Arcade.StaticBody#setSize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] + * @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param {number} [offsetX] - The horizontal offset of the Body from the Game Object's center. + * @param {number} [offsetY] - The vertical offset of the Body from the Game Object's center. * * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ @@ -503,6 +530,18 @@ var StaticBody = new Class({ if (offsetX === undefined) { offsetX = this.offset.x; } if (offsetY === undefined) { offsetY = this.offset.y; } + var gameObject = this.gameObject; + + if (!width && gameObject.frame) + { + width = gameObject.frame.realWidth; + } + + if (!height && gameObject.frame) + { + height = gameObject.frame.realHeight; + } + this.world.staticTree.remove(this); this.width = width; @@ -524,14 +563,14 @@ var StaticBody = new Class({ }, /** - * [description] + * Sets this Static Body to have a circular body and sets its sizes and position. * * @method Phaser.Physics.Arcade.StaticBody#setCircle * @since 3.0.0 * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] + * @param {number} radius - The radius of the StaticBody, in pixels. + * @param {number} [offsetX] - The horizontal offset of the StaticBody from its Game Object, in pixels. + * @param {number} [offsetY] - The vertical offset of the StaticBody from its Game Object, in pixels. * * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ @@ -569,7 +608,7 @@ var StaticBody = new Class({ }, /** - * [description] + * Updates the StaticBody's `center` from its `position` and dimensions. * * @method Phaser.Physics.Arcade.StaticBody#updateCenter * @since 3.0.0 @@ -580,13 +619,14 @@ var StaticBody = new Class({ }, /** - * [description] + * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * Similar to `updateFromGameObject`, but doesn't modify the Body's dimensions. * * @method Phaser.Physics.Arcade.StaticBody#reset * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} [x] - The x coordinate to reset the body to. If not given will use the parent Game Object's coordinate. + * @param {number} [y] - The y coordinate to reset the body to. If not given will use the parent Game Object's coordinate. */ reset: function (x, y) { @@ -597,6 +637,8 @@ var StaticBody = new Class({ this.world.staticTree.remove(this); + gameObject.setPosition(x, y); + gameObject.getTopLeft(this.position); this.updateCenter(); @@ -605,7 +647,7 @@ var StaticBody = new Class({ }, /** - * [description] + * NOOP function. A Static Body cannot be stopped. * * @method Phaser.Physics.Arcade.StaticBody#stop * @since 3.0.0 @@ -618,14 +660,14 @@ var StaticBody = new Class({ }, /** - * [description] + * Returns the x and y coordinates of the top left and bottom right points of the StaticBody. * * @method Phaser.Physics.Arcade.StaticBody#getBounds * @since 3.0.0 * - * @param {ArcadeBodyBounds} obj - [description] + * @param {ArcadeBodyBounds} obj - The object which will hold the coordinates of the bounds. * - * @return {ArcadeBodyBounds} [description] + * @return {ArcadeBodyBounds} The same object that was passed with `x`, `y`, `right` and `bottom` values matching the respective values of the StaticBody. */ getBounds: function (obj) { @@ -638,15 +680,15 @@ var StaticBody = new Class({ }, /** - * [description] + * Checks to see if a given x,y coordinate is colliding with this Static Body. * * @method Phaser.Physics.Arcade.StaticBody#hitTest * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The x coordinate to check against this body. + * @param {number} y - The y coordinate to check against this body. * - * @return {boolean} [description] + * @return {boolean} `true` if the given coordinate lies within this body, otherwise `false`. */ hitTest: function (x, y) { @@ -654,12 +696,22 @@ var StaticBody = new Class({ }, /** - * [description] + * NOOP + * + * @method Phaser.Physics.Arcade.StaticBody#postUpdate + * @since 3.12.0 + */ + postUpdate: function () + { + }, + + /** + * The absolute (non-negative) change in this StaticBody's horizontal position from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaAbsX * @since 3.0.0 * - * @return {number} [description] + * @return {number} Always zero for a Static Body. */ deltaAbsX: function () { @@ -667,12 +719,12 @@ var StaticBody = new Class({ }, /** - * [description] + * The absolute (non-negative) change in this StaticBody's vertical position from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaAbsY * @since 3.0.0 * - * @return {number} [description] + * @return {number} Always zero for a Static Body. */ deltaAbsY: function () { @@ -680,12 +732,12 @@ var StaticBody = new Class({ }, /** - * [description] + * The change in this StaticBody's horizontal position from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaX * @since 3.0.0 * - * @return {number} [description] + * @return {number} The change in this StaticBody's velocity from the previous step. Always zero. */ deltaX: function () { @@ -693,12 +745,12 @@ var StaticBody = new Class({ }, /** - * [description] + * The change in this StaticBody's vertical position from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaY * @since 3.0.0 * - * @return {number} [description] + * @return {number} The change in this StaticBody's velocity from the previous step. Always zero. */ deltaY: function () { @@ -706,12 +758,12 @@ var StaticBody = new Class({ }, /** - * [description] + * The change in this StaticBody's rotation from the previous step. Always zero. * * @method Phaser.Physics.Arcade.StaticBody#deltaZ * @since 3.0.0 * - * @return {number} [description] + * @return {number} The change in this StaticBody's rotation from the previous step. Always zero. */ deltaZ: function () { @@ -719,7 +771,7 @@ var StaticBody = new Class({ }, /** - * [description] + * Disables this Body and marks it for destruction during the next step. * * @method Phaser.Physics.Arcade.StaticBody#destroy * @since 3.0.0 @@ -732,31 +784,43 @@ var StaticBody = new Class({ }, /** - * [description] + * Draws a graphical representation of the StaticBody for visual debugging purposes. * * @method Phaser.Physics.Arcade.StaticBody#drawDebug * @since 3.0.0 * - * @param {Phaser.GameObjects.Graphics} graphic - [description] + * @param {Phaser.GameObjects.Graphics} graphic - The Graphics object to use for the debug drawing of the StaticBody. */ drawDebug: function (graphic) { var pos = this.position; + var x = pos.x + this.halfWidth; + var y = pos.y + this.halfHeight; + if (this.debugShowBody) { graphic.lineStyle(1, this.debugBodyColor, 1); - graphic.strokeRect(pos.x, pos.y, this.width, this.height); + + if (this.isCircle) + { + graphic.strokeCircle(x, y, this.width / 2); + } + else + { + graphic.strokeRect(pos.x, pos.y, this.width, this.height); + } + } }, /** - * [description] + * Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate. * * @method Phaser.Physics.Arcade.StaticBody#willDrawDebug * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} Whether or not the StaticBody is going to show the debug visualization during postUpdate. */ willDrawDebug: function () { @@ -764,12 +828,12 @@ var StaticBody = new Class({ }, /** - * [description] + * Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero. * * @method Phaser.Physics.Arcade.StaticBody#setMass * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The value to set the Mass to. Values of zero or less are changed to 0.1. * * @return {Phaser.Physics.Arcade.StaticBody} This Static Body object. */ @@ -787,7 +851,7 @@ var StaticBody = new Class({ }, /** - * [description] + * The x coordinate of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#x * @type {number} @@ -812,7 +876,7 @@ var StaticBody = new Class({ }, /** - * [description] + * The y coordinate of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#y * @type {number} @@ -837,11 +901,11 @@ var StaticBody = new Class({ }, /** - * [description] + * Returns the left-most x coordinate of the area of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#left * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ left: { @@ -854,11 +918,11 @@ var StaticBody = new Class({ }, /** - * [description] + * The right-most x coordinate of the area of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#right * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ right: { @@ -871,11 +935,11 @@ var StaticBody = new Class({ }, /** - * [description] + * The highest y coordinate of the area of the StaticBody. * * @name Phaser.Physics.Arcade.StaticBody#top * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ top: { @@ -888,11 +952,11 @@ var StaticBody = new Class({ }, /** - * [description] + * The lowest y coordinate of the area of the StaticBody. (y + height) * * @name Phaser.Physics.Arcade.StaticBody#bottom * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ bottom: { diff --git a/src/physics/arcade/StaticPhysicsGroup.js b/src/physics/arcade/StaticPhysicsGroup.js index ece0b65d1..796efa125 100644 --- a/src/physics/arcade/StaticPhysicsGroup.js +++ b/src/physics/arcade/StaticPhysicsGroup.js @@ -4,27 +4,30 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Phaser.Physics.Arcade.StaticGroup - var ArcadeSprite = require('./ArcadeSprite'); var Class = require('../../utils/Class'); var CONST = require('./const'); var Group = require('../../gameobjects/group/Group'); +var IsPlainObject = require('../../utils/object/IsPlainObject'); /** * @classdesc - * [description] + * An Arcade Physics Static Group object. + * + * All Game Objects created by this Group will automatically be given static Arcade Physics bodies. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Group}. * * @class StaticGroup * @extends Phaser.GameObjects.Group - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * - * @param {Phaser.Physics.Arcade.World} world - [description] - * @param {Phaser.Scene} scene - [description] - * @param {array} children - [description] - * @param {GroupConfig} config - [description] + * @param {Phaser.Physics.Arcade.World} world - The physics simulation. + * @param {Phaser.Scene} scene - The scene this group belongs to. + * @param {(Phaser.GameObjects.GameObject[]|GroupConfig|GroupCreateConfig)} [children] - Game Objects to add to this group; or the `config` argument. + * @param {GroupConfig|GroupCreateConfig} [config] - Settings for this group. */ var StaticPhysicsGroup = new Class({ @@ -34,18 +37,43 @@ var StaticPhysicsGroup = new Class({ function StaticPhysicsGroup (world, scene, children, config) { - if (config === undefined && !Array.isArray(children) && typeof children === 'object') + if (!children && !config) { + config = { + createCallback: this.createCallbackHandler, + removeCallback: this.removeCallbackHandler, + createMultipleCallback: this.createMultipleCallbackHandler, + classType: ArcadeSprite + }; + } + else if (IsPlainObject(children)) + { + // children is a plain object, so swizzle them: config = children; children = null; + + config.createCallback = this.createCallbackHandler; + config.removeCallback = this.removeCallbackHandler; + config.createMultipleCallback = this.createMultipleCallbackHandler; + config.classType = ArcadeSprite; } - else if (config === undefined) + else if (Array.isArray(children) && IsPlainObject(children[0])) { - config = {}; + // children is an array of plain objects + config = children; + children = null; + + config.forEach(function (singleConfig) + { + singleConfig.createCallback = this.createCallbackHandler; + singleConfig.removeCallback = this.removeCallbackHandler; + singleConfig.createMultipleCallback = this.createMultipleCallbackHandler; + singleConfig.classType = ArcadeSprite; + }); } /** - * [description] + * The physics simulation. * * @name Phaser.Physics.Arcade.StaticGroup#world * @type {Phaser.Physics.Arcade.World} @@ -53,17 +81,12 @@ var StaticPhysicsGroup = new Class({ */ this.world = world; - config.createCallback = this.createCallbackHandler; - config.removeCallback = this.removeCallbackHandler; - config.createMultipleCallback = this.createMultipleCallbackHandler; - - config.classType = ArcadeSprite; - /** - * [description] + * The scene this group belongs to. * * @name Phaser.Physics.Arcade.StaticGroup#physicsType * @type {integer} + * @default Phaser.Physics.Arcade.STATIC_BODY * @since 3.0.0 */ this.physicsType = CONST.STATIC_BODY; @@ -72,12 +95,14 @@ var StaticPhysicsGroup = new Class({ }, /** - * [description] + * Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation. * * @method Phaser.Physics.Arcade.StaticGroup#createCallbackHandler * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {Phaser.GameObjects.GameObject} child - The new group member. + * + * @see Phaser.Physics.Arcade.World#enableBody */ createCallbackHandler: function (child) { @@ -88,12 +113,14 @@ var StaticPhysicsGroup = new Class({ }, /** - * [description] + * Disables the group member's physics body, removing it from the simulation. * * @method Phaser.Physics.Arcade.StaticGroup#removeCallbackHandler * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} child - [description] + * @param {Phaser.GameObjects.GameObject} child - The group member being removed. + * + * @see Phaser.Physics.Arcade.World#disableBody */ removeCallbackHandler: function (child) { @@ -104,12 +131,14 @@ var StaticPhysicsGroup = new Class({ }, /** - * [description] + * Refreshes the group. * * @method Phaser.Physics.Arcade.StaticGroup#createMultipleCallbackHandler * @since 3.0.0 * - * @param {object} entries - [description] + * @param {Phaser.GameObjects.GameObject[]} entries - The newly created group members. + * + * @see Phaser.Physics.Arcade.StaticGroup#refresh */ createMultipleCallbackHandler: function () { @@ -117,12 +146,15 @@ var StaticPhysicsGroup = new Class({ }, /** - * [description] + * Resets each Body to the position of its parent Game Object. + * Body sizes aren't changed (use {@link Phaser.Physics.Arcade.Components.Enable#refreshBody} for that). * * @method Phaser.Physics.Arcade.StaticGroup#refresh * @since 3.0.0 * - * @return {Phaser.Physics.Arcade.StaticGroup} [description] + * @return {Phaser.Physics.Arcade.StaticGroup} This group. + * + * @see Phaser.Physics.Arcade.StaticBody#reset */ refresh: function () { diff --git a/src/physics/arcade/World.js b/src/physics/arcade/World.js index 1801a4020..5eeeb4ad8 100644 --- a/src/physics/arcade/World.js +++ b/src/physics/arcade/World.js @@ -27,40 +27,52 @@ var SeparateY = require('./SeparateY'); var Set = require('../../structs/Set'); var StaticBody = require('./StaticBody'); var TileIntersectsBody = require('./tilemap/TileIntersectsBody'); +var TransformMatrix = require('../../gameobjects/components/TransformMatrix'); var Vector2 = require('../../math/Vector2'); var Wrap = require('../../math/Wrap'); /** - * @event Phaser.Physics.Arcade.World#pause + * The physics simulation paused. + * @event Phaser.Physics.Arcade.World#pauseEvent */ /** - * @event Phaser.Physics.Arcade.World#resume + * The physics simulation resumed (from a paused state). + * @event Phaser.Physics.Arcade.World#resumeEvent */ /** - * @event Phaser.Physics.Arcade.World#collide + * Two Game Objects collided. + * This event is emitted only if at least one body has `onCollide` enabled. + * @event Phaser.Physics.Arcade.World#collideEvent * @param {Phaser.GameObjects.GameObject} gameObject1 * @param {Phaser.GameObjects.GameObject} gameObject2 * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 + * @see Phaser.Physics.Arcade.Body#onCollide */ /** - * @event Phaser.Physics.Arcade.World#overlap + * Two Game Objects overlapped. + * This event is emitted only if at least one body has `onOverlap` enabled. + * @event Phaser.Physics.Arcade.World#overlapEvent * @param {Phaser.GameObjects.GameObject} gameObject1 * @param {Phaser.GameObjects.GameObject} gameObject2 * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body1 * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body2 + * @see Phaser.Physics.Arcade.Body#onOverlap */ /** - * @event Phaser.Physics.Arcade.World#worldbounds + * A Body contacted the world boundary. + * This event is emitted only if the body has `onWorldBounds` enabled. + * @event Phaser.Physics.Arcade.World#worldboundsEvent * @param {Phaser.Physics.Arcade.Body} body * @param {boolean} up * @param {boolean} down * @param {boolean} left * @param {boolean} right + * @see Phaser.Physics.Arcade.Body#onWorldBounds */ /** @@ -98,35 +110,35 @@ var Wrap = require('../../math/Wrap'); /** * @typedef {object} CheckCollisionObject * - * @property {boolean} up - [description] - * @property {boolean} down - [description] - * @property {boolean} left - [description] - * @property {boolean} right - [description] + * @property {boolean} up - Will bodies collide with the top side of the world bounds? + * @property {boolean} down - Will bodies collide with the bottom side of the world bounds? + * @property {boolean} left - Will bodies collide with the left side of the world bounds? + * @property {boolean} right - Will bodies collide with the right side of the world bounds? */ /** * @typedef {object} ArcadeWorldDefaults * - * @property {boolean} debugShowBody - [description] - * @property {boolean} debugShowStaticBody - [description] - * @property {boolean} debugShowVelocity - [description] - * @property {number} bodyDebugColor - [description] - * @property {number} staticBodyDebugColor - [description] - * @property {number} velocityDebugColor - [description] + * @property {boolean} debugShowBody - Set to `true` to render dynamic body outlines to the debug display. + * @property {boolean} debugShowStaticBody - Set to `true` to render static body outlines to the debug display. + * @property {boolean} debugShowVelocity - Set to `true` to render body velocity markers to the debug display. + * @property {number} bodyDebugColor - The color of dynamic body outlines when rendered to the debug display. + * @property {number} staticBodyDebugColor - The color of static body outlines when rendered to the debug display. + * @property {number} velocityDebugColor - The color of the velocity markers when rendered to the debug display. */ /** * @typedef {object} ArcadeWorldTreeMinMax * - * @property {number} minX - [description] - * @property {number} minY - [description] - * @property {number} maxX - [description] - * @property {number} maxY - [description] + * @property {number} minX - The minimum x value used in RTree searches. + * @property {number} minY - The minimum y value used in RTree searches. + * @property {number} maxX - The maximum x value used in RTree searches. + * @property {number} maxY - The maximum y value used in RTree searches. */ /** * An Arcade Physics Collider Type. - * + * * @typedef {( * Phaser.GameObjects.GameObject| * Phaser.GameObjects.Group| @@ -156,7 +168,7 @@ var Wrap = require('../../math/Wrap'); * * @class World * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Physics.Arcade + * @memberof Phaser.Physics.Arcade * @constructor * @since 3.0.0 * @@ -257,11 +269,11 @@ var World = new Class({ /** * The number of physics steps to be taken per second. - * + * * This property is read-only. Use the `setFPS` method to modify it at run-time. * * @name Phaser.Physics.Arcade.World#fps - * @readOnly + * @readonly * @type {number} * @default 60 * @since 3.10.0 @@ -302,7 +314,7 @@ var World = new Class({ * The number of steps that took place in the last frame. * * @name Phaser.Physics.Arcade.World#stepsLastFrame - * @readOnly + * @readonly * @type {number} * @since 3.10.0 */ @@ -316,7 +328,7 @@ var World = new Class({ * - 0.5 = double speed * * @name Phaser.Physics.Arcade.World#timeScale - * @property {number} + * @property {number} * @default 1 * @since 3.10.0 */ @@ -416,7 +428,7 @@ var World = new Class({ /** * The maximum number of items per node on the RTree. - * + * * This is ignored if `useTree` is `false`. If you have a large number of bodies in * your world then you may find search performance improves by increasing this value, * to allow more items per node and less node division. @@ -430,7 +442,7 @@ var World = new Class({ /** * Should this Arcade Physics World use an RTree for Dynamic Physics bodies or not? - * + * * An RTree is a fast way of spatially sorting of all the moving bodies in the world. * However, at certain limits, the cost of clearing and inserting the bodies into the * tree every frame becomes more expensive than the search speed gains it provides. @@ -478,6 +490,26 @@ var World = new Class({ */ this.treeMinMax = { minX: 0, minY: 0, maxX: 0, maxY: 0 }; + /** + * A temporary Transform Matrix used by bodies for calculations without them needing their own local copy. + * + * @name Phaser.Physics.Arcade.World#_tempMatrix + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * A temporary Transform Matrix used by bodies for calculations without them needing their own local copy. + * + * @name Phaser.Physics.Arcade.World#_tempMatrix2 + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @private + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + if (this.drawDebug) { this.createDebugGraphic(); @@ -486,7 +518,7 @@ var World = new Class({ /** * Adds an Arcade Physics Body to a Game Object, an array of Game Objects, or the children of a Group. - * + * * The difference between this and the `enableBody` method is that you can pass arrays or Groups * to this method. * @@ -612,7 +644,7 @@ var World = new Class({ * @since 3.10.0 * * @param {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} body - The Body to be added to the simulation. - * + * * @return {(Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody)} The Body that was added to the simulation. */ add: function (body) @@ -635,10 +667,10 @@ var World = new Class({ /** * Disables the Arcade Physics Body of a Game Object, an array of Game Objects, or the children of a Group. - * + * * The difference between this and the `disableBody` method is that you can pass arrays or Groups * to this method. - * + * * The body itself is not deleted, it just has its `enable` property set to false, which * means you can re-enable it again at any point by passing it to enable `World.enable` or `World.add`. * @@ -673,13 +705,13 @@ var World = new Class({ } else { - this.disableBody(child); + this.disableBody(child.body); } } } else { - this.disableBody(entry); + this.disableBody(entry.body); } } }, @@ -832,7 +864,7 @@ var World = new Class({ * checks. * * @method Phaser.Physics.Arcade.World#pause - * @fires Phaser.Physics.Arcade.World#pause + * @fires Phaser.Physics.Arcade.World#pauseEvent * @since 3.0.0 * * @return {Phaser.Physics.Arcade.World} This World object. @@ -850,7 +882,7 @@ var World = new Class({ * Resumes the simulation, if paused. * * @method Phaser.Physics.Arcade.World#resume - * @fires Phaser.Physics.Arcade.World#resume + * @fires Phaser.Physics.Arcade.World#resumeEvent * @since 3.0.0 * * @return {Phaser.Physics.Arcade.World} This World object. @@ -1025,12 +1057,12 @@ var World = new Class({ }, /** - * Advances the simulation by one step. + * Advances the simulation by a time increment. * * @method Phaser.Physics.Arcade.World#step * @since 3.10.0 * - * @param {number} delta - The delta time amount, in ms, by which to advance the simulation. + * @param {number} delta - The delta time amount, in seconds, by which to advance the simulation. */ step: function (delta) { @@ -1169,7 +1201,7 @@ var World = new Class({ * @since 3.0.0 * * @param {Phaser.Physics.Arcade.Body} body - The Body to be updated. - * @param {number} delta - The delta value to be used in the motion calculations. + * @param {number} delta - The delta value to be used in the motion calculations, in seconds. */ updateMotion: function (body, delta) { @@ -1188,7 +1220,7 @@ var World = new Class({ * @since 3.10.0 * * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. - * @param {number} delta - The delta value to be used in the calculation. + * @param {number} delta - The delta value to be used in the calculation, in seconds. */ computeAngularVelocity: function (body, delta) { @@ -1234,7 +1266,7 @@ var World = new Class({ * @since 3.0.0 * * @param {Phaser.Physics.Arcade.Body} body - The Body to compute the velocity for. - * @param {number} delta - The delta value to be used in the calculation. + * @param {number} delta - The delta value to be used in the calculation, in seconds. */ computeVelocity: function (body, delta) { @@ -1340,8 +1372,8 @@ var World = new Class({ * Separates two Bodies. * * @method Phaser.Physics.Arcade.World#separate - * @fires Phaser.Physics.Arcade.World#collide - * @fires Phaser.Physics.Arcade.World#overlap + * @fires Phaser.Physics.Arcade.World#collideEvent + * @fires Phaser.Physics.Arcade.World#overlapEvent * @since 3.0.0 * * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. @@ -1436,9 +1468,15 @@ var World = new Class({ { this.emit('overlap', body1.gameObject, body2.gameObject, body1, body2); } - else if (body1.onCollide || body2.onCollide) + else { - this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + body1.postUpdate(); + body2.postUpdate(); + + if (body1.onCollide || body2.onCollide) + { + this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); + } } } @@ -1449,8 +1487,8 @@ var World = new Class({ * Separates two Bodies, when both are circular. * * @method Phaser.Physics.Arcade.World#separateCircle - * @fires Phaser.Physics.Arcade.World#collide - * @fires Phaser.Physics.Arcade.World#overlap + * @fires Phaser.Physics.Arcade.World#collideEvent + * @fires Phaser.Physics.Arcade.World#overlapEvent * @since 3.0.0 * * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to be separated. @@ -1638,6 +1676,10 @@ var World = new Class({ this.emit('collide', body1.gameObject, body2.gameObject, body1, body2); } + // sync changes back to the bodies + body1.postUpdate(); + body2.postUpdate(); + return true; }, @@ -1717,11 +1759,11 @@ var World = new Class({ * @method Phaser.Physics.Arcade.World#overlap * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} [overlapCallback] - [description] - * @param {ArcadePhysicsCallback} [processCallback] - [description] - * @param {*} [callbackContext] - [description] + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [overlapCallback] - An optional callback function that is called if the objects overlap. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param {*} [callbackContext] - The context in which to run the callbacks. * * @return {boolean} True if at least one Game Object overlaps another. */ @@ -1739,7 +1781,7 @@ var World = new Class({ * Game Objects, arrays of Game Objects, Physics Groups, arrays of Physics Groups or normal Groups. * * If you don't require separation then use {@link #overlap} instead. - * + * * If two Groups or arrays are passed, each member of one will be tested against each member of the other. * * If one Group **only** is passed (as `object1`), each member of the Group will be collided against the other members. @@ -1755,13 +1797,13 @@ var World = new Class({ * @method Phaser.Physics.Arcade.World#collide * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} [collideCallback] - [description] - * @param {ArcadePhysicsCallback} [processCallback] - [description] - * @param {*} [callbackContext] - [description] + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} [object2] - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {any} [callbackContext] - The context in which to run the callbacks. * - * @return {boolean} True if any overlapping Game Objects were separated. + * @return {boolean} `true` if any overlapping Game Objects were separated, otherwise `false`. */ collide: function (object1, object2, collideCallback, processCallback, callbackContext) { @@ -1773,19 +1815,20 @@ var World = new Class({ }, /** - * Helper for Phaser.Physics.Arcade.World#collide. + * Internal helper function. Please use Phaser.Physics.Arcade.World#collide instead. * * @method Phaser.Physics.Arcade.World#collideObjects + * @private * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {ArcadeColliderType} object1 - The first object to check for collision. + * @param {ArcadeColliderType} object2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {any} callbackContext - The scope in which to call the callbacks. + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. * - * @return {boolean} True if any overlapping objects were separated. + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. */ collideObjects: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) { @@ -1843,19 +1886,20 @@ var World = new Class({ }, /** - * Helper for Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap. + * Internal helper function. Please use Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap instead. * * @method Phaser.Physics.Arcade.World#collideHandler + * @private * @since 3.0.0 * - * @param {ArcadeColliderType} object1 - [description] - * @param {ArcadeColliderType} [object2] - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {ArcadeColliderType} object1 - The first object or array of objects to check. + * @param {ArcadeColliderType} object2 - The second object or array of objects to check, or `undefined`. + * @param {ArcadePhysicsCallback} collideCallback - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} processCallback - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {any} callbackContext - The context in which to run the callbacks. + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. * - * @return {boolean} [description] + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. */ collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext, overlapOnly) { @@ -1921,19 +1965,21 @@ var World = new Class({ }, /** - * Handler for Sprite vs. Sprite collisions. + * Internal handler for Sprite vs. Sprite collisions. + * Please use Phaser.Physics.Arcade.World#collide instead. * * @method Phaser.Physics.Arcade.World#collideSpriteVsSprite + * @private * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} sprite1 - [description] - * @param {Phaser.GameObjects.GameObject} sprite2 - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.GameObject} sprite1 - The first object to check for collision. + * @param {Phaser.GameObjects.GameObject} sprite2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {any} [callbackContext] - The context in which to run the callbacks. + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. * - * @return {boolean} [description] + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. */ collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext, overlapOnly) { @@ -1956,19 +2002,21 @@ var World = new Class({ }, /** - * Handler for Sprite vs. Group collisions. + * Internal handler for Sprite vs. Group collisions. + * Please use Phaser.Physics.Arcade.World#collide instead. * * @method Phaser.Physics.Arcade.World#collideSpriteVsGroup + * @private * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {Phaser.GameObjects.Group} group - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.GameObject} sprite - The first object to check for collision. + * @param {Phaser.GameObjects.Group} group - The second object to check for collision. + * @param {ArcadePhysicsCallback} collideCallback - The callback to invoke when the two objects collide. + * @param {ArcadePhysicsCallback} processCallback - The callback to invoke when the two objects collide. Must return a boolean. + * @param {any} callbackContext - The scope in which to call the callbacks. + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. * - * @return {boolean} [description] + * @return {boolean} `true` if the Sprite collided with the given Group, otherwise `false`. */ collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext, overlapOnly) { @@ -2049,19 +2097,21 @@ var World = new Class({ }, /** - * Helper for Group vs. Tilemap collisions. + * Internal handler for Group vs. Tilemap collisions. + * Please use Phaser.Physics.Arcade.World#collide instead. * * @method Phaser.Physics.Arcade.World#collideGroupVsTilemapLayer + * @private * @since 3.0.0 * - * @param {Phaser.GameObjects.Group} group - [description] - * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.Group} group - The first object to check for collision. + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {any} [callbackContext] - The context in which to run the callbacks. + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. * - * @return {boolean} [description] + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. */ collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) { @@ -2089,21 +2139,24 @@ var World = new Class({ }, /** - * Helper for Sprite vs. Tilemap collisions. + * Internal handler for Sprite vs. Tilemap collisions. + * Please use Phaser.Physics.Arcade.World#collide instead. * * @method Phaser.Physics.Arcade.World#collideSpriteVsTilemapLayer - * @fires Phaser.Physics.Arcade.World#collide - * @fires Phaser.Physics.Arcade.World#overlap + * @fires Phaser.GameObjects.GameObject#collideEvent + * @fires Phaser.GameObjects.GameObject#overlapEvent + * @fires Phaser.Physics.Arcade.World#collideEvent + * @fires Phaser.Physics.Arcade.World#overlapEvent * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} sprite - [description] - * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.GameObject} sprite - The first object to check for collision. + * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {any} [callbackContext] - The context in which to run the callbacks. + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. * - * @return {boolean} [description] + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. */ collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext, overlapOnly) { @@ -2185,24 +2238,29 @@ var World = new Class({ { sprite.emit('collide', body.gameObject, tile, body, null); } + + // sync changes back to the body + body.postUpdate(); } } }, /** - * Helper for Group vs. Group collisions. + * Internal helper for Group vs. Group collisions. + * Please use Phaser.Physics.Arcade.World#collide instead. * * @method Phaser.Physics.Arcade.World#collideGroupVsGroup + * @private * @since 3.0.0 * - * @param {Phaser.GameObjects.Group} group1 - [description] - * @param {Phaser.GameObjects.Group} group2 - [description] - * @param {ArcadePhysicsCallback} collideCallback - [description] - * @param {ArcadePhysicsCallback} processCallback - [description] - * @param {*} callbackContext - [description] - * @param {boolean} overlapOnly - [description] + * @param {Phaser.GameObjects.Group} group1 - The first object to check for collision. + * @param {Phaser.GameObjects.Group} group2 - The second object to check for collision. + * @param {ArcadePhysicsCallback} [collideCallback] - An optional callback function that is called if the objects collide. + * @param {ArcadePhysicsCallback} [processCallback] - An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param {any} [callbackContext] - The context in which to run the callbacks. + * @param {boolean} overlapOnly - Whether this is a collision or overlap check. * - * @return {boolean} [description] + * @return {boolean} True if any objects overlap (with `overlapOnly`); or true if any overlapping objects were separated. */ collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext, overlapOnly) { @@ -2318,3 +2376,23 @@ var World = new Class({ }); module.exports = World; + +/** + * A physics-enabled Game Object collided with a Tile. + * This event is emitted only if the Game Object's body has `onCollide` enabled. + * @event Phaser.GameObjects.GameObject#collideEvent + * @param {Phaser.GameObjects.GameObject} gameObject + * @param {Phaser.Tilemaps.Tile} tile + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body + * @see Phaser.Physics.Arcade.Body#onCollide + */ + +/** + * A physics-enabled Game Object overlapped with a Tile. + * This event is emitted only if the Game Object's body has `onOverlap` enabled. + * @event Phaser.GameObjects.GameObject#overlapEvent + * @param {Phaser.GameObjects.GameObject} gameObject + * @param {Phaser.Tilemaps.Tile} tile + * @param {Phaser.Physics.Arcade.Body|Phaser.Physics.Arcade.StaticBody} body + * @see Phaser.Physics.Arcade.Body#onOverlap + */ diff --git a/src/physics/arcade/components/Acceleration.js b/src/physics/arcade/components/Acceleration.js index f26ef6957..587bd4dc6 100644 --- a/src/physics/arcade/components/Acceleration.js +++ b/src/physics/arcade/components/Acceleration.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Provides methods used for setting the acceleration properties of an Arcade Physics Body. * * @name Phaser.Physics.Arcade.Components.Acceleration * @since 3.0.0 @@ -13,7 +13,7 @@ var Acceleration = { /** - * [description] + * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. * * @method Phaser.Physics.Arcade.Components.Acceleration#setAcceleration * @since 3.0.0 @@ -31,7 +31,7 @@ var Acceleration = { }, /** - * [description] + * Sets the body's horizontal acceleration. * * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationX * @since 3.0.0 @@ -48,7 +48,7 @@ var Acceleration = { }, /** - * [description] + * Sets the body's vertical acceleration. * * @method Phaser.Physics.Arcade.Components.Acceleration#setAccelerationY * @since 3.0.0 diff --git a/src/physics/arcade/components/Angular.js b/src/physics/arcade/components/Angular.js index 718026f1f..5b8ad10ad 100644 --- a/src/physics/arcade/components/Angular.js +++ b/src/physics/arcade/components/Angular.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Provides methods used for setting the angular acceleration properties of an Arcade Physics Body. * * @name Phaser.Physics.Arcade.Components.Angular * @since 3.0.0 @@ -13,12 +13,16 @@ var Angular = { /** - * [description] + * Sets the angular velocity of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. * * @method Phaser.Physics.Arcade.Components.Angular#setAngularVelocity * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The amount of angular velocity. * * @return {this} This Game Object. */ @@ -30,12 +34,16 @@ var Angular = { }, /** - * [description] + * Sets the angular acceleration of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. * * @method Phaser.Physics.Arcade.Components.Angular#setAngularAcceleration * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The amount of angular acceleration. * * @return {this} This Game Object. */ @@ -47,12 +55,12 @@ var Angular = { }, /** - * [description] + * Sets the angular drag of the body. Drag is applied to the current velocity, providing a form of deceleration. * * @method Phaser.Physics.Arcade.Components.Angular#setAngularDrag * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The amount of drag. * * @return {this} This Game Object. */ diff --git a/src/physics/arcade/components/Bounce.js b/src/physics/arcade/components/Bounce.js index fed3b89c8..b8c5ccd54 100644 --- a/src/physics/arcade/components/Bounce.js +++ b/src/physics/arcade/components/Bounce.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Provides methods used for setting the bounce properties of an Arcade Physics Body. * * @name Phaser.Physics.Arcade.Components.Bounce * @since 3.0.0 @@ -13,13 +13,16 @@ var Bounce = { /** - * [description] + * Sets the bounce values of this body. + * + * Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. + * A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all. * * @method Phaser.Physics.Arcade.Components.Bounce#setBounce * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. + * @param {number} [y=x] - The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. * * @return {this} This Game Object. */ @@ -31,12 +34,12 @@ var Bounce = { }, /** - * [description] + * Sets the horizontal bounce value for this body. * * @method Phaser.Physics.Arcade.Components.Bounce#setBounceX * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. * * @return {this} This Game Object. */ @@ -48,12 +51,12 @@ var Bounce = { }, /** - * [description] + * Sets the vertical bounce value for this body. * * @method Phaser.Physics.Arcade.Components.Bounce#setBounceY * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. * * @return {this} This Game Object. */ @@ -65,12 +68,12 @@ var Bounce = { }, /** - * [description] + * Sets if this body should collide with the world bounds or not. * * @method Phaser.Physics.Arcade.Components.Bounce#setCollideWorldBounds * @since 3.0.0 * - * @param {boolean} value - [description] + * @param {boolean} value - `true` if this body should collide with the world bounds, otherwise `false`. * * @return {this} This Game Object. */ diff --git a/src/physics/arcade/components/Debug.js b/src/physics/arcade/components/Debug.js index e24059ab0..f1acf73c4 100644 --- a/src/physics/arcade/components/Debug.js +++ b/src/physics/arcade/components/Debug.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Provides methods used for setting the debug properties of an Arcade Physics Body. * * @name Phaser.Physics.Arcade.Components.Debug * @since 3.0.0 @@ -13,14 +13,17 @@ var Debug = { /** - * [description] + * Sets the debug values of this body. + * + * Bodies will only draw their debug if debug has been enabled for Arcade Physics as a whole. + * Note that there is a performance cost in drawing debug displays. It should never be used in production. * * @method Phaser.Physics.Arcade.Components.Debug#setDebug * @since 3.0.0 * - * @param {boolean} showBody - [description] - * @param {boolean} showVelocity - [description] - * @param {number} bodyColor - [description] + * @param {boolean} showBody - Set to `true` to have this body render its outline to the debug display. + * @param {boolean} showVelocity - Set to `true` to have this body render a velocity marker to the debug display. + * @param {number} bodyColor - The color of the body outline when rendered to the debug display. * * @return {this} This Game Object. */ @@ -34,12 +37,12 @@ var Debug = { }, /** - * [description] + * Sets the color of the body outline when it renders to the debug display. * * @method Phaser.Physics.Arcade.Components.Debug#setDebugBodyColor * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The color of the body outline when rendered to the debug display. * * @return {this} This Game Object. */ @@ -51,7 +54,7 @@ var Debug = { }, /** - * [description] + * Set to `true` to have this body render its outline to the debug display. * * @name Phaser.Physics.Arcade.Components.Debug#debugShowBody * @type {boolean} @@ -72,7 +75,7 @@ var Debug = { }, /** - * [description] + * Set to `true` to have this body render a velocity marker to the debug display. * * @name Phaser.Physics.Arcade.Components.Debug#debugShowVelocity * @type {boolean} @@ -93,7 +96,7 @@ var Debug = { }, /** - * [description] + * The color of the body outline when it renders to the debug display. * * @name Phaser.Physics.Arcade.Components.Debug#debugBodyColor * @type {number} diff --git a/src/physics/arcade/components/Drag.js b/src/physics/arcade/components/Drag.js index 2e527cfe2..8b5bf6c07 100644 --- a/src/physics/arcade/components/Drag.js +++ b/src/physics/arcade/components/Drag.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Provides methods used for setting the drag properties of an Arcade Physics Body. * * @name Phaser.Physics.Arcade.Components.Drag * @since 3.0.0 @@ -13,13 +13,24 @@ var Drag = { /** - * [description] + * Sets the body's horizontal and vertical drag. If the vertical drag value is not provided, the vertical drag is set to the same value as the horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. * * @method Phaser.Physics.Arcade.Components.Drag#setDrag * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The amount of horizontal drag to apply. + * @param {number} [y=x] - The amount of vertical drag to apply. * * @return {this} This Game Object. */ @@ -31,12 +42,23 @@ var Drag = { }, /** - * [description] + * Sets the body's horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. * * @method Phaser.Physics.Arcade.Components.Drag#setDragX * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The amount of horizontal drag to apply. * * @return {this} This Game Object. */ @@ -48,12 +70,23 @@ var Drag = { }, /** - * [description] + * Sets the body's vertical drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. * * @method Phaser.Physics.Arcade.Components.Drag#setDragY * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The amount of vertical drag to apply. * * @return {this} This Game Object. */ @@ -65,7 +98,15 @@ var Drag = { }, /** - * [description] + * If this Body is using `drag` for deceleration this function controls how the drag is applied. + * If set to `true` drag will use a damping effect rather than a linear approach. If you are + * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in + * the game Asteroids) then you will get a far smoother and more visually correct deceleration + * by using damping, avoiding the axis-drift that is prone with linear deceleration. + * + * If you enable this property then you should use far smaller `drag` values than with linear, as + * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow + * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. * * @method Phaser.Physics.Arcade.Components.Drag#setDamping * @since 3.10.0 diff --git a/src/physics/arcade/components/Enable.js b/src/physics/arcade/components/Enable.js index 56f9a9cfb..978774f16 100644 --- a/src/physics/arcade/components/Enable.js +++ b/src/physics/arcade/components/Enable.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Provides methods used for setting the enable properties of an Arcade Physics Body. * * @name Phaser.Physics.Arcade.Components.Enable * @since 3.0.0 @@ -13,18 +13,25 @@ var Enable = { /** - * [description] + * Enables this Game Object's Body. * * @method Phaser.Physics.Arcade.Components.Enable#enableBody * @since 3.0.0 * - * @param {boolean} reset - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {boolean} enableGameObject - [description] - * @param {boolean} showGameObject - [description] + * @param {boolean} reset - Also reset the Body and place it at (x, y). + * @param {number} x - The horizontal position to place the Game Object and Body. + * @param {number} y - The horizontal position to place the Game Object and Body. + * @param {boolean} enableGameObject - Also activate this Game Object. + * @param {boolean} showGameObject - Also show this Game Object. * * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.Body#enable + * @see Phaser.Physics.Arcade.StaticBody#enable + * @see Phaser.Physics.Arcade.Body#reset + * @see Phaser.Physics.Arcade.StaticBody#reset + * @see Phaser.GameObjects.GameObject#active + * @see Phaser.GameObjects.GameObject#visible */ enableBody: function (reset, x, y, enableGameObject, showGameObject) { @@ -49,15 +56,20 @@ var Enable = { }, /** - * [description] + * Stops and disables this Game Object's Body. * * @method Phaser.Physics.Arcade.Components.Enable#disableBody * @since 3.0.0 * - * @param {boolean} [disableGameObject=false] - [description] - * @param {boolean} [hideGameObject=false] - [description] + * @param {boolean} [disableGameObject=false] - Also deactivate this Game Object. + * @param {boolean} [hideGameObject=false] - Also hide this Game Object. * * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.Body#enable + * @see Phaser.Physics.Arcade.StaticBody#enable + * @see Phaser.GameObjects.GameObject#active + * @see Phaser.GameObjects.GameObject#visible */ disableBody: function (disableGameObject, hideGameObject) { @@ -82,7 +94,7 @@ var Enable = { }, /** - * Syncs the Bodies position and size with its parent Game Object. + * Syncs the Body's position and size with its parent Game Object. * You don't need to call this for Dynamic Bodies, as it happens automatically. * But for Static bodies it's a useful way of modifying the position of a Static Body * in the Physics World, based on its Game Object. @@ -91,6 +103,8 @@ var Enable = { * @since 3.1.0 * * @return {this} This Game Object. + * + * @see Phaser.Physics.Arcade.StaticBody#updateFromGameObject */ refreshBody: function () { diff --git a/src/physics/arcade/components/Friction.js b/src/physics/arcade/components/Friction.js index 5de3b606c..447371dc8 100644 --- a/src/physics/arcade/components/Friction.js +++ b/src/physics/arcade/components/Friction.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. The higher than friction, the faster the body will slow down once force stops being applied to it. * * @name Phaser.Physics.Arcade.Components.Friction * @since 3.0.0 @@ -13,13 +13,14 @@ var Friction = { /** - * [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. * * @method Phaser.Physics.Arcade.Components.Friction#setFriction * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The amount of horizontal friction to apply. + * @param {number} [y=x] - The amount of vertical friction to apply. * * @return {this} This Game Object. */ @@ -31,12 +32,13 @@ var Friction = { }, /** - * [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. * * @method Phaser.Physics.Arcade.Components.Friction#setFrictionX * @since 3.0.0 * - * @param {number} x - [description] + * @param {number} x - The amount of friction to apply. * * @return {this} This Game Object. */ @@ -48,12 +50,13 @@ var Friction = { }, /** - * [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. * * @method Phaser.Physics.Arcade.Components.Friction#setFrictionY * @since 3.0.0 * - * @param {number} y - [description] + * @param {number} x - The amount of friction to apply. * * @return {this} This Game Object. */ diff --git a/src/physics/arcade/components/Gravity.js b/src/physics/arcade/components/Gravity.js index 576466fb2..b0cef108b 100644 --- a/src/physics/arcade/components/Gravity.js +++ b/src/physics/arcade/components/Gravity.js @@ -5,7 +5,8 @@ */ /** - * [description] + * Provides methods for setting the gravity properties of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. * * @name Phaser.Physics.Arcade.Components.Gravity * @since 3.0.0 @@ -13,13 +14,15 @@ var Gravity = { /** - * [description] + * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. + * + * If only one value is provided, this value will be used for both the X and Y axis. * * @method Phaser.Physics.Arcade.Components.Gravity#setGravity * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The gravitational force to be applied to the X-axis. + * @param {number} [y=x] - The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. * * @return {this} This Game Object. */ @@ -31,12 +34,12 @@ var Gravity = { }, /** - * [description] + * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. * * @method Phaser.Physics.Arcade.Components.Gravity#setGravityX * @since 3.0.0 * - * @param {number} x - [description] + * @param {number} x - The gravitational force to be applied to the X-axis. * * @return {this} This Game Object. */ @@ -48,12 +51,12 @@ var Gravity = { }, /** - * [description] + * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. * * @method Phaser.Physics.Arcade.Components.Gravity#setGravityY * @since 3.0.0 * - * @param {number} y - [description] + * @param {number} y - The gravitational force to be applied to the Y-axis. * * @return {this} This Game Object. */ diff --git a/src/physics/arcade/components/Immovable.js b/src/physics/arcade/components/Immovable.js index 176641741..899700f9a 100644 --- a/src/physics/arcade/components/Immovable.js +++ b/src/physics/arcade/components/Immovable.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Provides methods used for setting the immovable properties of an Arcade Physics Body. * * @name Phaser.Physics.Arcade.Components.Immovable * @since 3.0.0 @@ -13,12 +13,12 @@ var Immovable = { /** - * [description] + * Sets Whether this Body can be moved by collisions with another Body. * * @method Phaser.Physics.Arcade.Components.Immovable#setImmovable * @since 3.0.0 * - * @param {boolean} [value=true] - [description] + * @param {boolean} [value=true] - Sets if this body can be moved by collisions with another Body. * * @return {this} This Game Object. */ diff --git a/src/physics/arcade/components/Mass.js b/src/physics/arcade/components/Mass.js index 0bce361d7..112227910 100644 --- a/src/physics/arcade/components/Mass.js +++ b/src/physics/arcade/components/Mass.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Provides methods used for setting the mass properties of an Arcade Physics Body. * * @name Phaser.Physics.Arcade.Components.Mass * @since 3.0.0 @@ -13,12 +13,12 @@ var Mass = { /** - * [description] + * Sets the mass of the physics body * * @method Phaser.Physics.Arcade.Components.Mass#setMass * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - New value for the mass of the body. * * @return {this} This Game Object. */ diff --git a/src/physics/arcade/components/Size.js b/src/physics/arcade/components/Size.js index a957abc85..653b4b8b9 100644 --- a/src/physics/arcade/components/Size.js +++ b/src/physics/arcade/components/Size.js @@ -5,7 +5,8 @@ */ /** - * [description] + * Provides methods for setting the size of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. * * @name Phaser.Physics.Arcade.Components.Size * @since 3.0.0 @@ -13,13 +14,14 @@ var Size = { /** - * [description] + * Sets the body offset. This allows you to adjust the difference between the center of the body + * and the x and y coordinates of the parent Game Object. * * @method Phaser.Physics.Arcade.Components.Size#setOffset * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The amount to offset the body from the parent Game Object along the x-axis. + * @param {number} [y=x] - The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. * * @return {this} This Game Object. */ @@ -31,14 +33,15 @@ var Size = { }, /** - * [description] + * Sets the size of this physics body. Setting the size does not adjust the dimensions + * of the parent Game Object. * * @method Phaser.Physics.Arcade.Components.Size#setSize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {boolean} [center=true] - [description] + * @param {number} width - The new width of the physics body, in pixels. + * @param {number} height - The new height of the physics body, in pixels. + * @param {boolean} [center=true] - Should the body be re-positioned so its center aligns with the parent Game Object? * * @return {this} This Game Object. */ @@ -50,14 +53,14 @@ var Size = { }, /** - * [description] + * Sets this physics body to use a circle for collision instead of a rectangle. * * @method Phaser.Physics.Arcade.Components.Size#setCircle * @since 3.0.0 * - * @param {number} radius - [description] - * @param {number} [offsetX] - [description] - * @param {number} [offsetY] - [description] + * @param {number} radius - The radius of the physics body, in pixels. + * @param {number} [offsetX] - The amount to offset the body from the parent Game Object along the x-axis. + * @param {number} [offsetY] - The amount to offset the body from the parent Game Object along the y-axis. * * @return {this} This Game Object. */ diff --git a/src/physics/arcade/components/Velocity.js b/src/physics/arcade/components/Velocity.js index 30150f9a9..9266e85c9 100644 --- a/src/physics/arcade/components/Velocity.js +++ b/src/physics/arcade/components/Velocity.js @@ -5,7 +5,9 @@ */ /** - * [description] + * Provides methods for modifying the velocity of an Arcade Physics body. + * + * Should be applied as a mixin and not used directly. * * @name Phaser.Physics.Arcade.Components.Velocity * @since 3.0.0 @@ -13,65 +15,69 @@ var Velocity = { /** - * [description] + * Sets the velocity of the Body. * * @method Phaser.Physics.Arcade.Components.Velocity#setVelocity * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The horizontal velocity of the body. Positive values move the body to the right, while negative values move it to the left. + * @param {number} [y=x] - The vertical velocity of the body. Positive values move the body down, while negative values move it up. * * @return {this} This Game Object. */ setVelocity: function (x, y) { - this.body.velocity.set(x, y); + this.body.setVelocity(x, y); return this; }, /** - * [description] + * Sets the horizontal component of the body's velocity. + * + * Positive values move the body to the right, while negative values move it to the left. * * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityX * @since 3.0.0 * - * @param {number} x - [description] + * @param {number} x - The new horizontal velocity. * * @return {this} This Game Object. */ setVelocityX: function (x) { - this.body.velocity.x = x; + this.body.setVelocityX(x); return this; }, /** - * [description] + * Sets the vertical component of the body's velocity. + * + * Positive values move the body down, while negative values move it up. * * @method Phaser.Physics.Arcade.Components.Velocity#setVelocityY * @since 3.0.0 * - * @param {number} y - [description] + * @param {number} y - The new vertical velocity of the body. * * @return {this} This Game Object. */ setVelocityY: function (y) { - this.body.velocity.y = y; + this.body.setVelocityY(y); return this; }, /** - * [description] + * Sets the maximum velocity of the body. * * @method Phaser.Physics.Arcade.Components.Velocity#setMaxVelocity * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The new maximum horizontal velocity. + * @param {number} [y=x] - The new maximum vertical velocity. * * @return {this} This Game Object. */ diff --git a/src/physics/arcade/const.js b/src/physics/arcade/const.js index 2639caf51..75943cc45 100644 --- a/src/physics/arcade/const.js +++ b/src/physics/arcade/const.js @@ -6,99 +6,115 @@ /** * Arcade Physics consts. - * + * * @ignore */ var CONST = { /** - * [description] - * + * Dynamic Body. + * * @name Phaser.Physics.Arcade.DYNAMIC_BODY - * @readOnly + * @readonly * @type {number} * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#physicsType + * @see Phaser.Physics.Arcade.Group#physicsType */ DYNAMIC_BODY: 0, /** - * [description] - * + * Static Body. + * * @name Phaser.Physics.Arcade.STATIC_BODY - * @readOnly + * @readonly * @type {number} * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#physicsType + * @see Phaser.Physics.Arcade.StaticBody#physicsType */ STATIC_BODY: 1, /** - * [description] - * + * Arcade Physics Group containing Dynamic Bodies. + * * @name Phaser.Physics.Arcade.GROUP - * @readOnly + * @readonly * @type {number} * @since 3.0.0 */ GROUP: 2, /** - * [description] - * + * A Tilemap Layer. + * * @name Phaser.Physics.Arcade.TILEMAPLAYER - * @readOnly + * @readonly * @type {number} * @since 3.0.0 */ TILEMAPLAYER: 3, /** - * [description] - * + * Facing no direction (initial value). + * * @name Phaser.Physics.Arcade.FACING_NONE - * @readOnly + * @readonly * @type {number} * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing */ FACING_NONE: 10, /** - * [description] - * + * Facing up. + * * @name Phaser.Physics.Arcade.FACING_UP - * @readOnly + * @readonly * @type {number} * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing */ FACING_UP: 11, /** - * [description] - * + * Facing down. + * * @name Phaser.Physics.Arcade.FACING_DOWN - * @readOnly + * @readonly * @type {number} * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing */ FACING_DOWN: 12, /** - * [description] - * + * Facing left. + * * @name Phaser.Physics.Arcade.FACING_LEFT - * @readOnly + * @readonly * @type {number} * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing */ FACING_LEFT: 13, /** - * [description] - * + * Facing right. + * * @name Phaser.Physics.Arcade.FACING_RIGHT - * @readOnly + * @readonly * @type {number} * @since 3.0.0 + * + * @see Phaser.Physics.Arcade.Body#facing */ FACING_RIGHT: 14 diff --git a/src/physics/arcade/index.js b/src/physics/arcade/index.js index b81f0b3a1..3bebfd22b 100644 --- a/src/physics/arcade/index.js +++ b/src/physics/arcade/index.js @@ -10,8 +10,8 @@ var Extend = require('../../utils/object/Extend'); /** * @callback ArcadePhysicsCallback * - * @param {Phaser.GameObjects.GameObject} object1 - [description] - * @param {Phaser.GameObjects.GameObject} object2 - [description] + * @param {Phaser.GameObjects.GameObject} object1 - The first Body to separate. + * @param {Phaser.GameObjects.GameObject} object2 - The second Body to separate. */ /** diff --git a/src/physics/arcade/tilemap/ProcessTileCallbacks.js b/src/physics/arcade/tilemap/ProcessTileCallbacks.js index 4ec4e8174..14cf85e52 100644 --- a/src/physics/arcade/tilemap/ProcessTileCallbacks.js +++ b/src/physics/arcade/tilemap/ProcessTileCallbacks.js @@ -5,19 +5,19 @@ */ /** - * [description] + * A function to process the collision callbacks between a single tile and an Arcade Physics enabled Game Object. * * @function Phaser.Physics.Arcade.Tilemap.ProcessTileCallbacks * @since 3.0.0 * - * @param {Phaser.Tilemaps.Tilemap} tile - [description] - * @param {Phaser.GameObjects.Sprite} sprite - [description] + * @param {Phaser.Tilemaps.Tile} tile - The Tile to process. + * @param {Phaser.GameObjects.Sprite} sprite - The Game Object to process with the Tile. * - * @return {boolean} [description] + * @return {boolean} The result of the callback, `true` for further processing, or `false` to skip this pair. */ var ProcessTileCallbacks = function (tile, sprite) { - // Tile callbacks take priority over layer level callbacks + // Tile callbacks take priority over layer level callbacks if (tile.collisionCallback) { return !tile.collisionCallback.call(tile.collisionCallbackContext, sprite, tile); diff --git a/src/physics/arcade/tilemap/SeparateTile.js b/src/physics/arcade/tilemap/SeparateTile.js index ef94f5451..9e3fe0a9f 100644 --- a/src/physics/arcade/tilemap/SeparateTile.js +++ b/src/physics/arcade/tilemap/SeparateTile.js @@ -14,14 +14,14 @@ var TileIntersectsBody = require('./TileIntersectsBody'); * @function Phaser.Physics.Arcade.Tilemap.SeparateTile * @since 3.0.0 * - * @param {number} i - [description] + * @param {number} i - The index of the tile within the map data. * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. * @param {Phaser.Tilemaps.Tile} tile - The tile to collide against. - * @param {Phaser.Geom.Rectangle} tileWorldRect - [description] + * @param {Phaser.Geom.Rectangle} tileWorldRect - A rectangle-like object defining the dimensions of the tile. * @param {(Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} tilemapLayer - The tilemapLayer to collide against. - * @param {number} tileBias - [description] + * @param {number} tileBias - The tile bias value. Populated by the `World.TILE_BIAS` constant. * - * @return {boolean} Returns true if the body was separated, otherwise false. + * @return {boolean} `true` if the body was separated, otherwise `false`. */ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBias) { diff --git a/src/physics/arcade/tilemap/TileCheckX.js b/src/physics/arcade/tilemap/TileCheckX.js index b039d64c1..e91924ec7 100644 --- a/src/physics/arcade/tilemap/TileCheckX.js +++ b/src/physics/arcade/tilemap/TileCheckX.js @@ -8,15 +8,16 @@ var ProcessTileSeparationX = require('./ProcessTileSeparationX'); /** * Check the body against the given tile on the X axis. + * Used internally by the SeparateTile function. * * @function Phaser.Physics.Arcade.Tilemap.TileCheckX * @since 3.0.0 * * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileLeft - [description] - * @param {number} tileRight - [description] - * @param {number} tileBias - [description] + * @param {number} tileLeft - The left position of the tile within the tile world. + * @param {number} tileRight - The right position of the tile within the tile world. + * @param {number} tileBias - The tile bias value. Populated by the `World.TILE_BIAS` constant. * * @return {number} The amount of separation that occurred. */ diff --git a/src/physics/arcade/tilemap/TileCheckY.js b/src/physics/arcade/tilemap/TileCheckY.js index e80cc2f63..d02f045ec 100644 --- a/src/physics/arcade/tilemap/TileCheckY.js +++ b/src/physics/arcade/tilemap/TileCheckY.js @@ -8,15 +8,16 @@ var ProcessTileSeparationY = require('./ProcessTileSeparationY'); /** * Check the body against the given tile on the Y axis. + * Used internally by the SeparateTile function. * * @function Phaser.Physics.Arcade.Tilemap.TileCheckY * @since 3.0.0 * * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate. * @param {Phaser.Tilemaps.Tile} tile - The tile to check. - * @param {number} tileTop - [description] - * @param {number} tileBottom - [description] - * @param {number} tileBias - [description] + * @param {number} tileTop - The top position of the tile within the tile world. + * @param {number} tileBottom - The bottom position of the tile within the tile world. + * @param {number} tileBias - The tile bias value. Populated by the `World.TILE_BIAS` constant. * * @return {number} The amount of separation that occurred. */ diff --git a/src/physics/arcade/tilemap/TileIntersectsBody.js b/src/physics/arcade/tilemap/TileIntersectsBody.js index d2e23b4ce..f478994f8 100644 --- a/src/physics/arcade/tilemap/TileIntersectsBody.js +++ b/src/physics/arcade/tilemap/TileIntersectsBody.js @@ -5,20 +5,19 @@ */ /** - * [description] + * Checks for intersection between the given tile rectangle-like object and an Arcade Physics body. * * @function Phaser.Physics.Arcade.Tilemap.TileIntersectsBody * @since 3.0.0 * - * @param {{ left: number, right: number, top: number, bottom: number }} tileWorldRect - [description] - * @param {Phaser.Physics.Arcade.Body} body - [description] + * @param {{ left: number, right: number, top: number, bottom: number }} tileWorldRect - A rectangle object that defines the tile placement in the world. + * @param {Phaser.Physics.Arcade.Body} body - The body to check for intersection against. * - * @return {boolean} [description] + * @return {boolean} Returns `true` of the tile intersects with the body, otherwise `false`. */ var TileIntersectsBody = function (tileWorldRect, body) { - // Currently, all bodies are treated as rectangles when colliding with a Tile. Eventually, this - // should support circle bodies when those are less buggy in v3. + // Currently, all bodies are treated as rectangles when colliding with a Tile. return !( body.right <= tileWorldRect.left || diff --git a/src/physics/impact/Body.js b/src/physics/impact/Body.js index 114063edb..ee7affcd7 100644 --- a/src/physics/impact/Body.js +++ b/src/physics/impact/Body.js @@ -22,11 +22,11 @@ var UpdateMotion = require('./UpdateMotion'); * * @property {string} name - [description] * @property {object} size - [description] - * @property {object} pos - [description] - * @property {object} vel - [description] - * @property {object} accel - [description] - * @property {object} friction - [description] - * @property {object} maxVel - [description] + * @property {object} pos - The entity's position in the game world. + * @property {object} vel - Current velocity in pixels per second. + * @property {object} accel - Current acceleration to be added to the entity's velocity per second. E.g. an entity with a `vel.x` of 0 and `accel.x` of 10 will have a `vel.x` of 100 ten seconds later. + * @property {object} friction - Deceleration to be subtracted from the entity's velocity per second. Only applies if `accel` is 0. + * @property {object} maxVel - The maximum velocity a body can move. * @property {number} gravityFactor - [description] * @property {number} bounciness - [description] * @property {number} minBounceVelocity - [description] @@ -41,7 +41,7 @@ var UpdateMotion = require('./UpdateMotion'); * This re-creates the properties you'd get on an Entity and the math needed to update them. * * @class Body - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -368,7 +368,7 @@ var Body = new Class({ * @method Phaser.Physics.Impact.Body#update * @since 3.0.0 * - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (delta) { @@ -461,7 +461,7 @@ var Body = new Class({ }, /** - * [description] + * Determines whether the body collides with the `other` one or not. * * @method Phaser.Physics.Impact.Body#touches * @since 3.0.0 @@ -481,15 +481,15 @@ var Body = new Class({ }, /** - * [description] + * Reset the size and position of the physics body. * * @method Phaser.Physics.Impact.Body#resetSize * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} x - The x coordinate to position the body. + * @param {number} y - The y coordinate to position the body. + * @param {number} width - The width of the body. + * @param {number} height - The height of the body. * * @return {Phaser.Physics.Impact.Body} This Body object. */ @@ -504,12 +504,12 @@ var Body = new Class({ }, /** - * [description] + * Export this body object to JSON. * * @method Phaser.Physics.Impact.Body#toJSON * @since 3.0.0 * - * @return {JSONImpactBody} [description] + * @return {JSONImpactBody} JSON representation of this body object. */ toJSON: function () { diff --git a/src/physics/impact/COLLIDES.js b/src/physics/impact/COLLIDES.js index 847875e95..8e7d06c2d 100644 --- a/src/physics/impact/COLLIDES.js +++ b/src/physics/impact/COLLIDES.js @@ -15,8 +15,8 @@ * * @name Phaser.Physics.Impact.COLLIDES * @enum {integer} - * @memberOf Phaser.Physics.Impact - * @readOnly + * @memberof Phaser.Physics.Impact + * @readonly * @since 3.0.0 */ module.exports = { diff --git a/src/physics/impact/CollisionMap.js b/src/physics/impact/CollisionMap.js index 0b79701fc..ec042d80a 100644 --- a/src/physics/impact/CollisionMap.js +++ b/src/physics/impact/CollisionMap.js @@ -12,7 +12,7 @@ var DefaultDefs = require('./DefaultDefs'); * [description] * * @class CollisionMap - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * diff --git a/src/physics/impact/Factory.js b/src/physics/impact/Factory.js index a2418ce03..f74dfc4a3 100644 --- a/src/physics/impact/Factory.js +++ b/src/physics/impact/Factory.js @@ -15,11 +15,11 @@ var ImpactSprite = require('./ImpactSprite'); * Objects that are created by this Factory are automatically added to the physics world. * * @class Factory - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * - * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Impact.World} world - A reference to the Impact Physics world. */ var Factory = new Class({ @@ -28,7 +28,7 @@ var Factory = new Class({ function Factory (world) { /** - * [description] + * A reference to the Impact Physics world. * * @name Phaser.Physics.Impact.Factory#world * @type {Phaser.Physics.Impact.World} @@ -47,15 +47,15 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new ImpactBody object and adds it to the physics simulation. * * @method Phaser.Physics.Impact.Factory#body * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} x - The horizontal position of the body in the physics world. + * @param {number} y - The vertical position of the body in the physics world. + * @param {number} width - The width of the body. + * @param {number} height - The height of the body. * * @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created. */ @@ -70,7 +70,7 @@ var Factory = new Class({ * @method Phaser.Physics.Impact.Factory#existing * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to receive the physics body. * * @return {Phaser.GameObjects.GameObject} The Game Object. */ @@ -90,7 +90,7 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new ImpactImage object and adds it to the physics world. * * @method Phaser.Physics.Impact.Factory#image * @since 3.0.0 @@ -112,7 +112,7 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new ImpactSprite object and adds it to the physics world. * * @method Phaser.Physics.Impact.Factory#sprite * @since 3.0.0 diff --git a/src/physics/impact/GetVelocity.js b/src/physics/impact/GetVelocity.js index 9e1b230ec..9fa209bd5 100644 --- a/src/physics/impact/GetVelocity.js +++ b/src/physics/impact/GetVelocity.js @@ -12,7 +12,7 @@ var Clamp = require('../../math/Clamp'); * @function Phaser.Physics.Impact.GetVelocity * @since 3.0.0 * - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. * @param {number} vel - [description] * @param {number} accel - [description] * @param {number} friction - [description] diff --git a/src/physics/impact/ImpactBody.js b/src/physics/impact/ImpactBody.js index b2b3d3ea5..faca25f6c 100644 --- a/src/physics/impact/ImpactBody.js +++ b/src/physics/impact/ImpactBody.js @@ -12,7 +12,7 @@ var Components = require('./components'); * [description] * * @class ImpactBody - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -30,9 +30,9 @@ var Components = require('./components'); * @extends Phaser.Physics.Impact.Components.Velocity * * @param {Phaser.Physics.Impact.World} world - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] + * @param {number} x - x - The horizontal position of this physics body in the world. + * @param {number} y - y - The vertical position of this physics body in the world. + * @param {number} width - The width of the physics body in the world. * @param {number} height - [description] */ var ImpactBody = new Class({ diff --git a/src/physics/impact/ImpactImage.js b/src/physics/impact/ImpactImage.js index 09fe6b09a..dbd3c8b04 100644 --- a/src/physics/impact/ImpactImage.js +++ b/src/physics/impact/ImpactImage.js @@ -19,7 +19,7 @@ var Image = require('../../gameobjects/image/Image'); * * @class ImpactImage * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * @@ -50,7 +50,7 @@ var Image = require('../../gameobjects/image/Image'); * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible * - * @param {Phaser.Physics.Impact.World} world - [description] + * @param {Phaser.Physics.Impact.World} world - The physics world of the Impact physics system. * @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 {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. @@ -82,7 +82,7 @@ var ImpactImage = new Class({ Image.call(this, world.scene, x, y, texture, frame); /** - * [description] + * The Physics Body linked to an ImpactImage. * * @name Phaser.Physics.Impact.ImpactImage#body * @type {Phaser.Physics.Impact.Body} @@ -94,7 +94,7 @@ var ImpactImage = new Class({ this.body.gameObject = this; /** - * [description] + * The size of the physics Body. * * @name Phaser.Physics.Impact.ImpactImage#size * @type {{x: number, y: number}} @@ -103,7 +103,7 @@ var ImpactImage = new Class({ this.size = this.body.size; /** - * [description] + * The X and Y offset of the Body from the left and top of the Image. * * @name Phaser.Physics.Impact.ImpactImage#offset * @type {{x: number, y: number}} @@ -112,7 +112,7 @@ var ImpactImage = new Class({ this.offset = this.body.offset; /** - * [description] + * The velocity, or rate of change the Body's position. Measured in pixels per second. * * @name Phaser.Physics.Impact.ImpactImage#vel * @type {{x: number, y: number}} @@ -121,7 +121,7 @@ var ImpactImage = new Class({ this.vel = this.body.vel; /** - * [description] + * The acceleration is the rate of change of the velocity. Measured in pixels per second squared. * * @name Phaser.Physics.Impact.ImpactImage#accel * @type {{x: number, y: number}} @@ -130,7 +130,7 @@ var ImpactImage = new Class({ this.accel = this.body.accel; /** - * [description] + * Friction between colliding bodies. * * @name Phaser.Physics.Impact.ImpactImage#friction * @type {{x: number, y: number}} @@ -139,7 +139,7 @@ var ImpactImage = new Class({ this.friction = this.body.friction; /** - * [description] + * The maximum velocity of the body. * * @name Phaser.Physics.Impact.ImpactImage#maxVel * @type {{x: number, y: number}} diff --git a/src/physics/impact/ImpactPhysics.js b/src/physics/impact/ImpactPhysics.js index e689ee915..24d980605 100644 --- a/src/physics/impact/ImpactPhysics.js +++ b/src/physics/impact/ImpactPhysics.js @@ -16,7 +16,7 @@ var World = require('./World'); * [description] * * @class ImpactPhysics - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * diff --git a/src/physics/impact/ImpactSprite.js b/src/physics/impact/ImpactSprite.js index 4b3ae464d..c7fb7d536 100644 --- a/src/physics/impact/ImpactSprite.js +++ b/src/physics/impact/ImpactSprite.js @@ -22,7 +22,7 @@ var Sprite = require('../../gameobjects/sprite/Sprite'); * * @class ImpactSprite * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * diff --git a/src/physics/impact/Solver.js b/src/physics/impact/Solver.js index 0b42f6092..a6e03523a 100644 --- a/src/physics/impact/Solver.js +++ b/src/physics/impact/Solver.js @@ -14,9 +14,9 @@ var SeperateY = require('./SeperateY'); * @function Phaser.Physics.Impact.Solver * @since 3.0.0 * - * @param {Phaser.Physics.Impact.World} world - [description] - * @param {Phaser.Physics.Impact.Body} bodyA - [description] - * @param {Phaser.Physics.Impact.Body} bodyB - [description] + * @param {Phaser.Physics.Impact.World} world - The Impact simulation to run the solver in. + * @param {Phaser.Physics.Impact.Body} bodyA - The first body in the collision. + * @param {Phaser.Physics.Impact.Body} bodyB - The second body in the collision. */ var Solver = function (world, bodyA, bodyB) { diff --git a/src/physics/impact/TYPE.js b/src/physics/impact/TYPE.js index 28103022a..856f280b8 100644 --- a/src/physics/impact/TYPE.js +++ b/src/physics/impact/TYPE.js @@ -15,8 +15,8 @@ * * @name Phaser.Physics.Impact.TYPE * @enum {integer} - * @memberOf Phaser.Physics.Impact - * @readOnly + * @memberof Phaser.Physics.Impact + * @readonly * @since 3.0.0 */ module.exports = { diff --git a/src/physics/impact/World.js b/src/physics/impact/World.js index 04af7557a..ac44a53cd 100644 --- a/src/physics/impact/World.js +++ b/src/physics/impact/World.js @@ -19,31 +19,31 @@ var TYPE = require('./TYPE'); /** * @typedef {object} Phaser.Physics.Impact.WorldConfig * - * @property {number} [gravity=0] - [description] - * @property {number} [cellSize=64] - [description] - * @property {number} [timeScale=1] - [description] + * @property {number} [gravity=0] - Sets {@link Phaser.Physics.Impact.World#gravity} + * @property {number} [cellSize=64] - The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world. + * @property {number} [timeScale=1] - A `Number` that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed. * @property {number} [maxStep=0.05] - [description] - * @property {boolean} [debug=false] - [description] - * @property {number} [maxVelocity=100] - [description] - * @property {boolean} [debugShowBody=true] - [description] - * @property {boolean} [debugShowVelocity=true] - [description] - * @property {number} [debugBodyColor=0xff00ff] - [description] - * @property {number} [debugVelocityColor=0x00ff00] - [description] - * @property {number} [maxVelocityX=maxVelocity] - [description] - * @property {number} [maxVelocityY=maxVelocity] - [description] - * @property {number} [minBounceVelocity=40] - [description] - * @property {number} [gravityFactor=1] - [description] - * @property {number} [bounciness=0] - [description] - * @property {(object|boolean)} [setBounds] - [description] - * @property {number} [setBounds.x=0] - [description] - * @property {number} [setBounds.y=0] - [description] - * @property {number} [setBounds.width] - [description] - * @property {number} [setBounds.height] - [description] - * @property {number} [setBounds.thickness=64] - [description] - * @property {boolean} [setBounds.left=true] - [description] - * @property {boolean} [setBounds.right=true] - [description] - * @property {boolean} [setBounds.top=true] - [description] - * @property {boolean} [setBounds.bottom=true] - [description] + * @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Impact.World#debug}. + * @property {number} [maxVelocity=100] - The maximum velocity a body can move. + * @property {boolean} [debugShowBody=true] - Whether the Body's boundary is drawn to the debug display. + * @property {boolean} [debugShowVelocity=true] - Whether the Body's velocity is drawn to the debug display. + * @property {number} [debugBodyColor=0xff00ff] - The color of this Body on the debug display. + * @property {number} [debugVelocityColor=0x00ff00] - The color of the Body's velocity on the debug display. + * @property {number} [maxVelocityX=maxVelocity] - Maximum X velocity objects can move. + * @property {number} [maxVelocityY=maxVelocity] - Maximum Y velocity objects can move. + * @property {number} [minBounceVelocity=40] - The minimum velocity an object can be moving at to be considered for bounce. + * @property {number} [gravityFactor=1] - Gravity multiplier. Set to 0 for no gravity. + * @property {number} [bounciness=0] - The default bounce, or restitution, of bodies in the world. + * @property {(object|boolean)} [setBounds] - Should the world have bounds enabled by default? + * @property {number} [setBounds.x=0] - The x coordinate of the world bounds. + * @property {number} [setBounds.y=0] - The y coordinate of the world bounds. + * @property {number} [setBounds.width] - The width of the world bounds. + * @property {number} [setBounds.height] - The height of the world bounds. + * @property {number} [setBounds.thickness=64] - The thickness of the walls of the world bounds. + * @property {boolean} [setBounds.left=true] - Should the left-side world bounds wall be created? + * @property {boolean} [setBounds.right=true] - Should the right-side world bounds wall be created? + * @property {boolean} [setBounds.top=true] - Should the top world bounds wall be created? + * @property {boolean} [setBounds.bottom=true] - Should the bottom world bounds wall be created? */ /** @@ -51,24 +51,24 @@ var TYPE = require('./TYPE'); * * @typedef {object} Phaser.Physics.Impact.WorldDefaults * - * @property {boolean} debugShowBody - [description] - * @property {boolean} debugShowVelocity - [description] - * @property {number} bodyDebugColor - [description] - * @property {number} velocityDebugColor - [description] - * @property {number} maxVelocityX - [description] - * @property {number} maxVelocityY - [description] - * @property {number} minBounceVelocity - [description] - * @property {number} gravityFactor - [description] - * @property {number} bounciness - [description] + * @property {boolean} debugShowBody - Whether the Body's boundary is drawn to the debug display. + * @property {boolean} debugShowVelocity - Whether the Body's velocity is drawn to the debug display. + * @property {number} bodyDebugColor - The color of this Body on the debug display. + * @property {number} velocityDebugColor - The color of the Body's velocity on the debug display. + * @property {number} maxVelocityX - Maximum X velocity objects can move. + * @property {number} maxVelocityY - Maximum Y velocity objects can move. + * @property {number} minBounceVelocity - The minimum velocity an object can be moving at to be considered for bounce. + * @property {number} gravityFactor - Gravity multiplier. Set to 0 for no gravity. + * @property {number} bounciness - The default bounce, or restitution, of bodies in the world. */ /** * @typedef {object} Phaser.Physics.Impact.WorldWalls * - * @property {?Phaser.Physics.Impact.Body} left - [description] - * @property {?Phaser.Physics.Impact.Body} right - [description] - * @property {?Phaser.Physics.Impact.Body} top - [description] - * @property {?Phaser.Physics.Impact.Body} bottom - [description] + * @property {?Phaser.Physics.Impact.Body} left - The left-side wall of the world bounds. + * @property {?Phaser.Physics.Impact.Body} right - The right-side wall of the world bounds. + * @property {?Phaser.Physics.Impact.Body} top - The top wall of the world bounds. + * @property {?Phaser.Physics.Impact.Body} bottom - The bottom wall of the world bounds. */ /** @@ -77,11 +77,11 @@ var TYPE = require('./TYPE'); * * @class World * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Physics.Impact + * @memberof Phaser.Physics.Impact * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene to which this Impact World instance belongs. * @param {Phaser.Physics.Impact.WorldConfig} config - [description] */ var World = new Class({ @@ -484,12 +484,12 @@ var World = new Class({ }, /** - * [description] + * Creates a Graphics Game Object used for debug display and enables the world for debug drawing. * * @method Phaser.Physics.Impact.World#createDebugGraphic * @since 3.0.0 * - * @return {Phaser.GameObjects.Graphics} [description] + * @return {Phaser.GameObjects.Graphics} The Graphics object created that will have the debug visuals drawn to it. */ createDebugGraphic: function () { @@ -592,8 +592,8 @@ var World = new Class({ * @method Phaser.Physics.Impact.World#update * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (time, delta) { diff --git a/src/physics/impact/components/Acceleration.js b/src/physics/impact/components/Acceleration.js index efed22d6f..18ffe0c63 100644 --- a/src/physics/impact/components/Acceleration.js +++ b/src/physics/impact/components/Acceleration.js @@ -5,7 +5,8 @@ */ /** - * [description] + * The Impact Acceleration component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Acceleration * @since 3.0.0 @@ -13,14 +14,14 @@ var Acceleration = { /** - * [description] + * Sets the horizontal acceleration of this body. * * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX * @since 3.0.0 * - * @param {number} x - [description] + * @param {number} x - The amount of acceleration to apply. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setAccelerationX: function (x) { @@ -30,14 +31,14 @@ var Acceleration = { }, /** - * [description] + * Sets the vertical acceleration of this body. * * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY * @since 3.0.0 * - * @param {number} y - [description] + * @param {number} y - The amount of acceleration to apply. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setAccelerationY: function (y) { @@ -47,15 +48,15 @@ var Acceleration = { }, /** - * [description] + * Sets the horizontal and vertical acceleration of this body. * * @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The amount of horizontal acceleration to apply. + * @param {number} y - The amount of vertical acceleration to apply. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setAcceleration: function (x, y) { diff --git a/src/physics/impact/components/BodyScale.js b/src/physics/impact/components/BodyScale.js index dab45e806..4e9483b69 100644 --- a/src/physics/impact/components/BodyScale.js +++ b/src/physics/impact/components/BodyScale.js @@ -5,7 +5,8 @@ */ /** - * [description] + * The Impact Body Scale component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.BodyScale * @since 3.0.0 @@ -13,15 +14,15 @@ var BodyScale = { /** - * [description] + * Sets the size of the physics body. * * @method Phaser.Physics.Impact.Components.BodyScale#setBodySize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} [height=width] - [description] + * @param {number} width - The width of the body in pixels. + * @param {number} [height=width] - The height of the body in pixels. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setBodySize: function (width, height) { @@ -34,15 +35,15 @@ var BodyScale = { }, /** - * [description] + * Sets the scale of the physics body. * * @method Phaser.Physics.Impact.Components.BodyScale#setBodyScale * @since 3.0.0 * - * @param {number} scaleX - [description] - * @param {number} [scaleY] - [description] + * @param {number} scaleX - The horizontal scale of the body. + * @param {number} [scaleY] - The vertical scale of the body. If not given, will use the horizontal scale value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setBodyScale: function (scaleX, scaleY) { diff --git a/src/physics/impact/components/BodyType.js b/src/physics/impact/components/BodyType.js index b6d6f6bc8..6da8778a1 100644 --- a/src/physics/impact/components/BodyType.js +++ b/src/physics/impact/components/BodyType.js @@ -7,7 +7,8 @@ var TYPE = require('../TYPE'); /** - * [description] + * The Impact Body Type component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.BodyType * @since 3.0.0 diff --git a/src/physics/impact/components/Bounce.js b/src/physics/impact/components/Bounce.js index 11814aa99..ac4765446 100644 --- a/src/physics/impact/components/Bounce.js +++ b/src/physics/impact/components/Bounce.js @@ -5,7 +5,8 @@ */ /** - * [description] + * The Impact Bounce component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Bounce * @since 3.0.0 @@ -13,12 +14,12 @@ var Bounce = { /** - * [description] + * Sets the impact physics bounce, or restitution, value. * * @method Phaser.Physics.Impact.Components.Bounce#setBounce * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - A value between 0 (no rebound) and 1 (full rebound) * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -30,12 +31,12 @@ var Bounce = { }, /** - * [description] + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. * * @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The minimum allowed velocity. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -47,7 +48,8 @@ var Bounce = { }, /** - * [description] + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) * * @name Phaser.Physics.Impact.Components.Bounce#bounce * @type {number} diff --git a/src/physics/impact/components/CheckAgainst.js b/src/physics/impact/components/CheckAgainst.js index 118d51f89..0b3d2554d 100644 --- a/src/physics/impact/components/CheckAgainst.js +++ b/src/physics/impact/components/CheckAgainst.js @@ -7,7 +7,8 @@ var TYPE = require('../TYPE'); /** - * [description] + * The Impact Check Against component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.CheckAgainst * @since 3.0.0 diff --git a/src/physics/impact/components/Collides.js b/src/physics/impact/components/Collides.js index 3a82c7a13..8af458bb6 100644 --- a/src/physics/impact/components/Collides.js +++ b/src/physics/impact/components/Collides.js @@ -15,7 +15,8 @@ var COLLIDES = require('../COLLIDES'); */ /** - * [description] + * The Impact Collides component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Collides * @since 3.0.0 diff --git a/src/physics/impact/components/Debug.js b/src/physics/impact/components/Debug.js index 267478bbb..b91ac79a3 100644 --- a/src/physics/impact/components/Debug.js +++ b/src/physics/impact/components/Debug.js @@ -5,7 +5,8 @@ */ /** - * [description] + * The Impact Debug component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Debug * @since 3.0.0 diff --git a/src/physics/impact/components/Friction.js b/src/physics/impact/components/Friction.js index 24f50501e..b0d14c2dc 100644 --- a/src/physics/impact/components/Friction.js +++ b/src/physics/impact/components/Friction.js @@ -5,7 +5,8 @@ */ /** - * [description] + * The Impact Friction component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Friction * @since 3.0.0 diff --git a/src/physics/impact/components/Gravity.js b/src/physics/impact/components/Gravity.js index ae5e34444..6ea581451 100644 --- a/src/physics/impact/components/Gravity.js +++ b/src/physics/impact/components/Gravity.js @@ -5,7 +5,8 @@ */ /** - * [description] + * The Impact Gravity component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Gravity * @since 3.0.0 diff --git a/src/physics/impact/components/Offset.js b/src/physics/impact/components/Offset.js index 2c1329c23..d640eb609 100644 --- a/src/physics/impact/components/Offset.js +++ b/src/physics/impact/components/Offset.js @@ -5,7 +5,8 @@ */ /** - * [description] + * The Impact Offset component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Offset * @since 3.0.0 diff --git a/src/physics/impact/components/SetGameObject.js b/src/physics/impact/components/SetGameObject.js index 1fcb1b9c1..0344c4a3d 100644 --- a/src/physics/impact/components/SetGameObject.js +++ b/src/physics/impact/components/SetGameObject.js @@ -5,7 +5,8 @@ */ /** - * [description] + * The Impact Set Game Object component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.SetGameObject * @since 3.0.0 diff --git a/src/physics/impact/components/Velocity.js b/src/physics/impact/components/Velocity.js index 551d2c5c0..c2028aba1 100644 --- a/src/physics/impact/components/Velocity.js +++ b/src/physics/impact/components/Velocity.js @@ -5,7 +5,8 @@ */ /** - * [description] + * The Impact Velocity component. + * Should be applied as a mixin. * * @name Phaser.Physics.Impact.Components.Velocity * @since 3.0.0 @@ -13,14 +14,14 @@ var Velocity = { /** - * [description] + * Sets the horizontal velocity of the physics body. * * @method Phaser.Physics.Impact.Components.Velocity#setVelocityX * @since 3.0.0 * - * @param {number} x - [description] + * @param {number} x - The horizontal velocity value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setVelocityX: function (x) { @@ -30,14 +31,14 @@ var Velocity = { }, /** - * [description] + * Sets the vertical velocity of the physics body. * * @method Phaser.Physics.Impact.Components.Velocity#setVelocityY * @since 3.0.0 * - * @param {number} y - [description] + * @param {number} y - The vertical velocity value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setVelocityY: function (y) { @@ -47,15 +48,15 @@ var Velocity = { }, /** - * [description] + * Sets the horizontal and vertical velocities of the physics body. * * @method Phaser.Physics.Impact.Components.Velocity#setVelocity * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The horizontal velocity value. + * @param {number} [y=x] - The vertical velocity value. If not given, defaults to the horizontal value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setVelocity: function (x, y) { @@ -68,15 +69,15 @@ var Velocity = { }, /** - * [description] + * Sets the maximum velocity this body can travel at. * * @method Phaser.Physics.Impact.Components.Velocity#setMaxVelocity * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The maximum allowed horizontal velocity. + * @param {number} [y=x] - The maximum allowed vertical velocity. If not given, defaults to the horizontal value. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setMaxVelocity: function (x, y) { diff --git a/src/physics/matter-js/Factory.js b/src/physics/matter-js/Factory.js index 26c87428e..aae35f3bb 100644 --- a/src/physics/matter-js/Factory.js +++ b/src/physics/matter-js/Factory.js @@ -16,14 +16,14 @@ var PointerConstraint = require('./PointerConstraint'); /** * @classdesc - * [description] + * The Matter Factory can create different types of bodies and them to a physics world. * * @class Factory - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * - * @param {Phaser.Physics.Matter.World} world - [description] + * @param {Phaser.Physics.Matter.World} world - The Matter World which this Factory adds to. */ var Factory = new Class({ @@ -32,7 +32,7 @@ var Factory = new Class({ function Factory (world) { /** - * [description] + * The Matter World which this Factory adds to. * * @name Phaser.Physics.Matter.Factory#world * @type {Phaser.Physics.Matter.World} @@ -41,7 +41,7 @@ var Factory = new Class({ this.world = world; /** - * [description] + * The Scene which this Factory's Matter World belongs to. * * @name Phaser.Physics.Matter.Factory#scene * @type {Phaser.Scene} @@ -60,16 +60,16 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new rigid rectangular Body and adds it to the World. * * @method Phaser.Physics.Matter.Factory#rectangle * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} options - [description] + * @param {number} x - The X coordinate of the center of the Body. + * @param {number} y - The Y coordinate of the center of the Body. + * @param {number} width - The width of the Body. + * @param {number} height - The height of the Body. + * @param {object} options - An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. * * @return {MatterJS.Body} A Matter JS Body. */ @@ -83,17 +83,17 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new rigid trapezoidal Body and adds it to the World. * * @method Phaser.Physics.Matter.Factory#trapezoid * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} slope - [description] - * @param {object} options - [description] + * @param {number} x - The X coordinate of the center of the Body. + * @param {number} y - The Y coordinate of the center of the Body. + * @param {number} width - The width of the trapezoid of the Body. + * @param {number} height - The height of the trapezoid of the Body. + * @param {number} slope - The slope of the trapezoid. 0 creates a rectangle, while 1 creates a triangle. Positive values make the top side shorter, while negative values make the bottom side shorter. + * @param {object} options - An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. * * @return {MatterJS.Body} A Matter JS Body. */ @@ -107,16 +107,16 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new rigid circular Body and adds it to the World. * * @method Phaser.Physics.Matter.Factory#circle * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} radius - [description] - * @param {object} options - [description] - * @param {number} maxSides - [description] + * @param {number} x - The X coordinate of the center of the Body. + * @param {number} y - The Y coordinate of the center of the Body. + * @param {number} radius - The radius of the circle. + * @param {object} options - An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. + * @param {number} maxSides - The maximum amount of sides to use for the polygon which will approximate this circle. * * @return {MatterJS.Body} A Matter JS Body. */ @@ -130,16 +130,16 @@ var Factory = new Class({ }, /** - * [description] + * Creates a new rigid polygonal Body and adds it to the World. * * @method Phaser.Physics.Matter.Factory#polygon * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} sides - [description] - * @param {number} radius - [description] - * @param {object} options - [description] + * @param {number} x - The X coordinate of the center of the Body. + * @param {number} y - The Y coordinate of the center of the Body. + * @param {number} sides - The number of sides the polygon will have. + * @param {number} radius - The "radius" of the polygon, i.e. the distance from its center to any vertex. This is also the radius of its circumcircle. + * @param {object} options - An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. * * @return {MatterJS.Body} A Matter JS Body. */ @@ -153,18 +153,19 @@ var Factory = new Class({ }, /** - * [description] + * Creates a body using the supplied vertices (or an array containing multiple sets of vertices) and adds it to the World. + * If the vertices are convex, they will pass through as supplied. Otherwise, if the vertices are concave, they will be decomposed. Note that this process is not guaranteed to support complex sets of vertices, e.g. ones with holes. * * @method Phaser.Physics.Matter.Factory#fromVertices * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] + * @param {number} x - The X coordinate of the center of the Body. + * @param {number} y - The Y coordinate of the center of the Body. * @param {array} vertexSets - [description] * @param {object} options - [description] - * @param {boolean} flagInternal - [description] - * @param {boolean} removeCollinear - [description] - * @param {number} minimumArea - [description] + * @param {boolean} flagInternal - Flag internal edges (coincident part edges) + * @param {boolean} removeCollinear - Whether Matter.js will discard collinear edges (to improve performance). + * @param {number} minimumArea - During decomposition discard parts that have an area less than this * * @return {MatterJS.Body} A Matter JS Body. */ @@ -260,7 +261,7 @@ var Factory = new Class({ * @param {number} rows - The number of rows in the pyramid. * @param {number} columnGap - The distance between each column. * @param {number} rowGap - The distance between each row. - * @param {function} callback - [description] + * @param {function} callback - The callback function to be invoked. * * @return {MatterJS.Composite} A Matter JS Composite pyramid. */ @@ -371,7 +372,7 @@ var Factory = new Class({ * @param {number} columnGap - The distance between each column. * @param {number} rowGap - The distance between each row. * @param {boolean} crossBrace - [description] - * @param {number} particleRadius - [description] + * @param {number} particleRadius - The radius of this circlular composite. * @param {object} particleOptions - [description] * @param {object} constraintOptions - [description] * @@ -411,10 +412,10 @@ var Factory = new Class({ * @method Phaser.Physics.Matter.Factory#spring * @since 3.0.0 * - * @param {MatterJS.Body} bodyA - [description] - * @param {MatterJS.Body} bodyB - [description] - * @param {number} length - [description] - * @param {number} [stiffness=1] - [description] + * @param {MatterJS.Body} bodyA - The first possible `Body` that this constraint is attached to. + * @param {MatterJS.Body} bodyB - The second possible `Body` that this constraint is attached to. + * @param {number} length - A Number that specifies the target resting length of the constraint. It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB` + * @param {number} [stiffness=1] - A Number that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. A value of `1` means the constraint should be very stiff. A value of `0.2` means the constraint acts as a soft spring. * @param {object} [options={}] - [description] * * @return {MatterJS.Constraint} A Matter JS Constraint. diff --git a/src/physics/matter-js/MatterGameObject.js b/src/physics/matter-js/MatterGameObject.js index 198fa074f..717fc15b5 100644 --- a/src/physics/matter-js/MatterGameObject.js +++ b/src/physics/matter-js/MatterGameObject.js @@ -9,7 +9,7 @@ var GetFastValue = require('../../utils/object/GetFastValue'); var Vector2 = require('../../math/Vector2'); /** - * [description] + * Internal function to check if the object has a getter or setter. * * @function hasGetterOrSetter * @private @@ -29,11 +29,11 @@ function hasGetterOrSetter (def) * @function Phaser.Physics.Matter.MatterGameObject * @since 3.3.0 * - * @param {Phaser.Physics.Matter.World} world - [description] - * @param {Phaser.GameObjects.GameObject} gameObject - [description] - * @param {object} options - [description] + * @param {Phaser.Physics.Matter.World} world - The Matter world to add the body to. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will have the Matter body applied to it. + * @param {object} options - Matter options config object. * - * @return {Phaser.GameObjects.GameObject} [description] + * @return {Phaser.GameObjects.GameObject} The Game Object that was created with the Matter body. */ var MatterGameObject = function (world, gameObject, options) { @@ -44,6 +44,7 @@ var MatterGameObject = function (world, gameObject, options) // Temp body pos to avoid body null checks gameObject.body = { + temp: true, position: { x: x, y: y diff --git a/src/physics/matter-js/MatterImage.js b/src/physics/matter-js/MatterImage.js index 309c877a2..3e1dd9200 100644 --- a/src/physics/matter-js/MatterImage.js +++ b/src/physics/matter-js/MatterImage.js @@ -23,7 +23,7 @@ var Vector2 = require('../../math/Vector2'); * * @class Image * @extends Phaser.GameObjects.Image - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * diff --git a/src/physics/matter-js/MatterPhysics.js b/src/physics/matter-js/MatterPhysics.js index 1013e5cb3..622b27638 100644 --- a/src/physics/matter-js/MatterPhysics.js +++ b/src/physics/matter-js/MatterPhysics.js @@ -15,13 +15,14 @@ var Merge = require('../../utils/object/Merge'); var Plugin = require('./lib/core/Plugin'); var PluginCache = require('../../plugins/PluginCache'); var World = require('./World'); +var Vertices = require('./lib/geometry/Vertices'); /** * @classdesc * [description] * * @class MatterPhysics - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * @@ -78,6 +79,17 @@ var MatterPhysics = new Class({ */ this.add; + /** + * A reference to the `Matter.Vertices` module which contains methods for creating and manipulating sets of vertices. + * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. + * A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). + * + * @name Phaser.Physics.Matter.MatterPhysics#verts + * @type {MatterJS.Vertices} + * @since 3.14.0 + */ + this.verts = Vertices; + // Matter plugins if (GetValue(this.config, 'plugins.attractors', false)) diff --git a/src/physics/matter-js/MatterSprite.js b/src/physics/matter-js/MatterSprite.js index 1566e216a..c093a4723 100644 --- a/src/physics/matter-js/MatterSprite.js +++ b/src/physics/matter-js/MatterSprite.js @@ -27,7 +27,7 @@ var Vector2 = require('../../math/Vector2'); * * @class Sprite * @extends Phaser.GameObjects.Sprite - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * diff --git a/src/physics/matter-js/MatterTileBody.js b/src/physics/matter-js/MatterTileBody.js index c0b3787a2..e22e46a76 100644 --- a/src/physics/matter-js/MatterTileBody.js +++ b/src/physics/matter-js/MatterTileBody.js @@ -26,7 +26,7 @@ var Vertices = require('./lib/geometry/Vertices'); * Phaser.Physics.Matter.TileBody#setFromTileCollision for more information. * * @class TileBody - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * diff --git a/src/physics/matter-js/PointerConstraint.js b/src/physics/matter-js/PointerConstraint.js index f0ddacea1..76a692124 100644 --- a/src/physics/matter-js/PointerConstraint.js +++ b/src/physics/matter-js/PointerConstraint.js @@ -20,7 +20,7 @@ var Vertices = require('./lib/geometry/Vertices'); * [description] * * @class PointerConstraint - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * diff --git a/src/physics/matter-js/World.js b/src/physics/matter-js/World.js index 2e774359c..0a8fda1e5 100644 --- a/src/physics/matter-js/World.js +++ b/src/physics/matter-js/World.js @@ -24,11 +24,11 @@ var Vector = require('./lib/geometry/Vector'); * * @class World * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Physics.Matter + * @memberof Phaser.Physics.Matter * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene to which this Matter World instance belongs. * @param {object} config - [description] */ var World = new Class({ @@ -42,7 +42,7 @@ var World = new Class({ EventEmitter.call(this); /** - * [description] + * The Scene to which this Matter World instance belongs. * * @name Phaser.Physics.Matter.World#scene * @type {Phaser.Scene} @@ -51,7 +51,7 @@ var World = new Class({ this.scene = scene; /** - * [description] + * An instance of the MatterJS Engine. * * @name Phaser.Physics.Matter.World#engine * @type {MatterJS.Engine} @@ -109,7 +109,7 @@ var World = new Class({ } /** - * [description] + * A flag that toggles if the world is enabled or not. * * @name Phaser.Physics.Matter.World#enabled * @type {boolean} @@ -175,7 +175,7 @@ var World = new Class({ this.autoUpdate = GetValue(config, 'autoUpdate', true); /** - * [description] + * A flag that controls if the debug graphics will be drawn to or not. * * @name Phaser.Physics.Matter.World#drawDebug * @type {boolean} @@ -185,7 +185,7 @@ var World = new Class({ this.drawDebug = GetValue(config, 'debug', false); /** - * [description] + * An instance of the Graphics object the debug bodies are drawn to, if enabled. * * @name Phaser.Physics.Matter.World#debugGraphic * @type {Phaser.GameObjects.Graphics} @@ -194,21 +194,27 @@ var World = new Class({ this.debugGraphic; /** - * [description] + * The default configuration values. * * @name Phaser.Physics.Matter.World#defaults * @type {object} * @since 3.0.0 */ this.defaults = { - debugShowBody: GetValue(config, 'debugShowBody', true), - debugShowStaticBody: GetValue(config, 'debugShowStaticBody', true), - debugShowVelocity: GetValue(config, 'debugShowVelocity', true), - bodyDebugColor: GetValue(config, 'debugBodyColor', 0xff00ff), - staticBodyDebugColor: GetValue(config, 'debugBodyColor', 0x0000ff), - velocityDebugColor: GetValue(config, 'debugVelocityColor', 0x00ff00), - debugShowJoint: GetValue(config, 'debugShowJoint', true), - jointDebugColor: GetValue(config, 'debugJointColor', 0x000000) + debugShowBody: GetFastValue(config, 'debugShowBody', true), + debugShowStaticBody: GetFastValue(config, 'debugShowStaticBody', true), + debugShowVelocity: GetFastValue(config, 'debugShowVelocity', true), + bodyDebugColor: GetFastValue(config, 'debugBodyColor', 0xff00ff), + bodyDebugFillColor: GetFastValue(config, 'bodyDebugFillColor', 0xe3a7e3), + staticBodyDebugColor: GetFastValue(config, 'debugBodyColor', 0x0000ff), + velocityDebugColor: GetFastValue(config, 'debugVelocityColor', 0x00ff00), + debugShowJoint: GetFastValue(config, 'debugShowJoint', true), + jointDebugColor: GetFastValue(config, 'debugJointColor', 0x000000), + debugWireframes: GetFastValue(config, 'debugWireframes', true), + debugShowInternalEdges: GetFastValue(config, 'debugShowInternalEdges', false), + debugShowConvexHulls: GetFastValue(config, 'debugShowConvexHulls', false), + debugConvexHullColor: GetFastValue(config, 'debugConvexHullColor', 0xaaaaaa), + debugShowSleeping: GetFastValue(config, 'debugShowSleeping', false) }; if (this.drawDebug) @@ -393,7 +399,7 @@ var World = new Class({ }, /** - * [description] + * Sets the world's gravity and gravity scale to 0. * * @method Phaser.Physics.Matter.World#disableGravity * @since 3.0.0 @@ -410,13 +416,13 @@ var World = new Class({ }, /** - * [description] + * Sets the world's gravity * * @method Phaser.Physics.Matter.World#setGravity * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=1] - [description] + * @param {number} [x=0] - The world gravity x component. + * @param {number} [y=1] - The world gravity y component. * @param {number} [scale] - [description] * * @return {Phaser.Physics.Matter.World} This Matter World object. @@ -438,18 +444,18 @@ var World = new Class({ }, /** - * [description] + * Creates a rectangle Matter body and adds it to the world. * * @method Phaser.Physics.Matter.World#create * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} width - [description] - * @param {number} height - [description] - * @param {object} options - [description] + * @param {number} x - The horizontal position of the body in the world. + * @param {number} y - The vertical position of the body in the world. + * @param {number} width - The width of the body. + * @param {number} height - The height of the body. + * @param {object} options - Optional Matter configuration object. * - * @return {MatterJS.Body} [description] + * @return {MatterJS.Body} The Matter.js body that was created. */ create: function (x, y, width, height, options) { @@ -461,7 +467,7 @@ var World = new Class({ }, /** - * [description] + * Adds an object to the world. * * @method Phaser.Physics.Matter.World#add * @since 3.0.0 @@ -586,7 +592,7 @@ var World = new Class({ * @method Phaser.Physics.Matter.World#nextCategory * @since 3.0.0 * - * @return {number} [description] + * @return {number} Returns the next unique category bitfield. */ nextCategory: function () { @@ -633,8 +639,8 @@ var World = new Class({ * @method Phaser.Physics.Matter.World#update * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (time, delta) { @@ -703,9 +709,10 @@ var World = new Class({ }, /** - * [description] + * Handles the rendering of bodies and debug information to the debug Graphics object, if enabled. * * @method Phaser.Physics.Matter.World#postUpdate + * @private * @since 3.0.0 */ postUpdate: function () @@ -715,135 +722,325 @@ var World = new Class({ return; } - var graphics = this.debugGraphic; + this.debugGraphic.clear(); + var bodies = Composite.allBodies(this.localWorld); - graphics.clear(); - graphics.lineStyle(1, this.defaults.bodyDebugColor); - graphics.beginPath(); - - var i,j; - - for (i = 0; i < bodies.length; i++) + if (this.defaults.debugWireframes) { - if (!bodies[i].render.visible) + if (this.defaults.debugShowConvexHulls) { - return; + this.renderConvexHulls(bodies); } - // Handle drawing both single bodies and compound bodies. If compound, draw both the - // convex hull (first part) and the rest of the bodies. - for (j = 0; j < bodies[i].parts.length; j++) - { - var body = bodies[i].parts[j]; - - var vertices = body.vertices; - - graphics.moveTo(vertices[0].x, vertices[0].y); - - for (var k = 1; k < vertices.length; k++) - { - graphics.lineTo(vertices[k].x, vertices[k].y); - } - - graphics.lineTo(vertices[0].x, vertices[0].y); - - graphics.strokePath(); - } + this.renderWireframes(bodies); + } + else + { + this.renderBodies(bodies); } - - graphics.closePath(); if (this.defaults.debugShowJoint) { - graphics.lineStyle(2, this.defaults.jointDebugColor); + this.renderJoints(); + } + }, - // Render constraints - var constraints = Composite.allConstraints(this.localWorld); + /** + * Renders the debug convex hulls from the given array of bodies. + * + * @method Phaser.Physics.Matter.World#renderConvexHulls + * @private + * @since 3.14.0 + * + * @param {array} bodies - An array of bodies from the localWorld. + */ + renderConvexHulls: function (bodies) + { + var graphics = this.debugGraphic; - for (i = 0; i < constraints.length; i++) + graphics.lineStyle(1, this.defaults.debugConvexHullColor); + + graphics.beginPath(); + + for (var i = 0; i < bodies.length; i++) + { + var body = bodies[i]; + + if (!body.render.visible || body.parts.length === 1) { - var constraint = constraints[i]; + continue; + } - if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) + graphics.moveTo(body.vertices[0].x, body.vertices[0].y); + + for (var j = 1; j < body.vertices.length; j++) + { + graphics.lineTo(body.vertices[j].x, body.vertices[j].y); + } + + graphics.lineTo(body.vertices[0].x, body.vertices[0].y); + } + + graphics.strokePath(); + }, + + /** + * Renders the wireframes of the given array of bodies. + * + * @method Phaser.Physics.Matter.World#renderWireframes + * @private + * @since 3.14.0 + * + * @param {array} bodies - An array of bodies from the localWorld. + */ + renderWireframes: function (bodies) + { + var graphics = this.debugGraphic; + var showInternalEdges = this.defaults.debugShowInternalEdges; + + graphics.lineStyle(1, this.defaults.bodyDebugColor); + + graphics.beginPath(); + + for (var i = 0; i < bodies.length; i++) + { + var body = bodies[i]; + + if (!body.render.visible) + { + continue; + } + + for (var k = (body.parts.length > 1) ? 1 : 0; k < body.parts.length; k++) + { + var part = body.parts[k]; + + var vertLength = part.vertices.length; + + graphics.moveTo(part.vertices[0].x, part.vertices[0].y); + + for (var j = 1; j < vertLength; j++) + { + if (!part.vertices[j - 1].isInternal || showInternalEdges) + { + graphics.lineTo(part.vertices[j].x, part.vertices[j].y); + } + else + { + graphics.moveTo(part.vertices[j].x, part.vertices[j].y); + } + + if (part.vertices[j].isInternal && !showInternalEdges) + { + graphics.moveTo(part.vertices[(j + 1) % vertLength].x, part.vertices[(j + 1) % vertLength].y); + } + } + + graphics.lineTo(part.vertices[0].x, part.vertices[0].y); + } + } + + graphics.strokePath(); + }, + + /** + * Renders the array of bodies. + * + * @method Phaser.Physics.Matter.World#renderBodies + * @private + * @since 3.14.0 + * + * @param {array} bodies - An array of bodies from the localWorld. + */ + renderBodies: function (bodies) + { + var graphics = this.debugGraphic; + + var showInternalEdges = this.defaults.debugShowInternalEdges || !this.defaults.debugWireframes; + var showSleeping = this.defaults.debugShowSleeping; + var wireframes = this.defaults.debugWireframes; + + var body; + var part; + var i; + var k; + + for (i = 0; i < bodies.length; i++) + { + body = bodies[i]; + + if (!body.render.visible) + { + continue; + } + + // Handle compound parts + for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) + { + part = body.parts[k]; + + if (!part.render.visible) { continue; } - if (constraint.render.lineWidth) + if (showSleeping && body.isSleeping) { - graphics.lineStyle(constraint.render.lineWidth, Common.colorToNumber(constraint.render.strokeStyle)); - } - - var bodyA = constraint.bodyA; - var bodyB = constraint.bodyB; - var start; - var end; - - if (bodyA) - { - start = Vector.add(bodyA.position, constraint.pointA); + graphics.lineStyle(1, this.defaults.bodyDebugColor, 0.5 * part.render.opacity); + graphics.fillStyle(this.defaults.bodyDebugColor, 0.5 * part.render.opacity); } else { - start = constraint.pointA; + graphics.lineStyle(1, this.defaults.bodyDebugColor, part.render.opacity); + graphics.fillStyle(this.defaults.bodyDebugColor, part.render.opacity); } - if (constraint.render.type === 'pin') + // Part polygon + if (part.circleRadius) { graphics.beginPath(); - graphics.arc(start.x, start.y, 3, 0, 2 * Math.PI); - graphics.closePath(); + graphics.arc(part.position.x, part.position.y, part.circleRadius, 0, 2 * Math.PI); } else { - if (bodyB) - { - end = Vector.add(bodyB.position, constraint.pointB); - } - else - { - end = constraint.pointB; - } - graphics.beginPath(); - graphics.moveTo(start.x, start.y); + graphics.moveTo(part.vertices[0].x, part.vertices[0].y); - if (constraint.render.type === 'spring') + var vertLength = part.vertices.length; + + for (var j = 1; j < vertLength; j++) { - var delta = Vector.sub(end, start); - var normal = Vector.perp(Vector.normalise(delta)); - var coils = Math.ceil(Common.clamp(constraint.length / 5, 12, 20)); - var offset; - - for (j = 1; j < coils; j += 1) + if (!part.vertices[j - 1].isInternal || showInternalEdges) { - offset = (j % 2 === 0) ? 1 : -1; + graphics.lineTo(part.vertices[j].x, part.vertices[j].y); + } + else + { + graphics.moveTo(part.vertices[j].x, part.vertices[j].y); + } - graphics.lineTo( - start.x + delta.x * (j / coils) + normal.x * offset * 4, - start.y + delta.y * (j / coils) + normal.y * offset * 4 - ); + if (part.vertices[j].isInternal && !showInternalEdges) + { + graphics.moveTo(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y); } } + + graphics.lineTo(part.vertices[0].x, part.vertices[0].y); - graphics.lineTo(end.x, end.y); + graphics.closePath(); } - if (constraint.render.lineWidth) + if (!wireframes) + { + graphics.fillPath(); + } + else { graphics.strokePath(); } + } + } + }, - if (constraint.render.anchors) + /** + * Renders world constraints. + * + * @method Phaser.Physics.Matter.World#renderJoints + * @private + * @since 3.14.0 + */ + renderJoints: function () + { + var graphics = this.debugGraphic; + + graphics.lineStyle(2, this.defaults.jointDebugColor); + + // Render constraints + var constraints = Composite.allConstraints(this.localWorld); + + for (var i = 0; i < constraints.length; i++) + { + var constraint = constraints[i]; + + if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) + { + continue; + } + + if (constraint.render.lineWidth) + { + graphics.lineStyle(constraint.render.lineWidth, Common.colorToNumber(constraint.render.strokeStyle)); + } + + var bodyA = constraint.bodyA; + var bodyB = constraint.bodyB; + var start; + var end; + + if (bodyA) + { + start = Vector.add(bodyA.position, constraint.pointA); + } + else + { + start = constraint.pointA; + } + + if (constraint.render.type === 'pin') + { + graphics.beginPath(); + graphics.arc(start.x, start.y, 3, 0, 2 * Math.PI); + graphics.closePath(); + } + else + { + if (bodyB) { - graphics.fillStyle(Common.colorToNumber(constraint.render.strokeStyle)); - graphics.beginPath(); - graphics.arc(start.x, start.y, 6, 0, 2 * Math.PI); - graphics.arc(end.x, end.y, 6, 0, 2 * Math.PI); - graphics.closePath(); - graphics.fillPath(); + end = Vector.add(bodyB.position, constraint.pointB); } + else + { + end = constraint.pointB; + } + + graphics.beginPath(); + graphics.moveTo(start.x, start.y); + + if (constraint.render.type === 'spring') + { + var delta = Vector.sub(end, start); + var normal = Vector.perp(Vector.normalise(delta)); + var coils = Math.ceil(Common.clamp(constraint.length / 5, 12, 20)); + var offset; + + for (var j = 1; j < coils; j += 1) + { + offset = (j % 2 === 0) ? 1 : -1; + + graphics.lineTo( + start.x + delta.x * (j / coils) + normal.x * offset * 4, + start.y + delta.y * (j / coils) + normal.y * offset * 4 + ); + } + } + + graphics.lineTo(end.x, end.y); + } + + if (constraint.render.lineWidth) + { + graphics.strokePath(); + } + + if (constraint.render.anchors) + { + graphics.fillStyle(Common.colorToNumber(constraint.render.strokeStyle)); + graphics.beginPath(); + graphics.arc(start.x, start.y, 6, 0, 2 * Math.PI); + graphics.arc(end.x, end.y, 6, 0, 2 * Math.PI); + graphics.closePath(); + graphics.fillPath(); } } }, @@ -877,7 +1074,8 @@ var World = new Class({ }, /** - * [description] + * Will remove all Matter physics event listeners and clear the matter physics world, + * engine and any debug graphics, if any. * * @method Phaser.Physics.Matter.World#shutdown * @since 3.0.0 @@ -891,10 +1089,18 @@ var World = new Class({ MatterWorld.clear(this.localWorld, false); Engine.clear(this.engine); + + if (this.drawDebug) + { + this.debugGraphic.destroy(); + } }, /** - * [description] + * Will remove all Matter physics event listeners and clear the matter physics world, + * engine and any debug graphics, if any. + * + * After destroying the world it cannot be re-used again. * * @method Phaser.Physics.Matter.World#destroy * @since 3.0.0 diff --git a/src/physics/matter-js/components/Bounce.js b/src/physics/matter-js/components/Bounce.js index 9ada1efaf..634ca6514 100644 --- a/src/physics/matter-js/components/Bounce.js +++ b/src/physics/matter-js/components/Bounce.js @@ -5,7 +5,7 @@ */ /** - * [description] + * A component to set restitution on objects. * * @name Phaser.Physics.Matter.Components.Bounce * @since 3.0.0 @@ -13,12 +13,12 @@ var Bounce = { /** - * [description] + * Sets the restitution on the physics object. * * @method Phaser.Physics.Matter.Components.Bounce#setBounce * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)` * * @return {Phaser.GameObjects.GameObject} This Game Object. */ diff --git a/src/physics/matter-js/components/Collision.js b/src/physics/matter-js/components/Collision.js index 5843eda57..1d43f0fb4 100644 --- a/src/physics/matter-js/components/Collision.js +++ b/src/physics/matter-js/components/Collision.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Contains methods for changing the collision filter of a Matter Body. Should be used as a mixin and not called directly. * * @name Phaser.Physics.Matter.Components.Collision * @since 3.0.0 @@ -13,7 +13,7 @@ var Collision = { /** - * [description] + * Sets the collision category of this Game Object's Matter Body. This number must be a power of two between 2^0 (= 1) and 2^31. Two bodies with different collision groups (see {@link #setCollisionGroup}) will only collide if their collision categories are included in their collision masks (see {@link #setCollidesWith}). * * @method Phaser.Physics.Matter.Components.Collision#setCollisionCategory * @since 3.0.0 @@ -30,7 +30,7 @@ var Collision = { }, /** - * [description] + * Sets the collision group of this Game Object's Matter Body. If this is zero or two Matter Bodies have different values, they will collide according to the usual rules (see {@link #setCollisionCategory} and {@link #setCollisionGroup}). If two Matter Bodies have the same positive value, they will always collide; if they have the same negative value, they will never collide. * * @method Phaser.Physics.Matter.Components.Collision#setCollisionGroup * @since 3.0.0 @@ -47,7 +47,7 @@ var Collision = { }, /** - * [description] + * Sets the collision mask for this Game Object's Matter Body. Two Matter Bodies with different collision groups will only collide if each one includes the other's category in its mask based on a bitwise AND, i.e. `(categoryA & maskB) !== 0` and `(categoryB & maskA) !== 0` are both true. * * @method Phaser.Physics.Matter.Components.Collision#setCollidesWith * @since 3.0.0 diff --git a/src/physics/matter-js/components/Force.js b/src/physics/matter-js/components/Force.js index 87d964320..5f10d60a1 100644 --- a/src/physics/matter-js/components/Force.js +++ b/src/physics/matter-js/components/Force.js @@ -7,7 +7,7 @@ var Body = require('../lib/body/Body'); /** - * [description] + * A component to apply force to Matter.js bodies. * * @name Phaser.Physics.Matter.Components.Force * @since 3.0.0 @@ -15,13 +15,14 @@ var Body = require('../lib/body/Body'); var Force = { // force = vec2 / point + /** - * [description] + * Applies a force to a body. * * @method Phaser.Physics.Matter.Components.Force#applyForce * @since 3.0.0 * - * @param {Phaser.Math.Vector2} force - [description] + * @param {Phaser.Math.Vector2} force - A Vector that specifies the force to apply. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -35,13 +36,13 @@ var Force = { }, /** - * [description] + * Applies a force to a body from a given position. * * @method Phaser.Physics.Matter.Components.Force#applyForceFrom * @since 3.0.0 * - * @param {Phaser.Math.Vector2} position - [description] - * @param {Phaser.Math.Vector2} force - [description] + * @param {Phaser.Math.Vector2} position - The position in which the force comes from. + * @param {Phaser.Math.Vector2} force - A Vector that specifies the force to apply. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -53,12 +54,12 @@ var Force = { }, /** - * [description] + * Apply thrust to the forward position of the body. * * @method Phaser.Physics.Matter.Components.Force#thrust * @since 3.0.0 * - * @param {number} speed - [description] + * @param {number} speed - A speed value to be applied to a directional force. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -74,12 +75,12 @@ var Force = { }, /** - * [description] + * Apply thrust to the left position of the body. * * @method Phaser.Physics.Matter.Components.Force#thrustLeft * @since 3.0.0 * - * @param {number} speed - [description] + * @param {number} speed - A speed value to be applied to a directional force. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -95,12 +96,12 @@ var Force = { }, /** - * [description] + * Apply thrust to the right position of the body. * * @method Phaser.Physics.Matter.Components.Force#thrustRight * @since 3.0.0 * - * @param {number} speed - [description] + * @param {number} speed - A speed value to be applied to a directional force. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -116,12 +117,12 @@ var Force = { }, /** - * [description] + * Apply thrust to the back position of the body. * * @method Phaser.Physics.Matter.Components.Force#thrustBack * @since 3.0.0 * - * @param {number} speed - [description] + * @param {number} speed - A speed value to be applied to a directional force. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ diff --git a/src/physics/matter-js/components/Friction.js b/src/physics/matter-js/components/Friction.js index 41bb33ab2..1a778ed67 100644 --- a/src/physics/matter-js/components/Friction.js +++ b/src/physics/matter-js/components/Friction.js @@ -5,7 +5,7 @@ */ /** - * [description] + * Contains methods for changing the friction of a Game Object's Matter Body. Should be used a mixin, not called directly. * * @name Phaser.Physics.Matter.Components.Friction * @since 3.0.0 @@ -13,14 +13,14 @@ var Friction = { /** - * [description] + * Sets new friction values for this Game Object's Matter Body. * * @method Phaser.Physics.Matter.Components.Friction#setFriction * @since 3.0.0 * - * @param {number} value - [description] - * @param {number} [air] - [description] - * @param {number} [fstatic] - [description] + * @param {number} value - The new friction of the body, between 0 and 1, where 0 allows the Body to slide indefinitely, while 1 allows it to stop almost immediately after a force is applied. + * @param {number} [air] - If provided, the new air resistance of the Body. The higher the value, the faster the Body will slow as it moves through space. 0 means the body has no air resistance. + * @param {number} [fstatic] - If provided, the new static friction of the Body. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. 0 means the body will never "stick" when it is nearly stationary. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -42,12 +42,12 @@ var Friction = { }, /** - * [description] + * Sets a new air resistance for this Game Object's Matter Body. A value of 0 means the Body will never slow as it moves through space. The higher the value, the faster a Body slows when moving through space. * * @method Phaser.Physics.Matter.Components.Friction#setFrictionAir * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The new air resistance for the Body. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -59,12 +59,12 @@ var Friction = { }, /** - * [description] + * Sets a new static friction for this Game Object's Matter Body. A value of 0 means the Body will never "stick" when it is nearly stationary. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. * * @method Phaser.Physics.Matter.Components.Friction#setFrictionStatic * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The new static friction for the Body. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ diff --git a/src/physics/matter-js/components/Gravity.js b/src/physics/matter-js/components/Gravity.js index c77dc0f8b..f1bcc6b4a 100644 --- a/src/physics/matter-js/components/Gravity.js +++ b/src/physics/matter-js/components/Gravity.js @@ -5,7 +5,7 @@ */ /** - * [description] + * A component to manipulate world gravity for Matter.js bodies. * * @name Phaser.Physics.Matter.Components.Gravity * @since 3.0.0 @@ -13,12 +13,12 @@ var Gravity = { /** - * [description] + * A togglable function for ignoring world gravity in real-time on the current body. * * @method Phaser.Physics.Matter.Components.Gravity#setIgnoreGravity * @since 3.0.0 * - * @param {boolean} value - [description] + * @param {boolean} value - Set to true to ignore the effect of world gravity, or false to not ignore it. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ diff --git a/src/physics/matter-js/components/Mass.js b/src/physics/matter-js/components/Mass.js index ea7378fec..f6d461864 100644 --- a/src/physics/matter-js/components/Mass.js +++ b/src/physics/matter-js/components/Mass.js @@ -8,7 +8,7 @@ var Body = require('../lib/body/Body'); var Vector2 = require('../../../math/Vector2'); /** - * [description] + * Allows accessing the mass, density, and center of mass of a Matter-enabled Game Object. Should be used as a mixin and not directly. * * @name Phaser.Physics.Matter.Components.Mass * @since 3.0.0 @@ -16,12 +16,12 @@ var Vector2 = require('../../../math/Vector2'); var Mass = { /** - * [description] + * Sets the mass of the Game Object's Matter Body. * * @method Phaser.Physics.Matter.Components.Mass#setMass * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The new mass of the body. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -33,12 +33,12 @@ var Mass = { }, /** - * [description] + * Sets density of the body. * * @method Phaser.Physics.Matter.Components.Mass#setDensity * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The new density of the body. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -53,7 +53,7 @@ var Mass = { * The body's center of mass. * * @name Phaser.Physics.Matter.Components.Mass#centerOfMass - * @readOnly + * @readonly * @since 3.10.0 * * @return {Phaser.Math.Vector2} The center of mass. diff --git a/src/physics/matter-js/components/SetBody.js b/src/physics/matter-js/components/SetBody.js index 39f2c66fa..c9ff710ba 100644 --- a/src/physics/matter-js/components/SetBody.js +++ b/src/physics/matter-js/components/SetBody.js @@ -8,6 +8,7 @@ var Bodies = require('../lib/factory/Bodies'); var Body = require('../lib/body/Body'); var GetFastValue = require('../../../utils/object/GetFastValue'); var PhysicsEditorParser = require('../PhysicsEditorParser'); +var Vertices = require('../lib/geometry/Vertices'); /** * [description] @@ -20,13 +21,13 @@ var SetBody = { // Calling any of these methods resets previous properties you may have set on the body, including plugins, mass, etc /** - * [description] + * Set the body on a Game Object to a rectangle. * * @method Phaser.Physics.Matter.Components.SetBody#setRectangle * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} width - Width of the rectangle. + * @param {number} height - Height of the rectangle. * @param {object} options - [description] * * @return {Phaser.GameObjects.GameObject} This Game Object. @@ -53,14 +54,14 @@ var SetBody = { }, /** - * [description] + * Set the body on the Game Object to a polygon shape. * * @method Phaser.Physics.Matter.Components.SetBody#setPolygon * @since 3.0.0 * - * @param {number} radius - [description] - * @param {number} sides - [description] - * @param {object} options - [description] + * @param {number} radius - The radius of the polygon. + * @param {number} sides - The amount of sides creating the polygon. + * @param {object} options - A matterjs config object. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -70,15 +71,15 @@ var SetBody = { }, /** - * [description] + * Creates a new matterjs trapezoid body. * * @method Phaser.Physics.Matter.Components.SetBody#setTrapezoid * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} slope - [description] - * @param {object} options - [description] + * @param {number} width - The width of the trapezoid. + * @param {number} height - The height of the trapezoid. + * @param {number} slope - The angle of slope for the trapezoid. + * @param {object} options - A matterjs config object for the body. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -111,7 +112,11 @@ var SetBody = { } this.body = body; - this.body.gameObject = this; + + for (var i = 0; i < body.parts.length; i++) + { + body.parts[i].gameObject = this; + } var _this = this; @@ -186,26 +191,39 @@ var SetBody = { case 'polygon': var sides = GetFastValue(config, 'sides', 5); - var pradius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); - body = Bodies.polygon(bodyX, bodyY, sides, pradius, options); + var pRadius = GetFastValue(config, 'radius', Math.max(bodyWidth, bodyHeight) / 2); + body = Bodies.polygon(bodyX, bodyY, sides, pRadius, options); break; case 'fromVertices': case 'fromVerts': - var verts = GetFastValue(config, 'verts', []); - if (this.body) + var verts = GetFastValue(config, 'verts', null); + + if (verts) { - Body.setVertices(this.body, verts); - body = this.body; - } - else - { - var flagInternal = GetFastValue(config, 'flagInternal', false); - var removeCollinear = GetFastValue(config, 'removeCollinear', 0.01); - var minimumArea = GetFastValue(config, 'minimumArea', 10); - body = Bodies.fromVertices(bodyX, bodyY, verts, options, flagInternal, removeCollinear, minimumArea); + // Has the verts array come from Vertices.fromPath, or is it raw? + if (typeof verts === 'string') + { + verts = Vertices.fromPath(verts); + } + + if (this.body && !this.body.hasOwnProperty('temp')) + { + Body.setVertices(this.body, verts); + + body = this.body; + } + else + { + var flagInternal = GetFastValue(config, 'flagInternal', false); + var removeCollinear = GetFastValue(config, 'removeCollinear', 0.01); + var minimumArea = GetFastValue(config, 'minimumArea', 10); + + body = Bodies.fromVertices(bodyX, bodyY, verts, options, flagInternal, removeCollinear, minimumArea); + } } + break; case 'fromPhysicsEditor': @@ -213,7 +231,10 @@ var SetBody = { break; } - this.setExistingBody(body, config.addToWorld); + if (body) + { + this.setExistingBody(body, config.addToWorld); + } return this; } diff --git a/src/physics/matter-js/components/Transform.js b/src/physics/matter-js/components/Transform.js index 457fd0ce4..c87159e8a 100644 --- a/src/physics/matter-js/components/Transform.js +++ b/src/physics/matter-js/components/Transform.js @@ -15,7 +15,7 @@ var _FLAG = 4; // 0100 // Transform Component /** - * [description] + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. * * @name Phaser.Physics.Matter.Components.Transform * @since 3.0.0 @@ -23,7 +23,7 @@ var _FLAG = 4; // 0100 var Transform = { /** - * [description] + * The x position of this Game Object. * * @name Phaser.Physics.Matter.Components.Transform#x * @type {number} @@ -46,7 +46,7 @@ var Transform = { }, /** - * [description] + * The y position of this Game Object. * * @name Phaser.Physics.Matter.Components.Transform#y * @type {number} @@ -69,7 +69,7 @@ var Transform = { }, /** - * [description] + * The horizontal scale of this Game Object. * * @name Phaser.Physics.Matter.Components.Transform#scaleX * @type {number} @@ -84,6 +84,9 @@ var Transform = { set: function (value) { + var factorX = 1 / this._scaleX; + var factorY = 1 / this._scaleY; + this._scaleX = value; if (this._scaleX === 0) @@ -95,13 +98,16 @@ var Transform = { this.renderFlags |= _FLAG; } + // Reset Matter scale back to 1 (sigh) + Body.scale(this.body, factorX, factorY); + Body.scale(this.body, value, this._scaleY); } }, /** - * [description] + * The vertical scale of this Game Object. * * @name Phaser.Physics.Matter.Components.Transform#scaleY * @type {number} @@ -116,6 +122,9 @@ var Transform = { set: function (value) { + var factorX = 1 / this._scaleX; + var factorY = 1 / this._scaleY; + this._scaleY = value; if (this._scaleY === 0) @@ -127,13 +136,15 @@ var Transform = { this.renderFlags |= _FLAG; } + Body.scale(this.body, factorX, factorY); + Body.scale(this.body, this._scaleX, value); } }, /** - * [description] + * Use `angle` to set or get rotation of the physics body associated to this GameObject. Unlike rotation, when using set the value can be in degrees, which will be converted to radians internally. * * @name Phaser.Physics.Matter.Components.Transform#angle * @type {number} @@ -154,7 +165,7 @@ var Transform = { }, /** - * [description] + * Use `rotation` to set or get the rotation of the physics body associated with this GameObject. The value when set must be in radians. * * @name Phaser.Physics.Matter.Components.Transform#rotation * @type {number} @@ -177,15 +188,15 @@ var Transform = { }, /** - * [description] + * Sets the position of the physics body along x and y axes. Both the parameters to this function are optional and if not passed any they default to 0. * * @method Phaser.Physics.Matter.Components.Transform#setPosition * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=x] - [description] + * @param {number} [x=0] - The horizontal position of the body. + * @param {number} [y=x] - The vertical position of the body. * - * @return{Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setPosition: function (x, y) { @@ -207,7 +218,7 @@ var Transform = { * * @param {number} [radians=0] - [description] * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setRotation: function (radians) { @@ -226,7 +237,7 @@ var Transform = { * @method Phaser.Physics.Matter.Components.Transform#setFixedRotation * @since 3.0.0 * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setFixedRotation: function () { @@ -243,7 +254,7 @@ var Transform = { * * @param {number} [degrees=0] - [description] * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setAngle: function (degrees) { @@ -257,25 +268,30 @@ var Transform = { }, /** - * [description] + * Sets the scale of this Game Object. * * @method Phaser.Physics.Matter.Components.Transform#setScale * @since 3.0.0 * - * @param {number} [x=1] - [description] - * @param {number} [y=x] - [description] - * @param {Phaser.Math.Vector2} [point] - [description] + * @param {number} [x=1] - The horizontal scale of this Game Object. + * @param {number} [y=x] - The vertical scale of this Game Object. If not set it will use the x value. + * @param {Phaser.Math.Vector2} [point] - The point (Vector2) from which scaling will occur. * - * @return {Phaser.GameObjects.GameObject} This Game Object. + * @return {this} This Game Object. */ setScale: function (x, y, point) { if (x === undefined) { x = 1; } if (y === undefined) { y = x; } + var factorX = 1 / this._scaleX; + var factorY = 1 / this._scaleY; + this._scaleX = x; this._scaleY = y; + Body.scale(this.body, factorX, factorY, point); + Body.scale(this.body, x, y, point); return this; diff --git a/src/physics/matter-js/components/Velocity.js b/src/physics/matter-js/components/Velocity.js index 840d439a8..1072ed9c5 100644 --- a/src/physics/matter-js/components/Velocity.js +++ b/src/physics/matter-js/components/Velocity.js @@ -32,12 +32,12 @@ var Velocity = { }, /** - * [description] + * Sets the horizontal velocity of the physics body. * * @method Phaser.Physics.Matter.Components.Velocity#setVelocityX * @since 3.0.0 * - * @param {number} x - [description] + * @param {number} x - The horizontal velocity value. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -51,12 +51,12 @@ var Velocity = { }, /** - * [description] + * Sets vertical velocity of the physics body. * * @method Phaser.Physics.Matter.Components.Velocity#setVelocityY * @since 3.0.0 * - * @param {number} y - [description] + * @param {number} y - The vertical velocity value. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ @@ -70,13 +70,13 @@ var Velocity = { }, /** - * [description] + * Sets both the horizontal and vertical velocity of the physics body. * * @method Phaser.Physics.Matter.Components.Velocity#setVelocity * @since 3.0.0 * - * @param {number} x - [description] - * @param {number} [y=x] - [description] + * @param {number} x - The horizontal velocity value. + * @param {number} [y=x] - The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the `x` value. * * @return {Phaser.GameObjects.GameObject} This Game Object. */ diff --git a/src/physics/matter-js/index.js b/src/physics/matter-js/index.js index 8f132e976..19aeb7949 100644 --- a/src/physics/matter-js/index.js +++ b/src/physics/matter-js/index.js @@ -72,3 +72,12 @@ module.exports = { * * @class MatterJS.Engine */ + +/** + * @classdesc +* The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. +* A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. +* A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). +* +* @class MatterJS.Vertices +*/ diff --git a/src/physics/matter-js/lib/body/Body.js b/src/physics/matter-js/lib/body/Body.js index 21362eb03..66fced681 100644 --- a/src/physics/matter-js/lib/body/Body.js +++ b/src/physics/matter-js/lib/body/Body.js @@ -184,11 +184,11 @@ var Axes = require('../geometry/Axes'); * Prefer to use the actual setter functions in performance critical situations. * @method set * @param {body} body - * @param {object} settings A map of properties and values to set on the body. + * @param {} settings A property name (or map of properties and values) to set on the body. + * @param {} value The value to set if `settings` is a single property name. */ - Body.set = function(body, settings) { - var property, - value; + Body.set = function(body, settings, value) { + var property; if (typeof settings === 'string') { property = settings; @@ -417,7 +417,7 @@ var Axes = require('../geometry/Axes'); } // sum the properties of all compound parts of the parent body - var total = _totalProperties(body); + var total = Body._totalProperties(body); body.area = total.area; body.parent = body; @@ -543,35 +543,50 @@ var Axes = require('../geometry/Axes'); * @param {vector} [point] */ Body.scale = function(body, scaleX, scaleY, point) { + var totalArea = 0, + totalInertia = 0; + point = point || body.position; for (var i = 0; i < body.parts.length; i++) { var part = body.parts[i]; - // scale position - part.position.x = point.x + (part.position.x - point.x) * scaleX; - part.position.y = point.y + (part.position.y - point.y) * scaleY; - // scale vertices Vertices.scale(part.vertices, scaleX, scaleY, point); // update properties part.axes = Axes.fromVertices(part.vertices); + part.area = Vertices.area(part.vertices); + Body.setMass(part, body.density * part.area); - if (!body.isStatic) { - part.area = Vertices.area(part.vertices); - Body.setMass(part, body.density * part.area); + // update inertia (requires vertices to be at origin) + Vertices.translate(part.vertices, { x: -part.position.x, y: -part.position.y }); + Body.setInertia(part, Body._inertiaScale * Vertices.inertia(part.vertices, part.mass)); + Vertices.translate(part.vertices, { x: part.position.x, y: part.position.y }); - // update inertia (requires vertices to be at origin) - Vertices.translate(part.vertices, { x: -part.position.x, y: -part.position.y }); - Body.setInertia(part, Vertices.inertia(part.vertices, part.mass)); - Vertices.translate(part.vertices, { x: part.position.x, y: part.position.y }); + if (i > 0) { + totalArea += part.area; + totalInertia += part.inertia; } + // scale position + part.position.x = point.x + (part.position.x - point.x) * scaleX; + part.position.y = point.y + (part.position.y - point.y) * scaleY; + // update bounds Bounds.update(part.bounds, part.vertices, body.velocity); } + // handle parent body + if (body.parts.length > 1) { + body.area = totalArea; + + if (!body.isStatic) { + Body.setMass(body, body.density * totalArea); + Body.setInertia(body, totalInertia); + } + } + // handle circles if (body.circleRadius) { if (scaleX === scaleY) { @@ -581,13 +596,6 @@ var Axes = require('../geometry/Axes'); body.circleRadius = null; } } - - if (!body.isStatic) { - var total = _totalProperties(body); - body.area = total.area; - Body.setMass(body, total.mass); - Body.setInertia(body, total.inertia); - } }; /** @@ -668,7 +676,7 @@ var Axes = require('../geometry/Axes'); * @param {body} body * @return {} */ - var _totalProperties = function(body) { + Body._totalProperties = function(body) { // from equations at: // https://ecourses.ou.edu/cgi-bin/ebook.cgi?doc=&topic=st&chap_sec=07.2&page=theory // http://output.to/sideway/default.asp?qno=121100087 @@ -685,7 +693,7 @@ var Axes = require('../geometry/Axes'); var part = body.parts[i], mass = part.mass !== Infinity ? part.mass : 1; - properties.mass += part.mass; + properties.mass += mass; properties.area += part.area; properties.inertia += part.inertia; properties.centre = Vector.add(properties.centre, Vector.mult(part.position, mass)); diff --git a/src/physics/matter-js/lib/body/Composite.js b/src/physics/matter-js/lib/body/Composite.js index b46d65e19..878748f6f 100644 --- a/src/physics/matter-js/lib/body/Composite.js +++ b/src/physics/matter-js/lib/body/Composite.js @@ -15,6 +15,7 @@ module.exports = Composite; var Events = require('../core/Events'); var Common = require('../core/Common'); +var Bounds = require('../geometry/Bounds'); var Body = require('./Body'); (function() { @@ -539,7 +540,7 @@ var Body = require('./Body'); * @returns {bounds} The composite bounds. */ Composite.bounds = function(composite) { - var bodies = Matter.Composite.allBodies(composite), + var bodies = Composite.allBodies(composite), vertices = []; for (var i = 0; i < bodies.length; i += 1) { @@ -547,7 +548,7 @@ var Body = require('./Body'); vertices.push(body.bounds.min, body.bounds.max); } - return Matter.Bounds.create(vertices); + return Bounds.create(vertices); }; /* diff --git a/src/physics/matter-js/lib/body/World.js b/src/physics/matter-js/lib/body/World.js index 0cd31715c..8a4cbcec7 100644 --- a/src/physics/matter-js/lib/body/World.js +++ b/src/physics/matter-js/lib/body/World.js @@ -96,6 +96,23 @@ var Common = require('../core/Common'); // World is a Composite body // see src/module/Outro.js for these aliases: + /** + * An alias for Composite.add + * @method add + * @param {world} world + * @param {} object + * @return {composite} The original world with the objects added + */ + + /** + * An alias for Composite.remove + * @method remove + * @param {world} world + * @param {} object + * @param {boolean} [deep=false] + * @return {composite} The original world with the objects removed + */ + /** * An alias for Composite.clear * @method clear @@ -104,7 +121,7 @@ var Common = require('../core/Common'); */ /** - * An alias for Composite.add + * An alias for Composite.addComposite * @method addComposite * @param {world} world * @param {composite} composite diff --git a/src/physics/matter-js/lib/collision/Grid.js b/src/physics/matter-js/lib/collision/Grid.js index 7e1066fd6..4acff1ef3 100644 --- a/src/physics/matter-js/lib/collision/Grid.js +++ b/src/physics/matter-js/lib/collision/Grid.js @@ -82,7 +82,7 @@ var Common = require('../core/Common'); || body.bounds.max.y < world.bounds.min.y || body.bounds.min.y > world.bounds.max.y) continue; - var newRegion = _getRegion(grid, body); + var newRegion = Grid._getRegion(grid, body); // if the body has changed grid region if (!body.region || newRegion.id !== body.region.id || forceUpdate) { @@ -94,13 +94,13 @@ var Common = require('../core/Common'); if (!body.region || forceUpdate) body.region = newRegion; - var union = _regionUnion(newRegion, body.region); + var union = Grid._regionUnion(newRegion, body.region); // update grid buckets affected by region change // iterate over the union of both regions for (col = union.startCol; col <= union.endCol; col++) { for (row = union.startRow; row <= union.endRow; row++) { - bucketId = _getBucketId(col, row); + bucketId = Grid._getBucketId(col, row); bucket = buckets[bucketId]; var isInsideNewRegion = (col >= newRegion.startCol && col <= newRegion.endCol @@ -113,15 +113,15 @@ var Common = require('../core/Common'); if (!isInsideNewRegion && isInsideOldRegion) { if (isInsideOldRegion) { if (bucket) - _bucketRemoveBody(grid, bucket, body); + Grid._bucketRemoveBody(grid, bucket, body); } } // add to new region buckets if (body.region === newRegion || (isInsideNewRegion && !isInsideOldRegion) || forceUpdate) { if (!bucket) - bucket = _createBucket(buckets, bucketId); - _bucketAddBody(grid, bucket, body); + bucket = Grid._createBucket(buckets, bucketId); + Grid._bucketAddBody(grid, bucket, body); } } } @@ -136,7 +136,7 @@ var Common = require('../core/Common'); // update pairs list only if pairs changed (i.e. a body changed region) if (gridChanged) - grid.pairsList = _createActivePairsList(grid); + grid.pairsList = Grid._createActivePairsList(grid); }; /** @@ -158,13 +158,13 @@ var Common = require('../core/Common'); * @param {} regionB * @return {} region */ - var _regionUnion = function(regionA, regionB) { + Grid._regionUnion = function(regionA, regionB) { var startCol = Math.min(regionA.startCol, regionB.startCol), endCol = Math.max(regionA.endCol, regionB.endCol), startRow = Math.min(regionA.startRow, regionB.startRow), endRow = Math.max(regionA.endRow, regionB.endRow); - return _createRegion(startCol, endCol, startRow, endRow); + return Grid._createRegion(startCol, endCol, startRow, endRow); }; /** @@ -175,14 +175,14 @@ var Common = require('../core/Common'); * @param {} body * @return {} region */ - var _getRegion = function(grid, body) { + Grid._getRegion = function(grid, body) { var bounds = body.bounds, startCol = Math.floor(bounds.min.x / grid.bucketWidth), endCol = Math.floor(bounds.max.x / grid.bucketWidth), startRow = Math.floor(bounds.min.y / grid.bucketHeight), endRow = Math.floor(bounds.max.y / grid.bucketHeight); - return _createRegion(startCol, endCol, startRow, endRow); + return Grid._createRegion(startCol, endCol, startRow, endRow); }; /** @@ -195,7 +195,7 @@ var Common = require('../core/Common'); * @param {} endRow * @return {} region */ - var _createRegion = function(startCol, endCol, startRow, endRow) { + Grid._createRegion = function(startCol, endCol, startRow, endRow) { return { id: startCol + ',' + endCol + ',' + startRow + ',' + endRow, startCol: startCol, @@ -213,7 +213,7 @@ var Common = require('../core/Common'); * @param {} row * @return {string} bucket id */ - var _getBucketId = function(column, row) { + Grid._getBucketId = function(column, row) { return 'C' + column + 'R' + row; }; @@ -225,7 +225,7 @@ var Common = require('../core/Common'); * @param {} bucketId * @return {} bucket */ - var _createBucket = function(buckets, bucketId) { + Grid._createBucket = function(buckets, bucketId) { var bucket = buckets[bucketId] = []; return bucket; }; @@ -238,7 +238,7 @@ var Common = require('../core/Common'); * @param {} bucket * @param {} body */ - var _bucketAddBody = function(grid, bucket, body) { + Grid._bucketAddBody = function(grid, bucket, body) { // add new pairs for (var i = 0; i < bucket.length; i++) { var bodyB = bucket[i]; @@ -270,9 +270,9 @@ var Common = require('../core/Common'); * @param {} bucket * @param {} body */ - var _bucketRemoveBody = function(grid, bucket, body) { + Grid._bucketRemoveBody = function(grid, bucket, body) { // remove from bucket - bucket.splice(bucket.indexOf(body), 1); + bucket.splice(Common.indexOf(bucket, body), 1); // update pair counts for (var i = 0; i < bucket.length; i++) { @@ -294,7 +294,7 @@ var Common = require('../core/Common'); * @param {} grid * @return [] pairs */ - var _createActivePairsList = function(grid) { + Grid._createActivePairsList = function(grid) { var pairKeys, pair, pairs = []; diff --git a/src/physics/matter-js/lib/collision/Pair.js b/src/physics/matter-js/lib/collision/Pair.js index 05c9aa7aa..9f8597dbf 100644 --- a/src/physics/matter-js/lib/collision/Pair.js +++ b/src/physics/matter-js/lib/collision/Pair.js @@ -32,7 +32,6 @@ module.exports = Pair; isSensor: bodyA.isSensor || bodyB.isSensor, timeCreated: timestamp, timeUpdated: timestamp, - collision: null, inverseMass: 0, friction: 0, @@ -54,22 +53,9 @@ module.exports = Pair; * @param {number} timestamp */ Pair.update = function(pair, collision, timestamp) { - // var contacts = pair.contacts, - // supports = collision.supports, - // activeContacts = pair.activeContacts, - // parentA = collision.parentA, - // parentB = collision.parentB; - pair.collision = collision; - // pair.inverseMass = parentA.inverseMass + parentB.inverseMass; - // pair.friction = Math.min(parentA.friction, parentB.friction); - // pair.frictionStatic = Math.max(parentA.frictionStatic, parentB.frictionStatic); - // pair.restitution = Math.max(parentA.restitution, parentB.restitution); - // pair.slop = Math.max(parentA.slop, parentB.slop); - // activeContacts.length = 0; - - if (collision.collided) { + if (collision.collided) { var supports = collision.supports, activeContacts = pair.activeContacts, parentA = collision.parentA, @@ -85,8 +71,8 @@ module.exports = Pair; activeContacts[i] = supports[i].contact; } + // optimise array size var supportCount = supports.length; - if (supportCount < activeContacts.length) { activeContacts.length = supportCount; } diff --git a/src/physics/matter-js/lib/collision/Pairs.js b/src/physics/matter-js/lib/collision/Pairs.js index 83a899137..b17904b28 100644 --- a/src/physics/matter-js/lib/collision/Pairs.js +++ b/src/physics/matter-js/lib/collision/Pairs.js @@ -13,7 +13,7 @@ var Common = require('../core/Common'); (function() { - var _pairMaxIdleLife = 1000; + Pairs._pairMaxIdleLife = 1000; /** * Creates a new pairs structure. @@ -94,7 +94,7 @@ var Common = require('../core/Common'); // deactivate previously active pairs that are now inactive for (i = 0; i < pairsList.length; i++) { pair = pairsList[i]; - if (!pair.confirmedActive) { + if (pair.isActive && !pair.confirmedActive) { Pair.setActive(pair, false, timestamp); collisionEnd.push(pair); } @@ -127,7 +127,7 @@ var Common = require('../core/Common'); } // if pair is inactive for too long, mark it to be removed - if (timestamp - pair.timeUpdated > _pairMaxIdleLife) { + if (timestamp - pair.timeUpdated > Pairs._pairMaxIdleLife) { indexesToRemove.push(i); } } diff --git a/src/physics/matter-js/lib/collision/Query.js b/src/physics/matter-js/lib/collision/Query.js index 0b99e9d91..7166478a1 100644 --- a/src/physics/matter-js/lib/collision/Query.js +++ b/src/physics/matter-js/lib/collision/Query.js @@ -18,6 +18,38 @@ var Vertices = require('../geometry/Vertices'); (function() { + /** + * Returns a list of collisions between `body` and `bodies`. + * @method collides + * @param {body} body + * @param {body[]} bodies + * @return {object[]} Collisions + */ + Query.collides = function(body, bodies) { + var collisions = []; + + for (var i = 0; i < bodies.length; i++) { + var bodyA = bodies[i]; + + if (Bounds.overlaps(bodyA.bounds, body.bounds)) { + for (var j = bodyA.parts.length === 1 ? 0 : 1; j < bodyA.parts.length; j++) { + var part = bodyA.parts[j]; + + if (Bounds.overlaps(part.bounds, body.bounds)) { + var collision = SAT.collides(part, body); + + if (collision.collided) { + collisions.push(collision); + break; + } + } + } + } + } + + return collisions; + }; + /** * Casts a ray segment against a set of bodies and returns all collisions, ray width is optional. Intersection points are not provided. * @method ray @@ -35,25 +67,11 @@ var Vertices = require('../geometry/Vertices'); rayX = (endPoint.x + startPoint.x) * 0.5, rayY = (endPoint.y + startPoint.y) * 0.5, ray = Bodies.rectangle(rayX, rayY, rayLength, rayWidth, { angle: rayAngle }), - collisions = []; + collisions = Query.collides(ray, bodies); - for (var i = 0; i < bodies.length; i++) { - var bodyA = bodies[i]; - - if (Bounds.overlaps(bodyA.bounds, ray.bounds)) { - for (var j = bodyA.parts.length === 1 ? 0 : 1; j < bodyA.parts.length; j++) { - var part = bodyA.parts[j]; - - if (Bounds.overlaps(part.bounds, ray.bounds)) { - var collision = SAT.collides(part, ray); - if (collision.collided) { - collision.body = collision.bodyA = collision.bodyB = bodyA; - collisions.push(collision); - break; - } - } - } - } + for (var i = 0; i < collisions.length; i += 1) { + var collision = collisions[i]; + collision.body = collision.bodyB = collision.bodyA; } return collisions; diff --git a/src/physics/matter-js/lib/collision/Resolver.js b/src/physics/matter-js/lib/collision/Resolver.js index 4cf788535..4b4cf507e 100644 --- a/src/physics/matter-js/lib/collision/Resolver.js +++ b/src/physics/matter-js/lib/collision/Resolver.js @@ -48,6 +48,7 @@ var Bounds = require('../geometry/Bounds'); * Find a solution for pair positions. * @method solvePosition * @param {pair[]} pairs + * @param {body[]} bodies * @param {number} timeScale */ Resolver.solvePosition = function(pairs, bodies, timeScale) { @@ -67,7 +68,7 @@ var Bounds = require('../geometry/Bounds'); bodyBtoAX, bodyBtoAY, positionImpulse, - impulseCoefficient = timeScale * Resolver._positionDampen; + impulseCoefficient = timeScale * Resolver._positionDampen; for (i = 0; i < bodies.length; i++) { var body = bodies[i]; @@ -92,14 +93,12 @@ var Bounds = require('../geometry/Bounds'); penetration = collision.penetration; - // bodyBtoA = positionImpulseB - positionImpulseA + penetration bodyBtoAX = positionImpulseB.x - positionImpulseA.x + penetration.x; bodyBtoAY = positionImpulseB.y - positionImpulseA.y + penetration.y; normalX = normal.x; normalY = normal.y; - // separation = dot(normal, bodyBtoA) separation = normalX * bodyBtoAX + normalY * bodyBtoAY; pair.separation = separation; diff --git a/src/physics/matter-js/lib/collision/SAT.js b/src/physics/matter-js/lib/collision/SAT.js index 5c3d6694b..29a58c357 100644 --- a/src/physics/matter-js/lib/collision/SAT.js +++ b/src/physics/matter-js/lib/collision/SAT.js @@ -54,7 +54,7 @@ var Vector = require('../geometry/Vector'); axisBodyB = axisBodyA === bodyA ? bodyB : bodyA, axes = [axisBodyA.axes[previousCollision.axisNumber]]; - minOverlap = _overlapAxes(axisBodyA.vertices, axisBodyB.vertices, axes); + minOverlap = SAT._overlapAxes(axisBodyA.vertices, axisBodyB.vertices, axes); collision.reused = true; if (minOverlap.overlap <= 0) { @@ -64,14 +64,14 @@ var Vector = require('../geometry/Vector'); } else { // if we can't reuse a result, perform a full SAT test - overlapAB = _overlapAxes(bodyA.vertices, bodyB.vertices, bodyA.axes); + overlapAB = SAT._overlapAxes(bodyA.vertices, bodyB.vertices, bodyA.axes); if (overlapAB.overlap <= 0) { collision.collided = false; return collision; } - overlapBA = _overlapAxes(bodyB.vertices, bodyA.vertices, bodyB.axes); + overlapBA = SAT._overlapAxes(bodyB.vertices, bodyA.vertices, bodyB.axes); if (overlapBA.overlap <= 0) { collision.collided = false; @@ -120,7 +120,7 @@ var Vector = require('../geometry/Vector'); collision.penetration.y = collision.normal.y * collision.depth; // find support points, there is always either exactly one or two - var verticesB = _findSupports(bodyA, bodyB, collision.normal), + var verticesB = SAT._findSupports(bodyA, bodyB, collision.normal), supports = []; // find the supports from bodyB that are inside bodyA @@ -132,7 +132,7 @@ var Vector = require('../geometry/Vector'); // find the supports from bodyA that are inside bodyB if (supports.length < 2) { - var verticesA = _findSupports(bodyB, bodyA, Vector.neg(collision.normal)); + var verticesA = SAT._findSupports(bodyB, bodyA, Vector.neg(collision.normal)); if (Vertices.contains(bodyB.vertices, verticesA[0])) supports.push(verticesA[0]); @@ -159,7 +159,7 @@ var Vector = require('../geometry/Vector'); * @param {} axes * @return result */ - var _overlapAxes = function(verticesA, verticesB, axes) { + SAT._overlapAxes = function(verticesA, verticesB, axes) { var projectionA = Vector._temp[0], projectionB = Vector._temp[1], result = { overlap: Number.MAX_VALUE }, @@ -169,8 +169,8 @@ var Vector = require('../geometry/Vector'); for (var i = 0; i < axes.length; i++) { axis = axes[i]; - _projectToAxis(projectionA, verticesA, axis); - _projectToAxis(projectionB, verticesB, axis); + SAT._projectToAxis(projectionA, verticesA, axis); + SAT._projectToAxis(projectionB, verticesB, axis); overlap = Math.min(projectionA.max - projectionB.min, projectionB.max - projectionA.min); @@ -197,7 +197,7 @@ var Vector = require('../geometry/Vector'); * @param {} vertices * @param {} axis */ - var _projectToAxis = function(projection, vertices, axis) { + SAT._projectToAxis = function(projection, vertices, axis) { var min = Vector.dot(vertices[0], axis), max = min; @@ -224,7 +224,7 @@ var Vector = require('../geometry/Vector'); * @param {} normal * @return [vector] */ - var _findSupports = function(bodyA, bodyB, normal) { + SAT._findSupports = function(bodyA, bodyB, normal) { var nearestDistance = Number.MAX_VALUE, vertexToBody = Vector._temp[0], vertices = bodyB.vertices, diff --git a/src/physics/matter-js/lib/constraint/Constraint.js b/src/physics/matter-js/lib/constraint/Constraint.js index 2e5d596ae..9e49f16af 100644 --- a/src/physics/matter-js/lib/constraint/Constraint.js +++ b/src/physics/matter-js/lib/constraint/Constraint.js @@ -30,6 +30,7 @@ var Common = require('../core/Common'); * All properties have default values, and many are pre-calculated automatically based on other properties. * To simulate a revolute constraint (or pin joint) set `length: 0` and a high `stiffness` value (e.g. `0.7` or above). * If the constraint is unstable, try lowering the `stiffness` value and / or increasing `engine.constraintIterations`. + * For compound bodies, constraints must be applied to the parent body (not one of its parts). * See the properties section below for detailed information on what you can pass via the `options` object. * @method create * @param {} options @@ -405,7 +406,7 @@ var Common = require('../core/Common'); */ /** - * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position. + * A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyB` if defined, otherwise a world-space position. * * @property pointB * @type vector diff --git a/src/physics/matter-js/lib/constraint/MouseConstraint.js b/src/physics/matter-js/lib/constraint/MouseConstraint.js index fa1734aff..4dc55610e 100644 --- a/src/physics/matter-js/lib/constraint/MouseConstraint.js +++ b/src/physics/matter-js/lib/constraint/MouseConstraint.js @@ -77,7 +77,7 @@ var Bounds = require('../geometry/Bounds'); Events.on(engine, 'beforeUpdate', function() { var allBodies = Composite.allBodies(engine.world); MouseConstraint.update(mouseConstraint, allBodies); - _triggerEvents(mouseConstraint); + MouseConstraint._triggerEvents(mouseConstraint); }); return mouseConstraint; @@ -136,7 +136,7 @@ var Bounds = require('../geometry/Bounds'); * @private * @param {mouse} mouseConstraint */ - var _triggerEvents = function(mouseConstraint) { + MouseConstraint._triggerEvents = function(mouseConstraint) { var mouse = mouseConstraint.mouse, mouseEvents = mouse.sourceEvents; diff --git a/src/physics/matter-js/lib/core/Common.js b/src/physics/matter-js/lib/core/Common.js index 1086e7065..7be5a6060 100644 --- a/src/physics/matter-js/lib/core/Common.js +++ b/src/physics/matter-js/lib/core/Common.js @@ -177,7 +177,11 @@ module.exports = Common; * @return {boolean} True if the object is a HTMLElement, otherwise false */ Common.isElement = function(obj) { - return obj instanceof HTMLElement; + if (typeof HTMLElement !== 'undefined') { + return obj instanceof HTMLElement; + } + + return !!(obj && obj.nodeType && obj.nodeName); }; /** @@ -217,7 +221,7 @@ module.exports = Common; * @return {boolean} True if the object is a string, otherwise false */ Common.isString = function(obj) { - return Object.prototype.toString.call(obj) === '[object String]'; + return toString.call(obj) === '[object String]'; }; /** @@ -369,6 +373,7 @@ module.exports = Common; * @param {array} haystack * @param {object} needle * @return {number} The position of needle in haystack, otherwise -1. + */ Common.indexOf = function(haystack, needle) { if (haystack.indexOf) return haystack.indexOf(needle); @@ -380,7 +385,6 @@ module.exports = Common; return -1; }; - */ /** * A cross browser compatible array map implementation. @@ -420,14 +424,14 @@ module.exports = Common; for (var node in graph) { if (!visited[node] && !temp[node]) { - _topologicalSort(node, visited, temp, graph, result); + Common._topologicalSort(node, visited, temp, graph, result); } } return result; }; - var _topologicalSort = function(node, visited, temp, graph, result) { + Common._topologicalSort = function(node, visited, temp, graph, result) { var neighbors = graph[node] || []; temp[node] = true; @@ -440,7 +444,7 @@ module.exports = Common; } if (!visited[neighbor]) { - _topologicalSort(neighbor, visited, temp, graph, result); + Common._topologicalSort(neighbor, visited, temp, graph, result); } } @@ -532,4 +536,22 @@ module.exports = Common; )); }; + /** + * Used to require external libraries outside of the bundle. + * It first looks for the `globalName` on the environment's global namespace. + * If the global is not found, it will fall back to using the standard `require` using the `moduleName`. + * @private + * @method _requireGlobal + * @param {string} globalName The global module name + * @param {string} moduleName The fallback CommonJS module name + * @return {} The loaded module + */ + Common._requireGlobal = function(globalName, moduleName) { + var obj = (typeof window !== 'undefined' ? window[globalName] : typeof global !== 'undefined' ? global[globalName] : null); + + // Breaks webpack :( + // return obj || require(moduleName); + + return obj; + }; })(); diff --git a/src/physics/matter-js/lib/core/Engine.js b/src/physics/matter-js/lib/core/Engine.js index 52928571b..b0f5caca8 100644 --- a/src/physics/matter-js/lib/core/Engine.js +++ b/src/physics/matter-js/lib/core/Engine.js @@ -62,7 +62,6 @@ var Body = require('../body/Body'); var engine = Common.extend(defaults, options); - /* // @deprecated if (element || engine.render) { var renderDefaults = { @@ -82,7 +81,6 @@ var Body = require('../body/Body'); if (engine.render) { engine.render.engine = engine; } - */ engine.world = options.world || World.create(engine.world); engine.pairs = Pairs.create(); @@ -145,10 +143,10 @@ var Body = require('../body/Body'); Sleeping.update(allBodies, timing.timeScale); // applies gravity to all bodies - _bodiesApplyGravity(allBodies, world.gravity); + Engine._bodiesApplyGravity(allBodies, world.gravity); // update all body position and rotation by integration - _bodiesUpdate(allBodies, delta, timing.timeScale, correction, world.bounds); + Engine._bodiesUpdate(allBodies, delta, timing.timeScale, correction, world.bounds); // update all constraints (first pass) Constraint.preSolveAll(allBodies); @@ -226,7 +224,7 @@ var Body = require('../body/Body'); // @endif // clear force buffers - _bodiesClearForces(allBodies); + Engine._bodiesClearForces(allBodies); Events.trigger(engine, 'afterUpdate', event); @@ -277,11 +275,11 @@ var Body = require('../body/Body'); /** * Zeroes the `body.force` and `body.torque` force buffers. - * @method bodiesClearForces + * @method _bodiesClearForces * @private * @param {body[]} bodies */ - var _bodiesClearForces = function(bodies) { + Engine._bodiesClearForces = function(bodies) { for (var i = 0; i < bodies.length; i++) { var body = bodies[i]; @@ -294,12 +292,12 @@ var Body = require('../body/Body'); /** * Applys a mass dependant force to all given bodies. - * @method bodiesApplyGravity + * @method _bodiesApplyGravity * @private * @param {body[]} bodies * @param {vector} gravity */ - var _bodiesApplyGravity = function(bodies, gravity) { + Engine._bodiesApplyGravity = function(bodies, gravity) { var gravityScale = typeof gravity.scale !== 'undefined' ? gravity.scale : 0.001; if ((gravity.x === 0 && gravity.y === 0) || gravityScale === 0) { @@ -320,7 +318,7 @@ var Body = require('../body/Body'); /** * Applys `Body.update` to all given `bodies`. - * @method updateAll + * @method _bodiesUpdate * @private * @param {body[]} bodies * @param {number} deltaTime @@ -330,7 +328,7 @@ var Body = require('../body/Body'); * The Verlet correction factor (deltaTime / lastDeltaTime) * @param {bounds} worldBounds */ - var _bodiesUpdate = function(bodies, deltaTime, timeScale, correction, worldBounds) { + Engine._bodiesUpdate = function(bodies, deltaTime, timeScale, correction, worldBounds) { for (var i = 0; i < bodies.length; i++) { var body = bodies[i]; diff --git a/src/physics/matter-js/lib/core/Events.js b/src/physics/matter-js/lib/core/Events.js index bf5e93693..54ee7ccba 100644 --- a/src/physics/matter-js/lib/core/Events.js +++ b/src/physics/matter-js/lib/core/Events.js @@ -84,7 +84,9 @@ var Common = require('./Common'); callbacks, eventClone; - if (object.events) { + var events = object.events; + + if (events && Common.keys(events).length > 0) { if (!event) event = {}; @@ -92,7 +94,7 @@ var Common = require('./Common'); for (var i = 0; i < names.length; i++) { name = names[i]; - callbacks = object.events[name]; + callbacks = events[name]; if (callbacks) { eventClone = Common.clone(event, false); diff --git a/src/physics/matter-js/lib/core/Matter.js b/src/physics/matter-js/lib/core/Matter.js index d86268fab..6c139aa61 100644 --- a/src/physics/matter-js/lib/core/Matter.js +++ b/src/physics/matter-js/lib/core/Matter.js @@ -27,7 +27,7 @@ var Common = require('./Common'); * @readOnly * @type {String} */ - Matter.version = '0.13.1'; + Matter.version = '0.14.2'; /** * A list of plugin dependencies to be installed. These are normally set and installed through `Matter.use`. diff --git a/src/physics/matter-js/lib/geometry/Svg.js b/src/physics/matter-js/lib/geometry/Svg.js index 971d0ab78..6ed51bce4 100644 --- a/src/physics/matter-js/lib/geometry/Svg.js +++ b/src/physics/matter-js/lib/geometry/Svg.js @@ -13,6 +13,7 @@ var Svg = {}; module.exports = Svg; var Bounds = require('../geometry/Bounds'); +var Common = require('../core/Common'); (function() { @@ -21,12 +22,17 @@ var Bounds = require('../geometry/Bounds'); * If the input path forms a concave shape, you must decompose the result into convex parts before use. * See `Bodies.fromVertices` which provides support for this. * Note that this function is not guaranteed to support complex paths (such as those with holes). + * You must load the `pathseg.js` polyfill on newer browsers. * @method pathToVertices * @param {SVGPathElement} path * @param {Number} [sampleLength=15] * @return {Vector[]} points */ Svg.pathToVertices = function(path, sampleLength) { + if (typeof window !== 'undefined' && !('SVGPathSeg' in window)) { + Common.warn('Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.'); + } + // https://github.com/wout/svg.topoly.js/blob/master/svg.topoly.js var i, il, total, point, segment, segments, segmentsQueue, lastSegment, @@ -97,7 +103,7 @@ var Bounds = require('../geometry/Bounds'); }; // ensure path is absolute - _svgPathToAbsolute(path); + Svg._svgPathToAbsolute(path); // get total length total = path.getTotalLength(); @@ -149,7 +155,7 @@ var Bounds = require('../geometry/Bounds'); return points; }; - var _svgPathToAbsolute = function(path) { + Svg._svgPathToAbsolute = function(path) { // http://phrogz.net/convert-svg-path-to-all-absolute-commands // Copyright (c) Gavin Kistner // http://phrogz.net/js/_ReuseLicense.txt diff --git a/src/physics/matter-js/lib/geometry/Vector.js b/src/physics/matter-js/lib/geometry/Vector.js index bfc512dbb..2a8bb6414 100644 --- a/src/physics/matter-js/lib/geometry/Vector.js +++ b/src/physics/matter-js/lib/geometry/Vector.js @@ -214,7 +214,7 @@ module.exports = Vector; }; /** - * Returns the angle in radians between the two vectors relative to the x-axis. + * Returns the angle between the vector `vectorB - vectorA` and the x-axis in radians. * @method angle * @param {vector} vectorA * @param {vector} vectorB diff --git a/src/physics/matter-js/lib/geometry/Vertices.js b/src/physics/matter-js/lib/geometry/Vertices.js index 8489a14f5..ed686ffe2 100644 --- a/src/physics/matter-js/lib/geometry/Vertices.js +++ b/src/physics/matter-js/lib/geometry/Vertices.js @@ -275,16 +275,12 @@ var Common = require('../core/Common'); * @param {number} qualityMax */ Vertices.chamfer = function(vertices, radius, quality, qualityMin, qualityMax) { - if (typeof radius === 'number') { radius = [radius]; } else { radius = radius || [8]; } - if (!radius.length) - radius = [radius]; - // quality defaults to -1, which is auto quality = (typeof quality !== 'undefined') ? quality : -1; qualityMin = qualityMin || 2; diff --git a/src/physics/matter-js/poly-decomp/index.js b/src/physics/matter-js/poly-decomp/index.js index 9d6faef26..f63807b4f 100644 --- a/src/physics/matter-js/poly-decomp/index.js +++ b/src/physics/matter-js/poly-decomp/index.js @@ -1,14 +1,16 @@ /** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. + * @author Stefan Hedman (http://steffe.se) * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +// v0.3.0 + module.exports = { decomp: polygonDecomp, quickDecomp: polygonQuickDecomp, isSimple: polygonIsSimple, removeCollinearPoints: polygonRemoveCollinearPoints, + removeDuplicatePoints: polygonRemoveDuplicatePoints, makeCCW: polygonMakeCCW }; @@ -184,6 +186,9 @@ function polygonMakeCCW(polygon){ // reverse poly if clockwise if (!isLeft(polygonAt(polygon, br - 1), polygonAt(polygon, br), polygonAt(polygon, br + 1))) { polygonReverse(polygon); + return true; + } else { + return false; } } @@ -248,6 +253,27 @@ function polygonCanSee(polygon, a,b) { return true; } +/** + * Check if two vertices in the polygon can see each other + * @method canSee2 + * @param {Number} a Vertex index 1 + * @param {Number} b Vertex index 2 + * @return {Boolean} + */ +function polygonCanSee2(polygon, a,b) { + // for each edge + for (var i = 0; i !== polygon.length; ++i) { + // ignore incident edges + if (i === a || i === b || (i + 1) % polygon.length === a || (i + 1) % polygon.length === b){ + continue; + } + if( lineSegmentsIntersect(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i), polygonAt(polygon, i+1)) ){ + return false; + } + } + return true; +} + /** * Copy the polygon from vertex i to vertex j. * @method copy @@ -531,9 +557,12 @@ function polygonQuickDecomp(polygon, result,reflexVertices,steinerPoints,delta,m } for (var j = lowerIndex; j <= upperIndex; ++j) { - if (isLeftOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j))) { + if ( + isLeftOn(polygonAt(poly, i - 1), polygonAt(poly, i), polygonAt(poly, j)) && + isRightOn(polygonAt(poly, i + 1), polygonAt(poly, i), polygonAt(poly, j)) + ) { d = sqdist(polygonAt(poly, i), polygonAt(poly, j)); - if (d < closestDist) { + if (d < closestDist && polygonCanSee2(poly, i, j)) { closestDist = d; closestIndex = j % polygon.length; } @@ -590,6 +619,23 @@ function polygonRemoveCollinearPoints(polygon, precision){ return num; } +/** + * Remove duplicate points in the polygon. + * @method removeDuplicatePoints + * @param {Number} [precision] The threshold to use when determining whether two points are the same. Use zero for best precision. + */ +function polygonRemoveDuplicatePoints(polygon, precision){ + for(var i=polygon.length-1; i>=1; --i){ + var pi = polygon[i]; + for(var j=i-1; j>=0; --j){ + if(points_eq(pi, polygon[j], precision)){ + polygon.splice(i,1); + continue; + } + } + } +} + /** * Check if two scalars are equal * @static @@ -601,5 +647,18 @@ function polygonRemoveCollinearPoints(polygon, precision){ */ function scalar_eq(a,b,precision){ precision = precision || 0; - return Math.abs(a-b) < precision; + return Math.abs(a-b) <= precision; +} + +/** + * Check if two points are equal + * @static + * @method points_eq + * @param {Array} a + * @param {Array} b + * @param {Number} [precision] + * @return {Boolean} + */ +function points_eq(a,b,precision){ + return scalar_eq(a[0],b[0],precision) && scalar_eq(a[1],b[1],precision); } diff --git a/src/plugins/BasePlugin.js b/src/plugins/BasePlugin.js index a4a94d604..895f86092 100644 --- a/src/plugins/BasePlugin.js +++ b/src/plugins/BasePlugin.js @@ -12,7 +12,7 @@ var Class = require('../utils/Class'); * It can listen for Game events and respond to them. * * @class BasePlugin - * @memberOf Phaser.Plugins + * @memberof Phaser.Plugins * @constructor * @since 3.8.0 * @@ -80,6 +80,8 @@ var BasePlugin = new Class({ * * @method Phaser.Plugins.BasePlugin#init * @since 3.8.0 + * + * @param {?any} [data] - A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually). */ init: function () { diff --git a/src/plugins/DefaultPlugins.js b/src/plugins/DefaultPlugins.js index 049c0f636..01ed3904f 100644 --- a/src/plugins/DefaultPlugins.js +++ b/src/plugins/DefaultPlugins.js @@ -24,10 +24,12 @@ var DefaultPlugins = { */ Global: [ + 'game', 'anims', 'cache', 'plugins', 'registry', + 'scale', 'sound', 'textures' @@ -73,7 +75,6 @@ var DefaultPlugins = { */ DefaultScene: [ - 'CameraManager3D', 'Clock', 'DataManagerPlugin', 'InputPlugin', @@ -85,4 +86,14 @@ var DefaultPlugins = { }; +if (typeof PLUGIN_CAMERA3D) +{ + DefaultPlugins.DefaultScene.push('CameraManager3D'); +} + +if (typeof PLUGIN_FBINSTANT) +{ + DefaultPlugins.Global.push('facebook'); +} + module.exports = DefaultPlugins; diff --git a/src/plugins/PluginCache.js b/src/plugins/PluginCache.js index e5dae8877..674a51e92 100644 --- a/src/plugins/PluginCache.js +++ b/src/plugins/PluginCache.js @@ -61,10 +61,11 @@ PluginCache.register = function (key, plugin, mapping, custom) * @param {string} key - A reference used to get this plugin from the plugin cache. * @param {function} plugin - The plugin to be stored. Should be the core object, not instantiated. * @param {string} mapping - If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @param {?any} data - A value to be passed to the plugin's `init` method. */ -PluginCache.registerCustom = function (key, plugin, mapping) +PluginCache.registerCustom = function (key, plugin, mapping, data) { - customPlugins[key] = { plugin: plugin, mapping: mapping }; + customPlugins[key] = { plugin: plugin, mapping: mapping, data: data }; }; /** @@ -174,4 +175,41 @@ PluginCache.removeCustom = function (key) } }; +/** + * Removes all Core Plugins. + * + * This includes all of the internal system plugins that Phaser needs, like the Input Plugin and Loader Plugin. + * So be sure you only call this if you do not wish to run Phaser again. + * + * @method Phaser.Plugins.PluginCache.destroyCorePlugins + * @since 3.12.0 + */ +PluginCache.destroyCorePlugins = function () +{ + for (var key in corePlugins) + { + if (corePlugins.hasOwnProperty(key)) + { + delete corePlugins[key]; + } + } +}; + +/** + * Removes all Custom Plugins. + * + * @method Phaser.Plugins.PluginCache.destroyCustomPlugins + * @since 3.12.0 + */ +PluginCache.destroyCustomPlugins = function () +{ + for (var key in customPlugins) + { + if (customPlugins.hasOwnProperty(key)) + { + delete customPlugins[key]; + } + } +}; + module.exports = PluginCache; diff --git a/src/plugins/PluginManager.js b/src/plugins/PluginManager.js index 4e2aa5a95..c6d1dfb20 100644 --- a/src/plugins/PluginManager.js +++ b/src/plugins/PluginManager.js @@ -57,7 +57,7 @@ var Remove = require('../utils/array/Remove'); * For information on creating your own plugin please see the Phaser 3 Plugin Template. * * @class PluginManager - * @memberOf Phaser.Plugins + * @memberof Phaser.Plugins * @constructor * @since 3.0.0 * @@ -146,6 +146,7 @@ var PluginManager = new Class({ var plugin; var start; var mapping; + var data; var config = this.game.config; // Any plugins to install? @@ -158,16 +159,17 @@ var PluginManager = new Class({ { entry = list[i]; - // { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test' } + // { key: 'TestPlugin', plugin: TestPlugin, start: true, mapping: 'test', data: { msg: 'The plugin is alive' } } key = GetFastValue(entry, 'key', null); plugin = GetFastValue(entry, 'plugin', null); start = GetFastValue(entry, 'start', false); mapping = GetFastValue(entry, 'mapping', null); + data = GetFastValue(entry, 'data', null); if (key && plugin) { - this.install(key, plugin, start, mapping); + this.install(key, plugin, start, mapping, data); } } @@ -239,6 +241,10 @@ var PluginManager = new Class({ scene[map[pluginKey]] = sys[pluginKey]; } } + else if (pluginKey === 'game' && map.hasOwnProperty(pluginKey)) + { + scene[map[pluginKey]] = game; + } } for (var s = 0; s < scenePlugins.length; s++) @@ -399,22 +405,26 @@ var PluginManager = new Class({ * @param {function} plugin - The plugin code. This should be the non-instantiated version. * @param {boolean} [start=false] - Automatically start the plugin running? This is always `true` if you provide a mapping value. * @param {string} [mapping] - If this plugin is injected into the Phaser.Scene class, this is the property key to use. + * @param {any} [data] - A value passed to the plugin's `init` method. + * + * @return {?Phaser.Plugins.BasePlugin} The plugin that was started, or `null` if `start` was false, or game isn't yet booted. */ - install: function (key, plugin, start, mapping) + install: function (key, plugin, start, mapping, data) { if (start === undefined) { start = false; } if (mapping === undefined) { mapping = null; } + if (data === undefined) { data = null; } if (typeof plugin !== 'function') { console.warn('Invalid Plugin: ' + key); - return; + return null; } if (PluginCache.hasCustom(key)) { console.warn('Plugin key in use: ' + key); - return; + return null; } if (mapping !== null) @@ -424,18 +434,20 @@ var PluginManager = new Class({ if (!this.game.isBooted) { - this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping }); + this._pendingGlobal.push({ key: key, plugin: plugin, start: start, mapping: mapping, data: data }); } else { // Add it to the plugin store - PluginCache.registerCustom(key, plugin, mapping); + PluginCache.registerCustom(key, plugin, mapping, data); if (start) { return this.start(key); } } + + return null; }, /** @@ -568,12 +580,13 @@ var PluginManager = new Class({ key: runAs, plugin: instance, active: true, - mapping: entry.mapping + mapping: entry.mapping, + data: entry.data }; this.plugins.push(entry); - instance.init(); + instance.init(entry.data); instance.start(); } @@ -804,7 +817,8 @@ var PluginManager = new Class({ /** * Destroys this Plugin Manager and all associated plugins. * It will iterate all plugins found and call their `destroy` methods. - * Note that the PluginCache is NOT cleared by this as it doesn't hold any plugin instances. + * + * The PluginCache will remove all custom plugins. * * @method Phaser.Plugins.PluginManager#destroy * @since 3.8.0 @@ -816,6 +830,13 @@ var PluginManager = new Class({ this.plugins[i].plugin.destroy(); } + PluginCache.destroyCustomPlugins(); + + if (this.game.noReturn) + { + PluginCache.destroyCorePlugins(); + } + this.game = null; this.plugins = []; this.scenePlugins = []; diff --git a/src/plugins/ScenePlugin.js b/src/plugins/ScenePlugin.js index 13843258f..884d79686 100644 --- a/src/plugins/ScenePlugin.js +++ b/src/plugins/ScenePlugin.js @@ -14,7 +14,7 @@ var Class = require('../utils/Class'); * It can map itself to a Scene property, or into the Scene Systems, or both. * * @class ScenePlugin - * @memberOf Phaser.Plugins + * @memberof Phaser.Plugins * @extends Phaser.Plugins.BasePlugin * @constructor * @since 3.8.0 @@ -32,26 +32,7 @@ var ScenePlugin = new Class({ { BasePlugin.call(this, pluginManager); - /** - * A reference to the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * - * @name Phaser.Plugins.ScenePlugin#scene - * @type {?Phaser.Scene} - * @protected - * @since 3.8.0 - */ this.scene = scene; - - /** - * A reference to the Scene Systems of the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - * - * @name Phaser.Plugins.ScenePlugin#systems - * @type {?Phaser.Scenes.Systems} - * @protected - * @since 3.8.0 - */ this.systems = scene.sys; scene.sys.events.once('boot', this.boot, this); diff --git a/src/polyfills/Function.bind.js b/src/polyfills/Function.bind.js deleted file mode 100644 index 1f9d25fc0..000000000 --- a/src/polyfills/Function.bind.js +++ /dev/null @@ -1,42 +0,0 @@ -/** -* A polyfill for Function.prototype.bind -*/ -if (!Function.prototype.bind) { - - /* jshint freeze: false */ - Function.prototype.bind = (function () { - - var slice = Array.prototype.slice; - - return function (thisArg) { - - var target = this, boundArgs = slice.call(arguments, 1); - - if (typeof target !== 'function') - { - throw new TypeError(); - } - - function bound() { - var args = boundArgs.concat(slice.call(arguments)); - target.apply(this instanceof bound ? this : thisArg, args); - } - - bound.prototype = (function F(proto) { - if (proto) - { - F.prototype = proto; - } - - if (!(this instanceof F)) - { - /* jshint supernew: true */ - return new F; - } - })(target.prototype); - - return bound; - }; - })(); -} - diff --git a/src/polyfills/index.js b/src/polyfills/index.js index bddf9b943..b05f1e561 100644 --- a/src/polyfills/index.js +++ b/src/polyfills/index.js @@ -2,7 +2,6 @@ require('./Array.forEach'); require('./Array.isArray'); require('./AudioContextMonkeyPatch'); require('./console'); -require('./Function.bind'); require('./Math.trunc'); require('./performance.now'); require('./requestAnimationFrame'); diff --git a/src/renderer/BlendModes.js b/src/renderer/BlendModes.js index 298df9ca7..761b69e2a 100644 --- a/src/renderer/BlendModes.js +++ b/src/renderer/BlendModes.js @@ -9,8 +9,8 @@ * * @name Phaser.BlendModes * @enum {integer} - * @memberOf Phaser - * @readOnly + * @memberof Phaser + * @readonly * @since 3.0.0 */ @@ -24,122 +24,226 @@ module.exports = { SKIP_CHECK: -1, /** - * Normal blend mode. + * Normal blend mode. For Canvas and WebGL. + * This is the default setting and draws new shapes on top of the existing canvas content. * * @name Phaser.BlendModes.NORMAL */ NORMAL: 0, /** - * Add blend mode. + * Add blend mode. For Canvas and WebGL. + * Where both shapes overlap the color is determined by adding color values. * * @name Phaser.BlendModes.ADD */ ADD: 1, /** - * Multiply blend mode. + * Multiply blend mode. For Canvas and WebGL. + * The pixels are of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. * * @name Phaser.BlendModes.MULTIPLY */ MULTIPLY: 2, /** - * Screen blend mode. + * Screen blend mode. For Canvas and WebGL. + * The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) * * @name Phaser.BlendModes.SCREEN */ SCREEN: 3, /** - * Overlay blend mode. + * Overlay blend mode. For Canvas only. + * A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter. * * @name Phaser.BlendModes.OVERLAY */ OVERLAY: 4, /** - * Darken blend mode. + * Darken blend mode. For Canvas only. + * Retains the darkest pixels of both layers. * * @name Phaser.BlendModes.DARKEN */ DARKEN: 5, /** - * Lighten blend mode. + * Lighten blend mode. For Canvas only. + * Retains the lightest pixels of both layers. * * @name Phaser.BlendModes.LIGHTEN */ LIGHTEN: 6, /** - * Color Dodge blend mode. + * Color Dodge blend mode. For Canvas only. + * Divides the bottom layer by the inverted top layer. * * @name Phaser.BlendModes.COLOR_DODGE */ COLOR_DODGE: 7, /** - * Color Burn blend mode. + * Color Burn blend mode. For Canvas only. + * Divides the inverted bottom layer by the top layer, and then inverts the result. * * @name Phaser.BlendModes.COLOR_BURN */ COLOR_BURN: 8, /** - * Hard Light blend mode. + * Hard Light blend mode. For Canvas only. + * A combination of multiply and screen like overlay, but with top and bottom layer swapped. * * @name Phaser.BlendModes.HARD_LIGHT */ HARD_LIGHT: 9, /** - * Soft Light blend mode. + * Soft Light blend mode. For Canvas only. + * A softer version of hard-light. Pure black or white does not result in pure black or white. * * @name Phaser.BlendModes.SOFT_LIGHT */ SOFT_LIGHT: 10, /** - * Difference blend mode. + * Difference blend mode. For Canvas only. + * Subtracts the bottom layer from the top layer or the other way round to always get a positive value. * * @name Phaser.BlendModes.DIFFERENCE */ DIFFERENCE: 11, /** - * Exclusion blend mode. + * Exclusion blend mode. For Canvas only. + * Like difference, but with lower contrast. * * @name Phaser.BlendModes.EXCLUSION */ EXCLUSION: 12, /** - * Hue blend mode. + * Hue blend mode. For Canvas only. + * Preserves the luma and chroma of the bottom layer, while adopting the hue of the top layer. * * @name Phaser.BlendModes.HUE */ HUE: 13, /** - * Saturation blend mode. + * Saturation blend mode. For Canvas only. + * Preserves the luma and hue of the bottom layer, while adopting the chroma of the top layer. * * @name Phaser.BlendModes.SATURATION */ SATURATION: 14, /** - * Color blend mode. + * Color blend mode. For Canvas only. + * Preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer. * * @name Phaser.BlendModes.COLOR */ COLOR: 15, /** - * Luminosity blend mode. + * Luminosity blend mode. For Canvas only. + * Preserves the hue and chroma of the bottom layer, while adopting the luma of the top layer. * * @name Phaser.BlendModes.LUMINOSITY */ - LUMINOSITY: 16 + LUMINOSITY: 16, + + /** + * Alpha erase blend mode. For Canvas and WebGL. + * + * @name Phaser.BlendModes.ERASE + */ + ERASE: 17, + + /** + * Source-in blend mode. For Canvas only. + * The new shape is drawn only where both the new shape and the destination canvas overlap. Everything else is made transparent. + * + * @name Phaser.BlendModes.SOURCE_IN + */ + SOURCE_IN: 18, + + /** + * Source-out blend mode. For Canvas only. + * The new shape is drawn where it doesn't overlap the existing canvas content. + * + * @name Phaser.BlendModes.SOURCE_OUT + */ + SOURCE_OUT: 19, + + /** + * Source-out blend mode. For Canvas only. + * The new shape is only drawn where it overlaps the existing canvas content. + * + * @name Phaser.BlendModes.SOURCE_ATOP + */ + SOURCE_ATOP: 20, + + /** + * Destination-over blend mode. For Canvas only. + * New shapes are drawn behind the existing canvas content. + * + * @name Phaser.BlendModes.DESTINATION_OVER + */ + DESTINATION_OVER: 21, + + /** + * Destination-in blend mode. For Canvas only. + * The existing canvas content is kept where both the new shape and existing canvas content overlap. Everything else is made transparent. + * + * @name Phaser.BlendModes.DESTINATION_IN + */ + DESTINATION_IN: 22, + + /** + * Destination-out blend mode. For Canvas only. + * The existing content is kept where it doesn't overlap the new shape. + * + * @name Phaser.BlendModes.DESTINATION_OUT + */ + DESTINATION_OUT: 23, + + /** + * Destination-out blend mode. For Canvas only. + * The existing canvas is only kept where it overlaps the new shape. The new shape is drawn behind the canvas content. + * + * @name Phaser.BlendModes.DESTINATION_ATOP + */ + DESTINATION_ATOP: 24, + + /** + * Lighten blend mode. For Canvas only. + * Where both shapes overlap the color is determined by adding color values. + * + * @name Phaser.BlendModes.LIGHTER + */ + LIGHTER: 25, + + /** + * Copy blend mode. For Canvas only. + * Only the new shape is shown. + * + * @name Phaser.BlendModes.COPY + */ + COPY: 26, + + /** + * xor blend mode. For Canvas only. + * Shapes are made transparent where both overlap and drawn normal everywhere else. + * + * @name Phaser.BlendModes.XOR + */ + XOR: 27 }; diff --git a/src/renderer/ScaleModes.js b/src/renderer/ScaleModes.js index 875502f01..4b9dbf51f 100644 --- a/src/renderer/ScaleModes.js +++ b/src/renderer/ScaleModes.js @@ -9,8 +9,8 @@ * * @name Phaser.ScaleModes * @enum {integer} - * @memberOf Phaser - * @readOnly + * @memberof Phaser + * @readonly * @since 3.0.0 */ diff --git a/src/renderer/canvas/CanvasRenderer.js b/src/renderer/canvas/CanvasRenderer.js index e23d27eb2..881280abc 100644 --- a/src/renderer/canvas/CanvasRenderer.js +++ b/src/renderer/canvas/CanvasRenderer.js @@ -5,21 +5,20 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var BlitImage = require('./utils/BlitImage'); var CanvasSnapshot = require('../snapshot/CanvasSnapshot'); var Class = require('../../utils/Class'); var CONST = require('../../const'); -var DrawImage = require('./utils/DrawImage'); var GetBlendModes = require('./utils/GetBlendModes'); var ScaleModes = require('../ScaleModes'); var Smoothing = require('../../display/canvas/Smoothing'); +var TransformMatrix = require('../../gameobjects/components/TransformMatrix'); /** * @classdesc - * [description] + * The Canvas Renderer is responsible for managing 2D canvas rendering contexts, including the one used by the Game's canvas. It tracks the internal state of a given context and can renderer textured Game Objects to it, taking into account alpha, blending, and scaling. * * @class CanvasRenderer - * @memberOf Phaser.Renderer.Canvas + * @memberof Phaser.Renderer.Canvas * @constructor * @since 3.0.0 * @@ -41,7 +40,7 @@ var CanvasRenderer = new Class({ this.game = game; /** - * [description] + * A constant which allows the renderer to be easily identified as a Canvas Renderer. * * @name Phaser.Renderer.Canvas.CanvasRenderer#type * @type {integer} @@ -50,7 +49,7 @@ var CanvasRenderer = new Class({ this.type = CONST.CANVAS; /** - * [description] + * The total number of Game Objects which were rendered in a frame. * * @name Phaser.Renderer.Canvas.CanvasRenderer#drawCount * @type {number} @@ -60,7 +59,7 @@ var CanvasRenderer = new Class({ this.drawCount = 0; /** - * [description] + * The width of the canvas being rendered to. * * @name Phaser.Renderer.Canvas.CanvasRenderer#width * @type {number} @@ -69,7 +68,7 @@ var CanvasRenderer = new Class({ this.width = game.config.width; /** - * [description] + * The height of the canvas being rendered to. * * @name Phaser.Renderer.Canvas.CanvasRenderer#height * @type {number} @@ -78,7 +77,7 @@ var CanvasRenderer = new Class({ this.height = game.config.height; /** - * [description] + * The local configuration settings of the CanvasRenderer. * * @name Phaser.Renderer.Canvas.CanvasRenderer#config * @type {RendererConfig} @@ -94,7 +93,7 @@ var CanvasRenderer = new Class({ }; /** - * [description] + * The scale mode which should be used by the CanvasRenderer. * * @name Phaser.Renderer.Canvas.CanvasRenderer#scaleMode * @type {integer} @@ -103,7 +102,7 @@ var CanvasRenderer = new Class({ this.scaleMode = (game.config.antialias) ? ScaleModes.LINEAR : ScaleModes.NEAREST; /** - * [description] + * The canvas element which the Game uses. * * @name Phaser.Renderer.Canvas.CanvasRenderer#gameCanvas * @type {HTMLCanvasElement} @@ -112,7 +111,7 @@ var CanvasRenderer = new Class({ this.gameCanvas = game.canvas; /** - * [description] + * The canvas context used to render all Cameras in all Scenes during the game loop. * * @name Phaser.Renderer.Canvas.CanvasRenderer#gameContext * @type {CanvasRenderingContext2D} @@ -121,7 +120,7 @@ var CanvasRenderer = new Class({ this.gameContext = (this.game.config.context) ? this.game.config.context : this.gameCanvas.getContext('2d'); /** - * [description] + * The canvas context currently used by the CanvasRenderer for all rendering operations. * * @name Phaser.Renderer.Canvas.CanvasRenderer#currentContext * @type {CanvasRenderingContext2D} @@ -130,25 +129,9 @@ var CanvasRenderer = new Class({ this.currentContext = this.gameContext; /** - * Map to the required function. + * The blend modes supported by the Canvas Renderer. * - * @name Phaser.Renderer.Canvas.CanvasRenderer#drawImage - * @type {function} - * @since 3.0.0 - */ - this.drawImage = DrawImage; - - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#blitImage - * @type {function} - * @since 3.0.0 - */ - this.blitImage = BlitImage(this.config.roundPixels); - - /** - * [description] + * This object maps the {@link Phaser.BlendModes} to canvas compositing operations. * * @name Phaser.Renderer.Canvas.CanvasRenderer#blendModes * @type {array} @@ -156,28 +139,11 @@ var CanvasRenderer = new Class({ */ this.blendModes = GetBlendModes(); - /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentAlpha - * @type {number} - * @default 1 - * @since 3.0.0 - */ - this.currentAlpha = 1; + // image-rendering: optimizeSpeed; + // image-rendering: pixelated; /** - * [description] - * - * @name Phaser.Renderer.Canvas.CanvasRenderer#currentBlendMode - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentBlendMode = 0; - - /** - * [description] + * The scale mode currently in use by the Canvas Renderer. * * @name Phaser.Renderer.Canvas.CanvasRenderer#currentScaleMode * @type {number} @@ -187,7 +153,7 @@ var CanvasRenderer = new Class({ this.currentScaleMode = 0; /** - * [description] + * If a snapshot is scheduled, the function to call after it is taken. * * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotCallback * @type {?SnapshotCallback} @@ -197,7 +163,7 @@ var CanvasRenderer = new Class({ this.snapshotCallback = null; /** - * [description] + * The type of the image to create when taking the snapshot, usually `image/png`. * * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotType * @type {?string} @@ -207,7 +173,7 @@ var CanvasRenderer = new Class({ this.snapshotType = null; /** - * [description] + * The image quality of the snapshot which will be taken, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). * * @name Phaser.Renderer.Canvas.CanvasRenderer#snapshotEncoder * @type {?number} @@ -216,11 +182,51 @@ var CanvasRenderer = new Class({ */ this.snapshotEncoder = null; + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.Canvas.CanvasRenderer#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix4 = new TransformMatrix(); + this.init(); }, /** - * [description] + * Prepares the game canvas for rendering. * * @method Phaser.Renderer.Canvas.CanvasRenderer#init * @since 3.0.0 @@ -236,11 +242,15 @@ var CanvasRenderer = new Class({ * @method Phaser.Renderer.Canvas.CanvasRenderer#resize * @since 3.0.0 * - * @param {integer} width - [description] - * @param {integer} height - [description] + * @param {integer} width - The new width of the canvas. + * @param {integer} height - The new height of the canvas. */ resize: function (width, height) { + this.width = width; + this.height = height; + + /* var resolution = this.config.resolution; this.width = width * resolution; @@ -254,6 +264,7 @@ var CanvasRenderer = new Class({ this.gameCanvas.style.width = (this.width / resolution) + 'px'; this.gameCanvas.style.height = (this.height / resolution) + 'px'; } + */ // Resizing a canvas will reset imageSmoothingEnabled (and probably other properties) if (this.scaleMode === ScaleModes.NEAREST) @@ -263,31 +274,31 @@ var CanvasRenderer = new Class({ }, /** - * [description] + * A NOOP method for handling lost context. Intentionally empty. * * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextLost * @since 3.0.0 * - * @param {function} callback - [description] + * @param {function} callback - Ignored parameter. */ onContextLost: function () { }, /** - * [description] + * A NOOP method for handling restored context. Intentionally empty. * * @method Phaser.Renderer.Canvas.CanvasRenderer#onContextRestored * @since 3.0.0 * - * @param {function} callback - [description] + * @param {function} callback - Ignored parameter. */ onContextRestored: function () { }, /** - * [description] + * Resets the transformation matrix of the current context to the identity matrix, thus resetting any transformation. * * @method Phaser.Renderer.Canvas.CanvasRenderer#resetTransform * @since 3.0.0 @@ -298,45 +309,54 @@ var CanvasRenderer = new Class({ }, /** - * [description] + * Sets the blend mode (compositing operation) of the current context. * * @method Phaser.Renderer.Canvas.CanvasRenderer#setBlendMode * @since 3.0.0 * - * @param {number} blendMode - [description] + * @param {string} blendMode - The new blend mode which should be used. * - * @return {number} [description] + * @return {this} This CanvasRenderer object. */ setBlendMode: function (blendMode) { - if (this.currentBlendMode !== blendMode) - { - this.currentContext.globalCompositeOperation = blendMode; - this.currentBlendMode = blendMode; - } + this.currentContext.globalCompositeOperation = blendMode; - return this.currentBlendMode; + return this; }, /** - * [description] + * Changes the Canvas Rendering Context that all draw operations are performed against. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#setContext + * @since 3.12.0 + * + * @param {?CanvasRenderingContext2D} [ctx] - The new Canvas Rendering Context to draw everything to. Leave empty to reset to the Game Canvas. + * + * @return {this} The Canvas Renderer instance. + */ + setContext: function (ctx) + { + this.currentContext = (ctx) ? ctx : this.gameContext; + + return this; + }, + + /** + * Sets the global alpha of the current context. * * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha * @since 3.0.0 * - * @param {number} alpha - [description] + * @param {number} alpha - The new alpha to use, where 0 is fully transparent and 1 is fully opaque. * - * @return {number} [description] + * @return {this} This CanvasRenderer object. */ setAlpha: function (alpha) { - if (this.currentAlpha !== alpha) - { - this.currentContext.globalAlpha = alpha; - this.currentAlpha = alpha; - } + this.currentContext.globalAlpha = alpha; - return this.currentAlpha; + return this; }, /** @@ -353,6 +373,10 @@ var CanvasRenderer = new Class({ var width = this.width; var height = this.height; + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + ctx.setTransform(1, 0, 0, 1, 0, 0); + if (config.clearBeforeRender) { ctx.clearRect(0, 0, width, height); @@ -364,6 +388,8 @@ var CanvasRenderer = new Class({ ctx.fillRect(0, 0, width, height); } + ctx.save(); + this.drawCount = 0; }, @@ -373,57 +399,62 @@ var CanvasRenderer = new Class({ * @method Phaser.Renderer.Canvas.CanvasRenderer#render * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.DisplayList} children - [description] - * @param {number} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Scene} scene - The Scene to render. + * @param {Phaser.GameObjects.DisplayList} children - The Game Objects within the Scene to be rendered. + * @param {number} interpolationPercentage - The interpolation percentage to apply. Currently unused. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Scene Camera to render with. */ render: function (scene, children, interpolationPercentage, camera) { - var ctx = scene.sys.context; - var scissor = (camera.x !== 0 || camera.y !== 0 || camera.width !== ctx.canvas.width || camera.height !== ctx.canvas.height); var list = children.list; - var resolution = this.config.resolution; + var childCount = list.length; + + var cx = camera._cx; + var cy = camera._cy; + var cw = camera._cw; + var ch = camera._ch; + + var ctx = (camera.renderToTexture) ? camera.context : scene.sys.context; + + // Save context pre-clip + ctx.save(); + + if (this.game.scene.customViewports) + { + ctx.beginPath(); + ctx.rect(cx, cy, cw, ch); + ctx.clip(); + } this.currentContext = ctx; - // If the alpha or blend mode didn't change since the last render, then don't set them again (saves 2 ops) - if (!camera.transparent) { ctx.fillStyle = camera.backgroundColor.rgba; - ctx.fillRect(camera.x, camera.y, camera.width, camera.height); + ctx.fillRect(cx, cy, cw, ch); } ctx.globalAlpha = camera.alpha; - this.currentAlpha = camera.alpha; - - if (this.currentBlendMode !== 0) - { - ctx.globalCompositeOperation = 'source-over'; - this.currentBlendMode = 0; - } - - this.currentScaleMode = 0; + ctx.globalCompositeOperation = 'source-over'; this.drawCount += list.length; - if (scissor) + if (camera.renderToTexture) { - ctx.save(); - ctx.beginPath(); - ctx.rect(camera.x * resolution, camera.y * resolution, camera.width * resolution, camera.height * resolution); - ctx.clip(); + camera.emit('prerender', camera); } - var matrix = camera.matrix.matrix; + camera.matrix.copyToContext(ctx); - ctx.setTransform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - - for (var c = 0; c < list.length; c++) + for (var i = 0; i < childCount; i++) { - var child = list[c]; + var child = list[i]; + + if (!child.willRender(camera)) + { + continue; + } if (child.mask) { @@ -445,15 +476,23 @@ var CanvasRenderer = new Class({ camera.flashEffect.postRenderCanvas(ctx); camera.fadeEffect.postRenderCanvas(ctx); - // Reset the camera scissor - if (scissor) + camera.dirty = false; + + // Restore pre-clip context + ctx.restore(); + + if (camera.renderToTexture) { - ctx.restore(); + camera.emit('postrender', camera); + + scene.sys.context.drawImage(camera.canvas, cx, cy); } }, /** - * [description] + * Restores the game context's global settings and takes a snapshot if one is scheduled. + * + * The post-render step happens after all Cameras in all Scenes have been rendered. * * @method Phaser.Renderer.Canvas.CanvasRenderer#postRender * @since 3.0.0 @@ -462,11 +501,7 @@ var CanvasRenderer = new Class({ { var ctx = this.gameContext; - ctx.globalAlpha = 1; - ctx.globalCompositeOperation = 'source-over'; - - this.currentAlpha = 1; - this.currentBlendMode = 0; + ctx.restore(); if (this.snapshotCallback) { @@ -476,14 +511,14 @@ var CanvasRenderer = new Class({ }, /** - * [description] + * Schedules a snapshot to be taken after the current frame is rendered. * * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshot * @since 3.0.0 * - * @param {SnapshotCallback} callback - [description] - * @param {string} type - [description] - * @param {number} encoderOptions - [description] + * @param {SnapshotCallback} callback - Function to invoke after the snapshot is created. + * @param {string} type - The format of the image to create, usually `image/png`. + * @param {number} encoderOptions - The image quality, between 0 and 1, to use for image formats with lossy compression (such as `image/jpeg`). */ snapshot: function (callback, type, encoderOptions) { @@ -493,7 +528,131 @@ var CanvasRenderer = new Class({ }, /** - * [description] + * Takes a Sprite Game Object, or any object that extends it, and draws it to the current context. + * + * @method Phaser.Renderer.Canvas.CanvasRenderer#batchSprite + * @since 3.12.0 + * + * @param {Phaser.GameObjects.GameObject} sprite - The texture based Game Object to draw. + * @param {Phaser.Textures.Frame} frame - The frame to draw, doesn't have to be that owned by the Game Object. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the rendering transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - The transform matrix of the parent container, if set. + */ + batchSprite: function (sprite, frame, camera, parentTransformMatrix) + { + var alpha = camera.alpha * sprite.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + + var ctx = this.currentContext; + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var cd = frame.canvasData; + + var frameX = cd.x; + var frameY = cd.y; + var frameWidth = frame.cutWidth; + var frameHeight = frame.cutHeight; + var res = frame.source.resolution; + + var x = -sprite.displayOriginX + frame.x; + var y = -sprite.displayOriginY + frame.y; + + var fx = (sprite.flipX) ? -1 : 1; + var fy = (sprite.flipY) ? -1 : 1; + + if (sprite.isCropped) + { + var crop = sprite._crop; + + if (crop.flipX !== sprite.flipX || crop.flipY !== sprite.flipY) + { + frame.updateCropUVs(crop, sprite.flipX, sprite.flipY); + } + + frameWidth = crop.cw; + frameHeight = crop.ch; + + frameX = crop.cx; + frameY = crop.cy; + + x = -sprite.displayOriginX + crop.x; + y = -sprite.displayOriginY + crop.y; + + if (fx === -1) + { + if (x >= 0) + { + x = -(x + frameWidth); + } + else if (x < 0) + { + x = (Math.abs(x) - frameWidth); + } + } + + if (fy === -1) + { + if (y >= 0) + { + y = -(y + frameHeight); + } + else if (y < 0) + { + y = (Math.abs(y) - frameHeight); + } + } + } + + spriteMatrix.applyITRS(sprite.x, sprite.y, sprite.rotation, sprite.scaleX, sprite.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * sprite.scrollFactorX, -camera.scrollY * sprite.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = sprite.x; + spriteMatrix.f = sprite.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * sprite.scrollFactorX; + spriteMatrix.f -= camera.scrollY * sprite.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + ctx.save(); + + calcMatrix.setToContext(ctx); + + ctx.scale(fx, fy); + + ctx.globalCompositeOperation = this.blendModes[sprite.blendMode]; + + ctx.globalAlpha = alpha; + + ctx.drawImage(frame.source.image, frameX, frameY, frameWidth, frameHeight, x, y, frameWidth / res, frameHeight / res); + + ctx.restore(); + }, + + /** + * Destroys all object references in the Canvas Renderer. * * @method Phaser.Renderer.Canvas.CanvasRenderer#destroy * @since 3.0.0 diff --git a/src/renderer/canvas/index.js b/src/renderer/canvas/index.js index 8cec395ff..c46df1248 100644 --- a/src/renderer/canvas/index.js +++ b/src/renderer/canvas/index.js @@ -10,9 +10,8 @@ module.exports = { - BlitImage: require('./utils/BlitImage'), CanvasRenderer: require('./CanvasRenderer'), - DrawImage: require('./utils/DrawImage'), - GetBlendModes: require('./utils/GetBlendModes') + GetBlendModes: require('./utils/GetBlendModes'), + SetTransform: require('./utils/SetTransform') }; diff --git a/src/renderer/canvas/utils/BlitImage.js b/src/renderer/canvas/utils/BlitImage.js deleted file mode 100644 index 5249dd25e..000000000 --- a/src/renderer/canvas/utils/BlitImage.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var roundPixels = false; - -/** - * No scaling, anchor, rotation or effects, literally draws the frame directly to the canvas. - * - * @function Phaser.Renderer.Canvas.BlitImage - * @since 3.0.0 - * - * @param {number} dx - The x coordinate to render the Frame to. - * @param {number} dy - The y coordinate to render the Frame to. - * @param {Phaser.Textures.Frame} frame - The Frame to render. - */ -var BlitImage = function (dx, dy, frame) -{ - var ctx = this.currentContext; - var cd = frame.canvasData; - - if (roundPixels) - { - dx |= 0; - dy |= 0; - } - - ctx.drawImage( - frame.source.image, - cd.sx, - cd.sy, - cd.sWidth, - cd.sHeight, - dx, - dy, - cd.dWidth, - cd.dHeight - ); -}; - -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return BlitImage; -}; diff --git a/src/renderer/canvas/utils/DrawImage.js b/src/renderer/canvas/utils/DrawImage.js deleted file mode 100644 index f0d56c27e..000000000 --- a/src/renderer/canvas/utils/DrawImage.js +++ /dev/null @@ -1,112 +0,0 @@ -/** - * @author Richard Davey - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -/** - * [description] - * - * @function Phaser.Renderer.Canvas.DrawImage - * @since 3.0.0 - * - * @param {Phaser.GameObjects.GameObject} src - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - [description] - */ -var DrawImage = function (src, camera, parentMatrix) -{ - var ctx = this.currentContext; - var frame = src.frame; - var cd = frame.canvasData; - - // Alpha - - var alpha = camera.alpha * src.alpha; - - if (alpha === 0) - { - // Nothing to see, so abort early - return; - } - - ctx.globalAlpha = alpha; - - // Blend Mode - - if (this.currentBlendMode !== src.blendMode) - { - this.currentBlendMode = src.blendMode; - ctx.globalCompositeOperation = this.blendModes[src.blendMode]; - } - - // Smoothing - - if (this.currentScaleMode !== src.scaleMode) - { - this.currentScaleMode = src.scaleMode; - - // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); - } - - var dx = frame.x; - var dy = frame.y; - - var fx = 1; - var fy = 1; - - if (src.flipX) - { - fx = -1; - dx -= cd.dWidth - src.displayOriginX; - } - else - { - dx -= src.displayOriginX; - } - - if (src.flipY) - { - fy = -1; - dy -= cd.dHeight - src.displayOriginY; - } - else - { - dy -= src.displayOriginY; - } - - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - - if (camera.roundPixels) - { - tx |= 0; - ty |= 0; - dx |= 0; - dy |= 0; - } - - // Perform Matrix ITRS - - ctx.save(); - - if (parentMatrix) - { - var matrix = parentMatrix.matrix; - - ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); - } - - ctx.translate(tx, ty); - - ctx.rotate(src.rotation); - - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(fx, fy); - - ctx.drawImage(frame.source.image, cd.sx, cd.sy, cd.sWidth, cd.sHeight, dx, dy, cd.dWidth, cd.dHeight); - - ctx.restore(); -}; - -module.exports = DrawImage; diff --git a/src/renderer/canvas/utils/GetBlendModes.js b/src/renderer/canvas/utils/GetBlendModes.js index d7d17762b..b3b1e1eed 100644 --- a/src/renderer/canvas/utils/GetBlendModes.js +++ b/src/renderer/canvas/utils/GetBlendModes.js @@ -8,35 +8,49 @@ var modes = require('../../BlendModes'); var CanvasFeatures = require('../../../device/CanvasFeatures'); /** - * [description] + * Returns an array which maps the default blend modes to supported Canvas blend modes. + * + * If the browser doesn't support a blend mode, it will default to the normal `source-over` blend mode. * * @function Phaser.Renderer.Canvas.GetBlendModes * @since 3.0.0 * - * @return {array} [description] + * @return {array} Which Canvas blend mode corresponds to which default Phaser blend mode. */ var GetBlendModes = function () { var output = []; var useNew = CanvasFeatures.supportNewBlendModes; + var so = 'source-over'; - output[modes.NORMAL] = 'source-over'; + output[modes.NORMAL] = so; output[modes.ADD] = 'lighter'; - output[modes.MULTIPLY] = (useNew) ? 'multiply' : 'source-over'; - output[modes.SCREEN] = (useNew) ? 'screen' : 'source-over'; - output[modes.OVERLAY] = (useNew) ? 'overlay' : 'source-over'; - output[modes.DARKEN] = (useNew) ? 'darken' : 'source-over'; - output[modes.LIGHTEN] = (useNew) ? 'lighten' : 'source-over'; - output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : 'source-over'; - output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : 'source-over'; - output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : 'source-over'; - output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : 'source-over'; - output[modes.DIFFERENCE] = (useNew) ? 'difference' : 'source-over'; - output[modes.EXCLUSION] = (useNew) ? 'exclusion' : 'source-over'; - output[modes.HUE] = (useNew) ? 'hue' : 'source-over'; - output[modes.SATURATION] = (useNew) ? 'saturation' : 'source-over'; - output[modes.COLOR] = (useNew) ? 'color' : 'source-over'; - output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : 'source-over'; + output[modes.MULTIPLY] = (useNew) ? 'multiply' : so; + output[modes.SCREEN] = (useNew) ? 'screen' : so; + output[modes.OVERLAY] = (useNew) ? 'overlay' : so; + output[modes.DARKEN] = (useNew) ? 'darken' : so; + output[modes.LIGHTEN] = (useNew) ? 'lighten' : so; + output[modes.COLOR_DODGE] = (useNew) ? 'color-dodge' : so; + output[modes.COLOR_BURN] = (useNew) ? 'color-burn' : so; + output[modes.HARD_LIGHT] = (useNew) ? 'hard-light' : so; + output[modes.SOFT_LIGHT] = (useNew) ? 'soft-light' : so; + output[modes.DIFFERENCE] = (useNew) ? 'difference' : so; + output[modes.EXCLUSION] = (useNew) ? 'exclusion' : so; + output[modes.HUE] = (useNew) ? 'hue' : so; + output[modes.SATURATION] = (useNew) ? 'saturation' : so; + output[modes.COLOR] = (useNew) ? 'color' : so; + output[modes.LUMINOSITY] = (useNew) ? 'luminosity' : so; + output[modes.ERASE] = 'destination-out'; + output[modes.SOURCE_IN] = 'source-in'; + output[modes.SOURCE_OUT] = 'source-out'; + output[modes.SOURCE_ATOP] = 'source-atop'; + output[modes.DESTINATION_OVER] = 'destination-over'; + output[modes.DESTINATION_IN] = 'destination-in'; + output[modes.DESTINATION_OUT] = 'destination-out'; + output[modes.DESTINATION_ATOP] = 'destination-atop'; + output[modes.LIGHTER] = 'lighter'; + output[modes.COPY] = 'copy'; + output[modes.XOR] = 'xor'; return output; }; diff --git a/src/renderer/canvas/utils/SetTransform.js b/src/renderer/canvas/utils/SetTransform.js new file mode 100644 index 000000000..c802fb09f --- /dev/null +++ b/src/renderer/canvas/utils/SetTransform.js @@ -0,0 +1,79 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Takes a reference to the Canvas Renderer, a Canvas Rendering Context, a Game Object, a Camera and a parent matrix + * and then performs the following steps: + * + * 1) Checks the alpha of the source combined with the Camera alpha. If 0 or less it aborts. + * 2) Takes the Camera and Game Object matrix and multiplies them, combined with the parent matrix if given. + * 3) Sets the blend mode of the context to be that used by the Game Object. + * 4) Sets the alpha value of the context to be that used by the Game Object combined with the Camera. + * 5) Saves the context state. + * 6) Sets the final matrix values into the context via setTransform. + * + * This function is only meant to be used internally. Most of the Canvas Renderer classes use it. + * + * @function Phaser.Renderer.Canvas.SetTransform + * @since 3.12.0 + * + * @param {Phaser.Renderer.Canvas.CanvasRenderer} renderer - A reference to the current active Canvas renderer. + * @param {CanvasRenderingContext2D} ctx - The canvas context to set the transform on. + * @param {Phaser.GameObjects.GameObject} src - The Game Object being rendered. Can be any type that extends the base class. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentMatrix] - A parent transform matrix to apply to the Game Object before rendering. + * + * @return {boolean} `true` if the Game Object context was set, otherwise `false`. + */ +var SetTransform = function (renderer, ctx, src, camera, parentMatrix) +{ + var alpha = camera.alpha * src.alpha; + + if (alpha <= 0) + { + // Nothing to see, so don't waste time calculating stuff + return false; + } + + var camMatrix = renderer._tempMatrix1.copyFromArray(camera.matrix.matrix); + var gameObjectMatrix = renderer._tempMatrix2.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + var calcMatrix = renderer._tempMatrix3; + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + gameObjectMatrix.e = src.x; + gameObjectMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(gameObjectMatrix, calcMatrix); + } + else + { + gameObjectMatrix.e -= camera.scrollX * src.scrollFactorX; + gameObjectMatrix.f -= camera.scrollY * src.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(gameObjectMatrix, calcMatrix); + } + + // Blend Mode + ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; + + // Alpha + ctx.globalAlpha = alpha; + + ctx.save(); + + calcMatrix.setToContext(ctx); + + return true; +}; + +module.exports = SetTransform; diff --git a/src/renderer/index.js b/src/renderer/index.js index a7b531266..697ddfe90 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -7,12 +7,12 @@ /** * @typedef {object} RendererConfig * - * @property {boolean} clearBeforeRender - [description] - * @property {boolean} antialias - [description] - * @property {Phaser.Display.Color} backgroundColor - [description] - * @property {number} resolution - [description] - * @property {boolean} autoResize - [description] - * @property {boolean} roundPixels - [description] + * @property {boolean} clearBeforeRender - If `false`, the canvas won't be cleared before a frame is rendered. As a side effect, this can give a negligible performance boost with no visual artifacts with full-screen backgrounds. + * @property {boolean} antialias - Whether to antialias textures when transforming them. This should be turned off if you're using pixel art as it will make it look blurry. + * @property {Phaser.Display.Color} backgroundColor - The background color of the canvas. This is visible in areas which aren't covered by any Game Objects. + * @property {number} resolution - The resolution of the game canvas. This is the scale of a pixel compared to the size it'll actually be visible as. This can allow high-resolution textures at the expense of video memory. + * @property {boolean} autoResize - Whether the game canvas element should be physically resized to match the actual size of the canvas automatically. + * @property {boolean} roundPixels - If `true`, graphics won't be drawn at fractional pixels. Enabling this can make pixel art look better. */ /** diff --git a/src/renderer/snapshot/CanvasSnapshot.js b/src/renderer/snapshot/CanvasSnapshot.js index 8c5d06ff3..5d547d46b 100644 --- a/src/renderer/snapshot/CanvasSnapshot.js +++ b/src/renderer/snapshot/CanvasSnapshot.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Takes a snapshot of the current frame displayed by a 2D canvas. * * @function Phaser.Renderer.Snapshot.Canvas * @since 3.0.0 * - * @param {HTMLCanvasElement} canvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {number} [encoderOptions=0.92] - [description] + * @param {HTMLCanvasElement} canvas - The canvas to take a snapshot of. + * @param {string} [type='image/png'] - The format of the returned image. + * @param {number} [encoderOptions=0.92] - The image quality, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). * - * @return {HTMLImageElement} [description] + * @return {HTMLImageElement} Returns an image of the type specified. */ var CanvasSnapshot = function (canvas, type, encoderOptions) { diff --git a/src/renderer/snapshot/WebGLSnapshot.js b/src/renderer/snapshot/WebGLSnapshot.js index 2d28e951a..69894d6f1 100644 --- a/src/renderer/snapshot/WebGLSnapshot.js +++ b/src/renderer/snapshot/WebGLSnapshot.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Takes a snapshot of the current frame displayed by a WebGL canvas. * * @function Phaser.Renderer.Snapshot.WebGL * @since 3.0.0 * - * @param {HTMLCanvasElement} sourceCanvas - [description] - * @param {string} [type='image/png'] - [description] - * @param {number} [encoderOptions=0.92] - [description] + * @param {HTMLCanvasElement} sourceCanvas - The canvas to take a snapshot of. + * @param {string} [type='image/png'] - The format of the returned image. + * @param {number} [encoderOptions=0.92] - The image quality, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). * - * @return {HTMLImageElement} [description] + * @return {HTMLImageElement} A new image which contains a snapshot of the canvas's contents. */ var WebGLSnapshot = function (sourceCanvas, type, encoderOptions) { diff --git a/src/renderer/webgl/Utils.js b/src/renderer/webgl/Utils.js index 946346b91..949bf56f3 100644 --- a/src/renderer/webgl/Utils.js +++ b/src/renderer/webgl/Utils.js @@ -18,8 +18,8 @@ module.exports = { * @since 3.0.0 * * @param {number} r - Red component in a range from 0.0 to 1.0 - * @param {number} g - [description] - * @param {number} b - [description] + * @param {number} g - Green component in a range from 0.0 to 1.0 + * @param {number} b - Blue component in a range from 0.0 to 1.0 * @param {number} a - Alpha component in a range from 0.0 to 1.0 * * @return {number} [description] diff --git a/src/renderer/webgl/WebGLPipeline.js b/src/renderer/webgl/WebGLPipeline.js index b15259eff..283344908 100644 --- a/src/renderer/webgl/WebGLPipeline.js +++ b/src/renderer/webgl/WebGLPipeline.js @@ -10,12 +10,12 @@ var Utils = require('./Utils'); /** * @classdesc - * WebGLPipeline is a class that describes the way elements will be rendererd - * in WebGL, specially focused on batching vertices (batching is not provided). - * Pipelines are mostly used for describing 2D rendering passes but it's - * flexible enough to be used for any type of rendering including 3D. + * WebGLPipeline is a class that describes the way elements will be rendererd + * in WebGL, specially focused on batching vertices (batching is not provided). + * Pipelines are mostly used for describing 2D rendering passes but it's + * flexible enough to be used for any type of rendering including 3D. * Internally WebGLPipeline will handle things like compiling shaders, - * creating vertex buffers, assigning primitive topology and binding + * creating vertex buffers, assigning primitive topology and binding * vertex attributes. * * The config properties are: @@ -30,7 +30,7 @@ var Utils = require('./Utils'); * - vertexSize: The size of a single vertex in bytes. * - vertices: An optional buffer of vertices * - attributes: An array describing the vertex attributes - * + * * The vertex attributes properties are: * - name : String - Name of the attribute in the vertex shader * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 @@ -41,11 +41,11 @@ var Utils = require('./Utils'); * - https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer * * @class WebGLPipeline - * @memberOf Phaser.Renderer.WebGL + * @memberof Phaser.Renderer.WebGL * @constructor * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object for this WebGL Pipeline, as described above. */ var WebGLPipeline = new Class({ @@ -63,7 +63,7 @@ var WebGLPipeline = new Class({ this.name = 'WebGLPipeline'; /** - * [description] + * The Game which owns this WebGL Pipeline. * * @name Phaser.Renderer.WebGL.WebGLPipeline#game * @type {Phaser.Game} @@ -72,7 +72,7 @@ var WebGLPipeline = new Class({ this.game = config.game; /** - * [description] + * The canvas which this WebGL Pipeline renders to. * * @name Phaser.Renderer.WebGL.WebGLPipeline#view * @type {HTMLCanvasElement} @@ -108,7 +108,7 @@ var WebGLPipeline = new Class({ this.height = config.game.config.height * this.resolution; /** - * [description] + * The WebGL context this WebGL Pipeline uses. * * @name Phaser.Renderer.WebGL.WebGLPipeline#gl * @type {WebGLRenderingContext} @@ -136,7 +136,7 @@ var WebGLPipeline = new Class({ this.vertexCapacity = config.vertexCapacity; /** - * [description] + * The WebGL Renderer which owns this WebGL Pipeline. * * @name Phaser.Renderer.WebGL.WebGLPipeline#renderer * @type {Phaser.Renderer.WebGL.WebGLRenderer} @@ -238,6 +238,19 @@ var WebGLPipeline = new Class({ this.active = false; }, + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#boot + * @since 3.11.0 + */ + boot: function () + { + }, + /** * Adds a description of vertex attribute to the pipeline * @@ -250,7 +263,7 @@ var WebGLPipeline = new Class({ * @param {boolean} normalized - Is the value normalized to a range * @param {integer} offset - Byte offset to the beginning of the first element in the vertex * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ addAttribute: function (name, size, type, normalized, offset) { @@ -271,7 +284,7 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if the current batch should be flushed, otherwise `false`. */ shouldFlush: function () { @@ -284,16 +297,17 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#resize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] + * @param {number} width - The new width of this WebGL Pipeline. + * @param {number} height - The new height of this WebGL Pipeline. + * @param {number} resolution - The resolution this WebGL Pipeline should be resized to. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ resize: function (width, height, resolution) { this.width = width * resolution; this.height = height * resolution; + return this; }, @@ -303,7 +317,7 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#bind * @since 3.0.0 * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ bind: function () { @@ -337,12 +351,14 @@ var WebGLPipeline = new Class({ }, /** - * [description] + * Set whenever this WebGL Pipeline is bound to a WebGL Renderer. + * + * This method is called every time the WebGL Pipeline is attempted to be bound, even if it already is the current pipeline. * * @method Phaser.Renderer.WebGL.WebGLPipeline#onBind * @since 3.0.0 * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ onBind: function () { @@ -351,12 +367,12 @@ var WebGLPipeline = new Class({ }, /** - * [description] + * Called before each frame is rendered, but after the canvas has been cleared. * * @method Phaser.Renderer.WebGL.WebGLPipeline#onPreRender * @since 3.0.0 * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ onPreRender: function () { @@ -365,15 +381,15 @@ var WebGLPipeline = new Class({ }, /** - * [description] + * Called before a Scene's Camera is rendered. * * @method Phaser.Renderer.WebGL.WebGLPipeline#onRender * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Scene} scene - The Scene being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Scene Camera being rendered with. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ onRender: function () { @@ -382,12 +398,12 @@ var WebGLPipeline = new Class({ }, /** - * [description] + * Called after each frame has been completely rendered and snapshots have been taken. * * @method Phaser.Renderer.WebGL.WebGLPipeline#onPostRender * @since 3.0.0 * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ onPostRender: function () { @@ -402,7 +418,7 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#flush * @since 3.0.0 * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ flush: function () { @@ -431,12 +447,12 @@ var WebGLPipeline = new Class({ }, /** - * [description] + * Removes all object references in this WebGL Pipeline and removes its program from the WebGL context. * * @method Phaser.Renderer.WebGL.WebGLPipeline#destroy * @since 3.0.0 * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ destroy: function () { @@ -458,14 +474,15 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1 * @since 3.2.0 * - * @param {string} name - [description] - * @param {number} x - [description] + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - The new value of the `float` uniform. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setFloat1: function (name, x) { this.renderer.setFloat1(this.program, name, x); + return this; }, @@ -475,16 +492,16 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2 * @since 3.2.0 * - * @param {string} name - [description] - * @param {number} x - [description] - * @param {number} y - [description] + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - The new X component of the `vec2` uniform. + * @param {number} y - The new Y component of the `vec2` uniform. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setFloat2: function (name, x, y) { - this.renderer.setFloat2(this.program, name, x, y); + return this; }, @@ -494,17 +511,17 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3 * @since 3.2.0 * - * @param {string} name - [description] - * @param {number} x - [description] - * @param {number} y - [description] - * @param {number} z - [description] + * @param {string} name - The name of the uniform to look-up and modify. + * @param {number} x - The new X component of the `vec3` uniform. + * @param {number} y - The new Y component of the `vec3` uniform. + * @param {number} z - The new Z component of the `vec3` uniform. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setFloat3: function (name, x, y, z) { - this.renderer.setFloat3(this.program, name, x, y, z); + return this; }, @@ -514,18 +531,90 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4 * @since 3.2.0 * - * @param {string} name - Name of the uniform + * @param {string} name - The name of the uniform to look-up and modify. * @param {number} x - X component of the uniform * @param {number} y - Y component of the uniform * @param {number} z - Z component of the uniform * @param {number} w - W component of the uniform * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setFloat4: function (name, x, y, z, w) { - this.renderer.setFloat4(this.program, name, x, y, z, w); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat1v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat1v: function (name, arr) + { + this.renderer.setFloat1v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat2v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat2v: function (name, arr) + { + this.renderer.setFloat2v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat3v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat3v: function (name, arr) + { + this.renderer.setFloat3v(this.program, name, arr); + + return this; + }, + + /** + * Set a uniform value of the current pipeline program. + * + * @method Phaser.Renderer.WebGL.WebGLPipeline#setFloat4v + * @since 3.13.0 + * + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGLPipeline instance. + */ + setFloat4v: function (name, arr) + { + this.renderer.setFloat4v(this.program, name, arr); + return this; }, @@ -535,14 +624,15 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt1 * @since 3.2.0 * - * @param {string} name - [description] - * @param {integer} x - [description] + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - The new value of the `int` uniform. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setInt1: function (name, x) { this.renderer.setInt1(this.program, name, x); + return this; }, @@ -552,15 +642,16 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt2 * @since 3.2.0 * - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - The new X component of the `ivec2` uniform. + * @param {integer} y - The new Y component of the `ivec2` uniform. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setInt2: function (name, x, y) { this.renderer.setInt2(this.program, name, x, y); + return this; }, @@ -570,16 +661,17 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt3 * @since 3.2.0 * - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - The new X component of the `ivec3` uniform. + * @param {integer} y - The new Y component of the `ivec3` uniform. + * @param {integer} z - The new Z component of the `ivec3` uniform. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setInt3: function (name, x, y, z) { this.renderer.setInt3(this.program, name, x, y, z); + return this; }, @@ -589,56 +681,56 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setInt4 * @since 3.2.0 * - * @param {string} name - Name of the uniform + * @param {string} name - The name of the uniform to look-up and modify. * @param {integer} x - X component of the uniform * @param {integer} y - Y component of the uniform * @param {integer} z - Z component of the uniform * @param {integer} w - W component of the uniform * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setInt4: function (name, x, y, z, w) { this.renderer.setInt4(this.program, name, x, y, z, w); + return this; }, /** * Set a uniform value of the current pipeline program. - * [description] * * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2 * @since 3.2.0 * - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - Whether to transpose the matrix. Should be `false`. + * @param {Float32Array} matrix - The new values for the `mat2` uniform. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setMatrix2: function (name, transpose, matrix) { this.renderer.setMatrix2(this.program, name, transpose, matrix); + return this; }, /** * Set a uniform value of the current pipeline program. - * [description] - * [description] * * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3 * @since 3.2.0 * - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - Whether to transpose the matrix. Should be `false`. + * @param {Float32Array} matrix - The new values for the `mat3` uniform. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setMatrix3: function (name, transpose, matrix) { this.renderer.setMatrix3(this.program, name, transpose, matrix); + return this; }, @@ -648,15 +740,16 @@ var WebGLPipeline = new Class({ * @method Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4 * @since 3.2.0 * - * @param {string} name - Name of the uniform + * @param {string} name - The name of the uniform to look-up and modify. * @param {boolean} transpose - Should the matrix be transpose * @param {Float32Array} matrix - Matrix data * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {this} This WebGLPipeline instance. */ setMatrix4: function (name, transpose, matrix) { this.renderer.setMatrix4(this.program, name, transpose, matrix); + return this; } diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index 9f3c043b5..1cba6a7bc 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -5,31 +5,32 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var BaseCamera = require('../../cameras/2d/BaseCamera'); var Class = require('../../utils/Class'); var CONST = require('../../const'); var IsSizePowerOfTwo = require('../../math/pow2/IsSizePowerOfTwo'); var SpliceOne = require('../../utils/array/SpliceOne'); +var TransformMatrix = require('../../gameobjects/components/TransformMatrix'); var Utils = require('./Utils'); var WebGLSnapshot = require('../snapshot/WebGLSnapshot'); // Default Pipelines var BitmapMaskPipeline = require('./pipelines/BitmapMaskPipeline'); -var FlatTintPipeline = require('./pipelines/FlatTintPipeline'); var ForwardDiffuseLightPipeline = require('./pipelines/ForwardDiffuseLightPipeline'); var TextureTintPipeline = require('./pipelines/TextureTintPipeline'); /** * @callback WebGLContextCallback * - * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description] + * @param {Phaser.Renderer.WebGL.WebGLRenderer} renderer - The WebGL Renderer which owns the context. */ /** * @typedef {object} SnapshotState * - * @property {SnapshotCallback} callback - [description] - * @property {string} type - [description] - * @property {number} encoder - [description] + * @property {SnapshotCallback} callback - The function to call after the snapshot is taken. + * @property {string} type - The type of the image to create. + * @property {number} encoder - The image quality, between 0 and 1, for image formats which use lossy compression (such as `image/jpeg`). */ /** @@ -39,15 +40,15 @@ var TextureTintPipeline = require('./pipelines/TextureTintPipeline'); * any context change that happens for WebGL rendering inside of Phaser. This means * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL * rendering ecosystem they might pollute the current WebGLRenderingContext state producing - * unexpected behaviour. It's recommended that WebGL interaction is done through + * unexpected behavior. It's recommended that WebGL interaction is done through * WebGLRenderer and/or WebGLPipeline. * * @class WebGLRenderer - * @memberOf Phaser.Renderer.WebGL + * @memberof Phaser.Renderer.WebGL * @constructor * @since 3.0.0 * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - The Game instance which owns this WebGL Renderer. */ var WebGLRenderer = new Class({ @@ -62,17 +63,16 @@ var WebGLRenderer = new Class({ var contextCreationConfig = { alpha: gameConfig.transparent, - depth: false, // enable when 3D is added in the future + depth: false, antialias: gameConfig.antialias, premultipliedAlpha: gameConfig.premultipliedAlpha, stencil: true, - preserveDrawingBuffer: gameConfig.preserveDrawingBuffer, failIfMajorPerformanceCaveat: gameConfig.failIfMajorPerformanceCaveat, powerPreference: gameConfig.powerPreference }; /** - * [description] + * The local configuration settings of this WebGL Renderer. * * @name Phaser.Renderer.WebGL.WebGLRenderer#config * @type {RendererConfig} @@ -87,11 +87,13 @@ var WebGLRenderer = new Class({ autoResize: gameConfig.autoResize, roundPixels: gameConfig.roundPixels, maxTextures: gameConfig.maxTextures, - maxTextureSize: gameConfig.maxTextureSize + maxTextureSize: gameConfig.maxTextureSize, + batchSize: gameConfig.batchSize, + maxLights: gameConfig.maxLights }; /** - * [description] + * The Game instance which owns this WebGL Renderer. * * @name Phaser.Renderer.WebGL.WebGLRenderer#game * @type {Phaser.Game} @@ -100,7 +102,7 @@ var WebGLRenderer = new Class({ this.game = game; /** - * [description] + * A constant which allows the renderer to be easily identified as a WebGL Renderer. * * @name Phaser.Renderer.WebGL.WebGLRenderer#type * @type {integer} @@ -109,25 +111,25 @@ var WebGLRenderer = new Class({ this.type = CONST.WEBGL; /** - * [description] + * The width of the canvas being rendered to. * * @name Phaser.Renderer.WebGL.WebGLRenderer#width - * @type {number} + * @type {integer} * @since 3.0.0 */ - this.width = game.config.width; + this.width = game.scale.canvasWidth; /** - * [description] + * The height of the canvas being rendered to. * * @name Phaser.Renderer.WebGL.WebGLRenderer#height - * @type {number} + * @type {integer} * @since 3.0.0 */ - this.height = game.config.height; + this.height = game.scale.canvasHeight; /** - * [description] + * The canvas which this WebGL Renderer draws to. * * @name Phaser.Renderer.WebGL.WebGLRenderer#canvas * @type {HTMLCanvasElement} @@ -136,7 +138,7 @@ var WebGLRenderer = new Class({ this.canvas = game.canvas; /** - * [description] + * An array of functions to invoke if the WebGL context is lost. * * @name Phaser.Renderer.WebGL.WebGLRenderer#lostContextCallbacks * @type {WebGLContextCallback[]} @@ -145,7 +147,7 @@ var WebGLRenderer = new Class({ this.lostContextCallbacks = []; /** - * [description] + * An array of functions to invoke if the WebGL context is restored. * * @name Phaser.Renderer.WebGL.WebGLRenderer#restoredContextCallbacks * @type {WebGLContextCallback[]} @@ -154,7 +156,9 @@ var WebGLRenderer = new Class({ this.restoredContextCallbacks = []; /** - * [description] + * An array of blend modes supported by the WebGL Renderer. + * + * This array includes the default blend modes as well as any custom blend modes added through {@link #addBlendMode}. * * @name Phaser.Renderer.WebGL.WebGLRenderer#blendModes * @type {array} @@ -174,7 +178,7 @@ var WebGLRenderer = new Class({ this.nativeTextures = []; /** - * [description] + * Set to `true` if the WebGL context of the renderer is lost. * * @name Phaser.Renderer.WebGL.WebGLRenderer#contextLost * @type {boolean} @@ -194,7 +198,9 @@ var WebGLRenderer = new Class({ this.pipelines = null; /** - * [description] + * Details about the currently scheduled snapshot. + * + * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. * * @name Phaser.Renderer.WebGL.WebGLRenderer#snapshotState * @type {SnapshotState} @@ -302,17 +308,8 @@ var WebGLRenderer = new Class({ * @type {Uint32Array} * @since 3.0.0 */ - this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); - - /** - * Index to the scissor stack top - * - * @name Phaser.Renderer.WebGL.WebGLRenderer#currentScissorIdx - * @type {number} - * @default 0 - * @since 3.0.0 - */ - this.currentScissorIdx = 0; + // this.currentScissor = new Uint32Array([ 0, 0, this.width, this.height ]); + this.currentScissor = null; /** * Stack of scissor data @@ -321,7 +318,7 @@ var WebGLRenderer = new Class({ * @type {Uint32Array} * @since 3.0.0 */ - this.scissorStack = new Uint32Array(4 * 1000); + this.scissorStack = []; // Setup context lost and restore event listeners @@ -351,7 +348,7 @@ var WebGLRenderer = new Class({ // These are initialized post context creation /** - * [description] + * The underlying WebGL context of the renderer. * * @name Phaser.Renderer.WebGL.WebGLRenderer#gl * @type {WebGLRenderingContext} @@ -403,6 +400,69 @@ var WebGLRenderer = new Class({ S3TC: false }; + /** + * Cached drawing buffer height to reduce gl calls. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#drawingBufferHeight + * @type {number} + * @readonly + * @since 3.11.0 + */ + this.drawingBufferHeight = 0; + + /** + * A blank 32x32 transparent texture, as used by the Graphics system where needed. + * This is set in the `boot` method. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#blankTexture + * @type {WebGLTexture} + * @readonly + * @since 3.12.0 + */ + this.blankTexture = null; + + this.defaultCamera = new BaseCamera(0, 0, 0, 0); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.WebGLRenderer#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.12.0 + */ + this._tempMatrix4 = new TransformMatrix(); + this.init(this.config); }, @@ -413,9 +473,9 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#init * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object for the renderer. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGLRenderer instance. */ init: function (config) { @@ -437,23 +497,31 @@ var WebGLRenderer = new Class({ { this.contextLost = true; - throw new Error('This browser does not support WebGL. Try using the Canvas pipeline.'); + throw new Error('WebGL unsupported'); } this.gl = gl; - // Set it back into the Game, so devs can access it from there too + // Set it back into the Game, so developers can access it from there too this.game.context = gl; - for (var i = 0; i <= 16; i++) + for (var i = 0; i <= 27; i++) { this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD }); } + // ADD this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ]; + + // MULTIPLY this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ]; + + // SCREEN this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ]; + // ERASE + this.blendModes[17] = { func: [ gl.ZERO, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_REVERSE_SUBTRACT }; + this.glFormats[0] = gl.BYTE; this.glFormats[1] = gl.SHORT; this.glFormats[2] = gl.UNSIGNED_BYTE; @@ -479,15 +547,16 @@ var WebGLRenderer = new Class({ this.compression.ETC1 = gl.getExtension(extString + 'etc1') || gl.getExtension(wkExtString + 'etc1'); this.compression.PVRTC = gl.getExtension(extString + 'pvrtc') || gl.getExtension(wkExtString + 'pvrtc'); this.compression.S3TC = gl.getExtension(extString + 's3tc') || gl.getExtension(wkExtString + 's3tc'); - + this.supportedExtensions = exts; - // Setup initial WebGL state + // Setup initial WebGL state gl.disable(gl.DEPTH_TEST); gl.disable(gl.CULL_FACE); - gl.disable(gl.SCISSOR_TEST); + gl.enable(gl.BLEND); - gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1.0); + + gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1); // Initialize all textures to null for (var index = 0; index < this.currentTextures.length; ++index) @@ -499,68 +568,111 @@ var WebGLRenderer = new Class({ this.pipelines = {}; this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: this.game, renderer: this })); - this.addPipeline('FlatTintPipeline', new FlatTintPipeline({ game: this.game, renderer: this })); this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: this.game, renderer: this })); - this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this })); + this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: this.game, renderer: this, maxLights: config.maxLights })); this.setBlendMode(CONST.BlendModes.NORMAL); - this.resize(this.width, this.height); + + var width = this.width; + var height = this.height; + + gl.viewport(0, 0, width, height); + + var pipelines = this.pipelines; + + // Update all registered pipelines + for (var pipelineName in pipelines) + { + pipelines[pipelineName].resize(width, height, this.game.scale.resolution); + } + + this.drawingBufferHeight = gl.drawingBufferHeight; + + this.defaultCamera.setSize(width, height); + + gl.scissor(0, (this.drawingBufferHeight - height), width, height); + + this.game.events.once('texturesready', this.boot, this); return this; }, /** - * [description] + * Internal boot handler. Calls 'boot' on each pipeline. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#boot + * @private + * @since 3.11.0 + */ + boot: function () + { + for (var pipelineName in this.pipelines) + { + this.pipelines[pipelineName].boot(); + } + + var blank = this.game.textures.getFrame('__DEFAULT'); + + this.pipelines.TextureTintPipeline.currentFrame = blank; + + this.blankTexture = blank; + + var gl = this.gl; + + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + + gl.enable(gl.SCISSOR_TEST); + + this.setPipeline(this.pipelines.TextureTintPipeline); + }, + + /** + * Resizes the drawing buffer. * * @method Phaser.Renderer.WebGL.WebGLRenderer#resize * @since 3.0.0 * - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} width - The width of the renderer. + * @param {number} height - The height of the renderer. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGLRenderer instance. */ resize: function (width, height) { var gl = this.gl; var pipelines = this.pipelines; - var resolution = this.config.resolution; + var resolution = this.game.scale.resolution; this.width = Math.floor(width * resolution); this.height = Math.floor(height * resolution); - this.canvas.width = this.width; - this.canvas.height = this.height; - - if (this.config.autoResize) - { - this.canvas.style.width = (this.width / resolution) + 'px'; - this.canvas.style.height = (this.height / resolution) + 'px'; - } - gl.viewport(0, 0, this.width, this.height); - // Update all registered pipelines + // Update all registered pipelines for (var pipelineName in pipelines) { pipelines[pipelineName].resize(width, height, resolution); } - - this.currentScissor.set([ 0, 0, this.width, this.height ]); + + this.drawingBufferHeight = gl.drawingBufferHeight; + + this.defaultCamera.setSize(width, height); + + gl.scissor(0, (this.drawingBufferHeight - this.height), this.width, this.height); return this; }, /** - * [description] + * Adds a callback to be invoked when the WebGL context has been restored by the browser. * * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextRestored * @since 3.0.0 * - * @param {WebGLContextCallback} callback - [description] - * @param {object} target - [description] + * @param {WebGLContextCallback} callback - The callback to be invoked on context restoration. + * @param {object} target - The context of the callback. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGLRenderer instance. */ onContextRestored: function (callback, target) { @@ -570,15 +682,15 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Adds a callback to be invoked when the WebGL context has been lost by the browser. * * @method Phaser.Renderer.WebGL.WebGLRenderer#onContextLost * @since 3.0.0 * - * @param {WebGLContextCallback} callback - [description] - * @param {object} target - [description] + * @param {WebGLContextCallback} callback - The callback to be invoked on context loss. + * @param {object} target - The context of the callback. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGLRenderer instance. */ onContextLost: function (callback, target) { @@ -595,7 +707,7 @@ var WebGLRenderer = new Class({ * * @param {string} extensionName - Name of the WebGL extension * - * @return {boolean} [description] + * @return {boolean} `true` if the extension is supported, otherwise `false`. */ hasExtension: function (extensionName) { @@ -608,7 +720,7 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#getExtension * @since 3.0.0 * - * @param {string} extensionName - [description] + * @param {string} extensionName - The name of the extension to load. * * @return {object} WebGL extension if the extension is supported */ @@ -638,17 +750,15 @@ var WebGLRenderer = new Class({ } }, - /* Renderer State Manipulation Functions */ - /** * Checks if a pipeline is present in the current WebGLRenderer * * @method Phaser.Renderer.WebGL.WebGLRenderer#hasPipeline * @since 3.0.0 * - * @param {string} pipelineName - Name of the pipeline + * @param {string} pipelineName - The name of the pipeline. * - * @return {boolean} [description] + * @return {boolean} `true` if the given pipeline is loaded, otherwise `false`. */ hasPipeline: function (pipelineName) { @@ -661,9 +771,9 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#getPipeline * @since 3.0.0 * - * @param {string} pipelineName - [description] + * @param {string} pipelineName - The name of the pipeline. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline instance, or `null` if not found. */ getPipeline: function (pipelineName) { @@ -671,14 +781,14 @@ var WebGLRenderer = new Class({ }, /** - * Removes a pipeline by name + * Removes a pipeline by name. * * @method Phaser.Renderer.WebGL.WebGLRenderer#removePipeline * @since 3.0.0 * - * @param {string} pipelineName - [description] + * @param {string} pipelineName - The name of the pipeline to be removed. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGLRenderer instance. */ removePipeline: function (pipelineName) { @@ -693,10 +803,10 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#addPipeline * @since 3.0.0 * - * @param {string} pipelineName - [description] - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - Pipeline instance must extend WebGLPipeline + * @param {string} pipelineName - A unique string-based key for the pipeline. + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - A pipeline instance which must extend WebGLPipeline. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} The instance that was passed. + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline instance that was passed. */ addPipeline: function (pipelineName, pipelineInstance) { @@ -706,7 +816,7 @@ var WebGLRenderer = new Class({ } else { - console.warn('Pipeline', pipelineName, ' already exists.'); + console.warn('Pipeline exists: ' + pipelineName); } pipelineInstance.name = pipelineName; @@ -716,81 +826,74 @@ var WebGLRenderer = new Class({ return pipelineInstance; }, - /** - * Sets the current scissor state - * - * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor - * @since 3.0.0 - * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] - */ - setScissor: function (x, y, w, h) - { - var gl = this.gl; - var currentScissor = this.currentScissor; - var enabled = (x === 0 && y === 0 && w === gl.canvas.width && h === gl.canvas.height && w >= 0 && h >= 0); - - if (currentScissor[0] !== x || - currentScissor[1] !== y || - currentScissor[2] !== w || - currentScissor[3] !== h) - { - this.flush(); - } - - currentScissor[0] = x; - currentScissor[1] = y; - currentScissor[2] = w; - currentScissor[3] = h; - - this.currentScissorEnabled = enabled; - - if (enabled) - { - gl.disable(gl.SCISSOR_TEST); - - return this; - } - - gl.enable(gl.SCISSOR_TEST); - gl.scissor(x, (gl.drawingBufferHeight - y - h), w, h); - - return this; - }, - /** * Pushes a new scissor state. This is used to set nested scissor states. * * @method Phaser.Renderer.WebGL.WebGLRenderer#pushScissor * @since 3.0.0 * - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} w - [description] - * @param {integer} h - [description] + * @param {integer} x - The x position of the scissor. + * @param {integer} y - The y position of the scissor. + * @param {integer} width - The width of the scissor. + * @param {integer} height - The height of the scissor. + * @param {integer} [drawingBufferHeight] - Optional drawingBufferHeight override value. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {integer[]} An array containing the scissor values. */ - pushScissor: function (x, y, w, h) + pushScissor: function (x, y, width, height, drawingBufferHeight) { + if (drawingBufferHeight === undefined) { drawingBufferHeight = this.drawingBufferHeight; } + var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx; - var currentScissor = this.currentScissor; - scissorStack[stackIndex + 0] = currentScissor[0]; - scissorStack[stackIndex + 1] = currentScissor[1]; - scissorStack[stackIndex + 2] = currentScissor[2]; - scissorStack[stackIndex + 3] = currentScissor[3]; + var scissor = [ x, y, width, height ]; - this.currentScissorIdx += 4; - this.setScissor(x, y, w, h); + scissorStack.push(scissor); - return this; + this.setScissor(x, y, width, height, drawingBufferHeight); + + this.currentScissor = scissor; + + return scissor; + }, + + /** + * Sets the current scissor state. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setScissor + * @since 3.0.0 + * + * @param {integer} x - The x position of the scissor. + * @param {integer} y - The y position of the scissor. + * @param {integer} width - The width of the scissor. + * @param {integer} height - The height of the scissor. + * @param {integer} [drawingBufferHeight] - Optional drawingBufferHeight override value. + */ + setScissor: function (x, y, width, height, drawingBufferHeight) + { + var gl = this.gl; + + var current = this.currentScissor; + + var setScissor = (width > 0 && height > 0); + + if (current && setScissor) + { + var cx = current[0]; + var cy = current[1]; + var cw = current[2]; + var ch = current[3]; + + setScissor = (cx !== x || cy !== y || cw !== width || ch !== height); + } + + if (setScissor) + { + this.flush(); + + // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/scissor + gl.scissor(x, (drawingBufferHeight - y - height), width, height); + } }, /** @@ -798,23 +901,23 @@ var WebGLRenderer = new Class({ * * @method Phaser.Renderer.WebGL.WebGLRenderer#popScissor * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ popScissor: function () { var scissorStack = this.scissorStack; - var stackIndex = this.currentScissorIdx - 4; - var x = scissorStack[stackIndex + 0]; - var y = scissorStack[stackIndex + 1]; - var w = scissorStack[stackIndex + 2]; - var h = scissorStack[stackIndex + 3]; + // Remove the current scissor + scissorStack.pop(); - this.currentScissorIdx = stackIndex; - this.setScissor(x, y, w, h); + // Reset the previous scissor + var scissor = scissorStack[scissorStack.length - 1]; - return this; + if (scissor) + { + this.setScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + } + + this.currentScissor = scissor; }, /** @@ -823,11 +926,12 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setPipeline * @since 3.0.0 * - * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - [description] + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - The pipeline instance to be activated. + * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any. * - * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] + * @return {Phaser.Renderer.WebGL.WebGLPipeline} The pipeline that was activated. */ - setPipeline: function (pipelineInstance) + setPipeline: function (pipelineInstance, gameObject) { if (this.currentPipeline !== pipelineInstance || this.currentPipeline.vertexBuffer !== this.currentVertexBuffer || @@ -838,28 +942,98 @@ var WebGLRenderer = new Class({ this.currentPipeline.bind(); } - this.currentPipeline.onBind(); + this.currentPipeline.onBind(gameObject); return this.currentPipeline; }, /** - * [description] + * Use this to reset the gl context to the state that Phaser requires to continue rendering. + * Calling this will: + * + * * Disable `DEPTH_TEST`, `CULL_FACE` and `STENCIL_TEST`. + * * Clear the depth buffer and stencil buffers. + * * Reset the viewport size. + * * Reset the blend mode. + * * Bind a blank texture as the active texture on texture unit zero. + * * Rebinds the given pipeline instance. + * + * You should call this having previously called `clearPipeline` and then wishing to return + * control to Phaser again. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#rebindPipeline + * @since 3.16.0 + * + * @param {Phaser.Renderer.WebGL.WebGLPipeline} pipelineInstance - The pipeline instance to be activated. + */ + rebindPipeline: function (pipelineInstance) + { + var gl = this.gl; + + gl.disable(gl.DEPTH_TEST); + gl.disable(gl.CULL_FACE); + gl.disable(gl.STENCIL_TEST); + + gl.clear(gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + + gl.viewport(0, 0, this.width, this.height); + + this.setBlendMode(0, true); + + gl.activeTexture(gl.TEXTURE0); + gl.bindTexture(gl.TEXTURE_2D, this.blankTexture.glTexture); + + this.currentActiveTextureUnit = 0; + this.currentTextures[0] = this.blankTexture.glTexture; + + this.currentPipeline = pipelineInstance; + this.currentPipeline.bind(); + this.currentPipeline.onBind(); + }, + + /** + * Flushes the current WebGLPipeline being used and then clears it, along with the + * the current shader program and vertex buffer. Then resets the blend mode to NORMAL. + * Call this before jumping to your own gl context handler, and then call `rebindPipeline` when + * you wish to return control to Phaser again. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#clearPipeline + * @since 3.16.0 + */ + clearPipeline: function () + { + this.flush(); + + this.currentPipeline = null; + this.currentProgram = null; + this.currentVertexBuffer = null; + this.currentIndexBuffer = null; + + this.setBlendMode(0, true); + }, + + /** + * Sets the blend mode to the value given. + * + * If the current blend mode is different from the one given, the pipeline is flushed and the new + * blend mode is enabled. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlendMode * @since 3.0.0 * - * @param {integer} blendModeId - [description] + * @param {integer} blendModeId - The blend mode to be set. Can be a `BlendModes` const or an integer value. + * @param {boolean} [force=false] - Force the blend mode to be set, regardless of the currently set blend mode. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {boolean} `true` if the blend mode was changed as a result of this call, forcing a flush, otherwise `false`. */ - setBlendMode: function (blendModeId) + setBlendMode: function (blendModeId, force) { + if (force === undefined) { force = false; } + var gl = this.gl; var blendMode = this.blendModes[blendModeId]; - if (blendModeId !== CONST.BlendModes.SKIP_CHECK && - this.currentBlendMode !== blendModeId) + if (force || (blendModeId !== CONST.BlendModes.SKIP_CHECK && this.currentBlendMode !== blendModeId)) { this.flush(); @@ -876,21 +1050,23 @@ var WebGLRenderer = new Class({ } this.currentBlendMode = blendModeId; + + return true; } - return this; + return false; }, /** - * [description] + * Creates a new custom blend mode for the renderer. * * @method Phaser.Renderer.WebGL.WebGLRenderer#addBlendMode * @since 3.0.0 * - * @param {function} func - [description] - * @param {function} equation - [description] + * @param {function} func - An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for {@link WebGLRenderingContext#blendFunc()}. + * @param {function} equation - The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for {@link WebGLRenderingContext#blendEquation()}. * - * @return {integer} [description] + * @return {integer} The index of the new blend mode, used for referencing it in the future. */ addBlendMode: function (func, equation) { @@ -900,16 +1076,16 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Updates the function bound to a given custom blend mode. * * @method Phaser.Renderer.WebGL.WebGLRenderer#updateBlendMode * @since 3.0.0 * - * @param {integer} index - [description] - * @param {function} func - [description] - * @param {function} equation - [description] + * @param {integer} index - The index of the custom blend mode. + * @param {function} func - The function to use for the blend mode. + * @param {function} equation - The equation to use for the blend mode. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ updateBlendMode: function (index, func, equation) { @@ -927,18 +1103,19 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Removes a custom blend mode from the renderer. + * Any Game Objects still using this blend mode will error, so be sure to clear them first. * * @method Phaser.Renderer.WebGL.WebGLRenderer#removeBlendMode * @since 3.0.0 * - * @param {integer} index - [description] + * @param {integer} index - The index of the custom blend mode to be removed. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ removeBlendMode: function (index) { - if (index > 16 && this.blendModes[index]) + if (index > 17 && this.blendModes[index]) { this.blendModes.splice(index, 1); } @@ -947,24 +1124,50 @@ var WebGLRenderer = new Class({ }, /** - * Binds a texture at a texture unit. If a texture is already + * Sets the current active texture for texture unit zero to be a blank texture. + * This only happens if there isn't a texture already in use by texture unit zero. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setBlankTexture + * @private + * @since 3.12.0 + * + * @param {boolean} [force=false] - Force a blank texture set, regardless of what's already bound? + */ + setBlankTexture: function (force) + { + if (force === undefined) { force = false; } + + if (force || this.currentActiveTextureUnit !== 0 || !this.currentTextures[0]) + { + this.setTexture2D(this.blankTexture.glTexture, 0); + } + }, + + /** + * Binds a texture at a texture unit. If a texture is already * bound to that unit it will force a flush on the current pipeline. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setTexture2D * @since 3.0.0 * - * @param {WebGLTexture} texture - The WebGL texture that needs to be bound - * @param {integer} textureUnit - The texture unit to which the texture will be bound + * @param {WebGLTexture} texture - The WebGL texture that needs to be bound. + * @param {integer} textureUnit - The texture unit to which the texture will be bound. + * @param {boolean} [flush=true] - Will the current pipeline be flushed if this is a new texture, or not? * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ - setTexture2D: function (texture, textureUnit) + setTexture2D: function (texture, textureUnit, flush) { + if (flush === undefined) { flush = true; } + var gl = this.gl; if (texture !== this.currentTextures[textureUnit]) { - this.flush(); + if (flush) + { + this.flush(); + } if (this.currentActiveTextureUnit !== textureUnit) { @@ -982,26 +1185,57 @@ var WebGLRenderer = new Class({ }, /** - * Binds a framebuffer. If there was another framebuffer already bound - * it will force a pipeline flush. + * Binds a framebuffer. If there was another framebuffer already bound it will force a pipeline flush. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setFramebuffer * @since 3.0.0 * - * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound + * @param {WebGLFramebuffer} framebuffer - The framebuffer that needs to be bound. + * @param {boolean} [updateScissor=false] - If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ - setFramebuffer: function (framebuffer) + setFramebuffer: function (framebuffer, updateScissor) { + if (updateScissor === undefined) { updateScissor = false; } + var gl = this.gl; + var width = this.width; + var height = this.height; + if (framebuffer !== this.currentFramebuffer) { - this.flush(); + if (framebuffer && framebuffer.renderTexture) + { + width = framebuffer.renderTexture.width; + height = framebuffer.renderTexture.height; + } + else + { + this.flush(); + } gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer); + gl.viewport(0, 0, width, height); + + if (updateScissor) + { + if (framebuffer) + { + this.drawingBufferHeight = height; + + this.pushScissor(0, 0, width, height); + } + else + { + this.drawingBufferHeight = this.height; + + this.popScissor(); + } + } + this.currentFramebuffer = framebuffer; } @@ -1009,15 +1243,14 @@ var WebGLRenderer = new Class({ }, /** - * Binds a program. If there was another program already bound - * it will force a pipeline flush + * Binds a program. If there was another program already bound it will force a pipeline flush. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setProgram * @since 3.0.0 * - * @param {WebGLProgram} program - The program that needs to be bound + * @param {WebGLProgram} program - The program that needs to be bound. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ setProgram: function (program) { @@ -1036,15 +1269,14 @@ var WebGLRenderer = new Class({ }, /** - * Bounds a vertex buffer. If there is a vertex buffer already bound - * it'll force a pipeline flush. + * Bounds a vertex buffer. If there is a vertex buffer already bound it'll force a pipeline flush. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setVertexBuffer * @since 3.0.0 * - * @param {WebGLBuffer} vertexBuffer - The buffer that needs to be bound + * @param {WebGLBuffer} vertexBuffer - The buffer that needs to be bound. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ setVertexBuffer: function (vertexBuffer) { @@ -1063,15 +1295,14 @@ var WebGLRenderer = new Class({ }, /** - * Bounds a index buffer. If there is a index buffer already bound - * it'll force a pipeline flush. + * Bounds a index buffer. If there is a index buffer already bound it'll force a pipeline flush. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setIndexBuffer * @since 3.0.0 * - * @param {WebGLBuffer} indexBuffer - The buffer the needs to be bound + * @param {WebGLBuffer} indexBuffer - The buffer the needs to be bound. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ setIndexBuffer: function (indexBuffer) { @@ -1089,21 +1320,18 @@ var WebGLRenderer = new Class({ return this; }, - /* Renderer Resource Creation Functions */ - /** - * Creates a texture from an image source. If the source is not valid - * it creates an empty texture + * Creates a texture from an image source. If the source is not valid it creates an empty texture. * * @method Phaser.Renderer.WebGL.WebGLRenderer#createTextureFromSource * @since 3.0.0 * - * @param {object} source - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} scaleMode - [description] + * @param {object} source - The source of the texture. + * @param {integer} width - The width of the texture. + * @param {integer} height - The height of the texture. + * @param {integer} scaleMode - The scale mode to be used by the texture. * - * @return {WebGLTexture} [description] + * @return {?WebGLTexture} The WebGL Texture that was created, or `null` if it couldn't be created. */ createTextureFromSource: function (source, width, height, scaleMode) { @@ -1138,32 +1366,31 @@ var WebGLRenderer = new Class({ }, /** - * A wrapper for creating a WebGLTexture. If not pixel data is passed - * it will create an empty texture. + * A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture. * * @method Phaser.Renderer.WebGL.WebGLRenderer#createTexture2D * @since 3.0.0 * - * @param {integer} mipLevel - Mip level of the texture - * @param {integer} minFilter - Filtering of the texture - * @param {integer} magFilter - Filtering of the texture - * @param {integer} wrapT - Wrapping mode of the texture - * @param {integer} wrapS - Wrapping mode of the texture - * @param {integer} format - Which format does the texture use - * @param {object} pixels - pixel data - * @param {integer} width - Width of the texture in pixels - * @param {integer} height - Height of the texture in pixels + * @param {integer} mipLevel - Mip level of the texture. + * @param {integer} minFilter - Filtering of the texture. + * @param {integer} magFilter - Filtering of the texture. + * @param {integer} wrapT - Wrapping mode of the texture. + * @param {integer} wrapS - Wrapping mode of the texture. + * @param {integer} format - Which format does the texture use. + * @param {object} pixels - pixel data. + * @param {integer} width - Width of the texture in pixels. + * @param {integer} height - Height of the texture in pixels. * @param {boolean} pma - Does the texture have premultiplied alpha? * - * @return {WebGLTexture} Raw WebGLTexture + * @return {WebGLTexture} The WebGLTexture that was created. */ createTexture2D: function (mipLevel, minFilter, magFilter, wrapT, wrapS, format, pixels, width, height, pma) { + pma = (pma === undefined || pma === null) ? true : pma; + var gl = this.gl; var texture = gl.createTexture(); - pma = (pma === undefined || pma === null) ? true : pma; - this.setTexture2D(texture, 0); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, minFilter); @@ -1203,7 +1430,7 @@ var WebGLRenderer = new Class({ * * @param {integer} width - Width in pixels of the framebuffer * @param {integer} height - Height in pixels of the framebuffer - * @param {WebGLTexture} renderTexture - The color texture to where the color pixels are written + * @param {WebGLTexture} renderTexture - The color texture to where the color pixels are written * @param {boolean} addDepthStencilBuffer - Indicates if the current framebuffer support depth and stencil buffers * * @return {WebGLFramebuffer} Raw WebGLFramebuffer @@ -1325,8 +1552,8 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#createIndexBuffer * @since 3.0.0 * - * @param {ArrayBuffer} initialDataOrSize - It's either ArrayBuffer or an integer indicating the size of the vbo - * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW + * @param {ArrayBuffer} initialDataOrSize - Either ArrayBuffer or an integer indicating the size of the vbo. + * @param {integer} bufferUsage - How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. * * @return {WebGLBuffer} Raw index buffer */ @@ -1345,14 +1572,14 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Removes the given texture from the nativeTextures array and then deletes it from the GPU. * * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteTexture * @since 3.0.0 * - * @param {WebGLTexture} texture - [description] + * @param {WebGLTexture} texture - The WebGL Texture to be deleted. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ deleteTexture: function (texture) { @@ -1365,18 +1592,24 @@ var WebGLRenderer = new Class({ this.gl.deleteTexture(texture); + if (this.currentTextures[0] === texture) + { + // texture we just deleted is in use, so bind a blank texture + this.setBlankTexture(true); + } + return this; }, /** - * Wrapper for deleting a raw WebGLFramebuffer + * Deletes a WebGLFramebuffer from the GL instance. * * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteFramebuffer * @since 3.0.0 * - * @param {WebGLFramebuffer} framebuffer - [description] + * @param {WebGLFramebuffer} framebuffer - The Framebuffer to be deleted. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ deleteFramebuffer: function (framebuffer) { @@ -1386,14 +1619,14 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Deletes a WebGLProgram from the GL instance. * * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteProgram * @since 3.0.0 * - * @param {WebGLProgram} program - [description] + * @param {WebGLProgram} program - The shader program to be deleted. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ deleteProgram: function (program) { @@ -1403,14 +1636,14 @@ var WebGLRenderer = new Class({ }, /** - * Wrapper for deleting a vertex or index buffer + * Deletes a WebGLBuffer from the GL instance. * * @method Phaser.Renderer.WebGL.WebGLRenderer#deleteBuffer * @since 3.0.0 * - * @param {WebGLBuffer} vertexBuffer - [description] + * @param {WebGLBuffer} vertexBuffer - The WebGLBuffer to be deleted. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. + * @return {this} This WebGLRenderer instance. */ deleteBuffer: function (buffer) { @@ -1419,68 +1652,127 @@ var WebGLRenderer = new Class({ return this; }, - /* Rendering Functions */ - /** - * Handles any clipping needed by the camera and renders the background - * color if a color is visible. + * Controls the pre-render operations for the given camera. + * Handles any clipping needed by the camera and renders the background color if a color is visible. * * @method Phaser.Renderer.WebGL.WebGLRenderer#preRenderCamera * @since 3.0.0 * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to pre-render. */ preRenderCamera: function (camera) { - var resolution = this.config.resolution; + var cx = camera._cx; + var cy = camera._cy; + var cw = camera._cw; + var ch = camera._ch; - var cx = Math.floor(camera.x * resolution); - var cy = Math.floor(camera.y * resolution); - var cw = Math.floor(camera.width * resolution); - var ch = Math.floor(camera.height * resolution); + var TextureTintPipeline = this.pipelines.TextureTintPipeline; - this.pushScissor(cx, cy, cw, ch); + var color = camera.backgroundColor; - if (camera.backgroundColor.alphaGL > 0) + if (camera.renderToTexture) { - var color = camera.backgroundColor; - var FlatTintPipeline = this.pipelines.FlatTintPipeline; + this.flush(); - FlatTintPipeline.batchFillRect( - 0, 0, 1, 1, 0, - camera.x, camera.y, camera.width, camera.height, - Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1.0), - color.alphaGL, - 1, 0, 0, 1, 0, 0, - [ 1, 0, 0, 1, 0, 0 ] - ); + this.pushScissor(cx, cy, cw, -ch); - FlatTintPipeline.flush(); + this.setFramebuffer(camera.framebuffer); + + var gl = this.gl; + + gl.clearColor(0, 0, 0, 0); + + gl.clear(gl.COLOR_BUFFER_BIT); + + TextureTintPipeline.projOrtho(cx, cw + cx, cy, ch + cy, -1000, 1000); + + if (color.alphaGL > 0) + { + TextureTintPipeline.drawFillRect( + cx, cy, cw + cx, ch + cy, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1), + color.alphaGL + ); + } + + camera.emit('prerender', camera); + } + else + { + this.pushScissor(cx, cy, cw, ch); + + if (color.alphaGL > 0) + { + TextureTintPipeline.drawFillRect( + cx, cy, cw , ch, + Utils.getTintFromFloats(color.redGL, color.greenGL, color.blueGL, 1), + color.alphaGL + ); + } } }, /** - * Renders the foreground camera effects like flash and fading. - * It resets the current scissor state. + * Controls the post-render operations for the given camera. + * Renders the foreground camera effects like flash and fading. It resets the current scissor state. * * @method Phaser.Renderer.WebGL.WebGLRenderer#postRenderCamera * @since 3.0.0 * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to post-render. */ postRenderCamera: function (camera) { - var FlatTintPipeline = this.pipelines.FlatTintPipeline; + var TextureTintPipeline = this.pipelines.TextureTintPipeline; - var isFlashing = camera.flashEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); - var isFading = camera.fadeEffect.postRenderWebGL(FlatTintPipeline, Utils.getTintFromFloats); + camera.flashEffect.postRenderWebGL(TextureTintPipeline, Utils.getTintFromFloats); + camera.fadeEffect.postRenderWebGL(TextureTintPipeline, Utils.getTintFromFloats); - if (isFading || isFlashing) - { - FlatTintPipeline.flush(); - } + camera.dirty = false; this.popScissor(); + + if (camera.renderToTexture) + { + TextureTintPipeline.flush(); + + this.setFramebuffer(null); + + camera.emit('postrender', camera); + + TextureTintPipeline.projOrtho(0, TextureTintPipeline.width, TextureTintPipeline.height, 0, -1000.0, 1000.0); + + var getTint = Utils.getTintAppendFloatAlpha; + + var pipeline = (camera.pipeline) ? camera.pipeline : TextureTintPipeline; + + pipeline.batchTexture( + camera, + camera.glTexture, + camera.width, camera.height, + camera.x, camera.y, + camera.width, camera.height, + camera.zoom, camera.zoom, + camera.rotation, + camera.flipX, !camera.flipY, + 1, 1, + 0, 0, + 0, 0, camera.width, camera.height, + getTint(camera._tintTL, camera._alphaTL), + getTint(camera._tintTR, camera._alphaTR), + getTint(camera._tintBL, camera._alphaBL), + getTint(camera._tintBR, camera._alphaBR), + (camera._isTinted && camera.tintFill), + 0, 0, + this.defaultCamera, + null + ); + + // Force clear the current texture so that items next in the batch (like Graphics) don't try and use it + this.setBlankTexture(true); + } }, /** @@ -1494,33 +1786,58 @@ var WebGLRenderer = new Class({ if (this.contextLost) { return; } var gl = this.gl; - var color = this.config.backgroundColor; var pipelines = this.pipelines; - // Bind custom framebuffer here - gl.clearColor(color.redGL, color.greenGL, color.blueGL, color.alphaGL); + // Make sure we are bound to the main frame buffer + gl.bindFramebuffer(gl.FRAMEBUFFER, null); if (this.config.clearBeforeRender) { + var clearColor = this.config.backgroundColor; + + gl.clearColor(clearColor.redGL, clearColor.greenGL, clearColor.blueGL, 1); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); } + gl.enable(gl.SCISSOR_TEST); + for (var key in pipelines) { pipelines[key].onPreRender(); } + + // TODO - Find a way to stop needing to create these arrays every frame + // and equally not need a huge array buffer created to hold them + + this.currentScissor = [ 0, 0, this.width, this.height ]; + this.scissorStack = [ this.currentScissor ]; + + if (this.game.scene.customViewports) + { + gl.scissor(0, (this.drawingBufferHeight - this.height), this.width, this.height); + } + + this.setPipeline(this.pipelines.TextureTintPipeline); }, /** - * [description] + * The core render step for a Scene Camera. + * + * Iterates through the given Game Object's array and renders them with the given Camera. + * + * This is called by the `CameraManager.render` method. The Camera Manager instance belongs to a Scene, and is invoked + * by the Scene Systems.render method. + * + * This method is not called if `Camera.visible` is `false`, or `Camera.alpha` is zero. * * @method Phaser.Renderer.WebGL.WebGLRenderer#render * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.GameObjects.GameObject} children - [description] - * @param {number} interpolationPercentage - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Scene} scene - The Scene to render. + * @param {Phaser.GameObjects.GameObject} children - The Game Object's within the Scene to be rendered. + * @param {number} interpolationPercentage - The interpolation percentage to apply. Currently un-used. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Scene Camera to render with. */ render: function (scene, children, interpolationPercentage, camera) { @@ -1535,13 +1852,14 @@ var WebGLRenderer = new Class({ pipelines[key].onRender(scene, camera); } + // Apply scissor for cam region + render background color, if not transparent this.preRenderCamera(camera); - for (var index = 0; index < childCount; ++index) + for (var i = 0; i < childCount; i++) { - var child = list[index]; + var child = list[i]; - if (!child.willRender()) + if (!child.willRender(camera)) { continue; } @@ -1551,26 +1869,30 @@ var WebGLRenderer = new Class({ this.setBlendMode(child.blendMode); } - if (child.mask) + var mask = child.mask; + + if (mask) { - child.mask.preRenderWebGL(this, child, camera); + mask.preRenderWebGL(this, child, camera); + + child.renderWebGL(this, child, interpolationPercentage, camera); + + mask.postRenderWebGL(this, child); } - - child.renderWebGL(this, child, interpolationPercentage, camera); - - if (child.mask) + else { - child.mask.postRenderWebGL(this, child); + child.renderWebGL(this, child, interpolationPercentage, camera); } } - this.flush(); this.setBlendMode(CONST.BlendModes.NORMAL); + + // Applies camera effects and pops the scissor, if set this.postRenderCamera(camera); }, /** - * [description] + * The post-render step happens after all Cameras in all Scenes have been rendered. * * @method Phaser.Renderer.WebGL.WebGLRenderer#postRender * @since 3.0.0 @@ -1579,6 +1901,8 @@ var WebGLRenderer = new Class({ { if (this.contextLost) { return; } + this.flush(); + // Unbind custom framebuffer here if (this.snapshotState.callback) @@ -1596,16 +1920,16 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Schedules a snapshot to be taken after the current frame is rendered. * * @method Phaser.Renderer.WebGL.WebGLRenderer#snapshot * @since 3.0.0 * - * @param {SnapshotCallback} callback - [description] - * @param {string} type - [description] - * @param {number} encoderOptions - [description] + * @param {SnapshotCallback} callback - Function to invoke after the snapshot is created. + * @param {string} type - The format of the image to create, usually `image/png`. + * @param {number} encoderOptions - The image quality, between 0 and 1, to use for image formats with lossy compression (such as `image/jpeg`). * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {Phaser.Renderer.WebGL.WebGLRenderer} This WebGL Renderer. */ snapshot: function (callback, type, encoderOptions) { @@ -1617,25 +1941,28 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Creates a WebGL Texture based on the given canvas element. * * @method Phaser.Renderer.WebGL.WebGLRenderer#canvasToTexture * @since 3.0.0 * - * @param {HTMLCanvasElement} srcCanvas - [description] - * @param {WebGLTexture} [dstTexture] - [description] + * @param {HTMLCanvasElement} srcCanvas - The Canvas element that will be used to populate the texture. + * @param {WebGLTexture} [dstTexture] - Is this going to replace an existing texture? If so, pass it here. + * @param {boolean} [noRepeat=false] - Should this canvas never be allowed to set REPEAT? (such as for Text objects) * - * @return {WebGLTexture} [description] + * @return {WebGLTexture} The newly created WebGL Texture. */ - canvasToTexture: function (srcCanvas, dstTexture) + canvasToTexture: function (srcCanvas, dstTexture, noRepeat) { + if (noRepeat === undefined) { noRepeat = false; } + var gl = this.gl; if (!dstTexture) { var wrapping = gl.CLAMP_TO_EDGE; - if (IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) + if (!noRepeat && IsSizePowerOfTwo(srcCanvas.width, srcCanvas.height)) { wrapping = gl.REPEAT; } @@ -1658,15 +1985,15 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Sets the minification and magnification filter for a texture. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setTextureFilter * @since 3.0.0 * - * @param {integer} texture - [description] - * @param {integer} filter - [description] + * @param {integer} texture - The texture to set the filter for. + * @param {integer} filter - The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setTextureFilter: function (texture, filter) { @@ -1689,11 +2016,11 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1 * @since 3.0.0 * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. * @param {number} x - [description] * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setFloat1: function (program, name, x) { @@ -1710,12 +2037,12 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2 * @since 3.0.0 * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. * @param {number} x - [description] * @param {number} y - [description] * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setFloat2: function (program, name, x, y) { @@ -1732,13 +2059,13 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3 * @since 3.0.0 * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. * @param {number} x - [description] * @param {number} y - [description] * @param {number} z - [description] * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setFloat3: function (program, name, x, y, z) { @@ -1755,14 +2082,14 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4 * @since 3.0.0 * - * @param {WebGLProgram} program - Target program - * @param {string} name - Name of the uniform + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. * @param {number} x - X component * @param {number} y - Y component * @param {number} z - Z component * @param {number} w - W component * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setFloat4: function (program, name, x, y, z, w) { @@ -1774,16 +2101,101 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat1v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + setFloat1v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform1fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat2v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + setFloat2v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform2fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat3v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + setFloat3v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform3fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * + * @method Phaser.Renderer.WebGL.WebGLRenderer#setFloat4v + * @since 3.13.0 + * + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {Float32Array} arr - The new value to be used for the uniform variable. + * + * @return {this} This WebGL Renderer instance. + */ + + setFloat4v: function (program, name, arr) + { + this.setProgram(program); + + this.gl.uniform4fv(this.gl.getUniformLocation(program, name), arr); + + return this; + }, + + /** + * Sets the value of a uniform variable in the given WebGLProgram. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt1 * @since 3.0.0 * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. * @param {integer} x - [description] * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setInt1: function (program, name, x) { @@ -1795,17 +2207,17 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Sets the value of a uniform variable in the given WebGLProgram. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt2 * @since 3.0.0 * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - The new X component + * @param {integer} y - The new Y component * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setInt2: function (program, name, x, y) { @@ -1817,18 +2229,18 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Sets the value of a uniform variable in the given WebGLProgram. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt3 * @since 3.0.0 * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {integer} x - [description] - * @param {integer} y - [description] - * @param {integer} z - [description] + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {integer} x - The new X component + * @param {integer} y - The new Y component + * @param {integer} z - The new Z component * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setInt3: function (program, name, x, y, z) { @@ -1840,19 +2252,19 @@ var WebGLRenderer = new Class({ }, /** - * Sets uniform of a WebGLProgram + * Sets the value of a uniform variable in the given WebGLProgram. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setInt4 * @since 3.0.0 * - * @param {WebGLProgram} program - Target Program - * @param {string} name - Name of the uniform + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. * @param {integer} x - X component * @param {integer} y - Y component * @param {integer} z - Z component * @param {integer} w - W component * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setInt4: function (program, name, x, y, z, w) { @@ -1864,17 +2276,17 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Sets the value of a 2x2 matrix uniform variable in the given WebGLProgram. * * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix2 * @since 3.0.0 * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] - * @param {boolean} transpose - [description] - * @param {Float32Array} matrix - [description] + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. + * @param {boolean} transpose - The value indicating whether to transpose the matrix. Must be false. + * @param {Float32Array} matrix - The new matrix value. * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setMatrix2: function (program, name, transpose, matrix) { @@ -1891,12 +2303,12 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix3 * @since 3.0.0 * - * @param {WebGLProgram} program - [description] - * @param {string} name - [description] + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. * @param {boolean} transpose - [description] * @param {Float32Array} matrix - [description] * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setMatrix3: function (program, name, transpose, matrix) { @@ -1913,12 +2325,12 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#setMatrix4 * @since 3.0.0 * - * @param {WebGLProgram} program - Target program - * @param {string} name - Name of the uniform + * @param {WebGLProgram} program - The target WebGLProgram from which the uniform location will be looked-up. + * @param {string} name - The name of the uniform to look-up and modify. * @param {boolean} transpose - Is the matrix transposed * @param {Float32Array} matrix - Matrix data * - * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] + * @return {this} This WebGL Renderer instance. */ setMatrix4: function (program, name, transpose, matrix) { @@ -1950,7 +2362,7 @@ var WebGLRenderer = new Class({ * @method Phaser.Renderer.WebGL.WebGLRenderer#getMaxTextureSize * @since 3.8.0 * - * @return {integer} ... + * @return {integer} The maximum supported texture size. */ getMaxTextureSize: function () { @@ -1958,7 +2370,7 @@ var WebGLRenderer = new Class({ }, /** - * [description] + * Destroy this WebGLRenderer, cleaning up all related resources such as pipelines, native textures, etc. * * @method Phaser.Renderer.WebGL.WebGLRenderer#destroy * @since 3.0.0 diff --git a/src/renderer/webgl/pipelines/BitmapMaskPipeline.js b/src/renderer/webgl/pipelines/BitmapMaskPipeline.js index 726ae60d6..505aa57b5 100644 --- a/src/renderer/webgl/pipelines/BitmapMaskPipeline.js +++ b/src/renderer/webgl/pipelines/BitmapMaskPipeline.js @@ -26,7 +26,7 @@ var WebGLPipeline = require('../WebGLPipeline'); * * @class BitmapMaskPipeline * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines + * @memberof Phaser.Renderer.WebGL.Pipelines * @constructor * @since 3.0.0 * @@ -105,7 +105,7 @@ var BitmapMaskPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline#onBind * @since 3.0.0 * - * @return {Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline} [description] + * @return {this} This WebGLPipeline instance. */ onBind: function () { @@ -135,7 +135,7 @@ var BitmapMaskPipeline = new Class({ * @param {number} height - [description] * @param {number} resolution - [description] * - * @return {Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline} [description] + * @return {this} This WebGLPipeline instance. */ resize: function (width, height, resolution) { @@ -157,26 +157,28 @@ var BitmapMaskPipeline = new Class({ */ beginMask: function (mask, maskedObject, camera) { - var bitmapMask = mask.bitmapMask; var renderer = this.renderer; var gl = this.gl; - var visible = bitmapMask.visible; + + // The renderable Game Object that is being used for the bitmap mask + var bitmapMask = mask.bitmapMask; if (bitmapMask && gl) { + renderer.flush(); + // First we clear the mask framebuffer renderer.setFramebuffer(mask.maskFramebuffer); gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT); - // We render out mask source - bitmapMask.visible = true; - bitmapMask.renderWebGL(renderer, bitmapMask, 0.0, camera); - bitmapMask.visible = visible; + // We render our mask source + bitmapMask.renderWebGL(renderer, bitmapMask, 0, camera); renderer.flush(); // Bind and clear our main source (masked object) renderer.setFramebuffer(mask.mainFramebuffer); + gl.clearColor(0, 0, 0, 0); gl.clear(gl.COLOR_BUFFER_BIT); } @@ -195,11 +197,13 @@ var BitmapMaskPipeline = new Class({ */ endMask: function (mask) { - var bitmapMask = mask.bitmapMask; var renderer = this.renderer; var gl = this.gl; - if (bitmapMask) + // The renderable Game Object that is being used for the bitmap mask + var bitmapMask = mask.bitmapMask; + + if (bitmapMask && gl) { // Return to default framebuffer renderer.setFramebuffer(null); diff --git a/src/renderer/webgl/pipelines/FlatTintPipeline.js b/src/renderer/webgl/pipelines/FlatTintPipeline.js deleted file mode 100644 index 9063e3814..000000000 --- a/src/renderer/webgl/pipelines/FlatTintPipeline.js +++ /dev/null @@ -1,1163 +0,0 @@ -/** - * @author Richard Davey - * @author Felipe Alfonso <@bitnenfer> - * @copyright 2018 Photon Storm Ltd. - * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} - */ - -var Class = require('../../../utils/Class'); -var Commands = require('../../../gameobjects/graphics/Commands'); -var Earcut = require('../../../geom/polygon/Earcut'); -var ModelViewProjection = require('./components/ModelViewProjection'); -var ShaderSourceFS = require('../shaders/FlatTint-frag.js'); -var ShaderSourceVS = require('../shaders/FlatTint-vert.js'); -var Utils = require('../Utils'); -var WebGLPipeline = require('../WebGLPipeline'); - -var Point = function (x, y, width, rgb, alpha) -{ - this.x = x; - this.y = y; - this.width = width; - this.rgb = rgb; - this.alpha = alpha; -}; - -var Path = function (x, y, width, rgb, alpha) -{ - this.points = []; - this.pointsLength = 1; - this.points[0] = new Point(x, y, width, rgb, alpha); -}; - -var currentMatrix = new Float32Array([ 1, 0, 0, 1, 0, 0 ]); -var matrixStack = new Float32Array(6 * 1000); -var matrixStackLength = 0; -var pathArray = []; - -/** - * @classdesc - * The FlatTintPipeline is used for rendering flat colored shapes. - * Mostly used by the Graphics game object. - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - * - * @class FlatTintPipeline - * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines - * @constructor - * @since 3.0.0 - * - * @param {object} config - Used for overriding shader an pipeline properties if extending this pipeline. - */ -var FlatTintPipeline = new Class({ - - Extends: WebGLPipeline, - - Mixins: [ - ModelViewProjection - ], - - initialize: - - function FlatTintPipeline (config) - { - WebGLPipeline.call(this, { - game: config.game, - renderer: config.renderer, - gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapcity ? config.vertexCapacity : 12000), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2 + - Uint8Array.BYTES_PER_ELEMENT * 4), - - attributes: [ - { - name: 'inPosition', - size: 2, - type: config.renderer.gl.FLOAT, - normalized: false, - offset: 0 - }, - { - name: 'inTint', - size: 4, - type: config.renderer.gl.UNSIGNED_BYTE, - normalized: true, - offset: Float32Array.BYTES_PER_ELEMENT * 2 - } - ] - }); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#vertexViewF32 - * @type {Float32Array} - * @since 3.0.0 - */ - this.vertexViewF32 = new Float32Array(this.vertexData); - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#vertexViewU32 - * @type {Uint32Array} - * @since 3.0.0 - */ - this.vertexViewU32 = new Uint32Array(this.vertexData); - - /** - * Used internally to draw triangles - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#tempTriangle - * @type {array} - * @since 3.0.0 - */ - this.tempTriangle = [ - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0}, - {x: 0, y: 0, width: 0, rgb: 0xFFFFFF, alpha: 1.0} - ]; - - /** - * Used internally for triangulating a polygon - * - * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#polygonCache - * @type {array} - * @default [] - * @since 3.0.0 - */ - this.polygonCache = []; - - this.mvpInit(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - this.mvpUpdate(); - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); - - return this; - }, - - /** - * Pushes a rectangle into the vertex batch - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillRect - * @since 3.0.0 - * - * @param {number} srcX - Graphics horizontal component for translation - * @param {number} srcY - Graphics vertical component for translation - * @param {number} srcScaleX - Graphics horizontal component for scale - * @param {number} srcScaleY - Graphics vertical component for scale - * @param {number} srcRotation - Graphics rotation - * @param {number} x - Horiztonal top left coordinate of the rectangle - * @param {number} y - Vertical top left coordinate of the rectangle - * @param {number} width - Width of the rectangle - * @param {number} height - Height of the rectangle - * @param {integer} fillColor - RGB color packed as a uint - * @param {number} fillAlpha - Alpha represented as float - * @param {number} a1 - Matrix stack top a component - * @param {number} b1 - Matrix stack top b component - * @param {number} c1 - Matrix stack top c component - * @param {number} d1 - Matrix stack top d component - * @param {number} e1 - Matrix stack top e component - * @param {number} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillRect: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x, y, width, height, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = this.vertexCount * this.vertexComponentCount; - var xw = x + width; - var yh = y + height; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tx0 = x * a + y * c + e; - var ty0 = x * b + y * d + f; - var tx1 = x * a + yh * c + e; - var ty1 = x * b + yh * d + f; - var tx2 = xw * a + yh * c + e; - var ty2 = xw * b + yh * d + f; - var tx3 = xw * a + y * c + e; - var ty3 = xw * b + y * d + f; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - - vertexViewF32[vertexOffset + 9] = tx0; - vertexViewF32[vertexOffset + 10] = ty0; - vertexViewU32[vertexOffset + 11] = tint; - - vertexViewF32[vertexOffset + 12] = tx2; - vertexViewF32[vertexOffset + 13] = ty2; - vertexViewU32[vertexOffset + 14] = tint; - - vertexViewF32[vertexOffset + 15] = tx3; - vertexViewF32[vertexOffset + 16] = ty3; - vertexViewU32[vertexOffset + 17] = tint; - - this.vertexCount += 6; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillTriangle - * @since 3.0.0 - * - * @param {number} srcX - Graphics horizontal component for translation - * @param {number} srcY - Graphics vertical component for translation - * @param {number} srcScaleX - Graphics horizontal component for scale - * @param {number} srcScaleY - Graphics vertical component for scale - * @param {number} srcRotation - Graphics rotation - * @param {number} x0 - Point 0 x coordinate - * @param {number} y0 - Point 0 y coordinate - * @param {number} x1 - Point 1 x coordinate - * @param {number} y1 - Point 1 y coordinate - * @param {number} x2 - Point 2 x coordinate - * @param {number} y2 - Point 2 y coordinate - * @param {integer} fillColor - RGB color packed as a uint - * @param {number} fillAlpha - Alpha represented as float - * @param {number} a1 - Matrix stack top a component - * @param {number} b1 - Matrix stack top b component - * @param {number} c1 - Matrix stack top c component - * @param {number} d1 - Matrix stack top d component - * @param {number} e1 - Matrix stack top e component - * @param {number} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 3 > this.vertexCapacity) - { - this.flush(); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = this.vertexCount * this.vertexComponentCount; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tx0 = x0 * a + y0 * c + e; - var ty0 = x0 * b + y0 * d + f; - var tx1 = x1 * a + y1 * c + e; - var ty1 = x1 * b + y1 * d + f; - var tx2 = x2 * a + y2 * c + e; - var ty2 = x2 * b + y2 * d + f; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - - this.vertexCount += 3; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokeTriangle - * @since 3.0.0 - * - * @param {number} srcX - Graphics horizontal component for translation - * @param {number} srcY - Graphics vertical component for translation - * @param {number} srcScaleX - Graphics horizontal component for scale - * @param {number} srcScaleY - Graphics vertical component for scale - * @param {number} srcRotation - Graphics rotation - * @param {number} x0 - [description] - * @param {number} y0 - [description] - * @param {number} x1 - [description] - * @param {number} y1 - [description] - * @param {number} x2 - [description] - * @param {number} y2 - [description] - * @param {number} lineWidth - Size of the line as a float value - * @param {integer} lineColor - RGB color packed as a uint - * @param {number} lineAlpha - Alpha represented as float - * @param {number} a - Matrix stack top a component - * @param {number} b - Matrix stack top b component - * @param {number} c - Matrix stack top c component - * @param {number} d - Matrix stack top d component - * @param {number} e - Matrix stack top e component - * @param {number} f - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchStrokeTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, currentMatrix) - { - var tempTriangle = this.tempTriangle; - - tempTriangle[0].x = x0; - tempTriangle[0].y = y0; - tempTriangle[0].width = lineWidth; - tempTriangle[0].rgb = lineColor; - tempTriangle[0].alpha = lineAlpha; - tempTriangle[1].x = x1; - tempTriangle[1].y = y1; - tempTriangle[1].width = lineWidth; - tempTriangle[1].rgb = lineColor; - tempTriangle[1].alpha = lineAlpha; - tempTriangle[2].x = x2; - tempTriangle[2].y = y2; - tempTriangle[2].width = lineWidth; - tempTriangle[2].rgb = lineColor; - tempTriangle[2].alpha = lineAlpha; - tempTriangle[3].x = x0; - tempTriangle[3].y = y0; - tempTriangle[3].width = lineWidth; - tempTriangle[3].rgb = lineColor; - tempTriangle[3].alpha = lineAlpha; - - this.batchStrokePath( - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - tempTriangle, lineWidth, lineColor, lineAlpha, - a, b, c, d, e, f, - false, - currentMatrix - ); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillPath - * @since 3.0.0 - * - * @param {number} srcX - Graphics horizontal component for translation - * @param {number} srcY - Graphics vertical component for translation - * @param {number} srcScaleX - Graphics horizontal component for scale - * @param {number} srcScaleY - Graphics vertical component for scale - * @param {number} srcRotation - Graphics rotation - * @param {number} path - Collection of points that represent the path - * @param {integer} fillColor - RGB color packed as a uint - * @param {number} fillAlpha - Alpha represented as float - * @param {number} a1 - Matrix stack top a component - * @param {number} b1 - Matrix stack top b component - * @param {number} c1 - Matrix stack top c component - * @param {number} d1 - Matrix stack top d component - * @param {number} e1 - Matrix stack top e component - * @param {number} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchFillPath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - var length = path.length; - var polygonCache = this.polygonCache; - var polygonIndexArray; - var point; - var v0, v1, v2; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset = 0; - var x0, y0, x1, y1, x2, y2; - var tx0, ty0, tx1, ty1, tx2, ty2; - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha); - - for (var pathIndex = 0; pathIndex < length; ++pathIndex) - { - point = path[pathIndex]; - polygonCache.push(point.x, point.y); - } - - polygonIndexArray = Earcut(polygonCache); - length = polygonIndexArray.length; - - for (var index = 0; index < length; index += 3) - { - v0 = polygonIndexArray[index + 0] * 2; - v1 = polygonIndexArray[index + 1] * 2; - v2 = polygonIndexArray[index + 2] * 2; - - if (this.vertexCount + 3 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - x0 = polygonCache[v0 + 0]; - y0 = polygonCache[v0 + 1]; - x1 = polygonCache[v1 + 0]; - y1 = polygonCache[v1 + 1]; - x2 = polygonCache[v2 + 0]; - y2 = polygonCache[v2 + 1]; - - tx0 = x0 * a + y0 * c + e; - ty0 = x0 * b + y0 * d + f; - tx1 = x1 * a + y1 * c + e; - ty1 = x1 * b + y1 * d + f; - tx2 = x2 * a + y2 * c + e; - ty2 = x2 * b + y2 * d + f; - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewU32[vertexOffset + 2] = tint; - - vertexViewF32[vertexOffset + 3] = tx1; - vertexViewF32[vertexOffset + 4] = ty1; - vertexViewU32[vertexOffset + 5] = tint; - - vertexViewF32[vertexOffset + 6] = tx2; - vertexViewF32[vertexOffset + 7] = ty2; - vertexViewU32[vertexOffset + 8] = tint; - - this.vertexCount += 3; - } - - polygonCache.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokePath - * @since 3.0.0 - * - * @param {number} srcX - Graphics horizontal component for translation - * @param {number} srcY - Graphics vertical component for translation - * @param {number} srcScaleX - Graphics horizontal component for scale - * @param {number} srcScaleY - Graphics vertical component for scale - * @param {number} srcRotation - Graphics rotation - * @param {array} path - [description] - * @param {number} lineWidth - [description] - * @param {integer} lineColor - RGB color packed as a uint - * @param {number} lineAlpha - Alpha represented as float - * @param {number} a - Matrix stack top a component - * @param {number} b - Matrix stack top b component - * @param {number} c - Matrix stack top c component - * @param {number} d - Matrix stack top d component - * @param {number} e - Matrix stack top e component - * @param {number} f - Matrix stack top f component - * @param {boolean} isLastPath - Indicates if the path should be closed - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchStrokePath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, isLastPath, currentMatrix) - { - this.renderer.setPipeline(this); - - var point0, point1; - var pathLength = path.length; - var polylines = this.polygonCache; - var last, curr; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var vertexOffset; - var line; - var getTint = Utils.getTintAppendFloatAlphaAndSwap; - - for (var pathIndex = 0; pathIndex + 1 < pathLength; pathIndex += 1) - { - point0 = path[pathIndex]; - point1 = path[pathIndex + 1]; - - line = this.batchLine( - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - point0.x, point0.y, - point1.x, point1.y, - point0.width / 2, point1.width / 2, - point0.rgb, point1.rgb, lineAlpha, - a, b, c, d, e, f, - currentMatrix - ); - - polylines.push(line); - } - - /* Render joints */ - for (var index = 1, polylinesLength = polylines.length; index < polylinesLength; ++index) - { - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - last = polylines[index - 1] || polylines[polylinesLength - 1]; - curr = polylines[index]; - vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = last[3 * 2 + 0]; - vertexViewF32[vertexOffset + 1] = last[3 * 2 + 1]; - vertexViewU32[vertexOffset + 2] = getTint(last[3 * 2 + 2], lineAlpha); - - vertexViewF32[vertexOffset + 3] = last[3 * 0 + 0]; - vertexViewF32[vertexOffset + 4] = last[3 * 0 + 1]; - vertexViewU32[vertexOffset + 5] = getTint(last[3 * 0 + 2], lineAlpha); - - vertexViewF32[vertexOffset + 6] = curr[3 * 3 + 0]; - vertexViewF32[vertexOffset + 7] = curr[3 * 3 + 1]; - vertexViewU32[vertexOffset + 8] = getTint(curr[3 * 3 + 2], lineAlpha); - - vertexViewF32[vertexOffset + 9] = last[3 * 0 + 0]; - vertexViewF32[vertexOffset + 10] = last[3 * 0 + 1]; - vertexViewU32[vertexOffset + 11] = getTint(last[3 * 0 + 2], lineAlpha); - - vertexViewF32[vertexOffset + 12] = last[3 * 2 + 0]; - vertexViewF32[vertexOffset + 13] = last[3 * 2 + 1]; - vertexViewU32[vertexOffset + 14] = getTint(last[3 * 2 + 2], lineAlpha); - - vertexViewF32[vertexOffset + 15] = curr[3 * 1 + 0]; - vertexViewF32[vertexOffset + 16] = curr[3 * 1 + 1]; - vertexViewU32[vertexOffset + 17] = getTint(curr[3 * 1 + 2], lineAlpha); - - this.vertexCount += 6; - } - - polylines.length = 0; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchLine - * @since 3.0.0 - * - * @param {number} srcX - Graphics horizontal component for translation - * @param {number} srcY - Graphics vertical component for translation - * @param {number} srcScaleX - Graphics horizontal component for scale - * @param {number} srcScaleY - Graphics vertical component for scale - * @param {number} srcRotation - Graphics rotation - * @param {number} ax - X coordinate to the start of the line - * @param {number} ay - Y coordinate to the start of the line - * @param {number} bx - X coordinate to the end of the line - * @param {number} by - Y coordinate to the end of the line - * @param {number} aLineWidth - Width of the start of the line - * @param {number} bLineWidth - Width of the end of the line - * @param {integer} aLineColor - RGB color packed as a uint - * @param {integer} bLineColor - RGB color packed as a uint - * @param {number} lineAlpha - Alpha represented as float - * @param {number} a1 - Matrix stack top a component - * @param {number} b1 - Matrix stack top b component - * @param {number} c1 - Matrix stack top c component - * @param {number} d1 - Matrix stack top d component - * @param {number} e1 - Matrix stack top e component - * @param {number} f1 - Matrix stack top f component - * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers - */ - batchLine: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, ax, ay, bx, by, aLineWidth, bLineWidth, aLineColor, bLineColor, lineAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) - { - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var a0 = currentMatrix[0]; - var b0 = currentMatrix[1]; - var c0 = currentMatrix[2]; - var d0 = currentMatrix[3]; - var e0 = currentMatrix[4]; - var f0 = currentMatrix[5]; - var a = a1 * a0 + b1 * c0; - var b = a1 * b0 + b1 * d0; - var c = c1 * a0 + d1 * c0; - var d = c1 * b0 + d1 * d0; - var e = e1 * a0 + f1 * c0 + e0; - var f = e1 * b0 + f1 * d0 + f0; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var dx = bx - ax; - var dy = by - ay; - var len = Math.sqrt(dx * dx + dy * dy); - var al0 = aLineWidth * (by - ay) / len; - var al1 = aLineWidth * (ax - bx) / len; - var bl0 = bLineWidth * (by - ay) / len; - var bl1 = bLineWidth * (ax - bx) / len; - var lx0 = bx - bl0; - var ly0 = by - bl1; - var lx1 = ax - al0; - var ly1 = ay - al1; - var lx2 = bx + bl0; - var ly2 = by + bl1; - var lx3 = ax + al0; - var ly3 = ay + al1; - var x0 = lx0 * a + ly0 * c + e; - var y0 = lx0 * b + ly0 * d + f; - var x1 = lx1 * a + ly1 * c + e; - var y1 = lx1 * b + ly1 * d + f; - var x2 = lx2 * a + ly2 * c + e; - var y2 = lx2 * b + ly2 * d + f; - var x3 = lx3 * a + ly3 * c + e; - var y3 = lx3 * b + ly3 * d + f; - var getTint = Utils.getTintAppendFloatAlphaAndSwap; - var aTint = getTint(aLineColor, lineAlpha); - var bTint = getTint(bLineColor, lineAlpha); - var vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = x0; - vertexViewF32[vertexOffset + 1] = y0; - vertexViewU32[vertexOffset + 2] = bTint; - - vertexViewF32[vertexOffset + 3] = x1; - vertexViewF32[vertexOffset + 4] = y1; - vertexViewU32[vertexOffset + 5] = aTint; - - vertexViewF32[vertexOffset + 6] = x2; - vertexViewF32[vertexOffset + 7] = y2; - vertexViewU32[vertexOffset + 8] = bTint; - - vertexViewF32[vertexOffset + 9] = x1; - vertexViewF32[vertexOffset + 10] = y1; - vertexViewU32[vertexOffset + 11] = aTint; - - vertexViewF32[vertexOffset + 12] = x3; - vertexViewF32[vertexOffset + 13] = y3; - vertexViewU32[vertexOffset + 14] = aTint; - - vertexViewF32[vertexOffset + 15] = x2; - vertexViewF32[vertexOffset + 16] = y2; - vertexViewU32[vertexOffset + 17] = bTint; - - this.vertexCount += 6; - - return [ - x0, y0, bLineColor, - x1, y1, aLineColor, - x2, y2, bLineColor, - x3, y3, aLineColor - ]; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchGraphics - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchGraphics: function (graphics, camera, parentTransformMatrix) - { - if (graphics.commandBuffer.length <= 0) { return; } - - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var cameraScrollX = camera.scrollX * graphics.scrollFactorX; - var cameraScrollY = camera.scrollY * graphics.scrollFactorY; - var srcX = graphics.x; - var srcY = graphics.y; - var srcScaleX = graphics.scaleX; - var srcScaleY = graphics.scaleY; - var srcRotation = graphics.rotation; - var commands = graphics.commandBuffer; - var alpha = camera.alpha * graphics.alpha; - var lineAlpha = 1.0; - var fillAlpha = 1.0; - var lineColor = 0; - var fillColor = 0; - var lineWidth = 1.0; - var cameraMatrix = camera.matrix.matrix; - var lastPath = null; - var iteration = 0; - var iterStep = 0.01; - var tx = 0; - var ty = 0; - var ta = 0; - var x = 0; - var y = 0; - var radius = 0; - var startAngle = 0; - var endAngle = 0; - var anticlockwise = 0; - var path = null; - var sin = Math.sin; - var cos = Math.cos; - var PI2 = Math.PI * 2; - var sr = sin(srcRotation); - var cr = cos(srcRotation); - var sra = cr * srcScaleX; - var srb = sr * srcScaleX; - var src = -sr * srcScaleY; - var srd = cr * srcScaleY; - var sre = srcX; - var srf = srcY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var pathArrayIndex; - var pathArrayLength; - - pathArray.length = 0; - - for (var cmdIndex = 0, cmdLength = commands.length; cmdIndex < cmdLength; ++cmdIndex) - { - cmd = commands[cmdIndex]; - - switch (cmd) - { - case Commands.ARC: - iteration = 0; - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - radius = commands[cmdIndex + 3]; - startAngle = commands[cmdIndex + 4]; - endAngle = commands[cmdIndex + 5]; - anticlockwise = commands[cmdIndex + 6]; - - if (lastPath === null) - { - lastPath = new Path(x + cos(startAngle) * radius, y + sin(startAngle) * radius, lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - iteration += iterStep; - } - - endAngle -= startAngle; - - if (anticlockwise) - { - if (endAngle < -PI2) - { - endAngle = -PI2; - } - else if (endAngle > 0) - { - endAngle = -PI2 + endAngle % PI2; - } - } - else if (endAngle > PI2) - { - endAngle = PI2; - } - else if (endAngle < 0) - { - endAngle = PI2 + endAngle % PI2; - } - - while (iteration < 1) - { - ta = endAngle * iteration + startAngle; - tx = x + cos(ta) * radius; - ty = y + sin(ta) * radius; - - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); - - iteration += iterStep; - } - - ta = endAngle + startAngle; - tx = x + cos(ta) * radius; - ty = y + sin(ta) * radius; - - lastPath.points.push(new Point(tx, ty, lineWidth, lineColor, lineAlpha * alpha)); - - cmdIndex += 6; - break; - - case Commands.LINE_STYLE: - lineWidth = commands[cmdIndex + 1]; - lineColor = commands[cmdIndex + 2]; - lineAlpha = commands[cmdIndex + 3]; - cmdIndex += 3; - break; - - case Commands.FILL_STYLE: - fillColor = commands[cmdIndex + 1]; - fillAlpha = commands[cmdIndex + 2]; - cmdIndex += 2; - break; - - case Commands.BEGIN_PATH: - pathArray.length = 0; - lastPath = null; - break; - - case Commands.CLOSE_PATH: - if (lastPath && lastPath.points.length) - { - lastPath.points.push(lastPath.points[0]); - } - break; - - case Commands.FILL_PATH: - for (pathArrayIndex = 0, pathArrayLength = pathArray.length; - pathArrayIndex < pathArrayLength; - ++pathArrayIndex) - { - this.batchFillPath( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - pathArray[pathArrayIndex].points, - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - } - break; - - case Commands.STROKE_PATH: - for (pathArrayIndex = 0, pathArrayLength = pathArray.length; - pathArrayIndex < pathArrayLength; - ++pathArrayIndex) - { - path = pathArray[pathArrayIndex]; - this.batchStrokePath( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - path.points, - lineWidth, - lineColor, - lineAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - path === this._lastPath, - currentMatrix - ); - } - break; - - case Commands.FILL_RECT: - this.batchFillRect( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Rectangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 4; - break; - - case Commands.FILL_TRIANGLE: - this.batchFillTriangle( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Triangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5], - commands[cmdIndex + 6], - fillColor, - fillAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 6; - break; - - case Commands.STROKE_TRIANGLE: - this.batchStrokeTriangle( - - /* Graphics Game Object Properties */ - srcX, srcY, srcScaleX, srcScaleY, srcRotation, - - /* Triangle properties */ - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5], - commands[cmdIndex + 6], - lineWidth, - lineColor, - lineAlpha * alpha, - - /* Transform */ - mva, mvb, mvc, mvd, mve, mvf, - currentMatrix - ); - - cmdIndex += 6; - break; - - case Commands.LINE_TO: - if (lastPath !== null) - { - lastPath.points.push(new Point(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha)); - } - else - { - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - } - cmdIndex += 2; - break; - - case Commands.MOVE_TO: - lastPath = new Path(commands[cmdIndex + 1], commands[cmdIndex + 2], lineWidth, lineColor, lineAlpha * alpha); - pathArray.push(lastPath); - cmdIndex += 2; - break; - - case Commands.LINE_FX_TO: - if (lastPath !== null) - { - lastPath.points.push(new Point( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - )); - } - else - { - lastPath = new Path( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - ); - pathArray.push(lastPath); - } - cmdIndex += 5; - break; - - case Commands.MOVE_FX_TO: - lastPath = new Path( - commands[cmdIndex + 1], - commands[cmdIndex + 2], - commands[cmdIndex + 3], - commands[cmdIndex + 4], - commands[cmdIndex + 5] * alpha - ); - pathArray.push(lastPath); - cmdIndex += 5; - break; - - case Commands.SAVE: - matrixStack[matrixStackLength + 0] = currentMatrix[0]; - matrixStack[matrixStackLength + 1] = currentMatrix[1]; - matrixStack[matrixStackLength + 2] = currentMatrix[2]; - matrixStack[matrixStackLength + 3] = currentMatrix[3]; - matrixStack[matrixStackLength + 4] = currentMatrix[4]; - matrixStack[matrixStackLength + 5] = currentMatrix[5]; - matrixStackLength += 6; - break; - - case Commands.RESTORE: - matrixStackLength -= 6; - currentMatrix[0] = matrixStack[matrixStackLength + 0]; - currentMatrix[1] = matrixStack[matrixStackLength + 1]; - currentMatrix[2] = matrixStack[matrixStackLength + 2]; - currentMatrix[3] = matrixStack[matrixStackLength + 3]; - currentMatrix[4] = matrixStack[matrixStackLength + 4]; - currentMatrix[5] = matrixStack[matrixStackLength + 5]; - break; - - case Commands.TRANSLATE: - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - currentMatrix[4] = currentMatrix[0] * x + currentMatrix[2] * y + currentMatrix[4]; - currentMatrix[5] = currentMatrix[1] * x + currentMatrix[3] * y + currentMatrix[5]; - cmdIndex += 2; - break; - - case Commands.SCALE: - x = commands[cmdIndex + 1]; - y = commands[cmdIndex + 2]; - currentMatrix[0] *= x; - currentMatrix[1] *= x; - currentMatrix[2] *= y; - currentMatrix[3] *= y; - cmdIndex += 2; - break; - - case Commands.ROTATE: - y = commands[cmdIndex + 1]; - x = sin(y); - y = cos(y); - sra = currentMatrix[0]; - srb = currentMatrix[1]; - src = currentMatrix[2]; - srd = currentMatrix[3]; - currentMatrix[0] = y * sra + x * src; - currentMatrix[1] = y * srb + x * srd; - currentMatrix[2] = -x * sra + y * src; - currentMatrix[3] = -x * srb + y * srd; - cmdIndex += 1; - break; - - default: - // eslint-disable-next-line no-console - console.error('Phaser: Invalid Graphics Command ID ' + cmd); - break; - } - } - } - -}); - -module.exports = FlatTintPipeline; diff --git a/src/renderer/webgl/pipelines/ForwardDiffuseLightPipeline.js b/src/renderer/webgl/pipelines/ForwardDiffuseLightPipeline.js index eb8a0bacf..9925b61d2 100644 --- a/src/renderer/webgl/pipelines/ForwardDiffuseLightPipeline.js +++ b/src/renderer/webgl/pipelines/ForwardDiffuseLightPipeline.js @@ -19,11 +19,11 @@ var LIGHT_COUNT = 10; * * @class ForwardDiffuseLightPipeline * @extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines + * @memberof Phaser.Renderer.WebGL.Pipelines * @constructor * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration of the pipeline, same as the {@link Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline}. The fragment shader will be replaced with the lighting shader. */ var ForwardDiffuseLightPipeline = new Class({ @@ -33,21 +33,64 @@ var ForwardDiffuseLightPipeline = new Class({ function ForwardDiffuseLightPipeline (config) { + LIGHT_COUNT = config.maxLights; + config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString()); TextureTintPipeline.call(this, config); + + /** + * Default normal map texture to use. + * + * @name Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#defaultNormalMap + * @type {Phaser.Texture.Frame} + * @private + * @since 3.11.0 + */ + this.defaultNormalMap; + + /** + * Inverse rotation matrix for normal map rotations. + * + * @name Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#inverseRotationMatrix + * @type {Float32Array} + * @private + * @since 3.16.0 + */ + this.inverseRotationMatrix = new Float32Array([ + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 + ]); }, /** - * This function binds it's base class resources and this lights 2D resources. + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#boot + * @override + * @since 3.11.0 + */ + boot: function () + { + this.defaultNormalMap = this.game.textures.getFrame('__DEFAULT'); + }, + + /** + * This function binds its base class resources and this lights 2D resources. * * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onBind * @override * @since 3.0.0 + * + * @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any. * - * @return {Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline} [description] + * @return {this} This WebGLPipeline instance. */ - onBind: function () + onBind: function (gameObject) { TextureTintPipeline.prototype.onBind.call(this); @@ -59,6 +102,11 @@ var ForwardDiffuseLightPipeline = new Class({ renderer.setInt1(program, 'uNormSampler', 1); renderer.setFloat2(program, 'uResolution', this.width, this.height); + if (gameObject) + { + this.setNormalMap(gameObject); + } + return this; }, @@ -68,10 +116,10 @@ var ForwardDiffuseLightPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onRender * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Scene} scene - The Scene being rendered. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Scene Camera being rendered with. * - * @return {Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline} [description] + * @return {this} This WebGLPipeline instance. */ onRender: function (scene, camera) { @@ -128,114 +176,298 @@ var ForwardDiffuseLightPipeline = new Class({ }, /** - * [description] + * Generic function for batching a textured quad * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawStaticTilemapLayer - * @override + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture * @since 3.0.0 * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject + * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad + * @param {integer} textureWidth - Real texture width + * @param {integer} textureHeight - Real texture height + * @param {number} srcX - X coordinate of the quad + * @param {number} srcY - Y coordinate of the quad + * @param {number} srcWidth - Width of the quad + * @param {number} srcHeight - Height of the quad + * @param {number} scaleX - X component of scale + * @param {number} scaleY - Y component of scale + * @param {number} rotation - Rotation of the quad + * @param {boolean} flipX - Indicates if the quad is horizontally flipped + * @param {boolean} flipY - Indicates if the quad is vertically flipped + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll + * @param {number} displayOriginX - Horizontal origin in pixels + * @param {number} displayOriginY - Vertical origin in pixels + * @param {number} frameX - X coordinate of the texture frame + * @param {number} frameY - Y coordinate of the texture frame + * @param {number} frameWidth - Width of the texture frame + * @param {number} frameHeight - Height of the texture frame + * @param {integer} tintTL - Tint for top left + * @param {integer} tintTR - Tint for top right + * @param {integer} tintBL - Tint for bottom left + * @param {integer} tintBR - Tint for bottom right + * @param {number} tintEffect - The tint effect (0 for additive, 1 for replacement) + * @param {number} uOffset - Horizontal offset on texture coordinate + * @param {number} vOffset - Vertical offset on texture coordinate + * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container */ - drawStaticTilemapLayer: function (tilemap, camera, parentTransformMatrix) + batchTexture: function ( + gameObject, + texture, + textureWidth, textureHeight, + srcX, srcY, + srcWidth, srcHeight, + scaleX, scaleY, + rotation, + flipX, flipY, + scrollFactorX, scrollFactorY, + displayOriginX, displayOriginY, + frameX, frameY, frameWidth, frameHeight, + tintTL, tintTR, tintBL, tintBR, tintEffect, + uOffset, vOffset, + camera, + parentTransformMatrix) { if (!this.active) { return; } - var normalTexture = tilemap.tileset.image.dataSource[0]; + this.renderer.setPipeline(this); - if (normalTexture) + var normalTexture; + + if (gameObject.displayTexture) { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera, parentTransformMatrix); + normalTexture = gameObject.displayTexture.dataSource[gameObject.displayFrame.sourceIndex]; + } + else if (gameObject.texture) + { + normalTexture = gameObject.texture.dataSource[gameObject.frame.sourceIndex]; + } + else if (gameObject.tileset) + { + normalTexture = gameObject.tileset.image.dataSource[0]; + } + + if (!normalTexture) + { + console.warn('Normal map missing or invalid'); + return; + } + + this.setTexture2D(normalTexture.glTexture, 1); + this.setNormalMapRotation(rotation); + + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; + + var u0 = (frameX / textureWidth) + uOffset; + var v0 = (frameY / textureHeight) + vOffset; + var u1 = (frameX + frameWidth) / textureWidth + uOffset; + var v1 = (frameY + frameHeight) / textureHeight + vOffset; + + var width = srcWidth; + var height = srcHeight; + + // var x = -displayOriginX + frameX; + // var y = -displayOriginY + frameY; + + var x = -displayOriginX; + var y = -displayOriginY; + + if (gameObject.isCropped) + { + var crop = gameObject._crop; + + width = crop.width; + height = crop.height; + + srcWidth = crop.width; + srcHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + var ox = frameX; + var oy = frameY; + + if (flipX) + { + ox = (frameWidth - crop.x - crop.width); + } + + if (flipY && !texture.isRenderTexture) + { + oy = (frameHeight - crop.y - crop.height); + } + + u0 = (ox / textureWidth) + uOffset; + v0 = (oy / textureHeight) + vOffset; + u1 = (ox + crop.width) / textureWidth + uOffset; + v1 = (oy + crop.height) / textureHeight + vOffset; + + x = -displayOriginX + frameX; + y = -displayOriginY + frameY; + } + + // Invert the flipY if this is a RenderTexture + flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); + + if (flipX) + { + width *= -1; + x += srcWidth; + } + + if (flipY) + { + height *= -1; + y += srcHeight; + } + + // Do we need this? (doubt it) + // if (camera.roundPixels) + // { + // x |= 0; + // y |= 0; + // } + + var xw = x + width; + var yh = y + height; + + spriteMatrix.applyITRS(srcX, srcY, rotation, scaleX, scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * scrollFactorX, -camera.scrollY * scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = srcX; + spriteMatrix.f = srcY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); } else { - console.warn('Normal map texture missing for using Light2D pipeline. StaticTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera, parentTransformMatrix); + spriteMatrix.e -= camera.scrollX * scrollFactorX; + spriteMatrix.f -= camera.scrollY * scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 = Math.round(tx0); + ty0 = Math.round(ty0); + + tx1 = Math.round(tx1); + ty1 = Math.round(ty1); + + tx2 = Math.round(tx2); + ty2 = Math.round(ty2); + + tx3 = Math.round(tx3); + ty3 = Math.round(ty3); + } + + this.setTexture2D(texture, 0); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0); }, /** - * [description] + * Sets the Game Objects normal map as the active texture. * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#setNormalMap + * @since 3.11.0 * + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to update. */ - drawEmitterManager: function (emitterManager, camera, parentTransformMatrix) + setNormalMap: function (gameObject) { - if (!this.active) + if (!this.active || !gameObject) { return; } - var normalTexture = emitterManager.texture.dataSource[emitterManager.frame.sourceIndex]; + var normalTexture; - if (normalTexture) + if (gameObject.texture) { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera, parentTransformMatrix); + normalTexture = gameObject.texture.dataSource[gameObject.frame.sourceIndex]; } - else + + if (!normalTexture) { - console.warn('Normal map texture missing for using Light2D pipeline. EmitterManager rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera, parentTransformMatrix); + normalTexture = this.defaultNormalMap; } + + this.setTexture2D(normalTexture.glTexture, 1); + + this.renderer.setPipeline(gameObject.defaultPipeline); }, /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * + * Rotates the normal map vectors inversely by the given angle. + * Only works in 2D space. + * + * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#setNormalMapRotation + * @since 3.16.0 + * + * @param {number} rotation - The angle of rotation in radians. */ - drawBlitter: function (blitter, camera, parentTransformMatrix) + setNormalMapRotation: function (rotation) { - if (!this.active) - { - return; - } + var inverseRotationMatrix = this.inverseRotationMatrix; - var normalTexture = blitter.texture.dataSource[blitter.frame.sourceIndex]; - - if (normalTexture) + if (rotation) { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera, parentTransformMatrix); + var rot = -rotation; + var c = Math.cos(rot); + var s = Math.sin(rot); + + inverseRotationMatrix[1] = s; + inverseRotationMatrix[3] = -s; + inverseRotationMatrix[0] = inverseRotationMatrix[4] = c; } else { - console.warn('Normal map texture missing for using Light2D pipeline. Blitter rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera, parentTransformMatrix); + inverseRotationMatrix[0] = inverseRotationMatrix[4] = 1; + inverseRotationMatrix[1] = inverseRotationMatrix[3] = 0; } + + this.renderer.setMatrix3(this.program, 'uInverseRotationMatrix', false, inverseRotationMatrix); }, /** - * [description] + * Takes a Sprite Game Object, or any object that extends it, which has a normal texture and adds it to the batch. * * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchSprite * @since 3.0.0 * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * + * @param {Phaser.GameObjects.Sprite} sprite - The texture-based Game Object to add to the batch. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the rendering transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - The transform matrix of the parent container, if set. */ batchSprite: function (sprite, camera, parentTransformMatrix) { @@ -249,208 +481,12 @@ var ForwardDiffuseLightPipeline = new Class({ if (normalTexture) { this.renderer.setPipeline(this); + this.setTexture2D(normalTexture.glTexture, 1); + this.setNormalMapRotation(sprite.rotation); + TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera, parentTransformMatrix); } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Sprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchMesh: function (mesh, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = mesh.texture.dataSource[mesh.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Mesh rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera, parentTransformMatrix); - - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = bitmapText.texture.dataSource[bitmapText.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. BitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var normalTexture = bitmapText.texture.dataSource[bitmapText.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicBitmapText rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchText: function (text, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = text.texture.dataSource[text.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchText.call(this, text, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. Text rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchText(text, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tilemapLayer.tileset.image.dataSource[0]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. DynamicTilemapLayer rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera, parentTransformMatrix); - } - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - */ - batchTileSprite: function (tileSprite, camera, parentTransformMatrix) - { - if (!this.active) - { - return; - } - - var normalTexture = tileSprite.texture.dataSource[tileSprite.frame.sourceIndex]; - - if (normalTexture) - { - this.renderer.setPipeline(this); - this.setTexture2D(normalTexture.glTexture, 1); - TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera, parentTransformMatrix); - } - else - { - console.warn('Normal map texture missing for using Light2D pipeline. TileSprite rendered with default pipeline.'); - this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera, parentTransformMatrix); - } } }); diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index 4f79de15b..9bea5c50c 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -6,9 +6,12 @@ */ var Class = require('../../../utils/Class'); +var Earcut = require('../../../geom/polygon/Earcut'); +var GetFastValue = require('../../../utils/object/GetFastValue'); var ModelViewProjection = require('./components/ModelViewProjection'); var ShaderSourceFS = require('../shaders/TextureTint-frag.js'); var ShaderSourceVS = require('../shaders/TextureTint-vert.js'); +var TransformMatrix = require('../../../gameobjects/components/TransformMatrix'); var Utils = require('../Utils'); var WebGLPipeline = require('../WebGLPipeline'); @@ -28,11 +31,11 @@ var WebGLPipeline = require('../WebGLPipeline'); * * @class TextureTintPipeline * @extends Phaser.Renderer.WebGL.WebGLPipeline - * @memberOf Phaser.Renderer.WebGL.Pipelines + * @memberof Phaser.Renderer.WebGL.Pipelines * @constructor * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration options for this Texture Tint Pipeline, as described above. */ var TextureTintPipeline = new Class({ @@ -46,20 +49,19 @@ var TextureTintPipeline = new Class({ function TextureTintPipeline (config) { + var rendererConfig = config.renderer.config; + + // Vertex Size = attribute size added together (2 + 2 + 1 + 4) + WebGLPipeline.call(this, { game: config.game, renderer: config.renderer, gl: config.renderer.gl, - topology: (config.topology ? config.topology : config.renderer.gl.TRIANGLES), - vertShader: (config.vertShader ? config.vertShader : ShaderSourceVS), - fragShader: (config.fragShader ? config.fragShader : ShaderSourceFS), - vertexCapacity: (config.vertexCapacity ? config.vertexCapacity : 6 * 2000), - - vertexSize: (config.vertexSize ? config.vertexSize : - Float32Array.BYTES_PER_ELEMENT * 2 + - Float32Array.BYTES_PER_ELEMENT * 2 + - Uint8Array.BYTES_PER_ELEMENT * 4), - + topology: GetFastValue(config, 'topology', config.renderer.gl.TRIANGLES), + vertShader: GetFastValue(config, 'vertShader', ShaderSourceVS), + fragShader: GetFastValue(config, 'fragShader', ShaderSourceFS), + vertexCapacity: GetFastValue(config, 'vertexCapacity', 6 * rendererConfig.batchSize), + vertexSize: GetFastValue(config, 'vertexSize', Float32Array.BYTES_PER_ELEMENT * 5 + Uint8Array.BYTES_PER_ELEMENT * 4), attributes: [ { name: 'inPosition', @@ -75,12 +77,19 @@ var TextureTintPipeline = new Class({ normalized: false, offset: Float32Array.BYTES_PER_ELEMENT * 2 }, + { + name: 'inTintEffect', + size: 1, + type: config.renderer.gl.FLOAT, + normalized: false, + offset: Float32Array.BYTES_PER_ELEMENT * 4 + }, { name: 'inTint', size: 4, type: config.renderer.gl.UNSIGNED_BYTE, normalized: true, - offset: Float32Array.BYTES_PER_ELEMENT * 4 + offset: Float32Array.BYTES_PER_ELEMENT * 5 } ] }); @@ -108,10 +117,9 @@ var TextureTintPipeline = new Class({ * * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#maxQuads * @type {integer} - * @default 2000 * @since 3.0.0 */ - this.maxQuads = 2000; + this.maxQuads = rendererConfig.batchSize; /** * Collection of batch information @@ -122,61 +130,229 @@ var TextureTintPipeline = new Class({ */ this.batches = []; + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix1 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix1 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix2 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix2 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix3 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix3 = new TransformMatrix(); + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix4 + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.11.0 + */ + this._tempMatrix4 = new TransformMatrix(); + + /** + * Used internally to draw stroked triangles. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tempTriangle + * @type {array} + * @private + * @since 3.12.0 + */ + this.tempTriangle = [ + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 }, + { x: 0, y: 0, width: 0 } + ]; + + /** + * The tint effect to be applied by the shader in the next geometry draw: + * + * 0 = texture multiplied by color + * 1 = solid color + texture alpha + * 2 = solid color, no texture + * 3 = solid texture, no color + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tintEffect + * @type {number} + * @private + * @since 3.12.0 + */ + this.tintEffect = 2; + + /** + * Cached stroke tint. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#strokeTint + * @type {object} + * @private + * @since 3.12.0 + */ + this.strokeTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; + + /** + * Cached fill tint. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#fillTint + * @type {object} + * @private + * @since 3.12.0 + */ + this.fillTint = { TL: 0, TR: 0, BL: 0, BR: 0 }; + + /** + * Internal texture frame reference. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#currentFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.12.0 + */ + this.currentFrame = { u0: 0, v0: 0, u1: 1, v1: 1 }; + + /** + * Internal path quad cache. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#firstQuad + * @type {array} + * @private + * @since 3.12.0 + */ + this.firstQuad = [ 0, 0, 0, 0, 0 ]; + + /** + * Internal path quad cache. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#prevQuad + * @type {array} + * @private + * @since 3.12.0 + */ + this.prevQuad = [ 0, 0, 0, 0, 0 ]; + + /** + * Used internally for triangulating a polygon. + * + * @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#polygonCache + * @type {array} + * @private + * @since 3.12.0 + */ + this.polygonCache = []; + this.mvpInit(); }, /** - * Assigns a texture to the current batch. If a texture is already set it creates - * a new batch object. + * Called every time the pipeline needs to be used. + * It binds all necessary resources. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#onBind + * @since 3.0.0 + * + * @return {this} This WebGLPipeline instance. + */ + onBind: function () + { + WebGLPipeline.prototype.onBind.call(this); + + this.mvpUpdate(); + + return this; + }, + + /** + * Resizes this pipeline and updates the projection. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#resize + * @since 3.0.0 + * + * @param {number} width - The new width. + * @param {number} height - The new height. + * @param {number} resolution - The resolution. + * + * @return {this} This WebGLPipeline instance. + */ + resize: function (width, height, resolution) + { + WebGLPipeline.prototype.resize.call(this, width, height, resolution); + + this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); + + return this; + }, + + /** + * Assigns a texture to the current batch. If a different texture is already set it creates a new batch object. * * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#setTexture2D * @since 3.1.0 * - * @param {WebGLTexture} texture - WebGLTexture that will be assigned to the current batch. - * @param {integer} textureUnit - Texture unit to which the texture needs to be bound. + * @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch. If not given uses blankTexture. + * @param {integer} [unit=0] - Texture unit to which the texture needs to be bound. * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] + * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This pipeline instance. */ setTexture2D: function (texture, unit) { - if (!texture) + if (texture === undefined) { texture = this.renderer.blankTexture.glTexture; } + if (unit === undefined) { unit = 0; } + + if (this.requireTextureBatch(texture, unit)) { - return this; - } - - var batches = this.batches; - - if (batches.length === 0) - { - this.pushBatch(); - } - - var batch = batches[batches.length - 1]; - - if (unit > 0) - { - if (batch.textures[unit - 1] && - batch.textures[unit - 1] !== texture) - { - this.pushBatch(); - } - - batches[batches.length - 1].textures[unit - 1] = texture; - } - else - { - if (batch.texture !== null && - batch.texture !== texture) - { - this.pushBatch(); - } - - batches[batches.length - 1].texture = texture; + this.pushBatch(texture, unit); } return this; }, + /** + * Checks if the current batch has the same texture and texture unit, or if we need to create a new batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#requireTextureBatch + * @since 3.16.0 + * + * @param {WebGLTexture} texture - WebGLTexture that will be assigned to the current batch. If not given uses blankTexture. + * @param {integer} unit - Texture unit to which the texture needs to be bound. + * + * @return {boolean} `true` if the pipeline needs to create a new batch, otherwise `false`. + */ + requireTextureBatch: function (texture, unit) + { + var batches = this.batches; + var batchLength = batches.length; + + if (batchLength > 0) + { + // If Texture Unit specified, we get the texture from the textures array, otherwise we use the texture property + var currentTexture = (unit > 0) ? batches[batchLength - 1].textures[unit - 1] : batches[batchLength - 1].texture; + + return !(currentTexture === texture); + } + + return true; + }, + /** * Creates a new batch object and pushes it to a batch array. * The batch object contains information relevant to the current @@ -185,25 +361,41 @@ var TextureTintPipeline = new Class({ * * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#pushBatch * @since 3.1.0 + * + * @param {WebGLTexture} texture - Optional WebGLTexture that will be assigned to the created batch. + * @param {integer} unit - Texture unit to which the texture needs to be bound. */ - pushBatch: function () + pushBatch: function (texture, unit) { - var batch = { - first: this.vertexCount, - texture: null, - textures: [] - }; + if (unit === 0) + { + this.batches.push({ + first: this.vertexCount, + texture: texture, + textures: [] + }); + } + else + { + var textures = []; - this.batches.push(batch); + textures[unit - 1] = texture; + + this.batches.push({ + first: this.vertexCount, + texture: null, + textures: textures + }); + } }, /** - * Binds, uploads resources and processes all batches generating draw calls. + * Uploads the vertex data and emits a draw call for the current batch of vertices. * * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#flush - * @since 3.1.0 + * @since 3.0.0 * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This Pipeline. + * @return {this} This WebGLPipeline instance. */ flush: function () { @@ -215,10 +407,11 @@ var TextureTintPipeline = new Class({ this.flushLocked = true; var gl = this.gl; - var renderer = this.renderer; var vertexCount = this.vertexCount; var topology = this.topology; var vertexSize = this.vertexSize; + var renderer = this.renderer; + var batches = this.batches; var batchCount = batches.length; var batchVertexCount = 0; @@ -230,16 +423,20 @@ var TextureTintPipeline = new Class({ if (batchCount === 0 || vertexCount === 0) { this.flushLocked = false; + return this; } gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize)); - for (var index = 0; index < batches.length - 1; ++index) + // Process the TEXTURE BATCHES + + for (var index = 0; index < batchCount - 1; index++) { batch = batches[index]; batchNext = batches[index + 1]; + // Multi-texture check (for non-zero texture units) if (batch.textures.length > 0) { for (textureIndex = 0; textureIndex < batch.textures.length; ++textureIndex) @@ -248,7 +445,7 @@ var TextureTintPipeline = new Class({ if (nTexture) { - renderer.setTexture2D(nTexture, 1 + textureIndex); + renderer.setTexture2D(nTexture, 1 + textureIndex, false); } } @@ -257,14 +454,21 @@ var TextureTintPipeline = new Class({ batchVertexCount = batchNext.first - batch.first; - if (batch.texture === null || batchVertexCount <= 0) { continue; } + // Bail out if texture property is null (i.e. if a texture unit > 0) + if (batch.texture === null || batchVertexCount <= 0) + { + continue; + } + + renderer.setTexture2D(batch.texture, 0, false); - renderer.setTexture2D(batch.texture, 0); gl.drawArrays(topology, batch.first, batchVertexCount); } // Left over data - batch = batches[batches.length - 1]; + batch = batches[batchCount - 1]; + + // Multi-texture check (for non-zero texture units) if (batch.textures.length > 0) { @@ -274,7 +478,7 @@ var TextureTintPipeline = new Class({ if (nTexture) { - renderer.setTexture2D(nTexture, 1 + textureIndex); + renderer.setTexture2D(nTexture, 1 + textureIndex, false); } } @@ -285,1562 +489,382 @@ var TextureTintPipeline = new Class({ if (batch.texture && batchVertexCount > 0) { - renderer.setTexture2D(batch.texture, 0); + renderer.setTexture2D(batch.texture, 0, false); + gl.drawArrays(topology, batch.first, batchVertexCount); } this.vertexCount = 0; + batches.length = 0; - this.pushBatch(); + this.flushLocked = false; return this; }, /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#onBind - * @since 3.0.0 - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - onBind: function () - { - WebGLPipeline.prototype.onBind.call(this); - - this.mvpUpdate(); - - if (this.batches.length === 0) - { - this.pushBatch(); - } - - return this; - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#resize - * @since 3.0.0 - * - * @param {number} width - [description] - * @param {number} height - [description] - * @param {number} resolution - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} [description] - */ - resize: function (width, height, resolution) - { - WebGLPipeline.prototype.resize.call(this, width, height, resolution); - this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0); - return this; - }, - - /** - * Renders immediately a static tilemap. This function won't use - * the batching functionality of the pipeline. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawStaticTilemapLayer: function (tilemap) - { - if (tilemap.vertexCount > 0) - { - var pipelineVertexBuffer = this.vertexBuffer; - var gl = this.gl; - var renderer = this.renderer; - var frame = tilemap.tileset.image.get(); - - if (renderer.currentPipeline && - renderer.currentPipeline.vertexCount > 0) - { - renderer.flush(); - } - - this.vertexBuffer = tilemap.vertexBuffer; - renderer.setPipeline(this); - renderer.setTexture2D(frame.source.glTexture, 0); - gl.drawArrays(this.topology, 0, tilemap.vertexCount); - this.vertexBuffer = pipelineVertexBuffer; - } - - this.viewIdentity(); - this.modelIdentity(); - }, - - /** - * Renders contents of a ParticleEmitterManager. It'll batch all particles if possible. - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawEmitterManager: function (emitterManager, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var roundPixels = camera.roundPixels; - var emitters = emitterManager.emitters.list; - var emitterCount = emitters.length; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var renderer = this.renderer; - var maxQuads = this.maxQuads; - var cameraScrollX = camera.scrollX; - var cameraScrollY = camera.scrollY; - var cameraMatrix = camera.matrix.matrix; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var sin = Math.sin; - var cos = Math.cos; - var vertexComponentCount = this.vertexComponentCount; - var vertexCapacity = this.vertexCapacity; - var texture = emitterManager.defaultFrame.source.glTexture; - var pca, pcb, pcc, pcd, pce, pcf; - var pma, pmb, pmc, pmd, pme, pmf; - - if (parentMatrix) - { - pma = parentMatrix[0]; - pmb = parentMatrix[1]; - pmc = parentMatrix[2]; - pmd = parentMatrix[3]; - pme = parentMatrix[4]; - pmf = parentMatrix[5]; - } - - this.setTexture2D(texture, 0); - - for (var emitterIndex = 0; emitterIndex < emitterCount; ++emitterIndex) - { - var emitter = emitters[emitterIndex]; - var particles = emitter.alive; - var aliveLength = particles.length; - var batchCount = Math.ceil(aliveLength / maxQuads); - var particleOffset = 0; - var scrollX = cameraScrollX * emitter.scrollFactorX; - var scrollY = cameraScrollY * emitter.scrollFactorY; - - if (parentMatrix) - { - var cse = -scrollX; - var csf = -scrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - pca = pma * cma + pmb * cmc; - pcb = pma * cmb + pmb * cmd; - pcc = pmc * cma + pmd * cmc; - pcd = pmc * cmb + pmd * cmd; - pce = pme * cma + pmf * cmc + pse; - pcf = pme * cmb + pmf * cmd + psf; - - cma = pca; - cmb = pcb; - cmc = pcc; - cmd = pcd; - cme = pce; - cmf = pcf; - - scrollX = 0.0; - scrollY = 0.0; - } - - if (!emitter.visible || aliveLength === 0) - { - continue; - } - - renderer.setBlendMode(emitter.blendMode); - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - - for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) - { - var batchSize = Math.min(aliveLength, maxQuads); - - for (var index = 0; index < batchSize; ++index) - { - var particle = particles[particleOffset + index]; - - if (particle.alpha <= 0) - { - continue; - } - - var frame = particle.frame; - var uvs = frame.uvs; - var x = -(frame.halfWidth); - var y = -(frame.halfHeight); - var color = particle.color; - var xw = x + frame.width; - var yh = y + frame.height; - var sr = sin(particle.rotation); - var cr = cos(particle.rotation); - - var sra = cr * particle.scaleX; - var srb = sr * particle.scaleX; - var src = -sr * particle.scaleY; - var srd = cr * particle.scaleY; - var sre = particle.x - scrollX; - var srf = particle.y - scrollY; - - var mva = sra * cma + srb * cmc; - var mvb = sra * cmb + srb * cmd; - var mvc = src * cma + srd * cmc; - var mvd = src * cmb + srd * cmd; - var mve = sre * cma + srf * cmc + cme; - var mvf = sre * cmb + srf * cmd + cmf; - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - - var vertexOffset = this.vertexCount * vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = color; - - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = color; - - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = color; - - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = color; - - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = color; - - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = color; - - this.vertexCount += 6; - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - } - - particleOffset += batchSize; - aliveLength -= batchSize; - - if (this.vertexCount >= vertexCapacity) - { - this.flush(); - this.setTexture2D(texture, 0); - } - } - } - - this.setTexture2D(texture, 0); - }, - - /** - * Batches blitter game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - drawBlitter: function (blitter, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - var roundPixels = camera.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var list = blitter.getRenderList(); - var length = list.length; - var cameraMatrix = camera.matrix.matrix; - var a = cameraMatrix[0]; - var b = cameraMatrix[1]; - var c = cameraMatrix[2]; - var d = cameraMatrix[3]; - var e = cameraMatrix[4]; - var f = cameraMatrix[5]; - var cameraScrollX = camera.scrollX * blitter.scrollFactorX; - var cameraScrollY = camera.scrollY * blitter.scrollFactorY; - var batchCount = Math.ceil(length / this.maxQuads); - var batchOffset = 0; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * a + csf * c + e; - var psf = cse * b + csf * d + f; - var pca = pma * a + pmb * c; - var pcb = pma * b + pmb * d; - var pcc = pmc * a + pmd * c; - var pcd = pmc * b + pmd * d; - var pce = pme * a + pmf * c + pse; - var pcf = pme * b + pmf * d + psf; - - a = pca; - b = pcb; - c = pcc; - d = pcd; - e = pce; - f = pcf; - - cameraScrollX = 0.0; - cameraScrollY = 0.0; - } - - var blitterX = blitter.x - cameraScrollX; - var blitterY = blitter.y - cameraScrollY; - - var prevTextureSourceIndex; - - var alpha = camera.alpha * blitter.alpha; - - for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) - { - var batchSize = Math.min(length, this.maxQuads); - - for (var index = 0; index < batchSize; ++index) - { - var bob = list[batchOffset + index]; - var frame = bob.frame; - var bobAlpha = bob.alpha * alpha; - - if (bobAlpha === 0) - { - // Nothing to see here, moving on ... - continue; - } - - var tint = getTint(0xffffff, bobAlpha); - var uvs = frame.uvs; - var flipX = bob.flipX; - var flipY = bob.flipY; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = blitterX + bob.x + frame.x + (frame.width * ((flipX) ? 1.0 : 0.0)); - var y = blitterY + bob.y + frame.y + (frame.height * ((flipY) ? 1.0 : 0.0)); - var xw = x + width; - var yh = y + height; - var tx0 = x * a + y * c + e; - var ty0 = x * b + y * d + f; - var tx1 = xw * a + yh * c + e; - var ty1 = xw * b + yh * d + f; - - // Bind texture only if the Texture Source is different from before - if (frame.sourceIndex !== prevTextureSourceIndex) - { - this.setTexture2D(frame.texture.source[frame.sourceIndex].glTexture, 0); - - prevTextureSourceIndex = frame.sourceIndex; - } - - var vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = tint; - vertexViewF32[vertexOffset + 5] = tx0; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = tint; - vertexViewF32[vertexOffset + 10] = tx1; - vertexViewF32[vertexOffset + 11] = ty1; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = tint; - vertexViewF32[vertexOffset + 20] = tx1; - vertexViewF32[vertexOffset + 21] = ty1; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = tint; - vertexViewF32[vertexOffset + 25] = tx1; - vertexViewF32[vertexOffset + 26] = ty0; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = tint; - - this.vertexCount += 6; - - if (this.vertexCount >= this.vertexCapacity) - { - this.flush(); - - prevTextureSourceIndex = -1; - } - } - - batchOffset += batchSize; - length -= batchSize; - - if (this.vertexCount >= this.vertexCapacity) - { - this.flush(); - } - } - }, - - /** - * Batches Sprite game object + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. * * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchSprite * @since 3.0.0 * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] + * @param {(Phaser.GameObjects.Image|Phaser.GameObjects.Sprite)} sprite - The texture based Game Object to add to the batch. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to use for the rendering transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - The transform matrix of the parent container, if set. */ batchSprite: function (sprite, camera, parentTransformMatrix) { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - + // Will cause a flush if there are batchSize entries already this.renderer.setPipeline(this); - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; var frame = sprite.frame; - var texture = frame.texture.source[frame.sourceIndex].glTexture; - var getTint = Utils.getTintAppendFloatAlpha; - var forceFlipY = (texture.isRenderTexture ? true : false); - var flipX = sprite.flipX; - var flipY = sprite.flipY ^ forceFlipY; - var uvs = frame.uvs; + var texture = frame.glTexture; - var scaleX = sprite.scaleX; - var scaleY = sprite.scaleY; - var rotation = sprite.rotation; - var alphaTL = camera.alpha * sprite._alphaTL; - var alphaTR = camera.alpha * sprite._alphaTR; - var alphaBL = camera.alpha * sprite._alphaBL; - var alphaBR = camera.alpha * sprite._alphaBR; - var tintTL = sprite._tintTL; - var tintTR = sprite._tintTR; - var tintBL = sprite._tintBL; - var tintBR = sprite._tintBR; - - var roundPixels = camera.roundPixels; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = -sprite.displayOriginX + frame.x + ((frame.width) * (flipX ? 1.0 : 0.0)); - var y = -sprite.displayOriginY + frame.y + ((frame.height) * (flipY ? 1.0 : 0.0)); - var xw = (roundPixels ? (x | 0) : x) + width; - var yh = (roundPixels ? (y | 0) : y) + height; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = sprite.x; - var srf = sprite.y; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + var frameX = frame.x; + var frameY = frame.y; + var frameWidth = frame.cutWidth; + var frameHeight = frame.cutHeight; - if (parentMatrix) + var x = -sprite.displayOriginX + frameX; + var y = -sprite.displayOriginY + frameY; + + if (sprite.isCropped) { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * sprite.scrollFactorX; - var csf = -camera.scrollY * sprite.scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; + var crop = sprite._crop; - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; + if (crop.flipX !== sprite.flipX || crop.flipY !== sprite.flipY) + { + frame.updateCropUVs(crop, sprite.flipX, sprite.flipY); + } + + u0 = crop.u0; + v0 = crop.v0; + u1 = crop.u1; + v1 = crop.v1; + + frameWidth = crop.width; + frameHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + x = -sprite.displayOriginX + frameX; + y = -sprite.displayOriginY + frameY; + } + + if (sprite.flipX) + { + x += frameWidth; + frameWidth *= -1; + } + + if (sprite.flipY) + { + y += frameHeight; + frameHeight *= -1; + } + + var xw = x + frameWidth; + var yh = y + frameHeight; + + spriteMatrix.applyITRS(sprite.x, sprite.y, sprite.rotation, sprite.scaleX, sprite.scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * sprite.scrollFactorX, -camera.scrollY * sprite.scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = sprite.x; + spriteMatrix.f = sprite.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); } else { - sre -= camera.scrollX * sprite.scrollFactorX; - srf -= camera.scrollY * sprite.scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; + spriteMatrix.e -= camera.scrollX * sprite.scrollFactorX; + spriteMatrix.f -= camera.scrollY * sprite.scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); } - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vTintTL = getTint(tintTL, alphaTL); - var vTintTR = getTint(tintTR, alphaTR); - var vTintBL = getTint(tintBL, alphaBL); - var vTintBR = getTint(tintBR, alphaBR); + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); - if (roundPixels) + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + var tintTL = Utils.getTintAppendFloatAlpha(sprite._tintTL, camera.alpha * sprite._alphaTL); + var tintTR = Utils.getTintAppendFloatAlpha(sprite._tintTR, camera.alpha * sprite._alphaTR); + var tintBL = Utils.getTintAppendFloatAlpha(sprite._tintBL, camera.alpha * sprite._alphaBL); + var tintBR = Utils.getTintAppendFloatAlpha(sprite._tintBR, camera.alpha * sprite._alphaBR); + + if (camera.roundPixels) { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; + tx0 = Math.round(tx0); + ty0 = Math.round(ty0); + + tx1 = Math.round(tx1); + ty1 = Math.round(ty1); + + tx2 = Math.round(tx2); + ty2 = Math.round(ty2); + + tx3 = Math.round(tx3); + ty3 = Math.round(ty3); } this.setTexture2D(texture, 0); - var vertexOffset = this.vertexCount * this.vertexComponentCount; + var tintEffect = (sprite._isTinted && sprite.tintFill); - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = uvs.x0; - vertexViewF32[vertexOffset + 3] = uvs.y0; - vertexViewU32[vertexOffset + 4] = vTintTL; + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0); + }, - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = uvs.x1; - vertexViewF32[vertexOffset + 8] = uvs.y1; - vertexViewU32[vertexOffset + 9] = vTintBL; + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 6 vertices in the following arrangement: + * + * ``` + * 0----3 + * |\ B| + * | \ | + * | \ | + * | A \| + * | \ + * 1----2 + * ``` + * + * Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3 + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchQuad + * @since 3.12.0 + * + * @param {number} x0 - The top-left x position. + * @param {number} y0 - The top-left y position. + * @param {number} x1 - The bottom-left x position. + * @param {number} y1 - The bottom-left y position. + * @param {number} x2 - The bottom-right x position. + * @param {number} y2 - The bottom-right y position. + * @param {number} x3 - The top-right x position. + * @param {number} y3 - The top-right y position. + * @param {number} u0 - UV u0 value. + * @param {number} v0 - UV v0 value. + * @param {number} u1 - UV u1 value. + * @param {number} v1 - UV v1 value. + * @param {number} tintTL - The top-left tint color value. + * @param {number} tintTR - The top-right tint color value. + * @param {number} tintBL - The bottom-left tint color value. + * @param {number} tintBR - The bottom-right tint color value. + * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. + * @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch if a flush occurs. + * @param {integer} [unit=0] - Texture unit to which the texture needs to be bound. + * + * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. + */ + batchQuad: function (x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, unit) + { + var hasFlushed = false; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = uvs.x2; - vertexViewF32[vertexOffset + 13] = uvs.y2; - vertexViewU32[vertexOffset + 14] = vTintBR; + if (this.vertexCount + 6 > this.vertexCapacity) + { + this.flush(); - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = uvs.x0; - vertexViewF32[vertexOffset + 18] = uvs.y0; - vertexViewU32[vertexOffset + 19] = vTintTL; + hasFlushed = true; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = uvs.x2; - vertexViewF32[vertexOffset + 23] = uvs.y2; - vertexViewU32[vertexOffset + 24] = vTintBR; + this.setTexture2D(texture, unit); + } - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = uvs.x3; - vertexViewF32[vertexOffset + 28] = uvs.y3; - vertexViewU32[vertexOffset + 29] = vTintTR; + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + + var vertexOffset = (this.vertexCount * this.vertexComponentCount) - 1; + + vertexViewF32[++vertexOffset] = x0; + vertexViewF32[++vertexOffset] = y0; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x1; + vertexViewF32[++vertexOffset] = y1; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBR; + + vertexViewF32[++vertexOffset] = x0; + vertexViewF32[++vertexOffset] = y0; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; + + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBR; + + vertexViewF32[++vertexOffset] = x3; + vertexViewF32[++vertexOffset] = y3; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTR; this.vertexCount += 6; + + return hasFlushed; }, /** - * Batches Mesh game object + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 3 vertices in the following arrangement: + * + * ``` + * 0 + * |\ + * | \ + * | \ + * | \ + * | \ + * 1-----2 + * ``` * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchMesh - * @since 3.0.0 + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTri + * @since 3.12.0 * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] + * @param {number} x1 - The bottom-left x position. + * @param {number} y1 - The bottom-left y position. + * @param {number} x2 - The bottom-right x position. + * @param {number} y2 - The bottom-right y position. + * @param {number} x3 - The top-right x position. + * @param {number} y3 - The top-right y position. + * @param {number} u0 - UV u0 value. + * @param {number} v0 - UV v0 value. + * @param {number} u1 - UV u1 value. + * @param {number} v1 - UV v1 value. + * @param {number} tintTL - The top-left tint color value. + * @param {number} tintTR - The top-right tint color value. + * @param {number} tintBL - The bottom-left tint color value. + * @param {(number|boolean)} tintEffect - The tint effect for the shader to use. + * @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch if a flush occurs. + * @param {integer} [unit=0] - Texture unit to which the texture needs to be bound. + * + * @return {boolean} `true` if this method caused the batch to flush, otherwise `false`. */ - batchMesh: function (mesh, camera, parentTransformMatrix) + batchTri: function (x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect, texture, unit) { - var parentMatrix = null; + var hasFlushed = false; - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - var vertices = mesh.vertices; - var length = vertices.length; - var vertexCount = (length / 2)|0; - - this.renderer.setPipeline(this); - - if (this.vertexCount + vertexCount > this.vertexCapacity) + if (this.vertexCount + 3 > this.vertexCapacity) { this.flush(); + + this.setTexture2D(texture, unit); + + hasFlushed = true; } - var roundPixels = camera.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var uvs = mesh.uv; - var colors = mesh.colors; - var alphas = mesh.alphas; var vertexViewF32 = this.vertexViewF32; var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var frame = mesh.frame; - var texture = mesh.texture.source[frame.sourceIndex].glTexture; - var translateX = mesh.x; - var translateY = mesh.y; - var scaleX = mesh.scaleX; - var scaleY = mesh.scaleY; - var rotation = mesh.rotation; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * mesh.scrollFactorX; - var csf = -camera.scrollY * mesh.scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; + var vertexOffset = (this.vertexCount * this.vertexComponentCount) - 1; - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * mesh.scrollFactorX; - srf -= camera.scrollY * mesh.scrollFactorY; + vertexViewF32[++vertexOffset] = x1; + vertexViewF32[++vertexOffset] = y1; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v0; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTL; - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } + vertexViewF32[++vertexOffset] = x2; + vertexViewF32[++vertexOffset] = y2; + vertexViewF32[++vertexOffset] = u0; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintTR; - this.setTexture2D(texture, 0); + vertexViewF32[++vertexOffset] = x3; + vertexViewF32[++vertexOffset] = y3; + vertexViewF32[++vertexOffset] = u1; + vertexViewF32[++vertexOffset] = v1; + vertexViewF32[++vertexOffset] = tintEffect; + vertexViewU32[++vertexOffset] = tintBL; - vertexOffset = this.vertexCount * this.vertexComponentCount; + this.vertexCount += 3; - for (var index = 0, index0 = 0; index < length; index += 2) - { - var x = vertices[index + 0]; - var y = vertices[index + 1]; - var tx = x * mva + y * mvc + mve; - var ty = x * mvb + y * mvd + mvf; - - if (roundPixels) - { - tx |= 0; - ty |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx; - vertexViewF32[vertexOffset + 1] = ty; - vertexViewF32[vertexOffset + 2] = uvs[index + 0]; - vertexViewF32[vertexOffset + 3] = uvs[index + 1]; - vertexViewU32[vertexOffset + 4] = getTint(colors[index0], camera.alpha * alphas[index0]); - - vertexOffset += 5; - index0 += 1; - } - - this.vertexCount += vertexCount; + return hasFlushed; }, /** - * Batches BitmapText game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = camera.roundPixels; - var text = bitmapText.text; - var textLength = text.length; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var cameraWidth = camera.width + 50; - var cameraHeight = camera.height + 50; - var cameraX = -50; - var cameraY = -50; - var frame = bitmapText.frame; - var textureSource = bitmapText.texture.source[frame.sourceIndex]; - var cameraScrollX = camera.scrollX * bitmapText.scrollFactorX; - var cameraScrollY = camera.scrollY * bitmapText.scrollFactorY; - var fontData = bitmapText.fontData; - var lineHeight = fontData.lineHeight; - var scale = (bitmapText.fontSize / fontData.size); - var chars = fontData.chars; - var alpha = camera.alpha * bitmapText.alpha; - var vTintTL = getTint(bitmapText._tintTL, alpha); - var vTintTR = getTint(bitmapText._tintTR, alpha); - var vTintBL = getTint(bitmapText._tintBL, alpha); - var vTintBR = getTint(bitmapText._tintBR, alpha); - var srcX = bitmapText.x; - var srcY = bitmapText.y; - var textureX = frame.cutX; - var textureY = frame.cutY; - var textureWidth = textureSource.width; - var textureHeight = textureSource.height; - var texture = textureSource.glTexture; - var xAdvance = 0; - var yAdvance = 0; - var indexCount = 0; - var charCode = 0; - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - var x = 0; - var y = 0; - var xw = 0; - var yh = 0; - - var tx0; - var ty0; - var tx1; - var ty1; - var tx2; - var ty2; - var tx3; - var ty3; - - var umin = 0; - var umax = 0; - var vmin = 0; - var vmax = 0; - var lastGlyph = null; - var lastCharCode = 0; - var translateX = srcX + frame.x; - var translateY = srcY + frame.y; - var rotation = bitmapText.rotation; - var scaleX = bitmapText.scaleX; - var scaleY = bitmapText.scaleY; - var letterSpacing = bitmapText.letterSpacing; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - for (var index = 0; index < textLength; ++index) - { - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) * scale; - y = (glyph.yOffset + yAdvance) * scale; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - x -= bitmapText.displayOriginX; - y -= bitmapText.displayOriginY; - - xw = x + glyphW * scale; - yh = y + glyphH * scale; - tx0 = x * mva + y * mvc + mve; - ty0 = x * mvb + y * mvd + mvf; - tx1 = x * mva + yh * mvc + mve; - ty1 = x * mvb + yh * mvd + mvf; - tx2 = xw * mva + yh * mvc + mve; - ty2 = xw * mvb + yh * mvd + mvf; - tx3 = xw * mva + y * mvc + mve; - ty3 = xw * mvb + y * mvd + mvf; - - umin = glyphX / textureWidth; - umax = (glyphX + glyphW) / textureWidth; - vmin = glyphY / textureHeight; - vmax = (glyphY + glyphH) / textureHeight; - - if ((tx0 < cameraX || tx0 > cameraWidth || ty0 < cameraY || ty0 > cameraHeight) && - (tx1 < cameraX || tx1 > cameraWidth || ty1 < cameraY || ty1 > cameraHeight) && - (tx2 < cameraX || tx2 > cameraWidth || ty2 < cameraY || ty2 > cameraHeight) && - (tx3 < cameraX || tx3 > cameraWidth || ty3 < cameraY || ty3 > cameraHeight)) - { - continue; - } - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = umin; - vertexViewF32[vertexOffset + 3] = vmin; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = umin; - vertexViewF32[vertexOffset + 8] = vmax; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = umax; - vertexViewF32[vertexOffset + 13] = vmax; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = umin; - vertexViewF32[vertexOffset + 18] = vmin; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = umax; - vertexViewF32[vertexOffset + 23] = vmax; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = umax; - vertexViewF32[vertexOffset + 28] = vmin; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - } - }, - - /** - * Batches DynamicBitmapText game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix) - { - var parentMatrix = null; - - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - var roundPixels = camera.roundPixels; - var displayCallback = bitmapText.displayCallback; - var text = bitmapText.text; - var textLength = text.length; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var renderer = this.renderer; - var cameraMatrix = camera.matrix.matrix; - var frame = bitmapText.frame; - var textureSource = bitmapText.texture.source[frame.sourceIndex]; - var cameraScrollX = camera.scrollX * bitmapText.scrollFactorX; - var cameraScrollY = camera.scrollY * bitmapText.scrollFactorY; - var scrollX = bitmapText.scrollX; - var scrollY = bitmapText.scrollY; - var fontData = bitmapText.fontData; - var lineHeight = fontData.lineHeight; - var scale = (bitmapText.fontSize / fontData.size); - var chars = fontData.chars; - var alpha = camera.alpha * bitmapText.alpha; - var vTintTL = getTint(bitmapText._tintTL, alpha); - var vTintTR = getTint(bitmapText._tintTR, alpha); - var vTintBL = getTint(bitmapText._tintBL, alpha); - var vTintBR = getTint(bitmapText._tintBR, alpha); - var srcX = bitmapText.x; - var srcY = bitmapText.y; - var textureX = frame.cutX; - var textureY = frame.cutY; - var textureWidth = textureSource.width; - var textureHeight = textureSource.height; - var texture = textureSource.glTexture; - var xAdvance = 0; - var yAdvance = 0; - var indexCount = 0; - var charCode = 0; - var glyph = null; - var glyphX = 0; - var glyphY = 0; - var glyphW = 0; - var glyphH = 0; - var x = 0; - var y = 0; - var xw = 0; - var tx0; - var ty0; - var tx1; - var ty1; - var tx2; - var ty2; - var tx3; - var ty3; - var yh = 0; - var umin = 0; - var umax = 0; - var vmin = 0; - var vmax = 0; - var lastGlyph = null; - var lastCharCode = 0; - var translateX = srcX + frame.x; - var translateY = srcY + frame.y; - var rotation = bitmapText.rotation; - var scaleX = bitmapText.scaleX; - var scaleY = bitmapText.scaleY; - var letterSpacing = bitmapText.letterSpacing; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var crop = (bitmapText.cropWidth > 0 || bitmapText.cropHeight > 0); - var uta, utb, utc, utd, ute, utf; - var vertexOffset = 0; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -cameraScrollX; - var csf = -cameraScrollY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= cameraScrollX; - srf -= cameraScrollY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - this.setTexture2D(texture, 0); - - if (crop) - { - renderer.pushScissor( - bitmapText.x, - bitmapText.y, - bitmapText.cropWidth * bitmapText.scaleX, - bitmapText.cropHeight * bitmapText.scaleY - ); - } - - for (var index = 0; index < textLength; ++index) - { - scale = (bitmapText.fontSize / bitmapText.fontData.size); - rotation = 0; - - charCode = text.charCodeAt(index); - - if (charCode === 10) - { - xAdvance = 0; - indexCount = 0; - yAdvance += lineHeight; - lastGlyph = null; - continue; - } - - glyph = chars[charCode]; - - if (!glyph) - { - continue; - } - - glyphX = textureX + glyph.x; - glyphY = textureY + glyph.y; - - glyphW = glyph.width; - glyphH = glyph.height; - - x = (indexCount + glyph.xOffset + xAdvance) - scrollX; - y = (glyph.yOffset + yAdvance) - scrollY; - - if (lastGlyph !== null) - { - var kerningOffset = glyph.kerning[lastCharCode]; - x += (kerningOffset !== undefined) ? kerningOffset : 0; - } - - xAdvance += glyph.xAdvance + letterSpacing; - indexCount += 1; - lastGlyph = glyph; - lastCharCode = charCode; - - // Nothing to render or a space? Then skip to the next glyph - if (glyphW === 0 || glyphH === 0 || charCode === 32) - { - continue; - } - - if (displayCallback) - { - var output = displayCallback({ - color: 0, - tint: { - topLeft: vTintTL, - topRight: vTintTR, - bottomLeft: vTintBL, - bottomRight: vTintBR - }, - index: index, - charCode: charCode, - x: x, - y: y, - scale: scale, - rotation: 0, - data: glyph.data - }); - - x = output.x; - y = output.y; - scale = output.scale; - rotation = output.rotation; - - if (output.color) - { - vTintTL = output.color; - vTintTR = output.color; - vTintBL = output.color; - vTintBR = output.color; - } - else - { - vTintTL = output.tint.topLeft; - vTintTR = output.tint.topRight; - vTintBL = output.tint.bottomLeft; - vTintBR = output.tint.bottomRight; - } - - vTintTL = getTint(vTintTL, alpha); - vTintTR = getTint(vTintTR, alpha); - vTintBL = getTint(vTintBL, alpha); - vTintBR = getTint(vTintBR, alpha); - } - - x -= bitmapText.displayOriginX; - y -= bitmapText.displayOriginY; - x *= scale; - y *= scale; - - sr = Math.sin(rotation); - cr = Math.cos(rotation); - uta = cr * scale; - utb = sr * scale; - utc = -sr * scale; - utd = cr * scale; - ute = x; - utf = y; - - sra = uta * mva + utb * mvc; - srb = uta * mvb + utb * mvd; - src = utc * mva + utd * mvc; - srd = utc * mvb + utd * mvd; - sre = ute * mva + utf * mvc + mve; - srf = ute * mvb + utf * mvd + mvf; - - xw = glyphW; - yh = glyphH; - tx0 = sre; - ty0 = srf; - tx1 = yh * src + sre; - ty1 = yh * srd + srf; - tx2 = xw * sra + yh * src + sre; - ty2 = xw * srb + yh * srd + srf; - tx3 = xw * sra + sre; - ty3 = xw * srb + srf; - - umin = glyphX / textureWidth; - umax = (glyphX + glyphW) / textureWidth; - vmin = glyphY / textureHeight; - vmax = (glyphY + glyphH) / textureHeight; - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - vertexOffset = this.vertexCount * this.vertexComponentCount; - - if (roundPixels) - { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; - } - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = umin; - vertexViewF32[vertexOffset + 3] = vmin; - vertexViewU32[vertexOffset + 4] = vTintTL; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = umin; - vertexViewF32[vertexOffset + 8] = vmax; - vertexViewU32[vertexOffset + 9] = vTintBL; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = umax; - vertexViewF32[vertexOffset + 13] = vmax; - vertexViewU32[vertexOffset + 14] = vTintBR; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = umin; - vertexViewF32[vertexOffset + 18] = vmin; - vertexViewU32[vertexOffset + 19] = vTintTL; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = umax; - vertexViewF32[vertexOffset + 23] = vmax; - vertexViewU32[vertexOffset + 24] = vTintBR; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = umax; - vertexViewF32[vertexOffset + 28] = vmin; - vertexViewU32[vertexOffset + 29] = vTintTR; - - this.vertexCount += 6; - } - - if (crop) - { - renderer.popScissor(); - } - }, - - /** - * Batches Text game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchText: function (text, camera, parentTransformMatrix) - { - var getTint = Utils.getTintAppendFloatAlpha; - - this.batchTexture( - text, - text.canvasTexture, - text.canvasTexture.width, text.canvasTexture.height, - text.x, text.y, - text.canvasTexture.width, text.canvasTexture.height, - text.scaleX, text.scaleY, - text.rotation, - text.flipX, text.flipY, - text.scrollFactorX, text.scrollFactorY, - text.displayOriginX, text.displayOriginY, - 0, 0, text.canvasTexture.width, text.canvasTexture.height, - getTint(text._tintTL, camera.alpha * text._alphaTL), - getTint(text._tintTR, camera.alpha * text._alphaTR), - getTint(text._tintBL, camera.alpha * text._alphaBL), - getTint(text._tintBR, camera.alpha * text._alphaBR), - 0, 0, - camera, - parentTransformMatrix - ); - }, - - /** - * Batches DynamicTilemapLayer game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix) - { - var renderTiles = tilemapLayer.culledTiles; - var length = renderTiles.length; - var texture = tilemapLayer.tileset.image.get().source.glTexture; - var tileset = tilemapLayer.tileset; - var scrollFactorX = tilemapLayer.scrollFactorX; - var scrollFactorY = tilemapLayer.scrollFactorY; - var alpha = camera.alpha * tilemapLayer.alpha; - var x = tilemapLayer.x; - var y = tilemapLayer.y; - var sx = tilemapLayer.scaleX; - var sy = tilemapLayer.scaleY; - var getTint = Utils.getTintAppendFloatAlpha; - - for (var index = 0; index < length; ++index) - { - var tile = renderTiles[index]; - - var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } - - var frameWidth = tile.width; - var frameHeight = tile.height; - var frameX = tileTexCoords.x; - var frameY = tileTexCoords.y; - var tint = getTint(tile.tint, alpha * tile.alpha); - - this.batchTexture( - tilemapLayer, - texture, - texture.width, texture.height, - (tile.width / 2) + x + tile.pixelX * sx, (tile.height / 2) + y + tile.pixelY * sy, - tile.width * sx, tile.height * sy, - 1, 1, - tile.rotation, - tile.flipX, tile.flipY, - scrollFactorX, scrollFactorY, - (tile.width / 2), (tile.height / 2), - frameX, frameY, frameWidth, frameHeight, - tint, tint, tint, tint, - 0, 0, - camera, - parentTransformMatrix - ); - } - }, - - /** - * Generic function for batching a textured quad + * Generic function for batching a textured quad using argument values instead of a Game Object. * * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject - * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad - * @param {integer} textureWidth - Real texture width - * @param {integer} textureHeight - Real texture height - * @param {number} srcX - X coordinate of the quad - * @param {number} srcY - Y coordinate of the quad - * @param {number} srcWidth - Width of the quad - * @param {number} srcHeight - Height of the quad - * @param {number} scaleX - X component of scale - * @param {number} scaleY - Y component of scale - * @param {number} rotation - Rotation of the quad - * @param {boolean} flipX - Indicates if the quad is horizontally flipped - * @param {boolean} flipY - Indicates if the quad is vertically flipped - * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll - * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll - * @param {number} displayOriginX - Horizontal origin in pixels - * @param {number} displayOriginY - Vertical origin in pixels - * @param {number} frameX - X coordinate of the texture frame - * @param {number} frameY - Y coordinate of the texture frame - * @param {number} frameWidth - Width of the texture frame - * @param {number} frameHeight - Height of the texture frame - * @param {integer} tintTL - Tint for top left - * @param {integer} tintTR - Tint for top right - * @param {integer} tintBL - Tint for bottom left - * @param {integer} tintBR - Tint for bottom right - * @param {number} uOffset - Horizontal offset on texture coordinate - * @param {number} vOffset - Vertical offset on texture coordinate - * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container + * @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject. + * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad. + * @param {integer} textureWidth - Real texture width. + * @param {integer} textureHeight - Real texture height. + * @param {number} srcX - X coordinate of the quad. + * @param {number} srcY - Y coordinate of the quad. + * @param {number} srcWidth - Width of the quad. + * @param {number} srcHeight - Height of the quad. + * @param {number} scaleX - X component of scale. + * @param {number} scaleY - Y component of scale. + * @param {number} rotation - Rotation of the quad. + * @param {boolean} flipX - Indicates if the quad is horizontally flipped. + * @param {boolean} flipY - Indicates if the quad is vertically flipped. + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll. + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll. + * @param {number} displayOriginX - Horizontal origin in pixels. + * @param {number} displayOriginY - Vertical origin in pixels. + * @param {number} frameX - X coordinate of the texture frame. + * @param {number} frameY - Y coordinate of the texture frame. + * @param {number} frameWidth - Width of the texture frame. + * @param {number} frameHeight - Height of the texture frame. + * @param {integer} tintTL - Tint for top left. + * @param {integer} tintTR - Tint for top right. + * @param {integer} tintBL - Tint for bottom left. + * @param {integer} tintBR - Tint for bottom right. + * @param {number} tintEffect - The tint effect. + * @param {number} uOffset - Horizontal offset on texture coordinate. + * @param {number} vOffset - Vertical offset on texture coordinate. + * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container. + * @param {boolean} [skipFlip=false] - Skip the renderTexture check. */ batchTexture: function ( gameObject, @@ -1854,314 +878,607 @@ var TextureTintPipeline = new Class({ scrollFactorX, scrollFactorY, displayOriginX, displayOriginY, frameX, frameY, frameWidth, frameHeight, - tintTL, tintTR, tintBL, tintBR, + tintTL, tintTR, tintBL, tintBR, tintEffect, uOffset, vOffset, camera, - parentTransformMatrix) + parentTransformMatrix, + skipFlip) { - var parentMatrix = null; + this.renderer.setPipeline(this, gameObject); - if (parentTransformMatrix) - { - parentMatrix = parentTransformMatrix.matrix; - } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) - { - this.flush(); - } - - flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); - - var roundPixels = camera.roundPixels; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; - var width = srcWidth * (flipX ? -1.0 : 1.0); - var height = srcHeight * (flipY ? -1.0 : 1.0); - var x = -displayOriginX + ((srcWidth) * (flipX ? 1.0 : 0.0)); - var y = -displayOriginY + ((srcHeight) * (flipY ? 1.0 : 0.0)); - - // var x = -displayOriginX + frameX + ((frameWidth) * (flipX ? 1.0 : 0.0)); - // var y = -displayOriginY + frameY + ((frameHeight) * (flipY ? 1.0 : 0.0)); - - var xw = (roundPixels ? (x | 0) : x) + width; - var yh = (roundPixels ? (y | 0) : y) + height; - var sr = Math.sin(rotation); - var cr = Math.cos(rotation); - var sra = cr * scaleX; - var srb = sr * scaleX; - var src = -sr * scaleY; - var srd = cr * scaleY; - var sre = srcX; - var srf = srcY; - var cma = cameraMatrix[0]; - var cmb = cameraMatrix[1]; - var cmc = cameraMatrix[2]; - var cmd = cameraMatrix[3]; - var cme = cameraMatrix[4]; - var cmf = cameraMatrix[5]; - var mva, mvb, mvc, mvd, mve, mvf; - - if (parentMatrix) - { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var cse = -camera.scrollX * scrollFactorX; - var csf = -camera.scrollY * scrollFactorY; - var pse = cse * cma + csf * cmc + cme; - var psf = cse * cmb + csf * cmd + cmf; - var pca = pma * cma + pmb * cmc; - var pcb = pma * cmb + pmb * cmd; - var pcc = pmc * cma + pmd * cmc; - var pcd = pmc * cmb + pmd * cmd; - var pce = pme * cma + pmf * cmc + pse; - var pcf = pme * cmb + pmf * cmd + psf; - - mva = sra * pca + srb * pcc; - mvb = sra * pcb + srb * pcd; - mvc = src * pca + srd * pcc; - mvd = src * pcb + srd * pcd; - mve = sre * pca + srf * pcc + pce; - mvf = sre * pcb + srf * pcd + pcf; - } - else - { - sre -= camera.scrollX * scrollFactorX; - srf -= camera.scrollY * scrollFactorY; - - mva = sra * cma + srb * cmc; - mvb = sra * cmb + srb * cmd; - mvc = src * cma + srd * cmc; - mvd = src * cmb + srd * cmd; - mve = sre * cma + srf * cmc + cme; - mvf = sre * cmb + srf * cmd + cmf; - } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; + var camMatrix = this._tempMatrix1; + var spriteMatrix = this._tempMatrix2; + var calcMatrix = this._tempMatrix3; var u0 = (frameX / textureWidth) + uOffset; var v0 = (frameY / textureHeight) + vOffset; var u1 = (frameX + frameWidth) / textureWidth + uOffset; var v1 = (frameY + frameHeight) / textureHeight + vOffset; - if (roundPixels) + var width = srcWidth; + var height = srcHeight; + + var x = -displayOriginX; + var y = -displayOriginY; + + if (gameObject.isCropped) { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; + var crop = gameObject._crop; + + width = crop.width; + height = crop.height; + + srcWidth = crop.width; + srcHeight = crop.height; + + frameX = crop.x; + frameY = crop.y; + + var ox = frameX; + var oy = frameY; + + if (flipX) + { + ox = (frameWidth - crop.x - crop.width); + } + + if (flipY && !texture.isRenderTexture) + { + oy = (frameHeight - crop.y - crop.height); + } + + u0 = (ox / textureWidth) + uOffset; + v0 = (oy / textureHeight) + vOffset; + u1 = (ox + crop.width) / textureWidth + uOffset; + v1 = (oy + crop.height) / textureHeight + vOffset; + + x = -displayOriginX + frameX; + y = -displayOriginY + frameY; + } + + // Invert the flipY if this is a RenderTexture + flipY = flipY ^ (!skipFlip && texture.isRenderTexture ? 1 : 0); + + if (flipX) + { + width *= -1; + x += srcWidth; + } + + if (flipY) + { + height *= -1; + y += srcHeight; + } + + var xw = x + width; + var yh = y + height; + + spriteMatrix.applyITRS(srcX, srcY, rotation, scaleX, scaleY); + + camMatrix.copyFrom(camera.matrix); + + if (parentTransformMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentTransformMatrix, -camera.scrollX * scrollFactorX, -camera.scrollY * scrollFactorY); + + // Undo the camera scroll + spriteMatrix.e = srcX; + spriteMatrix.f = srcY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + else + { + spriteMatrix.e -= camera.scrollX * scrollFactorX; + spriteMatrix.f -= camera.scrollY * scrollFactorY; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(spriteMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 = Math.round(tx0); + ty0 = Math.round(ty0); + + tx1 = Math.round(tx1); + ty1 = Math.round(ty1); + + tx2 = Math.round(tx2); + ty2 = Math.round(ty2); + + tx3 = Math.round(tx3); + ty3 = Math.round(ty3); } this.setTexture2D(texture, 0); - var vertexOffset = this.vertexCount * this.vertexComponentCount; - - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = u0; - vertexViewF32[vertexOffset + 3] = v0; - vertexViewU32[vertexOffset + 4] = tintTL; - - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = u0; - vertexViewF32[vertexOffset + 8] = v1; - vertexViewU32[vertexOffset + 9] = tintTR; - - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = u1; - vertexViewF32[vertexOffset + 13] = v1; - vertexViewU32[vertexOffset + 14] = tintBL; - - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = u0; - vertexViewF32[vertexOffset + 18] = v0; - vertexViewU32[vertexOffset + 19] = tintTL; - - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = u1; - vertexViewF32[vertexOffset + 23] = v1; - vertexViewU32[vertexOffset + 24] = tintBL; - - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = u1; - vertexViewF32[vertexOffset + 28] = v0; - vertexViewU32[vertexOffset + 29] = tintBR; - - this.vertexCount += 6; + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0); }, /** - * Immediately draws a texture with no batching. + * Adds a Texture Frame into the batch for rendering. * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawTexture - * @since 3.2.0 + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTextureFrame + * @since 3.12.0 * - * @param {WebGLTexture} texture [description] - * @param {number} srcX - [description] - * @param {number} srcY - [description] - * @param {number} tint - [description] - * @param {number} alpha - [description] - * @param {number} frameX - [description] - * @param {number} frameY - [description] - * @param {number} frameWidth - [description] - * @param {number} frameHeight - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} transformMatrix - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - * - * @return {Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline} This Pipeline. + * @param {Phaser.Textures.Frame} frame - The Texture Frame to be rendered. + * @param {number} x - The horizontal position to render the texture at. + * @param {number} y - The vertical position to render the texture at. + * @param {number} tint - The tint color. + * @param {number} alpha - The alpha value. + * @param {Phaser.GameObjects.Components.TransformMatrix} transformMatrix - The Transform Matrix to use for the texture. + * @param {Phaser.GameObjects.Components.TransformMatrix} [parentTransformMatrix] - A parent Transform Matrix. */ - drawTexture: function ( - texture, - srcX, srcY, + batchTextureFrame: function ( + frame, + x, y, tint, alpha, - frameX, frameY, frameWidth, frameHeight, transformMatrix, parentTransformMatrix ) { - var parentMatrix = null; + this.renderer.setPipeline(this); + + var spriteMatrix = this._tempMatrix1.copyFrom(transformMatrix); + var calcMatrix = this._tempMatrix2; + + var xw = x + frame.width; + var yh = y + frame.height; if (parentTransformMatrix) { - parentMatrix = parentTransformMatrix.matrix; + spriteMatrix.multiply(parentTransformMatrix, calcMatrix); } - - this.renderer.setPipeline(this); - - if (this.vertexCount + 6 > this.vertexCapacity) + else { - this.flush(); + calcMatrix = spriteMatrix; } - var roundPixels = this.renderer.config.roundPixels; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var width = frameWidth; - var height = frameHeight; - var x = srcX; - var y = srcY; + var tx0 = calcMatrix.getX(x, y); + var ty0 = calcMatrix.getY(x, y); + + var tx1 = calcMatrix.getX(x, yh); + var ty1 = calcMatrix.getY(x, yh); + + var tx2 = calcMatrix.getX(xw, yh); + var ty2 = calcMatrix.getY(xw, yh); + + var tx3 = calcMatrix.getX(xw, y); + var ty3 = calcMatrix.getY(xw, y); + + this.setTexture2D(frame.glTexture, 0); + + tint = Utils.getTintAppendFloatAlpha(tint, alpha); + + this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, 0, frame.glTexture, 0); + }, + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle has no transform values and isn't transformed into the local space. + * Used for directly batching untransformed rectangles, such as Camera background colors. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawFillRect + * @since 3.12.0 + * + * @param {number} x - Horizontal top left coordinate of the rectangle. + * @param {number} y - Vertical top left coordinate of the rectangle. + * @param {number} width - Width of the rectangle. + * @param {number} height - Height of the rectangle. + * @param {number} color - Color of the rectangle to draw. + * @param {number} alpha - Alpha value of the rectangle to draw. + */ + drawFillRect: function (x, y, width, height, color, alpha) + { var xw = x + width; var yh = y + height; - var mva = transformMatrix[0]; - var mvb = transformMatrix[1]; - var mvc = transformMatrix[2]; - var mvd = transformMatrix[3]; - var mve = transformMatrix[4]; - var mvf = transformMatrix[5]; + this.setTexture2D(); + + var tint = Utils.getTintAppendFloatAlphaAndSwap(color, alpha); + + this.batchQuad(x, y, x, yh, xw, yh, xw, y, 0, 0, 1, 1, tint, tint, tint, tint, 2); + }, + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle factors in the given transform matrices before adding to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillRect + * @since 3.12.0 + * + * @param {number} x - Horizontal top left coordinate of the rectangle. + * @param {number} y - Vertical top left coordinate of the rectangle. + * @param {number} width - Width of the rectangle. + * @param {number} height - Height of the rectangle. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillRect: function (x, y, width, height, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix if (parentMatrix) { - var pma = parentMatrix[0]; - var pmb = parentMatrix[1]; - var pmc = parentMatrix[2]; - var pmd = parentMatrix[3]; - var pme = parentMatrix[4]; - var pmf = parentMatrix[5]; - var pca = mva * pma + mvb * pmc; - var pcb = mva * pmb + mvb * pmd; - var pcc = mvc * pma + mvd * pmc; - var pcd = mvc * pmb + mvd * pmd; - var pce = mve * pma + mvf * pmc + pme; - var pcf = mve * pmb + mvf * pmd + pmf; - mva = pca; - mvb = pcb; - mvc = pcc; - mvd = pcd; - mve = pce; - mvf = pcf; + parentMatrix.multiply(currentMatrix, calcMatrix); } - - var tx0 = x * mva + y * mvc + mve; - var ty0 = x * mvb + y * mvd + mvf; - var tx1 = x * mva + yh * mvc + mve; - var ty1 = x * mvb + yh * mvd + mvf; - var tx2 = xw * mva + yh * mvc + mve; - var ty2 = xw * mvb + yh * mvd + mvf; - var tx3 = xw * mva + y * mvc + mve; - var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = 0; - var textureWidth = texture.width; - var textureHeight = texture.height; - var u0 = (frameX / textureWidth); - var v0 = (frameY / textureHeight); - var u1 = (frameX + frameWidth) / textureWidth; - var v1 = (frameY + frameHeight) / textureHeight; - tint = Utils.getTintAppendFloatAlpha(tint, alpha); - this.setTexture2D(texture, 0); + var xw = x + width; + var yh = y + height; - vertexOffset = this.vertexCount * this.vertexComponentCount; + var x0 = calcMatrix.getX(x, y); + var y0 = calcMatrix.getY(x, y); - if (roundPixels) + var x1 = calcMatrix.getX(x, yh); + var y1 = calcMatrix.getY(x, yh); + + var x2 = calcMatrix.getX(xw, yh); + var y2 = calcMatrix.getY(xw, yh); + + var x3 = calcMatrix.getX(xw, y); + var y3 = calcMatrix.getY(xw, y); + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.fillTint.BR, this.tintEffect); + }, + + /** + * Pushes a filled triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillTriangle + * @since 3.12.0 + * + * @param {number} x0 - Point 0 x coordinate. + * @param {number} y0 - Point 0 y coordinate. + * @param {number} x1 - Point 1 x coordinate. + * @param {number} y1 - Point 1 y coordinate. + * @param {number} x2 - Point 2 x coordinate. + * @param {number} y2 - Point 2 y coordinate. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillTriangle: function (x0, y0, x1, y1, x2, y2, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) { - tx0 |= 0; - ty0 |= 0; - tx1 |= 0; - ty1 |= 0; - tx2 |= 0; - ty2 |= 0; - tx3 |= 0; - ty3 |= 0; + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, this.fillTint.TL, this.fillTint.TR, this.fillTint.BL, this.tintEffect); + }, + + /** + * Pushes a stroked triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * The triangle is created from 3 lines and drawn using the `batchStrokePath` method. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokeTriangle + * @since 3.12.0 + * + * @param {number} x0 - Point 0 x coordinate. + * @param {number} y0 - Point 0 y coordinate. + * @param {number} x1 - Point 1 x coordinate. + * @param {number} y1 - Point 1 y coordinate. + * @param {number} x2 - Point 2 x coordinate. + * @param {number} y2 - Point 2 y coordinate. + * @param {number} lineWidth - The width of the line in pixels. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchStrokeTriangle: function (x0, y0, x1, y1, x2, y2, lineWidth, currentMatrix, parentMatrix) + { + var tempTriangle = this.tempTriangle; + + tempTriangle[0].x = x0; + tempTriangle[0].y = y0; + tempTriangle[0].width = lineWidth; + + tempTriangle[1].x = x1; + tempTriangle[1].y = y1; + tempTriangle[1].width = lineWidth; + + tempTriangle[2].x = x2; + tempTriangle[2].y = y2; + tempTriangle[2].width = lineWidth; + + tempTriangle[3].x = x0; + tempTriangle[3].y = y0; + tempTriangle[3].width = lineWidth; + + this.batchStrokePath(tempTriangle, lineWidth, false, currentMatrix, parentMatrix); + }, + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and then passing it through Earcut, which + * creates a list of polygons. Each polygon is then added to the batch. + * + * The path is always automatically closed because it's filled. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillPath + * @since 3.12.0 + * + * @param {array} path - Collection of points that represent the path. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchFillPath: function (path, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); } - vertexViewF32[vertexOffset + 0] = tx0; - vertexViewF32[vertexOffset + 1] = ty0; - vertexViewF32[vertexOffset + 2] = u0; - vertexViewF32[vertexOffset + 3] = v0; - vertexViewU32[vertexOffset + 4] = tint; - vertexViewF32[vertexOffset + 5] = tx1; - vertexViewF32[vertexOffset + 6] = ty1; - vertexViewF32[vertexOffset + 7] = u0; - vertexViewF32[vertexOffset + 8] = v1; - vertexViewU32[vertexOffset + 9] = tint; - vertexViewF32[vertexOffset + 10] = tx2; - vertexViewF32[vertexOffset + 11] = ty2; - vertexViewF32[vertexOffset + 12] = u1; - vertexViewF32[vertexOffset + 13] = v1; - vertexViewU32[vertexOffset + 14] = tint; - vertexViewF32[vertexOffset + 15] = tx0; - vertexViewF32[vertexOffset + 16] = ty0; - vertexViewF32[vertexOffset + 17] = u0; - vertexViewF32[vertexOffset + 18] = v0; - vertexViewU32[vertexOffset + 19] = tint; - vertexViewF32[vertexOffset + 20] = tx2; - vertexViewF32[vertexOffset + 21] = ty2; - vertexViewF32[vertexOffset + 22] = u1; - vertexViewF32[vertexOffset + 23] = v1; - vertexViewU32[vertexOffset + 24] = tint; - vertexViewF32[vertexOffset + 25] = tx3; - vertexViewF32[vertexOffset + 26] = ty3; - vertexViewF32[vertexOffset + 27] = u1; - vertexViewF32[vertexOffset + 28] = v0; - vertexViewU32[vertexOffset + 29] = tint; + var length = path.length; + var polygonCache = this.polygonCache; + var polygonIndexArray; + var point; - this.vertexCount += 6; + var tintTL = this.fillTint.TL; + var tintTR = this.fillTint.TR; + var tintBL = this.fillTint.BL; + var tintEffect = this.tintEffect; - // Force an immediate draw - this.flush(); + for (var pathIndex = 0; pathIndex < length; ++pathIndex) + { + point = path[pathIndex]; + polygonCache.push(point.x, point.y); + } + + polygonIndexArray = Earcut(polygonCache); + length = polygonIndexArray.length; + + var frame = this.currentFrame; + + for (var index = 0; index < length; index += 3) + { + var p0 = polygonIndexArray[index + 0] * 2; + var p1 = polygonIndexArray[index + 1] * 2; + var p2 = polygonIndexArray[index + 2] * 2; + + var x0 = polygonCache[p0 + 0]; + var y0 = polygonCache[p0 + 1]; + var x1 = polygonCache[p1 + 0]; + var y1 = polygonCache[p1 + 1]; + var x2 = polygonCache[p2 + 0]; + var y2 = polygonCache[p2 + 1]; + + var tx0 = calcMatrix.getX(x0, y0); + var ty0 = calcMatrix.getY(x0, y0); + + var tx1 = calcMatrix.getX(x1, y1); + var ty1 = calcMatrix.getY(x1, y1); + + var tx2 = calcMatrix.getX(x2, y2); + var ty2 = calcMatrix.getY(x2, y2); + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + this.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect); + } + + polygonCache.length = 0; + }, + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and calling `batchLine` for each section + * of the path. + * + * The path is optionally closed at the end. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokePath + * @since 3.12.0 + * + * @param {array} path - Collection of points that represent the path. + * @param {number} lineWidth - The width of the line segments in pixels. + * @param {boolean} pathOpen - Indicates if the path should be closed or left open. + * @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform. + */ + batchStrokePath: function (path, lineWidth, pathOpen, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + // Reset the closePath booleans + this.prevQuad[4] = 0; + this.firstQuad[4] = 0; + + var pathLength = path.length - 1; + + for (var pathIndex = 0; pathIndex < pathLength; pathIndex++) + { + var point0 = path[pathIndex]; + var point1 = path[pathIndex + 1]; + + this.batchLine( + point0.x, + point0.y, + point1.x, + point1.y, + point0.width / 2, + point1.width / 2, + lineWidth, + pathIndex, + !pathOpen && (pathIndex === pathLength - 1), + currentMatrix, + parentMatrix + ); + } + }, + + /** + * Creates a quad and adds it to the vertex batch based on the given line values. + * + * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchLine + * @since 3.12.0 + * + * @param {number} ax - X coordinate to the start of the line + * @param {number} ay - Y coordinate to the start of the line + * @param {number} bx - X coordinate to the end of the line + * @param {number} by - Y coordinate to the end of the line + * @param {number} aLineWidth - Width of the start of the line + * @param {number} bLineWidth - Width of the end of the line + * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers + */ + batchLine: function (ax, ay, bx, by, aLineWidth, bLineWidth, lineWidth, index, closePath, currentMatrix, parentMatrix) + { + this.renderer.setPipeline(this); + + var calcMatrix = this._tempMatrix3; + + // Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix + if (parentMatrix) + { + parentMatrix.multiply(currentMatrix, calcMatrix); + } + + var dx = bx - ax; + var dy = by - ay; + + var len = Math.sqrt(dx * dx + dy * dy); + var al0 = aLineWidth * (by - ay) / len; + var al1 = aLineWidth * (ax - bx) / len; + var bl0 = bLineWidth * (by - ay) / len; + var bl1 = bLineWidth * (ax - bx) / len; + + var lx0 = bx - bl0; + var ly0 = by - bl1; + var lx1 = ax - al0; + var ly1 = ay - al1; + var lx2 = bx + bl0; + var ly2 = by + bl1; + var lx3 = ax + al0; + var ly3 = ay + al1; + + // tx0 = bottom right + var brX = calcMatrix.getX(lx0, ly0); + var brY = calcMatrix.getY(lx0, ly0); + + // tx1 = bottom left + var blX = calcMatrix.getX(lx1, ly1); + var blY = calcMatrix.getY(lx1, ly1); + + // tx2 = top right + var trX = calcMatrix.getX(lx2, ly2); + var trY = calcMatrix.getY(lx2, ly2); + + // tx3 = top left + var tlX = calcMatrix.getX(lx3, ly3); + var tlY = calcMatrix.getY(lx3, ly3); + + var tint = this.strokeTint; + var tintEffect = this.tintEffect; + + var tintTL = tint.TL; + var tintTR = tint.TR; + var tintBL = tint.BL; + var tintBR = tint.BR; + + var frame = this.currentFrame; + + var u0 = frame.u0; + var v0 = frame.v0; + var u1 = frame.u1; + var v1 = frame.v1; + + // TL, BL, BR, TR + this.batchQuad(tlX, tlY, blX, blY, brX, brY, trX, trY, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + + if (lineWidth <= 2) + { + // No point doing a linejoin if the line isn't thick enough + return; + } + + var prev = this.prevQuad; + var first = this.firstQuad; + + if (index > 0 && prev[4]) + { + this.batchQuad(tlX, tlY, blX, blY, prev[0], prev[1], prev[2], prev[3], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + else + { + first[0] = tlX; + first[1] = tlY; + first[2] = blX; + first[3] = blY; + first[4] = 1; + } + + if (closePath && first[4]) + { + // Add a join for the final path segment + this.batchQuad(brX, brY, trX, trY, first[0], first[1], first[2], first[3], u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect); + } + else + { + // Store it + + prev[0] = brX; + prev[1] = brY; + prev[2] = trX; + prev[3] = trY; + prev[4] = 1; + } } }); diff --git a/src/renderer/webgl/pipelines/index.js b/src/renderer/webgl/pipelines/index.js index d340eefe9..bfbc04d9f 100644 --- a/src/renderer/webgl/pipelines/index.js +++ b/src/renderer/webgl/pipelines/index.js @@ -11,7 +11,6 @@ module.exports = { BitmapMaskPipeline: require('./BitmapMaskPipeline'), - FlatTintPipeline: require('./FlatTintPipeline'), ForwardDiffuseLightPipeline: require('./ForwardDiffuseLightPipeline'), TextureTintPipeline: require('./TextureTintPipeline') diff --git a/src/renderer/webgl/shaders/FlatTint-frag.js b/src/renderer/webgl/shaders/FlatTint-frag.js deleted file mode 100644 index c4d50a021..000000000 --- a/src/renderer/webgl/shaders/FlatTint-frag.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = [ - '#define SHADER_NAME PHASER_FLAT_TINT_FS', - '', - 'precision mediump float;', - '', - 'varying vec4 outTint;', - '', - 'void main() {', - ' gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a);', - '}', - '' -].join('\n'); diff --git a/src/renderer/webgl/shaders/FlatTint-vert.js b/src/renderer/webgl/shaders/FlatTint-vert.js deleted file mode 100644 index a72b538a0..000000000 --- a/src/renderer/webgl/shaders/FlatTint-vert.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = [ - '#define SHADER_NAME PHASER_FLAT_TINT_VS', - '', - 'precision mediump float;', - '', - 'uniform mat4 uProjectionMatrix;', - 'uniform mat4 uViewMatrix;', - 'uniform mat4 uModelMatrix;', - '', - 'attribute vec2 inPosition;', - 'attribute vec4 inTint;', - '', - 'varying vec4 outTint;', - '', - 'void main () {', - ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', - ' outTint = inTint;', - '}', - '' -].join('\n'); diff --git a/src/renderer/webgl/shaders/ForwardDiffuse-frag.js b/src/renderer/webgl/shaders/ForwardDiffuse-frag.js index 36fb4bfb4..ec391f178 100644 --- a/src/renderer/webgl/shaders/ForwardDiffuse-frag.js +++ b/src/renderer/webgl/shaders/ForwardDiffuse-frag.js @@ -19,6 +19,7 @@ module.exports = [ 'uniform sampler2D uNormSampler;', 'uniform vec3 uAmbientLightColor;', 'uniform Light uLights[kMaxLights];', + 'uniform mat3 uInverseRotationMatrix;', '', 'varying vec2 outTexCoord;', 'varying vec4 outTint;', @@ -28,7 +29,7 @@ module.exports = [ ' vec3 finalColor = vec3(0.0, 0.0, 0.0);', ' vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);', ' vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb;', - ' vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0));', + ' vec3 normal = normalize(uInverseRotationMatrix * vec3(normalMap * 2.0 - 1.0));', ' vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w;', '', ' for (int index = 0; index < kMaxLights; ++index)', diff --git a/src/renderer/webgl/shaders/GBuffer-frag.js b/src/renderer/webgl/shaders/GBuffer-frag.js deleted file mode 100644 index 49eb9fe44..000000000 --- a/src/renderer/webgl/shaders/GBuffer-frag.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = [ - '#extension GL_EXT_draw_buffers : require', - '', - '#define SHADER_NAME PHASER_GBUFFER_FS', - '', - 'precision mediump float;', - '', - 'uniform sampler2D uMainSampler;', - 'uniform sampler2D uNormSampler;', - '', - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - '', - 'void main()', - '{', - ' vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a);', - ' vec3 normal = texture2D(uNormSampler, outTexCoord).rgb;', - '', - ' gl_FragData[0] = color;', - ' gl_FragData[1] = vec4(normal, color.a);', - '}', - '' -].join('\n'); diff --git a/src/renderer/webgl/shaders/TextureTint-frag.js b/src/renderer/webgl/shaders/TextureTint-frag.js index c979396b4..fc7cfdaf6 100644 --- a/src/renderer/webgl/shaders/TextureTint-frag.js +++ b/src/renderer/webgl/shaders/TextureTint-frag.js @@ -6,13 +6,33 @@ module.exports = [ 'uniform sampler2D uMainSampler;', '', 'varying vec2 outTexCoord;', + 'varying float outTintEffect;', 'varying vec4 outTint;', '', 'void main()', '{', - ' vec4 texel = texture2D(uMainSampler, outTexCoord);', - ' texel *= vec4(outTint.rgb * outTint.a, outTint.a);', - ' gl_FragColor = texel;', + ' vec4 texture = texture2D(uMainSampler, outTexCoord);', + ' vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);', + ' vec4 color = texture;', + '', + ' if (outTintEffect == 0.0)', + ' {', + ' // Multiply texture tint', + ' color = texture * texel;', + ' }', + ' else if (outTintEffect == 1.0)', + ' {', + ' // Solid color + texture alpha', + ' color.rgb = mix(texture.rgb, outTint.rgb * outTint.a, texture.a);', + ' color.a = texture.a * texel.a;', + ' }', + ' else if (outTintEffect == 2.0)', + ' {', + ' // Solid color, no texture', + ' color = texel;', + ' }', + '', + ' gl_FragColor = color;', '}', '' ].join('\n'); diff --git a/src/renderer/webgl/shaders/TextureTint-vert.js b/src/renderer/webgl/shaders/TextureTint-vert.js index fcaa647a5..a9461d030 100644 --- a/src/renderer/webgl/shaders/TextureTint-vert.js +++ b/src/renderer/webgl/shaders/TextureTint-vert.js @@ -9,16 +9,20 @@ module.exports = [ '', 'attribute vec2 inPosition;', 'attribute vec2 inTexCoord;', + 'attribute float inTintEffect;', 'attribute vec4 inTint;', '', 'varying vec2 outTexCoord;', + 'varying float outTintEffect;', 'varying vec4 outTint;', '', 'void main ()', '{', ' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);', + '', ' outTexCoord = inTexCoord;', ' outTint = inTint;', + ' outTintEffect = inTintEffect;', '}', '', '' diff --git a/src/renderer/webgl/shaders/src/FlatTint.frag b/src/renderer/webgl/shaders/src/FlatTint.frag deleted file mode 100644 index 892a4ba0f..000000000 --- a/src/renderer/webgl/shaders/src/FlatTint.frag +++ /dev/null @@ -1,9 +0,0 @@ -#define SHADER_NAME PHASER_FLAT_TINT_FS - -precision mediump float; - -varying vec4 outTint; - -void main() { - gl_FragColor = vec4(outTint.rgb * outTint.a, outTint.a); -} diff --git a/src/renderer/webgl/shaders/src/FlatTint.vert b/src/renderer/webgl/shaders/src/FlatTint.vert deleted file mode 100644 index 85a077b33..000000000 --- a/src/renderer/webgl/shaders/src/FlatTint.vert +++ /dev/null @@ -1,17 +0,0 @@ -#define SHADER_NAME PHASER_FLAT_TINT_VS - -precision mediump float; - -uniform mat4 uProjectionMatrix; -uniform mat4 uViewMatrix; -uniform mat4 uModelMatrix; - -attribute vec2 inPosition; -attribute vec4 inTint; - -varying vec4 outTint; - -void main () { - gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0); - outTint = inTint; -} diff --git a/src/renderer/webgl/shaders/src/ForwardDiffuse.frag b/src/renderer/webgl/shaders/src/ForwardDiffuse.frag index bc737f9a4..eecef7c0e 100644 --- a/src/renderer/webgl/shaders/src/ForwardDiffuse.frag +++ b/src/renderer/webgl/shaders/src/ForwardDiffuse.frag @@ -18,6 +18,7 @@ uniform sampler2D uMainSampler; uniform sampler2D uNormSampler; uniform vec3 uAmbientLightColor; uniform Light uLights[kMaxLights]; +uniform mat3 uInverseRotationMatrix; varying vec2 outTexCoord; varying vec4 outTint; @@ -27,7 +28,7 @@ void main() vec3 finalColor = vec3(0.0, 0.0, 0.0); vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a); vec3 normalMap = texture2D(uNormSampler, outTexCoord).rgb; - vec3 normal = normalize(vec3(normalMap * 2.0 - 1.0)); + vec3 normal = normalize(uInverseRotationMatrix * vec3(normalMap * 2.0 - 1.0)); vec2 res = vec2(min(uResolution.x, uResolution.y)) * uCamera.w; for (int index = 0; index < kMaxLights; ++index) diff --git a/src/renderer/webgl/shaders/src/GBuffer.frag b/src/renderer/webgl/shaders/src/GBuffer.frag deleted file mode 100644 index 99cf03927..000000000 --- a/src/renderer/webgl/shaders/src/GBuffer.frag +++ /dev/null @@ -1,20 +0,0 @@ -#extension GL_EXT_draw_buffers : require - -#define SHADER_NAME PHASER_GBUFFER_FS - -precision mediump float; - -uniform sampler2D uMainSampler; -uniform sampler2D uNormSampler; - -varying vec2 outTexCoord; -varying vec4 outTint; - -void main() -{ - vec4 color = texture2D(uMainSampler, outTexCoord) * vec4(outTint.rgb * outTint.a, outTint.a); - vec3 normal = texture2D(uNormSampler, outTexCoord).rgb; - - gl_FragData[0] = color; - gl_FragData[1] = vec4(normal, color.a); -} diff --git a/src/renderer/webgl/shaders/src/TextureTint.frag b/src/renderer/webgl/shaders/src/TextureTint.frag index 4078308a1..c4e90fdd1 100644 --- a/src/renderer/webgl/shaders/src/TextureTint.frag +++ b/src/renderer/webgl/shaders/src/TextureTint.frag @@ -5,11 +5,31 @@ precision mediump float; uniform sampler2D uMainSampler; varying vec2 outTexCoord; +varying float outTintEffect; varying vec4 outTint; -void main() +void main() { - vec4 texel = texture2D(uMainSampler, outTexCoord); - texel *= vec4(outTint.rgb * outTint.a, outTint.a); - gl_FragColor = texel; + vec4 texture = texture2D(uMainSampler, outTexCoord); + vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a); + vec4 color = texture; + + if (outTintEffect == 0.0) + { + // Multiply texture tint + color = texture * texel; + } + else if (outTintEffect == 1.0) + { + // Solid color + texture alpha + color.rgb = mix(texture.rgb, outTint.rgb * outTint.a, texture.a); + color.a = texture.a * texel.a; + } + else if (outTintEffect == 2.0) + { + // Solid color, no texture + color = texel; + } + + gl_FragColor = color; } diff --git a/src/renderer/webgl/shaders/src/TextureTint.vert b/src/renderer/webgl/shaders/src/TextureTint.vert index 16d9f7e3f..819df76eb 100644 --- a/src/renderer/webgl/shaders/src/TextureTint.vert +++ b/src/renderer/webgl/shaders/src/TextureTint.vert @@ -8,15 +8,19 @@ uniform mat4 uModelMatrix; attribute vec2 inPosition; attribute vec2 inTexCoord; +attribute float inTintEffect; attribute vec4 inTint; varying vec2 outTexCoord; +varying float outTintEffect; varying vec4 outTint; void main () { gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0); + outTexCoord = inTexCoord; outTint = inTint; + outTintEffect = inTintEffect; } diff --git a/src/scene/GetScenePlugins.js b/src/scene/GetScenePlugins.js index e37010858..d92fdb320 100644 --- a/src/scene/GetScenePlugins.js +++ b/src/scene/GetScenePlugins.js @@ -12,9 +12,9 @@ var GetFastValue = require('../utils/object/GetFastValue'); * @function Phaser.Scenes.GetScenePlugins * @since 3.0.0 * - * @param {Phaser.Scenes.Systems} sys - [description] + * @param {Phaser.Scenes.Systems} sys - The Scene Systems object to check for plugins. * - * @return {array} [description] + * @return {array} An array of all plugins which should be activated, either the default ones or the ones configured in the Scene Systems object. */ var GetScenePlugins = function (sys) { diff --git a/src/scene/InjectionMap.js b/src/scene/InjectionMap.js index c364ab012..a4c47f5d6 100644 --- a/src/scene/InjectionMap.js +++ b/src/scene/InjectionMap.js @@ -22,12 +22,12 @@ var InjectionMap = { cache: 'cache', plugins: 'plugins', registry: 'registry', + scale: 'scale', sound: 'sound', textures: 'textures', events: 'events', cameras: 'cameras', - cameras3d: 'cameras3d', add: 'add', make: 'make', scenePlugin: 'scene', @@ -46,4 +46,14 @@ var InjectionMap = { }; +if (typeof PLUGIN_CAMERA3D) +{ + InjectionMap.cameras3d = 'cameras3d'; +} + +if (typeof PLUGIN_FBINSTANT) +{ + InjectionMap.facebook = 'facebook'; +} + module.exports = InjectionMap; diff --git a/src/scene/Scene.js b/src/scene/Scene.js index 063b48e60..3162ffd99 100644 --- a/src/scene/Scene.js +++ b/src/scene/Scene.js @@ -9,10 +9,10 @@ var Systems = require('./Systems'); /** * @classdesc - * [description] + * A base Phaser.Scene class which you could extend for your own use. * * @class Scene - * @memberOf Phaser + * @memberof Phaser * @constructor * @since 3.0.0 * @@ -113,16 +113,6 @@ var Scene = new Class({ */ this.cameras; - /** - * A scene level 3D Camera System. - * This property will only be available if defined in the Scene Injection Map. - * - * @name Phaser.Scene#cameras3d - * @type {Phaser.Cameras.Sprite3D.CameraManager} - * @since 3.0.0 - */ - this.cameras3d; - /** * A scene level Game Object Factory. * This property will only be available if defined in the Scene Injection Map. @@ -252,6 +242,19 @@ var Scene = new Class({ * @since 3.0.0 */ this.matter; + + if (typeof PLUGIN_FBINSTANT) + { + /** + * A scene level Facebook Instant Games Plugin. + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + * + * @name Phaser.Scene#facebook + * @type {Phaser.FacebookInstantGamesPlugin} + * @since 3.12.0 + */ + this.facebook; + } }, /** @@ -261,8 +264,8 @@ var Scene = new Class({ * @override * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function () { diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index 15afce399..9fac22443 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -20,7 +20,7 @@ var Systems = require('./Systems'); * * * @class SceneManager - * @memberOf Phaser.Scenes + * @memberof Phaser.Scenes * @constructor * @since 3.0.0 * @@ -106,7 +106,7 @@ var SceneManager = new Class({ * @name Phaser.Scenes.SceneManager#isProcessing * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isProcessing = false; @@ -117,11 +117,22 @@ var SceneManager = new Class({ * @name Phaser.Scenes.SceneManager#isBooted * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.4.0 */ this.isBooted = false; + /** + * Do any of the Cameras in any of the Scenes require a custom viewport? + * If not we can skip scissor tests. + * + * @name Phaser.Scenes.SceneManager#customViewports + * @type {number} + * @default 0 + * @since 3.12.0 + */ + this.customViewports = 0; + if (sceneConfig) { if (!Array.isArray(sceneConfig)) @@ -377,7 +388,7 @@ var SceneManager = new Class({ * The Scene is removed from the local scenes array, it's key is cleared from the keys * cache and Scene.Systems.destroy is then called on it. * - * If the SceneManager is processing the Scenes when this method is called it wil + * If the SceneManager is processing the Scenes when this method is called it will * queue the operation for the next update sequence. * * @method Phaser.Scenes.SceneManager#remove @@ -1091,29 +1102,40 @@ var SceneManager = new Class({ if (scene) { - scene.sys.start(data); - - var loader; - - if (scene.sys.load) + // If the Scene is already running (perhaps they called start from a launched sub-Scene?) + // then we close it down before starting it again. + if (scene.sys.isActive() || scene.sys.isPaused()) { - loader = scene.sys.load; + scene.sys.shutdown(); + + scene.sys.start(data); } - - // Files payload? - if (loader && scene.sys.settings.hasOwnProperty('pack')) + else { - loader.reset(); + scene.sys.start(data); - if (loader.addPack({ payload: scene.sys.settings.pack })) + var loader; + + if (scene.sys.load) { - scene.sys.settings.status = CONST.LOADING; - - loader.once('complete', this.payloadComplete, this); - - loader.start(); - - return this; + loader = scene.sys.load; + } + + // Files payload? + if (loader && scene.sys.settings.hasOwnProperty('pack')) + { + loader.reset(); + + if (loader.addPack({ payload: scene.sys.settings.pack })) + { + scene.sys.settings.status = CONST.LOADING; + + loader.once('complete', this.payloadComplete, this); + + loader.start(); + + return this; + } } } @@ -1532,7 +1554,7 @@ var SceneManager = new Class({ */ destroy: function () { - for (var i = this.scenes.length - 1; i >= 0; i--) + for (var i = 0; i < this.scenes.length; i++) { var sys = this.scenes[i].sys; diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index 103aa4be8..e48162406 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -6,7 +6,6 @@ var Clamp = require('../math/Clamp'); var Class = require('../utils/Class'); -var CONST = require('./const'); var GetFastValue = require('../utils/object/GetFastValue'); var PluginCache = require('../plugins/PluginCache'); @@ -15,7 +14,7 @@ var PluginCache = require('../plugins/PluginCache'); * A proxy class to the Global Scene Manager. * * @class ScenePlugin - * @memberOf Phaser.Scenes + * @memberof Phaser.Scenes * @constructor * @since 3.0.0 * @@ -211,7 +210,7 @@ var ScenePlugin = new Class({ * * @method Phaser.Scenes.ScenePlugin#restart * @since 3.4.0 - * + * * @param {object} [data] - The Scene data. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. @@ -228,7 +227,7 @@ var ScenePlugin = new Class({ /** * @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`) @@ -242,26 +241,26 @@ var ScenePlugin = new Class({ /** * 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. - * + * as the Scenes `init` and `create` methods are not invoked when a Scene 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. + * These events are cleared of all 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 @@ -269,7 +268,7 @@ var ScenePlugin = new Class({ * 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 * @@ -372,8 +371,8 @@ var ScenePlugin = new Class({ * @private * @since 3.5.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ step: function (time, delta) { @@ -444,12 +443,13 @@ var ScenePlugin = new Class({ * @param {string} key - The Scene key. * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The config for the Scene. * @param {boolean} autoStart - Whether to start the Scene after it's added. + * @param {object} [data] - Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - add: function (key, sceneConfig, autoStart) + add: function (key, sceneConfig, autoStart, data) { - this.manager.add(key, sceneConfig, autoStart); + this.manager.add(key, sceneConfig, autoStart, data); return this; }, @@ -469,14 +469,7 @@ var ScenePlugin = new Class({ { if (key && key !== this.key) { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('start', key, data); - } - else - { - this.manager.start(key, data); - } + this.manager.queueOp('start', key, data); } return this; @@ -484,7 +477,7 @@ var ScenePlugin = new Class({ /** * Runs the given Scene, but does not change the state of this Scene. - * + * * If the given Scene is paused, it will resume it. If sleeping, it will wake it. * If not running at all, it will be started. * @@ -501,14 +494,10 @@ var ScenePlugin = new Class({ */ run: function (key, data) { - if (this.settings.status !== CONST.RUNNING) + if (key && key !== this.key) { this.manager.queueOp('run', key, data); } - else - { - this.manager.run(key, data); - } return this; }, @@ -528,7 +517,7 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - this.manager.pause(key, data); + this.manager.queueOp('pause', key, data); return this; }, @@ -548,7 +537,7 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - this.manager.resume(key, data); + this.manager.queueOp('resume', key, data); return this; }, @@ -568,7 +557,7 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - this.manager.sleep(key, data); + this.manager.queueOp('sleep', key, data); return this; }, @@ -579,7 +568,7 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#wake * @since 3.0.0 * - * @param {string} key - The Scene to wake up. + * @param {string} [key] - The Scene to wake up. * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its wake event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. @@ -588,7 +577,7 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - this.manager.wake(key, data); + this.manager.queueOp('wake', key, data); return this; }, @@ -607,14 +596,7 @@ var ScenePlugin = new Class({ { if (key !== this.key) { - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('switch', this.key, key); - } - else - { - this.manager.switch(this.key, key); - } + this.manager.queueOp('switch', this.key, key); } return this; @@ -634,7 +616,7 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - this.manager.stop(key); + this.manager.queueOp('stop', key); return this; }, diff --git a/src/scene/Settings.js b/src/scene/Settings.js index 7009d362b..2f338011a 100644 --- a/src/scene/Settings.js +++ b/src/scene/Settings.js @@ -16,50 +16,50 @@ var InjectionMap = require('./InjectionMap'); /** * @typedef {object} Phaser.Scenes.Settings.Config * - * @property {string} [key] - [description] - * @property {boolean} [active=false] - [description] - * @property {boolean} [visible=true] - [description] - * @property {(false|Phaser.Loader.FileTypes.PackFileConfig)} [pack=false] - [description] - * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} [cameras=null] - [description] + * @property {string} [key] - The unique key of this Scene. Must be unique within the entire Game instance. + * @property {boolean} [active=false] - Does the Scene start as active or not? An active Scene updates each step. + * @property {boolean} [visible=true] - Does the Scene start as visible or not? A visible Scene renders each step. + * @property {(false|Phaser.Loader.FileTypes.PackFileConfig)} [pack=false] - An optional Loader Packfile to be loaded before the Scene begins. + * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} [cameras=null] - An optional Camera configuration object. * @property {Object.} [map] - Overwrites the default injection map for a scene. * @property {Object.} [mapAdd] - Extends the injection map for a scene. - * @property {object} [physics={}] - [description] - * @property {object} [loader={}] - [description] - * @property {(false|*)} [plugins=false] - [description] + * @property {object} [physics={}] - The physics configuration object for the Scene. + * @property {object} [loader={}] - The loader configuration object for the Scene. + * @property {(false|*)} [plugins=false] - The plugin configuration object for the Scene. */ /** * @typedef {object} Phaser.Scenes.Settings.Object * - * @property {number} status - [description] - * @property {string} key - [description] - * @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|Phaser.Loader.FileTypes.PackFileConfig)} pack - [description] - * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} cameras - [description] - * @property {Object.} map - [description] - * @property {object} physics - [description] - * @property {object} loader - [description] - * @property {(false|*)} plugins - [description] + * @property {number} status - The current status of the Scene. Maps to the Scene constants. + * @property {string} key - The unique key of this Scene. Unique within the entire Game instance. + * @property {boolean} active - The active state of this Scene. An active Scene updates each step. + * @property {boolean} visible - The visible state of this Scene. A visible Scene renders each step. + * @property {boolean} isBooted - Has the Scene finished booting? + * @property {boolean} isTransition - Is the Scene in a state of transition? + * @property {?Phaser.Scene} transitionFrom - The Scene this Scene is transitioning from, if set. + * @property {integer} transitionDuration - The duration of the transition, if set. + * @property {boolean} transitionAllowInput - Is this Scene allowed to receive input during transitions? + * @property {object} data - a data bundle passed to this Scene from the Scene Manager. + * @property {(false|Phaser.Loader.FileTypes.PackFileConfig)} pack - The Loader Packfile to be loaded before the Scene begins. + * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} cameras - The Camera configuration object. + * @property {Object.} map - The Scene's Injection Map. + * @property {object} physics - The physics configuration object for the Scene. + * @property {object} loader - The loader configuration object for the Scene. + * @property {(false|*)} plugins - The plugin configuration object for the Scene. */ var Settings = { /** - * Takes a Scene configuration object and returns a fully formed Systems object. + * Takes a Scene configuration object and returns a fully formed System Settings object. * * @function Phaser.Scenes.Settings.create * @since 3.0.0 * - * @param {(string|Phaser.Scenes.Settings.Config)} config - [description] + * @param {(string|Phaser.Scenes.Settings.Config)} config - The Scene configuration object used to create this Scene Settings. * - * @return {Phaser.Scenes.Settings.Object} [description] + * @return {Phaser.Scenes.Settings.Object} The Scene Settings object created as a result of the config and default settings. */ create: function (config) { diff --git a/src/scene/Systems.js b/src/scene/Systems.js index 512293b22..ef07b5cd7 100644 --- a/src/scene/Systems.js +++ b/src/scene/Systems.js @@ -21,7 +21,7 @@ var Settings = require('./Settings'); * handling the update step and renderer. It also contains references to global systems belonging to Game. * * @class Systems - * @memberOf Phaser.Scenes + * @memberof Phaser.Scenes * @constructor * @since 3.0.0 * @@ -35,7 +35,7 @@ var Systems = new Class({ function Systems (scene, config) { /** - * [description] + * A reference to the Scene that these Systems belong to. * * @name Phaser.Scenes.Systems#scene * @type {Phaser.Scene} @@ -44,7 +44,7 @@ var Systems = new Class({ this.scene = scene; /** - * [description] + * A reference to the Phaser Game instance. * * @name Phaser.Scenes.Systems#game * @type {Phaser.Game} @@ -52,8 +52,20 @@ var Systems = new Class({ */ this.game; + if (typeof PLUGIN_FBINSTANT) + { + /** + * The Facebook Instant Games Plugin. + * + * @name Phaser.Scenes.Systems#facebook + * @type {Phaser.FacebookInstantGamesPlugin} + * @since 3.12.0 + */ + this.facebook; + } + /** - * [description] + * The Scene Configuration object, as passed in when creating the Scene. * * @name Phaser.Scenes.Systems#config * @type {(string|Phaser.Scenes.Settings.Config)} @@ -62,7 +74,7 @@ var Systems = new Class({ this.config = config; /** - * [description] + * The Scene Settings. This is the parsed output based on the Scene configuration. * * @name Phaser.Scenes.Systems#settings * @type {Phaser.Scenes.Settings.Object} @@ -80,7 +92,7 @@ var Systems = new Class({ this.canvas; /** - * [description] + * A reference to the Canvas Rendering Context being used by the renderer. * * @name Phaser.Scenes.Systems#context * @type {CanvasRenderingContext2D} @@ -91,7 +103,9 @@ var Systems = new Class({ // Global Systems - these are single-instance global managers that belong to Game /** - * [description] + * A reference to the global Animations Manager. + * + * In the default set-up you can access this from within a Scene via the `this.anims` property. * * @name Phaser.Scenes.Systems#anims * @type {Phaser.Animations.AnimationManager} @@ -100,7 +114,10 @@ var Systems = new Class({ this.anims; /** - * [description] + * A reference to the global Cache. The Cache stores all files bought in to Phaser via + * the Loader, with the exception of images. Images are stored in the Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.cache` property. * * @name Phaser.Scenes.Systems#cache * @type {Phaser.Cache.CacheManager} @@ -109,7 +126,9 @@ var Systems = new Class({ this.cache; /** - * [description] + * A reference to the global Plugins Manager. + * + * In the default set-up you can access this from within a Scene via the `this.plugins` property. * * @name Phaser.Scenes.Systems#plugins * @type {Phaser.Plugins.PluginManager} @@ -118,7 +137,10 @@ var Systems = new Class({ this.plugins; /** - * [description] + * A reference to the global registry. This is a game-wide instance of the Data Manager, allowing + * you to exchange data between Scenes via a universal and shared point. + * + * In the default set-up you can access this from within a Scene via the `this.registry` property. * * @name Phaser.Scenes.Systems#registry * @type {Phaser.Data.DataManager} @@ -127,7 +149,20 @@ var Systems = new Class({ this.registry; /** - * [description] + * A reference to the global Scale Manager. + * + * In the default set-up you can access this from within a Scene via the `this.scale` property. + * + * @name Phaser.Scenes.Systems#scale + * @type {Phaser.DOM.ScaleManager} + * @since 3.15.0 + */ + this.scale; + + /** + * A reference to the global Sound Manager. + * + * In the default set-up you can access this from within a Scene via the `this.sound` property. * * @name Phaser.Scenes.Systems#sound * @type {Phaser.Sound.BaseSoundManager} @@ -136,7 +171,9 @@ var Systems = new Class({ this.sound; /** - * [description] + * A reference to the global Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.textures` property. * * @name Phaser.Scenes.Systems#textures * @type {Phaser.Textures.TextureManager} @@ -147,7 +184,11 @@ var Systems = new Class({ // Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems /** - * [description] + * A reference to the Scene's Game Object Factory. + * + * Use this to quickly and easily create new Game Object's. + * + * In the default set-up you can access this from within a Scene via the `this.add` property. * * @name Phaser.Scenes.Systems#add * @type {Phaser.GameObjects.GameObjectFactory} @@ -156,7 +197,11 @@ var Systems = new Class({ this.add; /** - * [description] + * A reference to the Scene's Camera Manager. + * + * Use this to manipulate and create Cameras for this specific Scene. + * + * In the default set-up you can access this from within a Scene via the `this.cameras` property. * * @name Phaser.Scenes.Systems#cameras * @type {Phaser.Cameras.Scene2D.CameraManager} @@ -165,7 +210,11 @@ var Systems = new Class({ this.cameras; /** - * [description] + * A reference to the Scene's Display List. + * + * Use this to organize the children contained in the display list. + * + * In the default set-up you can access this from within a Scene via the `this.children` property. * * @name Phaser.Scenes.Systems#displayList * @type {Phaser.GameObjects.DisplayList} @@ -174,7 +223,11 @@ var Systems = new Class({ this.displayList; /** - * [description] + * A reference to the Scene's Event Manager. + * + * Use this to listen for Scene specific events, such as `pause` and `shutdown`. + * + * In the default set-up you can access this from within a Scene via the `this.events` property. * * @name Phaser.Scenes.Systems#events * @type {Phaser.Events.EventEmitter} @@ -183,7 +236,13 @@ var Systems = new Class({ this.events; /** - * [description] + * A reference to the Scene's Game Object Creator. + * + * Use this to quickly and easily create new Game Object's. The difference between this and the + * Game Object Factory, is that the Creator just creates and returns Game Object instances, it + * doesn't then add them to the Display List or Update List. + * + * In the default set-up you can access this from within a Scene via the `this.make` property. * * @name Phaser.Scenes.Systems#make * @type {Phaser.GameObjects.GameObjectCreator} @@ -192,7 +251,12 @@ var Systems = new Class({ this.make; /** - * [description] + * A reference to the Scene Manager Plugin. + * + * Use this to manipulate both this and other Scene's in your game, for example to launch a parallel Scene, + * or pause or resume a Scene, or switch from this Scene to another. + * + * In the default set-up you can access this from within a Scene via the `this.scene` property. * * @name Phaser.Scenes.Systems#scenePlugin * @type {Phaser.Scenes.ScenePlugin} @@ -201,7 +265,14 @@ var Systems = new Class({ this.scenePlugin; /** - * [description] + * A reference to the Scene's Update List. + * + * Use this to organize the children contained in the update list. + * + * The Update List is responsible for managing children that need their `preUpdate` methods called, + * in order to process so internal components, such as Sprites with Animations. + * + * In the default set-up there is no reference to this from within the Scene itself. * * @name Phaser.Scenes.Systems#updateList * @type {Phaser.GameObjects.UpdateList} @@ -298,13 +369,13 @@ var Systems = new Class({ }, /** - * Called automatically by the Scene Manager. Instructs the Scene to render itself via - * its Camera Manager to the renderer given. + * 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 * - * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - [description] + * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The renderer that invoked the render call. */ render: function (renderer) { @@ -450,7 +521,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#isSleeping * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Scene is asleep, otherwise `false`. */ isSleeping: function () { @@ -463,13 +534,26 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#isActive * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Scene is active, otherwise `false`. */ isActive: function () { return (this.settings.status === CONST.RUNNING); }, + /** + * Is this Scene paused? + * + * @method Phaser.Scenes.Systems#isPaused + * @since 3.13.0 + * + * @return {boolean} `true` if this Scene is paused, otherwise `false`. + */ + isPaused: function () + { + return (this.settings.status === CONST.PAUSED); + }, + /** * Is this Scene currently transitioning out to, or in from another Scene? * @@ -515,7 +599,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#isVisible * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Scene is visible, otherwise `false`. */ isVisible: function () { @@ -529,7 +613,7 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#setVisible * @since 3.0.0 * - * @param {boolean} value - [description] + * @param {boolean} value - `true` to render this Scene, otherwise `false`. * * @return {Phaser.Scenes.Systems} This Systems object. */ diff --git a/src/scene/const.js b/src/scene/const.js index 978827e37..952544faa 100644 --- a/src/scene/const.js +++ b/src/scene/const.js @@ -16,7 +16,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.PENDING - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -26,7 +26,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.INIT - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -36,7 +36,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.START - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -46,7 +46,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.LOADING - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -56,7 +56,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.CREATING - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -66,7 +66,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.RUNNING - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -76,7 +76,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.PAUSED - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -86,7 +86,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.SLEEPING - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -96,7 +96,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.SHUTDOWN - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ @@ -106,7 +106,7 @@ var CONST = { * Scene state. * * @name Phaser.Scenes.DESTROYED - * @readOnly + * @readonly * @type {integer} * @since 3.0.0 */ diff --git a/src/sound/BaseSound.js b/src/sound/BaseSound.js index a1a789cfe..759f8786a 100644 --- a/src/sound/BaseSound.js +++ b/src/sound/BaseSound.js @@ -16,7 +16,7 @@ var NOOP = require('../utils/NOOP'); * * @class BaseSound * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -49,7 +49,7 @@ var BaseSound = new Class({ * * @name Phaser.Sound.BaseSound#key * @type {string} - * @readOnly + * @readonly * @since 3.0.0 */ this.key = key; @@ -60,7 +60,7 @@ var BaseSound = new Class({ * @name Phaser.Sound.BaseSound#isPlaying * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isPlaying = false; @@ -71,7 +71,7 @@ var BaseSound = new Class({ * @name Phaser.Sound.BaseSound#isPaused * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.isPaused = false; @@ -84,7 +84,7 @@ var BaseSound = new Class({ * @name Phaser.Sound.BaseSound#totalRate * @type {number} * @default 1 - * @readOnly + * @readonly * @since 3.0.0 */ this.totalRate = 1; @@ -95,7 +95,7 @@ var BaseSound = new Class({ * * @name Phaser.Sound.BaseSound#duration * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ this.duration = this.duration || 0; @@ -105,7 +105,7 @@ var BaseSound = new Class({ * * @name Phaser.Sound.BaseSound#totalDuration * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ this.totalDuration = this.totalDuration || 0; @@ -150,7 +150,7 @@ var BaseSound = new Class({ * @name Phaser.Sound.BaseSound#markers * @type {Object.} * @default {} - * @readOnly + * @readonly * @since 3.0.0 */ this.markers = {}; @@ -162,7 +162,7 @@ var BaseSound = new Class({ * @name Phaser.Sound.BaseSound#currentMarker * @type {SoundMarker} * @default null - * @readOnly + * @readonly * @since 3.0.0 */ this.currentMarker = null; diff --git a/src/sound/BaseSoundManager.js b/src/sound/BaseSoundManager.js index 89e4083cf..607241b49 100644 --- a/src/sound/BaseSoundManager.js +++ b/src/sound/BaseSoundManager.js @@ -38,7 +38,7 @@ var NOOP = require('../utils/NOOP'); * * @class BaseSoundManager * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -59,7 +59,7 @@ var BaseSoundManager = new Class({ * * @name Phaser.Sound.BaseSoundManager#game * @type {Phaser.Game} - * @readOnly + * @readonly * @since 3.0.0 */ this.game = game; @@ -69,7 +69,7 @@ var BaseSoundManager = new Class({ * * @name Phaser.Sound.BaseSoundManager#jsonCache * @type {Phaser.Cache.BaseCache} - * @readOnly + * @readonly * @since 3.7.0 */ this.jsonCache = game.cache.json; @@ -145,7 +145,7 @@ var BaseSoundManager = new Class({ * * @name Phaser.Sound.BaseSoundManager#locked * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ this.locked = this.locked || false; diff --git a/src/sound/html5/HTML5AudioSound.js b/src/sound/html5/HTML5AudioSound.js index 40e9a03c1..49aa1ed22 100644 --- a/src/sound/html5/HTML5AudioSound.js +++ b/src/sound/html5/HTML5AudioSound.js @@ -14,7 +14,7 @@ var Class = require('../../utils/Class'); * * @class HTML5AudioSound * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -635,6 +635,8 @@ var HTML5AudioSound = new Class({ return; } + this.updateMute(); + this.emit('mute', this, value); } }, @@ -687,6 +689,8 @@ var HTML5AudioSound = new Class({ return; } + this.updateVolume(); + this.emit('volume', this, value); } }, diff --git a/src/sound/html5/HTML5AudioSoundManager.js b/src/sound/html5/HTML5AudioSoundManager.js index 4f85800ee..73d3581de 100644 --- a/src/sound/html5/HTML5AudioSoundManager.js +++ b/src/sound/html5/HTML5AudioSoundManager.js @@ -14,7 +14,7 @@ var HTML5AudioSound = require('./HTML5AudioSound'); * * @class HTML5AudioSoundManager * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * diff --git a/src/sound/noaudio/NoAudioSound.js b/src/sound/noaudio/NoAudioSound.js index 72f55d8ea..1ecbab921 100644 --- a/src/sound/noaudio/NoAudioSound.js +++ b/src/sound/noaudio/NoAudioSound.js @@ -21,7 +21,7 @@ var Extend = require('../../utils/object/Extend'); * * @class NoAudioSound * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * diff --git a/src/sound/noaudio/NoAudioSoundManager.js b/src/sound/noaudio/NoAudioSoundManager.js index acdee3328..23aefee67 100644 --- a/src/sound/noaudio/NoAudioSoundManager.js +++ b/src/sound/noaudio/NoAudioSoundManager.js @@ -22,7 +22,7 @@ var NOOP = require('../../utils/NOOP'); * * @class NoAudioSoundManager * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * diff --git a/src/sound/webaudio/WebAudioSound.js b/src/sound/webaudio/WebAudioSound.js index b8e3e6991..24da56c40 100644 --- a/src/sound/webaudio/WebAudioSound.js +++ b/src/sound/webaudio/WebAudioSound.js @@ -14,7 +14,7 @@ var Class = require('../../utils/Class'); * * @class WebAudioSound * @extends Phaser.Sound.BaseSound - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * diff --git a/src/sound/webaudio/WebAudioSoundManager.js b/src/sound/webaudio/WebAudioSoundManager.js index d36a31747..15bbc5b33 100644 --- a/src/sound/webaudio/WebAudioSoundManager.js +++ b/src/sound/webaudio/WebAudioSoundManager.js @@ -15,7 +15,7 @@ var WebAudioSound = require('./WebAudioSound'); * * @class WebAudioSoundManager * @extends Phaser.Sound.BaseSoundManager - * @memberOf Phaser.Sound + * @memberof Phaser.Sound * @constructor * @since 3.0.0 * @@ -144,13 +144,13 @@ var WebAudioSoundManager = new Class({ { var _this = this; - var unlock = function () + var unlockHandler = function unlockHandler () { _this.context.resume().then(function () { - document.body.removeEventListener('touchstart', unlock); - document.body.removeEventListener('touchend', unlock); - document.body.removeEventListener('click', unlock); + document.body.removeEventListener('touchstart', unlockHandler); + document.body.removeEventListener('touchend', unlockHandler); + document.body.removeEventListener('click', unlockHandler); _this.unlocked = true; }); @@ -158,9 +158,9 @@ var WebAudioSoundManager = new Class({ if (document.body) { - document.body.addEventListener('touchstart', unlock, false); - document.body.addEventListener('touchend', unlock, false); - document.body.addEventListener('click', unlock, false); + document.body.addEventListener('touchstart', unlockHandler, false); + document.body.addEventListener('touchend', unlockHandler, false); + document.body.addEventListener('click', unlockHandler, false); } }, @@ -174,7 +174,10 @@ var WebAudioSoundManager = new Class({ */ onBlur: function () { - this.context.suspend(); + if (!this.locked) + { + this.context.suspend(); + } }, /** @@ -187,7 +190,10 @@ var WebAudioSoundManager = new Class({ */ onFocus: function () { - this.context.resume(); + if (!this.locked) + { + this.context.resume(); + } }, /** diff --git a/src/structs/List.js b/src/structs/List.js index 0960e1362..43188e855 100644 --- a/src/structs/List.js +++ b/src/structs/List.js @@ -13,22 +13,22 @@ var StableSort = require('../utils/array/StableSort'); * @callback EachListCallback * @generic I - [item] * - * @param {*} item - [description] + * @param {*} item - The item which is currently being processed. * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. */ /** * @classdesc - * [description] + * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. * * @class List - * @memberOf Phaser.Structs + * @memberof Phaser.Structs * @constructor * @since 3.0.0 * * @generic T * - * @param {*} parent - [description] + * @param {*} parent - The parent of this list. */ var List = new Class({ @@ -58,7 +58,9 @@ var List = new Class({ this.list = []; /** - * [description] + * The index of the current element. + * + * This is used internally when iterating through the list with the {@link #first}, {@link #last}, {@link #get}, and {@link #previous} properties. * * @name Phaser.Structs.List#position * @type {integer} @@ -96,17 +98,17 @@ var List = new Class({ }, /** - * [description] + * Adds the given item to the end of the list. Each item must be unique. * * @method Phaser.Structs.List#add * @since 3.0.0 * * @genericUse {T} - [child,$return] * - * @param {*|Array.<*>} child - [description] + * @param {*|Array.<*>} child - The item, or array of items, to add to the list. * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. * - * @return {*} [description] + * @return {*} The list's underlying array. */ add: function (child, skipCallback) { @@ -121,18 +123,18 @@ var List = new Class({ }, /** - * [description] + * Adds an item to list, starting at a specified index. Each item must be unique within the list. * * @method Phaser.Structs.List#addAt * @since 3.0.0 * * @genericUse {T} - [child,$return] * - * @param {*} child - [description] - * @param {integer} [index=0] - [description] + * @param {*} child - The item, or array of items, to add to the list. + * @param {integer} [index=0] - The index in the list at which the element(s) will be inserted. * @param {boolean} [skipCallback=false] - Skip calling the List.addCallback if this child is added successfully. * - * @return {*} [description] + * @return {*} The List's underlying array. */ addAt: function (child, index, skipCallback) { @@ -147,16 +149,16 @@ var List = new Class({ }, /** - * [description] + * Retrieves the item at a given position inside the List. * * @method Phaser.Structs.List#getAt * @since 3.0.0 * * @genericUse {T} - [$return] * - * @param {integer} index - [description] + * @param {integer} index - The index of the item. * - * @return {*} [description] + * @return {*} The retrieved item, or `undefined` if it's outside the List's bounds. */ getAt: function (index) { @@ -164,16 +166,16 @@ var List = new Class({ }, /** - * [description] + * Locates an item within the List and returns its index. * * @method Phaser.Structs.List#getIndex * @since 3.0.0 * * @genericUse {T} - [child] * - * @param {*} child - [description] + * @param {*} child - The item to locate. * - * @return {integer} [description] + * @return {integer} The index of the item within the List, or -1 if it's not in the List. */ getIndex: function (child) { @@ -193,7 +195,7 @@ var List = new Class({ * * @param {string} property - The property to lexically sort by. * - * @return {Array.<*>} [description] + * @return {Phaser.Structs.List} This List object. */ sort: function (property) { @@ -208,7 +210,7 @@ var List = new Class({ }, /** - * [description] + * Internal handler for the {@link #sort} method which compares two items. * * @method Phaser.Structs.List#sortHandler * @private @@ -216,10 +218,10 @@ var List = new Class({ * * @genericUse {T} - [childA,childB] * - * @param {*} childA - [description] - * @param {*} childB - [description] + * @param {*} childA - The first item to compare. + * @param {*} childB - The second item to compare. * - * @return {integer} [description] + * @return {integer} The result of the comparison, which will be negative if the first item is smaller then second, positive if the first item is larger than the second, or 0 if they're equal. */ sortHandler: function (childA, childB) { @@ -264,7 +266,7 @@ var List = new Class({ }, /** - * [description] + * Returns the first element in a given part of the List which matches a specific criterion. * * @method Phaser.Structs.List#getFirst * @since 3.0.0 @@ -272,16 +274,16 @@ var List = new Class({ * @genericUse {T} - [value] * @genericUse {T | null} - [$return] * - * @param {string} property - [description] - * @param {*} value - [description] - * @param {number} [startIndex=0] - [description] - * @param {number} [endIndex] - [description] + * @param {string} property - The name of the property to test or a falsey value to have no criterion. + * @param {*} value - The value to test the `property` against, or `undefined` to allow any value and only check for existence. + * @param {number} [startIndex=0] - The position in the List to start the search at. + * @param {number} [endIndex] - The position in the List to optionally stop the search at. It won't be checked. * - * @return {?*} [description] + * @return {?*} The first item which matches the given criterion, or `null` if no such item exists. */ getFirst: function (property, value, startIndex, endIndex) { - return ArrayUtils.GetFirstElement(this.list, property, value, startIndex, endIndex); + return ArrayUtils.GetFirst(this.list, property, value, startIndex, endIndex); }, /** @@ -310,7 +312,7 @@ var List = new Class({ * @param {integer} [startIndex] - The first child index to start the search from. * @param {integer} [endIndex] - The last child index to search up until. * - * @return {Array.<*>} [description] + * @return {Array.<*>} All items of the List which match the given criterion, if any. */ getAll: function (property, value, startIndex, endIndex) { @@ -318,17 +320,17 @@ var List = new Class({ }, /** - * [description] + * Returns the total number of items in the List which have a property matching the given value. * * @method Phaser.Structs.List#count * @since 3.0.0 * * @genericUse {T} - [value] * - * @param {string} property - [description] - * @param {*} value - [description] + * @param {string} property - The property to test on each item. + * @param {*} value - The value to test the property against. * - * @return {integer} [description] + * @return {integer} The total number of matching elements. */ count: function (property, value) { @@ -336,15 +338,15 @@ var List = new Class({ }, /** - * [description] + * Swaps the positions of two items in the list. * * @method Phaser.Structs.List#swap * @since 3.0.0 * * @genericUse {T} - [child1,child2] * - * @param {*} child1 - [description] - * @param {*} child2 - [description] + * @param {*} child1 - The first item to swap. + * @param {*} child2 - The second item to swap. */ swap: function (child1, child2) { @@ -352,17 +354,17 @@ var List = new Class({ }, /** - * [description] + * Moves an item in the List to a new position. * * @method Phaser.Structs.List#moveTo * @since 3.0.0 * * @genericUse {T} - [child,$return] * - * @param {*} child - [description] - * @param {integer} index - [description] + * @param {*} child - The item to move. + * @param {integer} index - Moves an item in the List to a new position. * - * @return {*} [description] + * @return {*} The item that was moved. */ moveTo: function (child, index) { @@ -370,17 +372,17 @@ var List = new Class({ }, /** - * [description] + * Removes one or many items from the List. * * @method Phaser.Structs.List#remove * @since 3.0.0 * * @genericUse {T} - [child,$return] * - * @param {*} child - [description] + * @param {*} child - The item, or array of items, to remove. * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. * - * @return {*} [description] + * @return {*} The item, or array of items, which were successfully removed from the List. */ remove: function (child, skipCallback) { @@ -395,17 +397,17 @@ var List = new Class({ }, /** - * [description] + * Removes the item at the given position in the List. * * @method Phaser.Structs.List#removeAt * @since 3.0.0 * * @genericUse {T} - [$return] * - * @param {integer} index - [description] + * @param {integer} index - The position to remove the item from. * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. * - * @return {*} [description] + * @return {*} The item that was removed. */ removeAt: function (index, skipCallback) { @@ -420,18 +422,18 @@ var List = new Class({ }, /** - * [description] + * Removes the items within the given range in the List. * * @method Phaser.Structs.List#removeBetween * @since 3.0.0 * * @genericUse {T[]} - [$return] * - * @param {integer} [startIndex=0] - [description] - * @param {integer} [endIndex] - [description] + * @param {integer} [startIndex=0] - The index to start removing from. + * @param {integer} [endIndex] - The position to stop removing at. The item at this position won't be removed. * @param {boolean} [skipCallback=false] - Skip calling the List.removeCallback. * - * @return {Array.<*>} [description] + * @return {Array.<*>} An array of the items which were removed. */ removeBetween: function (startIndex, endIndex, skipCallback) { @@ -477,9 +479,9 @@ var List = new Class({ * * @genericUse {T} - [child,$return] * - * @param {*} child - [description] + * @param {*} child - The item to bring to the top of the List. * - * @return {*} [description] + * @return {*} The item which was moved. */ bringToTop: function (child) { @@ -494,9 +496,9 @@ var List = new Class({ * * @genericUse {T} - [child,$return] * - * @param {*} child - [description] + * @param {*} child - The item to send to the back of the list. * - * @return {*} [description] + * @return {*} The item which was moved. */ sendToBack: function (child) { @@ -511,9 +513,9 @@ var List = new Class({ * * @genericUse {T} - [child,$return] * - * @param {*} child - [description] + * @param {*} child - The item to move up. * - * @return {*} [description] + * @return {*} The item which was moved. */ moveUp: function (child) { @@ -530,9 +532,9 @@ var List = new Class({ * * @genericUse {T} - [child,$return] * - * @param {*} child - [description] + * @param {*} child - The item to move down. * - * @return {*} [description] + * @return {*} The item which was moved. */ moveDown: function (child) { @@ -559,7 +561,7 @@ var List = new Class({ }, /** - * [description] + * Shuffles the items in the list. * * @method Phaser.Structs.List#shuffle * @since 3.0.0 @@ -594,16 +596,16 @@ var List = new Class({ }, /** - * [description] + * Checks if an item exists within the List. * * @method Phaser.Structs.List#exists * @since 3.0.0 * * @genericUse {T} - [child] * - * @param {*} child - [description] + * @param {*} child - The item to check for the existence of. * - * @return {boolean} True if the item is found in the list, otherwise false. + * @return {boolean} `true` if the item is found in the list, otherwise `false`. */ exists: function (child) { @@ -618,8 +620,8 @@ var List = new Class({ * * @genericUse {T} - [value] * - * @param {string} property - [description] - * @param {*} value - [description] + * @param {string} property - The name of the property to set. + * @param {*} value - The value to set the property to. * @param {integer} [startIndex] - The first child index to start the search from. * @param {integer} [endIndex] - The last child index to search up until. */ @@ -660,7 +662,7 @@ var List = new Class({ }, /** - * [description] + * Clears the List and recreates its internal array. * * @method Phaser.Structs.List#shutdown * @since 3.0.0 @@ -673,7 +675,7 @@ var List = new Class({ }, /** - * [description] + * Destroys this List. * * @method Phaser.Structs.List#destroy * @since 3.0.0 @@ -688,11 +690,11 @@ var List = new Class({ }, /** - * [description] + * The number of items inside the List. * * @name Phaser.Structs.List#length * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ length: { @@ -705,11 +707,12 @@ var List = new Class({ }, /** - * [description] + * The first item in the List or `null` for an empty List. * * @name Phaser.Structs.List#first - * @type {integer} - * @readOnly + * @genericUse {T} - [$type] + * @type {*} The first item in the List or `null` for an empty List. + * @readonly * @since 3.0.0 */ first: { @@ -731,11 +734,12 @@ var List = new Class({ }, /** - * [description] + * The last item in the List, or `null` for an empty List. * * @name Phaser.Structs.List#last - * @type {integer} - * @readOnly + * @genericUse {T} - [$type] + * @type {*} The last item in the List, or `null` for an empty List. + * @readonly * @since 3.0.0 */ last: { @@ -757,11 +761,14 @@ var List = new Class({ }, /** - * [description] + * The next item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #first} or manually setting the {@link #position} to iterate the List. * * @name Phaser.Structs.List#next - * @type {integer} - * @readOnly + * @genericUse {T} - [$type] + * @type {*} The next item in the List, or `null` if the entire List has been traversed. + * @readonly * @since 3.0.0 */ next: { @@ -783,11 +790,14 @@ var List = new Class({ }, /** - * [description] + * The previous item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #last} or manually setting the {@link #position} to iterate the List backwards. * * @name Phaser.Structs.List#previous - * @type {integer} - * @readOnly + * @genericUse {T} - [$type] + * @type {*} The previous item in the List, or `null` if the entire List has been traversed. + * @readonly * @since 3.0.0 */ previous: { diff --git a/src/structs/Map.js b/src/structs/Map.js index 28c7d39c5..ac84967aa 100644 --- a/src/structs/Map.js +++ b/src/structs/Map.js @@ -10,23 +10,26 @@ var Class = require('../utils/Class'); * @callback EachMapCallback * @generic E - [entry] * - * @param {string} key - [description] - * @param {*} entry - [description] + * @param {string} key - The key of the Map entry. + * @param {*} entry - The value of the Map entry. * - * @return {?boolean} [description] + * @return {?boolean} The callback result. */ /** * @classdesc * The keys of a Map can be arbitrary values. + * + * ```javascript * var map = new Map([ * [ 1, 'one' ], * [ 2, 'two' ], * [ 3, 'three' ] * ]); + * ``` * * @class Map - * @memberOf Phaser.Structs + * @memberof Phaser.Structs * @constructor * @since 3.0.0 * @@ -34,7 +37,7 @@ var Class = require('../utils/Class'); * @generic V * @genericUse {V[]} - [elements] * - * @param {Array.<*>} elements - [description] + * @param {Array.<*>} elements - An optional array of key-value pairs to populate this Map with. */ var Map = new Class({ @@ -43,7 +46,7 @@ var Map = new Class({ function Map (elements) { /** - * [description] + * The entries in this Map. * * @genericUse {Object.} - [$type] * @@ -55,7 +58,7 @@ var Map = new Class({ this.entries = {}; /** - * [description] + * The number of key / value pairs in this Map. * * @name Phaser.Structs.Map#size * @type {number} @@ -74,7 +77,7 @@ var Map = new Class({ }, /** - * [description] + * Adds an element with a specified `key` and `value` to this Map. * * @method Phaser.Structs.Map#set * @since 3.0.0 @@ -83,8 +86,8 @@ var Map = new Class({ * @genericUse {V} - [value] * @genericUse {Phaser.Structs.Map.} - [$return] * - * @param {string} key - [description] - * @param {*} value - [description] + * @param {string} key - The key of the element to be added to this Map. + * @param {*} value - The value of the element to be added to this Map. * * @return {Phaser.Structs.Map} This Map object. */ @@ -100,7 +103,7 @@ var Map = new Class({ }, /** - * [description] + * Returns the value associated to the `key`, or `undefined` if there is none. * * @method Phaser.Structs.Map#get * @since 3.0.0 @@ -108,9 +111,9 @@ var Map = new Class({ * @genericUse {K} - [key] * @genericUse {V} - [$return] * - * @param {string} key - [description] + * @param {string} key - The key of the element to return from the `Map` object. * - * @return {*} [description] + * @return {*} The element associated with the specified key or `undefined` if the key can't be found in this Map object. */ get: function (key) { @@ -121,14 +124,14 @@ var Map = new Class({ }, /** - * [description] + * Returns an `Array` of all the values stored in this Map. * * @method Phaser.Structs.Map#getArray * @since 3.0.0 * * @genericUse {V[]} - [$return] * - * @return {Array.<*>} [description] + * @return {Array.<*>} An array of the values stored in this Map. */ getArray: function () { @@ -144,16 +147,16 @@ var Map = new Class({ }, /** - * [description] + * Returns a boolean indicating whether an element with the specified key exists or not. * * @method Phaser.Structs.Map#has * @since 3.0.0 * * @genericUse {K} - [key] * - * @param {string} key - [description] + * @param {string} key - The key of the element to test for presence of in this Map. * - * @return {boolean} [description] + * @return {boolean} Returns `true` if an element with the specified key exists in this Map, otherwise `false`. */ has: function (key) { @@ -161,7 +164,7 @@ var Map = new Class({ }, /** - * [description] + * Delete the specified element from this Map. * * @method Phaser.Structs.Map#delete * @since 3.0.0 @@ -169,7 +172,7 @@ var Map = new Class({ * @genericUse {K} - [key] * @genericUse {Phaser.Structs.Map.} - [$return] * - * @param {string} key - [description] + * @param {string} key - The key of the element to delete from this Map. * * @return {Phaser.Structs.Map} This Map object. */ @@ -185,7 +188,7 @@ var Map = new Class({ }, /** - * [description] + * Delete all entries from this Map. * * @method Phaser.Structs.Map#clear * @since 3.0.0 @@ -208,14 +211,14 @@ var Map = new Class({ }, /** - * [description] + * Returns all entries keys in this Map. * * @method Phaser.Structs.Map#keys * @since 3.0.0 * * @genericUse {K[]} - [$return] * - * @return {string[]} [description] + * @return {string[]} Array containing entries' keys. */ keys: function () { @@ -223,14 +226,14 @@ var Map = new Class({ }, /** - * [description] + * Returns an `Array` of all entries. * * @method Phaser.Structs.Map#values * @since 3.0.0 * * @genericUse {V[]} - [$return] * - * @return {Array.<*>} [description] + * @return {Array.<*>} An `Array` of entries. */ values: function () { @@ -246,7 +249,7 @@ var Map = new Class({ }, /** - * [description] + * Dumps the contents of this Map to the console via `console.group`. * * @method Phaser.Structs.Map#dump * @since 3.0.0 @@ -268,7 +271,7 @@ var Map = new Class({ }, /** - * [description] + * Passes all entries in this Map to the given callback. * * @method Phaser.Structs.Map#each * @since 3.0.0 @@ -276,7 +279,7 @@ var Map = new Class({ * @genericUse {EachMapCallback.} - [callback] * @genericUse {Phaser.Structs.Map.} - [$return] * - * @param {EachMapCallback} callback - [description] + * @param {EachMapCallback} callback - The callback which will receive the keys and entries held in this Map. * * @return {Phaser.Structs.Map} This Map object. */ @@ -296,16 +299,16 @@ var Map = new Class({ }, /** - * [description] + * Returns `true` if the value exists within this Map. Otherwise, returns `false`. * * @method Phaser.Structs.Map#contains * @since 3.0.0 * * @genericUse {V} - [value] * - * @param {*} value - [description] + * @param {*} value - The value to search for. * - * @return {boolean} [description] + * @return {boolean} `true` if the value is found, otherwise `false`. */ contains: function (value) { @@ -323,17 +326,16 @@ var Map = new Class({ }, /** - * Merges all new keys from the given Map into this one - * If it encounters a key that already exists it will be skipped - * unless override = true. + * Merges all new keys from the given Map into this one. + * If it encounters a key that already exists it will be skipped unless override is set to `true`. * * @method Phaser.Structs.Map#merge * @since 3.0.0 * * @genericUse {Phaser.Structs.Map.} - [map,$return] * - * @param {Phaser.Structs.Map} map - [description] - * @param {boolean} [override=false] - [description] + * @param {Phaser.Structs.Map} map - The Map to merge in to this Map. + * @param {boolean} [override=false] - Set to `true` to replace values in this Map with those from the source map, or `false` to skip them. * * @return {Phaser.Structs.Map} This Map object. */ diff --git a/src/structs/ProcessQueue.js b/src/structs/ProcessQueue.js index 2cbc68969..58df83a6a 100644 --- a/src/structs/ProcessQueue.js +++ b/src/structs/ProcessQueue.js @@ -8,10 +8,19 @@ var Class = require('../utils/Class'); /** * @classdesc - * [description] + * A Process Queue maintains three internal lists. + * + * The `pending` list is a selection of items which are due to be made 'active' in the next update. + * The `active` list is a selection of items which are considered active and should be updated. + * The `destroy` list is a selection of items that were active and are awaiting being destroyed in the next update. + * + * When new items are added to a Process Queue they are put in a pending data, rather than being added + * immediately the active list. Equally, items that are removed are put into the destroy list, rather than + * being destroyed immediately. This allows the Process Queue to carefully process each item at a specific, fixed + * time, rather than at the time of the request from the API. * * @class ProcessQueue - * @memberOf Phaser.Structs + * @memberof Phaser.Structs * @constructor * @since 3.0.0 * @@ -24,7 +33,7 @@ var ProcessQueue = new Class({ function ProcessQueue () { /** - * [description] + * The `pending` list is a selection of items which are due to be made 'active' in the next update. * * @genericUse {T[]} - [$type] * @@ -37,7 +46,7 @@ var ProcessQueue = new Class({ this._pending = []; /** - * [description] + * The `active` list is a selection of items which are considered active and should be updated. * * @genericUse {T[]} - [$type] * @@ -50,7 +59,7 @@ var ProcessQueue = new Class({ this._active = []; /** - * [description] + * The `destroy` list is a selection of items that were active and are awaiting being destroyed in the next update. * * @genericUse {T[]} - [$type] * @@ -63,7 +72,7 @@ var ProcessQueue = new Class({ this._destroy = []; /** - * [description] + * The total number of items awaiting processing. * * @name Phaser.Structs.ProcessQueue#_toProcess * @type {integer} @@ -75,7 +84,8 @@ var ProcessQueue = new Class({ }, /** - * [description] + * Adds a new item to the Process Queue. + * The item is added to the pending list and made active in the next update. * * @method Phaser.Structs.ProcessQueue#add * @since 3.0.0 @@ -83,7 +93,7 @@ var ProcessQueue = new Class({ * @genericUse {T} - [item] * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] * - * @param {*} item - [description] + * @param {*} item - The item to add to the queue. * * @return {Phaser.Structs.ProcessQueue} This Process Queue object. */ @@ -97,7 +107,8 @@ var ProcessQueue = new Class({ }, /** - * [description] + * Removes an item from the Process Queue. + * The item is added to the pending destroy and fully removed in the next update. * * @method Phaser.Structs.ProcessQueue#remove * @since 3.0.0 @@ -105,7 +116,7 @@ var ProcessQueue = new Class({ * @genericUse {T} - [item] * @genericUse {Phaser.Structs.ProcessQueue.} - [$return] * - * @param {*} item - [description] + * @param {*} item - The item to be removed from the queue. * * @return {Phaser.Structs.ProcessQueue} This Process Queue object. */ @@ -119,14 +130,17 @@ var ProcessQueue = new Class({ }, /** - * [description] + * Update this queue. First it will process any items awaiting destruction, and remove them. + * + * Then it will check to see if there are any items pending insertion, and move them to an + * active state. Finally, it will return a list of active items for further processing. * * @method Phaser.Structs.ProcessQueue#update * @since 3.0.0 * * @genericUse {T[]} - [$return] * - * @return {Array.<*>} [description] + * @return {Array.<*>} A list of active items. */ update: function () { @@ -178,14 +192,14 @@ var ProcessQueue = new Class({ }, /** - * [description] + * Returns the current list of active items. * * @method Phaser.Structs.ProcessQueue#getActive * @since 3.0.0 * * @genericUse {T[]} - [$return] * - * @return {Array.<*>} [description] + * @return {Array.<*>} A list of active items. */ getActive: function () { @@ -193,13 +207,15 @@ var ProcessQueue = new Class({ }, /** - * [description] + * Immediately destroys this process queue, clearing all of its internal arrays and resetting the process totals. * * @method Phaser.Structs.ProcessQueue#destroy * @since 3.0.0 */ destroy: function () { + this._toProcess = 0; + this._pending = []; this._active = []; this._destroy = []; diff --git a/src/structs/RTree.js b/src/structs/RTree.js index 6d5856d82..62b10f675 100644 --- a/src/structs/RTree.js +++ b/src/structs/RTree.js @@ -18,7 +18,7 @@ var quickselect = require('../utils/array/QuickSelect'); * This is to avoid the eval like function creation that the original library used, which caused CSP policy violations. * * @class RTree - * @memberOf Phaser.Structs + * @memberof Phaser.Structs * @constructor * @since 3.0.0 */ diff --git a/src/structs/Set.js b/src/structs/Set.js index e3cc3a9f9..2c8a4656f 100644 --- a/src/structs/Set.js +++ b/src/structs/Set.js @@ -10,10 +10,10 @@ var Class = require('../utils/Class'); * @callback EachSetCallback * @generic E - [entry] * - * @param {*} entry - [description] - * @param {number} index - [description] + * @param {*} entry - The Set entry. + * @param {number} index - The index of the entry within the Set. * - * @return {?boolean} [description] + * @return {?boolean} The callback result. */ /** @@ -21,14 +21,14 @@ var Class = require('../utils/Class'); * A Set is a collection of unique elements. * * @class Set - * @memberOf Phaser.Structs + * @memberof Phaser.Structs * @constructor * @since 3.0.0 * * @generic T * @genericUse {T[]} - [elements] * - * @param {Array.<*>} [elements] - [description] + * @param {Array.<*>} [elements] - An optional array of elements to insert into this Set. */ var Set = new Class({ @@ -37,7 +37,7 @@ var Set = new Class({ function Set (elements) { /** - * [description] + * The entries of this Set. Stored internally as an array. * * @genericUse {T[]} - [$type] * @@ -58,7 +58,7 @@ var Set = new Class({ }, /** - * [description] + * Inserts the provided value into this Set. If the value is already contained in this Set this method will have no effect. * * @method Phaser.Structs.Set#set * @since 3.0.0 @@ -66,7 +66,7 @@ var Set = new Class({ * @genericUse {T} - [value] * @genericUse {Phaser.Structs.Set.} - [$return] * - * @param {*} value - [description] + * @param {*} value - The value to insert into this Set. * * @return {Phaser.Structs.Set} This Set object. */ @@ -81,17 +81,18 @@ var Set = new Class({ }, /** - * [description] + * Get an element of this Set which has a property of the specified name, if that property is equal to the specified value. + * If no elements of this Set satisfy the condition then this method will return `null`. * * @method Phaser.Structs.Set#get * @since 3.0.0 * * @genericUse {T} - [value,$return] * - * @param {string} property - [description] - * @param {*} value - [description] + * @param {string} property - The property name to check on the elements of this Set. + * @param {*} value - The value to check for. * - * @return {*} [description] + * @return {*} The first element of this Set that meets the required condition, or `null` if this Set contains no elements that meet the condition. */ get: function (property, value) { @@ -107,14 +108,14 @@ var Set = new Class({ }, /** - * [description] + * Returns an array containing all the values in this Set. * * @method Phaser.Structs.Set#getArray * @since 3.0.0 * * @genericUse {T[]} - [$return] * - * @return {Array.<*>} [description] + * @return {Array.<*>} An array containing all the values in this Set. */ getArray: function () { @@ -122,7 +123,7 @@ var Set = new Class({ }, /** - * [description] + * Removes the given value from this Set if this Set contains that value. * * @method Phaser.Structs.Set#delete * @since 3.0.0 @@ -130,7 +131,7 @@ var Set = new Class({ * @genericUse {T} - [value] * @genericUse {Phaser.Structs.Set.} - [$return] * - * @param {*} value - [description] + * @param {*} value - The value to remove from the Set. * * @return {Phaser.Structs.Set} This Set object. */ @@ -147,7 +148,7 @@ var Set = new Class({ }, /** - * [description] + * Dumps the contents of this Set to the console via `console.group`. * * @method Phaser.Structs.Set#dump * @since 3.0.0 @@ -168,7 +169,8 @@ var Set = new Class({ }, /** - * For when you know this Set will be modified during the iteration. + * Passes each value in this Set to the given callback. + * Use this function when you know this Set will be modified during the iteration, otherwise use `iterate`. * * @method Phaser.Structs.Set#each * @since 3.0.0 @@ -176,8 +178,8 @@ var Set = new Class({ * @genericUse {EachSetCallback.} - [callback] * @genericUse {Phaser.Structs.Set.} - [$return] * - * @param {EachSetCallback} callback - [description] - * @param {*} callbackScope - [description] + * @param {EachSetCallback} callback - The callback to be invoked and passed each value this Set contains. + * @param {*} [callbackScope] - The scope of the callback. * * @return {Phaser.Structs.Set} This Set object. */ @@ -212,6 +214,7 @@ var Set = new Class({ }, /** + * Passes each value in this Set to the given callback. * For when you absolutely know this Set won't be modified during the iteration. * * @method Phaser.Structs.Set#iterate @@ -220,8 +223,8 @@ var Set = new Class({ * @genericUse {EachSetCallback.} - [callback] * @genericUse {Phaser.Structs.Set.} - [$return] * - * @param {EachSetCallback} callback - [description] - * @param {*} callbackScope - [description] + * @param {EachSetCallback} callback - The callback to be invoked and passed each value this Set contains. + * @param {*} [callbackScope] - The scope of the callback. * * @return {Phaser.Structs.Set} This Set object. */ @@ -255,14 +258,14 @@ var Set = new Class({ }, /** - * [description] + * Goes through each entry in this Set and invokes the given function on them, passing in the arguments. * * @method Phaser.Structs.Set#iterateLocal * @since 3.0.0 * * @genericUse {Phaser.Structs.Set.} - [$return] * - * @param {string} callbackKey - [description] + * @param {string} callbackKey - The key of the function to be invoked on each Set entry. * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. * * @return {Phaser.Structs.Set} This Set object. @@ -290,7 +293,7 @@ var Set = new Class({ }, /** - * [description] + * Clears this Set so that it no longer contains any values. * * @method Phaser.Structs.Set#clear * @since 3.0.0 @@ -307,16 +310,16 @@ var Set = new Class({ }, /** - * [description] + * Returns `true` if this Set contains the given value, otherwise returns `false`. * * @method Phaser.Structs.Set#contains * @since 3.0.0 * * @genericUse {T} - [value] * - * @param {*} value - [description] + * @param {*} value - The value to check for in this Set. * - * @return {boolean} [description] + * @return {boolean} `true` if the given value was found in this Set, otherwise `false`. */ contains: function (value) { @@ -324,16 +327,16 @@ var Set = new Class({ }, /** - * [description] + * Returns a new Set containing all values that are either in this Set or in the Set provided as an argument. * * @method Phaser.Structs.Set#union * @since 3.0.0 * * @genericUse {Phaser.Structs.Set.} - [set,$return] * - * @param {Phaser.Structs.Set} set - [description] + * @param {Phaser.Structs.Set} set - The Set to perform the union with. * - * @return {Phaser.Structs.Set} [description] + * @return {Phaser.Structs.Set} A new Set containing all the values in this Set and the Set provided as an argument. */ union: function (set) { @@ -353,16 +356,16 @@ var Set = new Class({ }, /** - * [description] + * Returns a new Set that contains only the values which are in this Set and that are also in the given Set. * * @method Phaser.Structs.Set#intersect * @since 3.0.0 * * @genericUse {Phaser.Structs.Set.} - [set,$return] * - * @param {Phaser.Structs.Set} set - [description] + * @param {Phaser.Structs.Set} set - The Set to intersect this set with. * - * @return {Phaser.Structs.Set} [description] + * @return {Phaser.Structs.Set} The result of the intersection, as a new Set. */ intersect: function (set) { @@ -380,16 +383,16 @@ var Set = new Class({ }, /** - * [description] + * Returns a new Set containing all the values in this Set which are *not* also in the given Set. * * @method Phaser.Structs.Set#difference * @since 3.0.0 * * @genericUse {Phaser.Structs.Set.} - [set,$return] * - * @param {Phaser.Structs.Set} set - [description] + * @param {Phaser.Structs.Set} set - The Set to perform the difference with. * - * @return {Phaser.Structs.Set} [description] + * @return {Phaser.Structs.Set} A new Set containing all the values in this Set that are not also in the Set provided as an argument to this method. */ difference: function (set) { @@ -407,7 +410,9 @@ var Set = new Class({ }, /** - * [description] + * The size of this Set. This is the number of entries within it. + * Changing the size will truncate the Set if the given value is smaller than the current size. + * Increasing the size larger than the current size has no effect. * * @name Phaser.Structs.Set#size * @type {integer} @@ -422,7 +427,14 @@ var Set = new Class({ set: function (value) { - return this.entries.length = value; + if (value < this.entries.length) + { + return this.entries.length = value; + } + else + { + return this.entries.length; + } } } diff --git a/src/structs/Size.js b/src/structs/Size.js new file mode 100644 index 000000000..ddba90efc --- /dev/null +++ b/src/structs/Size.js @@ -0,0 +1,538 @@ +/** + * @author Richard Davey + * @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 + * The Size component allows you to set `width` and `height` properties and define the relationship between them. + * + * The component can automatically maintain the aspect ratios between the two values, and clamp them + * to a defined min-max range. You can also control the dominant axis. When dimensions are given to the Size component + * that would cause it to exceed its min-max range, the dimensions are adjusted based on the dominant axis. + * + * @class Size + * @memberof Phaser.Structs + * @constructor + * @since 3.16.0 + * + * @param {number} [width] - The width of the Size component. + * @param {number} [height=width] - The height of the Size component. If not given, it will use the `width`. + * @param {boolean} [lockAspectRatio=false] - Should the aspect ratio be locked? It will be based on the given `width` and `height` arguments. + * @param {boolean} [lockWidth=true] - Set to `true` to make the `width` the dominant axis, or `false` to make `height` the dominant axis. + */ +var Size = new Class({ + + initialize: + + function Size (width, height, lockAspectRatio, lockWidth) + { + if (width === undefined) { width = 0; } + if (height === undefined) { height = width; } + if (lockAspectRatio === undefined) { lockAspectRatio = false; } + if (lockWidth === undefined) { lockWidth = true; } + + /** + * The width. + * + * @name Phaser.Structs.Size#_width + * @type {number} + * @private + * @since 3.16.0 + */ + this._width = width; + + /** + * The height. + * + * @name Phaser.Structs.Size#_height + * @type {number} + * @private + * @since 3.16.0 + */ + this._height = height; + + /** + * The proportional relationship between the width and height. + * + * This property is read only and is updated automatically when either the `width` or `height` properties are changed, + * providing the aspect ratio lock isn't enabled. + * + * @name Phaser.Structs.Size#ratioH + * @type {number} + * @readonly + * @since 3.16.0 + */ + this.ratioH = (height === 0) ? 1 : width / height; + + /** + * The proportional relationship between the height and width. + * + * This property is read only and is updated automatically when either the `width` or `height` properties are changed, + * providing the aspect ratio lock isn't enabled. + * + * @name Phaser.Structs.Size#ratioV + * @type {number} + * @readonly + * @since 3.16.0 + */ + this.ratioV = (width === 0) ? 1 : height / width; + + /** + * Set this property to lock the aspect ratios to their current values. + * + * Once enabled, changing the `width` or `height` properties will automatically adjust the other based on the aspect ratio. + * + * @name Phaser.Structs.Size#lockAspectRatio + * @type {boolean} + * @since 3.16.0 + */ + this.lockAspectRatio = lockAspectRatio; + + /** + * When scaling the Size based on the min-max range and the aspect ratio, this property controls the priority of + * the axis. If `true` (the default) the `width` will be the dominant axis, and the height will adjust to match it. If `false`, + * the `height` will be the dominant axis, and the `width` will adjust to match it. + * + * @name Phaser.Structs.Size#lockWidth + * @type {boolean} + * @default true + * @since 3.16.0 + */ + this.lockWidth = lockWidth; + + /** + * The minimum allowed width. + * + * @name Phaser.Structs.Size#_minWidth + * @type {number} + * @private + * @since 3.16.0 + */ + this._minWidth = 0; + + /** + * The minimum allowed height. + * + * @name Phaser.Structs.Size#_minHeight + * @type {number} + * @private + * @since 3.16.0 + */ + this._minHeight = 0; + + /** + * The maximum allowed width. + * + * @name Phaser.Structs.Size#_maxWidth + * @type {number} + * @private + * @since 3.16.0 + */ + this._maxWidth = Number.MAX_VALUE; + + /** + * The maximum allowed height. + * + * @name Phaser.Structs.Size#_maxHeight + * @type {number} + * @private + * @since 3.16.0 + */ + this._maxHeight = Number.MAX_VALUE; + }, + + /** + * Lock the aspect ratio to its current value? + * + * If enabled, changing the `width` or `height` properties will automatically adjust the other based on the aspect ratio. + * + * @method Phaser.Structs.Size#setAspectRatioLock + * @since 3.16.0 + * + * @param {boolean} value - `true` to enable the aspect ratio lock or `false` to disable it. + * + * @return {this} This Size instance. + */ + setAspectRatioLock: function (value) + { + this.lockAspectRatio = value; + + return this; + }, + + /** + * Set the minimum width and height values this Size component will allow. + * + * If enabled, the properties will be clamped to the min-max range, including when locked to their aspect ratios. + * + * Setting this will automatically adjust both the `width` and `height` properties to ensure they are within range. + * + * @method Phaser.Structs.Size#setMin + * @since 3.16.0 + * + * @param {number} [width=0] - The minimum allowed width of the Size component. + * @param {number} [height=width] - The minimum allowed height of the Size component. If not given, it will use the `width`. + * + * @return {this} This Size instance. + */ + setMin: function (width, height) + { + if (width === undefined) { width = 0; } + if (height === undefined) { height = width; } + + this._minWidth = width; + this._minHeight = height; + + return this.update(); + }, + + /** + * Set the maximum width and height values this Size component will allow. + * + * If enabled, the properties will be clamped to the min-max range, including when locked to their aspect ratios. + * + * Setting this will automatically adjust both the `width` and `height` properties to ensure they are within range. + * + * @method Phaser.Structs.Size#setMax + * @since 3.16.0 + * + * @param {number} [width=Number.MAX_VALUE] - The maximum allowed width of the Size component. + * @param {number} [height=width] - The maximum allowed height of the Size component. If not given, it will use the `width`. + * + * @return {this} This Size instance. + */ + setMax: function (width, height) + { + if (width === undefined) { width = Number.MAX_VALUE; } + if (height === undefined) { height = width; } + + this._maxWidth = width; + this._maxHeight = height; + + return this.update(); + }, + + /** + * Calls `setSize` with the current width and height. + * This has the effect of applying min-max clamping and axis locking to the current values. + * + * @method Phaser.Structs.Size#update + * @since 3.16.0 + * + * @return {this} This Size instance. + */ + update: function () + { + return this.setSize(this._width, this._height); + }, + + /** + * Updates the `ratioH` and `ratioV` properties based on the current width and height. + * + * They are only updated if `lockAspectRatio` is `false`. + * + * @method Phaser.Structs.Size#updateRatios + * @since 3.16.0 + * + * @return {this} This Size instance. + */ + updateRatios: function () + { + if (!this.lockAspectRatio) + { + this.ratioH = (this._height === 0) ? 1 : this._width / this._height; + this.ratioV = (this._width === 0) ? 1 : this._height / this._width; + } + + return this; + }, + + /** + * Sets a new width for this Size component. + * + * The new width is clamped to the min-max range automatically. + * + * Additionally, if the aspect ratio is locked, the height will also be adjusted based on the new width. + * + * @method Phaser.Structs.Size#updateWidth + * @since 3.16.0 + * + * @param {number} width - The new width of the Size component. + * + * @return {this} This Size instance. + */ + updateWidth: function (width) + { + width = Clamp(width, this._minWidth, this._maxWidth); + + if (this.lockAspectRatio) + { + // What's the new height? + var height = width * this.ratioV; + + // height takes priority + if (!this.lockWidth) + { + if (height < this._minHeight) + { + height = this._minHeight; + } + else if (height > this._maxHeight) + { + height = this._maxHeight; + } + + // Re-adjust the width based on the dominant height + width = height * this.ratioH; + } + } + + this._width = width; + this._height = height; + + return this.updateRatios(); + }, + + /** + * Sets a new height for this Size component. + * + * The new height is clamped to the min-max range automatically. + * + * Additionally, if the aspect ratio is locked, the width will also be adjusted based on the new height. + * + * @method Phaser.Structs.Size#updateHeight + * @since 3.16.0 + * + * @param {number} height - The new height of the Size component. + * + * @return {this} This Size instance. + */ + updateHeight: function (height) + { + height = Clamp(height, this._minHeight, this._maxHeight); + + if (this.lockAspectRatio) + { + // What's the new width? + var width = height * this.ratioH; + + // width takes priority + if (this.lockWidth) + { + if (width < this._minWidth) + { + width = this._minWidth; + } + else if (width > this._maxWidth) + { + width = this._maxWidth; + } + + // Re-adjust the height based on the dominant width + height = width * this.ratioV; + } + } + + this._width = width; + this._height = height; + + return this.updateRatios(); + }, + + /** + * Set the width and height of this Size component, adjusting for the aspect ratio, if locked. + * + * @method Phaser.Structs.Size#setSize + * @since 3.16.0 + * + * @param {number} [width] - The width of the Size component. + * @param {number} [height=width] - The height of the Size component. If not given, it will use the `width`. + * + * @return {this} This Size instance. + */ + setSize: function (width, height) + { + if (width === undefined) { width = 0; } + if (height === undefined) { height = width; } + + return (this.lockWidth) ? this.updateWidth(width) : this.updateHeight(height); + }, + + /** + * The `width` and `height` are adjusted to fit inside the given dimensions, while keeping the current aspect ratio. + * + * There may be some space inside the parent area which is not covered if its aspect ratio differs. + * + * @method Phaser.Structs.Size#fitTo + * @since 3.16.0 + * + * @param {number} width - The width of the Size component. + * @param {number} height - The height of the Size component. + * + * @return {this} This Size instance. + */ + fitTo: function (width, height) + { + // Get the aspect ratios in case we need to expand or shrink to fit + var newRatio = (height === 0) ? 1 : width / height; + + var newWidth = width; + var newHeight = height; + + // Get the larger aspect ratio of the two. + // If aspect ratio is 1 then no adjustment needed + if (this.ratioH > newRatio) + { + newHeight = width / this.ratioH; + } + else if (this.ratioH < newRatio) + { + newWidth = height * this.ratioH; + } + + this._width = newWidth; + this._height = newHeight; + + this.ratioH = (this._height === 0) ? 1 : this._width / this._height; + this.ratioV = (this._width === 0) ? 1 : this._height / this._width; + + return this; + }, + + /** + * Sets the width of this Size component. + * + * If the aspect ratio is locked, changing the width will also automatically update the height. + * + * @method Phaser.Structs.Size#setWidth + * @since 3.16.0 + * + * @param {number} width - The width of the Size component. + * + * @return {this} This Size instance. + */ + setWidth: function (value) + { + return this.updateWidth(value); + }, + + /** + * Gets the width of this Size component. + * + * @method Phaser.Structs.Size#getWidth + * @since 3.16.0 + * + * @return {number} The width of this Size component. + */ + getWidth: function () + { + return this._width; + }, + + /** + * Sets the height of this Size component. + * + * If the aspect ratio is locked, changing the height will also automatically update the width. + * + * @method Phaser.Structs.Size#setHeight + * @since 3.16.0 + * + * @param {number} height - The height of the Size component. + * + * @return {this} This Size instance. + */ + setHeight: function (value) + { + return this.updateHeight(value); + }, + + /** + * Gets the height of this Size component. + * + * @method Phaser.Structs.Size#getHeight + * @since 3.16.0 + * + * @return {number} The height of this Size component. + */ + getHeight: function () + { + return this._height; + }, + + /** + * Returns a string representation of this Size component. + * + * @method Phaser.Structs.Size#toString + * @since 3.16.0 + * + * @return {string} A string representation of this Size component. + */ + toString: function () + { + return '[{ Size (width=' + this._width + ' height=' + this._height + ' ratioH=' + this.ratioH + ' ratioV=' + this.ratioV + ' lockAspectRatio=' + this.lockAspectRatio + ') }]'; + }, + + /** + * The width of this Size component. + * + * This value is clamped to the range specified by `minWidth` and `maxWidth`, if enabled. + * + * A width can never be less than zero. + * + * Changing this value will automatically update the `height` if the aspect ratio lock is enabled. + * You can also use the `setWidth` and `getWidth` methods. + * + * @name Phaser.Structs.Size#width + * @type {number} + * @since 3.16.0 + */ + width: { + + get: function () + { + return this._width; + }, + + set: function (value) + { + this.updateWidth(value); + } + + }, + + /** + * The height of this Size component. + * + * This value is clamped to the range specified by `minHeight` and `maxHeight`, if enabled. + * + * A height can never be less than zero. + * + * Changing this value will automatically update the `width` if the aspect ratio lock is enabled. + * You can also use the `setHeight` and `getHeight` methods. + * + * @name Phaser.Structs.Size#height + * @type {number} + * @since 3.16.0 + */ + height: { + + get: function () + { + return this._height; + }, + + set: function (value) + { + this.updateHeight(value); + } + + } + +}); + +module.exports = Size; diff --git a/src/structs/index.js b/src/structs/index.js index 4c948e140..e3b2d2913 100644 --- a/src/structs/index.js +++ b/src/structs/index.js @@ -14,6 +14,7 @@ module.exports = { Map: require('./Map'), ProcessQueue: require('./ProcessQueue'), RTree: require('./RTree'), - Set: require('./Set') + Set: require('./Set'), + Size: require('./Size') }; diff --git a/src/textures/CanvasTexture.js b/src/textures/CanvasTexture.js index 3389c05e0..71fd96f36 100644 --- a/src/textures/CanvasTexture.js +++ b/src/textures/CanvasTexture.js @@ -5,6 +5,8 @@ */ var Class = require('../utils/Class'); +var Clamp = require('../math/Clamp'); +var Color = require('../display/color/Color'); var IsSizePowerOfTwo = require('../math/pow2/IsSizePowerOfTwo'); var Texture = require('./Texture'); @@ -30,11 +32,11 @@ var Texture = require('./Texture'); * * @class CanvasTexture * @extends Phaser.Textures.Texture - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.7.0 * - * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. + * @param {Phaser.Textures.CanvasTexture} manager - A reference to the Texture Manager this Texture belongs to. * @param {string} key - The unique string-based key of this Texture. * @param {HTMLCanvasElement} source - The canvas element that is used as the base of this texture. * @param {integer} width - The width of the canvas. @@ -55,7 +57,7 @@ var CanvasTexture = new Class({ /** * A reference to the Texture Source of this Canvas. * - * @name Phaser.Textures.TextureManager#_source + * @name Phaser.Textures.CanvasTexture#_source * @type {Phaser.Textures.TextureSource} * @private * @since 3.7.0 @@ -65,8 +67,8 @@ var CanvasTexture = new Class({ /** * The source Canvas Element. * - * @name Phaser.Textures.TextureManager#canvas - * @readOnly + * @name Phaser.Textures.CanvasTexture#canvas + * @readonly * @type {HTMLCanvasElement} * @since 3.7.0 */ @@ -75,8 +77,8 @@ var CanvasTexture = new Class({ /** * The 2D Canvas Rendering Context. * - * @name Phaser.Textures.TextureManager#canvas - * @readOnly + * @name Phaser.Textures.CanvasTexture#context + * @readonly * @type {CanvasRenderingContext2D} * @since 3.7.0 */ @@ -84,10 +86,10 @@ var CanvasTexture = new Class({ /** * The width of the Canvas. - * This property is read-only, if you wish to change use `setSize`. + * This property is read-only, if you wish to change it use the `setSize` method. * - * @name Phaser.Textures.TextureManager#width - * @readOnly + * @name Phaser.Textures.CanvasTexture#width + * @readonly * @type {integer} * @since 3.7.0 */ @@ -95,14 +97,400 @@ var CanvasTexture = new Class({ /** * The height of the Canvas. - * This property is read-only, if you wish to change use `setSize`. + * This property is read-only, if you wish to change it use the `setSize` method. * - * @name Phaser.Textures.TextureManager#height - * @readOnly + * @name Phaser.Textures.CanvasTexture#height + * @readonly * @type {integer} * @since 3.7.0 */ this.height = height; + + /** + * The context image data. + * Use the `update` method to populate this when the canvas changes. + * + * @name Phaser.Textures.CanvasTexture#imageData + * @type {ImageData} + * @since 3.13.0 + */ + this.imageData = this.context.getImageData(0, 0, width, height); + + /** + * A Uint8ClampedArray view into the `buffer`. + * Use the `update` method to populate this when the canvas changes. + * Note that this is unavailable in some browsers, such as Epic Browser, due to their security restrictions. + * + * @name Phaser.Textures.CanvasTexture#data + * @type {Uint8ClampedArray} + * @since 3.13.0 + */ + this.data = null; + + if (this.imageData) + { + this.data = this.imageData.data; + } + + /** + * An Uint32Array view into the `buffer`. + * + * @name Phaser.Textures.CanvasTexture#pixels + * @type {Uint32Array} + * @since 3.13.0 + */ + this.pixels = null; + + /** + * An ArrayBuffer the same size as the context ImageData. + * + * @name Phaser.Textures.CanvasTexture#buffer + * @type {ArrayBuffer} + * @since 3.13.0 + */ + this.buffer; + + if (this.data) + { + if (this.imageData.data.buffer) + { + this.buffer = this.imageData.data.buffer; + this.pixels = new Uint32Array(this.buffer); + } + else if (window.ArrayBuffer) + { + this.buffer = new ArrayBuffer(this.imageData.data.length); + this.pixels = new Uint32Array(this.buffer); + } + else + { + this.pixels = this.imageData.data; + } + } + }, + + /** + * This re-creates the `imageData` from the current context. + * It then re-builds the ArrayBuffer, the `data` Uint8ClampedArray reference and the `pixels` Int32Array. + * + * Warning: This is a very expensive operation, so use it sparingly. + * + * @method Phaser.Textures.CanvasTexture#update + * @since 3.13.0 + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + update: function () + { + this.imageData = this.context.getImageData(0, 0, this.width, this.height); + + this.data = this.imageData.data; + + if (this.imageData.data.buffer) + { + this.buffer = this.imageData.data.buffer; + this.pixels = new Uint32Array(this.buffer); + } + else if (window.ArrayBuffer) + { + this.buffer = new ArrayBuffer(this.imageData.data.length); + this.pixels = new Uint32Array(this.buffer); + } + else + { + this.pixels = this.imageData.data; + } + + return this; + }, + + /** + * Draws the given Image or Canvas element to this CanvasTexture, then updates the internal + * ImageData buffer and arrays. + * + * @method Phaser.Textures.CanvasTexture#draw + * @since 3.13.0 + * + * @param {integer} x - The x coordinate to draw the source at. + * @param {integer} y - The y coordinate to draw the source at. + * @param {(HTMLImageElement|HTMLCanvasElement)} source - The element to draw to this canvas. + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + draw: function (x, y, source) + { + this.context.drawImage(source, x, y); + + return this.update(); + }, + + /** + * Draws the given texture frame to this CanvasTexture, then updates the internal + * ImageData buffer and arrays. + * + * @method Phaser.Textures.CanvasTexture#drawFrame + * @since 3.16.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. + * @param {integer} [x=0] - The x coordinate to draw the source at. + * @param {integer} [y=0] - The y coordinate to draw the source at. + * + * @return {Phaser.Textures.CanvasTexture} This CanvasTexture. + */ + drawFrame: function (key, frame, x, y) + { + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + + var textureFrame = this.manager.getFrame(key, frame); + + if (textureFrame) + { + var cd = textureFrame.canvasData; + + var width = textureFrame.cutWidth; + var height = textureFrame.cutHeight; + var res = textureFrame.source.resolution; + + this.context.drawImage( + textureFrame.source.image, + cd.x, cd.y, + width, + height, + x, y, + width / res, + height / res + ); + + return this.update(); + } + else + { + return this; + } + }, + + /** + * Sets a pixel in the CanvasTexture to the given color and alpha values. + * + * This is an expensive operation to run in large quantities, so use sparingly. + * + * @method Phaser.Textures.CanvasTexture#setPixel + * @since 3.16.0 + * + * @param {integer} x - The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} y - The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} red - The red color value. A number between 0 and 255. + * @param {integer} green - The green color value. A number between 0 and 255. + * @param {integer} blue - The blue color value. A number between 0 and 255. + * @param {integer} [alpha=255] - The alpha value. A number between 0 and 255. + * + * @return {this} This CanvasTexture. + */ + setPixel: function (x, y, red, green, blue, alpha) + { + if (alpha === undefined) { alpha = 255; } + + x = Math.abs(Math.floor(x)); + y = Math.abs(Math.floor(y)); + + var index = this.getIndex(x, y); + + if (index > -1) + { + var imageData = this.context.getImageData(x, y, 1, 1); + + imageData.data[0] = red; + imageData.data[1] = green; + imageData.data[2] = blue; + imageData.data[3] = alpha; + + this.context.putImageData(imageData, x, y); + } + + return this; + }, + + /** + * Puts the ImageData into the context of this CanvasTexture at the given coordinates. + * + * @method Phaser.Textures.CanvasTexture#putData + * @since 3.16.0 + * + * @param {ImageData} imageData - The ImageData to put at the given location. + * @param {integer} x - The x coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} y - The y coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer. + * + * @return {this} This CanvasTexture. + */ + putData: function (imageData, x, y) + { + x = Math.abs(Math.floor(x)); + y = Math.abs(Math.floor(y)); + + this.context.putImageData(imageData, x, y); + + return this; + }, + + /** + * Gets an ImageData region from this CanvasTexture from the position and size specified. + * You can write this back using `CanvasTexture.putData`, or manipulate it. + * + * @method Phaser.Textures.CanvasTexture#getData + * @since 3.16.0 + * + * @param {integer} x - The x coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} y - The y coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} width - The width of the region to get. Must be an integer. + * @param {integer} height - The height of the region to get. Must be an integer. + * + * @return {ImageData} The ImageData extracted from this CanvasTexture. + */ + getData: function (x, y, width, height) + { + x = Clamp(Math.floor(x), 0, this.width - 1); + y = Clamp(Math.floor(y), 0, this.height - 1); + width = Clamp(width, 1, this.width - x); + height = Clamp(height, 1, this.height - y); + + var imageData = this.context.getImageData(x, y, width, height); + + return imageData; + }, + + /** + * Get the color of a specific pixel from this texture and store it in a Color object. + * + * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * + * @method Phaser.Textures.CanvasTexture#getPixel + * @since 3.13.0 + * + * @param {integer} x - The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} y - The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {Phaser.Display.Color} [out] - A Color object to store the pixel values in. If not provided a new Color object will be created. + * + * @return {Phaser.Display.Color} An object with the red, green, blue and alpha values set in the r, g, b and a properties. + */ + getPixel: function (x, y, out) + { + if (!out) + { + out = new Color(); + } + + var index = this.getIndex(x, y); + + if (index > -1) + { + var data = this.data; + + var r = data[index + 0]; + var g = data[index + 1]; + var b = data[index + 2]; + var a = data[index + 3]; + + out.setTo(r, g, b, a); + } + + return out; + }, + + /** + * An object containing the position and color data for a single pixel in a CanvasTexture. + * + * @typedef {object} Phaser.Textures.CanvasTexture.PixelConfig + * + * @property {integer} x - The x-coordinate of the pixel. + * @property {integer} y - The y-coordinate of the pixel. + * @property {integer} color - The color of the pixel, not including the alpha channel. + * @property {float} alpha - The alpha of the pixel, between 0 and 1. + */ + + /** + * Returns an array containing all of the pixels in the given region. + * + * If the requested region extends outside the bounds of this CanvasTexture, + * the region is truncated to fit. + * + * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * + * @method Phaser.Textures.CanvasTexture#getPixels + * @since 3.16.0 + * + * @param {integer} x - The x coordinate of the top-left of the region. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} y - The y coordinate of the top-left of the region. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} width - The width of the region to get. Must be an integer. + * @param {integer} [height] - The height of the region to get. Must be an integer. If not given will be set to the `width`. + * + * @return {Phaser.Textures.CanvasTexture.PixelConfig[]} An array of Pixel objects. + */ + getPixels: function (x, y, width, height) + { + if (height === undefined) { height = width; } + + x = Math.abs(Math.round(x)); + y = Math.abs(Math.round(y)); + + var left = Clamp(x, 0, this.width); + var right = Clamp(x + width, 0, this.width); + var top = Clamp(y, 0, this.height); + var bottom = Clamp(y + height, 0, this.height); + + var pixel = new Color(); + + var out = []; + + for (var py = top; py < bottom; py++) + { + var row = []; + + for (var px = left; px < right; px++) + { + pixel = this.getPixel(px, py, pixel); + + row.push({ x: px, y: py, color: pixel.color, alpha: pixel.alphaGL }); + } + + out.push(row); + } + + return out; + }, + + /** + * Returns the Image Data index for the given pixel in this CanvasTexture. + * + * The index can be used to read directly from the `this.data` array. + * + * The index points to the red value in the array. The subsequent 3 indexes + * point to green, blue and alpha respectively. + * + * @method Phaser.Textures.CanvasTexture#getIndex + * @since 3.16.0 + * + * @param {integer} x - The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param {integer} y - The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * + * @return {integer} + */ + getIndex: function (x, y) + { + x = Math.abs(Math.round(x)); + y = Math.abs(Math.round(y)); + + if (x < this.width && y < this.height) + { + return (x + y * this.width) * 4; + } + else + { + return -1; + } }, /** @@ -149,18 +537,29 @@ var CanvasTexture = new Class({ }, /** - * Clears this Canvas Texture, resetting it back to transparent. + * Clears the given region of this Canvas Texture, resetting it back to transparent. + * If no region is given, the whole Canvas Texture is cleared. * * @method Phaser.Textures.CanvasTexture#clear * @since 3.7.0 + * + * @param {integer} [x=0] - The x coordinate of the top-left of the region to clear. + * @param {integer} [y=0] - The y coordinate of the top-left of the region to clear. + * @param {integer} [width] - The width of the region. + * @param {integer} [height] - The height of the region. * * @return {Phaser.Textures.CanvasTexture} The Canvas Texture. */ - clear: function () + clear: function (x, y, width, height) { - this.context.clearRect(0, 0, this.width, this.height); + if (x === undefined) { x = 0; } + if (y === undefined) { y = 0; } + if (width === undefined) { width = this.width; } + if (height === undefined) { height = this.height; } - return this; + this.context.clearRect(x, y, width, height); + + return this.update(); }, /** @@ -196,6 +595,25 @@ var CanvasTexture = new Class({ } return this; + }, + + /** + * Destroys this Texture and releases references to its sources and frames. + * + * @method Phaser.Textures.CanvasTexture#destroy + * @since 3.16.0 + */ + destroy: function () + { + Texture.prototype.destroy.call(this); + + this._source = null; + this.canvas = null; + this.context = null; + this.imageData = null; + this.data = null; + this.pixels = null; + this.buffer = null; } }); diff --git a/src/textures/Frame.js b/src/textures/Frame.js index 8217b5488..cbdc2930f 100644 --- a/src/textures/Frame.js +++ b/src/textures/Frame.js @@ -5,6 +5,7 @@ */ var Class = require('../utils/Class'); +var Clamp = require('../math/Clamp'); var Extend = require('../utils/object/Extend'); /** @@ -12,7 +13,7 @@ var Extend = require('../utils/object/Extend'); * A Frame is a section of a Texture. * * @class Frame - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * @@ -67,6 +68,16 @@ var Frame = new Class({ */ this.sourceIndex = sourceIndex; + /** + * A reference to the Texture Source WebGL Texture that this Frame is using. + * + * @name Phaser.Textures.Frame#glTexture + * @type {?WebGLTexture} + * @default null + * @since 3.11.0 + */ + this.glTexture = this.source.glTexture; + /** * X position within the source image to cut from. * @@ -245,6 +256,46 @@ var Frame = new Class({ */ this.customData = {}; + /** + * WebGL UV u0 value. + * + * @name Phaser.Textures.Frame#u0 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.u0 = 0; + + /** + * WebGL UV v0 value. + * + * @name Phaser.Textures.Frame#v0 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.v0 = 0; + + /** + * WebGL UV u1 value. + * + * @name Phaser.Textures.Frame#u1 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.u1 = 0; + + /** + * WebGL UV v1 value. + * + * @name Phaser.Textures.Frame#v1 + * @type {number} + * @default 0 + * @since 3.11.0 + */ + this.v1 = 0; + /** * The un-modified source frame, trim and UV data. * @@ -271,26 +322,16 @@ var Frame = new Class({ x: 0, y: 0, w: 0, - h: 0 - }, - uvs: { - x0: 0, - y0: 0, - x1: 0, - y1: 0, - x2: 0, - y2: 0, - x3: 0, - y3: 0 + h: 0, + r: 0, + b: 0 }, radius: 0, drawImage: { - sx: 0, - sy: 0, - sWidth: 0, - sHeight: 0, - dWidth: 0, - dHeight: 0 + x: 0, + y: 0, + width: 0, + height: 0 } }; @@ -352,12 +393,10 @@ var Frame = new Class({ var drawImage = data.drawImage; - drawImage.sx = x; - drawImage.sy = y; - drawImage.sWidth = width; - drawImage.sHeight = height; - drawImage.dWidth = width; - drawImage.dHeight = height; + drawImage.x = x; + drawImage.y = y; + drawImage.width = width; + drawImage.height = height; return this.updateUVs(); }, @@ -393,6 +432,8 @@ var Frame = new Class({ ss.y = destY; ss.w = destWidth; ss.h = destHeight; + ss.r = destX + destWidth; + ss.b = destY + destHeight; // Adjust properties this.x = destX; @@ -410,6 +451,165 @@ var Frame = new Class({ return this.updateUVs(); }, + /** + * Takes a crop data object and, based on the rectangular region given, calculates the + * required UV coordinates in order to crop this Frame for WebGL and Canvas rendering. + * + * This is called directly by the Game Object Texture Components `setCrop` method. + * Please use that method to crop a Game Object. + * + * @method Phaser.Textures.Frame#setCropUVs + * @since 3.11.0 + * + * @param {object} crop - The crop data object. This is the `GameObject._crop` property. + * @param {number} x - The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. + * @param {number} y - The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param {number} width - The width of the crop rectangle. Cannot exceed the Frame width. + * @param {number} height - The height of the crop rectangle. Cannot exceed the Frame height. + * @param {boolean} flipX - Does the parent Game Object have flipX set? + * @param {boolean} flipY - Does the parent Game Object have flipY set? + * + * @return {object} The updated crop data object. + */ + setCropUVs: function (crop, x, y, width, height, flipX, flipY) + { + // Clamp the input values + + var cx = this.cutX; + var cy = this.cutY; + var cw = this.cutWidth; + var ch = this.cutHeight; + var rw = this.realWidth; + var rh = this.realHeight; + + x = Clamp(x, 0, rw); + y = Clamp(y, 0, rh); + + width = Clamp(width, 0, rw - x); + height = Clamp(height, 0, rh - y); + + var ox = cx + x; + var oy = cy + y; + var ow = width; + var oh = height; + + var data = this.data; + + if (data.trim) + { + var ss = data.spriteSourceSize; + + // Need to check for intersection between the cut area and the crop area + // If there is none, we set UV to be empty, otherwise set it to be the intersection area + + width = Clamp(width, 0, cw - x); + height = Clamp(height, 0, ch - y); + + var cropRight = x + width; + var cropBottom = y + height; + + var intersects = !(ss.r < x || ss.b < y || ss.x > cropRight || ss.y > cropBottom); + + if (intersects) + { + var ix = Math.max(ss.x, x); + var iy = Math.max(ss.y, y); + var iw = Math.min(ss.r, cropRight) - ix; + var ih = Math.min(ss.b, cropBottom) - iy; + + ow = iw; + oh = ih; + + if (flipX) + { + ox = cx + (cw - (ix - ss.x) - iw); + } + else + { + ox = cx + (ix - ss.x); + } + + if (flipY) + { + oy = cy + (ch - (iy - ss.y) - ih); + } + else + { + oy = cy + (iy - ss.y); + } + + x = ix; + y = iy; + + width = iw; + height = ih; + } + else + { + ox = 0; + oy = 0; + ow = 0; + oh = 0; + } + } + else + { + if (flipX) + { + ox = cx + (cw - x - width); + } + + if (flipY) + { + oy = cy + (ch - y - height); + } + } + + var tw = this.source.width; + var th = this.source.height; + + // Map the given coordinates into UV space, clamping to the 0-1 range. + + crop.u0 = Math.max(0, ox / tw); + crop.v0 = Math.max(0, oy / th); + crop.u1 = Math.min(1, (ox + ow) / tw); + crop.v1 = Math.min(1, (oy + oh) / th); + + crop.x = x; + crop.y = y; + + crop.cx = ox; + crop.cy = oy; + crop.cw = ow; + crop.ch = oh; + + crop.width = width; + crop.height = height; + + crop.flipX = flipX; + crop.flipY = flipY; + + return crop; + }, + + /** + * Takes a crop data object and recalculates the UVs based on the dimensions inside the crop object. + * Called automatically by `setFrame`. + * + * @method Phaser.Textures.Frame#updateCropUVs + * @since 3.11.0 + * + * @param {object} crop - The crop data object. This is the `GameObject._crop` property. + * @param {boolean} flipX - Does the parent Game Object have flipX set? + * @param {boolean} flipY - Does the parent Game Object have flipY set? + * + * @return {object} The updated crop data object. + */ + updateCropUVs: function (crop, flipX, flipY) + { + return this.setCropUVs(crop, crop.x, crop.y, crop.width, crop.height, flipX, flipY); + }, + /** * Updates the internal WebGL UV cache and the drawImage cache. * @@ -429,28 +629,19 @@ var Frame = new Class({ var cd = this.data.drawImage; - cd.sWidth = cw; - cd.sHeight = ch; - cd.dWidth = cw; - cd.dHeight = ch; + cd.width = cw; + cd.height = ch; // WebGL data var tw = this.source.width; var th = this.source.height; - var uvs = this.data.uvs; - uvs.x0 = cx / tw; - uvs.y0 = cy / th; + this.u0 = cx / tw; + this.v0 = cy / th; - uvs.x1 = cx / tw; - uvs.y1 = (cy + ch) / th; - - uvs.x2 = (cx + cw) / tw; - uvs.y2 = (cy + ch) / th; - - uvs.x3 = (cx + cw) / tw; - uvs.y3 = cy / th; + this.u1 = (cx + cw) / tw; + this.v1 = (cy + ch) / th; return this; }, @@ -467,19 +658,12 @@ var Frame = new Class({ { var tw = this.source.width; var th = this.source.height; - var uvs = this.data.uvs; - uvs.x3 = (this.cutX + this.cutHeight) / tw; - uvs.y3 = (this.cutY + this.cutWidth) / th; + this.u0 = (this.cutX + this.cutHeight) / tw; + this.v0 = this.cutY / th; - uvs.x2 = this.cutX / tw; - uvs.y2 = (this.cutY + this.cutWidth) / th; - - uvs.x1 = this.cutX / tw; - uvs.y1 = this.cutY / th; - - uvs.x0 = (this.cutX + this.cutHeight) / tw; - uvs.y0 = this.cutY / th; + this.u1 = this.cutX / tw; + this.v1 = (this.cutY + this.cutWidth) / th; return this; }, @@ -541,7 +725,7 @@ var Frame = new Class({ * * @name Phaser.Textures.Frame#realWidth * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ realWidth: { @@ -559,7 +743,7 @@ var Frame = new Class({ * * @name Phaser.Textures.Frame#realHeight * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ realHeight: { @@ -571,29 +755,12 @@ var Frame = new Class({ }, - /** - * The UV data for this Frame. - * - * @name Phaser.Textures.Frame#uvs - * @type {object} - * @readOnly - * @since 3.0.0 - */ - uvs: { - - get: function () - { - return this.data.uvs; - } - - }, - /** * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) * * @name Phaser.Textures.Frame#radius * @type {number} - * @readOnly + * @readonly * @since 3.0.0 */ radius: { @@ -610,7 +777,7 @@ var Frame = new Class({ * * @name Phaser.Textures.Frame#trimmed * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ trimmed: { @@ -627,7 +794,7 @@ var Frame = new Class({ * * @name Phaser.Textures.Frame#canvasData * @type {object} - * @readOnly + * @readonly * @since 3.0.0 */ canvasData: { diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 555e1e790..17a9a1174 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -8,6 +8,8 @@ var Class = require('../utils/Class'); var Frame = require('./Frame'); var TextureSource = require('./TextureSource'); +var TEXTURE_MISSING_ERROR = 'Texture.frame missing: '; + /** * @classdesc * A Texture consists of a source, usually an Image from the Cache, and a collection of Frames. @@ -21,13 +23,13 @@ var TextureSource = require('./TextureSource'); * Sprites and other Game Objects get the texture data they need from the TextureManager. * * @class Texture - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * * @param {Phaser.Textures.TextureManager} manager - A reference to the Texture Manager this Texture belongs to. * @param {string} key - The unique string-based key of this Texture. - * @param {(HTMLImageElement[]|HTMLCanvasElement[])} source - An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. + * @param {(HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[])} source - An array of sources that are used to create the texture. Usually Images, but can also be a Canvas. * @param {number} [width] - The width of the Texture. This is optional and automatically derived from the source images. * @param {number} [height] - The height of the Texture. This is optional and automatically derived from the source images. */ @@ -203,7 +205,7 @@ var Texture = new Class({ if (!frame) { - console.warn('No Texture.frame found with name ' + name); + console.warn(TEXTURE_MISSING_ERROR + name); frame = this.frames[this.firstFrame]; } @@ -244,16 +246,19 @@ var Texture = new Class({ * @since 3.0.0 * * @param {integer} sourceIndex - The index of the TextureSource to get the Frames from. + * @param {boolean} [includeBase=false] - Include the `__BASE` Frame in the output array? * * @return {Phaser.Textures.Frame[]} An array of Texture Frames. */ - getFramesFromTextureSource: function (sourceIndex) + getFramesFromTextureSource: function (sourceIndex, includeBase) { + if (includeBase === undefined) { includeBase = false; } + var out = []; for (var frameName in this.frames) { - if (frameName === '__BASE') + if (frameName === '__BASE' && !includeBase) { continue; } @@ -262,7 +267,7 @@ var Texture = new Class({ if (frame.sourceIndex === sourceIndex) { - out.push(frame.name); + out.push(frame); } } @@ -311,7 +316,7 @@ var Texture = new Class({ * * @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture. * - * @return {(HTMLImageElement|HTMLCanvasElement)} The DOM Image or Canvas Element. + * @return {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)} The DOM Image, Canvas Element or Render Texture. */ getSourceImage: function (name) { @@ -322,15 +327,15 @@ var Texture = new Class({ var frame = this.frames[name]; - if (!frame) + if (frame) { - console.warn('No Texture.frame found with name ' + name); - - return this.frames['__BASE'].source.image; + return frame.source.image; } else { - return frame.source.image; + console.warn(TEXTURE_MISSING_ERROR + name); + + return this.frames['__BASE'].source.image; } }, @@ -359,7 +364,7 @@ var Texture = new Class({ if (!frame) { - console.warn('No Texture.frame found with name ' + name); + console.warn(TEXTURE_MISSING_ERROR + name); idx = this.frames['__BASE'].sourceIndex; } @@ -380,7 +385,7 @@ var Texture = new Class({ * @method Phaser.Textures.Texture#setDataSource * @since 3.0.0 * - * @param {(HTMLImageElement|HTMLCanvasElement)} data - The source image. + * @param {(HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[])} data - The source image. */ setDataSource: function (data) { @@ -388,7 +393,7 @@ var Texture = new Class({ { data = [ data ]; } - + for (var i = 0; i < data.length; i++) { var source = this.source[i]; diff --git a/src/textures/TextureManager.js b/src/textures/TextureManager.js index fb9667229..8b83e77ed 100644 --- a/src/textures/TextureManager.js +++ b/src/textures/TextureManager.js @@ -18,7 +18,7 @@ var Texture = require('./Texture'); /** * @callback EachTextureCallback * - * @param {Phaser.Textures.Texture} texture - [description] + * @param {Phaser.Textures.Texture} texture - Each texture in Texture Manager. * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. */ @@ -33,11 +33,11 @@ var Texture = require('./Texture'); * * @class TextureManager * @extends Phaser.Events.EventEmitter - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * - * @param {Phaser.Game} game - [description] + * @param {Phaser.Game} game - The Phaser.Game instance this Texture Manager belongs to. */ var TextureManager = new Class({ @@ -50,7 +50,7 @@ var TextureManager = new Class({ EventEmitter.call(this); /** - * [description] + * The Game that this TextureManager belongs to. * * @name Phaser.Textures.TextureManager#game * @type {Phaser.Game} @@ -59,7 +59,7 @@ var TextureManager = new Class({ this.game = game; /** - * [description] + * The name of this manager. * * @name Phaser.Textures.TextureManager#name * @type {string} @@ -68,7 +68,8 @@ var TextureManager = new Class({ this.name = 'TextureManager'; /** - * [description] + * An object that has all of textures that Texture Manager creates. + * Textures are assigned to keys so we can access to any texture that this object has directly by key value without iteration. * * @name Phaser.Textures.TextureManager#list * @type {object} @@ -78,7 +79,7 @@ var TextureManager = new Class({ this.list = {}; /** - * [description] + * The temporary canvas element to save an pixel data of an arbitrary texture in getPixel() and getPixelAlpha() method. * * @name Phaser.Textures.TextureManager#_tempCanvas * @type {HTMLCanvasElement} @@ -88,7 +89,7 @@ var TextureManager = new Class({ this._tempCanvas = CanvasPool.create2D(this, 1, 1); /** - * [description] + * The context of the temporary canvas element made to save an pixel data in getPixel() and getPixelAlpha() method. * * @name Phaser.Textures.TextureManager#_tempContext * @type {CanvasRenderingContext2D} @@ -98,7 +99,7 @@ var TextureManager = new Class({ this._tempContext = this._tempCanvas.getContext('2d'); /** - * [description] + * An counting value used for emitting 'ready' event after all of managers in game is loaded. * * @name Phaser.Textures.TextureManager#_pending * @type {integer} @@ -112,9 +113,10 @@ var TextureManager = new Class({ }, /** - * [description] + * The Boot Handler called by Phaser.Game when it first starts up. * * @method Phaser.Textures.TextureManager#boot + * @private * @since 3.0.0 */ boot: function () @@ -131,9 +133,10 @@ var TextureManager = new Class({ }, /** - * [description] + * After 'onload' or 'onerror' invoked twice, emit 'ready' event. * * @method Phaser.Textures.TextureManager#updatePending + * @private * @since 3.0.0 */ updatePending: function () @@ -145,7 +148,7 @@ var TextureManager = new Class({ this.off('onload'); this.off('onerror'); - this.game.events.emit('ready'); + this.game.events.emit('texturesready'); } }, @@ -225,6 +228,8 @@ var TextureManager = new Class({ * * @param {string} key - The unique string-based key of the Texture. * @param {*} data - The Base64 encoded data. + * + * @return {this} This Texture Manager instance. */ addBase64: function (key, data) { @@ -252,6 +257,59 @@ var TextureManager = new Class({ image.src = data; } + + return this; + }, + + /** + * Gets an existing texture frame and converts it into a base64 encoded image and returns the base64 data. + * + * You can also provide the image type and encoder options. + * + * @method Phaser.Textures.TextureManager#getBase64 + * @since 3.12.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. + * @param {string} [type='image/png'] - [description] + * @param {number} [encoderOptions=0.92] - [description] + * + * @return {string} The base64 encoded data, or an empty string if the texture frame could not be found. + */ + getBase64: function (key, frame, type, encoderOptions) + { + if (type === undefined) { type = 'image/png'; } + if (encoderOptions === undefined) { encoderOptions = 0.92; } + + var data = ''; + + var textureFrame = this.getFrame(key, frame); + + if (textureFrame) + { + var cd = textureFrame.canvasData; + + var canvas = CanvasPool.create2D(this, cd.width, cd.height); + var ctx = canvas.getContext('2d'); + + ctx.drawImage( + textureFrame.source.image, + cd.x, + cd.y, + cd.width, + cd.height, + 0, + 0, + cd.width, + cd.height + ); + + data = canvas.toDataURL(type, encoderOptions); + + CanvasPool.remove(canvas); + } + + return data; }, /** @@ -262,7 +320,7 @@ var TextureManager = new Class({ * * @param {string} key - The unique string-based key of the Texture. * @param {HTMLImageElement} source - The source Image element. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * @param {HTMLImageElement|HTMLCanvasElement} [dataSource] - An optional data Image element. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -287,6 +345,34 @@ var TextureManager = new Class({ return texture; }, + /** + * Adds a Render Texture to the Texture Manager using the given key. + * This allows you to then use the Render Texture as a normal texture for texture based Game Objects like Sprites. + * + * @method Phaser.Textures.TextureManager#addRenderTexture + * @since 3.12.0 + * + * @param {string} key - The unique string-based key of the Texture. + * @param {Phaser.GameObjects.RenderTexture} renderTexture - The source Render Texture. + * + * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. + */ + addRenderTexture: function (key, renderTexture) + { + var texture = null; + + if (this.checkKey(key)) + { + texture = this.create(key, renderTexture); + + texture.add('__BASE', 0, 0, 0, renderTexture.width, renderTexture.height); + + this.emit('addtexture', key, texture); + } + + return texture; + }, + /** * Creates a new Texture using the given config values. * Generated textures consist of a Canvas element to which the texture data is drawn. @@ -296,7 +382,7 @@ var TextureManager = new Class({ * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. - * @param {object} config - [description] + * @param {object} config - The configuration object needed to generate the texture. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -349,22 +435,29 @@ var TextureManager = new Class({ }, /** - * Creates a new Canvas Texture object from an existing Canvas element and adds - * it to this Texture Manager. + * Creates a new Canvas Texture object from an existing Canvas element + * and adds it to this Texture Manager, unless `skipCache` is true. * * @method Phaser.Textures.TextureManager#addCanvas * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. * @param {HTMLCanvasElement} source - The Canvas element to form the base of the new Texture. + * @param {boolean} [skipCache=false] - Skip adding this Texture into the Cache? * * @return {?Phaser.Textures.CanvasTexture} The Canvas Texture that was created, or `null` if the key is already in use. */ - addCanvas: function (key, source) + addCanvas: function (key, source, skipCache) { + if (skipCache === undefined) { skipCache = false; } + var texture = null; - if (this.checkKey(key)) + if (skipCache) + { + texture = new CanvasTexture(this, key, source, source.width, source.height); + } + else if (this.checkKey(key)) { texture = new CanvasTexture(this, key, source, source.width, source.height); @@ -386,7 +479,7 @@ var TextureManager = new Class({ * @param {string} key - The unique string-based key of the Texture. * @param {HTMLImageElement} source - The source Image element. * @param {object} data - The Texture Atlas data. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * @param {HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[]} [dataSource] - An optional data Image element. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -414,7 +507,7 @@ var TextureManager = new Class({ * @param {string} key - The unique string-based key of the Texture. * @param {(HTMLImageElement|HTMLImageElement[])} source - The source Image element/s. * @param {(object|object[])} data - The Texture Atlas data/s. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * @param {HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[]} [dataSource] - An optional data Image element. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -466,7 +559,7 @@ var TextureManager = new Class({ * @param {string} key - The unique string-based key of the Texture. * @param {HTMLImageElement} source - The source Image element. * @param {object} data - The Texture Atlas data. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * @param {HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[]} [dataSource] - An optional data Image element. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -511,7 +604,7 @@ var TextureManager = new Class({ * @param {string} key - The unique string-based key of the Texture. * @param {HTMLImageElement} source - The source Image element. * @param {object} data - The Texture Atlas XML data. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * @param {HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[]} [dataSource] - An optional data Image element. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -546,7 +639,7 @@ var TextureManager = new Class({ * @param {string} key - The unique string-based key of the Texture. * @param {HTMLImageElement} source - The source Image element. * @param {object} data - The Texture Atlas data. - * @param {HTMLImageElement} [dataSource] - An optional data Image element. + * @param {HTMLImageElement|HTMLCanvasElement|HTMLImageElement[]|HTMLCanvasElement[]} [dataSource] - An optional data Image element. * * @return {?Phaser.Textures.Texture} The Texture that was created, or `null` if the key is already in use. */ @@ -775,7 +868,7 @@ var TextureManager = new Class({ * @since 3.0.0 * * @param {string} key - The unique string-based key of the Texture. - * @param {(string|integer)} frame - The string or index of the Frame. + * @param {(string|integer)} [frame] - The string-based name, or integer based index, of the Frame to get from the Texture. * * @return {Phaser.Textures.Frame} A Texture Frame object. */ @@ -833,25 +926,23 @@ var TextureManager = new Class({ if (textureFrame) { - var source = textureFrame.source.image; + // Adjust for trim (if not trimmed x and y are just zero) + x -= textureFrame.x; + y -= textureFrame.y; - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) + var data = textureFrame.data.cut; + + x += data.x; + y += data.y; + + if (x >= data.x && x < data.r && y >= data.y && y < data.b) { - x += textureFrame.cutX; - y += textureFrame.cutY; + var ctx = this._tempContext; - // if (textureFrame.trimmed) - // { - // x -= this.sprite.texture.trim.x; - // y -= this.sprite.texture.trim.y; - // } + ctx.clearRect(0, 0, 1, 1); + ctx.drawImage(textureFrame.source.image, x, y, 1, 1, 0, 0, 1, 1); - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); + var rgb = ctx.getImageData(0, 0, 1, 1); return new Color(rgb.data[0], rgb.data[1], rgb.data[2], rgb.data[3]); } @@ -881,20 +972,24 @@ var TextureManager = new Class({ if (textureFrame) { - var source = textureFrame.source.image; + // Adjust for trim (if not trimmed x and y are just zero) + x -= textureFrame.x; + y -= textureFrame.y; - if (x >= 0 && x <= source.width && y >= 0 && y <= source.height) + var data = textureFrame.data.cut; + + x += data.x; + y += data.y; + + if (x >= data.x && x < data.r && y >= data.y && y < data.b) { - x += textureFrame.cutX; - y += textureFrame.cutY; - - var context = this._tempContext; - - context.clearRect(0, 0, 1, 1); - context.drawImage(source, x, y, 1, 1, 0, 0, 1, 1); - - var rgb = context.getImageData(0, 0, 1, 1); + var ctx = this._tempContext; + ctx.clearRect(0, 0, 1, 1); + ctx.drawImage(textureFrame.source.image, x, y, 1, 1, 0, 0, 1, 1); + + var rgb = ctx.getImageData(0, 0, 1, 1); + return rgb.data[3]; } } @@ -909,7 +1004,7 @@ var TextureManager = new Class({ * @method Phaser.Textures.TextureManager#setTexture * @since 3.0.0 * - * @param {Phaser.GameObjects.GameObject} gameObject - [description] + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the texture would be set on. * @param {string} key - The unique string-based key of the Texture. * @param {(string|integer)} frame - The string or index of the Frame. * @@ -926,6 +1021,40 @@ var TextureManager = new Class({ return gameObject; }, + /** + * Changes the key being used by a Texture to the new key provided. + * + * The old key is removed, allowing it to be re-used. + * + * Game Objects are linked to Textures by a reference to the Texture object, so + * all existing references will be retained. + * + * @method Phaser.Textures.TextureManager#renameTexture + * @since 3.12.0 + * + * @param {string} currentKey - The current string-based key of the Texture you wish to rename. + * @param {string} newKey - The new unique string-based key to use for the Texture. + * + * @return {boolean} `true` if the Texture key was successfully renamed, otherwise `false`. + */ + renameTexture: function (currentKey, newKey) + { + var texture = this.get(currentKey); + + if (texture && currentKey !== newKey) + { + texture.key = newKey; + + this.list[newKey] = texture; + + delete this.list[currentKey]; + + return true; + } + + return false; + }, + /** * Passes all Textures to the given callback. * diff --git a/src/textures/TextureSource.js b/src/textures/TextureSource.js index 93d9710b1..4bc0c4908 100644 --- a/src/textures/TextureSource.js +++ b/src/textures/TextureSource.js @@ -17,7 +17,7 @@ var ScaleModes = require('../renderer/ScaleModes'); * A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded. * * @class TextureSource - * @memberOf Phaser.Textures + * @memberof Phaser.Textures * @constructor * @since 3.0.0 * @@ -47,13 +47,24 @@ var TextureSource = new Class({ * The Texture this TextureSource belongs to. * * @name Phaser.Textures.TextureSource#texture - * @type {string} + * @type {Phaser.Textures.Texture} * @since 3.0.0 */ this.texture = texture; /** - * The source image data. This is either an Image Element, or a Canvas Element. + * The source of the image data. + * This is either an Image Element, a Canvas Element or a RenderTexture. + * + * @name Phaser.Textures.TextureSource#source + * @type {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)} + * @since 3.12.0 + */ + this.source = source; + + /** + * The image data. + * This is either an Image element or a Canvas element. * * @name Phaser.Textures.TextureSource#image * @type {(HTMLImageElement|HTMLCanvasElement)} @@ -120,6 +131,15 @@ var TextureSource = new Class({ */ this.isCanvas = (source instanceof HTMLCanvasElement); + /** + * Is the source image a Render Texture? + * + * @name Phaser.Textures.TextureSource#isRenderTexture + * @type {boolean} + * @since 3.12.0 + */ + this.isRenderTexture = (source.type === 'RenderTexture'); + /** * Are the source image dimensions a power of two? * @@ -152,15 +172,28 @@ var TextureSource = new Class({ */ init: function (game) { - if (this.renderer && this.renderer.gl) + if (this.renderer) { - if (this.isCanvas) + if (this.renderer.gl) { - this.glTexture = this.renderer.canvasToTexture(this.image); + if (this.isCanvas) + { + this.glTexture = this.renderer.canvasToTexture(this.image); + } + else if (this.isRenderTexture) + { + this.image = this.source.canvas; + + this.glTexture = this.renderer.createTextureFromSource(null, this.width, this.height, this.scaleMode); + } + else + { + this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + } } - else + else if (this.isRenderTexture) { - this.glTexture = this.renderer.createTextureFromSource(this.image, this.width, this.height, this.scaleMode); + this.image = this.source.canvas; } } @@ -201,7 +234,20 @@ var TextureSource = new Class({ { if (this.renderer.gl && this.isCanvas) { - this.renderer.canvasToTexture(this.image, this.glTexture); + this.glTexture = this.renderer.canvasToTexture(this.image, this.glTexture); + + // Update all the Frames using this TextureSource + + /* + var index = this.texture.getTextureSourceIndex(this); + + var frames = this.texture.getFramesFromTextureSource(index, true); + + for (var i = 0; i < frames.length; i++) + { + frames[i].glTexture = this.glTexture; + } + */ } }, @@ -225,7 +271,9 @@ var TextureSource = new Class({ this.renderer = null; this.texture = null; + this.source = null; this.image = null; + this.glTexture = null; } }); diff --git a/src/textures/const.js b/src/textures/const.js index e4c33f0ca..8ea18b883 100644 --- a/src/textures/const.js +++ b/src/textures/const.js @@ -9,8 +9,8 @@ * * @name Phaser.Textures.FilterMode * @enum {integer} - * @memberOf Phaser.Textures - * @readOnly + * @memberof Phaser.Textures + * @readonly * @since 3.0.0 */ var CONST = { diff --git a/src/textures/parsers/AtlasXML.js b/src/textures/parsers/AtlasXML.js index 6385eebbe..0e1966331 100644 --- a/src/textures/parsers/AtlasXML.js +++ b/src/textures/parsers/AtlasXML.js @@ -8,7 +8,7 @@ * Parses an XML Texture Atlas object and adds all the Frames into a Texture. * * @function Phaser.Textures.Parsers.AtlasXML - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.7.0 * diff --git a/src/textures/parsers/Canvas.js b/src/textures/parsers/Canvas.js index 218863ee2..6035541e0 100644 --- a/src/textures/parsers/Canvas.js +++ b/src/textures/parsers/Canvas.js @@ -8,7 +8,7 @@ * Adds a Canvas Element to a Texture. * * @function Phaser.Textures.Parsers.Canvas - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * diff --git a/src/textures/parsers/Image.js b/src/textures/parsers/Image.js index cee1e89f9..e78f2aa87 100644 --- a/src/textures/parsers/Image.js +++ b/src/textures/parsers/Image.js @@ -8,7 +8,7 @@ * Adds an Image Element to a Texture. * * @function Phaser.Textures.Parsers.Image - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * diff --git a/src/textures/parsers/JSONArray.js b/src/textures/parsers/JSONArray.js index f338c6045..f630610c3 100644 --- a/src/textures/parsers/JSONArray.js +++ b/src/textures/parsers/JSONArray.js @@ -11,7 +11,7 @@ var Clone = require('../../utils/object/Clone'); * JSON format expected to match that defined by Texture Packer, with the frames property containing an array of Frames. * * @function Phaser.Textures.Parsers.JSONArray - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * diff --git a/src/textures/parsers/JSONHash.js b/src/textures/parsers/JSONHash.js index 33c0a5725..3f2a3ac41 100644 --- a/src/textures/parsers/JSONHash.js +++ b/src/textures/parsers/JSONHash.js @@ -11,7 +11,7 @@ var Clone = require('../../utils/object/Clone'); * JSON format expected to match that defined by Texture Packer, with the frames property containing an object of Frames. * * @function Phaser.Textures.Parsers.JSONHash - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * diff --git a/src/textures/parsers/SpriteSheet.js b/src/textures/parsers/SpriteSheet.js index 65c99cb98..c9a5e3d14 100644 --- a/src/textures/parsers/SpriteSheet.js +++ b/src/textures/parsers/SpriteSheet.js @@ -13,7 +13,7 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * same size and cannot be trimmed or rotated. * * @function Phaser.Textures.Parsers.SpriteSheet - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -58,6 +58,11 @@ var SpriteSheet = function (texture, sourceIndex, x, y, width, height, config) var column = Math.floor((height - margin + spacing) / (frameHeight + spacing)); var total = row * column; + if (total === 0) + { + console.warn('SpriteSheet frame dimensions will result in zero frames.'); + } + if (startFrame > total || startFrame < -total) { startFrame = 0; diff --git a/src/textures/parsers/SpriteSheetFromAtlas.js b/src/textures/parsers/SpriteSheetFromAtlas.js index 1d3626d40..b9e341c95 100644 --- a/src/textures/parsers/SpriteSheetFromAtlas.js +++ b/src/textures/parsers/SpriteSheetFromAtlas.js @@ -13,7 +13,7 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * same size and cannot be trimmed or rotated. * * @function Phaser.Textures.Parsers.SpriteSheetFromAtlas - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * @@ -22,8 +22,8 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * @param {object} config - An object describing how to parse the Sprite Sheet. * @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet. * @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided. - * @param {number} [config.startFrame=0] - [description] - * @param {number} [config.endFrame=-1] - [description] + * @param {number} [config.startFrame=0] - Index of the start frame in the sprite sheet + * @param {number} [config.endFrame=-1] - Index of the end frame in the sprite sheet. -1 mean all the rest of the frames * @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here. * @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here. * @@ -117,27 +117,33 @@ var SpriteSheetFromAtlas = function (texture, frame, config) { var destX = (leftRow) ? leftPad : 0; var destY = (topRow) ? topPad : 0; - var destWidth = frameWidth; - var destHeight = frameHeight; + + var trimWidth = 0; + var trimHeight = 0; if (leftRow) { - destWidth = leftWidth; + trimWidth += (frameWidth - leftWidth); } - else if (rightRow) + + if (rightRow) { - destWidth = rightWidth; + trimWidth += (frameWidth - rightWidth); } if (topRow) { - destHeight = topHeight; + trimHeight += (frameHeight - topHeight); } - else if (bottomRow) + + if (bottomRow) { - destHeight = bottomHeight; + trimHeight += (frameHeight - bottomHeight); } + var destWidth = frameWidth - trimWidth; + var destHeight = frameHeight - trimHeight; + sheetFrame.cutWidth = destWidth; sheetFrame.cutHeight = destHeight; @@ -152,7 +158,7 @@ var SpriteSheetFromAtlas = function (texture, frame, config) } else if (rightRow) { - frameX += rightRow; + frameX += rightWidth; } else { diff --git a/src/textures/parsers/UnityYAML.js b/src/textures/parsers/UnityYAML.js index 4069c45e1..5234724a6 100644 --- a/src/textures/parsers/UnityYAML.js +++ b/src/textures/parsers/UnityYAML.js @@ -40,7 +40,7 @@ var addFrame = function (texture, sourceIndex, name, frame) * For more details about Sprite Meta Data see https://docs.unity3d.com/ScriptReference/SpriteMetaData.html * * @function Phaser.Textures.Parsers.UnityYAML - * @memberOf Phaser.Textures.Parsers + * @memberof Phaser.Textures.Parsers * @private * @since 3.0.0 * diff --git a/src/tilemaps/ImageCollection.js b/src/tilemaps/ImageCollection.js index 02583a22f..880c7898a 100644 --- a/src/tilemaps/ImageCollection.js +++ b/src/tilemaps/ImageCollection.js @@ -13,7 +13,7 @@ var Class = require('../utils/Class'); * Image Collections are normally created automatically when Tiled data is loaded. * * @class ImageCollection - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -60,7 +60,7 @@ var ImageCollection = new Class({ * * @name Phaser.Tilemaps.ImageCollection#imageWidth * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.imageWidth = width | 0; @@ -70,7 +70,7 @@ var ImageCollection = new Class({ * * @name Phaser.Tilemaps.ImageCollection#imageHeight * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.imageHeight = height | 0; @@ -81,7 +81,7 @@ var ImageCollection = new Class({ * * @name Phaser.Tilemaps.ImageCollection#imageMarge * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.imageMargin = margin | 0; @@ -92,7 +92,7 @@ var ImageCollection = new Class({ * * @name Phaser.Tilemaps.ImageCollection#imageSpacing * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.imageSpacing = spacing | 0; @@ -111,7 +111,7 @@ var ImageCollection = new Class({ * * @name Phaser.Tilemaps.ImageCollection#images * @type {array} - * @readOnly + * @readonly * @since 3.0.0 */ this.images = []; @@ -121,7 +121,7 @@ var ImageCollection = new Class({ * * @name Phaser.Tilemaps.ImageCollection#total * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.total = 0; diff --git a/src/tilemaps/Tile.js b/src/tilemaps/Tile.js index 3133c14c0..d8b1f4ca8 100644 --- a/src/tilemaps/Tile.js +++ b/src/tilemaps/Tile.js @@ -15,7 +15,7 @@ var Rectangle = require('../geom/rectangle'); * scale or layer position. * * @class Tile - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -710,7 +710,9 @@ var Tile = new Class({ // bottom left, while the Phaser renderer assumes the origin is the top left. The y // coordinate needs to be adjusted by the difference. this.pixelX = this.x * this.baseWidth; - this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight); + this.pixelY = this.y * this.baseHeight; + + // this.pixelY = this.y * this.baseHeight - (this.height - this.baseHeight); return this; }, @@ -720,7 +722,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#canCollide * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ canCollide: { @@ -735,7 +737,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#collides * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ collides: { @@ -750,7 +752,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#hasInterestingFace * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ hasInterestingFace: { @@ -761,20 +763,34 @@ var Tile = new Class({ }, /** - * The tileset that contains this Tile. This will only return null if accessed from a LayerData - * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. + * The tileset that contains this Tile. This is null if accessed from a LayerData instance + * before the tile is placed in a StaticTilemapLayer or DynamicTilemapLayer, or if the tile has + * an index that doesn't correspond to any of the map's tilesets. * * @name Phaser.Tilemaps.Tile#tileset * @type {?Phaser.Tilemaps.Tileset} - * @readOnly + * @readonly * @since 3.0.0 */ tileset: { + get: function () { - var tilemapLayer = this.tilemapLayer; - return tilemapLayer ? tilemapLayer.tileset : null; + var tilemapLayer = this.layer.tilemapLayer; + + if (tilemapLayer) + { + var tileset = tilemapLayer.gidMap[this.index]; + + if (tileset) + { + return tileset; + } + } + + return null; } + }, /** @@ -784,7 +800,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#tilemapLayer * @type {?Phaser.Tilemaps.StaticTilemapLayer|Phaser.Tilemaps.DynamicTilemapLayer} - * @readOnly + * @readonly * @since 3.0.0 */ tilemapLayer: { @@ -800,7 +816,7 @@ var Tile = new Class({ * * @name Phaser.Tilemaps.Tile#tilemap * @type {?Phaser.Tilemaps.Tilemap} - * @readOnly + * @readonly * @since 3.0.0 */ tilemap: { diff --git a/src/tilemaps/Tilemap.js b/src/tilemaps/Tilemap.js index a5e61bbed..e3f334e8d 100644 --- a/src/tilemaps/Tilemap.js +++ b/src/tilemaps/Tilemap.js @@ -19,21 +19,21 @@ var Tileset = require('./Tileset'); /** * @callback TilemapFilterCallback * - * @param {Phaser.GameObjects.GameObject} value - [description] - * @param {number} index - [description] - * @param {Phaser.GameObjects.GameObject[]} array - [description] + * @param {Phaser.GameObjects.GameObject} value - An object found in the filtered area. + * @param {number} index - The index of the object within the array. + * @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found. * - * @return {Phaser.GameObjects.GameObject} [description] + * @return {Phaser.GameObjects.GameObject} The object. */ /** * @callback TilemapFindCallback * - * @param {Phaser.GameObjects.GameObject} value - [description] - * @param {number} index - [description] - * @param {Phaser.GameObjects.GameObject[]} array - [description] + * @param {Phaser.GameObjects.GameObject} value - An object found. + * @param {number} index - The index of the object within the array. + * @param {Phaser.GameObjects.GameObject[]} array - An array of all the objects found. * - * @return {boolean} [description] + * @return {boolean} `true` if the callback should be invoked, otherwise `false`. */ /** @@ -55,7 +55,7 @@ var Tileset = require('./Tileset'); * it. * * @class Tilemap - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -122,6 +122,24 @@ var Tilemap = new Class({ */ this.orientation = mapData.orientation; + /** + * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. + * + * The draw orders are: + * + * right-down + * left-down + * right-up + * left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.Tilemap#renderOrder + * @type {string} + * @since 3.12.0 + */ + this.renderOrder = mapData.renderOrder; + /** * The format of the map data. * @@ -221,6 +239,52 @@ var Tilemap = new Class({ this.currentLayerIndex = 0; }, + /** + * Sets the rendering (draw) order of the tiles in this map. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * Calling this method _after_ creating Static or Dynamic Tilemap Layers will **not** automatically + * update them to use the new render order. If you call this method after creating layers, use their + * own `setRenderOrder` methods to change them as needed. + * + * @method Phaser.Tilemaps.Tilemap#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'number') + { + renderOrder = orders[renderOrder]; + } + + if (orders.indexOf(renderOrder) > -1) + { + this.renderOrder = renderOrder; + } + + return this; + }, + /** * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled @@ -255,7 +319,7 @@ var Tilemap = new Class({ if (!this.scene.sys.textures.exists(key)) { - console.warn('Invalid image key given for tileset: "' + key + '"'); + console.warn('Invalid Tileset Image: ' + key); return null; } @@ -265,16 +329,19 @@ var Tilemap = new Class({ if (index === null && this.format === Formats.TILED_JSON) { - console.warn('No data found in the JSON tilemap from Tiled matching the tileset name: "' + tilesetName + '"'); + console.warn('No data found for Tileset: ' + tilesetName); return null; } - if (this.tilesets[index]) + var tileset = this.tilesets[index]; + + if (tileset) { - this.tilesets[index].setTileSize(tileWidth, tileHeight); - this.tilesets[index].setSpacing(tileMargin, tileSpacing); - this.tilesets[index].setImage(texture); - return this.tilesets[index]; + tileset.setTileSize(tileWidth, tileHeight); + tileset.setSpacing(tileMargin, tileSpacing); + tileset.setImage(texture); + + return tileset; } if (tileWidth === undefined) { tileWidth = this.tileWidth; } @@ -283,8 +350,10 @@ var Tilemap = new Class({ if (tileSpacing === undefined) { tileSpacing = 0; } if (gid === undefined) { gid = 0; } - var tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); + tileset = new Tileset(tilesetName, gid, tileWidth, tileHeight, tileMargin, tileSpacing); + tileset.setImage(texture); + this.tilesets.push(tileset); return tileset; @@ -336,12 +405,24 @@ var Tilemap = new Class({ }, /** - * See component documentation. If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers. * * @method Phaser.Tilemaps.Tilemap#copy * @since 3.0.0 * + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. + * * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. */ copy: function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) @@ -364,24 +445,20 @@ var Tilemap = new Class({ }, /** - * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set - * to this new layer. + * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set to this new layer. * * @method Phaser.Tilemaps.Tilemap#createBlankDynamicLayer * @since 3.0.0 * * @param {string} name - The name of this layer. Must be unique within the map. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. * @param {number} [x=0] - The world x position where the top left of this layer will be placed. * @param {number} [y=0] - The world y position where the top left of this layer will be placed. - * @param {integer} [width] - The width of the layer in tiles. If not specified, it will default - * to the map's width. - * @param {integer} [height] - The height of the layer in tiles. If not specified, it will default - * to the map's height. - * @param {integer} [tileWidth] - The width of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileWidth. - * @param {integer} [tileHeight] - The height of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileHeight. + * @param {integer} [width] - The width of the layer in tiles. If not specified, it will default to the map's width. + * @param {integer} [height] - The height of the layer in tiles. If not specified, it will default to the map's height. + * @param {integer} [tileWidth] - The width of the tiles the layer uses for calculations. If not specified, it will default to the map's tileWidth. + * @param {integer} [tileHeight] - The height of the tiles the layer uses for calculations. If not specified, it will default to the map's tileHeight. + * * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. */ createBlankDynamicLayer: function (name, tileset, x, y, width, height, tileWidth, tileHeight) @@ -397,7 +474,7 @@ var Tilemap = new Class({ if (index !== null) { - console.warn('Cannot create blank layer: layer with matching name already exists ' + name); + console.warn('Invalid Tilemap Layer ID: ' + name); return null; } @@ -424,9 +501,13 @@ var Tilemap = new Class({ } this.layers.push(layerData); + this.currentLayerIndex = this.layers.length - 1; var dynamicLayer = new DynamicTilemapLayer(this.scene, this, this.currentLayerIndex, tileset, x, y); + + dynamicLayer.setRenderOrder(this.renderOrder); + this.scene.sys.displayList.add(dynamicLayer); return dynamicLayer; @@ -446,13 +527,10 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#createDynamicLayer * @since 3.0.0 * - * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. * * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. */ @@ -462,7 +540,7 @@ var Tilemap = new Class({ if (index === null) { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); + console.warn('Invalid Tilemap Layer ID: ' + layerID); return null; } @@ -471,25 +549,20 @@ var Tilemap = new Class({ // Check for an associated static or dynamic tilemap layer if (layerData.tilemapLayer) { - console.warn('Cannot create dynamic tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); + console.warn('Tilemap Layer ID already exists:' + layerID); return null; } this.currentLayerIndex = index; - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. + // Default the x/y position to match Tiled layer offset, if it exists. if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } var layer = new DynamicTilemapLayer(this.scene, this, index, tileset, x, y); + + layer.setRenderOrder(this.renderOrder); + this.scene.sys.displayList.add(layer); return layer; @@ -501,6 +574,9 @@ var Tilemap = new Class({ * way to configure Sprite properties from within the map editor. For example giving an object a * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. * + * Custom object properties not sharing names with the Sprite's own properties are copied to the + * Sprite's {@link Phaser.GameObjects.Sprite#data data store}. + * * @method Phaser.Tilemaps.Tilemap#createFromObjects * @since 3.0.0 * @@ -508,7 +584,7 @@ var Tilemap = new Class({ * @param {(integer|string)} id - Either the id (object), gid (tile object) or name (object or * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects * with the same graphic. The same name can be used on multiple objects. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. * scene.make.sprite). * @param {Phaser.Scene} [scene=the scene the map is within] - The Scene to create the Sprites within. * @@ -579,6 +655,16 @@ var Tilemap = new Class({ if (!obj.visible) { sprite.visible = false; } + for (var key in obj.properties) + { + if (sprite.hasOwnProperty(key)) + { + continue; + } + + sprite.setData(key, obj.properties[key]); + } + sprites.push(sprite); } } @@ -599,11 +685,10 @@ var Tilemap = new Class({ * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite). * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.GameObjects.Sprite[]} Returns an array of Tiles, or null if the layer given was invalid. */ @@ -630,13 +715,10 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#createStaticLayer * @since 3.0.0 * - * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {number} x - The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param {number} y - The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. + * @param {(integer|string)} layerID - The layer array index value, or if a string is given, the layer name from Tiled. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param {number} x - The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param {number} y - The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. * * @return {?Phaser.Tilemaps.StaticTilemapLayer} Returns the new layer was created, or null if it failed. */ @@ -646,34 +728,29 @@ var Tilemap = new Class({ if (index === null) { - console.warn('Cannot create tilemap layer, invalid layer ID given: ' + layerID); + console.warn('Invalid Tilemap Layer ID: ' + layerID); return null; } var layerData = this.layers[index]; - // Check for an associated static or dynamic tilemap layer + // Check for an associated static or dynamic tilemap layer if (layerData.tilemapLayer) { - console.warn('Cannot create static tilemap layer since a static or dynamic tilemap layer exists for layer ID:' + layerID); + console.warn('Tilemap Layer ID already exists:' + layerID); return null; } this.currentLayerIndex = index; - // Make sure that all the LayerData & the tiles have the correct tile size. They usually - // are, but wouldn't match if you try to load a 2x or 4x res tileset when the map was made - // with a 1x res tileset. - if (layerData.tileWidth !== tileset.tileWidth || layerData.tileHeight !== tileset.tileHeight) - { - this.setLayerTileSize(tileset.tileWidth, tileset.tileHeight, index); - } - - // Default the x/y position to match Tiled layer offset, if it exists. + // Default the x/y position to match Tiled layer offset, if it exists. if (x === undefined && this.layers[index].x) { x = this.layers[index].x; } if (y === undefined && this.layers[index].y) { y = this.layers[index].y; } var layer = new StaticTilemapLayer(this.scene, this, index, tileset, x, y); + + layer.setRenderOrder(this.renderOrder); + this.scene.sys.displayList.add(layer); return layer; @@ -705,13 +782,13 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#fill * @since 3.0.0 * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} index - The tile index to fill the area with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. */ @@ -774,18 +851,15 @@ var Tilemap = new Class({ * callback as the first and only parameter. The callback should return true for tiles that pass the * filter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. */ @@ -811,9 +885,8 @@ var Tilemap = new Class({ * * @param {integer} index - The tile index value to search for. * @param {integer} [skip=0] - The number of times to skip a matching tile before returning. - * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [reverse=false] - If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. */ @@ -867,21 +940,17 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#findTile * @since 3.0.0 * - * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The Tile layer to run the search on. If not provided will use the current layer. * * @return {?Phaser.Tilemaps.Tile} Returns a Tiles, or null if the layer given was invalid. */ @@ -903,21 +972,17 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#forEachTile * @since 3.0.0 * - * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {LayerData} [layer] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The Tile layer to run the search on. If not provided will use the current layer. * * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. */ @@ -1073,9 +1138,8 @@ var Tilemap = new Class({ * * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. */ @@ -1097,10 +1161,9 @@ var Tilemap = new Class({ * * @param {number} worldX - X position to get the tile from (given in pixels) * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. */ @@ -1125,18 +1188,15 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#getTilesWithin * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. */ @@ -1159,14 +1219,11 @@ var Tilemap = new Class({ * * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. */ @@ -1186,19 +1243,16 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#getTilesWithinWorldXY * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile[]} Returns an array of Tiles, or null if the layer given was invalid. */ @@ -1211,6 +1265,23 @@ var Tilemap = new Class({ return TilemapComponents.GetTilesWithinWorldXY(worldX, worldY, width, height, filteringOptions, camera, layer); }, + /** + * Gets the Tileset that has the given `name`, or null if an invalid `name` is given. + * + * @method Phaser.Tilemaps.Tilemap#getTileset + * @since 3.14.0 + * + * @param {string} name - The name of the Tileset to get. + * + * @return {?Phaser.Tilemaps.Tileset} The Tileset, or `null` if no matching named tileset was found. + */ + getTileset: function (name) + { + var index = this.getIndex(this.tilesets, name); + + return (index !== null) ? this.tilesets[index] : null; + }, + /** * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an * invalid `name` is given. @@ -1236,9 +1307,9 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#hasTileAt * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?boolean} Returns a boolean, or null if the layer given was invalid. */ @@ -1260,10 +1331,10 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#hasTileAtWorldXY * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?boolean} Returns a boolean, or null if the layer given was invalid. */ @@ -1310,12 +1381,12 @@ var Tilemap = new Class({ * @since 3.0.0 * * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * - * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. + * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid or the coordinates were out of bounds. */ putTileAt: function (tile, tileX, tileY, recalculateFaces, layer) { @@ -1341,11 +1412,11 @@ var Tilemap = new Class({ * @since 3.0.0 * * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. */ @@ -1373,12 +1444,11 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#putTilesAt * @since 3.0.0 * - * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. */ @@ -1409,12 +1479,12 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#randomize * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. */ @@ -1442,9 +1512,9 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#calculateFacesAt * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. */ @@ -1469,11 +1539,11 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#calculateFacesWithin * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Returns this, or null if the layer given was invalid. */ @@ -1524,13 +1594,11 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#removeTileAt * @since 3.0.0 * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. */ @@ -1555,14 +1623,12 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#removeTileAtWorldXY * @since 3.0.0 * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tile} Returns a Tile, or null if the layer given was invalid. */ @@ -1590,13 +1656,10 @@ var Tilemap = new Class({ * * @param {Phaser.GameObjects.Graphics} graphics - The target Graphics object to draw upon. * @param {object} styleConfig - An object specifying the colors to use for the debug drawing. - * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. - * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. - * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {?Color} [styleConfig.tileColor=blue] - Color to use for drawing a filled rectangle at non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + * @param {?Color} [styleConfig.collidingTileColor=orange] - Color to use for drawing a filled rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + * @param {?Color} [styleConfig.faceColor=grey] - Color to use for drawing a line at interesting tile faces. If set to null, interesting tile faces will not be drawn. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -1622,13 +1685,13 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#replaceByIndex * @since 3.0.0 * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -1657,11 +1720,9 @@ var Tilemap = new Class({ * @since 3.0.0 * * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -1689,11 +1750,9 @@ var Tilemap = new Class({ * * @param {integer} start - The first index of the tile to be set for collision. * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -1722,13 +1781,10 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#setCollisionByProperty * @since 3.0.0 * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {object} properties - An object with tile properties and corresponding values that should be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -1754,11 +1810,9 @@ var Tilemap = new Class({ * @since 3.0.0 * * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -1784,11 +1838,9 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#setCollisionFromCollisionGroup * @since 3.0.0 * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -1814,11 +1866,10 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#setTileIndexCallback * @since 3.0.0 * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for. * @param {function} callback - The callback that will be invoked when the tile is collided with. * @param {object} callbackContext - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -1843,13 +1894,13 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#setTileLocationCallback * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. * @param {function} callback - The callback that will be invoked when the tile is collided with. * @param {object} [callbackContext] - The context under which the callback is called. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -1910,16 +1961,16 @@ var Tilemap = new Class({ // Update the base tile size on all layers & tiles for (var i = 0; i < this.layers.length; i++) { - this.layers[i].baseWidth = tileWidth; - this.layers[i].baseHeight = tileHeight; + this.layers[i].baseTileWidth = tileWidth; + this.layers[i].baseTileHeight = tileHeight; var mapData = this.layers[i].data; var mapWidth = this.layers[i].width; var mapHeight = this.layers[i].height; - for (var row = 0; row < mapHeight; ++row) + for (var row = 0; row < mapHeight; row++) { - for (var col = 0; col < mapWidth; ++col) + for (var col = 0; col < mapWidth; col++) { var tile = mapData[row][col]; @@ -1963,13 +2014,16 @@ var Tilemap = new Class({ var mapWidth = layer.width; var mapHeight = layer.height; - for (var row = 0; row < mapHeight; ++row) + for (var row = 0; row < mapHeight; row++) { - for (var col = 0; col < mapWidth; ++col) + for (var col = 0; col < mapWidth; col++) { var tile = mapData[row][col]; - if (tile !== null) { tile.setSize(tileWidth, tileHeight); } + if (tile !== null) + { + tile.setSize(tileWidth, tileHeight); + } } } @@ -1988,11 +2042,11 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#shuffle * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -2023,11 +2077,11 @@ var Tilemap = new Class({ * * @param {integer} tileA - First tile index. * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -2054,9 +2108,9 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#tileToWorldX * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?number} Returns a number, or null if the layer given was invalid. */ @@ -2078,9 +2132,10 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#tileToWorldY * @since 3.0.0 * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer + * to use. If not given the current layer is used. * * @return {?number} Returns a number, or null if the layer given was invalid. */ @@ -2103,11 +2158,11 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#tileToWorldXY * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. */ @@ -2141,14 +2196,14 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#weightedRandomize * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during * randomization. They should be in the form: { index: 0, weight: 4 } or * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Tilemaps.Tilemap} Return this Tilemap object, or null if the layer given was invalid. */ @@ -2175,11 +2230,11 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#worldToTileX * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer + * to use. If not given the current layer is used. * * @return {?number} Returns a number, or null if the layer given was invalid. */ @@ -2201,11 +2256,10 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#worldToTileY * @since 3.0.0 * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?number} Returns a number, or null if the layer given was invalid. */ @@ -2228,13 +2282,12 @@ var Tilemap = new Class({ * @method Phaser.Tilemaps.Tilemap#worldToTileXY * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] - * @param {Phaser.Tilemaps.LayerData} [layer] - [description] + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. + * @param {(string|integer|Phaser.Tilemaps.DynamicTilemapLayer|Phaser.Tilemaps.StaticTilemapLayer)} [layer] - The tile layer to use. If not given the current layer is used. * * @return {?Phaser.Math.Vector2} Returns a point, or null if the layer given was invalid. */ diff --git a/src/tilemaps/Tileset.js b/src/tilemaps/Tileset.js index c58041339..a3db0ca1a 100644 --- a/src/tilemaps/Tileset.js +++ b/src/tilemaps/Tileset.js @@ -12,7 +12,7 @@ var Class = require('../utils/Class'); * each tile. * * @class Tileset - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -63,7 +63,7 @@ var Tileset = new Class({ * * @name Phaser.Tilemaps.Tileset#tileWidth * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.tileWidth = tileWidth; @@ -73,7 +73,7 @@ var Tileset = new Class({ * * @name Phaser.Tilemaps.Tileset#tileHeight * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.tileHeight = tileHeight; @@ -83,7 +83,7 @@ var Tileset = new Class({ * * @name Phaser.Tilemaps.Tileset#tileMargin * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.tileMargin = tileMargin; @@ -93,7 +93,7 @@ var Tileset = new Class({ * * @name Phaser.Tilemaps.Tileset#tileSpacing * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.tileSpacing = tileSpacing; @@ -123,17 +123,27 @@ var Tileset = new Class({ * * @name Phaser.Tilemaps.Tileset#image * @type {?Phaser.Textures.Texture} - * @readOnly + * @readonly * @since 3.0.0 */ this.image = null; + /** + * The gl texture used by the WebGL renderer. + * + * @name Phaser.Tilemaps.Tileset#glTexture + * @type {?WebGLTexture} + * @readonly + * @since 3.11.0 + */ + this.glTexture = null; + /** * The number of tile rows in the the tileset. * * @name Phaser.Tilemaps.Tileset#rows * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.rows = 0; @@ -143,7 +153,7 @@ var Tileset = new Class({ * * @name Phaser.Tilemaps.Tileset#columns * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.columns = 0; @@ -153,7 +163,7 @@ var Tileset = new Class({ * * @name Phaser.Tilemaps.Tileset#total * @type {integer} - * @readOnly + * @readonly * @since 3.0.0 */ this.total = 0; @@ -164,7 +174,7 @@ var Tileset = new Class({ * * @name Phaser.Tilemaps.Tileset#texCoordinates * @type {object[]} - * @readOnly + * @readonly * @since 3.0.0 */ this.texCoordinates = []; @@ -276,6 +286,8 @@ var Tileset = new Class({ { this.image = texture; + this.glTexture = texture.get().source.glTexture; + this.updateTileData(this.image.source[0].width, this.image.source[0].height); return this; @@ -347,7 +359,7 @@ var Tileset = new Class({ if (rowCount % 1 !== 0 || colCount % 1 !== 0) { - console.warn('Tileset ' + this.name + ' image tile area is not an even multiple of tile size'); + console.warn('Image tile area not tile size multiple in: ' + this.name); } // In Tiled a tileset image that is not an even multiple of the tile dimensions is truncated diff --git a/src/tilemaps/components/CalculateFacesWithin.js b/src/tilemaps/components/CalculateFacesWithin.js index 3e4ab49aa..870fd4148 100644 --- a/src/tilemaps/components/CalculateFacesWithin.js +++ b/src/tilemaps/components/CalculateFacesWithin.js @@ -16,10 +16,10 @@ var GetTilesWithin = require('./GetTilesWithin'); * @private * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var CalculateFacesWithin = function (tileX, tileY, width, height, layer) diff --git a/src/tilemaps/components/Copy.js b/src/tilemaps/components/Copy.js index 19181e43e..a45939ad8 100644 --- a/src/tilemaps/components/Copy.js +++ b/src/tilemaps/components/Copy.js @@ -16,13 +16,13 @@ var CalculateFacesWithin = require('./CalculateFacesWithin'); * @private * @since 3.0.0 * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var Copy = function (srcTileX, srcTileY, width, height, destTileX, destTileY, recalculateFaces, layer) diff --git a/src/tilemaps/components/CreateFromTiles.js b/src/tilemaps/components/CreateFromTiles.js index bffb881b5..a40aedb8d 100644 --- a/src/tilemaps/components/CreateFromTiles.js +++ b/src/tilemaps/components/CreateFromTiles.js @@ -20,11 +20,8 @@ var ReplaceByIndex = require('./ReplaceByIndex'); * @since 3.0.0 * * @param {(integer|array)} indexes - The tile index, or array of indexes, to create Sprites from. - * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted - * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a - * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). + * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a one-to-one mapping with the indexes array. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. scene.make.sprite). * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. diff --git a/src/tilemaps/components/CullTiles.js b/src/tilemaps/components/CullTiles.js index 6ec3bc118..96455091b 100644 --- a/src/tilemaps/components/CullTiles.js +++ b/src/tilemaps/components/CullTiles.js @@ -4,9 +4,11 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +var SnapFloor = require('../../math/snap/SnapFloor'); +var SnapCeil = require('../../math/snap/SnapCeil'); + /** - * Returns the tiles in the given layer that are within the camera's viewport. This is used - * internally. + * Returns the tiles in the given layer that are within the camera's viewport. This is used internally. * * @function Phaser.Tilemaps.Components.CullTiles * @private @@ -14,111 +16,134 @@ * * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * @param {Phaser.Cameras.Scene2D.Camera} [camera] - The Camera to run the cull check against. - * @param {array} [outputArray] - [description] + * @param {array} [outputArray] - An optional array to store the Tile objects within. * * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. */ -var CullTiles = function (layer, camera, outputArray) +var CullTiles = function (layer, camera, outputArray, renderOrder) { if (outputArray === undefined) { outputArray = []; } + if (renderOrder === undefined) { renderOrder = 0; } outputArray.length = 0; - - var zoom = camera.zoom; - var originX = camera.width / 2; - var originY = camera.height / 2; - - camera.matrix.loadIdentity(); - camera.matrix.translate(camera.x + originX, camera.y + originY); - camera.matrix.rotate(camera.rotation); - camera.matrix.scale(zoom, zoom); - camera.matrix.translate(-originX, -originY); - camera.matrix.invert(); - - camera.shakeEffect.preRender(); + var tilemap = layer.tilemapLayer.tilemap; var tilemapLayer = layer.tilemapLayer; - var tileW = layer.tileWidth; - var tileH = layer.tileHeight; - var cullX = ((camera.scrollX * tilemapLayer.scrollFactorX) - tileW); - var cullY = ((camera.scrollY * tilemapLayer.scrollFactorY) - tileH); - var cullW = (cullX + (camera.width + tileW * 2)); - var cullH = (cullY + (camera.height + tileH * 2)); + var mapData = layer.data; var mapWidth = layer.width; var mapHeight = layer.height; - var cameraMatrix = camera.matrix.matrix; - var a = cameraMatrix[0]; - var b = cameraMatrix[1]; - var c = cameraMatrix[2]; - var d = cameraMatrix[3]; - var e = cameraMatrix[4]; - var f = cameraMatrix[5]; - var tCullX = cullX * a + cullY * c + e; - var tCullY = cullX * b + cullY * d + f; - var tCullW = cullW * a + cullH * c + e; - var tCullH = cullW * b + cullH * d + f; - for (var y = 0; y < mapHeight; ++y) + // We need to use the tile sizes defined for the map as a whole, not the layer, + // in order to calculate the bounds correctly. As different sized tiles may be + // placed on the grid and we cannot trust layer.baseTileWidth to give us the true size. + var tileW = Math.floor(tilemap.tileWidth * tilemapLayer.scaleX); + var tileH = Math.floor(tilemap.tileHeight * tilemapLayer.scaleY); + + var drawLeft = 0; + var drawRight = mapWidth; + var drawTop = 0; + var drawBottom = mapHeight; + + if (!tilemapLayer.skipCull && tilemapLayer.scrollFactorX === 1 && tilemapLayer.scrollFactorY === 1) { - for (var x = 0; x < mapWidth; ++x) + // Camera world view bounds, snapped for scaled tile size + // Cull Padding values are given in tiles, not pixels + + var boundsLeft = SnapFloor(camera.worldView.x - tilemapLayer.x, tileW, 0, true) - tilemapLayer.cullPaddingX; + var boundsRight = SnapCeil(camera.worldView.right - tilemapLayer.x, tileW, 0, true) + tilemapLayer.cullPaddingX; + var boundsTop = SnapFloor(camera.worldView.y - tilemapLayer.y, tileH, 0, true) - tilemapLayer.cullPaddingY; + var boundsBottom = SnapCeil(camera.worldView.bottom - tilemapLayer.y, tileH, 0, true) + tilemapLayer.cullPaddingY; + + drawLeft = Math.max(0, boundsLeft); + drawRight = Math.min(mapWidth, boundsRight); + drawTop = Math.max(0, boundsTop); + drawBottom = Math.min(mapHeight, boundsBottom); + } + + var x; + var y; + var tile; + + if (renderOrder === 0) + { + // right-down + + for (y = drawTop; y < drawBottom; y++) { - var tile = mapData[y][x]; - - if (tile === null || tile.index === -1) + for (x = drawLeft; mapData[y] && x < drawRight; x++) { - continue; + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); } + } + } + else if (renderOrder === 1) + { + // left-down - var tilePixelX = (tile.pixelX + tilemapLayer.x); - var tilePixelY = (tile.pixelY + tilemapLayer.y); - var tileX = (tilePixelX * a + tilePixelY * c + e); - var tileY = (tilePixelX * b + tilePixelY * d + f); - - if (tile.visible && - tileX >= tCullX && - tileY >= tCullY && - tileX + tileW <= tCullW && - tileY + tileH <= tCullH - ) + for (y = drawTop; y < drawBottom; y++) + { + for (x = drawRight; mapData[y] && x >= drawLeft; x--) { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 2) + { + // right-up + + for (y = drawBottom; y >= drawTop; y--) + { + for (x = drawLeft; mapData[y] && x < drawRight; x++) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + + outputArray.push(tile); + } + } + } + else if (renderOrder === 3) + { + // left-up + + for (y = drawBottom; y >= drawTop; y--) + { + for (x = drawRight; mapData[y] && x >= drawLeft; x--) + { + tile = mapData[y][x]; + + if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0) + { + continue; + } + outputArray.push(tile); } } } - /* var tilemapLayer = layer.tilemapLayer; - var mapData = layer.data; - var mapWidth = layer.width; - var mapHeight = layer.height; - var left = (camera.scrollX * camera.zoom * tilemapLayer.scrollFactorX) - tilemapLayer.x; - var top = (camera.scrollY * camera.zoom * tilemapLayer.scrollFactorY) - tilemapLayer.y; - var sx = tilemapLayer.scaleX; - var sy = tilemapLayer.scaleY; - var tileWidth = layer.tileWidth * sx; - var tileHeight = layer.tileHeight * sy; - - for (var row = 0; row < mapHeight; ++row) - { - for (var col = 0; col < mapWidth; ++col) - { - var tile = mapData[row][col]; - - if (tile === null || tile.index === -1) { continue; } - - var tileX = tile.pixelX * sx - left; - var tileY = tile.pixelY * sy - top; - var cullW = camera.width + tileWidth; - var cullH = camera.height + tileHeight; - - if (tile.visible && - tileX > -tileWidth && tileY > -tileHeight && - tileX < cullW && tileY < cullH) - { - outputArray.push(tile); - } - } - } */ + tilemapLayer.tilesDrawn = outputArray.length; + tilemapLayer.tilesTotal = mapWidth * mapHeight; return outputArray; }; diff --git a/src/tilemaps/components/Fill.js b/src/tilemaps/components/Fill.js index 4bca073d1..e4b7505be 100644 --- a/src/tilemaps/components/Fill.js +++ b/src/tilemaps/components/Fill.js @@ -17,21 +17,20 @@ var SetTileCollision = require('./SetTileCollision'); * @private * @since 3.0.0 * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. + * @param {integer} index - The tile index to fill the area with. + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} recalculateFaces - `true` if the faces data should be recalculated. + * @param {Phaser.Tilemaps.LayerData} layer - The tile layer to use. If not given the current layer is used. */ var Fill = function (index, tileX, tileY, width, height, recalculateFaces, layer) { - if (recalculateFaces === undefined) { recalculateFaces = true; } - var doesIndexCollide = (layer.collideIndexes.indexOf(index) !== -1); var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) { tiles[i].index = index; diff --git a/src/tilemaps/components/FilterTiles.js b/src/tilemaps/components/FilterTiles.js index df2d067f4..58580ff66 100644 --- a/src/tilemaps/components/FilterTiles.js +++ b/src/tilemaps/components/FilterTiles.js @@ -19,17 +19,14 @@ var GetTilesWithin = require('./GetTilesWithin'); * callback as the first and only parameter. The callback should return true for tiles that pass the * filter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Tilemaps.Tile[]} The filtered array of Tiles. @@ -37,6 +34,7 @@ var GetTilesWithin = require('./GetTilesWithin'); var FilterTiles = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) { var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + return tiles.filter(callback, context); }; diff --git a/src/tilemaps/components/FindTile.js b/src/tilemaps/components/FindTile.js index 486d35ebe..6933647c1 100644 --- a/src/tilemaps/components/FindTile.js +++ b/src/tilemaps/components/FindTile.js @@ -9,11 +9,11 @@ var GetTilesWithin = require('./GetTilesWithin'); /** * @callback FindTileCallback * - * @param {Phaser.Tilemaps.Tile} value - [description] - * @param {number} index - [description] - * @param {Phaser.Tilemaps.Tile[]} array - [description] + * @param {Phaser.Tilemaps.Tile} value - The Tile. + * @param {integer} index - The index of the tile. + * @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects. * - * @return {boolean} [description] + * @return {boolean} Return `true` if the callback should run, otherwise `false`. */ /** @@ -25,20 +25,16 @@ var GetTilesWithin = require('./GetTilesWithin'); * @private * @since 3.0.0 * - * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {?Phaser.Tilemaps.Tile} A Tile that matches the search, or null if no Tile found diff --git a/src/tilemaps/components/ForEachTile.js b/src/tilemaps/components/ForEachTile.js index de06ca086..2d5ae1293 100644 --- a/src/tilemaps/components/ForEachTile.js +++ b/src/tilemaps/components/ForEachTile.js @@ -9,9 +9,9 @@ var GetTilesWithin = require('./GetTilesWithin'); /** * @callback EachTileCallback * - * @param {Phaser.Tilemaps.Tile} value - [description] - * @param {number} index - [description] - * @param {Phaser.Tilemaps.Tile[]} array - [description] + * @param {Phaser.Tilemaps.Tile} value - The Tile. + * @param {integer} index - The index of the tile. + * @param {Phaser.Tilemaps.Tile[]} array - An array of Tile objects. */ /** @@ -22,25 +22,22 @@ var GetTilesWithin = require('./GetTilesWithin'); * @private * @since 3.0.0 * - * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var ForEachTile = function (callback, context, tileX, tileY, width, height, filteringOptions, layer) { var tiles = GetTilesWithin(tileX, tileY, width, height, filteringOptions, layer); + tiles.forEach(callback, context); }; diff --git a/src/tilemaps/components/GetTileAt.js b/src/tilemaps/components/GetTileAt.js index fc2454f3f..d23c6f783 100644 --- a/src/tilemaps/components/GetTileAt.js +++ b/src/tilemaps/components/GetTileAt.js @@ -15,8 +15,7 @@ var IsInLayerBounds = require('./IsInLayerBounds'); * * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates @@ -28,7 +27,7 @@ var GetTileAt = function (tileX, tileY, nonNull, layer) if (IsInLayerBounds(tileX, tileY, layer)) { - var tile = layer.data[tileY][tileX]; + var tile = layer.data[tileY][tileX] || null; if (tile === null) { return null; diff --git a/src/tilemaps/components/GetTileAtWorldXY.js b/src/tilemaps/components/GetTileAtWorldXY.js index da53b9124..30d2c719b 100644 --- a/src/tilemaps/components/GetTileAtWorldXY.js +++ b/src/tilemaps/components/GetTileAtWorldXY.js @@ -17,9 +17,8 @@ var WorldToTileY = require('./WorldToTileY'); * * @param {number} worldX - X position to get the tile from (given in pixels) * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates diff --git a/src/tilemaps/components/GetTilesWithin.js b/src/tilemaps/components/GetTilesWithin.js index f5f2c94c7..f3464a900 100644 --- a/src/tilemaps/components/GetTilesWithin.js +++ b/src/tilemaps/components/GetTilesWithin.js @@ -21,10 +21,10 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * @private * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] + * @param {integer} tileX - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. * @param {object} GetTilesWithinFilteringOptions - Optional filters to apply when getting the tiles. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * diff --git a/src/tilemaps/components/GetTilesWithinShape.js b/src/tilemaps/components/GetTilesWithinShape.js index ed13a562e..30f20777b 100644 --- a/src/tilemaps/components/GetTilesWithinShape.js +++ b/src/tilemaps/components/GetTilesWithinShape.js @@ -31,13 +31,10 @@ var TriangleToRectangle = function (triangle, rect) * * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. diff --git a/src/tilemaps/components/GetTilesWithinWorldXY.js b/src/tilemaps/components/GetTilesWithinWorldXY.js index f5822e177..2b66b9ca6 100644 --- a/src/tilemaps/components/GetTilesWithinWorldXY.js +++ b/src/tilemaps/components/GetTilesWithinWorldXY.js @@ -15,18 +15,15 @@ var WorldToTileY = require('./WorldToTileY'); * @private * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Tilemaps.Tile[]} Array of Tile objects. diff --git a/src/tilemaps/components/HasTileAt.js b/src/tilemaps/components/HasTileAt.js index b34960f0d..37fb5fc48 100644 --- a/src/tilemaps/components/HasTileAt.js +++ b/src/tilemaps/components/HasTileAt.js @@ -14,11 +14,11 @@ var IsInLayerBounds = require('./IsInLayerBounds'); * @private * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] + * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). + * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * - * @return {boolean} + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. */ var HasTileAt = function (tileX, tileY, layer) { diff --git a/src/tilemaps/components/HasTileAtWorldXY.js b/src/tilemaps/components/HasTileAtWorldXY.js index 7455a41cf..746b9a1da 100644 --- a/src/tilemaps/components/HasTileAtWorldXY.js +++ b/src/tilemaps/components/HasTileAtWorldXY.js @@ -16,12 +16,12 @@ var WorldToTileY = require('./WorldToTileY'); * @private * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The X coordinate of the world position. + * @param {number} worldY - The Y coordinate of the world position. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * - * @return {boolean} + * @return {?boolean} Returns a boolean, or null if the layer given was invalid. */ var HasTileAtWorldXY = function (worldX, worldY, camera, layer) { diff --git a/src/tilemaps/components/IsInLayerBounds.js b/src/tilemaps/components/IsInLayerBounds.js index 881a5eb92..1fe71cc08 100644 --- a/src/tilemaps/components/IsInLayerBounds.js +++ b/src/tilemaps/components/IsInLayerBounds.js @@ -11,11 +11,11 @@ * @private * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * - * @return {boolean} + * @return {boolean} `true` if the tile coordinates are within the bounds of the layer, otherwise `false`. */ var IsInLayerBounds = function (tileX, tileY, layer) { diff --git a/src/tilemaps/components/PutTileAt.js b/src/tilemaps/components/PutTileAt.js index 899c82a91..c72627e1f 100644 --- a/src/tilemaps/components/PutTileAt.js +++ b/src/tilemaps/components/PutTileAt.js @@ -20,9 +20,9 @@ var SetTileCollision = require('./SetTileCollision'); * @since 3.0.0 * * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. diff --git a/src/tilemaps/components/PutTileAtWorldXY.js b/src/tilemaps/components/PutTileAtWorldXY.js index d7eb8d1d4..1ed6737d9 100644 --- a/src/tilemaps/components/PutTileAtWorldXY.js +++ b/src/tilemaps/components/PutTileAtWorldXY.js @@ -19,10 +19,10 @@ var WorldToTileY = require('./WorldToTileY'); * @since 3.0.0 * * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Tilemaps.Tile} The Tile object that was created or added to this map. diff --git a/src/tilemaps/components/PutTilesAt.js b/src/tilemaps/components/PutTilesAt.js index c55a2d711..66dcd1012 100644 --- a/src/tilemaps/components/PutTilesAt.js +++ b/src/tilemaps/components/PutTilesAt.js @@ -18,11 +18,10 @@ var PutTileAt = require('./PutTileAt'); * @private * @since 3.0.0 * - * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var PutTilesAt = function (tilesArray, tileX, tileY, recalculateFaces, layer) diff --git a/src/tilemaps/components/Randomize.js b/src/tilemaps/components/Randomize.js index a6c590116..8b070623b 100644 --- a/src/tilemaps/components/Randomize.js +++ b/src/tilemaps/components/Randomize.js @@ -18,10 +18,10 @@ var GetRandom = require('../../utils/array/GetRandom'); * @private * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ diff --git a/src/tilemaps/components/RemoveTileAt.js b/src/tilemaps/components/RemoveTileAt.js index 5d66544a4..ff2194f07 100644 --- a/src/tilemaps/components/RemoveTileAt.js +++ b/src/tilemaps/components/RemoveTileAt.js @@ -16,12 +16,10 @@ var CalculateFacesAt = require('./CalculateFacesAt'); * @private * @since 3.0.0 * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] + * @param {integer} tileX - The x coordinate. + * @param {integer} tileY - The y coordinate. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. @@ -32,7 +30,7 @@ var RemoveTileAt = function (tileX, tileY, replaceWithNull, recalculateFaces, la if (recalculateFaces === undefined) { recalculateFaces = true; } if (!IsInLayerBounds(tileX, tileY, layer)) { return null; } - var tile = layer.data[tileY][tileX]; + var tile = layer.data[tileY][tileX] || null; if (tile === null) { return null; diff --git a/src/tilemaps/components/RemoveTileAtWorldXY.js b/src/tilemaps/components/RemoveTileAtWorldXY.js index dd75e2076..00a9ec294 100644 --- a/src/tilemaps/components/RemoveTileAtWorldXY.js +++ b/src/tilemaps/components/RemoveTileAtWorldXY.js @@ -16,13 +16,11 @@ var WorldToTileY = require('./WorldToTileY'); * @private * @since 3.0.0 * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Tilemaps.Tile} The Tile object that was removed. diff --git a/src/tilemaps/components/RenderDebug.js b/src/tilemaps/components/RenderDebug.js index fa9ba7f06..a12ec9198 100644 --- a/src/tilemaps/components/RenderDebug.js +++ b/src/tilemaps/components/RenderDebug.js @@ -7,6 +7,10 @@ var GetTilesWithin = require('./GetTilesWithin'); var Color = require('../../display/color'); +var defaultTileColor = new Color(105, 210, 231, 150); +var defaultCollidingTileColor = new Color(243, 134, 48, 200); +var defaultFaceColor = new Color(40, 39, 37, 150); + /** * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to * get a quick idea of which of your tiles are colliding and which have interesting faces. The tiles @@ -32,18 +36,15 @@ var RenderDebug = function (graphics, styleConfig, layer) if (styleConfig === undefined) { styleConfig = {}; } // Default colors without needlessly creating Color objects - var tileColor = styleConfig.tileColor !== undefined - ? styleConfig.tileColor - : new Color(105, 210, 231, 150); - var collidingTileColor = styleConfig.collidingTileColor !== undefined - ? styleConfig.collidingTileColor - : new Color(243, 134, 48, 200); - var faceColor = styleConfig.faceColor !== undefined - ? styleConfig.faceColor - : new Color(40, 39, 37, 150); + var tileColor = (styleConfig.tileColor !== undefined) ? styleConfig.tileColor : defaultTileColor; + var collidingTileColor = (styleConfig.collidingTileColor !== undefined) ? styleConfig.collidingTileColor : defaultCollidingTileColor; + var faceColor = (styleConfig.faceColor !== undefined) ? styleConfig.faceColor : defaultFaceColor; var tiles = GetTilesWithin(0, 0, layer.width, layer.height, null, layer); + graphics.translate(layer.tilemapLayer.x, layer.tilemapLayer.y); + graphics.scale(layer.tilemapLayer.scaleX, layer.tilemapLayer.scaleY); + for (var i = 0; i < tiles.length; i++) { var tile = tiles[i]; @@ -54,6 +55,7 @@ var RenderDebug = function (graphics, styleConfig, layer) var y = tile.pixelY; var color = tile.collides ? collidingTileColor : tileColor; + if (color !== null) { graphics.fillStyle(color.color, color.alpha / 255); @@ -69,6 +71,7 @@ var RenderDebug = function (graphics, styleConfig, layer) if (faceColor !== null) { graphics.lineStyle(1, faceColor.color, faceColor.alpha / 255); + if (tile.faceTop) { graphics.lineBetween(x, y, x + tw, y); } if (tile.faceRight) { graphics.lineBetween(x + tw, y, x + tw, y + th); } if (tile.faceBottom) { graphics.lineBetween(x, y + th, x + tw, y + th); } diff --git a/src/tilemaps/components/ReplaceByIndex.js b/src/tilemaps/components/ReplaceByIndex.js index 4327f8644..eaf912d32 100644 --- a/src/tilemaps/components/ReplaceByIndex.js +++ b/src/tilemaps/components/ReplaceByIndex.js @@ -15,17 +15,18 @@ var GetTilesWithin = require('./GetTilesWithin'); * @private * @since 3.0.0 * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var ReplaceByIndex = function (findIndex, newIndex, tileX, tileY, width, height, layer) { var tiles = GetTilesWithin(tileX, tileY, width, height, null, layer); + for (var i = 0; i < tiles.length; i++) { if (tiles[i] && tiles[i].index === findIndex) diff --git a/src/tilemaps/components/SetCollision.js b/src/tilemaps/components/SetCollision.js index b3111cb2d..0d46d4a2d 100644 --- a/src/tilemaps/components/SetCollision.js +++ b/src/tilemaps/components/SetCollision.js @@ -18,10 +18,8 @@ var SetLayerCollisionIndex = require('./SetLayerCollisionIndex'); * @since 3.0.0 * * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var SetCollision = function (indexes, collides, recalculateFaces, layer) @@ -50,7 +48,10 @@ var SetCollision = function (indexes, collides, recalculateFaces, layer) } } - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } }; module.exports = SetCollision; diff --git a/src/tilemaps/components/SetCollisionBetween.js b/src/tilemaps/components/SetCollisionBetween.js index 27b058482..20ff01b6c 100644 --- a/src/tilemaps/components/SetCollisionBetween.js +++ b/src/tilemaps/components/SetCollisionBetween.js @@ -20,10 +20,8 @@ var SetLayerCollisionIndex = require('./SetLayerCollisionIndex'); * * @param {integer} start - The first index of the tile to be set for collision. * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var SetCollisionBetween = function (start, stop, collides, recalculateFaces, layer) @@ -55,7 +53,10 @@ var SetCollisionBetween = function (start, stop, collides, recalculateFaces, lay } } - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } }; module.exports = SetCollisionBetween; diff --git a/src/tilemaps/components/SetCollisionByExclusion.js b/src/tilemaps/components/SetCollisionByExclusion.js index e917597f0..cb0927013 100644 --- a/src/tilemaps/components/SetCollisionByExclusion.js +++ b/src/tilemaps/components/SetCollisionByExclusion.js @@ -18,10 +18,8 @@ var SetLayerCollisionIndex = require('./SetLayerCollisionIndex'); * @since 3.0.0 * * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, layer) @@ -44,7 +42,10 @@ var SetCollisionByExclusion = function (indexes, collides, recalculateFaces, lay } } - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } }; module.exports = SetCollisionByExclusion; diff --git a/src/tilemaps/components/SetCollisionByProperty.js b/src/tilemaps/components/SetCollisionByProperty.js index 204118590..47b726440 100644 --- a/src/tilemaps/components/SetCollisionByProperty.js +++ b/src/tilemaps/components/SetCollisionByProperty.js @@ -21,12 +21,9 @@ var HasValue = require('../../utils/object/HasValue'); * @private * @since 3.0.0 * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {object} properties - An object with tile properties and corresponding values that should be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var SetCollisionByProperty = function (properties, collides, recalculateFaces, layer) @@ -63,7 +60,10 @@ var SetCollisionByProperty = function (properties, collides, recalculateFaces, l } } - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } }; module.exports = SetCollisionByProperty; diff --git a/src/tilemaps/components/SetCollisionFromCollisionGroup.js b/src/tilemaps/components/SetCollisionFromCollisionGroup.js index 0c0ef986e..951f82b39 100644 --- a/src/tilemaps/components/SetCollisionFromCollisionGroup.js +++ b/src/tilemaps/components/SetCollisionFromCollisionGroup.js @@ -17,10 +17,8 @@ var CalculateFacesWithin = require('./CalculateFacesWithin'); * @private * @since 3.0.0 * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer) @@ -47,7 +45,10 @@ var SetCollisionFromCollisionGroup = function (collides, recalculateFaces, layer } } - if (recalculateFaces) { CalculateFacesWithin(0, 0, layer.width, layer.height, layer); } + if (recalculateFaces) + { + CalculateFacesWithin(0, 0, layer.width, layer.height, layer); + } }; module.exports = SetCollisionFromCollisionGroup; diff --git a/src/tilemaps/components/SetLayerCollisionIndex.js b/src/tilemaps/components/SetLayerCollisionIndex.js index 78891e0ff..b399f1c87 100644 --- a/src/tilemaps/components/SetLayerCollisionIndex.js +++ b/src/tilemaps/components/SetLayerCollisionIndex.js @@ -12,8 +12,8 @@ * @private * @since 3.0.0 * - * @param {integer} tileIndex - [description] - * @param {boolean} [collides=true] - [description] + * @param {integer} tileIndex - The tile index to set the collision boolean for. + * @param {boolean} [collides=true] - Should the tile index collide or not? * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var SetLayerCollisionIndex = function (tileIndex, collides, layer) diff --git a/src/tilemaps/components/SetTileCollision.js b/src/tilemaps/components/SetTileCollision.js index 876c74a9b..23413ce51 100644 --- a/src/tilemaps/components/SetTileCollision.js +++ b/src/tilemaps/components/SetTileCollision.js @@ -12,8 +12,8 @@ * @private * @since 3.0.0 * - * @param {Phaser.Tilemaps.Tile} tile - [description] - * @param {boolean} [collides=true] - [description] + * @param {Phaser.Tilemaps.Tile} tile - The Tile to set the collision on. + * @param {boolean} [collides=true] - Should the tile index collide or not? */ var SetTileCollision = function (tile, collides) { diff --git a/src/tilemaps/components/SetTileIndexCallback.js b/src/tilemaps/components/SetTileIndexCallback.js index 94ca43b03..5bddeba39 100644 --- a/src/tilemaps/components/SetTileIndexCallback.js +++ b/src/tilemaps/components/SetTileIndexCallback.js @@ -14,8 +14,7 @@ * @private * @since 3.0.0 * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for. * @param {function} callback - The callback that will be invoked when the tile is collided with. * @param {object} callbackContext - The context under which the callback is called. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. diff --git a/src/tilemaps/components/SetTileLocationCallback.js b/src/tilemaps/components/SetTileLocationCallback.js index ff6c11004..4614811d6 100644 --- a/src/tilemaps/components/SetTileLocationCallback.js +++ b/src/tilemaps/components/SetTileLocationCallback.js @@ -15,10 +15,10 @@ var GetTilesWithin = require('./GetTilesWithin'); * @private * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {function} callback - The callback that will be invoked when the tile is collided with. * @param {object} callbackContext - The context under which the callback is called. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. diff --git a/src/tilemaps/components/Shuffle.js b/src/tilemaps/components/Shuffle.js index bea02e761..a53db8296 100644 --- a/src/tilemaps/components/Shuffle.js +++ b/src/tilemaps/components/Shuffle.js @@ -17,10 +17,10 @@ var ShuffleArray = require('../../utils/array/Shuffle'); * @private * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var Shuffle = function (tileX, tileY, width, height, layer) diff --git a/src/tilemaps/components/SwapByIndex.js b/src/tilemaps/components/SwapByIndex.js index 3b780888d..9dd6ffeb7 100644 --- a/src/tilemaps/components/SwapByIndex.js +++ b/src/tilemaps/components/SwapByIndex.js @@ -17,10 +17,10 @@ var GetTilesWithin = require('./GetTilesWithin'); * * @param {integer} tileA - First tile index. * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. */ var SwapByIndex = function (indexA, indexB, tileX, tileY, width, height, layer) diff --git a/src/tilemaps/components/TileToWorldX.js b/src/tilemaps/components/TileToWorldX.js index 48047ff86..4ad6210d2 100644 --- a/src/tilemaps/components/TileToWorldX.js +++ b/src/tilemaps/components/TileToWorldX.js @@ -12,8 +12,8 @@ * @private * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {number} diff --git a/src/tilemaps/components/TileToWorldXY.js b/src/tilemaps/components/TileToWorldXY.js index 9416b4e79..d04e55074 100644 --- a/src/tilemaps/components/TileToWorldXY.js +++ b/src/tilemaps/components/TileToWorldXY.js @@ -17,10 +17,10 @@ var Vector2 = require('../../math/Vector2'); * @private * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Math.Vector2} The XY location in world coordinates. diff --git a/src/tilemaps/components/TileToWorldY.js b/src/tilemaps/components/TileToWorldY.js index dacc57501..4dd833ef9 100644 --- a/src/tilemaps/components/TileToWorldY.js +++ b/src/tilemaps/components/TileToWorldY.js @@ -12,8 +12,8 @@ * @private * @since 3.0.0 * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {integer} tileY - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {number} diff --git a/src/tilemaps/components/WeightedRandomize.js b/src/tilemaps/components/WeightedRandomize.js index 1b63d8de7..766fce487 100644 --- a/src/tilemaps/components/WeightedRandomize.js +++ b/src/tilemaps/components/WeightedRandomize.js @@ -25,10 +25,10 @@ var GetTilesWithin = require('./GetTilesWithin'); * @private * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during * randomization. They should be in the form: { index: 0, weight: 4 } or * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. diff --git a/src/tilemaps/components/WorldToTileX.js b/src/tilemaps/components/WorldToTileX.js index 6e111a816..58a588d8d 100644 --- a/src/tilemaps/components/WorldToTileX.js +++ b/src/tilemaps/components/WorldToTileX.js @@ -12,10 +12,9 @@ * @private * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {number} The X location in tile units. diff --git a/src/tilemaps/components/WorldToTileXY.js b/src/tilemaps/components/WorldToTileXY.js index 421e64de8..83e99b638 100644 --- a/src/tilemaps/components/WorldToTileXY.js +++ b/src/tilemaps/components/WorldToTileXY.js @@ -17,12 +17,11 @@ var Vector2 = require('../../math/Vector2'); * @private * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {Phaser.Math.Vector2} The XY location in tile units. diff --git a/src/tilemaps/components/WorldToTileY.js b/src/tilemaps/components/WorldToTileY.js index cfd00fa34..9e3004140 100644 --- a/src/tilemaps/components/WorldToTileY.js +++ b/src/tilemaps/components/WorldToTileY.js @@ -12,10 +12,9 @@ * @private * @since 3.0.0 * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * @param {Phaser.Tilemaps.LayerData} layer - The Tilemap Layer to act upon. * * @return {number} The Y location in tile units. diff --git a/src/tilemaps/dynamiclayer/DynamicTilemapLayer.js b/src/tilemaps/dynamiclayer/DynamicTilemapLayer.js index 5385d455d..dad886933 100644 --- a/src/tilemaps/dynamiclayer/DynamicTilemapLayer.js +++ b/src/tilemaps/dynamiclayer/DynamicTilemapLayer.js @@ -12,17 +12,18 @@ var TilemapComponents = require('../components'); /** * @classdesc - * A DynamicTilemapLayer is a game object that renders LayerData from a Tilemap. A - * DynamicTilemapLayer can only render tiles from a single tileset. + * A Dynamic Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. * - * A DynamicTilemapLayer trades some speed for being able to apply powerful effects. Unlike a - * StaticTilemapLayer, you can apply per-tile effects like tint or alpha, and you can change the - * tiles in a DynamicTilemapLayer. Use this over a StaticTilemapLayer when you need those - * features. + * A Dynamic Tilemap Layer trades some speed for being able to apply powerful effects. Unlike a + * Static Tilemap Layer, you can apply per-tile effects like tint or alpha, and you can change the + * tiles in a DynamicTilemapLayer. + * + * Use this over a Static Tilemap Layer when you need those features. * * @class DynamicTilemapLayer * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -39,10 +40,10 @@ var TilemapComponents = require('../components'); * @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Visible * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. * @param {number} [x=0] - The world x position where the top left of this layer will be placed. * @param {number} [y=0] - The world y position where the top left of this layer will be placed. */ @@ -77,7 +78,7 @@ var DynamicTilemapLayer = new Class({ * * @name Phaser.Tilemaps.DynamicTilemapLayer#isTilemap * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ this.isTilemap = true; @@ -110,16 +111,19 @@ var DynamicTilemapLayer = new Class({ */ this.layer = tilemap.layers[layerIndex]; - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer + // Link the LayerData with this static tilemap layer + this.layer.tilemapLayer = this; /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. * * @name Phaser.Tilemaps.DynamicTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} + * @type {Phaser.Tilemaps.Tileset[]} * @since 3.0.0 */ - this.tileset = tileset; + this.tileset = []; /** * Used internally with the canvas render. This holds the tiles that are visible within the @@ -131,14 +135,211 @@ var DynamicTilemapLayer = new Class({ */ this.culledTiles = []; + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#skipCull + * @type {boolean} + * @since 3.11.0 + */ + this.skipCull = false; + + /** + * The total number of tiles drawn by the renderer in the last frame. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilesDrawn + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.tilesDrawn = 0; + + /** + * The total number of tiles in this layer. Updated every frame. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#tilesTotal + * @type {integer} + * @readonly + * @since 3.11.0 + */ + this.tilesTotal = this.layer.width * this.layer.height; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingX + * @type {integer} + * @default 1 + * @since 3.11.0 + */ + this.cullPaddingX = 1; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullPaddingY + * @type {integer} + * @default 1 + * @since 3.11.0 + */ + this.cullPaddingY = 1; + + /** + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1) The Phaser.Tilemaps.LayerData object for this Layer + * 2) The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3) A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#cullCallback + * @type {function} + * @since 3.11.0 + */ + this.cullCallback = TilemapComponents.CullTiles; + + /** + * The rendering (draw) order of the tiles in this layer. + * + * The default is 0 which is 'right-down', meaning it will draw the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#_renderOrder + * @type {integer} + * @default 0 + * @private + * @since 3.12.0 + */ + this._renderOrder = 0; + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + * + * @name Phaser.Tilemaps.DynamicTilemapLayer#gidMap + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.14.0 + */ + this.gidMap = []; + + this.setTilesets(tileset); this.setAlpha(this.layer.alpha); this.setPosition(x, y); this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + this.setSize(tilemap.tileWidth * this.layer.width, tilemap.tileHeight * this.layer.height); this.initPipeline('TextureTintPipeline'); }, + /** + * Populates the internal `tileset` array with the Tileset references this Layer requires for rendering. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setTilesets + * @private + * @since 3.14.0 + * + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + */ + setTilesets: function (tilesets) + { + var gidMap = []; + var setList = []; + var map = this.tilemap; + + if (!Array.isArray(tilesets)) + { + tilesets = [ tilesets ]; + } + + for (var i = 0; i < tilesets.length; i++) + { + var tileset = tilesets[i]; + + if (typeof tileset === 'string') + { + tileset = map.getTileset(tileset); + } + + if (tileset) + { + setList.push(tileset); + + var s = tileset.firstgid; + + for (var t = 0; t < tileset.total; t++) + { + gidMap[s + t] = tileset; + } + } + } + + this.gidMap = gidMap; + this.tileset = setList; + }, + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap Layer object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'string') + { + renderOrder = orders.indexOf(renderOrder); + } + + if (renderOrder >= 0 && renderOrder < 4) + { + this._renderOrder = renderOrder; + } + + return this; + }, + /** * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting * faces are used internally for optimizing collisions against tiles. This method is mostly used @@ -167,10 +368,10 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#calculateFacesWithin * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -194,7 +395,7 @@ var DynamicTilemapLayer = new Class({ * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. * scene.make.sprite). * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY @@ -219,7 +420,7 @@ var DynamicTilemapLayer = new Class({ */ cull: function (camera) { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); + return this.cullCallback(this.layer, camera, this.culledTiles, this._renderOrder); }, /** @@ -230,13 +431,13 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#copy * @since 3.0.0 * - * @param {integer} srcTileX - [description] - * @param {integer} srcTileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] - * @param {integer} destTileX - [description] - * @param {integer} destTileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] + * @param {integer} srcTileX - The x coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} srcTileY - The y coordinate of the area to copy from, in tiles, not pixels. + * @param {integer} width - The width of the area to copy, in tiles, not pixels. + * @param {integer} height - The height of the area to copy, in tiles, not pixels. + * @param {integer} destTileX - The x coordinate of the area to copy to, in tiles, not pixels. + * @param {integer} destTileY - The y coordinate of the area to copy to, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -263,8 +464,11 @@ var DynamicTilemapLayer = new Class({ this.tilemap = undefined; this.layer = undefined; - this.tileset = undefined; this.culledTiles.length = 0; + this.cullCallback = null; + + this.gidMap = []; + this.tileset = []; GameObject.prototype.destroy.call(this); }, @@ -277,12 +481,12 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#fill * @since 3.0.0 * - * @param {integer} index - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] - * @param {boolean} [recalculateFaces=true] - [description] + * @param {integer} index - The tile index to fill the area with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -305,17 +509,14 @@ var DynamicTilemapLayer = new Class({ * callback as the first and only parameter. The callback should return true for tiles that pass the * filter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. * * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. */ @@ -354,20 +555,16 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#findTile * @since 3.0.0 * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param {FindTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. * * @return {?Phaser.Tilemaps.Tile} */ @@ -383,20 +580,16 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#forEachTile * @since 3.0.0 * - * @param {function} callback - The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param {EachTileCallback} callback - The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area to search. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide - * on at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -415,8 +608,7 @@ var DynamicTilemapLayer = new Class({ * * @param {integer} tileX - X position to get the tile from (given in tile units, not pixels). * @param {integer} tileY - Y position to get the tile from (given in tile units, not pixels). - * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. + * @param {boolean} [nonNull=false] - If true getTile won't return null for empty tiles, but a Tile object with an index of -1. * * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates were invalid. */ @@ -433,9 +625,8 @@ var DynamicTilemapLayer = new Class({ * * @param {number} worldX - X position to get the tile from (given in pixels) * @param {number} worldY - Y position to get the tile from (given in pixels) - * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile object with an index of -1. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates * were invalid. @@ -451,17 +642,14 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithin * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. * * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. */ @@ -479,13 +667,10 @@ var DynamicTilemapLayer = new Class({ * * @param {(Phaser.Geom.Circle|Phaser.Geom.Line|Phaser.Geom.Rectangle|Phaser.Geom.Triangle)} shape - A shape in world (pixel) coordinates * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. * * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. */ @@ -500,18 +685,15 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#getTilesWithinWorldXY * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} worldX - The world x coordinate for the top-left of the area. + * @param {number} worldY - The world y coordinate for the top-left of the area. + * @param {number} width - The width of the area. + * @param {number} height - The height of the area. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. - * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have - * -1 for an index. - * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on - * at least one side. - * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that - * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have -1 for an index. + * @param {boolean} [filteringOptions.isColliding=false] - If true, only return tiles that collide on at least one side. + * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that have at least one interesting face. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. * * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. */ @@ -527,10 +709,10 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAt * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. * - * @return {boolean} + * @return {boolean} `true` if a tile was found at the given location, otherwise `false`. */ hasTileAt: function (tileX, tileY) { @@ -544,11 +726,11 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#hasTileAtWorldXY * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. * - * @return {boolean} + * @return {boolean} `true` if a tile was found at the given location, otherwise `false`. */ hasTileAtWorldXY: function (worldX, worldY, camera) { @@ -565,9 +747,9 @@ var DynamicTilemapLayer = new Class({ * @since 3.0.0 * * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * * @return {Phaser.Tilemaps.Tile} A Tile object. */ @@ -586,10 +768,10 @@ var DynamicTilemapLayer = new Class({ * @since 3.0.0 * * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} worldX - [description] - * @param {integer} worldY - [description] - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera] - [description] + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {Phaser.Tilemaps.Tile} A Tile object. */ @@ -608,11 +790,10 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#putTilesAt * @since 3.0.0 * - * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [recalculateFaces=true] - [description] + * @param {(integer[]|integer[][]|Phaser.Tilemaps.Tile[]|Phaser.Tilemaps.Tile[][])} tile - A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -633,10 +814,10 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#randomize * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {integer[]} [indexes] - An array of indexes to randomly draw from during randomization. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. @@ -655,12 +836,10 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAt * @since 3.0.0 * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. * * @return {Phaser.Tilemaps.Tile} A Tile object. */ @@ -676,13 +855,11 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#removeTileAtWorldXY * @since 3.0.0 * - * @param {(integer|Phaser.Tilemaps.Tile)} tile - The index of this tile to set or a Tile object. - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. - * @param {boolean} [recalculateFaces=true] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The x coordinate, in pixels. + * @param {number} worldY - The y coordinate, in pixels. + * @param {boolean} [replaceWithNull=true] - If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. + * @param {boolean} [recalculateFaces=true] - `true` if the faces data should be recalculated. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {Phaser.Tilemaps.Tile} A Tile object. */ @@ -726,12 +903,12 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#replaceByIndex * @since 3.0.0 * - * @param {integer} findIndex - [description] - * @param {integer} newIndex - [description] - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} findIndex - The index of the tile to search for. + * @param {integer} newIndex - The index of the tile to replace it with. + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -742,6 +919,54 @@ var DynamicTilemapLayer = new Class({ return this; }, + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setSkipCull + * @since 3.11.0 + * + * @param {boolean} [value=true] - Set to `true` to stop culling tiles. Set to `false` to enable culling again. + * + * @return {this} This Tilemap Layer object. + */ + setSkipCull: function (value) + { + if (value === undefined) { value = true; } + + this.skipCull = value; + + return this; + }, + + /** + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * + * @method Phaser.Tilemaps.DynamicTilemapLayer#setCullPadding + * @since 3.11.0 + * + * @param {integer} [paddingX=1] - The amount of extra horizontal tiles to add to the cull check padding. + * @param {integer} [paddingY=1] - The amount of extra vertical tiles to add to the cull check padding. + * + * @return {this} This Tilemap Layer object. + */ + setCullPadding: function (paddingX, paddingY) + { + if (paddingX === undefined) { paddingX = 1; } + if (paddingY === undefined) { paddingY = 1; } + + this.cullPaddingX = paddingX; + this.cullPaddingY = paddingY; + + return this; + }, + /** * Sets collision on the given tile or tiles within a layer by index. You can pass in either a * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if @@ -751,10 +976,8 @@ var DynamicTilemapLayer = new Class({ * @since 3.0.0 * * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -776,10 +999,8 @@ var DynamicTilemapLayer = new Class({ * * @param {integer} start - The first index of the tile to be set for collision. * @param {integer} stop - The last index of the tile to be set for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -802,12 +1023,9 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionByProperty * @since 3.0.0 * - * @param {object} properties - An object with tile properties and corresponding values that should - * be checked. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {object} properties - An object with tile properties and corresponding values that should be checked. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -827,10 +1045,8 @@ var DynamicTilemapLayer = new Class({ * @since 3.0.0 * * @param {integer[]} indexes - An array of the tile indexes to not be counted for collision. - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -850,10 +1066,8 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#setCollisionFromCollisionGroup * @since 3.0.0 * - * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear - * collision. - * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the - * update. + * @param {boolean} [collides=true] - If true it will enable collision. If false it will clear collision. + * @param {boolean} [recalculateFaces=true] - Whether or not to recalculate the tile faces after the update. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -873,8 +1087,7 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileIndexCallback * @since 3.0.0 * - * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a - * collision callback set for. + * @param {(integer|array)} indexes - Either a single tile index, or an array of tile indexes to have a collision callback set for. * @param {function} callback - The callback that will be invoked when the tile is collided with. * @param {object} callbackContext - The context under which the callback is called. * @@ -895,10 +1108,10 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#setTileLocationCallback * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {function} callback - The callback that will be invoked when the tile is collided with. * @param {object} [callbackContext] - The context under which the callback is called. * @@ -920,10 +1133,10 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#shuffle * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -944,10 +1157,10 @@ var DynamicTilemapLayer = new Class({ * * @param {integer} tileA - First tile index. * @param {integer} tileB - Second tile index. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * * @return {Phaser.Tilemaps.DynamicTilemapLayer} This Tilemap Layer object. */ @@ -965,8 +1178,8 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldX * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {number} */ @@ -982,8 +1195,8 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldY * @since 3.0.0 * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {number} */ @@ -1000,10 +1213,10 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#tileToWorldXY * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {integer} tileX - The x coordinate, in tiles, not pixels. + * @param {integer} tileY - The y coordinate, in tiles, not pixels. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {Phaser.Math.Vector2} */ @@ -1030,10 +1243,10 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#weightedRandomize * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during * randomization. They should be in the form: { index: 0, weight: 4 } or * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. @@ -1054,10 +1267,9 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileX * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {number} */ @@ -1073,10 +1285,9 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileY * @since 3.0.0 * - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {number} */ @@ -1093,12 +1304,11 @@ var DynamicTilemapLayer = new Class({ * @method Phaser.Tilemaps.DynamicTilemapLayer#worldToTileXY * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the - * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The x coordinate to be converted, in pixels, not tiles. + * @param {number} worldY - The y coordinate to be converted, in pixels, not tiles. + * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the nearest integer. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {Phaser.Math.Vector2} */ diff --git a/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js b/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js index ab9b5af13..0d8255f74 100644 --- a/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js +++ b/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../gameobjects/GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -19,65 +17,102 @@ var GameObject = require('../../gameobjects/GameObject'); * @param {Phaser.Tilemaps.DynamicTilemapLayer} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + + if (tileCount === 0) { return; } - src.cull(camera); + var camMatrix = renderer._tempMatrix1; + var layerMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; - var renderTiles = src.culledTiles; - var length = renderTiles.length; - var image = src.tileset.image.getSourceImage(); - var tileset = this.tileset; + layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; - var ctx = renderer.gameContext; + camMatrix.copyFrom(camera.matrix); + + var ctx = renderer.currentContext; + var gidMap = src.gidMap; ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - for (var index = 0; index < length; ++index) + if (parentMatrix) { - var tile = renderTiles[index]; + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + // Undo the camera scroll + layerMatrix.e = src.x; + layerMatrix.f = src.y; + + // Multiply by the Sprite matrix, store result in calcMatrix + camMatrix.multiply(layerMatrix, calcMatrix); + + calcMatrix.copyToContext(ctx); + } + else + { + layerMatrix.e -= camera.scrollX * src.scrollFactorX; + layerMatrix.f -= camera.scrollY * src.scrollFactorY; + + layerMatrix.copyToContext(ctx); + } + + var alpha = camera.alpha * src.alpha; + + for (var i = 0; i < tileCount; i++) + { + var tile = renderTiles[i]; + + var tileset = gidMap[tile.index]; + + if (!tileset) + { + continue; + } + + var image = tileset.image.getSourceImage(); var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } - var halfWidth = tile.width / 2; - var halfHeight = tile.height / 2; - - ctx.save(); - ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); - - if (tile.rotation !== 0) + if (tileTexCoords) { - ctx.rotate(tile.rotation); + var halfWidth = tile.width / 2; + var halfHeight = tile.height / 2; + + ctx.save(); + + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale((tile.flipX) ? -1 : 1, (tile.flipY) ? -1 : 1); + } + + ctx.globalAlpha = alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tile.width, tile.height, + -halfWidth, -halfHeight, + tile.width, tile.height + ); + + ctx.restore(); } - - if (tile.flipX || tile.flipY) - { - ctx.scale(tile.flipX ? -1 : 1, tile.flipY ? -1 : 1); - } - - ctx.globalAlpha = camera.alpha * src.alpha * tile.alpha; - - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - -halfWidth, -halfHeight, - tile.width, tile.height - ); - - ctx.restore(); } ctx.restore(); diff --git a/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js b/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js index 961582c04..7e7358c5f 100644 --- a/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js +++ b/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js @@ -4,7 +4,7 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../gameobjects/GameObject'); +var Utils = require('../../renderer/webgl/Utils'); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -22,14 +22,90 @@ var GameObject = require('../../gameobjects/GameObject'); */ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + var alpha = camera.alpha * src.alpha; + + if (tileCount === 0 || alpha <= 0) { return; } - src.cull(camera); + var gidMap = src.gidMap; + var pipeline = src.pipeline; - this.pipeline.batchDynamicTilemapLayer(src, camera); + var getTint = Utils.getTintAppendFloatAlpha; + + var scrollFactorX = src.scrollFactorX; + var scrollFactorY = src.scrollFactorY; + + var x = src.x; + var y = src.y; + + var sx = src.scaleX; + var sy = src.scaleY; + + var tilesets = src.tileset; + + // Loop through each tileset in this layer, drawing just the tiles that are in that set each time + // Doing it this way around allows us to batch tiles using the same tileset + for (var c = 0; c < tilesets.length; c++) + { + var currentSet = tilesets[c]; + var texture = currentSet.glTexture; + + for (var i = 0; i < tileCount; i++) + { + var tile = renderTiles[i]; + + var tileset = gidMap[tile.index]; + + if (tileset !== currentSet) + { + // Skip tiles that aren't in this set + continue; + } + + var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); + + if (tileTexCoords === null) + { + continue; + } + + var frameWidth = tile.width; + var frameHeight = tile.height; + + var frameX = tileTexCoords.x; + var frameY = tileTexCoords.y; + + var tw = tile.width * 0.5; + var th = tile.height * 0.5; + + var tint = getTint(tile.tint, alpha * tile.alpha); + + pipeline.batchTexture( + src, + texture, + texture.width, texture.height, + x + ((tw + tile.pixelX) * sx), y + ((th + tile.pixelY) * sy), + tile.width, tile.height, + sx, sy, + tile.rotation, + tile.flipX, tile.flipY, + scrollFactorX, scrollFactorY, + tw, th, + frameX, frameY, frameWidth, frameHeight, + tint, tint, tint, tint, false, + 0, 0, + camera, + null, + true + ); + } + } }; module.exports = DynamicTilemapLayerWebGLRenderer; diff --git a/src/tilemaps/mapdata/LayerData.js b/src/tilemaps/mapdata/LayerData.js index f5a6c3c6e..d40a818f9 100644 --- a/src/tilemaps/mapdata/LayerData.js +++ b/src/tilemaps/mapdata/LayerData.js @@ -14,7 +14,7 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * to this data and use it to look up and perform operations on tiles. * * @class LayerData - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * diff --git a/src/tilemaps/mapdata/MapData.js b/src/tilemaps/mapdata/MapData.js index 37ea3e0e6..6e7489007 100644 --- a/src/tilemaps/mapdata/MapData.js +++ b/src/tilemaps/mapdata/MapData.js @@ -14,7 +14,7 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * itself. * * @class MapData - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -119,7 +119,21 @@ var MapData = new Class({ this.orientation = GetFastValue(config, 'orientation', 'orthogonal'); /** - * [description] + * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. + * + * @name Phaser.Tilemaps.MapData#renderOrder + * @type {string} + * @since 3.12.0 + */ + this.renderOrder = GetFastValue(config, 'renderOrder', 'right-down'); + + /** + * Determines the draw order of tilemap. Default is right-down + * + * 0, or 'right-down' + * 1, or 'left-down' + * 2, or 'right-up' + * 3, or 'left-up' * * @name Phaser.Tilemaps.MapData#version * @type {string} @@ -128,7 +142,7 @@ var MapData = new Class({ this.version = GetFastValue(config, 'version', '1'); /** - * [description] + * The version of the map data (as specified in Tiled). * * @name Phaser.Tilemaps.MapData#properties * @type {object} @@ -137,7 +151,7 @@ var MapData = new Class({ this.properties = GetFastValue(config, 'properties', {}); /** - * [description] + * Map specific properties (can be specified in Tiled) * * @name Phaser.Tilemaps.MapData#layers * @type {array} @@ -146,7 +160,7 @@ var MapData = new Class({ this.layers = GetFastValue(config, 'layers', []); /** - * [description] + * An array with all the layers configured to the MapData * * @name Phaser.Tilemaps.MapData#images * @type {array} @@ -155,7 +169,7 @@ var MapData = new Class({ this.images = GetFastValue(config, 'images', []); /** - * [description] + * An array of Tiled Image Layers * * @name Phaser.Tilemaps.MapData#objects * @type {object} @@ -164,7 +178,7 @@ var MapData = new Class({ this.objects = GetFastValue(config, 'objects', {}); /** - * [description] + * An object of Tiled Object Layers * * @name Phaser.Tilemaps.MapData#collision * @type {object} @@ -173,7 +187,7 @@ var MapData = new Class({ this.collision = GetFastValue(config, 'collision', {}); /** - * [description] + * An object of collision data. Must be created as physics object or will return undefined * * @name Phaser.Tilemaps.MapData#tilesets * @type {array} @@ -182,7 +196,7 @@ var MapData = new Class({ this.tilesets = GetFastValue(config, 'tilesets', []); /** - * [description] + * An array of Tilesets * * @name Phaser.Tilemaps.MapData#imageCollections * @type {array} diff --git a/src/tilemaps/mapdata/ObjectLayer.js b/src/tilemaps/mapdata/ObjectLayer.js index 544970dbc..888b411a2 100644 --- a/src/tilemaps/mapdata/ObjectLayer.js +++ b/src/tilemaps/mapdata/ObjectLayer.js @@ -17,11 +17,11 @@ var GetFastValue = require('../../utils/object/GetFastValue'); * - "draworder" is ignored. * * @class ObjectLayer - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * - * @param {object} [config] - [description] + * @param {object} [config] - The data for the layer from the Tiled JSON object. */ var ObjectLayer = new Class({ @@ -32,7 +32,7 @@ var ObjectLayer = new Class({ if (config === undefined) { config = {}; } /** - * [description] + * The name of the Object Layer. * * @name Phaser.Tilemaps.ObjectLayer#name * @type {string} @@ -41,7 +41,7 @@ var ObjectLayer = new Class({ this.name = GetFastValue(config, 'name', 'object layer'); /** - * [description] + * The opacity of the layer, between 0 and 1. * * @name Phaser.Tilemaps.ObjectLayer#opacity * @type {number} @@ -50,7 +50,7 @@ var ObjectLayer = new Class({ this.opacity = GetFastValue(config, 'opacity', 1); /** - * [description] + * The custom properties defined on the Object Layer, keyed by their name. * * @name Phaser.Tilemaps.ObjectLayer#properties * @type {object} @@ -59,7 +59,7 @@ var ObjectLayer = new Class({ this.properties = GetFastValue(config, 'properties', {}); /** - * [description] + * The type of each custom property defined on the Object Layer, keyed by its name. * * @name Phaser.Tilemaps.ObjectLayer#propertyTypes * @type {object} @@ -68,7 +68,7 @@ var ObjectLayer = new Class({ this.propertyTypes = GetFastValue(config, 'propertytypes', {}); /** - * [description] + * The type of the layer, which should be `objectgroup`. * * @name Phaser.Tilemaps.ObjectLayer#type * @type {string} @@ -77,7 +77,7 @@ var ObjectLayer = new Class({ this.type = GetFastValue(config, 'type', 'objectgroup'); /** - * [description] + * Whether the layer is shown (`true`) or hidden (`false`). * * @name Phaser.Tilemaps.ObjectLayer#visible * @type {boolean} @@ -86,7 +86,15 @@ var ObjectLayer = new Class({ this.visible = GetFastValue(config, 'visible', true); /** - * [description] + * An array of all objects on this Object Layer. + * + * Each Tiled object corresponds to a JavaScript object in this array. It has an `id` (unique), `name` (as assigned in Tiled), `type` (as assigned in Tiled), `rotation` (in clockwise degrees), `properties` (if any), `visible` state (`true` if visible, `false` otherwise), `x` and `y` coordinates (in pixels, relative to the tilemap), and a `width` and `height` (in pixels). + * + * An object tile has a `gid` property (GID of the represented tile), a `flippedHorizontal` property, a `flippedVertical` property, and `flippedAntiDiagonal` property. The {@link http://docs.mapeditor.org/en/latest/reference/tmx-map-format/|Tiled documentation} contains information on flipping and rotation. + * + * Polylines have a `polyline` property, which is an array of objects corresponding to points, where each point has an `x` property and a `y` property. Polygons have an identically structured array in their `polygon` property. Text objects have a `text` property with the text's properties. + * + * Rectangles and ellipses have a `rectangle` or `ellipse` property set to `true`. * * @name Phaser.Tilemaps.ObjectLayer#objects * @type {Phaser.GameObjects.GameObject[]} diff --git a/src/tilemaps/parsers/Parse.js b/src/tilemaps/parsers/Parse.js index bed92e725..506386f95 100644 --- a/src/tilemaps/parsers/Parse.js +++ b/src/tilemaps/parsers/Parse.js @@ -33,7 +33,7 @@ var ParseWeltmeister = require('./impact/ParseWeltmeister'); * consumption. However if your map is small or you need to update the tiles dynamically, then leave * the default value set. * - * @return {Phaser.Tilemaps.MapData} [description] + * @return {Phaser.Tilemaps.MapData} The created `MapData` object. */ var Parse = function (name, mapFormat, data, tileWidth, tileHeight, insertNull) { diff --git a/src/tilemaps/parsers/ParseCSV.js b/src/tilemaps/parsers/ParseCSV.js index d57e80a1b..e04cb09ab 100644 --- a/src/tilemaps/parsers/ParseCSV.js +++ b/src/tilemaps/parsers/ParseCSV.js @@ -24,7 +24,7 @@ var Parse2DArray = require('./Parse2DArray'); * consumption. However if your map is small or you need to update the tiles dynamically, then leave * the default value set. * - * @return {Phaser.Tilemaps.MapData} [description] + * @return {Phaser.Tilemaps.MapData} The resulting MapData object. */ var ParseCSV = function (name, data, tileWidth, tileHeight, insertNull) { diff --git a/src/tilemaps/parsers/tiled/Base64Decode.js b/src/tilemaps/parsers/tiled/Base64Decode.js index 76e11ae14..a346cff6f 100644 --- a/src/tilemaps/parsers/tiled/Base64Decode.js +++ b/src/tilemaps/parsers/tiled/Base64Decode.js @@ -5,14 +5,14 @@ */ /** - * [description] + * Decode base-64 encoded data, for example as exported by Tiled. * * @function Phaser.Tilemaps.Parsers.Tiled.Base64Decode * @since 3.0.0 * - * @param {object} data - [description] + * @param {object} data - Base-64 encoded data to decode. * - * @return {array} [description] + * @return {array} Array containing the decoded bytes. */ var Base64Decode = function (data) { diff --git a/src/tilemaps/parsers/tiled/ParseJSONTiled.js b/src/tilemaps/parsers/tiled/ParseJSONTiled.js index e2d3e49d1..8c639e01a 100644 --- a/src/tilemaps/parsers/tiled/ParseJSONTiled.js +++ b/src/tilemaps/parsers/tiled/ParseJSONTiled.js @@ -33,7 +33,7 @@ var GetFastValue = require('../../../utils/object/GetFastValue'); * consumption. However if your map is small or you need to update the tiles dynamically, then leave * the default value set. * - * @return {?Phaser.Tilemaps.MapData} [description] + * @return {?Phaser.Tilemaps.MapData} The created MapData object, or `null` if the data can't be parsed. */ var ParseJSONTiled = function (name, json, insertNull) { @@ -54,7 +54,8 @@ var ParseJSONTiled = function (name, json, insertNull) format: Formats.TILED_JSON, version: json.version, properties: json.properties, - infinite: GetFastValue(json, 'infinite', false) + renderOrder: json.renderorder, + infinite: json.infinite }); mapData.layers = ParseTileLayers(json, insertNull); diff --git a/src/tilemaps/parsers/tiled/ParseObject.js b/src/tilemaps/parsers/tiled/ParseObject.js index f56fb9b4c..d54d0abc5 100644 --- a/src/tilemaps/parsers/tiled/ParseObject.js +++ b/src/tilemaps/parsers/tiled/ParseObject.js @@ -12,16 +12,16 @@ var copyPoints = function (p) { return { x: p.x, y: p.y }; }; var commonObjectProps = [ 'id', 'name', 'type', 'rotation', 'properties', 'visible', 'x', 'y', 'width', 'height' ]; /** - * [description] + * Convert a Tiled object to an internal parsed object normalising and copying properties over, while applying optional x and y offsets. The parsed object will always have the properties `id`, `name`, `type`, `rotation`, `properties`, `visible`, `x`, `y`, `width` and `height`. Other properties will be added according to the object type (such as text, polyline, gid etc.) * * @function Phaser.Tilemaps.Parsers.Tiled.ParseObject * @since 3.0.0 * - * @param {object} tiledObject - [description] - * @param {number} [offsetX=0] - [description] - * @param {number} [offsetY=0] - [description] + * @param {object} tiledObject - Tiled object to convert to an internal parsed object normalising and copying properties over. + * @param {number} [offsetX=0] - Optional additional offset to apply to the object's x property. Defaults to 0. + * @param {number} [offsetY=0] - Optional additional offset to apply to the object's y property. Defaults to 0. * - * @return {object} [description] + * @return {object} The parsed object containing properties read from the Tiled object according to it's type with x and y values updated according to the given offsets. */ var ParseObject = function (tiledObject, offsetX, offsetY) { diff --git a/src/tilemaps/parsers/tiled/ParseObjectLayers.js b/src/tilemaps/parsers/tiled/ParseObjectLayers.js index dcf638688..1428af7df 100644 --- a/src/tilemaps/parsers/tiled/ParseObjectLayers.js +++ b/src/tilemaps/parsers/tiled/ParseObjectLayers.js @@ -9,14 +9,14 @@ var ParseObject = require('./ParseObject'); var ObjectLayer = require('../../mapdata/ObjectLayer'); /** - * [description] + * Parses a Tiled JSON object into an array of ObjectLayer objects. * * @function Phaser.Tilemaps.Parsers.Tiled.ParseObjectLayers * @since 3.0.0 * - * @param {object} json - [description] + * @param {object} json - The Tiled JSON object. * - * @return {array} [description] + * @return {array} An array of all object layers in the tilemap as `ObjectLayer`s. */ var ParseObjectLayers = function (json) { diff --git a/src/tilemaps/parsers/tiled/ParseTilesets.js b/src/tilemaps/parsers/tiled/ParseTilesets.js index 0d0c25fd8..1c9ed3f36 100644 --- a/src/tilemaps/parsers/tiled/ParseTilesets.js +++ b/src/tilemaps/parsers/tiled/ParseTilesets.js @@ -38,27 +38,91 @@ var ParseTilesets = function (json) { var newSet = new Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing); - // Properties stored per-tile in object with string indexes starting at "0" - if (set.tileproperties) + if (json.version > 1) { - newSet.tileProperties = set.tileproperties; - } + // Tiled 1.2+ - // Object & terrain shapes stored per-tile in object with string indexes starting at "0" - if (set.tiles) - { - newSet.tileData = set.tiles; - - // Parse the objects into Phaser format to match handling of other Tiled objects - for (stringID in newSet.tileData) + if (Array.isArray(set.tiles)) { - var objectGroup = newSet.tileData[stringID].objectgroup; - if (objectGroup && objectGroup.objects) + var tiles = {}; + var props = {}; + + for (var t = 0; t < set.tiles.length; t++) { - var parsedObjects = objectGroup.objects.map( - function (obj) { return ParseObject(obj); } - ); - newSet.tileData[stringID].objectgroup.objects = parsedObjects; + var tile = set.tiles[t]; + + // Convert tileproperties + if (tile.properties) + { + var newPropData = {}; + + tile.properties.forEach(function (propData) + { + newPropData[propData['name']] = propData['value']; + }); + + props[tile.id] = newPropData; + } + + // Convert objectgroup + if (tile.objectgroup) + { + tiles[tile.id] = { objectgroup: tile.objectgroup }; + + if (tile.objectgroup.objects) + { + var parsedObjects2 = tile.objectgroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + + tiles[tile.id].objectgroup.objects = parsedObjects2; + } + } + + // Copy animation data + if (tile.animation) + { + if (tiles.hasOwnProperty(tile.id)) + { + tiles[tile.id].animation = tile.animation; + } + else + { + tiles[tile.id] = { animation: tile.animation }; + } + } + } + + newSet.tileData = tiles; + newSet.tileProperties = props; + } + } + else + { + // Tiled 1 + + // Properties stored per-tile in object with string indexes starting at "0" + if (set.tileproperties) + { + newSet.tileProperties = set.tileproperties; + } + + // Object & terrain shapes stored per-tile in object with string indexes starting at "0" + if (set.tiles) + { + newSet.tileData = set.tiles; + + // Parse the objects into Phaser format to match handling of other Tiled objects + for (stringID in newSet.tileData) + { + var objectGroup = newSet.tileData[stringID].objectgroup; + if (objectGroup && objectGroup.objects) + { + var parsedObjects1 = objectGroup.objects.map( + function (obj) { return ParseObject(obj); } + ); + newSet.tileData[stringID].objectgroup.objects = parsedObjects1; + } } } } diff --git a/src/tilemaps/parsers/tiled/Pick.js b/src/tilemaps/parsers/tiled/Pick.js index 0c8c032c7..f1a50ddd0 100644 --- a/src/tilemaps/parsers/tiled/Pick.js +++ b/src/tilemaps/parsers/tiled/Pick.js @@ -7,15 +7,15 @@ var HasValue = require('../../../utils/object/HasValue'); /** - * [description] + * Returns a new object that only contains the `keys` that were found on the object provided. If no `keys` are found, an empty object is returned. * * @function Phaser.Tilemaps.Parsers.Tiled.Pick * @since 3.0.0 * - * @param {object} object - [description] - * @param {array} keys - [description] + * @param {object} object - The object to pick the provided keys from. + * @param {array} keys - An array of properties to retrieve from the provided object. * - * @return {object} [description] + * @return {object} A new object that only contains the `keys` that were found on the provided object. If no `keys` were found, an empty object will be returned. */ var Pick = function (object, keys) { diff --git a/src/tilemaps/staticlayer/StaticTilemapLayer.js b/src/tilemaps/staticlayer/StaticTilemapLayer.js index 0fc087ab4..03b9956f5 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayer.js @@ -10,20 +10,22 @@ var CONST = require('../../const'); var GameObject = require('../../gameobjects/GameObject'); var StaticTilemapLayerRender = require('./StaticTilemapLayerRender'); var TilemapComponents = require('../components'); +var TransformMatrix = require('../../gameobjects/components/TransformMatrix'); var Utils = require('../../renderer/webgl/Utils'); /** * @classdesc - * A StaticTilemapLayer is a game object that renders LayerData from a Tilemap. A - * StaticTilemapLayer can only render tiles from a single tileset. + * A Static Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. * - * A StaticTilemapLayer is optimized for speed over flexibility. You cannot apply per-tile - * effects like tint or alpha. You cannot change the tiles in a StaticTilemapLayer. Use this - * over a DynamicTilemapLayer when you don't need either of those features. + * A Static Tilemap Layer is optimized for rendering speed over flexibility. You cannot apply per-tile + * effects like tint or alpha, or change the tiles or tilesets the layer uses. + * + * Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features. * * @class StaticTilemapLayer * @extends Phaser.GameObjects.GameObject - * @memberOf Phaser.Tilemaps + * @memberof Phaser.Tilemaps * @constructor * @since 3.0.0 * @@ -40,10 +42,10 @@ var Utils = require('../../renderer/webgl/Utils'); * @extends Phaser.GameObjects.Components.Visible * @extends Phaser.GameObjects.Components.ScrollFactor * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene to which this Game Object belongs. * @param {Phaser.Tilemaps.Tilemap} tilemap - The Tilemap this layer is a part of. * @param {integer} layerIndex - The index of the LayerData associated with this layer. - * @param {Phaser.Tilemaps.Tileset} tileset - The tileset used to render the tiles in this layer. + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. * @param {number} [x=0] - The world x position where the top left of this layer will be placed. * @param {number} [y=0] - The world y position where the top left of this layer will be placed. */ @@ -78,7 +80,7 @@ var StaticTilemapLayer = new Class({ * * @name Phaser.Tilemaps.StaticTilemapLayer#isTilemap * @type {boolean} - * @readOnly + * @readonly * @since 3.0.0 */ this.isTilemap = true; @@ -111,20 +113,23 @@ var StaticTilemapLayer = new Class({ */ this.layer = tilemap.layers[layerIndex]; - this.layer.tilemapLayer = this; // Link the LayerData with this static tilemap layer + // Link the LayerData with this static tilemap layer + this.layer.tilemapLayer = this; /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. * * @name Phaser.Tilemaps.StaticTilemapLayer#tileset - * @type {Phaser.Tilemaps.Tileset} + * @type {Phaser.Tilemaps.Tileset[]} * @since 3.0.0 */ - this.tileset = tileset; + this.tileset = []; /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. + * Used internally by the Canvas renderer. + * This holds the tiles that are visible within the camera in the last frame. * * @name Phaser.Tilemaps.StaticTilemapLayer#culledTiles * @type {array} @@ -133,14 +138,98 @@ var StaticTilemapLayer = new Class({ this.culledTiles = []; /** - * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer - * @type {array} - * @private - * @since 3.0.0 + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#skipCull + * @type {boolean} + * @since 3.12.0 */ - this.vertexBuffer = null; + this.skipCull = false; /** + * Canvas only. + * + * The total number of tiles drawn by the renderer in the last frame. + * + * This only works when rending with Canvas. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilesDrawn + * @type {integer} + * @readonly + * @since 3.12.0 + */ + this.tilesDrawn = 0; + + /** + * Canvas only. + * + * The total number of tiles in this layer. Updated every frame. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#tilesTotal + * @type {integer} + * @readonly + * @since 3.12.0 + */ + this.tilesTotal = this.layer.width * this.layer.height; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullPaddingX + * @type {integer} + * @default 1 + * @since 3.12.0 + */ + this.cullPaddingX = 1; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullPaddingY + * @type {integer} + * @default 1 + * @since 3.12.0 + */ + this.cullPaddingY = 1; + + /** + * Canvas only. + * + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1) The Phaser.Tilemaps.LayerData object for this Layer + * 2) The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3) A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#cullCallback + * @type {function} + * @since 3.12.0 + */ + this.cullCallback = TilemapComponents.CullTiles; + + /** + * A reference to the renderer. + * * @name Phaser.Tilemaps.StaticTilemapLayer#renderer * @type {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} * @private @@ -149,49 +238,126 @@ var StaticTilemapLayer = new Class({ this.renderer = scene.sys.game.renderer; /** + * An array of vertex buffer objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#vertexBuffer + * @type {WebGLBuffer[]} + * @private + * @since 3.0.0 + */ + this.vertexBuffer = []; + + /** + * An array of ArrayBuffer objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * * @name Phaser.Tilemaps.StaticTilemapLayer#bufferData - * @type {ArrayBuffer} + * @type {ArrayBuffer[]} * @private * @since 3.0.0 */ - this.bufferData = null; + this.bufferData = []; /** + * An array of Float32 Array objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewF32 - * @type {Float32Array} + * @type {Float32Array[]} * @private * @since 3.0.0 */ - this.vertexViewF32 = null; + this.vertexViewF32 = []; /** + * An array of Uint32 Array objects, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single instance. + * * @name Phaser.Tilemaps.StaticTilemapLayer#vertexViewU32 - * @type {Uint32Array} + * @type {Uint32Array[]} * @private * @since 3.0.0 */ - this.vertexViewU32 = null; + this.vertexViewU32 = []; /** + * An array of booleans, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single boolean. + * * @name Phaser.Tilemaps.StaticTilemapLayer#dirty - * @type {boolean} + * @type {boolean[]} * @private * @since 3.0.0 */ - this.dirty = true; + this.dirty = []; /** + * An array of integers, used by the WebGL renderer. + * + * As of Phaser 3.14 this property is now an array, where each element maps to a Tileset instance. Previously it was a single integer. + * * @name Phaser.Tilemaps.StaticTilemapLayer#vertexCount - * @type {integer} + * @type {integer[]} * @private * @since 3.0.0 */ - this.vertexCount = 0; + this.vertexCount = []; + /** + * The rendering (draw) order of the tiles in this layer. + * + * The default is 0 which is 'right-down', meaning it will draw the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * This can be changed via the `setRenderOrder` method. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#_renderOrder + * @type {integer} + * @default 0 + * @private + * @since 3.12.0 + */ + this._renderOrder = 0; + + /** + * A temporary Transform Matrix, re-used internally during batching. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#_tempMatrix + * @private + * @type {Phaser.GameObjects.Components.TransformMatrix} + * @since 3.14.0 + */ + this._tempMatrix = new TransformMatrix(); + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + * + * @name Phaser.Tilemaps.StaticTilemapLayer#gidMap + * @type {Phaser.Tilemaps.Tileset[]} + * @since 3.14.0 + */ + this.gidMap = []; + + this.setTilesets(tileset); this.setAlpha(this.layer.alpha); this.setPosition(x, y); this.setOrigin(); - this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height); + this.setSize(tilemap.tileWidth * this.layer.width, tilemap.tileHeight * this.layer.height); + + this.updateVBOData(); this.initPipeline('TextureTintPipeline'); @@ -199,12 +365,81 @@ var StaticTilemapLayer = new Class({ { scene.sys.game.renderer.onContextRestored(function () { - this.dirty = true; - this.vertexBuffer = null; + this.updateVBOData(); }, this); } }, + /** + * Populates the internal `tileset` array with the Tileset references this Layer requires for rendering. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setTilesets + * @private + * @since 3.14.0 + * + * @param {(string|string[]|Phaser.Tilemaps.Tileset|Phaser.Tilemaps.Tileset[])} tileset - The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + */ + setTilesets: function (tilesets) + { + var gidMap = []; + var setList = []; + var map = this.tilemap; + + if (!Array.isArray(tilesets)) + { + tilesets = [ tilesets ]; + } + + for (var i = 0; i < tilesets.length; i++) + { + var tileset = tilesets[i]; + + if (typeof tileset === 'string') + { + tileset = map.getTileset(tileset); + } + + if (tileset) + { + setList.push(tileset); + + var s = tileset.firstgid; + + for (var t = 0; t < tileset.total; t++) + { + gidMap[s + t] = tileset; + } + } + } + + this.gidMap = gidMap; + this.tileset = setList; + }, + + /** + * Prepares the VBO data arrays for population by the `upload` method. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#updateVBOData + * @private + * @since 3.14.0 + * + * @return {this} This Tilemap Layer object. + */ + updateVBOData: function () + { + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + this.vertexCount[i] = 0; + this.vertexBuffer[i] = null; + this.bufferData[i] = null; + this.vertexViewF32[i] = null; + this.vertexViewU32[i] = null; + } + + return this; + }, + /** * Upload the tile data to a VBO. * @@ -212,131 +447,325 @@ var StaticTilemapLayer = new Class({ * @since 3.0.0 * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera to render to. + * @param {integer} tilesetIndex - The tileset index. * * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. */ - upload: function (camera) + upload: function (camera, tilesetIndex) { - var tileset = this.tileset; - var mapWidth = this.layer.width; - var mapHeight = this.layer.height; - var width = tileset.image.source[0].width; - var height = tileset.image.source[0].height; - var mapData = this.layer.data; var renderer = this.renderer; - var tile; - var row; - var col; - var texCoords; + var gl = renderer.gl; - if (renderer.gl) + var pipeline = renderer.pipelines.TextureTintPipeline; + + if (this.dirty[tilesetIndex]) { - var pipeline = renderer.pipelines.TextureTintPipeline; + var tileset = this.tileset[tilesetIndex]; + var mapWidth = this.layer.width; + var mapHeight = this.layer.height; + var width = tileset.image.source[0].width; + var height = tileset.image.source[0].height; + var mapData = this.layer.data; + var tile; + var row; + var col; + var renderOrder = this._renderOrder; + var minTileIndex = tileset.firstgid; + var maxTileIndex = tileset.firstgid + tileset.total; + + var vertexBuffer = this.vertexBuffer[tilesetIndex]; + var bufferData = this.bufferData[tilesetIndex]; + var vOffset = -1; + var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; - if (this.dirty) + this.vertexCount[tilesetIndex] = 0; + + if (bufferData === null) { - var gl = renderer.gl; - var vertexBuffer = this.vertexBuffer; - var bufferData = this.bufferData; - var voffset = 0; - var vertexCount = 0; - var bufferSize = (mapWidth * mapHeight) * pipeline.vertexSize * 6; + bufferData = new ArrayBuffer(bufferSize); - if (bufferData === null) + this.bufferData[tilesetIndex] = bufferData; + + this.vertexViewF32[tilesetIndex] = new Float32Array(bufferData); + this.vertexViewU32[tilesetIndex] = new Uint32Array(bufferData); + } + + if (renderOrder === 0) + { + // right-down + + for (row = 0; row < mapHeight; row++) { - bufferData = new ArrayBuffer(bufferSize); - this.bufferData = bufferData; - this.vertexViewF32 = new Float32Array(bufferData); - this.vertexViewU32 = new Uint32Array(bufferData); - } - - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - - for (row = 0; row < mapHeight; ++row) - { - for (col = 0; col < mapWidth; ++col) + for (col = 0; col < mapWidth; col++) { tile = mapData[row][col]; - if (tile === null || tile.index === -1) { continue; } - - var tx = tile.pixelX; - var ty = tile.pixelY; - var txw = tx + tile.width; - var tyh = ty + tile.height; - - texCoords = tileset.getTileTextureCoordinates(tile.index); - if (texCoords === null) { continue; } - - var u0 = texCoords.x / width; - var v0 = texCoords.y / height; - var u1 = (texCoords.x + tile.width) / width; - var v1 = (texCoords.y + tile.height) / height; - - var tx0 = tx; - var ty0 = ty; - var tx1 = tx; - var ty1 = tyh; - var tx2 = txw; - var ty2 = tyh; - var tx3 = txw; - var ty3 = ty; - var tint = Utils.getTintAppendFloatAlpha(0xffffff, camera.alpha * this.alpha * tile.alpha); - - vertexViewF32[voffset + 0] = tx0; - vertexViewF32[voffset + 1] = ty0; - vertexViewF32[voffset + 2] = u0; - vertexViewF32[voffset + 3] = v0; - vertexViewU32[voffset + 4] = tint; - vertexViewF32[voffset + 5] = tx1; - vertexViewF32[voffset + 6] = ty1; - vertexViewF32[voffset + 7] = u0; - vertexViewF32[voffset + 8] = v1; - vertexViewU32[voffset + 9] = tint; - vertexViewF32[voffset + 10] = tx2; - vertexViewF32[voffset + 11] = ty2; - vertexViewF32[voffset + 12] = u1; - vertexViewF32[voffset + 13] = v1; - vertexViewU32[voffset + 14] = tint; - vertexViewF32[voffset + 15] = tx0; - vertexViewF32[voffset + 16] = ty0; - vertexViewF32[voffset + 17] = u0; - vertexViewF32[voffset + 18] = v0; - vertexViewU32[voffset + 19] = tint; - vertexViewF32[voffset + 20] = tx2; - vertexViewF32[voffset + 21] = ty2; - vertexViewF32[voffset + 22] = u1; - vertexViewF32[voffset + 23] = v1; - vertexViewU32[voffset + 24] = tint; - vertexViewF32[voffset + 25] = tx3; - vertexViewF32[voffset + 26] = ty3; - vertexViewF32[voffset + 27] = u1; - vertexViewF32[voffset + 28] = v0; - vertexViewU32[voffset + 29] = tint; - - voffset += 30; - vertexCount += 6; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); } } - - this.vertexCount = vertexCount; - this.dirty = false; - if (vertexBuffer === null) + } + else if (renderOrder === 1) + { + // left-down + + for (row = 0; row < mapHeight; row++) { - vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); - this.vertexBuffer = vertexBuffer; - } - else - { - renderer.setVertexBuffer(vertexBuffer); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); + for (col = mapWidth - 1; col >= 0; col--) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } } } + else if (renderOrder === 2) + { + // right-up + + for (row = mapHeight - 1; row >= 0; row--) + { + for (col = 0; col < mapWidth; col++) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + else if (renderOrder === 3) + { + // left-up + + for (row = mapHeight - 1; row >= 0; row--) + { + for (col = mapWidth - 1; col >= 0; col--) + { + tile = mapData[row][col]; + + if (!tile || tile.index < minTileIndex || tile.index > maxTileIndex || !tile.visible) + { + continue; + } + + vOffset = this.batchTile(vOffset, tile, tileset, width, height, camera, tilesetIndex); + } + } + } + + this.dirty[tilesetIndex] = false; + + if (vertexBuffer === null) + { + vertexBuffer = renderer.createVertexBuffer(bufferData, gl.STATIC_DRAW); + + this.vertexBuffer[tilesetIndex] = vertexBuffer; + } + else + { + renderer.setVertexBuffer(vertexBuffer); + + gl.bufferSubData(gl.ARRAY_BUFFER, 0, bufferData); + } + } - pipeline.modelIdentity(); - pipeline.modelTranslate(this.x - (camera.scrollX * this.scrollFactorX), this.y - (camera.scrollY * this.scrollFactorY), 0.0); - pipeline.modelScale(this.scaleX, this.scaleY, 1.0); - pipeline.viewLoad2D(camera.matrix.matrix); + return this; + }, + + /** + * Add a single tile into the batch. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#batchTile + * @private + * @since 3.12.0 + * + * @param {integer} vOffset - The vertex offset. + * @param {any} tile - The tile being rendered. + * @param {any} tileset - The tileset being used for rendering. + * @param {integer} width - The width of the tileset image in pixels. + * @param {integer} height - The height of the tileset image in pixels. + * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera the layer is being rendered with. + * @param {integer} tilesetIndex - The tileset index. + * + * @return {integer} The new vOffset value. + */ + batchTile: function (vOffset, tile, tileset, width, height, camera, tilesetIndex) + { + var texCoords = tileset.getTileTextureCoordinates(tile.index); + + if (!texCoords) + { + return vOffset; + } + + var tileWidth = tileset.tileWidth; + var tileHeight = tileset.tileHeight; + + var halfTileWidth = tileWidth / 2; + var halfTileHeight = tileHeight / 2; + + var u0 = texCoords.x / width; + var v0 = texCoords.y / height; + var u1 = (texCoords.x + tileWidth) / width; + var v1 = (texCoords.y + tileHeight) / height; + + var matrix = this._tempMatrix; + + var x = -halfTileWidth; + var y = -halfTileHeight; + + if (tile.flipX) + { + tileWidth *= -1; + x += tileset.tileWidth; + } + + if (tile.flipY) + { + tileHeight *= -1; + y += tileset.tileHeight; + } + + var xw = x + tileWidth; + var yh = y + tileHeight; + + matrix.applyITRS(halfTileWidth + tile.pixelX, halfTileHeight + tile.pixelY, tile.rotation, 1, 1); + + var tint = Utils.getTintAppendFloatAlpha(0xffffff, camera.alpha * this.alpha * tile.alpha); + + var tx0 = matrix.getX(x, y); + var ty0 = matrix.getY(x, y); + + var tx1 = matrix.getX(x, yh); + var ty1 = matrix.getY(x, yh); + + var tx2 = matrix.getX(xw, yh); + var ty2 = matrix.getY(xw, yh); + + var tx3 = matrix.getX(xw, y); + var ty3 = matrix.getY(xw, y); + + if (camera.roundPixels) + { + tx0 = Math.round(tx0); + ty0 = Math.round(ty0); + + tx1 = Math.round(tx1); + ty1 = Math.round(ty1); + + tx2 = Math.round(tx2); + ty2 = Math.round(ty2); + + tx3 = Math.round(tx3); + ty3 = Math.round(ty3); + } + + var vertexViewF32 = this.vertexViewF32[tilesetIndex]; + var vertexViewU32 = this.vertexViewU32[tilesetIndex]; + + vertexViewF32[++vOffset] = tx0; + vertexViewF32[++vOffset] = ty0; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx1; + vertexViewF32[++vOffset] = ty1; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx2; + vertexViewF32[++vOffset] = ty2; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx0; + vertexViewF32[++vOffset] = ty0; + vertexViewF32[++vOffset] = u0; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx2; + vertexViewF32[++vOffset] = ty2; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v1; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + vertexViewF32[++vOffset] = tx3; + vertexViewF32[++vOffset] = ty3; + vertexViewF32[++vOffset] = u1; + vertexViewF32[++vOffset] = v0; + vertexViewF32[++vOffset] = 0; + vertexViewU32[++vOffset] = tint; + + this.vertexCount[tilesetIndex] += 6; + + return vOffset; + }, + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setRenderOrder + * @since 3.12.0 + * + * @param {(integer|string)} renderOrder - The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + * + * @return {this} This Tilemap Layer object. + */ + setRenderOrder: function (renderOrder) + { + var orders = [ 'right-down', 'left-down', 'right-up', 'left-up' ]; + + if (typeof renderOrder === 'string') + { + renderOrder = orders.indexOf(renderOrder); + } + + if (renderOrder >= 0 && renderOrder < 4) + { + this._renderOrder = renderOrder; + + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + } } return this; @@ -370,10 +799,10 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#calculateFacesWithin * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The top most tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * * @return {Phaser.Tilemaps.StaticTilemapLayer} This Tilemap Layer object. */ @@ -397,7 +826,7 @@ var StaticTilemapLayer = new Class({ * @param {(integer|array)} replacements - The tile index, or array of indexes, to change a converted * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a * one-to-one mapping with the indexes array. - * @param {object} spriteConfig - The config object to pass into the Sprite creator (i.e. + * @param {SpriteConfig} spriteConfig - The config object to pass into the Sprite creator (i.e. * scene.make.sprite). * @param {Phaser.Scene} [scene=scene the map is within] - The Scene to create the Sprites within. * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when determining the world XY @@ -422,28 +851,59 @@ var StaticTilemapLayer = new Class({ */ cull: function (camera) { - return TilemapComponents.CullTiles(this.layer, camera, this.culledTiles); + return this.cullCallback(this.layer, camera, this.culledTiles); }, /** - * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. * - * @method Phaser.Tilemaps.StaticTilemapLayer#destroy - * @since 3.0.0 + * However, there are some instances when you may wish to disable this. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setSkipCull + * @since 3.12.0 + * + * @param {boolean} [value=true] - Set to `true` to stop culling tiles. Set to `false` to enable culling again. + * + * @return {this} This Tilemap Layer object. */ - destroy: function () + setSkipCull: function (value) { - // Uninstall this layer only if it is still installed on the LayerData object - if (this.layer.tilemapLayer === this) - { - this.layer.tilemapLayer = undefined; - } + if (value === undefined) { value = true; } - this.tilemap = undefined; - this.layer = undefined; - this.tileset = undefined; + this.skipCull = value; - GameObject.prototype.destroy.call(this); + return this; + }, + + /** + * Canvas only. + * + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * + * @method Phaser.Tilemaps.StaticTilemapLayer#setCullPadding + * @since 3.12.0 + * + * @param {integer} [paddingX=1] - The amount of extra horizontal tiles to add to the cull check padding. + * @param {integer} [paddingY=1] - The amount of extra vertical tiles to add to the cull check padding. + * + * @return {this} This Tilemap Layer object. + */ + setCullPadding: function (paddingX, paddingY) + { + if (paddingX === undefined) { paddingX = 1; } + if (paddingY === undefined) { paddingY = 1; } + + this.cullPaddingX = paddingX; + this.cullPaddingY = paddingY; + + return this; }, /** @@ -479,10 +939,10 @@ var StaticTilemapLayer = new Class({ * @param {function} callback - The callback. Each tile in the given area will be passed to this * callback as the first and only parameter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The left most tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The topmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have * -1 for an index. @@ -510,10 +970,10 @@ var StaticTilemapLayer = new Class({ * callback as the first and only parameter. The callback should return true for tiles that pass the * filter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The topmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have * -1 for an index. @@ -539,10 +999,10 @@ var StaticTilemapLayer = new Class({ * @param {function} callback - The callback. Each tile in the given area will be passed to this * callback as the first and only parameter. * @param {object} [context] - The context under which the callback should be run. - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [tileY=0] - The topmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have * -1 for an index. @@ -588,7 +1048,7 @@ var StaticTilemapLayer = new Class({ * @param {number} worldY - Y position to get the tile from (given in pixels) * @param {boolean} [nonNull=false] - If true, function won't return null for empty tiles, but a Tile * object with an index of -1. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {Phaser.Tilemaps.Tile} The tile at the given coordinates or null if no tile was found or the coordinates * were invalid. @@ -604,10 +1064,10 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithin * @since 3.0.0 * - * @param {integer} [tileX=0] - [description] - * @param {integer} [tileY=0] - [description] - * @param {integer} [width=max width based on tileX] - [description] - * @param {integer} [height=max height based on tileY] - [description] + * @param {integer} [tileX=0] - The leftmost tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [tileY=0] - The topmost tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} [width=max width based on tileX] - How many tiles wide from the `tileX` index the area will be. + * @param {integer} [height=max height based on tileY] - How many tiles tall from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have * -1 for an index. @@ -629,10 +1089,10 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#getTilesWithinWorldXY * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {number} width - [description] - * @param {number} height - [description] + * @param {number} worldX - The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {number} worldY - The topmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param {number} width - How many tiles wide from the `tileX` index the area will be. + * @param {number} height - How many tiles high from the `tileY` index the area will be. * @param {object} [filteringOptions] - Optional filters to apply when getting the tiles. * @param {boolean} [filteringOptions.isNotEmpty=false] - If true, only return tiles that don't have * -1 for an index. @@ -640,7 +1100,7 @@ var StaticTilemapLayer = new Class({ * at least one side. * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when factoring in which tiles to return. * * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. */ @@ -664,7 +1124,7 @@ var StaticTilemapLayer = new Class({ * at least one side. * @param {boolean} [filteringOptions.hasInterestingFace=false] - If true, only return tiles that * have at least one interesting face. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {Phaser.Tilemaps.Tile[]} An array of Tile objects. */ @@ -680,8 +1140,8 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAt * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] + * @param {integer} tileX - X position to get the tile from in tile coordinates. + * @param {integer} tileY - Y position to get the tile from in tile coordinates. * * @return {boolean} */ @@ -697,9 +1157,9 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#hasTileAtWorldXY * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {number} worldX - The X coordinate of the world position. + * @param {number} worldY - The Y coordinate of the world position. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {boolean} */ @@ -888,10 +1348,10 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#setTileLocationCallback * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {integer} width - [description] - * @param {integer} height - [description] + * @param {integer} tileX - The leftmost tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} tileY - The topmost tile index (in tile coordinates) to use as the origin of the area. + * @param {integer} width - How many tiles wide from the `tileX` index the area will be. + * @param {integer} height - How many tiles tall from the `tileY` index the area will be. * @param {function} callback - The callback that will be invoked when the tile is collided with. * @param {object} [callbackContext] - The context under which the callback is called. * @@ -911,8 +1371,8 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldX * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {integer} tileX - The X coordinate, in tile coordinates. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index. * * @return {number} */ @@ -928,8 +1388,8 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldY * @since 3.0.0 * - * @param {integer} tileY - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {integer} tileY - The Y coordinate, in tile coordinates. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index. * * @return {number} */ @@ -946,10 +1406,10 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#tileToWorldXY * @since 3.0.0 * - * @param {integer} tileX - [description] - * @param {integer} tileY - [description] - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {integer} tileX - The X coordinate, in tile coordinates. + * @param {integer} tileY - The Y coordinate, in tile coordinates. + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given, a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the world values from the tile index. * * @return {Phaser.Math.Vector2} */ @@ -965,10 +1425,10 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileX * @since 3.0.0 * - * @param {number} worldX - [description] + * @param {number} worldX - The X coordinate, in world pixels. * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values.] * * @return {number} */ @@ -984,10 +1444,10 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileY * @since 3.0.0 * - * @param {number} worldY - [description] + * @param {number} worldY - The Y coordinate, in world pixels. * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the * nearest integer. - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {number} */ @@ -1004,18 +1464,53 @@ var StaticTilemapLayer = new Class({ * @method Phaser.Tilemaps.StaticTilemapLayer#worldToTileXY * @since 3.0.0 * - * @param {number} worldX - [description] - * @param {number} worldY - [description] + * @param {number} worldX - The X coordinate, in world pixels. + * @param {number} worldY - The Y coordinate, in world pixels. * @param {boolean} [snapToFloor=true] - Whether or not to round the tile coordinate down to the * nearest integer. - * @param {Phaser.Math.Vector2} [point] - [description] - * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - [description] + * @param {Phaser.Math.Vector2} [point] - A Vector2 to store the coordinates in. If not given, a new Vector2 is created. + * @param {Phaser.Cameras.Scene2D.Camera} [camera=main camera] - The Camera to use when calculating the tile index from the world values. * * @return {Phaser.Math.Vector2} */ worldToTileXY: function (worldX, worldY, snapToFloor, point, camera) { return TilemapComponents.WorldToTileXY(worldX, worldY, snapToFloor, point, camera, this.layer); + }, + + /** + * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + * + * @method Phaser.Tilemaps.StaticTilemapLayer#destroy + * @since 3.0.0 + */ + destroy: function () + { + // Uninstall this layer only if it is still installed on the LayerData object + if (this.layer.tilemapLayer === this) + { + this.layer.tilemapLayer = undefined; + } + + this.tilemap = undefined; + this.layer = undefined; + this.culledTiles.length = 0; + this.cullCallback = null; + + for (var i = 0; i < this.tileset.length; i++) + { + this.dirty[i] = true; + this.vertexCount[i] = 0; + this.vertexBuffer[i] = null; + this.bufferData[i] = null; + this.vertexViewF32[i] = null; + this.vertexViewU32[i] = null; + } + + this.gidMap = []; + this.tileset = []; + + GameObject.prototype.destroy.call(this); } }); diff --git a/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js b/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js index c838170f5..2fb481cde 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../gameobjects/GameObject'); - /** * Renders this Game Object with the Canvas Renderer to the given Camera. * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. @@ -19,46 +17,106 @@ var GameObject = require('../../gameobjects/GameObject'); * @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call. * @param {number} interpolationPercentage - Reserved for future use and custom pipelines. * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object. + * @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested */ -var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) +var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) + src.cull(camera); + + var renderTiles = src.culledTiles; + var tileCount = renderTiles.length; + + if (tileCount === 0) { return; } - src.cull(camera); + var camMatrix = renderer._tempMatrix1; + var layerMatrix = renderer._tempMatrix2; + var calcMatrix = renderer._tempMatrix3; - var renderTiles = src.culledTiles; - var tileset = this.tileset; - var ctx = renderer.gameContext; - var tileCount = renderTiles.length; - var image = tileset.image.getSourceImage(); - var tx = src.x - camera.scrollX * src.scrollFactorX; - var ty = src.y - camera.scrollY * src.scrollFactorY; + layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY); + + camMatrix.copyFrom(camera.matrix); + + var ctx = renderer.currentContext; + var gidMap = src.gidMap; ctx.save(); - ctx.translate(tx, ty); - ctx.rotate(src.rotation); - ctx.scale(src.scaleX, src.scaleY); - ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); + + if (parentMatrix) + { + // Multiply the camera by the parent matrix + camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY); + + // Undo the camera scroll + layerMatrix.e = src.x; + layerMatrix.f = src.y; + + camMatrix.multiply(layerMatrix, calcMatrix); + + calcMatrix.copyToContext(ctx); + } + else + { + // Undo the camera scroll + layerMatrix.e -= camera.scrollX * src.scrollFactorX; + layerMatrix.f -= camera.scrollY * src.scrollFactorY; + + layerMatrix.copyToContext(ctx); + } + + var alpha = camera.alpha * src.alpha; + ctx.globalAlpha = camera.alpha * src.alpha; - for (var index = 0; index < tileCount; ++index) + for (var i = 0; i < tileCount; i++) { - var tile = renderTiles[index]; + var tile = renderTiles[i]; + var tileset = gidMap[tile.index]; + + if (!tileset) + { + continue; + } + + var image = tileset.image.getSourceImage(); var tileTexCoords = tileset.getTileTextureCoordinates(tile.index); - if (tileTexCoords === null) { continue; } + if (tileTexCoords) + { + var tileWidth = tileset.tileWidth; + var tileHeight = tileset.tileHeight; + var halfWidth = tileWidth / 2; + var halfHeight = tileHeight / 2; + + ctx.save(); - ctx.drawImage( - image, - tileTexCoords.x, tileTexCoords.y, - tile.width, tile.height, - tile.pixelX, tile.pixelY, - tile.width, tile.height - ); + ctx.translate(tile.pixelX + halfWidth, tile.pixelY + halfHeight); + + if (tile.rotation !== 0) + { + ctx.rotate(tile.rotation); + } + + if (tile.flipX || tile.flipY) + { + ctx.scale((tile.flipX) ? -1 : 1, (tile.flipY) ? -1 : 1); + } + + ctx.globalAlpha = alpha * tile.alpha; + + ctx.drawImage( + image, + tileTexCoords.x, tileTexCoords.y, + tileWidth, tileHeight, + -halfWidth, -halfHeight, + tileWidth, tileHeight + ); + + ctx.restore(); + } } ctx.restore(); diff --git a/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js b/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js index 72f7dc73a..231d8f1bd 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js @@ -4,12 +4,13 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var GameObject = require('../../gameobjects/GameObject'); - /** * Renders this Game Object with the WebGL Renderer to the given Camera. + * * The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera. * This method should not be called directly. It is a utility function of the Render module. + * + * A Static Tilemap Layer renders immediately and does not use any batching. * * @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL * @since 3.0.0 @@ -22,14 +23,44 @@ var GameObject = require('../../gameobjects/GameObject'); */ var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) + var tilesets = src.tileset; + + var pipeline = src.pipeline; + var pipelineVertexBuffer = pipeline.vertexBuffer; + + renderer.setPipeline(pipeline); + + pipeline.modelIdentity(); + pipeline.modelTranslate(src.x - (camera.scrollX * src.scrollFactorX), src.y - (camera.scrollY * src.scrollFactorY), 0); + pipeline.modelScale(src.scaleX, src.scaleY, 1); + pipeline.viewLoad2D(camera.matrix.matrix); + + for (var i = 0; i < tilesets.length; i++) { - return; + src.upload(camera, i); + + if (src.vertexCount[i] > 0) + { + if (renderer.currentPipeline && renderer.currentPipeline.vertexCount > 0) + { + renderer.flush(); + } + + pipeline.vertexBuffer = src.vertexBuffer[i]; + + renderer.setPipeline(pipeline); + + renderer.setTexture2D(tilesets[i].glTexture, 0); + + renderer.gl.drawArrays(pipeline.topology, 0, src.vertexCount[i]); + } } - src.upload(camera); + // Restore the pipeline + pipeline.vertexBuffer = pipelineVertexBuffer; - this.pipeline.drawStaticTilemapLayer(src, camera); + pipeline.viewIdentity(); + pipeline.modelIdentity(); }; module.exports = StaticTilemapLayerWebGLRenderer; diff --git a/src/time/Clock.js b/src/time/Clock.js index 325191380..150cacf43 100644 --- a/src/time/Clock.js +++ b/src/time/Clock.js @@ -10,14 +10,14 @@ var TimerEvent = require('./TimerEvent'); /** * @classdesc - * [description] + * The Clock is a Scene plugin which creates and updates Timer Events for its Scene. * * @class Clock - * @memberOf Phaser.Time + * @memberof Phaser.Time * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene which owns this Clock. */ var Clock = new Class({ @@ -26,7 +26,7 @@ var Clock = new Class({ function Clock (scene) { /** - * [description] + * The Scene which owns this Clock. * * @name Phaser.Time.Clock#scene * @type {Phaser.Scene} @@ -35,7 +35,7 @@ var Clock = new Class({ this.scene = scene; /** - * [description] + * The Scene Systems object of the Scene which owns this Clock. * * @name Phaser.Time.Clock#systems * @type {Phaser.Scenes.Systems} @@ -44,7 +44,9 @@ var Clock = new Class({ this.systems = scene.sys; /** - * [description] + * The current time of the Clock, in milliseconds. + * + * If accessed externally, this is equivalent to the `time` parameter normally passed to a Scene's `update` method. * * @name Phaser.Time.Clock#now * @type {number} @@ -56,7 +58,9 @@ var Clock = new Class({ // which then influences anything using this Clock for calculations, like TimerEvents /** - * [description] + * The scale of the Clock's time delta. + * + * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Clock and anything which uses it, such as its Timer Events. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing the Clock. * * @name Phaser.Time.Clock#timeScale * @type {number} @@ -66,7 +70,9 @@ var Clock = new Class({ this.timeScale = 1; /** - * [description] + * Whether the Clock is paused (`true`) or active (`false`). + * + * When paused, the Clock will not update any of its Timer Events, thus freezing time. * * @name Phaser.Time.Clock#paused * @type {boolean} @@ -76,7 +82,7 @@ var Clock = new Class({ this.paused = false; /** - * [description] + * An array of all Timer Events whose delays haven't expired - these are actively updating Timer Events. * * @name Phaser.Time.Clock#_active * @type {Phaser.Time.TimerEvent[]} @@ -87,7 +93,7 @@ var Clock = new Class({ this._active = []; /** - * [description] + * An array of all Timer Events which will be added to the Clock at the start of the frame. * * @name Phaser.Time.Clock#_pendingInsertion * @type {Phaser.Time.TimerEvent[]} @@ -98,7 +104,7 @@ var Clock = new Class({ this._pendingInsertion = []; /** - * [description] + * An array of all Timer Events which will be removed from the Clock at the start of the frame. * * @name Phaser.Time.Clock#_pendingRemoval * @type {Phaser.Time.TimerEvent[]} @@ -144,14 +150,14 @@ var Clock = new Class({ }, /** - * [description] + * Creates a Timer Event and adds it to the Clock at the start of the frame. * * @method Phaser.Time.Clock#addEvent * @since 3.0.0 * - * @param {TimerEventConfig} config - [description] + * @param {TimerEventConfig} config - The configuration for the Timer Event. * - * @return {Phaser.Time.TimerEvent} [description] + * @return {Phaser.Time.TimerEvent} The Timer Event which was created. */ addEvent: function (config) { @@ -163,17 +169,19 @@ var Clock = new Class({ }, /** - * [description] + * Creates a Timer Event and adds it to the Clock at the start of the frame. + * + * This is a shortcut for {@link #addEvent} which can be shorter and is compatible with the syntax of the GreenSock Animation Platform (GSAP). * * @method Phaser.Time.Clock#delayedCall * @since 3.0.0 * - * @param {number} delay - [description] - * @param {function} callback - [description] - * @param {Array.<*>} args - [description] - * @param {*} callbackScope - [description] + * @param {number} delay - The delay of the function call, in milliseconds. + * @param {function} callback - The function to call after the delay expires. + * @param {Array.<*>} args - The arguments to call the function with. + * @param {*} callbackScope - The scope (`this` object) to call the function with. * - * @return {Phaser.Time.TimerEvent} [description] + * @return {Phaser.Time.TimerEvent} The Timer Event which was created. */ delayedCall: function (delay, callback, args, callbackScope) { @@ -181,12 +189,12 @@ var Clock = new Class({ }, /** - * [description] + * Clears and recreates the array of pending Timer Events. * * @method Phaser.Time.Clock#clearPendingEvents * @since 3.0.0 * - * @return {Phaser.Time.Clock} [description] + * @return {Phaser.Time.Clock} This Clock object. */ clearPendingEvents: function () { @@ -196,12 +204,12 @@ var Clock = new Class({ }, /** - * [description] + * Schedules all active Timer Events for removal at the start of the frame. * * @method Phaser.Time.Clock#removeAllEvents * @since 3.0.0 * - * @return {Phaser.Time.Clock} [description] + * @return {Phaser.Time.Clock} This Clock object. */ removeAllEvents: function () { @@ -211,13 +219,13 @@ var Clock = new Class({ }, /** - * [description] + * Updates the arrays of active and pending Timer Events. Called at the start of the frame. * * @method Phaser.Time.Clock#preUpdate * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ preUpdate: function () { @@ -262,13 +270,13 @@ var Clock = new Class({ }, /** - * [description] + * Updates the Clock's internal time and all of its Timer Events. * * @method Phaser.Time.Clock#update * @since 3.0.0 * - * @param {number} time - [description] - * @param {number} delta - [description] + * @param {number} time - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (time, delta) { diff --git a/src/time/TimerEvent.js b/src/time/TimerEvent.js index 1c549655a..28d4fba1a 100644 --- a/src/time/TimerEvent.js +++ b/src/time/TimerEvent.js @@ -10,27 +10,29 @@ var GetFastValue = require('../utils/object/GetFastValue'); /** * @typedef {object} TimerEventConfig * - * @property {number} [delay=0] - [description] - * @property {number} [repeat=0] - [description] - * @property {boolean} [loop=false] - [description] - * @property {function} [callback] - [description] - * @property {*} [callbackScope] - [description] - * @property {Array.<*>} [args] - [description] - * @property {number} [timeScale=1] - [description] - * @property {number} [startAt=1] - [description] - * @property {boolean} [paused=false] - [description] + * @property {number} [delay=0] - The delay after which the Timer Event should fire, in milliseconds. + * @property {number} [repeat=0] - The total number of times the Timer Event will repeat before finishing. + * @property {boolean} [loop=false] - `true` if the Timer Event should repeat indefinitely. + * @property {function} [callback] - The callback which will be called when the Timer Event fires. + * @property {*} [callbackScope] - The scope (`this` object) with which to invoke the `callback`. + * @property {Array.<*>} [args] - Additional arguments to be passed to the `callback`. + * @property {number} [timeScale=1] - The scale of the elapsed time. + * @property {number} [startAt=1] - The initial elapsed time in milliseconds. Useful if you want a long duration with repeat, but for the first loop to fire quickly. + * @property {boolean} [paused=false] - `true` if the Timer Event should be paused. */ /** * @classdesc - * [description] + * A Timer Event represents a delayed function call. It's managed by a Scene's {@link Clock} and will call its function after a set amount of time has passed. The Timer Event can optionally repeat - i.e. call its function multiple times before finishing, or loop indefinitely. + * + * Because it's managed by a Clock, a Timer Event is based on game time, will be affected by its Clock's time scale, and will pause if its Clock pauses. * * @class TimerEvent - * @memberOf Phaser.Time + * @memberof Phaser.Time * @constructor * @since 3.0.0 * - * @param {TimerEventConfig} config - [description] + * @param {TimerEventConfig} config - The configuration for the Timer Event, including its delay and callback. */ var TimerEvent = new Class({ @@ -44,7 +46,7 @@ var TimerEvent = new Class({ * @name Phaser.Time.TimerEvent#delay * @type {number} * @default 0 - * @readOnly + * @readonly * @since 3.0.0 */ this.delay = 0; @@ -55,7 +57,7 @@ var TimerEvent = new Class({ * @name Phaser.Time.TimerEvent#repeat * @type {number} * @default 0 - * @readOnly + * @readonly * @since 3.0.0 */ this.repeat = 0; @@ -76,7 +78,7 @@ var TimerEvent = new Class({ * @name Phaser.Time.TimerEvent#loop * @type {boolean} * @default false - * @readOnly + * @readonly * @since 3.0.0 */ this.loop = false; @@ -129,7 +131,9 @@ var TimerEvent = new Class({ this.startAt = 0; /** - * [description] + * The time in milliseconds which has elapsed since the Timer Event's creation. + * + * This value is local for the Timer Event and is relative to its Clock. As such, it's influenced by the Clock's time scale and paused state, the Timer Event's initial {@link #startAt} property, and the Timer Event's {@link #timeScale} and {@link #paused} state. * * @name Phaser.Time.TimerEvent#elapsed * @type {number} @@ -139,7 +143,7 @@ var TimerEvent = new Class({ this.elapsed = 0; /** - * [description] + * Whether or not this timer is paused. * * @name Phaser.Time.TimerEvent#paused * @type {boolean} @@ -149,7 +153,9 @@ var TimerEvent = new Class({ this.paused = false; /** - * [description] + * Whether the Timer Event's function has been called. + * + * When the Timer Event fires, this property will be set to `true` before the callback function is invoked and will be reset immediately afterward if the Timer Event should repeat. The value of this property does not directly influence whether the Timer Event will be removed from its Clock, but can prevent it from firing. * * @name Phaser.Time.TimerEvent#hasDispatched * @type {boolean} @@ -162,12 +168,12 @@ var TimerEvent = new Class({ }, /** - * [description] + * Completely reinitializes the Timer Event, regardless of its current state, according to a configuration object. * * @method Phaser.Time.TimerEvent#reset * @since 3.0.0 * - * @param {TimerEventConfig} config - [description] + * @param {TimerEventConfig} config - The new state for the Timer Event. * * @return {Phaser.Time.TimerEvent} This TimerEvent object. */ @@ -205,7 +211,7 @@ var TimerEvent = new Class({ * @method Phaser.Time.TimerEvent#getProgress * @since 3.0.0 * - * @return {number} [description] + * @return {number} A number between 0 and 1 representing the current progress. */ getProgress: function () { @@ -218,7 +224,7 @@ var TimerEvent = new Class({ * @method Phaser.Time.TimerEvent#getOverallProgress * @since 3.0.0 * - * @return {number} [description] + * @return {number} The overall progress of the Timer Event, between 0 and 1. */ getOverallProgress: function () { @@ -236,12 +242,14 @@ var TimerEvent = new Class({ }, /** - * [description] + * Returns the number of times this Timer Event will repeat before finishing. + * + * This should not be confused with the number of times the Timer Event will fire before finishing. A return value of 0 doesn't indicate that the Timer Event has finished running - it indicates that it will not repeat after the next time it fires. * * @method Phaser.Time.TimerEvent#getRepeatCount * @since 3.0.0 * - * @return {number} [description] + * @return {number} How many times the Timer Event will repeat. */ getRepeatCount: function () { @@ -249,12 +257,12 @@ var TimerEvent = new Class({ }, /** - * [description] + * Returns the local elapsed time for the current iteration of the Timer Event. * * @method Phaser.Time.TimerEvent#getElapsed * @since 3.0.0 * - * @return {number} [description] + * @return {number} The local elapsed time in milliseconds. */ getElapsed: function () { @@ -262,12 +270,12 @@ var TimerEvent = new Class({ }, /** - * [description] + * Returns the local elapsed time for the current iteration of the Timer Event in seconds. * * @method Phaser.Time.TimerEvent#getElapsedSeconds * @since 3.0.0 * - * @return {number} [description] + * @return {number} The local elapsed time in seconds. */ getElapsedSeconds: function () { @@ -275,12 +283,12 @@ var TimerEvent = new Class({ }, /** - * [description] + * Forces the Timer Event to immediately expire, thus scheduling its removal in the next frame. * * @method Phaser.Time.TimerEvent#remove * @since 3.0.0 * - * @param {function} dispatchCallback - [description] + * @param {function} dispatchCallback - If `true` (by default `false`), the function of the Timer Event will be called before its removal from its Clock. */ remove: function (dispatchCallback) { @@ -294,7 +302,9 @@ var TimerEvent = new Class({ }, /** - * [description] + * Destroys all object references in the Timer Event, i.e. its callback, scope, and arguments. + * + * Normally, this method is only called by the Clock when it shuts down. As such, it doesn't stop the Timer Event. If called manually, the Timer Event will still be updated by the Clock, but it won't do anything when it fires. * * @method Phaser.Time.TimerEvent#destroy * @since 3.0.0 diff --git a/src/tweens/Timeline.js b/src/tweens/Timeline.js index ece97eb99..8ab481664 100644 --- a/src/tweens/Timeline.js +++ b/src/tweens/Timeline.js @@ -11,15 +11,17 @@ var TWEEN_CONST = require('./tween/const'); /** * @classdesc - * [description] + * A Timeline combines multiple Tweens into one. Its overall behavior is otherwise similar to a single Tween. + * + * The Timeline updates all of its Tweens simultaneously. Its methods allow you to easily build a sequence of Tweens (each one starting after the previous one) or run multiple Tweens at once during given parts of the Timeline. * * @class Timeline - * @memberOf Phaser.Tweens + * @memberof Phaser.Tweens * @extends Phaser.Events.EventEmitter * @constructor * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager} manager - [description] + * @param {Phaser.Tweens.TweenManager} manager - The Tween Manager which owns this Timeline. */ var Timeline = new Class({ @@ -32,7 +34,7 @@ var Timeline = new Class({ EventEmitter.call(this); /** - * [description] + * The Tween Manager which owns this Timeline. * * @name Phaser.Tweens.Timeline#manager * @type {Phaser.Tweens.TweenManager} @@ -41,7 +43,7 @@ var Timeline = new Class({ this.manager = manager; /** - * [description] + * A constant value which allows this Timeline to be easily identified as one. * * @name Phaser.Tweens.Timeline#isTimeline * @type {boolean} @@ -243,12 +245,13 @@ var Timeline = new Class({ }, /** - * [description] + * Sets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. * * @method Phaser.Tweens.Timeline#setTimeScale * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The time scale value to set. * * @return {Phaser.Tweens.Timeline} This Timeline object. */ @@ -260,12 +263,12 @@ var Timeline = new Class({ }, /** - * [description] + * Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. * * @method Phaser.Tweens.Timeline#getTimeScale * @since 3.0.0 * - * @return {number} [description] + * @return {number} The value of the time scale applied to this Tween. */ getTimeScale: function () { @@ -273,12 +276,12 @@ var Timeline = new Class({ }, /** - * [description] + * Check whether or not the Timeline is playing. * * @method Phaser.Tweens.Timeline#isPlaying * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if this Timeline is active, otherwise `false`. */ isPlaying: function () { @@ -341,14 +344,14 @@ var Timeline = new Class({ }, /** - * [description] + * Checks whether the offset value is a number or a directive that is relative to previous tweens. * * @method Phaser.Tweens.Timeline#isOffsetAbsolute * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The offset value to be evaluated * - * @return {boolean} [description] + * @return {boolean} True if the result is a number, false if it is a directive like " -= 1000" */ isOffsetAbsolute: function (value) { @@ -356,14 +359,14 @@ var Timeline = new Class({ }, /** - * [description] + * Checks if the offset is a relative value rather than an absolute one. If the value is just a number, this returns false. * * @method Phaser.Tweens.Timeline#isOffsetRelative * @since 3.0.0 * - * @param {string} value - [description] + * @param {string} value - The offset value to be evaluated * - * @return {boolean} [description] + * @return {boolean} Returns true if the value is relative, i.e " -= 1000". If false, the offset is absolute. */ isOffsetRelative: function (value) { @@ -383,15 +386,15 @@ var Timeline = new Class({ }, /** - * [description] + * Parses the relative offset value, returning a positive or negative number. * * @method Phaser.Tweens.Timeline#getRelativeOffset * @since 3.0.0 * - * @param {string} value - [description] - * @param {number} base - [description] + * @param {string} value - The relative offset, in the format of '-=500', for example. The first character determines whether it will be a positive or negative number. Spacing matters here. + * @param {number} base - The value to use as the offset. * - * @return {number} [description] + * @return {number} The returned number value. */ getRelativeOffset: function (value, base) { @@ -415,7 +418,7 @@ var Timeline = new Class({ }, /** - * [description] + * Calculates the total duration of the timeline. Computes all tween's durations and returns the full duration of the timeline. The resulting number is stored in the timeline, not as a return value. * * @method Phaser.Tweens.Timeline#calcDuration * @since 3.0.0 @@ -478,12 +481,12 @@ var Timeline = new Class({ }, /** - * [description] + * Initializes the timeline, which means all Tweens get their init() called, and the total duration will be computed. Returns a boolean indicating whether the timeline is auto-started or not. * * @method Phaser.Tweens.Timeline#init * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} Returns true if the timeline is started. False if it is paused. */ init: function () { @@ -505,12 +508,12 @@ var Timeline = new Class({ }, /** - * [description] + * Resets all of the timeline's tweens back to their initial states. The boolean parameter indicates whether tweens that are looping should reset as well, or not. * * @method Phaser.Tweens.Timeline#resetTweens * @since 3.0.0 * - * @param {boolean} resetFromLoop - [description] + * @param {boolean} resetFromLoop - If true, resets all looping tweens to their initial values. */ resetTweens: function (resetFromLoop) { @@ -523,15 +526,15 @@ var Timeline = new Class({ }, /** - * [description] + * Sets a callback for the Timeline. * * @method Phaser.Tweens.Timeline#setCallback * @since 3.0.0 * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] - * @param {object} [scope] - [description] + * @param {string} type - The internal type of callback to set. + * @param {function} callback - Timeline allows multiple tweens to be linked together to create a streaming sequence. + * @param {array} [params] - The parameters to pass to the callback. + * @param {object} [scope] - The context scope of the callback. * * @return {Phaser.Tweens.Timeline} This Timeline object. */ @@ -561,7 +564,7 @@ var Timeline = new Class({ }, /** - * [description] + * Starts playing the timeline. * * @method Phaser.Tweens.Timeline#play * @since 3.0.0 @@ -666,7 +669,7 @@ var Timeline = new Class({ * @since 3.0.0 * * @param {number} timestamp - [description] - * @param {number} delta - [description] + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. * * @return {boolean} Returns `true` if this Timeline has finished and should be removed from the Tween Manager. */ @@ -772,7 +775,7 @@ var Timeline = new Class({ }, /** - * [description] + * Pauses the timeline, retaining its internal state. * * @method Phaser.Tweens.Timeline#pause * @since 3.0.0 @@ -798,7 +801,7 @@ var Timeline = new Class({ }, /** - * [description] + * Resumes the timeline from where it was when it was paused. * * @method Phaser.Tweens.Timeline#resume * @since 3.0.0 @@ -820,14 +823,14 @@ var Timeline = new Class({ }, /** - * [description] + * Checks if any of the tweens has the target as the object they are operating on. Retuns false if no tweens operate on the target object. * * @method Phaser.Tweens.Timeline#hasTarget * @since 3.0.0 * - * @param {object} target - [description] + * @param {object} target - The target to check all tweens against. * - * @return {boolean} [description] + * @return {boolean} True if there at least a single tween that operates on the target object. False otherwise. */ hasTarget: function (target) { @@ -843,7 +846,7 @@ var Timeline = new Class({ }, /** - * [description] + * Stops all the Tweens in the Timeline immediately, whatever stage of progress they are at and flags them for removal by the TweenManager. * * @method Phaser.Tweens.Timeline#destroy * @since 3.0.0 diff --git a/src/tweens/TweenManager.js b/src/tweens/TweenManager.js index 32ec7feaf..309f0efa4 100644 --- a/src/tweens/TweenManager.js +++ b/src/tweens/TweenManager.js @@ -13,14 +13,14 @@ var TweenBuilder = require('./builders/TweenBuilder'); /** * @classdesc - * [description] + * The Tween Manager is a default Scene Plugin which controls and updates Tweens and Timelines. * * @class TweenManager - * @memberOf Phaser.Tweens + * @memberof Phaser.Tweens * @constructor * @since 3.0.0 * - * @param {Phaser.Scene} scene - [description] + * @param {Phaser.Scene} scene - The Scene which owns this Tween Manager. */ var TweenManager = new Class({ @@ -29,7 +29,7 @@ var TweenManager = new Class({ function TweenManager (scene) { /** - * [description] + * The Scene which owns this Tween Manager. * * @name Phaser.Tweens.TweenManager#scene * @type {Phaser.Scene} @@ -38,7 +38,7 @@ var TweenManager = new Class({ this.scene = scene; /** - * [description] + * The Systems object of the Scene which owns this Tween Manager. * * @name Phaser.Tweens.TweenManager#systems * @type {Phaser.Scenes.Systems} @@ -47,7 +47,9 @@ var TweenManager = new Class({ this.systems = scene.sys; /** - * [description] + * The time scale of the Tween Manager. + * + * This value scales the time delta between two frames, thus influencing the speed of time for all Tweens owned by this Tween Manager. * * @name Phaser.Tweens.TweenManager#timeScale * @type {number} @@ -57,7 +59,7 @@ var TweenManager = new Class({ this.timeScale = 1; /** - * [description] + * An array of Tweens and Timelines which will be added to the Tween Manager at the start of the frame. * * @name Phaser.Tweens.TweenManager#_add * @type {array} @@ -67,7 +69,7 @@ var TweenManager = new Class({ this._add = []; /** - * [description] + * An array of Tweens and Timelines pending to be later added to the Tween Manager. * * @name Phaser.Tweens.TweenManager#_pending * @type {array} @@ -77,7 +79,7 @@ var TweenManager = new Class({ this._pending = []; /** - * [description] + * An array of Tweens and Timelines which are still incomplete and are actively processed by the Tween Manager. * * @name Phaser.Tweens.TweenManager#_active * @type {array} @@ -87,7 +89,7 @@ var TweenManager = new Class({ this._active = []; /** - * [description] + * An array of Tweens and Timelines which will be removed from the Tween Manager at the start of the frame. * * @name Phaser.Tweens.TweenManager#_destroy * @type {array} @@ -97,7 +99,7 @@ var TweenManager = new Class({ this._destroy = []; /** - * [description] + * The number of Tweens and Timelines which need to be processed by the Tween Manager at the start of the frame. * * @name Phaser.Tweens.TweenManager#_toProcess * @type {integer} @@ -150,9 +152,9 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#createTimeline * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object for the Timeline and its Tweens. * - * @return {Phaser.Tweens.Timeline} [description] + * @return {Phaser.Tweens.Timeline} The created Timeline object. */ createTimeline: function (config) { @@ -165,9 +167,9 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#timeline * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object for the Timeline and its Tweens. * - * @return {Phaser.Tweens.Timeline} [description] + * @return {Phaser.Tweens.Timeline} The created Timeline object. */ timeline: function (config) { @@ -189,9 +191,9 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#create * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object for the Tween as per {@link Phaser.Tweens.Builders.TweenBuilder}. * - * @return {Phaser.Tweens.Tween} [description] + * @return {Phaser.Tweens.Tween} The created Tween object. */ create: function (config) { @@ -204,9 +206,9 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#add * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object for the Tween as per the {@link Phaser.Tweens.Builders.TweenBuilder}. * - * @return {Phaser.Tweens.Tween} [description] + * @return {Phaser.Tweens.Tween} The created Tween. */ add: function (config) { @@ -225,7 +227,7 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#existing * @since 3.0.0 * - * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.Tween} tween - The Tween to add. * * @return {Phaser.Tweens.TweenManager} This Tween Manager object. */ @@ -244,9 +246,9 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#addCounter * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object for the Number Tween as per the {@link Phaser.Tweens.Builders.NumberTweenBuilder}. * - * @return {Phaser.Tweens.Tween} [description] + * @return {Phaser.Tweens.Tween} The created Number Tween. */ addCounter: function (config) { @@ -260,7 +262,9 @@ var TweenManager = new Class({ }, /** - * [description] + * Updates the Tween Manager's internal lists at the start of the frame. + * + * This method will return immediately if no changes have been indicated. * * @method Phaser.Tweens.TweenManager#preUpdate * @since 3.0.0 @@ -275,6 +279,7 @@ var TweenManager = new Class({ var list = this._destroy; var active = this._active; + var pending = this._pending; var i; var tween; @@ -286,7 +291,18 @@ var TweenManager = new Class({ // Remove from the 'active' array var idx = active.indexOf(tween); - if (idx !== -1) + if (idx === -1) + { + // Not in the active array, is it in pending instead? + idx = pending.indexOf(tween); + + if (idx > -1) + { + tween.state = TWEEN_CONST.REMOVED; + pending.splice(idx, 1); + } + } + else { tween.state = TWEEN_CONST.REMOVED; active.splice(idx, 1); @@ -326,13 +342,13 @@ var TweenManager = new Class({ }, /** - * [description] + * Updates all Tweens and Timelines of the Tween Manager. * * @method Phaser.Tweens.TweenManager#update * @since 3.0.0 * - * @param {number} timestamp - [description] - * @param {number} delta - [description] + * @param {number} timestamp - The current time in milliseconds. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update: function (timestamp, delta) { @@ -358,12 +374,12 @@ var TweenManager = new Class({ }, /** - * [description] + * Checks if a Tween or Timeline is active and adds it to the Tween Manager at the start of the frame if it isn't. * * @method Phaser.Tweens.TweenManager#makeActive * @since 3.0.0 * - * @param {Phaser.Tweens.Tween} tween - [description] + * @param {Phaser.Tweens.Tween} tween - The Tween to check. * * @return {Phaser.Tweens.TweenManager} This Tween Manager object. */ @@ -396,9 +412,9 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#each * @since 3.0.0 * - * @param {function} callback - [description] - * @param {object} [scope] - [description] - * @param {...*} [args] - [description] + * @param {function} callback - The function to call. + * @param {object} [scope] - The scope (`this` object) to call the function with. + * @param {...*} [args] - The arguments to pass into the function. Its first argument will always be the Tween currently being iterated. */ each: function (callback, scope) { @@ -418,12 +434,12 @@ var TweenManager = new Class({ }, /** - * [description] + * Returns an array of all active Tweens and Timelines in the Tween Manager. * * @method Phaser.Tweens.TweenManager#getAllTweens * @since 3.0.0 * - * @return {Phaser.Tweens.Tween[]} [description] + * @return {Phaser.Tweens.Tween[]} A new array containing references to all active Tweens and Timelines. */ getAllTweens: function () { @@ -439,12 +455,12 @@ var TweenManager = new Class({ }, /** - * [description] + * Returns the scale of the time delta for all Tweens and Timelines owned by this Tween Manager. * * @method Phaser.Tweens.TweenManager#getGlobalTimeScale * @since 3.0.0 * - * @return {number} [description] + * @return {number} The scale of the time delta, usually 1. */ getGlobalTimeScale: function () { @@ -452,14 +468,14 @@ var TweenManager = new Class({ }, /** - * [description] + * Returns an array of all Tweens or Timelines in the Tween Manager which affect the given target or array of targets. * * @method Phaser.Tweens.TweenManager#getTweensOf * @since 3.0.0 * - * @param {(object|array)} target - [description] + * @param {(object|array)} target - The target to look for. Provide an array to look for multiple targets. * - * @return {Phaser.Tweens.Tween[]} [description] + * @return {Phaser.Tweens.Tween[]} A new array containing all Tweens and Timelines which affect the given target(s). */ getTweensOf: function (target) { @@ -500,14 +516,14 @@ var TweenManager = new Class({ }, /** - * [description] + * Checks if the given object is being affected by a playing Tween. * * @method Phaser.Tweens.TweenManager#isTweening * @since 3.0.0 * - * @param {object} target - [description] + * @param {object} target - target Phaser.Tweens.Tween object * - * @return {boolean} [description] + * @return {boolean} returns if target tween object is active or not */ isTweening: function (target) { @@ -528,12 +544,12 @@ var TweenManager = new Class({ }, /** - * [description] + * Stops all Tweens in this Tween Manager. They will be removed at the start of the frame. * * @method Phaser.Tweens.TweenManager#killAll * @since 3.0.0 * - * @return {Phaser.Tweens.TweenManager} [description] + * @return {Phaser.Tweens.TweenManager} This Tween Manager. */ killAll: function () { @@ -548,14 +564,16 @@ var TweenManager = new Class({ }, /** - * [description] + * Stops all Tweens which affect the given target or array of targets. The Tweens will be removed from the Tween Manager at the start of the frame. + * + * @see {@link #getTweensOf} * * @method Phaser.Tweens.TweenManager#killTweensOf * @since 3.0.0 * - * @param {(object|array)} target - [description] + * @param {(object|array)} target - The target to look for. Provide an array to look for multiple targets. * - * @return {Phaser.Tweens.TweenManager} [description] + * @return {Phaser.Tweens.TweenManager} This Tween Manager. */ killTweensOf: function (target) { @@ -570,12 +588,12 @@ var TweenManager = new Class({ }, /** - * [description] + * Pauses all Tweens in this Tween Manager. * * @method Phaser.Tweens.TweenManager#pauseAll * @since 3.0.0 * - * @return {Phaser.Tweens.TweenManager} [description] + * @return {Phaser.Tweens.TweenManager} This Tween Manager. */ pauseAll: function () { @@ -590,12 +608,12 @@ var TweenManager = new Class({ }, /** - * [description] + * Resumes all Tweens in this Tween Manager. * * @method Phaser.Tweens.TweenManager#resumeAll * @since 3.0.0 * - * @return {Phaser.Tweens.TweenManager} [description] + * @return {Phaser.Tweens.TweenManager} This Tween Manager. */ resumeAll: function () { @@ -610,14 +628,16 @@ var TweenManager = new Class({ }, /** - * [description] + * Sets a new scale of the time delta for this Tween Manager. + * + * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Tween Manager and all Tweens it owns. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing all Tweens. * * @method Phaser.Tweens.TweenManager#setGlobalTimeScale * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The new scale of the time delta, where 1 is the normal speed. * - * @return {Phaser.Tweens.TweenManager} [description] + * @return {Phaser.Tweens.TweenManager} This Tween Manager. */ setGlobalTimeScale: function (value) { diff --git a/src/tweens/builders/GetBoolean.js b/src/tweens/builders/GetBoolean.js index 5d135de13..1fb2901bf 100644 --- a/src/tweens/builders/GetBoolean.js +++ b/src/tweens/builders/GetBoolean.js @@ -5,16 +5,16 @@ */ /** - * [description] + * Retrieves the value of the given key from an object. * * @function Phaser.Tweens.Builders.GetBoolean * @since 3.0.0 * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The key to look for in the `source` object. + * @param {*} defaultValue - The default value to return if the `key` doesn't exist or if no `source` object is provided. * - * @return {*} [description] + * @return {*} The retrieved value. */ var GetBoolean = function (source, key, defaultValue) { diff --git a/src/tweens/builders/GetProps.js b/src/tweens/builders/GetProps.js index d72144ca5..f2bc8c018 100644 --- a/src/tweens/builders/GetProps.js +++ b/src/tweens/builders/GetProps.js @@ -12,9 +12,9 @@ var RESERVED = require('../tween/ReservedProps'); * @function Phaser.Tweens.Builders.GetProps * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object of the tween to get the target(s) from. * - * @return {array} [description] + * @return {array} An array of all the targets the tween is operating on. */ var GetProps = function (config) { diff --git a/src/tweens/builders/GetTargets.js b/src/tweens/builders/GetTargets.js index 3a8d814da..0963c3e7c 100644 --- a/src/tweens/builders/GetTargets.js +++ b/src/tweens/builders/GetTargets.js @@ -7,14 +7,16 @@ var GetValue = require('../../utils/object/GetValue'); /** - * [description] + * Extracts an array of targets from a Tween configuration object. + * + * The targets will be looked for in a `targets` property. If it's a function, its return value will be used as the result. * * @function Phaser.Tweens.Builders.GetTargets * @since 3.0.0 * - * @param {object} config - [description] + * @param {object} config - The configuration object to use. * - * @return {array} [description] + * @return {array} An array of targets (may contain only one element), or `null` if no targets were specified. */ var GetTargets = function (config) { diff --git a/src/tweens/builders/GetTweens.js b/src/tweens/builders/GetTweens.js index f42a33655..0ffcdac6c 100644 --- a/src/tweens/builders/GetTweens.js +++ b/src/tweens/builders/GetTweens.js @@ -7,7 +7,7 @@ var GetValue = require('../../utils/object/GetValue'); /** - * [description] + * Returns an array of all tweens in the given config * * @function Phaser.Tweens.Builders.GetTweens * @since 3.0.0 diff --git a/src/tweens/builders/GetValueOp.js b/src/tweens/builders/GetValueOp.js index d9fa6a00e..8abcd9025 100644 --- a/src/tweens/builders/GetValueOp.js +++ b/src/tweens/builders/GetValueOp.js @@ -20,15 +20,17 @@ function hasGetters (def) } /** - * [description] + * Returns `getStart` and `getEnd` functions for a Tween's Data based on a target property and end value. + * + * If the end value is a number, it will be treated as an absolute value and the property will be tweened to it. A string can be provided to specify a relative end value which consists of an operation (`+=` to add to the current value, `-=` to subtract from the current value, `*=` to multiply the current value, or `/=` to divide the current value) followed by its operand. A function can be provided to allow greater control over the end value; it will receive the target object being tweened, the name of the property being tweened, and the current value of the property as its arguments. If both the starting and the ending values need to be controlled, an object with `getStart` and `getEnd` callbacks, which will receive the same arguments, can be provided instead. If an object with a `value` property is provided, the property will be used as the effective value under the same rules described here. * * @function Phaser.Tweens.Builders.GetValueOp * @since 3.0.0 * - * @param {string} key - [description] - * @param {*} propertyValue - [description] + * @param {string} key - The name of the property to modify. + * @param {*} propertyValue - The ending value of the property, as described above. * - * @return {function} [description] + * @return {function} An array of two functions, `getStart` and `getEnd`, which return the starting and the ending value of the property based on the provided value. */ var GetValueOp = function (key, propertyValue) { diff --git a/src/tweens/builders/TimelineBuilder.js b/src/tweens/builders/TimelineBuilder.js index 2a6ff9079..a282527b6 100644 --- a/src/tweens/builders/TimelineBuilder.js +++ b/src/tweens/builders/TimelineBuilder.js @@ -17,15 +17,44 @@ var Timeline = require('../Timeline'); var TweenBuilder = require('./TweenBuilder'); /** - * [description] + * Builds a Timeline of Tweens based on a configuration object. + * + * The configuration object (`config`) can have the following properties: + * + * `tweens` - an array of tween configuration objects to create and add into the new Timeline, as described by `TweenBuilder`. If this doesn't exist or is empty, the Timeline will start off paused and none of the other configuration settings will be read. If it's a function, it will be called and its return value will be used as the array. + * `targets` - an array (or function which returns one) of default targets to which to apply the Timeline. Each individual Tween configuration can override this value. + * `totalDuration` - if specified, each Tween in the Timeline will get an equal portion of this duration, usually in milliseconds, by default. Each individual Tween configuration can override the Tween's duration. + * `duration` - if `totalDuration` is not specified, the default duration, usually in milliseconds, of each Tween which will be created. Each individual Tween configuration can override the Tween's duration. + * `delay`, `easeParams`, `ease`, `hold`, `repeat`, `repeatDelay`, `yoyo`, `flipX`, `flipY` - the default settings for each Tween which will be created, as specified by `TweenBuilder`. Each individual Tween configuration can override any of these values. + * `completeDelay` - if specified, the time to wait, usually in milliseconds, before the Timeline completes. + * `loop` - how many times the Timeline should loop, or -1 to loop indefinitely. + * `loopDelay` - the time, usually in milliseconds, between each loop + * `paused` - if `true`, the Timeline will start paused + * `useFrames` - if `true`, all duration in the Timeline will be in frames instead of milliseconds + * `callbackScope` - the default scope (`this` value) to use for each callback registered by the Timeline Builder. If not specified, the Timeline itself will be used. + * `onStart` - if specified, the `onStart` callback for the Timeline, called every time it starts playing + * `onStartScope` - the scope (`this` value) to use for the `onStart` callback. If not specified, the `callbackScope` will be used. + * `onStartParams` - additional arguments to pass to the `onStart` callback. The Timeline will always be the first argument. + * `onUpdate` - if specified, the `onUpdate` callback for the Timeline, called every frame it's active, regardless of its Tweens + * `onUpdateScope` - the scope (`this` value) to use for the `onUpdate` callback. If not specified, the `callbackScope` will be used. + * `onUpdateParams` - additional arguments to pass to the `onUpdate` callback. The Timeline will always be the first argument. + * `onLoop` - if specified, the `onLoop` callback for the Timeline, called every time it loops + * `onLoopScope` - the scope (`this` value) to use for the `onLoop` callback. If not specified, the `callbackScope` will be used. + * `onLoopParams` - additional arguments to pass to the `onLoop` callback. The Timeline will always be the first argument. + * `onYoyo` - if specified, the `onYoyo` callback for the Timeline, called every time it yoyos + * `onYoyoScope` - the scope (`this` value) to use for the `onYoyo` callback. If not specified, the `callbackScope` will be used. + * `onYoyoParams` - additional arguments to pass to the `onYoyo` callback. The first argument will always be `null`, while the Timeline will always be the second argument. + * `onComplete` - if specified, the `onComplete` callback for the Timeline, called after it completes + * `onCompleteScope` - the scope (`this` value) to use for the `onComplete` callback. If not specified, the `callbackScope` will be used. + * `onCompleteParams` - additional arguments to pass to the `onComplete` callback. The Timeline will always be the first argument. * * @function Phaser.Tweens.Builders.TimelineBuilder * @since 3.0.0 * - * @param {Phaser.Tweens.TweenManager} manager - [description] - * @param {object} config - [description] + * @param {Phaser.Tweens.TweenManager} manager - The Tween Manager to which the Timeline will belong. + * @param {object} config - The configuration object for the Timeline, as described above. * - * @return {Phaser.Tweens.Timeline} [description] + * @return {Phaser.Tweens.Timeline} The created Timeline. */ var TimelineBuilder = function (manager, config) { diff --git a/src/tweens/builders/TweenBuilder.js b/src/tweens/builders/TweenBuilder.js index 8d1d92af9..c9102f926 100644 --- a/src/tweens/builders/TweenBuilder.js +++ b/src/tweens/builders/TweenBuilder.js @@ -24,7 +24,33 @@ var TweenData = require('../tween/TweenData'); * * @param {(Phaser.Tweens.TweenManager|Phaser.Tweens.Timeline)} parent - [description] * @param {object} config - [description] - * @param {Phaser.Tweens.TweenConfigDefaults} defaults - [description] + * @param {Phaser.Tweens.TweenConfigDefaults} defaults - Tween configuration defaults. +` + * @property {(object|object[])} targets - The object, or an array of objects, to run the tween on. + * @property {number} [delay=0] - The number of milliseconds to delay before the tween will start. + * @property {number} [duration=1000] - The duration of the tween in milliseconds. + * @property {string} [ease='Power0'] - The easing equation to use for the tween. + * @property {array} [easeParams] - Optional easing parameters. + * @property {number} [hold=0] - The number of milliseconds to hold the tween for before yoyo'ing. + * @property {number} [repeat=0] - The number of times to repeat the tween. + * @property {number} [repeatDelay=0] - The number of milliseconds to pause before a tween will repeat. + * @property {boolean} [yoyo=false] - Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete. + * @property {boolean} [flipX=false] - Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property. + * @property {boolean} [flipY=false] - Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property. +` +{ + targets: null, + delay: 0, + duration: 1000, + ease: 'Power0', + easeParams: null, + hold: 0, + repeat: 0, + repeatDelay: 0, + yoyo: false, + flipX: false, + flipY: false +}; * * @return {Phaser.Tweens.Tween} [description] */ diff --git a/src/tweens/tween/Defaults.js b/src/tweens/tween/Defaults.js index 06dc9471b..eefd0cfb4 100644 --- a/src/tweens/tween/Defaults.js +++ b/src/tweens/tween/Defaults.js @@ -7,17 +7,17 @@ /** * @typedef {object} Phaser.Tweens.TweenConfigDefaults * - * @property {(object|object[])} targets - [description] - * @property {number} [delay=0] - [description] - * @property {number} [duration=1000] - [description] - * @property {string} [ease='Power0'] - [description] - * @property {array} [easeParams] - [description] - * @property {number} [hold=0] - [description] - * @property {number} [repeat=0] - [description] - * @property {number} [repeatDelay=0] - [description] - * @property {boolean} [yoyo=false] - [description] - * @property {boolean} [flipX=false] - [description] - * @property {boolean} [flipY=false] - [description] + * @property {(object|object[])} targets - The object, or an array of objects, to run the tween on. + * @property {number} [delay=0] - The number of milliseconds to delay before the tween will start. + * @property {number} [duration=1000] - The duration of the tween in milliseconds. + * @property {string} [ease='Power0'] - The easing equation to use for the tween. + * @property {array} [easeParams] - Optional easing parameters. + * @property {number} [hold=0] - The number of milliseconds to hold the tween for before yoyo'ing. + * @property {number} [repeat=0] - The number of times to repeat the tween. + * @property {number} [repeatDelay=0] - The number of milliseconds to pause before a tween will repeat. + * @property {boolean} [yoyo=false] - Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete. + * @property {boolean} [flipX=false] - Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property. + * @property {boolean} [flipY=false] - Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property. */ var TWEEN_DEFAULTS = { diff --git a/src/tweens/tween/Tween.js b/src/tweens/tween/Tween.js index 92845ac41..66624c25b 100644 --- a/src/tweens/tween/Tween.js +++ b/src/tweens/tween/Tween.js @@ -14,7 +14,7 @@ var TWEEN_CONST = require('./const'); * [description] * * @class Tween - * @memberOf Phaser.Tweens + * @memberof Phaser.Tweens * @constructor * @since 3.0.0 * @@ -284,7 +284,7 @@ var Tween = new Class({ }, /** - * [description] + * Returns the current value of the Tween. * * @method Phaser.Tweens.Tween#getValue * @since 3.0.0 @@ -297,12 +297,12 @@ var Tween = new Class({ }, /** - * [description] + * Set the scale the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. * * @method Phaser.Tweens.Tween#setTimeScale * @since 3.0.0 * - * @param {number} value - [description] + * @param {number} value - The scale factor for timescale. * * @return {Phaser.Tweens.Tween} This Tween object. */ @@ -314,12 +314,12 @@ var Tween = new Class({ }, /** - * [description] + * Returns the scale of the time applied to this Tween. * * @method Phaser.Tweens.Tween#getTimeScale * @since 3.0.0 * - * @return {number} [description] + * @return {number} The timescale of this tween (between 0 and 1) */ getTimeScale: function () { @@ -327,12 +327,12 @@ var Tween = new Class({ }, /** - * [description] + * Checks if the Tween is currently active. * * @method Phaser.Tweens.Tween#isPlaying * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if the Tween is active, otherwise `false`. */ isPlaying: function () { @@ -340,12 +340,12 @@ var Tween = new Class({ }, /** - * [description] + * Checks if the Tween is currently paused. * * @method Phaser.Tweens.Tween#isPaused * @since 3.0.0 * - * @return {boolean} [description] + * @return {boolean} `true` if the Tween is paused, otherwise `false`. */ isPaused: function () { @@ -353,7 +353,7 @@ var Tween = new Class({ }, /** - * [description] + * See if this Tween is currently acting upon the given target. * * @method Phaser.Tweens.Tween#hasTarget * @since 3.0.0 @@ -402,7 +402,7 @@ var Tween = new Class({ }, /** - * [description] + * Restarts the tween from the beginning. * * @method Phaser.Tweens.Tween#restart * @since 3.0.0 @@ -723,7 +723,7 @@ var Tween = new Class({ }, /** - * [description] + * Resumes the playback of a previously paused Tween. * * @method Phaser.Tweens.Tween#resume * @since 3.0.0 @@ -828,9 +828,9 @@ var Tween = new Class({ * @method Phaser.Tweens.Tween#setCallback * @since 3.0.0 * - * @param {string} type - [description] - * @param {function} callback - [description] - * @param {array} [params] - [description] + * @param {string} type - Type of the callback. + * @param {function} callback - Callback function. + * @param {array} [params] - An array of parameters for specified callbacks types. * @param {object} [scope] - [description] * * @return {Phaser.Tweens.Tween} This Tween object. @@ -899,6 +899,12 @@ var Tween = new Class({ if (this.state !== TWEEN_CONST.REMOVED) { + if (this.state === TWEEN_CONST.PAUSED || this.state === TWEEN_CONST.PENDING_ADD) + { + this.parent._destroy.push(this); + this.parent._toProcess++; + } + this.state = TWEEN_CONST.PENDING_REMOVE; } }, @@ -909,8 +915,8 @@ var Tween = new Class({ * @method Phaser.Tweens.Tween#update * @since 3.0.0 * - * @param {number} timestamp - [description] - * @param {number} delta - [description] + * @param {number} timestamp - The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. * * @return {boolean} Returns `true` if this Tween has finished and should be removed from the Tween Manager, otherwise returns `false`. */ @@ -1120,7 +1126,7 @@ var Tween = new Class({ * @since 3.0.0 * * @param {Phaser.Tweens.Tween} tween - [description] - * @param {Phaser.Tweens.TweenDataConfig} tweenData - [description] + * @param {Phaser.Tweens.TweenDataConfig} tweenData - A TweenData object contains all the information related to a tween. Created by and belongs to a Phaser.Tween object. * @param {number} diff - [description] * * @return {integer} The state of this Tween. @@ -1177,7 +1183,6 @@ var Tween = new Class({ return TWEEN_CONST.COMPLETE; }, - // /** * [description] * diff --git a/src/tweens/tween/TweenData.js b/src/tweens/tween/TweenData.js index 779c92fc0..6146f8081 100644 --- a/src/tweens/tween/TweenData.js +++ b/src/tweens/tween/TweenData.js @@ -7,11 +7,11 @@ /** * @typedef {object} TweenDataGenConfig * - * @property {function} delay - [description] - * @property {function} duration - [description] - * @property {function} hold - [description] - * @property {function} repeat - [description] - * @property {function} repeatDelay - [description] + * @property {function} delay - Time in ms/frames before tween will start. + * @property {function} duration - Duration of the tween in ms/frames, excludes time for yoyo or repeats. + * @property {function} hold - Time in ms/frames the tween will pause before running the yoyo or starting a repeat. + * @property {function} repeat - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + * @property {function} repeatDelay - Time in ms/frames before the repeat will start. */ /** @@ -44,26 +44,28 @@ */ /** - * [description] + * Returns a TweenDataConfig object that describes the tween data for a unique property of a unique target. A single Tween consists of multiple TweenDatas, depending on how many properties are being changed by the Tween. + * + * This is an internal function used by the TweenBuilder and should not be accessed directly, instead, Tweens should be created using the GameObjectFactory or GameObjectCreator. * * @function Phaser.Tweens.TweenData * @since 3.0.0 * - * @param {object} target - [description] - * @param {string} key - [description] - * @param {function} getEnd - [description] - * @param {function} getStart - [description] - * @param {function} ease - [description] - * @param {number} delay - [description] - * @param {number} duration - [description] - * @param {boolean} yoyo - [description] - * @param {number} hold - [description] - * @param {number} repeat - [description] - * @param {number} repeatDelay - [description] - * @param {boolean} flipX - [description] - * @param {boolean} flipY - [description] + * @param {object} target - The target to tween. + * @param {string} key - The property of the target to tween. + * @param {function} getEnd - What the property will be at the END of the Tween. + * @param {function} getStart - What the property will be at the START of the Tween. + * @param {function} ease - The ease function this tween uses. + * @param {number} delay - Time in ms/frames before tween will start. + * @param {number} duration - Duration of the tween in ms/frames. + * @param {boolean} yoyo - Determines whether the tween should return back to its start value after hold has expired. + * @param {number} hold - Time in ms/frames the tween will pause before repeating or returning to its starting value if yoyo is set to true. + * @param {number} repeat - Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + * @param {number} repeatDelay - Time in ms/frames before the repeat will start. + * @param {boolean} flipX - Should toggleFlipX be called when yoyo or repeat happens? + * @param {boolean} flipY - Should toggleFlipY be called when yoyo or repeat happens? * - * @return {TweenDataConfig} [description] + * @return {TweenDataConfig} The config object describing this TweenData. */ var TweenData = function (target, key, getEnd, getStart, ease, delay, duration, yoyo, hold, repeat, repeatDelay, flipX, flipY) { diff --git a/src/utils/array/FindClosestInSorted.js b/src/utils/array/FindClosestInSorted.js index 8cc1c417a..b3cb13680 100644 --- a/src/utils/array/FindClosestInSorted.js +++ b/src/utils/array/FindClosestInSorted.js @@ -5,7 +5,10 @@ */ /** - * [description] + * Searches a pre-sorted array for the closet value to the given number. + * + * If the `key` argument is given it will assume the array contains objects that all have the required `key` property name, + * and will check for the closest value of those to the given number. * * @function Phaser.Utils.Array.FindClosestInSorted * @since 3.0.0 @@ -14,7 +17,7 @@ * @param {array} array - The array to search, which must be sorted. * @param {string} [key] - An optional property key. If specified the array elements property will be checked against value. * - * @return {number|object} The nearest value found in the array, or if a `key` was given, the nearest object with the matching property value. + * @return {(number|any)} The nearest value found in the array, or if a `key` was given, the nearest object with the matching property value. */ var FindClosestInSorted = function (value, array, key) { diff --git a/src/utils/array/MoveUp.js b/src/utils/array/MoveUp.js index 7b61e7440..a66668014 100644 --- a/src/utils/array/MoveUp.js +++ b/src/utils/array/MoveUp.js @@ -20,10 +20,10 @@ var MoveUp = function (array, item) { var currentIndex = array.indexOf(item); - if (currentIndex !== -1 && currentIndex < array.length - 2) + if (currentIndex !== -1 && currentIndex < array.length - 1) { + // The element one above `item` in the array var item2 = array[currentIndex + 1]; - var index2 = array.indexOf(item2); array[currentIndex] = item2; diff --git a/src/utils/array/NumberArrayStep.js b/src/utils/array/NumberArrayStep.js index 51d3f2317..5c99c8bc1 100644 --- a/src/utils/array/NumberArrayStep.js +++ b/src/utils/array/NumberArrayStep.js @@ -41,7 +41,7 @@ var RoundAwayFromZero = require('../../math/RoundAwayFromZero'); * @param {number} [end=null] - The end of the range. * @param {number} [step=1] - The value to increment or decrement by. * - * @return {number[]} [description] + * @return {number[]} The array of number values. */ var NumberArrayStep = function (start, end, step) { diff --git a/src/utils/array/QuickSelect.js b/src/utils/array/QuickSelect.js index 62a8a6fbf..7943ab6b0 100644 --- a/src/utils/array/QuickSelect.js +++ b/src/utils/array/QuickSelect.js @@ -4,32 +4,42 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// This is from the quickselect npm package: https://www.npmjs.com/package/quickselect -// Coded by https://www.npmjs.com/~mourner (Vladimir Agafonkin) +function swap (arr, i, j) +{ + var tmp = arr[i]; + arr[i] = arr[j]; + arr[j] = tmp; +} -// https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm - -// Floyd-Rivest selection algorithm: -// Rearrange items so that all items in the [left, k] range are smaller than all items in (k, right]; -// The k-th element will have the (k - left + 1)th smallest value in [left, right] +function defaultCompare (a, b) +{ + return a < b ? -1 : a > b ? 1 : 0; +} /** - * [description] + * A [Floyd-Rivest](https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm) quick selection algorithm. + * + * Rearranges the array items so that all items in the [left, k] range are smaller than all items in [k, right]; + * The k-th element will have the (k - left + 1)th smallest value in [left, right]. + * + * The array is modified in-place. + * + * Based on code by [Vladimir Agafonkin](https://www.npmjs.com/~mourner) * * @function Phaser.Utils.Array.QuickSelect * @since 3.0.0 * - * @param {array} arr - [description] - * @param {number} k - [description] - * @param {number} left - [description] - * @param {number} right - [description] - * @param {function} compare - [description] + * @param {array} arr - The array to sort. + * @param {integer} k - The k-th element index. + * @param {integer} [left=0] - The index of the left part of the range. + * @param {integer} [right] - The index of the right part of the range. + * @param {function} [compare] - An optional comparison function. Is passed two elements and should return 0, 1 or -1. */ var QuickSelect = function (arr, k, left, right, compare) { - left = left || 0; - right = right || (arr.length - 1); - compare = compare || defaultCompare; + if (left === undefined) { left = 0; } + if (right === undefined) { right = arr.length - 1; } + if (compare === undefined) { compare = defaultCompare; } while (right > left) { @@ -97,16 +107,4 @@ var QuickSelect = function (arr, k, left, right, compare) } }; -function swap (arr, i, j) -{ - var tmp = arr[i]; - arr[i] = arr[j]; - arr[j] = tmp; -} - -function defaultCompare (a, b) -{ - return a < b ? -1 : a > b ? 1 : 0; -} - module.exports = QuickSelect; diff --git a/src/utils/array/Range.js b/src/utils/array/Range.js index 8d6333b29..c79649c27 100644 --- a/src/utils/array/Range.js +++ b/src/utils/array/Range.js @@ -25,47 +25,45 @@ var BuildChunk = function (a, b, qty) return out; }; -// options = repeat, random, randomB, yoyo, max, qty - -// Range ([a,b,c], [1,2,3]) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2,3], qty = 3) = -// a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 - -// Range ([a,b,c], [1,2,3], repeat x1) = -// a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 - -// Range ([a,b], [1,2], repeat -1 = endless, max = 14) = -// Maybe if max is set then repeat goes to -1 automatically? -// a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) - -// Range ([a], [1,2,3,4,5], random = true) = -// a4, a1, a5, a2, a3 - -// Range ([a, b], [1,2,3], random = true) = -// b3, a2, a1, b1, a3, b2 - -// Range ([a, b, c], [1,2,3], randomB = true) = -// a3, a1, a2, b2, b3, b1, c1, c3, c2 - -// Range ([a], [1,2,3,4,5], yoyo = true) = -// a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 - -// Range ([a, b], [1,2,3], yoyo = true) = -// a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 - /** - * [description] + * Creates an array populated with a range of values, based on the given arguments and configuration object. + * + * Range ([a,b,c], [1,2,3]) = + * a1, a2, a3, b1, b2, b3, c1, c2, c3 + * + * Range ([a,b], [1,2,3], qty = 3) = + * a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 + * + * Range ([a,b,c], [1,2,3], repeat x1) = + * a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 + * + * Range ([a,b], [1,2], repeat -1 = endless, max = 14) = + * Maybe if max is set then repeat goes to -1 automatically? + * a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) + * + * Range ([a], [1,2,3,4,5], random = true) = + * a4, a1, a5, a2, a3 + * + * Range ([a, b], [1,2,3], random = true) = + * b3, a2, a1, b1, a3, b2 + * + * Range ([a, b, c], [1,2,3], randomB = true) = + * a3, a1, a2, b2, b3, b1, c1, c3, c2 + * + * Range ([a], [1,2,3,4,5], yoyo = true) = + * a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 + * + * Range ([a, b], [1,2,3], yoyo = true) = + * a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 * * @function Phaser.Utils.Array.Range * @since 3.0.0 * - * @param {array} a - [description] - * @param {array} b - [description] - * @param {object} options - [description] + * @param {array} a - The first array of range elements. + * @param {array} b - The second array of range elements. + * @param {object} [options] - A range configuration object. Can contain: repeat, random, randomB, yoyo, max, qty. * - * @return {array} [description] + * @return {array} An array of arranged elements. */ var Range = function (a, b, options) { diff --git a/src/utils/array/SpliceOne.js b/src/utils/array/SpliceOne.js index 63bf8d565..25a7319bb 100644 --- a/src/utils/array/SpliceOne.js +++ b/src/utils/array/SpliceOne.js @@ -11,10 +11,10 @@ * @function Phaser.Utils.Array.SpliceOne * @since 3.0.0 * - * @param {array} array - [description] - * @param {integer} index - [description] + * @param {array} array - The array to splice from. + * @param {integer} index - The index of the item which should be spliced. * - * @return {*} [description] + * @return {*} The item which was spliced (removed). */ var SpliceOne = function (array, index) { diff --git a/src/utils/array/StableSort.js b/src/utils/array/StableSort.js index 8831aba5d..13d9be1cc 100644 --- a/src/utils/array/StableSort.js +++ b/src/utils/array/StableSort.js @@ -9,13 +9,33 @@ (function() { -// A stable array sort, because `Array#sort()` is not guaranteed stable. -// This is an implementation of merge sort, without recursion. - + /** + * A stable array sort, because `Array#sort()` is not guaranteed stable. + * This is an implementation of merge sort, without recursion. + * + * @function Phaser.Utils.Array.StableSort + * @since 3.0.0 + * + * @param {array} arr - The input array to be sorted. + * @param {function} comp - The comparison handler. + * + * @return {array} The sorted result. + */ var stable = function(arr, comp) { return exec(arr.slice(), comp); }; + /** + * Sort the input array and simply copy it back if the result isn't in the original array, which happens on an odd number of passes. + * + * @function Phaser.Utils.Array.StableSort.inplace + * @since 3.0.0 + * + * @param {array} arr - The input array. + * @param {function} comp - The comparison handler. + * + * @return {array} The sorted array. + */ stable.inplace = function(arr, comp) { var result = exec(arr, comp); diff --git a/src/utils/array/matrix/CheckMatrix.js b/src/utils/array/matrix/CheckMatrix.js index 130ec352a..c146672b2 100644 --- a/src/utils/array/matrix/CheckMatrix.js +++ b/src/utils/array/matrix/CheckMatrix.js @@ -5,27 +5,27 @@ */ /** -* A Matrix is simply an array of arrays, where each sub-array (the rows) have the same length: -* -* let matrix2 = [ -* [ 1, 1, 1, 1, 1, 1 ], -* [ 2, 0, 0, 0, 0, 4 ], -* [ 2, 0, 1, 2, 0, 4 ], -* [ 2, 0, 3, 4, 0, 4 ], -* [ 2, 0, 0, 0, 0, 4 ], -* [ 3, 3, 3, 3, 3, 3 ] -*]; -*/ - -/** - * [description] + * Checks if an array can be used as a matrix. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` * * @function Phaser.Utils.Array.Matrix.CheckMatrix * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - The array to check. * - * @return {boolean} [description] + * @return {boolean} `true` if the given `matrix` array is a valid matrix. */ var CheckMatrix = function (matrix) { diff --git a/src/utils/array/matrix/MatrixToString.js b/src/utils/array/matrix/MatrixToString.js index 450a92632..65dded167 100644 --- a/src/utils/array/matrix/MatrixToString.js +++ b/src/utils/array/matrix/MatrixToString.js @@ -7,18 +7,15 @@ var Pad = require('../../string/Pad'); var CheckMatrix = require('./CheckMatrix'); -// Generates a string (which you can pass to console.log) from the given -// Array Matrix. - /** - * [description] + * Generates a string (which you can pass to console.log) from the given Array Matrix. * * @function Phaser.Utils.Array.Matrix.MatrixToString * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - A 2-dimensional array. * - * @return {string} [description] + * @return {string} A string representing the matrix. */ var MatrixToString = function (matrix) { diff --git a/src/utils/array/matrix/ReverseColumns.js b/src/utils/array/matrix/ReverseColumns.js index a1c5c247c..216458caa 100644 --- a/src/utils/array/matrix/ReverseColumns.js +++ b/src/utils/array/matrix/ReverseColumns.js @@ -5,23 +5,18 @@ */ /** - * [description] + * Reverses the columns in the given Array Matrix. * * @function Phaser.Utils.Array.Matrix.ReverseColumns * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - The array matrix to reverse the columns for. * - * @return {array} [description] + * @return {array} The column reversed matrix. */ var ReverseColumns = function (matrix) { - for (var i = 0; i < matrix.length; i++) - { - matrix[i].reverse(); - } - - return matrix; + return matrix.reverse(); }; module.exports = ReverseColumns; diff --git a/src/utils/array/matrix/ReverseRows.js b/src/utils/array/matrix/ReverseRows.js index d1d5fe491..7986d1f09 100644 --- a/src/utils/array/matrix/ReverseRows.js +++ b/src/utils/array/matrix/ReverseRows.js @@ -5,18 +5,23 @@ */ /** - * [description] + * Reverses the rows in the given Array Matrix. * * @function Phaser.Utils.Array.Matrix.ReverseRows * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - The array matrix to reverse the rows for. * - * @return {array} [description] + * @return {array} The column reversed matrix. */ var ReverseRows = function (matrix) { - return matrix.reverse(); + for (var i = 0; i < matrix.length; i++) + { + matrix[i].reverse(); + } + + return matrix; }; module.exports = ReverseRows; diff --git a/src/utils/array/matrix/Rotate180.js b/src/utils/array/matrix/Rotate180.js index 708f5d334..cb202288c 100644 --- a/src/utils/array/matrix/Rotate180.js +++ b/src/utils/array/matrix/Rotate180.js @@ -7,14 +7,14 @@ var RotateMatrix = require('./RotateMatrix'); /** - * [description] + * Rotates the array matrix 180 degrees. * * @function Phaser.Utils.Array.Matrix.Rotate180 * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - The array to rotate. * - * @return {array} [description] + * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. */ var Rotate180 = function (matrix) { diff --git a/src/utils/array/matrix/RotateLeft.js b/src/utils/array/matrix/RotateLeft.js index cf23066bd..53b1b101e 100644 --- a/src/utils/array/matrix/RotateLeft.js +++ b/src/utils/array/matrix/RotateLeft.js @@ -7,14 +7,14 @@ var RotateMatrix = require('./RotateMatrix'); /** - * [description] + * Rotates the array matrix to the left (or 90 degrees) * * @function Phaser.Utils.Array.Matrix.RotateLeft * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - The array to rotate. * - * @return {array} [description] + * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. */ var RotateLeft = function (matrix) { diff --git a/src/utils/array/matrix/RotateMatrix.js b/src/utils/array/matrix/RotateMatrix.js index f2144e99e..940cc0794 100644 --- a/src/utils/array/matrix/RotateMatrix.js +++ b/src/utils/array/matrix/RotateMatrix.js @@ -4,19 +4,22 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. - var CheckMatrix = require('./CheckMatrix'); var TransposeMatrix = require('./TransposeMatrix'); /** - * [description] + * Rotates the array matrix based on the given rotation value. + * + * The value can be given in degrees: 90, -90, 270, -270 or 180, + * or a string command: `rotateLeft`, `rotateRight` or `rotate180`. + * + * Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. * * @function Phaser.Utils.Array.Matrix.RotateMatrix * @since 3.0.0 * * @param {array} matrix - The array to rotate. - * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. + * @param {(number|string)} [direction=90] - The amount to rotate the matrix by. * * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. */ diff --git a/src/utils/array/matrix/RotateRight.js b/src/utils/array/matrix/RotateRight.js index c4be6a1cf..73dec8d32 100644 --- a/src/utils/array/matrix/RotateRight.js +++ b/src/utils/array/matrix/RotateRight.js @@ -7,14 +7,14 @@ var RotateMatrix = require('./RotateMatrix'); /** - * [description] + * Rotates the array matrix to the left (or -90 degrees) * * @function Phaser.Utils.Array.Matrix.RotateRight * @since 3.0.0 * - * @param {array} matrix - [description] + * @param {array} matrix - The array to rotate. * - * @return {array} [description] + * @return {array} The rotated matrix array. The source matrix should be discard for the returned matrix. */ var RotateRight = function (matrix) { diff --git a/src/utils/array/matrix/TransposeMatrix.js b/src/utils/array/matrix/TransposeMatrix.js index 94446d255..cf8fab963 100644 --- a/src/utils/array/matrix/TransposeMatrix.js +++ b/src/utils/array/matrix/TransposeMatrix.js @@ -4,11 +4,10 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// Transposes the elements of the given matrix (array of arrays). -// The transpose of a matrix is a new matrix whose rows are the columns of the original. - /** - * [description] + * Transposes the elements of the given matrix (array of arrays). + * + * The transpose of a matrix is a new matrix whose rows are the columns of the original. * * @function Phaser.Utils.Array.Matrix.TransposeMatrix * @since 3.0.0 diff --git a/src/utils/object/Clone.js b/src/utils/object/Clone.js index c4274583b..821944fa2 100644 --- a/src/utils/object/Clone.js +++ b/src/utils/object/Clone.js @@ -7,7 +7,7 @@ /** * Shallow Object Clone. Will not clone nested objects. * - * @function Phaser.Utils.Object.Clone + * @function Phaser.Utils.Objects.Clone * @since 3.0.0 * * @param {object} obj - the object from which to clone diff --git a/src/utils/object/Extend.js b/src/utils/object/Extend.js index e5d729c0d..2406816e6 100644 --- a/src/utils/object/Extend.js +++ b/src/utils/object/Extend.js @@ -13,10 +13,10 @@ var IsPlainObject = require('./IsPlainObject'); /** * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ * - * @function Phaser.Utils.Object.Extend + * @function Phaser.Utils.Objects.Extend * @since 3.0.0 * - * @return {object} [description] + * @return {object} The extended object. */ var Extend = function () { diff --git a/src/utils/object/GetAdvancedValue.js b/src/utils/object/GetAdvancedValue.js index 74287b8b1..e373751a6 100644 --- a/src/utils/object/GetAdvancedValue.js +++ b/src/utils/object/GetAdvancedValue.js @@ -7,44 +7,45 @@ var MATH = require('../../math/const'); var GetValue = require('./GetValue'); -// Allowed types: - -// Implicit -// { -// x: 4 -// } -// -// From function -// { -// x: function () -// } -// -// Randomly pick one element from the array -// { -// x: [a, b, c, d, e, f] -// } -// -// Random integer between min and max: -// { -// x: { randInt: [min, max] } -// } -// -// Random float between min and max: -// { -// x: { randFloat: [min, max] } -// } - /** - * [description] + * Retrieves a value from an object. Allows for more advanced selection options, including: * - * @function Phaser.Utils.Object.GetAdvancedValue + * Allowed types: + * + * Implicit + * { + * x: 4 + * } + * + * From function + * { + * x: function () + * } + * + * Randomly pick one element from the array + * { + * x: [a, b, c, d, e, f] + * } + * + * Random integer between min and max: + * { + * x: { randInt: [min, max] } + * } + * + * Random float between min and max: + * { + * x: { randFloat: [min, max] } + * } + * + * + * @function Phaser.Utils.Objects.GetAdvancedValue * @since 3.0.0 * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param {*} defaultValue - The value to return if the `key` isn't found in the `source` object. * - * @return {*} [description] + * @return {*} The value of the requested key. */ var GetAdvancedValue = function (source, key, defaultValue) { diff --git a/src/utils/object/GetFastValue.js b/src/utils/object/GetFastValue.js index 9d8dc9640..cf95d37bc 100644 --- a/src/utils/object/GetFastValue.js +++ b/src/utils/object/GetFastValue.js @@ -7,7 +7,7 @@ /** * Finds the key within the top level of the {@link source} object, or returns {@link defaultValue} * - * @function Phaser.Utils.Object.GetFastValue + * @function Phaser.Utils.Objects.GetFastValue * @since 3.0.0 * * @param {object} source - The object to search diff --git a/src/utils/object/GetMinMaxValue.js b/src/utils/object/GetMinMaxValue.js index 867044873..562770b44 100644 --- a/src/utils/object/GetMinMaxValue.js +++ b/src/utils/object/GetMinMaxValue.js @@ -8,18 +8,18 @@ var GetValue = require('./GetValue'); var Clamp = require('../../math/Clamp'); /** - * [description] + * Retrieves and clamps a numerical value from an object. * - * @function Phaser.Utils.Object.GetMinMaxValue + * @function Phaser.Utils.Objects.GetMinMaxValue * @since 3.0.0 * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {number} min - [description] - * @param {number} max - [description] - * @param {number} defaultValue - [description] + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`). + * @param {number} min - The minimum value which can be returned. + * @param {number} max - The maximum value which can be returned. + * @param {number} defaultValue - The value to return if the property doesn't exist. It's also constrained to the given bounds. * - * @return {number} [description] + * @return {number} The clamped value from the `source` object. */ var GetMinMaxValue = function (source, key, min, max, defaultValue) { diff --git a/src/utils/object/GetValue.js b/src/utils/object/GetValue.js index fa33e691c..1d495dfbb 100644 --- a/src/utils/object/GetValue.js +++ b/src/utils/object/GetValue.js @@ -9,16 +9,16 @@ // The default value to use if the key doesn't exist /** - * [description] + * Retrieves a value from an object. * - * @function Phaser.Utils.Object.GetValue + * @function Phaser.Utils.Objects.GetValue * @since 3.0.0 * - * @param {object} source - [description] - * @param {string} key - [description] - * @param {*} defaultValue - [description] + * @param {object} source - The object to retrieve the value from. + * @param {string} key - The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param {*} defaultValue - The value to return if the `key` isn't found in the `source` object. * - * @return {*} [description] + * @return {*} The value of the requested key. */ var GetValue = function (source, key, defaultValue) { diff --git a/src/utils/object/HasAll.js b/src/utils/object/HasAll.js index fa10fc25c..769fc67bf 100644 --- a/src/utils/object/HasAll.js +++ b/src/utils/object/HasAll.js @@ -7,7 +7,7 @@ /** * Verifies that an object contains all requested keys * - * @function Phaser.Utils.Object.HasAll + * @function Phaser.Utils.Objects.HasAll * @since 3.0.0 * * @param {object} source - an object on which to check for key existence diff --git a/src/utils/object/HasAny.js b/src/utils/object/HasAny.js index cd67b6ffb..3d43d87e8 100644 --- a/src/utils/object/HasAny.js +++ b/src/utils/object/HasAny.js @@ -7,7 +7,7 @@ /** * Verifies that an object contains at least one of the requested keys * - * @function Phaser.Utils.Object.HasAny + * @function Phaser.Utils.Objects.HasAny * @since 3.0.0 * * @param {object} source - an object on which to check for key existence diff --git a/src/utils/object/HasValue.js b/src/utils/object/HasValue.js index cc58f9f98..3a4dd6d76 100644 --- a/src/utils/object/HasValue.js +++ b/src/utils/object/HasValue.js @@ -5,15 +5,15 @@ */ /** - * [description] + * Determine whether the source object has a property with the specified key. * - * @function Phaser.Utils.Object.HasValue + * @function Phaser.Utils.Objects.HasValue * @since 3.0.0 * - * @param {object} source - [description] - * @param {string} key - [description] + * @param {object} source - The source object to be checked. + * @param {string} key - The property to check for within the object * - * @return {boolean} [description] + * @return {boolean} `true` if the provided `key` exists on the `source` object, otherwise `false`. */ var HasValue = function (source, key) { diff --git a/src/utils/object/IsPlainObject.js b/src/utils/object/IsPlainObject.js index b67480e0c..5df7280f7 100644 --- a/src/utils/object/IsPlainObject.js +++ b/src/utils/object/IsPlainObject.js @@ -8,7 +8,7 @@ * This is a slightly modified version of jQuery.isPlainObject. * A plain object is an object whose internal class property is [object Object]. * - * @function Phaser.Utils.Object.IsPlainObject + * @function Phaser.Utils.Objects.IsPlainObject * @since 3.0.0 * * @param {object} obj - The object to inspect. diff --git a/src/utils/object/Merge.js b/src/utils/object/Merge.js index afa7fb772..597371782 100644 --- a/src/utils/object/Merge.js +++ b/src/utils/object/Merge.js @@ -10,13 +10,13 @@ var Clone = require('./Clone'); * Creates a new Object using all values from obj1 and obj2. * If a value exists in both obj1 and obj2, the value in obj1 is used. * - * @function Phaser.Utils.Object.Merge + * @function Phaser.Utils.Objects.Merge * @since 3.0.0 * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] + * @param {object} obj1 - The first object. + * @param {object} obj2 - The second object. * - * @return {object} [description] + * @return {object} A new object containing the union of obj1's and obj2's properties. */ var Merge = function (obj1, obj2) { diff --git a/src/utils/object/MergeRight.js b/src/utils/object/MergeRight.js index 7df1eca82..1f347692c 100644 --- a/src/utils/object/MergeRight.js +++ b/src/utils/object/MergeRight.js @@ -11,13 +11,13 @@ var Clone = require('./Clone'); * * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. * - * @function Phaser.Utils.Object.MergeRight + * @function Phaser.Utils.Objects.MergeRight * @since 3.0.0 * - * @param {object} obj1 - [description] - * @param {object} obj2 - [description] + * @param {object} obj1 - The first object to merge. + * @param {object} obj2 - The second object to merge. Keys from this object which also exist in `obj1` will be copied to `obj1`. * - * @return {object} [description] + * @return {object} The merged object. `obj1` and `obj2` are not modified. */ var MergeRight = function (obj1, obj2) { diff --git a/src/utils/string/UUID.js b/src/utils/string/UUID.js new file mode 100644 index 000000000..285e3f8b2 --- /dev/null +++ b/src/utils/string/UUID.js @@ -0,0 +1,29 @@ +/** + * @author Richard Davey + * @copyright 2018 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * Creates and returns an RFC4122 version 4 compliant UUID. + * + * The string is in the form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` where each `x` is replaced with a random + * hexadecimal digit from 0 to f, and `y` is replaced with a random hexadecimal digit from 8 to b. + * + * @function Phaser.Utils.String.UUID + * @since 3.12.0 + * + * @return {string} The UUID string. + */ +var UUID = function () +{ + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) + { + var r = Math.random() * 16 | 0; + var v = (c === 'x') ? r : (r & 0x3 | 0x8); + + return v.toString(16); + }); +}; + +module.exports = UUID; diff --git a/src/utils/string/index.js b/src/utils/string/index.js index ed2e39218..61f43a75a 100644 --- a/src/utils/string/index.js +++ b/src/utils/string/index.js @@ -13,6 +13,7 @@ module.exports = { Format: require('./Format'), Pad: require('./Pad'), Reverse: require('./Reverse'), - UppercaseFirst: require('./UppercaseFirst') + UppercaseFirst: require('./UppercaseFirst'), + UUID: require('./UUID') }; diff --git a/webpack.config.js b/webpack.config.js index 229d86f99..49f279177 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,8 +9,7 @@ module.exports = { context: `${__dirname}/src/`, entry: { - phaser: './phaser.js', - 'phaser-core': './phaser-core.js' + phaser: './phaser.js' }, output: { @@ -29,7 +28,10 @@ module.exports = { plugins: [ new webpack.DefinePlugin({ "typeof CANVAS_RENDERER": JSON.stringify(true), - "typeof WEBGL_RENDERER": JSON.stringify(true) + "typeof WEBGL_RENDERER": JSON.stringify(true), + "typeof EXPERIMENTAL": JSON.stringify(true), + "typeof PLUGIN_CAMERA3D": JSON.stringify(false), + "typeof PLUGIN_FBINSTANT": JSON.stringify(false) }), { apply: (compiler) => { diff --git a/webpack.dist.config.js b/webpack.dist.config.js index 0af006e6d..a6795dc9d 100644 --- a/webpack.dist.config.js +++ b/webpack.dist.config.js @@ -13,9 +13,7 @@ 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-core': './phaser-core.js', - 'phaser-core.min': './phaser-core.js' + 'phaser-arcade-physics.min': './phaser-arcade-physics.js' }, output: { @@ -49,7 +47,10 @@ module.exports = { plugins: [ new webpack.DefinePlugin({ "typeof CANVAS_RENDERER": JSON.stringify(true), - "typeof WEBGL_RENDERER": JSON.stringify(true) + "typeof WEBGL_RENDERER": JSON.stringify(true), + "typeof EXPERIMENTAL": JSON.stringify(false), + "typeof PLUGIN_CAMERA3D": JSON.stringify(false), + "typeof PLUGIN_FBINSTANT": JSON.stringify(false) }), new CleanWebpackPlugin([ 'dist' ]) diff --git a/webpack.fb.config.js b/webpack.fb.config.js new file mode 100644 index 000000000..6dd6d0503 --- /dev/null +++ b/webpack.fb.config.js @@ -0,0 +1,49 @@ +'use strict'; + +const webpack = require('webpack'); +const exec = require('child_process').exec; + +module.exports = { + mode: 'development', + + context: `${__dirname}/src/`, + + entry: { + phaser: './phaser.js' + }, + + output: { + path: `${__dirname}/build/`, + filename: 'phaser-facebook-instant-games.js', + library: 'Phaser', + libraryTarget: 'umd', + sourceMapFilename: '[file].map', + devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string + devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string + umdNamedDefine: true + }, + + performance: { hints: false }, + + plugins: [ + new webpack.DefinePlugin({ + "typeof CANVAS_RENDERER": JSON.stringify(true), + "typeof WEBGL_RENDERER": JSON.stringify(true), + "typeof EXPERIMENTAL": JSON.stringify(false), + "typeof PLUGIN_CAMERA3D": JSON.stringify(false), + "typeof PLUGIN_FBINSTANT": JSON.stringify(true) + }), + { + apply: (compiler) => { + compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => { + exec('node scripts/copy-to-examples-fb.js', (err, stdout, stderr) => { + if (stdout) process.stdout.write(stdout); + if (stderr) process.stderr.write(stderr); + }); + }); + } + } + ], + + devtool: 'source-map' +}; diff --git a/webpack.fb.dist.config.js b/webpack.fb.dist.config.js new file mode 100644 index 000000000..473a43970 --- /dev/null +++ b/webpack.fb.dist.config.js @@ -0,0 +1,53 @@ +'use strict'; + +const webpack = require('webpack'); +const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); + +module.exports = { + mode: 'production', + + context: `${__dirname}/src/`, + + entry: { + 'phaser-facebook-instant-games': './phaser.js', + 'phaser-facebook-instant-games.min': './phaser.js' + }, + + output: { + path: `${__dirname}/dist/`, + filename: '[name].js', + library: 'Phaser', + libraryTarget: 'umd', + umdNamedDefine: true + }, + + performance: { hints: false }, + + optimization: { + minimizer: [ + new UglifyJSPlugin({ + include: /\.min\.js$/, + parallel: true, + sourceMap: false, + uglifyOptions: { + compress: true, + ie8: false, + ecma: 5, + output: {comments: false}, + warnings: false + }, + warningsFilter: () => false + }) + ] + }, + + plugins: [ + new webpack.DefinePlugin({ + "typeof CANVAS_RENDERER": JSON.stringify(true), + "typeof WEBGL_RENDERER": JSON.stringify(true), + "typeof EXPERIMENTAL": JSON.stringify(false), + "typeof PLUGIN_CAMERA3D": JSON.stringify(false), + "typeof PLUGIN_FBINSTANT": JSON.stringify(true) + }) + ] +};